@bikdotai/bik-component-library 0.0.694 → 0.0.695
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/cjs/components/data-source-panel/DataSourcePanel.d.ts +7 -0
- package/dist/cjs/components/data-source-panel/DataSourcePanel.js +1 -1
- package/dist/esm/components/data-source-panel/DataSourcePanel.d.ts +7 -0
- package/dist/esm/components/data-source-panel/DataSourcePanel.js +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { ApplicationType } from '@bikdotai/bik-models/growth';
|
|
3
3
|
import { AllSourceInfoDetailsCustomDataModel, CustomDataType, DataSourcePanelZeroState, footerButtonOptionModel, InfoContent, MessageSource, ProductSourceData } from './model';
|
|
4
|
+
export interface ProductSearchRuleDB {
|
|
5
|
+
rule_id?: string;
|
|
6
|
+
rule_name: string;
|
|
7
|
+
keywords: string[];
|
|
8
|
+
}
|
|
4
9
|
export interface CollapsibleSectionProps {
|
|
5
10
|
title: string;
|
|
6
11
|
count: number;
|
|
@@ -32,5 +37,7 @@ export interface DataSourcePanelProps {
|
|
|
32
37
|
productSourceData?: ProductSourceData;
|
|
33
38
|
reasonForAiGeneratedResponse?: string;
|
|
34
39
|
showAiResponseReason?: boolean;
|
|
40
|
+
productSearchRule?: ProductSearchRuleDB;
|
|
41
|
+
onEditProductSearchRule?: (ruleId: string) => void;
|
|
35
42
|
}
|
|
36
43
|
export declare const DataSourcePanel: React.FC<DataSourcePanelProps>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../node_modules/react/jsx-runtime.js"),t=require("@bikdotai/bik-models/growth"),s=require("../../assets/icons/boxV2.svg.js"),i=require("../../assets/icons/chevronDownOutline.svg.js"),o=require("../../assets/icons/chevronUpOutline.svg.js"),n=require("../../assets/icons/cross.svg.js"),r=require("../../assets/icons/edit.svg.js"),l=require("../../assets/icons/filePdf.svg.js"),a=require("../../assets/icons/help.svg.js"),d=require("../../assets/icons/info.svg.js"),c=require("../../assets/icons/openai.svg.js"),u=require("../../assets/icons/plus.svg.js"),x=require("../../assets/icons/redirect.svg.js"),p=require("../../assets/icons/text_t9.svg.js"),j=require("../../assets/icons/website.svg.js"),m=require("react"),g=require("../../constants/Theme.js"),h=require("../button/Button.js"),E=require("../icon-button/IconButton.js"),C=require("../shimmer/ShimmerComponent/BikShimmer.js"),y=require("../side-modal/SideModal.js"),R=require("../tag/Tag.js"),O=require("../tooltips/Tooltip.js"),f=require("../TypographyStyle.js"),v=require("./DataSourceInfoFooter.js"),S=require("./DataSourcePanel.style.js"),T=require("./IntentConfig.js"),I=require("./Modals/DescriptionModal.js"),b=require("./model.js");exports.DataSourcePanel=L=>{var w,D;const{appType:N,storeId:A,messageSource:F,setMessageSourcePanel:_,hideCloseButton:q,isSourceInfoFetched:B,allSourceInfoDetail:k,ChecklistType:P,title:M,zeroStateButton:U,editableSources:K,preFillTrainingSourceCount:W,redirect:H,footerButtonOption:$,fetchTrainingSourceCount:Q,fetchProductFAQCount:G,productSourceData:Y,reasonForAiGeneratedResponse:z,showAiResponseReason:X}=L,{sources:V}=F,J=["blog","article","page","policy"],[Z,ee]=m.useState(!1),[te,se]=m.useState(!1),[ie,oe]=m.useState(!1),[ne,re]=m.useState(0),[le,ae]=m.useState(),[de,ce]=m.useState(null!=W?W:{}),[ue,xe]=m.useState(!1),[pe,je]=m.useState(!1),me={};T.intentConfig.forEach((t=>{let{key:s,type:i,tagText:o}=t;P[s]&&(me[P[s]]=e.jsxRuntimeExports.jsx(R.Tag,{theme:"light",type:i,tagText:o,cursor:"pointer"}))}));const ge=V.filter((e=>"PRODUCTS"==e.type||"Products"==e.subTitle||e.productId)),he=V.filter((e=>"PRODUCTS"!=e.type&&"Products"!=e.subTitle&&!e.productId)),Ee=m.useMemo((()=>{const e={};return["STORE_INFORMATION","CONTACT_INFO","STORE_LOCATION","SHIPPING_POLICY","RETURN_AND_REFUND","SALES_AND_OFFERS","SALES_AND_OFFERS_ISSUES","PRODUCT_CUSTOMISATION","PAYMENT_METHODS","CHECKOUT_ENQUIRY","ORDER_ENQUIRY"].forEach((t=>{P[t]&&(e[P[t]]=P[t])})),["COLLABORATION","SUBSCRIPTION_ENQUIRY"].forEach((t=>{e[t]=t})),e}),[P]);m.useEffect((()=>{var e,t,s,i;if(!(null==F?void 0:F.messageId))return;ee(!0),se(!0),oe(!1!==(null===(t=null===(e=F.sources)||void 0===e?void 0:e[0])||void 0===t?void 0:t.isTrainable)||!!(null===(i=null===(s=F.sources)||void 0===s?void 0:s[0])||void 0===i?void 0:i.insights));const o=F.sources.filter((e=>!!e.productId)).map((e=>e.productId)),n=Array.from(new Set(o)).filter((e=>!!e));G(A,n).then((e=>re(e))).then((()=>{W?(ce(W),setTimeout((()=>{ee(!1),se(!1)}),100)):(setTimeout((()=>ee(!1)),100),Q(A).then((e=>ce(e))).then((()=>setTimeout((()=>{se(!1)}),100))))}))}),[G,Q,null==F?void 0:F.messageId,F.sources,W,A]);const Ce=e=>!!(e&&0===e.length||(null==F?void 0:F.isUnsatisfactoryAnswer)),ye=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];var s;return"custom"==e?e=b.CustomDataType.FILES:J.includes(e)?e=b.CustomDataType.FETCHED_LINKS:"url"==e?e=b.CustomDataType.WEBSITE_LINKS:"text"===e?e=b.CustomDataType.TEXTS:"faq"===e&&(e=b.CustomDataType.FAQ),t?e:null===(s=null==e?void 0:e.toLowerCase())||void 0===s?void 0:s.replace(/_/g," ")},Re=e=>e?"faq"==e.toLocaleLowerCase()?"FAQ":"openai"==e.toLocaleLowerCase()?"OPENAI":"files"==e.toLocaleLowerCase()?"PDF":"texts"==e.toLocaleLowerCase()?"Custom text":((e=(e=e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).replace("_"," ")).endsWith("s")&&(e=e.slice(0,-1)),e.replace("Website","Manual")):"",Oe=t=>"products"==t||"product"==t?e.jsxRuntimeExports.jsx(s.default,{height:16,width:16,color:g.COLORS.content.secondary}):"files"==t?e.jsxRuntimeExports.jsx(l.default,{height:16,width:16,color:g.COLORS.content.secondary}):"website links"==t||"fetched links"==t?e.jsxRuntimeExports.jsx(j.default,{height:16,width:16,color:g.COLORS.content.secondary}):"faq"==t?e.jsxRuntimeExports.jsx(a.default,{height:16,width:16,color:g.COLORS.content.secondary}):"texts"==t?e.jsxRuntimeExports.jsx(p.default,{height:16,width:16,color:g.COLORS.content.secondary}):e.jsxRuntimeExports.jsx(c.default,{height:16,width:16,color:g.COLORS.content.secondary}),fe=e=>{const t=e.replace(/(<([^>]+)>)/gi,""),s=document.createElement("textarea");return s.innerHTML=t,s.value};if(Z||!B)return e.jsxRuntimeExports.jsx(S.SourceInfoDetailsStyle,{children:e.jsxRuntimeExports.jsx(C.BikShimmer,{boxes:[{width:"100px",height:"16px"},{width:"0",height:"4px"},{width:"100%",height:"32px"},{width:"100%",height:"32px"},{width:"100%",height:"32px"},{width:"100%",height:"32px"},{width:"0",height:"4px"},{width:"100%",height:"16px"}]})});const ve=s=>{const{title:n,count:r,isExpanded:l,onToggle:a,children:d}=s;return e.jsxRuntimeExports.jsxs("div",{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 12px",cursor:"pointer"},onClick:a},{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",gap:"8px"}},{children:[e.jsxRuntimeExports.jsx(f.BodyCaption,Object.assign({style:{fontWeight:"600"}},{children:n})),N===t.ApplicationType.MANIFEST?e.jsxRuntimeExports.jsx("div",Object.assign({style:{backgroundColor:g.COLORS.surface.subdued,color:g.COLORS.content.secondary,padding:"2px 8px",borderRadius:"12px",fontSize:"12px",fontWeight:"500"}},{children:r})):e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{})]})),e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:N===t.ApplicationType.BIK?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{}):l?e.jsxRuntimeExports.jsx(i.default,{width:20,height:20,color:g.COLORS.content.primary}):e.jsxRuntimeExports.jsx(o.default,{width:20,height:20,color:g.COLORS.content.primary})})]})),l&&d]})};return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(S.SourceInfoDetailsStyle,{children:e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({className:"pop-up-header",style:{display:"flex",flexDirection:"column",paddingBottom:"12px"}},{children:[!!M&&e.jsxRuntimeExports.jsx(f.TitleSmall,{children:M}),e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",alignItems:"center"}},{children:[e.jsxRuntimeExports.jsx(f.BodyCaption,Object.assign({color:g.COLORS.content.secondary},{children:"Intent"})),null!==(w=me[F.intent])&&void 0!==w?w:me.GENERIC,!q&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{display:"flex",marginLeft:"auto",cursor:"pointer"},onClick:()=>_(void 0)},{children:e.jsxRuntimeExports.jsx(n.default,{height:20,width:20,color:g.COLORS.content.secondary})}))]})),Ce(V)?e.jsxRuntimeExports.jsx("div",Object.assign({style:{display:"flex",margin:"auto",justifyContent:"center",alignItems:"center",height:"calc(100vh - 300px)"}},{children:(()=>{var t,s;return e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",margin:"0px 30px",gap:"8px"}},{children:[e.jsxRuntimeExports.jsx("div",Object.assign({style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"12px",backgroundColor:`${g.COLORS.background.negative.light}`,borderRadius:"100px"}},{children:e.jsxRuntimeExports.jsx(d.default,{width:24,height:24,color:g.COLORS.stroke.negative.vibrant})})),e.jsxRuntimeExports.jsx("div",Object.assign({style:{justifyContent:"center",alignItems:"center",marginBottom:"-4px"}},{children:e.jsxRuntimeExports.jsx(f.TitleSmall,{children:"Insufficient data"})})),e.jsxRuntimeExports.jsx(f.BodySecondary,Object.assign({color:g.COLORS.content.secondary,style:{display:"flex",justifyContent:"center",textAlign:"center"}},{children:"No data available to answer this query. Add an FAQ to address it in the future"})),U&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{display:"flex",width:"100%"}},{children:e.jsxRuntimeExports.jsx(h.Button,{LeadingIcon:null!==(t=U.leadingIcon)&&void 0!==t?t:u.default,buttonText:null!==(s=U.title)&&void 0!==s?s:"Add FAQ",buttonType:"secondary",size:"small",matchParentWidth:!0,onClick:()=>{U.onClick()}})}))]}))})()})):e.jsxRuntimeExports.jsx(R.Tag,{LeadingIcon:d.default,version:"2.0",type:"grey",theme:"light",alignIcon:"start",contentPadding:12,tagText:F.isEditable?`If any of the information is incorrect, update the original data source and sync it again. Alternatively, you can make local corrections directly in ${N===t.ApplicationType.BIK?"BIK":"Manifest"}.`:"Edit the original source and save again to update the response"})]})),!Ce(V)&&e.jsxRuntimeExports.jsxs("div",Object.assign({className:"info-container"},{children:[e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:ge.length>0&&e.jsxRuntimeExports.jsx("div",Object.assign({className:"info-product-source"},{children:e.jsxRuntimeExports.jsx(ve,Object.assign({title:"Product Sources",count:ge.length,isExpanded:N!==t.ApplicationType.MANIFEST||ue,onToggle:()=>xe(!ue)},{children:e.jsxRuntimeExports.jsx("div",Object.assign({className:"source",style:{padding:"0 12px",maxWidth:"100%"}},{children:ge.map(((t,s)=>{var i,o,n,l;const a=ye(t.type||t.subTitle||"OpenAI"),d=ye(t.type||t.subTitle||"OpenAI",!0),c=Re(a),u=null==K?void 0:K.includes(d),p=k[null!==(i=t.productId)&&void 0!==i?i:"Products"],j=t.title,m=t.productId&&(null==Y?void 0:Y[t.productId]),h=m&&m.metafield.join(", ");return e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"8px",padding:"16px 0px",borderBottom:s+1<(null==ge?void 0:ge.length)?`1px solid ${g.COLORS.stroke.primary}`:"none"}},{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",justifyContent:"space-between",alignItems:"center"}},{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flex:1,gap:"8px",flexDirection:"row",alignItems:"center",justifyContent:"flex-start"}},{children:[Oe(a),e.jsxRuntimeExports.jsx(O.Tooltip,Object.assign({body:j,placement:"top"},{children:e.jsxRuntimeExports.jsx(f.BodySecondary,Object.assign({style:d==b.CustomDataType.FETCHED_LINKS||d==b.CustomDataType.WEBSITE_LINKS?{cursor:"pointer",textDecoration:"underline"}:{},color:g.COLORS.content.primary,className:"clamp-title",onClick:()=>d==b.CustomDataType.FETCHED_LINKS||d==b.CustomDataType.WEBSITE_LINKS?H(t):{}},{children:j}))}))]})),e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",justifyContent:"flex-end",alignItems:"center",gap:"4px",flex:"none"}},{children:[t.intent!==P.EMAIL_COLLECTION&&e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsx(f.BodyCaption,Object.assign({color:g.COLORS.content.secondary},{children:c}))}),(t.link||t.docId)&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{cursor:"pointer",marginLeft:"0px"}},{children:u?e.jsxRuntimeExports.jsx(E.IconButton,{Icon:r.default,height:16,width:16,iconColor:g.COLORS.content.secondary,onClick:()=>null==p?void 0:p.onEditClick(p.data,p.type),disabled:!p,disabledTooltip:"This source is deleted"}):e.jsxRuntimeExports.jsx(E.IconButton,{Icon:x.default,height:16,width:16,iconColor:g.COLORS.content.secondary,disabled:"custom"===t.type&&!p,disabledTooltip:"This source is deleted",onClick:()=>H(t)})}))]}))]})),m&&e.jsxRuntimeExports.jsxs(f.BodyCaption,{children:[e.jsxRuntimeExports.jsx("span",Object.assign({className:"product-data-text1",onClick:()=>{var e;ae({title:j,description:fe(m.description),imageUrl:null!==(e=t.imageUrl)&&void 0!==e?e:"",onClose:()=>ae(void 0)})}},{children:`${null===(o=m.description)||void 0===o?void 0:o.length} characters description,`})),e.jsxRuntimeExports.jsx("span",Object.assign({className:"product-data-text1",onClick:()=>m.onEditFaqClick(m.faqs)},{children:`${null===(n=m.faqs)||void 0===n?void 0:n.length} FAQs, `})),e.jsxRuntimeExports.jsx("span",Object.assign({className:"product-data-text2"},{children:"and"})),e.jsxRuntimeExports.jsx(O.Tooltip,Object.assign({body:h,placement:"top"},{children:e.jsxRuntimeExports.jsx("span",Object.assign({className:"product-data-text1"},{children:`${null===(l=m.metafield)||void 0===l?void 0:l.length} metafields`}))}))]})]}),`info-${s}`)}))}))}))}))}),e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:he.length>0&&e.jsxRuntimeExports.jsx("div",Object.assign({className:"info-content-source"},{children:e.jsxRuntimeExports.jsx(ve,Object.assign({title:"Content Sources",count:he.length,isExpanded:N!==t.ApplicationType.MANIFEST||pe,onToggle:()=>je(!pe)},{children:e.jsxRuntimeExports.jsx("div",Object.assign({className:"source",style:{padding:"0 12px",maxWidth:"100%"}},{children:he.map(((t,s)=>{var i,o,n,l,a,d,c,u,p,j,m,h,C,y,R,v,S;const T=ye(t.type||t.subTitle||"OpenAI"),I=ye(t.type||t.subTitle||"OpenAI",!0),L=Re(T),w=null==K?void 0:K.includes(I),D="Products"===t.subTitle?k[null!==(i=t.productId)&&void 0!==i?i:"Products"]:k[null!==(o=t.docId)&&void 0!==o?o:""],N=I.toLowerCase()===(null===(n=b.CustomDataType.FAQ)||void 0===n?void 0:n.toLowerCase())?"faq"===(null===(l=t.title)||void 0===l?void 0:l.toLowerCase())?t.subTitle:t.title:I.toLowerCase()===(null===(a=b.CustomDataType.FILES)||void 0===a?void 0:a.toLowerCase())||I.toLowerCase()===(null===(d=b.CustomDataType.FETCHED_LINKS)||void 0===d?void 0:d.toLowerCase())||I.toLowerCase()===(null===(c=b.CustomDataType.TEXTS)||void 0===c?void 0:c.toLowerCase())?t.title:I.toLowerCase()===(null===(u=b.CustomDataType.WEBSITE_LINKS)||void 0===u?void 0:u.toLowerCase())?t.title.split("/")[t.title.split("/").length-1].replace(/[^\w\s]/gi," ").replace(/^(.)(.*)$/,((e,t,s)=>t.toUpperCase()+s)):t.intent===P.EMAIL_COLLECTION?L:t.title,A="faq"===I.toLowerCase()?null!==(m=null!==(p=null==D?void 0:D.content)&&void 0!==p?p:null===(j=null==D?void 0:D.data)||void 0===j?void 0:j.answer)&&void 0!==m?m:"":I.toLowerCase()===(null===(h=b.CustomDataType.FETCHED_LINKS)||void 0===h?void 0:h.toLowerCase())||I.toLowerCase()===(null===(C=b.CustomDataType.WEBSITE_LINKS)||void 0===C?void 0:C.toLowerCase())||I.toLowerCase()===(null===(y=b.CustomDataType.TEXTS)||void 0===y?void 0:y.toLowerCase())?null!==(S=null!==(R=null==D?void 0:D.content)&&void 0!==R?R:null===(v=null==D?void 0:D.data)||void 0===v?void 0:v.fileContentText)&&void 0!==S?S:"":t.intent===P.EMAIL_COLLECTION?"Collect leads before replying to messages":"";return e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"8px",padding:"16px 0px",borderBottom:s+1<(null==he?void 0:he.length)?`1px solid ${g.COLORS.stroke.primary}`:"none"}},{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",justifyContent:"space-between",alignItems:"center"}},{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flex:1,gap:"8px",flexDirection:"row",alignItems:"center",justifyContent:"flex-start"}},{children:[Oe(T),e.jsxRuntimeExports.jsx(O.Tooltip,Object.assign({body:N,placement:"top"},{children:e.jsxRuntimeExports.jsx(f.BodySecondary,Object.assign({style:I==b.CustomDataType.FETCHED_LINKS||I==b.CustomDataType.WEBSITE_LINKS?{cursor:"pointer",textDecoration:"underline"}:{},color:g.COLORS.content.primary,className:"clamp-title",onClick:()=>I==b.CustomDataType.FETCHED_LINKS||I==b.CustomDataType.WEBSITE_LINKS?H(t):{}},{children:N}))}))]})),e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",justifyContent:"flex-end",alignItems:"center",gap:"4px",flex:"none"}},{children:[t.intent!==P.EMAIL_COLLECTION&&e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsx(f.BodyCaption,Object.assign({color:g.COLORS.content.secondary},{children:L}))}),(t.link||t.docId)&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{cursor:"pointer",marginLeft:"0px"}},{children:w?e.jsxRuntimeExports.jsx(E.IconButton,{Icon:r.default,height:16,width:16,iconColor:g.COLORS.content.secondary,onClick:()=>null==D?void 0:D.onEditClick(D.data,D.type),disabled:!D,disabledTooltip:"This source is deleted"}):e.jsxRuntimeExports.jsx(E.IconButton,{Icon:x.default,height:16,width:16,iconColor:g.COLORS.content.secondary,disabled:"custom"===t.type&&!D,disabledTooltip:"This source is deleted",onClick:()=>H(t)})}))]}))]})),(null!=A?A:"").trim()&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{padding:"4px 8px",border:`1px dashed ${g.COLORS.stroke.primary}`,borderRadius:"4px",backgroundColor:g.COLORS.surface.subdued}},{children:e.jsxRuntimeExports.jsx(f.BodyCaption,Object.assign({color:g.COLORS.content.primary,className:"clamp-description"},{children:fe(null!=A?A:"").trim()}))}))]}),`info-${s}`)}))}))}))}))})]})),ie&&!Ce(V)&&e.jsxRuntimeExports.jsx("div",Object.assign({className:"footer"},{children:e.jsxRuntimeExports.jsx(v.default,{appType:N,storeId:A,messageSource:F,sourceIntent:null!==(D=F.intent)&&void 0!==D?D:P.GENERIC,faqCount:ne,trainingSourceCount:de,ShowTrainingDataSource:Ee,ChecklistType:P,footerButtonOption:$,isFooterLoading:te,reasonForAiGeneratedResponse:z,showAiResponseReason:X})}))]})}),le&&e.jsxRuntimeExports.jsx(y.SideModal,Object.assign({header:"Product description",onClose:()=>ae(void 0),width:"30%"},{children:e.jsxRuntimeExports.jsx(I.DescriptionModal,{title:le.title,description:le.description,imageUrl:le.imageUrl,onClose:le.onClose})}))]})};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../node_modules/react/jsx-runtime.js"),t=require("@bikdotai/bik-models/growth"),s=require("../../assets/icons/boxV2.svg.js"),i=require("../../assets/icons/chevronDownOutline.svg.js"),o=require("../../assets/icons/chevronUpOutline.svg.js"),n=require("../../assets/icons/cross.svg.js"),r=require("../../assets/icons/edit.svg.js"),l=require("../../assets/icons/filePdf.svg.js"),a=require("../../assets/icons/help.svg.js"),d=require("../../assets/icons/info.svg.js"),c=require("../../assets/icons/openai.svg.js"),u=require("../../assets/icons/plus.svg.js"),x=require("../../assets/icons/redirect.svg.js"),p=require("../../assets/icons/text_t9.svg.js"),j=require("../../assets/icons/website.svg.js"),m=require("react"),g=require("../../constants/Theme.js"),h=require("../button/Button.js"),y=require("../icon-button/IconButton.js"),E=require("../shimmer/ShimmerComponent/BikShimmer.js"),C=require("../side-modal/SideModal.js"),R=require("../tag/Tag.js"),O=require("../tooltips/Tooltip.js"),f=require("../TypographyStyle.js"),v=require("./DataSourceInfoFooter.js"),S=require("./DataSourcePanel.style.js"),T=require("./IntentConfig.js"),I=require("./Modals/DescriptionModal.js"),b=require("./model.js");exports.DataSourcePanel=L=>{var w,D;const{appType:N,storeId:A,messageSource:F,setMessageSourcePanel:_,hideCloseButton:k,isSourceInfoFetched:B,allSourceInfoDetail:q,ChecklistType:P,title:M,zeroStateButton:U,editableSources:K,preFillTrainingSourceCount:W,redirect:$,footerButtonOption:H,fetchTrainingSourceCount:Q,fetchProductFAQCount:G,productSourceData:Y,reasonForAiGeneratedResponse:z,showAiResponseReason:X,productSearchRule:V,onEditProductSearchRule:J}=L,{sources:Z}=F,ee=["blog","article","page","policy"],[te,se]=m.useState(!1),[ie,oe]=m.useState(!1),[ne,re]=m.useState(!1),[le,ae]=m.useState(0),[de,ce]=m.useState(),[ue,xe]=m.useState(null!=W?W:{}),[pe,je]=m.useState(!1),[me,ge]=m.useState(!1),he={};T.intentConfig.forEach((t=>{let{key:s,type:i,tagText:o}=t;P[s]&&(he[P[s]]=e.jsxRuntimeExports.jsx(R.Tag,{theme:"light",type:i,tagText:o,cursor:"pointer"}))}));const ye=Z.filter((e=>"PRODUCTS"==e.type||"Products"==e.subTitle||e.productId)),Ee=Z.filter((e=>"PRODUCTS"!=e.type&&"Products"!=e.subTitle&&!e.productId)),Ce=m.useMemo((()=>{const e={};return["STORE_INFORMATION","CONTACT_INFO","STORE_LOCATION","SHIPPING_POLICY","RETURN_AND_REFUND","SALES_AND_OFFERS","SALES_AND_OFFERS_ISSUES","PRODUCT_CUSTOMISATION","PAYMENT_METHODS","CHECKOUT_ENQUIRY","ORDER_ENQUIRY"].forEach((t=>{P[t]&&(e[P[t]]=P[t])})),["COLLABORATION","SUBSCRIPTION_ENQUIRY"].forEach((t=>{e[t]=t})),e}),[P]);m.useEffect((()=>{var e,t,s,i;if(!(null==F?void 0:F.messageId))return;se(!0),oe(!0),re(!1!==(null===(t=null===(e=F.sources)||void 0===e?void 0:e[0])||void 0===t?void 0:t.isTrainable)||!!(null===(i=null===(s=F.sources)||void 0===s?void 0:s[0])||void 0===i?void 0:i.insights));const o=F.sources.filter((e=>!!e.productId)).map((e=>e.productId)),n=Array.from(new Set(o)).filter((e=>!!e));G(A,n).then((e=>ae(e))).then((()=>{W?(xe(W),setTimeout((()=>{se(!1),oe(!1)}),100)):(setTimeout((()=>se(!1)),100),Q(A).then((e=>xe(e))).then((()=>setTimeout((()=>{oe(!1)}),100))))}))}),[G,Q,null==F?void 0:F.messageId,F.sources,W,A]);const Re=e=>!!(e&&0===e.length||(null==F?void 0:F.isUnsatisfactoryAnswer)),Oe=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];var s;return"custom"==e?e=b.CustomDataType.FILES:ee.includes(e)?e=b.CustomDataType.FETCHED_LINKS:"url"==e?e=b.CustomDataType.WEBSITE_LINKS:"text"===e?e=b.CustomDataType.TEXTS:"faq"===e&&(e=b.CustomDataType.FAQ),t?e:null===(s=null==e?void 0:e.toLowerCase())||void 0===s?void 0:s.replace(/_/g," ")},fe=e=>e?"faq"==e.toLocaleLowerCase()?"FAQ":"openai"==e.toLocaleLowerCase()?"OPENAI":"files"==e.toLocaleLowerCase()?"PDF":"texts"==e.toLocaleLowerCase()?"Custom text":((e=(e=e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).replace("_"," ")).endsWith("s")&&(e=e.slice(0,-1)),e.replace("Website","Manual")):"",ve=t=>"products"==t||"product"==t?e.jsxRuntimeExports.jsx(s.default,{height:16,width:16,color:g.COLORS.content.secondary}):"files"==t?e.jsxRuntimeExports.jsx(l.default,{height:16,width:16,color:g.COLORS.content.secondary}):"website links"==t||"fetched links"==t?e.jsxRuntimeExports.jsx(j.default,{height:16,width:16,color:g.COLORS.content.secondary}):"faq"==t?e.jsxRuntimeExports.jsx(a.default,{height:16,width:16,color:g.COLORS.content.secondary}):"texts"==t?e.jsxRuntimeExports.jsx(p.default,{height:16,width:16,color:g.COLORS.content.secondary}):e.jsxRuntimeExports.jsx(c.default,{height:16,width:16,color:g.COLORS.content.secondary}),Se=e=>{const t=e.replace(/(<([^>]+)>)/gi,""),s=document.createElement("textarea");return s.innerHTML=t,s.value};if(te||!B)return e.jsxRuntimeExports.jsx(S.SourceInfoDetailsStyle,{children:e.jsxRuntimeExports.jsx(E.BikShimmer,{boxes:[{width:"100px",height:"16px"},{width:"0",height:"4px"},{width:"100%",height:"32px"},{width:"100%",height:"32px"},{width:"100%",height:"32px"},{width:"100%",height:"32px"},{width:"0",height:"4px"},{width:"100%",height:"16px"}]})});const Te=s=>{const{title:n,count:r,isExpanded:l,onToggle:a,children:d}=s;return e.jsxRuntimeExports.jsxs("div",{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 12px",cursor:"pointer"},onClick:a},{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",gap:"8px"}},{children:[e.jsxRuntimeExports.jsx(f.BodyCaption,Object.assign({style:{fontWeight:"600"}},{children:n})),N===t.ApplicationType.MANIFEST?e.jsxRuntimeExports.jsx("div",Object.assign({style:{backgroundColor:g.COLORS.surface.subdued,color:g.COLORS.content.secondary,padding:"2px 8px",borderRadius:"12px",fontSize:"12px",fontWeight:"500"}},{children:r})):e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{})]})),e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:N===t.ApplicationType.BIK?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{}):l?e.jsxRuntimeExports.jsx(i.default,{width:20,height:20,color:g.COLORS.content.primary}):e.jsxRuntimeExports.jsx(o.default,{width:20,height:20,color:g.COLORS.content.primary})})]})),l&&d]})};return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(S.SourceInfoDetailsStyle,{children:e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({className:"pop-up-header",style:{display:"flex",flexDirection:"column",paddingBottom:"12px"}},{children:[!!M&&e.jsxRuntimeExports.jsx(f.TitleSmall,{children:M}),e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",alignItems:"center"}},{children:[e.jsxRuntimeExports.jsx(f.BodyCaption,Object.assign({color:g.COLORS.content.secondary},{children:"Intent"})),null!==(w=he[F.intent])&&void 0!==w?w:he.GENERIC,!k&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{display:"flex",marginLeft:"auto",cursor:"pointer"},onClick:()=>_(void 0)},{children:e.jsxRuntimeExports.jsx(n.default,{height:20,width:20,color:g.COLORS.content.secondary})}))]})),V&&e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"12px",marginTop:"6px"}},{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",justifyContent:"space-between"}},{children:[e.jsxRuntimeExports.jsx(f.BodySecondary,Object.assign({color:g.COLORS.content.primary},{children:V.rule_name})),J&&V.rule_id&&e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",gap:"8px"}},{children:[e.jsxRuntimeExports.jsx(f.BodyCaption,Object.assign({color:g.COLORS.content.secondary},{children:"Edit search rule"})),e.jsxRuntimeExports.jsx(y.IconButton,{Icon:r.default,height:16,width:16,bordered:!0,iconColor:g.COLORS.content.secondary,onClick:()=>J(V.rule_id)})]}))]})),V.keywords&&V.keywords.length>0&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{display:"flex",flexWrap:"wrap",gap:"6px",padding:"12px",backgroundColor:g.COLORS.surface.subdued,borderRadius:"8px",border:`1px dashed ${g.COLORS.stroke.primary}`}},{children:V.keywords.map(((t,s)=>e.jsxRuntimeExports.jsx(R.Tag,{tagText:t,theme:"light"},`keyword-${s}`)))}))]})),Re(Z)?e.jsxRuntimeExports.jsx("div",Object.assign({style:{display:"flex",margin:"auto",justifyContent:"center",alignItems:"center",height:"calc(100vh - 300px)"}},{children:(()=>{var t,s;return e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",margin:"0px 30px",gap:"8px"}},{children:[e.jsxRuntimeExports.jsx("div",Object.assign({style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"12px",backgroundColor:`${g.COLORS.background.negative.light}`,borderRadius:"100px"}},{children:e.jsxRuntimeExports.jsx(d.default,{width:24,height:24,color:g.COLORS.stroke.negative.vibrant})})),e.jsxRuntimeExports.jsx("div",Object.assign({style:{justifyContent:"center",alignItems:"center",marginBottom:"-4px"}},{children:e.jsxRuntimeExports.jsx(f.TitleSmall,{children:"Insufficient data"})})),e.jsxRuntimeExports.jsx(f.BodySecondary,Object.assign({color:g.COLORS.content.secondary,style:{display:"flex",justifyContent:"center",textAlign:"center"}},{children:"No data available to answer this query. Add an FAQ to address it in the future"})),U&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{display:"flex",width:"100%"}},{children:e.jsxRuntimeExports.jsx(h.Button,{LeadingIcon:null!==(t=U.leadingIcon)&&void 0!==t?t:u.default,buttonText:null!==(s=U.title)&&void 0!==s?s:"Add FAQ",buttonType:"secondary",size:"small",matchParentWidth:!0,onClick:()=>{U.onClick()}})}))]}))})()})):e.jsxRuntimeExports.jsx(R.Tag,{LeadingIcon:d.default,version:"2.0",type:"grey",theme:"light",alignIcon:"start",contentPadding:12,tagText:F.isEditable?`If any of the information is incorrect, update the original data source and sync it again. Alternatively, you can make local corrections directly in ${N===t.ApplicationType.BIK?"BIK":"Manifest"}.`:"Edit the original source and save again to update the response"})]})),!Re(Z)&&e.jsxRuntimeExports.jsxs("div",Object.assign({className:"info-container"},{children:[e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:ye.length>0&&e.jsxRuntimeExports.jsx("div",Object.assign({className:"info-product-source"},{children:e.jsxRuntimeExports.jsx(Te,Object.assign({title:"Product Sources",count:ye.length,isExpanded:N!==t.ApplicationType.MANIFEST||pe,onToggle:()=>je(!pe)},{children:e.jsxRuntimeExports.jsx("div",Object.assign({className:"source",style:{padding:"0 12px",maxWidth:"100%"}},{children:ye.map(((t,s)=>{var i,o,n,l;const a=Oe(t.type||t.subTitle||"OpenAI"),d=Oe(t.type||t.subTitle||"OpenAI",!0),c=fe(a),u=null==K?void 0:K.includes(d),p=q[null!==(i=t.productId)&&void 0!==i?i:"Products"],j=t.title,m=t.productId&&(null==Y?void 0:Y[t.productId]),h=m&&m.metafield.join(", ");return e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"8px",padding:"16px 0px",borderBottom:s+1<(null==ye?void 0:ye.length)?`1px solid ${g.COLORS.stroke.primary}`:"none"}},{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",justifyContent:"space-between",alignItems:"center"}},{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flex:1,gap:"8px",flexDirection:"row",alignItems:"center",justifyContent:"flex-start"}},{children:[ve(a),e.jsxRuntimeExports.jsx(O.Tooltip,Object.assign({body:j,placement:"top"},{children:e.jsxRuntimeExports.jsx(f.BodySecondary,Object.assign({style:d==b.CustomDataType.FETCHED_LINKS||d==b.CustomDataType.WEBSITE_LINKS?{cursor:"pointer",textDecoration:"underline"}:{},color:g.COLORS.content.primary,className:"clamp-title",onClick:()=>d==b.CustomDataType.FETCHED_LINKS||d==b.CustomDataType.WEBSITE_LINKS?$(t):{}},{children:j}))}))]})),e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",justifyContent:"flex-end",alignItems:"center",gap:"4px",flex:"none"}},{children:[t.intent!==P.EMAIL_COLLECTION&&e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsx(f.BodyCaption,Object.assign({color:g.COLORS.content.secondary},{children:c}))}),(t.link||t.docId)&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{cursor:"pointer",marginLeft:"0px"}},{children:u?e.jsxRuntimeExports.jsx(y.IconButton,{Icon:r.default,height:16,width:16,iconColor:g.COLORS.content.secondary,onClick:()=>null==p?void 0:p.onEditClick(p.data,p.type),disabled:!p,disabledTooltip:"This source is deleted"}):e.jsxRuntimeExports.jsx(y.IconButton,{Icon:x.default,height:16,width:16,iconColor:g.COLORS.content.secondary,disabled:"custom"===t.type&&!p,disabledTooltip:"This source is deleted",onClick:()=>$(t)})}))]}))]})),m&&e.jsxRuntimeExports.jsxs(f.BodyCaption,{children:[e.jsxRuntimeExports.jsx("span",Object.assign({className:"product-data-text1",onClick:()=>{var e;ce({title:j,description:Se(m.description),imageUrl:null!==(e=t.imageUrl)&&void 0!==e?e:"",onClose:()=>ce(void 0)})}},{children:`${null===(o=m.description)||void 0===o?void 0:o.length} characters description,`})),e.jsxRuntimeExports.jsx("span",Object.assign({className:"product-data-text1",onClick:()=>m.onEditFaqClick(m.faqs)},{children:`${null===(n=m.faqs)||void 0===n?void 0:n.length} FAQs, `})),e.jsxRuntimeExports.jsx("span",Object.assign({className:"product-data-text2"},{children:"and"})),e.jsxRuntimeExports.jsx(O.Tooltip,Object.assign({body:h,placement:"top"},{children:e.jsxRuntimeExports.jsx("span",Object.assign({className:"product-data-text1"},{children:`${null===(l=m.metafield)||void 0===l?void 0:l.length} metafields`}))}))]})]}),`info-${s}`)}))}))}))}))}),e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:Ee.length>0&&e.jsxRuntimeExports.jsx("div",Object.assign({className:"info-content-source"},{children:e.jsxRuntimeExports.jsx(Te,Object.assign({title:"Content Sources",count:Ee.length,isExpanded:N!==t.ApplicationType.MANIFEST||me,onToggle:()=>ge(!me)},{children:e.jsxRuntimeExports.jsx("div",Object.assign({className:"source",style:{padding:"0 12px",maxWidth:"100%"}},{children:Ee.map(((t,s)=>{var i,o,n,l,a,d,c,u,p,j,m,h,E,C,R,v,S;const T=Oe(t.type||t.subTitle||"OpenAI"),I=Oe(t.type||t.subTitle||"OpenAI",!0),L=fe(T),w=null==K?void 0:K.includes(I),D="Products"===t.subTitle?q[null!==(i=t.productId)&&void 0!==i?i:"Products"]:q[null!==(o=t.docId)&&void 0!==o?o:""],N=I.toLowerCase()===(null===(n=b.CustomDataType.FAQ)||void 0===n?void 0:n.toLowerCase())?"faq"===(null===(l=t.title)||void 0===l?void 0:l.toLowerCase())?t.subTitle:t.title:I.toLowerCase()===(null===(a=b.CustomDataType.FILES)||void 0===a?void 0:a.toLowerCase())||I.toLowerCase()===(null===(d=b.CustomDataType.FETCHED_LINKS)||void 0===d?void 0:d.toLowerCase())||I.toLowerCase()===(null===(c=b.CustomDataType.TEXTS)||void 0===c?void 0:c.toLowerCase())?t.title:I.toLowerCase()===(null===(u=b.CustomDataType.WEBSITE_LINKS)||void 0===u?void 0:u.toLowerCase())?t.title.split("/")[t.title.split("/").length-1].replace(/[^\w\s]/gi," ").replace(/^(.)(.*)$/,((e,t,s)=>t.toUpperCase()+s)):t.intent===P.EMAIL_COLLECTION?L:t.title,A="faq"===I.toLowerCase()?null!==(m=null!==(p=null==D?void 0:D.content)&&void 0!==p?p:null===(j=null==D?void 0:D.data)||void 0===j?void 0:j.answer)&&void 0!==m?m:"":I.toLowerCase()===(null===(h=b.CustomDataType.FETCHED_LINKS)||void 0===h?void 0:h.toLowerCase())||I.toLowerCase()===(null===(E=b.CustomDataType.WEBSITE_LINKS)||void 0===E?void 0:E.toLowerCase())||I.toLowerCase()===(null===(C=b.CustomDataType.TEXTS)||void 0===C?void 0:C.toLowerCase())?null!==(S=null!==(R=null==D?void 0:D.content)&&void 0!==R?R:null===(v=null==D?void 0:D.data)||void 0===v?void 0:v.fileContentText)&&void 0!==S?S:"":t.intent===P.EMAIL_COLLECTION?"Collect leads before replying to messages":"";return e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"8px",padding:"16px 0px",borderBottom:s+1<(null==Ee?void 0:Ee.length)?`1px solid ${g.COLORS.stroke.primary}`:"none"}},{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",justifyContent:"space-between",alignItems:"center"}},{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flex:1,gap:"8px",flexDirection:"row",alignItems:"center",justifyContent:"flex-start"}},{children:[ve(T),e.jsxRuntimeExports.jsx(O.Tooltip,Object.assign({body:N,placement:"top"},{children:e.jsxRuntimeExports.jsx(f.BodySecondary,Object.assign({style:I==b.CustomDataType.FETCHED_LINKS||I==b.CustomDataType.WEBSITE_LINKS?{cursor:"pointer",textDecoration:"underline"}:{},color:g.COLORS.content.primary,className:"clamp-title",onClick:()=>I==b.CustomDataType.FETCHED_LINKS||I==b.CustomDataType.WEBSITE_LINKS?$(t):{}},{children:N}))}))]})),e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",justifyContent:"flex-end",alignItems:"center",gap:"4px",flex:"none"}},{children:[t.intent!==P.EMAIL_COLLECTION&&e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsx(f.BodyCaption,Object.assign({color:g.COLORS.content.secondary},{children:L}))}),(t.link||t.docId)&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{cursor:"pointer",marginLeft:"0px"}},{children:w?e.jsxRuntimeExports.jsx(y.IconButton,{Icon:r.default,height:16,width:16,iconColor:g.COLORS.content.secondary,onClick:()=>null==D?void 0:D.onEditClick(D.data,D.type),disabled:!D,disabledTooltip:"This source is deleted"}):e.jsxRuntimeExports.jsx(y.IconButton,{Icon:x.default,height:16,width:16,iconColor:g.COLORS.content.secondary,disabled:"custom"===t.type&&!D,disabledTooltip:"This source is deleted",onClick:()=>$(t)})}))]}))]})),(null!=A?A:"").trim()&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{padding:"4px 8px",border:`1px dashed ${g.COLORS.stroke.primary}`,borderRadius:"4px",backgroundColor:g.COLORS.surface.subdued}},{children:e.jsxRuntimeExports.jsx(f.BodyCaption,Object.assign({color:g.COLORS.content.primary,className:"clamp-description"},{children:Se(null!=A?A:"").trim()}))}))]}),`info-${s}`)}))}))}))}))})]})),ne&&!Re(Z)&&e.jsxRuntimeExports.jsx("div",Object.assign({className:"footer"},{children:e.jsxRuntimeExports.jsx(v.default,{appType:N,storeId:A,messageSource:F,sourceIntent:null!==(D=F.intent)&&void 0!==D?D:P.GENERIC,faqCount:le,trainingSourceCount:ue,ShowTrainingDataSource:Ce,ChecklistType:P,footerButtonOption:H,isFooterLoading:ie,reasonForAiGeneratedResponse:z,showAiResponseReason:X})}))]})}),de&&e.jsxRuntimeExports.jsx(C.SideModal,Object.assign({header:"Product description",onClose:()=>ce(void 0),width:"30%"},{children:e.jsxRuntimeExports.jsx(I.DescriptionModal,{title:de.title,description:de.description,imageUrl:de.imageUrl,onClose:de.onClose})}))]})};
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { ApplicationType } from '@bikdotai/bik-models/growth';
|
|
3
3
|
import { AllSourceInfoDetailsCustomDataModel, CustomDataType, DataSourcePanelZeroState, footerButtonOptionModel, InfoContent, MessageSource, ProductSourceData } from './model';
|
|
4
|
+
export interface ProductSearchRuleDB {
|
|
5
|
+
rule_id?: string;
|
|
6
|
+
rule_name: string;
|
|
7
|
+
keywords: string[];
|
|
8
|
+
}
|
|
4
9
|
export interface CollapsibleSectionProps {
|
|
5
10
|
title: string;
|
|
6
11
|
count: number;
|
|
@@ -32,5 +37,7 @@ export interface DataSourcePanelProps {
|
|
|
32
37
|
productSourceData?: ProductSourceData;
|
|
33
38
|
reasonForAiGeneratedResponse?: string;
|
|
34
39
|
showAiResponseReason?: boolean;
|
|
40
|
+
productSearchRule?: ProductSearchRuleDB;
|
|
41
|
+
onEditProductSearchRule?: (ruleId: string) => void;
|
|
35
42
|
}
|
|
36
43
|
export declare const DataSourcePanel: React.FC<DataSourcePanelProps>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"../../node_modules/react/jsx-runtime.js";import{ApplicationType as t}from"@bikdotai/bik-models/growth";import s from"../../assets/icons/boxV2.svg.js";import i from"../../assets/icons/chevronDownOutline.svg.js";import o from"../../assets/icons/chevronUpOutline.svg.js";import n from"../../assets/icons/cross.svg.js";import r from"../../assets/icons/edit.svg.js";import l from"../../assets/icons/filePdf.svg.js";import c from"../../assets/icons/help.svg.js";import a from"../../assets/icons/info.svg.js";import d from"../../assets/icons/openai.svg.js";import p from"../../assets/icons/plus.svg.js";import u from"../../assets/icons/redirect.svg.js";import g from"../../assets/icons/text_t9.svg.js";import h from"../../assets/icons/website.svg.js";import{useState as x,useMemo as m,useEffect as j}from"react";import{COLORS as f}from"../../constants/Theme.js";import{Button as v}from"../button/Button.js";import{IconButton as y}from"../icon-button/IconButton.js";import{BikShimmer as C}from"../shimmer/ShimmerComponent/BikShimmer.js";import{SideModal as I}from"../side-modal/SideModal.js";import{Tag as b}from"../tag/Tag.js";import{Tooltip as O}from"../tooltips/Tooltip.js";import{TitleSmall as T,BodyCaption as E,BodySecondary as S}from"../TypographyStyle.js";import w from"./DataSourceInfoFooter.js";import{SourceInfoDetailsStyle as L}from"./DataSourcePanel.style.js";import{intentConfig as N}from"./IntentConfig.js";import{DescriptionModal as F}from"./Modals/DescriptionModal.js";import{CustomDataType as A}from"./model.js";const _=_=>{var D,k;const{appType:R,storeId:B,messageSource:P,setMessageSourcePanel:U,hideCloseButton:K,isSourceInfoFetched:M,allSourceInfoDetail:W,ChecklistType:H,title:$,zeroStateButton:q,editableSources:Q,preFillTrainingSourceCount:G,redirect:Y,footerButtonOption:z,fetchTrainingSourceCount:X,fetchProductFAQCount:V,productSourceData:J,reasonForAiGeneratedResponse:Z,showAiResponseReason:ee}=_,{sources:te}=P,se=["blog","article","page","policy"],[ie,oe]=x(!1),[ne,re]=x(!1),[le,ce]=x(!1),[ae,de]=x(0),[pe,ue]=x(),[ge,he]=x(null!=G?G:{}),[xe,me]=x(!1),[je,fe]=x(!1),ve={};N.forEach((t=>{let{key:s,type:i,tagText:o}=t;H[s]&&(ve[H[s]]=e.jsx(b,{theme:"light",type:i,tagText:o,cursor:"pointer"}))}));const ye=te.filter((e=>"PRODUCTS"==e.type||"Products"==e.subTitle||e.productId)),Ce=te.filter((e=>"PRODUCTS"!=e.type&&"Products"!=e.subTitle&&!e.productId)),Ie=m((()=>{const e={};return["STORE_INFORMATION","CONTACT_INFO","STORE_LOCATION","SHIPPING_POLICY","RETURN_AND_REFUND","SALES_AND_OFFERS","SALES_AND_OFFERS_ISSUES","PRODUCT_CUSTOMISATION","PAYMENT_METHODS","CHECKOUT_ENQUIRY","ORDER_ENQUIRY"].forEach((t=>{H[t]&&(e[H[t]]=H[t])})),["COLLABORATION","SUBSCRIPTION_ENQUIRY"].forEach((t=>{e[t]=t})),e}),[H]);j((()=>{var e,t,s,i;if(!(null==P?void 0:P.messageId))return;oe(!0),re(!0),ce(!1!==(null===(t=null===(e=P.sources)||void 0===e?void 0:e[0])||void 0===t?void 0:t.isTrainable)||!!(null===(i=null===(s=P.sources)||void 0===s?void 0:s[0])||void 0===i?void 0:i.insights));const o=P.sources.filter((e=>!!e.productId)).map((e=>e.productId)),n=Array.from(new Set(o)).filter((e=>!!e));V(B,n).then((e=>de(e))).then((()=>{G?(he(G),setTimeout((()=>{oe(!1),re(!1)}),100)):(setTimeout((()=>oe(!1)),100),X(B).then((e=>he(e))).then((()=>setTimeout((()=>{re(!1)}),100))))}))}),[V,X,null==P?void 0:P.messageId,P.sources,G,B]);const be=e=>!!(e&&0===e.length||(null==P?void 0:P.isUnsatisfactoryAnswer)),Oe=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];var s;return"custom"==e?e=A.FILES:se.includes(e)?e=A.FETCHED_LINKS:"url"==e?e=A.WEBSITE_LINKS:"text"===e?e=A.TEXTS:"faq"===e&&(e=A.FAQ),t?e:null===(s=null==e?void 0:e.toLowerCase())||void 0===s?void 0:s.replace(/_/g," ")},Te=e=>e?"faq"==e.toLocaleLowerCase()?"FAQ":"openai"==e.toLocaleLowerCase()?"OPENAI":"files"==e.toLocaleLowerCase()?"PDF":"texts"==e.toLocaleLowerCase()?"Custom text":((e=(e=e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).replace("_"," ")).endsWith("s")&&(e=e.slice(0,-1)),e.replace("Website","Manual")):"",Ee=t=>"products"==t||"product"==t?e.jsx(s,{height:16,width:16,color:f.content.secondary}):"files"==t?e.jsx(l,{height:16,width:16,color:f.content.secondary}):"website links"==t||"fetched links"==t?e.jsx(h,{height:16,width:16,color:f.content.secondary}):"faq"==t?e.jsx(c,{height:16,width:16,color:f.content.secondary}):"texts"==t?e.jsx(g,{height:16,width:16,color:f.content.secondary}):e.jsx(d,{height:16,width:16,color:f.content.secondary}),Se=e=>{const t=e.replace(/(<([^>]+)>)/gi,""),s=document.createElement("textarea");return s.innerHTML=t,s.value};if(ie||!M)return e.jsx(L,{children:e.jsx(C,{boxes:[{width:"100px",height:"16px"},{width:"0",height:"4px"},{width:"100%",height:"32px"},{width:"100%",height:"32px"},{width:"100%",height:"32px"},{width:"100%",height:"32px"},{width:"0",height:"4px"},{width:"100%",height:"16px"}]})});const we=s=>{const{title:n,count:r,isExpanded:l,onToggle:c,children:a}=s;return e.jsxs("div",{children:[e.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 12px",cursor:"pointer"},onClick:c},{children:[e.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",gap:"8px"}},{children:[e.jsx(E,Object.assign({style:{fontWeight:"600"}},{children:n})),R===t.MANIFEST?e.jsx("div",Object.assign({style:{backgroundColor:f.surface.subdued,color:f.content.secondary,padding:"2px 8px",borderRadius:"12px",fontSize:"12px",fontWeight:"500"}},{children:r})):e.jsx(e.Fragment,{})]})),e.jsx(e.Fragment,{children:R===t.BIK?e.jsx(e.Fragment,{}):l?e.jsx(i,{width:20,height:20,color:f.content.primary}):e.jsx(o,{width:20,height:20,color:f.content.primary})})]})),l&&a]})};return e.jsxs(e.Fragment,{children:[e.jsx(L,{children:e.jsxs(e.Fragment,{children:[e.jsxs("div",Object.assign({className:"pop-up-header",style:{display:"flex",flexDirection:"column",paddingBottom:"12px"}},{children:[!!$&&e.jsx(T,{children:$}),e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",alignItems:"center"}},{children:[e.jsx(E,Object.assign({color:f.content.secondary},{children:"Intent"})),null!==(D=ve[P.intent])&&void 0!==D?D:ve.GENERIC,!K&&e.jsx("div",Object.assign({style:{display:"flex",marginLeft:"auto",cursor:"pointer"},onClick:()=>U(void 0)},{children:e.jsx(n,{height:20,width:20,color:f.content.secondary})}))]})),be(te)?e.jsx("div",Object.assign({style:{display:"flex",margin:"auto",justifyContent:"center",alignItems:"center",height:"calc(100vh - 300px)"}},{children:(()=>{var t,s;return e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",margin:"0px 30px",gap:"8px"}},{children:[e.jsx("div",Object.assign({style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"12px",backgroundColor:`${f.background.negative.light}`,borderRadius:"100px"}},{children:e.jsx(a,{width:24,height:24,color:f.stroke.negative.vibrant})})),e.jsx("div",Object.assign({style:{justifyContent:"center",alignItems:"center",marginBottom:"-4px"}},{children:e.jsx(T,{children:"Insufficient data"})})),e.jsx(S,Object.assign({color:f.content.secondary,style:{display:"flex",justifyContent:"center",textAlign:"center"}},{children:"No data available to answer this query. Add an FAQ to address it in the future"})),q&&e.jsx("div",Object.assign({style:{display:"flex",width:"100%"}},{children:e.jsx(v,{LeadingIcon:null!==(t=q.leadingIcon)&&void 0!==t?t:p,buttonText:null!==(s=q.title)&&void 0!==s?s:"Add FAQ",buttonType:"secondary",size:"small",matchParentWidth:!0,onClick:()=>{q.onClick()}})}))]}))})()})):e.jsx(b,{LeadingIcon:a,version:"2.0",type:"grey",theme:"light",alignIcon:"start",contentPadding:12,tagText:P.isEditable?`If any of the information is incorrect, update the original data source and sync it again. Alternatively, you can make local corrections directly in ${R===t.BIK?"BIK":"Manifest"}.`:"Edit the original source and save again to update the response"})]})),!be(te)&&e.jsxs("div",Object.assign({className:"info-container"},{children:[e.jsx(e.Fragment,{children:ye.length>0&&e.jsx("div",Object.assign({className:"info-product-source"},{children:e.jsx(we,Object.assign({title:"Product Sources",count:ye.length,isExpanded:R!==t.MANIFEST||xe,onToggle:()=>me(!xe)},{children:e.jsx("div",Object.assign({className:"source",style:{padding:"0 12px",maxWidth:"100%"}},{children:ye.map(((t,s)=>{var i,o,n,l;const c=Oe(t.type||t.subTitle||"OpenAI"),a=Oe(t.type||t.subTitle||"OpenAI",!0),d=Te(c),p=null==Q?void 0:Q.includes(a),g=W[null!==(i=t.productId)&&void 0!==i?i:"Products"],h=t.title,x=t.productId&&(null==J?void 0:J[t.productId]),m=x&&x.metafield.join(", ");return e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"8px",padding:"16px 0px",borderBottom:s+1<(null==ye?void 0:ye.length)?`1px solid ${f.stroke.primary}`:"none"}},{children:[e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",justifyContent:"space-between",alignItems:"center"}},{children:[e.jsxs("div",Object.assign({style:{display:"flex",flex:1,gap:"8px",flexDirection:"row",alignItems:"center",justifyContent:"flex-start"}},{children:[Ee(c),e.jsx(O,Object.assign({body:h,placement:"top"},{children:e.jsx(S,Object.assign({style:a==A.FETCHED_LINKS||a==A.WEBSITE_LINKS?{cursor:"pointer",textDecoration:"underline"}:{},color:f.content.primary,className:"clamp-title",onClick:()=>a==A.FETCHED_LINKS||a==A.WEBSITE_LINKS?Y(t):{}},{children:h}))}))]})),e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",justifyContent:"flex-end",alignItems:"center",gap:"4px",flex:"none"}},{children:[t.intent!==H.EMAIL_COLLECTION&&e.jsx(e.Fragment,{children:e.jsx(E,Object.assign({color:f.content.secondary},{children:d}))}),(t.link||t.docId)&&e.jsx("div",Object.assign({style:{cursor:"pointer",marginLeft:"0px"}},{children:p?e.jsx(y,{Icon:r,height:16,width:16,iconColor:f.content.secondary,onClick:()=>null==g?void 0:g.onEditClick(g.data,g.type),disabled:!g,disabledTooltip:"This source is deleted"}):e.jsx(y,{Icon:u,height:16,width:16,iconColor:f.content.secondary,disabled:"custom"===t.type&&!g,disabledTooltip:"This source is deleted",onClick:()=>Y(t)})}))]}))]})),x&&e.jsxs(E,{children:[e.jsx("span",Object.assign({className:"product-data-text1",onClick:()=>{var e;ue({title:h,description:Se(x.description),imageUrl:null!==(e=t.imageUrl)&&void 0!==e?e:"",onClose:()=>ue(void 0)})}},{children:`${null===(o=x.description)||void 0===o?void 0:o.length} characters description,`})),e.jsx("span",Object.assign({className:"product-data-text1",onClick:()=>x.onEditFaqClick(x.faqs)},{children:`${null===(n=x.faqs)||void 0===n?void 0:n.length} FAQs, `})),e.jsx("span",Object.assign({className:"product-data-text2"},{children:"and"})),e.jsx(O,Object.assign({body:m,placement:"top"},{children:e.jsx("span",Object.assign({className:"product-data-text1"},{children:`${null===(l=x.metafield)||void 0===l?void 0:l.length} metafields`}))}))]})]}),`info-${s}`)}))}))}))}))}),e.jsx(e.Fragment,{children:Ce.length>0&&e.jsx("div",Object.assign({className:"info-content-source"},{children:e.jsx(we,Object.assign({title:"Content Sources",count:Ce.length,isExpanded:R!==t.MANIFEST||je,onToggle:()=>fe(!je)},{children:e.jsx("div",Object.assign({className:"source",style:{padding:"0 12px",maxWidth:"100%"}},{children:Ce.map(((t,s)=>{var i,o,n,l,c,a,d,p,g,h,x,m,j,v,C,I,b;const T=Oe(t.type||t.subTitle||"OpenAI"),w=Oe(t.type||t.subTitle||"OpenAI",!0),L=Te(T),N=null==Q?void 0:Q.includes(w),F="Products"===t.subTitle?W[null!==(i=t.productId)&&void 0!==i?i:"Products"]:W[null!==(o=t.docId)&&void 0!==o?o:""],_=w.toLowerCase()===(null===(n=A.FAQ)||void 0===n?void 0:n.toLowerCase())?"faq"===(null===(l=t.title)||void 0===l?void 0:l.toLowerCase())?t.subTitle:t.title:w.toLowerCase()===(null===(c=A.FILES)||void 0===c?void 0:c.toLowerCase())||w.toLowerCase()===(null===(a=A.FETCHED_LINKS)||void 0===a?void 0:a.toLowerCase())||w.toLowerCase()===(null===(d=A.TEXTS)||void 0===d?void 0:d.toLowerCase())?t.title:w.toLowerCase()===(null===(p=A.WEBSITE_LINKS)||void 0===p?void 0:p.toLowerCase())?t.title.split("/")[t.title.split("/").length-1].replace(/[^\w\s]/gi," ").replace(/^(.)(.*)$/,((e,t,s)=>t.toUpperCase()+s)):t.intent===H.EMAIL_COLLECTION?L:t.title,D="faq"===w.toLowerCase()?null!==(x=null!==(g=null==F?void 0:F.content)&&void 0!==g?g:null===(h=null==F?void 0:F.data)||void 0===h?void 0:h.answer)&&void 0!==x?x:"":w.toLowerCase()===(null===(m=A.FETCHED_LINKS)||void 0===m?void 0:m.toLowerCase())||w.toLowerCase()===(null===(j=A.WEBSITE_LINKS)||void 0===j?void 0:j.toLowerCase())||w.toLowerCase()===(null===(v=A.TEXTS)||void 0===v?void 0:v.toLowerCase())?null!==(b=null!==(C=null==F?void 0:F.content)&&void 0!==C?C:null===(I=null==F?void 0:F.data)||void 0===I?void 0:I.fileContentText)&&void 0!==b?b:"":t.intent===H.EMAIL_COLLECTION?"Collect leads before replying to messages":"";return e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"8px",padding:"16px 0px",borderBottom:s+1<(null==Ce?void 0:Ce.length)?`1px solid ${f.stroke.primary}`:"none"}},{children:[e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",justifyContent:"space-between",alignItems:"center"}},{children:[e.jsxs("div",Object.assign({style:{display:"flex",flex:1,gap:"8px",flexDirection:"row",alignItems:"center",justifyContent:"flex-start"}},{children:[Ee(T),e.jsx(O,Object.assign({body:_,placement:"top"},{children:e.jsx(S,Object.assign({style:w==A.FETCHED_LINKS||w==A.WEBSITE_LINKS?{cursor:"pointer",textDecoration:"underline"}:{},color:f.content.primary,className:"clamp-title",onClick:()=>w==A.FETCHED_LINKS||w==A.WEBSITE_LINKS?Y(t):{}},{children:_}))}))]})),e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",justifyContent:"flex-end",alignItems:"center",gap:"4px",flex:"none"}},{children:[t.intent!==H.EMAIL_COLLECTION&&e.jsx(e.Fragment,{children:e.jsx(E,Object.assign({color:f.content.secondary},{children:L}))}),(t.link||t.docId)&&e.jsx("div",Object.assign({style:{cursor:"pointer",marginLeft:"0px"}},{children:N?e.jsx(y,{Icon:r,height:16,width:16,iconColor:f.content.secondary,onClick:()=>null==F?void 0:F.onEditClick(F.data,F.type),disabled:!F,disabledTooltip:"This source is deleted"}):e.jsx(y,{Icon:u,height:16,width:16,iconColor:f.content.secondary,disabled:"custom"===t.type&&!F,disabledTooltip:"This source is deleted",onClick:()=>Y(t)})}))]}))]})),(null!=D?D:"").trim()&&e.jsx("div",Object.assign({style:{padding:"4px 8px",border:`1px dashed ${f.stroke.primary}`,borderRadius:"4px",backgroundColor:f.surface.subdued}},{children:e.jsx(E,Object.assign({color:f.content.primary,className:"clamp-description"},{children:Se(null!=D?D:"").trim()}))}))]}),`info-${s}`)}))}))}))}))})]})),le&&!be(te)&&e.jsx("div",Object.assign({className:"footer"},{children:e.jsx(w,{appType:R,storeId:B,messageSource:P,sourceIntent:null!==(k=P.intent)&&void 0!==k?k:H.GENERIC,faqCount:ae,trainingSourceCount:ge,ShowTrainingDataSource:Ie,ChecklistType:H,footerButtonOption:z,isFooterLoading:ne,reasonForAiGeneratedResponse:Z,showAiResponseReason:ee})}))]})}),pe&&e.jsx(I,Object.assign({header:"Product description",onClose:()=>ue(void 0),width:"30%"},{children:e.jsx(F,{title:pe.title,description:pe.description,imageUrl:pe.imageUrl,onClose:pe.onClose})}))]})};export{_ as DataSourcePanel};
|
|
1
|
+
import{j as e}from"../../node_modules/react/jsx-runtime.js";import{ApplicationType as t}from"@bikdotai/bik-models/growth";import s from"../../assets/icons/boxV2.svg.js";import i from"../../assets/icons/chevronDownOutline.svg.js";import o from"../../assets/icons/chevronUpOutline.svg.js";import n from"../../assets/icons/cross.svg.js";import r from"../../assets/icons/edit.svg.js";import l from"../../assets/icons/filePdf.svg.js";import c from"../../assets/icons/help.svg.js";import a from"../../assets/icons/info.svg.js";import d from"../../assets/icons/openai.svg.js";import p from"../../assets/icons/plus.svg.js";import u from"../../assets/icons/redirect.svg.js";import g from"../../assets/icons/text_t9.svg.js";import x from"../../assets/icons/website.svg.js";import{useState as h,useMemo as j,useEffect as m}from"react";import{COLORS as f}from"../../constants/Theme.js";import{Button as y}from"../button/Button.js";import{IconButton as v}from"../icon-button/IconButton.js";import{BikShimmer as C}from"../shimmer/ShimmerComponent/BikShimmer.js";import{SideModal as b}from"../side-modal/SideModal.js";import{Tag as I}from"../tag/Tag.js";import{Tooltip as O}from"../tooltips/Tooltip.js";import{TitleSmall as T,BodyCaption as E,BodySecondary as w}from"../TypographyStyle.js";import S from"./DataSourceInfoFooter.js";import{SourceInfoDetailsStyle as L}from"./DataSourcePanel.style.js";import{intentConfig as N}from"./IntentConfig.js";import{DescriptionModal as F}from"./Modals/DescriptionModal.js";import{CustomDataType as A}from"./model.js";const k=k=>{var _,D;const{appType:R,storeId:P,messageSource:B,setMessageSourcePanel:U,hideCloseButton:K,isSourceInfoFetched:M,allSourceInfoDetail:W,ChecklistType:$,title:H,zeroStateButton:q,editableSources:Q,preFillTrainingSourceCount:G,redirect:Y,footerButtonOption:z,fetchTrainingSourceCount:X,fetchProductFAQCount:V,productSourceData:J,reasonForAiGeneratedResponse:Z,showAiResponseReason:ee,productSearchRule:te,onEditProductSearchRule:se}=k,{sources:ie}=B,oe=["blog","article","page","policy"],[ne,re]=h(!1),[le,ce]=h(!1),[ae,de]=h(!1),[pe,ue]=h(0),[ge,xe]=h(),[he,je]=h(null!=G?G:{}),[me,fe]=h(!1),[ye,ve]=h(!1),Ce={};N.forEach((t=>{let{key:s,type:i,tagText:o}=t;$[s]&&(Ce[$[s]]=e.jsx(I,{theme:"light",type:i,tagText:o,cursor:"pointer"}))}));const be=ie.filter((e=>"PRODUCTS"==e.type||"Products"==e.subTitle||e.productId)),Ie=ie.filter((e=>"PRODUCTS"!=e.type&&"Products"!=e.subTitle&&!e.productId)),Oe=j((()=>{const e={};return["STORE_INFORMATION","CONTACT_INFO","STORE_LOCATION","SHIPPING_POLICY","RETURN_AND_REFUND","SALES_AND_OFFERS","SALES_AND_OFFERS_ISSUES","PRODUCT_CUSTOMISATION","PAYMENT_METHODS","CHECKOUT_ENQUIRY","ORDER_ENQUIRY"].forEach((t=>{$[t]&&(e[$[t]]=$[t])})),["COLLABORATION","SUBSCRIPTION_ENQUIRY"].forEach((t=>{e[t]=t})),e}),[$]);m((()=>{var e,t,s,i;if(!(null==B?void 0:B.messageId))return;re(!0),ce(!0),de(!1!==(null===(t=null===(e=B.sources)||void 0===e?void 0:e[0])||void 0===t?void 0:t.isTrainable)||!!(null===(i=null===(s=B.sources)||void 0===s?void 0:s[0])||void 0===i?void 0:i.insights));const o=B.sources.filter((e=>!!e.productId)).map((e=>e.productId)),n=Array.from(new Set(o)).filter((e=>!!e));V(P,n).then((e=>ue(e))).then((()=>{G?(je(G),setTimeout((()=>{re(!1),ce(!1)}),100)):(setTimeout((()=>re(!1)),100),X(P).then((e=>je(e))).then((()=>setTimeout((()=>{ce(!1)}),100))))}))}),[V,X,null==B?void 0:B.messageId,B.sources,G,P]);const Te=e=>!!(e&&0===e.length||(null==B?void 0:B.isUnsatisfactoryAnswer)),Ee=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];var s;return"custom"==e?e=A.FILES:oe.includes(e)?e=A.FETCHED_LINKS:"url"==e?e=A.WEBSITE_LINKS:"text"===e?e=A.TEXTS:"faq"===e&&(e=A.FAQ),t?e:null===(s=null==e?void 0:e.toLowerCase())||void 0===s?void 0:s.replace(/_/g," ")},we=e=>e?"faq"==e.toLocaleLowerCase()?"FAQ":"openai"==e.toLocaleLowerCase()?"OPENAI":"files"==e.toLocaleLowerCase()?"PDF":"texts"==e.toLocaleLowerCase()?"Custom text":((e=(e=e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).replace("_"," ")).endsWith("s")&&(e=e.slice(0,-1)),e.replace("Website","Manual")):"",Se=t=>"products"==t||"product"==t?e.jsx(s,{height:16,width:16,color:f.content.secondary}):"files"==t?e.jsx(l,{height:16,width:16,color:f.content.secondary}):"website links"==t||"fetched links"==t?e.jsx(x,{height:16,width:16,color:f.content.secondary}):"faq"==t?e.jsx(c,{height:16,width:16,color:f.content.secondary}):"texts"==t?e.jsx(g,{height:16,width:16,color:f.content.secondary}):e.jsx(d,{height:16,width:16,color:f.content.secondary}),Le=e=>{const t=e.replace(/(<([^>]+)>)/gi,""),s=document.createElement("textarea");return s.innerHTML=t,s.value};if(ne||!M)return e.jsx(L,{children:e.jsx(C,{boxes:[{width:"100px",height:"16px"},{width:"0",height:"4px"},{width:"100%",height:"32px"},{width:"100%",height:"32px"},{width:"100%",height:"32px"},{width:"100%",height:"32px"},{width:"0",height:"4px"},{width:"100%",height:"16px"}]})});const Ne=s=>{const{title:n,count:r,isExpanded:l,onToggle:c,children:a}=s;return e.jsxs("div",{children:[e.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 12px",cursor:"pointer"},onClick:c},{children:[e.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",gap:"8px"}},{children:[e.jsx(E,Object.assign({style:{fontWeight:"600"}},{children:n})),R===t.MANIFEST?e.jsx("div",Object.assign({style:{backgroundColor:f.surface.subdued,color:f.content.secondary,padding:"2px 8px",borderRadius:"12px",fontSize:"12px",fontWeight:"500"}},{children:r})):e.jsx(e.Fragment,{})]})),e.jsx(e.Fragment,{children:R===t.BIK?e.jsx(e.Fragment,{}):l?e.jsx(i,{width:20,height:20,color:f.content.primary}):e.jsx(o,{width:20,height:20,color:f.content.primary})})]})),l&&a]})};return e.jsxs(e.Fragment,{children:[e.jsx(L,{children:e.jsxs(e.Fragment,{children:[e.jsxs("div",Object.assign({className:"pop-up-header",style:{display:"flex",flexDirection:"column",paddingBottom:"12px"}},{children:[!!H&&e.jsx(T,{children:H}),e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",alignItems:"center"}},{children:[e.jsx(E,Object.assign({color:f.content.secondary},{children:"Intent"})),null!==(_=Ce[B.intent])&&void 0!==_?_:Ce.GENERIC,!K&&e.jsx("div",Object.assign({style:{display:"flex",marginLeft:"auto",cursor:"pointer"},onClick:()=>U(void 0)},{children:e.jsx(n,{height:20,width:20,color:f.content.secondary})}))]})),te&&e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"12px",marginTop:"6px"}},{children:[e.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",justifyContent:"space-between"}},{children:[e.jsx(w,Object.assign({color:f.content.primary},{children:te.rule_name})),se&&te.rule_id&&e.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",gap:"8px"}},{children:[e.jsx(E,Object.assign({color:f.content.secondary},{children:"Edit search rule"})),e.jsx(v,{Icon:r,height:16,width:16,bordered:!0,iconColor:f.content.secondary,onClick:()=>se(te.rule_id)})]}))]})),te.keywords&&te.keywords.length>0&&e.jsx("div",Object.assign({style:{display:"flex",flexWrap:"wrap",gap:"6px",padding:"12px",backgroundColor:f.surface.subdued,borderRadius:"8px",border:`1px dashed ${f.stroke.primary}`}},{children:te.keywords.map(((t,s)=>e.jsx(I,{tagText:t,theme:"light"},`keyword-${s}`)))}))]})),Te(ie)?e.jsx("div",Object.assign({style:{display:"flex",margin:"auto",justifyContent:"center",alignItems:"center",height:"calc(100vh - 300px)"}},{children:(()=>{var t,s;return e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",margin:"0px 30px",gap:"8px"}},{children:[e.jsx("div",Object.assign({style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"12px",backgroundColor:`${f.background.negative.light}`,borderRadius:"100px"}},{children:e.jsx(a,{width:24,height:24,color:f.stroke.negative.vibrant})})),e.jsx("div",Object.assign({style:{justifyContent:"center",alignItems:"center",marginBottom:"-4px"}},{children:e.jsx(T,{children:"Insufficient data"})})),e.jsx(w,Object.assign({color:f.content.secondary,style:{display:"flex",justifyContent:"center",textAlign:"center"}},{children:"No data available to answer this query. Add an FAQ to address it in the future"})),q&&e.jsx("div",Object.assign({style:{display:"flex",width:"100%"}},{children:e.jsx(y,{LeadingIcon:null!==(t=q.leadingIcon)&&void 0!==t?t:p,buttonText:null!==(s=q.title)&&void 0!==s?s:"Add FAQ",buttonType:"secondary",size:"small",matchParentWidth:!0,onClick:()=>{q.onClick()}})}))]}))})()})):e.jsx(I,{LeadingIcon:a,version:"2.0",type:"grey",theme:"light",alignIcon:"start",contentPadding:12,tagText:B.isEditable?`If any of the information is incorrect, update the original data source and sync it again. Alternatively, you can make local corrections directly in ${R===t.BIK?"BIK":"Manifest"}.`:"Edit the original source and save again to update the response"})]})),!Te(ie)&&e.jsxs("div",Object.assign({className:"info-container"},{children:[e.jsx(e.Fragment,{children:be.length>0&&e.jsx("div",Object.assign({className:"info-product-source"},{children:e.jsx(Ne,Object.assign({title:"Product Sources",count:be.length,isExpanded:R!==t.MANIFEST||me,onToggle:()=>fe(!me)},{children:e.jsx("div",Object.assign({className:"source",style:{padding:"0 12px",maxWidth:"100%"}},{children:be.map(((t,s)=>{var i,o,n,l;const c=Ee(t.type||t.subTitle||"OpenAI"),a=Ee(t.type||t.subTitle||"OpenAI",!0),d=we(c),p=null==Q?void 0:Q.includes(a),g=W[null!==(i=t.productId)&&void 0!==i?i:"Products"],x=t.title,h=t.productId&&(null==J?void 0:J[t.productId]),j=h&&h.metafield.join(", ");return e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"8px",padding:"16px 0px",borderBottom:s+1<(null==be?void 0:be.length)?`1px solid ${f.stroke.primary}`:"none"}},{children:[e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",justifyContent:"space-between",alignItems:"center"}},{children:[e.jsxs("div",Object.assign({style:{display:"flex",flex:1,gap:"8px",flexDirection:"row",alignItems:"center",justifyContent:"flex-start"}},{children:[Se(c),e.jsx(O,Object.assign({body:x,placement:"top"},{children:e.jsx(w,Object.assign({style:a==A.FETCHED_LINKS||a==A.WEBSITE_LINKS?{cursor:"pointer",textDecoration:"underline"}:{},color:f.content.primary,className:"clamp-title",onClick:()=>a==A.FETCHED_LINKS||a==A.WEBSITE_LINKS?Y(t):{}},{children:x}))}))]})),e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",justifyContent:"flex-end",alignItems:"center",gap:"4px",flex:"none"}},{children:[t.intent!==$.EMAIL_COLLECTION&&e.jsx(e.Fragment,{children:e.jsx(E,Object.assign({color:f.content.secondary},{children:d}))}),(t.link||t.docId)&&e.jsx("div",Object.assign({style:{cursor:"pointer",marginLeft:"0px"}},{children:p?e.jsx(v,{Icon:r,height:16,width:16,iconColor:f.content.secondary,onClick:()=>null==g?void 0:g.onEditClick(g.data,g.type),disabled:!g,disabledTooltip:"This source is deleted"}):e.jsx(v,{Icon:u,height:16,width:16,iconColor:f.content.secondary,disabled:"custom"===t.type&&!g,disabledTooltip:"This source is deleted",onClick:()=>Y(t)})}))]}))]})),h&&e.jsxs(E,{children:[e.jsx("span",Object.assign({className:"product-data-text1",onClick:()=>{var e;xe({title:x,description:Le(h.description),imageUrl:null!==(e=t.imageUrl)&&void 0!==e?e:"",onClose:()=>xe(void 0)})}},{children:`${null===(o=h.description)||void 0===o?void 0:o.length} characters description,`})),e.jsx("span",Object.assign({className:"product-data-text1",onClick:()=>h.onEditFaqClick(h.faqs)},{children:`${null===(n=h.faqs)||void 0===n?void 0:n.length} FAQs, `})),e.jsx("span",Object.assign({className:"product-data-text2"},{children:"and"})),e.jsx(O,Object.assign({body:j,placement:"top"},{children:e.jsx("span",Object.assign({className:"product-data-text1"},{children:`${null===(l=h.metafield)||void 0===l?void 0:l.length} metafields`}))}))]})]}),`info-${s}`)}))}))}))}))}),e.jsx(e.Fragment,{children:Ie.length>0&&e.jsx("div",Object.assign({className:"info-content-source"},{children:e.jsx(Ne,Object.assign({title:"Content Sources",count:Ie.length,isExpanded:R!==t.MANIFEST||ye,onToggle:()=>ve(!ye)},{children:e.jsx("div",Object.assign({className:"source",style:{padding:"0 12px",maxWidth:"100%"}},{children:Ie.map(((t,s)=>{var i,o,n,l,c,a,d,p,g,x,h,j,m,y,C,b,I;const T=Ee(t.type||t.subTitle||"OpenAI"),S=Ee(t.type||t.subTitle||"OpenAI",!0),L=we(T),N=null==Q?void 0:Q.includes(S),F="Products"===t.subTitle?W[null!==(i=t.productId)&&void 0!==i?i:"Products"]:W[null!==(o=t.docId)&&void 0!==o?o:""],k=S.toLowerCase()===(null===(n=A.FAQ)||void 0===n?void 0:n.toLowerCase())?"faq"===(null===(l=t.title)||void 0===l?void 0:l.toLowerCase())?t.subTitle:t.title:S.toLowerCase()===(null===(c=A.FILES)||void 0===c?void 0:c.toLowerCase())||S.toLowerCase()===(null===(a=A.FETCHED_LINKS)||void 0===a?void 0:a.toLowerCase())||S.toLowerCase()===(null===(d=A.TEXTS)||void 0===d?void 0:d.toLowerCase())?t.title:S.toLowerCase()===(null===(p=A.WEBSITE_LINKS)||void 0===p?void 0:p.toLowerCase())?t.title.split("/")[t.title.split("/").length-1].replace(/[^\w\s]/gi," ").replace(/^(.)(.*)$/,((e,t,s)=>t.toUpperCase()+s)):t.intent===$.EMAIL_COLLECTION?L:t.title,_="faq"===S.toLowerCase()?null!==(h=null!==(g=null==F?void 0:F.content)&&void 0!==g?g:null===(x=null==F?void 0:F.data)||void 0===x?void 0:x.answer)&&void 0!==h?h:"":S.toLowerCase()===(null===(j=A.FETCHED_LINKS)||void 0===j?void 0:j.toLowerCase())||S.toLowerCase()===(null===(m=A.WEBSITE_LINKS)||void 0===m?void 0:m.toLowerCase())||S.toLowerCase()===(null===(y=A.TEXTS)||void 0===y?void 0:y.toLowerCase())?null!==(I=null!==(C=null==F?void 0:F.content)&&void 0!==C?C:null===(b=null==F?void 0:F.data)||void 0===b?void 0:b.fileContentText)&&void 0!==I?I:"":t.intent===$.EMAIL_COLLECTION?"Collect leads before replying to messages":"";return e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"8px",padding:"16px 0px",borderBottom:s+1<(null==Ie?void 0:Ie.length)?`1px solid ${f.stroke.primary}`:"none"}},{children:[e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",justifyContent:"space-between",alignItems:"center"}},{children:[e.jsxs("div",Object.assign({style:{display:"flex",flex:1,gap:"8px",flexDirection:"row",alignItems:"center",justifyContent:"flex-start"}},{children:[Se(T),e.jsx(O,Object.assign({body:k,placement:"top"},{children:e.jsx(w,Object.assign({style:S==A.FETCHED_LINKS||S==A.WEBSITE_LINKS?{cursor:"pointer",textDecoration:"underline"}:{},color:f.content.primary,className:"clamp-title",onClick:()=>S==A.FETCHED_LINKS||S==A.WEBSITE_LINKS?Y(t):{}},{children:k}))}))]})),e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",justifyContent:"flex-end",alignItems:"center",gap:"4px",flex:"none"}},{children:[t.intent!==$.EMAIL_COLLECTION&&e.jsx(e.Fragment,{children:e.jsx(E,Object.assign({color:f.content.secondary},{children:L}))}),(t.link||t.docId)&&e.jsx("div",Object.assign({style:{cursor:"pointer",marginLeft:"0px"}},{children:N?e.jsx(v,{Icon:r,height:16,width:16,iconColor:f.content.secondary,onClick:()=>null==F?void 0:F.onEditClick(F.data,F.type),disabled:!F,disabledTooltip:"This source is deleted"}):e.jsx(v,{Icon:u,height:16,width:16,iconColor:f.content.secondary,disabled:"custom"===t.type&&!F,disabledTooltip:"This source is deleted",onClick:()=>Y(t)})}))]}))]})),(null!=_?_:"").trim()&&e.jsx("div",Object.assign({style:{padding:"4px 8px",border:`1px dashed ${f.stroke.primary}`,borderRadius:"4px",backgroundColor:f.surface.subdued}},{children:e.jsx(E,Object.assign({color:f.content.primary,className:"clamp-description"},{children:Le(null!=_?_:"").trim()}))}))]}),`info-${s}`)}))}))}))}))})]})),ae&&!Te(ie)&&e.jsx("div",Object.assign({className:"footer"},{children:e.jsx(S,{appType:R,storeId:P,messageSource:B,sourceIntent:null!==(D=B.intent)&&void 0!==D?D:$.GENERIC,faqCount:pe,trainingSourceCount:he,ShowTrainingDataSource:Oe,ChecklistType:$,footerButtonOption:z,isFooterLoading:le,reasonForAiGeneratedResponse:Z,showAiResponseReason:ee})}))]})}),ge&&e.jsx(b,Object.assign({header:"Product description",onClose:()=>xe(void 0),width:"30%"},{children:e.jsx(F,{title:ge.title,description:ge.description,imageUrl:ge.imageUrl,onClose:ge.onClose})}))]})};export{k as DataSourcePanel};
|