@tsocial/tvweb-sdk 5.38.2 → 5.38.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/build/esm/chunk-0042305b.js +1 -0
  2. package/build/esm/{chunk-26f22aaa.js → chunk-0d38d10a.js} +1 -1
  3. package/build/esm/{chunk-f253519c.js → chunk-1ffc8702.js} +1 -1
  4. package/build/esm/chunk-27713cdc.js +1205 -0
  5. package/build/esm/chunk-3918125a.js +1 -0
  6. package/build/esm/chunk-4f3a497a.js +1 -0
  7. package/build/esm/chunk-4f993a97.js +3 -0
  8. package/build/esm/chunk-65036591.js +256 -0
  9. package/build/esm/{chunk-d6a3ff5a.js → chunk-67605c5a.js} +1 -1
  10. package/build/esm/{chunk-69854c99.js → chunk-77246947.js} +2 -2
  11. package/build/esm/chunk-788a3d4e.js +1 -0
  12. package/build/esm/{chunk-4588a2bc.js → chunk-89b09e98.js} +32 -32
  13. package/build/esm/chunk-9462231f.js +1 -0
  14. package/build/esm/chunk-9803c4f4.js +1 -0
  15. package/build/esm/chunk-99078e42.js +1 -0
  16. package/build/esm/{chunk-d436b362.js → chunk-b9c073ce.js} +5 -5
  17. package/build/esm/{chunk-df438efe.js → chunk-c385606a.js} +2 -2
  18. package/build/esm/{chunk-a9d5f5ae.js → chunk-cc109f43.js} +1 -1
  19. package/build/esm/chunk-d311aed8.js +1 -0
  20. package/build/esm/chunk-ec2cd6ff.js +1 -0
  21. package/build/esm/tvweb-sdk.esm.min.js +1 -1
  22. package/build/tvweb-sdk.cjs.min.js +661 -695
  23. package/build/tvweb-sdk.standalone.js +6013 -7694
  24. package/build/tvweb-sdk.standalone.min.js +661 -695
  25. package/build/types/index.d.ts +1 -9
  26. package/package.json +5 -5
  27. package/build/esm/chunk-05ac2e29.js +0 -1
  28. package/build/esm/chunk-148a64eb.js +0 -1
  29. package/build/esm/chunk-18c2104b.js +0 -1
  30. package/build/esm/chunk-2f00d703.js +0 -1
  31. package/build/esm/chunk-30941db8.js +0 -1
  32. package/build/esm/chunk-4dbeaf6f.js +0 -256
  33. package/build/esm/chunk-5952fbfb.js +0 -1
  34. package/build/esm/chunk-67dba361.js +0 -1
  35. package/build/esm/chunk-7a1034f3.js +0 -1
  36. package/build/esm/chunk-94b9613e.js +0 -45
  37. package/build/esm/chunk-95585c1a.js +0 -3
  38. package/build/esm/chunk-bb5383fa.js +0 -1195
  39. package/build/esm/chunk-d7808881.js +0 -1
  40. package/build/esm/chunk-e2249d38.js +0 -1
