@bikdotai/bik-component-library 0.0.655-4 → 0.0.655-5

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.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../assets/icons/alert_triangle.svg.js"),o=require("../../assets/icons/plus.svg.js"),n=require("react"),i=require("../../constants/Theme.js"),r=require("../button/Button.js"),s=require("../TypographyStyle.js"),d=require("./DataSourcePanel.style.js"),l=require("./model.js");const a=n.memo((a=>{const{appType:c,sourceIntent:v,hideHeading:g,messageSource:h,trainingSourceCount:p={},ShowTrainingDataSource:m={},faqCount:T,ChecklistType:b,footerButtonOption:y}=a,j=m,[O,f]=n.useState(!0),[C,I]=n.useState(!0),[A,x]=n.useState({buttonTitle:"",redirectUrl:"",addFaqProps:{}}),[R,_]=n.useState({title:"",subTitle:""}),F=n.useMemo((()=>{const e=(null==p?void 0:p[v])||0;return e<=1?"There is "+e+"data source added to the identified intent":`There are ${e} data sources added to the identified intent`}),[p,v]),S=()=>{var e;(null==A?void 0:A.redirectUrl)?window.open(`${window.location.origin}${null==A?void 0:A.redirectUrl}`,"_self"):Object.keys(null!==(e=null==A?void 0:A.addFaqProps)&&void 0!==e?e:{}).length>0?null==y||y.onClick(A):(null==y?void 0:y.navigate)&&(null==y||y.navigate("/Training",{tab:"/"},{},!0))};return n.useEffect((()=>{var e,t,o,n,i,r,s,d,a,u,g,m;if(console.log("KB sourceIntent",v,h),v){if(null===(e=null==h?void 0:h.sources)||void 0===e?void 0:e.length)if(console.log("KB sourceIntent 1"),j[v])v===b.ORDER_ENQUIRY&&I(!1);else{console.log("KB sourceIntent 2");let e=null===(t=h.sources[0])||void 0===t?void 0:t.insights,y="";switch(console.log("KB sourceIntent 3"),v){case b.PRODUCT_DETAILS:"Product reviews"!==(null===(o=h.sources[0])||void 0===o?void 0:o.title)&&(e=`${T||"No"} FAQs added for this product`,y="Add product-specific information via FAQs to improve responses",x({buttonTitle:"Add FAQ",addFaqProps:{faqProducts:[{id:null===(n=h.sources[0])||void 0===n?void 0:n.productId,variantId:null===(i=h.sources[0])||void 0===i?void 0:i.variantId,name:null===(r=h.sources[0])||void 0===r?void 0:r.title,imageUrl:null===(s=h.sources[0])||void 0===s?void 0:s.imageUrl}]},redirectUrl:""}));break;case b.ORDER_MODIFICATION:e=(null==p?void 0:p[v])?void 0:"Customers who are looking to modify their orders would be redirected to your live agents via the agent handover flow.",e&&x({buttonTitle:"Manage agent handover",redirectUrl:c==l.AppType.MANIFEST?"/customise?tab=AgentHandover":"/training",addFaqProps:{}});break;case b.ORDER_CANCELLATION:e=(null==p?void 0:p[v])?void 0:"Customers who are looking to cancel their orders would be redirected to your live agents via the agent handover flow.",x({buttonTitle:"Manage agent handover",redirectUrl:c==l.AppType.MANIFEST?"/customise?tab=AgentHandover":"/training",addFaqProps:{}});break;case b.ORDER_TRACKING:if("ORDER_NOT_FOUND"===(null===(d=h.sources[0])||void 0===d?void 0:d.subIntent))break;x({buttonTitle:"Add order tracking link",redirectUrl:c==l.AppType.MANIFEST?"/training/order-management":"/training",addFaqProps:{}});break;case b.PRODUCT_SEARCH:if("QUIZ"===(null===(a=h.sources[0])||void 0===a?void 0:a.type))break;if(-1!==(null===(m=null===(g=null===(u=null==h?void 0:h.sources)||void 0===u?void 0:u[0])||void 0===g?void 0:g.title)||void 0===m?void 0:m.toLowerCase().indexOf("collection"))){e="Collections are recommended by matching queries with collection names and descriptions. Add relevant keywords to your collection description to improve results.";break}e="Products are recommended by matching queries with product names, descriptions, tags, and collections. Add relevant keywords and tags to your products to improve results."}_({title:null!=e?e:"",subTitle:y})}(j[v]||[b.PRODUCT_DETAILS,b.ORDER_MODIFICATION,b.ORDER_CANCELLATION,b.ORDER_TRACKING].includes(v))&&f(!1)}}),[null==h?void 0:h.messageId,p,v,null==h?void 0:h.sources,j,b,T,c,h]),n.useEffect((()=>{console.log("KB change",R,R)}),[A,R]),e.jsx(d.SourceInfoFooterStyle,{children:!(null==R?void 0:R.title)&&p&&v in p?e.jsxs(e.Fragment,{children:[e.jsx(u,{hideHeading:null!=g&&g}),e.jsxs("div",Object.assign({className:"source_info_details "+(p[v]>0?"":"no_data_source")},{children:[p[v]>0&&C?e.jsxs(e.Fragment,{children:[e.jsx(s.BodyCaption,{children:F}),e.jsx(s.BodyCaption,Object.assign({color:i.COLORS.content.secondary},{children:"Improve responses by adding more data sources for the identified intent"}))]}):C&&e.jsxs("div",Object.assign({className:"no_data_source_title"},{children:[e.jsx(t.default,{width:15,height:15,color:i.COLORS.content.negative,style:{marginTop:2}}),e.jsx(s.BodyCaption,{children:"No data sources added to the identified link"})]})),!y||y.hideAddDataButton||O?e.jsx(e.Fragment,{}):e.jsx(r.Button,{size:"small",buttonType:"tertiary",LeadingIcon:o.default,buttonText:(null==A?void 0:A.buttonTitle.length)>0?null==A?void 0:A.buttonTitle:"Add relevant data",matchParentWidth:!0,onClick:()=>S(),style:{backgroundColor:"unset"}})]}))]}):e.jsxs(e.Fragment,{children:[e.jsx(u,{hideHeading:null!=g&&g}),e.jsxs("div",Object.assign({className:"source_info_details"},{children:[C&&e.jsxs(e.Fragment,{children:[e.jsx(s.BodyCaption,{children:null==R?void 0:R.title}),e.jsx(s.BodyCaption,Object.assign({color:i.COLORS.content.secondary},{children:null==R?void 0:R.subTitle}))]}),!y||y.hideAddDataButton||O?e.jsx(e.Fragment,{}):e.jsx(r.Button,{size:"small",buttonType:"tertiary",LeadingIcon:o.default,buttonText:(null==A?void 0:A.buttonTitle.length)>0?null==A?void 0:A.buttonTitle:"Add relevant data",matchParentWidth:!0,onClick:()=>S(),style:{backgroundColor:"unset"}})]}))]})})})),u=n.memo((t=>t.hideHeading?null:e.jsx(s.BodyCaption,Object.assign({color:i.COLORS.content.secondary},{children:"Training insights"}))));u.displayName="TrainingInsightsHeading",a.displayName="SourceInfoFooter",exports.default=a;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../assets/icons/alert_triangle.svg.js"),o=require("../../assets/icons/plus.svg.js"),n=require("react"),i=require("../../constants/Theme.js"),r=require("../button/Button.js"),s=require("../TypographyStyle.js"),d=require("./DataSourcePanel.style.js"),l=require("./model.js");const a=n.memo((a=>{const{appType:c,sourceIntent:v,hideHeading:g,messageSource:h,trainingSourceCount:p={},ShowTrainingDataSource:m={},faqCount:T,ChecklistType:b,footerButtonOption:y}=a,j=m,[O,f]=n.useState(!0),[C,I]=n.useState(!0),[A,x]=n.useState({buttonTitle:"",redirectUrl:"",addFaqProps:{}}),[R,_]=n.useState({title:"",subTitle:""}),F=n.useMemo((()=>{const e=(null==p?void 0:p[v])||0;return e<=1?"There is "+e+"data source added to the identified intent":`There are ${e} data sources added to the identified intent`}),[p,v]),S=()=>{var e;(null==A?void 0:A.redirectUrl)?window.open(`${window.location.origin}${null==A?void 0:A.redirectUrl}`,"_self"):Object.keys(null!==(e=null==A?void 0:A.addFaqProps)&&void 0!==e?e:{}).length>0?null==y||y.onClick(A):(null==y?void 0:y.navigate)&&(null==y||y.navigate("/Training",{tab:"/"},{},!0))};return n.useEffect((()=>{var e,t,o,n,i,r,s,d,a,u,g,m;if(console.log("KB sourceIntent",v,h),v){if(null===(e=null==h?void 0:h.sources)||void 0===e?void 0:e.length)if(console.log("KB sourceIntent 1",j),j[v]){console.log("KB sourceIntent 2");let e=null===(t=h.sources[0])||void 0===t?void 0:t.insights,y="";switch(console.log("KB sourceIntent 3"),v){case b.PRODUCT_DETAILS:"Product reviews"!==(null===(o=h.sources[0])||void 0===o?void 0:o.title)&&(e=`${T||"No"} FAQs added for this product`,y="Add product-specific information via FAQs to improve responses",x({buttonTitle:"Add FAQ",addFaqProps:{faqProducts:[{id:null===(n=h.sources[0])||void 0===n?void 0:n.productId,variantId:null===(i=h.sources[0])||void 0===i?void 0:i.variantId,name:null===(r=h.sources[0])||void 0===r?void 0:r.title,imageUrl:null===(s=h.sources[0])||void 0===s?void 0:s.imageUrl}]},redirectUrl:""}));break;case b.ORDER_MODIFICATION:e=(null==p?void 0:p[v])?void 0:"Customers who are looking to modify their orders would be redirected to your live agents via the agent handover flow.",e&&x({buttonTitle:"Manage agent handover",redirectUrl:c==l.AppType.MANIFEST?"/customise?tab=AgentHandover":"/training",addFaqProps:{}});break;case b.ORDER_CANCELLATION:e=(null==p?void 0:p[v])?void 0:"Customers who are looking to cancel their orders would be redirected to your live agents via the agent handover flow.",x({buttonTitle:"Manage agent handover",redirectUrl:c==l.AppType.MANIFEST?"/customise?tab=AgentHandover":"/training",addFaqProps:{}});break;case b.ORDER_TRACKING:if("ORDER_NOT_FOUND"===(null===(d=h.sources[0])||void 0===d?void 0:d.subIntent))break;x({buttonTitle:"Add order tracking link",redirectUrl:c==l.AppType.MANIFEST?"/training/order-management":"/training",addFaqProps:{}});break;case b.PRODUCT_SEARCH:if("QUIZ"===(null===(a=h.sources[0])||void 0===a?void 0:a.type))break;if(-1!==(null===(m=null===(g=null===(u=null==h?void 0:h.sources)||void 0===u?void 0:u[0])||void 0===g?void 0:g.title)||void 0===m?void 0:m.toLowerCase().indexOf("collection"))){e="Collections are recommended by matching queries with collection names and descriptions. Add relevant keywords to your collection description to improve results.";break}e="Products are recommended by matching queries with product names, descriptions, tags, and collections. Add relevant keywords and tags to your products to improve results."}_({title:null!=e?e:"",subTitle:y})}else v===b.ORDER_ENQUIRY&&I(!1);(j[v]||[b.PRODUCT_DETAILS,b.ORDER_MODIFICATION,b.ORDER_CANCELLATION,b.ORDER_TRACKING].includes(v))&&f(!1)}}),[null==h?void 0:h.messageId,p,v,null==h?void 0:h.sources,j,b,T,c,h]),n.useEffect((()=>{console.log("KB change",R,R)}),[A,R]),e.jsx(d.SourceInfoFooterStyle,{children:!(null==R?void 0:R.title)&&p&&v in p?e.jsxs(e.Fragment,{children:[e.jsx(u,{hideHeading:null!=g&&g}),e.jsxs("div",Object.assign({className:"source_info_details "+(p[v]>0?"":"no_data_source")},{children:[p[v]>0&&C?e.jsxs(e.Fragment,{children:[e.jsx(s.BodyCaption,{children:F}),e.jsx(s.BodyCaption,Object.assign({color:i.COLORS.content.secondary},{children:"Improve responses by adding more data sources for the identified intent"}))]}):C&&e.jsxs("div",Object.assign({className:"no_data_source_title"},{children:[e.jsx(t.default,{width:15,height:15,color:i.COLORS.content.negative,style:{marginTop:2}}),e.jsx(s.BodyCaption,{children:"No data sources added to the identified link"})]})),!y||y.hideAddDataButton||O?e.jsx(e.Fragment,{}):e.jsx(r.Button,{size:"small",buttonType:"tertiary",LeadingIcon:o.default,buttonText:(null==A?void 0:A.buttonTitle.length)>0?null==A?void 0:A.buttonTitle:"Add relevant data",matchParentWidth:!0,onClick:()=>S(),style:{backgroundColor:"unset"}})]}))]}):e.jsxs(e.Fragment,{children:[e.jsx(u,{hideHeading:null!=g&&g}),e.jsxs("div",Object.assign({className:"source_info_details"},{children:[C&&e.jsxs(e.Fragment,{children:[e.jsx(s.BodyCaption,{children:null==R?void 0:R.title}),e.jsx(s.BodyCaption,Object.assign({color:i.COLORS.content.secondary},{children:null==R?void 0:R.subTitle}))]}),!y||y.hideAddDataButton||O?e.jsx(e.Fragment,{}):e.jsx(r.Button,{size:"small",buttonType:"tertiary",LeadingIcon:o.default,buttonText:(null==A?void 0:A.buttonTitle.length)>0?null==A?void 0:A.buttonTitle:"Add relevant data",matchParentWidth:!0,onClick:()=>S(),style:{backgroundColor:"unset"}})]}))]})})})),u=n.memo((t=>t.hideHeading?null:e.jsx(s.BodyCaption,Object.assign({color:i.COLORS.content.secondary},{children:"Training insights"}))));u.displayName="TrainingInsightsHeading",a.displayName="SourceInfoFooter",exports.default=a;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../assets/icons/boxV2.svg.js"),i=require("../../assets/icons/cross.svg.js"),o=require("../../assets/icons/edit.svg.js"),s=require("../../assets/icons/filePdf.svg.js"),n=require("../../assets/icons/help.svg.js"),a=require("../../assets/icons/info.svg.js"),r=require("../../assets/icons/openai.svg.js"),l=require("../../assets/icons/plus.svg.js"),d=require("../../assets/icons/redirect.svg.js"),c=require("../../assets/icons/text_t9.svg.js"),u=require("../../assets/icons/website.svg.js"),p=require("react"),y=require("../../constants/Theme.js"),g=require("../button/Button.js"),C=require("../icon-button/IconButton.js"),T=require("../shimmer/ShimmerComponent/BikShimmer.js"),h=require("../tag/Tag.js"),x=require("../tooltips/Tooltip.js"),O=require("../TypographyStyle.js"),S=require("./DataSourceInfoFooter.js"),I=require("./DataSourcePanel.style.js"),v=require("./model.js");exports.DataSourcePanel=E=>{var j,f;const{appType:m,storeId:L,messageSource:b,setMessageSourcePanel:N,hideCloseButton:R,isSourceInfoFetched:_,allSourceInfoDetail:D,ChecklistType:A,title:w,zeroStateButton:k,editableSources:F,preFillTrainingSourceCount:P,redirect:q,footerButtonOption:U,fetchTrainingSourceCount:B,fetchProductFAQCount:M}=E,{sources:H}=b,K=["blog","article","page","policy"],[Q,G]=p.useState(!1),[Y,W]=p.useState(!1),[$,z]=p.useState(0),[X,V]=p.useState(null!=P?P:{}),Z={};[{key:"GENERIC",type:"neutral",tagText:"Generic"},{key:"STORE_INFORMATION",type:"blue",tagText:"Store information"},{key:"SHIPPING_POLICY",type:"positive",tagText:"Shipping policy"},{key:"RETURN_AND_REFUND",type:"purple",tagText:"Returns & refund policy"},{key:"CONTACT_INFO",type:"warning",tagText:"Contact details"},{key:"STORE_LOCATION",type:"grey",tagText:"Store location"},{key:"SALES_AND_OFFERS",type:"purple",tagText:"Offers & rewards"},{key:"PRODUCT_CUSTOMISATION",type:"blue",tagText:"Product customisation"},{key:"PRODUCT_DETAILS",type:"blue",tagText:"Product details"},{key:"PAYMENT_METHODS",type:"positive",tagText:"Payment methods"},{key:"ORDER_TRACKING",type:"warning",tagText:"Order tracking"},{key:"PRODUCT_SEARCH",type:"neutral",tagText:"Product search"},{key:"PURCHASE",type:"blue",tagText:"Purchase"},{key:"CONNECT_TO_AGENT",type:"purple",tagText:"Talk to a person"},{key:"CHECKOUT_ENQUIRY",type:"purple",tagText:"Checkout enquiry"},{key:"ORDER_CANCELLATION",type:"positive",tagText:"Order cancellation"},{key:"ORDER_ENQUIRY",type:"neutral",tagText:"Order enquiry"},{key:"ORDER_MODIFICATION",type:"blue",tagText:"Order modification"},{key:"SUBSCRIPTION_ENQUIRY",type:"warning",tagText:"Subscription enquiry"},{key:"SALES_AND_OFFERS_ISSUES",type:"grey",tagText:"Offer-related enquiries"},{key:"COLLABORATION",type:"positive",tagText:"Collaboration"},{key:"QUIZ_GENERATION",type:"warning",tagText:"Start the quiz"},{key:"SIMILAR_PRODUCT",type:"blue",tagText:"Similar Product"},{key:"EMAIL_COLLECTION",type:"warning",tagText:"Email Collection"},{key:"ADD_TO_CART_SUCCESS",type:"blue",tagText:"Add to Cart Success"},{key:"ADD_TO_CART_SUCCESS_MESSAGE",type:"blue",tagText:"Add to Cart Success Message"},{key:"FEEDBACK",type:"blue",tagText:"Feedback"},{key:"PHONE_NUMBER_COLLECTION",type:"blue",tagText:"Phone no. collection"}].forEach((t=>{let{key:i,type:o,tagText:s}=t;A[i]&&(Z[A[i]]=e.jsx(h.Tag,{theme:"light",type:o,tagText:s,cursor:"pointer"}))}));const J=p.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=>{A[t]&&(e[A[t]]=A[t])})),["COLLABORATION","SUBSCRIPTION_ENQUIRY"].forEach((t=>{e[t]=t})),e}),[]);p.useEffect((()=>{var e,t,i,o;if(!(null==b?void 0:b.messageId))return;G(!0),W(!1!==(null===(t=null===(e=b.sources)||void 0===e?void 0:e[0])||void 0===t?void 0:t.isTrainable)||!!(null===(o=null===(i=b.sources)||void 0===i?void 0:i[0])||void 0===o?void 0:o.insights));const s=b.sources.filter((e=>!!e.productId)).map((e=>e.productId)),n=Array.from(new Set(s)).filter((e=>!!e));M(L,n).then((e=>z(e))).then((()=>{P||B(L).then((e=>V(e))).then((()=>{setTimeout((()=>G(!1)),100)}))}))}),[M,B,null==b?void 0:b.messageId,b.sources,P,L]);const ee=e=>!(0!==e.length&&!(null==b?void 0:b.isUnsatisfactoryAnswer)),te=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];var i;return"custom"==e?e=v.CustomDataType.FILES:K.includes(e)?e=v.CustomDataType.FETCHED_LINKS:"url"==e?e=v.CustomDataType.WEBSITE_LINKS:"text"===e?e=v.CustomDataType.TEXTS:"faq"===e&&(e=v.CustomDataType.FAQ),t?e:null===(i=null==e?void 0:e.toLowerCase())||void 0===i?void 0:i.replace(/_/g," ")};return Q||!_?e.jsx(I.SourceInfoDetailsStyle,{children:e.jsx(T.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"}]})}):e.jsx(e.Fragment,{children:e.jsx(I.SourceInfoDetailsStyle,{children:e.jsxs(e.Fragment,{children:[e.jsxs("div",Object.assign({className:"pop-up-header",style:{display:"flex",flexDirection:"column",paddingBottom:"12px"}},{children:[!!w&&e.jsx(O.TitleSmall,{children:w}),e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",alignItems:"center"}},{children:[e.jsx(O.BodyCaption,Object.assign({color:y.COLORS.content.secondary},{children:"Intent"})),null!==(j=Z[b.intent])&&void 0!==j?j:Z.GENERIC,!R&&e.jsx("div",Object.assign({style:{display:"flex",marginLeft:"auto",cursor:"pointer"},onClick:()=>N(void 0)},{children:e.jsx(i.default,{height:20,width:20,color:y.COLORS.content.secondary})}))]})),ee(H)?e.jsx("div",Object.assign({style:{display:"flex",margin:"auto",justifyContent:"center",alignItems:"center",height:"calc(100vh - 300px)"}},{children:(()=>{var t,i;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:`${y.COLORS.background.negative.light}`,borderRadius:"100px"}},{children:e.jsx(a.default,{width:24,height:24,color:y.COLORS.stroke.negative.vibrant})})),e.jsx("div",Object.assign({style:{justifyContent:"center",alignItems:"center",marginBottom:"-4px"}},{children:e.jsx(O.TitleSmall,{children:"Insufficient data"})})),e.jsx(O.BodySecondary,Object.assign({color:y.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"})),k&&e.jsx("div",Object.assign({style:{display:"flex",width:"100%"}},{children:e.jsx(g.Button,{LeadingIcon:null!==(t=k.leadingIcon)&&void 0!==t?t:l.default,buttonText:null!==(i=k.title)&&void 0!==i?i:"Add FAQ",buttonType:"secondary",size:"small",matchParentWidth:!0,onClick:()=>{k.onClick()}})}))]}))})()})):e.jsx(h.Tag,{LeadingIcon:a.default,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 Manifest.":"Edit the original source and save again to update the response"})]})),!ee(H)&&e.jsx("div",Object.assign({className:"info-container"},{children:e.jsx("div",Object.assign({style:{padding:"0 8px",maxWidth:"100%"}},{children:H.map(((i,a)=>{var l,p,g,T,h,S,I,E,j,f,m,L,b,N,R,_,w;const k=te(i.type||i.subTitle||"OpenAI"),P=te(i.type||i.subTitle||"OpenAI",!0),U=(B=k)?"faq"==B.toLocaleLowerCase()?"FAQ":"openai"==B.toLocaleLowerCase()?"OPENAI":"files"==B.toLocaleLowerCase()?"PDF":"texts"==B.toLocaleLowerCase()?"Custom text":((B=(B=B.charAt(0).toUpperCase()+B.slice(1).toLowerCase()).replace("_"," ")).endsWith("s")&&(B=B.slice(0,-1)),B.replace("Website","Manual")):"";var B;const M=null==F?void 0:F.includes(P),H="Products"===i.subTitle?D[null!==(l=i.productId)&&void 0!==l?l:"Products"]:D[null!==(p=i.docId)&&void 0!==p?p:""],K=P.toLowerCase()===(null===(g=v.CustomDataType.FAQ)||void 0===g?void 0:g.toLowerCase())?"faq"===(null===(T=i.title)||void 0===T?void 0:T.toLowerCase())?i.subTitle:i.title:P.toLowerCase()===(null===(h=v.CustomDataType.FILES)||void 0===h?void 0:h.toLowerCase())||P.toLowerCase()===(null===(S=v.CustomDataType.FETCHED_LINKS)||void 0===S?void 0:S.toLowerCase())||P.toLowerCase()===(null===(I=v.CustomDataType.TEXTS)||void 0===I?void 0:I.toLowerCase())?i.title:P.toLowerCase()===(null===(E=v.CustomDataType.WEBSITE_LINKS)||void 0===E?void 0:E.toLowerCase())?i.title.split("/")[i.title.split("/").length-1].replace(/[^\w\s]/gi," ").replace(/^(.)(.*)$/,((e,t,i)=>t.toUpperCase()+i)):i.intent===A.EMAIL_COLLECTION?U:i.title,Q="faq"===P.toLowerCase()?null!==(m=null!==(j=null==H?void 0:H.content)&&void 0!==j?j:null===(f=null==H?void 0:H.data)||void 0===f?void 0:f.answer)&&void 0!==m?m:"":P.toLowerCase()===(null===(L=v.CustomDataType.FETCHED_LINKS)||void 0===L?void 0:L.toLowerCase())||P.toLowerCase()===(null===(b=v.CustomDataType.WEBSITE_LINKS)||void 0===b?void 0:b.toLowerCase())||P.toLowerCase()===(null===(N=v.CustomDataType.TEXTS)||void 0===N?void 0:N.toLowerCase())?null!==(w=null!==(R=null==H?void 0:H.content)&&void 0!==R?R:null===(_=null==H?void 0:H.data)||void 0===_?void 0:_.fileContentText)&&void 0!==w?w:"":i.intent===A.EMAIL_COLLECTION?"Collect leads before replying to messages":"";return e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"8px",padding:"24px 0px",borderBottom:`1px solid ${y.COLORS.stroke.primary}`}},{children:[e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",justifyContent:"space-between",alignItems:"center"}},{children:[e.jsx("div",Object.assign({style:{flex:1}},{children:e.jsx(x.Tooltip,Object.assign({body:K,placement:"top"},{children:e.jsx(O.BodySecondary,Object.assign({style:P==v.CustomDataType.FETCHED_LINKS||P==v.CustomDataType.WEBSITE_LINKS?{cursor:"pointer",textDecoration:"underline"}:{},color:y.COLORS.content.primary,className:"clamp-title",onClick:()=>P==v.CustomDataType.FETCHED_LINKS||P==v.CustomDataType.WEBSITE_LINKS?q(i):{}},{children:K}))}))})),e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",justifyContent:"flex-end",alignItems:"center",gap:"4px",flex:"none"}},{children:[i.intent!==A.EMAIL_COLLECTION&&e.jsxs(e.Fragment,{children:[(Y=k,"products"==Y||"product"==Y?e.jsx(t.default,{height:16,width:16,color:y.COLORS.content.secondary}):"files"==Y?e.jsx(s.default,{height:16,width:16,color:y.COLORS.content.secondary}):"website links"==Y||"fetched links"==Y?e.jsx(u.default,{height:16,width:16,color:y.COLORS.content.secondary}):"faq"==Y?e.jsx(n.default,{height:16,width:16,color:y.COLORS.content.secondary}):"texts"==Y?e.jsx(c.default,{height:16,width:16,color:y.COLORS.content.secondary}):e.jsx(r.default,{height:16,width:16,color:y.COLORS.content.secondary})),e.jsx(O.BodyCaption,Object.assign({color:y.COLORS.content.secondary},{children:U}))]}),(i.link||i.docId)&&e.jsx("div",Object.assign({style:{cursor:"pointer",marginLeft:"4px"}},{children:M?e.jsx(C.IconButton,{Icon:o.default,height:16,width:16,bordered:!0,onClick:()=>null==H?void 0:H.onEditClick(H.data,H.type),disabled:!H,disabledTooltip:"This source is deleted"}):e.jsx(C.IconButton,{Icon:d.default,height:16,width:16,bordered:!0,disabled:"custom"===i.type&&!H,disabledTooltip:"This source is deleted",onClick:()=>q(i)})}))]}))]})),(null!=Q?Q:"").trim()&&e.jsx("div",Object.assign({style:{padding:"4px 8px",border:`1px dashed ${y.COLORS.stroke.primary}`,borderRadius:"4px",backgroundColor:y.COLORS.surface.subdued}},{children:e.jsx(O.BodyCaption,Object.assign({color:y.COLORS.content.primary,className:"clamp-description"},{children:(G=null!=Q?Q:"",G.replace(/(<([^>]+)>)/gi,"")).trim()}))}))]}),`info-${a}`);var G,Y}))}))})),Y&&!ee(H)&&e.jsx("div",Object.assign({className:"footer"},{children:e.jsx(S.default,{appType:m,storeId:L,messageSource:b,sourceIntent:null!==(f=b.intent)&&void 0!==f?f:A.GENERIC,faqCount:$,trainingSourceCount:X,ShowTrainingDataSource:J,ChecklistType:A,footerButtonOption:U})}))]})})})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../assets/icons/boxV2.svg.js"),i=require("../../assets/icons/cross.svg.js"),o=require("../../assets/icons/edit.svg.js"),s=require("../../assets/icons/filePdf.svg.js"),n=require("../../assets/icons/help.svg.js"),a=require("../../assets/icons/info.svg.js"),r=require("../../assets/icons/openai.svg.js"),l=require("../../assets/icons/plus.svg.js"),d=require("../../assets/icons/redirect.svg.js"),c=require("../../assets/icons/text_t9.svg.js"),u=require("../../assets/icons/website.svg.js"),p=require("react"),y=require("../../constants/Theme.js"),g=require("../button/Button.js"),C=require("../icon-button/IconButton.js"),T=require("../shimmer/ShimmerComponent/BikShimmer.js"),h=require("../tag/Tag.js"),x=require("../tooltips/Tooltip.js"),O=require("../TypographyStyle.js"),S=require("./DataSourceInfoFooter.js"),I=require("./DataSourcePanel.style.js"),v=require("./model.js");exports.DataSourcePanel=E=>{var j,f;const{appType:m,storeId:L,messageSource:b,setMessageSourcePanel:N,hideCloseButton:R,isSourceInfoFetched:_,allSourceInfoDetail:D,ChecklistType:A,title:w,zeroStateButton:k,editableSources:F,preFillTrainingSourceCount:P,redirect:q,footerButtonOption:U,fetchTrainingSourceCount:B,fetchProductFAQCount:M}=E,{sources:H}=b,K=["blog","article","page","policy"],[Q,G]=p.useState(!1),[Y,W]=p.useState(!1),[$,z]=p.useState(0),[X,V]=p.useState(null!=P?P:{}),Z={};[{key:"GENERIC",type:"neutral",tagText:"Generic"},{key:"STORE_INFORMATION",type:"blue",tagText:"Store information"},{key:"SHIPPING_POLICY",type:"positive",tagText:"Shipping policy"},{key:"RETURN_AND_REFUND",type:"purple",tagText:"Returns & refund policy"},{key:"CONTACT_INFO",type:"warning",tagText:"Contact details"},{key:"STORE_LOCATION",type:"grey",tagText:"Store location"},{key:"SALES_AND_OFFERS",type:"purple",tagText:"Offers & rewards"},{key:"PRODUCT_CUSTOMISATION",type:"blue",tagText:"Product customisation"},{key:"PRODUCT_DETAILS",type:"blue",tagText:"Product details"},{key:"PAYMENT_METHODS",type:"positive",tagText:"Payment methods"},{key:"ORDER_TRACKING",type:"warning",tagText:"Order tracking"},{key:"PRODUCT_SEARCH",type:"neutral",tagText:"Product search"},{key:"PURCHASE",type:"blue",tagText:"Purchase"},{key:"CONNECT_TO_AGENT",type:"purple",tagText:"Talk to a person"},{key:"CHECKOUT_ENQUIRY",type:"purple",tagText:"Checkout enquiry"},{key:"ORDER_CANCELLATION",type:"positive",tagText:"Order cancellation"},{key:"ORDER_ENQUIRY",type:"neutral",tagText:"Order enquiry"},{key:"ORDER_MODIFICATION",type:"blue",tagText:"Order modification"},{key:"SUBSCRIPTION_ENQUIRY",type:"warning",tagText:"Subscription enquiry"},{key:"SALES_AND_OFFERS_ISSUES",type:"grey",tagText:"Offer-related enquiries"},{key:"COLLABORATION",type:"positive",tagText:"Collaboration"},{key:"QUIZ_GENERATION",type:"warning",tagText:"Start the quiz"},{key:"SIMILAR_PRODUCT",type:"blue",tagText:"Similar Product"},{key:"EMAIL_COLLECTION",type:"warning",tagText:"Email Collection"},{key:"ADD_TO_CART_SUCCESS",type:"blue",tagText:"Add to Cart Success"},{key:"ADD_TO_CART_SUCCESS_MESSAGE",type:"blue",tagText:"Add to Cart Success Message"},{key:"FEEDBACK",type:"blue",tagText:"Feedback"},{key:"PHONE_NUMBER_COLLECTION",type:"blue",tagText:"Phone no. collection"}].forEach((t=>{let{key:i,type:o,tagText:s}=t;A[i]&&(Z[A[i]]=e.jsx(h.Tag,{theme:"light",type:o,tagText:s,cursor:"pointer"}))}));const J=p.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=>{A[t]&&(e[A[t]]=A[t])})),["COLLABORATION","SUBSCRIPTION_ENQUIRY"].forEach((t=>{e[t]=t})),e}),[A]);p.useEffect((()=>{var e,t,i,o;if(!(null==b?void 0:b.messageId))return;G(!0),W(!1!==(null===(t=null===(e=b.sources)||void 0===e?void 0:e[0])||void 0===t?void 0:t.isTrainable)||!!(null===(o=null===(i=b.sources)||void 0===i?void 0:i[0])||void 0===o?void 0:o.insights));const s=b.sources.filter((e=>!!e.productId)).map((e=>e.productId)),n=Array.from(new Set(s)).filter((e=>!!e));M(L,n).then((e=>z(e))).then((()=>{P||B(L).then((e=>V(e))).then((()=>{setTimeout((()=>G(!1)),100)}))}))}),[M,B,null==b?void 0:b.messageId,b.sources,P,L]);const ee=e=>!(0!==e.length&&!(null==b?void 0:b.isUnsatisfactoryAnswer)),te=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];var i;return"custom"==e?e=v.CustomDataType.FILES:K.includes(e)?e=v.CustomDataType.FETCHED_LINKS:"url"==e?e=v.CustomDataType.WEBSITE_LINKS:"text"===e?e=v.CustomDataType.TEXTS:"faq"===e&&(e=v.CustomDataType.FAQ),t?e:null===(i=null==e?void 0:e.toLowerCase())||void 0===i?void 0:i.replace(/_/g," ")};return Q||!_?e.jsx(I.SourceInfoDetailsStyle,{children:e.jsx(T.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"}]})}):e.jsx(e.Fragment,{children:e.jsx(I.SourceInfoDetailsStyle,{children:e.jsxs(e.Fragment,{children:[e.jsxs("div",Object.assign({className:"pop-up-header",style:{display:"flex",flexDirection:"column",paddingBottom:"12px"}},{children:[!!w&&e.jsx(O.TitleSmall,{children:w}),e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",alignItems:"center"}},{children:[e.jsx(O.BodyCaption,Object.assign({color:y.COLORS.content.secondary},{children:"Intent"})),null!==(j=Z[b.intent])&&void 0!==j?j:Z.GENERIC,!R&&e.jsx("div",Object.assign({style:{display:"flex",marginLeft:"auto",cursor:"pointer"},onClick:()=>N(void 0)},{children:e.jsx(i.default,{height:20,width:20,color:y.COLORS.content.secondary})}))]})),ee(H)?e.jsx("div",Object.assign({style:{display:"flex",margin:"auto",justifyContent:"center",alignItems:"center",height:"calc(100vh - 300px)"}},{children:(()=>{var t,i;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:`${y.COLORS.background.negative.light}`,borderRadius:"100px"}},{children:e.jsx(a.default,{width:24,height:24,color:y.COLORS.stroke.negative.vibrant})})),e.jsx("div",Object.assign({style:{justifyContent:"center",alignItems:"center",marginBottom:"-4px"}},{children:e.jsx(O.TitleSmall,{children:"Insufficient data"})})),e.jsx(O.BodySecondary,Object.assign({color:y.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"})),k&&e.jsx("div",Object.assign({style:{display:"flex",width:"100%"}},{children:e.jsx(g.Button,{LeadingIcon:null!==(t=k.leadingIcon)&&void 0!==t?t:l.default,buttonText:null!==(i=k.title)&&void 0!==i?i:"Add FAQ",buttonType:"secondary",size:"small",matchParentWidth:!0,onClick:()=>{k.onClick()}})}))]}))})()})):e.jsx(h.Tag,{LeadingIcon:a.default,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 Manifest.":"Edit the original source and save again to update the response"})]})),!ee(H)&&e.jsx("div",Object.assign({className:"info-container"},{children:e.jsx("div",Object.assign({style:{padding:"0 8px",maxWidth:"100%"}},{children:H.map(((i,a)=>{var l,p,g,T,h,S,I,E,j,f,m,L,b,N,R,_,w;const k=te(i.type||i.subTitle||"OpenAI"),P=te(i.type||i.subTitle||"OpenAI",!0),U=(B=k)?"faq"==B.toLocaleLowerCase()?"FAQ":"openai"==B.toLocaleLowerCase()?"OPENAI":"files"==B.toLocaleLowerCase()?"PDF":"texts"==B.toLocaleLowerCase()?"Custom text":((B=(B=B.charAt(0).toUpperCase()+B.slice(1).toLowerCase()).replace("_"," ")).endsWith("s")&&(B=B.slice(0,-1)),B.replace("Website","Manual")):"";var B;const M=null==F?void 0:F.includes(P),H="Products"===i.subTitle?D[null!==(l=i.productId)&&void 0!==l?l:"Products"]:D[null!==(p=i.docId)&&void 0!==p?p:""],K=P.toLowerCase()===(null===(g=v.CustomDataType.FAQ)||void 0===g?void 0:g.toLowerCase())?"faq"===(null===(T=i.title)||void 0===T?void 0:T.toLowerCase())?i.subTitle:i.title:P.toLowerCase()===(null===(h=v.CustomDataType.FILES)||void 0===h?void 0:h.toLowerCase())||P.toLowerCase()===(null===(S=v.CustomDataType.FETCHED_LINKS)||void 0===S?void 0:S.toLowerCase())||P.toLowerCase()===(null===(I=v.CustomDataType.TEXTS)||void 0===I?void 0:I.toLowerCase())?i.title:P.toLowerCase()===(null===(E=v.CustomDataType.WEBSITE_LINKS)||void 0===E?void 0:E.toLowerCase())?i.title.split("/")[i.title.split("/").length-1].replace(/[^\w\s]/gi," ").replace(/^(.)(.*)$/,((e,t,i)=>t.toUpperCase()+i)):i.intent===A.EMAIL_COLLECTION?U:i.title,Q="faq"===P.toLowerCase()?null!==(m=null!==(j=null==H?void 0:H.content)&&void 0!==j?j:null===(f=null==H?void 0:H.data)||void 0===f?void 0:f.answer)&&void 0!==m?m:"":P.toLowerCase()===(null===(L=v.CustomDataType.FETCHED_LINKS)||void 0===L?void 0:L.toLowerCase())||P.toLowerCase()===(null===(b=v.CustomDataType.WEBSITE_LINKS)||void 0===b?void 0:b.toLowerCase())||P.toLowerCase()===(null===(N=v.CustomDataType.TEXTS)||void 0===N?void 0:N.toLowerCase())?null!==(w=null!==(R=null==H?void 0:H.content)&&void 0!==R?R:null===(_=null==H?void 0:H.data)||void 0===_?void 0:_.fileContentText)&&void 0!==w?w:"":i.intent===A.EMAIL_COLLECTION?"Collect leads before replying to messages":"";return e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"8px",padding:"24px 0px",borderBottom:`1px solid ${y.COLORS.stroke.primary}`}},{children:[e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",justifyContent:"space-between",alignItems:"center"}},{children:[e.jsx("div",Object.assign({style:{flex:1}},{children:e.jsx(x.Tooltip,Object.assign({body:K,placement:"top"},{children:e.jsx(O.BodySecondary,Object.assign({style:P==v.CustomDataType.FETCHED_LINKS||P==v.CustomDataType.WEBSITE_LINKS?{cursor:"pointer",textDecoration:"underline"}:{},color:y.COLORS.content.primary,className:"clamp-title",onClick:()=>P==v.CustomDataType.FETCHED_LINKS||P==v.CustomDataType.WEBSITE_LINKS?q(i):{}},{children:K}))}))})),e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",justifyContent:"flex-end",alignItems:"center",gap:"4px",flex:"none"}},{children:[i.intent!==A.EMAIL_COLLECTION&&e.jsxs(e.Fragment,{children:[(Y=k,"products"==Y||"product"==Y?e.jsx(t.default,{height:16,width:16,color:y.COLORS.content.secondary}):"files"==Y?e.jsx(s.default,{height:16,width:16,color:y.COLORS.content.secondary}):"website links"==Y||"fetched links"==Y?e.jsx(u.default,{height:16,width:16,color:y.COLORS.content.secondary}):"faq"==Y?e.jsx(n.default,{height:16,width:16,color:y.COLORS.content.secondary}):"texts"==Y?e.jsx(c.default,{height:16,width:16,color:y.COLORS.content.secondary}):e.jsx(r.default,{height:16,width:16,color:y.COLORS.content.secondary})),e.jsx(O.BodyCaption,Object.assign({color:y.COLORS.content.secondary},{children:U}))]}),(i.link||i.docId)&&e.jsx("div",Object.assign({style:{cursor:"pointer",marginLeft:"4px"}},{children:M?e.jsx(C.IconButton,{Icon:o.default,height:16,width:16,bordered:!0,onClick:()=>null==H?void 0:H.onEditClick(H.data,H.type),disabled:!H,disabledTooltip:"This source is deleted"}):e.jsx(C.IconButton,{Icon:d.default,height:16,width:16,bordered:!0,disabled:"custom"===i.type&&!H,disabledTooltip:"This source is deleted",onClick:()=>q(i)})}))]}))]})),(null!=Q?Q:"").trim()&&e.jsx("div",Object.assign({style:{padding:"4px 8px",border:`1px dashed ${y.COLORS.stroke.primary}`,borderRadius:"4px",backgroundColor:y.COLORS.surface.subdued}},{children:e.jsx(O.BodyCaption,Object.assign({color:y.COLORS.content.primary,className:"clamp-description"},{children:(G=null!=Q?Q:"",G.replace(/(<([^>]+)>)/gi,"")).trim()}))}))]}),`info-${a}`);var G,Y}))}))})),Y&&!ee(H)&&e.jsx("div",Object.assign({className:"footer"},{children:e.jsx(S.default,{appType:m,storeId:L,messageSource:b,sourceIntent:null!==(f=b.intent)&&void 0!==f?f:A.GENERIC,faqCount:$,trainingSourceCount:X,ShowTrainingDataSource:J,ChecklistType:A,footerButtonOption:U})}))]})})})};
@@ -1 +1 @@
1
- import{jsx as e,jsxs as o,Fragment as t}from"react/jsx-runtime";import i from"../../assets/icons/alert_triangle.svg.js";import n from"../../assets/icons/plus.svg.js";import{memo as r,useState as d,useMemo as l,useEffect as s}from"react";import{COLORS as a}from"../../constants/Theme.js";import{Button as c}from"../button/Button.js";import{BodyCaption as u}from"../TypographyStyle.js";import{SourceInfoFooterStyle as v}from"./DataSourcePanel.style.js";import{AppType as g}from"./model.js";const h=r((r=>{const{appType:h,sourceIntent:p,hideHeading:b,messageSource:T,trainingSourceCount:f={},ShowTrainingDataSource:I={},faqCount:y,ChecklistType:A,footerButtonOption:O}=r,C=I,[R,_]=d(!0),[k,N]=d(!0),[D,w]=d({buttonTitle:"",redirectUrl:"",addFaqProps:{}}),[E,F]=d({title:"",subTitle:""}),j=l((()=>{const e=(null==f?void 0:f[p])||0;return e<=1?"There is "+e+"data source added to the identified intent":`There are ${e} data sources added to the identified intent`}),[f,p]),P=()=>{var e;(null==D?void 0:D.redirectUrl)?window.open(`${window.location.origin}${null==D?void 0:D.redirectUrl}`,"_self"):Object.keys(null!==(e=null==D?void 0:D.addFaqProps)&&void 0!==e?e:{}).length>0?null==O||O.onClick(D):(null==O?void 0:O.navigate)&&(null==O||O.navigate("/Training",{tab:"/"},{},!0))};return s((()=>{var e,o,t,i,n,r,d,l,s,a,c,u;if(console.log("KB sourceIntent",p,T),p){if(null===(e=null==T?void 0:T.sources)||void 0===e?void 0:e.length)if(console.log("KB sourceIntent 1"),C[p])p===A.ORDER_ENQUIRY&&N(!1);else{console.log("KB sourceIntent 2");let e=null===(o=T.sources[0])||void 0===o?void 0:o.insights,v="";switch(console.log("KB sourceIntent 3"),p){case A.PRODUCT_DETAILS:"Product reviews"!==(null===(t=T.sources[0])||void 0===t?void 0:t.title)&&(e=`${y||"No"} FAQs added for this product`,v="Add product-specific information via FAQs to improve responses",w({buttonTitle:"Add FAQ",addFaqProps:{faqProducts:[{id:null===(i=T.sources[0])||void 0===i?void 0:i.productId,variantId:null===(n=T.sources[0])||void 0===n?void 0:n.variantId,name:null===(r=T.sources[0])||void 0===r?void 0:r.title,imageUrl:null===(d=T.sources[0])||void 0===d?void 0:d.imageUrl}]},redirectUrl:""}));break;case A.ORDER_MODIFICATION:e=(null==f?void 0:f[p])?void 0:"Customers who are looking to modify their orders would be redirected to your live agents via the agent handover flow.",e&&w({buttonTitle:"Manage agent handover",redirectUrl:h==g.MANIFEST?"/customise?tab=AgentHandover":"/training",addFaqProps:{}});break;case A.ORDER_CANCELLATION:e=(null==f?void 0:f[p])?void 0:"Customers who are looking to cancel their orders would be redirected to your live agents via the agent handover flow.",w({buttonTitle:"Manage agent handover",redirectUrl:h==g.MANIFEST?"/customise?tab=AgentHandover":"/training",addFaqProps:{}});break;case A.ORDER_TRACKING:if("ORDER_NOT_FOUND"===(null===(l=T.sources[0])||void 0===l?void 0:l.subIntent))break;w({buttonTitle:"Add order tracking link",redirectUrl:h==g.MANIFEST?"/training/order-management":"/training",addFaqProps:{}});break;case A.PRODUCT_SEARCH:if("QUIZ"===(null===(s=T.sources[0])||void 0===s?void 0:s.type))break;if(-1!==(null===(u=null===(c=null===(a=null==T?void 0:T.sources)||void 0===a?void 0:a[0])||void 0===c?void 0:c.title)||void 0===u?void 0:u.toLowerCase().indexOf("collection"))){e="Collections are recommended by matching queries with collection names and descriptions. Add relevant keywords to your collection description to improve results.";break}e="Products are recommended by matching queries with product names, descriptions, tags, and collections. Add relevant keywords and tags to your products to improve results."}F({title:null!=e?e:"",subTitle:v})}(C[p]||[A.PRODUCT_DETAILS,A.ORDER_MODIFICATION,A.ORDER_CANCELLATION,A.ORDER_TRACKING].includes(p))&&_(!1)}}),[null==T?void 0:T.messageId,f,p,null==T?void 0:T.sources,C,A,y,h,T]),s((()=>{console.log("KB change",E,E)}),[D,E]),e(v,{children:!(null==E?void 0:E.title)&&f&&p in f?o(t,{children:[e(m,{hideHeading:null!=b&&b}),o("div",Object.assign({className:"source_info_details "+(f[p]>0?"":"no_data_source")},{children:[f[p]>0&&k?o(t,{children:[e(u,{children:j}),e(u,Object.assign({color:a.content.secondary},{children:"Improve responses by adding more data sources for the identified intent"}))]}):k&&o("div",Object.assign({className:"no_data_source_title"},{children:[e(i,{width:15,height:15,color:a.content.negative,style:{marginTop:2}}),e(u,{children:"No data sources added to the identified link"})]})),!O||O.hideAddDataButton||R?e(t,{}):e(c,{size:"small",buttonType:"tertiary",LeadingIcon:n,buttonText:(null==D?void 0:D.buttonTitle.length)>0?null==D?void 0:D.buttonTitle:"Add relevant data",matchParentWidth:!0,onClick:()=>P(),style:{backgroundColor:"unset"}})]}))]}):o(t,{children:[e(m,{hideHeading:null!=b&&b}),o("div",Object.assign({className:"source_info_details"},{children:[k&&o(t,{children:[e(u,{children:null==E?void 0:E.title}),e(u,Object.assign({color:a.content.secondary},{children:null==E?void 0:E.subTitle}))]}),!O||O.hideAddDataButton||R?e(t,{}):e(c,{size:"small",buttonType:"tertiary",LeadingIcon:n,buttonText:(null==D?void 0:D.buttonTitle.length)>0?null==D?void 0:D.buttonTitle:"Add relevant data",matchParentWidth:!0,onClick:()=>P(),style:{backgroundColor:"unset"}})]}))]})})})),m=r((o=>o.hideHeading?null:e(u,Object.assign({color:a.content.secondary},{children:"Training insights"}))));m.displayName="TrainingInsightsHeading",h.displayName="SourceInfoFooter";export{h as default};
1
+ import{jsx as e,jsxs as o,Fragment as t}from"react/jsx-runtime";import i from"../../assets/icons/alert_triangle.svg.js";import n from"../../assets/icons/plus.svg.js";import{memo as r,useState as d,useMemo as l,useEffect as s}from"react";import{COLORS as a}from"../../constants/Theme.js";import{Button as c}from"../button/Button.js";import{BodyCaption as u}from"../TypographyStyle.js";import{SourceInfoFooterStyle as v}from"./DataSourcePanel.style.js";import{AppType as g}from"./model.js";const h=r((r=>{const{appType:h,sourceIntent:p,hideHeading:b,messageSource:T,trainingSourceCount:f={},ShowTrainingDataSource:I={},faqCount:y,ChecklistType:A,footerButtonOption:O}=r,C=I,[R,_]=d(!0),[k,N]=d(!0),[D,w]=d({buttonTitle:"",redirectUrl:"",addFaqProps:{}}),[E,F]=d({title:"",subTitle:""}),j=l((()=>{const e=(null==f?void 0:f[p])||0;return e<=1?"There is "+e+"data source added to the identified intent":`There are ${e} data sources added to the identified intent`}),[f,p]),P=()=>{var e;(null==D?void 0:D.redirectUrl)?window.open(`${window.location.origin}${null==D?void 0:D.redirectUrl}`,"_self"):Object.keys(null!==(e=null==D?void 0:D.addFaqProps)&&void 0!==e?e:{}).length>0?null==O||O.onClick(D):(null==O?void 0:O.navigate)&&(null==O||O.navigate("/Training",{tab:"/"},{},!0))};return s((()=>{var e,o,t,i,n,r,d,l,s,a,c,u;if(console.log("KB sourceIntent",p,T),p){if(null===(e=null==T?void 0:T.sources)||void 0===e?void 0:e.length)if(console.log("KB sourceIntent 1",C),C[p]){console.log("KB sourceIntent 2");let e=null===(o=T.sources[0])||void 0===o?void 0:o.insights,v="";switch(console.log("KB sourceIntent 3"),p){case A.PRODUCT_DETAILS:"Product reviews"!==(null===(t=T.sources[0])||void 0===t?void 0:t.title)&&(e=`${y||"No"} FAQs added for this product`,v="Add product-specific information via FAQs to improve responses",w({buttonTitle:"Add FAQ",addFaqProps:{faqProducts:[{id:null===(i=T.sources[0])||void 0===i?void 0:i.productId,variantId:null===(n=T.sources[0])||void 0===n?void 0:n.variantId,name:null===(r=T.sources[0])||void 0===r?void 0:r.title,imageUrl:null===(d=T.sources[0])||void 0===d?void 0:d.imageUrl}]},redirectUrl:""}));break;case A.ORDER_MODIFICATION:e=(null==f?void 0:f[p])?void 0:"Customers who are looking to modify their orders would be redirected to your live agents via the agent handover flow.",e&&w({buttonTitle:"Manage agent handover",redirectUrl:h==g.MANIFEST?"/customise?tab=AgentHandover":"/training",addFaqProps:{}});break;case A.ORDER_CANCELLATION:e=(null==f?void 0:f[p])?void 0:"Customers who are looking to cancel their orders would be redirected to your live agents via the agent handover flow.",w({buttonTitle:"Manage agent handover",redirectUrl:h==g.MANIFEST?"/customise?tab=AgentHandover":"/training",addFaqProps:{}});break;case A.ORDER_TRACKING:if("ORDER_NOT_FOUND"===(null===(l=T.sources[0])||void 0===l?void 0:l.subIntent))break;w({buttonTitle:"Add order tracking link",redirectUrl:h==g.MANIFEST?"/training/order-management":"/training",addFaqProps:{}});break;case A.PRODUCT_SEARCH:if("QUIZ"===(null===(s=T.sources[0])||void 0===s?void 0:s.type))break;if(-1!==(null===(u=null===(c=null===(a=null==T?void 0:T.sources)||void 0===a?void 0:a[0])||void 0===c?void 0:c.title)||void 0===u?void 0:u.toLowerCase().indexOf("collection"))){e="Collections are recommended by matching queries with collection names and descriptions. Add relevant keywords to your collection description to improve results.";break}e="Products are recommended by matching queries with product names, descriptions, tags, and collections. Add relevant keywords and tags to your products to improve results."}F({title:null!=e?e:"",subTitle:v})}else p===A.ORDER_ENQUIRY&&N(!1);(C[p]||[A.PRODUCT_DETAILS,A.ORDER_MODIFICATION,A.ORDER_CANCELLATION,A.ORDER_TRACKING].includes(p))&&_(!1)}}),[null==T?void 0:T.messageId,f,p,null==T?void 0:T.sources,C,A,y,h,T]),s((()=>{console.log("KB change",E,E)}),[D,E]),e(v,{children:!(null==E?void 0:E.title)&&f&&p in f?o(t,{children:[e(m,{hideHeading:null!=b&&b}),o("div",Object.assign({className:"source_info_details "+(f[p]>0?"":"no_data_source")},{children:[f[p]>0&&k?o(t,{children:[e(u,{children:j}),e(u,Object.assign({color:a.content.secondary},{children:"Improve responses by adding more data sources for the identified intent"}))]}):k&&o("div",Object.assign({className:"no_data_source_title"},{children:[e(i,{width:15,height:15,color:a.content.negative,style:{marginTop:2}}),e(u,{children:"No data sources added to the identified link"})]})),!O||O.hideAddDataButton||R?e(t,{}):e(c,{size:"small",buttonType:"tertiary",LeadingIcon:n,buttonText:(null==D?void 0:D.buttonTitle.length)>0?null==D?void 0:D.buttonTitle:"Add relevant data",matchParentWidth:!0,onClick:()=>P(),style:{backgroundColor:"unset"}})]}))]}):o(t,{children:[e(m,{hideHeading:null!=b&&b}),o("div",Object.assign({className:"source_info_details"},{children:[k&&o(t,{children:[e(u,{children:null==E?void 0:E.title}),e(u,Object.assign({color:a.content.secondary},{children:null==E?void 0:E.subTitle}))]}),!O||O.hideAddDataButton||R?e(t,{}):e(c,{size:"small",buttonType:"tertiary",LeadingIcon:n,buttonText:(null==D?void 0:D.buttonTitle.length)>0?null==D?void 0:D.buttonTitle:"Add relevant data",matchParentWidth:!0,onClick:()=>P(),style:{backgroundColor:"unset"}})]}))]})})})),m=r((o=>o.hideHeading?null:e(u,Object.assign({color:a.content.secondary},{children:"Training insights"}))));m.displayName="TrainingInsightsHeading",h.displayName="SourceInfoFooter";export{h as default};
@@ -1 +1 @@
1
- import{jsx as e,Fragment as t,jsxs as i}from"react/jsx-runtime";import o from"../../assets/icons/boxV2.svg.js";import n from"../../assets/icons/cross.svg.js";import s from"../../assets/icons/edit.svg.js";import r from"../../assets/icons/filePdf.svg.js";import l from"../../assets/icons/help.svg.js";import a from"../../assets/icons/info.svg.js";import c from"../../assets/icons/openai.svg.js";import d from"../../assets/icons/plus.svg.js";import p from"../../assets/icons/redirect.svg.js";import u from"../../assets/icons/text_t9.svg.js";import g from"../../assets/icons/website.svg.js";import{useState as y,useMemo as h,useEffect as T}from"react";import{COLORS as C}from"../../constants/Theme.js";import{Button as m}from"../button/Button.js";import{IconButton as I}from"../icon-button/IconButton.js";import{BikShimmer as v}from"../shimmer/ShimmerComponent/BikShimmer.js";import{Tag as O}from"../tag/Tag.js";import{Tooltip as f}from"../tooltips/Tooltip.js";import{TitleSmall as E,BodyCaption as x,BodySecondary as S}from"../TypographyStyle.js";import L from"./DataSourceInfoFooter.js";import{SourceInfoDetailsStyle as b}from"./DataSourcePanel.style.js";import{CustomDataType as N}from"./model.js";const _=_=>{var A,w;const{appType:R,storeId:k,messageSource:j,setMessageSourcePanel:D,hideCloseButton:F,isSourceInfoFetched:P,allSourceInfoDetail:U,ChecklistType:B,title:M,zeroStateButton:H,editableSources:K,preFillTrainingSourceCount:Q,redirect:q,footerButtonOption:G,fetchTrainingSourceCount:Y,fetchProductFAQCount:W}=_,{sources:$}=j,z=["blog","article","page","policy"],[X,V]=y(!1),[Z,J]=y(!1),[ee,te]=y(0),[ie,oe]=y(null!=Q?Q:{}),ne={};[{key:"GENERIC",type:"neutral",tagText:"Generic"},{key:"STORE_INFORMATION",type:"blue",tagText:"Store information"},{key:"SHIPPING_POLICY",type:"positive",tagText:"Shipping policy"},{key:"RETURN_AND_REFUND",type:"purple",tagText:"Returns & refund policy"},{key:"CONTACT_INFO",type:"warning",tagText:"Contact details"},{key:"STORE_LOCATION",type:"grey",tagText:"Store location"},{key:"SALES_AND_OFFERS",type:"purple",tagText:"Offers & rewards"},{key:"PRODUCT_CUSTOMISATION",type:"blue",tagText:"Product customisation"},{key:"PRODUCT_DETAILS",type:"blue",tagText:"Product details"},{key:"PAYMENT_METHODS",type:"positive",tagText:"Payment methods"},{key:"ORDER_TRACKING",type:"warning",tagText:"Order tracking"},{key:"PRODUCT_SEARCH",type:"neutral",tagText:"Product search"},{key:"PURCHASE",type:"blue",tagText:"Purchase"},{key:"CONNECT_TO_AGENT",type:"purple",tagText:"Talk to a person"},{key:"CHECKOUT_ENQUIRY",type:"purple",tagText:"Checkout enquiry"},{key:"ORDER_CANCELLATION",type:"positive",tagText:"Order cancellation"},{key:"ORDER_ENQUIRY",type:"neutral",tagText:"Order enquiry"},{key:"ORDER_MODIFICATION",type:"blue",tagText:"Order modification"},{key:"SUBSCRIPTION_ENQUIRY",type:"warning",tagText:"Subscription enquiry"},{key:"SALES_AND_OFFERS_ISSUES",type:"grey",tagText:"Offer-related enquiries"},{key:"COLLABORATION",type:"positive",tagText:"Collaboration"},{key:"QUIZ_GENERATION",type:"warning",tagText:"Start the quiz"},{key:"SIMILAR_PRODUCT",type:"blue",tagText:"Similar Product"},{key:"EMAIL_COLLECTION",type:"warning",tagText:"Email Collection"},{key:"ADD_TO_CART_SUCCESS",type:"blue",tagText:"Add to Cart Success"},{key:"ADD_TO_CART_SUCCESS_MESSAGE",type:"blue",tagText:"Add to Cart Success Message"},{key:"FEEDBACK",type:"blue",tagText:"Feedback"},{key:"PHONE_NUMBER_COLLECTION",type:"blue",tagText:"Phone no. collection"}].forEach((t=>{let{key:i,type:o,tagText:n}=t;B[i]&&(ne[B[i]]=e(O,{theme:"light",type:o,tagText:n,cursor:"pointer"}))}));const se=h((()=>{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=>{B[t]&&(e[B[t]]=B[t])})),["COLLABORATION","SUBSCRIPTION_ENQUIRY"].forEach((t=>{e[t]=t})),e}),[]);T((()=>{var e,t,i,o;if(!(null==j?void 0:j.messageId))return;V(!0),J(!1!==(null===(t=null===(e=j.sources)||void 0===e?void 0:e[0])||void 0===t?void 0:t.isTrainable)||!!(null===(o=null===(i=j.sources)||void 0===i?void 0:i[0])||void 0===o?void 0:o.insights));const n=j.sources.filter((e=>!!e.productId)).map((e=>e.productId)),s=Array.from(new Set(n)).filter((e=>!!e));W(k,s).then((e=>te(e))).then((()=>{Q||Y(k).then((e=>oe(e))).then((()=>{setTimeout((()=>V(!1)),100)}))}))}),[W,Y,null==j?void 0:j.messageId,j.sources,Q,k]);const re=e=>!(0!==e.length&&!(null==j?void 0:j.isUnsatisfactoryAnswer)),le=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];var i;return"custom"==e?e=N.FILES:z.includes(e)?e=N.FETCHED_LINKS:"url"==e?e=N.WEBSITE_LINKS:"text"===e?e=N.TEXTS:"faq"===e&&(e=N.FAQ),t?e:null===(i=null==e?void 0:e.toLowerCase())||void 0===i?void 0:i.replace(/_/g," ")};return X||!P?e(b,{children:e(v,{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"}]})}):e(t,{children:e(b,{children:i(t,{children:[i("div",Object.assign({className:"pop-up-header",style:{display:"flex",flexDirection:"column",paddingBottom:"12px"}},{children:[!!M&&e(E,{children:M}),i("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",alignItems:"center"}},{children:[e(x,Object.assign({color:C.content.secondary},{children:"Intent"})),null!==(A=ne[j.intent])&&void 0!==A?A:ne.GENERIC,!F&&e("div",Object.assign({style:{display:"flex",marginLeft:"auto",cursor:"pointer"},onClick:()=>D(void 0)},{children:e(n,{height:20,width:20,color:C.content.secondary})}))]})),re($)?e("div",Object.assign({style:{display:"flex",margin:"auto",justifyContent:"center",alignItems:"center",height:"calc(100vh - 300px)"}},{children:(()=>{var t,o;return i("div",Object.assign({style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",margin:"0px 30px",gap:"8px"}},{children:[e("div",Object.assign({style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"12px",backgroundColor:`${C.background.negative.light}`,borderRadius:"100px"}},{children:e(a,{width:24,height:24,color:C.stroke.negative.vibrant})})),e("div",Object.assign({style:{justifyContent:"center",alignItems:"center",marginBottom:"-4px"}},{children:e(E,{children:"Insufficient data"})})),e(S,Object.assign({color:C.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"})),H&&e("div",Object.assign({style:{display:"flex",width:"100%"}},{children:e(m,{LeadingIcon:null!==(t=H.leadingIcon)&&void 0!==t?t:d,buttonText:null!==(o=H.title)&&void 0!==o?o:"Add FAQ",buttonType:"secondary",size:"small",matchParentWidth:!0,onClick:()=>{H.onClick()}})}))]}))})()})):e(O,{LeadingIcon:a,version:"2.0",type:"grey",theme:"light",alignIcon:"start",contentPadding:12,tagText:j.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 Manifest.":"Edit the original source and save again to update the response"})]})),!re($)&&e("div",Object.assign({className:"info-container"},{children:e("div",Object.assign({style:{padding:"0 8px",maxWidth:"100%"}},{children:$.map(((n,a)=>{var d,y,h,T,m,v,O,E,L,b,_,A,w,R,k,j,D;const F=le(n.type||n.subTitle||"OpenAI"),P=le(n.type||n.subTitle||"OpenAI",!0),M=(H=F)?"faq"==H.toLocaleLowerCase()?"FAQ":"openai"==H.toLocaleLowerCase()?"OPENAI":"files"==H.toLocaleLowerCase()?"PDF":"texts"==H.toLocaleLowerCase()?"Custom text":((H=(H=H.charAt(0).toUpperCase()+H.slice(1).toLowerCase()).replace("_"," ")).endsWith("s")&&(H=H.slice(0,-1)),H.replace("Website","Manual")):"";var H;const Q=null==K?void 0:K.includes(P),G="Products"===n.subTitle?U[null!==(d=n.productId)&&void 0!==d?d:"Products"]:U[null!==(y=n.docId)&&void 0!==y?y:""],Y=P.toLowerCase()===(null===(h=N.FAQ)||void 0===h?void 0:h.toLowerCase())?"faq"===(null===(T=n.title)||void 0===T?void 0:T.toLowerCase())?n.subTitle:n.title:P.toLowerCase()===(null===(m=N.FILES)||void 0===m?void 0:m.toLowerCase())||P.toLowerCase()===(null===(v=N.FETCHED_LINKS)||void 0===v?void 0:v.toLowerCase())||P.toLowerCase()===(null===(O=N.TEXTS)||void 0===O?void 0:O.toLowerCase())?n.title:P.toLowerCase()===(null===(E=N.WEBSITE_LINKS)||void 0===E?void 0:E.toLowerCase())?n.title.split("/")[n.title.split("/").length-1].replace(/[^\w\s]/gi," ").replace(/^(.)(.*)$/,((e,t,i)=>t.toUpperCase()+i)):n.intent===B.EMAIL_COLLECTION?M:n.title,W="faq"===P.toLowerCase()?null!==(_=null!==(L=null==G?void 0:G.content)&&void 0!==L?L:null===(b=null==G?void 0:G.data)||void 0===b?void 0:b.answer)&&void 0!==_?_:"":P.toLowerCase()===(null===(A=N.FETCHED_LINKS)||void 0===A?void 0:A.toLowerCase())||P.toLowerCase()===(null===(w=N.WEBSITE_LINKS)||void 0===w?void 0:w.toLowerCase())||P.toLowerCase()===(null===(R=N.TEXTS)||void 0===R?void 0:R.toLowerCase())?null!==(D=null!==(k=null==G?void 0:G.content)&&void 0!==k?k:null===(j=null==G?void 0:G.data)||void 0===j?void 0:j.fileContentText)&&void 0!==D?D:"":n.intent===B.EMAIL_COLLECTION?"Collect leads before replying to messages":"";return i("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"8px",padding:"24px 0px",borderBottom:`1px solid ${C.stroke.primary}`}},{children:[i("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",justifyContent:"space-between",alignItems:"center"}},{children:[e("div",Object.assign({style:{flex:1}},{children:e(f,Object.assign({body:Y,placement:"top"},{children:e(S,Object.assign({style:P==N.FETCHED_LINKS||P==N.WEBSITE_LINKS?{cursor:"pointer",textDecoration:"underline"}:{},color:C.content.primary,className:"clamp-title",onClick:()=>P==N.FETCHED_LINKS||P==N.WEBSITE_LINKS?q(n):{}},{children:Y}))}))})),i("div",Object.assign({style:{display:"flex",flexDirection:"row",justifyContent:"flex-end",alignItems:"center",gap:"4px",flex:"none"}},{children:[n.intent!==B.EMAIL_COLLECTION&&i(t,{children:[(z=F,e("products"==z||"product"==z?o:"files"==z?r:"website links"==z||"fetched links"==z?g:"faq"==z?l:"texts"==z?u:c,{height:16,width:16,color:C.content.secondary})),e(x,Object.assign({color:C.content.secondary},{children:M}))]}),(n.link||n.docId)&&e("div",Object.assign({style:{cursor:"pointer",marginLeft:"4px"}},{children:e(I,Q?{Icon:s,height:16,width:16,bordered:!0,onClick:()=>null==G?void 0:G.onEditClick(G.data,G.type),disabled:!G,disabledTooltip:"This source is deleted"}:{Icon:p,height:16,width:16,bordered:!0,disabled:"custom"===n.type&&!G,disabledTooltip:"This source is deleted",onClick:()=>q(n)})}))]}))]})),(null!=W?W:"").trim()&&e("div",Object.assign({style:{padding:"4px 8px",border:`1px dashed ${C.stroke.primary}`,borderRadius:"4px",backgroundColor:C.surface.subdued}},{children:e(x,Object.assign({color:C.content.primary,className:"clamp-description"},{children:($=null!=W?W:"",$.replace(/(<([^>]+)>)/gi,"")).trim()}))}))]}),`info-${a}`);var $,z}))}))})),Z&&!re($)&&e("div",Object.assign({className:"footer"},{children:e(L,{appType:R,storeId:k,messageSource:j,sourceIntent:null!==(w=j.intent)&&void 0!==w?w:B.GENERIC,faqCount:ee,trainingSourceCount:ie,ShowTrainingDataSource:se,ChecklistType:B,footerButtonOption:G})}))]})})})};export{_ as DataSourcePanel};
1
+ import{jsx as e,Fragment as t,jsxs as i}from"react/jsx-runtime";import o from"../../assets/icons/boxV2.svg.js";import n from"../../assets/icons/cross.svg.js";import s from"../../assets/icons/edit.svg.js";import r from"../../assets/icons/filePdf.svg.js";import l from"../../assets/icons/help.svg.js";import a from"../../assets/icons/info.svg.js";import c from"../../assets/icons/openai.svg.js";import d from"../../assets/icons/plus.svg.js";import p from"../../assets/icons/redirect.svg.js";import u from"../../assets/icons/text_t9.svg.js";import g from"../../assets/icons/website.svg.js";import{useState as y,useMemo as h,useEffect as T}from"react";import{COLORS as C}from"../../constants/Theme.js";import{Button as m}from"../button/Button.js";import{IconButton as I}from"../icon-button/IconButton.js";import{BikShimmer as v}from"../shimmer/ShimmerComponent/BikShimmer.js";import{Tag as O}from"../tag/Tag.js";import{Tooltip as f}from"../tooltips/Tooltip.js";import{TitleSmall as E,BodyCaption as x,BodySecondary as S}from"../TypographyStyle.js";import L from"./DataSourceInfoFooter.js";import{SourceInfoDetailsStyle as b}from"./DataSourcePanel.style.js";import{CustomDataType as N}from"./model.js";const _=_=>{var A,w;const{appType:R,storeId:k,messageSource:j,setMessageSourcePanel:D,hideCloseButton:F,isSourceInfoFetched:P,allSourceInfoDetail:U,ChecklistType:B,title:M,zeroStateButton:H,editableSources:K,preFillTrainingSourceCount:Q,redirect:q,footerButtonOption:G,fetchTrainingSourceCount:Y,fetchProductFAQCount:W}=_,{sources:$}=j,z=["blog","article","page","policy"],[X,V]=y(!1),[Z,J]=y(!1),[ee,te]=y(0),[ie,oe]=y(null!=Q?Q:{}),ne={};[{key:"GENERIC",type:"neutral",tagText:"Generic"},{key:"STORE_INFORMATION",type:"blue",tagText:"Store information"},{key:"SHIPPING_POLICY",type:"positive",tagText:"Shipping policy"},{key:"RETURN_AND_REFUND",type:"purple",tagText:"Returns & refund policy"},{key:"CONTACT_INFO",type:"warning",tagText:"Contact details"},{key:"STORE_LOCATION",type:"grey",tagText:"Store location"},{key:"SALES_AND_OFFERS",type:"purple",tagText:"Offers & rewards"},{key:"PRODUCT_CUSTOMISATION",type:"blue",tagText:"Product customisation"},{key:"PRODUCT_DETAILS",type:"blue",tagText:"Product details"},{key:"PAYMENT_METHODS",type:"positive",tagText:"Payment methods"},{key:"ORDER_TRACKING",type:"warning",tagText:"Order tracking"},{key:"PRODUCT_SEARCH",type:"neutral",tagText:"Product search"},{key:"PURCHASE",type:"blue",tagText:"Purchase"},{key:"CONNECT_TO_AGENT",type:"purple",tagText:"Talk to a person"},{key:"CHECKOUT_ENQUIRY",type:"purple",tagText:"Checkout enquiry"},{key:"ORDER_CANCELLATION",type:"positive",tagText:"Order cancellation"},{key:"ORDER_ENQUIRY",type:"neutral",tagText:"Order enquiry"},{key:"ORDER_MODIFICATION",type:"blue",tagText:"Order modification"},{key:"SUBSCRIPTION_ENQUIRY",type:"warning",tagText:"Subscription enquiry"},{key:"SALES_AND_OFFERS_ISSUES",type:"grey",tagText:"Offer-related enquiries"},{key:"COLLABORATION",type:"positive",tagText:"Collaboration"},{key:"QUIZ_GENERATION",type:"warning",tagText:"Start the quiz"},{key:"SIMILAR_PRODUCT",type:"blue",tagText:"Similar Product"},{key:"EMAIL_COLLECTION",type:"warning",tagText:"Email Collection"},{key:"ADD_TO_CART_SUCCESS",type:"blue",tagText:"Add to Cart Success"},{key:"ADD_TO_CART_SUCCESS_MESSAGE",type:"blue",tagText:"Add to Cart Success Message"},{key:"FEEDBACK",type:"blue",tagText:"Feedback"},{key:"PHONE_NUMBER_COLLECTION",type:"blue",tagText:"Phone no. collection"}].forEach((t=>{let{key:i,type:o,tagText:n}=t;B[i]&&(ne[B[i]]=e(O,{theme:"light",type:o,tagText:n,cursor:"pointer"}))}));const se=h((()=>{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=>{B[t]&&(e[B[t]]=B[t])})),["COLLABORATION","SUBSCRIPTION_ENQUIRY"].forEach((t=>{e[t]=t})),e}),[B]);T((()=>{var e,t,i,o;if(!(null==j?void 0:j.messageId))return;V(!0),J(!1!==(null===(t=null===(e=j.sources)||void 0===e?void 0:e[0])||void 0===t?void 0:t.isTrainable)||!!(null===(o=null===(i=j.sources)||void 0===i?void 0:i[0])||void 0===o?void 0:o.insights));const n=j.sources.filter((e=>!!e.productId)).map((e=>e.productId)),s=Array.from(new Set(n)).filter((e=>!!e));W(k,s).then((e=>te(e))).then((()=>{Q||Y(k).then((e=>oe(e))).then((()=>{setTimeout((()=>V(!1)),100)}))}))}),[W,Y,null==j?void 0:j.messageId,j.sources,Q,k]);const re=e=>!(0!==e.length&&!(null==j?void 0:j.isUnsatisfactoryAnswer)),le=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];var i;return"custom"==e?e=N.FILES:z.includes(e)?e=N.FETCHED_LINKS:"url"==e?e=N.WEBSITE_LINKS:"text"===e?e=N.TEXTS:"faq"===e&&(e=N.FAQ),t?e:null===(i=null==e?void 0:e.toLowerCase())||void 0===i?void 0:i.replace(/_/g," ")};return X||!P?e(b,{children:e(v,{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"}]})}):e(t,{children:e(b,{children:i(t,{children:[i("div",Object.assign({className:"pop-up-header",style:{display:"flex",flexDirection:"column",paddingBottom:"12px"}},{children:[!!M&&e(E,{children:M}),i("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",alignItems:"center"}},{children:[e(x,Object.assign({color:C.content.secondary},{children:"Intent"})),null!==(A=ne[j.intent])&&void 0!==A?A:ne.GENERIC,!F&&e("div",Object.assign({style:{display:"flex",marginLeft:"auto",cursor:"pointer"},onClick:()=>D(void 0)},{children:e(n,{height:20,width:20,color:C.content.secondary})}))]})),re($)?e("div",Object.assign({style:{display:"flex",margin:"auto",justifyContent:"center",alignItems:"center",height:"calc(100vh - 300px)"}},{children:(()=>{var t,o;return i("div",Object.assign({style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",margin:"0px 30px",gap:"8px"}},{children:[e("div",Object.assign({style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"12px",backgroundColor:`${C.background.negative.light}`,borderRadius:"100px"}},{children:e(a,{width:24,height:24,color:C.stroke.negative.vibrant})})),e("div",Object.assign({style:{justifyContent:"center",alignItems:"center",marginBottom:"-4px"}},{children:e(E,{children:"Insufficient data"})})),e(S,Object.assign({color:C.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"})),H&&e("div",Object.assign({style:{display:"flex",width:"100%"}},{children:e(m,{LeadingIcon:null!==(t=H.leadingIcon)&&void 0!==t?t:d,buttonText:null!==(o=H.title)&&void 0!==o?o:"Add FAQ",buttonType:"secondary",size:"small",matchParentWidth:!0,onClick:()=>{H.onClick()}})}))]}))})()})):e(O,{LeadingIcon:a,version:"2.0",type:"grey",theme:"light",alignIcon:"start",contentPadding:12,tagText:j.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 Manifest.":"Edit the original source and save again to update the response"})]})),!re($)&&e("div",Object.assign({className:"info-container"},{children:e("div",Object.assign({style:{padding:"0 8px",maxWidth:"100%"}},{children:$.map(((n,a)=>{var d,y,h,T,m,v,O,E,L,b,_,A,w,R,k,j,D;const F=le(n.type||n.subTitle||"OpenAI"),P=le(n.type||n.subTitle||"OpenAI",!0),M=(H=F)?"faq"==H.toLocaleLowerCase()?"FAQ":"openai"==H.toLocaleLowerCase()?"OPENAI":"files"==H.toLocaleLowerCase()?"PDF":"texts"==H.toLocaleLowerCase()?"Custom text":((H=(H=H.charAt(0).toUpperCase()+H.slice(1).toLowerCase()).replace("_"," ")).endsWith("s")&&(H=H.slice(0,-1)),H.replace("Website","Manual")):"";var H;const Q=null==K?void 0:K.includes(P),G="Products"===n.subTitle?U[null!==(d=n.productId)&&void 0!==d?d:"Products"]:U[null!==(y=n.docId)&&void 0!==y?y:""],Y=P.toLowerCase()===(null===(h=N.FAQ)||void 0===h?void 0:h.toLowerCase())?"faq"===(null===(T=n.title)||void 0===T?void 0:T.toLowerCase())?n.subTitle:n.title:P.toLowerCase()===(null===(m=N.FILES)||void 0===m?void 0:m.toLowerCase())||P.toLowerCase()===(null===(v=N.FETCHED_LINKS)||void 0===v?void 0:v.toLowerCase())||P.toLowerCase()===(null===(O=N.TEXTS)||void 0===O?void 0:O.toLowerCase())?n.title:P.toLowerCase()===(null===(E=N.WEBSITE_LINKS)||void 0===E?void 0:E.toLowerCase())?n.title.split("/")[n.title.split("/").length-1].replace(/[^\w\s]/gi," ").replace(/^(.)(.*)$/,((e,t,i)=>t.toUpperCase()+i)):n.intent===B.EMAIL_COLLECTION?M:n.title,W="faq"===P.toLowerCase()?null!==(_=null!==(L=null==G?void 0:G.content)&&void 0!==L?L:null===(b=null==G?void 0:G.data)||void 0===b?void 0:b.answer)&&void 0!==_?_:"":P.toLowerCase()===(null===(A=N.FETCHED_LINKS)||void 0===A?void 0:A.toLowerCase())||P.toLowerCase()===(null===(w=N.WEBSITE_LINKS)||void 0===w?void 0:w.toLowerCase())||P.toLowerCase()===(null===(R=N.TEXTS)||void 0===R?void 0:R.toLowerCase())?null!==(D=null!==(k=null==G?void 0:G.content)&&void 0!==k?k:null===(j=null==G?void 0:G.data)||void 0===j?void 0:j.fileContentText)&&void 0!==D?D:"":n.intent===B.EMAIL_COLLECTION?"Collect leads before replying to messages":"";return i("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"8px",padding:"24px 0px",borderBottom:`1px solid ${C.stroke.primary}`}},{children:[i("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",justifyContent:"space-between",alignItems:"center"}},{children:[e("div",Object.assign({style:{flex:1}},{children:e(f,Object.assign({body:Y,placement:"top"},{children:e(S,Object.assign({style:P==N.FETCHED_LINKS||P==N.WEBSITE_LINKS?{cursor:"pointer",textDecoration:"underline"}:{},color:C.content.primary,className:"clamp-title",onClick:()=>P==N.FETCHED_LINKS||P==N.WEBSITE_LINKS?q(n):{}},{children:Y}))}))})),i("div",Object.assign({style:{display:"flex",flexDirection:"row",justifyContent:"flex-end",alignItems:"center",gap:"4px",flex:"none"}},{children:[n.intent!==B.EMAIL_COLLECTION&&i(t,{children:[(z=F,e("products"==z||"product"==z?o:"files"==z?r:"website links"==z||"fetched links"==z?g:"faq"==z?l:"texts"==z?u:c,{height:16,width:16,color:C.content.secondary})),e(x,Object.assign({color:C.content.secondary},{children:M}))]}),(n.link||n.docId)&&e("div",Object.assign({style:{cursor:"pointer",marginLeft:"4px"}},{children:e(I,Q?{Icon:s,height:16,width:16,bordered:!0,onClick:()=>null==G?void 0:G.onEditClick(G.data,G.type),disabled:!G,disabledTooltip:"This source is deleted"}:{Icon:p,height:16,width:16,bordered:!0,disabled:"custom"===n.type&&!G,disabledTooltip:"This source is deleted",onClick:()=>q(n)})}))]}))]})),(null!=W?W:"").trim()&&e("div",Object.assign({style:{padding:"4px 8px",border:`1px dashed ${C.stroke.primary}`,borderRadius:"4px",backgroundColor:C.surface.subdued}},{children:e(x,Object.assign({color:C.content.primary,className:"clamp-description"},{children:($=null!=W?W:"",$.replace(/(<([^>]+)>)/gi,"")).trim()}))}))]}),`info-${a}`);var $,z}))}))})),Z&&!re($)&&e("div",Object.assign({className:"footer"},{children:e(L,{appType:R,storeId:k,messageSource:j,sourceIntent:null!==(w=j.intent)&&void 0!==w?w:B.GENERIC,faqCount:ee,trainingSourceCount:ie,ShowTrainingDataSource:se,ChecklistType:B,footerButtonOption:G})}))]})})})};export{_ as DataSourcePanel};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bikdotai/bik-component-library",
3
- "version": "0.0.655-4",
3
+ "version": "0.0.655-5",
4
4
  "description": "Bik Component Library",
5
5
  "repository": {
6
6
  "type": "git",