@telnyx/ai-chat-widget 2.4.1 → 2.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +1 -4
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +1 -4
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -775,9 +775,6 @@ React keys must be passed directly to JSX without using spread:
|
|
|
775
775
|
.items-center {
|
|
776
776
|
align-items: center;
|
|
777
777
|
}
|
|
778
|
-
.items-end {
|
|
779
|
-
align-items: flex-end;
|
|
780
|
-
}
|
|
781
778
|
.items-start {
|
|
782
779
|
align-items: flex-start;
|
|
783
780
|
}
|
|
@@ -2538,7 +2535,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
2538
2535
|
*
|
|
2539
2536
|
* This source code is licensed under the ISC license.
|
|
2540
2537
|
* See the LICENSE file in the root directory of this source tree.
|
|
2541
|
-
*/const vF=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],EF=dR("zap",vF);function wF(e){const t=e+"CollectionProvider",[n,r]=Ea(t),[a,i]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=m=>{const{scope:v,children:h}=m,b=O.useRef(null),y=O.useRef(new Map).current;return w.jsx(a,{scope:v,itemMap:y,collectionRef:b,children:h})};o.displayName=t;const s=e+"CollectionSlot",l=cf(s),u=O.forwardRef((m,v)=>{const{scope:h,children:b}=m,y=i(s,h),S=Jt(v,y.collectionRef);return w.jsx(l,{ref:S,children:b})});u.displayName=s;const c=e+"CollectionItemSlot",d="data-radix-collection-item",p=cf(c),f=O.forwardRef((m,v)=>{const{scope:h,children:b,...y}=m,S=O.useRef(null),x=Jt(v,S),E=i(c,h);return O.useEffect(()=>(E.itemMap.set(S,{ref:S,...y}),()=>void E.itemMap.delete(S))),w.jsx(p,{[d]:"",ref:x,children:b})});f.displayName=c;function g(m){const v=i(e+"CollectionConsumer",m);return O.useCallback(()=>{const b=v.collectionRef.current;if(!b)return[];const y=Array.from(b.querySelectorAll(`[${d}]`));return Array.from(v.itemMap.values()).sort((E,T)=>y.indexOf(E.ref.current)-y.indexOf(T.ref.current))},[v.collectionRef,v.itemMap])}return[{Provider:o,Slot:u,ItemSlot:f},g,r]}var SF=N.createContext(void 0);function pR(e){const t=N.useContext(SF);return e||t||"ltr"}var To="rovingFocusGroup.onEntryFocus",xF={bubbles:!1,cancelable:!0},Ta="RovingFocusGroup",[yf,fR,TF]=wF(Ta),[AF,gR]=Ea(Ta,[TF]),[kF,RF]=AF(Ta),mR=N.forwardRef((e,t)=>w.jsx(yf.Provider,{scope:e.__scopeRovingFocusGroup,children:w.jsx(yf.Slot,{scope:e.__scopeRovingFocusGroup,children:w.jsx(IF,{...e,ref:t})})}));mR.displayName=Ta;var IF=N.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:a=!1,dir:i,currentTabStopId:o,defaultCurrentTabStopId:s,onCurrentTabStopIdChange:l,onEntryFocus:u,preventScrollOnEntryFocus:c=!1,...d}=e,p=N.useRef(null),f=Jt(t,p),g=pR(i),[m,v]=xa({prop:o,defaultProp:s??null,onChange:l,caller:Ta}),[h,b]=N.useState(!1),y=wa(u),S=fR(n),x=N.useRef(!1),[E,T]=N.useState(0);return N.useEffect(()=>{const k=p.current;if(k)return k.addEventListener(To,y),()=>k.removeEventListener(To,y)},[y]),w.jsx(kF,{scope:n,orientation:r,dir:g,loop:a,currentTabStopId:m,onItemFocus:N.useCallback(k=>v(k),[v]),onItemShiftTab:N.useCallback(()=>b(!0),[]),onFocusableItemAdd:N.useCallback(()=>T(k=>k+1),[]),onFocusableItemRemove:N.useCallback(()=>T(k=>k-1),[]),children:w.jsx(Pt.div,{tabIndex:h||E===0?-1:0,"data-orientation":r,...d,ref:f,style:{outline:"none",...e.style},onMouseDown:rt(e.onMouseDown,()=>{x.current=!0}),onFocus:rt(e.onFocus,k=>{const C=!x.current;if(k.target===k.currentTarget&&C&&!h){const I=new CustomEvent(To,xF);if(k.currentTarget.dispatchEvent(I),!I.defaultPrevented){const D=S().filter(H=>H.focusable),B=D.find(H=>H.active),P=D.find(H=>H.id===m),z=[B,P,...D].filter(Boolean).map(H=>H.ref.current);yR(z,c)}}x.current=!1}),onBlur:rt(e.onBlur,()=>b(!1))})})}),hR="RovingFocusGroupItem",bR=N.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:a=!1,tabStopId:i,children:o,...s}=e,l=Ck(),u=i||l,c=RF(hR,n),d=c.currentTabStopId===u,p=fR(n),{onFocusableItemAdd:f,onFocusableItemRemove:g,currentTabStopId:m}=c;return N.useEffect(()=>{if(r)return f(),()=>g()},[r,f,g]),w.jsx(yf.ItemSlot,{scope:n,id:u,focusable:r,active:a,children:w.jsx(Pt.span,{tabIndex:d?0:-1,"data-orientation":c.orientation,...s,ref:t,onMouseDown:rt(e.onMouseDown,v=>{r?c.onItemFocus(u):v.preventDefault()}),onFocus:rt(e.onFocus,()=>c.onItemFocus(u)),onKeyDown:rt(e.onKeyDown,v=>{if(v.key==="Tab"&&v.shiftKey){c.onItemShiftTab();return}if(v.target!==v.currentTarget)return;const h=NF(v,c.orientation,c.dir);if(h!==void 0){if(v.metaKey||v.ctrlKey||v.altKey||v.shiftKey)return;v.preventDefault();let y=p().filter(S=>S.focusable).map(S=>S.ref.current);if(h==="last")y.reverse();else if(h==="prev"||h==="next"){h==="prev"&&y.reverse();const S=y.indexOf(v.currentTarget);y=c.loop?OF(y,S+1):y.slice(S+1)}setTimeout(()=>yR(y))}}),children:typeof o=="function"?o({isCurrentTabStop:d,hasTabStop:m!=null}):o})})});bR.displayName=hR;var CF={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function _F(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function NF(e,t,n){const r=_F(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return CF[r]}function yR(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function OF(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var LF=mR,DF=bR,vR="Toggle",ER=N.forwardRef((e,t)=>{const{pressed:n,defaultPressed:r,onPressedChange:a,...i}=e,[o,s]=xa({prop:n,onChange:a,defaultProp:r??!1,caller:vR});return w.jsx(Pt.button,{type:"button","aria-pressed":o,"data-state":o?"on":"off","data-disabled":e.disabled?"":void 0,...i,ref:t,onClick:rt(e.onClick,()=>{e.disabled||s(!o)})})});ER.displayName=vR;var Tn="ToggleGroup",[wR,z6]=Ea(Tn,[gR]),SR=gR(),Ng=O.forwardRef((e,t)=>{const{type:n,...r}=e;if(n==="single"){const a=r;return w.jsx(MF,{...a,ref:t})}if(n==="multiple"){const a=r;return w.jsx(PF,{...a,ref:t})}throw new Error(`Missing prop \`type\` expected on \`${Tn}\``)});Ng.displayName=Tn;var[xR,TR]=wR(Tn),MF=O.forwardRef((e,t)=>{const{value:n,defaultValue:r,onValueChange:a=()=>{},...i}=e,[o,s]=xa({prop:n,defaultProp:r??"",onChange:a,caller:Tn});return w.jsx(xR,{scope:e.__scopeToggleGroup,type:"single",value:O.useMemo(()=>o?[o]:[],[o]),onItemActivate:s,onItemDeactivate:O.useCallback(()=>s(""),[s]),children:w.jsx(AR,{...i,ref:t})})}),PF=O.forwardRef((e,t)=>{const{value:n,defaultValue:r,onValueChange:a=()=>{},...i}=e,[o,s]=xa({prop:n,defaultProp:r??[],onChange:a,caller:Tn}),l=O.useCallback(c=>s((d=[])=>[...d,c]),[s]),u=O.useCallback(c=>s((d=[])=>d.filter(p=>p!==c)),[s]);return w.jsx(xR,{scope:e.__scopeToggleGroup,type:"multiple",value:o,onItemActivate:l,onItemDeactivate:u,children:w.jsx(AR,{...i,ref:t})})});Ng.displayName=Tn;var[FF,BF]=wR(Tn),AR=O.forwardRef((e,t)=>{const{__scopeToggleGroup:n,disabled:r=!1,rovingFocus:a=!0,orientation:i,dir:o,loop:s=!0,...l}=e,u=SR(n),c=pR(o),d={role:"group",dir:c,...l};return w.jsx(FF,{scope:n,rovingFocus:a,disabled:r,children:a?w.jsx(LF,{asChild:!0,...u,orientation:i,dir:c,loop:s,children:w.jsx(Pt.div,{...d,ref:t})}):w.jsx(Pt.div,{...d,ref:t})})}),mi="ToggleGroupItem",kR=O.forwardRef((e,t)=>{const n=TR(mi,e.__scopeToggleGroup),r=BF(mi,e.__scopeToggleGroup),a=SR(e.__scopeToggleGroup),i=n.value.includes(e.value),o=r.disabled||e.disabled,s={...e,pressed:i,disabled:o},l=O.useRef(null);return r.rovingFocus?w.jsx(DF,{asChild:!0,...a,focusable:!o,active:i,ref:l,children:w.jsx(vb,{...s,ref:t})}):w.jsx(vb,{...s,ref:t})});kR.displayName=mi;var vb=O.forwardRef((e,t)=>{const{__scopeToggleGroup:n,value:r,...a}=e,i=TR(mi,n),o={role:"radio","aria-checked":e.pressed,"aria-pressed":void 0},s=i.type==="single"?o:void 0;return w.jsx(ER,{...s,...a,ref:t,onPressedChange:l=>{l?i.onItemActivate(r):i.onItemDeactivate(r)}})}),UF=Ng,jF=kR;const RR=N.createContext({size:"default",variant:"default"}),IR=N.forwardRef(({className:e,size:t="default",variant:n="default",children:r,...a},i)=>w.jsx(UF,{ref:i,className:te("flex items-center gap-1",e),...a,children:w.jsx(RR.Provider,{value:{size:t,variant:n},children:r})}));IR.displayName="ToggleGroup";const Ao={base:"inline-flex flex-1 items-center justify-center gap-1.5 rounded-full text-xs font-medium transition-all cursor-pointer focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",variant:{default:"bg-transparent text-gray-500 hover:bg-gray-100 hover:text-gray-700 data-[state=on]:bg-black data-[state=on]:text-white",outline:"border border-neutral-500 bg-transparent text-neutral-500 hover:bg-telnyx-cream hover:text-gray-700 data-[state=on]:border-black data-[state=on]:bg-black data-[state=on]:text-white",telnyx:"border border-black bg-transparent text-black hover:bg-telnyx-cream hover:text-gray-700 data-[state=on]:border-black data-[state=on]:bg-black data-[state=on]:text-telnyx-green"},size:{default:"px-3 py-1.5",xs:"px-1.5 py-0.5",sm:"px-2.5 py-1",lg:"px-4 py-2"}},vf=N.forwardRef(({className:e,children:t,variant:n,size:r,...a},i)=>{const o=N.useContext(RR),s=n||o.variant||"default",l=r||o.size||"default";return w.jsx(jF,{ref:i,className:te(Ao.base,Ao.variant[s],Ao.size[l],e),...a,children:t})});vf.displayName="ToggleGroupItem";const zF=200;function GF(){const[e,t]=O.useState(!1),n=O.useRef(null),r=J(p=>p.endpoint),a=J(p=>p.setEndpoint),i=J(p=>p.botState),o=i==="loading"||i==="streaming",s=p=>{p&&a(p)},l=()=>{n.current=setTimeout(()=>{t(!0)},zF)},u=()=>{n.current&&(clearTimeout(n.current),n.current=null),t(!1)},c=Jp[we.FLOW],d=Jp[we.AIDA];return w.jsx(ge.div,{className:te("relative z-0","border-2 border-black bg-telnyx-dark-cream","rounded-t-xl","px-1 pt-0.5 pb-3.5","transition-[padding]",o&&"hidden"),onHoverStart:l,onHoverEnd:u,animate:{y:14},transition:{duration:.2,ease:"easeOut"},children:w.jsxs(IR,{type:"single",value:r,onValueChange:s,disabled:o,className:te("flex items-center justify-between","transition-[gap] duration-200 ease-out",e?"gap-1":"gap-0"),children:[w.jsxs(en,{children:[w.jsx(tn,{asChild:!0,children:w.jsx("span",{className:te("flex flex-1",!e&&r!==we.FLOW&&"hidden"),children:w.jsxs(vf,{value:we.FLOW,"aria-label":"Instant mode",variant:"telnyx",className:te("flex-1 transition-all duration-200 ease-out",e?"px-2.5 py-1 text-xs":"px-2 py-0.5 text-[8px]"),children:[w.jsx(EF,{className:te("transition-all duration-200",e?"size-3":"size-2")}),w.jsx("span",{children:"Instant"})]})})}),w.jsx(Vt,{side:"top",align:"start",className:"p-0",children:w.jsxs("div",{className:"p-3 max-w-[220px] space-y-2",children:[w.jsx("p",{className:"font-semibold text-sm",children:c.tooltip.title}),w.jsx("ul",{className:"space-y-1",children:c.tooltip.capabilities.map(p=>w.jsxs("li",{className:"text-xs flex items-center gap-1.5",children:[w.jsx("span",{className:"text-green-400",children:"✓"}),w.jsx("span",{children:p})]},p))}),w.jsxs("div",{className:"text-xs flex items-center gap-1.5 text-gray-300",children:[w.jsx("span",{children:"⏱"}),w.jsx("span",{children:c.tooltip.timing})]})]})})]}),w.jsxs(en,{children:[w.jsx(tn,{asChild:!0,children:w.jsx("span",{className:te("flex flex-1",!e&&r!==we.AIDA&&"hidden"),children:w.jsxs(vf,{value:we.AIDA,"aria-label":"Heavy thinking mode",variant:"telnyx",className:te("flex-1 transition-all duration-200 ease-out",e?"px-2.5 py-1 text-xs":"px-2 py-0.5 text-[8px]"),children:[w.jsx(yF,{className:te("transition-all duration-200",e?"size-3":"size-2")}),w.jsx("span",{children:"Heavy thinking"})]})})}),w.jsx(Vt,{side:"top",align:"end",className:"p-0",children:w.jsxs("div",{className:"p-3 max-w-[220px] space-y-2",children:[w.jsx("p",{className:"font-semibold text-sm",children:d.tooltip.title}),w.jsx("ul",{className:"space-y-1",children:d.tooltip.capabilities.map(p=>w.jsxs("li",{className:"text-xs flex items-center gap-1.5",children:[w.jsx("span",{className:"text-green-400",children:"✓"}),w.jsx("span",{children:p})]},p))}),w.jsxs("div",{className:"text-xs flex items-center gap-1.5 text-gray-300",children:[w.jsx("span",{children:"⏱"}),w.jsx("span",{children:d.tooltip.timing})]})]})})]})]})})}const qF=ge.create(Sk),VF=ge.create(uR),Eb=e=>({open:t=>({opacity:e==="outline"?t?0:1:t?1:0,top:"50%",left:"50%",x:"calc(-50% + 1px)",y:"calc(-50% - 1px)",rotate:"-45deg"})}),HF=({question:e,handleSendMessage:t})=>{const n=J(i=>i.botState),r=!!e,a=n==="loading"||n==="streaming";return w.jsxs(ge.button,{disabled:!r||a,className:te("bg-telnyx-light-green relative rounded-full p-2 size-8 overflow-clip","cursor-pointer disabled:cursor-default",r&&"shadow-md"),whileHover:r?{scale:.9}:{},whileTap:r?{scale:.7}:{},onClick:t,children:[w.jsx(qF,{className:"absolute size-4.5",initial:!1,variants:Eb("outline"),custom:r,animate:"open"}),w.jsx(VF,{className:"absolute size-4.5",initial:!1,variants:Eb("solid"),custom:r,animate:"open"})]})},CR=O.forwardRef(({message:e,handleInput:t,placeholders:n,handleSendMessage:r},a)=>{const i=J(h=>h.setCustomOpen),o=J(h=>h.botState),s=o==="loading"||o==="streaming",[l,u]=O.useState(0),c=O.useRef(null),d=O.useRef(0),p=O.useRef(null),f=!!i,g=O.useCallback(h=>{p.current=h,typeof a=="function"?a(h):a&&(a.current=h)},[a]);bb(p,"Enter",h=>{var b;h.shiftKey||(h.preventDefault(),r(),(b=p.current)==null||b.blur())},{enabled:!s,shiftKey:!1}),bb(p,"Escape",()=>{var h;(h=p.current)==null||h.blur()});const m=O.useCallback(()=>{if(document.visibilityState!=="visible"&&c.current)return;const h=b=>{b-d.current>=3e3&&(u(y=>(y+1)%n.length),d.current=b),c.current=requestAnimationFrame(h)};d.current=performance.now(),c.current=requestAnimationFrame(h)},[n.length]),v=O.useCallback(()=>{document.visibilityState!=="visible"&&c.current?(cancelAnimationFrame(c.current),c.current=null):document.visibilityState==="visible"&&m()},[m]);return O.useEffect(()=>(m(),document.addEventListener("visibilitychange",v),()=>{c.current&&cancelAnimationFrame(c.current),document.removeEventListener("visibilitychange",v)}),[n,m,v]),w.jsxs("div",{className:"flex flex-col",children:[w.jsx(GF,{}),w.jsx("div",{className:te("flex flex-col rounded-xl border-2 border-black bg-telnyx-cream","transition-all focus-within:ring-1 focus-within:ring-black focus-within:ring-offset-0.5 focus-within:bg-telnyx-dark-cream","relative z-10",s&&"opacity-50"),children:w.jsxs("div",{className:"flex",children:[w.jsxs("div",{className:"pl-4 pt-3 pb-2 flex-1 relative",children:[w.jsx("textarea",{id:"user-message-input",ref:g,value:e,onInput:t,disabled:s,"aria-disabled":s,className:te("w-full max-h-24 bg-transparent text-sm resize-none overflow-y-auto focus:outline-hidden focus:placeholder-black","scrollbar scrollbar-w-1 scrollbar-thumb-rounded-full scrollbar-track-transparent scrollbar-thumb-telnyx-gray-hover-light"),rows:1}),w.jsx("div",{className:"absolute inset-0 flex items-center pointer-events-none",children:w.jsx(nn,{mode:"wait",children:!e&&w.jsx(ge.p,{initial:{y:5,opacity:0},animate:{y:0,opacity:1},exit:{y:-15,opacity:0},transition:{duration:.3,ease:"linear"},className:"text-neutral-500 text-sm pl-4 text-left w-[calc(100%-32px)] truncate",children:n[l]},`current-placeholder-${l}`)})})]}),w.jsx("span",{className:"w-12 flex items-end justify-center mb-0",children:f&&w.jsx(HF,{question:e,handleSendMessage:r})})]})})]})});CR.displayName="FooterTextInput";const $F={[gr.HAS_NOT_BEEN_OPENED]:{y:0},[gr.HAS_BEEN_OPENED]:{y:[0,-3,0],scale:[1,1.01,1],filter:["blur(0px)","blur(5px)","blur(0px)"],opacity:[1,.8,1]}};function WF({text:e,className:t}){const n=J(r=>r.hasWidgetBeenOpened);return e.split("").map((r,a)=>w.jsx(ge.span,{initial:!1,animate:n,variants:$F,transition:{duration:.5,delay:a*.05},className:te("inline-block whitespace-pre font-sans tracking-tight",t),children:r},`${r}-${a}`))}const YF=()=>w.jsxs("div",{className:"flex justify-center text-xs pb-0.5 mt-2",children:[w.jsx(Ui,{className:"h-4 w-4 mr-1"}),w.jsx(WF,{className:"translate-y-0.5 font-pp-formula",text:"Powered by Telnyx"})]}),KF={[dt.INITIAL]:{y:0},[dt.USER_HAS_TYPED]:{y:0,transition:{duration:.2}}},_R=O.forwardRef(({question:e,handleInput:t,handleSendMessage:n},r)=>{const a=J(f=>f.chatVisualState),i=J(f=>f.onHelpAction),o=J(f=>f.botState),s=J(f=>f.getLastMessage()),l=(s==null?void 0:s.show_help_action)===!0,u=a===dt.USER_HAS_TYPED,c=J(f=>f.placeholders),d=o==="error"?["Error!","Please try again."]:c,p=l&&i!==null;return w.jsx("div",{className:te("mt-2 pt-1",u&&"mt-0 mb-2 pt-0"),children:w.jsxs(ge.div,{initial:"initial",animate:a,variants:KF,className:"space-y-1",children:[p&&w.jsx(XF,{onHelpAction:i}),w.jsx(CR,{ref:r,message:e,handleInput:t,handleSendMessage:n,placeholders:d}),!u&&w.jsx(YF,{})]})})});_R.displayName="Footer";const XF=({onHelpAction:e})=>w.jsx("div",{className:"flex items-center justify-center mb-0.5",children:w.jsxs(ge.button,{initial:{scale:.5,opacity:0,y:10},animate:{scale:.75,opacity:1,y:0,transition:{duration:.2}},exit:{scale:.5,y:10,transition:{duration:.2}},whileHover:{scale:.8,transition:{duration:.2}},whileTap:{scale:.7,transition:{duration:.2}},className:te("flex items-center gap-1 rounded-full p-2","bg-black text-white cursor-pointer"),onClick:e,children:[w.jsx("p",{className:"text-sm font-medium text-white",children:"Chat to support"}),w.jsx(eF,{className:"size-5 text-white"})]})}),ZF=({children:e,className:t,containerClassName:n})=>{const r=Zp(0),a=Zp(0),i={default:`url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32' width='16' height='16' fill='none'%3E%3Ccircle fill='%23404040' id='pattern-circle' cx='10' cy='10' r='2.5'%3E%3C/circle%3E%3C/svg%3E")`,hover:`url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32' width='16' height='16' fill='none'%3E%3Ccircle fill='%2300E3AA' id='pattern-circle' cx='10' cy='10' r='2.5'%3E%3C/circle%3E%3C/svg%3E")`};function o({currentTarget:s,clientX:l,clientY:u}){if(!s)return;const{left:c,top:d}=s.getBoundingClientRect();r.set(l-c),a.set(u-d)}return w.jsxs("div",{className:te("group relative h-full w-full items-center bg-black",n),onMouseMove:o,children:[w.jsx("div",{className:"pointer-events-none absolute inset-0",style:{backgroundImage:i.default}}),w.jsx(ge.div,{className:"pointer-events-none absolute inset-0 opacity-0 transition duration-300 group-hover:opacity-100",style:{backgroundImage:i.hover,WebkitMaskImage:Dh`
|
|
2538
|
+
*/const vF=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],EF=dR("zap",vF);function wF(e){const t=e+"CollectionProvider",[n,r]=Ea(t),[a,i]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=m=>{const{scope:v,children:h}=m,b=O.useRef(null),y=O.useRef(new Map).current;return w.jsx(a,{scope:v,itemMap:y,collectionRef:b,children:h})};o.displayName=t;const s=e+"CollectionSlot",l=cf(s),u=O.forwardRef((m,v)=>{const{scope:h,children:b}=m,y=i(s,h),S=Jt(v,y.collectionRef);return w.jsx(l,{ref:S,children:b})});u.displayName=s;const c=e+"CollectionItemSlot",d="data-radix-collection-item",p=cf(c),f=O.forwardRef((m,v)=>{const{scope:h,children:b,...y}=m,S=O.useRef(null),x=Jt(v,S),E=i(c,h);return O.useEffect(()=>(E.itemMap.set(S,{ref:S,...y}),()=>void E.itemMap.delete(S))),w.jsx(p,{[d]:"",ref:x,children:b})});f.displayName=c;function g(m){const v=i(e+"CollectionConsumer",m);return O.useCallback(()=>{const b=v.collectionRef.current;if(!b)return[];const y=Array.from(b.querySelectorAll(`[${d}]`));return Array.from(v.itemMap.values()).sort((E,T)=>y.indexOf(E.ref.current)-y.indexOf(T.ref.current))},[v.collectionRef,v.itemMap])}return[{Provider:o,Slot:u,ItemSlot:f},g,r]}var SF=N.createContext(void 0);function pR(e){const t=N.useContext(SF);return e||t||"ltr"}var To="rovingFocusGroup.onEntryFocus",xF={bubbles:!1,cancelable:!0},Ta="RovingFocusGroup",[yf,fR,TF]=wF(Ta),[AF,gR]=Ea(Ta,[TF]),[kF,RF]=AF(Ta),mR=N.forwardRef((e,t)=>w.jsx(yf.Provider,{scope:e.__scopeRovingFocusGroup,children:w.jsx(yf.Slot,{scope:e.__scopeRovingFocusGroup,children:w.jsx(IF,{...e,ref:t})})}));mR.displayName=Ta;var IF=N.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:a=!1,dir:i,currentTabStopId:o,defaultCurrentTabStopId:s,onCurrentTabStopIdChange:l,onEntryFocus:u,preventScrollOnEntryFocus:c=!1,...d}=e,p=N.useRef(null),f=Jt(t,p),g=pR(i),[m,v]=xa({prop:o,defaultProp:s??null,onChange:l,caller:Ta}),[h,b]=N.useState(!1),y=wa(u),S=fR(n),x=N.useRef(!1),[E,T]=N.useState(0);return N.useEffect(()=>{const k=p.current;if(k)return k.addEventListener(To,y),()=>k.removeEventListener(To,y)},[y]),w.jsx(kF,{scope:n,orientation:r,dir:g,loop:a,currentTabStopId:m,onItemFocus:N.useCallback(k=>v(k),[v]),onItemShiftTab:N.useCallback(()=>b(!0),[]),onFocusableItemAdd:N.useCallback(()=>T(k=>k+1),[]),onFocusableItemRemove:N.useCallback(()=>T(k=>k-1),[]),children:w.jsx(Pt.div,{tabIndex:h||E===0?-1:0,"data-orientation":r,...d,ref:f,style:{outline:"none",...e.style},onMouseDown:rt(e.onMouseDown,()=>{x.current=!0}),onFocus:rt(e.onFocus,k=>{const C=!x.current;if(k.target===k.currentTarget&&C&&!h){const I=new CustomEvent(To,xF);if(k.currentTarget.dispatchEvent(I),!I.defaultPrevented){const D=S().filter(H=>H.focusable),B=D.find(H=>H.active),P=D.find(H=>H.id===m),z=[B,P,...D].filter(Boolean).map(H=>H.ref.current);yR(z,c)}}x.current=!1}),onBlur:rt(e.onBlur,()=>b(!1))})})}),hR="RovingFocusGroupItem",bR=N.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:a=!1,tabStopId:i,children:o,...s}=e,l=Ck(),u=i||l,c=RF(hR,n),d=c.currentTabStopId===u,p=fR(n),{onFocusableItemAdd:f,onFocusableItemRemove:g,currentTabStopId:m}=c;return N.useEffect(()=>{if(r)return f(),()=>g()},[r,f,g]),w.jsx(yf.ItemSlot,{scope:n,id:u,focusable:r,active:a,children:w.jsx(Pt.span,{tabIndex:d?0:-1,"data-orientation":c.orientation,...s,ref:t,onMouseDown:rt(e.onMouseDown,v=>{r?c.onItemFocus(u):v.preventDefault()}),onFocus:rt(e.onFocus,()=>c.onItemFocus(u)),onKeyDown:rt(e.onKeyDown,v=>{if(v.key==="Tab"&&v.shiftKey){c.onItemShiftTab();return}if(v.target!==v.currentTarget)return;const h=NF(v,c.orientation,c.dir);if(h!==void 0){if(v.metaKey||v.ctrlKey||v.altKey||v.shiftKey)return;v.preventDefault();let y=p().filter(S=>S.focusable).map(S=>S.ref.current);if(h==="last")y.reverse();else if(h==="prev"||h==="next"){h==="prev"&&y.reverse();const S=y.indexOf(v.currentTarget);y=c.loop?OF(y,S+1):y.slice(S+1)}setTimeout(()=>yR(y))}}),children:typeof o=="function"?o({isCurrentTabStop:d,hasTabStop:m!=null}):o})})});bR.displayName=hR;var CF={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function _F(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function NF(e,t,n){const r=_F(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return CF[r]}function yR(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function OF(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var LF=mR,DF=bR,vR="Toggle",ER=N.forwardRef((e,t)=>{const{pressed:n,defaultPressed:r,onPressedChange:a,...i}=e,[o,s]=xa({prop:n,onChange:a,defaultProp:r??!1,caller:vR});return w.jsx(Pt.button,{type:"button","aria-pressed":o,"data-state":o?"on":"off","data-disabled":e.disabled?"":void 0,...i,ref:t,onClick:rt(e.onClick,()=>{e.disabled||s(!o)})})});ER.displayName=vR;var Tn="ToggleGroup",[wR,z6]=Ea(Tn,[gR]),SR=gR(),Ng=O.forwardRef((e,t)=>{const{type:n,...r}=e;if(n==="single"){const a=r;return w.jsx(MF,{...a,ref:t})}if(n==="multiple"){const a=r;return w.jsx(PF,{...a,ref:t})}throw new Error(`Missing prop \`type\` expected on \`${Tn}\``)});Ng.displayName=Tn;var[xR,TR]=wR(Tn),MF=O.forwardRef((e,t)=>{const{value:n,defaultValue:r,onValueChange:a=()=>{},...i}=e,[o,s]=xa({prop:n,defaultProp:r??"",onChange:a,caller:Tn});return w.jsx(xR,{scope:e.__scopeToggleGroup,type:"single",value:O.useMemo(()=>o?[o]:[],[o]),onItemActivate:s,onItemDeactivate:O.useCallback(()=>s(""),[s]),children:w.jsx(AR,{...i,ref:t})})}),PF=O.forwardRef((e,t)=>{const{value:n,defaultValue:r,onValueChange:a=()=>{},...i}=e,[o,s]=xa({prop:n,defaultProp:r??[],onChange:a,caller:Tn}),l=O.useCallback(c=>s((d=[])=>[...d,c]),[s]),u=O.useCallback(c=>s((d=[])=>d.filter(p=>p!==c)),[s]);return w.jsx(xR,{scope:e.__scopeToggleGroup,type:"multiple",value:o,onItemActivate:l,onItemDeactivate:u,children:w.jsx(AR,{...i,ref:t})})});Ng.displayName=Tn;var[FF,BF]=wR(Tn),AR=O.forwardRef((e,t)=>{const{__scopeToggleGroup:n,disabled:r=!1,rovingFocus:a=!0,orientation:i,dir:o,loop:s=!0,...l}=e,u=SR(n),c=pR(o),d={role:"group",dir:c,...l};return w.jsx(FF,{scope:n,rovingFocus:a,disabled:r,children:a?w.jsx(LF,{asChild:!0,...u,orientation:i,dir:c,loop:s,children:w.jsx(Pt.div,{...d,ref:t})}):w.jsx(Pt.div,{...d,ref:t})})}),mi="ToggleGroupItem",kR=O.forwardRef((e,t)=>{const n=TR(mi,e.__scopeToggleGroup),r=BF(mi,e.__scopeToggleGroup),a=SR(e.__scopeToggleGroup),i=n.value.includes(e.value),o=r.disabled||e.disabled,s={...e,pressed:i,disabled:o},l=O.useRef(null);return r.rovingFocus?w.jsx(DF,{asChild:!0,...a,focusable:!o,active:i,ref:l,children:w.jsx(vb,{...s,ref:t})}):w.jsx(vb,{...s,ref:t})});kR.displayName=mi;var vb=O.forwardRef((e,t)=>{const{__scopeToggleGroup:n,value:r,...a}=e,i=TR(mi,n),o={role:"radio","aria-checked":e.pressed,"aria-pressed":void 0},s=i.type==="single"?o:void 0;return w.jsx(ER,{...s,...a,ref:t,onPressedChange:l=>{l?i.onItemActivate(r):i.onItemDeactivate(r)}})}),UF=Ng,jF=kR;const RR=N.createContext({size:"default",variant:"default"}),IR=N.forwardRef(({className:e,size:t="default",variant:n="default",children:r,...a},i)=>w.jsx(UF,{ref:i,className:te("flex items-center gap-1",e),...a,children:w.jsx(RR.Provider,{value:{size:t,variant:n},children:r})}));IR.displayName="ToggleGroup";const Ao={base:"inline-flex flex-1 items-center justify-center gap-1.5 rounded-full text-xs font-medium transition-all cursor-pointer focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",variant:{default:"bg-transparent text-gray-500 hover:bg-gray-100 hover:text-gray-700 data-[state=on]:bg-black data-[state=on]:text-white",outline:"border border-neutral-500 bg-transparent text-neutral-500 hover:bg-telnyx-cream hover:text-gray-700 data-[state=on]:border-black data-[state=on]:bg-black data-[state=on]:text-white",telnyx:"border border-black bg-transparent text-black hover:bg-telnyx-cream hover:text-gray-700 data-[state=on]:border-black data-[state=on]:bg-black data-[state=on]:text-telnyx-green"},size:{default:"px-3 py-1.5",xs:"px-1.5 py-0.5",sm:"px-2.5 py-1",lg:"px-4 py-2"}},vf=N.forwardRef(({className:e,children:t,variant:n,size:r,...a},i)=>{const o=N.useContext(RR),s=n||o.variant||"default",l=r||o.size||"default";return w.jsx(jF,{ref:i,className:te(Ao.base,Ao.variant[s],Ao.size[l],e),...a,children:t})});vf.displayName="ToggleGroupItem";const zF=200;function GF(){const[e,t]=O.useState(!1),n=O.useRef(null),r=J(p=>p.endpoint),a=J(p=>p.setEndpoint),i=J(p=>p.botState),o=i==="loading"||i==="streaming",s=p=>{p&&a(p)},l=()=>{n.current=setTimeout(()=>{t(!0)},zF)},u=()=>{n.current&&(clearTimeout(n.current),n.current=null),t(!1)},c=Jp[we.FLOW],d=Jp[we.AIDA];return w.jsx(ge.div,{className:te("relative z-0","border-2 border-black bg-telnyx-dark-cream","rounded-t-xl","px-1 pt-0.5 pb-3.5","transition-[padding]",o&&"hidden"),onHoverStart:l,onHoverEnd:u,animate:{y:14},transition:{duration:.2,ease:"easeOut"},children:w.jsxs(IR,{type:"single",value:r,onValueChange:s,disabled:o,className:te("flex items-center justify-between","transition-[gap] duration-200 ease-out",e?"gap-1":"gap-0"),children:[w.jsxs(en,{children:[w.jsx(tn,{asChild:!0,children:w.jsx("span",{className:te("flex flex-1",!e&&r!==we.FLOW&&"hidden"),children:w.jsxs(vf,{value:we.FLOW,"aria-label":"Instant mode",variant:"telnyx",className:te("flex-1 transition-all duration-200 ease-out",e?"px-2.5 py-1 text-xs":"px-2 py-0.5 text-[8px]"),children:[w.jsx(EF,{className:te("transition-all duration-200",e?"size-3":"size-2")}),w.jsx("span",{children:"Instant"})]})})}),w.jsx(Vt,{side:"top",align:"start",className:"p-0",children:w.jsxs("div",{className:"p-3 max-w-[220px] space-y-2",children:[w.jsx("p",{className:"font-semibold text-sm",children:c.tooltip.title}),w.jsx("ul",{className:"space-y-1",children:c.tooltip.capabilities.map(p=>w.jsxs("li",{className:"text-xs flex items-center gap-1.5",children:[w.jsx("span",{className:"text-green-400",children:"✓"}),w.jsx("span",{children:p})]},p))}),w.jsxs("div",{className:"text-xs flex items-center gap-1.5 text-gray-300",children:[w.jsx("span",{children:"⏱"}),w.jsx("span",{children:c.tooltip.timing})]})]})})]}),w.jsxs(en,{children:[w.jsx(tn,{asChild:!0,children:w.jsx("span",{className:te("flex flex-1",!e&&r!==we.AIDA&&"hidden"),children:w.jsxs(vf,{value:we.AIDA,"aria-label":"Heavy thinking mode",variant:"telnyx",className:te("flex-1 transition-all duration-200 ease-out",e?"px-2.5 py-1 text-xs":"px-2 py-0.5 text-[8px]"),children:[w.jsx(yF,{className:te("transition-all duration-200",e?"size-3":"size-2")}),w.jsx("span",{children:"Heavy thinking"})]})})}),w.jsx(Vt,{side:"top",align:"end",className:"p-0",children:w.jsxs("div",{className:"p-3 max-w-[220px] space-y-2",children:[w.jsx("p",{className:"font-semibold text-sm",children:d.tooltip.title}),w.jsx("ul",{className:"space-y-1",children:d.tooltip.capabilities.map(p=>w.jsxs("li",{className:"text-xs flex items-center gap-1.5",children:[w.jsx("span",{className:"text-green-400",children:"✓"}),w.jsx("span",{children:p})]},p))}),w.jsxs("div",{className:"text-xs flex items-center gap-1.5 text-gray-300",children:[w.jsx("span",{children:"⏱"}),w.jsx("span",{children:d.tooltip.timing})]})]})})]})]})})}const qF=ge.create(Sk),VF=ge.create(uR),Eb=e=>({open:t=>({opacity:e==="outline"?t?0:1:t?1:0,top:"50%",left:"50%",x:"calc(-50% + 1px)",y:"calc(-50% - 1px)",rotate:"-45deg"})}),HF=({question:e,handleSendMessage:t})=>{const n=J(i=>i.botState),r=!!e,a=n==="loading"||n==="streaming";return w.jsxs(ge.button,{disabled:!r||a,className:te("bg-telnyx-light-green relative rounded-full p-2 size-8 overflow-clip","cursor-pointer disabled:cursor-default",r&&"shadow-md"),whileHover:r?{scale:.9}:{},whileTap:r?{scale:.7}:{},onClick:t,children:[w.jsx(qF,{className:"absolute size-4.5",initial:!1,variants:Eb("outline"),custom:r,animate:"open"}),w.jsx(VF,{className:"absolute size-4.5",initial:!1,variants:Eb("solid"),custom:r,animate:"open"})]})},CR=O.forwardRef(({message:e,handleInput:t,placeholders:n,handleSendMessage:r},a)=>{const i=J(h=>h.setCustomOpen),o=J(h=>h.botState),s=o==="loading"||o==="streaming",[l,u]=O.useState(0),c=O.useRef(null),d=O.useRef(0),p=O.useRef(null),f=!!i,g=O.useCallback(h=>{p.current=h,typeof a=="function"?a(h):a&&(a.current=h)},[a]);bb(p,"Enter",h=>{var b;h.shiftKey||(h.preventDefault(),r(),(b=p.current)==null||b.blur())},{enabled:!s,shiftKey:!1}),bb(p,"Escape",()=>{var h;(h=p.current)==null||h.blur()});const m=O.useCallback(()=>{if(document.visibilityState!=="visible"&&c.current)return;const h=b=>{b-d.current>=3e3&&(u(y=>(y+1)%n.length),d.current=b),c.current=requestAnimationFrame(h)};d.current=performance.now(),c.current=requestAnimationFrame(h)},[n.length]),v=O.useCallback(()=>{document.visibilityState!=="visible"&&c.current?(cancelAnimationFrame(c.current),c.current=null):document.visibilityState==="visible"&&m()},[m]);return O.useEffect(()=>(m(),document.addEventListener("visibilitychange",v),()=>{c.current&&cancelAnimationFrame(c.current),document.removeEventListener("visibilitychange",v)}),[n,m,v]),w.jsxs("div",{className:"flex flex-col",children:[w.jsx(GF,{}),w.jsx("div",{className:te("flex flex-col rounded-xl border-2 border-black bg-telnyx-cream","transition-all focus-within:ring-1 focus-within:ring-black focus-within:ring-offset-0.5 focus-within:bg-telnyx-dark-cream","relative z-10",s&&"opacity-50"),children:w.jsxs("div",{className:"flex",children:[w.jsxs("div",{className:"pl-4 pt-3 pb-2 flex-1 relative",children:[w.jsx("textarea",{id:"user-message-input",ref:g,value:e,onInput:t,disabled:s,"aria-disabled":s,className:te("w-full max-h-24 bg-transparent text-sm resize-none overflow-y-auto focus:outline-hidden focus:placeholder-black","scrollbar scrollbar-w-1 scrollbar-thumb-rounded-full scrollbar-track-transparent scrollbar-thumb-telnyx-gray-hover-light"),rows:1}),w.jsx("div",{className:"absolute inset-0 flex items-center pointer-events-none",children:w.jsx(nn,{mode:"wait",children:!e&&w.jsx(ge.p,{initial:{y:5,opacity:0},animate:{y:0,opacity:1},exit:{y:-15,opacity:0},transition:{duration:.3,ease:"linear"},className:"text-neutral-500 text-sm pl-4 text-left w-[calc(100%-32px)] truncate",children:n[l]},`current-placeholder-${l}`)})})]}),w.jsx("span",{className:"w-12 flex items-center justify-center mb-0",children:f&&w.jsx(HF,{question:e,handleSendMessage:r})})]})})]})});CR.displayName="FooterTextInput";const $F={[gr.HAS_NOT_BEEN_OPENED]:{y:0},[gr.HAS_BEEN_OPENED]:{y:[0,-3,0],scale:[1,1.01,1],filter:["blur(0px)","blur(5px)","blur(0px)"],opacity:[1,.8,1]}};function WF({text:e,className:t}){const n=J(r=>r.hasWidgetBeenOpened);return e.split("").map((r,a)=>w.jsx(ge.span,{initial:!1,animate:n,variants:$F,transition:{duration:.5,delay:a*.05},className:te("inline-block whitespace-pre font-sans tracking-tight",t),children:r},`${r}-${a}`))}const YF=()=>w.jsxs("div",{className:"flex justify-center text-xs pb-0.5 mt-2",children:[w.jsx(Ui,{className:"h-4 w-4 mr-1"}),w.jsx(WF,{className:"translate-y-0.5 font-pp-formula",text:"Powered by Telnyx"})]}),KF={[dt.INITIAL]:{y:0},[dt.USER_HAS_TYPED]:{y:0,transition:{duration:.2}}},_R=O.forwardRef(({question:e,handleInput:t,handleSendMessage:n},r)=>{const a=J(f=>f.chatVisualState),i=J(f=>f.onHelpAction),o=J(f=>f.botState),s=J(f=>f.getLastMessage()),l=(s==null?void 0:s.show_help_action)===!0,u=a===dt.USER_HAS_TYPED,c=J(f=>f.placeholders),d=o==="error"?["Error!","Please try again."]:c,p=l&&i!==null;return w.jsx("div",{className:te("mt-2 pt-1",u&&"mt-0 mb-2 pt-0"),children:w.jsxs(ge.div,{initial:"initial",animate:a,variants:KF,className:"space-y-1",children:[p&&w.jsx(XF,{onHelpAction:i}),w.jsx(CR,{ref:r,message:e,handleInput:t,handleSendMessage:n,placeholders:d}),!u&&w.jsx(YF,{})]})})});_R.displayName="Footer";const XF=({onHelpAction:e})=>w.jsx("div",{className:"flex items-center justify-center mb-0.5",children:w.jsxs(ge.button,{initial:{scale:.5,opacity:0,y:10},animate:{scale:.75,opacity:1,y:0,transition:{duration:.2}},exit:{scale:.5,y:10,transition:{duration:.2}},whileHover:{scale:.8,transition:{duration:.2}},whileTap:{scale:.7,transition:{duration:.2}},className:te("flex items-center gap-1 rounded-full p-2","bg-black text-white cursor-pointer"),onClick:e,children:[w.jsx("p",{className:"text-sm font-medium text-white",children:"Chat to support"}),w.jsx(eF,{className:"size-5 text-white"})]})}),ZF=({children:e,className:t,containerClassName:n})=>{const r=Zp(0),a=Zp(0),i={default:`url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32' width='16' height='16' fill='none'%3E%3Ccircle fill='%23404040' id='pattern-circle' cx='10' cy='10' r='2.5'%3E%3C/circle%3E%3C/svg%3E")`,hover:`url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32' width='16' height='16' fill='none'%3E%3Ccircle fill='%2300E3AA' id='pattern-circle' cx='10' cy='10' r='2.5'%3E%3C/circle%3E%3C/svg%3E")`};function o({currentTarget:s,clientX:l,clientY:u}){if(!s)return;const{left:c,top:d}=s.getBoundingClientRect();r.set(l-c),a.set(u-d)}return w.jsxs("div",{className:te("group relative h-full w-full items-center bg-black",n),onMouseMove:o,children:[w.jsx("div",{className:"pointer-events-none absolute inset-0",style:{backgroundImage:i.default}}),w.jsx(ge.div,{className:"pointer-events-none absolute inset-0 opacity-0 transition duration-300 group-hover:opacity-100",style:{backgroundImage:i.hover,WebkitMaskImage:Dh`
|
|
2542
2539
|
radial-gradient(
|
|
2543
2540
|
50px circle at ${r}px ${a}px,
|
|
2544
2541
|
black 0%,
|