@tsocial/tvweb-sdk 5.36.0 → 5.37.0

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 (29) hide show
  1. package/build/esm/{chunk-de5b2d76.js → chunk-16aae30a.js} +1 -1
  2. package/build/esm/{chunk-e31767ae.js → chunk-1aa3850a.js} +1 -1
  3. package/build/esm/{chunk-81ce3c83.js → chunk-3ed55750.js} +1 -1
  4. package/build/esm/{chunk-641f0a71.js → chunk-3eee0401.js} +1 -1
  5. package/build/esm/{chunk-44cbd562.js → chunk-444546ef.js} +55 -55
  6. package/build/esm/{chunk-571e89c0.js → chunk-54342a62.js} +1 -1
  7. package/build/esm/chunk-78da2232.js +1121 -0
  8. package/build/esm/{chunk-e0f43811.js → chunk-7b011490.js} +1 -1
  9. package/build/esm/{chunk-0811f0b9.js → chunk-84c22657.js} +2 -2
  10. package/build/esm/{chunk-6b0b5adc.js → chunk-86785e18.js} +1 -1
  11. package/build/esm/{chunk-dc7a2229.js → chunk-8db48f4d.js} +1 -1
  12. package/build/esm/{chunk-e3a48659.js → chunk-91c53b7b.js} +1 -1
  13. package/build/esm/{chunk-ee9ed408.js → chunk-a03b960b.js} +1 -1
  14. package/build/esm/{chunk-6e830372.js → chunk-b5e82a4b.js} +1 -1
  15. package/build/esm/{chunk-e77bab5e.js → chunk-bf5a5b12.js} +1 -1
  16. package/build/esm/{chunk-3475f25e.js → chunk-c1fff47f.js} +1 -1
  17. package/build/esm/{chunk-fa450310.js → chunk-c91849f8.js} +1 -1
  18. package/build/esm/{chunk-abf5e014.js → chunk-c9afc075.js} +1 -1
  19. package/build/esm/{chunk-7f5333af.js → chunk-db249df9.js} +1 -1
  20. package/build/esm/chunk-df824644.js +1 -0
  21. package/build/esm/{chunk-e289e491.js → chunk-f309ca64.js} +1 -1
  22. package/build/esm/{chunk-b87b1853.js → chunk-fbbb4c3f.js} +1 -1
  23. package/build/esm/tvweb-sdk.esm.min.js +1 -1
  24. package/build/tvweb-sdk.cjs.min.js +668 -668
  25. package/build/tvweb-sdk.standalone.js +1504 -15963
  26. package/build/tvweb-sdk.standalone.min.js +668 -668
  27. package/package.json +5 -6
  28. package/build/esm/chunk-ed832fec.js +0 -1121
  29. package/build/esm/chunk-ff693e7b.js +0 -1
@@ -1,4 +1,4 @@
1
- import{i as e,P as t,j as n,B as o,r as r,X as i,aU as a,a3 as u,m as l,c as s,D as c,k as d,b as p,aV as f}from"./chunk-ed832fec.js";let h=e.table`
1
+ import{i as e,P as t,j as n,B as o,r as r,X as i,aU as a,a3 as u,m as l,c as s,D as c,k as d,b as p,aV as f}from"./chunk-78da2232.js";let h=e.table`
2
2
  width: 100%;
3
3
  height: 100%;
