@whoa-chat/react 0.2.0 → 0.3.0

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.
@@ -51,6 +51,8 @@
51
51
  "deletedBy": "Borttaget av {{name}}",
52
52
  "undoDelete": "Ångra",
53
53
  "newBelow": "Nya meddelanden",
54
+ "linkClicked_one": "Klickad {{time}}",
55
+ "linkClicked_other": "Klickad {{count}} gånger, först {{time}}",
54
56
  "linkOpened_one": "Länk öppnad {{time}}",
55
57
  "linkOpened_other": "{{count}} länkklick, först {{time}}"
56
58
  },
@@ -233,6 +235,15 @@
233
235
  "now": "nu",
234
236
  "summary": "{{now}} i appen nu, {{total}} de senaste 10 minuterna"
235
237
  },
238
+ "transcript": {
239
+ "button": "Mejla mig en utskrift",
240
+ "about": "Vi mejlar dig en länk för att ladda ner den här konversationen.",
241
+ "send": "Skicka",
242
+ "sending": "Skickar...",
243
+ "sent": "Skickat till {{to}}. Länken fungerar i 30 dagar.",
244
+ "noEmail": "Vi har inte din e-postadress än. Fråga oss i chatten så skickar vi den.",
245
+ "failed": "Det fungerade inte. Försök igen om en minut."
246
+ },
236
247
  "menu": {
237
248
  "camera": "Kamera",
238
249
  "files": "Bilder och filer",
@@ -51,6 +51,8 @@
51
51
  "deletedBy": "已被 {{name}} 删除",
52
52
  "undoDelete": "撤销",
53
53
  "newBelow": "新消息",
54
+ "linkClicked_one": "已点击 {{time}}",
55
+ "linkClicked_other": "已点击 {{count}} 次,首次 {{time}}",
54
56
  "linkOpened_one": "已打开链接 {{time}}",
55
57
  "linkOpened_other": "链接点击 {{count}} 次,首次 {{time}}"
56
58
  },
@@ -233,6 +235,15 @@
233
235
  "now": "现在",
234
236
  "summary": "当前 {{now}} 个在应用中,过去 10 分钟内共 {{total}} 个"
235
237
  },
238
+ "transcript": {
239
+ "button": "通过邮件发送对话记录",
240
+ "about": "我们会通过邮件发送一个链接,供你下载这段对话。",
241
+ "send": "发送",
242
+ "sending": "正在发送...",
243
+ "sent": "已发送至 {{to}}。链接 30 天内有效。",
244
+ "noEmail": "我们还没有你的邮箱地址。在聊天中告诉我们,我们会发送给你。",
245
+ "failed": "发送失败。请一分钟后再试。"
246
+ },
236
247
  "menu": {
237
248
  "camera": "相机",
238
249
  "files": "照片和文件",
@@ -51,6 +51,8 @@
51
51
  "deletedBy": "已被 {{name}} 刪除",
52
52
  "undoDelete": "復原",
53
53
  "newBelow": "新訊息",
54
+ "linkClicked_one": "已點擊 {{time}}",
55
+ "linkClicked_other": "已點擊 {{count}} 次,首次 {{time}}",
54
56
  "linkOpened_one": "已開啟連結 {{time}}",
55
57
  "linkOpened_other": "連結點擊 {{count}} 次,首次 {{time}}"
56
58
  },
@@ -233,6 +235,15 @@
233
235
  "now": "現在",
234
236
  "summary": "目前 {{now}} 個在應用程式中,過去 10 分鐘內共 {{total}} 個"
235
237
  },
