@tsocial/tvweb-sdk.platform 5.38.2 → 5.38.4

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.
Files changed (40) hide show
  1. package/build/esm/chunk-001d91a5.js +3 -0
  2. package/build/esm/{chunk-48199d95.js → chunk-07fa1ee8.js} +2 -2
  3. package/build/esm/chunk-158293f4.js +256 -0
  4. package/build/esm/{chunk-7fa83a52.js → chunk-3d38e367.js} +1 -1
  5. package/build/esm/chunk-457fe1f2.js +1 -0
  6. package/build/esm/chunk-480f7783.js +1 -0
  7. package/build/esm/chunk-52bf7aa2.js +1 -0
  8. package/build/esm/{chunk-036bae4b.js → chunk-5f4b20dc.js} +1 -1
  9. package/build/esm/{chunk-2118775a.js → chunk-665f0d35.js} +2 -2
  10. package/build/esm/chunk-66ec7159.js +1 -0
  11. package/build/esm/chunk-84cee1c5.js +1 -0
  12. package/build/esm/chunk-92b01004.js +1 -0
  13. package/build/esm/chunk-96c04d90.js +1 -0
  14. package/build/esm/{chunk-3aa490f8.js → chunk-9d07c97a.js} +32 -32
  15. package/build/esm/chunk-c4b227ab.js +1 -0
  16. package/build/esm/chunk-d93d576d.js +1 -0
  17. package/build/esm/chunk-ed3848f7.js +1205 -0
  18. package/build/esm/{chunk-da8ef78b.js → chunk-f403b8bc.js} +5 -5
  19. package/build/esm/{chunk-30dc9915.js → chunk-f4844e7f.js} +1 -1
  20. package/build/esm/{chunk-7618f5a4.js → chunk-fd4c4194.js} +1 -1
  21. package/build/esm/tvweb-sdk.platform.esm.min.js +1 -1
  22. package/build/tvweb-sdk.platform.cjs.min.js +661 -695
  23. package/build/tvweb-sdk.platform.standalone.js +6013 -7694
  24. package/build/tvweb-sdk.platform.standalone.min.js +661 -695
  25. package/build/types/index.d.ts +1 -9
  26. package/package.json +5 -5
  27. package/build/esm/chunk-0319b1ae.js +0 -45
  28. package/build/esm/chunk-2b4d00a3.js +0 -3
  29. package/build/esm/chunk-3b109c2f.js +0 -1
  30. package/build/esm/chunk-409b3310.js +0 -1
  31. package/build/esm/chunk-51b3fd2d.js +0 -1
  32. package/build/esm/chunk-6e5358d6.js +0 -1
  33. package/build/esm/chunk-71508ce2.js +0 -1
  34. package/build/esm/chunk-71ff4107.js +0 -1
  35. package/build/esm/chunk-88ec0901.js +0 -256
  36. package/build/esm/chunk-91b54c2c.js +0 -1
  37. package/build/esm/chunk-c747321c.js +0 -1195
  38. package/build/esm/chunk-d7bc8179.js +0 -1
  39. package/build/esm/chunk-ddb14dfb.js +0 -1
  40. package/build/esm/chunk-e5a92416.js +0 -1