4
4
  td {
@@ -1,4 +1,4 @@
1
- let e,t;import{r as r,i as a,j as o,e as i,F as n,aE as l,J as s,au as c,aF as u,aG as h,s as d,c as f,G as m,t as g,aH as _,v as p,av as b,k as y,K as w,P as E,d as C}from"./chunk-ed832fec.js";import{W as v}from"./chunk-e0f43811.js";let A=({onVideoPlayed:e})=>{let[t,a]=r.useState(!1),[o,i]=r.useState({});return{onVideoPlayed:r.useCallback(t=>{i((e=>{let{videoAreaWidth:t,videoAreaHeight:r,lostX:a,lostY:o}=e;return{width:t,height:r,x:Math.max(a,0),y:Math.max(o,0)}})(t)),a(!0),"function"==typeof e&&e(t)},[e]),cropArea:o,isPlaying:t}},F={LOADING:"loading",FAR_FACE:"far_face",CLOSE_FACE:"close_face",START_FLASHING:"start_flashing",STOP_DECTECTING:"stop_detecting"},R={FAR_FACE:"far",CLOSE_FACE:"close",FLASHING:"flashing"},S={timeout:"timeout",no_face:"no_face"},x=({prediction:e,canvas:t,index:r,quality:a=.8})=>{let o=t.toDataURL("image/jpeg",a);return e?{label:"portrait",base64:o.split(",")[1],landmarks:e.landmarks,index:r}:{label:"portrait",base64:o.split(",")[1],index:r}},k=a.div`
1
+ let e,t;import{r as r,i as a,j as o,e as i,G as n,aE as l,I as s,au as c,aF as u,aG as h,s as d,c as f,J as m,t as g,aH as _,v as p,av as b,k as y,K as w,P as E,d as C}from"./chunk-78da2232.js";import{W as v}from"./chunk-7b011490.js";let A=({onVideoPlayed:e})=>{let[t,a]=r.useState(!1),[o,i]=r.useState({});return{onVideoPlayed:r.useCallback(t=>{i((e=>{let{videoAreaWidth:t,videoAreaHeight:r,lostX:a,lostY:o}=e;return{width:t,height:r,x:Math.max(a,0),y:Math.max(o,0)}})(t)),a(!0),"function"==typeof e&&e(t)},[e]),cropArea:o,isPlaying:t}},F={LOADING:"loading",FAR_FACE:"far_face",CLOSE_FACE:"close_face",START_FLASHING:"start_flashing",STOP_DECTECTING:"stop_detecting"},R={FAR_FACE:"far",CLOSE_FACE:"close",FLASHING:"flashing"},S={timeout:"timeout",no_face:"no_face"},x=({prediction:e,canvas:t,index:r,quality:a=.8})=>{let o=t.toDataURL("image/jpeg",a);return e?{label:"portrait",base64:o.split(",")[1],landmarks:e.landmarks,index:r}:{label:"portrait",base64:o.split(",")[1],index:r}},k=a.div`
2
2
  position: fixed;
3
3
  top: 0;
4
4
  left: 0;
@@ -7,4 +7,4 @@ let e,t;import{r as r,i as a,j as o,e as i,F as n,aE as l,J as s,au as c,aF as u
7
7
  z-index: 1001;
8
8
 
9
9
  background-color: ${e=>e.$overlay?"white":"transparent"};
10
- `,T=({children:e=null,overlay:t=!1,loadingComponent:r=o.jsx(v,{})})=>o.jsxs(k,{$overlay:t,children:[t&&r,o.jsx("div",{style:{visibility:t?"hidden":"visible"},children:e})]}),L=(e,t,r)=>{let{smallScale:a,largeScale:o,ovalPadding:i}=e,n=t.width/t.height,l=a*r.height,s=o*r.height,c=i.top+i.bottom,u=i.left+i.right,h=s-c;if(parseFloat((h*n).toFixed(2))+u>r.width){let e=Number(((r.width-u)/t.width).toFixed(2));return{smallScale:Number((a/o*e).toFixed(2)),largeScale:e}}let d=Number(((l-c)/t.height).toFixed(2));return{smallScale:d,largeScale:Number((h/t.height).toFixed(2))}},M=({offset:e,ovalPadding:t,largeScale:r,ovalHeight:a,maskHeight:o})=>{let i=a/2+t.bottom;return(i+e)*r>o/2?o/2/r-i:e},P=e=>{r.useEffect(()=>()=>{e&&e.srcObject?.getTracks().forEach(e=>{e.stop()})},[e])},O=()=>{let[e,t]=r.useState(null),[a,o]=r.useState(!1),i=r.useRef(null);return r.useEffect(()=>{if(!i.current)return()=>{};let e=i.current,r=()=>{t(e.getBoundingClientRect()),o(!1)},a=()=>{o(!0)};return e.addEventListener("transitionstart",a),e.addEventListener("transitionend",r),()=>{e.removeEventListener("transitionstart",a),e.removeEventListener("transitionend",r)}},[]),[i,e??i.current?.getBoundingClientRect(),a,o]},B=()=>{let e=r.useRef(),{sendEvent:t}=i.useSDKTracking();return r.useCallback((r,a,o={})=>{let i=performance.now(),n={};"object"==typeof o&&(n={...o},e.current&&(n.interval_vs_previous_in_ms=Math.round(i-e.current))),"function"==typeof o&&(n=o({lastTimeLog:e.current})),e.current=i,t({tag:r,event:a,log:n})},[t])},D=(e,t)=>{let a=r.useRef(e);r.useEffect(()=>{a.current=e},[e]),r.useEffect(()=>{t&&"function"==typeof a.current&&a.current()},[t])},N=({compareFn:e,duration:t,minFrames:a=null})=>{let o=r.useRef(null),i=r.useRef(!1),n=r.useRef(0),l=r.useRef(()=>{}),{compareAndStoreResult:s,getBestResult:c,reset:u}=r.useMemo(()=>{var r,a;let o,i,n;return r=e,a=t,o=null,i=null,n=()=>null!==i&&performance.now()-i>a,{checkIsTimeUp:n,compareAndStoreResult:e=>{null===o&&(o=e,i=performance.now()),n()||r(o,e)&&(o=e)},getBestResult:()=>o,reset:()=>{o=null,i=null}}},[e,t]),h=r.useCallback(()=>{u(),n.current=0,i.current=!1,o.current&&(clearTimeout(o.current),o.current=null)},[u]),d=r.useCallback(()=>null!==o.current,[]),f=r.useCallback(e=>{if(s(e),n.current+=1,!i.current||"number"!=typeof a||n.current<a)return;let t=c();l.current(t),h()},[s,c,a,h]),m=r.useCallback(({initialFrame:e,onDone:r})=>{l.current=r,f(e),o.current=setTimeout(()=>{if(i.current=!0,"number"==typeof a&&n.current<a)return;let e=c();l.current(e),h()},t)},[f,t,c,a,h]);return r.useEffect(()=>()=>{clearTimeout(o.current)},[]),r.useMemo(()=>({captureFrame:f,getBestResult:c,isAutoCapturing:d,startCapturing:m,stopCapturing:h}),[f,c,d,m,h])},I=e=>{let t=document.createElement("canvas");return t.setAttribute("width",e.videoWidth.toString()),t.setAttribute("height",e.videoHeight.toString()),t.getContext("2d").drawImage(e,0,0,e.videoWidth,e.videoHeight),t},j=()=>{let[e,t]=r.useState(Date.now());return{sessionId:e,updateSessionId:r.useCallback(()=>{t(Date.now())},[])}},z=(e,t)=>{if(0===Object.keys(e).length)return{topLeft:[0,0],bottomRight:[0,0],probability:0,landmarks:[]};let r=e.topLeft??[0,0],a=e.bottomRight??[0,0],o=e.probability??0,i=e.landmarks??[];return{topLeft:[r[0]*t,r[1]*t],bottomRight:[a[0]*t,a[1]*t],probability:o,landmarks:i.map(e=>[e[0]*t,e[1]*t])}},W=200,q=({size:e,scale:t=1,video:r,baseSize:a=W})=>{let{width:o,height:i}=e,{videoWidth:n=Number.MAX_SAFE_INTEGER,videoHeight:l=Number.MAX_SAFE_INTEGER}=r??{},s=Math.min(o,i)/a,c=Math.round(o/s*t),u=Math.round(i/s*t);return c>n||u>l?{width:o,height:i}:{width:c,height:u}},G=({width:e,height:t,cameraScale:r})=>{let a=document.createElement("canvas");a.width=e,a.height=t;let o=a.getContext("2d");return o?(o.translate(e,0),o.scale(-1*r,+r)):console.error("Failed to get 2D context from canvas in createLivenessCanvas"),a},H=({maskBoundingBox:e,faceRatio:t,validFaceRatio:r,video:a,shouldCropCenterSquare:o=!0,cropArea:i,frame:l,facePrediction:s,detectionToWholeFaceRatio:c=.8})=>{let u=e.width*t/r,h=u/e.width,d=e.height*h,f={x:e.x-(u-e.width)/2,y:e.y-(d-e.height)/2,width:u,height:d};f.x+f.width>i.x+i.width&&(f.width=i.width,f.x=i.x),f.y+f.height>i.y+i.height&&(f.height=i.height,f.y=i.y);let m=null;if(o){let e=Math.min(f.width,f.height),t=(s.bottomRight[1]-s.topLeft[1])/c,r=s.bottomRight[1]-t+(t-e)/2+i.y;r+e>f.y+f.height&&(r=f.y+f.height-e);let o={x:f.x+f.width/2-e/2,y:r,width:e,height:e};m=n.analyzeVideoAndWindowSizes(a,o)}else m=n.analyzeVideoAndWindowSizes(a,f);let g=q({size:{width:m.cropWidth,height:m.cropHeight},baseSize:400,video:a}),_=G({width:g.width,height:g.height,cameraScale:1}),p=_.width,b=_.height;return _.getContext("2d").drawImage(l,m.cropX,m.cropY,m.cropWidth,m.cropHeight,0,0,p,b),_},V=l(async function e({tfScriptUrls:t,closeEyesModelUrl:r,blazefaceModelUrl:a,qualifyModelUrl:o,opencvUrl:i}={}){let n=new u(r),l=new h(o),d=new c;await s.loadTensorFlow(t),await s.initTensorFlow({preferredBackends:["wasm","cpu"]});let f=[s.loadBlazefaceModel({modelUrl:a}),n.load(),l.init({opencvUrl:i}),c.init({opencvUrl:i})],[{blazefaceModel:m}]=await Promise.all(f);return{closeEyesModel:n,blazefaceModel:m,notQualifiedModel:l,brightnessDetector:d}}),U=({width:e,height:t,cameraScale:a=1,debug:o=!1})=>{let[i,n]=r.useState(null);return r.useEffect(()=>{let r=G({width:e,height:t,cameraScale:a});return o&&(document.body.appendChild(r),r.style.position="fixed",r.style.top="0",r.style.left="0",r.style.zIndex="9999"),n(r),()=>{o&&document.body.removeChild(r)}},[a,o,t,e]),i},K=y.isMobile?200:400;function J({cameraScale:e=1,isVideoPlaying:t,step:a,cropArea:o,videoRef:i,onFarFaceDetected:l,onFarFullFaceDetected:s,onCloseFaceDetected:c,onCloseFullFaceDetected:u,onFlashingFramesCaptured:h,frameInterval:y=0,useFaceDetectorWhenFlashing:w,onFaceError:E,onError:C,maskBoundingRect:v,shouldPauseFaceDetection:A,shouldContinueOnError:R,debug:S=!1,faceDetectionSettings:x}){let{faceSettings:k,maskSettings:T,closeEyesSettings:L,captureFrameSettings:M,blurCheckFarSettings:P,blurCheckCloseSettings:O,brightnessDetectionFarSettings:B,brightnessDetectionCloseSettings:D,notQualifiedFarSettings:N,notQualifiedCloseSettings:I,frontalFaceCheckSettings:j}=x,{chinToMaskBottomPadding:W}=T,{frameScale:G}=M,{enable:H,timeout:J,forceCheck:X}=L,{enable:$,upDownBoundMin:Y,upDownBoundMax:Q}=j,{minFarFaceRatio:Z,maxFarFaceRatio:ee,closeFaceRatio:et}=k,er=(e=>{let[t,a]=r.useState(e);return r.useEffect(()=>{(async()=>{try{let t=Math.max(16.666666666666668,33.333333333333336,e);a(t)}catch(e){console.error(e),a(20)}})()},[e]),t})(y),ea=(({videoRef:e,cropArea:t})=>r.useMemo(()=>e.current&&0!==Object.keys(t).length?n.analyzeVideoAndWindowSizes(e.current,t):{},[e,t]))({videoRef:i,cropArea:o}),eo=q({size:{width:ea.cropWidth,height:ea.cropHeight},scale:G,video:i.current}),ei=(({cropArea:e,maskBoundingRect:t,baseSize:r})=>{let{width:a,height:o,x:i,y:n}=e,l=Math.min(a,o)/r,s=t?.left??0,c=t?.top??0,u=t?.right??a;return{left:Math.max((s-i)/l,0),right:Math.min((u-i)/l,a/l),top:Math.max((c-n)/l,0),bottom:Math.min(((t?.bottom??o)-n)/l,o/l)}})({cropArea:o,maskBoundingRect:v,baseSize:Math.min(eo.width,eo.height)}),en=U({width:eo.width,height:eo.height,cameraScale:e}),el=Math.min(o.width,o.height)/Math.min(eo.width,eo.height),es=U({width:K,height:K*(eo.height/eo.width),cameraScale:e,debug:S}),ec=(({width:e,height:t,debug:a})=>{let o=r.useRef(null),i=r.useMemo(()=>{let r=document.createElement("canvas");return r.width=e,r.height=t,r.style.position="fixed",r.style.bottom="0",r.style.left="0",r.style.zIndex="99999",o.current=r,a&&document.body.appendChild(r),r},[t,e,a]);return r.useEffect(()=>()=>{a&&document.body.removeChild(o.current)},[a]),i})({width:160,height:150,debug:S}),{customUrls:eu}=f.useSDKSettings(),[eh,ed]=((e,t)=>{let[a,o]=r.useState({}),i=Object.keys(a).length>0;return r.useEffect(()=>{let r=!1;return(async()=>{try{let t=await V(e);if(r)return;o(t)}catch(e){t({...d.Errors.unable_to_load_model,details:e}),console.error(e)}})(),()=>{r=!0}},[i,e,t]),[a,i]})(eu,C),ef=r.useRef(null),{markTime:em,checkIfEllapsed:eg}=(({timeout:e})=>{let t=r.useRef(null),a=r.useCallback(()=>{t.current=performance.now()},[]),o=r.useCallback(()=>null===t.current?(a(),!1):performance.now()-t.current>e,[a,e]);return{markTime:a,checkIfEllapsed:o}})({timeout:1e3*J}),e_=ed&&t,{closeEyesModel:ep,blazefaceModel:eb,notQualifiedModel:ey,brightnessDetector:ew}=eh,eE=r.useCallback(async(e,t)=>{try{if(t?.width===0||t?.height===0||null===i.current||A||a===F.STOP_DECTECTING)return;let{cropX:n,cropY:f,cropWidth:y,cropHeight:C}=e,v=t.width,x=t.height;t.getContext("2d").drawImage(i.current,n,f,y,C,0,0,v,x);let k=m.drawToSquareCanvas(t),T=K/v;if(S&&es.getContext("2d").drawImage(i.current,n,f,y,C,0,0,v*T,x*T),!w&&a===F.START_FLASHING){"function"==typeof h&&await h({prediction:null,originalRatio:el,canvas:t});return}let L=await g.getModelPredictions({model:eb,sCanvas:k}),M=[[ei.left,ei.top],[ei.right,ei.bottom]],{error:j,fullFace:q,faceRatio:G}=await _.validatePredictions({predictions:L,cropAreaCoordinates:M});if(S){var r,o;let e,t={left:ei.left*T,top:ei.top*T,right:ei.right*T,bottom:ei.bottom*T};r=es,o={x:t.left,y:t.top,width:t.right-t.left,height:t.bottom-t.top},e=r.getContext("2d"),e?(e.strokeStyle="red",e.lineWidth=1,e.beginPath(),e.rect(o.x,o.y,o.width,o.height),e.stroke(),e.closePath()):console.warn("drawBoundingBox: 2D context is not available.");let a=L.map(e=>z(e,T));((e,t,r=!1)=>{let a=e.getContext("2d");if(!a)return;let o=e.width;a.strokeStyle="blue",a.fillStyle="blue",a.lineWidth=1,t.forEach(e=>{e.landmarks.forEach(e=>{a.beginPath(),a.arc(r?o-e[0]:e[0],e[1],2,0,2*Math.PI),a.fill(),a.closePath()}),a.beginPath();let t={x:r?o-e.bottomRight[0]:e.bottomRight[0],y:e.topLeft[1],width:e.bottomRight[0]-e.topLeft[0],height:e.bottomRight[1]-e.topLeft[1]};a.rect(t.x,t.y,t.width,t.height),a.stroke(),a.closePath()})})(es,a,!0)}let V=d.FaceDirection.FRONTAL;if(q&&$){let e=await _.calculateFaceDirection({landmarks:q.landmarks,upDownBound:{lower:Y,upper:Q}});V=e?.gesture??""}(q||j?.code===d.Errors.partial_face.code)&&a===F.FAR_FACE&&"function"==typeof l&&await l({prediction:L[0],originalRatio:el,canvas:t}),(q||j?.code===d.Errors.partial_face.code)&&a===F.CLOSE_FACE&&"function"==typeof c&&await c({prediction:L[0],originalRatio:el,canvas:t});let U=j?.code;try{if(U===d.Errors.no_face.code)throw Error("no_face");if(U===d.Errors.multiple_faces.code){let e=_.calculateFaceArea(L[0]),t=_.calculateFaceArea(L[1]);if(e<=2*t)throw Error("multiple_faces")}if(V!==d.FaceDirection.FRONTAL)throw Error("face_not_frontal");if(U===d.Errors.partial_face.code){let e=_.cropFaceInsideBox([L[0].topLeft,L[0].bottomRight],M);if(p.rectEdgeRatio(e,M)>.95)throw Error("face_too_large")}if(a===F.FAR_FACE){if(G>ee)throw Error("face_too_large");if(G<Z)throw Error("face_too_small")}if(a===F.CLOSE_FACE&&G<et)throw Error("face_too_small");if(Array.isArray(L)&&L.length>0&&ei.bottom-L[0].bottomRight[1]>W)throw Error("face_too_high");if(U===d.Errors.face_out_of_box.code&&(a===F.FAR_FACE&&G>=Z&&G<=ee||a===F.CLOSE_FACE&&G>=et))throw Error("")}catch(e){U=e.message}let J=null;if(H)if(U)em();else{let e=await ep.predict(t,q.landmarks),r=!X&&eg();J=e.isEyeClose,e.isEyeClose&&!r&&(U="eye_close")}let er=null,ea=a===F.FAR_FACE?B:D;if((ea.enableTooBrightCheck||ea.enableTooDarkCheck)&&Array.isArray(L)&&L.length>0){let e=[[Math.max(L[0].topLeft[1],0),Math.min(L[0].bottomRight[0],t.width),Math.min(L[0].bottomRight[1],t.height),Math.max(L[0].topLeft[0],0)]],{score:r,message:a}=ew.score(t,e,ea.tooDarkThreshold,ea.tooBrightThreshold);er=r,""===U&&ea.enableTooBrightCheck&&"face_too_bright"===a&&(U="face_too_bright"),""===U&&ea.enableTooDarkCheck&&"face_too_dark"===a&&(U="face_too_dark")}let eo=0,en={enable:a===F.FAR_FACE?P.enable:O.enable,threshold:a===F.FAR_FACE?P.threshold:O.threshold};en.enable&&(eo=await b.calculateBlurScore(t),""!==U||b.hasBetterBlurScore(eo,en.threshold)||(U="blurry_face"));let eu=0,eh=0,ed="model_not_run",ef={enable:a===F.FAR_FACE?N.enable:I.enable,threshold:a===F.FAR_FACE?N.threshold:I.threshold};if(ef.enable&&q&&q.landmarks){let[e,r,a,o]=await ey.predict(t,q.landmarks,ef.threshold);eu=r,eh=o,ed=a,""!==U||e||(U="face_not_qualified")}if((S&&m.drawDebugCanvas(ec,{error:U,ovalFaceRatio:G?.toFixed(3)??"null",ovalError:j?.code??"null",step:a===F.FAR_FACE?"far":"close",blurScore:eo.toFixed(3),qualifyScore:eu.toFixed(3),brightnessScore:er?.toFixed(3)??"null"}),U)&&("function"==typeof E&&await E({error:U,currentStep:a}),!R))return;let e_=q,eE=G;if(!e_&&R&&(e_=Array.isArray(L)&&L.length>0?L[0]:{},eE=a===F.FAR_FACE?ee:et),a===F.FAR_FACE&&e_&&Z<=eE&&eE<=ee&&"function"==typeof s)return void await s({prediction:e_,originalRatio:el,canvas:t,frame:{faceRatio:eE,isEyeClosed:J,blurScore:eo,qualifyScore:eu,realQualifyScore:eh,qualifyModelMessage:ed,brightnessScore:er,faceError:U}});if(e_&&a===F.CLOSE_FACE&&eE>=et&&"function"==typeof u)return void await u({prediction:e_,originalRatio:el,canvas:t,frame:{faceRatio:eE,isEyeClosed:J,blurScore:eo,qualifyScore:eu,realQualifyScore:eh,qualifyModelMessage:ed,brightnessScore:er,faceError:U}});w&&e_&&a===F.START_FLASHING&&eE>=et&&"function"==typeof h&&await h({prediction:e_,originalRatio:el,canvas:t,faceError:U})}catch(e){console.error(e),C({error:e})}},[i,A,a,S,w,eb,ei.left,ei.top,ei.right,ei.bottom,$,H,B,D,P.enable,P.threshold,O.enable,O.threshold,N.enable,N.threshold,I.enable,I.threshold,R,Z,ee,et,es,h,el,Y,Q,l,c,W,ep,X,eg,em,ew,ey,ec,E,s,u,C]);return r.useEffect(()=>{let e=null,t=!1;return e_&&function r(){e=requestAnimationFrame(async e=>{t||null===i.current||((null===ef.current&&(ef.current=e),e-ef.current<er)?r():(ef.current=e,await eE(ea,en),r()))})}(),()=>{t=!0,cancelAnimationFrame(e)}},[en,ea,eE,e_,i,er]),{warmupDone:ed}}let X=e=>{let{shouldStart:t,totalTime:a,totalDelay:o,onError:i,onTimeout:n,onDelayEnd:l,maxRetriesSettings:s,interruptible:c=!0}=e,u=r.useRef(new w({totalTime:a,interruptible:c,totalDelayBetweenReset:o})),[h,f]=r.useState(a);return r.useEffect(()=>u.current.on("tick",({remainTime:e})=>{f(e)}),[n]),r.useEffect(()=>u.current.on("delaystart",({attemptCount:e})=>{s.enable&&e>=s.total?i(d.Errors.max_retry_reached):n()}),[s.enable,s.total,i,n]),r.useEffect(()=>u.current.on("delayend",()=>{l()}),[l]),r.useEffect(()=>u.current.on("reset",({attemptCount:e,fromBackground:t})=>{s.enable&&e>=s.total&&i(d.Errors.max_retry_reached),t&&(n(),l())}),[n,l,s.enable,s.total,i]),r.useEffect(()=>t?u.current.start():()=>{},[t]),{remaining:h}},$=e=>{switch(e){case"partial_face":return"flash_liveness.error.partial_face";case"no_face":case"face_out_of_box":return"flash_liveness.error.no_face";case"face_too_small":return"flash_liveness.error.face_too_small";case"face_too_large":return"flash_liveness.error.face_too_large";case"eye_close":return"flash_liveness.error.close_eye";case"face_not_frontal":return"flash_liveness.error.face_not_frontal";case"multiple_faces":return"flash_liveness.error.multiple_faces";case"face_too_high":return"flash_liveness.error.face_too_high";case"blurry_face":return"flash_liveness.error.face_too_blurry";case"face_not_qualified":return"flash_liveness.error.face_not_qualified";case"face_too_bright":return"flash_liveness.error.face_too_bright";case"face_too_dark":return"flash_liveness.error.face_too_dark";default:return""}},Y=e=>Array.isArray(e)?e.map(({base64:e,label:t,index:r,metadata:a})=>({base64:e,label:t,index:r,metadata:a})):e,Q=r.createContext({enable:!1,key:""}),Z=({children:e,settings:t})=>{let a=r.useMemo(()=>{let e=t?.key??"";return{enable:!!e,key:e}},[t?.key]);return o.jsx(Q.Provider,{value:a,children:e})};Z.propTypes={children:E.node.isRequired,settings:E.shape({key:E.string})},Z.defaultProps={settings:{key:""}};let ee=()=>r.useContext(Q),et=r.createContext({}),er=({apiCredentials:e,children:t})=>{let{apiClient:r}=C.useApiClient({apiCredentials:e});return o.jsx(et.Provider,{value:r,children:t})};er.propTypes={apiCredentials:E.shape({accessKey:E.string.isRequired,secretKey:E.string.isRequired,apiUrl:E.string.isRequired}),children:E.node.isRequired},er.defaultProps={apiCredentials:{}};let ea=()=>r.useContext(et);let eo=(e=[],t=async()=>(await Promise.all(e)).map(e=>({id:e?.data?.file_id??-1})),{uploadFrameBatch:(t,r,a)=>{let o=new Blob([JSON.stringify(t)]);e.push(r.uploadFile({file:o,metadata:JSON.stringify({type:"selfie"}),label:"video"},a))},getAllUploadedBatches:t,resetUploadBatches:()=>{e.length=0}});export{er as A,R as F,Z as O,S as R,F as S,T as W,O as a,N as b,j as c,A as d,I as e,x as f,J as g,P as h,D as i,X as j,H as k,M as l,$ as m,L as n,ee as o,ea as p,eo as q,Y as r,z as s,B as u};
10
+ `,T=({children:e=null,overlay:t=!1,loadingComponent:r=o.jsx(v,{})})=>o.jsxs(k,{$overlay:t,children:[t&&r,o.jsx("div",{style:{visibility:t?"hidden":"visible"},children:e})]}),L=(e,t,r)=>{let{smallScale:a,largeScale:o,ovalPadding:i}=e,n=t.width/t.height,l=a*r.height,s=o*r.height,c=i.top+i.bottom,u=i.left+i.right,h=s-c;if(parseFloat((h*n).toFixed(2))+u>r.width){let e=Number(((r.width-u)/t.width).toFixed(2));return{smallScale:Number((a/o*e).toFixed(2)),largeScale:e}}let d=Number(((l-c)/t.height).toFixed(2));return{smallScale:d,largeScale:Number((h/t.height).toFixed(2))}},M=({offset:e,ovalPadding:t,largeScale:r,ovalHeight:a,maskHeight:o})=>{let i=a/2+t.bottom;return(i+e)*r>o/2?o/2/r-i:e},P=e=>{r.useEffect(()=>()=>{e&&e.srcObject?.getTracks().forEach(e=>{e.stop()})},[e])},O=()=>{let[e,t]=r.useState(null),[a,o]=r.useState(!1),i=r.useRef(null);return r.useEffect(()=>{if(!i.current)return()=>{};let e=i.current,r=()=>{t(e.getBoundingClientRect()),o(!1)},a=()=>{o(!0)};return e.addEventListener("transitionstart",a),e.addEventListener("transitionend",r),()=>{e.removeEventListener("transitionstart",a),e.removeEventListener("transitionend",r)}},[]),[i,e??i.current?.getBoundingClientRect(),a,o]},B=()=>{let e=r.useRef(),{sendEvent:t}=i.useSDKTracking();return r.useCallback((r,a,o={})=>{let i=performance.now(),n={};"object"==typeof o&&(n={...o},e.current&&(n.interval_vs_previous_in_ms=Math.round(i-e.current))),"function"==typeof o&&(n=o({lastTimeLog:e.current})),e.current=i,t({tag:r,event:a,log:n})},[t])},D=(e,t)=>{let a=r.useRef(e);r.useEffect(()=>{a.current=e},[e]),r.useEffect(()=>{t&&"function"==typeof a.current&&a.current()},[t])},I=({compareFn:e,duration:t,minFrames:a=null})=>{let o=r.useRef(null),i=r.useRef(!1),n=r.useRef(0),l=r.useRef(()=>{}),{compareAndStoreResult:s,getBestResult:c,reset:u}=r.useMemo(()=>{var r,a;let o,i,n;return r=e,a=t,o=null,i=null,n=()=>null!==i&&performance.now()-i>a,{checkIsTimeUp:n,compareAndStoreResult:e=>{null===o&&(o=e,i=performance.now()),n()||r(o,e)&&(o=e)},getBestResult:()=>o,reset:()=>{o=null,i=null}}},[e,t]),h=r.useCallback(()=>{u(),n.current=0,i.current=!1,o.current&&(clearTimeout(o.current),o.current=null)},[u]),d=r.useCallback(()=>null!==o.current,[]),f=r.useCallback(e=>{if(s(e),n.current+=1,!i.current||"number"!=typeof a||n.current<a)return;let t=c();l.current(t),h()},[s,c,a,h]),m=r.useCallback(({initialFrame:e,onDone:r})=>{l.current=r,f(e),o.current=setTimeout(()=>{if(i.current=!0,"number"==typeof a&&n.current<a)return;let e=c();l.current(e),h()},t)},[f,t,c,a,h]);return r.useEffect(()=>()=>{clearTimeout(o.current)},[]),r.useMemo(()=>({captureFrame:f,getBestResult:c,isAutoCapturing:d,startCapturing:m,stopCapturing:h}),[f,c,d,m,h])},N=e=>{let t=document.createElement("canvas");return t.setAttribute("width",e.videoWidth.toString()),t.setAttribute("height",e.videoHeight.toString()),t.getContext("2d").drawImage(e,0,0,e.videoWidth,e.videoHeight),t},j=()=>{let[e,t]=r.useState(Date.now());return{sessionId:e,updateSessionId:r.useCallback(()=>{t(Date.now())},[])}},z=(e,t)=>{if(0===Object.keys(e).length)return{topLeft:[0,0],bottomRight:[0,0],probability:0,landmarks:[]};let r=e.topLeft??[0,0],a=e.bottomRight??[0,0],o=e.probability??0,i=e.landmarks??[];return{topLeft:[r[0]*t,r[1]*t],bottomRight:[a[0]*t,a[1]*t],probability:o,landmarks:i.map(e=>[e[0]*t,e[1]*t])}},W=200,q=({size:e,scale:t=1,video:r,baseSize:a=W})=>{let{width:o,height:i}=e,{videoWidth:n=Number.MAX_SAFE_INTEGER,videoHeight:l=Number.MAX_SAFE_INTEGER}=r??{},s=Math.min(o,i)/a,c=Math.round(o/s*t),u=Math.round(i/s*t);return c>n||u>l?{width:o,height:i}:{width:c,height:u}},G=({width:e,height:t,cameraScale:r})=>{let a=document.createElement("canvas");a.width=e,a.height=t;let o=a.getContext("2d");return o?(o.translate(e,0),o.scale(-1*r,+r)):console.error("Failed to get 2D context from canvas in createLivenessCanvas"),a},H=({maskBoundingBox:e,faceRatio:t,validFaceRatio:r,video:a,shouldCropCenterSquare:o=!0,cropArea:i,frame:l,facePrediction:s,detectionToWholeFaceRatio:c=.8})=>{let u=e.width*t/r,h=u/e.width,d=e.height*h,f={x:e.x-(u-e.width)/2,y:e.y-(d-e.height)/2,width:u,height:d};f.x+f.width>i.x+i.width&&(f.width=i.width,f.x=i.x),f.y+f.height>i.y+i.height&&(f.height=i.height,f.y=i.y);let m=null;if(o){let e=Math.min(f.width,f.height),t=(s.bottomRight[1]-s.topLeft[1])/c,r=s.bottomRight[1]-t+(t-e)/2+i.y;r+e>f.y+f.height&&(r=f.y+f.height-e);let o={x:f.x+f.width/2-e/2,y:r,width:e,height:e};m=n.analyzeVideoAndWindowSizes(a,o)}else m=n.analyzeVideoAndWindowSizes(a,f);let g=q({size:{width:m.cropWidth,height:m.cropHeight},baseSize:400,video:a}),_=G({width:g.width,height:g.height,cameraScale:1}),p=_.width,b=_.height;return _.getContext("2d").drawImage(l,m.cropX,m.cropY,m.cropWidth,m.cropHeight,0,0,p,b),_},V=l(async function e({tfScriptUrls:t,closeEyesModelUrl:r,blazefaceModelUrl:a,qualifyModelUrl:o,opencvUrl:i}={}){let n=new u(r),l=new h(o),d=new c;await s.loadTensorFlow(t),await s.initTensorFlow({preferredBackends:["wasm","cpu"]});let f=[s.loadBlazefaceModel({modelUrl:a}),n.load(),l.init({opencvUrl:i}),c.init({opencvUrl:i})],[{blazefaceModel:m}]=await Promise.all(f);return{closeEyesModel:n,blazefaceModel:m,notQualifiedModel:l,brightnessDetector:d}}),U=({width:e,height:t,cameraScale:a=1,debug:o=!1})=>{let[i,n]=r.useState(null);return r.useEffect(()=>{let r=G({width:e,height:t,cameraScale:a});return o&&(document.body.appendChild(r),r.style.position="fixed",r.style.top="0",r.style.left="0",r.style.zIndex="9999"),n(r),()=>{o&&document.body.removeChild(r)}},[a,o,t,e]),i},K=y.isMobile?200:400;function J({cameraScale:e=1,isVideoPlaying:t,step:a,cropArea:o,videoRef:i,onFarFaceDetected:l,onFarFullFaceDetected:s,onCloseFaceDetected:c,onCloseFullFaceDetected:u,onFlashingFramesCaptured:h,frameInterval:y=0,useFaceDetectorWhenFlashing:w,onFaceError:E,onError:C,maskBoundingRect:v,shouldPauseFaceDetection:A,shouldContinueOnError:R,debug:S=!1,faceDetectionSettings:x}){let{faceSettings:k,maskSettings:T,closeEyesSettings:L,captureFrameSettings:M,blurCheckFarSettings:P,blurCheckCloseSettings:O,brightnessDetectionFarSettings:B,brightnessDetectionCloseSettings:D,notQualifiedFarSettings:I,notQualifiedCloseSettings:N,frontalFaceCheckSettings:j}=x,{chinToMaskBottomPadding:W}=T,{frameScale:G}=M,{enable:H,timeout:J,forceCheck:X}=L,{enable:$,upDownBoundMin:Y,upDownBoundMax:Q}=j,{minFarFaceRatio:Z,maxFarFaceRatio:ee,closeFaceRatio:et}=k,er=(e=>{let[t,a]=r.useState(e);return r.useEffect(()=>{(async()=>{try{let t=Math.max(16.666666666666668,33.333333333333336,e);a(t)}catch(e){console.error(e),a(20)}})()},[e]),t})(y),ea=(({videoRef:e,cropArea:t})=>r.useMemo(()=>e.current&&0!==Object.keys(t).length?n.analyzeVideoAndWindowSizes(e.current,t):{},[e,t]))({videoRef:i,cropArea:o}),eo=q({size:{width:ea.cropWidth,height:ea.cropHeight},scale:G,video:i.current}),ei=(({cropArea:e,maskBoundingRect:t,baseSize:r})=>{let{width:a,height:o,x:i,y:n}=e,l=Math.min(a,o)/r,s=t?.left??0,c=t?.top??0,u=t?.right??a;return{left:Math.max((s-i)/l,0),right:Math.min((u-i)/l,a/l),top:Math.max((c-n)/l,0),bottom:Math.min(((t?.bottom??o)-n)/l,o/l)}})({cropArea:o,maskBoundingRect:v,baseSize:Math.min(eo.width,eo.height)}),en=U({width:eo.width,height:eo.height,cameraScale:e}),el=Math.min(o.width,o.height)/Math.min(eo.width,eo.height),es=U({width:K,height:K*(eo.height/eo.width),cameraScale:e,debug:S}),ec=(({width:e,height:t,debug:a})=>{let o=r.useRef(null),i=r.useMemo(()=>{let r=document.createElement("canvas");return r.width=e,r.height=t,r.style.position="fixed",r.style.bottom="0",r.style.left="0",r.style.zIndex="99999",o.current=r,a&&document.body.appendChild(r),r},[t,e,a]);return r.useEffect(()=>()=>{a&&document.body.removeChild(o.current)},[a]),i})({width:160,height:150,debug:S}),{customUrls:eu}=f.useSDKSettings(),[eh,ed]=((e,t)=>{let[a,o]=r.useState({}),i=Object.keys(a).length>0;return r.useEffect(()=>{let r=!1;return(async()=>{try{let t=await V(e);if(r)return;o(t)}catch(e){t({...d.Errors.unable_to_load_model,details:e}),console.error(e)}})(),()=>{r=!0}},[i,e,t]),[a,i]})(eu,C),ef=r.useRef(null),{markTime:em,checkIfEllapsed:eg}=(({timeout:e})=>{let t=r.useRef(null),a=r.useCallback(()=>{t.current=performance.now()},[]),o=r.useCallback(()=>null===t.current?(a(),!1):performance.now()-t.current>e,[a,e]);return{markTime:a,checkIfEllapsed:o}})({timeout:1e3*J}),e_=ed&&t,{closeEyesModel:ep,blazefaceModel:eb,notQualifiedModel:ey,brightnessDetector:ew}=eh,eE=r.useCallback(async(e,t)=>{try{if(t?.width===0||t?.height===0||null===i.current||A||a===F.STOP_DECTECTING)return;let{cropX:n,cropY:f,cropWidth:y,cropHeight:C}=e,v=t.width,x=t.height;t.getContext("2d").drawImage(i.current,n,f,y,C,0,0,v,x);let k=m.drawToSquareCanvas(t),T=K/v;if(S&&es.getContext("2d").drawImage(i.current,n,f,y,C,0,0,v*T,x*T),!w&&a===F.START_FLASHING){"function"==typeof h&&await h({prediction:null,originalRatio:el,canvas:t});return}let L=await g.getModelPredictions({model:eb,sCanvas:k}),M=[[ei.left,ei.top],[ei.right,ei.bottom]],{error:j,fullFace:q,faceRatio:G}=await _.validatePredictions({predictions:L,cropAreaCoordinates:M});if(S){var r,o;let e,t={left:ei.left*T,top:ei.top*T,right:ei.right*T,bottom:ei.bottom*T};r=es,o={x:t.left,y:t.top,width:t.right-t.left,height:t.bottom-t.top},e=r.getContext("2d"),e?(e.strokeStyle="red",e.lineWidth=1,e.beginPath(),e.rect(o.x,o.y,o.width,o.height),e.stroke(),e.closePath()):console.warn("drawBoundingBox: 2D context is not available.");let a=L.map(e=>z(e,T));((e,t,r=!1)=>{let a=e.getContext("2d");if(!a)return;let o=e.width;a.strokeStyle="blue",a.fillStyle="blue",a.lineWidth=1,t.forEach(e=>{e.landmarks.forEach(e=>{a.beginPath(),a.arc(r?o-e[0]:e[0],e[1],2,0,2*Math.PI),a.fill(),a.closePath()}),a.beginPath();let t={x:r?o-e.bottomRight[0]:e.bottomRight[0],y:e.topLeft[1],width:e.bottomRight[0]-e.topLeft[0],height:e.bottomRight[1]-e.topLeft[1]};a.rect(t.x,t.y,t.width,t.height),a.stroke(),a.closePath()})})(es,a,!0)}let V=d.FaceDirection.FRONTAL;if(q&&$){let e=await _.calculateFaceDirection({landmarks:q.landmarks,upDownBound:{lower:Y,upper:Q}});V=e?.gesture??""}(q||j?.code===d.Errors.partial_face.code)&&a===F.FAR_FACE&&"function"==typeof l&&await l({prediction:L[0],originalRatio:el,canvas:t}),(q||j?.code===d.Errors.partial_face.code)&&a===F.CLOSE_FACE&&"function"==typeof c&&await c({prediction:L[0],originalRatio:el,canvas:t});let U=j?.code;try{if(U===d.Errors.no_face.code)throw Error("no_face");if(U===d.Errors.multiple_faces.code){let e=_.calculateFaceArea(L[0]),t=_.calculateFaceArea(L[1]);if(e<=2*t)throw Error("multiple_faces")}if(V!==d.FaceDirection.FRONTAL)throw Error("face_not_frontal");if(U===d.Errors.partial_face.code){let e=_.cropFaceInsideBox([L[0].topLeft,L[0].bottomRight],M);if(p.rectEdgeRatio(e,M)>.95)throw Error("face_too_large")}if(a===F.FAR_FACE){if(G>ee)throw Error("face_too_large");if(G<Z)throw Error("face_too_small")}if(a===F.CLOSE_FACE&&G<et)throw Error("face_too_small");if(Array.isArray(L)&&L.length>0&&ei.bottom-L[0].bottomRight[1]>W)throw Error("face_too_high");if(U===d.Errors.face_out_of_box.code&&(a===F.FAR_FACE&&G>=Z&&G<=ee||a===F.CLOSE_FACE&&G>=et))throw Error("")}catch(e){U=e.message}let J=null;if(H)if(U)em();else{let e=await ep.predict(t,q.landmarks),r=!X&&eg();J=e.isEyeClose,e.isEyeClose&&!r&&(U="eye_close")}let er=null,ea=a===F.FAR_FACE?B:D;if((ea.enableTooBrightCheck||ea.enableTooDarkCheck)&&Array.isArray(L)&&L.length>0){let e=[[Math.max(L[0].topLeft[1],0),Math.min(L[0].bottomRight[0],t.width),Math.min(L[0].bottomRight[1],t.height),Math.max(L[0].topLeft[0],0)]],{score:r,message:a}=ew.score(t,e,ea.tooDarkThreshold,ea.tooBrightThreshold);er=r,""===U&&ea.enableTooBrightCheck&&"face_too_bright"===a&&(U="face_too_bright"),""===U&&ea.enableTooDarkCheck&&"face_too_dark"===a&&(U="face_too_dark")}let eo=0,en={enable:a===F.FAR_FACE?P.enable:O.enable,threshold:a===F.FAR_FACE?P.threshold:O.threshold};en.enable&&(eo=await b.calculateBlurScore(t),""!==U||b.hasBetterBlurScore(eo,en.threshold)||(U="blurry_face"));let eu=0,eh=0,ed="model_not_run",ef={enable:a===F.FAR_FACE?I.enable:N.enable,threshold:a===F.FAR_FACE?I.threshold:N.threshold};if(ef.enable&&q&&q.landmarks){let[e,r,a,o]=await ey.predict(t,q.landmarks,ef.threshold);eu=r,eh=o,ed=a,""!==U||e||(U="face_not_qualified")}if((S&&m.drawDebugCanvas(ec,{error:U,ovalFaceRatio:G?.toFixed(3)??"null",ovalError:j?.code??"null",step:a===F.FAR_FACE?"far":"close",blurScore:eo.toFixed(3),qualifyScore:eu.toFixed(3),brightnessScore:er?.toFixed(3)??"null"}),U)&&("function"==typeof E&&await E({error:U,currentStep:a}),!R))return;let e_=q,eE=G;if(!e_&&R&&(e_=Array.isArray(L)&&L.length>0?L[0]:{},eE=a===F.FAR_FACE?ee:et),a===F.FAR_FACE&&e_&&Z<=eE&&eE<=ee&&"function"==typeof s)return void await s({prediction:e_,originalRatio:el,canvas:t,frame:{faceRatio:eE,isEyeClosed:J,blurScore:eo,qualifyScore:eu,realQualifyScore:eh,qualifyModelMessage:ed,brightnessScore:er,faceError:U}});if(e_&&a===F.CLOSE_FACE&&eE>=et&&"function"==typeof u)return void await u({prediction:e_,originalRatio:el,canvas:t,frame:{faceRatio:eE,isEyeClosed:J,blurScore:eo,qualifyScore:eu,realQualifyScore:eh,qualifyModelMessage:ed,brightnessScore:er,faceError:U}});w&&e_&&a===F.START_FLASHING&&eE>=et&&"function"==typeof h&&await h({prediction:e_,originalRatio:el,canvas:t,faceError:U})}catch(e){console.error(e),C({error:e})}},[i,A,a,S,w,eb,ei.left,ei.top,ei.right,ei.bottom,$,H,B,D,P.enable,P.threshold,O.enable,O.threshold,I.enable,I.threshold,N.enable,N.threshold,R,Z,ee,et,es,h,el,Y,Q,l,c,W,ep,X,eg,em,ew,ey,ec,E,s,u,C]);return r.useEffect(()=>{let e=null,t=!1;return e_&&function r(){e=requestAnimationFrame(async e=>{t||null===i.current||((null===ef.current&&(ef.current=e),e-ef.current<er)?r():(ef.current=e,await eE(ea,en),r()))})}(),()=>{t=!0,cancelAnimationFrame(e)}},[en,ea,eE,e_,i,er]),{warmupDone:ed}}let X=e=>{let{shouldStart:t,totalTime:a,totalDelay:o,onError:i,onTimeout:n,onDelayEnd:l,maxRetriesSettings:s,interruptible:c=!0}=e,u=r.useRef(new w({totalTime:a,interruptible:c,totalDelayBetweenReset:o})),[h,f]=r.useState(a);return r.useEffect(()=>u.current.on("tick",({remainTime:e})=>{f(e)}),[n]),r.useEffect(()=>u.current.on("delaystart",({attemptCount:e})=>{s.enable&&e>=s.total?i(d.Errors.max_retry_reached):n()}),[s.enable,s.total,i,n]),r.useEffect(()=>u.current.on("delayend",()=>{l()}),[l]),r.useEffect(()=>u.current.on("reset",({attemptCount:e,fromBackground:t})=>{s.enable&&e>=s.total&&i(d.Errors.max_retry_reached),t&&(n(),l())}),[n,l,s.enable,s.total,i]),r.useEffect(()=>t?u.current.start():()=>{},[t]),{remaining:h}},$=e=>{switch(e){case"partial_face":return"flash_liveness.error.partial_face";case"no_face":case"face_out_of_box":return"flash_liveness.error.no_face";case"face_too_small":return"flash_liveness.error.face_too_small";case"face_too_large":return"flash_liveness.error.face_too_large";case"eye_close":return"flash_liveness.error.close_eye";case"face_not_frontal":return"flash_liveness.error.face_not_frontal";case"multiple_faces":return"flash_liveness.error.multiple_faces";case"face_too_high":return"flash_liveness.error.face_too_high";case"blurry_face":return"flash_liveness.error.face_too_blurry";case"face_not_qualified":return"flash_liveness.error.face_not_qualified";case"face_too_bright":return"flash_liveness.error.face_too_bright";case"face_too_dark":return"flash_liveness.error.face_too_dark";default:return""}},Y=e=>Array.isArray(e)?e.map(({base64:e,label:t,index:r,metadata:a})=>({base64:e,label:t,index:r,metadata:a})):e,Q=r.createContext({enable:!1,key:""}),Z=({children:e,settings:t})=>{let a=r.useMemo(()=>{let e=t?.key??"";return{enable:!!e,key:e}},[t?.key]);return o.jsx(Q.Provider,{value:a,children:e})};Z.propTypes={children:E.node.isRequired,settings:E.shape({key:E.string})},Z.defaultProps={settings:{key:""}};let ee=()=>r.useContext(Q),et=r.createContext({}),er=({apiCredentials:e,children:t})=>{let{apiClient:r}=C.useApiClient({apiCredentials:e});return o.jsx(et.Provider,{value:r,children:t})};er.propTypes={apiCredentials:E.shape({accessKey:E.string.isRequired,secretKey:E.string.isRequired,apiUrl:E.string.isRequired}),children:E.node.isRequired},er.defaultProps={apiCredentials:{}};let ea=()=>r.useContext(et);let eo=(e=[],t=async()=>(await Promise.all(e)).map(e=>({id:e?.data?.file_id??-1})),{uploadFrameBatch:(t,r,a)=>{let o=new Blob([JSON.stringify(t)]);e.push(r.uploadFile({file:o,metadata:JSON.stringify({type:"selfie"}),label:"video"},a))},getAllUploadedBatches:t,resetUploadBatches:()=>{e.length=0}});export{er as A,R as F,Z as O,S as R,F as S,T as W,O as a,I as b,j as c,A as d,N as e,x as f,J as g,P as h,D as i,X as j,H as k,M as l,$ as m,L as n,ee as o,ea as p,eo as q,Y as r,z as s,B as u};
@@ -1,3 +1,3 @@
1
- import{i as e,P as r,s as t,A as n,T as s,m as i,b as a,j as o,C as c,r as l,aI as u,c as m,a4 as p,k as d,aJ as f}from"./chunk-ed832fec.js";import{M as g,O as h,W as j,C as x}from"./chunk-e0f43811.js";import{u as F}from"./chunk-571e89c0.js";import{p as y,g as C,a as D,O as S,I as b,h as T,F as I,i as v,j as E,L as k,b as L,S as R}from"./chunk-7f5333af.js";import{u as V}from"./chunk-de5b2d76.js";import"./chunk-ff693e7b.js";import"./chunk-e77bab5e.js";import"./chunk-81ce3c83.js";import"./chunk-b87b1853.js";let _=e.img`
1
+ import{i as e,P as r,s as t,A as n,T as s,m as i,b as a,j as o,C as c,r as l,aI as u,c as m,a4 as p,k as d,aJ as f}from"./chunk-78da2232.js";import{M as g,O as h,W as j,C as x}from"./chunk-7b011490.js";import{u as F}from"./chunk-54342a62.js";import{p as y,g as C,a as D,O as S,I as b,h as T,F as I,i as v,j as E,L as k,b as L,S as R}from"./chunk-db249df9.js";import{u as V}from"./chunk-16aae30a.js";import"./chunk-df824644.js";import"./chunk-bf5a5b12.js";import"./chunk-3ed55750.js";import"./chunk-fbbb4c3f.js";let _=e.img`
2
2
  width: ${({width:e})=>e};
3
3
  `;function w({type:e}){let r=n(),t=s(`Selfie.Active.directionIcon.${e}`,`${e}_arrow.gif`),c=i(`Selfie.Active.directionIcon.${e}Width`)({theme:r}),l=a(r,`Selfie.Active.directionIcon.${e}`);return null===l?o.jsx(o.Fragment,{}):l&&null!==l?o.jsx(_,{src:a(r,`Selfie.Active.directionIcon.${e}`),width:c,alt:""}):o.jsx(_,{src:t,alt:"",width:c})}w.propTypes={type:r.oneOf([t.FaceDirection.LEFT,t.FaceDirection.RIGHT,t.FaceDirection.UP,t.FaceDirection.FRONTAL])},w.defaultProps={type:t.FaceDirection.LEFT};let A=d.isMobile?{width:{ideal:640}}:null,$=({stepNumber:e,type:r,theme:t})=>{let n=f(`instruction_${r}.svg`),s=a(t,`Selfie.Active.imageHolder.${r}`);return null===s?o.jsx(o.Fragment,{}):"string"==typeof s&&""!==s?o.jsx("img",{src:s,alt:""}):"v1"===a(t,"themeVersion")?o.jsx("span",{children:e}):o.jsx("img",{src:n,alt:""})};function P(e){var r,f;let{apiCheck:_,onLivenessDetectionDone:w,captureFrameSettings:P,onFramesCaptured:N,frontCamera:H,flipVideoHorizontal:O,customDirectionIcon:M,customStepTimeConstraints:U,onProcessing:B,customErrors:K,apiCredentials:G,outputEncryptionSettings:W,cameraScale:z,defaultCameraId:Y,offsetFaceY:J,styledComponent:q,isLoading:Q,serviceSettings:X,onReset:Z}=e,ee=n(),{onErrorCallback:er,onCloseCallback:et}=V(),en=c.useAsset("bg_camera_mask.png"),es=c.useAsset("bg_camera_mask_red.png"),ei=s("IDCapturing.loadingIcon.src","ic_loading.gif"),[ea,eo]=l.useState({}),{yFaceVerificationStepsWrapper:ec,yFaceDetectionError:el}=ea,[eu,em]=l.useState(""),[ep,ed]=l.useState(),ef=l.useMemo(()=>({backgroundColor:i("Selfie.backgroundColor")({theme:ee})}),[ee]);u(a(ee,"themeVersion"),"up_arrow.gif"),u(a(ee,"themeVersion"),"left_arrow.gif"),u(a(ee,"themeVersion"),"right_arrow.gif"),u(a(ee,"themeVersion"),"frontal_arrow.gif"),u(a(ee,"themeVersion"),"instruction_up.svg"),u(a(ee,"themeVersion"),"instruction_left.svg"),u(a(ee,"themeVersion"),"instruction_right.svg"),u(a(ee,"themeVersion"),"instruction_frontal.svg");let eg=l.useCallback(({clientHeight:e,videoAreaWidth:r,videoAreaHeight:t,lostX:n,lostY:s})=>{let i,a;d.isMobile?a=i=r:i=a=t-200;let o=Math.floor((r-i)/2)+n,c=5+s,l=s+25,u=l+30;eo({yFaceDetectionError:l,yFaceVerificationStepsWrapper:u+a+20});let m=Math.floor(s),p=Math.floor(e-s);return c=Math.floor(u),0!==J&&(c+J<m||c+J+a>p)?er({code:`offsetFaceY must be in [-${c-m}, ${p-a-c}]`}):c+=J,{x:o,y:c,width:i,height:a}},[J,er]),{shouldResetFlowOnOrientationChange:eh,cropArea:ej,curStepIndex:ex,directionIcon:eF,directionIconAnimation:ey,faceDetectionError:eC,resetFlow:eD,handleVideoPlayed:eS,instructions:eb,refVideo:eT,refIsReseting:eI,steps:ev,videoPlayed:eE,activeCapturing:ek,warmupDone:eL,showLoading:eR}=F({currentOrientation:ep,apiCheck:_,bgCameraMask:en,bgCameraMaskRed:es,surroundStyle:ef,onLivenessDetectionDone:w,onError:er,cropAreaDimension:eg,customDirectionIcon:M,captureFrameSettings:P,onFramesCaptured:N,setRemainingTime:em,customStepTimeConstraints:U,onProcessing:B,customErrors:K,apiCredentials:G,outputEncryptionSettings:W,cameraScale:z,serviceSettings:X,onReset:Z});l.useEffect(()=>{"string"==typeof ev[0]?.directionIcon&&Promise.all(ev.map(e=>y(e.directionIcon)))},[ev]);let{CloseCameraButton:eV}=q,e_=C(e,ee),ew=eI.current?0:ex/ev.length*100,{lang:eA}=m.useSDKSettings(),e$=l.useRef(0),eP=l.useRef({}),eN=l.useRef(t.ErrorDuration.SHORT),eH=l.useMemo(()=>{let{msg:e,duration:r=t.ErrorDuration.SHORT}=eC||{},n=e?.[eA];return Date.now()-e$.current>=eN.current&&(e$.current=Date.now(),eN.current=r,eP.current=n),eP.current},[eC,ex]),eO=l.useCallback(e=>{ed(e),eh?eD():e===g.LANDSCAPE?eT.current?.pause():eT.current?.play()},[eT,eD,eh]);return o.jsx(h,{onOrientationChange:eO,children:o.jsxs(p,{frontCamera:H,onVideoPlayed:eS,onClose:et,flipHorizontal:O??H,ref:eT,videoSettings:A,onError:er,scale:z,defaultCameraId:Y,closeButton:eV||null,children:[!eL&&o.jsx(j,{}),eE?o.jsxs(o.Fragment,{children:[ej.current?o.jsxs(x,{x:`${ej.current.x}px`,y:`${ej.current.y}px`,width:`${ej.current.width}px`,height:`${ej.current.height}px`,surroundStyle:ej.current.surroundStyle,children:[o.jsx(D,{}),o.jsx(S,{...e_,progress:ew,showErrorRing:!!eC&&i("Selfie.progressCircle.showErrorRing")({theme:ee})}),o.jsx(b,{children:(r=eF,f=ey,r?"string"==typeof r?o.jsx("img",{className:f,src:r,alt:"",style:{maxWidth:"98px",maxHeight:"98px",marginBottom:"25px"}}):r:null)}),ek&&o.jsx(T,{})]}):null,eb?o.jsxs(o.Fragment,{children:[o.jsx(I,{top:ec+5,className:"instructions",children:eb}),o.jsx(v,{top:ec+35,children:ev.map((e,r)=>{let{name:t,image:{objUrl:n}}=e;return o.jsx(E,{active:ex>=r,className:"step-item",children:n?o.jsx("img",{className:"image_preview",src:n,alt:""}):o.jsx($,{stepNumber:r+1,type:t,theme:ee})},t)})})]}):null]}):null,(eR||Q)&&o.jsx(k,{children:o.jsx("img",{src:ei,alt:"",className:"spin"})}),eu&&o.jsx(L,{top:ec-30,children:eu}),"string"==typeof eH?o.jsx(R,{top:el-15,className:"face-detection-error",children:eH}):null]})})}P.propTypes={apiCheck:r.bool,onLivenessDetectionDone:r.func,onClose:r.func,onError:r.func,onReset:r.func,captureFrameSettings:r.shape({}),onFramesCaptured:r.func,flipVideoHorizontal:r.bool,frontCamera:r.bool,isLoading:r.bool,customDirectionIcon:r.shape({}),customStepTimeConstraints:r.shape({}),onProcessing:r.func,customErrors:r.shape({}),apiCredentials:r.shape({accessKey:r.string,secretKey:r.string,apiUrl:r.string}),outputEncryptionSettings:r.shape({}),cameraScale:r.number,defaultCameraId:r.string,offsetFaceY:r.number,styledComponent:r.shape({CloseCameraButton:r.node}),serviceSettings:r.shape({})},P.defaultProps={apiCheck:!1,onLivenessDetectionDone:null,onClose:null,onError:()=>{},onReset:()=>{},captureFrameSettings:{enable:!1,framesIntervalTime:180,framesBatchLength:0},onFramesCaptured:()=>{},flipVideoHorizontal:null,frontCamera:!0,isLoading:!1,customDirectionIcon:{[t.FaceDirection.LEFT]:o.jsx(w,{type:t.FaceDirection.LEFT}),[t.FaceDirection.RIGHT]:o.jsx(w,{type:t.FaceDirection.RIGHT}),[t.FaceDirection.UP]:o.jsx(w,{type:t.FaceDirection.UP}),[t.FaceDirection.FRONTAL]:o.jsx(w,{type:t.FaceDirection.FRONTAL})},customStepTimeConstraints:{[t.FaceDirection.UP]:{delayTime:0},[t.FaceDirection.LEFT]:{delayTime:0},[t.FaceDirection.RIGHT]:{delayTime:0},[t.FaceDirection.FRONTAL]:{delayTime:2e3}},onProcessing:()=>{},customErrors:null,apiCredentials:{accessKey:"",secretKey:"",apiUrl:""},outputEncryptionSettings:null,cameraScale:1,defaultCameraId:void 0,offsetFaceY:0,styledComponent:{CloseCameraButton:null},serviceSettings:{enableUploadFrames:!0,enableUploadImages:!0,enableVerifySanityPortrait:!0,enableVerifySanityIDCard:!0,enableVerifyFaceLiveness:!0,enableDetectIDCardTampering:!0,enableReadIDCardInfo:!0}};export{P as default};
@@ -1 +1 @@
1
- let e,t;import{b as n,s as a,d as s,r as r,P as i,L as o,j as l,f as u,c as c,u as f,p as p,g as d}from"./chunk-ed832fec.js";import{L as g,C as m,S as h,u as v}from"./chunk-b87b1853.js";import{W as A}from"./chunk-de5b2d76.js";var C,S,b,y,F,T,E,I,x,_={exports:{}};function M(){if(C)return _.exports;C=1;var e="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(e){var t=new Uint8Array(16);_.exports=function(){return e(t),t}}else{var n=Array(16);_.exports=function(){for(var e,t=0;t<16;t++)(3&t)==0&&(e=0x100000000*Math.random()),n[t]=e>>>((3&t)<<3)&255;return n}}return _.exports}function D(){if(b)return S;b=1;for(var e=[],t=0;t<256;++t)e[t]=(t+256).toString(16).substr(1);return S=function(t,n){var a=n||0;return""+e[t[a++]]+e[t[a++]]+e[t[a++]]+e[t[a++]]+"-"+e[t[a++]]+e[t[a++]]+"-"+e[t[a++]]+e[t[a++]]+"-"+e[t[a++]]+e[t[a++]]+"-"+e[t[a++]]+e[t[a++]]+e[t[a++]]+e[t[a++]]+e[t[a++]]+e[t[a++]]}}var U=function(){if(x)return I;x=1;var e=function(){if(F)return y;F=1;var e,t,n=M(),a=D(),s=0,r=0;return y=function(i,o,l){var u=o&&l||0,c=o||[],f=(i=i||{}).node||e,p=void 0!==i.clockseq?i.clockseq:t;if(null==f||null==p){var d=n();null==f&&(f=e=[1|d[0],d[1],d[2],d[3],d[4],d[5]]),null==p&&(p=t=(d[6]<<8|d[7])&16383)}var g=void 0!==i.msecs?i.msecs:new Date().getTime(),m=void 0!==i.nsecs?i.nsecs:r+1,h=g-s+(m-r)/1e4;if(h<0&&void 0===i.clockseq&&(p=p+1&16383),(h<0||g>s)&&void 0===i.nsecs&&(m=0),m>=1e4)throw Error("uuid.v1(): Can't create more than 10M uuids/sec");s=g,r=m,t=p;var v=((0xfffffff&(g+=122192928e5))*1e4+m)%0x100000000;c[u++]=v>>>24&255,c[u++]=v>>>16&255,c[u++]=v>>>8&255,c[u++]=255&v;var A=g/0x100000000*1e4&0xfffffff;c[u++]=A>>>8&255,c[u++]=255&A,c[u++]=A>>>24&15|16,c[u++]=A>>>16&255,c[u++]=p>>>8|128,c[u++]=255&p;for(var C=0;C<6;++C)c[u+C]=f[C];return o||a(c)}}(),t=function(){if(E)return T;E=1;var e=M(),t=D();return T=function(n,a,s){var r=a&&s||0;"string"==typeof n&&(a="binary"===n?Array(16):null,n=null);var i=(n=n||{}).random||(n.rng||e)();if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,a)for(var o=0;o<16;++o)a[r+o]=i[o];return a||t(i)}}();return t.v1=e,t.v4=t,I=t}();let k=e=>{let t={};return Object.entries(e).forEach(([e,n])=>{if(n){if("customerUserId"===e){t.cus_user_id=n;return}if("faces"===e){t.faces=n.map(e=>({id:e.id}));return}if("gestureFaces"===e){t.gesture_faces=n.map(e=>({gesture:e.gesture,images:e.images.map(e=>({id:e.id}))}));return}if("videos"===e){t.videos=n;return}t[e.replace(/[A-Z]/g,e=>`_${e.toLowerCase()}`)]=n}}),t},R={enableVerifySanityPortrait:!1,enableVerifyFaceLiveness:!1};function w(e){let{apiCheck:t,mode:i,authType:o,authMethod:g,apiCredentials:m,onDone:h,onError:C,onClose:S,onReset:b,captureFrameSettings:y,onFramesCaptured:F,clientSettings:T,outputEncryptionSettings:E,logCredentials:I,flowId:x,serviceSettings:_,cameraScale:M,offsetFaceY:D,frontalMinSize:w,customTheme:N,livenessDetectionComponent:j,customComponent:L,customTexts:V,extraConfig:H}=e,B=v(),G=r.useMemo(()=>{let e={..._,...R};return u.getEnabledServices(e,B)},[B,_]),{FaceAuthenticationLoading:O}=L,[P,K]=r.useState(!1),{registerFace:W,authenFace:q}=function({apiCredentials:e,authMethod:t,enabledServices:a,authType:i}){let{apiClient:o}=s.useApiClient({apiCredentials:e}),l=r.useCallback(async e=>{let n=e.frontalFaces?.map(e=>({id:e.id}))??[],s=e.steps?.map(e=>({gesture:e.name,images:[{id:e.id}]})),r=[];return{selfieType:t,faces:n,gestureFaces:s,videos:r=a.enableUploadFrames?e.uploadFramesResult??[]:e.capturedFrames??[]}},[t,a.enableUploadFrames]),u=r.useCallback(async({sdkResult:e})=>{let t=await l(e),s=U.v4();t={...t,faceType:"selfie",customerUserId:s};let r=null;if(a.enableRegisterFace){let e=k(t);"success"===n(r=await o.httpClient.post("/v1/face_auth_register",e),"data.status")&&localStorage.setItem("tv:cus-user-id",s)}return{...t,apiResult:r}},[o.httpClient,l,a.enableRegisterFace]);return{registerFace:u,authenFace:r.useCallback(async({sdkResult:e})=>{let t=await l(e),n=localStorage.getItem("tv:cus-user-id");t={...t,customerUserId:n,authType:i};let s=null;if(a.enableAuthenticateFace){let e=k(t);s=await o.httpClient.post("/v1/face_auth",e)}return{...t,apiResult:s}},[o.httpClient,i,l,a.enableAuthenticateFace])}}({apiCredentials:m,authMethod:g,enabledServices:G,authType:o}),{billingSettings:z,enableBilling:Y}=c.useSDKSettings(),Z=f.getWebSetting(B,"data.settings.sdk_settings.billing_settings.billing_config"),$=f.getWebSetting(B,"data.settings.sdk_settings.billing_settings.url"),J=p.buildBillingInput(e),{submitBilling:Q}=d({enable:Y,onError:C,billingSettings:z??{json:Z??{}},billingUrl:$}),X=r.useCallback(e=>{let t={sdkStatus:a.BillingStatus.success,result:p.buildBillingOutput(e)};Q({service:a.BillingService.faceAuth,input:J,output:t}),h&&h(e)},[J,h,Q]),ee=r.useCallback(e=>{if(a.ErrorsWithoutBilling.includes(e.code))return void C(e);let t={error:e,sdkStatus:a.BillingStatus.fail};Q({service:a.BillingService.faceAuth,input:J,output:t}),C&&C(e)},[J,C,Q]),et=r.useCallback(e=>{var t,s;let r,l,u,c=(s={...e,frontalFaces:(r=n(t=e,"frontalFaces",[]),l=n(t,"frontalFacesEncrypted",[]),r.map((e,t)=>({blob:e,encrypted:l[t]??null})))},u={},u.faces=n(s,"frontalFaces"),u.videos=Array.isArray(n(s,"capturedFrames"))&&n(s,"capturedFrames").length>0?[{frames:n(s,"capturedFrames")}]:null,u.gestureFaces=Array.isArray(n(s,"steps"))&&n(s,"steps").length>0?n(s,"steps").map(e=>{let{name:t}=e;return{gesture:t,images:[{...e?.image}]}}):null,u);i===a.FaceAuthenticationMode.REGISTRATION&&(c={...c,customerUserID:U.v4(),faceType:"selfie",selfieType:g}),i===a.FaceAuthenticationMode.AUTHENTICATION&&(c={...c,selfieType:g,authType:o}),X(c)},[i,X,g,o]),en=r.useCallback(async e=>{if(!t||!G.enableUploadImages)return void et(e);try{let t;K(!0),i===a.FaceAuthenticationMode.REGISTRATION&&(t=await W({sdkResult:e})),i===a.FaceAuthenticationMode.AUTHENTICATION&&(t=await q({sdkResult:e})),X(t)}catch(e){console.error(e),ee({...a.Errors.api_call_error,details:e})}finally{K(!1)}},[t,G.enableUploadImages,et,i,X,W,q,ee]);return l.jsxs(A,{isWrappedBy:"face_authen",children:[l.jsx(j,{mode:(e=>{switch(e){case a.FaceAuthMethod.STANDARD_AUTHEN:return a.Mode.PASSIVE;case a.FaceAuthMethod.ADVANCED_AUTHEN_ACTIVE:return a.Mode.ACTIVE;case a.FaceAuthMethod.EDGE_AUTHEN:return a.Mode.FLASH_EDGE;case a.FaceAuthMethod.ADVANCED_AUTHEN_FLASH:return a.Mode.FLASH_ADVANCED;case a.FaceAuthMethod.LIGHT_AUTHEN:return a.Mode.PASSIVE;default:return e}})(g),cameraScale:M,offsetFaceY:D,frontalMinSize:w,captureFrameSettings:y,logCredentials:I,onLivenessDetectionDone:en,outputEncryptionSettings:E,onFramesCaptured:F,onError:C,onClose:S,onReset:b,clientSettings:T,customTheme:N,extraConfig:H,customComponent:L,apiCheck:t,apiCredentials:m,serviceSettings:G,flowId:x,customTexts:V}),l.jsx(O,{loading:P})]})}w.propTypes={apiCheck:i.bool,mode:i.string,authMethod:i.string,authType:i.string,onDone:i.func,onError:i.func,onClose:i.func,outputEncryptionSettings:i.shape({}),captureFrameSettings:i.shape({enable:i.bool,framesIntervalTime:i.number,framesBatchLength:i.number}),cameraScale:i.number,offsetFaceY:i.number,frontalMinSize:i.number,apiCredentials:i.shape({accessKey:i.string,secretKey:i.string,apiUrl:i.string}),logCredentials:i.shape({}),customTheme:i.shape({}),serviceSettings:i.shape({}),flowId:i.string,clientSettings:i.shape({}),livenessDetectionComponent:i.elementType,customComponent:i.shape({FaceAuthenticationLoading:i.elementType}),extraConfig:i.shape({}),onReset:i.func,onFramesCaptured:i.func,customTexts:i.shape({})},w.defaultProps={apiCheck:!1,mode:a.FaceAuthenticationMode.REGISTRATION,authMethod:a.FaceAuthMethod.EDGE_AUTHEN,authType:"transfer",onDone:()=>{},onError:()=>{},onClose:()=>{},outputEncryptionSettings:null,captureFrameSettings:{enable:!0,framesIntervalTime:180,framesBatchLength:15},cameraScale:1,offsetFaceY:0,frontalMinSize:null,apiCredentials:{accessKey:"",secretKey:"",apiUrl:""},logCredentials:null,customTheme:null,serviceSettings:{enableUploadFrames:!0,enableUploadImages:!0,enableRegisterFace:!0,enableAuthenticateFace:!0},flowId:"face_authen",clientSettings:null,livenessDetectionComponent:g,customComponent:{FaceAuthenticationLoading:o},extraConfig:null,onReset:()=>{},onFramesCaptured:()=>{},customTexts:{}};var N=(e=w,t=function(t){let{customTexts:n}=t;return l.jsx(h,{customTexts:n,children:l.jsx(e,{...t})})},function(e){let{apiCheck:n,apiCredentials:a,serviceSettings:s,flowId:r,clientSettings:i}=e,o=n&&(s?.enableGetClientSettings??!0);return l.jsx(m,{enableGetClientSettings:o,clientSettings:i,apiCredentials:a,flowId:r,children:l.jsx(t,{...e})})});function j(e){return l.jsx(N,{...e})}j.propTypes={logCredentials:i.shape({}),clientSettings:i.shape({})},j.defaultProps={logCredentials:null,clientSettings:null};export{j as default};
1
+ let e,t;import{b as n,s as a,d as s,r as r,P as i,L as o,j as l,f as u,c as c,u as f,p as p,g as d}from"./chunk-78da2232.js";import{L as g,C as m,S as h,u as v}from"./chunk-fbbb4c3f.js";import{W as A}from"./chunk-16aae30a.js";var C,S,b,y,F,T,E,I,x,_={exports:{}};function M(){if(C)return _.exports;C=1;var e="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(e){var t=new Uint8Array(16);_.exports=function(){return e(t),t}}else{var n=Array(16);_.exports=function(){for(var e,t=0;t<16;t++)(3&t)==0&&(e=0x100000000*Math.random()),n[t]=e>>>((3&t)<<3)&255;return n}}return _.exports}function D(){if(b)return S;b=1;for(var e=[],t=0;t<256;++t)e[t]=(t+256).toString(16).substr(1);return S=function(t,n){var a=n||0;return""+e[t[a++]]+e[t[a++]]+e[t[a++]]+e[t[a++]]+"-"+e[t[a++]]+e[t[a++]]+"-"+e[t[a++]]+e[t[a++]]+"-"+e[t[a++]]+e[t[a++]]+"-"+e[t[a++]]+e[t[a++]]+e[t[a++]]+e[t[a++]]+e[t[a++]]+e[t[a++]]}}var U=function(){if(x)return I;x=1;var e=function(){if(F)return y;F=1;var e,t,n=M(),a=D(),s=0,r=0;return y=function(i,o,l){var u=o&&l||0,c=o||[],f=(i=i||{}).node||e,p=void 0!==i.clockseq?i.clockseq:t;if(null==f||null==p){var d=n();null==f&&(f=e=[1|d[0],d[1],d[2],d[3],d[4],d[5]]),null==p&&(p=t=(d[6]<<8|d[7])&16383)}var g=void 0!==i.msecs?i.msecs:new Date().getTime(),m=void 0!==i.nsecs?i.nsecs:r+1,h=g-s+(m-r)/1e4;if(h<0&&void 0===i.clockseq&&(p=p+1&16383),(h<0||g>s)&&void 0===i.nsecs&&(m=0),m>=1e4)throw Error("uuid.v1(): Can't create more than 10M uuids/sec");s=g,r=m,t=p;var v=((0xfffffff&(g+=122192928e5))*1e4+m)%0x100000000;c[u++]=v>>>24&255,c[u++]=v>>>16&255,c[u++]=v>>>8&255,c[u++]=255&v;var A=g/0x100000000*1e4&0xfffffff;c[u++]=A>>>8&255,c[u++]=255&A,c[u++]=A>>>24&15|16,c[u++]=A>>>16&255,c[u++]=p>>>8|128,c[u++]=255&p;for(var C=0;C<6;++C)c[u+C]=f[C];return o||a(c)}}(),t=function(){if(E)return T;E=1;var e=M(),t=D();return T=function(n,a,s){var r=a&&s||0;"string"==typeof n&&(a="binary"===n?Array(16):null,n=null);var i=(n=n||{}).random||(n.rng||e)();if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,a)for(var o=0;o<16;++o)a[r+o]=i[o];return a||t(i)}}();return t.v1=e,t.v4=t,I=t}();let k=e=>{let t={};return Object.entries(e).forEach(([e,n])=>{if(n){if("customerUserId"===e){t.cus_user_id=n;return}if("faces"===e){t.faces=n.map(e=>({id:e.id}));return}if("gestureFaces"===e){t.gesture_faces=n.map(e=>({gesture:e.gesture,images:e.images.map(e=>({id:e.id}))}));return}if("videos"===e){t.videos=n;return}t[e.replace(/[A-Z]/g,e=>`_${e.toLowerCase()}`)]=n}}),t},R={enableVerifySanityPortrait:!1,enableVerifyFaceLiveness:!1};function w(e){let{apiCheck:t,mode:i,authType:o,authMethod:g,apiCredentials:m,onDone:h,onError:C,onClose:S,onReset:b,captureFrameSettings:y,onFramesCaptured:F,clientSettings:T,outputEncryptionSettings:E,logCredentials:I,flowId:x,serviceSettings:_,cameraScale:M,offsetFaceY:D,frontalMinSize:w,customTheme:N,livenessDetectionComponent:j,customComponent:L,customTexts:V,extraConfig:H}=e,B=v(),G=r.useMemo(()=>{let e={..._,...R};return u.getEnabledServices(e,B)},[B,_]),{FaceAuthenticationLoading:O}=L,[P,K]=r.useState(!1),{registerFace:W,authenFace:q}=function({apiCredentials:e,authMethod:t,enabledServices:a,authType:i}){let{apiClient:o}=s.useApiClient({apiCredentials:e}),l=r.useCallback(async e=>{let n=e.frontalFaces?.map(e=>({id:e.id}))??[],s=e.steps?.map(e=>({gesture:e.name,images:[{id:e.id}]})),r=[];return{selfieType:t,faces:n,gestureFaces:s,videos:r=a.enableUploadFrames?e.uploadFramesResult??[]:e.capturedFrames??[]}},[t,a.enableUploadFrames]),u=r.useCallback(async({sdkResult:e})=>{let t=await l(e),s=U.v4();t={...t,faceType:"selfie",customerUserId:s};let r=null;if(a.enableRegisterFace){let e=k(t);"success"===n(r=await o.httpClient.post("/v1/face_auth_register",e),"data.status")&&localStorage.setItem("tv:cus-user-id",s)}return{...t,apiResult:r}},[o.httpClient,l,a.enableRegisterFace]);return{registerFace:u,authenFace:r.useCallback(async({sdkResult:e})=>{let t=await l(e),n=localStorage.getItem("tv:cus-user-id");t={...t,customerUserId:n,authType:i};let s=null;if(a.enableAuthenticateFace){let e=k(t);s=await o.httpClient.post("/v1/face_auth",e)}return{...t,apiResult:s}},[o.httpClient,i,l,a.enableAuthenticateFace])}}({apiCredentials:m,authMethod:g,enabledServices:G,authType:o}),{billingSettings:z,enableBilling:Y}=c.useSDKSettings(),Z=f.getWebSetting(B,"data.settings.sdk_settings.billing_settings.billing_config"),$=f.getWebSetting(B,"data.settings.sdk_settings.billing_settings.url"),J=p.buildBillingInput(e),{submitBilling:Q}=d({enable:Y,onError:C,billingSettings:z??{json:Z??{}},billingUrl:$}),X=r.useCallback(e=>{let t={sdkStatus:a.BillingStatus.success,result:p.buildBillingOutput(e)};Q({service:a.BillingService.faceAuth,input:J,output:t}),h&&h(e)},[J,h,Q]),ee=r.useCallback(e=>{if(a.ErrorsWithoutBilling.includes(e.code))return void C(e);let t={error:e,sdkStatus:a.BillingStatus.fail};Q({service:a.BillingService.faceAuth,input:J,output:t}),C&&C(e)},[J,C,Q]),et=r.useCallback(e=>{var t,s;let r,l,u,c=(s={...e,frontalFaces:(r=n(t=e,"frontalFaces",[]),l=n(t,"frontalFacesEncrypted",[]),r.map((e,t)=>({blob:e,encrypted:l[t]??null})))},u={},u.faces=n(s,"frontalFaces"),u.videos=Array.isArray(n(s,"capturedFrames"))&&n(s,"capturedFrames").length>0?[{frames:n(s,"capturedFrames")}]:null,u.gestureFaces=Array.isArray(n(s,"steps"))&&n(s,"steps").length>0?n(s,"steps").map(e=>{let{name:t}=e;return{gesture:t,images:[{...e?.image}]}}):null,u);i===a.FaceAuthenticationMode.REGISTRATION&&(c={...c,customerUserID:U.v4(),faceType:"selfie",selfieType:g}),i===a.FaceAuthenticationMode.AUTHENTICATION&&(c={...c,selfieType:g,authType:o}),X(c)},[i,X,g,o]),en=r.useCallback(async e=>{if(!t||!G.enableUploadImages)return void et(e);try{let t;K(!0),i===a.FaceAuthenticationMode.REGISTRATION&&(t=await W({sdkResult:e})),i===a.FaceAuthenticationMode.AUTHENTICATION&&(t=await q({sdkResult:e})),X(t)}catch(e){console.error(e),ee({...a.Errors.api_call_error,details:e})}finally{K(!1)}},[t,G.enableUploadImages,et,i,X,W,q,ee]);return l.jsxs(A,{isWrappedBy:"face_authen",children:[l.jsx(j,{mode:(e=>{switch(e){case a.FaceAuthMethod.STANDARD_AUTHEN:return a.Mode.PASSIVE;case a.FaceAuthMethod.ADVANCED_AUTHEN_ACTIVE:return a.Mode.ACTIVE;case a.FaceAuthMethod.EDGE_AUTHEN:return a.Mode.FLASH_EDGE;case a.FaceAuthMethod.ADVANCED_AUTHEN_FLASH:return a.Mode.FLASH_ADVANCED;case a.FaceAuthMethod.LIGHT_AUTHEN:return a.Mode.PASSIVE;default:return e}})(g),cameraScale:M,offsetFaceY:D,frontalMinSize:w,captureFrameSettings:y,logCredentials:I,onLivenessDetectionDone:en,outputEncryptionSettings:E,onFramesCaptured:F,onError:C,onClose:S,onReset:b,clientSettings:T,customTheme:N,extraConfig:H,customComponent:L,apiCheck:t,apiCredentials:m,serviceSettings:G,flowId:x,customTexts:V}),l.jsx(O,{loading:P})]})}w.propTypes={apiCheck:i.bool,mode:i.string,authMethod:i.string,authType:i.string,onDone:i.func,onError:i.func,onClose:i.func,outputEncryptionSettings:i.shape({}),captureFrameSettings:i.shape({enable:i.bool,framesIntervalTime:i.number,framesBatchLength:i.number}),cameraScale:i.number,offsetFaceY:i.number,frontalMinSize:i.number,apiCredentials:i.shape({accessKey:i.string,secretKey:i.string,apiUrl:i.string}),logCredentials:i.shape({}),customTheme:i.shape({}),serviceSettings:i.shape({}),flowId:i.string,clientSettings:i.shape({}),livenessDetectionComponent:i.elementType,customComponent:i.shape({FaceAuthenticationLoading:i.elementType}),extraConfig:i.shape({}),onReset:i.func,onFramesCaptured:i.func,customTexts:i.shape({})},w.defaultProps={apiCheck:!1,mode:a.FaceAuthenticationMode.REGISTRATION,authMethod:a.FaceAuthMethod.EDGE_AUTHEN,authType:"transfer",onDone:()=>{},onError:()=>{},onClose:()=>{},outputEncryptionSettings:null,captureFrameSettings:{enable:!0,framesIntervalTime:180,framesBatchLength:15},cameraScale:1,offsetFaceY:0,frontalMinSize:null,apiCredentials:{accessKey:"",secretKey:"",apiUrl:""},logCredentials:null,customTheme:null,serviceSettings:{enableUploadFrames:!0,enableUploadImages:!0,enableRegisterFace:!0,enableAuthenticateFace:!0},flowId:"face_authen",clientSettings:null,livenessDetectionComponent:g,customComponent:{FaceAuthenticationLoading:o},extraConfig:null,onReset:()=>{},onFramesCaptured:()=>{},customTexts:{}};var N=(e=w,t=function(t){let{customTexts:n}=t;return l.jsx(h,{customTexts:n,children:l.jsx(e,{...t})})},function(e){let{apiCheck:n,apiCredentials:a,serviceSettings:s,flowId:r,clientSettings:i}=e,o=n&&(s?.enableGetClientSettings??!0);return l.jsx(m,{enableGetClientSettings:o,clientSettings:i,apiCredentials:a,flowId:r,children:l.jsx(t,{...e})})});function j(e){return l.jsx(N,{...e})}j.propTypes={logCredentials:i.shape({}),clientSettings:i.shape({})},j.defaultProps={logCredentials:null,clientSettings:null};export{j as default};
@@ -1 +1 @@
1
- import{A as e,C as r,T as s,r as a,m as n,c as t,s as o,j as i,a4 as c,az as l,b as u,P as p,k as m}from"./chunk-ed832fec.js";import{p as d,g as f,S as h,a as g,O as C,C as j,E as y,b as D,B as F,c as x,L as S}from"./chunk-7f5333af.js";import{u as b,C as T}from"./chunk-fa450310.js";import{M as k,O as I,W as E,C as R}from"./chunk-e0f43811.js";import{D as L}from"./chunk-3475f25e.js";import{u as v}from"./chunk-de5b2d76.js";import"./chunk-e77bab5e.js";import"./chunk-81ce3c83.js";import"./chunk-b87b1853.js";let P=m.isMobile?{width:{ideal:640}}:null;function A(p){let{apiCheck:m,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:J}=p,Q=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:Q})}),[Q]),em=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:ed,countdownToTakePicture:ef,cropArea:eh,curStepIndex:eg,faceDetectionError:eC,resetFlow:ej,handleTriggerPassiveMode:ey,handleVideoPlayed:eD,refVideo:eF,showCountdown:ex,steps:eS,refIsReseting:eb,videoPlayed:eT,warmupDone:ek,showCaptureButton:eI,shouldShowCountdown:eE,showLoading:eR}=b({currentOrientation:el,apiCheck:m,bgCameraMask:ee,bgCameraMaskRed:er,surroundStyle:ep,onLivenessDetectionDone:L,onError:X,cropAreaDimension:em,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=>d(e.directionIcon)))},[eS]);let{CloseCameraButton:eL}=Y,ev=f(p,Q),eP=eb.current?0:eg/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,eg]),eU=a.useCallback(e=>{eu(e),ed?ej():e===k.LANDSCAPE?eF.current?.pause():eF.current?.play()},[eF,ej,ed]);return i.jsx(I,{onOrientationChange:eU,children:i.jsxs(c,{frontCamera:H,onVideoPlayed:eD,onClose:Z,flipHorizontal:O??H,ref:eF,videoSettings:P,onError:X,scale:K,defaultCameraId:N,closeButton:eL||i.jsx(l,{}),children:[!ek&&i.jsx(E,{}),eT?i.jsxs(i.Fragment,{children:["string"==typeof ew?i.jsx(h,{top:et-15,className:"face-detection-error",children:ew}):null,eh.current?i.jsxs(R,{x:`${eh.current.x}px`,y:`${eh.current.y}px`,width:`${eh.current.width}px`,height:`${eh.current.height}px`,surroundStyle:eh.current.surroundStyle,children:[i.jsx(g,{}),i.jsx(C,{...ev,progress:eP,showErrorRing:!!eC&&n("Selfie.progressCircle.showErrorRing")({theme:Q})}),eE?i.jsx(j,{children:ef}):null,eC&&i.jsx(y,{})]}):null,ei&&i.jsx(D,{top:eo-30,children:ei}),eI?i.jsx(F,{children:i.jsx(x,{onClick:ey,disabled:ex,children:u(Q,"Selfie.captureIcon.src")?i.jsx("img",{src:u(Q,"Selfie.captureIcon.src"),alt:""}):i.jsx(T,{fillColor:"rgba(193, 197, 204, 1)"})})}):null]}):null,(eR||J)&&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};
1
+ import{A as e,C as r,T as s,r as a,m as n,c as t,s as o,j as i,a4 as c,az as l,b as u,P as p,k as m}from"./chunk-78da2232.js";import{p as d,g as f,S as h,a as g,O as C,C as j,E as y,b as D,B as F,c as x,L as S}from"./chunk-db249df9.js";import{u as b,C as T}from"./chunk-c91849f8.js";import{M as k,O as I,W as E,C as R}from"./chunk-7b011490.js";import{D as L}from"./chunk-c1fff47f.js";import{u as v}from"./chunk-16aae30a.js";import"./chunk-bf5a5b12.js";import"./chunk-3ed55750.js";import"./chunk-fbbb4c3f.js";let P=m.isMobile?{width:{ideal:640}}:null;function A(p){let{apiCheck:m,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:J}=p,Q=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:Q})}),[Q]),em=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:ed,countdownToTakePicture:ef,cropArea:eh,curStepIndex:eg,faceDetectionError:eC,resetFlow:ej,handleTriggerPassiveMode:ey,handleVideoPlayed:eD,refVideo:eF,showCountdown:ex,steps:eS,refIsReseting:eb,videoPlayed:eT,warmupDone:ek,showCaptureButton:eI,shouldShowCountdown:eE,showLoading:eR}=b({currentOrientation:el,apiCheck:m,bgCameraMask:ee,bgCameraMaskRed:er,surroundStyle:ep,onLivenessDetectionDone:L,onError:X,cropAreaDimension:em,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=>d(e.directionIcon)))},[eS]);let{CloseCameraButton:eL}=Y,ev=f(p,Q),eP=eb.current?0:eg/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,eg]),eU=a.useCallback(e=>{eu(e),ed?ej():e===k.LANDSCAPE?eF.current?.pause():eF.current?.play()},[eF,ej,ed]);return i.jsx(I,{onOrientationChange:eU,children:i.jsxs(c,{frontCamera:H,onVideoPlayed:eD,onClose:Z,flipHorizontal:O??H,ref:eF,videoSettings:P,onError:X,scale:K,defaultCameraId:N,closeButton:eL||i.jsx(l,{}),children:[!ek&&i.jsx(E,{}),eT?i.jsxs(i.Fragment,{children:["string"==typeof ew?i.jsx(h,{top:et-15,className:"face-detection-error",children:ew}):null,eh.current?i.jsxs(R,{x:`${eh.current.x}px`,y:`${eh.current.y}px`,width:`${eh.current.width}px`,height:`${eh.current.height}px`,surroundStyle:eh.current.surroundStyle,children:[i.jsx(g,{}),i.jsx(C,{...ev,progress:eP,showErrorRing:!!eC&&n("Selfie.progressCircle.showErrorRing")({theme:Q})}),eE?i.jsx(j,{children:ef}):null,eC&&i.jsx(y,{})]}):null,ei&&i.jsx(D,{top:eo-30,children:ei}),eI?i.jsx(F,{children:i.jsx(x,{onClick:ey,disabled:ex,children:u(Q,"Selfie.captureIcon.src")?i.jsx("img",{src:u(Q,"Selfie.captureIcon.src"),alt:""}):i.jsx(T,{fillColor:"rgba(193, 197, 204, 1)"})})}):null]}):null,(eR||J)&&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};
@@ -1 +1 @@
1
- import{A as e,C as r,T as s,r as n,m as a,c as t,s as o,j as i,a4 as c,b as l,P as u,k as p}from"./chunk-ed832fec.js";import{p as m,g as d,S as f,a as h,O as g,C as C,E as j,b as y,B as D,c as F,L as S}from"./chunk-7f5333af.js";import{u as x,C as b}from"./chunk-fa450310.js";import{M as T,O as k,W as I,C as E}from"./chunk-e0f43811.js";import{D as R}from"./chunk-3475f25e.js";import{u as L}from"./chunk-de5b2d76.js";import"./chunk-e77bab5e.js";import"./chunk-81ce3c83.js";import"./chunk-b87b1853.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,J=e(),{onErrorCallback:Q,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:J})}),[J]),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)?Q({code:`offsetFaceY must be in [-${i-t}, ${o-r-i}]`}):i+=z,{y:i}},[z,Q]),{shouldResetFlowOnOrientationChange:em,countdownToTakePicture:ed,cropArea:ef,curStepIndex:eh,faceDetectionError:eg,resetFlow:eC,handleTriggerPassiveMode:ej,handleVideoPlayed:ey,refVideo:eD,showCountdown:eF,steps:eS,refIsReseting:ex,videoPlayed:eb,warmupDone:eT,showCaptureButton:ek,shouldShowCountdown:eI,showLoading:eE}=x({currentOrientation:ec,apiCheck:p,bgCameraMask:Z,bgCameraMaskRed:ee,surroundStyle:eu,onLivenessDetectionDone:R,onError:Q,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 eS[0]?.directionIcon&&Promise.all(eS.map(e=>m(e.directionIcon)))},[eS]);let{CloseCameraButton:eR}=G,eL=d(u,J),ev=ex.current?0:eh/eS.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}=eg||{},s=e?.[eP];return Date.now()-eA.current>=eO.current&&(eA.current=Date.now(),eO.current=r,eM.current=s),eM.current},[eg,eh]),eV=n.useCallback(e=>{el(e),em?eC():e===T.LANDSCAPE?eD.current?.pause():eD.current?.play()},[eD,eC,em]);return i.jsx(k,{onOrientationChange:eV,children:i.jsxs(c,{frontCamera:M,onVideoPlayed:ey,onClose:X,flipHorizontal:O??M,ref:eD,videoSettings:v,onError:Q,scale:B,defaultCameraId:K,closeButton:eR||null,children:[!eT&&i.jsx(I,{}),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(E,{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(h,{}),i.jsx(g,{...eL,progress:ev,showErrorRing:!!eg&&a("Selfie.progressCircle.showErrorRing")({theme:J})}),eI?i.jsx(C,{children:ed}):null,eg&&i.jsx(j,{})]}):null,eo&&i.jsx(y,{top:et-30,children:eo}),ek?i.jsx(D,{children:i.jsx(F,{onClick:ej,disabled:eF,children:l(J,"Selfie.captureIcon.src")?i.jsx("img",{src:l(J,"Selfie.captureIcon.src"),alt:""}):i.jsx(b,{fillColor:"rgba(193, 197, 204, 1)"})})}):null]}):null,(eE||q)&&i.jsx(S,{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};
1
+ import{A as e,C as r,T as s,r as n,m as a,c as t,s as o,j as i,a4 as c,b as l,P as u,k as p}from"./chunk-78da2232.js";import{p as m,g as d,S as f,a as h,O as g,C as C,E as j,b as y,B as D,c as F,L as S}from"./chunk-db249df9.js";import{u as x,C as b}from"./chunk-c91849f8.js";import{M as T,O as k,W as I,C as E}from"./chunk-7b011490.js";import{D as R}from"./chunk-c1fff47f.js";import{u as L}from"./chunk-16aae30a.js";import"./chunk-bf5a5b12.js";import"./chunk-3ed55750.js";import"./chunk-fbbb4c3f.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,J=e(),{onErrorCallback:Q,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:J})}),[J]),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)?Q({code:`offsetFaceY must be in [-${i-t}, ${o-r-i}]`}):i+=z,{y:i}},[z,Q]),{shouldResetFlowOnOrientationChange:em,countdownToTakePicture:ed,cropArea:ef,curStepIndex:eh,faceDetectionError:eg,resetFlow:eC,handleTriggerPassiveMode:ej,handleVideoPlayed:ey,refVideo:eD,showCountdown:eF,steps:eS,refIsReseting:ex,videoPlayed:eb,warmupDone:eT,showCaptureButton:ek,shouldShowCountdown:eI,showLoading:eE}=x({currentOrientation:ec,apiCheck:p,bgCameraMask:Z,bgCameraMaskRed:ee,surroundStyle:eu,onLivenessDetectionDone:R,onError:Q,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 eS[0]?.directionIcon&&Promise.all(eS.map(e=>m(e.directionIcon)))},[eS]);let{CloseCameraButton:eR}=G,eL=d(u,J),ev=ex.current?0:eh/eS.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}=eg||{},s=e?.[eP];return Date.now()-eA.current>=eO.current&&(eA.current=Date.now(),eO.current=r,eM.current=s),eM.current},[eg,eh]),eV=n.useCallback(e=>{el(e),em?eC():e===T.LANDSCAPE?eD.current?.pause():eD.current?.play()},[eD,eC,em]);return i.jsx(k,{onOrientationChange:eV,children:i.jsxs(c,{frontCamera:M,onVideoPlayed:ey,onClose:X,flipHorizontal:O??M,ref:eD,videoSettings:v,onError:Q,scale:B,defaultCameraId:K,closeButton:eR||null,children:[!eT&&i.jsx(I,{}),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(E,{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(h,{}),i.jsx(g,{...eL,progress:ev,showErrorRing:!!eg&&a("Selfie.progressCircle.showErrorRing")({theme:J})}),eI?i.jsx(C,{children:ed}):null,eg&&i.jsx(j,{})]}):null,eo&&i.jsx(y,{top:et-30,children:eo}),ek?i.jsx(D,{children:i.jsx(F,{onClick:ej,disabled:eF,children:l(J,"Selfie.captureIcon.src")?i.jsx("img",{src:l(J,"Selfie.captureIcon.src"),alt:""}):i.jsx(b,{fillColor:"rgba(193, 197, 204, 1)"})})}):null]}):null,(eE||q)&&i.jsx(S,{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};
@@ -1 +1 @@
1
- import{A as e,C as r,T as s,r as t,m as n,aI as a,b as o,c as i,s as c,j as l,a4 as u,az as m,a7 as p,W as d,P as h,k as g,aJ as f}from"./chunk-ed832fec.js";import{M as j,O as x,W as y,C as C}from"./chunk-e0f43811.js";import{u as F}from"./chunk-571e89c0.js";import{D as D}from"./chunk-3475f25e.js";import{p as S,d as b,e as v,A as T,f as k,I as I,h as E,F as _,i as V,j as L,T as R,L as w,k as A,l as P,S as H}from"./chunk-7f5333af.js";import{u as N}from"./chunk-de5b2d76.js";import"./chunk-ff693e7b.js";import"./chunk-e77bab5e.js";import"./chunk-81ce3c83.js";import"./chunk-b87b1853.js";let M=g.isMobile?{width:{ideal:640}}:null,$=({stepNumber:e,type:r,theme:s})=>{let t=f(`instruction_${r}.svg`),n=o(s,`Selfie.Active.imageHolder.${r}`);return null===n?l.jsx(l.Fragment,{}):"string"==typeof n&&""!==n?l.jsx("img",{src:n,alt:""}):"v1"===o(s,"themeVersion")?l.jsx("span",{children:e}):l.jsx("img",{src:t,alt:""})};function O(h){var f,D;let{apiCheck:O,onLivenessDetectionDone:U,captureFrameSettings:B,onFramesCaptured:K,frontCamera:z,flipVideoHorizontal:W,customDirectionIcon:G,customStepTimeConstraints:Y,onProcessing:J,customErrors:q,apiCredentials:Q,outputEncryptionSettings:X,cameraScale:Z,defaultCameraId:ee,offsetFaceY:er,isLoading:es,serviceSettings:et,onReset:en}=h,ea=e(),{onErrorCallback:eo,onCloseCallback:ei}=N(),ec=r.useAsset("bg_camera_mask.png"),el=r.useAsset("bg_camera_mask_red.png"),eu=s("IDCapturing.loadingIcon.src","ic_loading.gif"),[em,ep]=t.useState({}),{yFaceVerificationStepsWrapper:ed,yFaceDetectionError:eh,yCountdown:eg}=em,[ef,ej]=t.useState(""),[ex,ey]=t.useState(),eC=t.useMemo(()=>({backgroundColor:n("Selfie.backgroundColor")({theme:ea})}),[ea]);a(o(ea,"themeVersion"),"up_arrow.gif"),a(o(ea,"themeVersion"),"left_arrow.gif"),a(o(ea,"themeVersion"),"right_arrow.gif"),a(o(ea,"themeVersion"),"frontal_arrow.svg"),a(o(ea,"themeVersion"),"instruction_up.svg"),a(o(ea,"themeVersion"),"instruction_left.svg"),a(o(ea,"themeVersion"),"instruction_right.svg"),a(o(ea,"themeVersion"),"instruction_frontal.svg");let eF=t.useCallback(({lostY:e,height:r,clientHeight:s})=>{let t=g.isMobile?e:e+80,n=t+r+20,a=n+110;ep({yFaceDetectionError:a+30,yCountdown:a,yFaceVerificationStepsWrapper:n});let o=Math.floor(e),i=Math.floor(s-e),c=Math.floor(t);return 0!==er&&(c+er<o||c+er+r>i)?eo({code:`offsetFaceY must be in [-${c-o}, ${i-r-c}]`}):c+=er,{y:c}},[er,eo]),{shouldResetFlowOnOrientationChange:eD,cropArea:eS,curStepIndex:eb,directionIcon:ev,directionIconAnimation:eT,faceDetectionError:ek,resetFlow:eI,handleVideoPlayed:eE,instructions:e_,refVideo:eV,refIsReseting:eL,steps:eR,videoPlayed:ew,activeCapturing:eA,warmupDone:eP,showLoading:eH}=F({currentOrientation:ex,apiCheck:O,bgCameraMask:ec,bgCameraMaskRed:el,surroundStyle:eC,onLivenessDetectionDone:U,onError:eo,cropAreaDimension:eF,customDirectionIcon:G,captureFrameSettings:B,onFramesCaptured:K,setRemainingTime:ej,customStepTimeConstraints:Y,onProcessing:J,customErrors:q,apiCredentials:Q,outputEncryptionSettings:X,cameraScale:Z,serviceSettings:et,onReset:en});t.useEffect(()=>{"string"==typeof eR[0]?.directionIcon&&Promise.all(eR.map(e=>S(e.directionIcon)))},[eR]);let eN=b(h,ea),eM=eL.current?0:eb/eR.length*100,{lang:e$}=i.useSDKSettings(),eO=t.useRef(0),eU=t.useRef({}),eB=t.useRef(c.ErrorDuration.SHORT),eK=t.useMemo(()=>{let{msg:e,duration:r=c.ErrorDuration.SHORT}=ek||{},s=e?.[e$];return Date.now()-eO.current>=eB.current&&(eO.current=Date.now(),eB.current=r,eU.current=s),eU.current},[ek,eb]),ez=t.useCallback(e=>{ey(e),eD?eI():e===j.LANDSCAPE?eV.current?.pause():eV.current?.play()},[eV,eI,eD]);return l.jsx(x,{onOrientationChange:ez,children:l.jsxs(u,{frontCamera:z,onVideoPlayed:eE,onClose:ei,flipHorizontal:W??z,ref:eV,videoSettings:M,onError:eo,scale:Z,defaultCameraId:ee,closeButton:l.jsx(m,{}),children:[!eP&&l.jsx(y,{}),ew?l.jsxs(l.Fragment,{children:[eS.current?l.jsxs(C,{x:`${eS.current.x}px`,y:`${eS.current.y}px`,width:`${eS.current.width}px`,height:`${eS.current.height}px`,surroundStyle:eS.current.surroundStyle,children:[l.jsx(v,{padding:T}),l.jsx(k,{...eN,progress:eM,showErrorRing:!!ek}),l.jsx(I,{children:(f=ev,D=eT,f?"string"==typeof f?l.jsx("img",{className:D,src:f,alt:"",style:{maxWidth:"98px",maxHeight:"98px",marginBottom:"25px"}}):f:null)}),eA&&l.jsx(E,{})]}):null,e_?l.jsxs(l.Fragment,{children:[l.jsx(_,{top:ed+5,className:"instructions",children:e_}),l.jsx(V,{top:ed+40,children:eR.map((e,r)=>{let{name:s,image:{objUrl:t}}=e;return l.jsx(L,{active:eb>=r,className:"step-item",children:t?l.jsx("img",{className:"image_preview",src:t,alt:""}):l.jsx($,{stepNumber:r+1,type:s,theme:ea})},s)})})]}):null]}):null,l.jsx(R,{y:"20px",children:l.jsx(p,{id:"flash_liveness.title"})}),(eH||es)&&l.jsx(w,{children:l.jsx("img",{src:eu,alt:""})}),ef&&l.jsxs(A,{top:eg,children:[l.jsx(d,{color:n("Selfie.countdown.color")({theme:ea})}),l.jsx(P,{children:ef})]}),"string"==typeof eK?l.jsx(H,{top:eh,className:"face-detection-error",children:eK}):null]})})}O.propTypes={apiCheck:h.bool,onLivenessDetectionDone:h.func,onClose:h.func,onError:h.func,onReset:h.func,captureFrameSettings:h.shape({}),onFramesCaptured:h.func,flipVideoHorizontal:h.bool,frontCamera:h.bool,isLoading:h.bool,customDirectionIcon:h.shape({}),customStepTimeConstraints:h.shape({}),onProcessing:h.func,customErrors:h.shape({}),apiCredentials:h.shape({accessKey:h.string,secretKey:h.string,apiUrl:h.string}),outputEncryptionSettings:h.shape({}),cameraScale:h.number,defaultCameraId:h.string,offsetFaceY:h.number,styledComponent:h.shape({CloseCameraButton:h.node}),serviceSettings:h.shape({})},O.defaultProps={apiCheck:!1,onLivenessDetectionDone:null,onClose:null,onError:()=>{},onReset:()=>{},captureFrameSettings:{enable:!1,framesIntervalTime:180,framesBatchLength:0},onFramesCaptured:()=>{},flipVideoHorizontal:null,frontCamera:!0,isLoading:!1,customDirectionIcon:{[c.FaceDirection.LEFT]:l.jsx(D,{type:c.FaceDirection.LEFT}),[c.FaceDirection.RIGHT]:l.jsx(D,{type:c.FaceDirection.RIGHT}),[c.FaceDirection.UP]:l.jsx(D,{type:c.FaceDirection.UP}),[c.FaceDirection.FRONTAL]:l.jsx(D,{type:c.FaceDirection.FRONTAL})},customStepTimeConstraints:{[c.FaceDirection.UP]:{delayTime:0},[c.FaceDirection.LEFT]:{delayTime:0},[c.FaceDirection.RIGHT]:{delayTime:0},[c.FaceDirection.FRONTAL]:{delayTime:2e3}},onProcessing:()=>{},customErrors:null,apiCredentials:{accessKey:"",secretKey:"",apiUrl:""},outputEncryptionSettings:null,cameraScale:1,defaultCameraId:void 0,offsetFaceY:0,styledComponent:{CloseCameraButton:null},serviceSettings:{enableUploadFrames:!0,enableUploadImages:!0,enableVerifySanityPortrait:!0,enableVerifySanityIDCard:!0,enableVerifyFaceLiveness:!0,enableDetectIDCardTampering:!0,enableReadIDCardInfo:!0}};export{O as default};
1
+ import{A as e,C as r,T as s,r as t,m as n,aI as a,b as o,c as i,s as c,j as l,a4 as u,az as m,a7 as p,W as d,P as h,k as g,aJ as f}from"./chunk-78da2232.js";import{M as j,O as x,W as y,C as C}from"./chunk-7b011490.js";import{u as F}from"./chunk-54342a62.js";import{D as D}from"./chunk-c1fff47f.js";import{p as S,d as b,e as v,A as T,f as k,I as I,h as E,F as _,i as V,j as L,T as R,L as w,k as A,l as P,S as H}from"./chunk-db249df9.js";import{u as N}from"./chunk-16aae30a.js";import"./chunk-df824644.js";import"./chunk-bf5a5b12.js";import"./chunk-3ed55750.js";import"./chunk-fbbb4c3f.js";let M=g.isMobile?{width:{ideal:640}}:null,$=({stepNumber:e,type:r,theme:s})=>{let t=f(`instruction_${r}.svg`),n=o(s,`Selfie.Active.imageHolder.${r}`);return null===n?l.jsx(l.Fragment,{}):"string"==typeof n&&""!==n?l.jsx("img",{src:n,alt:""}):"v1"===o(s,"themeVersion")?l.jsx("span",{children:e}):l.jsx("img",{src:t,alt:""})};function O(h){var f,D;let{apiCheck:O,onLivenessDetectionDone:U,captureFrameSettings:B,onFramesCaptured:K,frontCamera:z,flipVideoHorizontal:W,customDirectionIcon:G,customStepTimeConstraints:Y,onProcessing:J,customErrors:q,apiCredentials:Q,outputEncryptionSettings:X,cameraScale:Z,defaultCameraId:ee,offsetFaceY:er,isLoading:es,serviceSettings:et,onReset:en}=h,ea=e(),{onErrorCallback:eo,onCloseCallback:ei}=N(),ec=r.useAsset("bg_camera_mask.png"),el=r.useAsset("bg_camera_mask_red.png"),eu=s("IDCapturing.loadingIcon.src","ic_loading.gif"),[em,ep]=t.useState({}),{yFaceVerificationStepsWrapper:ed,yFaceDetectionError:eh,yCountdown:eg}=em,[ef,ej]=t.useState(""),[ex,ey]=t.useState(),eC=t.useMemo(()=>({backgroundColor:n("Selfie.backgroundColor")({theme:ea})}),[ea]);a(o(ea,"themeVersion"),"up_arrow.gif"),a(o(ea,"themeVersion"),"left_arrow.gif"),a(o(ea,"themeVersion"),"right_arrow.gif"),a(o(ea,"themeVersion"),"frontal_arrow.svg"),a(o(ea,"themeVersion"),"instruction_up.svg"),a(o(ea,"themeVersion"),"instruction_left.svg"),a(o(ea,"themeVersion"),"instruction_right.svg"),a(o(ea,"themeVersion"),"instruction_frontal.svg");let eF=t.useCallback(({lostY:e,height:r,clientHeight:s})=>{let t=g.isMobile?e:e+80,n=t+r+20,a=n+110;ep({yFaceDetectionError:a+30,yCountdown:a,yFaceVerificationStepsWrapper:n});let o=Math.floor(e),i=Math.floor(s-e),c=Math.floor(t);return 0!==er&&(c+er<o||c+er+r>i)?eo({code:`offsetFaceY must be in [-${c-o}, ${i-r-c}]`}):c+=er,{y:c}},[er,eo]),{shouldResetFlowOnOrientationChange:eD,cropArea:eS,curStepIndex:eb,directionIcon:ev,directionIconAnimation:eT,faceDetectionError:ek,resetFlow:eI,handleVideoPlayed:eE,instructions:e_,refVideo:eV,refIsReseting:eL,steps:eR,videoPlayed:ew,activeCapturing:eA,warmupDone:eP,showLoading:eH}=F({currentOrientation:ex,apiCheck:O,bgCameraMask:ec,bgCameraMaskRed:el,surroundStyle:eC,onLivenessDetectionDone:U,onError:eo,cropAreaDimension:eF,customDirectionIcon:G,captureFrameSettings:B,onFramesCaptured:K,setRemainingTime:ej,customStepTimeConstraints:Y,onProcessing:J,customErrors:q,apiCredentials:Q,outputEncryptionSettings:X,cameraScale:Z,serviceSettings:et,onReset:en});t.useEffect(()=>{"string"==typeof eR[0]?.directionIcon&&Promise.all(eR.map(e=>S(e.directionIcon)))},[eR]);let eN=b(h,ea),eM=eL.current?0:eb/eR.length*100,{lang:e$}=i.useSDKSettings(),eO=t.useRef(0),eU=t.useRef({}),eB=t.useRef(c.ErrorDuration.SHORT),eK=t.useMemo(()=>{let{msg:e,duration:r=c.ErrorDuration.SHORT}=ek||{},s=e?.[e$];return Date.now()-eO.current>=eB.current&&(eO.current=Date.now(),eB.current=r,eU.current=s),eU.current},[ek,eb]),ez=t.useCallback(e=>{ey(e),eD?eI():e===j.LANDSCAPE?eV.current?.pause():eV.current?.play()},[eV,eI,eD]);return l.jsx(x,{onOrientationChange:ez,children:l.jsxs(u,{frontCamera:z,onVideoPlayed:eE,onClose:ei,flipHorizontal:W??z,ref:eV,videoSettings:M,onError:eo,scale:Z,defaultCameraId:ee,closeButton:l.jsx(m,{}),children:[!eP&&l.jsx(y,{}),ew?l.jsxs(l.Fragment,{children:[eS.current?l.jsxs(C,{x:`${eS.current.x}px`,y:`${eS.current.y}px`,width:`${eS.current.width}px`,height:`${eS.current.height}px`,surroundStyle:eS.current.surroundStyle,children:[l.jsx(v,{padding:T}),l.jsx(k,{...eN,progress:eM,showErrorRing:!!ek}),l.jsx(I,{children:(f=ev,D=eT,f?"string"==typeof f?l.jsx("img",{className:D,src:f,alt:"",style:{maxWidth:"98px",maxHeight:"98px",marginBottom:"25px"}}):f:null)}),eA&&l.jsx(E,{})]}):null,e_?l.jsxs(l.Fragment,{children:[l.jsx(_,{top:ed+5,className:"instructions",children:e_}),l.jsx(V,{top:ed+40,children:eR.map((e,r)=>{let{name:s,image:{objUrl:t}}=e;return l.jsx(L,{active:eb>=r,className:"step-item",children:t?l.jsx("img",{className:"image_preview",src:t,alt:""}):l.jsx($,{stepNumber:r+1,type:s,theme:ea})},s)})})]}):null]}):null,l.jsx(R,{y:"20px",children:l.jsx(p,{id:"flash_liveness.title"})}),(eH||es)&&l.jsx(w,{children:l.jsx("img",{src:eu,alt:""})}),ef&&l.jsxs(A,{top:eg,children:[l.jsx(d,{color:n("Selfie.countdown.color")({theme:ea})}),l.jsx(P,{children:ef})]}),"string"==typeof eK?l.jsx(H,{top:eh,className:"face-detection-error",children:eK}):null]})})}O.propTypes={apiCheck:h.bool,onLivenessDetectionDone:h.func,onClose:h.func,onError:h.func,onReset:h.func,captureFrameSettings:h.shape({}),onFramesCaptured:h.func,flipVideoHorizontal:h.bool,frontCamera:h.bool,isLoading:h.bool,customDirectionIcon:h.shape({}),customStepTimeConstraints:h.shape({}),onProcessing:h.func,customErrors:h.shape({}),apiCredentials:h.shape({accessKey:h.string,secretKey:h.string,apiUrl:h.string}),outputEncryptionSettings:h.shape({}),cameraScale:h.number,defaultCameraId:h.string,offsetFaceY:h.number,styledComponent:h.shape({CloseCameraButton:h.node}),serviceSettings:h.shape({})},O.defaultProps={apiCheck:!1,onLivenessDetectionDone:null,onClose:null,onError:()=>{},onReset:()=>{},captureFrameSettings:{enable:!1,framesIntervalTime:180,framesBatchLength:0},onFramesCaptured:()=>{},flipVideoHorizontal:null,frontCamera:!0,isLoading:!1,customDirectionIcon:{[c.FaceDirection.LEFT]:l.jsx(D,{type:c.FaceDirection.LEFT}),[c.FaceDirection.RIGHT]:l.jsx(D,{type:c.FaceDirection.RIGHT}),[c.FaceDirection.UP]:l.jsx(D,{type:c.FaceDirection.UP}),[c.FaceDirection.FRONTAL]:l.jsx(D,{type:c.FaceDirection.FRONTAL})},customStepTimeConstraints:{[c.FaceDirection.UP]:{delayTime:0},[c.FaceDirection.LEFT]:{delayTime:0},[c.FaceDirection.RIGHT]:{delayTime:0},[c.FaceDirection.FRONTAL]:{delayTime:2e3}},onProcessing:()=>{},customErrors:null,apiCredentials:{accessKey:"",secretKey:"",apiUrl:""},outputEncryptionSettings:null,cameraScale:1,defaultCameraId:void 0,offsetFaceY:0,styledComponent:{CloseCameraButton:null},serviceSettings:{enableUploadFrames:!0,enableUploadImages:!0,enableVerifySanityPortrait:!0,enableVerifySanityIDCard:!0,enableVerifyFaceLiveness:!0,enableDetectIDCardTampering:!0,enableReadIDCardInfo:!0}};export{O as default};
@@ -1 +1 @@
1
- import{ah as n,aT as t,ai as i,$ as r}from"./chunk-ed832fec.js";function e(){if(f)return u;f=1;var r=i(),e=function(){if(o)return a;o=1;var t=n();return a=function(){return t.Date.now()}}(),c=t(),v=Math.max,d=Math.min;return u=function(n,t,i){var a,o,u,f,l,m,s=0,p=!1,g=!1,h=!0;if("function"!=typeof n)throw TypeError("Expected a function");function T(t){var i=a,r=o;return a=o=void 0,s=t,f=n.apply(r,i)}t=c(t)||0,r(i)&&(p=!!i.leading,u=(g="maxWait"in i)?v(c(i.maxWait)||0,t):u,h="trailing"in i?!!i.trailing:h);function x(n){var i=n-m,r=n-s;return void 0===m||i>=t||i<0||g&&r>=u}function y(){var n,i,r,a,o=e();if(x(o))return E(o);l=setTimeout(y,(i=(n=o)-m,r=n-s,a=t-i,g?d(a,u-r):a))}function E(n){return(l=void 0,h&&a)?T(n):(a=o=void 0,f)}function w(){var n,i=e(),r=x(i);if(a=arguments,o=this,m=i,r){if(void 0===l){return s=n=m,l=setTimeout(y,t),p?T(n):f}if(g)return clearTimeout(l),l=setTimeout(y,t),T(m)}return void 0===l&&(l=setTimeout(y,t)),f}return w.cancel=function(){void 0!==l&&clearTimeout(l),s=0,a=m=o=l=void 0},w.flush=function(){return void 0===l?f:E(e())},w}}var a,o,u,f,c,v,d=r(function(){if(v)return c;v=1;var n=e(),t=i();return c=function(i,r,e){var a=!0,o=!0;if("function"!=typeof i)throw TypeError("Expected a function");return t(e)&&(a="leading"in e?!!e.leading:a,o="trailing"in e?!!e.trailing:o),n(i,r,{leading:a,maxWait:r,trailing:o})}}());export{e as r,d as t};
1
+ import{ah as n,aT as t,ai as i,$ as r}from"./chunk-78da2232.js";function e(){if(f)return u;f=1;var r=i(),e=function(){if(o)return a;o=1;var t=n();return a=function(){return t.Date.now()}}(),c=t(),v=Math.max,d=Math.min;return u=function(n,t,i){var a,o,u,f,l,m,s=0,p=!1,g=!1,h=!0;if("function"!=typeof n)throw TypeError("Expected a function");function T(t){var i=a,r=o;return a=o=void 0,s=t,f=n.apply(r,i)}t=c(t)||0,r(i)&&(p=!!i.leading,u=(g="maxWait"in i)?v(c(i.maxWait)||0,t):u,h="trailing"in i?!!i.trailing:h);function x(n){var i=n-m,r=n-s;return void 0===m||i>=t||i<0||g&&r>=u}function y(){var n,i,r,a,o=e();if(x(o))return E(o);l=setTimeout(y,(i=(n=o)-m,r=n-s,a=t-i,g?d(a,u-r):a))}function E(n){return(l=void 0,h&&a)?T(n):(a=o=void 0,f)}function w(){var n,i=e(),r=x(i);if(a=arguments,o=this,m=i,r){if(void 0===l){return s=n=m,l=setTimeout(y,t),p?T(n):f}if(g)return clearTimeout(l),l=setTimeout(y,t),T(m)}return void 0===l&&(l=setTimeout(y,t)),f}return w.cancel=function(){void 0!==l&&clearTimeout(l),s=0,a=m=o=l=void 0},w.flush=function(){return void 0===l?f:E(e())},w}}var a,o,u,f,c,v,d=r(function(){if(v)return c;v=1;var n=e(),t=i();return c=function(i,r,e){var a=!0,o=!0;if("function"!=typeof i)throw TypeError("Expected a function");return t(e)&&(a="leading"in e?!!e.leading:a,o="trailing"in e?!!e.trailing:o),n(i,r,{leading:a,maxWait:r,trailing:o})}}());export{e as r,d as t};
@@ -1,3 +1,3 @@
1
- import{i as i,P as e,s as t,A as c,T as o,m as r,b as n,j as a}from"./chunk-ed832fec.js";let s=i.img`
1
+ import{i as i,P as e,s as t,A as c,T as o,m as r,b as n,j as a}from"./chunk-78da2232.js";let s=i.img`
2
2
  width: ${({width:i})=>i};
3
3
  `;function l({type:i}){let e=c(),l=o(`Selfie.Active.directionIcon.${i}`,`${i}_arrow.gif`),F=o(`Selfie.Active.directionIcon.${t.FaceDirection.FRONTAL}`,"frontal_arrow.svg"),d=r(`Selfie.Active.directionIcon.${i}Width`)({theme:e}),f=n(e,`Selfie.Active.directionIcon.${i}`);return null===f?a.jsx(a.Fragment,{}):i===t.FaceDirection.FRONTAL&&F?a.jsx(s,{src:F,width:d,alt:""}):f&&null!==f?a.jsx(s,{src:n(e,`Selfie.Active.directionIcon.${i}`),width:d,alt:""}):a.jsx(s,{src:l,alt:"",width:d})}l.propTypes={type:e.oneOf([t.FaceDirection.LEFT,t.FaceDirection.RIGHT,t.FaceDirection.UP,t.FaceDirection.FRONTAL])},l.defaultProps={type:t.FaceDirection.LEFT};export{l as D};
@@ -1 +1 @@
1
- import{r as e,b as t,u as s,aH as a,s as n,c as i,ab as r,d as l,e as c,f as o,k as u,aK as _,aL as m,J as g,O as d,Y as f,Q as h,F as b,av as v,t as p,aB as w,j as k}from"./chunk-ed832fec.js";import{t as y}from"./chunk-e77bab5e.js";import{t as F}from"./chunk-81ce3c83.js";import{n as T,u as L,o as R,q as B,r as C,v as S,s as x,x as I}from"./chunk-7f5333af.js";import{m as M}from"./chunk-de5b2d76.js";import{u as D}from"./chunk-b87b1853.js";let E=a.faceTracker(),j=new _,{FaceDirection:P,Errors:A,Messages:V,TrackLivenessEvents:W}=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:Z,surroundStyle:G,cropAreaDimension:H,customInstructions:J,customIcon:Q,customDirectionIcon:X,customStepTimeConstraints:Y=U,onLivenessDetectionDone:$,onError:ee,frontalMinSize:et,waitingTimeToGetBetterFrames:es=500,captureFrameSettings:ea=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:eB,assetRoot:eC,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),[ej,eP]=e.useState(!1),eA=e.useRef({}),{sendEvent:eV}=c.useSDKTracking(),[eW,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),eZ=e.useRef([]),eG=e.useRef(null),eH=e.useRef(),eJ=e.useRef(null);null===eJ.current&&(eJ.current=a.initFaceVerificationData({assetRoot:eC,customInstructions:J,customIcon:Q,customDirectionIcon:X,customStepTimeConstraints:Y,Locale:eI,lang:eB}));let[eQ,eX]=e.useState(),eY=e.useCallback(e=>{eX(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:ts,waitBeforeStartFlowMs:ta,resetFlowOnOrientationChange:tn,captureFrameSettings:ti}=function({clientSettings:a,captureFrameSettingsProp:n}){return e.useMemo(()=>{let e,i=M({},T,a),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"),_=s.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:!s.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(a,"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}},[a,n])}({clientSettings:e4,captureFrameSettingsProp:ea}),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===W?.show_alert){let t=e.log?.alert;if(t===to.current)return;to.current=t}eV(e),ed&&ed(e)}},[ed,eV]),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:W?.start_camera,log:{}})},[tu]),e.useEffect(()=>(j.start(),()=>{j.stop()}),[]),e.useEffect(()=>{let e=!1;return async function t(){!ej&&(e1.current=performance.now(),eA.current=await m(eS),await g.initTensorFlow({preferredBackends:["wasm","webgl","cpu"]}),e||(eP(!0),tu({tag:"selfie",event:W?.show_warmup,log:{}}),tu({tag:"selfie",event:W?.finish_load_model,log:{status:"success",time_in_ms:performance.now()-e1.current}}),e1.current=null))}(),()=>{e=!0}},[ej,eS,tu]);let tf=e.useRef(!1),th=e.useCallback(()=>{eJ.current.curStepIndex=eJ.current.steps.length,tf.current=!0,eF(!1),td.current?.discardRecording(),clearInterval(eq.current)},[]),tb=e.useCallback(()=>{eJ.current=a.initFaceVerificationData({assetRoot:eC,customInstructions:J,customIcon:Q,customDirectionIcon:X,Locale:eI,lang:eB}),tm.current=0,tg.current=null,e0.current=[],eL(!1),eX(null),x(),td.current?.start(),tf.current=!1,eK(!1),eN(3),eG.current=null,eZ.current=[],eH.current=null,"function"==typeof eb&&eb(),eD()},[eI,eC,X,Q,J,eK,eB,eb]),tv=e.useCallback(()=>{th(),setTimeout(()=>{tb()},e2)},[e2,tb,th]),tp=e.useMemo(()=>({...A,...er}),[er]),tw=e.useMemo(()=>({...V,...el}),[el]),tk=e.useCallback(()=>{let e={};Object.keys(tp.liveness_terminated_time_out?.msg).forEach(t=>{let s=F(tp.liveness_terminated_time_out?.msg[t]);e[t]=s({x:e3.limitTimeSecond})}),eX({...tp.liveness_terminated_time_out,msg:e,duration:.95*e2}),tu({tag:"selfie",event:W?.show_alert,log:{alert:"liveness_terminated_time_out,"}}),j.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=F(tw.REMAIN_TIME[eB]),s=e;switch(e3.format){case"mm:ss":s=e.toString().padStart(5,"00:00");break;case"ss":s=e.toString().padStart(2,"0")}en(t({x:s}))}},[eB,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(),j.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&&ej,onTimesUp:tk,onTick:ty,onReset:tF}),tL=e.useCallback(({clientWidth:e,clientHeight:t,videoAreaWidth:s,videoAreaHeight:a,lostX:n,lostY:i})=>{let r,l;u.isMobile?l=r=s:r=l=a-200;let c=Math.floor((s-r)/2)+n;eE.current={x:c,y:5+i,width:r,height:l,image:k,surroundStyle:G},"object"==typeof H?eE.current={...eE.current,...H}:"function"==typeof H&&(eE.current={...eE.current,...H({clientWidth:e,clientHeight:t,videoAreaWidth:s,videoAreaHeight:a,lostX:n,lostY:i,isMobile:u.isMobile,width:r,height:l})}),eD(),ek(!0)},[k,G,H]),tR=e.useCallback(()=>{eN(3),clearInterval(eq.current),eK(!0);let e=async e=>{if(e-1==0){let e;j.stop(),tT(),clearInterval(eq.current),ei(),await td.current?.stopVideoRecording(),ep(!0),d.addExifData("user_action",{start_selfie:Date.now()-1e3*j.duration("from_1st_frame"),end_selfie:Date.now()});let t=(e=e9.enable?[eG.current]:eZ.current).map(e=>f.resizeBlobImg(e.blob,400,400)),s=(await Promise.all(t)).map((t,s)=>{let a=d.parseLivenessImg({...e[s],gesture:"frontal"});return d.writeCurrentExif({imageData:{blob:t},enableExifData:e6.enable,additionalData:a})}),a=await Promise.all(s),n={};if(e_&&e_.key){let{key:e}=e_,t=a.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,s)=>({...t,base64:e[s]})),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:s})=>({base64:e,label:t,index:s}))),_&&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:P.FRONTAL})}),s=e.map((e,s)=>eM.uploadImage({file:a[s],...t(e.leftRightScore)}));e_&&e_.key&&(s=e.map((e,s)=>{let a=new Blob([n.frontalFacesEncrypted[s].hex]);return eM.uploadImage({file:a,...t(e.leftRightScore)},{"X-TV-Key":e_.key})}));try{let t=await Promise.all(s),a=null;tc.enableVerifyFaceLiveness&&(a=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([a,n]);$({apiCheckPassed:r?.data.is_live??!1,verifyFaceLivenessResult:r?.data??null,verifyFacePortraitResult:l?.data??null,frontalFaces:t.map((t,s)=>({id:t?.data?.image_id,blob:e?.[s]?.blob}))})}catch(e){ee({error:e})}}else $({frontalFaces:a,...n,capturedFrames:i,video:B()}),C()}};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]),tB=e.useRef({});e.useEffect(()=>{tB.current.isFirstValidFrameFoundRef=eT},[eT]),e.useEffect(()=>{let e,t=eR.current;async function s({faceDirection:e,canvas:t,leftRightScore:s,blurScore:a,isEyeClosed:n}){if(!0===ez.current&&(ts&&e===P.FRONTAL||!ts)){let e=await b.takePicture({canvas:t});e9?.enable&&Date.now()-eH.current<e9?.waitForBestImageTimeMsWeb?(eG.current||(eG.current={blob:e,blurScore:a,isEyeClosed:n,captureTime:Date.now()}),tt?.enable&&(eG.current=I({incomingFrame:{blob:e,blurScore:a,isEyeClosed:n,captureTime:Date.now()},currentBestFrame:eG.current}))):eZ.current.length<1&&eZ.current.push({blob:e,leftRightScore:s,captureTime:Date.now(),blurScore:a})}}async function i(r,l){let c,o;if(l?.width===0||l?.height===0)return;let{isFirstValidFrameFoundRef:u}=tB.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:B,faceNotFrontalMinThreshold:C}=await a.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}=eJ.current;if(L){I=L.landmarks;let e=await a.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===j.duration("limit_close_eye")||j.duration("limit_close_eye")<t)){e7?.forceCheck||-1!==j.duration("limit_close_eye")||j.start("limit_close_eye");let{isEyeClose:e}=await b.predict(l,I,e7?.webThreshold);e&&!c&&(c=A.close_eye)}}let V=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:s}=e5;tg.current&&e||(tg.current={time:Date.now(),frame:0}),e&&tg.current.frame++;let{time:a}=tg.current;e&&Date.now()-a>=s&&(eX({...tp.liveness_terminated_no_face,duration:e2}),tu({tag:"selfie",event:W?.show_alert,log:{alert:"liveness_terminated_no_face"}}),tv())}({noFace:V&&N,isFirstValidFrameFoundRef:u}),c?.code&&t_({tag:"selfie",event:W?.show_alert,log:{alert:c.code}}),!c||"face_too_small"===c.code&&S!==P.FRONTAL&&B>=C){if(!function(e,t,s,a){if(e0.current.length&&Date.now()-e0.current[e0.current.length-1].time<ti.framesIntervalTime)return;if(ti.enable&&!0){let{topLeft:a,bottomRight:n}=e,i=[...a,...n],{score:r,time:l}=E(e,0===e0.current.length),c={label:"portrait",base64:t.toDataURL("image/jpeg",.8).split(",")[1],landmarks:s,original_landmarks:s,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:s},a)=>({base64:t[a],label:e,index:s}))),_&&tc.enableUploadFrames&&R(e_,e.map(({label:e,index:s},a)=>({base64:t[a],label:e,index:s})),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:s})=>({base64:e,label:t,index:s}))),_&&tc.enableUploadFrames&&R(e_,e0.current.slice(-ti.framesBatchLength),eM,e0.current.length===ti.framesBatchLength));return};}(F[0],l,I),S!==P.FRONTAL&&ts)o=tp.not_frontal_face,eE.current.image=Z;else if(!c){u||(eL(!0),j.start("from_1st_frame"));let e=e9?.enable&&!ez.current&&0===eZ.current.length;tt?.enable?null!==y&&y>tt?.webBlurryThreshold?(o=null,e&&(eH.current=Date.now(),tR())):ez.current||(o=tp.liveness_blurry):e&&(eH.current=Date.now(),tR());let{isEyeClose:t}=await b.predict(l,I,e7?.webThreshold);await s({faceDirection:S,canvas:l,leftRightScore:x,blurScore:y,...null!==t?{isEyeClosed:t}:{}})}}else M<D.length&&(o=tp[c.code],eE.current.image=Z);e$(o),-1!==e&&(e=requestAnimationFrame(()=>i(r,l)))}async function r(){let e=b.analyzeVideoAndWindowSizes(t,eE.current),s=document.createElement("canvas");s.width=400,s.height=400;let a=s.getContext("2d");a.translate(400,0),a.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,s)}return ew&&ej&&setTimeout(()=>{r()},ta??eu),()=>{cancelAnimationFrame(e),e=-1}},[eh,ta,ts,tt?.enable,tt?.webBlurryThreshold,e9?.enable,e9?.waitForBestImageTimeMsWeb,eu,ew,eB,eM,_,k,Z,$,ee,et,es,ti,ei,e3.enable,en,e$,Y,e2,tv,e5,tp,ej,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(()=>{eQ&&(eQ?.code!==tp?.liveness_terminated_time_out&&eQ?.code!==tp?.liveness_terminated_no_face&&e9?.enable&&ez.current||(clearInterval(eq.current),eK(!1),eG.current=null,eZ.current=[],eH.current=null))},[e9?.enable,eQ,eK,tp]);let{curStepIndex:tC,steps:tS}=eJ.current,tx=eT&&!eQ&&!eg&&(!e9?.enable||e9?.showCaptureButton),tI=eU&&!tf.current&&(e9?.enable?e9?.showCountdown:te?.showCountdown);return{resetFlowOnOrientationChange:tn,countdownToTakePicture:eW,cropArea:eE,curStepIndex:tC,faceDetectionError:eQ,resetFlow:tv,handleTriggerPassiveMode:tR,handleVideoPlayed:tL,refVideo:eR,refIsReseting:tf,showCountdown:eU,steps:tS,videoPlayed:ew,activeCapturing:ey,isFirstValidFrameFound:eT,warmupDone:ej,showLoading:ev,showCaptureButton:tx,shouldShowCountdown:tI}}function Z({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{Z as C,q as u};
1
+ import{r as e,b as t,u as s,aH as a,s as n,c as i,ab as r,d as l,e as c,f as o,k as u,aK as _,aL as m,I as g,O as d,Y as f,Q as h,G as b,av as v,t as p,aB as w,j as k}from"./chunk-78da2232.js";import{t as y}from"./chunk-bf5a5b12.js";import{t as F}from"./chunk-3ed55750.js";import{n as T,u as L,o as R,q as B,r as C,v as S,s as x,x as I}from"./chunk-db249df9.js";import{m as M}from"./chunk-16aae30a.js";import{u as D}from"./chunk-fbbb4c3f.js";let E=a.faceTracker(),j=new _,{FaceDirection:P,Errors:A,Messages:V,TrackLivenessEvents:W}=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:H,customInstructions:J,customIcon:Q,customDirectionIcon:X,customStepTimeConstraints:Y=U,onLivenessDetectionDone:$,onError:ee,frontalMinSize:et,waitingTimeToGetBetterFrames:es=500,captureFrameSettings:ea=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:eB,assetRoot:eC,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),[ej,eP]=e.useState(!1),eA=e.useRef({}),{sendEvent:eV}=c.useSDKTracking(),[eW,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),eH=e.useRef(),eJ=e.useRef(null);null===eJ.current&&(eJ.current=a.initFaceVerificationData({assetRoot:eC,customInstructions:J,customIcon:Q,customDirectionIcon:X,customStepTimeConstraints:Y,Locale:eI,lang:eB}));let[eQ,eX]=e.useState(),eY=e.useCallback(e=>{eX(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:ts,waitBeforeStartFlowMs:ta,resetFlowOnOrientationChange:tn,captureFrameSettings:ti}=function({clientSettings:a,captureFrameSettingsProp:n}){return e.useMemo(()=>{let e,i=M({},T,a),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"),_=s.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:!s.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(a,"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}},[a,n])}({clientSettings:e4,captureFrameSettingsProp:ea}),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===W?.show_alert){let t=e.log?.alert;if(t===to.current)return;to.current=t}eV(e),ed&&ed(e)}},[ed,eV]),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:W?.start_camera,log:{}})},[tu]),e.useEffect(()=>(j.start(),()=>{j.stop()}),[]),e.useEffect(()=>{let e=!1;return async function t(){!ej&&(e1.current=performance.now(),eA.current=await m(eS),await g.initTensorFlow({preferredBackends:["wasm","webgl","cpu"]}),e||(eP(!0),tu({tag:"selfie",event:W?.show_warmup,log:{}}),tu({tag:"selfie",event:W?.finish_load_model,log:{status:"success",time_in_ms:performance.now()-e1.current}}),e1.current=null))}(),()=>{e=!0}},[ej,eS,tu]);let tf=e.useRef(!1),th=e.useCallback(()=>{eJ.current.curStepIndex=eJ.current.steps.length,tf.current=!0,eF(!1),td.current?.discardRecording(),clearInterval(eq.current)},[]),tb=e.useCallback(()=>{eJ.current=a.initFaceVerificationData({assetRoot:eC,customInstructions:J,customIcon:Q,customDirectionIcon:X,Locale:eI,lang:eB}),tm.current=0,tg.current=null,e0.current=[],eL(!1),eX(null),x(),td.current?.start(),tf.current=!1,eK(!1),eN(3),eZ.current=null,eG.current=[],eH.current=null,"function"==typeof eb&&eb(),eD()},[eI,eC,X,Q,J,eK,eB,eb]),tv=e.useCallback(()=>{th(),setTimeout(()=>{tb()},e2)},[e2,tb,th]),tp=e.useMemo(()=>({...A,...er}),[er]),tw=e.useMemo(()=>({...V,...el}),[el]),tk=e.useCallback(()=>{let e={};Object.keys(tp.liveness_terminated_time_out?.msg).forEach(t=>{let s=F(tp.liveness_terminated_time_out?.msg[t]);e[t]=s({x:e3.limitTimeSecond})}),eX({...tp.liveness_terminated_time_out,msg:e,duration:.95*e2}),tu({tag:"selfie",event:W?.show_alert,log:{alert:"liveness_terminated_time_out,"}}),j.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=F(tw.REMAIN_TIME[eB]),s=e;switch(e3.format){case"mm:ss":s=e.toString().padStart(5,"00:00");break;case"ss":s=e.toString().padStart(2,"0")}en(t({x:s}))}},[eB,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(),j.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&&ej,onTimesUp:tk,onTick:ty,onReset:tF}),tL=e.useCallback(({clientWidth:e,clientHeight:t,videoAreaWidth:s,videoAreaHeight:a,lostX:n,lostY:i})=>{let r,l;u.isMobile?l=r=s:r=l=a-200;let c=Math.floor((s-r)/2)+n;eE.current={x:c,y:5+i,width:r,height:l,image:k,surroundStyle:Z},"object"==typeof H?eE.current={...eE.current,...H}:"function"==typeof H&&(eE.current={...eE.current,...H({clientWidth:e,clientHeight:t,videoAreaWidth:s,videoAreaHeight:a,lostX:n,lostY:i,isMobile:u.isMobile,width:r,height:l})}),eD(),ek(!0)},[k,Z,H]),tR=e.useCallback(()=>{eN(3),clearInterval(eq.current),eK(!0);let e=async e=>{if(e-1==0){let e;j.stop(),tT(),clearInterval(eq.current),ei(),await td.current?.stopVideoRecording(),ep(!0),d.addExifData("user_action",{start_selfie:Date.now()-1e3*j.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)),s=(await Promise.all(t)).map((t,s)=>{let a=d.parseLivenessImg({...e[s],gesture:"frontal"});return d.writeCurrentExif({imageData:{blob:t},enableExifData:e6.enable,additionalData:a})}),a=await Promise.all(s),n={};if(e_&&e_.key){let{key:e}=e_,t=a.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,s)=>({...t,base64:e[s]})),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:s})=>({base64:e,label:t,index:s}))),_&&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:P.FRONTAL})}),s=e.map((e,s)=>eM.uploadImage({file:a[s],...t(e.leftRightScore)}));e_&&e_.key&&(s=e.map((e,s)=>{let a=new Blob([n.frontalFacesEncrypted[s].hex]);return eM.uploadImage({file:a,...t(e.leftRightScore)},{"X-TV-Key":e_.key})}));try{let t=await Promise.all(s),a=null;tc.enableVerifyFaceLiveness&&(a=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([a,n]);$({apiCheckPassed:r?.data.is_live??!1,verifyFaceLivenessResult:r?.data??null,verifyFacePortraitResult:l?.data??null,frontalFaces:t.map((t,s)=>({id:t?.data?.image_id,blob:e?.[s]?.blob}))})}catch(e){ee({error:e})}}else $({frontalFaces:a,...n,capturedFrames:i,video:B()}),C()}};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]),tB=e.useRef({});e.useEffect(()=>{tB.current.isFirstValidFrameFoundRef=eT},[eT]),e.useEffect(()=>{let e,t=eR.current;async function s({faceDirection:e,canvas:t,leftRightScore:s,blurScore:a,isEyeClosed:n}){if(!0===ez.current&&(ts&&e===P.FRONTAL||!ts)){let e=await b.takePicture({canvas:t});e9?.enable&&Date.now()-eH.current<e9?.waitForBestImageTimeMsWeb?(eZ.current||(eZ.current={blob:e,blurScore:a,isEyeClosed:n,captureTime:Date.now()}),tt?.enable&&(eZ.current=I({incomingFrame:{blob:e,blurScore:a,isEyeClosed:n,captureTime:Date.now()},currentBestFrame:eZ.current}))):eG.current.length<1&&eG.current.push({blob:e,leftRightScore:s,captureTime:Date.now(),blurScore:a})}}async function i(r,l){let c,o;if(l?.width===0||l?.height===0)return;let{isFirstValidFrameFoundRef:u}=tB.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:B,faceNotFrontalMinThreshold:C}=await a.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}=eJ.current;if(L){I=L.landmarks;let e=await a.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===j.duration("limit_close_eye")||j.duration("limit_close_eye")<t)){e7?.forceCheck||-1!==j.duration("limit_close_eye")||j.start("limit_close_eye");let{isEyeClose:e}=await b.predict(l,I,e7?.webThreshold);e&&!c&&(c=A.close_eye)}}let V=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:s}=e5;tg.current&&e||(tg.current={time:Date.now(),frame:0}),e&&tg.current.frame++;let{time:a}=tg.current;e&&Date.now()-a>=s&&(eX({...tp.liveness_terminated_no_face,duration:e2}),tu({tag:"selfie",event:W?.show_alert,log:{alert:"liveness_terminated_no_face"}}),tv())}({noFace:V&&N,isFirstValidFrameFoundRef:u}),c?.code&&t_({tag:"selfie",event:W?.show_alert,log:{alert:c.code}}),!c||"face_too_small"===c.code&&S!==P.FRONTAL&&B>=C){if(!function(e,t,s,a){if(e0.current.length&&Date.now()-e0.current[e0.current.length-1].time<ti.framesIntervalTime)return;if(ti.enable&&!0){let{topLeft:a,bottomRight:n}=e,i=[...a,...n],{score:r,time:l}=E(e,0===e0.current.length),c={label:"portrait",base64:t.toDataURL("image/jpeg",.8).split(",")[1],landmarks:s,original_landmarks:s,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:s},a)=>({base64:t[a],label:e,index:s}))),_&&tc.enableUploadFrames&&R(e_,e.map(({label:e,index:s},a)=>({base64:t[a],label:e,index:s})),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:s})=>({base64:e,label:t,index:s}))),_&&tc.enableUploadFrames&&R(e_,e0.current.slice(-ti.framesBatchLength),eM,e0.current.length===ti.framesBatchLength));return};}(F[0],l,I),S!==P.FRONTAL&&ts)o=tp.not_frontal_face,eE.current.image=G;else if(!c){u||(eL(!0),j.start("from_1st_frame"));let e=e9?.enable&&!ez.current&&0===eG.current.length;tt?.enable?null!==y&&y>tt?.webBlurryThreshold?(o=null,e&&(eH.current=Date.now(),tR())):ez.current||(o=tp.liveness_blurry):e&&(eH.current=Date.now(),tR());let{isEyeClose:t}=await b.predict(l,I,e7?.webThreshold);await s({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),s=document.createElement("canvas");s.width=400,s.height=400;let a=s.getContext("2d");a.translate(400,0),a.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,s)}return ew&&ej&&setTimeout(()=>{r()},ta??eu),()=>{cancelAnimationFrame(e),e=-1}},[eh,ta,ts,tt?.enable,tt?.webBlurryThreshold,e9?.enable,e9?.waitForBestImageTimeMsWeb,eu,ew,eB,eM,_,k,G,$,ee,et,es,ti,ei,e3.enable,en,e$,Y,e2,tv,e5,tp,ej,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(()=>{eQ&&(eQ?.code!==tp?.liveness_terminated_time_out&&eQ?.code!==tp?.liveness_terminated_no_face&&e9?.enable&&ez.current||(clearInterval(eq.current),eK(!1),eZ.current=null,eG.current=[],eH.current=null))},[e9?.enable,eQ,eK,tp]);let{curStepIndex:tC,steps:tS}=eJ.current,tx=eT&&!eQ&&!eg&&(!e9?.enable||e9?.showCaptureButton),tI=eU&&!tf.current&&(e9?.enable?e9?.showCountdown:te?.showCountdown);return{resetFlowOnOrientationChange:tn,countdownToTakePicture:eW,cropArea:eE,curStepIndex:tC,faceDetectionError:eQ,resetFlow:tv,handleTriggerPassiveMode:tR,handleVideoPlayed:tL,refVideo:eR,refIsReseting:tf,showCountdown:eU,steps:tS,videoPlayed:ew,activeCapturing:ey,isFirstValidFrameFound:eT,warmupDone:ej,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};
@@ -1 +1 @@
1
- import{r as e,u as t,k as s,b as a,A as i,m as n,ap as r,aq as l,M as o,O as _,Q as g,j as d,ar as c,as as m,at as f,au as u,av as v,aC as b,aD as h,az as p,F as k,R as y,d as S,f as C,s as F,aA as x,aB as w,Y as E,P as W}from"./chunk-ed832fec.js";import{d as R}from"./chunk-ff693e7b.js";import{t as M}from"./chunk-e77bab5e.js";import{C as L,O as O}from"./chunk-e0f43811.js";import{u as D,S as B,a as I,o as P,b as T,c as j,d as A,n as V,l as q,f as U,F as z,e as Q,s as N,g as J,h as G,i as H,j as K,W as $,k as X,m as Y,p as Z,q as ee,r as et,A as es,O as ea}from"./chunk-0811f0b9.js";import{m as ei,u as en,b as er}from"./chunk-de5b2d76.js";import{u as el}from"./chunk-b87b1853.js";let eo=0,e_=1,eg={data:{settings:{sdk_settings:{passive_liveness_v2_settings:{frontal_face_check:{enable:!0,up_down_bound_min:.35,up_down_bound_max:.7},capture_frame_settings:{enable:!1,frames_batch_length:10,frames_interval_time:0,frame_quality:.8,frame_scale:1,auto_capture_min_frames:8,auto_capture_min_frames_far:8,auto_capture_min_frames_close:0},not_qualified_settings:{enable_far:!1,threshold_far:.11},close_eyes_settings:{enable:!1,timeout:5,force_check:!1},face_settings:{chin_height:20,max_far_face_ratio:.9,min_far_face_ratio:.8,mobile:{chin_height:20,max_far_face_ratio:.9,min_far_face_ratio:.85}},timeout_settings:{enable:!0,total:30,countdown:10,max_retry_count:0,non_stoppable:!1},exif_data_settings:{enable:!0},mask_settings:{mobile:{oval_vertical_padding:20,oval_horizontal_padding:20,oval_vertical_offset:60,small_scale:.65},oval_horizontal_padding:20,oval_vertical_padding:20,oval_vertical_offset:0,small_scale:.6},image_settings:{valid_face_ratio:.6,image_quality:1,crop_center_far:!0,crop_center_close:!1,detection_to_whole_face_ratio:.8},blur_far_settings:{enable:!0,blurry_threshold:.4,wait_for_best_image_time_ms:1e3},brightness_detection_far_settings:{enable_too_bright_check:!1,enable_too_dark_check:!1,too_bright_threshold:.83,too_dark_threshold:.195},output_image_settings:{image_ordering:["far","close"]},auto_gen_frame_ids:{enable:!1,max_items:50}}}}}},ed=()=>{let i=el();return e.useMemo(()=>{let e=ei({},eg,i),n={enable:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.capture_frame_settings.enable"),framesIntervalTime:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.capture_frame_settings.frames_interval_time"),framesBatchLength:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.capture_frame_settings.frames_batch_length"),frameScale:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.capture_frame_settings.frame_scale"),frameQuality:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.capture_frame_settings.frame_quality"),autoCaptureMinFrames:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.capture_frame_settings.auto_capture_min_frames"),autoCaptureMinFramesFar:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.capture_frame_settings.auto_capture_min_frames_far"),autoCaptureMinFramesClose:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.capture_frame_settings.auto_capture_min_frames_close")},r={smallScale:t.getWebSetting(e,s.isMobile?"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.mobile.small_scale":"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.small_scale"),largeScale:t.getWebSetting(e,s.isMobile?"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.mobile.small_scale":"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.small_scale"),ovalPadding:{left:t.getWebSetting(e,s.isMobile?"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.mobile.oval_horizontal_padding":"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.oval_horizontal_padding"),right:t.getWebSetting(e,s.isMobile?"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.mobile.oval_horizontal_padding":"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.oval_horizontal_padding"),top:t.getWebSetting(e,s.isMobile?"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.mobile.oval_vertical_padding":"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.oval_vertical_padding"),bottom:t.getWebSetting(e,s.isMobile?"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.mobile.oval_vertical_padding":"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.oval_vertical_padding")},ovalVerticalOffset:t.getWebSetting(e,s.isMobile?"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.mobile.oval_vertical_offset":"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.oval_vertical_offset"),chinToMaskBottomPadding:t.getWebSetting(e,s.isMobile?"data.settings.sdk_settings.passive_liveness_v2_settings.face_settings.mobile.chin_height":"data.settings.sdk_settings.passive_liveness_v2_settings.face_settings.chin_height")},l={minFarFaceRatio:t.getWebSetting(e,s.isMobile?"data.settings.sdk_settings.passive_liveness_v2_settings.face_settings.mobile.min_far_face_ratio":"data.settings.sdk_settings.passive_liveness_v2_settings.face_settings.min_far_face_ratio"),maxFarFaceRatio:t.getWebSetting(e,s.isMobile?"data.settings.sdk_settings.passive_liveness_v2_settings.face_settings.mobile.max_far_face_ratio":"data.settings.sdk_settings.passive_liveness_v2_settings.face_settings.max_far_face_ratio")},o={enable:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.close_eyes_settings.enable"),timeout:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.close_eyes_settings.timeout"),forceCheck:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.close_eyes_settings.force_check")},_={enable:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.exif_data_settings.enable")},g={imageQuality:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.image_settings.image_quality"),validFaceRatio:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.image_settings.valid_face_ratio"),enableCropCenterFar:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.image_settings.crop_center_far"),detectionToWholeFaceRatio:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.image_settings.detection_to_whole_face_ratio")},d=t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.timeout_settings.max_retry_count"),c={enable:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.timeout_settings.enable"),total:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.timeout_settings.total"),countdown:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.timeout_settings.countdown"),enableMaxRetryCount:d>0,maxRetryCount:d,interruptible:!t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.timeout_settings.non_stoppable")},m={enable:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.blur_far_settings.enable"),threshold:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.blur_far_settings.blurry_threshold"),duration:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.blur_far_settings.wait_for_best_image_time_ms")},f={enable:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.not_qualified_settings.enable_far"),threshold:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.not_qualified_settings.threshold_far")},u={enableTooBrightCheck:a(e,"data.settings.sdk_settings.passive_liveness_v2_settings.brightness_detection_far_settings.enable_too_bright_check"),enableTooDarkCheck:a(e,"data.settings.sdk_settings.passive_liveness_v2_settings.brightness_detection_far_settings.enable_too_dark_check"),tooBrightThreshold:a(e,"data.settings.sdk_settings.passive_liveness_v2_settings.brightness_detection_far_settings.too_bright_threshold"),tooDarkThreshold:a(e,"data.settings.sdk_settings.passive_liveness_v2_settings.brightness_detection_far_settings.too_dark_threshold")},v={imageOrdering:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.output_image_settings.image_ordering"),farImageOrder:e_,closeImageOrder:eo};Array.isArray(v.imageOrdering)&&2===v.imageOrdering.length&&"far"===v.imageOrdering[0]&&"close"===v.imageOrdering[1]&&(v.farImageOrder=0,v.closeImageOrder=1);let b={enable:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.auto_gen_frame_ids.enable")&&c.enable,maxItems:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.auto_gen_frame_ids.max_items")};return{captureFrameSettings:n,livenessSettings:{},flashSettings:{},maskSettings:r,faceSettings:l,closeEyesSettings:o,exifSettings:_,imageSettings:g,timeoutSettings:c,blurCheckFarSettings:m,blurCheckCloseSettings:{},notQualifiedFarSettings:f,notQualifiedCloseSettings:{},brightnessDetectionFarSettings:u,brightnessDetectionCloseSettings:{},outputImageSettings:v,autoGenFrameIds:b,frontalFaceCheckSettings:{enable:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.frontal_face_check.enable"),upDownBoundMin:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.frontal_face_check.up_down_bound_min"),upDownBoundMax:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.frontal_face_check.up_down_bound_max")}}},[i])},ec=s.isMobile?{width:{ideal:640},whiteBalanceMode:"none"}:{width:{ideal:9999},whiteBalanceMode:"none"},em=(e,t)=>""===t.faceError&&(!!e.isEyeClosed&&!t.isEyeClosed||(!!e.isEyeClosed||!t.isEyeClosed)&&(!!u.hasBetterBrightnessScore(t.brightnessScore,e.brightnessScore)||!!u.hasSameBrightnessScore(t.brightnessScore,e.brightnessScore)&&v.hasBetterBlurScore(t.blurScore,e.blurScore)));function ef(t){let{onReset:s,onDone:a,frontCamera:u,styledComponent:v,onFramesCaptured:S,customComponent:C,extraConfig:F}=t,{onErrorCallback:x,onCloseCallback:w}=en(),E=ed(),W=C?.PassiveLivenessBody??b,O=C?.PassiveLivenessError??h,Z=C?.PassiveLivenessCloseIcon??p,{maskSettings:ee,faceSettings:et,captureFrameSettings:es,exifSettings:ea,imageSettings:ei,timeoutSettings:el,blurCheckFarSettings:eo,outputImageSettings:e_,autoGenFrameIds:eg}=E,ef=e.useRef(),eu=D(),ev=er(),[eb,eh]=e.useState(""),ep=e.useMemo(()=>M(eh,1e3),[]),[ek,ey]=e.useState(!1),[eS,eC]=e.useState(B.LOADING),eF=i(),ex={width:n("FlashLiveness.mask.width")({theme:eF}),height:n("FlashLiveness.mask.height")({theme:eF}),strokeColor:(eS===B.FAR_FACE||eS===B.CLOSE_FACE)&&eb&&!ek?n("FlashLiveness.mask.strokeColorError")({theme:eF}):n("FlashLiveness.mask.strokeColor")({theme:eF}),strokeWidth:2*n("FlashLiveness.mask.strokeWidth")({theme:eF}),path:n("FlashLiveness.mask.path")({theme:eF}),backgroundColor:n("FlashLiveness.maskFill")({theme:eF})},ew=e.useRef(null),[eE,eW,eR]=I(),[eM,eL]=e.useState(0),[eO,eD]=e.useState(!1),eB=e.useRef({frames:[],images:[]}),eI=e.useRef(!1),eP=P(),eT=T({compareFn:em,duration:eo.duration,minFrames:es.autoCaptureMinFrames}),[ej,eA]=e.useState(!1),{sessionId:eV,updateSessionId:eq}=j(),eU=e.useRef(r.createSingleUUID()),{onVideoPlayed:ez,cropArea:eQ,isPlaying:eN}=A({}),{smallScale:eJ,largeScale:eG}=V(ee,{width:ex.width,height:ex.height},{width:eQ.width,height:eQ.height}),eH=1e3*el.total/es.framesIntervalTime,{uuids:eK,getNextUUID:e$,reset:eX}=l({total:Math.min(eg.maxItems,Math.ceil(eH/es.framesBatchLength*1.2))}),eY=e.useCallback(e=>{let t=e[e.length-1];try{let e=JSON.parse(t.metadata);eg.enable&&(e.global_batch_id=e$()),e.global_session_id=eU.current,t.metadata=JSON.stringify(e)}catch(e){console.error("Unable to process last frame metadata",e)}},[eg.enable,e$]),eZ=e.useRef(null),{playVoice:e2}=o.useVoicePlayer(),e0=e.useMemo(()=>R(()=>{if(eI.current=!1,eB.current.frames=[],eB.current.images=[],eZ.current=null,eL(eJ),eC(B.FAR_FACE),e2("move_face_into_frame"),eq(),eT.stopCapturing(),ey(!1),eg.enable){let e=eX();_.addExifData("frame_batch_ids",e)}s()},200,{leading:!0}),[eJ,e2,eq,eT,eg.enable,s,eX]),e1=q({offset:ee.ovalVerticalOffset,ovalPadding:ee.ovalPadding,largeScale:eG,maskHeight:eQ.height,ovalHeight:ex.height}),e8=e.useCallback(async()=>{eC(B.STOP_DECTECTING),eu("selfie_passive_v2","user_activity",()=>({passive_liveness_in_ms:performance.now()-ef.current}));let{frames:e}=eB.current;if(es.enable&&es.framesBatchLength>0){let t=e.length%es.framesBatchLength;if(0!==t){let s=e.slice(-1*t);eY(s),"function"==typeof S&&S(s)}}eB.current.images[e_.farImageOrder].blob=await eB.current.images[e_.farImageOrder].blob,_.addExifData("selfie_type","passive_v2"),_.addExifData("passive_liveness_v2",{number_of_frames:{far_frames:e.length},passive_liveness_in_ms:Math.round(performance.now()-ef.current),face_settings:{max_far_face_ratio:et.maxFarFaceRatio,min_far_face_ratio:et.minFarFaceRatio},mask_settings:{oval_vertical_offset:ee.ovalVerticalOffset,small_scale:ee.smallScale},image_settings:{valid_face_ratio:ei.validFaceRatio}});let t=await _.writeCurrentExif({imageData:eB.current.images[e_.farImageOrder],enableExifData:ea.enable});eB.current.images[e_.farImageOrder].blob=t,eP.enable&&(eB.current.images[e_.farImageOrder].encrypted=await g.encrypt({blob:eB.current.images[e_.farImageOrder].blob,key:eP.key})),eB.current.images=eB.current.images.filter(e=>!!e);try{"function"==typeof a&&await a({images:eB.current.images,frames:eB.current.frames})}catch(e){x({error:e})}},[eu,es.enable,es.framesBatchLength,e_.farImageOrder,et.maxFarFaceRatio,et.minFarFaceRatio,ee.ovalVerticalOffset,ee.smallScale,ei.validFaceRatio,ea.enable,eP.enable,eP.key,eY,S,a,x]),e3=e.useCallback(({prediction:e,canvas:t})=>{if(!es.enable)return;let{frames:s}=eB.current,a=U({prediction:e,canvas:t,index:s.length,quality:es.frameQuality});if(a.metadata=JSON.stringify({type:z.FAR_FACE,time:Math.round(performance.now()),session_id:eV}),s.push(a),es.framesBatchLength<=0||s.length%es.framesBatchLength!=0)return;let i=s.slice(-1*es.framesBatchLength);eY(i),"function"==typeof S&&S(i)},[es.enable,es.frameQuality,es.framesBatchLength,S,eY,eV]),e9=e.useCallback(async()=>{let{frames:e}=eB.current;0===e.length&&(eI.current=!0)},[]),e5=e.useMemo(()=>({x:Math.max(eW?.left,0),y:Math.max(eW?.top,0),width:Math.min(eW?.right-eW?.left,eQ.width),height:Math.min(eW?.bottom-eW?.top,eQ.height)}),[eQ.height,eQ.width,eW?.bottom,eW?.left,eW?.right,eW?.top]),e6=e.useCallback(async({frame:e,prediction:t,canvas:s,originalRatio:a})=>{if("no_face"===e.faceError||eB.current.images[e_.farImageOrder])return;if(es.enable){let e=performance.now();if(null!==eZ.current&&e-eZ.current<es.framesIntervalTime)return;eZ.current=e}let i=e=>{let t=X({maskBoundingBox:e5,faceRatio:e.faceRatio,validFaceRatio:ei.validFaceRatio,video:ew.current,shouldCropCenterSquare:ei.enableCropCenterFar,cropArea:eQ,frame:e.snapshot,facePrediction:e.facePrediction,detectionToWholeFaceRatio:ei.detectionToWholeFaceRatio}),s={blob:k.takePicture({canvas:t,quality:ei.imageQuality}),gesture:"frontal",captureTime:e.captureTime,selfieLabel:z.FAR_FACE,qualifyScore:e.qualifyScore,blurScore:e.blurScore,brightnessScore:e.brightnessScore};_.addExifData("model_score.face_blurry_score",s.blurScore),_.addExifData("model_score.face_brightness_score",s.brightnessScore),_.addExifData("model_score.face_qualify_score",s.qualifyScore),_.addExifData("selfie_label",s.selfieLabel),_.addExifData("capture_time",s.captureTime),_.addExifData("type",s.gesture),eB.current.images[e_.farImageOrder]=s},n={qualifyScore:e.qualifyScore,blurScore:e.blurScore,isEyeClosed:e.isEyeClosed,faceRatio:e.faceRatio,snapshot:Q(ew.current),captureTime:Date.now(),facePrediction:N(t,a),brightnessScore:e.brightnessScore,faceError:e.faceError};if(!eo.enable){e3({prediction:t,canvas:s}),i(n),await e8();return}if(!eT.isAutoCapturing()){await e2("please_hold_still"),ey(!0),e3({prediction:t,canvas:s}),eT.startCapturing({onDone:async e=>{i(e),await e8()},initialFrame:n});return}e3({prediction:t,canvas:s}),eT.captureFrame(n)},[e_.farImageOrder,es.enable,es.framesIntervalTime,eo.enable,eT,e3,e5,ei.validFaceRatio,ei.enableCropCenterFar,ei.detectionToWholeFaceRatio,ei.imageQuality,eQ,e8,e2]),{warmupDone:e4}=J({onError:x,isVideoPlaying:eN,step:eS,cropArea:eQ,videoRef:ew,onFarFaceDetected:e9,onFarFullFaceDetected:e6,onFaceError:e.useCallback(({error:e})=>{ep(e),("no_face"===e||"multiple_faces"===e)&&"no_face"===e&&eI.current&&e0()},[e0,ep]),faceSettings:et,maskBoundingRect:eW,shouldPauseFaceDetection:eR||ej,faceDetectionSettings:E,shouldContinueOnError:ek,debug:ev});G(ew.current);H(()=>{!async function(){let{resourceReport:e,measureReport:t}=await y.reportAll();Object.values(e).forEach(e=>{eu("selfie_passive_v2","sdk.download_model",e)}),Object.values(t).forEach(e=>{eu("selfie_passive_v2","sdk.init_model",e)})}()},e4),H(()=>{eC(B.FAR_FACE),eL(eJ),e2("move_face_into_frame"),eD(!0),eg.enable&&_.addExifData("frame_batch_ids",eK),_.addExifData("global_session_id",eU.current),ef.current||(ef.current=performance.now())},e4&&eN),H(()=>eu("selfie_passive_v2","user_activity.start"),!0),H(()=>eu("selfie_passive_v2","user_activity.start_far"),eS===B.FAR_FACE);let{Loading:e7}=v,te=e.useCallback(()=>{ey(!1),eT.stopCapturing(),eA(!0)},[eT]),tt=e.useCallback(()=>{eA(!1),e0()},[e0]),{remaining:ts}=K({shouldStart:eO&&el.enable,onTimeout:te,onDelayEnd:tt,onError:x,totalTime:el.total,totalDelay:3,maxRetriesSettings:{enable:el.enableMaxRetryCount,total:el.maxRetryCount},interruptible:el.interruptible}),ta=Y(eb),ti=eQ.y+eQ.height/2+e1,tn=eo.duration,tr=Math.max(tn,es.autoCaptureMinFrames*es.framesIntervalTime);return d.jsxs(d.Fragment,{children:[d.jsx(c,{frontCamera:u,onVideoPlayed:ez,onClose:w,flipHorizontal:u,ref:ew,onError:x,videoSettings:ec,closeButton:d.jsx(Z,{}),children:d.jsxs($,{overlay:!e4||!eN,loadingComponent:e7,children:[!ek&&""!==eb&&d.jsx(m,{}),d.jsx(L,{x:`${Math.round(eQ.x)}px`,y:`${Math.round(eQ.y)}px`,width:`${eQ.width}px`,height:`${eQ.height}px`,surroundStyle:{background:n("FlashLiveness.maskFill")({theme:eF})},children:d.jsx(f,{ref:eE,scale:eM,debug:ev,width:eQ.width,height:eQ.height,padding:ee.ovalPadding,verticalOffset:e1,mask:ex})}),!ek&&""!==ta&&d.jsx(O,{errorY:ti,errorMessage:ta})]})}),d.jsx(W,{step:eS,errorCode:eb,timeoutProps:{remaining:ts,warningThreshold:el.countdown,total:el.total,shouldStart:eO&&el.enable},isAutoCapturing:ek,autoCaptureDuration:tr,extraConfig:F})]})}let eu=t=>{let{apiCheck:s,onLivenessDetectionDone:a,frontalMinSize:i,serviceSettings:n,apiCredentials:r,...l}=t,o=l.customComponent?.FlashLivenessLoading??x,[_,g]=e.useState(!1),c=P(),m=el(),f=C.getEnabledServices(n,m),{verifyLiveness:u}=function({outputEncryptionSettings:t,selfieType:s,enabledServices:a,apiCredentials:i}){let{apiClient:n}=S.useApiClient({apiCredentials:i});return{verifyLiveness:e.useCallback(async({videos:e,images:i,metadata:r})=>{try{let l=await Promise.all(i.map(e=>{if(!t.enable)return n.uploadImage({label:"portrait",file:e.blob,metadata:JSON.stringify({label:e.selfieLabel})});let s=new Blob([e.encrypted.hex]);return n.uploadImage({file:s,label:"portrait",metadata:JSON.stringify({label:e.selfieLabel})},{"X-TV-Key":t.key})})),o=null;a.enableVerifyFaceLiveness&&(o=n.verifyFaceLiveness({images:l.map(e=>({id:e?.data?.image_id,label:"portrait"})),videos:e,metadata:r,selfie_type:s}));let _=null;a.enableVerifySanityPortrait&&(_=n.requestVerifyPortrait({image:{id:l[l.length-1]?.data?.image_id},selfie_type:s}));let[g,d]=await Promise.all([o,_]);return{uploadedImages:l,faceLivenessResult:g,portraitResult:d}}catch(e){return console.error(e),{}}},[n,a.enableVerifyFaceLiveness,a.enableVerifySanityPortrait,t.enable,t.key,s])}}({apiCredentials:r,outputEncryptionSettings:c,selfieType:F.Mode.PASSIVE_V2,enabledServices:f}),{captureFrameSettings:v}=ed(),{framesIntervalTime:b}=v,{onFramesCaptured:h,onReset:p}=t,{onErrorCallback:k}=en(),y=Z(),W=async e=>{let t=e;if(c.enable&&(t=await w.encryptFrames(t,c.key)),"function"==typeof h&&h(t),s&&f.enableUploadFrames){let e={};c.enable&&(e["X-TV-Key"]=c.key),ee.uploadFrameBatch(et(t),y,e)}},R=async e=>{let t={frame_interval:b},n=e.images.filter(e=>"frontal"===e.gesture),r=n.map(e=>e.blob),l=n.map(e=>e.encrypted),o=r[r.length-1],_=o&&"number"==typeof i?await E.scaleImage(o,{minsize:i}):null,d=e.frames;if(c.enable&&(d=await w.encryptFrames(d,c.key)),!s||!f.enableUploadImages)return void await a({capturedFrames:d,frontalFaces:r,frontalFacesEncrypted:l,frontalScaledImage:_,steps:[],metadata:t});try{g(!0);let s=null;s=v.enable?await ee.getAllUploadedBatches():[{frames:et(d)}];let{uploadedImages:i,faceLivenessResult:n,portraitResult:o}=await u({videos:s,images:e.images,metadata:t});if(ee.resetUploadBatches(),g(!1),n?.errors)throw n.errors;if(o?.errors)throw o.errors;await a({capturedFrames:d,steps:[],frontalFaces:r.map((e,t)=>({blob:e,id:i?.[t]?.data?.image_id})),frontalFacesEncrypted:l,frontalScaledImage:_,apiCheckPassed:n?.data.is_live??!1,verifyFaceLivenessResult:n?.data??null,verifyPortraitResult:o?.data??null,uploadFramesResult:s})}catch(e){console.error(e),g(!1),k({error:e})}};return d.jsxs(d.Fragment,{children:[d.jsx(ef,{...l,apiCheck:s,onDone:R,onFramesCaptured:W,onReset:()=>{ee.resetUploadBatches(),"function"==typeof p&&p()}}),s&&d.jsx(o,{loading:_})]})},ev=e=>{let{apiCredentials:t,outputEncryptionSettings:s}=e;return d.jsx(O,{version:"v2",unmountOnHidden:!0,children:d.jsx(es,{apiCredentials:t,children:d.jsx(ea,{settings:s,children:d.jsx(eu,{...e})})})})};ev.propTypes={apiCheck:W.bool,apiCredentials:W.shape({accessKey:W.string,secretKey:W.string,apiUrl:W.string}),onReset:W.func,onLivenessDetectionDone:W.func,onClose:W.func,onError:W.func,onFramesCaptured:W.func,frontCamera:W.bool,styledComponent:W.shape({CloseCameraButton:W.node}),outputEncryptionSettings:W.shape({key:W.string}),frontalMinSize:W.number,serviceSettings:W.shape({enableGetClientSettings:W.bool,enableUploadFrames:W.bool,enableUploadImages:W.bool,enableVerifySanityPortrait:W.bool,enableVerifyFaceLiveness:W.bool}),mode:W.string,flowId:W.string,customTexts:W.shape({}),customComponents:W.shape({PassiveLivenessBody:W.elementType}),extraConfig:W.shape({})},ev.defaultProps={apiCheck:!1,apiCredentials:{},onReset:()=>{},onLivenessDetectionDone:()=>{},onClose:()=>{},onError:()=>{},onFramesCaptured:()=>{},frontCamera:!0,styledComponent:{CloseCameraButton:null},outputEncryptionSettings:{key:""},frontalMinSize:null,serviceSettings:{enableGetClientSettings:!0,enableUploadFrames:!0,enableUploadImages:!0,enableVerifySanityPortrait:!0,enableVerifyFaceLiveness:!0},flowId:"",customTexts:{},customComponents:{PassiveLivenessBody:null},extraConfig:null};export{ev as default};
1
+ import{r as e,u as t,k as s,b as a,A as i,m as n,ap as r,aq as l,M as o,O as _,Q as g,j as d,ar as c,as as m,at as f,au as u,av as v,aC as b,aD as h,az as p,G as k,R as y,d as S,f as C,s as F,aA as x,aB as w,Y as E,P as W}from"./chunk-78da2232.js";import{d as R}from"./chunk-df824644.js";import{t as M}from"./chunk-bf5a5b12.js";import{C as L,O as O}from"./chunk-7b011490.js";import{u as D,S as B,a as I,o as P,b as T,c as j,d as A,n as V,l as q,f as U,F as z,e as Q,s as N,g as G,h as J,i as H,j as K,W as $,k as X,m as Y,p as Z,q as ee,r as et,A as es,O as ea}from"./chunk-84c22657.js";import{m as ei,u as en,b as er}from"./chunk-16aae30a.js";import{u as el}from"./chunk-fbbb4c3f.js";let eo=0,e_=1,eg={data:{settings:{sdk_settings:{passive_liveness_v2_settings:{frontal_face_check:{enable:!0,up_down_bound_min:.35,up_down_bound_max:.7},capture_frame_settings:{enable:!1,frames_batch_length:10,frames_interval_time:0,frame_quality:.8,frame_scale:1,auto_capture_min_frames:8,auto_capture_min_frames_far:8,auto_capture_min_frames_close:0},not_qualified_settings:{enable_far:!1,threshold_far:.11},close_eyes_settings:{enable:!1,timeout:5,force_check:!1},face_settings:{chin_height:20,max_far_face_ratio:.9,min_far_face_ratio:.8,mobile:{chin_height:20,max_far_face_ratio:.9,min_far_face_ratio:.85}},timeout_settings:{enable:!0,total:30,countdown:10,max_retry_count:0,non_stoppable:!1},exif_data_settings:{enable:!0},mask_settings:{mobile:{oval_vertical_padding:20,oval_horizontal_padding:20,oval_vertical_offset:60,small_scale:.65},oval_horizontal_padding:20,oval_vertical_padding:20,oval_vertical_offset:0,small_scale:.6},image_settings:{valid_face_ratio:.6,image_quality:1,crop_center_far:!0,crop_center_close:!1,detection_to_whole_face_ratio:.8},blur_far_settings:{enable:!0,blurry_threshold:.4,wait_for_best_image_time_ms:1e3},brightness_detection_far_settings:{enable_too_bright_check:!1,enable_too_dark_check:!1,too_bright_threshold:.83,too_dark_threshold:.195},output_image_settings:{image_ordering:["far","close"]},auto_gen_frame_ids:{enable:!1,max_items:50}}}}}},ed=()=>{let i=el();return e.useMemo(()=>{let e=ei({},eg,i),n={enable:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.capture_frame_settings.enable"),framesIntervalTime:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.capture_frame_settings.frames_interval_time"),framesBatchLength:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.capture_frame_settings.frames_batch_length"),frameScale:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.capture_frame_settings.frame_scale"),frameQuality:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.capture_frame_settings.frame_quality"),autoCaptureMinFrames:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.capture_frame_settings.auto_capture_min_frames"),autoCaptureMinFramesFar:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.capture_frame_settings.auto_capture_min_frames_far"),autoCaptureMinFramesClose:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.capture_frame_settings.auto_capture_min_frames_close")},r={smallScale:t.getWebSetting(e,s.isMobile?"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.mobile.small_scale":"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.small_scale"),largeScale:t.getWebSetting(e,s.isMobile?"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.mobile.small_scale":"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.small_scale"),ovalPadding:{left:t.getWebSetting(e,s.isMobile?"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.mobile.oval_horizontal_padding":"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.oval_horizontal_padding"),right:t.getWebSetting(e,s.isMobile?"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.mobile.oval_horizontal_padding":"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.oval_horizontal_padding"),top:t.getWebSetting(e,s.isMobile?"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.mobile.oval_vertical_padding":"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.oval_vertical_padding"),bottom:t.getWebSetting(e,s.isMobile?"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.mobile.oval_vertical_padding":"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.oval_vertical_padding")},ovalVerticalOffset:t.getWebSetting(e,s.isMobile?"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.mobile.oval_vertical_offset":"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.oval_vertical_offset"),chinToMaskBottomPadding:t.getWebSetting(e,s.isMobile?"data.settings.sdk_settings.passive_liveness_v2_settings.face_settings.mobile.chin_height":"data.settings.sdk_settings.passive_liveness_v2_settings.face_settings.chin_height")},l={minFarFaceRatio:t.getWebSetting(e,s.isMobile?"data.settings.sdk_settings.passive_liveness_v2_settings.face_settings.mobile.min_far_face_ratio":"data.settings.sdk_settings.passive_liveness_v2_settings.face_settings.min_far_face_ratio"),maxFarFaceRatio:t.getWebSetting(e,s.isMobile?"data.settings.sdk_settings.passive_liveness_v2_settings.face_settings.mobile.max_far_face_ratio":"data.settings.sdk_settings.passive_liveness_v2_settings.face_settings.max_far_face_ratio")},o={enable:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.close_eyes_settings.enable"),timeout:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.close_eyes_settings.timeout"),forceCheck:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.close_eyes_settings.force_check")},_={enable:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.exif_data_settings.enable")},g={imageQuality:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.image_settings.image_quality"),validFaceRatio:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.image_settings.valid_face_ratio"),enableCropCenterFar:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.image_settings.crop_center_far"),detectionToWholeFaceRatio:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.image_settings.detection_to_whole_face_ratio")},d=t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.timeout_settings.max_retry_count"),c={enable:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.timeout_settings.enable"),total:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.timeout_settings.total"),countdown:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.timeout_settings.countdown"),enableMaxRetryCount:d>0,maxRetryCount:d,interruptible:!t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.timeout_settings.non_stoppable")},m={enable:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.blur_far_settings.enable"),threshold:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.blur_far_settings.blurry_threshold"),duration:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.blur_far_settings.wait_for_best_image_time_ms")},f={enable:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.not_qualified_settings.enable_far"),threshold:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.not_qualified_settings.threshold_far")},u={enableTooBrightCheck:a(e,"data.settings.sdk_settings.passive_liveness_v2_settings.brightness_detection_far_settings.enable_too_bright_check"),enableTooDarkCheck:a(e,"data.settings.sdk_settings.passive_liveness_v2_settings.brightness_detection_far_settings.enable_too_dark_check"),tooBrightThreshold:a(e,"data.settings.sdk_settings.passive_liveness_v2_settings.brightness_detection_far_settings.too_bright_threshold"),tooDarkThreshold:a(e,"data.settings.sdk_settings.passive_liveness_v2_settings.brightness_detection_far_settings.too_dark_threshold")},v={imageOrdering:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.output_image_settings.image_ordering"),farImageOrder:e_,closeImageOrder:eo};Array.isArray(v.imageOrdering)&&2===v.imageOrdering.length&&"far"===v.imageOrdering[0]&&"close"===v.imageOrdering[1]&&(v.farImageOrder=0,v.closeImageOrder=1);let b={enable:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.auto_gen_frame_ids.enable")&&c.enable,maxItems:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.auto_gen_frame_ids.max_items")};return{captureFrameSettings:n,livenessSettings:{},flashSettings:{},maskSettings:r,faceSettings:l,closeEyesSettings:o,exifSettings:_,imageSettings:g,timeoutSettings:c,blurCheckFarSettings:m,blurCheckCloseSettings:{},notQualifiedFarSettings:f,notQualifiedCloseSettings:{},brightnessDetectionFarSettings:u,brightnessDetectionCloseSettings:{},outputImageSettings:v,autoGenFrameIds:b,frontalFaceCheckSettings:{enable:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.frontal_face_check.enable"),upDownBoundMin:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.frontal_face_check.up_down_bound_min"),upDownBoundMax:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.frontal_face_check.up_down_bound_max")}}},[i])},ec=s.isMobile?{width:{ideal:640},whiteBalanceMode:"none"}:{width:{ideal:9999},whiteBalanceMode:"none"},em=(e,t)=>""===t.faceError&&(!!e.isEyeClosed&&!t.isEyeClosed||(!!e.isEyeClosed||!t.isEyeClosed)&&(!!u.hasBetterBrightnessScore(t.brightnessScore,e.brightnessScore)||!!u.hasSameBrightnessScore(t.brightnessScore,e.brightnessScore)&&v.hasBetterBlurScore(t.blurScore,e.blurScore)));function ef(t){let{onReset:s,onDone:a,frontCamera:u,styledComponent:v,onFramesCaptured:S,customComponent:C,extraConfig:F}=t,{onErrorCallback:x,onCloseCallback:w}=en(),E=ed(),W=C?.PassiveLivenessBody??b,O=C?.PassiveLivenessError??h,Z=C?.PassiveLivenessCloseIcon??p,{maskSettings:ee,faceSettings:et,captureFrameSettings:es,exifSettings:ea,imageSettings:ei,timeoutSettings:el,blurCheckFarSettings:eo,outputImageSettings:e_,autoGenFrameIds:eg}=E,ef=e.useRef(),eu=D(),ev=er(),[eb,eh]=e.useState(""),ep=e.useMemo(()=>M(eh,1e3),[]),[ek,ey]=e.useState(!1),[eS,eC]=e.useState(B.LOADING),eF=i(),ex={width:n("FlashLiveness.mask.width")({theme:eF}),height:n("FlashLiveness.mask.height")({theme:eF}),strokeColor:(eS===B.FAR_FACE||eS===B.CLOSE_FACE)&&eb&&!ek?n("FlashLiveness.mask.strokeColorError")({theme:eF}):n("FlashLiveness.mask.strokeColor")({theme:eF}),strokeWidth:2*n("FlashLiveness.mask.strokeWidth")({theme:eF}),path:n("FlashLiveness.mask.path")({theme:eF}),backgroundColor:n("FlashLiveness.maskFill")({theme:eF})},ew=e.useRef(null),[eE,eW,eR]=I(),[eM,eL]=e.useState(0),[eO,eD]=e.useState(!1),eB=e.useRef({frames:[],images:[]}),eI=e.useRef(!1),eP=P(),eT=T({compareFn:em,duration:eo.duration,minFrames:es.autoCaptureMinFrames}),[ej,eA]=e.useState(!1),{sessionId:eV,updateSessionId:eq}=j(),eU=e.useRef(r.createSingleUUID()),{onVideoPlayed:ez,cropArea:eQ,isPlaying:eN}=A({}),{smallScale:eG,largeScale:eJ}=V(ee,{width:ex.width,height:ex.height},{width:eQ.width,height:eQ.height}),eH=1e3*el.total/es.framesIntervalTime,{uuids:eK,getNextUUID:e$,reset:eX}=l({total:Math.min(eg.maxItems,Math.ceil(eH/es.framesBatchLength*1.2))}),eY=e.useCallback(e=>{let t=e[e.length-1];try{let e=JSON.parse(t.metadata);eg.enable&&(e.global_batch_id=e$()),e.global_session_id=eU.current,t.metadata=JSON.stringify(e)}catch(e){console.error("Unable to process last frame metadata",e)}},[eg.enable,e$]),eZ=e.useRef(null),{playVoice:e2}=o.useVoicePlayer(),e0=e.useMemo(()=>R(()=>{if(eI.current=!1,eB.current.frames=[],eB.current.images=[],eZ.current=null,eL(eG),eC(B.FAR_FACE),e2("move_face_into_frame"),eq(),eT.stopCapturing(),ey(!1),eg.enable){let e=eX();_.addExifData("frame_batch_ids",e)}s()},200,{leading:!0}),[eG,e2,eq,eT,eg.enable,s,eX]),e1=q({offset:ee.ovalVerticalOffset,ovalPadding:ee.ovalPadding,largeScale:eJ,maskHeight:eQ.height,ovalHeight:ex.height}),e8=e.useCallback(async()=>{eC(B.STOP_DECTECTING),eu("selfie_passive_v2","user_activity",()=>({passive_liveness_in_ms:performance.now()-ef.current}));let{frames:e}=eB.current;if(es.enable&&es.framesBatchLength>0){let t=e.length%es.framesBatchLength;if(0!==t){let s=e.slice(-1*t);eY(s),"function"==typeof S&&S(s)}}eB.current.images[e_.farImageOrder].blob=await eB.current.images[e_.farImageOrder].blob,_.addExifData("selfie_type","passive_v2"),_.addExifData("passive_liveness_v2",{number_of_frames:{far_frames:e.length},passive_liveness_in_ms:Math.round(performance.now()-ef.current),face_settings:{max_far_face_ratio:et.maxFarFaceRatio,min_far_face_ratio:et.minFarFaceRatio},mask_settings:{oval_vertical_offset:ee.ovalVerticalOffset,small_scale:ee.smallScale},image_settings:{valid_face_ratio:ei.validFaceRatio}});let t=await _.writeCurrentExif({imageData:eB.current.images[e_.farImageOrder],enableExifData:ea.enable});eB.current.images[e_.farImageOrder].blob=t,eP.enable&&(eB.current.images[e_.farImageOrder].encrypted=await g.encrypt({blob:eB.current.images[e_.farImageOrder].blob,key:eP.key})),eB.current.images=eB.current.images.filter(e=>!!e);try{"function"==typeof a&&await a({images:eB.current.images,frames:eB.current.frames})}catch(e){x({error:e})}},[eu,es.enable,es.framesBatchLength,e_.farImageOrder,et.maxFarFaceRatio,et.minFarFaceRatio,ee.ovalVerticalOffset,ee.smallScale,ei.validFaceRatio,ea.enable,eP.enable,eP.key,eY,S,a,x]),e3=e.useCallback(({prediction:e,canvas:t})=>{if(!es.enable)return;let{frames:s}=eB.current,a=U({prediction:e,canvas:t,index:s.length,quality:es.frameQuality});if(a.metadata=JSON.stringify({type:z.FAR_FACE,time:Math.round(performance.now()),session_id:eV}),s.push(a),es.framesBatchLength<=0||s.length%es.framesBatchLength!=0)return;let i=s.slice(-1*es.framesBatchLength);eY(i),"function"==typeof S&&S(i)},[es.enable,es.frameQuality,es.framesBatchLength,S,eY,eV]),e9=e.useCallback(async()=>{let{frames:e}=eB.current;0===e.length&&(eI.current=!0)},[]),e5=e.useMemo(()=>({x:Math.max(eW?.left,0),y:Math.max(eW?.top,0),width:Math.min(eW?.right-eW?.left,eQ.width),height:Math.min(eW?.bottom-eW?.top,eQ.height)}),[eQ.height,eQ.width,eW?.bottom,eW?.left,eW?.right,eW?.top]),e6=e.useCallback(async({frame:e,prediction:t,canvas:s,originalRatio:a})=>{if("no_face"===e.faceError||eB.current.images[e_.farImageOrder])return;if(es.enable){let e=performance.now();if(null!==eZ.current&&e-eZ.current<es.framesIntervalTime)return;eZ.current=e}let i=e=>{let t=X({maskBoundingBox:e5,faceRatio:e.faceRatio,validFaceRatio:ei.validFaceRatio,video:ew.current,shouldCropCenterSquare:ei.enableCropCenterFar,cropArea:eQ,frame:e.snapshot,facePrediction:e.facePrediction,detectionToWholeFaceRatio:ei.detectionToWholeFaceRatio}),s={blob:k.takePicture({canvas:t,quality:ei.imageQuality}),gesture:"frontal",captureTime:e.captureTime,selfieLabel:z.FAR_FACE,qualifyScore:e.qualifyScore,blurScore:e.blurScore,brightnessScore:e.brightnessScore};_.addExifData("model_score.face_blurry_score",s.blurScore),_.addExifData("model_score.face_brightness_score",s.brightnessScore),_.addExifData("model_score.face_qualify_score",s.qualifyScore),_.addExifData("selfie_label",s.selfieLabel),_.addExifData("capture_time",s.captureTime),_.addExifData("type",s.gesture),eB.current.images[e_.farImageOrder]=s},n={qualifyScore:e.qualifyScore,blurScore:e.blurScore,isEyeClosed:e.isEyeClosed,faceRatio:e.faceRatio,snapshot:Q(ew.current),captureTime:Date.now(),facePrediction:N(t,a),brightnessScore:e.brightnessScore,faceError:e.faceError};if(!eo.enable){e3({prediction:t,canvas:s}),i(n),await e8();return}if(!eT.isAutoCapturing()){await e2("please_hold_still"),ey(!0),e3({prediction:t,canvas:s}),eT.startCapturing({onDone:async e=>{i(e),await e8()},initialFrame:n});return}e3({prediction:t,canvas:s}),eT.captureFrame(n)},[e_.farImageOrder,es.enable,es.framesIntervalTime,eo.enable,eT,e3,e5,ei.validFaceRatio,ei.enableCropCenterFar,ei.detectionToWholeFaceRatio,ei.imageQuality,eQ,e8,e2]),{warmupDone:e4}=G({onError:x,isVideoPlaying:eN,step:eS,cropArea:eQ,videoRef:ew,onFarFaceDetected:e9,onFarFullFaceDetected:e6,onFaceError:e.useCallback(({error:e})=>{ep(e),("no_face"===e||"multiple_faces"===e)&&"no_face"===e&&eI.current&&e0()},[e0,ep]),faceSettings:et,maskBoundingRect:eW,shouldPauseFaceDetection:eR||ej,faceDetectionSettings:E,shouldContinueOnError:ek,debug:ev});J(ew.current);H(()=>{!async function(){let{resourceReport:e,measureReport:t}=await y.reportAll();Object.values(e).forEach(e=>{eu("selfie_passive_v2","sdk.download_model",e)}),Object.values(t).forEach(e=>{eu("selfie_passive_v2","sdk.init_model",e)})}()},e4),H(()=>{eC(B.FAR_FACE),eL(eG),e2("move_face_into_frame"),eD(!0),eg.enable&&_.addExifData("frame_batch_ids",eK),_.addExifData("global_session_id",eU.current),ef.current||(ef.current=performance.now())},e4&&eN),H(()=>eu("selfie_passive_v2","user_activity.start"),!0),H(()=>eu("selfie_passive_v2","user_activity.start_far"),eS===B.FAR_FACE);let{Loading:e7}=v,te=e.useCallback(()=>{ey(!1),eT.stopCapturing(),eA(!0)},[eT]),tt=e.useCallback(()=>{eA(!1),e0()},[e0]),{remaining:ts}=K({shouldStart:eO&&el.enable,onTimeout:te,onDelayEnd:tt,onError:x,totalTime:el.total,totalDelay:3,maxRetriesSettings:{enable:el.enableMaxRetryCount,total:el.maxRetryCount},interruptible:el.interruptible}),ta=Y(eb),ti=eQ.y+eQ.height/2+e1,tn=eo.duration,tr=Math.max(tn,es.autoCaptureMinFrames*es.framesIntervalTime);return d.jsxs(d.Fragment,{children:[d.jsx(c,{frontCamera:u,onVideoPlayed:ez,onClose:w,flipHorizontal:u,ref:ew,onError:x,videoSettings:ec,closeButton:d.jsx(Z,{}),children:d.jsxs($,{overlay:!e4||!eN,loadingComponent:e7,children:[!ek&&""!==eb&&d.jsx(m,{}),d.jsx(L,{x:`${Math.round(eQ.x)}px`,y:`${Math.round(eQ.y)}px`,width:`${eQ.width}px`,height:`${eQ.height}px`,surroundStyle:{background:n("FlashLiveness.maskFill")({theme:eF})},children:d.jsx(f,{ref:eE,scale:eM,debug:ev,width:eQ.width,height:eQ.height,padding:ee.ovalPadding,verticalOffset:e1,mask:ex})}),!ek&&""!==ta&&d.jsx(O,{errorY:ti,errorMessage:ta})]})}),d.jsx(W,{step:eS,errorCode:eb,timeoutProps:{remaining:ts,warningThreshold:el.countdown,total:el.total,shouldStart:eO&&el.enable},isAutoCapturing:ek,autoCaptureDuration:tr,extraConfig:F})]})}let eu=t=>{let{apiCheck:s,onLivenessDetectionDone:a,frontalMinSize:i,serviceSettings:n,apiCredentials:r,...l}=t,o=l.customComponent?.FlashLivenessLoading??x,[_,g]=e.useState(!1),c=P(),m=el(),f=C.getEnabledServices(n,m),{verifyLiveness:u}=function({outputEncryptionSettings:t,selfieType:s,enabledServices:a,apiCredentials:i}){let{apiClient:n}=S.useApiClient({apiCredentials:i});return{verifyLiveness:e.useCallback(async({videos:e,images:i,metadata:r})=>{try{let l=await Promise.all(i.map(e=>{if(!t.enable)return n.uploadImage({label:"portrait",file:e.blob,metadata:JSON.stringify({label:e.selfieLabel})});let s=new Blob([e.encrypted.hex]);return n.uploadImage({file:s,label:"portrait",metadata:JSON.stringify({label:e.selfieLabel})},{"X-TV-Key":t.key})})),o=null;a.enableVerifyFaceLiveness&&(o=n.verifyFaceLiveness({images:l.map(e=>({id:e?.data?.image_id,label:"portrait"})),videos:e,metadata:r,selfie_type:s}));let _=null;a.enableVerifySanityPortrait&&(_=n.requestVerifyPortrait({image:{id:l[l.length-1]?.data?.image_id},selfie_type:s}));let[g,d]=await Promise.all([o,_]);return{uploadedImages:l,faceLivenessResult:g,portraitResult:d}}catch(e){return console.error(e),{}}},[n,a.enableVerifyFaceLiveness,a.enableVerifySanityPortrait,t.enable,t.key,s])}}({apiCredentials:r,outputEncryptionSettings:c,selfieType:F.Mode.PASSIVE_V2,enabledServices:f}),{captureFrameSettings:v}=ed(),{framesIntervalTime:b}=v,{onFramesCaptured:h,onReset:p}=t,{onErrorCallback:k}=en(),y=Z(),W=async e=>{let t=e;if(c.enable&&(t=await w.encryptFrames(t,c.key)),"function"==typeof h&&h(t),s&&f.enableUploadFrames){let e={};c.enable&&(e["X-TV-Key"]=c.key),ee.uploadFrameBatch(et(t),y,e)}},R=async e=>{let t={frame_interval:b},n=e.images.filter(e=>"frontal"===e.gesture),r=n.map(e=>e.blob),l=n.map(e=>e.encrypted),o=r[r.length-1],_=o&&"number"==typeof i?await E.scaleImage(o,{minsize:i}):null,d=e.frames;if(c.enable&&(d=await w.encryptFrames(d,c.key)),!s||!f.enableUploadImages)return void await a({capturedFrames:d,frontalFaces:r,frontalFacesEncrypted:l,frontalScaledImage:_,steps:[],metadata:t});try{g(!0);let s=null;s=v.enable?await ee.getAllUploadedBatches():[{frames:et(d)}];let{uploadedImages:i,faceLivenessResult:n,portraitResult:o}=await u({videos:s,images:e.images,metadata:t});if(ee.resetUploadBatches(),g(!1),n?.errors)throw n.errors;if(o?.errors)throw o.errors;await a({capturedFrames:d,steps:[],frontalFaces:r.map((e,t)=>({blob:e,id:i?.[t]?.data?.image_id})),frontalFacesEncrypted:l,frontalScaledImage:_,apiCheckPassed:n?.data.is_live??!1,verifyFaceLivenessResult:n?.data??null,verifyPortraitResult:o?.data??null,uploadFramesResult:s})}catch(e){console.error(e),g(!1),k({error:e})}};return d.jsxs(d.Fragment,{children:[d.jsx(ef,{...l,apiCheck:s,onDone:R,onFramesCaptured:W,onReset:()=>{ee.resetUploadBatches(),"function"==typeof p&&p()}}),s&&d.jsx(o,{loading:_})]})},ev=e=>{let{apiCredentials:t,outputEncryptionSettings:s}=e;return d.jsx(O,{version:"v2",unmountOnHidden:!0,children:d.jsx(es,{apiCredentials:t,children:d.jsx(ea,{settings:s,children:d.jsx(eu,{...e})})})})};ev.propTypes={apiCheck:W.bool,apiCredentials:W.shape({accessKey:W.string,secretKey:W.string,apiUrl:W.string}),onReset:W.func,onLivenessDetectionDone:W.func,onClose:W.func,onError:W.func,onFramesCaptured:W.func,frontCamera:W.bool,styledComponent:W.shape({CloseCameraButton:W.node}),outputEncryptionSettings:W.shape({key:W.string}),frontalMinSize:W.number,serviceSettings:W.shape({enableGetClientSettings:W.bool,enableUploadFrames:W.bool,enableUploadImages:W.bool,enableVerifySanityPortrait:W.bool,enableVerifyFaceLiveness:W.bool}),mode:W.string,flowId:W.string,customTexts:W.shape({}),customComponents:W.shape({PassiveLivenessBody:W.elementType}),extraConfig:W.shape({})},ev.defaultProps={apiCheck:!1,apiCredentials:{},onReset:()=>{},onLivenessDetectionDone:()=>{},onClose:()=>{},onError:()=>{},onFramesCaptured:()=>{},frontCamera:!0,styledComponent:{CloseCameraButton:null},outputEncryptionSettings:{key:""},frontalMinSize:null,serviceSettings:{enableGetClientSettings:!0,enableUploadFrames:!0,enableUploadImages:!0,enableVerifySanityPortrait:!0,enableVerifyFaceLiveness:!0},flowId:"",customTexts:{},customComponents:{PassiveLivenessBody:null},extraConfig:null};export{ev as default};
@@ -1,4 +1,4 @@
1
- import{aM as e,z as i,aN as r,aO as t,aP as s,m as o,b as n,r as a,K as l,P as d,D as c,s as g,X as h,j as f,i as u,y as p,B as m,k as w,aQ as k}from"./chunk-ed832fec.js";var b=Object.freeze({__proto__:null,blink:e,flipY:i,slide:r,spin:t,splash:s});let R=({curStep:e,faceDirection:i})=>{let r=n(e,"stepTimeConstraints.delayTime");return!!r&&(null===e.firstFrameSpottedAt?(e.name===i&&(e.firstFrameSpottedAt=new Date().getTime()),!0):!!(new Date().getTime()-e.firstFrameSpottedAt<r)||!1)},S=(e,i)=>({radius:e.radius??o("Selfie.progressCircle.radius")({theme:i}),strokeWidth:e.strokeWidth??o("Selfie.progressCircle.strokeWidth")({theme:i}),progress:e.progress??o("Selfie.progressCircle.progress")({theme:i}),showErrorRing:e.showErrorRing??o("Selfie.progressCircle.showErrorRing")({theme:i}),activeColor:e.activeColor??o("Selfie.progressCircle.activeColor")({theme:i}),innerPadding:e.innerPadding??o("Selfie.progressCircle.innerPadding")({theme:i}),outsideRingColor:e.outsideRingColor??o("Selfie.progressCircle.outsideRingColor")({theme:i}),outsideRingOpacity:e.outsideRingOpacity??o("Selfie.progressCircle.outsideRingOpacity")({theme:i}),insideRingColor:e.insideRingColor??o("Selfie.progressCircle.insideRingColor")({theme:i}),insideRingWidth:e.insideRingWidth??o("Selfie.progressCircle.insideRingWidth")({theme:i}),insideRingStrokeDash:e.insideRingStrokeDash??o("Selfie.progressCircle.insideRingStrokeDash")({theme:i}),errorRingWidth:e.errorRingWidth??o("Selfie.progressCircle.errorRingWidth")({theme:i}),errorRingColor:e.errorRingColor??o("Selfie.progressCircle.errorRingColor")({theme:i}),dashedRingColor:e.dashedRingColor??o("Selfie.progressCircle.dashedRingColor")({theme:i}),dashedRingOpacity:e.dashedRingOpacity??o("Selfie.progressCircle.dashedRingOpacity")({theme:i}),dashedRingWidth:e.dashedRingWidth??o("Selfie.progressCircle.dashedRingWidth")({theme:i}),dashedRingLineThick:e.dashedRingLineThick??o("Selfie.progressCircle.dashedRingLineThick")({theme:i}),dashedRingLineSpacing:e.dashedRingLineSpacing??o("Selfie.progressCircle.dashedRingLineSpacing")({theme:i}),dashedInsideRingColor:e.dashedInsideRingColor??o("Selfie.progressCircle.dashedInsideRingColor")({theme:i}),dashedInsideRingWidth:e.dashedInsideRingWidth??o("Selfie.progressCircle.dashedInsideRingWidth")({theme:i}),showOutsideRing:e.showOutsideRing??o("Selfie.progressCircle.showOutsideRing")({theme:i}),showInsideRing:e.showInsideRing??o("Selfie.progressCircle.showInsideRing")({theme:i}),showDashedRing:e.showDashedRing??o("Selfie.progressCircle.showDashedRing")({theme:i})}),_=(e,i)=>({radius:e.radius??o("Selfie.progressCircleV2.radius")({theme:i}),strokeWidth:e.strokeWidth??o("Selfie.progressCircleV2.strokeWidth")({theme:i}),progress:e.progress??o("Selfie.progressCircleV2.progress")({theme:i}),activeColor:e.activeColor??o("Selfie.progressCircleV2.activeColor")({theme:i}),neutralColor:e.neutralColor??o("Selfie.progressCircleV2.neutralColor")({theme:i}),errorColor:e.errorColor??o("Selfie.progressCircleV2.errorColor")({theme:i}),tickWidth:e.tickWidth??o("Selfie.progressCircleV2.tickWidth")({theme:i}),numberOfTicks:e.numberOfTicks??o("Selfie.progressCircleV2.numberOfTicks")({theme:i})}),y=({incomingFrame:e,currentBestFrame:i})=>e?.isEyeClosed&&!i?.isEyeClosed?i:!e?.isEyeClosed&&i?.isEyeClosed?e:e?.blurScore>i?.blurScore?e:i;function C(e){return new Promise(i=>{let r=new Image;r.onload=i,r.onerror=i,r.src=e})}let x=[],v=()=>{x=[]},$=(e,i,r,t)=>{t&&v(),x.push({id:null});let s=x.length-1;if(e&&e.key){let t=new Blob([JSON.stringify(i)]);r.uploadFile({file:t,metadata:JSON.stringify({type:"selfie"}),label:"video"},{"X-TV-Key":e.key}).then(e=>{e&&e.data&&e.data.file_id?x[s].id=e.data.file_id:x[s].id=-1})}else{let e=new Blob([JSON.stringify(i)]);r.uploadFile({file:e,metadata:JSON.stringify({type:"selfie"}),label:"video"}).then(e=>{e&&e.data&&e.data.file_id?x[s].id=e.data.file_id:x[s].id=-1})}},W=()=>new Promise(e=>{let i=setInterval(()=>{x.every(e=>e.id)&&(e(),clearInterval(i))},200)}),j=e=>e.enable?x.some(e=>-1===e.id)?null:x:[],I=[],O=null,D=!1,A=()=>I,T=()=>{D=!0,I=[];try{O instanceof MediaStream&&(O.getTracks().forEach(e=>e.stop()),O=null)}catch(e){}};async function E({outputImagesSize:e,videoEl:i,resultAnalyzeVideoAndWindowSizes:r}){let t;T();let s=document.createElement("canvas");s.width=e,s.height=e;let o=s.getContext("2d");try{let n={mimeType:"video/webm"};try{let e=(O=i?.captureStream()?.clone()).getVideoTracks()[0];await e.applyConstraints({width:{min:360,ideal:400},height:{min:360,ideal:400}})}catch(e){}MediaRecorder.isTypeSupported("video/mp4")&&(D=!1,!function e(i,r,t,s){if(!i||!s)return;let{cropX:o,cropY:n,cropWidth:a,cropHeight:l}=s;i.drawImage(r,o,n,a,l,0,0,t,t),D||requestAnimationFrame(()=>e(i,r,t,s))}(o,i,e,r),O=s.captureStream(25),n={mimeType:"video/mp4",videoBitsPerSecond:25e5}),t=new MediaRecorder(O,n);let a=async()=>{await new Promise((e,i)=>{t.ondataavailable=r=>(function(e,i,r){if(e.data.size>0){let r=new Blob([e.data],{type:"video/mp4"});I.push(r),i()}else console.error("No video have recored!"),r()})(r,e,i),"inactive"!==t.state&&t.stop()})};t.stopVideoRecording=a,t.discardRecording=()=>{"inactive"!==t.state&&t.stop()}}catch(e){}return{mediaRecorder:t}}let P={data:{settings:{sdk_settings:{passive_liveness_settings:{auto_capture:{enable:!0,show_capture_button:!0,show_countdown:!0,wait_for_best_image_time_ms_web:3e3},manual_capture:{show_countdown:!0,wait_for_best_image_time_ms_web:3e3},blur_check:{enable:!0,web_blurry_threshold:.4},close_eye_detector:{enable:!0,web_threshold:.342,web_timeout:5,force_check:!1},web_is_required_frontal_face:!0},active_liveness_settings:{reset_flow_on_orientation_change:!0,wait_before_start_flow_ms:2e3,face_tracking_setting:{enable:!1,web_terminate_threshold:.0030152991993743408,web_warning_threshold:.0017317430600108828,limit_for:"all_flow",max_warning_time:5},flow_interval_time_ms:3e3,take_one_picture_time_ms:3e3,limit_time_liveness_check:{enable:!1,limit_time_second:45,remain_time_show:10,format:"s",max_retry_count:0,non_stoppable:!1},terminate_if_no_face:{enable:!1,max_invalid_frame:5,max_time_ms:1e3},close_eye_detector:{enable:!0,web_threshold:.342,web_timeout:5,force_check:!1},exif_data_settings:{enable:!0},record_video:{enable:!1},save_encoded_frames:{enable:!1,enable_logging:!1,frames_batch_len:0,frames_interval_ms:180,quality_android:90,quality_ios:80},auto_gen_frame_ids:{enable:!1,max_items:50}}}}}},V=30,L=e=>{let{shouldStart:i,totalTime:r,totalDelayBetweenReset:t,interruptible:s=!0,onReset:o,onTick:n,onTimesUp:d}=e,c=a.useRef(new l({totalTime:r,totalDelayBetweenReset:t,interruptible:s}));return a.useEffect(()=>c.current.on("tick",({remainTime:e})=>{n({remainTime:e})}),[n]),a.useEffect(()=>c.current.on("delaystart",()=>{d()}),[d]),a.useEffect(()=>c.current.on("reset",({attemptCount:e,fromBackground:i})=>{o({attemptCount:e,fromBackground:i})}),[o]),a.useEffect(()=>i?c.current.start():()=>{},[i]),{stopTimer:a.useCallback(()=>{c.current.stop()},[])}},{ErrorDuration:z}=g;function M({children:e,errorMsg:i,className:r}){return h.isValidElement(e)?i?f.jsx("div",{className:r,children:h.cloneElement(e,{errorMsg:i})}):null:i?f.jsx("div",{className:r,children:i}):null}function B({children:e,className:i,error:r}){let t=a.useRef(0),s=a.useRef(""),o=c(),n=a.useRef(z.SHORT),{code:l,duration:d=z.SHORT}=r||{},g=o(l);return Date.now()-t.current>=n.current?(t.current=Date.now(),n.current=d,s.current=g,M({children:e,errorMsg:g,className:i})):M({children:e,errorMsg:s.current,className:i})}B.propTypes={children:d.node,className:d.string},B.defaultProps={className:""};let N=u.g`
1
+ import{aM as e,z as i,aN as r,aO as t,aP as s,m as o,b as n,r as a,K as l,P as d,D as c,s as g,X as h,j as f,i as u,y as p,B as m,k as w,aQ as k}from"./chunk-78da2232.js";var b=Object.freeze({__proto__:null,blink:e,flipY:i,slide:r,spin:t,splash:s});let R=({curStep:e,faceDirection:i})=>{let r=n(e,"stepTimeConstraints.delayTime");return!!r&&(null===e.firstFrameSpottedAt?(e.name===i&&(e.firstFrameSpottedAt=new Date().getTime()),!0):!!(new Date().getTime()-e.firstFrameSpottedAt<r)||!1)},S=(e,i)=>({radius:e.radius??o("Selfie.progressCircle.radius")({theme:i}),strokeWidth:e.strokeWidth??o("Selfie.progressCircle.strokeWidth")({theme:i}),progress:e.progress??o("Selfie.progressCircle.progress")({theme:i}),showErrorRing:e.showErrorRing??o("Selfie.progressCircle.showErrorRing")({theme:i}),activeColor:e.activeColor??o("Selfie.progressCircle.activeColor")({theme:i}),innerPadding:e.innerPadding??o("Selfie.progressCircle.innerPadding")({theme:i}),outsideRingColor:e.outsideRingColor??o("Selfie.progressCircle.outsideRingColor")({theme:i}),outsideRingOpacity:e.outsideRingOpacity??o("Selfie.progressCircle.outsideRingOpacity")({theme:i}),insideRingColor:e.insideRingColor??o("Selfie.progressCircle.insideRingColor")({theme:i}),insideRingWidth:e.insideRingWidth??o("Selfie.progressCircle.insideRingWidth")({theme:i}),insideRingStrokeDash:e.insideRingStrokeDash??o("Selfie.progressCircle.insideRingStrokeDash")({theme:i}),errorRingWidth:e.errorRingWidth??o("Selfie.progressCircle.errorRingWidth")({theme:i}),errorRingColor:e.errorRingColor??o("Selfie.progressCircle.errorRingColor")({theme:i}),dashedRingColor:e.dashedRingColor??o("Selfie.progressCircle.dashedRingColor")({theme:i}),dashedRingOpacity:e.dashedRingOpacity??o("Selfie.progressCircle.dashedRingOpacity")({theme:i}),dashedRingWidth:e.dashedRingWidth??o("Selfie.progressCircle.dashedRingWidth")({theme:i}),dashedRingLineThick:e.dashedRingLineThick??o("Selfie.progressCircle.dashedRingLineThick")({theme:i}),dashedRingLineSpacing:e.dashedRingLineSpacing??o("Selfie.progressCircle.dashedRingLineSpacing")({theme:i}),dashedInsideRingColor:e.dashedInsideRingColor??o("Selfie.progressCircle.dashedInsideRingColor")({theme:i}),dashedInsideRingWidth:e.dashedInsideRingWidth??o("Selfie.progressCircle.dashedInsideRingWidth")({theme:i}),showOutsideRing:e.showOutsideRing??o("Selfie.progressCircle.showOutsideRing")({theme:i}),showInsideRing:e.showInsideRing??o("Selfie.progressCircle.showInsideRing")({theme:i}),showDashedRing:e.showDashedRing??o("Selfie.progressCircle.showDashedRing")({theme:i})}),_=(e,i)=>({radius:e.radius??o("Selfie.progressCircleV2.radius")({theme:i}),strokeWidth:e.strokeWidth??o("Selfie.progressCircleV2.strokeWidth")({theme:i}),progress:e.progress??o("Selfie.progressCircleV2.progress")({theme:i}),activeColor:e.activeColor??o("Selfie.progressCircleV2.activeColor")({theme:i}),neutralColor:e.neutralColor??o("Selfie.progressCircleV2.neutralColor")({theme:i}),errorColor:e.errorColor??o("Selfie.progressCircleV2.errorColor")({theme:i}),tickWidth:e.tickWidth??o("Selfie.progressCircleV2.tickWidth")({theme:i}),numberOfTicks:e.numberOfTicks??o("Selfie.progressCircleV2.numberOfTicks")({theme:i})}),y=({incomingFrame:e,currentBestFrame:i})=>e?.isEyeClosed&&!i?.isEyeClosed?i:!e?.isEyeClosed&&i?.isEyeClosed?e:e?.blurScore>i?.blurScore?e:i;function C(e){return new Promise(i=>{let r=new Image;r.onload=i,r.onerror=i,r.src=e})}let x=[],v=()=>{x=[]},$=(e,i,r,t)=>{t&&v(),x.push({id:null});let s=x.length-1;if(e&&e.key){let t=new Blob([JSON.stringify(i)]);r.uploadFile({file:t,metadata:JSON.stringify({type:"selfie"}),label:"video"},{"X-TV-Key":e.key}).then(e=>{e&&e.data&&e.data.file_id?x[s].id=e.data.file_id:x[s].id=-1})}else{let e=new Blob([JSON.stringify(i)]);r.uploadFile({file:e,metadata:JSON.stringify({type:"selfie"}),label:"video"}).then(e=>{e&&e.data&&e.data.file_id?x[s].id=e.data.file_id:x[s].id=-1})}},W=()=>new Promise(e=>{let i=setInterval(()=>{x.every(e=>e.id)&&(e(),clearInterval(i))},200)}),j=e=>e.enable?x.some(e=>-1===e.id)?null:x:[],I=[],O=null,D=!1,A=()=>I,T=()=>{D=!0,I=[];try{O instanceof MediaStream&&(O.getTracks().forEach(e=>e.stop()),O=null)}catch(e){}};async function E({outputImagesSize:e,videoEl:i,resultAnalyzeVideoAndWindowSizes:r}){let t;T();let s=document.createElement("canvas");s.width=e,s.height=e;let o=s.getContext("2d");try{let n={mimeType:"video/webm"};try{let e=(O=i?.captureStream()?.clone()).getVideoTracks()[0];await e.applyConstraints({width:{min:360,ideal:400},height:{min:360,ideal:400}})}catch(e){}MediaRecorder.isTypeSupported("video/mp4")&&(D=!1,!function e(i,r,t,s){if(!i||!s)return;let{cropX:o,cropY:n,cropWidth:a,cropHeight:l}=s;i.drawImage(r,o,n,a,l,0,0,t,t),D||requestAnimationFrame(()=>e(i,r,t,s))}(o,i,e,r),O=s.captureStream(25),n={mimeType:"video/mp4",videoBitsPerSecond:25e5}),t=new MediaRecorder(O,n);let a=async()=>{await new Promise((e,i)=>{t.ondataavailable=r=>(function(e,i,r){if(e.data.size>0){let r=new Blob([e.data],{type:"video/mp4"});I.push(r),i()}else console.error("No video have recored!"),r()})(r,e,i),"inactive"!==t.state&&t.stop()})};t.stopVideoRecording=a,t.discardRecording=()=>{"inactive"!==t.state&&t.stop()}}catch(e){}return{mediaRecorder:t}}let P={data:{settings:{sdk_settings:{passive_liveness_settings:{auto_capture:{enable:!0,show_capture_button:!0,show_countdown:!0,wait_for_best_image_time_ms_web:3e3},manual_capture:{show_countdown:!0,wait_for_best_image_time_ms_web:3e3},blur_check:{enable:!0,web_blurry_threshold:.4},close_eye_detector:{enable:!0,web_threshold:.342,web_timeout:5,force_check:!1},web_is_required_frontal_face:!0},active_liveness_settings:{reset_flow_on_orientation_change:!0,wait_before_start_flow_ms:2e3,face_tracking_setting:{enable:!1,web_terminate_threshold:.0030152991993743408,web_warning_threshold:.0017317430600108828,limit_for:"all_flow",max_warning_time:5},flow_interval_time_ms:3e3,take_one_picture_time_ms:3e3,limit_time_liveness_check:{enable:!1,limit_time_second:45,remain_time_show:10,format:"s",max_retry_count:0,non_stoppable:!1},terminate_if_no_face:{enable:!1,max_invalid_frame:5,max_time_ms:1e3},close_eye_detector:{enable:!0,web_threshold:.342,web_timeout:5,force_check:!1},exif_data_settings:{enable:!0},record_video:{enable:!1},save_encoded_frames:{enable:!1,enable_logging:!1,frames_batch_len:0,frames_interval_ms:180,quality_android:90,quality_ios:80},auto_gen_frame_ids:{enable:!1,max_items:50}}}}}},V=30,L=e=>{let{shouldStart:i,totalTime:r,totalDelayBetweenReset:t,interruptible:s=!0,onReset:o,onTick:n,onTimesUp:d}=e,c=a.useRef(new l({totalTime:r,totalDelayBetweenReset:t,interruptible:s}));return a.useEffect(()=>c.current.on("tick",({remainTime:e})=>{n({remainTime:e})}),[n]),a.useEffect(()=>c.current.on("delaystart",()=>{d()}),[d]),a.useEffect(()=>c.current.on("reset",({attemptCount:e,fromBackground:i})=>{o({attemptCount:e,fromBackground:i})}),[o]),a.useEffect(()=>i?c.current.start():()=>{},[i]),{stopTimer:a.useCallback(()=>{c.current.stop()},[])}},{ErrorDuration:z}=g;function M({children:e,errorMsg:i,className:r}){return h.isValidElement(e)?i?f.jsx("div",{className:r,children:h.cloneElement(e,{errorMsg:i})}):null:i?f.jsx("div",{className:r,children:i}):null}function B({children:e,className:i,error:r}){let t=a.useRef(0),s=a.useRef(""),o=c(),n=a.useRef(z.SHORT),{code:l,duration:d=z.SHORT}=r||{},g=o(l);return Date.now()-t.current>=n.current?(t.current=Date.now(),n.current=d,s.current=g,M({children:e,errorMsg:g,className:i})):M({children:e,errorMsg:s.current,className:i})}B.propTypes={children:d.node,className:d.string},B.defaultProps={className:""};let N=u.g`
2
2
  transition: stroke-dashoffset 0.4s;
3
3
  transform: rotate(-90deg);
4
4
  transform-origin: 50% 50%;
@@ -0,0 +1 @@
1
+ import{$ as r}from"./chunk-78da2232.js";import{r as o}from"./chunk-bf5a5b12.js";var s=r(o());export{s as d};