238
+ "transcript": {
239
+ "button": "透過電子郵件寄送對話記錄",
240
+ "about": "我們會寄一封含下載連結的電子郵件給你,讓你下載這段對話。",
241
+ "send": "寄送",
242
+ "sending": "正在寄送...",
243
+ "sent": "已寄送至 {{to}}。連結 30 天內有效。",
244
+ "noEmail": "我們還沒有你的電子郵件地址。請在聊天中告訴我們,我們會寄給你。",
245
+ "failed": "寄送失敗。請一分鐘後再試。"
246
+ },
236
247
  "menu": {
237
248
  "camera": "相機",
238
249
  "files": "照片和檔案",
@@ -1 +1 @@
1
- import{Fragment as w,jsx as n,jsxs as s}from"react/jsx-runtime";import{useEffect as k,useState as p}from"react";const f={shop_overview:{now:"Looking at the store",done:"Looked at the store",icon:"store"},check_store_setup:{now:"Checking the store setup",done:"Checked the store setup",icon:"search"},get_subscription:{now:"Opening a subscription",done:"Opened a subscription",icon:"doc"},search_subscriptions:{now:"Searching subscriptions",done:"Searched subscriptions",icon:"search"},get_billing_issues:{now:"Checking billing issues",done:"Checked billing issues",icon:"search"},bundle_config:{now:"Reading the bundle setup",done:"Read the bundle setup",icon:"doc"},get_offer:{now:"Opening an offer",done:"Opened an offer",icon:"doc"},search_offers:{now:"Searching offers",done:"Searched offers",icon:"search"},get_offer_performance:{now:"Checking offer performance",done:"Checked offer performance",icon:"chart"},get_subscription_metrics:{now:"Checking subscription numbers",done:"Checked subscription numbers",icon:"chart"},get_retention_insights:{now:"Checking retention",done:"Checked retention",icon:"chart"},search_loyalty_programs:{now:"Searching loyalty programs",done:"Searched loyalty programs",icon:"search"},product_facts:{now:"Checking a product",done:"Checked a product",icon:"search"},storefront_errors:{now:"Checking storefront errors",done:"Checked storefront errors",icon:"search"},search_help_center:{now:"Searching the help center",done:"Searched the help center",icon:"search"},get_help_article:{now:"Reading a help article",done:"Read a help article",icon:"doc"},admin_links:{now:"Finding admin links",done:"Found admin links",icon:"link"},setting_link:{now:"Finding a settings link",done:"Found a settings link",icon:"link"}},u=e=>f[e]??{now:e.replace(/_/g," "),done:e.replace(/_/g," "),icon:"search"},g={search:"M9 15a6 6 0 1 0 0-12 6 6 0 0 0 0 12zM13.5 13.5 17 17",store:"M3.5 8 5 3.5h10L16.5 8M3.5 8a2.2 2.2 0 0 0 4.4 0 2.1 2.1 0 0 0 4.2 0 2.2 2.2 0 0 0 4.4 0M5 10.5V16.5h10v-6",doc:"M5.5 2.5h6l3.5 3.5v11h-9.5zM11.5 2.5V6H15M8 10h5M8 13h5",link:"M8.5 11.5l3-3M7 9 5.5 10.5a2.5 2.5 0 0 0 3.5 3.5L10.5 12.5M13 11l1.5-1.5a2.5 2.5 0 0 0-3.5-3.5L9.5 7.5",chart:"M3.5 16.5h13M6 13.5V9M10 13.5V5.5M14 13.5v-3"},m=({kind:e})=>n("svg",{viewBox:"0 0 20 20",width:"15",height:"15","aria-hidden":!0,children:n("path",{d:g[e]??g.search,fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})}),b=({step:e,detail:i})=>{const[r,a]=p(!1),o=u(e.tool),c=e.status==="running"?`${o.now}...`:e.status==="error"?`${o.now} (could not)`:o.done,d=s(w,{children:[e.status==="running"?n("i",{className:"ai-spin","aria-hidden":!0}):n(m,{kind:o.icon}),n("span",{children:c})]});return s("li",{className:`ai-step ai-step--${e.status}`,children:[i?n("button",{type:"button",className:"ai-step-row","aria-expanded":r,onClick:()=>a(l=>!l),children:d}):n("div",{className:"ai-step-row",children:d}),i&&r&&s("div",{className:"ai-step-detail",children:[n("code",{className:"ai-step-tool",children:e.tool}),n("span",{children:"Asked"}),n("pre",{children:e.input||"{}"}),e.output!==void 0&&s(w,{children:[n("span",{children:"Got"}),n("pre",{children:e.output||"(nothing)"})]})]})]})},_=(e,i)=>{const[r,a]=p(()=>Date.now());return k(()=>{if(!i)return;const o=window.setInterval(()=>a(Date.now()),1e3);return()=>window.clearInterval(o)},[i]),e?Math.max(0,Math.round((r-Date.parse(e))/1e3)):null},M=({run:e,detail:i=!1,since:r})=>{const[a,o]=p(!1),c=e.status==="running",d=_(r,c);if(!c&&!e.steps.length)return null;const l=e.steps.filter(t=>t.status!=="running").length,h=[...e.steps].reverse().find(t=>t.status==="running");return s("div",{className:"ai-steps-wrap",children:[c?s("div",{className:"ai-toggle ai-toggle--live",role:"status",children:[n("span",{className:"ai-shimmer",children:h?u(h.tool).now:e.steps.length?"Writing an answer":"Looking into it"}),d!==null&&s("span",{className:"ai-seconds",children:[d,"s"]})]}):s("button",{type:"button",className:"ai-toggle","aria-expanded":a,onClick:()=>o(t=>!t),children:[n("svg",{viewBox:"0 0 20 20",width:"14",height:"14","aria-hidden":!0,children:n("path",{d:"M5 10.5l3.2 3.2L15 7",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"})}),l===1?"1 step completed":`${l} steps completed`,n("svg",{className:"ai-toggle-caret",viewBox:"0 0 20 20",width:"12",height:"12","aria-hidden":!0,children:n("path",{d:"M6 8l4 4 4-4",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"})})]}),(a||c)&&e.steps.length>0&&n("ul",{className:"ai-steps",children:e.steps.map(t=>n(b,{step:t,detail:i},t.id))})]})};export{M as AiSteps};
1
+ import{Fragment as k,jsx as o,jsxs as c}from"react/jsx-runtime";import{useEffect as m,useState as h}from"react";const b={shop_overview:{now:"Looking at the store",done:"Looked at the store",icon:"store"},check_store_setup:{now:"Checking the store setup",done:"Checked the store setup",icon:"search"},get_subscription:{now:"Opening a subscription",done:"Opened a subscription",icon:"doc"},search_subscriptions:{now:"Searching subscriptions",done:"Searched subscriptions",icon:"search"},get_billing_issues:{now:"Checking billing issues",done:"Checked billing issues",icon:"search"},bundle_config:{now:"Reading the bundle setup",done:"Read the bundle setup",icon:"doc"},get_offer:{now:"Opening an offer",done:"Opened an offer",icon:"doc"},search_offers:{now:"Searching offers",done:"Searched offers",icon:"search"},get_offer_performance:{now:"Checking offer performance",done:"Checked offer performance",icon:"chart"},get_subscription_metrics:{now:"Checking subscription numbers",done:"Checked subscription numbers",icon:"chart"},get_retention_insights:{now:"Checking retention",done:"Checked retention",icon:"chart"},search_loyalty_programs:{now:"Searching loyalty programs",done:"Searched loyalty programs",icon:"search"},product_facts:{now:"Checking a product",done:"Checked a product",icon:"search"},storefront_errors:{now:"Checking storefront errors",done:"Checked storefront errors",icon:"search"},search_help_center:{now:"Searching the help center",done:"Searched the help center",icon:"search"},get_help_article:{now:"Reading a help article",done:"Read a help article",icon:"doc"},admin_links:{now:"Finding admin links",done:"Found admin links",icon:"link"},setting_link:{now:"Finding a settings link",done:"Found a settings link",icon:"link"}},v={get:["Getting","Got"],fetch:["Getting","Got"],read:["Reading","Read"],list:["Listing","Listed"],search:["Searching","Searched"],find:["Finding","Found"],lookup:["Looking up","Looked up"],check:["Checking","Checked"],count:["Counting","Counted"],create:["Creating","Created"],update:["Updating","Updated"],verify:["Verifying","Verified"],open:["Opening","Opened"],load:["Loading","Loaded"]},_=e=>{const t=e.replace(/^.*__/,"").split(/[_\s-]+/).filter(Boolean).map(r=>r.toLowerCase()),n=v[t[0]],s=(n?t.slice(1):t).join(" "),i=s?n?`the ${s}`:s:"";return{now:n?`${n[0]} ${i}`.trim():`Using ${i}`,done:n?`${n[1]} ${i}`.trim():`Used ${i}`,icon:"search"}},g=e=>b[e]??_(e),u=e=>{if(!e)return null;try{const t=JSON.parse(e),n=[t.query,t.q,t.search,t.title,t.term].find(s=>typeof s=="string"&&s.trim());return n?n.trim().length>42?`${n.trim().slice(0,40)}...`:n.trim():null}catch{return null}},f=e=>{const t=g(e.tool),n=u(e.input);return n?`${t.now} for "${n}"`:t.now},w={search:"M9 15a6 6 0 1 0 0-12 6 6 0 0 0 0 12zM13.5 13.5 17 17",store:"M3.5 8 5 3.5h10L16.5 8M3.5 8a2.2 2.2 0 0 0 4.4 0 2.1 2.1 0 0 0 4.2 0 2.2 2.2 0 0 0 4.4 0M5 10.5V16.5h10v-6",doc:"M5.5 2.5h6l3.5 3.5v11h-9.5zM11.5 2.5V6H15M8 10h5M8 13h5",link:"M8.5 11.5l3-3M7 9 5.5 10.5a2.5 2.5 0 0 0 3.5 3.5L10.5 12.5M13 11l1.5-1.5a2.5 2.5 0 0 0-3.5-3.5L9.5 7.5",chart:"M3.5 16.5h13M6 13.5V9M10 13.5V5.5M14 13.5v-3"},C=({kind:e})=>o("svg",{viewBox:"0 0 20 20",width:"15",height:"15","aria-hidden":!0,children:o("path",{d:w[e]??w.search,fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})}),S=({step:e,detail:t})=>{const[n,s]=h(!1),i=g(e.tool),r=u(e.input),p=e.status==="running"?`${f(e)}...`:e.status==="error"?`${i.now} (could not)`:r?`${i.done}: "${r}"`:i.done,d=c(k,{children:[e.status==="running"?o("i",{className:"ai-spin","aria-hidden":!0}):o(C,{kind:i.icon}),o("span",{children:p})]});return c("li",{className:`ai-step ai-step--${e.status}`,children:[t?o("button",{type:"button",className:"ai-step-row","aria-expanded":n,onClick:()=>s(l=>!l),children:d}):o("div",{className:"ai-step-row",children:d}),t&&n&&c("div",{className:"ai-step-detail",children:[o("code",{className:"ai-step-tool",children:e.tool}),o("span",{children:"Asked"}),o("pre",{children:e.input||"{}"}),e.output!==void 0&&c(k,{children:[o("span",{children:"Got"}),o("pre",{children:e.output||"(nothing)"})]})]})]})},L=(e,t)=>{const[n,s]=h(()=>Date.now());return m(()=>{if(!t)return;const i=window.setInterval(()=>s(Date.now()),1e3);return()=>window.clearInterval(i)},[t]),e?Math.max(0,Math.round((n-Date.parse(e))/1e3)):null},y=({run:e,detail:t=!1,since:n})=>{const[s,i]=h(!1),r=e.status==="running",p=L(n,r);if(!r&&!e.steps.length)return null;const d=e.steps.filter(a=>a.status!=="running").length,l=[...e.steps].reverse().find(a=>a.status==="running");return c("div",{className:"ai-steps-wrap",children:[r?c("div",{className:"ai-toggle ai-toggle--live",role:"status",children:[o("span",{className:"ai-shimmer",children:l?f(l):e.steps.length?"Writing an answer":"Looking into it"},l?.id??e.steps.length),p!==null&&c("span",{className:"ai-seconds",children:[p,"s"]})]}):c("button",{type:"button",className:"ai-toggle","aria-expanded":s,onClick:()=>i(a=>!a),children:[o("svg",{viewBox:"0 0 20 20",width:"14",height:"14","aria-hidden":!0,children:o("path",{d:"M5 10.5l3.2 3.2L15 7",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"})}),d===1?"1 step completed":`${d} steps completed`,o("svg",{className:"ai-toggle-caret",viewBox:"0 0 20 20",width:"12",height:"12","aria-hidden":!0,children:o("path",{d:"M6 8l4 4 4-4",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"})})]}),(s||r)&&e.steps.length>0&&o("ul",{className:"ai-steps",children:e.steps.map(a=>o(S,{step:a,detail:t},a.id))})]})};export{y as AiSteps};
@@ -1,8 +1,8 @@
1
- import{Fragment as k,jsx as s,jsxs as o}from"react/jsx-runtime";import{Fragment as He,useEffect as T,useLayoutEffect as Hn,useRef as y,useState as f}from"react";import{mentionsIn as Ps,noteTarget as Es,splitMentions as zn,typingMention as Is}from"@whoa-chat/core/mentions";import{ALLOWED_TYPES as ze,fileTypeOf as Bs,maxBytesFor as Fs,maxLabelFor as js}from"@whoa-chat/core/fileTypes";import{InlineImage as Hs,MediaProvider as zs,MessageFiles as Wn,PendingFiles as Ws}from"./Attachments.js";import{AvailabilityCard as Vs,AwayBar as Vn,OnlineBar as qs}from"./AvailabilityCard.js";import{HelpOfferCard as _s,VerifiedIcon as Ks}from"./HelpOfferCard.js";import{PasswordCard as Gs}from"./PasswordCard.js";import{FeatureRequestCard as Zs,TicketCard as Qs}from"./RequestCards.js";import{CardOutcome as Us}from"./CardOutcome.js";import{EmojiPicker as Ys,LinkPicker as Js}from"./ComposerTools.js";import{useTranslation as Xs}from"./i18n.js";import{TEAM_FLAG as We,languageFlag as qn,languageName as _n}from"./flags.js";import{FILE_IMG as ta,FormattedText as Ve,inlineFileIds as ea}from"./FormattedText.js";import{isUrl as na,linkToken as qe}from"@whoa-chat/core/links";import{splitRefs as sa}from"./refLinks.js";import{RichInput as aa}from"./RichInput.js";import{AiSteps as ra}from"./AssistantNote.js";import{AiChoices as oa,AiProgress as ia}from"./AiChoices.js";import{MessageActions as _e}from"./MessageActions.js";import{ActionGroup as la}from"./ActionGroup.js";import{EventRow as ca}from"./EventRow.js";import{DraftCard as da}from"./DraftCard.js";import{StoreAvatar as ua}from"./StoreAvatar.js";import{AgentAvatar as Ct}from"./agents.js";import{ReviewCard as pa}from"./ReviewCard.js";import{CustomCard as ga}from"./CustomCard.js";import{ChatEnvProvider as Kn,DeepLinkCard as ma,Mention as ha,MessageWithReferences as fa,PricingCard as ka,ReferenceCard as Gn}from"./RichCards.js";import{timeOpts as ba}from"./clock.js";import{LinkNamesContext as ya,OpenedLinksContext as va}from"./chatEnv.js";import{useAppearance as Ca}from"./appearance.js";import{brandVars as $a,chatHost as Zn}from"./host.js";const It=({viewer:p,message:c,children:it})=>p==="agent"?s(Us,{message:c,children:it}):s(k,{children:it}),Y=p=>new Date(p).toDateString(),te=({d:p})=>s("svg",{viewBox:"0 0 20 20",width:"20",height:"20","aria-hidden":!0,children:s("path",{d:p,fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})}),F=p=>new Date(p).toLocaleTimeString([],ba()),Na=30*6e4,Qn=(p,c)=>c==="agent"&&p.translation&&p.from==="merchant"?{kind:"from",lang:p.translation.from,main:p.translation.text,alt:p.body}:c==="agent"&&p.translation&&p.from==="agent"?{kind:"to",lang:p.translation.to,main:p.body,alt:p.translation.text}:c==="merchant"&&p.original?{kind:"merchant",lang:p.original.lang,main:p.body,alt:p.original.body}:null,Ke=(p,c,it)=>{const $t=Qn(p,c);return $t?it?$t.alt:$t.main:p.body},sr=({messages:p,viewer:c,shopOwnerName:it,listing:$t,onSend:Ge,onReviewState:Un,sending:Yn,previewUrl:ee,open:Jn,agents:K=[],onSendNote:Bt,onDraft:Nt,uploadUrl:Ze,uploadFields:Qe,fileUrl:z,uploadFile:Ft,pickGif:ne,fetchFile:jt,availability:G,shortcuts:lt=[],onSendCard:se,composerTop:ae=null,composerFill:wt=null,onComposerEscape:Ue,composerSend:M=null,shortcutVars:Xn={},gifSearchUrl:re,gifPickUrl:oe,otherReadAt:xt=null,otherDeliveredAt:Ye=null,emailedAt:Je=null,email:ie=null,menu:Ht,plusOnDesktop:ts,me:W=null,merchantCountry:Xe=null,rich:S=!1,onDraftChange:tn,typingNow:C=null,onEdit:ct,onDelete:J,onRestore:en,onSaveReply:wa,onSlash:nn,onReact:dt,visitorCta:es=!1,onResendEmail:sn,searchRefs:ut,linkShortcuts:pt,onTrack:Mt,onAddFeature:an,actions:le=null,store:X,onActionsBefore:ce,actionsStatus:rn=null,refLink:on,linkNames:ns})=>{const{t:r,i18n:de}=Xs("home"),ss=t=>{const n=new Map,a=(t.clicks??[]).filter(i=>i.action==="link"&&/^https?:/.test(i.detail??""));for(const i of a){const e=a.filter(l=>l.detail===i.detail);n.has(i.detail)||n.set(i.detail,r("supportChat.msg.linkOpened",{time:F(e[0].at),count:e.length}))}return n},ln=Ca(de,c==="merchant"),cn=(t,n)=>on?sa(t,on).map((a,i)=>a.href?s("a",{href:a.href,target:"_blank",rel:"noopener noreferrer",children:a.text},`${n}-r${i}`):s(He,{children:a.text},`${n}-r${i}`)):t,[g,A]=f(""),[D,zt]=f(null),[L,ue]=f(null),[Lt,pe]=f(null),[dn,ge]=f([]),Wt=t=>{ge(i=>i.some(e=>e.key===t.key)?i.map(e=>e.key===t.key?{...t,status:"sending"}:e):[...i,t]);const n=t.card&&se?se(t.card):t.note&&Bt?Bt(t.body,t.files,t.replyTo):Ge(t.body,t.files,t.refs,t.replyTo),a=()=>ge(i=>i.filter(e=>e.key!==t.key));if(!n)return a();n.then(a,()=>ge(i=>i.map(e=>e.key===t.key?{...e,status:"failed"}:e)))},as=t=>Number(t.key.split("-")[0])||0,rs=t=>!t.card&&!!t.body&&p.some(n=>n.from===c&&n.kind==="note"===t.note&&n.body?.trim()===t.body.trim()&&Date.parse(n.at)>=as(t)-12e4),[Rt,os]=f(()=>new Set),is=t=>os(n=>{const a=new Set(n);return a.delete(t)||a.add(t),a}),Vt=y(null),[me,ls]=f(!1),he=y(null),qt=t=>{const n=Vt.current;n&&t!==me&&(he.current=new Map([n,...Array.from(n.children)].map(a=>[a,a.getBoundingClientRect()]))),ls(t)},un=y(qt);un.current=qt,T(()=>{g?g.includes(`
1
+ import{Fragment as k,jsx as s,jsxs as o}from"react/jsx-runtime";import{Fragment as He,useEffect as T,useLayoutEffect as Hn,useRef as y,useState as f}from"react";import{mentionsIn as Ps,noteTarget as Es,splitMentions as zn,typingMention as Is}from"@whoa-chat/core/mentions";import{ALLOWED_TYPES as ze,fileTypeOf as Bs,maxBytesFor as Fs,maxLabelFor as js}from"@whoa-chat/core/fileTypes";import{InlineImage as Hs,MediaProvider as zs,MessageFiles as Wn,PendingFiles as Ws}from"./Attachments.js";import{AvailabilityCard as Vs,AwayBar as Vn,OnlineBar as qs}from"./AvailabilityCard.js";import{HelpOfferCard as _s,VerifiedIcon as Ks}from"./HelpOfferCard.js";import{PasswordCard as Gs}from"./PasswordCard.js";import{FeatureRequestCard as Zs,TicketCard as Qs}from"./RequestCards.js";import{CardOutcome as Us}from"./CardOutcome.js";import{EmojiPicker as Ys,LinkPicker as Js}from"./ComposerTools.js";import{useTranslation as Xs}from"./i18n.js";import{TEAM_FLAG as We,languageFlag as qn,languageName as _n}from"./flags.js";import{FILE_IMG as ta,FormattedText as Ve,inlineFileIds as ea}from"./FormattedText.js";import{isUrl as na,linkToken as qe}from"@whoa-chat/core/links";import{splitRefs as sa}from"./refLinks.js";import{RichInput as aa}from"./RichInput.js";import{AiSteps as ra}from"./AssistantNote.js";import{AiChoices as oa,AiProgress as ia}from"./AiChoices.js";import{MessageActions as _e}from"./MessageActions.js";import{ActionGroup as la}from"./ActionGroup.js";import{EventRow as ca}from"./EventRow.js";import{DraftCard as da}from"./DraftCard.js";import{StoreAvatar as ua}from"./StoreAvatar.js";import{AgentAvatar as Ct}from"./agents.js";import{ReviewCard as pa}from"./ReviewCard.js";import{CustomCard as ga}from"./CustomCard.js";import{ChatEnvProvider as Kn,DeepLinkCard as ma,Mention as ha,MessageWithReferences as fa,PricingCard as ka,ReferenceCard as Gn}from"./RichCards.js";import{timeOpts as ba}from"./clock.js";import{LinkNamesContext as ya,OpenedLinksContext as va}from"./chatEnv.js";import{useAppearance as Ca}from"./appearance.js";import{brandVars as $a,chatHost as Zn}from"./host.js";const It=({viewer:p,message:c,children:it})=>p==="agent"?s(Us,{message:c,children:it}):s(k,{children:it}),Y=p=>new Date(p).toDateString(),te=({d:p})=>s("svg",{viewBox:"0 0 20 20",width:"20",height:"20","aria-hidden":!0,children:s("path",{d:p,fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})}),F=p=>new Date(p).toLocaleTimeString([],ba()),Na=30*6e4,Qn=(p,c)=>c==="agent"&&p.translation&&p.from==="merchant"?{kind:"from",lang:p.translation.from,main:p.translation.text,alt:p.body}:c==="agent"&&p.translation&&p.from==="agent"?{kind:"to",lang:p.translation.to,main:p.body,alt:p.translation.text}:c==="merchant"&&p.original?{kind:"merchant",lang:p.original.lang,main:p.body,alt:p.original.body}:null,Ke=(p,c,it)=>{const $t=Qn(p,c);return $t?it?$t.alt:$t.main:p.body},sr=({messages:p,viewer:c,shopOwnerName:it,listing:$t,onSend:Ge,onReviewState:Un,sending:Yn,previewUrl:ee,open:Jn,agents:K=[],onSendNote:Bt,onDraft:Nt,uploadUrl:Ze,uploadFields:Qe,fileUrl:z,uploadFile:Ft,pickGif:ne,fetchFile:jt,availability:G,shortcuts:lt=[],onSendCard:se,composerTop:ae=null,composerFill:wt=null,onComposerEscape:Ue,composerSend:M=null,shortcutVars:Xn={},gifSearchUrl:re,gifPickUrl:oe,otherReadAt:xt=null,otherDeliveredAt:Ye=null,emailedAt:Je=null,email:ie=null,menu:Ht,plusOnDesktop:ts,me:W=null,merchantCountry:Xe=null,rich:S=!1,onDraftChange:tn,typingNow:C=null,onEdit:ct,onDelete:J,onRestore:en,onSaveReply:wa,onSlash:nn,onReact:dt,visitorCta:es=!1,onResendEmail:sn,searchRefs:ut,linkShortcuts:pt,onTrack:Mt,onAddFeature:an,actions:le=null,store:X,onActionsBefore:ce,actionsStatus:rn=null,refLink:on,linkNames:ns})=>{const{t:r,i18n:de}=Xs("home"),ss=t=>{const n=new Map,a=(t.clicks??[]).filter(i=>i.action==="link"&&/^https?:/.test(i.detail??""));for(const i of a){const e=a.filter(l=>l.detail===i.detail);n.has(i.detail)||n.set(i.detail,r("supportChat.msg.linkClicked",{time:F(e[0].at),count:e.length}))}return n},ln=Ca(de,c==="merchant"),cn=(t,n)=>on?sa(t,on).map((a,i)=>a.href?s("a",{href:a.href,target:"_blank",rel:"noopener noreferrer",children:a.text},`${n}-r${i}`):s(He,{children:a.text},`${n}-r${i}`)):t,[g,A]=f(""),[D,zt]=f(null),[L,ue]=f(null),[Lt,pe]=f(null),[dn,ge]=f([]),Wt=t=>{ge(i=>i.some(e=>e.key===t.key)?i.map(e=>e.key===t.key?{...t,status:"sending"}:e):[...i,t]);const n=t.card&&se?se(t.card):t.note&&Bt?Bt(t.body,t.files,t.replyTo):Ge(t.body,t.files,t.refs,t.replyTo),a=()=>ge(i=>i.filter(e=>e.key!==t.key));if(!n)return a();n.then(a,()=>ge(i=>i.map(e=>e.key===t.key?{...e,status:"failed"}:e)))},as=t=>Number(t.key.split("-")[0])||0,rs=t=>!t.card&&!!t.body&&p.some(n=>n.from===c&&n.kind==="note"===t.note&&n.body?.trim()===t.body.trim()&&Date.parse(n.at)>=as(t)-12e4),[Rt,os]=f(()=>new Set),is=t=>os(n=>{const a=new Set(n);return a.delete(t)||a.add(t),a}),Vt=y(null),[me,ls]=f(!1),he=y(null),qt=t=>{const n=Vt.current;n&&t!==me&&(he.current=new Map([n,...Array.from(n.children)].map(a=>[a,a.getBoundingClientRect()]))),ls(t)},un=y(qt);un.current=qt,T(()=>{g?g.includes(`
2
2
  `)&&qt(!0):qt(!1)},[g]),T(()=>{const t=Vt.current;if(!t||typeof ResizeObserver>"u")return;const n=new ResizeObserver(()=>{const a=t.querySelector(".sc-rich-input, textarea");a&&a.scrollHeight>44&&un.current(!0)});return n.observe(t),()=>n.disconnect()},[]),Hn(()=>{const t=he.current;he.current=null;const n=Vt.current;if(!t||!n||window.matchMedia("(prefers-reduced-motion: reduce)").matches)return;const a={duration:220,easing:"cubic-bezier(0.2, 0.8, 0.2, 1)"};for(const[i,e]of t){if(!i.isConnected)continue;const l=i.getBoundingClientRect();if(i===n){Math.abs(e.height-l.height)>1&&n.animate([{height:`${e.height}px`},{height:`${l.height}px`}],a);continue}const d=e.left-l.left,m=e.top-l.top;(Math.abs(d)>1||Math.abs(m)>1)&&i.animate([{transform:`translate(${d}px, ${m}px)`},{transform:"none"}],a)}},[me]);const pn=y(!1),fe=y(tn);fe.current=tn,T(()=>{D||fe.current?.(g,pn.current)},[g,D]);const w=y(null),gn=y(g);gn.current=g,T(()=>{if(!wt)return;if(wt.replace){j(wt.text);return}if(g.trim())return;let t=0,n;const a=()=>{j(wt.text),n=setTimeout(()=>{!gn.current.trim()&&++t<30&&a()},100)};return a(),()=>clearTimeout(n)},[wt?.key]);const[cs,ds]=f(""),$=S?cs:g,j=(t,n)=>{S&&(t?w.current?.setText(t,n):w.current?.clear()),A(t)},ke=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform)?"\u2318 Enter":"Ctrl Enter",V=[];for(const t of[...p.map(n=>({at:n.at,message:n})),...c==="agent"&&le?le.map(n=>({at:n.at,action:n})):[]].sort((n,a)=>Date.parse(n.at)-Date.parse(a.at))){const n=V[V.length-1];"action"in t&&t.action?n?.group&&Y(n.at)===Y(t.at)?n.group.push(t.action):V.push({at:t.at,group:[t.action]}):"message"in t&&t.message&&V.push({at:t.at,message:t.message})}const be=t=>t?.message&&(!t.message.kind||t.message.kind==="text")?`${t.message.from}:${t.message.agentName??""}`:null,mn=(t,n)=>!!(t&&n&&be(t)&&be(t)===be(n)&&Y(t.at)===Y(n.at)&&Date.parse(n.at)-Date.parse(t.at)<5*6e4),us=y(null),tt=y(null),hn=y(null),gt=y(!0),fn=()=>{const t=tt.current;if(!t||!ce)return;if(t.scrollTop<60)return ce(new Date(0).toISOString());const n=t.getBoundingClientRect().top,a=t.querySelectorAll("[data-at]"),i=[...a].find(e=>e.getBoundingClientRect().bottom>=n)??a[0];i?.dataset.at&&ce(i.dataset.at)},_t=y(0),ps=le?.length??0;Hn(()=>{const t=tt.current;t&&(!gt.current&&_t.current&&(t.scrollTop+=t.scrollHeight-_t.current),_t.current=t.scrollHeight,fn())},[ps]),T(()=>{const t=tt.current,n=hn.current;if(!t||!n)return;const a=()=>gt.current&&(t.scrollTop=t.scrollHeight),i=new ResizeObserver(a);return i.observe(n),i.observe(t),a(),()=>i.disconnect()},[]);const mt=p[p.length-1],[kn,ye]=f(!1),bn=y(null),yn=()=>{gt.current=!0,ye(!1),tt.current&&(tt.current.scrollTop=tt.current.scrollHeight)};T(()=>{const t=bn.current===null;if(bn.current=mt?.id??"",!mt)return;const n=mt.from===c||c==="agent"&&mt.from==="agent"&&mt.agentName===W;t||n||gt.current?yn():ye(!0)},[mt?.id]);const[Kt,et]=f(!1),[Tt,St]=f(!1),O=y(null),q=c==="agent"&&!!Bt&&K.length>0,ht=q?Es(g,K):null,Gt=q&&/^\s*@/.test(g),x=q&&(Tt||(!!ht||Gt)&&!Kt);pn.current=x,T(()=>{!D&&g.trim()&&fe.current?.(g,x)},[x]);const Zt=y(!1);T(()=>{q&&!Tt&&!Kt&&(Gt||ht)&&(Zt.current=!0,St(!0))},[q,Tt,Kt,Gt,ht]),T(()=>{c==="agent"&&nn&&g==="/"&&(j(""),nn())},[g]);const vn=x?Ps(g,K):[],ve=q?Is($):null,_=ve===null?[]:K.filter(t=>t.toLowerCase().startsWith(ve.toLowerCase())),[gs,Ce]=f(0);T(()=>Ce(0),[ve]);const $e=_[Math.min(gs,_.length-1)];T(()=>{g.trim()||et(!1);const t=O.current;t&&(t.style.height="auto",t.style.height=`${Math.min(t.scrollHeight,160)}px`)},[g]);const Ne=lt.length?$.match(/(?:^|\s)!([a-z0-9-]*)$/i)?.[1]??null:null,ft=Ne===null?[]:lt.filter(t=>t.key.startsWith(Ne.toLowerCase())||t.title.toLowerCase().includes(Ne.toLowerCase())).slice(0,6),we=t=>t.replace(/\{\{\s*(\w+)\s*\}\}/g,(n,a)=>Xn[a]??n),Cn=t=>{const n=t.body;t.card&&se&&pe(t.card),S?w.current?.replaceBefore($.match(/![a-z0-9-]*$/i)?.[0].length??0,we(n)):A(a=>a.replace(/![a-z0-9-]*$/i,we(n))),O.current?.focus()},[xe,$n]=f(null),[Me,ms]=f(null),Nn=c==="agent"&&pt?$.match(/(?:^|\s)\[([^[\]\n]{0,40})$/)?.[1]??null:null,Z=Nn!==null&&Me!==null&&$.startsWith(Me)&&$.lastIndexOf("[")===Me.lastIndexOf("[")?null:Nn;T(()=>{Z!==null&&xe===null&&pt&&pt().then($n,()=>$n([]))},[Z!==null]);const hs=(Z??"").toLowerCase().split(/\s+/).filter(Boolean),P=Z===null||!xe?[]:xe.filter(t=>hs.every(n=>`${t.label} ${t.url}`.toLowerCase().includes(n))).slice(0,6),[Le,Re]=f(0);T(()=>Re(0),[Z]);const wn=t=>{const n=$.match(/\[[^[\]\n]*$/)?.[0].length??0;S?w.current?.insertLink(t.url,void 0,n):(A(a=>a.replace(/\[[^[\]\n]*$/,`${qe(t.url,"")} `)),O.current?.focus())},[Te,fs]=f(null),ks=ut?$.match(/(?:^|\s)#((?:[^\s#\d][^#\n]{0,39})?|\d[^\s#]{0,19})$/)?.[1]??null:null,H=Te!==null&&$.startsWith(Te)&&$.lastIndexOf("#")===Te.lastIndexOf("#")?null:ks,[nt,xn]=f({q:"",data:null}),[Q,At]=f(null),[Se,Qt]=f([]);T(()=>{if(H===null||!ut)return At(null);let t=!0;const n=window.setTimeout(()=>{ut(H.trim()).then(a=>t&&xn({q:H,data:a}),()=>t&&xn({q:H,data:{offers:[],products:[]}}))},350);return()=>{t=!1,window.clearTimeout(n)}},[H,ut]);const st=(t,n)=>{if(S){w.current?.replaceBefore($.match(/#[^#\n]*$/)?.[0].length??0,t,{text:t,ref:n??t.replace(/^#/,"")}),At(null);return}A(a=>a.replace(/#[^#\n]*$/,`${t} `)),n&&Qt(a=>[...a.filter(i=>i.text!==t),{text:t,ref:n}]),At(null),O.current?.focus()},Ut=H===null||!nt.data?[]:Q?[{key:"any",label:r("supportChat.refPick.anyVariant"),sub:Q.title,image:Q.image,pick:()=>st(Q.title,`product-${Q.id}`)},...Q.variants.map(t=>({key:t.id,label:t.title,sub:t.sku?`SKU ${t.sku}`:void 0,pick:()=>st(`${Q.title}, ${t.title}`,`variant-${t.id}`)}))]:[...nt.data.offers.slice(0,3).map((t,n)=>({key:`o${t.id}`,section:n===0?r("supportChat.refPick.offers"):void 0,label:t.name,sub:t.label,pick:()=>st(t.name,`offer-${t.id}`)})),...nt.data.products.slice(0,4).map((t,n)=>({key:`p${t.id}`,section:n===0?r("supportChat.refPick.products"):void 0,label:t.title,sub:t.variants.length>1?r("supportChat.product.variants",{count:t.variants.length}):t.status!=="active"?r(`supportChat.product.status.${t.status}`,{defaultValue:t.status}):void 0,image:t.image,pick:()=>t.variants.length>1?At(t):st(t.title,`product-${t.id}`)})),...(nt.data.customers??[]).slice(0,3).map((t,n)=>({key:`c${t.id}`,section:n===0?r("supportChat.refPick.customers"):void 0,label:t.name,sub:[t.email,t.active?r("supportChat.customer.active",{count:t.active}):t.subscriptions?r("supportChat.customer.noneActive",{count:t.subscriptions}):null].filter(Boolean).join(" \xB7 "),pick:()=>st(t.name,`customer-${t.id}`)})),...(nt.data.subscriptions??[]).slice(0,3).map((t,n)=>({key:`s${t.id}`,section:n===0?r("supportChat.refPick.subscriptions"):void 0,label:t.customer,sub:[`#${t.id}`,t.product,t.status].filter(Boolean).join(" \xB7 "),pick:()=>st(`#${t.id}`,null)})),...(nt.data.orders??[]).slice(0,3).map((t,n)=>({key:`r${t.name}`,section:n===0?r("supportChat.refPick.orders"):void 0,label:t.name,sub:[t.customer,new Date(t.createdAt).toLocaleDateString(void 0,{day:"numeric",month:"short"})].filter(Boolean).join(" \xB7 "),pick:()=>st(t.name.startsWith("#")?t.name:`#${t.name}`,null)}))],Ae=y(null),bs=(()=>{const t=Se.filter(d=>g.includes(d.text)).sort((d,m)=>m.text.length-d.text.length),n=new Map(t.map(d=>[d.text,d.ref.startsWith("offer-")?"offer":d.ref.startsWith("customer-")?"customer":"product"])),a=[...t.map(d=>d.text.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")),"#[A-Za-z]{0,6}\\d{3,20}[A-Za-z]{0,6}\\b","`[^`\\n]+`"],i=new RegExp(`(${a.join("|")})`,"g"),e=(d,m)=>x?zn(d,K).map((h,v)=>h.agent?s("mark",{className:"sc-hl sc-hl--mention",children:h.text},`${m}-m${v}`):h.text):d,l=(d,m)=>d.split(i).map((h,v)=>v%2===1?s("mark",{className:`sc-hl sc-hl--${h.startsWith("`")?"code":n.get(h)??"order"}`,children:h},`${m}-${v}`):e(h,`${m}-${v}`));return o(k,{children:[g.split(/(```[\s\S]*?(?:```|$))/).map((d,m)=>m%2===1?s("mark",{className:"sc-hl sc-hl--block",children:d},`f${m}`):l(d,`t${m}`)),`
3
3
  `]})})(),Yt=t=>{if(S)return w.current?.insertText(`${$&&!/\s$/.test($)?" ":""}${t}`);A(n=>`${n}${n&&!/\s$/.test(n)?" ":""}${t}`),window.requestAnimationFrame(()=>{const n=O.current;n&&(n.focus(),n.setSelectionRange(n.value.length,n.value.length))})},Mn=t=>{if(t.key==="Escape"&&Tt&&!D&&!L&&!ft.length&&Z===null)return Zt.current=!1,St(!1),et(!0),!0;if(t.key==="Escape"&&M&&Ue&&H===null&&Z===null&&!ft.length)return Ue(),!0;if((t.key==="Tab"||t.key==="Enter")&&H!==null&&Ut.length&&!t.metaKey&&!t.ctrlKey)return Ut[0].pick(),!0;if(t.key==="Escape"&&H!==null)return fs($),!0;if((t.key==="ArrowDown"||t.key==="ArrowUp")&&P.length>1){const a=t.key==="ArrowDown"?1:-1;return Re(i=>(Math.min(i,P.length-1)+a+P.length)%P.length),!0}if((t.key==="Tab"||t.key==="Enter")&&P.length)return wn(P[Math.min(Le,P.length-1)]),!0;if(t.key==="Escape"&&Z!==null)return ms($),!0;if((t.key==="Tab"||t.key==="Enter")&&ft.length)return Cn(ft[0]),!0;if((t.key==="ArrowDown"||t.key==="ArrowUp")&&_.length>1){const a=t.key==="ArrowDown"?1:-1;return Ce(i=>(Math.min(i,_.length-1)+a+_.length)%_.length),!0}if((t.key==="Tab"||t.key==="Enter")&&$e)return Sn($e),!0;if(t.key==="ArrowUp"&&!g&&ct&&W){const a=Ns();return a?(zt(a.id),j(a.body,a.refs),!0):!1}return t.key==="Escape"&&D?(Be(),!0):t.key==="Escape"&&L?(Jt(),!0):t.key!=="Enter"||t.isComposing?!1:(c==="agent"?t.metaKey||t.ctrlKey:!t.shiftKey)?(Bn(),!0):!1},ys=t=>{const n=t.currentTarget;if(n.selectionStart!==n.selectionEnd)return;const a=n.selectionStart,i=g.lastIndexOf(`
4
4
  `,a-1)+1,e=/^(\s*)(?:([-*•])|(\d{1,3})([.)]))\s+/.exec(g.slice(i,a));if(!e)return;t.preventDefault();const l=g.slice(i,a).trim()===e[0].trim(),d=e[3]?`${e[1]}${Number(e[3])+1}${e[4]} `:`${e[1]}${e[2]} `,m=l?g.slice(0,i)+g.slice(a):`${g.slice(0,a)}
5
- ${d}${g.slice(a)}`,h=l?i:a+1+d.length;A(m),requestAnimationFrame(()=>n.setSelectionRange(h,h))},[at,kt]=f(null),[Ln,De]=f(!1),Rn=y(null),Tn=t=>{if(S)return w.current?.insertText(t);const n=O.current,a=n?.selectionStart??g.length,i=n?.selectionEnd??a;A(e=>e.slice(0,a)+t+e.slice(i)),window.requestAnimationFrame(()=>{n?.focus(),n?.setSelectionRange(a+t.length,a+t.length)})},Sn=t=>{S?w.current?.replaceBefore($.match(/@[\p{L}]*$/u)?.[0].length??0,`@${t} `):A(n=>n.replace(/@[\p{L}]*$/u,`@${t} `)),O.current?.focus()},[Dt,E]=f([]),[An,Oe]=f(!1),Pe=y(null),Dn=Dt.some(t=>!t.ref&&!t.error),vs=Dt.filter(t=>t.ref).map(t=>t.ref.id),Cs=t=>Dt.filter(n=>n.ref&&(!n.inline||t.includes(`file:${n.ref.id}`))).map(n=>n.ref.id),U=!!(Ze||Ft),Ot=(t,n=!1)=>{if(U)for(const a of Array.from(t).slice(0,10)){const i=`${Date.now()}-${Math.random().toString(36).slice(2)}`,e=Bs(a.name,a.type),l=e===a.type?a:new File([a],a.name,{type:e}),d=ze[l.type]?l.size>Fs(l.type)?r("supportChat.files.tooBig",{max:js(l.type)}):void 0:r("supportChat.files.notAllowed"),m=!d&&l.type.startsWith("image/")?URL.createObjectURL(l):null,h=!!(n&&S&&m&&Ft&&w.current),v=l.name||"screenshot.png";if(E(b=>[...b,{key:i,name:v,size:l.size,type:l.type,preview:m,error:d,...h?{inline:!0}:{}}]),d)continue;h&&w.current.insertImage(i,v,m);const I=(b,R)=>{h&&(b?w.current?.setImageId(i,b.id):w.current?.removeImage(i)),E(vt=>vt.map(u=>u.key===i?b?{...u,ref:b}:{...u,error:R??r("supportChat.files.failed")}:u))};if(Ft){Ft(l).then(b=>I(b),()=>I());continue}const B=new FormData;for(const[b,R]of Object.entries(Qe??{}))B.append(b,R);B.append("file",l,l.name||"screenshot.png"),fetch(Ze,{method:"POST",body:B}).then(async b=>({ok:b.ok,body:await b.json().catch(()=>({}))})).then(({ok:b,body:R})=>E(vt=>vt.map(u=>u.key===i?b&&R.file?{...u,ref:R.file}:{...u,error:R.error??r("supportChat.files.failed")}:u))).catch(()=>E(b=>b.map(R=>R.key===i?{...R,error:r("supportChat.files.failed")}:R)))}},$s=t=>{if(!oe&&!ne)return;kt(null);const n=`gif-${t.id}-${Date.now()}`;if(E(i=>[...i,{key:n,name:t.title||"GIF",size:0,type:"image/gif",preview:t.preview}]),ne){ne(t.id).then(i=>E(e=>e.map(l=>l.key===n?{...l,ref:i,size:i.size}:l)),()=>E(i=>i.map(e=>e.key===n?{...e,error:r("supportChat.files.failed")}:e)));return}if(!oe)return;const a=new FormData;for(const[i,e]of Object.entries(Qe??{}))a.append(i,e);a.append("id",t.id),fetch(oe,{method:"POST",body:a}).then(async i=>({ok:i.ok,body:await i.json().catch(()=>({}))})).then(({ok:i,body:e})=>E(l=>l.map(d=>d.key===n?i&&e.file?{...d,ref:e.file,size:e.file.size}:{...d,error:e.error??r("supportChat.files.failed")}:d))).catch(()=>E(i=>i.map(e=>e.key===n?{...e,error:r("supportChat.files.failed")}:e)))},Ns=()=>[...p].reverse().find(t=>t.from==="agent"&&t.agentName===W&&(t.kind==="text"||t.kind==="note")&&t.id!=="pending")??null,[Pt,Ee]=f(null),[ws,On]=f(!1),Ie=t=>{Ee(t),S?w.current?.focus?.():O.current?.focus()},rt=(t,n)=>c==="agent"&&t.from==="agent"?s(_e,{inline:!0,side:n,onReply:()=>Ie(t),onDelete:J?()=>J(t.id):void 0}):null,Pn=t=>t.from==="merchant"?c==="merchant"?r("supportChat.msg.you"):X?.name??r("supportChat.msg.merchant"):t.bot?Zn().brand.bot:t.author??t.agentName??Zn().brand.team,En=t=>t.replyTo?o("button",{type:"button",className:"sc-quote",onClick:()=>document.querySelector(`[data-msg="${CSS.escape(t.replyTo.id)}"]`)?.nextElementSibling?.scrollIntoView({behavior:"smooth",block:"center"}),children:[s("strong",{children:Pn({from:t.replyTo.from,author:t.replyTo.author==="merchant"?void 0:t.replyTo.author})}),s("span",{children:t.replyTo.excerpt})]}):null,In=t=>{ue(null),zt(t.id),j(t.body,t.refs),O.current?.focus()},Be=()=>{zt(null),j("")},Jt=()=>{ue(null),j("")},Bn=()=>{const t=g.trim();if(M){if(M.blocked)return;M.send(t),j("");return}if(D){t&&ct&&ct(D,t),Be();return}if(L){t&&Nt&&Nt(L.id,"send",t),Jt();return}const n=Cs(t);if(!t&&!n.length&&!Lt||Dn)return;const a=Lt;pe(null),(t||n.length)&&Wt({key:`${Date.now()}-${Math.random()}`,body:t,files:n,refs:Se.filter(i=>t.includes(i.text)),note:!!(x&&Bt),...Pt?{replyTo:Pt.id}:{},status:"sending"}),Ee(null),a&&Wt({key:`${Date.now()}-card`,body:"",files:[],note:!1,card:a,status:"sending"}),Qt([]),j(""),et(!1),Zt.current&&(Zt.current=!1,St(!1)),E([])},xs=p.find(t=>t.from==="agent"&&!t.bot&&!t.deletedAt&&t.kind!=="note"&&t.kind!=="draft"&&t.kind!=="event")?.id??null,Xt=z?(t,n,a)=>s(Hs,{id:t,name:n,url:z(t),load:jt},a):void 0,Et=t=>{const n=ea(t.body);return(t.files??[]).filter(a=>!n.has(a.id))},Fe=[];if(z){for(const t of p)if(!(t.deletedAt||t.kind==="event")){for(const n of(t.body??"").matchAll(ta))Fe.push({id:n[2],name:n[1]||"Image",type:"image/png",url:z(n[2])});for(const n of Et(t))(n.type.startsWith("image/")||n.type.startsWith("video/"))&&Fe.push({id:n.id,name:n.name,type:n.type,url:z(n.id)})}}const Ms=t=>t==="system"?"system":t===c?"merchant":"agent",ot=ee?{previewUrl:ee,open:Jn}:null,bt=p.filter(t=>t.kind!=="note").filter(t=>t.kind!=="event"&&t.kind!=="draft"),Ls=bt[bt.length-1]?.id??null,Rs=t=>{const n=bt.findIndex(a=>a.id===t);return bt.slice(n+1).find(a=>a.from==="merchant")?.body??null},Ts=t=>Wt({key:`${Date.now()}-choice`,body:t,files:[],note:!1,status:"sending"}),Fn=c==="merchant"?"merchant":"agent",jn=[...bt].reverse().find(t=>t.from===Fn)?.id??null,Ss=xt?Date.parse(xt):NaN,As=[...bt].reverse().find(t=>t.from===Fn&&t.id!=="pending"&&Date.parse(t.at)<=Ss)?.id??null,Ds=t=>{if(t.id===As&&t.id!==jn){const B=r("supportChat.receipts.seen");return o("span",{className:"sc-receipt sc-receipt--seen","data-tip":`${B} ${F(xt)}`,children:[o("svg",{viewBox:"0 0 18 14",width:"17",height:"13","aria-hidden":!0,children:[s("path",{d:"M1.5 7.5l3.2 3.2L11 4.2",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"}),s("path",{d:"M8.2 10.7L14.6 4.2",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round"})]}),s("span",{className:"sc-receipt-label",children:B})]})}if(t.id!==jn||t.id==="pending")return null;const n=B=>!!(B&&Date.parse(B)>=Date.parse(t.at)),a=c==="agent"&&ie&&n(ie.at)?ie:null,i=a?a.clickedAt??a.openedAt??null:null,e=c==="agent"&&!a&&n(Je)?Je:null,l=n(xt)?{kind:"seen",at:xt}:i?{kind:"emailOpened",at:i}:n(Ye)?{kind:"delivered",at:Ye}:a?.status==="sent"||e?{kind:"emailed",at:a?.at??e}:{kind:a?.status==="held"||a?.status==="failed"?"held":"sent",at:t.at},d=l.kind==="held"&&a?.status==="failed",m=r(`supportChat.receipts.${l.kind==="held"?a?.status==="failed"?"emailFailed":"emailHeld":l.kind}`),h=l.kind!=="sent"&&l.kind!=="held",v=o("svg",{viewBox:"0 0 18 14",width:"17",height:"13","aria-hidden":!0,children:[s("path",{d:h?"M1.5 7.5l3.2 3.2L11 4.2":"M3.5 7.5l3.2 3.2L13 4.2",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"}),h&&s("path",{d:"M8.2 10.7L14.6 4.2",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round"})]}),I=l.kind==="seen"||l.kind==="emailOpened"?`${m} ${F(l.at)}`:void 0;return o("span",{className:`sc-receipt sc-receipt--${l.kind}${d?" sc-receipt--failed":""}`,"data-tip":l.kind==="emailOpened"?`${I}. ${r("supportChat.receipts.openNote")}`:I,children:[v,s("span",{className:"sc-receipt-label",children:m}),d&&sn&&s("button",{type:"button",className:"sc-resend",disabled:ws,onClick:()=>{On(!0),sn().finally(()=>On(!1))},children:r("supportChat.receipts.resend")})]})},je=t=>{const n=Ds(t);return n?o(k,{children:[n," \xB7 "]}):null},yt=(t,n)=>o("div",{className:"sc-meta",style:{textAlign:n==="merchant"?"right":"left"},children:[je(t),t.from==="agent"&&t.agentName?`${t.agentName} \xB7 `:"",F(t.at)]}),Os=t=>{if(!ot)return null;const n=ot.open;return{...ot,open:n?a=>{Mt?.(t,"open"),n(a)}:void 0}};return s(zs,{items:Fe,load:jt,children:s(ya.Provider,{value:ns,children:s(Kn,{value:ot,children:o("div",{className:`sc-shell sc-shell--${c}${An?" sc-shell--drop":""}${ln.className}`,style:ln.style,onDragOver:t=>{!U||!t.dataTransfer.types.includes("Files")||(t.preventDefault(),Oe(!0))},onDragLeave:t=>{t.currentTarget.contains(t.relatedTarget)||Oe(!1)},onDrop:t=>{U&&(t.preventDefault(),Oe(!1),Ot(t.dataTransfer.files,!0))},children:[An&&s("div",{className:"sc-drop",children:r("supportChat.files.drop")}),o("div",{className:"sc-thread","aria-live":"polite",ref:tt,onScroll:t=>{const n=t.currentTarget;gt.current=n.scrollHeight-n.scrollTop-n.clientHeight<40,gt.current&&kn&&ye(!1),_t.current=n.scrollHeight,fn()},children:[s("div",{className:"sc-newbelow-wrap",children:kn&&o("button",{type:"button",className:"sc-newbelow",onClick:yn,children:[r("supportChat.msg.newBelow")," \u2193"]})}),o("div",{className:"sc-content",ref:hn,children:[c==="merchant"&&G&&p.length>0&&s(Vn,{availability:G}),c==="merchant"&&G&&p.length>0&&s(qs,{availability:G,recentReply:p.some(t=>t.from==="agent"&&!t.bot&&Date.now()-Date.parse(t.at)<30*6e4)}),rn&&s("div",{className:"sc-actions-status",children:rn}),p.length===0&&o("div",{className:"sc-empty",children:[s("strong",{children:r("supportChat.emptyTitle")}),r(G?"supportChat.emptyBodyShort":"supportChat.emptyBody"),G&&o("div",{className:"sc-empty-card",children:[s(Vn,{availability:G}),s(Vs,{availability:G})]})]}),V.map((t,n)=>{const a=V[n-1]?.at,i=(!a||Y(a)!==Y(t.at))&&s("div",{className:"sc-day",children:new Date(t.at).toLocaleDateString([],{weekday:"short",day:"numeric",month:"short"})});if(t.group)return o("div",{style:{display:"contents"},children:[i,s("i",{className:"sc-at","data-at":t.at}),s(la,{actions:t.group,store:X})]},`a-${t.group[0].id}`);const e=t.message,l=Ms(e.from);return o("div",{style:{display:"contents"},onClickCapture:c==="merchant"&&e.from==="agent"&&e.kind==="text"?d=>{const m=d.target.closest?.("a[href]");m&&/^https?:/.test(m.href)&&Mt?.(e.id,"link",m.href.slice(0,300))}:void 0,children:[i,s("i",{className:"sc-at","data-at":e.at,"data-msg":e.id}),e.deletedAt?c==="agent"?o("div",{className:`sc-deleted sc-deleted--${l}`,children:[s("s",{children:e.body.length>120?`${e.body.slice(0,117)}...`:e.body}),s("span",{children:r("supportChat.msg.deletedBy",{name:e.deletedBy??""})}),en&&s("button",{type:"button",className:"sc-deleted-undo",onClick:()=>{en(e.id)},children:r("supportChat.msg.undoDelete")})]}):null:e.kind==="draft"?c==="agent"?s(da,{message:e,time:F(e.at),onDraft:Nt,editing:L?.id===e.id,onEdit:()=>{zt(null),ue({id:e.id,name:e.agentName??"Claude"}),j(e.body)}}):null:e.kind==="event"?c==="agent"?s(ca,{message:e,time:F(e.at)}):null:e.kind==="note"?c==="agent"?o("div",{className:`sc-note${e.reminder?" sc-note--reminder":""}`,"aria-label":r(e.reminder?"supportChat.reminders.noteLabel":"supportChat.note.label"),children:[o("div",{className:"sc-note-head",children:[s("svg",{viewBox:"0 0 20 20",width:"13",height:"13","aria-hidden":!0,children:s("path",{d:"M6 9V7a4 4 0 1 1 8 0v2M5 9h10v8H5z",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinejoin:"round"})}),r(e.reminder?"supportChat.reminders.noteTitle":"supportChat.note.title",{name:e.agentName??""}),o("span",{children:[F(e.at),e.editedAt?` \xB7 ${r("supportChat.edit.edited")}`:""]}),e.from==="agent"&&!e.reminder&&(J||ct)?s(_e,{inline:!0,side:"agent",onReply:()=>Ie(e),onEdit:ct&&e.agentName===W?()=>In(e):void 0,onDelete:J?()=>J(e.id):void 0,copyText:e.body}):null]}),s("div",{className:"sc-note-body",children:s(Ve,{text:e.body,image:Xt,inline:(d,m)=>zn(d,K.length?K:e.mentions??[]).map((h,v)=>h.agent?o("span",{className:"sc-mention",children:["@",h.agent]},`${m}-${v}`):s(He,{children:cn(h.text,`${m}-${v}`)},`${m}-${v}`))})}),Et(e).length&&z?s(Wn,{files:Et(e),fileUrl:z,fetchFile:jt}):null]}):null:l==="system"?s("div",{className:"sc-system",children:e.body}):e.kind==="password_request"?o(k,{children:[o("div",{className:`sc-row sc-row--${l} sc-row--card`,children:[rt(e,l),s(It,{viewer:c,message:e,children:s(Gs,{message:e,onOpen:c==="merchant"?()=>Mt?.(e.id,"open"):void 0})})]}),yt(e,l)]}):e.kind==="feature_request"?o(k,{children:[o("div",{className:`sc-row sc-row--${l} sc-row--card`,children:[rt(e,l),s(It,{viewer:c,message:e,children:s(Zs,{message:e,onAdd:c==="merchant"&&an?()=>an(e.id):void 0})})]}),yt(e,l)]}):e.kind==="ticket"?o(k,{children:[o("div",{className:`sc-row sc-row--${l} sc-row--card`,children:[rt(e,l),s(Qs,{message:e})]}),yt(e,l)]}):e.kind==="custom"&&e.card?o(k,{children:[o("div",{className:`sc-row sc-row--${l} sc-row--card`,children:[rt(e,l),s(ga,{tree:e.card.tree,name:e.card.name})]}),yt(e,l)]}):e.kind==="help_offer"?o(k,{children:[o("div",{className:`sc-row sc-row--${l} sc-row--card`,children:[rt(e,l),s(It,{viewer:c,message:e,children:s(_s,{message:e,answered:p.slice(p.indexOf(e)+1).some(d=>d.from==="merchant"),onAnswer:c==="merchant"?d=>{Mt?.(e.id,d===r("supportChat.helpOffer.yesMessage")?"help_yes":"help_no"),Ge(d,[])}:void 0})})]}),yt(e,l)]}):e.kind==="review_request"&&e.review?o(k,{children:[o("div",{className:`sc-row sc-row--${l}`,children:[rt(e,l),s(It,{viewer:c,message:e,children:s(pa,{message:e,shopOwnerName:it,listing:$t,preview:c==="agent",onState:(d,m)=>Un?.(e.id,d,m),onAway:c==="merchant"?d=>Mt?.(e.id,"review_away",d):void 0})})]}),yt(e,l)]}):e.kind==="subscription"&&e.subscriptionId&&ot||e.kind==="link"&&e.link||e.kind==="pricing"&&e.pricing||e.kind==="offer"&&e.offerId&&ot?o(k,{children:[o("div",{className:`sc-row sc-row--${l} sc-row--card`,children:[rt(e,l),l==="agent"&&e.from==="agent"&&s(Ct,{name:e.agentName??"Stefan",size:28}),c==="agent"&&e.from==="agent"&&s("span",{className:"sc-own-avatar",children:s(Ct,{name:e.agentName??"Stefan",size:28})}),s(It,{viewer:c,message:e,children:s(Kn,{value:Os(e.id),children:e.kind==="link"&&e.link?s(ma,{link:e.link}):e.kind==="pricing"&&e.pricing?s(ka,{pricing:e.pricing}):e.kind==="offer"&&e.offerId?s(Gn,{refId:`offer-${e.offerId}`}):s(Gn,{refId:e.subscriptionId})})})]}),o("div",{className:"sc-meta",style:{textAlign:l==="merchant"?"right":"left",paddingLeft:l==="agent"&&e.from==="agent"?36:0,paddingRight:c==="agent"&&e.from==="agent"?36:0},children:[je(e),e.from==="agent"&&e.agentName?`${e.agentName} \xB7 `:"",F(e.at)]})]}):(()=>{const d=mn(V[n-1],t),m=mn(t,V[n+1]),h=e.from==="agent",v=`sc-bubble${h?" sc-bubble--card":""}${e.bot?" sc-bubble--ai":""}${d?" sc-bubble--after":""}${m?" sc-bubble--before":""}`,I=(()=>{for(let u=n-1;u>=0;u--){const N=V[u].message;if(N&&N.kind!=="note")return N}return null})(),B=!!(I&&I.from==="agent"&&I.agentName===e.agentName&&Date.parse(e.at)-Date.parse(I.at)<Na&&Y(I.at)===Y(e.at)),b=h&&!B?o("header",{className:"ho-head sc-card-head",children:[s(Ct,{name:e.agentName??"Stefan",size:30}),o("div",{children:[o("strong",{children:[e.agentName??"Stefan",e.bot&&s("em",{className:"sc-ai-label",children:"AI"})]}),s("span",{children:r(e.bot?"supportChat.ai.byline":"supportChat.preview.fromTeam",$a())})]})]}):null,R=c==="agent"&&e.bot&&e.verified?s("div",{className:"sc-verified",children:r("supportChat.verified.checked",{text:e.verified})}):null,vt=e.bot&&(e.ai||R)?o(k,{children:[b,e.ai?s(ra,{run:e.ai,detail:c==="agent",since:e.at}):null,R]}):b;return o(k,{children:[o("div",{className:`sc-row sc-row--${l}${d?" sc-row--cont":""}${e.bot?" sc-row--ai":""}`,children:[c==="agent"&&e.from==="merchant"&&X?s("span",{className:"sc-row-av","aria-hidden":!0,children:!m&&s(ua,{shop:X.shop,name:X.name,look:X.look,size:28})}):null,o("div",{className:"sc-msg-stack",children:[(()=>{const u=Qn(e,c);if(!u&&!(c==="agent"&&e.translating))return null;const N=u?.lang??null;return o("div",{className:`sc-translated sc-translated--${l}`,children:[N&&s("span",{className:"sc-translated-flags","aria-hidden":!0,children:u?.kind==="from"?`${qn(N,Xe)} \u203A ${We}`:u?.kind==="to"?`${We} \u203A ${qn(N,Xe)}`:We}),u?u.kind==="from"?r("supportChat.translate.from",{language:_n(u.lang,de.language)}):u.kind==="to"?r("supportChat.translate.sentIn",{language:_n(u.lang,de.language)}):r("supportChat.translate.translated"):r("supportChat.translate.translating"),u&&s("button",{type:"button",onClick:()=>is(e.id),"aria-pressed":Rt.has(e.id),children:r(u.kind==="to"!==Rt.has(e.id)?"supportChat.translate.showTranslation":"supportChat.translate.showOriginal")})]})})(),(e.body||e.bot&&e.ai)&&o("div",{className:"sc-bubble-anchor",children:[(c==="agent"||dt)&&e.kind==="text"&&e.body&&s(_e,{side:l,onReply:()=>Ie(e),onReact:dt?u=>dt(e.id,u):void 0,onEdit:c==="agent"&&ct&&e.from==="agent"&&e.agentName===W?()=>In(e):void 0,onDelete:c==="agent"&&J&&e.from==="agent"&&!e.bot?()=>J(e.id):void 0,copyText:Ke(e,c,Rt.has(e.id)),reacted:e.reactions?.filter(u=>c==="merchant"?u.by.includes("merchant"):W&&u.by.includes(W)).map(u=>u.emoji)}),s(va.Provider,{value:c==="agent"?ss(e):null,children:ot?s(fa,{text:Ke(e,c,Rt.has(e.id)),bubbleClass:v,head:o(k,{children:[vt,En(e)]}),links:e.refs,image:Xt}):o("div",{className:v,children:[vt,En(e),s(Ve,{text:Ke(e,c,Rt.has(e.id)),inline:cn,image:Xt})]})})]}),e.id===xs&&o("div",{className:"sc-human",children:[s(Ks,{size:15}),r("supportChat.preview.helpPerks")]}),e.reactions?.length?s("div",{className:"sc-reacts",children:e.reactions.map(u=>o("button",{type:"button",className:`sc-react${(c==="merchant"?u.by.includes("merchant"):W&&u.by.includes(W))?" sc-react--mine":""}`,title:u.by.map(N=>N==="merchant"?c==="merchant"?r("supportChat.msg.you"):X?.name??r("supportChat.msg.merchant"):N).join(", "),disabled:!dt,onClick:()=>dt&&void dt(e.id,u.emoji),children:[u.emoji,u.by.length>1&&s("span",{children:u.by.length})]},u.emoji))}):null,e.bot&&e.progress?.length?s(ia,{steps:e.progress}):null,es&&e.bot&&c==="agent"?s("div",{className:"sc-visitor-cta",children:s("span",{children:r("supportChat.visitor.ctaShown")})}):null,e.bot&&e.assigned?o("div",{className:"sc-assigned",children:[s(Ct,{name:e.assigned,size:20}),s("span",{children:r("supportChat.ai.assigned",{name:e.assigned})})]}):null,e.choices?.length?s(oa,{choices:e.choices,active:c==="merchant"&&e.id===Ls&&dn.length===0,picked:Rs(e.id),onPick:Ts}):null,Et(e).length&&z?s(Wn,{files:Et(e),fileUrl:z,fetchFile:jt}):null]})]}),c==="agent"&&e.clicks?.some(u=>u.action==="link"&&!/^https?:/.test(u.detail??""))&&(()=>{const u=e.clicks.filter(N=>N.action==="link"&&!/^https?:/.test(N.detail??""));return s("div",{className:"sc-link-opened",title:u.map(N=>`${F(N.at)} ${N.detail??""}`).join(`
5
+ ${d}${g.slice(a)}`,h=l?i:a+1+d.length;A(m),requestAnimationFrame(()=>n.setSelectionRange(h,h))},[at,kt]=f(null),[Ln,De]=f(!1),Rn=y(null),Tn=t=>{if(S)return w.current?.insertText(t);const n=O.current,a=n?.selectionStart??g.length,i=n?.selectionEnd??a;A(e=>e.slice(0,a)+t+e.slice(i)),window.requestAnimationFrame(()=>{n?.focus(),n?.setSelectionRange(a+t.length,a+t.length)})},Sn=t=>{S?w.current?.replaceBefore($.match(/@[\p{L}]*$/u)?.[0].length??0,`@${t} `):A(n=>n.replace(/@[\p{L}]*$/u,`@${t} `)),O.current?.focus()},[Dt,E]=f([]),[An,Oe]=f(!1),Pe=y(null),Dn=Dt.some(t=>!t.ref&&!t.error),vs=Dt.filter(t=>t.ref).map(t=>t.ref.id),Cs=t=>Dt.filter(n=>n.ref&&(!n.inline||t.includes(`file:${n.ref.id}`))).map(n=>n.ref.id),U=!!(Ze||Ft),Ot=(t,n=!1)=>{if(U)for(const a of Array.from(t).slice(0,10)){const i=`${Date.now()}-${Math.random().toString(36).slice(2)}`,e=Bs(a.name,a.type),l=e===a.type?a:new File([a],a.name,{type:e}),d=ze[l.type]?l.size>Fs(l.type)?r("supportChat.files.tooBig",{max:js(l.type)}):void 0:r("supportChat.files.notAllowed"),m=!d&&l.type.startsWith("image/")?URL.createObjectURL(l):null,h=!!(n&&S&&m&&Ft&&w.current),v=l.name||"screenshot.png";if(E(b=>[...b,{key:i,name:v,size:l.size,type:l.type,preview:m,error:d,...h?{inline:!0}:{}}]),d)continue;h&&w.current.insertImage(i,v,m);const I=(b,R)=>{h&&(b?w.current?.setImageId(i,b.id):w.current?.removeImage(i)),E(vt=>vt.map(u=>u.key===i?b?{...u,ref:b}:{...u,error:R??r("supportChat.files.failed")}:u))};if(Ft){Ft(l).then(b=>I(b),()=>I());continue}const B=new FormData;for(const[b,R]of Object.entries(Qe??{}))B.append(b,R);B.append("file",l,l.name||"screenshot.png"),fetch(Ze,{method:"POST",body:B}).then(async b=>({ok:b.ok,body:await b.json().catch(()=>({}))})).then(({ok:b,body:R})=>E(vt=>vt.map(u=>u.key===i?b&&R.file?{...u,ref:R.file}:{...u,error:R.error??r("supportChat.files.failed")}:u))).catch(()=>E(b=>b.map(R=>R.key===i?{...R,error:r("supportChat.files.failed")}:R)))}},$s=t=>{if(!oe&&!ne)return;kt(null);const n=`gif-${t.id}-${Date.now()}`;if(E(i=>[...i,{key:n,name:t.title||"GIF",size:0,type:"image/gif",preview:t.preview}]),ne){ne(t.id).then(i=>E(e=>e.map(l=>l.key===n?{...l,ref:i,size:i.size}:l)),()=>E(i=>i.map(e=>e.key===n?{...e,error:r("supportChat.files.failed")}:e)));return}if(!oe)return;const a=new FormData;for(const[i,e]of Object.entries(Qe??{}))a.append(i,e);a.append("id",t.id),fetch(oe,{method:"POST",body:a}).then(async i=>({ok:i.ok,body:await i.json().catch(()=>({}))})).then(({ok:i,body:e})=>E(l=>l.map(d=>d.key===n?i&&e.file?{...d,ref:e.file,size:e.file.size}:{...d,error:e.error??r("supportChat.files.failed")}:d))).catch(()=>E(i=>i.map(e=>e.key===n?{...e,error:r("supportChat.files.failed")}:e)))},Ns=()=>[...p].reverse().find(t=>t.from==="agent"&&t.agentName===W&&(t.kind==="text"||t.kind==="note")&&t.id!=="pending")??null,[Pt,Ee]=f(null),[ws,On]=f(!1),Ie=t=>{Ee(t),S?w.current?.focus?.():O.current?.focus()},rt=(t,n)=>c==="agent"&&t.from==="agent"?s(_e,{inline:!0,side:n,onReply:()=>Ie(t),onDelete:J?()=>J(t.id):void 0}):null,Pn=t=>t.from==="merchant"?c==="merchant"?r("supportChat.msg.you"):X?.name??r("supportChat.msg.merchant"):t.bot?Zn().brand.bot:t.author??t.agentName??Zn().brand.team,En=t=>t.replyTo?o("button",{type:"button",className:"sc-quote",onClick:()=>document.querySelector(`[data-msg="${CSS.escape(t.replyTo.id)}"]`)?.nextElementSibling?.scrollIntoView({behavior:"smooth",block:"center"}),children:[s("strong",{children:Pn({from:t.replyTo.from,author:t.replyTo.author==="merchant"?void 0:t.replyTo.author})}),s("span",{children:t.replyTo.excerpt})]}):null,In=t=>{ue(null),zt(t.id),j(t.body,t.refs),O.current?.focus()},Be=()=>{zt(null),j("")},Jt=()=>{ue(null),j("")},Bn=()=>{const t=g.trim();if(M){if(M.blocked)return;M.send(t),j("");return}if(D){t&&ct&&ct(D,t),Be();return}if(L){t&&Nt&&Nt(L.id,"send",t),Jt();return}const n=Cs(t);if(!t&&!n.length&&!Lt||Dn)return;const a=Lt;pe(null),(t||n.length)&&Wt({key:`${Date.now()}-${Math.random()}`,body:t,files:n,refs:Se.filter(i=>t.includes(i.text)),note:!!(x&&Bt),...Pt?{replyTo:Pt.id}:{},status:"sending"}),Ee(null),a&&Wt({key:`${Date.now()}-card`,body:"",files:[],note:!1,card:a,status:"sending"}),Qt([]),j(""),et(!1),Zt.current&&(Zt.current=!1,St(!1)),E([])},xs=p.find(t=>t.from==="agent"&&!t.bot&&!t.deletedAt&&t.kind!=="note"&&t.kind!=="draft"&&t.kind!=="event")?.id??null,Xt=z?(t,n,a)=>s(Hs,{id:t,name:n,url:z(t),load:jt},a):void 0,Et=t=>{const n=ea(t.body);return(t.files??[]).filter(a=>!n.has(a.id))},Fe=[];if(z){for(const t of p)if(!(t.deletedAt||t.kind==="event")){for(const n of(t.body??"").matchAll(ta))Fe.push({id:n[2],name:n[1]||"Image",type:"image/png",url:z(n[2])});for(const n of Et(t))(n.type.startsWith("image/")||n.type.startsWith("video/"))&&Fe.push({id:n.id,name:n.name,type:n.type,url:z(n.id)})}}const Ms=t=>t==="system"?"system":t===c?"merchant":"agent",ot=ee?{previewUrl:ee,open:Jn}:null,bt=p.filter(t=>t.kind!=="note").filter(t=>t.kind!=="event"&&t.kind!=="draft"),Ls=bt[bt.length-1]?.id??null,Rs=t=>{const n=bt.findIndex(a=>a.id===t);return bt.slice(n+1).find(a=>a.from==="merchant")?.body??null},Ts=t=>Wt({key:`${Date.now()}-choice`,body:t,files:[],note:!1,status:"sending"}),Fn=c==="merchant"?"merchant":"agent",jn=[...bt].reverse().find(t=>t.from===Fn)?.id??null,Ss=xt?Date.parse(xt):NaN,As=[...bt].reverse().find(t=>t.from===Fn&&t.id!=="pending"&&Date.parse(t.at)<=Ss)?.id??null,Ds=t=>{if(t.id===As&&t.id!==jn){const B=r("supportChat.receipts.seen");return o("span",{className:"sc-receipt sc-receipt--seen","data-tip":`${B} ${F(xt)}`,children:[o("svg",{viewBox:"0 0 18 14",width:"17",height:"13","aria-hidden":!0,children:[s("path",{d:"M1.5 7.5l3.2 3.2L11 4.2",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"}),s("path",{d:"M8.2 10.7L14.6 4.2",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round"})]}),s("span",{className:"sc-receipt-label",children:B})]})}if(t.id!==jn||t.id==="pending")return null;const n=B=>!!(B&&Date.parse(B)>=Date.parse(t.at)),a=c==="agent"&&ie&&n(ie.at)?ie:null,i=a?a.clickedAt??a.openedAt??null:null,e=c==="agent"&&!a&&n(Je)?Je:null,l=n(xt)?{kind:"seen",at:xt}:i?{kind:"emailOpened",at:i}:n(Ye)?{kind:"delivered",at:Ye}:a?.status==="sent"||e?{kind:"emailed",at:a?.at??e}:{kind:a?.status==="held"||a?.status==="failed"?"held":"sent",at:t.at},d=l.kind==="held"&&a?.status==="failed",m=r(`supportChat.receipts.${l.kind==="held"?a?.status==="failed"?"emailFailed":"emailHeld":l.kind}`),h=l.kind!=="sent"&&l.kind!=="held",v=o("svg",{viewBox:"0 0 18 14",width:"17",height:"13","aria-hidden":!0,children:[s("path",{d:h?"M1.5 7.5l3.2 3.2L11 4.2":"M3.5 7.5l3.2 3.2L13 4.2",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"}),h&&s("path",{d:"M8.2 10.7L14.6 4.2",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round"})]}),I=l.kind==="seen"||l.kind==="emailOpened"?`${m} ${F(l.at)}`:void 0;return o("span",{className:`sc-receipt sc-receipt--${l.kind}${d?" sc-receipt--failed":""}`,"data-tip":l.kind==="emailOpened"?`${I}. ${r("supportChat.receipts.openNote")}`:I,children:[v,s("span",{className:"sc-receipt-label",children:m}),d&&sn&&s("button",{type:"button",className:"sc-resend",disabled:ws,onClick:()=>{On(!0),sn().finally(()=>On(!1))},children:r("supportChat.receipts.resend")})]})},je=t=>{const n=Ds(t);return n?o(k,{children:[n," \xB7 "]}):null},yt=(t,n)=>o("div",{className:"sc-meta",style:{textAlign:n==="merchant"?"right":"left"},children:[je(t),t.from==="agent"&&t.agentName?`${t.agentName} \xB7 `:"",F(t.at)]}),Os=t=>{if(!ot)return null;const n=ot.open;return{...ot,open:n?a=>{Mt?.(t,"open"),n(a)}:void 0}};return s(zs,{items:Fe,load:jt,children:s(ya.Provider,{value:ns,children:s(Kn,{value:ot,children:o("div",{className:`sc-shell sc-shell--${c}${An?" sc-shell--drop":""}${ln.className}`,style:ln.style,onDragOver:t=>{!U||!t.dataTransfer.types.includes("Files")||(t.preventDefault(),Oe(!0))},onDragLeave:t=>{t.currentTarget.contains(t.relatedTarget)||Oe(!1)},onDrop:t=>{U&&(t.preventDefault(),Oe(!1),Ot(t.dataTransfer.files,!0))},children:[An&&s("div",{className:"sc-drop",children:r("supportChat.files.drop")}),o("div",{className:"sc-thread","aria-live":"polite",ref:tt,onScroll:t=>{const n=t.currentTarget;gt.current=n.scrollHeight-n.scrollTop-n.clientHeight<40,gt.current&&kn&&ye(!1),_t.current=n.scrollHeight,fn()},children:[s("div",{className:"sc-newbelow-wrap",children:kn&&o("button",{type:"button",className:"sc-newbelow",onClick:yn,children:[r("supportChat.msg.newBelow")," \u2193"]})}),o("div",{className:"sc-content",ref:hn,children:[c==="merchant"&&G&&p.length>0&&s(Vn,{availability:G}),c==="merchant"&&G&&p.length>0&&s(qs,{availability:G,recentReply:p.some(t=>t.from==="agent"&&!t.bot&&Date.now()-Date.parse(t.at)<30*6e4)}),rn&&s("div",{className:"sc-actions-status",children:rn}),p.length===0&&o("div",{className:"sc-empty",children:[s("strong",{children:r("supportChat.emptyTitle")}),r(G?"supportChat.emptyBodyShort":"supportChat.emptyBody"),G&&o("div",{className:"sc-empty-card",children:[s(Vn,{availability:G}),s(Vs,{availability:G})]})]}),V.map((t,n)=>{const a=V[n-1]?.at,i=(!a||Y(a)!==Y(t.at))&&s("div",{className:"sc-day",children:new Date(t.at).toLocaleDateString([],{weekday:"short",day:"numeric",month:"short"})});if(t.group)return o("div",{style:{display:"contents"},children:[i,s("i",{className:"sc-at","data-at":t.at}),s(la,{actions:t.group,store:X})]},`a-${t.group[0].id}`);const e=t.message,l=Ms(e.from);return o("div",{style:{display:"contents"},onClickCapture:c==="merchant"&&e.from==="agent"&&e.kind==="text"?d=>{const m=d.target.closest?.("a[href]");m&&/^https?:/.test(m.href)&&Mt?.(e.id,"link",m.href.slice(0,300))}:void 0,children:[i,s("i",{className:"sc-at","data-at":e.at,"data-msg":e.id}),e.deletedAt?c==="agent"?o("div",{className:`sc-deleted sc-deleted--${l}`,children:[s("s",{children:e.body.length>120?`${e.body.slice(0,117)}...`:e.body}),s("span",{children:r("supportChat.msg.deletedBy",{name:e.deletedBy??""})}),en&&s("button",{type:"button",className:"sc-deleted-undo",onClick:()=>{en(e.id)},children:r("supportChat.msg.undoDelete")})]}):null:e.kind==="draft"?c==="agent"?s(da,{message:e,time:F(e.at),onDraft:Nt,editing:L?.id===e.id,onEdit:()=>{zt(null),ue({id:e.id,name:e.agentName??"Claude"}),j(e.body)}}):null:e.kind==="event"?c==="agent"?s(ca,{message:e,time:F(e.at)}):null:e.kind==="note"?c==="agent"?o("div",{className:`sc-note${e.reminder?" sc-note--reminder":""}`,"aria-label":r(e.reminder?"supportChat.reminders.noteLabel":"supportChat.note.label"),children:[o("div",{className:"sc-note-head",children:[s("svg",{viewBox:"0 0 20 20",width:"13",height:"13","aria-hidden":!0,children:s("path",{d:"M4.5 3.5h11v8l-4 4.5h-7zM11.5 16v-4.5h4M7.5 7.5h5M7.5 10.5h2.5",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})}),r(e.reminder?"supportChat.reminders.noteTitle":"supportChat.note.title",{name:e.agentName??""}),e.from==="agent"&&!e.reminder&&(J||ct)?s(_e,{inline:!0,side:"agent",onReply:()=>Ie(e),onEdit:ct&&e.agentName===W?()=>In(e):void 0,onDelete:J?()=>J(e.id):void 0,copyText:e.body}):null,o("span",{children:[F(e.at),e.editedAt?` \xB7 ${r("supportChat.edit.edited")}`:""]})]}),s("div",{className:"sc-note-body",children:s(Ve,{text:e.body,image:Xt,inline:(d,m)=>zn(d,K.length?K:e.mentions??[]).map((h,v)=>h.agent?o("span",{className:"sc-mention",children:["@",h.agent]},`${m}-${v}`):s(He,{children:cn(h.text,`${m}-${v}`)},`${m}-${v}`))})}),Et(e).length&&z?s(Wn,{files:Et(e),fileUrl:z,fetchFile:jt}):null]}):null:l==="system"?s("div",{className:"sc-system",children:e.body}):e.kind==="password_request"?o(k,{children:[o("div",{className:`sc-row sc-row--${l} sc-row--card`,children:[rt(e,l),s(It,{viewer:c,message:e,children:s(Gs,{message:e,onOpen:c==="merchant"?()=>Mt?.(e.id,"open"):void 0})})]}),yt(e,l)]}):e.kind==="feature_request"?o(k,{children:[o("div",{className:`sc-row sc-row--${l} sc-row--card`,children:[rt(e,l),s(It,{viewer:c,message:e,children:s(Zs,{message:e,onAdd:c==="merchant"&&an?()=>an(e.id):void 0})})]}),yt(e,l)]}):e.kind==="ticket"?o(k,{children:[o("div",{className:`sc-row sc-row--${l} sc-row--card`,children:[rt(e,l),s(Qs,{message:e})]}),yt(e,l)]}):e.kind==="custom"&&e.card?o(k,{children:[o("div",{className:`sc-row sc-row--${l} sc-row--card`,children:[rt(e,l),s(ga,{tree:e.card.tree,name:e.card.name})]}),yt(e,l)]}):e.kind==="help_offer"?o(k,{children:[o("div",{className:`sc-row sc-row--${l} sc-row--card`,children:[rt(e,l),s(It,{viewer:c,message:e,children:s(_s,{message:e,answered:p.slice(p.indexOf(e)+1).some(d=>d.from==="merchant"),onAnswer:c==="merchant"?d=>{Mt?.(e.id,d===r("supportChat.helpOffer.yesMessage")?"help_yes":"help_no"),Ge(d,[])}:void 0})})]}),yt(e,l)]}):e.kind==="review_request"&&e.review?o(k,{children:[o("div",{className:`sc-row sc-row--${l}`,children:[rt(e,l),s(It,{viewer:c,message:e,children:s(pa,{message:e,shopOwnerName:it,listing:$t,preview:c==="agent",onState:(d,m)=>Un?.(e.id,d,m),onAway:c==="merchant"?d=>Mt?.(e.id,"review_away",d):void 0})})]}),yt(e,l)]}):e.kind==="subscription"&&e.subscriptionId&&ot||e.kind==="link"&&e.link||e.kind==="pricing"&&e.pricing||e.kind==="offer"&&e.offerId&&ot?o(k,{children:[o("div",{className:`sc-row sc-row--${l} sc-row--card`,children:[rt(e,l),l==="agent"&&e.from==="agent"&&s(Ct,{name:e.agentName??"Stefan",size:28}),c==="agent"&&e.from==="agent"&&s("span",{className:"sc-own-avatar",children:s(Ct,{name:e.agentName??"Stefan",size:28})}),s(It,{viewer:c,message:e,children:s(Kn,{value:Os(e.id),children:e.kind==="link"&&e.link?s(ma,{link:e.link}):e.kind==="pricing"&&e.pricing?s(ka,{pricing:e.pricing}):e.kind==="offer"&&e.offerId?s(Gn,{refId:`offer-${e.offerId}`}):s(Gn,{refId:e.subscriptionId})})})]}),o("div",{className:"sc-meta",style:{textAlign:l==="merchant"?"right":"left",paddingLeft:l==="agent"&&e.from==="agent"?36:0,paddingRight:c==="agent"&&e.from==="agent"?36:0},children:[je(e),e.from==="agent"&&e.agentName?`${e.agentName} \xB7 `:"",F(e.at)]})]}):(()=>{const d=mn(V[n-1],t),m=mn(t,V[n+1]),h=e.from==="agent",v=`sc-bubble${h?" sc-bubble--card":""}${e.bot?" sc-bubble--ai":""}${d?" sc-bubble--after":""}${m?" sc-bubble--before":""}`,I=(()=>{for(let u=n-1;u>=0;u--){const N=V[u].message;if(N&&N.kind!=="note")return N}return null})(),B=!!(I&&I.from==="agent"&&I.agentName===e.agentName&&Date.parse(e.at)-Date.parse(I.at)<Na&&Y(I.at)===Y(e.at)),b=h&&!B?o("header",{className:"ho-head sc-card-head",children:[s(Ct,{name:e.agentName??"Stefan",size:30}),o("div",{children:[o("strong",{children:[e.agentName??"Stefan",e.bot&&s("em",{className:"sc-ai-label",children:"AI"})]}),s("span",{children:r(e.bot?"supportChat.ai.byline":"supportChat.preview.fromTeam",$a())})]})]}):null,R=c==="agent"&&e.bot&&e.verified?s("div",{className:"sc-verified",children:r("supportChat.verified.checked",{text:e.verified})}):null,vt=e.bot&&(e.ai||R)?o(k,{children:[b,e.ai?s(ra,{run:e.ai,detail:c==="agent",since:e.at}):null,R]}):b;return o(k,{children:[o("div",{className:`sc-row sc-row--${l}${d?" sc-row--cont":""}${e.bot?" sc-row--ai":""}`,children:[c==="agent"&&e.from==="merchant"&&X?s("span",{className:"sc-row-av","aria-hidden":!0,children:!m&&s(ua,{shop:X.shop,name:X.name,look:X.look,size:28})}):null,o("div",{className:"sc-msg-stack",children:[(()=>{const u=Qn(e,c);if(!u&&!(c==="agent"&&e.translating))return null;const N=u?.lang??null;return o("div",{className:`sc-translated sc-translated--${l}`,children:[N&&s("span",{className:"sc-translated-flags","aria-hidden":!0,children:u?.kind==="from"?`${qn(N,Xe)} \u203A ${We}`:u?.kind==="to"?`${We} \u203A ${qn(N,Xe)}`:We}),u?u.kind==="from"?r("supportChat.translate.from",{language:_n(u.lang,de.language)}):u.kind==="to"?r("supportChat.translate.sentIn",{language:_n(u.lang,de.language)}):r("supportChat.translate.translated"):r("supportChat.translate.translating"),u&&s("button",{type:"button",onClick:()=>is(e.id),"aria-pressed":Rt.has(e.id),children:r(u.kind==="to"!==Rt.has(e.id)?"supportChat.translate.showTranslation":"supportChat.translate.showOriginal")})]})})(),(e.body||e.bot&&e.ai)&&o("div",{className:"sc-bubble-anchor",children:[(c==="agent"||dt)&&e.kind==="text"&&e.body&&s(_e,{side:l,onReply:()=>Ie(e),onReact:dt?u=>dt(e.id,u):void 0,onEdit:c==="agent"&&ct&&e.from==="agent"&&e.agentName===W?()=>In(e):void 0,onDelete:c==="agent"&&J&&e.from==="agent"&&!e.bot?()=>J(e.id):void 0,copyText:Ke(e,c,Rt.has(e.id)),reacted:e.reactions?.filter(u=>c==="merchant"?u.by.includes("merchant"):W&&u.by.includes(W)).map(u=>u.emoji)}),s(va.Provider,{value:c==="agent"?ss(e):null,children:ot?s(fa,{text:Ke(e,c,Rt.has(e.id)),bubbleClass:v,head:o(k,{children:[vt,En(e)]}),links:e.refs,image:Xt}):o("div",{className:v,children:[vt,En(e),s(Ve,{text:Ke(e,c,Rt.has(e.id)),inline:cn,image:Xt})]})})]}),e.id===xs&&o("div",{className:"sc-human",children:[s(Ks,{size:15}),r("supportChat.preview.helpPerks")]}),e.reactions?.length?s("div",{className:"sc-reacts",children:e.reactions.map(u=>o("button",{type:"button",className:`sc-react${(c==="merchant"?u.by.includes("merchant"):W&&u.by.includes(W))?" sc-react--mine":""}`,title:u.by.map(N=>N==="merchant"?c==="merchant"?r("supportChat.msg.you"):X?.name??r("supportChat.msg.merchant"):N).join(", "),disabled:!dt,onClick:()=>dt&&void dt(e.id,u.emoji),children:[u.emoji,u.by.length>1&&s("span",{children:u.by.length})]},u.emoji))}):null,e.bot&&e.progress?.length?s(ia,{steps:e.progress}):null,es&&e.bot&&c==="agent"?s("div",{className:"sc-visitor-cta",children:s("span",{children:r("supportChat.visitor.ctaShown")})}):null,e.bot&&e.assigned?o("div",{className:"sc-assigned",children:[s(Ct,{name:e.assigned,size:20}),s("span",{children:r("supportChat.ai.assigned",{name:e.assigned})})]}):null,e.choices?.length?s(oa,{choices:e.choices,active:c==="merchant"&&e.id===Ls&&dn.length===0,picked:Rs(e.id),onPick:Ts}):null,Et(e).length&&z?s(Wn,{files:Et(e),fileUrl:z,fetchFile:jt}):null]})]}),c==="agent"&&e.clicks?.some(u=>u.action==="link"&&!/^https?:/.test(u.detail??""))&&(()=>{const u=e.clicks.filter(N=>N.action==="link"&&!/^https?:/.test(N.detail??""));return s("div",{className:"sc-link-opened",title:u.map(N=>`${F(N.at)} ${N.detail??""}`).join(`
6
6
  `),children:r("supportChat.msg.linkOpened",{time:F(u[0].at),count:u.length})})})(),!m&&o("div",{className:"sc-meta",style:{textAlign:l==="merchant"?"right":"left"},children:[je(e),e.email?`${r("supportChat.email.via")} \xB7 `:"",F(e.at),e.editedAt?` \xB7 ${r("supportChat.edit.edited")}`:"",e.email&&!e.email.verified&&c==="agent"?s("span",{className:"sc-meta-warn",children:` \xB7 ${r("supportChat.email.unverified")}`}):null]})]})})()]},e.id)}),dn.filter(t=>!(t.status==="sending"&&rs(t))).map(t=>o("div",{className:`sc-out${t.status==="failed"?" sc-out--failed":""}`,children:[s("div",{className:"sc-row sc-row--merchant",children:s("div",{className:"sc-msg-stack",children:s("div",{className:t.note?"sc-note":"sc-bubble",children:s(Ve,{image:Xt,text:t.card?r("supportChat.outbox.card",{card:r(`supportChat.inbox.tabs.${t.card.kind}`)}):t.body||r("supportChat.outbox.files",{count:t.files.length})})})})}),s("div",{className:`sc-meta sc-out-meta${t.status==="sending"?" sc-out-meta--sending":""}`,role:t.status==="failed"?"alert":void 0,children:t.status==="sending"?r("supportChat.outbox.sending"):o(k,{children:[r("supportChat.outbox.failed"),s("button",{type:"button",onClick:()=>Wt(t),children:r("supportChat.outbox.resend")})]})})]},t.key)),C&&o("div",{className:"sc-row sc-row--agent sc-typing-row",role:"status","aria-live":"polite",children:[C.agent&&s(Ct,{name:C.name,size:28}),o("div",{className:`sc-typing${C.text?" sc-typing--peek":""}`,children:[C.text?o(k,{children:[o("span",{className:"sc-typing-label",children:[r("supportChat.typing.peek",{name:C.name}),C.agent&&s("em",{className:`sc-typing-kind${C.note?" sc-typing-kind--note":""}`,children:r(C.note?"supportChat.typing.note":"supportChat.typing.reply")})]}),s("span",{className:"sc-typing-text",children:C.text.length>400?`...${C.text.slice(-400)}`:C.text})]}):o("span",{className:"sc-typing-label",children:[r("supportChat.typing.dots",{name:C.name}),C.agent&&s("em",{className:`sc-typing-kind${C.note?" sc-typing-kind--note":""}`,children:r(C.note?"supportChat.typing.note":"supportChat.typing.reply")})]}),o("span",{className:"sc-dots","aria-hidden":!0,children:[s("i",{}),s("i",{}),s("i",{})]})]})]}),s("div",{ref:us})]})]}),D&&o("div",{className:"sc-note-bar sc-edit-bar",role:"status",children:[s("span",{children:r(c==="agent"?"supportChat.edit.modeAgent":"supportChat.edit.mode",{key:ke})}),s("button",{type:"button",onClick:Be,children:r("supportChat.edit.cancel")})]}),L&&o("div",{className:"sc-note-bar sc-edit-bar sc-draft-bar",role:"status",children:[s("span",{children:r("supportChat.draft.editing",{name:L.name,key:ke})}),o("span",{className:"sc-draft-bar-actions",children:[s("button",{type:"button",onClick:Jt,children:r("supportChat.draft.cancelEdits")}),s("button",{type:"button",className:"sc-draft-update",disabled:!g.trim(),onClick:()=>{const t=g.trim();t&&Nt&&L&&Nt(L.id,"update",t),Jt()},children:r("supportChat.draft.update")})]})]}),Pt&&!D&&!L&&o("div",{className:"sc-replying",role:"status",children:[s("span",{className:"sc-replying-bar","aria-hidden":!0}),o("span",{className:"sc-replying-text",children:[s("strong",{children:r("supportChat.msg.replyingTo",{name:Pn(Pt)})}),s("span",{children:Pt.body.replace(/\s+/g," ").slice(0,140)})]}),s("button",{type:"button","aria-label":r("supportChat.msg.cancelReply"),onClick:()=>Ee(null),children:"\xD7"})]}),q&&!D&&!L&&o("div",{className:"sc-mode",role:"tablist","aria-label":r("supportChat.note.label"),children:[s("button",{type:"button",role:"tab","aria-selected":!x,onClick:()=>{St(!1),et(!0)},children:r("supportChat.note.tabReply")}),s("button",{type:"button",role:"tab","aria-selected":x,className:"sc-mode-note",onClick:()=>{St(!0),et(!1)},children:r("supportChat.note.tabNote")})]}),!D&&!L&&!Tt&&(x||(ht||Gt)&&Kt)&&s("div",{className:`sc-note-bar${x?"":" sc-note-bar--reply"}`,role:"status",children:x?o(k,{children:[s("svg",{viewBox:"0 0 20 20",width:"13",height:"13","aria-hidden":!0,children:s("path",{d:"M6 9V7a4 4 0 1 1 8 0v2M5 9h10v8H5z",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinejoin:"round"})}),s("span",{children:vn.length||ht?r("supportChat.note.mode",{names:vn.join(` ${r("supportChat.note.and")} `)||ht}):r("supportChat.note.modeTeam")}),s("button",{type:"button",onClick:()=>et(!0),children:r("supportChat.note.sendAsReply")})]}):o(k,{children:[s("span",{children:r("supportChat.note.replyMode")}),s("button",{type:"button",onClick:()=>et(!1),children:r("supportChat.note.makeNote")})]})}),H!==null&&o("div",{className:"sc-shortcuts sc-refpick",role:"listbox","aria-label":r("supportChat.refPick.hint"),children:[Q&&s("button",{type:"button",className:"sc-refpick-back",onMouseDown:t=>t.preventDefault(),onClick:()=>At(null),children:r("supportChat.refPick.back")}),nt.data?Ut.length===0?s("p",{className:"sc-refpick-note",children:r("supportChat.refPick.none")}):Ut.map(t=>o(He,{children:[t.section&&s("span",{className:"sc-refpick-section",children:t.section}),o("button",{type:"button",role:"option","aria-selected":!1,onMouseDown:n=>n.preventDefault(),onClick:t.pick,children:[s("span",{className:"sc-refpick-thumb",children:t.image?s("img",{src:t.image,alt:""}):null}),o("span",{className:"sc-shortcut-text",children:[s("strong",{children:t.label}),t.sub&&s("span",{children:t.sub})]})]})]},t.key)):s("p",{className:"sc-refpick-note",children:r("supportChat.refPick.searching")})]}),P.length>0&&s("div",{className:"sc-shortcuts sc-link-suggest",role:"listbox","aria-label":r("supportChat.links.button"),children:P.map((t,n)=>s("button",{type:"button",role:"option","aria-selected":n===Math.min(Le,P.length-1),className:n===Math.min(Le,P.length-1)?"sc-shortcut--on":void 0,onMouseDown:a=>a.preventDefault(),onMouseEnter:()=>Re(n),onClick:()=>wn(t),children:o("span",{className:"sc-shortcut-text",children:[s("strong",{children:t.label}),s("span",{children:t.url.replace(/^https:\/\//,"")})]})},`${t.group}-${t.url}`))}),ft.length>0&&s("div",{className:"sc-shortcuts",role:"listbox","aria-label":r("supportChat.tools.shortcuts"),children:ft.map(t=>o("button",{type:"button",role:"option","aria-selected":!1,onMouseDown:n=>n.preventDefault(),onClick:()=>Cn(t),children:[o("span",{className:"sc-shortcut-key",children:["!",t.key]}),o("span",{className:"sc-shortcut-text",children:[o("strong",{children:[t.title,t.card&&s("em",{className:"sc-shortcut-card",children:r(`supportChat.inbox.tabs.${t.card.kind}`)})]}),s("span",{children:we(t.body)})]})]},t.key))}),_.length>0&&s("div",{className:"sc-suggest",role:"listbox","aria-label":r("supportChat.note.suggest"),children:_.map(t=>o("button",{type:"button",role:"option","aria-selected":t===$e,onMouseDown:n=>n.preventDefault(),onMouseEnter:()=>Ce(_.indexOf(t)),onClick:()=>Sn(t),children:[s(Ct,{name:t,size:22}),t]},t))}),(()=>{const t=[...Se.filter(n=>g.includes(n.text)).map(n=>({text:n.text,ref:n.ref})),...[...new Set(g.match(/#[A-Za-z]{0,6}\d{3,20}[A-Za-z]{0,6}\b/g)??[])].map(n=>({text:n,ref:n.slice(1)}))];return t.length&&ee&&!S?s("div",{className:"sc-draft-refs",children:t.map(n=>o("span",{className:"sc-draft-ref",children:[s(ha,{refId:n.ref,text:n.text}),s("button",{type:"button","aria-label":r("supportChat.files.remove"),onClick:()=>{A(a=>a.split(n.text).join("").replace(/ {2,}/g," ")),Qt(a=>a.filter(i=>i.ref!==n.ref))},children:s("svg",{viewBox:"0 0 20 20",width:"9",height:"9","aria-hidden":!0,children:s("path",{d:"M5 5l10 10M15 5L5 15",stroke:"currentColor",strokeWidth:"2.4",strokeLinecap:"round"})})})]},n.ref))}):null})(),Dt.some(t=>!t.inline||t.error)&&s(Ws,{files:Dt.filter(t=>!t.inline||t.error),removeLabel:r("supportChat.files.remove"),onRemove:t=>E(n=>n.filter(a=>a.key!==t))}),Lt&&o("div",{className:"sc-attached-card",children:[s("span",{children:r("supportChat.outbox.card",{card:r(`supportChat.inbox.tabs.${Lt.kind}`)})}),s("button",{type:"button","aria-label":r("supportChat.outbox.removeCard"),onClick:()=>pe(null),children:s("svg",{viewBox:"0 0 20 20",width:"10",height:"10","aria-hidden":!0,children:s("path",{d:"M5 5l10 10M15 5L5 15",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round"})})})]}),o("div",{ref:Vt,className:`sc-composer${ae?" sc-composer--top":""}${M?M.text?" sc-composer--cardtext":" sc-composer--card":""}${x&&!L?" sc-composer--note":""}${L?" sc-composer--draft":""}${Ht?" sc-composer--menu":""}${Ht&&ts?" sc-composer--plus":""}${me&&!M?" sc-composer--multi":""}`,children:[ae&&s("div",{className:"sc-composer-top",children:ae}),M&&!M.text&&M.label&&s("span",{className:"sc-composer-cardnote",children:M.label}),Ht&&o(k,{children:[s("button",{type:"button",className:"sc-plus","aria-label":r("supportChat.menu.open"),"aria-expanded":Ln,onClick:()=>De(t=>!t),children:s("svg",{viewBox:"0 0 20 20",width:"20",height:"20","aria-hidden":!0,children:s("path",{d:"M10 4v12M4 10h12",fill:"none",stroke:"currentColor",strokeWidth:"1.9",strokeLinecap:"round"})})}),Ln&&o(k,{children:[s("div",{className:"sc-menu-scrim",onClick:()=>De(!1),"aria-hidden":!0}),s("div",{className:"sc-menu",role:"menu",children:[...U?[{key:"camera",label:r("supportChat.menu.camera"),icon:s(te,{d:"M4 7.5h2.6l1.4-2h4l1.4 2H16a1 1 0 0 1 1 1V15a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V8.5a1 1 0 0 1 1-1z M10 13.6a2.6 2.6 0 1 0 0-5.2 2.6 2.6 0 0 0 0 5.2z"}),onSelect:()=>Rn.current?.click()},{key:"files",label:r("supportChat.menu.files"),icon:s(te,{d:"M13.5 6.5l-6 6a1.8 1.8 0 0 0 2.5 2.5l6.2-6.2a3.3 3.3 0 0 0-4.7-4.7L5.3 10.3a4.8 4.8 0 0 0 6.8 6.8l5.4-5.4"}),onSelect:()=>Pe.current?.click()}]:[],...ut?[{key:"hash",label:r("supportChat.tools.hash"),icon:s(te,{d:"M8 3.5 6.5 16.5M13.5 3.5 12 16.5M4 7.5h12.5M3.5 12.5H16"}),onSelect:()=>Yt("#")}]:[],...lt.length?[{key:"slash",label:r("supportChat.tools.slash"),icon:s(te,{d:"M11.8 6.5 8.2 13.5 M6.5 3h7a3.5 3.5 0 0 1 3.5 3.5v7a3.5 3.5 0 0 1-3.5 3.5h-7A3.5 3.5 0 0 1 3 13.5v-7A3.5 3.5 0 0 1 6.5 3z"}),onSelect:()=>Yt("!")}]:[],...Ht].map(t=>o("button",{type:"button",role:"menuitem","data-key":t.key,onClick:()=>{De(!1),t.onSelect()},children:[s("span",{className:"sc-menu-icon",children:t.icon}),t.label]},t.key))})]}),U&&s("input",{ref:Rn,type:"file",accept:"image/*",capture:"environment",hidden:!0,onChange:t=>{t.target.files&&Ot(t.target.files),t.target.value=""}})]}),at==="link"&&pt&&s(Js,{load:pt,onClose:()=>kt(null),onPick:t=>{if(kt(null),S)w.current?.insertLink(t.url);else{const n=O.current,a=n?g.slice(n.selectionStart,n.selectionEnd):"";Tn(`${qe(t.url,a.includes(`
7
7
  `)?"":a)} `)}}}),(at==="emoji"||at==="gif"&&re)&&s(Ys,{onPick:t=>Tn(t),onClose:()=>kt(null),gif:re?{searchUrl:re,onPick:$s}:void 0,startOn:at==="gif"?"gif":"emoji"}),s("button",{type:"button","data-popover-toggle":!0,className:"sc-attach sc-emoji-btn","aria-label":r("supportChat.tools.emoji"),"aria-expanded":at==="emoji"||at==="gif",onClick:()=>kt(t=>t==="emoji"||t==="gif"?null:"emoji"),children:o("svg",{viewBox:"0 0 20 20",width:"18",height:"18","aria-hidden":!0,children:[s("circle",{cx:"10",cy:"10",r:"7.25",fill:"none",stroke:"currentColor",strokeWidth:"1.6"}),s("path",{d:"M7 11.5a3.6 3.6 0 0 0 6 0",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"}),s("circle",{cx:"7.6",cy:"8.2",r:"1",fill:"currentColor"}),s("circle",{cx:"12.4",cy:"8.2",r:"1",fill:"currentColor"})]})}),c==="agent"&&pt&&s("button",{type:"button","data-popover-toggle":!0,className:"sc-attach sc-link-btn","aria-label":r("supportChat.links.button"),title:r("supportChat.links.button"),"aria-expanded":at==="link",onClick:()=>kt(t=>t==="link"?null:"link"),children:s("svg",{viewBox:"0 0 20 20",width:"17",height:"17","aria-hidden":!0,children:s("path",{d:"M8.6 11.4a3 3 0 0 0 4.2 0l2.6-2.6a3 3 0 0 0-4.2-4.2l-1 1M11.4 8.6a3 3 0 0 0-4.2 0l-2.6 2.6a3 3 0 0 0 4.2 4.2l1-1",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"})})}),ut&&s("button",{type:"button",className:"sc-attach sc-tok-btn","aria-label":r("supportChat.tools.hash"),title:r("supportChat.tools.hash"),onClick:()=>Yt("#"),children:s("svg",{viewBox:"0 0 20 20",width:"17",height:"17","aria-hidden":!0,children:s("path",{d:"M8 3.5 6.5 16.5M13.5 3.5 12 16.5M4 7.5h12.5M3.5 12.5H16",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"})})}),lt.length>0&&s("button",{type:"button",className:"sc-attach sc-tok-btn","aria-label":r("supportChat.tools.slash"),title:r("supportChat.tools.slash"),onClick:()=>Yt("!"),children:o("svg",{viewBox:"0 0 20 20",width:"17",height:"17","aria-hidden":!0,children:[s("rect",{x:"3",y:"3",width:"14",height:"14",rx:"3.5",fill:"none",stroke:"currentColor",strokeWidth:"1.6"}),s("path",{d:"M11.8 6.5 8.2 13.5",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"})]})}),U&&o(k,{children:[s("button",{type:"button",className:"sc-attach","aria-label":r("supportChat.files.add"),onClick:()=>Pe.current?.click(),children:s("svg",{viewBox:"0 0 20 20",width:"18",height:"18","aria-hidden":!0,children:s("path",{d:"M13.5 6.5l-6 6a1.8 1.8 0 0 0 2.5 2.5l6.2-6.2a3.3 3.3 0 0 0-4.7-4.7L5.3 10.3a4.8 4.8 0 0 0 6.8 6.8l5.4-5.4",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"})})}),s("input",{ref:Pe,type:"file",multiple:!0,hidden:!0,accept:[...Object.keys(ze),...Object.values(ze).map(t=>`.${t}`)].join(","),onChange:t=>{t.target.files&&Ot(t.target.files),t.target.value=""}})]}),S?s(aa,{ref:w,placeholder:M?.text?.placeholder??r(x?"supportChat.note.notePlaceholder":lt.length?"supportChat.tools.placeholder":q?"supportChat.note.placeholder":"supportChat.agentPlaceholder"),onChange:({text:t,refs:n,before:a})=>{A(t),Qt(n),ds(a)},onKey:Mn,onPasteFiles:U?t=>Ot(t,!0):void 0,mentions:x?K:[]}):s(k,{children:o("div",{className:"sc-input",children:[s("div",{className:"sc-mirror",ref:Ae,"aria-hidden":!0,children:bs}),s("textarea",{onPaste:t=>{if(U&&t.clipboardData.files.length){t.preventDefault(),Ot(t.clipboardData.files);return}const n=t.currentTarget,a=t.clipboardData.getData("text/plain").trim(),i=n.value.slice(n.selectionStart,n.selectionEnd);if(!na(a)||!i.trim()||i.includes(`
8
8
  `))return;t.preventDefault();const e=qe(a,i),l=n.selectionStart,d=`${n.value.slice(0,l)}${e}${n.value.slice(n.selectionEnd)}`;A(d.slice(0,4e3)),requestAnimationFrame(()=>n.setSelectionRange(l+e.length,l+e.length))},ref:O,onScroll:t=>Ae.current&&(Ae.current.scrollTop=t.currentTarget.scrollTop),rows:1,value:g,maxLength:4e3,placeholder:r(c==="merchant"?"supportChat.placeholder":x?"supportChat.note.notePlaceholder":lt.length?"supportChat.tools.placeholder":q?"supportChat.note.placeholder":"supportChat.agentPlaceholder"),onChange:t=>A(t.target.value),onKeyDown:t=>{Mn(t.nativeEvent)?t.preventDefault():t.key==="Enter"&&!t.nativeEvent.isComposing&&ys(t)}})]})}),s("button",{type:"button",className:"sc-send",title:c==="agent"?r("supportChat.sendWith",{key:ke}):void 0,onClick:Bn,disabled:M?M.blocked:!g.trim()&&!vs.length&&!Lt||Yn||Dn,"aria-label":r("supportChat.send"),children:s("svg",{viewBox:"0 0 20 20",width:"18",height:"18","aria-hidden":!0,children:s("path",{d:"M10 15.5v-11M5 9l5-5 5 5",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})]})]})})})})};export{sr as ChatThread,te as MenuIcon};
@@ -0,0 +1,6 @@
1
+ export declare const EmailTranscriptButton: ({ send, className }: {
2
+ send: () => Promise<{
3
+ to: string;
4
+ }>;
5
+ className?: string;
6
+ }) => import("react").JSX.Element;
@@ -0,0 +1 @@
1
+ import{Fragment as d,jsx as s,jsxs as a}from"react/jsx-runtime";import{useState as p}from"react";import{useTranslation as b}from"./i18n.js";const g=({send:c,className:l})=>{const{t}=b("home"),[e,i]=p(!1),[r,n]=p({kind:"idle"}),u=async()=>{n({kind:"busy"});try{n({kind:"sent",to:(await c()).to})}catch(o){const h=o.message;n({kind:"error",text:/no email address/i.test(h)?t("supportChat.transcript.noEmail"):t("supportChat.transcript.failed")})}};return a("span",{className:"sc-tr",children:[s("button",{type:"button",className:l??"sc-tr-btn","aria-label":t("supportChat.transcript.button"),title:t("supportChat.transcript.button"),"aria-expanded":e,onClick:()=>{i(o=>!o),n({kind:"idle"})},children:s("svg",{viewBox:"0 0 20 20",width:"17",height:"17","aria-hidden":!0,children:s("path",{d:"M5 2.8h6.5L15 6.3v10.9H5z M11.5 2.8v3.5H15 M7.5 10h5 M7.5 13h5",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})})}),e&&a(d,{children:[s("div",{className:"sc-tr-scrim",onClick:()=>i(!1),"aria-hidden":!0}),a("div",{className:"sc-tr-pop",role:"dialog","aria-label":t("supportChat.transcript.button"),children:[s("strong",{children:t("supportChat.transcript.button")}),r.kind==="sent"?s("p",{className:"sc-tr-done",children:t("supportChat.transcript.sent",{to:r.to})}):a(d,{children:[s("p",{children:t("supportChat.transcript.about")}),r.kind==="error"&&s("p",{className:"sc-tr-err",children:r.text}),s("button",{type:"button",className:"sc-tr-send",disabled:r.kind==="busy",onClick:()=>{u()},children:t(r.kind==="busy"?"supportChat.transcript.sending":"supportChat.transcript.send")})]})]})]})]})};export{g as EmailTranscriptButton};
@@ -1,2 +1,2 @@
1
- import{jsx as e,jsxs as s}from"react/jsx-runtime";import{useState as h}from"react";import{useTranslation as g}from"./i18n.js";import{AgentAvatar as m}from"./agents.js";const b={install:"good",reinstall:"good",uninstall:"bad",billing_activated:"good",review:"good",review_low:"warn",access_granted:"good",billing_cancelled:"bad",failed:"bad",widget_enable_fail:"bad",customer_portal_enable_fail:"bad",attempt:"quiet",resolved:"quiet",reopened:"quiet",ai_handover:"quiet",ai_takeback:"quiet",assigned:"quiet",widget_enable_click:"quiet",customer_portal_enable_click:"quiet",subscription_plan_create_click:"quiet",quickstart_skipped:"quiet"},f=n=>b[n]??(/uninstall|fail/.test(n)?"bad":/install|enable_success|_enabled$/.test(n)?"good":/click|attempt/.test(n)?"quiet":"info"),M={good:"M10 4v8m-4-4 4 4 4-4M5 16h10",bad:"M5 6h10M8 6V4.5h4V6m-6 0 .7 9.5h6.6L14 6",warn:"M10 4.5 17 16H3zM10 9v3m0 2v.5",fail:"M6 6l8 8M14 6l-8 8",info:"m5 10.5 3 3 7-7",quiet:"M6 10h.01M10 10h.01M14 10h.01"},_=[[/portal/,"M10 10a3 3 0 1 0 0-6 3 3 0 0 0 0 6zM4.5 16c.8-2.6 3-4 5.5-4s4.7 1.4 5.5 4"],[/widget/,"M4 4.5h12v11H4zM7 8.5h.01M9.5 8.5H13M7 11.5h.01M9.5 11.5H13"],[/offer/,"M3.5 10.2V4.5a1 1 0 0 1 1-1h5.7l6.3 6.3-6.7 6.7zM7 7h.01"]],k=(n,i)=>_.find(([o])=>o.test(n))?.[1]??M[/fail/.test(n)?"fail":i],w=/^(plan|country|name|type|installed for|setting up|rating|targeting)$/i,C=({message:n,time:i})=>{const{t:o}=g("home"),[r,u]=h(!1),a=n.event?.fields??[],d=f(n.event?.type??"other"),v=a.filter(t=>w.test(t.label)&&!t.url&&t.value.length<=40&&!t.value.includes(`
2
- `)).slice(0,3),l=n.event?.type;if((l==="resolved"||l==="reopened")&&n.agentName)return s("div",{className:`sc-event-status sc-event-status--${l}`,children:[e(m,{name:n.agentName,size:22}),e("span",{children:n.body}),e("time",{children:i})]});if(l==="access_granted"){const t=a.find(p=>p.url),c=a.find(p=>p.label==="Name")?.value??t?.value??"";return s("div",{className:"sc-event-access",children:[e("span",{className:"sc-event-access-icon","aria-hidden":!0,children:e("svg",{viewBox:"0 0 20 20",width:"18",height:"18",children:e("path",{d:"M12.5 3.5a4 4 0 1 1-3.9 4.9L3.5 13.5v3h3v-2h2v-2h2l.9-.9A4 4 0 0 1 12.5 3.5zM13.5 6.5h.01",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round"})})}),s("div",{className:"sc-event-access-text",children:[e("strong",{children:o("supportChat.event.accessTitle")}),c&&e("span",{children:o("supportChat.event.accessBody",{name:c})})]}),e("time",{children:i}),t?.url&&e("a",{className:"sc-event-access-open",href:t.url,target:"_blank",rel:"noopener noreferrer",children:o("supportChat.event.accessOpen")})]})}return d==="quiet"?s("div",{className:"sc-event sc-event--quiet",children:[e("span",{children:n.body}),e("time",{children:i})]}):s("div",{className:`sc-event sc-event--${d}${r?" sc-event--open":""}`,children:[s("button",{type:"button",className:"sc-event-head",onClick:()=>a.length&&u(t=>!t),"aria-expanded":a.length?r:void 0,disabled:!a.length,children:[e("span",{className:"sc-event-icon","aria-hidden":!0,children:e("svg",{viewBox:"0 0 20 20",width:"13",height:"13",children:e("path",{d:k(n.event?.type??"",d),fill:"none",stroke:"currentColor",strokeWidth:"1.9",strokeLinecap:"round",strokeLinejoin:"round"})})}),e("span",{className:"sc-event-title",children:n.body}),v.length>0&&e("span",{className:"sc-event-summary",children:v.map(t=>t.value).join(" \xB7 ")}),e("time",{children:i}),a.length>0&&e("svg",{className:"sc-event-caret",viewBox:"0 0 20 20",width:"12",height:"12","aria-label":o(r?"supportChat.event.hide":"supportChat.event.show"),children:e("path",{d:"m6 8 4 4 4-4",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"})})]}),r&&e("dl",{className:"sc-event-fields",children:a.map((t,c)=>s("div",{children:[e("dt",{children:t.label}),e("dd",{children:t.url?e("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",children:t.value.replace(/^https:\/\/(www\.)?/,"")}):t.value})]},c))})]})};export{C as EventRow};
1
+ import{jsx as e,jsxs as s}from"react/jsx-runtime";import{useState as m}from"react";import{useTranslation as f}from"./i18n.js";import{AgentAvatar as h}from"./agents.js";const b={install:"good",reinstall:"good",uninstall:"bad",billing_activated:"good",review:"good",review_low:"warn",access_granted:"good",billing_cancelled:"bad",failed:"bad",widget_enable_fail:"bad",customer_portal_enable_fail:"bad",attempt:"quiet",resolved:"quiet",reopened:"quiet",ai_handover:"quiet",ai_takeback:"quiet",assigned:"quiet",widget_enable_click:"quiet",customer_portal_enable_click:"quiet",subscription_plan_create_click:"quiet",quickstart_skipped:"quiet"},M=n=>b[n]??(/uninstall|fail/.test(n)?"bad":/install|enable_success|_enabled$/.test(n)?"good":/click|attempt/.test(n)?"quiet":"info"),_={good:"M10 4v8m-4-4 4 4 4-4M5 16h10",bad:"M5 6h10M8 6V4.5h4V6m-6 0 .7 9.5h6.6L14 6",warn:"M10 4.5 17 16H3zM10 9v3m0 2v.5",fail:"M6 6l8 8M14 6l-8 8",info:"m5 10.5 3 3 7-7",quiet:"M6 10h.01M10 10h.01M14 10h.01"},k=[[/portal/,"M10 10a3 3 0 1 0 0-6 3 3 0 0 0 0 6zM4.5 16c.8-2.6 3-4 5.5-4s4.7 1.4 5.5 4"],[/widget/,"M4 4.5h12v11H4zM7 8.5h.01M9.5 8.5H13M7 11.5h.01M9.5 11.5H13"],[/offer/,"M3.5 10.2V4.5a1 1 0 0 1 1-1h5.7l6.3 6.3-6.7 6.7zM7 7h.01"]],w=(n,i)=>k.find(([o])=>o.test(n))?.[1]??_[/fail/.test(n)?"fail":i],N=/^(plan|country|name|type|installed for|setting up|rating|targeting)$/i,T=({message:n,time:i})=>{const{t:o}=f("home"),[l,g]=m(!1),a=n.event?.fields??[],d=M(n.event?.type??"other"),p=a.filter(t=>N.test(t.label)&&!t.url&&t.value.length<=40&&!t.value.includes(`
2
+ `)).slice(0,3),r=n.event?.type;if((r==="resolved"||r==="reopened")&&n.agentName)return s("div",{className:`sc-event-status sc-event-status--${r}`,children:[e(h,{name:n.agentName,size:22}),e("span",{children:n.body}),e("time",{children:i})]});const u=r==="assigned"?a.find(t=>t.label==="Assigned to")?.value:void 0;if(u)return s("div",{className:"sc-event-status sc-event-status--assigned",children:[e(h,{name:u,size:22}),e("span",{children:n.body}),e("time",{children:i})]});if(r==="access_granted"){const t=a.find(v=>v.url),c=a.find(v=>v.label==="Name")?.value??t?.value??"";return s("div",{className:"sc-event-access",children:[e("span",{className:"sc-event-access-icon","aria-hidden":!0,children:e("svg",{viewBox:"0 0 20 20",width:"18",height:"18",children:e("path",{d:"M12.5 3.5a4 4 0 1 1-3.9 4.9L3.5 13.5v3h3v-2h2v-2h2l.9-.9A4 4 0 0 1 12.5 3.5zM13.5 6.5h.01",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round"})})}),s("div",{className:"sc-event-access-text",children:[e("strong",{children:o("supportChat.event.accessTitle")}),c&&e("span",{children:o("supportChat.event.accessBody",{name:c})})]}),e("time",{children:i}),t?.url&&e("a",{className:"sc-event-access-open",href:t.url,target:"_blank",rel:"noopener noreferrer",children:o("supportChat.event.accessOpen")})]})}return d==="quiet"?s("div",{className:"sc-event sc-event--quiet",children:[e("span",{children:n.body}),e("time",{children:i})]}):s("div",{className:`sc-event sc-event--${d}${l?" sc-event--open":""}`,children:[s("button",{type:"button",className:"sc-event-head",onClick:()=>a.length&&g(t=>!t),"aria-expanded":a.length?l:void 0,disabled:!a.length,children:[e("span",{className:"sc-event-icon","aria-hidden":!0,children:e("svg",{viewBox:"0 0 20 20",width:"13",height:"13",children:e("path",{d:w(n.event?.type??"",d),fill:"none",stroke:"currentColor",strokeWidth:"1.9",strokeLinecap:"round",strokeLinejoin:"round"})})}),e("span",{className:"sc-event-title",children:n.body}),p.length>0&&e("span",{className:"sc-event-summary",children:p.map(t=>t.value).join(" \xB7 ")}),e("time",{children:i}),a.length>0&&e("svg",{className:"sc-event-caret",viewBox:"0 0 20 20",width:"12",height:"12","aria-label":o(l?"supportChat.event.hide":"supportChat.event.show"),children:e("path",{d:"m6 8 4 4 4-4",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"})})]}),l&&e("dl",{className:"sc-event-fields",children:a.map((t,c)=>s("div",{children:[e("dt",{children:t.label}),e("dd",{children:t.url?e("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",children:t.value.replace(/^https:\/\/(www\.)?/,"")}):t.value})]},c))})]})};export{T as EventRow};
@@ -1,5 +1,5 @@
1
- import{Fragment as k,jsx as i,jsxs as g}from"react/jsx-runtime";import{Fragment as $,useState as L}from"react";import{highlightCode as P}from"./highlight.js";import{useChatEnv as D,useLinkNames as q,useOpened as z}from"./chatEnv.js";import{chatHost as b}from"./host.js";import{MD_LINK as G}from"@whoa-chat/core/links";const C=/^\s*[-*•]\s+/,S=/^\s*\d{1,3}[.)]\s+/,U=/(https?:\/\/[^\s<>"']+[^\s<>"'.,;:!?)\]])/g,H=/(`[^`\n]+`)/g,K=/(\*\*[^*\n]+\*\*)/g,W=/```[^\S\n]*([\w+#.-]*)[^\S\n]*\n?([\s\S]*?)(?:```|$)/g,j=/^https:\/\/admin\.shopify\.com\/(?:store\/[^/]+\/?)?(.*)$/,h=e=>e.replace(/[-_]+/g," ").replace(/\b\w/g,t=>t.toUpperCase()),N=e=>{const t=j.exec(e);if(!t)return null;const[n,o=""]=t[1].split("?"),s=new URLSearchParams(o),r=n.split("/").filter(Boolean),[a,l,c]=r;if(!a)return["Home"];if(a==="themes")return r.includes("editor")?["Online Store","Themes","Customize",...s.get("context")==="apps"||s.has("appEmbed")?["App embeds"]:[]]:["Online Store","Themes"];if(a==="apps"){const u=r.slice(r.indexOf("app")+1).filter(d=>!/^[0-9a-f]{24}$|^\d+$/.test(d));return["Apps",b().brand.app,...u.slice(0,2).map(h)]}if(a==="settings")return["Settings",...l?[h(l)]:[],...c&&!/^\d+$/.test(c)?[h(c)]:[]];if(a==="online_store")return["Online Store",...l?[h(l)]:[]];const p={products:"Products",orders:"Orders",customers:"Customers",collections:"Collections",discounts:"Discounts",markets:"Markets",menus:"Online Store",pages:"Online Store",content:"Content"},m={products:"This product",orders:"This order",customers:"This customer",collections:"This collection",discounts:"This discount"};return p[a]?[p[a],...l&&!/^\d+$/.test(l)?[h(l)]:l?[m[a]??"Open"]:[]]:null},J=/^https:\/\/admin\.shopify\.com\/(?:store\/[^/]+\/)?apps\/([^/?#]+)(\/app(?:\/[^?#]*)?)(\?[^#]*)?/,A=/^[0-9a-f]{24}$|^\d+$/,x=e=>{const t=J.exec(e);if(!t)return null;const n=b().appLinks??[],o=n.find(d=>d.handle===t[1]),s=b().brand,r=o??(n.length<=1&&(!n.length||n[0].handle===t[1])?{name:s.app,logo:s.logo,pages:[]}:{name:h(t[1]),pages:[]}),a=`${t[2]}${t[3]??""}`,l=t[2].split("/").filter(Boolean).slice(1),c=l.filter(d=>!A.test(d)),p=c.length?r.pages.find(d=>d.segment===c[0].toLowerCase()):void 0,m=c.length?[p?.name??h(c[0]),...c.slice(1,2).map(h)]:["Home"];c.length===1&&l.length>1&&A.test(l[1])&&p?.item&&m.push(p.item.replace("{id}",l[1]));const u=new URLSearchParams(t[3]??"").get("highlight");return u&&m.push(...u.split(".").map(h)),{path:a,steps:m.slice(0,4),app:{name:r.name,logo:"logo"in r?r.logo:void 0}}},R=({url:e,page:t,label:n,asText:o})=>{const s=D(),r=n?[n]:t.steps,a=g(k,{children:[t.app.logo?i("img",{src:t.app.logo,alt:t.app.name,width:13,height:13}):null,r.map((l,c)=>g($,{children:[c>0&&i("i",{"aria-hidden":!0,children:"\u203A"}),i("span",{className:c===r.length-1?"sc-app-last":void 0,children:l})]},c))]});return o?i("span",{className:"sc-app-link",title:e,children:a}):g(k,{children:[i("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"sc-app-link",title:e,onClick:l=>{s?.open&&(l.preventDefault(),s.open(t.path))},children:a}),i(y,{url:e})]})},y=({url:e})=>{const t=z(e);return t?i("span",{className:"sc-opened-mark",title:t,"aria-label":t,role:"img",children:i("svg",{viewBox:"0 0 16 16",width:"12",height:"12","aria-hidden":!0,children:i("path",{d:"M3.5 8.5l3 3 6-7",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}):null},T=({url:e,label:t})=>g(k,{children:[i("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"sc-link",title:e,children:t||e}),i(y,{url:e})]}),Q=/^https:\/\/admin\.shopify\.com\/(?:store\/[^/]+\/)?(products|orders)\/(\d+)/,I=({url:e,path:t,label:n,asText:o})=>{const s=Q.exec(e),r=q()?.[s?`${s[1]}/${s[2]}`:""],a=n?[n]:r?[t[0],r]:t,l=g(k,{children:[i("img",{src:"/support/shopify.svg",alt:"Shopify",width:13,height:13}),a.slice(0,-1).map((c,p)=>g("span",{className:"sc-admin-step",children:[c,i("i",{"aria-hidden":!0,children:"\u203A"})]},p)),i("u",{children:a[a.length-1]})]});return o?i("span",{className:"sc-admin-link",title:e,children:l}):g(k,{children:[i("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"sc-admin-link",title:e,children:l}),i(y,{url:e})]})},ct=e=>!!(x(e)||N(e)),V=({url:e,label:t,asText:n})=>{const o=x(e);if(o)return i(R,{url:e,page:o,label:t,asText:n});const s=N(e);return s?i(I,{url:e,path:s,label:t,asText:n}):n?i("span",{className:"sc-link",title:e,children:t||e}):i(T,{url:e,label:t})},E=(e,t,n)=>{const o=[];let s=0,r=0;for(const a of e.matchAll(G))o.push(...F(e.slice(s,a.index),t,`${n}-m${r}`)),o.push(i(V,{url:a[2],label:a[1]},`${n}-l${r}`)),s=a.index+a[0].length,r++;return o.push(...F(e.slice(s),t,`${n}-m${r}`)),o},F=(e,t,n)=>e.split(U).map((o,s)=>s%2===1&&x(o)?i(R,{url:o,page:x(o)},`${n}-${s}`):s%2===1&&N(o)?i(I,{url:o,path:N(o)},`${n}-${s}`):s%2===1?i(T,{url:o},`${n}-${s}`):i($,{children:t(o,`${n}-${s}`)},`${n}-${s}`)),X=({code:e})=>{const[t,n]=L(!1),o=()=>{navigator.clipboard?.writeText(e).then(()=>{n(!0),window.setTimeout(()=>n(!1),1400)})};return i("code",{className:"sc-icode sc-icode--copy",role:"button",tabIndex:0,"data-tip":t?"Copied":"Copy","aria-label":`${e}, ${t?"copied":"copy"}`,onClick:s=>{s.stopPropagation(),o()},onKeyDown:s=>{s.key!=="Enter"&&s.key!==" "||(s.preventDefault(),s.stopPropagation(),o())},children:e})},Y=/!\[[^\]\n]*\]\((https:\/\/media\d*\.giphy\.com\/media\/[^\s)<>"']+\.gif)\)/g,Z=(e,t,n)=>e.split(K).map((o,s)=>s%2===1?i("strong",{children:E(o.slice(2,-2),t,`${n}-b${s}`)},`${n}-b${s}`):i($,{children:E(o,t,`${n}-t${s}`)},`${n}-t${s}`)),O=(e,t,n)=>e.split(H).map((o,s)=>s%2===1?i(X,{code:o.slice(1,-1)},`${n}-c${s}`):i($,{children:o.split(Y).map((r,a)=>a%2===1?i("img",{className:"sc-md-gif",src:r,alt:"GIF",loading:"lazy",referrerPolicy:"no-referrer"},`${n}-g${a}`):i($,{children:Z(r,t,`${n}-g${a}`)},`${n}-g${a}`))},`${n}-c${s}`)),_=[{id:"javascript",label:"JavaScript",aliases:["js","javascript","jsx","ts","typescript"]},{id:"liquid",label:"Liquid",aliases:["liquid","html","htm","xml","svg"]},{id:"css",label:"CSS",aliases:["css","scss"]}],w=e=>_.find(t=>t.aliases.includes(e.toLowerCase()))?.id??null,tt=e=>_.find(t=>t.id===w(e))?.label??(e||"Code"),v=e=>{const t=e.trim();return t?/\{%-?\s*\w|\{\{-?\s*[\w'"]/.test(t)||/<\/?[a-z][\w-]*(\s[^<>]*)?\/?>/i.test(t)?"liquid":/\b(const|let|var|function|return|document\.|window\.|console\.|addEventListener|querySelector|async|await)\b|=>/.test(t)?"javascript":/[^{}]+\{[^{}]*[\w-]+\s*:\s*[^;{}]+;?[^{}]*\}/.test(t)||/^\s*[\w-]+\s*:\s*[^;{}]+;\s*$/m.test(t)||/@media|!important/.test(t)?"css":null:null},et=({lang:e})=>{const t=e?w(e):null;return t==="javascript"?g("svg",{className:"sc-lang-icon",viewBox:"0 0 16 16",width:"14",height:"14","aria-hidden":!0,children:[i("rect",{width:"16",height:"16",rx:"3",fill:"#f7df1e"}),i("text",{x:"14.2",y:"13.6",textAnchor:"end",fontFamily:"Arial, sans-serif",fontWeight:"700",fontSize:"7.6",fill:"#1b1b1b",children:"JS"})]}):t==="css"?g("svg",{className:"sc-lang-icon",viewBox:"0 0 16 16",width:"14",height:"14","aria-hidden":!0,children:[i("rect",{width:"16",height:"16",rx:"3",fill:"#2965f1"}),i("text",{x:"8",y:"11",textAnchor:"middle",fontFamily:"Arial, sans-serif",fontWeight:"700",fontSize:"5.6",fill:"#fff",children:"CSS"})]}):t==="liquid"?g("svg",{className:"sc-lang-icon",viewBox:"0 0 16 16",width:"14",height:"14","aria-hidden":!0,children:[i("path",{d:"M8 1.2C8 1.2 3 7 3 10.1A5 5 0 0 0 13 10.1C13 7 8 1.2 8 1.2z",fill:"#38bdf8"}),i("path",{d:"M6 10.6a2 2 0 0 0 2 2",fill:"none",stroke:"#fff",strokeWidth:"1.3",strokeLinecap:"round"})]}):null},st=({code:e,lang:t})=>{const[n,o]=L(!1),s=()=>navigator.clipboard?.writeText(e).then(()=>{o(!0),window.setTimeout(()=>o(!1),1500)},()=>{});return g("div",{className:"sc-code",children:[g("div",{className:"sc-code-bar",children:[g("span",{className:"sc-code-lang",children:[i(et,{lang:t||v(e)}),tt(t||v(e)||"")]}),i("button",{type:"button",onClick:s,children:n?"Copied":"Copy"})]}),i("pre",{children:(()=>{const r=P(e,w(t)??(t?null:v(e)));return r?i("code",{className:"sc-hl-code",dangerouslySetInnerHTML:{__html:r}}):i("code",{children:e})})()})]})},nt=e=>{const t=[];for(const n of e.split(`
2
- `)){const o=C.test(n)?"ul":S.test(n)?"ol":"p",s=t[t.length-1];s&&s.kind===o?s.lines.push(n):t.push({kind:o,lines:[n]})}return t},B=(e,t,n)=>e.replace(/[ \t]+\n/g,`
3
- `).replace(/^\n+|\n+$/g,"").split(/\n{2,}/).filter(o=>o.trim()).flatMap((o,s)=>nt(o).map((r,a)=>{const l=`${n}-${s}-${a}`;if(r.kind==="p")return i("p",{children:O(r.lines.join(`
4
- `),t,l)},l);const c=r.kind,p=r.kind==="ol"?Number(/\d+/.exec(r.lines[0])?.[0]??1):void 0;return i(c,{start:p!==1?p:void 0,children:r.lines.map((m,u)=>i("li",{children:O(m.replace(r.kind==="ul"?C:S,""),t,`${l}-${u}`)},u))},l)})),M=/!\[([^\]\n]*)\]\(file:([^)\s]+)\)/g,pt=e=>new Set([...(e??"").matchAll(M)].map(t=>t[2])),dt=({text:e,inline:t=o=>o,image:n})=>{const o=e.replace(/\r\n?/g,`
5
- `).trim(),s=[];let r=0,a=0;const l=(c,p)=>{const m=[];let u=0,d=0;for(const f of c.matchAll(M))m.push(...B(c.slice(u,f.index),t,`${p}i${d}`)),m.push(n?i("div",{className:"sc-inline-img",children:n(f[2],f[1],`${p}img${d}`)},`${p}img${d}`):g("p",{className:"sc-inline-img-name",children:["[",f[1]||"image","]"]},`${p}img${d}`)),u=f.index+f[0].length,d++;return m.push(...B(c.slice(u),t,`${p}i${d}`)),m};for(const c of o.matchAll(W)){s.push(...l(o.slice(r,c.index),`t${a}`));const p=c[2].replace(/\n$/,"");p.trim()&&s.push(i(st,{code:p,lang:c[1]},`code${a}`)),r=c.index+c[0].length,a++}return s.push(...l(o.slice(r),`t${a}`)),i("div",{className:"sc-text",children:s})};export{_ as CODE_LANGUAGES,M as FILE_IMG,dt as FormattedText,et as LanguageIcon,V as LinkBadge,N as adminPath,x as appPage,w as codeLanguage,v as detectLanguage,pt as inlineFileIds,ct as isBadgeLink};
1
+ import{Fragment as k,jsx as i,jsxs as g}from"react/jsx-runtime";import{Fragment as $,useState as L}from"react";import{highlightCode as P}from"./highlight.js";import{useChatEnv as D,useLinkNames as q,useOpened as z}from"./chatEnv.js";import{chatHost as x}from"./host.js";import{MD_LINK as G}from"@whoa-chat/core/links";const C=/^\s*[-*•]\s+/,S=/^\s*\d{1,3}[.)]\s+/,U=/(https?:\/\/[^\s<>"']+[^\s<>"'.,;:!?)\]])/g,H=/(`[^`\n]+`)/g,K=/(\*\*[^*\n]+\*\*)/g,W=/```[^\S\n]*([\w+#.-]*)[^\S\n]*\n?([\s\S]*?)(?:```|$)/g,j=/^https:\/\/admin\.shopify\.com\/(?:store\/[^/]+\/?)?(.*)$/,h=e=>e.replace(/[-_]+/g," ").replace(/\b\w/g,t=>t.toUpperCase()),N=e=>{const t=j.exec(e);if(!t)return null;const[n,o=""]=t[1].split("?"),s=new URLSearchParams(o),r=n.split("/").filter(Boolean),[a,l,c]=r;if(!a)return["Home"];if(a==="themes")return r.includes("editor")?["Online Store","Themes","Customize",...s.get("context")==="apps"||s.has("appEmbed")?["App embeds"]:[]]:["Online Store","Themes"];if(a==="apps"){const u=r.slice(r.indexOf("app")+1).filter(d=>!/^[0-9a-f]{24}$|^\d+$/.test(d));return["Apps",x().brand.app,...u.slice(0,2).map(h)]}if(a==="settings")return["Settings",...l?[h(l)]:[],...c&&!/^\d+$/.test(c)?[h(c)]:[]];if(a==="online_store")return["Online Store",...l?[h(l)]:[]];const p={products:"Products",orders:"Orders",customers:"Customers",collections:"Collections",discounts:"Discounts",markets:"Markets",menus:"Online Store",pages:"Online Store",content:"Content"},m={products:"This product",orders:"This order",customers:"This customer",collections:"This collection",discounts:"This discount"};return p[a]?[p[a],...l&&!/^\d+$/.test(l)?[h(l)]:l?[m[a]??"Open"]:[]]:null},J=/^https:\/\/admin\.shopify\.com\/(?:store\/[^/]+\/)?apps\/([^/?#]+)(\/app(?:\/[^?#]*)?)(\?[^#]*)?/,A=/^[0-9a-f]{24}$|^\d+$/,b=e=>{const t=J.exec(e);if(!t)return null;const n=x().appLinks??[],o=n.find(d=>d.handle===t[1]),s=x().brand,r=o??(n.length<=1&&(!n.length||n[0].handle===t[1])?{name:s.app,logo:s.logo,pages:[]}:{name:h(t[1]),pages:[]}),a=`${t[2]}${t[3]??""}`,l=t[2].split("/").filter(Boolean).slice(1),c=l.filter(d=>!A.test(d)),p=c.length?r.pages.find(d=>d.segment===c[0].toLowerCase()):void 0,m=c.length?[p?.name??h(c[0]),...c.slice(1,2).map(h)]:["Home"];c.length===1&&l.length>1&&A.test(l[1])&&p?.item&&m.push(p.item.replace("{id}",l[1]));const u=new URLSearchParams(t[3]??"").get("highlight");return u&&m.push(...u.split(".").map(h)),{path:a,steps:m.slice(0,4),app:{name:r.name,logo:"logo"in r?r.logo:void 0}}},R=({url:e,page:t,label:n,asText:o})=>{const s=D(),r=n?[n]:t.steps,a=g(k,{children:[t.app.logo?i("img",{src:t.app.logo,alt:t.app.name,width:13,height:13}):null,r.map((l,c)=>g($,{children:[c>0&&i("i",{"aria-hidden":!0,children:"\u203A"}),i("span",{className:c===r.length-1?"sc-app-last":void 0,children:l})]},c))]});return o?i("span",{className:"sc-app-link",title:e,children:a}):i(k,{children:g("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"sc-app-link",title:e,onClick:l=>{s?.open&&(l.preventDefault(),s.open(t.path))},children:[a,i(y,{url:e,inBadge:!0})]})})},y=({url:e,inBadge:t})=>{const n=z(e);return n?i("span",{className:t?"sc-opened-mark sc-opened-mark--in":"sc-opened-mark",title:n,"aria-label":n,role:"img",children:i("svg",{viewBox:"0 0 16 16",width:"12",height:"12","aria-hidden":!0,children:i("path",{d:"M3.5 8.5l3 3 6-7",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}):null},T=({url:e,label:t})=>g(k,{children:[i("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"sc-link",title:e,children:t||e}),i(y,{url:e})]}),Q=/^https:\/\/admin\.shopify\.com\/(?:store\/[^/]+\/)?(products|orders)\/(\d+)/,I=({url:e,path:t,label:n,asText:o})=>{const s=Q.exec(e),r=q()?.[s?`${s[1]}/${s[2]}`:""],a=n?[n]:r?[t[0],r]:t,l=g(k,{children:[i("img",{src:"/support/shopify.svg",alt:"Shopify",width:13,height:13}),a.slice(0,-1).map((c,p)=>g("span",{className:"sc-admin-step",children:[c,i("i",{"aria-hidden":!0,children:"\u203A"})]},p)),i("u",{children:a[a.length-1]})]});return o?i("span",{className:"sc-admin-link",title:e,children:l}):i(k,{children:g("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"sc-admin-link",title:e,children:[l,i(y,{url:e,inBadge:!0})]})})},ct=e=>!!(b(e)||N(e)),V=({url:e,label:t,asText:n})=>{const o=b(e);if(o)return i(R,{url:e,page:o,label:t,asText:n});const s=N(e);return s?i(I,{url:e,path:s,label:t,asText:n}):n?i("span",{className:"sc-link",title:e,children:t||e}):i(T,{url:e,label:t})},B=(e,t,n)=>{const o=[];let s=0,r=0;for(const a of e.matchAll(G))o.push(...E(e.slice(s,a.index),t,`${n}-m${r}`)),o.push(i(V,{url:a[2],label:a[1]},`${n}-l${r}`)),s=a.index+a[0].length,r++;return o.push(...E(e.slice(s),t,`${n}-m${r}`)),o},E=(e,t,n)=>e.split(U).map((o,s)=>s%2===1&&b(o)?i(R,{url:o,page:b(o)},`${n}-${s}`):s%2===1&&N(o)?i(I,{url:o,path:N(o)},`${n}-${s}`):s%2===1?i(T,{url:o},`${n}-${s}`):i($,{children:t(o,`${n}-${s}`)},`${n}-${s}`)),X=({code:e})=>{const[t,n]=L(!1),o=()=>{navigator.clipboard?.writeText(e).then(()=>{n(!0),window.setTimeout(()=>n(!1),1400)})};return i("code",{className:"sc-icode sc-icode--copy",role:"button",tabIndex:0,"data-tip":t?"Copied":"Copy","aria-label":`${e}, ${t?"copied":"copy"}`,onClick:s=>{s.stopPropagation(),o()},onKeyDown:s=>{s.key!=="Enter"&&s.key!==" "||(s.preventDefault(),s.stopPropagation(),o())},children:e})},Y=/!\[[^\]\n]*\]\((https:\/\/media\d*\.giphy\.com\/media\/[^\s)<>"']+\.gif)\)/g,Z=(e,t,n)=>e.split(K).map((o,s)=>s%2===1?i("strong",{children:B(o.slice(2,-2),t,`${n}-b${s}`)},`${n}-b${s}`):i($,{children:B(o,t,`${n}-t${s}`)},`${n}-t${s}`)),F=(e,t,n)=>e.split(H).map((o,s)=>s%2===1?i(X,{code:o.slice(1,-1)},`${n}-c${s}`):i($,{children:o.split(Y).map((r,a)=>a%2===1?i("img",{className:"sc-md-gif",src:r,alt:"GIF",loading:"lazy",referrerPolicy:"no-referrer"},`${n}-g${a}`):i($,{children:Z(r,t,`${n}-g${a}`)},`${n}-g${a}`))},`${n}-c${s}`)),O=[{id:"javascript",label:"JavaScript",aliases:["js","javascript","jsx","ts","typescript"]},{id:"liquid",label:"Liquid",aliases:["liquid","html","htm","xml","svg"]},{id:"css",label:"CSS",aliases:["css","scss"]}],w=e=>O.find(t=>t.aliases.includes(e.toLowerCase()))?.id??null,tt=e=>O.find(t=>t.id===w(e))?.label??(e||"Code"),v=e=>{const t=e.trim();return t?/\{%-?\s*\w|\{\{-?\s*[\w'"]/.test(t)||/<\/?[a-z][\w-]*(\s[^<>]*)?\/?>/i.test(t)?"liquid":/\b(const|let|var|function|return|document\.|window\.|console\.|addEventListener|querySelector|async|await)\b|=>/.test(t)?"javascript":/[^{}]+\{[^{}]*[\w-]+\s*:\s*[^;{}]+;?[^{}]*\}/.test(t)||/^\s*[\w-]+\s*:\s*[^;{}]+;\s*$/m.test(t)||/@media|!important/.test(t)?"css":null:null},et=({lang:e})=>{const t=e?w(e):null;return t==="javascript"?g("svg",{className:"sc-lang-icon",viewBox:"0 0 16 16",width:"14",height:"14","aria-hidden":!0,children:[i("rect",{width:"16",height:"16",rx:"3",fill:"#f7df1e"}),i("text",{x:"14.2",y:"13.6",textAnchor:"end",fontFamily:"Arial, sans-serif",fontWeight:"700",fontSize:"7.6",fill:"#1b1b1b",children:"JS"})]}):t==="css"?g("svg",{className:"sc-lang-icon",viewBox:"0 0 16 16",width:"14",height:"14","aria-hidden":!0,children:[i("rect",{width:"16",height:"16",rx:"3",fill:"#2965f1"}),i("text",{x:"8",y:"11",textAnchor:"middle",fontFamily:"Arial, sans-serif",fontWeight:"700",fontSize:"5.6",fill:"#fff",children:"CSS"})]}):t==="liquid"?g("svg",{className:"sc-lang-icon",viewBox:"0 0 16 16",width:"14",height:"14","aria-hidden":!0,children:[i("path",{d:"M8 1.2C8 1.2 3 7 3 10.1A5 5 0 0 0 13 10.1C13 7 8 1.2 8 1.2z",fill:"#38bdf8"}),i("path",{d:"M6 10.6a2 2 0 0 0 2 2",fill:"none",stroke:"#fff",strokeWidth:"1.3",strokeLinecap:"round"})]}):null},st=({code:e,lang:t})=>{const[n,o]=L(!1),s=()=>navigator.clipboard?.writeText(e).then(()=>{o(!0),window.setTimeout(()=>o(!1),1500)},()=>{});return g("div",{className:"sc-code",children:[g("div",{className:"sc-code-bar",children:[g("span",{className:"sc-code-lang",children:[i(et,{lang:t||v(e)}),tt(t||v(e)||"")]}),i("button",{type:"button",onClick:s,children:n?"Copied":"Copy"})]}),i("pre",{children:(()=>{const r=P(e,w(t)??(t?null:v(e)));return r?i("code",{className:"sc-hl-code",dangerouslySetInnerHTML:{__html:r}}):i("code",{children:e})})()})]})},nt=e=>{const t=[];for(const n of e.split(`
2
+ `)){const o=C.test(n)?"ul":S.test(n)?"ol":"p",s=t[t.length-1];s&&s.kind===o?s.lines.push(n):t.push({kind:o,lines:[n]})}return t},_=(e,t,n)=>e.replace(/[ \t]+\n/g,`
3
+ `).replace(/^\n+|\n+$/g,"").split(/\n{2,}/).filter(o=>o.trim()).flatMap((o,s)=>nt(o).map((r,a)=>{const l=`${n}-${s}-${a}`;if(r.kind==="p")return i("p",{children:F(r.lines.join(`
4
+ `),t,l)},l);const c=r.kind,p=r.kind==="ol"?Number(/\d+/.exec(r.lines[0])?.[0]??1):void 0;return i(c,{start:p!==1?p:void 0,children:r.lines.map((m,u)=>i("li",{children:F(m.replace(r.kind==="ul"?C:S,""),t,`${l}-${u}`)},u))},l)})),M=/!\[([^\]\n]*)\]\(file:([^)\s]+)\)/g,pt=e=>new Set([...(e??"").matchAll(M)].map(t=>t[2])),dt=({text:e,inline:t=o=>o,image:n})=>{const o=e.replace(/\r\n?/g,`
5
+ `).trim(),s=[];let r=0,a=0;const l=(c,p)=>{const m=[];let u=0,d=0;for(const f of c.matchAll(M))m.push(..._(c.slice(u,f.index),t,`${p}i${d}`)),m.push(n?i("div",{className:"sc-inline-img",children:n(f[2],f[1],`${p}img${d}`)},`${p}img${d}`):g("p",{className:"sc-inline-img-name",children:["[",f[1]||"image","]"]},`${p}img${d}`)),u=f.index+f[0].length,d++;return m.push(..._(c.slice(u),t,`${p}i${d}`)),m};for(const c of o.matchAll(W)){s.push(...l(o.slice(r,c.index),`t${a}`));const p=c[2].replace(/\n$/,"");p.trim()&&s.push(i(st,{code:p,lang:c[1]},`code${a}`)),r=c.index+c[0].length,a++}return s.push(...l(o.slice(r),`t${a}`)),i("div",{className:"sc-text",children:s})};export{O as CODE_LANGUAGES,M as FILE_IMG,dt as FormattedText,et as LanguageIcon,V as LinkBadge,N as adminPath,b as appPage,w as codeLanguage,v as detectLanguage,pt as inlineFileIds,ct as isBadgeLink};
@@ -1 +1 @@
1
- import{Fragment as z,jsx as t,jsxs as n}from"react/jsx-runtime";import{useEffect as R,useState as c}from"react";import{useTranslation as A}from"./i18n.js";import{StoreAvatar as S}from"./StoreAvatar.js";import{EditIcon as I}from"./MessageActions.js";import{timeOpts as L}from"./clock.js";const T=e=>e&&/^[A-Z]{2}$/.test(e)?String.fromCodePoint(...[...e].map(o=>127462+o.charCodeAt(0)-65)):"",E=()=>{const[e,o]=c(()=>Date.now());return R(()=>{const l=window.setInterval(()=>o(Date.now()),3e4);return()=>window.clearInterval(l)},[]),e},x=({text:e})=>{const{t:o}=A("home"),[l,p]=c(!1);return t("button",{type:"button",className:"mi-copy","aria-label":o("supportChat.merchant.copy"),onClick:()=>{navigator.clipboard?.writeText(e),p(!0),window.setTimeout(()=>p(!1),1500)},children:l?t("svg",{viewBox:"0 0 20 20",width:"13",height:"13","aria-hidden":!0,children:t("path",{d:"M5 10.5l3.2 3.2L15 7",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round"})}):n("svg",{viewBox:"0 0 20 20",width:"13",height:"13","aria-hidden":!0,children:[t("rect",{x:"6.5",y:"6.5",width:"9",height:"9",rx:"2",fill:"none",stroke:"currentColor",strokeWidth:"1.6"}),t("path",{d:"M13.5 6.5V5a1.5 1.5 0 0 0-1.5-1.5H5A1.5 1.5 0 0 0 3.5 5v7A1.5 1.5 0 0 0 5 13.5h1.5",fill:"none",stroke:"currentColor",strokeWidth:"1.6"})]})})},V=({info:e,look:o,supportUrl:l,linksInHeader:p=!1,onSaveEmail:m,onMarkReview:h})=>{const{t:a,i18n:b}=A("home"),[g,d]=c(null),[s,i]=c(null),w=E(),D=e.timezone?new Date(w).toLocaleTimeString(b.language,L({timeZone:e.timezone,weekday:"short"})):null,v=e.timezone?Number(new Intl.DateTimeFormat("en-GB",{timeZone:e.timezone,hour:"2-digit"}).format(new Date(w))):null,k=v!==null&&(v>=22||v<7),y=[e.city,e.region,e.country].filter(Boolean).join(", "),N=e.firstInstallAt?new Date(e.firstInstallAt).toLocaleDateString(b.language,{day:"numeric",month:"short",year:"numeric"}):null;return n("aside",{className:"mi-panel","aria-label":a("supportChat.merchant.title"),children:[n("div",{className:"mi-hero",children:[t(S,{shop:e.shop,name:e.name??e.shop,look:{favicon:o?.favicon??e.logo??null,development:e.development,reviewed:!!e.reviewed,rating:e.reviewed?.rating??null,locked:e.passwordProtected??null},size:44}),n("div",{children:[t("strong",{children:e.name??e.shop}),e.owner&&t("span",{children:e.owner})]})]}),n("dl",{className:"mi-facts",children:[n("div",{children:[t("dt",{children:a("supportChat.merchant.domain")}),n("dd",{className:"mi-mono",children:[t("span",{children:e.shop}),t(x,{text:e.shop})]})]}),n("div",{children:[t("dt",{children:a("supportChat.merchant.location")}),t("dd",{children:y?n(z,{children:[t("span",{className:"mi-flag","aria-hidden":!0,children:T(e.countryCode)}),y]}):t("span",{className:"mi-muted",children:a("supportChat.merchant.unknown")})})]}),n("div",{children:[t("dt",{children:a("supportChat.merchant.timezone")}),t("dd",{children:e.timezone?n("span",{className:"mi-time",children:[t("b",{className:k?"mi-night":"mi-day",children:D}),t("span",{children:e.timezone.replace(/_/g," ")}),k&&t("em",{children:a("supportChat.merchant.night")})]}):t("span",{className:"mi-muted",children:a("supportChat.merchant.unknown")})})]}),n("div",{children:[t("dt",{children:a("supportChat.merchant.plan")}),n("dd",{children:[e.plan??t("span",{className:"mi-muted",children:a("supportChat.merchant.unknown")}),e.plus&&t("span",{className:"mi-tag mi-tag--plus",children:"Plus"}),e.development&&t("span",{className:"mi-tag",children:a("supportChat.merchant.dev")})]})]}),n("div",{children:[t("dt",{children:a("supportChat.merchant.app")}),t("dd",{children:e.installed?N?a("supportChat.merchant.since",{date:N}):a("supportChat.merchant.installed"):t("span",{className:"mi-tag mi-tag--gone",children:a("supportChat.merchant.uninstalled")})})]}),e.foundVia&&n("div",{children:[t("dt",{children:a("supportChat.merchant.foundVia")}),t("dd",{children:e.foundVia})]}),e.uninstallReason&&n("div",{children:[t("dt",{children:a("supportChat.merchant.uninstallReason")}),n("dd",{className:"mi-left",children:[e.uninstallReason.reason&&t("strong",{children:e.uninstallReason.reason}),e.uninstallReason.description&&t("span",{children:e.uninstallReason.description})]})]}),n("div",{children:[t("dt",{children:a("supportChat.merchant.review")}),t("dd",{children:e.reviewed?t("span",{className:"mi-tag mi-tag--ok",children:a("supportChat.merchant.reviewed",{rating:e.reviewed.rating??"?"})}):e.development?t("span",{className:"mi-muted",children:a("supportChat.merchant.cannotReview")}):s&&h?n("form",{className:"mi-review-mark",onSubmit:r=>{r.preventDefault(),s.rating&&(i({...s,busy:!0,error:null}),h(s.rating,s.body.trim()).then(()=>i(null),u=>i(C=>C&&{...C,busy:!1,error:u.message})))},children:[t("span",{className:"mi-stars",role:"radiogroup","aria-label":a("supportChat.merchant.markReviewed"),children:[1,2,3,4,5].map(r=>t("button",{type:"button",role:"radio","aria-checked":s.rating===r,"aria-label":`${r}`,className:r<=s.rating?"on":"",onClick:()=>i({...s,rating:r}),children:"\u2605"},r))}),t("textarea",{rows:2,value:s.body,placeholder:a("supportChat.merchant.reviewText"),onChange:r=>i({...s,body:r.target.value})}),s.error&&t("span",{className:"mi-review-error",children:s.error}),n("span",{className:"mi-review-actions",children:[t("button",{type:"button",onClick:()=>i(null),children:a("supportChat.msg.cancelReply")}),t("button",{type:"submit",disabled:!s.rating||s.busy,children:a("supportChat.msg.save")})]})]}):n(z,{children:[t("span",{className:"mi-muted",children:a("supportChat.merchant.notReviewed")}),h&&t("button",{type:"button",className:"mi-review-add",onClick:()=>i({rating:0,body:"",busy:!1,error:null}),children:a("supportChat.merchant.markReviewed")})]})})]}),e.otherApps&&n("div",{children:[t("dt",{children:a("supportChat.merchant.otherApps")}),t("dd",{className:"mi-apps",children:e.otherApps.length?e.otherApps.map(r=>n("span",{className:`mi-app${r.enabled?"":" mi-muted"}`,children:[r.icon?t("img",{className:"mi-app-icon",src:`${r.icon}?width=48&height=48`,alt:"",width:18,height:18,loading:"lazy"}):t("span",{className:"mi-app-icon mi-app-icon--letter","aria-hidden":!0,children:r.name.charAt(0).toUpperCase()}),t("span",{className:"mi-app-name",children:r.name})]},r.name)):t("span",{className:"mi-muted",children:a("supportChat.merchant.otherAppsNone")})})]}),(e.email||m)&&n("div",{children:[t("dt",{children:a("supportChat.merchant.email")}),g!==null&&m?t("dd",{children:n("form",{className:"mi-email-edit",onSubmit:r=>{r.preventDefault();const u=g.trim().toLowerCase();/^[^\s@<>",;]{1,64}@[^\s@<>",;]{1,190}\.[a-z]{2,}$/i.test(u)&&(m(u),d(null))},children:[t("input",{autoFocus:!0,type:"email",value:g,onChange:r=>d(r.target.value),onKeyDown:r=>r.key==="Escape"&&d(null)}),t("button",{type:"submit",children:a("supportChat.msg.save")})]})}):n("dd",{className:"mi-mono",children:[t("span",{children:e.email}),e.email&&t(x,{text:e.email}),m&&t("button",{type:"button",className:"mi-email-pen","aria-label":a("supportChat.msg.edit"),title:a("supportChat.msg.edit"),onClick:()=>d(e.email??""),children:t(I,{size:13})})]})]})]}),n("div",{className:"mi-links",children:[!p&&l&&t("a",{href:`${l}?${new URLSearchParams({switchTo:e.shop})}`,target:"_blank",rel:"noopener noreferrer",children:a("supportChat.merchant.openSupport")}),e.links.storefront&&t("a",{href:e.links.storefront,target:"_blank",rel:"noopener noreferrer",children:a("supportChat.merchant.openStore")}),t("a",{href:e.links.admin,target:"_blank",rel:"noopener noreferrer",children:a("supportChat.merchant.openAdmin")}),t("a",{href:e.links.posthog,target:"_blank",rel:"noopener noreferrer",children:a("supportChat.merchant.openPosthog")})]}),e.readError&&t("p",{className:"mi-muted mi-note",children:a("supportChat.merchant.readError")})]})};export{V as MerchantPanel};
1
+ import{Fragment as z,jsx as t,jsxs as n}from"react/jsx-runtime";import{useEffect as R,useState as c}from"react";import{useTranslation as A}from"./i18n.js";import{StoreAvatar as S}from"./StoreAvatar.js";import{EditIcon as I}from"./MessageActions.js";import{timeOpts as L}from"./clock.js";const T=e=>e&&/^[A-Z]{2}$/.test(e)?String.fromCodePoint(...[...e].map(o=>127462+o.charCodeAt(0)-65)):"",E=()=>{const[e,o]=c(()=>Date.now());return R(()=>{const l=window.setInterval(()=>o(Date.now()),3e4);return()=>window.clearInterval(l)},[]),e},x=({text:e})=>{const{t:o}=A("home"),[l,p]=c(!1);return t("button",{type:"button",className:"mi-copy","aria-label":o("supportChat.merchant.copy"),onClick:()=>{navigator.clipboard?.writeText(e),p(!0),window.setTimeout(()=>p(!1),1500)},children:l?t("svg",{viewBox:"0 0 20 20",width:"13",height:"13","aria-hidden":!0,children:t("path",{d:"M5 10.5l3.2 3.2L15 7",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round"})}):n("svg",{viewBox:"0 0 20 20",width:"13",height:"13","aria-hidden":!0,children:[t("rect",{x:"6.5",y:"6.5",width:"9",height:"9",rx:"2",fill:"none",stroke:"currentColor",strokeWidth:"1.6"}),t("path",{d:"M13.5 6.5V5a1.5 1.5 0 0 0-1.5-1.5H5A1.5 1.5 0 0 0 3.5 5v7A1.5 1.5 0 0 0 5 13.5h1.5",fill:"none",stroke:"currentColor",strokeWidth:"1.6"})]})})},V=({info:e,look:o,supportUrl:l,linksInHeader:p=!1,onSaveEmail:m,onMarkReview:h})=>{const{t:a,i18n:b}=A("home"),[g,d]=c(null),[s,i]=c(null),w=E(),D=e.timezone?new Date(w).toLocaleTimeString(b.language,L({timeZone:e.timezone,weekday:"short"})):null,v=e.timezone?Number(new Intl.DateTimeFormat("en-GB",{timeZone:e.timezone,hour:"2-digit"}).format(new Date(w))):null,k=v!==null&&(v>=22||v<7),y=[e.city,e.region,e.country].filter(Boolean).join(", "),N=e.firstInstallAt?new Date(e.firstInstallAt).toLocaleDateString(b.language,{day:"numeric",month:"short",year:"numeric"}):null;return n("aside",{className:"mi-panel","aria-label":a("supportChat.merchant.title"),children:[n("div",{className:"mi-hero",children:[t(S,{shop:e.shop,name:e.name??e.shop,look:{favicon:o?.favicon??e.logo??null,development:e.development,reviewed:!!e.reviewed,rating:e.reviewed?.rating??null,locked:e.passwordProtected??null,paying:!!e.paying},size:44}),n("div",{children:[t("strong",{children:e.name??e.shop}),e.owner&&t("span",{children:e.owner})]})]}),n("dl",{className:"mi-facts",children:[n("div",{children:[t("dt",{children:a("supportChat.merchant.domain")}),n("dd",{className:"mi-mono",children:[t("span",{children:e.shop}),t(x,{text:e.shop})]})]}),n("div",{children:[t("dt",{children:a("supportChat.merchant.location")}),t("dd",{children:y?n(z,{children:[t("span",{className:"mi-flag","aria-hidden":!0,children:T(e.countryCode)}),y]}):t("span",{className:"mi-muted",children:a("supportChat.merchant.unknown")})})]}),n("div",{children:[t("dt",{children:a("supportChat.merchant.timezone")}),t("dd",{children:e.timezone?n("span",{className:"mi-time",children:[t("b",{className:k?"mi-night":"mi-day",children:D}),t("span",{children:e.timezone.replace(/_/g," ")}),k&&t("em",{children:a("supportChat.merchant.night")})]}):t("span",{className:"mi-muted",children:a("supportChat.merchant.unknown")})})]}),n("div",{children:[t("dt",{children:a("supportChat.merchant.plan")}),n("dd",{children:[e.plan??t("span",{className:"mi-muted",children:a("supportChat.merchant.unknown")}),e.plus&&t("span",{className:"mi-tag mi-tag--plus",children:"Plus"}),e.development&&t("span",{className:"mi-tag",children:a("supportChat.merchant.dev")})]})]}),n("div",{children:[t("dt",{children:a("supportChat.merchant.app")}),t("dd",{children:e.installed?N?a("supportChat.merchant.since",{date:N}):a("supportChat.merchant.installed"):t("span",{className:"mi-tag mi-tag--gone",children:a("supportChat.merchant.uninstalled")})})]}),e.foundVia&&n("div",{children:[t("dt",{children:a("supportChat.merchant.foundVia")}),t("dd",{children:e.foundVia})]}),e.uninstallReason&&n("div",{children:[t("dt",{children:a("supportChat.merchant.uninstallReason")}),n("dd",{className:"mi-left",children:[e.uninstallReason.reason&&t("strong",{children:e.uninstallReason.reason}),e.uninstallReason.description&&t("span",{children:e.uninstallReason.description})]})]}),n("div",{children:[t("dt",{children:a("supportChat.merchant.review")}),t("dd",{children:e.reviewed?t("span",{className:"mi-tag mi-tag--ok",children:a("supportChat.merchant.reviewed",{rating:e.reviewed.rating??"?"})}):e.development?t("span",{className:"mi-muted",children:a("supportChat.merchant.cannotReview")}):s&&h?n("form",{className:"mi-review-mark",onSubmit:r=>{r.preventDefault(),s.rating&&(i({...s,busy:!0,error:null}),h(s.rating,s.body.trim()).then(()=>i(null),u=>i(C=>C&&{...C,busy:!1,error:u.message})))},children:[t("span",{className:"mi-stars",role:"radiogroup","aria-label":a("supportChat.merchant.markReviewed"),children:[1,2,3,4,5].map(r=>t("button",{type:"button",role:"radio","aria-checked":s.rating===r,"aria-label":`${r}`,className:r<=s.rating?"on":"",onClick:()=>i({...s,rating:r}),children:"\u2605"},r))}),t("textarea",{rows:2,value:s.body,placeholder:a("supportChat.merchant.reviewText"),onChange:r=>i({...s,body:r.target.value})}),s.error&&t("span",{className:"mi-review-error",children:s.error}),n("span",{className:"mi-review-actions",children:[t("button",{type:"button",onClick:()=>i(null),children:a("supportChat.msg.cancelReply")}),t("button",{type:"submit",disabled:!s.rating||s.busy,children:a("supportChat.msg.save")})]})]}):n(z,{children:[t("span",{className:"mi-muted",children:a("supportChat.merchant.notReviewed")}),h&&t("button",{type:"button",className:"mi-review-add",onClick:()=>i({rating:0,body:"",busy:!1,error:null}),children:a("supportChat.merchant.markReviewed")})]})})]}),e.otherApps&&n("div",{children:[t("dt",{children:a("supportChat.merchant.otherApps")}),t("dd",{className:"mi-apps",children:e.otherApps.length?e.otherApps.map(r=>n("span",{className:`mi-app${r.enabled?"":" mi-muted"}`,children:[r.icon?t("img",{className:"mi-app-icon",src:`${r.icon}?width=48&height=48`,alt:"",width:18,height:18,loading:"lazy"}):t("span",{className:"mi-app-icon mi-app-icon--letter","aria-hidden":!0,children:r.name.charAt(0).toUpperCase()}),t("span",{className:"mi-app-name",children:r.name})]},r.name)):t("span",{className:"mi-muted",children:a("supportChat.merchant.otherAppsNone")})})]}),(e.email||m)&&n("div",{children:[t("dt",{children:a("supportChat.merchant.email")}),g!==null&&m?t("dd",{children:n("form",{className:"mi-email-edit",onSubmit:r=>{r.preventDefault();const u=g.trim().toLowerCase();/^[^\s@<>",;]{1,64}@[^\s@<>",;]{1,190}\.[a-z]{2,}$/i.test(u)&&(m(u),d(null))},children:[t("input",{autoFocus:!0,type:"email",value:g,onChange:r=>d(r.target.value),onKeyDown:r=>r.key==="Escape"&&d(null)}),t("button",{type:"submit",children:a("supportChat.msg.save")})]})}):n("dd",{className:"mi-mono",children:[t("span",{children:e.email}),e.email&&t(x,{text:e.email}),m&&t("button",{type:"button",className:"mi-email-pen","aria-label":a("supportChat.msg.edit"),title:a("supportChat.msg.edit"),onClick:()=>d(e.email??""),children:t(I,{size:13})})]})]})]}),n("div",{className:"mi-links",children:[!p&&l&&t("a",{href:`${l}?${new URLSearchParams({switchTo:e.shop})}`,target:"_blank",rel:"noopener noreferrer",children:a("supportChat.merchant.openSupport")}),e.links.storefront&&t("a",{href:e.links.storefront,target:"_blank",rel:"noopener noreferrer",children:a("supportChat.merchant.openStore")}),t("a",{href:e.links.admin,target:"_blank",rel:"noopener noreferrer",children:a("supportChat.merchant.openAdmin")}),t("a",{href:e.links.posthog,target:"_blank",rel:"noopener noreferrer",children:a("supportChat.merchant.openPosthog")})]}),e.readError&&t("p",{className:"mi-muted mi-note",children:a("supportChat.merchant.readError")})]})};export{V as MerchantPanel};
@@ -1 +1 @@
1
- import{jsx as e,jsxs as o}from"react/jsx-runtime";import{useEffect as b,useRef as I,useState as d,useMemo as O}from"react";import{useTranslation as q}from"./i18n.js";import{copyToClipboard as E}from"./copyToClipboard.js";import{APP_STORE_REVIEW_URL as u}from"@whoa-chat/core/types";import{awayDetail as U,watchReviewAway as B}from"@whoa-chat/core/reviewAway";import{AgentAvatar as F}from"./agents.js";import{brandVars as V,chatHost as C}from"./host.js";const W=new Set(["already-open","open-in-progress"]),k="M11.128 4.123c-.453-.95-1.803-.95-2.256 0l-1.39 2.912-3.199.421c-1.042.138-1.46 1.422-.697 2.146l2.34 2.222-.587 3.172c-.192 1.034.901 1.828 1.825 1.327l2.836-1.54 2.836 1.54c.924.501 2.017-.293 1.825-1.327l-.587-3.172 2.34-2.222c.762-.724.345-2.008-.697-2.146l-3.2-.421-1.389-2.912Z",j=async()=>{let r="error";try{r=(await shopify.reviews.request()).code}catch{}return W.has(r)?null:r!=="success"&&r!=="cancelled"?(window.open(u,"_blank","noopener"),"app-store"):r},z=async r=>{const a=Date.now(),s=await j();return r&&(s==="success"||s==="app-store")&&B(s==="app-store"?"tab":"dialog",c=>r(U(c)),{startedAt:a,answerMs:Date.now()-a}),s},H=()=>e("svg",{viewBox:"0 0 24 24",width:"13",height:"13","aria-hidden":!0,children:e("path",{className:"srv-check-path",d:"M5 12.5l4.2 4.2L19 7",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round"})}),G=({rating:r})=>e("span",{className:"srv-stars","aria-hidden":!0,children:[1,2,3,4,5].map(a=>o("svg",{viewBox:"0 0 20 20",width:"15",height:"15",style:{animationDelay:`${.25+a*.07}s`},children:[e("defs",{children:e("clipPath",{id:`srv-star-${a}`,children:e("rect",{x:"0",y:"0",width:20*Math.max(0,Math.min(1,r-a+1)),height:"20"})})}),e("path",{d:k,fill:"#e3e3e3",transform:"translate(-0.5 -0.6) scale(1.1)"}),e("path",{d:k,fill:"#ffb21e",clipPath:`url(#srv-star-${a})`,transform:"translate(-0.5 -0.6) scale(1.1)"})]},a))}),y=["#7c5cff","#29b6f6","#f5a623","#22c55e","#ff5c8a","#ffd23f"],Z=()=>{const r=O(()=>Array.from({length:70},(a,s)=>({left:Math.random()*100,drift:(Math.random()-.5)*140,spin:(Math.random()-.5)*900,delay:Math.random()*.35,duration:1.6+Math.random()*1.1,colour:y[s%y.length],round:s%3===0})),[]);return e("div",{className:"srv-confetti","aria-hidden":!0,children:r.map((a,s)=>e("i",{className:a.round?"srv-confetti-dot":void 0,style:{left:`${a.left}%`,background:a.colour,animationDelay:`${a.delay}s`,animationDuration:`${a.duration}s`,"--drift":`${a.drift}px`,"--spin":`${a.spin}deg`}},s))})},ae=({message:r,shopOwnerName:a,listing:s,preview:c,onState:v,onAway:S})=>{const{t,i18n:L}=q("home"),i=r.review,l=r.agentName??"Stefan",[m,h]=d(i.state),[x,f]=d(!1),[M,R]=d(!1),[A,P]=d(!1),w=I(!1);b(()=>h(i.state),[i.state]),b(()=>{c||w.current||i.state!=="sent"||(w.current=!0,v?.("seen"))},[c,i.state,v]);const g=(n,p)=>{h(n),v?.(n,p)},_=async()=>{if(c)return;const n=await z(S);n!==null&&(n==="app-store"&&R(!0),P(!0),g("clicked",n))},D=async()=>{c||(await E(u),f(!0),window.setTimeout(()=>f(!1),2500))},N=a?.split(" ")[0],T=s?new Intl.NumberFormat(L.language,{minimumFractionDigits:1,maximumFractionDigits:1}).format(s.rating):null;return m==="clicked"?o("div",{className:"srv-card srv-card--thanks",role:"status",children:[A&&e(Z,{}),e("img",{className:"srv-thanks-logo",src:C().brand.logo,alt:"",width:52,height:52}),e("p",{className:"srv-thanks-title",children:N?t("supportChat.review.thanksNamed",{name:N}):t("supportChat.review.thanks")}),e("p",{className:"srv-thanks-copy",children:t("supportChat.review.thanksCopy",{agent:l})}),e("a",{className:"srv-link",href:u,target:"_blank",rel:"noopener noreferrer",children:t(M?"supportChat.review.openListing":"supportChat.review.openAgain")})]}):m==="issue"?e("div",{className:"srv-card srv-card--quiet",role:"status",children:e("p",{className:"srv-quiet",children:t("supportChat.review.issueAck",{agent:l})})}):m==="dismissed"?e("div",{className:"srv-card srv-card--quiet",children:o("p",{className:"srv-quiet",children:[t("supportChat.review.dismissedAck")," ",e("button",{type:"button",className:"srv-link",onClick:()=>g("seen"),children:t("supportChat.review.showAgain")})]})}):o("article",{className:`srv-card${c?" srv-card--preview":""}`,"aria-label":t("supportChat.review.label"),children:[o("div",{className:"srv-hero",children:[e("span",{className:"srv-blob srv-blob--a","aria-hidden":!0}),e("span",{className:"srv-blob srv-blob--b","aria-hidden":!0}),e("img",{className:"srv-logo",src:C().brand.logo,alt:"",width:56,height:56}),o("div",{className:"srv-app",children:[e("strong",{children:t("supportChat.review.appName",V())}),s?o("span",{className:"srv-rating",children:[e(G,{rating:s.rating}),e("b",{children:T}),e("span",{children:t("supportChat.review.reviewCount",{count:s.reviewCount})})]}):e("span",{className:"srv-rating",children:t("supportChat.review.onAppStore")})]})]}),o("div",{className:"srv-body",children:[i.fixed&&o("div",{className:"srv-fixed",children:[e("span",{className:"srv-check",children:e(H,{})}),o("div",{className:"srv-fixed-main",children:[e("span",{className:"srv-eyebrow",children:t("supportChat.review.fixedBy",{agent:l})}),e("p",{className:"srv-fixed-text",children:i.fixed})]}),e("span",{className:"srv-agent-ring",children:e(F,{name:l,size:40})})]}),i.beforeImageUrl&&i.afterImageUrl&&e("div",{className:"srv-ba",children:[[i.beforeImageUrl,t("supportChat.review.before")],[i.afterImageUrl,t("supportChat.review.after")]].map(([n,p],$)=>o("a",{className:`srv-shot${$?" srv-shot--after":""}`,href:n,target:"_blank",rel:"noopener noreferrer",children:[e("img",{src:n,alt:p,loading:"lazy"}),e("span",{children:p})]},p))}),e("h3",{className:"srv-title",children:i?.title||t("supportChat.review.title")}),e("p",{className:"srv-copy",children:i?.ask||t("supportChat.review.body")}),o("button",{type:"button",className:"srv-primary","data-card-action":"review_clicked",onClick:_,disabled:c,children:[e("span",{children:t("supportChat.review.cta")}),e("span",{className:"srv-primary-icon","aria-hidden":!0,children:e("svg",{viewBox:"0 0 20 20",width:"12",height:"12",children:e("path",{d:"M7 13l6-6M8 7h5v5",fill:"none",stroke:"currentColor",strokeWidth:"2.4",strokeLinecap:"round",strokeLinejoin:"round"})})})]}),e("p",{className:"srv-time",children:s?t("supportChat.review.joinOthers",{count:s.reviewCount}):t("supportChat.review.time")})]}),o("footer",{className:"srv-owner",children:[e("span",{children:t("supportChat.review.ownerOnly")}),e("button",{type:"button",className:"srv-link",onClick:D,children:t(x?"supportChat.review.copied":"supportChat.review.copyLink")})]})]})};export{ae as ReviewCard,j as requestReview,z as requestReviewTimed};
1
+ import{jsx as e,jsxs as i}from"react/jsx-runtime";import{useEffect as b,useRef as I,useState as d,useMemo as O}from"react";import{useTranslation as q}from"./i18n.js";import{copyToClipboard as E}from"./copyToClipboard.js";import{APP_STORE_REVIEW_URL as u}from"@whoa-chat/core/types";import{awayDetail as U,watchReviewAway as B}from"@whoa-chat/core/reviewAway";import{AgentAvatar as F}from"./agents.js";import{brandVars as V,chatHost as C}from"./host.js";const W=new Set(["already-open","open-in-progress"]),k="M11.128 4.123c-.453-.95-1.803-.95-2.256 0l-1.39 2.912-3.199.421c-1.042.138-1.46 1.422-.697 2.146l2.34 2.222-.587 3.172c-.192 1.034.901 1.828 1.825 1.327l2.836-1.54 2.836 1.54c.924.501 2.017-.293 1.825-1.327l-.587-3.172 2.34-2.222c.762-.724.345-2.008-.697-2.146l-3.2-.421-1.389-2.912Z",j=async()=>{let r="error";try{r=(await shopify.reviews.request()).code}catch{}return W.has(r)?null:r!=="success"&&r!=="cancelled"?(window.open(u,"_blank","noopener"),"app-store"):r},z=async r=>{const a=Date.now(),s=await j();return r&&(s==="success"||s==="app-store")&&B(s==="app-store"?"tab":"dialog",c=>r(U(c)),{startedAt:a,answerMs:Date.now()-a}),s},H=()=>e("svg",{viewBox:"0 0 24 24",width:"10",height:"10","aria-hidden":!0,children:e("path",{className:"srv-check-path",d:"M5 12.5l4.2 4.2L19 7",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round"})}),G=({rating:r})=>e("span",{className:"srv-stars","aria-hidden":!0,children:[1,2,3,4,5].map(a=>i("svg",{viewBox:"0 0 20 20",width:"15",height:"15",style:{animationDelay:`${.25+a*.07}s`},children:[e("defs",{children:e("clipPath",{id:`srv-star-${a}`,children:e("rect",{x:"0",y:"0",width:20*Math.max(0,Math.min(1,r-a+1)),height:"20"})})}),e("path",{d:k,fill:"#e3e3e3",transform:"translate(-0.5 -0.6) scale(1.1)"}),e("path",{d:k,fill:"#ffb21e",clipPath:`url(#srv-star-${a})`,transform:"translate(-0.5 -0.6) scale(1.1)"})]},a))}),y=["#7c5cff","#29b6f6","#f5a623","#22c55e","#ff5c8a","#ffd23f"],Z=()=>{const r=O(()=>Array.from({length:70},(a,s)=>({left:Math.random()*100,drift:(Math.random()-.5)*140,spin:(Math.random()-.5)*900,delay:Math.random()*.35,duration:1.6+Math.random()*1.1,colour:y[s%y.length],round:s%3===0})),[]);return e("div",{className:"srv-confetti","aria-hidden":!0,children:r.map((a,s)=>e("i",{className:a.round?"srv-confetti-dot":void 0,style:{left:`${a.left}%`,background:a.colour,animationDelay:`${a.delay}s`,animationDuration:`${a.duration}s`,"--drift":`${a.drift}px`,"--spin":`${a.spin}deg`}},s))})},ae=({message:r,shopOwnerName:a,listing:s,preview:c,onState:v,onAway:S})=>{const{t,i18n:L}=q("home"),o=r.review,l=r.agentName??"Stefan",[m,h]=d(o.state),[x,f]=d(!1),[M,R]=d(!1),[A,P]=d(!1),w=I(!1);b(()=>h(o.state),[o.state]),b(()=>{c||w.current||o.state!=="sent"||(w.current=!0,v?.("seen"))},[c,o.state,v]);const g=(n,p)=>{h(n),v?.(n,p)},_=async()=>{if(c)return;const n=await z(S);n!==null&&(n==="app-store"&&R(!0),P(!0),g("clicked",n))},D=async()=>{c||(await E(u),f(!0),window.setTimeout(()=>f(!1),2500))},N=a?.split(" ")[0],T=s?new Intl.NumberFormat(L.language,{minimumFractionDigits:1,maximumFractionDigits:1}).format(s.rating):null;return m==="clicked"?i("div",{className:"srv-card srv-card--thanks",role:"status",children:[A&&e(Z,{}),e("img",{className:"srv-thanks-logo",src:C().brand.logo,alt:"",width:52,height:52}),e("p",{className:"srv-thanks-title",children:N?t("supportChat.review.thanksNamed",{name:N}):t("supportChat.review.thanks")}),e("p",{className:"srv-thanks-copy",children:t("supportChat.review.thanksCopy",{agent:l})}),e("a",{className:"srv-link",href:u,target:"_blank",rel:"noopener noreferrer",children:t(M?"supportChat.review.openListing":"supportChat.review.openAgain")})]}):m==="issue"?e("div",{className:"srv-card srv-card--quiet",role:"status",children:e("p",{className:"srv-quiet",children:t("supportChat.review.issueAck",{agent:l})})}):m==="dismissed"?e("div",{className:"srv-card srv-card--quiet",children:i("p",{className:"srv-quiet",children:[t("supportChat.review.dismissedAck")," ",e("button",{type:"button",className:"srv-link",onClick:()=>g("seen"),children:t("supportChat.review.showAgain")})]})}):i("article",{className:`srv-card${c?" srv-card--preview":""}`,"aria-label":t("supportChat.review.label"),children:[i("div",{className:"srv-hero",children:[e("span",{className:"srv-blob srv-blob--a","aria-hidden":!0}),e("span",{className:"srv-blob srv-blob--b","aria-hidden":!0}),e("img",{className:"srv-logo",src:C().brand.logo,alt:"",width:56,height:56}),i("div",{className:"srv-app",children:[e("strong",{children:t("supportChat.review.appName",V())}),s?i("span",{className:"srv-rating",children:[e(G,{rating:s.rating}),e("b",{children:T}),e("span",{children:t("supportChat.review.reviewCount",{count:s.reviewCount})})]}):e("span",{className:"srv-rating",children:t("supportChat.review.onAppStore")})]})]}),i("div",{className:"srv-body",children:[o.fixed&&i("div",{className:"srv-fixed",children:[i("span",{className:"srv-agent-ring",children:[e(F,{name:l,size:36}),e("span",{className:"srv-check",children:e(H,{})})]}),i("div",{className:"srv-fixed-main",children:[e("span",{className:"srv-eyebrow",children:t("supportChat.review.fixedBy",{agent:l})}),e("p",{className:"srv-fixed-text",children:o.fixed})]})]}),o.beforeImageUrl&&o.afterImageUrl&&e("div",{className:"srv-ba",children:[[o.beforeImageUrl,t("supportChat.review.before")],[o.afterImageUrl,t("supportChat.review.after")]].map(([n,p],$)=>i("a",{className:`srv-shot${$?" srv-shot--after":""}`,href:n,target:"_blank",rel:"noopener noreferrer",children:[e("img",{src:n,alt:p,loading:"lazy"}),e("span",{children:p})]},p))}),e("h3",{className:"srv-title",children:o?.title||t("supportChat.review.title")}),e("p",{className:"srv-copy",children:o?.ask||t("supportChat.review.body")}),i("button",{type:"button",className:"srv-primary","data-card-action":"review_clicked",onClick:_,disabled:c,children:[e("span",{children:t("supportChat.review.cta")}),e("span",{className:"srv-primary-icon","aria-hidden":!0,children:e("svg",{viewBox:"0 0 20 20",width:"12",height:"12",children:e("path",{d:"M7 13l6-6M8 7h5v5",fill:"none",stroke:"currentColor",strokeWidth:"2.4",strokeLinecap:"round",strokeLinejoin:"round"})})})]}),e("p",{className:"srv-time",children:s?t("supportChat.review.joinOthers",{count:s.reviewCount}):t("supportChat.review.time")})]}),i("footer",{className:"srv-owner",children:[e("span",{children:t("supportChat.review.ownerOnly")}),e("button",{type:"button",className:"srv-link",onClick:D,children:t(x?"supportChat.review.copied":"supportChat.review.copyLink")})]})]})};export{ae as ReviewCard,j as requestReview,z as requestReviewTimed};
@@ -5,6 +5,7 @@ export type StoreLook = {
5
5
  reviewed?: boolean;
6
6
  rating?: number | null;
7
7
  locked?: boolean | null;
8
+ paying?: boolean;
8
9
  uninstalled?: boolean;
9
10
  collaborator?: boolean;
10
11
  };
@@ -15,6 +16,7 @@ export declare const lookFrom: (info: {
15
16
  rating: number | null;
16
17
  } | null;
17
18
  passwordProtected?: boolean | null;
19
+ paying?: boolean | null;
18
20
  logo?: string | null;
19
21
  installed?: boolean;
20
22
  } | null | undefined) => StoreLook | null;
@@ -1 +1 @@
1
- import{jsx as e,jsxs as L}from"react/jsx-runtime";import{STORE_THREAD as m}from"@whoa-chat/core/conversation";import{useState as w}from"react";const y=n=>n?{uninstalled:n.installed===!1,favicon:n.logo??null,development:!!n.development,reviewed:!!n.reviewed,rating:n.reviewed?.rating??null,locked:n.passwordProtected??null}:null,c=["#ff6b2c","#f2506a","#e040c8","#a53af0","#4f7cff","#12a150","#f5a524","#0ea5a4"],b=n=>c[[...n].reduce((l,t)=>l*31+t.charCodeAt(0)>>>0,7)%c.length],S=n=>n.replace(/\.myshopify\.com(~[a-z0-9]+)?$/,"").split(/[\s._-]+/).filter(Boolean).slice(0,2).map(l=>l[0].toUpperCase()).join("")||"?",B=({dev:n})=>e("img",{className:"st-bag",src:n?"/support/shopify-dev.png":"/support/shopify.svg",alt:""}),N=({shop:n,name:l,look:t,size:i=40,flag:o=null,online:u=!1,status:r=null})=>{const[p,g]=w(!1),v=!!(n&&m.test(n)),a=!!t?.development,f=t?.favicon&&!p?e("img",{src:t.favicon,alt:"",onError:()=>g(!0)}):v?e(B,{dev:a}):e("span",{className:"st-initials",style:{background:b(l||n||"?"),fontSize:i*.38},children:S(l||n||"?")}),s=t?.reviewed?t.rating!==null&&t.rating!==void 0&&t.rating<=3?"low":"gold":null,h=[t?.uninstalled?"Uninstalled":null,t?.reviewed?`Reviewed${t.rating?` \u2605 ${t.rating}`:""}`:null,t?.collaborator?"Collaborator access":null,a?"Development store":t?.locked?"Password protected":null,r?.label??null].filter(Boolean),d=r&&!t?.uninstalled?{good:"done",partial:"half",none:"none"}[r.tone]:null;return L("span",{className:`st-avatar${t?.uninstalled?" st-avatar--gone":""}${a?" st-avatar--dev":""}${s?` st-avatar--ring-${s}`:""}`,style:{width:i,height:i},title:h.join(" \xB7 ")||void 0,children:[f,u&&e("i",{className:"st-online",title:"Online now","aria-label":"Online now"}),d&&e("i",{className:`st-setup st-setup--${d}`,"aria-hidden":!0,children:d==="done"&&e("svg",{viewBox:"0 0 16 16",width:"7",height:"7",children:e("path",{d:"M3.5 8.5 6.5 11.5 12.5 4.5",fill:"none",stroke:"#fff",strokeWidth:"2.4",strokeLinecap:"round",strokeLinejoin:"round"})})}),o&&e("i",{className:"st-flag",title:o.title,"aria-label":o.title,children:o.code?e("img",{src:`https://flagcdn.com/${o.code.toLowerCase()}.svg`,alt:""}):e("span",{children:o.emoji})}),s?e("i",{className:`st-star${s==="low"?" st-star--low":""}`,children:e("svg",{viewBox:"0 0 16 16","aria-hidden":!0,children:e("path",{d:"M8 1.5l1.9 4.1 4.5.5-3.3 3.1.9 4.4L8 11.4l-4 2.2.9-4.4-3.3-3.1 4.5-.5z",fill:"#fff"})})}):a?e("i",{className:"st-code",children:e("svg",{viewBox:"0 0 16 16",width:"7",height:"7","aria-hidden":!0,children:e("path",{d:"M5.5 4.5 2 8l3.5 3.5M10.5 4.5 14 8l-3.5 3.5",fill:"none",stroke:"#fff",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}):t?.locked?e("i",{className:"st-lock",children:e("svg",{viewBox:"0 0 16 16",width:"6.5",height:"6.5","aria-hidden":!0,children:e("path",{d:"M4.5 7V5.5a3.5 3.5 0 0 1 7 0V7M3.5 7h9v7h-9z",fill:"none",stroke:"#fff",strokeWidth:"1.8",strokeLinejoin:"round"})})}):null]})};export{N as StoreAvatar,y as lookFrom};
1
+ import{jsx as e,jsxs as S}from"react/jsx-runtime";import{STORE_THREAD as m}from"@whoa-chat/core/conversation";import{useState as w}from"react";const N=t=>t?{uninstalled:t.installed===!1,favicon:t.logo??null,development:!!t.development,reviewed:!!t.reviewed,rating:t.reviewed?.rating??null,locked:t.passwordProtected??null,paying:!!t.paying}:null,c=["#ff6b2c","#f2506a","#e040c8","#a53af0","#4f7cff","#12a150","#f5a524","#0ea5a4"],b=t=>c[[...t].reduce((l,n)=>l*31+n.charCodeAt(0)>>>0,7)%c.length],y=t=>t.replace(/\.myshopify\.com(~[a-z0-9]+)?$/,"").split(/[\s._-]+/).filter(Boolean).slice(0,2).map(l=>l[0].toUpperCase()).join("")||"?",B=({dev:t})=>e("img",{className:"st-bag",src:t?"/support/shopify-dev.png":"/support/shopify.svg",alt:""}),k=({shop:t,name:l,look:n,size:i=40,flag:a=null,online:u=!1,status:r=null})=>{const[p,g]=w(!1),v=!!(t&&m.test(t)),o=!!n?.development,f=n?.favicon&&!p?e("img",{src:n.favicon,alt:"",onError:()=>g(!0)}):v?e(B,{dev:o}):e("span",{className:"st-initials",style:{background:b(l||t||"?"),fontSize:i*.38},children:y(l||t||"?")}),s=n?.reviewed?n.rating!==null&&n.rating!==void 0&&n.rating<=3?"low":"gold":null,h=[n?.uninstalled?"Uninstalled":null,n?.paying?"Paying":null,n?.reviewed?`Reviewed${n.rating?` \u2605 ${n.rating}`:""}`:null,n?.collaborator?"Collaborator access":null,o?"Development store":n?.locked?"Password protected":null,r?.label??null].filter(Boolean),d=r&&!n?.uninstalled?{good:"done",partial:"half",none:"none"}[r.tone]:null;return S("span",{className:`st-avatar${n?.uninstalled?" st-avatar--gone":""}${o?" st-avatar--dev":""}${s?` st-avatar--ring-${s}`:""}`,style:{width:i,height:i},title:h.join(" \xB7 ")||void 0,children:[f,u&&e("i",{className:"st-online",title:"Online now","aria-label":"Online now"}),d&&e("i",{className:`st-setup st-setup--${d}`,"aria-hidden":!0,children:d==="done"&&e("svg",{viewBox:"0 0 16 16",width:"7",height:"7",children:e("path",{d:"M3.5 8.5 6.5 11.5 12.5 4.5",fill:"none",stroke:"#fff",strokeWidth:"2.4",strokeLinecap:"round",strokeLinejoin:"round"})})}),a&&e("i",{className:"st-flag",title:a.title,"aria-label":a.title,children:a.code?e("img",{src:`https://flagcdn.com/${a.code.toLowerCase()}.svg`,alt:""}):e("span",{children:a.emoji})}),n?.paying?e("i",{className:`st-cash${n.reviewed?" st-cash--gold":""}`,children:e("svg",{viewBox:"0 0 16 16","aria-hidden":!0,children:e("path",{d:"M10.5 5.2c-.5-.8-1.4-1.2-2.5-1.2-1.4 0-2.4.7-2.4 1.8 0 2.4 5 1.3 5 3.9 0 1.1-1 1.9-2.6 1.9-1.2 0-2.1-.5-2.6-1.3M8 2.5v11",fill:"none",stroke:"#fff",strokeWidth:"1.8",strokeLinecap:"round"})})}):s?e("i",{className:`st-star${s==="low"?" st-star--low":""}`,children:e("svg",{viewBox:"0 0 16 16","aria-hidden":!0,children:e("path",{d:"M8 1.5l1.9 4.1 4.5.5-3.3 3.1.9 4.4L8 11.4l-4 2.2.9-4.4-3.3-3.1 4.5-.5z",fill:"#fff"})})}):o?e("i",{className:"st-code",children:e("svg",{viewBox:"0 0 16 16",width:"7",height:"7","aria-hidden":!0,children:e("path",{d:"M5.5 4.5 2 8l3.5 3.5M10.5 4.5 14 8l-3.5 3.5",fill:"none",stroke:"#fff",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}):n?.locked?e("i",{className:"st-lock",children:e("svg",{viewBox:"0 0 16 16",width:"6.5",height:"6.5","aria-hidden":!0,children:e("path",{d:"M4.5 7V5.5a3.5 3.5 0 0 1 7 0V7M3.5 7h9v7h-9z",fill:"none",stroke:"#fff",strokeWidth:"1.8",strokeLinejoin:"round"})})}):null]})};export{k as StoreAvatar,N as lookFrom};