@bikdotai/bik-component-library 0.0.660-1 → 0.0.660-2

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/boxV2.svg.js"),s=require("../../assets/icons/cross.svg.js"),i=require("../../assets/icons/edit.svg.js"),o=require("../../assets/icons/filePdf.svg.js"),n=require("../../assets/icons/help.svg.js"),a=require("../../assets/icons/info.svg.js"),l=require("../../assets/icons/openai.svg.js"),r=require("../../assets/icons/plus.svg.js"),c=require("../../assets/icons/redirect.svg.js"),d=require("../../assets/icons/text_t9.svg.js"),u=require("../../assets/icons/website.svg.js"),p=require("react"),x=require("../../constants/Theme.js"),g=require("../button/Button.js"),h=require("../icon-button/IconButton.js"),C=require("../shimmer/ShimmerComponent/BikShimmer.js"),y=require("../side-modal/SideModal.js"),j=require("../tag/Tag.js"),O=require("../tooltips/Tooltip.js"),f=require("../TypographyStyle.js"),m=require("./DataSourceInfoFooter.js"),S=require("./DataSourcePanel.style.js"),T=require("./IntentConfig.js"),v=require("./Modals/DescriptionModal.js"),I=require("./model.js");exports.DataSourcePanel=L=>{var b,E;const{appType:D,storeId:w,messageSource:N,setMessageSourcePanel:R,hideCloseButton:B,isSourceInfoFetched:_,allSourceInfoDetail:q,ChecklistType:A,title:F,zeroStateButton:k,editableSources:P,preFillTrainingSourceCount:U,redirect:M,footerButtonOption:K,fetchTrainingSourceCount:W,fetchProductFAQCount:H,productSourceData:$}=L,{sources:Q}=N,Y=["blog","article","page","policy"],[G,X]=p.useState(!1),[z,V]=p.useState(!1),[J,Z]=p.useState(0),[ee,te]=p.useState(),[se,ie]=p.useState(null!=U?U:{}),oe={};T.intentConfig.forEach((t=>{let{key:s,type:i,tagText:o}=t;A[s]&&(oe[A[s]]=e.jsx(j.Tag,{theme:"light",type:i,tagText:o,cursor:"pointer"}))}));const ne=Q.filter((e=>"PRODUCTS"==e.type||"Products"==e.subTitle||e.productId)),ae=Q.filter((e=>"PRODUCTS"!=e.type&&"Products"!=e.subTitle&&!e.productId)),le=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((()=>{}),[H,W,null==N?void 0:N.messageId,N.sources,U,w]);const re=e=>!!(e&&0===e.length||(null==N?void 0:N.isUnsatisfactoryAnswer)),ce=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];var s;return"custom"==e?e=I.CustomDataType.FILES:Y.includes(e)?e=I.CustomDataType.FETCHED_LINKS:"url"==e?e=I.CustomDataType.WEBSITE_LINKS:"text"===e?e=I.CustomDataType.TEXTS:"faq"===e&&(e=I.CustomDataType.FAQ),t?e:null===(s=null==e?void 0:e.toLowerCase())||void 0===s?void 0:s.replace(/_/g," ")},de=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")):"",ue=s=>"products"==s||"product"==s?e.jsx(t.default,{height:16,width:16,color:x.COLORS.content.secondary}):"files"==s?e.jsx(o.default,{height:16,width:16,color:x.COLORS.content.secondary}):"website links"==s||"fetched links"==s?e.jsx(u.default,{height:16,width:16,color:x.COLORS.content.secondary}):"faq"==s?e.jsx(n.default,{height:16,width:16,color:x.COLORS.content.secondary}):"texts"==s?e.jsx(d.default,{height:16,width:16,color:x.COLORS.content.secondary}):e.jsx(l.default,{height:16,width:16,color:x.COLORS.content.secondary}),pe=e=>{const t=e.replace(/(<([^>]+)>)/gi,""),s=document.createElement("textarea");return s.innerHTML=t,s.value};return G||!_?e.jsx(S.SourceInfoDetailsStyle,{children:e.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"}]})}):e.jsxs(e.Fragment,{children:[e.jsx(S.SourceInfoDetailsStyle,{children:e.jsxs(e.Fragment,{children:[e.jsxs("div",Object.assign({className:"pop-up-header",style:{display:"flex",flexDirection:"column",paddingBottom:"12px"}},{children:[!!F&&e.jsx(f.TitleSmall,{children:F}),e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",alignItems:"center"}},{children:[e.jsx(f.BodyCaption,Object.assign({color:x.COLORS.content.secondary},{children:"Intent"})),null!==(b=oe[N.intent])&&void 0!==b?b:oe.GENERIC,!B&&e.jsx("div",Object.assign({style:{display:"flex",marginLeft:"auto",cursor:"pointer"},onClick:()=>R(void 0)},{children:e.jsx(s.default,{height:20,width:20,color:x.COLORS.content.secondary})}))]})),re(Q)?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:`${x.COLORS.background.negative.light}`,borderRadius:"100px"}},{children:e.jsx(a.default,{width:24,height:24,color:x.COLORS.stroke.negative.vibrant})})),e.jsx("div",Object.assign({style:{justifyContent:"center",alignItems:"center",marginBottom:"-4px"}},{children:e.jsx(f.TitleSmall,{children:"Insufficient data"})})),e.jsx(f.BodySecondary,Object.assign({color:x.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:r.default,buttonText:null!==(s=k.title)&&void 0!==s?s:"Add FAQ",buttonType:"secondary",size:"small",matchParentWidth:!0,onClick:()=>{k.onClick()}})}))]}))})()})):e.jsx(j.Tag,{LeadingIcon:a.default,version:"2.0",type:"grey",theme:"light",alignIcon:"start",contentPadding:12,tagText:N.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 ${D===I.AppType.BIK?"BIK":"Manifest"}.`:"Edit the original source and save again to update the response"})]})),!re(Q)&&e.jsxs("div",Object.assign({className:"info-container"},{children:[e.jsxs("div",Object.assign({className:"info-product-source"},{children:[e.jsx(f.BodyCaption,{children:"Product Source"}),e.jsx("div",Object.assign({className:"source",style:{padding:"0 12px",maxWidth:"100%"}},{children:Q.filter((e=>"PRODUCTS"==e.type||"Products"==e.subTitle||e.productId)).map(((t,s)=>{var o;const n=ce(t.type||t.subTitle||"OpenAI"),a=ce(t.type||t.subTitle||"OpenAI",!0),l=de(n),r=null==P?void 0:P.includes(a),d=q[null!==(o=t.productId)&&void 0!==o?o:"Products"],u=t.title,p=t.productId&&(null==$?void 0:$[t.productId]),g=p&&p.metafield.join(", ");return e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"8px",padding:"16px 0px",borderBottom:s+1<ne.length?`1px solid ${x.COLORS.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:[ue(n),e.jsx(O.Tooltip,Object.assign({body:u,placement:"top"},{children:e.jsx(f.BodySecondary,Object.assign({style:a==I.CustomDataType.FETCHED_LINKS||a==I.CustomDataType.WEBSITE_LINKS?{cursor:"pointer",textDecoration:"underline"}:{},color:x.COLORS.content.primary,className:"clamp-title",onClick:()=>a==I.CustomDataType.FETCHED_LINKS||a==I.CustomDataType.WEBSITE_LINKS?M(t):{}},{children:u}))}))]})),e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",justifyContent:"flex-end",alignItems:"center",gap:"4px",flex:"none"}},{children:[t.intent!==A.EMAIL_COLLECTION&&e.jsx(e.Fragment,{children:e.jsx(f.BodyCaption,Object.assign({color:x.COLORS.content.secondary},{children:l}))}),(t.link||t.docId)&&e.jsx("div",Object.assign({style:{cursor:"pointer",marginLeft:"0px"}},{children:r?e.jsx(h.IconButton,{Icon:i.default,height:16,width:16,iconColor:x.COLORS.content.secondary,onClick:()=>null==d?void 0:d.onEditClick(d.data,d.type),disabled:!d,disabledTooltip:"This source is deleted"}):e.jsx(h.IconButton,{Icon:c.default,height:16,width:16,iconColor:x.COLORS.content.secondary,disabled:"custom"===t.type&&!d,disabledTooltip:"This source is deleted",onClick:()=>M(t)})}))]}))]})),p&&e.jsxs("div",Object.assign({className:"product-data"},{children:[e.jsx(f.BodyCaption,Object.assign({className:"product-data-text",onClick:()=>{var e;te({title:u,description:pe(p.description),imageUrl:null!==(e=t.imageUrl)&&void 0!==e?e:"",onClose:()=>te(void 0)})}},{children:`${p.description.length} characters description,`})),e.jsx(f.BodyCaption,Object.assign({className:"product-data-text",onClick:()=>p.onEditFaqClick(p.faqs)},{children:`${p.faqs.length} FAQs,`})),e.jsx(O.Tooltip,Object.assign({body:g},{children:e.jsx(f.BodyCaption,Object.assign({className:"product-data-text"},{children:`${p.metafield.length} metafields`}))}))]}))]}),`info-${s}`)}))}))]})),e.jsxs("div",Object.assign({className:"info-content-source"},{children:[e.jsx(f.BodyCaption,{children:"Content Source"}),e.jsx("div",Object.assign({className:"source",style:{padding:"0 12px",maxWidth:"100%"}},{children:Q.filter((e=>"PRODUCTS"!=e.type&&"Products"!=e.subTitle&&!e.productId)).map(((t,s)=>{var o,n,a,l,r,d,u,p,g,C,y,j,m,S,T,v,L;const b=ce(t.type||t.subTitle||"OpenAI"),E=ce(t.type||t.subTitle||"OpenAI",!0),D=de(b),w=null==P?void 0:P.includes(E),N="Products"===t.subTitle?q[null!==(o=t.productId)&&void 0!==o?o:"Products"]:q[null!==(n=t.docId)&&void 0!==n?n:""],R=E.toLowerCase()===(null===(a=I.CustomDataType.FAQ)||void 0===a?void 0:a.toLowerCase())?"faq"===(null===(l=t.title)||void 0===l?void 0:l.toLowerCase())?t.subTitle:t.title:E.toLowerCase()===(null===(r=I.CustomDataType.FILES)||void 0===r?void 0:r.toLowerCase())||E.toLowerCase()===(null===(d=I.CustomDataType.FETCHED_LINKS)||void 0===d?void 0:d.toLowerCase())||E.toLowerCase()===(null===(u=I.CustomDataType.TEXTS)||void 0===u?void 0:u.toLowerCase())?t.title:E.toLowerCase()===(null===(p=I.CustomDataType.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===A.EMAIL_COLLECTION?D:t.title,B="faq"===E.toLowerCase()?null!==(y=null!==(g=null==N?void 0:N.content)&&void 0!==g?g:null===(C=null==N?void 0:N.data)||void 0===C?void 0:C.answer)&&void 0!==y?y:"":E.toLowerCase()===(null===(j=I.CustomDataType.FETCHED_LINKS)||void 0===j?void 0:j.toLowerCase())||E.toLowerCase()===(null===(m=I.CustomDataType.WEBSITE_LINKS)||void 0===m?void 0:m.toLowerCase())||E.toLowerCase()===(null===(S=I.CustomDataType.TEXTS)||void 0===S?void 0:S.toLowerCase())?null!==(L=null!==(T=null==N?void 0:N.content)&&void 0!==T?T:null===(v=null==N?void 0:N.data)||void 0===v?void 0:v.fileContentText)&&void 0!==L?L:"":t.intent===A.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<ae.length?`1px solid ${x.COLORS.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:[ue(b),e.jsx(O.Tooltip,Object.assign({body:R,placement:"top"},{children:e.jsx(f.BodySecondary,Object.assign({style:E==I.CustomDataType.FETCHED_LINKS||E==I.CustomDataType.WEBSITE_LINKS?{cursor:"pointer",textDecoration:"underline"}:{},color:x.COLORS.content.primary,className:"clamp-title",onClick:()=>E==I.CustomDataType.FETCHED_LINKS||E==I.CustomDataType.WEBSITE_LINKS?M(t):{}},{children:R}))}))]})),e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",justifyContent:"flex-end",alignItems:"center",gap:"4px",flex:"none"}},{children:[t.intent!==A.EMAIL_COLLECTION&&e.jsx(e.Fragment,{children:e.jsx(f.BodyCaption,Object.assign({color:x.COLORS.content.secondary},{children:D}))}),(t.link||t.docId)&&e.jsx("div",Object.assign({style:{cursor:"pointer",marginLeft:"0px"}},{children:w?e.jsx(h.IconButton,{Icon:i.default,height:16,width:16,iconColor:x.COLORS.content.secondary,onClick:()=>null==N?void 0:N.onEditClick(N.data,N.type),disabled:!N,disabledTooltip:"This source is deleted"}):e.jsx(h.IconButton,{Icon:c.default,height:16,width:16,iconColor:x.COLORS.content.secondary,disabled:"custom"===t.type&&!N,disabledTooltip:"This source is deleted",onClick:()=>M(t)})}))]}))]})),(null!=B?B:"").trim()&&e.jsx("div",Object.assign({style:{padding:"4px 8px",border:`1px dashed ${x.COLORS.stroke.primary}`,borderRadius:"4px",backgroundColor:x.COLORS.surface.subdued}},{children:e.jsx(f.BodyCaption,Object.assign({color:x.COLORS.content.primary,className:"clamp-description"},{children:pe(null!=B?B:"").trim()}))}))]}),`info-${s}`)}))}))]}))]})),z&&!re(Q)&&e.jsx("div",Object.assign({className:"footer"},{children:e.jsx(m.default,{appType:D,storeId:w,messageSource:N,sourceIntent:null!==(E=N.intent)&&void 0!==E?E:A.GENERIC,faqCount:J,trainingSourceCount:se,ShowTrainingDataSource:le,ChecklistType:A,footerButtonOption:K})}))]})}),ee&&e.jsx(y.SideModal,Object.assign({header:"Product description",onClose:()=>te(void 0)},{children:e.jsx(v.DescriptionModal,{title:ee.title,description:ee.description,imageUrl:ee.imageUrl,onClose:ee.onClose})}))]})};
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"),s=require("../../assets/icons/edit.svg.js"),o=require("../../assets/icons/filePdf.svg.js"),n=require("../../assets/icons/help.svg.js"),l=require("../../assets/icons/info.svg.js"),a=require("../../assets/icons/openai.svg.js"),r=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"),g=require("../../constants/Theme.js"),h=require("../button/Button.js"),x=require("../icon-button/IconButton.js"),C=require("../shimmer/ShimmerComponent/BikShimmer.js"),y=require("../side-modal/SideModal.js"),j=require("../tag/Tag.js"),O=require("../tooltips/Tooltip.js"),m=require("../TypographyStyle.js"),f=require("./DataSourceInfoFooter.js"),v=require("./DataSourcePanel.style.js"),S=require("./IntentConfig.js"),T=require("./Modals/DescriptionModal.js"),I=require("./model.js");exports.DataSourcePanel=L=>{var b,E;const{appType:w,storeId:D,messageSource:N,setMessageSourcePanel:R,hideCloseButton:B,isSourceInfoFetched:_,allSourceInfoDetail:q,ChecklistType:A,title:F,zeroStateButton:k,editableSources:P,preFillTrainingSourceCount:M,redirect:U,footerButtonOption:K,fetchTrainingSourceCount:W,fetchProductFAQCount:H,productSourceData:$}=L,{sources:Q}=N,Y=["blog","article","page","policy"],[G,X]=p.useState(!1),[z,V]=p.useState(!1),[J,Z]=p.useState(0),[ee,te]=p.useState(),[ie,se]=p.useState(null!=M?M:{}),oe={};S.intentConfig.forEach((t=>{let{key:i,type:s,tagText:o}=t;A[i]&&(oe[A[i]]=e.jsx(j.Tag,{theme:"light",type:s,tagText:o,cursor:"pointer"}))}));const ne=Q.filter((e=>"PRODUCTS"==e.type||"Products"==e.subTitle||e.productId)),le=Q.filter((e=>"PRODUCTS"!=e.type&&"Products"!=e.subTitle&&!e.productId)),ae=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((()=>{}),[H,W,null==N?void 0:N.messageId,N.sources,M,D]);const re=e=>!!(e&&0===e.length||(null==N?void 0:N.isUnsatisfactoryAnswer)),de=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];var i;return"custom"==e?e=I.CustomDataType.FILES:Y.includes(e)?e=I.CustomDataType.FETCHED_LINKS:"url"==e?e=I.CustomDataType.WEBSITE_LINKS:"text"===e?e=I.CustomDataType.TEXTS:"faq"===e&&(e=I.CustomDataType.FAQ),t?e:null===(i=null==e?void 0:e.toLowerCase())||void 0===i?void 0:i.replace(/_/g," ")},ce=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")):"",ue=i=>"products"==i||"product"==i?e.jsx(t.default,{height:16,width:16,color:g.COLORS.content.secondary}):"files"==i?e.jsx(o.default,{height:16,width:16,color:g.COLORS.content.secondary}):"website links"==i||"fetched links"==i?e.jsx(u.default,{height:16,width:16,color:g.COLORS.content.secondary}):"faq"==i?e.jsx(n.default,{height:16,width:16,color:g.COLORS.content.secondary}):"texts"==i?e.jsx(c.default,{height:16,width:16,color:g.COLORS.content.secondary}):e.jsx(a.default,{height:16,width:16,color:g.COLORS.content.secondary}),pe=e=>{const t=e.replace(/(<([^>]+)>)/gi,""),i=document.createElement("textarea");return i.innerHTML=t,i.value};return G||!_?e.jsx(v.SourceInfoDetailsStyle,{children:e.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"}]})}):e.jsxs(e.Fragment,{children:[e.jsx(v.SourceInfoDetailsStyle,{children:e.jsxs(e.Fragment,{children:[e.jsxs("div",Object.assign({className:"pop-up-header",style:{display:"flex",flexDirection:"column",paddingBottom:"12px"}},{children:[!!F&&e.jsx(m.TitleSmall,{children:F}),e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",alignItems:"center"}},{children:[e.jsx(m.BodyCaption,Object.assign({color:g.COLORS.content.secondary},{children:"Intent"})),null!==(b=oe[N.intent])&&void 0!==b?b:oe.GENERIC,!B&&e.jsx("div",Object.assign({style:{display:"flex",marginLeft:"auto",cursor:"pointer"},onClick:()=>R(void 0)},{children:e.jsx(i.default,{height:20,width:20,color:g.COLORS.content.secondary})}))]})),re(Q)?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:`${g.COLORS.background.negative.light}`,borderRadius:"100px"}},{children:e.jsx(l.default,{width:24,height:24,color:g.COLORS.stroke.negative.vibrant})})),e.jsx("div",Object.assign({style:{justifyContent:"center",alignItems:"center",marginBottom:"-4px"}},{children:e.jsx(m.TitleSmall,{children:"Insufficient data"})})),e.jsx(m.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"})),k&&e.jsx("div",Object.assign({style:{display:"flex",width:"100%"}},{children:e.jsx(h.Button,{LeadingIcon:null!==(t=k.leadingIcon)&&void 0!==t?t:r.default,buttonText:null!==(i=k.title)&&void 0!==i?i:"Add FAQ",buttonType:"secondary",size:"small",matchParentWidth:!0,onClick:()=>{k.onClick()}})}))]}))})()})):e.jsx(j.Tag,{LeadingIcon:l.default,version:"2.0",type:"grey",theme:"light",alignIcon:"start",contentPadding:12,tagText:N.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 ${w===I.AppType.BIK?"BIK":"Manifest"}.`:"Edit the original source and save again to update the response"})]})),!re(Q)&&e.jsxs("div",Object.assign({className:"info-container"},{children:[ne.length>0&&e.jsxs("div",Object.assign({className:"info-product-source"},{children:[e.jsx(m.BodyCaption,{children:"Product Source"}),e.jsx("div",Object.assign({className:"source",style:{padding:"0 12px",maxWidth:"100%"}},{children:ne.map(((t,i)=>{var o,n,l,a;const r=de(t.type||t.subTitle||"OpenAI"),c=de(t.type||t.subTitle||"OpenAI",!0),u=ce(r),p=null==P?void 0:P.includes(c),h=q[null!==(o=t.productId)&&void 0!==o?o:"Products"],C=t.title,y=t.productId&&(null==$?void 0:$[t.productId]),j=y&&y.metafield.join(", ");return e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"8px",padding:"16px 0px",borderBottom:i+1<(null==ne?void 0:ne.length)?`1px solid ${g.COLORS.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:[ue(r),e.jsx(O.Tooltip,Object.assign({body:C,placement:"top"},{children:e.jsx(m.BodySecondary,Object.assign({style:c==I.CustomDataType.FETCHED_LINKS||c==I.CustomDataType.WEBSITE_LINKS?{cursor:"pointer",textDecoration:"underline"}:{},color:g.COLORS.content.primary,className:"clamp-title",onClick:()=>c==I.CustomDataType.FETCHED_LINKS||c==I.CustomDataType.WEBSITE_LINKS?U(t):{}},{children:C}))}))]})),e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",justifyContent:"flex-end",alignItems:"center",gap:"4px",flex:"none"}},{children:[t.intent!==A.EMAIL_COLLECTION&&e.jsx(e.Fragment,{children:e.jsx(m.BodyCaption,Object.assign({color:g.COLORS.content.secondary},{children:u}))}),(t.link||t.docId)&&e.jsx("div",Object.assign({style:{cursor:"pointer",marginLeft:"0px"}},{children:p?e.jsx(x.IconButton,{Icon:s.default,height:16,width:16,iconColor:g.COLORS.content.secondary,onClick:()=>null==h?void 0:h.onEditClick(h.data,h.type),disabled:!h,disabledTooltip:"This source is deleted"}):e.jsx(x.IconButton,{Icon:d.default,height:16,width:16,iconColor:g.COLORS.content.secondary,disabled:"custom"===t.type&&!h,disabledTooltip:"This source is deleted",onClick:()=>U(t)})}))]}))]})),y&&e.jsxs("div",Object.assign({className:"product-data"},{children:[e.jsx(m.BodyCaption,Object.assign({className:"product-data-text",onClick:()=>{var e;te({title:C,description:pe(y.description),imageUrl:null!==(e=t.imageUrl)&&void 0!==e?e:"",onClose:()=>te(void 0)})}},{children:`${null===(n=y.description)||void 0===n?void 0:n.length} characters description,`})),e.jsx(m.BodyCaption,Object.assign({className:"product-data-text",onClick:()=>y.onEditFaqClick(y.faqs)},{children:`${null===(l=y.faqs)||void 0===l?void 0:l.length} FAQs,`})),e.jsx(O.Tooltip,Object.assign({body:j},{children:e.jsx(m.BodyCaption,Object.assign({className:"product-data-text"},{children:`${null===(a=y.metafield)||void 0===a?void 0:a.length} metafields`}))}))]}))]}),`info-${i}`)}))}))]})),le.length>0&&e.jsxs("div",Object.assign({className:"info-content-source"},{children:[e.jsx(m.BodyCaption,{children:"Content Source"}),e.jsx("div",Object.assign({className:"source",style:{padding:"0 12px",maxWidth:"100%"}},{children:le.map(((t,i)=>{var o,n,l,a,r,c,u,p,h,C,y,j,f,v,S,T,L;const b=de(t.type||t.subTitle||"OpenAI"),E=de(t.type||t.subTitle||"OpenAI",!0),w=ce(b),D=null==P?void 0:P.includes(E),N="Products"===t.subTitle?q[null!==(o=t.productId)&&void 0!==o?o:"Products"]:q[null!==(n=t.docId)&&void 0!==n?n:""],R=E.toLowerCase()===(null===(l=I.CustomDataType.FAQ)||void 0===l?void 0:l.toLowerCase())?"faq"===(null===(a=t.title)||void 0===a?void 0:a.toLowerCase())?t.subTitle:t.title:E.toLowerCase()===(null===(r=I.CustomDataType.FILES)||void 0===r?void 0:r.toLowerCase())||E.toLowerCase()===(null===(c=I.CustomDataType.FETCHED_LINKS)||void 0===c?void 0:c.toLowerCase())||E.toLowerCase()===(null===(u=I.CustomDataType.TEXTS)||void 0===u?void 0:u.toLowerCase())?t.title:E.toLowerCase()===(null===(p=I.CustomDataType.WEBSITE_LINKS)||void 0===p?void 0:p.toLowerCase())?t.title.split("/")[t.title.split("/").length-1].replace(/[^\w\s]/gi," ").replace(/^(.)(.*)$/,((e,t,i)=>t.toUpperCase()+i)):t.intent===A.EMAIL_COLLECTION?w:t.title,B="faq"===E.toLowerCase()?null!==(y=null!==(h=null==N?void 0:N.content)&&void 0!==h?h:null===(C=null==N?void 0:N.data)||void 0===C?void 0:C.answer)&&void 0!==y?y:"":E.toLowerCase()===(null===(j=I.CustomDataType.FETCHED_LINKS)||void 0===j?void 0:j.toLowerCase())||E.toLowerCase()===(null===(f=I.CustomDataType.WEBSITE_LINKS)||void 0===f?void 0:f.toLowerCase())||E.toLowerCase()===(null===(v=I.CustomDataType.TEXTS)||void 0===v?void 0:v.toLowerCase())?null!==(L=null!==(S=null==N?void 0:N.content)&&void 0!==S?S:null===(T=null==N?void 0:N.data)||void 0===T?void 0:T.fileContentText)&&void 0!==L?L:"":t.intent===A.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:i+1<(null==le?void 0:le.length)?`1px solid ${g.COLORS.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:[ue(b),e.jsx(O.Tooltip,Object.assign({body:R,placement:"top"},{children:e.jsx(m.BodySecondary,Object.assign({style:E==I.CustomDataType.FETCHED_LINKS||E==I.CustomDataType.WEBSITE_LINKS?{cursor:"pointer",textDecoration:"underline"}:{},color:g.COLORS.content.primary,className:"clamp-title",onClick:()=>E==I.CustomDataType.FETCHED_LINKS||E==I.CustomDataType.WEBSITE_LINKS?U(t):{}},{children:R}))}))]})),e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",justifyContent:"flex-end",alignItems:"center",gap:"4px",flex:"none"}},{children:[t.intent!==A.EMAIL_COLLECTION&&e.jsx(e.Fragment,{children:e.jsx(m.BodyCaption,Object.assign({color:g.COLORS.content.secondary},{children:w}))}),(t.link||t.docId)&&e.jsx("div",Object.assign({style:{cursor:"pointer",marginLeft:"0px"}},{children:D?e.jsx(x.IconButton,{Icon:s.default,height:16,width:16,iconColor:g.COLORS.content.secondary,onClick:()=>null==N?void 0:N.onEditClick(N.data,N.type),disabled:!N,disabledTooltip:"This source is deleted"}):e.jsx(x.IconButton,{Icon:d.default,height:16,width:16,iconColor:g.COLORS.content.secondary,disabled:"custom"===t.type&&!N,disabledTooltip:"This source is deleted",onClick:()=>U(t)})}))]}))]})),(null!=B?B:"").trim()&&e.jsx("div",Object.assign({style:{padding:"4px 8px",border:`1px dashed ${g.COLORS.stroke.primary}`,borderRadius:"4px",backgroundColor:g.COLORS.surface.subdued}},{children:e.jsx(m.BodyCaption,Object.assign({color:g.COLORS.content.primary,className:"clamp-description"},{children:pe(null!=B?B:"").trim()}))}))]}),`info-${i}`)}))}))]}))]})),z&&!re(Q)&&e.jsx("div",Object.assign({className:"footer"},{children:e.jsx(f.default,{appType:w,storeId:D,messageSource:N,sourceIntent:null!==(E=N.intent)&&void 0!==E?E:A.GENERIC,faqCount:J,trainingSourceCount:ie,ShowTrainingDataSource:ae,ChecklistType:A,footerButtonOption:K})}))]})}),ee&&e.jsx(y.SideModal,Object.assign({header:"Product description",onClose:()=>te(void 0),width:"30%"},{children:e.jsx(T.DescriptionModal,{title:ee.title,description:ee.description,imageUrl:ee.imageUrl,onClose:ee.onClose})}))]})};
@@ -1 +1 @@
1
- import{jsx as e,jsxs as t,Fragment 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 l from"../../assets/icons/filePdf.svg.js";import r from"../../assets/icons/help.svg.js";import c from"../../assets/icons/info.svg.js";import a 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 h,useMemo as m,useEffect as f}from"react";import{COLORS as y}from"../../constants/Theme.js";import{Button as C}from"../button/Button.js";import{IconButton as v}from"../icon-button/IconButton.js";import{BikShimmer as x}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 j,BodySecondary as E}from"../TypographyStyle.js";import L from"./DataSourceInfoFooter.js";import{SourceInfoDetailsStyle as S}from"./DataSourcePanel.style.js";import{intentConfig as w}from"./IntentConfig.js";import{DescriptionModal as N}from"./Modals/DescriptionModal.js";import{AppType as D,CustomDataType as _}from"./model.js";const A=A=>{var k,F;const{appType:P,storeId:R,messageSource:B,setMessageSourcePanel:U,hideCloseButton:K,isSourceInfoFetched:M,allSourceInfoDetail:W,ChecklistType:H,title:$,zeroStateButton:q,editableSources:Q,preFillTrainingSourceCount:Y,redirect:G,footerButtonOption:X,fetchTrainingSourceCount:z,fetchProductFAQCount:V,productSourceData:J}=A,{sources:Z}=B,ee=["blog","article","page","policy"],[te,ie]=h(!1),[oe,ne]=h(!1),[se,le]=h(0),[re,ce]=h(),[ae,de]=h(null!=Y?Y:{}),pe={};w.forEach((t=>{let{key:i,type:o,tagText:n}=t;H[i]&&(pe[H[i]]=e(b,{theme:"light",type:o,tagText:n,cursor:"pointer"}))}));const ue=Z.filter((e=>"PRODUCTS"==e.type||"Products"==e.subTitle||e.productId)),ge=Z.filter((e=>"PRODUCTS"!=e.type&&"Products"!=e.subTitle&&!e.productId)),he=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]);f((()=>{}),[V,z,null==B?void 0:B.messageId,B.sources,Y,R]);const me=e=>!!(e&&0===e.length||(null==B?void 0:B.isUnsatisfactoryAnswer)),fe=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];var i;return"custom"==e?e=_.FILES:ee.includes(e)?e=_.FETCHED_LINKS:"url"==e?e=_.WEBSITE_LINKS:"text"===e?e=_.TEXTS:"faq"===e&&(e=_.FAQ),t?e:null===(i=null==e?void 0:e.toLowerCase())||void 0===i?void 0:i.replace(/_/g," ")},ye=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")):"",Ce=t=>e("products"==t||"product"==t?o:"files"==t?l:"website links"==t||"fetched links"==t?g:"faq"==t?r:"texts"==t?u:a,{height:16,width:16,color:y.content.secondary}),ve=e=>{const t=e.replace(/(<([^>]+)>)/gi,""),i=document.createElement("textarea");return i.innerHTML=t,i.value};return te||!M?e(S,{children:e(x,{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"}]})}):t(i,{children:[e(S,{children:t(i,{children:[t("div",Object.assign({className:"pop-up-header",style:{display:"flex",flexDirection:"column",paddingBottom:"12px"}},{children:[!!$&&e(T,{children:$}),t("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",alignItems:"center"}},{children:[e(j,Object.assign({color:y.content.secondary},{children:"Intent"})),null!==(k=pe[B.intent])&&void 0!==k?k:pe.GENERIC,!K&&e("div",Object.assign({style:{display:"flex",marginLeft:"auto",cursor:"pointer"},onClick:()=>U(void 0)},{children:e(n,{height:20,width:20,color:y.content.secondary})}))]})),me(Z)?e("div",Object.assign({style:{display:"flex",margin:"auto",justifyContent:"center",alignItems:"center",height:"calc(100vh - 300px)"}},{children:(()=>{var i,o;return t("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:`${y.background.negative.light}`,borderRadius:"100px"}},{children:e(c,{width:24,height:24,color:y.stroke.negative.vibrant})})),e("div",Object.assign({style:{justifyContent:"center",alignItems:"center",marginBottom:"-4px"}},{children:e(T,{children:"Insufficient data"})})),e(E,Object.assign({color:y.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("div",Object.assign({style:{display:"flex",width:"100%"}},{children:e(C,{LeadingIcon:null!==(i=q.leadingIcon)&&void 0!==i?i:d,buttonText:null!==(o=q.title)&&void 0!==o?o:"Add FAQ",buttonType:"secondary",size:"small",matchParentWidth:!0,onClick:()=>{q.onClick()}})}))]}))})()})):e(b,{LeadingIcon:c,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 ${P===D.BIK?"BIK":"Manifest"}.`:"Edit the original source and save again to update the response"})]})),!me(Z)&&t("div",Object.assign({className:"info-container"},{children:[t("div",Object.assign({className:"info-product-source"},{children:[e(j,{children:"Product Source"}),e("div",Object.assign({className:"source",style:{padding:"0 12px",maxWidth:"100%"}},{children:Z.filter((e=>"PRODUCTS"==e.type||"Products"==e.subTitle||e.productId)).map(((o,n)=>{var l;const r=fe(o.type||o.subTitle||"OpenAI"),c=fe(o.type||o.subTitle||"OpenAI",!0),a=ye(r),d=null==Q?void 0:Q.includes(c),u=W[null!==(l=o.productId)&&void 0!==l?l:"Products"],g=o.title,h=o.productId&&(null==J?void 0:J[o.productId]),m=h&&h.metafield.join(", ");return t("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"8px",padding:"16px 0px",borderBottom:n+1<ue.length?`1px solid ${y.stroke.primary}`:"none"}},{children:[t("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",justifyContent:"space-between",alignItems:"center"}},{children:[t("div",Object.assign({style:{display:"flex",flex:1,gap:"8px",flexDirection:"row",alignItems:"center",justifyContent:"flex-start"}},{children:[Ce(r),e(O,Object.assign({body:g,placement:"top"},{children:e(E,Object.assign({style:c==_.FETCHED_LINKS||c==_.WEBSITE_LINKS?{cursor:"pointer",textDecoration:"underline"}:{},color:y.content.primary,className:"clamp-title",onClick:()=>c==_.FETCHED_LINKS||c==_.WEBSITE_LINKS?G(o):{}},{children:g}))}))]})),t("div",Object.assign({style:{display:"flex",flexDirection:"row",justifyContent:"flex-end",alignItems:"center",gap:"4px",flex:"none"}},{children:[o.intent!==H.EMAIL_COLLECTION&&e(i,{children:e(j,Object.assign({color:y.content.secondary},{children:a}))}),(o.link||o.docId)&&e("div",Object.assign({style:{cursor:"pointer",marginLeft:"0px"}},{children:e(v,d?{Icon:s,height:16,width:16,iconColor:y.content.secondary,onClick:()=>null==u?void 0:u.onEditClick(u.data,u.type),disabled:!u,disabledTooltip:"This source is deleted"}:{Icon:p,height:16,width:16,iconColor:y.content.secondary,disabled:"custom"===o.type&&!u,disabledTooltip:"This source is deleted",onClick:()=>G(o)})}))]}))]})),h&&t("div",Object.assign({className:"product-data"},{children:[e(j,Object.assign({className:"product-data-text",onClick:()=>{var e;ce({title:g,description:ve(h.description),imageUrl:null!==(e=o.imageUrl)&&void 0!==e?e:"",onClose:()=>ce(void 0)})}},{children:`${h.description.length} characters description,`})),e(j,Object.assign({className:"product-data-text",onClick:()=>h.onEditFaqClick(h.faqs)},{children:`${h.faqs.length} FAQs,`})),e(O,Object.assign({body:m},{children:e(j,Object.assign({className:"product-data-text"},{children:`${h.metafield.length} metafields`}))}))]}))]}),`info-${n}`)}))}))]})),t("div",Object.assign({className:"info-content-source"},{children:[e(j,{children:"Content Source"}),e("div",Object.assign({className:"source",style:{padding:"0 12px",maxWidth:"100%"}},{children:Z.filter((e=>"PRODUCTS"!=e.type&&"Products"!=e.subTitle&&!e.productId)).map(((o,n)=>{var l,r,c,a,d,u,g,h,m,f,C,x,I,b,T,L,S;const w=fe(o.type||o.subTitle||"OpenAI"),N=fe(o.type||o.subTitle||"OpenAI",!0),D=ye(w),A=null==Q?void 0:Q.includes(N),k="Products"===o.subTitle?W[null!==(l=o.productId)&&void 0!==l?l:"Products"]:W[null!==(r=o.docId)&&void 0!==r?r:""],F=N.toLowerCase()===(null===(c=_.FAQ)||void 0===c?void 0:c.toLowerCase())?"faq"===(null===(a=o.title)||void 0===a?void 0:a.toLowerCase())?o.subTitle:o.title:N.toLowerCase()===(null===(d=_.FILES)||void 0===d?void 0:d.toLowerCase())||N.toLowerCase()===(null===(u=_.FETCHED_LINKS)||void 0===u?void 0:u.toLowerCase())||N.toLowerCase()===(null===(g=_.TEXTS)||void 0===g?void 0:g.toLowerCase())?o.title:N.toLowerCase()===(null===(h=_.WEBSITE_LINKS)||void 0===h?void 0:h.toLowerCase())?o.title.split("/")[o.title.split("/").length-1].replace(/[^\w\s]/gi," ").replace(/^(.)(.*)$/,((e,t,i)=>t.toUpperCase()+i)):o.intent===H.EMAIL_COLLECTION?D:o.title,P="faq"===N.toLowerCase()?null!==(C=null!==(m=null==k?void 0:k.content)&&void 0!==m?m:null===(f=null==k?void 0:k.data)||void 0===f?void 0:f.answer)&&void 0!==C?C:"":N.toLowerCase()===(null===(x=_.FETCHED_LINKS)||void 0===x?void 0:x.toLowerCase())||N.toLowerCase()===(null===(I=_.WEBSITE_LINKS)||void 0===I?void 0:I.toLowerCase())||N.toLowerCase()===(null===(b=_.TEXTS)||void 0===b?void 0:b.toLowerCase())?null!==(S=null!==(T=null==k?void 0:k.content)&&void 0!==T?T:null===(L=null==k?void 0:k.data)||void 0===L?void 0:L.fileContentText)&&void 0!==S?S:"":o.intent===H.EMAIL_COLLECTION?"Collect leads before replying to messages":"";return t("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"8px",padding:"16px 0px",borderBottom:n+1<ge.length?`1px solid ${y.stroke.primary}`:"none"}},{children:[t("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",justifyContent:"space-between",alignItems:"center"}},{children:[t("div",Object.assign({style:{display:"flex",flex:1,gap:"8px",flexDirection:"row",alignItems:"center",justifyContent:"flex-start"}},{children:[Ce(w),e(O,Object.assign({body:F,placement:"top"},{children:e(E,Object.assign({style:N==_.FETCHED_LINKS||N==_.WEBSITE_LINKS?{cursor:"pointer",textDecoration:"underline"}:{},color:y.content.primary,className:"clamp-title",onClick:()=>N==_.FETCHED_LINKS||N==_.WEBSITE_LINKS?G(o):{}},{children:F}))}))]})),t("div",Object.assign({style:{display:"flex",flexDirection:"row",justifyContent:"flex-end",alignItems:"center",gap:"4px",flex:"none"}},{children:[o.intent!==H.EMAIL_COLLECTION&&e(i,{children:e(j,Object.assign({color:y.content.secondary},{children:D}))}),(o.link||o.docId)&&e("div",Object.assign({style:{cursor:"pointer",marginLeft:"0px"}},{children:e(v,A?{Icon:s,height:16,width:16,iconColor:y.content.secondary,onClick:()=>null==k?void 0:k.onEditClick(k.data,k.type),disabled:!k,disabledTooltip:"This source is deleted"}:{Icon:p,height:16,width:16,iconColor:y.content.secondary,disabled:"custom"===o.type&&!k,disabledTooltip:"This source is deleted",onClick:()=>G(o)})}))]}))]})),(null!=P?P:"").trim()&&e("div",Object.assign({style:{padding:"4px 8px",border:`1px dashed ${y.stroke.primary}`,borderRadius:"4px",backgroundColor:y.surface.subdued}},{children:e(j,Object.assign({color:y.content.primary,className:"clamp-description"},{children:ve(null!=P?P:"").trim()}))}))]}),`info-${n}`)}))}))]}))]})),oe&&!me(Z)&&e("div",Object.assign({className:"footer"},{children:e(L,{appType:P,storeId:R,messageSource:B,sourceIntent:null!==(F=B.intent)&&void 0!==F?F:H.GENERIC,faqCount:se,trainingSourceCount:ae,ShowTrainingDataSource:he,ChecklistType:H,footerButtonOption:X})}))]})}),re&&e(I,Object.assign({header:"Product description",onClose:()=>ce(void 0)},{children:e(N,{title:re.title,description:re.description,imageUrl:re.imageUrl,onClose:re.onClose})}))]})};export{A as DataSourcePanel};
1
+ import{jsx as e,jsxs as t,Fragment 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 l from"../../assets/icons/filePdf.svg.js";import r from"../../assets/icons/help.svg.js";import c from"../../assets/icons/info.svg.js";import a 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 h,useMemo as m,useEffect as f}from"react";import{COLORS as v}from"../../constants/Theme.js";import{Button as y}from"../button/Button.js";import{IconButton as C}from"../icon-button/IconButton.js";import{BikShimmer as x}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 j,BodyCaption as T,BodySecondary as E}from"../TypographyStyle.js";import L from"./DataSourceInfoFooter.js";import{SourceInfoDetailsStyle as S}from"./DataSourcePanel.style.js";import{intentConfig as w}from"./IntentConfig.js";import{DescriptionModal as N}from"./Modals/DescriptionModal.js";import{AppType as _,CustomDataType as D}from"./model.js";const A=A=>{var k,F;const{appType:P,storeId:B,messageSource:R,setMessageSourcePanel:U,hideCloseButton:K,isSourceInfoFetched:M,allSourceInfoDetail:W,ChecklistType:H,title:$,zeroStateButton:q,editableSources:Q,preFillTrainingSourceCount:Y,redirect:G,footerButtonOption:X,fetchTrainingSourceCount:z,fetchProductFAQCount:V,productSourceData:J}=A,{sources:Z}=R,ee=["blog","article","page","policy"],[te,ie]=h(!1),[oe,ne]=h(!1),[se,le]=h(0),[re,ce]=h(),[ae,de]=h(null!=Y?Y:{}),pe={};w.forEach((t=>{let{key:i,type:o,tagText:n}=t;H[i]&&(pe[H[i]]=e(b,{theme:"light",type:o,tagText:n,cursor:"pointer"}))}));const ue=Z.filter((e=>"PRODUCTS"==e.type||"Products"==e.subTitle||e.productId)),ge=Z.filter((e=>"PRODUCTS"!=e.type&&"Products"!=e.subTitle&&!e.productId)),he=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]);f((()=>{}),[V,z,null==R?void 0:R.messageId,R.sources,Y,B]);const me=e=>!!(e&&0===e.length||(null==R?void 0:R.isUnsatisfactoryAnswer)),fe=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];var i;return"custom"==e?e=D.FILES:ee.includes(e)?e=D.FETCHED_LINKS:"url"==e?e=D.WEBSITE_LINKS:"text"===e?e=D.TEXTS:"faq"===e&&(e=D.FAQ),t?e:null===(i=null==e?void 0:e.toLowerCase())||void 0===i?void 0:i.replace(/_/g," ")},ve=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")):"",ye=t=>e("products"==t||"product"==t?o:"files"==t?l:"website links"==t||"fetched links"==t?g:"faq"==t?r:"texts"==t?u:a,{height:16,width:16,color:v.content.secondary}),Ce=e=>{const t=e.replace(/(<([^>]+)>)/gi,""),i=document.createElement("textarea");return i.innerHTML=t,i.value};return te||!M?e(S,{children:e(x,{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"}]})}):t(i,{children:[e(S,{children:t(i,{children:[t("div",Object.assign({className:"pop-up-header",style:{display:"flex",flexDirection:"column",paddingBottom:"12px"}},{children:[!!$&&e(j,{children:$}),t("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",alignItems:"center"}},{children:[e(T,Object.assign({color:v.content.secondary},{children:"Intent"})),null!==(k=pe[R.intent])&&void 0!==k?k:pe.GENERIC,!K&&e("div",Object.assign({style:{display:"flex",marginLeft:"auto",cursor:"pointer"},onClick:()=>U(void 0)},{children:e(n,{height:20,width:20,color:v.content.secondary})}))]})),me(Z)?e("div",Object.assign({style:{display:"flex",margin:"auto",justifyContent:"center",alignItems:"center",height:"calc(100vh - 300px)"}},{children:(()=>{var i,o;return t("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:`${v.background.negative.light}`,borderRadius:"100px"}},{children:e(c,{width:24,height:24,color:v.stroke.negative.vibrant})})),e("div",Object.assign({style:{justifyContent:"center",alignItems:"center",marginBottom:"-4px"}},{children:e(j,{children:"Insufficient data"})})),e(E,Object.assign({color:v.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("div",Object.assign({style:{display:"flex",width:"100%"}},{children:e(y,{LeadingIcon:null!==(i=q.leadingIcon)&&void 0!==i?i:d,buttonText:null!==(o=q.title)&&void 0!==o?o:"Add FAQ",buttonType:"secondary",size:"small",matchParentWidth:!0,onClick:()=>{q.onClick()}})}))]}))})()})):e(b,{LeadingIcon:c,version:"2.0",type:"grey",theme:"light",alignIcon:"start",contentPadding:12,tagText:R.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 ${P===_.BIK?"BIK":"Manifest"}.`:"Edit the original source and save again to update the response"})]})),!me(Z)&&t("div",Object.assign({className:"info-container"},{children:[ue.length>0&&t("div",Object.assign({className:"info-product-source"},{children:[e(T,{children:"Product Source"}),e("div",Object.assign({className:"source",style:{padding:"0 12px",maxWidth:"100%"}},{children:ue.map(((o,n)=>{var l,r,c,a;const d=fe(o.type||o.subTitle||"OpenAI"),u=fe(o.type||o.subTitle||"OpenAI",!0),g=ve(d),h=null==Q?void 0:Q.includes(u),m=W[null!==(l=o.productId)&&void 0!==l?l:"Products"],f=o.title,y=o.productId&&(null==J?void 0:J[o.productId]),x=y&&y.metafield.join(", ");return t("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"8px",padding:"16px 0px",borderBottom:n+1<(null==ue?void 0:ue.length)?`1px solid ${v.stroke.primary}`:"none"}},{children:[t("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",justifyContent:"space-between",alignItems:"center"}},{children:[t("div",Object.assign({style:{display:"flex",flex:1,gap:"8px",flexDirection:"row",alignItems:"center",justifyContent:"flex-start"}},{children:[ye(d),e(O,Object.assign({body:f,placement:"top"},{children:e(E,Object.assign({style:u==D.FETCHED_LINKS||u==D.WEBSITE_LINKS?{cursor:"pointer",textDecoration:"underline"}:{},color:v.content.primary,className:"clamp-title",onClick:()=>u==D.FETCHED_LINKS||u==D.WEBSITE_LINKS?G(o):{}},{children:f}))}))]})),t("div",Object.assign({style:{display:"flex",flexDirection:"row",justifyContent:"flex-end",alignItems:"center",gap:"4px",flex:"none"}},{children:[o.intent!==H.EMAIL_COLLECTION&&e(i,{children:e(T,Object.assign({color:v.content.secondary},{children:g}))}),(o.link||o.docId)&&e("div",Object.assign({style:{cursor:"pointer",marginLeft:"0px"}},{children:e(C,h?{Icon:s,height:16,width:16,iconColor:v.content.secondary,onClick:()=>null==m?void 0:m.onEditClick(m.data,m.type),disabled:!m,disabledTooltip:"This source is deleted"}:{Icon:p,height:16,width:16,iconColor:v.content.secondary,disabled:"custom"===o.type&&!m,disabledTooltip:"This source is deleted",onClick:()=>G(o)})}))]}))]})),y&&t("div",Object.assign({className:"product-data"},{children:[e(T,Object.assign({className:"product-data-text",onClick:()=>{var e;ce({title:f,description:Ce(y.description),imageUrl:null!==(e=o.imageUrl)&&void 0!==e?e:"",onClose:()=>ce(void 0)})}},{children:`${null===(r=y.description)||void 0===r?void 0:r.length} characters description,`})),e(T,Object.assign({className:"product-data-text",onClick:()=>y.onEditFaqClick(y.faqs)},{children:`${null===(c=y.faqs)||void 0===c?void 0:c.length} FAQs,`})),e(O,Object.assign({body:x},{children:e(T,Object.assign({className:"product-data-text"},{children:`${null===(a=y.metafield)||void 0===a?void 0:a.length} metafields`}))}))]}))]}),`info-${n}`)}))}))]})),ge.length>0&&t("div",Object.assign({className:"info-content-source"},{children:[e(T,{children:"Content Source"}),e("div",Object.assign({className:"source",style:{padding:"0 12px",maxWidth:"100%"}},{children:ge.map(((o,n)=>{var l,r,c,a,d,u,g,h,m,f,y,x,I,b,j,L,S;const w=fe(o.type||o.subTitle||"OpenAI"),N=fe(o.type||o.subTitle||"OpenAI",!0),_=ve(w),A=null==Q?void 0:Q.includes(N),k="Products"===o.subTitle?W[null!==(l=o.productId)&&void 0!==l?l:"Products"]:W[null!==(r=o.docId)&&void 0!==r?r:""],F=N.toLowerCase()===(null===(c=D.FAQ)||void 0===c?void 0:c.toLowerCase())?"faq"===(null===(a=o.title)||void 0===a?void 0:a.toLowerCase())?o.subTitle:o.title:N.toLowerCase()===(null===(d=D.FILES)||void 0===d?void 0:d.toLowerCase())||N.toLowerCase()===(null===(u=D.FETCHED_LINKS)||void 0===u?void 0:u.toLowerCase())||N.toLowerCase()===(null===(g=D.TEXTS)||void 0===g?void 0:g.toLowerCase())?o.title:N.toLowerCase()===(null===(h=D.WEBSITE_LINKS)||void 0===h?void 0:h.toLowerCase())?o.title.split("/")[o.title.split("/").length-1].replace(/[^\w\s]/gi," ").replace(/^(.)(.*)$/,((e,t,i)=>t.toUpperCase()+i)):o.intent===H.EMAIL_COLLECTION?_:o.title,P="faq"===N.toLowerCase()?null!==(y=null!==(m=null==k?void 0:k.content)&&void 0!==m?m:null===(f=null==k?void 0:k.data)||void 0===f?void 0:f.answer)&&void 0!==y?y:"":N.toLowerCase()===(null===(x=D.FETCHED_LINKS)||void 0===x?void 0:x.toLowerCase())||N.toLowerCase()===(null===(I=D.WEBSITE_LINKS)||void 0===I?void 0:I.toLowerCase())||N.toLowerCase()===(null===(b=D.TEXTS)||void 0===b?void 0:b.toLowerCase())?null!==(S=null!==(j=null==k?void 0:k.content)&&void 0!==j?j:null===(L=null==k?void 0:k.data)||void 0===L?void 0:L.fileContentText)&&void 0!==S?S:"":o.intent===H.EMAIL_COLLECTION?"Collect leads before replying to messages":"";return t("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"8px",padding:"16px 0px",borderBottom:n+1<(null==ge?void 0:ge.length)?`1px solid ${v.stroke.primary}`:"none"}},{children:[t("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",justifyContent:"space-between",alignItems:"center"}},{children:[t("div",Object.assign({style:{display:"flex",flex:1,gap:"8px",flexDirection:"row",alignItems:"center",justifyContent:"flex-start"}},{children:[ye(w),e(O,Object.assign({body:F,placement:"top"},{children:e(E,Object.assign({style:N==D.FETCHED_LINKS||N==D.WEBSITE_LINKS?{cursor:"pointer",textDecoration:"underline"}:{},color:v.content.primary,className:"clamp-title",onClick:()=>N==D.FETCHED_LINKS||N==D.WEBSITE_LINKS?G(o):{}},{children:F}))}))]})),t("div",Object.assign({style:{display:"flex",flexDirection:"row",justifyContent:"flex-end",alignItems:"center",gap:"4px",flex:"none"}},{children:[o.intent!==H.EMAIL_COLLECTION&&e(i,{children:e(T,Object.assign({color:v.content.secondary},{children:_}))}),(o.link||o.docId)&&e("div",Object.assign({style:{cursor:"pointer",marginLeft:"0px"}},{children:e(C,A?{Icon:s,height:16,width:16,iconColor:v.content.secondary,onClick:()=>null==k?void 0:k.onEditClick(k.data,k.type),disabled:!k,disabledTooltip:"This source is deleted"}:{Icon:p,height:16,width:16,iconColor:v.content.secondary,disabled:"custom"===o.type&&!k,disabledTooltip:"This source is deleted",onClick:()=>G(o)})}))]}))]})),(null!=P?P:"").trim()&&e("div",Object.assign({style:{padding:"4px 8px",border:`1px dashed ${v.stroke.primary}`,borderRadius:"4px",backgroundColor:v.surface.subdued}},{children:e(T,Object.assign({color:v.content.primary,className:"clamp-description"},{children:Ce(null!=P?P:"").trim()}))}))]}),`info-${n}`)}))}))]}))]})),oe&&!me(Z)&&e("div",Object.assign({className:"footer"},{children:e(L,{appType:P,storeId:B,messageSource:R,sourceIntent:null!==(F=R.intent)&&void 0!==F?F:H.GENERIC,faqCount:se,trainingSourceCount:ae,ShowTrainingDataSource:he,ChecklistType:H,footerButtonOption:X})}))]})}),re&&e(I,Object.assign({header:"Product description",onClose:()=>ce(void 0),width:"30%"},{children:e(N,{title:re.title,description:re.description,imageUrl:re.imageUrl,onClose:re.onClose})}))]})};export{A as DataSourcePanel};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bikdotai/bik-component-library",
3
- "version": "0.0.660-1",
3
+ "version": "0.0.660-2",
4
4
  "description": "Bik Component Library",
5
5
  "repository": {
6
6
  "type": "git",