import{u as e,C as t}from"./chunk-1676c7f9.js";import{l as i,B as r,d as o,e as a,b as n,g as s,A as l,k as c,p as d,q as u,s as m,j as f,r as p,P as g,t as v,c as h,i as b,v as w,w as S,F as A,R as C}from"./chunk-5b723e6e.js";import{h as y,C as k}from"./chunk-fae379a6.js";import{d as x}from"./chunk-4f4afcb4.js";import"./chunk-39846631.js";import"./chunk-f4e27fd3.js";import{A as $,F as j,S as _}from"./chunk-56643838.js";import"./chunk-ba537d74.js";import"./chunk-748531e9.js";import"./chunk-60817d1f.js";import"./chunk-d2b7acc0.js";import"./chunk-8412c433.js";import{u as I}from"./chunk-f365de99.js";let{blink:B,slide:D}=$,E=i`
  z-index: ${r+20};
  color: #ffffff;
`,O=o.div`
  ${E}
`,L=i`
  ${E}
  ${({top:e})=>e&&i`
      top: ${e}px;
    `}
  ${({bottom:e})=>e&&i`
      bottom: ${e}px;
    `}
  ${({centerY:e})=>e&&i`
      top: 50%;
      transform: translateY(-50%);
    `}
    font-size: ${a("Selfie.error.fontSize")};
  font-weight: ${a("Selfie.error.fontWeight")};
  background: ${a("Selfie.error.backgroundColor")};
  color: ${a("Selfie.error.color")};
  padding: ${a("Selfie.error.padding")};
  border-radius: ${a("Selfie.error.borderRadius")};
  position: absolute;
  white-space: pre-wrap;
  text-align: center;
  max-width: 80%;
`,H=o(j)`
  ${L}
`,z=o(O)`
  ${({top:e})=>e&&i`
      top: ${e}px;
    `}
  font-size: ${a("Selfie.countdown.fontSize")};
  font-weight: ${a("Selfie.countdown.fontWeight")};
  background: ${a("Selfie.countdown.backgroundColor")};
  color: ${a("Selfie.countdown.color")};
  padding: ${a("Selfie.countdown.padding")};
  border-radius: ${a("Selfie.countdown.borderRadius")};
  position: absolute;
  left: 50%;
  transform: translate(-50%, 0);
  white-space: nowrap;
`,R=o(O)`
  position: absolute;
  ${({top:e})=>e&&i`
      top: ${e}px;
    `}
  ${({bottom:e})=>e&&i`
      bottom: ${e}px;
    `}
  color: ${a("Selfie.Active.instruction.color")};
  font-size: ${a("Selfie.Active.instruction.fontSize")};
  font-weight: ${a("Selfie.Active.instruction.fontWeight")};
  text-shadow: ${a("Selfie.Active.instruction.textShadow")};
  background-color: ${a("Selfie.Active.instruction.backgroundColor")};
  border: ${a("Selfie.Active.instruction.border")};
  border-radius: ${a("Selfie.Active.instruction.borderRadius")};
`,M=o.div`
  height: ${()=>n.isMobile?"50px":"70px"};
  position: absolute;
  ${({top:e})=>e&&i`
      top: ${e}px;
    `}
  ${({bottom:e})=>e&&i`
      bottom: ${e}px;
    `}
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: ${r+20};
`,T=o.div`
  width: ${a("Selfie.Active.imageHolder.width")};
  height: ${a("Selfie.Active.imageHolder.height")};
  border-radius: ${a("Selfie.Active.imageHolder.borderRadius")};
  font-size: ${a("Selfie.Active.imageHolder.fontSize")};
  color: ${a("Selfie.Active.imageHolder.color")};
  font-weight: ${a("Selfie.Active.imageHolder.fontWeight")};

  ${({theme:e})=>"v2"===s(e,"themeVersion")?"border: unset;":`border: ${a("Selfie.Active.imageHolder.border")({theme:e})};`}

  display: flex;
  justify-content: center;
  align-items: center;

  & + & {
    margin-left: 10px;
  }

  ${e=>!e.active&&i`
      opacity: 0.6;
    `}

  img {
    width: 100%;
    margin: 0;
    border-radius: ${a("Selfie.Active.imageHolder.borderRadius")};
  }
  img.image_preview {
    border: ${a("Selfie.Active.imageHolder.border")};
  }
`,P=o.div`
  color: #ffffff;
  height: 70px;
  position: absolute;
  bottom: 0;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: ${r+20};
`,U=o.div`
  ${({disabled:e})=>e?i`
          pointer-events: none;
        `:i`
          cursor: pointer;
        `}
  text-align: center;

  img {
    width: ${a("Selfie.captureIcon.width")};
  }
`,W=o.div`
  position: absolute;
  width: 100%;
  top: 0;
  bottom: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  color: #ffffff;
  font-size: 140px;
  opacity: 0.6;
`;var q=Object.freeze({__proto__:null,BottomButtonsOverlay:P,Button:U,CountDownOverlay:W,CountdownTime:z,FaceDetectionError:H,FaceVerificationInstructions:R,FaceVerificationStepsWrapper:M,InstructionsOverlay:o.div`
  position: absolute;
  width: 100%;
  top: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  ${D.default};
  ${B.default};
`,LivenessStyledComponent:_,StepItem:T,Text:O,useActiveLiveness:I,usePassiveLiveness:e}),K=Object.freeze({__proto__:null,AutoCapturingIcon:l,Camera:t});c(async function e(e,t){let{tfScriptUrls:i,blazefaceModelUrl:r,closeEyesModelUrl:o,opencvUrl:a,idCardModelUrls:n}=e;try{d.loadTensorFlow(i).then(()=>{d.loadBlazefaceModel({modelUrl:r})}),await Promise.all([d.preloadResource({modelUrl:o}),u.init({url:a}),...Object.values(n).map(e=>d.preloadResource({modelUrl:e}))])}catch(e){t({...m.Errors.unable_to_load_model,details:e})}});let N=o.div`
  width: 100%;
  padding-bottom: ${e=>1/e.ratio*100}%;
  position: relative;
`,X=o.div`
  position: absolute;
  top: ${e=>e.padding};
  left: ${e=>e.padding};
  right: ${e=>e.padding};
  bottom: ${e=>e.padding};
`,V=({children:e=null,ratio:t=4/3,padding:i="0",...r})=>f.jsx(N,{ratio:t,...r,children:f.jsx(X,{padding:i,children:e})}),{useActiveLiveness:Q,usePassiveLiveness:Z,...G}=q,J={RetryButton:y,ConfirmButton:k},Y=x;var F="data:image/svg+xml,%3csvg width='24' height='24' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3e%3cpath d='M17.9999 6C17.8124 5.81253 17.5581 5.70721 17.2929 5.70721C17.0278 5.70721 16.7735 5.81253 16.5859 6L11.9999 10.586L7.41394 6C7.22641 5.81253 6.9721 5.70721 6.70694 5.70721C6.44178 5.70721 6.18747 5.81253 5.99994 6C5.81247 6.18753 5.70715 6.44184 5.70715 6.707C5.70715 6.97217 5.81247 7.22647 5.99994 7.414L10.5859 12L5.99994 16.586C5.81247 16.7735 5.70715 17.0278 5.70715 17.293C5.70715 17.5582 5.81247 17.8125 5.99994 18C6.18747 18.1875 6.44178 18.2928 6.70694 18.2928C6.9721 18.2928 7.22641 18.1875 7.41394 18L11.9999 13.414L16.5859 18C16.7735 18.1875 17.0278 18.2928 17.2929 18.2928C17.5581 18.2928 17.8124 18.1875 17.9999 18C18.1874 17.8125 18.2927 17.5582 18.2927 17.293C18.2927 17.0278 18.1874 16.7735 17.9999 16.586L13.4139 12L17.9999 7.414C18.1874 7.22647 18.2927 6.97217 18.2927 6.707C18.2927 6.44184 18.1874 6.18753 17.9999 6Z' fill='%23999999'/%3e%3c/svg%3e",ee="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAC8AAAAvCAYAAABzJ5OsAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAU3SURBVHgB1VpBbxtFFH5vxjZpJdLNIWmqtpKRaJqckh5acUCKKy5wInDh2OTCBaEkEiS5oNgXiMohiRDnOPyCHJEQynIBbjg3SIW6CC6Eg50WlSj2zPDeOnHi3Vl77dix+0lrb97Mrr958+a9eW+C0AEkVp5ntNZTiDhpjJkCBAcMpM91KdHlUbtH7T8IIQqVtVdduCAQ2gQTJoLvaqNn6U8HWgcPxr1/K7n988dXXGgDLZNn0qS9Vboy0CHwIOjKtTobsckPrBTTZSO3Okk6RAYxn0SVO1ob8uL0F7E6Lf87f6zFL90kzqD3z/LvfPbti4U4/RPNOoil5+tgVNOX8dQbMHtotCsMeFL6i9SHUuBohLQBwYt6uokSnO+eqPUn/5Sv3RlO5qBd8mL52RZUF2QUiKDe1FdhA7JDZ2TpKof7Fuja8e/IBCUArR2xGvBKNRgD2f2DSnpsJDEHEcDGxM0sRJPO6cdDG3BByJXibHAQX8+k4K3XT/WK+agBWMmTqawSuaz1ATIPhWoOYi6qWKCZeH88tX7LwZkHtyU8uC2CLDfGhpOLIS5BAS9OsvEIjfrazkKX8Nvf5Sw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SKsmzpBPzXT6426+Jy5DwfgOKg7f894LL4j3/SMScnCg3SxpuDCN9/eCX8w2QeRpltlLjTKunaO6AD4NnQGqYQ5PRJBY4vZ2IY4fN3XoHxEfRoIVPkxgJVn/f4u13C5/E/WsAq4Ijo4hwAAAAASUVORK5CYII=";function et(){if(navigator.mediaDevices&&navigator.mediaDevices.getUserMedia)return navigator.mediaDevices;let e=navigator.mozGetUserMedia||navigator.webkitGetUserMedia;return e?{getUserMedia:t=>new Promise((i,r)=>{e.call(navigator,t,i,r)})}:null}function ei(){return"function"==typeof navigator.enumerateDevices?navigator.enumerateDevices():"object"==typeof navigator.mediaDevices&&"function"==typeof navigator.mediaDevices.enumerateDevices?navigator.mediaDevices.enumerateDevices():new Promise((e,t)=>{try{if(null==window.MediaStreamTrack||null==window.MediaStreamTrack.getSources)throw Error();window.MediaStreamTrack.getSources(t=>{e(t.filter(e=>"video"===e.kind.toLowerCase()||"videoinput"===e.kind.toLowerCase()).map(e=>({deviceId:null!=e.deviceId?e.deviceId:"",groupId:e.groupId,kind:"videoinput",label:e.label,toJSON(){return this}})))})}catch(e){return t(e)}})}let er=["camtwist","obs virtual","logi capture","iglasses","virtual","cyberlink youcam","splitcam","splitcam virtual","splitcam video","snap camera","manycam virtual","chromacam","elgato virtual camera","sparkocam virtual webcam","webcammax capture","xsplit vcam","xpression"],eo=et(),ea={width:{ideal:1460},aspectRatio:{ideal:window.innerHeight/window.innerWidth}},{Errors:en}=m,es={...en,no_permission:{code:"no_permission",msg:{en:"Please grant the app permission to use the camera.",vi:"Vui l\xf2ng cấp quyền sử dụng camera cho ứng dụng."}}},el=o.div`
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: #000;
  display: flex;
  justify-content: center;
  z-index: ${1e3};
  ${e=>e.checkCameraMode&&"opacity: 0;"}
`,ec=o.video`
  width: 100%;
  ${e=>e.flipHorizontal&&`
     transform: scale(${-1*e.scale}, ${+e.scale});
  `}
`,ed=o.div`
  cursor: pointer;
  text-align: center;
  width: 50px;

  img {
    width: 100%;
  }
`,eu=o(ed)`
  z-index: ${2e3};
  position: fixed;
  cursor: pointer;
  ${({theme:e})=>i`
    top: ${s(e,"closeButton.top")};
    right: ${s(e,"closeButton.right")};
    left: ${s(e,"closeButton.left")};
    bottom: ${s(e,"closeButton.bottom")};
    display: ${s(e,"closeButton.display")};
    width: ${s(e,"closeButton.width")};
    height: ${s(e,"closeButton.height")};
  `}
`,em=o.div`
  z-index: ${1020};
  position: absolute;
  top: 40px;
  color: red;
`,ef=C.createRef(),ep=et();function eg(e){var t,i;let r,{checkCameraMode:o,frontCamera:a,onClose:s,children:l,onVideoPlayed:c,flipHorizontal:d,videoSettings:u,refVideo:m,onError:g,closeButton:v,videoClassName:y,scale:k,defaultCameraId:x,onWarning:$}=e,j=p.useRef(),{lang:_}=h.useSDKSettings(),{sendEvent:I}=b.useSDKTracking(),[B,D]=p.useState(""),E=p.useRef(!1),O=p.useRef(!1),L=p.useRef(!1),H=p.useRef(),z=p.useRef([]),R=p.useRef(""),M=p.useCallback(e=>{g&&g(e)},[g]),T=p.useCallback(()=>{try{clearInterval(j.current),m?.current?.srcObject instanceof MediaStream&&(m.current.srcObject.getTracks().forEach(e=>e.stop()),m.current.srcObject=null)}catch(e){}clearTimeout(H)},[m]);async function P(){try{z.current=(await ei()).filter(e=>e.deviceId&&"videoinput"===e.kind),w.addExifData("device_info.camera_list",JSON.stringify(z.current.map(e=>e.label)))}catch(e){console.error(e)}}j.current||(j.current=setInterval(()=>{document.getElementById(`tv-camera-${j.current}`)||T()},1e3)),p.useEffect(()=>()=>{L.current=!0},[]);let U=p.useCallback(()=>{H.current||(H.current=setTimeout(()=>{E.current||(D(es.camera_timeout.msg[_]),M(es.camera_timeout))},2e4))},[_,M]),W=p.useCallback(async(e,t=!1)=>{let i,r,o={};if(!1===window.tv_last_req_camera_complete)return $&&$("too_many_request_to_camera"),new Promise(e=>e(null));window.tv_last_req_camera_complete=!1,o=n.isMobile?n.isIOS?{width:{ideal:1460},aspectRatio:{ideal:window.innerHeight/window.innerWidth}}:{height:{ideal:720},aspectRatio:{ideal:window.innerHeight/window.innerWidth}}:{width:{ideal:9999}};let{updateTime:s,getStart:l,getEnd:c}={updateTime:(e,t="start")=>{"start"===t?i=e:"end"===t&&(r=e)},getStart:()=>i,getEnd:()=>r};try{var d,m;let i=u||o;s(performance.now(),"start"),d=n.isMobile,m=n.isIOS,(!d||1===navigator.maxTouchPoints||navigator.plugins.length>0&&!m||0)&&a&&(i={}),t&&(i={}),w.addExifData("device_info.camera_label_dimension.req",JSON.stringify(i));let r={audio:!1,video:{...e?{deviceId:e}:{facingMode:a?"user":"environment"},...i}},f=await ep.getUserMedia(r);if(await P(),U(),!f)return D(es.not_supported.msg[_]),M(es.not_supported),null;s(performance.now(),"end"),window.tv_last_req_camera_complete=!0,c()-l()<1600?I({tag:"cam_permission",event:"user_activity.cam",log:{already_enable:!0}}):I({tag:"cam_permission",event:"user_activity.allow",log:{}});try{let e=f.getVideoTracks()[0].getSettings();w.addExifData("device_info.camera_label_dimension.got",`${e.width}x${e.height}`)}catch(e){}return f}catch(e){s(performance.now(),"end"),"NotAllowedError"===e.name?(D(es.no_permission.msg[_]),M(es.no_permission),O.current=!0,I({tag:"cam_permission",event:"user_activity.cam",log:c()-l()<1600?{already_block:!0}:{click_block_on_popup:!0}})):O.current&&("NotReadableError"===e.name?(M(es.not_readable),D(es.not_readable.msg[_])):(D(e.message),M({code:e.name||e.code,message:e.message})))}return window.tv_last_req_camera_complete=!0,null},[a,u,_,M,$,U,I]),q=p.useCallback(async(e=x,t=!1)=>{let i=m.current;if(i?.srcObject?.id&&i?.srcObject?.active&&E.current)return;i.oncanplaythrough=e=>{i.play();let t=e.target.srcObject;w.addExifData("device_info.camera_label",t?.getVideoTracks()?.[0]?.label),E.current=!0,D("");let r=window.innerWidth,o=window.innerHeight,{lostX:a=0,lostY:n=0}=S.analyzeVideoAndWindowSizes(i),s=Math.min(r,Math.floor(r-2*a)),l=Math.min(o,Math.floor(o-2*n));c&&c({clientWidth:r,clientHeight:o,videoAreaWidth:s,videoAreaHeight:l,lostX:a,lostY:n})};let r=await W(e,t),{deviceLabel:o,isVirtual:a}=(e=>{if(!e)return{isVirtual:!1};let t=e.getTracks();if(!t||!t.length)return{isVirtual:!1};let i=t[0].label,r=i&&er.some(e=>i.toLowerCase().includes(e));return{deviceLabel:i,isVirtual:r}})(r);if(a){R.current+=`${o}, `;let e=z.current.filter(e=>!R.current.includes(e.label));e[0]&&e[0].deviceId&&q(e[0].deviceId)}r||O.current||(w.addExifData("device_info.camera_label_retry","yes"),O.current=!0,q(e,!0)),r&&L.current&&(m.current.srcObject=r,T()),!r||L.current||a||(i.srcObject=r)},[m,W,c,x,T]);p.useEffect(()=>{async function e(){await q();let e=(await ei()).filter(e=>"videoinput"===e.kind&&e.label.includes("back")&&e.label.includes("0"));if(e.length>0){let{deviceId:t}=e[0];T(),q(t)}}let t=m.current;if(E.current)return()=>{};if(!ep||n.browserName&&["facebook"].includes(n.browserName.toLowerCase())||n.getUA.includes("Zalo iOS"))D(es.not_supported.msg[_]),M(es.not_supported);else if(t){if(x)return q(x),()=>{};n.isAndroid&&!1===a?e():q()}return()=>{L.current&&T()}},[m,_,a,q,T,M,x]);let K=p.useCallback(()=>{T(),s&&s(),I({tag:"result",event:"user_activity.cancel",log:{}})},[s,T,I]);return t=m,i=u,r=p.useRef(null),p.useEffect(()=>{let e=t.current,o=async()=>{if(!n.isIOS||"visible"!==document.visibilityState)return;let t=e?.srcObject?.getVideoTracks();if(!Array.isArray(t)||0===t.length)return;let o=t[0]?.getConstraints(),{deviceId:a}=t[0]?.getSettings(),s={audio:!1,video:{deviceId:a,...i??ea}};Object.keys(o).length>0&&(s.video=o),t.forEach(e=>e.stop());let l=await eo.getUserMedia(s);r.current=l,e.srcObject=l};return document.addEventListener("visibilitychange",o),()=>{document.removeEventListener("visibilitychange",o)}},[t,i]),p.useEffect(()=>()=>{r.current&&(r.current.getTracks().forEach(e=>e.stop()),r.current=null)},[]),f.jsx(A,{videoElement:m.current,children:f.jsxs(el,{id:`tv-camera-${j.current}`,checkCameraMode:o,children:[(()=>{if(!B)return null;let e=es.no_permission.msg[_];return B===e&&n.isIOS?f.jsxs(em,{children:[B," ",f.jsx("button",{onClick:()=>{window.location.reload()},children:{vi:"Cấp lại quyền truy cập camera",en:"Request camera permission"}[_]})]}):f.jsx(em,{children:B})})(),f.jsx(ec,{ref:m,playsInline:!0,muted:!0,flipHorizontal:d,className:y,scale:k}),l,v?C.cloneElement(v,{onClick:K,"data-testid":"close-camera"}):f.jsx(eu,{onClick:K,"data-testid":"close-camera",children:f.jsx("img",{src:F,alt:""})})]})})}eg.propTypes={checkCameraMode:g.bool,frontCamera:g.bool,onClose:g.func,onError:g.func,onVideoPlayed:g.func,children:g.node,flipHorizontal:g.bool,videoSettings:g.object,refVideo:g.object,closeButton:g.node,videoClassName:g.string,scale:g.number,defaultCameraId:g.string,onWarning:g.func},eg.defaultProps={checkCameraMode:!1,frontCamera:!0,onClose:null,onError:null,onVideoPlayed:null,children:null,flipHorizontal:!1,videoSettings:null,refVideo:null,closeButton:null,videoClassName:"",scale:1,defaultCameraId:void 0,onWarning:null};let ev=v(eg,250);var eh=C.forwardRef((e,t)=>f.jsx(ev,{...e,refVideo:t||ef}));export{eh as C,K as I,G as L,V as R,Y as S,Q as a,F as b,J as c,ee as i,Z as u};
