@maebgch/rcs-emulator 0.1.6 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/rcs-emulator.cjs.js +132 -132
- package/dist/rcs-emulator.cjs.js.map +1 -1
- package/dist/rcs-emulator.es.js +2189 -1781
- package/dist/rcs-emulator.es.js.map +1 -1
- package/package.json +1 -1
package/dist/rcs-emulator.cjs.js
CHANGED
|
@@ -1,214 +1,214 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),l=require("react");function W(n){return"reply"in n}function C(n){return"action"in n}function te(n){if(!C(n))return!1;const{urlAction:t}=n.action;return t?.openUrl?.application==="WEBVIEW"}function P(n){const{urlAction:t}=n.action;return t?.openUrl?.application==="WEBVIEW"?t.openUrl:null}const se={name:"Business",verified:!1},ne={currentMessageId:null,chatHistory:[],isTyping:!1,error:null},G=l.createContext(null);function F({children:n,theme:t,device:s,businessInfo:r,state:o,showSuggestions:a,isProfileOpen:i,toggleProfile:u,onReply:c,onAction:d,webView:h,openWebView:m,closeWebView:y}){const g={theme:t,device:s,businessInfo:{...se,...r},state:{...ne,...o},showSuggestions:a,isProfileOpen:i,toggleProfile:u,handleReply:c,handleAction:d,webView:h,openWebView:m,closeWebView:y};return e.jsx(G.Provider,{value:g,children:n})}function v(){const n=l.useContext(G);if(!n)throw new Error("useEmulator must be used within an EmulatorProvider");return n}function q(n){const t=Object.values(n.messages);return t.find(s=>s.is_first)||t[0]||null}function S(n,t){return n.messages[t]||null}function V(n,t){const s=n.responses?.keyword?.keyword_response?.choices;return s&&s[t]?.next_message||null}function T(n,t){const s=n.parts,r=re(s),o=ie(s);return{id:`${n.id}-${t}-${Date.now()}`,sender:"business",content:r,timestamp:Date.now(),suggestions:o}}function re(n){for(const t of n){const s=t.RCSMessage;if(s.textMessage)return{type:"text",text:s.textMessage};const r=s.richcardMessage?.message?.generalPurposeCard;if(r)return{type:"richcard",card:H(r.content,r.layout)};const o=s.richcardMessage?.message?.generalPurposeCardCarousel;if(o)return{type:"carousel",cards:o.content.map(a=>H(a,{cardOrientation:"VERTICAL",cardWidth:o.layout.cardWidth}))}}return{type:"text",text:"[Unsupported message type]"}}function H(n,t){const s=()=>{if(n.media){if(n.media.mediaUrl)return n.media.mediaUrl;if(n.media.contentInfo?.fileUrl)return n.media.contentInfo.fileUrl}},r=()=>{if(n.media){if(n.media.thumbnailUri)return n.media.thumbnailUri;if(n.media.contentInfo?.thumbnailUrl)return n.media.contentInfo.thumbnailUrl}},o=s();return{title:n.title,description:n.description,media:o?{url:o,height:oe(n.media?.height||"MEDIUM_HEIGHT"),thumbnailUrl:r()}:void 0,suggestions:n.suggestions,layout:{orientation:t.cardOrientation==="HORIZONTAL"?"horizontal":"vertical",width:t.cardWidth==="SMALL_WIDTH"?"small":"medium",imageAlignment:t.imageAlignment==="RIGHT"?"right":"left"}}}function oe(n){switch(n){case"SHORT_HEIGHT":return"short";case"TALL_HEIGHT":return"tall";default:return"medium"}}function ie(n){const t=[];for(const s of n){const r=s.RCSMessage;r.suggestedChipList?.suggestions&&t.push(...r.suggestedChipList.suggestions)}return t}function ae(n){return{id:`user-${Date.now()}`,sender:"user",content:{type:"userReply",text:n},timestamp:Date.now()}}function J(n){if(!n||typeof n!="object")return!1;const t=n;if(typeof t.name!="string"||!t.messages||typeof t.messages!="object")return!1;const s=Object.values(t.messages);if(s.length===0)return!1;for(const r of s){if(!r||typeof r!="object")return!1;const o=r;if(typeof o.id!="string"||!Array.isArray(o.parts))return!1}return!0}function Y(n){const t=q(n);if(!t||!t.parts.length)return"New message";const r=t.parts[0].RCSMessage;if(r.textMessage)return r.textMessage.slice(0,50)+(r.textMessage.length>50?"...":"");const o=r.richcardMessage?.message?.generalPurposeCard;if(o?.content.title)return o.content.title;const a=r.richcardMessage?.message?.generalPurposeCardCarousel;return a?.content[0]?.title?a.content[0].title:"New message"}const Q={currentMessageId:null,chatHistory:[],isTyping:!1,error:null};function le(n,t){switch(t.type){case"INIT":return{...n,currentMessageId:t.messageId,error:null};case"ADD_BUSINESS_MESSAGE":return{...n,chatHistory:[...n.chatHistory,t.message],isTyping:!1};case"ADD_USER_REPLY":{const s=ae(t.text),r=n.chatHistory.map((o,a)=>a===n.chatHistory.length-1?{...o,suggestions:void 0}:o);return{...n,chatHistory:[...r,s]}}case"SET_TYPING":return{...n,isTyping:t.isTyping};case"NAVIGATE_TO":return{...n,currentMessageId:t.messageId};case"SET_ERROR":return{...n,error:t.error,isTyping:!1};case"RESET":return Q;default:return n}}function ce({flow:n,onUserReply:t,typingDelay:s=800}){const[r,o]=l.useReducer(le,Q),a=l.useRef(0),i=l.useRef(!1);l.useEffect(()=>{if(i.current)return;i.current=!0;const h=q(n);if(!h){o({type:"SET_ERROR",error:"No first message found in conversation flow"});return}o({type:"INIT",messageId:h.id});const m=T(h,a.current++);o({type:"ADD_BUSINESS_MESSAGE",message:m})},[n]);const u=l.useCallback(h=>{if(!W(h))return;const{displayText:m,postback:y}=h.reply,g=y.data;o({type:"ADD_USER_REPLY",text:m,postbackData:g});const k={type:"reply",postbackData:g,displayText:m,timestamp:Date.now()};t(k);const p=r.currentMessageId?S(n,r.currentMessageId):null;if(!p){o({type:"SET_ERROR",error:"Current message not found"});return}const f=V(p,g);if(!f)return;const b=S(n,f);if(!b){o({type:"SET_ERROR",error:`Next message "${f}" not found`});return}o({type:"SET_TYPING",isTyping:!0}),o({type:"NAVIGATE_TO",messageId:f}),setTimeout(()=>{const x=T(b,a.current++);o({type:"ADD_BUSINESS_MESSAGE",message:x})},s)},[n,r.currentMessageId,t,s]),c=l.useCallback(h=>{if(!C(h))return;const{displayText:m,postback:y,openUrlAction:g,dialAction:k,dialerAction:p,mapAction:f,viewLocationAction:b}=h.action,x=y.data,j=k?.phoneNumber||p?.dialPhoneNumber?.phoneNumber,N=f?.showLocation?.location||b?.latLong;let M;g?M={type:"openUrl",url:g.url}:j?M={type:"dial",phoneNumber:j}:N&&(M={type:"viewLocation",latitude:N.latitude,longitude:N.longitude,query:b?.query});const w={type:"action",postbackData:x,displayText:m,timestamp:Date.now(),actionData:M};if(t(w),g)window.open(g.url,"_blank","noopener,noreferrer");else if(j)window.location.href=`tel:${j}`;else if(N){const z=f?.showLocation?.location?.label||b?.label||"",I=`https://www.google.com/maps/search/?api=1&query=${N.latitude},${N.longitude}${z?`&query_place_id=${encodeURIComponent(z)}`:""}`;window.open(I,"_blank","noopener,noreferrer")}const L=r.currentMessageId?S(n,r.currentMessageId):null;if(L){const z=V(L,x);if(z){const I=S(n,z);I&&(o({type:"ADD_USER_REPLY",text:m,postbackData:x}),o({type:"SET_TYPING",isTyping:!0}),o({type:"NAVIGATE_TO",messageId:z}),setTimeout(()=>{const ee=T(I,a.current++);o({type:"ADD_BUSINESS_MESSAGE",message:ee})},s))}}},[n,r.currentMessageId,t,s]),d=l.useCallback(()=>{i.current=!1,a.current=0,o({type:"RESET"})},[]);return{state:r,handleReply:u,handleAction:c,reset:d}}function X(n){const[t,s]=l.useState(null),[r,o]=l.useState(!1),[a,i]=l.useState(null),u=l.useCallback(async()=>{if(!n){s(null),i(null);return}o(!0),i(null);try{const c=await fetch(n,{method:"GET",headers:{Accept:"application/json"}});if(!c.ok)throw new Error(`HTTP ${c.status}: ${c.statusText}`);const d=await c.json();if(!d||typeof d!="object")throw new Error("Invalid JSON: Expected an object");if(!d.messages||typeof d.messages!="object")throw new Error("Invalid RBM JSON: Missing 'messages' object");s(d)}catch(c){const d=c instanceof Error?c.message:"Failed to fetch JSON";i(d),s(null)}finally{o(!1)}},[n]);return l.useEffect(()=>{u()},[u]),{data:t,isLoading:r,error:a,refetch:u}}function de(n){const t=l.useRef(null);return l.useEffect(()=>{t.current&&t.current.scrollTo({top:t.current.scrollHeight,behavior:"smooth"})},[n]),t}const ue=l.memo(function(){const{theme:t,businessInfo:s,toggleProfile:r}=v(),o=t==="dark",a=s.brandColor||"#0084ff";return e.jsxs("header",{className:`
|
|
2
2
|
flex items-center gap-3 px-3 py-2.5 border-b
|
|
3
|
-
${
|
|
4
|
-
`,
|
|
3
|
+
${o?"bg-zinc-900 border-zinc-800":"bg-white border-gray-100"}
|
|
4
|
+
`,role:"banner","aria-label":`Chat with ${s.name}`,children:[e.jsx("button",{type:"button",className:`
|
|
5
5
|
p-1.5 -ml-1 rounded-full transition-colors
|
|
6
|
-
${
|
|
7
|
-
|
|
6
|
+
${o?"hover:bg-zinc-800 text-white":"hover:bg-gray-100 text-gray-700"}
|
|
7
|
+
`,"aria-label":"Go back",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}),e.jsxs("button",{onClick:r,className:"flex items-center gap-2.5 flex-1 min-w-0 text-left","aria-label":"View business info",children:[e.jsx("div",{className:`
|
|
8
8
|
relative w-9 h-9 rounded-full overflow-hidden flex-shrink-0
|
|
9
|
-
${
|
|
10
|
-
`,
|
|
9
|
+
${o?"bg-zinc-800":"bg-gray-100"}
|
|
10
|
+
`,style:{backgroundColor:s.logo?void 0:a},children:s.logo?e.jsx("img",{src:s.logo,alt:`${s.name} logo`,className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-sm font-bold text-white",children:s.name.charAt(0).toUpperCase()})}),e.jsx("h1",{className:`
|
|
11
11
|
text-base font-medium truncate
|
|
12
|
-
${
|
|
13
|
-
|
|
12
|
+
${o?"text-white":"text-gray-900"}
|
|
13
|
+
`,children:s.name})]}),e.jsxs("div",{className:"flex items-center gap-0.5",children:[s.verified&&e.jsx("button",{type:"button",className:`
|
|
14
14
|
p-2 rounded-full transition-colors
|
|
15
|
-
${
|
|
16
|
-
`,"aria-label":"Verified business",children:
|
|
15
|
+
${o?"hover:bg-zinc-800":"hover:bg-gray-100"}
|
|
16
|
+
`,"aria-label":"Verified business",children:e.jsxs("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",fill:"none",children:[e.jsx("path",{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z",stroke:o?"#9ca3af":"#6b7280",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M9 12l2 2 4-4",stroke:"#3b82f6",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})]})}),e.jsx("button",{type:"button",className:`
|
|
17
17
|
p-2 rounded-full transition-colors
|
|
18
|
-
${
|
|
19
|
-
|
|
18
|
+
${o?"hover:bg-zinc-800 text-zinc-400":"hover:bg-gray-100 text-gray-500"}
|
|
19
|
+
`,"aria-label":"More options",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 5v.01M12 12v.01M12 19v.01M12 6a1 1 0 110-2 1 1 0 010 2zm0 7a1 1 0 110-2 1 1 0 010 2zm0 7a1 1 0 110-2 1 1 0 010 2z"})})})]})]})}),xe=l.memo(function(){const{theme:t,businessInfo:s}=v(),r=t==="dark",o=s.brandColor||"#0084ff";return e.jsxs("div",{className:"flex flex-col items-center py-4 px-4",children:[e.jsxs("div",{className:"relative mb-3",children:[e.jsx("div",{className:`
|
|
20
20
|
w-16 h-16 rounded-full overflow-hidden
|
|
21
|
-
${
|
|
21
|
+
${r?"bg-zinc-800":"bg-gray-100"}
|
|
22
22
|
shadow-lg
|
|
23
|
-
`,
|
|
23
|
+
`,style:{backgroundColor:s.logo?void 0:o},children:s.logo?e.jsx("img",{src:s.logo,alt:`${s.name} logo`,className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-2xl font-bold text-white",children:s.name.charAt(0).toUpperCase()})}),s.verified&&e.jsx("div",{className:"absolute -bottom-0.5 -right-0.5 w-5 h-5 rounded-full bg-blue-500 flex items-center justify-center border-2 border-white shadow-sm",children:e.jsx("svg",{className:"w-3 h-3 text-white",viewBox:"0 0 24 24",fill:"currentColor",children:e.jsx("path",{d:"M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41L9 16.17z"})})})]}),e.jsx("h1",{className:`
|
|
24
24
|
text-lg font-semibold text-center
|
|
25
|
-
${
|
|
26
|
-
|
|
25
|
+
${r?"text-white":"text-gray-900"}
|
|
26
|
+
`,children:s.name}),s.description&&e.jsx("p",{className:`
|
|
27
27
|
text-sm text-center mt-0.5
|
|
28
|
-
${
|
|
29
|
-
`,children:
|
|
28
|
+
${r?"text-zinc-400":"text-gray-500"}
|
|
29
|
+
`,children:s.description})]})}),he=l.memo(function({text:t,sender:s,timestamp:r}){const{theme:o,businessInfo:a}=v(),i=o==="dark",u=s==="business",c=a.brandColor||"#0084ff",d=new Date(r).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});return u?e.jsxs("div",{className:"max-w-[90%]",children:[e.jsx("div",{className:`
|
|
30
30
|
px-4 py-3 rounded-2xl text-sm leading-relaxed
|
|
31
|
-
${
|
|
32
|
-
|
|
31
|
+
${i?"bg-zinc-800 text-white":"bg-gray-100 text-gray-900"}
|
|
32
|
+
`,children:t}),e.jsx("span",{className:"sr-only",children:d})]}):e.jsxs("div",{className:"flex items-end gap-1.5 max-w-[85%] ml-auto",children:[e.jsx("div",{className:"px-4 py-2.5 rounded-full text-white text-sm leading-relaxed",style:{backgroundColor:c},children:t}),e.jsx("div",{className:"w-5 h-5 rounded-full flex items-center justify-center flex-shrink-0",style:{backgroundColor:c},children:e.jsx("svg",{className:"w-3 h-3 text-white",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:3,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),e.jsx("span",{className:"sr-only",children:d})]})}),me=l.memo(function({text:t,timestamp:s}){const{businessInfo:r}=v(),o=r.brandColor||"#0084ff",a=new Date(s).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});return e.jsxs("div",{className:"flex items-end gap-1.5 max-w-[85%] ml-auto",children:[e.jsx("div",{className:"px-4 py-2.5 rounded-full text-white text-sm leading-relaxed shadow-sm",style:{backgroundColor:o},children:t}),e.jsx("div",{className:"w-5 h-5 rounded-full flex items-center justify-center flex-shrink-0",style:{backgroundColor:o},children:e.jsx("svg",{className:"w-3 h-3 text-white",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:3,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),e.jsx("span",{className:"sr-only",children:a})]})}),fe=l.memo(function({card:t,timestamp:s}){const{theme:r,handleReply:o,handleAction:a}=v(),i=r==="dark",u=new Date(s).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),c=m=>{"reply"in m?o(m):a(m)},d={short:"h-36",medium:"h-44",tall:"h-56"},h=i?"bg-zinc-800":"bg-[#e8f5e9]";return e.jsxs("div",{className:"w-full",children:[e.jsxs("div",{className:`
|
|
33
33
|
overflow-hidden rounded-2xl w-full shadow-sm
|
|
34
|
-
${
|
|
35
|
-
|
|
34
|
+
${h}
|
|
35
|
+
`,children:[t.media&&e.jsx("div",{className:`
|
|
36
36
|
w-full overflow-hidden
|
|
37
|
-
${
|
|
38
|
-
`,children:
|
|
37
|
+
${d[t.media.height]}
|
|
38
|
+
`,children:e.jsx("img",{src:t.media.url,alt:t.title||"Rich card media",className:"w-full h-full object-cover",loading:"lazy"})}),e.jsxs("div",{className:"p-4",children:[t.title&&e.jsx("h3",{className:`
|
|
39
39
|
text-base font-semibold leading-snug
|
|
40
|
-
${
|
|
41
|
-
`,children:
|
|
40
|
+
${i?"text-white":"text-gray-900"}
|
|
41
|
+
`,children:t.title}),t.description&&e.jsx("p",{className:`
|
|
42
42
|
text-sm leading-relaxed mt-1.5
|
|
43
|
-
${
|
|
44
|
-
`,children:
|
|
43
|
+
${i?"text-zinc-300":"text-gray-700"}
|
|
44
|
+
`,children:t.description}),t.suggestions&&t.suggestions.length>0&&e.jsx("div",{className:`
|
|
45
45
|
mt-4 rounded-xl overflow-hidden divide-y
|
|
46
|
-
${
|
|
47
|
-
`,children:
|
|
46
|
+
${i?"divide-zinc-700 bg-zinc-800":"divide-gray-100 bg-white"}
|
|
47
|
+
`,children:t.suggestions.map((m,y)=>e.jsx(ye,{suggestion:m,onClick:()=>c(m),isDark:i},y))})]})]}),e.jsx("span",{className:"sr-only",children:u})]})}),A="w-5 h-5 text-gray-400",ge=()=>e.jsx("svg",{className:A,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21 12a9 9 0 01-9 9m9-9a9 9 0 00-9-9m9 9H3m9 9a9 9 0 01-9-9m9 9c1.657 0 3-4.03 3-9s-1.343-9-3-9m0 18c-1.657 0-3-4.03-3-9s1.343-9 3-9m-9 9a9 9 0 019-9"})}),pe=()=>e.jsx("svg",{className:A,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 5a2 2 0 012-2h3.28a1 1 0 01.948.684l1.498 4.493a1 1 0 01-.502 1.21l-2.257 1.13a11.042 11.042 0 005.516 5.516l1.13-2.257a1 1 0 011.21-.502l4.493 1.498a1 1 0 01.684.949V19a2 2 0 01-2 2h-1C9.716 21 3 14.284 3 6V5z"})}),be=()=>e.jsxs("svg",{className:A,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:[e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M17.657 16.657L13.414 20.9a1.998 1.998 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z"}),e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 11a3 3 0 11-6 0 3 3 0 016 0z"})]}),je=()=>e.jsx("svg",{className:A,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"})}),_=()=>e.jsx("svg",{className:A,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})}),ye=l.memo(function({suggestion:t,onClick:s,isDark:r}){const o=C(t),a=o?t.action.displayText:t.reply.displayText,i=()=>{if(!o)return e.jsx(_,{});const{action:u}=t;return u.urlAction||u.openUrlAction?e.jsx(ge,{}):u.dialerAction||u.dialAction?e.jsx(pe,{}):u.mapAction||u.viewLocationAction?e.jsx(be,{}):u.calendarAction||u.createCalendarEventAction?e.jsx(je,{}):e.jsx(_,{})};return e.jsxs("button",{onClick:s,className:`
|
|
48
48
|
w-full flex items-center gap-3 px-4 py-3 text-left transition-colors
|
|
49
|
-
${
|
|
50
|
-
|
|
49
|
+
${r?"hover:bg-zinc-700":"hover:bg-gray-50"}
|
|
50
|
+
`,children:[e.jsx("span",{className:"flex-shrink-0",children:i()}),e.jsx("span",{className:`text-sm ${r?"text-white":"text-gray-900"}`,children:a})]})}),we=l.memo(function({cards:t,timestamp:s}){const{theme:r,handleReply:o,handleAction:a}=v(),i=l.useRef(null),[u,c]=l.useState(!1),[d,h]=l.useState(t.length>1),m=r==="dark",y=new Date(s).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),g=f=>{"reply"in f?o(f):a(f)},k=l.useCallback(()=>{if(i.current){const{scrollLeft:f,scrollWidth:b,clientWidth:x}=i.current;c(f>0),h(f<b-x-10)}},[]),p=f=>{i.current&&i.current.scrollBy({left:f==="left"?-200:200,behavior:"smooth"})};return e.jsxs("div",{className:"w-full -mx-3",children:[e.jsxs("div",{className:"relative",children:[u&&e.jsx("button",{onClick:()=>p("left"),className:`
|
|
51
51
|
absolute left-2 top-1/2 -translate-y-1/2 z-10
|
|
52
52
|
w-8 h-8 rounded-full flex items-center justify-center
|
|
53
53
|
shadow-lg transition-opacity
|
|
54
|
-
${
|
|
55
|
-
`,"aria-label":"Scroll left",children:
|
|
54
|
+
${m?"bg-zinc-700 text-white":"bg-white text-gray-700"}
|
|
55
|
+
`,"aria-label":"Scroll left",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}),e.jsx("div",{ref:i,onScroll:k,className:"flex gap-2.5 overflow-x-auto py-1 px-3 snap-x snap-mandatory",style:{scrollbarWidth:"none",msOverflowStyle:"none"},children:t.map((f,b)=>e.jsx(ke,{card:f,isDark:m,onSuggestionClick:g},b))}),d&&e.jsx("button",{onClick:()=>p("right"),className:`
|
|
56
56
|
absolute right-2 top-1/2 -translate-y-1/2 z-10
|
|
57
57
|
w-8 h-8 rounded-full flex items-center justify-center
|
|
58
58
|
shadow-lg transition-opacity
|
|
59
|
-
${
|
|
60
|
-
`,"aria-label":"Scroll right",children:
|
|
59
|
+
${m?"bg-zinc-700 text-white":"bg-white text-gray-700"}
|
|
60
|
+
`,"aria-label":"Scroll right",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})})]}),e.jsx("span",{className:"sr-only",children:y})]})}),$="w-4 h-4 text-gray-400",ve=n=>{if(!C(n))return e.jsx("svg",{className:$,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})});const{action:t}=n;return t.urlAction||t.openUrlAction?e.jsx("svg",{className:$,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21 12a9 9 0 01-9 9m9-9a9 9 0 00-9-9m9 9H3m9 9a9 9 0 01-9-9m9 9c1.657 0 3-4.03 3-9s-1.343-9-3-9m0 18c-1.657 0-3-4.03-3-9s1.343-9 3-9m-9 9a9 9 0 019-9"})}):t.dialerAction||t.dialAction?e.jsx("svg",{className:$,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 5a2 2 0 012-2h3.28a1 1 0 01.948.684l1.498 4.493a1 1 0 01-.502 1.21l-2.257 1.13a11.042 11.042 0 005.516 5.516l1.13-2.257a1 1 0 011.21-.502l4.493 1.498a1 1 0 01.684.949V19a2 2 0 01-2 2h-1C9.716 21 3 14.284 3 6V5z"})}):t.mapAction||t.viewLocationAction?e.jsxs("svg",{className:$,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:[e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M17.657 16.657L13.414 20.9a1.998 1.998 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z"}),e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 11a3 3 0 11-6 0 3 3 0 016 0z"})]}):t.calendarAction||t.createCalendarEventAction?e.jsx("svg",{className:$,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"})}):e.jsx("svg",{className:$,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})})},ke=l.memo(function({card:t,isDark:s,onSuggestionClick:r}){const o=t.layout.width==="small"?"w-44":"w-52";return e.jsxs("div",{className:`
|
|
61
61
|
flex-shrink-0 snap-start rounded-2xl overflow-hidden shadow-sm
|
|
62
|
-
${
|
|
63
|
-
${
|
|
64
|
-
|
|
62
|
+
${o}
|
|
63
|
+
${s?"bg-zinc-800":"bg-[#e8f5e9]"}
|
|
64
|
+
`,children:[t.media&&e.jsx("div",{className:"w-full h-32 bg-gray-200 overflow-hidden",children:e.jsx("img",{src:t.media.url,alt:t.title||"Carousel card media",className:"w-full h-full object-cover",loading:"lazy"})}),e.jsxs("div",{className:"p-3",children:[t.title&&e.jsx("h4",{className:`
|
|
65
65
|
text-sm font-semibold leading-tight mb-1 line-clamp-2
|
|
66
|
-
${
|
|
67
|
-
`,children:
|
|
66
|
+
${s?"text-white":"text-gray-900"}
|
|
67
|
+
`,children:t.title}),t.description&&e.jsx("p",{className:`
|
|
68
68
|
text-xs leading-relaxed line-clamp-3
|
|
69
|
-
${
|
|
70
|
-
`,children:
|
|
69
|
+
${s?"text-zinc-400":"text-gray-700"}
|
|
70
|
+
`,children:t.description}),t.suggestions&&t.suggestions.length>0&&e.jsx("div",{className:`
|
|
71
71
|
mt-3 rounded-lg overflow-hidden divide-y
|
|
72
|
-
${
|
|
73
|
-
`,children:
|
|
72
|
+
${s?"divide-zinc-600 bg-zinc-700":"divide-gray-100 bg-white"}
|
|
73
|
+
`,children:t.suggestions.map((a,i)=>{const c=C(a)?a.action.displayText:a.reply.displayText;return e.jsxs("button",{onClick:()=>r(a),className:`
|
|
74
74
|
w-full flex items-center gap-2 px-3 py-2.5
|
|
75
75
|
text-xs transition-colors text-left
|
|
76
|
-
${
|
|
77
|
-
`,children:[
|
|
76
|
+
${s?"hover:bg-zinc-600 text-white":"hover:bg-gray-50 text-gray-900"}
|
|
77
|
+
`,children:[e.jsx("span",{className:"flex-shrink-0",children:ve(a)}),e.jsx("span",{className:"truncate",children:c})]},i)})})]})]})}),Ne={text:({content:n,sender:t,timestamp:s})=>n.type!=="text"?null:e.jsx(he,{text:n.text,sender:t,timestamp:s}),userReply:({content:n,timestamp:t})=>n.type!=="userReply"?null:e.jsx(me,{text:n.text,timestamp:t}),richcard:({content:n,timestamp:t})=>n.type!=="richcard"?null:e.jsx(fe,{card:n.card,timestamp:t}),carousel:({content:n,timestamp:t})=>n.type!=="carousel"?null:e.jsx(we,{cards:n.cards,timestamp:t})},Ce=l.memo(function({message:t,isLast:s}){const{content:r,sender:o,timestamp:a}=t,i=Ne[r.type];return i?e.jsx(i,{content:r,sender:o,timestamp:a,showSuggestions:s&&o==="business"}):(console.warn(`Unknown message type: ${r.type}`),e.jsx("div",{className:"px-4 py-2 text-gray-500 text-sm italic",children:"[Unsupported message type]"}))}),Le=l.memo(function(){const{theme:t}=v(),s=t==="dark";return e.jsx("div",{className:"flex items-start gap-2 px-4 py-2",role:"status","aria-label":"Business is typing",children:e.jsxs("div",{className:`
|
|
78
78
|
inline-flex items-center gap-1 px-4 py-3 rounded-2xl rounded-bl-sm
|
|
79
|
-
${
|
|
80
|
-
`,
|
|
79
|
+
${s?"bg-zinc-800":"bg-gray-100"}
|
|
80
|
+
`,children:[e.jsx("span",{className:`
|
|
81
81
|
rcs-typing-dot w-2 h-2 rounded-full
|
|
82
|
-
${
|
|
83
|
-
|
|
82
|
+
${s?"bg-zinc-500":"bg-gray-400"}
|
|
83
|
+
`}),e.jsx("span",{className:`
|
|
84
84
|
rcs-typing-dot w-2 h-2 rounded-full
|
|
85
|
-
${
|
|
86
|
-
|
|
85
|
+
${s?"bg-zinc-500":"bg-gray-400"}
|
|
86
|
+
`}),e.jsx("span",{className:`
|
|
87
87
|
rcs-typing-dot w-2 h-2 rounded-full
|
|
88
|
-
${
|
|
89
|
-
|
|
88
|
+
${s?"bg-zinc-500":"bg-gray-400"}
|
|
89
|
+
`})]})})}),Me=l.memo(function(){const{theme:t,state:s}=v(),{chatHistory:r,isTyping:o}=s,a=t==="dark";return e.jsxs("div",{className:"px-3 pb-3 space-y-3",role:"log","aria-label":"Chat messages","aria-live":"polite",children:[r.length>0&&e.jsx("div",{className:"flex justify-center py-2",children:e.jsx("span",{className:`
|
|
90
90
|
text-xs font-medium px-3 py-1
|
|
91
|
-
${
|
|
92
|
-
`,children:"Today"})}),
|
|
91
|
+
${a?"text-zinc-500":"text-gray-500"}
|
|
92
|
+
`,children:"Today"})}),e.jsxs("div",{className:`
|
|
93
93
|
rounded-3xl overflow-hidden
|
|
94
|
-
${
|
|
95
|
-
|
|
96
|
-
${
|
|
97
|
-
`,children:
|
|
94
|
+
${a?"bg-zinc-900":"bg-gray-50"}
|
|
95
|
+
`,children:[r.length===0&&!o&&e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("p",{className:`text-sm ${a?"text-zinc-500":"text-gray-400"}`,children:"No messages yet"})}),e.jsxs("div",{className:"p-3 space-y-3",children:[r.map((i,u)=>e.jsx("div",{className:`
|
|
96
|
+
${i.sender==="user"?"flex justify-end":"flex justify-start"}
|
|
97
|
+
`,children:e.jsx(Ce,{message:i,isLast:u===r.length-1&&!o})},i.id)),o&&e.jsx(Le,{})]})]})]})}),ze=l.memo(function({suggestion:t,onClick:s,variant:r="bar"}){const{theme:o,businessInfo:a}=v(),i=o==="dark",u=C(t),c=u?t.action.displayText:t.reply.displayText,d=u?$e(t):null,h=a.brandColor||"#0084ff";return r==="bar"?e.jsxs("button",{type:"button",onClick:s,className:`
|
|
98
98
|
inline-flex items-center gap-2 px-4 py-2 rounded-full text-sm font-medium
|
|
99
99
|
whitespace-nowrap transition-colors flex-shrink-0
|
|
100
100
|
border
|
|
101
|
-
${
|
|
102
|
-
|
|
101
|
+
${i?"bg-zinc-800 border-zinc-700 hover:bg-zinc-700 text-white":"bg-white border-gray-300 hover:bg-gray-50 text-gray-900"}
|
|
102
|
+
`,"aria-label":u?`${Ae(t)}: ${c}`:c,children:[d&&e.jsx("span",{style:{color:h},children:e.jsx(d,{className:"w-4 h-4"})}),e.jsx("span",{children:c})]}):r==="card"?e.jsxs("button",{type:"button",onClick:s,className:`
|
|
103
103
|
w-full flex items-center gap-3 px-3 py-2.5 text-left transition-colors rounded-lg
|
|
104
|
-
${
|
|
105
|
-
|
|
104
|
+
${i?"hover:bg-zinc-700":"hover:bg-gray-100"}
|
|
105
|
+
`,children:[d&&e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center flex-shrink-0",style:{backgroundColor:`${h}15`},children:e.jsx(d,{className:"w-4 h-4",style:{color:h}})}),e.jsx("span",{className:`text-sm font-medium ${i?"text-white":"text-gray-900"}`,children:c})]}):e.jsx("button",{type:"button",onClick:s,className:`
|
|
106
106
|
w-full px-3 py-2 rounded-lg text-xs font-medium text-center
|
|
107
107
|
border transition-colors
|
|
108
|
-
${
|
|
109
|
-
|
|
108
|
+
${i?"border-zinc-600 hover:bg-zinc-700 text-white":"border-gray-300 hover:bg-gray-50 text-gray-900"}
|
|
109
|
+
`,children:c})});function $e(n){if(!C(n))return null;const{action:t}=n;return t.openUrlAction?({className:s,style:r})=>e.jsx("svg",{className:s,style:r,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21 12a9 9 0 01-9 9m9-9a9 9 0 00-9-9m9 9H3m9 9a9 9 0 01-9-9m9 9c1.657 0 3-4.03 3-9s-1.343-9-3-9m0 18c-1.657 0-3-4.03-3-9s1.343-9 3-9m-9 9a9 9 0 019-9"})}):t.dialAction?({className:s,style:r})=>e.jsx("svg",{className:s,style:r,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 5a2 2 0 012-2h3.28a1 1 0 01.948.684l1.498 4.493a1 1 0 01-.502 1.21l-2.257 1.13a11.042 11.042 0 005.516 5.516l1.13-2.257a1 1 0 011.21-.502l4.493 1.498a1 1 0 01.684.949V19a2 2 0 01-2 2h-1C9.716 21 3 14.284 3 6V5z"})}):t.shareLocationAction?({className:s,style:r})=>e.jsxs("svg",{className:s,style:r,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:[e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M17.657 16.657L13.414 20.9a1.998 1.998 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z"}),e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 11a3 3 0 11-6 0 3 3 0 016 0z"})]}):t.viewLocationAction?({className:s,style:r})=>e.jsxs("svg",{className:s,style:r,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:[e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M17.657 16.657L13.414 20.9a1.998 1.998 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z"}),e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 11a3 3 0 11-6 0 3 3 0 016 0z"})]}):t.createCalendarEventAction?({className:s,style:r})=>e.jsx("svg",{className:s,style:r,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"})}):null}function Ae(n){if(!C(n))return"Reply";const{action:t}=n;return t.openUrlAction?"Open link":t.dialAction?"Call":t.shareLocationAction?"Share location":t.viewLocationAction?"View location":t.createCalendarEventAction?"Add to calendar":"Action"}const Ie=l.memo(function({suggestions:t}){const{theme:s,handleReply:r,handleAction:o}=v(),a=s==="dark";if(!t||t.length===0)return null;const i=u=>{W(u)?r(u):C(u)&&o(u)};return e.jsx("div",{className:`
|
|
110
110
|
px-3 py-2
|
|
111
|
-
${
|
|
112
|
-
|
|
111
|
+
${a?"bg-zinc-900":"bg-white"}
|
|
112
|
+
`,role:"group","aria-label":"Quick replies",children:e.jsx("div",{className:"flex gap-2 overflow-x-auto pb-1 -mx-1 px-1",style:{scrollbarWidth:"none",msOverflowStyle:"none"},children:t.map((u,c)=>e.jsx(ze,{suggestion:u,onClick:()=>i(u),variant:"bar"},c))})})}),Se=l.memo(function(){const{theme:t,state:s,showSuggestions:r}=v(),{chatHistory:o,isTyping:a,error:i}=s,u=de([o.length,a]),c=t==="dark",d=o[o.length-1],h=r&&d?.sender==="business"&&!a?d.suggestions:void 0;return e.jsxs("div",{className:`
|
|
113
113
|
flex flex-col h-full w-full overflow-hidden
|
|
114
|
-
${
|
|
115
|
-
|
|
114
|
+
${c?"bg-zinc-950":"bg-white"}
|
|
115
|
+
`,children:[e.jsx(ue,{}),i&&e.jsx("div",{className:"px-4 py-2 bg-red-500/10 border-b border-red-500/20",role:"alert",children:e.jsx("p",{className:"text-sm text-red-500",children:i})}),e.jsxs("div",{ref:u,className:"flex-1 overflow-y-auto rcs-scrollbar",children:[e.jsx(xe,{}),e.jsx(Me,{})]}),h&&h.length>0&&e.jsx(Ie,{suggestions:h}),e.jsxs("div",{className:`
|
|
116
116
|
px-3 py-2 flex items-center gap-2
|
|
117
|
-
${
|
|
118
|
-
`,
|
|
117
|
+
${c?"bg-zinc-900":"bg-white"}
|
|
118
|
+
`,children:[e.jsx("button",{type:"button",className:`
|
|
119
119
|
w-9 h-9 flex items-center justify-center rounded-full flex-shrink-0
|
|
120
120
|
border transition-colors
|
|
121
|
-
${
|
|
122
|
-
|
|
121
|
+
${c?"border-zinc-700 text-zinc-400 hover:bg-zinc-800":"border-gray-300 text-gray-500 hover:bg-gray-100"}
|
|
122
|
+
`,"aria-label":"Add attachment",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})}),e.jsxs("div",{className:`
|
|
123
123
|
flex-1 flex items-center gap-2 px-4 py-2 rounded-full
|
|
124
|
-
${
|
|
125
|
-
`,
|
|
124
|
+
${c?"bg-zinc-800":"bg-gray-100"}
|
|
125
|
+
`,children:[e.jsx("span",{className:`flex-1 text-sm ${c?"text-zinc-500":"text-gray-400"}`,children:"RCS message"}),e.jsx("button",{type:"button",className:`p-1 ${c?"text-zinc-500":"text-gray-400"}`,"aria-label":"Emoji",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M14.828 14.828a4 4 0 01-5.656 0M9 10h.01M15 10h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})}),e.jsx("button",{type:"button",className:`p-1 ${c?"text-zinc-500":"text-gray-400"}`,"aria-label":"Attach image",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})})})]}),e.jsx("button",{type:"button",className:"w-10 h-10 flex items-center justify-center rounded-full bg-green-100 text-green-600 flex-shrink-0","aria-label":"Voice message",children:e.jsx("svg",{className:"w-5 h-5",fill:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{d:"M12 14c1.66 0 3-1.34 3-3V5c0-1.66-1.34-3-3-3S9 3.34 9 5v6c0 1.66 1.34 3 3 3zm-1 1.93c-3.94-.49-7-3.85-7-7.93h2c0 3.31 2.69 6 6 6s6-2.69 6-6h2c0 4.08-3.06 7.44-7 7.93V20h4v2H8v-2h4v-4.07z"})})})]})]})}),Te=l.memo(function(){const{theme:t,businessInfo:s,toggleProfile:r}=v(),[o,a]=l.useState("info"),i=t==="dark",u=s.bannerImage||"https://images.unsplash.com/photo-1436491865332-7a61a109cc05?w=800&q=80",c=s.brandColor||"#0084ff";return e.jsxs("div",{className:`
|
|
126
126
|
absolute inset-0 z-50 flex flex-col
|
|
127
|
-
${
|
|
128
|
-
`,
|
|
127
|
+
${i?"bg-zinc-950":"bg-white"}
|
|
128
|
+
`,children:[e.jsxs("header",{className:`
|
|
129
129
|
flex items-center gap-3 px-4 py-3 border-b
|
|
130
|
-
${
|
|
131
|
-
`,
|
|
130
|
+
${i?"bg-zinc-900 border-zinc-800":"bg-white border-gray-200"}
|
|
131
|
+
`,children:[e.jsx("button",{onClick:r,className:`
|
|
132
132
|
p-1.5 -ml-1.5 rounded-full transition-colors
|
|
133
|
-
${
|
|
134
|
-
|
|
133
|
+
${i?"hover:bg-zinc-800 text-white":"hover:bg-gray-100 text-gray-900"}
|
|
134
|
+
`,"aria-label":"Go back",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}),e.jsx("span",{className:`text-base font-medium ${i?"text-white":"text-gray-900"}`,children:"Info & options"})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[e.jsx("div",{className:"relative h-40 bg-gray-200",children:e.jsx("img",{src:u,alt:"Business banner",className:"w-full h-full object-cover"})}),e.jsx("div",{className:"relative px-4",children:e.jsx("div",{className:`
|
|
135
135
|
absolute -top-10 left-1/2 -translate-x-1/2
|
|
136
136
|
w-20 h-20 rounded-full overflow-hidden border-4
|
|
137
|
-
${
|
|
137
|
+
${i?"border-zinc-950 bg-zinc-800":"border-white bg-gray-100"}
|
|
138
138
|
shadow-lg
|
|
139
|
-
|
|
139
|
+
`,children:s.logo?e.jsx("img",{src:s.logo,alt:`${s.name} logo`,className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-2xl font-bold text-white",style:{backgroundColor:c},children:s.name.charAt(0).toUpperCase()})})}),e.jsxs("div",{className:"pt-12 pb-4 px-4 text-center",children:[e.jsx("h1",{className:`text-xl font-semibold ${i?"text-white":"text-gray-900"}`,children:s.name}),s.description&&e.jsx("p",{className:`text-sm mt-1 ${i?"text-zinc-400":"text-gray-500"}`,children:s.description})]}),e.jsxs("div",{className:"flex justify-center gap-4 px-4 pb-4",children:[s.phoneNumbers&&s.phoneNumbers.length>0&&e.jsx(E,{icon:"phone",label:"Call",isDark:i,brandColor:c,onClick:()=>{const d=s.phoneNumbers?.[0]?.number;d&&(window.location.href=`tel:${d}`)}}),s.websites&&s.websites.length>0&&e.jsx(E,{icon:"globe",label:"Website",isDark:i,brandColor:c,onClick:()=>{const d=s.websites?.[0]?.url;d&&window.open(d,"_blank","noopener,noreferrer")}}),s.emails&&s.emails.length>0&&e.jsx(E,{icon:"mail",label:"Contact",isDark:i,brandColor:c,onClick:()=>{const d=s.emails?.[0]?.email;d&&(window.location.href=`mailto:${d}`)}})]}),e.jsxs("div",{className:`
|
|
140
140
|
flex mx-4 rounded-lg overflow-hidden border
|
|
141
|
-
${
|
|
142
|
-
`,
|
|
141
|
+
${i?"border-zinc-700 bg-zinc-800":"border-gray-200 bg-gray-100"}
|
|
142
|
+
`,children:[e.jsx(U,{active:o==="info",onClick:()=>a("info"),isDark:i,brandColor:c,children:"Info"}),e.jsx(U,{active:o==="options",onClick:()=>a("options"),isDark:i,brandColor:c,children:"Options"})]}),e.jsx("div",{className:"p-4",children:o==="info"?e.jsx(Ee,{isDark:i,brandColor:c}):e.jsx(Re,{isDark:i})})]})]})}),E=l.memo(function({icon:t,label:s,isDark:r,brandColor:o,onClick:a}){const i={phone:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 5a2 2 0 012-2h3.28a1 1 0 01.948.684l1.498 4.493a1 1 0 01-.502 1.21l-2.257 1.13a11.042 11.042 0 005.516 5.516l1.13-2.257a1 1 0 011.21-.502l4.493 1.498a1 1 0 01.684.949V19a2 2 0 01-2 2h-1C9.716 21 3 14.284 3 6V5z"}),globe:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 12a9 9 0 01-9 9m9-9a9 9 0 00-9-9m9 9H3m9 9a9 9 0 01-9-9m9 9c1.657 0 3-4.03 3-9s-1.343-9-3-9m0 18c-1.657 0-3-4.03-3-9s1.343-9 3-9m-9 9a9 9 0 019-9"}),mail:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"})};return e.jsxs("button",{onClick:a,className:`
|
|
143
143
|
flex flex-col items-center gap-2 px-6 py-3 rounded-xl border transition-colors
|
|
144
|
-
${
|
|
145
|
-
`,
|
|
144
|
+
${r?"bg-zinc-800 border-zinc-700 hover:bg-zinc-700":"bg-white border-gray-200 hover:bg-gray-50"}
|
|
145
|
+
`,children:[e.jsx("svg",{className:"w-6 h-6",fill:"none",viewBox:"0 0 24 24",stroke:o,children:i[t]}),e.jsx("span",{className:`text-xs font-medium ${r?"text-zinc-300":"text-gray-600"}`,children:s})]})}),U=l.memo(function({active:t,onClick:s,isDark:r,brandColor:o,children:a}){return e.jsx("button",{onClick:s,className:`
|
|
146
146
|
flex-1 py-2.5 text-sm font-medium transition-colors rounded-lg
|
|
147
|
-
${
|
|
148
|
-
|
|
147
|
+
${t?"text-white":r?"text-zinc-400 hover:text-zinc-200":"text-gray-500 hover:text-gray-700"}
|
|
148
|
+
`,style:t?{backgroundColor:o}:void 0,children:a})}),Ee=l.memo(function({isDark:t,brandColor:s}){const{businessInfo:r}=v();return r.phoneNumbers&&r.phoneNumbers.length>0||r.websites&&r.websites.length>0||r.emails&&r.emails.length>0?e.jsxs("div",{className:`
|
|
149
149
|
rounded-xl overflow-hidden border divide-y
|
|
150
|
-
${
|
|
151
|
-
|
|
150
|
+
${t?"bg-zinc-900 border-zinc-800 divide-zinc-800":"bg-gray-50 border-gray-200 divide-gray-200"}
|
|
151
|
+
`,children:[r.phoneNumbers?.map((a,i)=>e.jsx(R,{icon:"phone",primary:a.number,secondary:a.label,isDark:t,brandColor:s,onClick:()=>window.location.href=`tel:${a.number}`},`phone-${i}`)),r.websites?.map((a,i)=>e.jsx(R,{icon:"globe",primary:a.url.replace(/^https?:\/\//,""),secondary:a.label||"Website",isDark:t,brandColor:s,onClick:()=>window.open(a.url,"_blank","noopener,noreferrer")},`web-${i}`)),r.emails?.map((a,i)=>e.jsx(R,{icon:"mail",primary:a.email,secondary:a.label||"Email",isDark:t,brandColor:s,onClick:()=>window.location.href=`mailto:${a.email}`},`email-${i}`))]}):e.jsx("div",{className:`text-center py-8 ${t?"text-zinc-500":"text-gray-400"}`,children:"No contact information available"})}),R=l.memo(function({icon:t,primary:s,secondary:r,isDark:o,onClick:a}){const i={phone:"M3 5a2 2 0 012-2h3.28a1 1 0 01.948.684l1.498 4.493a1 1 0 01-.502 1.21l-2.257 1.13a11.042 11.042 0 005.516 5.516l1.13-2.257a1 1 0 011.21-.502l4.493 1.498a1 1 0 01.684.949V19a2 2 0 01-2 2h-1C9.716 21 3 14.284 3 6V5z",globe:"M21 12a9 9 0 01-9 9m9-9a9 9 0 00-9-9m9 9H3m9 9a9 9 0 01-9-9m9 9c1.657 0 3-4.03 3-9s-1.343-9-3-9m0 18c-1.657 0-3-4.03-3-9s1.343-9 3-9m-9 9a9 9 0 019-9",mail:"M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"};return e.jsxs("button",{onClick:a,className:`
|
|
152
152
|
w-full flex items-center gap-4 px-4 py-3.5 text-left transition-colors
|
|
153
|
-
${
|
|
154
|
-
`,
|
|
153
|
+
${o?"hover:bg-zinc-800":"hover:bg-gray-100"}
|
|
154
|
+
`,children:[e.jsx("svg",{className:`w-5 h-5 flex-shrink-0 ${o?"text-zinc-500":"text-gray-400"}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:i[t]})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:`text-sm font-medium truncate ${o?"text-white":"text-gray-900"}`,children:s}),r&&e.jsx("p",{className:`text-xs truncate ${o?"text-zinc-500":"text-gray-500"}`,children:r})]})]})}),Re=l.memo(function({isDark:t}){return e.jsxs("div",{className:`
|
|
155
155
|
rounded-xl overflow-hidden border divide-y
|
|
156
|
-
${
|
|
157
|
-
|
|
156
|
+
${t?"bg-zinc-900 border-zinc-800 divide-zinc-800":"bg-gray-50 border-gray-200 divide-gray-200"}
|
|
157
|
+
`,children:[e.jsx(B,{icon:"bell",label:"Notifications",isDark:t}),e.jsx(B,{icon:"block",label:"Block & report spam",isDark:t}),e.jsx(B,{icon:"info",label:"About RCS",isDark:t})]})}),B=l.memo(function({icon:t,label:s,isDark:r}){const o={bell:"M15 17h5l-1.405-1.405A2.032 2.032 0 0118 14.158V11a6.002 6.002 0 00-4-5.659V5a2 2 0 10-4 0v.341C7.67 6.165 6 8.388 6 11v3.159c0 .538-.214 1.055-.595 1.436L4 17h5m6 0v1a3 3 0 11-6 0v-1m6 0H9",block:"M18.364 18.364A9 9 0 005.636 5.636m12.728 12.728A9 9 0 015.636 5.636m12.728 12.728L5.636 5.636",info:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"};return e.jsxs("button",{className:`
|
|
158
158
|
w-full flex items-center gap-4 px-4 py-3.5 text-left transition-colors
|
|
159
|
-
${
|
|
160
|
-
`,
|
|
159
|
+
${r?"hover:bg-zinc-800":"hover:bg-gray-100"}
|
|
160
|
+
`,children:[e.jsx("svg",{className:`w-5 h-5 flex-shrink-0 ${r?"text-zinc-500":"text-gray-400"}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:o[t]})}),e.jsx("span",{className:`text-sm font-medium ${r?"text-white":"text-gray-900"}`,children:s})]})}),D={FULL:"h-full",TALL:"h-[80%]",HALF:"h-[50%]"},Z=l.memo(function(){const{theme:t,businessInfo:s,webView:r,closeWebView:o}=v(),[a,i]=l.useState(!0),[u,c]=l.useState(!1),d=t==="dark",h=s.brandColor||"#0084ff";l.useEffect(()=>{r?.url&&(i(!0),c(!1))},[r?.url]);const m=l.useCallback(()=>{i(!1)},[]),y=l.useCallback(()=>{i(!1),c(!0)},[]),g=w=>{try{return new URL(w).hostname}catch{return"Web Page"}};if(!r||!r.isOpen)return null;const{url:k,viewMode:p,title:f,postbackData:b}=r,x=f||g(k),j=p==="FULL",N=p==="TALL"||p==="HALF",M=D[p]||D.TALL;return e.jsxs("div",{className:`
|
|
161
161
|
rcs-webview-overlay absolute inset-0 z-50 flex flex-col
|
|
162
|
-
${
|
|
163
|
-
${
|
|
164
|
-
`,
|
|
162
|
+
${j?"":"justify-end"}
|
|
163
|
+
${d?"bg-black/60":"bg-black/40"}
|
|
164
|
+
`,role:"dialog","aria-modal":"true","aria-label":`WebView: ${x}`,"data-postback":b,"data-view-mode":p,children:[N&&e.jsx("button",{type:"button",className:"absolute inset-0 w-full h-full cursor-default",onClick:o,"aria-label":"Close WebView"}),e.jsxs("div",{className:`
|
|
165
165
|
rcs-webview-container relative flex flex-col overflow-hidden
|
|
166
|
-
${
|
|
167
|
-
${
|
|
168
|
-
${
|
|
169
|
-
|
|
166
|
+
${d?"bg-zinc-900":"bg-white"}
|
|
167
|
+
${M} w-full
|
|
168
|
+
${N?"rounded-t-2xl shadow-2xl":""}
|
|
169
|
+
`,style:{position:"relative",zIndex:1},children:[e.jsxs("header",{className:`
|
|
170
170
|
rcs-webview-header flex items-center gap-3 px-2 py-2 flex-shrink-0
|
|
171
171
|
border-b
|
|
172
|
-
${
|
|
173
|
-
`,
|
|
172
|
+
${d?"bg-zinc-900 border-zinc-800":"bg-white border-gray-200"}
|
|
173
|
+
`,children:[e.jsx("button",{type:"button",onClick:o,className:`
|
|
174
174
|
rcs-webview-close w-10 h-10 rounded-full flex items-center justify-center
|
|
175
175
|
transition-colors
|
|
176
|
-
${
|
|
177
|
-
|
|
176
|
+
${d?"text-white hover:bg-zinc-800":"text-gray-700 hover:bg-gray-100"}
|
|
177
|
+
`,"aria-label":"Close WebView",children:e.jsx("svg",{className:"w-6 h-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 19l-7-7 7-7"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h2",{className:`
|
|
178
178
|
rcs-webview-title text-base font-medium truncate
|
|
179
|
-
${
|
|
180
|
-
|
|
179
|
+
${d?"text-white":"text-gray-900"}
|
|
180
|
+
`,children:x}),e.jsx("p",{className:`
|
|
181
181
|
rcs-webview-url text-xs truncate
|
|
182
|
-
${
|
|
183
|
-
|
|
182
|
+
${d?"text-zinc-400":"text-gray-500"}
|
|
183
|
+
`,children:g(k)})]}),e.jsx("button",{type:"button",className:`
|
|
184
184
|
w-10 h-10 rounded-full flex items-center justify-center
|
|
185
|
-
${
|
|
186
|
-
|
|
185
|
+
${d?"text-zinc-400 hover:bg-zinc-800":"text-gray-500 hover:bg-gray-100"}
|
|
186
|
+
`,"aria-label":"More options",children:e.jsxs("svg",{className:"w-5 h-5",fill:"currentColor",viewBox:"0 0 24 24",children:[e.jsx("circle",{cx:"12",cy:"5",r:"2"}),e.jsx("circle",{cx:"12",cy:"12",r:"2"}),e.jsx("circle",{cx:"12",cy:"19",r:"2"})]})})]}),a&&e.jsx("div",{className:"rcs-webview-loading absolute top-14 left-0 right-0 h-1 overflow-hidden",style:{backgroundColor:`${h}20`},children:e.jsx("div",{className:"h-full animate-pulse",style:{backgroundColor:h,animation:"webview-loading 1.5s ease-in-out infinite",width:"30%"}})}),u&&e.jsxs("div",{className:`
|
|
187
187
|
rcs-webview-error flex-1 flex flex-col items-center justify-center p-6 text-center
|
|
188
|
-
${
|
|
189
|
-
`,children:[
|
|
188
|
+
${d?"text-zinc-400":"text-gray-500"}
|
|
189
|
+
`,children:[e.jsx("svg",{className:"w-16 h-16 mb-4 opacity-50",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),e.jsx("p",{className:"text-sm font-medium mb-2",children:"Unable to load page"}),e.jsx("p",{className:"text-xs opacity-75 mb-4",children:"This content cannot be displayed in the emulator"}),e.jsx("button",{type:"button",onClick:o,className:`
|
|
190
190
|
px-4 py-2 rounded-full text-sm font-medium
|
|
191
|
-
${
|
|
192
|
-
`,children:"Go Back"})]})
|
|
191
|
+
${d?"bg-zinc-800 text-white hover:bg-zinc-700":"bg-gray-100 text-gray-700 hover:bg-gray-200"}
|
|
192
|
+
`,children:"Go Back"})]}),!u&&e.jsx("div",{className:"rcs-webview-iframe-container flex-1 overflow-hidden",children:e.jsx("iframe",{src:k,title:x,className:"w-full h-full border-0",onLoad:m,onError:y,sandbox:"allow-scripts allow-same-origin allow-forms allow-popups",referrerPolicy:"no-referrer-when-downgrade",loading:"lazy"})}),N&&e.jsx("div",{className:`
|
|
193
193
|
rcs-webview-safe-area h-2 flex-shrink-0
|
|
194
|
-
${
|
|
195
|
-
`})
|
|
194
|
+
${d?"bg-zinc-900":"bg-white"}
|
|
195
|
+
`})]}),e.jsx("style",{children:`
|
|
196
196
|
@keyframes webview-loading {
|
|
197
197
|
0% { transform: translateX(-100%); }
|
|
198
198
|
50% { transform: translateX(200%); }
|
|
199
199
|
100% { transform: translateX(-100%); }
|
|
200
200
|
}
|
|
201
|
-
`})
|
|
201
|
+
`})]})}),Be=l.memo(function({onUnlock:t,messagePreview:s="New message"}){const{theme:r,businessInfo:o}=v(),[a,i]=l.useState(new Date),u=r==="dark";l.useEffect(()=>{const m=setInterval(()=>{i(new Date)},1e3);return()=>clearInterval(m)},[]);const c=a.toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0}),d=a.toLocaleDateString([],{weekday:"short",month:"long",day:"numeric"});return e.jsxs("div",{className:`
|
|
202
202
|
lock-screen flex flex-col h-full w-full select-none
|
|
203
|
-
${
|
|
204
|
-
|
|
205
|
-
transition-transform active:scale-[0.98] hover:shadow-xl`,children:[
|
|
203
|
+
${u?"bg-zinc-900":"bg-zinc-800"}
|
|
204
|
+
`,children:[e.jsx("div",{className:"h-6"}),e.jsx("div",{className:"flex justify-center mt-4",children:e.jsx("div",{className:"w-8 h-8 rounded-full bg-zinc-700 flex items-center justify-center",children:e.jsx("svg",{className:"w-4 h-4 text-zinc-400",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M5 9V7a5 5 0 0110 0v2a2 2 0 012 2v5a2 2 0 01-2 2H5a2 2 0 01-2-2v-5a2 2 0 012-2zm8-2v2H7V7a3 3 0 016 0z",clipRule:"evenodd"})})})}),e.jsx("div",{className:"mt-6 text-center",children:e.jsx("h1",{className:"text-5xl font-light text-white tracking-tight",children:c})}),e.jsxs("div",{className:"mt-2 text-center",children:[e.jsx("p",{className:"text-zinc-400 text-sm",children:d}),e.jsxs("div",{className:"flex items-center justify-center gap-1 mt-1 text-zinc-500 text-xs",children:[e.jsx("svg",{className:"w-3.5 h-3.5",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{d:"M5.5 16a3.5 3.5 0 01-.369-6.98 4 4 0 117.753-1.977A4.5 4.5 0 1113.5 16h-8z"})}),e.jsx("span",{children:"19°C"})]})]}),e.jsx("div",{className:"h-24"}),e.jsx("div",{className:"px-4 pb-8",children:e.jsxs("button",{onClick:t,className:`w-full bg-white rounded-2xl p-3 flex items-center gap-3 shadow-lg
|
|
205
|
+
transition-transform active:scale-[0.98] hover:shadow-xl`,children:[e.jsx("div",{className:"w-12 h-12 rounded-xl bg-zinc-900 flex items-center justify-center flex-shrink-0 overflow-hidden",children:o.logo?e.jsx("img",{src:o.logo,alt:o.name,className:"w-full h-full object-cover"}):e.jsx("div",{className:"text-white",children:e.jsxs("svg",{className:"w-7 h-7",viewBox:"0 0 24 24",fill:"currentColor",children:[e.jsx("circle",{cx:"12",cy:"12",r:"1.5"}),e.jsx("circle",{cx:"12",cy:"6",r:"1"}),e.jsx("circle",{cx:"12",cy:"18",r:"1"}),e.jsx("circle",{cx:"6",cy:"12",r:"1"}),e.jsx("circle",{cx:"18",cy:"12",r:"1"}),e.jsx("circle",{cx:"8",cy:"8",r:"0.8"}),e.jsx("circle",{cx:"16",cy:"8",r:"0.8"}),e.jsx("circle",{cx:"8",cy:"16",r:"0.8"}),e.jsx("circle",{cx:"16",cy:"16",r:"0.8"}),e.jsx("circle",{cx:"6",cy:"6",r:"0.5"}),e.jsx("circle",{cx:"18",cy:"6",r:"0.5"}),e.jsx("circle",{cx:"6",cy:"18",r:"0.5"}),e.jsx("circle",{cx:"18",cy:"18",r:"0.5"})]})})}),e.jsxs("div",{className:"flex-1 text-left min-w-0",children:[e.jsx("p",{className:"text-sm font-semibold text-gray-900 truncate",children:o.name}),e.jsx("p",{className:"text-sm text-gray-500 truncate",children:s})]}),e.jsx("span",{className:"text-xs text-gray-400 flex-shrink-0",children:"now"})]})}),e.jsx("div",{className:"flex-1"}),e.jsx("div",{className:"flex justify-center pb-2",children:e.jsx("div",{className:"w-32 h-1 rounded-full bg-zinc-600"})})]})}),O={name:"Business",verified:!1},We=l.memo(function({flow:t,onUserReply:s,theme:r,device:o,businessInfo:a,showSuggestions:i}){const{state:u,handleReply:c,handleAction:d}=ce({flow:t,onUserReply:s,typingDelay:800}),[h,m]=l.useState(!1),y=l.useCallback(()=>{m(x=>!x)},[]),[g,k]=l.useState(null),p=l.useCallback(x=>{k({...x,isOpen:!0})},[]),f=l.useCallback(()=>{k(null)},[]),b=l.useCallback(x=>{if(!C(x))return;const j=P(x);if(j){p({url:j.url,viewMode:j.webviewViewMode||"TALL",title:j.description||"",postbackData:x.action.postback.data}),s({type:"action",postbackData:x.action.postback.data,displayText:x.action.displayText,timestamp:Date.now(),actionData:{type:"webview",url:j.url,viewMode:j.webviewViewMode||"TALL",description:j.description}});return}d(x)},[d,p,s]);return e.jsxs(F,{theme:r,device:o,businessInfo:a,state:u,showSuggestions:i,isProfileOpen:h,toggleProfile:y,onReply:c,onAction:b,webView:g,openWebView:p,closeWebView:f,children:[e.jsx(Se,{}),h&&e.jsx(Te,{}),e.jsx(Z,{})]})}),K=l.memo(function({messages:t,jsonUrl:s,onUserReply:r,theme:o="light",device:a="android",businessInfo:i,className:u="",width:c=375,height:d=667,showSuggestions:h=!0,showLockScreen:m=!1}){const[y,g]=l.useState(m),k=l.useCallback(()=>{g(!1)},[]),{data:p,isLoading:f,error:b}=X(s),x=s?p:t,j=l.useMemo(()=>x?J(x):!1,[x]),N=l.useMemo(()=>({...O,...i,name:i?.name||x?.name||O.name}),[i,x?.name]),M=l.useMemo(()=>x&&j?Y(x):"New message",[x,j]),w=o==="dark",L=({children:z})=>e.jsx("div",{className:`
|
|
206
206
|
rcs-emulator relative overflow-hidden
|
|
207
207
|
rounded-2xl shadow-2xl
|
|
208
|
-
${
|
|
209
|
-
${
|
|
210
|
-
`,style:{width:
|
|
208
|
+
${w?"bg-zinc-950":"bg-white"}
|
|
209
|
+
${u}
|
|
210
|
+
`,style:{width:c,height:d},role:"application","aria-label":"RCS Message Emulator","data-theme":o,"data-device":a,children:z});return s&&f?e.jsx(L,{children:e.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-6",children:[e.jsx("div",{className:`
|
|
211
211
|
w-10 h-10 border-3 border-t-transparent rounded-full animate-spin mb-4
|
|
212
|
-
${
|
|
213
|
-
|
|
212
|
+
${w?"border-zinc-600":"border-gray-300"}
|
|
213
|
+
`,style:{borderTopColor:"transparent"}}),e.jsx("p",{className:`text-sm ${w?"text-zinc-400":"text-gray-500"}`,children:"Loading conversation..."})]})}):s&&b?e.jsx(L,{children:e.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-6 text-center",children:[e.jsx("svg",{className:"w-12 h-12 mx-auto mb-4 text-red-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),e.jsx("h3",{className:`text-lg font-medium mb-2 ${w?"text-white":"text-gray-900"}`,children:"Failed to Load"}),e.jsx("p",{className:`text-sm ${w?"text-zinc-400":"text-gray-500"}`,children:b}),e.jsx("p",{className:`text-xs mt-2 break-all max-w-full ${w?"text-zinc-500":"text-gray-400"}`,children:s})]})}):x?j?e.jsx(L,{children:y?e.jsx(F,{theme:o,device:a,businessInfo:N,state:{currentMessageId:null,chatHistory:[],isTyping:!1,error:null},showSuggestions:!1,isProfileOpen:!1,toggleProfile:()=>{},onReply:()=>{},onAction:()=>{},webView:null,openWebView:()=>{},closeWebView:()=>{},children:e.jsx(Be,{onUnlock:k,messagePreview:M})}):e.jsx(We,{flow:x,onUserReply:r,theme:o,device:a,businessInfo:N,showSuggestions:h})}):e.jsx(L,{children:e.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-6 text-center",children:[e.jsx("svg",{className:"w-12 h-12 mx-auto mb-4 text-amber-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),e.jsx("h3",{className:`text-lg font-medium mb-2 ${w?"text-white":"text-gray-900"}`,children:"Invalid RBM JSON"}),e.jsx("p",{className:`text-sm ${w?"text-zinc-400":"text-gray-500"}`,children:"The conversation flow structure is not valid"})]})}):e.jsx(L,{children:e.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-6 text-center",children:[e.jsx("svg",{className:`w-12 h-12 mx-auto mb-4 ${w?"text-zinc-600":"text-gray-300"}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})}),e.jsx("h3",{className:`text-lg font-medium mb-2 ${w?"text-white":"text-gray-900"}`,children:"No Conversation Data"}),e.jsxs("p",{className:`text-sm ${w?"text-zinc-400":"text-gray-500"}`,children:["Provide either"," ",e.jsx("code",{className:"px-1 py-0.5 rounded bg-gray-100 dark:bg-zinc-800",children:"messages"})," ","or"," ",e.jsx("code",{className:"px-1 py-0.5 rounded bg-gray-100 dark:bg-zinc-800",children:"jsonUrl"})," ","prop"]})]})})});exports.RcsEmulator=K;exports.WebViewRenderer=Z;exports.default=K;exports.getFirstMessagePreview=Y;exports.getWebViewConfig=P;exports.isSuggestedAction=C;exports.isSuggestedReply=W;exports.isWebViewAction=te;exports.useJsonFetch=X;exports.validateConversationFlow=J;
|
|
214
214
|
//# sourceMappingURL=rcs-emulator.cjs.js.map
|