@@ -0,0 +1 @@
1
+ import{Y as r}from"./chunk-27713cdc.js";import{r as o}from"./chunk-67605c5a.js";var s=r(o());export{s as d};
@@ -0,0 +1 @@
1
+ let e,t;import{n as n,s as a,d as s,r as r,P as i,aa as o,j as l,f as u,c as c,u as f,p as p,g as d}from"./chunk-27713cdc.js";import{L as g,C as m,S as h,u as v}from"./chunk-788a3d4e.js";import{W as A}from"./chunk-9803c4f4.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:V,customTexts:H,extraConfig:L}=e,B=v(),G=r.useMemo(()=>{let e={..._,...R};return u.getEnabledServices(e,B)},[B,_]),{FaceAuthenticationLoading:O}=V,[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:L,customComponent:V,apiCheck:t,apiCredentials:m,serviceSettings:G,flowId:x,customTexts:H}),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};
@@ -0,0 +1,3 @@
1
+ import{o as e,P as i,s as t,x as c,Q as o,e as n,n as r,j as a}from"./chunk-27713cdc.js";let s=e.img`
2
+ width: ${({width:e})=>e};
3
+ `;function l({type:e}){let i=c(),l=o(`Selfie.Active.directionIcon.${e}`,`${e}_arrow.gif`),F=o(`Selfie.Active.directionIcon.${t.FaceDirection.FRONTAL}`,"frontal_arrow.svg"),d=n(`Selfie.Active.directionIcon.${e}Width`)({theme:i}),f=r(i,`Selfie.Active.directionIcon.${e}`);return null===f?a.jsx(a.Fragment,{}):e===t.FaceDirection.FRONTAL&&F?a.jsx(s,{src:F,width:d,alt:""}):f&&null!==f?a.jsx(s,{src:r(i,`Selfie.Active.directionIcon.${e}`),width:d,alt:""}):a.jsx(s,{src:l,alt:"",width:d})}l.propTypes={type:i.oneOf([t.FaceDirection.LEFT,t.FaceDirection.RIGHT,t.FaceDirection.UP,t.FaceDirection.FRONTAL])},l.defaultProps={type:t.FaceDirection.LEFT};export{l as D};
@@ -0,0 +1,256 @@
1
+ import{aL as e,w as i,aM as r,aN as t,aO as o,e as s,n as n,ai as a,aj as l,aP as d,af as c,aQ as g,Y as f,r as u,H as h,P as p,z as m,s as _,V as b,j as w,o as v,v as k,B as R,b as y,aR as S}from"./chunk-27713cdc.js";import{r as C,f as x,g as $,h as j,i as W,j as O,k as I,l as E,n as A,o as D,p as T}from"./chunk-9803c4f4.js";var P,L,V,z,M,B,F,N,H,U,q,K,J,Y,Z,G,Q,X,ee,ei,er,et,eo,es,en,ea,el,ed,ec,eg,ef,eu,eh,ep,em=Object.freeze({__proto__:null,blink:e,flipY:i,slide:r,spin:t,splash:o});let e_=({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)},eb=(e,i)=>({radius:e.radius??s("Selfie.progressCircle.radius")({theme:i}),strokeWidth:e.strokeWidth??s("Selfie.progressCircle.strokeWidth")({theme:i}),progress:e.progress??s("Selfie.progressCircle.progress")({theme:i}),showErrorRing:e.showErrorRing??s("Selfie.progressCircle.showErrorRing")({theme:i}),activeColor:e.activeColor??s("Selfie.progressCircle.activeColor")({theme:i}),innerPadding:e.innerPadding??s("Selfie.progressCircle.innerPadding")({theme:i}),outsideRingColor:e.outsideRingColor??s("Selfie.progressCircle.outsideRingColor")({theme:i}),outsideRingOpacity:e.outsideRingOpacity??s("Selfie.progressCircle.outsideRingOpacity")({theme:i}),insideRingColor:e.insideRingColor??s("Selfie.progressCircle.insideRingColor")({theme:i}),insideRingWidth:e.insideRingWidth??s("Selfie.progressCircle.insideRingWidth")({theme:i}),insideRingStrokeDash:e.insideRingStrokeDash??s("Selfie.progressCircle.insideRingStrokeDash")({theme:i}),errorRingWidth:e.errorRingWidth??s("Selfie.progressCircle.errorRingWidth")({theme:i}),errorRingColor:e.errorRingColor??s("Selfie.progressCircle.errorRingColor")({theme:i}),dashedRingColor:e.dashedRingColor??s("Selfie.progressCircle.dashedRingColor")({theme:i}),dashedRingOpacity:e.dashedRingOpacity??s("Selfie.progressCircle.dashedRingOpacity")({theme:i}),dashedRingWidth:e.dashedRingWidth??s("Selfie.progressCircle.dashedRingWidth")({theme:i}),dashedRingLineThick:e.dashedRingLineThick??s("Selfie.progressCircle.dashedRingLineThick")({theme:i}),dashedRingLineSpacing:e.dashedRingLineSpacing??s("Selfie.progressCircle.dashedRingLineSpacing")({theme:i}),dashedInsideRingColor:e.dashedInsideRingColor??s("Selfie.progressCircle.dashedInsideRingColor")({theme:i}),dashedInsideRingWidth:e.dashedInsideRingWidth??s("Selfie.progressCircle.dashedInsideRingWidth")({theme:i}),showOutsideRing:e.showOutsideRing??s("Selfie.progressCircle.showOutsideRing")({theme:i}),showInsideRing:e.showInsideRing??s("Selfie.progressCircle.showInsideRing")({theme:i}),showDashedRing:e.showDashedRing??s("Selfie.progressCircle.showDashedRing")({theme:i})}),ew=(e,i)=>({radius:e.radius??s("Selfie.progressCircleV2.radius")({theme:i}),strokeWidth:e.strokeWidth??s("Selfie.progressCircleV2.strokeWidth")({theme:i}),progress:e.progress??s("Selfie.progressCircleV2.progress")({theme:i}),activeColor:e.activeColor??s("Selfie.progressCircleV2.activeColor")({theme:i}),neutralColor:e.neutralColor??s("Selfie.progressCircleV2.neutralColor")({theme:i}),errorColor:e.errorColor??s("Selfie.progressCircleV2.errorColor")({theme:i}),tickWidth:e.tickWidth??s("Selfie.progressCircleV2.tickWidth")({theme:i}),numberOfTicks:e.numberOfTicks??s("Selfie.progressCircleV2.numberOfTicks")({theme:i})}),ev=({incomingFrame:e,currentBestFrame:i})=>e?.isEyeClosed&&!i?.isEyeClosed?i:!e?.isEyeClosed&&i?.isEyeClosed?e:e?.blurScore>i?.blurScore?e:i;function ek(e){return new Promise(i=>{let r=new Image;r.onload=i,r.onerror=i,r.src=e})}function eR(){if(z)return V;z=1;var e=a(),i=l(),r=j();return V=function(t){if(!i(t))return!1;var o=e(t);return"[object Error]"==o||"[object DOMException]"==o||"string"==typeof t.message&&"string"==typeof t.name&&!r(t)}}function ey(){return ei?ee:(ei=1,ee=/<%=([\s\S]+?)%>/g)}var eS=f(function(){if(ep)return eh;ep=1;var e=function(){if(L)return P;L=1;var e=C(),i=x(),r=$();return P=i(function(i,t,o,s){e(t,r(t),i,s)})}(),i=function(){if(B)return M;B=1;var e=O(),i=W(),r=eR();return M=i(function(i,t){try{return e(i,void 0,t)}catch(e){return r(e)?e:Error(e)}})}(),r=function(){if(N)return F;N=1;var e=d();return F=function(i,r){return e(r,function(e){return i[e]})}}(),t=function(){if(U)return H;U=1;var e=c(),i=Object.prototype,r=i.hasOwnProperty;return H=function(t,o,s,n){return void 0===t||e(t,i[s])&&!r.call(n,s)?o:t}}(),o=function(){if(K)return q;K=1;var e={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"};return q=function(i){return"\\"+e[i]}}(),s=eR(),n=T(),a=function(){if(X)return Q;X=1;var e=A(),i=function(){if(G)return Z;G=1;var e=E(),i=Y?J:(Y=1,J=I()(Object.keys,Object)),r=Object.prototype.hasOwnProperty;return Z=function(t){if(!e(t))return i(t);var o=[];for(var s in Object(t))r.call(t,s)&&"constructor"!=s&&o.push(s);return o}}(),r=D();return Q=function(t){return r(t)?e(t):i(t)}}(),l=ey(),f=function(){if(eu)return ef;eu=1;var e=function(){if(ea)return en;ea=1;var e=function(){if(es)return eo;es=1;var e=et?er:(et=1,er=function(e){return function(i){return null==e?void 0:e[i]}});return eo=e({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})}(),i=g(),r=/[&<>"']/g,t=RegExp(r.source);return en=function(o){return(o=i(o))&&t.test(o)?o.replace(r,e):o}}(),i=ed?el:(ed=1,el=/<%-([\s\S]+?)%>/g),r=eg?ec:(eg=1,ec=/<%([\s\S]+?)%>/g),t=ey();return ef={escape:i,evaluate:r,interpolate:t,variable:"",imports:{_:{escape:e}}}}(),u=g(),h=/\b__p \+= '';/g,p=/\b(__p \+=) '' \+/g,m=/(__e\(.*?\)|\b__t\)) \+\n'';/g,_=/[()=,{}\[\]\/\s]/,b=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,w=/($^)/,v=/['\n\r\u2028\u2029\\]/g,k=Object.prototype.hasOwnProperty;return eh=function(d,c,g){var R=f.imports._.templateSettings||f;g&&n(d,c,g)&&(c=void 0),d=u(d),c=e({},c,R,t);var y=e({},c.imports,R.imports,t),S=a(y),C=r(y,S),x,$,j=0,W=c.interpolate||w,O="__p += '",I=RegExp((c.escape||w).source+"|"+W.source+"|"+(W===l?b:w).source+"|"+(c.evaluate||w).source+"|$","g"),E=k.call(c,"sourceURL")?"//# sourceURL="+(c.sourceURL+"").replace(/\s/g," ")+"\n":"";d.replace(I,function(e,i,r,t,s,n){return r||(r=t),O+=d.slice(j,n).replace(v,o),i&&(x=!0,O+="' +\n__e("+i+") +\n'"),s&&($=!0,O+="';\n"+s+";\n__p += '"),r&&(O+="' +\n((__t = ("+r+")) == null ? '' : __t) +\n'"),j=n+e.length,e}),O+="';\n";var A=k.call(c,"variable")&&c.variable;if(A){if(_.test(A))throw Error("Invalid `variable` option passed into `_.template`")}else O="with (obj) {\n"+O+"\n}\n";O=($?O.replace(h,""):O).replace(p,"$1").replace(m,"$1;"),O="function("+(A||"obj")+") {\n"+(A?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(x?", __e = _.escape":"")+($?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+O+"return __p\n}";var D=i(function(){return Function(S,E+"return "+O).apply(void 0,C)});if(D.source=O,s(D))throw D;return D}}());let eC=[],ex=()=>{eC=[]},e$=(e,i,r,t)=>{t&&ex(),eC.push({id:null});let o=eC.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?eC[o].id=e.data.file_id:eC[o].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?eC[o].id=e.data.file_id:eC[o].id=-1})}},ej=()=>new Promise(e=>{let i=setInterval(()=>{eC.every(e=>e.id)&&(e(),clearInterval(i))},200)}),eW=e=>e.enable?eC.some(e=>-1===e.id)?null:eC:[],eO=[],eI=null,eE=!1,eA=()=>eO,eD=()=>{eE=!0,eO=[];try{eI instanceof MediaStream&&(eI.getTracks().forEach(e=>e.stop()),eI=null)}catch(e){}};async function eT({outputImagesSize:e,videoEl:i,resultAnalyzeVideoAndWindowSizes:r}){let t;eD();let o=document.createElement("canvas");o.width=e,o.height=e;let s=o.getContext("2d");try{let n={mimeType:"video/webm"};try{let e=(eI=i?.captureStream()?.clone()).getVideoTracks()[0];await e.applyConstraints({width:{min:360,ideal:400},height:{min:360,ideal:400}})}catch(e){}MediaRecorder.isTypeSupported("video/mp4")&&(eE=!1,!function e(i,r,t,o){if(!i||!o)return;let{cropX:s,cropY:n,cropWidth:a,cropHeight:l}=o;i.drawImage(r,s,n,a,l,0,0,t,t),eE||requestAnimationFrame(()=>e(i,r,t,o))}(s,i,e,r),eI=o.captureStream(25),n={mimeType:"video/mp4",videoBitsPerSecond:25e5}),t=new MediaRecorder(eI,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"});eO.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 eP={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}}}}}},eL=30,eV=e=>{let{shouldStart:i,totalTime:r,totalDelayBetweenReset:t,interruptible:o=!0,onReset:s,onTick:n,onTimesUp:a}=e,l=u.useRef(new h({totalTime:r,totalDelayBetweenReset:t,interruptible:o}));return u.useEffect(()=>l.current.on("tick",({remainTime:e})=>{n({remainTime:e})}),[n]),u.useEffect(()=>l.current.on("delaystart",()=>{a()}),[a]),u.useEffect(()=>l.current.on("reset",({attemptCount:e,fromBackground:i})=>{s({attemptCount:e,fromBackground:i})}),[s]),u.useEffect(()=>i?l.current.start():()=>{},[i]),{stopTimer:u.useCallback(()=>{l.current.stop()},[])}},{ErrorDuration:ez}=_;function eM({children:e,errorMsg:i,className:r}){return b.isValidElement(e)?i?w.jsx("div",{className:r,children:b.cloneElement(e,{errorMsg:i})}):null:i?w.jsx("div",{className:r,children:i}):null}function eB({children:e,className:i,error:r}){let t=u.useRef(0),o=u.useRef(""),s=m(),n=u.useRef(ez.SHORT),{code:a,duration:l=ez.SHORT}=r||{},d=s(a);return Date.now()-t.current>=n.current?(t.current=Date.now(),n.current=l,o.current=d,eM({children:e,errorMsg:d,className:i})):eM({children:e,errorMsg:o.current,className:i})}eB.propTypes={children:p.node,className:p.string},eB.defaultProps={className:""};let eF=v.g`
2
+ transition: stroke-dashoffset 0.4s;
3
+ transform: rotate(-90deg);
4
+ transform-origin: 50% 50%;
5
+ `,eN=v.circle`
6
+ transition: stroke-dashoffset 0.4s, stroke 0.4s;
7
+ transform: rotate(-90deg);
8
+ transform-origin: 50% 50%;
9
+ fill: none;
10
+ `,eH=v.circle`
11
+ transition: stroke-dashoffset 0.4s;
12
+ transform: rotate(-90deg);
13
+ transform-origin: 50% 50%;
14
+ `;function eU({className:e,style:i,radius:r,strokeWidth:t,progress:o,showErrorRing:s,activeColor:n,innerPadding:a,outsideRingColor:l,outsideRingOpacity:d,insideRingColor:c,insideRingWidth:g,insideRingStrokeDash:f,errorRingWidth:u,errorRingColor:h,dashedRingColor:p,dashedRingOpacity:m,dashedRingWidth:_,dashedRingLineThick:b,dashedRingLineSpacing:v,dashedInsideRingColor:k,dashedInsideRingWidth:R,showOutsideRing:y,showInsideRing:S,showDashedRing:C}){let x=2*r,$=2*r,j=r-2*t,W=2*Math.PI*j,O=j-_/2-t/2-a,I=2*Math.PI*O,E=O-R/2-_/2,A=2*Math.PI*E,D=E-g/2-R/2,T=E-u/2-R/2;return w.jsxs("svg",{className:e,style:i,width:x,height:$,viewBox:`0 0 ${x} ${$}`,fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[y?w.jsxs(w.Fragment,{children:[w.jsx("circle",{"data-testid":"outsideRing",opacity:d,cx:r,cy:r,r:j,stroke:l}),w.jsx(eH,{"data-testid":"outsideAnimateRing",cx:r,cy:r,r:j,stroke:n,strokeWidth:t,strokeLinecap:"round",strokeDasharray:`${W} ${W}`,style:{strokeDashoffset:W-o/100*W}})]}):null,C?w.jsxs(w.Fragment,{children:[w.jsx("circle",{"data-testid":"dashedRing",opacity:m,cx:r,cy:r,r:O,stroke:p,strokeWidth:_,strokeDasharray:`${b} ${v}`}),w.jsx("mask",{id:"mask0","mask-type":"alpha",maskUnits:"userSpaceOnUse",children:w.jsx("circle",{cx:r,cy:r,r:O,stroke:n,strokeWidth:_,strokeDasharray:`${b} ${v}`})}),w.jsx("g",{mask:"url(#mask0)",children:w.jsx(eH,{"data-testid":"dashedAnimateRing",cx:r,cy:r,r:O,stroke:n,strokeWidth:_,strokeDasharray:`${I} ${I}`,style:{strokeDashoffset:I-o/100*I}})}),w.jsx("circle",{"data-testid":"dashedInsideRing",opacity:m,cx:r,cy:r,r:E,stroke:k,strokeWidth:R}),w.jsx(eH,{"data-testid":"dashedInsideAnimateRing",cx:r,cy:r,r:E,stroke:n,strokeWidth:R,strokeLinecap:"round",strokeDasharray:`${A} ${A}`,style:{strokeDashoffset:A-o/100*A}})]}):null,S?w.jsx("circle",{"data-testid":"insideRing",strokeDasharray:f,cx:r,cy:r,r:D,stroke:c,strokeWidth:g}):null,s?w.jsx("circle",{"data-testid":"errorRing",strokeDasharray:f,cx:r,cy:r,r:T,stroke:h,strokeWidth:u}):null]})}eU.propTypes={className:p.string,style:p.shape({}),radius:p.number,strokeWidth:p.number,progress:p.number,showErrorRing:p.bool,activeColor:p.string,innerPadding:p.number,outsideRingColor:p.string,outsideRingOpacity:p.number,insideRingColor:p.string,insideRingWidth:p.number,insideRingStrokeDash:p.string,errorRingColor:p.string,errorRingWidth:p.number,dashedRingColor:p.string,dashedRingOpacity:p.number,dashedRingWidth:p.number,dashedRingLineThick:p.number,dashedRingLineSpacing:p.number,dashedInsideRingColor:p.string,dashedInsideRingWidth:p.number,showOutsideRing:p.bool,showDashedRing:p.bool,showInsideRing:p.bool},eU.defaultProps={className:"",style:null,radius:160,strokeWidth:3,progress:0,showErrorRing:!1,activeColor:"#0092ff",innerPadding:5,outsideRingColor:"#f2f6f9",outsideRingOpacity:.1,insideRingColor:"#f2f6f9",insideRingWidth:3,insideRingStrokeDash:"0",errorRingColor:"#df0000",errorRingWidth:3,dashedRingColor:"#ffffff",dashedRingOpacity:.3,dashedRingWidth:10,dashedRingLineThick:1,dashedRingLineSpacing:6,dashedInsideRingColor:"#ffffff",dashedInsideRingWidth:0,showOutsideRing:!0,showDashedRing:!0,showInsideRing:!0};let{blink:eq,slide:eK,spin:eJ}=em,eY=k`
15
+ z-index: ${R+20};
16
+ color: #ffffff;
17
+ `,eZ=v.div`
18
+ ${eY}
19
+ `,eG=k`
20
+ ${eY}
21
+ ${({top:e})=>e&&k`
22
+ top: ${e}px;
23
+ `}
24
+ ${({bottom:e})=>e&&k`
25
+ bottom: ${e}px;
26
+ `}
27
+ ${({centerY:e})=>e&&k`
28
+ top: 50%;
29
+ transform: translateY(-50%);
30
+ `}
31
+ font-size: ${s("Selfie.error.fontSize")};
32
+ font-weight: ${s("Selfie.error.fontWeight")};
33
+ background: ${s("Selfie.error.backgroundColor")};
34
+ color: ${s("Selfie.error.color")};
35
+ padding: ${s("Selfie.error.padding")};
36
+ border-radius: ${s("Selfie.error.borderRadius")};
37
+ position: absolute;
38
+ white-space: pre-wrap;
39
+ text-align: center;
40
+ max-width: 80%;
41
+ `;v(eB)`
42
+ ${eG}
43
+ `;let eQ=v.div`
44
+ ${eG}
45
+ `,eX=v.div`
46
+ z-index: ${R+20};
47
+ display: flex;
48
+ align-items: center;
49
+ position: absolute;
50
+ left: 50%;
51
+ transform: translate(-50%, 0);
52
+ ${({top:e})=>e&&k`
53
+ top: ${e}px;
54
+ `}
55
+ `,e0=v(eZ)`
56
+ font-size: ${s("Selfie.countdown.fontSize")};
57
+ font-weight: ${s("Selfie.countdown.fontWeight")};
58
+ background: ${s("Selfie.countdown.backgroundColor")};
59
+ color: ${s("Selfie.countdown.color")};
60
+ padding: ${s("Selfie.countdown.padding")};
61
+ border-radius: ${s("Selfie.countdown.borderRadius")};
62
+ white-space: nowrap;
63
+ `,e1=v(e0)`
64
+ position: absolute;
65
+ left: 50%;
66
+ transform: translate(-50%, 0);
67
+ ${({top:e})=>e&&k`
68
+ top: ${e}px;
69
+ `}
70
+ `,e2=v(eZ)`
71
+ position: absolute;
72
+ ${({top:e})=>e&&k`
73
+ top: ${e}px;
74
+ `}
75
+ ${({bottom:e})=>e&&k`
76
+ bottom: ${e}px;
77
+ `}
78
+ color: ${s("Selfie.Active.instruction.color")};
79
+ font-size: ${s("Selfie.Active.instruction.fontSize")};
80
+ font-weight: ${s("Selfie.Active.instruction.fontWeight")};
81
+ text-shadow: ${s("Selfie.Active.instruction.textShadow")};
82
+ background-color: ${s("Selfie.Active.instruction.backgroundColor")};
83
+ border: ${s("Selfie.Active.instruction.border")};
84
+ border-radius: ${s("Selfie.Active.instruction.borderRadius")};
85
+ `,e3=v.div`
86
+ height: ${()=>y.isMobile?"50px":"70px"};
87
+ position: absolute;
88
+ ${({top:e})=>e&&k`
89
+ top: ${e}px;
90
+ `}
91
+ ${({bottom:e})=>e&&k`
92
+ bottom: ${e}px;
93
+ `}
94
+ width: 100%;
95
+ display: flex;
96
+ justify-content: center;
97
+ align-items: center;
98
+ z-index: ${R+20};
99
+ `,e5=v.div`
100
+ width: ${s("Selfie.Active.imageHolder.width")};
101
+ height: ${s("Selfie.Active.imageHolder.height")};
102
+ border-radius: ${s("Selfie.Active.imageHolder.borderRadius")};
103
+ font-size: ${s("Selfie.Active.imageHolder.fontSize")};
104
+ color: ${s("Selfie.Active.imageHolder.color")};
105
+ font-weight: ${s("Selfie.Active.imageHolder.fontWeight")};
106
+
107
+ ${({theme:e})=>"v2"===n(e,"themeVersion")?"border: unset;":`border: ${s("Selfie.Active.imageHolder.border")({theme:e})};`}
108
+
109
+ display: flex;
110
+ justify-content: center;
111
+ align-items: center;
112
+
113
+ & + & {
114
+ margin-left: 10px;
115
+ }
116
+
117
+ ${e=>e.active?k`
118
+ img:not(.image_preview) {
119
+ border: ${s("Selfie.Active.imageHolder.activeStepBorder")};
120
+ border-radius: ${s("Selfie.Active.imageHolder.activeStepBorderRadius")};
121
+ }
122
+ `:k`
123
+ opacity: 0.3;
124
+ `}
125
+
126
+ img {
127
+ width: 100%;
128
+ margin: 0;
129
+ border-radius: ${s("Selfie.Active.imageHolder.borderRadius")};
130
+ }
131
+ img.image_preview {
132
+ border: ${s("Selfie.Active.imageHolder.border")};
133
+ }
134
+ `,e4=v.div`
135
+ color: #ffffff;
136
+ height: 70px;
137
+ position: absolute;
138
+ bottom: 0;
139
+ width: 100%;
140
+ display: flex;
141
+ justify-content: center;
142
+ align-items: center;
143
+ z-index: ${R+20};
144
+ `,e8=v.div`
145
+ ${({disabled:e})=>e?k`
146
+ pointer-events: none;
147
+ `:k`
148
+ cursor: pointer;
149
+ `}
150
+ text-align: center;
151
+
152
+ img {
153
+ width: ${s("Selfie.captureIcon.width")};
154
+ }
155
+ `,e6=v.div`
156
+ position: absolute;
157
+ width: 100%;
158
+ top: 0;
159
+ bottom: 0;
160
+ display: flex;
161
+ justify-content: center;
162
+ align-items: center;
163
+ color: #ffffff;
164
+ font-size: 140px;
165
+ opacity: 0.6;
166
+ `,e9=v.div`
167
+ position: absolute;
168
+ width: 100%;
169
+ top: 0;
170
+ bottom: 0;
171
+ display: flex;
172
+ flex-direction: column;
173
+ justify-content: center;
174
+ align-items: center;
175
+ ${eK.default};
176
+ ${eq.default};
177
+ `,e7=v(eU)`
178
+ position: absolute;
179
+ top: 0;
180
+ left: 0;
181
+ width: 100%;
182
+ height: 100%;
183
+ `,ie=v(({className:e="",radius:i=80,neutralColor:r="#CBD5E1",activeColor:t="#0276F1",errorColor:o="#E84848",strokeWidth:s=2,tickWidth:n=15,numberOfTicks:a=200,progress:l=0,showErrorRing:d=!1})=>{let c=2*i,g=i-5,f=2*Math.PI*g,u=Array.from({length:a}).map((e,r)=>{let t=360*r/a+3;return w.jsx("use",{href:"#tick",transform:`rotate(${t} ${i} ${i})`},r)}),h=i-eL,p=2*Math.PI*h;return w.jsxs("svg",{height:c,width:c,viewBox:`0 0 ${c} ${c}`,className:e,xmlns:"http://www.w3.org/2000/svg",children:[d?w.jsx("circle",{cx:i,cy:i,r:i-eL,stroke:o,strokeWidth:s,fill:"none"}):w.jsxs(w.Fragment,{children:[w.jsx("circle",{cx:i,cy:i,r:h,stroke:r,strokeWidth:s,fill:"none"}),w.jsx(eN,{cx:i,cy:i,r:h,stroke:t,strokeWidth:s,strokeLinecap:"round",strokeDasharray:`${p} ${p}`,style:{strokeDashoffset:p-l/100*p}})]}),w.jsx("defs",{children:w.jsx("line",{id:"tick",x1:i,y1:"0",x2:i,y2:n,stroke:r,strokeWidth:s,strokeLinecap:"round"})}),w.jsx("g",{id:"border-segments",children:u}),w.jsx("mask",{id:"tickMask",maskUnits:"userSpaceOnUse",children:w.jsx("g",{id:"tick-mask-segments",children:u})}),w.jsx("g",{mask:"url(#tickMask)",children:w.jsx(eF,{strokeDasharray:`${f} ${f}`,style:{strokeDashoffset:f-l/100*f},children:w.jsx("circle",{cx:i,cy:i,r:g,stroke:t,strokeWidth:20,fill:"none"})})})]})})`
184
+ position: absolute;
185
+ top: 0;
186
+ left: 0;
187
+ width: 100%;
188
+ height: 100%;
189
+ `,ii=v(function({className:e=""}){return w.jsx("svg",{className:e,width:"320",height:"320",viewBox:"0 0 320 320",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:w.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M320 0H0V320H320V0ZM160 296C235.111 296 296 235.111 296 160C296 84.8893 235.111 24 160 24C84.8893 24 24 84.8893 24 160C24 235.111 84.8893 296 160 296Z",fill:"currentColor"})})})`
190
+ width: 100%;
191
+ height: 100%;
192
+ vertical-align: middle;
193
+ margin: 0;
194
+ color: ${s("Selfie.backgroundColor")};
195
+ `,ir=v(function({className:e="",radius:i=160,backgroundColor:r="#fff",padding:t=0}){let o=2*i;return w.jsxs("svg",{className:e,width:o,height:o,viewBox:`0 0 ${o} ${o}`,fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[w.jsxs("mask",{id:"CIRCLE_MASK",children:[w.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:"white",mask:"url(#CIRCLE_MASK)"}),w.jsx("circle",{cx:i,cy:i,r:i-t,fill:"black"})]}),w.jsx("circle",{cx:i,cy:i,r:i,fill:"none"}),w.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:r,mask:"url(#CIRCLE_MASK)"})]})})`
196
+ width: 100%;
197
+ height: 100%;
198
+ vertical-align: middle;
199
+ margin: 0;
200
+ color: ${s("Selfie.backgroundColor")};
201
+ `,it=v.div`
202
+ position: absolute;
203
+ z-index: -1;
204
+ background: rgba(223, 0, 0, 0.2);
205
+ border-radius: 50%;
206
+ width: 86%;
207
+ height: 86%;
208
+ top: 7%;
209
+ left: 7%;
210
+ `,io=S`
211
+ from {
212
+ opacity: 1;
213
+ }
214
+
215
+ to {
216
+ opacity: 0;
217
+ }
218
+ `,is=v.div`
219
+ position: absolute;
220
+ width: 100%;
221
+ top: 0;
222
+ bottom: 0;
223
+ z-index: -1;
224
+ background: rgba(255, 255, 255, 0.3);
225
+ animation: ${io} 1s infinite;
226
+ border-radius: 50%;
227
+ `,ia=v.div`
228
+ top: 0;
229
+ left: 0;
230
+ right: 0;
231
+ bottom: 0;
232
+ position: absolute;
233
+ margin: auto;
234
+ width: ${s("Selfie.loadingIcon.width")};
235
+ height: ${s("Selfie.loadingIcon.height")};
236
+
237
+ img {
238
+ width: 100%;
239
+ }
240
+
241
+ z-index: ${R+20};
242
+ ${eJ.default}
243
+ `,il=v.div`
244
+ text-align: center;
245
+ color: ${s("Selfie.title.color")};
246
+ font-size: ${s("Selfie.title.fontSize")};
247
+ font-weight: ${s("Selfie.title.fontWeight")};
248
+ background-color: ${s("Selfie.title.backgroundColor")};
249
+ position: absolute;
250
+ top: ${e=>e.y};
251
+ z-index: ${R+10};
252
+ display: flex;
253
+ align-items: center;
254
+ justify-content: center;
255
+ width: 100%;
256
+ `;export{eL as A,e4 as B,e6 as C,it as E,e2 as F,e9 as I,ia as L,e7 as O,eQ as S,il as T,ii as a,e1 as b,e8 as c,ew as d,ir as e,ie as f,eb as g,is as h,e3 as i,e5 as j,eX as k,e0 as l,eW as m,eP as n,e$ as o,ek as p,eA as q,eD as r,ex as s,eS as t,eV as u,eT as v,ej as w,e_ as x,ev as y};
@@ -1 +1 @@
1
- import{ah as n,aT as t,ai as i,$ as r}from"./chunk-bb5383fa.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{ag as n,aS as t,ah as i,Y as r}from"./chunk-27713cdc.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,g=!1,p=!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)&&(g=!!i.leading,u=(p="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||p&&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,p?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),g?T(n):f}if(p)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,4 +1,4 @@
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-bb5383fa.js";import{W as v}from"./chunk-d436b362.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,o as a,j as o,I as i,D as n,aD as l,F as s,at as c,aE as u,aF as h,s as d,c as f,G as m,k as g,aG as _,m as p,au as b,b as y,H as w,P as E,d as C}from"./chunk-27713cdc.js";import{W as A}from"./chunk-b9c073ce.js";let F=({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}},v={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,G as n,aE as l,I 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])},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};
10
+ `,T=({children:e=null,overlay:t=!1,loadingComponent:r=o.jsx(A,{})})=>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])},D=()=>{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]},O=()=>{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])},B=(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 X({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:A,shouldPauseFaceDetection:F,shouldContinueOnError:R,debug:S=!1,faceDetectionSettings:x}){let{faceSettings:k,maskSettings:T,closeEyesSettings:L,captureFrameSettings:M,blurCheckFarSettings:P,blurCheckCloseSettings:D,brightnessDetectionFarSettings:O,brightnessDetectionCloseSettings:B,notQualifiedFarSettings:I,notQualifiedCloseSettings:N,frontalFaceCheckSettings:j}=x,{chinToMaskBottomPadding:W}=T,{frameScale:G}=M,{enable:H,timeout:X,forceCheck:$}=L,{enable:J,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:A,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*X}),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||F||a===v.STOP_DECTECTING)return;let{cropX:n,cropY:f,cropWidth:y,cropHeight:C}=e,A=t.width,x=t.height;t.getContext("2d").drawImage(i.current,n,f,y,C,0,0,A,x);let k=m.drawToSquareCanvas(t),T=K/A;if(S&&es.getContext("2d").drawImage(i.current,n,f,y,C,0,0,A*T,x*T),!w&&a===v.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&&J){let e=await _.calculateFaceDirection({landmarks:q.landmarks,upDownBound:{lower:Y,upper:Q}});V=e?.gesture??""}(q||j?.code===d.Errors.partial_face.code)&&a===v.FAR_FACE&&"function"==typeof l&&await l({prediction:L[0],originalRatio:el,canvas:t}),(q||j?.code===d.Errors.partial_face.code)&&a===v.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===v.FAR_FACE){if(G>ee)throw Error("face_too_large");if(G<Z)throw Error("face_too_small")}if(a===v.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===v.FAR_FACE&&G>=Z&&G<=ee||a===v.CLOSE_FACE&&G>=et))throw Error("")}catch(e){U=e.message}let X=null;if(H)if(U)em();else{let e=await ep.predict(t,q.landmarks),r=!$&&eg();X=e.isEyeClose,e.isEyeClose&&!r&&(U="eye_close")}let er=null,ea=a===v.FAR_FACE?O:B;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===v.FAR_FACE?P.enable:D.enable,threshold:a===v.FAR_FACE?P.threshold:D.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===v.FAR_FACE?I.enable:N.enable,threshold:a===v.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===v.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===v.FAR_FACE?ee:et),a===v.FAR_FACE&&e_&&Z<=eE&&eE<=ee&&"function"==typeof s)return void await s({prediction:e_,originalRatio:el,canvas:t,frame:{faceRatio:eE,isEyeClosed:X,blurScore:eo,qualifyScore:eu,realQualifyScore:eh,qualifyModelMessage:ed,brightnessScore:er,faceError:U}});if(e_&&a===v.CLOSE_FACE&&eE>=et&&"function"==typeof u)return void await u({prediction:e_,originalRatio:el,canvas:t,frame:{faceRatio:eE,isEyeClosed:X,blurScore:eo,qualifyScore:eu,realQualifyScore:eh,qualifyModelMessage:ed,brightnessScore:er,faceError:U}});w&&e_&&a===v.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,F,a,S,w,eb,ei.left,ei.top,ei.right,ei.bottom,J,H,O,B,P.enable,P.threshold,D.enable,D.threshold,I.enable,I.threshold,N.enable,N.threshold,R,Z,ee,et,es,h,el,Y,Q,l,c,W,ep,$,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 $=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}},J=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,v as S,T as W,D as a,I as b,j as c,F as d,N as e,x as f,X as g,P as h,B as i,$ as j,H as k,M as l,J as m,L as n,ee as o,ea as p,eo as q,Y as r,z as s,O as u};
@@ -0,0 +1 @@
1
+ let e;import{d as t,r as s,j as n,a as i,a8 as l,c as r,a7 as a,a9 as o,a1 as c,u as u,g as g,p as d,s as S,I as h,V as v}from"./chunk-27713cdc.js";import{c as j,e as f,b as p,D as b,S as x}from"./chunk-9803c4f4.js";let k=s.createContext({}),y={},C=({children:e,enableGetClientSettings:i,clientSettings:l,apiCredentials:r,flowId:a})=>{let{apiClient:o}=t.useApiClient({apiCredentials:r}),[c,u]=s.useState({}),[g,d]=s.useState(!1);s.useEffect(()=>{i?async function e(){try{if(!o||"function"!=typeof o.clientSettings)return;let e=await o.clientSettings({flow_id:a});u(e)}catch(e){console.error(e)}finally{d(!0)}}():d(!0)},[i,o,a]);let S=y;return(l&&Object.keys(l).length>0?S=l:i&&(S=c),g)?n.jsx(k.Provider,{value:S,children:e}):null},m=()=>s.useContext(k),_=({children:e,onError:t})=>{let s=m();return n.jsx(i.LicenseProvider,{clientSettings:s,onError:t,children:e})},E=({children:e,onError:t,type:s})=>{let i=m();return n.jsx(l.Provider,{clientSettings:i,type:s,onError:t,children:e})},D={},P=({children:e,customTexts:t=D})=>{let s=m(),{lang:i,uiSettings:l}=r.useSDKSettings(),c=a({customTexts:t,clientSettings:s,lang:i,uiSettings:l});return n.jsx(o.SDKLocaleProvider,{value:c,children:e})},L={},B=({children:e,customTheme:t=L})=>{let s=m(),{uiSettings:i,themeVersion:l}=r.useSDKSettings(),a=j({customTheme:t,clientSettings:s,themeVersion:l,uiSettings:i,defaultThemes:f});return n.jsx(c,{theme:a,children:e})},z=v.lazy(()=>import("./chunk-1ffc8702.js")),w=v.lazy(()=>import("./chunk-0042305b.js")),A=v.lazy(()=>import("./chunk-cc109f43.js")),I=v.lazy(()=>import("./chunk-ec2cd6ff.js")),K=v.lazy(()=>import("./chunk-c385606a.js")),V=v.lazy(()=>import("./chunk-9462231f.js"));var T=(e=e=>{var t,i,l;let a,{logCredentials:o={enable:!1},livenessComponent:c,customTheme:v={},customTexts:j,...f}=e,{mode:k,flowId:y,onError:C,onClose:D,debug:L,onLivenessDetectionDone:T}=f,W=m(),{billingSettings:M,enableBilling:O,themeVersion:G}=r.useSDKSettings(),F=u.getWebSetting(W,"data.settings.sdk_settings.billing_settings.billing_config"),{submitBilling:U}=g({enable:O,onError:C,billingSettings:M??{json:F??{}},billingUrl:u.getWebSetting(W,"data.settings.sdk_settings.billing_settings.url")}),$=d.buildBillingInput(e),q=p(),H="face_authen"===q?S.BillingService.faceAuth:S.BillingService.selfie,J=s.useCallback(async(...e)=>{if("face_authen"===q)return void await T(...e);try{if(!await U({service:H,input:$,output:{...d.buildBillingOutput(e?.[0]||{}),sdkStatus:S.BillingStatus.success}}))return}catch(e){console.error(e)}await T(...e)},[$,H,q,T,U]),N=s.useCallback(e=>{S.ErrorsWithoutBilling.includes(e.code)?C(e):(U({service:H,input:$,output:{error:e,sdkStatus:S.BillingStatus.fail}}),C&&C(e))},[U,H,$,C]),Q=s.useCallback(()=>{U({service:H,input:$,output:{sdkStatus:S.BillingStatus.cancel}}),D&&D()},[U,H,$,D]),R=(t=k,i=c,l=G,a=I,t===S.Mode.ACTIVE&&(a=i?.ActiveLiveness??("v1"===l?K:I)),t===S.Mode.PASSIVE_V2&&(a=i?.PassiveLivenessV2??A),t===S.Mode.PASSIVE&&(a=i?.PassiveLiveness??("v1"===l?V:w)),"string"==typeof t&&t.startsWith("flash")&&(a=i?.FlashLiveness??z),a);return n.jsx(b,{debug:L,children:n.jsx(x,{onDone:T,onError:N,onClose:Q,children:n.jsx(P,{customTexts:j,children:n.jsx(E,{onError:N,type:"face_authen"===y?"face_auth":"liveness",children:n.jsx(_,{onError:C,children:n.jsx(B,{customTheme:v,children:n.jsx(h.SDKTrackingProvider,{value:{tracking:{...o}},children:n.jsx(s.Suspense,{fallback:null,children:n.jsx(R,{...f,onLivenessDetectionDone:J})})})})})})})})})},function(t){let{apiCheck:s,apiCredentials:i,serviceSettings:l,flowId:r,clientSettings:a}=t,o=s&&(l?.enableGetClientSettings??!0);return n.jsx(C,{enableGetClientSettings:o,clientSettings:a,apiCredentials:i,flowId:r,children:n.jsx(e,{...t})})}),W=Object.freeze({__proto__:null,default:T});export{C as C,T as L,P as S,W as i,m as u};