interview-widget 3.2.20 → 3.2.21
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.
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
(function(ve,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("react/jsx-runtime"),require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","react-dom"],o):(ve=typeof globalThis<"u"?globalThis:ve||self,o(ve.InterviewWidget={},ve.jsxRuntime,ve.React,ve.ReactDOM))})(this,function(ve,o,d,Tl){"use strict";var f2=Object.defineProperty;var w2=(ve,o,d)=>o in ve?f2(ve,o,{enumerable:!0,configurable:!0,writable:!0,value:d}):ve[o]=d;var we=(ve,o,d)=>w2(ve,typeof o!="symbol"?o+"":o,d);var wn=typeof document<"u"?document.currentScript:null;const gn={},Re={api:{baseUrl:"/api",retryConfig:{attempts:3,backoff:"exponential",baseDelay:1e3}},ui:{baseColor:"#3B82F6",borderRadius:"8px"},interview:{allow_answer_editing:!0,capture_screenshots:!1,timers:{thinkingDuration:30,answeringDuration:120,editingDuration:30},stt:{provider:"groq",model:"whisper-large-v3-turbo",language:"en"},tts:{provider:"piper"},proctoring:{enabled:!0,gazeAnalysisEnabled:!0,prevent_unintended_exit:!1}}},pn="iw-storage";function Nl(){if(!(typeof{url:typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:wn&&wn.tagName.toUpperCase()==="SCRIPT"&&wn.src||new URL("widget.umd.3.2.20.js",document.baseURI).href}<"u"&&(gn!=null&&gn.VITE_IW_SECRET)))return typeof process<"u"&&process.env.NEXT_PUBLIC_IW_SECRET?process.env.NEXT_PUBLIC_IW_SECRET:typeof window<"u"&&window.__IW_SECRET__?window.__IW_SECRET__:"proctoring-data-seed"}const Zs=Nl(),yi=30,Il={SCREENSHOT:"screenshot"},mn="AES-GCM",yn=12;async function Rs(e){const r=new TextEncoder().encode(e),i=await crypto.subtle.digest("SHA-256",r);return crypto.subtle.importKey("raw",i,mn,!1,["encrypt","decrypt"])}function Fl(){return crypto.getRandomValues(new Uint8Array(yn))}async function Ll(e,t="default-seed"){try{const r=typeof e=="string"?e:JSON.stringify(e),n=new TextEncoder().encode(r),s=await Rs(t),a=Fl(),c=await crypto.subtle.encrypt({name:mn,iv:a},s,n),l=new Uint8Array(a.length+c.byteLength);return l.set(new Uint8Array(a),0),l.set(new Uint8Array(c),a.length),btoa(String.fromCharCode(...Array.from(l)))}catch(r){throw console.error("Encryption failed:",r),new Error("Failed to encrypt data")}}async function Ml(e,t="default-seed"){try{const r=atob(e),i=new Uint8Array(r.length);for(let h=0;h<r.length;h++)i[h]=r.charCodeAt(h);const n=i.slice(0,yn),s=i.slice(yn),a=await Rs(t),c=await crypto.subtle.decrypt({name:mn,iv:n},a,s);return new TextDecoder().decode(c)}catch(r){throw console.error("Decryption failed:",r),new Error("Failed to decrypt data")}}async function Dl(e,t="default-seed"){return Ll(e,t)}async function Pl(e,t="default-seed"){const r=await Ml(e,t);try{return JSON.parse(r)}catch{return r}}const Ur=d.createContext(null),Ol=async()=>{try{const e=sessionStorage.getItem(pn);if(e){const r=(await Pl(e,Zs)).state;return{logViolations:(r==null?void 0:r.logViolations)||[],totalViolations:(r==null?void 0:r.totalViolations)||0,gazeViolationCounters:(r==null?void 0:r.gazeViolationCounters)||{lookingAwayCount:0,noFaceDetectedCount:0,multipleFacesCount:0,totalGazeViolations:0},referenceSet:(r==null?void 0:r.referenceSet)??!1,referenceRef:(r==null?void 0:r.referenceRef)??{x:.5,y:.5,noseX:.5,noseY:.5}}}}catch(e){console.error("Failed to load proctoring data from session storage:",e)}return{logViolations:[],totalViolations:0,gazeViolationCounters:{lookingAwayCount:0,noFaceDetectedCount:0,multipleFacesCount:0,totalGazeViolations:0},referenceSet:!1,referenceRef:{x:.5,y:.5,noseX:.5,noseY:.5}}},Vr=async e=>{try{const t=await Dl({state:e,version:0},Zs);sessionStorage.setItem(pn,t)}catch(t){console.error("Failed to save proctoring data to session storage:",t)}},Bl=({children:e})=>{const t=d.useRef({logViolations:[],totalViolations:0,gazeViolationCounters:{lookingAwayCount:0,noFaceDetectedCount:0,multipleFacesCount:0,totalGazeViolations:0},referenceSet:!1,referenceRef:{x:.5,y:.5,noseX:.5,noseY:.5}}),r=d.useRef(new Set);d.useEffect(()=>{Ol().then(w=>{t.current=w,i()})},[]);const i=d.useCallback(()=>{r.current.forEach(w=>w())},[]),n=d.useCallback(w=>(r.current.add(w),()=>{r.current.delete(w)}),[]),s=d.useCallback(()=>t.current,[]),a=d.useCallback(w=>{t.current={...t.current,logViolations:[...t.current.logViolations,w],totalViolations:t.current.totalViolations+1},Vr(t.current),i()},[i]),c=d.useCallback(w=>{const g={...t.current.gazeViolationCounters};w==="looking_away"&&(g.lookingAwayCount+=1),w==="no_face_detected"&&(g.noFaceDetectedCount+=1),w==="multiple_faces"&&(g.multipleFacesCount+=1),g.totalGazeViolations=g.lookingAwayCount+g.noFaceDetectedCount+g.multipleFacesCount,t.current={...t.current,gazeViolationCounters:g},Vr(t.current),i()},[i]),l=d.useCallback(()=>{t.current={...t.current,logViolations:[],totalViolations:0},Vr(t.current),i()},[i]),h=d.useCallback(()=>{t.current={...t.current,gazeViolationCounters:{lookingAwayCount:0,noFaceDetectedCount:0,multipleFacesCount:0,totalGazeViolations:0}},Vr(t.current),i()},[i]),u=d.useCallback((w,g)=>{t.current={...t.current,referenceSet:w,referenceRef:g},Vr(t.current),i()},[i]),f=d.useMemo(()=>({getState:s,addViolation:a,clearViolations:l,subscribe:n,incrementGazeViolation:c,clearGazeViolationCounters:h,setReferenceData:u}),[s,a,l,n,c,h,u]);return o.jsx(Ur.Provider,{value:f,children:e})},eo=()=>{const e=d.useContext(Ur);if(!e)throw new Error("useProctoringStore must be used within a ProctoringProvider");const t=d.useSyncExternalStore(e.subscribe,e.getState,e.getState);return{logViolations:t.logViolations,totalViolations:t.totalViolations,addViolation:e.addViolation,clearViolations:e.clearViolations,gazeViolationCounters:t.gazeViolationCounters,referenceSet:t.referenceSet,referenceRef:t.referenceRef,incrementGazeViolation:e.incrementGazeViolation,clearGazeViolationCounters:e.clearGazeViolationCounters,setReferenceData:e.setReferenceData}},Ul=()=>{const e=d.useContext(Ur);if(!e)throw new Error("useViolations must be used within a ProctoringProvider");return d.useSyncExternalStore(e.subscribe,()=>e.getState().logViolations,()=>e.getState().logViolations)},Vl=()=>{const e=d.useContext(Ur);if(!e)throw new Error("useTotalViolations must be used within a ProctoringProvider");return d.useSyncExternalStore(e.subscribe,()=>e.getState().totalViolations,()=>e.getState().totalViolations)},Gl=()=>{const e=d.useContext(Ur);if(!e)throw new Error("useProctoringActions must be used within a ProctoringProvider");return{addViolation:e.addViolation,clearViolations:e.clearViolations}},to=d.createContext(null);function ro({config:e={},children:t}){var i,n,s,a,c;const r={api:{...Re.api,...e.api,retryConfig:{...Re.api.retryConfig,...(i=e.api)==null?void 0:i.retryConfig}},ui:{...Re.ui,...e.ui},interview:{...Re.interview,...e.interview,timers:{...Re.interview.timers,...(n=e.interview)==null?void 0:n.timers},stt:{...Re.interview.stt,...(s=e.interview)==null?void 0:s.stt},tts:{...Re.interview.tts,...(a=e.interview)==null?void 0:a.tts},proctoring:{...Re.interview.proctoring,...(c=e.interview)==null?void 0:c.proctoring}}};return o.jsx(to.Provider,{value:r,children:o.jsx(Bl,{children:t})})}function bi(){const e=d.useContext(to);if(!e)throw new Error("useInterviewConfig must be used within an InterviewWidgetProvider. Wrap your component tree with <InterviewWidgetProvider config={...}>");return e}function io(){return bi().api||Re.api}function Rt(){return bi().ui||Re.ui}function Gr(){return bi().interview||Re.interview}function jl(e){const t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return t?{r:parseInt(t[1],16),g:parseInt(t[2],16),b:parseInt(t[3],16)}:null}function $l(e,t,r){return"#"+[e,t,r].map(i=>{const n=Math.round(i).toString(16);return n.length===1?"0"+n:n}).join("")}function zl(e,t){const r=jl(e);if(!r)return e;const i=r.r+(255-r.r)*t,n=r.g+(255-r.g)*t,s=r.b+(255-r.b)*t;return $l(i,n,s)}function Wl(e){return new Promise(t=>setTimeout(t,e))}function Hl(e){return`linear-gradient(to left, ${zl(e,.4)}, ${e})`}const ql=()=>Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15);function Kl(e){try{const t=e.split(".");if(t.length!==3||!t[1])throw new Error("Invalid JWT token");const i=t[1].replace(/-/g,"+").replace(/_/g,"/"),n=i.padEnd(i.length+(4-i.length%4)%4,"="),s=atob(n);return JSON.parse(s)}catch(t){return console.error("Error decoding JWT:",t),null}}const Yl=e=>{var t;return!e||typeof e!="string"?"":(t=e.charAt(0))==null?void 0:t.toUpperCase()},bn=(e,t)=>{const r=Math.max(0,Math.floor(e));if(t&&r<60)return`${r}`;const i=Math.floor(r/60).toString().padStart(2,"0"),n=(r%60).toString().padStart(2,"0");return`${i}:${n}`},vn=({brandLogo:e,brandName:t,className:r="",showFallbackStyles:i=!0})=>{const{baseColor:n}=Rt();return e?o.jsx("div",{className:r,children:e}):o.jsx("div",{className:i?`iw-h-7 iw-w-7 iw-rounded-md iw-flex iw-items-center iw-justify-center iw-text-white iw-font-semibold ${r}`:r,style:i?{backgroundColor:n}:{},children:Yl(t)})},Xl=e=>{const t=d.useRef(null),r=d.useRef(null),[i,n]=d.useState(!1),[s,a]=d.useState(!1),[c,l]=d.useState(null),[h,u]=d.useState([]),[f,w]=d.useState([]),[g,p]=d.useState(""),[y,b]=d.useState(""),[m,v]=d.useState(!1),k=d.useCallback(()=>{r.current&&(r.current.getTracks().forEach(C=>C.stop()),r.current=null,l(null))},[]),_=d.useCallback(async()=>{var C,x,M,U;try{const V=await navigator.mediaDevices.enumerateDevices(),q=V.filter(O=>O.kind==="audioinput"),D=V.filter(O=>O.kind==="videoinput");if(u(q),w(D),!g&&q.length>0){const O=(C=r.current)==null?void 0:C.getAudioTracks()[0],R=O==null?void 0:O.getSettings().deviceId;p(R||((x=q[0])==null?void 0:x.deviceId)||"")}if(!y&&D.length>0){const O=(M=r.current)==null?void 0:M.getVideoTracks()[0],R=O==null?void 0:O.getSettings().deviceId;b(R||((U=D[0])==null?void 0:U.deviceId)||"")}}catch(V){console.error("Error enumerating devices:",V)}},[g,y]),S=d.useCallback(async(C,x)=>{const M={width:{ideal:1280},height:{ideal:720},...x?{deviceId:{exact:x}}:{facingMode:"user"}},U={echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0,sampleRate:{ideal:16e3},channelCount:{ideal:1},...C?{deviceId:{exact:C}}:{}};let V=null;try{V=await navigator.mediaDevices.getUserMedia({video:M,audio:U}),n(!0),a(!0)}catch(q){console.warn("Combined media request failed, trying individual.",q);try{const D=await navigator.mediaDevices.getUserMedia({audio:U});n(!0),V=D}catch(D){console.error("Audio permission denied",D),n(!1)}try{const D=await navigator.mediaDevices.getUserMedia({video:M});a(!0),V?D.getTracks().forEach(O=>V.addTrack(O)):V=D}catch(D){console.error("Video permission denied",D),a(!1)}}V?(r.current=V,l(V),t.current&&(t.current.srcObject=V,await t.current.play().catch(q=>console.error("Error playing video element",q)))):(r.current=null,l(null)),await _()},[_]),E=async C=>{C!==g&&(v(!0),p(C),k(),await S(C,y),v(!1))},P=async C=>{C!==y&&(v(!0),b(C),k(),await S(g,C),v(!1))};return d.useEffect(()=>{if(!e){k();return}return S(),()=>k()},[e]),{videoRef:t,audioAllowed:i,videoAllowed:s,audioDevices:h,videoDevices:f,selectedAudioDeviceId:g,selectedVideoDeviceId:y,isDeviceLoading:m,currentStream:c,handleAudioChange:E,handleVideoChange:P,stopStream:k}},vi=e=>o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...e,children:[o.jsx("path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"}),o.jsx("path",{d:"M12 9v4"}),o.jsx("path",{d:"M12 17h.01"})]}),Ql=e=>o.jsxs("svg",{width:24,height:24,fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:"prefix__lucide prefix__lucide-bolt-icon prefix__lucide-bolt",...e,children:[o.jsx("path",{d:"M21 16V8a2 2 0 00-1-1.73l-7-4a2 2 0 00-2 0l-7 4A2 2 0 003 8v8a2 2 0 001 1.73l7 4a2 2 0 002 0l7-4A2 2 0 0021 16z"}),o.jsx("circle",{cx:12,cy:12,r:4})]}),Jl=e=>o.jsxs("svg",{width:24,height:24,fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:"prefix__lucide prefix__lucide-camera-off-icon prefix__lucide-camera-off",...e,children:[o.jsx("path",{d:"M14.564 14.558a3 3 0 11-4.122-4.121M2 2l20 20"}),o.jsx("path",{d:"M20 20H4a2 2 0 01-2-2V9a2 2 0 012-2h1.997a2 2 0 00.819-.175M9.695 4.024A2 2 0 0110.004 4h3.993a2 2 0 011.76 1.05l.486.9A2 2 0 0018.003 7H20a2 2 0 012 2v7.344"})]}),xi=e=>o.jsx("svg",{width:"10",height:"9",viewBox:"0 0 10 9",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:o.jsx("path",{d:"M0.75 5.5C0.75 5.5 2.35 6.4125 3.15 7.75C3.15 7.75 5.55 2.5 8.75 0.75",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),Zl=({className:e})=>o.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:e,children:o.jsx("path",{d:"M18 9.00005C18 9.00005 13.5811 15 12 15C10.4188 15 6 9 6 9",stroke:"#062260",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),no=e=>o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...e,children:[o.jsx("path",{d:"M12 2a10 10 0 0 1 7.38 16.75"}),o.jsx("path",{d:"M12 6v6l4 2"}),o.jsx("path",{d:"M2.5 8.875a10 10 0 0 0-.5 3"}),o.jsx("path",{d:"M2.83 16a10 10 0 0 0 2.43 3.4"}),o.jsx("path",{d:"M4.636 5.235a10 10 0 0 1 .891-.857"}),o.jsx("path",{d:"M8.644 21.42a10 10 0 0 0 7.631-.38"})]}),Ei=e=>o.jsx("svg",{className:"iw-w-5 iw-h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",...e,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})}),Rl=e=>o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...e,children:[o.jsx("path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0"}),o.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),ed=e=>o.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:[o.jsx("path",{d:"M2.66797 2H13.3346",stroke:"#5C6686",strokeLinecap:"round",strokeLinejoin:"round"}),o.jsx("path",{d:"M3.66797 2V3.35359C3.66797 4.18151 4.05252 4.96247 4.70874 5.46726L8.0013 8L11.2938 5.46726C11.9501 4.96247 12.3346 4.18151 12.3346 3.35359V2",stroke:"#5C6686",strokeLinecap:"round",strokeLinejoin:"round"}),o.jsx("path",{d:"M3.66797 14V12.6464C3.66797 11.8185 4.05252 11.0375 4.70874 10.5327L8.0013 8L11.2938 10.5327C11.9501 11.0375 12.3346 11.8185 12.3346 12.6464V14",stroke:"#5C6686",strokeLinecap:"round",strokeLinejoin:"round"}),o.jsx("path",{d:"M2.66797 14H13.3346",stroke:"#5C6686",strokeLinecap:"round",strokeLinejoin:"round"})]}),so=({className:e,...t})=>o.jsx("div",{children:o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:`iw-animate-spin ${e}`,...t,children:[o.jsx("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),o.jsx("path",{d:"M12 6l0 -3"}),o.jsx("path",{d:"M16.25 7.75l2.15 -2.15"}),o.jsx("path",{d:"M18 12l3 0"}),o.jsx("path",{d:"M16.25 16.25l2.15 2.15"}),o.jsx("path",{d:"M12 18l0 3"}),o.jsx("path",{d:"M7.75 16.25l-2.15 2.15"}),o.jsx("path",{d:"M6 12l-3 0"}),o.jsx("path",{d:"M7.75 7.75l-2.15 -2.15"})]})}),td=e=>o.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:[o.jsx("path",{d:"M17 7V11C17 13.7614 14.7614 16 12 16C9.23858 16 7 13.7614 7 11V7C7 4.23858 9.23858 2 12 2C14.7614 2 17 4.23858 17 7Z",stroke:"currentColor",strokeWidth:"1.5"}),o.jsx("path",{d:"M20 11C20 15.4183 16.4183 19 12 19M12 19C7.58172 19 4 15.4183 4 11M12 19V22M12 22H15M12 22H9",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),oo=e=>o.jsxs("svg",{width:24,height:24,fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:"prefix__lucide prefix__lucide-target-icon prefix__lucide-target",...e,children:[o.jsx("circle",{cx:12,cy:12,r:10}),o.jsx("circle",{cx:12,cy:12,r:6}),o.jsx("circle",{cx:12,cy:12,r:2})]}),rd=e=>o.jsxs("svg",{width:24,height:24,fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:"prefix__lucide prefix__lucide-users-icon prefix__lucide-users",...e,children:[o.jsx("path",{d:"M16 21v-2a4 4 0 00-4-4H6a4 4 0 00-4 4v2M16 3.128a4 4 0 010 7.744M22 21v-2a4 4 0 00-3-3.87"}),o.jsx("circle",{cx:9,cy:7,r:4})]}),id=e=>o.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:[o.jsx("path",{d:"M11 8H13",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),o.jsx("path",{d:"M2 11C2 7.70017 2 6.05025 3.02513 5.02513C4.05025 4 5.70017 4 9 4H10C13.2998 4 14.9497 4 15.9749 5.02513C17 6.05025 17 7.70017 17 11V13C17 16.2998 17 17.9497 15.9749 18.9749C14.9497 20 13.2998 20 10 20H9C5.70017 20 4.05025 20 3.02513 18.9749C2 17.9497 2 16.2998 2 13V11Z",stroke:"currentColor",strokeWidth:"1.5"}),o.jsx("path",{d:"M17 8.90585L17.1259 8.80196C19.2417 7.05623 20.2996 6.18336 21.1498 6.60482C22 7.02628 22 8.42355 22 11.2181V12.7819C22 15.5765 22 16.9737 21.1498 17.3952C20.2996 17.8166 19.2417 16.9438 17.1259 15.198L17 15.0941",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),nd=e=>o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...e,children:[o.jsx("path",{d:"M8.8 20v-4.1l1.9.2a2.3 2.3 0 0 0 2.164-2.1V8.3A5.37 5.37 0 0 0 2 8.25c0 2.8.656 3.054 1 4.55a5.77 5.77 0 0 1 .029 2.758L2 20"}),o.jsx("path",{d:"M19.8 17.8a7.5 7.5 0 0 0 .003-10.603"}),o.jsx("path",{d:"M17 15a3.5 3.5 0 0 0-.025-4.975"})]}),ke={FACE_DETECTED:"face_detected",NO_FACE:"no_face_detected",MULTIPLE_FACES:"multiple_faces",LOOKING_AWAY:"looking_away",CAMERA_ERROR:"camera_error",MODEL_LOADING:"model_loading"},ao={[ke.FACE_DETECTED]:{icon:Rl,iconColor:"iw-text-green-600",iconBg:"iw-bg-green-50",iconBorder:"iw-border-green-100",title:"All Good",subtitle:"Everything looks normal",description:"Your gaze is properly focused on the screen. Continue with your interview.",buttonText:"Continue"},[ke.NO_FACE]:{icon:Jl,iconColor:"iw-text-orange-600",iconBg:"iw-bg-orange-50",iconBorder:"iw-border-orange-100",title:"Face Not Detected",subtitle:"We can't see you in the camera",description:"Please ensure you're positioned properly in front of the camera and that your face is clearly visible.",buttonText:"I Understood"},[ke.MULTIPLE_FACES]:{icon:rd,iconColor:"iw-text-red-600",iconBg:"iw-bg-red-50",iconBorder:"iw-border-red-100",title:"Multiple People Detected",subtitle:"More than one person is visible on the screen.",buttonText:"I Understood"},[ke.LOOKING_AWAY]:{icon:oo,iconColor:"iw-text-amber-600",iconBg:"iw-bg-amber-50",iconBorder:"iw-border-amber-200/75",title:"Focus Alert",subtitle:"You looked away from the screen. Maintain focus to continue.",buttonText:"I Understood"},[ke.CAMERA_ERROR]:{icon:vi,iconColor:"iw-text-red-600",iconBg:"iw-bg-red-50",iconBorder:"iw-border-red-100",title:"Camera Issue",subtitle:"There's a problem with your camera",description:"Please check your camera connection and permissions, contact support if the problem continues.",buttonText:"I Understood"},[ke.MODEL_LOADING]:{icon:oo,iconColor:"iw-text-blue-600",iconBg:"iw-bg-blue-50",iconBorder:"iw-border-blue-100",title:"Initializing Model",subtitle:"Please wait while we set up the AI",description:"The face detection model is being loaded. This should only take a moment.",buttonText:"Wait"}},sd=({gazeAnalysisEnabled:e,isModelLoaded:t,stats:r,statusMessage:i,loadingProgress:n})=>o.jsx("div",{className:"iw-w-full",children:o.jsxs("div",{className:"iw-border-strock iw-rounded-md iw-border iw-bg-gray-50 iw-p-4",children:[o.jsxs("h3",{className:"iw-m-0 iw-mb-2.5",children:["Status: ",i]}),n>0&&n<100&&o.jsxs("div",{className:"iw-mb-2.5",children:[o.jsx("div",{className:"iw-h-2 iw-w-full iw-rounded iw-bg-gray-300",children:o.jsx("div",{className:"iw-h-full iw-rounded iw-bg-blue-600 iw-transition-all iw-duration-300 iw-ease-out",style:{width:`${n}%`}})}),o.jsxs("small",{className:"iw-text-gray-600",children:["Loading model... ",n.toFixed(1),"%"]})]}),o.jsxs("div",{className:"iw-grid iw-grid-cols-2 iw-gap-2.5 iw-text-sm",children:[o.jsxs("div",{children:[o.jsx("strong",{children:"FPS:"})," ",o.jsx("span",{className:r.fps<15?"iw-text-red-600":r.fps<25?"iw-text-orange-500":"iw-text-green-600",children:r.fps})]}),o.jsxs("div",{children:[o.jsx("strong",{children:"Model:"})," ",t?"✓ Loaded":"✗ Loading"]}),e&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{children:[o.jsx("strong",{children:"Engagement:"})," ",r.engagement.toFixed(1),"%"]}),o.jsxs("div",{children:[o.jsx("strong",{children:"Looking:"})," ",o.jsx("span",{className:r.isLookingAway?"iw-text-red-600":"iw-text-green-600",children:r.isLookingAway?"Away":"At Screen"})]})]})]}),r.referenceFaceNotDetected&&o.jsxs("div",{className:"iw-text-gray-dark iw-mt-2.5 iw-w-full iw-rounded-md iw-bg-[#ffeb3b] iw-p-2.5 iw-text-sm",children:[o.jsx("strong",{children:"Reference Face Not Detected"}),o.jsx("br",{}),"The previously set reference face is no longer in view."]}),r.multipleFacesDetected&&o.jsxs("div",{className:"iw-mt-2.5 iw-rounded iw-bg-red-50 iw-p-2.5 iw-text-sm iw-text-red-700",children:[o.jsx("strong",{children:"Multiple Faces Detected"}),o.jsx("br",{}),"Please ensure only one person is in the frame."]}),!e&&o.jsxs("div",{className:"iw-mt-2.5 iw-rounded iw-bg-blue-50 iw-p-2.5 iw-text-sm iw-text-blue-700",children:[o.jsx("strong",{children:"Gaze Analysis Disabled"}),o.jsx("br",{}),"Enable to track engagement and attention levels."]})]})}),od=({showControls:e,isBubbleOpen:t,setIsBubbleOpen:r,setReference:i,clearCache:n,isModelLoaded:s,gazeAnalysisEnabled:a,referenceSet:c,showLandmarks:l,setShowLandmarks:h,showEngagementBar:u,setShowEngagementBar:f,handleToggleGazeAnalysis:w,stats:g,statusMessage:p,loadingProgress:y})=>e?o.jsxs(o.Fragment,{children:[o.jsx("button",{onClick:()=>r(!t),className:"iw-absolute iw-right-4 iw-bottom-4 iw-z-10 iw-flex iw-h-10 iw-w-10 iw-items-center iw-justify-center iw-rounded-full iw-text-white",children:o.jsx(Ql,{className:"iw-size-4.5"})}),t&&o.jsxs("div",{className:"iw-absolute iw-right-4 iw-bottom-16 iw-z-10 iw-max-h-96 iw-w-80 iw-overflow-y-auto iw-rounded-md iw-bg-gray-50 iw-p-4 iw-shadow-lg",children:[o.jsx("h4",{className:"m-0 mb-2.5",children:"Controls"}),o.jsx("button",{onClick:i,disabled:!s||!a,className:`iw-mb-2.5 iw-block iw-w-full iw-rounded border-none iw-px-4 iw-py-2 iw-text-sm iw-text-white ${!s||!a?"iw-cursor-not-allowed iw-bg-gray-400":"iw-cursor-pointer iw-bg-blue-600 hover:iw-bg-blue-700"}`,children:c?"Reference Set ✓":"Set Reference"}),o.jsx("button",{onClick:n,className:"iw-mb-4 iw-block iw-w-full iw-cursor-pointer iw-rounded iw-border-none iw-bg-red-600 iw-px-4 iw-py-2 iw-text-sm iw-text-white hover:iw-bg-red-700",children:"Clear Model Cache"}),o.jsxs("div",{className:"iw-flex iw-flex-col iw-gap-2.5",children:[o.jsxs("label",{className:"iw-flex iw-cursor-pointer iw-items-center iw-gap-2",children:[o.jsx("input",{type:"checkbox",checked:a,onChange:b=>w(b.target.checked)}),o.jsx("strong",{children:"Enable Gaze Analysis"})]}),o.jsxs("label",{className:`iw-flex iw-cursor-pointer iw-items-center iw-gap-2 ${a?"iw-opacity-100":"iw-opacity-60"}`,children:[o.jsx("input",{type:"checkbox",checked:l,onChange:b=>h(b.target.checked),disabled:!a}),"Show Landmarks"]}),o.jsxs("label",{className:`iw-flex iw-cursor-pointer iw-items-center iw-gap-2 ${a?"iw-opacity-100":"iw-opacity-60"}`,children:[o.jsx("input",{type:"checkbox",checked:u,onChange:b=>f(b.target.checked),disabled:!a}),"Show Engagement Bar"]})]}),c&&o.jsx(sd,{gazeAnalysisEnabled:a,isModelLoaded:s,loadingProgress:y,stats:g,statusMessage:p})]})]}):null;var er=typeof self<"u"?self:{};function jr(e,t){e:{for(var r=["CLOSURE_FLAGS"],i=er,n=0;n<r.length;n++)if((i=i[r[n]])==null){r=null;break e}r=i}return(e=r&&r[e])!=null?e:t}function Pt(){throw Error("Invalid UTF8")}function co(e,t){return t=String.fromCharCode.apply(null,t),e==null?t:e+t}let _i,xn;const ad=typeof TextDecoder<"u";let cd;const ld=typeof TextEncoder<"u";function lo(e){if(ld)e=(cd||(cd=new TextEncoder)).encode(e);else{let r=0;const i=new Uint8Array(3*e.length);for(let n=0;n<e.length;n++){var t=e.charCodeAt(n);if(t<128)i[r++]=t;else{if(t<2048)i[r++]=t>>6|192;else{if(t>=55296&&t<=57343){if(t<=56319&&n<e.length){const s=e.charCodeAt(++n);if(s>=56320&&s<=57343){t=1024*(t-55296)+s-56320+65536,i[r++]=t>>18|240,i[r++]=t>>12&63|128,i[r++]=t>>6&63|128,i[r++]=63&t|128;continue}n--}t=65533}i[r++]=t>>12|224,i[r++]=t>>6&63|128}i[r++]=63&t|128}}e=r===i.length?i:i.subarray(0,r)}return e}function uo(e){er.setTimeout(()=>{throw e},0)}var En,dd=jr(610401301,!1),ho=jr(748402147,!0),_n=jr(824648567,!0),kn=jr(824656860,jr(1,!0));function fo(){var e=er.navigator;return e&&(e=e.userAgent)?e:""}const wo=er.navigator;function ki(e){return ki[" "](e),e}En=wo&&wo.userAgentData||null,ki[" "]=function(){};const go={};let $r=null;function ud(e){const t=e.length;let r=3*t/4;r%3?r=Math.floor(r):"=.".indexOf(e[t-1])!=-1&&(r="=.".indexOf(e[t-2])!=-1?r-2:r-1);const i=new Uint8Array(r);let n=0;return function(s,a){function c(h){for(;l<s.length;){const u=s.charAt(l++),f=$r[u];if(f!=null)return f;if(!/^[\s\xa0]*$/.test(u))throw Error("Unknown base64 encoding at char: "+u)}return h}po();let l=0;for(;;){const h=c(-1),u=c(0),f=c(64),w=c(64);if(w===64&&h===-1)break;a(h<<2|u>>4),f!=64&&(a(u<<4&240|f>>2),w!=64&&a(f<<6&192|w))}}(e,function(s){i[n++]=s}),n!==r?i.subarray(0,n):i}function po(){if(!$r){$r={};var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),t=["+/=","+/","-_=","-_.","-_"];for(let r=0;r<5;r++){const i=e.concat(t[r].split(""));go[r]=i;for(let n=0;n<i.length;n++){const s=i[n];$r[s]===void 0&&($r[s]=n)}}}}var hd=typeof Uint8Array<"u",mo=!(!(dd&&En&&En.brands.length>0)&&(fo().indexOf("Trident")!=-1||fo().indexOf("MSIE")!=-1))&&typeof btoa=="function";const yo=/[-_.]/g,fd={"-":"+",_:"/",".":"="};function wd(e){return fd[e]||""}function bo(e){if(!mo)return ud(e);e=yo.test(e)?e.replace(yo,wd):e,e=atob(e);const t=new Uint8Array(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}function Sn(e){return hd&&e!=null&&e instanceof Uint8Array}var tr={};function Ot(){return gd||(gd=new nt(null,tr))}function An(e){vo(tr);var t=e.g;return(t=t==null||Sn(t)?t:typeof t=="string"?bo(t):null)==null?t:e.g=t}var nt=class{h(){return new Uint8Array(An(this)||0)}constructor(e,t){if(vo(t),this.g=e,e!=null&&e.length===0)throw Error("ByteString should be constructed with non-empty values")}};let gd,pd;function vo(e){if(e!==tr)throw Error("illegal external caller")}function xo(e,t){e.__closure__error__context__984382||(e.__closure__error__context__984382={}),e.__closure__error__context__984382.severity=t}function Cn(e){return xo(e=Error(e),"warning"),e}function rr(e,t){if(e!=null){var r=pd??(pd={}),i=r[e]||0;i>=t||(r[e]=i+1,xo(e=Error(),"incident"),uo(e))}}function ir(){return typeof BigInt=="function"}var nr=typeof Symbol=="function"&&typeof Symbol()=="symbol";function st(e,t,r=!1){return typeof Symbol=="function"&&typeof Symbol()=="symbol"?r&&Symbol.for&&e?Symbol.for(e):e!=null?Symbol(e):Symbol():t}var md=st("jas",void 0,!0),Eo=st(void 0,"0di"),zr=st(void 0,"1oa"),Fe=st(void 0,Symbol()),yd=st(void 0,"0ub"),bd=st(void 0,"0ubs"),Tn=st(void 0,"0ubsb"),vd=st(void 0,"0actk"),sr=st("m_m","Pa",!0),_o=st();const ko={Ga:{value:0,configurable:!0,writable:!0,enumerable:!1}},So=Object.defineProperties,T=nr?md:"Ga";var Bt;const Ao=[];function Wr(e,t){nr||T in e||So(e,ko),e[T]|=t}function ue(e,t){nr||T in e||So(e,ko),e[T]=t}function Hr(e){return Wr(e,34),e}function qr(e){return Wr(e,8192),e}ue(Ao,7),Bt=Object.freeze(Ao);var or={};function Le(e,t){return t===void 0?e.h!==Ut&&!!(2&(0|e.v[T])):!!(2&t)&&e.h!==Ut}const Ut={};function Nn(e,t){if(e!=null){if(typeof e=="string")e=e?new nt(e,tr):Ot();else if(e.constructor!==nt)if(Sn(e))e=e.length?new nt(new Uint8Array(e),tr):Ot();else{if(!t)throw Error();e=void 0}}return e}class Co{constructor(t,r,i){this.g=t,this.h=r,this.l=i}next(){const t=this.g.next();return t.done||(t.value=this.h.call(this.l,t.value)),t}[Symbol.iterator](){return this}}var xd=Object.freeze({});function To(e,t,r){const i=128&t?0:-1,n=e.length;var s;(s=!!n)&&(s=(s=e[n-1])!=null&&typeof s=="object"&&s.constructor===Object);const a=n+(s?-1:0);for(t=128&t?1:0;t<a;t++)r(t-i,e[t]);if(s){e=e[n-1];for(const c in e)!isNaN(c)&&r(+c,e[c])}}var No={};function ar(e){return 128&e?No:void 0}function Si(e){return e.Na=!0,e}var Ed=Si(e=>typeof e=="number"),Io=Si(e=>typeof e=="string"),_d=Si(e=>typeof e=="boolean"),Ai=typeof er.BigInt=="function"&&typeof er.BigInt(0)=="bigint";function Me(e){var t=e;if(Io(t)){if(!/^\s*(?:-?[1-9]\d*|0)?\s*$/.test(t))throw Error(String(t))}else if(Ed(t)&&!Number.isSafeInteger(t))throw Error(String(t));return Ai?BigInt(e):e=_d(e)?e?"1":"0":Io(e)?e.trim()||"0":String(e)}var In=Si(e=>Ai?e>=Sd&&e<=Cd:e[0]==="-"?Fo(e,kd):Fo(e,Ad));const kd=Number.MIN_SAFE_INTEGER.toString(),Sd=Ai?BigInt(Number.MIN_SAFE_INTEGER):void 0,Ad=Number.MAX_SAFE_INTEGER.toString(),Cd=Ai?BigInt(Number.MAX_SAFE_INTEGER):void 0;function Fo(e,t){if(e.length>t.length)return!1;if(e.length<t.length||e===t)return!0;for(let r=0;r<e.length;r++){const i=e[r],n=t[r];if(i>n)return!1;if(i<n)return!0}}const Td=typeof Uint8Array.prototype.slice=="function";let Nd,ee=0,ce=0;function Lo(e){const t=e>>>0;ee=t,ce=(e-t)/4294967296>>>0}function cr(e){if(e<0){Lo(-e);const[t,r]=Pn(ee,ce);ee=t>>>0,ce=r>>>0}else Lo(e)}function Fn(e){const t=Nd||(Nd=new DataView(new ArrayBuffer(8)));t.setFloat32(0,+e,!0),ce=0,ee=t.getUint32(0,!0)}function Ln(e,t){const r=4294967296*t+(e>>>0);return Number.isSafeInteger(r)?r:Kr(e,t)}function Id(e,t){return Me(ir()?BigInt.asUintN(64,(BigInt(t>>>0)<<BigInt(32))+BigInt(e>>>0)):Kr(e,t))}function Mn(e,t){const r=2147483648&t;return r&&(t=~t>>>0,(e=1+~e>>>0)==0&&(t=t+1>>>0)),typeof(e=Ln(e,t))=="number"?r?-e:e:r?"-"+e:e}function Mo(e,t){return ir()?Me(BigInt.asIntN(64,(BigInt.asUintN(32,BigInt(t))<<BigInt(32))+BigInt.asUintN(32,BigInt(e)))):Me(Dn(e,t))}function Kr(e,t){if(e>>>=0,(t>>>=0)<=2097151)var r=""+(4294967296*t+e);else ir()?r=""+(BigInt(t)<<BigInt(32)|BigInt(e)):(e=(16777215&e)+6777216*(r=16777215&(e>>>24|t<<8))+6710656*(t=t>>16&65535),r+=8147497*t,t*=2,e>=1e7&&(r+=e/1e7>>>0,e%=1e7),r>=1e7&&(t+=r/1e7>>>0,r%=1e7),r=t+Do(r)+Do(e));return r}function Do(e){return e=String(e),"0000000".slice(e.length)+e}function Dn(e,t){if(2147483648&t)if(ir())e=""+(BigInt(0|t)<<BigInt(32)|BigInt(e>>>0));else{const[r,i]=Pn(e,t);e="-"+Kr(r,i)}else e=Kr(e,t);return e}function Ci(e){if(e.length<16)cr(Number(e));else if(ir())e=BigInt(e),ee=Number(e&BigInt(4294967295))>>>0,ce=Number(e>>BigInt(32)&BigInt(4294967295));else{const t=+(e[0]==="-");ce=ee=0;const r=e.length;for(let i=t,n=(r-t)%6+t;n<=r;i=n,n+=6){const s=Number(e.slice(i,n));ce*=1e6,ee=1e6*ee+s,ee>=4294967296&&(ce+=Math.trunc(ee/4294967296),ce>>>=0,ee>>>=0)}if(t){const[i,n]=Pn(ee,ce);ee=i,ce=n}}}function Pn(e,t){return t=~t,e?e=1+~e:t+=1,[e,t]}function et(e){return Array.prototype.slice.call(e)}const Yr=typeof BigInt=="function"?BigInt.asIntN:void 0,Fd=typeof BigInt=="function"?BigInt.asUintN:void 0,Vt=Number.isSafeInteger,Ti=Number.isFinite,lr=Math.trunc,Ld=Me(0);function Xr(e){if(e!=null&&typeof e!="number")throw Error(`Value of float/double field must be a number, found ${typeof e}: ${e}`);return e}function ot(e){return e==null||typeof e=="number"?e:e==="NaN"||e==="Infinity"||e==="-Infinity"?Number(e):void 0}function Qr(e){if(e!=null&&typeof e!="boolean"){var t=typeof e;throw Error(`Expected boolean but got ${t!="object"?t:e?Array.isArray(e)?"array":t:"null"}: ${e}`)}return e}function Po(e){return e==null||typeof e=="boolean"?e:typeof e=="number"?!!e:void 0}const Md=/^-?([1-9][0-9]*|0)(\.[0-9]+)?$/;function Jr(e){switch(typeof e){case"bigint":return!0;case"number":return Ti(e);case"string":return Md.test(e);default:return!1}}function dr(e){if(e==null)return e;if(typeof e=="string"&&e)e=+e;else if(typeof e!="number")return;return Ti(e)?0|e:void 0}function Oo(e){if(e==null)return e;if(typeof e=="string"&&e)e=+e;else if(typeof e!="number")return;return Ti(e)?e>>>0:void 0}function Bo(e){const t=e.length;return(e[0]==="-"?t<20||t===20&&e<="-9223372036854775808":t<19||t===19&&e<="9223372036854775807")?e:(Ci(e),Dn(ee,ce))}function On(e){return e=lr(e),Vt(e)||(cr(e),e=Mn(ee,ce)),e}function Uo(e){var t=lr(Number(e));return Vt(t)?String(t):((t=e.indexOf("."))!==-1&&(e=e.substring(0,t)),Bo(e))}function Vo(e){var t=lr(Number(e));return Vt(t)?Me(t):((t=e.indexOf("."))!==-1&&(e=e.substring(0,t)),ir()?Me(Yr(64,BigInt(e))):Me(Bo(e)))}function Go(e){return Vt(e)?e=Me(On(e)):(e=lr(e),Vt(e)?e=String(e):(cr(e),e=Dn(ee,ce)),e=Me(e)),e}function Dd(e){return e==null?e:typeof e=="bigint"?(In(e)?e=Number(e):(e=Yr(64,e),e=In(e)?Number(e):String(e)),e):Jr(e)?typeof e=="number"?On(e):Uo(e):void 0}function Ni(e){const t=typeof e;return e==null?e:t==="bigint"?Me(Yr(64,e)):Jr(e)?t==="string"?Vo(e):Go(e):void 0}function jo(e){if(typeof e!="string")throw Error();return e}function Zr(e){if(e!=null&&typeof e!="string")throw Error();return e}function xe(e){return e==null||typeof e=="string"?e:void 0}function Bn(e,t,r,i){return e!=null&&e[sr]===or?e:Array.isArray(e)?((i=(r=0|e[T])|32&i|2&i)!==r&&ue(e,i),new t(e)):(r?2&i?((e=t[Eo])||(Hr((e=new t).v),e=t[Eo]=e),t=e):t=new t:t=void 0,t)}function Pd(e,t,r){if(t)e:{if(!Jr(t=e))throw Cn("int64");switch(typeof t){case"string":t=Vo(t);break e;case"bigint":t=Me(Yr(64,t));break e;default:t=Go(t)}}else t=Ni(e);return(e=t)==null?r?Ld:void 0:e}const Od={};let Bd=function(){try{return ki(new class extends Map{constructor(){super()}}),!1}catch{return!0}}();class Un{constructor(){this.g=new Map}get(t){return this.g.get(t)}set(t,r){return this.g.set(t,r),this.size=this.g.size,this}delete(t){return t=this.g.delete(t),this.size=this.g.size,t}clear(){this.g.clear(),this.size=this.g.size}has(t){return this.g.has(t)}entries(){return this.g.entries()}keys(){return this.g.keys()}values(){return this.g.values()}forEach(t,r){return this.g.forEach(t,r)}[Symbol.iterator](){return this.entries()}}const Ud=Bd?(Object.setPrototypeOf(Un.prototype,Map.prototype),Object.defineProperties(Un.prototype,{size:{value:0,configurable:!0,enumerable:!0,writable:!0}}),Un):class extends Map{constructor(){super()}};function $o(e){return e}function Vn(e){if(2&e.J)throw Error("Cannot mutate an immutable Map")}var gt=class extends Ud{constructor(e,t,r=$o,i=$o){super(),this.J=0|e[T],this.K=t,this.S=r,this.fa=this.K?Vd:i;for(let n=0;n<e.length;n++){const s=e[n],a=r(s[0],!1,!0);let c=s[1];t?c===void 0&&(c=null):c=i(s[1],!1,!0,void 0,void 0,this.J),super.set(a,c)}}V(e){return qr(Array.from(super.entries(),e))}clear(){Vn(this),super.clear()}delete(e){return Vn(this),super.delete(this.S(e,!0,!1))}entries(){if(this.K){var e=super.keys();e=new Co(e,Gd,this)}else e=super.entries();return e}values(){if(this.K){var e=super.keys();e=new Co(e,gt.prototype.get,this)}else e=super.values();return e}forEach(e,t){this.K?super.forEach((r,i,n)=>{e.call(t,n.get(i),i,n)}):super.forEach(e,t)}set(e,t){return Vn(this),(e=this.S(e,!0,!1))==null?this:t==null?(super.delete(e),this):super.set(e,this.fa(t,!0,!0,this.K,!1,this.J))}Ma(e){const t=this.S(e[0],!1,!0);e=e[1],e=this.K?e===void 0?null:e:this.fa(e,!1,!0,void 0,!1,this.J),super.set(t,e)}has(e){return super.has(this.S(e,!1,!1))}get(e){e=this.S(e,!1,!1);const t=super.get(e);if(t!==void 0){var r=this.K;return r?((r=this.fa(t,!1,!0,r,this.ra,this.J))!==t&&super.set(e,r),r):t}}[Symbol.iterator](){return this.entries()}};function Vd(e,t,r,i,n,s){return e=Bn(e,i,r,s),n&&(e=$n(e)),e}function Gd(e){return[e,this.get(e)]}let jd;function zo(){return jd||(jd=new gt(Hr([]),void 0,void 0,void 0,Od))}function Ii(e){return Fe?e[Fe]:void 0}function Fi(e,t){for(const r in e)!isNaN(r)&&t(e,+r,e[r])}gt.prototype.toJSON=void 0;var Gn=class{};const $d={Ka:!0};function zd(e,t){t<100||rr(bd,1)}function Li(e,t,r,i){const n=i!==void 0;i=!!i;var s,a=Fe;!n&&nr&&a&&(s=e[a])&&Fi(s,zd),a=[];var c=e.length;let l;s=4294967295;let h=!1;const u=!!(64&t),f=u?128&t?0:-1:void 0;1&t||(l=c&&e[c-1],l!=null&&typeof l=="object"&&l.constructor===Object?s=--c:l=void 0,!u||128&t||n||(h=!0,s=s-f+f)),t=void 0;for(var w=0;w<c;w++){let g=e[w];if(g!=null&&(g=r(g,i))!=null)if(u&&w>=s){const p=w-f;(t??(t={}))[p]=g}else a[w]=g}if(l)for(let g in l){if((c=l[g])==null||(c=r(c,i))==null)continue;let p;w=+g,u&&!Number.isNaN(w)&&(p=w+f)<s?a[p]=c:(t??(t={}))[g]=c}return t&&(h?a.push(t):a[s]=t),n&&Fe&&(e=Ii(e))&&e instanceof Gn&&(a[Fe]=function(g){const p=new Gn;return Fi(g,(y,b,m)=>{p[b]=et(m)}),p.da=g.da,p}(e)),a}function Wd(e){return e[0]=Rr(e[0]),e[1]=Rr(e[1]),e}function Rr(e){switch(typeof e){case"number":return Number.isFinite(e)?e:""+e;case"bigint":return In(e)?Number(e):""+e;case"boolean":return e?1:0;case"object":if(Array.isArray(e)){var t=0|e[T];return e.length===0&&1&t?void 0:Li(e,t,Rr)}if(e!=null&&e[sr]===or)return Wo(e);if(e instanceof nt){if((t=e.g)==null)e="";else if(typeof t=="string")e=t;else{if(mo){for(var r="",i=0,n=t.length-10240;i<n;)r+=String.fromCharCode.apply(null,t.subarray(i,i+=10240));r+=String.fromCharCode.apply(null,i?t.subarray(i):t),t=btoa(r)}else{r===void 0&&(r=0),po(),r=go[r],i=Array(Math.floor(t.length/3)),n=r[64]||"";let h=0,u=0;for(;h<t.length-2;h+=3){var s=t[h],a=t[h+1],c=t[h+2],l=r[s>>2];s=r[(3&s)<<4|a>>4],a=r[(15&a)<<2|c>>6],c=r[63&c],i[u++]=l+s+a+c}switch(l=0,c=n,t.length-h){case 2:c=r[(15&(l=t[h+1]))<<2]||n;case 1:t=t[h],i[u]=r[t>>2]+r[(3&t)<<4|l>>4]+c+n}t=i.join("")}e=e.g=t}return e}return e instanceof gt?e=e.size!==0?e.V(Wd):void 0:void 0}return e}function Wo(e){return Li(e=e.v,0|e[T],Rr)}let Hd,qd;function Gt(e,t){return Ho(e,t[0],t[1])}function Ho(e,t,r,i=0){if(e==null){var n=32;r?(e=[r],n|=128):e=[],t&&(n=-16760833&n|(1023&t)<<14)}else{if(!Array.isArray(e))throw Error("narr");if(n=0|e[T],ho&&1&n)throw Error("rfarr");if(2048&n&&!(2&n)&&function(){if(ho)throw Error("carr");rr(vd,5)}(),256&n)throw Error("farr");if(64&n)return(n|i)!==n&&ue(e,n|i),e;if(r&&(n|=128,r!==e[0]))throw Error("mid");e:{n|=64;var s=(r=e).length;if(s){var a=s-1;const l=r[a];if(l!=null&&typeof l=="object"&&l.constructor===Object){if((a-=t=128&n?0:-1)>=1024)throw Error("pvtlmt");for(var c in l)(s=+c)<a&&(r[s+t]=l[c],delete l[c]);n=-16760833&n|(1023&a)<<14;break e}}if(t){if((c=Math.max(t,s-(128&n?0:-1)))>1024)throw Error("spvt");n=-16760833&n|(1023&c)<<14}}}return ue(e,64|n|i),e}function Kd(e,t){if(typeof e!="object")return e;if(Array.isArray(e)){var r=0|e[T];return e.length===0&&1&r?void 0:qo(e,r,t)}if(e!=null&&e[sr]===or)return Ko(e);if(e instanceof gt){if(2&(t=e.J))return e;if(!e.size)return;if(r=Hr(e.V()),e.K)for(e=0;e<r.length;e++){const i=r[e];let n=i[1];n=n==null||typeof n!="object"?void 0:n!=null&&n[sr]===or?Ko(n):Array.isArray(n)?qo(n,0|n[T],!!(32&t)):void 0,i[1]=n}return r}return e instanceof nt?e:void 0}function qo(e,t,r){return 2&t||(!r||4096&t||16&t?e=ur(e,t,!1,r&&!(16&t)):(Wr(e,34),4&t&&Object.freeze(e))),e}function jn(e,t,r){return e=new e.constructor(t),r&&(e.h=Ut),e.m=Ut,e}function Ko(e){const t=e.v,r=0|t[T];return Le(e,r)?e:zn(e,t,r)?jn(e,t):ur(t,r)}function ur(e,t,r,i){return i??(i=!!(34&t)),e=Li(e,t,Kd,i),i=32,r&&(i|=2),ue(e,t=16769217&t|i),e}function $n(e){const t=e.v,r=0|t[T];return Le(e,r)?zn(e,t,r)?jn(e,t,!0):new e.constructor(ur(t,r,!1)):e}function hr(e){if(e.h!==Ut)return!1;var t=e.v;return Wr(t=ur(t,0|t[T]),2048),e.v=t,e.h=void 0,e.m=void 0,!0}function fr(e){if(!hr(e)&&Le(e,0|e.v[T]))throw Error()}function jt(e,t){t===void 0&&(t=0|e[T]),32&t&&!(4096&t)&&ue(e,4096|t)}function zn(e,t,r){return!!(2&r)||!(!(32&r)||4096&r)&&(ue(t,2|r),e.h=Ut,!0)}const Yd=Me(0),xt={};function Q(e,t,r,i,n){if((t=pt(e.v,t,r,n))!==null||i&&e.m!==Ut)return t}function pt(e,t,r,i){if(t===-1)return null;const n=t+(r?0:-1),s=e.length-1;let a,c;if(!(s<1+(r?0:-1))){if(n>=s)if(a=e[s],a!=null&&typeof a=="object"&&a.constructor===Object)r=a[t],c=!0;else{if(n!==s)return;r=a}else r=e[n];if(i&&r!=null){if((i=i(r))==null)return i;if(!Object.is(i,r))return c?a[t]=i:e[n]=i,i}return r}}function K(e,t,r,i){fr(e),he(e=e.v,0|e[T],t,r,i)}function he(e,t,r,i,n){const s=r+(n?0:-1);var a=e.length-1;if(a>=1+(n?0:-1)&&s>=a){const c=e[a];if(c!=null&&typeof c=="object"&&c.constructor===Object)return c[r]=i,t}return s<=a?(e[s]=i,t):(i!==void 0&&(r>=(a=(t??(t=0|e[T]))>>14&1023||536870912)?i!=null&&(e[a+(n?0:-1)]={[r]:i}):e[s]=i),t)}function $t(){return xd===void 0?2:4}function zt(e,t,r,i,n){let s=e.v,a=0|s[T];i=Le(e,a)?1:i,n=!!n||i===3,i===2&&hr(e)&&(s=e.v,a=0|s[T]);let c=(e=Wn(s,t))===Bt?7:0|e[T],l=Hn(c,a);var h=!(4&l);if(h){4&l&&(e=et(e),c=0,l=Ht(l,a),a=he(s,a,t,e));let u=0,f=0;for(;u<e.length;u++){const w=r(e[u]);w!=null&&(e[f++]=w)}f<u&&(e.length=f),r=-513&(4|l),l=r&=-1025,l&=-4097}return l!==c&&(ue(e,l),2&l&&Object.freeze(e)),Yo(e,l,s,a,t,i,h,n)}function Yo(e,t,r,i,n,s,a,c){let l=t;return s===1||s===4&&(2&t||!(16&t)&&32&i)?Wt(t)||((t|=!e.length||a&&!(4096&t)||32&i&&!(4096&t||16&t)?2:256)!==l&&ue(e,t),Object.freeze(e)):(s===2&&Wt(t)&&(e=et(e),l=0,t=Ht(t,i),i=he(r,i,n,e)),Wt(t)||(c||(t|=16),t!==l&&ue(e,t))),2&t||!(4096&t||16&t)||jt(r,i),e}function Wn(e,t,r){return e=pt(e,t,r),Array.isArray(e)?e:Bt}function Hn(e,t){return 2&t&&(e|=2),1|e}function Wt(e){return!!(2&e)&&!!(4&e)||!!(256&e)}function Xo(e){return Nn(e,!0)}function Qo(e){e=et(e);for(let t=0;t<e.length;t++){const r=e[t]=et(e[t]);Array.isArray(r[1])&&(r[1]=Hr(r[1]))}return qr(e)}function Et(e,t,r,i){fr(e),he(e=e.v,0|e[T],t,(i==="0"?Number(r)===0:r===i)?void 0:r)}function wr(e,t,r){if(2&t)throw Error();const i=ar(t);let n=Wn(e,r,i),s=n===Bt?7:0|n[T],a=Hn(s,t);return(2&a||Wt(a)||16&a)&&(a===s||Wt(a)||ue(n,a),n=et(n),s=0,a=Ht(a,t),he(e,t,r,n,i)),a&=-13,a!==s&&ue(n,a),n}function qn(e,t){var r=rc;return Yn(Kn(e=e.v),e,void 0,r)===t?t:-1}function Kn(e){if(nr)return e[zr]??(e[zr]=new Map);if(zr in e)return e[zr];const t=new Map;return Object.defineProperty(e,zr,{value:t}),t}function Jo(e,t,r,i,n){const s=Kn(e),a=Yn(s,e,t,r,n);return a!==i&&(a&&(t=he(e,t,a,void 0,n)),s.set(r,i)),t}function Yn(e,t,r,i,n){let s=e.get(i);if(s!=null)return s;s=0;for(let a=0;a<i.length;a++){const c=i[a];pt(t,c,n)!=null&&(s!==0&&(r=he(t,r,s,void 0,n)),s=c)}return e.set(i,s),s}function Xn(e,t,r){let i=0|e[T];const n=ar(i),s=pt(e,r,n);let a;if(s!=null&&s[sr]===or){if(!Le(s))return hr(s),s.v;a=s.v}else Array.isArray(s)&&(a=s);if(a){const c=0|a[T];2&c&&(a=ur(a,c))}return a=Gt(a,t),a!==s&&he(e,i,r,a,n),a}function Zo(e,t,r,i,n){let s=!1;if((i=pt(e,i,n,a=>{const c=Bn(a,r,!1,t);return s=c!==a&&c!=null,c}))!=null)return s&&!Le(i)&&jt(e,t),i}function W(e,t,r,i){let n=e.v,s=0|n[T];if((t=Zo(n,s,t,r,i))==null)return t;if(s=0|n[T],!Le(e,s)){const a=$n(t);a!==t&&(hr(e)&&(n=e.v,s=0|n[T]),s=he(n,s,r,t=a,i),jt(n,s))}return t}function Ro(e,t,r,i,n,s,a,c){var l=Le(e,r);s=l?1:s,a=!!a||s===3,l=c&&!l,(s===2||l)&&hr(e)&&(r=0|(t=e.v)[T]);var h=(e=Wn(t,n))===Bt?7:0|e[T],u=Hn(h,r);if(c=!(4&u)){var f=e,w=r;const g=!!(2&u);g&&(w|=2);let p=!g,y=!0,b=0,m=0;for(;b<f.length;b++){const v=Bn(f[b],i,!1,w);if(v instanceof i){if(!g){const k=Le(v);p&&(p=!k),y&&(y=k)}f[m++]=v}}m<b&&(f.length=m),u|=4,u=y?-4097&u:4096|u,u=p?8|u:-9&u}if(u!==h&&(ue(e,u),2&u&&Object.freeze(e)),l&&!(8&u||!e.length&&(s===1||s===4&&(2&u||!(16&u)&&32&r)))){for(Wt(u)&&(e=et(e),u=Ht(u,r),r=he(t,r,n,e)),i=e,l=u,h=0;h<i.length;h++)(f=i[h])!==(u=$n(f))&&(i[h]=u);l|=8,ue(e,u=l=i.length?4096|l:-4097&l)}return Yo(e,u,t,r,n,s,c,a)}function mt(e,t,r){const i=e.v;return Ro(e,i,0|i[T],t,r,$t(),!1,!0)}function ea(e){return e==null&&(e=void 0),e}function L(e,t,r,i,n){return K(e,r,i=ea(i),n),i&&!Le(i)&&jt(e.v),e}function ei(e,t,r,i){e:{var n=i=ea(i);fr(e);const s=e.v;let a=0|s[T];if(n==null){const c=Kn(s);if(Yn(c,s,a,r)!==t)break e;c.set(r,0)}else a=Jo(s,a,r,t);he(s,a,t,n)}i&&!Le(i)&&jt(e.v)}function Ht(e,t){return-273&(2&t?2|e:-3&e)}function Qn(e,t,r,i){var n=i;fr(e),e=Ro(e,i=e.v,0|i[T],r,t,2,!0),n=n??new r,e.push(n),t=r=e===Bt?7:0|e[T],(n=Le(n))?(r&=-9,e.length===1&&(r&=-4097)):r|=4096,r!==t&&ue(e,r),n||jt(i)}function qe(e,t,r){return dr(Q(e,t,void 0,r))}function ta(e){return(kn?Q(e,2,void 0,void 0,Ni):Ni(Q(e,2)))??Yd}function se(e,t){return Q(e,t,void 0,void 0,ot)??0}function yt(e,t,r){if(r!=null){if(typeof r!="number"||!Ti(r))throw Cn("int32");r|=0}K(e,t,r)}function F(e,t,r){K(e,t,Xr(r))}function De(e,t,r){Et(e,t,Zr(r),"")}function Mi(e,t,r){{fr(e);const a=e.v;let c=0|a[T];if(r==null)he(a,c,t);else{var i=e=r===Bt?7:0|r[T],n=Wt(e),s=n||Object.isFrozen(r);for(n||(e=0),s||(r=et(r),i=0,e=Ht(e,c),s=!1),e|=5,e|=(4&e?512&e?512:1024&e?1024:0:void 0)??(kn?1024:0),n=0;n<r.length;n++){const l=r[n],h=jo(l);Object.is(l,h)||(s&&(r=et(r),i=0,e=Ht(e,c),s=!1),r[n]=h)}e!==i&&(s&&(r=et(r),e=Ht(e,c)),ue(r,e)),he(a,c,t,r)}}}function Di(e,t,r){fr(e),zt(e,t,xe,2,!0).push(jo(r))}var gr=class{constructor(e,t,r){if(this.buffer=e,r&&!t)throw Error();this.g=t}};function Jn(e,t){if(typeof e=="string")return new gr(bo(e),t);if(Array.isArray(e))return new gr(new Uint8Array(e),t);if(e.constructor===Uint8Array)return new gr(e,!1);if(e.constructor===ArrayBuffer)return e=new Uint8Array(e),new gr(e,!1);if(e.constructor===nt)return t=An(e)||new Uint8Array(0),new gr(t,!0,e);if(e instanceof Uint8Array)return e=e.constructor===Uint8Array?e:new Uint8Array(e.buffer,e.byteOffset,e.byteLength),new gr(e,!1);throw Error()}function pr(e,t){let r,i=0,n=0,s=0;const a=e.h;let c=e.g;do r=a[c++],i|=(127&r)<<s,s+=7;while(s<32&&128&r);if(s>32)for(n|=(127&r)>>4,s=3;s<32&&128&r;s+=7)r=a[c++],n|=(127&r)<<s;if(qt(e,c),!(128&r))return t(i>>>0,n>>>0);throw Error()}function Zn(e){let t=0,r=e.g;const i=r+10,n=e.h;for(;r<i;){const s=n[r++];if(t|=s,(128&s)==0)return qt(e,r),!!(127&t)}throw Error()}function _t(e){const t=e.h;let r=e.g,i=t[r++],n=127&i;if(128&i&&(i=t[r++],n|=(127&i)<<7,128&i&&(i=t[r++],n|=(127&i)<<14,128&i&&(i=t[r++],n|=(127&i)<<21,128&i&&(i=t[r++],n|=i<<28,128&i&&128&t[r++]&&128&t[r++]&&128&t[r++]&&128&t[r++]&&128&t[r++])))))throw Error();return qt(e,r),n}function bt(e){return _t(e)>>>0}function Pi(e){var t=e.h;const r=e.g;var i=t[r],n=t[r+1];const s=t[r+2];return t=t[r+3],qt(e,e.g+4),e=2*((n=(i<<0|n<<8|s<<16|t<<24)>>>0)>>31)+1,i=n>>>23&255,n&=8388607,i==255?n?NaN:e*(1/0):i==0?1401298464324817e-60*e*n:e*Math.pow(2,i-150)*(n+8388608)}function Xd(e){return _t(e)}function qt(e,t){if(e.g=t,t>e.l)throw Error()}function ra(e,t){if(t<0)throw Error();const r=e.g;if((t=r+t)>e.l)throw Error();return e.g=t,r}function ia(e,t){if(t==0)return Ot();var r=ra(e,t);return e.Y&&e.j?r=e.h.subarray(r,r+t):(e=e.h,r=r===(t=r+t)?new Uint8Array(0):Td?e.slice(r,t):new Uint8Array(e.subarray(r,t))),r.length==0?Ot():new nt(r,tr)}var na=[];function sa(e,t,r,i){if(Ui.length){const n=Ui.pop();return n.o(i),n.g.init(e,t,r,i),n}return new Qd(e,t,r,i)}function oa(e){e.g.clear(),e.l=-1,e.h=-1,Ui.length<100&&Ui.push(e)}function aa(e){var t=e.g;if(t.g==t.l)return!1;e.m=e.g.g;var r=bt(e.g);if(t=r>>>3,!((r&=7)>=0&&r<=5)||t<1)throw Error();return e.l=t,e.h=r,!0}function Oi(e){switch(e.h){case 0:e.h!=0?Oi(e):Zn(e.g);break;case 1:qt(e=e.g,e.g+8);break;case 2:if(e.h!=2)Oi(e);else{var t=bt(e.g);qt(e=e.g,e.g+t)}break;case 5:qt(e=e.g,e.g+4);break;case 3:for(t=e.l;;){if(!aa(e))throw Error();if(e.h==4){if(e.l!=t)throw Error();break}Oi(e)}break;default:throw Error()}}function ti(e,t,r){const i=e.g.l;var n=bt(e.g);let s=(n=e.g.g+n)-i;if(s<=0&&(e.g.l=n,r(t,e,void 0,void 0,void 0),s=n-e.g.g),s)throw Error();return e.g.g=n,e.g.l=i,t}function Rn(e){var t=bt(e.g),r=ra(e=e.g,t);if(e=e.h,ad){var i,n=e;(i=xn)||(i=xn=new TextDecoder("utf-8",{fatal:!0})),t=r+t,n=r===0&&t===n.length?n:n.subarray(r,t);try{var s=i.decode(n)}catch(c){if(_i===void 0){try{i.decode(new Uint8Array([128]))}catch{}try{i.decode(new Uint8Array([97])),_i=!0}catch{_i=!1}}throw!_i&&(xn=void 0),c}}else{t=(s=r)+t,r=[];let c,l=null;for(;s<t;){var a=e[s++];a<128?r.push(a):a<224?s>=t?Pt():(c=e[s++],a<194||(192&c)!=128?(s--,Pt()):r.push((31&a)<<6|63&c)):a<240?s>=t-1?Pt():(c=e[s++],(192&c)!=128||a===224&&c<160||a===237&&c>=160||(192&(i=e[s++]))!=128?(s--,Pt()):r.push((15&a)<<12|(63&c)<<6|63&i)):a<=244?s>=t-2?Pt():(c=e[s++],(192&c)!=128||c-144+(a<<28)>>30||(192&(i=e[s++]))!=128||(192&(n=e[s++]))!=128?(s--,Pt()):(a=(7&a)<<18|(63&c)<<12|(63&i)<<6|63&n,a-=65536,r.push(55296+(a>>10&1023),56320+(1023&a)))):Pt(),r.length>=8192&&(l=co(l,r),r.length=0)}s=co(l,r)}return s}function ca(e){const t=bt(e.g);return ia(e.g,t)}function Bi(e,t,r){var i=bt(e.g);for(i=e.g.g+i;e.g.g<i;)r.push(t(e.g))}var Qd=class{constructor(e,t,r,i){if(na.length){const n=na.pop();n.init(e,t,r,i),e=n}else e=new class{constructor(n,s,a,c){this.h=null,this.j=!1,this.g=this.l=this.m=0,this.init(n,s,a,c)}init(n,s,a,{Y:c=!1,ea:l=!1}={}){this.Y=c,this.ea=l,n&&(n=Jn(n,this.ea),this.h=n.buffer,this.j=n.g,this.m=s||0,this.l=a!==void 0?this.m+a:this.h.length,this.g=this.m)}clear(){this.h=null,this.j=!1,this.g=this.l=this.m=0,this.Y=!1}}(e,t,r,i);this.g=e,this.m=this.g.g,this.h=this.l=-1,this.o(i)}o({ha:e=!1}={}){this.ha=e}},Ui=[];function la(e){return e?/^\d+$/.test(e)?(Ci(e),new es(ee,ce)):null:Jd||(Jd=new es(0,0))}var es=class{constructor(e,t){this.h=e>>>0,this.g=t>>>0}};let Jd;function da(e){return e?/^-?\d+$/.test(e)?(Ci(e),new ts(ee,ce)):null:Zd||(Zd=new ts(0,0))}var ts=class{constructor(e,t){this.h=e>>>0,this.g=t>>>0}};let Zd;function mr(e,t,r){for(;r>0||t>127;)e.g.push(127&t|128),t=(t>>>7|r<<25)>>>0,r>>>=7;e.g.push(t)}function yr(e,t){for(;t>127;)e.g.push(127&t|128),t>>>=7;e.g.push(t)}function Vi(e,t){if(t>=0)yr(e,t);else{for(let r=0;r<9;r++)e.g.push(127&t|128),t>>=7;e.g.push(1)}}function rs(e){var t=ee;e.g.push(t>>>0&255),e.g.push(t>>>8&255),e.g.push(t>>>16&255),e.g.push(t>>>24&255)}function br(e,t){t.length!==0&&(e.l.push(t),e.h+=t.length)}function Ke(e,t,r){yr(e.g,8*t+r)}function is(e,t){return Ke(e,t,2),t=e.g.end(),br(e,t),t.push(e.h),t}function ns(e,t){var r=t.pop();for(r=e.h+e.g.length()-r;r>127;)t.push(127&r|128),r>>>=7,e.h++;t.push(r),e.h++}function Gi(e,t,r){Ke(e,t,2),yr(e.g,r.length),br(e,e.g.end()),br(e,r)}function ji(e,t,r,i){r!=null&&(t=is(e,t),i(r,e),ns(e,t))}function at(){const e=class{constructor(){throw Error()}};return Object.setPrototypeOf(e,e.prototype),e}var ss=at(),ua=at(),os=at(),as=at(),ha=at(),fa=at(),Rd=at(),$i=at(),wa=at(),ga=at();function ct(e,t,r){var i=e.v;Fe&&Fe in i&&(i=i[Fe])&&delete i[t.g],t.h?t.j(e,t.h,t.g,r,t.l):t.j(e,t.g,r,t.l)}var N=class{constructor(e,t){this.v=Ho(e,t,void 0,2048)}toJSON(){return Wo(this)}j(){var n;var e=Pu,t=this.v,r=e.g,i=Fe;if(nr&&i&&((n=t[i])==null?void 0:n[r])!=null&&rr(yd,3),t=e.g,_o&&Fe&&_o===void 0&&(i=(r=this.v)[Fe])&&(i=i.da))try{i(r,t,$d)}catch(s){uo(s)}return e.h?e.m(this,e.h,e.g,e.l):e.m(this,e.g,e.defaultValue,e.l)}clone(){const e=this.v,t=0|e[T];return zn(this,e,t)?jn(this,e,!0):new this.constructor(ur(e,t,!1))}};N.prototype[sr]=or,N.prototype.toString=function(){return this.v.toString()};var vr=class{constructor(e,t,r){this.g=e,this.h=t,e=ss,this.l=!!e&&r===e||!1}};function zi(e,t){return new vr(e,t,ss)}function pa(e,t,r,i,n){ji(e,r,Ea(t,i),n)}const eu=zi(function(e,t,r,i,n){return e.h===2&&(ti(e,Xn(t,i,r),n),!0)},pa),tu=zi(function(e,t,r,i,n){return e.h===2&&(ti(e,Xn(t,i,r),n),!0)},pa);var Wi=Symbol(),Hi=Symbol(),cs=Symbol(),ma=Symbol(),ya=Symbol();let ba,va;function Kt(e,t,r,i){var n=i[e];if(n)return n;(n={}).qa=i,n.T=function(f){switch(typeof f){case"boolean":return Hd||(Hd=[0,void 0,!0]);case"number":return f>0?void 0:f===0?qd||(qd=[0,void 0]):[-f,void 0];case"string":return[0,f];case"object":return f}}(i[0]);var s=i[1];let a=1;s&&s.constructor===Object&&(n.ba=s,typeof(s=i[++a])=="function"&&(n.ma=!0,ba??(ba=s),va??(va=i[a+1]),s=i[a+=2]));const c={};for(;s&&Array.isArray(s)&&s.length&&typeof s[0]=="number"&&s[0]>0;){for(var l=0;l<s.length;l++)c[s[l]]=s;s=i[++a]}for(l=1;s!==void 0;){let f;typeof s=="number"&&(l+=s,s=i[++a]);var h=void 0;if(s instanceof vr?f=s:(f=eu,a--),f==null?void 0:f.l){s=i[++a],h=i;var u=a;typeof s=="function"&&(s=s(),h[u]=s),h=s}for(u=l+1,typeof(s=i[++a])=="number"&&s<0&&(u-=s,s=i[++a]);l<u;l++){const w=c[l];h?r(n,l,f,h,w):t(n,l,f,w)}}return i[e]=n}function xa(e){return Array.isArray(e)?e[0]instanceof vr?e:[tu,e]:[e,void 0]}function Ea(e,t){return e instanceof N?e.v:Array.isArray(e)?Gt(e,t):void 0}function ls(e,t,r,i){const n=r.g;e[t]=i?(s,a,c)=>n(s,a,c,i):n}function ds(e,t,r,i,n){const s=r.g;let a,c;e[t]=(l,h,u)=>s(l,h,u,c||(c=Kt(Hi,ls,ds,i).T),a||(a=us(i)),n)}function us(e){let t=e[cs];if(t!=null)return t;const r=Kt(Hi,ls,ds,e);return t=r.ma?(i,n)=>ba(i,n,r):(i,n)=>{for(;aa(n)&&n.h!=4;){var s=n.l,a=r[s];if(a==null){var c=r.ba;c&&(c=c[s])&&(c=iu(c))!=null&&(a=r[s]=c)}if(a==null||!a(n,i,s)){if(a=(c=n).m,Oi(c),c.ha)var l=void 0;else l=c.g.g-a,c.g.g=a,l=ia(c.g,l);a=void 0,c=i,l&&((a=c[Fe]??(c[Fe]=new Gn))[s]??(a[s]=[])).push(l)}}return(i=Ii(i))&&(i.da=r.qa[ya]),!0},e[cs]=t,e[ya]=ru.bind(e),t}function ru(e,t,r,i){var n=this[Hi];const s=this[cs],a=Gt(void 0,n.T),c=Ii(e);if(c){var l=!1,h=n.ba;if(h){if(n=(u,f,w)=>{if(w.length!==0)if(h[f])for(const g of w){u=sa(g);try{l=!0,s(a,u)}finally{oa(u)}}else i==null||i(e,f,w)},t==null)Fi(c,n);else if(c!=null){const u=c[t];u&&n(c,t,u)}if(l){let u=0|e[T];if(2&u&&2048&u&&!(r!=null&&r.Ka))throw Error();const f=ar(u),w=(g,p)=>{if(pt(e,g,f)!=null){if((r==null?void 0:r.Qa)===1)return;throw Error()}p!=null&&(u=he(e,u,g,p,f)),delete c[g]};t==null?To(a,0|a[T],(g,p)=>{w(g,p)}):w(t,pt(a,t,f))}}}}function iu(e){const t=(e=xa(e))[0].g;if(e=e[1]){const r=us(e),i=Kt(Hi,ls,ds,e).T;return(n,s,a)=>t(n,s,a,i,r)}return t}function qi(e,t,r){e[t]=r.h}function Ki(e,t,r,i){let n,s;const a=r.h;e[t]=(c,l,h)=>a(c,l,h,s||(s=Kt(Wi,qi,Ki,i).T),n||(n=_a(i)))}function _a(e){let t=e[ma];if(!t){const r=Kt(Wi,qi,Ki,e);t=(i,n)=>ka(i,n,r),e[ma]=t}return t}function ka(e,t,r){To(e,0|e[T],(i,n)=>{if(n!=null){var s=function(a,c){var l=a[c];if(l)return l;if((l=a.ba)&&(l=l[c])){var h=(l=xa(l))[0].h;if(l=l[1]){const u=_a(l),f=Kt(Wi,qi,Ki,l).T;l=a.ma?va(f,u):(w,g,p)=>h(w,g,p,f,u)}else l=h;return a[c]=l}}(r,i);s?s(t,n,i):i<500||rr(Tn,3)}}),(e=Ii(e))&&Fi(e,(i,n,s)=>{for(br(t,t.g.end()),i=0;i<s.length;i++)br(t,An(s[i])||new Uint8Array(0))})}const nu=Me(0);function xr(e,t){if(Array.isArray(t)){var r=0|t[T];if(4&r)return t;for(var i=0,n=0;i<t.length;i++){const s=e(t[i]);s!=null&&(t[n++]=s)}return n<i&&(t.length=n),(e=-1537&(5|r))!==r&&ue(t,e),2&e&&Object.freeze(t),t}}function Se(e,t,r){return new vr(e,t,r)}function Er(e,t,r){return new vr(e,t,r)}function ge(e,t,r){he(e,0|e[T],t,r,ar(0|e[T]))}var su=zi(function(e,t,r,i,n){if(e.h!==2)return!1;if(e=et(e=ti(e,Gt([void 0,void 0],i),n)),n=ar(i=0|t[T]),2&i)throw Error();let s=pt(t,r,n);if(s instanceof gt)2&s.J?(s=s.V(),s.push(e),he(t,i,r,s,n)):s.Ma(e);else if(Array.isArray(s)){var a=0|s[T];8192&a||ue(s,a|=8192),2&a&&(s=Qo(s),he(t,i,r,s,n)),s.push(e)}else he(t,i,r,qr([e]),n);return!0},function(e,t,r,i,n){if(t instanceof gt)t.forEach((s,a)=>{ji(e,r,Gt([a,s],i),n)});else if(Array.isArray(t)){for(let s=0;s<t.length;s++){const a=t[s];Array.isArray(a)&&ji(e,r,Gt(a,i),n)}qr(t)}});function Sa(e,t,r){(t=ot(t))!=null&&(Ke(e,r,5),e=e.g,Fn(t),rs(e))}function Aa(e,t,r){if(t=function(i){if(i==null)return i;const n=typeof i;if(n==="bigint")return String(Yr(64,i));if(Jr(i)){if(n==="string")return Uo(i);if(n==="number")return On(i)}}(t),t!=null&&(typeof t=="string"&&da(t),t!=null))switch(Ke(e,r,0),typeof t){case"number":e=e.g,cr(t),mr(e,ee,ce);break;case"bigint":r=BigInt.asUintN(64,t),r=new ts(Number(r&BigInt(4294967295)),Number(r>>BigInt(32))),mr(e.g,r.h,r.g);break;default:r=da(t),mr(e.g,r.h,r.g)}}function Ca(e,t,r){(t=dr(t))!=null&&t!=null&&(Ke(e,r,0),Vi(e.g,t))}function Ta(e,t,r){(t=Po(t))!=null&&(Ke(e,r,0),e.g.g.push(t?1:0))}function Na(e,t,r){(t=xe(t))!=null&&Gi(e,r,lo(t))}function Ia(e,t,r,i,n){ji(e,r,Ea(t,i),n)}function Fa(e,t,r){(t=t==null||typeof t=="string"||t instanceof nt?t:void 0)!=null&&Gi(e,r,Jn(t,!0).buffer)}function La(e,t,r){return(e.h===5||e.h===2)&&(t=wr(t,0|t[T],r),e.h==2?Bi(e,Pi,t):t.push(Pi(e.g)),!0)}var le=Se(function(e,t,r){return e.h===5&&(ge(t,r,Pi(e.g)),!0)},Sa,$i),ou=Er(La,function(e,t,r){if((t=xr(ot,t))!=null)for(let a=0;a<t.length;a++){var i=e,n=r,s=t[a];s!=null&&(Ke(i,n,5),i=i.g,Fn(s),rs(i))}},$i),hs=Er(La,function(e,t,r){if((t=xr(ot,t))!=null&&t.length){Ke(e,r,2),yr(e.g,4*t.length);for(let i=0;i<t.length;i++)r=e.g,Fn(t[i]),rs(r)}},$i),au=Se(function(e,t,r){return e.h===5&&(ge(t,r,(e=Pi(e.g))===0?void 0:e),!0)},Sa,$i),kt=Se(function(e,t,r){return _n?(e.h!==0?e=!1:(ge(t,r,pr(e.g,Mo)),e=!0),e):e.h===0&&(ge(t,r,pr(e.g,Mn)),!0)},Aa,fa),fs=Se(function(e,t,r){return _n?(e.h!==0?t=!1:(ge(t,r,(e=pr(e.g,Mo))===nu?void 0:e),t=!0),t):e.h===0&&(ge(t,r,(e=pr(e.g,Mn))===0?void 0:e),!0)},Aa,fa),cu=Se(function(e,t,r){return _n?(e.h!==0?e=!1:(ge(t,r,pr(e.g,Id)),e=!0),e):e.h===0&&(ge(t,r,pr(e.g,Ln)),!0)},function(e,t,r){if(t=function(i){if(i==null)return i;var n=typeof i;if(n==="bigint")return String(Fd(64,i));if(Jr(i)){if(n==="string")return n=lr(Number(i)),Vt(n)&&n>=0?i=String(n):((n=i.indexOf("."))!==-1&&(i=i.substring(0,n)),(n=i[0]!=="-"&&((n=i.length)<20||n===20&&i<="18446744073709551615"))||(Ci(i),i=Kr(ee,ce))),i;if(n==="number")return(i=lr(i))>=0&&Vt(i)||(cr(i),i=Ln(ee,ce)),i}}(t),t!=null&&(typeof t=="string"&&la(t),t!=null))switch(Ke(e,r,0),typeof t){case"number":e=e.g,cr(t),mr(e,ee,ce);break;case"bigint":r=BigInt.asUintN(64,t),r=new es(Number(r&BigInt(4294967295)),Number(r>>BigInt(32))),mr(e.g,r.h,r.g);break;default:r=la(t),mr(e.g,r.h,r.g)}},Rd),pe=Se(function(e,t,r){return e.h===0&&(ge(t,r,_t(e.g)),!0)},Ca,as),ri=Er(function(e,t,r){return(e.h===0||e.h===2)&&(t=wr(t,0|t[T],r),e.h==2?Bi(e,_t,t):t.push(_t(e.g)),!0)},function(e,t,r){if((t=xr(dr,t))!=null&&t.length){r=is(e,r);for(let i=0;i<t.length;i++)Vi(e.g,t[i]);ns(e,r)}},as),_r=Se(function(e,t,r){return e.h===0&&(ge(t,r,(e=_t(e.g))===0?void 0:e),!0)},Ca,as),oe=Se(function(e,t,r){return e.h===0&&(ge(t,r,Zn(e.g)),!0)},Ta,ua),Yt=Se(function(e,t,r){return e.h===0&&(ge(t,r,(e=Zn(e.g))===!1?void 0:e),!0)},Ta,ua),Ee=Er(function(e,t,r){return e.h===2&&(e=Rn(e),wr(t,0|t[T],r).push(e),!0)},function(e,t,r){if((t=xr(xe,t))!=null)for(let a=0;a<t.length;a++){var i=e,n=r,s=t[a];s!=null&&Gi(i,n,lo(s))}},os),St=Se(function(e,t,r){return e.h===2&&(ge(t,r,(e=Rn(e))===""?void 0:e),!0)},Na,os),X=Se(function(e,t,r){return e.h===2&&(ge(t,r,Rn(e)),!0)},Na,os),me=function(e,t,r=ss){return new vr(e,t,r)}(function(e,t,r,i,n){return e.h===2&&(i=Gt(void 0,i),wr(t,0|t[T],r).push(i),ti(e,i,n),!0)},function(e,t,r,i,n){if(Array.isArray(t)){for(let s=0;s<t.length;s++)Ia(e,t[s],r,i,n);1&(e=0|t[T])||ue(t,1|e)}}),ae=zi(function(e,t,r,i,n,s){if(e.h!==2)return!1;let a=0|t[T];return Jo(t,a,s,r,ar(a)),ti(e,t=Xn(t,i,r),n),!0},Ia),Ma=Se(function(e,t,r){return e.h===2&&(ge(t,r,ca(e)),!0)},Fa,wa),lu=Er(function(e,t,r){return(e.h===0||e.h===2)&&(t=wr(t,0|t[T],r),e.h==2?Bi(e,bt,t):t.push(bt(e.g)),!0)},function(e,t,r){if((t=xr(Oo,t))!=null)for(let a=0;a<t.length;a++){var i=e,n=r,s=t[a];s!=null&&(Ke(i,n,0),yr(i.g,s))}},ha),du=Se(function(e,t,r){return e.h===0&&(ge(t,r,(e=bt(e.g))===0?void 0:e),!0)},function(e,t,r){(t=Oo(t))!=null&&t!=null&&(Ke(e,r,0),yr(e.g,t))},ha),Pe=Se(function(e,t,r){return e.h===0&&(ge(t,r,_t(e.g)),!0)},function(e,t,r){(t=dr(t))!=null&&(t=parseInt(t,10),Ke(e,r,0),Vi(e.g,t))},ga);class uu{constructor(t,r){var i=Oe;this.g=t,this.h=r,this.m=W,this.j=L,this.defaultValue=void 0,this.l=i.Oa!=null?No:void 0}register(){ki(this)}}function lt(e,t){return new uu(e,t)}function At(e,t){return(r,i)=>{{const s={ea:!0};i&&Object.assign(s,i),r=sa(r,void 0,void 0,s);try{const a=new e,c=a.v;us(t)(c,r);var n=a}finally{oa(r)}}return n}}function Yi(e){return function(){const t=new class{constructor(){this.l=[],this.h=0,this.g=new class{constructor(){this.g=[]}length(){return this.g.length}end(){const a=this.g;return this.g=[],a}}}};ka(this.v,t,Kt(Wi,qi,Ki,e)),br(t,t.g.end());const r=new Uint8Array(t.h),i=t.l,n=i.length;let s=0;for(let a=0;a<n;a++){const c=i[a];r.set(c,s),s+=c.length}return t.l=[r],r}}var Da=class extends N{constructor(e){super(e)}},Pa=[0,St,Se(function(e,t,r){return e.h===2&&(ge(t,r,(e=ca(e))===Ot()?void 0:e),!0)},function(e,t,r){if(t!=null){if(t instanceof N){const i=t.Ra;return void(i?(t=i(t),t!=null&&Gi(e,r,Jn(t,!0).buffer)):rr(Tn,3))}if(Array.isArray(t))return void rr(Tn,3)}Fa(e,t,r)},wa)];let ws,Oa=globalThis.trustedTypes;function Ba(e){var t;return ws===void 0&&(ws=function(){let r=null;if(!Oa)return r;try{const i=n=>n;r=Oa.createPolicy("goog#html",{createHTML:i,createScript:i,createScriptURL:i})}catch{}return r}()),e=(t=ws)?t.createScriptURL(e):e,new class{constructor(r){this.g=r}toString(){return this.g+""}}(e)}function hu(e,...t){if(t.length===0)return Ba(e[0]);let r=e[0];for(let i=0;i<t.length;i++)r+=encodeURIComponent(t[i])+e[i+1];return Ba(r)}var Ua=[0,pe,Pe,oe,-1,ri,Pe,-1,oe],fu=class extends N{constructor(e){super(e)}},Va=[0,oe,X,oe,Pe,-1,Er(function(e,t,r){return(e.h===0||e.h===2)&&(t=wr(t,0|t[T],r),e.h==2?Bi(e,Xd,t):t.push(_t(e.g)),!0)},function(e,t,r){if((t=xr(dr,t))!=null&&t.length){r=is(e,r);for(let i=0;i<t.length;i++)Vi(e.g,t[i]);ns(e,r)}},ga),X,-1,[0,oe,-1],Pe,oe,-1],Ga=[0,3,oe,-1,2,[0,pe],[0,Pe,oe],[0,X,-1],[0]],ja=[0,X,-2],$a=class extends N{constructor(e){super(e)}},za=[0],Wa=[0,pe,oe,1,oe,-4],Oe=class extends N{constructor(e){super(e,2)}},fe={};fe[336783863]=[0,X,oe,-1,pe,[0,[1,2,3,4,5,6,7,8,9],ae,za,ae,Va,ae,ja,ae,Wa,ae,Ua,ae,[0,X,-2],ae,[0,X,Pe],ae,Ga,ae,[0,Pe,-1,oe]],[0,X],oe,[0,[1,3],[2,4],ae,[0,ri],-1,ae,[0,Ee],-1,me,[0,X,-1]],X];var Ha=[0,fs,-1,Yt,-3,fs,ri,St,_r,fs,-1,Yt,_r,Yt,-2,St];function J(e,t){Di(e,3,t)}function j(e,t){Di(e,4,t)}var Te=class extends N{constructor(e){super(e,500)}o(e){return L(this,0,7,e)}},ii=[-1,{}],qa=[0,X,1,ii],Ka=[0,X,Ee,ii];function Ye(e,t){Qn(e,1,Te,t)}function te(e,t){Di(e,10,t)}function H(e,t){Di(e,15,t)}var Be=class extends N{constructor(e){super(e,500)}o(e){return L(this,0,1001,e)}},Ya=[-500,me,[-500,St,-1,Ee,-3,[-2,fe,oe],me,Pa,_r,-1,qa,Ka,me,[0,St,Yt],St,Ha,_r,Ee,987,Ee],4,me,[-500,X,-1,[-1,{}],998,X],me,[-500,X,Ee,-1,[-2,{},oe],997,Ee,-1],_r,me,[-500,X,Ee,ii,998,Ee],Ee,_r,qa,Ka,me,[0,St,-1,ii],Ee,-2,Ha,St,-1,Yt,[0,Yt,du],978,ii,me,Pa];Be.prototype.g=Yi(Ya);var wu=At(Be,Ya),gu=class extends N{constructor(e){super(e)}},Xa=class extends N{constructor(e){super(e)}g(){return mt(this,gu,1)}},Qa=[0,me,[0,pe,le,X,-1]],Xi=At(Xa,Qa),pu=class extends N{constructor(e){super(e)}},mu=class extends N{constructor(e){super(e)}},gs=class extends N{constructor(e){super(e)}l(){return W(this,pu,2)}g(){return mt(this,mu,5)}},Ja=At(class extends N{constructor(e){super(e)}},[0,Ee,ri,hs,[0,Pe,[0,pe,-3],[0,le,-3],[0,pe,-1,[0,me,[0,pe,-2]]],me,[0,le,-1,X,le]],X,-1,kt,me,[0,pe,le],Ee,kt]),Za=class extends N{constructor(e){super(e)}},kr=At(class extends N{constructor(e){super(e)}},[0,me,[0,le,-4]]),Ra=class extends N{constructor(e){super(e)}},ni=At(class extends N{constructor(e){super(e)}},[0,me,[0,le,-4]]),yu=class extends N{constructor(e){super(e)}},bu=[0,pe,-1,hs,Pe],ec=class extends N{constructor(e){super(e)}};ec.prototype.g=Yi([0,le,-4,kt]);var vu=class extends N{constructor(e){super(e)}},xu=At(class extends N{constructor(e){super(e)}},[0,me,[0,1,pe,X,Qa],kt]),tc=class extends N{constructor(e){super(e)}},Eu=class extends N{constructor(e){super(e)}na(){const e=Q(this,1,void 0,void 0,Xo);return e??Ot()}},_u=class extends N{constructor(e){super(e)}},rc=[1,2],ku=At(class extends N{constructor(e){super(e)}},[0,me,[0,rc,ae,[0,hs],ae,[0,Ma],pe,X],kt]),ps=class extends N{constructor(e){super(e)}},ic=[0,X,pe,le,Ee,-1],nc=class extends N{constructor(e){super(e)}},Su=[0,oe,-1],sc=class extends N{constructor(e){super(e)}},Qi=[1,2,3,4,5,6],Ji=class extends N{constructor(e){super(e)}g(){return Q(this,1,void 0,void 0,Xo)!=null}l(){return xe(Q(this,2))!=null}},ie=class extends N{constructor(e){super(e)}g(){return Po(Q(this,2))??!1}},oc=[0,Ma,X,[0,pe,kt,-1],[0,cu,kt]],de=[0,oc,oe,[0,Qi,ae,Wa,ae,Va,ae,Ua,ae,za,ae,ja,ae,Ga],Pe],Zi=class extends N{constructor(e){super(e)}},ms=[0,de,le,-1,pe],Au=lt(502141897,Zi);fe[502141897]=ms;var Cu=At(class extends N{constructor(e){super(e)}},[0,[0,Pe,-1,ou,lu],bu]),ac=class extends N{constructor(e){super(e)}},cc=class extends N{constructor(e){super(e)}},ys=[0,de,le,[0,de],oe],Tu=lt(508968150,cc);fe[508968150]=[0,de,ms,ys,le,[0,[0,oc]]],fe[508968149]=ys;var Sr=class extends N{constructor(e){super(e)}l(){return W(this,ps,2)}g(){K(this,2)}},lc=[0,de,ic];fe[478825465]=lc;var Nu=class extends N{constructor(e){super(e)}},dc=class extends N{constructor(e){super(e)}},bs=class extends N{constructor(e){super(e)}},vs=class extends N{constructor(e){super(e)}},uc=class extends N{constructor(e){super(e)}},hc=[0,de,[0,de],lc,-1],fc=[0,de,le,pe],xs=[0,de,le],wc=[0,de,fc,xs,le],Iu=lt(479097054,uc);fe[479097054]=[0,de,wc,hc],fe[463370452]=hc,fe[464864288]=fc;var Fu=lt(462713202,vs);fe[462713202]=wc,fe[474472470]=xs;var Lu=class extends N{constructor(e){super(e)}},gc=class extends N{constructor(e){super(e)}},pc=class extends N{constructor(e){super(e)}},mc=class extends N{constructor(e){super(e)}},Es=[0,de,le,-1,pe],_s=[0,de,le,oe];mc.prototype.g=Yi([0,de,xs,[0,de],ms,ys,Es,_s]);var yc=class extends N{constructor(e){super(e)}},Mu=lt(456383383,yc);fe[456383383]=[0,de,ic];var bc=class extends N{constructor(e){super(e)}},Du=lt(476348187,bc);fe[476348187]=[0,de,Su];var vc=class extends N{constructor(e){super(e)}},xc=class extends N{constructor(e){super(e)}},Ec=[0,Pe,-1],Pu=lt(458105876,class extends N{constructor(e){super(e)}g(){let e;var t=this.v;const r=0|t[T];return e=Le(this,r),t=function(i,n,s,a){var c=xc;!a&&hr(i)&&(s=0|(n=i.v)[T]);var l=pt(n,2);if(i=!1,l==null){if(a)return zo();l=[]}else if(l.constructor===gt){if(!(2&l.J)||a)return l;l=l.V()}else Array.isArray(l)?i=!!(2&(0|l[T])):l=[];if(a){if(!l.length)return zo();i||(i=!0,Hr(l))}else i&&(i=!1,qr(l),l=Qo(l));return!i&&32&s&&Wr(l,32),s=he(n,s,2,a=new gt(l,c,Pd,void 0)),i||jt(n,s),a}(this,t,r,e),!e&&xc&&(t.ra=!0),t}});fe[458105876]=[0,Ec,su,[!0,kt,[0,X,-1,Ee]],[0,ri,oe,Pe]];var ks=class extends N{constructor(e){super(e)}},_c=lt(458105758,ks);fe[458105758]=[0,de,X,Ec];var Ss=class extends N{constructor(e){super(e)}},kc=[0,au,-1,Yt],Ou=class extends N{constructor(e){super(e)}},Sc=class extends N{constructor(e){super(e)}},As=[1,2];Sc.prototype.g=Yi([0,As,ae,kc,ae,[0,me,kc]]);var Ac=class extends N{constructor(e){super(e)}},Bu=lt(443442058,Ac);fe[443442058]=[0,de,X,pe,le,Ee,-1,oe,le],fe[514774813]=Es;var Cc=class extends N{constructor(e){super(e)}},Uu=lt(516587230,Cc);function Cs(e,t){return t=t?t.clone():new ps,e.displayNamesLocale!==void 0?K(t,1,Zr(e.displayNamesLocale)):e.displayNamesLocale===void 0&&K(t,1),e.maxResults!==void 0?yt(t,2,e.maxResults):"maxResults"in e&&K(t,2),e.scoreThreshold!==void 0?F(t,3,e.scoreThreshold):"scoreThreshold"in e&&K(t,3),e.categoryAllowlist!==void 0?Mi(t,4,e.categoryAllowlist):"categoryAllowlist"in e&&K(t,4),e.categoryDenylist!==void 0?Mi(t,5,e.categoryDenylist):"categoryDenylist"in e&&K(t,5),t}function Tc(e){const t=Number(e);return Number.isSafeInteger(t)?t:String(e)}function Ts(e,t=-1,r=""){return{categories:e.map(i=>({index:qe(i,1)??0??-1,score:se(i,2)??0,categoryName:xe(Q(i,3))??""??"",displayName:xe(Q(i,4))??""??""})),headIndex:t,headName:r}}function Vu(e){const t={classifications:mt(e,vu,1).map(r=>{var i;return Ts(((i=W(r,Xa,4))==null?void 0:i.g())??[],qe(r,2)??0,xe(Q(r,3))??"")})};return function(r){return Dd(kn?Q(r,2,void 0,void 0,Ni):Q(r,2))}(e)!=null&&(t.timestampMs=Tc(ta(e))),t}function Nc(e){var a,c;var t=zt(e,3,ot,$t()),r=zt(e,2,dr,$t()),i=zt(e,1,xe,$t()),n=zt(e,9,xe,$t());const s={categories:[],keypoints:[]};for(let l=0;l<t.length;l++)s.categories.push({score:t[l],index:r[l]??-1,categoryName:i[l]??"",displayName:n[l]??""});if((t=(a=W(e,gs,4))==null?void 0:a.l())&&(s.boundingBox={originX:qe(t,1,xt)??0,originY:qe(t,2,xt)??0,width:qe(t,3,xt)??0,height:qe(t,4,xt)??0,angle:0}),(c=W(e,gs,4))==null?void 0:c.g().length)for(const l of W(e,gs,4).g())s.keypoints.push({x:Q(l,1,void 0,xt,ot)??0,y:Q(l,2,void 0,xt,ot)??0,score:Q(l,4,void 0,xt,ot)??0,label:xe(Q(l,3,void 0,xt))??""});return s}function Ri(e){const t=[];for(const r of mt(e,Ra,1))t.push({x:se(r,1)??0,y:se(r,2)??0,z:se(r,3)??0,visibility:se(r,4)??0});return t}function si(e){const t=[];for(const r of mt(e,Za,1))t.push({x:se(r,1)??0,y:se(r,2)??0,z:se(r,3)??0,visibility:se(r,4)??0});return t}function Ic(e){return Array.from(e,t=>t>127?t-256:t)}function Fc(e,t){if(e.length!==t.length)throw Error(`Cannot compute cosine similarity between embeddings of different sizes (${e.length} vs. ${t.length}).`);let r=0,i=0,n=0;for(let s=0;s<e.length;s++)r+=e[s]*t[s],i+=e[s]*e[s],n+=t[s]*t[s];if(i<=0||n<=0)throw Error("Cannot compute cosine similarity on embedding with 0 norm.");return r/Math.sqrt(i*n)}let en;fe[516587230]=[0,de,Es,_s,le],fe[518928384]=_s;const Gu=new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11]);async function Lc(){if(en===void 0)try{await WebAssembly.instantiate(Gu),en=!0}catch{en=!1}return en}async function oi(e,t=hu``){const r=await Lc()?"wasm_internal":"wasm_nosimd_internal";return{wasmLoaderPath:`${t}/${e}_${r}.js`,wasmBinaryPath:`${t}/${e}_${r}.wasm`}}var Xt=class{};function Mc(){var e=navigator;return typeof OffscreenCanvas<"u"&&(!function(t=navigator){return(t=t.userAgent).includes("Safari")&&!t.includes("Chrome")}(e)||!!((e=e.userAgent.match(/Version\/([\d]+).*Safari/))&&e.length>=1&&Number(e[1])>=17))}async function Dc(e){if(typeof importScripts!="function"){const t=document.createElement("script");return t.src=e.toString(),t.crossOrigin="anonymous",new Promise((r,i)=>{t.addEventListener("load",()=>{r()},!1),t.addEventListener("error",n=>{i(n)},!1),document.body.appendChild(t)})}try{importScripts(e.toString())}catch(t){if(!(t instanceof TypeError))throw t;await self.import(e.toString())}}function Pc(e){return e.videoWidth!==void 0?[e.videoWidth,e.videoHeight]:e.naturalWidth!==void 0?[e.naturalWidth,e.naturalHeight]:e.displayWidth!==void 0?[e.displayWidth,e.displayHeight]:[e.width,e.height]}function I(e,t,r){e.m||console.error("No wasm multistream support detected: ensure dependency inclusion of :gl_graph_runner_internal_multi_input target"),r(t=e.i.stringToNewUTF8(t)),e.i._free(t)}function Oc(e,t,r){if(!e.i.canvas)throw Error("No OpenGL canvas configured.");if(r?e.i._bindTextureToStream(r):e.i._bindTextureToCanvas(),!(r=e.i.canvas.getContext("webgl2")||e.i.canvas.getContext("webgl")))throw Error("Failed to obtain WebGL context from the provided canvas. `getContext()` should only be invoked with `webgl` or `webgl2`.");e.i.gpuOriginForWebTexturesIsBottomLeft&&r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,!0),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,t),e.i.gpuOriginForWebTexturesIsBottomLeft&&r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,!1);const[i,n]=Pc(t);return!e.l||i===e.i.canvas.width&&n===e.i.canvas.height||(e.i.canvas.width=i,e.i.canvas.height=n),[i,n]}function Bc(e,t,r){e.m||console.error("No wasm multistream support detected: ensure dependency inclusion of :gl_graph_runner_internal_multi_input target");const i=new Uint32Array(t.length);for(let n=0;n<t.length;n++)i[n]=e.i.stringToNewUTF8(t[n]);t=e.i._malloc(4*i.length),e.i.HEAPU32.set(i,t>>2),r(t);for(const n of i)e.i._free(n);e.i._free(t)}function dt(e,t,r){e.i.simpleListeners=e.i.simpleListeners||{},e.i.simpleListeners[t]=r}function Ct(e,t,r){let i=[];e.i.simpleListeners=e.i.simpleListeners||{},e.i.simpleListeners[t]=(n,s,a)=>{s?(r(i,a),i=[]):i.push(n)}}Xt.forVisionTasks=function(e){return oi("vision",e)},Xt.forTextTasks=function(e){return oi("text",e)},Xt.forGenAiExperimentalTasks=function(e){return oi("genai_experimental",e)},Xt.forGenAiTasks=function(e){return oi("genai",e)},Xt.forAudioTasks=function(e){return oi("audio",e)},Xt.isSimdSupported=function(){return Lc()};async function ju(e,t,r,i){return e=await(async(n,s,a,c,l)=>{if(s&&await Dc(s),!self.ModuleFactory||a&&(await Dc(a),!self.ModuleFactory))throw Error("ModuleFactory not set.");return self.Module&&l&&((s=self.Module).locateFile=l.locateFile,l.mainScriptUrlOrBlob&&(s.mainScriptUrlOrBlob=l.mainScriptUrlOrBlob)),l=await self.ModuleFactory(self.Module||l),self.ModuleFactory=self.Module=void 0,new n(l,c)})(e,r.wasmLoaderPath,r.assetLoaderPath,t,{locateFile:n=>n.endsWith(".wasm")?r.wasmBinaryPath.toString():r.assetBinaryPath&&n.endsWith(".data")?r.assetBinaryPath.toString():n}),await e.o(i),e}function Ns(e,t){const r=W(e.baseOptions,Ji,1)||new Ji;typeof t=="string"?(K(r,2,Zr(t)),K(r,1)):t instanceof Uint8Array&&(K(r,1,Nn(t,!1)),K(r,2)),L(e.baseOptions,0,1,r)}function Uc(e){try{const t=e.H.length;if(t===1)throw Error(e.H[0].message);if(t>1)throw Error("Encountered multiple errors: "+e.H.map(r=>r.message).join(", "))}finally{e.H=[]}}function A(e,t){e.C=Math.max(e.C,t)}function tn(e,t){e.B=new Te,De(e.B,2,"PassThroughCalculator"),J(e.B,"free_memory"),j(e.B,"free_memory_unused_out"),te(t,"free_memory"),Ye(t,e.B)}function Ar(e,t){J(e.B,t),j(e.B,t+"_unused_out")}function rn(e){e.g.addBoolToStream(!0,"free_memory",e.C)}var Is=class{constructor(e){this.g=e,this.H=[],this.C=0,this.g.setAutoRenderToScreen(!1)}l(e,t=!0){var r,i,n,s,a,c;if(t){const l=e.baseOptions||{};if((r=e.baseOptions)!=null&&r.modelAssetBuffer&&((i=e.baseOptions)!=null&&i.modelAssetPath))throw Error("Cannot set both baseOptions.modelAssetPath and baseOptions.modelAssetBuffer");if(!((n=W(this.baseOptions,Ji,1))!=null&&n.g()||(s=W(this.baseOptions,Ji,1))!=null&&s.l()||(a=e.baseOptions)!=null&&a.modelAssetBuffer||(c=e.baseOptions)!=null&&c.modelAssetPath))throw Error("Either baseOptions.modelAssetPath or baseOptions.modelAssetBuffer must be set");if(function(h,u){let f=W(h.baseOptions,sc,3);if(!f){var w=f=new sc,g=new $a;ei(w,4,Qi,g)}"delegate"in u&&(u.delegate==="GPU"?(u=f,w=new fu,ei(u,2,Qi,w)):(u=f,w=new $a,ei(u,4,Qi,w))),L(h.baseOptions,0,3,f)}(this,l),l.modelAssetPath)return fetch(l.modelAssetPath.toString()).then(h=>{if(h.ok)return h.arrayBuffer();throw Error(`Failed to fetch model: ${l.modelAssetPath} (${h.status})`)}).then(h=>{try{this.g.i.FS_unlink("/model.dat")}catch{}this.g.i.FS_createDataFile("/","model.dat",new Uint8Array(h),!0,!1,!1),Ns(this,"/model.dat"),this.m(),this.L()});if(l.modelAssetBuffer instanceof Uint8Array)Ns(this,l.modelAssetBuffer);else if(l.modelAssetBuffer)return async function(h){const u=[];for(var f=0;;){const{done:w,value:g}=await h.read();if(w)break;u.push(g),f+=g.length}if(u.length===0)return new Uint8Array(0);if(u.length===1)return u[0];h=new Uint8Array(f),f=0;for(const w of u)h.set(w,f),f+=w.length;return h}(l.modelAssetBuffer).then(h=>{Ns(this,h),this.m(),this.L()})}return this.m(),this.L(),Promise.resolve()}L(){}ca(){let e;if(this.g.ca(t=>{e=wu(t)}),!e)throw Error("Failed to retrieve CalculatorGraphConfig");return e}setGraph(e,t){this.g.attachErrorListener((r,i)=>{this.H.push(Error(i))}),this.g.Ja(),this.g.setGraph(e,t),this.B=void 0,Uc(this)}finishProcessing(){this.g.finishProcessing(),Uc(this)}close(){this.B=void 0,this.g.closeGraph()}};function Tt(e,t){if(!e)throw Error(`Unable to obtain required WebGL resource: ${t}`);return e}Is.prototype.close=Is.prototype.close;class $u{constructor(t,r,i,n){this.g=t,this.h=r,this.m=i,this.l=n}bind(){this.g.bindVertexArray(this.h)}close(){this.g.deleteVertexArray(this.h),this.g.deleteBuffer(this.m),this.g.deleteBuffer(this.l)}}function Vc(e,t,r){const i=e.g;if(r=Tt(i.createShader(r),"Failed to create WebGL shader"),i.shaderSource(r,t),i.compileShader(r),!i.getShaderParameter(r,i.COMPILE_STATUS))throw Error(`Could not compile WebGL shader: ${i.getShaderInfoLog(r)}`);return i.attachShader(e.h,r),r}function Gc(e,t){const r=e.g,i=Tt(r.createVertexArray(),"Failed to create vertex array");r.bindVertexArray(i);const n=Tt(r.createBuffer(),"Failed to create buffer");r.bindBuffer(r.ARRAY_BUFFER,n),r.enableVertexAttribArray(e.O),r.vertexAttribPointer(e.O,2,r.FLOAT,!1,0,0),r.bufferData(r.ARRAY_BUFFER,new Float32Array([-1,-1,-1,1,1,1,1,-1]),r.STATIC_DRAW);const s=Tt(r.createBuffer(),"Failed to create buffer");return r.bindBuffer(r.ARRAY_BUFFER,s),r.enableVertexAttribArray(e.L),r.vertexAttribPointer(e.L,2,r.FLOAT,!1,0,0),r.bufferData(r.ARRAY_BUFFER,new Float32Array(t?[0,1,0,0,1,0,1,1]:[0,0,0,1,1,1,1,0]),r.STATIC_DRAW),r.bindBuffer(r.ARRAY_BUFFER,null),r.bindVertexArray(null),new $u(r,i,n,s)}function Fs(e,t){if(e.g){if(t!==e.g)throw Error("Cannot change GL context once initialized")}else e.g=t}function zu(e,t,r,i){return Fs(e,t),e.h||(e.m(),e.D()),r?(e.u||(e.u=Gc(e,!0)),r=e.u):(e.A||(e.A=Gc(e,!1)),r=e.A),t.useProgram(e.h),r.bind(),e.l(),e=i(),r.g.bindVertexArray(null),e}function jc(e,t,r){return Fs(e,t),e=Tt(t.createTexture(),"Failed to create texture"),t.bindTexture(t.TEXTURE_2D,e),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,r??t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,r??t.LINEAR),t.bindTexture(t.TEXTURE_2D,null),e}function $c(e,t,r){Fs(e,t),e.B||(e.B=Tt(t.createFramebuffer(),"Failed to create framebuffe.")),t.bindFramebuffer(t.FRAMEBUFFER,e.B),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,r,0)}function Wu(e){var t;(t=e.g)==null||t.bindFramebuffer(e.g.FRAMEBUFFER,null)}var zc=class{H(){return`
|
|
1
|
+
(function(ve,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("react/jsx-runtime"),require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","react-dom"],o):(ve=typeof globalThis<"u"?globalThis:ve||self,o(ve.InterviewWidget={},ve.jsxRuntime,ve.React,ve.ReactDOM))})(this,function(ve,o,d,Nl){"use strict";var w2=Object.defineProperty;var g2=(ve,o,d)=>o in ve?w2(ve,o,{enumerable:!0,configurable:!0,writable:!0,value:d}):ve[o]=d;var we=(ve,o,d)=>g2(ve,typeof o!="symbol"?o+"":o,d);var gn=typeof document<"u"?document.currentScript:null;const pn={},Re={api:{baseUrl:"/api",retryConfig:{attempts:3,backoff:"exponential",baseDelay:1e3}},ui:{baseColor:"#3B82F6",borderRadius:"8px"},interview:{allow_answer_editing:!0,capture_screenshots:!1,timers:{thinkingDuration:30,answeringDuration:120,editingDuration:30},stt:{provider:"groq",model:"whisper-large-v3-turbo",language:"en"},tts:{provider:"piper"},proctoring:{enabled:!0,gazeAnalysisEnabled:!0,prevent_unintended_exit:!1}}},mn="iw-storage";function Il(){if(!(typeof{url:typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:gn&&gn.tagName.toUpperCase()==="SCRIPT"&&gn.src||new URL("widget.umd.3.2.21.js",document.baseURI).href}<"u"&&(pn!=null&&pn.VITE_IW_SECRET)))return typeof process<"u"&&process.env.NEXT_PUBLIC_IW_SECRET?process.env.NEXT_PUBLIC_IW_SECRET:typeof window<"u"&&window.__IW_SECRET__?window.__IW_SECRET__:"proctoring-data-seed"}const Rs=Il(),bi=30,Fl={SCREENSHOT:"screenshot"},yn="AES-GCM",bn=12;async function eo(e){const r=new TextEncoder().encode(e),i=await crypto.subtle.digest("SHA-256",r);return crypto.subtle.importKey("raw",i,yn,!1,["encrypt","decrypt"])}function Ll(){return crypto.getRandomValues(new Uint8Array(bn))}async function Ml(e,t="default-seed"){try{const r=typeof e=="string"?e:JSON.stringify(e),n=new TextEncoder().encode(r),s=await eo(t),a=Ll(),c=await crypto.subtle.encrypt({name:yn,iv:a},s,n),l=new Uint8Array(a.length+c.byteLength);return l.set(new Uint8Array(a),0),l.set(new Uint8Array(c),a.length),btoa(String.fromCharCode(...Array.from(l)))}catch(r){throw console.error("Encryption failed:",r),new Error("Failed to encrypt data")}}async function Dl(e,t="default-seed"){try{const r=atob(e),i=new Uint8Array(r.length);for(let h=0;h<r.length;h++)i[h]=r.charCodeAt(h);const n=i.slice(0,bn),s=i.slice(bn),a=await eo(t),c=await crypto.subtle.decrypt({name:yn,iv:n},a,s);return new TextDecoder().decode(c)}catch(r){throw console.error("Decryption failed:",r),new Error("Failed to decrypt data")}}async function Pl(e,t="default-seed"){return Ml(e,t)}async function Ol(e,t="default-seed"){const r=await Dl(e,t);try{return JSON.parse(r)}catch{return r}}const Vr=d.createContext(null),Bl=async()=>{try{const e=sessionStorage.getItem(mn);if(e){const r=(await Ol(e,Rs)).state;return{logViolations:(r==null?void 0:r.logViolations)||[],totalViolations:(r==null?void 0:r.totalViolations)||0,gazeViolationCounters:(r==null?void 0:r.gazeViolationCounters)||{lookingAwayCount:0,noFaceDetectedCount:0,multipleFacesCount:0,totalGazeViolations:0},referenceSet:(r==null?void 0:r.referenceSet)??!1,referenceRef:(r==null?void 0:r.referenceRef)??{x:.5,y:.5,noseX:.5,noseY:.5}}}}catch(e){console.error("Failed to load proctoring data from session storage:",e)}return{logViolations:[],totalViolations:0,gazeViolationCounters:{lookingAwayCount:0,noFaceDetectedCount:0,multipleFacesCount:0,totalGazeViolations:0},referenceSet:!1,referenceRef:{x:.5,y:.5,noseX:.5,noseY:.5}}},Gr=async e=>{try{const t=await Pl({state:e,version:0},Rs);sessionStorage.setItem(mn,t)}catch(t){console.error("Failed to save proctoring data to session storage:",t)}},Ul=({children:e})=>{const t=d.useRef({logViolations:[],totalViolations:0,gazeViolationCounters:{lookingAwayCount:0,noFaceDetectedCount:0,multipleFacesCount:0,totalGazeViolations:0},referenceSet:!1,referenceRef:{x:.5,y:.5,noseX:.5,noseY:.5}}),r=d.useRef(new Set);d.useEffect(()=>{Bl().then(w=>{t.current=w,i()})},[]);const i=d.useCallback(()=>{r.current.forEach(w=>w())},[]),n=d.useCallback(w=>(r.current.add(w),()=>{r.current.delete(w)}),[]),s=d.useCallback(()=>t.current,[]),a=d.useCallback(w=>{t.current={...t.current,logViolations:[...t.current.logViolations,w],totalViolations:t.current.totalViolations+1},Gr(t.current),i()},[i]),c=d.useCallback(w=>{const g={...t.current.gazeViolationCounters};w==="looking_away"&&(g.lookingAwayCount+=1),w==="no_face_detected"&&(g.noFaceDetectedCount+=1),w==="multiple_faces"&&(g.multipleFacesCount+=1),g.totalGazeViolations=g.lookingAwayCount+g.noFaceDetectedCount+g.multipleFacesCount,t.current={...t.current,gazeViolationCounters:g},Gr(t.current),i()},[i]),l=d.useCallback(()=>{t.current={...t.current,logViolations:[],totalViolations:0},Gr(t.current),i()},[i]),h=d.useCallback(()=>{t.current={...t.current,gazeViolationCounters:{lookingAwayCount:0,noFaceDetectedCount:0,multipleFacesCount:0,totalGazeViolations:0}},Gr(t.current),i()},[i]),u=d.useCallback((w,g)=>{t.current={...t.current,referenceSet:w,referenceRef:g},Gr(t.current),i()},[i]),f=d.useMemo(()=>({getState:s,addViolation:a,clearViolations:l,subscribe:n,incrementGazeViolation:c,clearGazeViolationCounters:h,setReferenceData:u}),[s,a,l,n,c,h,u]);return o.jsx(Vr.Provider,{value:f,children:e})},to=()=>{const e=d.useContext(Vr);if(!e)throw new Error("useProctoringStore must be used within a ProctoringProvider");const t=d.useSyncExternalStore(e.subscribe,e.getState,e.getState);return{logViolations:t.logViolations,totalViolations:t.totalViolations,addViolation:e.addViolation,clearViolations:e.clearViolations,gazeViolationCounters:t.gazeViolationCounters,referenceSet:t.referenceSet,referenceRef:t.referenceRef,incrementGazeViolation:e.incrementGazeViolation,clearGazeViolationCounters:e.clearGazeViolationCounters,setReferenceData:e.setReferenceData}},Vl=()=>{const e=d.useContext(Vr);if(!e)throw new Error("useViolations must be used within a ProctoringProvider");return d.useSyncExternalStore(e.subscribe,()=>e.getState().logViolations,()=>e.getState().logViolations)},Gl=()=>{const e=d.useContext(Vr);if(!e)throw new Error("useTotalViolations must be used within a ProctoringProvider");return d.useSyncExternalStore(e.subscribe,()=>e.getState().totalViolations,()=>e.getState().totalViolations)},jl=()=>{const e=d.useContext(Vr);if(!e)throw new Error("useProctoringActions must be used within a ProctoringProvider");return{addViolation:e.addViolation,clearViolations:e.clearViolations}},ro=d.createContext(null);function io({config:e={},children:t}){var i,n,s,a,c;const r={api:{...Re.api,...e.api,retryConfig:{...Re.api.retryConfig,...(i=e.api)==null?void 0:i.retryConfig}},ui:{...Re.ui,...e.ui},interview:{...Re.interview,...e.interview,timers:{...Re.interview.timers,...(n=e.interview)==null?void 0:n.timers},stt:{...Re.interview.stt,...(s=e.interview)==null?void 0:s.stt},tts:{...Re.interview.tts,...(a=e.interview)==null?void 0:a.tts},proctoring:{...Re.interview.proctoring,...(c=e.interview)==null?void 0:c.proctoring}}};return o.jsx(ro.Provider,{value:r,children:o.jsx(Ul,{children:t})})}function vi(){const e=d.useContext(ro);if(!e)throw new Error("useInterviewConfig must be used within an InterviewWidgetProvider. Wrap your component tree with <InterviewWidgetProvider config={...}>");return e}function no(){return vi().api||Re.api}function Rt(){return vi().ui||Re.ui}function jr(){return vi().interview||Re.interview}function $l(e){const t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return t?{r:parseInt(t[1],16),g:parseInt(t[2],16),b:parseInt(t[3],16)}:null}function zl(e,t,r){return"#"+[e,t,r].map(i=>{const n=Math.round(i).toString(16);return n.length===1?"0"+n:n}).join("")}function Wl(e,t){const r=$l(e);if(!r)return e;const i=r.r+(255-r.r)*t,n=r.g+(255-r.g)*t,s=r.b+(255-r.b)*t;return zl(i,n,s)}function Hl(e){return new Promise(t=>setTimeout(t,e))}function ql(e){return`linear-gradient(to left, ${Wl(e,.4)}, ${e})`}const Kl=()=>Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15);function Yl(e){try{const t=e.split(".");if(t.length!==3||!t[1])throw new Error("Invalid JWT token");const i=t[1].replace(/-/g,"+").replace(/_/g,"/"),n=i.padEnd(i.length+(4-i.length%4)%4,"="),s=atob(n);return JSON.parse(s)}catch(t){return console.error("Error decoding JWT:",t),null}}const Xl=e=>{var t;return!e||typeof e!="string"?"":(t=e.charAt(0))==null?void 0:t.toUpperCase()},vn=(e,t)=>{const r=Math.max(0,Math.floor(e));if(t&&r<60)return`${r}`;const i=Math.floor(r/60).toString().padStart(2,"0"),n=(r%60).toString().padStart(2,"0");return`${i}:${n}`},xn=({brandLogo:e,brandName:t,className:r="",showFallbackStyles:i=!0})=>{const{baseColor:n}=Rt();return e?o.jsx("div",{className:r,children:e}):o.jsx("div",{className:i?`iw-h-7 iw-w-7 iw-rounded-md iw-flex iw-items-center iw-justify-center iw-text-white iw-font-semibold ${r}`:r,style:i?{backgroundColor:n}:{},children:Xl(t)})},Ql=e=>{const t=d.useRef(null),r=d.useRef(null),[i,n]=d.useState(!1),[s,a]=d.useState(!1),[c,l]=d.useState(null),[h,u]=d.useState([]),[f,w]=d.useState([]),[g,p]=d.useState(""),[y,b]=d.useState(""),[m,v]=d.useState(!1),_=d.useCallback(()=>{r.current&&(r.current.getTracks().forEach(x=>x.stop()),r.current=null,l(null))},[]),E=d.useCallback(async()=>{var x,A,D,U;try{const j=await navigator.mediaDevices.enumerateDevices(),q=j.filter(O=>O.kind==="audioinput"),M=j.filter(O=>O.kind==="videoinput");if(u(q),w(M),!g&&q.length>0){const O=(x=r.current)==null?void 0:x.getAudioTracks()[0],R=O==null?void 0:O.getSettings().deviceId;p(R||((A=q[0])==null?void 0:A.deviceId)||"")}if(!y&&M.length>0){const O=(D=r.current)==null?void 0:D.getVideoTracks()[0],R=O==null?void 0:O.getSettings().deviceId;b(R||((U=M[0])==null?void 0:U.deviceId)||"")}}catch(j){console.error("Error enumerating devices:",j)}},[g,y]),k=d.useCallback(async(x,A)=>{const D={width:{ideal:1280},height:{ideal:720},...A?{deviceId:{exact:A}}:{facingMode:"user"}},U={echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0,sampleRate:{ideal:16e3},channelCount:{ideal:1},...x?{deviceId:{exact:x}}:{}};let j=null;try{j=await navigator.mediaDevices.getUserMedia({video:D,audio:U}),n(!0),a(!0)}catch(q){console.warn("Combined media request failed, trying individual.",q);try{const M=await navigator.mediaDevices.getUserMedia({audio:U});n(!0),j=M}catch(M){console.error("Audio permission denied",M),n(!1)}try{const M=await navigator.mediaDevices.getUserMedia({video:D});a(!0),j?M.getTracks().forEach(O=>j.addTrack(O)):j=M}catch(M){console.error("Video permission denied",M),a(!1)}}j?(r.current=j,l(j),t.current&&(t.current.srcObject=j,await t.current.play().catch(q=>console.error("Error playing video element",q)))):(r.current=null,l(null)),await E()},[E]),S=async x=>{x!==g&&(v(!0),p(x),_(),await k(x,y),v(!1))},P=async x=>{x!==y&&(v(!0),b(x),_(),await k(g,x),v(!1))};return d.useEffect(()=>{if(!e){_();return}return k(),()=>_()},[e]),{videoRef:t,audioAllowed:i,videoAllowed:s,audioDevices:h,videoDevices:f,selectedAudioDeviceId:g,selectedVideoDeviceId:y,isDeviceLoading:m,currentStream:c,handleAudioChange:S,handleVideoChange:P,stopStream:_}},xi=e=>o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...e,children:[o.jsx("path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"}),o.jsx("path",{d:"M12 9v4"}),o.jsx("path",{d:"M12 17h.01"})]}),Jl=e=>o.jsxs("svg",{width:24,height:24,fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:"prefix__lucide prefix__lucide-bolt-icon prefix__lucide-bolt",...e,children:[o.jsx("path",{d:"M21 16V8a2 2 0 00-1-1.73l-7-4a2 2 0 00-2 0l-7 4A2 2 0 003 8v8a2 2 0 001 1.73l7 4a2 2 0 002 0l7-4A2 2 0 0021 16z"}),o.jsx("circle",{cx:12,cy:12,r:4})]}),Zl=e=>o.jsxs("svg",{width:24,height:24,fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:"prefix__lucide prefix__lucide-camera-off-icon prefix__lucide-camera-off",...e,children:[o.jsx("path",{d:"M14.564 14.558a3 3 0 11-4.122-4.121M2 2l20 20"}),o.jsx("path",{d:"M20 20H4a2 2 0 01-2-2V9a2 2 0 012-2h1.997a2 2 0 00.819-.175M9.695 4.024A2 2 0 0110.004 4h3.993a2 2 0 011.76 1.05l.486.9A2 2 0 0018.003 7H20a2 2 0 012 2v7.344"})]}),Ei=e=>o.jsx("svg",{width:"10",height:"9",viewBox:"0 0 10 9",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:o.jsx("path",{d:"M0.75 5.5C0.75 5.5 2.35 6.4125 3.15 7.75C3.15 7.75 5.55 2.5 8.75 0.75",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),Rl=({className:e})=>o.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:e,children:o.jsx("path",{d:"M18 9.00005C18 9.00005 13.5811 15 12 15C10.4188 15 6 9 6 9",stroke:"#062260",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),so=e=>o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...e,children:[o.jsx("path",{d:"M12 2a10 10 0 0 1 7.38 16.75"}),o.jsx("path",{d:"M12 6v6l4 2"}),o.jsx("path",{d:"M2.5 8.875a10 10 0 0 0-.5 3"}),o.jsx("path",{d:"M2.83 16a10 10 0 0 0 2.43 3.4"}),o.jsx("path",{d:"M4.636 5.235a10 10 0 0 1 .891-.857"}),o.jsx("path",{d:"M8.644 21.42a10 10 0 0 0 7.631-.38"})]}),_i=e=>o.jsx("svg",{className:"iw-w-5 iw-h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",...e,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})}),ed=e=>o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...e,children:[o.jsx("path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0"}),o.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),td=e=>o.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:[o.jsx("path",{d:"M2.66797 2H13.3346",stroke:"#5C6686",strokeLinecap:"round",strokeLinejoin:"round"}),o.jsx("path",{d:"M3.66797 2V3.35359C3.66797 4.18151 4.05252 4.96247 4.70874 5.46726L8.0013 8L11.2938 5.46726C11.9501 4.96247 12.3346 4.18151 12.3346 3.35359V2",stroke:"#5C6686",strokeLinecap:"round",strokeLinejoin:"round"}),o.jsx("path",{d:"M3.66797 14V12.6464C3.66797 11.8185 4.05252 11.0375 4.70874 10.5327L8.0013 8L11.2938 10.5327C11.9501 11.0375 12.3346 11.8185 12.3346 12.6464V14",stroke:"#5C6686",strokeLinecap:"round",strokeLinejoin:"round"}),o.jsx("path",{d:"M2.66797 14H13.3346",stroke:"#5C6686",strokeLinecap:"round",strokeLinejoin:"round"})]}),oo=({className:e,...t})=>o.jsx("div",{children:o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:`iw-animate-spin ${e}`,...t,children:[o.jsx("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),o.jsx("path",{d:"M12 6l0 -3"}),o.jsx("path",{d:"M16.25 7.75l2.15 -2.15"}),o.jsx("path",{d:"M18 12l3 0"}),o.jsx("path",{d:"M16.25 16.25l2.15 2.15"}),o.jsx("path",{d:"M12 18l0 3"}),o.jsx("path",{d:"M7.75 16.25l-2.15 2.15"}),o.jsx("path",{d:"M6 12l-3 0"}),o.jsx("path",{d:"M7.75 7.75l-2.15 -2.15"})]})}),rd=e=>o.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:[o.jsx("path",{d:"M17 7V11C17 13.7614 14.7614 16 12 16C9.23858 16 7 13.7614 7 11V7C7 4.23858 9.23858 2 12 2C14.7614 2 17 4.23858 17 7Z",stroke:"currentColor",strokeWidth:"1.5"}),o.jsx("path",{d:"M20 11C20 15.4183 16.4183 19 12 19M12 19C7.58172 19 4 15.4183 4 11M12 19V22M12 22H15M12 22H9",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),ao=e=>o.jsxs("svg",{width:24,height:24,fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:"prefix__lucide prefix__lucide-target-icon prefix__lucide-target",...e,children:[o.jsx("circle",{cx:12,cy:12,r:10}),o.jsx("circle",{cx:12,cy:12,r:6}),o.jsx("circle",{cx:12,cy:12,r:2})]}),id=e=>o.jsxs("svg",{width:24,height:24,fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:"prefix__lucide prefix__lucide-users-icon prefix__lucide-users",...e,children:[o.jsx("path",{d:"M16 21v-2a4 4 0 00-4-4H6a4 4 0 00-4 4v2M16 3.128a4 4 0 010 7.744M22 21v-2a4 4 0 00-3-3.87"}),o.jsx("circle",{cx:9,cy:7,r:4})]}),nd=e=>o.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:[o.jsx("path",{d:"M11 8H13",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),o.jsx("path",{d:"M2 11C2 7.70017 2 6.05025 3.02513 5.02513C4.05025 4 5.70017 4 9 4H10C13.2998 4 14.9497 4 15.9749 5.02513C17 6.05025 17 7.70017 17 11V13C17 16.2998 17 17.9497 15.9749 18.9749C14.9497 20 13.2998 20 10 20H9C5.70017 20 4.05025 20 3.02513 18.9749C2 17.9497 2 16.2998 2 13V11Z",stroke:"currentColor",strokeWidth:"1.5"}),o.jsx("path",{d:"M17 8.90585L17.1259 8.80196C19.2417 7.05623 20.2996 6.18336 21.1498 6.60482C22 7.02628 22 8.42355 22 11.2181V12.7819C22 15.5765 22 16.9737 21.1498 17.3952C20.2996 17.8166 19.2417 16.9438 17.1259 15.198L17 15.0941",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),sd=e=>o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...e,children:[o.jsx("path",{d:"M8.8 20v-4.1l1.9.2a2.3 2.3 0 0 0 2.164-2.1V8.3A5.37 5.37 0 0 0 2 8.25c0 2.8.656 3.054 1 4.55a5.77 5.77 0 0 1 .029 2.758L2 20"}),o.jsx("path",{d:"M19.8 17.8a7.5 7.5 0 0 0 .003-10.603"}),o.jsx("path",{d:"M17 15a3.5 3.5 0 0 0-.025-4.975"})]}),ke={FACE_DETECTED:"face_detected",NO_FACE:"no_face_detected",MULTIPLE_FACES:"multiple_faces",LOOKING_AWAY:"looking_away",CAMERA_ERROR:"camera_error",MODEL_LOADING:"model_loading"},co={[ke.FACE_DETECTED]:{icon:ed,iconColor:"iw-text-green-600",iconBg:"iw-bg-green-50",iconBorder:"iw-border-green-100",title:"All Good",subtitle:"Everything looks normal",description:"Your gaze is properly focused on the screen. Continue with your interview.",buttonText:"Continue"},[ke.NO_FACE]:{icon:Zl,iconColor:"iw-text-orange-600",iconBg:"iw-bg-orange-50",iconBorder:"iw-border-orange-100",title:"Face Not Detected",subtitle:"We can't see you in the camera",description:"Please ensure you're positioned properly in front of the camera and that your face is clearly visible.",buttonText:"I Understood"},[ke.MULTIPLE_FACES]:{icon:id,iconColor:"iw-text-red-600",iconBg:"iw-bg-red-50",iconBorder:"iw-border-red-100",title:"Multiple People Detected",subtitle:"More than one person is visible on the screen.",buttonText:"I Understood"},[ke.LOOKING_AWAY]:{icon:ao,iconColor:"iw-text-amber-600",iconBg:"iw-bg-amber-50",iconBorder:"iw-border-amber-200/75",title:"Focus Alert",subtitle:"You looked away from the screen. Maintain focus to continue.",buttonText:"I Understood"},[ke.CAMERA_ERROR]:{icon:xi,iconColor:"iw-text-red-600",iconBg:"iw-bg-red-50",iconBorder:"iw-border-red-100",title:"Camera Issue",subtitle:"There's a problem with your camera",description:"Please check your camera connection and permissions, contact support if the problem continues.",buttonText:"I Understood"},[ke.MODEL_LOADING]:{icon:ao,iconColor:"iw-text-blue-600",iconBg:"iw-bg-blue-50",iconBorder:"iw-border-blue-100",title:"Initializing Model",subtitle:"Please wait while we set up the AI",description:"The face detection model is being loaded. This should only take a moment.",buttonText:"Wait"}},od=({gazeAnalysisEnabled:e,isModelLoaded:t,stats:r,statusMessage:i,loadingProgress:n})=>o.jsx("div",{className:"iw-w-full",children:o.jsxs("div",{className:"iw-border-strock iw-rounded-md iw-border iw-bg-gray-50 iw-p-4",children:[o.jsxs("h3",{className:"iw-m-0 iw-mb-2.5",children:["Status: ",i]}),n>0&&n<100&&o.jsxs("div",{className:"iw-mb-2.5",children:[o.jsx("div",{className:"iw-h-2 iw-w-full iw-rounded iw-bg-gray-300",children:o.jsx("div",{className:"iw-h-full iw-rounded iw-bg-blue-600 iw-transition-all iw-duration-300 iw-ease-out",style:{width:`${n}%`}})}),o.jsxs("small",{className:"iw-text-gray-600",children:["Loading model... ",n.toFixed(1),"%"]})]}),o.jsxs("div",{className:"iw-grid iw-grid-cols-2 iw-gap-2.5 iw-text-sm",children:[o.jsxs("div",{children:[o.jsx("strong",{children:"FPS:"})," ",o.jsx("span",{className:r.fps<15?"iw-text-red-600":r.fps<25?"iw-text-orange-500":"iw-text-green-600",children:r.fps})]}),o.jsxs("div",{children:[o.jsx("strong",{children:"Model:"})," ",t?"✓ Loaded":"✗ Loading"]}),e&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{children:[o.jsx("strong",{children:"Engagement:"})," ",r.engagement.toFixed(1),"%"]}),o.jsxs("div",{children:[o.jsx("strong",{children:"Looking:"})," ",o.jsx("span",{className:r.isLookingAway?"iw-text-red-600":"iw-text-green-600",children:r.isLookingAway?"Away":"At Screen"})]})]})]}),r.referenceFaceNotDetected&&o.jsxs("div",{className:"iw-text-gray-dark iw-mt-2.5 iw-w-full iw-rounded-md iw-bg-[#ffeb3b] iw-p-2.5 iw-text-sm",children:[o.jsx("strong",{children:"Reference Face Not Detected"}),o.jsx("br",{}),"The previously set reference face is no longer in view."]}),r.multipleFacesDetected&&o.jsxs("div",{className:"iw-mt-2.5 iw-rounded iw-bg-red-50 iw-p-2.5 iw-text-sm iw-text-red-700",children:[o.jsx("strong",{children:"Multiple Faces Detected"}),o.jsx("br",{}),"Please ensure only one person is in the frame."]}),!e&&o.jsxs("div",{className:"iw-mt-2.5 iw-rounded iw-bg-blue-50 iw-p-2.5 iw-text-sm iw-text-blue-700",children:[o.jsx("strong",{children:"Gaze Analysis Disabled"}),o.jsx("br",{}),"Enable to track engagement and attention levels."]})]})}),ad=({showControls:e,isBubbleOpen:t,setIsBubbleOpen:r,setReference:i,clearCache:n,isModelLoaded:s,gazeAnalysisEnabled:a,referenceSet:c,showLandmarks:l,setShowLandmarks:h,showEngagementBar:u,setShowEngagementBar:f,handleToggleGazeAnalysis:w,stats:g,statusMessage:p,loadingProgress:y})=>e?o.jsxs(o.Fragment,{children:[o.jsx("button",{onClick:()=>r(!t),className:"iw-absolute iw-right-4 iw-bottom-4 iw-z-10 iw-flex iw-h-10 iw-w-10 iw-items-center iw-justify-center iw-rounded-full iw-text-white",children:o.jsx(Jl,{className:"iw-size-4.5"})}),t&&o.jsxs("div",{className:"iw-absolute iw-right-4 iw-bottom-16 iw-z-10 iw-max-h-96 iw-w-80 iw-overflow-y-auto iw-rounded-md iw-bg-gray-50 iw-p-4 iw-shadow-lg",children:[o.jsx("h4",{className:"m-0 mb-2.5",children:"Controls"}),o.jsx("button",{onClick:i,disabled:!s||!a,className:`iw-mb-2.5 iw-block iw-w-full iw-rounded border-none iw-px-4 iw-py-2 iw-text-sm iw-text-white ${!s||!a?"iw-cursor-not-allowed iw-bg-gray-400":"iw-cursor-pointer iw-bg-blue-600 hover:iw-bg-blue-700"}`,children:c?"Reference Set ✓":"Set Reference"}),o.jsx("button",{onClick:n,className:"iw-mb-4 iw-block iw-w-full iw-cursor-pointer iw-rounded iw-border-none iw-bg-red-600 iw-px-4 iw-py-2 iw-text-sm iw-text-white hover:iw-bg-red-700",children:"Clear Model Cache"}),o.jsxs("div",{className:"iw-flex iw-flex-col iw-gap-2.5",children:[o.jsxs("label",{className:"iw-flex iw-cursor-pointer iw-items-center iw-gap-2",children:[o.jsx("input",{type:"checkbox",checked:a,onChange:b=>w(b.target.checked)}),o.jsx("strong",{children:"Enable Gaze Analysis"})]}),o.jsxs("label",{className:`iw-flex iw-cursor-pointer iw-items-center iw-gap-2 ${a?"iw-opacity-100":"iw-opacity-60"}`,children:[o.jsx("input",{type:"checkbox",checked:l,onChange:b=>h(b.target.checked),disabled:!a}),"Show Landmarks"]}),o.jsxs("label",{className:`iw-flex iw-cursor-pointer iw-items-center iw-gap-2 ${a?"iw-opacity-100":"iw-opacity-60"}`,children:[o.jsx("input",{type:"checkbox",checked:u,onChange:b=>f(b.target.checked),disabled:!a}),"Show Engagement Bar"]})]}),c&&o.jsx(od,{gazeAnalysisEnabled:a,isModelLoaded:s,loadingProgress:y,stats:g,statusMessage:p})]})]}):null;var er=typeof self<"u"?self:{};function $r(e,t){e:{for(var r=["CLOSURE_FLAGS"],i=er,n=0;n<r.length;n++)if((i=i[r[n]])==null){r=null;break e}r=i}return(e=r&&r[e])!=null?e:t}function Pt(){throw Error("Invalid UTF8")}function lo(e,t){return t=String.fromCharCode.apply(null,t),e==null?t:e+t}let ki,En;const cd=typeof TextDecoder<"u";let ld;const dd=typeof TextEncoder<"u";function uo(e){if(dd)e=(ld||(ld=new TextEncoder)).encode(e);else{let r=0;const i=new Uint8Array(3*e.length);for(let n=0;n<e.length;n++){var t=e.charCodeAt(n);if(t<128)i[r++]=t;else{if(t<2048)i[r++]=t>>6|192;else{if(t>=55296&&t<=57343){if(t<=56319&&n<e.length){const s=e.charCodeAt(++n);if(s>=56320&&s<=57343){t=1024*(t-55296)+s-56320+65536,i[r++]=t>>18|240,i[r++]=t>>12&63|128,i[r++]=t>>6&63|128,i[r++]=63&t|128;continue}n--}t=65533}i[r++]=t>>12|224,i[r++]=t>>6&63|128}i[r++]=63&t|128}}e=r===i.length?i:i.subarray(0,r)}return e}function ho(e){er.setTimeout(()=>{throw e},0)}var _n,ud=$r(610401301,!1),fo=$r(748402147,!0),kn=$r(824648567,!0),Sn=$r(824656860,$r(1,!0));function wo(){var e=er.navigator;return e&&(e=e.userAgent)?e:""}const go=er.navigator;function Si(e){return Si[" "](e),e}_n=go&&go.userAgentData||null,Si[" "]=function(){};const po={};let zr=null;function hd(e){const t=e.length;let r=3*t/4;r%3?r=Math.floor(r):"=.".indexOf(e[t-1])!=-1&&(r="=.".indexOf(e[t-2])!=-1?r-2:r-1);const i=new Uint8Array(r);let n=0;return function(s,a){function c(h){for(;l<s.length;){const u=s.charAt(l++),f=zr[u];if(f!=null)return f;if(!/^[\s\xa0]*$/.test(u))throw Error("Unknown base64 encoding at char: "+u)}return h}mo();let l=0;for(;;){const h=c(-1),u=c(0),f=c(64),w=c(64);if(w===64&&h===-1)break;a(h<<2|u>>4),f!=64&&(a(u<<4&240|f>>2),w!=64&&a(f<<6&192|w))}}(e,function(s){i[n++]=s}),n!==r?i.subarray(0,n):i}function mo(){if(!zr){zr={};var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),t=["+/=","+/","-_=","-_.","-_"];for(let r=0;r<5;r++){const i=e.concat(t[r].split(""));po[r]=i;for(let n=0;n<i.length;n++){const s=i[n];zr[s]===void 0&&(zr[s]=n)}}}}var fd=typeof Uint8Array<"u",yo=!(!(ud&&_n&&_n.brands.length>0)&&(wo().indexOf("Trident")!=-1||wo().indexOf("MSIE")!=-1))&&typeof btoa=="function";const bo=/[-_.]/g,wd={"-":"+",_:"/",".":"="};function gd(e){return wd[e]||""}function vo(e){if(!yo)return hd(e);e=bo.test(e)?e.replace(bo,gd):e,e=atob(e);const t=new Uint8Array(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}function An(e){return fd&&e!=null&&e instanceof Uint8Array}var tr={};function Ot(){return pd||(pd=new nt(null,tr))}function Cn(e){xo(tr);var t=e.g;return(t=t==null||An(t)?t:typeof t=="string"?vo(t):null)==null?t:e.g=t}var nt=class{h(){return new Uint8Array(Cn(this)||0)}constructor(e,t){if(xo(t),this.g=e,e!=null&&e.length===0)throw Error("ByteString should be constructed with non-empty values")}};let pd,md;function xo(e){if(e!==tr)throw Error("illegal external caller")}function Eo(e,t){e.__closure__error__context__984382||(e.__closure__error__context__984382={}),e.__closure__error__context__984382.severity=t}function Tn(e){return Eo(e=Error(e),"warning"),e}function rr(e,t){if(e!=null){var r=md??(md={}),i=r[e]||0;i>=t||(r[e]=i+1,Eo(e=Error(),"incident"),ho(e))}}function ir(){return typeof BigInt=="function"}var nr=typeof Symbol=="function"&&typeof Symbol()=="symbol";function st(e,t,r=!1){return typeof Symbol=="function"&&typeof Symbol()=="symbol"?r&&Symbol.for&&e?Symbol.for(e):e!=null?Symbol(e):Symbol():t}var yd=st("jas",void 0,!0),_o=st(void 0,"0di"),Wr=st(void 0,"1oa"),Fe=st(void 0,Symbol()),bd=st(void 0,"0ub"),vd=st(void 0,"0ubs"),Nn=st(void 0,"0ubsb"),xd=st(void 0,"0actk"),sr=st("m_m","Pa",!0),ko=st();const So={Ga:{value:0,configurable:!0,writable:!0,enumerable:!1}},Ao=Object.defineProperties,T=nr?yd:"Ga";var Bt;const Co=[];function Hr(e,t){nr||T in e||Ao(e,So),e[T]|=t}function ue(e,t){nr||T in e||Ao(e,So),e[T]=t}function qr(e){return Hr(e,34),e}function Kr(e){return Hr(e,8192),e}ue(Co,7),Bt=Object.freeze(Co);var or={};function Le(e,t){return t===void 0?e.h!==Ut&&!!(2&(0|e.v[T])):!!(2&t)&&e.h!==Ut}const Ut={};function In(e,t){if(e!=null){if(typeof e=="string")e=e?new nt(e,tr):Ot();else if(e.constructor!==nt)if(An(e))e=e.length?new nt(new Uint8Array(e),tr):Ot();else{if(!t)throw Error();e=void 0}}return e}class To{constructor(t,r,i){this.g=t,this.h=r,this.l=i}next(){const t=this.g.next();return t.done||(t.value=this.h.call(this.l,t.value)),t}[Symbol.iterator](){return this}}var Ed=Object.freeze({});function No(e,t,r){const i=128&t?0:-1,n=e.length;var s;(s=!!n)&&(s=(s=e[n-1])!=null&&typeof s=="object"&&s.constructor===Object);const a=n+(s?-1:0);for(t=128&t?1:0;t<a;t++)r(t-i,e[t]);if(s){e=e[n-1];for(const c in e)!isNaN(c)&&r(+c,e[c])}}var Io={};function ar(e){return 128&e?Io:void 0}function Ai(e){return e.Na=!0,e}var _d=Ai(e=>typeof e=="number"),Fo=Ai(e=>typeof e=="string"),kd=Ai(e=>typeof e=="boolean"),Ci=typeof er.BigInt=="function"&&typeof er.BigInt(0)=="bigint";function Me(e){var t=e;if(Fo(t)){if(!/^\s*(?:-?[1-9]\d*|0)?\s*$/.test(t))throw Error(String(t))}else if(_d(t)&&!Number.isSafeInteger(t))throw Error(String(t));return Ci?BigInt(e):e=kd(e)?e?"1":"0":Fo(e)?e.trim()||"0":String(e)}var Fn=Ai(e=>Ci?e>=Ad&&e<=Td:e[0]==="-"?Lo(e,Sd):Lo(e,Cd));const Sd=Number.MIN_SAFE_INTEGER.toString(),Ad=Ci?BigInt(Number.MIN_SAFE_INTEGER):void 0,Cd=Number.MAX_SAFE_INTEGER.toString(),Td=Ci?BigInt(Number.MAX_SAFE_INTEGER):void 0;function Lo(e,t){if(e.length>t.length)return!1;if(e.length<t.length||e===t)return!0;for(let r=0;r<e.length;r++){const i=e[r],n=t[r];if(i>n)return!1;if(i<n)return!0}}const Nd=typeof Uint8Array.prototype.slice=="function";let Id,ee=0,ce=0;function Mo(e){const t=e>>>0;ee=t,ce=(e-t)/4294967296>>>0}function cr(e){if(e<0){Mo(-e);const[t,r]=On(ee,ce);ee=t>>>0,ce=r>>>0}else Mo(e)}function Ln(e){const t=Id||(Id=new DataView(new ArrayBuffer(8)));t.setFloat32(0,+e,!0),ce=0,ee=t.getUint32(0,!0)}function Mn(e,t){const r=4294967296*t+(e>>>0);return Number.isSafeInteger(r)?r:Yr(e,t)}function Fd(e,t){return Me(ir()?BigInt.asUintN(64,(BigInt(t>>>0)<<BigInt(32))+BigInt(e>>>0)):Yr(e,t))}function Dn(e,t){const r=2147483648&t;return r&&(t=~t>>>0,(e=1+~e>>>0)==0&&(t=t+1>>>0)),typeof(e=Mn(e,t))=="number"?r?-e:e:r?"-"+e:e}function Do(e,t){return ir()?Me(BigInt.asIntN(64,(BigInt.asUintN(32,BigInt(t))<<BigInt(32))+BigInt.asUintN(32,BigInt(e)))):Me(Pn(e,t))}function Yr(e,t){if(e>>>=0,(t>>>=0)<=2097151)var r=""+(4294967296*t+e);else ir()?r=""+(BigInt(t)<<BigInt(32)|BigInt(e)):(e=(16777215&e)+6777216*(r=16777215&(e>>>24|t<<8))+6710656*(t=t>>16&65535),r+=8147497*t,t*=2,e>=1e7&&(r+=e/1e7>>>0,e%=1e7),r>=1e7&&(t+=r/1e7>>>0,r%=1e7),r=t+Po(r)+Po(e));return r}function Po(e){return e=String(e),"0000000".slice(e.length)+e}function Pn(e,t){if(2147483648&t)if(ir())e=""+(BigInt(0|t)<<BigInt(32)|BigInt(e>>>0));else{const[r,i]=On(e,t);e="-"+Yr(r,i)}else e=Yr(e,t);return e}function Ti(e){if(e.length<16)cr(Number(e));else if(ir())e=BigInt(e),ee=Number(e&BigInt(4294967295))>>>0,ce=Number(e>>BigInt(32)&BigInt(4294967295));else{const t=+(e[0]==="-");ce=ee=0;const r=e.length;for(let i=t,n=(r-t)%6+t;n<=r;i=n,n+=6){const s=Number(e.slice(i,n));ce*=1e6,ee=1e6*ee+s,ee>=4294967296&&(ce+=Math.trunc(ee/4294967296),ce>>>=0,ee>>>=0)}if(t){const[i,n]=On(ee,ce);ee=i,ce=n}}}function On(e,t){return t=~t,e?e=1+~e:t+=1,[e,t]}function et(e){return Array.prototype.slice.call(e)}const Xr=typeof BigInt=="function"?BigInt.asIntN:void 0,Ld=typeof BigInt=="function"?BigInt.asUintN:void 0,Vt=Number.isSafeInteger,Ni=Number.isFinite,lr=Math.trunc,Md=Me(0);function Qr(e){if(e!=null&&typeof e!="number")throw Error(`Value of float/double field must be a number, found ${typeof e}: ${e}`);return e}function ot(e){return e==null||typeof e=="number"?e:e==="NaN"||e==="Infinity"||e==="-Infinity"?Number(e):void 0}function Jr(e){if(e!=null&&typeof e!="boolean"){var t=typeof e;throw Error(`Expected boolean but got ${t!="object"?t:e?Array.isArray(e)?"array":t:"null"}: ${e}`)}return e}function Oo(e){return e==null||typeof e=="boolean"?e:typeof e=="number"?!!e:void 0}const Dd=/^-?([1-9][0-9]*|0)(\.[0-9]+)?$/;function Zr(e){switch(typeof e){case"bigint":return!0;case"number":return Ni(e);case"string":return Dd.test(e);default:return!1}}function dr(e){if(e==null)return e;if(typeof e=="string"&&e)e=+e;else if(typeof e!="number")return;return Ni(e)?0|e:void 0}function Bo(e){if(e==null)return e;if(typeof e=="string"&&e)e=+e;else if(typeof e!="number")return;return Ni(e)?e>>>0:void 0}function Uo(e){const t=e.length;return(e[0]==="-"?t<20||t===20&&e<="-9223372036854775808":t<19||t===19&&e<="9223372036854775807")?e:(Ti(e),Pn(ee,ce))}function Bn(e){return e=lr(e),Vt(e)||(cr(e),e=Dn(ee,ce)),e}function Vo(e){var t=lr(Number(e));return Vt(t)?String(t):((t=e.indexOf("."))!==-1&&(e=e.substring(0,t)),Uo(e))}function Go(e){var t=lr(Number(e));return Vt(t)?Me(t):((t=e.indexOf("."))!==-1&&(e=e.substring(0,t)),ir()?Me(Xr(64,BigInt(e))):Me(Uo(e)))}function jo(e){return Vt(e)?e=Me(Bn(e)):(e=lr(e),Vt(e)?e=String(e):(cr(e),e=Pn(ee,ce)),e=Me(e)),e}function Pd(e){return e==null?e:typeof e=="bigint"?(Fn(e)?e=Number(e):(e=Xr(64,e),e=Fn(e)?Number(e):String(e)),e):Zr(e)?typeof e=="number"?Bn(e):Vo(e):void 0}function Ii(e){const t=typeof e;return e==null?e:t==="bigint"?Me(Xr(64,e)):Zr(e)?t==="string"?Go(e):jo(e):void 0}function $o(e){if(typeof e!="string")throw Error();return e}function Rr(e){if(e!=null&&typeof e!="string")throw Error();return e}function xe(e){return e==null||typeof e=="string"?e:void 0}function Un(e,t,r,i){return e!=null&&e[sr]===or?e:Array.isArray(e)?((i=(r=0|e[T])|32&i|2&i)!==r&&ue(e,i),new t(e)):(r?2&i?((e=t[_o])||(qr((e=new t).v),e=t[_o]=e),t=e):t=new t:t=void 0,t)}function Od(e,t,r){if(t)e:{if(!Zr(t=e))throw Tn("int64");switch(typeof t){case"string":t=Go(t);break e;case"bigint":t=Me(Xr(64,t));break e;default:t=jo(t)}}else t=Ii(e);return(e=t)==null?r?Md:void 0:e}const Bd={};let Ud=function(){try{return Si(new class extends Map{constructor(){super()}}),!1}catch{return!0}}();class Vn{constructor(){this.g=new Map}get(t){return this.g.get(t)}set(t,r){return this.g.set(t,r),this.size=this.g.size,this}delete(t){return t=this.g.delete(t),this.size=this.g.size,t}clear(){this.g.clear(),this.size=this.g.size}has(t){return this.g.has(t)}entries(){return this.g.entries()}keys(){return this.g.keys()}values(){return this.g.values()}forEach(t,r){return this.g.forEach(t,r)}[Symbol.iterator](){return this.entries()}}const Vd=Ud?(Object.setPrototypeOf(Vn.prototype,Map.prototype),Object.defineProperties(Vn.prototype,{size:{value:0,configurable:!0,enumerable:!0,writable:!0}}),Vn):class extends Map{constructor(){super()}};function zo(e){return e}function Gn(e){if(2&e.J)throw Error("Cannot mutate an immutable Map")}var wt=class extends Vd{constructor(e,t,r=zo,i=zo){super(),this.J=0|e[T],this.K=t,this.S=r,this.fa=this.K?Gd:i;for(let n=0;n<e.length;n++){const s=e[n],a=r(s[0],!1,!0);let c=s[1];t?c===void 0&&(c=null):c=i(s[1],!1,!0,void 0,void 0,this.J),super.set(a,c)}}V(e){return Kr(Array.from(super.entries(),e))}clear(){Gn(this),super.clear()}delete(e){return Gn(this),super.delete(this.S(e,!0,!1))}entries(){if(this.K){var e=super.keys();e=new To(e,jd,this)}else e=super.entries();return e}values(){if(this.K){var e=super.keys();e=new To(e,wt.prototype.get,this)}else e=super.values();return e}forEach(e,t){this.K?super.forEach((r,i,n)=>{e.call(t,n.get(i),i,n)}):super.forEach(e,t)}set(e,t){return Gn(this),(e=this.S(e,!0,!1))==null?this:t==null?(super.delete(e),this):super.set(e,this.fa(t,!0,!0,this.K,!1,this.J))}Ma(e){const t=this.S(e[0],!1,!0);e=e[1],e=this.K?e===void 0?null:e:this.fa(e,!1,!0,void 0,!1,this.J),super.set(t,e)}has(e){return super.has(this.S(e,!1,!1))}get(e){e=this.S(e,!1,!1);const t=super.get(e);if(t!==void 0){var r=this.K;return r?((r=this.fa(t,!1,!0,r,this.ra,this.J))!==t&&super.set(e,r),r):t}}[Symbol.iterator](){return this.entries()}};function Gd(e,t,r,i,n,s){return e=Un(e,i,r,s),n&&(e=zn(e)),e}function jd(e){return[e,this.get(e)]}let $d;function Wo(){return $d||($d=new wt(qr([]),void 0,void 0,void 0,Bd))}function Fi(e){return Fe?e[Fe]:void 0}function Li(e,t){for(const r in e)!isNaN(r)&&t(e,+r,e[r])}wt.prototype.toJSON=void 0;var jn=class{};const zd={Ka:!0};function Wd(e,t){t<100||rr(vd,1)}function Mi(e,t,r,i){const n=i!==void 0;i=!!i;var s,a=Fe;!n&&nr&&a&&(s=e[a])&&Li(s,Wd),a=[];var c=e.length;let l;s=4294967295;let h=!1;const u=!!(64&t),f=u?128&t?0:-1:void 0;1&t||(l=c&&e[c-1],l!=null&&typeof l=="object"&&l.constructor===Object?s=--c:l=void 0,!u||128&t||n||(h=!0,s=s-f+f)),t=void 0;for(var w=0;w<c;w++){let g=e[w];if(g!=null&&(g=r(g,i))!=null)if(u&&w>=s){const p=w-f;(t??(t={}))[p]=g}else a[w]=g}if(l)for(let g in l){if((c=l[g])==null||(c=r(c,i))==null)continue;let p;w=+g,u&&!Number.isNaN(w)&&(p=w+f)<s?a[p]=c:(t??(t={}))[g]=c}return t&&(h?a.push(t):a[s]=t),n&&Fe&&(e=Fi(e))&&e instanceof jn&&(a[Fe]=function(g){const p=new jn;return Li(g,(y,b,m)=>{p[b]=et(m)}),p.da=g.da,p}(e)),a}function Hd(e){return e[0]=ei(e[0]),e[1]=ei(e[1]),e}function ei(e){switch(typeof e){case"number":return Number.isFinite(e)?e:""+e;case"bigint":return Fn(e)?Number(e):""+e;case"boolean":return e?1:0;case"object":if(Array.isArray(e)){var t=0|e[T];return e.length===0&&1&t?void 0:Mi(e,t,ei)}if(e!=null&&e[sr]===or)return Ho(e);if(e instanceof nt){if((t=e.g)==null)e="";else if(typeof t=="string")e=t;else{if(yo){for(var r="",i=0,n=t.length-10240;i<n;)r+=String.fromCharCode.apply(null,t.subarray(i,i+=10240));r+=String.fromCharCode.apply(null,i?t.subarray(i):t),t=btoa(r)}else{r===void 0&&(r=0),mo(),r=po[r],i=Array(Math.floor(t.length/3)),n=r[64]||"";let h=0,u=0;for(;h<t.length-2;h+=3){var s=t[h],a=t[h+1],c=t[h+2],l=r[s>>2];s=r[(3&s)<<4|a>>4],a=r[(15&a)<<2|c>>6],c=r[63&c],i[u++]=l+s+a+c}switch(l=0,c=n,t.length-h){case 2:c=r[(15&(l=t[h+1]))<<2]||n;case 1:t=t[h],i[u]=r[t>>2]+r[(3&t)<<4|l>>4]+c+n}t=i.join("")}e=e.g=t}return e}return e instanceof wt?e=e.size!==0?e.V(Hd):void 0:void 0}return e}function Ho(e){return Mi(e=e.v,0|e[T],ei)}let qd,Kd;function Gt(e,t){return qo(e,t[0],t[1])}function qo(e,t,r,i=0){if(e==null){var n=32;r?(e=[r],n|=128):e=[],t&&(n=-16760833&n|(1023&t)<<14)}else{if(!Array.isArray(e))throw Error("narr");if(n=0|e[T],fo&&1&n)throw Error("rfarr");if(2048&n&&!(2&n)&&function(){if(fo)throw Error("carr");rr(xd,5)}(),256&n)throw Error("farr");if(64&n)return(n|i)!==n&&ue(e,n|i),e;if(r&&(n|=128,r!==e[0]))throw Error("mid");e:{n|=64;var s=(r=e).length;if(s){var a=s-1;const l=r[a];if(l!=null&&typeof l=="object"&&l.constructor===Object){if((a-=t=128&n?0:-1)>=1024)throw Error("pvtlmt");for(var c in l)(s=+c)<a&&(r[s+t]=l[c],delete l[c]);n=-16760833&n|(1023&a)<<14;break e}}if(t){if((c=Math.max(t,s-(128&n?0:-1)))>1024)throw Error("spvt");n=-16760833&n|(1023&c)<<14}}}return ue(e,64|n|i),e}function Yd(e,t){if(typeof e!="object")return e;if(Array.isArray(e)){var r=0|e[T];return e.length===0&&1&r?void 0:Ko(e,r,t)}if(e!=null&&e[sr]===or)return Yo(e);if(e instanceof wt){if(2&(t=e.J))return e;if(!e.size)return;if(r=qr(e.V()),e.K)for(e=0;e<r.length;e++){const i=r[e];let n=i[1];n=n==null||typeof n!="object"?void 0:n!=null&&n[sr]===or?Yo(n):Array.isArray(n)?Ko(n,0|n[T],!!(32&t)):void 0,i[1]=n}return r}return e instanceof nt?e:void 0}function Ko(e,t,r){return 2&t||(!r||4096&t||16&t?e=ur(e,t,!1,r&&!(16&t)):(Hr(e,34),4&t&&Object.freeze(e))),e}function $n(e,t,r){return e=new e.constructor(t),r&&(e.h=Ut),e.m=Ut,e}function Yo(e){const t=e.v,r=0|t[T];return Le(e,r)?e:Wn(e,t,r)?$n(e,t):ur(t,r)}function ur(e,t,r,i){return i??(i=!!(34&t)),e=Mi(e,t,Yd,i),i=32,r&&(i|=2),ue(e,t=16769217&t|i),e}function zn(e){const t=e.v,r=0|t[T];return Le(e,r)?Wn(e,t,r)?$n(e,t,!0):new e.constructor(ur(t,r,!1)):e}function hr(e){if(e.h!==Ut)return!1;var t=e.v;return Hr(t=ur(t,0|t[T]),2048),e.v=t,e.h=void 0,e.m=void 0,!0}function fr(e){if(!hr(e)&&Le(e,0|e.v[T]))throw Error()}function jt(e,t){t===void 0&&(t=0|e[T]),32&t&&!(4096&t)&&ue(e,4096|t)}function Wn(e,t,r){return!!(2&r)||!(!(32&r)||4096&r)&&(ue(t,2|r),e.h=Ut,!0)}const Xd=Me(0),xt={};function Q(e,t,r,i,n){if((t=gt(e.v,t,r,n))!==null||i&&e.m!==Ut)return t}function gt(e,t,r,i){if(t===-1)return null;const n=t+(r?0:-1),s=e.length-1;let a,c;if(!(s<1+(r?0:-1))){if(n>=s)if(a=e[s],a!=null&&typeof a=="object"&&a.constructor===Object)r=a[t],c=!0;else{if(n!==s)return;r=a}else r=e[n];if(i&&r!=null){if((i=i(r))==null)return i;if(!Object.is(i,r))return c?a[t]=i:e[n]=i,i}return r}}function K(e,t,r,i){fr(e),he(e=e.v,0|e[T],t,r,i)}function he(e,t,r,i,n){const s=r+(n?0:-1);var a=e.length-1;if(a>=1+(n?0:-1)&&s>=a){const c=e[a];if(c!=null&&typeof c=="object"&&c.constructor===Object)return c[r]=i,t}return s<=a?(e[s]=i,t):(i!==void 0&&(r>=(a=(t??(t=0|e[T]))>>14&1023||536870912)?i!=null&&(e[a+(n?0:-1)]={[r]:i}):e[s]=i),t)}function $t(){return Ed===void 0?2:4}function zt(e,t,r,i,n){let s=e.v,a=0|s[T];i=Le(e,a)?1:i,n=!!n||i===3,i===2&&hr(e)&&(s=e.v,a=0|s[T]);let c=(e=Hn(s,t))===Bt?7:0|e[T],l=qn(c,a);var h=!(4&l);if(h){4&l&&(e=et(e),c=0,l=Ht(l,a),a=he(s,a,t,e));let u=0,f=0;for(;u<e.length;u++){const w=r(e[u]);w!=null&&(e[f++]=w)}f<u&&(e.length=f),r=-513&(4|l),l=r&=-1025,l&=-4097}return l!==c&&(ue(e,l),2&l&&Object.freeze(e)),Xo(e,l,s,a,t,i,h,n)}function Xo(e,t,r,i,n,s,a,c){let l=t;return s===1||s===4&&(2&t||!(16&t)&&32&i)?Wt(t)||((t|=!e.length||a&&!(4096&t)||32&i&&!(4096&t||16&t)?2:256)!==l&&ue(e,t),Object.freeze(e)):(s===2&&Wt(t)&&(e=et(e),l=0,t=Ht(t,i),i=he(r,i,n,e)),Wt(t)||(c||(t|=16),t!==l&&ue(e,t))),2&t||!(4096&t||16&t)||jt(r,i),e}function Hn(e,t,r){return e=gt(e,t,r),Array.isArray(e)?e:Bt}function qn(e,t){return 2&t&&(e|=2),1|e}function Wt(e){return!!(2&e)&&!!(4&e)||!!(256&e)}function Qo(e){return In(e,!0)}function Jo(e){e=et(e);for(let t=0;t<e.length;t++){const r=e[t]=et(e[t]);Array.isArray(r[1])&&(r[1]=qr(r[1]))}return Kr(e)}function Et(e,t,r,i){fr(e),he(e=e.v,0|e[T],t,(i==="0"?Number(r)===0:r===i)?void 0:r)}function wr(e,t,r){if(2&t)throw Error();const i=ar(t);let n=Hn(e,r,i),s=n===Bt?7:0|n[T],a=qn(s,t);return(2&a||Wt(a)||16&a)&&(a===s||Wt(a)||ue(n,a),n=et(n),s=0,a=Ht(a,t),he(e,t,r,n,i)),a&=-13,a!==s&&ue(n,a),n}function Kn(e,t){var r=ic;return Xn(Yn(e=e.v),e,void 0,r)===t?t:-1}function Yn(e){if(nr)return e[Wr]??(e[Wr]=new Map);if(Wr in e)return e[Wr];const t=new Map;return Object.defineProperty(e,Wr,{value:t}),t}function Zo(e,t,r,i,n){const s=Yn(e),a=Xn(s,e,t,r,n);return a!==i&&(a&&(t=he(e,t,a,void 0,n)),s.set(r,i)),t}function Xn(e,t,r,i,n){let s=e.get(i);if(s!=null)return s;s=0;for(let a=0;a<i.length;a++){const c=i[a];gt(t,c,n)!=null&&(s!==0&&(r=he(t,r,s,void 0,n)),s=c)}return e.set(i,s),s}function Qn(e,t,r){let i=0|e[T];const n=ar(i),s=gt(e,r,n);let a;if(s!=null&&s[sr]===or){if(!Le(s))return hr(s),s.v;a=s.v}else Array.isArray(s)&&(a=s);if(a){const c=0|a[T];2&c&&(a=ur(a,c))}return a=Gt(a,t),a!==s&&he(e,i,r,a,n),a}function Ro(e,t,r,i,n){let s=!1;if((i=gt(e,i,n,a=>{const c=Un(a,r,!1,t);return s=c!==a&&c!=null,c}))!=null)return s&&!Le(i)&&jt(e,t),i}function W(e,t,r,i){let n=e.v,s=0|n[T];if((t=Ro(n,s,t,r,i))==null)return t;if(s=0|n[T],!Le(e,s)){const a=zn(t);a!==t&&(hr(e)&&(n=e.v,s=0|n[T]),s=he(n,s,r,t=a,i),jt(n,s))}return t}function ea(e,t,r,i,n,s,a,c){var l=Le(e,r);s=l?1:s,a=!!a||s===3,l=c&&!l,(s===2||l)&&hr(e)&&(r=0|(t=e.v)[T]);var h=(e=Hn(t,n))===Bt?7:0|e[T],u=qn(h,r);if(c=!(4&u)){var f=e,w=r;const g=!!(2&u);g&&(w|=2);let p=!g,y=!0,b=0,m=0;for(;b<f.length;b++){const v=Un(f[b],i,!1,w);if(v instanceof i){if(!g){const _=Le(v);p&&(p=!_),y&&(y=_)}f[m++]=v}}m<b&&(f.length=m),u|=4,u=y?-4097&u:4096|u,u=p?8|u:-9&u}if(u!==h&&(ue(e,u),2&u&&Object.freeze(e)),l&&!(8&u||!e.length&&(s===1||s===4&&(2&u||!(16&u)&&32&r)))){for(Wt(u)&&(e=et(e),u=Ht(u,r),r=he(t,r,n,e)),i=e,l=u,h=0;h<i.length;h++)(f=i[h])!==(u=zn(f))&&(i[h]=u);l|=8,ue(e,u=l=i.length?4096|l:-4097&l)}return Xo(e,u,t,r,n,s,c,a)}function pt(e,t,r){const i=e.v;return ea(e,i,0|i[T],t,r,$t(),!1,!0)}function ta(e){return e==null&&(e=void 0),e}function L(e,t,r,i,n){return K(e,r,i=ta(i),n),i&&!Le(i)&&jt(e.v),e}function ti(e,t,r,i){e:{var n=i=ta(i);fr(e);const s=e.v;let a=0|s[T];if(n==null){const c=Yn(s);if(Xn(c,s,a,r)!==t)break e;c.set(r,0)}else a=Zo(s,a,r,t);he(s,a,t,n)}i&&!Le(i)&&jt(e.v)}function Ht(e,t){return-273&(2&t?2|e:-3&e)}function Jn(e,t,r,i){var n=i;fr(e),e=ea(e,i=e.v,0|i[T],r,t,2,!0),n=n??new r,e.push(n),t=r=e===Bt?7:0|e[T],(n=Le(n))?(r&=-9,e.length===1&&(r&=-4097)):r|=4096,r!==t&&ue(e,r),n||jt(i)}function qe(e,t,r){return dr(Q(e,t,void 0,r))}function ra(e){return(Sn?Q(e,2,void 0,void 0,Ii):Ii(Q(e,2)))??Xd}function se(e,t){return Q(e,t,void 0,void 0,ot)??0}function mt(e,t,r){if(r!=null){if(typeof r!="number"||!Ni(r))throw Tn("int32");r|=0}K(e,t,r)}function F(e,t,r){K(e,t,Qr(r))}function De(e,t,r){Et(e,t,Rr(r),"")}function Di(e,t,r){{fr(e);const a=e.v;let c=0|a[T];if(r==null)he(a,c,t);else{var i=e=r===Bt?7:0|r[T],n=Wt(e),s=n||Object.isFrozen(r);for(n||(e=0),s||(r=et(r),i=0,e=Ht(e,c),s=!1),e|=5,e|=(4&e?512&e?512:1024&e?1024:0:void 0)??(Sn?1024:0),n=0;n<r.length;n++){const l=r[n],h=$o(l);Object.is(l,h)||(s&&(r=et(r),i=0,e=Ht(e,c),s=!1),r[n]=h)}e!==i&&(s&&(r=et(r),e=Ht(e,c)),ue(r,e)),he(a,c,t,r)}}}function Pi(e,t,r){fr(e),zt(e,t,xe,2,!0).push($o(r))}var gr=class{constructor(e,t,r){if(this.buffer=e,r&&!t)throw Error();this.g=t}};function Zn(e,t){if(typeof e=="string")return new gr(vo(e),t);if(Array.isArray(e))return new gr(new Uint8Array(e),t);if(e.constructor===Uint8Array)return new gr(e,!1);if(e.constructor===ArrayBuffer)return e=new Uint8Array(e),new gr(e,!1);if(e.constructor===nt)return t=Cn(e)||new Uint8Array(0),new gr(t,!0,e);if(e instanceof Uint8Array)return e=e.constructor===Uint8Array?e:new Uint8Array(e.buffer,e.byteOffset,e.byteLength),new gr(e,!1);throw Error()}function pr(e,t){let r,i=0,n=0,s=0;const a=e.h;let c=e.g;do r=a[c++],i|=(127&r)<<s,s+=7;while(s<32&&128&r);if(s>32)for(n|=(127&r)>>4,s=3;s<32&&128&r;s+=7)r=a[c++],n|=(127&r)<<s;if(qt(e,c),!(128&r))return t(i>>>0,n>>>0);throw Error()}function Rn(e){let t=0,r=e.g;const i=r+10,n=e.h;for(;r<i;){const s=n[r++];if(t|=s,(128&s)==0)return qt(e,r),!!(127&t)}throw Error()}function _t(e){const t=e.h;let r=e.g,i=t[r++],n=127&i;if(128&i&&(i=t[r++],n|=(127&i)<<7,128&i&&(i=t[r++],n|=(127&i)<<14,128&i&&(i=t[r++],n|=(127&i)<<21,128&i&&(i=t[r++],n|=i<<28,128&i&&128&t[r++]&&128&t[r++]&&128&t[r++]&&128&t[r++]&&128&t[r++])))))throw Error();return qt(e,r),n}function yt(e){return _t(e)>>>0}function Oi(e){var t=e.h;const r=e.g;var i=t[r],n=t[r+1];const s=t[r+2];return t=t[r+3],qt(e,e.g+4),e=2*((n=(i<<0|n<<8|s<<16|t<<24)>>>0)>>31)+1,i=n>>>23&255,n&=8388607,i==255?n?NaN:e*(1/0):i==0?1401298464324817e-60*e*n:e*Math.pow(2,i-150)*(n+8388608)}function Qd(e){return _t(e)}function qt(e,t){if(e.g=t,t>e.l)throw Error()}function ia(e,t){if(t<0)throw Error();const r=e.g;if((t=r+t)>e.l)throw Error();return e.g=t,r}function na(e,t){if(t==0)return Ot();var r=ia(e,t);return e.Y&&e.j?r=e.h.subarray(r,r+t):(e=e.h,r=r===(t=r+t)?new Uint8Array(0):Nd?e.slice(r,t):new Uint8Array(e.subarray(r,t))),r.length==0?Ot():new nt(r,tr)}var sa=[];function oa(e,t,r,i){if(Vi.length){const n=Vi.pop();return n.o(i),n.g.init(e,t,r,i),n}return new Jd(e,t,r,i)}function aa(e){e.g.clear(),e.l=-1,e.h=-1,Vi.length<100&&Vi.push(e)}function ca(e){var t=e.g;if(t.g==t.l)return!1;e.m=e.g.g;var r=yt(e.g);if(t=r>>>3,!((r&=7)>=0&&r<=5)||t<1)throw Error();return e.l=t,e.h=r,!0}function Bi(e){switch(e.h){case 0:e.h!=0?Bi(e):Rn(e.g);break;case 1:qt(e=e.g,e.g+8);break;case 2:if(e.h!=2)Bi(e);else{var t=yt(e.g);qt(e=e.g,e.g+t)}break;case 5:qt(e=e.g,e.g+4);break;case 3:for(t=e.l;;){if(!ca(e))throw Error();if(e.h==4){if(e.l!=t)throw Error();break}Bi(e)}break;default:throw Error()}}function ri(e,t,r){const i=e.g.l;var n=yt(e.g);let s=(n=e.g.g+n)-i;if(s<=0&&(e.g.l=n,r(t,e,void 0,void 0,void 0),s=n-e.g.g),s)throw Error();return e.g.g=n,e.g.l=i,t}function es(e){var t=yt(e.g),r=ia(e=e.g,t);if(e=e.h,cd){var i,n=e;(i=En)||(i=En=new TextDecoder("utf-8",{fatal:!0})),t=r+t,n=r===0&&t===n.length?n:n.subarray(r,t);try{var s=i.decode(n)}catch(c){if(ki===void 0){try{i.decode(new Uint8Array([128]))}catch{}try{i.decode(new Uint8Array([97])),ki=!0}catch{ki=!1}}throw!ki&&(En=void 0),c}}else{t=(s=r)+t,r=[];let c,l=null;for(;s<t;){var a=e[s++];a<128?r.push(a):a<224?s>=t?Pt():(c=e[s++],a<194||(192&c)!=128?(s--,Pt()):r.push((31&a)<<6|63&c)):a<240?s>=t-1?Pt():(c=e[s++],(192&c)!=128||a===224&&c<160||a===237&&c>=160||(192&(i=e[s++]))!=128?(s--,Pt()):r.push((15&a)<<12|(63&c)<<6|63&i)):a<=244?s>=t-2?Pt():(c=e[s++],(192&c)!=128||c-144+(a<<28)>>30||(192&(i=e[s++]))!=128||(192&(n=e[s++]))!=128?(s--,Pt()):(a=(7&a)<<18|(63&c)<<12|(63&i)<<6|63&n,a-=65536,r.push(55296+(a>>10&1023),56320+(1023&a)))):Pt(),r.length>=8192&&(l=lo(l,r),r.length=0)}s=lo(l,r)}return s}function la(e){const t=yt(e.g);return na(e.g,t)}function Ui(e,t,r){var i=yt(e.g);for(i=e.g.g+i;e.g.g<i;)r.push(t(e.g))}var Jd=class{constructor(e,t,r,i){if(sa.length){const n=sa.pop();n.init(e,t,r,i),e=n}else e=new class{constructor(n,s,a,c){this.h=null,this.j=!1,this.g=this.l=this.m=0,this.init(n,s,a,c)}init(n,s,a,{Y:c=!1,ea:l=!1}={}){this.Y=c,this.ea=l,n&&(n=Zn(n,this.ea),this.h=n.buffer,this.j=n.g,this.m=s||0,this.l=a!==void 0?this.m+a:this.h.length,this.g=this.m)}clear(){this.h=null,this.j=!1,this.g=this.l=this.m=0,this.Y=!1}}(e,t,r,i);this.g=e,this.m=this.g.g,this.h=this.l=-1,this.o(i)}o({ha:e=!1}={}){this.ha=e}},Vi=[];function da(e){return e?/^\d+$/.test(e)?(Ti(e),new ts(ee,ce)):null:Zd||(Zd=new ts(0,0))}var ts=class{constructor(e,t){this.h=e>>>0,this.g=t>>>0}};let Zd;function ua(e){return e?/^-?\d+$/.test(e)?(Ti(e),new rs(ee,ce)):null:Rd||(Rd=new rs(0,0))}var rs=class{constructor(e,t){this.h=e>>>0,this.g=t>>>0}};let Rd;function mr(e,t,r){for(;r>0||t>127;)e.g.push(127&t|128),t=(t>>>7|r<<25)>>>0,r>>>=7;e.g.push(t)}function yr(e,t){for(;t>127;)e.g.push(127&t|128),t>>>=7;e.g.push(t)}function Gi(e,t){if(t>=0)yr(e,t);else{for(let r=0;r<9;r++)e.g.push(127&t|128),t>>=7;e.g.push(1)}}function is(e){var t=ee;e.g.push(t>>>0&255),e.g.push(t>>>8&255),e.g.push(t>>>16&255),e.g.push(t>>>24&255)}function br(e,t){t.length!==0&&(e.l.push(t),e.h+=t.length)}function Ke(e,t,r){yr(e.g,8*t+r)}function ns(e,t){return Ke(e,t,2),t=e.g.end(),br(e,t),t.push(e.h),t}function ss(e,t){var r=t.pop();for(r=e.h+e.g.length()-r;r>127;)t.push(127&r|128),r>>>=7,e.h++;t.push(r),e.h++}function ji(e,t,r){Ke(e,t,2),yr(e.g,r.length),br(e,e.g.end()),br(e,r)}function $i(e,t,r,i){r!=null&&(t=ns(e,t),i(r,e),ss(e,t))}function at(){const e=class{constructor(){throw Error()}};return Object.setPrototypeOf(e,e.prototype),e}var os=at(),ha=at(),as=at(),cs=at(),fa=at(),wa=at(),eu=at(),zi=at(),ga=at(),pa=at();function ct(e,t,r){var i=e.v;Fe&&Fe in i&&(i=i[Fe])&&delete i[t.g],t.h?t.j(e,t.h,t.g,r,t.l):t.j(e,t.g,r,t.l)}var N=class{constructor(e,t){this.v=qo(e,t,void 0,2048)}toJSON(){return Ho(this)}j(){var n;var e=Ou,t=this.v,r=e.g,i=Fe;if(nr&&i&&((n=t[i])==null?void 0:n[r])!=null&&rr(bd,3),t=e.g,ko&&Fe&&ko===void 0&&(i=(r=this.v)[Fe])&&(i=i.da))try{i(r,t,zd)}catch(s){ho(s)}return e.h?e.m(this,e.h,e.g,e.l):e.m(this,e.g,e.defaultValue,e.l)}clone(){const e=this.v,t=0|e[T];return Wn(this,e,t)?$n(this,e,!0):new this.constructor(ur(e,t,!1))}};N.prototype[sr]=or,N.prototype.toString=function(){return this.v.toString()};var vr=class{constructor(e,t,r){this.g=e,this.h=t,e=os,this.l=!!e&&r===e||!1}};function Wi(e,t){return new vr(e,t,os)}function ma(e,t,r,i,n){$i(e,r,_a(t,i),n)}const tu=Wi(function(e,t,r,i,n){return e.h===2&&(ri(e,Qn(t,i,r),n),!0)},ma),ru=Wi(function(e,t,r,i,n){return e.h===2&&(ri(e,Qn(t,i,r),n),!0)},ma);var Hi=Symbol(),qi=Symbol(),ls=Symbol(),ya=Symbol(),ba=Symbol();let va,xa;function Kt(e,t,r,i){var n=i[e];if(n)return n;(n={}).qa=i,n.T=function(f){switch(typeof f){case"boolean":return qd||(qd=[0,void 0,!0]);case"number":return f>0?void 0:f===0?Kd||(Kd=[0,void 0]):[-f,void 0];case"string":return[0,f];case"object":return f}}(i[0]);var s=i[1];let a=1;s&&s.constructor===Object&&(n.ba=s,typeof(s=i[++a])=="function"&&(n.ma=!0,va??(va=s),xa??(xa=i[a+1]),s=i[a+=2]));const c={};for(;s&&Array.isArray(s)&&s.length&&typeof s[0]=="number"&&s[0]>0;){for(var l=0;l<s.length;l++)c[s[l]]=s;s=i[++a]}for(l=1;s!==void 0;){let f;typeof s=="number"&&(l+=s,s=i[++a]);var h=void 0;if(s instanceof vr?f=s:(f=tu,a--),f==null?void 0:f.l){s=i[++a],h=i;var u=a;typeof s=="function"&&(s=s(),h[u]=s),h=s}for(u=l+1,typeof(s=i[++a])=="number"&&s<0&&(u-=s,s=i[++a]);l<u;l++){const w=c[l];h?r(n,l,f,h,w):t(n,l,f,w)}}return i[e]=n}function Ea(e){return Array.isArray(e)?e[0]instanceof vr?e:[ru,e]:[e,void 0]}function _a(e,t){return e instanceof N?e.v:Array.isArray(e)?Gt(e,t):void 0}function ds(e,t,r,i){const n=r.g;e[t]=i?(s,a,c)=>n(s,a,c,i):n}function us(e,t,r,i,n){const s=r.g;let a,c;e[t]=(l,h,u)=>s(l,h,u,c||(c=Kt(qi,ds,us,i).T),a||(a=hs(i)),n)}function hs(e){let t=e[ls];if(t!=null)return t;const r=Kt(qi,ds,us,e);return t=r.ma?(i,n)=>va(i,n,r):(i,n)=>{for(;ca(n)&&n.h!=4;){var s=n.l,a=r[s];if(a==null){var c=r.ba;c&&(c=c[s])&&(c=nu(c))!=null&&(a=r[s]=c)}if(a==null||!a(n,i,s)){if(a=(c=n).m,Bi(c),c.ha)var l=void 0;else l=c.g.g-a,c.g.g=a,l=na(c.g,l);a=void 0,c=i,l&&((a=c[Fe]??(c[Fe]=new jn))[s]??(a[s]=[])).push(l)}}return(i=Fi(i))&&(i.da=r.qa[ba]),!0},e[ls]=t,e[ba]=iu.bind(e),t}function iu(e,t,r,i){var n=this[qi];const s=this[ls],a=Gt(void 0,n.T),c=Fi(e);if(c){var l=!1,h=n.ba;if(h){if(n=(u,f,w)=>{if(w.length!==0)if(h[f])for(const g of w){u=oa(g);try{l=!0,s(a,u)}finally{aa(u)}}else i==null||i(e,f,w)},t==null)Li(c,n);else if(c!=null){const u=c[t];u&&n(c,t,u)}if(l){let u=0|e[T];if(2&u&&2048&u&&!(r!=null&&r.Ka))throw Error();const f=ar(u),w=(g,p)=>{if(gt(e,g,f)!=null){if((r==null?void 0:r.Qa)===1)return;throw Error()}p!=null&&(u=he(e,u,g,p,f)),delete c[g]};t==null?No(a,0|a[T],(g,p)=>{w(g,p)}):w(t,gt(a,t,f))}}}}function nu(e){const t=(e=Ea(e))[0].g;if(e=e[1]){const r=hs(e),i=Kt(qi,ds,us,e).T;return(n,s,a)=>t(n,s,a,i,r)}return t}function Ki(e,t,r){e[t]=r.h}function Yi(e,t,r,i){let n,s;const a=r.h;e[t]=(c,l,h)=>a(c,l,h,s||(s=Kt(Hi,Ki,Yi,i).T),n||(n=ka(i)))}function ka(e){let t=e[ya];if(!t){const r=Kt(Hi,Ki,Yi,e);t=(i,n)=>Sa(i,n,r),e[ya]=t}return t}function Sa(e,t,r){No(e,0|e[T],(i,n)=>{if(n!=null){var s=function(a,c){var l=a[c];if(l)return l;if((l=a.ba)&&(l=l[c])){var h=(l=Ea(l))[0].h;if(l=l[1]){const u=ka(l),f=Kt(Hi,Ki,Yi,l).T;l=a.ma?xa(f,u):(w,g,p)=>h(w,g,p,f,u)}else l=h;return a[c]=l}}(r,i);s?s(t,n,i):i<500||rr(Nn,3)}}),(e=Fi(e))&&Li(e,(i,n,s)=>{for(br(t,t.g.end()),i=0;i<s.length;i++)br(t,Cn(s[i])||new Uint8Array(0))})}const su=Me(0);function xr(e,t){if(Array.isArray(t)){var r=0|t[T];if(4&r)return t;for(var i=0,n=0;i<t.length;i++){const s=e(t[i]);s!=null&&(t[n++]=s)}return n<i&&(t.length=n),(e=-1537&(5|r))!==r&&ue(t,e),2&e&&Object.freeze(t),t}}function Se(e,t,r){return new vr(e,t,r)}function Er(e,t,r){return new vr(e,t,r)}function ge(e,t,r){he(e,0|e[T],t,r,ar(0|e[T]))}var ou=Wi(function(e,t,r,i,n){if(e.h!==2)return!1;if(e=et(e=ri(e,Gt([void 0,void 0],i),n)),n=ar(i=0|t[T]),2&i)throw Error();let s=gt(t,r,n);if(s instanceof wt)2&s.J?(s=s.V(),s.push(e),he(t,i,r,s,n)):s.Ma(e);else if(Array.isArray(s)){var a=0|s[T];8192&a||ue(s,a|=8192),2&a&&(s=Jo(s),he(t,i,r,s,n)),s.push(e)}else he(t,i,r,Kr([e]),n);return!0},function(e,t,r,i,n){if(t instanceof wt)t.forEach((s,a)=>{$i(e,r,Gt([a,s],i),n)});else if(Array.isArray(t)){for(let s=0;s<t.length;s++){const a=t[s];Array.isArray(a)&&$i(e,r,Gt(a,i),n)}Kr(t)}});function Aa(e,t,r){(t=ot(t))!=null&&(Ke(e,r,5),e=e.g,Ln(t),is(e))}function Ca(e,t,r){if(t=function(i){if(i==null)return i;const n=typeof i;if(n==="bigint")return String(Xr(64,i));if(Zr(i)){if(n==="string")return Vo(i);if(n==="number")return Bn(i)}}(t),t!=null&&(typeof t=="string"&&ua(t),t!=null))switch(Ke(e,r,0),typeof t){case"number":e=e.g,cr(t),mr(e,ee,ce);break;case"bigint":r=BigInt.asUintN(64,t),r=new rs(Number(r&BigInt(4294967295)),Number(r>>BigInt(32))),mr(e.g,r.h,r.g);break;default:r=ua(t),mr(e.g,r.h,r.g)}}function Ta(e,t,r){(t=dr(t))!=null&&t!=null&&(Ke(e,r,0),Gi(e.g,t))}function Na(e,t,r){(t=Oo(t))!=null&&(Ke(e,r,0),e.g.g.push(t?1:0))}function Ia(e,t,r){(t=xe(t))!=null&&ji(e,r,uo(t))}function Fa(e,t,r,i,n){$i(e,r,_a(t,i),n)}function La(e,t,r){(t=t==null||typeof t=="string"||t instanceof nt?t:void 0)!=null&&ji(e,r,Zn(t,!0).buffer)}function Ma(e,t,r){return(e.h===5||e.h===2)&&(t=wr(t,0|t[T],r),e.h==2?Ui(e,Oi,t):t.push(Oi(e.g)),!0)}var le=Se(function(e,t,r){return e.h===5&&(ge(t,r,Oi(e.g)),!0)},Aa,zi),au=Er(Ma,function(e,t,r){if((t=xr(ot,t))!=null)for(let a=0;a<t.length;a++){var i=e,n=r,s=t[a];s!=null&&(Ke(i,n,5),i=i.g,Ln(s),is(i))}},zi),fs=Er(Ma,function(e,t,r){if((t=xr(ot,t))!=null&&t.length){Ke(e,r,2),yr(e.g,4*t.length);for(let i=0;i<t.length;i++)r=e.g,Ln(t[i]),is(r)}},zi),cu=Se(function(e,t,r){return e.h===5&&(ge(t,r,(e=Oi(e.g))===0?void 0:e),!0)},Aa,zi),kt=Se(function(e,t,r){return kn?(e.h!==0?e=!1:(ge(t,r,pr(e.g,Do)),e=!0),e):e.h===0&&(ge(t,r,pr(e.g,Dn)),!0)},Ca,wa),ws=Se(function(e,t,r){return kn?(e.h!==0?t=!1:(ge(t,r,(e=pr(e.g,Do))===su?void 0:e),t=!0),t):e.h===0&&(ge(t,r,(e=pr(e.g,Dn))===0?void 0:e),!0)},Ca,wa),lu=Se(function(e,t,r){return kn?(e.h!==0?e=!1:(ge(t,r,pr(e.g,Fd)),e=!0),e):e.h===0&&(ge(t,r,pr(e.g,Mn)),!0)},function(e,t,r){if(t=function(i){if(i==null)return i;var n=typeof i;if(n==="bigint")return String(Ld(64,i));if(Zr(i)){if(n==="string")return n=lr(Number(i)),Vt(n)&&n>=0?i=String(n):((n=i.indexOf("."))!==-1&&(i=i.substring(0,n)),(n=i[0]!=="-"&&((n=i.length)<20||n===20&&i<="18446744073709551615"))||(Ti(i),i=Yr(ee,ce))),i;if(n==="number")return(i=lr(i))>=0&&Vt(i)||(cr(i),i=Mn(ee,ce)),i}}(t),t!=null&&(typeof t=="string"&&da(t),t!=null))switch(Ke(e,r,0),typeof t){case"number":e=e.g,cr(t),mr(e,ee,ce);break;case"bigint":r=BigInt.asUintN(64,t),r=new ts(Number(r&BigInt(4294967295)),Number(r>>BigInt(32))),mr(e.g,r.h,r.g);break;default:r=da(t),mr(e.g,r.h,r.g)}},eu),pe=Se(function(e,t,r){return e.h===0&&(ge(t,r,_t(e.g)),!0)},Ta,cs),ii=Er(function(e,t,r){return(e.h===0||e.h===2)&&(t=wr(t,0|t[T],r),e.h==2?Ui(e,_t,t):t.push(_t(e.g)),!0)},function(e,t,r){if((t=xr(dr,t))!=null&&t.length){r=ns(e,r);for(let i=0;i<t.length;i++)Gi(e.g,t[i]);ss(e,r)}},cs),_r=Se(function(e,t,r){return e.h===0&&(ge(t,r,(e=_t(e.g))===0?void 0:e),!0)},Ta,cs),oe=Se(function(e,t,r){return e.h===0&&(ge(t,r,Rn(e.g)),!0)},Na,ha),Yt=Se(function(e,t,r){return e.h===0&&(ge(t,r,(e=Rn(e.g))===!1?void 0:e),!0)},Na,ha),Ee=Er(function(e,t,r){return e.h===2&&(e=es(e),wr(t,0|t[T],r).push(e),!0)},function(e,t,r){if((t=xr(xe,t))!=null)for(let a=0;a<t.length;a++){var i=e,n=r,s=t[a];s!=null&&ji(i,n,uo(s))}},as),St=Se(function(e,t,r){return e.h===2&&(ge(t,r,(e=es(e))===""?void 0:e),!0)},Ia,as),X=Se(function(e,t,r){return e.h===2&&(ge(t,r,es(e)),!0)},Ia,as),me=function(e,t,r=os){return new vr(e,t,r)}(function(e,t,r,i,n){return e.h===2&&(i=Gt(void 0,i),wr(t,0|t[T],r).push(i),ri(e,i,n),!0)},function(e,t,r,i,n){if(Array.isArray(t)){for(let s=0;s<t.length;s++)Fa(e,t[s],r,i,n);1&(e=0|t[T])||ue(t,1|e)}}),ae=Wi(function(e,t,r,i,n,s){if(e.h!==2)return!1;let a=0|t[T];return Zo(t,a,s,r,ar(a)),ri(e,t=Qn(t,i,r),n),!0},Fa),Da=Se(function(e,t,r){return e.h===2&&(ge(t,r,la(e)),!0)},La,ga),du=Er(function(e,t,r){return(e.h===0||e.h===2)&&(t=wr(t,0|t[T],r),e.h==2?Ui(e,yt,t):t.push(yt(e.g)),!0)},function(e,t,r){if((t=xr(Bo,t))!=null)for(let a=0;a<t.length;a++){var i=e,n=r,s=t[a];s!=null&&(Ke(i,n,0),yr(i.g,s))}},fa),uu=Se(function(e,t,r){return e.h===0&&(ge(t,r,(e=yt(e.g))===0?void 0:e),!0)},function(e,t,r){(t=Bo(t))!=null&&t!=null&&(Ke(e,r,0),yr(e.g,t))},fa),Pe=Se(function(e,t,r){return e.h===0&&(ge(t,r,_t(e.g)),!0)},function(e,t,r){(t=dr(t))!=null&&(t=parseInt(t,10),Ke(e,r,0),Gi(e.g,t))},pa);class hu{constructor(t,r){var i=Oe;this.g=t,this.h=r,this.m=W,this.j=L,this.defaultValue=void 0,this.l=i.Oa!=null?Io:void 0}register(){Si(this)}}function lt(e,t){return new hu(e,t)}function At(e,t){return(r,i)=>{{const s={ea:!0};i&&Object.assign(s,i),r=oa(r,void 0,void 0,s);try{const a=new e,c=a.v;hs(t)(c,r);var n=a}finally{aa(r)}}return n}}function Xi(e){return function(){const t=new class{constructor(){this.l=[],this.h=0,this.g=new class{constructor(){this.g=[]}length(){return this.g.length}end(){const a=this.g;return this.g=[],a}}}};Sa(this.v,t,Kt(Hi,Ki,Yi,e)),br(t,t.g.end());const r=new Uint8Array(t.h),i=t.l,n=i.length;let s=0;for(let a=0;a<n;a++){const c=i[a];r.set(c,s),s+=c.length}return t.l=[r],r}}var Pa=class extends N{constructor(e){super(e)}},Oa=[0,St,Se(function(e,t,r){return e.h===2&&(ge(t,r,(e=la(e))===Ot()?void 0:e),!0)},function(e,t,r){if(t!=null){if(t instanceof N){const i=t.Ra;return void(i?(t=i(t),t!=null&&ji(e,r,Zn(t,!0).buffer)):rr(Nn,3))}if(Array.isArray(t))return void rr(Nn,3)}La(e,t,r)},ga)];let gs,Ba=globalThis.trustedTypes;function Ua(e){var t;return gs===void 0&&(gs=function(){let r=null;if(!Ba)return r;try{const i=n=>n;r=Ba.createPolicy("goog#html",{createHTML:i,createScript:i,createScriptURL:i})}catch{}return r}()),e=(t=gs)?t.createScriptURL(e):e,new class{constructor(r){this.g=r}toString(){return this.g+""}}(e)}function fu(e,...t){if(t.length===0)return Ua(e[0]);let r=e[0];for(let i=0;i<t.length;i++)r+=encodeURIComponent(t[i])+e[i+1];return Ua(r)}var Va=[0,pe,Pe,oe,-1,ii,Pe,-1,oe],wu=class extends N{constructor(e){super(e)}},Ga=[0,oe,X,oe,Pe,-1,Er(function(e,t,r){return(e.h===0||e.h===2)&&(t=wr(t,0|t[T],r),e.h==2?Ui(e,Qd,t):t.push(_t(e.g)),!0)},function(e,t,r){if((t=xr(dr,t))!=null&&t.length){r=ns(e,r);for(let i=0;i<t.length;i++)Gi(e.g,t[i]);ss(e,r)}},pa),X,-1,[0,oe,-1],Pe,oe,-1],ja=[0,3,oe,-1,2,[0,pe],[0,Pe,oe],[0,X,-1],[0]],$a=[0,X,-2],za=class extends N{constructor(e){super(e)}},Wa=[0],Ha=[0,pe,oe,1,oe,-4],Oe=class extends N{constructor(e){super(e,2)}},fe={};fe[336783863]=[0,X,oe,-1,pe,[0,[1,2,3,4,5,6,7,8,9],ae,Wa,ae,Ga,ae,$a,ae,Ha,ae,Va,ae,[0,X,-2],ae,[0,X,Pe],ae,ja,ae,[0,Pe,-1,oe]],[0,X],oe,[0,[1,3],[2,4],ae,[0,ii],-1,ae,[0,Ee],-1,me,[0,X,-1]],X];var qa=[0,ws,-1,Yt,-3,ws,ii,St,_r,ws,-1,Yt,_r,Yt,-2,St];function J(e,t){Pi(e,3,t)}function G(e,t){Pi(e,4,t)}var Te=class extends N{constructor(e){super(e,500)}o(e){return L(this,0,7,e)}},ni=[-1,{}],Ka=[0,X,1,ni],Ya=[0,X,Ee,ni];function Ye(e,t){Jn(e,1,Te,t)}function te(e,t){Pi(e,10,t)}function H(e,t){Pi(e,15,t)}var Be=class extends N{constructor(e){super(e,500)}o(e){return L(this,0,1001,e)}},Xa=[-500,me,[-500,St,-1,Ee,-3,[-2,fe,oe],me,Oa,_r,-1,Ka,Ya,me,[0,St,Yt],St,qa,_r,Ee,987,Ee],4,me,[-500,X,-1,[-1,{}],998,X],me,[-500,X,Ee,-1,[-2,{},oe],997,Ee,-1],_r,me,[-500,X,Ee,ni,998,Ee],Ee,_r,Ka,Ya,me,[0,St,-1,ni],Ee,-2,qa,St,-1,Yt,[0,Yt,uu],978,ni,me,Oa];Be.prototype.g=Xi(Xa);var gu=At(Be,Xa),pu=class extends N{constructor(e){super(e)}},Qa=class extends N{constructor(e){super(e)}g(){return pt(this,pu,1)}},Ja=[0,me,[0,pe,le,X,-1]],Qi=At(Qa,Ja),mu=class extends N{constructor(e){super(e)}},yu=class extends N{constructor(e){super(e)}},ps=class extends N{constructor(e){super(e)}l(){return W(this,mu,2)}g(){return pt(this,yu,5)}},Za=At(class extends N{constructor(e){super(e)}},[0,Ee,ii,fs,[0,Pe,[0,pe,-3],[0,le,-3],[0,pe,-1,[0,me,[0,pe,-2]]],me,[0,le,-1,X,le]],X,-1,kt,me,[0,pe,le],Ee,kt]),Ra=class extends N{constructor(e){super(e)}},kr=At(class extends N{constructor(e){super(e)}},[0,me,[0,le,-4]]),ec=class extends N{constructor(e){super(e)}},si=At(class extends N{constructor(e){super(e)}},[0,me,[0,le,-4]]),bu=class extends N{constructor(e){super(e)}},vu=[0,pe,-1,fs,Pe],tc=class extends N{constructor(e){super(e)}};tc.prototype.g=Xi([0,le,-4,kt]);var xu=class extends N{constructor(e){super(e)}},Eu=At(class extends N{constructor(e){super(e)}},[0,me,[0,1,pe,X,Ja],kt]),rc=class extends N{constructor(e){super(e)}},_u=class extends N{constructor(e){super(e)}na(){const e=Q(this,1,void 0,void 0,Qo);return e??Ot()}},ku=class extends N{constructor(e){super(e)}},ic=[1,2],Su=At(class extends N{constructor(e){super(e)}},[0,me,[0,ic,ae,[0,fs],ae,[0,Da],pe,X],kt]),ms=class extends N{constructor(e){super(e)}},nc=[0,X,pe,le,Ee,-1],sc=class extends N{constructor(e){super(e)}},Au=[0,oe,-1],oc=class extends N{constructor(e){super(e)}},Ji=[1,2,3,4,5,6],Zi=class extends N{constructor(e){super(e)}g(){return Q(this,1,void 0,void 0,Qo)!=null}l(){return xe(Q(this,2))!=null}},ie=class extends N{constructor(e){super(e)}g(){return Oo(Q(this,2))??!1}},ac=[0,Da,X,[0,pe,kt,-1],[0,lu,kt]],de=[0,ac,oe,[0,Ji,ae,Ha,ae,Ga,ae,Va,ae,Wa,ae,$a,ae,ja],Pe],Ri=class extends N{constructor(e){super(e)}},ys=[0,de,le,-1,pe],Cu=lt(502141897,Ri);fe[502141897]=ys;var Tu=At(class extends N{constructor(e){super(e)}},[0,[0,Pe,-1,au,du],vu]),cc=class extends N{constructor(e){super(e)}},lc=class extends N{constructor(e){super(e)}},bs=[0,de,le,[0,de],oe],Nu=lt(508968150,lc);fe[508968150]=[0,de,ys,bs,le,[0,[0,ac]]],fe[508968149]=bs;var Sr=class extends N{constructor(e){super(e)}l(){return W(this,ms,2)}g(){K(this,2)}},dc=[0,de,nc];fe[478825465]=dc;var Iu=class extends N{constructor(e){super(e)}},uc=class extends N{constructor(e){super(e)}},vs=class extends N{constructor(e){super(e)}},xs=class extends N{constructor(e){super(e)}},hc=class extends N{constructor(e){super(e)}},fc=[0,de,[0,de],dc,-1],wc=[0,de,le,pe],Es=[0,de,le],gc=[0,de,wc,Es,le],Fu=lt(479097054,hc);fe[479097054]=[0,de,gc,fc],fe[463370452]=fc,fe[464864288]=wc;var Lu=lt(462713202,xs);fe[462713202]=gc,fe[474472470]=Es;var Mu=class extends N{constructor(e){super(e)}},pc=class extends N{constructor(e){super(e)}},mc=class extends N{constructor(e){super(e)}},yc=class extends N{constructor(e){super(e)}},_s=[0,de,le,-1,pe],ks=[0,de,le,oe];yc.prototype.g=Xi([0,de,Es,[0,de],ys,bs,_s,ks]);var bc=class extends N{constructor(e){super(e)}},Du=lt(456383383,bc);fe[456383383]=[0,de,nc];var vc=class extends N{constructor(e){super(e)}},Pu=lt(476348187,vc);fe[476348187]=[0,de,Au];var xc=class extends N{constructor(e){super(e)}},Ec=class extends N{constructor(e){super(e)}},_c=[0,Pe,-1],Ou=lt(458105876,class extends N{constructor(e){super(e)}g(){let e;var t=this.v;const r=0|t[T];return e=Le(this,r),t=function(i,n,s,a){var c=Ec;!a&&hr(i)&&(s=0|(n=i.v)[T]);var l=gt(n,2);if(i=!1,l==null){if(a)return Wo();l=[]}else if(l.constructor===wt){if(!(2&l.J)||a)return l;l=l.V()}else Array.isArray(l)?i=!!(2&(0|l[T])):l=[];if(a){if(!l.length)return Wo();i||(i=!0,qr(l))}else i&&(i=!1,Kr(l),l=Jo(l));return!i&&32&s&&Hr(l,32),s=he(n,s,2,a=new wt(l,c,Od,void 0)),i||jt(n,s),a}(this,t,r,e),!e&&Ec&&(t.ra=!0),t}});fe[458105876]=[0,_c,ou,[!0,kt,[0,X,-1,Ee]],[0,ii,oe,Pe]];var Ss=class extends N{constructor(e){super(e)}},kc=lt(458105758,Ss);fe[458105758]=[0,de,X,_c];var As=class extends N{constructor(e){super(e)}},Sc=[0,cu,-1,Yt],Bu=class extends N{constructor(e){super(e)}},Ac=class extends N{constructor(e){super(e)}},Cs=[1,2];Ac.prototype.g=Xi([0,Cs,ae,Sc,ae,[0,me,Sc]]);var Cc=class extends N{constructor(e){super(e)}},Uu=lt(443442058,Cc);fe[443442058]=[0,de,X,pe,le,Ee,-1,oe,le],fe[514774813]=_s;var Tc=class extends N{constructor(e){super(e)}},Vu=lt(516587230,Tc);function Ts(e,t){return t=t?t.clone():new ms,e.displayNamesLocale!==void 0?K(t,1,Rr(e.displayNamesLocale)):e.displayNamesLocale===void 0&&K(t,1),e.maxResults!==void 0?mt(t,2,e.maxResults):"maxResults"in e&&K(t,2),e.scoreThreshold!==void 0?F(t,3,e.scoreThreshold):"scoreThreshold"in e&&K(t,3),e.categoryAllowlist!==void 0?Di(t,4,e.categoryAllowlist):"categoryAllowlist"in e&&K(t,4),e.categoryDenylist!==void 0?Di(t,5,e.categoryDenylist):"categoryDenylist"in e&&K(t,5),t}function Nc(e){const t=Number(e);return Number.isSafeInteger(t)?t:String(e)}function Ns(e,t=-1,r=""){return{categories:e.map(i=>({index:qe(i,1)??0??-1,score:se(i,2)??0,categoryName:xe(Q(i,3))??""??"",displayName:xe(Q(i,4))??""??""})),headIndex:t,headName:r}}function Gu(e){const t={classifications:pt(e,xu,1).map(r=>{var i;return Ns(((i=W(r,Qa,4))==null?void 0:i.g())??[],qe(r,2)??0,xe(Q(r,3))??"")})};return function(r){return Pd(Sn?Q(r,2,void 0,void 0,Ii):Q(r,2))}(e)!=null&&(t.timestampMs=Nc(ra(e))),t}function Ic(e){var a,c;var t=zt(e,3,ot,$t()),r=zt(e,2,dr,$t()),i=zt(e,1,xe,$t()),n=zt(e,9,xe,$t());const s={categories:[],keypoints:[]};for(let l=0;l<t.length;l++)s.categories.push({score:t[l],index:r[l]??-1,categoryName:i[l]??"",displayName:n[l]??""});if((t=(a=W(e,ps,4))==null?void 0:a.l())&&(s.boundingBox={originX:qe(t,1,xt)??0,originY:qe(t,2,xt)??0,width:qe(t,3,xt)??0,height:qe(t,4,xt)??0,angle:0}),(c=W(e,ps,4))==null?void 0:c.g().length)for(const l of W(e,ps,4).g())s.keypoints.push({x:Q(l,1,void 0,xt,ot)??0,y:Q(l,2,void 0,xt,ot)??0,score:Q(l,4,void 0,xt,ot)??0,label:xe(Q(l,3,void 0,xt))??""});return s}function en(e){const t=[];for(const r of pt(e,ec,1))t.push({x:se(r,1)??0,y:se(r,2)??0,z:se(r,3)??0,visibility:se(r,4)??0});return t}function oi(e){const t=[];for(const r of pt(e,Ra,1))t.push({x:se(r,1)??0,y:se(r,2)??0,z:se(r,3)??0,visibility:se(r,4)??0});return t}function Fc(e){return Array.from(e,t=>t>127?t-256:t)}function Lc(e,t){if(e.length!==t.length)throw Error(`Cannot compute cosine similarity between embeddings of different sizes (${e.length} vs. ${t.length}).`);let r=0,i=0,n=0;for(let s=0;s<e.length;s++)r+=e[s]*t[s],i+=e[s]*e[s],n+=t[s]*t[s];if(i<=0||n<=0)throw Error("Cannot compute cosine similarity on embedding with 0 norm.");return r/Math.sqrt(i*n)}let tn;fe[516587230]=[0,de,_s,ks,le],fe[518928384]=ks;const ju=new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11]);async function Mc(){if(tn===void 0)try{await WebAssembly.instantiate(ju),tn=!0}catch{tn=!1}return tn}async function ai(e,t=fu``){const r=await Mc()?"wasm_internal":"wasm_nosimd_internal";return{wasmLoaderPath:`${t}/${e}_${r}.js`,wasmBinaryPath:`${t}/${e}_${r}.wasm`}}var Xt=class{};function Dc(){var e=navigator;return typeof OffscreenCanvas<"u"&&(!function(t=navigator){return(t=t.userAgent).includes("Safari")&&!t.includes("Chrome")}(e)||!!((e=e.userAgent.match(/Version\/([\d]+).*Safari/))&&e.length>=1&&Number(e[1])>=17))}async function Pc(e){if(typeof importScripts!="function"){const t=document.createElement("script");return t.src=e.toString(),t.crossOrigin="anonymous",new Promise((r,i)=>{t.addEventListener("load",()=>{r()},!1),t.addEventListener("error",n=>{i(n)},!1),document.body.appendChild(t)})}try{importScripts(e.toString())}catch(t){if(!(t instanceof TypeError))throw t;await self.import(e.toString())}}function Oc(e){return e.videoWidth!==void 0?[e.videoWidth,e.videoHeight]:e.naturalWidth!==void 0?[e.naturalWidth,e.naturalHeight]:e.displayWidth!==void 0?[e.displayWidth,e.displayHeight]:[e.width,e.height]}function I(e,t,r){e.m||console.error("No wasm multistream support detected: ensure dependency inclusion of :gl_graph_runner_internal_multi_input target"),r(t=e.i.stringToNewUTF8(t)),e.i._free(t)}function Bc(e,t,r){if(!e.i.canvas)throw Error("No OpenGL canvas configured.");if(r?e.i._bindTextureToStream(r):e.i._bindTextureToCanvas(),!(r=e.i.canvas.getContext("webgl2")||e.i.canvas.getContext("webgl")))throw Error("Failed to obtain WebGL context from the provided canvas. `getContext()` should only be invoked with `webgl` or `webgl2`.");e.i.gpuOriginForWebTexturesIsBottomLeft&&r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,!0),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,t),e.i.gpuOriginForWebTexturesIsBottomLeft&&r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,!1);const[i,n]=Oc(t);return!e.l||i===e.i.canvas.width&&n===e.i.canvas.height||(e.i.canvas.width=i,e.i.canvas.height=n),[i,n]}function Uc(e,t,r){e.m||console.error("No wasm multistream support detected: ensure dependency inclusion of :gl_graph_runner_internal_multi_input target");const i=new Uint32Array(t.length);for(let n=0;n<t.length;n++)i[n]=e.i.stringToNewUTF8(t[n]);t=e.i._malloc(4*i.length),e.i.HEAPU32.set(i,t>>2),r(t);for(const n of i)e.i._free(n);e.i._free(t)}function dt(e,t,r){e.i.simpleListeners=e.i.simpleListeners||{},e.i.simpleListeners[t]=r}function Ct(e,t,r){let i=[];e.i.simpleListeners=e.i.simpleListeners||{},e.i.simpleListeners[t]=(n,s,a)=>{s?(r(i,a),i=[]):i.push(n)}}Xt.forVisionTasks=function(e){return ai("vision",e)},Xt.forTextTasks=function(e){return ai("text",e)},Xt.forGenAiExperimentalTasks=function(e){return ai("genai_experimental",e)},Xt.forGenAiTasks=function(e){return ai("genai",e)},Xt.forAudioTasks=function(e){return ai("audio",e)},Xt.isSimdSupported=function(){return Mc()};async function $u(e,t,r,i){return e=await(async(n,s,a,c,l)=>{if(s&&await Pc(s),!self.ModuleFactory||a&&(await Pc(a),!self.ModuleFactory))throw Error("ModuleFactory not set.");return self.Module&&l&&((s=self.Module).locateFile=l.locateFile,l.mainScriptUrlOrBlob&&(s.mainScriptUrlOrBlob=l.mainScriptUrlOrBlob)),l=await self.ModuleFactory(self.Module||l),self.ModuleFactory=self.Module=void 0,new n(l,c)})(e,r.wasmLoaderPath,r.assetLoaderPath,t,{locateFile:n=>n.endsWith(".wasm")?r.wasmBinaryPath.toString():r.assetBinaryPath&&n.endsWith(".data")?r.assetBinaryPath.toString():n}),await e.o(i),e}function Is(e,t){const r=W(e.baseOptions,Zi,1)||new Zi;typeof t=="string"?(K(r,2,Rr(t)),K(r,1)):t instanceof Uint8Array&&(K(r,1,In(t,!1)),K(r,2)),L(e.baseOptions,0,1,r)}function Vc(e){try{const t=e.H.length;if(t===1)throw Error(e.H[0].message);if(t>1)throw Error("Encountered multiple errors: "+e.H.map(r=>r.message).join(", "))}finally{e.H=[]}}function C(e,t){e.C=Math.max(e.C,t)}function rn(e,t){e.B=new Te,De(e.B,2,"PassThroughCalculator"),J(e.B,"free_memory"),G(e.B,"free_memory_unused_out"),te(t,"free_memory"),Ye(t,e.B)}function Ar(e,t){J(e.B,t),G(e.B,t+"_unused_out")}function nn(e){e.g.addBoolToStream(!0,"free_memory",e.C)}var Fs=class{constructor(e){this.g=e,this.H=[],this.C=0,this.g.setAutoRenderToScreen(!1)}l(e,t=!0){var r,i,n,s,a,c;if(t){const l=e.baseOptions||{};if((r=e.baseOptions)!=null&&r.modelAssetBuffer&&((i=e.baseOptions)!=null&&i.modelAssetPath))throw Error("Cannot set both baseOptions.modelAssetPath and baseOptions.modelAssetBuffer");if(!((n=W(this.baseOptions,Zi,1))!=null&&n.g()||(s=W(this.baseOptions,Zi,1))!=null&&s.l()||(a=e.baseOptions)!=null&&a.modelAssetBuffer||(c=e.baseOptions)!=null&&c.modelAssetPath))throw Error("Either baseOptions.modelAssetPath or baseOptions.modelAssetBuffer must be set");if(function(h,u){let f=W(h.baseOptions,oc,3);if(!f){var w=f=new oc,g=new za;ti(w,4,Ji,g)}"delegate"in u&&(u.delegate==="GPU"?(u=f,w=new wu,ti(u,2,Ji,w)):(u=f,w=new za,ti(u,4,Ji,w))),L(h.baseOptions,0,3,f)}(this,l),l.modelAssetPath)return fetch(l.modelAssetPath.toString()).then(h=>{if(h.ok)return h.arrayBuffer();throw Error(`Failed to fetch model: ${l.modelAssetPath} (${h.status})`)}).then(h=>{try{this.g.i.FS_unlink("/model.dat")}catch{}this.g.i.FS_createDataFile("/","model.dat",new Uint8Array(h),!0,!1,!1),Is(this,"/model.dat"),this.m(),this.L()});if(l.modelAssetBuffer instanceof Uint8Array)Is(this,l.modelAssetBuffer);else if(l.modelAssetBuffer)return async function(h){const u=[];for(var f=0;;){const{done:w,value:g}=await h.read();if(w)break;u.push(g),f+=g.length}if(u.length===0)return new Uint8Array(0);if(u.length===1)return u[0];h=new Uint8Array(f),f=0;for(const w of u)h.set(w,f),f+=w.length;return h}(l.modelAssetBuffer).then(h=>{Is(this,h),this.m(),this.L()})}return this.m(),this.L(),Promise.resolve()}L(){}ca(){let e;if(this.g.ca(t=>{e=gu(t)}),!e)throw Error("Failed to retrieve CalculatorGraphConfig");return e}setGraph(e,t){this.g.attachErrorListener((r,i)=>{this.H.push(Error(i))}),this.g.Ja(),this.g.setGraph(e,t),this.B=void 0,Vc(this)}finishProcessing(){this.g.finishProcessing(),Vc(this)}close(){this.B=void 0,this.g.closeGraph()}};function Tt(e,t){if(!e)throw Error(`Unable to obtain required WebGL resource: ${t}`);return e}Fs.prototype.close=Fs.prototype.close;class zu{constructor(t,r,i,n){this.g=t,this.h=r,this.m=i,this.l=n}bind(){this.g.bindVertexArray(this.h)}close(){this.g.deleteVertexArray(this.h),this.g.deleteBuffer(this.m),this.g.deleteBuffer(this.l)}}function Gc(e,t,r){const i=e.g;if(r=Tt(i.createShader(r),"Failed to create WebGL shader"),i.shaderSource(r,t),i.compileShader(r),!i.getShaderParameter(r,i.COMPILE_STATUS))throw Error(`Could not compile WebGL shader: ${i.getShaderInfoLog(r)}`);return i.attachShader(e.h,r),r}function jc(e,t){const r=e.g,i=Tt(r.createVertexArray(),"Failed to create vertex array");r.bindVertexArray(i);const n=Tt(r.createBuffer(),"Failed to create buffer");r.bindBuffer(r.ARRAY_BUFFER,n),r.enableVertexAttribArray(e.O),r.vertexAttribPointer(e.O,2,r.FLOAT,!1,0,0),r.bufferData(r.ARRAY_BUFFER,new Float32Array([-1,-1,-1,1,1,1,1,-1]),r.STATIC_DRAW);const s=Tt(r.createBuffer(),"Failed to create buffer");return r.bindBuffer(r.ARRAY_BUFFER,s),r.enableVertexAttribArray(e.L),r.vertexAttribPointer(e.L,2,r.FLOAT,!1,0,0),r.bufferData(r.ARRAY_BUFFER,new Float32Array(t?[0,1,0,0,1,0,1,1]:[0,0,0,1,1,1,1,0]),r.STATIC_DRAW),r.bindBuffer(r.ARRAY_BUFFER,null),r.bindVertexArray(null),new zu(r,i,n,s)}function Ls(e,t){if(e.g){if(t!==e.g)throw Error("Cannot change GL context once initialized")}else e.g=t}function Wu(e,t,r,i){return Ls(e,t),e.h||(e.m(),e.D()),r?(e.u||(e.u=jc(e,!0)),r=e.u):(e.A||(e.A=jc(e,!1)),r=e.A),t.useProgram(e.h),r.bind(),e.l(),e=i(),r.g.bindVertexArray(null),e}function $c(e,t,r){return Ls(e,t),e=Tt(t.createTexture(),"Failed to create texture"),t.bindTexture(t.TEXTURE_2D,e),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,r??t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,r??t.LINEAR),t.bindTexture(t.TEXTURE_2D,null),e}function zc(e,t,r){Ls(e,t),e.B||(e.B=Tt(t.createFramebuffer(),"Failed to create framebuffe.")),t.bindFramebuffer(t.FRAMEBUFFER,e.B),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,r,0)}function Hu(e){var t;(t=e.g)==null||t.bindFramebuffer(e.g.FRAMEBUFFER,null)}var Wc=class{H(){return`
|
|
2
2
|
precision mediump float;
|
|
3
3
|
varying vec2 vTex;
|
|
4
4
|
uniform sampler2D inputTexture;
|
|
5
5
|
void main() {
|
|
6
6
|
gl_FragColor = texture2D(inputTexture, vTex);
|
|
7
7
|
}
|
|
8
|
-
`}m(){const e=this.g;if(this.h=Tt(e.createProgram(),"Failed to create WebGL program"),this.X=
|
|
8
|
+
`}m(){const e=this.g;if(this.h=Tt(e.createProgram(),"Failed to create WebGL program"),this.X=Gc(this,`
|
|
9
9
|
attribute vec2 aVertex;
|
|
10
10
|
attribute vec2 aTex;
|
|
11
11
|
varying vec2 vTex;
|
|
12
12
|
void main(void) {
|
|
13
13
|
gl_Position = vec4(aVertex, 0.0, 1.0);
|
|
14
14
|
vTex = aTex;
|
|
15
|
-
}`,e.VERTEX_SHADER),this.W=Vc(this,this.H(),e.FRAGMENT_SHADER),e.linkProgram(this.h),!e.getProgramParameter(this.h,e.LINK_STATUS))throw Error(`Error during program linking: ${e.getProgramInfoLog(this.h)}`);this.O=e.getAttribLocation(this.h,"aVertex"),this.L=e.getAttribLocation(this.h,"aTex")}D(){}l(){}close(){if(this.h){const e=this.g;e.deleteProgram(this.h),e.deleteShader(this.X),e.deleteShader(this.W)}this.B&&this.g.deleteFramebuffer(this.B),this.A&&this.A.close(),this.u&&this.u.close()}};function vt(e,t){switch(t){case 0:return e.g.find(r=>r instanceof Uint8Array);case 1:return e.g.find(r=>r instanceof Float32Array);case 2:return e.g.find(r=>typeof WebGLTexture<"u"&&r instanceof WebGLTexture);default:throw Error(`Type is not supported: ${t}`)}}function Ls(e){var t=vt(e,1);if(!t){if(t=vt(e,0))t=new Float32Array(t).map(i=>i/255);else{t=new Float32Array(e.width*e.height);const i=Cr(e);var r=Ms(e);if($c(r,i,Wc(e)),"iPad Simulator;iPhone Simulator;iPod Simulator;iPad;iPhone;iPod".split(";").includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"document"in self&&"ontouchend"in self.document){r=new Float32Array(e.width*e.height*4),i.readPixels(0,0,e.width,e.height,i.RGBA,i.FLOAT,r);for(let n=0,s=0;n<t.length;++n,s+=4)t[n]=r[s]}else i.readPixels(0,0,e.width,e.height,i.RED,i.FLOAT,t)}e.g.push(t)}return t}function Wc(e){let t=vt(e,2);if(!t){const r=Cr(e);t=qc(e);const i=Ls(e),n=Hc(e);r.texImage2D(r.TEXTURE_2D,0,n,e.width,e.height,0,r.RED,r.FLOAT,i),Ds(e)}return t}function Cr(e){if(!e.canvas)throw Error("Conversion to different image formats require that a canvas is passed when initializing the image.");return e.h||(e.h=Tt(e.canvas.getContext("webgl2"),"You cannot use a canvas that is already bound to a different type of rendering context.")),e.h}function Hc(e){if(e=Cr(e),!nn)if(e.getExtension("EXT_color_buffer_float")&&e.getExtension("OES_texture_float_linear")&&e.getExtension("EXT_float_blend"))nn=e.R32F;else{if(!e.getExtension("EXT_color_buffer_half_float"))throw Error("GPU does not fully support 4-channel float32 or float16 formats");nn=e.R16F}return nn}function Ms(e){return e.l||(e.l=new zc),e.l}function qc(e){const t=Cr(e);t.viewport(0,0,e.width,e.height),t.activeTexture(t.TEXTURE0);let r=vt(e,2);return r||(r=jc(Ms(e),t,e.m?t.LINEAR:t.NEAREST),e.g.push(r),e.j=!0),t.bindTexture(t.TEXTURE_2D,r),r}function Ds(e){e.h.bindTexture(e.h.TEXTURE_2D,null)}var nn,ye=class{constructor(e,t,r,i,n,s,a){this.g=e,this.m=t,this.j=r,this.canvas=i,this.l=n,this.width=s,this.height=a,this.j&&--Kc===0&&console.error("You seem to be creating MPMask instances without invoking .close(). This leaks resources.")}Fa(){return!!vt(this,0)}ka(){return!!vt(this,1)}R(){return!!vt(this,2)}ja(){return(t=vt(e=this,0))||(t=Ls(e),t=new Uint8Array(t.map(r=>Math.round(255*r))),e.g.push(t)),t;var e,t}ia(){return Ls(this)}N(){return Wc(this)}clone(){const e=[];for(const t of this.g){let r;if(t instanceof Uint8Array)r=new Uint8Array(t);else if(t instanceof Float32Array)r=new Float32Array(t);else{if(!(t instanceof WebGLTexture))throw Error(`Type is not supported: ${t}`);{const i=Cr(this),n=Ms(this);i.activeTexture(i.TEXTURE1),r=jc(n,i,this.m?i.LINEAR:i.NEAREST),i.bindTexture(i.TEXTURE_2D,r);const s=Hc(this);i.texImage2D(i.TEXTURE_2D,0,s,this.width,this.height,0,i.RED,i.FLOAT,null),i.bindTexture(i.TEXTURE_2D,null),$c(n,i,r),zu(n,i,!1,()=>{qc(this),i.clearColor(0,0,0,0),i.clear(i.COLOR_BUFFER_BIT),i.drawArrays(i.TRIANGLE_FAN,0,4),Ds(this)}),Wu(n),Ds(this)}}e.push(r)}return new ye(e,this.m,this.R(),this.canvas,this.l,this.width,this.height)}close(){this.j&&Cr(this).deleteTexture(vt(this,2)),Kc=-1}};ye.prototype.close=ye.prototype.close,ye.prototype.clone=ye.prototype.clone,ye.prototype.getAsWebGLTexture=ye.prototype.N,ye.prototype.getAsFloat32Array=ye.prototype.ia,ye.prototype.getAsUint8Array=ye.prototype.ja,ye.prototype.hasWebGLTexture=ye.prototype.R,ye.prototype.hasFloat32Array=ye.prototype.ka,ye.prototype.hasUint8Array=ye.prototype.Fa;var Kc=250;function tt(...e){return e.map(([t,r])=>({start:t,end:r}))}const Hu=function(e){return class extends e{Ja(){this.i._registerModelResourcesGraphService()}}}((Yc=class{constructor(e,t){this.l=!0,this.i=e,this.g=null,this.h=0,this.m=typeof this.i._addIntToInputStream=="function",t!==void 0?this.i.canvas=t:Mc()?this.i.canvas=new OffscreenCanvas(1,1):(console.warn("OffscreenCanvas not supported and GraphRunner constructor glCanvas parameter is undefined. Creating backup canvas."),this.i.canvas=document.createElement("canvas"))}async initializeGraph(e){const t=await(await fetch(e)).arrayBuffer();e=!(e.endsWith(".pbtxt")||e.endsWith(".textproto")),this.setGraph(new Uint8Array(t),e)}setGraphFromString(e){this.setGraph(new TextEncoder().encode(e),!1)}setGraph(e,t){const r=e.length,i=this.i._malloc(r);this.i.HEAPU8.set(e,i),t?this.i._changeBinaryGraph(r,i):this.i._changeTextGraph(r,i),this.i._free(i)}configureAudio(e,t,r,i,n){this.i._configureAudio||console.warn('Attempting to use configureAudio without support for input audio. Is build dep ":gl_graph_runner_audio" missing?'),I(this,i||"input_audio",s=>{I(this,n=n||"audio_header",a=>{this.i._configureAudio(s,a,e,t??0,r)})})}setAutoResizeCanvas(e){this.l=e}setAutoRenderToScreen(e){this.i._setAutoRenderToScreen(e)}setGpuBufferVerticalFlip(e){this.i.gpuOriginForWebTexturesIsBottomLeft=e}ca(e){dt(this,"__graph_config__",t=>{e(t)}),I(this,"__graph_config__",t=>{this.i._getGraphConfig(t,void 0)}),delete this.i.simpleListeners.__graph_config__}attachErrorListener(e){this.i.errorListener=e}attachEmptyPacketListener(e,t){this.i.emptyPacketListeners=this.i.emptyPacketListeners||{},this.i.emptyPacketListeners[e]=t}addAudioToStream(e,t,r){this.addAudioToStreamWithShape(e,0,0,t,r)}addAudioToStreamWithShape(e,t,r,i,n){const s=4*e.length;this.h!==s&&(this.g&&this.i._free(this.g),this.g=this.i._malloc(s),this.h=s),this.i.HEAPF32.set(e,this.g/4),I(this,i,a=>{this.i._addAudioToInputStream(this.g,t,r,a,n)})}addGpuBufferToStream(e,t,r){I(this,t,i=>{const[n,s]=Oc(this,e,i);this.i._addBoundTextureToStream(i,n,s,r)})}addBoolToStream(e,t,r){I(this,t,i=>{this.i._addBoolToInputStream(e,i,r)})}addDoubleToStream(e,t,r){I(this,t,i=>{this.i._addDoubleToInputStream(e,i,r)})}addFloatToStream(e,t,r){I(this,t,i=>{this.i._addFloatToInputStream(e,i,r)})}addIntToStream(e,t,r){I(this,t,i=>{this.i._addIntToInputStream(e,i,r)})}addUintToStream(e,t,r){I(this,t,i=>{this.i._addUintToInputStream(e,i,r)})}addStringToStream(e,t,r){I(this,t,i=>{I(this,e,n=>{this.i._addStringToInputStream(n,i,r)})})}addStringRecordToStream(e,t,r){I(this,t,i=>{Bc(this,Object.keys(e),n=>{Bc(this,Object.values(e),s=>{this.i._addFlatHashMapToInputStream(n,s,Object.keys(e).length,i,r)})})})}addProtoToStream(e,t,r,i){I(this,r,n=>{I(this,t,s=>{const a=this.i._malloc(e.length);this.i.HEAPU8.set(e,a),this.i._addProtoToInputStream(a,e.length,s,n,i),this.i._free(a)})})}addEmptyPacketToStream(e,t){I(this,e,r=>{this.i._addEmptyPacketToInputStream(r,t)})}addBoolVectorToStream(e,t,r){I(this,t,i=>{const n=this.i._allocateBoolVector(e.length);if(!n)throw Error("Unable to allocate new bool vector on heap.");for(const s of e)this.i._addBoolVectorEntry(n,s);this.i._addBoolVectorToInputStream(n,i,r)})}addDoubleVectorToStream(e,t,r){I(this,t,i=>{const n=this.i._allocateDoubleVector(e.length);if(!n)throw Error("Unable to allocate new double vector on heap.");for(const s of e)this.i._addDoubleVectorEntry(n,s);this.i._addDoubleVectorToInputStream(n,i,r)})}addFloatVectorToStream(e,t,r){I(this,t,i=>{const n=this.i._allocateFloatVector(e.length);if(!n)throw Error("Unable to allocate new float vector on heap.");for(const s of e)this.i._addFloatVectorEntry(n,s);this.i._addFloatVectorToInputStream(n,i,r)})}addIntVectorToStream(e,t,r){I(this,t,i=>{const n=this.i._allocateIntVector(e.length);if(!n)throw Error("Unable to allocate new int vector on heap.");for(const s of e)this.i._addIntVectorEntry(n,s);this.i._addIntVectorToInputStream(n,i,r)})}addUintVectorToStream(e,t,r){I(this,t,i=>{const n=this.i._allocateUintVector(e.length);if(!n)throw Error("Unable to allocate new unsigned int vector on heap.");for(const s of e)this.i._addUintVectorEntry(n,s);this.i._addUintVectorToInputStream(n,i,r)})}addStringVectorToStream(e,t,r){I(this,t,i=>{const n=this.i._allocateStringVector(e.length);if(!n)throw Error("Unable to allocate new string vector on heap.");for(const s of e)I(this,s,a=>{this.i._addStringVectorEntry(n,a)});this.i._addStringVectorToInputStream(n,i,r)})}addBoolToInputSidePacket(e,t){I(this,t,r=>{this.i._addBoolToInputSidePacket(e,r)})}addDoubleToInputSidePacket(e,t){I(this,t,r=>{this.i._addDoubleToInputSidePacket(e,r)})}addFloatToInputSidePacket(e,t){I(this,t,r=>{this.i._addFloatToInputSidePacket(e,r)})}addIntToInputSidePacket(e,t){I(this,t,r=>{this.i._addIntToInputSidePacket(e,r)})}addUintToInputSidePacket(e,t){I(this,t,r=>{this.i._addUintToInputSidePacket(e,r)})}addStringToInputSidePacket(e,t){I(this,t,r=>{I(this,e,i=>{this.i._addStringToInputSidePacket(i,r)})})}addProtoToInputSidePacket(e,t,r){I(this,r,i=>{I(this,t,n=>{const s=this.i._malloc(e.length);this.i.HEAPU8.set(e,s),this.i._addProtoToInputSidePacket(s,e.length,n,i),this.i._free(s)})})}addBoolVectorToInputSidePacket(e,t){I(this,t,r=>{const i=this.i._allocateBoolVector(e.length);if(!i)throw Error("Unable to allocate new bool vector on heap.");for(const n of e)this.i._addBoolVectorEntry(i,n);this.i._addBoolVectorToInputSidePacket(i,r)})}addDoubleVectorToInputSidePacket(e,t){I(this,t,r=>{const i=this.i._allocateDoubleVector(e.length);if(!i)throw Error("Unable to allocate new double vector on heap.");for(const n of e)this.i._addDoubleVectorEntry(i,n);this.i._addDoubleVectorToInputSidePacket(i,r)})}addFloatVectorToInputSidePacket(e,t){I(this,t,r=>{const i=this.i._allocateFloatVector(e.length);if(!i)throw Error("Unable to allocate new float vector on heap.");for(const n of e)this.i._addFloatVectorEntry(i,n);this.i._addFloatVectorToInputSidePacket(i,r)})}addIntVectorToInputSidePacket(e,t){I(this,t,r=>{const i=this.i._allocateIntVector(e.length);if(!i)throw Error("Unable to allocate new int vector on heap.");for(const n of e)this.i._addIntVectorEntry(i,n);this.i._addIntVectorToInputSidePacket(i,r)})}addUintVectorToInputSidePacket(e,t){I(this,t,r=>{const i=this.i._allocateUintVector(e.length);if(!i)throw Error("Unable to allocate new unsigned int vector on heap.");for(const n of e)this.i._addUintVectorEntry(i,n);this.i._addUintVectorToInputSidePacket(i,r)})}addStringVectorToInputSidePacket(e,t){I(this,t,r=>{const i=this.i._allocateStringVector(e.length);if(!i)throw Error("Unable to allocate new string vector on heap.");for(const n of e)I(this,n,s=>{this.i._addStringVectorEntry(i,s)});this.i._addStringVectorToInputSidePacket(i,r)})}attachBoolListener(e,t){dt(this,e,t),I(this,e,r=>{this.i._attachBoolListener(r)})}attachBoolVectorListener(e,t){Ct(this,e,t),I(this,e,r=>{this.i._attachBoolVectorListener(r)})}attachIntListener(e,t){dt(this,e,t),I(this,e,r=>{this.i._attachIntListener(r)})}attachIntVectorListener(e,t){Ct(this,e,t),I(this,e,r=>{this.i._attachIntVectorListener(r)})}attachUintListener(e,t){dt(this,e,t),I(this,e,r=>{this.i._attachUintListener(r)})}attachUintVectorListener(e,t){Ct(this,e,t),I(this,e,r=>{this.i._attachUintVectorListener(r)})}attachDoubleListener(e,t){dt(this,e,t),I(this,e,r=>{this.i._attachDoubleListener(r)})}attachDoubleVectorListener(e,t){Ct(this,e,t),I(this,e,r=>{this.i._attachDoubleVectorListener(r)})}attachFloatListener(e,t){dt(this,e,t),I(this,e,r=>{this.i._attachFloatListener(r)})}attachFloatVectorListener(e,t){Ct(this,e,t),I(this,e,r=>{this.i._attachFloatVectorListener(r)})}attachStringListener(e,t){dt(this,e,t),I(this,e,r=>{this.i._attachStringListener(r)})}attachStringVectorListener(e,t){Ct(this,e,t),I(this,e,r=>{this.i._attachStringVectorListener(r)})}attachProtoListener(e,t,r){dt(this,e,t),I(this,e,i=>{this.i._attachProtoListener(i,r||!1)})}attachProtoVectorListener(e,t,r){Ct(this,e,t),I(this,e,i=>{this.i._attachProtoVectorListener(i,r||!1)})}attachAudioListener(e,t,r){this.i._attachAudioListener||console.warn('Attempting to use attachAudioListener without support for output audio. Is build dep ":gl_graph_runner_audio_out" missing?'),dt(this,e,(i,n)=>{i=new Float32Array(i.buffer,i.byteOffset,i.length/4),t(i,n)}),I(this,e,i=>{this.i._attachAudioListener(i,r||!1)})}finishProcessing(){this.i._waitUntilIdle()}closeGraph(){this.i._closeGraph(),this.i.simpleListeners=void 0,this.i.emptyPacketListeners=void 0}},class extends Yc{get ga(){return this.i}pa(e,t,r){I(this,t,i=>{const[n,s]=Oc(this,e,i);this.ga._addBoundTextureAsImageToStream(i,n,s,r)})}Z(e,t){dt(this,e,t),I(this,e,r=>{this.ga._attachImageListener(r)})}aa(e,t){Ct(this,e,t),I(this,e,r=>{this.ga._attachImageVectorListener(r)})}}));var Yc,rt=class extends Hu{};async function z(e,t,r){return async function(i,n,s,a){return ju(i,n,s,a)}(e,r.canvas??(Mc()?void 0:document.createElement("canvas")),t,r)}function Xc(e,t,r,i){if(e.U){const s=new ec;if(r!=null&&r.regionOfInterest){if(!e.oa)throw Error("This task doesn't support region-of-interest.");var n=r.regionOfInterest;if(n.left>=n.right||n.top>=n.bottom)throw Error("Expected RectF with left < right and top < bottom.");if(n.left<0||n.top<0||n.right>1||n.bottom>1)throw Error("Expected RectF values to be in [0,1].");F(s,1,(n.left+n.right)/2),F(s,2,(n.top+n.bottom)/2),F(s,4,n.right-n.left),F(s,3,n.bottom-n.top)}else F(s,1,.5),F(s,2,.5),F(s,4,1),F(s,3,1);if(r!=null&&r.rotationDegrees){if((r==null?void 0:r.rotationDegrees)%90!=0)throw Error("Expected rotation to be a multiple of 90°.");if(F(s,5,-Math.PI*r.rotationDegrees/180),(r==null?void 0:r.rotationDegrees)%180!=0){const[a,c]=Pc(t);r=se(s,3)*c/a,n=se(s,4)*a/c,F(s,4,r),F(s,3,n)}}e.g.addProtoToStream(s.g(),"mediapipe.NormalizedRect",e.U,i)}e.g.pa(t,e.X,i??performance.now()),e.finishProcessing()}function it(e,t,r){var i;if((i=e.baseOptions)!=null&&i.g())throw Error("Task is not initialized with image mode. 'runningMode' must be set to 'IMAGE'.");Xc(e,t,r,e.C+1)}function ut(e,t,r,i){var n;if(!((n=e.baseOptions)!=null&&n.g()))throw Error("Task is not initialized with video mode. 'runningMode' must be set to 'VIDEO'.");Xc(e,t,r,i)}function Tr(e,t,r,i){var n=t.data;const s=t.width,a=s*(t=t.height);if((n instanceof Uint8Array||n instanceof Float32Array)&&n.length!==a)throw Error("Unsupported channel count: "+n.length/a);return e=new ye([n],r,!1,e.g.i.canvas,e.P,s,t),i?e.clone():e}var Ue=class extends Is{constructor(e,t,r,i){super(e),this.g=e,this.X=t,this.U=r,this.oa=i,this.P=new zc}l(e,t=!0){if("runningMode"in e&&K(this.baseOptions,2,Qr(!!e.runningMode&&e.runningMode!=="IMAGE")),e.canvas!==void 0&&this.g.i.canvas!==e.canvas)throw Error("You must create a new task to reset the canvas.");return super.l(e,t)}close(){this.P.close(),super.close()}};Ue.prototype.close=Ue.prototype.close;var Xe=class extends Ue{constructor(e,t){super(new rt(e,t),"image_in","norm_rect_in",!1),this.j={detections:[]},L(e=this.h=new Zi,0,1,t=new ie),F(this.h,2,.5),F(this.h,3,.3)}get baseOptions(){return W(this.h,ie,1)}set baseOptions(e){L(this.h,0,1,e)}o(e){return"minDetectionConfidence"in e&&F(this.h,2,e.minDetectionConfidence??.5),"minSuppressionThreshold"in e&&F(this.h,3,e.minSuppressionThreshold??.3),this.l(e)}F(e,t){return this.j={detections:[]},it(this,e,t),this.j}G(e,t,r){return this.j={detections:[]},ut(this,e,r,t),this.j}m(){var e=new Be;te(e,"image_in"),te(e,"norm_rect_in"),H(e,"detections");const t=new Oe;ct(t,Au,this.h);const r=new Te;De(r,2,"mediapipe.tasks.vision.face_detector.FaceDetectorGraph"),J(r,"IMAGE:image_in"),J(r,"NORM_RECT:norm_rect_in"),j(r,"DETECTIONS:detections"),r.o(t),Ye(e,r),this.g.attachProtoVectorListener("detections",(i,n)=>{for(const s of i)i=Ja(s),this.j.detections.push(Nc(i));A(this,n)}),this.g.attachEmptyPacketListener("detections",i=>{A(this,i)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Xe.prototype.detectForVideo=Xe.prototype.G,Xe.prototype.detect=Xe.prototype.F,Xe.prototype.setOptions=Xe.prototype.o,Xe.createFromModelPath=async function(e,t){return z(Xe,e,{baseOptions:{modelAssetPath:t}})},Xe.createFromModelBuffer=function(e,t){return z(Xe,e,{baseOptions:{modelAssetBuffer:t}})},Xe.createFromOptions=function(e,t){return z(Xe,e,t)};var Ps=tt([61,146],[146,91],[91,181],[181,84],[84,17],[17,314],[314,405],[405,321],[321,375],[375,291],[61,185],[185,40],[40,39],[39,37],[37,0],[0,267],[267,269],[269,270],[270,409],[409,291],[78,95],[95,88],[88,178],[178,87],[87,14],[14,317],[317,402],[402,318],[318,324],[324,308],[78,191],[191,80],[80,81],[81,82],[82,13],[13,312],[312,311],[311,310],[310,415],[415,308]),Os=tt([263,249],[249,390],[390,373],[373,374],[374,380],[380,381],[381,382],[382,362],[263,466],[466,388],[388,387],[387,386],[386,385],[385,384],[384,398],[398,362]),Bs=tt([276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]),Qc=tt([474,475],[475,476],[476,477],[477,474]),Us=tt([33,7],[7,163],[163,144],[144,145],[145,153],[153,154],[154,155],[155,133],[33,246],[246,161],[161,160],[160,159],[159,158],[158,157],[157,173],[173,133]),Vs=tt([46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]),Jc=tt([469,470],[470,471],[471,472],[472,469]),Gs=tt([10,338],[338,297],[297,332],[332,284],[284,251],[251,389],[389,356],[356,454],[454,323],[323,361],[361,288],[288,397],[397,365],[365,379],[379,378],[378,400],[400,377],[377,152],[152,148],[148,176],[176,149],[149,150],[150,136],[136,172],[172,58],[58,132],[132,93],[93,234],[234,127],[127,162],[162,21],[21,54],[54,103],[103,67],[67,109],[109,10]),Zc=[...Ps,...Os,...Bs,...Us,...Vs,...Gs],Rc=tt([127,34],[34,139],[139,127],[11,0],[0,37],[37,11],[232,231],[231,120],[120,232],[72,37],[37,39],[39,72],[128,121],[121,47],[47,128],[232,121],[121,128],[128,232],[104,69],[69,67],[67,104],[175,171],[171,148],[148,175],[118,50],[50,101],[101,118],[73,39],[39,40],[40,73],[9,151],[151,108],[108,9],[48,115],[115,131],[131,48],[194,204],[204,211],[211,194],[74,40],[40,185],[185,74],[80,42],[42,183],[183,80],[40,92],[92,186],[186,40],[230,229],[229,118],[118,230],[202,212],[212,214],[214,202],[83,18],[18,17],[17,83],[76,61],[61,146],[146,76],[160,29],[29,30],[30,160],[56,157],[157,173],[173,56],[106,204],[204,194],[194,106],[135,214],[214,192],[192,135],[203,165],[165,98],[98,203],[21,71],[71,68],[68,21],[51,45],[45,4],[4,51],[144,24],[24,23],[23,144],[77,146],[146,91],[91,77],[205,50],[50,187],[187,205],[201,200],[200,18],[18,201],[91,106],[106,182],[182,91],[90,91],[91,181],[181,90],[85,84],[84,17],[17,85],[206,203],[203,36],[36,206],[148,171],[171,140],[140,148],[92,40],[40,39],[39,92],[193,189],[189,244],[244,193],[159,158],[158,28],[28,159],[247,246],[246,161],[161,247],[236,3],[3,196],[196,236],[54,68],[68,104],[104,54],[193,168],[168,8],[8,193],[117,228],[228,31],[31,117],[189,193],[193,55],[55,189],[98,97],[97,99],[99,98],[126,47],[47,100],[100,126],[166,79],[79,218],[218,166],[155,154],[154,26],[26,155],[209,49],[49,131],[131,209],[135,136],[136,150],[150,135],[47,126],[126,217],[217,47],[223,52],[52,53],[53,223],[45,51],[51,134],[134,45],[211,170],[170,140],[140,211],[67,69],[69,108],[108,67],[43,106],[106,91],[91,43],[230,119],[119,120],[120,230],[226,130],[130,247],[247,226],[63,53],[53,52],[52,63],[238,20],[20,242],[242,238],[46,70],[70,156],[156,46],[78,62],[62,96],[96,78],[46,53],[53,63],[63,46],[143,34],[34,227],[227,143],[123,117],[117,111],[111,123],[44,125],[125,19],[19,44],[236,134],[134,51],[51,236],[216,206],[206,205],[205,216],[154,153],[153,22],[22,154],[39,37],[37,167],[167,39],[200,201],[201,208],[208,200],[36,142],[142,100],[100,36],[57,212],[212,202],[202,57],[20,60],[60,99],[99,20],[28,158],[158,157],[157,28],[35,226],[226,113],[113,35],[160,159],[159,27],[27,160],[204,202],[202,210],[210,204],[113,225],[225,46],[46,113],[43,202],[202,204],[204,43],[62,76],[76,77],[77,62],[137,123],[123,116],[116,137],[41,38],[38,72],[72,41],[203,129],[129,142],[142,203],[64,98],[98,240],[240,64],[49,102],[102,64],[64,49],[41,73],[73,74],[74,41],[212,216],[216,207],[207,212],[42,74],[74,184],[184,42],[169,170],[170,211],[211,169],[170,149],[149,176],[176,170],[105,66],[66,69],[69,105],[122,6],[6,168],[168,122],[123,147],[147,187],[187,123],[96,77],[77,90],[90,96],[65,55],[55,107],[107,65],[89,90],[90,180],[180,89],[101,100],[100,120],[120,101],[63,105],[105,104],[104,63],[93,137],[137,227],[227,93],[15,86],[86,85],[85,15],[129,102],[102,49],[49,129],[14,87],[87,86],[86,14],[55,8],[8,9],[9,55],[100,47],[47,121],[121,100],[145,23],[23,22],[22,145],[88,89],[89,179],[179,88],[6,122],[122,196],[196,6],[88,95],[95,96],[96,88],[138,172],[172,136],[136,138],[215,58],[58,172],[172,215],[115,48],[48,219],[219,115],[42,80],[80,81],[81,42],[195,3],[3,51],[51,195],[43,146],[146,61],[61,43],[171,175],[175,199],[199,171],[81,82],[82,38],[38,81],[53,46],[46,225],[225,53],[144,163],[163,110],[110,144],[52,65],[65,66],[66,52],[229,228],[228,117],[117,229],[34,127],[127,234],[234,34],[107,108],[108,69],[69,107],[109,108],[108,151],[151,109],[48,64],[64,235],[235,48],[62,78],[78,191],[191,62],[129,209],[209,126],[126,129],[111,35],[35,143],[143,111],[117,123],[123,50],[50,117],[222,65],[65,52],[52,222],[19,125],[125,141],[141,19],[221,55],[55,65],[65,221],[3,195],[195,197],[197,3],[25,7],[7,33],[33,25],[220,237],[237,44],[44,220],[70,71],[71,139],[139,70],[122,193],[193,245],[245,122],[247,130],[130,33],[33,247],[71,21],[21,162],[162,71],[170,169],[169,150],[150,170],[188,174],[174,196],[196,188],[216,186],[186,92],[92,216],[2,97],[97,167],[167,2],[141,125],[125,241],[241,141],[164,167],[167,37],[37,164],[72,38],[38,12],[12,72],[38,82],[82,13],[13,38],[63,68],[68,71],[71,63],[226,35],[35,111],[111,226],[101,50],[50,205],[205,101],[206,92],[92,165],[165,206],[209,198],[198,217],[217,209],[165,167],[167,97],[97,165],[220,115],[115,218],[218,220],[133,112],[112,243],[243,133],[239,238],[238,241],[241,239],[214,135],[135,169],[169,214],[190,173],[173,133],[133,190],[171,208],[208,32],[32,171],[125,44],[44,237],[237,125],[86,87],[87,178],[178,86],[85,86],[86,179],[179,85],[84,85],[85,180],[180,84],[83,84],[84,181],[181,83],[201,83],[83,182],[182,201],[137,93],[93,132],[132,137],[76,62],[62,183],[183,76],[61,76],[76,184],[184,61],[57,61],[61,185],[185,57],[212,57],[57,186],[186,212],[214,207],[207,187],[187,214],[34,143],[143,156],[156,34],[79,239],[239,237],[237,79],[123,137],[137,177],[177,123],[44,1],[1,4],[4,44],[201,194],[194,32],[32,201],[64,102],[102,129],[129,64],[213,215],[215,138],[138,213],[59,166],[166,219],[219,59],[242,99],[99,97],[97,242],[2,94],[94,141],[141,2],[75,59],[59,235],[235,75],[24,110],[110,228],[228,24],[25,130],[130,226],[226,25],[23,24],[24,229],[229,23],[22,23],[23,230],[230,22],[26,22],[22,231],[231,26],[112,26],[26,232],[232,112],[189,190],[190,243],[243,189],[221,56],[56,190],[190,221],[28,56],[56,221],[221,28],[27,28],[28,222],[222,27],[29,27],[27,223],[223,29],[30,29],[29,224],[224,30],[247,30],[30,225],[225,247],[238,79],[79,20],[20,238],[166,59],[59,75],[75,166],[60,75],[75,240],[240,60],[147,177],[177,215],[215,147],[20,79],[79,166],[166,20],[187,147],[147,213],[213,187],[112,233],[233,244],[244,112],[233,128],[128,245],[245,233],[128,114],[114,188],[188,128],[114,217],[217,174],[174,114],[131,115],[115,220],[220,131],[217,198],[198,236],[236,217],[198,131],[131,134],[134,198],[177,132],[132,58],[58,177],[143,35],[35,124],[124,143],[110,163],[163,7],[7,110],[228,110],[110,25],[25,228],[356,389],[389,368],[368,356],[11,302],[302,267],[267,11],[452,350],[350,349],[349,452],[302,303],[303,269],[269,302],[357,343],[343,277],[277,357],[452,453],[453,357],[357,452],[333,332],[332,297],[297,333],[175,152],[152,377],[377,175],[347,348],[348,330],[330,347],[303,304],[304,270],[270,303],[9,336],[336,337],[337,9],[278,279],[279,360],[360,278],[418,262],[262,431],[431,418],[304,408],[408,409],[409,304],[310,415],[415,407],[407,310],[270,409],[409,410],[410,270],[450,348],[348,347],[347,450],[422,430],[430,434],[434,422],[313,314],[314,17],[17,313],[306,307],[307,375],[375,306],[387,388],[388,260],[260,387],[286,414],[414,398],[398,286],[335,406],[406,418],[418,335],[364,367],[367,416],[416,364],[423,358],[358,327],[327,423],[251,284],[284,298],[298,251],[281,5],[5,4],[4,281],[373,374],[374,253],[253,373],[307,320],[320,321],[321,307],[425,427],[427,411],[411,425],[421,313],[313,18],[18,421],[321,405],[405,406],[406,321],[320,404],[404,405],[405,320],[315,16],[16,17],[17,315],[426,425],[425,266],[266,426],[377,400],[400,369],[369,377],[322,391],[391,269],[269,322],[417,465],[465,464],[464,417],[386,257],[257,258],[258,386],[466,260],[260,388],[388,466],[456,399],[399,419],[419,456],[284,332],[332,333],[333,284],[417,285],[285,8],[8,417],[346,340],[340,261],[261,346],[413,441],[441,285],[285,413],[327,460],[460,328],[328,327],[355,371],[371,329],[329,355],[392,439],[439,438],[438,392],[382,341],[341,256],[256,382],[429,420],[420,360],[360,429],[364,394],[394,379],[379,364],[277,343],[343,437],[437,277],[443,444],[444,283],[283,443],[275,440],[440,363],[363,275],[431,262],[262,369],[369,431],[297,338],[338,337],[337,297],[273,375],[375,321],[321,273],[450,451],[451,349],[349,450],[446,342],[342,467],[467,446],[293,334],[334,282],[282,293],[458,461],[461,462],[462,458],[276,353],[353,383],[383,276],[308,324],[324,325],[325,308],[276,300],[300,293],[293,276],[372,345],[345,447],[447,372],[352,345],[345,340],[340,352],[274,1],[1,19],[19,274],[456,248],[248,281],[281,456],[436,427],[427,425],[425,436],[381,256],[256,252],[252,381],[269,391],[391,393],[393,269],[200,199],[199,428],[428,200],[266,330],[330,329],[329,266],[287,273],[273,422],[422,287],[250,462],[462,328],[328,250],[258,286],[286,384],[384,258],[265,353],[353,342],[342,265],[387,259],[259,257],[257,387],[424,431],[431,430],[430,424],[342,353],[353,276],[276,342],[273,335],[335,424],[424,273],[292,325],[325,307],[307,292],[366,447],[447,345],[345,366],[271,303],[303,302],[302,271],[423,266],[266,371],[371,423],[294,455],[455,460],[460,294],[279,278],[278,294],[294,279],[271,272],[272,304],[304,271],[432,434],[434,427],[427,432],[272,407],[407,408],[408,272],[394,430],[430,431],[431,394],[395,369],[369,400],[400,395],[334,333],[333,299],[299,334],[351,417],[417,168],[168,351],[352,280],[280,411],[411,352],[325,319],[319,320],[320,325],[295,296],[296,336],[336,295],[319,403],[403,404],[404,319],[330,348],[348,349],[349,330],[293,298],[298,333],[333,293],[323,454],[454,447],[447,323],[15,16],[16,315],[315,15],[358,429],[429,279],[279,358],[14,15],[15,316],[316,14],[285,336],[336,9],[9,285],[329,349],[349,350],[350,329],[374,380],[380,252],[252,374],[318,402],[402,403],[403,318],[6,197],[197,419],[419,6],[318,319],[319,325],[325,318],[367,364],[364,365],[365,367],[435,367],[367,397],[397,435],[344,438],[438,439],[439,344],[272,271],[271,311],[311,272],[195,5],[5,281],[281,195],[273,287],[287,291],[291,273],[396,428],[428,199],[199,396],[311,271],[271,268],[268,311],[283,444],[444,445],[445,283],[373,254],[254,339],[339,373],[282,334],[334,296],[296,282],[449,347],[347,346],[346,449],[264,447],[447,454],[454,264],[336,296],[296,299],[299,336],[338,10],[10,151],[151,338],[278,439],[439,455],[455,278],[292,407],[407,415],[415,292],[358,371],[371,355],[355,358],[340,345],[345,372],[372,340],[346,347],[347,280],[280,346],[442,443],[443,282],[282,442],[19,94],[94,370],[370,19],[441,442],[442,295],[295,441],[248,419],[419,197],[197,248],[263,255],[255,359],[359,263],[440,275],[275,274],[274,440],[300,383],[383,368],[368,300],[351,412],[412,465],[465,351],[263,467],[467,466],[466,263],[301,368],[368,389],[389,301],[395,378],[378,379],[379,395],[412,351],[351,419],[419,412],[436,426],[426,322],[322,436],[2,164],[164,393],[393,2],[370,462],[462,461],[461,370],[164,0],[0,267],[267,164],[302,11],[11,12],[12,302],[268,12],[12,13],[13,268],[293,300],[300,301],[301,293],[446,261],[261,340],[340,446],[330,266],[266,425],[425,330],[426,423],[423,391],[391,426],[429,355],[355,437],[437,429],[391,327],[327,326],[326,391],[440,457],[457,438],[438,440],[341,382],[382,362],[362,341],[459,457],[457,461],[461,459],[434,430],[430,394],[394,434],[414,463],[463,362],[362,414],[396,369],[369,262],[262,396],[354,461],[461,457],[457,354],[316,403],[403,402],[402,316],[315,404],[404,403],[403,315],[314,405],[405,404],[404,314],[313,406],[406,405],[405,313],[421,418],[418,406],[406,421],[366,401],[401,361],[361,366],[306,408],[408,407],[407,306],[291,409],[409,408],[408,291],[287,410],[410,409],[409,287],[432,436],[436,410],[410,432],[434,416],[416,411],[411,434],[264,368],[368,383],[383,264],[309,438],[438,457],[457,309],[352,376],[376,401],[401,352],[274,275],[275,4],[4,274],[421,428],[428,262],[262,421],[294,327],[327,358],[358,294],[433,416],[416,367],[367,433],[289,455],[455,439],[439,289],[462,370],[370,326],[326,462],[2,326],[326,370],[370,2],[305,460],[460,455],[455,305],[254,449],[449,448],[448,254],[255,261],[261,446],[446,255],[253,450],[450,449],[449,253],[252,451],[451,450],[450,252],[256,452],[452,451],[451,256],[341,453],[453,452],[452,341],[413,464],[464,463],[463,413],[441,413],[413,414],[414,441],[258,442],[442,441],[441,258],[257,443],[443,442],[442,257],[259,444],[444,443],[443,259],[260,445],[445,444],[444,260],[467,342],[342,445],[445,467],[459,458],[458,250],[250,459],[289,392],[392,290],[290,289],[290,328],[328,460],[460,290],[376,433],[433,435],[435,376],[250,290],[290,392],[392,250],[411,416],[416,433],[433,411],[341,463],[463,464],[464,341],[453,464],[464,465],[465,453],[357,465],[465,412],[412,357],[343,412],[412,399],[399,343],[360,363],[363,440],[440,360],[437,399],[399,456],[456,437],[420,456],[456,363],[363,420],[401,435],[435,288],[288,401],[372,383],[383,353],[353,372],[339,255],[255,249],[249,339],[448,261],[261,255],[255,448],[133,243],[243,190],[190,133],[133,155],[155,112],[112,133],[33,246],[246,247],[247,33],[33,130],[130,25],[25,33],[398,384],[384,286],[286,398],[362,398],[398,414],[414,362],[362,463],[463,341],[341,362],[263,359],[359,467],[467,263],[263,249],[249,255],[255,263],[466,467],[467,260],[260,466],[75,60],[60,166],[166,75],[238,239],[239,79],[79,238],[162,127],[127,139],[139,162],[72,11],[11,37],[37,72],[121,232],[232,120],[120,121],[73,72],[72,39],[39,73],[114,128],[128,47],[47,114],[233,232],[232,128],[128,233],[103,104],[104,67],[67,103],[152,175],[175,148],[148,152],[119,118],[118,101],[101,119],[74,73],[73,40],[40,74],[107,9],[9,108],[108,107],[49,48],[48,131],[131,49],[32,194],[194,211],[211,32],[184,74],[74,185],[185,184],[191,80],[80,183],[183,191],[185,40],[40,186],[186,185],[119,230],[230,118],[118,119],[210,202],[202,214],[214,210],[84,83],[83,17],[17,84],[77,76],[76,146],[146,77],[161,160],[160,30],[30,161],[190,56],[56,173],[173,190],[182,106],[106,194],[194,182],[138,135],[135,192],[192,138],[129,203],[203,98],[98,129],[54,21],[21,68],[68,54],[5,51],[51,4],[4,5],[145,144],[144,23],[23,145],[90,77],[77,91],[91,90],[207,205],[205,187],[187,207],[83,201],[201,18],[18,83],[181,91],[91,182],[182,181],[180,90],[90,181],[181,180],[16,85],[85,17],[17,16],[205,206],[206,36],[36,205],[176,148],[148,140],[140,176],[165,92],[92,39],[39,165],[245,193],[193,244],[244,245],[27,159],[159,28],[28,27],[30,247],[247,161],[161,30],[174,236],[236,196],[196,174],[103,54],[54,104],[104,103],[55,193],[193,8],[8,55],[111,117],[117,31],[31,111],[221,189],[189,55],[55,221],[240,98],[98,99],[99,240],[142,126],[126,100],[100,142],[219,166],[166,218],[218,219],[112,155],[155,26],[26,112],[198,209],[209,131],[131,198],[169,135],[135,150],[150,169],[114,47],[47,217],[217,114],[224,223],[223,53],[53,224],[220,45],[45,134],[134,220],[32,211],[211,140],[140,32],[109,67],[67,108],[108,109],[146,43],[43,91],[91,146],[231,230],[230,120],[120,231],[113,226],[226,247],[247,113],[105,63],[63,52],[52,105],[241,238],[238,242],[242,241],[124,46],[46,156],[156,124],[95,78],[78,96],[96,95],[70,46],[46,63],[63,70],[116,143],[143,227],[227,116],[116,123],[123,111],[111,116],[1,44],[44,19],[19,1],[3,236],[236,51],[51,3],[207,216],[216,205],[205,207],[26,154],[154,22],[22,26],[165,39],[39,167],[167,165],[199,200],[200,208],[208,199],[101,36],[36,100],[100,101],[43,57],[57,202],[202,43],[242,20],[20,99],[99,242],[56,28],[28,157],[157,56],[124,35],[35,113],[113,124],[29,160],[160,27],[27,29],[211,204],[204,210],[210,211],[124,113],[113,46],[46,124],[106,43],[43,204],[204,106],[96,62],[62,77],[77,96],[227,137],[137,116],[116,227],[73,41],[41,72],[72,73],[36,203],[203,142],[142,36],[235,64],[64,240],[240,235],[48,49],[49,64],[64,48],[42,41],[41,74],[74,42],[214,212],[212,207],[207,214],[183,42],[42,184],[184,183],[210,169],[169,211],[211,210],[140,170],[170,176],[176,140],[104,105],[105,69],[69,104],[193,122],[122,168],[168,193],[50,123],[123,187],[187,50],[89,96],[96,90],[90,89],[66,65],[65,107],[107,66],[179,89],[89,180],[180,179],[119,101],[101,120],[120,119],[68,63],[63,104],[104,68],[234,93],[93,227],[227,234],[16,15],[15,85],[85,16],[209,129],[129,49],[49,209],[15,14],[14,86],[86,15],[107,55],[55,9],[9,107],[120,100],[100,121],[121,120],[153,145],[145,22],[22,153],[178,88],[88,179],[179,178],[197,6],[6,196],[196,197],[89,88],[88,96],[96,89],[135,138],[138,136],[136,135],[138,215],[215,172],[172,138],[218,115],[115,219],[219,218],[41,42],[42,81],[81,41],[5,195],[195,51],[51,5],[57,43],[43,61],[61,57],[208,171],[171,199],[199,208],[41,81],[81,38],[38,41],[224,53],[53,225],[225,224],[24,144],[144,110],[110,24],[105,52],[52,66],[66,105],[118,229],[229,117],[117,118],[227,34],[34,234],[234,227],[66,107],[107,69],[69,66],[10,109],[109,151],[151,10],[219,48],[48,235],[235,219],[183,62],[62,191],[191,183],[142,129],[129,126],[126,142],[116,111],[111,143],[143,116],[118,117],[117,50],[50,118],[223,222],[222,52],[52,223],[94,19],[19,141],[141,94],[222,221],[221,65],[65,222],[196,3],[3,197],[197,196],[45,220],[220,44],[44,45],[156,70],[70,139],[139,156],[188,122],[122,245],[245,188],[139,71],[71,162],[162,139],[149,170],[170,150],[150,149],[122,188],[188,196],[196,122],[206,216],[216,92],[92,206],[164,2],[2,167],[167,164],[242,141],[141,241],[241,242],[0,164],[164,37],[37,0],[11,72],[72,12],[12,11],[12,38],[38,13],[13,12],[70,63],[63,71],[71,70],[31,226],[226,111],[111,31],[36,101],[101,205],[205,36],[203,206],[206,165],[165,203],[126,209],[209,217],[217,126],[98,165],[165,97],[97,98],[237,220],[220,218],[218,237],[237,239],[239,241],[241,237],[210,214],[214,169],[169,210],[140,171],[171,32],[32,140],[241,125],[125,237],[237,241],[179,86],[86,178],[178,179],[180,85],[85,179],[179,180],[181,84],[84,180],[180,181],[182,83],[83,181],[181,182],[194,201],[201,182],[182,194],[177,137],[137,132],[132,177],[184,76],[76,183],[183,184],[185,61],[61,184],[184,185],[186,57],[57,185],[185,186],[216,212],[212,186],[186,216],[192,214],[214,187],[187,192],[139,34],[34,156],[156,139],[218,79],[79,237],[237,218],[147,123],[123,177],[177,147],[45,44],[44,4],[4,45],[208,201],[201,32],[32,208],[98,64],[64,129],[129,98],[192,213],[213,138],[138,192],[235,59],[59,219],[219,235],[141,242],[242,97],[97,141],[97,2],[2,141],[141,97],[240,75],[75,235],[235,240],[229,24],[24,228],[228,229],[31,25],[25,226],[226,31],[230,23],[23,229],[229,230],[231,22],[22,230],[230,231],[232,26],[26,231],[231,232],[233,112],[112,232],[232,233],[244,189],[189,243],[243,244],[189,221],[221,190],[190,189],[222,28],[28,221],[221,222],[223,27],[27,222],[222,223],[224,29],[29,223],[223,224],[225,30],[30,224],[224,225],[113,247],[247,225],[225,113],[99,60],[60,240],[240,99],[213,147],[147,215],[215,213],[60,20],[20,166],[166,60],[192,187],[187,213],[213,192],[243,112],[112,244],[244,243],[244,233],[233,245],[245,244],[245,128],[128,188],[188,245],[188,114],[114,174],[174,188],[134,131],[131,220],[220,134],[174,217],[217,236],[236,174],[236,198],[198,134],[134,236],[215,177],[177,58],[58,215],[156,143],[143,124],[124,156],[25,110],[110,7],[7,25],[31,228],[228,25],[25,31],[264,356],[356,368],[368,264],[0,11],[11,267],[267,0],[451,452],[452,349],[349,451],[267,302],[302,269],[269,267],[350,357],[357,277],[277,350],[350,452],[452,357],[357,350],[299,333],[333,297],[297,299],[396,175],[175,377],[377,396],[280,347],[347,330],[330,280],[269,303],[303,270],[270,269],[151,9],[9,337],[337,151],[344,278],[278,360],[360,344],[424,418],[418,431],[431,424],[270,304],[304,409],[409,270],[272,310],[310,407],[407,272],[322,270],[270,410],[410,322],[449,450],[450,347],[347,449],[432,422],[422,434],[434,432],[18,313],[313,17],[17,18],[291,306],[306,375],[375,291],[259,387],[387,260],[260,259],[424,335],[335,418],[418,424],[434,364],[364,416],[416,434],[391,423],[423,327],[327,391],[301,251],[251,298],[298,301],[275,281],[281,4],[4,275],[254,373],[373,253],[253,254],[375,307],[307,321],[321,375],[280,425],[425,411],[411,280],[200,421],[421,18],[18,200],[335,321],[321,406],[406,335],[321,320],[320,405],[405,321],[314,315],[315,17],[17,314],[423,426],[426,266],[266,423],[396,377],[377,369],[369,396],[270,322],[322,269],[269,270],[413,417],[417,464],[464,413],[385,386],[386,258],[258,385],[248,456],[456,419],[419,248],[298,284],[284,333],[333,298],[168,417],[417,8],[8,168],[448,346],[346,261],[261,448],[417,413],[413,285],[285,417],[326,327],[327,328],[328,326],[277,355],[355,329],[329,277],[309,392],[392,438],[438,309],[381,382],[382,256],[256,381],[279,429],[429,360],[360,279],[365,364],[364,379],[379,365],[355,277],[277,437],[437,355],[282,443],[443,283],[283,282],[281,275],[275,363],[363,281],[395,431],[431,369],[369,395],[299,297],[297,337],[337,299],[335,273],[273,321],[321,335],[348,450],[450,349],[349,348],[359,446],[446,467],[467,359],[283,293],[293,282],[282,283],[250,458],[458,462],[462,250],[300,276],[276,383],[383,300],[292,308],[308,325],[325,292],[283,276],[276,293],[293,283],[264,372],[372,447],[447,264],[346,352],[352,340],[340,346],[354,274],[274,19],[19,354],[363,456],[456,281],[281,363],[426,436],[436,425],[425,426],[380,381],[381,252],[252,380],[267,269],[269,393],[393,267],[421,200],[200,428],[428,421],[371,266],[266,329],[329,371],[432,287],[287,422],[422,432],[290,250],[250,328],[328,290],[385,258],[258,384],[384,385],[446,265],[265,342],[342,446],[386,387],[387,257],[257,386],[422,424],[424,430],[430,422],[445,342],[342,276],[276,445],[422,273],[273,424],[424,422],[306,292],[292,307],[307,306],[352,366],[366,345],[345,352],[268,271],[271,302],[302,268],[358,423],[423,371],[371,358],[327,294],[294,460],[460,327],[331,279],[279,294],[294,331],[303,271],[271,304],[304,303],[436,432],[432,427],[427,436],[304,272],[272,408],[408,304],[395,394],[394,431],[431,395],[378,395],[395,400],[400,378],[296,334],[334,299],[299,296],[6,351],[351,168],[168,6],[376,352],[352,411],[411,376],[307,325],[325,320],[320,307],[285,295],[295,336],[336,285],[320,319],[319,404],[404,320],[329,330],[330,349],[349,329],[334,293],[293,333],[333,334],[366,323],[323,447],[447,366],[316,15],[15,315],[315,316],[331,358],[358,279],[279,331],[317,14],[14,316],[316,317],[8,285],[285,9],[9,8],[277,329],[329,350],[350,277],[253,374],[374,252],[252,253],[319,318],[318,403],[403,319],[351,6],[6,419],[419,351],[324,318],[318,325],[325,324],[397,367],[367,365],[365,397],[288,435],[435,397],[397,288],[278,344],[344,439],[439,278],[310,272],[272,311],[311,310],[248,195],[195,281],[281,248],[375,273],[273,291],[291,375],[175,396],[396,199],[199,175],[312,311],[311,268],[268,312],[276,283],[283,445],[445,276],[390,373],[373,339],[339,390],[295,282],[282,296],[296,295],[448,449],[449,346],[346,448],[356,264],[264,454],[454,356],[337,336],[336,299],[299,337],[337,338],[338,151],[151,337],[294,278],[278,455],[455,294],[308,292],[292,415],[415,308],[429,358],[358,355],[355,429],[265,340],[340,372],[372,265],[352,346],[346,280],[280,352],[295,442],[442,282],[282,295],[354,19],[19,370],[370,354],[285,441],[441,295],[295,285],[195,248],[248,197],[197,195],[457,440],[440,274],[274,457],[301,300],[300,368],[368,301],[417,351],[351,465],[465,417],[251,301],[301,389],[389,251],[394,395],[395,379],[379,394],[399,412],[412,419],[419,399],[410,436],[436,322],[322,410],[326,2],[2,393],[393,326],[354,370],[370,461],[461,354],[393,164],[164,267],[267,393],[268,302],[302,12],[12,268],[312,268],[268,13],[13,312],[298,293],[293,301],[301,298],[265,446],[446,340],[340,265],[280,330],[330,425],[425,280],[322,426],[426,391],[391,322],[420,429],[429,437],[437,420],[393,391],[391,326],[326,393],[344,440],[440,438],[438,344],[458,459],[459,461],[461,458],[364,434],[434,394],[394,364],[428,396],[396,262],[262,428],[274,354],[354,457],[457,274],[317,316],[316,402],[402,317],[316,315],[315,403],[403,316],[315,314],[314,404],[404,315],[314,313],[313,405],[405,314],[313,421],[421,406],[406,313],[323,366],[366,361],[361,323],[292,306],[306,407],[407,292],[306,291],[291,408],[408,306],[291,287],[287,409],[409,291],[287,432],[432,410],[410,287],[427,434],[434,411],[411,427],[372,264],[264,383],[383,372],[459,309],[309,457],[457,459],[366,352],[352,401],[401,366],[1,274],[274,4],[4,1],[418,421],[421,262],[262,418],[331,294],[294,358],[358,331],[435,433],[433,367],[367,435],[392,289],[289,439],[439,392],[328,462],[462,326],[326,328],[94,2],[2,370],[370,94],[289,305],[305,455],[455,289],[339,254],[254,448],[448,339],[359,255],[255,446],[446,359],[254,253],[253,449],[449,254],[253,252],[252,450],[450,253],[252,256],[256,451],[451,252],[256,341],[341,452],[452,256],[414,413],[413,463],[463,414],[286,441],[441,414],[414,286],[286,258],[258,441],[441,286],[258,257],[257,442],[442,258],[257,259],[259,443],[443,257],[259,260],[260,444],[444,259],[260,467],[467,445],[445,260],[309,459],[459,250],[250,309],[305,289],[289,290],[290,305],[305,290],[290,460],[460,305],[401,376],[376,435],[435,401],[309,250],[250,392],[392,309],[376,411],[411,433],[433,376],[453,341],[341,464],[464,453],[357,453],[453,465],[465,357],[343,357],[357,412],[412,343],[437,343],[343,399],[399,437],[344,360],[360,440],[440,344],[420,437],[437,456],[456,420],[360,420],[420,363],[363,360],[361,401],[401,288],[288,361],[265,372],[372,353],[353,265],[390,339],[339,249],[249,390],[339,448],[448,255],[255,339]);function el(e){e.j={faceLandmarks:[],faceBlendshapes:[],facialTransformationMatrixes:[]}}var re=class extends Ue{constructor(e,t){super(new rt(e,t),"image_in","norm_rect",!1),this.j={faceLandmarks:[],faceBlendshapes:[],facialTransformationMatrixes:[]},this.outputFacialTransformationMatrixes=this.outputFaceBlendshapes=!1,L(e=this.h=new cc,0,1,t=new ie),this.A=new ac,L(this.h,0,3,this.A),this.u=new Zi,L(this.h,0,2,this.u),yt(this.u,4,1),F(this.u,2,.5),F(this.A,2,.5),F(this.h,4,.5)}get baseOptions(){return W(this.h,ie,1)}set baseOptions(e){L(this.h,0,1,e)}o(e){return"numFaces"in e&&yt(this.u,4,e.numFaces??1),"minFaceDetectionConfidence"in e&&F(this.u,2,e.minFaceDetectionConfidence??.5),"minTrackingConfidence"in e&&F(this.h,4,e.minTrackingConfidence??.5),"minFacePresenceConfidence"in e&&F(this.A,2,e.minFacePresenceConfidence??.5),"outputFaceBlendshapes"in e&&(this.outputFaceBlendshapes=!!e.outputFaceBlendshapes),"outputFacialTransformationMatrixes"in e&&(this.outputFacialTransformationMatrixes=!!e.outputFacialTransformationMatrixes),this.l(e)}F(e,t){return el(this),it(this,e,t),this.j}G(e,t,r){return el(this),ut(this,e,r,t),this.j}m(){var e=new Be;te(e,"image_in"),te(e,"norm_rect"),H(e,"face_landmarks");const t=new Oe;ct(t,Tu,this.h);const r=new Te;De(r,2,"mediapipe.tasks.vision.face_landmarker.FaceLandmarkerGraph"),J(r,"IMAGE:image_in"),J(r,"NORM_RECT:norm_rect"),j(r,"NORM_LANDMARKS:face_landmarks"),r.o(t),Ye(e,r),this.g.attachProtoVectorListener("face_landmarks",(i,n)=>{for(const s of i)i=ni(s),this.j.faceLandmarks.push(Ri(i));A(this,n)}),this.g.attachEmptyPacketListener("face_landmarks",i=>{A(this,i)}),this.outputFaceBlendshapes&&(H(e,"blendshapes"),j(r,"BLENDSHAPES:blendshapes"),this.g.attachProtoVectorListener("blendshapes",(i,n)=>{if(this.outputFaceBlendshapes)for(const s of i)i=Xi(s),this.j.faceBlendshapes.push(Ts(i.g()??[]));A(this,n)}),this.g.attachEmptyPacketListener("blendshapes",i=>{A(this,i)})),this.outputFacialTransformationMatrixes&&(H(e,"face_geometry"),j(r,"FACE_GEOMETRY:face_geometry"),this.g.attachProtoVectorListener("face_geometry",(i,n)=>{if(this.outputFacialTransformationMatrixes)for(const s of i)(i=W(i=Cu(s),yu,2))&&this.j.facialTransformationMatrixes.push({rows:qe(i,1)??0??0,columns:qe(i,2)??0??0,data:zt(i,3,ot,$t()).slice()??[]});A(this,n)}),this.g.attachEmptyPacketListener("face_geometry",i=>{A(this,i)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};re.prototype.detectForVideo=re.prototype.G,re.prototype.detect=re.prototype.F,re.prototype.setOptions=re.prototype.o,re.createFromModelPath=function(e,t){return z(re,e,{baseOptions:{modelAssetPath:t}})},re.createFromModelBuffer=function(e,t){return z(re,e,{baseOptions:{modelAssetBuffer:t}})},re.createFromOptions=function(e,t){return z(re,e,t)},re.FACE_LANDMARKS_LIPS=Ps,re.FACE_LANDMARKS_LEFT_EYE=Os,re.FACE_LANDMARKS_LEFT_EYEBROW=Bs,re.FACE_LANDMARKS_LEFT_IRIS=Qc,re.FACE_LANDMARKS_RIGHT_EYE=Us,re.FACE_LANDMARKS_RIGHT_EYEBROW=Vs,re.FACE_LANDMARKS_RIGHT_IRIS=Jc,re.FACE_LANDMARKS_FACE_OVAL=Gs,re.FACE_LANDMARKS_CONTOURS=Zc,re.FACE_LANDMARKS_TESSELATION=Rc;var js=tt([0,1],[1,2],[2,3],[3,4],[0,5],[5,6],[6,7],[7,8],[5,9],[9,10],[10,11],[11,12],[9,13],[13,14],[14,15],[15,16],[13,17],[0,17],[17,18],[18,19],[19,20]);function tl(e){e.gestures=[],e.landmarks=[],e.worldLandmarks=[],e.handedness=[]}function rl(e){return e.gestures.length===0?{gestures:[],landmarks:[],worldLandmarks:[],handedness:[],handednesses:[]}:{gestures:e.gestures,landmarks:e.landmarks,worldLandmarks:e.worldLandmarks,handedness:e.handedness,handednesses:e.handedness}}function il(e,t=!0){const r=[];for(const n of e){var i=Xi(n);e=[];for(const s of i.g())i=t&&qe(s,1)!=null?qe(s,1)??0:-1,e.push({score:se(s,2)??0,index:i,categoryName:xe(Q(s,3))??""??"",displayName:xe(Q(s,4))??""??""});r.push(e)}return r}var Ve=class extends Ue{constructor(e,t){super(new rt(e,t),"image_in","norm_rect",!1),this.gestures=[],this.landmarks=[],this.worldLandmarks=[],this.handedness=[],L(e=this.j=new uc,0,1,t=new ie),this.u=new vs,L(this.j,0,2,this.u),this.D=new bs,L(this.u,0,3,this.D),this.A=new dc,L(this.u,0,2,this.A),this.h=new Nu,L(this.j,0,3,this.h),F(this.A,2,.5),F(this.u,4,.5),F(this.D,2,.5)}get baseOptions(){return W(this.j,ie,1)}set baseOptions(e){L(this.j,0,1,e)}o(e){var n,s,a,c;if(yt(this.A,3,e.numHands??1),"minHandDetectionConfidence"in e&&F(this.A,2,e.minHandDetectionConfidence??.5),"minTrackingConfidence"in e&&F(this.u,4,e.minTrackingConfidence??.5),"minHandPresenceConfidence"in e&&F(this.D,2,e.minHandPresenceConfidence??.5),e.cannedGesturesClassifierOptions){var t=new Sr,r=t,i=Cs(e.cannedGesturesClassifierOptions,(n=W(this.h,Sr,3))==null?void 0:n.l());L(r,0,2,i),L(this.h,0,3,t)}else e.cannedGesturesClassifierOptions===void 0&&((s=W(this.h,Sr,3))==null||s.g());return e.customGesturesClassifierOptions?(L(r=t=new Sr,0,2,i=Cs(e.customGesturesClassifierOptions,(a=W(this.h,Sr,4))==null?void 0:a.l())),L(this.h,0,4,t)):e.customGesturesClassifierOptions===void 0&&((c=W(this.h,Sr,4))==null||c.g()),this.l(e)}Ha(e,t){return tl(this),it(this,e,t),rl(this)}Ia(e,t,r){return tl(this),ut(this,e,r,t),rl(this)}m(){var e=new Be;te(e,"image_in"),te(e,"norm_rect"),H(e,"hand_gestures"),H(e,"hand_landmarks"),H(e,"world_hand_landmarks"),H(e,"handedness");const t=new Oe;ct(t,Iu,this.j);const r=new Te;De(r,2,"mediapipe.tasks.vision.gesture_recognizer.GestureRecognizerGraph"),J(r,"IMAGE:image_in"),J(r,"NORM_RECT:norm_rect"),j(r,"HAND_GESTURES:hand_gestures"),j(r,"LANDMARKS:hand_landmarks"),j(r,"WORLD_LANDMARKS:world_hand_landmarks"),j(r,"HANDEDNESS:handedness"),r.o(t),Ye(e,r),this.g.attachProtoVectorListener("hand_landmarks",(i,n)=>{for(const s of i){i=ni(s);const a=[];for(const c of mt(i,Ra,1))a.push({x:se(c,1)??0,y:se(c,2)??0,z:se(c,3)??0,visibility:se(c,4)??0});this.landmarks.push(a)}A(this,n)}),this.g.attachEmptyPacketListener("hand_landmarks",i=>{A(this,i)}),this.g.attachProtoVectorListener("world_hand_landmarks",(i,n)=>{for(const s of i){i=kr(s);const a=[];for(const c of mt(i,Za,1))a.push({x:se(c,1)??0,y:se(c,2)??0,z:se(c,3)??0,visibility:se(c,4)??0});this.worldLandmarks.push(a)}A(this,n)}),this.g.attachEmptyPacketListener("world_hand_landmarks",i=>{A(this,i)}),this.g.attachProtoVectorListener("hand_gestures",(i,n)=>{this.gestures.push(...il(i,!1)),A(this,n)}),this.g.attachEmptyPacketListener("hand_gestures",i=>{A(this,i)}),this.g.attachProtoVectorListener("handedness",(i,n)=>{this.handedness.push(...il(i)),A(this,n)}),this.g.attachEmptyPacketListener("handedness",i=>{A(this,i)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};function nl(e){return{landmarks:e.landmarks,worldLandmarks:e.worldLandmarks,handednesses:e.handedness,handedness:e.handedness}}Ve.prototype.recognizeForVideo=Ve.prototype.Ia,Ve.prototype.recognize=Ve.prototype.Ha,Ve.prototype.setOptions=Ve.prototype.o,Ve.createFromModelPath=function(e,t){return z(Ve,e,{baseOptions:{modelAssetPath:t}})},Ve.createFromModelBuffer=function(e,t){return z(Ve,e,{baseOptions:{modelAssetBuffer:t}})},Ve.createFromOptions=function(e,t){return z(Ve,e,t)},Ve.HAND_CONNECTIONS=js;var Ge=class extends Ue{constructor(e,t){super(new rt(e,t),"image_in","norm_rect",!1),this.landmarks=[],this.worldLandmarks=[],this.handedness=[],L(e=this.h=new vs,0,1,t=new ie),this.u=new bs,L(this.h,0,3,this.u),this.j=new dc,L(this.h,0,2,this.j),yt(this.j,3,1),F(this.j,2,.5),F(this.u,2,.5),F(this.h,4,.5)}get baseOptions(){return W(this.h,ie,1)}set baseOptions(e){L(this.h,0,1,e)}o(e){return"numHands"in e&&yt(this.j,3,e.numHands??1),"minHandDetectionConfidence"in e&&F(this.j,2,e.minHandDetectionConfidence??.5),"minTrackingConfidence"in e&&F(this.h,4,e.minTrackingConfidence??.5),"minHandPresenceConfidence"in e&&F(this.u,2,e.minHandPresenceConfidence??.5),this.l(e)}F(e,t){return this.landmarks=[],this.worldLandmarks=[],this.handedness=[],it(this,e,t),nl(this)}G(e,t,r){return this.landmarks=[],this.worldLandmarks=[],this.handedness=[],ut(this,e,r,t),nl(this)}m(){var e=new Be;te(e,"image_in"),te(e,"norm_rect"),H(e,"hand_landmarks"),H(e,"world_hand_landmarks"),H(e,"handedness");const t=new Oe;ct(t,Fu,this.h);const r=new Te;De(r,2,"mediapipe.tasks.vision.hand_landmarker.HandLandmarkerGraph"),J(r,"IMAGE:image_in"),J(r,"NORM_RECT:norm_rect"),j(r,"LANDMARKS:hand_landmarks"),j(r,"WORLD_LANDMARKS:world_hand_landmarks"),j(r,"HANDEDNESS:handedness"),r.o(t),Ye(e,r),this.g.attachProtoVectorListener("hand_landmarks",(i,n)=>{for(const s of i)i=ni(s),this.landmarks.push(Ri(i));A(this,n)}),this.g.attachEmptyPacketListener("hand_landmarks",i=>{A(this,i)}),this.g.attachProtoVectorListener("world_hand_landmarks",(i,n)=>{for(const s of i)i=kr(s),this.worldLandmarks.push(si(i));A(this,n)}),this.g.attachEmptyPacketListener("world_hand_landmarks",i=>{A(this,i)}),this.g.attachProtoVectorListener("handedness",(i,n)=>{var s=this.handedness,a=s.push;const c=[];for(const l of i){i=Xi(l);const h=[];for(const u of i.g())h.push({score:se(u,2)??0,index:qe(u,1)??0??-1,categoryName:xe(Q(u,3))??""??"",displayName:xe(Q(u,4))??""??""});c.push(h)}a.call(s,...c),A(this,n)}),this.g.attachEmptyPacketListener("handedness",i=>{A(this,i)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Ge.prototype.detectForVideo=Ge.prototype.G,Ge.prototype.detect=Ge.prototype.F,Ge.prototype.setOptions=Ge.prototype.o,Ge.createFromModelPath=function(e,t){return z(Ge,e,{baseOptions:{modelAssetPath:t}})},Ge.createFromModelBuffer=function(e,t){return z(Ge,e,{baseOptions:{modelAssetBuffer:t}})},Ge.createFromOptions=function(e,t){return z(Ge,e,t)},Ge.HAND_CONNECTIONS=js;var sl=tt([0,1],[1,2],[2,3],[3,7],[0,4],[4,5],[5,6],[6,8],[9,10],[11,12],[11,13],[13,15],[15,17],[15,19],[15,21],[17,19],[12,14],[14,16],[16,18],[16,20],[16,22],[18,20],[11,23],[12,24],[23,24],[23,25],[24,26],[25,27],[26,28],[27,29],[28,30],[29,31],[30,32],[27,31],[28,32]);function ol(e){e.h={faceLandmarks:[],faceBlendshapes:[],poseLandmarks:[],poseWorldLandmarks:[],poseSegmentationMasks:[],leftHandLandmarks:[],leftHandWorldLandmarks:[],rightHandLandmarks:[],rightHandWorldLandmarks:[]}}function al(e){try{if(!e.D)return e.h;e.D(e.h)}finally{rn(e)}}function sn(e,t){e=ni(e),t.push(Ri(e))}var Z=class extends Ue{constructor(e,t){super(new rt(e,t),"input_frames_image",null,!1),this.h={faceLandmarks:[],faceBlendshapes:[],poseLandmarks:[],poseWorldLandmarks:[],poseSegmentationMasks:[],leftHandLandmarks:[],leftHandWorldLandmarks:[],rightHandLandmarks:[],rightHandWorldLandmarks:[]},this.outputPoseSegmentationMasks=this.outputFaceBlendshapes=!1,L(e=this.j=new mc,0,1,t=new ie),this.I=new bs,L(this.j,0,2,this.I),this.W=new Lu,L(this.j,0,3,this.W),this.u=new Zi,L(this.j,0,4,this.u),this.O=new ac,L(this.j,0,5,this.O),this.A=new gc,L(this.j,0,6,this.A),this.M=new pc,L(this.j,0,7,this.M),F(this.u,2,.5),F(this.u,3,.3),F(this.O,2,.5),F(this.A,2,.5),F(this.A,3,.3),F(this.M,2,.5),F(this.I,2,.5)}get baseOptions(){return W(this.j,ie,1)}set baseOptions(e){L(this.j,0,1,e)}o(e){return"minFaceDetectionConfidence"in e&&F(this.u,2,e.minFaceDetectionConfidence??.5),"minFaceSuppressionThreshold"in e&&F(this.u,3,e.minFaceSuppressionThreshold??.3),"minFacePresenceConfidence"in e&&F(this.O,2,e.minFacePresenceConfidence??.5),"outputFaceBlendshapes"in e&&(this.outputFaceBlendshapes=!!e.outputFaceBlendshapes),"minPoseDetectionConfidence"in e&&F(this.A,2,e.minPoseDetectionConfidence??.5),"minPoseSuppressionThreshold"in e&&F(this.A,3,e.minPoseSuppressionThreshold??.3),"minPosePresenceConfidence"in e&&F(this.M,2,e.minPosePresenceConfidence??.5),"outputPoseSegmentationMasks"in e&&(this.outputPoseSegmentationMasks=!!e.outputPoseSegmentationMasks),"minHandLandmarksConfidence"in e&&F(this.I,2,e.minHandLandmarksConfidence??.5),this.l(e)}F(e,t,r){const i=typeof t!="function"?t:{};return this.D=typeof t=="function"?t:r,ol(this),it(this,e,i),al(this)}G(e,t,r,i){const n=typeof r!="function"?r:{};return this.D=typeof r=="function"?r:i,ol(this),ut(this,e,n,t),al(this)}m(){var e=new Be;te(e,"input_frames_image"),H(e,"pose_landmarks"),H(e,"pose_world_landmarks"),H(e,"face_landmarks"),H(e,"left_hand_landmarks"),H(e,"left_hand_world_landmarks"),H(e,"right_hand_landmarks"),H(e,"right_hand_world_landmarks");const t=new Oe,r=new Da;De(r,1,"type.googleapis.com/mediapipe.tasks.vision.holistic_landmarker.proto.HolisticLandmarkerGraphOptions"),function(n,s){if(s!=null)if(Array.isArray(s))K(n,2,Li(s,0,Rr));else{if(!(typeof s=="string"||s instanceof nt||Sn(s)))throw Error("invalid value in Any.value field: "+s+" expected a ByteString, a base64 encoded string, a Uint8Array or a jspb array");Et(n,2,Nn(s,!1),Ot())}}(r,this.j.g());const i=new Te;De(i,2,"mediapipe.tasks.vision.holistic_landmarker.HolisticLandmarkerGraph"),Qn(i,8,Da,r),J(i,"IMAGE:input_frames_image"),j(i,"POSE_LANDMARKS:pose_landmarks"),j(i,"POSE_WORLD_LANDMARKS:pose_world_landmarks"),j(i,"FACE_LANDMARKS:face_landmarks"),j(i,"LEFT_HAND_LANDMARKS:left_hand_landmarks"),j(i,"LEFT_HAND_WORLD_LANDMARKS:left_hand_world_landmarks"),j(i,"RIGHT_HAND_LANDMARKS:right_hand_landmarks"),j(i,"RIGHT_HAND_WORLD_LANDMARKS:right_hand_world_landmarks"),i.o(t),Ye(e,i),tn(this,e),this.g.attachProtoListener("pose_landmarks",(n,s)=>{sn(n,this.h.poseLandmarks),A(this,s)}),this.g.attachEmptyPacketListener("pose_landmarks",n=>{A(this,n)}),this.g.attachProtoListener("pose_world_landmarks",(n,s)=>{var a=this.h.poseWorldLandmarks;n=kr(n),a.push(si(n)),A(this,s)}),this.g.attachEmptyPacketListener("pose_world_landmarks",n=>{A(this,n)}),this.outputPoseSegmentationMasks&&(j(i,"POSE_SEGMENTATION_MASK:pose_segmentation_mask"),Ar(this,"pose_segmentation_mask"),this.g.Z("pose_segmentation_mask",(n,s)=>{this.h.poseSegmentationMasks=[Tr(this,n,!0,!this.D)],A(this,s)}),this.g.attachEmptyPacketListener("pose_segmentation_mask",n=>{this.h.poseSegmentationMasks=[],A(this,n)})),this.g.attachProtoListener("face_landmarks",(n,s)=>{sn(n,this.h.faceLandmarks),A(this,s)}),this.g.attachEmptyPacketListener("face_landmarks",n=>{A(this,n)}),this.outputFaceBlendshapes&&(H(e,"extra_blendshapes"),j(i,"FACE_BLENDSHAPES:extra_blendshapes"),this.g.attachProtoListener("extra_blendshapes",(n,s)=>{var a=this.h.faceBlendshapes;this.outputFaceBlendshapes&&(n=Xi(n),a.push(Ts(n.g()??[]))),A(this,s)}),this.g.attachEmptyPacketListener("extra_blendshapes",n=>{A(this,n)})),this.g.attachProtoListener("left_hand_landmarks",(n,s)=>{sn(n,this.h.leftHandLandmarks),A(this,s)}),this.g.attachEmptyPacketListener("left_hand_landmarks",n=>{A(this,n)}),this.g.attachProtoListener("left_hand_world_landmarks",(n,s)=>{var a=this.h.leftHandWorldLandmarks;n=kr(n),a.push(si(n)),A(this,s)}),this.g.attachEmptyPacketListener("left_hand_world_landmarks",n=>{A(this,n)}),this.g.attachProtoListener("right_hand_landmarks",(n,s)=>{sn(n,this.h.rightHandLandmarks),A(this,s)}),this.g.attachEmptyPacketListener("right_hand_landmarks",n=>{A(this,n)}),this.g.attachProtoListener("right_hand_world_landmarks",(n,s)=>{var a=this.h.rightHandWorldLandmarks;n=kr(n),a.push(si(n)),A(this,s)}),this.g.attachEmptyPacketListener("right_hand_world_landmarks",n=>{A(this,n)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Z.prototype.detectForVideo=Z.prototype.G,Z.prototype.detect=Z.prototype.F,Z.prototype.setOptions=Z.prototype.o,Z.createFromModelPath=function(e,t){return z(Z,e,{baseOptions:{modelAssetPath:t}})},Z.createFromModelBuffer=function(e,t){return z(Z,e,{baseOptions:{modelAssetBuffer:t}})},Z.createFromOptions=function(e,t){return z(Z,e,t)},Z.HAND_CONNECTIONS=js,Z.POSE_CONNECTIONS=sl,Z.FACE_LANDMARKS_LIPS=Ps,Z.FACE_LANDMARKS_LEFT_EYE=Os,Z.FACE_LANDMARKS_LEFT_EYEBROW=Bs,Z.FACE_LANDMARKS_LEFT_IRIS=Qc,Z.FACE_LANDMARKS_RIGHT_EYE=Us,Z.FACE_LANDMARKS_RIGHT_EYEBROW=Vs,Z.FACE_LANDMARKS_RIGHT_IRIS=Jc,Z.FACE_LANDMARKS_FACE_OVAL=Gs,Z.FACE_LANDMARKS_CONTOURS=Zc,Z.FACE_LANDMARKS_TESSELATION=Rc;var Qe=class extends Ue{constructor(e,t){super(new rt(e,t),"input_image","norm_rect",!0),this.j={classifications:[]},L(e=this.h=new yc,0,1,t=new ie)}get baseOptions(){return W(this.h,ie,1)}set baseOptions(e){L(this.h,0,1,e)}o(e){return L(this.h,0,2,Cs(e,W(this.h,ps,2))),this.l(e)}sa(e,t){return this.j={classifications:[]},it(this,e,t),this.j}ta(e,t,r){return this.j={classifications:[]},ut(this,e,r,t),this.j}m(){var e=new Be;te(e,"input_image"),te(e,"norm_rect"),H(e,"classifications");const t=new Oe;ct(t,Mu,this.h);const r=new Te;De(r,2,"mediapipe.tasks.vision.image_classifier.ImageClassifierGraph"),J(r,"IMAGE:input_image"),J(r,"NORM_RECT:norm_rect"),j(r,"CLASSIFICATIONS:classifications"),r.o(t),Ye(e,r),this.g.attachProtoListener("classifications",(i,n)=>{this.j=Vu(xu(i)),A(this,n)}),this.g.attachEmptyPacketListener("classifications",i=>{A(this,i)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Qe.prototype.classifyForVideo=Qe.prototype.ta,Qe.prototype.classify=Qe.prototype.sa,Qe.prototype.setOptions=Qe.prototype.o,Qe.createFromModelPath=function(e,t){return z(Qe,e,{baseOptions:{modelAssetPath:t}})},Qe.createFromModelBuffer=function(e,t){return z(Qe,e,{baseOptions:{modelAssetBuffer:t}})},Qe.createFromOptions=function(e,t){return z(Qe,e,t)};var je=class extends Ue{constructor(e,t){super(new rt(e,t),"image_in","norm_rect",!0),this.h=new bc,this.embeddings={embeddings:[]},L(e=this.h,0,1,t=new ie)}get baseOptions(){return W(this.h,ie,1)}set baseOptions(e){L(this.h,0,1,e)}o(e){var t=this.h,r=W(this.h,nc,2);return r=r?r.clone():new nc,e.l2Normalize!==void 0?K(r,1,Qr(e.l2Normalize)):"l2Normalize"in e&&K(r,1),e.quantize!==void 0?K(r,2,Qr(e.quantize)):"quantize"in e&&K(r,2),L(t,0,2,r),this.l(e)}za(e,t){return it(this,e,t),this.embeddings}Aa(e,t,r){return ut(this,e,r,t),this.embeddings}m(){var e=new Be;te(e,"image_in"),te(e,"norm_rect"),H(e,"embeddings_out");const t=new Oe;ct(t,Du,this.h);const r=new Te;De(r,2,"mediapipe.tasks.vision.image_embedder.ImageEmbedderGraph"),J(r,"IMAGE:image_in"),J(r,"NORM_RECT:norm_rect"),j(r,"EMBEDDINGS:embeddings_out"),r.o(t),Ye(e,r),this.g.attachProtoListener("embeddings_out",(i,n)=>{i=ku(i),this.embeddings=function(s){return{embeddings:mt(s,_u,1).map(a=>{var h,u;const c={headIndex:qe(a,3)??0??-1,headName:xe(Q(a,4))??""??""};var l=a.v;return Zo(l,0|l[T],tc,qn(a,1))!==void 0?(a=zt(a=W(a,tc,qn(a,1),void 0),1,ot,$t()),c.floatEmbedding=a.slice()):(l=new Uint8Array(0),c.quantizedEmbedding=((u=(h=W(a,Eu,qn(a,2),void 0))==null?void 0:h.na())==null?void 0:u.h())??l),c}),timestampMs:Tc(ta(s))}}(i),A(this,n)}),this.g.attachEmptyPacketListener("embeddings_out",i=>{A(this,i)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};je.cosineSimilarity=function(e,t){if(e.floatEmbedding&&t.floatEmbedding)e=Fc(e.floatEmbedding,t.floatEmbedding);else{if(!e.quantizedEmbedding||!t.quantizedEmbedding)throw Error("Cannot compute cosine similarity between quantized and float embeddings.");e=Fc(Ic(e.quantizedEmbedding),Ic(t.quantizedEmbedding))}return e},je.prototype.embedForVideo=je.prototype.Aa,je.prototype.embed=je.prototype.za,je.prototype.setOptions=je.prototype.o,je.createFromModelPath=function(e,t){return z(je,e,{baseOptions:{modelAssetPath:t}})},je.createFromModelBuffer=function(e,t){return z(je,e,{baseOptions:{modelAssetBuffer:t}})},je.createFromOptions=function(e,t){return z(je,e,t)};var $s=class{constructor(e,t,r){this.confidenceMasks=e,this.categoryMask=t,this.qualityScores=r}close(){var e,t;(e=this.confidenceMasks)==null||e.forEach(r=>{r.close()}),(t=this.categoryMask)==null||t.close()}};function qu(e){var r,i;const t=function(n){return mt(n,Te,1)}(e.ca()).filter(n=>(xe(Q(n,1))??"").includes("mediapipe.tasks.TensorsToSegmentationCalculator"));if(e.u=[],t.length>1)throw Error("The graph has more than one mediapipe.tasks.TensorsToSegmentationCalculator.");t.length===1&&(((i=(r=W(t[0],Oe,7))==null?void 0:r.j())==null?void 0:i.g())??new Map).forEach((n,s)=>{e.u[Number(s)]=xe(Q(n,1))??""})}function cl(e){e.categoryMask=void 0,e.confidenceMasks=void 0,e.qualityScores=void 0}function ll(e){try{const t=new $s(e.confidenceMasks,e.categoryMask,e.qualityScores);if(!e.j)return t;e.j(t)}finally{rn(e)}}$s.prototype.close=$s.prototype.close;var Ne=class extends Ue{constructor(e,t){super(new rt(e,t),"image_in","norm_rect",!1),this.u=[],this.outputCategoryMask=!1,this.outputConfidenceMasks=!0,this.h=new ks,this.A=new vc,L(this.h,0,3,this.A),L(e=this.h,0,1,t=new ie)}get baseOptions(){return W(this.h,ie,1)}set baseOptions(e){L(this.h,0,1,e)}o(e){return e.displayNamesLocale!==void 0?K(this.h,2,Zr(e.displayNamesLocale)):"displayNamesLocale"in e&&K(this.h,2),"outputCategoryMask"in e&&(this.outputCategoryMask=e.outputCategoryMask??!1),"outputConfidenceMasks"in e&&(this.outputConfidenceMasks=e.outputConfidenceMasks??!0),super.l(e)}L(){qu(this)}segment(e,t,r){const i=typeof t!="function"?t:{};return this.j=typeof t=="function"?t:r,cl(this),it(this,e,i),ll(this)}La(e,t,r,i){const n=typeof r!="function"?r:{};return this.j=typeof r=="function"?r:i,cl(this),ut(this,e,n,t),ll(this)}Da(){return this.u}m(){var e=new Be;te(e,"image_in"),te(e,"norm_rect");const t=new Oe;ct(t,_c,this.h);const r=new Te;De(r,2,"mediapipe.tasks.vision.image_segmenter.ImageSegmenterGraph"),J(r,"IMAGE:image_in"),J(r,"NORM_RECT:norm_rect"),r.o(t),Ye(e,r),tn(this,e),this.outputConfidenceMasks&&(H(e,"confidence_masks"),j(r,"CONFIDENCE_MASKS:confidence_masks"),Ar(this,"confidence_masks"),this.g.aa("confidence_masks",(i,n)=>{this.confidenceMasks=i.map(s=>Tr(this,s,!0,!this.j)),A(this,n)}),this.g.attachEmptyPacketListener("confidence_masks",i=>{this.confidenceMasks=[],A(this,i)})),this.outputCategoryMask&&(H(e,"category_mask"),j(r,"CATEGORY_MASK:category_mask"),Ar(this,"category_mask"),this.g.Z("category_mask",(i,n)=>{this.categoryMask=Tr(this,i,!1,!this.j),A(this,n)}),this.g.attachEmptyPacketListener("category_mask",i=>{this.categoryMask=void 0,A(this,i)})),H(e,"quality_scores"),j(r,"QUALITY_SCORES:quality_scores"),this.g.attachFloatVectorListener("quality_scores",(i,n)=>{this.qualityScores=i,A(this,n)}),this.g.attachEmptyPacketListener("quality_scores",i=>{this.categoryMask=void 0,A(this,i)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Ne.prototype.getLabels=Ne.prototype.Da,Ne.prototype.segmentForVideo=Ne.prototype.La,Ne.prototype.segment=Ne.prototype.segment,Ne.prototype.setOptions=Ne.prototype.o,Ne.createFromModelPath=function(e,t){return z(Ne,e,{baseOptions:{modelAssetPath:t}})},Ne.createFromModelBuffer=function(e,t){return z(Ne,e,{baseOptions:{modelAssetBuffer:t}})},Ne.createFromOptions=function(e,t){return z(Ne,e,t)};var zs=class{constructor(e,t,r){this.confidenceMasks=e,this.categoryMask=t,this.qualityScores=r}close(){var e,t;(e=this.confidenceMasks)==null||e.forEach(r=>{r.close()}),(t=this.categoryMask)==null||t.close()}};zs.prototype.close=zs.prototype.close;var ht=class extends Ue{constructor(e,t){super(new rt(e,t),"image_in","norm_rect_in",!1),this.outputCategoryMask=!1,this.outputConfidenceMasks=!0,this.h=new ks,this.u=new vc,L(this.h,0,3,this.u),L(e=this.h,0,1,t=new ie)}get baseOptions(){return W(this.h,ie,1)}set baseOptions(e){L(this.h,0,1,e)}o(e){return"outputCategoryMask"in e&&(this.outputCategoryMask=e.outputCategoryMask??!1),"outputConfidenceMasks"in e&&(this.outputConfidenceMasks=e.outputConfidenceMasks??!0),super.l(e)}segment(e,t,r,i){const n=typeof r!="function"?r:{};if(this.j=typeof r=="function"?r:i,this.qualityScores=this.categoryMask=this.confidenceMasks=void 0,r=this.C+1,i=new Sc,t.keypoint&&t.scribble)throw Error("Cannot provide both keypoint and scribble.");if(t.keypoint){var s=new Ss;Et(s,3,Qr(!0),!1),Et(s,1,Xr(t.keypoint.x),0),Et(s,2,Xr(t.keypoint.y),0),ei(i,1,As,s)}else{if(!t.scribble)throw Error("Must provide either a keypoint or a scribble.");{const c=new Ou;for(s of t.scribble)Et(t=new Ss,3,Qr(!0),!1),Et(t,1,Xr(s.x),0),Et(t,2,Xr(s.y),0),Qn(c,1,Ss,t);ei(i,2,As,c)}}this.g.addProtoToStream(i.g(),"mediapipe.tasks.vision.interactive_segmenter.proto.RegionOfInterest","roi_in",r),it(this,e,n);e:{try{const c=new zs(this.confidenceMasks,this.categoryMask,this.qualityScores);if(!this.j){var a=c;break e}this.j(c)}finally{rn(this)}a=void 0}return a}m(){var e=new Be;te(e,"image_in"),te(e,"roi_in"),te(e,"norm_rect_in");const t=new Oe;ct(t,_c,this.h);const r=new Te;De(r,2,"mediapipe.tasks.vision.interactive_segmenter.InteractiveSegmenterGraphV2"),J(r,"IMAGE:image_in"),J(r,"ROI:roi_in"),J(r,"NORM_RECT:norm_rect_in"),r.o(t),Ye(e,r),tn(this,e),this.outputConfidenceMasks&&(H(e,"confidence_masks"),j(r,"CONFIDENCE_MASKS:confidence_masks"),Ar(this,"confidence_masks"),this.g.aa("confidence_masks",(i,n)=>{this.confidenceMasks=i.map(s=>Tr(this,s,!0,!this.j)),A(this,n)}),this.g.attachEmptyPacketListener("confidence_masks",i=>{this.confidenceMasks=[],A(this,i)})),this.outputCategoryMask&&(H(e,"category_mask"),j(r,"CATEGORY_MASK:category_mask"),Ar(this,"category_mask"),this.g.Z("category_mask",(i,n)=>{this.categoryMask=Tr(this,i,!1,!this.j),A(this,n)}),this.g.attachEmptyPacketListener("category_mask",i=>{this.categoryMask=void 0,A(this,i)})),H(e,"quality_scores"),j(r,"QUALITY_SCORES:quality_scores"),this.g.attachFloatVectorListener("quality_scores",(i,n)=>{this.qualityScores=i,A(this,n)}),this.g.attachEmptyPacketListener("quality_scores",i=>{this.categoryMask=void 0,A(this,i)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};ht.prototype.segment=ht.prototype.segment,ht.prototype.setOptions=ht.prototype.o,ht.createFromModelPath=function(e,t){return z(ht,e,{baseOptions:{modelAssetPath:t}})},ht.createFromModelBuffer=function(e,t){return z(ht,e,{baseOptions:{modelAssetBuffer:t}})},ht.createFromOptions=function(e,t){return z(ht,e,t)};var Je=class extends Ue{constructor(e,t){super(new rt(e,t),"input_frame_gpu","norm_rect",!1),this.j={detections:[]},L(e=this.h=new Ac,0,1,t=new ie)}get baseOptions(){return W(this.h,ie,1)}set baseOptions(e){L(this.h,0,1,e)}o(e){return e.displayNamesLocale!==void 0?K(this.h,2,Zr(e.displayNamesLocale)):"displayNamesLocale"in e&&K(this.h,2),e.maxResults!==void 0?yt(this.h,3,e.maxResults):"maxResults"in e&&K(this.h,3),e.scoreThreshold!==void 0?F(this.h,4,e.scoreThreshold):"scoreThreshold"in e&&K(this.h,4),e.categoryAllowlist!==void 0?Mi(this.h,5,e.categoryAllowlist):"categoryAllowlist"in e&&K(this.h,5),e.categoryDenylist!==void 0?Mi(this.h,6,e.categoryDenylist):"categoryDenylist"in e&&K(this.h,6),this.l(e)}F(e,t){return this.j={detections:[]},it(this,e,t),this.j}G(e,t,r){return this.j={detections:[]},ut(this,e,r,t),this.j}m(){var e=new Be;te(e,"input_frame_gpu"),te(e,"norm_rect"),H(e,"detections");const t=new Oe;ct(t,Bu,this.h);const r=new Te;De(r,2,"mediapipe.tasks.vision.ObjectDetectorGraph"),J(r,"IMAGE:input_frame_gpu"),J(r,"NORM_RECT:norm_rect"),j(r,"DETECTIONS:detections"),r.o(t),Ye(e,r),this.g.attachProtoVectorListener("detections",(i,n)=>{for(const s of i)i=Ja(s),this.j.detections.push(Nc(i));A(this,n)}),this.g.attachEmptyPacketListener("detections",i=>{A(this,i)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Je.prototype.detectForVideo=Je.prototype.G,Je.prototype.detect=Je.prototype.F,Je.prototype.setOptions=Je.prototype.o,Je.createFromModelPath=async function(e,t){return z(Je,e,{baseOptions:{modelAssetPath:t}})},Je.createFromModelBuffer=function(e,t){return z(Je,e,{baseOptions:{modelAssetBuffer:t}})},Je.createFromOptions=function(e,t){return z(Je,e,t)};var Ws=class{constructor(e,t,r){this.landmarks=e,this.worldLandmarks=t,this.segmentationMasks=r}close(){var e;(e=this.segmentationMasks)==null||e.forEach(t=>{t.close()})}};function dl(e){e.landmarks=[],e.worldLandmarks=[],e.segmentationMasks=void 0}function ul(e){try{const t=new Ws(e.landmarks,e.worldLandmarks,e.segmentationMasks);if(!e.u)return t;e.u(t)}finally{rn(e)}}Ws.prototype.close=Ws.prototype.close;var $e=class extends Ue{constructor(e,t){super(new rt(e,t),"image_in","norm_rect",!1),this.landmarks=[],this.worldLandmarks=[],this.outputSegmentationMasks=!1,L(e=this.h=new Cc,0,1,t=new ie),this.A=new pc,L(this.h,0,3,this.A),this.j=new gc,L(this.h,0,2,this.j),yt(this.j,4,1),F(this.j,2,.5),F(this.A,2,.5),F(this.h,4,.5)}get baseOptions(){return W(this.h,ie,1)}set baseOptions(e){L(this.h,0,1,e)}o(e){return"numPoses"in e&&yt(this.j,4,e.numPoses??1),"minPoseDetectionConfidence"in e&&F(this.j,2,e.minPoseDetectionConfidence??.5),"minTrackingConfidence"in e&&F(this.h,4,e.minTrackingConfidence??.5),"minPosePresenceConfidence"in e&&F(this.A,2,e.minPosePresenceConfidence??.5),"outputSegmentationMasks"in e&&(this.outputSegmentationMasks=e.outputSegmentationMasks??!1),this.l(e)}F(e,t,r){const i=typeof t!="function"?t:{};return this.u=typeof t=="function"?t:r,dl(this),it(this,e,i),ul(this)}G(e,t,r,i){const n=typeof r!="function"?r:{};return this.u=typeof r=="function"?r:i,dl(this),ut(this,e,n,t),ul(this)}m(){var e=new Be;te(e,"image_in"),te(e,"norm_rect"),H(e,"normalized_landmarks"),H(e,"world_landmarks"),H(e,"segmentation_masks");const t=new Oe;ct(t,Uu,this.h);const r=new Te;De(r,2,"mediapipe.tasks.vision.pose_landmarker.PoseLandmarkerGraph"),J(r,"IMAGE:image_in"),J(r,"NORM_RECT:norm_rect"),j(r,"NORM_LANDMARKS:normalized_landmarks"),j(r,"WORLD_LANDMARKS:world_landmarks"),r.o(t),Ye(e,r),tn(this,e),this.g.attachProtoVectorListener("normalized_landmarks",(i,n)=>{this.landmarks=[];for(const s of i)i=ni(s),this.landmarks.push(Ri(i));A(this,n)}),this.g.attachEmptyPacketListener("normalized_landmarks",i=>{this.landmarks=[],A(this,i)}),this.g.attachProtoVectorListener("world_landmarks",(i,n)=>{this.worldLandmarks=[];for(const s of i)i=kr(s),this.worldLandmarks.push(si(i));A(this,n)}),this.g.attachEmptyPacketListener("world_landmarks",i=>{this.worldLandmarks=[],A(this,i)}),this.outputSegmentationMasks&&(j(r,"SEGMENTATION_MASK:segmentation_masks"),Ar(this,"segmentation_masks"),this.g.aa("segmentation_masks",(i,n)=>{this.segmentationMasks=i.map(s=>Tr(this,s,!0,!this.u)),A(this,n)}),this.g.attachEmptyPacketListener("segmentation_masks",i=>{this.segmentationMasks=[],A(this,i)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};$e.prototype.detectForVideo=$e.prototype.G,$e.prototype.detect=$e.prototype.F,$e.prototype.setOptions=$e.prototype.o,$e.createFromModelPath=function(e,t){return z($e,e,{baseOptions:{modelAssetPath:t}})},$e.createFromModelBuffer=function(e,t){return z($e,e,{baseOptions:{modelAssetBuffer:t}})},$e.createFromOptions=function(e,t){return z($e,e,t)},$e.POSE_CONNECTIONS=sl;const on="https://storage.googleapis.com/mediapipe-models/face_landmarker/face_landmarker/float16/latest/face_landmarker.task",Ku="https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@0.10.32/wasm",Yu=()=>{const e=d.useRef(null),[t,r]=d.useState(!1),[i,n]=d.useState("Initializing..."),[s,a]=d.useState(0),[c,l]=d.useState(!1);d.useEffect(()=>{"serviceWorker"in navigator&&navigator.serviceWorker.register("/sw.js").then(w=>{console.log("ServiceWorker registered:",w)}).catch(w=>{console.log("ServiceWorker registration failed:",w)})},[]);const h=async()=>"caches"in window?await(await caches.open("mediapipe-models-v1")).match(on)!==void 0:!1,u=async()=>{try{const w=await fetch(on),g=w.headers.get("content-length"),p=g?parseInt(g,10):0;if(!w.body)throw new Error("No response body");const y=w.body.getReader();let b=0;const m=[];for(;;){const{done:v,value:k}=await y.read();if(v)break;if(m.push(k),b+=k.length,p){const _=Math.round(b/p*100);a(_),n(`Downloading model... ${_}%`)}}return"caches"in window&&await(await caches.open("mediapipe-models-v1")).put(on,new Response(new Blob(m),{headers:{"Content-Type":"application/octet-stream"}})),!0}catch(w){return console.error("Failed to preload model:",w),!1}};return d.useEffect(()=>{(async()=>{try{n("Checking cached models..."),await h()?n("Using cached model..."):(n("Model not cached. Downloading..."),await u()),n("Loading MediaPipe WASM...");const p=await Xt.forVisionTasks(Ku);n("Creating face landmarker...");const y=await re.createFromOptions(p,{baseOptions:{modelAssetPath:on,delegate:"GPU"},runningMode:"VIDEO",outputFaceBlendshapes:!0,numFaces:2});e.current=y,r(!0),n("Model loaded successfully ✅")}catch(g){console.error("Model init error:",g),n(`Error: ${g==null?void 0:g.message}`),(g==null?void 0:g.name)==="NotAllowedError"&&l(!0)}})()},[]),{faceLandmarkerRef:e,isModelLoaded:t,statusMessage:i,setStatusMessage:n,loadingProgress:s,permissionDenied:c,clearCache:async()=>{"caches"in window&&(await caches.delete("mediapipe-models-v1"),n("Cache cleared. Please refresh to re-download models."))}}},Xu=()=>{const[e,t]=d.useState(0),r=d.useRef({lastTime:0,frames:0,fps:0}),i=d.useCallback(()=>{const n=performance.now(),s=r.current;if(s.frames++,n-s.lastTime>=1e3){const a=Math.round(s.frames*1e3/(n-s.lastTime));t(a),s.frames=0,s.lastTime=n}},[]);return{fps:e,updateFPS:i}},Qu=()=>{const e=d.useRef({value:100,isLookingAway:!1}),t=d.useCallback((s,a,c,l)=>{if(!s||!c||!a)return;const h=s.getContext("2d");if(!h)return;const{width:u,height:f}=s;if(h.clearRect(0,0,u,f),h.drawImage(a,0,0,u,f),l){h.fillStyle="#00FF00";for(const w of c)h.fillRect(w.x*u-.5,w.y*f-.5,1,1)}},[]),r=d.useCallback(s=>{const a=e.current.value/100,c=100,l=20,h=20,u=40;s.fillStyle="rgba(0, 0, 0, 0.3)",s.fillRect(h,u,l,c),s.fillStyle=`rgba(${Math.floor(255*(1-a))}, ${Math.floor(255*a)}, 0, 0.8)`;const f=c*a;s.fillRect(h,u+c-f,l,f),s.fillStyle="#FFFFFF",s.fillRect(h,u+c*(1-a),l,2)},[]),i=d.useCallback((s,a,c,l,h,u,f)=>{if(t(s,a,c,l),h&&u&&f){const w=s.getContext("2d");w&&r(w)}},[t,r]),n=d.useCallback((s,a)=>{const c=s.getContext("2d");c&&(c.clearRect(0,0,s.width,s.height),c.drawImage(a,0,0,s.width,s.height))},[]);return{drawLandmarks:t,drawEngagementBar:r,drawWithEngagementBar:i,clearCanvas:n,engagementRef:e}},Ju=50,Zu=()=>{const[e,t]=d.useState(100),[r,i]=d.useState(!1),n=d.useRef(0),s=d.useCallback((a,c,l)=>{if(!l||a.length<468)return;const h=a[33],u=a[263],f=a[1];if(!h||!u||!f)return;const w=(h.x+u.x)*.5,g=(h.y+u.y)*.5,p=w-c.x,y=g-c.y,b=Math.sqrt(p*p+y*y),m=Math.abs(f.y-c.noseY)*100,v=Math.abs(f.x-c.noseX)*100,k=Math.max(0,100-(b*200+m+v)),_=k<Ju,S=performance.now();return S-n.current>100&&(t(k),i(_),n.current=S),{engagement:k,isLookingAway:_}},[]);return{engagement:e,isLookingAway:r,analyzeGaze:s,setEngagement:t,setIsLookingAway:i}},Ru=.05,eh=()=>{const[e,t]=d.useState(!1),[r,i]=d.useState(!1),n=d.useCallback((c,l)=>Math.sqrt(Math.pow(c.x-l.x,2)+Math.pow(c.y-l.y,2)),[]),s=d.useCallback((c,l)=>{if(!c||!l)return 0;const h=[1,33,263,61,291,10,152];let u=0,f=0;const w=l[33],g=l[263],p=c[33],y=c[263];if(!w||!g||!p||!y)return 0;const b=n(w,g),m=n(p,y);if(b===0||m===0)return 0;for(const k of h){const _=l[k],S=c[k];if(_&&S){const E=w.x+(S.x-p.x)*b/m,P=w.y+(S.y-p.y)*b/m;u+=n(_,{x:E,y:P}),f++}}return f===0?0:u/f},[n]),a=d.useCallback((c,l,h,u)=>{if(!c.faceLandmarks||c.faceLandmarks.length===0)return u("Face not detected."),i(!0),t(!1),null;if(l&&h){let f=null,w=0;for(const g of c.faceLandmarks)s(g,h)<Ru&&(f=g,w++);return w===1?(t(!1),i(!1),u("Reference face tracked."),f):w>1?(t(!0),i(!1),u("Multiple matching faces detected. Tracking suspended."),null):(t(!1),i(!0),u("Reference face not detected."),null)}else{const f=c.faceLandmarks[0];if(c.faceLandmarks.length>1)return t(!0),i(!1),u("Multiple faces detected. Please ensure only you are visible."),null;if(!f)return i(!0),t(!1),u("Face not detected."),null;const g=f[1],p=f[33],y=f[263];return g&&p&&y&&g.x>.35&&g.x<.65&&g.y>.3&&g.y<.7&&p.x>.2&&p.x<.8&&y.x>.2&&y.x<.8?(i(!1),t(!1),u("Face detected. Ready for calibration."),f):(i(!0),t(!1),u("Please position your face in the center."),null)}},[s]);return{multipleFacesDetected:e,referenceFaceNotDetected:r,analyzeFace:a,setMultipleFacesDetected:t,setReferenceFaceNotDetected:i}},th=500,rh=(e,t,r)=>{const[i,n]=d.useState(!1),[s,a]=d.useState(ke.MODEL_LOADING),{incrementGazeViolation:c}=eo(),{multipleFacesDetected:l,referenceFaceNotDetected:h,isLookingAway:u}=e;d.useEffect(()=>{if(!r)return;let g;return(u||l||h)&&t?g=setTimeout(()=>{n(!0),u?(a("looking_away"),c("looking_away")):l?(a("multiple_faces"),c("multiple_faces")):h&&(a("no_face_detected"),c("no_face_detected"))},th):(n(!1),s===ke.MODEL_LOADING?g=setTimeout(()=>{a("face_detected")},500):a("face_detected")),()=>{clearTimeout(g)}},[u,l,h,t,c,r]);const f=d.useCallback(()=>l?ke.MULTIPLE_FACES:h?"no_face_detected":u?ke.LOOKING_AWAY:s===ke.MODEL_LOADING?ke.MODEL_LOADING:ke.FACE_DETECTED,[l,h,u,s]),w=d.useCallback(()=>{n(!1),a("face_detected")},[]);return{showGazeWarningModal:i,faceDetectionState:s,getWarningType:f,closeWarningModal:w,setShowGazeWarningModal:n,setFaceDetectionState:a}};function ih(e){var t;if(!navigator.onLine)return{type:"network",message:"No internet connection",retryable:!0,userMessage:"Please check your internet connection and try again."};if(e.name==="AbortError"||(t=e.message)!=null&&t.includes("timeout"))return{type:"timeout",message:"Request timed out",retryable:!0,userMessage:"The request is taking longer than expected. Please try again."};if(e.status){const{status:r}=e;if(r===401||r===403)return{type:"auth",status:r,message:"Authentication failed",retryable:!1,userMessage:"Your session has expired. Please refresh the page."};if(r===429)return{type:"rate-limit",status:r,message:"Too many requests",retryable:!0,userMessage:"Please wait a moment before trying again."};if(r>=500)return{type:"server",status:r,message:`Server error: ${r}`,retryable:!0,userMessage:"Our servers are experiencing issues. Please try again in a few moments."};if(r>=400)return{type:"client",status:r,message:`Client error: ${r}`,retryable:!1,userMessage:"There was an issue with your request. Please check your input."}}return{type:"unknown",message:e.message||"Unknown error occurred",retryable:!0,userMessage:"Something unexpected happened. Please try again.",originalError:e}}async function Nt(e,t={},r={attempts:3,backoff:"exponential",baseDelay:1e3,maxDelay:1e4,jitter:!0}){let i;for(let n=1;n<=r.attempts;n++)try{const s=new AbortController,a=setTimeout(()=>s.abort(),6e4),c=await fetch(e,{...t,signal:s.signal});if(clearTimeout(a),c.status>=400&&c.status<500&&c.status!==429)return c;if(!c.ok)throw new Error(`HTTP ${c.status}: ${c.statusText}`);return c}catch(s){i=s;const a=ih(s);if(!a.retryable||n===r.attempts)throw a;const c=nh(n,r);console.warn(`API request failed (attempt ${n}/${r.attempts}), retrying in ${c}ms:`,a.message),await new Promise(l=>setTimeout(l,c))}throw i}function nh(e,t){let r;return t.backoff==="exponential"?r=t.baseDelay*Math.pow(2,e-1):r=t.baseDelay,r=Math.min(r,t.maxDelay),t.jitter&&(r=r*(.5+Math.random()*.5)),Math.round(r)}const It={v2:"/v2"},Ft={GENERATE_QUESTION:e=>`${It.v2}/interviews/${e}/next-question`,SCREENSHOT_UPLOAD:e=>`${It.v2}/interviews/${e}/assets/upload-url`,CONFIRM_UPLOAD:e=>`${It.v2}/interviews/assets/${e}/confirm`,TRANSCRIBE_ANSWER:e=>`${It.v2}/interviews/${e}/transcribe-answer`,SUBMIT_ANSWER:e=>`${It.v2}/interviews/${e}/submit-answer`,EXIT:e=>`${It.v2}/interviews/${e}/exit`,CONFIG:e=>`${It.v2}/interviews/${e}/config`,TRANSCRIPTION:e=>`${It.v2}/interviews/${e}/transcript`};class Y extends Error{constructor(t,r,i=!1){super(t),this.code=r,this.recoverable=i,this.name="STTError"}}const sh=50*1024*1024,hl=300,fl=500,ai=class ai{constructor(t={}){we(this,"config");we(this,"mediaRecorder",null);we(this,"audioChunks",[]);we(this,"audioChunksTotalSize",0);we(this,"recordingStream",null);we(this,"autoStopTimeoutId",null);we(this,"disposed",!1);we(this,"pendingStopPromise",null);we(this,"isStarting",!1);we(this,"recordingStartTime",null);this.config={baseUrl:"http://localhost:8000",provider:"groq",model:"whisper-large-v3-turbo",language:"en",includeTimestamps:!1,temperature:0,...t}}updateConfig(t){this.throwIfDisposed(),this.config={...this.config,...t}}isRecordingSupported(){return!!(navigator.mediaDevices&&typeof navigator.mediaDevices.getUserMedia=="function"&&window.MediaRecorder)}async startRecording(t,r){var i;if(this.throwIfDisposed(),!this.isRecordingSupported())throw new Y("Audio recording is not supported in this browser","RECORDING_NOT_SUPPORTED",!1);if(this.isRecording()||this.isStarting){console.warn("STTService.startRecording: already recording or starting, ignoring duplicate call.");return}this.isStarting=!0;try{this.recordingStream=await navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0,sampleRate:{ideal:16e3},channelCount:{ideal:1}}}),ai.activeStream=this.recordingStream,this.audioChunks=[],this.audioChunksTotalSize=0;const n=this.getSupportedMimeType();this.mediaRecorder=new MediaRecorder(this.recordingStream,{mimeType:n}),this.mediaRecorder.addEventListener("dataavailable",s=>{var a,c,l;if(s.data.size>0){if(this.audioChunksTotalSize+s.data.size>sh){console.error(`Max size exceeded: ${(this.audioChunksTotalSize/1024/1024).toFixed(2)} MB`);const h=new Y("Recording exceeded maximum size limit","MAX_SIZE_EXCEEDED",!1);(a=r==null?void 0:r.onError)==null||a.call(r,h),this.isRecording()&&((c=this.mediaRecorder)==null||c.stop());return}this.audioChunks.push(s.data),this.audioChunksTotalSize+=s.data.size,(l=r==null?void 0:r.onDataAvailable)==null||l.call(r,s.data)}}),this.mediaRecorder.addEventListener("stop",()=>{var s;(s=r==null?void 0:r.onStop)==null||s.call(r)},{once:!0}),this.mediaRecorder.addEventListener("error",s=>{var c;const a=new Y(`Recording failed: ${s.error}`,"RECORDING_ERROR",!0);(c=r==null?void 0:r.onError)==null||c.call(r,a),this.cleanup()}),this.mediaRecorder.start(100),this.recordingStartTime=Date.now(),(i=r==null?void 0:r.onStart)==null||i.call(r),t&&t>0&&(this.autoStopTimeoutId=setTimeout(()=>{this.handleAutoStop()},t*1e3))}catch(n){if(this.cleanup(),n instanceof Error){if(n.name==="NotAllowedError"||n.name==="PermissionDeniedError")throw new Y("Microphone permission was denied","PERMISSION_DENIED",!1);if(n.name==="NotFoundError")throw new Y("No microphone found","NO_MICROPHONE",!1)}throw new Y(`Failed to start recording: ${n instanceof Error?n.message:String(n)}`,"START_RECORDING_FAILED",!0)}finally{this.isStarting=!1}}async stopRecording(){var t;if(this.throwIfDisposed(),this.pendingStopPromise)return this.pendingStopPromise;if(this.autoStopTimeoutId&&(clearTimeout(this.autoStopTimeoutId),this.autoStopTimeoutId=null),!this.mediaRecorder||this.mediaRecorder.state==="inactive"){if(this.audioChunks.length>0){const i=((t=this.mediaRecorder)==null?void 0:t.mimeType)||"audio/webm",n=new Blob(this.audioChunks,{type:i});return this.cleanup(),n}const r=this.mediaRecorder?"State is inactive":"MediaRecorder is null";throw console.warn(`Cannot stop recording: ${r}`),new Y("No active recording to stop","NO_ACTIVE_RECORDING",!1)}if(this.recordingStartTime!==null){const r=Date.now()-this.recordingStartTime;r<hl&&await new Promise(i=>setTimeout(i,hl-r))}return this.pendingStopPromise=new Promise((r,i)=>{if(!this.mediaRecorder){this.pendingStopPromise=null,i(new Y("MediaRecorder is null","MEDIARECORDER_NULL",!1));return}const n=this.mediaRecorder,s=()=>{setTimeout(()=>{try{const a=n.mimeType||"audio/webm",c=new Blob(this.audioChunks,{type:a});if(!c||c.size===0){this.cleanup(),i(new Y("Audio blob is empty","EMPTY_BLOB",!1));return}this.cleanup(),r(c)}catch(a){this.cleanup(),i(new Y(`Failed to create audio blob: ${a instanceof Error?a.message:String(a)}`,"BLOB_CREATION_FAILED",!1))}finally{this.pendingStopPromise=null}},0)};n.addEventListener("stop",s,{once:!0});try{n.requestData(),n.stop()}catch(a){this.pendingStopPromise=null,i(a)}}),this.pendingStopPromise}handleAutoStop(){if(!this.isRecording())return;const t=this.recordingStartTime?Date.now()-this.recordingStartTime:1/0;if(t<fl){const r=fl-t;setTimeout(()=>{this.isRecording()&&this.executeAutoStop()},r);return}this.executeAutoStop()}executeAutoStop(){this.stopRecording().catch(t=>{console.error("Auto-stop recording failed:",t),t instanceof Y&&console.error(`[${t.code}] ${t.message}`)})}async transcribe(t){this.throwIfDisposed();const{audioBlob:r}=t;if(!r||r.size===0)throw new Y("Audio blob is empty or invalid","INVALID_AUDIO",!1);try{const i=new FormData,n=new File([r],"recording.wav",{type:r.type||"audio/wav"});if(i.append("file",n),i.append("qna_id",this.config.qnaId||""),!this.config.interviewId)throw new Y("Interview ID is missing from configuration","MISSING_INTERVIEW_ID",!1);const s=await Nt(`${this.config.baseUrl}${Ft.TRANSCRIBE_ANSWER(this.config.interviewId)}`,{method:"POST",headers:{accept:"application/json","X-STT-Provider":this.config.provider||"groq",...this.config.authToken&&{Authorization:`Bearer ${this.config.authToken}`}},body:i},{attempts:1,backoff:"exponential",baseDelay:1e3,maxDelay:3e3,jitter:!0});if(!s.ok){const c=await s.text();let l=`STT request failed: ${s.status} ${s.statusText}`;try{const h=JSON.parse(c);l=h.message||h.error||l}catch{l=c||l}throw new Y(l,`HTTP_${s.status}`,s.status>=500)}return{transcript:(await s.json()).data.transcribed_text??""}}catch(i){throw i instanceof Y?i:new Y(`Transcription failed: ${i instanceof Error?i.message:String(i)}`,"TRANSCRIPTION_FAILED",!0)}}cancelRecording(){this.autoStopTimeoutId&&(clearTimeout(this.autoStopTimeoutId),this.autoStopTimeoutId=null),this.mediaRecorder&&this.isRecording()&&this.mediaRecorder.stop(),this.cleanup()}isRecording(){return this.mediaRecorder!==null&&this.mediaRecorder.state==="recording"}dispose(){this.disposed||(this.cancelRecording(),this.disposed=!0)}isDisposed(){return this.disposed}getSupportedMimeType(){const t=["audio/webm;codecs=opus","audio/webm","audio/ogg;codecs=opus","audio/mp4","audio/wav"];for(const r of t)if(MediaRecorder.isTypeSupported(r))return r;return"audio/webm"}getRecordingStream(){return this.recordingStream}cleanup(){this.recordingStream&&(this.recordingStream.getTracks().forEach(t=>t.stop()),this.recordingStream=null,ai.activeStream=null),this.recordingStartTime=null,this.mediaRecorder=null,this.audioChunks=[],this.audioChunksTotalSize=0,this.autoStopTimeoutId&&(clearTimeout(this.autoStopTimeoutId),this.autoStopTimeoutId=null)}throwIfDisposed(){if(this.disposed)throw new Y("STTService has been disposed and cannot be reused","SERVICE_DISPOSED",!1)}};we(ai,"activeStream",null);let Nr=ai;const wl=new Nr,oh=(e,t,r,i)=>{const n=d.useRef(null);return d.useEffect(()=>{if(!t)return;const s=async()=>{try{const l=await navigator.mediaDevices.getUserMedia({video:{width:{ideal:640},height:{ideal:480},facingMode:"user"}});e.current&&(e.current.srcObject=l,e.current.onloadeddata=()=>{r()})}catch(l){console.error("Camera access error:",l),i("Camera access failed")}},a=n.current,c=e.current;return s(),()=>{a&&cancelAnimationFrame(a),c!=null&&c.srcObject&&c.srcObject.getTracks().forEach(h=>h.stop())}},[t,r]),d.useEffect(()=>{const s=wl.getRecordingStream();if(s&&e.current){e.current.srcObject=s;const a=s.getVideoTracks(),c=s.getAudioTracks(),l=()=>{console.log("Media track ended - permission may have been revoked")};[...a,...c].forEach(h=>{h.addEventListener("ended",l)})}},[]),{animationFrameRef:n}},ah=(e,t,r,i,n,s,a,c,l,h,u,f,w,g,p)=>{const y=d.useRef(null),b=d.useCallback(()=>{const m=e.current,v=t.current,k=r.current;if(!m||m.readyState<2||!k||!v){y.current=requestAnimationFrame(b);return}i();try{const _=performance.now(),S=k.detectForVideo(m,_),E=n(S,l,h.current,g);E?(s(v,m,E,u,f,w,l),l&&w&&c(E,h.current,w)):a(v,m)}catch(_){console.error("Face detection error:",_)}y.current=requestAnimationFrame(b)},[e,t,r,i,n,s,a,c,l,h,u,f,w,g,p]);return{renderLoop:b,animationFrameRef:y}},ch=(e,t,r,i)=>{const{referenceSet:n,referenceRef:s,setReferenceData:a}=eo(),c=d.useRef(s),l=d.useCallback(()=>{c.current=s},[s]),h=d.useCallback(()=>{var g;const f=e.current,w=t.current;if(!(!f||!w))try{const p=performance.now(),y=f.detectForVideo(w,p);if((g=y.faceLandmarks)!=null&&g[0]){const b=y.faceLandmarks[0],m=b[33],v=b[263],k=b[1];m&&v&&k&&(c.current={x:(m.x+v.x)*.5,y:(m.y+v.y)*.5,noseX:k.x,noseY:k.y},a(!0,c.current),r("Reference set. Gaze tracking active."),i&&i())}}catch(p){console.error("Set reference error:",p),r("Failed to set reference")}},[e,t,r,a,i]),u=d.useCallback(()=>{a(!1,{x:0,y:0,noseX:0,noseY:0}),r("Reference reset. Starting calibration...")},[a,r]);return{referenceSet:n,referenceRef:c,setReference:h,resetReference:u,syncReference:l}};function lh({onClose:e,warningType:t,isCheatingModalOpen:r=!1}){const i=ao[t],n=i.icon;return t==="face_detected"?null:o.jsx("div",{className:"iw-absolute iw-left-4 iw-right-4 md:iw-right-auto md:iw-w-[480px] iw-z-50 iw-animate-in iw-fade-in iw-slide-in-from-bottom-4 iw-duration-300 iw-transition-all",style:{bottom:r?"280px":"5rem"},children:o.jsxs("div",{className:"iw-relative iw-overflow-hidden iw-rounded-xl iw-border iw-border-dashed iw-border-[#5C6686] iw-bg-[#F1F5FE] iw-p-4 iw-shadow-2xl iw-backdrop-blur-sm",children:[o.jsx("button",{onClick:e,className:"iw-absolute iw-right-3 iw-top-3 iw-text-gray-400 iw-transition-colors iw-hover:iw-text-gray-600",children:o.jsx(Ei,{className:"iw-h-5 iw-w-5"})}),o.jsxs("div",{className:"iw-flex iw-items-start iw-gap-2",children:[o.jsx("div",{className:"iw-flex iw-size-8 iw-flex-shrink-0 iw-items-center iw-justify-center iw-rounded-full iw-border iw-border-[#5C6686]",children:o.jsx(n,{className:"iw-size-6 iw-text-[#5C6686]"})}),o.jsxs("div",{className:"iw-flex-1 iw-pt-0.5",children:[o.jsx("h2",{className:"iw-text-[20px] iw-font-semibold iw-leading-tight iw-text-[#062260] iw-pr-6",children:i.title}),o.jsx("p",{className:"iw-mt-1.5 iw-text-lg iw-text-[#5C6686]",children:i.subtitle}),i.description&&o.jsx("div",{className:"iw-mt-3 iw-border-t iw-border-dashed iw-border-[#5C6686] iw-pt-3",children:o.jsx("p",{className:"iw-text-[14px] iw-font-bold iw-text-[#062260]",children:i.description})})]})]})]})})}const dh=({status:e})=>{const t=ao[e];if(!t)return null;const r=e!=="face_detected";return o.jsxs("div",{className:"iw-flex iw-flex-col iw-items-center iw-gap-0.5",children:[o.jsxs("div",{className:"iw-flex iw-items-center iw-gap-2 iw-px-3 iw-py-1 iw-rounded-full iw-backdrop-blur-md iw-shadow-sm transition-colors duration-300 iw-text-white",children:[o.jsx("div",{className:`iw-flex iw-h-4 iw-w-4 iw-items-center iw-size-2.5 iw-justify-center iw-rounded-full iw-text-white ${e==="face_detected"?"iw-bg-[#22C55E]":e==="model_loading"?"iw-bg-[#062260]":"iw-bg-[#E94315]"}`,children:e==="face_detected"?o.jsx(xi,{}):e==="model_loading"?o.jsx("div",{className:"iw-animate-spin iw-border iw-border-white iw-border-t-transparent iw-rounded-full iw-w-2 iw-h-2"}):o.jsx(Ei,{})}),o.jsx("span",{className:"iw-text-sm iw-font-medium",children:e==="face_detected"?"Face detected clearly":e==="camera_error"?"Camera not found":t.title})]}),r&&o.jsx("span",{className:"iw-text-white iw-text-center iw-text-xs iw-drop-shadow-sm iw-max-w-[400px] iw-px-3",children:e==="model_loading"?"Initializing Face models. Please wait...":e==="no_face_detected"?"Face not detected. Please position yourself clearly in the frame.":e==="multiple_faces"?"Multiple faces detected. Please ensure only you are visible.":"Please position your face correctly."})]})};function uh(e,t={}){const[r,i]=d.useState({data:null,loading:!1,error:null}),n=d.useCallback(async(...s)=>{var a,c,l,h;i(u=>({...u,loading:!0,error:null}));try{const u=await e(...s);i(f=>({...f,data:u,loading:!1,error:null})),(a=t.onSuccess)==null||a.call(t,u),(c=t.onSettled)==null||c.call(t,u,null)}catch(u){const f=u.type?u:{type:"unknown",message:u.message||"Unknown error",retryable:!0,userMessage:"Something went wrong. Please try again.",originalError:u};i(w=>({...w,loading:!1,error:f})),(l=t.onError)==null||l.call(t,f),(h=t.onSettled)==null||h.call(t,null,f)}},[e,t]);return{...r,execute:n}}const hh=e=>{const[t,r]=d.useState(null),[i,n]=d.useState(!1),s=document,a=()=>!!(s.fullscreenEnabled||s.webkitFullscreenEnabled||s.mozFullScreenEnabled||s.msFullscreenEnabled),c=()=>s.fullscreenElement||s.webkitFullscreenElement||s.mozFullScreenElement||s.msFullscreenElement,l=async g=>{var p;try{if(!a())throw new Error("Fullscreen is not supported in this environment");g.requestFullscreen?await g.requestFullscreen():g.webkitRequestFullscreen?await g.webkitRequestFullscreen():g.mozRequestFullScreen?await g.mozRequestFullScreen():g.msRequestFullscreen&&await g.msRequestFullscreen()}catch(y){const b={name:"FullscreenError",message:y instanceof Error?y.message:"Failed to enter fullscreen"};r(b),(p=e==null?void 0:e.onError)==null||p.call(e,b)}},h=async()=>{var g;try{s.exitFullscreen?await s.exitFullscreen():s.webkitExitFullscreen?await s.webkitExitFullscreen():s.mozCancelFullScreen?await s.mozCancelFullScreen():s.msExitFullscreen&&await s.msExitFullscreen()}catch(p){const y={name:"FullscreenError",message:p instanceof Error?p.message:"Failed to exit fullscreen"};r(y),(g=e==null?void 0:e.onError)==null||g.call(e,y)}},u=d.useCallback(()=>{var p;const g=!!c();n(g),(p=e==null?void 0:e.onFullScreenChange)==null||p.call(e,g)},[e]);d.useEffect(()=>{const g=["fullscreenchange","webkitfullscreenchange","mozfullscreenchange","MSFullscreenChange"];return g.forEach(p=>{document.addEventListener(p,u)}),()=>{g.forEach(p=>{document.removeEventListener(p,u)})}},[u]);const f=async g=>{r(null);const p=g??document.documentElement;await l(p)};return{isFullScreen:i,toggleFullScreen:async g=>{i?await h():await f(g)},enterFullScreen:f,exitFullScreen:h,error:t}};class fh{constructor(t={}){we(this,"config");this.config=t}updateConfig(t){this.config={...this.config,...t}}getHeaders(){var r;const t={"Content-Type":"application/json"};return(r=this.config)!=null&&r.authToken&&(t.Authorization=`Bearer ${this.config.authToken}`),t}getBaseUrl(){var t;return((t=this.config)==null?void 0:t.baseUrl)||"/api"}async generateQuestion({interviewId:t,isInterviewDone:r=!1}){const i=await Nt(`${this.getBaseUrl()}${Ft.GENERATE_QUESTION(t)}`,{method:"POST",headers:this.getHeaders(),body:JSON.stringify({interview_id:t,is_interview_done:r})});if(!i.ok)throw new Error(`Failed to get questions: ${i.status}`);return await i.json()}async submitAnswer({interviewId:t,qnaId:r,answer:i}){const n=await Nt(`${this.getBaseUrl()}${Ft.SUBMIT_ANSWER(t)}`,{method:"POST",headers:this.getHeaders(),body:JSON.stringify({qna_id:r,answer_text:i})});if(!n.ok)throw new Error(`Failed to submit answer: ${n.status}`);return await n.json()}async exitInterview(t){const r=await Nt(`${this.getBaseUrl()}${Ft.EXIT(t)}`,{method:"POST",headers:this.getHeaders()});if(!r.ok)throw new Error(`Failed to exit interview: ${r.status}`)}async getInterviewConfig(t){const r=await Nt(`${this.getBaseUrl()}${Ft.CONFIG(t)}`,{method:"GET",headers:this.getHeaders()});if(!r.ok)throw new Error(`Failed to get interview config: ${r.status}`);return await r.json()}async requestScreenshotUploadUrl(t,r=`screenshot-${Date.now()}.jpeg`){const i=await Nt(`${this.getBaseUrl()}${Ft.SCREENSHOT_UPLOAD(t)}`,{method:"POST",headers:this.getHeaders(),body:JSON.stringify({filename:r,mime_type:"image/jpeg",asset_type:Il.SCREENSHOT})});if(!i.ok)throw new Error(`Failed to request screenshot upload URL: ${i.status}`);return await i.json()}async uploadScreenshot(t,r){const i=await fetch(t,{method:"PUT",body:r,headers:{"Content-Type":"image/jpeg"}});if(!i.ok)throw new Error(`Failed to upload screenshot: ${i.status}`)}async confirmScreenshotUpload(t){const r=await Nt(`${this.getBaseUrl()}${Ft.CONFIRM_UPLOAD(t)}`,{method:"POST",headers:this.getHeaders()});if(!r.ok)throw new Error(`Failed to confirm screenshot upload: ${r.status}`)}async getInterviewTranscription(t){const r=await Nt(`${this.getBaseUrl()}${Ft.TRANSCRIPTION(t)}`,{method:"GET",headers:{...this.getHeaders()}});if(!r.ok)throw new Error(`Failed to get interview transcription: ${r.status}`);return await r.json()}}function Hs(){const e=bi();return d.useMemo(()=>{const r=e.api||{};return new fh(r)},[e.api])}const wh=e=>{d.useEffect(()=>{const t=i=>{(i.ctrlKey||i.metaKey)&&["c","v","a","t","n","w","r","s","p"].includes(i.key.toLowerCase())&&(i.preventDefault(),e({type:"blocked_shortcut",severity:"low",details:{action:"shortcut_pressed",reason:`Attempted to use a blocked keyboard shortcut: Ctrl + ${i.key}`}})),i.key.startsWith("F")&&i.key.length<=3&&(i.preventDefault(),e({type:"blocked_function_key",severity:"low",details:{action:"function_key_pressed",reason:`Attempted to use a blocked function key: ${i.key}`}})),i.altKey&&i.key==="Tab"&&(i.preventDefault(),e({type:"alt_tab_attempt",severity:"medium",details:{action:"alt_tab",reason:"Attempted to use the Alt + Tab shortcut"}}))},r=i=>{i.preventDefault(),e({type:"right_click_attempt",severity:"low",details:{action:"right_click",reason:"Attempted to use the right click"}})};return document.addEventListener("keydown",t),document.addEventListener("contextmenu",r),()=>{document.removeEventListener("keydown",t),document.removeEventListener("contextmenu",r)}},[e])},gh=(e={})=>{const[t,r]=d.useState(!1),[i,n]=d.useState(!1),[s,a]=d.useState(null),[c,l]=d.useState(null),[h,u]=d.useState(null),f=d.useRef(e);f.current=e;const w=d.useRef(null);w.current||(w.current=new Nr(e.config)),d.useEffect(()=>{var m;e.config&&((m=w.current)==null||m.updateConfig(e.config))},[e.config]),d.useEffect(()=>{const m=w.current;return()=>{m==null||m.dispose(),w.current=null}},[]);const g=d.useCallback(async m=>{var k,_;const v=w.current;if(!v||v.isDisposed())throw new Y("STT service is not available","SERVICE_UNAVAILABLE",!1);try{l(null),a(null),u(null),await v.startRecording(m,{onStart:()=>{var S,E;r(!0),(E=(S=f.current).onStart)==null||E.call(S)},onStop:()=>{var S,E;r(!1),(E=(S=f.current).onStop)==null||E.call(S)},onError:S=>{var P,C;const E=S instanceof Y?S:new Y(S.message,"RECORDING_ERROR",!0);l(E),r(!1),(C=(P=f.current).onError)==null||C.call(P,E)}})}catch(S){const E=S instanceof Y?S:new Y(S instanceof Error?S.message:String(S),"START_FAILED",!1);throw l(E),r(!1),(_=(k=f.current).onError)==null||_.call(k,E),E}},[]),p=d.useCallback(async()=>{var v,k;const m=w.current;if(!m||m.isDisposed())throw new Y("STT service is not available","SERVICE_UNAVAILABLE",!1);try{const _=await m.stopRecording();return u(_),_}catch(_){const S=_ instanceof Y?_:new Y(_ instanceof Error?_.message:String(_),"STOP_FAILED",!1);throw l(S),r(!1),(k=(v=f.current).onError)==null||k.call(v,S),S}},[]),y=d.useCallback(async(m,v={})=>{var _,S,E,P,C,x;const k=w.current;if(!k||k.isDisposed())throw new Y("STT service is not available","SERVICE_UNAVAILABLE",!1);try{if(l(null),n(!0),!m||m.size===0){console.warn("Skipping transcription — blob is empty");const V={transcript:""};return a(V.transcript),n(!1),(S=(_=f.current).onTranscriptionComplete)==null||S.call(_,V),V}const M={audioBlob:m,...v},U=await k.transcribe(M);return a(U.transcript),n(!1),(P=(E=f.current).onTranscriptionComplete)==null||P.call(E,U),U}catch(M){const U=M instanceof Y?M:new Y(M instanceof Error?M.message:String(M),"TRANSCRIPTION_FAILED",!0);throw l(U),n(!1),(x=(C=f.current).onError)==null||x.call(C,U),U}},[]),b=d.useCallback(()=>{var m;(m=w.current)==null||m.cancelRecording(),r(!1),u(null)},[]);return{startRecording:g,stopRecording:p,transcribe:y,cancelRecording:b,isRecording:t,isTranscribing:i,transcript:s,error:c,audioBlob:h}},ph=e=>{const t=d.useRef(null),r=d.useRef(!1);d.useEffect(()=>{const i=()=>{document.hidden&&(r.current=!0,t.current&&(clearTimeout(t.current),t.current=null),e({type:"tab_switch",severity:"high",details:{action:"tab_hidden",reason:"Attempted to switch tabs or applications"}}),setTimeout(()=>{r.current=!1},100))},n=()=>{r.current||(t.current=setTimeout(()=>{r.current||e({type:"focus_loss",severity:"medium",details:{action:"window_blur",reason:"Focus lost from the interview window"}}),t.current=null},50))};return document.addEventListener("visibilitychange",i),window.addEventListener("blur",n),()=>{document.removeEventListener("visibilitychange",i),window.removeEventListener("blur",n),t.current&&clearTimeout(t.current)}},[e])},mh=()=>{d.useEffect(()=>{const e=document.createElement("style");return e.textContent=`
|
|
15
|
+
}`,e.VERTEX_SHADER),this.W=Gc(this,this.H(),e.FRAGMENT_SHADER),e.linkProgram(this.h),!e.getProgramParameter(this.h,e.LINK_STATUS))throw Error(`Error during program linking: ${e.getProgramInfoLog(this.h)}`);this.O=e.getAttribLocation(this.h,"aVertex"),this.L=e.getAttribLocation(this.h,"aTex")}D(){}l(){}close(){if(this.h){const e=this.g;e.deleteProgram(this.h),e.deleteShader(this.X),e.deleteShader(this.W)}this.B&&this.g.deleteFramebuffer(this.B),this.A&&this.A.close(),this.u&&this.u.close()}};function bt(e,t){switch(t){case 0:return e.g.find(r=>r instanceof Uint8Array);case 1:return e.g.find(r=>r instanceof Float32Array);case 2:return e.g.find(r=>typeof WebGLTexture<"u"&&r instanceof WebGLTexture);default:throw Error(`Type is not supported: ${t}`)}}function Ms(e){var t=bt(e,1);if(!t){if(t=bt(e,0))t=new Float32Array(t).map(i=>i/255);else{t=new Float32Array(e.width*e.height);const i=Cr(e);var r=Ds(e);if(zc(r,i,Hc(e)),"iPad Simulator;iPhone Simulator;iPod Simulator;iPad;iPhone;iPod".split(";").includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"document"in self&&"ontouchend"in self.document){r=new Float32Array(e.width*e.height*4),i.readPixels(0,0,e.width,e.height,i.RGBA,i.FLOAT,r);for(let n=0,s=0;n<t.length;++n,s+=4)t[n]=r[s]}else i.readPixels(0,0,e.width,e.height,i.RED,i.FLOAT,t)}e.g.push(t)}return t}function Hc(e){let t=bt(e,2);if(!t){const r=Cr(e);t=Kc(e);const i=Ms(e),n=qc(e);r.texImage2D(r.TEXTURE_2D,0,n,e.width,e.height,0,r.RED,r.FLOAT,i),Ps(e)}return t}function Cr(e){if(!e.canvas)throw Error("Conversion to different image formats require that a canvas is passed when initializing the image.");return e.h||(e.h=Tt(e.canvas.getContext("webgl2"),"You cannot use a canvas that is already bound to a different type of rendering context.")),e.h}function qc(e){if(e=Cr(e),!sn)if(e.getExtension("EXT_color_buffer_float")&&e.getExtension("OES_texture_float_linear")&&e.getExtension("EXT_float_blend"))sn=e.R32F;else{if(!e.getExtension("EXT_color_buffer_half_float"))throw Error("GPU does not fully support 4-channel float32 or float16 formats");sn=e.R16F}return sn}function Ds(e){return e.l||(e.l=new Wc),e.l}function Kc(e){const t=Cr(e);t.viewport(0,0,e.width,e.height),t.activeTexture(t.TEXTURE0);let r=bt(e,2);return r||(r=$c(Ds(e),t,e.m?t.LINEAR:t.NEAREST),e.g.push(r),e.j=!0),t.bindTexture(t.TEXTURE_2D,r),r}function Ps(e){e.h.bindTexture(e.h.TEXTURE_2D,null)}var sn,ye=class{constructor(e,t,r,i,n,s,a){this.g=e,this.m=t,this.j=r,this.canvas=i,this.l=n,this.width=s,this.height=a,this.j&&--Yc===0&&console.error("You seem to be creating MPMask instances without invoking .close(). This leaks resources.")}Fa(){return!!bt(this,0)}ka(){return!!bt(this,1)}R(){return!!bt(this,2)}ja(){return(t=bt(e=this,0))||(t=Ms(e),t=new Uint8Array(t.map(r=>Math.round(255*r))),e.g.push(t)),t;var e,t}ia(){return Ms(this)}N(){return Hc(this)}clone(){const e=[];for(const t of this.g){let r;if(t instanceof Uint8Array)r=new Uint8Array(t);else if(t instanceof Float32Array)r=new Float32Array(t);else{if(!(t instanceof WebGLTexture))throw Error(`Type is not supported: ${t}`);{const i=Cr(this),n=Ds(this);i.activeTexture(i.TEXTURE1),r=$c(n,i,this.m?i.LINEAR:i.NEAREST),i.bindTexture(i.TEXTURE_2D,r);const s=qc(this);i.texImage2D(i.TEXTURE_2D,0,s,this.width,this.height,0,i.RED,i.FLOAT,null),i.bindTexture(i.TEXTURE_2D,null),zc(n,i,r),Wu(n,i,!1,()=>{Kc(this),i.clearColor(0,0,0,0),i.clear(i.COLOR_BUFFER_BIT),i.drawArrays(i.TRIANGLE_FAN,0,4),Ps(this)}),Hu(n),Ps(this)}}e.push(r)}return new ye(e,this.m,this.R(),this.canvas,this.l,this.width,this.height)}close(){this.j&&Cr(this).deleteTexture(bt(this,2)),Yc=-1}};ye.prototype.close=ye.prototype.close,ye.prototype.clone=ye.prototype.clone,ye.prototype.getAsWebGLTexture=ye.prototype.N,ye.prototype.getAsFloat32Array=ye.prototype.ia,ye.prototype.getAsUint8Array=ye.prototype.ja,ye.prototype.hasWebGLTexture=ye.prototype.R,ye.prototype.hasFloat32Array=ye.prototype.ka,ye.prototype.hasUint8Array=ye.prototype.Fa;var Yc=250;function tt(...e){return e.map(([t,r])=>({start:t,end:r}))}const qu=function(e){return class extends e{Ja(){this.i._registerModelResourcesGraphService()}}}((Xc=class{constructor(e,t){this.l=!0,this.i=e,this.g=null,this.h=0,this.m=typeof this.i._addIntToInputStream=="function",t!==void 0?this.i.canvas=t:Dc()?this.i.canvas=new OffscreenCanvas(1,1):(console.warn("OffscreenCanvas not supported and GraphRunner constructor glCanvas parameter is undefined. Creating backup canvas."),this.i.canvas=document.createElement("canvas"))}async initializeGraph(e){const t=await(await fetch(e)).arrayBuffer();e=!(e.endsWith(".pbtxt")||e.endsWith(".textproto")),this.setGraph(new Uint8Array(t),e)}setGraphFromString(e){this.setGraph(new TextEncoder().encode(e),!1)}setGraph(e,t){const r=e.length,i=this.i._malloc(r);this.i.HEAPU8.set(e,i),t?this.i._changeBinaryGraph(r,i):this.i._changeTextGraph(r,i),this.i._free(i)}configureAudio(e,t,r,i,n){this.i._configureAudio||console.warn('Attempting to use configureAudio without support for input audio. Is build dep ":gl_graph_runner_audio" missing?'),I(this,i||"input_audio",s=>{I(this,n=n||"audio_header",a=>{this.i._configureAudio(s,a,e,t??0,r)})})}setAutoResizeCanvas(e){this.l=e}setAutoRenderToScreen(e){this.i._setAutoRenderToScreen(e)}setGpuBufferVerticalFlip(e){this.i.gpuOriginForWebTexturesIsBottomLeft=e}ca(e){dt(this,"__graph_config__",t=>{e(t)}),I(this,"__graph_config__",t=>{this.i._getGraphConfig(t,void 0)}),delete this.i.simpleListeners.__graph_config__}attachErrorListener(e){this.i.errorListener=e}attachEmptyPacketListener(e,t){this.i.emptyPacketListeners=this.i.emptyPacketListeners||{},this.i.emptyPacketListeners[e]=t}addAudioToStream(e,t,r){this.addAudioToStreamWithShape(e,0,0,t,r)}addAudioToStreamWithShape(e,t,r,i,n){const s=4*e.length;this.h!==s&&(this.g&&this.i._free(this.g),this.g=this.i._malloc(s),this.h=s),this.i.HEAPF32.set(e,this.g/4),I(this,i,a=>{this.i._addAudioToInputStream(this.g,t,r,a,n)})}addGpuBufferToStream(e,t,r){I(this,t,i=>{const[n,s]=Bc(this,e,i);this.i._addBoundTextureToStream(i,n,s,r)})}addBoolToStream(e,t,r){I(this,t,i=>{this.i._addBoolToInputStream(e,i,r)})}addDoubleToStream(e,t,r){I(this,t,i=>{this.i._addDoubleToInputStream(e,i,r)})}addFloatToStream(e,t,r){I(this,t,i=>{this.i._addFloatToInputStream(e,i,r)})}addIntToStream(e,t,r){I(this,t,i=>{this.i._addIntToInputStream(e,i,r)})}addUintToStream(e,t,r){I(this,t,i=>{this.i._addUintToInputStream(e,i,r)})}addStringToStream(e,t,r){I(this,t,i=>{I(this,e,n=>{this.i._addStringToInputStream(n,i,r)})})}addStringRecordToStream(e,t,r){I(this,t,i=>{Uc(this,Object.keys(e),n=>{Uc(this,Object.values(e),s=>{this.i._addFlatHashMapToInputStream(n,s,Object.keys(e).length,i,r)})})})}addProtoToStream(e,t,r,i){I(this,r,n=>{I(this,t,s=>{const a=this.i._malloc(e.length);this.i.HEAPU8.set(e,a),this.i._addProtoToInputStream(a,e.length,s,n,i),this.i._free(a)})})}addEmptyPacketToStream(e,t){I(this,e,r=>{this.i._addEmptyPacketToInputStream(r,t)})}addBoolVectorToStream(e,t,r){I(this,t,i=>{const n=this.i._allocateBoolVector(e.length);if(!n)throw Error("Unable to allocate new bool vector on heap.");for(const s of e)this.i._addBoolVectorEntry(n,s);this.i._addBoolVectorToInputStream(n,i,r)})}addDoubleVectorToStream(e,t,r){I(this,t,i=>{const n=this.i._allocateDoubleVector(e.length);if(!n)throw Error("Unable to allocate new double vector on heap.");for(const s of e)this.i._addDoubleVectorEntry(n,s);this.i._addDoubleVectorToInputStream(n,i,r)})}addFloatVectorToStream(e,t,r){I(this,t,i=>{const n=this.i._allocateFloatVector(e.length);if(!n)throw Error("Unable to allocate new float vector on heap.");for(const s of e)this.i._addFloatVectorEntry(n,s);this.i._addFloatVectorToInputStream(n,i,r)})}addIntVectorToStream(e,t,r){I(this,t,i=>{const n=this.i._allocateIntVector(e.length);if(!n)throw Error("Unable to allocate new int vector on heap.");for(const s of e)this.i._addIntVectorEntry(n,s);this.i._addIntVectorToInputStream(n,i,r)})}addUintVectorToStream(e,t,r){I(this,t,i=>{const n=this.i._allocateUintVector(e.length);if(!n)throw Error("Unable to allocate new unsigned int vector on heap.");for(const s of e)this.i._addUintVectorEntry(n,s);this.i._addUintVectorToInputStream(n,i,r)})}addStringVectorToStream(e,t,r){I(this,t,i=>{const n=this.i._allocateStringVector(e.length);if(!n)throw Error("Unable to allocate new string vector on heap.");for(const s of e)I(this,s,a=>{this.i._addStringVectorEntry(n,a)});this.i._addStringVectorToInputStream(n,i,r)})}addBoolToInputSidePacket(e,t){I(this,t,r=>{this.i._addBoolToInputSidePacket(e,r)})}addDoubleToInputSidePacket(e,t){I(this,t,r=>{this.i._addDoubleToInputSidePacket(e,r)})}addFloatToInputSidePacket(e,t){I(this,t,r=>{this.i._addFloatToInputSidePacket(e,r)})}addIntToInputSidePacket(e,t){I(this,t,r=>{this.i._addIntToInputSidePacket(e,r)})}addUintToInputSidePacket(e,t){I(this,t,r=>{this.i._addUintToInputSidePacket(e,r)})}addStringToInputSidePacket(e,t){I(this,t,r=>{I(this,e,i=>{this.i._addStringToInputSidePacket(i,r)})})}addProtoToInputSidePacket(e,t,r){I(this,r,i=>{I(this,t,n=>{const s=this.i._malloc(e.length);this.i.HEAPU8.set(e,s),this.i._addProtoToInputSidePacket(s,e.length,n,i),this.i._free(s)})})}addBoolVectorToInputSidePacket(e,t){I(this,t,r=>{const i=this.i._allocateBoolVector(e.length);if(!i)throw Error("Unable to allocate new bool vector on heap.");for(const n of e)this.i._addBoolVectorEntry(i,n);this.i._addBoolVectorToInputSidePacket(i,r)})}addDoubleVectorToInputSidePacket(e,t){I(this,t,r=>{const i=this.i._allocateDoubleVector(e.length);if(!i)throw Error("Unable to allocate new double vector on heap.");for(const n of e)this.i._addDoubleVectorEntry(i,n);this.i._addDoubleVectorToInputSidePacket(i,r)})}addFloatVectorToInputSidePacket(e,t){I(this,t,r=>{const i=this.i._allocateFloatVector(e.length);if(!i)throw Error("Unable to allocate new float vector on heap.");for(const n of e)this.i._addFloatVectorEntry(i,n);this.i._addFloatVectorToInputSidePacket(i,r)})}addIntVectorToInputSidePacket(e,t){I(this,t,r=>{const i=this.i._allocateIntVector(e.length);if(!i)throw Error("Unable to allocate new int vector on heap.");for(const n of e)this.i._addIntVectorEntry(i,n);this.i._addIntVectorToInputSidePacket(i,r)})}addUintVectorToInputSidePacket(e,t){I(this,t,r=>{const i=this.i._allocateUintVector(e.length);if(!i)throw Error("Unable to allocate new unsigned int vector on heap.");for(const n of e)this.i._addUintVectorEntry(i,n);this.i._addUintVectorToInputSidePacket(i,r)})}addStringVectorToInputSidePacket(e,t){I(this,t,r=>{const i=this.i._allocateStringVector(e.length);if(!i)throw Error("Unable to allocate new string vector on heap.");for(const n of e)I(this,n,s=>{this.i._addStringVectorEntry(i,s)});this.i._addStringVectorToInputSidePacket(i,r)})}attachBoolListener(e,t){dt(this,e,t),I(this,e,r=>{this.i._attachBoolListener(r)})}attachBoolVectorListener(e,t){Ct(this,e,t),I(this,e,r=>{this.i._attachBoolVectorListener(r)})}attachIntListener(e,t){dt(this,e,t),I(this,e,r=>{this.i._attachIntListener(r)})}attachIntVectorListener(e,t){Ct(this,e,t),I(this,e,r=>{this.i._attachIntVectorListener(r)})}attachUintListener(e,t){dt(this,e,t),I(this,e,r=>{this.i._attachUintListener(r)})}attachUintVectorListener(e,t){Ct(this,e,t),I(this,e,r=>{this.i._attachUintVectorListener(r)})}attachDoubleListener(e,t){dt(this,e,t),I(this,e,r=>{this.i._attachDoubleListener(r)})}attachDoubleVectorListener(e,t){Ct(this,e,t),I(this,e,r=>{this.i._attachDoubleVectorListener(r)})}attachFloatListener(e,t){dt(this,e,t),I(this,e,r=>{this.i._attachFloatListener(r)})}attachFloatVectorListener(e,t){Ct(this,e,t),I(this,e,r=>{this.i._attachFloatVectorListener(r)})}attachStringListener(e,t){dt(this,e,t),I(this,e,r=>{this.i._attachStringListener(r)})}attachStringVectorListener(e,t){Ct(this,e,t),I(this,e,r=>{this.i._attachStringVectorListener(r)})}attachProtoListener(e,t,r){dt(this,e,t),I(this,e,i=>{this.i._attachProtoListener(i,r||!1)})}attachProtoVectorListener(e,t,r){Ct(this,e,t),I(this,e,i=>{this.i._attachProtoVectorListener(i,r||!1)})}attachAudioListener(e,t,r){this.i._attachAudioListener||console.warn('Attempting to use attachAudioListener without support for output audio. Is build dep ":gl_graph_runner_audio_out" missing?'),dt(this,e,(i,n)=>{i=new Float32Array(i.buffer,i.byteOffset,i.length/4),t(i,n)}),I(this,e,i=>{this.i._attachAudioListener(i,r||!1)})}finishProcessing(){this.i._waitUntilIdle()}closeGraph(){this.i._closeGraph(),this.i.simpleListeners=void 0,this.i.emptyPacketListeners=void 0}},class extends Xc{get ga(){return this.i}pa(e,t,r){I(this,t,i=>{const[n,s]=Bc(this,e,i);this.ga._addBoundTextureAsImageToStream(i,n,s,r)})}Z(e,t){dt(this,e,t),I(this,e,r=>{this.ga._attachImageListener(r)})}aa(e,t){Ct(this,e,t),I(this,e,r=>{this.ga._attachImageVectorListener(r)})}}));var Xc,rt=class extends qu{};async function z(e,t,r){return async function(i,n,s,a){return $u(i,n,s,a)}(e,r.canvas??(Dc()?void 0:document.createElement("canvas")),t,r)}function Qc(e,t,r,i){if(e.U){const s=new tc;if(r!=null&&r.regionOfInterest){if(!e.oa)throw Error("This task doesn't support region-of-interest.");var n=r.regionOfInterest;if(n.left>=n.right||n.top>=n.bottom)throw Error("Expected RectF with left < right and top < bottom.");if(n.left<0||n.top<0||n.right>1||n.bottom>1)throw Error("Expected RectF values to be in [0,1].");F(s,1,(n.left+n.right)/2),F(s,2,(n.top+n.bottom)/2),F(s,4,n.right-n.left),F(s,3,n.bottom-n.top)}else F(s,1,.5),F(s,2,.5),F(s,4,1),F(s,3,1);if(r!=null&&r.rotationDegrees){if((r==null?void 0:r.rotationDegrees)%90!=0)throw Error("Expected rotation to be a multiple of 90°.");if(F(s,5,-Math.PI*r.rotationDegrees/180),(r==null?void 0:r.rotationDegrees)%180!=0){const[a,c]=Oc(t);r=se(s,3)*c/a,n=se(s,4)*a/c,F(s,4,r),F(s,3,n)}}e.g.addProtoToStream(s.g(),"mediapipe.NormalizedRect",e.U,i)}e.g.pa(t,e.X,i??performance.now()),e.finishProcessing()}function it(e,t,r){var i;if((i=e.baseOptions)!=null&&i.g())throw Error("Task is not initialized with image mode. 'runningMode' must be set to 'IMAGE'.");Qc(e,t,r,e.C+1)}function ut(e,t,r,i){var n;if(!((n=e.baseOptions)!=null&&n.g()))throw Error("Task is not initialized with video mode. 'runningMode' must be set to 'VIDEO'.");Qc(e,t,r,i)}function Tr(e,t,r,i){var n=t.data;const s=t.width,a=s*(t=t.height);if((n instanceof Uint8Array||n instanceof Float32Array)&&n.length!==a)throw Error("Unsupported channel count: "+n.length/a);return e=new ye([n],r,!1,e.g.i.canvas,e.P,s,t),i?e.clone():e}var Ue=class extends Fs{constructor(e,t,r,i){super(e),this.g=e,this.X=t,this.U=r,this.oa=i,this.P=new Wc}l(e,t=!0){if("runningMode"in e&&K(this.baseOptions,2,Jr(!!e.runningMode&&e.runningMode!=="IMAGE")),e.canvas!==void 0&&this.g.i.canvas!==e.canvas)throw Error("You must create a new task to reset the canvas.");return super.l(e,t)}close(){this.P.close(),super.close()}};Ue.prototype.close=Ue.prototype.close;var Xe=class extends Ue{constructor(e,t){super(new rt(e,t),"image_in","norm_rect_in",!1),this.j={detections:[]},L(e=this.h=new Ri,0,1,t=new ie),F(this.h,2,.5),F(this.h,3,.3)}get baseOptions(){return W(this.h,ie,1)}set baseOptions(e){L(this.h,0,1,e)}o(e){return"minDetectionConfidence"in e&&F(this.h,2,e.minDetectionConfidence??.5),"minSuppressionThreshold"in e&&F(this.h,3,e.minSuppressionThreshold??.3),this.l(e)}F(e,t){return this.j={detections:[]},it(this,e,t),this.j}G(e,t,r){return this.j={detections:[]},ut(this,e,r,t),this.j}m(){var e=new Be;te(e,"image_in"),te(e,"norm_rect_in"),H(e,"detections");const t=new Oe;ct(t,Cu,this.h);const r=new Te;De(r,2,"mediapipe.tasks.vision.face_detector.FaceDetectorGraph"),J(r,"IMAGE:image_in"),J(r,"NORM_RECT:norm_rect_in"),G(r,"DETECTIONS:detections"),r.o(t),Ye(e,r),this.g.attachProtoVectorListener("detections",(i,n)=>{for(const s of i)i=Za(s),this.j.detections.push(Ic(i));C(this,n)}),this.g.attachEmptyPacketListener("detections",i=>{C(this,i)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Xe.prototype.detectForVideo=Xe.prototype.G,Xe.prototype.detect=Xe.prototype.F,Xe.prototype.setOptions=Xe.prototype.o,Xe.createFromModelPath=async function(e,t){return z(Xe,e,{baseOptions:{modelAssetPath:t}})},Xe.createFromModelBuffer=function(e,t){return z(Xe,e,{baseOptions:{modelAssetBuffer:t}})},Xe.createFromOptions=function(e,t){return z(Xe,e,t)};var Os=tt([61,146],[146,91],[91,181],[181,84],[84,17],[17,314],[314,405],[405,321],[321,375],[375,291],[61,185],[185,40],[40,39],[39,37],[37,0],[0,267],[267,269],[269,270],[270,409],[409,291],[78,95],[95,88],[88,178],[178,87],[87,14],[14,317],[317,402],[402,318],[318,324],[324,308],[78,191],[191,80],[80,81],[81,82],[82,13],[13,312],[312,311],[311,310],[310,415],[415,308]),Bs=tt([263,249],[249,390],[390,373],[373,374],[374,380],[380,381],[381,382],[382,362],[263,466],[466,388],[388,387],[387,386],[386,385],[385,384],[384,398],[398,362]),Us=tt([276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]),Jc=tt([474,475],[475,476],[476,477],[477,474]),Vs=tt([33,7],[7,163],[163,144],[144,145],[145,153],[153,154],[154,155],[155,133],[33,246],[246,161],[161,160],[160,159],[159,158],[158,157],[157,173],[173,133]),Gs=tt([46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]),Zc=tt([469,470],[470,471],[471,472],[472,469]),js=tt([10,338],[338,297],[297,332],[332,284],[284,251],[251,389],[389,356],[356,454],[454,323],[323,361],[361,288],[288,397],[397,365],[365,379],[379,378],[378,400],[400,377],[377,152],[152,148],[148,176],[176,149],[149,150],[150,136],[136,172],[172,58],[58,132],[132,93],[93,234],[234,127],[127,162],[162,21],[21,54],[54,103],[103,67],[67,109],[109,10]),Rc=[...Os,...Bs,...Us,...Vs,...Gs,...js],el=tt([127,34],[34,139],[139,127],[11,0],[0,37],[37,11],[232,231],[231,120],[120,232],[72,37],[37,39],[39,72],[128,121],[121,47],[47,128],[232,121],[121,128],[128,232],[104,69],[69,67],[67,104],[175,171],[171,148],[148,175],[118,50],[50,101],[101,118],[73,39],[39,40],[40,73],[9,151],[151,108],[108,9],[48,115],[115,131],[131,48],[194,204],[204,211],[211,194],[74,40],[40,185],[185,74],[80,42],[42,183],[183,80],[40,92],[92,186],[186,40],[230,229],[229,118],[118,230],[202,212],[212,214],[214,202],[83,18],[18,17],[17,83],[76,61],[61,146],[146,76],[160,29],[29,30],[30,160],[56,157],[157,173],[173,56],[106,204],[204,194],[194,106],[135,214],[214,192],[192,135],[203,165],[165,98],[98,203],[21,71],[71,68],[68,21],[51,45],[45,4],[4,51],[144,24],[24,23],[23,144],[77,146],[146,91],[91,77],[205,50],[50,187],[187,205],[201,200],[200,18],[18,201],[91,106],[106,182],[182,91],[90,91],[91,181],[181,90],[85,84],[84,17],[17,85],[206,203],[203,36],[36,206],[148,171],[171,140],[140,148],[92,40],[40,39],[39,92],[193,189],[189,244],[244,193],[159,158],[158,28],[28,159],[247,246],[246,161],[161,247],[236,3],[3,196],[196,236],[54,68],[68,104],[104,54],[193,168],[168,8],[8,193],[117,228],[228,31],[31,117],[189,193],[193,55],[55,189],[98,97],[97,99],[99,98],[126,47],[47,100],[100,126],[166,79],[79,218],[218,166],[155,154],[154,26],[26,155],[209,49],[49,131],[131,209],[135,136],[136,150],[150,135],[47,126],[126,217],[217,47],[223,52],[52,53],[53,223],[45,51],[51,134],[134,45],[211,170],[170,140],[140,211],[67,69],[69,108],[108,67],[43,106],[106,91],[91,43],[230,119],[119,120],[120,230],[226,130],[130,247],[247,226],[63,53],[53,52],[52,63],[238,20],[20,242],[242,238],[46,70],[70,156],[156,46],[78,62],[62,96],[96,78],[46,53],[53,63],[63,46],[143,34],[34,227],[227,143],[123,117],[117,111],[111,123],[44,125],[125,19],[19,44],[236,134],[134,51],[51,236],[216,206],[206,205],[205,216],[154,153],[153,22],[22,154],[39,37],[37,167],[167,39],[200,201],[201,208],[208,200],[36,142],[142,100],[100,36],[57,212],[212,202],[202,57],[20,60],[60,99],[99,20],[28,158],[158,157],[157,28],[35,226],[226,113],[113,35],[160,159],[159,27],[27,160],[204,202],[202,210],[210,204],[113,225],[225,46],[46,113],[43,202],[202,204],[204,43],[62,76],[76,77],[77,62],[137,123],[123,116],[116,137],[41,38],[38,72],[72,41],[203,129],[129,142],[142,203],[64,98],[98,240],[240,64],[49,102],[102,64],[64,49],[41,73],[73,74],[74,41],[212,216],[216,207],[207,212],[42,74],[74,184],[184,42],[169,170],[170,211],[211,169],[170,149],[149,176],[176,170],[105,66],[66,69],[69,105],[122,6],[6,168],[168,122],[123,147],[147,187],[187,123],[96,77],[77,90],[90,96],[65,55],[55,107],[107,65],[89,90],[90,180],[180,89],[101,100],[100,120],[120,101],[63,105],[105,104],[104,63],[93,137],[137,227],[227,93],[15,86],[86,85],[85,15],[129,102],[102,49],[49,129],[14,87],[87,86],[86,14],[55,8],[8,9],[9,55],[100,47],[47,121],[121,100],[145,23],[23,22],[22,145],[88,89],[89,179],[179,88],[6,122],[122,196],[196,6],[88,95],[95,96],[96,88],[138,172],[172,136],[136,138],[215,58],[58,172],[172,215],[115,48],[48,219],[219,115],[42,80],[80,81],[81,42],[195,3],[3,51],[51,195],[43,146],[146,61],[61,43],[171,175],[175,199],[199,171],[81,82],[82,38],[38,81],[53,46],[46,225],[225,53],[144,163],[163,110],[110,144],[52,65],[65,66],[66,52],[229,228],[228,117],[117,229],[34,127],[127,234],[234,34],[107,108],[108,69],[69,107],[109,108],[108,151],[151,109],[48,64],[64,235],[235,48],[62,78],[78,191],[191,62],[129,209],[209,126],[126,129],[111,35],[35,143],[143,111],[117,123],[123,50],[50,117],[222,65],[65,52],[52,222],[19,125],[125,141],[141,19],[221,55],[55,65],[65,221],[3,195],[195,197],[197,3],[25,7],[7,33],[33,25],[220,237],[237,44],[44,220],[70,71],[71,139],[139,70],[122,193],[193,245],[245,122],[247,130],[130,33],[33,247],[71,21],[21,162],[162,71],[170,169],[169,150],[150,170],[188,174],[174,196],[196,188],[216,186],[186,92],[92,216],[2,97],[97,167],[167,2],[141,125],[125,241],[241,141],[164,167],[167,37],[37,164],[72,38],[38,12],[12,72],[38,82],[82,13],[13,38],[63,68],[68,71],[71,63],[226,35],[35,111],[111,226],[101,50],[50,205],[205,101],[206,92],[92,165],[165,206],[209,198],[198,217],[217,209],[165,167],[167,97],[97,165],[220,115],[115,218],[218,220],[133,112],[112,243],[243,133],[239,238],[238,241],[241,239],[214,135],[135,169],[169,214],[190,173],[173,133],[133,190],[171,208],[208,32],[32,171],[125,44],[44,237],[237,125],[86,87],[87,178],[178,86],[85,86],[86,179],[179,85],[84,85],[85,180],[180,84],[83,84],[84,181],[181,83],[201,83],[83,182],[182,201],[137,93],[93,132],[132,137],[76,62],[62,183],[183,76],[61,76],[76,184],[184,61],[57,61],[61,185],[185,57],[212,57],[57,186],[186,212],[214,207],[207,187],[187,214],[34,143],[143,156],[156,34],[79,239],[239,237],[237,79],[123,137],[137,177],[177,123],[44,1],[1,4],[4,44],[201,194],[194,32],[32,201],[64,102],[102,129],[129,64],[213,215],[215,138],[138,213],[59,166],[166,219],[219,59],[242,99],[99,97],[97,242],[2,94],[94,141],[141,2],[75,59],[59,235],[235,75],[24,110],[110,228],[228,24],[25,130],[130,226],[226,25],[23,24],[24,229],[229,23],[22,23],[23,230],[230,22],[26,22],[22,231],[231,26],[112,26],[26,232],[232,112],[189,190],[190,243],[243,189],[221,56],[56,190],[190,221],[28,56],[56,221],[221,28],[27,28],[28,222],[222,27],[29,27],[27,223],[223,29],[30,29],[29,224],[224,30],[247,30],[30,225],[225,247],[238,79],[79,20],[20,238],[166,59],[59,75],[75,166],[60,75],[75,240],[240,60],[147,177],[177,215],[215,147],[20,79],[79,166],[166,20],[187,147],[147,213],[213,187],[112,233],[233,244],[244,112],[233,128],[128,245],[245,233],[128,114],[114,188],[188,128],[114,217],[217,174],[174,114],[131,115],[115,220],[220,131],[217,198],[198,236],[236,217],[198,131],[131,134],[134,198],[177,132],[132,58],[58,177],[143,35],[35,124],[124,143],[110,163],[163,7],[7,110],[228,110],[110,25],[25,228],[356,389],[389,368],[368,356],[11,302],[302,267],[267,11],[452,350],[350,349],[349,452],[302,303],[303,269],[269,302],[357,343],[343,277],[277,357],[452,453],[453,357],[357,452],[333,332],[332,297],[297,333],[175,152],[152,377],[377,175],[347,348],[348,330],[330,347],[303,304],[304,270],[270,303],[9,336],[336,337],[337,9],[278,279],[279,360],[360,278],[418,262],[262,431],[431,418],[304,408],[408,409],[409,304],[310,415],[415,407],[407,310],[270,409],[409,410],[410,270],[450,348],[348,347],[347,450],[422,430],[430,434],[434,422],[313,314],[314,17],[17,313],[306,307],[307,375],[375,306],[387,388],[388,260],[260,387],[286,414],[414,398],[398,286],[335,406],[406,418],[418,335],[364,367],[367,416],[416,364],[423,358],[358,327],[327,423],[251,284],[284,298],[298,251],[281,5],[5,4],[4,281],[373,374],[374,253],[253,373],[307,320],[320,321],[321,307],[425,427],[427,411],[411,425],[421,313],[313,18],[18,421],[321,405],[405,406],[406,321],[320,404],[404,405],[405,320],[315,16],[16,17],[17,315],[426,425],[425,266],[266,426],[377,400],[400,369],[369,377],[322,391],[391,269],[269,322],[417,465],[465,464],[464,417],[386,257],[257,258],[258,386],[466,260],[260,388],[388,466],[456,399],[399,419],[419,456],[284,332],[332,333],[333,284],[417,285],[285,8],[8,417],[346,340],[340,261],[261,346],[413,441],[441,285],[285,413],[327,460],[460,328],[328,327],[355,371],[371,329],[329,355],[392,439],[439,438],[438,392],[382,341],[341,256],[256,382],[429,420],[420,360],[360,429],[364,394],[394,379],[379,364],[277,343],[343,437],[437,277],[443,444],[444,283],[283,443],[275,440],[440,363],[363,275],[431,262],[262,369],[369,431],[297,338],[338,337],[337,297],[273,375],[375,321],[321,273],[450,451],[451,349],[349,450],[446,342],[342,467],[467,446],[293,334],[334,282],[282,293],[458,461],[461,462],[462,458],[276,353],[353,383],[383,276],[308,324],[324,325],[325,308],[276,300],[300,293],[293,276],[372,345],[345,447],[447,372],[352,345],[345,340],[340,352],[274,1],[1,19],[19,274],[456,248],[248,281],[281,456],[436,427],[427,425],[425,436],[381,256],[256,252],[252,381],[269,391],[391,393],[393,269],[200,199],[199,428],[428,200],[266,330],[330,329],[329,266],[287,273],[273,422],[422,287],[250,462],[462,328],[328,250],[258,286],[286,384],[384,258],[265,353],[353,342],[342,265],[387,259],[259,257],[257,387],[424,431],[431,430],[430,424],[342,353],[353,276],[276,342],[273,335],[335,424],[424,273],[292,325],[325,307],[307,292],[366,447],[447,345],[345,366],[271,303],[303,302],[302,271],[423,266],[266,371],[371,423],[294,455],[455,460],[460,294],[279,278],[278,294],[294,279],[271,272],[272,304],[304,271],[432,434],[434,427],[427,432],[272,407],[407,408],[408,272],[394,430],[430,431],[431,394],[395,369],[369,400],[400,395],[334,333],[333,299],[299,334],[351,417],[417,168],[168,351],[352,280],[280,411],[411,352],[325,319],[319,320],[320,325],[295,296],[296,336],[336,295],[319,403],[403,404],[404,319],[330,348],[348,349],[349,330],[293,298],[298,333],[333,293],[323,454],[454,447],[447,323],[15,16],[16,315],[315,15],[358,429],[429,279],[279,358],[14,15],[15,316],[316,14],[285,336],[336,9],[9,285],[329,349],[349,350],[350,329],[374,380],[380,252],[252,374],[318,402],[402,403],[403,318],[6,197],[197,419],[419,6],[318,319],[319,325],[325,318],[367,364],[364,365],[365,367],[435,367],[367,397],[397,435],[344,438],[438,439],[439,344],[272,271],[271,311],[311,272],[195,5],[5,281],[281,195],[273,287],[287,291],[291,273],[396,428],[428,199],[199,396],[311,271],[271,268],[268,311],[283,444],[444,445],[445,283],[373,254],[254,339],[339,373],[282,334],[334,296],[296,282],[449,347],[347,346],[346,449],[264,447],[447,454],[454,264],[336,296],[296,299],[299,336],[338,10],[10,151],[151,338],[278,439],[439,455],[455,278],[292,407],[407,415],[415,292],[358,371],[371,355],[355,358],[340,345],[345,372],[372,340],[346,347],[347,280],[280,346],[442,443],[443,282],[282,442],[19,94],[94,370],[370,19],[441,442],[442,295],[295,441],[248,419],[419,197],[197,248],[263,255],[255,359],[359,263],[440,275],[275,274],[274,440],[300,383],[383,368],[368,300],[351,412],[412,465],[465,351],[263,467],[467,466],[466,263],[301,368],[368,389],[389,301],[395,378],[378,379],[379,395],[412,351],[351,419],[419,412],[436,426],[426,322],[322,436],[2,164],[164,393],[393,2],[370,462],[462,461],[461,370],[164,0],[0,267],[267,164],[302,11],[11,12],[12,302],[268,12],[12,13],[13,268],[293,300],[300,301],[301,293],[446,261],[261,340],[340,446],[330,266],[266,425],[425,330],[426,423],[423,391],[391,426],[429,355],[355,437],[437,429],[391,327],[327,326],[326,391],[440,457],[457,438],[438,440],[341,382],[382,362],[362,341],[459,457],[457,461],[461,459],[434,430],[430,394],[394,434],[414,463],[463,362],[362,414],[396,369],[369,262],[262,396],[354,461],[461,457],[457,354],[316,403],[403,402],[402,316],[315,404],[404,403],[403,315],[314,405],[405,404],[404,314],[313,406],[406,405],[405,313],[421,418],[418,406],[406,421],[366,401],[401,361],[361,366],[306,408],[408,407],[407,306],[291,409],[409,408],[408,291],[287,410],[410,409],[409,287],[432,436],[436,410],[410,432],[434,416],[416,411],[411,434],[264,368],[368,383],[383,264],[309,438],[438,457],[457,309],[352,376],[376,401],[401,352],[274,275],[275,4],[4,274],[421,428],[428,262],[262,421],[294,327],[327,358],[358,294],[433,416],[416,367],[367,433],[289,455],[455,439],[439,289],[462,370],[370,326],[326,462],[2,326],[326,370],[370,2],[305,460],[460,455],[455,305],[254,449],[449,448],[448,254],[255,261],[261,446],[446,255],[253,450],[450,449],[449,253],[252,451],[451,450],[450,252],[256,452],[452,451],[451,256],[341,453],[453,452],[452,341],[413,464],[464,463],[463,413],[441,413],[413,414],[414,441],[258,442],[442,441],[441,258],[257,443],[443,442],[442,257],[259,444],[444,443],[443,259],[260,445],[445,444],[444,260],[467,342],[342,445],[445,467],[459,458],[458,250],[250,459],[289,392],[392,290],[290,289],[290,328],[328,460],[460,290],[376,433],[433,435],[435,376],[250,290],[290,392],[392,250],[411,416],[416,433],[433,411],[341,463],[463,464],[464,341],[453,464],[464,465],[465,453],[357,465],[465,412],[412,357],[343,412],[412,399],[399,343],[360,363],[363,440],[440,360],[437,399],[399,456],[456,437],[420,456],[456,363],[363,420],[401,435],[435,288],[288,401],[372,383],[383,353],[353,372],[339,255],[255,249],[249,339],[448,261],[261,255],[255,448],[133,243],[243,190],[190,133],[133,155],[155,112],[112,133],[33,246],[246,247],[247,33],[33,130],[130,25],[25,33],[398,384],[384,286],[286,398],[362,398],[398,414],[414,362],[362,463],[463,341],[341,362],[263,359],[359,467],[467,263],[263,249],[249,255],[255,263],[466,467],[467,260],[260,466],[75,60],[60,166],[166,75],[238,239],[239,79],[79,238],[162,127],[127,139],[139,162],[72,11],[11,37],[37,72],[121,232],[232,120],[120,121],[73,72],[72,39],[39,73],[114,128],[128,47],[47,114],[233,232],[232,128],[128,233],[103,104],[104,67],[67,103],[152,175],[175,148],[148,152],[119,118],[118,101],[101,119],[74,73],[73,40],[40,74],[107,9],[9,108],[108,107],[49,48],[48,131],[131,49],[32,194],[194,211],[211,32],[184,74],[74,185],[185,184],[191,80],[80,183],[183,191],[185,40],[40,186],[186,185],[119,230],[230,118],[118,119],[210,202],[202,214],[214,210],[84,83],[83,17],[17,84],[77,76],[76,146],[146,77],[161,160],[160,30],[30,161],[190,56],[56,173],[173,190],[182,106],[106,194],[194,182],[138,135],[135,192],[192,138],[129,203],[203,98],[98,129],[54,21],[21,68],[68,54],[5,51],[51,4],[4,5],[145,144],[144,23],[23,145],[90,77],[77,91],[91,90],[207,205],[205,187],[187,207],[83,201],[201,18],[18,83],[181,91],[91,182],[182,181],[180,90],[90,181],[181,180],[16,85],[85,17],[17,16],[205,206],[206,36],[36,205],[176,148],[148,140],[140,176],[165,92],[92,39],[39,165],[245,193],[193,244],[244,245],[27,159],[159,28],[28,27],[30,247],[247,161],[161,30],[174,236],[236,196],[196,174],[103,54],[54,104],[104,103],[55,193],[193,8],[8,55],[111,117],[117,31],[31,111],[221,189],[189,55],[55,221],[240,98],[98,99],[99,240],[142,126],[126,100],[100,142],[219,166],[166,218],[218,219],[112,155],[155,26],[26,112],[198,209],[209,131],[131,198],[169,135],[135,150],[150,169],[114,47],[47,217],[217,114],[224,223],[223,53],[53,224],[220,45],[45,134],[134,220],[32,211],[211,140],[140,32],[109,67],[67,108],[108,109],[146,43],[43,91],[91,146],[231,230],[230,120],[120,231],[113,226],[226,247],[247,113],[105,63],[63,52],[52,105],[241,238],[238,242],[242,241],[124,46],[46,156],[156,124],[95,78],[78,96],[96,95],[70,46],[46,63],[63,70],[116,143],[143,227],[227,116],[116,123],[123,111],[111,116],[1,44],[44,19],[19,1],[3,236],[236,51],[51,3],[207,216],[216,205],[205,207],[26,154],[154,22],[22,26],[165,39],[39,167],[167,165],[199,200],[200,208],[208,199],[101,36],[36,100],[100,101],[43,57],[57,202],[202,43],[242,20],[20,99],[99,242],[56,28],[28,157],[157,56],[124,35],[35,113],[113,124],[29,160],[160,27],[27,29],[211,204],[204,210],[210,211],[124,113],[113,46],[46,124],[106,43],[43,204],[204,106],[96,62],[62,77],[77,96],[227,137],[137,116],[116,227],[73,41],[41,72],[72,73],[36,203],[203,142],[142,36],[235,64],[64,240],[240,235],[48,49],[49,64],[64,48],[42,41],[41,74],[74,42],[214,212],[212,207],[207,214],[183,42],[42,184],[184,183],[210,169],[169,211],[211,210],[140,170],[170,176],[176,140],[104,105],[105,69],[69,104],[193,122],[122,168],[168,193],[50,123],[123,187],[187,50],[89,96],[96,90],[90,89],[66,65],[65,107],[107,66],[179,89],[89,180],[180,179],[119,101],[101,120],[120,119],[68,63],[63,104],[104,68],[234,93],[93,227],[227,234],[16,15],[15,85],[85,16],[209,129],[129,49],[49,209],[15,14],[14,86],[86,15],[107,55],[55,9],[9,107],[120,100],[100,121],[121,120],[153,145],[145,22],[22,153],[178,88],[88,179],[179,178],[197,6],[6,196],[196,197],[89,88],[88,96],[96,89],[135,138],[138,136],[136,135],[138,215],[215,172],[172,138],[218,115],[115,219],[219,218],[41,42],[42,81],[81,41],[5,195],[195,51],[51,5],[57,43],[43,61],[61,57],[208,171],[171,199],[199,208],[41,81],[81,38],[38,41],[224,53],[53,225],[225,224],[24,144],[144,110],[110,24],[105,52],[52,66],[66,105],[118,229],[229,117],[117,118],[227,34],[34,234],[234,227],[66,107],[107,69],[69,66],[10,109],[109,151],[151,10],[219,48],[48,235],[235,219],[183,62],[62,191],[191,183],[142,129],[129,126],[126,142],[116,111],[111,143],[143,116],[118,117],[117,50],[50,118],[223,222],[222,52],[52,223],[94,19],[19,141],[141,94],[222,221],[221,65],[65,222],[196,3],[3,197],[197,196],[45,220],[220,44],[44,45],[156,70],[70,139],[139,156],[188,122],[122,245],[245,188],[139,71],[71,162],[162,139],[149,170],[170,150],[150,149],[122,188],[188,196],[196,122],[206,216],[216,92],[92,206],[164,2],[2,167],[167,164],[242,141],[141,241],[241,242],[0,164],[164,37],[37,0],[11,72],[72,12],[12,11],[12,38],[38,13],[13,12],[70,63],[63,71],[71,70],[31,226],[226,111],[111,31],[36,101],[101,205],[205,36],[203,206],[206,165],[165,203],[126,209],[209,217],[217,126],[98,165],[165,97],[97,98],[237,220],[220,218],[218,237],[237,239],[239,241],[241,237],[210,214],[214,169],[169,210],[140,171],[171,32],[32,140],[241,125],[125,237],[237,241],[179,86],[86,178],[178,179],[180,85],[85,179],[179,180],[181,84],[84,180],[180,181],[182,83],[83,181],[181,182],[194,201],[201,182],[182,194],[177,137],[137,132],[132,177],[184,76],[76,183],[183,184],[185,61],[61,184],[184,185],[186,57],[57,185],[185,186],[216,212],[212,186],[186,216],[192,214],[214,187],[187,192],[139,34],[34,156],[156,139],[218,79],[79,237],[237,218],[147,123],[123,177],[177,147],[45,44],[44,4],[4,45],[208,201],[201,32],[32,208],[98,64],[64,129],[129,98],[192,213],[213,138],[138,192],[235,59],[59,219],[219,235],[141,242],[242,97],[97,141],[97,2],[2,141],[141,97],[240,75],[75,235],[235,240],[229,24],[24,228],[228,229],[31,25],[25,226],[226,31],[230,23],[23,229],[229,230],[231,22],[22,230],[230,231],[232,26],[26,231],[231,232],[233,112],[112,232],[232,233],[244,189],[189,243],[243,244],[189,221],[221,190],[190,189],[222,28],[28,221],[221,222],[223,27],[27,222],[222,223],[224,29],[29,223],[223,224],[225,30],[30,224],[224,225],[113,247],[247,225],[225,113],[99,60],[60,240],[240,99],[213,147],[147,215],[215,213],[60,20],[20,166],[166,60],[192,187],[187,213],[213,192],[243,112],[112,244],[244,243],[244,233],[233,245],[245,244],[245,128],[128,188],[188,245],[188,114],[114,174],[174,188],[134,131],[131,220],[220,134],[174,217],[217,236],[236,174],[236,198],[198,134],[134,236],[215,177],[177,58],[58,215],[156,143],[143,124],[124,156],[25,110],[110,7],[7,25],[31,228],[228,25],[25,31],[264,356],[356,368],[368,264],[0,11],[11,267],[267,0],[451,452],[452,349],[349,451],[267,302],[302,269],[269,267],[350,357],[357,277],[277,350],[350,452],[452,357],[357,350],[299,333],[333,297],[297,299],[396,175],[175,377],[377,396],[280,347],[347,330],[330,280],[269,303],[303,270],[270,269],[151,9],[9,337],[337,151],[344,278],[278,360],[360,344],[424,418],[418,431],[431,424],[270,304],[304,409],[409,270],[272,310],[310,407],[407,272],[322,270],[270,410],[410,322],[449,450],[450,347],[347,449],[432,422],[422,434],[434,432],[18,313],[313,17],[17,18],[291,306],[306,375],[375,291],[259,387],[387,260],[260,259],[424,335],[335,418],[418,424],[434,364],[364,416],[416,434],[391,423],[423,327],[327,391],[301,251],[251,298],[298,301],[275,281],[281,4],[4,275],[254,373],[373,253],[253,254],[375,307],[307,321],[321,375],[280,425],[425,411],[411,280],[200,421],[421,18],[18,200],[335,321],[321,406],[406,335],[321,320],[320,405],[405,321],[314,315],[315,17],[17,314],[423,426],[426,266],[266,423],[396,377],[377,369],[369,396],[270,322],[322,269],[269,270],[413,417],[417,464],[464,413],[385,386],[386,258],[258,385],[248,456],[456,419],[419,248],[298,284],[284,333],[333,298],[168,417],[417,8],[8,168],[448,346],[346,261],[261,448],[417,413],[413,285],[285,417],[326,327],[327,328],[328,326],[277,355],[355,329],[329,277],[309,392],[392,438],[438,309],[381,382],[382,256],[256,381],[279,429],[429,360],[360,279],[365,364],[364,379],[379,365],[355,277],[277,437],[437,355],[282,443],[443,283],[283,282],[281,275],[275,363],[363,281],[395,431],[431,369],[369,395],[299,297],[297,337],[337,299],[335,273],[273,321],[321,335],[348,450],[450,349],[349,348],[359,446],[446,467],[467,359],[283,293],[293,282],[282,283],[250,458],[458,462],[462,250],[300,276],[276,383],[383,300],[292,308],[308,325],[325,292],[283,276],[276,293],[293,283],[264,372],[372,447],[447,264],[346,352],[352,340],[340,346],[354,274],[274,19],[19,354],[363,456],[456,281],[281,363],[426,436],[436,425],[425,426],[380,381],[381,252],[252,380],[267,269],[269,393],[393,267],[421,200],[200,428],[428,421],[371,266],[266,329],[329,371],[432,287],[287,422],[422,432],[290,250],[250,328],[328,290],[385,258],[258,384],[384,385],[446,265],[265,342],[342,446],[386,387],[387,257],[257,386],[422,424],[424,430],[430,422],[445,342],[342,276],[276,445],[422,273],[273,424],[424,422],[306,292],[292,307],[307,306],[352,366],[366,345],[345,352],[268,271],[271,302],[302,268],[358,423],[423,371],[371,358],[327,294],[294,460],[460,327],[331,279],[279,294],[294,331],[303,271],[271,304],[304,303],[436,432],[432,427],[427,436],[304,272],[272,408],[408,304],[395,394],[394,431],[431,395],[378,395],[395,400],[400,378],[296,334],[334,299],[299,296],[6,351],[351,168],[168,6],[376,352],[352,411],[411,376],[307,325],[325,320],[320,307],[285,295],[295,336],[336,285],[320,319],[319,404],[404,320],[329,330],[330,349],[349,329],[334,293],[293,333],[333,334],[366,323],[323,447],[447,366],[316,15],[15,315],[315,316],[331,358],[358,279],[279,331],[317,14],[14,316],[316,317],[8,285],[285,9],[9,8],[277,329],[329,350],[350,277],[253,374],[374,252],[252,253],[319,318],[318,403],[403,319],[351,6],[6,419],[419,351],[324,318],[318,325],[325,324],[397,367],[367,365],[365,397],[288,435],[435,397],[397,288],[278,344],[344,439],[439,278],[310,272],[272,311],[311,310],[248,195],[195,281],[281,248],[375,273],[273,291],[291,375],[175,396],[396,199],[199,175],[312,311],[311,268],[268,312],[276,283],[283,445],[445,276],[390,373],[373,339],[339,390],[295,282],[282,296],[296,295],[448,449],[449,346],[346,448],[356,264],[264,454],[454,356],[337,336],[336,299],[299,337],[337,338],[338,151],[151,337],[294,278],[278,455],[455,294],[308,292],[292,415],[415,308],[429,358],[358,355],[355,429],[265,340],[340,372],[372,265],[352,346],[346,280],[280,352],[295,442],[442,282],[282,295],[354,19],[19,370],[370,354],[285,441],[441,295],[295,285],[195,248],[248,197],[197,195],[457,440],[440,274],[274,457],[301,300],[300,368],[368,301],[417,351],[351,465],[465,417],[251,301],[301,389],[389,251],[394,395],[395,379],[379,394],[399,412],[412,419],[419,399],[410,436],[436,322],[322,410],[326,2],[2,393],[393,326],[354,370],[370,461],[461,354],[393,164],[164,267],[267,393],[268,302],[302,12],[12,268],[312,268],[268,13],[13,312],[298,293],[293,301],[301,298],[265,446],[446,340],[340,265],[280,330],[330,425],[425,280],[322,426],[426,391],[391,322],[420,429],[429,437],[437,420],[393,391],[391,326],[326,393],[344,440],[440,438],[438,344],[458,459],[459,461],[461,458],[364,434],[434,394],[394,364],[428,396],[396,262],[262,428],[274,354],[354,457],[457,274],[317,316],[316,402],[402,317],[316,315],[315,403],[403,316],[315,314],[314,404],[404,315],[314,313],[313,405],[405,314],[313,421],[421,406],[406,313],[323,366],[366,361],[361,323],[292,306],[306,407],[407,292],[306,291],[291,408],[408,306],[291,287],[287,409],[409,291],[287,432],[432,410],[410,287],[427,434],[434,411],[411,427],[372,264],[264,383],[383,372],[459,309],[309,457],[457,459],[366,352],[352,401],[401,366],[1,274],[274,4],[4,1],[418,421],[421,262],[262,418],[331,294],[294,358],[358,331],[435,433],[433,367],[367,435],[392,289],[289,439],[439,392],[328,462],[462,326],[326,328],[94,2],[2,370],[370,94],[289,305],[305,455],[455,289],[339,254],[254,448],[448,339],[359,255],[255,446],[446,359],[254,253],[253,449],[449,254],[253,252],[252,450],[450,253],[252,256],[256,451],[451,252],[256,341],[341,452],[452,256],[414,413],[413,463],[463,414],[286,441],[441,414],[414,286],[286,258],[258,441],[441,286],[258,257],[257,442],[442,258],[257,259],[259,443],[443,257],[259,260],[260,444],[444,259],[260,467],[467,445],[445,260],[309,459],[459,250],[250,309],[305,289],[289,290],[290,305],[305,290],[290,460],[460,305],[401,376],[376,435],[435,401],[309,250],[250,392],[392,309],[376,411],[411,433],[433,376],[453,341],[341,464],[464,453],[357,453],[453,465],[465,357],[343,357],[357,412],[412,343],[437,343],[343,399],[399,437],[344,360],[360,440],[440,344],[420,437],[437,456],[456,420],[360,420],[420,363],[363,360],[361,401],[401,288],[288,361],[265,372],[372,353],[353,265],[390,339],[339,249],[249,390],[339,448],[448,255],[255,339]);function tl(e){e.j={faceLandmarks:[],faceBlendshapes:[],facialTransformationMatrixes:[]}}var re=class extends Ue{constructor(e,t){super(new rt(e,t),"image_in","norm_rect",!1),this.j={faceLandmarks:[],faceBlendshapes:[],facialTransformationMatrixes:[]},this.outputFacialTransformationMatrixes=this.outputFaceBlendshapes=!1,L(e=this.h=new lc,0,1,t=new ie),this.A=new cc,L(this.h,0,3,this.A),this.u=new Ri,L(this.h,0,2,this.u),mt(this.u,4,1),F(this.u,2,.5),F(this.A,2,.5),F(this.h,4,.5)}get baseOptions(){return W(this.h,ie,1)}set baseOptions(e){L(this.h,0,1,e)}o(e){return"numFaces"in e&&mt(this.u,4,e.numFaces??1),"minFaceDetectionConfidence"in e&&F(this.u,2,e.minFaceDetectionConfidence??.5),"minTrackingConfidence"in e&&F(this.h,4,e.minTrackingConfidence??.5),"minFacePresenceConfidence"in e&&F(this.A,2,e.minFacePresenceConfidence??.5),"outputFaceBlendshapes"in e&&(this.outputFaceBlendshapes=!!e.outputFaceBlendshapes),"outputFacialTransformationMatrixes"in e&&(this.outputFacialTransformationMatrixes=!!e.outputFacialTransformationMatrixes),this.l(e)}F(e,t){return tl(this),it(this,e,t),this.j}G(e,t,r){return tl(this),ut(this,e,r,t),this.j}m(){var e=new Be;te(e,"image_in"),te(e,"norm_rect"),H(e,"face_landmarks");const t=new Oe;ct(t,Nu,this.h);const r=new Te;De(r,2,"mediapipe.tasks.vision.face_landmarker.FaceLandmarkerGraph"),J(r,"IMAGE:image_in"),J(r,"NORM_RECT:norm_rect"),G(r,"NORM_LANDMARKS:face_landmarks"),r.o(t),Ye(e,r),this.g.attachProtoVectorListener("face_landmarks",(i,n)=>{for(const s of i)i=si(s),this.j.faceLandmarks.push(en(i));C(this,n)}),this.g.attachEmptyPacketListener("face_landmarks",i=>{C(this,i)}),this.outputFaceBlendshapes&&(H(e,"blendshapes"),G(r,"BLENDSHAPES:blendshapes"),this.g.attachProtoVectorListener("blendshapes",(i,n)=>{if(this.outputFaceBlendshapes)for(const s of i)i=Qi(s),this.j.faceBlendshapes.push(Ns(i.g()??[]));C(this,n)}),this.g.attachEmptyPacketListener("blendshapes",i=>{C(this,i)})),this.outputFacialTransformationMatrixes&&(H(e,"face_geometry"),G(r,"FACE_GEOMETRY:face_geometry"),this.g.attachProtoVectorListener("face_geometry",(i,n)=>{if(this.outputFacialTransformationMatrixes)for(const s of i)(i=W(i=Tu(s),bu,2))&&this.j.facialTransformationMatrixes.push({rows:qe(i,1)??0??0,columns:qe(i,2)??0??0,data:zt(i,3,ot,$t()).slice()??[]});C(this,n)}),this.g.attachEmptyPacketListener("face_geometry",i=>{C(this,i)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};re.prototype.detectForVideo=re.prototype.G,re.prototype.detect=re.prototype.F,re.prototype.setOptions=re.prototype.o,re.createFromModelPath=function(e,t){return z(re,e,{baseOptions:{modelAssetPath:t}})},re.createFromModelBuffer=function(e,t){return z(re,e,{baseOptions:{modelAssetBuffer:t}})},re.createFromOptions=function(e,t){return z(re,e,t)},re.FACE_LANDMARKS_LIPS=Os,re.FACE_LANDMARKS_LEFT_EYE=Bs,re.FACE_LANDMARKS_LEFT_EYEBROW=Us,re.FACE_LANDMARKS_LEFT_IRIS=Jc,re.FACE_LANDMARKS_RIGHT_EYE=Vs,re.FACE_LANDMARKS_RIGHT_EYEBROW=Gs,re.FACE_LANDMARKS_RIGHT_IRIS=Zc,re.FACE_LANDMARKS_FACE_OVAL=js,re.FACE_LANDMARKS_CONTOURS=Rc,re.FACE_LANDMARKS_TESSELATION=el;var $s=tt([0,1],[1,2],[2,3],[3,4],[0,5],[5,6],[6,7],[7,8],[5,9],[9,10],[10,11],[11,12],[9,13],[13,14],[14,15],[15,16],[13,17],[0,17],[17,18],[18,19],[19,20]);function rl(e){e.gestures=[],e.landmarks=[],e.worldLandmarks=[],e.handedness=[]}function il(e){return e.gestures.length===0?{gestures:[],landmarks:[],worldLandmarks:[],handedness:[],handednesses:[]}:{gestures:e.gestures,landmarks:e.landmarks,worldLandmarks:e.worldLandmarks,handedness:e.handedness,handednesses:e.handedness}}function nl(e,t=!0){const r=[];for(const n of e){var i=Qi(n);e=[];for(const s of i.g())i=t&&qe(s,1)!=null?qe(s,1)??0:-1,e.push({score:se(s,2)??0,index:i,categoryName:xe(Q(s,3))??""??"",displayName:xe(Q(s,4))??""??""});r.push(e)}return r}var Ve=class extends Ue{constructor(e,t){super(new rt(e,t),"image_in","norm_rect",!1),this.gestures=[],this.landmarks=[],this.worldLandmarks=[],this.handedness=[],L(e=this.j=new hc,0,1,t=new ie),this.u=new xs,L(this.j,0,2,this.u),this.D=new vs,L(this.u,0,3,this.D),this.A=new uc,L(this.u,0,2,this.A),this.h=new Iu,L(this.j,0,3,this.h),F(this.A,2,.5),F(this.u,4,.5),F(this.D,2,.5)}get baseOptions(){return W(this.j,ie,1)}set baseOptions(e){L(this.j,0,1,e)}o(e){var n,s,a,c;if(mt(this.A,3,e.numHands??1),"minHandDetectionConfidence"in e&&F(this.A,2,e.minHandDetectionConfidence??.5),"minTrackingConfidence"in e&&F(this.u,4,e.minTrackingConfidence??.5),"minHandPresenceConfidence"in e&&F(this.D,2,e.minHandPresenceConfidence??.5),e.cannedGesturesClassifierOptions){var t=new Sr,r=t,i=Ts(e.cannedGesturesClassifierOptions,(n=W(this.h,Sr,3))==null?void 0:n.l());L(r,0,2,i),L(this.h,0,3,t)}else e.cannedGesturesClassifierOptions===void 0&&((s=W(this.h,Sr,3))==null||s.g());return e.customGesturesClassifierOptions?(L(r=t=new Sr,0,2,i=Ts(e.customGesturesClassifierOptions,(a=W(this.h,Sr,4))==null?void 0:a.l())),L(this.h,0,4,t)):e.customGesturesClassifierOptions===void 0&&((c=W(this.h,Sr,4))==null||c.g()),this.l(e)}Ha(e,t){return rl(this),it(this,e,t),il(this)}Ia(e,t,r){return rl(this),ut(this,e,r,t),il(this)}m(){var e=new Be;te(e,"image_in"),te(e,"norm_rect"),H(e,"hand_gestures"),H(e,"hand_landmarks"),H(e,"world_hand_landmarks"),H(e,"handedness");const t=new Oe;ct(t,Fu,this.j);const r=new Te;De(r,2,"mediapipe.tasks.vision.gesture_recognizer.GestureRecognizerGraph"),J(r,"IMAGE:image_in"),J(r,"NORM_RECT:norm_rect"),G(r,"HAND_GESTURES:hand_gestures"),G(r,"LANDMARKS:hand_landmarks"),G(r,"WORLD_LANDMARKS:world_hand_landmarks"),G(r,"HANDEDNESS:handedness"),r.o(t),Ye(e,r),this.g.attachProtoVectorListener("hand_landmarks",(i,n)=>{for(const s of i){i=si(s);const a=[];for(const c of pt(i,ec,1))a.push({x:se(c,1)??0,y:se(c,2)??0,z:se(c,3)??0,visibility:se(c,4)??0});this.landmarks.push(a)}C(this,n)}),this.g.attachEmptyPacketListener("hand_landmarks",i=>{C(this,i)}),this.g.attachProtoVectorListener("world_hand_landmarks",(i,n)=>{for(const s of i){i=kr(s);const a=[];for(const c of pt(i,Ra,1))a.push({x:se(c,1)??0,y:se(c,2)??0,z:se(c,3)??0,visibility:se(c,4)??0});this.worldLandmarks.push(a)}C(this,n)}),this.g.attachEmptyPacketListener("world_hand_landmarks",i=>{C(this,i)}),this.g.attachProtoVectorListener("hand_gestures",(i,n)=>{this.gestures.push(...nl(i,!1)),C(this,n)}),this.g.attachEmptyPacketListener("hand_gestures",i=>{C(this,i)}),this.g.attachProtoVectorListener("handedness",(i,n)=>{this.handedness.push(...nl(i)),C(this,n)}),this.g.attachEmptyPacketListener("handedness",i=>{C(this,i)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};function sl(e){return{landmarks:e.landmarks,worldLandmarks:e.worldLandmarks,handednesses:e.handedness,handedness:e.handedness}}Ve.prototype.recognizeForVideo=Ve.prototype.Ia,Ve.prototype.recognize=Ve.prototype.Ha,Ve.prototype.setOptions=Ve.prototype.o,Ve.createFromModelPath=function(e,t){return z(Ve,e,{baseOptions:{modelAssetPath:t}})},Ve.createFromModelBuffer=function(e,t){return z(Ve,e,{baseOptions:{modelAssetBuffer:t}})},Ve.createFromOptions=function(e,t){return z(Ve,e,t)},Ve.HAND_CONNECTIONS=$s;var Ge=class extends Ue{constructor(e,t){super(new rt(e,t),"image_in","norm_rect",!1),this.landmarks=[],this.worldLandmarks=[],this.handedness=[],L(e=this.h=new xs,0,1,t=new ie),this.u=new vs,L(this.h,0,3,this.u),this.j=new uc,L(this.h,0,2,this.j),mt(this.j,3,1),F(this.j,2,.5),F(this.u,2,.5),F(this.h,4,.5)}get baseOptions(){return W(this.h,ie,1)}set baseOptions(e){L(this.h,0,1,e)}o(e){return"numHands"in e&&mt(this.j,3,e.numHands??1),"minHandDetectionConfidence"in e&&F(this.j,2,e.minHandDetectionConfidence??.5),"minTrackingConfidence"in e&&F(this.h,4,e.minTrackingConfidence??.5),"minHandPresenceConfidence"in e&&F(this.u,2,e.minHandPresenceConfidence??.5),this.l(e)}F(e,t){return this.landmarks=[],this.worldLandmarks=[],this.handedness=[],it(this,e,t),sl(this)}G(e,t,r){return this.landmarks=[],this.worldLandmarks=[],this.handedness=[],ut(this,e,r,t),sl(this)}m(){var e=new Be;te(e,"image_in"),te(e,"norm_rect"),H(e,"hand_landmarks"),H(e,"world_hand_landmarks"),H(e,"handedness");const t=new Oe;ct(t,Lu,this.h);const r=new Te;De(r,2,"mediapipe.tasks.vision.hand_landmarker.HandLandmarkerGraph"),J(r,"IMAGE:image_in"),J(r,"NORM_RECT:norm_rect"),G(r,"LANDMARKS:hand_landmarks"),G(r,"WORLD_LANDMARKS:world_hand_landmarks"),G(r,"HANDEDNESS:handedness"),r.o(t),Ye(e,r),this.g.attachProtoVectorListener("hand_landmarks",(i,n)=>{for(const s of i)i=si(s),this.landmarks.push(en(i));C(this,n)}),this.g.attachEmptyPacketListener("hand_landmarks",i=>{C(this,i)}),this.g.attachProtoVectorListener("world_hand_landmarks",(i,n)=>{for(const s of i)i=kr(s),this.worldLandmarks.push(oi(i));C(this,n)}),this.g.attachEmptyPacketListener("world_hand_landmarks",i=>{C(this,i)}),this.g.attachProtoVectorListener("handedness",(i,n)=>{var s=this.handedness,a=s.push;const c=[];for(const l of i){i=Qi(l);const h=[];for(const u of i.g())h.push({score:se(u,2)??0,index:qe(u,1)??0??-1,categoryName:xe(Q(u,3))??""??"",displayName:xe(Q(u,4))??""??""});c.push(h)}a.call(s,...c),C(this,n)}),this.g.attachEmptyPacketListener("handedness",i=>{C(this,i)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Ge.prototype.detectForVideo=Ge.prototype.G,Ge.prototype.detect=Ge.prototype.F,Ge.prototype.setOptions=Ge.prototype.o,Ge.createFromModelPath=function(e,t){return z(Ge,e,{baseOptions:{modelAssetPath:t}})},Ge.createFromModelBuffer=function(e,t){return z(Ge,e,{baseOptions:{modelAssetBuffer:t}})},Ge.createFromOptions=function(e,t){return z(Ge,e,t)},Ge.HAND_CONNECTIONS=$s;var ol=tt([0,1],[1,2],[2,3],[3,7],[0,4],[4,5],[5,6],[6,8],[9,10],[11,12],[11,13],[13,15],[15,17],[15,19],[15,21],[17,19],[12,14],[14,16],[16,18],[16,20],[16,22],[18,20],[11,23],[12,24],[23,24],[23,25],[24,26],[25,27],[26,28],[27,29],[28,30],[29,31],[30,32],[27,31],[28,32]);function al(e){e.h={faceLandmarks:[],faceBlendshapes:[],poseLandmarks:[],poseWorldLandmarks:[],poseSegmentationMasks:[],leftHandLandmarks:[],leftHandWorldLandmarks:[],rightHandLandmarks:[],rightHandWorldLandmarks:[]}}function cl(e){try{if(!e.D)return e.h;e.D(e.h)}finally{nn(e)}}function on(e,t){e=si(e),t.push(en(e))}var Z=class extends Ue{constructor(e,t){super(new rt(e,t),"input_frames_image",null,!1),this.h={faceLandmarks:[],faceBlendshapes:[],poseLandmarks:[],poseWorldLandmarks:[],poseSegmentationMasks:[],leftHandLandmarks:[],leftHandWorldLandmarks:[],rightHandLandmarks:[],rightHandWorldLandmarks:[]},this.outputPoseSegmentationMasks=this.outputFaceBlendshapes=!1,L(e=this.j=new yc,0,1,t=new ie),this.I=new vs,L(this.j,0,2,this.I),this.W=new Mu,L(this.j,0,3,this.W),this.u=new Ri,L(this.j,0,4,this.u),this.O=new cc,L(this.j,0,5,this.O),this.A=new pc,L(this.j,0,6,this.A),this.M=new mc,L(this.j,0,7,this.M),F(this.u,2,.5),F(this.u,3,.3),F(this.O,2,.5),F(this.A,2,.5),F(this.A,3,.3),F(this.M,2,.5),F(this.I,2,.5)}get baseOptions(){return W(this.j,ie,1)}set baseOptions(e){L(this.j,0,1,e)}o(e){return"minFaceDetectionConfidence"in e&&F(this.u,2,e.minFaceDetectionConfidence??.5),"minFaceSuppressionThreshold"in e&&F(this.u,3,e.minFaceSuppressionThreshold??.3),"minFacePresenceConfidence"in e&&F(this.O,2,e.minFacePresenceConfidence??.5),"outputFaceBlendshapes"in e&&(this.outputFaceBlendshapes=!!e.outputFaceBlendshapes),"minPoseDetectionConfidence"in e&&F(this.A,2,e.minPoseDetectionConfidence??.5),"minPoseSuppressionThreshold"in e&&F(this.A,3,e.minPoseSuppressionThreshold??.3),"minPosePresenceConfidence"in e&&F(this.M,2,e.minPosePresenceConfidence??.5),"outputPoseSegmentationMasks"in e&&(this.outputPoseSegmentationMasks=!!e.outputPoseSegmentationMasks),"minHandLandmarksConfidence"in e&&F(this.I,2,e.minHandLandmarksConfidence??.5),this.l(e)}F(e,t,r){const i=typeof t!="function"?t:{};return this.D=typeof t=="function"?t:r,al(this),it(this,e,i),cl(this)}G(e,t,r,i){const n=typeof r!="function"?r:{};return this.D=typeof r=="function"?r:i,al(this),ut(this,e,n,t),cl(this)}m(){var e=new Be;te(e,"input_frames_image"),H(e,"pose_landmarks"),H(e,"pose_world_landmarks"),H(e,"face_landmarks"),H(e,"left_hand_landmarks"),H(e,"left_hand_world_landmarks"),H(e,"right_hand_landmarks"),H(e,"right_hand_world_landmarks");const t=new Oe,r=new Pa;De(r,1,"type.googleapis.com/mediapipe.tasks.vision.holistic_landmarker.proto.HolisticLandmarkerGraphOptions"),function(n,s){if(s!=null)if(Array.isArray(s))K(n,2,Mi(s,0,ei));else{if(!(typeof s=="string"||s instanceof nt||An(s)))throw Error("invalid value in Any.value field: "+s+" expected a ByteString, a base64 encoded string, a Uint8Array or a jspb array");Et(n,2,In(s,!1),Ot())}}(r,this.j.g());const i=new Te;De(i,2,"mediapipe.tasks.vision.holistic_landmarker.HolisticLandmarkerGraph"),Jn(i,8,Pa,r),J(i,"IMAGE:input_frames_image"),G(i,"POSE_LANDMARKS:pose_landmarks"),G(i,"POSE_WORLD_LANDMARKS:pose_world_landmarks"),G(i,"FACE_LANDMARKS:face_landmarks"),G(i,"LEFT_HAND_LANDMARKS:left_hand_landmarks"),G(i,"LEFT_HAND_WORLD_LANDMARKS:left_hand_world_landmarks"),G(i,"RIGHT_HAND_LANDMARKS:right_hand_landmarks"),G(i,"RIGHT_HAND_WORLD_LANDMARKS:right_hand_world_landmarks"),i.o(t),Ye(e,i),rn(this,e),this.g.attachProtoListener("pose_landmarks",(n,s)=>{on(n,this.h.poseLandmarks),C(this,s)}),this.g.attachEmptyPacketListener("pose_landmarks",n=>{C(this,n)}),this.g.attachProtoListener("pose_world_landmarks",(n,s)=>{var a=this.h.poseWorldLandmarks;n=kr(n),a.push(oi(n)),C(this,s)}),this.g.attachEmptyPacketListener("pose_world_landmarks",n=>{C(this,n)}),this.outputPoseSegmentationMasks&&(G(i,"POSE_SEGMENTATION_MASK:pose_segmentation_mask"),Ar(this,"pose_segmentation_mask"),this.g.Z("pose_segmentation_mask",(n,s)=>{this.h.poseSegmentationMasks=[Tr(this,n,!0,!this.D)],C(this,s)}),this.g.attachEmptyPacketListener("pose_segmentation_mask",n=>{this.h.poseSegmentationMasks=[],C(this,n)})),this.g.attachProtoListener("face_landmarks",(n,s)=>{on(n,this.h.faceLandmarks),C(this,s)}),this.g.attachEmptyPacketListener("face_landmarks",n=>{C(this,n)}),this.outputFaceBlendshapes&&(H(e,"extra_blendshapes"),G(i,"FACE_BLENDSHAPES:extra_blendshapes"),this.g.attachProtoListener("extra_blendshapes",(n,s)=>{var a=this.h.faceBlendshapes;this.outputFaceBlendshapes&&(n=Qi(n),a.push(Ns(n.g()??[]))),C(this,s)}),this.g.attachEmptyPacketListener("extra_blendshapes",n=>{C(this,n)})),this.g.attachProtoListener("left_hand_landmarks",(n,s)=>{on(n,this.h.leftHandLandmarks),C(this,s)}),this.g.attachEmptyPacketListener("left_hand_landmarks",n=>{C(this,n)}),this.g.attachProtoListener("left_hand_world_landmarks",(n,s)=>{var a=this.h.leftHandWorldLandmarks;n=kr(n),a.push(oi(n)),C(this,s)}),this.g.attachEmptyPacketListener("left_hand_world_landmarks",n=>{C(this,n)}),this.g.attachProtoListener("right_hand_landmarks",(n,s)=>{on(n,this.h.rightHandLandmarks),C(this,s)}),this.g.attachEmptyPacketListener("right_hand_landmarks",n=>{C(this,n)}),this.g.attachProtoListener("right_hand_world_landmarks",(n,s)=>{var a=this.h.rightHandWorldLandmarks;n=kr(n),a.push(oi(n)),C(this,s)}),this.g.attachEmptyPacketListener("right_hand_world_landmarks",n=>{C(this,n)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Z.prototype.detectForVideo=Z.prototype.G,Z.prototype.detect=Z.prototype.F,Z.prototype.setOptions=Z.prototype.o,Z.createFromModelPath=function(e,t){return z(Z,e,{baseOptions:{modelAssetPath:t}})},Z.createFromModelBuffer=function(e,t){return z(Z,e,{baseOptions:{modelAssetBuffer:t}})},Z.createFromOptions=function(e,t){return z(Z,e,t)},Z.HAND_CONNECTIONS=$s,Z.POSE_CONNECTIONS=ol,Z.FACE_LANDMARKS_LIPS=Os,Z.FACE_LANDMARKS_LEFT_EYE=Bs,Z.FACE_LANDMARKS_LEFT_EYEBROW=Us,Z.FACE_LANDMARKS_LEFT_IRIS=Jc,Z.FACE_LANDMARKS_RIGHT_EYE=Vs,Z.FACE_LANDMARKS_RIGHT_EYEBROW=Gs,Z.FACE_LANDMARKS_RIGHT_IRIS=Zc,Z.FACE_LANDMARKS_FACE_OVAL=js,Z.FACE_LANDMARKS_CONTOURS=Rc,Z.FACE_LANDMARKS_TESSELATION=el;var Qe=class extends Ue{constructor(e,t){super(new rt(e,t),"input_image","norm_rect",!0),this.j={classifications:[]},L(e=this.h=new bc,0,1,t=new ie)}get baseOptions(){return W(this.h,ie,1)}set baseOptions(e){L(this.h,0,1,e)}o(e){return L(this.h,0,2,Ts(e,W(this.h,ms,2))),this.l(e)}sa(e,t){return this.j={classifications:[]},it(this,e,t),this.j}ta(e,t,r){return this.j={classifications:[]},ut(this,e,r,t),this.j}m(){var e=new Be;te(e,"input_image"),te(e,"norm_rect"),H(e,"classifications");const t=new Oe;ct(t,Du,this.h);const r=new Te;De(r,2,"mediapipe.tasks.vision.image_classifier.ImageClassifierGraph"),J(r,"IMAGE:input_image"),J(r,"NORM_RECT:norm_rect"),G(r,"CLASSIFICATIONS:classifications"),r.o(t),Ye(e,r),this.g.attachProtoListener("classifications",(i,n)=>{this.j=Gu(Eu(i)),C(this,n)}),this.g.attachEmptyPacketListener("classifications",i=>{C(this,i)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Qe.prototype.classifyForVideo=Qe.prototype.ta,Qe.prototype.classify=Qe.prototype.sa,Qe.prototype.setOptions=Qe.prototype.o,Qe.createFromModelPath=function(e,t){return z(Qe,e,{baseOptions:{modelAssetPath:t}})},Qe.createFromModelBuffer=function(e,t){return z(Qe,e,{baseOptions:{modelAssetBuffer:t}})},Qe.createFromOptions=function(e,t){return z(Qe,e,t)};var je=class extends Ue{constructor(e,t){super(new rt(e,t),"image_in","norm_rect",!0),this.h=new vc,this.embeddings={embeddings:[]},L(e=this.h,0,1,t=new ie)}get baseOptions(){return W(this.h,ie,1)}set baseOptions(e){L(this.h,0,1,e)}o(e){var t=this.h,r=W(this.h,sc,2);return r=r?r.clone():new sc,e.l2Normalize!==void 0?K(r,1,Jr(e.l2Normalize)):"l2Normalize"in e&&K(r,1),e.quantize!==void 0?K(r,2,Jr(e.quantize)):"quantize"in e&&K(r,2),L(t,0,2,r),this.l(e)}za(e,t){return it(this,e,t),this.embeddings}Aa(e,t,r){return ut(this,e,r,t),this.embeddings}m(){var e=new Be;te(e,"image_in"),te(e,"norm_rect"),H(e,"embeddings_out");const t=new Oe;ct(t,Pu,this.h);const r=new Te;De(r,2,"mediapipe.tasks.vision.image_embedder.ImageEmbedderGraph"),J(r,"IMAGE:image_in"),J(r,"NORM_RECT:norm_rect"),G(r,"EMBEDDINGS:embeddings_out"),r.o(t),Ye(e,r),this.g.attachProtoListener("embeddings_out",(i,n)=>{i=Su(i),this.embeddings=function(s){return{embeddings:pt(s,ku,1).map(a=>{var h,u;const c={headIndex:qe(a,3)??0??-1,headName:xe(Q(a,4))??""??""};var l=a.v;return Ro(l,0|l[T],rc,Kn(a,1))!==void 0?(a=zt(a=W(a,rc,Kn(a,1),void 0),1,ot,$t()),c.floatEmbedding=a.slice()):(l=new Uint8Array(0),c.quantizedEmbedding=((u=(h=W(a,_u,Kn(a,2),void 0))==null?void 0:h.na())==null?void 0:u.h())??l),c}),timestampMs:Nc(ra(s))}}(i),C(this,n)}),this.g.attachEmptyPacketListener("embeddings_out",i=>{C(this,i)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};je.cosineSimilarity=function(e,t){if(e.floatEmbedding&&t.floatEmbedding)e=Lc(e.floatEmbedding,t.floatEmbedding);else{if(!e.quantizedEmbedding||!t.quantizedEmbedding)throw Error("Cannot compute cosine similarity between quantized and float embeddings.");e=Lc(Fc(e.quantizedEmbedding),Fc(t.quantizedEmbedding))}return e},je.prototype.embedForVideo=je.prototype.Aa,je.prototype.embed=je.prototype.za,je.prototype.setOptions=je.prototype.o,je.createFromModelPath=function(e,t){return z(je,e,{baseOptions:{modelAssetPath:t}})},je.createFromModelBuffer=function(e,t){return z(je,e,{baseOptions:{modelAssetBuffer:t}})},je.createFromOptions=function(e,t){return z(je,e,t)};var zs=class{constructor(e,t,r){this.confidenceMasks=e,this.categoryMask=t,this.qualityScores=r}close(){var e,t;(e=this.confidenceMasks)==null||e.forEach(r=>{r.close()}),(t=this.categoryMask)==null||t.close()}};function Ku(e){var r,i;const t=function(n){return pt(n,Te,1)}(e.ca()).filter(n=>(xe(Q(n,1))??"").includes("mediapipe.tasks.TensorsToSegmentationCalculator"));if(e.u=[],t.length>1)throw Error("The graph has more than one mediapipe.tasks.TensorsToSegmentationCalculator.");t.length===1&&(((i=(r=W(t[0],Oe,7))==null?void 0:r.j())==null?void 0:i.g())??new Map).forEach((n,s)=>{e.u[Number(s)]=xe(Q(n,1))??""})}function ll(e){e.categoryMask=void 0,e.confidenceMasks=void 0,e.qualityScores=void 0}function dl(e){try{const t=new zs(e.confidenceMasks,e.categoryMask,e.qualityScores);if(!e.j)return t;e.j(t)}finally{nn(e)}}zs.prototype.close=zs.prototype.close;var Ne=class extends Ue{constructor(e,t){super(new rt(e,t),"image_in","norm_rect",!1),this.u=[],this.outputCategoryMask=!1,this.outputConfidenceMasks=!0,this.h=new Ss,this.A=new xc,L(this.h,0,3,this.A),L(e=this.h,0,1,t=new ie)}get baseOptions(){return W(this.h,ie,1)}set baseOptions(e){L(this.h,0,1,e)}o(e){return e.displayNamesLocale!==void 0?K(this.h,2,Rr(e.displayNamesLocale)):"displayNamesLocale"in e&&K(this.h,2),"outputCategoryMask"in e&&(this.outputCategoryMask=e.outputCategoryMask??!1),"outputConfidenceMasks"in e&&(this.outputConfidenceMasks=e.outputConfidenceMasks??!0),super.l(e)}L(){Ku(this)}segment(e,t,r){const i=typeof t!="function"?t:{};return this.j=typeof t=="function"?t:r,ll(this),it(this,e,i),dl(this)}La(e,t,r,i){const n=typeof r!="function"?r:{};return this.j=typeof r=="function"?r:i,ll(this),ut(this,e,n,t),dl(this)}Da(){return this.u}m(){var e=new Be;te(e,"image_in"),te(e,"norm_rect");const t=new Oe;ct(t,kc,this.h);const r=new Te;De(r,2,"mediapipe.tasks.vision.image_segmenter.ImageSegmenterGraph"),J(r,"IMAGE:image_in"),J(r,"NORM_RECT:norm_rect"),r.o(t),Ye(e,r),rn(this,e),this.outputConfidenceMasks&&(H(e,"confidence_masks"),G(r,"CONFIDENCE_MASKS:confidence_masks"),Ar(this,"confidence_masks"),this.g.aa("confidence_masks",(i,n)=>{this.confidenceMasks=i.map(s=>Tr(this,s,!0,!this.j)),C(this,n)}),this.g.attachEmptyPacketListener("confidence_masks",i=>{this.confidenceMasks=[],C(this,i)})),this.outputCategoryMask&&(H(e,"category_mask"),G(r,"CATEGORY_MASK:category_mask"),Ar(this,"category_mask"),this.g.Z("category_mask",(i,n)=>{this.categoryMask=Tr(this,i,!1,!this.j),C(this,n)}),this.g.attachEmptyPacketListener("category_mask",i=>{this.categoryMask=void 0,C(this,i)})),H(e,"quality_scores"),G(r,"QUALITY_SCORES:quality_scores"),this.g.attachFloatVectorListener("quality_scores",(i,n)=>{this.qualityScores=i,C(this,n)}),this.g.attachEmptyPacketListener("quality_scores",i=>{this.categoryMask=void 0,C(this,i)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Ne.prototype.getLabels=Ne.prototype.Da,Ne.prototype.segmentForVideo=Ne.prototype.La,Ne.prototype.segment=Ne.prototype.segment,Ne.prototype.setOptions=Ne.prototype.o,Ne.createFromModelPath=function(e,t){return z(Ne,e,{baseOptions:{modelAssetPath:t}})},Ne.createFromModelBuffer=function(e,t){return z(Ne,e,{baseOptions:{modelAssetBuffer:t}})},Ne.createFromOptions=function(e,t){return z(Ne,e,t)};var Ws=class{constructor(e,t,r){this.confidenceMasks=e,this.categoryMask=t,this.qualityScores=r}close(){var e,t;(e=this.confidenceMasks)==null||e.forEach(r=>{r.close()}),(t=this.categoryMask)==null||t.close()}};Ws.prototype.close=Ws.prototype.close;var ht=class extends Ue{constructor(e,t){super(new rt(e,t),"image_in","norm_rect_in",!1),this.outputCategoryMask=!1,this.outputConfidenceMasks=!0,this.h=new Ss,this.u=new xc,L(this.h,0,3,this.u),L(e=this.h,0,1,t=new ie)}get baseOptions(){return W(this.h,ie,1)}set baseOptions(e){L(this.h,0,1,e)}o(e){return"outputCategoryMask"in e&&(this.outputCategoryMask=e.outputCategoryMask??!1),"outputConfidenceMasks"in e&&(this.outputConfidenceMasks=e.outputConfidenceMasks??!0),super.l(e)}segment(e,t,r,i){const n=typeof r!="function"?r:{};if(this.j=typeof r=="function"?r:i,this.qualityScores=this.categoryMask=this.confidenceMasks=void 0,r=this.C+1,i=new Ac,t.keypoint&&t.scribble)throw Error("Cannot provide both keypoint and scribble.");if(t.keypoint){var s=new As;Et(s,3,Jr(!0),!1),Et(s,1,Qr(t.keypoint.x),0),Et(s,2,Qr(t.keypoint.y),0),ti(i,1,Cs,s)}else{if(!t.scribble)throw Error("Must provide either a keypoint or a scribble.");{const c=new Bu;for(s of t.scribble)Et(t=new As,3,Jr(!0),!1),Et(t,1,Qr(s.x),0),Et(t,2,Qr(s.y),0),Jn(c,1,As,t);ti(i,2,Cs,c)}}this.g.addProtoToStream(i.g(),"mediapipe.tasks.vision.interactive_segmenter.proto.RegionOfInterest","roi_in",r),it(this,e,n);e:{try{const c=new Ws(this.confidenceMasks,this.categoryMask,this.qualityScores);if(!this.j){var a=c;break e}this.j(c)}finally{nn(this)}a=void 0}return a}m(){var e=new Be;te(e,"image_in"),te(e,"roi_in"),te(e,"norm_rect_in");const t=new Oe;ct(t,kc,this.h);const r=new Te;De(r,2,"mediapipe.tasks.vision.interactive_segmenter.InteractiveSegmenterGraphV2"),J(r,"IMAGE:image_in"),J(r,"ROI:roi_in"),J(r,"NORM_RECT:norm_rect_in"),r.o(t),Ye(e,r),rn(this,e),this.outputConfidenceMasks&&(H(e,"confidence_masks"),G(r,"CONFIDENCE_MASKS:confidence_masks"),Ar(this,"confidence_masks"),this.g.aa("confidence_masks",(i,n)=>{this.confidenceMasks=i.map(s=>Tr(this,s,!0,!this.j)),C(this,n)}),this.g.attachEmptyPacketListener("confidence_masks",i=>{this.confidenceMasks=[],C(this,i)})),this.outputCategoryMask&&(H(e,"category_mask"),G(r,"CATEGORY_MASK:category_mask"),Ar(this,"category_mask"),this.g.Z("category_mask",(i,n)=>{this.categoryMask=Tr(this,i,!1,!this.j),C(this,n)}),this.g.attachEmptyPacketListener("category_mask",i=>{this.categoryMask=void 0,C(this,i)})),H(e,"quality_scores"),G(r,"QUALITY_SCORES:quality_scores"),this.g.attachFloatVectorListener("quality_scores",(i,n)=>{this.qualityScores=i,C(this,n)}),this.g.attachEmptyPacketListener("quality_scores",i=>{this.categoryMask=void 0,C(this,i)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};ht.prototype.segment=ht.prototype.segment,ht.prototype.setOptions=ht.prototype.o,ht.createFromModelPath=function(e,t){return z(ht,e,{baseOptions:{modelAssetPath:t}})},ht.createFromModelBuffer=function(e,t){return z(ht,e,{baseOptions:{modelAssetBuffer:t}})},ht.createFromOptions=function(e,t){return z(ht,e,t)};var Je=class extends Ue{constructor(e,t){super(new rt(e,t),"input_frame_gpu","norm_rect",!1),this.j={detections:[]},L(e=this.h=new Cc,0,1,t=new ie)}get baseOptions(){return W(this.h,ie,1)}set baseOptions(e){L(this.h,0,1,e)}o(e){return e.displayNamesLocale!==void 0?K(this.h,2,Rr(e.displayNamesLocale)):"displayNamesLocale"in e&&K(this.h,2),e.maxResults!==void 0?mt(this.h,3,e.maxResults):"maxResults"in e&&K(this.h,3),e.scoreThreshold!==void 0?F(this.h,4,e.scoreThreshold):"scoreThreshold"in e&&K(this.h,4),e.categoryAllowlist!==void 0?Di(this.h,5,e.categoryAllowlist):"categoryAllowlist"in e&&K(this.h,5),e.categoryDenylist!==void 0?Di(this.h,6,e.categoryDenylist):"categoryDenylist"in e&&K(this.h,6),this.l(e)}F(e,t){return this.j={detections:[]},it(this,e,t),this.j}G(e,t,r){return this.j={detections:[]},ut(this,e,r,t),this.j}m(){var e=new Be;te(e,"input_frame_gpu"),te(e,"norm_rect"),H(e,"detections");const t=new Oe;ct(t,Uu,this.h);const r=new Te;De(r,2,"mediapipe.tasks.vision.ObjectDetectorGraph"),J(r,"IMAGE:input_frame_gpu"),J(r,"NORM_RECT:norm_rect"),G(r,"DETECTIONS:detections"),r.o(t),Ye(e,r),this.g.attachProtoVectorListener("detections",(i,n)=>{for(const s of i)i=Za(s),this.j.detections.push(Ic(i));C(this,n)}),this.g.attachEmptyPacketListener("detections",i=>{C(this,i)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Je.prototype.detectForVideo=Je.prototype.G,Je.prototype.detect=Je.prototype.F,Je.prototype.setOptions=Je.prototype.o,Je.createFromModelPath=async function(e,t){return z(Je,e,{baseOptions:{modelAssetPath:t}})},Je.createFromModelBuffer=function(e,t){return z(Je,e,{baseOptions:{modelAssetBuffer:t}})},Je.createFromOptions=function(e,t){return z(Je,e,t)};var Hs=class{constructor(e,t,r){this.landmarks=e,this.worldLandmarks=t,this.segmentationMasks=r}close(){var e;(e=this.segmentationMasks)==null||e.forEach(t=>{t.close()})}};function ul(e){e.landmarks=[],e.worldLandmarks=[],e.segmentationMasks=void 0}function hl(e){try{const t=new Hs(e.landmarks,e.worldLandmarks,e.segmentationMasks);if(!e.u)return t;e.u(t)}finally{nn(e)}}Hs.prototype.close=Hs.prototype.close;var $e=class extends Ue{constructor(e,t){super(new rt(e,t),"image_in","norm_rect",!1),this.landmarks=[],this.worldLandmarks=[],this.outputSegmentationMasks=!1,L(e=this.h=new Tc,0,1,t=new ie),this.A=new mc,L(this.h,0,3,this.A),this.j=new pc,L(this.h,0,2,this.j),mt(this.j,4,1),F(this.j,2,.5),F(this.A,2,.5),F(this.h,4,.5)}get baseOptions(){return W(this.h,ie,1)}set baseOptions(e){L(this.h,0,1,e)}o(e){return"numPoses"in e&&mt(this.j,4,e.numPoses??1),"minPoseDetectionConfidence"in e&&F(this.j,2,e.minPoseDetectionConfidence??.5),"minTrackingConfidence"in e&&F(this.h,4,e.minTrackingConfidence??.5),"minPosePresenceConfidence"in e&&F(this.A,2,e.minPosePresenceConfidence??.5),"outputSegmentationMasks"in e&&(this.outputSegmentationMasks=e.outputSegmentationMasks??!1),this.l(e)}F(e,t,r){const i=typeof t!="function"?t:{};return this.u=typeof t=="function"?t:r,ul(this),it(this,e,i),hl(this)}G(e,t,r,i){const n=typeof r!="function"?r:{};return this.u=typeof r=="function"?r:i,ul(this),ut(this,e,n,t),hl(this)}m(){var e=new Be;te(e,"image_in"),te(e,"norm_rect"),H(e,"normalized_landmarks"),H(e,"world_landmarks"),H(e,"segmentation_masks");const t=new Oe;ct(t,Vu,this.h);const r=new Te;De(r,2,"mediapipe.tasks.vision.pose_landmarker.PoseLandmarkerGraph"),J(r,"IMAGE:image_in"),J(r,"NORM_RECT:norm_rect"),G(r,"NORM_LANDMARKS:normalized_landmarks"),G(r,"WORLD_LANDMARKS:world_landmarks"),r.o(t),Ye(e,r),rn(this,e),this.g.attachProtoVectorListener("normalized_landmarks",(i,n)=>{this.landmarks=[];for(const s of i)i=si(s),this.landmarks.push(en(i));C(this,n)}),this.g.attachEmptyPacketListener("normalized_landmarks",i=>{this.landmarks=[],C(this,i)}),this.g.attachProtoVectorListener("world_landmarks",(i,n)=>{this.worldLandmarks=[];for(const s of i)i=kr(s),this.worldLandmarks.push(oi(i));C(this,n)}),this.g.attachEmptyPacketListener("world_landmarks",i=>{this.worldLandmarks=[],C(this,i)}),this.outputSegmentationMasks&&(G(r,"SEGMENTATION_MASK:segmentation_masks"),Ar(this,"segmentation_masks"),this.g.aa("segmentation_masks",(i,n)=>{this.segmentationMasks=i.map(s=>Tr(this,s,!0,!this.u)),C(this,n)}),this.g.attachEmptyPacketListener("segmentation_masks",i=>{this.segmentationMasks=[],C(this,i)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};$e.prototype.detectForVideo=$e.prototype.G,$e.prototype.detect=$e.prototype.F,$e.prototype.setOptions=$e.prototype.o,$e.createFromModelPath=function(e,t){return z($e,e,{baseOptions:{modelAssetPath:t}})},$e.createFromModelBuffer=function(e,t){return z($e,e,{baseOptions:{modelAssetBuffer:t}})},$e.createFromOptions=function(e,t){return z($e,e,t)},$e.POSE_CONNECTIONS=ol;const an="https://storage.googleapis.com/mediapipe-models/face_landmarker/face_landmarker/float16/latest/face_landmarker.task",Yu="https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@0.10.32/wasm",Xu=()=>{const e=d.useRef(null),[t,r]=d.useState(!1),[i,n]=d.useState("Initializing..."),[s,a]=d.useState(0),[c,l]=d.useState(!1);d.useEffect(()=>{"serviceWorker"in navigator&&navigator.serviceWorker.register("/sw.js").then(w=>{console.log("ServiceWorker registered:",w)}).catch(w=>{console.log("ServiceWorker registration failed:",w)})},[]);const h=async()=>"caches"in window?await(await caches.open("mediapipe-models-v1")).match(an)!==void 0:!1,u=async()=>{try{const w=await fetch(an),g=w.headers.get("content-length"),p=g?parseInt(g,10):0;if(!w.body)throw new Error("No response body");const y=w.body.getReader();let b=0;const m=[];for(;;){const{done:v,value:_}=await y.read();if(v)break;if(m.push(_),b+=_.length,p){const E=Math.round(b/p*100);a(E),n(`Downloading model... ${E}%`)}}return"caches"in window&&await(await caches.open("mediapipe-models-v1")).put(an,new Response(new Blob(m),{headers:{"Content-Type":"application/octet-stream"}})),!0}catch(w){return console.error("Failed to preload model:",w),!1}};return d.useEffect(()=>{(async()=>{try{n("Checking cached models..."),await h()?n("Using cached model..."):(n("Model not cached. Downloading..."),await u()),n("Loading MediaPipe WASM...");const p=await Xt.forVisionTasks(Yu);n("Creating face landmarker...");const y=await re.createFromOptions(p,{baseOptions:{modelAssetPath:an,delegate:"GPU"},runningMode:"VIDEO",outputFaceBlendshapes:!0,numFaces:2});e.current=y,r(!0),n("Model loaded successfully ✅")}catch(g){console.error("Model init error:",g),n(`Error: ${g==null?void 0:g.message}`),(g==null?void 0:g.name)==="NotAllowedError"&&l(!0)}})()},[]),{faceLandmarkerRef:e,isModelLoaded:t,statusMessage:i,setStatusMessage:n,loadingProgress:s,permissionDenied:c,clearCache:async()=>{"caches"in window&&(await caches.delete("mediapipe-models-v1"),n("Cache cleared. Please refresh to re-download models."))}}},Qu=()=>{const[e,t]=d.useState(0),r=d.useRef({lastTime:0,frames:0,fps:0}),i=d.useCallback(()=>{const n=performance.now(),s=r.current;if(s.frames++,n-s.lastTime>=1e3){const a=Math.round(s.frames*1e3/(n-s.lastTime));t(a),s.frames=0,s.lastTime=n}},[]);return{fps:e,updateFPS:i}},Ju=()=>{const e=d.useRef({value:100,isLookingAway:!1}),t=d.useCallback((s,a,c,l)=>{if(!s||!c||!a)return;const h=s.getContext("2d");if(!h)return;const{width:u,height:f}=s;if(h.clearRect(0,0,u,f),h.drawImage(a,0,0,u,f),l){h.fillStyle="#00FF00";for(const w of c)h.fillRect(w.x*u-.5,w.y*f-.5,1,1)}},[]),r=d.useCallback(s=>{const a=e.current.value/100,c=100,l=20,h=20,u=40;s.fillStyle="rgba(0, 0, 0, 0.3)",s.fillRect(h,u,l,c),s.fillStyle=`rgba(${Math.floor(255*(1-a))}, ${Math.floor(255*a)}, 0, 0.8)`;const f=c*a;s.fillRect(h,u+c-f,l,f),s.fillStyle="#FFFFFF",s.fillRect(h,u+c*(1-a),l,2)},[]),i=d.useCallback((s,a,c,l,h,u,f)=>{if(t(s,a,c,l),h&&u&&f){const w=s.getContext("2d");w&&r(w)}},[t,r]),n=d.useCallback((s,a)=>{const c=s.getContext("2d");c&&(c.clearRect(0,0,s.width,s.height),c.drawImage(a,0,0,s.width,s.height))},[]);return{drawLandmarks:t,drawEngagementBar:r,drawWithEngagementBar:i,clearCanvas:n,engagementRef:e}},Zu=50,Ru=()=>{const[e,t]=d.useState(100),[r,i]=d.useState(!1),n=d.useRef(0),s=d.useCallback((a,c,l)=>{if(!l||a.length<468)return;const h=a[33],u=a[263],f=a[1];if(!h||!u||!f)return;const w=(h.x+u.x)*.5,g=(h.y+u.y)*.5,p=w-c.x,y=g-c.y,b=Math.sqrt(p*p+y*y),m=Math.abs(f.y-c.noseY)*100,v=Math.abs(f.x-c.noseX)*100,_=Math.max(0,100-(b*200+m+v)),E=_<Zu,k=performance.now();return k-n.current>100&&(t(_),i(E),n.current=k),{engagement:_,isLookingAway:E}},[]);return{engagement:e,isLookingAway:r,analyzeGaze:s,setEngagement:t,setIsLookingAway:i}},eh=.05,th=()=>{const[e,t]=d.useState(!1),[r,i]=d.useState(!1),n=d.useCallback((c,l)=>Math.sqrt(Math.pow(c.x-l.x,2)+Math.pow(c.y-l.y,2)),[]),s=d.useCallback((c,l)=>{if(!c||!l)return 0;const h=[1,33,263,61,291,10,152];let u=0,f=0;const w=l[33],g=l[263],p=c[33],y=c[263];if(!w||!g||!p||!y)return 0;const b=n(w,g),m=n(p,y);if(b===0||m===0)return 0;for(const _ of h){const E=l[_],k=c[_];if(E&&k){const S=w.x+(k.x-p.x)*b/m,P=w.y+(k.y-p.y)*b/m;u+=n(E,{x:S,y:P}),f++}}return f===0?0:u/f},[n]),a=d.useCallback((c,l,h,u)=>{if(!c.faceLandmarks||c.faceLandmarks.length===0)return u("Face not detected."),i(!0),t(!1),null;if(l&&h){let f=null,w=0;for(const g of c.faceLandmarks)s(g,h)<eh&&(f=g,w++);return w===1?(t(!1),i(!1),u("Reference face tracked."),f):w>1?(t(!0),i(!1),u("Multiple matching faces detected. Tracking suspended."),null):(t(!1),i(!0),u("Reference face not detected."),null)}else{const f=c.faceLandmarks[0];if(c.faceLandmarks.length>1)return t(!0),i(!1),u("Multiple faces detected. Please ensure only you are visible."),null;if(!f)return i(!0),t(!1),u("Face not detected."),null;const g=f[1],p=f[33],y=f[263];return g&&p&&y&&g.x>.35&&g.x<.65&&g.y>.3&&g.y<.7&&p.x>.2&&p.x<.8&&y.x>.2&&y.x<.8?(i(!1),t(!1),u("Face detected. Ready for calibration."),f):(i(!0),t(!1),u("Please position your face in the center."),null)}},[s]);return{multipleFacesDetected:e,referenceFaceNotDetected:r,analyzeFace:a,setMultipleFacesDetected:t,setReferenceFaceNotDetected:i}},rh=500,ih=(e,t,r)=>{const[i,n]=d.useState(!1),[s,a]=d.useState(ke.MODEL_LOADING),{incrementGazeViolation:c}=to(),{multipleFacesDetected:l,referenceFaceNotDetected:h,isLookingAway:u}=e;d.useEffect(()=>{if(!r)return;let g;return(u||l||h)&&t?g=setTimeout(()=>{n(!0),u?(a("looking_away"),c("looking_away")):l?(a("multiple_faces"),c("multiple_faces")):h&&(a("no_face_detected"),c("no_face_detected"))},rh):(n(!1),s===ke.MODEL_LOADING?g=setTimeout(()=>{a("face_detected")},500):a("face_detected")),()=>{clearTimeout(g)}},[u,l,h,t,c,r]);const f=d.useCallback(()=>l?ke.MULTIPLE_FACES:h?"no_face_detected":u?ke.LOOKING_AWAY:s===ke.MODEL_LOADING?ke.MODEL_LOADING:ke.FACE_DETECTED,[l,h,u,s]),w=d.useCallback(()=>{n(!1),a("face_detected")},[]);return{showGazeWarningModal:i,faceDetectionState:s,getWarningType:f,closeWarningModal:w,setShowGazeWarningModal:n,setFaceDetectionState:a}};function nh(e){var t;if(!navigator.onLine)return{type:"network",message:"No internet connection",retryable:!0,userMessage:"Please check your internet connection and try again."};if(e.name==="AbortError"||(t=e.message)!=null&&t.includes("timeout"))return{type:"timeout",message:"Request timed out",retryable:!0,userMessage:"The request is taking longer than expected. Please try again."};if(e.status){const{status:r}=e;if(r===401||r===403)return{type:"auth",status:r,message:"Authentication failed",retryable:!1,userMessage:"Your session has expired. Please refresh the page."};if(r===429)return{type:"rate-limit",status:r,message:"Too many requests",retryable:!0,userMessage:"Please wait a moment before trying again."};if(r>=500)return{type:"server",status:r,message:`Server error: ${r}`,retryable:!0,userMessage:"Our servers are experiencing issues. Please try again in a few moments."};if(r>=400)return{type:"client",status:r,message:`Client error: ${r}`,retryable:!1,userMessage:"There was an issue with your request. Please check your input."}}return{type:"unknown",message:e.message||"Unknown error occurred",retryable:!0,userMessage:"Something unexpected happened. Please try again.",originalError:e}}async function Nt(e,t={},r={attempts:3,backoff:"exponential",baseDelay:1e3,maxDelay:1e4,jitter:!0}){let i;for(let n=1;n<=r.attempts;n++)try{const s=new AbortController,a=setTimeout(()=>s.abort(),6e4),c=await fetch(e,{...t,signal:s.signal});if(clearTimeout(a),c.status>=400&&c.status<500&&c.status!==429)return c;if(!c.ok)throw new Error(`HTTP ${c.status}: ${c.statusText}`);return c}catch(s){i=s;const a=nh(s);if(!a.retryable||n===r.attempts)throw a;const c=sh(n,r);console.warn(`API request failed (attempt ${n}/${r.attempts}), retrying in ${c}ms:`,a.message),await new Promise(l=>setTimeout(l,c))}throw i}function sh(e,t){let r;return t.backoff==="exponential"?r=t.baseDelay*Math.pow(2,e-1):r=t.baseDelay,r=Math.min(r,t.maxDelay),t.jitter&&(r=r*(.5+Math.random()*.5)),Math.round(r)}const It={v2:"/v2"},Ft={GENERATE_QUESTION:e=>`${It.v2}/interviews/${e}/next-question`,SCREENSHOT_UPLOAD:e=>`${It.v2}/interviews/${e}/assets/upload-url`,CONFIRM_UPLOAD:e=>`${It.v2}/interviews/assets/${e}/confirm`,TRANSCRIBE_ANSWER:e=>`${It.v2}/interviews/${e}/transcribe-answer`,SUBMIT_ANSWER:e=>`${It.v2}/interviews/${e}/submit-answer`,EXIT:e=>`${It.v2}/interviews/${e}/exit`,CONFIG:e=>`${It.v2}/interviews/${e}/config`,TRANSCRIPTION:e=>`${It.v2}/interviews/${e}/transcript`};class Y extends Error{constructor(t,r,i=!1){super(t),this.code=r,this.recoverable=i,this.name="STTError"}}const oh=50*1024*1024,fl=300,wl=500,ci=class ci{constructor(t={}){we(this,"config");we(this,"mediaRecorder",null);we(this,"audioChunks",[]);we(this,"audioChunksTotalSize",0);we(this,"recordingStream",null);we(this,"autoStopTimeoutId",null);we(this,"disposed",!1);we(this,"pendingStopPromise",null);we(this,"isStarting",!1);we(this,"recordingStartTime",null);this.config={baseUrl:"http://localhost:8000",provider:"groq",model:"whisper-large-v3-turbo",language:"en",includeTimestamps:!1,temperature:0,...t}}updateConfig(t){this.throwIfDisposed(),this.config={...this.config,...t}}isRecordingSupported(){return!!(navigator.mediaDevices&&typeof navigator.mediaDevices.getUserMedia=="function"&&window.MediaRecorder)}async startRecording(t,r){var i;if(this.throwIfDisposed(),!this.isRecordingSupported())throw new Y("Audio recording is not supported in this browser","RECORDING_NOT_SUPPORTED",!1);if(this.isRecording()||this.isStarting){console.warn("STTService.startRecording: already recording or starting, ignoring duplicate call.");return}this.isStarting=!0;try{this.recordingStream=await navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0,sampleRate:{ideal:16e3},channelCount:{ideal:1}}}),ci.activeStream=this.recordingStream,this.audioChunks=[],this.audioChunksTotalSize=0;const n=this.getSupportedMimeType();this.mediaRecorder=new MediaRecorder(this.recordingStream,{mimeType:n}),this.mediaRecorder.addEventListener("dataavailable",s=>{var a,c,l;if(s.data.size>0){if(this.audioChunksTotalSize+s.data.size>oh){console.error(`Max size exceeded: ${(this.audioChunksTotalSize/1024/1024).toFixed(2)} MB`);const h=new Y("Recording exceeded maximum size limit","MAX_SIZE_EXCEEDED",!1);(a=r==null?void 0:r.onError)==null||a.call(r,h),this.isRecording()&&((c=this.mediaRecorder)==null||c.stop());return}this.audioChunks.push(s.data),this.audioChunksTotalSize+=s.data.size,(l=r==null?void 0:r.onDataAvailable)==null||l.call(r,s.data)}}),this.mediaRecorder.addEventListener("stop",()=>{var s;(s=r==null?void 0:r.onStop)==null||s.call(r)},{once:!0}),this.mediaRecorder.addEventListener("error",s=>{var c;const a=new Y(`Recording failed: ${s.error}`,"RECORDING_ERROR",!0);(c=r==null?void 0:r.onError)==null||c.call(r,a),this.cleanup()}),this.mediaRecorder.start(100),this.recordingStartTime=Date.now(),(i=r==null?void 0:r.onStart)==null||i.call(r),t&&t>0&&(this.autoStopTimeoutId=setTimeout(()=>{this.handleAutoStop()},t*1e3))}catch(n){if(this.cleanup(),n instanceof Error){if(n.name==="NotAllowedError"||n.name==="PermissionDeniedError")throw new Y("Microphone permission was denied","PERMISSION_DENIED",!1);if(n.name==="NotFoundError")throw new Y("No microphone found","NO_MICROPHONE",!1)}throw new Y(`Failed to start recording: ${n instanceof Error?n.message:String(n)}`,"START_RECORDING_FAILED",!0)}finally{this.isStarting=!1}}async stopRecording(){var t;if(this.throwIfDisposed(),this.pendingStopPromise)return this.pendingStopPromise;if(this.autoStopTimeoutId&&(clearTimeout(this.autoStopTimeoutId),this.autoStopTimeoutId=null),!this.mediaRecorder||this.mediaRecorder.state==="inactive"){if(this.audioChunks.length>0){const i=((t=this.mediaRecorder)==null?void 0:t.mimeType)||"audio/webm",n=new Blob(this.audioChunks,{type:i});return this.cleanup(),n}const r=this.mediaRecorder?"State is inactive":"MediaRecorder is null";throw console.warn(`Cannot stop recording: ${r}`),new Y("No active recording to stop","NO_ACTIVE_RECORDING",!1)}if(this.recordingStartTime!==null){const r=Date.now()-this.recordingStartTime;r<fl&&await new Promise(i=>setTimeout(i,fl-r))}return this.pendingStopPromise=new Promise((r,i)=>{if(!this.mediaRecorder){this.pendingStopPromise=null,i(new Y("MediaRecorder is null","MEDIARECORDER_NULL",!1));return}const n=this.mediaRecorder,s=()=>{setTimeout(()=>{try{const a=n.mimeType||"audio/webm",c=new Blob(this.audioChunks,{type:a});if(!c||c.size===0){this.cleanup(),i(new Y("Audio blob is empty","EMPTY_BLOB",!1));return}this.cleanup(),r(c)}catch(a){this.cleanup(),i(new Y(`Failed to create audio blob: ${a instanceof Error?a.message:String(a)}`,"BLOB_CREATION_FAILED",!1))}finally{this.pendingStopPromise=null}},0)};n.addEventListener("stop",s,{once:!0});try{n.requestData(),n.stop()}catch(a){this.pendingStopPromise=null,i(a)}}),this.pendingStopPromise}handleAutoStop(){if(!this.isRecording())return;const t=this.recordingStartTime?Date.now()-this.recordingStartTime:1/0;if(t<wl){const r=wl-t;setTimeout(()=>{this.isRecording()&&this.executeAutoStop()},r);return}this.executeAutoStop()}executeAutoStop(){this.stopRecording().catch(t=>{console.error("Auto-stop recording failed:",t),t instanceof Y&&console.error(`[${t.code}] ${t.message}`)})}async transcribe(t){this.throwIfDisposed();const{audioBlob:r}=t;if(!r||r.size===0)throw new Y("Audio blob is empty or invalid","INVALID_AUDIO",!1);try{const i=new FormData,n=new File([r],"recording.wav",{type:r.type||"audio/wav"});if(i.append("file",n),i.append("qna_id",this.config.qnaId||""),!this.config.interviewId)throw new Y("Interview ID is missing from configuration","MISSING_INTERVIEW_ID",!1);const s=await Nt(`${this.config.baseUrl}${Ft.TRANSCRIBE_ANSWER(this.config.interviewId)}`,{method:"POST",headers:{accept:"application/json","X-STT-Provider":this.config.provider||"groq",...this.config.authToken&&{Authorization:`Bearer ${this.config.authToken}`}},body:i},{attempts:1,backoff:"exponential",baseDelay:1e3,maxDelay:3e3,jitter:!0});if(!s.ok){const c=await s.text();let l=`STT request failed: ${s.status} ${s.statusText}`;try{const h=JSON.parse(c);l=h.message||h.error||l}catch{l=c||l}throw new Y(l,`HTTP_${s.status}`,s.status>=500)}return{transcript:(await s.json()).data.transcribed_text??""}}catch(i){throw i instanceof Y?i:new Y(`Transcription failed: ${i instanceof Error?i.message:String(i)}`,"TRANSCRIPTION_FAILED",!0)}}cancelRecording(){this.autoStopTimeoutId&&(clearTimeout(this.autoStopTimeoutId),this.autoStopTimeoutId=null),this.mediaRecorder&&this.isRecording()&&this.mediaRecorder.stop(),this.cleanup()}isRecording(){return this.mediaRecorder!==null&&this.mediaRecorder.state==="recording"}dispose(){this.disposed||(this.cancelRecording(),this.disposed=!0)}isDisposed(){return this.disposed}getSupportedMimeType(){const t=["audio/webm;codecs=opus","audio/webm","audio/ogg;codecs=opus","audio/mp4","audio/wav"];for(const r of t)if(MediaRecorder.isTypeSupported(r))return r;return"audio/webm"}getRecordingStream(){return this.recordingStream}cleanup(){this.recordingStream&&(this.recordingStream.getTracks().forEach(t=>t.stop()),this.recordingStream=null,ci.activeStream=null),this.recordingStartTime=null,this.mediaRecorder=null,this.audioChunks=[],this.audioChunksTotalSize=0,this.autoStopTimeoutId&&(clearTimeout(this.autoStopTimeoutId),this.autoStopTimeoutId=null)}throwIfDisposed(){if(this.disposed)throw new Y("STTService has been disposed and cannot be reused","SERVICE_DISPOSED",!1)}};we(ci,"activeStream",null);let Nr=ci;const gl=new Nr,ah=(e,t,r,i)=>{const n=d.useRef(null);return d.useEffect(()=>{if(!t)return;const s=async()=>{try{const l=await navigator.mediaDevices.getUserMedia({video:{width:{ideal:640},height:{ideal:480},facingMode:"user"}});e.current&&(e.current.srcObject=l,e.current.onloadeddata=()=>{r()})}catch(l){console.error("Camera access error:",l),i("Camera access failed")}},a=n.current,c=e.current;return s(),()=>{a&&cancelAnimationFrame(a),c!=null&&c.srcObject&&c.srcObject.getTracks().forEach(h=>h.stop())}},[t,r]),d.useEffect(()=>{const s=gl.getRecordingStream();if(s&&e.current){e.current.srcObject=s;const a=s.getVideoTracks(),c=s.getAudioTracks(),l=()=>{console.log("Media track ended - permission may have been revoked")};[...a,...c].forEach(h=>{h.addEventListener("ended",l)})}},[]),{animationFrameRef:n}},ch=(e,t,r,i,n,s,a,c,l,h,u,f,w,g,p)=>{const y=d.useRef(null),b=d.useCallback(()=>{const m=e.current,v=t.current,_=r.current;if(!m||m.readyState<2||!_||!v){y.current=requestAnimationFrame(b);return}i();try{const E=performance.now(),k=_.detectForVideo(m,E),S=n(k,l,h.current,g);S?(s(v,m,S,u,f,w,l),l&&w&&c(S,h.current,w)):a(v,m)}catch(E){console.error("Face detection error:",E)}y.current=requestAnimationFrame(b)},[e,t,r,i,n,s,a,c,l,h,u,f,w,g,p]);return{renderLoop:b,animationFrameRef:y}},lh=(e,t,r,i)=>{const{referenceSet:n,referenceRef:s,setReferenceData:a}=to(),c=d.useRef(s),l=d.useCallback(()=>{c.current=s},[s]),h=d.useCallback(()=>{var g;const f=e.current,w=t.current;if(!(!f||!w))try{const p=performance.now(),y=f.detectForVideo(w,p);if((g=y.faceLandmarks)!=null&&g[0]){const b=y.faceLandmarks[0],m=b[33],v=b[263],_=b[1];m&&v&&_&&(c.current={x:(m.x+v.x)*.5,y:(m.y+v.y)*.5,noseX:_.x,noseY:_.y},a(!0,c.current),r("Reference set. Gaze tracking active."),i&&i())}}catch(p){console.error("Set reference error:",p),r("Failed to set reference")}},[e,t,r,a,i]),u=d.useCallback(()=>{a(!1,{x:0,y:0,noseX:0,noseY:0}),r("Reference reset. Starting calibration...")},[a,r]);return{referenceSet:n,referenceRef:c,setReference:h,resetReference:u,syncReference:l}};function dh({onClose:e,warningType:t,isCheatingModalOpen:r=!1}){const i=co[t],n=i.icon;return t==="face_detected"?null:o.jsx("div",{className:"iw-absolute iw-left-4 iw-right-4 md:iw-right-auto md:iw-w-[480px] iw-z-50 iw-animate-in iw-fade-in iw-slide-in-from-bottom-4 iw-duration-300 iw-transition-all",style:{bottom:r?"280px":"5rem"},children:o.jsxs("div",{className:"iw-relative iw-overflow-hidden iw-rounded-xl iw-border iw-border-dashed iw-border-[#5C6686] iw-bg-[#F1F5FE] iw-p-4 iw-shadow-2xl iw-backdrop-blur-sm",children:[o.jsx("button",{onClick:e,className:"iw-absolute iw-right-3 iw-top-3 iw-text-gray-400 iw-transition-colors iw-hover:iw-text-gray-600",children:o.jsx(_i,{className:"iw-h-5 iw-w-5"})}),o.jsxs("div",{className:"iw-flex iw-items-start iw-gap-2",children:[o.jsx("div",{className:"iw-flex iw-size-8 iw-flex-shrink-0 iw-items-center iw-justify-center iw-rounded-full iw-border iw-border-[#5C6686]",children:o.jsx(n,{className:"iw-size-6 iw-text-[#5C6686]"})}),o.jsxs("div",{className:"iw-flex-1 iw-pt-0.5",children:[o.jsx("h2",{className:"iw-text-[20px] iw-font-semibold iw-leading-tight iw-text-[#062260] iw-pr-6",children:i.title}),o.jsx("p",{className:"iw-mt-1.5 iw-text-lg iw-text-[#5C6686]",children:i.subtitle}),i.description&&o.jsx("div",{className:"iw-mt-3 iw-border-t iw-border-dashed iw-border-[#5C6686] iw-pt-3",children:o.jsx("p",{className:"iw-text-[14px] iw-font-bold iw-text-[#062260]",children:i.description})})]})]})]})})}const uh=({status:e})=>{const t=co[e];if(!t)return null;const r=e!=="face_detected";return o.jsxs("div",{className:"iw-flex iw-flex-col iw-items-center iw-gap-0.5",children:[o.jsxs("div",{className:"iw-flex iw-items-center iw-gap-2 iw-px-3 iw-py-1 iw-rounded-full iw-backdrop-blur-md iw-shadow-sm transition-colors duration-300 iw-text-white",children:[o.jsx("div",{className:`iw-flex iw-h-4 iw-w-4 iw-items-center iw-size-2.5 iw-justify-center iw-rounded-full iw-text-white ${e==="face_detected"?"iw-bg-[#22C55E]":e==="model_loading"?"iw-bg-[#062260]":"iw-bg-[#E94315]"}`,children:e==="face_detected"?o.jsx(Ei,{}):e==="model_loading"?o.jsx("div",{className:"iw-animate-spin iw-border iw-border-white iw-border-t-transparent iw-rounded-full iw-w-2 iw-h-2"}):o.jsx(_i,{})}),o.jsx("span",{className:"iw-text-sm iw-font-medium",children:e==="face_detected"?"Face detected clearly":e==="camera_error"?"Camera not found":t.title})]}),r&&o.jsx("span",{className:"iw-text-white iw-text-center iw-text-xs iw-drop-shadow-sm iw-max-w-[400px] iw-px-3",children:e==="model_loading"?"Initializing Face models. Please wait...":e==="no_face_detected"?"Face not detected. Please position yourself clearly in the frame.":e==="multiple_faces"?"Multiple faces detected. Please ensure only you are visible.":"Please position your face correctly."})]})};function hh(e,t={}){const[r,i]=d.useState({data:null,loading:!1,error:null}),n=d.useCallback(async(...s)=>{var a,c,l,h;i(u=>({...u,loading:!0,error:null}));try{const u=await e(...s);i(f=>({...f,data:u,loading:!1,error:null})),(a=t.onSuccess)==null||a.call(t,u),(c=t.onSettled)==null||c.call(t,u,null)}catch(u){const f=u.type?u:{type:"unknown",message:u.message||"Unknown error",retryable:!0,userMessage:"Something went wrong. Please try again.",originalError:u};i(w=>({...w,loading:!1,error:f})),(l=t.onError)==null||l.call(t,f),(h=t.onSettled)==null||h.call(t,null,f)}},[e,t]);return{...r,execute:n}}const fh=e=>{const[t,r]=d.useState(null),[i,n]=d.useState(!1),s=document,a=()=>!!(s.fullscreenEnabled||s.webkitFullscreenEnabled||s.mozFullScreenEnabled||s.msFullscreenEnabled),c=()=>s.fullscreenElement||s.webkitFullscreenElement||s.mozFullScreenElement||s.msFullscreenElement,l=async g=>{var p;try{if(!a())throw new Error("Fullscreen is not supported in this environment");g.requestFullscreen?await g.requestFullscreen():g.webkitRequestFullscreen?await g.webkitRequestFullscreen():g.mozRequestFullScreen?await g.mozRequestFullScreen():g.msRequestFullscreen&&await g.msRequestFullscreen()}catch(y){const b={name:"FullscreenError",message:y instanceof Error?y.message:"Failed to enter fullscreen"};r(b),(p=e==null?void 0:e.onError)==null||p.call(e,b)}},h=async()=>{var g;try{s.exitFullscreen?await s.exitFullscreen():s.webkitExitFullscreen?await s.webkitExitFullscreen():s.mozCancelFullScreen?await s.mozCancelFullScreen():s.msExitFullscreen&&await s.msExitFullscreen()}catch(p){const y={name:"FullscreenError",message:p instanceof Error?p.message:"Failed to exit fullscreen"};r(y),(g=e==null?void 0:e.onError)==null||g.call(e,y)}},u=d.useCallback(()=>{var p;const g=!!c();n(g),(p=e==null?void 0:e.onFullScreenChange)==null||p.call(e,g)},[e]);d.useEffect(()=>{const g=["fullscreenchange","webkitfullscreenchange","mozfullscreenchange","MSFullscreenChange"];return g.forEach(p=>{document.addEventListener(p,u)}),()=>{g.forEach(p=>{document.removeEventListener(p,u)})}},[u]);const f=async g=>{r(null);const p=g??document.documentElement;await l(p)};return{isFullScreen:i,toggleFullScreen:async g=>{i?await h():await f(g)},enterFullScreen:f,exitFullScreen:h,error:t}};class wh{constructor(t={}){we(this,"config");this.config=t}updateConfig(t){this.config={...this.config,...t}}getHeaders(){var r;const t={"Content-Type":"application/json"};return(r=this.config)!=null&&r.authToken&&(t.Authorization=`Bearer ${this.config.authToken}`),t}getBaseUrl(){var t;return((t=this.config)==null?void 0:t.baseUrl)||"/api"}async generateQuestion({interviewId:t,isInterviewDone:r=!1}){const i=await Nt(`${this.getBaseUrl()}${Ft.GENERATE_QUESTION(t)}`,{method:"POST",headers:this.getHeaders(),body:JSON.stringify({interview_id:t,is_interview_done:r})});if(!i.ok)throw new Error(`Failed to get questions: ${i.status}`);return await i.json()}async submitAnswer({interviewId:t,qnaId:r,answer:i}){const n=await Nt(`${this.getBaseUrl()}${Ft.SUBMIT_ANSWER(t)}`,{method:"POST",headers:this.getHeaders(),body:JSON.stringify({qna_id:r,answer_text:i})});if(!n.ok)throw new Error(`Failed to submit answer: ${n.status}`);return await n.json()}async exitInterview(t){const r=await Nt(`${this.getBaseUrl()}${Ft.EXIT(t)}`,{method:"POST",headers:this.getHeaders()});if(!r.ok)throw new Error(`Failed to exit interview: ${r.status}`)}async getInterviewConfig(t){const r=await Nt(`${this.getBaseUrl()}${Ft.CONFIG(t)}`,{method:"GET",headers:this.getHeaders()});if(!r.ok)throw new Error(`Failed to get interview config: ${r.status}`);return await r.json()}async requestScreenshotUploadUrl(t,r=`screenshot-${Date.now()}.jpeg`){const i=await Nt(`${this.getBaseUrl()}${Ft.SCREENSHOT_UPLOAD(t)}`,{method:"POST",headers:this.getHeaders(),body:JSON.stringify({filename:r,mime_type:"image/jpeg",asset_type:Fl.SCREENSHOT})});if(!i.ok)throw new Error(`Failed to request screenshot upload URL: ${i.status}`);return await i.json()}async uploadScreenshot(t,r){const i=await fetch(t,{method:"PUT",body:r,headers:{"Content-Type":"image/jpeg"}});if(!i.ok)throw new Error(`Failed to upload screenshot: ${i.status}`)}async confirmScreenshotUpload(t){const r=await Nt(`${this.getBaseUrl()}${Ft.CONFIRM_UPLOAD(t)}`,{method:"POST",headers:this.getHeaders()});if(!r.ok)throw new Error(`Failed to confirm screenshot upload: ${r.status}`)}async getInterviewTranscription(t){const r=await Nt(`${this.getBaseUrl()}${Ft.TRANSCRIPTION(t)}`,{method:"GET",headers:{...this.getHeaders()}});if(!r.ok)throw new Error(`Failed to get interview transcription: ${r.status}`);return await r.json()}}function qs(){const e=vi();return d.useMemo(()=>{const r=e.api||{};return new wh(r)},[e.api])}const gh=e=>{d.useEffect(()=>{const t=i=>{(i.ctrlKey||i.metaKey)&&["c","v","a","t","n","w","r","s","p"].includes(i.key.toLowerCase())&&(i.preventDefault(),e({type:"blocked_shortcut",severity:"low",details:{action:"shortcut_pressed",reason:`Attempted to use a blocked keyboard shortcut: Ctrl + ${i.key}`}})),i.key.startsWith("F")&&i.key.length<=3&&(i.preventDefault(),e({type:"blocked_function_key",severity:"low",details:{action:"function_key_pressed",reason:`Attempted to use a blocked function key: ${i.key}`}})),i.altKey&&i.key==="Tab"&&(i.preventDefault(),e({type:"alt_tab_attempt",severity:"medium",details:{action:"alt_tab",reason:"Attempted to use the Alt + Tab shortcut"}}))},r=i=>{i.preventDefault(),e({type:"right_click_attempt",severity:"low",details:{action:"right_click",reason:"Attempted to use the right click"}})};return document.addEventListener("keydown",t),document.addEventListener("contextmenu",r),()=>{document.removeEventListener("keydown",t),document.removeEventListener("contextmenu",r)}},[e])},ph=(e={})=>{const[t,r]=d.useState(!1),[i,n]=d.useState(!1),[s,a]=d.useState(null),[c,l]=d.useState(null),[h,u]=d.useState(null),f=d.useRef(e);f.current=e;const w=d.useRef(null);w.current||(w.current=new Nr(e.config)),d.useEffect(()=>{var m;e.config&&((m=w.current)==null||m.updateConfig(e.config))},[e.config]),d.useEffect(()=>{const m=w.current;return()=>{m==null||m.dispose(),w.current=null}},[]);const g=d.useCallback(async m=>{var _,E;const v=w.current;if(!v||v.isDisposed())throw new Y("STT service is not available","SERVICE_UNAVAILABLE",!1);try{l(null),a(null),u(null),await v.startRecording(m,{onStart:()=>{var k,S;r(!0),(S=(k=f.current).onStart)==null||S.call(k)},onStop:()=>{var k,S;r(!1),(S=(k=f.current).onStop)==null||S.call(k)},onError:k=>{var P,x;const S=k instanceof Y?k:new Y(k.message,"RECORDING_ERROR",!0);l(S),r(!1),(x=(P=f.current).onError)==null||x.call(P,S)}})}catch(k){const S=k instanceof Y?k:new Y(k instanceof Error?k.message:String(k),"START_FAILED",!1);throw l(S),r(!1),(E=(_=f.current).onError)==null||E.call(_,S),S}},[]),p=d.useCallback(async()=>{var v,_;const m=w.current;if(!m||m.isDisposed())throw new Y("STT service is not available","SERVICE_UNAVAILABLE",!1);try{const E=await m.stopRecording();return u(E),E}catch(E){const k=E instanceof Y?E:new Y(E instanceof Error?E.message:String(E),"STOP_FAILED",!1);throw l(k),r(!1),(_=(v=f.current).onError)==null||_.call(v,k),k}},[]),y=d.useCallback(async(m,v={})=>{var E,k,S,P,x,A;const _=w.current;if(!_||_.isDisposed())throw new Y("STT service is not available","SERVICE_UNAVAILABLE",!1);try{if(l(null),n(!0),!m||m.size===0){console.warn("Skipping transcription — blob is empty");const j={transcript:""};return a(j.transcript),n(!1),(k=(E=f.current).onTranscriptionComplete)==null||k.call(E,j),j}const D={audioBlob:m,...v},U=await _.transcribe(D);return a(U.transcript),n(!1),(P=(S=f.current).onTranscriptionComplete)==null||P.call(S,U),U}catch(D){const U=D instanceof Y?D:new Y(D instanceof Error?D.message:String(D),"TRANSCRIPTION_FAILED",!0);throw l(U),n(!1),(A=(x=f.current).onError)==null||A.call(x,U),U}},[]),b=d.useCallback(()=>{var m;(m=w.current)==null||m.cancelRecording(),r(!1),u(null)},[]);return{startRecording:g,stopRecording:p,transcribe:y,cancelRecording:b,isRecording:t,isTranscribing:i,transcript:s,error:c,audioBlob:h}},mh=e=>{const t=d.useRef(null),r=d.useRef(!1);d.useEffect(()=>{const i=()=>{document.hidden&&(r.current=!0,t.current&&(clearTimeout(t.current),t.current=null),e({type:"tab_switch",severity:"high",details:{action:"tab_hidden",reason:"Attempted to switch tabs or applications"}}),setTimeout(()=>{r.current=!1},100))},n=()=>{r.current||(t.current=setTimeout(()=>{r.current||e({type:"focus_loss",severity:"medium",details:{action:"window_blur",reason:"Focus lost from the interview window"}}),t.current=null},50))};return document.addEventListener("visibilitychange",i),window.addEventListener("blur",n),()=>{document.removeEventListener("visibilitychange",i),window.removeEventListener("blur",n),t.current&&clearTimeout(t.current)}},[e])},yh=()=>{d.useEffect(()=>{const e=document.createElement("style");return e.textContent=`
|
|
16
16
|
* {
|
|
17
17
|
-webkit-user-select: none !important;
|
|
18
18
|
-moz-user-select: none !important;
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
-ms-user-select: text !important;
|
|
26
26
|
user-select: text !important;
|
|
27
27
|
}
|
|
28
|
-
`,document.head.appendChild(e),()=>{document.head.removeChild(e)}},[])};var
|
|
28
|
+
`,document.head.appendChild(e),()=>{document.head.removeChild(e)}},[])};var V=(e=>(e.IDLE="idle",e.FETCHING_QUESTION="fetching_question",e.READING_QUESTION="reading_question",e.THINKING="thinking",e.ANSWERING="answering",e.TRANSCRIBING="transcribing",e.EDITING="editing",e.SUBMITTING="submitting",e.COMPLETED="completed",e))(V||{});const pl={thinkingDuration:0,answeringDuration:120,editingDuration:30},ml={idle:{next:"fetching_question"},fetching_question:{next:"reading_question"},reading_question:{next:"answering"},thinking:{next:"answering",duration:0},answering:{next:"transcribing",duration:120},transcribing:{next:"editing"},editing:{next:"submitting",duration:30},submitting:{next:"completed"},completed:{next:"completed"}};class bh{constructor(t={},r={}){we(this,"config");we(this,"state");we(this,"phaseIntervalId",null);we(this,"globalIntervalId",null);we(this,"callbacks");this.config={...pl,...t},this.callbacks=r,this.state={phase:"idle",currentPhaseTimeRemaining:0,totalTimeElapsed:0,currentQuestionNumber:0}}updateConfig(t){this.config={...this.config,...t}}getState(){return{...this.state}}startQuestion(){this.state.currentQuestionNumber===0&&this.startGlobalTimer(),this.state.currentQuestionNumber=this.state.currentQuestionNumber+1,this.state.phase="fetching_question",this.notifyChange()}nextPhase(){const t=this.state.phase;let r=ml[t];if(!r)return;if(r.next==="editing"&&this.config.editingDuration===0){const n=ml.editing;n&&(r=n)}this.stopPhaseTimer(),this.state.phase=r.next;const i=this.getDurationForPhase(r.next);i>0?(this.state.currentPhaseTimeRemaining=i,this.startPhaseTimer()):this.state.currentPhaseTimeRemaining=0,this.notifyChange()}setTotalTimeElapsed(t){var r,i;this.state.totalTimeElapsed=t,(i=(r=this.callbacks).onTick)==null||i.call(r,this.getState())}completeInterview(){var t,r;this.stopGlobalTimer(),this.stopPhaseTimer(),this.state.phase="completed",(r=(t=this.callbacks).onInterviewEnd)==null||r.call(t),this.notifyChange()}destroy(){this.stopPhaseTimer(),this.stopGlobalTimer()}getDurationForPhase(t){switch(t){case"thinking":return this.config.thinkingDuration;case"answering":return this.config.answeringDuration;case"editing":return this.config.editingDuration;default:return 0}}startGlobalTimer(){this.globalIntervalId=setInterval(()=>{var t,r;this.state.totalTimeElapsed++,(r=(t=this.callbacks).onTick)==null||r.call(t,this.getState())},1e3)}stopGlobalTimer(){this.globalIntervalId&&(clearInterval(this.globalIntervalId),this.globalIntervalId=null)}startPhaseTimer(){this.phaseIntervalId=setInterval(()=>{this.state.currentPhaseTimeRemaining--,this.state.currentPhaseTimeRemaining<=0&&this.nextPhase()},1e3)}stopPhaseTimer(){this.phaseIntervalId&&(clearInterval(this.phaseIntervalId),this.phaseIntervalId=null)}notifyChange(){var t,r;(r=(t=this.callbacks).onPhaseChange)==null||r.call(t,this.state.phase,this.getState())}}function vh(e={}){const{config:t={},callbacks:r={}}=e,i=d.useRef(null);i.current||(i.current=new bh(t,{}));const n=i.current,[s,a]=d.useState(n.getState()),c=d.useCallback(()=>{a(n.getState())},[n]);d.useEffect(()=>{const f={onPhaseChange:(w,g)=>{var p;c(),(p=r.onPhaseChange)==null||p.call(r,w,g)},onTick:w=>{var g;c(),(g=r.onTick)==null||g.call(r,w)},onInterviewEnd:()=>{var w;c(),(w=r.onInterviewEnd)==null||w.call(r)}};n.callbacks=f},[n,r,c]),d.useEffect(()=>{n.updateConfig(t)},[n,t]),d.useEffect(()=>()=>{n.destroy()},[n]);const l=d.useCallback(()=>{n.startQuestion(),c()},[n,c]),h=d.useCallback(()=>{n.nextPhase(),c()},[n,c]),u=d.useCallback(()=>{n.completeInterview(),c()},[n,c]);return{state:s,startQuestion:l,nextPhase:h,completeInterview:u,timerService:n}}class xh{constructor(){we(this,"currentAudio",null)}async play(t,r){var i,n;try{if(this.stop(),(i=r==null?void 0:r.onStart)==null||i.call(r),!t)throw new Error("No audio data provided");const s=window.atob(t),a=new Uint8Array(s==null?void 0:s.length);for(let h=0;h<(s==null?void 0:s.length);h++)a[h]=s==null?void 0:s.charCodeAt(h);const c=new Blob([a],{type:"audio/wav"}),l=URL.createObjectURL(c);return this.currentAudio=new Audio(l),new Promise((h,u)=>{if(!this.currentAudio){u(new Error("Audio element not created"));return}const f=this.currentAudio;f.onended=()=>{var w;URL.revokeObjectURL(l),this.currentAudio=null,(w=r==null?void 0:r.onEnd)==null||w.call(r),h()},f.onerror=w=>{var p;URL.revokeObjectURL(l),this.currentAudio=null;const g=new Error(`Audio playback failed: ${w}`);(p=r==null?void 0:r.onError)==null||p.call(r,g),u(g)},f.play().catch(w=>{var p;URL.revokeObjectURL(l),this.currentAudio=null;const g=new Error(`Failed to play audio: ${w.message}`);(p=r==null?void 0:r.onError)==null||p.call(r,g),u(g)})})}catch(s){const a=s instanceof Error?s:new Error(`TTS Error: ${String(s)}`);throw(n=r==null?void 0:r.onError)==null||n.call(r,a),a}}stop(){this.currentAudio&&(this.currentAudio.pause(),this.currentAudio.currentTime=0,this.currentAudio=null)}isPlaying(){return this.currentAudio!==null&&!this.currentAudio.paused}}const Ks=new xh,Eh=(e={})=>{const[t,r]=d.useState(!1),[i,n]=d.useState(!1),[s,a]=d.useState(null),c=d.useCallback(async h=>{var u;try{a(null),n(!0),await Ks.play(h,{onStart:()=>{var f;n(!1),r(!0),(f=e.onStart)==null||f.call(e)},onEnd:()=>{var f;r(!1),(f=e.onEnd)==null||f.call(e)},onError:f=>{var w;r(!1),n(!1),a(f),(w=e.onError)==null||w.call(e,f)}})}catch(f){const w=f instanceof Error?f:new Error(String(f));throw a(w),r(!1),n(!1),(u=e.onError)==null||u.call(e,w),w}},[e]),l=d.useCallback(()=>{Ks.stop(),r(!1),n(!1)},[]);return{speak:c,stop:l,isPlaying:t,isLoading:i,error:s}},_h=({onViolation:e,onEnd:t,maxViolations:r=5})=>{const{addViolation:i}=jl(),n=Vl(),s=Gl(),a=d.useRef(s);d.useEffect(()=>{a.current=s},[s]);const c=d.useCallback(h=>{t&&t(h,a.current)},[t]);return{logViolation:d.useCallback(({type:h,severity:u,details:f})=>{const w={id:Kl(),type:h,severity:u,details:f,timestamp:Date.now()};i(w);const g=a.current+1;e&&e(w,g),g>=r&&c("excessive_violations")},[i,e,r,c]),onInterviewEnd:c,violationCount:s,logList:n}},kh=()=>{d.useEffect(()=>{function e(){console.clear(),console.log(`
|
|
29
29
|
%c
|
|
30
30
|
╔═══════════════════════════════════════════════════════════════════════╗
|
|
31
31
|
║ ║
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
│ │
|
|
72
72
|
│ 💡 IMMEDIATE ACTION REQUIRED: │
|
|
73
73
|
│ Close developer tools to continue interview │
|
|
74
|
-
└─────────────────────────────────────────────────────────────┘`,"color: #ffd93d; font-size: 14px; font-family: monospace; background: rgba(255, 217, 61, 0.1); padding: 10px;")}const t={open:!1,orientation:null},r=160,i=setInterval(()=>{window.outerHeight-window.innerHeight>r||window.outerWidth-window.innerWidth>r?t.open||(t.open=!0,t.orientation=window.outerWidth-window.innerWidth>r?"vertical":"horizontal",e()):t.open&&(t.open=!1,console.log("%c🌟 Developer tools closed. Interview continues smoothly! ✨","color: #4ecdc4; font-weight: bold; text-shadow: 0 0 10px #4ecdc4;"))},500),n=a=>{if(a.keyCode===123||a.ctrlKey&&a.shiftKey&&(a.keyCode===73||a.keyCode===74)||a.ctrlKey&&a.keyCode===85)return a.preventDefault(),console.log("%c🎭 Nice try! Keyboard shortcuts are disabled during interviews ✨","color: #ffd93d; font-weight: bold; text-shadow: 0 0 10px #ffd93d;"),!1},s=a=>(a.preventDefault(),console.log("%c🌈 Right-click menu disabled for interview integrity! 🎪","color: #ff9ff3; font-weight: bold; text-shadow: 0 0 10px #ff9ff3;"),!1);return document.addEventListener("keydown",n),document.addEventListener("contextmenu",s),()=>{clearInterval(i),document.removeEventListener("keydown",n),document.removeEventListener("contextmenu",s),delete window.showStats,delete window.interviewTips}},[])},ml=d.forwardRef(({className:e="",interviewId:t="",interview_duration:r,showProctoringUI:i=!0,onSetReference:n,isAnswering:s,onProctoringStatusChange:a,showStatusOverlay:c=!1,cheatingWarningVisible:l=!1,isDeviceLoading:h=!1,videoAllowed:u=!0},f)=>{var Cl;const{authToken:w}=io(),g=Hs(),p=w?Kl(w):null,{borderRadius:y}=Rt(),b=y??18,{proctoring:m,capture_screenshots:v}=Gr(),k=!!(m!=null&&m.gazeAnalysisEnabled),[_,S]=d.useState(!1),[E,P]=d.useState((m==null?void 0:m.showLandmarks)??!1),[C,x]=d.useState(i&&((m==null?void 0:m.showEngagementBar)??!0)),[M,U]=d.useState(k),[V,q]=d.useState(!1),D=d.useRef(null),O=d.useRef(null),R=d.useRef(null),be=d.useRef(null),ze=d.useCallback(async _e=>{var fn;const pi=D.current,Ae=R.current;if(!pi||!Ae)return;const Br=Ae.getContext("2d");if(!Br)return;Ae.width=pi.videoWidth,Ae.height=pi.videoHeight,Br.save(),Br.scale(-1,1),Br.drawImage(pi,-Ae.width,0,Ae.width,Ae.height),Br.restore();const mi=await new Promise(Zt=>Ae.toBlob(Zt,"image/jpeg"));if(mi&&t)try{const Zt=`${_e}-${Date.now()}.jpeg`,Ce=await g.requestScreenshotUploadUrl(t,Zt);Ce.data&&Ce.data.upload_url&&(await g.uploadScreenshot((fn=Ce==null?void 0:Ce.data)==null?void 0:fn.upload_url,mi),Ce.data.asset_id&&await g.confirmScreenshotUpload(Ce.data.asset_id))}catch(Zt){console.error(`Failed to upload screenshot for ${_e}:`,Zt)}},[g,t]);d.useEffect(()=>{let _e;return s&&(q(!0),_e=setTimeout(()=>q(!1),1e3)),()=>{_e&&clearTimeout(_e)}},[s]);const{faceLandmarkerRef:ft,isModelLoaded:We,statusMessage:He,setStatusMessage:wt,loadingProgress:Lt,permissionDenied:Ir,clearCache:Fr}=Yu(),{fps:Lr,updateFPS:Mr}=Xu(),{drawWithEngagementBar:Dr,clearCanvas:Qt,engagementRef:Ie}=Qu(),{engagement:Mt,isLookingAway:ne,analyzeGaze:ci,setEngagement:Pr,setIsLookingAway:Jt}=Zu(),{multipleFacesDetected:Or,referenceFaceNotDetected:li,analyzeFace:Qs,setMultipleFacesDetected:dn,setReferenceFaceNotDetected:di}=eh(),{referenceSet:ui,referenceRef:hi,setReference:fi,resetReference:wi,syncReference:gi}=ch(ft,D,wt,n),un={multipleFacesDetected:Or,referenceFaceNotDetected:li,isLookingAway:ne},{showGazeWarningModal:B,getWarningType:$,closeWarningModal:Ze,setShowGazeWarningModal:hn,setFaceDetectionState:Al}=rh(un,k&&!c,We);d.useEffect(()=>{if(a){if(h||!We){a("model_loading");return}if(!u){a("camera_error");return}const _e=$()||ke.NO_FACE;a(_e)}},[We,h,u,Or,li,ne,$,a]);const{renderLoop:a2}=ah(D,O,ft,Mr,Qs,Dr,Qt,ci,ui,hi,E,C,k,wt,di);oh(D,We,a2,wt),d.useEffect(()=>{gi()},[gi]),d.useEffect(()=>{Ie&&Ie.current&&(Ie.current.value=Mt,Ie.current.isLookingAway=ne)},[Mt,ne,Ie]);const c2=d.useCallback(_e=>{U(_e),_e||(Pr(100),Jt(!1))},[Pr,Jt]),l2=d.useCallback(()=>{Jt(!1),dn(!1),di(!1),Al("face_detected"),hn(!1),Ze()},[Jt,dn,di,Al,hn,Ze]),d2={engagement:Mt,fps:Lr,isLookingAway:ne,multipleFacesDetected:Or,referenceFaceNotDetected:li};return d.useEffect(()=>{if(!v)return;const _e=[];return(async()=>{try{const Ae=await navigator.mediaDevices.getUserMedia({video:!0,audio:!1});be.current=Ae,D.current&&(D.current.srcObject=Ae);const mi=(r??yi)*60*1e3/3,fn=[0,1,2].map((Ce,Dt)=>({label:`capture-${Dt+1}`,start:Dt*mi,end:(Dt+1)*mi})),Zt=(Ce,Dt)=>Ce===Dt?Ce:Math.random()*(Dt-Ce)+Ce;fn.forEach(({label:Ce,start:Dt,end:u2},h2)=>{let Js;h2===0?Js=3e3:Js=Zt(Dt,u2),_e.push(setTimeout(()=>{ze(Ce)},Js))})}catch(Ae){console.error("Error accessing camera:",Ae)}})(),()=>{be.current&&be.current.getTracks().forEach(Ae=>Ae.stop()),_e.forEach(clearTimeout)}},[ze,v]),d.useImperativeHandle(f,()=>({setReference:()=>{fi()},resetReference:()=>{wi()},stopCamera:()=>{be.current&&(be.current.getTracks().forEach(_e=>_e.stop()),be.current=null)}}),[fi,wi]),o.jsxs("div",{className:`iw-relative iw-h-full iw-w-full ${e}`,children:[Ir?o.jsxs("div",{className:"iw-rounded-md iw-border iw-border-red-600 iw-p-5 iw-text-red-600",children:[o.jsx("h2",{children:"Camera Permission Denied"}),o.jsx("p",{children:"Please allow camera access to use this application."})]}):o.jsx("div",{className:"iw-flex iw-w-full iw-h-full iw-justify-start iw-items-start",children:o.jsxs("div",{className:`iw-relative iw-max-w-full iw-max-h-full iw-aspect-video iw-rounded-2xl iw-overflow-hidden iw-bg-black ${V?"iw-animate-answer-start":""} ${s?"iw-border-4 iw-border-[#6296FB]":""}`,style:{width:"100%",height:"auto",minHeight:"0"},children:[o.jsx("video",{ref:D,autoPlay:!0,playsInline:!0,muted:!0,className:"iw-absolute iw-inset-0 iw-w-full iw-h-full iw-object-cover",style:{transform:"scaleX(-1)"}}),!u&&o.jsx("div",{className:"iw-absolute iw-inset-0 iw-flex iw-flex-col iw-items-center iw-justify-center iw-bg-black/60 iw-z-30",children:h||!We?o.jsxs("div",{className:"iw-flex iw-flex-col iw-items-center iw-gap-3",children:[o.jsx("div",{className:"iw-w-5 iw-h-5 iw-border-2 iw-border-white/20 iw-border-t-white iw-rounded-full iw-animate-spin"}),o.jsx("span",{className:"iw-text-white/60 iw-text-xs iw-font-medium iw-tracking-wide",children:"Initializing camera..."})]}):o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"iw-text-white iw-font-medium iw-text-sm",children:"Camera not found"}),o.jsx("p",{className:"iw-text-white/60 iw-text-xs iw-mt-1",children:"Please ensure your camera is connected and enabled"})]})}),k&&o.jsx("canvas",{ref:O,width:320,height:240,className:"iw-absolute iw-inset-0 iw-w-full iw-h-full iw-object-cover",style:{transform:"scaleX(-1)",borderRadius:b,display:"hidden"}}),o.jsx("canvas",{ref:R,style:{display:"none"}}),i&&o.jsxs("div",{className:"iw-absolute iw-top-4 iw-right-4 iw-inline-flex iw-items-center iw-gap-2 iw-rounded-lg iw-border iw-border-white/10 iw-bg-[#FFEBE6] iw-px-2 iw-py-1 iw-backdrop-blur-md",children:[o.jsx("div",{className:"iw-size-2 iw-animate-pulse iw-rounded-full iw-bg-red-500"}),o.jsx("span",{className:"iw-font-medium iw-text-xs iw-text-[#E94315]",children:"RECORDING"})]}),i&&((Cl=p==null?void 0:p.data)==null?void 0:Cl.user_name)&&o.jsx("div",{className:"iw-absolute iw-z-50 iw-bottom-4 iw-right-4 iw-inline-flex iw-items-center iw-gap-2 iw-rounded-lg iw-border iw-border-white/10 iw-bg-[#F1F5FE] iw-px-3 iw-py-1 iw-backdrop-blur-md",children:o.jsx("span",{className:"iw-font-medium iw-text-xs iw-text-[#062260]",children:p.data.user_name})}),i&&o.jsx("div",{className:"iw-absolute iw-bottom-4 iw-right-4",children:o.jsx(od,{showControls:(m==null?void 0:m.showControls)??!1,isBubbleOpen:_,setIsBubbleOpen:S,setReference:fi,clearCache:Fr,isModelLoaded:We,gazeAnalysisEnabled:M&&k,referenceSet:ui,showLandmarks:E,setShowLandmarks:P,showEngagementBar:C,setShowEngagementBar:x,handleToggleGazeAnalysis:c2,stats:d2,statusMessage:He,loadingProgress:Lt})}),c&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"iw-absolute iw-inset-0 iw-pointer-events-none iw-z-10 ",style:{background:"radial-gradient(ellipse 20% 40% at 50% 45%, transparent 99.5%, rgba(0,0,0,0.35) 100%)"}}),o.jsx("div",{className:"iw-absolute iw-bottom-2 iw-inset-x-0 iw-flex iw-justify-center iw-pointer-events-none iw-z-20",children:o.jsx(dh,{status:u?h||!We?"model_loading":$()??"no_face_detected":"camera_error"})})]})]})}),k&&B&&!c&&o.jsx(lh,{isOpen:B,onClose:l2,warningType:$(),isCheatingModalOpen:l})]})}),an=({children:e,variant:t="primary",size:r="md",fullWidth:i=!1,isLoading:n=!1,disabled:s,className:a="",...c})=>{const l="iw-inline-flex iw-items-center iw-justify-center iw-rounded-md iw-font-medium iw-transition-colors iw-focus:outline-none iw-focus:ring-2 iw-focus:ring-primary-500 iw-focus:ring-offset-2",h={primary:"iw-bg-primary-600 iw-text-white iw-hover:bg-primary-700 iw-border iw-border-transparent",secondary:"iw-bg-primary-100 iw-text-primary-700 iw-hover:bg-primary-200 iw-border iw-border-transparent",outline:"iw-bg-transparent iw-text-primary-700 iw-border iw-border-primary-500 iw-hover:bg-primary-50",text:"iw-bg-transparent iw-text-primary-600 iw-hover:bg-primary-50 iw-border iw-border-transparent",gradient:"iw-text-white iw-border iw-border-transparent iw-bg-gradient-to-r iw-from-purple-500 iw-to-indigo-500 hover:iw-from-purple-600 hover:iw-to-indigo-600"},u={sm:"iw-px-3 iw-py-1.5 iw-text-sm",md:"iw-px-4 iw-py-2.5 iw-text-sm",lg:"iw-px-5 iw-py-3 iw-text-base"},f="iw-disabled:opacity-50 iw-disabled:cursor-not-allowed iw-disabled:pointer-events-none",w=i?"iw-w-full":"";return o.jsxs("button",{className:`${l} ${h[t]} ${u[r]} ${w} ${f} ${a}`,disabled:s||n,...c,children:[n&&o.jsx(so,{height:16,width:16,style:{marginRight:"3px"}}),e]})},yl=({baseColor:e="#3B82F6",contentClassName:t,title:r,description:i})=>o.jsx(o.Fragment,{children:o.jsx("div",{className:`iw-hidden group-hover:iw-block iw-absolute iw-bottom-full iw-mb-3 iw-left-1/2 -iw-translate-x-1/2 iw-w-64 iw-z-50 ${t}`,children:o.jsxs("div",{className:"iw-rounded-lg iw-p-3 iw-shadow-lg iw-text-white iw-text-left iw-relative",style:{background:e},children:[r&&o.jsx("div",{className:"iw-flex iw-justify-between iw-items-start iw-mb-1",children:o.jsx("h4",{className:"iw-text-sm iw-font-bold iw-mr-2",children:r})}),i&&o.jsx("p",{className:"iw-text-xs iw-opacity-90 iw-leading-tight",children:i}),o.jsx("div",{className:"iw-absolute iw-top-full -iw-translate-x-1/2 iw-border-[6px] iw-border-transparent",style:{borderTopColor:e}})]})})}),kh=({stream:e,className:t="",barCount:r=50,onAudioLevel:i})=>{const n=d.useRef(null),s=d.useRef(null),a=d.useRef(0),c=d.useRef(null),l=d.useRef(null),h=d.useRef(null);d.useEffect(()=>{if(!e||window===void 0)return;l.current||(l.current=new(window.AudioContext||window.webkitAudioContext));const f=l.current;c.current||(c.current=f.createAnalyser(),c.current.fftSize=256,c.current.smoothingTimeConstant=.5);const w=c.current;try{h.current&&h.current.disconnect(),h.current=f.createMediaStreamSource(e),h.current.connect(w)}catch(p){console.error("Error creating media stream source:",p);return}const g=()=>{if(!n.current)return;const p=n.current,y=p.getContext("2d");if(!y)return;const b=w.frequencyBinCount,m=new Uint8Array(b);w.getByteFrequencyData(m);const v=p.width,k=p.height;y.clearRect(0,0,v,k);let _=0;for(let D=0;D<b;D++){const O=m[D]??0;_+=O*O}const S=Math.sqrt(_/b),E=Math.min(1,S/128),P=new Float32Array(w.fftSize);w.getFloatTimeDomainData(P);let C=0;for(let D=0;D<P.length;D++){const O=P[D]||0;C+=O*O}const x=Math.sqrt(C/P.length),M=x>0?20*Math.log10(x):-1/0;let U="problem";if(M>=-20?U="good":M>=-25?U="acceptable":M>=-45?U="poor":U="problem",i){const D=Date.now();D-a.current>200&&(a.current=D,i(U,M))}y.clearRect(0,0,v,k);const V=r,q=Math.floor(E*V);for(let D=0;D<V;D++){const O=D*(v/V),R=v/V-1.8;D<q?y.fillStyle="#0EB00E":y.fillStyle="#D9D9D9",y.fillRect(O,0,R,k)}s.current=requestAnimationFrame(g)};return g(),()=>{s.current&&cancelAnimationFrame(s.current)}},[e,r]);const u=d.useRef({audioContext:l.current,source:h.current});return u.current={audioContext:l.current,source:h.current},d.useEffect(()=>()=>{u.current.source&&u.current.source.disconnect(),u.current.audioContext&&u.current.audioContext.state!=="closed"&&u.current.audioContext.close()},[]),o.jsx("canvas",{ref:n,className:t,width:300,height:20,style:{width:"100%",height:"100%"}})},Sh={initial:{bgColor:"iw-bg-[#FEF2F2]",borderColor:"iw-border-[#FECACA]",iconBg:"iw-bg-[#C81E1E]",iconColor:"iw-text-white",titleColor:"iw-text-[#C81E1E]",subtitleColor:"iw-text-[#991B1B]",title:"Action Required: No Sound Detected",subtitle:"Please speak into your microphone to test it.",tooltipText:"Please speak into your microphone to verify audio quality before proceeding",tooltipBg:"#DC2626"},poor:{bgColor:"iw-bg-[#FFF7ED]",borderColor:"iw-border-[#FFEDD5]",iconBg:"iw-bg-[#EA580C]",iconColor:"iw-text-white",titleColor:"iw-text-[#EA580C]",subtitleColor:"iw-text-[#9A3412]",title:"Poor Audio Levels: Speak Louder to Continue",subtitle:"We can hear you, but your microphone sound is very low.",tooltipText:"Your microphone sound is very low. Please try speaking louder or check your microphone settings.",tooltipBg:"#EA580C"},acceptable:{bgColor:"iw-bg-[#FFFBEB]",borderColor:"iw-border-[#FDE68A]",iconBg:"iw-bg-[#D97706]",iconColor:"iw-text-white",titleColor:"iw-text-[#D97706]",subtitleColor:"iw-text-[#92400E]",title:"Acceptable Action: Keep speaking.",subtitle:"You can speak louder for better quality.",tooltipText:"Your microphone is working, but we're having trouble hearing you clearly. Try speaking a bit louder or moving closer to your microphone",tooltipBg:"#B45309"},good:{bgColor:"iw-bg-[#F0FDF4]",borderColor:"iw-border-[#BBF7D0]",iconBg:"iw-bg-[#16A34A]",iconColor:"iw-text-white",titleColor:"iw-text-[#16A34A]",subtitleColor:"iw-text-[#14532D]",title:"Excellent!",subtitle:"Your audio is clear. You can continue.",tooltipText:"Your audio levels are perfect. You're ready to proceed with the interview",tooltipBg:"#16A34A"},success:{bgColor:"iw-bg-[#F0FDF4]",borderColor:"iw-border-[#BBF7D0]",iconBg:"iw-bg-[#16A34A]",iconColor:"iw-text-white",titleColor:"iw-text-[#16A34A]",subtitleColor:"iw-text-[#14532D]",title:"Success! Mic is ready.",subtitle:"Your microphone is working perfectly.",tooltipText:"Your microphone is working perfectly and ready for the interview",tooltipBg:"#16A34A"}},Ah=({micEnabled:e,micTested:t,audioStatus:r})=>{if(!e)return null;let i="initial";t&&r==="problem"?i="success":r==="good"?i="good":r==="acceptable"?i="acceptable":r==="poor"&&(i="poor");const n=Sh[i];return o.jsx("div",{className:"iw-relative iw-w-full iw-group",children:o.jsxs("div",{className:`iw-flex iw-items-center iw-gap-3 iw-py-2 iw-px-2 iw-w-full iw-rounded-xl iw-border ${n.borderColor} ${n.bgColor} iw-transition-all iw-duration-300 ${i==="initial"||i==="poor"?"iw-animate-initial-mic":""}`,children:[o.jsx("div",{className:`iw-flex iw-items-center iw-justify-center iw-w-9 iw-h-9 iw-rounded-full ${n.iconBg} iw-shrink-0`,children:o.jsx(nd,{className:`iw-w-5 iw-h-5 ${n.iconColor}`})}),o.jsxs("div",{className:"iw-flex iw-flex-col iw-gap-[2px] iw-pr-2",children:[o.jsx("p",{className:`${n.titleColor} iw-text-sm iw-font-semibold iw-m-0 iw-leading-[1.1]`,children:n.title}),o.jsx("p",{className:`${n.subtitleColor} iw-text-xs iw-font-normal iw-m-0 iw-leading-[1.1]`,children:n.subtitle})]})]})})},bl=({icon:e,devices:t,selectedId:r,onChange:i,label:n,showVisualizer:s=!1,showMicHint:a=!1,micTested:c=!1,audioStatus:l="problem",stream:h=null,hasPermission:u=!0,onAudioLevel:f})=>{const{baseColor:w}=Rt(),[g,p]=d.useState(!1),y=d.useRef(null);d.useEffect(()=>{const v=k=>{y.current&&!y.current.contains(k.target)&&p(!1)};return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[]);const b=t.find(v=>v.deviceId===r)||t[0],m=u&&(b==null?void 0:b.label)||n;return o.jsxs("div",{className:`iw-relative iw-flex-1 iw-w-1/2 ${!u&&"iw-group"}`,ref:y,children:[o.jsxs("div",{className:`iw-max-w-[300px] iw-flex iw-items-center iw-justify-between iw-bg-white iw-border iw-border-gray-200 iw-rounded-xl iw-px-3 iw-py-3 iw-transition-colors ${u?"iw-cursor-pointer hover:iw-border-blue-500":"iw-cursor-not-allowed"}`,onClick:()=>u&&p(!g),title:u?"":"Permission denied or device not found",children:[o.jsxs("div",{className:"iw-flex iw-items-center iw-gap-3 iw-min-w-0 iw-flex-1",children:[o.jsx(e,{className:"iw-w-5 iw-h-5 iw-text-[#062260] iw-flex-shrink-0"}),o.jsxs("div",{className:"iw-flex iw-flex-col iw-min-w-0 iw-flex-1",children:[o.jsx("span",{className:"iw-text-sm iw-text-[#062260] iw-font-medium iw-truncate",children:m}),s&&u&&o.jsx("div",{className:"iw-w-full iw-h-1.5 iw-mt-1",children:o.jsx(kh,{stream:h,className:"iw-w-full iw-h-full",onAudioLevel:f,barCount:45})})]})]}),o.jsx("div",{className:"iw-flex iw-items-center iw-gap-2",children:u?o.jsxs(o.Fragment,{children:[o.jsx(Zl,{className:`iw-w-4 iw-h-4 iw-text-gray-400 iw-transition-transform ${g?"iw-rotate-180":""}`}),r&&o.jsx("div",{className:"iw-bg-[#22C55E] iw-rounded-full iw-p-0.5",children:o.jsx(xi,{className:"iw-w-3 iw-h-3 iw-text-white"})})]}):o.jsx("div",{className:"iw-text-[#E94315] iw-relative",children:o.jsx(vi,{className:"iw-size-5"})})})]}),!u&&o.jsx(yl,{baseColor:w,contentClassName:"!iw-left-0",title:`Allow us to access your ${(n==null?void 0:n.split(" ")[1])??"device"}`,description:"We need permission to access your device. Go to your browser privacy settings to allow it"}),a&&u&&o.jsx("div",{className:"iw-w-full iw-mt-2 sm:iw-w-[calc(200%+16px)] iw-z-100",children:o.jsx(Ah,{micEnabled:u,micTested:c,audioStatus:l})}),g&&u&&o.jsxs("div",{className:"iw-absolute iw-bottom-full iw-left-0 iw-right-0 iw-mb-2 iw-bg-white iw-border iw-border-gray-100 iw-rounded-xl iw-shadow-xl iw-z-50 iw-py-2 iw-max-h-60 iw-overflow-y-auto",children:[t.map(v=>o.jsxs("div",{className:`iw-px-4 iw-py-2.5 iw-text-sm iw-cursor-pointer iw-flex iw-items-center iw-justify-start hover:iw-bg-gray-50 ${r===v.deviceId?"iw-text-[#062260] iw-font-medium iw-bg-blue-50":"iw-text-gray-600"}`,onClick:()=>{i==null||i(v.deviceId),p(!1)},children:[r===v.deviceId&&o.jsx(xi,{className:"iw-w-4 iw-h-4 iw-text-[#062260] iw-mr-1"}),o.jsx("span",{className:"iw-truncate",children:v.label||`Device ${v.deviceId.slice(0,5)}...`})]},v.deviceId)),t.length===0&&o.jsx("div",{className:"iw-px-4 iw-py-2 iw-text-sm iw-text-gray-400",children:"No devices found"})]})]})},vl=({micEnabled:e=!1,videoEnabled:t=!1,buttonText:r,onButtonClick:i,isAgreed:n,onAgreedToggle:s,showCheckbox:a=!0,showMediaIcons:c=!0,disabled:l=!1,audioDevices:h=[],videoDevices:u=[],selectedAudioId:f,selectedVideoId:w,onAudioChange:g,onVideoChange:p,audioStream:y=null,isDeviceLoading:b=!1})=>{const{baseColor:m}=Rt(),[v,k]=d.useState("problem"),[_,S]=d.useState(!1);d.useEffect(()=>{k("problem"),S(!1)},[f]);const E=l||!n||c&&(!e||!t||!_)||b,P=C=>{const x={good:3,acceptable:2,poor:1,problem:0};k(M=>x[C]>x[M]?C:M),!_&&(C==="good"||C==="acceptable")&&S(!0)};return o.jsxs("div",{className:"iw-flex iw-flex-col iw-gap-1 iw-w-full",children:[o.jsxs("div",{className:"iw-flex iw-justify-center iw-items-center iw-gap-2 iw-flex-wrap iw-max-w-[700px] iw-mx-auto",children:[c&&o.jsxs("div",{className:"iw-flex sm:iw-flex-row iw-flex-col iw-gap-4 iw-w-full",children:[o.jsx(bl,{icon:td,devices:h,selectedId:f??"",onChange:C=>g&&g(C),label:"Choose mic",showVisualizer:!0,showMicHint:!0,micTested:_,audioStatus:v,stream:y,hasPermission:e,onAudioLevel:P}),o.jsx(bl,{icon:id,devices:u,selectedId:w??"",onChange:C=>p&&p(C),label:"Choose camera",hasPermission:t})]}),a&&o.jsxs("div",{className:"iw-flex iw-items-start iw-gap-3 iw-bg-[#F1F5FE] iw-rounded-xl iw-mb-1 iw-p-3 iw-pr-8 iw-border iw-border-[#c2c3c7]",children:[o.jsx("div",{className:`iw-mt-0.5 iw-h-5 iw-w-5 iw-min-w-[20px] iw-rounded iw-border iw-flex iw-items-center iw-justify-center iw-cursor-pointer iw-transition-colors ${n?"iw-bg-[#062260] iw-border-[#062260]":"iw-bg-white iw-border-[#062260]"}`,onClick:C=>{C.stopPropagation(),s(!n)},children:n&&o.jsx(xi,{className:"iw-size-3 iw-text-white"})}),o.jsx("label",{onClick:()=>s(!n),className:"iw-text-[13px] iw-text-[#062260] iw-font-medium iw-cursor-pointer iw-select-none",children:"By continuing, you acknowledge and consent to the use of your face data exclusively for interview monitoring"})]})]}),o.jsxs("div",{className:"iw-relative iw-group iw-w-full iw-max-w-[280px] iw-mx-auto iw-mt-1",children:[o.jsx(an,{onClick:i,disabled:E,className:`iw-h-12 iw-w-full iw-shadow-lg !iw-bg-[#F1F5FE] !iw-text-[#062260] !iw-font-bold !iw-border-[#E7EAF1] iw-rounded-lg ${E?"iw-opacity-50":"hover:iw-opacity-75"}`,children:b?"Device Loading...":r}),!n&&(!c||e&&t)&&yl({baseColor:m,title:"Action Required",description:"Please check the box to acknowledge and consent to continue."})]})]})},Ch=({steps:e,currentStepIndex:t})=>o.jsx("div",{className:"iw-flex iw-items-center iw-justify-center iw-gap-4 iw-w-full iw-py-2",children:e.map((r,i)=>{const n=i<t,s=i===t;return o.jsxs(d.Fragment,{children:[o.jsxs("div",{className:"iw-flex iw-items-center iw-gap-3",children:[o.jsx("div",{className:`iw-flex iw-size-9 iw-text-[#062260] iw-items-center iw-justify-center iw-rounded-full iw-font-semibold iw-border ${s||n?"iw-border-[#0EB00E] iw-bg-[#E9FFE6]":"iw-border-[#BDE0FD] iw-bg-[#E6F3FF]"}`,children:n?o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:o.jsx("polyline",{points:"20 6 9 17 4 12"})}):i+1}),o.jsx("span",{className:`iw-text-sm iw-font-medium ${s||n?"iw-text-[#062260]":"iw-text-[#5C6686]"}`,children:r.label})]}),i<e.length-1&&o.jsx("div",{className:"iw-flex-1 iw-max-w-[120px] iw-border-t iw-border-dotted iw-border-[#B3B9CB]"})]},i)})}),Th=["Don't refresh or reload the page during your assessment","Don't switch tabs or open other applications while session is ongoing","Don't leave your position during the session","Don't disable or interfere with video/audio monitoring"],Nh=({isOpen:e,onStart:t,gazeEnabled:r=!1,videoFeedRef:i,interviewId:n="",interview_duration:s=yi})=>{const{audioAllowed:a,videoAllowed:c,videoRef:l,audioDevices:h,videoDevices:u,selectedAudioDeviceId:f,selectedVideoDeviceId:w,isDeviceLoading:g,currentStream:p,handleAudioChange:y,handleVideoChange:b,stopStream:m}=Xl(e),[v,k]=d.useState(!1),[_,S]=d.useState(0),[E,P]=d.useState(!1),C=d.useRef(null),x=d.useRef(null),M=O=>{C.current=O,i&&(typeof i=="function"?i(O):i.current=O)};if(d.useEffect(()=>()=>{x.current&&(clearInterval(x.current),x.current=null)},[]),!e)return null;const[U,V]=d.useState(ke.MODEL_LOADING),q=async()=>{var R;k(!0),(R=C.current)==null||R.resetReference();const O=()=>{var be;return(be=C.current)==null?void 0:be.setReference()};O(),x.current&&clearInterval(x.current),x.current=setInterval(O,500)},D=[{label:r?"Calibrate your camera":"Camera & Mic permission"},{label:"Basic guidelines"}];return o.jsx("div",{className:"iw-fixed iw-inset-0 iw-z-50 iw-flex iw-items-center iw-justify-center iw-bg-gray-900/40 iw-backdrop-blur-sm iw-p-4 iw-pt-16 iw-overflow-auto",children:o.jsxs("div",{className:"iw-w-full iw-max-w-[700px] iw-max-h-[900px] iw-my-6 iw-bg-white iw-rounded-xl iw-shadow-2xl iw-overflow-auto",children:[o.jsxs("div",{className:"iw-px-12 iw-pt-3",children:[o.jsx("h2",{className:"iw-text-[#062260] iw-text-2xl iw-font-medium iw-tracking-tight",children:"Final checks before you go live"}),o.jsx("div",{className:"iw-mt-1 iw-bg-[#F1F5FE] iw-rounded-xl iw-p-2 iw-border iw-border-[#E7EAF1]",children:o.jsx("p",{className:"iw-text-[#5C6686] iw-text-xs iw-leading-relaxed",children:"To ensure the integrity of the interview process, this platform uses your device’s camera to monitor your face and gaze direction. We do not store any outside this session"})}),o.jsx("div",{className:"iw-mt-3 iw-border-b iw-border-dashed iw-border-[#B3B9CB] iw-w-full"}),o.jsx(Ch,{steps:D,currentStepIndex:_})]}),o.jsx("div",{className:"iw-px-12 iw-pb-3 iw-flex iw-flex-col iw-items-center",children:_===0?o.jsxs("div",{className:"iw-w-full iw-flex iw-flex-col iw-items-center iw-gap-4",children:[o.jsx("div",{className:"iw-w-full iw-max-w-[600px] iw-aspect-video iw-bg-slate-100 iw-rounded-2xl iw-overflow-hidden iw-relative iw-border iw-border-slate-200",children:r?o.jsx(ml,{ref:M,interviewId:n,interview_duration:s,showProctoringUI:!1,showStatusOverlay:!g&&c,isDeviceLoading:g,videoAllowed:c,onProctoringStatusChange:V,onSetReference:()=>{x.current&&(clearInterval(x.current),x.current=null),k(!1),S(1)}}):o.jsx("video",{ref:l,autoPlay:!0,playsInline:!0,muted:!0,className:"iw-w-full iw-h-full iw-object-cover",style:{transform:"scaleX(-1)"}})}),o.jsx(vl,{micEnabled:a,videoEnabled:c,buttonText:r?v?"Calibrating...":U==="model_loading"?"Initialising...":"Start calibrate":"Next",onButtonClick:()=>{r?q():S(1)},disabled:!E||r&&U!=="face_detected"||!r&&(!a||!c),isAgreed:E,onAgreedToggle:P,audioDevices:h,videoDevices:u,selectedAudioId:f,selectedVideoId:w,onAudioChange:y,onVideoChange:b,audioStream:p,isDeviceLoading:g})]}):o.jsxs("div",{className:"iw-w-full iw-flex iw-flex-col iw-gap-6",children:[o.jsx("div",{className:"iw-w-full iw-bg-[#F8FAFF] iw-rounded-2xl iw-p-8 iw-flex iw-flex-col iw-gap-5",children:Th.map((O,R)=>o.jsxs("div",{className:"iw-flex iw-items-center iw-gap-4",children:[o.jsx("div",{className:"iw-flex iw-h-7 iw-w-7 iw-min-w-[28px] iw-items-center iw-justify-center iw-rounded-full iw-bg-[#DBEAFE] iw-text-[#062260] iw-text-xs iw-font-bold",children:R+1}),o.jsx("span",{className:"iw-text-[#5C6686] iw-font-medium",children:O})]},R))}),o.jsx(vl,{buttonText:"Start interview",onButtonClick:()=>{t(),m()},isAgreed:E,onAgreedToggle:P,showMediaIcons:!1})]})})]})})},cn=e=>{const{baseColor:t,borderRadius:r}=Rt(),{loading:i,children:n,...s}=e;return o.jsx(an,{style:{background:Hl(t),borderRadius:r},...s,children:i?o.jsx(so,{}):n})},Ih=({question:e,isLoading:t=!1,phase:r,brandName:i,brandLogo:n})=>o.jsx("div",{className:"iw-rounded-xl iw-mb-4 message-animation iw-text-gray-800 iw-py-1",children:o.jsxs("div",{className:"iw-flex iw-items-center iw-gap-4",children:[o.jsx("div",{className:`iw-flex iw-flex-col iw-items-center iw-justify-center iw-relative iw-h-16 iw-w-16 iw-shrink-0 iw-shadow iw-rounded-full iw-border-[#E8EEFE] iw-border-4 ${r===G.READING_QUESTION?"iw-animate-speaking":""}`,children:o.jsx("div",{className:"iw-bg-transparent iw-flex iw-items-center iw-justify-center iw-rounded-full iw-size-full",style:{backgroundImage:"linear-gradient(#B5D0FD, #FFFFFF)"},children:o.jsx(vn,{brandLogo:n,brandName:i})})}),o.jsx(Fh,{phase:r,question:e,isLoading:t,brandName:i})]})}),Fh=({phase:e,question:t,isLoading:r,brandName:i})=>{const n=i||"We",s=i?"is":"are";if(r||e===G.FETCHING_QUESTION||e===G.IDLE)return o.jsxs("div",{className:"iw-animate-pulse iw-w-full iw-space-y-3 iw-mr-10",children:[o.jsx("div",{className:"iw-h-5 iw-bg-gray-200 iw-rounded iw-w-full"}),o.jsx("div",{className:"iw-h-5 iw-bg-gray-200 iw-rounded iw-w-3/4"})]});const a=()=>o.jsxs("span",{className:"iw-animate-dot-wave iw-ml-1",children:[o.jsx("span",{children:"."}),o.jsx("span",{children:"."}),o.jsx("span",{children:"."})]});switch(e){case G.ANSWERING:return o.jsx("div",{className:"iw-flex iw-items-center iw-justify-between iw-w-full",children:o.jsxs("p",{className:"iw-text-lg iw-leading-7 iw-font-medium iw-text-gray-600",children:["Listening",o.jsx(a,{})]})});case G.TRANSCRIBING:return o.jsxs("p",{className:"iw-text-lg iw-leading-7 iw-font-medium iw-text-gray-600",children:[n," ",s," analyzing your answer",o.jsx(a,{})]});case(G.EDITING||G.SUBMITTING):return o.jsxs("p",{className:"iw-text-lg iw-leading-7 iw-font-medium iw-text-gray-600",children:[n," ",s," waiting for your answer..."]});default:return o.jsx("p",{className:"iw-text-lg iw-leading-7",children:t==null?void 0:t.question})}},Lh=(e,t,r)=>Math.max(t,Math.min(r,e)),xl=e=>{const t=Math.max(0,Math.floor(e)),r=Math.floor(t/60).toString().padStart(2,"0"),i=(t%60).toString().padStart(2,"0");return`${r}:${i}`},ln=({total:e,remaining:t,size:r=64,strokeWidth:i=6,className:n="",showLabel:s=!0})=>{const a=Math.max(1,e||1),c=Lh(t/a,0,1),{radius:l,circumference:h,dashOffset:u,center:f}=d.useMemo(()=>{const p=(r-i)/2,y=2*Math.PI*p,b=y*(1-c),m=Math.round(i)%2===1,v=r/2+(m?.5:0);return{radius:p,circumference:y,dashOffset:b,center:v}},[r,i,c]),w=d.useMemo(()=>c<=.25?"iw-stroke-red-500":c<=.5?"iw-stroke-yellow-500":"iw-stroke-green-500",[c]),g=c<=.25?"iw-animate-pulse":"";return o.jsxs("div",{className:`iw-relative iw-inline-flex iw-items-center iw-justify-center iw-rounded-full iw-bg-white ${n}`,style:{width:r,height:r},"aria-label":`Time remaining ${xl(t)}`,role:"timer","aria-live":"polite",children:[o.jsx("svg",{width:r,height:r,viewBox:`0 0 ${r} ${r}`,preserveAspectRatio:"xMidYMid meet",children:o.jsxs("g",{transform:`rotate(-90 ${f} ${f})`,children:[o.jsx("circle",{cx:f,cy:f,r:l,className:"iw-stroke-gray-200",strokeWidth:i,fill:"none",shapeRendering:"geometricPrecision",vectorEffect:"non-scaling-stroke"}),o.jsx("circle",{cx:f,cy:f,r:l,className:`${w} ${g}`,strokeWidth:i,strokeLinecap:"round",fill:"none",strokeDasharray:h,strokeDashoffset:u,shapeRendering:"geometricPrecision",vectorEffect:"non-scaling-stroke",style:{transition:"stroke-dashoffset 0.3s ease, stroke 0.2s ease"}})]})}),s?o.jsx("div",{className:"iw-absolute iw-inset-0 iw-flex iw-items-center iw-justify-center iw-rotate-0",children:o.jsx("span",{className:`iw-text-[11px] iw-font-semibold iw-tabular-nums ${c<=.25?"iw-text-red-600":c<=.5?"iw-text-yellow-600":"iw-text-green-600"}`,children:xl(t)})}):o.jsx("div",{className:"iw-absolute iw-inset-0 iw-flex iw-items-center iw-justify-center iw-rotate-0",children:o.jsx(ed,{})})]})},Mh=({label:e,error:t,fullWidth:r=!1,className:i="",id:n,...s})=>{const a=n||`textarea-${Math.random().toString(36).substring(2,9)}`,c="iw-block iw-rounded-md iw-border iw-border-gray-300 iw-shadow-sm iw-px-4 iw-py-2 iw-text-sm iw-transition-all",l=t?"iw-border-red-500 iw-focus:border-red-500 iw-focus:ring-red-500":"",h=r?"iw-w-full":"",u=i.includes("iw-h-full")||r?"iw-h-full":"";return o.jsxs("div",{className:`iw-h-full iw-flex iw-flex-col ${r?"iw-w-full":""}`,children:[e&&o.jsx("label",{htmlFor:a,className:"iw-block iw-text-sm iw-font-medium iw-text-gray-700 iw-mb-1",children:e}),o.jsx("textarea",{id:a,className:`${c} ${l} ${h} ${u} ${i}`,"aria-invalid":t?"true":"false",...s}),t&&o.jsx("p",{className:"iw-mt-1 iw-text-sm iw-text-red-600",children:t})]})},Dh=({answerText:e,onAnswerChange:t,timerState:r,editingTime:i})=>o.jsxs("div",{className:"iw-w-full iw-bg-white iw-rounded-xl iw-border iw-border-[#84bbf5] iw-overflow-hidden iw-rounded-tr-none",children:[o.jsx("div",{className:"iw-p-2 iw-pb-0",children:o.jsx(Mh,{value:e,onChange:t,placeholder:"Type your answer here...",className:"iw-w-full iw-h-64 iw-resize-none iw-bg-transparent iw-border-none iw-text-[#062260] iw-text-base iw-leading-relaxed focus-visible:iw-outline-0 iw-p-0",disabled:r.phase===G.SUBMITTING})}),o.jsxs("div",{className:"iw-bg-[#F1F5FE] iw-px-2 iw-py-2 iw-flex iw-items-center iw-justify-between iw-border-t iw-border-[#E8EEFE]",children:[o.jsx("span",{className:"iw-text-[#062260] iw-text-sm iw-font-medium iw-line-clamp-1",children:"Time left to edit answer"}),o.jsxs("div",{className:"iw-flex iw-items-center iw-gap-2",children:[o.jsx(ln,{total:i,remaining:r.currentPhaseTimeRemaining,size:32,strokeWidth:3,showLabel:!1}),o.jsx("span",{className:"iw-text-[#062260] iw-text-sm iw-font-bold",children:`${bn(r.currentPhaseTimeRemaining,!0)}${r.currentPhaseTimeRemaining>=60?" min":" sec"}`})]})]})]}),El=({children:e})=>o.jsx("div",{className:"iw-flex iw-flex-col iw-items-start iw-mt-3 iw-gap-1",children:e}),Ph=({questionNumber:e})=>o.jsxs("div",{className:"iw-px-4 iw-py-1.5 iw-rounded-full iw-mb-2 iw-text-sm iw-font-semibold",style:{color:"#062260",backgroundColor:"#E6F3FF",border:"1px solid #BDE0FD"},children:[" Q",e]}),Oh=({label:e})=>o.jsxs("div",{className:"iw-flex iw-items-center iw-gap-2 iw-text-sm iw-text-gray-500 iw-bg-[#F1F5FE] iw-px-4 iw-py-1.5 iw-rounded-full iw-my-2 iw-font-semibold",children:[e&&o.jsx("span",{className:"iw-font-medium",children:e}),o.jsxs("span",{className:"iw-animate-dot-wave iw-text-2xl",children:[o.jsx("span",{children:"."}),o.jsx("span",{children:"."}),o.jsx("span",{children:"."})]})]}),Bh=({timerState:e,answeringTime:t})=>{const r=(e==null?void 0:e.currentPhaseTimeRemaining)||0,i=t||gl.answeringDuration;return o.jsxs("div",{className:"iw-flex iw-w-full iw-items-center iw-justify-between iw-gap-3 iw-bg-[#E6F3FF] iw-p-2 iw-rounded-lg",children:[o.jsx("span",{className:"iw-text-[#062260]",children:"Time left to answer"}),o.jsxs("div",{className:"iw-flex iw-items-center iw-gap-2",children:[o.jsxs("span",{className:"iw-text-xl iw-font-bold iw-text-[#062260]",children:[bn(r,!0),r>=60?" min":" sec"]}),o.jsx(ln,{total:i,remaining:r,size:35,strokeWidth:4,showLabel:!1,className:"iw-shadow-sm iw-border iw-border-gray-100"})]})]})},Uh=()=>{const e=d.useRef(null),t=d.useRef(null);return d.useEffect(()=>{const r=e.current;if(!r)return;const i=r.getContext("2d");if(!i)return;let n=null,s=null,a=null,c;const l=()=>{const h=Nr.activeStream;if(!h||!h.active){c=requestAnimationFrame(l);return}const u=window.AudioContext||window.webkitAudioContext;n=new u,s=n.createAnalyser(),s.fftSize=256,s.smoothingTimeConstant=.9,a=n.createMediaStreamSource(h),a.connect(s);const f=s.frequencyBinCount,w=new Uint8Array(f),g=new Float32Array(f),p=.2,y=()=>{if(t.current){const x=t.current.clientWidth-32;r.width!==x&&x>0&&(r.width=x)}const b=r.width,m=r.height;i.clearRect(0,0,b,m),s.getByteFrequencyData(w);for(let x=0;x<f;x++){const M=g[x]||0,U=w[x]||0;g[x]=M*p+U*(1-p)}const v=3,k=2,_=Math.floor(b/(v+k)),S=_>0?_%2===0?_-1:_:0;if(S<=0){c=requestAnimationFrame(y);return}const E=(b-S*(v+k))/2,P=Math.floor(S/2);i.fillStyle="#27ba71";const C=38;for(let x=0;x<S;x++){const M=Math.abs(x-P),U=P>0?M/P:0,V=2+Math.floor(Math.pow(U,1.5)*C);let q=g[Math.min(V,f-1)]||0;q=q/255,q=Math.pow(q,2.2);const D=1-U*.8,O=1.5,R=q>.05?Math.sin(Date.now()/300+x)*.5*D:0,be=q*(m-8)*D,ze=Math.max(O,be+R),ft=E+x*(v+k),We=(m-ze)/2;i.beginPath(),i.roundRect(ft,We,v,ze,v/2),i.fill()}c=requestAnimationFrame(y)};y()};return l(),()=>{cancelAnimationFrame(c),a&&a.disconnect(),s&&s.disconnect(),n&&n.state!=="closed"&&n.close()}},[]),o.jsxs("div",{className:"iw-flex iw-flex-col iw-items-end iw-w-full iw-mt-4",children:[o.jsx("div",{className:"iw-px-4 iw-py-1.5 iw-rounded-full iw-mb-2 iw-text-sm iw-font-semibold",style:{color:"#062260",backgroundColor:"#F2E8FE",border:"1px solid #E9D5FF"},children:"You"}),o.jsx("div",{ref:t,className:"iw-w-full iw-p-4 iw-rounded-xl iw-rounded-tr-none iw-flex iw-items-center iw-justify-center",style:{backgroundColor:"#F7F1FE",minHeight:"80px"},children:o.jsx("canvas",{ref:e,height:40,className:"iw-block"})})]})},Vh=({phase:e,questionNumber:t,timerState:r})=>{const{timers:i}=Gr();switch(e){case G.FETCHING_QUESTION:return o.jsxs(El,{children:[o.jsx(Ph,{questionNumber:t+1}),o.jsx(Oh,{})]});case G.ANSWERING:return o.jsxs("div",{className:"iw-flex iw-flex-col iw-items-end iw-w-full",children:[o.jsx(Uh,{}),o.jsx("div",{className:"iw-mt-2 iw-w-full",children:o.jsx(Bh,{timerState:r,answeringTime:i==null?void 0:i.answeringDuration})})]});case G.TRANSCRIBING:return o.jsx(El,{children:o.jsxs("div",{className:"iw-flex iw-items-center iw-px-1 iw-py-1.5 iw-rounded-lg iw-mb-2 iw-text-sm iw-bg-[#F2E8FE]",children:[o.jsx("div",{className:"iw-h-8 iw-w-12 iw-transcribing-icon"}),o.jsx("span",{className:"iw-text-sm iw-text-[#062260]",children:"Analyzing answer…"})]})});default:return null}},Gh=({item:e,index:t,isCurrentQuestion:r=!1,isEditable:i=!1,answerText:n="",onAnswerChange:s,timerState:a,editingTime:c})=>{const l=i&&a&&c!==void 0,h=l||e.answer!=null;return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"iw-flex iw-flex-col iw-items-start",children:[o.jsxs("div",{className:"iw-px-4 iw-py-1.5 iw-rounded-full iw-mb-2 iw-text-sm iw-font-semibold",style:{color:"#062260",backgroundColor:"#E6F3FF",border:"1px solid #BDE0FD"},children:["Q",t+1]}),o.jsx("div",{className:"iw-w-full iw-p-4 iw-rounded-xl iw-text-[#062260] iw-text-base iw-leading-relaxed iw-rounded-tl-none",style:{backgroundColor:"#F1F5FE",border:r?"2px solid #84bbf5":"1px solid transparent"},children:e.question})]}),h&&o.jsxs("div",{className:"iw-flex iw-flex-col iw-items-end iw-mt-4",children:[o.jsx("div",{className:"iw-px-4 iw-py-1.5 iw-rounded-full iw-mb-2 iw-text-sm iw-font-semibold",style:{color:"#062260",backgroundColor:"#F2E8FE",border:"1px solid #E9D5FF"},children:"You"}),l?o.jsx(Dh,{answerText:n||"",onAnswerChange:s,timerState:a,editingTime:c}):o.jsx("div",{className:"iw-w-full iw-p-4 iw-rounded-xl iw-text-[#062260] iw-text-base iw-leading-relaxed iw-rounded-tr-none",style:{backgroundColor:"#F7F1FE"},children:e.answer?e.answer:o.jsx("span",{className:"iw-italic iw-text-[#062260]/60",children:"No response"})})]}),r&&o.jsx(Vh,{phase:a==null?void 0:a.phase,questionNumber:t+1,timerState:a})]})},jh=()=>o.jsx("div",{className:"iw-space-y-6 iw-animate-pulse",children:[1,2,3].map(e=>o.jsxs("div",{className:`iw-flex iw-flex-col ${e%2===0?"iw-items-end":"iw-items-start"} iw-gap-2`,children:[o.jsx("div",{className:"iw-h-8 iw-w-16 iw-bg-gray-200 iw-rounded-full"}),o.jsx("div",{className:"iw-h-24 iw-w-full iw-bg-gray-100 iw-rounded-xl"})]},e))}),$h=({transcript:e,isLoading:t,className:r="",bottomRef:i,isEditing:n,answerText:s,onAnswerChange:a,timerState:c,editingTime:l})=>o.jsxs("div",{className:`iw-h-full iw-flex iw-flex-col iw-bg-white iw-scroll-smooth iw-p-6 iw-pr-2 iw-min-w-32 iw-border iw-rounded-tr-2xl iw-rounded-br-2xl iw-border-[#E8EEFE] ${r}`,children:[o.jsxs("div",{className:"iw-mb-6",children:[o.jsx("h2",{className:"iw-text-lg iw-font-semibold iw-mb-4",style:{color:"#062260"},children:"Interview transcript"}),o.jsx("div",{className:"iw-h-px iw-w-full iw-border-t iw-border-dashed iw-border-gray-300"})]}),o.jsxs("div",{className:"iw-flex-1 iw-overflow-y-auto iw-pr-2 iw-space-y-6 iw-scrollbar-thin iw-max-w-xl iw-pb-5",children:[t?o.jsx(jh,{}):e==null?void 0:e.map((h,u)=>o.jsx(Gh,{item:h,index:u,isCurrentQuestion:u===(e==null?void 0:e.length)-1,isEditable:!!(u===(e==null?void 0:e.length)-1&&n),answerText:s,onAnswerChange:a||(()=>{}),timerState:c,editingTime:l},h.qna_id)),o.jsx("div",{ref:i})]})]}),zh=({interviewId:e,className:t="",currentQuestion:r,lastSubmittedAnswer:i,isEditing:n,answerText:s,onAnswerChange:a,timerState:c,editingTime:l})=>{const h=Hs(),[u,f]=d.useState([]),[w,g]=d.useState(!0),p=d.useRef(null);return d.useEffect(()=>{var y;(y=p.current)==null||y.scrollIntoView({behavior:"smooth"})},[u,s,c==null?void 0:c.phase]),d.useEffect(()=>{(async()=>{var b;try{const m=await h.getInterviewTranscription(e);f(((b=m==null?void 0:m.data)==null?void 0:b.transcript)||[])}catch(m){console.error("Failed to fetch transcript:",m)}finally{g(!1)}})()},[e,h]),d.useEffect(()=>{r&&f(y=>{if(y.some(v=>v.qna_id===r.qna_id))return y;const m={qna_id:r.qna_id,question:r.question,answer:null,question_generated_at:new Date().toISOString(),answer_submitted_at:null};return[...y,m]})},[r]),d.useEffect(()=>{i?f(y=>y.map(b=>b.qna_id===i.qnaId?{...b,answer:i.answer,answer_submitted_at:new Date().toISOString()}:b)):s&&f(y=>y.map(b=>b.qna_id===(i==null?void 0:i.qnaId)?{...b,answer:s,answer_submitted_at:new Date().toISOString()}:b))},[i,s]),o.jsx($h,{transcript:u,isLoading:w||(u==null?void 0:u.length)===0,className:t,bottomRef:p,isEditing:n,answerText:s,onAnswerChange:a,timerState:c,editingTime:l})},Ks=5,Ys=5;function Wh({isOpen:e,onClose:t,warningCount:r,violationType:i,onDisqualify:n}){const[,s]=d.useState(Ys),a=d.useRef(t),c=d.useRef(n),l=d.useRef(r);if(d.useEffect(()=>{a.current=t,c.current=n,l.current=r},[t,n,r]),d.useEffect(()=>{if(!e)return;const w=setInterval(()=>{s(g=>g<=1?(l.current+1>Ks?c.current():a.current(),Ys):g-1)},1e3);return()=>clearInterval(w)},[e]),d.useEffect(()=>{e&&s(Ys)},[e]),!e)return null;const h=()=>{switch(i){case"tab_switch":return"Attempted tab switch/reload";case"fullscreen_exit":return"Attempted to exit full screen mode";case"focus_loss":return"Lost focus from interview window";case"blocked_shortcut":return"Used a blocked keyboard shortcut";case"right_click_attempt":return"Attempted right click";case"alt_tab_attempt":return"Attempted Alt + Tab";case"blocked_function_key":return"Attempted to use function key";default:return"Attempted right click/tab switch"}},u=Ks-r,f=()=>{r+1>Ks?n():t()};return o.jsx("div",{className:"iw-absolute iw-bottom-20 iw-left-4 iw-right-4 md:iw-right-auto md:iw-w-[480px] iw-z-50 iw-animate-in iw-fade-in iw-slide-in-from-bottom-4 iw-duration-300",children:o.jsxs("div",{className:"iw-relative iw-overflow-hidden iw-rounded-xl iw-border iw-border-dashed iw-border-[#E94315] iw-bg-[#FFEBE6] iw-p-4 iw-shadow-2xl iw-backdrop-blur-sm",children:[o.jsx("button",{onClick:f,className:"iw-absolute iw-right-3 iw-top-3 iw-text-gray-400 iw-transition-colors iw-hover:iw-text-gray-600",children:o.jsx(Ei,{className:"iw-h-5 iw-w-5"})}),o.jsxs("div",{className:"iw-flex iw-items-start iw-gap-3",children:[o.jsx("div",{className:"iw-flex iw-h-10 iw-w-10 iw-flex-shrink-0 iw-items-center iw-justify-center iw-rounded-full iw-border iw-border-[#FDCBBD]",children:o.jsx(vi,{className:"iw-h-5 iw-w-5 iw-text-red-500"})}),o.jsxs("div",{className:"iw-flex-1 iw-pt-0.5",children:[o.jsxs("h2",{className:"iw-text-[20px] iw-font-semibold iw-leading-tight iw-text-[#E94315]",children:["You have ",u>0?u:0," warning",u>1?"s":""," left"]}),o.jsx("p",{className:"iw-mt-1.5 iw-text-lg iw-text-[#5C6686]",children:h()}),o.jsx("div",{className:"iw-mt-3 iw-border-t iw-border-dashed iw-border-red-200 iw-pt-3",children:u===1?o.jsx("p",{className:"iw-text-[14px] iw-font-bold iw-text-[#062260]",children:"Next violation will disqualify you from this interview and automatically end the interview"}):o.jsx("p",{className:"iw-text-[14px] iw-font-bold iw-text-[#062260]",children:"Interview will end automatically after final warning"})})]})]})]})})}const Hh=e=>o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...e,children:[o.jsx("path",{d:"M9 9.003a1 1 0 0 1 1.517-.859l4.997 2.997a1 1 0 0 1 0 1.718l-4.997 2.997A1 1 0 0 1 9 14.996z"}),o.jsx("circle",{cx:"12",cy:"12",r:"10"})]}),_l=({isOpen:e,onClose:t,children:r,title:i,showCloseButton:n=!0,closeOnOverlayClick:s=!0,closeOnEscape:a=!0,className:c=""})=>{if(d.useEffect(()=>{if(!e||!a)return;const u=f=>{f.key==="Escape"&&t()};return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[e,a,t]),d.useEffect(()=>(e?(document.body.style.overflow="hidden",document.body.classList.add("interview-widget-container")):(document.body.style.overflow="unset",document.body.classList.remove("interview-widget-container")),()=>{document.body.style.overflow="unset",document.body.classList.remove("interview-widget-container")}),[e]),!e)return null;const l=u=>{s&&u.target===u.currentTarget&&t()},h=o.jsxs("div",{className:"interview-widget-container",style:{position:"fixed",inset:0,zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center"},children:[o.jsx("div",{style:{position:"fixed",inset:0,backgroundColor:"rgba(0, 0, 0, 0.5)",transition:"opacity 0.2s"},onClick:l}),o.jsxs("div",{className:`iw-relative iw-bg-white iw-rounded-lg iw-shadow-xl iw-max-w-md iw-w-full iw-mx-4 iw-max-h-[90vh] iw-overflow-hidden ${c}`,role:"dialog","aria-modal":"true","aria-labelledby":i?"standalone-dialog-title":void 0,style:{zIndex:1e4},children:[(i||n)&&o.jsxs("div",{className:"iw-flex iw-items-center iw-justify-between iw-p-4 iw-border-b iw-border-gray-200",children:[i&&o.jsx("h2",{id:"standalone-dialog-title",className:"iw-text-lg iw-font-semibold iw-text-gray-900",children:i}),n&&o.jsx("button",{onClick:t,className:"iw-p-1 iw-text-gray-400 iw-hover:text-gray-600 iw-transition-colors iw-rounded iw-hover:bg-gray-100","aria-label":"Close dialog",children:o.jsx("svg",{className:"iw-w-5 iw-h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),o.jsx("div",{className:"iw-p-4 iw-overflow-y-auto",children:r})]})]});return Tl.createPortal(h,document.body)},qh=({showHardReloadWarning:e,onContinue:t})=>{const r=()=>{t()};return o.jsxs(_l,{isOpen:e,onClose:r,closeOnOverlayClick:!1,closeOnEscape:!1,showCloseButton:!1,className:"iw-max-w-lg iw-px-2 iw-rounded-xl",children:[o.jsx("div",{className:"iw-absolute iw-inset-x-0 iw-top-0 iw-h-1 iw-bg-gradient-to-r iw-from-red-500 iw-to-red-600"}),o.jsx("div",{className:"iw-space-y-1 iw-pb-2 iw-pt-3",children:o.jsxs("div",{className:"iw-flex iw-items-center iw-gap-2",children:[o.jsx(vi,{className:"iw-w-5 iw-h-5 iw-text-red-500"}),o.jsx("h3",{className:"iw-text-xl iw-font-semibold iw-text-red-500",children:"Full Screen Exit Detected"})]})}),o.jsx("div",{className:"iw-pt-4 iw-pb-6",children:o.jsx("p",{className:"iw-text-center iw-text-sm iw-leading-relaxed iw-text-gray-500/90",children:"Exiting full screen mode or reloading this page during the session is strictly prohibited. Any attempt to do so will be recorded and may lead to penalties."})}),o.jsx("div",{className:"iw-pt-2 iw-pb-4",children:o.jsxs("button",{onClick:r,className:"iw-w-full iw-flex iw-items-center iw-justify-center iw-gap-2 iw-px-4 iw-py-3 iw-bg-gray-100 iw-text-gray-600 iw-rounded-md iw-font-medium iw-transition-colors hover:iw-bg-gray-200 focus:iw-outline-none focus:iw-ring-2 focus:iw-ring-gray-400 focus:iw-ring-offset-2",children:[o.jsx(Hh,{className:"iw-size-4"}),"Continue Session"]})})]})},kl=({confirmExitInterview:e,isOpen:t,onClose:r})=>o.jsxs(_l,{isOpen:t,onClose:r,showCloseButton:!1,closeOnOverlayClick:!1,className:"iw-max-w-xl iw-border-2 iw-border-dashed iw-rounded-xl iw-border-[#6296FB]",children:[o.jsxs("div",{className:"iw-p-4",children:[o.jsx("h2",{className:"iw-text-xl iw-font-semibold iw-text-[#062260]",children:"Are you sure you want to leave interview?"}),o.jsx("p",{className:"iw-mt-2 iw-text-[#667085] iw-line-clamp-2",children:"If you exit now, the interview will be terminated and cannot be resumed."})]}),o.jsx("div",{className:"iw-my-0 iw-h-px iw-m-6 iw-border-t iw-border-dashed iw-border-[#B3B9CB]"}),o.jsxs("div",{className:"iw-flex iw-justify-center iw-gap-4 iw-p-4",children:[o.jsx(an,{className:"iw-px-8 iw-py-3 iw-rounded-xl !iw-bg-[#E94315] !iw-text-white !iw-font-bold !iw-shadow-md !hover:iw-opacity-70",onClick:e,children:"Leave"}),o.jsx(an,{onClick:r,className:"iw-px-6 iw-py-3 iw-rounded-xl !iw-bg-[#F1F5FE] !iw-text-[#062260] !iw-font-bold !iw-border !iw-border-[#E7EAF1] !iw-shadow-md hover:iw-opacity-70",children:"Stay in Interview"})]})]}),Sl=d.createContext(null),Kh=()=>{const e=d.useContext(Sl);return e||{violationCount:0,violationType:"fullscreen_exit",showWarningModal:!1,setShowWarningModal:()=>{},handleClose:()=>{},handleDisqualify:()=>{},handleUnintendedExit:()=>{}}},Yh=d.forwardRef(({children:e,onDisqualify:t,onExit:r,isCompleted:i},n)=>{const[s,a]=d.useState(!1),[c,l]=d.useState(!1),[h,u]=d.useState(!1),[f,w]=d.useState(!1),[g,p]=d.useState("fullscreen_exit"),{logViolation:y,violationCount:b}=Eh({maxViolations:5,onViolation:x=>{!h&&!i&&!f&&(a(!0),p(x.type))}}),{enterFullScreen:m,isFullScreen:v,exitFullScreen:k}=hh({onFullScreenChange(x){!x&&!h&&!f&&!i&&(a(!0),y({type:"fullscreen_exit",severity:"high",details:{action:"fullscreen_exit",reason:"Attempted to exit full screen mode"}})),x&&w(!1)}});d.useEffect(()=>{m()},[]),d.useImperativeHandle(n,()=>({exitFullScreenIntentionally:async()=>{w(!0),a(!1),u(!1);try{document.fullscreenElement&&await document.exitFullscreen()}catch(x){console.error("Failed to exit fullscreen:",x)}}}),[]),ph(y),wh(y),mh(),_h();const{proctoring:_}=Gr(),S=(_==null?void 0:_.prevent_unintended_exit)??!1,E=d.useCallback(()=>{var x,M;qs.stop(),wl.dispose(),(M=(x=Nr.activeStream)==null?void 0:x.getTracks())==null||M.forEach(U=>U.stop())},[]);d.useEffect(()=>{const x=()=>{if(!(h||f||i)){if(S)l(!0);else if(window.confirm("Leave site? Changes you made may not be saved.")){E();return}window.history.pushState(null,"",window.location.href)}},M=V=>{if(!(h||f||i))return console.log("User attempted to reload or close the tab"),S&&l(!0),V.preventDefault(),V.returnValue="",""},U=()=>{f||E()};return window.history.pushState(null,"",window.location.href),window.addEventListener("popstate",x),window.addEventListener("beforeunload",M),window.addEventListener("unload",U),()=>{window.removeEventListener("popstate",x),window.removeEventListener("beforeunload",M),window.removeEventListener("unload",U)}},[h,f,i,S,E]);const P=()=>{E(),u(!0),k(),a(!1),l(!1),t==null||t()},C=()=>{E(),l(!1),r==null||r()};return o.jsxs(Sl.Provider,{value:{violationCount:b,violationType:g,showWarningModal:s,setShowWarningModal:a,handleClose:()=>{a(!1),m()},handleDisqualify:P,handleUnintendedExit:()=>{l(!0)}},children:[o.jsx("div",{className:"iw-relative iw-h-full iw-w-full",children:e}),o.jsx(kl,{isOpen:c,onClose:()=>{l(!1)},confirmExitInterview:()=>{C()}}),!v&&b>0&&!h&&!f&&o.jsx(qh,{showHardReloadWarning:!0,logViolation:y,onContinue:m})]})}),Xh=({onClick:e,text:t="Submit response",disabled:r=!1,isFirstQuestion:i=!1})=>(d.useEffect(()=>{if(typeof window>"u")return;const n=s=>{const a=s.key==="Enter",c=s.target;if(!(c.tagName==="INPUT"||c.isContentEditable)&&a){if(r)return;s.preventDefault(),e()}};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[e,r]),o.jsxs("div",{className:"iw-fixed iw-bottom-10 iw-left-1/4 iw-transform iw--translate-x-1/2 iw-z-50",children:[i&&o.jsxs("div",{className:"iw-absolute iw-bottom-full iw-left-0 iw-transform iw--translate-x-1/2 iw-mb-3 iw-px-3 iw-py-2 iw-border iw-border-[#ecedee] iw-bg-[#ecedee] iw-text-black iw-text-[12px] iw-rounded-lg iw-whitespace-nowrap iw-animate-bounce iw-shadow-xl",children:["You can click here to submit your response",o.jsx("div",{className:"iw-absolute iw-top-full iw-left-1/2 iw-transform iw--translate-x-1/2 iw-border-8 iw-border-transparent iw-border-t-[#ecedee]"})]}),o.jsxs("button",{disabled:r,onClick:e,className:`iw-flex iw-items-center iw-gap-3 iw-text-white iw-px-5 iw-py-3 iw-rounded-lg iw-shadow-lg iw-transition-all iw-duration-200 iw-group ${r?"iw-bg-[#4C6CFF]/60 iw-cursor-not-allowed":"iw-bg-[#4C6CFF] hover:iw-bg-[#4c6dffd5]"} ${i?"iw-animate-speaking iw-ring-4 iw-ring-[#4C6CFF]/30 iw-scale-105":""}`,children:[o.jsx("span",{className:"iw-font-semibold iw-text-sm",children:t}),o.jsx("span",{className:"iw-bg-white/90 iw-text-[#062260] iw-px-2 iw-py-1 iw-rounded iw-text-xs iw-font-mono iw-font-bold group-hover:iw-bg-white iw-transition-colors",children:"Press Enter"})]})]})),Qh=({brandName:e,brandLogo:t,currentQuestion:r,state:i,phase:n,className:s="",interviewId:a="",interview_duration:c=yi,videoFeedRef:l,lastSubmittedAnswer:h,onNextPhase:u,answerText:f,onAnswerChange:w,editingTime:g,disableSubmitButton:p=!1})=>{const{showWarningModal:y,violationCount:b,violationType:m,handleClose:v,handleDisqualify:k}=Kh();return o.jsxs("div",{className:`iw-px-4 iw-py-3 ${s} iw-h-[calc(100vh_-_120px)] iw-max-h-[calc(100vh_-_120px)] iw-flex iw-gap-0 iw-relative`,children:[o.jsxs("div",{className:"iw-flex iw-flex-col iw-flex-1 iw-p-5 iw-bg-white/50 iw-border iw-border-[#E8EEFE] iw-rounded-s-3xl iw-overflow-hidden",children:[o.jsx("div",{className:"iw-flex iw-items-start iw-justify-between iw-gap-3 iw-mb-4",children:o.jsx("div",{className:"iw-flex-1",children:o.jsx(Ih,{question:r,isLoading:n===G.FETCHING_QUESTION||n===G.IDLE,phase:n,brandName:e,brandLogo:t})})}),o.jsxs("div",{className:"iw-flex-1 iw-min-h-0 iw-rounded-[16px] iw-overflow-hidden iw-relative",children:[o.jsx(ml,{ref:l,interviewId:a,interview_duration:c,isAnswering:n===G.ANSWERING,cheatingWarningVisible:y}),o.jsx(Wh,{isOpen:y,warningCount:b,violationType:m,onClose:v,onDisqualify:k})]})]}),o.jsx("div",{className:"iw-interview-transcription iw-w-1/4 iw-min-w-32 iw-h-full",children:o.jsx(zh,{interviewId:a,currentQuestion:r,lastSubmittedAnswer:h,isEditing:n===G.EDITING,answerText:f,onAnswerChange:w,timerState:i,editingTime:g})}),u&&(n===G.ANSWERING||n===G.EDITING)&&o.jsx(Xh,{onClick:u,disabled:p,isFirstQuestion:(i==null?void 0:i.currentQuestionNumber)===1,text:n===G.ANSWERING?"Submit Response":"Submit Final Response"})]})},Jh=({title:e,brandName:t,brandLogo:r,onExit:i,totalDuration:n=30,elapsedTime:s=0})=>{const[a,c]=d.useState(!1),l=Math.min(s/(n*60)*100,100),h=()=>o.jsxs("div",{className:"iw-px-4 iw-pb-2 iw-flex iw-items-center iw-gap-3",children:[o.jsx("div",{className:"iw-flex-1 iw-h-4 iw-bg-[#F2F4F7] iw-rounded-full iw-overflow-hidden iw-border iw-border-blue-100 iw-relative",children:o.jsx("div",{className:"iw-h-full iw-bg-[#0EB00E] iw-rounded-full iw-transition-all iw-duration-1000 iw-ease-linear",style:{width:`${l}%`}})}),o.jsxs("div",{className:"iw-text-sm iw-font-medium iw-whitespace-nowrap",children:[o.jsx("span",{className:"iw-text-[#062260]",children:bn(s)}),o.jsxs("span",{className:"iw-text-[#667085]",children:["/",n," Min"]})]})]});return o.jsxs("header",{className:"iw-w-full iw-text-gray-900 iw-shadow-sm",children:[o.jsxs("div",{className:"iw-mx-auto iw-flex iw-items-center iw-justify-between iw-p-4 iw-pt-1 iw-mb-2 iw-border-b iw-border-[#B3B9CB] iw-border-dashed",children:[o.jsxs("div",{className:"iw-flex iw-items-center iw-space-x-2",children:[o.jsx(vn,{brandLogo:r,brandName:t}),o.jsx("p",{className:"iw-text-xl iw-font-semibold",children:t})]}),o.jsx("h1",{className:"iw-text-2xl iw-font-semibold iw-text-gradient-silver",children:e}),o.jsx("button",{className:"iw-text-sm iw-text-[#E94315] iw-min-w-10 iw-rounded-md hover:iw-bg-orange-100 iw-p-2",onClick:()=>c(!0),children:o.jsxs("span",{className:"iw-flex iw-items-center iw-gap-1 iw-text-[18px] iw-font-semibold iw-whitespace-nowrap",children:[o.jsx(Ei,{className:"iw-text-[#E94315] iw-size-5"}),"Leave interview"]})})]}),o.jsx(h,{}),o.jsx("div",{className:"iw-h-px iw-bg-gray-200"}),o.jsx(kl,{isOpen:a,confirmExitInterview:()=>{i(),c(!1)},onClose:()=>c(!1)})]})},Zh=({className:e="",width:t,height:r=56,barWidth:i=3,gap:n=2,fftSize:s=1024,smoothingTimeConstant:a=.8,mediaStream:c,startOnMount:l=!0})=>{const{baseColor:h}=Rt(),u=d.useRef(null),f=d.useRef(null),w=d.useRef(null),g=d.useRef(null),p=d.useRef(null),y=d.useRef(null),b=d.useRef(!1),[m,v]=d.useState(null);d.useEffect(()=>{if(t||!f.current)return;const _=f.current,S=()=>{const P=u.current;if(!P)return;const C=_.clientWidth,x=r;P.width=Math.max(1,Math.floor(C*window.devicePixelRatio||1)),P.height=Math.max(1,Math.floor(x*window.devicePixelRatio||1))},E=new ResizeObserver(S);return E.observe(_),S(),()=>E.disconnect()},[t,r]),d.useEffect(()=>{if(!t)return;const _=u.current;_&&(_.width=Math.max(1,Math.floor(t*(window.devicePixelRatio||1))),_.height=Math.max(1,Math.floor(r*(window.devicePixelRatio||1))))},[t,r]),d.useEffect(()=>{let _=!1;return(async()=>{try{const E=new(window.AudioContext||window.webkitAudioContext);w.current=E;let P=c;if(!P){if(!l)return;P=await navigator.mediaDevices.getUserMedia({audio:!0,video:!1}),b.current=!0}if(_)return;const C=E.createAnalyser();C.fftSize=s,C.smoothingTimeConstant=a,g.current=C;const x=E.createMediaStreamSource(P);p.current=x,x.connect(C),k()}catch(E){v((E==null?void 0:E.message)||"Failed to initialize microphone")}})(),()=>{var E,P,C,x;_=!0,y.current&&cancelAnimationFrame(y.current);try{(E=p.current)==null||E.disconnect()}catch{}try{(P=g.current)==null||P.disconnect()}catch{}b.current&&((x=((C=p.current)==null?void 0:C.mediaStream)||void 0)==null||x.getTracks().forEach(M=>M.stop())),w.current&&w.current.state!=="closed"&&w.current.close()}},[c,s,a,l]);const k=()=>{const _=u.current,S=g.current;if(!_||!S)return;const E=_.getContext("2d");if(!E)return;const P=window.devicePixelRatio||1,C=_.width,x=_.height,M=S.frequencyBinCount,U=new Uint8Array(M),V=()=>{y.current=requestAnimationFrame(V),S.getByteTimeDomainData(U),E.clearRect(0,0,C,x),E.fillStyle="rgba(0,0,0,0)",E.fillRect(0,0,C,x);const q=Math.max(1,Math.floor(i*P)),D=Math.max(1,Math.floor(n*P)),O=q+D,R=Math.max(8,Math.floor((C+D)/O)),be=Math.floor(U.length/R);for(let ze=0;ze<R;ze++){const ft=Math.min(U.length-1,ze*be),We=U[ft]/128-1,He=Math.abs(We),wt=Math.pow(He,.6),Lt=Math.max(x*.06,wt*(x*.9)),Ir=ze*O,Fr=(x-Lt)/2,Lr=140-Math.min(140,140*He),Mr=85,Dr=48+Math.floor(12*(1-He));E.fillStyle=`${h}`,E.shadowColor=`hsla(${Lr}, ${Mr}%, ${Dr}%, ${.25*He})`,E.shadowBlur=8*He;const Qt=Math.min(q/2,Lt/2);Rh(E,Ir,Fr,q,Lt,Qt),E.fill()}};V()};return o.jsxs("div",{ref:f,className:`iw-relative iw-w-full iw-overflow-hidden iw-rounded-md iw-bg-gray-50 ${e}`,style:{height:r},children:[o.jsx("canvas",{ref:u,className:"iw-w-full iw-h-full"}),m&&o.jsx("div",{className:"iw-absolute iw-inset-0 iw-flex iw-items-center iw-justify-center",children:o.jsx("span",{className:"iw-text-xs iw-text-red-600 iw-bg-red-50 iw-border iw-border-red-200 iw-px-2 iw-py-1 iw-rounded",children:m})})]})};function Rh(e,t,r,i,n,s){const a=Math.min(s,i/2,n/2);e.beginPath(),e.moveTo(t+a,r),e.lineTo(t+i-a,r),e.quadraticCurveTo(t+i,r,t+i,r+a),e.lineTo(t+i,r+n-a),e.quadraticCurveTo(t+i,r+n,t+i-a,r+n),e.lineTo(t+a,r+n),e.quadraticCurveTo(t,r+n,t,r+n-a),e.lineTo(t,r+a),e.quadraticCurveTo(t,r,t+a,r),e.closePath()}const e2=({state:e,answeringTime:t,nextPhase:r,sttError:i,disableStopButton:n=!1})=>o.jsxs("div",{className:"iw-flex iw-flex-col iw-justify-between iw-h-full ",children:[o.jsxs("div",{children:[o.jsxs("div",{className:"iw-flex iw-items-center iw-justify-between",children:[o.jsx("h3",{className:"iw-text-lg iw-font-semibold iw-text-gray-900 iw-mb-1",children:"You may start speaking now. We're listening...."}),o.jsxs("div",{className:"iw-flex iw-items-center iw-justify-center iw-gap-2",children:[o.jsxs("div",{className:"iw-flex iw-items-center iw-gap-1",children:[o.jsx(no,{className:"iw-size-4 iw-text-orange-600"}),o.jsx("p",{className:"iw-text-gray-700 iw-text-sm",children:"Time to talk: "})]}),o.jsx(ln,{total:t,remaining:e.currentPhaseTimeRemaining,size:50,strokeWidth:4})]})]}),o.jsx("p",{className:"iw-max-w-lg iw-text-gray-500 iw-text-xs iw-leading-[21px]",children:"Done talking? Click the button to review your answer."})]}),o.jsxs("div",{children:[o.jsx(Zh,{}),i&&o.jsxs("div",{className:"iw-mt-2 iw-text-xs iw-text-red-600",children:["Recording error: ",i.message]})]}),o.jsx("div",{className:"iw-w-full iw-grid iw-grid-cols-1",children:o.jsx(cn,{disabled:n,onClick:()=>{r()},children:"Transcribe My Answer"})})]});function t2(){const[e,t]=d.useState(!0),r=d.useMemo(()=>[0,1,2].map(i=>({id:i})),[]);return d.useEffect(()=>{const i=setInterval(()=>{t(n=>!n)},1500);return()=>clearInterval(i)},[]),o.jsxs("div",{className:"iw-flex iw-flex-col iw-items-center iw-justify-center iw-gap-8 iw-h-full",children:[o.jsx("div",{className:"iw-relative iw-w-80 iw-h-48 ","aria-hidden":!0,children:r.map((i,n)=>{const s=n*50,a=e?s:s+12,c=e?1:.08,l=n*140;return o.jsx("div",{role:"presentation",className:"iw-absolute iw-w-full iw-rounded-lg iw-p-4 iw-shadow-md iw-bg-gradient-to-b iw-from-gray-50 iw-to-gray-100 iw-overflow-hidden",style:{top:0,transform:`translateY(${a}px)`,opacity:c,transition:`transform 600ms cubic-bezier(.2,.9,.3,1) ${l}ms, opacity 400ms ease ${l}ms`},children:o.jsxs("div",{className:"iw-flex iw-gap-3 iw-items-center",children:[o.jsx("div",{className:"iw-w-10 iw-h-10 iw-bg-gray-300 iw-rounded iw-flex-shrink-0"}),o.jsxs("div",{className:"iw-flex-1 iw-space-y-2",children:[o.jsx("div",{className:"iw-h-2 iw-bg-gray-300 iw-rounded iw-w-24"}),o.jsx("div",{className:"iw-h-2 iw-bg-gray-300 iw-rounded iw-w-32"})]})]})},i.id)})}),o.jsx("div",{className:"iw-text-center",children:o.jsx("p",{className:"iw-text-gray-500 iw-font-medium",children:"Preparing your question..."})})]})}const r2=({size:e="192px",className:t,colors:r,animationDuration:i=20})=>{const s={...{bg:"oklch(95% 0.02 264.695)",c1:"oklch(75% 0.15 350)",c2:"oklch(80% 0.12 200)",c3:"oklch(78% 0.14 280)"},...r},a=parseInt(e.replace("px",""),10),c=a<50?Math.max(a*.008,1):Math.max(a*.015,4),l=a<50?Math.max(a*.004,1.2):Math.max(a*.008,1.5),h=a<50?Math.max(a*.004,.05):Math.max(a*.008,.1),u=a<50?Math.max(a*.004,.5):Math.max(a*.008,2),f=a<30?"0%":a<50?"5%":a<100?"15%":"25%",w=a<30?1.1:a<50?Math.max(l*1.2,1.3):l;return o.jsx("div",{className:`siri-orb ${t}`,style:{width:e,height:e,"--bg":s.bg,"--c1":s.c1,"--c2":s.c2,"--c3":s.c3,"--animation-duration":`${i}s`,"--blur-amount":`${c}px`,"--contrast-amount":w,"--dot-size":`${h}px`,"--shadow-spread":`${u}px`,"--mask-radius":f},children:o.jsx("style",{children:`
|
|
74
|
+
└─────────────────────────────────────────────────────────────┘`,"color: #ffd93d; font-size: 14px; font-family: monospace; background: rgba(255, 217, 61, 0.1); padding: 10px;")}const t={open:!1,orientation:null},r=160,i=setInterval(()=>{window.outerHeight-window.innerHeight>r||window.outerWidth-window.innerWidth>r?t.open||(t.open=!0,t.orientation=window.outerWidth-window.innerWidth>r?"vertical":"horizontal",e()):t.open&&(t.open=!1,console.log("%c🌟 Developer tools closed. Interview continues smoothly! ✨","color: #4ecdc4; font-weight: bold; text-shadow: 0 0 10px #4ecdc4;"))},500),n=a=>{if(a.keyCode===123||a.ctrlKey&&a.shiftKey&&(a.keyCode===73||a.keyCode===74)||a.ctrlKey&&a.keyCode===85)return a.preventDefault(),console.log("%c🎭 Nice try! Keyboard shortcuts are disabled during interviews ✨","color: #ffd93d; font-weight: bold; text-shadow: 0 0 10px #ffd93d;"),!1},s=a=>(a.preventDefault(),console.log("%c🌈 Right-click menu disabled for interview integrity! 🎪","color: #ff9ff3; font-weight: bold; text-shadow: 0 0 10px #ff9ff3;"),!1);return document.addEventListener("keydown",n),document.addEventListener("contextmenu",s),()=>{clearInterval(i),document.removeEventListener("keydown",n),document.removeEventListener("contextmenu",s),delete window.showStats,delete window.interviewTips}},[])},yl=d.forwardRef(({className:e="",interviewId:t="",interview_duration:r,showProctoringUI:i=!0,onSetReference:n,isAnswering:s,onProctoringStatusChange:a,showStatusOverlay:c=!1,cheatingWarningVisible:l=!1,isDeviceLoading:h=!1,videoAllowed:u=!0},f)=>{var Tl;const{authToken:w}=no(),g=qs(),p=w?Yl(w):null,{borderRadius:y}=Rt(),b=y??18,{proctoring:m,capture_screenshots:v}=jr(),_=!!(m!=null&&m.gazeAnalysisEnabled),[E,k]=d.useState(!1),[S,P]=d.useState((m==null?void 0:m.showLandmarks)??!1),[x,A]=d.useState(i&&((m==null?void 0:m.showEngagementBar)??!0)),[D,U]=d.useState(_),[j,q]=d.useState(!1),M=d.useRef(null),O=d.useRef(null),R=d.useRef(null),be=d.useRef(null),ze=d.useCallback(async _e=>{var wn;const mi=M.current,Ae=R.current;if(!mi||!Ae)return;const Ur=Ae.getContext("2d");if(!Ur)return;Ae.width=mi.videoWidth,Ae.height=mi.videoHeight,Ur.save(),Ur.scale(-1,1),Ur.drawImage(mi,-Ae.width,0,Ae.width,Ae.height),Ur.restore();const yi=await new Promise(Zt=>Ae.toBlob(Zt,"image/jpeg"));if(yi&&t)try{const Zt=`${_e}-${Date.now()}.jpeg`,Ce=await g.requestScreenshotUploadUrl(t,Zt);Ce.data&&Ce.data.upload_url&&(await g.uploadScreenshot((wn=Ce==null?void 0:Ce.data)==null?void 0:wn.upload_url,yi),Ce.data.asset_id&&await g.confirmScreenshotUpload(Ce.data.asset_id))}catch(Zt){console.error(`Failed to upload screenshot for ${_e}:`,Zt)}},[g,t]);d.useEffect(()=>{let _e;return s&&(q(!0),_e=setTimeout(()=>q(!1),1e3)),()=>{_e&&clearTimeout(_e)}},[s]);const{faceLandmarkerRef:vt,isModelLoaded:We,statusMessage:He,setStatusMessage:ft,loadingProgress:Lt,permissionDenied:Fr,clearCache:Lr}=Xu(),{fps:Mr,updateFPS:Dr}=Qu(),{drawWithEngagementBar:Pr,clearCanvas:Qt,engagementRef:Ie}=Ju(),{engagement:Mt,isLookingAway:ne,analyzeGaze:li,setEngagement:Or,setIsLookingAway:Jt}=Ru(),{multipleFacesDetected:Br,referenceFaceNotDetected:di,analyzeFace:Js,setMultipleFacesDetected:un,setReferenceFaceNotDetected:ui}=th(),{referenceSet:hi,referenceRef:fi,setReference:wi,resetReference:gi,syncReference:pi}=lh(vt,M,ft,n),hn={multipleFacesDetected:Br,referenceFaceNotDetected:di,isLookingAway:ne},{showGazeWarningModal:B,getWarningType:$,closeWarningModal:Ze,setShowGazeWarningModal:fn,setFaceDetectionState:Cl}=ih(hn,_&&!c,We);d.useEffect(()=>{if(a){if(h||!We){a("model_loading");return}if(!u){a("camera_error");return}const _e=$()||ke.NO_FACE;a(_e)}},[We,h,u,Br,di,ne,$,a]);const{renderLoop:c2}=ch(M,O,vt,Dr,Js,Pr,Qt,li,hi,fi,S,x,_,ft,ui);ah(M,We,c2,ft),d.useEffect(()=>{pi()},[pi]),d.useEffect(()=>{Ie&&Ie.current&&(Ie.current.value=Mt,Ie.current.isLookingAway=ne)},[Mt,ne,Ie]);const l2=d.useCallback(_e=>{U(_e),_e||(Or(100),Jt(!1))},[Or,Jt]),d2=d.useCallback(()=>{Jt(!1),un(!1),ui(!1),Cl("face_detected"),fn(!1),Ze()},[Jt,un,ui,Cl,fn,Ze]),u2={engagement:Mt,fps:Mr,isLookingAway:ne,multipleFacesDetected:Br,referenceFaceNotDetected:di};return d.useEffect(()=>{if(!v)return;const _e=[];return(async()=>{try{const Ae=await navigator.mediaDevices.getUserMedia({video:!0,audio:!1});be.current=Ae,M.current&&(M.current.srcObject=Ae);const yi=(r??bi)*60*1e3/3,wn=[0,1,2].map((Ce,Dt)=>({label:`capture-${Dt+1}`,start:Dt*yi,end:(Dt+1)*yi})),Zt=(Ce,Dt)=>Ce===Dt?Ce:Math.random()*(Dt-Ce)+Ce;wn.forEach(({label:Ce,start:Dt,end:h2},f2)=>{let Zs;f2===0?Zs=3e3:Zs=Zt(Dt,h2),_e.push(setTimeout(()=>{ze(Ce)},Zs))})}catch(Ae){console.error("Error accessing camera:",Ae)}})(),()=>{be.current&&be.current.getTracks().forEach(Ae=>Ae.stop()),_e.forEach(clearTimeout)}},[ze,v]),d.useImperativeHandle(f,()=>({setReference:()=>{wi()},resetReference:()=>{gi()},stopCamera:()=>{be.current&&(be.current.getTracks().forEach(_e=>_e.stop()),be.current=null)}}),[wi,gi]),o.jsxs("div",{className:`iw-relative iw-h-full iw-w-full ${e}`,children:[Fr?o.jsxs("div",{className:"iw-rounded-md iw-border iw-border-red-600 iw-p-5 iw-text-red-600",children:[o.jsx("h2",{children:"Camera Permission Denied"}),o.jsx("p",{children:"Please allow camera access to use this application."})]}):o.jsx("div",{className:"iw-flex iw-w-full iw-h-full iw-justify-start iw-items-start",children:o.jsxs("div",{className:`iw-relative iw-max-w-full iw-max-h-full iw-aspect-video iw-rounded-2xl iw-overflow-hidden iw-bg-black ${j?"iw-animate-answer-start":""} ${s?"iw-border-4 iw-border-[#6296FB]":""}`,style:{width:"100%",height:"auto",minHeight:"0"},children:[o.jsx("video",{ref:M,autoPlay:!0,playsInline:!0,muted:!0,className:"iw-absolute iw-inset-0 iw-w-full iw-h-full iw-object-cover",style:{transform:"scaleX(-1)"}}),!u&&o.jsx("div",{className:"iw-absolute iw-inset-0 iw-flex iw-flex-col iw-items-center iw-justify-center iw-bg-black/60 iw-z-30",children:h||!We?o.jsxs("div",{className:"iw-flex iw-flex-col iw-items-center iw-gap-3",children:[o.jsx("div",{className:"iw-w-5 iw-h-5 iw-border-2 iw-border-white/20 iw-border-t-white iw-rounded-full iw-animate-spin"}),o.jsx("span",{className:"iw-text-white/60 iw-text-xs iw-font-medium iw-tracking-wide",children:"Initializing camera..."})]}):o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"iw-text-white iw-font-medium iw-text-sm",children:"Camera not found"}),o.jsx("p",{className:"iw-text-white/60 iw-text-xs iw-mt-1",children:"Please ensure your camera is connected and enabled"})]})}),_&&o.jsx("canvas",{ref:O,width:320,height:240,className:"iw-absolute iw-inset-0 iw-w-full iw-h-full iw-object-cover",style:{transform:"scaleX(-1)",borderRadius:b,display:"hidden"}}),o.jsx("canvas",{ref:R,style:{display:"none"}}),i&&o.jsxs("div",{className:"iw-absolute iw-top-4 iw-right-4 iw-inline-flex iw-items-center iw-gap-2 iw-rounded-lg iw-border iw-border-white/10 iw-bg-[#FFEBE6] iw-px-2 iw-py-1 iw-backdrop-blur-md",children:[o.jsx("div",{className:"iw-size-2 iw-animate-pulse iw-rounded-full iw-bg-red-500"}),o.jsx("span",{className:"iw-font-medium iw-text-xs iw-text-[#E94315]",children:"RECORDING"})]}),i&&((Tl=p==null?void 0:p.data)==null?void 0:Tl.user_name)&&o.jsx("div",{className:"iw-absolute iw-z-50 iw-bottom-4 iw-right-4 iw-inline-flex iw-items-center iw-gap-2 iw-rounded-lg iw-border iw-border-white/10 iw-bg-[#F1F5FE] iw-px-3 iw-py-1 iw-backdrop-blur-md",children:o.jsx("span",{className:"iw-font-medium iw-text-xs iw-text-[#062260]",children:p.data.user_name})}),i&&o.jsx("div",{className:"iw-absolute iw-bottom-4 iw-right-4",children:o.jsx(ad,{showControls:(m==null?void 0:m.showControls)??!1,isBubbleOpen:E,setIsBubbleOpen:k,setReference:wi,clearCache:Lr,isModelLoaded:We,gazeAnalysisEnabled:D&&_,referenceSet:hi,showLandmarks:S,setShowLandmarks:P,showEngagementBar:x,setShowEngagementBar:A,handleToggleGazeAnalysis:l2,stats:u2,statusMessage:He,loadingProgress:Lt})}),c&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"iw-absolute iw-inset-0 iw-pointer-events-none iw-z-10 ",style:{background:"radial-gradient(ellipse 20% 40% at 50% 45%, transparent 99.5%, rgba(0,0,0,0.35) 100%)"}}),o.jsx("div",{className:"iw-absolute iw-bottom-2 iw-inset-x-0 iw-flex iw-justify-center iw-pointer-events-none iw-z-20",children:o.jsx(uh,{status:u?h||!We?"model_loading":$()??"no_face_detected":"camera_error"})})]})]})}),_&&B&&!c&&o.jsx(dh,{isOpen:B,onClose:d2,warningType:$(),isCheatingModalOpen:l})]})}),cn=({children:e,variant:t="primary",size:r="md",fullWidth:i=!1,isLoading:n=!1,disabled:s,className:a="",...c})=>{const l="iw-inline-flex iw-items-center iw-justify-center iw-rounded-md iw-font-medium iw-transition-colors iw-focus:outline-none iw-focus:ring-2 iw-focus:ring-primary-500 iw-focus:ring-offset-2",h={primary:"iw-bg-primary-600 iw-text-white iw-hover:bg-primary-700 iw-border iw-border-transparent",secondary:"iw-bg-primary-100 iw-text-primary-700 iw-hover:bg-primary-200 iw-border iw-border-transparent",outline:"iw-bg-transparent iw-text-primary-700 iw-border iw-border-primary-500 iw-hover:bg-primary-50",text:"iw-bg-transparent iw-text-primary-600 iw-hover:bg-primary-50 iw-border iw-border-transparent",gradient:"iw-text-white iw-border iw-border-transparent iw-bg-gradient-to-r iw-from-purple-500 iw-to-indigo-500 hover:iw-from-purple-600 hover:iw-to-indigo-600"},u={sm:"iw-px-3 iw-py-1.5 iw-text-sm",md:"iw-px-4 iw-py-2.5 iw-text-sm",lg:"iw-px-5 iw-py-3 iw-text-base"},f="iw-disabled:opacity-50 iw-disabled:cursor-not-allowed iw-disabled:pointer-events-none",w=i?"iw-w-full":"";return o.jsxs("button",{className:`${l} ${h[t]} ${u[r]} ${w} ${f} ${a}`,disabled:s||n,...c,children:[n&&o.jsx(oo,{height:16,width:16,style:{marginRight:"3px"}}),e]})},bl=({baseColor:e="#3B82F6",contentClassName:t,title:r,description:i})=>o.jsx(o.Fragment,{children:o.jsx("div",{className:`iw-hidden group-hover:iw-block iw-absolute iw-bottom-full iw-mb-3 iw-left-1/2 -iw-translate-x-1/2 iw-w-64 iw-z-50 ${t}`,children:o.jsxs("div",{className:"iw-rounded-lg iw-p-3 iw-shadow-lg iw-text-white iw-text-left iw-relative",style:{background:e},children:[r&&o.jsx("div",{className:"iw-flex iw-justify-between iw-items-start iw-mb-1",children:o.jsx("h4",{className:"iw-text-sm iw-font-bold iw-mr-2",children:r})}),i&&o.jsx("p",{className:"iw-text-xs iw-opacity-90 iw-leading-tight",children:i}),o.jsx("div",{className:"iw-absolute iw-top-full -iw-translate-x-1/2 iw-border-[6px] iw-border-transparent",style:{borderTopColor:e}})]})})}),Sh=({stream:e,className:t="",barCount:r=50,onAudioLevel:i})=>{const n=d.useRef(null),s=d.useRef(null),a=d.useRef(0),c=d.useRef(null),l=d.useRef(null),h=d.useRef(null);d.useEffect(()=>{if(!e||window===void 0)return;l.current||(l.current=new(window.AudioContext||window.webkitAudioContext));const f=l.current;c.current||(c.current=f.createAnalyser(),c.current.fftSize=256,c.current.smoothingTimeConstant=.5);const w=c.current;try{h.current&&h.current.disconnect(),h.current=f.createMediaStreamSource(e),h.current.connect(w)}catch(p){console.error("Error creating media stream source:",p);return}const g=()=>{if(!n.current)return;const p=n.current,y=p.getContext("2d");if(!y)return;const b=w.frequencyBinCount,m=new Uint8Array(b);w.getByteFrequencyData(m);const v=p.width,_=p.height;y.clearRect(0,0,v,_);let E=0;for(let M=0;M<b;M++){const O=m[M]??0;E+=O*O}const k=Math.sqrt(E/b),S=Math.min(1,k/128),P=new Float32Array(w.fftSize);w.getFloatTimeDomainData(P);let x=0;for(let M=0;M<P.length;M++){const O=P[M]||0;x+=O*O}const A=Math.sqrt(x/P.length),D=A>0?20*Math.log10(A):-1/0;let U="problem";if(D>=-20?U="good":D>=-25?U="acceptable":D>=-45?U="poor":U="problem",i){const M=Date.now();M-a.current>200&&(a.current=M,i(U,D))}y.clearRect(0,0,v,_);const j=r,q=Math.floor(S*j);for(let M=0;M<j;M++){const O=M*(v/j),R=v/j-1.8;M<q?y.fillStyle="#0EB00E":y.fillStyle="#D9D9D9",y.fillRect(O,0,R,_)}s.current=requestAnimationFrame(g)};return g(),()=>{s.current&&cancelAnimationFrame(s.current)}},[e,r]);const u=d.useRef({audioContext:l.current,source:h.current});return u.current={audioContext:l.current,source:h.current},d.useEffect(()=>()=>{u.current.source&&u.current.source.disconnect(),u.current.audioContext&&u.current.audioContext.state!=="closed"&&u.current.audioContext.close()},[]),o.jsx("canvas",{ref:n,className:t,width:300,height:20,style:{width:"100%",height:"100%"}})},Ah={initial:{bgColor:"iw-bg-[#FEF2F2]",borderColor:"iw-border-[#FECACA]",iconBg:"iw-bg-[#C81E1E]",iconColor:"iw-text-white",titleColor:"iw-text-[#C81E1E]",subtitleColor:"iw-text-[#991B1B]",title:"Action Required: No Sound Detected",subtitle:"Please speak into your microphone to test it.",tooltipText:"Please speak into your microphone to verify audio quality before proceeding",tooltipBg:"#DC2626"},poor:{bgColor:"iw-bg-[#FFF7ED]",borderColor:"iw-border-[#FFEDD5]",iconBg:"iw-bg-[#EA580C]",iconColor:"iw-text-white",titleColor:"iw-text-[#EA580C]",subtitleColor:"iw-text-[#9A3412]",title:"Poor Audio Levels: Speak Louder to Continue",subtitle:"We can hear you, but your microphone sound is very low.",tooltipText:"Your microphone sound is very low. Please try speaking louder or check your microphone settings.",tooltipBg:"#EA580C"},acceptable:{bgColor:"iw-bg-[#FFFBEB]",borderColor:"iw-border-[#FDE68A]",iconBg:"iw-bg-[#D97706]",iconColor:"iw-text-white",titleColor:"iw-text-[#D97706]",subtitleColor:"iw-text-[#92400E]",title:"Acceptable Action: Keep speaking.",subtitle:"You can speak louder for better quality.",tooltipText:"Your microphone is working, but we're having trouble hearing you clearly. Try speaking a bit louder or moving closer to your microphone",tooltipBg:"#B45309"},good:{bgColor:"iw-bg-[#F0FDF4]",borderColor:"iw-border-[#BBF7D0]",iconBg:"iw-bg-[#16A34A]",iconColor:"iw-text-white",titleColor:"iw-text-[#16A34A]",subtitleColor:"iw-text-[#14532D]",title:"Excellent!",subtitle:"Your audio is clear. You can continue.",tooltipText:"Your audio levels are perfect. You're ready to proceed with the interview",tooltipBg:"#16A34A"},success:{bgColor:"iw-bg-[#F0FDF4]",borderColor:"iw-border-[#BBF7D0]",iconBg:"iw-bg-[#16A34A]",iconColor:"iw-text-white",titleColor:"iw-text-[#16A34A]",subtitleColor:"iw-text-[#14532D]",title:"Success! Mic is ready.",subtitle:"Your microphone is working perfectly.",tooltipText:"Your microphone is working perfectly and ready for the interview",tooltipBg:"#16A34A"}},Ch=({micEnabled:e,micTested:t,audioStatus:r})=>{if(!e)return null;let i="initial";t&&r==="problem"?i="success":r==="good"?i="good":r==="acceptable"?i="acceptable":r==="poor"&&(i="poor");const n=Ah[i];return o.jsx("div",{className:"iw-relative iw-w-full iw-group",children:o.jsxs("div",{className:`iw-flex iw-items-center iw-gap-3 iw-py-2 iw-px-2 iw-w-full iw-rounded-xl iw-border ${n.borderColor} ${n.bgColor} iw-transition-all iw-duration-300 ${i==="initial"||i==="poor"?"iw-animate-initial-mic":""}`,children:[o.jsx("div",{className:`iw-flex iw-items-center iw-justify-center iw-w-9 iw-h-9 iw-rounded-full ${n.iconBg} iw-shrink-0`,children:o.jsx(sd,{className:`iw-w-5 iw-h-5 ${n.iconColor}`})}),o.jsxs("div",{className:"iw-flex iw-flex-col iw-gap-[2px] iw-pr-2",children:[o.jsx("p",{className:`${n.titleColor} iw-text-sm iw-font-semibold iw-m-0 iw-leading-[1.1]`,children:n.title}),o.jsx("p",{className:`${n.subtitleColor} iw-text-xs iw-font-normal iw-m-0 iw-leading-[1.1]`,children:n.subtitle})]})]})})},vl=({icon:e,devices:t,selectedId:r,onChange:i,label:n,showVisualizer:s=!1,showMicHint:a=!1,micTested:c=!1,audioStatus:l="problem",stream:h=null,hasPermission:u=!0,onAudioLevel:f})=>{const{baseColor:w}=Rt(),[g,p]=d.useState(!1),y=d.useRef(null);d.useEffect(()=>{const v=_=>{y.current&&!y.current.contains(_.target)&&p(!1)};return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[]);const b=t.find(v=>v.deviceId===r)||t[0],m=u&&(b==null?void 0:b.label)||n;return o.jsxs("div",{className:`iw-relative iw-flex-1 iw-w-1/2 ${!u&&"iw-group"}`,ref:y,children:[o.jsxs("div",{className:`iw-max-w-[300px] iw-flex iw-items-center iw-justify-between iw-bg-white iw-border iw-border-gray-200 iw-rounded-xl iw-px-3 iw-py-3 iw-transition-colors ${u?"iw-cursor-pointer hover:iw-border-blue-500":"iw-cursor-not-allowed"}`,onClick:()=>u&&p(!g),title:u?"":"Permission denied or device not found",children:[o.jsxs("div",{className:"iw-flex iw-items-center iw-gap-3 iw-min-w-0 iw-flex-1",children:[o.jsx(e,{className:"iw-w-5 iw-h-5 iw-text-[#062260] iw-flex-shrink-0"}),o.jsxs("div",{className:"iw-flex iw-flex-col iw-min-w-0 iw-flex-1",children:[o.jsx("span",{className:"iw-text-sm iw-text-[#062260] iw-font-medium iw-truncate",children:m}),s&&u&&o.jsx("div",{className:"iw-w-full iw-h-1.5 iw-mt-1",children:o.jsx(Sh,{stream:h,className:"iw-w-full iw-h-full",onAudioLevel:f,barCount:45})})]})]}),o.jsx("div",{className:"iw-flex iw-items-center iw-gap-2",children:u?o.jsxs(o.Fragment,{children:[o.jsx(Rl,{className:`iw-w-4 iw-h-4 iw-text-gray-400 iw-transition-transform ${g?"iw-rotate-180":""}`}),r&&o.jsx("div",{className:"iw-bg-[#22C55E] iw-rounded-full iw-p-0.5",children:o.jsx(Ei,{className:"iw-w-3 iw-h-3 iw-text-white"})})]}):o.jsx("div",{className:"iw-text-[#E94315] iw-relative",children:o.jsx(xi,{className:"iw-size-5"})})})]}),!u&&o.jsx(bl,{baseColor:w,contentClassName:"!iw-left-0",title:`Allow us to access your ${(n==null?void 0:n.split(" ")[1])??"device"}`,description:"We need permission to access your device. Go to your browser privacy settings to allow it"}),a&&u&&o.jsx("div",{className:"iw-w-full iw-mt-2 sm:iw-w-[calc(200%+16px)] iw-z-100",children:o.jsx(Ch,{micEnabled:u,micTested:c,audioStatus:l})}),g&&u&&o.jsxs("div",{className:"iw-absolute iw-bottom-full iw-left-0 iw-right-0 iw-mb-2 iw-bg-white iw-border iw-border-gray-100 iw-rounded-xl iw-shadow-xl iw-z-50 iw-py-2 iw-max-h-60 iw-overflow-y-auto",children:[t.map(v=>o.jsxs("div",{className:`iw-px-4 iw-py-2.5 iw-text-sm iw-cursor-pointer iw-flex iw-items-center iw-justify-start hover:iw-bg-gray-50 ${r===v.deviceId?"iw-text-[#062260] iw-font-medium iw-bg-blue-50":"iw-text-gray-600"}`,onClick:()=>{i==null||i(v.deviceId),p(!1)},children:[r===v.deviceId&&o.jsx(Ei,{className:"iw-w-4 iw-h-4 iw-text-[#062260] iw-mr-1"}),o.jsx("span",{className:"iw-truncate",children:v.label||`Device ${v.deviceId.slice(0,5)}...`})]},v.deviceId)),t.length===0&&o.jsx("div",{className:"iw-px-4 iw-py-2 iw-text-sm iw-text-gray-400",children:"No devices found"})]})]})},xl=({micEnabled:e=!1,videoEnabled:t=!1,buttonText:r,onButtonClick:i,isAgreed:n,onAgreedToggle:s,showCheckbox:a=!0,showMediaIcons:c=!0,disabled:l=!1,audioDevices:h=[],videoDevices:u=[],selectedAudioId:f,selectedVideoId:w,onAudioChange:g,onVideoChange:p,audioStream:y=null,isDeviceLoading:b=!1})=>{const{baseColor:m}=Rt(),[v,_]=d.useState("problem"),[E,k]=d.useState(!1);d.useEffect(()=>{_("problem"),k(!1)},[f]);const S=l||!n||c&&(!e||!t||!E)||b,P=x=>{const A={good:3,acceptable:2,poor:1,problem:0};_(D=>A[x]>A[D]?x:D),!E&&(x==="good"||x==="acceptable")&&k(!0)};return o.jsxs("div",{className:"iw-flex iw-flex-col iw-gap-1 iw-w-full",children:[o.jsxs("div",{className:"iw-flex iw-justify-center iw-items-center iw-gap-2 iw-flex-wrap iw-max-w-[700px] iw-mx-auto",children:[c&&o.jsxs("div",{className:"iw-flex sm:iw-flex-row iw-flex-col iw-gap-4 iw-w-full",children:[o.jsx(vl,{icon:rd,devices:h,selectedId:f??"",onChange:x=>g&&g(x),label:"Choose mic",showVisualizer:!0,showMicHint:!0,micTested:E,audioStatus:v,stream:y,hasPermission:e,onAudioLevel:P}),o.jsx(vl,{icon:nd,devices:u,selectedId:w??"",onChange:x=>p&&p(x),label:"Choose camera",hasPermission:t})]}),a&&o.jsxs("div",{className:"iw-flex iw-items-start iw-gap-3 iw-bg-[#F1F5FE] iw-rounded-xl iw-mb-1 iw-p-3 iw-pr-8 iw-border iw-border-[#c2c3c7]",children:[o.jsx("div",{className:`iw-mt-0.5 iw-h-5 iw-w-5 iw-min-w-[20px] iw-rounded iw-border iw-flex iw-items-center iw-justify-center iw-cursor-pointer iw-transition-colors ${n?"iw-bg-[#062260] iw-border-[#062260]":"iw-bg-white iw-border-[#062260]"}`,onClick:x=>{x.stopPropagation(),s(!n)},children:n&&o.jsx(Ei,{className:"iw-size-3 iw-text-white"})}),o.jsx("label",{onClick:()=>s(!n),className:"iw-text-[13px] iw-text-[#062260] iw-font-medium iw-cursor-pointer iw-select-none",children:"By continuing, you acknowledge and consent to the use of your face data exclusively for interview monitoring"})]})]}),o.jsxs("div",{className:"iw-relative iw-group iw-w-full iw-max-w-[280px] iw-mx-auto iw-mt-1",children:[o.jsx(cn,{onClick:i,disabled:S,className:`iw-h-12 iw-w-full iw-shadow-lg !iw-bg-[#F1F5FE] !iw-text-[#062260] !iw-font-bold !iw-border-[#E7EAF1] iw-rounded-lg ${S?"iw-opacity-50":"hover:iw-opacity-75"}`,children:b?"Device Loading...":r}),!n&&(!c||e&&t)&&bl({baseColor:m,title:"Action Required",description:"Please check the box to acknowledge and consent to continue."})]})]})},Th=({steps:e,currentStepIndex:t})=>o.jsx("div",{className:"iw-flex iw-items-center iw-justify-center iw-gap-4 iw-w-full iw-py-2",children:e.map((r,i)=>{const n=i<t,s=i===t;return o.jsxs(d.Fragment,{children:[o.jsxs("div",{className:"iw-flex iw-items-center iw-gap-3",children:[o.jsx("div",{className:`iw-flex iw-size-9 iw-text-[#062260] iw-items-center iw-justify-center iw-rounded-full iw-font-semibold iw-border ${s||n?"iw-border-[#0EB00E] iw-bg-[#E9FFE6]":"iw-border-[#BDE0FD] iw-bg-[#E6F3FF]"}`,children:n?o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:o.jsx("polyline",{points:"20 6 9 17 4 12"})}):i+1}),o.jsx("span",{className:`iw-text-sm iw-font-medium ${s||n?"iw-text-[#062260]":"iw-text-[#5C6686]"}`,children:r.label})]}),i<e.length-1&&o.jsx("div",{className:"iw-flex-1 iw-max-w-[120px] iw-border-t iw-border-dotted iw-border-[#B3B9CB]"})]},i)})}),Nh=["Don't refresh or reload the page during your assessment","Don't switch tabs or open other applications while session is ongoing","Don't leave your position during the session","Don't disable or interfere with video/audio monitoring"],Ih=({isOpen:e,onStart:t,gazeEnabled:r=!1,videoFeedRef:i,interviewId:n="",interview_duration:s=bi})=>{const{audioAllowed:a,videoAllowed:c,videoRef:l,audioDevices:h,videoDevices:u,selectedAudioDeviceId:f,selectedVideoDeviceId:w,isDeviceLoading:g,currentStream:p,handleAudioChange:y,handleVideoChange:b,stopStream:m}=Ql(e),[v,_]=d.useState(!1),[E,k]=d.useState(0),[S,P]=d.useState(!1),x=d.useRef(null),A=d.useRef(null),D=O=>{x.current=O,i&&(typeof i=="function"?i(O):i.current=O)};if(d.useEffect(()=>()=>{A.current&&(clearInterval(A.current),A.current=null)},[]),!e)return null;const[U,j]=d.useState(ke.MODEL_LOADING),q=async()=>{var R;_(!0),(R=x.current)==null||R.resetReference();const O=()=>{var be;return(be=x.current)==null?void 0:be.setReference()};O(),A.current&&clearInterval(A.current),A.current=setInterval(O,500)},M=[{label:r?"Calibrate your camera":"Camera & Mic permission"},{label:"Basic guidelines"}];return o.jsx("div",{className:"iw-fixed iw-inset-0 iw-z-50 iw-flex iw-items-center iw-justify-center iw-bg-gray-900/40 iw-backdrop-blur-sm iw-p-4 iw-pt-16 iw-overflow-auto",children:o.jsxs("div",{className:"iw-w-full iw-max-w-[700px] iw-max-h-[900px] iw-my-6 iw-bg-white iw-rounded-xl iw-shadow-2xl iw-overflow-auto",children:[o.jsxs("div",{className:"iw-px-12 iw-pt-3",children:[o.jsx("h2",{className:"iw-text-[#062260] iw-text-2xl iw-font-medium iw-tracking-tight",children:"Final checks before you go live"}),o.jsx("div",{className:"iw-mt-1 iw-bg-[#F1F5FE] iw-rounded-xl iw-p-2 iw-border iw-border-[#E7EAF1]",children:o.jsx("p",{className:"iw-text-[#5C6686] iw-text-xs iw-leading-relaxed",children:"To ensure the integrity of the interview process, this platform uses your device’s camera to monitor your face and gaze direction. We do not store any outside this session"})}),o.jsx("div",{className:"iw-mt-3 iw-border-b iw-border-dashed iw-border-[#B3B9CB] iw-w-full"}),o.jsx(Th,{steps:M,currentStepIndex:E})]}),o.jsx("div",{className:"iw-px-12 iw-pb-3 iw-flex iw-flex-col iw-items-center",children:E===0?o.jsxs("div",{className:"iw-w-full iw-flex iw-flex-col iw-items-center iw-gap-4",children:[o.jsx("div",{className:"iw-w-full iw-max-w-[600px] iw-aspect-video iw-bg-slate-100 iw-rounded-2xl iw-overflow-hidden iw-relative iw-border iw-border-slate-200",children:r?o.jsx(yl,{ref:D,interviewId:n,interview_duration:s,showProctoringUI:!1,showStatusOverlay:!g&&c,isDeviceLoading:g,videoAllowed:c,onProctoringStatusChange:j,onSetReference:()=>{A.current&&(clearInterval(A.current),A.current=null),_(!1),k(1)}}):o.jsx("video",{ref:l,autoPlay:!0,playsInline:!0,muted:!0,className:"iw-w-full iw-h-full iw-object-cover",style:{transform:"scaleX(-1)"}})}),o.jsx(xl,{micEnabled:a,videoEnabled:c,buttonText:r?v?"Calibrating...":U==="model_loading"?"Initialising...":"Start calibrate":"Next",onButtonClick:()=>{r?q():k(1)},disabled:!S||r&&U!=="face_detected"||!r&&(!a||!c),isAgreed:S,onAgreedToggle:P,audioDevices:h,videoDevices:u,selectedAudioId:f,selectedVideoId:w,onAudioChange:y,onVideoChange:b,audioStream:p,isDeviceLoading:g})]}):o.jsxs("div",{className:"iw-w-full iw-flex iw-flex-col iw-gap-6",children:[o.jsx("div",{className:"iw-w-full iw-bg-[#F8FAFF] iw-rounded-2xl iw-p-8 iw-flex iw-flex-col iw-gap-5",children:Nh.map((O,R)=>o.jsxs("div",{className:"iw-flex iw-items-center iw-gap-4",children:[o.jsx("div",{className:"iw-flex iw-h-7 iw-w-7 iw-min-w-[28px] iw-items-center iw-justify-center iw-rounded-full iw-bg-[#DBEAFE] iw-text-[#062260] iw-text-xs iw-font-bold",children:R+1}),o.jsx("span",{className:"iw-text-[#5C6686] iw-font-medium",children:O})]},R))}),o.jsx(xl,{buttonText:"Start interview",onButtonClick:()=>{t(),m()},isAgreed:S,onAgreedToggle:P,showMediaIcons:!1})]})})]})})},Ir=d.useCallback(()=>{var e,t;Ks.stop(),gl.dispose(),(t=(e=Nr.activeStream)==null?void 0:e.getTracks())==null||t.forEach(r=>r.stop())},[]),ln=e=>{const{baseColor:t,borderRadius:r}=Rt(),{loading:i,children:n,...s}=e;return o.jsx(cn,{style:{background:ql(t),borderRadius:r},...s,children:i?o.jsx(oo,{}):n})},Fh=({question:e,isLoading:t=!1,phase:r,brandName:i,brandLogo:n})=>o.jsx("div",{className:"iw-rounded-xl iw-mb-4 message-animation iw-text-gray-800 iw-py-1",children:o.jsxs("div",{className:"iw-flex iw-items-center iw-gap-4",children:[o.jsx("div",{className:`iw-flex iw-flex-col iw-items-center iw-justify-center iw-relative iw-h-16 iw-w-16 iw-shrink-0 iw-shadow iw-rounded-full iw-border-[#E8EEFE] iw-border-4 ${r===V.READING_QUESTION?"iw-animate-speaking":""}`,children:o.jsx("div",{className:"iw-bg-transparent iw-flex iw-items-center iw-justify-center iw-rounded-full iw-size-full",style:{backgroundImage:"linear-gradient(#B5D0FD, #FFFFFF)"},children:o.jsx(xn,{brandLogo:n,brandName:i})})}),o.jsx(Lh,{phase:r,question:e,isLoading:t,brandName:i})]})}),Lh=({phase:e,question:t,isLoading:r,brandName:i})=>{const n=i||"We",s=i?"is":"are";if(r||e===V.FETCHING_QUESTION||e===V.IDLE)return o.jsxs("div",{className:"iw-animate-pulse iw-w-full iw-space-y-3 iw-mr-10",children:[o.jsx("div",{className:"iw-h-5 iw-bg-gray-200 iw-rounded iw-w-full"}),o.jsx("div",{className:"iw-h-5 iw-bg-gray-200 iw-rounded iw-w-3/4"})]});const a=()=>o.jsxs("span",{className:"iw-animate-dot-wave iw-ml-1",children:[o.jsx("span",{children:"."}),o.jsx("span",{children:"."}),o.jsx("span",{children:"."})]});switch(e){case V.ANSWERING:return o.jsx("div",{className:"iw-flex iw-items-center iw-justify-between iw-w-full",children:o.jsxs("p",{className:"iw-text-lg iw-leading-7 iw-font-medium iw-text-gray-600",children:["Listening",o.jsx(a,{})]})});case V.TRANSCRIBING:return o.jsxs("p",{className:"iw-text-lg iw-leading-7 iw-font-medium iw-text-gray-600",children:[n," ",s," analyzing your answer",o.jsx(a,{})]});case(V.EDITING||V.SUBMITTING):return o.jsxs("p",{className:"iw-text-lg iw-leading-7 iw-font-medium iw-text-gray-600",children:[n," ",s," waiting for your answer..."]});default:return o.jsx("p",{className:"iw-text-lg iw-leading-7",children:t==null?void 0:t.question})}},Mh=(e,t,r)=>Math.max(t,Math.min(r,e)),El=e=>{const t=Math.max(0,Math.floor(e)),r=Math.floor(t/60).toString().padStart(2,"0"),i=(t%60).toString().padStart(2,"0");return`${r}:${i}`},dn=({total:e,remaining:t,size:r=64,strokeWidth:i=6,className:n="",showLabel:s=!0})=>{const a=Math.max(1,e||1),c=Mh(t/a,0,1),{radius:l,circumference:h,dashOffset:u,center:f}=d.useMemo(()=>{const p=(r-i)/2,y=2*Math.PI*p,b=y*(1-c),m=Math.round(i)%2===1,v=r/2+(m?.5:0);return{radius:p,circumference:y,dashOffset:b,center:v}},[r,i,c]),w=d.useMemo(()=>c<=.25?"iw-stroke-red-500":c<=.5?"iw-stroke-yellow-500":"iw-stroke-green-500",[c]),g=c<=.25?"iw-animate-pulse":"";return o.jsxs("div",{className:`iw-relative iw-inline-flex iw-items-center iw-justify-center iw-rounded-full iw-bg-white ${n}`,style:{width:r,height:r},"aria-label":`Time remaining ${El(t)}`,role:"timer","aria-live":"polite",children:[o.jsx("svg",{width:r,height:r,viewBox:`0 0 ${r} ${r}`,preserveAspectRatio:"xMidYMid meet",children:o.jsxs("g",{transform:`rotate(-90 ${f} ${f})`,children:[o.jsx("circle",{cx:f,cy:f,r:l,className:"iw-stroke-gray-200",strokeWidth:i,fill:"none",shapeRendering:"geometricPrecision",vectorEffect:"non-scaling-stroke"}),o.jsx("circle",{cx:f,cy:f,r:l,className:`${w} ${g}`,strokeWidth:i,strokeLinecap:"round",fill:"none",strokeDasharray:h,strokeDashoffset:u,shapeRendering:"geometricPrecision",vectorEffect:"non-scaling-stroke",style:{transition:"stroke-dashoffset 0.3s ease, stroke 0.2s ease"}})]})}),s?o.jsx("div",{className:"iw-absolute iw-inset-0 iw-flex iw-items-center iw-justify-center iw-rotate-0",children:o.jsx("span",{className:`iw-text-[11px] iw-font-semibold iw-tabular-nums ${c<=.25?"iw-text-red-600":c<=.5?"iw-text-yellow-600":"iw-text-green-600"}`,children:El(t)})}):o.jsx("div",{className:"iw-absolute iw-inset-0 iw-flex iw-items-center iw-justify-center iw-rotate-0",children:o.jsx(td,{})})]})},Dh=({label:e,error:t,fullWidth:r=!1,className:i="",id:n,...s})=>{const a=n||`textarea-${Math.random().toString(36).substring(2,9)}`,c="iw-block iw-rounded-md iw-border iw-border-gray-300 iw-shadow-sm iw-px-4 iw-py-2 iw-text-sm iw-transition-all",l=t?"iw-border-red-500 iw-focus:border-red-500 iw-focus:ring-red-500":"",h=r?"iw-w-full":"",u=i.includes("iw-h-full")||r?"iw-h-full":"";return o.jsxs("div",{className:`iw-h-full iw-flex iw-flex-col ${r?"iw-w-full":""}`,children:[e&&o.jsx("label",{htmlFor:a,className:"iw-block iw-text-sm iw-font-medium iw-text-gray-700 iw-mb-1",children:e}),o.jsx("textarea",{id:a,className:`${c} ${l} ${h} ${u} ${i}`,"aria-invalid":t?"true":"false",...s}),t&&o.jsx("p",{className:"iw-mt-1 iw-text-sm iw-text-red-600",children:t})]})},Ph=({answerText:e,onAnswerChange:t,timerState:r,editingTime:i})=>o.jsxs("div",{className:"iw-w-full iw-bg-white iw-rounded-xl iw-border iw-border-[#84bbf5] iw-overflow-hidden iw-rounded-tr-none",children:[o.jsx("div",{className:"iw-p-2 iw-pb-0",children:o.jsx(Dh,{value:e,onChange:t,placeholder:"Type your answer here...",className:"iw-w-full iw-h-64 iw-resize-none iw-bg-transparent iw-border-none iw-text-[#062260] iw-text-base iw-leading-relaxed focus-visible:iw-outline-0 iw-p-0",disabled:r.phase===V.SUBMITTING})}),o.jsxs("div",{className:"iw-bg-[#F1F5FE] iw-px-2 iw-py-2 iw-flex iw-items-center iw-justify-between iw-border-t iw-border-[#E8EEFE]",children:[o.jsx("span",{className:"iw-text-[#062260] iw-text-sm iw-font-medium iw-line-clamp-1",children:"Time left to edit answer"}),o.jsxs("div",{className:"iw-flex iw-items-center iw-gap-2",children:[o.jsx(dn,{total:i,remaining:r.currentPhaseTimeRemaining,size:32,strokeWidth:3,showLabel:!1}),o.jsx("span",{className:"iw-text-[#062260] iw-text-sm iw-font-bold",children:`${vn(r.currentPhaseTimeRemaining,!0)}${r.currentPhaseTimeRemaining>=60?" min":" sec"}`})]})]})]}),_l=({children:e})=>o.jsx("div",{className:"iw-flex iw-flex-col iw-items-start iw-mt-3 iw-gap-1",children:e}),Oh=({questionNumber:e})=>o.jsxs("div",{className:"iw-px-4 iw-py-1.5 iw-rounded-full iw-mb-2 iw-text-sm iw-font-semibold",style:{color:"#062260",backgroundColor:"#E6F3FF",border:"1px solid #BDE0FD"},children:[" Q",e]}),Bh=({label:e})=>o.jsxs("div",{className:"iw-flex iw-items-center iw-gap-2 iw-text-sm iw-text-gray-500 iw-bg-[#F1F5FE] iw-px-4 iw-py-1.5 iw-rounded-full iw-my-2 iw-font-semibold",children:[e&&o.jsx("span",{className:"iw-font-medium",children:e}),o.jsxs("span",{className:"iw-animate-dot-wave iw-text-2xl",children:[o.jsx("span",{children:"."}),o.jsx("span",{children:"."}),o.jsx("span",{children:"."})]})]}),Uh=({timerState:e,answeringTime:t})=>{const r=(e==null?void 0:e.currentPhaseTimeRemaining)||0,i=t||pl.answeringDuration;return o.jsxs("div",{className:"iw-flex iw-w-full iw-items-center iw-justify-between iw-gap-3 iw-bg-[#E6F3FF] iw-p-2 iw-rounded-lg",children:[o.jsx("span",{className:"iw-text-[#062260]",children:"Time left to answer"}),o.jsxs("div",{className:"iw-flex iw-items-center iw-gap-2",children:[o.jsxs("span",{className:"iw-text-xl iw-font-bold iw-text-[#062260]",children:[vn(r,!0),r>=60?" min":" sec"]}),o.jsx(dn,{total:i,remaining:r,size:35,strokeWidth:4,showLabel:!1,className:"iw-shadow-sm iw-border iw-border-gray-100"})]})]})},Vh=()=>{const e=d.useRef(null),t=d.useRef(null);return d.useEffect(()=>{const r=e.current;if(!r)return;const i=r.getContext("2d");if(!i)return;let n=null,s=null,a=null,c;const l=()=>{const h=Nr.activeStream;if(!h||!h.active){c=requestAnimationFrame(l);return}const u=window.AudioContext||window.webkitAudioContext;n=new u,s=n.createAnalyser(),s.fftSize=256,s.smoothingTimeConstant=.9,a=n.createMediaStreamSource(h),a.connect(s);const f=s.frequencyBinCount,w=new Uint8Array(f),g=new Float32Array(f),p=.2,y=()=>{if(t.current){const A=t.current.clientWidth-32;r.width!==A&&A>0&&(r.width=A)}const b=r.width,m=r.height;i.clearRect(0,0,b,m),s.getByteFrequencyData(w);for(let A=0;A<f;A++){const D=g[A]||0,U=w[A]||0;g[A]=D*p+U*(1-p)}const v=3,_=2,E=Math.floor(b/(v+_)),k=E>0?E%2===0?E-1:E:0;if(k<=0){c=requestAnimationFrame(y);return}const S=(b-k*(v+_))/2,P=Math.floor(k/2);i.fillStyle="#27ba71";const x=38;for(let A=0;A<k;A++){const D=Math.abs(A-P),U=P>0?D/P:0,j=2+Math.floor(Math.pow(U,1.5)*x);let q=g[Math.min(j,f-1)]||0;q=q/255,q=Math.pow(q,2.2);const M=1-U*.8,O=1.5,R=q>.05?Math.sin(Date.now()/300+A)*.5*M:0,be=q*(m-8)*M,ze=Math.max(O,be+R),vt=S+A*(v+_),We=(m-ze)/2;i.beginPath(),i.roundRect(vt,We,v,ze,v/2),i.fill()}c=requestAnimationFrame(y)};y()};return l(),()=>{cancelAnimationFrame(c),a&&a.disconnect(),s&&s.disconnect(),n&&n.state!=="closed"&&n.close()}},[]),o.jsxs("div",{className:"iw-flex iw-flex-col iw-items-end iw-w-full iw-mt-4",children:[o.jsx("div",{className:"iw-px-4 iw-py-1.5 iw-rounded-full iw-mb-2 iw-text-sm iw-font-semibold",style:{color:"#062260",backgroundColor:"#F2E8FE",border:"1px solid #E9D5FF"},children:"You"}),o.jsx("div",{ref:t,className:"iw-w-full iw-p-4 iw-rounded-xl iw-rounded-tr-none iw-flex iw-items-center iw-justify-center",style:{backgroundColor:"#F7F1FE",minHeight:"80px"},children:o.jsx("canvas",{ref:e,height:40,className:"iw-block"})})]})},Gh=({phase:e,questionNumber:t,timerState:r})=>{const{timers:i}=jr();switch(e){case V.FETCHING_QUESTION:return o.jsxs(_l,{children:[o.jsx(Oh,{questionNumber:t+1}),o.jsx(Bh,{})]});case V.ANSWERING:return o.jsxs("div",{className:"iw-flex iw-flex-col iw-items-end iw-w-full",children:[o.jsx(Vh,{}),o.jsx("div",{className:"iw-mt-2 iw-w-full",children:o.jsx(Uh,{timerState:r,answeringTime:i==null?void 0:i.answeringDuration})})]});case V.TRANSCRIBING:return o.jsx(_l,{children:o.jsxs("div",{className:"iw-flex iw-items-center iw-px-1 iw-py-1.5 iw-rounded-lg iw-mb-2 iw-text-sm iw-bg-[#F2E8FE]",children:[o.jsx("div",{className:"iw-h-8 iw-w-12 iw-transcribing-icon"}),o.jsx("span",{className:"iw-text-sm iw-text-[#062260]",children:"Analyzing answer…"})]})});default:return null}},jh=({item:e,index:t,isCurrentQuestion:r=!1,isEditable:i=!1,answerText:n="",onAnswerChange:s,timerState:a,editingTime:c})=>{const l=i&&a&&c!==void 0,h=l||e.answer!=null;return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"iw-flex iw-flex-col iw-items-start",children:[o.jsxs("div",{className:"iw-px-4 iw-py-1.5 iw-rounded-full iw-mb-2 iw-text-sm iw-font-semibold",style:{color:"#062260",backgroundColor:"#E6F3FF",border:"1px solid #BDE0FD"},children:["Q",t+1]}),o.jsx("div",{className:"iw-w-full iw-p-4 iw-rounded-xl iw-text-[#062260] iw-text-base iw-leading-relaxed iw-rounded-tl-none",style:{backgroundColor:"#F1F5FE",border:r?"2px solid #84bbf5":"1px solid transparent"},children:e.question})]}),h&&o.jsxs("div",{className:"iw-flex iw-flex-col iw-items-end iw-mt-4",children:[o.jsx("div",{className:"iw-px-4 iw-py-1.5 iw-rounded-full iw-mb-2 iw-text-sm iw-font-semibold",style:{color:"#062260",backgroundColor:"#F2E8FE",border:"1px solid #E9D5FF"},children:"You"}),l?o.jsx(Ph,{answerText:n||"",onAnswerChange:s,timerState:a,editingTime:c}):o.jsx("div",{className:"iw-w-full iw-p-4 iw-rounded-xl iw-text-[#062260] iw-text-base iw-leading-relaxed iw-rounded-tr-none",style:{backgroundColor:"#F7F1FE"},children:e.answer?e.answer:o.jsx("span",{className:"iw-italic iw-text-[#062260]/60",children:"No response"})})]}),r&&o.jsx(Gh,{phase:a==null?void 0:a.phase,questionNumber:t+1,timerState:a})]})},$h=()=>o.jsx("div",{className:"iw-space-y-6 iw-animate-pulse",children:[1,2,3].map(e=>o.jsxs("div",{className:`iw-flex iw-flex-col ${e%2===0?"iw-items-end":"iw-items-start"} iw-gap-2`,children:[o.jsx("div",{className:"iw-h-8 iw-w-16 iw-bg-gray-200 iw-rounded-full"}),o.jsx("div",{className:"iw-h-24 iw-w-full iw-bg-gray-100 iw-rounded-xl"})]},e))}),zh=({transcript:e,isLoading:t,className:r="",bottomRef:i,isEditing:n,answerText:s,onAnswerChange:a,timerState:c,editingTime:l})=>o.jsxs("div",{className:`iw-h-full iw-flex iw-flex-col iw-bg-white iw-scroll-smooth iw-p-6 iw-pr-2 iw-min-w-32 iw-border iw-rounded-tr-2xl iw-rounded-br-2xl iw-border-[#E8EEFE] ${r}`,children:[o.jsxs("div",{className:"iw-mb-6",children:[o.jsx("h2",{className:"iw-text-lg iw-font-semibold iw-mb-4",style:{color:"#062260"},children:"Interview transcript"}),o.jsx("div",{className:"iw-h-px iw-w-full iw-border-t iw-border-dashed iw-border-gray-300"})]}),o.jsxs("div",{className:"iw-flex-1 iw-overflow-y-auto iw-pr-2 iw-space-y-6 iw-scrollbar-thin iw-max-w-xl iw-pb-5",children:[t?o.jsx($h,{}):e==null?void 0:e.map((h,u)=>o.jsx(jh,{item:h,index:u,isCurrentQuestion:u===(e==null?void 0:e.length)-1,isEditable:!!(u===(e==null?void 0:e.length)-1&&n),answerText:s,onAnswerChange:a||(()=>{}),timerState:c,editingTime:l},h.qna_id)),o.jsx("div",{ref:i})]})]}),Wh=({interviewId:e,className:t="",currentQuestion:r,lastSubmittedAnswer:i,isEditing:n,answerText:s,onAnswerChange:a,timerState:c,editingTime:l})=>{const h=qs(),[u,f]=d.useState([]),[w,g]=d.useState(!0),p=d.useRef(null);return d.useEffect(()=>{var y;(y=p.current)==null||y.scrollIntoView({behavior:"smooth"})},[u,s,c==null?void 0:c.phase]),d.useEffect(()=>{(async()=>{var b;try{const m=await h.getInterviewTranscription(e);f(((b=m==null?void 0:m.data)==null?void 0:b.transcript)||[])}catch(m){console.error("Failed to fetch transcript:",m)}finally{g(!1)}})()},[e,h]),d.useEffect(()=>{r&&f(y=>{if(y.some(v=>v.qna_id===r.qna_id))return y;const m={qna_id:r.qna_id,question:r.question,answer:null,question_generated_at:new Date().toISOString(),answer_submitted_at:null};return[...y,m]})},[r]),d.useEffect(()=>{i?f(y=>y.map(b=>b.qna_id===i.qnaId?{...b,answer:i.answer,answer_submitted_at:new Date().toISOString()}:b)):s&&f(y=>y.map(b=>b.qna_id===(i==null?void 0:i.qnaId)?{...b,answer:s,answer_submitted_at:new Date().toISOString()}:b))},[i,s]),o.jsx(zh,{transcript:u,isLoading:w||(u==null?void 0:u.length)===0,className:t,bottomRef:p,isEditing:n,answerText:s,onAnswerChange:a,timerState:c,editingTime:l})},Ys=5,Xs=5;function Hh({isOpen:e,onClose:t,warningCount:r,violationType:i,onDisqualify:n}){const[,s]=d.useState(Xs),a=d.useRef(t),c=d.useRef(n),l=d.useRef(r);if(d.useEffect(()=>{a.current=t,c.current=n,l.current=r},[t,n,r]),d.useEffect(()=>{if(!e)return;const w=setInterval(()=>{s(g=>g<=1?(l.current+1>Ys?c.current():a.current(),Xs):g-1)},1e3);return()=>clearInterval(w)},[e]),d.useEffect(()=>{e&&s(Xs)},[e]),!e)return null;const h=()=>{switch(i){case"tab_switch":return"Attempted tab switch/reload";case"fullscreen_exit":return"Attempted to exit full screen mode";case"focus_loss":return"Lost focus from interview window";case"blocked_shortcut":return"Used a blocked keyboard shortcut";case"right_click_attempt":return"Attempted right click";case"alt_tab_attempt":return"Attempted Alt + Tab";case"blocked_function_key":return"Attempted to use function key";default:return"Attempted right click/tab switch"}},u=Ys-r,f=()=>{r+1>Ys?n():t()};return o.jsx("div",{className:"iw-absolute iw-bottom-20 iw-left-4 iw-right-4 md:iw-right-auto md:iw-w-[480px] iw-z-50 iw-animate-in iw-fade-in iw-slide-in-from-bottom-4 iw-duration-300",children:o.jsxs("div",{className:"iw-relative iw-overflow-hidden iw-rounded-xl iw-border iw-border-dashed iw-border-[#E94315] iw-bg-[#FFEBE6] iw-p-4 iw-shadow-2xl iw-backdrop-blur-sm",children:[o.jsx("button",{onClick:f,className:"iw-absolute iw-right-3 iw-top-3 iw-text-gray-400 iw-transition-colors iw-hover:iw-text-gray-600",children:o.jsx(_i,{className:"iw-h-5 iw-w-5"})}),o.jsxs("div",{className:"iw-flex iw-items-start iw-gap-3",children:[o.jsx("div",{className:"iw-flex iw-h-10 iw-w-10 iw-flex-shrink-0 iw-items-center iw-justify-center iw-rounded-full iw-border iw-border-[#FDCBBD]",children:o.jsx(xi,{className:"iw-h-5 iw-w-5 iw-text-red-500"})}),o.jsxs("div",{className:"iw-flex-1 iw-pt-0.5",children:[o.jsxs("h2",{className:"iw-text-[20px] iw-font-semibold iw-leading-tight iw-text-[#E94315]",children:["You have ",u>0?u:0," warning",u>1?"s":""," left"]}),o.jsx("p",{className:"iw-mt-1.5 iw-text-lg iw-text-[#5C6686]",children:h()}),o.jsx("div",{className:"iw-mt-3 iw-border-t iw-border-dashed iw-border-red-200 iw-pt-3",children:u===1?o.jsx("p",{className:"iw-text-[14px] iw-font-bold iw-text-[#062260]",children:"Next violation will disqualify you from this interview and automatically end the interview"}):o.jsx("p",{className:"iw-text-[14px] iw-font-bold iw-text-[#062260]",children:"Interview will end automatically after final warning"})})]})]})]})})}const qh=e=>o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...e,children:[o.jsx("path",{d:"M9 9.003a1 1 0 0 1 1.517-.859l4.997 2.997a1 1 0 0 1 0 1.718l-4.997 2.997A1 1 0 0 1 9 14.996z"}),o.jsx("circle",{cx:"12",cy:"12",r:"10"})]}),kl=({isOpen:e,onClose:t,children:r,title:i,showCloseButton:n=!0,closeOnOverlayClick:s=!0,closeOnEscape:a=!0,className:c=""})=>{if(d.useEffect(()=>{if(!e||!a)return;const u=f=>{f.key==="Escape"&&t()};return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[e,a,t]),d.useEffect(()=>(e?(document.body.style.overflow="hidden",document.body.classList.add("interview-widget-container")):(document.body.style.overflow="unset",document.body.classList.remove("interview-widget-container")),()=>{document.body.style.overflow="unset",document.body.classList.remove("interview-widget-container")}),[e]),!e)return null;const l=u=>{s&&u.target===u.currentTarget&&t()},h=o.jsxs("div",{className:"interview-widget-container",style:{position:"fixed",inset:0,zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center"},children:[o.jsx("div",{style:{position:"fixed",inset:0,backgroundColor:"rgba(0, 0, 0, 0.5)",transition:"opacity 0.2s"},onClick:l}),o.jsxs("div",{className:`iw-relative iw-bg-white iw-rounded-lg iw-shadow-xl iw-max-w-md iw-w-full iw-mx-4 iw-max-h-[90vh] iw-overflow-hidden ${c}`,role:"dialog","aria-modal":"true","aria-labelledby":i?"standalone-dialog-title":void 0,style:{zIndex:1e4},children:[(i||n)&&o.jsxs("div",{className:"iw-flex iw-items-center iw-justify-between iw-p-4 iw-border-b iw-border-gray-200",children:[i&&o.jsx("h2",{id:"standalone-dialog-title",className:"iw-text-lg iw-font-semibold iw-text-gray-900",children:i}),n&&o.jsx("button",{onClick:t,className:"iw-p-1 iw-text-gray-400 iw-hover:text-gray-600 iw-transition-colors iw-rounded iw-hover:bg-gray-100","aria-label":"Close dialog",children:o.jsx("svg",{className:"iw-w-5 iw-h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),o.jsx("div",{className:"iw-p-4 iw-overflow-y-auto",children:r})]})]});return Nl.createPortal(h,document.body)},Kh=({showHardReloadWarning:e,onContinue:t})=>{const r=()=>{t()};return o.jsxs(kl,{isOpen:e,onClose:r,closeOnOverlayClick:!1,closeOnEscape:!1,showCloseButton:!1,className:"iw-max-w-lg iw-px-2 iw-rounded-xl",children:[o.jsx("div",{className:"iw-absolute iw-inset-x-0 iw-top-0 iw-h-1 iw-bg-gradient-to-r iw-from-red-500 iw-to-red-600"}),o.jsx("div",{className:"iw-space-y-1 iw-pb-2 iw-pt-3",children:o.jsxs("div",{className:"iw-flex iw-items-center iw-gap-2",children:[o.jsx(xi,{className:"iw-w-5 iw-h-5 iw-text-red-500"}),o.jsx("h3",{className:"iw-text-xl iw-font-semibold iw-text-red-500",children:"Full Screen Exit Detected"})]})}),o.jsx("div",{className:"iw-pt-4 iw-pb-6",children:o.jsx("p",{className:"iw-text-center iw-text-sm iw-leading-relaxed iw-text-gray-500/90",children:"Exiting full screen mode or reloading this page during the session is strictly prohibited. Any attempt to do so will be recorded and may lead to penalties."})}),o.jsx("div",{className:"iw-pt-2 iw-pb-4",children:o.jsxs("button",{onClick:r,className:"iw-w-full iw-flex iw-items-center iw-justify-center iw-gap-2 iw-px-4 iw-py-3 iw-bg-gray-100 iw-text-gray-600 iw-rounded-md iw-font-medium iw-transition-colors hover:iw-bg-gray-200 focus:iw-outline-none focus:iw-ring-2 focus:iw-ring-gray-400 focus:iw-ring-offset-2",children:[o.jsx(qh,{className:"iw-size-4"}),"Continue Session"]})})]})},Sl=({confirmExitInterview:e,isOpen:t,onClose:r})=>o.jsxs(kl,{isOpen:t,onClose:r,showCloseButton:!1,closeOnOverlayClick:!1,className:"iw-max-w-xl iw-border-2 iw-border-dashed iw-rounded-xl iw-border-[#6296FB]",children:[o.jsxs("div",{className:"iw-p-4",children:[o.jsx("h2",{className:"iw-text-xl iw-font-semibold iw-text-[#062260]",children:"Are you sure you want to leave interview?"}),o.jsx("p",{className:"iw-mt-2 iw-text-[#667085] iw-line-clamp-2",children:"If you exit now, the interview will be terminated and cannot be resumed."})]}),o.jsx("div",{className:"iw-my-0 iw-h-px iw-m-6 iw-border-t iw-border-dashed iw-border-[#B3B9CB]"}),o.jsxs("div",{className:"iw-flex iw-justify-center iw-gap-4 iw-p-4",children:[o.jsx(cn,{className:"iw-px-8 iw-py-3 iw-rounded-xl !iw-bg-[#E94315] !iw-text-white !iw-font-bold !iw-shadow-md !hover:iw-opacity-70",onClick:e,children:"Leave"}),o.jsx(cn,{onClick:r,className:"iw-px-6 iw-py-3 iw-rounded-xl !iw-bg-[#F1F5FE] !iw-text-[#062260] !iw-font-bold !iw-border !iw-border-[#E7EAF1] !iw-shadow-md hover:iw-opacity-70",children:"Stay in Interview"})]})]}),Al=d.createContext(null),Yh=()=>{const e=d.useContext(Al);return e||{violationCount:0,violationType:"fullscreen_exit",showWarningModal:!1,setShowWarningModal:()=>{},handleClose:()=>{},handleDisqualify:()=>{},handleUnintendedExit:()=>{}}},Xh=d.forwardRef(({children:e,onDisqualify:t,onExit:r,isCompleted:i},n)=>{const[s,a]=d.useState(!1),[c,l]=d.useState(!1),[h,u]=d.useState(!1),[f,w]=d.useState(!1),[g,p]=d.useState("fullscreen_exit"),{logViolation:y,violationCount:b}=_h({maxViolations:5,onViolation:x=>{!h&&!i&&!f&&(a(!0),p(x.type))}}),{enterFullScreen:m,isFullScreen:v,exitFullScreen:_}=fh({onFullScreenChange(x){!x&&!h&&!f&&!i&&(a(!0),y({type:"fullscreen_exit",severity:"high",details:{action:"fullscreen_exit",reason:"Attempted to exit full screen mode"}})),x&&w(!1)}});d.useEffect(()=>{m()},[]),d.useImperativeHandle(n,()=>({exitFullScreenIntentionally:async()=>{w(!0),a(!1),u(!1);try{document.fullscreenElement&&await document.exitFullscreen()}catch(x){console.error("Failed to exit fullscreen:",x)}}}),[]),mh(y),gh(y),yh(),kh();const{proctoring:E}=jr(),k=(E==null?void 0:E.prevent_unintended_exit)??!1;d.useEffect(()=>{const x=()=>{if(!(h||f||i)){if(k)l(!0);else if(window.confirm("Leave site? Changes you made may not be saved.")){Ir(),window.history.back();return}window.history.pushState(null,"",window.location.href)}},A=U=>{if(!(h||f||i))return console.log("User attempted to reload or close the tab"),k&&l(!0),U.preventDefault(),U.returnValue="",""},D=()=>{f||Ir()};return window.history.pushState(null,"",window.location.href),window.addEventListener("popstate",x),window.addEventListener("beforeunload",A),window.addEventListener("unload",D),()=>{window.removeEventListener("popstate",x),window.removeEventListener("beforeunload",A),window.removeEventListener("unload",D)}},[h,f,i,k,Ir]);const S=()=>{Ir(),u(!0),_(),a(!1),l(!1),t==null||t()},P=()=>{Ir(),l(!1),r==null||r()};return o.jsxs(Al.Provider,{value:{violationCount:b,violationType:g,showWarningModal:s,setShowWarningModal:a,handleClose:()=>{a(!1),m()},handleDisqualify:S,handleUnintendedExit:()=>{l(!0)}},children:[o.jsx("div",{className:"iw-relative iw-h-full iw-w-full",children:e}),o.jsx(Sl,{isOpen:c,onClose:()=>{l(!1)},confirmExitInterview:()=>{P()}}),!v&&b>0&&!h&&!f&&o.jsx(Kh,{showHardReloadWarning:!0,logViolation:y,onContinue:m})]})}),Qh=({onClick:e,text:t="Submit response",disabled:r=!1,isFirstQuestion:i=!1})=>(d.useEffect(()=>{if(typeof window>"u")return;const n=s=>{const a=s.key==="Enter",c=s.target;if(!(c.tagName==="INPUT"||c.isContentEditable)&&a){if(r)return;s.preventDefault(),e()}};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[e,r]),o.jsxs("div",{className:"iw-fixed iw-bottom-10 iw-left-1/4 iw-transform iw--translate-x-1/2 iw-z-50",children:[i&&o.jsxs("div",{className:"iw-absolute iw-bottom-full iw-left-0 iw-transform iw--translate-x-1/2 iw-mb-3 iw-px-3 iw-py-2 iw-border iw-border-[#ecedee] iw-bg-[#ecedee] iw-text-black iw-text-[12px] iw-rounded-lg iw-whitespace-nowrap iw-animate-bounce iw-shadow-xl",children:["You can click here to submit your response",o.jsx("div",{className:"iw-absolute iw-top-full iw-left-1/2 iw-transform iw--translate-x-1/2 iw-border-8 iw-border-transparent iw-border-t-[#ecedee]"})]}),o.jsxs("button",{disabled:r,onClick:e,className:`iw-flex iw-items-center iw-gap-3 iw-text-white iw-px-5 iw-py-3 iw-rounded-lg iw-shadow-lg iw-transition-all iw-duration-200 iw-group ${r?"iw-bg-[#4C6CFF]/60 iw-cursor-not-allowed":"iw-bg-[#4C6CFF] hover:iw-bg-[#4c6dffd5]"} ${i?"iw-animate-speaking iw-ring-4 iw-ring-[#4C6CFF]/30 iw-scale-105":""}`,children:[o.jsx("span",{className:"iw-font-semibold iw-text-sm",children:t}),o.jsx("span",{className:"iw-bg-white/90 iw-text-[#062260] iw-px-2 iw-py-1 iw-rounded iw-text-xs iw-font-mono iw-font-bold group-hover:iw-bg-white iw-transition-colors",children:"Press Enter"})]})]})),Jh=({brandName:e,brandLogo:t,currentQuestion:r,state:i,phase:n,className:s="",interviewId:a="",interview_duration:c=bi,videoFeedRef:l,lastSubmittedAnswer:h,onNextPhase:u,answerText:f,onAnswerChange:w,editingTime:g,disableSubmitButton:p=!1})=>{const{showWarningModal:y,violationCount:b,violationType:m,handleClose:v,handleDisqualify:_}=Yh();return o.jsxs("div",{className:`iw-px-4 iw-py-3 ${s} iw-h-[calc(100vh_-_120px)] iw-max-h-[calc(100vh_-_120px)] iw-flex iw-gap-0 iw-relative`,children:[o.jsxs("div",{className:"iw-flex iw-flex-col iw-flex-1 iw-p-5 iw-bg-white/50 iw-border iw-border-[#E8EEFE] iw-rounded-s-3xl iw-overflow-hidden",children:[o.jsx("div",{className:"iw-flex iw-items-start iw-justify-between iw-gap-3 iw-mb-4",children:o.jsx("div",{className:"iw-flex-1",children:o.jsx(Fh,{question:r,isLoading:n===V.FETCHING_QUESTION||n===V.IDLE,phase:n,brandName:e,brandLogo:t})})}),o.jsxs("div",{className:"iw-flex-1 iw-min-h-0 iw-rounded-[16px] iw-overflow-hidden iw-relative",children:[o.jsx(yl,{ref:l,interviewId:a,interview_duration:c,isAnswering:n===V.ANSWERING,cheatingWarningVisible:y}),o.jsx(Hh,{isOpen:y,warningCount:b,violationType:m,onClose:v,onDisqualify:_})]})]}),o.jsx("div",{className:"iw-interview-transcription iw-w-1/4 iw-min-w-32 iw-h-full",children:o.jsx(Wh,{interviewId:a,currentQuestion:r,lastSubmittedAnswer:h,isEditing:n===V.EDITING,answerText:f,onAnswerChange:w,timerState:i,editingTime:g})}),u&&(n===V.ANSWERING||n===V.EDITING)&&o.jsx(Qh,{onClick:u,disabled:p,isFirstQuestion:(i==null?void 0:i.currentQuestionNumber)===1,text:n===V.ANSWERING?"Submit Response":"Submit Final Response"})]})},Zh=({title:e,brandName:t,brandLogo:r,onExit:i,totalDuration:n=30,elapsedTime:s=0})=>{const[a,c]=d.useState(!1),l=Math.min(s/(n*60)*100,100),h=()=>o.jsxs("div",{className:"iw-px-4 iw-pb-2 iw-flex iw-items-center iw-gap-3",children:[o.jsx("div",{className:"iw-flex-1 iw-h-4 iw-bg-[#F2F4F7] iw-rounded-full iw-overflow-hidden iw-border iw-border-blue-100 iw-relative",children:o.jsx("div",{className:"iw-h-full iw-bg-[#0EB00E] iw-rounded-full iw-transition-all iw-duration-1000 iw-ease-linear",style:{width:`${l}%`}})}),o.jsxs("div",{className:"iw-text-sm iw-font-medium iw-whitespace-nowrap",children:[o.jsx("span",{className:"iw-text-[#062260]",children:vn(s)}),o.jsxs("span",{className:"iw-text-[#667085]",children:["/",n," Min"]})]})]});return o.jsxs("header",{className:"iw-w-full iw-text-gray-900 iw-shadow-sm",children:[o.jsxs("div",{className:"iw-mx-auto iw-flex iw-items-center iw-justify-between iw-p-4 iw-pt-1 iw-mb-2 iw-border-b iw-border-[#B3B9CB] iw-border-dashed",children:[o.jsxs("div",{className:"iw-flex iw-items-center iw-space-x-2",children:[o.jsx(xn,{brandLogo:r,brandName:t}),o.jsx("p",{className:"iw-text-xl iw-font-semibold",children:t})]}),o.jsx("h1",{className:"iw-text-2xl iw-font-semibold iw-text-gradient-silver",children:e}),o.jsx("button",{className:"iw-text-sm iw-text-[#E94315] iw-min-w-10 iw-rounded-md hover:iw-bg-orange-100 iw-p-2",onClick:()=>c(!0),children:o.jsxs("span",{className:"iw-flex iw-items-center iw-gap-1 iw-text-[18px] iw-font-semibold iw-whitespace-nowrap",children:[o.jsx(_i,{className:"iw-text-[#E94315] iw-size-5"}),"Leave interview"]})})]}),o.jsx(h,{}),o.jsx("div",{className:"iw-h-px iw-bg-gray-200"}),o.jsx(Sl,{isOpen:a,confirmExitInterview:()=>{i(),c(!1)},onClose:()=>c(!1)})]})},Rh=({className:e="",width:t,height:r=56,barWidth:i=3,gap:n=2,fftSize:s=1024,smoothingTimeConstant:a=.8,mediaStream:c,startOnMount:l=!0})=>{const{baseColor:h}=Rt(),u=d.useRef(null),f=d.useRef(null),w=d.useRef(null),g=d.useRef(null),p=d.useRef(null),y=d.useRef(null),b=d.useRef(!1),[m,v]=d.useState(null);d.useEffect(()=>{if(t||!f.current)return;const E=f.current,k=()=>{const P=u.current;if(!P)return;const x=E.clientWidth,A=r;P.width=Math.max(1,Math.floor(x*window.devicePixelRatio||1)),P.height=Math.max(1,Math.floor(A*window.devicePixelRatio||1))},S=new ResizeObserver(k);return S.observe(E),k(),()=>S.disconnect()},[t,r]),d.useEffect(()=>{if(!t)return;const E=u.current;E&&(E.width=Math.max(1,Math.floor(t*(window.devicePixelRatio||1))),E.height=Math.max(1,Math.floor(r*(window.devicePixelRatio||1))))},[t,r]),d.useEffect(()=>{let E=!1;return(async()=>{try{const S=new(window.AudioContext||window.webkitAudioContext);w.current=S;let P=c;if(!P){if(!l)return;P=await navigator.mediaDevices.getUserMedia({audio:!0,video:!1}),b.current=!0}if(E)return;const x=S.createAnalyser();x.fftSize=s,x.smoothingTimeConstant=a,g.current=x;const A=S.createMediaStreamSource(P);p.current=A,A.connect(x),_()}catch(S){v((S==null?void 0:S.message)||"Failed to initialize microphone")}})(),()=>{var S,P,x,A;E=!0,y.current&&cancelAnimationFrame(y.current);try{(S=p.current)==null||S.disconnect()}catch{}try{(P=g.current)==null||P.disconnect()}catch{}b.current&&((A=((x=p.current)==null?void 0:x.mediaStream)||void 0)==null||A.getTracks().forEach(D=>D.stop())),w.current&&w.current.state!=="closed"&&w.current.close()}},[c,s,a,l]);const _=()=>{const E=u.current,k=g.current;if(!E||!k)return;const S=E.getContext("2d");if(!S)return;const P=window.devicePixelRatio||1,x=E.width,A=E.height,D=k.frequencyBinCount,U=new Uint8Array(D),j=()=>{y.current=requestAnimationFrame(j),k.getByteTimeDomainData(U),S.clearRect(0,0,x,A),S.fillStyle="rgba(0,0,0,0)",S.fillRect(0,0,x,A);const q=Math.max(1,Math.floor(i*P)),M=Math.max(1,Math.floor(n*P)),O=q+M,R=Math.max(8,Math.floor((x+M)/O)),be=Math.floor(U.length/R);for(let ze=0;ze<R;ze++){const vt=Math.min(U.length-1,ze*be),We=U[vt]/128-1,He=Math.abs(We),ft=Math.pow(He,.6),Lt=Math.max(A*.06,ft*(A*.9)),Fr=ze*O,Lr=(A-Lt)/2,Mr=140-Math.min(140,140*He),Dr=85,Pr=48+Math.floor(12*(1-He));S.fillStyle=`${h}`,S.shadowColor=`hsla(${Mr}, ${Dr}%, ${Pr}%, ${.25*He})`,S.shadowBlur=8*He;const Qt=Math.min(q/2,Lt/2);e2(S,Fr,Lr,q,Lt,Qt),S.fill()}};j()};return o.jsxs("div",{ref:f,className:`iw-relative iw-w-full iw-overflow-hidden iw-rounded-md iw-bg-gray-50 ${e}`,style:{height:r},children:[o.jsx("canvas",{ref:u,className:"iw-w-full iw-h-full"}),m&&o.jsx("div",{className:"iw-absolute iw-inset-0 iw-flex iw-items-center iw-justify-center",children:o.jsx("span",{className:"iw-text-xs iw-text-red-600 iw-bg-red-50 iw-border iw-border-red-200 iw-px-2 iw-py-1 iw-rounded",children:m})})]})};function e2(e,t,r,i,n,s){const a=Math.min(s,i/2,n/2);e.beginPath(),e.moveTo(t+a,r),e.lineTo(t+i-a,r),e.quadraticCurveTo(t+i,r,t+i,r+a),e.lineTo(t+i,r+n-a),e.quadraticCurveTo(t+i,r+n,t+i-a,r+n),e.lineTo(t+a,r+n),e.quadraticCurveTo(t,r+n,t,r+n-a),e.lineTo(t,r+a),e.quadraticCurveTo(t,r,t+a,r),e.closePath()}const t2=({state:e,answeringTime:t,nextPhase:r,sttError:i,disableStopButton:n=!1})=>o.jsxs("div",{className:"iw-flex iw-flex-col iw-justify-between iw-h-full ",children:[o.jsxs("div",{children:[o.jsxs("div",{className:"iw-flex iw-items-center iw-justify-between",children:[o.jsx("h3",{className:"iw-text-lg iw-font-semibold iw-text-gray-900 iw-mb-1",children:"You may start speaking now. We're listening...."}),o.jsxs("div",{className:"iw-flex iw-items-center iw-justify-center iw-gap-2",children:[o.jsxs("div",{className:"iw-flex iw-items-center iw-gap-1",children:[o.jsx(so,{className:"iw-size-4 iw-text-orange-600"}),o.jsx("p",{className:"iw-text-gray-700 iw-text-sm",children:"Time to talk: "})]}),o.jsx(dn,{total:t,remaining:e.currentPhaseTimeRemaining,size:50,strokeWidth:4})]})]}),o.jsx("p",{className:"iw-max-w-lg iw-text-gray-500 iw-text-xs iw-leading-[21px]",children:"Done talking? Click the button to review your answer."})]}),o.jsxs("div",{children:[o.jsx(Rh,{}),i&&o.jsxs("div",{className:"iw-mt-2 iw-text-xs iw-text-red-600",children:["Recording error: ",i.message]})]}),o.jsx("div",{className:"iw-w-full iw-grid iw-grid-cols-1",children:o.jsx(ln,{disabled:n,onClick:()=>{r()},children:"Transcribe My Answer"})})]});function r2(){const[e,t]=d.useState(!0),r=d.useMemo(()=>[0,1,2].map(i=>({id:i})),[]);return d.useEffect(()=>{const i=setInterval(()=>{t(n=>!n)},1500);return()=>clearInterval(i)},[]),o.jsxs("div",{className:"iw-flex iw-flex-col iw-items-center iw-justify-center iw-gap-8 iw-h-full",children:[o.jsx("div",{className:"iw-relative iw-w-80 iw-h-48 ","aria-hidden":!0,children:r.map((i,n)=>{const s=n*50,a=e?s:s+12,c=e?1:.08,l=n*140;return o.jsx("div",{role:"presentation",className:"iw-absolute iw-w-full iw-rounded-lg iw-p-4 iw-shadow-md iw-bg-gradient-to-b iw-from-gray-50 iw-to-gray-100 iw-overflow-hidden",style:{top:0,transform:`translateY(${a}px)`,opacity:c,transition:`transform 600ms cubic-bezier(.2,.9,.3,1) ${l}ms, opacity 400ms ease ${l}ms`},children:o.jsxs("div",{className:"iw-flex iw-gap-3 iw-items-center",children:[o.jsx("div",{className:"iw-w-10 iw-h-10 iw-bg-gray-300 iw-rounded iw-flex-shrink-0"}),o.jsxs("div",{className:"iw-flex-1 iw-space-y-2",children:[o.jsx("div",{className:"iw-h-2 iw-bg-gray-300 iw-rounded iw-w-24"}),o.jsx("div",{className:"iw-h-2 iw-bg-gray-300 iw-rounded iw-w-32"})]})]})},i.id)})}),o.jsx("div",{className:"iw-text-center",children:o.jsx("p",{className:"iw-text-gray-500 iw-font-medium",children:"Preparing your question..."})})]})}const i2=({size:e="192px",className:t,colors:r,animationDuration:i=20})=>{const s={...{bg:"oklch(95% 0.02 264.695)",c1:"oklch(75% 0.15 350)",c2:"oklch(80% 0.12 200)",c3:"oklch(78% 0.14 280)"},...r},a=parseInt(e.replace("px",""),10),c=a<50?Math.max(a*.008,1):Math.max(a*.015,4),l=a<50?Math.max(a*.004,1.2):Math.max(a*.008,1.5),h=a<50?Math.max(a*.004,.05):Math.max(a*.008,.1),u=a<50?Math.max(a*.004,.5):Math.max(a*.008,2),f=a<30?"0%":a<50?"5%":a<100?"15%":"25%",w=a<30?1.1:a<50?Math.max(l*1.2,1.3):l;return o.jsx("div",{className:`siri-orb ${t}`,style:{width:e,height:e,"--bg":s.bg,"--c1":s.c1,"--c2":s.c2,"--c3":s.c3,"--animation-duration":`${i}s`,"--blur-amount":`${c}px`,"--contrast-amount":w,"--dot-size":`${h}px`,"--shadow-spread":`${u}px`,"--mask-radius":f},children:o.jsx("style",{children:`
|
|
75
75
|
@property --angle {
|
|
76
76
|
syntax: "<angle>";
|
|
77
77
|
inherits: false;
|
|
@@ -176,4 +176,4 @@
|
|
|
176
176
|
animation: none;
|
|
177
177
|
}
|
|
178
178
|
}
|
|
179
|
-
`})})};function i2({ttsError:e}){return o.jsxs("div",{className:"iw-flex iw-flex-col iw-items-center iw-justify-center iw-gap-8 iw-w-full iw-h-full",children:[o.jsx(r2,{size:"80px"}),e&&o.jsxs("div",{className:"iw-mt-2 iw-text-xs iw-text-red-600",children:["Audio playback failed: ",e.message]}),o.jsx("p",{className:"iw-text- iw-text-gray-700",children:"Your AI interviewer is speaking..."})]})}const n2=({state:e,thinkingTime:t,nextPhase:r})=>o.jsxs("div",{className:"iw-flex iw-flex-col iw-gap-6 iw-items-center iw-justify-center iw-text-center iw-h-full ",children:[o.jsxs("div",{children:[o.jsx("h3",{className:"iw-text-lg iw-font-semibold iw-text-gray-900 iw-mb-1",children:"Get Ready to Answer"}),o.jsx("p",{className:"iw-max-w-lg iw-text-gray-500 iw-text-xs iw-leading-[21px]",children:"After 30-seconds thinking time, recording will start automatically, or you can begin recording early by clicking the button below."})]}),o.jsxs("div",{className:"iw-flex iw-items-center iw-justify-center iw-gap-2",children:[o.jsxs("div",{className:"iw-flex iw-items-center iw-gap-1",children:[o.jsx(no,{className:"iw-size-4 iw-text-orange-600"}),o.jsx("p",{className:"iw-text-gray-700 iw-text-sm",children:"Time to think: "})]}),o.jsx(ln,{total:t,remaining:e.currentPhaseTimeRemaining,size:50,strokeWidth:4})]}),o.jsx("div",{className:"iw-w-full iw-grid iw-grid-cols-1",children:o.jsx(cn,{onClick:()=>{r()},children:"Start Answering"})})]}),s2=({sttError:e,editingDuration:t})=>o.jsxs("div",{className:"iw-flex iw-flex-col iw-items-center iw-justify-center iw-h-full",children:[o.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 60 60",fill:"none",children:[o.jsx("rect",{width:60,height:60,rx:30,fill:"url(#prefix__paint0_linear_1460_12482)"}),o.jsx("path",{d:"M28.127 14c.276 7.685 6.442 13.851 14.127 14.127-7.684.276-13.85 6.442-14.127 14.127-.275-7.685-6.442-13.851-14.126-14.127 7.684-.276 13.85-6.442 14.126-14.127zM38.937 31.873A7.331 7.331 0 0046 38.937 7.331 7.331 0 0038.937 46a7.331 7.331 0 00-7.064-7.063 7.331 7.331 0 007.064-7.064z",fill:"#fff"}),o.jsx("defs",{children:o.jsxs("linearGradient",{id:"prefix__paint0_linear_1460_12482",x1:30,y1:-6.563,x2:77.813,y2:54.375,gradientUnits:"userSpaceOnUse",children:[o.jsx("stop",{offset:.211,stopColor:"#5C92FA"}),o.jsx("stop",{offset:1,stopColor:"#A75FFD"})]})})]}),o.jsx("h3",{className:"iw-text-lg iw-font-semibold iw-text-gray-900 iw-mb-1 iw-mt-3",children:"Just a moment... We're analyzing your response"}),o.jsxs("p",{className:"iw-max-w-lg iw-text-gray-500 iw-text-xs iw-leading-[21px]",children:["After transcription, you'll have ",t||30," sec to review your answer."]}),e&&o.jsxs("div",{className:"iw-mt-2 iw-text-xs iw-text-red-600",children:["Transcription error: ",e.message,e.recoverable&&" (attempting to continue)"]})]}),o2=({interviewTitle:e,brandName:t="Novara",brandLogo:r,interviewId:i,onComplete:n,onDisqualify:s,className:a="",videoFeedRef:c})=>{var gi,un;const l=Hs(),{baseUrl:h,authToken:u}=io(),{timers:f,stt:w,proctoring:g}=Gr(),p=d.useRef(null),[y,b]=d.useState(null),[m,v]=d.useState(""),[k,_]=d.useState(null),[S,E]=d.useState(yi),[P,C]=d.useState(!0),x=d.useRef(""),M=d.useRef(null),U={thinkingTime:(f==null?void 0:f.thinkingDuration)||0,answeringTime:(f==null?void 0:f.answeringDuration)||120,editingTime:P?(f==null?void 0:f.editingDuration)||30:0},{thinkingTime:V,answeringTime:q,editingTime:D}=U;d.useEffect(()=>{x.current=m},[m]);const[O,R]=d.useState(!1),be=d.useRef(!1),{speak:ze,stop:ft,error:We}=xh({onEnd:()=>{be.current=!1,ne()},onError:()=>{be.current||(be.current=!0,ne())}}),He=d.useRef(!1),wt=d.useRef(!1),{startRecording:Lt,stopRecording:Ir,transcribe:Fr,cancelRecording:Lr,isRecording:Mr,error:Dr,audioBlob:Qt}=gh({config:{baseUrl:h,provider:w==null?void 0:w.provider,model:w==null?void 0:w.model,language:w==null?void 0:w.language,authToken:u,qnaId:((gi=M.current)==null?void 0:gi.qna_id)||"",interviewId:i},onStart:()=>{He.current=!1,wt.current=!1},onStop:()=>{},onTranscriptionComplete:B=>{const $=B.transcript;v($),x.current=$,wt.current||(wt.current=!0,ne())},onError:B=>{console.error("STT Error:",B),He.current||(He.current=!0,ne())}}),{state:Ie,startQuestion:Mt,nextPhase:ne,completeInterview:ci,timerService:Pr}=bh({config:{answeringDuration:q,editingDuration:D},callbacks:{onPhaseChange:B=>{switch(B){case G.FETCHING_QUESTION:Jt();break;case G.READING_QUESTION:Qs();break;case G.ANSWERING:dn();break;case G.TRANSCRIBING:di();break;case G.SUBMITTING:li();break}},onInterviewEnd:()=>{n==null||n()}}});d.useEffect(()=>{Mt()},[]),d.useEffect(()=>{(async()=>{try{const $=await l.getInterviewConfig(i);if($!=null&&$.data&&($.data.duration_in_minutes&&E($.data.duration_in_minutes),typeof $.data.allow_answer_editing=="boolean"&&C($.data.allow_answer_editing),typeof $.data.elapsed_time_in_minutes=="number")){const Ze=Math.floor($.data.elapsed_time_in_minutes*60);Pr.setTotalTimeElapsed(Ze)}}catch($){console.error("Failed to fetch interview config:",$)}})()},[i,Pr]);const{execute:Jt,error:Or}=uh(async()=>{const B=await l.generateQuestion({interviewId:i});return M.current=B.data,B},{onSuccess:async B=>{B&&B.data&&(v(""),x.current="",b(B.data),ne())},onError:B=>{console.error("Failed to fetch questions:",B)}}),li=d.useCallback(async()=>{var B;try{const $=x.current,Ze=((B=M.current)==null?void 0:B.qna_id)||"";P&&await l.submitAnswer({interviewId:i,qnaId:Ze,answer:$}),_({qnaId:Ze,answer:$})}catch($){console.error("Failed to submit answer:",$)}Mt()},[l,i,Mt,P]),Qs=d.useCallback(async()=>{var B,$;if((B=M.current)!=null&&B.question)if(M.current.question_audio_data_base64)try{be.current=!1,await ze(M.current.question_audio_data_base64),M.current.is_interview_done&&(ft(),Lr(),c&&"current"in c&&(($=c.current)==null||$.stopCamera()),ci())}catch(Ze){console.error("Failed to speak question:",Ze)}else console.warn("No audio data available for question"),await Wl(2e3),ne();else ne()},[ze,ne,ci]),dn=d.useCallback(async()=>{try{await Lt(q)}catch(B){if((B==null?void 0:B.code)==="ALREADY_RECORDING"){console.warn("startRecording called while already recording — ignoring duplicate call.");return}console.error("Failed to start recording:",B),ne()}},[Lt,ne,q]),di=d.useCallback(async()=>{if(O){console.warn("Audio processing already in progress, ignoring duplicate call");return}R(!0);try{const B=!Mr&&Qt?Qt:await Ir();await Fr(B)}catch(B){console.error("STT processing failed:",B),!He.current&&!wt.current&&(He.current=!0,ne())}finally{R(!1)}},[O,Mr,Qt,Ir,Fr,ne,i,Pr]),ui=d.useCallback(()=>{O||ne()},[O,ne]),hi=d.useCallback(async B=>{var $,Ze;ft(),Lr(),c&&"current"in c&&(($=c.current)==null||$.stopCamera()),await((Ze=p.current)==null?void 0:Ze.exitFullScreenIntentionally());try{await l.exitInterview(i)}catch(hn){console.error("API call failed:",hn)}finally{B==null||B(),ci(),sessionStorage.removeItem(pn)}},[i,ft,l]),fi=()=>{const{phase:B}=Ie;switch(B){case G.IDLE:return o.jsxs("div",{className:"iw-text-center iw-flex iw-flex-col iw-items-center iw-justify-center iw-gap-2 iw-h-full",children:[o.jsx("h3",{className:"iw-text-lg iw-font-semibold iw-text-gray-900 iw-mb-1",children:"Ready to start the Interview?"}),o.jsx("p",{className:"iw-max-w-xl iw-text-gray-500 iw-text-xs iw-leading-[21px]",children:`You will be asked a series of behavioral and technical questions. For each one you'll get a short thinking period, then a timed recording window. We'll transcribe your response so you can review and edit it before submitting. Click "Start Interview" when you're ready.`}),o.jsx(cn,{onClick:Mt,className:"iw-mt-2 iw-w-40",children:"Start Interview"})]});case G.FETCHING_QUESTION:return Or?o.jsxs("div",{className:"iw-text-center iw-flex iw-flex-col iw-items-center iw-justify-center iw-gap-2 iw-h-full",children:[o.jsx("h3",{className:"iw-text-lg iw-font-semibold iw-text-red-600 iw-mb-1",children:"Failed to load the next question"}),o.jsx("p",{className:"iw-max-w-md iw-text-gray-500 iw-text-sm iw-leading-[21px]",children:Or.message||"Please check your network connection and try again."}),o.jsx(cn,{onClick:()=>Jt(),className:"iw-mt-4 iw-w-40",children:"Retry"})]}):o.jsx(t2,{});case G.READING_QUESTION:return o.jsx(i2,{ttsError:We});case G.THINKING:return o.jsx(n2,{state:Ie,thinkingTime:V,nextPhase:ne});case G.ANSWERING:return o.jsx(e2,{state:Ie,answeringTime:q,nextPhase:ui,sttError:Dr,disableStopButton:O});case G.TRANSCRIBING:return o.jsx(s2,{sttError:Dr,editingDuration:D});case G.EDITING:case G.SUBMITTING:return null;case G.COMPLETED:return null;default:return null}},wi=o.jsxs(o.Fragment,{children:[o.jsx(Jh,{title:e,brandName:t,brandLogo:r,totalDuration:S,elapsedTime:Ie.totalTimeElapsed,onExit:()=>{var B;return(B=p.current)==null?void 0:B.exitFullScreenIntentionally().then(()=>hi())}}),o.jsx(Qh,{brandName:t,brandLogo:r,currentQuestion:y,state:Ie,phase:Ie.phase,className:a,interviewId:i,interview_duration:S,videoFeedRef:c,lastSubmittedAnswer:k,onNextPhase:Ie.phase===G.ANSWERING?ui:ne,answerText:m,onAnswerChange:B=>{const $=B.target.value;v($),x.current=$},editingTime:D,disableSubmitButton:Ie.phase===G.ANSWERING&&O,children:fi()})]});return o.jsx(o.Fragment,{children:g!=null&&g.enabled?o.jsx(Yh,{ref:p,onDisqualify:()=>hi(s),onExit:()=>hi(),isCompleted:((un=M==null?void 0:M.current)==null?void 0:un.is_interview_done)??!1,children:wi}):wi})},Xs=({title:e,brandName:t,brandLogo:r,interviewId:i,onInterviewEnd:n,onInterviewDisqualify:s,className:a=""})=>{const[c,l]=d.useState(!1),[h,u]=d.useState(!0),[f,w]=d.useState(!1),{proctoring:g}=Gr(),p=d.useRef(null),y=d.useRef(null),b=(g==null?void 0:g.gazeAnalysisEnabled)===!0,m=()=>{l(!0),u(!1)};return d.useEffect(()=>{if(c&&f&&y.current&&b)try{y.current.setReference()}finally{w(!1)}},[c,f,b]),c?o.jsx("div",{className:"interview-widget-container",children:o.jsx("div",{ref:p,className:`iw-flex iw-flex-col iw-rounded-xl iw-shadow-lg iw-overflow-hidden iw-h-[calc(100vh-1rem)] ${a}`,children:o.jsx("div",{className:"iw-h-[calc(100vh-1rem)] iw-flex iw-flex-col iw-justify-between gap-1",children:o.jsx(o2,{interviewTitle:e??"Interview",brandName:t??"Novara",brandLogo:r,interviewId:i,className:a,onComplete:n??(()=>{}),onDisqualify:s,videoFeedRef:y})})})}):o.jsxs("div",{className:"interview-widget-container",children:[o.jsxs("div",{className:"iw-flex iw-items-center iw-space-x-2 iw-mx-auto iw-p-2 iw-max-w-[1800px]",children:[o.jsx(vn,{brandLogo:r,brandName:t}),o.jsx("p",{className:"iw-text-xl iw-font-semibold",children:t})]}),o.jsx(Nh,{isOpen:h,gazeEnabled:b,onStart:m,onRequestCalibration:()=>w(!0),videoFeedRef:y,interviewId:i})]})};typeof window<"u"&&(window.InterviewWidget={InterviewWidget:Xs,InterviewWidgetProvider:ro}),ve.InterviewWidget=Xs,ve.InterviewWidgetProvider=ro,ve.default=Xs,Object.defineProperties(ve,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
179
|
+
`})})};function n2({ttsError:e}){return o.jsxs("div",{className:"iw-flex iw-flex-col iw-items-center iw-justify-center iw-gap-8 iw-w-full iw-h-full",children:[o.jsx(i2,{size:"80px"}),e&&o.jsxs("div",{className:"iw-mt-2 iw-text-xs iw-text-red-600",children:["Audio playback failed: ",e.message]}),o.jsx("p",{className:"iw-text- iw-text-gray-700",children:"Your AI interviewer is speaking..."})]})}const s2=({state:e,thinkingTime:t,nextPhase:r})=>o.jsxs("div",{className:"iw-flex iw-flex-col iw-gap-6 iw-items-center iw-justify-center iw-text-center iw-h-full ",children:[o.jsxs("div",{children:[o.jsx("h3",{className:"iw-text-lg iw-font-semibold iw-text-gray-900 iw-mb-1",children:"Get Ready to Answer"}),o.jsx("p",{className:"iw-max-w-lg iw-text-gray-500 iw-text-xs iw-leading-[21px]",children:"After 30-seconds thinking time, recording will start automatically, or you can begin recording early by clicking the button below."})]}),o.jsxs("div",{className:"iw-flex iw-items-center iw-justify-center iw-gap-2",children:[o.jsxs("div",{className:"iw-flex iw-items-center iw-gap-1",children:[o.jsx(so,{className:"iw-size-4 iw-text-orange-600"}),o.jsx("p",{className:"iw-text-gray-700 iw-text-sm",children:"Time to think: "})]}),o.jsx(dn,{total:t,remaining:e.currentPhaseTimeRemaining,size:50,strokeWidth:4})]}),o.jsx("div",{className:"iw-w-full iw-grid iw-grid-cols-1",children:o.jsx(ln,{onClick:()=>{r()},children:"Start Answering"})})]}),o2=({sttError:e,editingDuration:t})=>o.jsxs("div",{className:"iw-flex iw-flex-col iw-items-center iw-justify-center iw-h-full",children:[o.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 60 60",fill:"none",children:[o.jsx("rect",{width:60,height:60,rx:30,fill:"url(#prefix__paint0_linear_1460_12482)"}),o.jsx("path",{d:"M28.127 14c.276 7.685 6.442 13.851 14.127 14.127-7.684.276-13.85 6.442-14.127 14.127-.275-7.685-6.442-13.851-14.126-14.127 7.684-.276 13.85-6.442 14.126-14.127zM38.937 31.873A7.331 7.331 0 0046 38.937 7.331 7.331 0 0038.937 46a7.331 7.331 0 00-7.064-7.063 7.331 7.331 0 007.064-7.064z",fill:"#fff"}),o.jsx("defs",{children:o.jsxs("linearGradient",{id:"prefix__paint0_linear_1460_12482",x1:30,y1:-6.563,x2:77.813,y2:54.375,gradientUnits:"userSpaceOnUse",children:[o.jsx("stop",{offset:.211,stopColor:"#5C92FA"}),o.jsx("stop",{offset:1,stopColor:"#A75FFD"})]})})]}),o.jsx("h3",{className:"iw-text-lg iw-font-semibold iw-text-gray-900 iw-mb-1 iw-mt-3",children:"Just a moment... We're analyzing your response"}),o.jsxs("p",{className:"iw-max-w-lg iw-text-gray-500 iw-text-xs iw-leading-[21px]",children:["After transcription, you'll have ",t||30," sec to review your answer."]}),e&&o.jsxs("div",{className:"iw-mt-2 iw-text-xs iw-text-red-600",children:["Transcription error: ",e.message,e.recoverable&&" (attempting to continue)"]})]}),a2=({interviewTitle:e,brandName:t="Novara",brandLogo:r,interviewId:i,onComplete:n,onDisqualify:s,className:a="",videoFeedRef:c})=>{var pi,hn;const l=qs(),{baseUrl:h,authToken:u}=no(),{timers:f,stt:w,proctoring:g}=jr(),p=d.useRef(null),[y,b]=d.useState(null),[m,v]=d.useState(""),[_,E]=d.useState(null),[k,S]=d.useState(bi),[P,x]=d.useState(!0),A=d.useRef(""),D=d.useRef(null),U={thinkingTime:(f==null?void 0:f.thinkingDuration)||0,answeringTime:(f==null?void 0:f.answeringDuration)||120,editingTime:P?(f==null?void 0:f.editingDuration)||30:0},{thinkingTime:j,answeringTime:q,editingTime:M}=U;d.useEffect(()=>{A.current=m},[m]);const[O,R]=d.useState(!1),be=d.useRef(!1),{speak:ze,stop:vt,error:We}=Eh({onEnd:()=>{be.current=!1,ne()},onError:()=>{be.current||(be.current=!0,ne())}}),He=d.useRef(!1),ft=d.useRef(!1),{startRecording:Lt,stopRecording:Fr,transcribe:Lr,cancelRecording:Mr,isRecording:Dr,error:Pr,audioBlob:Qt}=ph({config:{baseUrl:h,provider:w==null?void 0:w.provider,model:w==null?void 0:w.model,language:w==null?void 0:w.language,authToken:u,qnaId:((pi=D.current)==null?void 0:pi.qna_id)||"",interviewId:i},onStart:()=>{He.current=!1,ft.current=!1},onStop:()=>{},onTranscriptionComplete:B=>{const $=B.transcript;v($),A.current=$,ft.current||(ft.current=!0,ne())},onError:B=>{console.error("STT Error:",B),He.current||(He.current=!0,ne())}}),{state:Ie,startQuestion:Mt,nextPhase:ne,completeInterview:li,timerService:Or}=vh({config:{answeringDuration:q,editingDuration:M},callbacks:{onPhaseChange:B=>{switch(B){case V.FETCHING_QUESTION:Jt();break;case V.READING_QUESTION:Js();break;case V.ANSWERING:un();break;case V.TRANSCRIBING:ui();break;case V.SUBMITTING:di();break}},onInterviewEnd:()=>{n==null||n()}}});d.useEffect(()=>{Mt()},[]),d.useEffect(()=>{(async()=>{try{const $=await l.getInterviewConfig(i);if($!=null&&$.data&&($.data.duration_in_minutes&&S($.data.duration_in_minutes),typeof $.data.allow_answer_editing=="boolean"&&x($.data.allow_answer_editing),typeof $.data.elapsed_time_in_minutes=="number")){const Ze=Math.floor($.data.elapsed_time_in_minutes*60);Or.setTotalTimeElapsed(Ze)}}catch($){console.error("Failed to fetch interview config:",$)}})()},[i,Or]);const{execute:Jt,error:Br}=hh(async()=>{const B=await l.generateQuestion({interviewId:i});return D.current=B.data,B},{onSuccess:async B=>{B&&B.data&&(v(""),A.current="",b(B.data),ne())},onError:B=>{console.error("Failed to fetch questions:",B)}}),di=d.useCallback(async()=>{var B;try{const $=A.current,Ze=((B=D.current)==null?void 0:B.qna_id)||"";P&&await l.submitAnswer({interviewId:i,qnaId:Ze,answer:$}),E({qnaId:Ze,answer:$})}catch($){console.error("Failed to submit answer:",$)}Mt()},[l,i,Mt,P]),Js=d.useCallback(async()=>{var B,$;if((B=D.current)!=null&&B.question)if(D.current.question_audio_data_base64)try{be.current=!1,await ze(D.current.question_audio_data_base64),D.current.is_interview_done&&(vt(),Mr(),c&&"current"in c&&(($=c.current)==null||$.stopCamera()),li())}catch(Ze){console.error("Failed to speak question:",Ze)}else console.warn("No audio data available for question"),await Hl(2e3),ne();else ne()},[ze,ne,li]),un=d.useCallback(async()=>{try{await Lt(q)}catch(B){if((B==null?void 0:B.code)==="ALREADY_RECORDING"){console.warn("startRecording called while already recording — ignoring duplicate call.");return}console.error("Failed to start recording:",B),ne()}},[Lt,ne,q]),ui=d.useCallback(async()=>{if(O){console.warn("Audio processing already in progress, ignoring duplicate call");return}R(!0);try{const B=!Dr&&Qt?Qt:await Fr();await Lr(B)}catch(B){console.error("STT processing failed:",B),!He.current&&!ft.current&&(He.current=!0,ne())}finally{R(!1)}},[O,Dr,Qt,Fr,Lr,ne,i,Or]),hi=d.useCallback(()=>{O||ne()},[O,ne]),fi=d.useCallback(async B=>{var $,Ze;Ir(),Mr(),c&&"current"in c&&(($=c.current)==null||$.stopCamera()),await((Ze=p.current)==null?void 0:Ze.exitFullScreenIntentionally());try{await l.exitInterview(i)}catch(fn){console.error("API call failed:",fn)}finally{B==null||B(),li(),sessionStorage.removeItem(mn)}},[i,vt,l]),wi=()=>{const{phase:B}=Ie;switch(B){case V.IDLE:return o.jsxs("div",{className:"iw-text-center iw-flex iw-flex-col iw-items-center iw-justify-center iw-gap-2 iw-h-full",children:[o.jsx("h3",{className:"iw-text-lg iw-font-semibold iw-text-gray-900 iw-mb-1",children:"Ready to start the Interview?"}),o.jsx("p",{className:"iw-max-w-xl iw-text-gray-500 iw-text-xs iw-leading-[21px]",children:`You will be asked a series of behavioral and technical questions. For each one you'll get a short thinking period, then a timed recording window. We'll transcribe your response so you can review and edit it before submitting. Click "Start Interview" when you're ready.`}),o.jsx(ln,{onClick:Mt,className:"iw-mt-2 iw-w-40",children:"Start Interview"})]});case V.FETCHING_QUESTION:return Br?o.jsxs("div",{className:"iw-text-center iw-flex iw-flex-col iw-items-center iw-justify-center iw-gap-2 iw-h-full",children:[o.jsx("h3",{className:"iw-text-lg iw-font-semibold iw-text-red-600 iw-mb-1",children:"Failed to load the next question"}),o.jsx("p",{className:"iw-max-w-md iw-text-gray-500 iw-text-sm iw-leading-[21px]",children:Br.message||"Please check your network connection and try again."}),o.jsx(ln,{onClick:()=>Jt(),className:"iw-mt-4 iw-w-40",children:"Retry"})]}):o.jsx(r2,{});case V.READING_QUESTION:return o.jsx(n2,{ttsError:We});case V.THINKING:return o.jsx(s2,{state:Ie,thinkingTime:j,nextPhase:ne});case V.ANSWERING:return o.jsx(t2,{state:Ie,answeringTime:q,nextPhase:hi,sttError:Pr,disableStopButton:O});case V.TRANSCRIBING:return o.jsx(o2,{sttError:Pr,editingDuration:M});case V.EDITING:case V.SUBMITTING:return null;case V.COMPLETED:return null;default:return null}},gi=o.jsxs(o.Fragment,{children:[o.jsx(Zh,{title:e,brandName:t,brandLogo:r,totalDuration:k,elapsedTime:Ie.totalTimeElapsed,onExit:()=>{var B;return(B=p.current)==null?void 0:B.exitFullScreenIntentionally().then(()=>fi())}}),o.jsx(Jh,{brandName:t,brandLogo:r,currentQuestion:y,state:Ie,phase:Ie.phase,className:a,interviewId:i,interview_duration:k,videoFeedRef:c,lastSubmittedAnswer:_,onNextPhase:Ie.phase===V.ANSWERING?hi:ne,answerText:m,onAnswerChange:B=>{const $=B.target.value;v($),A.current=$},editingTime:M,disableSubmitButton:Ie.phase===V.ANSWERING&&O,children:wi()})]});return o.jsx(o.Fragment,{children:g!=null&&g.enabled?o.jsx(Xh,{ref:p,onDisqualify:()=>fi(s),onExit:()=>fi(),isCompleted:((hn=D==null?void 0:D.current)==null?void 0:hn.is_interview_done)??!1,children:gi}):gi})},Qs=({title:e,brandName:t,brandLogo:r,interviewId:i,onInterviewEnd:n,onInterviewDisqualify:s,className:a=""})=>{const[c,l]=d.useState(!1),[h,u]=d.useState(!0),[f,w]=d.useState(!1),{proctoring:g}=jr(),p=d.useRef(null),y=d.useRef(null),b=(g==null?void 0:g.gazeAnalysisEnabled)===!0,m=()=>{l(!0),u(!1)};return d.useEffect(()=>{if(c&&f&&y.current&&b)try{y.current.setReference()}finally{w(!1)}},[c,f,b]),c?o.jsx("div",{className:"interview-widget-container",children:o.jsx("div",{ref:p,className:`iw-flex iw-flex-col iw-rounded-xl iw-shadow-lg iw-overflow-hidden iw-h-[calc(100vh-1rem)] ${a}`,children:o.jsx("div",{className:"iw-h-[calc(100vh-1rem)] iw-flex iw-flex-col iw-justify-between gap-1",children:o.jsx(a2,{interviewTitle:e??"Interview",brandName:t??"Novara",brandLogo:r,interviewId:i,className:a,onComplete:n??(()=>{}),onDisqualify:s,videoFeedRef:y})})})}):o.jsxs("div",{className:"interview-widget-container",children:[o.jsxs("div",{className:"iw-flex iw-items-center iw-space-x-2 iw-mx-auto iw-p-2 iw-max-w-[1800px]",children:[o.jsx(xn,{brandLogo:r,brandName:t}),o.jsx("p",{className:"iw-text-xl iw-font-semibold",children:t})]}),o.jsx(Ih,{isOpen:h,gazeEnabled:b,onStart:m,onRequestCalibration:()=>w(!0),videoFeedRef:y,interviewId:i})]})};typeof window<"u"&&(window.InterviewWidget={InterviewWidget:Qs,InterviewWidgetProvider:io}),ve.InterviewWidget=Qs,ve.InterviewWidgetProvider=io,ve.default=Qs,Object.defineProperties(ve,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|