@bikdotai/bik-component-library 0.0.641-3 → 0.0.641-4

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"),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"),h=require("../../constants/Theme.js"),g=require("../button/Button.js"),x=require("../icon-button/IconButton.js"),C=require("../shimmer/ShimmerComponent/BikShimmer.js"),y=require("../tag/Tag.js"),j=require("../tooltips/Tooltip.js"),v=require("../TypographyStyle.js"),m=require("./DataSourceInfoFooter.js"),f=require("./DataSourcePanel.style.js"),L=require("./model.js");exports.DataSourcePanel=O=>{var I,S;const{storeId:b,messageSource:T,setMessageSourcePanel:w,hideCloseButton:E,faqCount:D,isSourceInfoFetched:q,allSourceInfoDetail:B,ChecklistType:N,IntentComponentMap:R,title:k,zeroStateButton:F,editableSources:_}=O,{sources:A}=T,P=["blog","article","page","policy"],[K,W]=p.useState(!1),[M,H]=p.useState(!1);p.useEffect((()=>{var e,t,s,i;(null==T?void 0:T.messageId)&&(W(!0),setTimeout((()=>W(!1)),200),H(!1!==(null===(t=null===(e=T.sources)||void 0===e?void 0:e[0])||void 0===t?void 0:t.isTrainable)||!!(null===(i=null===(s=T.sources)||void 0===s?void 0:s[0])||void 0===i?void 0:i.insights)))}),[null==T?void 0:T.messageId]);const Q=e=>!(0!==e.length&&!(null==T?void 0:T.isUnsatisfactoryAnswer)),$=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];var s;return"custom"==e?e=L.CustomDataType.FILES:P.includes(e)?e=L.CustomDataType.FETCHED_LINKS:"url"==e?e=L.CustomDataType.WEBSITE_LINKS:"text"===e?e=L.CustomDataType.TEXTS:"faq"===e&&(e=L.CustomDataType.FAQ),t?e:null===(s=null==e?void 0:e.toLowerCase())||void 0===s?void 0:s.replace(/_/g," ")};return K||!q?e.jsx(f.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.jsx(e.Fragment,{children:e.jsx(f.SourceInfoDetailsStyle,{children:!!(null==A?void 0:A.length)&&e.jsxs(e.Fragment,{children:[e.jsxs("div",Object.assign({className:"pop-up-header",style:{display:"flex",flexDirection:"column",paddingBottom:"12px"}},{children:[!!k&&e.jsx(v.TitleSmall,{children:k}),e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",alignItems:"center"}},{children:[e.jsx(v.BodyCaption,Object.assign({color:h.COLORS.content.secondary},{children:"Intent"})),null!==(I=R[T.intent])&&void 0!==I?I:R.GENERIC,!E&&e.jsx("div",Object.assign({style:{display:"flex",marginLeft:"auto",cursor:"pointer"},onClick:()=>w(void 0)},{children:e.jsx(s.default,{height:20,width:20,color:h.COLORS.content.secondary})}))]})),Q(A)?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:`${h.COLORS.background.negative.light}`,borderRadius:"100px"}},{children:e.jsx(a.default,{width:24,height:24,color:h.COLORS.stroke.negative.vibrant})})),e.jsx("div",Object.assign({style:{justifyContent:"center",alignItems:"center",marginBottom:"-4px"}},{children:e.jsx(v.TitleSmall,{children:"Insufficient data"})})),e.jsx(v.BodySecondary,Object.assign({color:h.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"})),F&&e.jsx("div",Object.assign({style:{display:"flex",width:"100%"}},{children:e.jsx(g.Button,{LeadingIcon:null!==(t=F.leadingIcon)&&void 0!==t?t:l.default,buttonText:null!==(s=F.title)&&void 0!==s?s:"Add FAQ",buttonType:"secondary",size:"small",matchParentWidth:!0,onClick:()=>{F.onClick()}})}))]}))})()})):e.jsx(y.Tag,{LeadingIcon:a.default,version:"2.0",type:"grey",theme:"light",alignIcon:"start",contentPadding:12,tagText:T.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"})]})),!Q(A)&&e.jsx("div",Object.assign({className:"info-container"},{children:e.jsx("div",Object.assign({style:{padding:"0 8px",maxWidth:"100%"}},{children:A.map(((s,a)=>{var l,p,g,C,y,m,f,O,I,S,b,T,w,E;const D=$(s.type||s.subTitle||"OpenAI"),q=$(s.type||s.subTitle||"OpenAI",!0),R=(k=D)?"faq"==k.toLocaleLowerCase()?"FAQ":"openai"==k.toLocaleLowerCase()?"OPENAI":"files"==k.toLocaleLowerCase()?"PDF":"texts"==k.toLocaleLowerCase()?"Custom text":((k=(k=k.charAt(0).toUpperCase()+k.slice(1).toLowerCase()).replace("_"," ")).endsWith("s")&&(k=k.slice(0,-1)),k.replace("Website","Manual")):"";var k;const F=null==_?void 0:_.includes(q),A="Products"===s.subTitle?B[null!==(l=s.productId)&&void 0!==l?l:"Products"]:B[null!==(p=s.docId)&&void 0!==p?p:""],P=q.toLowerCase()===(null===(g=L.CustomDataType.FAQ)||void 0===g?void 0:g.toLowerCase())?"faq"===(null===(C=s.title)||void 0===C?void 0:C.toLowerCase())?s.subTitle:s.title:q.toLowerCase()===(null===(y=L.CustomDataType.FILES)||void 0===y?void 0:y.toLowerCase())||q.toLowerCase()===(null===(m=L.CustomDataType.FETCHED_LINKS)||void 0===m?void 0:m.toLowerCase())||q.toLowerCase()===(null===(f=L.CustomDataType.TEXTS)||void 0===f?void 0:f.toLowerCase())?s.title:q.toLowerCase()===(null===(O=L.CustomDataType.WEBSITE_LINKS)||void 0===O?void 0:O.toLowerCase())?s.title.split("/")[s.title.split("/").length-1].replace(/[^\w\s]/gi," ").replace(/^(.)(.*)$/,((e,t,s)=>t.toUpperCase()+s)):s.intent===N.EMAIL_COLLECTION?R:s.title,K="faq"===q.toLowerCase()?null===(I=null==A?void 0:A.data)||void 0===I?void 0:I.answer:q.toLowerCase()===(null===(S=L.CustomDataType.FETCHED_LINKS)||void 0===S?void 0:S.toLowerCase())||q.toLowerCase()===(null===(b=L.CustomDataType.WEBSITE_LINKS)||void 0===b?void 0:b.toLowerCase())||q.toLowerCase()===(null===(T=L.CustomDataType.TEXTS)||void 0===T?void 0:T.toLowerCase())?null!==(E=null===(w=null==A?void 0:A.data)||void 0===w?void 0:w.fileContentText)&&void 0!==E?E:"":s.intent===N.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 ${h.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(j.Tooltip,Object.assign({body:P,placement:"top"},{children:e.jsx(v.BodySecondary,Object.assign({style:q==L.CustomDataType.FETCHED_LINKS||q==L.CustomDataType.WEBSITE_LINKS?{cursor:"pointer",textDecoration:"underline"}:{},color:h.COLORS.content.primary,className:"clamp-title",onClick:()=>q==L.CustomDataType.FETCHED_LINKS||q==L.CustomDataType.WEBSITE_LINKS?A.redirect&&A.redirect(s):{}},{children:P}))}))})),e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",justifyContent:"flex-end",alignItems:"center",gap:"4px",flex:"none"}},{children:[s.intent!==N.EMAIL_COLLECTION&&e.jsxs(e.Fragment,{children:[(M=D,"products"==M?e.jsx(t.default,{height:16,width:16,color:h.COLORS.content.secondary}):"files"==M?e.jsx(o.default,{height:16,width:16,color:h.COLORS.content.secondary}):"website links"==M||"fetched links"==M?e.jsx(u.default,{height:16,width:16,color:h.COLORS.content.secondary}):"faq"==M?e.jsx(n.default,{height:16,width:16,color:h.COLORS.content.secondary}):"texts"==M?e.jsx(c.default,{height:16,width:16,color:h.COLORS.content.secondary}):e.jsx(r.default,{height:16,width:16,color:h.COLORS.content.secondary})),e.jsx(v.BodyCaption,Object.assign({color:h.COLORS.content.secondary},{children:R}))]}),(s.link||s.docId)&&e.jsx("div",Object.assign({style:{cursor:"pointer",marginLeft:"4px"}},{children:F?e.jsx(x.IconButton,{Icon:i.default,height:16,width:16,bordered:!0,onClick:()=>null==A?void 0:A.onEditClick(A.data,A.type),disabled:!A,disabledTooltip:"This source is deleted"}):e.jsx(x.IconButton,{Icon:d.default,height:16,width:16,bordered:!0,disabled:"custom"===s.type&&!A,disabledTooltip:"This source is deleted",onClick:()=>A.redirect&&A.redirect(s)})}))]}))]})),(null!=K?K:"").trim()&&e.jsx("div",Object.assign({style:{padding:"4px 8px",border:`1px dashed ${h.COLORS.stroke.primary}`,borderRadius:"4px",backgroundColor:h.COLORS.surface.subdued}},{children:e.jsx(v.BodyCaption,Object.assign({color:h.COLORS.content.primary,className:"clamp-description"},{children:(W=null!=K?K:"",W.replace(/(<([^>]+)>)/gi,"")).trim()}))}))]}),`info-${a}`);var W,M}))}))})),M&&!Q(A)&&e.jsx("div",Object.assign({className:"footer"},{children:e.jsx(m.SourceInfoFooter,{storeId:b,messageSource:T,sourceIntent:null!==(S=T.intent)&&void 0!==S?S:N.GENERIC,faqCount:D})}))]})})})};
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"),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"),h=require("../../constants/Theme.js"),g=require("../button/Button.js"),x=require("../icon-button/IconButton.js"),C=require("../shimmer/ShimmerComponent/BikShimmer.js"),v=require("../tag/Tag.js"),y=require("../tooltips/Tooltip.js"),j=require("../TypographyStyle.js"),m=require("./DataSourceInfoFooter.js"),f=require("./DataSourcePanel.style.js"),L=require("./model.js");exports.DataSourcePanel=O=>{var I,S;const{storeId:b,messageSource:T,setMessageSourcePanel:w,hideCloseButton:E,faqCount:D,isSourceInfoFetched:q,allSourceInfoDetail:B,ChecklistType:N,IntentComponentMap:R,title:k,zeroStateButton:F,editableSources:_}=O,{sources:A}=T,P=["blog","article","page","policy"],[K,W]=p.useState(!1),[M,H]=p.useState(!1);p.useEffect((()=>{var e,t,s,i;(null==T?void 0:T.messageId)&&(W(!0),setTimeout((()=>W(!1)),200),H(!1!==(null===(t=null===(e=T.sources)||void 0===e?void 0:e[0])||void 0===t?void 0:t.isTrainable)||!!(null===(i=null===(s=T.sources)||void 0===s?void 0:s[0])||void 0===i?void 0:i.insights)))}),[null==T?void 0:T.messageId]);const Q=e=>!(0!==e.length&&!(null==T?void 0:T.isUnsatisfactoryAnswer)),$=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];var s;return"custom"==e?e=L.CustomDataType.FILES:P.includes(e)?e=L.CustomDataType.FETCHED_LINKS:"url"==e?e=L.CustomDataType.WEBSITE_LINKS:"text"===e?e=L.CustomDataType.TEXTS:"faq"===e&&(e=L.CustomDataType.FAQ),t?e:null===(s=null==e?void 0:e.toLowerCase())||void 0===s?void 0:s.replace(/_/g," ")};return K||!q?e.jsx(f.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.jsx(e.Fragment,{children:e.jsx(f.SourceInfoDetailsStyle,{children:!!(null==A?void 0:A.length)&&e.jsxs(e.Fragment,{children:[e.jsxs("div",Object.assign({className:"pop-up-header",style:{display:"flex",flexDirection:"column",paddingBottom:"12px"}},{children:[!!k&&e.jsx(j.TitleSmall,{children:k}),e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",alignItems:"center"}},{children:[e.jsx(j.BodyCaption,Object.assign({color:h.COLORS.content.secondary},{children:"Intent"})),null!==(I=R[T.intent])&&void 0!==I?I:R.GENERIC,!E&&e.jsx("div",Object.assign({style:{display:"flex",marginLeft:"auto",cursor:"pointer"},onClick:()=>w(void 0)},{children:e.jsx(s.default,{height:20,width:20,color:h.COLORS.content.secondary})}))]})),Q(A)?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:`${h.COLORS.background.negative.light}`,borderRadius:"100px"}},{children:e.jsx(a.default,{width:24,height:24,color:h.COLORS.stroke.negative.vibrant})})),e.jsx("div",Object.assign({style:{justifyContent:"center",alignItems:"center",marginBottom:"-4px"}},{children:e.jsx(j.TitleSmall,{children:"Insufficient data"})})),e.jsx(j.BodySecondary,Object.assign({color:h.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"})),F&&e.jsx("div",Object.assign({style:{display:"flex",width:"100%"}},{children:e.jsx(g.Button,{LeadingIcon:null!==(t=F.leadingIcon)&&void 0!==t?t:r.default,buttonText:null!==(s=F.title)&&void 0!==s?s:"Add FAQ",buttonType:"secondary",size:"small",matchParentWidth:!0,onClick:()=>{F.onClick()}})}))]}))})()})):e.jsx(v.Tag,{LeadingIcon:a.default,version:"2.0",type:"grey",theme:"light",alignIcon:"start",contentPadding:12,tagText:T.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"})]})),!Q(A)&&e.jsx("div",Object.assign({className:"info-container"},{children:e.jsx("div",Object.assign({style:{padding:"0 8px",maxWidth:"100%"}},{children:A.map(((s,a)=>{var r,p,g,C,v,m,f,O,I,S,b,T,w,E;const D=$(s.type||s.subTitle||"OpenAI"),q=$(s.type||s.subTitle||"OpenAI",!0),R=(k=D)?"faq"==k.toLocaleLowerCase()?"FAQ":"openai"==k.toLocaleLowerCase()?"OPENAI":"files"==k.toLocaleLowerCase()?"PDF":"texts"==k.toLocaleLowerCase()?"Custom text":((k=(k=k.charAt(0).toUpperCase()+k.slice(1).toLowerCase()).replace("_"," ")).endsWith("s")&&(k=k.slice(0,-1)),k.replace("Website","Manual")):"";var k;const F=null==_?void 0:_.includes(q),A="Products"===s.subTitle?B[null!==(r=s.productId)&&void 0!==r?r:"Products"]:B[null!==(p=s.docId)&&void 0!==p?p:""],P=q.toLowerCase()===(null===(g=L.CustomDataType.FAQ)||void 0===g?void 0:g.toLowerCase())?"faq"===(null===(C=s.title)||void 0===C?void 0:C.toLowerCase())?s.subTitle:s.title:q.toLowerCase()===(null===(v=L.CustomDataType.FILES)||void 0===v?void 0:v.toLowerCase())||q.toLowerCase()===(null===(m=L.CustomDataType.FETCHED_LINKS)||void 0===m?void 0:m.toLowerCase())||q.toLowerCase()===(null===(f=L.CustomDataType.TEXTS)||void 0===f?void 0:f.toLowerCase())?s.title:q.toLowerCase()===(null===(O=L.CustomDataType.WEBSITE_LINKS)||void 0===O?void 0:O.toLowerCase())?s.title.split("/")[s.title.split("/").length-1].replace(/[^\w\s]/gi," ").replace(/^(.)(.*)$/,((e,t,s)=>t.toUpperCase()+s)):s.intent===N.EMAIL_COLLECTION?R:s.title,K="faq"===q.toLowerCase()?null===(I=null==A?void 0:A.data)||void 0===I?void 0:I.answer:q.toLowerCase()===(null===(S=L.CustomDataType.FETCHED_LINKS)||void 0===S?void 0:S.toLowerCase())||q.toLowerCase()===(null===(b=L.CustomDataType.WEBSITE_LINKS)||void 0===b?void 0:b.toLowerCase())||q.toLowerCase()===(null===(T=L.CustomDataType.TEXTS)||void 0===T?void 0:T.toLowerCase())?null!==(E=null===(w=null==A?void 0:A.data)||void 0===w?void 0:w.fileContentText)&&void 0!==E?E:"":s.intent===N.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 ${h.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(y.Tooltip,Object.assign({body:P,placement:"top"},{children:e.jsx(j.BodySecondary,Object.assign({style:q==L.CustomDataType.FETCHED_LINKS||q==L.CustomDataType.WEBSITE_LINKS?{cursor:"pointer",textDecoration:"underline"}:{},color:h.COLORS.content.primary,className:"clamp-title",onClick:()=>q==L.CustomDataType.FETCHED_LINKS||q==L.CustomDataType.WEBSITE_LINKS?(null==A?void 0:A.redirect)&&(null==A?void 0:A.redirect(s)):{}},{children:P}))}))})),e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",justifyContent:"flex-end",alignItems:"center",gap:"4px",flex:"none"}},{children:[s.intent!==N.EMAIL_COLLECTION&&e.jsxs(e.Fragment,{children:[(M=D,"products"==M?e.jsx(t.default,{height:16,width:16,color:h.COLORS.content.secondary}):"files"==M?e.jsx(o.default,{height:16,width:16,color:h.COLORS.content.secondary}):"website links"==M||"fetched links"==M?e.jsx(u.default,{height:16,width:16,color:h.COLORS.content.secondary}):"faq"==M?e.jsx(n.default,{height:16,width:16,color:h.COLORS.content.secondary}):"texts"==M?e.jsx(c.default,{height:16,width:16,color:h.COLORS.content.secondary}):e.jsx(l.default,{height:16,width:16,color:h.COLORS.content.secondary})),e.jsx(j.BodyCaption,Object.assign({color:h.COLORS.content.secondary},{children:R}))]}),(s.link||s.docId)&&e.jsx("div",Object.assign({style:{cursor:"pointer",marginLeft:"4px"}},{children:F?e.jsx(x.IconButton,{Icon:i.default,height:16,width:16,bordered:!0,onClick:()=>null==A?void 0:A.onEditClick(A.data,A.type),disabled:!A,disabledTooltip:"This source is deleted"}):e.jsx(x.IconButton,{Icon:d.default,height:16,width:16,bordered:!0,disabled:"custom"===s.type&&!A,disabledTooltip:"This source is deleted",onClick:()=>(null==A?void 0:A.redirect)&&(null==A?void 0:A.redirect(s))})}))]}))]})),(null!=K?K:"").trim()&&e.jsx("div",Object.assign({style:{padding:"4px 8px",border:`1px dashed ${h.COLORS.stroke.primary}`,borderRadius:"4px",backgroundColor:h.COLORS.surface.subdued}},{children:e.jsx(j.BodyCaption,Object.assign({color:h.COLORS.content.primary,className:"clamp-description"},{children:(W=null!=K?K:"",W.replace(/(<([^>]+)>)/gi,"")).trim()}))}))]}),`info-${a}`);var W,M}))}))})),M&&!Q(A)&&e.jsx("div",Object.assign({className:"footer"},{children:e.jsx(m.SourceInfoFooter,{storeId:b,messageSource:T,sourceIntent:null!==(S=T.intent)&&void 0!==S?S:N.GENERIC,faqCount:D})}))]})})})};
@@ -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 s from"../../assets/icons/cross.svg.js";import n 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 d from"../../assets/icons/openai.svg.js";import c 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,useEffect as m}from"react";import{COLORS as v}from"../../constants/Theme.js";import{Button as f}from"../button/Button.js";import{IconButton as y}from"../icon-button/IconButton.js";import{BikShimmer as x}from"../shimmer/ShimmerComponent/BikShimmer.js";import{Tag as C}from"../tag/Tag.js";import{Tooltip as b}from"../tooltips/Tooltip.js";import{TitleSmall as I,BodyCaption as L,BodySecondary as j}from"../TypographyStyle.js";import{SourceInfoFooter as w}from"./DataSourceInfoFooter.js";import{SourceInfoDetailsStyle as E}from"./DataSourcePanel.style.js";import{CustomDataType as T}from"./model.js";const O=O=>{var S,N;const{storeId:k,messageSource:A,setMessageSourcePanel:D,hideCloseButton:_,faqCount:F,isSourceInfoFetched:B,allSourceInfoDetail:K,ChecklistType:P,IntentComponentMap:W,title:q,zeroStateButton:M,editableSources:H}=O,{sources:Q}=A,$=["blog","article","page","policy"],[R,U]=h(!1),[X,z]=h(!1);m((()=>{var e,t,i,o;(null==A?void 0:A.messageId)&&(U(!0),setTimeout((()=>U(!1)),200),z(!1!==(null===(t=null===(e=A.sources)||void 0===e?void 0:e[0])||void 0===t?void 0:t.isTrainable)||!!(null===(o=null===(i=A.sources)||void 0===i?void 0:i[0])||void 0===o?void 0:o.insights)))}),[null==A?void 0:A.messageId]);const G=e=>!(0!==e.length&&!(null==A?void 0:A.isUnsatisfactoryAnswer)),V=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];var i;return"custom"==e?e=T.FILES:$.includes(e)?e=T.FETCHED_LINKS:"url"==e?e=T.WEBSITE_LINKS:"text"===e?e=T.TEXTS:"faq"===e&&(e=T.FAQ),t?e:null===(i=null==e?void 0:e.toLowerCase())||void 0===i?void 0:i.replace(/_/g," ")};return R||!B?e(E,{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"}]})}):e(t,{children:e(E,{children:!!(null==Q?void 0:Q.length)&&i(t,{children:[i("div",Object.assign({className:"pop-up-header",style:{display:"flex",flexDirection:"column",paddingBottom:"12px"}},{children:[!!q&&e(I,{children:q}),i("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",alignItems:"center"}},{children:[e(L,Object.assign({color:v.content.secondary},{children:"Intent"})),null!==(S=W[A.intent])&&void 0!==S?S:W.GENERIC,!_&&e("div",Object.assign({style:{display:"flex",marginLeft:"auto",cursor:"pointer"},onClick:()=>D(void 0)},{children:e(s,{height:20,width:20,color:v.content.secondary})}))]})),G(Q)?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:`${v.background.negative.light}`,borderRadius:"100px"}},{children:e(a,{width:24,height:24,color:v.stroke.negative.vibrant})})),e("div",Object.assign({style:{justifyContent:"center",alignItems:"center",marginBottom:"-4px"}},{children:e(I,{children:"Insufficient data"})})),e(j,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"})),M&&e("div",Object.assign({style:{display:"flex",width:"100%"}},{children:e(f,{LeadingIcon:null!==(t=M.leadingIcon)&&void 0!==t?t:c,buttonText:null!==(o=M.title)&&void 0!==o?o:"Add FAQ",buttonType:"secondary",size:"small",matchParentWidth:!0,onClick:()=>{M.onClick()}})}))]}))})()})):e(C,{LeadingIcon:a,version:"2.0",type:"grey",theme:"light",alignIcon:"start",contentPadding:12,tagText:A.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"})]})),!G(Q)&&e("div",Object.assign({className:"info-container"},{children:e("div",Object.assign({style:{padding:"0 8px",maxWidth:"100%"}},{children:Q.map(((s,a)=>{var c,h,m,f,x,C,I,w,E,O,S,N,k,A;const D=V(s.type||s.subTitle||"OpenAI"),_=V(s.type||s.subTitle||"OpenAI",!0),F=(B=D)?"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 W=null==H?void 0:H.includes(_),q="Products"===s.subTitle?K[null!==(c=s.productId)&&void 0!==c?c:"Products"]:K[null!==(h=s.docId)&&void 0!==h?h:""],M=_.toLowerCase()===(null===(m=T.FAQ)||void 0===m?void 0:m.toLowerCase())?"faq"===(null===(f=s.title)||void 0===f?void 0:f.toLowerCase())?s.subTitle:s.title:_.toLowerCase()===(null===(x=T.FILES)||void 0===x?void 0:x.toLowerCase())||_.toLowerCase()===(null===(C=T.FETCHED_LINKS)||void 0===C?void 0:C.toLowerCase())||_.toLowerCase()===(null===(I=T.TEXTS)||void 0===I?void 0:I.toLowerCase())?s.title:_.toLowerCase()===(null===(w=T.WEBSITE_LINKS)||void 0===w?void 0:w.toLowerCase())?s.title.split("/")[s.title.split("/").length-1].replace(/[^\w\s]/gi," ").replace(/^(.)(.*)$/,((e,t,i)=>t.toUpperCase()+i)):s.intent===P.EMAIL_COLLECTION?F:s.title,Q="faq"===_.toLowerCase()?null===(E=null==q?void 0:q.data)||void 0===E?void 0:E.answer:_.toLowerCase()===(null===(O=T.FETCHED_LINKS)||void 0===O?void 0:O.toLowerCase())||_.toLowerCase()===(null===(S=T.WEBSITE_LINKS)||void 0===S?void 0:S.toLowerCase())||_.toLowerCase()===(null===(N=T.TEXTS)||void 0===N?void 0:N.toLowerCase())?null!==(A=null===(k=null==q?void 0:q.data)||void 0===k?void 0:k.fileContentText)&&void 0!==A?A:"":s.intent===P.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 ${v.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(b,Object.assign({body:M,placement:"top"},{children:e(j,Object.assign({style:_==T.FETCHED_LINKS||_==T.WEBSITE_LINKS?{cursor:"pointer",textDecoration:"underline"}:{},color:v.content.primary,className:"clamp-title",onClick:()=>_==T.FETCHED_LINKS||_==T.WEBSITE_LINKS?q.redirect&&q.redirect(s):{}},{children:M}))}))})),i("div",Object.assign({style:{display:"flex",flexDirection:"row",justifyContent:"flex-end",alignItems:"center",gap:"4px",flex:"none"}},{children:[s.intent!==P.EMAIL_COLLECTION&&i(t,{children:[(R=D,e("products"==R?o:"files"==R?r:"website links"==R||"fetched links"==R?g:"faq"==R?l:"texts"==R?u:d,{height:16,width:16,color:v.content.secondary})),e(L,Object.assign({color:v.content.secondary},{children:F}))]}),(s.link||s.docId)&&e("div",Object.assign({style:{cursor:"pointer",marginLeft:"4px"}},{children:e(y,W?{Icon:n,height:16,width:16,bordered:!0,onClick:()=>null==q?void 0:q.onEditClick(q.data,q.type),disabled:!q,disabledTooltip:"This source is deleted"}:{Icon:p,height:16,width:16,bordered:!0,disabled:"custom"===s.type&&!q,disabledTooltip:"This source is deleted",onClick:()=>q.redirect&&q.redirect(s)})}))]}))]})),(null!=Q?Q:"").trim()&&e("div",Object.assign({style:{padding:"4px 8px",border:`1px dashed ${v.stroke.primary}`,borderRadius:"4px",backgroundColor:v.surface.subdued}},{children:e(L,Object.assign({color:v.content.primary,className:"clamp-description"},{children:($=null!=Q?Q:"",$.replace(/(<([^>]+)>)/gi,"")).trim()}))}))]}),`info-${a}`);var $,R}))}))})),X&&!G(Q)&&e("div",Object.assign({className:"footer"},{children:e(w,{storeId:k,messageSource:A,sourceIntent:null!==(N=A.intent)&&void 0!==N?N:P.GENERIC,faqCount:F})}))]})})})};export{O 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 s from"../../assets/icons/cross.svg.js";import n from"../../assets/icons/edit.svg.js";import l from"../../assets/icons/filePdf.svg.js";import r from"../../assets/icons/help.svg.js";import a from"../../assets/icons/info.svg.js";import d from"../../assets/icons/openai.svg.js";import c 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,useEffect as m}from"react";import{COLORS as v}from"../../constants/Theme.js";import{Button as f}from"../button/Button.js";import{IconButton as y}from"../icon-button/IconButton.js";import{BikShimmer as x}from"../shimmer/ShimmerComponent/BikShimmer.js";import{Tag as C}from"../tag/Tag.js";import{Tooltip as b}from"../tooltips/Tooltip.js";import{TitleSmall as I,BodyCaption as L,BodySecondary as j}from"../TypographyStyle.js";import{SourceInfoFooter as w}from"./DataSourceInfoFooter.js";import{SourceInfoDetailsStyle as E}from"./DataSourcePanel.style.js";import{CustomDataType as T}from"./model.js";const O=O=>{var S,N;const{storeId:k,messageSource:A,setMessageSourcePanel:D,hideCloseButton:_,faqCount:F,isSourceInfoFetched:B,allSourceInfoDetail:K,ChecklistType:P,IntentComponentMap:W,title:q,zeroStateButton:M,editableSources:H}=O,{sources:Q}=A,$=["blog","article","page","policy"],[R,U]=h(!1),[X,z]=h(!1);m((()=>{var e,t,i,o;(null==A?void 0:A.messageId)&&(U(!0),setTimeout((()=>U(!1)),200),z(!1!==(null===(t=null===(e=A.sources)||void 0===e?void 0:e[0])||void 0===t?void 0:t.isTrainable)||!!(null===(o=null===(i=A.sources)||void 0===i?void 0:i[0])||void 0===o?void 0:o.insights)))}),[null==A?void 0:A.messageId]);const G=e=>!(0!==e.length&&!(null==A?void 0:A.isUnsatisfactoryAnswer)),V=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];var i;return"custom"==e?e=T.FILES:$.includes(e)?e=T.FETCHED_LINKS:"url"==e?e=T.WEBSITE_LINKS:"text"===e?e=T.TEXTS:"faq"===e&&(e=T.FAQ),t?e:null===(i=null==e?void 0:e.toLowerCase())||void 0===i?void 0:i.replace(/_/g," ")};return R||!B?e(E,{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"}]})}):e(t,{children:e(E,{children:!!(null==Q?void 0:Q.length)&&i(t,{children:[i("div",Object.assign({className:"pop-up-header",style:{display:"flex",flexDirection:"column",paddingBottom:"12px"}},{children:[!!q&&e(I,{children:q}),i("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",alignItems:"center"}},{children:[e(L,Object.assign({color:v.content.secondary},{children:"Intent"})),null!==(S=W[A.intent])&&void 0!==S?S:W.GENERIC,!_&&e("div",Object.assign({style:{display:"flex",marginLeft:"auto",cursor:"pointer"},onClick:()=>D(void 0)},{children:e(s,{height:20,width:20,color:v.content.secondary})}))]})),G(Q)?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:`${v.background.negative.light}`,borderRadius:"100px"}},{children:e(a,{width:24,height:24,color:v.stroke.negative.vibrant})})),e("div",Object.assign({style:{justifyContent:"center",alignItems:"center",marginBottom:"-4px"}},{children:e(I,{children:"Insufficient data"})})),e(j,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"})),M&&e("div",Object.assign({style:{display:"flex",width:"100%"}},{children:e(f,{LeadingIcon:null!==(t=M.leadingIcon)&&void 0!==t?t:c,buttonText:null!==(o=M.title)&&void 0!==o?o:"Add FAQ",buttonType:"secondary",size:"small",matchParentWidth:!0,onClick:()=>{M.onClick()}})}))]}))})()})):e(C,{LeadingIcon:a,version:"2.0",type:"grey",theme:"light",alignIcon:"start",contentPadding:12,tagText:A.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"})]})),!G(Q)&&e("div",Object.assign({className:"info-container"},{children:e("div",Object.assign({style:{padding:"0 8px",maxWidth:"100%"}},{children:Q.map(((s,a)=>{var c,h,m,f,x,C,I,w,E,O,S,N,k,A;const D=V(s.type||s.subTitle||"OpenAI"),_=V(s.type||s.subTitle||"OpenAI",!0),F=(B=D)?"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 W=null==H?void 0:H.includes(_),q="Products"===s.subTitle?K[null!==(c=s.productId)&&void 0!==c?c:"Products"]:K[null!==(h=s.docId)&&void 0!==h?h:""],M=_.toLowerCase()===(null===(m=T.FAQ)||void 0===m?void 0:m.toLowerCase())?"faq"===(null===(f=s.title)||void 0===f?void 0:f.toLowerCase())?s.subTitle:s.title:_.toLowerCase()===(null===(x=T.FILES)||void 0===x?void 0:x.toLowerCase())||_.toLowerCase()===(null===(C=T.FETCHED_LINKS)||void 0===C?void 0:C.toLowerCase())||_.toLowerCase()===(null===(I=T.TEXTS)||void 0===I?void 0:I.toLowerCase())?s.title:_.toLowerCase()===(null===(w=T.WEBSITE_LINKS)||void 0===w?void 0:w.toLowerCase())?s.title.split("/")[s.title.split("/").length-1].replace(/[^\w\s]/gi," ").replace(/^(.)(.*)$/,((e,t,i)=>t.toUpperCase()+i)):s.intent===P.EMAIL_COLLECTION?F:s.title,Q="faq"===_.toLowerCase()?null===(E=null==q?void 0:q.data)||void 0===E?void 0:E.answer:_.toLowerCase()===(null===(O=T.FETCHED_LINKS)||void 0===O?void 0:O.toLowerCase())||_.toLowerCase()===(null===(S=T.WEBSITE_LINKS)||void 0===S?void 0:S.toLowerCase())||_.toLowerCase()===(null===(N=T.TEXTS)||void 0===N?void 0:N.toLowerCase())?null!==(A=null===(k=null==q?void 0:q.data)||void 0===k?void 0:k.fileContentText)&&void 0!==A?A:"":s.intent===P.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 ${v.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(b,Object.assign({body:M,placement:"top"},{children:e(j,Object.assign({style:_==T.FETCHED_LINKS||_==T.WEBSITE_LINKS?{cursor:"pointer",textDecoration:"underline"}:{},color:v.content.primary,className:"clamp-title",onClick:()=>_==T.FETCHED_LINKS||_==T.WEBSITE_LINKS?(null==q?void 0:q.redirect)&&(null==q?void 0:q.redirect(s)):{}},{children:M}))}))})),i("div",Object.assign({style:{display:"flex",flexDirection:"row",justifyContent:"flex-end",alignItems:"center",gap:"4px",flex:"none"}},{children:[s.intent!==P.EMAIL_COLLECTION&&i(t,{children:[(R=D,e("products"==R?o:"files"==R?l:"website links"==R||"fetched links"==R?g:"faq"==R?r:"texts"==R?u:d,{height:16,width:16,color:v.content.secondary})),e(L,Object.assign({color:v.content.secondary},{children:F}))]}),(s.link||s.docId)&&e("div",Object.assign({style:{cursor:"pointer",marginLeft:"4px"}},{children:e(y,W?{Icon:n,height:16,width:16,bordered:!0,onClick:()=>null==q?void 0:q.onEditClick(q.data,q.type),disabled:!q,disabledTooltip:"This source is deleted"}:{Icon:p,height:16,width:16,bordered:!0,disabled:"custom"===s.type&&!q,disabledTooltip:"This source is deleted",onClick:()=>(null==q?void 0:q.redirect)&&(null==q?void 0:q.redirect(s))})}))]}))]})),(null!=Q?Q:"").trim()&&e("div",Object.assign({style:{padding:"4px 8px",border:`1px dashed ${v.stroke.primary}`,borderRadius:"4px",backgroundColor:v.surface.subdued}},{children:e(L,Object.assign({color:v.content.primary,className:"clamp-description"},{children:($=null!=Q?Q:"",$.replace(/(<([^>]+)>)/gi,"")).trim()}))}))]}),`info-${a}`);var $,R}))}))})),X&&!G(Q)&&e("div",Object.assign({className:"footer"},{children:e(w,{storeId:k,messageSource:A,sourceIntent:null!==(N=A.intent)&&void 0!==N?N:P.GENERIC,faqCount:F})}))]})})})};export{O as DataSourcePanel};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bikdotai/bik-component-library",
3
- "version": "0.0.641-3",
3
+ "version": "0.0.641-4",
4
4
  "description": "Bik Component Library",
5
5
  "repository": {
6
6
  "type": "git",