1(function(){try{var e=typeof window<`u`?window:typeof global<`u`?global:typeof globalThis<`u`?globalThis:typeof self<`u`?self:{};e.SENTRY_RELEASE={id:`release-202609241050`};var t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]=`d054bb75-4095-413c-8977-7f720bc91495`,e._sentryDebugIdIdentifier=`sentry-dbid-d054bb75-4095-413c-8977-7f720bc91495`)}catch{}})();import{A as e,C as t,F as n,I as r,It as i,K as a,M as o,Mt as s,Nt as c,O as l,Ot as u,R as d,S as f,b as p,d as m,et as h,gt as g,ht as _,it as v,j as y,k as b,ot as x,pt as S,w as C}from"./vendor-vue-core-B0avW4A6.js";import{At as w,Bt as T,Ct as E,M as D,v as O}from"./utils-01hI5-7X.js";import{H as ee,k as te,t as k}from"./user-1VcPMvca.js";import{a as ne}from"./vendor-utils-PJ_f0V92.js";import{t as re}from"./toast-nz9AHFzD.js";import{C as ie,M as ae,T as oe,b as A}from"./vendor-ui-CFT4XuI7.js";import{t as se}from"./_plugin-vue_export-helper-CwAtdVh-.js";import{t as ce}from"./UpgradeNowPopup-CRf7z2f5.js";import{t as le}from"./Tooltip-45hSZU0i.js";import{t as j}from"./Loader-ChJ3YuZD.js";import{a as ue,n as M,p as de,u as fe}from"./vendor-forms-BTH3IdZK.js";import{t as pe}from"./useAIAssistant-CImYbqTW.js";import{n as me,t as he}from"./useAIDataSource-CqCVPKry.js";import{n as N}from"./markdown-B2oOu8EY.js";import{t as P}from"./UpgradeNowButton-DdPBx2Ti.js";import{t as F}from"./Switch-RazmFRf4.js";import"./plain-crown-Bfuxtexx.js";import{t as ge}from"./InputField-BXOtsVwQ.js";import{t as I}from"./shopify-colored-BLE0jIi1.js";import{t as _e}from"./RichTextEditor-B4TPsWIZ.js";import{t as ve}from"./UnsavedConfirmationModal-DRwcg1fJ.js";var L=e=>e!==!1&&e!==0,R=(e=[])=>{let t=new Set,n=new Set,r=!0;e.forEach(e=>{let i=L(e.is_published),a=e.is_custom===1||e.is_custom===!0,o=e.custom_date||(a?e.day:void 0);a||o?o&&n.add(o):e.day!==void 0&&e.day!==null&&(!e.is_hidden&&i&&t.add(e.day),(e.is_hidden||!e.full_day||!i)&&(r=!1))});for(let t of[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`])if(!e.some(e=>{let n=L(e.is_published);return!(e.is_custom===1||e.is_custom===!0)&&!e.custom_date&&e.day===t&&!e.is_hidden&&n})){r=!1;break}let i=t.size,a=n.size;return i===7&&!a?r?`Always available`:`Interact daily, at scheduled times`:!i&&a?`${a} specific ${a>1?`dates`:`date`}`:i&&!a?`${i} ${i>1?`days`:`day`} a week`:!i&&!a?`Never interact with AI support agent`:`${i} ${i>1?`days`:`day`} a week + ${a} specific ${a>1?`dates`:`date`}`},z=(e=[])=>({pages:e.includes(`pages`),posts:e.includes(`posts`),products:e.includes(`products`),orders_fulfillments:e.includes(`orders_fulfillments`),carts:e.includes(`carts`)}),B=e=>e.filter(e=>e.id!=null&&!isNaN(Number(e.id))).map(e=>({id:Number(e.id),permissions:z(e.permissions)})),ye=e=>{if(!e?.length)return[];let t=new Map;return e.forEach(e=>{let n=e.attributes?.link||e.href||e.link||``;if(!n)return;let r=D(n);!r||r===`invalid`||(t.has(r)||t.set(r,[]),t.get(r).push(n))}),Array.from(t.entries()).map(([e,t])=>({url:e,depth:t.length>1}))},V=(e,t,n)=>{let r=[...e||[],...t||[]],i=n||[],a=i.length>0?r.filter(e=>!i.some(t=>Number(t.id)===Number(e.id))):r,o=new Set(a.map(e=>e.attributes?.channel?.toLowerCase()).filter(Boolean));return{hasAny:a.length>0,isShopifyOnly:o.size===1&&o.has(`shopify`),isWordPressOnly:o.size===1&&o.has(`wordpress`)}},H=e=>e.toLowerCase()===`shopify`,U=e=>e.toLowerCase()===`wordpress`,W=(e,t=!1)=>{let n=H(e);return t?n?`Store`:`Website`:n?`store`:`website`},be=e=>H(e)?`Shopify store`:`WordPress website`,G=(e,t)=>H(e)?T.filter(e=>e.platforms.includes(`shopify`)):t?T.filter(e=>e.platforms.includes(`wordpress`)):T.filter(e=>e.id===`pages`||e.id===`posts`),K=(e,t)=>G(e,t).map(e=>e.id),xe=`data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M22%2012C22%206.49%2017.51%202%2012%202C6.48%202%202%206.49%202%2012C2%2017.52%206.48%2022%2012%2022C17.51%2022%2022%2017.52%2022%2012ZM9.78%2017.37L6.37%208.22C6.92%208.2%207.54%208.14%207.54%208.14C8.04%208.08%207.98%207.01%207.48%207.03C7.48%207.03%206.03%207.14%205.11%207.14C4.93%207.14%204.74%207.14%204.53%207.13C6.12%204.69%208.87%203.11%2012%203.11C14.33%203.11%2016.45%203.98%2018.05%205.45C17.37%205.34%2016.4%205.84%2016.4%207.03C16.4%207.77%2016.85%208.39%2017.3%2
109.13C17.65%209.74%2017.85%2010.49%2017.85%2011.59C17.85%2013.08%2016.45%2016.59%2016.45%2016.59L13.42%208.22C13.96%208.2%2014.24%208.05%2014.24%208.05C14.74%208%2014.68%206.8%2014.18%206.83C14.18%206.83%2012.74%206.95%2011.8%206.95C10.93%206.95%209.47%206.83%209.47%206.83C8.97%206.8%208.91%208.03%209.41%208.05L10.33%208.13L11.59%2011.54L9.78%2017.37ZM19.41%2012C19.65%2011.36%2020.15%2010.13%2019.84%207.75C20.54%209.04%2020.89%2010.46%2020.89%2012C20.89%2015.29%2019.16%2018.24%2016.49%2019.78C17.46%2017.19%2018.43%2014.58%2019.41%2012ZM8.1%2020.09C5.12%2018.65%203.11%2015.53%203.11%2012C3.11%2010.7%203.34%209.52%203.83%208.41C5.25%2012.3%206.67%2016.2%208.1%2020.09ZM12.13%2013.46L14.71%2020.44C13.85%2020.73%2012.95%2020.89%2012%2020.89C11.21%2020.89%2010.43%2020.78%209.71%2020.56C10.52%2018.18%2011.33%2015.82%2012.13%2013.46Z'%20fill='%233858E9'/%3e%3c/svg%3e`,q={key:0,src:I,alt:``,"aria-hidden":`true`},J={key:1,src:xe,alt:``,"aria-hidden":`true`},Se=d({__name:`PlatformIcon`,props:{platform:{}},setup(e){let t=e,n=l(()=>H(t.platform));return(e,t)=>n.value?(h(),o(`img`,q)):(h(),o(`img`,J))}}),Ce={class:`border rounded-lg transition-colors border-primary bg-main100`},we={class:`flex items-start gap-2 py-3 px-4`},Y={class:`text-grey900 grow min-w-0`},Te={class:`text-sm font-semibold truncate`},Ee={class:`text-xs text-grey900 mt-0.5`},De={class:`w-83.5`},Oe={key:0,class:`border-t border-grey200 px-4 pb-3`},ke=[`aria-expanded`,`aria-label`],Ae={key:0,class:`absolute top-full mt-1 z-10 w-full bg-white rounded-md overflow-hidden shadow-[4px_0px_16px_0px_rgba(43,43,62,0.16)]`},je={role:`listbox`,tabindex:`-1`,class:`py-1 overflow-auto text-base rounded-md shadow-xs max-h-60 focus:outline-hidden`},X=[`onClick`,`aria-selected`,`aria-disabled`],Me={key:0,class:`absolute inset-y-0 right-0 flex items-center pr-4`},Ne={key:0,class:`mt-2 flex flex-wrap items-center gap-2`},Z={class:`text-xs text-grey900`},Pe=[`onClick`,`aria-label`],Fe=d({__name:`SiteAccessCard`,props:{site:{},showToggle:{type:Boolean,default:!0}},emits:[`update:site`],setup(n,{emit:a}){let d=k(),f=n,p=a,m=u(!1),g=u(null),S=l(()=>H(f.site.platform)),w=l(()=>G(f.site.platform,f.site.is_woocommerce_installed));A(g,()=>{m.value=!1});let E=e=>{p(`update:site`,{...f.site,...e})},D=e=>{E(e?{enabled:e,permissions:w.value.map(e=>e.id)}:{enabled:e})},O=e=>f.site.enabled&&f.site.permissions?.includes(e)&&f.site.permissions.length===1,ee=e=>{let t=[...f.site.permissions||[]],n=t.indexOf(e);if(n===-1)t.push(e);else{if(f.site.enabled&&t.length===1)return;t.splice(n,1)}E({permissions:t})},te=e=>{let t=[...f.site.permissions||[]],n=t.indexOf(e);if(n!==-1){if(f.site.enabled&&t.length===1)return;t.splice(n,1),E({permissions:t})}};return(n,a)=>{let l=x(`PlatformIcon`),u=x(`VDropdown`),f=x(`CwIcon`);return h(),o(`div`,Ce,[b(`div`,we,[r(l,{platform:n.site.platform,class:`w-5 h-5 mt-0.5 shrink-0`},null,8,[`platform`]),b(`div`,Y,[b(`div`,Te,`Allow access to `+i(s(W)(n.site.platform))+` data - `+i(n.site.url),1),b(`div`,Ee,` Let AI securely fetch `+i(S.value?`published resources, product, order, and cart details`:`public pages, products, customer order, and cart details`)+` when users ask without storing or learning from your data `,1)]),n.showToggle?(h(),o(C,{key:0},[s(d).isProUserOrTrial?(h(),e(F,{key:1,"model-value":n.site.enabled,"onUpdate:modelValue":D,size:`sm`,class:`shrink-0 mt-0.5`,"aria-label":`Allow access to ${n.site.name||n.site.url}`},null,8,[`model-value`,`aria-label`])):(h(),e(u,{key:0,theme:`chatway-upgradenow`,triggers:[`click`],placement:`left`,class:`shrink-0 mt-0.5 inline-flex`},{popper:_(()=>[b(`div`,De,[r(ce)])]),default:_(()=>[a[1]||=b(`button`,{type:`button`,class:`inline-flex cursor-pointer appearance-none bg-transparent p-0 h-auto border-none m-0`,"aria-label":`Upgrade to Pro`},[b(`img`,{src:`data:image/svg+xml,%3csvg%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M18.3281%206.12599L18.3305%206.12796C18.4384%206.21694%2018.5193%206.33432%2018.564%206.46685C18.6088%206.59938%2018.6156%206.74178%2018.5836%206.87796L16.5915%2015.3385L16.5915%2015.3385L16.5902%2015.3443C16.5686%2015.4412%2016.5271%2015.5326%2016.4685%2015.6127L16.8718%2015.9082L16.4685%2015.6127C16.4098%2015.6927%2016.3351%2015.7598%2016.2492%2015.8096L16.2484%2015.8101C16.0686%2015.9148%2015.8547%2015.9443%2015.6533%2015.8921C11.9501%2014.8689%208.03869%2014.8692%204.33559%2015.893L4.33558%2015.893L4.32974%2015.8947C4.26827%2015.9125%204.20462%2015.9216%204.14064%2015.9218C4.00271%2015.9215%203.86743%2015.884%203.74908%2015.8131L3.74667%2015.8117C3.66018%2015.7606%203.58497%2015.6924%203.5256%2015.6114C3.46622%2015.5304%203.42392%2015.4381%203.40125%2015.3403L3.40094%2015.3389L1.41656%206.87798L1.41626%206.87671C1.38395%206.74056%201.39038%206.5981%201.4348%206.46541C1.47923%206.33273%201.55989%206.21512%201.66766%206.12588C1.77543%206.03664%201.90602%205.97932%202.04466%205.96042C2.1833%205.94151%202.32447%205.96177%202.4522%206.01889L2.45318%206.01933L6.4063%207.77714L6.82462%207.96315L7.04669%207.56282L9.34219%203.42468C9.40829%203.30905%209.50371%203.21287%209.61884%203.14585L9.3673%202.71373L9.61884%203.14585C9.7346%203.07847%209.86614%203.04297%2010.0001%203.04297C10.134%203.04297%2010.2656%203.07847%2010.3813%203.14585C10.4965%203.21287%2010.5919%203.30905%2010.658%203.42468L12.9535%207.56282L13.1755%207.96315L13.5939%207.77714L17.547%206.01933L17.5486%206.01862C17.6755%205.96165%2017.8159%205.94151%2017.9537%205.96049C18.0916%205.97948%2018.2213%206.03682%2018.3281%206.12599Z'%20fill='%23FFB800'%20stroke='%23FFB800'/%3e%3cmask%20id='mask0_9616_42288'%20style='mask-type:alpha'%20maskUnits='userSpaceOnUse'%20x='0'%20y='2'%20width='20'%20height='15'%3e%3cpath%20d='M18.332%206.08302L18.3344%206.085C18.4423%206.17397%2018.5232%206.29135%2018.568%206.42388C18.6127%206.55642%2018.6195%206.69882%2018.5875%206.835L16.5954%2015.2955L16.5954%2015.2955L16.5941%2015.3013C16.5725%2015.3982%2016.531%2015.4896%2016.4724%2015.5697C16.4137%2015.6498%2016.339%2015.7168%2016.2532%2015.7667L16.2523%2
1015.7671C16.0725%2015.8719%2015.8586%2015.9013%2015.6572%2015.8491C11.954%2014.8259%208.04259%2014.8263%204.3395%2015.8501L4.33949%2015.85L4.33364%2015.8517C4.27218%2015.8695%204.20853%2015.8787%204.14454%2015.8789C4.00662%2015.8786%203.87133%2015.841%203.75299%2015.7702L3.75057%2015.7687C3.66409%2015.7176%203.58888%2015.6495%203.5295%2015.5684C3.47013%2015.4874%203.42783%2015.3952%203.40516%2015.2973L3.40484%2015.2959L1.42047%206.83501L1.42017%206.83374C1.38786%206.69759%201.39428%206.55513%201.43871%206.42244C1.48314%206.28976%201.56379%206.17215%201.67157%206.08291C1.77934%205.99367%201.90993%205.93635%202.04857%205.91745C2.18721%205.89854%202.32837%205.9188%202.4561%205.97593L2.45709%205.97636L6.41021%207.73417L6.82853%207.92018L7.0506%207.51985L9.34609%203.38171C9.41219%203.26608%209.50762%203.1699%209.62275%203.10288C9.7385%203.0355%209.87005%203%2010.004%203C10.1379%203%2010.2695%203.0355%2010.3852%203.10288C10.5004%203.1699%2010.5958%203.26608%2010.6619%203.38171L12.9574%207.51985L13.1795%207.92018L13.5978%207.73417L17.5509%205.97637L17.5525%205.97566C17.6794%205.91868%2017.8198%205.89854%2017.9576%205.91752C18.0955%205.93651%2018.2252%205.99385%2018.332%206.08302Z'%20fill='%23FFB800'%20stroke='%23FFB800'/%3e%3c/mask%3e%3cg%20mask='url(%23mask0_9616_42288)'%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M13.9968%20-0.654127L12.7814%20-0.820312L7.89941%2022.7099L9.11479%2022.876L13.9968%20-0.654127ZM17.5603%204.17066L14.3624%203.7334L11.4011%2018.0067L14.599%2018.444L17.5603%204.17066Z'%20fill='white'%20fill-opacity='0.5'/%3e%3c/g%3e%3c/svg%3e`,alt:``,class:`w-5 h-5`})],-1)]),_:1}))],64)):y(``,!0)]),n.site.enabled?(h(),o(`div`,Oe,[b(`div`,{class:`relative`,ref_key:`dropdownRef`,ref:g},[b(`button`,{type:`button`,onClick:a[0]||=e=>m.value=!m.value,"aria-expanded":m.value,"aria-haspopup":`listbox`,"aria-label":`Set permissions for ${n.site.name||n.site.url}`,class:`border flex items-center justify-between gap-2 py-1.5 px-2 mt-2.5 rounded-lg bg-white border-grey200 cursor-default w-full`},[a[2]||=b(`div`,{class:`text-[10px] whitespace-nowrap sm:text-sm text-grey900`},`Set permissions for data access`,-1),r(f,{name:`chevron-down`,class:c([`transition-transform duration-200`,{"rotate-180":m.value}]),"aria-hidden":`true`},null,8,[`class`])],8,ke),m.value?(h(),o(`div`,Ae,[b(`ul`,je,[(h(!0),o(C,null,v(w.value,e=>(h(),o(`li`,{key:e.id,onClick:t(t=>ee(e.id),[`prevent`]),role:`option`,"aria-selected":n.site.permissions?.includes(e.id),"aria-disabled":O(e.id),class:c([`relative py-2 pl-4 pr-9 m-0 cursor-default select-none hover:bg-grey100`,{"opacity-50 pointer-events-none":O(e.id)}])},[b(`span`,{class:c([`block text-sm font-normal text-grey900 truncate`,{"text-primary":n.site.permissions?.includes(e.id)}])},i(e.label),3),n.site.permissions?.includes(e.id)?(h(),o(`span`,Me,[r(f,{name:`check`,"stroke-width":`1`,class:`text-primary w-5 h-5`,"aria-hidden":`true`})])):y(``,!0)],10,X))),128))])])):y(``,!0)],512),n.site.permissions?.length?(h(),o(`div`,Ne,[(h(!0),o(C,null,v(n.site.permissions,e=>(h(),o(`div`,{key:e,class:`flex items-center gap-1 px-2 py-1 rounded-full bg-grey200`},[b(`div`,Z,i(s(T).find(t=>t.id===e)?.label||e),1),O(e)?y(``,!0):(h(),o(`button`,{key:0,type:`button`,onClick:t(t=>te(e),[`prevent`]),"aria-label":`Remove ${s(T).find(t=>t.id===e)?.label||e} permission`,class:`w-3 h-3 p-0! cursor-pointer bg-grey600 rounded-full flex items-center justify-center`},[r(f,{name:`close`,"stroke-width":`1`,class:`w-2 h-2 text-white`,"aria-hidden":`true`})],8,Pe))]))),128))])):y(``,!0)])):y(``,!0)])}}}),Ie={class:`flex justify-end items-center gap-4 border-t border-grey200 px-6 py-4`},Le=[`disabled`,`aria-label`],Re={key:1,class:`text-white text-base`},ze=d({__name:`SelectStoresModal`,props:{isOpen:{type:Boolean},sites:{},isSaving:{type:Boolean}},emits:[`close`,`save`],setup(t,{emit:n}){let r=t,a=n,s=k(),{height:d}=ae(),f=u(r.sites.map(e=>({...e}))),p=u(null),{height:m}=ie(p),g=l(()=>s.isProUserOrTrial),S=l(()=>r.isSaving?!0:f.value.some(e=>e.enabled&&e.permissions.length===0)),w=l(()=>f.value.some(e=>e.enabled&&e.platform===`wordpress`&&Number(e.wp_consent_agree)!==1)),T=l(()=>{let e=d.value*.6;return m.value>e-10?`overflow-y-auto`:`overflow-visible`}),E=(e,t)=>{f.value[e]=t},D=()=>{a(`close`)},O=()=>{a(`save`,f.value)};return(t,n)=>{let r=x(`Modal`);return t.isOpen?(h(),e(r,{key:0,headerTitle:`Select Stores and Websites`,closeModal:!1,onCloseModal:D,classes:`md:w-[540px]!`,showFooter:!1},{default:_(()=>[b(`div`,{class:c([`max-h-[60vh]`,T.value])},[b(`div`,{ref_key:`contentRef`,ref:p,class:`px-6 py-4 space-y-4`},[(h(!0),o(C,null,v(f.value,(t,n)=>(h(),e(Fe,{key:t.url,site:t,"onUpdate:site":e=>E(n,e)},null,8,[`site`,`onUpdate:site`]))),128))],512)],2),b(`div`,Ie,[b(`button`,{type:`button`,onClick:D,class:`flex justify-center items-center gap-2 rounded-lg bg-grey100 text-base text-grey900 w-[5.31rem] h-11.5`},`Cancel`),g.value?(h(),o(`button`,{key:1,type:`button`,onClick:O,disabled:S.value,"aria-label":t.isSaving?`Saving changes`:`Save changes`,class:`flex justify-center items-center gap-2 rounded-lg bg-grey900 text-base text-white w-auto min-w-25 px-4 h-11.5 disabled:opacity-50`},[t.isSaving?(h(),e(j,{key:0,size:`16px`,inline:``,class:`before:border-white!`})):(h(),o(`span`,Re,i(w.value?`Allow & Save`:`Save`),1))],8,Le)):(h(),e(P,{key:0,class:`rounded-lg! h-11.5! px-4! w-auto! text-base! capitalize`}))])]),_:1})):y(``,!0)}}}),Be=[`aria-expanded`],Ve={key:0,id:`common-questions-dropdown`,class:`absolute top-full left-0 mt-1 w-full max-w-[420px] bg-white border border-grey100 rounded-xl shadow-lg z-50 overflow-hidden`},He={class:`p-3 border-b border-grey100`},Ue={class:`flex items-center gap-0 px-3 py-0 border border-grey200 rounded-lg`},We={class:`max-h-72 overflow-y-auto py-1`,role:`listbox`},Ge=[`onClick`,`onKeydown`],Ke={key:0,class:`px-4 py-1.5 text-sm text-grey700 text-center`},qe=d({__name:`CommonQuestionsDropdown`,emits:[`select`],setup(e,{emit:a}){let s=a,c=u(!1),d=u(``),m=u(null),_=l(()=>{let e=d.value.trim().toLowerCase();return e?w.filter(t=>t.toLowerCase().includes(e)):w}),S=e=>{s(`select`,e),c.value=!1,d.value=``};return A(m,()=>{c.value=!1,d.value=``}),(e,a)=>{let s=x(`CwIcon`);return h(),o(`div`,{class:`relative`,ref_key:`dropdownRef`,ref:m},[b(`button`,{type:`button`,onMousedown:a[0]||=t(()=>{},[`prevent`]),onClick:a[1]||=e=>c.value=!c.value,"aria-expanded":c.value,"aria-controls":`common-questions-dropdown`,class:`inline-flex items-center gap-1.5 px-3 h-8 rounded-full text-sm text-grey900 transition-colors bg-[#282D3E0F]`},[r(s,{name:`plus-circle`,class:`w-4 h-4 text-grey600`}),a[4]||=n(` Add from common questions `)],40,Be),c.value?(h(),o(`div`,Ve,[b(`div`,He,[b(`div`,Ue,[r(s,{name:`search`,class:`w-4 h-4 shrink-0 text-grey600`}),g(b(`input`,{"onUpdate:modelValue":a[2]||=e=>d.value=e,type:`text`,placeholder:`Search`,class:`flex-1 text-sm border-0 outline-none focus:ring-0 bg-transparent text-grey900 placeholder-grey400 pl-2`,onClick:a[3]||=t(()=>{},[`stop`])},null,512),[[p,d.value]])])]),b(`ul`,We,[(h(!0),o(C,null,v(_.value,e=>(h(),o(`li`,{key:e,onClick:t=>S(e),onKeydown:[f(t(t=>S(e),[`prevent`]),[`enter`]),f(t(t=>S(e),[`prevent`]),[`space`])],role:`option`,tabindex:`0`,class:`px-4 py-1.5 text-sm text-grey900 hover:bg-grey50 cursor-pointer focus:outline-none focus:bg-grey50`},i(e),41,Ge))),128)),_.value.length?y(``,!0):(h(),o(`li`,Ke,`No results`))])])):y(``,!0)],512)}}}),Je=d({__name:`RemoveQAPopup`,emits:[`remove`],setup(e,{emit:t}){let n=t,i=u(!1),s=u(),l=u(),d=u(`bottom`),f=e=>{let t=e.parentElement;for(;t;){let e=window.getComputedStyle(t),n=e.overflowY,r=e.overflowX;if(/(auto|scroll|hidden)/.test(`${n} ${r}`))return{rect:t.getBoundingClientRect(),el:t};t=t.parentElement}let n=e.closest(`.modal-container`);return n?{rect:n.getBoundingClientRect(),el:n}:{rect:{top:0,bottom:window.innerHeight},el:null}},p=async()=>{await a();let e=s.value,t=l.value;if(!e||!t)return;let n=e.getBoundingClientRect(),{rect:r}=f(e),i=t.getBoundingClientRect(),o=r.bottom-n.bottom,c=n.top-r.top,u=o>=i.height+8,p=c>=i.height+8;if(u){d.value=`bottom`;return}if(p){d.value=`top`;return}d.value=c>o?`top`:`bottom`},m=async()=>{i.value=!i.value,i.value&&(d.value=`bottom`,await p())},g=()=>{n(`remove`),i.value=!1};return A(s,()=>{i.value=!1}),S(i,e=>{e&&p()}),(e,t)=>{let n=x(`CwIcon`);return h(),o(`div`,{class:`relative shrink-0`,ref_key:`removeLinkPopupRef`,ref:s},[b(`button`,{onClick:m,class:`p-1`},[r(n,{name:`trash`,"stroke-width":`1.5`,class:`w-4 h-4 text-negative100`,"aria-label":`trash`}),t[0]||=b(`span`,{class:`sr-only`},`Remove`,-1)]),i.value?(h(),o(`div`,{key:0,ref_key:`popupRef`,ref:l,class:c([`absolute right-0 z-50 p-3 w-[230px] rounded-lg bg-white shadow-[0px_4px_8px_-4.875px_rgba(40,45,62,0.24)]`,d.value===`top`?`bottom-full mb-2`:`top-full mt-2`])},[t[1]||=b(`div`,{class:`text-xs font-semibold mb-1`},`Remove this knowledge source?`,-1),t[2]||=b(`div`,{class:`text-xs mb-3`},`If you remove this title/question, the AI will no longer be able to learn from it.`,-1),b(`button`,{onClick:g,class:`w-full h-auto block px-4 py-1.5 bg-danger200 text-sm text-white`},`Remove now`)],2)):y(``,!0)],512)}}}),Ye={class:`flex items-center gap-2`},Xe={class:`text-sm text-grey900 line-clamp-3`},Ze={class:`flex items-center gap-1 shrink-0`},Qe={key:2,class:`text-xs bg-grey900/6 rounded-full py-1 pl-0.5 pr-[7px] inline-flex items-center gap-1`},$e={key:0,class:`bg-grey200/40 rounded-b-lg divide-y divide-grey200`},et=[`innerHTML`],tt=d({__name:`QuestionAnswerDisclosure`,props:{content:{},isOnboarding:{type:Boolean}},emits:[`edit`,`delete`],setup(t,{emit:a}){let l=a,d=u(!1);return(t,a)=>{let u=x(`CwIcon`),f=x(`Loader`);return h(),o(C,null,[b(`div`,{class:c([`flex items-center justify-between bg-grey200/50 px-4 py-2.5 mt-2`,d.value?`sticky top-0 rounded-t-lg border-b border-grey200 `:`rounded-lg`])},[b(`div`,Ye,[b(`button`,{onClick:a[0]||=e=>d.value=!d.value,class:`flex items-center gap-1 p-0 shrink-0`},[r(u,{name:`chevron-down`,class:c([`w-5 h-5 transition text-grey600`,d.value?`-rotate-90`:``]),"aria-label":`chevron-down`},null,8,[`class`])]),b(`div`,Xe,i(t.content.question),1)]),b(`div`,Ze,[t.content.is_temp||t.isOnboarding?(h(),o(`button`,{key:0,onClick:a[1]||=e=>l(`edit`),class:`p-1`},[r(u,{name:`edit-3`,class:`w-4 h-4 text-grey600`,"aria-label":`edit`})])):y(``,!0),t.content.is_processing?y(``,!0):(h(),e(Je,{key:1,onRemove:a[2]||=e=>l(`delete`)})),t.content.is_processing?(h(),o(`div`,Qe,[r(f,{class:`before:border-primary! before:border-2! m-0!`,size:`16px`}),a[3]||=n(` Processing... `)])):y(``,!0)])],2),d.value?(h(),o(`div`,$e,[b(`div`,{innerHTML:s(N)(t.content.answer),class:`text-sm text-grey900 p-3 prose`},null,8,et)])):y(``,!0)],64)}}}),nt={class:`h-[calc(100vh-300px)] xl:h-auto xl:flex divide-y xl:divide-x overflow-y-auto xl:overflow-auto`},rt={class:`w-full xl:w-2xl xl:h-[calc(100vh-300px)] xl:overflow-hidden xl:flex xl:flex-col p-6`},it={class:`mb-3`},at={class:`mb-3`},ot={class:`flex-1 min-h-0 editor-fill-wrapper`},st={class:`flex justify-end mt-3`},ct={class:`w-full xl:w-175.5 xl:h-[calc(100vh-300px)] xl:overflow-y-auto p-6`},lt={key:0,class:`flex items-center p-4 mb-4 text-yellow-800 rounded-lg bg-yellow-50`,role:`alert`},ut={class:`ms-3 text-sm font-medium`},dt={key:1},ft={class:`mb-2`},pt={class:`text-sm text-grey900`},mt={key:2,class:`grid place-content-center h-full mt-4 sm:mt-8 xl:mt-0`},ht={class:`flex flex-col sm:flex-row items-center justify-between gap-4 border-t px-6 py-4`},gt={class:`flex justify-center items-center gap-1 w-full sm:w-auto`},_t={type:`button`,class:`flex items-center justify-center p-0 h-auto`,"aria-label":`CSV upload information`},vt={class:`max-w-64 text-left`},yt=[`href`],bt={key:0,class:`flex items-center gap-4 w-full sm:w-auto`},xt=[`disabled`],St={key:1,class:`flex items-center justify-end gap-4 w-full sm:w-auto`},Ct=[`disabled`],Q=1e3,$=2500,wt=se(d({__name:`AddContentModal`,props:{isOpen:{type:Boolean},showSaveButton:{type:Boolean},isOnboarding:{type:Boolean}},emits:[`close`,`previous`,`next`],setup(t,{emit:c}
1){let d=t,f=c,p=ee(),g=te(),w=re(),{newQAs:T}=m(g),{getQAs:D,getMatrix:k,getExistingResources:ie}=he(),{activateAssistant:ae}=pe(),{files:A,open:se,reset:ce}=oe({accept:`.csv`}),j=u(null),N=u(``),P=u(``),F=u(null),I=u(null),L=u(!1),R=u(),z=de({question:{required:M.withMessage(`Please add question`,fe),maxLength:ue(255)},answer:{required:M.withMessage(`Please add answer`,fe),maxLength:M.withMessage(`The maximum length allowed is 1000 characters`,ue(1e3))}},{question:N,answer:P},{$scope:!1,$stopPropagation:!0}),B=l(()=>T.value.filter(e=>e.is_temp).length),ye=l(()=>d.isOnboarding?0:g.qaPagination.total),V=l(()=>ye.value+B.value),H=l(()=>Math.max(0,Q-B.value)),U=l(()=>Math.max(0,$-V.value)),W=l(()=>Math.min(H.value,U.value)),be=l(()=>B.value>=Q),G=l(()=>V.value>=$),K=l(()=>be.value||G.value),xe=l(()=>B.value>Q||V.value>$),q=l(()=>U.value<=H.value?{count:$,type:`total`}:{count:Q,type:`batch`}),J=l(()=>K.value?`You've reached the ${q.value.count.toLocaleString()}-Q&A ${q.value.type} limit.`:`You have ${W.value} Q&As remaining out of the ${q.value.count.toLocaleString()}-Q&A ${q.value.type} limit.`),Se=l(()=>V.value>0&&W.value<=50),Ce=l(()=>T.value.some(e=>e.is_csv_imported)),we=l(()=>xe.value||L.value||T.value.length===0&&(!N.value||!P.value)),Y=()=>!F.value&&K.value?(w.set({message:J.value,type:`error`,time:4e3}),!1):(z.value.$touch(),z.value.$invalid?!1:(F.value?T.value[I.value]={...F.value,question:N.value,answer:P.value,is_processing:!1,is_temp:!0}:T.value.push({id:ne(),question:N.value,answer:P.value,is_processing:!1,is_temp:!0}),I.value=null,F.value=null,N.value=``,P.value=``,z.value.$reset(),!0)),Te=async()=>{if(d.isOnboarding)return N.value&&P.value&&!Y()?!1:(N.value=``,P.value=``,F.value=null,I.value=null,Ne(),!0);if(!p.selectedAssistant?.id||xe.value||N.value&&P.value&&!Y())return!1;L.value=!0;try{let e=T.value.filter(e=>e.is_temp).map(e=>({question:e.question,answer:e.answer}));if(!e.length)return Z(),!0;let{data:t}=await new me().addQAs(p.selectedAssistant.id,{data:e});return t.length&&(ae(),await D()),T.value=[],I.value=null,F.value=null,N.value=``,P.value=``,z.value.$reset(),Z(),k(),ie(),w.set({message:`Your knowledge sources have been added and are now being processed.`,type:`success`}),!0}catch(e){E(e),console.log(e)}finally{L.value=!1}return!1},Ee=(e,t)=>{F.value=e,I.value=t,N.value=e.question,P.value=e.answer},De=(e,t)=>{if(!e.is_processing&&(T.value.splice(t,1),!(e.is_temp||d.isOnboarding)))try{new me().bulkActions(p.selectedAssistant.id,{remove_qas:[e.id]}),g.questionAnswers=g.questionAnswers.filter(t=>t.id!==e.id),--g.qaPagination.total}catch(t){T.value.push(e),E(t),console.log(t)}},Oe=e=>{let t=[],n=[],r=``,i=!1;for(let a=0;a<e.length;a++){let o=e[a],s=e[a+1];o===`"`?i&&s===`"`?(r+=`"`,a++):i=!i:o===`,`&&!i?(n.push(r),r=``):(o===` 2`||o===`\r`)&&!i?(o===`\r`&&s===` 3`&&a++,n.push(r),n.some(e=>e.trim())&&t.push(n),n=[],r=``):r+=o}return n.push(r),n.some(e=>e.trim())&&t.push(n),t},ke=e=>{try{if(!e.trim()){w.set({message:`The Q&A CSV file is empty`,type:`error`});return}let[t,...n]=Oe(e),r=t?.map(e=>e.replace(/^\uFEFF/,``).trim().toLowerCase()),i=r?.findIndex(e=>e===`question`||e===`questions`)??-1,a=r?.findIndex(e=>e===`answer`||e===`answers`)??-1;if(i===-1||a===-1){w.set({message:`CSV must include one Question column and one Answer column`,type:`error`});return}let o=n.map(e=>({question:e[i]?.trim()||``,answer:e[a]?.trim()||``})).filter(e=>e.question&&e.answer);if(!o.length){w.set({message:`No valid Q&A rows found in the CSV file`,type:`error`});return}let s=new Set(T.value.map(e=>`${e.question.trim().toLowerCase()}\u0000${e.answer.trim().toLowerCase()}`)),c=0,l=o.filter(e=>{let t=`${e.question.toLowerCase()}\u0000${e.answer.toLowerCase()}`;return s.has(t)?(c++,!1):(s.add(t),!0)}),u=W.value,d=`${q.value.count.toLocaleString()}-Q&A ${q.value.type} limit`,f=l.slice(0,u).map(e=>({...e,id:ne(),is_processing:!1,is_temp:!0,is_csv_imported:!0})),p=l.length-f.length;T.value=T.value.concat(f);let m=[`Added ${f.length}`];c&&m.push(`skipped ${c} duplicate${c===1?``:`s`}`),p&&m.push(`skipped ${p} due to the ${d}`),w.set({message:`${m.join(`, `)}.`,type:f.length?`success`:`error`,time:4e3})}catch(e){w.set({message:`Unable to process the Q&A CSV file`,type:`error`}),console.error(e)}},Ae=e=>{if(K.value){w.set({message:J.value,type:`error`});return}let t=e?.[0];if(t){if(t.type!==`text/csv`&&!t.name.toLowerCase().endsWith(`.csv`)){w.set({message:`Please upload a CSV file`,type:`error`});return}try{let e=new FileReader;e.onerror=()=>{w.set({message:`Unable to read the Q&A CSV file`,type:`error`})},e.onload=e=>{let t=e.target?.result;if(typeof t!=`string`){w.set({message:`Unable to read the Q&A CSV file`,type:`error`});return}ke(t)},e.readAsText(t)}catch(e){w.set({message:`Unable to upload the Q&A CSV file`,type:`error`}),console.error(e)}finally{ce()}}},je=()=>{T.value=T.value.filter(e=>!e.is_csv_imported)},X=e=>{if(!Ce.value){e();return}R.value?.show({hideModal:()=>{je(),e()}})},Me=()=>{X(()=>f(`next`))},Ne=()=>{z.value.$reset(),f(`close`)},Z=()=>{X(Ne)},Pe=()=>{X(()=>f(`previous`))},Fe=async()=>{N.value&&P.value&&!Y()||(T.value.length>0?await Te()&&f(`next`):T.value.length==0&&f(`next`))};return S(A,e=>{Ae(e)}),S(()=>d.isOpen,e=>{e&&a(()=>j.value?.focus())}),S(()=>d.showSaveButton,e=>{e&&(T.value=[])},{immediate:!0}),(t,a)=>{let c=x(`CwIcon`),l=x(`Loader`),u=x(`Modal`);return h(),o(C,null,[t.isOpen?(h(),e(u,{key:0,headerTitle:`Add your content`,closeModal:!1,onCloseModal:Z,classes:`md:w-[1375px]!`,showFooter:!1},{default:_(()=>[b(`div`,null,[b(`div`,nt,[b(`div`,rt,[a[5]||=b(`label`,{for:`title`,class:`block text-sm text-grey600 mb-1`},`Title/Question`,-1),b(`div`,it,[r(ge,{ref_key:`questionInputRef`,ref:j,value:N.value,onInput:a[0]||=e=>N.value=e,hasError:s(z).question.$error,validationMessage:s(z).question.$errors,type:`text`,forValue:`title`,placeholder:`Add the text title`},null,8,[`value`,`hasError`,`validationMessage`])]),b(`div`,at,[r(qe,{onSelect:a[1]||=e=>(N.value=e,s(z).question.$reset())})]),b(`div`,ot,[r(_e,{"md-content":P.value,"onUpdate:mdContent":[a[2]||=e=>P.value=e,a[3]||=e=>P.value.length&&s(z).answer.$touch()],hasError:s(z).answer.$error,validationMessage:s(z).answer.$errors,showImageUpload:!1,placeholder:`Your text/answer`,height:`auto`},null,8,[`md-content`,`hasError`,`validationMessage`])]),b(`div`,st,[b(`button`,{onClick:Y,type:`button`,class:`h-10 px-5 py-2.5 rounded-lg bg-main100 text-primary text-base`},i(F.value?`Update`:`Add Another Question`),1)])]),b(`div`,ct,[Se.value?(h(),o(`div`,lt,[r(c,{name:`info`,class:`shrink-0 w-4 h-4 text-yellow-800`,"aria-hidden":`true`}),b(`div`,ut,i(J.value),1)])):y(``,!0),s(T).length?(h(),o(`div`,dt,[b(`div`,ft,[b(`div`,pt,[a[6]||=b(`strong`,null,`Added Texts:`,-1),n(` (`+i(s(T).length)+`) `,1)])]),(h(!0),o(C,null,v(s(T),(e,t)=>(h(),o(`div`,{key:t},[r(tt,{content:e,onEdit:n=>Ee(e,t),onDelete:n=>De(e,t)},null,8,[`content`,`onEdit`,`onDelete`])]))),128))])):(h(),o(`div`,mt,a[7]||=[b(`div`,{class:`flex flex-col items-center text-center`},[b(`div`,{class:`w-18 h-18 flex items-center justify-center bg-grey100 rounded-full mb-2`}
3,[b(`img`,{src:`/assets/note-BwPI308a.png`,alt:`Note`,class:`w-10 h-10`})]),b(`div`,{class:`max-w-109.5 text-grey600 text-sm leading-lh400`},` Insert text/Q&A as an AI knowledge source for the AI to learn from in order to answer your users' questions. Points, bullets, links, code blocks, tables, and quotes can all be included. `)],-1)]))])]),b(`div`,ht,[b(`div`,gt,[b(`button`,{type:`button`,onClick:a[4]||=e=>s(se)(),class:`flex justify-center items-center gap-1 text-base text-grey900`},[r(c,{name:`upload`,class:`cursor-pointer w-4 h-4`,"aria-label":`upload`}),a[8]||=n(` Upload CSV `)]),r(le,{triggers:[`hover`,`click`],popperTriggers:[`hover`],delay:{show:0,hide:300}},{content:_(()=>[b(`div`,vt,[a[10]||=b(`div`,{class:`p-3 pb-0 text-sm`},`CSV must include one Question column and one Answer column`,-1),b(`a`,{href:`${s(O)}templates/Knowledge_Sources_Q%26A_Chatway.csv`,download:`Knowledge_Sources_Q&A_Chatway.csv`,class:`flex w-full items-center gap-2 rounded-b-lg px-5 pt-2 pb-4 text-sm font-normal leading-5 text-primary focus-visible:bg-main100 focus-visible:outline-hidden`},[r(c,{name:`download`,"stroke-width":1.5,class:`h-4 w-4 shrink-0 text-primary`,"aria-hidden":`true`}),a[9]||=n(` Download template `)],8,yt)])]),default:_(()=>[b(`button`,_t,[r(c,{name:`info`,class:`text-grey600`,"aria-hidden":`true`})])]),_:1})]),t.showSaveButton||t.isOnboarding?(h(),o(`div`,bt,[b(`button`,{type:`button`,onClick:Z,class:`inline-flex justify-center rounded-lg bg-grey100 text-base text-grey900 flex-1 sm:flex-none sm:w-30 h-12`},`Cancel`),b(`button`,{type:`button`,onClick:Te,disabled:we.value,class:`flex justify-center rounded-lg bg-grey900 text-base text-white flex-1 sm:flex-none sm:w-30 h-12 disabled:bg-grey900! disabled:opacity-50!`},[L.value?(h(),e(l,{key:0,size:`16px`,class:`before:border-white! m-2!`})):y(``,!0),a[11]||=n(` Save `)],8,xt)])):(h(),o(`div`,St,[b(`button`,{type:`button`,onClick:Me,class:`flex justify-center gap-1 pr-0 text-base text-primary focus-visible:text-primaryDark hover:text-primaryDark`},[a[12]||=n(` Skip `),r(c,{name:`chevron-right`,class:`cursor-pointer text-primary`,"aria-hidden":`true`})]),b(`button`,{type:`button`,onClick:Pe,class:`flex justify-center gap-2 rounded-lg bg-grey100 text-base text-grey900 w-30 h-12`},[r(c,{name:`chevron-left`,class:`text-grey600`,"aria-label":`chevron left`}),a[13]||=n(` Back `)]),b(`button`,{type:`button`,onClick:Fe,disabled:L.value,class:`flex justify-center gap-2 rounded-lg bg-grey900 text-base text-white w-30 h-12 disabled:bg-grey900 disabled:opacity-50`},[L.value?(h(),e(l,{key:0,size:`20px`,class:`before:border-white!`})):y(``,!0),a[14]||=n(` Next `),r(c,{name:`chevron-right`,class:`text-white w-5 h-5`,"aria-label":`chevron right`})],8,Ct)]))])])]),_:1})):y(``,!0),r(ve,{ref_key:`unsavedConfirmationRef`,ref:R},null,512)],64)}}}),[[`__scopeId`,`data-v-c616fc2f`]]);export{Fe as a,V as c,W as d,be as f,U as h,ze as i,K as l,H as m,tt as n,Se as o,ye as p,qe as r,B as s,wt as t,R as u}; 4//# sourceMappingURL=AddContentModal-RvkpZoyt.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.