@deepdesk/deepdesk-sdk 10.1.6 → 10.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -1,6 +1,6 @@
1
- var Up=Object.defineProperty;var U=(t,e)=>{for(var o in e)Up(t,o,{get:e[o],enumerable:!0})};import Wn from"classnames";import Wp,{createContext as Gp,useContext as Gn,useEffect as $p,useState as Xp}from"react";import zp,{useContext as jp}from"react";import Vp from"classnames";var Mt=zp.createContext({});function y(t,e){let{debug:o,...n}=jp(Mt),s=n[t];return s?Object.entries(e).reduce((r,[i,a])=>{let l=s[i];return{...r,[i]:Vp(a,l,o?`${t}__${i}`:!1)}},{}):e}var Kr={root:"_root_vr71j_1"};import{jsx as yo,jsxs as qp}from"react/jsx-runtime";var Ur=()=>qp("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=Gp(qn),Qp=({title:t,src:e})=>{let o=Gn(So),[n,s]=Xp(!1);return $p(()=>{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,{})})},Zp=({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})},Jp=({as:t="h1",cropText:e=!1,className:o,children:n})=>{let s=Gn(So);return Wp.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=Qp;vo.Content=Zp;vo.Title=Jp;var H=vo;var zr={root:"_root_nkim0_1"};import{createContext as pu,useContext as uu}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:su,n=e&&e.serializer?e.serializer:nu,s=e&&e.strategy?e.strategy:eu;return s(t,{cache:o,serializer:n})}function Yp(t){return t==null||typeof t=="number"||typeof t=="boolean"}function Gr(t,e,o,n){var s=Yp(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 eu(t,e){var o=t.length===1?Gr:$r;return Zn(t,this,o,e.cache.create(),e.serializer)}function tu(t,e){return Zn(t,this,$r,e.cache.create(),e.serializer)}function ou(t,e){return Zn(t,this,Gr,e.cache.create(),e.serializer)}var nu=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 su={create:function(){return new Jn}},Ao={variadic:tu,monadic:ou};var Ke;(function(t){t.MISSING_VALUE="MISSING_VALUE",t.INVALID_VALUE="INVALID_VALUE",t.MISSING_INTL_API="MISSING_INTL_API"})(Ke||(Ke={}));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('", "'),'"'),Ke.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),Ke.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,'"'),Ke.MISSING_VALUE,n)||this}return e}(Dt);var z;(function(t){t[t.literal=0]="literal",t[t.object=1]="object"})(z||(z={}));function ru(t){return t.length<2?t:t.reduce(function(e,o){var n=e[e.length-1];return!n||n.type!==z.literal||o.type!==z.literal?e.push(o):n.value+=o.value,e},[])}function iu(t){return typeof t=="function"}function Ht(t,e,o,n,s,r,i){if(t.length===1&&Xn(t[0]))return[{type:z.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:z.literal,value:p.value});continue}if(qr(p)){typeof r=="number"&&a.push({type:z.literal,value:o.getNumberFormat(e).format(r)});continue}var u=p.value;if(!(s&&u in s))throw new Qr(u,i);var d=s[u];if(Vr(p)){(!d||typeof d=="string"||typeof d=="number")&&(d=typeof d=="string"||typeof d=="number"?String(d):""),a.push({type:typeof d=="string"?z.literal:z.object,value:d});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:z.literal,value:o.getDateTimeFormat(e,g).format(d)});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:z.literal,value:o.getDateTimeFormat(e,g).format(d)});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&&(d=d*(g.scale||1)),a.push({type:z.literal,value:o.getNumberFormat(e,g).format(d)});continue}if(Io(p)){var h=p.children,m=p.value,_=s[m];if(!iu(_))throw new Xr(m,"function",i);var w=Ht(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"?z.literal:z.object,value:k}}))}if(ko(p)){var v=p.options[d]||p.options.other;if(!v)throw new Yn(p.value,d,Object.keys(p.options),i);a.push.apply(a,Ht(v.value,e,o,n,s));continue}if(Po(p)){var v=p.options["=".concat(d)];if(!v){if(!Intl.PluralRules)throw new Dt(`Intl.PluralRules is not available in this environment.
1
+ var zp=Object.defineProperty;var z=(t,e)=>{for(var o in e)zp(t,o,{get:e[o],enumerable:!0})};import $n from"classnames";import Gp,{createContext as $p,useContext as Xn,useEffect as Xp,useState as Qp}from"react";import jp,{useContext as Vp}from"react";import qp from"classnames";var Ot=jp.createContext({});function y(t,e){let{debug:o,...n}=Vp(Ot),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 jr={root:"_root_vr71j_1"};import{jsx as So,jsxs as Wp}from"react/jsx-runtime";var vo=()=>Wp("svg",{className:jr.root,width:"185",height:"170",viewBox:"0 0 185 170",xmlns:"http://www.w3.org/2000/svg",children:[So("defs",{children:So("style",{children:".cls-1 { fill: #b3b3b3; }"})}),So("title",{children:"Failed loading image"}),So("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 Gn={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 et}from"react/jsx-runtime";var _o=$p(Gn),Zp=({title:t,src:e})=>{let o=Xn(_o),[n,s]=Qp(!1);return Xp(()=>{s(!1)},[e]),et("div",{className:o.imageWrapper,children:e&&!n?et("img",{className:o.image,alt:t,src:e,onError:()=>s(!0)}):et(vo,{})})},Jp=({className:t,lineClamp:e=!1,cropText:o=!1,children:n})=>{let s=Xn(_o);return et("div",{className:$n(s.content,t,{[s.contentIsCropped]:o,[s.lineClamp]:e}),children:n})},Yp=({as:t="h1",cropText:e=!1,className:o,children:n})=>{let s=Xn(_o);return Gp.createElement(t,{className:$n(s.title,o,{[s.contentIsCropped]:e})},n)},xo=({children:t})=>{let e=y("Card",Gn);return et("div",{className:$n(e.root),children:et(_o.Provider,{value:e,children:t})})};xo.Image=Zp;xo.Content=Jp;xo.Title=Yp;var H=xo;var Vr={root:"_root_nkim0_1"};import{createContext as uu,useContext as du}from"react";var Qn=function(t,e){return Qn=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])},Qn(t,e)};function Nt(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");Qn(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 qr(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 bo(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 Co;(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"})(Co||(Co={}));var wo=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 To;(function(t){t[t.number=0]="number",t[t.dateTime=1]="dateTime"})(To||(To={}));function Zn(t){return t.type===re.literal}function Wr(t){return t.type===re.argument}function Eo(t){return t.type===re.number}function ko(t){return t.type===re.date}function Po(t){return t.type===re.time}function Io(t){return t.type===re.select}function Ro(t){return t.type===re.plural}function Gr(t){return t.type===re.pound}function Lo(t){return t.type===re.tag}function Ao(t){return!!(t&&typeof t=="object"&&t.type===To.number)}function Dt(t){return!!(t&&typeof t=="object"&&t.type===To.dateTime)}function Jn(t){t.forEach(function(e){if(delete e.location,Io(e)||Ro(e))for(var o in e.options)delete e.options[o].location,Jn(e.options[o].value);else Eo(e)&&Ao(e.style)||(ko(e)||Po(e))&&Dt(e.style)?delete e.style.location:Lo(e)&&Jn(e.children)})}function $r(t,e){e===void 0&&(e={}),e=Z({shouldParseSkeletons:!0,requiresOtherClause:!0},e);var o=new wo(t,e).parse();if(o.err){var n=SyntaxError(Co[o.err.kind]);throw n.location=o.err.location,n.originalMessage=o.err.message,n}return e!=null&&e.captureLocation||Jn(o.val),o.val}function Mo(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 Xr(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 Qr(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 Yn(t,e,o,n,s){return o.bind(e,t,n,s)}function tu(t,e){var o=t.length===1?Xr:Qr;return Yn(t,this,o,e.cache.create(),e.serializer)}function ou(t,e){return Yn(t,this,Qr,e.cache.create(),e.serializer)}function nu(t,e){return Yn(t,this,Xr,e.cache.create(),e.serializer)}var su=function(){return JSON.stringify(arguments)};function es(){this.cache=Object.create(null)}es.prototype.get=function(t){return this.cache[t]};es.prototype.set=function(t,e){this.cache[t]=e};var ru={create:function(){return new es}},Oo={variadic:ou,monadic:nu};var Ke;(function(t){t.MISSING_VALUE="MISSING_VALUE",t.INVALID_VALUE="INVALID_VALUE",t.MISSING_INTL_API="MISSING_INTL_API"})(Ke||(Ke={}));var Ht=function(t){Nt(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 ts=function(t){Nt(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('", "'),'"'),Ke.INVALID_VALUE,r)||this}return e}(Ht);var Zr=function(t){Nt(e,t);function e(o,n,s){return t.call(this,'Value for "'.concat(o,'" must be of type ').concat(n),Ke.INVALID_VALUE,s)||this}return e}(Ht);var Jr=function(t){Nt(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,'"'),Ke.MISSING_VALUE,n)||this}return e}(Ht);var j;(function(t){t[t.literal=0]="literal",t[t.object=1]="object"})(j||(j={}));function iu(t){return t.length<2?t:t.reduce(function(e,o){var n=e[e.length-1];return!n||n.type!==j.literal||o.type!==j.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&&Zn(t[0]))return[{type:j.literal,value:t[0].value}];for(var a=[],l=0,c=t;l<c.length;l++){var p=c[l];if(Zn(p)){a.push({type:j.literal,value:p.value});continue}if(Gr(p)){typeof r=="number"&&a.push({type:j.literal,value:o.getNumberFormat(e).format(r)});continue}var u=p.value;if(!(s&&u in s))throw new Jr(u,i);var d=s[u];if(Wr(p)){(!d||typeof d=="string"||typeof d=="number")&&(d=typeof d=="string"||typeof d=="number"?String(d):""),a.push({type:typeof d=="string"?j.literal:j.object,value:d});continue}if(ko(p)){var m=typeof p.style=="string"?n.date[p.style]:Dt(p.style)?p.style.parsedOptions:void 0;a.push({type:j.literal,value:o.getDateTimeFormat(e,m).format(d)});continue}if(Po(p)){var m=typeof p.style=="string"?n.time[p.style]:Dt(p.style)?p.style.parsedOptions:n.time.medium;a.push({type:j.literal,value:o.getDateTimeFormat(e,m).format(d)});continue}if(Eo(p)){var m=typeof p.style=="string"?n.number[p.style]:Ao(p.style)?p.style.parsedOptions:void 0;m&&m.scale&&(d=d*(m.scale||1)),a.push({type:j.literal,value:o.getNumberFormat(e,m).format(d)});continue}if(Lo(p)){var h=p.children,g=p.value,v=s[g];if(!au(v))throw new Zr(g,"function",i);var E=Bt(h,e,o,n,s,r),f=v(E.map(function(w){return w.value}));Array.isArray(f)||(f=[f]),a.push.apply(a,f.map(function(w){return{type:typeof w=="string"?j.literal:j.object,value:w}}))}if(Io(p)){var _=p.options[d]||p.options.other;if(!_)throw new ts(p.value,d,Object.keys(p.options),i);a.push.apply(a,Bt(_.value,e,o,n,s));continue}if(Ro(p)){var _=p.options["=".concat(d)];if(!_){if(!Intl.PluralRules)throw new Ht(`Intl.PluralRules is not available in this environment.
2
2
  Try polyfilling it using "@formatjs/intl-pluralrules"
3
- `,Ke.MISSING_INTL_API,i);var x=o.getPluralRules(e,{type:p.pluralType}).select(d-(p.offset||0));v=p.options[x]||p.options.other}if(!v)throw new Yn(p.value,d,Object.keys(p.options),i);a.push.apply(a,Ht(v.value,e,o,n,s,d-(p.offset||0)));continue}}return ru(a)}function au(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 lu(t,e){return e?Object.keys(t).reduce(function(o,n){return o[n]=au(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 cu(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 u=p.reduce(function(d,g){return!d.length||g.type!==z.literal||typeof d[d.length-1]!="string"?d.push(g.value):d[d.length-1]+=g.value,d},[]);return u.length<=1?u[0]||"":u},this.formatToParts=function(c){return Ht(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=lu(t.formats,n),this.formatters=s&&s.formatters||cu(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 du(t,e){return e.split(".").reduce((o,n)=>o?o[n]:void 0,t)}var mu="dummy",ts=pu(null);function T(t){let e=uu(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=du(o,n);return r?new Zr(r).format(s):(e!==mu&&console.warn(`${n} does not exist in messages of ${e}`),`[${n}]`)}}var os={};U(os,{enUS:()=>gu,nlNL:()=>fu});var gu={experimental:[{type:0,value:"Experimental"}]},fu={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")})},hu=Jr;import yu from"classnames";var ei={root:"_root_cq1yq_1"};import{jsx as _u}from"react/jsx-runtime";var Su={"arrow-up":"\u25B2","arrow-down":"\u25BC",tab:"tab",esc:"Esc",enter:"\u21B5"},vu=({className:t,keyCode:e,...o})=>{let n=y("KeyboardHint",ei);return _u("span",{"data-key":Su[e],className:yu(t,n.root),...o})},ns=vu;import xu from"classnames";var ti={root:"_root_4a08n_1"};import{jsx as Cu}from"react/jsx-runtime";var bu=({className:t,children:e,...o})=>{let n=y("Label",ti);return Cu("span",{...o,className:xu(t,n.root),children:e})},ss=bu;var oi={root:"_root_jlggj_1",subTitleContainer:"_subTitleContainer_jlggj_5",subtitle:"_subtitle_jlggj_9",suggestions:"_suggestions_jlggj_17"};import{jsx as rs,jsxs as Tu}from"react/jsx-runtime";var wu=({title:t,children:e,type:o,...n})=>{let s=y("Section",oi);return Tu("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})]})},Ue=wu;import Eu from"classnames";import ku from"react";var ni={root:"_root_19wxp_1"};import{jsx as Iu}from"react/jsx-runtime";var Pu=ku.forwardRef(({className:t,children:e},o)=>{let n=y("SectionList",ni);return Iu("div",{ref:o,className:Eu(n.root,t),children:e})}),is=Pu;import Oo from"classnames";import Ru,{createContext as Lu,useCallback as Au,useContext as Bt}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 me,jsxs as Hu}from"react/jsx-runtime";var et=Lu(as),Mu=({fixed:t,children:e,...o})=>{let n=Bt(et);return me("div",{...o,className:Oo(n.actions,{[n.actionsIsFixed]:t}),children:e})},Ou=({className:t,primary:e,disabled:o,label:n,children:s})=>{let r=Bt(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,me("ul",{className:r.dropdownList,children:s})]})},Nu=({index:t,label:e,onClick:o})=>{let n=Bt(et);return me("li",{className:n.dropdownItem,children:me("button",{className:n.dropdownItemButton,type:"button","data-index":t,onClick:o,children:e})})},Du=({className:t,primary:e,disabled:o,onClick:n,label:s})=>{let r=Bt(et);return me("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=Bt(et);return me("div",{className:e.labels,children:t.map(o=>me("span",{className:e.label,children:o},o))})},tt=Ru.forwardRef(({className:t,selected:e,onClick:o,children:n,as:s="div",...r},i)=>{let a=y("Suggestion",as),l=Au(c=>{c.preventDefault(),o&&o(c)},[o]);return me(s,{...r,ref:i,className:Oo(t,a.root,{[a.isSelected]:e,[a.isClickable]:!!o}),onClick:l,children:me(et.Provider,{value:a,children:n})})});tt.Labels=ls;tt.Actions=Mu;tt.ActionButton=Du;tt.DropdownButton=Ou;tt.DropdownItem=Nu;var N=tt;import Bu from"classnames";var si={root:"_root_fp74r_1",isWithDivider:"_isWithDivider_fp74r_9"};import{jsx as Ku}from"react/jsx-runtime";var Fu=({withDivider:t,children:e})=>{let o=y("SuggestionList",si);return Ku("div",{className:Bu(o.root,{[o.isWithDivider]:t}),children:e})},ge=Fu;import Uu from"classnames";var ri={root:"_root_1wpmq_1",isCollapsed:"_isCollapsed_1wpmq_17"};import{jsx as cs}from"react/jsx-runtime";var zu=({className:t,isCollapsed:e,title:o,onClick:n})=>{let s=y("ToggleButton",ri);return cs("button",{type:"button",className:Uu(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=zu;var ii=/(?:[.,;:!?\\n]|:\\)|:\\(|:-\\)|:-\\()/g,nt=/(((\$!\{)|(\{))[a-zA-Z0-9_.]+\})/g;var ai=/x-deepdesk-(([a-z0-9\-_])+-version)/,fe=(m=>(m.SEARCH="search",m.TEMPLATE="template",m.ELASTIC_SEARCH="search-autocomplete",m.GPT="gpt",m.TRIE="trie",m.TRIE_WITH_TYPOS="trie-with-typos",m.SEMANTIC="semantic",m.TEXT_RECOMMENDATION="text_recommendation",m.URL_RECOMMENDATION="url_recommendation",m.LINK_RECOMMENDATION="link_recommendation",m.PERSONAL_COLLECTION="personal-collection",m.PERSONAL_COLLECTION_SEARCH="personal-collection-search",m.SEARCH_OVERLAY="search-overlay",m.SEARCH_PREVIEW="search-preview",m.SEARCH_URL="search-url",m))(fe||{}),ze=(s=>(s.TAB="tab",s.ARROW="arrow",s.HOTKEY="hotkey",s.MOUSE="mouse",s))(ze||{});import{render as Kn,unmountComponentAtNode as Br}from"react-dom";import{Fragment as Bg}from"react";import{createSlice as ju}from"@reduxjs/toolkit";import{useSelector as Vu}from"react-redux";var No=(o=>(o.NL_NL="nl-NL",o.EN_US="en-US",o))(No||{});var qu={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=ju({name:"settings",initialState:qu,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=>Vu(ps(t)),ci=li.reducer;import{useState as Tm}from"react";import{useDispatch as Em,useSelector as zs}from"react-redux";import{createAction as je,createSlice as Yu}from"@reduxjs/toolkit";import{diffChars as ed}from"diff";import{useSelector as td}from"react-redux";function pi(t){return typeof t=="object"&&!Array.isArray(t)&&t!==null}function Ie(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)=>Ie(r,e[i],o-1)):pi(t)&&pi(e)?Object.keys(t).length!==Object.keys(e).length?!1:Object.keys(t).every(i=>Ie(t[i],e[i],o-1)):!1}function Wu(t){return Math.max(...t.map(e=>e.length))}function Gu(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<Wu(n);s++){let r=Gu(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 $u=2;function us(t,e=""){if(t.length===0)return;if(t.length===1)return t[0];let o=ui(t,$u);return o&&o.text!==e?o:t[0]}import{createAction as Xu,createAsyncThunk as st,createSlice as Qu}from"@reduxjs/toolkit";var di={current:null,isSupported:null},I=Xu("resetConversation"),Do=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.sessionId)||null},Ho=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.id)||null},Bo=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=Ho(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=Ho(e.getState());if(!n)throw new Error("No current conversation to update messages");return o.postMessages(n,t.map(s=>({...s})))}),Zu=[Fo.rejected,Ko.rejected,Uo.rejected,zo.rejected].map(t=>t==null?void 0:t.toString()),Ju=Qu({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=>Zu.includes(e.type),(e,o)=>{throw new Error(o.error.message)})}}),mi=Ju.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,externalTimeTotalSeconds: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,searchTerm:a,text:l},eventMetrics:{inputType:c},replace:p}=t.stagedSuggestion,u=o==="search"||o==="personal-collection-search",d=e.slice(t.userCommitted.text.substring(0,t.userCommitted.selection.start).length);(u||p==="selection")&&(d=e),t.stagedSuggestion.suggestion.source==="search-overlay"&&(d=l),t.userCommitted.text=t.text,t.userCommitted.selection=t.selection,t.metrics.textSuggestions.push({text:d,source:o,abVariant:n,abTestName:s,inputType:c,sourceText:i,trainingJobs:r||[],searchTerm:u?t.userCommitted.text:a}),t.stagedSuggestion=null,t.textSuggestions=[],t.selectedSuggestionIndex=-1}var gi=t=>Yu({name:t,initialState:Re,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,{...Re,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&&(Ie(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:u,ctrlKey:d,metaKey:g,altKey:h}=e.previousKeyDownEvent;switch(p){case"Enter":u&&(e.metrics.numCharsTyped+=1);break;case"Backspace":case"Delete":{let{text:m}=e,{text:_}=o.payload,w=ed(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(!d&&!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(!d&&!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=Re.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}){let n=o.agentStartedTypingTimestamp!=null?o.agentStartedTypingTimestamp:Date.now(),s=(Date.now()-n)/1e3;e.metrics.externalTimeTotalSeconds=s,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=Re.tabCompletionSuggestion,o.previousKeyDownEvent=Re.previousKeyDownEvent,o.textSuggestions=Re.textSuggestions,o.selectedSuggestionIndex=Re.selectedSuggestionIndex,o.metrics=Re.metrics})}}),gs=gi("input"),rt=t=>t.input.userCommitted.text.substring(0,t.input.userCommitted.selection.end),od=t=>t.input.selection,fi=()=>td(od),{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:Le,stageSuggestion:ie,commitSuggestion:Ae}=gs.actions,W=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 nd=({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 d,g;let p=h=>{h.key==="Escape"&&(h.preventDefault(),h.stopPropagation(),s())},u=h=>{let m=window.getSelection();m!=null&&m.toString()||h.target===a.current&&t&&n()};return(d=a.current)==null||d.addEventListener("click",u),(g=a.current)==null||g.addEventListener("keyup",p),()=>{var h,m;(h=a.current)==null||h.removeEventListener("click",u),(m=a.current)==null||m.removeEventListener("keyup",p)}},[a,l,s,n]),Pi(()=>{var p,u;!a.current||!t||!e||(u=(p=a.current)==null?void 0:p.querySelector("input, textarea"))==null||u.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=nd;import{useEffect as va}from"react";import{useDispatch as im,useSelector as am}from"react-redux";var hs={};U(hs,{enUS:()=>sd,nlNL:()=>rd});var sd={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?"}]},rd={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 id}from"react/jsx-runtime";var Zo=()=>id("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 ad}from"react/jsx-runtime";var Oi=()=>ad("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 wd}from"react";import{useDispatch as Td}from"react-redux";import{Interweave as Ed}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 ud}from"interweave";import dd from"classnames";import{useEffect as ld,useRef as cd,useState as pd}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=cd(null),[o,n]=pd(!1);return ld(()=>{let s=!1,r=parseFloat(window.getComputedStyle(document.body).zoom??"1"),[i,a]=Ni((p,u)=>{let d=e.current;if(!d)return;let g=p/r,h=u/r,m=d.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:u})=>[p,u]),[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 te={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 md=({inputElement:t,children:e})=>{let o=y("TabCompletion",te),[n,s]=Jo(t);return Di("mark",{ref:n,className:dd(o.matchPlaceholder,{[o.hover]:s}),children:e})},at=class extends ud{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(md,{inputElement:o.inputElement,children:e},`placeholder_${o.matchString}_${o.key}`)}asTag(){return"mark"}};import{useEffect as gd,useRef as fd,useState as hd}from"react";function Yo(t){return t.contentEditable==="true"}function yd(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 Hi(t){let{selectionStart:e,selectionEnd:o}=Yo(t)?yd(t):t;return[e,o]}function en(t){let[,e]=hd(),o=fd(null);return o.current=Hi(t),gd(()=>{let n=()=>{let[s,r]=o.current??[],i=Hi(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 Sd}from"react";function lt(t){Sd(()=>{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 Bi,le=new Map,vd=["bottom","height","left","right","top","width"],_d=(t={},e={})=>vd.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();_d(n,e.rect)&&(e.rect=n,t.push(e))}),t.forEach(e=>{e.callbacks.forEach(o=>o(e.rect))}),le.size!==0&&(Bi=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(Bi)}}}}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(),u=window.getComputedStyle(e.closestScrollElement),d=ct(u.borderTopWidth),g=ct(u.borderBottomWidth),h=p.top+d-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={};U(xs,{enUS:()=>xd,nlNL:()=>bd});var xd={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"}]},bd={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 Cd}from"react/jsx-runtime";var Wi=()=>Cd("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||{}),Me=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;Ie(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 Oe=class extends Me{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 he,jsxs as bs}from"react/jsx-runtime";var kd=({value:t,onUse:e,...o})=>{var p;let n=T(xs),s=Td(),r=y("EditSuggestionTextInput",ys),[i,a]=wd(null),l=Cs(null),c=((p=t.match(nt))==null?void 0:p.length)||0;return jt(()=>{let u;return l.current&&(a(l.current),u=new Oe(l.current),u.on("change",({plainText:d})=>{s(W.actions.userInput({text:d,selection:u.getSelection()}))}),u.on("keydown",d=>{s(W.actions.registerKeyDown(Vo(d))),d.code==="Enter"&&d.shiftKey&&e(u.getText())}),u.on("paste",({pastedText:d,selectionText:g})=>{s(W.actions.registerPaste({text:d,selectionText:g}))}),u.on("cut",({selectionText:d})=>{s(W.actions.registerCut(d))})),()=>{s(W.actions.reset()),u.dispose(),u.deactivate()}},[l]),jt(()=>{t&&l.current&&(l.current.value=t)},[t,l]),jt(()=>{l.current&&setTimeout(()=>{if(!l.current)return;let u=l.current.value.length;l.current.setSelectionRange(u,u),l.current.focus()},0)},[l]),bs("div",{className:r.textInputWrapper,children:[he("textarea",{...o,ref:l,"data-testid":"edit-suggestion-dialog-textarea",className:r.textInput,defaultValue:t,onChange:()=>{}}),i&&he(Pd,{inputElement:l.current,value:t}),bs("div",{className:Qi(r.alert,c===0?r.success:r.warning),children:[he("div",{className:r.alertText,children:n("placeholders",{placeholderSize:c})}),c===0?he(Wi,{}):he($i,{})]})]})},Pd=({inputElement:t,value:e})=>{let o=y("EditSuggestionTextInput",ys),n=Cs(null),s=en(t);return jt(()=>{tn(t,s)},[s,t]),he(Id,{inputElement:t,children:bs("div",{ref:n,className:Qi(o.root,o.agentText),children:[he(Ed,{tagName:"span",disableLineBreaks:!0,content:e,matchers:[new at("placeholders")],inputElement:t,boundaryRef:n}),he("br",{})]})})},Id=({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]),he("div",{ref:o,children:e})},Zi=kd;import{useEffect as om,useState as nm,useRef as sm}from"react";var G={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 Ld}from"react/jsx-runtime";var Rd=({src:t,title:e})=>{let o=y("CommandPalette",G);return Ld("div",{className:o.image,children:[Ji("img",{src:t,alt:e,className:o.imageSrc}),e&&Ji("span",{className:o.imageTitle,children:e})]})},Yi=Rd;import Ad from"react";import Md from"classnames";import{jsx as ea,jsxs as Od}from"react/jsx-runtime";function ws({children:t,heading:e,orientation:o}){let n=y("CommandPalette",G);return Ad.Children.count(t)===0?null:Od("div",{"data-testid":"commandpalette-list",className:n.list,children:[e&&ea("h4",{className:n.listHeading,children:e}),ea("div",{className:Md(n.listWrapper,o==="horizontal"&&n.listHorizontal),children:t})]})}import nn from"classnames";import Ts from"react";import{jsx as Nd}from"react/jsx-runtime";var ta=Ts.createContext(void 0);function Ne(){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 Nd(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:u,onChangeOpen:d}=Ne(),g=y("CommandPalette",G);function h(m){n(m),t&&d(!1)}return sn("div",{className:nn(g.listItem,u===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={};U(Vt,{enUS:()=>Dd,nlNL:()=>Hd});var Dd={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",G),{page:a}=Ne();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 $d,useCallback as Xd,useEffect as Qd,useRef as Zd}from"react";var rn=()=>/Mac/i.test(navigator.platform);import{createAsyncThunk as zd,createSlice as jd}from"@reduxjs/toolkit";var Bd={info(...t){console.info("[Deepdesk]",...t)},warn(...t){console.warn("[Deepdesk]",...t)},error(...t){console.error("[Deepdesk]",...t)}},E=Bd;import{createAsyncThunk as Ls,createSlice as Kd}from"@reduxjs/toolkit";function Fd(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,[Fd(o)]:A(t[o])}),{}):t}function Rs(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,o)=>({...e,[Rs(o)]:F(t[o])}),{}):t}var Ud={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=Kd({name:"info",initialState:Ud,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=zd("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.map(a=>({...a,source:a.type==="URL"?"search-url":"search-overlay",searchTerm:t.query}))}),ua=jd({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:V}=ua.actions,da=ua.reducer;var Vd=/(https?:\/\/[^\s]+)/,cn=t=>t.split(" ").find(e=>Vd.test(e));import ma from"classnames";import{jsx as Wd,jsxs as Gd}from"react/jsx-runtime";var qd=({onClick:t,shortKeys:e,children:o,...n})=>{let s=y("CommandPalette",G);return Gd("button",{type:"button",...n,onClick:t,className:ma(s.actionButton,n.className),children:[o,e&&e.map(r=>Wd("span",{className:ma(s.actionShortcut,r===8629&&s.actionShortcutFixKerning),children:typeof r=="number"?String.fromCharCode(r):r},r))]})},ut=qd;import{jsx as pn,jsxs as Os}from"react/jsx-runtime";var Jd=({children:t,primaryLabel:e,secondaryLabel:o,onPrimary:n,onSecondary:s,list:r})=>{let i=y("CommandPalette",G),a=T(Vt),{selected:l,setSelected:c}=Ne(),p=r[l],u=p&&typeof p.text=="string"&&cn(p.text),d=Zd(null);function g(v){if(!d.current)return;let x=d.current.querySelectorAll(".command-palette-list-item"),k=0,C=0;v==="down"?(x.forEach((ee,D)=>{D===l&&(k=D)}),C=k===x.length-1?0:k+1):v==="up"?(x.forEach((ee,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(!d.current)return;let v=d.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=()=>{u&&window.open(u,"_blank")},_=()=>{p&&n(p,l)},w=()=>{!p.type||["IMAGE","command"].includes(p.type)||s&&s(p,l)},f=Xd(v=>{if(v.key==="Enter"&&v.altKey&&u){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 Qd(()=>(window.addEventListener("keyup",f),()=>{window.removeEventListener("keyup",f)}),[f]),Os("div",{className:i.actions,children:[pn("div",{className:i.actionsWrapper,ref:d,children:t}),Os("div",{className:i.actionsBar,children:[u&&pn(ut,{onClick:m,shortKeys:[rn()?8997:"ALT",8629],children:a("visitUrl")}),p&&Os($d,{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=Jd;import{forwardRef as em}from"react";import{jsx as ha,jsxs as Yd}from"react/jsx-runtime";var dt=()=>Yd("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 tm({onChange:t,onChangeType:e,placeholder:o,typePlaceholder:n,types:s,value:r,selectedType:i},a){let l=y("CommandPalette",G);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,autoComplete:"off",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=em(tm);import{jsx as Sa,jsxs as rm}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:u,search:d}){let[g,h]=nm(0),m=sm(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(d.length>0){r("");return}a(!1)};return om(()=>{h(0)},[d,n]),Sa(it,{autoFocus:!0,contentAriaLabel:"Search Results",overlayAriaLabel:"Command Palette",isOpen:u,onBack:w,onClose:_,children:rm(oa,{selected:g,setSelected:h,isOpen:u,onChangeOpen:a,page:n,children:[n===o&&Sa(ya,{ref:m,onChange:r,onChangeType:i,placeholder:t,value:d,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 ye,jsxs as Gt}from"react/jsx-runtime";var lm=({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=im(),c=T(hs),p=am(h=>h.overlayInput.text);va(()=>{t&&(l(W.actions.reset()),l(W.actions.stageSuggestion({text:i,suggestion:{...t,source:"search-preview"},eventMetrics:{inputType:"mouse"},replace:"until-selection-end"})),l(W.actions.commitSuggestion()))},[t]);let u=h=>{h.preventDefault(),d(p)},d=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&&ye("h3",{className:a.title,children:t.title}),t.searchKeywords&&t.searchKeywords.length>0&&ye(ls,{labels:t.searchKeywords}),ye(Zi,{onUse:d,value:p})]}),Gt("form",{className:a.actions,onSubmit:u,children:[Gt("div",{children:[ye("button",{disabled:!r,className:a.pagination,type:"button",onClick:r&&g(r),children:ye(Zo,{})}),ye("button",{disabled:!s,className:a.pagination,type:"button",onClick:s&&g(s),children:ye(Oi,{})})]}),Gt("div",{className:a.primaryButtons,children:[ye(R.Button,{onClick:g(o),shortKeys:["esc"],children:c("dismiss")}),ye(R.Button,{shortKeys:[8679,8629],type:"submit",children:c("add")})]})]})]})},un=lm;import{createAction as um,createAsyncThunk as Ca,createSlice as dm}from"@reduxjs/toolkit";var cm=["{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(cm.map(t=>`(?:${t.replace("{","\\{").replace("}","\\}")})`).join("|"));function _a(t,e){let o=t.split(pm),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 u=a.charAt(0),d=0;do c=u?e.indexOf(u,c+1):-1,d+=1;while(c!==-1&&a.indexOf(e.slice(c))!==0);if(c===-1&&d>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=um("textSuggestions/refresh"),Se=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(Le(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(Le(l)),l}),Ia=dm({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(Se.pending,(e,o)=>{let n=o.meta.arg,s=e[n]||wa;return{...e,[n]:{...s,fetchState:"loading",isInitialRequest:s.isInitialRequest===null}}}).addCase(Se.rejected,(e,o)=>{let n=o.meta.arg;e[n].fetchState="error"}).addCase(Se.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 mm}from"@reduxjs/toolkit";var Ma={contentType:null,suggestion:null},Oa=t=>t.activeSuggestion.suggestion,Na=t=>t.activeSuggestion.contentType,Da=mm({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:ve,resetActiveSuggestion:Ds}=Da.actions,Ha=Da.reducer;var Hs={};U(Hs,{enUS:()=>gm,nlNL:()=>fm});var gm={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"}]},fm={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 hm}from"@reduxjs/toolkit";var ym={showTabHint:!1,inputHasFocus:!1,overlayCollapsed:!1,openOverlayWhenTyping:!1,overlayCollapsedUserOverwrite:!1};var Ba=({ui:t})=>t.overlayCollapsed;var Fa=hm({name:"ui",initialState:ym,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 Sm}from"react";import{jsx as vm}from"react/jsx-runtime";var Va=ja.createContext(null),Qt=({broadcastEvents:t,children:e})=>{let o=ja.useMemo(()=>t,[]);return vm(Va.Provider,{value:o,children:e})},oe=()=>{let t=Sm(Va);if(!t)throw new Error("You should use the useBroadcastEvents within a BroadcastEventsProvider");return t};import{createAsyncThunk as Bs,createSlice as _m}from"@reduxjs/toolkit";var xm={isLoggedIn:!0,loginFetchState:"idle",verifyFetchState:"idle",showLoginOverlay:!1},_e=t=>t.auth.isLoggedIn,qa=t=>t.auth.loginFetchState,Wa=t=>t.auth.verifyFetchState,Ga=t=>t.auth.showLoginOverlay,De=Bs("auth/validate",async(t,e)=>e.extra.deepdeskAPI.isLoggedIn()),$a=Bs("auth/requestLogin",async({email:t},e)=>{let{deepdeskAPI:o}=e.extra;return o.requestLoginByEmail(t)}),Zt=Bs("auth/verifyLoginToken",async({token:t},e)=>{let{deepdeskAPI:o}=e.extra;return o.verifyLoginToken(t)}),Xa=_m({name:"auth",initialState:xm,reducers:{setIsLoggedIn(t,e){t.isLoggedIn=e.payload},setShowLoginOverlay(t,e){t.showLoginOverlay=e.payload}},extraReducers:t=>{t.addCase(De.pending,e=>{e.loginFetchState="loading"}),t.addCase(De.fulfilled,(e,{payload:o})=>{e.isLoggedIn=o,e.loginFetchState="done"}),t.addCase(De.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",bm="UserLoggedOut",xe="ApplySuggestion",Us="ApplyImageSuggestion",Cm="ShowCommandPalette",wm=t=>({[Fs]:e=>{t.dispatch(La(e.state)),t.dispatch(ve({contentType:e.contentType,suggestion:e.suggestion}))},[Cm]:e=>{t.dispatch(Y(e.isOpen)),e.page&&t.dispatch(V(e.page))},[St]:e=>{t.dispatch(Qa(e))},[Ks]:()=>{t.dispatch(De())},[bm]:()=>{t.dispatch(De())},[Us]:e=>{t.dispatch(Xo({suggestion:e.suggestion}))},[xe]:e=>{t.dispatch(ie({...e,eventMetrics:{inputType:"mouse"},replace:"selection"})),t.dispatch(Ae())}}),Ja=wm;import{jsx as Ya}from"react/jsx-runtime";var km=()=>{var h;let[t,e]=Tm(!1),o=zs(Oa),n=zs(Na),s=zs(gt),r=Em(),i=oe(),a=T(Hs),l=()=>{o!==null&&t?window.confirm(a("warning"))&&c():c()},c=()=>{r(Ds()),r(ft(!0)),r(W.actions.reset())},p=(m,_)=>{r(Ds()),r(ft(!0)),i.send(xe,{text:m,suggestion:_})};if(o===null||n===null)return null;let u=(h=s[n])==null?void 0:h.suggestions.indexOf(o),d=u===0||u===null?void 0:()=>r(ve({contentType:n,suggestion:s[n].suggestions[u-1]})),g=u===s[n].suggestions.length-1||u===null?void 0:()=>r(ve({contentType:n,suggestion:s[n].suggestions[u+1]}));return Ya(it,{autoFocus:!0,isOpen:u!==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:d})})},el=km;import{useSelector as rl}from"react-redux";import Vs 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 Pm from"classnames";var tl={root:"_root_1ukx5_1"};import{jsx as Rm}from"react/jsx-runtime";var Im=({className:t,value:e,...o})=>{let n=y("TextInput",tl);return Rm("input",{className:Pm(t,n.root),type:"text",value:e,...o})},Jt=Im;var js={};U(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 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 $,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}},Bm=({agentEmail:t,isOpen:e,origin:o="",onSuccess:n,onDismiss:s})=>{let r=T(js),i=y("LoginTokenDialog",ol),a=Dm(Wa),l=Nm(),c=b("productName"),[p,u]=qs(t||""),[d,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=Om(()=>x=>$("button",{type:"button","data-testid":"login-token-dialog-back-button",className:i.anchorButton,onClick:w,children:x},"back-button"),[]);return Mm(()=>{a==="error"&&m(r("verifyCodeError",{login:v})),a==="done"&&n()},[a]),$(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:[$("h1",{className:i.title,children:r("promptTitle",{productName:c})}),d===0&&mn("form",{onSubmit:_,children:[$("h2",{className:i.subtitle,children:r("requestCodeTitle")}),$("p",{className:i.text,children:r("requestCodeBody",{productName:c})}),$(Jt,{className:i.input,name:"email",placeholder:r("requestCodeInputPlaceholder"),value:p,onChange:x=>u(x.target.value)}),$("div",{className:i.actions,children:$("button",{type:"submit",className:Vs(i.button,i.primaryButton),children:r("requestCodeSubmitLabel")})})]}),d===1&&mn("form",{onSubmit:f,children:[$("h2",{className:i.subtitle,children:r("verifyCodeTitle")}),$("p",{className:i.text,children:r("verifyCodeBody")}),$(Jt,{className:i.input,name:"token",placeholder:r("verifyCodeInputPlaceholder"),disabled:["loading","done"].includes(a)}),h&&$("div",{className:i.errorMessage,children:h}),mn("div",{className:i.actions,children:[$("button",{type:"button",className:Vs(i.button),onClick:w,children:r("back")}),$("button",{type:"submit",className:Vs(i.button,i.primaryButton),disabled:["loading","done"].includes(a),children:r("verifyCodeSubmitLabel")})]})]})]})})},sl=Bm;import{jsx as Km}from"react/jsx-runtime";var Fm=()=>{let t=rl(Ga),e=rl(na),o=b("adminUrl"),n=oe(),s=()=>n.send(St,!1),r=()=>{n.send(St,!1),n.send(Ks)};return Km(sl,{isOpen:t,agentEmail:e==null?void 0:e.agentEmail,origin:o,onDismiss:s,onSuccess:r})},il=Fm;import Lg from"lodash.debounce";import{useCallback as Ys,useEffect as er,useState as oo}from"react";import{useDispatch as Ag,useSelector as Ct}from"react-redux";import{createAsyncThunk as Um,createSlice as zm}from"@reduxjs/toolkit";var jm={data:null,fetchState:"idle"},al=t=>t.contentTypes.data,Yt=Um("contentTypes/getContentTypes",async(t,e)=>e.extra.deepdeskAPI.getContentTypes()),Vm=zm({name:"contentTypes",initialState:jm,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=Vm.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 qm}from"react";function cl(t,e){qm(()=>{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 Jm}from"react";import{useSelector as Ym,useDispatch as eg}from"react-redux";import{createAsyncThunk as Wm,createSlice as Gm}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=Wm("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)}),$m=t=>t.filter((e,o)=>o===t.findIndex(n=>n.text===e.text)),Xm=Gm({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=$m(e.data?[...e.data,...o.payload]:o.payload)}).addCase(I,()=>pl)}}),ul=Xm.reducer;var Ws={};U(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 dl={root:"_root_17kae_1",empty:"_empty_17kae_5"};import{jsx as fn,jsxs as og}from"react/jsx-runtime";var tg=({onCopy:t,onUse:e})=>{let o=Jm(null),n=y("EntitiesList",dl),s=T(Ws),r=Ym(gn),i=eg();return ml(()=>{i(ae())},[]),ml(()=>{o.current&&o.current.focus()},[o]),og("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=tg;import{Fragment as lg,useEffect as hn,useRef as cg,useState as pg}from"react";import{useSelector as _l,useDispatch as ug}from"react-redux";import{createAsyncThunk as ng,createSlice as sg}from"@reduxjs/toolkit";var fl={data:null,fetchState:"idle"},hl=t=>t.summary.data,yl=t=>t.summary.fetchState==="error",be=ng("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}}),rg=sg({name:"summary",initialState:fl,reducers:{},extraReducers:t=>{t.addCase(be.pending,e=>{e.data=null,e.fetchState="loading"}).addCase(be.rejected,e=>{e.data=null,e.fetchState="error"}).addCase(be.fulfilled,(e,o)=>{e.fetchState="done",o.payload&&(e.data=o.payload.summary)}).addCase(I,()=>fl)}}),Sl=rg.reducer;var Gs={};U(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 vl={root:"_root_6ahh3_1",actions:"_actions_6ahh3_5",main:"_main_6ahh3_11",textInput:"_textInput_6ahh3_15",loading:"_loading_6ahh3_34",error:"_error_6ahh3_38"};import{jsx as vt,jsxs as mg}from"react/jsx-runtime";var dg=({onCopy:t})=>{let e=cg(null),o=y("SummaryForm",vl),[n,s]=pg(""),r=T(Gs),i=_l(hl),a=_l(yl),l=ug(),c=()=>{l(J({name:"summary copied to clipboard",data:{originalText:i,finalText:n},options:{includeConversationData:!0}})),t(n)},p=()=>{let u=document.getSelection();u&&l(J({name:"summary copied to clipboard",data:{originalText:i,finalText:u==null?void 0:u.toString()},options:{includeConversationData:!0}}))};return hn(()=>{l(be())},[]),hn(()=>{s(i||"")},[i]),hn(()=>{e.current&&i&&e.current.focus()},[e,i]),hn(()=>{let u=d=>{d.key==="Enter"&&d.shiftKey&&c()};return document.addEventListener("keydown",u),()=>{document.removeEventListener("keydown",u)}},[n]),vt("div",{className:o.root,tabIndex:-1,children:a?vt("p",{className:o.error,children:r("error")}):mg(lg,{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:u=>s(u.target.value)})}),vt("div",{className:o.actions,children:vt(R.Button,{shortKeys:[8679,8629],onClick:c,children:r("copy")})})]})})},xl=dg;var $s={};U($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 Cg,{useEffect as Zs,useRef as wg}from"react";import{useDispatch as Tg,useSelector as Pl}from"react-redux";var Xs={};U(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 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 Sg,createAsyncThunk as vg,createSlice as _g}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=Sg("answer/resetKnowledgeSearch"),_t=vg("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}}),xg=_g({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=xg.reducer;import{jsx as El,jsxs as bg}from"react/jsx-runtime";var kl=()=>bg("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 Js}from"react/jsx-runtime";var Eg=({onUse:t,onResetQuestion:e,question:o,promptInstruction:n})=>{let[s,r]=Cg.useState(""),{setSelected:i}=Ne(),a=wg(null),l=y("EntitiesList",bl),c=T(Xs),p=Tg(),u=Pl(Cl),d=Pl(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 Zs(()=>{var m;o&&d==="idle"?p(_t({question:o,promptInstruction:n})):(m=a.current)==null||m.focus()},[a,d]),Zs(()=>{d==="done"&&(p(J({name:"knowledge assist question answered",data:{question:s||o,sources:u[u.length-1].answer.sources,isFollowUpQuestion:u.length>1},options:{includeConversationData:!0}})),i(u.length-1),r(""))},[d,u]),Zs(()=>{a.current&&a.current.scrollIntoView({behavior:"smooth"})},[a,u]),Js("div",{className:l.root,children:[u.length>0&&Ce("div",{className:l.alignRight,children:Ce(R.Button,{onClick:e,children:c("reset")})}),Js(R.ActionsBar,{list:u.map(({answer:m})=>({text:m.answer,type:"answer"})),primaryLabel:c("use"),onPrimary:m=>t(m.text),children:[u.map(({question:m,answer:_},w)=>Ce(R.List,{children:Ce(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}`)),d==="loading"&&Ce("p",{className:l.status,children:c("loading")}),d==="error"&&Ce("p",{className:l.status,children:c("error")}),Js("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(kl,{})})]})]})]})},Il=Eg;import{createAsyncThunk as kg,createSlice as Pg}from"@reduxjs/toolkit";var Ig={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=kg("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)}),Rg=Pg({name:"profile",initialState:Ig,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})}}),Rl=Rg.reducer;import{jsx as X,jsxs as Al}from"react/jsx-runtime";var Mg=200,Og=5,Ng=4,Dg=t=>t.reduce((e,o)=>[...e,...o.list.map(n=>({...n,type:o.value}))],[]),Ll=(t,e)=>!e||t.toLowerCase().includes(e.toLowerCase()),Hg=()=>{let t=Ag(),e=oe(),o=T($s),[n,s]=oo(!1),[r,i]=oo(""),a=Ct(la),l=Ct(bt),[c,p]=oo(null),[u,d]=oo([]),[g,h]=oo(),m=Ct(_e),_=b("showSearch"),w=b("showEntitiesCommand"),f=b("showSummaryCommand"),v=b("showKnowledgeSearch"),x=b("showImageSearch"),k=b("searchTriggerKey"),C=Ct(al),O=Ct(ca),ee=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),B=[{label:o("entitiesClipboard"),onClick:()=>t(V("entities")),shouldShow:w&&Ll(o("entitiesClipboard"),r),experimental:!0},{label:o("summaryClipboard"),onClick:()=>t(V("summary")),shouldShow:f&&Ll(o("summaryClipboard"),r),experimental:!0},{label:r?`${o("knowledgeSearch")}: ${r}`:o("knowledgeSearch"),onClick:()=>t(V("knowledgeSearch")),shouldShow:v,experimental:!0}].filter(S=>S.shouldShow),q=(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=Ys(Lg((S,L)=>{t(qe({query:S,type:L,tags:["search-overlay"]}))},Mg),[]),Fe=Dg([...q,...P]),Lp=Ys((S,L)=>{if(!L)return;let Pe=[...P,...q].find(({value:Je})=>Je===L);Pe&&(t(V("edit")),p({...S,searchTerm:void 0}),d(Pe.list))},[t,c,q]),jn=Ys((S,L)=>{switch(L.type){case"IMAGE":e.send(Us,{suggestion:L});break;default:e.send(xe,{text:S,suggestion:L})}t(Y(!1))},[t]),Ap=S=>{eo(S.text),t(J({name:"entity copied",data:{entity:S,type:"copy"}})),t(Y(!1))},Mp=S=>{e.send(xe,{text:S,suggestion:{source:"knowledge-assist",text:S}}),t(J({name:"answer used",data:{originalText:S},options:{includeConversationData:!0}})),i(""),t(V("search")),t(xt()),t(Y(!1))},Op=S=>{eo(S),t(Y(!1))},Np=S=>{e.send(xe,{text:S.text,suggestion:{source:"entity",text:S.text}}),t(Y(!1))},Dp=c===null||u.indexOf(c)-1<0?void 0:()=>p(u[u.indexOf(c)-1]),Hp=c===null||u.indexOf(c)===u.length-1?void 0:()=>p(u[u.indexOf(c)+1]);function Vn(S,L){return S.slice(0,g?10:L.toLowerCase()==="image"?Ng:Og)}function Fr(S,L,Pe){return L.reduce((Je,ho)=>Pe&&g===Pe?ho.length+Je:Vn(ho,Pe).length+Je,S)}function Ze(S){return L=>{n?window.confirm(o("warning"))&&(S(L),s(!1)):S(L)}}return er(()=>{r?zn(r,g):t(ln())},[r,g]),er(()=>{a==="search"&&t(xt())},[a]),er(()=>{m&&t(Yt())},[m]),cl(k,()=>t(Y(!0))),!_||!l?null:Al(R,{placeholder:o("searchPlaceholder"),typePlaceholder:o("typePlaceholder"),onChangeSearch:i,onChangeOpen:Ze(S=>t(Y(S))),onChangeType:S=>h(S),onChangePage:Ze(S=>t(V(S))),selectedType:g,search:r,page:a,isOpen:ee,types:[...q,...P],children:[X(R.Page,{id:"search",children:Al(R.ActionsBar,{list:[...B.map(S=>({text:S.label,type:"command"})),...Fe.map(S=>({text:S.text||S.url||S.message,type:S.type}))],primaryLabel:o("use"),secondaryLabel:o("preview"),onPrimary:({text:S},L)=>jn(S,Fe[L]),onSecondary:(S,L)=>{Lp(Fe[L-B.length],Fe[L-B.length].type)},children:[B.length>0&&X(R.List,{heading:o("commands"),children:B.map((S,L)=>X(R.ListItem,{index:Fr(L,[],"commands"),closeOnSelect:!1,onClick:S.onClick,isExperimental:S.experimental,children:S.label},S.label))}),[...q,...P].map(({value:S,label:L,list:Pe,lineClamp:Je,listOrientation:ho},Bp)=>X(R.List,{heading:L,orientation:ho==="horizontal"?"horizontal":"vertical",children:Vn(Pe,S).map((se,Fp)=>X(R.ListItem,{index:Fr(B.length+Fp,[...q,...P].slice(0,Bp).map(({list:Kp})=>Kp),S),closeOnSelect:!1,lineClamp:Je,onClick:()=>jn(se.text,se),description:S!=="IMAGE"?se.title&&se.text:void 0,children:S==="IMAGE"?X(R.Image,{title:se.title||se.text,src:se.image}):se.title||se.text},`${se.id}-${se.text}`))},S))]})}),X(R.Page,{id:"edit",onDismiss:Ze(()=>{t(V("search")),p(null)}),children:c&&X(un,{suggestion:c,onTouched:s,onDismiss:()=>{s(!1),t(V("search")),p(null),d([])},onNext:Hp,onPrevious:Dp,onUse:S=>{t(V("search")),jn(S,c),t(Y(!1)),d([]),p(null)}})}),X(R.Page,{id:"entities",title:o("entitiesTitle"),isExperimental:!0,onDismiss:Ze(()=>{t(V("search"))}),children:X(gl,{onUse:Np,onCopy:Ap})}),X(R.Page,{id:"summary",title:o("summaryTitle"),isExperimental:!0,onDismiss:Ze(()=>{t(V("search"))}),children:X(xl,{onCopy:Op})}),X(R.Page,{id:"knowledgeSearch",title:o("knowledgeSearch"),isExperimental:!0,onDismiss:Ze(()=>{t(xt()),t(V("search"))}),children:X(Il,{promptInstruction:l.knowledgeSearchPromptInstruction,question:r,onUse:Mp,onResetQuestion:()=>{t(xt()),i("")}})})]})},Ml=Hg;import{jsx as tr,jsxs as Kg}from"react/jsx-runtime";var Fg=()=>{let t=b("showSearch"),e=b("isEmbedded");return Kg(Bg,{children:[t&&tr(Ml,{}),tr(el,{}),e&&tr(il,{})]})},Ol=Fg;import{Provider as Ug}from"react-redux";import{jsx as Sn}from"react/jsx-runtime";var zg=({children:t})=>{let o=b("locale").replace("-","");return Sn(ts.Provider,{value:o,children:t})},jg=({store:t,customStyles:e={},children:o})=>Sn(Ug,{store:t,children:Sn(zg,{children:Sn(Mt.Provider,{value:e,children:o})})}),no=jg;import lr from"classnames";import{useEffect as xf,useRef as bf,useState as Cf}from"react";import{connect as wf,useDispatch as Tf,useSelector as bn}from"react-redux";import{useState as Vg}from"react";function Nl(t,e){let[o,n]=Vg(()=>{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 Gg from"classnames";import{Fragment as $g,useCallback as nr,useMemo as Hl}from"react";var or={};U(or,{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 Dl={root:"_root_1vfca_1",anchor:"_anchor_1vfca_6",anchorButton:"_anchorButton_1vfca_11"};import{jsx as _n,jsxs as Bl}from"react/jsx-runtime";var sr=(t,e,o)=>n=>_n("button",{className:t.anchorButton,type:"button",value:e,onClick:o,children:n},e),Xg=({className:t,loginUrl:e,isEmbedded:o,onSnooze:n})=>{let s=T(or),r=oe(),i=y("Login",Dl),a=b("productName"),l=nr(m=>{m.preventDefault(),n&&n(parseInt(m.target.value,10))},[]),c=nr(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]),u=nr(m=>_n("button",{type:"button",className:i.anchorButton,onClick:c,children:m},"prompt"),[c]),{min:d,hour:g,day:h}=Hl(()=>({min:sr(i,60*10,l),hour:sr(i,60*60,l),day:sr(i,60*60*12,l)}),[]);return Bl("div",{className:Gg(t,i.root),children:[s("loginPlease",{login:o?u:p,productName:a}),n&&Bl($g,{children:[_n("br",{}),s("snooze",{min:d,hour:g,day:h})]})]})},xn=Xg;import{useDispatch as Qg}from"react-redux";var Fl={root:"_root_1g8fi_1",text:"_text_1g8fi_19"};import{jsx as Kl,jsxs as Jg}from"react/jsx-runtime";var Zg=({title:t})=>{let e=y("SearchTrigger",Fl),o=Qg();return Jg("button",{type:"button",className:e.root,onClick:()=>o(Y(!0)),children:[Kl(dt,{}),Kl("span",{className:e.text,children:t})]})},Ul=Zg;import{Fragment as yf}from"react";import{Interweave as af}from"interweave";import{useEffect as lf,useMemo as cf,useRef as pf}from"react";import{useDispatch as uf,useSelector as df}from"react-redux";import{useEffect as Yg}from"react";function zl(t,e,o){Yg(()=>{let n=t.current;return n?(n.addEventListener(e,o),()=>{n.removeEventListener(e,o)}):()=>{}},[t,e,o])}var ef=/[.*+?^${}()|[\]\\]/g,tf=/[^0-9A-Za-zÀ-ÖØ-öø-ÿ](?=[0-9A-Za-zÀ-ÖØ-öø-ÿ]*$)/;function of(t){return t.replace(ef,"\\$&")}function nf(t,e){let o=t.split("").findIndex((n,s)=>n!==e[s]);return o>-1?o:Math.min(t.length,e.length)}function rr(t){return t.search(tf)}function jl(t,e=[]){let o=t;return e.forEach(n=>{if(!n)return;let s=new RegExp(`\\b(${of(n)})\\b`,"gi");o=o.replace(s,"<strong>$1</strong>")}),o}function Vl(t){return t.replace(nt,'<mark data-type="placeholder">$1</mark>')}function so(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}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 ir(t,e,o={}){if(e){let n=nf(e.toLowerCase(),t.toLowerCase()),s=so(t.substring(n,t.length));if(o.stripAgentPart){let l=t.substring(0,n),c=rr(l);return`<span style="opacity: 0.5">${l.substring(c+1)}</span>${s}`}let i=e.split(ii).length>3||e.length>30?sf(e.trim(),n):0;return`${`${i>0?"\u2026":""}${so(t.substring(i,n))}`}<strong>${s}</strong>`}return t}var ql={badge:"_badge_8rv7b_1",formattedText:"_formattedText_8rv7b_5"};import{jsx as Wl}from"react/jsx-runtime";var mf=["search","personal-collection-search","search-autocomplete"];function gf(t,e,o,n={}){let s="";return mf.includes(e)?s=jl(ir(t,o,{stripAgentPart:!0}),n.searchKeywords??[o]):s=ir(t,o,n),n.placeholders===!0&&(s=Vl(s)),s}var ff=()=>{},hf=({index:t,selected:e,suggestion:o})=>{let n=b("inlineSuggestions"),s=df(rt),r=uf(),i=y("TextSuggestion",ql),a=pf(null);lf(()=>{let c=setTimeout(()=>{r(_i({text:o.text,suggestion:o}))},500);return()=>{clearTimeout(c)}},[o]),zl(a,"click",()=>{r(Qo(t)),r(ie({suggestion:o,text:o.text,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"}))});let l=cf(()=>gf(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:Wl(N,{ref:a,as:"button",selected:e,onClick:ff,children:Wl(af,{containerTagName:"div",noWrap:!1,tagName:"span",className:i.formattedText,content:l})})},Gl=hf;import{jsx as $l}from"react/jsx-runtime";var Sf=({suggestions:t,selectedIndex:e})=>$l(yf,{children:t.slice().map((o,n)=>$l(Gl,{index:n,selected:n===e,suggestion:o},`${o.text}-${o.source}`)).reverse()}),Xl=Sf;var ar={};U(ar,{enUS:()=>vf,nlNL:()=>_f});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"}]},_f={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 Ql={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 K,jsxs as ro}from"react/jsx-runtime";var Ef=({inline:t=!1,textSuggestions:e,selectedIndex:o})=>{let n=y("SuggestionsOverlay",Ql),s=T(ar),r=b("inlineSuggestions"),i=bn(vn),a=fi(),l=Tf(),c=bf(null),p=b("searchTriggerKey"),u=b("productName"),d=bn(Ba),g=bn(_e),h=bn(Bo),[m,_]=Cf(null),w=b("showSearch"),f=b("showTextSuggestions"),v=b("adminUrl"),x=b("isEmbedded"),[k,C]=Nl("dd-snooze-until-ms",0),O=d||k>Date.now(),ee=e.filter(B=>B.source!=="gpt").length,D=()=>{O&&C(0),l(Ua(!O))},P=B=>{let q=Date.now()+B*1e3;C(q),E.info(`Snooze until: ${new Date(q)}`),l(ht({collapse:!0}))};return xf(()=>{ee===0&&_(null)},[e,ee]),lt(()=>{l(ht({collapse:!0,skipWhenInputFocus:!0}))}),r!==t||g===null||h===!1?null:g===!1?ro("div",{ref:c,className:lr(n.root,{[n.isCollapsed]:O,[n.isInline]:t}),"data-inline":t,children:[!O&&ro("div",{className:n.triggers,children:[K("div",{style:{flex:1}}),K("div",{className:n.triggersRight,children:K(ot,{className:n.toggleButton,title:s("collapse"),onClick:D,isCollapsed:!1})})]}),K("div",{className:n.toggleButtonWrapper,children:K(ot,{className:n.toggleButton,title:s("open",{productName:u}),onClick:D,isCollapsed:!0})}),K("div",{className:n.collapsible,children:K(xn,{loginUrl:v,isEmbedded:x,onSnooze:P})})]}):!a||!i?null:ro("div",{ref:c,className:lr(n.root,{[n.isCollapsed]:O,[n.isInline]:t}),"data-inline":t,children:[!O&&ro("div",{className:n.triggers,children:[K("div",{style:{flex:1},children:w&&K("div",{style:{display:"inline-block"},onFocus:()=>{},onMouseOver:()=>_(s(rn()?"searchHintMac":"searchHintWindows",{searchTriggerKey:p.toUpperCase()})),onMouseLeave:()=>_(null),children:K(Ul,{title:s("search")})})}),ro("div",{className:n.triggersRight,onFocus:()=>{},children:[K("div",{className:lr(!m&&n.hintsHidden,n.hints),children:m}),K(ot,{className:n.toggleButton,title:s("collapse"),onClick:D,isCollapsed:!1})]})]}),K("div",{className:n.toggleButtonWrapper,children:K(ot,{className:n.toggleButton,title:s("open",{productName:u}),onClick:D,isCollapsed:!0})}),ee>0&&f&&K("div",{className:n.collapsible,onFocus:()=>{},children:K(ge,{children:K(Xl,{suggestions:e,selectedIndex:o})})})]})},kf=({input:t})=>({selectedIndex:t.selectedSuggestionIndex,textSuggestions:t.textSuggestions}),Cn=wf(kf)(Ef);import vr from"classnames";import{Interweave as vh}from"interweave";import{useCallback as _h,useEffect as xh,useMemo as hc,useRef as bh}from"react";import{connect as Ch}from"react-redux";import{cloneElement as Pf}from"react";var If=["div","span","mark","strong","b","i","u","em"];function cr(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(If.includes(s)){let i=Array.isArray(n.props.children)?n.props.children:[n.props.children];return[...t.slice(0,t.length-1),Pf(n,{children:cr(i,e,o+1)})]}return[...t,...e]}function we(t){return t.tagName.toLowerCase()==="textarea"}var Zl={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 Vf,useEffect as qf}from"react";import oc from"classnames";import{createRef as Ff,useCallback as ur,useMemo as Kf,useRef as Uf,useState as zf}from"react";import{useState as Rf,useLayoutEffect as Lf}from"react";var Af=["bottom","height","left","right","top","width"],Mf=(t={},e={})=>Af.some(o=>t[o]!==e[o]),Te=new Map,Jl,Yl=()=>{let t=[],e=[];Te.forEach((o,n)=>{if(n instanceof Element&&!n.isConnected){e.push(n);return}let s=n.getBoundingClientRect();Mf(s,o.rect)&&(o.rect=s,t.push(o))}),e.forEach(o=>{Te.delete(o)}),t.forEach(o=>{o.callbacks.forEach(n=>n(o.rect))}),Jl=window.requestAnimationFrame(Yl)};function Of(t,e){return{observe(){let o=Te.size===0;if(Te.has(t)){let n=Te.get(t);n.callbacks.push(e),n.rect&&e(n.rect)}else Te.set(t,{rect:void 0,hasRectChanged:!1,callbacks:[e]});o&&Yl()},unobserve(){let o=Te.get(t);if(o){let n=o.callbacks.indexOf(e);n>=0&&o.callbacks.splice(n,1),o.callbacks.length||Te.delete(t),Te.size||cancelAnimationFrame(Jl)}}}}function pr(t){let[e,o]=Rf(null);return Lf(()=>{if(!t.current)return;let n=Of(t.current,s=>{o(s)});return n.observe(),()=>{n.unobserve()}},[t]),e}import{useContext as Nf,useLayoutEffect as Df,useState as Hf}from"react";import{createPortal as Bf}from"react-dom";var ec={root:"_root_1jq08_1"};var tc=({children:t})=>{let[e,o]=Hf(null),n=Nf(Mt);return Df(()=>{let s=document.createElement("div");return Ve(s),s.classList.add(ec.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?Bf(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 dr}from"react/jsx-runtime";var wt=(t=!1)=>{let[e,o]=zf(t),n=ur(()=>o(!0),[]),s=ur(()=>o(!1),[]),r=ur(()=>o(a=>!a),[]),i=Uf(null);return{opened:e,open:n,close:s,toggle:r,triggerRef:i}};function mr(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=Ff(),position:n="above",align:s="center",children:r,toStyle:i=mr,...a})=>{let l=pr(e),c=pr(o),p=Kf(()=>i(l,c,0),[l,c]);return dr(tc,{children:dr("div",{className:oc(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:dr("div",{className:oc(t,pe.root),children:r})})})};import{jsx as io,jsxs as Gf}from"react/jsx-runtime";var Wf=({inputStyle:t,inputElement:e})=>{let o=y("TabCompletion",te),n=wt(document.activeElement===e);return lt(()=>n.close()),qf(()=>{let s=()=>n.open();return e.addEventListener("focus",s),()=>{e.removeEventListener("focus",s)}},[]),Gf(Vf,{children:[io("mark",{className:te.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 jf{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=(we(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:rr(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(Wf,{inputStyle:o.inputStyle,inputElement:o.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 nc(t){return t.replace(/[.*+^${}()|[\]\\]/g,"\\$&")}function Tn(t){return e=>{t.forEach(o=>{typeof o=="function"?o(e):o!=null&&(o.current=e)})}}function sc(t){return t!=null}import $f from"classnames";import{forwardRef as Xf,useRef as Qf}from"react";import{jsx as rc}from"react/jsx-runtime";var En=Xf(({className:t,children:e,...o},n)=>{let s=Qf(null),r=y("TabCompletion",te);return rc("div",{ref:Tn([s,n]),className:$f(t,r.popoverContentContainer),...o,children:rc("div",{className:r.popoverContent,children:e})})});import{jsx as ao,jsxs as nh}from"react/jsx-runtime";var th=t=>e=>{let o=mr(e);return"top"in o&&(o.width=t.width-(e.left-t.left)-10),o},oh=({inputElement:t,boundaryRef:e,inputStyle:o,children:n,suggestion:s})=>{let r=y("TabCompletion",te),i=wt(),a=eh(()=>th(t.getBoundingClientRect()),[t]),[l,c]=Jo(t);return Yf(()=>{c?i.open():i.close()},[c]),nh("span",{children:[ao("mark",{ref:Tn([l,i.triggerRef]),className:Zf(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 Jf{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${nc(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(sc);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(oh,{inputElement:o.inputElement,suggestion:o.suggestion,inputStyle:o.inputStyle,boundaryRef:o.boundaryRef,children:e},`keyword_${o.matchString}_${o.key}`)}asTag(){return"mark"}};import Sr from"classnames";import{Matcher as dh}from"interweave";import{createRef as mh,forwardRef as gh,useCallback as fh,useEffect as mc,useRef as gc,useState as fc}from"react";import{useDispatch as hh}from"react-redux";import{jsx as ic}from"react/jsx-runtime";var ac=()=>ic("svg",{width:"1.3em",height:"1.3em",focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24","data-testid":"InsertLinkIcon",tabIndex:-1,children:ic("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 cc,useState as pc}from"react";import{useDispatch as rh,useSelector as uc}from"react-redux";import ih from"lodash.debounce";var lc={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 gr(t){return t.replace("https://www.","").replace("https://","")}import{jsx as Ge,jsxs as fr}from"react/jsx-runtime";var ah=3,lh=t=>({image:t.image||"",text:t.text,id:t.id,title:t.title}),ch=({onSelectLink:t,onDismiss:e,placeholder:o,visitUrlText:n,linkCount:s=ah})=>{let r=y("LinkSearch",lc),[i,a]=pc(""),l=rh(),c=uc(Ta("url")),p=uc(pa("URL",lh)),[u,d]=pc(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=u-1<0?p.length-1:u-1,x=u+1===p.length?0:u+1;f.code==="Escape"&&(a(""),e()),f.code==="ArrowUp"&&d(v),f.code==="ArrowDown"&&d(x),f.code==="Enter"&&t(((k=p[u])==null?void 0:k.text)||i)},w=sh(ih(f=>{l(qe({query:f,type:"URL",tags:["link-search"]}))},300),[]);return cc(()=>{i&&w(i)},[i]),cc(()=>()=>{l(ln())},[]),fr("div",{className:r.root,children:[Ge(ge,{withDivider:!0,children:(i?p:c).slice(0,s).map((f,v)=>Ge(N,{selected:u===v,onClick:()=>t(f.text),"data-testid":"linksearch-suggestion",children:fr(H,{children:[Ge(H.Image,{src:Pn(f,"small",g||void 0),title:f.title||f.text}),fr(H.Content,{className:r.content,cropText:!0,children:[Ge(H.Title,{children:f.title||gr(f.text)}),f.title&&gr(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:_})]})},dc=ch;var hr={};U(hr,{enUS:()=>ph,nlNL:()=>uh});var ph={insertLink:[{type:0,value:"Insert link"}],linkInputPlaceholder:[{type:0,value:"Search, type or paste link"}],visitUrl:[{type:0,value:"Visit"}]},uh={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 yr}from"react/jsx-runtime";var yh=gh((t,e)=>{let o=y("TabCompletion",te);return ue("mark",{ref:e,className:Sr(o.matchSelection)},"selection-start")}),Sh=({startRef:t,boundaryRef:e,inputStyle:o,inputElement:n,children:s})=>{let r=T(hr),i=y("TabCompletion",te),a=gc(null),l=gc(null),[c,p]=fc(null),u=hh(),d=wt(document.activeElement===n),[g]=fc(()=>document.createRange());d.triggerRef.current=g,mc(()=>()=>g.detach(),[]),mc(()=>{let m=t.current,_=a.current;!m||!_||(g.setStart(m,0),g.setEnd(_,0))},[t.current,a.current]),lt(()=>{d.close()});let h=fh(m=>{let _=g.toString(),w=/^http(s?):\/\//.test(m)?m:`https://${m}`;u(qo({text:`[${_}](${w})`,replace:"selection"}))},[]);return yr("span",{children:[ue("mark",{ref:a,className:Sr(i.matchSelection),"aria-haspopup":"dialog","aria-expanded":d.opened?"true":"false",children:s}),d.opened&&ue(Tt,{className:i.popoverRoot,triggerRef:d.triggerRef,boundaryRef:e,position:"above",align:"start",children:yr(En,{style:o,ref:l,children:[ue("div",{className:Sr(i.selectionOptions,{[i.selectionOptionsIsHidden]:c!==null}),children:yr("button",{type:"button",tabIndex:c===null?-1:void 0,className:i.selectionOptionsButton,onClick:()=>p("insertLink"),children:[ue(ac,{}),ue("span",{children:"\xA0"}),ue("span",{children:r("insertLink")})]})}),c==="insertLink"&&ue(dc,{placeholder:r("linkInputPlaceholder"),visitUrlText:r("visitUrl"),onSelectLink:h,onDismiss:()=>{p(null),d.close()}})]})})]},"selection-end")},In=class extends dh{charCount=0;foundIndex=0;startRef=null;props;onBeforeParse(e,o){return this.props=o,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[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(yh,{ref:this.startRef}):ue(Sh,{inputElement:o.inputElement,startRef:this.startRef,boundaryRef:o.boundaryRef,inputStyle:o.inputStyle})}asTag(){return"mark"}};import{jsx as Et,jsxs as Eh}from"react/jsx-runtime";var wh=({enabled:t,content:e,tabText:o,showTabHint:n,showTabCompletion:s,showStyleSuggestions:r,keywordMatches:i,inputElement:a,source:l})=>{let c=y("TabCompletion",Zl),p=b("insertLink"),u=b("showMidSentenceSuggestions"),d=b("inlineSuggestions"),g=en(a),h=bh(null);xh(()=>{we(a)&&g&&tn(a,g)},[g]);let m=_h(f=>{if(!s||!o)return f;let v=[Et("span",{className:c.resetIndent,children:"\u200B"},"u200B"),Et("span",{className:vr(c.tabText,c.resetIndent),"data-source":l,children:o},"tabText")];return n&&v.push(Et("span",{className:vr(c.hint,c.resetIndent),children:Et(ns,{keyCode:"tab"},"tabHint")})),cr(f,v)},[s,o,n]),_=hc(()=>{let f=[];return d&&f.push(new wn("inline")),p&&f.push(new In("selection")),f.push(new at("placeholders")),r&&f.push(new kn("keywords")),f},[d,p,r]),w=hc(()=>{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?Eh("div",{ref:f=>{f!=null&&f.parentElement&&(h.current=f==null?void 0:f.parentElement)},className:c.root,style:w,children:[Et(vh,{tagName:"span",containerTagName:"div",className:vr(c.container,c.agentText),disableLineBreaks:we(a),content:e||"\u200B",onAfterParse:m,matchers:_,selection:g,keywordMatches:i,inputElement:a,inputStyle:w,boundaryRef:h,inlineSuggestionsOnlyAtEnd:!u}),Et("br",{})]}):null},Th=({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:u}=s,{showTabCompletion:d,visible:g,showStyleSuggestions:h}=o;return{showTabHint:p,showStyleSuggestions:h,showTabCompletion:d,content:l,tabText:c,source:a,keywordMatches:((m=n.list)==null?void 0:m.keywordMatches)??[],enabled:g&&u!==!1}},yc=Ch(Th)(wh);import cy from"classnames";import{useEffect as py}from"react";import{useDispatch as uy,useSelector as Q}from"react-redux";import{createAsyncThunk as lo,createSlice as kh}from"@reduxjs/toolkit";var Sc={list:[],fetchState:"idle",isInitialRequest:null},_c=t=>t.autoflows.list||[],vc=t=>e=>{var o;return(o=e.list)==null?void 0:o.find(n=>n.triggerPayload===t)},Ee=lo("autoflows/getAll",async(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");return o.getAutoflows(t)}),_r=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(Ee(t.platformSessionId))}),xr=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(Ee(t.platformSessionId))}),Ph=kh({name:"autoflows",initialState:Sc,reducers:{},extraReducers:t=>{t.addCase(_r.pending,(e,o)=>{let n=vc(o.meta.arg.triggerPayload)(e);n.state="Started",n.isBusy=!0}),t.addCase(xr.pending,(e,o)=>{let n=vc(o.meta.arg.triggerPayload)(e);n.state="Aborted",n.isBusy=!0}),t.addCase(Ee.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}),t.addCase(Ee.rejected,e=>{e.fetchState="error"}),t.addCase(Ee.fulfilled,(e,o)=>{e.list=o.payload,e.fetchState="done"}),t.addCase(I,()=>Sc)}}),xc=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(Ee(t))}),s.on("sessionCompleted",()=>{o(Ee(t))})}),bc=lo("autoflows/closeStream",(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");o.closeStream(t)}),Cc=Ph.reducer;import{createAsyncThunk as po,createSlice as Ih}from"@reduxjs/toolkit";var wc={list:[],fetchState:"idle",isInitialRequest:null,sentSuggestions:[],errorSuggestions:[],answeredSuggestions:[]},Tc=t=>t.customMessages.list,Ec=t=>e=>!!e.customMessages.sentSuggestions.find(o=>o===t),kc=t=>e=>!!e.customMessages.answeredSuggestions.find(o=>o===t),Pc=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)}),Ic=Ih({name:"customMessages",initialState:wc,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,()=>wc)}}),Rc=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(Ic.actions.onCustomMessage(r))})}),Lc=po("customMessages/closeStream",(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");o.closeStream(t)}),Ac=Ic.reducer;import{createAsyncThunk as Mc,createSlice as Rh}from"@reduxjs/toolkit";var Lh={jwt:null,accountUrl:null,interval:null},Oc=t=>e=>{let{exchangeToken:{jwt:o,accountUrl:n}}=e;return o&&n?`${n}/apis/admin/session/jwt/?jwt=${o}&redirect=${t}`:null},br=Mc("exchangeToken/getTemporaryExchangeToken",async(t,e)=>{let{deepdeskAPI:o}=e.extra,n=await o.getTemporaryExchangeToken();return{accountUrl:o.client.baseUrl,jwt:n}}),Cr=Mc("exchangeToken/pollExchangeToken",(t={},e)=>{let{interval:o=1e3*60*30}=t,{dispatch:n}=e;return n(br()),setInterval(()=>n(br()),o)}),Nc=Rh({name:"exchangeToken",initialState:Lh,reducers:{stopPollExchangeToken(t){t.interval&&clearInterval(t.interval),t.interval=null}},extraReducers:t=>{t.addCase(br.fulfilled,(e,o)=>{e.jwt=o.payload.jwt,e.accountUrl=o.payload.accountUrl}),t.addCase(Cr.fulfilled,(e,o)=>{e.interval=o.payload})}}),{stopPollExchangeToken:Dc}=Nc.actions,Hc=Nc.reducer;function Bc(t){let{customMessages:e,autoflows:o}=t;return o.fetchState==="loading"&&o.isInitialRequest===!0||e.fetchState==="loading"&&e.isInitialRequest===!0}import{Fragment as Uh}from"react";import{connect as zh}from"react-redux";import Bh from"classnames";import{Fragment as Fh}from"react";import Ah from"classnames";var Fc={root:"_root_838fd_1"};import{jsx as Oh}from"react/jsx-runtime";var Mh=({className:t,children:e})=>{let o=y("Unicode",Fc);return Oh("span",{className:Ah(t,o.root),children:e})},Kc=Mh;var Uc={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 wr={};U(wr,{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 An}from"react/jsx-runtime";var Kh=({disabled:t,state:e,displayName:o,description:n,onStartAutoflow:s,onStopAutoflow:r})=>{let i=y("Autoflow",Uc),a=T(wr),l=e==="Started"?"stop":"start",c=l==="start"?"\u25B6":l==="stop"?"\u25FC":"";return An(N,{className:Bh(i.root,{[i.isDisabled]:t,[i.isCompleted]:e==="Completed",[i.isAborted]:e==="Aborted",[i.isStarted]:e==="Started"}),children:[$e(H,{children:An(H.Content,{children:[An(H.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(Fh,{children:[$e(Kc,{children:c})," ",$e("span",{children:a(l)})]})})})]})},zc=Kh;import{jsx as jc}from"react/jsx-runtime";var jh=(t,e)=>{let o=e.filter(n=>n.state==="Started");return o.length>0?o.indexOf(t)===-1:!1},Vh=({autoflows:t,onStartAutoflow:e,onStopAutoflow:o,platformSessionId:n})=>jc(Uh,{children:t.map(s=>jc(zc,{displayName:s.displayName,description:s.description,disabled:s.isBusy||jh(s,t),state:s.state,onStartAutoflow:()=>e({platformSessionId:n,triggerPayload:s.triggerPayload}),onStopAutoflow:()=>o({platformSessionId:n,triggerPayload:s.triggerPayload})},s.displayName))}),qh=({autoflows:t,conversation:e})=>{var o;return{autoflows:t.list,platformSessionId:(o=e.current)==null?void 0:o.sessionId}},Wh={onStartAutoflow:_r,onStopAutoflow:xr},Vc=zh(qh,Wh)(Vh);import{useEffect as Gh,useState as $h}from"react";import{useDispatch as Xh}from"react-redux";import Gc from"classnames";import{jsx as qc}from"react/jsx-runtime";var Tr=()=>qc("svg",{width:"1em",height:"1em",viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg",children:qc("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 Wc={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 $c}from"react/jsx-runtime";var Qh=({entities:t})=>{let e=y("EntitiesWidgetList",Wc),[o,n]=$h(void 0),s=Xh(),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 Gh(()=>{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)=>$c("button",{title:a.text,className:e.entity,type:"button",onClick:()=>i(a),children:[kt("span",{className:e.entityText,children:a.text}),$c("span",{className:e.iconWrapper,children:[kt("span",{className:Gc(e.icon),children:kt(Tr,{})}),kt("span",{className:Gc(e.icon,o===l&&e.iconClicked),children:kt(Tr,{})})]})]},a.text))})},Xc=Qh;import Yh from"classnames";import{useCallback as Qc}from"react";import{useDispatch as ey,useSelector as Mn}from"react-redux";var uo={};U(uo,{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 ke={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 He,jsxs as On}from"react/jsx-runtime";var ty=({suggestion:t})=>{let e=T(uo),o=ey(),n=Mn(Ec(t.text)),s=Mn(kc(t.text)),r=Mn(Pc(t.text)),i=Mn(Do),{replyOptions:a}=t,l=Qc(p=>{p.preventDefault(),p.stopPropagation(),!(n||!i)&&o(Rn({platformSessionId:i,suggestion:t}))},[t,n,o,i]),c=Qc(p=>{if(p.preventDefault(),p.stopPropagation(),!i||!a)return;let u=parseInt(p.target.dataset.index,10),d=a[u];o(Ln({platformSessionId:i,reply:d,suggestion:t}))},[t,n,o,i]);return On(N,{onClick:l,className:Yh(ke.root,{[ke.isUsed]:n,[ke.hasError]:r}),children:[He(H,{children:On(H.Content,{children:[On(H.Title,{className:ke.title,children:[t.text," ",He(ss,{className:ke.label,children:"analyse tool"})," ",r&&He("span",{className:ke.errorIcon,role:"img","aria-label":e("sendingError"),title:e("sendingError"),children:"!"})]}),a&&a.length>0&&He("ul",{className:ke.quickReplies,children:a.map(p=>He("li",{className:ke.quickReply,children:p.title},p.title))})]})}),On(N.Actions,{fixed:r||n,children:[a&&a.length>0&&He(N.DropdownButton,{label:e("answer"),disabled:s,children:a.map((p,u)=>He(N.DropdownItem,{index:u,label:p.title,onClick:c},p.title))}),He(N.ActionButton,{primary:!0,disabled:n,onClick:l,label:e(n?"suggestionSent":r?"tryAgain":"sendSuggestion")})]})]})},Zc=ty;import{jsx as Jc}from"react/jsx-runtime";var Yc=()=>Jc("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:Jc("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 oy}from"react";import{jsx as Xe,jsxs as Nn}from"react/jsx-runtime";var ny=({suggestion:t,lines:e,onEdit:o,onUse:n})=>{var d;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)},u=oy(g=>{window.open(r,"_blank"),g.stopPropagation(),g.preventDefault()},[r]);return Nn(N,{onClick:c,"data-testid":"edit-suggestion",children:[Nn(H,{children:[a&&t.image&&Xe(H.Image,{src:Pn(t,"small",l||void 0),title:t.title}),Nn(H.Content,{children:[t.title&&Xe(H.Title,{children:t.title}),t.searchKeywords&&((d=t.searchKeywords)==null?void 0:d.length)>0&&Xe(N.Labels,{labels:t.searchKeywords}),Xe(H.Content,{cropText:e==="single",lineClamp:e==="multiple",children:s})]})]}),Nn(N.Actions,{children:[r&&Xe(N.ActionButton,{onClick:u,label:i("visitUrl")}),Xe(N.ActionButton,{primary:!0,onClick:p,label:i("preview")}),Xe(N.ActionButton,{primary:!0,onClick:c,label:i("useSuggestion")})]})]})},ep=ny;import{Fragment as iy,jsx as tp}from"react/jsx-runtime";var ry=({contentType:t,lines:e,suggestions:o})=>{let n=oe(),s=sy(gt),r=a=>{n.send(Fs,{state:s,suggestion:a,contentType:t})},i=(a,l)=>{n.send(xe,{text:a,suggestion:{...l,source:l.source,sourceText:l.text}})};return tp(iy,{children:o.map(a=>tp(ep,{suggestion:a,lines:e,onEdit:l=>r(l),onUse:l=>i(l,a)},a.text||a.url||a.message))})},op=ry;var Er={};U(Er,{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 np={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 sp}from"react/jsx-runtime";var rp=()=>sp("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:sp("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 ip}from"react/jsx-runtime";var ap=()=>ip("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:ip("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=Q(_e);py(()=>o?e.every(n=>!!n)?t():()=>{}:()=>{},[...e,o])},dy=()=>{let t=T(Er),e=uy(),o=b("isEmbedded"),n=y("Widget",np),s=b("showAutoflows"),r=b("showCustomMessages"),i=b("showPersonalCollectionLink"),a=b("showSummaryCommand"),l=b("showKnowledgeSearch"),c=b("showSearch"),p=Q(bt),u=Q(yn),d=Q(_c),g=Q(gn),h=Q(Tc),m=Q(Ho),_=Q(Bo),w=Q(_e),f=Q(Do),v=Q(Bc),x=Q(gt),k=oe(),C=Q(ka),O=Q(Oc("/admin/personal-collection")),ee=b("adminUrl");if(Dn(()=>(e(co(f)),e(Rc(f)),()=>{e(Lc(f))}),[e,_,r,f]),Dn(()=>(e(Ee(f)),e(xc(f)),()=>{e(bc(f))}),[e,_,s,f]),Dn(()=>{u.forEach(({type:P})=>{e(P==="entities"?ae():Se(P))})},[e,_,m,p]),Dn(()=>(e(Cr()),()=>{e(Dc())}),[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:ee})})},"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:cy(n.root),"data-testid":"widget",children:Pt(is,{className:n.sectionList,children:[D&&M(Ue,{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(ap,{}),t("linkSummary")]}),l&&Pt("button",{className:n.shortcut,onClick:()=>k.send("ShowCommandPalette",{isOpen:!0,page:"knowledgeSearch"}),children:[M(rp,{}),t("linkKnowledgeSearch")]}),O&&Pt("a",{className:n.shortcut,target:"_blank",href:O,rel:"noreferrer",children:[M(Yc,{}),t("linkPersonalcollection")]})]})}),r&&h.length>0&&M(Ue,{type:"custom-messages","data-testid":"custom-messages",children:M(ge,{withDivider:!0,children:h.map(P=>M(Zc,{suggestion:P},P.text))})}),s&&d.length>0&&M(Ue,{type:"autoflows",title:t("titleAutoflows"),"data-testid":"autoflows",children:M(ge,{withDivider:!0,children:M(Vc,{})})}),u.map(({type:P,title:B,amount:q,lines:zn})=>{var Fe;switch(P){case"entities":return g&&g.length>0&&M(Ue,{type:P,title:B,"data-testid":`type-${P}`,children:M(Xc,{entities:g})},P);default:return((Fe=x[P])==null?void 0:Fe.fetchState)==="done"&&x[P].suggestions.length>0&&M(Ue,{type:P,title:B,"data-testid":`type-${P}`,children:M(ge,{withDivider:!0,children:M(op,{lines:zn,contentType:P,suggestions:x[P].suggestions.slice(0,q)||[]})})},P)}})]})})},lp=dy;function cp(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,u=/[\u200B-\u200D\uFEFF]/;if(!u.test(l))return c;for(let d=0;d<=l.length;d++)if(u.test(l[d])||p++,p===c)return d;throw new Error("Offset out of range")}function a(l){var c;switch(l.nodeType){case Node.TEXT_NODE:{let p=l.textContent,u=p.replace(mo,""),d=s+u.length,g=e>=s&&e<=d,h=o>=s&&o<=d;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=d;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 u=0;u<l.childNodes.length&&(a(l.childNodes[u]),!r);u++);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 kr(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 u=p===o,d=p===s;switch(p.nodeType){case Node.TEXT_NODE:{let g=p.textContent;u&&(i=l+g.substring(0,n).replace(mo,"").length),d&&(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&&(u&&m===n&&(i=l),c(p.childNodes[m]),d&&m===r-1&&(a=l),a===void 0);m++);!d&&g==="DIV"&&!h&&l++,d&&(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 Hn(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,u=c===s;switch(p&&i++,c.nodeType){case Node.TEXT_NODE:{if(i!==0)return;let d=p?n:0,g=u?r:void 0,h=c.textContent.replace(mo,"");d===0&&g===void 0?a+=h:a+=h.substring(d,g);break}case Node.ELEMENT_NODE:{let{tagName:d}=c,g=c.nextSibling===null;i===0&&d==="BR"&&!g&&(a+=`
4
- `);for(let h=p?n:0;h<(u?Math.min(r,c.childNodes.length):c.childNodes.length)&&(l(c.childNodes[h]),i!==1);h++);!u&&i===0&&d==="DIV"&&!g&&(a+=`
5
- `);break}default:break}u&&i++}return l(t),a}var Rt=class extends Me{observer;getText(){let e=new Range;return e.selectNodeContents(this.element),Hn(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:kr(this.element,o)}getSelectedText(){if(!this.currentSelection)return"";let{start:e,end:o}=this.currentSelection;return Hn(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 Pr=class{constructor(e){this.name=e;this.broadcastChannel=new BroadcastChannel(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{constructor(e){this.params=e;this.deepdeskUrl=e.deepdeskUrl,this.eventMap=e.eventMap,this.defaultChannel=this.createChannel("deepdesk-general")}sessionId;deepdeskUrl;channel;defaultChannel;eventMap;get isCrossOrigin(){return this.params.deepdeskUrl!==(this.params.origin||window.location.origin)}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.params.createCustomChannel?this.params.createCustomChannel(e):this.isCrossOrigin?new Ir(e,this.deepdeskUrl,{debug:!0}):new Pr(e),n=s=>{var r,i;s.origin===this.deepdeskUrl&&s.data.type==="event"&&s.data.channel===e&&(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,channel:this.sessionId})}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)}},pp=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"},de=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:u=x=>x.status>=500,version:d="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 d=="string"&&(h.headers={...h.headers,"X-Deepdesk-API-Version":d});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=>u(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 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 Bn(t){return{...A(t),tags:t.tags}}var Be=class t{constructor(e,o={}){this.options=o;this.client=new de(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",{...F(e),tags:e.tags},{version:"v2"});return Bn(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 Bn(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=F(o);o.tags&&(n.tags=o.tags);let s=await this.client.put(`/api/conversations/${e}`,n,{version:"v2"});return Bn(s)}async postMessages(e,o){return(await this.client.post(`/api/conversations/${e}/messages`,o.map(s=>({...F(s),tags:s.tags})),{version:"v2"})).map(s=>Bn(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",F({...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:F({...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/",F(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}`,F(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`,F(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",F(e),{abortLatest:!0});return A(o)}async search(e){let o=await this.client.post(`/api/profiles/${e.profile}/search`,F(e),{version:"v2"});return A(o)}async knowledgeSearch(e,o,n){let s=await this.client.post("/api/knowledge-search/search",F({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 gy;(e=>{let t;(r=>(r.Started="Started",r.Aborted="Aborted",r.Completed="Completed"))(t=e.AutoflowSessionState||={})})(gy||={});var fo=class{constructor(e,o={}){this.apiUrl=e;this.client=new de(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`,F(o));return A(n)}async answerCustomMessage(e,o){await this.client.post(`/sessions/${e}/answers`,F(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",F(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 xy,configureStore as by}from"@reduxjs/toolkit";import{createSlice as fy}from"@reduxjs/toolkit";var up={startTime:null,stopTime:null},dp=fy({name:"handlingTime",initialState:up,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,()=>up)}}),{handlingTimeStart:mp,handlingTimeStop:Fn,handlingTimeReset:gp}=dp.actions,fp=dp.reducer;var hp=(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 hy,createSlice as yy}from"@reduxjs/toolkit";var Mr={list:{keywordMatches:[]},fetchState:"idle",isInitialRequest:null};var Qe=hy("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})}),Sy=yy({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",Ie(e.list,o.payload)||(e.list=o.payload)}).addCase(I,()=>Mr)}}),yp=Sy.reducer;var Sp=(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:d}=c.input;return d===a&&!o||(clearTimeout(e),d==="")||(e=setTimeout(()=>{o=!1,s.dispatch(n.getStyleSuggestions({text:d}))},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 vp=(t={})=>{let e={getTextSuggestions:Se,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,u=(m=l.conversation.current)==null?void 0:m.id,d=r.type===dn.toString();if(!u||!c&&!p)return a;let{input:{userCommitted:g}}=l;return vy(g,i)&&!d||(clearTimeout(o),!e.check(l))||(o=setTimeout(()=>{let _=rt(l);_===""?n.dispatch(e.getTextSuggestions("default")):n.dispatch(e.getAutocompleteSuggestions(_))},d?0:e.debounce)),a}};var _p=Qe.fulfilled.toString();function _y(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 xp=t=>e=>o=>n=>{var p;if(n.type!==_p){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=_y(s,i);n.type===_p&&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 Cy=xy({activeSuggestion:Ha,answer:Tl,auth:Za,autoflows:Cc,conversation:mi,contentTypes:ll,customMessages:Ac,exchangeToken:Hc,entities:ul,handlingTime:fp,info:ia,input:gs.reducer,overlayInput:W.reducer,settings:ci,profile:Rl,search:da,summary:Sl,styleSuggestions:yp,ui:za,textSuggestions:Aa});function bp(t){return by({reducer:Cy,middleware:e=>[...e({thunk:{extraArgument:{dynamicThunkObject:t.dynamicThunkObject,deepdeskAPI:t.deepdeskAPI,deepdeskBrokerAPI:t.deepdeskBrokerAPI}},serializableCheck:!1}),hp(),vp({debounce:200}),Sp({debounce:500}),xp(t.deepdeskAPI),...t.middleware?t.middleware:[]],preloadedState:t.preloadedState})}var wy=t=>{var e;return((e=t==null?void 0:t.type)==null?void 0:e.toLowerCase())??"unknown"},Ty=t=>e=>o=>n=>{var a;let s=e.getState(),r=ps("inlineSuggestions")(s);switch(n.type){case ve.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:wy(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 be.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(Le([])),e.dispatch(Ae()));break}default:break}return i},Cp=Ty;function Or(t){return t.toISOString().replace("T"," ").replace("Z","")}function wp(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 O,ee,D;let{text:n,metrics:{numCharsTyped:s,numCharsPasted:r,numCharsCut:i,numCharsDeleted:a,numPaste:l,agentStartedTypingTimestamp:c,externalTimeTotalSeconds:p,pastes:u,cuts:d,deletions:g,textSuggestions:h,offeredTextSuggestions:m}}=e[t],_=n.length,f=h.reduce((P,{text:B,searchTerm:q})=>P+B.length-(q?q.length:0),0),v=c??Date.now(),x=(Date.now()-v)/1e3+(p||0),k=s/x,C=h.reduce((P,{searchTerm:B})=>P+(B?B.length:0),0);return{conversationId:e.conversation.current.id,source:"agent",text:n,clientVersion:o.version,pastes:u,cuts:d,deletions:g,lenTextTyped:s+C,lenTextTotal:_,lenTextAssisted:f,lenTextPasted:r,lenTextCut:i,lenTextDeleted:a,timeTotalSeconds:x,charsPerSecond:k,numPastes:l,textSuggestionsV2:h,suggestionsCounters:[{source:"gpt",countOffered:m.filter(P=>P.source==="gpt").length}],agentId:(O=e.info.agentInfo)==null?void 0:O.agentId,agentName:(ee=e.info.agentInfo)==null?void 0:ee.agentName,agentEmail:(D=e.info.agentInfo)==null?void 0:D.agentEmail}}function Tp(t,e){let o=t.closest(e);if(o)return o;let n=t.getRootNode().host;return n instanceof HTMLElement?Tp(n,e):null}function Ep(t,e){return Tp(t,e)}function kp(t){return typeof t=="object"&&t!==null&&"name"in t&&"message"in t}function Dr(t){return t instanceof HTMLElement&&(we(t)||Yo(t))}var Pp=(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 Ey(t){return t.offsetParent!==null}function Ip(t){if(!Ey(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 Hr(t,e,o=100){let n=Ip(t);e({isVisible:n});let s=setInterval(()=>{let r=Ip(t);r!==n&&(n=r,e({isVisible:n}))},o);return()=>{clearTimeout(s)}}import{jsx as ne}from"react/jsx-runtime";var Rp=Pp("showTabHint",!0),Un=class t{static version="10.1.6";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,createCustomChannel:l}){let c=e.replace(/\/api$/,"");this.deepdeskApi=new Be(c,{token:r,fetch:i}),this.version=n,this.instanceId=t.count++;let p={deepdeskAPI:this.deepdeskApi,dynamicThunkObject:this.dynamicThunkObject,middleware:[Cp({emit:(u,d,g)=>this.emit(u,d,g),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=>Rp.update(u),sendEvent:(u,d)=>this.deepdeskApi.sendEvent(u,d)})]};o&&Object.assign(p,{deepdeskBrokerAPI:new fo(o)}),this.store=bp(p),this.broadcastEvents=new pp({debug:!0,deepdeskUrl:c,eventMap:Ja(this.store),createCustomChannel:l}),this.store.dispatch(Ft),this.store.dispatch(Xt(Rp.value())),this.store.dispatch(Ft({locale:s,adminUrl:c,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(De()),new Promise(e=>{let o=this.store.subscribe(()=>{let n=this.store.getState();_e(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(be());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(Ae())}notifyEditSuggestion(e){this.store.dispatch(Ra(e.contentType,e.suggestions)),this.store.dispatch(ve({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(Le([])))}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:u}=this.state.input;this.store.dispatch(Xt(!1)),this.state.input.selectedSuggestionIndex>-1?this.stageSelectedSuggestion({inputType:"tab"}):this.settings.showTabCompletion&&u&&u.text.startsWith(p)&&(this.store.dispatch(ie({text:u.text,suggestion:u,eventMetrics:{inputType:"tab"},replace:"until-selection-end"})),this.store.dispatch(Ae())),e.preventDefault();break}default:}}handleAfterSendMessage(e){this.emit("send-message",e),this.store.dispatch(Ti()),this.store.dispatch(Le([]))}handlingTimeStart(){this.state.handlingTime.startTime||(E.info("Start handling time"),this.store.dispatch(mp()))}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:this.version});e&&Object.assign(o,{text:e}),this.store.dispatch(Si(this.state.overlayInput.metrics))}logHandlingTime(){let e=wp(this.state,{version:this.version});this.deepdeskApi.sendEventV1("Handling Time",e),this.store.dispatch(gp())}notifySubmit(e={}){this.shouldAbort()||(this.store.dispatch(Ae()),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(()=>{Br(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(()=>{Br(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:u,detectSubmit:d,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:u,inlineSuggestions:w});let f=m&&Ep(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(ne(no,{store:this.store,customStyles:n,children:ne(Qt,{broadcastEvents:this.broadcastEvents,children:ne(yc,{inputElement:e})})}),v),Kn(ne(no,{store:this.store,customStyles:n,children:ne(Qt,{broadcastEvents:this.broadcastEvents,children:ne(Cn,{})})}),x),Kn(ne(no,{store:this.store,customStyles:n,children:ne(Qt,{broadcastEvents:this.broadcastEvents,children:ne(Ol,{})})}),this.createContainer("deepdesk-overlays")),Ve(e),this.inputMediator=h||(we(e)?new Oe(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",()=>{d&&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(ne(no,{store:this.store,customStyles:n,children:ne(Qt,{broadcastEvents:this.broadcastEvents,children:ne(lp,{})})}),e),this.whenConversationLoaded(()=>{var a;this.broadcastEvents.setSessionId((a=this.state.conversation.current)==null?void 0:a.sessionId)})}unmountWidget(){this.widgetRoot&&Br(this.widgetRoot),this.widgetRoot=null}setupHandlingTime(e){let o=Hr(e,({isVisible:n})=>{n?this.handlingTimeStart():this.handlingTimeStop()});this.unmountHandlers.push(()=>{this.handlingTimeStop(),o()}),this.whenConversationLoaded(()=>{this.handlingTimeStart()})}handleError(e){kp(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(Se(n))})}catch(n){this.handleError(n)}}};async function ky(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 Py(t,e,o={}){let n=o.replace?It(t,o.replace.start,o.replace.end):cp(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 Iy(t){return t.replace(/\[([\w\s\d]+)\]\((https?:\/\/[^\s]+)\)/g,'<a href="$2" target="_blank" rel="noreferrer">$1</a>')}async function Ry(t,e,o){await new Be(t).authenticateWithKey(e,o)}async function Ly(t){let o=await new de(t).get("/platform/config/",{version:null});return A(o)}async function Ay(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 My(t,e){let o=await Ay(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{H as Card,hu as Chip,Rt as ContentEditableInput,Be as DeepdeskAPI,Un as DeepdeskSDK,de as HTTPClient,Me as InputMediator,ze as InputType,ns as KeyboardHint,ss as Label,No as Locale,Ue as Section,is as SectionList,fe as Sources,N as Suggestion,ge as SuggestionList,Oe as TextAreaInput,ot as ToggleButton,My as attachFile,Ry as authenticateWithKey,zt as createOverlayContainer,It as createRangeFromOffsets,so as escapeHTML,Ly as fetchPlatformConfig,Iy as formatTextMarkup,kr as getRangeOffsets,Hn as getRangeText,Dr as isSupportedInputElement,Py as updateContentEditable,ky as updateTextArea,y as useStyles,Hr as waitForElementVisibilityChange};
3
+ `,Ke.MISSING_INTL_API,i);var x=o.getPluralRules(e,{type:p.pluralType}).select(d-(p.offset||0));_=p.options[x]||p.options.other}if(!_)throw new ts(p.value,d,Object.keys(p.options),i);a.push.apply(a,Bt(_.value,e,o,n,s,d-(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 os(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:Mo(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.NumberFormat).bind.apply(e,bo([void 0],o,!1)))},{cache:os(t.number),strategy:Oo.variadic}),getDateTimeFormat:Mo(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.DateTimeFormat).bind.apply(e,bo([void 0],o,!1)))},{cache:os(t.dateTime),strategy:Oo.variadic}),getPluralRules:Mo(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.PluralRules).bind.apply(e,bo([void 0],o,!1)))},{cache:os(t.pluralRules),strategy:Oo.variadic})}}var Yr=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 u=p.reduce(function(d,m){return!d.length||m.type!==j.literal||typeof d[d.length-1]!="string"?d.push(m.value):d[d.length-1]+=m.value,d},[]);return u.length<=1?u[0]||"":u},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=qr(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=$r,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 gu(t,e){return e.split(".").reduce((o,n)=>o?o[n]:void 0,t)}var mu="dummy",ns=uu(null);function T(t){let e=du(ns);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=gu(o,n);return r?new Yr(r).format(s):(e!==mu&&console.warn(`${n} does not exist in messages of ${e}`),`[${n}]`)}}var ss={};z(ss,{enUS:()=>fu,nlNL:()=>hu});var fu={experimental:[{type:0,value:"Experimental"}]},hu={experimental:[{type:0,value:"Experimenteel"}]};import{jsx as ti}from"react/jsx-runtime";var ei=({children:t})=>{let e=y("Chip",Vr);return ti("span",{className:e.root,children:t})},No=()=>{let t=T(ss);return ti(ei,{children:t("experimental")})},yu=ei;import Su from"classnames";var oi={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",oi);return xu("span",{"data-key":vu[e],className:Su(t,n.root),...o})},rs=_u;import bu from"classnames";var ni={root:"_root_4a08n_1"};import{jsx as wu}from"react/jsx-runtime";var Cu=({className:t,children:e,...o})=>{let n=y("Label",ni);return wu("span",{...o,className:bu(t,n.root),children:e})},is=Cu;var si={root:"_root_jlggj_1",subTitleContainer:"_subTitleContainer_jlggj_5",subtitle:"_subtitle_jlggj_9",suggestions:"_suggestions_jlggj_17"};import{jsx as as,jsxs as Eu}from"react/jsx-runtime";var Tu=({title:t,children:e,type:o,...n})=>{let s=y("Section",si);return Eu("section",{...n,className:s.root,"data-section-type":o,children:[t&&as("div",{className:s.subTitleContainer,children:as("span",{className:s.subtitle,children:t})}),as("div",{className:s.suggestions,children:e})]})},Ue=Tu;import ku from"classnames";import Pu from"react";var ri={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",ri);return Ru("div",{ref:o,className:ku(n.root,t),children:e})}),ls=Iu;import Do from"classnames";import Lu,{createContext as Au,useCallback as Mu,useContext as Ft}from"react";var cs={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 ge,jsxs as Bu}from"react/jsx-runtime";var tt=Au(cs),Ou=({fixed:t,children:e,...o})=>{let n=Ft(tt);return ge("div",{...o,className:Do(n.actions,{[n.actionsIsFixed]:t}),children:e})},Nu=({className:t,primary:e,disabled:o,label:n,children:s})=>{let r=Ft(tt);return Bu("div",{className:Do(t,r.actionButton,r.dropdownButton,{[r.actionButtonIsPrimary]:e,[r.actionButtonIsDisabled]:o}),onMouseDown:i=>i.stopPropagation(),onClick:i=>i.stopPropagation(),children:[n,ge("ul",{className:r.dropdownList,children:s})]})},Du=({index:t,label:e,onClick:o})=>{let n=Ft(tt);return ge("li",{className:n.dropdownItem,children:ge("button",{className:n.dropdownItemButton,type:"button","data-index":t,onClick:o,children:e})})},Hu=({className:t,primary:e,disabled:o,onClick:n,label:s})=>{let r=Ft(tt);return ge("button",{type:"button",className:Do(t,r.actionButton,{[r.actionButtonIsPrimary]:e,[r.actionButtonIsDisabled]:o}),onClick:n??(i=>i.stopPropagation()),disabled:o,"aria-hidden":o,children:s})},ps=({labels:t})=>{let e=Ft(tt);return ge("div",{className:e.labels,children:t.map(o=>ge("span",{className:e.label,children:o},o))})},ot=Lu.forwardRef(({className:t,selected:e,onClick:o,children:n,as:s="div",...r},i)=>{let a=y("Suggestion",cs),l=Mu(c=>{c.preventDefault(),o&&o(c)},[o]);return ge(s,{...r,ref:i,className:Do(t,a.root,{[a.isSelected]:e,[a.isClickable]:!!o}),onClick:l,children:ge(tt.Provider,{value:a,children:n})})});ot.Labels=ps;ot.Actions=Ou;ot.ActionButton=Hu;ot.DropdownButton=Nu;ot.DropdownItem=Du;var N=ot;import Fu from"classnames";var ii={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",ii);return Uu("div",{className:Fu(o.root,{[o.isWithDivider]:t}),children:e})},me=Ku;import zu from"classnames";var ai={root:"_root_1wpmq_1",isCollapsed:"_isCollapsed_1wpmq_17"};import{jsx as us}from"react/jsx-runtime";var ju=({className:t,isCollapsed:e,title:o,onClick:n})=>{let s=y("ToggleButton",ai);return us("button",{type:"button",className:zu(s.root,t,{[s.isCollapsed]:e}),onClick:n,title:o,children:us("svg",{width:"14",height:"8",viewBox:"-2.5 -5 75 60",preserveAspectRatio:"none",children:us("path",{d:"M0,0 l35,50 l35,-50",fill:"none",stroke:"grey",strokeLinecap:"round",strokeWidth:"6"})})})},nt=ju;var li=/(?:[.,;:!?\\n]|:\\)|:\\(|:-\\)|:-\\()/g,st=/(((\$!\{)|(\{))[a-zA-Z0-9_.]+\})/g;var ci=/x-deepdesk-(([a-z0-9\-_])+-version)/,fe=(g=>(g.SEARCH="search",g.TEMPLATE="template",g.ELASTIC_SEARCH="search-autocomplete",g.GPT="gpt",g.TRIE="trie",g.TRIE_WITH_TYPOS="trie-with-typos",g.SEMANTIC="semantic",g.TEXT_RECOMMENDATION="text_recommendation",g.URL_RECOMMENDATION="url_recommendation",g.LINK_RECOMMENDATION="link_recommendation",g.PERSONAL_COLLECTION="personal-collection",g.PERSONAL_COLLECTION_SEARCH="personal-collection-search",g.SEARCH_OVERLAY="search-overlay",g.SEARCH_PREVIEW="search-preview",g.SEARCH_URL="search-url",g))(fe||{}),ze=(s=>(s.TAB="tab",s.ARROW="arrow",s.HOTKEY="hotkey",s.MOUSE="mouse",s))(ze||{});import{render as zn,unmountComponentAtNode as Ur}from"react-dom";import{Fragment as Km}from"react";import{createSlice as Vu}from"@reduxjs/toolkit";import{useSelector as qu}from"react-redux";var Ho=(o=>(o.NL_NL="nl-NL",o.EN_US="en-US",o))(Ho||{});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"},pi=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:Kt}=pi.actions,ds=t=>e=>e.settings[t],b=t=>qu(ds(t)),ui=pi.reducer;import{useState as kg}from"react";import{useDispatch as Pg,useSelector as qs}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 di(t){return typeof t=="object"&&!Array.isArray(t)&&t!==null}function Ie(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)=>Ie(r,e[i],o-1)):di(t)&&di(e)?Object.keys(t).length!==Object.keys(e).length?!1:Object.keys(t).every(i=>Ie(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 gi(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 gs(t,e=""){if(t.length===0)return;if(t.length===1)return t[0];let o=gi(t,Xu);return o&&o.text!==e?o:t[0]}import{createAction as Qu,createAsyncThunk as rt,createSlice as Zu}from"@reduxjs/toolkit";var mi={current:null,isSupported:null},I=Qu("resetConversation"),Bo=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.sessionId)||null},Fo=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.id)||null},Ko=t=>t.conversation.isSupported,ms=rt("conversation/isSupported",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.isConversationSupported(t.sessionId,t.options)}),Uo=rt("conversation/create",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.createConversation(t)}),zo=rt("conversation/bySessionId",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.getConversationBySessionId(t.sessionId,t.options)}),jo=rt("conversation/update",(t,e)=>{let{deepdeskAPI:o}=e.extra,n=Fo(e.getState());if(!n)throw new Error("No current conversation to update");return o.updateConversation(n,t)}),fs=rt("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})})}),Vo=rt("conversation/postMessages",(t,e)=>{let{deepdeskAPI:o}=e.extra,n=Fo(e.getState());if(!n)throw new Error("No current conversation to update messages");return o.postMessages(n,t.map(s=>({...s})))}),Ju=[Uo.rejected,zo.rejected,jo.rejected,Vo.rejected].map(t=>t==null?void 0:t.toString()),Yu=Zu({name:"conversation",initialState:mi,reducers:{},extraReducers:t=>{t.addCase(ms.fulfilled,(e,o)=>{e.isSupported=o.payload}).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)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(fs.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(jo.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(Vo.fulfilled,(e,o)=>{e.current&&(e.current.messages=o.payload)}).addCase(I,()=>mi).addMatcher(e=>Ju.includes(e.type),(e,o)=>{throw new Error(o.error.message)})}}),fi=Yu.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,externalTimeTotalSeconds:null,pastes:[],deletions:[],offeredTextSuggestions:[],textSuggestions:[],cuts:[]}};function Wo(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 Go=je("input/replaceText"),$o=je("input/keyDown"),Ut=je("input/sendMessage"),Xo=je("input/sendEditSuggestionMessage"),Qo=je("input/uiInputChange"),Zo=je("input/applyImageSuggestion"),J=je("input/sendEvent");function qo(t){if(!t.stagedSuggestion)return;let{text:e,suggestion:{source:o,abVariant:n,abTestName:s,trainingJobs:r,sourceText:i,searchTerm:a,text:l},eventMetrics:{inputType:c},replace:p}=t.stagedSuggestion,u=o==="search"||o==="personal-collection-search",d=e.slice(t.userCommitted.text.substring(0,t.userCommitted.selection.start).length);(u||p==="selection")&&(d=e),t.stagedSuggestion.suggestion.source==="search-overlay"&&(d=l),t.userCommitted.text=t.text,t.userCommitted.selection=t.selection,t.metrics.textSuggestions.push({text:d,source:o,abVariant:n,abTestName:s,inputType:c,sourceText:i,trainingJobs:r||[],searchTerm:u?t.userCommitted.text:a}),t.stagedSuggestion=null,t.textSuggestions=[],t.selectedSuggestionIndex=-1}var hi=t=>ed({name:t,initialState:Re,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,{...Re,selection:e.selection})},resetToCommitted(e){e.text=e.userCommitted.text,e.selection=e.userCommitted.selection,e.stagedSuggestion=null,e.tabCompletionSuggestion=gs(e.textSuggestions,e.userCommitted.text)},setInputHtml(e,o){e.html=o.payload},changeSelection(e,o){o.payload&&(Ie(e.selection,o.payload)||(e.selection=o.payload,e.userCommitted.selection=e.selection,e.stagedSuggestion&&qo(e)))},userInput(e,o){var i,a,l,c;if(e.previousKeyDownEvent){let{key:p,shiftKey:u,ctrlKey:d,metaKey:m,altKey:h}=e.previousKeyDownEvent;switch(p){case"Enter":u&&(e.metrics.numCharsTyped+=1);break;case"Backspace":case"Delete":{let{text:g}=e,{text:v}=o.payload,E=td(g,v);g.length-v.length>1&&e.metrics.deletions.push(...E.filter(f=>f.removed).map(f=>f.value)),e.metrics.numCharsDeleted+=g.length-v.length;break}case"C":case"V":case"X":if(!d&&!m){e.metrics.numCharsTyped+=1;let g=((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;g&&g.length>0&&(e.metrics.numCharsDeleted+=g.length,e.metrics.deletions.push(g))}break;case"Shift":break;default:if(!d&&!m&&!h){e.metrics.numCharsTyped+=1;let g=((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;g&&g.length>0&&(e.metrics.numCharsDeleted+=g.length,e.metrics.deletions.push(g))}}}!e.metrics.agentStartedTypingTimestamp&&o.payload.text!==e.text&&(e.metrics.agentStartedTypingTimestamp=Date.now()),o.payload.text===""&&(e.metrics=Re.metrics,e.textSuggestions=[]),e.text!==o.payload.text&&qo(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"&&qo(e)},commitSuggestion(e){qo(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=gs(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}){let n=o.agentStartedTypingTimestamp!=null?o.agentStartedTypingTimestamp:Date.now(),s=(Date.now()-n)/1e3;e.metrics.externalTimeTotalSeconds=s,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=Re.tabCompletionSuggestion,o.previousKeyDownEvent=Re.previousKeyDownEvent,o.textSuggestions=Re.textSuggestions,o.selectedSuggestionIndex=Re.selectedSuggestionIndex,o.metrics=Re.metrics})}}),hs=hi("input"),it=t=>t.input.userCommitted.text.substring(0,t.input.userCommitted.selection.end),nd=t=>t.input.selection,yi=()=>od(nd),{userInput:Si,changeSelection:ys,initialInput:vi,mergeMetrics:_i,nextTextSuggestionIndex:xi,offeredTextSuggestion:bi,previousTextSuggestionIndex:Ci,registerCut:wi,registerKeyDown:Ti,registerPaste:Ei,reset:ki,resetToCommitted:zt,setInputHtml:Pi,setSelectedTextSuggestionIndex:Jo,setTextSuggestions:Le,stageSuggestion:ie,commitSuggestion:Ae}=hs.actions,W=hi("overlay");import{useEffect as Ri,useRef as Li}from"react";var Ii={root:"_root_1qp5s_1",content:"_content_1qp5s_23"};import{jsx as Ai}from"react/jsx-runtime";var sd=({isOpen:t,autoFocus:e,children:o,onClose:n,onBack:s,overlayAriaLabel:r,contentAriaLabel:i})=>{let a=Li(null),l=Li(null),c=y("Dialog",Ii);return Ri(()=>{var d,m;let p=h=>{h.key==="Escape"&&(h.preventDefault(),h.stopPropagation(),s())},u=h=>{let g=window.getSelection();g!=null&&g.toString()||h.target===a.current&&t&&n()};return(d=a.current)==null||d.addEventListener("click",u),(m=a.current)==null||m.addEventListener("keyup",p),()=>{var h,g;(h=a.current)==null||h.removeEventListener("click",u),(g=a.current)==null||g.removeEventListener("keyup",p)}},[a,l,s,n]),Ri(()=>{var p,u;!a.current||!t||!e||(u=(p=a.current)==null?void 0:p.querySelector("input, textarea"))==null||u.focus()},[t,e,a]),t?Ai("div",{role:"dialog","data-testid":"dialog",className:c.root,"aria-label":r,ref:a,children:Ai("div",{ref:l,"data-testid":"dialog-content",className:c.content,"aria-label":i,children:o})}):null},at=sd;import{useEffect as _a}from"react";import{useDispatch as lg,useSelector as cg}from"react-redux";var Ss={};z(Ss,{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 Mi={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 Oi,jsxs as ad}from"react/jsx-runtime";var Yo=()=>ad("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 256 512","aria-labelledby":"angleLeftTitle",children:[Oi("title",{id:"angleLeftTitle",children:"AngleLeft"}),Oi("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 Ni,jsxs as ld}from"react/jsx-runtime";var Di=()=>ld("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 256 512","aria-labelledby":"angleRightTitle",children:[Ni("title",{id:"angleRightTitle",children:"AngleRight"}),Ni("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 Vt,useRef as Ts,useState as Td}from"react";import{useDispatch as Ed}from"react-redux";import{Interweave as kd}from"interweave";import Ji from"classnames";var vs={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 gd from"classnames";import{useEffect as cd,useRef as pd,useState as ud}from"react";function Hi(t,e){let o;return[(...n)=>{window.cancelAnimationFrame(o);let s=e?e(...n):n;o=window.requestAnimationFrame(()=>{t(...s)})},()=>window.cancelAnimationFrame(o)]}function en(t){let e=pd(null),[o,n]=ud(!1);return cd(()=>{let s=!1,r=parseFloat(window.getComputedStyle(document.body).zoom??"1"),[i,a]=Hi((p,u)=>{let d=e.current;if(!d)return;let m=p/r,h=u/r,g=d.getBoundingClientRect(),v=m>g.x&&m<g.x+g.width&&h>g.y&&h<g.y+g.height;v&&!s?(s=!0,n(!0)):!v&&s&&(s=!1,n(!1))},({clientX:p,clientY:u})=>[p,u]),[l,c]=Hi(()=>{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 te={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 Bi}from"react/jsx-runtime";var md=({inputElement:t,children:e})=>{let o=y("TabCompletion",te),[n,s]=en(t);return Bi("mark",{ref:n,className:gd(o.matchPlaceholder,{[o.hover]:s}),children:e})},lt=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 Bi(md,{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 tn(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 Fi(t){let{selectionStart:e,selectionEnd:o}=tn(t)?Sd(t):t;return[e,o]}function on(t){let[,e]=yd(),o=hd(null);return o.current=Fi(t),fd(()=>{let n=()=>{let[s,r]=o.current??[],i=Fi(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 nn(t,e){if(!e)return;let o=t,{value:n}=o,[s,r]=e,i=n.match(st);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 ct(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 Ki,le=new Map,_d=["bottom","height","left","right","top","width"],xd=(t={},e={})=>_d.some(o=>t[o]!==e[o]),Ui=()=>{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&&(Ki=window.requestAnimationFrame(Ui))};function zi(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&&Ui()},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(Ki)}}}}var ji,ce=new Map,Vi=()=>{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&&(ji=window.requestAnimationFrame(Vi))};function qi(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&&Vi()},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(ji)}}}}var _s=["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 xs(t,e,o){return o.forEach(n=>{e.style[n]=t[n]})}function pt(t){return parseFloat(t)}function sn(t){return Math.round(t*1e6)}function Wi(t){return t/1e6}function bs(t,e,o){if(t.boxSizing==="content-box")return;let{clientWidth:n}=e,s=pt(t.width),r=pt(t.borderLeftWidth),i=pt(t.borderRightWidth),a=pt(t.paddingRight),l=Wi(sn(s)-sn(r)-sn(i)),c=Wi(sn(n));if(l-c>2){let p=l-c;o.style.paddingRight=`${a+p}px`}}function jt(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};xs(n,o,_s),bs(n,t,o),e.mirrorOverflow&&(o.style.overflow="hidden",t.addEventListener("scroll",r));let i=qi(t,()=>{xs(n,o,_s),bs(n,t,o),r(),setTimeout(r,0)}),a=zi(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(xs(n,o,_s),bs(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(),u=window.getComputedStyle(e.closestScrollElement),d=pt(u.borderTopWidth),m=pt(u.borderBottomWidth),h=p.top+d-c.top,g=c.top+c.height+-(p.top+p.height-m);o.style.clipPath=`inset(${h}px 0px ${g}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 Cs={};z(Cs,{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 Gi,jsxs as wd}from"react/jsx-runtime";var $i=()=>wd("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 512 512","aria-labelledby":"circleCheckTitle",children:[Gi("title",{id:"circleCheckTitle",children:"Check"}),Gi("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 Xi}from"react/jsx-runtime";var Qi=()=>Xi("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",fill:"currentColor",children:Xi("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 Zi=(i=>(i.CUT="Cut",i.BACKSPACE="Backspace",i.DELETE="Delete",i.ERASEEOF="EraseEof",i.UNDO="Undo",i.CLEAR="Clear",i))(Zi||{}),Me=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(Zi).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;Ie(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 Oe=class extends Me{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 he,jsxs as ws}from"react/jsx-runtime";var Pd=({value:t,onUse:e,...o})=>{var p;let n=T(Cs),s=Ed(),r=y("EditSuggestionTextInput",vs),[i,a]=Td(null),l=Ts(null),c=((p=t.match(st))==null?void 0:p.length)||0;return Vt(()=>{let u;return l.current&&(a(l.current),u=new Oe(l.current),u.on("change",({plainText:d})=>{s(W.actions.userInput({text:d,selection:u.getSelection()}))}),u.on("keydown",d=>{s(W.actions.registerKeyDown(Wo(d))),d.code==="Enter"&&d.shiftKey&&e(u.getText())}),u.on("paste",({pastedText:d,selectionText:m})=>{s(W.actions.registerPaste({text:d,selectionText:m}))}),u.on("cut",({selectionText:d})=>{s(W.actions.registerCut(d))})),()=>{s(W.actions.reset()),u.dispose(),u.deactivate()}},[l]),Vt(()=>{t&&l.current&&(l.current.value=t)},[t,l]),Vt(()=>{l.current&&setTimeout(()=>{if(!l.current)return;let u=l.current.value.length;l.current.setSelectionRange(u,u),l.current.focus()},0)},[l]),ws("div",{className:r.textInputWrapper,children:[he("textarea",{...o,ref:l,"data-testid":"edit-suggestion-dialog-textarea",className:r.textInput,defaultValue:t,onChange:()=>{}}),i&&he(Id,{inputElement:l.current,value:t}),ws("div",{className:Ji(r.alert,c===0?r.success:r.warning),children:[he("div",{className:r.alertText,children:n("placeholders",{placeholderSize:c})}),c===0?he($i,{}):he(Qi,{})]})]})},Id=({inputElement:t,value:e})=>{let o=y("EditSuggestionTextInput",vs),n=Ts(null),s=on(t);return Vt(()=>{nn(t,s)},[s,t]),he(Rd,{inputElement:t,children:ws("div",{ref:n,className:Ji(o.root,o.agentText),children:[he(kd,{tagName:"span",disableLineBreaks:!0,content:e,matchers:[new lt("placeholders")],inputElement:t,boundaryRef:n}),he("br",{})]})})},Rd=({inputElement:t,children:e})=>{let o=Ts(null);return Vt(()=>{if(!o.current)return()=>{};let[n,s]=jt(t,{overlayContainer:o.current,mirrorOverflow:!0});return()=>{s()}},[o.current]),he("div",{ref:o,children:e})},Yi=Pd;import{useEffect as sg,useState as rg,useRef as ig}from"react";import{useState as Md}from"react";import Es from"classnames";var G={root:"_root_185k9_1",list:"_list_185k9_2",listWrapper:"_listWrapper_185k9_6",listHorizontal:"_listHorizontal_185k9_10",page:"_page_185k9_19",search:"_search_185k9_25",pageNav:"_pageNav_185k9_33",pageTitle:"_pageTitle_185k9_41",pageBackButton:"_pageBackButton_185k9_48",listHeading:"_listHeading_185k9_62",listItem:"_listItem_185k9_70",listItemContent:"_listItemContent_185k9_79",listItemText:"_listItemText_185k9_97",listItemDescription:"_listItemDescription_185k9_105",truncate:"_truncate_185k9_112",lineClamp:"_lineClamp_185k9_118",listItemTitle:"_listItemTitle_185k9_125",listItemAction:"_listItemAction_185k9_132",listItemPrimaryAction:"_listItemPrimaryAction_185k9_146",listItemSelected:"_listItemSelected_185k9_151",sources:"_sources_185k9_155",sourcesTitle:"_sourcesTitle_185k9_162",source:"_source_185k9_155",icon:"_icon_185k9_177",searchIcon:"_searchIcon_185k9_194",searchInputWrapper:"_searchInputWrapper_185k9_199",searchInput:"_searchInput_185k9_199",select:"_select_185k9_220",selectType:"_selectType_185k9_237",selectWrapper:"_selectWrapper_185k9_241",image:"_image_185k9_271",imageSrc:"_imageSrc_185k9_278",imageSrcHidden:"_imageSrcHidden_185k9_289",imageSrcStatus:"_imageSrcStatus_185k9_293",imageTitle:"_imageTitle_185k9_303",actions:"_actions_185k9_308",actionsWrapper:"_actionsWrapper_185k9_312",actionsBar:"_actionsBar_185k9_318",actionButton:"_actionButton_185k9_327",actionShortcut:"_actionShortcut_185k9_345",actionShortcutFixKerning:"_actionShortcutFixKerning_185k9_352"};var qe={};z(qe,{enUS:()=>Ld,nlNL:()=>Ad});var Ld={visitUrl:[{type:0,value:"Visit"}],back:[{type:0,value:"Back"}],loading:[{type:0,value:"Loading..."}],imageError:[{type:0,value:"Could not load image"}]},Ad={visitUrl:[{type:0,value:"Bekijk"}],back:[{type:0,value:"Terug"}],loading:[{type:0,value:"Laden..."}],imageError:[{type:0,value:"Kan afbeelding niet laden"}]};import{jsx as qt,jsxs as Nd}from"react/jsx-runtime";var Od=({src:t,title:e})=>{let o=y("CommandPalette",G),[n,s]=Md("loading"),r=T(qe);return Nd("div",{className:o.image,children:[qt("img",{src:t,alt:e,onLoad:()=>s("done"),onError:()=>s("error"),className:Es(o.imageSrc,{[o.imageSrcHidden]:["loading","error"].includes(n)})}),n==="loading"&&qt("span",{className:Es(o.imageSrc,o.imageSrcStatus),children:r("loading")}),n==="error"&&qt("span",{className:Es(o.imageSrc,o.imageSrcStatus),children:qt(vo,{})}),e&&qt("span",{className:o.imageTitle,children:e})]})},ea=Od;import Dd from"react";import Hd from"classnames";import{jsx as ta,jsxs as Bd}from"react/jsx-runtime";function ks({children:t,heading:e,orientation:o}){let n=y("CommandPalette",G);return Dd.Children.count(t)===0?null:Bd("div",{"data-testid":"commandpalette-list",className:n.list,children:[e&&ta("h4",{className:n.listHeading,children:e}),ta("div",{className:Hd(n.listWrapper,o==="horizontal"&&n.listHorizontal),children:t})]})}import rn from"classnames";import Ps from"react";import{jsx as Fd}from"react/jsx-runtime";var oa=Ps.createContext(void 0);function Ne(){let t=Ps.useContext(oa);if(t===void 0)throw new Error("useCommandPalette must be used within the CommandPalette component");return t}var na=({children:t,page:e,isOpen:o,onChangeOpen:n,selected:s,setSelected:r})=>{let i=Ps.useMemo(()=>({page:e,isOpen:o,onChangeOpen:n,selected:s,setSelected:r}),[o,e,s]);return Fd(oa.Provider,{value:i,children:t})};import{jsx as ut,jsxs as an}from"react/jsx-runtime";function Is({closeOnSelect:t=!0,lineClamp:e,children:o,onClick:n,onSourceClick:s,index:r,isExperimental:i,description:a,sources:l,styles:c,...p}){let{selected:u,onChangeOpen:d}=Ne(),m=y("CommandPalette",G);function h(g){n(g),t&&d(!1)}return an("div",{className:rn(m.listItem,u===r&&m.listItemSelected),children:[an("button",{type:"button",className:rn("command-palette-list-item",m.listItemAction,m.listItemPrimaryAction),"aria-disabled":p.disabled??!1,onClick:h,...p,children:[an("div",{className:m.listItemContent,children:[typeof o=="string"?ut("p",{className:rn(m.listItemText,m.truncate,c==null?void 0:c.title),children:o}):o,a&&ut("p",{className:rn(m.listItemDescription,c==null?void 0:c.description,e?m.lineClamp:m.truncate),children:a})]}),i&&ut(No,{})]}),l&&an("div",{className:m.sources,children:[ut("span",{className:m.sourcesTitle,children:"Sources"}),l.map(g=>g.url?ut("a",{className:m.source,href:g.url,target:"_blank",title:g.url,rel:"noopener noreferrer",onClick:()=>s&&s(g),children:g.name},g.url):ut("span",{className:m.source,children:g.name},g.name))]})]})}import{jsx as Rs,jsxs as Ls}from"react/jsx-runtime";function As({children:t,title:e,id:o,onDismiss:n,isExperimental:s}){let r=T(qe),i=y("CommandPalette",G),{page:a}=Ne();return a!==o?null:Ls("div",{className:i.page,id:`page_${o}`,tabIndex:-1,children:[n&&Ls("div",{className:i.pageNav,children:[Ls("button",{className:i.pageBackButton,type:"button",onClick:n,children:[Rs(Yo,{}),r("back")]}),e&&Rs("h3",{className:i.pageTitle,children:e}),s&&Rs(No,{})]}),t]})}import{Fragment as Qd,useCallback as Zd,useEffect as Jd,useRef as Yd}from"react";var ln=()=>/Mac/i.test(navigator.platform);import{createAsyncThunk as Vd,createSlice as qd}from"@reduxjs/toolkit";var Kd={info(...t){console.info("[Deepdesk]",...t)},warn(...t){console.warn("[Deepdesk]",...t)},error(...t){console.error("[Deepdesk]",...t)}},k=Kd;import{createAsyncThunk as Os,createSlice as zd}from"@reduxjs/toolkit";function Ud(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,[Ud(o)]:A(t[o])}),{}):t}function Ms(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,o)=>({...e,[Ms(o)]:F(t[o])}),{}):t}var jd={agentInfo:void 0,agentSettings:{},visitorInfo:void 0,fetchState:"idle"},Gt=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)||""}},Wt=Os("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))}),Ns=Os("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}),Ds=Os("info/getAgentSettings",async(t,e)=>{let{deepdeskAPI:o}=e.extra;return(await o.client.get("/apis/admin/session/me/",{version:null})).ui_config}),sa=t=>t.info.agentInfo,ra=zd({name:"info",initialState:jd,reducers:{setVisitorInfo(t,e){t.visitorInfo={...t.visitorInfo,...e.payload}}},extraReducers:t=>{t.addCase(Wt.pending,(e,o)=>{e.fetchState="loading",e.agentInfo={...e.agentInfo,...o.meta.arg}}).addCase(Wt.rejected,e=>{e.fetchState="error"}).addCase(Wt.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(Ns.fulfilled,(e,o)=>{e.agentSettings=o.payload}).addCase(Ds.fulfilled,(e,o)=>{e.agentSettings=o.payload}).addCase(I,e=>{e.visitorInfo=void 0})}}),{setVisitorInfo:ia}=ra.actions,aa=ra.reducer;var cn={list:[],fetchState:"idle",isOpen:!1,page:"search"},la=t=>t.search.isOpen,ca=t=>t.search.page,pa=t=>t.search.list;function ua(t,e=o=>o){return o=>o.search.list.filter(n=>n.type===t).map(e)}var We=Vd("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:Gt(n),tags:t.tags});return r.map(a=>({...a,source:a.type==="URL"?"search-url":"search-overlay",searchTerm:t.query}))}),da=qd({name:"search",initialState:cn,reducers:{setIsOpen(t,e){t.isOpen=e.payload},setPage(t,e){t.page=e.payload},resetSearch(t){t.fetchState=cn.fetchState,t.list=cn.list}},extraReducers:t=>{t.addCase(We.pending,e=>{e.fetchState="loading"}).addCase(We.rejected,(e,o)=>{e.fetchState="error",k.error(o.error)}).addCase(We.fulfilled,(e,o)=>{e.fetchState="done",e.list=o.payload}).addCase(I,()=>cn)}}),{resetSearch:pn,setIsOpen:Y,setPage:V}=da.actions,ga=da.reducer;var Wd=/(https?:\/\/[^\s]+)/,un=t=>t.split(" ").find(e=>Wd.test(e));import ma from"classnames";import{jsx as $d,jsxs as Xd}from"react/jsx-runtime";var Gd=({onClick:t,shortKeys:e,children:o,...n})=>{let s=y("CommandPalette",G);return Xd("button",{type:"button",...n,onClick:t,className:ma(s.actionButton,n.className),children:[o,e&&e.map(r=>$d("span",{className:ma(s.actionShortcut,r===8629&&s.actionShortcutFixKerning),children:typeof r=="number"?String.fromCharCode(r):r},r))]})},dt=Gd;import{jsx as dn,jsxs as Hs}from"react/jsx-runtime";var eg=({children:t,primaryLabel:e,secondaryLabel:o,onPrimary:n,onSecondary:s,list:r})=>{let i=y("CommandPalette",G),a=T(qe),{selected:l,setSelected:c}=Ne(),p=r[l],u=p&&typeof p.text=="string"&&un(p.text),d=Yd(null);function m(_){if(!d.current)return;let x=d.current.querySelectorAll(".command-palette-list-item"),w=0,C=0;_==="down"?(x.forEach((ee,D)=>{D===l&&(w=D)}),C=w===x.length-1?0:w+1):_==="up"?(x.forEach((ee,D)=>{D===l&&(w=D)}),C=w?w-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(!d.current)return;let _=d.current.querySelectorAll(".command-palette-list-item"),x=0;_.forEach((C,O)=>{O===l&&(x=O)});let w=_[x];w&&w.click()}let g=()=>{u&&window.open(u,"_blank")},v=()=>{p&&n(p,l)},E=()=>{!p.type||["IMAGE","command"].includes(p.type)||s&&s(p,l)},f=Zd(_=>{if(_.key==="Enter"&&_.altKey&&u){g();return}if(_.key==="Enter"&&_.shiftKey){E();return}if(_.key==="ArrowDown"){_.preventDefault(),_.stopPropagation(),m("down");return}if(_.key==="ArrowUp"){_.preventDefault(),_.stopPropagation(),m("up");return}_.key==="Enter"&&l!==-1&&(_.preventDefault(),_.stopPropagation(),h())},[l]);return Jd(()=>(window.addEventListener("keyup",f),()=>{window.removeEventListener("keyup",f)}),[f]),Hs("div",{className:i.actions,children:[dn("div",{className:i.actionsWrapper,ref:d,children:t}),Hs("div",{className:i.actionsBar,children:[u&&dn(dt,{onClick:g,shortKeys:[ln()?8997:"ALT",8629],children:a("visitUrl")}),p&&Hs(Qd,{children:[s&&p.type&&!["command","image"].includes(p.type.toLowerCase())&&dn(dt,{onClick:E,shortKeys:[8679,8629],children:o}),dn(dt,{onClick:v,shortKeys:[8629],children:e})]})]})]})},ha=eg;import{forwardRef as og}from"react";import{jsx as ya,jsxs as tg}from"react/jsx-runtime";var gt=()=>tg("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 0 24 24",width:"1em",fill:"currentColor",children:[ya("path",{d:"M0 0h24v24H0z",fill:"none"}),ya("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 Bs}from"react/jsx-runtime";function ng({onChange:t,onChangeType:e,placeholder:o,typePlaceholder:n,types:s,value:r,selectedType:i},a){let l=y("CommandPalette",G);return Bs("div",{className:l.search,children:[mt("div",{className:l.searchIcon,children:mt(gt,{})}),Bs("div",{className:l.searchInputWrapper,children:[mt("input",{ref:a,spellCheck:!1,autoComplete:"off",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:Bs("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 Sa=og(ng);import{jsx as va,jsxs as ag}from"react/jsx-runtime";function Ge({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:u,search:d}){let[m,h]=rg(0),g=ig(null),v=()=>{s&&s(o),i(void 0),r(""),a(!1)},E=()=>{var f;if(n!==o&&s){s(o);return}if(l&&i){i(void 0),(f=g.current)==null||f.focus();return}if(d.length>0){r("");return}a(!1)};return sg(()=>{h(0)},[d,n]),va(at,{autoFocus:!0,contentAriaLabel:"Search Results",overlayAriaLabel:"Command Palette",isOpen:u,onBack:E,onClose:v,children:ag(na,{selected:m,setSelected:h,isOpen:u,onChangeOpen:a,page:n,children:[n===o&&va(Sa,{ref:g,onChange:r,onChangeType:i,placeholder:t,value:d,selectedType:l,types:c,typePlaceholder:e}),p]})})}Ge.Page=As;Ge.List=ks;Ge.Image=ea;Ge.ListItem=Is;Ge.ActionsBar=ha;Ge.Button=dt;var R=Ge;import{jsx as ye,jsxs as $t}from"react/jsx-runtime";var pg=({suggestion:t,onUse:e,onDismiss:o,onTouched:n,onNext:s,onPrevious:r})=>{let i=t.text||t.url||t.message,a=y("EditSuggestionForm",Mi),l=lg(),c=T(Ss),p=cg(h=>h.overlayInput.text);_a(()=>{t&&(l(W.actions.reset()),l(W.actions.stageSuggestion({text:i,suggestion:{...t,source:"search-preview"},eventMetrics:{inputType:"mouse"},replace:"until-selection-end"})),l(W.actions.commitSuggestion()))},[t]);let u=h=>{h.preventDefault(),d(p)},d=h=>{l(Xo(h)),e(h)},m=h=>g=>{p!==i?window.confirm(c("warning"))&&h(g):h(g)};return _a(()=>{n&&n(p!==i)},[n,t,p]),$t("div",{className:a.root,children:[$t("div",{className:a.content,children:[t.title&&ye("h3",{className:a.title,children:t.title}),t.searchKeywords&&t.searchKeywords.length>0&&ye(ps,{labels:t.searchKeywords}),ye(Yi,{onUse:d,value:p})]}),$t("form",{className:a.actions,onSubmit:u,children:[$t("div",{children:[ye("button",{disabled:!r,className:a.pagination,type:"button",onClick:r&&m(r),children:ye(Yo,{})}),ye("button",{disabled:!s,className:a.pagination,type:"button",onClick:s&&m(s),children:ye(Di,{})})]}),$t("div",{className:a.primaryButtons,children:[ye(R.Button,{onClick:m(o),shortKeys:["esc"],children:c("dismiss")}),ye(R.Button,{shortKeys:[8679,8629],type:"submit",children:c("add")})]})]})]})},gn=pg;import{createAction as gg,createAsyncThunk as wa,createSlice as mg}from"@reduxjs/toolkit";var ug=["{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}"],dg=new RegExp(ug.map(t=>`(?:${t.replace("{","\\{").replace("}","\\}")})`).join("|"));function xa(t,e){let o=t.split(dg),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 u=a.charAt(0),d=0;do c=u?e.indexOf(u,c+1):-1,d+=1;while(c!==-1&&a.indexOf(e.slice(c))!==0);if(c===-1&&d>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 ba(t,e){return typeof e=="boolean"?t:t.slice(0,e)}var Ta={suggestions:[],fetchState:"idle",isInitialRequest:null},Ca={default:Ta},Ea=t=>e=>{var o;return((o=e.textSuggestions[t])==null?void 0:o.suggestions)||[]},ka=t=>e=>{var o;return((o=e.textSuggestions[t])==null?void 0:o.suggestions)??[]},Pa=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")},ft=t=>t.textSuggestions,Ia=t=>e=>e.text.startsWith(t),mn=gg("textSuggestions/refresh"),Se=wa("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=it(n);if(!s)throw new Error("No current conversation to fetch text suggestions");let l=await o.getTextSuggestions(s,Gt(n),t);if(t==="default"){let p=i?l.filter(Ia(a)):l;e.dispatch(Le(p.slice(0,r)))}return l}),Xt=wa("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,{...Gt(n),input:t});if(!e.getState().input.text)throw new Error("Abort");return a&&(l=l.filter(Ia(t))),i&&(l=l.map(p=>({...p,text:p.source!=="trie-with-typos"?xa(p.text,t):p.text}))),l=ba(l,r),e.dispatch(Le(l)),l}),Ra=mg({name:"textSuggestions",initialState:Ca,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(Se.pending,(e,o)=>{let n=o.meta.arg,s=e[n]||Ta;return{...e,[n]:{...s,fetchState:"loading",isInitialRequest:s.isInitialRequest===null}}}).addCase(Se.rejected,(e,o)=>{let n=o.meta.arg;e[n].fetchState="error"}).addCase(Se.fulfilled,(e,o)=>{let n=o.meta.arg;e[n].fetchState="done",e[n].suggestions=o.payload}).addCase(Xt.pending,e=>{e.default.fetchState="loading"}).addCase(Xt.rejected,e=>{e.default.fetchState="error"}).addCase(Xt.fulfilled,(e,o)=>{e.default.fetchState="done",e.default.suggestions=o.payload}).addCase(I,()=>Ca)}}),{setTextSuggestions:La,setSuggestionState:Aa}=Ra.actions,Ma=Ra.reducer;import{createSlice as fg}from"@reduxjs/toolkit";var Oa={contentType:null,suggestion:null},Na=t=>t.activeSuggestion.suggestion,Da=t=>t.activeSuggestion.contentType,Ha=fg({name:"activeSuggestion",initialState:Oa,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,()=>Oa)}}),{setActiveSuggestion:ve,resetActiveSuggestion:Fs}=Ha.actions,Ba=Ha.reducer;var Ks={};z(Ks,{enUS:()=>hg,nlNL:()=>yg});var hg={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"}]},yg={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 Sg}from"@reduxjs/toolkit";var vg={showTabHint:!1,inputHasFocus:!1,overlayCollapsed:!1,openOverlayWhenTyping:!1,overlayCollapsedUserOverwrite:!1};var Fa=({ui:t})=>t.overlayCollapsed;var Ka=Sg({name:"ui",initialState:vg,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:Qt,setInputHasFocus:ht,setOverlayCollapsed:yt,setOpenOverlayWhenTyping:Ua,setOverlayCollapsedUserOverwrite:za}=Ka.actions,ja=Ka.reducer;import Va,{useContext as _g}from"react";import{jsx as xg}from"react/jsx-runtime";var qa=Va.createContext(null),Zt=({broadcastEvents:t,children:e})=>{let o=Va.useMemo(()=>t,[]);return xg(qa.Provider,{value:o,children:e})},oe=()=>{let t=_g(qa);if(!t)throw new Error("You should use the useBroadcastEvents within a BroadcastEventsProvider");return t};import{createAsyncThunk as Us,createSlice as bg}from"@reduxjs/toolkit";var Cg={isLoggedIn:!0,loginFetchState:"idle",verifyFetchState:"idle",showLoginOverlay:!1},_e=t=>t.auth.isLoggedIn,Wa=t=>t.auth.loginFetchState,Ga=t=>t.auth.verifyFetchState,$a=t=>t.auth.showLoginOverlay,De=Us("auth/validate",async(t,e)=>e.extra.deepdeskAPI.isLoggedIn()),Xa=Us("auth/requestLogin",async({email:t},e)=>{let{deepdeskAPI:o}=e.extra;return o.requestLoginByEmail(t)}),Jt=Us("auth/verifyLoginToken",async({token:t},e)=>{let{deepdeskAPI:o}=e.extra;return o.verifyLoginToken(t)}),Qa=bg({name:"auth",initialState:Cg,reducers:{setIsLoggedIn(t,e){t.isLoggedIn=e.payload},setShowLoginOverlay(t,e){t.showLoginOverlay=e.payload}},extraReducers:t=>{t.addCase(De.pending,e=>{e.loginFetchState="loading"}),t.addCase(De.fulfilled,(e,{payload:o})=>{e.isLoggedIn=o,e.loginFetchState="done"}),t.addCase(De.rejected,e=>{e.loginFetchState="error",e.isLoggedIn=!1}),t.addCase(Jt.pending,e=>{e.verifyFetchState="loading"}),t.addCase(Jt.rejected,e=>{e.verifyFetchState="error"}),t.addCase(Jt.fulfilled,(e,o)=>{o.payload.isLoggedIn?e.verifyFetchState="done":e.verifyFetchState="error"})}}),{setIsLoggedIn:St,setShowLoginOverlay:Za}=Qa.actions,Ja=Qa.reducer;var zs="SetActiveSuggestion",vt="ShowLoginOverlay",js="UserLoggedIn",wg="UserLoggedOut",xe="ApplySuggestion",Vs="ApplyImageSuggestion",Tg="ShowCommandPalette",Eg=t=>({[zs]:e=>{t.dispatch(Aa(e.state)),t.dispatch(ve({contentType:e.contentType,suggestion:e.suggestion}))},[Tg]:e=>{t.dispatch(Y(e.isOpen)),e.page&&t.dispatch(V(e.page))},[vt]:e=>{t.dispatch(Za(e))},[js]:()=>{t.dispatch(De())},[wg]:()=>{t.dispatch(De())},[Vs]:e=>{t.dispatch(Zo({suggestion:e.suggestion}))},[xe]:e=>{t.dispatch(ie({...e,eventMetrics:{inputType:"mouse"},replace:"selection"})),t.dispatch(Ae())}}),Ya=Eg;import{jsx as el}from"react/jsx-runtime";var Ig=()=>{var h;let[t,e]=kg(!1),o=qs(Na),n=qs(Da),s=qs(ft),r=Pg(),i=oe(),a=T(Ks),l=()=>{o!==null&&t?window.confirm(a("warning"))&&c():c()},c=()=>{r(Fs()),r(ht(!0)),r(W.actions.reset())},p=(g,v)=>{r(Fs()),r(ht(!0)),i.send(xe,{text:g,suggestion:v})};if(o===null||n===null)return null;let u=(h=s[n])==null?void 0:h.suggestions.indexOf(o),d=u===0||u===null?void 0:()=>r(ve({contentType:n,suggestion:s[n].suggestions[u-1]})),m=u===s[n].suggestions.length-1||u===null?void 0:()=>r(ve({contentType:n,suggestion:s[n].suggestions[u+1]}));return el(at,{autoFocus:!0,isOpen:u!==null,onClose:l,onBack:l,contentAriaLabel:a("editContentLabel"),overlayAriaLabel:a("overlayLabel"),children:el(gn,{onTouched:e,onDismiss:c,onUse:g=>p(g,o),suggestion:o,onNext:m,onPrevious:d})})},tl=Ig;import{useSelector as il}from"react-redux";import Gs from"classnames";import{useCallback as sl,useEffect as Ng,useMemo as Dg,useState as $s}from"react";import{useDispatch as Hg,useSelector as Bg}from"react-redux";import Rg from"classnames";var ol={root:"_root_1ukx5_1"};import{jsx as Ag}from"react/jsx-runtime";var Lg=({className:t,value:e,...o})=>{let n=y("TextInput",ol);return Ag("input",{className:Rg(t,n.root),type:"text",value:e,...o})},Yt=Lg;var Ws={};z(Ws,{enUS:()=>Mg,nlNL:()=>Og});var Mg={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"}]},Og={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 nl={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 $,jsxs as fn}from"react/jsx-runtime";var Fg=t=>{try{let e=new URL(t);return new URLSearchParams(e.search).get("token")||void 0}catch{return t}},Kg=({agentEmail:t,isOpen:e,origin:o="",onSuccess:n,onDismiss:s})=>{let r=T(Ws),i=y("LoginTokenDialog",nl),a=Bg(Ga),l=Hg(),c=b("productName"),[p,u]=$s(t||""),[d,m]=$s(0),[h,g]=$s(""),v=sl(async x=>{x.preventDefault(),l(Xa({email:p})),m(1)},[o,p]),E=()=>{g(""),m(0)},f=sl(async x=>{x.preventDefault();let w=Fg(x.target.elements.token.value);if(!w){g(r("verifyCodeError",{login:_}));return}l(Jt({token:w}))},[o]),_=Dg(()=>x=>$("button",{type:"button","data-testid":"login-token-dialog-back-button",className:i.anchorButton,onClick:E,children:x},"back-button"),[]);return Ng(()=>{a==="error"&&g(r("verifyCodeError",{login:_})),a==="done"&&n()},[a]),$(at,{autoFocus:!0,isOpen:e,contentAriaLabel:r("promptTitle",{productName:c}),overlayAriaLabel:r("promptTitle",{productName:c}),onClose:s,onBack:s,children:fn("div",{className:i.root,children:[$("h1",{className:i.title,children:r("promptTitle",{productName:c})}),d===0&&fn("form",{onSubmit:v,children:[$("h2",{className:i.subtitle,children:r("requestCodeTitle")}),$("p",{className:i.text,children:r("requestCodeBody",{productName:c})}),$(Yt,{className:i.input,name:"email",placeholder:r("requestCodeInputPlaceholder"),value:p,onChange:x=>u(x.target.value)}),$("div",{className:i.actions,children:$("button",{type:"submit",className:Gs(i.button,i.primaryButton),children:r("requestCodeSubmitLabel")})})]}),d===1&&fn("form",{onSubmit:f,children:[$("h2",{className:i.subtitle,children:r("verifyCodeTitle")}),$("p",{className:i.text,children:r("verifyCodeBody")}),$(Yt,{className:i.input,name:"token",placeholder:r("verifyCodeInputPlaceholder"),disabled:["loading","done"].includes(a)}),h&&$("div",{className:i.errorMessage,children:h}),fn("div",{className:i.actions,children:[$("button",{type:"button",className:Gs(i.button),onClick:E,children:r("back")}),$("button",{type:"submit",className:Gs(i.button,i.primaryButton),disabled:["loading","done"].includes(a),children:r("verifyCodeSubmitLabel")})]})]})]})})},rl=Kg;import{jsx as zg}from"react/jsx-runtime";var Ug=()=>{let t=il($a),e=il(sa),o=b("adminUrl"),n=oe(),s=()=>n.send(vt,!1),r=()=>{n.send(vt,!1),n.send(js)};return zg(rl,{isOpen:t,agentEmail:e==null?void 0:e.agentEmail,origin:o,onDismiss:s,onSuccess:r})},al=Ug;import Mm from"lodash.debounce";import{useCallback as or,useEffect as nr,useState as no}from"react";import{useDispatch as Om,useSelector as wt}from"react-redux";import{createAsyncThunk as jg,createSlice as Vg}from"@reduxjs/toolkit";var qg={data:null,fetchState:"idle"},ll=t=>t.contentTypes.data,eo=jg("contentTypes/getContentTypes",async(t,e)=>e.extra.deepdeskAPI.getContentTypes()),Wg=Vg({name:"contentTypes",initialState:qg,reducers:{},extraReducers:t=>{t.addCase(eo.pending,e=>{e.fetchState="loading"}).addCase(eo.rejected,e=>{e.fetchState="error"}).addCase(eo.fulfilled,(e,o)=>{e.fetchState="done",e.data=o.payload})}}),cl=Wg.reducer;function to(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 Gg}from"react";function pl(t,e){Gg(()=>{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 em}from"react";import{useSelector as tm,useDispatch as om}from"react-redux";import{createAsyncThunk as $g,createSlice as Xg}from"@reduxjs/toolkit";var ul={data:null,fetchState:"idle"},hn=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=$g("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)}),Qg=t=>t.filter((e,o)=>o===t.findIndex(n=>n.text===e.text)),Zg=Xg({name:"entities",initialState:ul,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=Qg(e.data?[...e.data,...o.payload]:o.payload)}).addCase(I,()=>ul)}}),dl=Zg.reducer;var Xs={};z(Xs,{enUS:()=>Jg,nlNL:()=>Yg});var Jg={noResults:[{type:0,value:"No entities have been found"}],copy:[{type:0,value:"Copy"}],use:[{type:0,value:"Use"}]},Yg={noResults:[{type:0,value:"Er zijn geen entiteiten gevonden"}],copy:[{type:0,value:"Kopieer"}],use:[{type:0,value:"Gebruik"}]};var gl={root:"_root_17kae_1",empty:"_empty_17kae_5"};import{jsx as yn,jsxs as sm}from"react/jsx-runtime";var nm=({onCopy:t,onUse:e})=>{let o=em(null),n=y("EntitiesList",gl),s=T(Xs),r=tm(hn),i=om();return ml(()=>{i(ae())},[]),ml(()=>{o.current&&o.current.focus()},[o]),sm("div",{className:n.root,ref:o,tabIndex:-1,children:[r&&r.length>0&&yn(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:yn(R.List,{children:r.map((a,l)=>yn(R.ListItem,{index:l,closeOnSelect:!0,onClick:()=>t(a),children:a.text},a.text))},"entities")}),r&&r.length===0&&yn("p",{className:n.empty,children:s("noResults")})]})},fl=nm;import{Fragment as pm,useEffect as Sn,useRef as um,useState as dm}from"react";import{useSelector as xl,useDispatch as gm}from"react-redux";import{createAsyncThunk as rm,createSlice as im}from"@reduxjs/toolkit";var hl={data:null,fetchState:"idle"},yl=t=>t.summary.data,Sl=t=>t.summary.fetchState==="error",be=rm("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}}),am=im({name:"summary",initialState:hl,reducers:{},extraReducers:t=>{t.addCase(be.pending,e=>{e.data=null,e.fetchState="loading"}).addCase(be.rejected,e=>{e.data=null,e.fetchState="error"}).addCase(be.fulfilled,(e,o)=>{e.fetchState="done",o.payload&&(e.data=o.payload.summary)}).addCase(I,()=>hl)}}),vl=am.reducer;var Qs={};z(Qs,{enUS:()=>lm,nlNL:()=>cm});var lm={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."}]},cm={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 _l={root:"_root_6ahh3_1",actions:"_actions_6ahh3_5",main:"_main_6ahh3_11",textInput:"_textInput_6ahh3_15",loading:"_loading_6ahh3_34",error:"_error_6ahh3_38"};import{jsx as _t,jsxs as fm}from"react/jsx-runtime";var mm=({onCopy:t})=>{let e=um(null),o=y("SummaryForm",_l),[n,s]=dm(""),r=T(Qs),i=xl(yl),a=xl(Sl),l=gm(),c=()=>{l(J({name:"summary copied to clipboard",data:{originalText:i,finalText:n},options:{includeConversationData:!0}})),t(n)},p=()=>{let u=document.getSelection();u&&l(J({name:"summary copied to clipboard",data:{originalText:i,finalText:u==null?void 0:u.toString()},options:{includeConversationData:!0}}))};return Sn(()=>{l(be())},[]),Sn(()=>{s(i||"")},[i]),Sn(()=>{e.current&&i&&e.current.focus()},[e,i]),Sn(()=>{let u=d=>{d.key==="Enter"&&d.shiftKey&&c()};return document.addEventListener("keydown",u),()=>{document.removeEventListener("keydown",u)}},[n]),_t("div",{className:o.root,tabIndex:-1,children:a?_t("p",{className:o.error,children:r("error")}):fm(pm,{children:[_t("div",{className:o.main,children:_t("textarea",{placeholder:i?void 0:r("loading"),disabled:!i,className:o.textInput,ref:e,value:n,onCopy:p,onChange:u=>s(u.target.value)})}),_t("div",{className:o.actions,children:_t(R.Button,{shortKeys:[8679,8629],onClick:c,children:r("copy")})})]})})},bl=mm;var Zs={};z(Zs,{enUS:()=>hm,nlNL:()=>ym});var hm={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?"}]},ym={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 Tm,{useEffect as er,useRef as Em}from"react";import{useDispatch as km,useSelector as Il}from"react-redux";var Js={};z(Js,{enUS:()=>Sm,nlNL:()=>vm});var Sm={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"}]},vm={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 _m,createAsyncThunk as xm,createSlice as bm}from"@reduxjs/toolkit";var Ys={data:[],fetchState:"idle"},wl=t=>{var e;return(e=t.answer)==null?void 0:e.data},Tl=t=>t.answer.fetchState,bt=_m("answer/resetKnowledgeSearch"),xt=xm("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}}),Cm=bm({name:"answer",initialState:Ys,reducers:{},extraReducers:t=>{t.addCase(xt.pending,e=>{e.fetchState="loading"}).addCase(xt.rejected,e=>{e.fetchState="error"}).addCase(xt.fulfilled,(e,o)=>{e.fetchState="done",e.data=[...e.data,o.payload]}).addCase(I,()=>Ys).addCase(bt,()=>Ys)}}),El=Cm.reducer;import{jsx as kl,jsxs as wm}from"react/jsx-runtime";var Pl=()=>wm("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 512 512","aria-labelledby":"paperPlaneTitle",children:[kl("title",{id:"paperPlaneTitle",children:"PaperPlane"}),kl("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 tr}from"react/jsx-runtime";var Pm=({onUse:t,onResetQuestion:e,question:o,promptInstruction:n})=>{let[s,r]=Tm.useState(""),{setSelected:i}=Ne(),a=Em(null),l=y("EntitiesList",Cl),c=T(Js),p=km(),u=Il(wl),d=Il(Tl),m=async g=>{g.preventDefault(),g.stopPropagation(),s!==""&&p(xt({question:s,promptInstruction:n}))},h=(g,v)=>{p(J({name:"knowledge assist source viewed",data:{question:v,sourceViewed:g.url||g.name},options:{includeConversationData:!0}}))};return er(()=>{var g;o&&d==="idle"?p(xt({question:o,promptInstruction:n})):(g=a.current)==null||g.focus()},[a,d]),er(()=>{d==="done"&&(p(J({name:"knowledge assist question answered",data:{question:s||o,sources:u[u.length-1].answer.sources,isFollowUpQuestion:u.length>1},options:{includeConversationData:!0}})),i(u.length-1),r(""))},[d,u]),er(()=>{a.current&&a.current.scrollIntoView({behavior:"smooth"})},[a,u]),tr("div",{className:l.root,children:[u.length>0&&Ce("div",{className:l.alignRight,children:Ce(R.Button,{onClick:e,children:c("reset")})}),tr(R.ActionsBar,{list:u.map(({answer:g})=>({text:g.answer,type:"answer"})),primaryLabel:c("use"),onPrimary:g=>t(g.text),children:[u.map(({question:g,answer:v},E)=>Ce(R.List,{children:Ce(R.ListItem,{"data-testid":"knowledge-search-answer",index:E,description:v.answer,closeOnSelect:!0,onClick:()=>t(v.answer),onSourceClick:f=>h(f,g),sources:v.sources,styles:{title:l.question,description:l.answer},children:g})},`${v.answer}_${E}`)),d==="loading"&&Ce("p",{className:l.status,children:c("loading")}),d==="error"&&Ce("p",{className:l.status,children:c("error")}),tr("form",{className:l.form,onSubmit:m,children:[Ce("input",{ref:a,placeholder:c("anotherQuestion"),className:l.input,type:"text",value:s,onFocus:()=>{i(-1)},onChange:g=>{i(-1),r(g.target.value)}}),Ce("button",{type:"submit",className:l.submit,children:Ce(Pl,{})})]})]})]})},Rl=Pm;import{createAsyncThunk as Im,createSlice as Rm}from"@reduxjs/toolkit";var Lm={data:null,fetchState:"idle"},Ct=t=>t.profile.data,vn=t=>t.profile.data?t.profile.data.uiConfig.widget.types.filter(e=>e.isActive):[],oo=Im("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)}),Am=Rm({name:"profile",initialState:Lm,reducers:{},extraReducers:t=>{t.addCase(oo.pending,e=>{e.fetchState="loading"}).addCase(oo.rejected,e=>{e.fetchState="error"}).addCase(oo.fulfilled,(e,o)=>{e.fetchState="done",e.data=o.payload})}}),Ll=Am.reducer;import{jsx as X,jsxs as Ml}from"react/jsx-runtime";var Nm=200,Dm=5,Hm=4,Bm=t=>t.reduce((e,o)=>[...e,...o.list.map(n=>({...n,type:o.value}))],[]),Al=(t,e)=>!e||t.toLowerCase().includes(e.toLowerCase()),Fm=()=>{let t=Om(),e=oe(),o=T(Zs),[n,s]=no(!1),[r,i]=no(""),a=wt(ca),l=wt(Ct),[c,p]=no(null),[u,d]=no([]),[m,h]=no(),g=wt(_e),v=b("showSearch"),E=b("showEntitiesCommand"),f=b("showSummaryCommand"),_=b("showKnowledgeSearch"),x=b("showImageSearch"),w=b("searchTriggerKey"),C=wt(ll),O=wt(pa),ee=wt(la),D=S=>Wn(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),B=[{label:o("entitiesClipboard"),onClick:()=>t(V("entities")),shouldShow:E&&Al(o("entitiesClipboard"),r),experimental:!0},{label:o("summaryClipboard"),onClick:()=>t(V("summary")),shouldShow:f&&Al(o("summaryClipboard"),r),experimental:!0},{label:r?`${o("knowledgeSearch")}: ${r}`:o("knowledgeSearch"),onClick:()=>t(V("knowledgeSearch")),shouldShow:_,experimental:!0}].filter(S=>S.shouldShow),q=(C==null?void 0:C.map(S=>({value:S.code.toUpperCase(),label:`${S.name}s`,list:D(S.code.toUpperCase()),listOrientation:"vertical",lineClamp:!0})))||[],Vn=or(Mm((S,L)=>{t(We({query:S,type:L,tags:["search-overlay"]}))},Nm),[]),Fe=Bm([...q,...P]),Ap=or((S,L)=>{if(!L)return;let Pe=[...P,...q].find(({value:Ye})=>Ye===L);Pe&&(t(V("edit")),p({...S,searchTerm:void 0}),d(Pe.list))},[t,c,q]),qn=or((S,L)=>{switch(L.type){case"IMAGE":e.send(Vs,{suggestion:L});break;default:e.send(xe,{text:S,suggestion:L})}t(Y(!1))},[t]),Mp=S=>{to(S.text),t(J({name:"entity copied",data:{entity:S,type:"copy"}})),t(Y(!1))},Op=S=>{e.send(xe,{text:S,suggestion:{source:"knowledge-assist",text:S}}),t(J({name:"answer used",data:{originalText:S},options:{includeConversationData:!0}})),i(""),t(V("search")),t(bt()),t(Y(!1))},Np=S=>{to(S),t(Y(!1))},Dp=S=>{e.send(xe,{text:S.text,suggestion:{source:"entity",text:S.text}}),t(Y(!1))},Hp=c===null||u.indexOf(c)-1<0?void 0:()=>p(u[u.indexOf(c)-1]),Bp=c===null||u.indexOf(c)===u.length-1?void 0:()=>p(u[u.indexOf(c)+1]);function Wn(S,L){return S.slice(0,m?10:L.toLowerCase()==="image"?Hm:Dm)}function zr(S,L,Pe){return L.reduce((Ye,yo)=>Pe&&m===Pe?yo.length+Ye:Wn(yo,Pe).length+Ye,S)}function Je(S){return L=>{n?window.confirm(o("warning"))&&(S(L),s(!1)):S(L)}}return nr(()=>{r?Vn(r,m):t(pn())},[r,m]),nr(()=>{a==="search"&&t(bt())},[a]),nr(()=>{g&&t(eo())},[g]),pl(w,()=>t(Y(!0))),!v||!l?null:Ml(R,{placeholder:o("searchPlaceholder"),typePlaceholder:o("typePlaceholder"),onChangeSearch:i,onChangeOpen:Je(S=>t(Y(S))),onChangeType:S=>h(S),onChangePage:Je(S=>t(V(S))),selectedType:m,search:r,page:a,isOpen:ee,types:[...q,...P],children:[X(R.Page,{id:"search",children:Ml(R.ActionsBar,{list:[...B.map(S=>({text:S.label,type:"command"})),...Fe.map(S=>({text:S.text||S.url||S.message,type:S.type}))],primaryLabel:o("use"),secondaryLabel:o("preview"),onPrimary:({text:S},L)=>qn(S,Fe[L]),onSecondary:(S,L)=>{Ap(Fe[L-B.length],Fe[L-B.length].type)},children:[B.length>0&&X(R.List,{heading:o("commands"),children:B.map((S,L)=>X(R.ListItem,{index:zr(L,[],"commands"),closeOnSelect:!1,onClick:S.onClick,isExperimental:S.experimental,children:S.label},S.label))}),[...q,...P].map(({value:S,label:L,list:Pe,lineClamp:Ye,listOrientation:yo},Fp)=>X(R.List,{heading:L,orientation:yo==="horizontal"?"horizontal":"vertical",children:Wn(Pe,S).map((se,Kp)=>X(R.ListItem,{index:zr(B.length+Kp,[...q,...P].slice(0,Fp).map(({list:Up})=>Up),S),closeOnSelect:!1,lineClamp:Ye,onClick:()=>qn(se.text,se),description:S!=="IMAGE"?se.title&&se.text:void 0,children:S==="IMAGE"?X(R.Image,{title:se.title||se.text,src:se.image}):se.title||se.text},`${se.id}-${se.text}`))},S))]})}),X(R.Page,{id:"edit",onDismiss:Je(()=>{t(V("search")),p(null)}),children:c&&X(gn,{suggestion:c,onTouched:s,onDismiss:()=>{s(!1),t(V("search")),p(null),d([])},onNext:Bp,onPrevious:Hp,onUse:S=>{t(V("search")),qn(S,c),t(Y(!1)),d([]),p(null)}})}),X(R.Page,{id:"entities",title:o("entitiesTitle"),isExperimental:!0,onDismiss:Je(()=>{t(V("search"))}),children:X(fl,{onUse:Dp,onCopy:Mp})}),X(R.Page,{id:"summary",title:o("summaryTitle"),isExperimental:!0,onDismiss:Je(()=>{t(V("search"))}),children:X(bl,{onCopy:Np})}),X(R.Page,{id:"knowledgeSearch",title:o("knowledgeSearch"),isExperimental:!0,onDismiss:Je(()=>{t(bt()),t(V("search"))}),children:X(Rl,{promptInstruction:l.knowledgeSearchPromptInstruction,question:r,onUse:Op,onResetQuestion:()=>{t(bt()),i("")}})})]})},Ol=Fm;import{jsx as sr,jsxs as zm}from"react/jsx-runtime";var Um=()=>{let t=b("showSearch"),e=b("isEmbedded");return zm(Km,{children:[t&&sr(Ol,{}),sr(tl,{}),e&&sr(al,{})]})},Nl=Um;import{Provider as jm}from"react-redux";import{jsx as _n}from"react/jsx-runtime";var Vm=({children:t})=>{let o=b("locale").replace("-","");return _n(ns.Provider,{value:o,children:t})},qm=({store:t,customStyles:e={},children:o})=>_n(jm,{store:t,children:_n(Vm,{children:_n(Ot.Provider,{value:e,children:o})})}),so=qm;import ur from"classnames";import{useEffect as Cf,useRef as wf,useState as Tf}from"react";import{connect as Ef,useDispatch as kf,useSelector as wn}from"react-redux";import{useState as Wm}from"react";function Dl(t,e){let[o,n]=Wm(()=>{if(typeof window>"u")return e;try{let r=window.localStorage.getItem(t);return r?JSON.parse(r):e}catch(r){return k.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){k.error(i)}}]}function xn(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 Xm from"classnames";import{Fragment as Qm,useCallback as ir,useMemo as Bl}from"react";var rr={};z(rr,{enUS:()=>Gm,nlNL:()=>$m});var Gm={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"}]}]},$m={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 bn,jsxs as Fl}from"react/jsx-runtime";var ar=(t,e,o)=>n=>bn("button",{className:t.anchorButton,type:"button",value:e,onClick:o,children:n},e),Zm=({className:t,loginUrl:e,isEmbedded:o,onSnooze:n})=>{let s=T(rr),r=oe(),i=y("Login",Hl),a=b("productName"),l=ir(g=>{g.preventDefault(),n&&n(parseInt(g.target.value,10))},[]),c=ir(g=>{g.preventDefault(),r.send(vt,!0)},[e]),p=Bl(()=>g=>bn("a",{href:e,className:i.anchor,target:"_blank",rel:"noreferrer",children:g},"login"),[e]),u=ir(g=>bn("button",{type:"button",className:i.anchorButton,onClick:c,children:g},"prompt"),[c]),{min:d,hour:m,day:h}=Bl(()=>({min:ar(i,60*10,l),hour:ar(i,60*60,l),day:ar(i,60*60*12,l)}),[]);return Fl("div",{className:Xm(t,i.root),children:[s("loginPlease",{login:o?u:p,productName:a}),n&&Fl(Qm,{children:[bn("br",{}),s("snooze",{min:d,hour:m,day:h})]})]})},Cn=Zm;import{useDispatch as Jm}from"react-redux";var Kl={root:"_root_1g8fi_1",text:"_text_1g8fi_19"};import{jsx as Ul,jsxs as ef}from"react/jsx-runtime";var Ym=({title:t})=>{let e=y("SearchTrigger",Kl),o=Jm();return ef("button",{type:"button",className:e.root,onClick:()=>o(Y(!0)),children:[Ul(gt,{}),Ul("span",{className:e.text,children:t})]})},zl=Ym;import{Fragment as vf}from"react";import{Interweave as cf}from"interweave";import{useEffect as pf,useMemo as uf,useRef as df}from"react";import{useDispatch as gf,useSelector as mf}from"react-redux";import{useEffect as tf}from"react";function jl(t,e,o){tf(()=>{let n=t.current;return n?(n.addEventListener(e,o),()=>{n.removeEventListener(e,o)}):()=>{}},[t,e,o])}var of=/[.*+?^${}()|[\]\\]/g,nf=/[^0-9A-Za-zÀ-ÖØ-öø-ÿ](?=[0-9A-Za-zÀ-ÖØ-öø-ÿ]*$)/;function sf(t){return t.replace(of,"\\$&")}function rf(t,e){let o=t.split("").findIndex((n,s)=>n!==e[s]);return o>-1?o:Math.min(t.length,e.length)}function lr(t){return t.search(nf)}function Vl(t,e=[]){let o=t;return e.forEach(n=>{if(!n)return;let s=new RegExp(`\\b(${sf(n)})\\b`,"gi");o=o.replace(s,"<strong>$1</strong>")}),o}function ql(t){return t.replace(st,'<mark data-type="placeholder">$1</mark>')}function ro(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function af(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 cr(t,e,o={}){if(e){let n=rf(e.toLowerCase(),t.toLowerCase()),s=ro(t.substring(n,t.length));if(o.stripAgentPart){let l=t.substring(0,n),c=lr(l);return`<span style="opacity: 0.5">${l.substring(c+1)}</span>${s}`}let i=e.split(li).length>3||e.length>30?af(e.trim(),n):0;return`${`${i>0?"\u2026":""}${ro(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 ff=["search","personal-collection-search","search-autocomplete"];function hf(t,e,o,n={}){let s="";return ff.includes(e)?s=Vl(cr(t,o,{stripAgentPart:!0}),n.searchKeywords??[o]):s=cr(t,o,n),n.placeholders===!0&&(s=ql(s)),s}var yf=()=>{},Sf=({index:t,selected:e,suggestion:o})=>{let n=b("inlineSuggestions"),s=mf(it),r=gf(),i=y("TextSuggestion",Wl),a=df(null);pf(()=>{let c=setTimeout(()=>{r(bi({text:o.text,suggestion:o}))},500);return()=>{clearTimeout(c)}},[o]),jl(a,"click",()=>{r(Jo(t)),r(ie({suggestion:o,text:o.text,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"}))});let l=uf(()=>hf(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:yf,children:Gl(cf,{containerTagName:"div",noWrap:!1,tagName:"span",className:i.formattedText,content:l})})},$l=Sf;import{jsx as Xl}from"react/jsx-runtime";var _f=({suggestions:t,selectedIndex:e})=>Xl(vf,{children:t.slice().map((o,n)=>Xl($l,{index:n,selected:n===e,suggestion:o},`${o.text}-${o.source}`)).reverse()}),Ql=_f;var pr={};z(pr,{enUS:()=>xf,nlNL:()=>bf});var xf={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"}]},bf={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 U,jsxs as io}from"react/jsx-runtime";var Pf=({inline:t=!1,textSuggestions:e,selectedIndex:o})=>{let n=y("SuggestionsOverlay",Zl),s=T(pr),r=b("inlineSuggestions"),i=wn(xn),a=yi(),l=kf(),c=wf(null),p=b("searchTriggerKey"),u=b("productName"),d=wn(Fa),m=wn(_e),h=wn(Ko),[g,v]=Tf(null),E=b("showSearch"),f=b("showTextSuggestions"),_=b("adminUrl"),x=b("isEmbedded"),[w,C]=Dl("dd-snooze-until-ms",0),O=d||w>Date.now(),ee=e.filter(B=>B.source!=="gpt").length,D=()=>{O&&C(0),l(za(!O))},P=B=>{let q=Date.now()+B*1e3;C(q),k.info(`Snooze until: ${new Date(q)}`),l(yt({collapse:!0}))};return Cf(()=>{ee===0&&v(null)},[e,ee]),ct(()=>{l(yt({collapse:!0,skipWhenInputFocus:!0}))}),r!==t||m===null||h===!1?null:m===!1?io("div",{ref:c,className:ur(n.root,{[n.isCollapsed]:O,[n.isInline]:t}),"data-inline":t,children:[!O&&io("div",{className:n.triggers,children:[U("div",{style:{flex:1}}),U("div",{className:n.triggersRight,children:U(nt,{className:n.toggleButton,title:s("collapse"),onClick:D,isCollapsed:!1})})]}),U("div",{className:n.toggleButtonWrapper,children:U(nt,{className:n.toggleButton,title:s("open",{productName:u}),onClick:D,isCollapsed:!0})}),U("div",{className:n.collapsible,children:U(Cn,{loginUrl:_,isEmbedded:x,onSnooze:P})})]}):!a||!i?null:io("div",{ref:c,className:ur(n.root,{[n.isCollapsed]:O,[n.isInline]:t}),"data-inline":t,children:[!O&&io("div",{className:n.triggers,children:[U("div",{style:{flex:1},children:E&&U("div",{style:{display:"inline-block"},onFocus:()=>{},onMouseOver:()=>v(s(ln()?"searchHintMac":"searchHintWindows",{searchTriggerKey:p.toUpperCase()})),onMouseLeave:()=>v(null),children:U(zl,{title:s("search")})})}),io("div",{className:n.triggersRight,onFocus:()=>{},children:[U("div",{className:ur(!g&&n.hintsHidden,n.hints),children:g}),U(nt,{className:n.toggleButton,title:s("collapse"),onClick:D,isCollapsed:!1})]})]}),U("div",{className:n.toggleButtonWrapper,children:U(nt,{className:n.toggleButton,title:s("open",{productName:u}),onClick:D,isCollapsed:!0})}),ee>0&&f&&U("div",{className:n.collapsible,onFocus:()=>{},children:U(me,{children:U(Ql,{suggestions:e,selectedIndex:o})})})]})},If=({input:t})=>({selectedIndex:t.selectedSuggestionIndex,textSuggestions:t.textSuggestions}),Tn=Ef(If)(Pf);import br from"classnames";import{Interweave as xh}from"interweave";import{useCallback as bh,useEffect as Ch,useMemo as yc,useRef as wh}from"react";import{connect as Th}from"react-redux";import{cloneElement as Rf}from"react";var Lf=["div","span","mark","strong","b","i","u","em"];function dr(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(Lf.includes(s)){let i=Array.isArray(n.props.children)?n.props.children:[n.props.children];return[...t.slice(0,t.length-1),Rf(n,{children:dr(i,e,o+1)})]}return[...t,...e]}function we(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 qf}from"interweave";import{Fragment as Wf,useEffect as Gf}from"react";import nc from"classnames";import{createRef as Uf,useCallback as mr,useMemo as zf,useRef as jf,useState as Vf}from"react";import{useState as Af,useLayoutEffect as Mf}from"react";var Of=["bottom","height","left","right","top","width"],Nf=(t={},e={})=>Of.some(o=>t[o]!==e[o]),Te=new Map,Yl,ec=()=>{let t=[],e=[];Te.forEach((o,n)=>{if(n instanceof Element&&!n.isConnected){e.push(n);return}let s=n.getBoundingClientRect();Nf(s,o.rect)&&(o.rect=s,t.push(o))}),e.forEach(o=>{Te.delete(o)}),t.forEach(o=>{o.callbacks.forEach(n=>n(o.rect))}),Yl=window.requestAnimationFrame(ec)};function Df(t,e){return{observe(){let o=Te.size===0;if(Te.has(t)){let n=Te.get(t);n.callbacks.push(e),n.rect&&e(n.rect)}else Te.set(t,{rect:void 0,hasRectChanged:!1,callbacks:[e]});o&&ec()},unobserve(){let o=Te.get(t);if(o){let n=o.callbacks.indexOf(e);n>=0&&o.callbacks.splice(n,1),o.callbacks.length||Te.delete(t),Te.size||cancelAnimationFrame(Yl)}}}}function gr(t){let[e,o]=Af(null);return Mf(()=>{if(!t.current)return;let n=Df(t.current,s=>{o(s)});return n.observe(),()=>{n.unobserve()}},[t]),e}import{useContext as Hf,useLayoutEffect as Bf,useState as Ff}from"react";import{createPortal as Kf}from"react-dom";var tc={root:"_root_1jq08_1"};var oc=({children:t})=>{let[e,o]=Ff(null),n=Hf(Ot);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?Kf(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 fr}from"react/jsx-runtime";var Tt=(t=!1)=>{let[e,o]=Vf(t),n=mr(()=>o(!0),[]),s=mr(()=>o(!1),[]),r=mr(()=>o(a=>!a),[]),i=jf(null);return{opened:e,open:n,close:s,toggle:r,triggerRef:i}};function hr(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 Et=({className:t,triggerRef:e,boundaryRef:o=Uf(),position:n="above",align:s="center",children:r,toStyle:i=hr,...a})=>{let l=gr(e),c=gr(o),p=zf(()=>i(l,c,0),[l,c]);return fr(oc,{children:fr("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:fr("div",{className:nc(t,pe.root),children:r})})})};import{jsx as ao,jsxs as Xf}from"react/jsx-runtime";var $f=({inputStyle:t,inputElement:e})=>{let o=y("TabCompletion",te),n=Tt(document.activeElement===e);return ct(()=>n.close()),Gf(()=>{let s=()=>n.open();return e.addEventListener("focus",s),()=>{e.removeEventListener("focus",s)}},[]),Xf(Wf,{children:[ao("mark",{className:te.caret,ref:n.triggerRef}),n.opened&&ao(Et,{className:o.popoverSuggestionsRoot,triggerRef:n.triggerRef,position:"above",align:"start",children:ao("div",{style:t,className:o.suggestionsOverlayInputStyles,children:ao(Tn,{inline:!0})})})]})},En=class extends qf{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=(we(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:lr(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 ao($f,{inputStyle:o.inputStyle,inputElement:o.inputElement},"caret")}asTag(){return"mark"}};import Yf from"classnames";import{Matcher as eh}from"interweave";import{useEffect as th,useMemo as oh}from"react";function sc(t){return t.replace(/[.*+^${}()|[\]\\]/g,"\\$&")}function kn(t){return e=>{t.forEach(o=>{typeof o=="function"?o(e):o!=null&&(o.current=e)})}}function rc(t){return t!=null}import Qf from"classnames";import{forwardRef as Zf,useRef as Jf}from"react";import{jsx as ic}from"react/jsx-runtime";var Pn=Zf(({className:t,children:e,...o},n)=>{let s=Jf(null),r=y("TabCompletion",te);return ic("div",{ref:kn([s,n]),className:Qf(t,r.popoverContentContainer),...o,children:ic("div",{className:r.popoverContent,children:e})})});import{jsx as lo,jsxs as rh}from"react/jsx-runtime";var nh=t=>e=>{let o=hr(e);return"top"in o&&(o.width=t.width-(e.left-t.left)-10),o},sh=({inputElement:t,boundaryRef:e,inputStyle:o,children:n,suggestion:s})=>{let r=y("TabCompletion",te),i=Tt(),a=oh(()=>nh(t.getBoundingClientRect()),[t]),[l,c]=en(t);return th(()=>{c?i.open():i.close()},[c]),rh("span",{children:[lo("mark",{ref:kn([l,i.triggerRef]),className:Yf(r.matchKeyword,{[r.hover]:c}),"aria-haspopup":"dialog","aria-expanded":i.opened?"true":"false",children:n}),i.opened&&lo(Et,{className:r.popover,triggerRef:i.triggerRef,boundaryRef:e,position:"below",align:"start",toStyle:a,children:lo(Pn,{style:o,children:lo("div",{className:r.hintText,children:s})})})]})},In=class extends eh{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 lo(sh,{inputElement:o.inputElement,suggestion:o.suggestion,inputStyle:o.inputStyle,boundaryRef:o.boundaryRef,children:e},`keyword_${o.matchString}_${o.key}`)}asTag(){return"mark"}};import xr from"classnames";import{Matcher as mh}from"interweave";import{createRef as fh,forwardRef as hh,useCallback as yh,useEffect as mc,useRef as fc,useState as hc}from"react";import{useDispatch as Sh}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 ih,useEffect as pc,useState as uc}from"react";import{useDispatch as ah,useSelector as dc}from"react-redux";import lh from"lodash.debounce";var cc={root:"_root_1muu8_1",content:"_content_1muu8_7"};function Rn(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 yr(t){return t.replace("https://www.","").replace("https://","")}import{jsx as $e,jsxs as Sr}from"react/jsx-runtime";var ch=3,ph=t=>({image:t.image||"",text:t.text,id:t.id,title:t.title}),uh=({onSelectLink:t,onDismiss:e,placeholder:o,visitUrlText:n,linkCount:s=ch})=>{let r=y("LinkSearch",cc),[i,a]=uc(""),l=ah(),c=dc(Ea("url")),p=dc(ua("URL",ph)),[u,d]=uc(p.length-1),m=b("fallbackImage"),h=f=>{let _=f.target;a(_.value)},g=(f,_)=>{f.stopPropagation(),f.preventDefault(),window.open(_,"_blank")},v=f=>{var w;let _=u-1<0?p.length-1:u-1,x=u+1===p.length?0:u+1;f.code==="Escape"&&(a(""),e()),f.code==="ArrowUp"&&d(_),f.code==="ArrowDown"&&d(x),f.code==="Enter"&&t(((w=p[u])==null?void 0:w.text)||i)},E=ih(lh(f=>{l(We({query:f,type:"URL",tags:["link-search"]}))},300),[]);return pc(()=>{i&&E(i)},[i]),pc(()=>()=>{l(pn())},[]),Sr("div",{className:r.root,children:[$e(me,{withDivider:!0,children:(i?p:c).slice(0,s).map((f,_)=>$e(N,{selected:u===_,onClick:()=>t(f.text),"data-testid":"linksearch-suggestion",children:Sr(H,{children:[$e(H.Image,{src:Rn(f,"small",m||void 0),title:f.title||f.text}),Sr(H.Content,{className:r.content,cropText:!0,children:[$e(H.Title,{children:f.title||yr(f.text)}),f.title&&yr(f.text)]}),$e(N.Actions,{children:$e(N.ActionButton,{label:n,onClick:x=>g(x,f.text)})})]})},f.text))}),$e(Yt,{value:i,onChange:h,autoFocus:!0,placeholder:o,onKeyUp:v})]})},gc=uh;var vr={};z(vr,{enUS:()=>dh,nlNL:()=>gh});var dh={insertLink:[{type:0,value:"Insert link"}],linkInputPlaceholder:[{type:0,value:"Search, type or paste link"}],visitUrl:[{type:0,value:"Visit"}]},gh={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 _r}from"react/jsx-runtime";var vh=hh((t,e)=>{let o=y("TabCompletion",te);return ue("mark",{ref:e,className:xr(o.matchSelection)},"selection-start")}),_h=({startRef:t,boundaryRef:e,inputStyle:o,inputElement:n,children:s})=>{let r=T(vr),i=y("TabCompletion",te),a=fc(null),l=fc(null),[c,p]=hc(null),u=Sh(),d=Tt(document.activeElement===n),[m]=hc(()=>document.createRange());d.triggerRef.current=m,mc(()=>()=>m.detach(),[]),mc(()=>{let g=t.current,v=a.current;!g||!v||(m.setStart(g,0),m.setEnd(v,0))},[t.current,a.current]),ct(()=>{d.close()});let h=yh(g=>{let v=m.toString(),E=/^http(s?):\/\//.test(g)?g:`https://${g}`;u(Go({text:`[${v}](${E})`,replace:"selection"}))},[]);return _r("span",{children:[ue("mark",{ref:a,className:xr(i.matchSelection),"aria-haspopup":"dialog","aria-expanded":d.opened?"true":"false",children:s}),d.opened&&ue(Et,{className:i.popoverRoot,triggerRef:d.triggerRef,boundaryRef:e,position:"above",align:"start",children:_r(Pn,{style:o,ref:l,children:[ue("div",{className:xr(i.selectionOptions,{[i.selectionOptionsIsHidden]:c!==null}),children:_r("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(gc,{placeholder:r("linkInputPlaceholder"),visitUrlText:r("visitUrl"),onSelectLink:h,onDismiss:()=>{p(null),d.close()}})]})})]},"selection-end")},Ln=class extends mh{charCount=0;foundIndex=0;startRef=null;props;onBeforeParse(e,o){return this.props=o,this.charCount=0,this.startRef=fh(),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(vh,{ref:this.startRef}):ue(_h,{inputElement:o.inputElement,startRef:this.startRef,boundaryRef:o.boundaryRef,inputStyle:o.inputStyle})}asTag(){return"mark"}};import{jsx as kt,jsxs as Ph}from"react/jsx-runtime";var Eh=({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"),u=b("showMidSentenceSuggestions"),d=b("inlineSuggestions"),m=on(a),h=wh(null);Ch(()=>{we(a)&&m&&nn(a,m)},[m]);let g=bh(f=>{if(!s||!o)return f;let _=[kt("span",{className:c.resetIndent,children:"\u200B"},"u200B"),kt("span",{className:br(c.tabText,c.resetIndent),"data-source":l,children:o},"tabText")];return n&&_.push(kt("span",{className:br(c.hint,c.resetIndent),children:kt(rs,{keyCode:"tab"},"tabHint")})),dr(f,_)},[s,o,n]),v=yc(()=>{let f=[];return d&&f.push(new En("inline")),p&&f.push(new Ln("selection")),f.push(new lt("placeholders")),r&&f.push(new In("keywords")),f},[d,p,r]),E=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?Ph("div",{ref:f=>{f!=null&&f.parentElement&&(h.current=f==null?void 0:f.parentElement)},className:c.root,style:E,children:[kt(xh,{tagName:"span",containerTagName:"div",className:br(c.container,c.agentText),disableLineBreaks:we(a),content:e||"\u200B",onAfterParse:g,matchers:v,selection:m,keywordMatches:i,inputElement:a,inputStyle:E,boundaryRef:h,inlineSuggestionsOnlyAtEnd:!u}),kt("br",{})]}):null},kh=({input:t,ui:e,settings:o,styleSuggestions:n,conversation:s})=>{var g;let{tabCompletionSuggestion:r}=t,i=(r==null?void 0:r.text)||"",a=(r==null?void 0:r.source)||"",l=t.html??ro(t.text),c=i.indexOf(t.text)===0?i.slice(t.text.length):"",{showTabHint:p}=e,{isSupported:u}=s,{showTabCompletion:d,visible:m,showStyleSuggestions:h}=o;return{showTabHint:p,showStyleSuggestions:h,showTabCompletion:d,content:l,tabText:c,source:a,keywordMatches:((g=n.list)==null?void 0:g.keywordMatches)??[],enabled:m&&u!==!1}},Sc=Th(kh)(Eh);import uy from"classnames";import{useEffect as dy}from"react";import{useDispatch as gy,useSelector as Q}from"react-redux";import{createAsyncThunk as co,createSlice as Ih}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)},Ee=co("autoflows/getAll",async(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");return o.getAutoflows(t)}),Cr=co("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(Ee(t.platformSessionId))}),wr=co("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(Ee(t.platformSessionId))}),Rh=Ih({name:"autoflows",initialState:vc,reducers:{},extraReducers:t=>{t.addCase(Cr.pending,(e,o)=>{let n=_c(o.meta.arg.triggerPayload)(e);n.state="Started",n.isBusy=!0}),t.addCase(wr.pending,(e,o)=>{let n=_c(o.meta.arg.triggerPayload)(e);n.state="Aborted",n.isBusy=!0}),t.addCase(Ee.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}),t.addCase(Ee.rejected,e=>{e.fetchState="error"}),t.addCase(Ee.fulfilled,(e,o)=>{e.list=o.payload,e.fetchState="done"}),t.addCase(I,()=>vc)}}),bc=co("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(Ee(t))}),s.on("sessionCompleted",()=>{o(Ee(t))})}),Cc=co("autoflows/closeStream",(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");o.closeStream(t)}),wc=Rh.reducer;import{createAsyncThunk as uo,createSlice as Lh}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),po=uo("customMessages/getAll",async(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");return o.getCustomMessages(t)}),An=uo("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)}),Mn=uo("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=Lh({name:"customMessages",initialState:Tc,reducers:{onCustomMessage(t,e){Array.isArray(e.payload)?t.list=e.payload:t.list=[e.payload]}},extraReducers:t=>{t.addCase(po.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}).addCase(po.rejected,e=>{e.fetchState="error"}).addCase(po.fulfilled,(e,o)=>{e.fetchState="done",e.list=o.payload||[]}).addCase(An.pending,(e,o)=>{e.sentSuggestions.push(o.meta.arg.suggestion.text),e.errorSuggestions=e.errorSuggestions.filter(n=>o.meta.arg.suggestion.text!==n)}).addCase(An.rejected,(e,o)=>{let n=e.sentSuggestions.indexOf(o.meta.arg.suggestion.text);e.errorSuggestions.push(...e.sentSuggestions.splice(n,1))}).addCase(Mn.pending,(e,o)=>{e.sentSuggestions.push(o.meta.arg.suggestion.text),e.answeredSuggestions.push(o.meta.arg.suggestion.text)}).addCase(Mn.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=uo("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=uo("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 Ah}from"@reduxjs/toolkit";var Mh={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},Tr=Oc("exchangeToken/getTemporaryExchangeToken",async(t,e)=>{let{deepdeskAPI:o}=e.extra,n=await o.getTemporaryExchangeToken();return{accountUrl:o.client.baseUrl,jwt:n}}),Er=Oc("exchangeToken/pollExchangeToken",(t={},e)=>{let{interval:o=1e3*60*30}=t,{dispatch:n}=e;return n(Tr()),setInterval(()=>n(Tr()),o)}),Dc=Ah({name:"exchangeToken",initialState:Mh,reducers:{stopPollExchangeToken(t){t.interval&&clearInterval(t.interval),t.interval=null}},extraReducers:t=>{t.addCase(Tr.fulfilled,(e,o)=>{e.jwt=o.payload.jwt,e.accountUrl=o.payload.accountUrl}),t.addCase(Er.fulfilled,(e,o)=>{e.interval=o.payload})}}),{stopPollExchangeToken:Hc}=Dc.actions,Bc=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 jh}from"react";import{connect as Vh}from"react-redux";import Kh from"classnames";import{Fragment as Uh}from"react";import Oh from"classnames";var Kc={root:"_root_838fd_1"};import{jsx as Dh}from"react/jsx-runtime";var Nh=({className:t,children:e})=>{let o=y("Unicode",Kc);return Dh("span",{className:Oh(t,o.root),children:e})},Uc=Nh;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 kr={};z(kr,{enUS:()=>Hh,nlNL:()=>Bh});var Hh={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 Xe,jsxs as On}from"react/jsx-runtime";var zh=({disabled:t,state:e,displayName:o,description:n,onStartAutoflow:s,onStopAutoflow:r})=>{let i=y("Autoflow",zc),a=T(kr),l=e==="Started"?"stop":"start",c=l==="start"?"\u25B6":l==="stop"?"\u25FC":"";return On(N,{className:Kh(i.root,{[i.isDisabled]:t,[i.isCompleted]:e==="Completed",[i.isAborted]:e==="Aborted",[i.isStarted]:e==="Started"}),children:[Xe(H,{children:On(H.Content,{children:[On(H.Title,{children:[e&&Xe("span",{className:i.stateBadge,children:a(e)}),o]}),Xe("span",{children:n})]})}),Xe(N.Actions,{fixed:e==="Started",children:Xe(N.ActionButton,{primary:!0,className:l==="start"?i.buttonStart:i.buttonStop,onClick:e==="Started"?r:s,disabled:t,label:On(Uh,{children:[Xe(Uc,{children:c})," ",Xe("span",{children:a(l)})]})})})]})},jc=zh;import{jsx as Vc}from"react/jsx-runtime";var qh=(t,e)=>{let o=e.filter(n=>n.state==="Started");return o.length>0?o.indexOf(t)===-1:!1},Wh=({autoflows:t,onStartAutoflow:e,onStopAutoflow:o,platformSessionId:n})=>Vc(jh,{children:t.map(s=>Vc(jc,{displayName:s.displayName,description:s.description,disabled:s.isBusy||qh(s,t),state:s.state,onStartAutoflow:()=>e({platformSessionId:n,triggerPayload:s.triggerPayload}),onStopAutoflow:()=>o({platformSessionId:n,triggerPayload:s.triggerPayload})},s.displayName))}),Gh=({autoflows:t,conversation:e})=>{var o;return{autoflows:t.list,platformSessionId:(o=e.current)==null?void 0:o.sessionId}},$h={onStartAutoflow:Cr,onStopAutoflow:wr},qc=Vh(Gh,$h)(Wh);import{useEffect as Xh,useState as Qh}from"react";import{useDispatch as Zh}from"react-redux";import $c from"classnames";import{jsx as Wc}from"react/jsx-runtime";var Pr=()=>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 Pt,jsxs as Xc}from"react/jsx-runtime";var Jh=({entities:t})=>{let e=y("EntitiesWidgetList",Gc),[o,n]=Qh(void 0),s=Zh(),r=()=>{n(void 0)},i=a=>{t&&(n(t.indexOf(a)),to(a.text),s(J({name:"entity copied",data:{entity:a,type:"copy"}})))};return Xh(()=>{let a=setTimeout(r,500);return()=>{clearTimeout(a)}},[o]),!t||t.length===0?null:Pt("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:[Pt("span",{className:e.entityText,children:a.text}),Xc("span",{className:e.iconWrapper,children:[Pt("span",{className:$c(e.icon),children:Pt(Pr,{})}),Pt("span",{className:$c(e.icon,o===l&&e.iconClicked),children:Pt(Pr,{})})]})]},a.text))})},Qc=Jh;import ty from"classnames";import{useCallback as Zc}from"react";import{useDispatch as oy,useSelector as Nn}from"react-redux";var go={};z(go,{enUS:()=>Yh,nlNL:()=>ey});var Yh={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"}]},ey={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 ke={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 He,jsxs as Dn}from"react/jsx-runtime";var ny=({suggestion:t})=>{let e=T(go),o=oy(),n=Nn(kc(t.text)),s=Nn(Pc(t.text)),r=Nn(Ic(t.text)),i=Nn(Bo),{replyOptions:a}=t,l=Zc(p=>{p.preventDefault(),p.stopPropagation(),!(n||!i)&&o(An({platformSessionId:i,suggestion:t}))},[t,n,o,i]),c=Zc(p=>{if(p.preventDefault(),p.stopPropagation(),!i||!a)return;let u=parseInt(p.target.dataset.index,10),d=a[u];o(Mn({platformSessionId:i,reply:d,suggestion:t}))},[t,n,o,i]);return Dn(N,{onClick:l,className:ty(ke.root,{[ke.isUsed]:n,[ke.hasError]:r}),children:[He(H,{children:Dn(H.Content,{children:[Dn(H.Title,{className:ke.title,children:[t.text," ",He(is,{className:ke.label,children:"analyse tool"})," ",r&&He("span",{className:ke.errorIcon,role:"img","aria-label":e("sendingError"),title:e("sendingError"),children:"!"})]}),a&&a.length>0&&He("ul",{className:ke.quickReplies,children:a.map(p=>He("li",{className:ke.quickReply,children:p.title},p.title))})]})}),Dn(N.Actions,{fixed:r||n,children:[a&&a.length>0&&He(N.DropdownButton,{label:e("answer"),disabled:s,children:a.map((p,u)=>He(N.DropdownItem,{index:u,label:p.title,onClick:c},p.title))}),He(N.ActionButton,{primary:!0,disabled:n,onClick:l,label:e(n?"suggestionSent":r?"tryAgain":"sendSuggestion")})]})]})},Jc=ny;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 iy}from"react-redux";import{useCallback as sy}from"react";import{jsx as Qe,jsxs as Hn}from"react/jsx-runtime";var ry=({suggestion:t,lines:e,onEdit:o,onUse:n})=>{var d;let s=t.text||t.url||t.message,r=un(s),i=T(go),a=b("showImages"),l=b("fallbackImage"),c=m=>{m.preventDefault(),m.stopPropagation(),n(s)},p=m=>{m.preventDefault(),m.stopPropagation(),o(t)},u=sy(m=>{window.open(r,"_blank"),m.stopPropagation(),m.preventDefault()},[r]);return Hn(N,{onClick:c,"data-testid":"edit-suggestion",children:[Hn(H,{children:[a&&t.image&&Qe(H.Image,{src:Rn(t,"small",l||void 0),title:t.title}),Hn(H.Content,{children:[t.title&&Qe(H.Title,{children:t.title}),t.searchKeywords&&((d=t.searchKeywords)==null?void 0:d.length)>0&&Qe(N.Labels,{labels:t.searchKeywords}),Qe(H.Content,{cropText:e==="single",lineClamp:e==="multiple",children:s})]})]}),Hn(N.Actions,{children:[r&&Qe(N.ActionButton,{onClick:u,label:i("visitUrl")}),Qe(N.ActionButton,{primary:!0,onClick:p,label:i("preview")}),Qe(N.ActionButton,{primary:!0,onClick:c,label:i("useSuggestion")})]})]})},tp=ry;import{Fragment as ly,jsx as op}from"react/jsx-runtime";var ay=({contentType:t,lines:e,suggestions:o})=>{let n=oe(),s=iy(ft),r=a=>{n.send(zs,{state:s,suggestion:a,contentType:t})},i=(a,l)=>{n.send(xe,{text:a,suggestion:{...l,source:l.source,sourceText:l.text}})};return op(ly,{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=ay;var Ir={};z(Ir,{enUS:()=>cy,nlNL:()=>py});var cy={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"}]},py={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 It}from"react/jsx-runtime";var Bn=(t,e)=>{let o=Q(_e);dy(()=>o?e.every(n=>!!n)?t():()=>{}:()=>{},[...e,o])},my=()=>{let t=T(Ir),e=gy(),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=Q(Ct),u=Q(vn),d=Q(xc),m=Q(hn),h=Q(Ec),g=Q(Fo),v=Q(Ko),E=Q(_e),f=Q(Bo),_=Q(Fc),x=Q(ft),w=oe(),C=Q(Pa),O=Q(Nc("/admin/personal-collection")),ee=b("adminUrl");if(Bn(()=>(e(po(f)),e(Lc(f)),()=>{e(Ac(f))}),[e,v,r,f]),Bn(()=>(e(Ee(f)),e(bc(f)),()=>{e(Cc(f))}),[e,v,s,f]),Bn(()=>{u.forEach(({type:P})=>{e(P==="entities"?ae():Se(P))})},[e,v,g,p]),Bn(()=>(e(Er()),()=>{e(Hc())}),[e,v,i,g]),v===!1)return M("div",{className:n.stateText,children:M("div",{children:M("p",{children:t("notSupported")})})},"supported");if(E===!1)return M("div",{className:n.loginText,children:M("div",{children:M(Cn,{isEmbedded:o,loginUrl:ee})})},"login");if(!p||!f||E===null||C||_)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:uy(n.root),"data-testid":"widget",children:It(ls,{className:n.sectionList,children:[D&&M(Ue,{title:t("actions"),type:"shortcuts",children:It("div",{className:n.shortcutList,children:[c&&It("button",{className:n.shortcut,onClick:()=>w.send("ShowCommandPalette",{isOpen:!0}),children:[M(gt,{}),t("linkSearch")]}),a&&It("button",{className:n.shortcut,onClick:()=>w.send("ShowCommandPalette",{isOpen:!0,page:"summary"}),children:[M(lp,{}),t("linkSummary")]}),l&&It("button",{className:n.shortcut,onClick:()=>w.send("ShowCommandPalette",{isOpen:!0,page:"knowledgeSearch"}),children:[M(ip,{}),t("linkKnowledgeSearch")]}),O&&It("a",{className:n.shortcut,target:"_blank",href:O,rel:"noreferrer",children:[M(ep,{}),t("linkPersonalcollection")]})]})}),r&&h.length>0&&M(Ue,{type:"custom-messages","data-testid":"custom-messages",children:M(me,{withDivider:!0,children:h.map(P=>M(Jc,{suggestion:P},P.text))})}),s&&d.length>0&&M(Ue,{type:"autoflows",title:t("titleAutoflows"),"data-testid":"autoflows",children:M(me,{withDivider:!0,children:M(qc,{})})}),u.map(({type:P,title:B,amount:q,lines:Vn})=>{var Fe;switch(P){case"entities":return m&&m.length>0&&M(Ue,{type:P,title:B,"data-testid":`type-${P}`,children:M(Qc,{entities:m})},P);default:return((Fe=x[P])==null?void 0:Fe.fetchState)==="done"&&x[P].suggestions.length>0&&M(Ue,{type:P,title:B,"data-testid":`type-${P}`,children:M(me,{withDivider:!0,children:M(np,{lines:Vn,contentType:P,suggestions:x[P].suggestions.slice(0,q)||[]})})},P)}})]})})},cp=my;function pp(t){let e=new Range;return e.selectNodeContents(t),e}var mo=/[\u200B-\u200D\uFEFF]/g;function Rt(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,u=/[\u200B-\u200D\uFEFF]/;if(!u.test(l))return c;for(let d=0;d<=l.length;d++)if(u.test(l[d])||p++,p===c)return d;throw new Error("Offset out of range")}function a(l){var c;switch(l.nodeType){case Node.TEXT_NODE:{let p=l.textContent,u=p.replace(mo,""),d=s+u.length,m=e>=s&&e<=d,h=o>=s&&o<=d;if(m){let g=i(p,e-s);g===0&&!h?n.setStartBefore(l):n.setStart(l,g)}h&&(n.setEnd(l,i(p,o-s)),r=!0),s=d;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 u=0;u<l.childNodes.length&&(a(l.childNodes[u]),!r);u++);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 Rr(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 u=p===o,d=p===s;switch(p.nodeType){case Node.TEXT_NODE:{let m=p.textContent;u&&(i=l+m.substring(0,n).replace(mo,"").length),d&&(a=l+m.substring(0,r).replace(mo,"").length),l+=m.replace(mo,"").length;break}case Node.ELEMENT_NODE:{let{tagName:m}=p,h=p.nextSibling===null;m==="BR"&&!h&&l++;for(let g=0;g<p.childNodes.length&&(u&&g===n&&(i=l),c(p.childNodes[g]),d&&g===r-1&&(a=l),a===void 0);g++);!d&&m==="DIV"&&!h&&l++,d&&(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 Fn(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,u=c===s;switch(p&&i++,c.nodeType){case Node.TEXT_NODE:{if(i!==0)return;let d=p?n:0,m=u?r:void 0,h=c.textContent.replace(mo,"");d===0&&m===void 0?a+=h:a+=h.substring(d,m);break}case Node.ELEMENT_NODE:{let{tagName:d}=c,m=c.nextSibling===null;i===0&&d==="BR"&&!m&&(a+=`
4
+ `);for(let h=p?n:0;h<(u?Math.min(r,c.childNodes.length):c.childNodes.length)&&(l(c.childNodes[h]),i!==1);h++);!u&&i===0&&d==="DIV"&&!m&&(a+=`
5
+ `);break}default:break}u&&i++}return l(t),a}var Lt=class extends Me{observer;getText(){let e=new Range;return e.selectNodeContents(this.element),Fn(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:Rr(this.element,o)}getSelectedText(){if(!this.currentSelection)return"";let{start:e,end:o}=this.currentSelection;return Fn(this.element,Rt(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 Lr=class{constructor(e){this.name=e;this.broadcastChannel=new BroadcastChannel(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()}},Ar=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()}},Mr=class{constructor(e){this.params=e;this.deepdeskUrl=e.deepdeskUrl,this.eventMap=e.eventMap,this.defaultChannel=this.createChannel("deepdesk-general")}sessionId;deepdeskUrl;channel;defaultChannel;eventMap;get isCrossOrigin(){return this.params.deepdeskUrl!==(this.params.origin||window.location.origin)}setSessionId(e){this.sessionId!==e&&(this.cleanup(),k.info("Set sessionId",e),this.sessionId=e,this.channel=this.createChannel(e))}createChannel(e){let o=this.params.createCustomChannel?this.params.createCustomChannel(e):this.isCrossOrigin?new Ar(e,this.deepdeskUrl,{debug:!0}):new Lr(e),n=s=>{var r,i;s.origin===this.deepdeskUrl&&s.data.type==="event"&&s.data.channel===e&&(k.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;k.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,channel:this.sessionId})}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=Mr;var At=class extends Error{constructor(o,n){super(o);this.body=n}name="CustomError"};var Or=t=>new Promise(e=>{setTimeout(e,t)});var Mt=class extends At{name="ClientError"},Nr=class extends At{name="ServerError"},de=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}request(e,o={}){return new Promise((n,s)=>{let r={isAborted:!1,reject:s},i=`${this.baseUrl}${e}`,a=this.fetch,{abortLatest:l=!1,attempts:c=1,retryDelay:p=500,refreshTokenOn401:u=!0,retryOnError:d=x=>x instanceof TypeError,retryOnResponse:m=x=>x.status>=500,version:h="v1",...g}=o,v={credentials:"include",...g,headers:{"Content-Type":"application/json",...g.headers}};o.method!==void 0&&o.method!=="GET"&&this.csrfToken&&(v.headers={...v.headers,"X-CSRFToken":this.csrfToken}),typeof h=="string"&&(v.headers={...v.headers,"X-Deepdesk-API-Version":h});let E=c,f=!1;if(!a)throw new Error("fetch is not set");this.latestRequestByUrl[i]&&l&&(this.latestRequestByUrl[i].isAborted=!0,this.latestRequestByUrl[i].reject(new Error("Aborted"))),this.latestRequestByUrl[i]=r;let _=async()=>(E--,a(i,v).then(async x=>m(x)&&!r.isAborted&&E>0?(await Or(p),_()):x.status===401&&u===!0&&f===!1?(f=!0,await this.refreshToken(),_()):x).catch(async x=>{if(d(x)&&!r.isAborted&&E>0)return await Or(p),_();throw x}));_().then(x=>x.json().catch(()=>null).then(w=>{x.status>=500?s(new Nr("Server Error",w)):x.status===401?s(new Mt("Unauthorized",w)):x.status===403?s(new Mt("Forbidden",w)):x.status===404?s(new Mt("Not Found",w)):x.status>=400&&s(new Mt("Bad Request",w)),delete this.latestRequestByUrl[i],n(w)})).catch(x=>{s(x)})})}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 fy;(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||={})})(fy||={});function Kn(t){return{...A(t),tags:t.tags}}var Be=class t{constructor(e,o={}){this.options=o;this.client=new de(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(),k.info(`Creating conversation for session ${e.sessionId} and agent ${e.agentId}`);let o=await this.client.post("/api/conversations",{...F(e),tags:e.tags},{version:"v2"});return Kn(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(),k.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 Kn(r)}async isConversationSupported(e,o={}){k.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=F(o);o.tags&&(n.tags=o.tags);let s=await this.client.put(`/api/conversations/${e}`,n,{version:"v2"});return Kn(s)}async postMessages(e,o){return(await this.client.post(`/api/conversations/${e}/messages`,o.map(s=>({...F(s),tags:s.tags})),{version:"v2"})).map(s=>Kn(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",F({...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:F({...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 k.warn(`Invalid token '${e}'`),o})}async authenticateWithKey(e,o){await this.client.post("/apis/admin/session/api-key/",F(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}`,F(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`,F(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",F(e),{abortLatest:!0});return A(o)}async search(e){let o=await this.client.post(`/api/profiles/${e.profile}/search`,F(e),{version:"v2"});return A(o)}async knowledgeSearch(e,o,n){let s=await this.client.post("/api/knowledge-search/search",F({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(ci);if(!o||!r)return;let i=r[1].replace("-","_"),a=this.latestReceivedDeepdeskVersions[i];a&&o&&a!==o&&k.warn(`Overwritten Version header ${s}: ${JSON.stringify(a)} -> ${JSON.stringify(o)}`),this.latestReceivedDeepdeskVersions[i]=o})}};var fo=class{constructor(e,o){this.url=e;this.options={timeout:25e3,...o}}eventListeners={};options;timeoutTimer;eventSource;proxyEvent(e){this.eventSource.addEventListener(Ms(e),o=>{let{data:n}=o;try{let s=JSON.parse(n);this.emit(e,A(s))}catch{k.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 hy;(e=>{let t;(r=>(r.Started="Started",r.Aborted="Aborted",r.Completed="Completed"))(t=e.AutoflowSessionState||={})})(hy||={});var ho=class{constructor(e,o={}){this.apiUrl=e;this.client=new de(e,o)}client;streams={};logger=k;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`,F(o));return A(n)}async answerCustomMessage(e,o){await this.client.post(`/sessions/${e}/answers`,F(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",F(e));return A(o)}async stopAutoflowSession(e){await this.client.delete(`/autoflow-sessions/${e}`)}openStream(e){return this.streams[e]||(this.streams[e]=new fo(`${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 wy}from"@reduxjs/toolkit";import{createSlice as yy}from"@reduxjs/toolkit";var dp={startTime:null,stopTime:null},gp=yy({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:mp,handlingTimeStop:Un,handlingTimeReset:fp}=gp.actions,hp=gp.reducer;var yp=(t={})=>{let e={onAuthError:St(!1),...t};return o=>n=>s=>("error"in s&&s.error.message==="Unauthorized"&&o.dispatch(e.onAuthError),n(s))};import{createAsyncThunk as Sy,createSlice as vy}from"@reduxjs/toolkit";var Dr={list:{keywordMatches:[]},fetchState:"idle",isInitialRequest:null};var Ze=Sy("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 Dr.list;if(!r)throw new Error("No current conversation to fetch pinned messages");return o.getStyleSuggestions({profileCode:r,message:t})}),_y=vy({name:"styleSuggestions",initialState:Dr,reducers:{},extraReducers:t=>{t.addCase(Ze.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}).addCase(Ze.rejected,e=>{e.fetchState="error"}).addCase(Ze.fulfilled,(e,o)=>{e.fetchState="done",Ie(e.list,o.payload)||(e.list=o.payload)}).addCase(I,()=>Dr)}}),Sp=_y.reducer;var vp=(t={})=>{let e,o=!0,n={getStyleSuggestions:Ze,debounce:500,...t};return s=>r=>i=>{var m;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(!((m=c.conversation.current)==null?void 0:m.id)||!p)return l;let{text:d}=c.input;return d===a&&!o||(clearTimeout(e),d==="")||(e=setTimeout(()=>{o=!1,s.dispatch(n.getStyleSuggestions({text:d}))},t.debounce)),l}};function xy(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:Se,getAutocompleteSuggestions:Xt,debounce:200,check:xn,...t},o;return n=>s=>r=>{var g;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,u=(g=l.conversation.current)==null?void 0:g.id,d=r.type===mn.toString();if(!u||!c&&!p)return a;let{input:{userCommitted:m}}=l;return xy(m,i)&&!d||(clearTimeout(o),!e.check(l))||(o=setTimeout(()=>{let v=it(l);v===""?n.dispatch(e.getTextSuggestions("default")):n.dispatch(e.getAutocompleteSuggestions(v))},d?0:e.debounce)),a}};var xp=Ze.fulfilled.toString();function by(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=by(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 Ty=Cy({activeSuggestion:Ba,answer:El,auth:Ja,autoflows:wc,conversation:fi,contentTypes:cl,customMessages:Mc,exchangeToken:Bc,entities:dl,handlingTime:hp,info:aa,input:hs.reducer,overlayInput:W.reducer,settings:ui,profile:Ll,search:ga,summary:vl,styleSuggestions:Sp,ui:ja,textSuggestions:Ma});function Cp(t){return wy({reducer:Ty,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 Ey=t=>{var e;return((e=t==null?void 0:t.type)==null?void 0:e.toLowerCase())??"unknown"},ky=t=>e=>o=>n=>{var a;let s=e.getState(),r=ds("inlineSuggestions")(s);switch(n.type){case ve.toString():{let l=ka(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 St.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:Ey(n.payload.suggestion),...n.payload,replace:n.payload.replace==="selection"?{start:l,end:c}:{start:0,end:c}},{mayApplyChanges:!0});break}case Go.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 zt.toString():{let l=e.getState(),{text:c,selection:p}=l.input.userCommitted;t.emit("reset",{text:c,selectionAfter:p},{mayApplyChanges:!0});break}case Zo.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 be.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 $o.toString():t.handleKeyDown(n.payload);break;case Ut.toString():t.logSendMessage(n.payload);break;case Xo.toString():t.logSendEditSuggestionMessage(n.payload);break;case Qo.toString():t.handleInputChanged(n.payload);break;default:break}let i=o(n);switch(n.type){case Ut.toString():t.handleAfterSendMessage(n.payload);break;case Qt.toString():t.onUpdateShowTabHint(n.payload);break;case Un.toString():t.logHandlingTime();break;case ie.toString():{r&&(e.dispatch(Le([])),e.dispatch(Ae()));break}default:break}return i},wp=ky;function Hr(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:Hr(o),timeStop:Hr(n)}}function Br(t,e,o){var O,ee,D;let{text:n,metrics:{numCharsTyped:s,numCharsPasted:r,numCharsCut:i,numCharsDeleted:a,numPaste:l,agentStartedTypingTimestamp:c,externalTimeTotalSeconds:p,pastes:u,cuts:d,deletions:m,textSuggestions:h,offeredTextSuggestions:g}}=e[t],v=n.length,f=h.reduce((P,{text:B,searchTerm:q})=>P+B.length-(q?q.length:0),0),_=c??Date.now(),x=(Date.now()-_)/1e3+(p||0),w=s/x,C=h.reduce((P,{searchTerm:B})=>P+(B?B.length:0),0);return{conversationId:e.conversation.current.id,source:"agent",text:n,clientVersion:o.version,pastes:u,cuts:d,deletions:m,lenTextTyped:s+C,lenTextTotal:v,lenTextAssisted:f,lenTextPasted:r,lenTextCut:i,lenTextDeleted:a,timeTotalSeconds:x,charsPerSecond:w,numPastes:l,textSuggestionsV2:h,suggestionsCounters:[{source:"gpt",countOffered:g.filter(P=>P.source==="gpt").length}],agentId:(O=e.info.agentInfo)==null?void 0:O.agentId,agentName:(ee=e.info.agentInfo)==null?void 0:ee.agentName,agentEmail:(D=e.info.agentInfo)==null?void 0:D.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 Fr(t){return t instanceof HTMLElement&&(we(t)||tn(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{k.warn("[Deepdesk] SessionStorage is blocked by browser")}}});function Py(t){return t.offsetParent!==null}function Rp(t){if(!Py(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 Kr(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 ne}from"react/jsx-runtime";var Lp=Ip("showTabHint",!0),jn=class t{static version="10.1.8";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,createCustomChannel:l}){let c=e.replace(/\/api$/,"");this.deepdeskApi=new Be(c,{token:r,fetch:i}),this.version=n,this.instanceId=t.count++;let p={deepdeskAPI:this.deepdeskApi,dynamicThunkObject:this.dynamicThunkObject,middleware:[wp({emit:(u,d,m)=>this.emit(u,d,m),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=>Lp.update(u),sendEvent:(u,d)=>this.deepdeskApi.sendEvent(u,d)})]};o&&Object.assign(p,{deepdeskBrokerAPI:new ho(o)}),this.store=Cp(p),this.broadcastEvents=new up({debug:!0,deepdeskUrl:c,eventMap:Ya(this.store),createCustomChannel:l}),this.store.dispatch(Kt),this.store.dispatch(Qt(Lp.value())),this.store.dispatch(Kt({locale:s,adminUrl:c,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?(k.warn("Conversation is not supported"),!0):this.hasConversation()?this.state.profile.data?!1:(k.warn("Profile has not been loaded (yet)"),!0):(k.warn("No conversation loaded (yet)"),!0)}login(){return this.store.dispatch(St(null)),this.store.dispatch(De()),new Promise(e=>{let o=this.store.subscribe(()=>{let n=this.store.getState();_e(n)&&Wa(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){k.warn("Failed to attach user:",o)}}async isConversationSupported(e,o){return(await this.store.dispatch(ms({sessionId:e,options:o}))).payload}async createConversation(e){return this.hasConversation()&&this.sessionId()!==e.sessionId&&this.resetConversation(),(await this.store.dispatch(Uo(e))).payload}async getConversationBySessionId(e,o){return this.hasConversation()&&this.sessionId()!==e&&this.resetConversation(),(await this.store.dispatch(zo({sessionId:e,options:o}))).payload}async upsertConversation(e){return this.hasConversation()&&this.sessionId()!==e.sessionId&&this.resetConversation(),(await this.store.dispatch(fs(e))).payload}async postMessages(e){return(await this.store.dispatch(Vo(e))).payload}async updateConversation(e){return(await this.store.dispatch(jo(e))).payload}resetConversation(){this.store.dispatch(I()),this.dynamicThunkObject.conversationQuery=null}async getSummary(){let e=await this.store.dispatch(be());if(e.error)throw new Error(e.error.message);return e.payload.summary}configure(e){this.store.dispatch(Kt(e))}setVisitorInfo(e){this.store.dispatch(ia(e))}async setAgentInfo(e){await this.store.dispatch(Wt(e))}async setAgentSettings(e){await this.store.dispatch(Ns(e))}async getAgentSettings(){return(await this.store.dispatch(Ds())).payload}async refresh(){if(this.shouldAbort())return Promise.resolve();let e=[];return this.store.dispatch(mn()),e.push(this.refreshWidgetSuggestions()),Promise.all(e).then(()=>{})}notifyInputChanged(e){this.store.dispatch(Qo(e))}syncInputHtml(e){this.store.dispatch(Pi(e))}notifyKeyDown(e){this.store.dispatch($o(e))}notifyPaste(e,o){this.store.dispatch(Ei({text:e,selectionText:o}))}notifyCut(e){this.store.dispatch(wi(e))}notifyExternalSuggestion(e){this.store.dispatch(ie(e)),this.store.dispatch(Ae())}notifyEditSuggestion(e){this.store.dispatch(La(e.contentType,e.suggestions)),this.store.dispatch(ve({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(yt({collapse:!1})),this.inputMediator&&this.store.dispatch(Si({text:e,html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),!this.shouldAbort()&&(this.isMounted||this.store.dispatch(Le([])))}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(Ti(Wo(e))),!(e.key!=="Tab"&&!this.settings.showTextSuggestions))switch(e.key){case"Up":case"ArrowUp":if(o||!a||!r||e.shiftKey)return;this.store.dispatch(xi()),i||this.stageSelectedSuggestion({inputType:"arrow"}),e.preventDefault();return;case"Down":case"ArrowDown":{if(o||!a||!r||e.shiftKey)return;this.store.dispatch(Ci());let{selectedSuggestionIndex:c}=this.state.input;c===-1?this.store.dispatch(zt()):i||this.stageSelectedSuggestion({inputType:"arrow"}),e.preventDefault();return}case"Esc":case"Escape":{l?(this.store.dispatch(Jo(-1)),this.store.dispatch(zt()),e.preventDefault()):o||(this.store.dispatch(yt({collapse:!0})),this.store.dispatch(Ua(!0)),e.preventDefault());return}case"Tab":{let{userCommitted:c}=this.state.input,p=c.text.substring(0,c.selection.end),{tabCompletionSuggestion:u}=this.state.input;this.store.dispatch(Qt(!1)),this.state.input.selectedSuggestionIndex>-1?this.stageSelectedSuggestion({inputType:"tab"}):this.settings.showTabCompletion&&u&&u.text.startsWith(p)&&(this.store.dispatch(ie({text:u.text,suggestion:u,eventMetrics:{inputType:"tab"},replace:"until-selection-end"})),this.store.dispatch(Ae())),e.preventDefault();break}default:}}handleAfterSendMessage(e){this.emit("send-message",e),this.store.dispatch(ki()),this.store.dispatch(Le([]))}handlingTimeStart(){this.state.handlingTime.startTime||(k.info("Start handling time"),this.store.dispatch(mp()))}handlingTimeStop(){this.state.handlingTime.startTime&&(k.info("Stop handling time"),this.store.dispatch(Un()))}logSendMessage(e){let o=Br("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=Br("overlayInput",this.state,{version:this.version});e&&Object.assign(o,{text:e}),this.store.dispatch(_i(this.state.overlayInput.metrics))}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(Ae()),this.store.dispatch(Ut(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){k.warn(`The following error occurred in deepdeskSDK.on('${e}', handler)`),k.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]=jt(n,s);return r.dataset.testid=e,o!=null&&o.rootNode&&r.classList.add(o.rootNode),this.unmountHandlers.push(()=>{Ur(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(()=>{Ur(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(!Fr(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:u,detectSubmit:d,insertLink:m,inputMediator:h,closestScrollSelector:g,appendOverlayTo:v,inlineSuggestions:E}=o;this.configure({showStyleSuggestions:s,showTabCompletion:r,textSuggestionsCount:a,showMidSentenceSuggestions:l,showSuggestionsBeforePattern:c,showSuggestionsAfterPattern:p,showTextSuggestions:i,insertLink:m,isEmbedded:u,inlineSuggestions:E});let f=g&&kp(e,g)||void 0,_=this.overlayContainerFactory("deepdesk-tab-completion",n,f||e,{appendTo:v,closestScrollElement:f,mirrorOverflow:!0,onRemove:()=>this.unmount()}),x=this.overlayContainerFactory("deepdesk-suggestions-overlay",n,f||e,{appendTo:v});o.automaticHandlingTime&&this.setupHandlingTime(e),zn(ne(so,{store:this.store,customStyles:n,children:ne(Zt,{broadcastEvents:this.broadcastEvents,children:ne(Sc,{inputElement:e})})}),_),zn(ne(so,{store:this.store,customStyles:n,children:ne(Zt,{broadcastEvents:this.broadcastEvents,children:ne(Tn,{})})}),x),zn(ne(so,{store:this.store,customStyles:n,children:ne(Zt,{broadcastEvents:this.broadcastEvents,children:ne(Nl,{})})}),this.createContainer("deepdesk-overlays")),Ve(e),this.inputMediator=h||(we(e)?new Oe(e):new Lt(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 w;this.inputMediator.on("selection",C=>{clearTimeout(w),C===null?w=setTimeout(()=>{C!==null&&this.store.dispatch(ys(C))},500):this.store.dispatch(ys(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",()=>{d&&this.notifySubmit()}),this.inputMediator.on("blur",()=>this.store.dispatch(ht(!1))),this.inputMediator.on("focus",()=>this.store.dispatch(ht(!0))),this.store.dispatch(vi({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&&k.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}),zn(ne(so,{store:this.store,customStyles:n,children:ne(Zt,{broadcastEvents:this.broadcastEvents,children:ne(cp,{})})}),e),this.whenConversationLoaded(()=>{var a;this.broadcastEvents.setSessionId((a=this.state.conversation.current)==null?void 0:a.sessionId)})}unmountWidget(){this.widgetRoot&&Ur(this.widgetRoot),this.widgetRoot=null}setupHandlingTime(e){let o=Kr(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(oo());let e=Ct(this.state);e&&this.store.dispatch(Kt({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(k.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;k.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=vn(this.state);try{o.forEach(({type:n})=>{n==="entities"?this.store.dispatch(ae()):this.store.dispatch(Se(n))})}catch(n){this.handleError(n)}}};async function Iy(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 Ry(t,e,o={}){let n=o.replace?Rt(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?Rt(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 Ly(t){return t.replace(/\[([\w\s\d]+)\]\((https?:\/\/[^\s]+)\)/g,'<a href="$2" target="_blank" rel="noreferrer">$1</a>')}async function Ay(t,e,o){await new Be(t).authenticateWithKey(e,o)}async function My(t){let o=await new de(t).get("/platform/config/",{version:null});return A(o)}async function Oy(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 Ny(t,e){let o=await Oy(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{H as Card,yu as Chip,Lt as ContentEditableInput,Be as DeepdeskAPI,jn as DeepdeskSDK,de as HTTPClient,Me as InputMediator,ze as InputType,rs as KeyboardHint,is as Label,Ho as Locale,Ue as Section,ls as SectionList,fe as Sources,N as Suggestion,me as SuggestionList,Oe as TextAreaInput,nt as ToggleButton,Ny as attachFile,Ay as authenticateWithKey,jt as createOverlayContainer,Rt as createRangeFromOffsets,ro as escapeHTML,My as fetchPlatformConfig,Ly as formatTextMarkup,Rr as getRangeOffsets,Fn as getRangeText,Fr as isSupportedInputElement,Ry as updateContentEditable,Iy as updateTextArea,y as useStyles,Kr as waitForElementVisibilityChange};