@wavoip/wavoip-webphone 1.1.8 → 1.1.9

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.es.js CHANGED
@@ -20220,7 +20220,7 @@ function kd({ children: A }) {
20220
20220
  "div",
20221
20221
  {
20222
20222
  "data-closed": l,
20223
- className: "wv:data-[closed=true]:hidden wv:absolute wv:flex wv:flex-col wv:w-70 wv:h-120 wv:rounded-2xl wv:max-sm:fixed wv:max-sm:w-dvw wv:max-sm:h-dvh wv:max-sm:!left-[0px] wv:max-sm:!top-[0px] wv:bg-background wv:shadow-lg wv:touch-manipulation",
20223
+ className: "wv:data-[closed=true]:hidden wv:fixed wv:flex wv:flex-col wv:w-70 wv:h-120 wv:rounded-2xl wv:max-sm:fixed wv:max-sm:w-dvw wv:max-sm:h-dvh wv:max-sm:!left-[0px] wv:max-sm:!top-[0px] wv:bg-background wv:shadow-lg wv:touch-manipulation z-[2147483647]",
20224
20224
  style: {
20225
20225
  left: t.x,
20226
20226
  top: t.y
package/dist/index.umd.js CHANGED
@@ -140,7 +140,7 @@ Error generating stack: `+Y.message+`
140
140
  *
141
141
  * This source code is licensed under the MIT license found in the
142
142
  * LICENSE file in the root directory of this source tree.
143
- */var Hc;function aU(){if(Hc)return On;Hc=1;var A=Pt();function q(C,h){return C===h&&(C!==0||1/C===1/h)||C!==C&&h!==h}var V=typeof Object.is=="function"?Object.is:q,t=A.useState,o=A.useEffect,g=A.useLayoutEffect,a=A.useDebugValue;function l(C,h){var Q=h(),D=t({inst:{value:Q,getSnapshot:h}}),F=D[0].inst,G=D[1];return g(function(){F.value=Q,F.getSnapshot=h,w(F)&&G({inst:F})},[C,Q,h]),o(function(){return w(F)&&G({inst:F}),C(function(){w(F)&&G({inst:F})})},[C]),a(Q),Q}function w(C){var h=C.getSnapshot;C=C.value;try{var Q=h();return!V(C,Q)}catch{return!0}}function B(C,h){return h()}var c=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?B:l;return On.useSyncExternalStore=A.useSyncExternalStore!==void 0?A.useSyncExternalStore:c,On}var zc;function rU(){return zc||(zc=1,jn.exports=aU()),jn.exports}var nU=rU();function lU(){return nU.useSyncExternalStore(wU,()=>!0,()=>!1)}function wU(){return()=>{}}var Hn="Avatar",[MU,LS]=fV(Hn),[BU,vc]=MU(Hn),Pc=n.forwardRef((A,q)=>{const{__scopeAvatar:V,...t}=A,[o,g]=n.useState("idle");return E.jsx(BU,{scope:V,imageLoadingStatus:o,onImageLoadingStatusChange:g,children:E.jsx(xA.span,{...t,ref:q})})});Pc.displayName=Hn;var bc="AvatarImage",Xc=n.forwardRef((A,q)=>{const{__scopeAvatar:V,src:t,onLoadingStatusChange:o=()=>{},...g}=A,a=vc(bc,V),l=YU(t,g),w=oe(B=>{o(B),a.onImageLoadingStatusChange(B)});return Yq(()=>{l!=="idle"&&w(l)},[l,w]),l==="loaded"?E.jsx(xA.img,{...g,ref:q,src:t}):null});Xc.displayName=bc;var _c="AvatarFallback",$c=n.forwardRef((A,q)=>{const{__scopeAvatar:V,delayMs:t,...o}=A,g=vc(_c,V),[a,l]=n.useState(t===void 0);return n.useEffect(()=>{if(t!==void 0){const w=window.setTimeout(()=>l(!0),t);return()=>window.clearTimeout(w)}},[t]),a&&g.imageLoadingStatus!=="loaded"?E.jsx(xA.span,{...o,ref:q}):null});$c.displayName=_c;function AE(A,q){return A?q?(A.src!==q&&(A.src=q),A.complete&&A.naturalWidth>0?"loaded":"loading"):"error":"idle"}function YU(A,{referrerPolicy:q,crossOrigin:V}){const t=lU(),o=n.useRef(null),g=t?(o.current||(o.current=new window.Image),o.current):null,[a,l]=n.useState(()=>AE(g,A));return Yq(()=>{l(AE(g,A))},[g,A]),Yq(()=>{const w=C=>()=>{l(C)};if(!g)return;const B=w("loaded"),c=w("error");return g.addEventListener("load",B),g.addEventListener("error",c),q&&(g.referrerPolicy=q),typeof V=="string"&&(g.crossOrigin=V),()=>{g.removeEventListener("load",B),g.removeEventListener("error",c)}},[g,V,q]),a}var CU=Pc,cU=Xc,EU=$c;function zn({className:A,...q}){return E.jsx(CU,{"data-slot":"avatar",className:OA("wv:relative wv:flex wv:size-8 wv:shrink-0 wv:overflow-hidden wv:rounded-full",A),...q})}function vn({className:A,...q}){return E.jsx(cU,{"data-slot":"avatar-image",className:OA("wv:aspect-square wv:size-full",A),...q})}function Pn({className:A,...q}){return E.jsx(EU,{"data-slot":"avatar-fallback",className:OA("wv:bg-muted wv:flex wv:size-full wv:items-center wv:justify-center wv:rounded-full",A),...q})}const hU=An("wv:inline-flex wv:items-center wv:justify-center wv:gap-2 wv:whitespace-nowrap wv:rounded-md wv:text-sm wv:font-medium wv:transition-all wv:disabled:pointer-events-none wv:disabled:opacity-50 wv:[&_svg]:pointer-events-none wv:[&_svg:not([class*=size-])]:size-4 wv:shrink-0 wv:[&_svg]:shrink-0 wv:outline-none wv:focus-visible:border-ring wv:focus-visible:ring-ring/50 wv:focus-visible:ring-[3px] wv:aria-invalid:ring-destructive/20 wv:dark:aria-invalid:ring-destructive/40 wv:aria-invalid:border-destructive",{variants:{variant:{default:"wv:bg-primary wv:text-primary-foreground wv:shadow-xs wv:hover:bg-primary/90",destructive:"wv:bg-destructive wv:text-white wv:shadow-xs wv:hover:bg-destructive/90 wv:focus-visible:ring-destructive/20 wv:dark:focus-visible:ring-destructive/40 wv:dark:bg-destructive/60",outline:"wv:border wv:bg-background wv:shadow-xs wv:hover:bg-accent wv:hover:text-accent-foreground wv:dark:bg-input/30 wv:dark:border-input wv:dark:hover:bg-input/50",secondary:"wv:bg-secondary wv:text-secondary-foreground wv:shadow-xs wv:hover:bg-secondary/80",ghost:"wv:hover:bg-accent wv:hover:text-accent-foreground wv:dark:hover:bg-accent/50",link:"wv:text-primary wv:underline-offset-4 wv:hover:underline"},size:{default:"wv:h-9 wv:px-4 wv:py-2 wv:has-[>svg]:px-3",sm:"wv:h-8 wv:rounded-md wv:gap-1.5 wv:px-3 wv:has-[>svg]:px-2.5",lg:"wv:h-10 wv:rounded-md wv:px-6 wv:has-[>svg]:px-4",icon:"wv:size-9"}},defaultVariants:{variant:"default",size:"default"}});function Vq({className:A,variant:q,size:V,asChild:t=!1,...o}){const g=t?AC:"button";return E.jsx(g,{"data-slot":"button",className:OA(hU({variant:q,size:V,className:A})),...o})}function mU({offer:A}){const[q,V]=n.useState(!1),[t,o]=n.useState(null),[g,a]=n.useState(null);return n.useEffect(()=>{A.onEnd(()=>{a("Chamada encerrada")}),A.onAcceptedElsewhere(()=>{a("Aceita por outro usuário")}),A.onRejectedElsewhere(()=>{a("Rejeitada pelo aplicativo")}),A.onUnanswered(()=>{a("Tempo limite")})},[A]),E.jsxs("div",{className:"wv:flex wv:flex-col wv:gap-3 wv:w-[365px] wv:bg-background",children:[E.jsx("div",{className:"wv:flex wv:flex-row wv:gap-1",children:E.jsxs("div",{className:"wv:flex wv:flex-row wv:justify-between wv:gap-2 ",children:[E.jsxs("div",{className:"wv:flex wv:flex-row wv:justify-center wv:items-center wv:gap-2 wv:opacity-75 wv:text-foreground",children:[E.jsx(gI,{size:20,color:"currentColor"}),E.jsx("p",{className:"wv:text-foreground wv:text-[14px] wv:select-none",children:"Whatsapp Audio"})]}),E.jsxs("div",{className:"wv:flex wv:items-center wv:space-x-1",children:[E.jsx("span",{className:"dot wv:w-1.5 wv:h-1.5 wv:rounded-full wv:bg-foreground animate-bounce1"}),E.jsx("span",{className:"dot wv:w-1.5 wv:h-1.5 wv:rounded-full wv:bg-foreground animate-bounce2"}),E.jsx("span",{className:"dot wv:w-1.5 wv:h-1.5 wv:rounded-full wv:bg-foreground animate-bounce3"})]})]})}),E.jsxs("div",{className:"wv:flex wv:gap-3",children:[E.jsxs(zn,{className:"wv:size-[50px] wv:rounded-xl",children:[E.jsx(vn,{src:A.peer?.profilePicture??""}),E.jsx(Pn,{children:gn(A.peer?.displayName)})]}),E.jsxs("div",{className:"wv:flex-grow wv:relative wv:group/title wv:flex wv:flex-col wv:overflow-hidden wv:font-normal",children:[t??g?E.jsxs(E.Fragment,{children:[t&&E.jsx("p",{className:"wv:text-xm wv:text-ellipsis wv:text-red-600",children:t}),g&&E.jsx("p",{className:"wv:text-foreground wv:opacity-40 wv:text-[14px] wv:select-none",children:g})]}):E.jsx("p",{className:"wv:text-foreground wv:opacity-40 wv:text-[14px] wv:select-none",children:A.peer?.phone}),E.jsx("div",{className:"wv:hidden wv:group-hover/title:block",children:E.jsx(hg,{speed:10,className:"wv:text-[24px] wv:leading-[28px] wv:font-normal wv:select-none",children:A.peer?.displayName||A.peer?.phone})}),E.jsx("p",{className:"wv:block wv:group-hover/title:hidden wv:text-[24px] wv:leading-[28px] wv:font-normal wv:truncate w-48",children:A.peer?.displayName||A.peer?.phone})]}),E.jsxs("div",{className:"wv:flex wv:flex-row wv:gap-2",children:[E.jsx(Vq,{type:"submit",size:"icon",className:"wv:text-[white] wv:p-4 wv:bg-red-500 wv:hover:bg-red-700 wv:active:bg-red-700 wv:hover:cursor-pointer wv:w-full wv:rounded-full wv:h-[40px] wv:w-[40px]",disabled:q,onClick:()=>{V(!0),A.reject().then(({err:l})=>{if(l){o(l),V(!1);return}cg.dismiss(A.id)})},children:E.jsx(iI,{className:"wv:size-5",weight:"fill"})}),E.jsx(Vq,{type:"submit",size:"icon",className:"wv:text-[white] wv:p-4 wv:bg-green-500 wv:hover:bg-green-700 wv:active:bg-green-700 wv:hover:cursor-pointer wv:w-full wv:rounded-full wv:h-[40px] wv:w-[40px]",disabled:q,onClick:()=>{V(!0),A.accept().then(({err:l})=>{if(l){o(l),V(!1);return}cg.dismiss(A.id)})},children:E.jsx(As,{className:"wv:size-5",weight:"fill"})})]})]})]})}const gV={video:document.createElement("video"),canvas:document.createElement("canvas"),call:null,animationID:null};function FU(){document.removeEventListener("visibilitychange",DU),gV.animationID&&(cancelAnimationFrame(gV.animationID),gV.animationID=null)}async function DU(){if(document.pictureInPictureEnabled){if(document.hidden&&!document.pictureInPictureElement){const{canvas:A,video:q}=gV;A.width=200,A.height=200,qE(A),q.height=200,q.width=200,q.srcObject=A.captureStream(),q.muted=!0,q.play(),q.addEventListener("loadedmetadata",()=>q.requestPictureInPicture(),{once:!0});return}document.pictureInPictureElement&&(await document.exitPictureInPicture(),gV.animationID&&(cancelAnimationFrame(gV.animationID),gV.animationID=null))}}async function qE(A){gV.animationID=requestAnimationFrame(()=>qE(A));const{call:q}=gV;if(!q)return;const V=10,t=A.getContext("2d");t.fillStyle="black",t.fillRect(0,0,A.width,A.height);const o={x:V,y:V,width:0,height:0};if(q.peer?.profilePicture){o.height=A.height/2-2*V,o.width=o.height;const{x:g,y:a,height:l,width:w}=o,B=new Image;B.crossOrigin="anonymous",B.src=q.peer?.profilePicture,B.onload=()=>{t.drawImage(B,g,a,w,l)}}}let Yo=[];function GU(A,q,V={}){const t=A.getContext("2d");if(!t)return;const o=window.devicePixelRatio||1;A.width=A.clientWidth*o,A.height=A.clientHeight*o,t.scale(o,o),t.imageSmoothingEnabled=!1,t.translate(.5,.5);const{x:g=0,y:a=0,width:l=A.clientWidth,height:w=A.clientHeight,bars:B=15,gap:c=2,color:C="#00ff66"}=V;t.clearRect(0,0,l,w),t.fillStyle=C;const h=Math.floor(q.length/B),Q=(l-c*(B-1))/B;Yo.length!==B&&(Yo=Array(B).fill(0));const D=Math.floor(B/2);for(let F=0;F<B;F++){const G=F-D,I=Math.abs(G);let p=0;for(let rA=0;rA<h;rA++)p+=q[I*h+rA];const T=p/h,W=Math.pow(T/255,.6),S=Math.max(W*w,3);Yo[F]=Yo[F]*.75+S*.25;const O=Yo[F],k=g+D*(Q+c)+G*(Q+c),N=a+(w-O)/2;QU(t,k,N,Q,O,3)}}function QU(A,q,V,t,o,g){A.beginPath(),A.moveTo(q+g,V),A.lineTo(q+t-g,V),A.quadraticCurveTo(q+t,V,q+t,V+g),A.lineTo(q+t,V+o-g),A.quadraticCurveTo(q+t,V+o,q+t-g,V+o),A.lineTo(q+g,V+o),A.quadraticCurveTo(q,V+o,q,V+o-g),A.lineTo(q,V+g),A.quadraticCurveTo(q,V,q+g,V),A.closePath(),A.fill()}const VE=n.createContext(void 0);function IU({children:A}){const[q,V]=n.useState("keyboard");return E.jsx(VE.Provider,{value:{screen:q,setScreen:V},children:A})}function eE(){const A=n.useContext(VE);if(!A)throw new Error("useScreen deve ser usado dentro de <ScreenProvider>");return A}var uU=(A,q,V,t,o,g,a,l)=>{let w=document.documentElement,B=["light","dark"];function c(Q){(Array.isArray(A)?A:[A]).forEach(D=>{let F=D==="class",G=F&&g?o.map(I=>g[I]||I):o;F?(w.classList.remove(...G),w.classList.add(g&&g[Q]?g[Q]:Q)):w.setAttribute(D,Q)}),C(Q)}function C(Q){l&&B.includes(Q)&&(w.style.colorScheme=Q)}function h(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}if(t)c(t);else try{let Q=localStorage.getItem(q)||V,D=a&&Q==="system"?h():Q;c(D)}catch{}},pU=n.createContext(void 0),KU={setTheme:A=>{},themes:[]},tE=()=>{var A;return(A=n.useContext(pU))!=null?A:KU};n.memo(({forcedTheme:A,storageKey:q,attribute:V,enableSystem:t,enableColorScheme:o,defaultTheme:g,value:a,themes:l,nonce:w,scriptProps:B})=>{let c=JSON.stringify([V,q,g,A,l,a,t,o]).slice(1,-1);return n.createElement("script",{...B,suppressHydrationWarning:!0,nonce:typeof window>"u"?w:"",dangerouslySetInnerHTML:{__html:`(${uU.toString()})(${c})`}})});const TU=({...A})=>{const{theme:q="system"}=tE();return E.jsx(oU,{theme:q,className:"wv:toaster wv:group",style:{"--normal-bg":"var(--popover)","--normal-text":"var(--popover-foreground)","--normal-border":"var(--border)"},...A})},Qt={};window.wavoip=Qt;function Co(A){A.call&&(Qt.call=A.call),A.notifications&&(Qt.notifications=A.notifications),A.widget&&(Qt.widget=A.widget),A.theme&&(Qt.theme=A.theme),A.settings&&(Qt.settings=A.settings),A.device&&(Qt.device=A.device)}const sE=n.createContext(void 0);function UU({children:A}){const[q,V]=n.useState(!0),[t,o]=n.useState(!0),[g,a]=n.useState(!1),[l,w]=n.useState(!0),[B,c]=n.useState(!0),[C,h]=n.useState(!0),[Q,D]=n.useState(!0),[F,G]=n.useState(!0),[I,p]=n.useState(!0);return Co({settings:{showNotifications:q,showSettings:t,showDevices:l,showAddDevices:B,showEnableDevices:C,showRemoveDevices:Q,showKeyboardScreen:F,showWidgetButton:I,setShowNotifications:V,setShowSettings:o,setShowDevices:w,setShowAddDevices:c,setShowEnableDevices:h,setShowRemoveDevices:D,setShowKeyboardScreen:G,setShowWidgetButton:p}}),E.jsx(sE.Provider,{value:{showNotifications:q,showSettings:t,showAudio:g,showDevices:l,showAddDevices:B,showEnableDevices:C,showRemoveDevices:Q,showKeyboardScreen:F,showWidgetButton:I,setShowWidgetButton:p,setShowNotifications:V,setShowSettings:o,setShowAudio:a,setShowDevices:w,setShowAddDevices:c,setShowEnableDevices:h,setShowRemoveDevices:D,setShowKeyboardScreen:G},children:A})}const bn=()=>{const A=n.useContext(sE);if(A===void 0)throw new Error("useSettings deve ser usado dentro de SettingsProvider");return A},xU={theme:"system",setTheme:()=>null},oE=n.createContext(xU);function dU({children:A,defaultTheme:q="system",storageKey:V="vite-ui-theme",...t}){const[o,g]=n.useState(()=>localStorage.getItem(V)||q);n.useEffect(()=>{const l=window.document.documentElement;if(l.classList.remove("light","dark"),o==="system"){const w=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";l.classList.add(w);return}l.classList.add(o)},[o]);const a=l=>{localStorage.setItem(V,l),g(l)};return Co({theme:{setTheme:a}}),E.jsx(oE.Provider,{...t,value:{theme:o,setTheme:a},children:A})}const LU=()=>{const A=n.useContext(oE);if(A===void 0)throw new Error("useTheme must be used within a ThemeProvider");return A},iE=n.createContext(void 0);function WU({children:A}){const{theme:q}=LU(),{showWidgetButton:V}=bn(),[t,o]=n.useState({x:document.body.clientWidth/3,y:document.body.clientHeight/3}),[g,a]=n.useState(!1),[l,w]=n.useState(!0),B=n.useRef({x:0,y:0}),c=n.useCallback(G=>{let I=G.clientX-B.current.x,p=G.clientY-B.current.y;I<0&&(I=0),p<0&&(p=0),I>document.body.clientWidth-280&&(I=document.body.clientWidth-280),p>document.body.clientHeight-480&&(p=document.body.clientHeight-480),o({x:I,y:p})},[]),C=n.useCallback(G=>{document.body.style.userSelect="none",a(!0),B.current={x:G.clientX-t.x,y:G.clientY-t.y},document.addEventListener("mousemove",c)},[c,t.x,t.y]),h=n.useCallback(()=>{a(!1),document.body.style.userSelect="unset",document.removeEventListener("mousemove",c)},[c]),Q=n.useCallback(()=>{l&&w(!1)},[l]),D=n.useCallback(()=>{l||w(!0)},[l]),F=n.useCallback(()=>{w(G=>!G)},[]);return n.useEffect(()=>{function G(){o({x:document.body.clientWidth/3,y:document.body.clientHeight/3})}return document.addEventListener("mouseleave",()=>{h()}),window.addEventListener("resize",G),()=>{window.removeEventListener("resize",G)}},[h]),Co({widget:{open:Q,close:D,toggle:F}}),E.jsxs(iE.Provider,{value:{position:t,setPosition:o,startDrag:C,stopDrag:h,isDragging:g,closed:l,setClosed:w,close:()=>{l||w(!0)},open:()=>{l&&w(!1)},toggle:()=>{w(G=>!G)}},children:[V&&E.jsx(Vq,{type:"button",onClick:()=>w(!1),size:"icon","data-closed":l,className:"wv:data-[closed=false]:hidden wv: wv:absolute sm:wv:fixed wv:bottom-0 wv:right-0 wv:p-3 wv:rounded-full wv:aspect-square wv:size-fit wv:bg-green-500 wv:text-white wv:font-bold wv:hover:bg-green-600",style:{position:"fixed",bottom:"20px",right:"20px",zIndex:9999},children:E.jsx(As,{className:"wv:size-8"})}),E.jsx(TU,{theme:q,position:"top-right",className:"!w-[400px]",toastOptions:{className:"wv:max-w-[400px] wv:w-full"}}),E.jsx("div",{"data-closed":l,className:"wv:data-[closed=true]:hidden wv:absolute wv:flex wv:flex-col wv:w-70 wv:h-120 wv:rounded-2xl wv:max-sm:fixed wv:max-sm:w-dvw wv:max-sm:h-dvh wv:max-sm:!left-[0px] wv:max-sm:!top-[0px] wv:bg-background wv:shadow-lg wv:touch-manipulation",style:{left:t.x,top:t.y},children:A})]})}function Xn(){const A=n.useContext(iE);if(!A)throw new Error("useWidget deve ser usado dentro de <WidgetProvider>");return A}const co=new Audio(iU),Eo=new Audio(gU);let ho=null;function yU({wavoip:A,devices:q}){const{setScreen:V}=eE(),{closed:t,setClosed:o,open:g}=Xn(),[a,l]=n.useState([]),[w,B]=n.useState(void 0),[c,C]=n.useState(void 0),h=n.useCallback(()=>{ZU(),FU(),setTimeout(()=>{ho&&(o(ho),ho=null),V("keyboard"),B(void 0),C(void 0),gV.call=null},3e3)},[V,o]),Q=n.useCallback(G=>{G.onEnd(()=>h());const I={...G,peer:G.peer,onEnd:p=>{G.onEnd(()=>{h(),p()})}};return V("call"),C(I),gV.call=G,I},[h,V]),D=n.useCallback(G=>{if(c)return;function I(){l(T=>T.filter(({id:W})=>W!==G.id)),_n(a),setTimeout(()=>{cg.dismiss(G.id)},2e3)}const p={...G,onEnd(T){G.onEnd(()=>{I(),T()})},onAcceptedElsewhere(T){G.onAcceptedElsewhere(()=>{I(),T()})},onRejectedElsewhere(T){G.onRejectedElsewhere(()=>{I(),T()})},onUnanswered(T){G.onUnanswered(()=>{I(),T()})},async accept(){const{call:T,err:W}=await G.accept();return T?(l([]),_n(a),g(),ho=t,{call:Q(T),err:W}):{call:T,err:W}},async reject(){const{err:T}=await G.reject();return T||_n(a),{err:T}}};l(T=>[...T,p]),SU(),cg(E.jsx(mU,{offer:p}),{id:G.id,duration:1e5,className:"wv:max-w-[400px] wv:!w-full"})},[t,c,Q,g,a]),F=n.useCallback(async(G,I)=>{const{call:p,err:T}=await A.startCall({fromTokens:I??q.filter(S=>S.enable).map(S=>S.token),to:G});if(T)return{err:T};p.onPeerAccept(S=>{Q(S),B(void 0)}),p.onUnanswered(()=>h()),p.onEnd(()=>h());const W={...p,peer:p.peer,onPeerAccept:S=>{p.onPeerAccept(O=>{const k=Q(O);B(void 0),S(k)})},onEnd:S=>{p.onEnd(()=>{S(),h()})},onUnanswered:S=>{p.onUnanswered(()=>{S(),h()})}};return ho=t,g(),B(W),V("outgoing"),RU(),gV.call=W,{err:null}},[q,Q,h,V,A.startCall,g,t]);return A.onOffer(G=>D(G)),{offers:a,outgoing:w,active:c,start:F}}function gE(A){return A.preventDefault(),A.returnValue="",""}function RU(){window.addEventListener("beforeunload",gE)}function ZU(){window.removeEventListener("beforeunload",gE)}function SU(){co.currentTime=0,co.loop=!0,co.volume=.25,co.play(),Eo.loop=!0,Eo.currentTime=0,Eo.volume=.25,Eo.play()}function _n(A){A.length||(co.pause(),Eo.pause())}const aE="wavoip:tokens";function rE(){const V=(localStorage.getItem(aE)?.split(";")||[]).map(t=>{const[o,g]=t.split(":");return{token:o,enable:g==="true"}});return new Map(V.map(t=>[t.token,t]))}function kU(A){const q=A.map(V=>`${V.token}:${V.enable}`).join(";");localStorage.setItem(aE,q)}const NU=rE();function fU({wavoip:A}){const[q,V]=n.useState(()=>A.getDevices().map(l=>({...l,enable:!!NU.get(l.token)?.enable&&["open","CONNECTED"].includes(l.status)}))),t=n.useCallback(l=>{const[w]=A.addDevices([l]);w&&V(B=>[...B,{...w,enable:["open","CONNECTOED"].includes(w.status)}])},[A.addDevices]),o=n.useCallback(l=>{A.removeDevices([l]),V(w=>w.filter(B=>B.token!==l))},[A.removeDevices]),g=n.useCallback(l=>{V(w=>w.map(B=>B.token===l?{...B,enable:!0}:B))},[]),a=n.useCallback(l=>{V(w=>w.map(B=>B.token===l?{...B,enable:!1}:B))},[]);return n.useEffect(()=>{for(const l of q)l.onQRCode(w=>{V(B=>B.map(c=>c.token===l.token?{...l,qrcode:w}:c))}),l.onStatus(w=>{V(B=>B.map(c=>c.token===l.token?{...l,status:w,enable:["open","CONNECTED"].includes(w)}:c))});kU(q)},[q]),{devices:q,add:t,remove:o,enable:g,disable:a}}const nE=n.createContext(void 0),JU=({children:A,wavoip:q})=>{const{devices:V,add:t,remove:o,disable:g,enable:a}=fU({wavoip:q}),{offers:l,outgoing:w,active:B,start:c}=yU({wavoip:q,devices:V});return n.useEffect(()=>()=>{delete window.wavoip},[]),Co({call:{startCall:c,getCallActive:()=>{if(!B)return;const{id:C,type:h,status:Q,device_token:D,direction:F,peer:G,muted:I}=B;return{id:C,type:h,status:Q,device_token:D,direction:F,peer:G,muted:I}},getCallOutgoing:()=>{if(!w)return;const{id:C,type:h,status:Q,device_token:D,direction:F,peer:G,muted:I}=w;return{id:C,type:h,status:Q,device_token:D,direction:F,peer:G,muted:I}},getOffers:()=>l.map(({id:C,type:h,status:Q,device_token:D,direction:F,peer:G,muted:I})=>({id:C,type:h,status:Q,device_token:D,direction:F,peer:G,muted:I}))},device:{getDevices:q.getDevices,addDevice:t,removeDevice:o,enableDevice:a,disableDevice:g}}),E.jsx(nE.Provider,{value:{wavoip:q,devices:V,offers:l,callOutgoing:w,callActive:B,startCall:c,addDevice:t,removeDevice:o,enableDevice:a,disableDevice:g},children:A})},Ze=()=>{const A=n.useContext(nE);if(!A)throw new Error("useWavoip deve ser usado dentro de WavoipProvider");return A};function jU(){const{wavoip:A}=Ze(),[q,V]=n.useState([]),[t,o]=n.useState([]);return n.useEffect(()=>{if(A){const g=A.getMultimediaDevices();V(g.microphones),o(g.speakers)}},[]),E.jsx("div",{className:" wv:py-3",children:E.jsx(Eu,{children:E.jsxs(hu,{className:"wv:flex wv:flex-col wv:gap-4",children:[E.jsxs(eC,{className:"wv:flex wv:flex-col wv:gap-1 wv:text-foreground",children:[E.jsx(tC,{children:"Microfone"}),E.jsxs(Sc,{children:[E.jsx(Nc,{className:"wv:max-w-[300px]",children:E.jsx(kc,{placeholder:"Choose department"})}),E.jsx(fc,{className:"wv:z-[2147483647]",children:q.map((g,a)=>E.jsx(Jc,{value:g.deviceId,children:g.label},`microphone_${a}`))})]}),E.jsx(sC,{children:"Selecione o microfone que deseja usar na ligação"})]}),E.jsxs(eC,{className:"wv:flex wv:flex-col wv:gap-1 wv:text-foreground",children:[E.jsx(tC,{children:"Alto falante"}),E.jsxs(Sc,{children:[E.jsx(Nc,{className:"wv:max-w-[300px]",children:E.jsx(kc,{placeholder:"Choose department"})}),E.jsx(fc,{className:"wv:z-[2147483647]",children:t.map((g,a)=>E.jsx(Jc,{value:g.deviceId,children:g.label},`speaker_${a}`))})]}),E.jsx(sC,{children:"Selecione o alto falante que deseja usar na ligação"})]})]})})})}var mg="Switch",[OU,WS]=fV(mg),[HU,zU]=OU(mg),lE=n.forwardRef((A,q)=>{const{__scopeSwitch:V,name:t,checked:o,defaultChecked:g,required:a,disabled:l,value:w="on",onCheckedChange:B,form:c,...C}=A,[h,Q]=n.useState(null),D=zA(q,T=>Q(T)),F=n.useRef(!1),G=h?c||!!h.closest("form"):!0,[I,p]=We({prop:o,defaultProp:g??!1,onChange:B,caller:mg});return E.jsxs(HU,{scope:V,checked:I,disabled:l,children:[E.jsx(xA.button,{type:"button",role:"switch","aria-checked":I,"aria-required":a,"data-state":YE(I),"data-disabled":l?"":void 0,disabled:l,value:w,...C,ref:D,onClick:pA(A.onClick,T=>{p(W=>!W),G&&(F.current=T.isPropagationStopped(),F.current||T.stopPropagation())})}),G&&E.jsx(BE,{control:h,bubbles:!F.current,name:t,value:w,checked:I,required:a,disabled:l,form:c,style:{transform:"translateX(-100%)"}})]})});lE.displayName=mg;var wE="SwitchThumb",ME=n.forwardRef((A,q)=>{const{__scopeSwitch:V,...t}=A,o=zU(wE,V);return E.jsx(xA.span,{"data-state":YE(o.checked),"data-disabled":o.disabled?"":void 0,...t,ref:q})});ME.displayName=wE;var vU="SwitchBubbleInput",BE=n.forwardRef(({__scopeSwitch:A,control:q,checked:V,bubbles:t=!0,...o},g)=>{const a=n.useRef(null),l=zA(a,g),w=XC(V),B=NC(q);return n.useEffect(()=>{const c=a.current;if(!c)return;const C=window.HTMLInputElement.prototype,Q=Object.getOwnPropertyDescriptor(C,"checked").set;if(w!==V&&Q){const D=new Event("click",{bubbles:t});Q.call(c,V),c.dispatchEvent(D)}},[w,V,t]),E.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:V,...o,tabIndex:-1,ref:l,style:{...o.style,...B,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});BE.displayName=vU;function YE(A){return A?"checked":"unchecked"}var PU=lE,bU=ME;function XU({className:A,...q}){return E.jsx(PU,{"data-slot":"switch",className:OA("wv:peer wv:data-[state=checked]:bg-primary wv:data-[state=unchecked]:bg-input wv:focus-visible:border-ring wv:focus-visible:ring-ring/50 wv:dark:data-[state=unchecked]:bg-input/80 wv:inline-flex wv:h-[1.15rem] wv:w-8 wv:shrink-0 wv:items-center wv:rounded-full wv:border wv:border-transparent wv:shadow-xs wv:transition-all wv:outline-none wv:focus-visible:ring-[3px] wv:disabled:cursor-not-allowed wv:disabled:opacity-50",A),...q,children:E.jsx(bU,{"data-slot":"switch-thumb",className:OA("wv:bg-background wv:dark:data-[state=unchecked]:bg-foreground wv:dark:data-[state=checked]:bg-primary-foreground wv:pointer-events-none wv:block wv:size-4 wv:rounded-full wv:ring-0 wv:transition-transform wv:data-[state=checked]:translate-x-[calc(100%-2px)] wv:data-[state=unchecked]:translate-x-0 wv:translate-y-0")})})}function _U(A,q){return n.useReducer((V,t)=>q[V][t]??V,A)}var ae=A=>{const{present:q,children:V}=A,t=$U(q),o=typeof V=="function"?V({present:t.isPresent}):n.Children.only(V),g=zA(t.ref,Ax(o));return typeof V=="function"||t.isPresent?n.cloneElement(o,{ref:g}):null};ae.displayName="Presence";function $U(A){const[q,V]=n.useState(),t=n.useRef(null),o=n.useRef(A),g=n.useRef("none"),a=A?"mounted":"unmounted",[l,w]=_U(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return n.useEffect(()=>{const B=Fg(t.current);g.current=l==="mounted"?B:"none"},[l]),Yq(()=>{const B=t.current,c=o.current;if(c!==A){const h=g.current,Q=Fg(B);A?w("MOUNT"):Q==="none"||B?.display==="none"?w("UNMOUNT"):w(c&&h!==Q?"ANIMATION_OUT":"UNMOUNT"),o.current=A}},[A,w]),Yq(()=>{if(q){let B;const c=q.ownerDocument.defaultView??window,C=Q=>{const F=Fg(t.current).includes(CSS.escape(Q.animationName));if(Q.target===q&&F&&(w("ANIMATION_END"),!o.current)){const G=q.style.animationFillMode;q.style.animationFillMode="forwards",B=c.setTimeout(()=>{q.style.animationFillMode==="forwards"&&(q.style.animationFillMode=G)})}},h=Q=>{Q.target===q&&(g.current=Fg(t.current))};return q.addEventListener("animationstart",h),q.addEventListener("animationcancel",C),q.addEventListener("animationend",C),()=>{c.clearTimeout(B),q.removeEventListener("animationstart",h),q.removeEventListener("animationcancel",C),q.removeEventListener("animationend",C)}}else w("ANIMATION_END")},[q,w]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:n.useCallback(B=>{t.current=B?getComputedStyle(B):null,V(B)},[])}}function Fg(A){return A?.animationName||"none"}function Ax(A){let q=Object.getOwnPropertyDescriptor(A.props,"ref")?.get,V=q&&"isReactWarning"in q&&q.isReactWarning;return V?A.ref:(q=Object.getOwnPropertyDescriptor(A,"ref")?.get,V=q&&"isReactWarning"in q&&q.isReactWarning,V?A.props.ref:A.props.ref||A.ref)}var[Dg,yS]=fV("Tooltip",[rs]),Gg=rs(),CE="TooltipProvider",qx=700,$n="tooltip.open",[Vx,Al]=Dg(CE),cE=A=>{const{__scopeTooltip:q,delayDuration:V=qx,skipDelayDuration:t=300,disableHoverableContent:o=!1,children:g}=A,a=n.useRef(!0),l=n.useRef(!1),w=n.useRef(0);return n.useEffect(()=>{const B=w.current;return()=>window.clearTimeout(B)},[]),E.jsx(Vx,{scope:q,isOpenDelayedRef:a,delayDuration:V,onOpen:n.useCallback(()=>{window.clearTimeout(w.current),a.current=!1},[]),onClose:n.useCallback(()=>{window.clearTimeout(w.current),w.current=window.setTimeout(()=>a.current=!0,t)},[t]),isPointerInTransitRef:l,onPointerInTransitChange:n.useCallback(B=>{l.current=B},[]),disableHoverableContent:o,children:g})};cE.displayName=CE;var mo="Tooltip",[ex,Fo]=Dg(mo),EE=A=>{const{__scopeTooltip:q,children:V,open:t,defaultOpen:o,onOpenChange:g,disableHoverableContent:a,delayDuration:l}=A,w=Al(mo,A.__scopeTooltip),B=Gg(q),[c,C]=n.useState(null),h=JV(),Q=n.useRef(0),D=a??w.disableHoverableContent,F=l??w.delayDuration,G=n.useRef(!1),[I,p]=We({prop:t,defaultProp:o??!1,onChange:k=>{k?(w.onOpen(),document.dispatchEvent(new CustomEvent($n))):w.onClose(),g?.(k)},caller:mo}),T=n.useMemo(()=>I?G.current?"delayed-open":"instant-open":"closed",[I]),W=n.useCallback(()=>{window.clearTimeout(Q.current),Q.current=0,G.current=!1,p(!0)},[p]),S=n.useCallback(()=>{window.clearTimeout(Q.current),Q.current=0,p(!1)},[p]),O=n.useCallback(()=>{window.clearTimeout(Q.current),Q.current=window.setTimeout(()=>{G.current=!0,p(!0),Q.current=0},F)},[F,p]);return n.useEffect(()=>()=>{Q.current&&(window.clearTimeout(Q.current),Q.current=0)},[]),E.jsx(pn,{...B,children:E.jsx(ex,{scope:q,contentId:h,open:I,stateAttribute:T,trigger:c,onTriggerChange:C,onTriggerEnter:n.useCallback(()=>{w.isOpenDelayedRef.current?O():W()},[w.isOpenDelayedRef,O,W]),onTriggerLeave:n.useCallback(()=>{D?S():(window.clearTimeout(Q.current),Q.current=0)},[S,D]),onOpen:W,onClose:S,disableHoverableContent:D,children:V})})};EE.displayName=mo;var ql="TooltipTrigger",hE=n.forwardRef((A,q)=>{const{__scopeTooltip:V,...t}=A,o=Fo(ql,V),g=Al(ql,V),a=Gg(V),l=n.useRef(null),w=zA(q,l,o.onTriggerChange),B=n.useRef(!1),c=n.useRef(!1),C=n.useCallback(()=>B.current=!1,[]);return n.useEffect(()=>()=>document.removeEventListener("pointerup",C),[C]),E.jsx(sg,{asChild:!0,...a,children:E.jsx(xA.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...t,ref:w,onPointerMove:pA(A.onPointerMove,h=>{h.pointerType!=="touch"&&!c.current&&!g.isPointerInTransitRef.current&&(o.onTriggerEnter(),c.current=!0)}),onPointerLeave:pA(A.onPointerLeave,()=>{o.onTriggerLeave(),c.current=!1}),onPointerDown:pA(A.onPointerDown,()=>{o.open&&o.onClose(),B.current=!0,document.addEventListener("pointerup",C,{once:!0})}),onFocus:pA(A.onFocus,()=>{B.current||o.onOpen()}),onBlur:pA(A.onBlur,o.onClose),onClick:pA(A.onClick,o.onClose)})})});hE.displayName=ql;var Vl="TooltipPortal",[tx,sx]=Dg(Vl,{forceMount:void 0}),mE=A=>{const{__scopeTooltip:q,forceMount:V,children:t,container:o}=A,g=Fo(Vl,q);return E.jsx(tx,{scope:q,forceMount:V,children:E.jsx(ae,{present:V||g.open,children:E.jsx(Mo,{asChild:!0,container:o,children:t})})})};mE.displayName=Vl;var Ys="TooltipContent",FE=n.forwardRef((A,q)=>{const V=sx(Ys,A.__scopeTooltip),{forceMount:t=V.forceMount,side:o="top",...g}=A,a=Fo(Ys,A.__scopeTooltip);return E.jsx(ae,{present:t||a.open,children:a.disableHoverableContent?E.jsx(DE,{side:o,...g,ref:q}):E.jsx(ox,{side:o,...g,ref:q})})}),ox=n.forwardRef((A,q)=>{const V=Fo(Ys,A.__scopeTooltip),t=Al(Ys,A.__scopeTooltip),o=n.useRef(null),g=zA(q,o),[a,l]=n.useState(null),{trigger:w,onClose:B}=V,c=o.current,{onPointerInTransitChange:C}=t,h=n.useCallback(()=>{l(null),C(!1)},[C]),Q=n.useCallback((D,F)=>{const G=D.currentTarget,I={x:D.clientX,y:D.clientY},p=rx(I,G.getBoundingClientRect()),T=nx(I,p),W=lx(F.getBoundingClientRect()),S=Mx([...T,...W]);l(S),C(!0)},[C]);return n.useEffect(()=>()=>h(),[h]),n.useEffect(()=>{if(w&&c){const D=G=>Q(G,c),F=G=>Q(G,w);return w.addEventListener("pointerleave",D),c.addEventListener("pointerleave",F),()=>{w.removeEventListener("pointerleave",D),c.removeEventListener("pointerleave",F)}}},[w,c,Q,h]),n.useEffect(()=>{if(a){const D=F=>{const G=F.target,I={x:F.clientX,y:F.clientY},p=w?.contains(G)||c?.contains(G),T=!wx(I,a);p?h():T&&(h(),B())};return document.addEventListener("pointermove",D),()=>document.removeEventListener("pointermove",D)}},[w,c,a,B,h]),E.jsx(DE,{...A,ref:g})}),[ix,gx]=Dg(mo,{isInside:!1}),ax=ru("TooltipContent"),DE=n.forwardRef((A,q)=>{const{__scopeTooltip:V,children:t,"aria-label":o,onEscapeKeyDown:g,onPointerDownOutside:a,...l}=A,w=Fo(Ys,V),B=Gg(V),{onClose:c}=w;return n.useEffect(()=>(document.addEventListener($n,c),()=>document.removeEventListener($n,c)),[c]),n.useEffect(()=>{if(w.trigger){const C=h=>{h.target?.contains(w.trigger)&&c()};return window.addEventListener("scroll",C,{capture:!0}),()=>window.removeEventListener("scroll",C,{capture:!0})}},[w.trigger,c]),E.jsx(ro,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:g,onPointerDownOutside:a,onFocusOutside:C=>C.preventDefault(),onDismiss:c,children:E.jsxs(Kn,{"data-state":w.stateAttribute,...B,...l,ref:q,style:{...l.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[E.jsx(ax,{children:t}),E.jsx(ix,{scope:V,isInside:!0,children:E.jsx(nK,{id:w.contentId,role:"tooltip",children:o||t})})]})})});FE.displayName=Ys;var GE="TooltipArrow",QE=n.forwardRef((A,q)=>{const{__scopeTooltip:V,...t}=A,o=Gg(V);return gx(GE,V).isInside?null:E.jsx(Tn,{...o,...t,ref:q})});QE.displayName=GE;function rx(A,q){const V=Math.abs(q.top-A.y),t=Math.abs(q.bottom-A.y),o=Math.abs(q.right-A.x),g=Math.abs(q.left-A.x);switch(Math.min(V,t,o,g)){case g:return"left";case o:return"right";case V:return"top";case t:return"bottom";default:throw new Error("unreachable")}}function nx(A,q,V=5){const t=[];switch(q){case"top":t.push({x:A.x-V,y:A.y+V},{x:A.x+V,y:A.y+V});break;case"bottom":t.push({x:A.x-V,y:A.y-V},{x:A.x+V,y:A.y-V});break;case"left":t.push({x:A.x+V,y:A.y-V},{x:A.x+V,y:A.y+V});break;case"right":t.push({x:A.x-V,y:A.y-V},{x:A.x-V,y:A.y+V});break}return t}function lx(A){const{top:q,right:V,bottom:t,left:o}=A;return[{x:o,y:q},{x:V,y:q},{x:V,y:t},{x:o,y:t}]}function wx(A,q){const{x:V,y:t}=A;let o=!1;for(let g=0,a=q.length-1;g<q.length;a=g++){const l=q[g],w=q[a],B=l.x,c=l.y,C=w.x,h=w.y;c>t!=h>t&&V<(C-B)*(t-c)/(h-c)+B&&(o=!o)}return o}function Mx(A){const q=A.slice();return q.sort((V,t)=>V.x<t.x?-1:V.x>t.x?1:V.y<t.y?-1:V.y>t.y?1:0),Bx(q)}function Bx(A){if(A.length<=1)return A.slice();const q=[];for(let t=0;t<A.length;t++){const o=A[t];for(;q.length>=2;){const g=q[q.length-1],a=q[q.length-2];if((g.x-a.x)*(o.y-a.y)>=(g.y-a.y)*(o.x-a.x))q.pop();else break}q.push(o)}q.pop();const V=[];for(let t=A.length-1;t>=0;t--){const o=A[t];for(;V.length>=2;){const g=V[V.length-1],a=V[V.length-2];if((g.x-a.x)*(o.y-a.y)>=(g.y-a.y)*(o.x-a.x))V.pop();else break}V.push(o)}return V.pop(),q.length===1&&V.length===1&&q[0].x===V[0].x&&q[0].y===V[0].y?q:q.concat(V)}var Yx=cE,Cx=EE,cx=hE,Ex=mE,hx=FE,mx=QE;function Fx({delayDuration:A=0,...q}){return E.jsx(Yx,{"data-slot":"tooltip-provider",delayDuration:A,...q})}function el({...A}){return E.jsx(Fx,{children:E.jsx(Cx,{"data-slot":"tooltip",...A})})}function tl({...A}){return E.jsx(cx,{"data-slot":"tooltip-trigger",...A})}function sl({className:A,sideOffset:q=0,children:V,container:t,...o}){return E.jsx(Ex,{container:t,children:E.jsxs(hx,{"data-slot":"tooltip-content",sideOffset:q,className:OA("wv:bg-primary wv:text-primary-foreground wv:animate-in wv:fade-in-0 wv:zoom-in-95 wv:data-[state=closed]:animate-out wv:data-[state=closed]:fade-out-0 wv:data-[state=closed]:zoom-out-95 wv:data-[side=bottom]:slide-in-from-top-2 wv:data-[side=left]:slide-in-from-right-2 wv:data-[side=right]:slide-in-from-left-2 wv:data-[side=top]:slide-in-from-bottom-2 wv:z-50 wv:w-fit wv:origin-(--radix-tooltip-content-transform-origin) wv:rounded-md wv:px-3 wv:py-1.5 wv:text-xs wv:text-balance",A),...o,children:[V,E.jsx(mx,{className:"wv:bg-primary wv:fill-primary wv:z-50 wv:size-2.5 wv:translate-y-[calc(-50%_-_2px)] wv:rotate-45 wv:rounded-[2px]"})]})})}function Dx({device:A,setShowQRCode:q}){const{removeDevice:V,disableDevice:t,enableDevice:o}=Ze(),[g,a]=n.useState(!1);return E.jsxs("div",{"data-enable":A.enable,className:"wv:relative wv:flex wv:justify-between wv:items-center wv:gap-2 wv:p-4 wv:bg-muted wv:data-[enable=false]:bg-muted-foreground/30 wv:rounded-md wv:overflow-hidden",children:[E.jsxs("div",{className:"wv:flex wv:flex-col wv:gap-1",children:[A.status&&E.jsxs(E.Fragment,{children:[["disconnected","hibernating"].includes(A.status)&&E.jsxs(el,{children:[E.jsxs(tl,{children:[E.jsx(Vq,{variant:"outline",className:"wv:size-fit !wv:p-0.5 wv:aspect-square wv:hover:cursor-pointer",onClick:()=>A.wakeUp(),children:E.jsx(XB,{})}),E.jsxs("div",{className:"wv:flex wv:flex-row wv:gap-1 wv:items-center",children:[E.jsx(As,{size:18,color:"red"}),E.jsx("p",{"data-enable":A.enable,className:"wv:font-medium wv:text-foreground",children:A.contact.unofficial?.phone})]})]}),E.jsx(sl,{children:E.jsx("p",{children:"Ligar Dispositivo"})})]}),(["connecting"].includes(A.status)||A.qrcode)&&E.jsxs("div",{className:"wv:flex wv:flex-row wv:gap-1 wv:items-center",children:[E.jsx(kr,{size:18}),E.jsx("p",{"data-enable":A.enable,className:"wv:font-medium wv:text-foreground",children:"Aguardando vincular Whatsapp"})]}),["close"].includes(A.status)&&E.jsxs("div",{className:"wv:flex wv:flex-row wv:gap-1 wv:items-center",children:[E.jsx(Sr,{size:18,color:"red"}),E.jsx("p",{"data-enable":A.enable,className:"wv:font-medium wv:data-[enable=false]:text-muted-foreground",children:"Desconectado"})]}),["error"].includes(A.status)&&E.jsxs("div",{className:"wv:flex wv:flex-row wv:gap-1 wv:items-center",children:[E.jsx(Sr,{size:18,color:"red"}),E.jsx("p",{"data-enable":A.enable,className:"wv:font-medium wv:data-[enable=false]:text-muted-foreground",children:"Falha"})]}),["open","UP"].includes(A.status)&&E.jsxs("div",{className:"wv:flex wv:flex-row wv:gap-1 wv:items-center",children:[E.jsx(As,{size:18,color:"green"}),E.jsx("p",{"data-enable":A.enable,className:"wv:font-medium wv:text-foreground",children:A.contact.unofficial?.phone})]})]}),E.jsx("p",{"data-enable":A.enable,className:"wv:text-[12px] wv:text-foreground",children:A.token})]}),E.jsxs("div",{className:"wv:flex wv:gap-2 wv:items-center",children:[E.jsx(XU,{className:"wv:hover:cursor-pointer",checked:A.enable,onCheckedChange:l=>l?o(A.token):t(A.token),disabled:!["open","CONNECTED"].includes(A.status)}),A.qrcode&&E.jsxs(el,{children:[E.jsx(tl,{asChild:!0,children:E.jsx(Vq,{variant:"ghost",className:"wv:size-fit !wv:p-1.5 wv:aspect-square wv:hover:cursor-pointer wv:bg-red",onClick:()=>q(A.qrcode),children:E.jsx(kr,{className:"size-6"})})}),E.jsx(sl,{children:E.jsx("p",{children:"Mostrar QRCode"})})]}),E.jsx(Vq,{variant:"destructive",className:"wv:size-fit !wv:p-1.5 wv:aspect-square wv:hover:cursor-pointer",onClick:()=>{a(!0)},children:E.jsx(oY,{})})]}),g&&E.jsx("div",{className:"wv:absolute wv:flex wv:bg-[#ef4444] wv:w-full wv:h-full wv:left-0 wv:border wv:border-[white] wv:rounded-md wv:items-center wv:p-4",children:E.jsxs("div",{className:"wv:flex wv:flex-row wv:gap-1 wv:w-full wv:justify-between",children:[E.jsx("div",{className:"wv:flex wv:flex-row wv:gap-1 wv:items-center",children:E.jsx("p",{"data-enable":A.enable,className:"wv:font-medium wv:text-[white] wv:select-none",children:"Deseja excluir esse dispositivo?"})}),E.jsxs("div",{className:"wv:flex wv:flex-row wv:gap-2",children:[E.jsx(Vq,{variant:"outline",size:"icon","aria-label":"Submit",className:"wv:bg-[transparent] wv:p-2 wv:px-[35px] wv:text-[white] wv:cursor-pointer wv:select-none",onClick:()=>{V(A.token)},children:"Excluir"}),E.jsx(Vq,{variant:"outline",className:"wv:bg-[transparent] wv:p-2 wv:px-[10px] wv:text-[white] wv:cursor-pointer wv:select-none",onClick:()=>{a(!1)},children:"Cancelar"})]})]})})]})}var Qg="Dialog",[IE,RS]=fV(Qg),[Gx,IV]=IE(Qg),uE=A=>{const{__scopeDialog:q,children:V,open:t,defaultOpen:o,onOpenChange:g,modal:a=!0}=A,l=n.useRef(null),w=n.useRef(null),[B,c]=We({prop:t,defaultProp:o??!1,onChange:g,caller:Qg});return E.jsx(Gx,{scope:q,triggerRef:l,contentRef:w,contentId:JV(),titleId:JV(),descriptionId:JV(),open:B,onOpenChange:c,onOpenToggle:n.useCallback(()=>c(C=>!C),[c]),modal:a,children:V})};uE.displayName=Qg;var pE="DialogTrigger",KE=n.forwardRef((A,q)=>{const{__scopeDialog:V,...t}=A,o=IV(pE,V),g=zA(q,o.triggerRef);return E.jsx(xA.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":gl(o.open),...t,ref:g,onClick:pA(A.onClick,o.onOpenToggle)})});KE.displayName=pE;var ol="DialogPortal",[Qx,TE]=IE(ol,{forceMount:void 0}),UE=A=>{const{__scopeDialog:q,forceMount:V,children:t,container:o}=A,g=IV(ol,q);return E.jsx(Qx,{scope:q,forceMount:V,children:n.Children.map(t,a=>E.jsx(ae,{present:V||g.open,children:E.jsx(Mo,{asChild:!0,container:o,children:a})}))})};UE.displayName=ol;var Ig="DialogOverlay",xE=n.forwardRef((A,q)=>{const V=TE(Ig,A.__scopeDialog),{forceMount:t=V.forceMount,...o}=A,g=IV(Ig,A.__scopeDialog);return g.modal?E.jsx(ae,{present:t||g.open,children:E.jsx(ux,{...o,ref:q})}):null});xE.displayName=Ig;var Ix=mt("DialogOverlay.RemoveScroll"),ux=n.forwardRef((A,q)=>{const{__scopeDialog:V,...t}=A,o=IV(Ig,V);return E.jsx(wg,{as:Ix,allowPinchZoom:!0,shards:[o.contentRef],children:E.jsx(xA.div,{"data-state":gl(o.open),...t,ref:q,style:{pointerEvents:"auto",...t.style}})})}),It="DialogContent",dE=n.forwardRef((A,q)=>{const V=TE(It,A.__scopeDialog),{forceMount:t=V.forceMount,...o}=A,g=IV(It,A.__scopeDialog);return E.jsx(ae,{present:t||g.open,children:g.modal?E.jsx(px,{...o,ref:q}):E.jsx(Kx,{...o,ref:q})})});dE.displayName=It;var px=n.forwardRef((A,q)=>{const V=IV(It,A.__scopeDialog),t=n.useRef(null),o=zA(q,V.contentRef,t);return n.useEffect(()=>{const g=t.current;if(g)return xn(g)},[]),E.jsx(LE,{...A,ref:o,trapFocus:V.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:pA(A.onCloseAutoFocus,g=>{g.preventDefault(),V.triggerRef.current?.focus()}),onPointerDownOutside:pA(A.onPointerDownOutside,g=>{const a=g.detail.originalEvent,l=a.button===0&&a.ctrlKey===!0;(a.button===2||l)&&g.preventDefault()}),onFocusOutside:pA(A.onFocusOutside,g=>g.preventDefault())})}),Kx=n.forwardRef((A,q)=>{const V=IV(It,A.__scopeDialog),t=n.useRef(!1),o=n.useRef(!1);return E.jsx(LE,{...A,ref:q,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:g=>{A.onCloseAutoFocus?.(g),g.defaultPrevented||(t.current||V.triggerRef.current?.focus(),g.preventDefault()),t.current=!1,o.current=!1},onInteractOutside:g=>{A.onInteractOutside?.(g),g.defaultPrevented||(t.current=!0,g.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const a=g.target;V.triggerRef.current?.contains(a)&&g.preventDefault(),g.detail.originalEvent.type==="focusin"&&o.current&&g.preventDefault()}})}),LE=n.forwardRef((A,q)=>{const{__scopeDialog:V,trapFocus:t,onOpenAutoFocus:o,onCloseAutoFocus:g,...a}=A,l=IV(It,V),w=n.useRef(null),B=zA(q,w);return ln(),E.jsxs(E.Fragment,{children:[E.jsx(vi,{asChild:!0,loop:!0,trapped:t,onMountAutoFocus:o,onUnmountAutoFocus:g,children:E.jsx(ro,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":gl(l.open),...a,ref:B,onDismiss:()=>l.onOpenChange(!1)})}),E.jsxs(E.Fragment,{children:[E.jsx(Tx,{titleId:l.titleId}),E.jsx(xx,{contentRef:w,descriptionId:l.descriptionId})]})]})}),il="DialogTitle",WE=n.forwardRef((A,q)=>{const{__scopeDialog:V,...t}=A,o=IV(il,V);return E.jsx(xA.h2,{id:o.titleId,...t,ref:q})});WE.displayName=il;var yE="DialogDescription",RE=n.forwardRef((A,q)=>{const{__scopeDialog:V,...t}=A,o=IV(yE,V);return E.jsx(xA.p,{id:o.descriptionId,...t,ref:q})});RE.displayName=yE;var ZE="DialogClose",SE=n.forwardRef((A,q)=>{const{__scopeDialog:V,...t}=A,o=IV(ZE,V);return E.jsx(xA.button,{type:"button",...t,ref:q,onClick:pA(A.onClick,()=>o.onOpenChange(!1))})});SE.displayName=ZE;function gl(A){return A?"open":"closed"}var kE="DialogTitleWarning",[ZS,NE]=Fu(kE,{contentName:It,titleName:il,docsSlug:"dialog"}),Tx=({titleId:A})=>{const q=NE(kE),V=`\`${q.contentName}\` requires a \`${q.titleName}\` for the component to be accessible for screen reader users.
143
+ */var Hc;function aU(){if(Hc)return On;Hc=1;var A=Pt();function q(C,h){return C===h&&(C!==0||1/C===1/h)||C!==C&&h!==h}var V=typeof Object.is=="function"?Object.is:q,t=A.useState,o=A.useEffect,g=A.useLayoutEffect,a=A.useDebugValue;function l(C,h){var Q=h(),D=t({inst:{value:Q,getSnapshot:h}}),F=D[0].inst,G=D[1];return g(function(){F.value=Q,F.getSnapshot=h,w(F)&&G({inst:F})},[C,Q,h]),o(function(){return w(F)&&G({inst:F}),C(function(){w(F)&&G({inst:F})})},[C]),a(Q),Q}function w(C){var h=C.getSnapshot;C=C.value;try{var Q=h();return!V(C,Q)}catch{return!0}}function B(C,h){return h()}var c=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?B:l;return On.useSyncExternalStore=A.useSyncExternalStore!==void 0?A.useSyncExternalStore:c,On}var zc;function rU(){return zc||(zc=1,jn.exports=aU()),jn.exports}var nU=rU();function lU(){return nU.useSyncExternalStore(wU,()=>!0,()=>!1)}function wU(){return()=>{}}var Hn="Avatar",[MU,LS]=fV(Hn),[BU,vc]=MU(Hn),Pc=n.forwardRef((A,q)=>{const{__scopeAvatar:V,...t}=A,[o,g]=n.useState("idle");return E.jsx(BU,{scope:V,imageLoadingStatus:o,onImageLoadingStatusChange:g,children:E.jsx(xA.span,{...t,ref:q})})});Pc.displayName=Hn;var bc="AvatarImage",Xc=n.forwardRef((A,q)=>{const{__scopeAvatar:V,src:t,onLoadingStatusChange:o=()=>{},...g}=A,a=vc(bc,V),l=YU(t,g),w=oe(B=>{o(B),a.onImageLoadingStatusChange(B)});return Yq(()=>{l!=="idle"&&w(l)},[l,w]),l==="loaded"?E.jsx(xA.img,{...g,ref:q,src:t}):null});Xc.displayName=bc;var _c="AvatarFallback",$c=n.forwardRef((A,q)=>{const{__scopeAvatar:V,delayMs:t,...o}=A,g=vc(_c,V),[a,l]=n.useState(t===void 0);return n.useEffect(()=>{if(t!==void 0){const w=window.setTimeout(()=>l(!0),t);return()=>window.clearTimeout(w)}},[t]),a&&g.imageLoadingStatus!=="loaded"?E.jsx(xA.span,{...o,ref:q}):null});$c.displayName=_c;function AE(A,q){return A?q?(A.src!==q&&(A.src=q),A.complete&&A.naturalWidth>0?"loaded":"loading"):"error":"idle"}function YU(A,{referrerPolicy:q,crossOrigin:V}){const t=lU(),o=n.useRef(null),g=t?(o.current||(o.current=new window.Image),o.current):null,[a,l]=n.useState(()=>AE(g,A));return Yq(()=>{l(AE(g,A))},[g,A]),Yq(()=>{const w=C=>()=>{l(C)};if(!g)return;const B=w("loaded"),c=w("error");return g.addEventListener("load",B),g.addEventListener("error",c),q&&(g.referrerPolicy=q),typeof V=="string"&&(g.crossOrigin=V),()=>{g.removeEventListener("load",B),g.removeEventListener("error",c)}},[g,V,q]),a}var CU=Pc,cU=Xc,EU=$c;function zn({className:A,...q}){return E.jsx(CU,{"data-slot":"avatar",className:OA("wv:relative wv:flex wv:size-8 wv:shrink-0 wv:overflow-hidden wv:rounded-full",A),...q})}function vn({className:A,...q}){return E.jsx(cU,{"data-slot":"avatar-image",className:OA("wv:aspect-square wv:size-full",A),...q})}function Pn({className:A,...q}){return E.jsx(EU,{"data-slot":"avatar-fallback",className:OA("wv:bg-muted wv:flex wv:size-full wv:items-center wv:justify-center wv:rounded-full",A),...q})}const hU=An("wv:inline-flex wv:items-center wv:justify-center wv:gap-2 wv:whitespace-nowrap wv:rounded-md wv:text-sm wv:font-medium wv:transition-all wv:disabled:pointer-events-none wv:disabled:opacity-50 wv:[&_svg]:pointer-events-none wv:[&_svg:not([class*=size-])]:size-4 wv:shrink-0 wv:[&_svg]:shrink-0 wv:outline-none wv:focus-visible:border-ring wv:focus-visible:ring-ring/50 wv:focus-visible:ring-[3px] wv:aria-invalid:ring-destructive/20 wv:dark:aria-invalid:ring-destructive/40 wv:aria-invalid:border-destructive",{variants:{variant:{default:"wv:bg-primary wv:text-primary-foreground wv:shadow-xs wv:hover:bg-primary/90",destructive:"wv:bg-destructive wv:text-white wv:shadow-xs wv:hover:bg-destructive/90 wv:focus-visible:ring-destructive/20 wv:dark:focus-visible:ring-destructive/40 wv:dark:bg-destructive/60",outline:"wv:border wv:bg-background wv:shadow-xs wv:hover:bg-accent wv:hover:text-accent-foreground wv:dark:bg-input/30 wv:dark:border-input wv:dark:hover:bg-input/50",secondary:"wv:bg-secondary wv:text-secondary-foreground wv:shadow-xs wv:hover:bg-secondary/80",ghost:"wv:hover:bg-accent wv:hover:text-accent-foreground wv:dark:hover:bg-accent/50",link:"wv:text-primary wv:underline-offset-4 wv:hover:underline"},size:{default:"wv:h-9 wv:px-4 wv:py-2 wv:has-[>svg]:px-3",sm:"wv:h-8 wv:rounded-md wv:gap-1.5 wv:px-3 wv:has-[>svg]:px-2.5",lg:"wv:h-10 wv:rounded-md wv:px-6 wv:has-[>svg]:px-4",icon:"wv:size-9"}},defaultVariants:{variant:"default",size:"default"}});function Vq({className:A,variant:q,size:V,asChild:t=!1,...o}){const g=t?AC:"button";return E.jsx(g,{"data-slot":"button",className:OA(hU({variant:q,size:V,className:A})),...o})}function mU({offer:A}){const[q,V]=n.useState(!1),[t,o]=n.useState(null),[g,a]=n.useState(null);return n.useEffect(()=>{A.onEnd(()=>{a("Chamada encerrada")}),A.onAcceptedElsewhere(()=>{a("Aceita por outro usuário")}),A.onRejectedElsewhere(()=>{a("Rejeitada pelo aplicativo")}),A.onUnanswered(()=>{a("Tempo limite")})},[A]),E.jsxs("div",{className:"wv:flex wv:flex-col wv:gap-3 wv:w-[365px] wv:bg-background",children:[E.jsx("div",{className:"wv:flex wv:flex-row wv:gap-1",children:E.jsxs("div",{className:"wv:flex wv:flex-row wv:justify-between wv:gap-2 ",children:[E.jsxs("div",{className:"wv:flex wv:flex-row wv:justify-center wv:items-center wv:gap-2 wv:opacity-75 wv:text-foreground",children:[E.jsx(gI,{size:20,color:"currentColor"}),E.jsx("p",{className:"wv:text-foreground wv:text-[14px] wv:select-none",children:"Whatsapp Audio"})]}),E.jsxs("div",{className:"wv:flex wv:items-center wv:space-x-1",children:[E.jsx("span",{className:"dot wv:w-1.5 wv:h-1.5 wv:rounded-full wv:bg-foreground animate-bounce1"}),E.jsx("span",{className:"dot wv:w-1.5 wv:h-1.5 wv:rounded-full wv:bg-foreground animate-bounce2"}),E.jsx("span",{className:"dot wv:w-1.5 wv:h-1.5 wv:rounded-full wv:bg-foreground animate-bounce3"})]})]})}),E.jsxs("div",{className:"wv:flex wv:gap-3",children:[E.jsxs(zn,{className:"wv:size-[50px] wv:rounded-xl",children:[E.jsx(vn,{src:A.peer?.profilePicture??""}),E.jsx(Pn,{children:gn(A.peer?.displayName)})]}),E.jsxs("div",{className:"wv:flex-grow wv:relative wv:group/title wv:flex wv:flex-col wv:overflow-hidden wv:font-normal",children:[t??g?E.jsxs(E.Fragment,{children:[t&&E.jsx("p",{className:"wv:text-xm wv:text-ellipsis wv:text-red-600",children:t}),g&&E.jsx("p",{className:"wv:text-foreground wv:opacity-40 wv:text-[14px] wv:select-none",children:g})]}):E.jsx("p",{className:"wv:text-foreground wv:opacity-40 wv:text-[14px] wv:select-none",children:A.peer?.phone}),E.jsx("div",{className:"wv:hidden wv:group-hover/title:block",children:E.jsx(hg,{speed:10,className:"wv:text-[24px] wv:leading-[28px] wv:font-normal wv:select-none",children:A.peer?.displayName||A.peer?.phone})}),E.jsx("p",{className:"wv:block wv:group-hover/title:hidden wv:text-[24px] wv:leading-[28px] wv:font-normal wv:truncate w-48",children:A.peer?.displayName||A.peer?.phone})]}),E.jsxs("div",{className:"wv:flex wv:flex-row wv:gap-2",children:[E.jsx(Vq,{type:"submit",size:"icon",className:"wv:text-[white] wv:p-4 wv:bg-red-500 wv:hover:bg-red-700 wv:active:bg-red-700 wv:hover:cursor-pointer wv:w-full wv:rounded-full wv:h-[40px] wv:w-[40px]",disabled:q,onClick:()=>{V(!0),A.reject().then(({err:l})=>{if(l){o(l),V(!1);return}cg.dismiss(A.id)})},children:E.jsx(iI,{className:"wv:size-5",weight:"fill"})}),E.jsx(Vq,{type:"submit",size:"icon",className:"wv:text-[white] wv:p-4 wv:bg-green-500 wv:hover:bg-green-700 wv:active:bg-green-700 wv:hover:cursor-pointer wv:w-full wv:rounded-full wv:h-[40px] wv:w-[40px]",disabled:q,onClick:()=>{V(!0),A.accept().then(({err:l})=>{if(l){o(l),V(!1);return}cg.dismiss(A.id)})},children:E.jsx(As,{className:"wv:size-5",weight:"fill"})})]})]})]})}const gV={video:document.createElement("video"),canvas:document.createElement("canvas"),call:null,animationID:null};function FU(){document.removeEventListener("visibilitychange",DU),gV.animationID&&(cancelAnimationFrame(gV.animationID),gV.animationID=null)}async function DU(){if(document.pictureInPictureEnabled){if(document.hidden&&!document.pictureInPictureElement){const{canvas:A,video:q}=gV;A.width=200,A.height=200,qE(A),q.height=200,q.width=200,q.srcObject=A.captureStream(),q.muted=!0,q.play(),q.addEventListener("loadedmetadata",()=>q.requestPictureInPicture(),{once:!0});return}document.pictureInPictureElement&&(await document.exitPictureInPicture(),gV.animationID&&(cancelAnimationFrame(gV.animationID),gV.animationID=null))}}async function qE(A){gV.animationID=requestAnimationFrame(()=>qE(A));const{call:q}=gV;if(!q)return;const V=10,t=A.getContext("2d");t.fillStyle="black",t.fillRect(0,0,A.width,A.height);const o={x:V,y:V,width:0,height:0};if(q.peer?.profilePicture){o.height=A.height/2-2*V,o.width=o.height;const{x:g,y:a,height:l,width:w}=o,B=new Image;B.crossOrigin="anonymous",B.src=q.peer?.profilePicture,B.onload=()=>{t.drawImage(B,g,a,w,l)}}}let Yo=[];function GU(A,q,V={}){const t=A.getContext("2d");if(!t)return;const o=window.devicePixelRatio||1;A.width=A.clientWidth*o,A.height=A.clientHeight*o,t.scale(o,o),t.imageSmoothingEnabled=!1,t.translate(.5,.5);const{x:g=0,y:a=0,width:l=A.clientWidth,height:w=A.clientHeight,bars:B=15,gap:c=2,color:C="#00ff66"}=V;t.clearRect(0,0,l,w),t.fillStyle=C;const h=Math.floor(q.length/B),Q=(l-c*(B-1))/B;Yo.length!==B&&(Yo=Array(B).fill(0));const D=Math.floor(B/2);for(let F=0;F<B;F++){const G=F-D,I=Math.abs(G);let p=0;for(let rA=0;rA<h;rA++)p+=q[I*h+rA];const T=p/h,W=Math.pow(T/255,.6),S=Math.max(W*w,3);Yo[F]=Yo[F]*.75+S*.25;const O=Yo[F],k=g+D*(Q+c)+G*(Q+c),N=a+(w-O)/2;QU(t,k,N,Q,O,3)}}function QU(A,q,V,t,o,g){A.beginPath(),A.moveTo(q+g,V),A.lineTo(q+t-g,V),A.quadraticCurveTo(q+t,V,q+t,V+g),A.lineTo(q+t,V+o-g),A.quadraticCurveTo(q+t,V+o,q+t-g,V+o),A.lineTo(q+g,V+o),A.quadraticCurveTo(q,V+o,q,V+o-g),A.lineTo(q,V+g),A.quadraticCurveTo(q,V,q+g,V),A.closePath(),A.fill()}const VE=n.createContext(void 0);function IU({children:A}){const[q,V]=n.useState("keyboard");return E.jsx(VE.Provider,{value:{screen:q,setScreen:V},children:A})}function eE(){const A=n.useContext(VE);if(!A)throw new Error("useScreen deve ser usado dentro de <ScreenProvider>");return A}var uU=(A,q,V,t,o,g,a,l)=>{let w=document.documentElement,B=["light","dark"];function c(Q){(Array.isArray(A)?A:[A]).forEach(D=>{let F=D==="class",G=F&&g?o.map(I=>g[I]||I):o;F?(w.classList.remove(...G),w.classList.add(g&&g[Q]?g[Q]:Q)):w.setAttribute(D,Q)}),C(Q)}function C(Q){l&&B.includes(Q)&&(w.style.colorScheme=Q)}function h(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}if(t)c(t);else try{let Q=localStorage.getItem(q)||V,D=a&&Q==="system"?h():Q;c(D)}catch{}},pU=n.createContext(void 0),KU={setTheme:A=>{},themes:[]},tE=()=>{var A;return(A=n.useContext(pU))!=null?A:KU};n.memo(({forcedTheme:A,storageKey:q,attribute:V,enableSystem:t,enableColorScheme:o,defaultTheme:g,value:a,themes:l,nonce:w,scriptProps:B})=>{let c=JSON.stringify([V,q,g,A,l,a,t,o]).slice(1,-1);return n.createElement("script",{...B,suppressHydrationWarning:!0,nonce:typeof window>"u"?w:"",dangerouslySetInnerHTML:{__html:`(${uU.toString()})(${c})`}})});const TU=({...A})=>{const{theme:q="system"}=tE();return E.jsx(oU,{theme:q,className:"wv:toaster wv:group",style:{"--normal-bg":"var(--popover)","--normal-text":"var(--popover-foreground)","--normal-border":"var(--border)"},...A})},Qt={};window.wavoip=Qt;function Co(A){A.call&&(Qt.call=A.call),A.notifications&&(Qt.notifications=A.notifications),A.widget&&(Qt.widget=A.widget),A.theme&&(Qt.theme=A.theme),A.settings&&(Qt.settings=A.settings),A.device&&(Qt.device=A.device)}const sE=n.createContext(void 0);function UU({children:A}){const[q,V]=n.useState(!0),[t,o]=n.useState(!0),[g,a]=n.useState(!1),[l,w]=n.useState(!0),[B,c]=n.useState(!0),[C,h]=n.useState(!0),[Q,D]=n.useState(!0),[F,G]=n.useState(!0),[I,p]=n.useState(!0);return Co({settings:{showNotifications:q,showSettings:t,showDevices:l,showAddDevices:B,showEnableDevices:C,showRemoveDevices:Q,showKeyboardScreen:F,showWidgetButton:I,setShowNotifications:V,setShowSettings:o,setShowDevices:w,setShowAddDevices:c,setShowEnableDevices:h,setShowRemoveDevices:D,setShowKeyboardScreen:G,setShowWidgetButton:p}}),E.jsx(sE.Provider,{value:{showNotifications:q,showSettings:t,showAudio:g,showDevices:l,showAddDevices:B,showEnableDevices:C,showRemoveDevices:Q,showKeyboardScreen:F,showWidgetButton:I,setShowWidgetButton:p,setShowNotifications:V,setShowSettings:o,setShowAudio:a,setShowDevices:w,setShowAddDevices:c,setShowEnableDevices:h,setShowRemoveDevices:D,setShowKeyboardScreen:G},children:A})}const bn=()=>{const A=n.useContext(sE);if(A===void 0)throw new Error("useSettings deve ser usado dentro de SettingsProvider");return A},xU={theme:"system",setTheme:()=>null},oE=n.createContext(xU);function dU({children:A,defaultTheme:q="system",storageKey:V="vite-ui-theme",...t}){const[o,g]=n.useState(()=>localStorage.getItem(V)||q);n.useEffect(()=>{const l=window.document.documentElement;if(l.classList.remove("light","dark"),o==="system"){const w=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";l.classList.add(w);return}l.classList.add(o)},[o]);const a=l=>{localStorage.setItem(V,l),g(l)};return Co({theme:{setTheme:a}}),E.jsx(oE.Provider,{...t,value:{theme:o,setTheme:a},children:A})}const LU=()=>{const A=n.useContext(oE);if(A===void 0)throw new Error("useTheme must be used within a ThemeProvider");return A},iE=n.createContext(void 0);function WU({children:A}){const{theme:q}=LU(),{showWidgetButton:V}=bn(),[t,o]=n.useState({x:document.body.clientWidth/3,y:document.body.clientHeight/3}),[g,a]=n.useState(!1),[l,w]=n.useState(!0),B=n.useRef({x:0,y:0}),c=n.useCallback(G=>{let I=G.clientX-B.current.x,p=G.clientY-B.current.y;I<0&&(I=0),p<0&&(p=0),I>document.body.clientWidth-280&&(I=document.body.clientWidth-280),p>document.body.clientHeight-480&&(p=document.body.clientHeight-480),o({x:I,y:p})},[]),C=n.useCallback(G=>{document.body.style.userSelect="none",a(!0),B.current={x:G.clientX-t.x,y:G.clientY-t.y},document.addEventListener("mousemove",c)},[c,t.x,t.y]),h=n.useCallback(()=>{a(!1),document.body.style.userSelect="unset",document.removeEventListener("mousemove",c)},[c]),Q=n.useCallback(()=>{l&&w(!1)},[l]),D=n.useCallback(()=>{l||w(!0)},[l]),F=n.useCallback(()=>{w(G=>!G)},[]);return n.useEffect(()=>{function G(){o({x:document.body.clientWidth/3,y:document.body.clientHeight/3})}return document.addEventListener("mouseleave",()=>{h()}),window.addEventListener("resize",G),()=>{window.removeEventListener("resize",G)}},[h]),Co({widget:{open:Q,close:D,toggle:F}}),E.jsxs(iE.Provider,{value:{position:t,setPosition:o,startDrag:C,stopDrag:h,isDragging:g,closed:l,setClosed:w,close:()=>{l||w(!0)},open:()=>{l&&w(!1)},toggle:()=>{w(G=>!G)}},children:[V&&E.jsx(Vq,{type:"button",onClick:()=>w(!1),size:"icon","data-closed":l,className:"wv:data-[closed=false]:hidden wv: wv:absolute sm:wv:fixed wv:bottom-0 wv:right-0 wv:p-3 wv:rounded-full wv:aspect-square wv:size-fit wv:bg-green-500 wv:text-white wv:font-bold wv:hover:bg-green-600",style:{position:"fixed",bottom:"20px",right:"20px",zIndex:9999},children:E.jsx(As,{className:"wv:size-8"})}),E.jsx(TU,{theme:q,position:"top-right",className:"!w-[400px]",toastOptions:{className:"wv:max-w-[400px] wv:w-full"}}),E.jsx("div",{"data-closed":l,className:"wv:data-[closed=true]:hidden wv:fixed wv:flex wv:flex-col wv:w-70 wv:h-120 wv:rounded-2xl wv:max-sm:fixed wv:max-sm:w-dvw wv:max-sm:h-dvh wv:max-sm:!left-[0px] wv:max-sm:!top-[0px] wv:bg-background wv:shadow-lg wv:touch-manipulation z-[2147483647]",style:{left:t.x,top:t.y},children:A})]})}function Xn(){const A=n.useContext(iE);if(!A)throw new Error("useWidget deve ser usado dentro de <WidgetProvider>");return A}const co=new Audio(iU),Eo=new Audio(gU);let ho=null;function yU({wavoip:A,devices:q}){const{setScreen:V}=eE(),{closed:t,setClosed:o,open:g}=Xn(),[a,l]=n.useState([]),[w,B]=n.useState(void 0),[c,C]=n.useState(void 0),h=n.useCallback(()=>{ZU(),FU(),setTimeout(()=>{ho&&(o(ho),ho=null),V("keyboard"),B(void 0),C(void 0),gV.call=null},3e3)},[V,o]),Q=n.useCallback(G=>{G.onEnd(()=>h());const I={...G,peer:G.peer,onEnd:p=>{G.onEnd(()=>{h(),p()})}};return V("call"),C(I),gV.call=G,I},[h,V]),D=n.useCallback(G=>{if(c)return;function I(){l(T=>T.filter(({id:W})=>W!==G.id)),_n(a),setTimeout(()=>{cg.dismiss(G.id)},2e3)}const p={...G,onEnd(T){G.onEnd(()=>{I(),T()})},onAcceptedElsewhere(T){G.onAcceptedElsewhere(()=>{I(),T()})},onRejectedElsewhere(T){G.onRejectedElsewhere(()=>{I(),T()})},onUnanswered(T){G.onUnanswered(()=>{I(),T()})},async accept(){const{call:T,err:W}=await G.accept();return T?(l([]),_n(a),g(),ho=t,{call:Q(T),err:W}):{call:T,err:W}},async reject(){const{err:T}=await G.reject();return T||_n(a),{err:T}}};l(T=>[...T,p]),SU(),cg(E.jsx(mU,{offer:p}),{id:G.id,duration:1e5,className:"wv:max-w-[400px] wv:!w-full"})},[t,c,Q,g,a]),F=n.useCallback(async(G,I)=>{const{call:p,err:T}=await A.startCall({fromTokens:I??q.filter(S=>S.enable).map(S=>S.token),to:G});if(T)return{err:T};p.onPeerAccept(S=>{Q(S),B(void 0)}),p.onUnanswered(()=>h()),p.onEnd(()=>h());const W={...p,peer:p.peer,onPeerAccept:S=>{p.onPeerAccept(O=>{const k=Q(O);B(void 0),S(k)})},onEnd:S=>{p.onEnd(()=>{S(),h()})},onUnanswered:S=>{p.onUnanswered(()=>{S(),h()})}};return ho=t,g(),B(W),V("outgoing"),RU(),gV.call=W,{err:null}},[q,Q,h,V,A.startCall,g,t]);return A.onOffer(G=>D(G)),{offers:a,outgoing:w,active:c,start:F}}function gE(A){return A.preventDefault(),A.returnValue="",""}function RU(){window.addEventListener("beforeunload",gE)}function ZU(){window.removeEventListener("beforeunload",gE)}function SU(){co.currentTime=0,co.loop=!0,co.volume=.25,co.play(),Eo.loop=!0,Eo.currentTime=0,Eo.volume=.25,Eo.play()}function _n(A){A.length||(co.pause(),Eo.pause())}const aE="wavoip:tokens";function rE(){const V=(localStorage.getItem(aE)?.split(";")||[]).map(t=>{const[o,g]=t.split(":");return{token:o,enable:g==="true"}});return new Map(V.map(t=>[t.token,t]))}function kU(A){const q=A.map(V=>`${V.token}:${V.enable}`).join(";");localStorage.setItem(aE,q)}const NU=rE();function fU({wavoip:A}){const[q,V]=n.useState(()=>A.getDevices().map(l=>({...l,enable:!!NU.get(l.token)?.enable&&["open","CONNECTED"].includes(l.status)}))),t=n.useCallback(l=>{const[w]=A.addDevices([l]);w&&V(B=>[...B,{...w,enable:["open","CONNECTOED"].includes(w.status)}])},[A.addDevices]),o=n.useCallback(l=>{A.removeDevices([l]),V(w=>w.filter(B=>B.token!==l))},[A.removeDevices]),g=n.useCallback(l=>{V(w=>w.map(B=>B.token===l?{...B,enable:!0}:B))},[]),a=n.useCallback(l=>{V(w=>w.map(B=>B.token===l?{...B,enable:!1}:B))},[]);return n.useEffect(()=>{for(const l of q)l.onQRCode(w=>{V(B=>B.map(c=>c.token===l.token?{...l,qrcode:w}:c))}),l.onStatus(w=>{V(B=>B.map(c=>c.token===l.token?{...l,status:w,enable:["open","CONNECTED"].includes(w)}:c))});kU(q)},[q]),{devices:q,add:t,remove:o,enable:g,disable:a}}const nE=n.createContext(void 0),JU=({children:A,wavoip:q})=>{const{devices:V,add:t,remove:o,disable:g,enable:a}=fU({wavoip:q}),{offers:l,outgoing:w,active:B,start:c}=yU({wavoip:q,devices:V});return n.useEffect(()=>()=>{delete window.wavoip},[]),Co({call:{startCall:c,getCallActive:()=>{if(!B)return;const{id:C,type:h,status:Q,device_token:D,direction:F,peer:G,muted:I}=B;return{id:C,type:h,status:Q,device_token:D,direction:F,peer:G,muted:I}},getCallOutgoing:()=>{if(!w)return;const{id:C,type:h,status:Q,device_token:D,direction:F,peer:G,muted:I}=w;return{id:C,type:h,status:Q,device_token:D,direction:F,peer:G,muted:I}},getOffers:()=>l.map(({id:C,type:h,status:Q,device_token:D,direction:F,peer:G,muted:I})=>({id:C,type:h,status:Q,device_token:D,direction:F,peer:G,muted:I}))},device:{getDevices:q.getDevices,addDevice:t,removeDevice:o,enableDevice:a,disableDevice:g}}),E.jsx(nE.Provider,{value:{wavoip:q,devices:V,offers:l,callOutgoing:w,callActive:B,startCall:c,addDevice:t,removeDevice:o,enableDevice:a,disableDevice:g},children:A})},Ze=()=>{const A=n.useContext(nE);if(!A)throw new Error("useWavoip deve ser usado dentro de WavoipProvider");return A};function jU(){const{wavoip:A}=Ze(),[q,V]=n.useState([]),[t,o]=n.useState([]);return n.useEffect(()=>{if(A){const g=A.getMultimediaDevices();V(g.microphones),o(g.speakers)}},[]),E.jsx("div",{className:" wv:py-3",children:E.jsx(Eu,{children:E.jsxs(hu,{className:"wv:flex wv:flex-col wv:gap-4",children:[E.jsxs(eC,{className:"wv:flex wv:flex-col wv:gap-1 wv:text-foreground",children:[E.jsx(tC,{children:"Microfone"}),E.jsxs(Sc,{children:[E.jsx(Nc,{className:"wv:max-w-[300px]",children:E.jsx(kc,{placeholder:"Choose department"})}),E.jsx(fc,{className:"wv:z-[2147483647]",children:q.map((g,a)=>E.jsx(Jc,{value:g.deviceId,children:g.label},`microphone_${a}`))})]}),E.jsx(sC,{children:"Selecione o microfone que deseja usar na ligação"})]}),E.jsxs(eC,{className:"wv:flex wv:flex-col wv:gap-1 wv:text-foreground",children:[E.jsx(tC,{children:"Alto falante"}),E.jsxs(Sc,{children:[E.jsx(Nc,{className:"wv:max-w-[300px]",children:E.jsx(kc,{placeholder:"Choose department"})}),E.jsx(fc,{className:"wv:z-[2147483647]",children:t.map((g,a)=>E.jsx(Jc,{value:g.deviceId,children:g.label},`speaker_${a}`))})]}),E.jsx(sC,{children:"Selecione o alto falante que deseja usar na ligação"})]})]})})})}var mg="Switch",[OU,WS]=fV(mg),[HU,zU]=OU(mg),lE=n.forwardRef((A,q)=>{const{__scopeSwitch:V,name:t,checked:o,defaultChecked:g,required:a,disabled:l,value:w="on",onCheckedChange:B,form:c,...C}=A,[h,Q]=n.useState(null),D=zA(q,T=>Q(T)),F=n.useRef(!1),G=h?c||!!h.closest("form"):!0,[I,p]=We({prop:o,defaultProp:g??!1,onChange:B,caller:mg});return E.jsxs(HU,{scope:V,checked:I,disabled:l,children:[E.jsx(xA.button,{type:"button",role:"switch","aria-checked":I,"aria-required":a,"data-state":YE(I),"data-disabled":l?"":void 0,disabled:l,value:w,...C,ref:D,onClick:pA(A.onClick,T=>{p(W=>!W),G&&(F.current=T.isPropagationStopped(),F.current||T.stopPropagation())})}),G&&E.jsx(BE,{control:h,bubbles:!F.current,name:t,value:w,checked:I,required:a,disabled:l,form:c,style:{transform:"translateX(-100%)"}})]})});lE.displayName=mg;var wE="SwitchThumb",ME=n.forwardRef((A,q)=>{const{__scopeSwitch:V,...t}=A,o=zU(wE,V);return E.jsx(xA.span,{"data-state":YE(o.checked),"data-disabled":o.disabled?"":void 0,...t,ref:q})});ME.displayName=wE;var vU="SwitchBubbleInput",BE=n.forwardRef(({__scopeSwitch:A,control:q,checked:V,bubbles:t=!0,...o},g)=>{const a=n.useRef(null),l=zA(a,g),w=XC(V),B=NC(q);return n.useEffect(()=>{const c=a.current;if(!c)return;const C=window.HTMLInputElement.prototype,Q=Object.getOwnPropertyDescriptor(C,"checked").set;if(w!==V&&Q){const D=new Event("click",{bubbles:t});Q.call(c,V),c.dispatchEvent(D)}},[w,V,t]),E.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:V,...o,tabIndex:-1,ref:l,style:{...o.style,...B,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});BE.displayName=vU;function YE(A){return A?"checked":"unchecked"}var PU=lE,bU=ME;function XU({className:A,...q}){return E.jsx(PU,{"data-slot":"switch",className:OA("wv:peer wv:data-[state=checked]:bg-primary wv:data-[state=unchecked]:bg-input wv:focus-visible:border-ring wv:focus-visible:ring-ring/50 wv:dark:data-[state=unchecked]:bg-input/80 wv:inline-flex wv:h-[1.15rem] wv:w-8 wv:shrink-0 wv:items-center wv:rounded-full wv:border wv:border-transparent wv:shadow-xs wv:transition-all wv:outline-none wv:focus-visible:ring-[3px] wv:disabled:cursor-not-allowed wv:disabled:opacity-50",A),...q,children:E.jsx(bU,{"data-slot":"switch-thumb",className:OA("wv:bg-background wv:dark:data-[state=unchecked]:bg-foreground wv:dark:data-[state=checked]:bg-primary-foreground wv:pointer-events-none wv:block wv:size-4 wv:rounded-full wv:ring-0 wv:transition-transform wv:data-[state=checked]:translate-x-[calc(100%-2px)] wv:data-[state=unchecked]:translate-x-0 wv:translate-y-0")})})}function _U(A,q){return n.useReducer((V,t)=>q[V][t]??V,A)}var ae=A=>{const{present:q,children:V}=A,t=$U(q),o=typeof V=="function"?V({present:t.isPresent}):n.Children.only(V),g=zA(t.ref,Ax(o));return typeof V=="function"||t.isPresent?n.cloneElement(o,{ref:g}):null};ae.displayName="Presence";function $U(A){const[q,V]=n.useState(),t=n.useRef(null),o=n.useRef(A),g=n.useRef("none"),a=A?"mounted":"unmounted",[l,w]=_U(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return n.useEffect(()=>{const B=Fg(t.current);g.current=l==="mounted"?B:"none"},[l]),Yq(()=>{const B=t.current,c=o.current;if(c!==A){const h=g.current,Q=Fg(B);A?w("MOUNT"):Q==="none"||B?.display==="none"?w("UNMOUNT"):w(c&&h!==Q?"ANIMATION_OUT":"UNMOUNT"),o.current=A}},[A,w]),Yq(()=>{if(q){let B;const c=q.ownerDocument.defaultView??window,C=Q=>{const F=Fg(t.current).includes(CSS.escape(Q.animationName));if(Q.target===q&&F&&(w("ANIMATION_END"),!o.current)){const G=q.style.animationFillMode;q.style.animationFillMode="forwards",B=c.setTimeout(()=>{q.style.animationFillMode==="forwards"&&(q.style.animationFillMode=G)})}},h=Q=>{Q.target===q&&(g.current=Fg(t.current))};return q.addEventListener("animationstart",h),q.addEventListener("animationcancel",C),q.addEventListener("animationend",C),()=>{c.clearTimeout(B),q.removeEventListener("animationstart",h),q.removeEventListener("animationcancel",C),q.removeEventListener("animationend",C)}}else w("ANIMATION_END")},[q,w]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:n.useCallback(B=>{t.current=B?getComputedStyle(B):null,V(B)},[])}}function Fg(A){return A?.animationName||"none"}function Ax(A){let q=Object.getOwnPropertyDescriptor(A.props,"ref")?.get,V=q&&"isReactWarning"in q&&q.isReactWarning;return V?A.ref:(q=Object.getOwnPropertyDescriptor(A,"ref")?.get,V=q&&"isReactWarning"in q&&q.isReactWarning,V?A.props.ref:A.props.ref||A.ref)}var[Dg,yS]=fV("Tooltip",[rs]),Gg=rs(),CE="TooltipProvider",qx=700,$n="tooltip.open",[Vx,Al]=Dg(CE),cE=A=>{const{__scopeTooltip:q,delayDuration:V=qx,skipDelayDuration:t=300,disableHoverableContent:o=!1,children:g}=A,a=n.useRef(!0),l=n.useRef(!1),w=n.useRef(0);return n.useEffect(()=>{const B=w.current;return()=>window.clearTimeout(B)},[]),E.jsx(Vx,{scope:q,isOpenDelayedRef:a,delayDuration:V,onOpen:n.useCallback(()=>{window.clearTimeout(w.current),a.current=!1},[]),onClose:n.useCallback(()=>{window.clearTimeout(w.current),w.current=window.setTimeout(()=>a.current=!0,t)},[t]),isPointerInTransitRef:l,onPointerInTransitChange:n.useCallback(B=>{l.current=B},[]),disableHoverableContent:o,children:g})};cE.displayName=CE;var mo="Tooltip",[ex,Fo]=Dg(mo),EE=A=>{const{__scopeTooltip:q,children:V,open:t,defaultOpen:o,onOpenChange:g,disableHoverableContent:a,delayDuration:l}=A,w=Al(mo,A.__scopeTooltip),B=Gg(q),[c,C]=n.useState(null),h=JV(),Q=n.useRef(0),D=a??w.disableHoverableContent,F=l??w.delayDuration,G=n.useRef(!1),[I,p]=We({prop:t,defaultProp:o??!1,onChange:k=>{k?(w.onOpen(),document.dispatchEvent(new CustomEvent($n))):w.onClose(),g?.(k)},caller:mo}),T=n.useMemo(()=>I?G.current?"delayed-open":"instant-open":"closed",[I]),W=n.useCallback(()=>{window.clearTimeout(Q.current),Q.current=0,G.current=!1,p(!0)},[p]),S=n.useCallback(()=>{window.clearTimeout(Q.current),Q.current=0,p(!1)},[p]),O=n.useCallback(()=>{window.clearTimeout(Q.current),Q.current=window.setTimeout(()=>{G.current=!0,p(!0),Q.current=0},F)},[F,p]);return n.useEffect(()=>()=>{Q.current&&(window.clearTimeout(Q.current),Q.current=0)},[]),E.jsx(pn,{...B,children:E.jsx(ex,{scope:q,contentId:h,open:I,stateAttribute:T,trigger:c,onTriggerChange:C,onTriggerEnter:n.useCallback(()=>{w.isOpenDelayedRef.current?O():W()},[w.isOpenDelayedRef,O,W]),onTriggerLeave:n.useCallback(()=>{D?S():(window.clearTimeout(Q.current),Q.current=0)},[S,D]),onOpen:W,onClose:S,disableHoverableContent:D,children:V})})};EE.displayName=mo;var ql="TooltipTrigger",hE=n.forwardRef((A,q)=>{const{__scopeTooltip:V,...t}=A,o=Fo(ql,V),g=Al(ql,V),a=Gg(V),l=n.useRef(null),w=zA(q,l,o.onTriggerChange),B=n.useRef(!1),c=n.useRef(!1),C=n.useCallback(()=>B.current=!1,[]);return n.useEffect(()=>()=>document.removeEventListener("pointerup",C),[C]),E.jsx(sg,{asChild:!0,...a,children:E.jsx(xA.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...t,ref:w,onPointerMove:pA(A.onPointerMove,h=>{h.pointerType!=="touch"&&!c.current&&!g.isPointerInTransitRef.current&&(o.onTriggerEnter(),c.current=!0)}),onPointerLeave:pA(A.onPointerLeave,()=>{o.onTriggerLeave(),c.current=!1}),onPointerDown:pA(A.onPointerDown,()=>{o.open&&o.onClose(),B.current=!0,document.addEventListener("pointerup",C,{once:!0})}),onFocus:pA(A.onFocus,()=>{B.current||o.onOpen()}),onBlur:pA(A.onBlur,o.onClose),onClick:pA(A.onClick,o.onClose)})})});hE.displayName=ql;var Vl="TooltipPortal",[tx,sx]=Dg(Vl,{forceMount:void 0}),mE=A=>{const{__scopeTooltip:q,forceMount:V,children:t,container:o}=A,g=Fo(Vl,q);return E.jsx(tx,{scope:q,forceMount:V,children:E.jsx(ae,{present:V||g.open,children:E.jsx(Mo,{asChild:!0,container:o,children:t})})})};mE.displayName=Vl;var Ys="TooltipContent",FE=n.forwardRef((A,q)=>{const V=sx(Ys,A.__scopeTooltip),{forceMount:t=V.forceMount,side:o="top",...g}=A,a=Fo(Ys,A.__scopeTooltip);return E.jsx(ae,{present:t||a.open,children:a.disableHoverableContent?E.jsx(DE,{side:o,...g,ref:q}):E.jsx(ox,{side:o,...g,ref:q})})}),ox=n.forwardRef((A,q)=>{const V=Fo(Ys,A.__scopeTooltip),t=Al(Ys,A.__scopeTooltip),o=n.useRef(null),g=zA(q,o),[a,l]=n.useState(null),{trigger:w,onClose:B}=V,c=o.current,{onPointerInTransitChange:C}=t,h=n.useCallback(()=>{l(null),C(!1)},[C]),Q=n.useCallback((D,F)=>{const G=D.currentTarget,I={x:D.clientX,y:D.clientY},p=rx(I,G.getBoundingClientRect()),T=nx(I,p),W=lx(F.getBoundingClientRect()),S=Mx([...T,...W]);l(S),C(!0)},[C]);return n.useEffect(()=>()=>h(),[h]),n.useEffect(()=>{if(w&&c){const D=G=>Q(G,c),F=G=>Q(G,w);return w.addEventListener("pointerleave",D),c.addEventListener("pointerleave",F),()=>{w.removeEventListener("pointerleave",D),c.removeEventListener("pointerleave",F)}}},[w,c,Q,h]),n.useEffect(()=>{if(a){const D=F=>{const G=F.target,I={x:F.clientX,y:F.clientY},p=w?.contains(G)||c?.contains(G),T=!wx(I,a);p?h():T&&(h(),B())};return document.addEventListener("pointermove",D),()=>document.removeEventListener("pointermove",D)}},[w,c,a,B,h]),E.jsx(DE,{...A,ref:g})}),[ix,gx]=Dg(mo,{isInside:!1}),ax=ru("TooltipContent"),DE=n.forwardRef((A,q)=>{const{__scopeTooltip:V,children:t,"aria-label":o,onEscapeKeyDown:g,onPointerDownOutside:a,...l}=A,w=Fo(Ys,V),B=Gg(V),{onClose:c}=w;return n.useEffect(()=>(document.addEventListener($n,c),()=>document.removeEventListener($n,c)),[c]),n.useEffect(()=>{if(w.trigger){const C=h=>{h.target?.contains(w.trigger)&&c()};return window.addEventListener("scroll",C,{capture:!0}),()=>window.removeEventListener("scroll",C,{capture:!0})}},[w.trigger,c]),E.jsx(ro,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:g,onPointerDownOutside:a,onFocusOutside:C=>C.preventDefault(),onDismiss:c,children:E.jsxs(Kn,{"data-state":w.stateAttribute,...B,...l,ref:q,style:{...l.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[E.jsx(ax,{children:t}),E.jsx(ix,{scope:V,isInside:!0,children:E.jsx(nK,{id:w.contentId,role:"tooltip",children:o||t})})]})})});FE.displayName=Ys;var GE="TooltipArrow",QE=n.forwardRef((A,q)=>{const{__scopeTooltip:V,...t}=A,o=Gg(V);return gx(GE,V).isInside?null:E.jsx(Tn,{...o,...t,ref:q})});QE.displayName=GE;function rx(A,q){const V=Math.abs(q.top-A.y),t=Math.abs(q.bottom-A.y),o=Math.abs(q.right-A.x),g=Math.abs(q.left-A.x);switch(Math.min(V,t,o,g)){case g:return"left";case o:return"right";case V:return"top";case t:return"bottom";default:throw new Error("unreachable")}}function nx(A,q,V=5){const t=[];switch(q){case"top":t.push({x:A.x-V,y:A.y+V},{x:A.x+V,y:A.y+V});break;case"bottom":t.push({x:A.x-V,y:A.y-V},{x:A.x+V,y:A.y-V});break;case"left":t.push({x:A.x+V,y:A.y-V},{x:A.x+V,y:A.y+V});break;case"right":t.push({x:A.x-V,y:A.y-V},{x:A.x-V,y:A.y+V});break}return t}function lx(A){const{top:q,right:V,bottom:t,left:o}=A;return[{x:o,y:q},{x:V,y:q},{x:V,y:t},{x:o,y:t}]}function wx(A,q){const{x:V,y:t}=A;let o=!1;for(let g=0,a=q.length-1;g<q.length;a=g++){const l=q[g],w=q[a],B=l.x,c=l.y,C=w.x,h=w.y;c>t!=h>t&&V<(C-B)*(t-c)/(h-c)+B&&(o=!o)}return o}function Mx(A){const q=A.slice();return q.sort((V,t)=>V.x<t.x?-1:V.x>t.x?1:V.y<t.y?-1:V.y>t.y?1:0),Bx(q)}function Bx(A){if(A.length<=1)return A.slice();const q=[];for(let t=0;t<A.length;t++){const o=A[t];for(;q.length>=2;){const g=q[q.length-1],a=q[q.length-2];if((g.x-a.x)*(o.y-a.y)>=(g.y-a.y)*(o.x-a.x))q.pop();else break}q.push(o)}q.pop();const V=[];for(let t=A.length-1;t>=0;t--){const o=A[t];for(;V.length>=2;){const g=V[V.length-1],a=V[V.length-2];if((g.x-a.x)*(o.y-a.y)>=(g.y-a.y)*(o.x-a.x))V.pop();else break}V.push(o)}return V.pop(),q.length===1&&V.length===1&&q[0].x===V[0].x&&q[0].y===V[0].y?q:q.concat(V)}var Yx=cE,Cx=EE,cx=hE,Ex=mE,hx=FE,mx=QE;function Fx({delayDuration:A=0,...q}){return E.jsx(Yx,{"data-slot":"tooltip-provider",delayDuration:A,...q})}function el({...A}){return E.jsx(Fx,{children:E.jsx(Cx,{"data-slot":"tooltip",...A})})}function tl({...A}){return E.jsx(cx,{"data-slot":"tooltip-trigger",...A})}function sl({className:A,sideOffset:q=0,children:V,container:t,...o}){return E.jsx(Ex,{container:t,children:E.jsxs(hx,{"data-slot":"tooltip-content",sideOffset:q,className:OA("wv:bg-primary wv:text-primary-foreground wv:animate-in wv:fade-in-0 wv:zoom-in-95 wv:data-[state=closed]:animate-out wv:data-[state=closed]:fade-out-0 wv:data-[state=closed]:zoom-out-95 wv:data-[side=bottom]:slide-in-from-top-2 wv:data-[side=left]:slide-in-from-right-2 wv:data-[side=right]:slide-in-from-left-2 wv:data-[side=top]:slide-in-from-bottom-2 wv:z-50 wv:w-fit wv:origin-(--radix-tooltip-content-transform-origin) wv:rounded-md wv:px-3 wv:py-1.5 wv:text-xs wv:text-balance",A),...o,children:[V,E.jsx(mx,{className:"wv:bg-primary wv:fill-primary wv:z-50 wv:size-2.5 wv:translate-y-[calc(-50%_-_2px)] wv:rotate-45 wv:rounded-[2px]"})]})})}function Dx({device:A,setShowQRCode:q}){const{removeDevice:V,disableDevice:t,enableDevice:o}=Ze(),[g,a]=n.useState(!1);return E.jsxs("div",{"data-enable":A.enable,className:"wv:relative wv:flex wv:justify-between wv:items-center wv:gap-2 wv:p-4 wv:bg-muted wv:data-[enable=false]:bg-muted-foreground/30 wv:rounded-md wv:overflow-hidden",children:[E.jsxs("div",{className:"wv:flex wv:flex-col wv:gap-1",children:[A.status&&E.jsxs(E.Fragment,{children:[["disconnected","hibernating"].includes(A.status)&&E.jsxs(el,{children:[E.jsxs(tl,{children:[E.jsx(Vq,{variant:"outline",className:"wv:size-fit !wv:p-0.5 wv:aspect-square wv:hover:cursor-pointer",onClick:()=>A.wakeUp(),children:E.jsx(XB,{})}),E.jsxs("div",{className:"wv:flex wv:flex-row wv:gap-1 wv:items-center",children:[E.jsx(As,{size:18,color:"red"}),E.jsx("p",{"data-enable":A.enable,className:"wv:font-medium wv:text-foreground",children:A.contact.unofficial?.phone})]})]}),E.jsx(sl,{children:E.jsx("p",{children:"Ligar Dispositivo"})})]}),(["connecting"].includes(A.status)||A.qrcode)&&E.jsxs("div",{className:"wv:flex wv:flex-row wv:gap-1 wv:items-center",children:[E.jsx(kr,{size:18}),E.jsx("p",{"data-enable":A.enable,className:"wv:font-medium wv:text-foreground",children:"Aguardando vincular Whatsapp"})]}),["close"].includes(A.status)&&E.jsxs("div",{className:"wv:flex wv:flex-row wv:gap-1 wv:items-center",children:[E.jsx(Sr,{size:18,color:"red"}),E.jsx("p",{"data-enable":A.enable,className:"wv:font-medium wv:data-[enable=false]:text-muted-foreground",children:"Desconectado"})]}),["error"].includes(A.status)&&E.jsxs("div",{className:"wv:flex wv:flex-row wv:gap-1 wv:items-center",children:[E.jsx(Sr,{size:18,color:"red"}),E.jsx("p",{"data-enable":A.enable,className:"wv:font-medium wv:data-[enable=false]:text-muted-foreground",children:"Falha"})]}),["open","UP"].includes(A.status)&&E.jsxs("div",{className:"wv:flex wv:flex-row wv:gap-1 wv:items-center",children:[E.jsx(As,{size:18,color:"green"}),E.jsx("p",{"data-enable":A.enable,className:"wv:font-medium wv:text-foreground",children:A.contact.unofficial?.phone})]})]}),E.jsx("p",{"data-enable":A.enable,className:"wv:text-[12px] wv:text-foreground",children:A.token})]}),E.jsxs("div",{className:"wv:flex wv:gap-2 wv:items-center",children:[E.jsx(XU,{className:"wv:hover:cursor-pointer",checked:A.enable,onCheckedChange:l=>l?o(A.token):t(A.token),disabled:!["open","CONNECTED"].includes(A.status)}),A.qrcode&&E.jsxs(el,{children:[E.jsx(tl,{asChild:!0,children:E.jsx(Vq,{variant:"ghost",className:"wv:size-fit !wv:p-1.5 wv:aspect-square wv:hover:cursor-pointer wv:bg-red",onClick:()=>q(A.qrcode),children:E.jsx(kr,{className:"size-6"})})}),E.jsx(sl,{children:E.jsx("p",{children:"Mostrar QRCode"})})]}),E.jsx(Vq,{variant:"destructive",className:"wv:size-fit !wv:p-1.5 wv:aspect-square wv:hover:cursor-pointer",onClick:()=>{a(!0)},children:E.jsx(oY,{})})]}),g&&E.jsx("div",{className:"wv:absolute wv:flex wv:bg-[#ef4444] wv:w-full wv:h-full wv:left-0 wv:border wv:border-[white] wv:rounded-md wv:items-center wv:p-4",children:E.jsxs("div",{className:"wv:flex wv:flex-row wv:gap-1 wv:w-full wv:justify-between",children:[E.jsx("div",{className:"wv:flex wv:flex-row wv:gap-1 wv:items-center",children:E.jsx("p",{"data-enable":A.enable,className:"wv:font-medium wv:text-[white] wv:select-none",children:"Deseja excluir esse dispositivo?"})}),E.jsxs("div",{className:"wv:flex wv:flex-row wv:gap-2",children:[E.jsx(Vq,{variant:"outline",size:"icon","aria-label":"Submit",className:"wv:bg-[transparent] wv:p-2 wv:px-[35px] wv:text-[white] wv:cursor-pointer wv:select-none",onClick:()=>{V(A.token)},children:"Excluir"}),E.jsx(Vq,{variant:"outline",className:"wv:bg-[transparent] wv:p-2 wv:px-[10px] wv:text-[white] wv:cursor-pointer wv:select-none",onClick:()=>{a(!1)},children:"Cancelar"})]})]})})]})}var Qg="Dialog",[IE,RS]=fV(Qg),[Gx,IV]=IE(Qg),uE=A=>{const{__scopeDialog:q,children:V,open:t,defaultOpen:o,onOpenChange:g,modal:a=!0}=A,l=n.useRef(null),w=n.useRef(null),[B,c]=We({prop:t,defaultProp:o??!1,onChange:g,caller:Qg});return E.jsx(Gx,{scope:q,triggerRef:l,contentRef:w,contentId:JV(),titleId:JV(),descriptionId:JV(),open:B,onOpenChange:c,onOpenToggle:n.useCallback(()=>c(C=>!C),[c]),modal:a,children:V})};uE.displayName=Qg;var pE="DialogTrigger",KE=n.forwardRef((A,q)=>{const{__scopeDialog:V,...t}=A,o=IV(pE,V),g=zA(q,o.triggerRef);return E.jsx(xA.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":gl(o.open),...t,ref:g,onClick:pA(A.onClick,o.onOpenToggle)})});KE.displayName=pE;var ol="DialogPortal",[Qx,TE]=IE(ol,{forceMount:void 0}),UE=A=>{const{__scopeDialog:q,forceMount:V,children:t,container:o}=A,g=IV(ol,q);return E.jsx(Qx,{scope:q,forceMount:V,children:n.Children.map(t,a=>E.jsx(ae,{present:V||g.open,children:E.jsx(Mo,{asChild:!0,container:o,children:a})}))})};UE.displayName=ol;var Ig="DialogOverlay",xE=n.forwardRef((A,q)=>{const V=TE(Ig,A.__scopeDialog),{forceMount:t=V.forceMount,...o}=A,g=IV(Ig,A.__scopeDialog);return g.modal?E.jsx(ae,{present:t||g.open,children:E.jsx(ux,{...o,ref:q})}):null});xE.displayName=Ig;var Ix=mt("DialogOverlay.RemoveScroll"),ux=n.forwardRef((A,q)=>{const{__scopeDialog:V,...t}=A,o=IV(Ig,V);return E.jsx(wg,{as:Ix,allowPinchZoom:!0,shards:[o.contentRef],children:E.jsx(xA.div,{"data-state":gl(o.open),...t,ref:q,style:{pointerEvents:"auto",...t.style}})})}),It="DialogContent",dE=n.forwardRef((A,q)=>{const V=TE(It,A.__scopeDialog),{forceMount:t=V.forceMount,...o}=A,g=IV(It,A.__scopeDialog);return E.jsx(ae,{present:t||g.open,children:g.modal?E.jsx(px,{...o,ref:q}):E.jsx(Kx,{...o,ref:q})})});dE.displayName=It;var px=n.forwardRef((A,q)=>{const V=IV(It,A.__scopeDialog),t=n.useRef(null),o=zA(q,V.contentRef,t);return n.useEffect(()=>{const g=t.current;if(g)return xn(g)},[]),E.jsx(LE,{...A,ref:o,trapFocus:V.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:pA(A.onCloseAutoFocus,g=>{g.preventDefault(),V.triggerRef.current?.focus()}),onPointerDownOutside:pA(A.onPointerDownOutside,g=>{const a=g.detail.originalEvent,l=a.button===0&&a.ctrlKey===!0;(a.button===2||l)&&g.preventDefault()}),onFocusOutside:pA(A.onFocusOutside,g=>g.preventDefault())})}),Kx=n.forwardRef((A,q)=>{const V=IV(It,A.__scopeDialog),t=n.useRef(!1),o=n.useRef(!1);return E.jsx(LE,{...A,ref:q,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:g=>{A.onCloseAutoFocus?.(g),g.defaultPrevented||(t.current||V.triggerRef.current?.focus(),g.preventDefault()),t.current=!1,o.current=!1},onInteractOutside:g=>{A.onInteractOutside?.(g),g.defaultPrevented||(t.current=!0,g.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const a=g.target;V.triggerRef.current?.contains(a)&&g.preventDefault(),g.detail.originalEvent.type==="focusin"&&o.current&&g.preventDefault()}})}),LE=n.forwardRef((A,q)=>{const{__scopeDialog:V,trapFocus:t,onOpenAutoFocus:o,onCloseAutoFocus:g,...a}=A,l=IV(It,V),w=n.useRef(null),B=zA(q,w);return ln(),E.jsxs(E.Fragment,{children:[E.jsx(vi,{asChild:!0,loop:!0,trapped:t,onMountAutoFocus:o,onUnmountAutoFocus:g,children:E.jsx(ro,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":gl(l.open),...a,ref:B,onDismiss:()=>l.onOpenChange(!1)})}),E.jsxs(E.Fragment,{children:[E.jsx(Tx,{titleId:l.titleId}),E.jsx(xx,{contentRef:w,descriptionId:l.descriptionId})]})]})}),il="DialogTitle",WE=n.forwardRef((A,q)=>{const{__scopeDialog:V,...t}=A,o=IV(il,V);return E.jsx(xA.h2,{id:o.titleId,...t,ref:q})});WE.displayName=il;var yE="DialogDescription",RE=n.forwardRef((A,q)=>{const{__scopeDialog:V,...t}=A,o=IV(yE,V);return E.jsx(xA.p,{id:o.descriptionId,...t,ref:q})});RE.displayName=yE;var ZE="DialogClose",SE=n.forwardRef((A,q)=>{const{__scopeDialog:V,...t}=A,o=IV(ZE,V);return E.jsx(xA.button,{type:"button",...t,ref:q,onClick:pA(A.onClick,()=>o.onOpenChange(!1))})});SE.displayName=ZE;function gl(A){return A?"open":"closed"}var kE="DialogTitleWarning",[ZS,NE]=Fu(kE,{contentName:It,titleName:il,docsSlug:"dialog"}),Tx=({titleId:A})=>{const q=NE(kE),V=`\`${q.contentName}\` requires a \`${q.titleName}\` for the component to be accessible for screen reader users.
144
144
 
145
145
  If you want to hide the \`${q.titleName}\`, you can wrap it with our VisuallyHidden component.
146
146
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wavoip/wavoip-webphone",
3
- "version": "1.1.8",
3
+ "version": "1.1.9",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "files": [