@botuyo/chat-widget-standalone 1.0.48 → 1.0.49
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/botuyo-chat.es.js +1 -1
- package/dist/botuyo-chat.umd.js +1 -1
- package/dist/botuyo-chat.umd.js.map +1 -1
- package/dist/{chunk-audio-CyGpZ-uC.js → chunk-audio-C2yGhaaL.js} +2 -2
- package/dist/{chunk-audio-CyGpZ-uC.js.map → chunk-audio-C2yGhaaL.js.map} +1 -1
- package/dist/{chunk-chat-ui-BMNIwxGE.js → chunk-chat-ui-FjQZGYF0.js} +13 -13
- package/dist/{chunk-chat-ui-BMNIwxGE.js.map → chunk-chat-ui-FjQZGYF0.js.map} +1 -1
- package/dist/{chunk-gallery-BbhpBhzp.js → chunk-gallery-BeGSPPtK.js} +2 -2
- package/dist/{chunk-gallery-BbhpBhzp.js.map → chunk-gallery-BeGSPPtK.js.map} +1 -1
- package/dist/src/chat-widget/components/VoiceCallOverlay.d.ts.map +1 -1
- package/dist/stats-umd.html +1 -1
- package/dist/stats.html +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{jsxs as r,jsx as e,Fragment as a}from"react/jsx-runtime";import{memo as t,useState as l,useRef as o,useMemo as n,useCallback as i}from"react";import{g as s,c,R as d,L as u,P as h,a as m,C as f}from"./chunk-chat-ui-
|
|
1
|
+
import{jsxs as r,jsx as e,Fragment as a}from"react/jsx-runtime";import{memo as t,useState as l,useRef as o,useMemo as n,useCallback as i}from"react";import{g as s,c,R as d,L as u,P as h,a as m,C as f}from"./chunk-chat-ui-FjQZGYF0.js";const p=t(function({url:t,isBot:p,primaryColor:y}){const[x,N]=l(!1),[g,w]=l(0),[b,v]=l(0),[C,k]=l(!0),[j,M]=l(null),P=o(null),S=n(()=>s({primaryColor:y}),[y]),E=i(()=>{j||(x?P.current?.pause():P.current?.play().catch(r=>{console.error("[AudioPlayer] Play error:",r),M("Error al reproducir")}),N(!x))},[x,j]),T=i(()=>{w(P.current?.duration||0)},[]),$=i(()=>{k(!1),M(null)},[]),A=i(()=>{console.error("[AudioPlayer] Failed to load audio:",t),k(!1),M("No se pudo cargar")},[t]),L=i(()=>{k(!0),M(null),P.current&&P.current.load()},[]);/* @__PURE__ */
|
|
2
2
|
return r("div",{className:c("flex items-center gap-3 py-1 min-w-[200px]",p?"text-foreground":"text-primary-foreground"),children:[
|
|
3
3
|
/* @__PURE__ */e("audio",{ref:P,src:t,preload:"metadata",onLoadedMetadata:T,onCanPlayThrough:$,onTimeUpdate:()=>v(P.current?.currentTime||0),onEnded:()=>N(!1),onError:A}),
|
|
4
4
|
/* @__PURE__ */e("button",j?{onClick:L,className:"w-8 h-8 rounded-full flex items-center justify-center shrink-0 bg-red-500/20 text-red-500 hover:bg-red-500/30 transition-colors",title:"Reintentar",children:/* @__PURE__ */e(d,{className:"w-4 h-4"})}:{onClick:E,disabled:C,className:"w-8 h-8 rounded-full flex items-center justify-center shrink-0 transition-opacity",style:{backgroundColor:p?S:"hsl(var(--card))",color:p?"white":S,opacity:C?.6:1},children:C?/* @__PURE__ */e(u,{className:"w-4 h-4 animate-spin"}):x?/* @__PURE__ */e(h,{className:"w-4 h-4 fill-current"}):/* @__PURE__ */e(m,{className:"w-4 h-4 fill-current ml-0.5"})}),
|
|
@@ -9,4 +9,4 @@ return r("div",{className:c("flex items-center gap-3 py-1 min-w-[200px]",p?"text
|
|
|
9
9
|
/* @__PURE__ */r("div",{className:"flex justify-between text-[9px] font-bold opacity-60",children:[
|
|
10
10
|
/* @__PURE__ */r("span",{children:[Math.floor(b/60),":",Math.floor(b%60).toString().padStart(2,"0")]}),
|
|
11
11
|
/* @__PURE__ */e("span",{children:C?"--:--":`${Math.floor(g/60)}:${Math.floor(g%60).toString().padStart(2,"0")}`})]})]})})]})});export{p as AudioPlayer};
|
|
12
|
-
//# sourceMappingURL=chunk-audio-
|
|
12
|
+
//# sourceMappingURL=chunk-audio-C2yGhaaL.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chunk-audio-
|
|
1
|
+
{"version":3,"file":"chunk-audio-C2yGhaaL.js","sources":["../src/chat-widget/components/AudioPlayer.tsx"],"sourcesContent":["'use client'\r\n\r\nimport { useState, useRef, useMemo, memo, useCallback } from 'react'\r\nimport { Play, Pause, Loader2, AlertCircle, RotateCw } from './Icons'\r\nimport { cn } from '@/lib/utils'\r\nimport { getPrimaryColor } from '../utils/theme'\r\n\r\ninterface AudioPlayerProps {\r\n url: string\r\n isBot: boolean\r\n primaryColor?: string\r\n}\r\n\r\nexport type { AudioPlayerProps }\r\n\r\nexport const AudioPlayer = memo(function AudioPlayer({\r\n url,\r\n isBot,\r\n primaryColor,\r\n}: AudioPlayerProps) {\r\n const [isPlaying, setIsPlaying] = useState(false)\r\n const [duration, setDuration] = useState(0)\r\n const [currentTime, setCurrentTime] = useState(0)\r\n // Blob URLs from URL.createObjectURL() are valid during the current session\r\n const [isLoading, setIsLoading] = useState(true)\r\n const [error, setError] = useState<string | null>(null)\r\n const audioRef = useRef<HTMLAudioElement>(null)\r\n\r\n const brandColor = useMemo(() => getPrimaryColor({ primaryColor }), [primaryColor])\r\n\r\n const togglePlay = useCallback(() => {\r\n if (error) return\r\n if (isPlaying) audioRef.current?.pause()\r\n else audioRef.current?.play().catch((e) => {\r\n console.error('[AudioPlayer] Play error:', e)\r\n setError('Error al reproducir')\r\n })\r\n setIsPlaying(!isPlaying)\r\n }, [isPlaying, error])\r\n\r\n const handleLoadedMetadata = useCallback(() => {\r\n setDuration(audioRef.current?.duration || 0)\r\n }, [])\r\n\r\n const handleCanPlayThrough = useCallback(() => {\r\n setIsLoading(false)\r\n setError(null)\r\n }, [])\r\n\r\n const handleError = useCallback(() => {\r\n console.error('[AudioPlayer] Failed to load audio:', url)\r\n setIsLoading(false)\r\n setError('No se pudo cargar')\r\n }, [url])\r\n\r\n const handleRetry = useCallback(() => {\r\n setIsLoading(true)\r\n setError(null)\r\n if (audioRef.current) {\r\n audioRef.current.load()\r\n }\r\n }, [])\r\n\r\n return (\r\n <div\r\n className={cn(\r\n 'flex items-center gap-3 py-1 min-w-[200px]',\r\n isBot ? 'text-foreground' : 'text-primary-foreground'\r\n )}\r\n >\r\n {/* Always render <audio> — onError handles expired URLs naturally */}\r\n <audio\r\n ref={audioRef}\r\n src={url}\r\n preload=\"metadata\"\r\n onLoadedMetadata={handleLoadedMetadata}\r\n onCanPlayThrough={handleCanPlayThrough}\r\n onTimeUpdate={() => setCurrentTime(audioRef.current?.currentTime || 0)}\r\n onEnded={() => setIsPlaying(false)}\r\n onError={handleError}\r\n />\r\n \r\n {error ? (\r\n // Error state - show retry button\r\n <button\r\n onClick={handleRetry}\r\n className=\"w-8 h-8 rounded-full flex items-center justify-center shrink-0 bg-red-500/20 text-red-500 hover:bg-red-500/30 transition-colors\"\r\n title=\"Reintentar\"\r\n >\r\n <RotateCw className=\"w-4 h-4\" />\r\n </button>\r\n ) : (\r\n // Normal play/pause button\r\n <button\r\n onClick={togglePlay}\r\n disabled={isLoading}\r\n className=\"w-8 h-8 rounded-full flex items-center justify-center shrink-0 transition-opacity\"\r\n style={{\r\n backgroundColor: isBot ? brandColor : 'hsl(var(--card))',\r\n color: isBot ? 'white' : brandColor,\r\n opacity: isLoading ? 0.6 : 1,\r\n }}\r\n >\r\n {isLoading ? (\r\n <Loader2 className=\"w-4 h-4 animate-spin\" />\r\n ) : isPlaying ? (\r\n <Pause className=\"w-4 h-4 fill-current\" />\r\n ) : (\r\n <Play className=\"w-4 h-4 fill-current ml-0.5\" />\r\n )}\r\n </button>\r\n )}\r\n \r\n <div className=\"flex-1 space-y-1\">\r\n {error ? (\r\n <div className=\"flex items-center gap-1.5 text-red-500\">\r\n <AlertCircle className=\"w-3 h-3\" />\r\n <span className=\"text-[9px] font-bold\">{error}</span>\r\n </div>\r\n ) : (\r\n <>\r\n <div className=\"relative h-1 w-full bg-current/20 rounded-full overflow-hidden\">\r\n <div\r\n className=\"absolute h-full bg-current rounded-full transition-all\"\r\n style={{ width: `${(currentTime / duration) * 100 || 0}%` }}\r\n />\r\n </div>\r\n <div className=\"flex justify-between text-[9px] font-bold opacity-60\">\r\n <span>\r\n {Math.floor(currentTime / 60)}:\r\n {Math.floor(currentTime % 60)\r\n .toString()\r\n .padStart(2, '0')}\r\n </span>\r\n <span>\r\n {isLoading ? '--:--' : `${Math.floor(duration / 60)}:${Math.floor(duration % 60).toString().padStart(2, '0')}`}\r\n </span>\r\n </div>\r\n </>\r\n )}\r\n </div>\r\n </div>\r\n )\r\n})\r\n"],"names":["AudioPlayer","memo","url","isBot","primaryColor","isPlaying","setIsPlaying","useState","duration","setDuration","currentTime","setCurrentTime","isLoading","setIsLoading","error","setError","audioRef","useRef","brandColor","useMemo","getPrimaryColor","togglePlay","useCallback","current","pause","play","catch","e","console","handleLoadedMetadata","handleCanPlayThrough","handleError","handleRetry","load","jsxs","className","cn","children","jsx","ref","src","preload","onLoadedMetadata","onCanPlayThrough","onTimeUpdate","onEnded","onError","onClick","title","RotateCw","disabled","style","backgroundColor","color","opacity","Loader2","Pause","Play","AlertCircle","Fragment","width","Math","floor","toString","padStart"],"mappings":"0OAeO,MAAMA,EAAcC,EAAK,UAAqBC,IACnDA,EAAAC,MACAA,EAAAC,aACAA,IAEA,MAAOC,EAAWC,GAAgBC,GAAS,IACpCC,EAAUC,GAAeF,EAAS,IAClCG,EAAaC,GAAkBJ,EAAS,IAExCK,EAAWC,GAAgBN,GAAS,IACpCO,EAAOC,GAAYR,EAAwB,MAC5CS,EAAWC,EAAyB,MAEpCC,EAAaC,EAAQ,IAAMC,EAAgB,CAAEhB,iBAAiB,CAACA,IAE/DiB,EAAaC,EAAY,KACzBR,IACAT,EAAWW,EAASO,SAASC,UACnBD,SAASE,OAAOC,MAAOC,IACnCC,QAAQd,MAAM,4BAA6Ba,GAC3CZ,EAAS,yBAEXT,GAAcD,KACb,CAACA,EAAWS,IAETe,EAAuBP,EAAY,KACvCb,EAAY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