@@ -0,0 +1 @@
1
+ import{x as e,y as r,Q as s,r as a,e as n,c as t,s as o,j as i,a2 as c,ay as l,n as u,P as p,b as d}from"./chunk-ed3848f7.js";import{p as m,g as f,S as g,a as h,O as C,C as y,E as j,b as D,B as x,c as F,L as S}from"./chunk-158293f4.js";import{u as b,C as I}from"./chunk-d93d576d.js";import{M as T,O as E,W as k,C as R}from"./chunk-f403b8bc.js";import{D as L}from"./chunk-001d91a5.js";import{u as v}from"./chunk-96c04d90.js";import"./chunk-5f4b20dc.js";import"./chunk-84cee1c5.js";let P=d.isMobile?{width:{ideal:640}}:null;function A(p){let{apiCheck:d,onLivenessDetectionDone:L,captureFrameSettings:A,onFramesCaptured:M,frontCamera:H,flipVideoHorizontal:O,customDirectionIcon:w,customStepTimeConstraints:U,onProcessing:V,customErrors:$,apiCredentials:_,outputEncryptionSettings:B,cameraScale:K,defaultCameraId:N,passiveModeAuto:z,offsetFaceY:G,styledComponent:Y,serviceSettings:W,onReset:Q,isLoading:q}=p,J=e(),{onErrorCallback:X,onCloseCallback:Z}=v(),ee=r.useAsset("bg_camera_mask.png"),er=r.useAsset("bg_camera_mask_red.png"),es=s("IDCapturing.loadingIcon.src","ic_loading.gif"),[ea,en]=a.useState({}),{yFaceDetectionError:et,yFaceVerificationStepsWrapper:eo}=ea,[ei,ec]=a.useState(""),[el,eu]=a.useState(),ep=a.useMemo(()=>({backgroundColor:n("Selfie.backgroundColor")({theme:J})}),[J]),ed=a.useCallback(({lostY:e,height:r,clientHeight:s})=>{let a=e+25,n=a+30;en({yFaceDetectionError:a,yFaceVerificationStepsWrapper:n+r+20});let t=Math.floor(e),o=Math.floor(s-e),i=Math.floor(n);return 0!==G&&(i+G<t||i+G+r>o)?X({code:`offsetFaceY must be in [-${i-t}, ${o-r-i}]`}):i+=G,{y:i}},[G,X]),{shouldResetFlowOnOrientationChange:em,countdownToTakePicture:ef,cropArea:eg,curStepIndex:eh,faceDetectionError:eC,resetFlow:ey,handleTriggerPassiveMode:ej,handleVideoPlayed:eD,refVideo:ex,showCountdown:eF,steps:eS,refIsReseting:eb,videoPlayed:eI,warmupDone:eT,showCaptureButton:eE,shouldShowCountdown:ek,showLoading:eR}=b({currentOrientation:el,apiCheck:d,bgCameraMask:ee,bgCameraMaskRed:er,surroundStyle:ep,onLivenessDetectionDone:L,onError:X,cropAreaDimension:ed,customDirectionIcon:w,captureFrameSettings:A,onFramesCaptured:M,setRemainingTime:ec,customStepTimeConstraints:U,onProcessing:V,customErrors:$,apiCredentials:_,outputEncryptionSettings:B,cameraScale:K,passiveModeAuto:z,serviceSettings:W,onReset:Q});a.useEffect(()=>{"string"==typeof eS[0]?.directionIcon&&Promise.all(eS.map(e=>m(e.directionIcon)))},[eS]);let{CloseCameraButton:eL}=Y,ev=f(p,J),eP=eb.current?0:eh/eS.length*100,{lang:eA}=t.useSDKSettings(),eM=a.useRef(0),eH=a.useRef({}),eO=a.useRef(o.ErrorDuration.SHORT),ew=a.useMemo(()=>{let{msg:e,duration:r=o.ErrorDuration.SHORT}=eC||{},s=e?.[eA];return Date.now()-eM.current>=eO.current&&(eM.current=Date.now(),eO.current=r,eH.current=s),eH.current},[eC,eh]),eU=a.useCallback(e=>{eu(e),em?ey():e===T.LANDSCAPE?ex.current?.pause():ex.current?.play()},[ex,ey,em]);return i.jsx(E,{onOrientationChange:eU,children:i.jsxs(c,{frontCamera:H,onVideoPlayed:eD,onClose:Z,flipHorizontal:O??H,ref:ex,videoSettings:P,onError:X,scale:K,defaultCameraId:N,closeButton:eL||i.jsx(l,{}),children:[!eT&&i.jsx(k,{}),eI?i.jsxs(i.Fragment,{children:["string"==typeof ew?i.jsx(g,{top:et-15,className:"face-detection-error",children:ew}):null,eg.current?i.jsxs(R,{x:`${eg.current.x}px`,y:`${eg.current.y}px`,width:`${eg.current.width}px`,height:`${eg.current.height}px`,surroundStyle:eg.current.surroundStyle,children:[i.jsx(h,{}),i.jsx(C,{...ev,progress:eP,showErrorRing:!!eC&&n("Selfie.progressCircle.showErrorRing")({theme:J})}),ek?i.jsx(y,{children:ef}):null,eC&&i.jsx(j,{})]}):null,ei&&i.jsx(D,{top:eo-30,children:ei}),eE?i.jsx(x,{children:i.jsx(F,{onClick:ej,disabled:eF,children:u(J,"Selfie.captureIcon.src")?i.jsx("img",{src:u(J,"Selfie.captureIcon.src"),alt:""}):i.jsx(I,{fillColor:"rgba(193, 197, 204, 1)"})})}):null]}):null,(eR||q)&&i.jsx(S,{children:i.jsx("img",{src:es,alt:""})})]})})}A.propTypes={apiCheck:p.bool,mode:p.string,onLivenessDetectionDone:p.func,onClose:p.func,onError:p.func,onReset:p.func,captureFrameSettings:p.shape({}),onFramesCaptured:p.func,frontCamera:p.bool,isLoading:p.bool,flipVideoHorizontal:p.bool,customDirectionIcon:p.shape({}),customStepTimeConstraints:p.shape({}),onProcessing:p.func,customErrors:p.shape({}),apiCredentials:p.shape({accessKey:p.string,secretKey:p.string,apiUrl:p.string}),outputEncryptionSettings:p.shape({}),cameraScale:p.number,defaultCameraId:p.string,passiveModeAuto:p.bool,offsetFaceY:p.number,styledComponent:p.shape({CloseCameraButton:p.node}),serviceSettings:p.shape({})},A.defaultProps={apiCheck:!1,mode:null,onLivenessDetectionDone:null,onClose:null,onError:()=>{},onReset:()=>{},captureFrameSettings:{enable:!1,framesIntervalTime:180,framesBatchLength:0},onFramesCaptured:()=>{},frontCamera:!0,isLoading:!1,flipVideoHorizontal:null,customDirectionIcon:{[o.FaceDirection.LEFT]:i.jsx(L,{type:o.FaceDirection.LEFT}),[o.FaceDirection.RIGHT]:i.jsx(L,{type:o.FaceDirection.RIGHT}),[o.FaceDirection.UP]:i.jsx(L,{type:o.FaceDirection.UP}),[o.FaceDirection.FRONTAL]:i.jsx(L,{type:o.FaceDirection.FRONTAL})},customStepTimeConstraints:{[o.FaceDirection.UP]:{delayTime:0},[o.FaceDirection.LEFT]:{delayTime:0},[o.FaceDirection.RIGHT]:{delayTime:0},[o.FaceDirection.FRONTAL]:{delayTime:2e3}},onProcessing:()=>{},customErrors:null,apiCredentials:{accessKey:"",secretKey:"",apiUrl:""},outputEncryptionSettings:null,cameraScale:1,defaultCameraId:void 0,passiveModeAuto:!1,offsetFaceY:0,styledComponent:{CloseCameraButton:null},serviceSettings:{enableUploadFrames:!0,enableUploadImages:!0,enableVerifySanityPortrait:!0,enableVerifySanityIDCard:!0,enableVerifyFaceLiveness:!0,enableDetectIDCardTampering:!0,enableReadIDCardInfo:!0}};export{A as default};
@@ -0,0 +1 @@
1
+ import{r as e,n as t,u as a,aG as s,s as n,c as i,a9 as r,d as l,I as c,f as o,b as u,aJ as _,aK as m,F as g,L as d,W as f,M as h,D as b,au as v,k as p,aA as w,j as k}from"./chunk-ed3848f7.js";import{t as y}from"./chunk-5f4b20dc.js";import{n as F,t as T,u as L,o as R,q as C,r as B,v as S,s as x,y as I}from"./chunk-158293f4.js";import{m as M}from"./chunk-96c04d90.js";import{u as D}from"./chunk-84cee1c5.js";let E=s.faceTracker(),P=new _,{FaceDirection:j,Errors:A,Messages:W,TrackLivenessEvents:V}=n,N={enable:!1,framesIntervalTime:180,framesBatchLength:0},U={[n.FaceDirection.UP]:{delayTime:0},[n.FaceDirection.LEFT]:{delayTime:0},[n.FaceDirection.RIGHT]:{delayTime:0},[n.FaceDirection.FRONTAL]:{delayTime:2e3}},O=()=>{},z=()=>{},K=()=>{};function q({apiCheck:_,bgCameraMask:k,bgCameraMaskRed:G,surroundStyle:Z,cropAreaDimension:J,customInstructions:H,customIcon:X,customDirectionIcon:Q,customStepTimeConstraints:Y=U,onLivenessDetectionDone:$,onError:ee,frontalMinSize:et,waitingTimeToGetBetterFrames:ea=500,captureFrameSettings:es=N,setRemainingTime:en=O,onProcessing:ei=K,customErrors:er,customMessages:el,apiCredentials:ec={},onFramesCaptured:eo=z,initFirstGestureTimeout:eu=2e3,outputEncryptionSettings:e_,cameraScale:em=1,passiveModeAuto:eg=!1,sendCustomEvent:ed,serviceSettings:ef,currentOrientation:eh,onReset:eb}={}){let[ev,ep]=e.useState(!1),[ew,ek]=e.useState(!1),[ey,eF]=e.useState(!1),[eT,eL]=e.useState(!1),eR=e.useRef(null),{lang:eC,assetRoot:eB,customUrls:eS,exifKey:ex}=i.useSDKSettings(),eI=r.useSDKLocale(),{apiClient:eM}=l.useApiClient({apiCredentials:ec}),[,eD]=e.useReducer(e=>e+1,0),eE=e.useRef(null),[eP,ej]=e.useState(!1),eA=e.useRef({}),{sendEvent:eW}=c.useSDKTracking(),[eV,eN]=e.useState(3),[eU,eO]=e.useState(!1),ez=e.useRef(!1),eK=e.useCallback(e=>{eO(e),ez.current=e},[]),eq=e.useRef(null),eG=e.useRef([]),eZ=e.useRef(null),eJ=e.useRef(),eH=e.useRef(null);null===eH.current&&(eH.current=s.initFaceVerificationData({assetRoot:eB,customInstructions:H,customIcon:X,customDirectionIcon:Q,customStepTimeConstraints:Y,Locale:eI,lang:eC}));let[eX,eQ]=e.useState(),eY=e.useCallback(e=>{eQ(e)},[]),e$=e.useMemo(()=>y(eY,500),[eY]),e0=e.useRef([]),e1=e.useRef(),e4=D(),{flowIntervalTimeMs:e2,limitTimeLivenessCheck:e3,terminateIfNoFace:e5,closeEyeDetectorSettings:e7,exifDataSettings:e6,recordVideo:e8,autoCaptureSettings:e9,manualCaptureSettings:te,blurCheckSettings:tt,webIsRequiredFrontalFace:ta,waitBeforeStartFlowMs:ts,resetFlowOnOrientationChange:tn,captureFrameSettings:ti}=function({clientSettings:s,captureFrameSettingsProp:n}){return e.useMemo(()=>{let e,i=M({},F,s),r={enable:t(i,"data.settings.sdk_settings.passive_liveness_settings.auto_capture.enable"),showCaptureButton:t(i,"data.settings.sdk_settings.passive_liveness_settings.auto_capture.show_capture_button"),showCountdown:t(i,"data.settings.sdk_settings.passive_liveness_settings.auto_capture.show_countdown"),waitForBestImageTimeMsWeb:t(i,"data.settings.sdk_settings.passive_liveness_settings.auto_capture.wait_for_best_image_time_ms_web")},l={showCountdown:t(i,"data.settings.sdk_settings.passive_liveness_settings.manual_capture.show_countdown"),waitForBestImageTimeMsWeb:t(i,"data.settings.sdk_settings.passive_liveness_settings.manual_capture.wait_for_best_image_time_ms_web")},c={enable:t(i,"data.settings.sdk_settings.passive_liveness_settings.blur_check.enable"),webBlurryThreshold:t(i,"data.settings.sdk_settings.passive_liveness_settings.blur_check.web_blurry_threshold")},o={enable:t(i,"data.settings.sdk_settings.passive_liveness_settings.close_eye_detector.enable"),webThreshold:t(i,"data.settings.sdk_settings.passive_liveness_settings.close_eye_detector.web_threshold"),webTimeout:t(i,"data.settings.sdk_settings.passive_liveness_settings.close_eye_detector.web_timeout"),forceCheck:t(i,"data.settings.sdk_settings.passive_liveness_settings.close_eye_detector.force_check")},u=t(i,"data.settings.sdk_settings.passive_liveness_settings.web_is_required_frontal_face"),_=a.getWebSetting(i,"data.settings.sdk_settings.active_liveness_settings.limit_time_liveness_check.max_retry_count"),m={enable:t(i,"data.settings.sdk_settings.active_liveness_settings.limit_time_liveness_check.enable"),limitTimeSecond:t(i,"data.settings.sdk_settings.active_liveness_settings.limit_time_liveness_check.limit_time_second"),remainTimeShow:t(i,"data.settings.sdk_settings.active_liveness_settings.limit_time_liveness_check.remain_time_show"),format:t(i,"data.settings.sdk_settings.active_liveness_settings.limit_time_liveness_check.format"),enableMaxRetries:_>0,totalMaxRetries:_,interruptible:!a.getWebSetting(i,"data.settings.sdk_settings.active_liveness_settings.limit_time_liveness_check.non_stoppable")},g={enable:t(i,"data.settings.sdk_settings.active_liveness_settings.terminate_if_no_face.enable"),maxInvalidFrame:t(i,"data.settings.sdk_settings.active_liveness_settings.terminate_if_no_face.max_invalid_frame"),maxTimeMs:t(i,"data.settings.sdk_settings.active_liveness_settings.terminate_if_no_face.max_time_ms")},d={enable:t(i,"data.settings.sdk_settings.active_liveness_settings.exif_data_settings.enable")},f={enable:t(i,"data.settings.sdk_settings.active_liveness_settings.record_video.enable")},h=t(i,"data.settings.sdk_settings.active_liveness_settings.wait_before_start_flow_ms"),b=t(i,"data.settings.sdk_settings.active_liveness_settings.reset_flow_on_orientation_change"),v=t(i,"data.settings.sdk_settings.active_liveness_settings.flow_interval_time_ms"),p=t(s,"data.settings.sdk_settings.active_liveness_settings.save_encoded_frames");return{autoCaptureSettings:r,manualCaptureSettings:l,blurCheckSettings:c,closeEyeDetectorSettings:o,webIsRequiredFrontalFace:u,limitTimeLivenessCheck:m,terminateIfNoFace:g,exifDataSettings:d,recordVideo:f,waitBeforeStartFlowMs:h,resetFlowOnOrientationChange:b,flowIntervalTimeMs:v,captureFrameSettings:e=p?{enable:p.enable,enableLogging:p.enable_logging,framesBatchLength:p.frames_batch_len,framesIntervalTime:p.frames_interval_ms}:n}},[s,n])}({clientSettings:e4,captureFrameSettingsProp:es}),tr=e9?.enable?e9?.waitForBestImageTimeMsWeb:te?.waitForBestImageTimeMsWeb,tl=e8?.enable,tc=e.useMemo(()=>o.getEnabledServices(ef,e4),[e4,ef]),to=e.useRef(""),tu=e.useCallback(e=>{if(e?.event){if(e.event===V?.show_alert){let t=e.log?.alert;if(t===to.current)return;to.current=t}eW(e),ed&&ed(e)}},[ed,eW]),t_=e.useMemo(()=>y(e=>{tu(e)},2e3),[tu]),tm=e.useRef(0),tg=e.useRef(),td=e.useRef();e.useEffect(()=>{tu({tag:"selfie",event:V?.start_camera,log:{}})},[tu]),e.useEffect(()=>(P.start(),()=>{P.stop()}),[]),e.useEffect(()=>{let e=!1;return async function t(){!eP&&(e1.current=performance.now(),eA.current=await m(eS),await g.initTensorFlow({preferredBackends:["wasm","webgl","cpu"]}),e||(ej(!0),tu({tag:"selfie",event:V?.show_warmup,log:{}}),tu({tag:"selfie",event:V?.finish_load_model,log:{status:"success",time_in_ms:performance.now()-e1.current}}),e1.current=null))}(),()=>{e=!0}},[eP,eS,tu]);let tf=e.useRef(!1),th=e.useCallback(()=>{eH.current.curStepIndex=eH.current.steps.length,tf.current=!0,eF(!1),td.current?.discardRecording(),clearInterval(eq.current)},[]),tb=e.useCallback(()=>{eH.current=s.initFaceVerificationData({assetRoot:eB,customInstructions:H,customIcon:X,customDirectionIcon:Q,Locale:eI,lang:eC}),tm.current=0,tg.current=null,e0.current=[],eL(!1),eQ(null),x(),td.current?.start(),tf.current=!1,eK(!1),eN(3),eZ.current=null,eG.current=[],eJ.current=null,"function"==typeof eb&&eb(),eD()},[eI,eB,Q,X,H,eK,eC,eb]),tv=e.useCallback(()=>{th(),setTimeout(()=>{tb()},e2)},[e2,tb,th]),tp=e.useMemo(()=>({...A,...er}),[er]),tw=e.useMemo(()=>({...W,...el}),[el]),tk=e.useCallback(()=>{let e={};Object.keys(tp.liveness_terminated_time_out?.msg).forEach(t=>{let a=T(tp.liveness_terminated_time_out?.msg[t]);e[t]=a({x:e3.limitTimeSecond})}),eQ({...tp.liveness_terminated_time_out,msg:e,duration:.95*e2}),tu({tag:"selfie",event:V?.show_alert,log:{alert:"liveness_terminated_time_out,"}}),P.stop(),en(""),th()},[tp.liveness_terminated_time_out,e2,e3.limitTimeSecond,th,tu,en]),ty=e.useCallback(({remainTime:e})=>{if(e>0&&e<=e3.remainTimeShow){let t=T(tw.REMAIN_TIME[eC]),a=e;switch(e3.format){case"mm:ss":a=e.toString().padStart(5,"00:00");break;case"ss":a=e.toString().padStart(2,"0")}en(t({x:a}))}},[eC,e3.format,e3.remainTimeShow,tw.REMAIN_TIME,en]),tF=e.useCallback(({attemptCount:e,fromBackground:t})=>{e3.enableMaxRetries&&e>=e3.totalMaxRetries&&ee(n.Errors.max_retry_reached),t&&th(),P.start(),tb()},[e3.enableMaxRetries,e3.totalMaxRetries,ee,tb,th]),{stopTimer:tT}=L({totalTime:e3.limitTimeSecond,totalDelayBetweenReset:e2/1e3,interruptible:e3.interruptible,shouldStart:ew&&e3.enable&&eP,onTimesUp:tk,onTick:ty,onReset:tF}),tL=e.useCallback(({clientWidth:e,clientHeight:t,videoAreaWidth:a,videoAreaHeight:s,lostX:n,lostY:i})=>{let r,l;u.isMobile?l=r=a:r=l=s-200;let c=Math.floor((a-r)/2)+n;eE.current={x:c,y:5+i,width:r,height:l,image:k,surroundStyle:Z},"object"==typeof J?eE.current={...eE.current,...J}:"function"==typeof J&&(eE.current={...eE.current,...J({clientWidth:e,clientHeight:t,videoAreaWidth:a,videoAreaHeight:s,lostX:n,lostY:i,isMobile:u.isMobile,width:r,height:l})}),eD(),ek(!0)},[k,Z,J]),tR=e.useCallback(()=>{eN(3),clearInterval(eq.current),eK(!0);let e=async e=>{if(e-1==0){let e;P.stop(),tT(),clearInterval(eq.current),ei(),await td.current?.stopVideoRecording(),ep(!0),d.addExifData("user_action",{start_selfie:Date.now()-1e3*P.duration("from_1st_frame"),end_selfie:Date.now()});let t=(e=e9.enable?[eZ.current]:eG.current).map(e=>f.resizeBlobImg(e.blob,400,400)),a=(await Promise.all(t)).map((t,a)=>{let s=d.parseLivenessImg({...e[a],gesture:"frontal"});return d.writeCurrentExif({imageData:{blob:t},enableExifData:e6.enable,additionalData:s})}),s=await Promise.all(a),n={};if(e_&&e_.key){let{key:e}=e_,t=s.map(t=>h.encrypt({blob:t,key:e}));n={frontalFacesEncrypted:await Promise.all(t)}}let i=[...e0.current];if(e_&&e_.key){let e=await Promise.all(i.map(e=>e?.base64));if(i=i.map((t,a)=>({...t,base64:e[a]})),ti.enable&&ti.framesBatchLength>0&&i.length%ti.framesBatchLength>0){let e=i.slice(-1*(i.length%ti.framesBatchLength));eo(e),_&&tc.enableUploadFrames&&R(e_,e,eM,i.length===ti.framesBatchLength)}}else ti.enable&&ti.framesBatchLength>0&&i.length%ti.framesBatchLength>0&&(eo(i.slice(-1*(i.length%ti.framesBatchLength)).map(({base64:e,label:t,index:a})=>({base64:e,label:t,index:a}))),_&&tc.enableUploadFrames&&R(e_,i.slice(-1*(i.length%ti.framesBatchLength)),eM));if(_&&tc.enableUploadImages){let t=e=>({label:"portrait",metadata:JSON.stringify({gesture_score:e,gesture:j.FRONTAL})}),a=e.map((e,a)=>eM.uploadImage({file:s[a],...t(e.leftRightScore)}));e_&&e_.key&&(a=e.map((e,a)=>{let s=new Blob([n.frontalFacesEncrypted[a].hex]);return eM.uploadImage({file:s,...t(e.leftRightScore)},{"X-TV-Key":e_.key})}));try{let t=await Promise.all(a),s=null;tc.enableVerifyFaceLiveness&&(s=eM.verifyFaceLiveness({images:t.map(e=>({id:e.data.image_id})),videos:[{frames:i}]}));let n=null;tc.enableVerifySanityPortrait&&(n=eM.requestVerifyPortrait({image:{id:t?.[t.length-1]?.data?.image_id}}));let[r,l]=await Promise.all([s,n]);$({apiCheckPassed:r?.data.is_live??!1,verifyFaceLivenessResult:r?.data??null,verifyFacePortraitResult:l?.data??null,frontalFaces:t.map((t,a)=>({id:t?.data?.image_id,blob:e?.[a]?.blob}))})}catch(e){ee({error:e})}}else $({frontalFaces:s,...n,capturedFrames:i,video:C()}),B()}};eq.current=setInterval(()=>{eN(t=>(e(t),t-1))},tr/3)},[eK,tr,tT,ei,e9.enable,e_,ti.enable,ti.framesBatchLength,_,tc.enableUploadImages,tc.enableUploadFrames,tc.enableVerifyFaceLiveness,tc.enableVerifySanityPortrait,e6.enable,eo,eM,$,ee]),tC=e.useRef({});e.useEffect(()=>{tC.current.isFirstValidFrameFoundRef=eT},[eT]),e.useEffect(()=>{let e,t=eR.current;async function a({faceDirection:e,canvas:t,leftRightScore:a,blurScore:s,isEyeClosed:n}){if(!0===ez.current&&(ta&&e===j.FRONTAL||!ta)){let e=await b.takePicture({canvas:t});e9?.enable&&Date.now()-eJ.current<e9?.waitForBestImageTimeMsWeb?(eZ.current||(eZ.current={blob:e,blurScore:s,isEyeClosed:n,captureTime:Date.now()}),tt?.enable&&(eZ.current=I({incomingFrame:{blob:e,blurScore:s,isEyeClosed:n,captureTime:Date.now()},currentBestFrame:eZ.current}))):eG.current.length<1&&eG.current.push({blob:e,leftRightScore:a,captureTime:Date.now(),blurScore:s})}}async function i(r,l){let c,o;if(l?.width===0||l?.height===0)return;let{isFirstValidFrameFoundRef:u}=tC.current,{cropX:m,cropY:g,cropWidth:d,cropHeight:f}=r;l.getContext("2d").drawImage(t,m,g,d,f,-((400*em-400)/2)/em,-((400*em-400)/2)/em,400,400);let{blazefaceModel:h,closeEyesModel:b}=eA.current,[y,F]=await Promise.all([v.calculateBlurScore(l),p.getModelPredictions({model:h,sCanvas:l})]),{error:T,fullFace:L,faceRatio:C,faceNotFrontalMinThreshold:B}=await s.validatePredictions({predictions:F,width:p.SIZE,height:p.SIZE});c=T,eE.current.image=k;let S=null,x=null,I=null,{curStepIndex:M,steps:D}=eH.current;if(L){I=L.landmarks;let e=await s.calculateFaceDirection({landmarks:I,getPerfectFrontal:!0});e&&(S=e.gesture,x=e.leftRightScore);let t=e7?.webTimeout+Y[n.FaceDirection.FRONTAL].delayTime/1e3;if(e7?.enable&&(-1===P.duration("limit_close_eye")||P.duration("limit_close_eye")<t)){e7?.forceCheck||-1!==P.duration("limit_close_eye")||P.start("limit_close_eye");let{isEyeClose:e}=await b.predict(l,I,e7?.webThreshold);e&&!c&&(c=A.close_eye)}}let W=c?.code==="no_face"||c?.code==="partial_face",N=M<D.length;if(!function({noFace:e,isFirstValidFrameFoundRef:t}){if(!e5.enable||!t)return;let{max_time_ms:a}=e5;tg.current&&e||(tg.current={time:Date.now(),frame:0}),e&&tg.current.frame++;let{time:s}=tg.current;e&&Date.now()-s>=a&&(eQ({...tp.liveness_terminated_no_face,duration:e2}),tu({tag:"selfie",event:V?.show_alert,log:{alert:"liveness_terminated_no_face"}}),tv())}({noFace:W&&N,isFirstValidFrameFoundRef:u}),c?.code&&t_({tag:"selfie",event:V?.show_alert,log:{alert:c.code}}),!c||"face_too_small"===c.code&&S!==j.FRONTAL&&C>=B){if(!function(e,t,a,s){if(e0.current.length&&Date.now()-e0.current[e0.current.length-1].time<ti.framesIntervalTime)return;if(ti.enable&&!0){let{topLeft:s,bottomRight:n}=e,i=[...s,...n],{score:r,time:l}=E(e,0===e0.current.length),c={label:"portrait",base64:t.toDataURL("image/jpeg",.8).split(",")[1],landmarks:a,original_landmarks:a,score:r,time:l,index:e0.current.length,bbox:i,original_bbox:i};if(e_&&e_.key){if(c.base64=w.encryptFrameBase64(c.base64,e_.key),e0.current.push(c),ti.framesBatchLength>0&&e0.current.length%ti.framesBatchLength==0&&eo){let e=e0.current.slice(-ti.framesBatchLength);Promise.all(e.map(e=>e?.base64)).then(t=>{eo(e.map(({label:e,index:a},s)=>({base64:t[s],label:e,index:a}))),_&&tc.enableUploadFrames&&R(e_,e.map(({label:e,index:a},s)=>({base64:t[s],label:e,index:a})),eM,e0.current.length===ti.framesBatchLength)})}}else e0.current.push(c),ti.framesBatchLength>0&&e0.current.length%ti.framesBatchLength==0&&eo&&(eo(e0.current.slice(-ti.framesBatchLength).map(({base64:e,label:t,index:a})=>({base64:e,label:t,index:a}))),_&&tc.enableUploadFrames&&R(e_,e0.current.slice(-ti.framesBatchLength),eM,e0.current.length===ti.framesBatchLength));return};}(F[0],l,I),S!==j.FRONTAL&&ta)o=tp.not_frontal_face,eE.current.image=G;else if(!c){u||(eL(!0),P.start("from_1st_frame"));let e=e9?.enable&&!ez.current&&0===eG.current.length;tt?.enable?null!==y&&y>tt?.webBlurryThreshold?(o=null,e&&(eJ.current=Date.now(),tR())):ez.current||(o=tp.liveness_blurry):e&&(eJ.current=Date.now(),tR());let{isEyeClose:t}=await b.predict(l,I,e7?.webThreshold);await a({faceDirection:S,canvas:l,leftRightScore:x,blurScore:y,...null!==t?{isEyeClosed:t}:{}})}}else M<D.length&&(o=tp[c.code],eE.current.image=G);e$(o),-1!==e&&(e=requestAnimationFrame(()=>i(r,l)))}async function r(){let e=b.analyzeVideoAndWindowSizes(t,eE.current),a=document.createElement("canvas");a.width=400,a.height=400;let s=a.getContext("2d");s.translate(400,0),s.scale(-1*em,+em);let{mediaRecorder:n}=tl&&t?await S({outputImagesSize:400,videoEl:t,resultAnalyzeVideoAndWindowSizes:e}):{};td.current=n,td.current&&td.current.start(),i(e,a)}return ew&&eP&&setTimeout(()=>{r()},ts??eu),()=>{cancelAnimationFrame(e),e=-1}},[eh,ts,ta,tt?.enable,tt?.webBlurryThreshold,e9?.enable,e9?.waitForBestImageTimeMsWeb,eu,ew,eC,eM,_,k,G,$,ee,et,ea,ti,ei,e3.enable,en,e$,Y,e2,tv,e5,tp,eP,tu,eo,e_,em,tR,eg,e7?.enable,e7?.webThreshold,e7?.webTimeout,e7?.forceCheck,e6.enable,ex,t_,ti.framesBatchLength,tl,tc.enableUploadFrames]),e.useEffect(()=>{eX&&(eX?.code!==tp?.liveness_terminated_time_out&&eX?.code!==tp?.liveness_terminated_no_face&&e9?.enable&&ez.current||(clearInterval(eq.current),eK(!1),eZ.current=null,eG.current=[],eJ.current=null))},[e9?.enable,eX,eK,tp]);let{curStepIndex:tB,steps:tS}=eH.current,tx=eT&&!eX&&!eg&&(!e9?.enable||e9?.showCaptureButton),tI=eU&&!tf.current&&(e9?.enable?e9?.showCountdown:te?.showCountdown);return{resetFlowOnOrientationChange:tn,countdownToTakePicture:eV,cropArea:eE,curStepIndex:tB,faceDetectionError:eX,resetFlow:tv,handleTriggerPassiveMode:tR,handleVideoPlayed:tL,refVideo:eR,refIsReseting:tf,showCountdown:eU,steps:tS,videoPlayed:ew,activeCapturing:ey,isFirstValidFrameFound:eT,warmupDone:eP,showLoading:ev,showCaptureButton:tx,shouldShowCountdown:tI}}function G({className:e="",fillColor:t=null}){return k.jsxs("svg",{className:e,width:"38px",height:"32px",viewBox:"0 0 24 21","data-testid":"camera-icon",children:[k.jsx("title",{children:"FA45C15C-1E21-4D7B-9585-07FB9F999CB8"}),k.jsx("desc",{children:"Created with sketchtool."}),k.jsx("g",{id:"Web-demo",stroke:"none",strokeWidth:"1",fill:"none",fillRule:"evenodd",children:k.jsx("g",{id:"step1",transform:"translate(-950.000000, -380.000000)",fill:t??"currentColor",fillRule:"nonzero",children:k.jsx("g",{id:"Group",transform:"translate(950.000000, 380.000000)",children:k.jsx("g",{id:"Group-2",children:k.jsx("g",{id:"camera",children:k.jsx("path",{d:"M21,3 L17,3 L15,0 L9,0 L7,3 L3,3 C1.34314575,3 0,4.34314575 0,6 L0,18 C0,19.6568542 1.34314575,21 3,21 L21,21 C22.6568542,21 24,19.6568542 24,18 L24,6 C24,4.34314575 22.6568542,3 21,3 Z M12,17 C9.23857625,17 7,14.7614237 7,12 C7,9.23857625 9.23857625,7 12,7 C14.7614237,7 17,9.23857625 17,12 C17,14.7614237 14.7614237,17 12,17 L12,17 Z",id:"Shape"})})})})})})]})}export{G as C,q as u};