1import{r,j as s}from"./ui-CPW3-RCR.js";import{a0 as _,l as M,m as P,o as U,aI as $,B as R,u as B,a as z,d as u,bV as H,bW as V,y as k,S as W,bX as F,I as K,L as X,bY as Y}from"./index-BraPXa8T.js";import"./supabase-B2z4OhLQ.js";import"./charts-DCB9_QAo.js";import"./vendor-CIXof4MH.js";/** 2 * @license lucide-react v0.462.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const G=_("PhoneOff",[["path",{d:"M10.68 13.31a16 16 0 0 0 3.41 2.6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7 2 2 0 0 1 1.72 2v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.42 19.42 0 0 1-3.33-2.67m-2.67-3.34a19.79 19.79 0 0 1-3.07-8.63A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91",key:"z86iuo"}],["line",{x1:"22",x2:"2",y1:"2",y2:"22",key:"11kh81"}]]),J={idle:"××ת××",connecting:"×ת××ר...",connected:"××××ר",failed:"×××××ר × ××©× - ××ת×× ×©×רשת ××ס×ת ××××ר ×ש×ר",ended:"× ×תק"};function Q({open:t,clientName:b,state:p,stream:m,onDisconnect:x}){const c=r.useRef(null);return r.useEffect(()=>{const i=c.current;if(i)return i.srcObject=m,m&&i.play().catch(()=>{}),()=>{i.srcObject=null}},[m]),s.jsx(M,{open:t,onOpenChange:i=>{i||x()},children:s.jsxs(P,{className:"max-w-[95vw] w-[95vw] h-[90vh] p-0 gap-0 flex flex-col overflow-hidden",children:[s.jsxs("div",{className:"flex items-center justify-between gap-3 border-b px-4 py-2 shrink-0",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs(U,{className:"text-sm truncate",children:["ש×ת××£ ××¡× - ",b]}),s.jsx($,{className:"text-[11px]",children:J[p]})]}),s.jsxs(R,{size:"sm",variant:"destructive",className:"gap-1 shrink-0",onClick:x,children:[s.jsx(G,{className:"w-4 h-4","aria-hidden":!0}),"× ×ת××§"]})]}),s.jsx("video",{ref:c,autoPlay:!0,playsInline:!0,controls:!0,muted:!0,className:"w-full h-full bg-black object-contain"})]})})}function ae(){const{user:t,clearanceLevel:b}=B(),{clients:p,loading:m}=z(),x=b<=3,[c,i]=r.useState(""),[S,I]=r.useState(null),[g,N]=r.useState(null),f=r.useRef(null),h=r.useCallback(()=>{f.current&&(window.clearTimeout(f.current.timer),f.current=null),I(null)},[]),A=r.useCallback(e=>{const n=f.current;!n||n.requestId!==e.requestId||(h(),e.status==="approved"?(u.success(`${e.byName} ××שר ×ת ×××××ר`),N({requestId:e.requestId,clientUserId:e.byUserId,clientName:e.byName})):e.status==="declined"?u.error(`${e.byName} ××× ×ת ×קשת ×××××ר`):u.warning("×××§×©× ×¤×× - ×××§×× ×× ×××× ××××"))},[h]),j=r.useRef(null),w=r.useRef(null),{presence:C,sendRequest:E,sendSignal:L,sendSessionEnded:q}=H({onResponse:A,onSignal:e=>{var n;return(n=j.current)==null?void 0:n.call(j,e)},onSessionEnded:e=>{var n;return(n=w.current)==null?void 0:n.call(w,e)},enabled:x}),l=V({role:"viewer",selfId:t==null?void 0:t.id,sendSignal:L,sendSessionEnded:q,onEnded:()=>N(null)});j.current=e=>{if(e.type==="offer"){l.acceptOffer(e.requestId,e.senderId,e.data);return}l.handleSignal(e)},w.current=()=>{l.stop(null),N(null),u.info("×××§×× ×¡××× ×ת ש×ת××£ ××ס×")};const D=r.useCallback(()=>{l.stop("agent-disconnect"),N(null)},[l]);r.useEffect(()=>()=>h(),[h]);const O=r.useMemo(()=>{const e=new Map;for(const n of C){if(!n||n.user_id===(t==null?void 0:t.id))continue;const a=Number(n.clearance_level);if(!Number.isFinite(a)||a<5)continue;const o=n.client_ids,v=Array.isArray(o)?o:typeof o=="string"&&o?[o]:[];for(const d of v)d&&!e.has(d)&&e.set(d,{name:n.display_name,ip:n.ip||"-"})}return e},[C,t==null?void 0:t.id]),y=r.useMemo(()=>{const e=c.trim().toLowerCase(),n=(p||[]).filter(a=>a&&!a.is_archived);return e?n.filter(a=>(a.name||"").toLowerCase().includes(e)||(a.slug||"").toLowerCase().includes(e)):n},[p,c]),T=(e,n)=>{var d;if(!t)return;const a=crypto.randomUUID();if(!E({requestId:a,agentUserId:t.id,agentName:((d=t.email)==null?void 0:d.split("@")[0])||"× ×¦××",targetClientId:e,sentAt:new Date().toISOString()})){u.error("×××××ר ×××× ××ת ×× ×××× ×ר××¢ - × ×¡× ×©××");return}I(e);const v=window.setTimeout(()=>{h(),u.warning(`××× ×ª×××× ×-${n} - ×××§×©× ×¤××`)},Y+2e3);f.current={requestId:a,timer:v}};return x?s.jsxs("div",{className:"max-w-5xl mx-auto p-4 md:p-6 space-y-4",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(F,{className:"w-5 h-5 text-primary"}),s.jsx("h1",{className:"text-xl font-semibold",children:"××××ר ×ר×××§ ×××§××"})]}),s.jsx(K,{value:c,onChange:e=>i(e.target.value),placeholder:"××פ×ש ××§××","aria-label":"××פ×ש ××§××",className:"max-w-xs"}),m?s.jsx("p",{className:"text-sm text-muted-foreground",children:"×××¢× ××§×××ת..."}):s.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[y.map(e=>{const n=O.get(e.id),a=S===e.id;return s.jsxs(k,{className:"p-3 flex items-center gap-3",children:[s.jsx("span",{className:`w-2.5 h-2.5 rounded-full shrink-0 ${n?"bg-green-500":"bg-red-500"}`,"aria-label":n?"××××ר":"×× ××××ר"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"text-sm font-medium truncate",children:e.name}),s.jsx("p",{className:"text-[11px] text-muted-foreground truncate",children:n?`${n.name} - ${n.ip}`:"×× ××××ר - IP ×× ××××"})]}),s.jsx(R,{size:"sm",disabled:!n||a||S!==null,onClick:()=>T(e.id,e.name),className:"shrink-0",children:a?s.jsx(X,{className:"w-4 h-4 animate-spin"}):"×ת××ר"})]},e.id)}),y.length===0&&s.jsx("p",{className:"text-sm text-muted-foreground",children:"×× × ×צ×× ××§×××ת"})]}),s.jsx(Q,{open:!!g,clientName:(g==null?void 0:g.clientName)||"",state:l.state,stream
6:l.remoteStream,onDisconnect:D})]}):s.jsx("div",{className:"max-w-2xl mx-auto p-6",children:s.jsxs(k,{className:"p-8 text-center space-y-3",children:[s.jsx(W,{className:"w-10 h-10 mx-auto text-primary"}),s.jsx("h1",{className:"text-xl font-semibold",children:"ת×××× ×ר×××§"}),s.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:"צ××ת ××ר××× ×××× ××קש ××ת××ר ×××¡× ×©×× ××× ××¢××ר. ×××§×©× ×ª××¦× ×× ××××× ××ש×ר - ×××××ר ×ת×צע רק ×××ר ××ש×ר ×פ×רש ש××, ×× ××ª× ×××× ×××ª× ××× ×¨××¢."})]})})}export{ae as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.