@whoa-chat/react 0.3.1 → 0.3.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.
- package/LICENSE +14 -0
- package/dist/locales/bg.json +4 -3
- package/dist/locales/da.json +4 -3
- package/dist/locales/de.json +4 -3
- package/dist/locales/en.json +4 -3
- package/dist/locales/es.json +4 -3
- package/dist/locales/fr.json +4 -3
- package/dist/locales/index.d.ts +15 -0
- package/dist/locales/it.json +4 -3
- package/dist/locales/ja.json +4 -3
- package/dist/locales/nl.json +4 -3
- package/dist/locales/pl.json +4 -3
- package/dist/locales/pt-BR.json +4 -3
- package/dist/locales/pt-PT.json +4 -3
- package/dist/locales/sv.json +4 -3
- package/dist/locales/zh-CN.json +4 -3
- package/dist/locales/zh-TW.json +4 -3
- package/dist/src/Attachments.d.ts +0 -3
- package/dist/src/AvailabilityCard.d.ts +0 -4
- package/dist/src/ChatThread.d.ts +0 -5
- package/dist/src/ChatThread.js +7 -7
- package/dist/src/DraftCard.js +1 -1
- package/dist/src/FormattedText.d.ts +0 -4
- package/dist/src/HelpOfferCard.js +1 -1
- package/dist/src/InboxTools.d.ts +0 -3
- package/dist/src/MessagePreview.js +1 -1
- package/dist/src/PasswordCard.js +1 -1
- package/dist/src/ReviewCard.d.ts +0 -2
- package/dist/src/ReviewCard.js +1 -1
- package/dist/src/RichCards.d.ts +0 -3
- package/dist/src/RichCards.js +1 -1
- package/dist/src/RichInput.d.ts +0 -8
- package/dist/src/StoreAvatar.d.ts +0 -1
- package/dist/src/appearance.d.ts +0 -3
- package/dist/src/chatApi.d.ts +0 -4
- package/dist/src/chatEnv.d.ts +0 -1
- package/dist/src/chime.d.ts +0 -1
- package/dist/src/clock.d.ts +0 -1
- package/dist/src/copyToClipboard.d.ts +0 -9
- package/dist/src/host.d.ts +1 -7
- package/dist/src/refLinks.d.ts +0 -1
- package/dist/src/supportChat.css +1 -2521
- package/dist/src/useLive.d.ts +0 -2
- package/package.json +8 -8
package/dist/src/RichCards.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Fragment as k,jsx as t,jsxs as n}from"react/jsx-runtime";import{useContext as $,useEffect as Y,useLayoutEffect as G,useRef as A,useState as z}from"react";import{createPortal as J}from"react-dom";import{useTranslation as m}from"./i18n.js";import{FormattedText as Q}from"./FormattedText.js";import{brandVars as L,chatHost as O}from"./host.js";import{ChatEnvContext as P,ChatEnvProvider as ee}from"./chatEnv.js";const T=/(#[A-Za-z]{0,6}\d{3,20}[A-Za-z]{0,6}\b)/g,B=new Map,te=e=>(B.has(e)||B.set(e,fetch(e,{headers:{Accept:"application/json"}}).then(s=>s.ok?s.json():null).then(s=>s?.reference??null).catch(()=>(B.delete(e),null))),B.get(e)),D=e=>{const s=$(P),[a,o]=z({loading:!0,data:null});return Y(()=>{if(!s)return;let i=!0;return te(s.previewUrl(e)).then(l=>i&&o({loading:!1,data:l})),()=>{i=!1}},[s,e]),a},j=e=>`shopify://admin/orders/${e.id}`,U=e=>`/app/contracts/${e.id}`,F=e=>`shopify://admin/products/${e.id}${e.variant?`/variants/${e.variant.id}`:""}`,V=e=>e.type==="order"?j(e.order):e.type==="subscription"?U(e.subscription):e.type==="product"?F(e.product):e.type==="customer"?`shopify://admin/customers/${e.customer.id}`:`/app/offers/${e.offer.id}`,v=()=>{const{t:e,i18n:s}=m("home");return{money:(r,p)=>new Intl.NumberFormat(s.language,{style:"currency",currency:p}).format(r),usd:r=>new Intl.NumberFormat(s.language,{style:"currency",currency:"USD",maximumFractionDigits:0}).format(r),date:r=>new Date(r).toLocaleDateString(s.language,{day:"numeric",month:"short",year:"numeric"}),inDays:r=>{const p=Math.round((Date.parse(r)-Date.now())/864e5);return p===0?e("supportChat.sub.today"):p>0?e("supportChat.sub.inDays",{count:p}):e("supportChat.sub.daysAgo",{count:-p})},every:r=>r?e(`supportChat.sub.every.${r.unit}`,{count:r.count,defaultValue:`${r.count} ${r.unit}`}):""}},se=e=>(e??"?").split(/\s+/).filter(Boolean).slice(0,2).map(s=>s[0].toUpperCase()).join(""),N=({size:e=13})=>t("svg",{viewBox:"0 0 20 20",width:e,height:e,"aria-hidden":!0,children:t("path",{d:"M4 9a5 5 0 0 1 8.6-3.5L14 7M16 11a5 5 0 0 1-8.6 3.5L6 13M14 3.5V7h-3.5M6 16.5V13h3.5",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round"})}),I=({size:e=13})=>t("svg",{viewBox:"0 0 20 20",width:e,height:e,"aria-hidden":!0,children:t("path",{d:"M5 7h10l-.8 9.2a1 1 0 0 1-1 .8H6.8a1 1 0 0 1-1-.8zM7.5 7V6a2.5 2.5 0 0 1 5 0v1",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round"})}),S=({size:e=13})=>n("svg",{viewBox:"0 0 20 20",width:e,height:e,"aria-hidden":!0,children:[t("path",{d:"M3.5 10.2V4.5a1 1 0 0 1 1-1h5.7l6.3 6.3a1 1 0 0 1 0 1.4l-5.3 5.3a1 1 0 0 1-1.4 0z",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinejoin:"round"}),t("circle",{cx:"7.2",cy:"7.2",r:"1.3",fill:"currentColor"})]}),R=({size:e=13})=>n("svg",{viewBox:"0 0 20 20",width:e,height:e,"aria-hidden":!0,children:[t("circle",{cx:"10",cy:"7",r:"3.2",fill:"none",stroke:"currentColor",strokeWidth:"1.7"}),t("path",{d:"M4 16.5c.8-3 3.2-4.6 6-4.6s5.2 1.6 6 4.6",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round"})]}),re=({size:e=13})=>t("svg",{viewBox:"0 0 20 20",width:e,height:e,"aria-hidden":!0,children:t("path",{d:"M8 3L6.5 17M13.5 3L12 17M3.5 7.5h13M3 12.5h13",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round"})}),W=()=>t("svg",{viewBox:"0 0 20 20",width:"14",height:"14","aria-hidden":!0,children:t("path",{d:"M7 4l6 6-6 6",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),ne={ACTIVE:"active",PAUSED:"paused",CANCELLED:"cancelled",FAILED:"failed",EXPIRED:"cancelled"},E=({tone:e,children:s,live:a})=>n("span",{className:`rc-status rc-status--${e}${a?" rc-status--live":""}`,children:[t("i",{"aria-hidden":!0}),s]}),_=({status:e})=>{const{t:s}=m("home"),a=ne[e]??"cancelled";return t(E,{tone:a,live:a==="active",children:s(`supportChat.sub.status.${a}`,{defaultValue:e.toLowerCase()})})},ae={PAID:"active",PARTIALLY_PAID:"paused",PENDING:"paused",AUTHORIZED:"paused",REFUNDED:"cancelled",PARTIALLY_REFUNDED:"paused",VOIDED:"cancelled",EXPIRED:"failed"},H=({order:e})=>{const{t:s}=m("home");return e.cancelled?t(E,{tone:"cancelled",children:s("supportChat.order.cancelled")}):t(E,{tone:ae[e.financial]??"cancelled",children:s(`supportChat.order.financial.${e.financial}`,{defaultValue:e.financial.toLowerCase()})})},Z=({lines:e,currency:s,more:a,limit:o})=>{const{t:i}=m("home"),l=v(),c=a+Math.max(0,e.length-o);return n("ul",{className:"rc-lines",children:[e.slice(0,o).map((r,p)=>n("li",{children:[t("span",{className:"rc-thumb",children:r.image?t("img",{src:r.image,alt:"",loading:"lazy"}):null}),n("span",{className:"rc-line-text",children:[t("strong",{children:r.title}),r.variant&&t("span",{children:r.variant})]}),n("span",{className:"rc-line-price",children:[r.quantity>1&&n("span",{children:[r.quantity," \xD7 "]}),l.money(r.price,s)]})]},p)),c>0&&t("li",{className:"rc-more",children:i("supportChat.sub.more",{count:c})})]})},w=({path:e,label:s})=>{const{t:a}=m("home"),o=$(P);return n("button",{type:"button",className:"rc-open","data-card-action":"open",disabled:!o?.open,onClick:()=>o?.open?.(e),children:[o?.open?s:a("supportChat.sub.opensForThem"),t(W,{})]})},oe=({compact:e})=>n("div",{className:`rc-card rc-sub${e?" rc-sub--compact":""}`,"aria-busy":"true",children:[t("div",{className:"rc-skel rc-skel--line"}),t("div",{className:"rc-skel rc-skel--block"}),t("div",{className:"rc-skel rc-skel--line rc-skel--short"})]}),ce=({sub:e,compact:s})=>{const{t:a}=m("home"),o=v();return n("article",{className:`rc-card rc-sub${s?" rc-sub--compact":""}`,"aria-label":a("supportChat.sub.label",{id:e.id}),children:[n("header",{className:"rc-sub-head",children:[t("span",{className:"rc-sub-icon","aria-hidden":!0,children:t(N,{size:17})}),n("div",{className:"rc-sub-title",children:[t("strong",{children:a("supportChat.sub.title",{id:e.id})}),t("span",{children:o.every(e.interval)})]}),t(_,{status:e.status})]}),e.customerName&&n("div",{className:"rc-sub-customer",children:[t("span",{className:"rc-initials","aria-hidden":!0,children:se(e.customerName)}),n("div",{children:[t("strong",{children:e.customerName}),e.createdAt&&t("span",{children:a("supportChat.sub.since",{date:o.date(e.createdAt)})})]})]}),t(Z,{lines:e.lines,currency:e.currency,more:e.moreLines,limit:s?2:4}),n("div",{className:"rc-next",children:[e.nextBillingDate&&e.status==="ACTIVE"?n("div",{children:[t("span",{className:"rc-next-label",children:a("supportChat.sub.nextOrder")}),t("strong",{children:o.date(e.nextBillingDate)}),t("span",{className:"rc-next-rel",children:o.inDays(e.nextBillingDate)})]}):t("div",{children:t("span",{className:"rc-next-label",children:a("supportChat.sub.noNextOrder")})}),n("div",{className:"rc-total",children:[t("span",{className:"rc-next-label",children:a("supportChat.sub.perOrder")}),t("strong",{children:o.money(e.total,e.currency)})]})]}),!s&&t(w,{path:U(e),label:a("supportChat.sub.open")})]})},ie=({order:e,compact:s})=>{const{t:a}=m("home"),o=v(),i=e.fulfillment==="FULFILLED";return n("article",{className:`rc-card rc-sub rc-order${s?" rc-sub--compact":""}`,"aria-label":a("supportChat.order.label",{name:e.name}),children:[n("header",{className:"rc-sub-head",children:[t("span",{className:"rc-sub-icon rc-sub-icon--order","aria-hidden":!0,children:t(I,{size:17})}),n("div",{className:"rc-sub-title",children:[t("strong",{children:a("supportChat.order.title",{name:e.name})}),t("span",{children:o.date(e.createdAt)})]}),t(H,{order:e})]}),n("div",{className:"rc-order-tags",children:[t("span",{className:`rc-tag${i?" rc-tag--done":""}`,children:a(`supportChat.order.fulfillment.${e.fulfillment}`,{defaultValue:e.fulfillment.toLowerCase().replace(/_/g," ")})}),e.fromSubscription&&n("span",{className:"rc-tag rc-tag--sub",children:[t(N,{size:11}),a("supportChat.order.subscriptionOrder")]}),e.customerName&&t("span",{className:"rc-tag rc-tag--plain",children:e.customerName})]}),t(Z,{lines:e.lines,currency:e.currency,more:e.moreItems,limit:s?2:4}),n("div",{className:"rc-next",children:[n("div",{children:[t("span",{className:"rc-next-label",children:a("supportChat.order.placed")}),t("strong",{children:o.inDays(e.createdAt)})]}),n("div",{className:"rc-total",children:[t("span",{className:"rc-next-label",children:a("supportChat.order.total")}),t("strong",{children:o.money(e.total,e.currency)})]})]}),!s&&t(w,{path:j(e),label:a("supportChat.order.open")})]})},M=({size:e=17})=>n("svg",{viewBox:"0 0 20 20",width:e,height:e,"aria-hidden":!0,children:[t("path",{d:"M10 2.4l1.8 1.3 2.2-.2.8 2.1 1.9 1.1-.5 2.2.5 2.2-1.9 1.1-.8 2.1-2.2-.2L10 17.6l-1.8-1.3-2.2.2-.8-2.1-1.9-1.1.5-2.2-.5-2.2 1.9-1.1.8-2.1 2.2.2z",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinejoin:"round"}),t("path",{d:"M7.6 12.4l4.8-4.8",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"}),t("circle",{cx:"7.9",cy:"7.9",r:"1",fill:"currentColor"}),t("circle",{cx:"12.1",cy:"12.1",r:"1",fill:"currentColor"})]}),q=e=>{const s=[...e.options,...e.tiers].map(o=>o.badge).filter(o=>!!o),a=s.map(o=>Number(/^(\d+(?:\.\d+)?)% off$/.exec(o)?.[1])).filter(o=>o>0);return a.length?`${Math.max(...a)}% off`:s[0]??null},le=({offer:e})=>{const{t:s}=m("home"),a=q(e),o=e.products.length+e.moreProducts;return n("article",{className:"rc-card rc-sub rc-offer rc-offer--simple","aria-label":e.name,children:[n("header",{className:"rc-offer-head",children:[t("span",{className:"rc-sub-icon rc-sub-icon--offer","aria-hidden":!0,children:t(M,{size:15})}),t("strong",{children:e.name}),n("span",{className:`rc-offer-status rc-offer-status--${e.status}`,children:[t("i",{"aria-hidden":!0}),s(`supportChat.offer.status.${e.status}`)]})]}),n("p",{className:"rc-offer-summary",children:[s(`supportChat.offer.type.${e.type}`)," \xB7 ",a?e.options.length+e.tiers.length>1?s("supportChat.offer.upTo",{off:a}):a:s("supportChat.offer.optionsCount",{count:e.options.length+e.tiers.length})]}),t("div",{className:"rc-offer-products",title:e.products.map(i=>i.title).join(", "),children:e.grouping==="all"?t("span",{className:"rc-tag rc-tag--plain",children:s("supportChat.offer.allProducts")}):o?n(k,{children:[t("span",{className:"rc-offer-thumbs",children:e.products.map((i,l)=>t("span",{className:"rc-thumb rc-thumb--sm",children:i.image?t("img",{src:i.image,alt:"",loading:"lazy"}):t("span",{className:"rc-thumb-letter",children:i.title.slice(0,1)})},l))}),t("span",{className:"rc-offer-names",children:s("supportChat.offer.products",{count:o})})]}):t("span",{className:"rc-tag rc-tag--plain",children:s("supportChat.offer.noProducts")})}),t(w,{path:`/app/offers/${e.id}`,label:s("supportChat.offer.open")})]})},pe=({product:e})=>{const{t:s}=m("home"),a=v(),o=e.variant?a.money(e.variant.price,e.currency):e.priceMin===e.priceMax?a.money(e.priceMin,e.currency):`${a.money(e.priceMin,e.currency)} to ${a.money(e.priceMax,e.currency)}`,i=e.sellingPlans.length>0||e.offers.length>0;return n("article",{className:"rc-card rc-sub rc-product","aria-label":e.title,children:[n("header",{className:"rc-sub-head",children:[t("span",{className:"rc-thumb",children:e.image?t("img",{src:e.image,alt:"",loading:"lazy"}):t("span",{className:"rc-thumb-letter",children:e.title.slice(0,1)})}),n("div",{className:"rc-sub-title",children:[t("strong",{children:e.title}),t("span",{children:e.variant?[e.variant.title,e.variant.sku&&`SKU ${e.variant.sku}`].filter(Boolean).join(" \xB7 ")||s("supportChat.product.variant"):s("supportChat.product.variants",{count:e.variantsCount})})]}),t(E,{tone:e.status==="active"?"active":e.status==="draft"?"paused":"cancelled",children:s(`supportChat.product.status.${e.status}`)})]}),n("div",{className:"rc-product-facts",children:[n("span",{children:[t("small",{children:s("supportChat.product.price")}),t("b",{children:o})]}),e.tracksInventory&&e.inventory!==null&&n("span",{children:[t("small",{children:s("supportChat.product.stock")}),t("b",{className:e.inventory<=0?"rc-product-out":void 0,children:e.inventory})]})]}),n("div",{className:`rc-product-subs${i?"":" rc-product-subs--none"}`,children:[t(N,{}),t("span",{children:i?[e.subscriptionOnly?s("supportChat.product.subscriptionOnly"):s("supportChat.product.onSubscription"),...e.sellingPlans.slice(0,2)].join(" \xB7 "):s("supportChat.product.noPlans")})]}),e.offers.length>0&&t("div",{className:"rc-product-offers",children:e.offers.map(l=>n("span",{className:"rc-tag rc-tag--plain",children:[t(M,{size:12})," ",l.name]},l.id))}),t(w,{path:F(e),label:s("supportChat.product.open")}),e.storeUrl&&t("a",{className:"rc-store-link",href:e.storeUrl,target:"_blank",rel:"noopener noreferrer",children:s("supportChat.product.viewInStore")})]})},ue=({customer:e})=>{const{t:s}=m("home"),a=v(),o=e.subscriptions.filter(l=>l.status==="active"),i=o.map(l=>l.next).filter(l=>!!l).sort()[0]??null;return n("article",{className:"rc-card rc-sub rc-customer","aria-label":e.name,children:[n("header",{className:"rc-offer-head",children:[t("span",{className:"rc-sub-icon rc-sub-icon--customer","aria-hidden":!0,children:t(R,{size:15})}),t("strong",{children:e.name})]}),e.email&&t("p",{className:"rc-offer-summary",children:e.email}),n("div",{className:"rc-product-facts",children:[n("span",{children:[t("small",{children:s("supportChat.customer.orders")}),t("b",{children:e.orders})]}),n("span",{children:[t("small",{children:s("supportChat.customer.spent")}),t("b",{children:a.money(e.spent,e.currency)})]}),e.since&&n("span",{children:[t("small",{children:s("supportChat.customer.since")}),t("b",{children:a.date(e.since)})]})]}),n("div",{className:`rc-product-subs${o.length?"":" rc-product-subs--none"}`,children:[t(N,{}),t("span",{children:o.length?[s("supportChat.customer.active",{count:o.length}),i?s("supportChat.mini.next",{date:a.date(i)}):null].filter(Boolean).join(" \xB7 "):e.subscriptions.length?s("supportChat.customer.noneActive",{count:e.subscriptions.length}):s("supportChat.customer.noSubs")})]}),e.subscriptions.length>0&&t("ul",{className:"rc-customer-subs",children:e.subscriptions.slice(0,3).map(l=>n("li",{children:[t("span",{className:`rc-dot rc-dot--${l.status}`,"aria-hidden":!0}),t("span",{children:l.product??`#${l.id}`}),t("em",{children:l.status})]},l.id))}),e.tags.length>0&&t("div",{className:"rc-product-offers",children:e.tags.map(l=>t("span",{className:"rc-tag rc-tag--plain",children:l},l))}),t(w,{path:`shopify://admin/customers/${e.id}`,label:s("supportChat.customer.open")})]})},K=({refId:e,compact:s})=>{const{t:a}=m("home"),{loading:o,data:i}=D(e);return o?t(oe,{compact:s}):i?i.type==="offer"?t(le,{offer:i.offer}):i.type==="product"?t(pe,{product:i.product}):i.type==="customer"?t(ue,{customer:i.customer}):i.type==="order"?t(ie,{order:i.order,compact:s}):t(ce,{sub:i.subscription,compact:s}):t("div",{className:`rc-card rc-sub rc-sub--missing${s?" rc-sub--compact":""}`,children:a("supportChat.ref.notFound",{ref:`#${e}`})})},we=({id:e})=>t(K,{refId:e}),de=({data:e})=>e?e.type==="order"?t(I,{}):e.type==="offer"?t(M,{size:13}):e.type==="product"?t(S,{}):e.type==="customer"?t(R,{}):t(N,{}):t(re,{}),X=({refId:e,text:s,active:a,onActive:o})=>{const i=$(P),{loading:l,data:c}=D(e),r=A(null),[p,g]=z(null),d=A(),f=()=>{window.clearTimeout(d.current),o?.(e);const h=r.current?.getBoundingClientRect();if(!h)return;const C=320,x=h.bottom+330>window.innerHeight&&h.top>340;g({left:Math.max(8,Math.min(h.left,window.innerWidth-C-8)),top:x?h.top-8:h.bottom+8,above:x})},u=()=>{d.current=window.setTimeout(()=>{g(null),o?.(null)},160)},b=p!==null;G(()=>{if(!b)return;const h=()=>r.current?.isConnected?f():g(null);return window.addEventListener("scroll",h,!0),()=>window.removeEventListener("scroll",h,!0)},[b]);const y=c?V(c):null;return l||!c?t(k,{children:s}):n(k,{children:[n("button",{ref:r,type:"button",className:`rc-mention${c?` rc-mention--${c.type}`:""}${a?" rc-mention--active":""}`,onMouseEnter:f,onMouseLeave:u,onFocus:f,onBlur:u,onClick:()=>i?.open&&y?i.open(y):p?g(null):f(),children:[t(de,{data:c}),s]}),p&&J(t("div",{className:`rc-pop${p.above?" rc-pop--above":""}`,style:{left:p.left,top:p.top},onMouseEnter:()=>window.clearTimeout(d.current),onMouseLeave:u,role:"tooltip",children:t(K,{refId:e,compact:!0})}),document.body)]})},me=({refId:e,active:s,onActive:a})=>{const{t:o}=m("home"),i=$(P),l=v(),{loading:c,data:r}=D(e),p=r?V(r):null,g=r?.type==="order"?r.order.lines:r?.type==="subscription"?r.subscription.lines:[];return!c&&!r?null:t("button",{type:"button",className:`rc-strip-item${s?" rc-strip-item--active":""}`,onMouseEnter:()=>a(e),onMouseLeave:()=>a(null),onFocus:()=>a(e),onBlur:()=>a(null),onClick:()=>i?.open&&p&&i.open(p),disabled:!r,children:c?t("span",{className:"rc-skel rc-skel--line",style:{width:"100%"}}):r?r.type==="customer"?n(k,{children:[n("span",{className:"rc-strip-top",children:[t("span",{className:"rc-strip-icon",children:t(R,{size:12})}),t("strong",{children:r.customer.name})]}),n("span",{className:"rc-strip-bottom",children:[t("span",{children:o("supportChat.customer.active",{count:r.customer.subscriptions.filter(d=>d.status==="active").length})}),t("b",{children:l.money(r.customer.spent,r.customer.currency)})]})]}):r.type==="offer"||r.type==="product"?n(k,{children:[n("span",{className:"rc-strip-top",children:[t("span",{className:"rc-strip-icon",children:r.type==="offer"?t(M,{size:12}):t(S,{size:12})}),t("strong",{children:r.type==="offer"?r.offer.name:r.product.title})]}),t("span",{className:"rc-strip-thumbs",children:(r.type==="offer"?r.offer.products.map(d=>d.image):[r.product.image]).slice(0,3).map((d,f)=>t("span",{className:"rc-thumb rc-thumb--sm",children:d?t("img",{src:d,alt:"",loading:"lazy"}):null},f))}),n("span",{className:"rc-strip-bottom",children:[t("span",{children:r.type==="offer"?o(`supportChat.offer.status.${r.offer.status}`):o(`supportChat.product.status.${r.product.status}`)}),r.type==="product"&&t("b",{children:l.money(r.product.variant?.price??r.product.priceMin,r.product.currency)})]})]}):n(k,{children:[n("span",{className:"rc-strip-top",children:[t("span",{className:`rc-strip-icon${r.type==="order"?" rc-strip-icon--order":""}`,children:r.type==="order"?t(I,{size:12}):t(N,{size:12})}),t("strong",{children:r.type==="order"?r.order.name:`#${r.subscription.id}`}),r.type==="order"?t(H,{order:r.order}):t(_,{status:r.subscription.status})]}),t("span",{className:"rc-strip-thumbs",children:g.slice(0,3).map((d,f)=>t("span",{className:"rc-thumb rc-thumb--sm",children:d.image?t("img",{src:d.image,alt:"",loading:"lazy"}):null},f))}),n("span",{className:"rc-strip-bottom",children:[t("span",{children:r.type==="order"?l.date(r.order.createdAt):l.every(r.subscription.interval)}),t("b",{children:r.type==="order"?l.money(r.order.total,r.order.currency):l.money(r.subscription.total,r.subscription.currency)})]})]}):t("span",{className:"rc-strip-missing",children:o("supportChat.ref.notFound",{ref:`#${e}`})})})},he=e=>[...new Set((e.match(T)??[]).map(s=>s.slice(1)))],ge=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),ke=({text:e,bubbleClass:s,head:a,links:o=[],image:i})=>{const{t:l}=m("home"),c=o.filter(u=>u.text&&e.includes(u.text)).sort((u,b)=>b.text.length-u.text.length),r=new Map(c.map(u=>[u.text,u.ref])),p=c.length?new RegExp(`(${c.map(u=>ge(u.text)).join("|")})`,"g"):null,g=[...new Set([...c.map(u=>u.ref),...he(e)])],[d,f]=z(null);return n("div",{className:"rc-msg",children:[n("div",{className:s,children:[a,t(Q,{text:e,image:i,inline:(u,b)=>(p?u.split(p):[u]).map((y,h)=>p&&h%2===1?t(X,{refId:r.get(y),text:y,active:d===r.get(y),onActive:f},`${b}-n${h}`):y.split(T).map((C,x)=>x%2===0?C:t(X,{refId:C.slice(1),text:C,active:d===C.slice(1),onActive:f},`${b}-${h}-${x}`)))})]}),g.length>1&&n("div",{className:"rc-strip",children:[t("span",{className:"rc-strip-label",children:l("supportChat.ref.mentioned",{count:g.length})}),t("div",{className:"rc-strip-row",children:g.map(u=>t(me,{refId:u,active:d===u,onActive:f},u))})]})]})},xe=({pricing:e})=>{const{t:s}=m("home"),a=v(),o=O().priceBook(e.priceBookId).tiers,i=o.findIndex(r=>r.key===e.tierKey),l=o[o.length-2].upToUsd??1,c=Math.min(98,Math.max(2,Math.log10(Math.max(e.revenueUsd,10))/Math.log10(l*1.5)*100));return n("article",{className:"rc-card rc-pricing","aria-label":s("supportChat.pricing.title",L()),children:[n("header",{className:"rc-pricing-head",children:[t("img",{src:O().brand.logo,alt:"",width:36,height:36}),n("div",{children:[t("strong",{children:s("supportChat.pricing.title",L())}),t("span",{children:s("supportChat.pricing.everyFeature")})]})]}),n("div",{className:"rc-pricing-you",children:[t("span",{className:"rc-next-label",children:s("supportChat.pricing.yourRevenue",L())}),t("strong",{children:a.usd(e.revenueUsd)}),n("div",{className:"rc-meter","aria-hidden":!0,children:[t("span",{className:"rc-meter-fill",style:{width:`${c}%`}}),t("span",{className:"rc-meter-dot",style:{left:`${c}%`}})]}),t("span",{className:"rc-pricing-asof",children:s("supportChat.pricing.asOf",{date:a.date(e.at)})})]}),t("ul",{className:"rc-tiers",children:o.map((r,p)=>n("li",{className:p===i?"rc-tier rc-tier--you":p===i+1?"rc-tier rc-tier--next":"rc-tier",children:[t("span",{className:"rc-tier-name",children:r.upToUsd===null?s("supportChat.pricing.above",{amount:a.usd(o[p-1]?.upToUsd??0)}):s("supportChat.pricing.upTo",{amount:a.usd(r.upToUsd)})}),p===i&&t("span",{className:"rc-tier-badge",children:s("supportChat.pricing.yourPlan")}),p===i+1&&t("span",{className:"rc-tier-badge rc-tier-badge--next",children:s("supportChat.pricing.next")}),t("span",{className:"rc-tier-price",children:r.priceUsd===0?s("supportChat.pricing.noCharge"):s("supportChat.pricing.perMonth",{price:a.usd(r.priceUsd)})})]},r.key))}),t("p",{className:"rc-pricing-note",children:s("supportChat.pricing.whatCounts",L())}),t(w,{path:"/app/plan",label:s("supportChat.pricing.open")})]})},$e=({link:e})=>{const{t:s}=m("home"),a=$(P);return n("article",{className:"rc-card rc-link","aria-label":e.title,children:[n("div",{className:"rc-window","aria-hidden":!0,children:[n("div",{className:"rc-window-bar",children:[t("i",{}),t("i",{}),t("i",{}),t("span",{children:[...e.crumb,e.title].join(" \u203A ")})]}),n("div",{className:"rc-window-body",children:[n("div",{className:"rc-window-nav",children:[t("b",{}),t("b",{}),t("b",{className:"rc-on"}),t("b",{})]}),n("div",{className:"rc-window-main",children:[t("b",{className:"rc-w60"}),t("b",{className:"rc-w90"}),e.setting?n("div",{className:"rc-target",children:[t("span",{children:e.title}),t("em",{})]}):t("b",{className:"rc-w75"}),t("b",{className:"rc-w40"})]})]}),e.setting&&t("svg",{className:"rc-cursor",viewBox:"0 0 24 24",width:"22",height:"22",children:t("path",{d:"M5 3l14 8-6 1.6L10.5 19z",fill:"#0d0d0d",stroke:"#fff",strokeWidth:"1.5",strokeLinejoin:"round"})})]}),n("div",{className:"rc-link-body",children:[t("span",{className:"rc-crumb",children:e.crumb.length?e.crumb.join(" \u203A "):s("supportChat.link.inApp")}),t("strong",{children:e.title}),t("p",{children:e.about}),n("button",{type:"button",className:"rc-open rc-open--brand","data-card-action":"open",disabled:!a?.open,onClick:()=>a?.open?.(e.path),children:[a?.open?s(e.setting?"supportChat.link.openSetting":"supportChat.link.openPage",{title:e.title}):s("supportChat.sub.opensForThem"),t(W,{})]}),e.setting&&t("span",{className:"rc-hint",children:s("supportChat.link.highlightHint")})]})]})},Pe=({refId:e})=>{const{t:s}=m("home"),a=v(),{loading:o,data:i}=D(e);if(o)return t("div",{className:"mp-mini",children:t("span",{className:"rc-skel rc-skel--line",style:{width:"70%"}})});if(!i)return null;const l=(c,r,p,g,d)=>n("div",{className:`mp-mini mp-mini--${c}`,children:[t("span",{className:"mp-mini-pic",children:p?t("img",{src:p,alt:"",loading:"lazy"}):r}),n("span",{className:"mp-mini-text",children:[t("strong",{children:g}),t("span",{children:d})]})]});switch(i.type){case"order":{const c=i.order;return l("order",t(I,{size:15}),c.lines[0]?.image??null,s("supportChat.mini.order",{name:c.name}),[c.cancelled?s("supportChat.mini.cancelled"):c.financial.toLowerCase().replace(/_/g," "),a.money(c.total,c.currency)].join(" \xB7 "))}case"subscription":{const c=i.subscription;return l("subscription",t(N,{size:15}),c.lines[0]?.image??null,s("supportChat.mini.subscription",{id:c.id}),[c.status.toLowerCase(),c.nextBillingDate?s("supportChat.mini.next",{date:a.date(c.nextBillingDate)}):null].filter(Boolean).join(" \xB7 "))}case"offer":{const c=i.offer,r=q(c);return l("offer",t(M,{size:15}),null,c.name,[s(`supportChat.offer.type.${c.type}`),r].filter(Boolean).join(" \xB7 "))}case"customer":{const c=i.customer,r=c.subscriptions.filter(p=>p.status==="active").length;return l("customer",t(R,{size:15}),null,c.name,[s("supportChat.customer.active",{count:r}),s("supportChat.customer.ordersCount",{count:c.orders})].join(" \xB7 "))}case"product":{const c=i.product;return l("product",t(S,{size:15}),c.image,c.variant?.title?`${c.title}, ${c.variant.title}`:c.title,[a.money(c.variant?.price??c.priceMin,c.currency),c.sellingPlans.length||c.offers.length?s("supportChat.product.onSubscription"):null].filter(Boolean).join(" \xB7 "))}}};export{ee as ChatEnvProvider,$e as DeepLinkCard,X as Mention,ke as MessageWithReferences,xe as PricingCard,K as ReferenceCard,Pe as ReferenceMini,we as SubscriptionCard,he as referencesIn};
|
|
1
|
+
import{Fragment as k,jsx as t,jsxs as n}from"react/jsx-runtime";import{useContext as $,useEffect as Y,useLayoutEffect as G,useRef as A,useState as z}from"react";import{createPortal as J}from"react-dom";import{useTranslation as m}from"./i18n.js";import{FormattedText as Q}from"./FormattedText.js";import{brandVars as L,chatHost as O}from"./host.js";import{ChatEnvContext as P,ChatEnvProvider as ee}from"./chatEnv.js";const T=/(#[A-Za-z]{0,6}\d{3,20}[A-Za-z]{0,6}\b)/g,B=new Map,te=e=>(B.has(e)||B.set(e,fetch(e,{headers:{Accept:"application/json"}}).then(s=>s.ok?s.json():null).then(s=>s?.reference??null).catch(()=>(B.delete(e),null))),B.get(e)),D=e=>{const s=$(P),[a,o]=z({loading:!0,data:null});return Y(()=>{if(!s)return;let i=!0;return te(s.previewUrl(e)).then(l=>i&&o({loading:!1,data:l})),()=>{i=!1}},[s,e]),a},j=e=>`shopify://admin/orders/${e.id}`,U=e=>`/app/contracts/${e.id}`,F=e=>`shopify://admin/products/${e.id}${e.variant?`/variants/${e.variant.id}`:""}`,V=e=>e.type==="order"?j(e.order):e.type==="subscription"?U(e.subscription):e.type==="product"?F(e.product):e.type==="customer"?`shopify://admin/customers/${e.customer.id}`:`/app/offers/${e.offer.id}`,v=()=>{const{t:e,i18n:s}=m("home");return{money:(r,p)=>new Intl.NumberFormat(s.language,{style:"currency",currency:p}).format(r),usd:r=>new Intl.NumberFormat(s.language,{style:"currency",currency:"USD",maximumFractionDigits:0}).format(r),date:r=>new Date(r).toLocaleDateString(s.language,{day:"numeric",month:"short",year:"numeric"}),inDays:r=>{const p=Math.round((Date.parse(r)-Date.now())/864e5);return p===0?e("supportChat.sub.today"):p>0?e("supportChat.sub.inDays",{count:p}):e("supportChat.sub.daysAgo",{count:-p})},every:r=>r?e(`supportChat.sub.every.${r.unit}`,{count:r.count,defaultValue:`${r.count} ${r.unit}`}):""}},se=e=>(e??"?").split(/\s+/).filter(Boolean).slice(0,2).map(s=>s[0].toUpperCase()).join(""),N=({size:e=13})=>t("svg",{viewBox:"0 0 20 20",width:e,height:e,"aria-hidden":!0,children:t("path",{d:"M4 9a5 5 0 0 1 8.6-3.5L14 7M16 11a5 5 0 0 1-8.6 3.5L6 13M14 3.5V7h-3.5M6 16.5V13h3.5",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round"})}),I=({size:e=13})=>t("svg",{viewBox:"0 0 20 20",width:e,height:e,"aria-hidden":!0,children:t("path",{d:"M5 7h10l-.8 9.2a1 1 0 0 1-1 .8H6.8a1 1 0 0 1-1-.8zM7.5 7V6a2.5 2.5 0 0 1 5 0v1",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round"})}),S=({size:e=13})=>n("svg",{viewBox:"0 0 20 20",width:e,height:e,"aria-hidden":!0,children:[t("path",{d:"M3.5 10.2V4.5a1 1 0 0 1 1-1h5.7l6.3 6.3a1 1 0 0 1 0 1.4l-5.3 5.3a1 1 0 0 1-1.4 0z",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinejoin:"round"}),t("circle",{cx:"7.2",cy:"7.2",r:"1.3",fill:"currentColor"})]}),R=({size:e=13})=>n("svg",{viewBox:"0 0 20 20",width:e,height:e,"aria-hidden":!0,children:[t("circle",{cx:"10",cy:"7",r:"3.2",fill:"none",stroke:"currentColor",strokeWidth:"1.7"}),t("path",{d:"M4 16.5c.8-3 3.2-4.6 6-4.6s5.2 1.6 6 4.6",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round"})]}),re=({size:e=13})=>t("svg",{viewBox:"0 0 20 20",width:e,height:e,"aria-hidden":!0,children:t("path",{d:"M8 3L6.5 17M13.5 3L12 17M3.5 7.5h13M3 12.5h13",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round"})}),W=()=>t("svg",{viewBox:"0 0 20 20",width:"14",height:"14","aria-hidden":!0,children:t("path",{d:"M7 4l6 6-6 6",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),ne={ACTIVE:"active",PAUSED:"paused",CANCELLED:"cancelled",FAILED:"failed",EXPIRED:"cancelled"},E=({tone:e,children:s,live:a})=>n("span",{className:`rc-status rc-status--${e}${a?" rc-status--live":""}`,children:[t("i",{"aria-hidden":!0}),s]}),_=({status:e})=>{const{t:s}=m("home"),a=ne[e]??"cancelled";return t(E,{tone:a,live:a==="active",children:s(`supportChat.sub.status.${a}`,{defaultValue:e.toLowerCase()})})},ae={PAID:"active",PARTIALLY_PAID:"paused",PENDING:"paused",AUTHORIZED:"paused",REFUNDED:"cancelled",PARTIALLY_REFUNDED:"paused",VOIDED:"cancelled",EXPIRED:"failed"},H=({order:e})=>{const{t:s}=m("home");return e.cancelled?t(E,{tone:"cancelled",children:s("supportChat.order.cancelled")}):t(E,{tone:ae[e.financial]??"cancelled",children:s(`supportChat.order.financial.${e.financial}`,{defaultValue:e.financial.toLowerCase()})})},Z=({lines:e,currency:s,more:a,limit:o})=>{const{t:i}=m("home"),l=v(),c=a+Math.max(0,e.length-o);return n("ul",{className:"rc-lines",children:[e.slice(0,o).map((r,p)=>n("li",{children:[t("span",{className:"rc-thumb",children:r.image?t("img",{src:r.image,alt:"",loading:"lazy"}):null}),n("span",{className:"rc-line-text",children:[t("strong",{children:r.title}),r.variant&&t("span",{children:r.variant})]}),n("span",{className:"rc-line-price",children:[r.quantity>1&&n("span",{children:[r.quantity," \xD7 "]}),l.money(r.price,s)]})]},p)),c>0&&t("li",{className:"rc-more",children:i("supportChat.sub.more",{count:c})})]})},w=({path:e,label:s})=>{const{t:a}=m("home"),o=$(P);return n("button",{type:"button",className:"rc-open","data-card-action":"open",disabled:!o?.open,onClick:()=>o?.open?.(e),children:[o?.open?s:a("supportChat.sub.opensForThem"),t(W,{})]})},oe=({compact:e})=>n("div",{className:`rc-card rc-sub${e?" rc-sub--compact":""}`,"aria-busy":"true",children:[t("div",{className:"rc-skel rc-skel--line"}),t("div",{className:"rc-skel rc-skel--block"}),t("div",{className:"rc-skel rc-skel--line rc-skel--short"})]}),ce=({sub:e,compact:s})=>{const{t:a}=m("home"),o=v();return n("article",{className:`rc-card rc-sub${s?" rc-sub--compact":""}`,"aria-label":a("supportChat.sub.label",{id:e.id}),children:[n("header",{className:"rc-sub-head",children:[t("span",{className:"rc-sub-icon","aria-hidden":!0,children:t(N,{size:17})}),n("div",{className:"rc-sub-title",children:[t("strong",{children:a("supportChat.sub.title",{id:e.id})}),t("span",{children:o.every(e.interval)})]}),t(_,{status:e.status})]}),e.customerName&&n("div",{className:"rc-sub-customer",children:[t("span",{className:"rc-initials","aria-hidden":!0,children:se(e.customerName)}),n("div",{children:[t("strong",{children:e.customerName}),e.createdAt&&t("span",{children:a("supportChat.sub.since",{date:o.date(e.createdAt)})})]})]}),t(Z,{lines:e.lines,currency:e.currency,more:e.moreLines,limit:s?2:4}),n("div",{className:"rc-next",children:[e.nextBillingDate&&e.status==="ACTIVE"?n("div",{children:[t("span",{className:"rc-next-label",children:a("supportChat.sub.nextOrder")}),t("strong",{children:o.date(e.nextBillingDate)}),t("span",{className:"rc-next-rel",children:o.inDays(e.nextBillingDate)})]}):t("div",{children:t("span",{className:"rc-next-label",children:a("supportChat.sub.noNextOrder")})}),n("div",{className:"rc-total",children:[t("span",{className:"rc-next-label",children:a("supportChat.sub.perOrder")}),t("strong",{children:o.money(e.total,e.currency)})]})]}),!s&&t(w,{path:U(e),label:a("supportChat.sub.open")})]})},ie=({order:e,compact:s})=>{const{t:a}=m("home"),o=v(),i=e.fulfillment==="FULFILLED";return n("article",{className:`rc-card rc-sub rc-order${s?" rc-sub--compact":""}`,"aria-label":a("supportChat.order.label",{name:e.name}),children:[n("header",{className:"rc-sub-head",children:[t("span",{className:"rc-sub-icon rc-sub-icon--order","aria-hidden":!0,children:t(I,{size:17})}),n("div",{className:"rc-sub-title",children:[t("strong",{children:a("supportChat.order.title",{name:e.name})}),t("span",{children:o.date(e.createdAt)})]}),t(H,{order:e})]}),n("div",{className:"rc-order-tags",children:[t("span",{className:`rc-tag${i?" rc-tag--done":""}`,children:a(`supportChat.order.fulfillment.${e.fulfillment}`,{defaultValue:e.fulfillment.toLowerCase().replace(/_/g," ")})}),e.fromSubscription&&n("span",{className:"rc-tag rc-tag--sub",children:[t(N,{size:11}),a("supportChat.order.subscriptionOrder")]}),e.customerName&&t("span",{className:"rc-tag rc-tag--plain",children:e.customerName})]}),t(Z,{lines:e.lines,currency:e.currency,more:e.moreItems,limit:s?2:4}),n("div",{className:"rc-next",children:[n("div",{children:[t("span",{className:"rc-next-label",children:a("supportChat.order.placed")}),t("strong",{children:o.inDays(e.createdAt)})]}),n("div",{className:"rc-total",children:[t("span",{className:"rc-next-label",children:a("supportChat.order.total")}),t("strong",{children:o.money(e.total,e.currency)})]})]}),!s&&t(w,{path:j(e),label:a("supportChat.order.open")})]})},M=({size:e=17})=>n("svg",{viewBox:"0 0 20 20",width:e,height:e,"aria-hidden":!0,children:[t("path",{d:"M10 2.4l1.8 1.3 2.2-.2.8 2.1 1.9 1.1-.5 2.2.5 2.2-1.9 1.1-.8 2.1-2.2-.2L10 17.6l-1.8-1.3-2.2.2-.8-2.1-1.9-1.1.5-2.2-.5-2.2 1.9-1.1.8-2.1 2.2.2z",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinejoin:"round"}),t("path",{d:"M7.6 12.4l4.8-4.8",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"}),t("circle",{cx:"7.9",cy:"7.9",r:"1",fill:"currentColor"}),t("circle",{cx:"12.1",cy:"12.1",r:"1",fill:"currentColor"})]}),q=e=>{const s=[...e.options,...e.tiers].map(o=>o.badge).filter(o=>!!o),a=s.map(o=>Number(/^(\d+(?:\.\d+)?)% off$/.exec(o)?.[1])).filter(o=>o>0);return a.length?`${Math.max(...a)}% off`:s[0]??null},le=({offer:e})=>{const{t:s}=m("home"),a=q(e),o=e.products.length+e.moreProducts;return n("article",{className:"rc-card rc-sub rc-offer rc-offer--simple","aria-label":e.name,children:[n("header",{className:"rc-offer-head",children:[t("span",{className:"rc-sub-icon rc-sub-icon--offer","aria-hidden":!0,children:t(M,{size:15})}),t("strong",{children:e.name}),n("span",{className:`rc-offer-status rc-offer-status--${e.status}`,children:[t("i",{"aria-hidden":!0}),s(`supportChat.offer.status.${e.status}`)]})]}),n("p",{className:"rc-offer-summary",children:[s(`supportChat.offer.type.${e.type}`)," \xB7 ",a?e.options.length+e.tiers.length>1?s("supportChat.offer.upTo",{off:a}):a:s("supportChat.offer.optionsCount",{count:e.options.length+e.tiers.length})]}),t("div",{className:"rc-offer-products",title:e.products.map(i=>i.title).join(", "),children:e.grouping==="all"?t("span",{className:"rc-tag rc-tag--plain",children:s("supportChat.offer.allProducts")}):o?n(k,{children:[t("span",{className:"rc-offer-thumbs",children:e.products.map((i,l)=>t("span",{className:"rc-thumb rc-thumb--sm",children:i.image?t("img",{src:i.image,alt:"",loading:"lazy"}):t("span",{className:"rc-thumb-letter",children:i.title.slice(0,1)})},l))}),t("span",{className:"rc-offer-names",children:s("supportChat.offer.products",{count:o})})]}):t("span",{className:"rc-tag rc-tag--plain",children:s("supportChat.offer.noProducts")})}),t(w,{path:`/app/offers/${e.id}`,label:s("supportChat.offer.open")})]})},pe=({product:e})=>{const{t:s}=m("home"),a=v(),o=e.variant?a.money(e.variant.price,e.currency):e.priceMin===e.priceMax?a.money(e.priceMin,e.currency):`${a.money(e.priceMin,e.currency)} to ${a.money(e.priceMax,e.currency)}`,i=e.sellingPlans.length>0||e.offers.length>0;return n("article",{className:"rc-card rc-sub rc-product","aria-label":e.title,children:[n("header",{className:"rc-sub-head",children:[t("span",{className:"rc-thumb",children:e.image?t("img",{src:e.image,alt:"",loading:"lazy"}):t("span",{className:"rc-thumb-letter",children:e.title.slice(0,1)})}),n("div",{className:"rc-sub-title",children:[t("strong",{children:e.title}),t("span",{children:e.variant?[e.variant.title,e.variant.sku&&`SKU ${e.variant.sku}`].filter(Boolean).join(" \xB7 ")||s("supportChat.product.variant"):s("supportChat.product.variants",{count:e.variantsCount})})]}),t(E,{tone:e.status==="active"?"active":e.status==="draft"?"paused":"cancelled",children:s(`supportChat.product.status.${e.status}`)})]}),n("div",{className:"rc-product-facts",children:[n("span",{children:[t("small",{children:s("supportChat.product.price")}),t("b",{children:o})]}),e.tracksInventory&&e.inventory!==null&&n("span",{children:[t("small",{children:s("supportChat.product.stock")}),t("b",{className:e.inventory<=0?"rc-product-out":void 0,children:e.inventory})]})]}),n("div",{className:`rc-product-subs${i?"":" rc-product-subs--none"}`,children:[t(N,{}),t("span",{children:i?[e.subscriptionOnly?s("supportChat.product.subscriptionOnly"):s("supportChat.product.onSubscription"),...e.sellingPlans.slice(0,2)].join(" \xB7 "):s("supportChat.product.noPlans")})]}),e.offers.length>0&&t("div",{className:"rc-product-offers",children:e.offers.map(l=>n("span",{className:"rc-tag rc-tag--plain",children:[t(M,{size:12})," ",l.name]},l.id))}),t(w,{path:F(e),label:s("supportChat.product.open")}),e.storeUrl&&t("a",{className:"rc-store-link",href:e.storeUrl,target:"_blank",rel:"noopener noreferrer",children:s("supportChat.product.viewInStore")})]})},ue=({customer:e})=>{const{t:s}=m("home"),a=v(),o=e.subscriptions.filter(l=>l.status==="active"),i=o.map(l=>l.next).filter(l=>!!l).sort()[0]??null;return n("article",{className:"rc-card rc-sub rc-customer","aria-label":e.name,children:[n("header",{className:"rc-offer-head",children:[t("span",{className:"rc-sub-icon rc-sub-icon--customer","aria-hidden":!0,children:t(R,{size:15})}),t("strong",{children:e.name})]}),e.email&&t("p",{className:"rc-offer-summary",children:e.email}),n("div",{className:"rc-product-facts",children:[n("span",{children:[t("small",{children:s("supportChat.customer.orders")}),t("b",{children:e.orders})]}),n("span",{children:[t("small",{children:s("supportChat.customer.spent")}),t("b",{children:a.money(e.spent,e.currency)})]}),e.since&&n("span",{children:[t("small",{children:s("supportChat.customer.since")}),t("b",{children:a.date(e.since)})]})]}),n("div",{className:`rc-product-subs${o.length?"":" rc-product-subs--none"}`,children:[t(N,{}),t("span",{children:o.length?[s("supportChat.customer.active",{count:o.length}),i?s("supportChat.mini.next",{date:a.date(i)}):null].filter(Boolean).join(" \xB7 "):e.subscriptions.length?s("supportChat.customer.noneActive",{count:e.subscriptions.length}):s("supportChat.customer.noSubs")})]}),e.subscriptions.length>0&&t("ul",{className:"rc-customer-subs",children:e.subscriptions.slice(0,3).map(l=>n("li",{children:[t("span",{className:`rc-dot rc-dot--${l.status}`,"aria-hidden":!0}),t("span",{children:l.product??`#${l.id}`}),t("em",{children:l.status})]},l.id))}),e.tags.length>0&&t("div",{className:"rc-product-offers",children:e.tags.map(l=>t("span",{className:"rc-tag rc-tag--plain",children:l},l))}),t(w,{path:`shopify://admin/customers/${e.id}`,label:s("supportChat.customer.open")})]})},K=({refId:e,compact:s})=>{const{t:a}=m("home"),{loading:o,data:i}=D(e);return o?t(oe,{compact:s}):i?i.type==="offer"?t(le,{offer:i.offer}):i.type==="product"?t(pe,{product:i.product}):i.type==="customer"?t(ue,{customer:i.customer}):i.type==="order"?t(ie,{order:i.order,compact:s}):t(ce,{sub:i.subscription,compact:s}):t("div",{className:`rc-card rc-sub rc-sub--missing${s?" rc-sub--compact":""}`,children:a("supportChat.ref.notFound",{ref:`#${e}`})})},we=({id:e})=>t(K,{refId:e}),de=({data:e})=>e?e.type==="order"?t(I,{}):e.type==="offer"?t(M,{size:13}):e.type==="product"?t(S,{}):e.type==="customer"?t(R,{}):t(N,{}):t(re,{}),X=({refId:e,text:s,active:a,onActive:o})=>{const i=$(P),{loading:l,data:c}=D(e),r=A(null),[p,g]=z(null),d=A(),f=()=>{window.clearTimeout(d.current),o?.(e);const h=r.current?.getBoundingClientRect();if(!h)return;const C=320,x=h.bottom+330>window.innerHeight&&h.top>340;g({left:Math.max(8,Math.min(h.left,window.innerWidth-C-8)),top:x?h.top-8:h.bottom+8,above:x})},u=()=>{d.current=window.setTimeout(()=>{g(null),o?.(null)},160)},b=p!==null;G(()=>{if(!b)return;const h=()=>r.current?.isConnected?f():g(null);return window.addEventListener("scroll",h,!0),()=>window.removeEventListener("scroll",h,!0)},[b]);const y=c?V(c):null;return l||!c?t(k,{children:s}):n(k,{children:[n("button",{ref:r,type:"button",className:`rc-mention${c?` rc-mention--${c.type}`:""}${a?" rc-mention--active":""}`,onMouseEnter:f,onMouseLeave:u,onFocus:f,onBlur:u,onClick:()=>i?.open&&y?i.open(y):p?g(null):f(),children:[t(de,{data:c}),s]}),p&&J(t("div",{className:`rc-pop${p.above?" rc-pop--above":""}`,style:{left:p.left,top:p.top},onMouseEnter:()=>window.clearTimeout(d.current),onMouseLeave:u,role:"tooltip",children:t(K,{refId:e,compact:!0})}),document.body)]})},me=({refId:e,active:s,onActive:a})=>{const{t:o}=m("home"),i=$(P),l=v(),{loading:c,data:r}=D(e),p=r?V(r):null,g=r?.type==="order"?r.order.lines:r?.type==="subscription"?r.subscription.lines:[];return!c&&!r?null:t("button",{type:"button",className:`rc-strip-item${s?" rc-strip-item--active":""}`,onMouseEnter:()=>a(e),onMouseLeave:()=>a(null),onFocus:()=>a(e),onBlur:()=>a(null),onClick:()=>i?.open&&p&&i.open(p),disabled:!r,children:c?t("span",{className:"rc-skel rc-skel--line",style:{width:"100%"}}):r?r.type==="customer"?n(k,{children:[n("span",{className:"rc-strip-top",children:[t("span",{className:"rc-strip-icon",children:t(R,{size:12})}),t("strong",{children:r.customer.name})]}),n("span",{className:"rc-strip-bottom",children:[t("span",{children:o("supportChat.customer.active",{count:r.customer.subscriptions.filter(d=>d.status==="active").length})}),t("b",{children:l.money(r.customer.spent,r.customer.currency)})]})]}):r.type==="offer"||r.type==="product"?n(k,{children:[n("span",{className:"rc-strip-top",children:[t("span",{className:"rc-strip-icon",children:r.type==="offer"?t(M,{size:12}):t(S,{size:12})}),t("strong",{children:r.type==="offer"?r.offer.name:r.product.title})]}),t("span",{className:"rc-strip-thumbs",children:(r.type==="offer"?r.offer.products.map(d=>d.image):[r.product.image]).slice(0,3).map((d,f)=>t("span",{className:"rc-thumb rc-thumb--sm",children:d?t("img",{src:d,alt:"",loading:"lazy"}):null},f))}),n("span",{className:"rc-strip-bottom",children:[t("span",{children:r.type==="offer"?o(`supportChat.offer.status.${r.offer.status}`):o(`supportChat.product.status.${r.product.status}`)}),r.type==="product"&&t("b",{children:l.money(r.product.variant?.price??r.product.priceMin,r.product.currency)})]})]}):n(k,{children:[n("span",{className:"rc-strip-top",children:[t("span",{className:`rc-strip-icon${r.type==="order"?" rc-strip-icon--order":""}`,children:r.type==="order"?t(I,{size:12}):t(N,{size:12})}),t("strong",{children:r.type==="order"?r.order.name:`#${r.subscription.id}`}),r.type==="order"?t(H,{order:r.order}):t(_,{status:r.subscription.status})]}),t("span",{className:"rc-strip-thumbs",children:g.slice(0,3).map((d,f)=>t("span",{className:"rc-thumb rc-thumb--sm",children:d.image?t("img",{src:d.image,alt:"",loading:"lazy"}):null},f))}),n("span",{className:"rc-strip-bottom",children:[t("span",{children:r.type==="order"?l.date(r.order.createdAt):l.every(r.subscription.interval)}),t("b",{children:r.type==="order"?l.money(r.order.total,r.order.currency):l.money(r.subscription.total,r.subscription.currency)})]})]}):t("span",{className:"rc-strip-missing",children:o("supportChat.ref.notFound",{ref:`#${e}`})})})},he=e=>[...new Set((e.match(T)??[]).map(s=>s.slice(1)))],ge=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),ke=({text:e,bubbleClass:s,head:a,links:o=[],image:i})=>{const{t:l}=m("home"),c=o.filter(u=>u.text&&e.includes(u.text)).sort((u,b)=>b.text.length-u.text.length),r=new Map(c.map(u=>[u.text,u.ref])),p=c.length?new RegExp(`(${c.map(u=>ge(u.text)).join("|")})`,"g"):null,g=[...new Set([...c.map(u=>u.ref),...he(e)])],[d,f]=z(null);return n("div",{className:"rc-msg",children:[n("div",{className:s,children:[a,t(Q,{text:e,image:i,inline:(u,b)=>(p?u.split(p):[u]).map((y,h)=>p&&h%2===1?t(X,{refId:r.get(y),text:y,active:d===r.get(y),onActive:f},`${b}-n${h}`):y.split(T).map((C,x)=>x%2===0?C:t(X,{refId:C.slice(1),text:C,active:d===C.slice(1),onActive:f},`${b}-${h}-${x}`)))})]}),g.length>1&&n("div",{className:"rc-strip",children:[t("span",{className:"rc-strip-label",children:l("supportChat.ref.mentioned",{count:g.length})}),t("div",{className:"rc-strip-row",children:g.map(u=>t(me,{refId:u,active:d===u,onActive:f},u))})]})]})},xe=({pricing:e})=>{const{t:s}=m("home"),a=v(),o=O().priceBook(e.priceBookId).tiers,i=o.findIndex(r=>r.key===e.tierKey),l=o[o.length-2].upToUsd??1,c=Math.min(98,Math.max(2,Math.log10(Math.max(e.revenueUsd,10))/Math.log10(l*1.5)*100));return n("article",{className:"rc-card rc-pricing","aria-label":s("supportChat.pricing.title",L()),children:[n("header",{className:"rc-pricing-head",children:[t("img",{src:O().brand.logo,alt:"",width:36,height:36}),n("div",{children:[t("strong",{children:s("supportChat.pricing.title",L())}),t("span",{children:s("supportChat.pricing.everyFeature")})]})]}),n("div",{className:"rc-pricing-you",children:[t("span",{className:"rc-next-label",children:s("supportChat.pricing.yourRevenue",L())}),t("strong",{children:a.usd(e.revenueUsd)}),n("div",{className:"rc-meter","aria-hidden":!0,children:[t("span",{className:"rc-meter-fill",style:{width:`${c}%`}}),t("span",{className:"rc-meter-dot",style:{left:`${c}%`}})]}),t("span",{className:"rc-pricing-asof",children:s("supportChat.pricing.asOf",{date:a.date(e.at)})})]}),t("ul",{className:"rc-tiers",children:o.map((r,p)=>n("li",{className:p===i?"rc-tier rc-tier--you":p===i+1?"rc-tier rc-tier--next":"rc-tier",children:[t("span",{className:"rc-tier-name",children:r.upToUsd===null?s("supportChat.pricing.above",{amount:a.usd(o[p-1]?.upToUsd??0)}):s("supportChat.pricing.upTo",{amount:a.usd(r.upToUsd)})}),p===i&&t("span",{className:"rc-tier-badge",children:s("supportChat.pricing.yourPlan")}),p===i+1&&t("span",{className:"rc-tier-badge rc-tier-badge--next",children:s("supportChat.pricing.next")}),t("span",{className:"rc-tier-price",children:r.custom?s("supportChat.pricing.custom"):r.priceUsd===0?s("supportChat.pricing.noCharge"):s("supportChat.pricing.perMonth",{price:a.usd(r.priceUsd)})})]},r.key))}),t("p",{className:"rc-pricing-note",children:s("supportChat.pricing.whatCounts",L())}),t(w,{path:"/app/plan",label:s("supportChat.pricing.open")})]})},$e=({link:e})=>{const{t:s}=m("home"),a=$(P);return n("article",{className:"rc-card rc-link","aria-label":e.title,children:[n("div",{className:"rc-window","aria-hidden":!0,children:[n("div",{className:"rc-window-bar",children:[t("i",{}),t("i",{}),t("i",{}),t("span",{children:[...e.crumb,e.title].join(" \u203A ")})]}),n("div",{className:"rc-window-body",children:[n("div",{className:"rc-window-nav",children:[t("b",{}),t("b",{}),t("b",{className:"rc-on"}),t("b",{})]}),n("div",{className:"rc-window-main",children:[t("b",{className:"rc-w60"}),t("b",{className:"rc-w90"}),e.setting?n("div",{className:"rc-target",children:[t("span",{children:e.title}),t("em",{})]}):t("b",{className:"rc-w75"}),t("b",{className:"rc-w40"})]})]}),e.setting&&t("svg",{className:"rc-cursor",viewBox:"0 0 24 24",width:"22",height:"22",children:t("path",{d:"M5 3l14 8-6 1.6L10.5 19z",fill:"#0d0d0d",stroke:"#fff",strokeWidth:"1.5",strokeLinejoin:"round"})})]}),n("div",{className:"rc-link-body",children:[t("span",{className:"rc-crumb",children:e.crumb.length?e.crumb.join(" \u203A "):s("supportChat.link.inApp")}),t("strong",{children:e.title}),t("p",{children:e.about}),n("button",{type:"button",className:"rc-open rc-open--brand","data-card-action":"open",disabled:!a?.open,onClick:()=>a?.open?.(e.path),children:[a?.open?s(e.setting?"supportChat.link.openSetting":"supportChat.link.openPage",{title:e.title}):s("supportChat.sub.opensForThem"),t(W,{})]}),e.setting&&t("span",{className:"rc-hint",children:s("supportChat.link.highlightHint")})]})]})},Pe=({refId:e})=>{const{t:s}=m("home"),a=v(),{loading:o,data:i}=D(e);if(o)return t("div",{className:"mp-mini",children:t("span",{className:"rc-skel rc-skel--line",style:{width:"70%"}})});if(!i)return null;const l=(c,r,p,g,d)=>n("div",{className:`mp-mini mp-mini--${c}`,children:[t("span",{className:"mp-mini-pic",children:p?t("img",{src:p,alt:"",loading:"lazy"}):r}),n("span",{className:"mp-mini-text",children:[t("strong",{children:g}),t("span",{children:d})]})]});switch(i.type){case"order":{const c=i.order;return l("order",t(I,{size:15}),c.lines[0]?.image??null,s("supportChat.mini.order",{name:c.name}),[c.cancelled?s("supportChat.mini.cancelled"):c.financial.toLowerCase().replace(/_/g," "),a.money(c.total,c.currency)].join(" \xB7 "))}case"subscription":{const c=i.subscription;return l("subscription",t(N,{size:15}),c.lines[0]?.image??null,s("supportChat.mini.subscription",{id:c.id}),[c.status.toLowerCase(),c.nextBillingDate?s("supportChat.mini.next",{date:a.date(c.nextBillingDate)}):null].filter(Boolean).join(" \xB7 "))}case"offer":{const c=i.offer,r=q(c);return l("offer",t(M,{size:15}),null,c.name,[s(`supportChat.offer.type.${c.type}`),r].filter(Boolean).join(" \xB7 "))}case"customer":{const c=i.customer,r=c.subscriptions.filter(p=>p.status==="active").length;return l("customer",t(R,{size:15}),null,c.name,[s("supportChat.customer.active",{count:r}),s("supportChat.customer.ordersCount",{count:c.orders})].join(" \xB7 "))}case"product":{const c=i.product;return l("product",t(S,{size:15}),c.image,c.variant?.title?`${c.title}, ${c.variant.title}`:c.title,[a.money(c.variant?.price??c.priceMin,c.currency),c.sellingPlans.length||c.offers.length?s("supportChat.product.onSubscription"):null].filter(Boolean).join(" \xB7 "))}}};export{ee as ChatEnvProvider,$e as DeepLinkCard,X as Mention,ke as MessageWithReferences,xe as PricingCard,K as ReferenceCard,Pe as ReferenceMini,we as SubscriptionCard,he as referencesIn};
|
package/dist/src/RichInput.d.ts
CHANGED
|
@@ -5,13 +5,9 @@ export type RichHandle = {
|
|
|
5
5
|
focus: () => void;
|
|
6
6
|
setText: (text: string, refs?: MessageRef[]) => void;
|
|
7
7
|
insertText: (text: string) => void;
|
|
8
|
-
/** Replaces the `count` characters before the caret with text, or with a chip and a space. */
|
|
9
8
|
replaceBefore: (count: number, text: string, chip?: MessageRef) => void;
|
|
10
9
|
clear: () => void;
|
|
11
|
-
/** Places an image at the cursor while it uploads (key), then gives it its file id, or takes it out. */
|
|
12
10
|
insertImage: (key: string, name: string, src: string) => void;
|
|
13
|
-
/** A link at the cursor as a chip; with no label given, the selected words become its label. */
|
|
14
|
-
/** before: how many characters before the caret it replaces (a typed "[query"). */
|
|
15
11
|
insertLink: (url: string, label?: string, before?: number) => void;
|
|
16
12
|
setImageId: (key: string, id: string) => void;
|
|
17
13
|
removeImage: (key: string) => void;
|
|
@@ -21,20 +17,16 @@ export type RichState = {
|
|
|
21
17
|
refs: MessageRef[];
|
|
22
18
|
before: string;
|
|
23
19
|
};
|
|
24
|
-
/** The document as the plain text the chat stores (exported for the round-trip tests). */
|
|
25
20
|
export declare const toText: (doc: PmNode) => string;
|
|
26
21
|
export declare const asContent: (text: string, refs?: MessageRef[]) => JSONContent[];
|
|
27
22
|
export declare const hasChips: (text: string, refs?: MessageRef[]) => boolean;
|
|
28
|
-
/** Stored text as the editor's blocks: the reverse of toText. */
|
|
29
23
|
export declare const toBlocks: (text: string, refs?: MessageRef[]) => JSONContent[];
|
|
30
|
-
/** The editor's building blocks (also how the tests build its schema without a browser). */
|
|
31
24
|
export declare const richExtensions: () => (Node<import("@tiptap/extension-code-block").CodeBlockOptions, any> | Node<any, any> | import("@tiptap/core").Extension<import("@tiptap/starter-kit").StarterKitOptions, any>)[];
|
|
32
25
|
type Props = {
|
|
33
26
|
placeholder: string;
|
|
34
27
|
onChange: (state: RichState) => void;
|
|
35
28
|
onKey: (e: KeyboardEvent) => boolean;
|
|
36
29
|
onPasteFiles?: (files: FileList) => void;
|
|
37
|
-
/** Teammates to tint when named (a note); empty for a reply. */
|
|
38
30
|
mentions?: string[];
|
|
39
31
|
};
|
|
40
32
|
export declare const RichInput: import("react").ForwardRefExoticComponent<Props & import("react").RefAttributes<RichHandle>>;
|
package/dist/src/appearance.d.ts
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import type { i18n as I18n } from "i18next";
|
|
2
2
|
import { type Appearance } from "@whoa-chat/core/appearance";
|
|
3
3
|
import type { AppLinks } from "@whoa-chat/core/links";
|
|
4
|
-
/** Lays the workspace's reworded texts over the chat's strings, once per i18n instance and text. Only those keys change. */
|
|
5
4
|
export declare const applyAppearanceTexts: (i18n: I18n, texts: Appearance["texts"]) => void;
|
|
6
|
-
/** The chat's style for the workspace's colours in the merchant's view: no class and no variables when none are set. */
|
|
7
5
|
export declare const useAppearance: (i18n: I18n, merchantView: boolean) => {
|
|
8
6
|
className: string;
|
|
9
7
|
style: import("react").CSSProperties | undefined;
|
|
10
8
|
};
|
|
11
|
-
/** For hosts: fetch the workspace's appearance through the merchant API and hand it to the chat; failures change nothing. */
|
|
12
9
|
export declare const loadMerchantAppearance: (api: {
|
|
13
10
|
appearance: () => Promise<Appearance & {
|
|
14
11
|
brand?: unknown;
|
package/dist/src/chatApi.d.ts
CHANGED
|
@@ -134,13 +134,9 @@ export type ApiThread = {
|
|
|
134
134
|
agentDeliveredAt?: string;
|
|
135
135
|
lastMessageAt?: string;
|
|
136
136
|
};
|
|
137
|
-
/** cards: whether order, subscription and offer previews can load where this is drawn. */
|
|
138
137
|
export declare const toView: (m: ApiMessage, { cards }: {
|
|
139
138
|
cards: boolean;
|
|
140
139
|
}) => SupportMessageView;
|
|
141
|
-
/** The merchant's side, signed with the App Bridge session token on every call (the shop comes from it, never the body). */
|
|
142
|
-
/** A token getter for merchantChatApi and useLive from the host's own endpoint that returns a fresh merchant token
|
|
143
|
-
* (@whoa-chat/connector signMerchant): kept until five minutes before it expires, then fetched again. */
|
|
144
140
|
export declare const cachedMerchantToken: (fetchToken: () => Promise<string>) => () => Promise<string>;
|
|
145
141
|
export declare const merchantChatApi: (base: string, token: () => Promise<string>) => {
|
|
146
142
|
thread: (peek: boolean) => Promise<{
|
package/dist/src/chatEnv.d.ts
CHANGED
|
@@ -12,5 +12,4 @@ export declare const useChatEnv: () => ChatEnv | null;
|
|
|
12
12
|
export declare const LinkNamesContext: import("react").Context<Record<string, string> | undefined>;
|
|
13
13
|
export declare const useLinkNames: () => Record<string, string> | undefined;
|
|
14
14
|
export declare const OpenedLinksContext: import("react").Context<Map<string, string> | null>;
|
|
15
|
-
/** When this link was opened, as words for its hover; null when it was not. */
|
|
16
15
|
export declare const useOpened: (url: string) => string | null;
|
package/dist/src/chime.d.ts
CHANGED
|
@@ -3,5 +3,4 @@ export declare const setSoundOn: (on: boolean) => void;
|
|
|
3
3
|
export declare const setChimeLevel: (l: "soft" | "loud") => void;
|
|
4
4
|
export declare const chime: () => void;
|
|
5
5
|
export declare const visitChime: () => void;
|
|
6
|
-
/** Chimes when `key` (the newest message from the other side) changes, but not for what was already there on load. */
|
|
7
6
|
export declare const useChime: (key: string | null, loaded: boolean) => void;
|
package/dist/src/clock.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export type ClockPref = "auto" | "12" | "24";
|
|
2
2
|
export declare const clockPref: () => ClockPref;
|
|
3
3
|
export declare const setClockPref: (pref: ClockPref) => void;
|
|
4
|
-
/** Options for a time of day in the chosen format ("3:05 PM" or "15:05"), plus any date parts. */
|
|
5
4
|
export declare const timeOpts: (extra?: Intl.DateTimeFormatOptions) => Intl.DateTimeFormatOptions;
|
|
@@ -1,10 +1 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copy text to the clipboard from inside the embedded admin.
|
|
3
|
-
*
|
|
4
|
-
* `navigator.clipboard` is refused in the app's iframe on some browsers (the
|
|
5
|
-
* Clipboard API needs a permissions grant the admin does not always hand down)
|
|
6
|
-
* and it rejects rather than falling back, so a copy button that only calls it
|
|
7
|
-
* reports a failure every time. The textarea and `execCommand` route still
|
|
8
|
-
* works there.
|
|
9
|
-
*/
|
|
10
1
|
export declare const copyToClipboard: (text: string) => Promise<boolean>;
|
package/dist/src/host.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export type HostTier = {
|
|
|
7
7
|
upToUsd: number | null;
|
|
8
8
|
priceUsd: number;
|
|
9
9
|
annualPriceUsd: number;
|
|
10
|
+
custom?: boolean;
|
|
10
11
|
};
|
|
11
12
|
export type ChatHost = {
|
|
12
13
|
priceBook: (id: string | null | undefined) => {
|
|
@@ -16,19 +17,13 @@ export type ChatHost = {
|
|
|
16
17
|
key: string;
|
|
17
18
|
label: string;
|
|
18
19
|
}[];
|
|
19
|
-
/** The workspace's names (app, team, AI) and icon, as merchants see them. */
|
|
20
20
|
brand: Brand;
|
|
21
|
-
/** The workspace's colours and reworded texts (Customize page); unset: the chat as built. */
|
|
22
21
|
appearance?: Appearance;
|
|
23
|
-
/** The team's photos by the name they write as (null: initials). The inbox's list and the merchant's thread fill it. */
|
|
24
22
|
team?: Record<string, string | null>;
|
|
25
|
-
/** Each app's admin pages as link badges name them (Settings, per app); a link to an app not listed reads its path. */
|
|
26
23
|
appLinks?: AppLinks[];
|
|
27
24
|
};
|
|
28
|
-
/** Call once at startup, before the chat renders. */
|
|
29
25
|
export declare const setChatHost: (next: Partial<ChatHost>) => void;
|
|
30
26
|
export declare const chatHost: () => ChatHost;
|
|
31
|
-
/** The brand's names for the strings that say them ({{app}}, {{appFull}}, {{team}}, {{bot}}, {{botFull}}). */
|
|
32
27
|
export declare const brandVars: () => {
|
|
33
28
|
app: string;
|
|
34
29
|
appFull: string;
|
|
@@ -36,5 +31,4 @@ export declare const brandVars: () => {
|
|
|
36
31
|
bot: string;
|
|
37
32
|
botFull: string;
|
|
38
33
|
};
|
|
39
|
-
/** Whether a message's author is the workspace's AI (its short name, or the longer one older replies were saved with). */
|
|
40
34
|
export declare const isBotName: (name: string | null | undefined) => boolean;
|
package/dist/src/refLinks.d.ts
CHANGED
|
@@ -3,5 +3,4 @@ export declare const splitRefs: (text: string, link: RefLink) => {
|
|
|
3
3
|
text: string;
|
|
4
4
|
href?: string;
|
|
5
5
|
}[];
|
|
6
|
-
/** The support app's page for a ref, switched to the store; supportUrl is the embedded app's base (…/apps/<id>/app). */
|
|
7
6
|
export declare const supportAppRefLink: (supportUrl: string | undefined, shop: string) => RefLink;
|