@tsocial/tvweb-sdk
Version:
TV Web SDK - The Standalone SDK
2 lines (1 loc) • 5.67 kB
JavaScript
import{x as e,y as r,Q as s,r as n,e as a,c as t,s as o,j as i,a2 as c,n as l,P as u,b as p}from"./chunk-554942c8.js";import{p as d,g as m,S as f,a as g,O as h,C as C,E as y,b as j,B as D,c as F,L as x}from"./chunk-c347f1a0.js";import{u as S,C as b}from"./chunk-cd77ddca.js";import{M as I,O as T,W as E,C as k}from"./chunk-2221afbd.js";import{D as R}from"./chunk-644e2eb3.js";import{u as L}from"./chunk-306b4e50.js";import"./chunk-1c4b07c3.js";import"./chunk-d34f70f1.js";let v=p.isMobile?{width:{ideal:640}}:null;function P(u){let{apiCheck:p,onLivenessDetectionDone:R,captureFrameSettings:P,onFramesCaptured:A,frontCamera:M,flipVideoHorizontal:O,customDirectionIcon:H,customStepTimeConstraints:V,onProcessing:w,customErrors:U,apiCredentials:$,outputEncryptionSettings:_,cameraScale:B,defaultCameraId:K,passiveModeAuto:N,offsetFaceY:z,styledComponent:G,serviceSettings:Y,onReset:W,isLoading:Q}=u,q=e(),{onErrorCallback:J,onCloseCallback:X}=L(),Z=r.useAsset("bg_camera_mask.png"),ee=r.useAsset("bg_camera_mask_red.png"),er=s("IDCapturing.loadingIcon.src","ic_loading.gif"),[es,en]=n.useState({}),{yFaceDetectionError:ea,yFaceVerificationStepsWrapper:et}=es,[eo,ei]=n.useState(""),[ec,el]=n.useState(),eu=n.useMemo(()=>({backgroundColor:a("Selfie.backgroundColor")({theme:q})}),[q]),ep=n.useCallback(({lostY:e,height:r,clientHeight:s})=>{let n=e+25,a=n+30;en({yFaceDetectionError:n,yFaceVerificationStepsWrapper:a+r+20});let t=Math.floor(e),o=Math.floor(s-e),i=Math.floor(a);return 0!==z&&(i+z<t||i+z+r>o)?J({code:`offsetFaceY must be in [-${i-t}, ${o-r-i}]`}):i+=z,{y:i}},[z,J]),{shouldResetFlowOnOrientationChange:ed,countdownToTakePicture:em,cropArea:ef,curStepIndex:eg,faceDetectionError:eh,resetFlow:eC,handleTriggerPassiveMode:ey,handleVideoPlayed:ej,refVideo:eD,showCountdown:eF,steps:ex,refIsReseting:eS,videoPlayed:eb,warmupDone:eI,showCaptureButton:eT,shouldShowCountdown:eE,showLoading:ek}=S({currentOrientation:ec,apiCheck:p,bgCameraMask:Z,bgCameraMaskRed:ee,surroundStyle:eu,onLivenessDetectionDone:R,onError:J,cropAreaDimension:ep,customDirectionIcon:H,captureFrameSettings:P,onFramesCaptured:A,setRemainingTime:ei,customStepTimeConstraints:V,onProcessing:w,customErrors:U,apiCredentials:$,outputEncryptionSettings:_,cameraScale:B,passiveModeAuto:N,serviceSettings:Y,onReset:W});n.useEffect(()=>{"string"==typeof ex[0]?.directionIcon&&Promise.all(ex.map(e=>d(e.directionIcon)))},[ex]);let{CloseCameraButton:eR}=G,eL=m(u,q),ev=eS.current?0:eg/ex.length*100,{lang:eP}=t.useSDKSettings(),eA=n.useRef(0),eM=n.useRef({}),eO=n.useRef(o.ErrorDuration.SHORT),eH=n.useMemo(()=>{let{msg:e,duration:r=o.ErrorDuration.SHORT}=eh||{},s=e?.[eP];return Date.now()-eA.current>=eO.current&&(eA.current=Date.now(),eO.current=r,eM.current=s),eM.current},[eh,eg]),eV=n.useCallback(e=>{el(e),ed?eC():e===I.LANDSCAPE?eD.current?.pause():eD.current?.play()},[eD,eC,ed]);return i.jsx(T,{onOrientationChange:eV,children:i.jsxs(c,{frontCamera:M,onVideoPlayed:ej,onClose:X,flipHorizontal:O??M,ref:eD,videoSettings:v,onError:J,scale:B,defaultCameraId:K,closeButton:eR||null,children:[!eI&&i.jsx(E,{}),eb?i.jsxs(i.Fragment,{children:["string"==typeof eH?i.jsx(f,{top:ea-15,className:"face-detection-error",children:eH}):null,ef.current?i.jsxs(k,{x:`${ef.current.x}px`,y:`${ef.current.y}px`,width:`${ef.current.width}px`,height:`${ef.current.height}px`,surroundStyle:ef.current.surroundStyle,children:[i.jsx(g,{}),i.jsx(h,{...eL,progress:ev,showErrorRing:!!eh&&a("Selfie.progressCircle.showErrorRing")({theme:q})}),eE?i.jsx(C,{children:em}):null,eh&&i.jsx(y,{})]}):null,eo&&i.jsx(j,{top:et-30,children:eo}),eT?i.jsx(D,{children:i.jsx(F,{onClick:ey,disabled:eF,children:l(q,"Selfie.captureIcon.src")?i.jsx("img",{src:l(q,"Selfie.captureIcon.src"),alt:""}):i.jsx(b,{fillColor:"rgba(193, 197, 204, 1)"})})}):null]}):null,(ek||Q)&&i.jsx(x,{children:i.jsx("img",{src:er,alt:""})})]})})}P.propTypes={apiCheck:u.bool,mode:u.string,onLivenessDetectionDone:u.func,onClose:u.func,onError:u.func,onReset:u.func,captureFrameSettings:u.shape({}),onFramesCaptured:u.func,frontCamera:u.bool,isLoading:u.bool,flipVideoHorizontal:u.bool,customDirectionIcon:u.shape({}),customStepTimeConstraints:u.shape({}),onProcessing:u.func,customErrors:u.shape({}),apiCredentials:u.shape({accessKey:u.string,secretKey:u.string,apiUrl:u.string}),outputEncryptionSettings:u.shape({}),cameraScale:u.number,defaultCameraId:u.string,passiveModeAuto:u.bool,offsetFaceY:u.number,styledComponent:u.shape({CloseCameraButton:u.node}),serviceSettings:u.shape({})},P.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(R,{type:o.FaceDirection.LEFT}),[o.FaceDirection.RIGHT]:i.jsx(R,{type:o.FaceDirection.RIGHT}),[o.FaceDirection.UP]:i.jsx(R,{type:o.FaceDirection.UP}),[o.FaceDirection.FRONTAL]:i.jsx(R,{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{P as default};