@incodetech/welcome 1.72.0-rc.20240614183418 → 1.72.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.
@@ -5,7 +5,7 @@ export declare const sources: {
5
5
  };
6
6
  type Keys = keyof typeof sources;
7
7
  type SourcesType = (typeof sources)[Keys];
8
- export declare const sendZoomedFrame: ({ source, base64Image, token, }: {
8
+ export declare const logFrame: ({ source, base64Image, token, }: {
9
9
  source: SourcesType;
10
10
  base64Image: string;
11
11
  token: string;
@@ -13,4 +13,4 @@ export declare const sendZoomedFrame: ({ source, base64Image, token, }: {
13
13
  success: boolean;
14
14
  }>;
15
15
  export {};
16
- //# sourceMappingURL=sendZoomedFrame.d.ts.map
16
+ //# sourceMappingURL=logFrame.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logFrame.d.ts","sourceRoot":"","sources":["../../../../src/camera/logFrame.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,OAAO;;;;CAIV,CAAC;AAEX,KAAK,IAAI,GAAG,MAAM,OAAO,OAAO,CAAC;AACjC,KAAK,WAAW,GAAG,CAAC,OAAO,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC;AAC1C,eAAO,MAAM,QAAQ;YAKX,WAAW;iBACN,MAAM;WACZ,MAAM;;aAGM,OAAO;EAgB3B,CAAC"}
@@ -22122,12 +22122,12 @@ const DetectionSetup$1 = DetectionSetup.getInstance(), sources = {
22122
22122
  front: "FRONT_ID",
22123
22123
  back: "BACK_ID",
22124
22124
  selfie: "SELFIE"
22125
- }, sendZoomedFrame = async ({
22125
+ }, logFrame = async ({
22126
22126
  source: ue,
22127
22127
  base64Image: me,
22128
22128
  token: Ue
22129
22129
  }) => api.post(
22130
- "/omni/zoomed-frame/v2",
22130
+ "/omni/log/frame/v2",
22131
22131
  {
22132
22132
  base64Image: me
22133
22133
  },
@@ -22173,10 +22173,10 @@ function useSelfie({
22173
22173
  return;
22174
22174
  }
22175
22175
  const dn = Sn.getImageData(), yn = Sn.getBase64Image();
22176
- sendZoomedFrame({
22176
+ logFrame({
22177
22177
  token: Ge,
22178
22178
  base64Image: yn,
22179
- source: "SELFIE"
22179
+ source: sources.selfie
22180
22180
  }), await MlWasmJSApi$1.allocateImageBuffers(dn.width, dn.height);
22181
22181
  const nn = await MlWasmJSApi$1.runSelfieCapture(dn);
22182
22182
  if (nn.faces.size() > 0) {
@@ -53048,7 +53048,7 @@ function renderUserConsent(ue, {
53048
53048
  })
53049
53049
  }), ue, He);
53050
53050
  }
53051
- const version = "1.72.0-rc.20240614183418";
53051
+ const version = "1.72.0";
53052
53052
  function r(ue) {
53053
53053
  for (var me = "", Ue = 0; Ue < ue.length; ++Ue)
53054
53054
  if (Ue > 0) {
@@ -109620,7 +109620,7 @@ function CaptureId({
109620
109620
  return;
109621
109621
  }
109622
109622
  const ea = ai.getImageData(), Kr = ai.getBase64Image();
109623
- sendZoomedFrame({
109623
+ logFrame({
109624
109624
  base64Image: Kr,
109625
109625
  token: tt == null ? void 0 : tt.token,
109626
109626
  source: sources[Ue]
@@ -1402,7 +1402,7 @@ https://fb.me/react-async-component-lifecycle-hooks`)}if(typeof ue.getDerivedSta
1402
1402
  overflow: hidden;
1403
1403
  margin: auto;
1404
1404
  }
1405
- `,isAndroid=!!mobile.Android(),isJ7Prime=!!mobile.J7Prime(),isAlcatel1x=!!mobile.Alcatel1x(),isLenovoVibeB=!!mobile.LenovoVibeB(),isDesktop=mobile.isDesktop(),parser=new UAParser,{browser:browser$1}=parser.getResult(),onFrameEmitter=new eventsExports.EventEmitter,Webcam=React$1.forwardRef(({className:ue,onPlay:me,videoSource:Ue,isSelfie:Qe=!1,type:Ze,permissionMessage:Je,onLog:Ge=emptyFunc,stream:He,onError:Xe=emptyFunc,token:$e,interviewId:Ke,onStreamReady:nt=emptyFunc,showCustomCameraPermissionScreen:tt,assistedOnboarding:et,deviceId:rt,onRestartOnboarding:it=reload,showDoublePermissionsRequest:ot=!1,publishAudio:at=!1,fullHeight:st=!1,isRecordingEnabled:ct=!1,isKiosk:lt=!1},dt)=>{const[ft,gt]=React$1.useState(!1),[pt,Tt]=React$1.useState(He),[Rt,bt]=React$1.useState(!0),[At,Nt]=React$1.useState(!0),[mt,Ut]=React$1.useState(!1),Mt=React$1.useRef(null),yt=React$1.useRef(),vt=React$1.useRef(0),{t:xt}=useTranslation(),[Et,Ct]=usePermissions(),wt=React$1.useRef(),Ft=React$1.useRef(!1);wt.current=Et;const[Lt,Jt]=React$1.useState(!ot);Je=Je||xt("permissionMessage"),React$1.useEffect(()=>{wt.current&&!isDesktop&&!lt&&Jt(wt.current)},[Et]),React$1.useEffect(()=>{const _t=sessionStorage.getItem("cameraPermissionsGranted")==="true";!isDesktop&&_t&&!lt&&Jt(!0)},[Et]),React$1.useEffect(()=>{const _t=Mt.current;return()=>{_t.pause(),_t.srcObject=null}},[]),React$1.useEffect(()=>()=>{pt==null||pt.getTracks().forEach(_t=>_t.stop())},[pt]),React$1.useEffect(()=>{let _t=0;const sn=()=>{if(!mt)return;if(!Mt.current){Ut(!1);return}if(Mt.current.paused){Ut(!1),_t=0;return}const cn=Mt.current.currentTime;cn!==_t&&(onFrameEmitter.emit("newFrame"),_t=cn),requestAnimationFrame(sn)};requestAnimationFrame(sn)},[mt]);const Qt=React$1.useCallback(()=>{var _t,sn,cn;if(!document.hidden)return(sn=(_t=Mt.current)==null?void 0:_t.srcObject)==null||sn.clone(),(cn=Mt.current)==null?void 0:cn.play()},[]);useEventListener("visibilitychange",Qt,document);const $t=async _t=>{const sn=_t.getVideoTracks()[0],cn=await getDeviceCapabilities(),fn=getChosenCameraInfo(sn,vt.current,Ue),{width:hn,height:An}=sn.getSettings(),{focusMode:en=!1}=navigator.mediaDevices.getSupportedConstraints();addEvent({code:"cameraType",payload:{type:"webRTC",resolution:`${hn}x${An}`,autofocus:en,label:sn.label},token:$e}),addEvent({code:"cameraDebugInfo",payload:{type:"webRTC",availableCameras:cn,chosenCamera:fn},token:$e}),Qe&&addEvent({code:"cameraSelfie",token:$e})},Gt=_t=>{Nt(!1),_t.constructor.name==="DOMException"?(addEvent({code:"permissionDenied",payload:{message:"User denied to use camera."},token:$e}),Ge(getLogObject("permissionDenied",{message:"User denied to use camera."})),_t.type="permissionDenied",tt?gt(!0):Xe(_t)):_t.constructor.name==="OverconstrainedError"?(Ge(getLogObject("OSVersionNotSupported",{message:"OS version is not supported."})),bt(!1)):(Ge(getLogObject("browserNotSupported",{message:"Browser is not supported."})),bt(!1))},Pt=async _t=>{Ct(!0);const sn=()=>{Mt.current.srcObject=_t,nt(_t),Tt(_t),ct||Nt(!1)},cn=_t.getVideoTracks()[0];MlWasmJSApi$1.isVirtualCamera(cn.label)&&Xe(new Error("Virtual camera is detected")),mobile.iOS()?cn.applyConstraints({advanced:[{focusDistance:1}]}).finally(()=>{sn()}):sn()};React$1.useEffect(()=>((async()=>{function sn(hn){const An={resizeMode:"none",facingMode:"environment"};switch(hn){case 0:return{...An,height:{ideal:localStorage.getItem("isIPhone14OrHigher")==="true"?1080:720}};case 1:return{...An,width:{min:3200,ideal:3840,max:4096},height:{min:1800,ideal:2160,max:2400}};case 2:return{...An,width:{min:1400,ideal:1920,max:2160},height:{min:900,ideal:1080,max:1440}};case 3:return{...An,width:{min:640,ideal:640,max:800},height:{min:480,ideal:480,max:600}};case 4:return{...An,width:{min:640,ideal:800,max:960},height:{min:480,ideal:480,max:480}};default:return{}}}const cn=async hn=>{const An={video:Ue==="environment"?sn(hn.current):localStorage.getItem("isIPhone14OrHigher")==="true"?{height:{ideal:1080}}:{facingMode:Ue,height:{ideal:480},width:{ideal:640}},audio:at},un={audio:isSafari()||at,video:{facingMode:"user",deviceId:rt?{exact:rt}:void 0}};if(mobile.isIpad()&&Ue==="user")try{const gn=await getNonUltraWideFrontCameraStream();Pt(gn),await $t(gn)}catch(gn){Xe({...gn,type:"permissionDenied"})}else isAndroid&&Ue==="environment"?navigator.mediaDevices.getUserMedia(An).then(async gn=>{const Sn=gn.getVideoTracks()[0],dn=await getCameras(),yn=adjustCamerasFromCameraStream(Sn,dn);gn.getTracks().forEach(tn=>tn.stop());let nn=1280,Xt=720;if(hn.current>1||isJ7Prime||isAlcatel1x||isLenovoVibeB){const{width:tn,height:ln}=sn(isJ7Prime?2:isAlcatel1x||isLenovoVibeB?4:hn.current);nn=tn==null?void 0:tn.ideal,Xt=ln==null?void 0:ln.ideal}const Kt={video:{deviceId:{exact:yn.deviceId},width:{ideal:nn},height:{ideal:Xt}}};navigator.mediaDevices.getUserMedia(Kt).then(async tn=>{await $t(tn),Pt(tn)})}).catch(gn=>{hn.current=hn.current+1,hn.current>4?Gt(gn):cn(hn)}):navigator.mediaDevices.getUserMedia(mobile.any()?An:un).then(async gn=>{await $t(gn),Pt(gn)}).catch(gn=>{Gt(gn)})};if(mobile.iOS()&&Ft.current)return;if(Lt===!0||isDesktop||lt||ot===!1){if(Ft.current=!0,He){Pt(He);return}Nt(!0),cn(vt),addEvent({token:$e,code:"cameraFeedbackDisplayed",payload:{feedback:"Loading..."},module:"ID Capture",screen:`${Ze} Camera Capture`})}const fn=document.createElement("canvas");yt.current=fn})(),()=>{Lt&&(Ft.current=!1,He==null||He.getTracks().forEach(sn=>sn.stop()))}),[Lt,Ue,He]),React$1.useImperativeHandle(dt,()=>({getCanvas:Dt,video:Mt.current,stream:pt,setIsLoadingCamera:Nt}));const jt=({width:_t=0,height:sn=0,useOriginalDimensions:cn=!0})=>{if(!Mt.current||!Mt.current.videoHeight||!Mt.current.videoWidth||!yt.current)return!1;if(cn)yt.current.width=Mt.current.videoWidth,yt.current.height=Mt.current.videoHeight;else{if(_t===0||sn===0)return!1;yt.current.width=_t,yt.current.height=sn}const fn=yt.current.getContext("2d");return fn.clearRect(0,0,yt.current.width,yt.current.height),fn.drawImage(Mt.current,0,0),!0},Dt=({width:_t=0,height:sn=0,useOriginalDimensions:cn=!0}={})=>jt({width:_t,height:sn,useOriginalDimensions:cn})?new IncodeCanvas(yt.current):null,ut=()=>Mt.current?Mt.current.videoWidth>Mt.current.videoHeight:!1,It=()=>{Jt(!0),sessionStorage.setItem("cameraPermissionsGranted",String(!0)),addEvent({token:$e,code:"permissionsAllowedCustom"}),addEvent({token:$e,code:"cameraPermissionSubmitted",payload:{requestor:"browser",requestorDetails:browser$1.name,permission:"allowed"},module:"ID capture",screen:`${Ze} Camera Capture`})},Vt=()=>{addEvent({token:$e,code:"permissionsQuitFlow"}),setTimeout(()=>{window.location.reload()},0)},Ot=()=>{addEvent({token:$e,code:"permissionsDeniedCustom"}),addEvent({token:$e,code:"cameraPermissionSubmitted",payload:{requestor:"browser",requestorDetails:browser$1.name,permission:"denied"},module:"ID capture",screen:`${Ze} Camera Capture`})},Zt=sessionStorage.getItem("cameraPermissionsGranted")==="true",zt=ot&&(typeof Et<"u"&&!Et&&!Lt||typeof Lt<"u"&&!Lt)&&!isDesktop&&!lt&&!Zt,Ht=()=>{!mt&&me&&typeof me=="function"&&me(),Ut(!0)};return jsxs(React$1.Fragment,{children:[ft&&jsx(AllowCameraUse,{handleAllowCamera:it}),zt&&jsx(FakePermissionsRequest,{handleDenyPermission:Ot,handleCameraPermission:It,handleQuitOnboarding:Vt,type:Ze,token:$e,interviewId:Ke}),!Rt&&jsx(BrowserNotSupported,{}),At&&!zt&&jsx(Loader$1,{message:xt("webcam.loading"),fullScreen:!0}),jsx(Video$1,{"aria-hidden":"true",autoPlay:!0,className:classNames(ue,{selfie:Qe,horizontal:ut(),desktop:!mobile.any(),assistedOnboarding:et,"full-height":st}),playsInline:!0,onPlay:Ht,ref:Mt,muted:!0})]})}),captureButton="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI2NSIgaGVpZ2h0PSI2NSIgdmlld0JveD0iMCAwIDY1IDY1Ij4KICAgIDxnIGZpbGw9Im5vbmUiIGZpbGwtcnVsZT0iZXZlbm9kZCI+CiAgICAgICAgPGc+CiAgICAgICAgICAgIDxnPgogICAgICAgICAgICAgICAgPGcgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoLTE1NSAtNjQ2KSB0cmFuc2xhdGUoMTU1IDY0NikiPgogICAgICAgICAgICAgICAgICAgIDxjaXJjbGUgY3g9IjMyLjMxOSIgY3k9IjMyLjMxOSIgcj0iMzIuMzE5IiBmaWxsPSIjMjAyNjNEIi8+CiAgICAgICAgICAgICAgICAgICAgPGNpcmNsZSBjeD0iMzIuMzE5IiBjeT0iMzIuMzE5IiByPSIyNS4xMzciIGZpbGw9IiNGRkYiIGZpbGwtb3BhY2l0eT0iLjA5MyIgc3Ryb2tlPSIjRkZGIiBzdHJva2Utd2lkdGg9IjIuMDUyIi8+CiAgICAgICAgICAgICAgICA8L2c+CiAgICAgICAgICAgICAgICA8ZyBmaWxsPSIjRkZGIiBmaWxsLXJ1bGU9Im5vbnplcm8iPgogICAgICAgICAgICAgICAgICAgIDxwYXRoIGQ9Ik0xNy4xOTMgMTIuMjRjMCAyLjI5NC0xLjg4IDQuMTYtNC4xOTMgNC4xNi0yLjMxMiAwLTQuMTkyLTEuODY2LTQuMTkyLTQuMTYgMC0yLjI5MyAxLjg4LTQuMTYgNC4xOTItNC4xNiAyLjMxMiAwIDQuMTkzIDEuODY3IDQuMTkzIDQuMTZ6TTI2IDYuMzM0djExLjgxNEMyNiAxOS43MjMgMjQuNzEzIDIxIDIzLjEyNSAyMUgyLjg3NUMxLjI4NyAyMSAwIDE5LjcyMyAwIDE4LjE0OFY2LjMzNEMwIDQuNzYgMS4yODcgMy40ODIgMi44NzUgMy40ODJoMy41MzZ2LS45ODdDNi40MTEgMS4xMTcgNy41MzcgMCA4LjkyNyAwaDguMTQ2YzEuMzkgMCAyLjUxNiAxLjExNyAyLjUxNiAyLjQ5NXYuOTg2aDMuNTM2QzI0LjcxMyAzLjQ4MiAyNiA0Ljc2IDI2IDYuMzM0em0tNi42NSA1LjkwNmMwLTMuNDczLTIuODQ5LTYuMjk4LTYuMzUtNi4yOTgtMy41IDAtNi4zNDkgMi44MjUtNi4zNDkgNi4yOThTOS41IDE4LjU0IDEzIDE4LjU0YzMuNTAxIDAgNi4zNS0yLjgyNiA2LjM1LTYuMjk5eiIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoLTE1NSAtNjQ2KSB0cmFuc2xhdGUoMTU1IDY0NikgdHJhbnNsYXRlKDE5IDIxKSIvPgogICAgICAgICAgICAgICAgPC9nPgogICAgICAgICAgICA8L2c+CiAgICAgICAgPC9nPgogICAgPC9nPgo8L3N2Zz4K",faceFrame$1="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIzMzYiIGhlaWdodD0iNTE4IiB2aWV3Qm94PSIwIDAgMzM2IDUxOCI+CiAgICA8cGF0aCBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIHN0cm9rZT0iI0ZGRiIgc3Ryb2tlLWRhc2hhcnJheT0iNy4xMzk5OTk2NzU3NTA3MzIsMTkuMDM5OTk5Njc1NzUwNzMiIHN0cm9rZS13aWR0aD0iOS4wNDQiIGQ9Ik0xNjggNTEzLjM5MmM3Ni44MyAwIDE2Mi44OTMtMTEzLjkyIDE2Mi44OTMtMjU0LjQ0N1MyODAuMjM2IDQuNDk4IDE2OCA0LjQ5OCA1LjEwNyAxMTguNDE4IDUuMTA3IDI1OC45NDUgOTEuMTcgNTEzLjM5MiAxNjggNTEzLjM5MnoiLz4KPC9zdmc+Cg==",deviceStatsQueue=[];let isReady=!1;function addDeviceStats(ue,me){if(!isReady){deviceStatsQueue.push(me);return}return exports.api.post("/omni/device/stats",me,{headers:{"X-Incode-Hardware-Id":ue}}).catch(()=>{})}function emptyDeviceStatsQueue(ue){isReady=!0,deviceStatsQueue.forEach(me=>{addDeviceStats(ue,me)})}class FaceDetection{constructor(){this.pipelineProfile=null,this.bestCanvas=null,this.bestLandmarks=null,this.bestTopLeft=null,this.bestSize=null,this.currCanvas=null}formatLandmarks(me,Ue,Qe){const[Ze,Je,Ge,He,Xe,$e,Ke,nt,tt,et]=me;return{rightEyeX:Ze,rightEyeY:Je,leftEyeX:Ge,leftEyeY:He,noseTipX:Xe,noseTipY:$e,rightMouthX:Ke,rightMouthY:nt,mouthX:tt,mouthY:et,x:Ue[0],y:Ue[1],width:Qe[0],height:Qe[1]}}async initialize(me){const{onNoFace:Ue,onCapturing:Qe,onCapture:Ze,onTooManyFaces:Je,onTooClose:Ge,onCenterFace:He,onFarAway:Xe,onFaceAngle:$e,onDark:Ke,onBlur:nt,onHeadWear:tt,onLenses:et,onEyesClosed:rt,onFaceMask:it,onSwitchToManualCapture:ot,isLensesCheckEnabled:at,isMaskCheckEnabled:st,isClosedEyesCheckEnabled:ct,isHeadWearCheckEnabled:lt,isVideoSelfie:dt,pipelineProfile:ft,autocaptureTimeout:gt}=me;this.pipelineProfile=ft;const pt=this.pipelineProfile.pipelineType;await MlWasmJSApi$1.setFacePositionConstraints(pt,ft.parameters.frameMinX,ft.parameters.frameMinY,ft.parameters.frameMaxX,ft.parameters.frameMaxY),await MlWasmJSApi$1.setFaceDetectionThresholds(pt,ft.parameters.brightnessThreshold,ft.parameters.blurrinessThreshold,ft.parameters.tiltRotationAngleThreshold,ft.parameters.minMagicCropSize,gt),await MlWasmJSApi$1.setFaceAttributesEnabled(pt,at,st,ct,lt),await MlWasmJSApi$1.setFaceAttributesThresholds(pt,ft.parameters.headwearThreshold,ft.parameters.lensesThreshold,ft.parameters.closedEyesThreshold,ft.parameters.maskThreshold),await MlWasmJSApi$1.setFaceDetectionMode(pt,dt);const Tt=()=>{this.bestCanvas.updateBase64Image(),this.bestCanvas.updateBlob(),Ze(this.bestCanvas,this.formatLandmarks(this.bestLandmarks,this.bestTopLeft,this.bestSize))},Rt=bt=>{this.bestCanvas=this.currCanvas.clone();const At=bt.rect;this.bestTopLeft=[At.x,At.y];const Nt=[At.x+At.width,At.y+At.height],mt=this.bestTopLeft,Ut=Nt;this.bestSize=[Ut[0]-mt[0],Ut[1]-mt[1]],this.bestLandmarks=[bt.rightEye.x,bt.rightEye.y,bt.leftEye.x,bt.leftEye.y,bt.noseTip.x,bt.noseTip.y,bt.rightMouthCorner.x,bt.rightMouthCorner.y,bt.leftMouthCorner.x,bt.leftMouthCorner.y]};await MlWasmJSApi$1.setFaceDetectionCallbacks(pt,Xe,Ge,Je,Ue,Tt,Qe,He,Ke,nt,$e,Rt,et,it,rt,tt,ot)}async detect(me){try{this.currCanvas=me,await MlWasmJSApi$1.allocateImageBuffers(me.width(),me.height()),await MlWasmJSApi$1.process(me.getImageData(),PipelineType.SelfieFaceDetectionPipeline)}catch(Ue){console.error(`Exception: ${Ue}`)}}}const state={token:null};var PipelineProfileType=(ue=>(ue[ue.IdCaptureBrazilian=0]="IdCaptureBrazilian",ue[ue.IdCaptureVisas=1]="IdCaptureVisas",ue[ue.IdVideoSelfieBrazilian=2]="IdVideoSelfieBrazilian",ue[ue.IdVideoSelfieVisas=3]="IdVideoSelfieVisas",ue[ue.SelfieFaceDetection=4]="SelfieFaceDetection",ue))(PipelineProfileType||{});class PipelineProfile{constructor(me,Ue,Qe,Ze,Je=null,Ge=""){this.pipelineType=me,this.profileType=Ue,this.modelNames=Qe,this.parameters=Ze,this.paramsConfigurator=Je,this.description=Ge}reconfigureParams(me=null){if(this.paramsConfigurator==null)throw new Error("PipelineProfile does not have a paramsConfigurator");this.paramsConfigurator(this.parameters,this.pipelineType,me)}}function IdCaptureParamsConfigurator(ue,me,Ue){Object.assign(ue,{areaDown:Ue?55e3:25e3,areaUp:Ue?75e3:55e3,areaIOSPassportUp:3e4,areaIOSPassportDown:2e4,widthIOSUp:me==PipelineType.IdCapturePipeline?125:180,widthIOSDown:me==PipelineType.IdCapturePipeline?85:150,widthDown:Ue?185:135,widthUp:Ue?255:205})}const SelfieFaceDetectionPipelineParams={frameMinX:0,frameMinY:0,frameMaxX:1,frameMaxY:1,brightnessThreshold:50,blurrinessThreshold:50,tiltRotationAngleThreshold:15,minMagicCropSize:200,headwearThreshold:.95,lensesThreshold:.95,closedEyesThreshold:.9,maskThreshold:.5},pipelineProfiles=[new PipelineProfile(PipelineType.IdCapturePipeline,PipelineProfileType.IdCaptureBrazilian,["brazilian_mobile_025_ep199_fp16.ortmodelv2"],{glareThreshold:.2,classificationThreshold:.98,sharpnessThreshold:.3,sharpnessChangeThreshold:.3},IdCaptureParamsConfigurator,"Id Capture Profile with brazilian_mobile model"),new PipelineProfile(PipelineType.IdCapturePipeline,PipelineProfileType.IdCaptureVisas,["visas_mobile_025_best_v1_03_fp16.ortmodelv2"],{glareThreshold:.3,classificationThreshold:.98,sharpnessThreshold:.2,sharpnessChangeThreshold:.2},IdCaptureParamsConfigurator,"Id Capture Profile with visas_mobile model"),new PipelineProfile(PipelineType.IdVideoSelfiePipeline,PipelineProfileType.IdVideoSelfieBrazilian,["brazilian_mobile_025_ep199_fp16.ortmodelv2"],{glareThreshold:.2,classificationThreshold:.9,sharpnessThreshold:.3,sharpnessChangeThreshold:.3},IdCaptureParamsConfigurator,"Id Videoselfie profile with brazilian_mobile model"),new PipelineProfile(PipelineType.IdVideoSelfiePipeline,PipelineProfileType.IdVideoSelfieVisas,["visas_mobile_025_best_v1_03_fp16.ortmodelv2"],{glareThreshold:.3,classificationThreshold:.9,sharpnessThreshold:.2,sharpnessChangeThreshold:.2},IdCaptureParamsConfigurator,"Id Videoselfie Profile with visas_mobile model"),new PipelineProfile(PipelineType.SelfieFaceDetectionPipeline,PipelineProfileType.SelfieFaceDetection,["selfie_bf_angles_192x192_opset9_fp16.ortmodelv2","bf_attrib_31b8f9d92fb345c2b4bbdd222792562c_0_fp16.ortmodelv2","mls_regressor_4773007c657b4f05a460321456740d0f_fp16.ortmodelv2"],SelfieFaceDetectionPipelineParams,null,"Selfie face detection profile")];function getProfile(ue){const me=pipelineProfiles.find(Ue=>Ue.profileType===ue);if(!me)throw new Error(`Profile not found for type: ${ue}`);return me}const probabilityThreshold=.9,wasmVersion="v1.8.2",brazilianPipelineBundle=[PipelineProfileType.IdCaptureBrazilian,PipelineProfileType.IdVideoSelfieBrazilian,PipelineProfileType.SelfieFaceDetection],visasPipelineBundle=[PipelineProfileType.IdCaptureVisas,PipelineProfileType.IdVideoSelfieVisas,PipelineProfileType.SelfieFaceDetection],PipelinesBundle=new Map([["brazilianPipelineBundle",brazilianPipelineBundle],["visasPipelineBundle",visasPipelineBundle]]);function switchBundle(){return Math.random()<probabilityThreshold?"brazilianPipelineBundle":"visasPipelineBundle"}function getInitializationParams(ue){const Ue=ue?switchBundle():"brazilianPipelineBundle",Qe="https://d3vv997wtl2myz.cloudfront.net/webcamera/onnx-backend-wasm",Ze=`${Qe}/${wasmVersion}/webLib.wasm`,Je=`${Qe}/${wasmVersion}/webLibSimd.wasm`,Ge=`${Qe}/${wasmVersion}/webLib.js`,He=`${Qe}/${wasmVersion}/versions.json`;let Xe=new Map,$e=new Map;for(const Ke of PipelinesBundle.get(Ue)){const nt=getProfile(Ke);if(!nt)throw new Error(`Profile not found for type: ${Ke}`);const tt=nt.modelNames;let et=[];for(const rt of tt)et.push(`${Qe}/${wasmVersion}/models/${rt}`);Xe.set(nt.pipelineType,et),$e.set(nt.pipelineType,nt)}return{wasmModulePath:Ze,wasmSimdModulePath:Je,glueCodePath:Ge,versionsFilePath:He,pipelineModels:Xe,enableSIMD:!0,bundle:Ue,profiles:$e}}class MotionStatusCheck{constructor(me,Ue,Qe,Ze,Je,Ge,He,Xe,$e,Ke,nt,tt){this.isRunning_=!1,this.acl_=null,this.gyro_=null,this.permission_=!0,this.minNumberOfFrames_=3,this.maxFrequency_=60,this.emptyParams={meanX:0,meanY:0,meanZ:0,m2X:0,m2Y:0,m2Z:0,cumulativeAbsErrorX:0,cumulativeAbsErrorY:0,cumulativeAbsErrorZ:0,ptsNum:0},this.paramsAcc_={...this.emptyParams},this.paramsGyro_={...this.emptyParams},this.paramsAccGrOld_={...this.emptyParams},this.paramsAccOld_={...this.emptyParams},this.paramsGyroscopeOld_={...this.emptyParams},this.paramsOrientationOld_={...this.emptyParams},this.waitForClick=()=>new Promise(et=>{document.addEventListener("click",async()=>{const rt=await this.requestMotionPermission();et(rt)},{once:!0})}),this.deviceMotionListener=et=>{if(et.accelerationIncludingGravity){const rt={x:et.accelerationIncludingGravity.x,y:et.accelerationIncludingGravity.y,z:et.accelerationIncludingGravity.z};this.checkFields(rt)&&(this.paramsAccGrOld_.ptsNum+=1,this.updateParams(this.paramsAccGrOld_,rt))}if(et.acceleration){const rt={x:et.acceleration.x,y:et.acceleration.y,z:et.acceleration.z};this.checkFields(rt)&&(this.paramsAccOld_.ptsNum+=1,this.updateParams(this.paramsAccOld_,rt))}if(et.rotationRate){const rt={x:et.rotationRate.alpha,y:et.rotationRate.beta,z:et.rotationRate.gamma};this.checkFields(rt)&&(this.paramsGyroscopeOld_.ptsNum+=1,this.updateParams(this.paramsGyroscopeOld_,rt))}},this.deviceOrientationListener=et=>{const rt={x:et.alpha,y:et.beta,z:et.gamma};this.checkFields(rt)&&(this.paramsOrientationOld_.ptsNum+=1,this.updateParams(this.paramsOrientationOld_,rt))},this.accThreshold_=me,this.gyroThreshold_=Ue,this.accGrOldThreshold_=Qe,this.accOldThreshold_=Ze,this.gyroscopeOldThreshold_=Je,this.orientationOldThreshold_=Ge,this.maeAccThreshold_=He,this.maeGyroThreshold_=Xe,this.maeAccGrOldThreshold_=$e,this.maeAccOldThreshold_=Ke,this.maeGyroscopeOldThreshold_=nt,this.maeOrientationOldThreshold_=tt}async requestMotionPermission(){DeviceMotionEvent&&typeof DeviceMotionEvent.requestPermission=="function"&&DeviceMotionEvent.requestPermission().then(me=>{me!=="granted"&&(this.permission_=!1)}).catch(console.error)}initializeAccelerometer(){if("Accelerometer"in window)try{this.acl_=new window.Accelerometer({frequency:this.maxFrequency_}),this.acl_.addEventListener("reading",()=>this.updateAcc())}catch{}}initializeGyroscope(){if("Gyroscope"in window)try{this.gyro_=new window.Gyroscope({frequency:this.maxFrequency_}),this.gyro_.addEventListener("reading",()=>this.updateGyro())}catch{}}async start(){this.run()}run(){if(!(this.isRunning_||!this.permission_)){try{this.initializeAccelerometer(),this.acl_.start()}catch{}try{this.initializeGyroscope(),this.gyro_.start()}catch{}window.addEventListener("devicemotion",this.deviceMotionListener),window.addEventListener("deviceorientation",this.deviceOrientationListener),this.isRunning_=!0}}stop(){this.isRunning_=!1,this.acl_&&this.acl_.stop(),this.gyro_&&this.gyro_.stop(),window.removeEventListener("devicemotion",this.deviceMotionListener),window.removeEventListener("deviceorientation",this.deviceOrientationListener),this.paramsAcc_={...this.emptyParams},this.paramsGyro_={...this.emptyParams},this.paramsAccGrOld_={...this.emptyParams},this.paramsAccOld_={...this.emptyParams},this.paramsGyroscopeOld_={...this.emptyParams},this.paramsOrientationOld_={...this.emptyParams}}updateAcc(){if(!(!this.isRunning_||!this.acl_)&&(this.paramsAcc_.ptsNum+=1,this.acl_)){const me={x:this.acl_.x,y:this.acl_.y,z:this.acl_.z};this.checkFields(me)&&this.updateParams(this.paramsAcc_,me)}}updateGyro(){if(!(!this.isRunning_||!this.gyro_)&&(this.paramsGyro_.ptsNum+=1,this.gyro_)){const me={x:this.gyro_.x,y:this.gyro_.y,z:this.gyro_.z};this.checkFields(me)&&this.updateParams(this.paramsGyro_,me)}}check(){if(!this.permission_)return"UNCLEAR";const me=this.checkStability();return me===null?"UNCLEAR":me?"FAIL":"PASS"}checkStability(){if(!this.isRunning_)return null;const Ue=[this.gyro_?this.isBelowStdThreshold(this.paramsGyro_,this.gyroThreshold_):null,this.acl_?this.isBelowStdThreshold(this.paramsAcc_,this.accThreshold_):null,this.isBelowStdThreshold(this.paramsAccGrOld_,this.accGrOldThreshold_),this.isBelowStdThreshold(this.paramsAccOld_,this.accOldThreshold_),this.isBelowStdThreshold(this.paramsGyroscopeOld_,this.gyroscopeOldThreshold_),this.isBelowStdThreshold(this.paramsOrientationOld_,this.orientationOldThreshold_)].filter(He=>He!==null),Qe=Ue.length>0?Ue.every(He=>He):null,Je=[this.gyro_?this.isBelowMaeThreshold(this.paramsGyro_,this.maeGyroThreshold_):null,this.acl_?this.isBelowMaeThreshold(this.paramsAcc_,this.maeAccThreshold_):null,this.isBelowMaeThreshold(this.paramsAccGrOld_,this.maeAccGrOldThreshold_),this.isBelowMaeThreshold(this.paramsAccOld_,this.maeAccOldThreshold_),this.isBelowMaeThreshold(this.paramsGyroscopeOld_,this.maeGyroscopeOldThreshold_),this.isBelowMaeThreshold(this.paramsOrientationOld_,this.maeOrientationOldThreshold_)].filter(He=>He!==null),Ge=Je.length>0?Je.every(He=>He):null;return Qe===null?Ge===null?null:Ge:Ge!==null?Qe&&Ge:Qe}updateParams(me,Ue){const Qe=Ue.x-me.meanX,Ze=Ue.y-me.meanY,Je=Ue.z-me.meanZ;me.meanX+=Qe/me.ptsNum,me.meanY+=Ze/me.ptsNum,me.meanZ+=Je/me.ptsNum,me.m2X+=Qe*(Ue.x-me.meanX),me.m2Y+=Ze*(Ue.y-me.meanY),me.m2Z+=Je*(Ue.z-me.meanZ),me.cumulativeAbsErrorX+=Math.abs(Ue.x-me.meanX),me.cumulativeAbsErrorY+=Math.abs(Ue.y-me.meanY),me.cumulativeAbsErrorZ+=Math.abs(Ue.z-me.meanZ)}calculateStd(me){const Ue={x:me.m2X/me.ptsNum,y:me.m2Y/me.ptsNum,z:me.m2Z/me.ptsNum};return{x:Math.sqrt(Ue.x),y:Math.sqrt(Ue.y),z:Math.sqrt(Ue.z)}}calculateMae(me){return{x:me.cumulativeAbsErrorX/me.ptsNum,y:me.cumulativeAbsErrorY/me.ptsNum,z:me.cumulativeAbsErrorZ/me.ptsNum}}checkFields(me){return me.x!==null&&me.y!==null&&me.z!==null}isBelowStdThreshold(me,Ue){if(me.ptsNum<this.minNumberOfFrames_)return null;const Qe=this.calculateStd(me);return Qe.x<Ue&&Qe.y<Ue&&Qe.z<Ue}isBelowMaeThreshold(me,Ue){if(me.ptsNum<this.minNumberOfFrames_)return null;const Qe=this.calculateMae(me);return Qe.x<Ue&&Qe.y<Ue&&Qe.z<Ue}}class OnboardingAnalytics{constructor(){this.motionStatusCheck=null,this.estimatedPerformance=null,this.analysisStatus="",this.motionStatus="",this.pipelineLogs="",this.pipelinesBundle=null,this.simdIsEnabled=null,this.motionStatusCheck=new MotionStatusCheck(.3,.3,.3,.3,10,10,.3,.3,.3,.3,10,10)}static getInstance(){return OnboardingAnalytics.instance||(OnboardingAnalytics.instance=new OnboardingAnalytics),OnboardingAnalytics.instance}setPipelinesBundle(me){this.pipelinesBundle=me}setSimdIsEnabled(me){this.simdIsEnabled=me}getPipelineLogs(){return this.pipelineLogs}getMotionStatus(){return this.motionStatus}getAnalysisStatus(){return this.analysisStatus}async analyzeFrame(me){const Ue=await base64ToImageData(me);await MlWasmJSApi$1.analyzeFrame(Ue),this.updatePipelineStats()}async startOnboardingCheck(){this.motionStatusCheck.start()}estimatePerformance(){if(this.estimatedPerformance)return this.estimatedPerformance;this.estimatedPerformance=MlWasmJSApi$1.estimatePerformance()}updatePipelineStats(){if(MlWasmJSApi$1.isInitialized())try{const me=MlWasmJSApi$1.getPipelineState();if(me!==""){const Ue=JSON.parse(me);this.analysisStatus=Ue.statsAnalysisStatus,Ue.pipelinesBundle=this.pipelinesBundle?this.pipelinesBundle:"unknown",Ue.estimatedPerformance=this.estimatedPerformance,Ue.simdIsEnabled=this.simdIsEnabled,this.pipelineLogs=JSON.stringify(Ue),this.motionStatus===""&&(this.motionStatus=this.motionStatusCheck.check())}}catch(me){console.error(`Exception: ${me}`)}}}const OnboardingAnalytics$1=OnboardingAnalytics.getInstance();class DetectionSetup{constructor(){this.setupDetectPromise=null,this.isSetupDetect=!1,this.pipelinesBundle=null,this.profiles=null}static getInstance(){return DetectionSetup.instance||(DetectionSetup.instance=new DetectionSetup),DetectionSetup.instance}setIsIPhone14OrHigher(){if(!mobile.iOS())return;if(new URLSearchParams(window.location.search).get("smallFrame")==="true"){localStorage.setItem("isIPhone14OrHigher","true");return}localStorage.setItem("isIPhone14OrHigher",String(window.outerHeight===852&&window.outerWidth===393||window.outerHeight===932&&window.outerWidth===430||window.innerHeight===631&&window.innerWidth===375))}async setupDetect(){return this.setupDetectPromise?this.setupDetectPromise:(this.setupDetectPromise=this._runSetupDetect(),this.setupDetectPromise)}getPipelinesBundle(){return this.pipelinesBundle}getProfile(me){var Ue;return((Ue=this.profiles)==null?void 0:Ue.get(me))??null}async warmup(){for(;!MlWasmJSApi$1.isInitialized();)await new Promise(me=>setTimeout(me,100))}async _runSetupDetect(){var Ze,Je;if(this.isSetupDetect)return;addEvent({token:(Ze=state.token)==null?void 0:Ze.token,code:"modelLoadStart"}),this.setIsIPhone14OrHigher();const me=getInitializationParams(!1);this.pipelinesBundle=me.bundle,this.profiles=me.profiles,OnboardingAnalytics$1.setPipelinesBundle(this.pipelinesBundle),OnboardingAnalytics$1.startOnboardingCheck();const Ue=await MlWasmJSApi$1.initialize(me.wasmModulePath,me.wasmSimdModulePath,me.glueCodePath,me.enableSIMD,me.versionsFilePath,me.pipelineModels);for(;!MlWasmJSApi$1.isInitialized();)await new Promise(Ge=>setTimeout(Ge,100));OnboardingAnalytics$1.estimatePerformance(),OnboardingAnalytics$1.setSimdIsEnabled(Ue),await MlWasmJSApi$1.initializePipelines();const Qe={}.VITE_WASM_PRODUCTION_MODE==="true";try{await MlWasmJSApi$1.setProductionMode(Qe)}catch(Ge){console.error(`Exception: ${Ge}`)}this.isSetupDetect=!0,addEvent({token:(Je=state.token)==null?void 0:Je.token,code:"modelLoadEnd",payload:{loadSuccessful:!0}})}}const DetectionSetup$1=DetectionSetup.getInstance(),sources={front:"FRONT_ID",back:"BACK_ID",selfie:"SELFIE"},sendZoomedFrame=async({source:ue,base64Image:me,token:Ue})=>exports.api.post("/omni/zoomed-frame/v2",{base64Image:me},{params:{source:ue},headers:{"X-Incode-Hardware-Id":Ue}}).then(Qe=>Qe.data).catch(emptyFunc);function useSelfie({timeout:ue=4e4,onLog:me=emptyFunc,handleCapture:Ue,numberOfTries:Qe=3,handleNoAttempsLeft:Ze=emptyFunc,webcam:Je,token:Ge,isDetecting:He,onSwitchManualCapture:Xe=emptyFunc,onManualCaptureSelfie:$e=emptyFunc}){const Ke=React$1.useRef(0),nt=React$1.useRef(!1),tt=React$1.useRef(!1),[et,rt]=React$1.useState(""),[it,ot]=React$1.useState("idle"),[at,st]=React$1.useState(!1),ct=React$1.useRef(void 0),[lt,dt]=React$1.useState(!1),ft=React$1.useRef(),gt=React$1.useRef(Xe),pt=React$1.useRef(null),Tt=React$1.useRef(!1),{t:Rt}=useTranslation(),bt=async(hn,An)=>{tt.current||(He.current=!1,await sleep(300),tt.current=!0,ot("uploading"),Ue(hn,An),await sleep(2e3),Nt(An).catch(console.log))},At=500;async function Nt(hn){var Xt;if(mobile.isDesktop())return;const en=document.querySelector("video").srcObject,un=en==null?void 0:en.getVideoTracks()[0];ct.current=(Xt=un==null?void 0:un.getSettings())==null?void 0:Xt.zoom;const gn=await zoomCameraToTheMax(en);if(mobile.iOS()&&!gn){await mt(un);return}await sleep(At);const Sn=Je.current.getCanvas();if(!Sn){await mt(un);return}const dn=Sn.getImageData(),yn=Sn.getBase64Image();sendZoomedFrame({token:Ge,base64Image:yn,source:"SELFIE"}),await MlWasmJSApi$1.allocateImageBuffers(dn.width,dn.height);const nn=await MlWasmJSApi$1.runSelfieCapture(dn);if(nn.faces.size()>0){const Kt=nn.faces.get(0),{rightEye:tn,leftEye:ln}=Kt;if(!(tn!=null&&tn.x)||!(tn!=null&&tn.y)||!(ln!=null&&ln.x)||!(ln!=null&&ln.y)){await mt(un);return}let an=1e4;if(hn&&(an=Math.sqrt((hn.rightEyeX-hn.leftEyeX)**2+(hn.rightEyeY-hn.leftEyeY)**2),an===0)){await mt(un);return}Math.sqrt((tn.x-ln.x)**2+(tn.y-ln.y)**2)/an<1.4&&await addDeviceStats(Ge,{virtualCameraDetected:!0})}await mt(un)}const mt=async hn=>{ct.current&&(await zoomCamera(hn,ct.current),await sleep(At),ct.current=hn.getSettings().zoom)},Ut=()=>{var An;const hn=getLogObject("timeout",{message:"No face found"});(An=gt.current)==null||An.call(gt),me(hn),dt(!0)},Mt=()=>{nt.current||(me(getLogObject("tooFar",{message:Rt("notifications.moveCloser")})),rt(Rt("notifications.moveCloser")))},yt=()=>{nt.current||(me(getLogObject("tooManyFaces",{message:Rt("notifications.tooManyFaces")})),rt(Rt("notifications.tooManyFaces")))},vt=()=>{nt.current||(me(getLogObject("centerFace",{message:Rt("notifications.centerFace")})),rt(Rt("notifications.centerFace")))},xt=()=>{tt.current||nt.current||(ot("capturing"),me(getLogObject("dontMove",{message:Rt("notifications.dontMove")})),rt(Rt("notifications.getReady")),nt.current=!0)},Et=()=>{nt.current||tt.current||rt(Rt("notifications.moveAway"))},Ct=()=>{nt.current||tt.current||rt(Rt("notifications.onDark"))},wt=()=>{nt.current||tt.current||rt(Rt("notifications.onBlur"))},Ft=()=>{nt.current||tt.current||rt(Rt("notifications.onFaceAngle"))},Lt=()=>{nt.current||tt.current||rt(Rt("notifications.removeHeadwear"))},Jt=()=>{nt.current||tt.current||rt(Rt("notifications.removeLenses"))},Qt=()=>{nt.current||tt.current||rt(Rt("notifications.openEyes"))},$t=()=>{nt.current||tt.current||rt(Rt("notifications.removeMask"))},Gt=async()=>{pt.current=new FaceDetection,await pt.current.initialize({onNoFace:emptyFunc,onCaptureFace:emptyFunc,onTooManyFaces:yt,onTooClose:Et,onCenterFace:vt,onFarAway:Mt,onCapturing:xt,onBlur:wt,onDark:Ct,onFaceAngle:Ft,onHeadWear:Lt,onLenses:Jt,onEyesClosed:Qt,onFaceMask:$t,onSwitchToManualCapture:Ut,onCapture:bt,isLensesCheckEnabled:!1,isMaskCheckEnabled:!1,isClosedEyesCheckEnabled:!0,isHeadWearCheckEnabled:!1,isVideoSelfie:!1,pipelineProfile:DetectionSetup$1.getProfile(PipelineType.SelfieFaceDetectionPipeline),autocaptureTimeout:ue})};React$1.useEffect(()=>{gt.current=Xe},[Xe]),React$1.useEffect(()=>{dt(!1)},[]);const Pt=async({response:hn,livenessPassed:An,imageBase64:en})=>{if(Ke.current=Ke.current+1,Qe!==-1&&Ke.current>=Qe)return Ze({response:hn,livenessPassed:An,imageBase64:en});rt(""),ot("idle"),nt.current=!1,tt.current=!1},jt=hn=>{const An=hn.errorMessage||hn.message||hn.reason,{status:en}=hn;if(en===3004){rt(Rt("notifications.unableToCrop")),me(getLogObject("unableToCrop",{message:`${Rt("notifications.unableToCrop")}`}));return}switch(An){case"No faces found on the image":rt(Rt("notifications.face")),me(getLogObject("faceNotDetected",{message:`${Rt("notifications.face")}`}));break;case"BadRequestException: More than one face detected.":rt(Rt("notifications.multiple")),me(getLogObject("multipleFacesDetected",{message:`${Rt("notifications.multiple")}`}));break;case"Cropping area goes off the image.":rt(Rt("notifications.crop")),me(getLogObject("cropTooSmall",{message:`${Rt("notifications.crop")}`}));break;case"Image in portrait orientation is expected.":rt(Rt("notifications.portrait")),me(getLogObject("imageNotPortrait",{message:`${Rt("notifications.portrait")}`}));break;default:me(getLogObject("InternalServerError",{message:`${Rt("notifications.error")}`})),rt(Rt("notifications.error"));break}},Dt=React$1.useCallback(async()=>{if(!(!He.current||Tt.current)){Tt.current=!0,pt.current||await Gt();try{await MlWasmJSApi$1.handleDetectionCallAndUpdateState(PipelineType.SelfieFaceDetectionPipeline);const hn=Je.current.getCanvas();await pt.current.detect(hn)}catch(hn){console.error(hn)}finally{Tt.current=!1}}},[Gt]);React$1.useEffect(()=>(onFrameEmitter.on("newFrame",Dt),()=>{onFrameEmitter.off("newFrame",Dt)}),[Dt]);const ut=React$1.useCallback(()=>{He.current||(He.current=!0,Je.current.video.play())},[me,Gt]),It=React$1.useCallback(async()=>{st(!0),await sleep(4e3),ut()},[ut]);function Vt(){$e();const hn=Je.current.getCanvas();hn.updateBase64Image(),hn.updateBlob(),bt(hn,null)}const Ot=it==="capturing",Zt=it==="uploading",zt=it==="success",Ht=it==="error",_t=Ot||Zt,sn=Zt||zt||Ht;return{notificationMessage:et,mode:it,capturing:nt,cameraReady:at,showManualCapture:lt,handleFaceAutoCapture:bt,setMode:ot,resetLoading:Pt,setNotificationMessage:rt,handleError:jt,autoDetectFace:ut,startAutoDetect:It,handleManualCapture:Vt,isCapturing:Ot,isUploading:Zt,isSuccess:zt,isError:Ht,isLoading:_t,hideCamera:sn,showBorders:at&&(it==="idle"||Ht),shouldShowManualCapture:lt&&!sn,selfieTimeoutRef:ft}}async function sendMfa({verificationCode:ue,transactionId:me}){return exports.api.post("/omni/oneToN/mfa",{verificationCode:ue,transactionId:me}).then(Ue=>Ue.data).catch(Ue=>{var Qe;return Promise.reject((Qe=Ue==null?void 0:Ue.response)==null?void 0:Qe.data)})}const ErrorContainer$1=styled.div`
1405
+ `,isAndroid=!!mobile.Android(),isJ7Prime=!!mobile.J7Prime(),isAlcatel1x=!!mobile.Alcatel1x(),isLenovoVibeB=!!mobile.LenovoVibeB(),isDesktop=mobile.isDesktop(),parser=new UAParser,{browser:browser$1}=parser.getResult(),onFrameEmitter=new eventsExports.EventEmitter,Webcam=React$1.forwardRef(({className:ue,onPlay:me,videoSource:Ue,isSelfie:Qe=!1,type:Ze,permissionMessage:Je,onLog:Ge=emptyFunc,stream:He,onError:Xe=emptyFunc,token:$e,interviewId:Ke,onStreamReady:nt=emptyFunc,showCustomCameraPermissionScreen:tt,assistedOnboarding:et,deviceId:rt,onRestartOnboarding:it=reload,showDoublePermissionsRequest:ot=!1,publishAudio:at=!1,fullHeight:st=!1,isRecordingEnabled:ct=!1,isKiosk:lt=!1},dt)=>{const[ft,gt]=React$1.useState(!1),[pt,Tt]=React$1.useState(He),[Rt,bt]=React$1.useState(!0),[At,Nt]=React$1.useState(!0),[mt,Ut]=React$1.useState(!1),Mt=React$1.useRef(null),yt=React$1.useRef(),vt=React$1.useRef(0),{t:xt}=useTranslation(),[Et,Ct]=usePermissions(),wt=React$1.useRef(),Ft=React$1.useRef(!1);wt.current=Et;const[Lt,Jt]=React$1.useState(!ot);Je=Je||xt("permissionMessage"),React$1.useEffect(()=>{wt.current&&!isDesktop&&!lt&&Jt(wt.current)},[Et]),React$1.useEffect(()=>{const _t=sessionStorage.getItem("cameraPermissionsGranted")==="true";!isDesktop&&_t&&!lt&&Jt(!0)},[Et]),React$1.useEffect(()=>{const _t=Mt.current;return()=>{_t.pause(),_t.srcObject=null}},[]),React$1.useEffect(()=>()=>{pt==null||pt.getTracks().forEach(_t=>_t.stop())},[pt]),React$1.useEffect(()=>{let _t=0;const sn=()=>{if(!mt)return;if(!Mt.current){Ut(!1);return}if(Mt.current.paused){Ut(!1),_t=0;return}const cn=Mt.current.currentTime;cn!==_t&&(onFrameEmitter.emit("newFrame"),_t=cn),requestAnimationFrame(sn)};requestAnimationFrame(sn)},[mt]);const Qt=React$1.useCallback(()=>{var _t,sn,cn;if(!document.hidden)return(sn=(_t=Mt.current)==null?void 0:_t.srcObject)==null||sn.clone(),(cn=Mt.current)==null?void 0:cn.play()},[]);useEventListener("visibilitychange",Qt,document);const $t=async _t=>{const sn=_t.getVideoTracks()[0],cn=await getDeviceCapabilities(),fn=getChosenCameraInfo(sn,vt.current,Ue),{width:hn,height:An}=sn.getSettings(),{focusMode:en=!1}=navigator.mediaDevices.getSupportedConstraints();addEvent({code:"cameraType",payload:{type:"webRTC",resolution:`${hn}x${An}`,autofocus:en,label:sn.label},token:$e}),addEvent({code:"cameraDebugInfo",payload:{type:"webRTC",availableCameras:cn,chosenCamera:fn},token:$e}),Qe&&addEvent({code:"cameraSelfie",token:$e})},Gt=_t=>{Nt(!1),_t.constructor.name==="DOMException"?(addEvent({code:"permissionDenied",payload:{message:"User denied to use camera."},token:$e}),Ge(getLogObject("permissionDenied",{message:"User denied to use camera."})),_t.type="permissionDenied",tt?gt(!0):Xe(_t)):_t.constructor.name==="OverconstrainedError"?(Ge(getLogObject("OSVersionNotSupported",{message:"OS version is not supported."})),bt(!1)):(Ge(getLogObject("browserNotSupported",{message:"Browser is not supported."})),bt(!1))},Pt=async _t=>{Ct(!0);const sn=()=>{Mt.current.srcObject=_t,nt(_t),Tt(_t),ct||Nt(!1)},cn=_t.getVideoTracks()[0];MlWasmJSApi$1.isVirtualCamera(cn.label)&&Xe(new Error("Virtual camera is detected")),mobile.iOS()?cn.applyConstraints({advanced:[{focusDistance:1}]}).finally(()=>{sn()}):sn()};React$1.useEffect(()=>((async()=>{function sn(hn){const An={resizeMode:"none",facingMode:"environment"};switch(hn){case 0:return{...An,height:{ideal:localStorage.getItem("isIPhone14OrHigher")==="true"?1080:720}};case 1:return{...An,width:{min:3200,ideal:3840,max:4096},height:{min:1800,ideal:2160,max:2400}};case 2:return{...An,width:{min:1400,ideal:1920,max:2160},height:{min:900,ideal:1080,max:1440}};case 3:return{...An,width:{min:640,ideal:640,max:800},height:{min:480,ideal:480,max:600}};case 4:return{...An,width:{min:640,ideal:800,max:960},height:{min:480,ideal:480,max:480}};default:return{}}}const cn=async hn=>{const An={video:Ue==="environment"?sn(hn.current):localStorage.getItem("isIPhone14OrHigher")==="true"?{height:{ideal:1080}}:{facingMode:Ue,height:{ideal:480},width:{ideal:640}},audio:at},un={audio:isSafari()||at,video:{facingMode:"user",deviceId:rt?{exact:rt}:void 0}};if(mobile.isIpad()&&Ue==="user")try{const gn=await getNonUltraWideFrontCameraStream();Pt(gn),await $t(gn)}catch(gn){Xe({...gn,type:"permissionDenied"})}else isAndroid&&Ue==="environment"?navigator.mediaDevices.getUserMedia(An).then(async gn=>{const Sn=gn.getVideoTracks()[0],dn=await getCameras(),yn=adjustCamerasFromCameraStream(Sn,dn);gn.getTracks().forEach(tn=>tn.stop());let nn=1280,Xt=720;if(hn.current>1||isJ7Prime||isAlcatel1x||isLenovoVibeB){const{width:tn,height:ln}=sn(isJ7Prime?2:isAlcatel1x||isLenovoVibeB?4:hn.current);nn=tn==null?void 0:tn.ideal,Xt=ln==null?void 0:ln.ideal}const Kt={video:{deviceId:{exact:yn.deviceId},width:{ideal:nn},height:{ideal:Xt}}};navigator.mediaDevices.getUserMedia(Kt).then(async tn=>{await $t(tn),Pt(tn)})}).catch(gn=>{hn.current=hn.current+1,hn.current>4?Gt(gn):cn(hn)}):navigator.mediaDevices.getUserMedia(mobile.any()?An:un).then(async gn=>{await $t(gn),Pt(gn)}).catch(gn=>{Gt(gn)})};if(mobile.iOS()&&Ft.current)return;if(Lt===!0||isDesktop||lt||ot===!1){if(Ft.current=!0,He){Pt(He);return}Nt(!0),cn(vt),addEvent({token:$e,code:"cameraFeedbackDisplayed",payload:{feedback:"Loading..."},module:"ID Capture",screen:`${Ze} Camera Capture`})}const fn=document.createElement("canvas");yt.current=fn})(),()=>{Lt&&(Ft.current=!1,He==null||He.getTracks().forEach(sn=>sn.stop()))}),[Lt,Ue,He]),React$1.useImperativeHandle(dt,()=>({getCanvas:Dt,video:Mt.current,stream:pt,setIsLoadingCamera:Nt}));const jt=({width:_t=0,height:sn=0,useOriginalDimensions:cn=!0})=>{if(!Mt.current||!Mt.current.videoHeight||!Mt.current.videoWidth||!yt.current)return!1;if(cn)yt.current.width=Mt.current.videoWidth,yt.current.height=Mt.current.videoHeight;else{if(_t===0||sn===0)return!1;yt.current.width=_t,yt.current.height=sn}const fn=yt.current.getContext("2d");return fn.clearRect(0,0,yt.current.width,yt.current.height),fn.drawImage(Mt.current,0,0),!0},Dt=({width:_t=0,height:sn=0,useOriginalDimensions:cn=!0}={})=>jt({width:_t,height:sn,useOriginalDimensions:cn})?new IncodeCanvas(yt.current):null,ut=()=>Mt.current?Mt.current.videoWidth>Mt.current.videoHeight:!1,It=()=>{Jt(!0),sessionStorage.setItem("cameraPermissionsGranted",String(!0)),addEvent({token:$e,code:"permissionsAllowedCustom"}),addEvent({token:$e,code:"cameraPermissionSubmitted",payload:{requestor:"browser",requestorDetails:browser$1.name,permission:"allowed"},module:"ID capture",screen:`${Ze} Camera Capture`})},Vt=()=>{addEvent({token:$e,code:"permissionsQuitFlow"}),setTimeout(()=>{window.location.reload()},0)},Ot=()=>{addEvent({token:$e,code:"permissionsDeniedCustom"}),addEvent({token:$e,code:"cameraPermissionSubmitted",payload:{requestor:"browser",requestorDetails:browser$1.name,permission:"denied"},module:"ID capture",screen:`${Ze} Camera Capture`})},Zt=sessionStorage.getItem("cameraPermissionsGranted")==="true",zt=ot&&(typeof Et<"u"&&!Et&&!Lt||typeof Lt<"u"&&!Lt)&&!isDesktop&&!lt&&!Zt,Ht=()=>{!mt&&me&&typeof me=="function"&&me(),Ut(!0)};return jsxs(React$1.Fragment,{children:[ft&&jsx(AllowCameraUse,{handleAllowCamera:it}),zt&&jsx(FakePermissionsRequest,{handleDenyPermission:Ot,handleCameraPermission:It,handleQuitOnboarding:Vt,type:Ze,token:$e,interviewId:Ke}),!Rt&&jsx(BrowserNotSupported,{}),At&&!zt&&jsx(Loader$1,{message:xt("webcam.loading"),fullScreen:!0}),jsx(Video$1,{"aria-hidden":"true",autoPlay:!0,className:classNames(ue,{selfie:Qe,horizontal:ut(),desktop:!mobile.any(),assistedOnboarding:et,"full-height":st}),playsInline:!0,onPlay:Ht,ref:Mt,muted:!0})]})}),captureButton="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI2NSIgaGVpZ2h0PSI2NSIgdmlld0JveD0iMCAwIDY1IDY1Ij4KICAgIDxnIGZpbGw9Im5vbmUiIGZpbGwtcnVsZT0iZXZlbm9kZCI+CiAgICAgICAgPGc+CiAgICAgICAgICAgIDxnPgogICAgICAgICAgICAgICAgPGcgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoLTE1NSAtNjQ2KSB0cmFuc2xhdGUoMTU1IDY0NikiPgogICAgICAgICAgICAgICAgICAgIDxjaXJjbGUgY3g9IjMyLjMxOSIgY3k9IjMyLjMxOSIgcj0iMzIuMzE5IiBmaWxsPSIjMjAyNjNEIi8+CiAgICAgICAgICAgICAgICAgICAgPGNpcmNsZSBjeD0iMzIuMzE5IiBjeT0iMzIuMzE5IiByPSIyNS4xMzciIGZpbGw9IiNGRkYiIGZpbGwtb3BhY2l0eT0iLjA5MyIgc3Ryb2tlPSIjRkZGIiBzdHJva2Utd2lkdGg9IjIuMDUyIi8+CiAgICAgICAgICAgICAgICA8L2c+CiAgICAgICAgICAgICAgICA8ZyBmaWxsPSIjRkZGIiBmaWxsLXJ1bGU9Im5vbnplcm8iPgogICAgICAgICAgICAgICAgICAgIDxwYXRoIGQ9Ik0xNy4xOTMgMTIuMjRjMCAyLjI5NC0xLjg4IDQuMTYtNC4xOTMgNC4xNi0yLjMxMiAwLTQuMTkyLTEuODY2LTQuMTkyLTQuMTYgMC0yLjI5MyAxLjg4LTQuMTYgNC4xOTItNC4xNiAyLjMxMiAwIDQuMTkzIDEuODY3IDQuMTkzIDQuMTZ6TTI2IDYuMzM0djExLjgxNEMyNiAxOS43MjMgMjQuNzEzIDIxIDIzLjEyNSAyMUgyLjg3NUMxLjI4NyAyMSAwIDE5LjcyMyAwIDE4LjE0OFY2LjMzNEMwIDQuNzYgMS4yODcgMy40ODIgMi44NzUgMy40ODJoMy41MzZ2LS45ODdDNi40MTEgMS4xMTcgNy41MzcgMCA4LjkyNyAwaDguMTQ2YzEuMzkgMCAyLjUxNiAxLjExNyAyLjUxNiAyLjQ5NXYuOTg2aDMuNTM2QzI0LjcxMyAzLjQ4MiAyNiA0Ljc2IDI2IDYuMzM0em0tNi42NSA1LjkwNmMwLTMuNDczLTIuODQ5LTYuMjk4LTYuMzUtNi4yOTgtMy41IDAtNi4zNDkgMi44MjUtNi4zNDkgNi4yOThTOS41IDE4LjU0IDEzIDE4LjU0YzMuNTAxIDAgNi4zNS0yLjgyNiA2LjM1LTYuMjk5eiIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoLTE1NSAtNjQ2KSB0cmFuc2xhdGUoMTU1IDY0NikgdHJhbnNsYXRlKDE5IDIxKSIvPgogICAgICAgICAgICAgICAgPC9nPgogICAgICAgICAgICA8L2c+CiAgICAgICAgPC9nPgogICAgPC9nPgo8L3N2Zz4K",faceFrame$1="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIzMzYiIGhlaWdodD0iNTE4IiB2aWV3Qm94PSIwIDAgMzM2IDUxOCI+CiAgICA8cGF0aCBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIHN0cm9rZT0iI0ZGRiIgc3Ryb2tlLWRhc2hhcnJheT0iNy4xMzk5OTk2NzU3NTA3MzIsMTkuMDM5OTk5Njc1NzUwNzMiIHN0cm9rZS13aWR0aD0iOS4wNDQiIGQ9Ik0xNjggNTEzLjM5MmM3Ni44MyAwIDE2Mi44OTMtMTEzLjkyIDE2Mi44OTMtMjU0LjQ0N1MyODAuMjM2IDQuNDk4IDE2OCA0LjQ5OCA1LjEwNyAxMTguNDE4IDUuMTA3IDI1OC45NDUgOTEuMTcgNTEzLjM5MiAxNjggNTEzLjM5MnoiLz4KPC9zdmc+Cg==",deviceStatsQueue=[];let isReady=!1;function addDeviceStats(ue,me){if(!isReady){deviceStatsQueue.push(me);return}return exports.api.post("/omni/device/stats",me,{headers:{"X-Incode-Hardware-Id":ue}}).catch(()=>{})}function emptyDeviceStatsQueue(ue){isReady=!0,deviceStatsQueue.forEach(me=>{addDeviceStats(ue,me)})}class FaceDetection{constructor(){this.pipelineProfile=null,this.bestCanvas=null,this.bestLandmarks=null,this.bestTopLeft=null,this.bestSize=null,this.currCanvas=null}formatLandmarks(me,Ue,Qe){const[Ze,Je,Ge,He,Xe,$e,Ke,nt,tt,et]=me;return{rightEyeX:Ze,rightEyeY:Je,leftEyeX:Ge,leftEyeY:He,noseTipX:Xe,noseTipY:$e,rightMouthX:Ke,rightMouthY:nt,mouthX:tt,mouthY:et,x:Ue[0],y:Ue[1],width:Qe[0],height:Qe[1]}}async initialize(me){const{onNoFace:Ue,onCapturing:Qe,onCapture:Ze,onTooManyFaces:Je,onTooClose:Ge,onCenterFace:He,onFarAway:Xe,onFaceAngle:$e,onDark:Ke,onBlur:nt,onHeadWear:tt,onLenses:et,onEyesClosed:rt,onFaceMask:it,onSwitchToManualCapture:ot,isLensesCheckEnabled:at,isMaskCheckEnabled:st,isClosedEyesCheckEnabled:ct,isHeadWearCheckEnabled:lt,isVideoSelfie:dt,pipelineProfile:ft,autocaptureTimeout:gt}=me;this.pipelineProfile=ft;const pt=this.pipelineProfile.pipelineType;await MlWasmJSApi$1.setFacePositionConstraints(pt,ft.parameters.frameMinX,ft.parameters.frameMinY,ft.parameters.frameMaxX,ft.parameters.frameMaxY),await MlWasmJSApi$1.setFaceDetectionThresholds(pt,ft.parameters.brightnessThreshold,ft.parameters.blurrinessThreshold,ft.parameters.tiltRotationAngleThreshold,ft.parameters.minMagicCropSize,gt),await MlWasmJSApi$1.setFaceAttributesEnabled(pt,at,st,ct,lt),await MlWasmJSApi$1.setFaceAttributesThresholds(pt,ft.parameters.headwearThreshold,ft.parameters.lensesThreshold,ft.parameters.closedEyesThreshold,ft.parameters.maskThreshold),await MlWasmJSApi$1.setFaceDetectionMode(pt,dt);const Tt=()=>{this.bestCanvas.updateBase64Image(),this.bestCanvas.updateBlob(),Ze(this.bestCanvas,this.formatLandmarks(this.bestLandmarks,this.bestTopLeft,this.bestSize))},Rt=bt=>{this.bestCanvas=this.currCanvas.clone();const At=bt.rect;this.bestTopLeft=[At.x,At.y];const Nt=[At.x+At.width,At.y+At.height],mt=this.bestTopLeft,Ut=Nt;this.bestSize=[Ut[0]-mt[0],Ut[1]-mt[1]],this.bestLandmarks=[bt.rightEye.x,bt.rightEye.y,bt.leftEye.x,bt.leftEye.y,bt.noseTip.x,bt.noseTip.y,bt.rightMouthCorner.x,bt.rightMouthCorner.y,bt.leftMouthCorner.x,bt.leftMouthCorner.y]};await MlWasmJSApi$1.setFaceDetectionCallbacks(pt,Xe,Ge,Je,Ue,Tt,Qe,He,Ke,nt,$e,Rt,et,it,rt,tt,ot)}async detect(me){try{this.currCanvas=me,await MlWasmJSApi$1.allocateImageBuffers(me.width(),me.height()),await MlWasmJSApi$1.process(me.getImageData(),PipelineType.SelfieFaceDetectionPipeline)}catch(Ue){console.error(`Exception: ${Ue}`)}}}const state={token:null};var PipelineProfileType=(ue=>(ue[ue.IdCaptureBrazilian=0]="IdCaptureBrazilian",ue[ue.IdCaptureVisas=1]="IdCaptureVisas",ue[ue.IdVideoSelfieBrazilian=2]="IdVideoSelfieBrazilian",ue[ue.IdVideoSelfieVisas=3]="IdVideoSelfieVisas",ue[ue.SelfieFaceDetection=4]="SelfieFaceDetection",ue))(PipelineProfileType||{});class PipelineProfile{constructor(me,Ue,Qe,Ze,Je=null,Ge=""){this.pipelineType=me,this.profileType=Ue,this.modelNames=Qe,this.parameters=Ze,this.paramsConfigurator=Je,this.description=Ge}reconfigureParams(me=null){if(this.paramsConfigurator==null)throw new Error("PipelineProfile does not have a paramsConfigurator");this.paramsConfigurator(this.parameters,this.pipelineType,me)}}function IdCaptureParamsConfigurator(ue,me,Ue){Object.assign(ue,{areaDown:Ue?55e3:25e3,areaUp:Ue?75e3:55e3,areaIOSPassportUp:3e4,areaIOSPassportDown:2e4,widthIOSUp:me==PipelineType.IdCapturePipeline?125:180,widthIOSDown:me==PipelineType.IdCapturePipeline?85:150,widthDown:Ue?185:135,widthUp:Ue?255:205})}const SelfieFaceDetectionPipelineParams={frameMinX:0,frameMinY:0,frameMaxX:1,frameMaxY:1,brightnessThreshold:50,blurrinessThreshold:50,tiltRotationAngleThreshold:15,minMagicCropSize:200,headwearThreshold:.95,lensesThreshold:.95,closedEyesThreshold:.9,maskThreshold:.5},pipelineProfiles=[new PipelineProfile(PipelineType.IdCapturePipeline,PipelineProfileType.IdCaptureBrazilian,["brazilian_mobile_025_ep199_fp16.ortmodelv2"],{glareThreshold:.2,classificationThreshold:.98,sharpnessThreshold:.3,sharpnessChangeThreshold:.3},IdCaptureParamsConfigurator,"Id Capture Profile with brazilian_mobile model"),new PipelineProfile(PipelineType.IdCapturePipeline,PipelineProfileType.IdCaptureVisas,["visas_mobile_025_best_v1_03_fp16.ortmodelv2"],{glareThreshold:.3,classificationThreshold:.98,sharpnessThreshold:.2,sharpnessChangeThreshold:.2},IdCaptureParamsConfigurator,"Id Capture Profile with visas_mobile model"),new PipelineProfile(PipelineType.IdVideoSelfiePipeline,PipelineProfileType.IdVideoSelfieBrazilian,["brazilian_mobile_025_ep199_fp16.ortmodelv2"],{glareThreshold:.2,classificationThreshold:.9,sharpnessThreshold:.3,sharpnessChangeThreshold:.3},IdCaptureParamsConfigurator,"Id Videoselfie profile with brazilian_mobile model"),new PipelineProfile(PipelineType.IdVideoSelfiePipeline,PipelineProfileType.IdVideoSelfieVisas,["visas_mobile_025_best_v1_03_fp16.ortmodelv2"],{glareThreshold:.3,classificationThreshold:.9,sharpnessThreshold:.2,sharpnessChangeThreshold:.2},IdCaptureParamsConfigurator,"Id Videoselfie Profile with visas_mobile model"),new PipelineProfile(PipelineType.SelfieFaceDetectionPipeline,PipelineProfileType.SelfieFaceDetection,["selfie_bf_angles_192x192_opset9_fp16.ortmodelv2","bf_attrib_31b8f9d92fb345c2b4bbdd222792562c_0_fp16.ortmodelv2","mls_regressor_4773007c657b4f05a460321456740d0f_fp16.ortmodelv2"],SelfieFaceDetectionPipelineParams,null,"Selfie face detection profile")];function getProfile(ue){const me=pipelineProfiles.find(Ue=>Ue.profileType===ue);if(!me)throw new Error(`Profile not found for type: ${ue}`);return me}const probabilityThreshold=.9,wasmVersion="v1.8.2",brazilianPipelineBundle=[PipelineProfileType.IdCaptureBrazilian,PipelineProfileType.IdVideoSelfieBrazilian,PipelineProfileType.SelfieFaceDetection],visasPipelineBundle=[PipelineProfileType.IdCaptureVisas,PipelineProfileType.IdVideoSelfieVisas,PipelineProfileType.SelfieFaceDetection],PipelinesBundle=new Map([["brazilianPipelineBundle",brazilianPipelineBundle],["visasPipelineBundle",visasPipelineBundle]]);function switchBundle(){return Math.random()<probabilityThreshold?"brazilianPipelineBundle":"visasPipelineBundle"}function getInitializationParams(ue){const Ue=ue?switchBundle():"brazilianPipelineBundle",Qe="https://d3vv997wtl2myz.cloudfront.net/webcamera/onnx-backend-wasm",Ze=`${Qe}/${wasmVersion}/webLib.wasm`,Je=`${Qe}/${wasmVersion}/webLibSimd.wasm`,Ge=`${Qe}/${wasmVersion}/webLib.js`,He=`${Qe}/${wasmVersion}/versions.json`;let Xe=new Map,$e=new Map;for(const Ke of PipelinesBundle.get(Ue)){const nt=getProfile(Ke);if(!nt)throw new Error(`Profile not found for type: ${Ke}`);const tt=nt.modelNames;let et=[];for(const rt of tt)et.push(`${Qe}/${wasmVersion}/models/${rt}`);Xe.set(nt.pipelineType,et),$e.set(nt.pipelineType,nt)}return{wasmModulePath:Ze,wasmSimdModulePath:Je,glueCodePath:Ge,versionsFilePath:He,pipelineModels:Xe,enableSIMD:!0,bundle:Ue,profiles:$e}}class MotionStatusCheck{constructor(me,Ue,Qe,Ze,Je,Ge,He,Xe,$e,Ke,nt,tt){this.isRunning_=!1,this.acl_=null,this.gyro_=null,this.permission_=!0,this.minNumberOfFrames_=3,this.maxFrequency_=60,this.emptyParams={meanX:0,meanY:0,meanZ:0,m2X:0,m2Y:0,m2Z:0,cumulativeAbsErrorX:0,cumulativeAbsErrorY:0,cumulativeAbsErrorZ:0,ptsNum:0},this.paramsAcc_={...this.emptyParams},this.paramsGyro_={...this.emptyParams},this.paramsAccGrOld_={...this.emptyParams},this.paramsAccOld_={...this.emptyParams},this.paramsGyroscopeOld_={...this.emptyParams},this.paramsOrientationOld_={...this.emptyParams},this.waitForClick=()=>new Promise(et=>{document.addEventListener("click",async()=>{const rt=await this.requestMotionPermission();et(rt)},{once:!0})}),this.deviceMotionListener=et=>{if(et.accelerationIncludingGravity){const rt={x:et.accelerationIncludingGravity.x,y:et.accelerationIncludingGravity.y,z:et.accelerationIncludingGravity.z};this.checkFields(rt)&&(this.paramsAccGrOld_.ptsNum+=1,this.updateParams(this.paramsAccGrOld_,rt))}if(et.acceleration){const rt={x:et.acceleration.x,y:et.acceleration.y,z:et.acceleration.z};this.checkFields(rt)&&(this.paramsAccOld_.ptsNum+=1,this.updateParams(this.paramsAccOld_,rt))}if(et.rotationRate){const rt={x:et.rotationRate.alpha,y:et.rotationRate.beta,z:et.rotationRate.gamma};this.checkFields(rt)&&(this.paramsGyroscopeOld_.ptsNum+=1,this.updateParams(this.paramsGyroscopeOld_,rt))}},this.deviceOrientationListener=et=>{const rt={x:et.alpha,y:et.beta,z:et.gamma};this.checkFields(rt)&&(this.paramsOrientationOld_.ptsNum+=1,this.updateParams(this.paramsOrientationOld_,rt))},this.accThreshold_=me,this.gyroThreshold_=Ue,this.accGrOldThreshold_=Qe,this.accOldThreshold_=Ze,this.gyroscopeOldThreshold_=Je,this.orientationOldThreshold_=Ge,this.maeAccThreshold_=He,this.maeGyroThreshold_=Xe,this.maeAccGrOldThreshold_=$e,this.maeAccOldThreshold_=Ke,this.maeGyroscopeOldThreshold_=nt,this.maeOrientationOldThreshold_=tt}async requestMotionPermission(){DeviceMotionEvent&&typeof DeviceMotionEvent.requestPermission=="function"&&DeviceMotionEvent.requestPermission().then(me=>{me!=="granted"&&(this.permission_=!1)}).catch(console.error)}initializeAccelerometer(){if("Accelerometer"in window)try{this.acl_=new window.Accelerometer({frequency:this.maxFrequency_}),this.acl_.addEventListener("reading",()=>this.updateAcc())}catch{}}initializeGyroscope(){if("Gyroscope"in window)try{this.gyro_=new window.Gyroscope({frequency:this.maxFrequency_}),this.gyro_.addEventListener("reading",()=>this.updateGyro())}catch{}}async start(){this.run()}run(){if(!(this.isRunning_||!this.permission_)){try{this.initializeAccelerometer(),this.acl_.start()}catch{}try{this.initializeGyroscope(),this.gyro_.start()}catch{}window.addEventListener("devicemotion",this.deviceMotionListener),window.addEventListener("deviceorientation",this.deviceOrientationListener),this.isRunning_=!0}}stop(){this.isRunning_=!1,this.acl_&&this.acl_.stop(),this.gyro_&&this.gyro_.stop(),window.removeEventListener("devicemotion",this.deviceMotionListener),window.removeEventListener("deviceorientation",this.deviceOrientationListener),this.paramsAcc_={...this.emptyParams},this.paramsGyro_={...this.emptyParams},this.paramsAccGrOld_={...this.emptyParams},this.paramsAccOld_={...this.emptyParams},this.paramsGyroscopeOld_={...this.emptyParams},this.paramsOrientationOld_={...this.emptyParams}}updateAcc(){if(!(!this.isRunning_||!this.acl_)&&(this.paramsAcc_.ptsNum+=1,this.acl_)){const me={x:this.acl_.x,y:this.acl_.y,z:this.acl_.z};this.checkFields(me)&&this.updateParams(this.paramsAcc_,me)}}updateGyro(){if(!(!this.isRunning_||!this.gyro_)&&(this.paramsGyro_.ptsNum+=1,this.gyro_)){const me={x:this.gyro_.x,y:this.gyro_.y,z:this.gyro_.z};this.checkFields(me)&&this.updateParams(this.paramsGyro_,me)}}check(){if(!this.permission_)return"UNCLEAR";const me=this.checkStability();return me===null?"UNCLEAR":me?"FAIL":"PASS"}checkStability(){if(!this.isRunning_)return null;const Ue=[this.gyro_?this.isBelowStdThreshold(this.paramsGyro_,this.gyroThreshold_):null,this.acl_?this.isBelowStdThreshold(this.paramsAcc_,this.accThreshold_):null,this.isBelowStdThreshold(this.paramsAccGrOld_,this.accGrOldThreshold_),this.isBelowStdThreshold(this.paramsAccOld_,this.accOldThreshold_),this.isBelowStdThreshold(this.paramsGyroscopeOld_,this.gyroscopeOldThreshold_),this.isBelowStdThreshold(this.paramsOrientationOld_,this.orientationOldThreshold_)].filter(He=>He!==null),Qe=Ue.length>0?Ue.every(He=>He):null,Je=[this.gyro_?this.isBelowMaeThreshold(this.paramsGyro_,this.maeGyroThreshold_):null,this.acl_?this.isBelowMaeThreshold(this.paramsAcc_,this.maeAccThreshold_):null,this.isBelowMaeThreshold(this.paramsAccGrOld_,this.maeAccGrOldThreshold_),this.isBelowMaeThreshold(this.paramsAccOld_,this.maeAccOldThreshold_),this.isBelowMaeThreshold(this.paramsGyroscopeOld_,this.maeGyroscopeOldThreshold_),this.isBelowMaeThreshold(this.paramsOrientationOld_,this.maeOrientationOldThreshold_)].filter(He=>He!==null),Ge=Je.length>0?Je.every(He=>He):null;return Qe===null?Ge===null?null:Ge:Ge!==null?Qe&&Ge:Qe}updateParams(me,Ue){const Qe=Ue.x-me.meanX,Ze=Ue.y-me.meanY,Je=Ue.z-me.meanZ;me.meanX+=Qe/me.ptsNum,me.meanY+=Ze/me.ptsNum,me.meanZ+=Je/me.ptsNum,me.m2X+=Qe*(Ue.x-me.meanX),me.m2Y+=Ze*(Ue.y-me.meanY),me.m2Z+=Je*(Ue.z-me.meanZ),me.cumulativeAbsErrorX+=Math.abs(Ue.x-me.meanX),me.cumulativeAbsErrorY+=Math.abs(Ue.y-me.meanY),me.cumulativeAbsErrorZ+=Math.abs(Ue.z-me.meanZ)}calculateStd(me){const Ue={x:me.m2X/me.ptsNum,y:me.m2Y/me.ptsNum,z:me.m2Z/me.ptsNum};return{x:Math.sqrt(Ue.x),y:Math.sqrt(Ue.y),z:Math.sqrt(Ue.z)}}calculateMae(me){return{x:me.cumulativeAbsErrorX/me.ptsNum,y:me.cumulativeAbsErrorY/me.ptsNum,z:me.cumulativeAbsErrorZ/me.ptsNum}}checkFields(me){return me.x!==null&&me.y!==null&&me.z!==null}isBelowStdThreshold(me,Ue){if(me.ptsNum<this.minNumberOfFrames_)return null;const Qe=this.calculateStd(me);return Qe.x<Ue&&Qe.y<Ue&&Qe.z<Ue}isBelowMaeThreshold(me,Ue){if(me.ptsNum<this.minNumberOfFrames_)return null;const Qe=this.calculateMae(me);return Qe.x<Ue&&Qe.y<Ue&&Qe.z<Ue}}class OnboardingAnalytics{constructor(){this.motionStatusCheck=null,this.estimatedPerformance=null,this.analysisStatus="",this.motionStatus="",this.pipelineLogs="",this.pipelinesBundle=null,this.simdIsEnabled=null,this.motionStatusCheck=new MotionStatusCheck(.3,.3,.3,.3,10,10,.3,.3,.3,.3,10,10)}static getInstance(){return OnboardingAnalytics.instance||(OnboardingAnalytics.instance=new OnboardingAnalytics),OnboardingAnalytics.instance}setPipelinesBundle(me){this.pipelinesBundle=me}setSimdIsEnabled(me){this.simdIsEnabled=me}getPipelineLogs(){return this.pipelineLogs}getMotionStatus(){return this.motionStatus}getAnalysisStatus(){return this.analysisStatus}async analyzeFrame(me){const Ue=await base64ToImageData(me);await MlWasmJSApi$1.analyzeFrame(Ue),this.updatePipelineStats()}async startOnboardingCheck(){this.motionStatusCheck.start()}estimatePerformance(){if(this.estimatedPerformance)return this.estimatedPerformance;this.estimatedPerformance=MlWasmJSApi$1.estimatePerformance()}updatePipelineStats(){if(MlWasmJSApi$1.isInitialized())try{const me=MlWasmJSApi$1.getPipelineState();if(me!==""){const Ue=JSON.parse(me);this.analysisStatus=Ue.statsAnalysisStatus,Ue.pipelinesBundle=this.pipelinesBundle?this.pipelinesBundle:"unknown",Ue.estimatedPerformance=this.estimatedPerformance,Ue.simdIsEnabled=this.simdIsEnabled,this.pipelineLogs=JSON.stringify(Ue),this.motionStatus===""&&(this.motionStatus=this.motionStatusCheck.check())}}catch(me){console.error(`Exception: ${me}`)}}}const OnboardingAnalytics$1=OnboardingAnalytics.getInstance();class DetectionSetup{constructor(){this.setupDetectPromise=null,this.isSetupDetect=!1,this.pipelinesBundle=null,this.profiles=null}static getInstance(){return DetectionSetup.instance||(DetectionSetup.instance=new DetectionSetup),DetectionSetup.instance}setIsIPhone14OrHigher(){if(!mobile.iOS())return;if(new URLSearchParams(window.location.search).get("smallFrame")==="true"){localStorage.setItem("isIPhone14OrHigher","true");return}localStorage.setItem("isIPhone14OrHigher",String(window.outerHeight===852&&window.outerWidth===393||window.outerHeight===932&&window.outerWidth===430||window.innerHeight===631&&window.innerWidth===375))}async setupDetect(){return this.setupDetectPromise?this.setupDetectPromise:(this.setupDetectPromise=this._runSetupDetect(),this.setupDetectPromise)}getPipelinesBundle(){return this.pipelinesBundle}getProfile(me){var Ue;return((Ue=this.profiles)==null?void 0:Ue.get(me))??null}async warmup(){for(;!MlWasmJSApi$1.isInitialized();)await new Promise(me=>setTimeout(me,100))}async _runSetupDetect(){var Ze,Je;if(this.isSetupDetect)return;addEvent({token:(Ze=state.token)==null?void 0:Ze.token,code:"modelLoadStart"}),this.setIsIPhone14OrHigher();const me=getInitializationParams(!1);this.pipelinesBundle=me.bundle,this.profiles=me.profiles,OnboardingAnalytics$1.setPipelinesBundle(this.pipelinesBundle),OnboardingAnalytics$1.startOnboardingCheck();const Ue=await MlWasmJSApi$1.initialize(me.wasmModulePath,me.wasmSimdModulePath,me.glueCodePath,me.enableSIMD,me.versionsFilePath,me.pipelineModels);for(;!MlWasmJSApi$1.isInitialized();)await new Promise(Ge=>setTimeout(Ge,100));OnboardingAnalytics$1.estimatePerformance(),OnboardingAnalytics$1.setSimdIsEnabled(Ue),await MlWasmJSApi$1.initializePipelines();const Qe={}.VITE_WASM_PRODUCTION_MODE==="true";try{await MlWasmJSApi$1.setProductionMode(Qe)}catch(Ge){console.error(`Exception: ${Ge}`)}this.isSetupDetect=!0,addEvent({token:(Je=state.token)==null?void 0:Je.token,code:"modelLoadEnd",payload:{loadSuccessful:!0}})}}const DetectionSetup$1=DetectionSetup.getInstance(),sources={front:"FRONT_ID",back:"BACK_ID",selfie:"SELFIE"},logFrame=async({source:ue,base64Image:me,token:Ue})=>exports.api.post("/omni/log/frame/v2",{base64Image:me},{params:{source:ue},headers:{"X-Incode-Hardware-Id":Ue}}).then(Qe=>Qe.data).catch(emptyFunc);function useSelfie({timeout:ue=4e4,onLog:me=emptyFunc,handleCapture:Ue,numberOfTries:Qe=3,handleNoAttempsLeft:Ze=emptyFunc,webcam:Je,token:Ge,isDetecting:He,onSwitchManualCapture:Xe=emptyFunc,onManualCaptureSelfie:$e=emptyFunc}){const Ke=React$1.useRef(0),nt=React$1.useRef(!1),tt=React$1.useRef(!1),[et,rt]=React$1.useState(""),[it,ot]=React$1.useState("idle"),[at,st]=React$1.useState(!1),ct=React$1.useRef(void 0),[lt,dt]=React$1.useState(!1),ft=React$1.useRef(),gt=React$1.useRef(Xe),pt=React$1.useRef(null),Tt=React$1.useRef(!1),{t:Rt}=useTranslation(),bt=async(hn,An)=>{tt.current||(He.current=!1,await sleep(300),tt.current=!0,ot("uploading"),Ue(hn,An),await sleep(2e3),Nt(An).catch(console.log))},At=500;async function Nt(hn){var Xt;if(mobile.isDesktop())return;const en=document.querySelector("video").srcObject,un=en==null?void 0:en.getVideoTracks()[0];ct.current=(Xt=un==null?void 0:un.getSettings())==null?void 0:Xt.zoom;const gn=await zoomCameraToTheMax(en);if(mobile.iOS()&&!gn){await mt(un);return}await sleep(At);const Sn=Je.current.getCanvas();if(!Sn){await mt(un);return}const dn=Sn.getImageData(),yn=Sn.getBase64Image();logFrame({token:Ge,base64Image:yn,source:sources.selfie}),await MlWasmJSApi$1.allocateImageBuffers(dn.width,dn.height);const nn=await MlWasmJSApi$1.runSelfieCapture(dn);if(nn.faces.size()>0){const Kt=nn.faces.get(0),{rightEye:tn,leftEye:ln}=Kt;if(!(tn!=null&&tn.x)||!(tn!=null&&tn.y)||!(ln!=null&&ln.x)||!(ln!=null&&ln.y)){await mt(un);return}let an=1e4;if(hn&&(an=Math.sqrt((hn.rightEyeX-hn.leftEyeX)**2+(hn.rightEyeY-hn.leftEyeY)**2),an===0)){await mt(un);return}Math.sqrt((tn.x-ln.x)**2+(tn.y-ln.y)**2)/an<1.4&&await addDeviceStats(Ge,{virtualCameraDetected:!0})}await mt(un)}const mt=async hn=>{ct.current&&(await zoomCamera(hn,ct.current),await sleep(At),ct.current=hn.getSettings().zoom)},Ut=()=>{var An;const hn=getLogObject("timeout",{message:"No face found"});(An=gt.current)==null||An.call(gt),me(hn),dt(!0)},Mt=()=>{nt.current||(me(getLogObject("tooFar",{message:Rt("notifications.moveCloser")})),rt(Rt("notifications.moveCloser")))},yt=()=>{nt.current||(me(getLogObject("tooManyFaces",{message:Rt("notifications.tooManyFaces")})),rt(Rt("notifications.tooManyFaces")))},vt=()=>{nt.current||(me(getLogObject("centerFace",{message:Rt("notifications.centerFace")})),rt(Rt("notifications.centerFace")))},xt=()=>{tt.current||nt.current||(ot("capturing"),me(getLogObject("dontMove",{message:Rt("notifications.dontMove")})),rt(Rt("notifications.getReady")),nt.current=!0)},Et=()=>{nt.current||tt.current||rt(Rt("notifications.moveAway"))},Ct=()=>{nt.current||tt.current||rt(Rt("notifications.onDark"))},wt=()=>{nt.current||tt.current||rt(Rt("notifications.onBlur"))},Ft=()=>{nt.current||tt.current||rt(Rt("notifications.onFaceAngle"))},Lt=()=>{nt.current||tt.current||rt(Rt("notifications.removeHeadwear"))},Jt=()=>{nt.current||tt.current||rt(Rt("notifications.removeLenses"))},Qt=()=>{nt.current||tt.current||rt(Rt("notifications.openEyes"))},$t=()=>{nt.current||tt.current||rt(Rt("notifications.removeMask"))},Gt=async()=>{pt.current=new FaceDetection,await pt.current.initialize({onNoFace:emptyFunc,onCaptureFace:emptyFunc,onTooManyFaces:yt,onTooClose:Et,onCenterFace:vt,onFarAway:Mt,onCapturing:xt,onBlur:wt,onDark:Ct,onFaceAngle:Ft,onHeadWear:Lt,onLenses:Jt,onEyesClosed:Qt,onFaceMask:$t,onSwitchToManualCapture:Ut,onCapture:bt,isLensesCheckEnabled:!1,isMaskCheckEnabled:!1,isClosedEyesCheckEnabled:!0,isHeadWearCheckEnabled:!1,isVideoSelfie:!1,pipelineProfile:DetectionSetup$1.getProfile(PipelineType.SelfieFaceDetectionPipeline),autocaptureTimeout:ue})};React$1.useEffect(()=>{gt.current=Xe},[Xe]),React$1.useEffect(()=>{dt(!1)},[]);const Pt=async({response:hn,livenessPassed:An,imageBase64:en})=>{if(Ke.current=Ke.current+1,Qe!==-1&&Ke.current>=Qe)return Ze({response:hn,livenessPassed:An,imageBase64:en});rt(""),ot("idle"),nt.current=!1,tt.current=!1},jt=hn=>{const An=hn.errorMessage||hn.message||hn.reason,{status:en}=hn;if(en===3004){rt(Rt("notifications.unableToCrop")),me(getLogObject("unableToCrop",{message:`${Rt("notifications.unableToCrop")}`}));return}switch(An){case"No faces found on the image":rt(Rt("notifications.face")),me(getLogObject("faceNotDetected",{message:`${Rt("notifications.face")}`}));break;case"BadRequestException: More than one face detected.":rt(Rt("notifications.multiple")),me(getLogObject("multipleFacesDetected",{message:`${Rt("notifications.multiple")}`}));break;case"Cropping area goes off the image.":rt(Rt("notifications.crop")),me(getLogObject("cropTooSmall",{message:`${Rt("notifications.crop")}`}));break;case"Image in portrait orientation is expected.":rt(Rt("notifications.portrait")),me(getLogObject("imageNotPortrait",{message:`${Rt("notifications.portrait")}`}));break;default:me(getLogObject("InternalServerError",{message:`${Rt("notifications.error")}`})),rt(Rt("notifications.error"));break}},Dt=React$1.useCallback(async()=>{if(!(!He.current||Tt.current)){Tt.current=!0,pt.current||await Gt();try{await MlWasmJSApi$1.handleDetectionCallAndUpdateState(PipelineType.SelfieFaceDetectionPipeline);const hn=Je.current.getCanvas();await pt.current.detect(hn)}catch(hn){console.error(hn)}finally{Tt.current=!1}}},[Gt]);React$1.useEffect(()=>(onFrameEmitter.on("newFrame",Dt),()=>{onFrameEmitter.off("newFrame",Dt)}),[Dt]);const ut=React$1.useCallback(()=>{He.current||(He.current=!0,Je.current.video.play())},[me,Gt]),It=React$1.useCallback(async()=>{st(!0),await sleep(4e3),ut()},[ut]);function Vt(){$e();const hn=Je.current.getCanvas();hn.updateBase64Image(),hn.updateBlob(),bt(hn,null)}const Ot=it==="capturing",Zt=it==="uploading",zt=it==="success",Ht=it==="error",_t=Ot||Zt,sn=Zt||zt||Ht;return{notificationMessage:et,mode:it,capturing:nt,cameraReady:at,showManualCapture:lt,handleFaceAutoCapture:bt,setMode:ot,resetLoading:Pt,setNotificationMessage:rt,handleError:jt,autoDetectFace:ut,startAutoDetect:It,handleManualCapture:Vt,isCapturing:Ot,isUploading:Zt,isSuccess:zt,isError:Ht,isLoading:_t,hideCamera:sn,showBorders:at&&(it==="idle"||Ht),shouldShowManualCapture:lt&&!sn,selfieTimeoutRef:ft}}async function sendMfa({verificationCode:ue,transactionId:me}){return exports.api.post("/omni/oneToN/mfa",{verificationCode:ue,transactionId:me}).then(Ue=>Ue.data).catch(Ue=>{var Qe;return Promise.reject((Qe=Ue==null?void 0:Ue.response)==null?void 0:Qe.data)})}const ErrorContainer$1=styled.div`
1406
1406
  text-align: center;
1407
1407
  margin-top: 10px;
1408
1408
  `,ErrorSpan=styled.span`
@@ -2592,7 +2592,7 @@ newPrivacyConsent.text4
2592
2592
  `).filter(ot=>!!ot.trim());return jsxs(ConsentWrapper$1,{role:"region","aria-live":"assertive",className:`
2593
2593
  ${me.default?"IncodeDefaultConsent":"IncodeCustomConsent"}
2594
2594
  `,children:[jsx(ConsentTitle,{tabIndex:0,children:rt}),it.map((ot,at)=>jsx(ConsentParagraph,{tabIndex:0,children:me.default?jsx(Markdown,{disallowedElements:disallowedMarkdownElements,children:Ge(ot)}):jsx(Markdown,{disallowedElements:disallowedMarkdownElements,children:ot})},at)),jsx(AcceptCheck$2,{consentChecked:He,setConsentChecked:Xe,text:tt,id:"one"}),Ze?jsx(AcceptCheck$2,{consentChecked:$e,setConsentChecked:Ke,text:Ge("privacyCheck.aeromexico"),id:"two"}):null,jsx("div",{children:jsx(Button$a,{tabIndex:0,"aria-disabled":et,disabled:et,onClick:nt,children:Ge("privacyConsent.button.continue")})})]})}function PrivacyConsent({session:ue,title:me,text:Ue,goNext:Qe,isAeroMexicoClient:Ze,customCheck:Je}){const{t:Ge}=useTranslation(),[He,Xe]=React$1.useState(null);React$1.useEffect(()=>{Object.hasOwn||(Object.hasOwn=(nt,tt)=>Object.prototype.hasOwnProperty.call(nt,tt))},[]);const $e=nt=>{const tt=nt.split(`
2595
- `);return tt.length===1?tt.join(" "):tt.filter(et=>!!et.trim()).map(et=>Ge(et)).join(" ")},Ke=({title:nt,content:tt,isDefault:et})=>{addConsent({title:`${et?Ge(nt):nt}`,content:et?$e(tt):tt,status:!0,session:ue})};return React$1.useEffect(()=>{if(me||Ue){Xe({title:me||defaultPrivacyConsent.title,text:Ue||defaultPrivacyConsent.text,consentType:defaultPrivacyConsent.consentType,default:!Ue});return}getPrivacyConsentData({session:ue,type:"PRIVACY"}).then(({consents:nt})=>{const tt=nt.find(({consentType:et})=>et==="PRIVACY");tt!=null&&tt.text?Xe({...tt,title:(tt==null?void 0:tt.title.trim())||defaultPrivacyConsent.title,text:tt.text.trim()||defaultPrivacyConsent.text,default:!(tt!=null&&tt.text)}):Xe(defaultPrivacyConsent)}).catch(()=>{Xe(defaultPrivacyConsent)})},[ue,me,Ue]),He?jsx(NormalPrivacyConsent,{consent:He,goNext:Qe,addPrivacyConsent:Ke,session:ue,isAeroMexicoClient:Ze,customCheck:Je}):null}function renderUserConsent(ue,{session:me,onSuccess:Ue,title:Qe,text:Ze,isAeroMexicoClient:Je=!1,customCheck:Ge=null}){const He=createRoot$1(ue),Xe=handleUnmountRoot(Ue,He,ue);customRender(jsx(App$1,{token:me.token,children:jsx(PrivacyConsent,{goNext:Xe,session:me,title:Qe,text:Ze,isAeroMexicoClient:Je,customCheck:Ge})}),ue,He)}const version="1.72.0-rc.20240614183418";function r(ue){for(var me="",Ue=0;Ue<ue.length;++Ue)if(Ue>0){var Qe=ue[Ue].toLowerCase();Qe!==ue[Ue]?me+=" ".concat(Qe):me+=ue[Ue]}else me+=ue[Ue].toUpperCase();return me}function o(ue,me){return function(Ue,Qe){return Object.prototype.hasOwnProperty.call(Ue,Qe)}(ue,me)?ue[me]:void 0}var i$1={default:"endpoint"},u={default:"tlsEndpoint"},a="Client timeout",R="Network connection error",c="Network request aborted",s="Response cannot be parsed",E="Blocked by CSP",f="The endpoint parameter is not a valid URL",d=r("WrongRegion"),l=r("SubscriptionNotActive"),_=r("UnsupportedVersion"),p=r("InstallationMethodRestricted"),v=r("HostnameRestricted"),O=r("IntegrationFailed"),I="API key required",h="API key not found",N="API key expired",T="Request cannot be parsed",m="Request failed",w="Request failed to process",A="Too many requests, rate limit exceeded",P="Not available for this origin",y="Not available with restricted header",D=I,S=h,L=N,U="3.8.6",b="9319";function g(ue,me){var Ue=[];return function(Qe,Ze){var Je=5,Ge=(tt=Qe,et=__spreadArray$1([],tt,!0),{current:function(){return et[0]},postpone:function(){var it=et.shift();it!==void 0&&et.push(it)},exclude:function(){et.shift()}}),He=($e=100,Ke=3e3,nt=0,function(){return Math.random()*Math.min(Ke,$e*Math.pow(2,nt++))}),Xe=Ge.current(),$e,Ke,nt,tt,et;if(Xe===void 0)return Promise.reject(new TypeError("The list of script URL patterns is empty"));var rt=function(it,ot){return Ze(it).catch(function(at){if(ot+1>=Je)throw at;(function(lt){if(!(lt instanceof Error))return!1;var dt=lt.message;return dt===E||dt===b})(at)?Ge.exclude():Ge.postpone();var st,ct=Ge.current();if(ct===void 0)throw at;return(st=He(),new Promise(function(lt){return setTimeout(lt,st)})).then(function(){return rt(ct,ot+1)})})};return rt(Xe,0)}(ue,function(Qe){var Ze=new Date,Je=function(He){return Ue.push({url:Qe,startedAt:Ze,finishedAt:new Date,error:He})},Ge=me(Qe);return Ge.then(function(){return Je()},Je),Ge}).then(function(Qe){return[Qe,Ue]})}var C="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",K=C,M="Failed to load the JS script of the agent";function B(ue){var me;ue.scriptUrlPattern;var Ue=ue.token,Qe=ue.apiKey,Ze=Qe===void 0?Ue:Qe,Je=__rest$1(ue,["scriptUrlPattern","token","apiKey"]),Ge=(me=o(ue,"scriptUrlPattern"))!==null&&me!==void 0?me:C,He=function(){var Ke=[],nt=function(){Ke.push({time:new Date,state:document.visibilityState})},tt=function(et,rt,it,ot){return et.addEventListener(rt,it,ot),function(){return et.removeEventListener(rt,it,ot)}}(document,"visibilitychange",nt);return nt(),[Ke,tt]}(),Xe=He[0],$e=He[1];return Promise.resolve().then(function(){if(!Ze||typeof Ze!="string")throw new Error(I);var Ke=function(nt,tt){return(Array.isArray(nt)?nt:[nt]).map(function(et){return function(rt,it){var ot=encodeURIComponent;return rt.replace(/<[^<>]+>/g,function(at){return at==="<version>"?"3":at==="<apiKey>"?ot(it):at==="<loaderVersion>"?ot(U):at})}(String(et),tt)})}(Ge,Ze);return g(Ke,F)}).catch(function(Ke){throw $e(),function(nt){return nt instanceof Error&&nt.message===b?new Error(M):nt}(Ke)}).then(function(Ke){var nt=Ke[0],tt=Ke[1];return $e(),nt.load(__assign$2(__assign$2({},Je),{ldi:{attempts:tt,visibilityStates:Xe}}))})}function F(ue){return function(me,Ue,Qe,Ze){var Je,Ge=document,He="securitypolicyviolation",Xe=function(Ke){var nt=new URL(me,location.href),tt=Ke.blockedURI;tt!==nt.href&&tt!==nt.protocol.slice(0,-1)&&tt!==nt.origin||(Je=Ke,$e())};Ge.addEventListener(He,Xe);var $e=function(){return Ge.removeEventListener(He,Xe)};return Ze==null||Ze.then($e,$e),Promise.resolve().then(Ue).then(function(Ke){return $e(),Ke},function(Ke){return new Promise(function(nt){return setTimeout(nt)}).then(function(){if($e(),Je)return Qe(Je);throw Ke})})}(ue,function(){return function(me){return new Promise(function(Ue,Qe){var Ze=document.createElement("script"),Je=function(){var He;return(He=Ze.parentNode)===null||He===void 0?void 0:He.removeChild(Ze)},Ge=document.head||document.getElementsByTagName("head")[0];Ze.onload=function(){Je(),Ue()},Ze.onerror=function(){Je(),Qe(new Error(M))},Ze.async=!0,Ze.src=me,Ge.appendChild(Ze)})}(ue)},function(){throw new Error(E)}).then(V)}function V(){var ue=window,me="__fpjs_p_l_b",Ue=ue[me];if(function(Qe,Ze){var Je,Ge=(Je=Object.getOwnPropertyDescriptor)===null||Je===void 0?void 0:Je.call(Object,Qe,Ze);Ge!=null&&Ge.configurable?delete Qe[Ze]:Ge&&!Ge.writable||(Qe[Ze]=void 0)}(ue,me),typeof(Ue==null?void 0:Ue.load)!="function")throw new Error(b);return Ue}var k={load:B,defaultScriptUrlPattern:K,ERROR_SCRIPT_LOAD_FAIL:M,ERROR_API_KEY_EXPIRED:N,ERROR_API_KEY_INVALID:h,ERROR_API_KEY_MISSING:I,ERROR_BAD_REQUEST_FORMAT:T,ERROR_BAD_RESPONSE_FORMAT:s,ERROR_CLIENT_TIMEOUT:a,ERROR_CSP_BLOCK:E,ERROR_FORBIDDEN_ENDPOINT:v,ERROR_FORBIDDEN_HEADER:y,ERROR_FORBIDDEN_ORIGIN:P,ERROR_GENERAL_SERVER_FAILURE:m,ERROR_INSTALLATION_METHOD_RESTRICTED:p,ERROR_INTEGRATION_FAILURE:O,ERROR_INVALID_ENDPOINT:f,ERROR_NETWORK_ABORT:c,ERROR_NETWORK_CONNECTION:R,ERROR_RATE_LIMIT:A,ERROR_SERVER_TIMEOUT:w,ERROR_SUBSCRIPTION_NOT_ACTIVE:l,ERROR_TOKEN_EXPIRED:L,ERROR_TOKEN_INVALID:S,ERROR_TOKEN_MISSING:D,ERROR_UNSUPPORTED_VERSION:_,ERROR_WRONG_REGION:d,defaultEndpoint:i$1,defaultTlsEndpoint:u};let fingerprintApiKey;function setFingerprintApiKey(ue){fingerprintApiKey=ue}async function getFingerPrint(){return k.load({token:fingerprintApiKey,endpoint:"https://fingerprint.incodesmile.com",scriptUrlPattern:"https://fingerprint.incodesmile.com/web/v<version>/<apiKey>/loader_v<loaderVersion>.js"}).then(ue=>ue.get({extendedResult:!0}))}const fingerPrintUrl="/omni/add/device-fingerprint";function postFingerprint({hash:ue,ip:me,deviceType:Ue,token:Qe,data:Ze,osVersion:Je,deviceModel:Ge,browser:He,sdkVersion:Xe,hasLiedBrowser:$e,hostingApp:Ke,ipLocation:nt}){return exports.api.post(fingerPrintUrl,{hash:ue,ip:me,deviceType:Ue,data:Ze,osVersion:Je,deviceModel:Ge,browser:He,hasLiedBrowser:$e,sdkVersion:Xe,hostingApp:Ke,ipLocation:nt},{headers:{"X-Incode-Hardware-Id":Qe}}).then(tt=>tt.data).catch(tt=>Promise.reject(tt.response.data))}function formatDeviceModel({vendor:ue,model:me}){return`${ue||""} ${me||""}`.trim()}const emptyFingerprint={visitorId:void 0,ip:void 0,ipLocation:{country:{name:void 0},subdivisions:[],city:{name:void 0},latitude:void 0,longitude:void 0}};async function sendFingerprint({token:ue},me=!0,Ue=!0){var Xe,$e,Ke;const Qe="WEBAPP",{os:Ze,device:Je,browser:Ge}=getUAParserResults(),He=Ue?await getFingerPrint().catch(nt=>(addEvent({code:"fingerprintFetchFailed",payload:{message:nt.message},token:ue}),emptyFingerprint)):emptyFingerprint;return postFingerprint({hash:He.visitorId||"",ip:me&&He.ip||"",deviceType:Qe,token:ue,data:JSON.stringify(He),osVersion:`${Ze.name} ${Ze.version}`,deviceModel:formatDeviceModel(Je),browser:`${Ge.name} ${Ge.version}`,hasLiedBrowser:isBrowserSimulation(),hostingApp:options.hostingApp,sdkVersion:version,ipLocation:{ipCountry:(Xe=He.ipLocation.country)==null?void 0:Xe.name,ipRegion:($e=He.ipLocation.subdivisions)==null?void 0:$e[0].name,ipCity:(Ke=He.ipLocation.city)==null?void 0:Ke.name,ipLatitude:He.ipLocation.latitude,ipLongitude:He.ipLocation.longitude}}).then(nt=>(emptyDeviceStatsQueue(ue),nt))}function mapI18nLang(ue){const me={en:"en-US",es:"es-ES",pt:"pt-BR"},Ue=ue==null?void 0:ue.substring(0,2);return me[Ue]||"en-US"}const createSessionUrl="/omni/start";async function createNewSession({externalId:ue,externalCustomerId:me,configurationId:Ue,uuid:Qe,interviewId:Ze,customFields:Je,language:Ge}={}){const He=Ge||mapI18nLang(i18nInstance.language);try{const Xe=await exports.api.post(createSessionUrl,{externalId:ue,externalCustomerId:me,configurationId:Ue,uuid:Qe,interviewId:Ze,customFields:Je,language:He});state.token=Xe.data;const $e=Xe.data;emptyQueue($e.token);const Ke=await sendFingerprint({token:$e.token,interviewId:$e.interviewId}).catch(()=>({regulationType:"",showMandatoryConsent:!1}));$e.regulationType=Ke.regulationType??"",$e.showMandatoryConsent=Ke.showMandatoryConsent??!1;const tt=new UAParser().getResult();return addEvent({code:"browser",payload:{userAgent:window.navigator.userAgent,isWebRtcSupported:isWebRtcSupported(),...tt},token:$e.token}),$e}catch(Xe){throw Xe!=null&&Xe.response?Xe.response.data:Xe}}const createRedirectUrl=async({session:ue})=>{const{url:me}=await exports.api.get("/omni/onboarding-url",{params:{clientId:ue.clientId},headers:{"X-Incode-Hardware-Id":ue.token}}).then(Ue=>Ue.data);return me};async function createSession$3(ue,me,{externalCustomerId:Ue,configurationId:Qe,uuid:Ze,interviewId:Je,customFields:Ge,language:He}={}){return createNewSession({externalId:me,externalCustomerId:Ue,configurationId:Qe,uuid:Ze,interviewId:Je,customFields:Ge,language:He})}var isHTMLElement=ue=>ue instanceof HTMLElement;const EVENTS={BLUR:"blur",CHANGE:"change",INPUT:"input"},VALIDATION_MODE={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},SELECT="select",UNDEFINED="undefined",INPUT_VALIDATION_RULES={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"};function attachEventListeners({ref:ue},me,Ue){isHTMLElement(ue)&&Ue&&(ue.addEventListener(me?EVENTS.CHANGE:EVENTS.INPUT,Ue),ue.addEventListener(EVENTS.BLUR,Ue))}var isNullOrUndefined=ue=>ue==null;const isObjectType=ue=>typeof ue=="object";var isObject$4=ue=>!isNullOrUndefined(ue)&&!Array.isArray(ue)&&isObjectType(ue)&&!(ue instanceof Date),isKey=ue=>/^\w*$/.test(ue),compact=ue=>ue.filter(Boolean),stringToPath=ue=>compact(ue.replace(/["|']/g,"").replace(/\[/g,".").replace(/\]/g,"").split("."));function set(ue,me,Ue){let Qe=-1;const Ze=isKey(me)?[me]:stringToPath(me),Je=Ze.length,Ge=Je-1;for(;++Qe<Je;){const He=Ze[Qe];let Xe=Ue;if(Qe!==Ge){const $e=ue[He];Xe=isObject$4($e)||Array.isArray($e)?$e:isNaN(+Ze[Qe+1])?{}:[]}ue[He]=Xe,ue=ue[He]}return ue}var transformToNestObject=(ue,me={})=>{for(const Ue in ue)isKey(Ue)?me[Ue]=ue[Ue]:set(me,Ue,ue[Ue]);return me},isUndefined$1=ue=>ue===void 0,get=(ue={},me,Ue)=>{const Qe=compact(me.split(/[,[\].]+?/)).reduce((Ze,Je)=>isNullOrUndefined(Ze)?Ze:Ze[Je],ue);return isUndefined$1(Qe)||Qe===ue?isUndefined$1(ue[me])?Ue:ue[me]:Qe},focusOnErrorField=(ue,me)=>{for(const Ue in ue)if(get(me,Ue)){const Qe=ue[Ue];if(Qe){if(Qe.ref.focus&&isUndefined$1(Qe.ref.focus()))break;if(Qe.options){Qe.options[0].ref.focus();break}}}},removeAllEventListeners=(ue,me)=>{isHTMLElement(ue)&&ue.removeEventListener&&(ue.removeEventListener(EVENTS.INPUT,me),ue.removeEventListener(EVENTS.CHANGE,me),ue.removeEventListener(EVENTS.BLUR,me))};const defaultReturn={isValid:!1,value:null};var getRadioValue=ue=>Array.isArray(ue)?ue.reduce((me,Ue)=>Ue&&Ue.ref.checked?{isValid:!0,value:Ue.ref.value}:me,defaultReturn):defaultReturn,getMultipleSelectValue=ue=>[...ue].filter(({selected:me})=>me).map(({value:me})=>me),isRadioInput=ue=>ue.type==="radio",isFileInput=ue=>ue.type==="file",isCheckBoxInput=ue=>ue.type==="checkbox",isMultipleSelect=ue=>ue.type===`${SELECT}-multiple`;const defaultResult={value:!1,isValid:!1},validResult={value:!0,isValid:!0};var getCheckboxValue=ue=>{if(Array.isArray(ue)){if(ue.length>1){const Ze=ue.filter(Je=>Je&&Je.ref.checked).map(({ref:{value:Je}})=>Je);return{value:Ze,isValid:!!Ze.length}}const{checked:me,value:Ue,attributes:Qe}=ue[0].ref;return me?Qe&&!isUndefined$1(Qe.value)?isUndefined$1(Ue)||Ue===""?validResult:{value:Ue,isValid:!0}:validResult:defaultResult}return defaultResult};function getFieldValue(ue,me,Ue,Qe,Ze){const Je=ue.current[me];if(Je){const{ref:{value:Ge,disabled:He},ref:Xe,valueAsNumber:$e,valueAsDate:Ke,setValueAs:nt}=Je;return He&&Qe?void 0:isFileInput(Xe)?Xe.files:isRadioInput(Xe)?getRadioValue(Je.options).value:isMultipleSelect(Xe)?getMultipleSelectValue(Xe.options):isCheckBoxInput(Xe)?getCheckboxValue(Je.options).value:Ze?Ge:$e?Ge===""?NaN:+Ge:Ke?Xe.valueAsDate:nt?nt(Ge):Ge}if(Ue)return get(Ue.current,me)}function isDetached(ue){return ue?!(ue instanceof HTMLElement)||ue.nodeType===Node.DOCUMENT_NODE?!1:isDetached(ue.parentNode):!0}var isEmptyObject=ue=>isObject$4(ue)&&!Object.keys(ue).length,isBoolean=ue=>typeof ue=="boolean";function baseGet(ue,me){const Ue=me.slice(0,-1).length;let Qe=0;for(;Qe<Ue;)ue=isUndefined$1(ue)?Qe++:ue[me[Qe++]];return ue}function unset(ue,me){const Ue=isKey(me)?[me]:stringToPath(me),Qe=Ue.length==1?ue:baseGet(ue,Ue),Ze=Ue[Ue.length-1];let Je;Qe&&delete Qe[Ze];for(let Ge=0;Ge<Ue.slice(0,-1).length;Ge++){let He=-1,Xe;const $e=Ue.slice(0,-(Ge+1)),Ke=$e.length-1;for(Ge>0&&(Je=ue);++He<$e.length;){const nt=$e[He];Xe=Xe?Xe[nt]:ue[nt],Ke===He&&(isObject$4(Xe)&&isEmptyObject(Xe)||Array.isArray(Xe)&&!Xe.filter(tt=>isObject$4(tt)&&!isEmptyObject(tt)||isBoolean(tt)).length)&&(Je?delete Je[nt]:delete ue[nt]),Je=Xe}}return ue}const isSameRef=(ue,me)=>ue&&ue.ref===me;function findRemovedFieldAndRemoveListener(ue,me,Ue,Qe,Ze,Je){const{ref:Ge,ref:{name:He}}=Ue,Xe=ue.current[He];if(!Ze){const $e=getFieldValue(ue,He,Qe);!isUndefined$1($e)&&set(Qe.current,He,$e)}if(!Ge.type||!Xe){delete ue.current[He];return}isRadioInput(Ge)||isCheckBoxInput(Ge)?Array.isArray(Xe.options)&&Xe.options.length?(compact(Xe.options).forEach(($e={},Ke)=>{(isDetached($e.ref)&&isSameRef($e,$e.ref)||Je)&&(removeAllEventListeners($e.ref,me),unset(Xe.options,`[${Ke}]`))}),Xe.options&&!compact(Xe.options).length&&delete ue.current[He]):delete ue.current[He]:(isDetached(Ge)&&isSameRef(Xe,Ge)||Je)&&(removeAllEventListeners(Ge,me),delete ue.current[He])}var isPrimitive=ue=>isNullOrUndefined(ue)||!isObjectType(ue);function deepMerge(ue,me){if(isPrimitive(ue)||isPrimitive(me))return me;for(const Ue in me){const Qe=ue[Ue],Ze=me[Ue];try{ue[Ue]=isObject$4(Qe)&&isObject$4(Ze)||Array.isArray(Qe)&&Array.isArray(Ze)?deepMerge(Qe,Ze):Ze}catch{}}return ue}function deepEqual(ue,me,Ue){if(isPrimitive(ue)||isPrimitive(me)||ue instanceof Date||me instanceof Date)return ue===me;if(!React$1.isValidElement(ue)){const Qe=Object.keys(ue),Ze=Object.keys(me);if(Qe.length!==Ze.length)return!1;for(const Je of Qe){const Ge=ue[Je];if(!(Ue&&Je==="ref")){const He=me[Je];if((isObject$4(Ge)||Array.isArray(Ge))&&(isObject$4(He)||Array.isArray(He))?!deepEqual(Ge,He,Ue):Ge!==He)return!1}}}return!0}function setDirtyFields(ue,me,Ue,Qe,Ze){let Je=-1;for(;++Je<ue.length;){for(const Ge in ue[Je])Array.isArray(ue[Je][Ge])?(!Ue[Je]&&(Ue[Je]={}),Ue[Je][Ge]=[],setDirtyFields(ue[Je][Ge],get(me[Je]||{},Ge,[]),Ue[Je][Ge],Ue[Je],Ge)):deepEqual(get(me[Je]||{},Ge),ue[Je][Ge])?set(Ue[Je]||{},Ge):Ue[Je]=Object.assign(Object.assign({},Ue[Je]),{[Ge]:!0});Qe&&!Ue.length&&delete Qe[Ze]}return Ue}var setFieldArrayDirtyFields=(ue,me,Ue)=>deepMerge(setDirtyFields(ue,me,Ue.slice(0,ue.length)),setDirtyFields(me,ue,Ue.slice(0,ue.length))),isString$2=ue=>typeof ue=="string",getFieldsValues=(ue,me,Ue,Qe,Ze)=>{const Je={};for(const Ge in ue.current)(isUndefined$1(Ze)||(isString$2(Ze)?Ge.startsWith(Ze):Array.isArray(Ze)&&Ze.find(He=>Ge.startsWith(He))))&&(Je[Ge]=getFieldValue(ue,Ge,void 0,Qe));return Ue?transformToNestObject(Je):deepMerge(me,transformToNestObject(Je))},isErrorStateChanged=({errors:ue,name:me,error:Ue,validFields:Qe,fieldsWithValidation:Ze})=>{const Je=isUndefined$1(Ue),Ge=get(ue,me);return Je&&!!Ge||!Je&&!deepEqual(Ge,Ue,!0)||Je&&get(Ze,me)&&!get(Qe,me)},isRegex=ue=>ue instanceof RegExp,getValueAndMessage=ue=>isObject$4(ue)&&!isRegex(ue)?ue:{value:ue,message:""},isFunction$1=ue=>typeof ue=="function",isMessage=ue=>isString$2(ue)||React$1.isValidElement(ue);function getValidateError(ue,me,Ue="validate"){if(isMessage(ue)||isBoolean(ue)&&!ue)return{type:Ue,message:isMessage(ue)?ue:"",ref:me}}var appendErrors=(ue,me,Ue,Qe,Ze)=>me?Object.assign(Object.assign({},Ue[ue]),{types:Object.assign(Object.assign({},Ue[ue]&&Ue[ue].types?Ue[ue].types:{}),{[Qe]:Ze||!0})}):{},validateField=async(ue,me,{ref:Ue,ref:{value:Qe},options:Ze,required:Je,maxLength:Ge,minLength:He,min:Xe,max:$e,pattern:Ke,validate:nt},tt)=>{const et=Ue.name,rt={},it=isRadioInput(Ue),ot=isCheckBoxInput(Ue),at=it||ot,st=Qe==="",ct=appendErrors.bind(null,et,me,rt),lt=(dt,ft,gt,pt=INPUT_VALIDATION_RULES.maxLength,Tt=INPUT_VALIDATION_RULES.minLength)=>{const Rt=dt?ft:gt;rt[et]=Object.assign({type:dt?pt:Tt,message:Rt,ref:Ue},ct(dt?pt:Tt,Rt))};if(Je&&(!it&&!ot&&(st||isNullOrUndefined(Qe))||isBoolean(Qe)&&!Qe||ot&&!getCheckboxValue(Ze).isValid||it&&!getRadioValue(Ze).isValid)){const{value:dt,message:ft}=isMessage(Je)?{value:!!Je,message:Je}:getValueAndMessage(Je);if(dt&&(rt[et]=Object.assign({type:INPUT_VALIDATION_RULES.required,message:ft,ref:at?((ue.current[et].options||[])[0]||{}).ref:Ue},ct(INPUT_VALIDATION_RULES.required,ft)),!me))return rt}if((!isNullOrUndefined(Xe)||!isNullOrUndefined($e))&&Qe!==""){let dt,ft;const gt=getValueAndMessage($e),pt=getValueAndMessage(Xe);if(isNaN(Qe)){const Tt=Ue.valueAsDate||new Date(Qe);isString$2(gt.value)&&(dt=Tt>new Date(gt.value)),isString$2(pt.value)&&(ft=Tt<new Date(pt.value))}else{const Tt=Ue.valueAsNumber||parseFloat(Qe);isNullOrUndefined(gt.value)||(dt=Tt>gt.value),isNullOrUndefined(pt.value)||(ft=Tt<pt.value)}if((dt||ft)&&(lt(!!dt,gt.message,pt.message,INPUT_VALIDATION_RULES.max,INPUT_VALIDATION_RULES.min),!me))return rt}if(isString$2(Qe)&&!st&&(Ge||He)){const dt=getValueAndMessage(Ge),ft=getValueAndMessage(He),gt=!isNullOrUndefined(dt.value)&&Qe.length>dt.value,pt=!isNullOrUndefined(ft.value)&&Qe.length<ft.value;if((gt||pt)&&(lt(gt,dt.message,ft.message),!me))return rt}if(isString$2(Qe)&&Ke&&!st){const{value:dt,message:ft}=getValueAndMessage(Ke);if(isRegex(dt)&&!dt.test(Qe)&&(rt[et]=Object.assign({type:INPUT_VALIDATION_RULES.pattern,message:ft,ref:Ue},ct(INPUT_VALIDATION_RULES.pattern,ft)),!me))return rt}if(nt){const dt=getFieldValue(ue,et,tt,!1,!0),ft=at&&Ze?Ze[0].ref:Ue;if(isFunction$1(nt)){const gt=await nt(dt),pt=getValidateError(gt,ft);if(pt&&(rt[et]=Object.assign(Object.assign({},pt),ct(INPUT_VALIDATION_RULES.validate,pt.message)),!me))return rt}else if(isObject$4(nt)){let gt={};for(const[pt,Tt]of Object.entries(nt)){if(!isEmptyObject(gt)&&!me)break;const Rt=await Tt(dt),bt=getValidateError(Rt,ft,pt);bt&&(gt=Object.assign(Object.assign({},bt),ct(pt,bt.message)),me&&(rt[et]=gt))}if(!isEmptyObject(gt)&&(rt[et]=Object.assign({ref:ft},gt),!me))return rt}}return rt};const getPath=(ue,me,Ue=[])=>{for(const Qe in me){const Ze=ue+(isObject$4(me)?`.${Qe}`:`[${Qe}]`);isPrimitive(me[Qe])?Ue.push(Ze):getPath(Ze,me[Qe],Ue)}return Ue};var assignWatchFields=(ue,me,Ue,Qe,Ze)=>{let Je;return Ue.add(me),isEmptyObject(ue)||(Je=get(ue,me),(isObject$4(Je)||Array.isArray(Je))&&getPath(me,Je).forEach(Ge=>Ue.add(Ge))),isUndefined$1(Je)?Ze?Qe:get(Qe,me):Je},skipValidation=({isOnBlur:ue,isOnChange:me,isOnTouch:Ue,isTouched:Qe,isReValidateOnBlur:Ze,isReValidateOnChange:Je,isBlurEvent:Ge,isSubmitted:He,isOnAll:Xe})=>Xe?!1:!He&&Ue?!(Qe||Ge):(He?Ze:ue)?!Ge:(He?Je:me)?Ge:!0,getFieldArrayParentName=ue=>ue.substring(0,ue.indexOf("["));const isMatchFieldArrayName=(ue,me)=>RegExp(`^${me}([|.)\\d+`.replace(/\[/g,"\\[").replace(/\]/g,"\\]")).test(ue);var isNameInFieldArray=(ue,me)=>[...ue].some(Ue=>isMatchFieldArrayName(me,Ue)),isSelectInput=ue=>ue.type===`${SELECT}-one`;function onDomRemove(ue,me){const Ue=new MutationObserver(()=>{for(const Qe of Object.values(ue.current))if(Qe&&Qe.options)for(const Ze of Qe.options)Ze&&Ze.ref&&isDetached(Ze.ref)&&me(Qe);else Qe&&isDetached(Qe.ref)&&me(Qe)});return Ue.observe(window.document,{childList:!0,subtree:!0}),Ue}var isWeb=typeof window!==UNDEFINED&&typeof document!==UNDEFINED;function cloneObject(ue){var me;let Ue;if(isPrimitive(ue)||isWeb&&(ue instanceof File||isHTMLElement(ue))||!["Set","Map","Object","Date","Array"].includes((me=ue.constructor)===null||me===void 0?void 0:me.name))return ue;if(ue instanceof Date)return Ue=new Date(ue.getTime()),Ue;if(ue instanceof Set){Ue=new Set;for(const Qe of ue)Ue.add(Qe);return Ue}if(ue instanceof Map){Ue=new Map;for(const Qe of ue.keys())Ue.set(Qe,cloneObject(ue.get(Qe)));return Ue}Ue=Array.isArray(ue)?[]:{};for(const Qe in ue)Ue[Qe]=cloneObject(ue[Qe]);return Ue}var modeChecker=ue=>({isOnSubmit:!ue||ue===VALIDATION_MODE.onSubmit,isOnBlur:ue===VALIDATION_MODE.onBlur,isOnChange:ue===VALIDATION_MODE.onChange,isOnAll:ue===VALIDATION_MODE.all,isOnTouch:ue===VALIDATION_MODE.onTouched}),isRadioOrCheckboxFunction=ue=>isRadioInput(ue)||isCheckBoxInput(ue);const isWindowUndefined=typeof window===UNDEFINED,isProxyEnabled=isWeb?"Proxy"in window:typeof Proxy!==UNDEFINED;function useForm({mode:ue=VALIDATION_MODE.onSubmit,reValidateMode:me=VALIDATION_MODE.onChange,resolver:Ue,context:Qe,defaultValues:Ze={},shouldFocusError:Je=!0,shouldUnregister:Ge=!0,criteriaMode:He}={}){const Xe=React$1.useRef({}),$e=React$1.useRef({}),Ke=React$1.useRef({}),nt=React$1.useRef(new Set),tt=React$1.useRef({}),et=React$1.useRef({}),rt=React$1.useRef({}),it=React$1.useRef({}),ot=React$1.useRef(Ze),at=React$1.useRef(!1),st=React$1.useRef(!1),ct=React$1.useRef(),lt=React$1.useRef({}),dt=React$1.useRef({}),ft=React$1.useRef(Qe),gt=React$1.useRef(Ue),pt=React$1.useRef(new Set),Tt=React$1.useRef(modeChecker(ue)),{isOnSubmit:Rt,isOnTouch:bt}=Tt.current,At=He===VALIDATION_MODE.all,[Nt,mt]=React$1.useState({isDirty:!1,isValidating:!1,dirtyFields:{},isSubmitted:!1,submitCount:0,touched:{},isSubmitting:!1,isSubmitSuccessful:!1,isValid:!Rt,errors:{}}),Ut=React$1.useRef({isDirty:!isProxyEnabled,dirtyFields:!isProxyEnabled,touched:!isProxyEnabled||bt,isValidating:!isProxyEnabled,isSubmitting:!isProxyEnabled,isValid:!isProxyEnabled}),Mt=React$1.useRef(Nt),yt=React$1.useRef(),{isOnBlur:vt,isOnChange:xt}=React$1.useRef(modeChecker(me)).current;ft.current=Qe,gt.current=Ue,Mt.current=Nt,lt.current=Ge?{}:isEmptyObject(lt.current)?cloneObject(Ze):lt.current;const Et=React$1.useCallback((Xt={})=>{at.current||(Mt.current=Object.assign(Object.assign({},Mt.current),Xt),mt(Mt.current))},[]),Ct=()=>Ut.current.isValidating&&Et({isValidating:!0}),wt=React$1.useCallback((Xt,Kt,tn=!1,ln={},an)=>{let mn=tn||isErrorStateChanged({errors:Mt.current.errors,error:Kt,name:Xt,validFields:it.current,fieldsWithValidation:rt.current});const Mn=get(Mt.current.errors,Xt);Kt?(unset(it.current,Xt),mn=mn||!Mn||!deepEqual(Mn,Kt,!0),set(Mt.current.errors,Xt,Kt)):((get(rt.current,Xt)||gt.current)&&(set(it.current,Xt,!0),mn=mn||Mn),unset(Mt.current.errors,Xt)),(mn&&!isNullOrUndefined(tn)||!isEmptyObject(ln)||Ut.current.isValidating)&&Et(Object.assign(Object.assign(Object.assign({},ln),gt.current?{isValid:!!an}:{}),{isValidating:!1}))},[]),Ft=React$1.useCallback((Xt,Kt)=>{const{ref:tn,options:ln}=Xe.current[Xt],an=isWeb&&isHTMLElement(tn)&&isNullOrUndefined(Kt)?"":Kt;isRadioInput(tn)?(ln||[]).forEach(({ref:mn})=>mn.checked=mn.value===an):isFileInput(tn)&&!isString$2(an)?tn.files=an:isMultipleSelect(tn)?[...tn.options].forEach(mn=>mn.selected=an.includes(mn.value)):isCheckBoxInput(tn)&&ln?ln.length>1?ln.forEach(({ref:mn})=>mn.checked=Array.isArray(an)?!!an.find(Mn=>Mn===mn.value):an===mn.value):ln[0].ref.checked=!!an:tn.value=an},[]),Lt=React$1.useCallback((Xt,Kt)=>{if(Ut.current.isDirty){const tn=Ot();return Xt&&Kt&&set(tn,Xt,Kt),!deepEqual(tn,ot.current)}return!1},[]),Jt=React$1.useCallback((Xt,Kt=!0)=>{if(Ut.current.isDirty||Ut.current.dirtyFields){const tn=!deepEqual(get(ot.current,Xt),getFieldValue(Xe,Xt,lt)),ln=get(Mt.current.dirtyFields,Xt),an=Mt.current.isDirty;tn?set(Mt.current.dirtyFields,Xt,!0):unset(Mt.current.dirtyFields,Xt);const mn={isDirty:Lt(),dirtyFields:Mt.current.dirtyFields},Mn=Ut.current.isDirty&&an!==mn.isDirty||Ut.current.dirtyFields&&ln!==get(Mt.current.dirtyFields,Xt);return Mn&&Kt&&Et(mn),Mn?mn:{}}return{}},[]),Qt=React$1.useCallback(async(Xt,Kt)=>{if(process.env.NODE_ENV!=="production"&&!Xe.current[Xt])return console.warn("📋 Field is missing with `name` attribute: ",Xt),!1;const tn=(await validateField(Xe,At,Xe.current[Xt],lt))[Xt];return wt(Xt,tn,Kt),isUndefined$1(tn)},[wt,At]),$t=React$1.useCallback(async Xt=>{const{errors:Kt}=await gt.current(Ot(),ft.current,At),tn=Mt.current.isValid;if(Array.isArray(Xt)){const ln=Xt.map(an=>{const mn=get(Kt,an);return mn?set(Mt.current.errors,an,mn):unset(Mt.current.errors,an),!mn}).every(Boolean);return Et({isValid:isEmptyObject(Kt),isValidating:!1}),ln}else{const ln=get(Kt,Xt);return wt(Xt,ln,tn!==isEmptyObject(Kt),{},isEmptyObject(Kt)),!ln}},[wt,At]),Gt=React$1.useCallback(async Xt=>{const Kt=Xt||Object.keys(Xe.current);if(Ct(),gt.current)return $t(Kt);if(Array.isArray(Kt)){!Xt&&(Mt.current.errors={});const tn=await Promise.all(Kt.map(async ln=>await Qt(ln,null)));return Et({isValidating:!1}),tn.every(Boolean)}return await Qt(Kt)},[$t,Qt]),Pt=React$1.useCallback((Xt,Kt,{shouldDirty:tn,shouldValidate:ln})=>{const an={};set(an,Xt,Kt);for(const mn of getPath(Xt,Kt))Xe.current[mn]&&(Ft(mn,get(an,mn)),tn&&Jt(mn),ln&&Gt(mn))},[Gt,Ft,Jt]),jt=React$1.useCallback((Xt,Kt,tn)=>{if(!Ge&&!isPrimitive(Kt)&&set(lt.current,Xt,Array.isArray(Kt)?[...Kt]:Object.assign({},Kt)),Xe.current[Xt])Ft(Xt,Kt),tn.shouldDirty&&Jt(Xt),tn.shouldValidate&&Gt(Xt);else if(!isPrimitive(Kt)&&(Pt(Xt,Kt,tn),pt.current.has(Xt))){const ln=getFieldArrayParentName(Xt)||Xt;set($e.current,Xt,Kt),dt.current[ln]({[ln]:get($e.current,ln)}),(Ut.current.isDirty||Ut.current.dirtyFields)&&tn.shouldDirty&&(set(Mt.current.dirtyFields,Xt,setFieldArrayDirtyFields(Kt,get(ot.current,Xt,[]),get(Mt.current.dirtyFields,Xt,[]))),Et({isDirty:!deepEqual(Object.assign(Object.assign({},Ot()),{[Xt]:Kt}),ot.current)}))}!Ge&&set(lt.current,Xt,Kt)},[Jt,Ft,Pt]),Dt=Xt=>st.current||nt.current.has(Xt)||nt.current.has((Xt.match(/\w+/)||[])[0]),ut=Xt=>{let Kt=!0;if(!isEmptyObject(tt.current))for(const tn in tt.current)(!Xt||!tt.current[tn].size||tt.current[tn].has(Xt)||tt.current[tn].has(getFieldArrayParentName(Xt)))&&(et.current[tn](),Kt=!1);return Kt};function It(Xt,Kt,tn){jt(Xt,Kt,tn||{}),Dt(Xt)&&Et(),ut(Xt)}ct.current=ct.current?ct.current:async({type:Xt,target:Kt})=>{let tn=Kt.name;const ln=Xe.current[tn];let an,mn;if(ln){const Mn=Xt===EVENTS.BLUR,Dn=skipValidation(Object.assign({isBlurEvent:Mn,isReValidateOnChange:xt,isReValidateOnBlur:vt,isTouched:!!get(Mt.current.touched,tn),isSubmitted:Mt.current.isSubmitted},Tt.current));let kn=Jt(tn,!1),Ln=!isEmptyObject(kn)||!Mn&&Dt(tn);if(Mn&&!get(Mt.current.touched,tn)&&Ut.current.touched&&(set(Mt.current.touched,tn,!0),kn=Object.assign(Object.assign({},kn),{touched:Mt.current.touched})),!Ge&&isCheckBoxInput(Kt)&&set(lt.current,tn,getFieldValue(Xe,tn)),Dn)return!Mn&&ut(tn),(!isEmptyObject(kn)||Ln&&isEmptyObject(kn))&&Et(kn);if(Ct(),gt.current){const{errors:On}=await gt.current(Ot(),ft.current,At),Vn=Mt.current.isValid;if(an=get(On,tn),isCheckBoxInput(Kt)&&!an&&gt.current){const $n=getFieldArrayParentName(tn),xn=get(On,$n,{});xn.type&&xn.message&&(an=xn),$n&&(xn||get(Mt.current.errors,$n))&&(tn=$n)}mn=isEmptyObject(On),Vn!==mn&&(Ln=!0)}else an=(await validateField(Xe,At,ln,lt))[tn];!Mn&&ut(tn),wt(tn,an,Ln,kn,mn)}};function Vt(Xt){if(!Ge){let Kt=cloneObject(Xt);for(const tn of pt.current)isKey(tn)&&!Kt[tn]&&(Kt=Object.assign(Object.assign({},Kt),{[tn]:[]}));return Kt}return Xt}function Ot(Xt){if(isString$2(Xt))return getFieldValue(Xe,Xt,lt);if(Array.isArray(Xt)){const Kt={};for(const tn of Xt)set(Kt,tn,getFieldValue(Xe,tn,lt));return Kt}return Vt(getFieldsValues(Xe,cloneObject(lt.current),Ge))}const Zt=React$1.useCallback(async(Xt={})=>{const Kt=isEmptyObject(Xe.current)?ot.current:{},{errors:tn}=await gt.current(Object.assign(Object.assign(Object.assign({},Kt),Ot()),Xt),ft.current,At)||{},ln=isEmptyObject(tn);Mt.current.isValid!==ln&&Et({isValid:ln})},[At]),zt=React$1.useCallback((Xt,Kt)=>{findRemovedFieldAndRemoveListener(Xe,ct.current,Xt,lt,Ge,Kt),Ge&&(unset(it.current,Xt.ref.name),unset(rt.current,Xt.ref.name))},[Ge]),Ht=React$1.useCallback(Xt=>{if(st.current)Et();else{for(const Kt of nt.current)if(Kt.startsWith(Xt)){Et();break}ut(Xt)}},[]),_t=React$1.useCallback((Xt,Kt)=>{Xt&&(zt(Xt,Kt),Ge&&!compact(Xt.options||[]).length&&(unset(Mt.current.errors,Xt.ref.name),set(Mt.current.dirtyFields,Xt.ref.name,!0),Et({isDirty:Lt()}),Ut.current.isValid&&gt.current&&Zt(),Ht(Xt.ref.name)))},[Zt,zt]);function sn(Xt){Xt&&(Array.isArray(Xt)?Xt:[Xt]).forEach(Kt=>Xe.current[Kt]&&isKey(Kt)?delete Mt.current.errors[Kt]:unset(Mt.current.errors,Kt)),Et({errors:Xt?Mt.current.errors:{}})}function cn(Xt,Kt){const tn=(Xe.current[Xt]||{}).ref;set(Mt.current.errors,Xt,Object.assign(Object.assign({},Kt),{ref:tn})),Et({isValid:!1}),Kt.shouldFocus&&tn&&tn.focus&&tn.focus()}const fn=React$1.useCallback((Xt,Kt,tn)=>{const ln=tn?tt.current[tn]:nt.current;let an=getFieldsValues(Xe,cloneObject(lt.current),Ge,!1,Xt);if(isString$2(Xt)){const Mn=getFieldArrayParentName(Xt)||Xt;return pt.current.has(Mn)&&(an=Object.assign(Object.assign({},Ke.current),an)),assignWatchFields(an,Xt,ln,isUndefined$1(get(ot.current,Xt))?Kt:get(ot.current,Xt),!0)}const mn=isUndefined$1(Kt)?ot.current:Kt;return Array.isArray(Xt)?Xt.reduce((Mn,Dn)=>Object.assign(Object.assign({},Mn),{[Dn]:assignWatchFields(an,Dn,ln,mn)}),{}):(st.current=isUndefined$1(tn),transformToNestObject(!isEmptyObject(an)&&an||mn))},[]);function hn(Xt,Kt){return fn(Xt,Kt)}function An(Xt){for(const Kt of Array.isArray(Xt)?Xt:[Xt])_t(Xe.current[Kt],!0)}function en(Xt,Kt={}){if(process.env.NODE_ENV!=="production"){if(!Xt.name)return console.warn("📋 Field is missing `name` attribute",Xt,"https://react-hook-form.com/api#useForm");if(pt.current.has(Xt.name.split(/\[\d+\]$/)[0])&&!RegExp(`^${Xt.name.split(/\[\d+\]$/)[0]}[\\d+].\\w+`.replace(/\[/g,"\\[").replace(/\]/g,"\\]")).test(Xt.name))return console.warn('📋 `name` prop should be in object shape: name="test[index].name"',Xt,"https://react-hook-form.com/api#useFieldArray")}const{name:tn,type:ln,value:an}=Xt,mn=Object.assign({ref:Xt},Kt),Mn=Xe.current,Dn=isRadioOrCheckboxFunction(Xt),kn=isNameInFieldArray(pt.current,tn),Ln=Qn=>isWeb&&(!isHTMLElement(Xt)||Qn===Xt);let On=Mn[tn],Vn=!0,$n;if(On&&(Dn?Array.isArray(On.options)&&compact(On.options).find(Qn=>an===Qn.ref.value&&Ln(Qn.ref)):Ln(On.ref))){Mn[tn]=Object.assign(Object.assign({},On),Kt);return}ln?On=Dn?Object.assign({options:[...compact(On&&On.options||[]),{ref:Xt}],ref:{type:ln,name:tn}},Kt):Object.assign({},mn):On=mn,Mn[tn]=On;const xn=isUndefined$1(get(lt.current,tn));(!isEmptyObject(ot.current)||!xn)&&($n=get(xn?ot.current:lt.current,tn),Vn=isUndefined$1($n),!Vn&&!kn&&Ft(tn,$n)),isEmptyObject(Kt)||(set(rt.current,tn,!0),!Rt&&Ut.current.isValid&&validateField(Xe,At,On,lt).then(Qn=>{const zn=Mt.current.isValid;isEmptyObject(Qn)?set(it.current,tn,!0):unset(it.current,tn),zn!==isEmptyObject(Qn)&&Et()})),Ge&&!(kn&&Vn)&&!kn&&unset(Mt.current.dirtyFields,tn),ln&&attachEventListeners(Dn&&On.options?On.options[On.options.length-1]:On,Dn||isSelectInput(Xt),ct.current)}function un(Xt,Kt){if(!isWindowUndefined)if(isString$2(Xt))en({name:Xt},Kt);else if(isObject$4(Xt)&&"name"in Xt)en(Xt,Kt);else return tn=>tn&&en(tn,Xt)}const gn=React$1.useCallback((Xt,Kt)=>async tn=>{tn&&tn.preventDefault&&(tn.preventDefault(),tn.persist());let ln={},an=Vt(getFieldsValues(Xe,cloneObject(lt.current),Ge,!0));Ut.current.isSubmitting&&Et({isSubmitting:!0});try{if(gt.current){const{errors:mn,values:Mn}=await gt.current(an,ft.current,At);Mt.current.errors=ln=mn,an=Mn}else for(const mn of Object.values(Xe.current))if(mn){const{name:Mn}=mn.ref,Dn=await validateField(Xe,At,mn,lt);Dn[Mn]?(set(ln,Mn,Dn[Mn]),unset(it.current,Mn)):get(rt.current,Mn)&&(unset(Mt.current.errors,Mn),set(it.current,Mn,!0))}isEmptyObject(ln)&&Object.keys(Mt.current.errors).every(mn=>mn in Xe.current)?(Et({errors:{},isSubmitting:!0}),await Xt(an,tn)):(Mt.current.errors=Object.assign(Object.assign({},Mt.current.errors),ln),Kt&&await Kt(Mt.current.errors,tn),Je&&focusOnErrorField(Xe.current,Mt.current.errors))}finally{Mt.current.isSubmitting=!1,Et({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:isEmptyObject(Mt.current.errors),submitCount:Mt.current.submitCount+1})}},[Je,At]),Sn=({errors:Xt,isDirty:Kt,isSubmitted:tn,touched:ln,isValid:an,submitCount:mn,dirtyFields:Mn})=>{an||(it.current={},rt.current={}),$e.current={},nt.current=new Set,st.current=!1,Et({submitCount:mn?Mt.current.submitCount:0,isDirty:Kt?Mt.current.isDirty:!1,isSubmitted:tn?Mt.current.isSubmitted:!1,isValid:an?Mt.current.isValid:!1,dirtyFields:Mn?Mt.current.dirtyFields:{},touched:ln?Mt.current.touched:{},errors:Xt?Mt.current.errors:{},isSubmitting:!1,isSubmitSuccessful:!1})},dn=(Xt,Kt={})=>{if(isWeb){for(const tn of Object.values(Xe.current))if(tn){const{ref:ln,options:an}=tn,mn=isRadioOrCheckboxFunction(ln)&&Array.isArray(an)?an[0].ref:ln;if(isHTMLElement(mn))try{mn.closest("form").reset();break}catch{}}}Xe.current={},ot.current=Object.assign({},Xt||ot.current),Xt&&ut(""),Object.values(dt.current).forEach(tn=>isFunction$1(tn)&&tn()),lt.current=Ge?{}:cloneObject(Xt||ot.current),Sn(Kt)};React$1.useEffect(()=>{Ue&&Ut.current.isValid&&Zt(),yt.current=yt.current||!isWeb?yt.current:onDomRemove(Xe,_t)},[_t,ot.current]),React$1.useEffect(()=>()=>{yt.current&&yt.current.disconnect(),at.current=!0,process.env.NODE_ENV==="production"&&Object.values(Xe.current).forEach(Xt=>_t(Xt,!0))},[]),!Ue&&Ut.current.isValid&&(Nt.isValid=deepEqual(it.current,rt.current)&&isEmptyObject(Mt.current.errors));const yn={trigger:Gt,setValue:React$1.useCallback(It,[jt,Gt]),getValues:React$1.useCallback(Ot,[]),register:React$1.useCallback(un,[ot.current]),unregister:React$1.useCallback(An,[]),formState:isProxyEnabled?new Proxy(Nt,{get:(Xt,Kt)=>{if(process.env.NODE_ENV!=="production"&&Kt==="isValid"&&Rt&&console.warn("📋 `formState.isValid` is applicable with `onTouched`, `onChange` or `onBlur` mode. https://react-hook-form.com/api#formState"),Kt in Xt)return Ut.current[Kt]=!0,Xt[Kt]}}):Nt},nn=React$1.useMemo(()=>Object.assign({isFormDirty:Lt,updateWatchedValue:Ht,shouldUnregister:Ge,updateFormState:Et,removeFieldEventListener:zt,watchInternal:fn,mode:Tt.current,reValidateMode:{isReValidateOnBlur:vt,isReValidateOnChange:xt},validateResolver:Ue?Zt:void 0,fieldsRef:Xe,resetFieldArrayFunctionRef:dt,useWatchFieldsRef:tt,useWatchRenderFunctionsRef:et,fieldArrayDefaultValuesRef:$e,validFieldsRef:it,fieldsWithValidationRef:rt,fieldArrayNamesRef:pt,readFormStateRef:Ut,formStateRef:Mt,defaultValuesRef:ot,shallowFieldsStateRef:lt,fieldArrayValuesRef:Ke},yn),[ot.current,Ht,Ge,zt,fn]);return Object.assign({watch:hn,control:nn,handleSubmit:gn,reset:React$1.useCallback(dn,[]),clearErrors:React$1.useCallback(sn,[]),setError:React$1.useCallback(cn,[]),errors:Nt.errors},yn)}/*! *****************************************************************************
2595
+ `);return tt.length===1?tt.join(" "):tt.filter(et=>!!et.trim()).map(et=>Ge(et)).join(" ")},Ke=({title:nt,content:tt,isDefault:et})=>{addConsent({title:`${et?Ge(nt):nt}`,content:et?$e(tt):tt,status:!0,session:ue})};return React$1.useEffect(()=>{if(me||Ue){Xe({title:me||defaultPrivacyConsent.title,text:Ue||defaultPrivacyConsent.text,consentType:defaultPrivacyConsent.consentType,default:!Ue});return}getPrivacyConsentData({session:ue,type:"PRIVACY"}).then(({consents:nt})=>{const tt=nt.find(({consentType:et})=>et==="PRIVACY");tt!=null&&tt.text?Xe({...tt,title:(tt==null?void 0:tt.title.trim())||defaultPrivacyConsent.title,text:tt.text.trim()||defaultPrivacyConsent.text,default:!(tt!=null&&tt.text)}):Xe(defaultPrivacyConsent)}).catch(()=>{Xe(defaultPrivacyConsent)})},[ue,me,Ue]),He?jsx(NormalPrivacyConsent,{consent:He,goNext:Qe,addPrivacyConsent:Ke,session:ue,isAeroMexicoClient:Ze,customCheck:Je}):null}function renderUserConsent(ue,{session:me,onSuccess:Ue,title:Qe,text:Ze,isAeroMexicoClient:Je=!1,customCheck:Ge=null}){const He=createRoot$1(ue),Xe=handleUnmountRoot(Ue,He,ue);customRender(jsx(App$1,{token:me.token,children:jsx(PrivacyConsent,{goNext:Xe,session:me,title:Qe,text:Ze,isAeroMexicoClient:Je,customCheck:Ge})}),ue,He)}const version="1.72.0";function r(ue){for(var me="",Ue=0;Ue<ue.length;++Ue)if(Ue>0){var Qe=ue[Ue].toLowerCase();Qe!==ue[Ue]?me+=" ".concat(Qe):me+=ue[Ue]}else me+=ue[Ue].toUpperCase();return me}function o(ue,me){return function(Ue,Qe){return Object.prototype.hasOwnProperty.call(Ue,Qe)}(ue,me)?ue[me]:void 0}var i$1={default:"endpoint"},u={default:"tlsEndpoint"},a="Client timeout",R="Network connection error",c="Network request aborted",s="Response cannot be parsed",E="Blocked by CSP",f="The endpoint parameter is not a valid URL",d=r("WrongRegion"),l=r("SubscriptionNotActive"),_=r("UnsupportedVersion"),p=r("InstallationMethodRestricted"),v=r("HostnameRestricted"),O=r("IntegrationFailed"),I="API key required",h="API key not found",N="API key expired",T="Request cannot be parsed",m="Request failed",w="Request failed to process",A="Too many requests, rate limit exceeded",P="Not available for this origin",y="Not available with restricted header",D=I,S=h,L=N,U="3.8.6",b="9319";function g(ue,me){var Ue=[];return function(Qe,Ze){var Je=5,Ge=(tt=Qe,et=__spreadArray$1([],tt,!0),{current:function(){return et[0]},postpone:function(){var it=et.shift();it!==void 0&&et.push(it)},exclude:function(){et.shift()}}),He=($e=100,Ke=3e3,nt=0,function(){return Math.random()*Math.min(Ke,$e*Math.pow(2,nt++))}),Xe=Ge.current(),$e,Ke,nt,tt,et;if(Xe===void 0)return Promise.reject(new TypeError("The list of script URL patterns is empty"));var rt=function(it,ot){return Ze(it).catch(function(at){if(ot+1>=Je)throw at;(function(lt){if(!(lt instanceof Error))return!1;var dt=lt.message;return dt===E||dt===b})(at)?Ge.exclude():Ge.postpone();var st,ct=Ge.current();if(ct===void 0)throw at;return(st=He(),new Promise(function(lt){return setTimeout(lt,st)})).then(function(){return rt(ct,ot+1)})})};return rt(Xe,0)}(ue,function(Qe){var Ze=new Date,Je=function(He){return Ue.push({url:Qe,startedAt:Ze,finishedAt:new Date,error:He})},Ge=me(Qe);return Ge.then(function(){return Je()},Je),Ge}).then(function(Qe){return[Qe,Ue]})}var C="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",K=C,M="Failed to load the JS script of the agent";function B(ue){var me;ue.scriptUrlPattern;var Ue=ue.token,Qe=ue.apiKey,Ze=Qe===void 0?Ue:Qe,Je=__rest$1(ue,["scriptUrlPattern","token","apiKey"]),Ge=(me=o(ue,"scriptUrlPattern"))!==null&&me!==void 0?me:C,He=function(){var Ke=[],nt=function(){Ke.push({time:new Date,state:document.visibilityState})},tt=function(et,rt,it,ot){return et.addEventListener(rt,it,ot),function(){return et.removeEventListener(rt,it,ot)}}(document,"visibilitychange",nt);return nt(),[Ke,tt]}(),Xe=He[0],$e=He[1];return Promise.resolve().then(function(){if(!Ze||typeof Ze!="string")throw new Error(I);var Ke=function(nt,tt){return(Array.isArray(nt)?nt:[nt]).map(function(et){return function(rt,it){var ot=encodeURIComponent;return rt.replace(/<[^<>]+>/g,function(at){return at==="<version>"?"3":at==="<apiKey>"?ot(it):at==="<loaderVersion>"?ot(U):at})}(String(et),tt)})}(Ge,Ze);return g(Ke,F)}).catch(function(Ke){throw $e(),function(nt){return nt instanceof Error&&nt.message===b?new Error(M):nt}(Ke)}).then(function(Ke){var nt=Ke[0],tt=Ke[1];return $e(),nt.load(__assign$2(__assign$2({},Je),{ldi:{attempts:tt,visibilityStates:Xe}}))})}function F(ue){return function(me,Ue,Qe,Ze){var Je,Ge=document,He="securitypolicyviolation",Xe=function(Ke){var nt=new URL(me,location.href),tt=Ke.blockedURI;tt!==nt.href&&tt!==nt.protocol.slice(0,-1)&&tt!==nt.origin||(Je=Ke,$e())};Ge.addEventListener(He,Xe);var $e=function(){return Ge.removeEventListener(He,Xe)};return Ze==null||Ze.then($e,$e),Promise.resolve().then(Ue).then(function(Ke){return $e(),Ke},function(Ke){return new Promise(function(nt){return setTimeout(nt)}).then(function(){if($e(),Je)return Qe(Je);throw Ke})})}(ue,function(){return function(me){return new Promise(function(Ue,Qe){var Ze=document.createElement("script"),Je=function(){var He;return(He=Ze.parentNode)===null||He===void 0?void 0:He.removeChild(Ze)},Ge=document.head||document.getElementsByTagName("head")[0];Ze.onload=function(){Je(),Ue()},Ze.onerror=function(){Je(),Qe(new Error(M))},Ze.async=!0,Ze.src=me,Ge.appendChild(Ze)})}(ue)},function(){throw new Error(E)}).then(V)}function V(){var ue=window,me="__fpjs_p_l_b",Ue=ue[me];if(function(Qe,Ze){var Je,Ge=(Je=Object.getOwnPropertyDescriptor)===null||Je===void 0?void 0:Je.call(Object,Qe,Ze);Ge!=null&&Ge.configurable?delete Qe[Ze]:Ge&&!Ge.writable||(Qe[Ze]=void 0)}(ue,me),typeof(Ue==null?void 0:Ue.load)!="function")throw new Error(b);return Ue}var k={load:B,defaultScriptUrlPattern:K,ERROR_SCRIPT_LOAD_FAIL:M,ERROR_API_KEY_EXPIRED:N,ERROR_API_KEY_INVALID:h,ERROR_API_KEY_MISSING:I,ERROR_BAD_REQUEST_FORMAT:T,ERROR_BAD_RESPONSE_FORMAT:s,ERROR_CLIENT_TIMEOUT:a,ERROR_CSP_BLOCK:E,ERROR_FORBIDDEN_ENDPOINT:v,ERROR_FORBIDDEN_HEADER:y,ERROR_FORBIDDEN_ORIGIN:P,ERROR_GENERAL_SERVER_FAILURE:m,ERROR_INSTALLATION_METHOD_RESTRICTED:p,ERROR_INTEGRATION_FAILURE:O,ERROR_INVALID_ENDPOINT:f,ERROR_NETWORK_ABORT:c,ERROR_NETWORK_CONNECTION:R,ERROR_RATE_LIMIT:A,ERROR_SERVER_TIMEOUT:w,ERROR_SUBSCRIPTION_NOT_ACTIVE:l,ERROR_TOKEN_EXPIRED:L,ERROR_TOKEN_INVALID:S,ERROR_TOKEN_MISSING:D,ERROR_UNSUPPORTED_VERSION:_,ERROR_WRONG_REGION:d,defaultEndpoint:i$1,defaultTlsEndpoint:u};let fingerprintApiKey;function setFingerprintApiKey(ue){fingerprintApiKey=ue}async function getFingerPrint(){return k.load({token:fingerprintApiKey,endpoint:"https://fingerprint.incodesmile.com",scriptUrlPattern:"https://fingerprint.incodesmile.com/web/v<version>/<apiKey>/loader_v<loaderVersion>.js"}).then(ue=>ue.get({extendedResult:!0}))}const fingerPrintUrl="/omni/add/device-fingerprint";function postFingerprint({hash:ue,ip:me,deviceType:Ue,token:Qe,data:Ze,osVersion:Je,deviceModel:Ge,browser:He,sdkVersion:Xe,hasLiedBrowser:$e,hostingApp:Ke,ipLocation:nt}){return exports.api.post(fingerPrintUrl,{hash:ue,ip:me,deviceType:Ue,data:Ze,osVersion:Je,deviceModel:Ge,browser:He,hasLiedBrowser:$e,sdkVersion:Xe,hostingApp:Ke,ipLocation:nt},{headers:{"X-Incode-Hardware-Id":Qe}}).then(tt=>tt.data).catch(tt=>Promise.reject(tt.response.data))}function formatDeviceModel({vendor:ue,model:me}){return`${ue||""} ${me||""}`.trim()}const emptyFingerprint={visitorId:void 0,ip:void 0,ipLocation:{country:{name:void 0},subdivisions:[],city:{name:void 0},latitude:void 0,longitude:void 0}};async function sendFingerprint({token:ue},me=!0,Ue=!0){var Xe,$e,Ke;const Qe="WEBAPP",{os:Ze,device:Je,browser:Ge}=getUAParserResults(),He=Ue?await getFingerPrint().catch(nt=>(addEvent({code:"fingerprintFetchFailed",payload:{message:nt.message},token:ue}),emptyFingerprint)):emptyFingerprint;return postFingerprint({hash:He.visitorId||"",ip:me&&He.ip||"",deviceType:Qe,token:ue,data:JSON.stringify(He),osVersion:`${Ze.name} ${Ze.version}`,deviceModel:formatDeviceModel(Je),browser:`${Ge.name} ${Ge.version}`,hasLiedBrowser:isBrowserSimulation(),hostingApp:options.hostingApp,sdkVersion:version,ipLocation:{ipCountry:(Xe=He.ipLocation.country)==null?void 0:Xe.name,ipRegion:($e=He.ipLocation.subdivisions)==null?void 0:$e[0].name,ipCity:(Ke=He.ipLocation.city)==null?void 0:Ke.name,ipLatitude:He.ipLocation.latitude,ipLongitude:He.ipLocation.longitude}}).then(nt=>(emptyDeviceStatsQueue(ue),nt))}function mapI18nLang(ue){const me={en:"en-US",es:"es-ES",pt:"pt-BR"},Ue=ue==null?void 0:ue.substring(0,2);return me[Ue]||"en-US"}const createSessionUrl="/omni/start";async function createNewSession({externalId:ue,externalCustomerId:me,configurationId:Ue,uuid:Qe,interviewId:Ze,customFields:Je,language:Ge}={}){const He=Ge||mapI18nLang(i18nInstance.language);try{const Xe=await exports.api.post(createSessionUrl,{externalId:ue,externalCustomerId:me,configurationId:Ue,uuid:Qe,interviewId:Ze,customFields:Je,language:He});state.token=Xe.data;const $e=Xe.data;emptyQueue($e.token);const Ke=await sendFingerprint({token:$e.token,interviewId:$e.interviewId}).catch(()=>({regulationType:"",showMandatoryConsent:!1}));$e.regulationType=Ke.regulationType??"",$e.showMandatoryConsent=Ke.showMandatoryConsent??!1;const tt=new UAParser().getResult();return addEvent({code:"browser",payload:{userAgent:window.navigator.userAgent,isWebRtcSupported:isWebRtcSupported(),...tt},token:$e.token}),$e}catch(Xe){throw Xe!=null&&Xe.response?Xe.response.data:Xe}}const createRedirectUrl=async({session:ue})=>{const{url:me}=await exports.api.get("/omni/onboarding-url",{params:{clientId:ue.clientId},headers:{"X-Incode-Hardware-Id":ue.token}}).then(Ue=>Ue.data);return me};async function createSession$3(ue,me,{externalCustomerId:Ue,configurationId:Qe,uuid:Ze,interviewId:Je,customFields:Ge,language:He}={}){return createNewSession({externalId:me,externalCustomerId:Ue,configurationId:Qe,uuid:Ze,interviewId:Je,customFields:Ge,language:He})}var isHTMLElement=ue=>ue instanceof HTMLElement;const EVENTS={BLUR:"blur",CHANGE:"change",INPUT:"input"},VALIDATION_MODE={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},SELECT="select",UNDEFINED="undefined",INPUT_VALIDATION_RULES={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"};function attachEventListeners({ref:ue},me,Ue){isHTMLElement(ue)&&Ue&&(ue.addEventListener(me?EVENTS.CHANGE:EVENTS.INPUT,Ue),ue.addEventListener(EVENTS.BLUR,Ue))}var isNullOrUndefined=ue=>ue==null;const isObjectType=ue=>typeof ue=="object";var isObject$4=ue=>!isNullOrUndefined(ue)&&!Array.isArray(ue)&&isObjectType(ue)&&!(ue instanceof Date),isKey=ue=>/^\w*$/.test(ue),compact=ue=>ue.filter(Boolean),stringToPath=ue=>compact(ue.replace(/["|']/g,"").replace(/\[/g,".").replace(/\]/g,"").split("."));function set(ue,me,Ue){let Qe=-1;const Ze=isKey(me)?[me]:stringToPath(me),Je=Ze.length,Ge=Je-1;for(;++Qe<Je;){const He=Ze[Qe];let Xe=Ue;if(Qe!==Ge){const $e=ue[He];Xe=isObject$4($e)||Array.isArray($e)?$e:isNaN(+Ze[Qe+1])?{}:[]}ue[He]=Xe,ue=ue[He]}return ue}var transformToNestObject=(ue,me={})=>{for(const Ue in ue)isKey(Ue)?me[Ue]=ue[Ue]:set(me,Ue,ue[Ue]);return me},isUndefined$1=ue=>ue===void 0,get=(ue={},me,Ue)=>{const Qe=compact(me.split(/[,[\].]+?/)).reduce((Ze,Je)=>isNullOrUndefined(Ze)?Ze:Ze[Je],ue);return isUndefined$1(Qe)||Qe===ue?isUndefined$1(ue[me])?Ue:ue[me]:Qe},focusOnErrorField=(ue,me)=>{for(const Ue in ue)if(get(me,Ue)){const Qe=ue[Ue];if(Qe){if(Qe.ref.focus&&isUndefined$1(Qe.ref.focus()))break;if(Qe.options){Qe.options[0].ref.focus();break}}}},removeAllEventListeners=(ue,me)=>{isHTMLElement(ue)&&ue.removeEventListener&&(ue.removeEventListener(EVENTS.INPUT,me),ue.removeEventListener(EVENTS.CHANGE,me),ue.removeEventListener(EVENTS.BLUR,me))};const defaultReturn={isValid:!1,value:null};var getRadioValue=ue=>Array.isArray(ue)?ue.reduce((me,Ue)=>Ue&&Ue.ref.checked?{isValid:!0,value:Ue.ref.value}:me,defaultReturn):defaultReturn,getMultipleSelectValue=ue=>[...ue].filter(({selected:me})=>me).map(({value:me})=>me),isRadioInput=ue=>ue.type==="radio",isFileInput=ue=>ue.type==="file",isCheckBoxInput=ue=>ue.type==="checkbox",isMultipleSelect=ue=>ue.type===`${SELECT}-multiple`;const defaultResult={value:!1,isValid:!1},validResult={value:!0,isValid:!0};var getCheckboxValue=ue=>{if(Array.isArray(ue)){if(ue.length>1){const Ze=ue.filter(Je=>Je&&Je.ref.checked).map(({ref:{value:Je}})=>Je);return{value:Ze,isValid:!!Ze.length}}const{checked:me,value:Ue,attributes:Qe}=ue[0].ref;return me?Qe&&!isUndefined$1(Qe.value)?isUndefined$1(Ue)||Ue===""?validResult:{value:Ue,isValid:!0}:validResult:defaultResult}return defaultResult};function getFieldValue(ue,me,Ue,Qe,Ze){const Je=ue.current[me];if(Je){const{ref:{value:Ge,disabled:He},ref:Xe,valueAsNumber:$e,valueAsDate:Ke,setValueAs:nt}=Je;return He&&Qe?void 0:isFileInput(Xe)?Xe.files:isRadioInput(Xe)?getRadioValue(Je.options).value:isMultipleSelect(Xe)?getMultipleSelectValue(Xe.options):isCheckBoxInput(Xe)?getCheckboxValue(Je.options).value:Ze?Ge:$e?Ge===""?NaN:+Ge:Ke?Xe.valueAsDate:nt?nt(Ge):Ge}if(Ue)return get(Ue.current,me)}function isDetached(ue){return ue?!(ue instanceof HTMLElement)||ue.nodeType===Node.DOCUMENT_NODE?!1:isDetached(ue.parentNode):!0}var isEmptyObject=ue=>isObject$4(ue)&&!Object.keys(ue).length,isBoolean=ue=>typeof ue=="boolean";function baseGet(ue,me){const Ue=me.slice(0,-1).length;let Qe=0;for(;Qe<Ue;)ue=isUndefined$1(ue)?Qe++:ue[me[Qe++]];return ue}function unset(ue,me){const Ue=isKey(me)?[me]:stringToPath(me),Qe=Ue.length==1?ue:baseGet(ue,Ue),Ze=Ue[Ue.length-1];let Je;Qe&&delete Qe[Ze];for(let Ge=0;Ge<Ue.slice(0,-1).length;Ge++){let He=-1,Xe;const $e=Ue.slice(0,-(Ge+1)),Ke=$e.length-1;for(Ge>0&&(Je=ue);++He<$e.length;){const nt=$e[He];Xe=Xe?Xe[nt]:ue[nt],Ke===He&&(isObject$4(Xe)&&isEmptyObject(Xe)||Array.isArray(Xe)&&!Xe.filter(tt=>isObject$4(tt)&&!isEmptyObject(tt)||isBoolean(tt)).length)&&(Je?delete Je[nt]:delete ue[nt]),Je=Xe}}return ue}const isSameRef=(ue,me)=>ue&&ue.ref===me;function findRemovedFieldAndRemoveListener(ue,me,Ue,Qe,Ze,Je){const{ref:Ge,ref:{name:He}}=Ue,Xe=ue.current[He];if(!Ze){const $e=getFieldValue(ue,He,Qe);!isUndefined$1($e)&&set(Qe.current,He,$e)}if(!Ge.type||!Xe){delete ue.current[He];return}isRadioInput(Ge)||isCheckBoxInput(Ge)?Array.isArray(Xe.options)&&Xe.options.length?(compact(Xe.options).forEach(($e={},Ke)=>{(isDetached($e.ref)&&isSameRef($e,$e.ref)||Je)&&(removeAllEventListeners($e.ref,me),unset(Xe.options,`[${Ke}]`))}),Xe.options&&!compact(Xe.options).length&&delete ue.current[He]):delete ue.current[He]:(isDetached(Ge)&&isSameRef(Xe,Ge)||Je)&&(removeAllEventListeners(Ge,me),delete ue.current[He])}var isPrimitive=ue=>isNullOrUndefined(ue)||!isObjectType(ue);function deepMerge(ue,me){if(isPrimitive(ue)||isPrimitive(me))return me;for(const Ue in me){const Qe=ue[Ue],Ze=me[Ue];try{ue[Ue]=isObject$4(Qe)&&isObject$4(Ze)||Array.isArray(Qe)&&Array.isArray(Ze)?deepMerge(Qe,Ze):Ze}catch{}}return ue}function deepEqual(ue,me,Ue){if(isPrimitive(ue)||isPrimitive(me)||ue instanceof Date||me instanceof Date)return ue===me;if(!React$1.isValidElement(ue)){const Qe=Object.keys(ue),Ze=Object.keys(me);if(Qe.length!==Ze.length)return!1;for(const Je of Qe){const Ge=ue[Je];if(!(Ue&&Je==="ref")){const He=me[Je];if((isObject$4(Ge)||Array.isArray(Ge))&&(isObject$4(He)||Array.isArray(He))?!deepEqual(Ge,He,Ue):Ge!==He)return!1}}}return!0}function setDirtyFields(ue,me,Ue,Qe,Ze){let Je=-1;for(;++Je<ue.length;){for(const Ge in ue[Je])Array.isArray(ue[Je][Ge])?(!Ue[Je]&&(Ue[Je]={}),Ue[Je][Ge]=[],setDirtyFields(ue[Je][Ge],get(me[Je]||{},Ge,[]),Ue[Je][Ge],Ue[Je],Ge)):deepEqual(get(me[Je]||{},Ge),ue[Je][Ge])?set(Ue[Je]||{},Ge):Ue[Je]=Object.assign(Object.assign({},Ue[Je]),{[Ge]:!0});Qe&&!Ue.length&&delete Qe[Ze]}return Ue}var setFieldArrayDirtyFields=(ue,me,Ue)=>deepMerge(setDirtyFields(ue,me,Ue.slice(0,ue.length)),setDirtyFields(me,ue,Ue.slice(0,ue.length))),isString$2=ue=>typeof ue=="string",getFieldsValues=(ue,me,Ue,Qe,Ze)=>{const Je={};for(const Ge in ue.current)(isUndefined$1(Ze)||(isString$2(Ze)?Ge.startsWith(Ze):Array.isArray(Ze)&&Ze.find(He=>Ge.startsWith(He))))&&(Je[Ge]=getFieldValue(ue,Ge,void 0,Qe));return Ue?transformToNestObject(Je):deepMerge(me,transformToNestObject(Je))},isErrorStateChanged=({errors:ue,name:me,error:Ue,validFields:Qe,fieldsWithValidation:Ze})=>{const Je=isUndefined$1(Ue),Ge=get(ue,me);return Je&&!!Ge||!Je&&!deepEqual(Ge,Ue,!0)||Je&&get(Ze,me)&&!get(Qe,me)},isRegex=ue=>ue instanceof RegExp,getValueAndMessage=ue=>isObject$4(ue)&&!isRegex(ue)?ue:{value:ue,message:""},isFunction$1=ue=>typeof ue=="function",isMessage=ue=>isString$2(ue)||React$1.isValidElement(ue);function getValidateError(ue,me,Ue="validate"){if(isMessage(ue)||isBoolean(ue)&&!ue)return{type:Ue,message:isMessage(ue)?ue:"",ref:me}}var appendErrors=(ue,me,Ue,Qe,Ze)=>me?Object.assign(Object.assign({},Ue[ue]),{types:Object.assign(Object.assign({},Ue[ue]&&Ue[ue].types?Ue[ue].types:{}),{[Qe]:Ze||!0})}):{},validateField=async(ue,me,{ref:Ue,ref:{value:Qe},options:Ze,required:Je,maxLength:Ge,minLength:He,min:Xe,max:$e,pattern:Ke,validate:nt},tt)=>{const et=Ue.name,rt={},it=isRadioInput(Ue),ot=isCheckBoxInput(Ue),at=it||ot,st=Qe==="",ct=appendErrors.bind(null,et,me,rt),lt=(dt,ft,gt,pt=INPUT_VALIDATION_RULES.maxLength,Tt=INPUT_VALIDATION_RULES.minLength)=>{const Rt=dt?ft:gt;rt[et]=Object.assign({type:dt?pt:Tt,message:Rt,ref:Ue},ct(dt?pt:Tt,Rt))};if(Je&&(!it&&!ot&&(st||isNullOrUndefined(Qe))||isBoolean(Qe)&&!Qe||ot&&!getCheckboxValue(Ze).isValid||it&&!getRadioValue(Ze).isValid)){const{value:dt,message:ft}=isMessage(Je)?{value:!!Je,message:Je}:getValueAndMessage(Je);if(dt&&(rt[et]=Object.assign({type:INPUT_VALIDATION_RULES.required,message:ft,ref:at?((ue.current[et].options||[])[0]||{}).ref:Ue},ct(INPUT_VALIDATION_RULES.required,ft)),!me))return rt}if((!isNullOrUndefined(Xe)||!isNullOrUndefined($e))&&Qe!==""){let dt,ft;const gt=getValueAndMessage($e),pt=getValueAndMessage(Xe);if(isNaN(Qe)){const Tt=Ue.valueAsDate||new Date(Qe);isString$2(gt.value)&&(dt=Tt>new Date(gt.value)),isString$2(pt.value)&&(ft=Tt<new Date(pt.value))}else{const Tt=Ue.valueAsNumber||parseFloat(Qe);isNullOrUndefined(gt.value)||(dt=Tt>gt.value),isNullOrUndefined(pt.value)||(ft=Tt<pt.value)}if((dt||ft)&&(lt(!!dt,gt.message,pt.message,INPUT_VALIDATION_RULES.max,INPUT_VALIDATION_RULES.min),!me))return rt}if(isString$2(Qe)&&!st&&(Ge||He)){const dt=getValueAndMessage(Ge),ft=getValueAndMessage(He),gt=!isNullOrUndefined(dt.value)&&Qe.length>dt.value,pt=!isNullOrUndefined(ft.value)&&Qe.length<ft.value;if((gt||pt)&&(lt(gt,dt.message,ft.message),!me))return rt}if(isString$2(Qe)&&Ke&&!st){const{value:dt,message:ft}=getValueAndMessage(Ke);if(isRegex(dt)&&!dt.test(Qe)&&(rt[et]=Object.assign({type:INPUT_VALIDATION_RULES.pattern,message:ft,ref:Ue},ct(INPUT_VALIDATION_RULES.pattern,ft)),!me))return rt}if(nt){const dt=getFieldValue(ue,et,tt,!1,!0),ft=at&&Ze?Ze[0].ref:Ue;if(isFunction$1(nt)){const gt=await nt(dt),pt=getValidateError(gt,ft);if(pt&&(rt[et]=Object.assign(Object.assign({},pt),ct(INPUT_VALIDATION_RULES.validate,pt.message)),!me))return rt}else if(isObject$4(nt)){let gt={};for(const[pt,Tt]of Object.entries(nt)){if(!isEmptyObject(gt)&&!me)break;const Rt=await Tt(dt),bt=getValidateError(Rt,ft,pt);bt&&(gt=Object.assign(Object.assign({},bt),ct(pt,bt.message)),me&&(rt[et]=gt))}if(!isEmptyObject(gt)&&(rt[et]=Object.assign({ref:ft},gt),!me))return rt}}return rt};const getPath=(ue,me,Ue=[])=>{for(const Qe in me){const Ze=ue+(isObject$4(me)?`.${Qe}`:`[${Qe}]`);isPrimitive(me[Qe])?Ue.push(Ze):getPath(Ze,me[Qe],Ue)}return Ue};var assignWatchFields=(ue,me,Ue,Qe,Ze)=>{let Je;return Ue.add(me),isEmptyObject(ue)||(Je=get(ue,me),(isObject$4(Je)||Array.isArray(Je))&&getPath(me,Je).forEach(Ge=>Ue.add(Ge))),isUndefined$1(Je)?Ze?Qe:get(Qe,me):Je},skipValidation=({isOnBlur:ue,isOnChange:me,isOnTouch:Ue,isTouched:Qe,isReValidateOnBlur:Ze,isReValidateOnChange:Je,isBlurEvent:Ge,isSubmitted:He,isOnAll:Xe})=>Xe?!1:!He&&Ue?!(Qe||Ge):(He?Ze:ue)?!Ge:(He?Je:me)?Ge:!0,getFieldArrayParentName=ue=>ue.substring(0,ue.indexOf("["));const isMatchFieldArrayName=(ue,me)=>RegExp(`^${me}([|.)\\d+`.replace(/\[/g,"\\[").replace(/\]/g,"\\]")).test(ue);var isNameInFieldArray=(ue,me)=>[...ue].some(Ue=>isMatchFieldArrayName(me,Ue)),isSelectInput=ue=>ue.type===`${SELECT}-one`;function onDomRemove(ue,me){const Ue=new MutationObserver(()=>{for(const Qe of Object.values(ue.current))if(Qe&&Qe.options)for(const Ze of Qe.options)Ze&&Ze.ref&&isDetached(Ze.ref)&&me(Qe);else Qe&&isDetached(Qe.ref)&&me(Qe)});return Ue.observe(window.document,{childList:!0,subtree:!0}),Ue}var isWeb=typeof window!==UNDEFINED&&typeof document!==UNDEFINED;function cloneObject(ue){var me;let Ue;if(isPrimitive(ue)||isWeb&&(ue instanceof File||isHTMLElement(ue))||!["Set","Map","Object","Date","Array"].includes((me=ue.constructor)===null||me===void 0?void 0:me.name))return ue;if(ue instanceof Date)return Ue=new Date(ue.getTime()),Ue;if(ue instanceof Set){Ue=new Set;for(const Qe of ue)Ue.add(Qe);return Ue}if(ue instanceof Map){Ue=new Map;for(const Qe of ue.keys())Ue.set(Qe,cloneObject(ue.get(Qe)));return Ue}Ue=Array.isArray(ue)?[]:{};for(const Qe in ue)Ue[Qe]=cloneObject(ue[Qe]);return Ue}var modeChecker=ue=>({isOnSubmit:!ue||ue===VALIDATION_MODE.onSubmit,isOnBlur:ue===VALIDATION_MODE.onBlur,isOnChange:ue===VALIDATION_MODE.onChange,isOnAll:ue===VALIDATION_MODE.all,isOnTouch:ue===VALIDATION_MODE.onTouched}),isRadioOrCheckboxFunction=ue=>isRadioInput(ue)||isCheckBoxInput(ue);const isWindowUndefined=typeof window===UNDEFINED,isProxyEnabled=isWeb?"Proxy"in window:typeof Proxy!==UNDEFINED;function useForm({mode:ue=VALIDATION_MODE.onSubmit,reValidateMode:me=VALIDATION_MODE.onChange,resolver:Ue,context:Qe,defaultValues:Ze={},shouldFocusError:Je=!0,shouldUnregister:Ge=!0,criteriaMode:He}={}){const Xe=React$1.useRef({}),$e=React$1.useRef({}),Ke=React$1.useRef({}),nt=React$1.useRef(new Set),tt=React$1.useRef({}),et=React$1.useRef({}),rt=React$1.useRef({}),it=React$1.useRef({}),ot=React$1.useRef(Ze),at=React$1.useRef(!1),st=React$1.useRef(!1),ct=React$1.useRef(),lt=React$1.useRef({}),dt=React$1.useRef({}),ft=React$1.useRef(Qe),gt=React$1.useRef(Ue),pt=React$1.useRef(new Set),Tt=React$1.useRef(modeChecker(ue)),{isOnSubmit:Rt,isOnTouch:bt}=Tt.current,At=He===VALIDATION_MODE.all,[Nt,mt]=React$1.useState({isDirty:!1,isValidating:!1,dirtyFields:{},isSubmitted:!1,submitCount:0,touched:{},isSubmitting:!1,isSubmitSuccessful:!1,isValid:!Rt,errors:{}}),Ut=React$1.useRef({isDirty:!isProxyEnabled,dirtyFields:!isProxyEnabled,touched:!isProxyEnabled||bt,isValidating:!isProxyEnabled,isSubmitting:!isProxyEnabled,isValid:!isProxyEnabled}),Mt=React$1.useRef(Nt),yt=React$1.useRef(),{isOnBlur:vt,isOnChange:xt}=React$1.useRef(modeChecker(me)).current;ft.current=Qe,gt.current=Ue,Mt.current=Nt,lt.current=Ge?{}:isEmptyObject(lt.current)?cloneObject(Ze):lt.current;const Et=React$1.useCallback((Xt={})=>{at.current||(Mt.current=Object.assign(Object.assign({},Mt.current),Xt),mt(Mt.current))},[]),Ct=()=>Ut.current.isValidating&&Et({isValidating:!0}),wt=React$1.useCallback((Xt,Kt,tn=!1,ln={},an)=>{let mn=tn||isErrorStateChanged({errors:Mt.current.errors,error:Kt,name:Xt,validFields:it.current,fieldsWithValidation:rt.current});const Mn=get(Mt.current.errors,Xt);Kt?(unset(it.current,Xt),mn=mn||!Mn||!deepEqual(Mn,Kt,!0),set(Mt.current.errors,Xt,Kt)):((get(rt.current,Xt)||gt.current)&&(set(it.current,Xt,!0),mn=mn||Mn),unset(Mt.current.errors,Xt)),(mn&&!isNullOrUndefined(tn)||!isEmptyObject(ln)||Ut.current.isValidating)&&Et(Object.assign(Object.assign(Object.assign({},ln),gt.current?{isValid:!!an}:{}),{isValidating:!1}))},[]),Ft=React$1.useCallback((Xt,Kt)=>{const{ref:tn,options:ln}=Xe.current[Xt],an=isWeb&&isHTMLElement(tn)&&isNullOrUndefined(Kt)?"":Kt;isRadioInput(tn)?(ln||[]).forEach(({ref:mn})=>mn.checked=mn.value===an):isFileInput(tn)&&!isString$2(an)?tn.files=an:isMultipleSelect(tn)?[...tn.options].forEach(mn=>mn.selected=an.includes(mn.value)):isCheckBoxInput(tn)&&ln?ln.length>1?ln.forEach(({ref:mn})=>mn.checked=Array.isArray(an)?!!an.find(Mn=>Mn===mn.value):an===mn.value):ln[0].ref.checked=!!an:tn.value=an},[]),Lt=React$1.useCallback((Xt,Kt)=>{if(Ut.current.isDirty){const tn=Ot();return Xt&&Kt&&set(tn,Xt,Kt),!deepEqual(tn,ot.current)}return!1},[]),Jt=React$1.useCallback((Xt,Kt=!0)=>{if(Ut.current.isDirty||Ut.current.dirtyFields){const tn=!deepEqual(get(ot.current,Xt),getFieldValue(Xe,Xt,lt)),ln=get(Mt.current.dirtyFields,Xt),an=Mt.current.isDirty;tn?set(Mt.current.dirtyFields,Xt,!0):unset(Mt.current.dirtyFields,Xt);const mn={isDirty:Lt(),dirtyFields:Mt.current.dirtyFields},Mn=Ut.current.isDirty&&an!==mn.isDirty||Ut.current.dirtyFields&&ln!==get(Mt.current.dirtyFields,Xt);return Mn&&Kt&&Et(mn),Mn?mn:{}}return{}},[]),Qt=React$1.useCallback(async(Xt,Kt)=>{if(process.env.NODE_ENV!=="production"&&!Xe.current[Xt])return console.warn("📋 Field is missing with `name` attribute: ",Xt),!1;const tn=(await validateField(Xe,At,Xe.current[Xt],lt))[Xt];return wt(Xt,tn,Kt),isUndefined$1(tn)},[wt,At]),$t=React$1.useCallback(async Xt=>{const{errors:Kt}=await gt.current(Ot(),ft.current,At),tn=Mt.current.isValid;if(Array.isArray(Xt)){const ln=Xt.map(an=>{const mn=get(Kt,an);return mn?set(Mt.current.errors,an,mn):unset(Mt.current.errors,an),!mn}).every(Boolean);return Et({isValid:isEmptyObject(Kt),isValidating:!1}),ln}else{const ln=get(Kt,Xt);return wt(Xt,ln,tn!==isEmptyObject(Kt),{},isEmptyObject(Kt)),!ln}},[wt,At]),Gt=React$1.useCallback(async Xt=>{const Kt=Xt||Object.keys(Xe.current);if(Ct(),gt.current)return $t(Kt);if(Array.isArray(Kt)){!Xt&&(Mt.current.errors={});const tn=await Promise.all(Kt.map(async ln=>await Qt(ln,null)));return Et({isValidating:!1}),tn.every(Boolean)}return await Qt(Kt)},[$t,Qt]),Pt=React$1.useCallback((Xt,Kt,{shouldDirty:tn,shouldValidate:ln})=>{const an={};set(an,Xt,Kt);for(const mn of getPath(Xt,Kt))Xe.current[mn]&&(Ft(mn,get(an,mn)),tn&&Jt(mn),ln&&Gt(mn))},[Gt,Ft,Jt]),jt=React$1.useCallback((Xt,Kt,tn)=>{if(!Ge&&!isPrimitive(Kt)&&set(lt.current,Xt,Array.isArray(Kt)?[...Kt]:Object.assign({},Kt)),Xe.current[Xt])Ft(Xt,Kt),tn.shouldDirty&&Jt(Xt),tn.shouldValidate&&Gt(Xt);else if(!isPrimitive(Kt)&&(Pt(Xt,Kt,tn),pt.current.has(Xt))){const ln=getFieldArrayParentName(Xt)||Xt;set($e.current,Xt,Kt),dt.current[ln]({[ln]:get($e.current,ln)}),(Ut.current.isDirty||Ut.current.dirtyFields)&&tn.shouldDirty&&(set(Mt.current.dirtyFields,Xt,setFieldArrayDirtyFields(Kt,get(ot.current,Xt,[]),get(Mt.current.dirtyFields,Xt,[]))),Et({isDirty:!deepEqual(Object.assign(Object.assign({},Ot()),{[Xt]:Kt}),ot.current)}))}!Ge&&set(lt.current,Xt,Kt)},[Jt,Ft,Pt]),Dt=Xt=>st.current||nt.current.has(Xt)||nt.current.has((Xt.match(/\w+/)||[])[0]),ut=Xt=>{let Kt=!0;if(!isEmptyObject(tt.current))for(const tn in tt.current)(!Xt||!tt.current[tn].size||tt.current[tn].has(Xt)||tt.current[tn].has(getFieldArrayParentName(Xt)))&&(et.current[tn](),Kt=!1);return Kt};function It(Xt,Kt,tn){jt(Xt,Kt,tn||{}),Dt(Xt)&&Et(),ut(Xt)}ct.current=ct.current?ct.current:async({type:Xt,target:Kt})=>{let tn=Kt.name;const ln=Xe.current[tn];let an,mn;if(ln){const Mn=Xt===EVENTS.BLUR,Dn=skipValidation(Object.assign({isBlurEvent:Mn,isReValidateOnChange:xt,isReValidateOnBlur:vt,isTouched:!!get(Mt.current.touched,tn),isSubmitted:Mt.current.isSubmitted},Tt.current));let kn=Jt(tn,!1),Ln=!isEmptyObject(kn)||!Mn&&Dt(tn);if(Mn&&!get(Mt.current.touched,tn)&&Ut.current.touched&&(set(Mt.current.touched,tn,!0),kn=Object.assign(Object.assign({},kn),{touched:Mt.current.touched})),!Ge&&isCheckBoxInput(Kt)&&set(lt.current,tn,getFieldValue(Xe,tn)),Dn)return!Mn&&ut(tn),(!isEmptyObject(kn)||Ln&&isEmptyObject(kn))&&Et(kn);if(Ct(),gt.current){const{errors:On}=await gt.current(Ot(),ft.current,At),Vn=Mt.current.isValid;if(an=get(On,tn),isCheckBoxInput(Kt)&&!an&&gt.current){const $n=getFieldArrayParentName(tn),xn=get(On,$n,{});xn.type&&xn.message&&(an=xn),$n&&(xn||get(Mt.current.errors,$n))&&(tn=$n)}mn=isEmptyObject(On),Vn!==mn&&(Ln=!0)}else an=(await validateField(Xe,At,ln,lt))[tn];!Mn&&ut(tn),wt(tn,an,Ln,kn,mn)}};function Vt(Xt){if(!Ge){let Kt=cloneObject(Xt);for(const tn of pt.current)isKey(tn)&&!Kt[tn]&&(Kt=Object.assign(Object.assign({},Kt),{[tn]:[]}));return Kt}return Xt}function Ot(Xt){if(isString$2(Xt))return getFieldValue(Xe,Xt,lt);if(Array.isArray(Xt)){const Kt={};for(const tn of Xt)set(Kt,tn,getFieldValue(Xe,tn,lt));return Kt}return Vt(getFieldsValues(Xe,cloneObject(lt.current),Ge))}const Zt=React$1.useCallback(async(Xt={})=>{const Kt=isEmptyObject(Xe.current)?ot.current:{},{errors:tn}=await gt.current(Object.assign(Object.assign(Object.assign({},Kt),Ot()),Xt),ft.current,At)||{},ln=isEmptyObject(tn);Mt.current.isValid!==ln&&Et({isValid:ln})},[At]),zt=React$1.useCallback((Xt,Kt)=>{findRemovedFieldAndRemoveListener(Xe,ct.current,Xt,lt,Ge,Kt),Ge&&(unset(it.current,Xt.ref.name),unset(rt.current,Xt.ref.name))},[Ge]),Ht=React$1.useCallback(Xt=>{if(st.current)Et();else{for(const Kt of nt.current)if(Kt.startsWith(Xt)){Et();break}ut(Xt)}},[]),_t=React$1.useCallback((Xt,Kt)=>{Xt&&(zt(Xt,Kt),Ge&&!compact(Xt.options||[]).length&&(unset(Mt.current.errors,Xt.ref.name),set(Mt.current.dirtyFields,Xt.ref.name,!0),Et({isDirty:Lt()}),Ut.current.isValid&&gt.current&&Zt(),Ht(Xt.ref.name)))},[Zt,zt]);function sn(Xt){Xt&&(Array.isArray(Xt)?Xt:[Xt]).forEach(Kt=>Xe.current[Kt]&&isKey(Kt)?delete Mt.current.errors[Kt]:unset(Mt.current.errors,Kt)),Et({errors:Xt?Mt.current.errors:{}})}function cn(Xt,Kt){const tn=(Xe.current[Xt]||{}).ref;set(Mt.current.errors,Xt,Object.assign(Object.assign({},Kt),{ref:tn})),Et({isValid:!1}),Kt.shouldFocus&&tn&&tn.focus&&tn.focus()}const fn=React$1.useCallback((Xt,Kt,tn)=>{const ln=tn?tt.current[tn]:nt.current;let an=getFieldsValues(Xe,cloneObject(lt.current),Ge,!1,Xt);if(isString$2(Xt)){const Mn=getFieldArrayParentName(Xt)||Xt;return pt.current.has(Mn)&&(an=Object.assign(Object.assign({},Ke.current),an)),assignWatchFields(an,Xt,ln,isUndefined$1(get(ot.current,Xt))?Kt:get(ot.current,Xt),!0)}const mn=isUndefined$1(Kt)?ot.current:Kt;return Array.isArray(Xt)?Xt.reduce((Mn,Dn)=>Object.assign(Object.assign({},Mn),{[Dn]:assignWatchFields(an,Dn,ln,mn)}),{}):(st.current=isUndefined$1(tn),transformToNestObject(!isEmptyObject(an)&&an||mn))},[]);function hn(Xt,Kt){return fn(Xt,Kt)}function An(Xt){for(const Kt of Array.isArray(Xt)?Xt:[Xt])_t(Xe.current[Kt],!0)}function en(Xt,Kt={}){if(process.env.NODE_ENV!=="production"){if(!Xt.name)return console.warn("📋 Field is missing `name` attribute",Xt,"https://react-hook-form.com/api#useForm");if(pt.current.has(Xt.name.split(/\[\d+\]$/)[0])&&!RegExp(`^${Xt.name.split(/\[\d+\]$/)[0]}[\\d+].\\w+`.replace(/\[/g,"\\[").replace(/\]/g,"\\]")).test(Xt.name))return console.warn('📋 `name` prop should be in object shape: name="test[index].name"',Xt,"https://react-hook-form.com/api#useFieldArray")}const{name:tn,type:ln,value:an}=Xt,mn=Object.assign({ref:Xt},Kt),Mn=Xe.current,Dn=isRadioOrCheckboxFunction(Xt),kn=isNameInFieldArray(pt.current,tn),Ln=Qn=>isWeb&&(!isHTMLElement(Xt)||Qn===Xt);let On=Mn[tn],Vn=!0,$n;if(On&&(Dn?Array.isArray(On.options)&&compact(On.options).find(Qn=>an===Qn.ref.value&&Ln(Qn.ref)):Ln(On.ref))){Mn[tn]=Object.assign(Object.assign({},On),Kt);return}ln?On=Dn?Object.assign({options:[...compact(On&&On.options||[]),{ref:Xt}],ref:{type:ln,name:tn}},Kt):Object.assign({},mn):On=mn,Mn[tn]=On;const xn=isUndefined$1(get(lt.current,tn));(!isEmptyObject(ot.current)||!xn)&&($n=get(xn?ot.current:lt.current,tn),Vn=isUndefined$1($n),!Vn&&!kn&&Ft(tn,$n)),isEmptyObject(Kt)||(set(rt.current,tn,!0),!Rt&&Ut.current.isValid&&validateField(Xe,At,On,lt).then(Qn=>{const zn=Mt.current.isValid;isEmptyObject(Qn)?set(it.current,tn,!0):unset(it.current,tn),zn!==isEmptyObject(Qn)&&Et()})),Ge&&!(kn&&Vn)&&!kn&&unset(Mt.current.dirtyFields,tn),ln&&attachEventListeners(Dn&&On.options?On.options[On.options.length-1]:On,Dn||isSelectInput(Xt),ct.current)}function un(Xt,Kt){if(!isWindowUndefined)if(isString$2(Xt))en({name:Xt},Kt);else if(isObject$4(Xt)&&"name"in Xt)en(Xt,Kt);else return tn=>tn&&en(tn,Xt)}const gn=React$1.useCallback((Xt,Kt)=>async tn=>{tn&&tn.preventDefault&&(tn.preventDefault(),tn.persist());let ln={},an=Vt(getFieldsValues(Xe,cloneObject(lt.current),Ge,!0));Ut.current.isSubmitting&&Et({isSubmitting:!0});try{if(gt.current){const{errors:mn,values:Mn}=await gt.current(an,ft.current,At);Mt.current.errors=ln=mn,an=Mn}else for(const mn of Object.values(Xe.current))if(mn){const{name:Mn}=mn.ref,Dn=await validateField(Xe,At,mn,lt);Dn[Mn]?(set(ln,Mn,Dn[Mn]),unset(it.current,Mn)):get(rt.current,Mn)&&(unset(Mt.current.errors,Mn),set(it.current,Mn,!0))}isEmptyObject(ln)&&Object.keys(Mt.current.errors).every(mn=>mn in Xe.current)?(Et({errors:{},isSubmitting:!0}),await Xt(an,tn)):(Mt.current.errors=Object.assign(Object.assign({},Mt.current.errors),ln),Kt&&await Kt(Mt.current.errors,tn),Je&&focusOnErrorField(Xe.current,Mt.current.errors))}finally{Mt.current.isSubmitting=!1,Et({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:isEmptyObject(Mt.current.errors),submitCount:Mt.current.submitCount+1})}},[Je,At]),Sn=({errors:Xt,isDirty:Kt,isSubmitted:tn,touched:ln,isValid:an,submitCount:mn,dirtyFields:Mn})=>{an||(it.current={},rt.current={}),$e.current={},nt.current=new Set,st.current=!1,Et({submitCount:mn?Mt.current.submitCount:0,isDirty:Kt?Mt.current.isDirty:!1,isSubmitted:tn?Mt.current.isSubmitted:!1,isValid:an?Mt.current.isValid:!1,dirtyFields:Mn?Mt.current.dirtyFields:{},touched:ln?Mt.current.touched:{},errors:Xt?Mt.current.errors:{},isSubmitting:!1,isSubmitSuccessful:!1})},dn=(Xt,Kt={})=>{if(isWeb){for(const tn of Object.values(Xe.current))if(tn){const{ref:ln,options:an}=tn,mn=isRadioOrCheckboxFunction(ln)&&Array.isArray(an)?an[0].ref:ln;if(isHTMLElement(mn))try{mn.closest("form").reset();break}catch{}}}Xe.current={},ot.current=Object.assign({},Xt||ot.current),Xt&&ut(""),Object.values(dt.current).forEach(tn=>isFunction$1(tn)&&tn()),lt.current=Ge?{}:cloneObject(Xt||ot.current),Sn(Kt)};React$1.useEffect(()=>{Ue&&Ut.current.isValid&&Zt(),yt.current=yt.current||!isWeb?yt.current:onDomRemove(Xe,_t)},[_t,ot.current]),React$1.useEffect(()=>()=>{yt.current&&yt.current.disconnect(),at.current=!0,process.env.NODE_ENV==="production"&&Object.values(Xe.current).forEach(Xt=>_t(Xt,!0))},[]),!Ue&&Ut.current.isValid&&(Nt.isValid=deepEqual(it.current,rt.current)&&isEmptyObject(Mt.current.errors));const yn={trigger:Gt,setValue:React$1.useCallback(It,[jt,Gt]),getValues:React$1.useCallback(Ot,[]),register:React$1.useCallback(un,[ot.current]),unregister:React$1.useCallback(An,[]),formState:isProxyEnabled?new Proxy(Nt,{get:(Xt,Kt)=>{if(process.env.NODE_ENV!=="production"&&Kt==="isValid"&&Rt&&console.warn("📋 `formState.isValid` is applicable with `onTouched`, `onChange` or `onBlur` mode. https://react-hook-form.com/api#formState"),Kt in Xt)return Ut.current[Kt]=!0,Xt[Kt]}}):Nt},nn=React$1.useMemo(()=>Object.assign({isFormDirty:Lt,updateWatchedValue:Ht,shouldUnregister:Ge,updateFormState:Et,removeFieldEventListener:zt,watchInternal:fn,mode:Tt.current,reValidateMode:{isReValidateOnBlur:vt,isReValidateOnChange:xt},validateResolver:Ue?Zt:void 0,fieldsRef:Xe,resetFieldArrayFunctionRef:dt,useWatchFieldsRef:tt,useWatchRenderFunctionsRef:et,fieldArrayDefaultValuesRef:$e,validFieldsRef:it,fieldsWithValidationRef:rt,fieldArrayNamesRef:pt,readFormStateRef:Ut,formStateRef:Mt,defaultValuesRef:ot,shallowFieldsStateRef:lt,fieldArrayValuesRef:Ke},yn),[ot.current,Ht,Ge,zt,fn]);return Object.assign({watch:hn,control:nn,handleSubmit:gn,reset:React$1.useCallback(dn,[]),clearErrors:React$1.useCallback(sn,[]),setError:React$1.useCallback(cn,[]),errors:Nt.errors},yn)}/*! *****************************************************************************
2596
2596
  Copyright (c) Microsoft Corporation.
2597
2597
 
2598
2598
  Permission to use, copy, modify, and/or distribute this software for any
@@ -4883,7 +4883,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
4883
4883
  width: 100%;
4884
4884
  opacity: 0.3;
4885
4885
  background-color: #fff;
4886
- `,SLEEP_DURATION=2e3,ZOOM_WAIT_DURATION=500,SUCESS_SLEEP_DURATION=300;let manualCaptureTimeout,showFillRectangleNorificationTimeout;function getIdType(ue,me){return ue==="back"?"BackId":me?"Passport":"FrontId"}function CaptureId({getInstructionsNotification:ue=emptyFunc,shouldTakeIdAgain:me=emptyFunc,type:Ue,onError:Qe,onSuccess:Ze,numberOfTries:Je,onLog:Ge,onlyFront:He,permission:Xe,setPermission:$e,permissionMessage:Ke,permissionBackgroundColor:nt,token:tt,sendBase64:et,stream:rt,onlyCapture:it,timeout:ot=18e3,showCustomCameraPermissionScreen:at,isRetry:st,isSecondId:ct,hideRetake:lt,isRecordingEnabled:dt=!1,onRestartOnboarding:ft,showDoublePermissionsRequest:gt,isCreditCard:pt,isCreditCardBack:Tt,onStreamReady:Rt,deviceId:bt,showAutoCaptureIDOverlay:At=!1,showManualCaptureIDOverlay:Nt=!1,defaultHorizontalMask:mt=!1,isFixedMask:Ut=!1,goNextCameraStep:Mt,isKiosk:yt=!1,ageAssurance:vt=!1,publishAudio:xt=!1,zoomLevel:Et=1}){const Ct=tt.token,[wt,Ft]=React$1.useState("white"),[Lt,Jt]=React$1.useState(!1),Qt=React$1.useRef(void 0),[$t,Gt]=React$1.useState(0),[Pt,jt]=React$1.useState(0),[Dt,ut]=React$1.useState(null),[It,Vt]=React$1.useState(!1),[Ot,Zt]=React$1.useState(""),[,zt]=React$1.useState(""),[Ht,_t]=React$1.useState(!1),[sn,cn]=React$1.useState(!1),[fn,hn]=React$1.useState(!1),[,An]=React$1.useState(!1),[en,un]=React$1.useState(0),[gn,Sn]=React$1.useState(!1),[,dn]=React$1.useState(!1),[yn,nn]=React$1.useState(!1),[Xt,Kt]=React$1.useState(""),[tn,ln]=React$1.useState(!1),[an,mn]=React$1.useState(null),[Mn,Dn]=React$1.useState(!1),[kn,Ln]=React$1.useState(!1),On=React$1.useRef(!1),[Vn,$n]=useSessionState(null),xn=cameraScreenNamesMapper[Ue],Qn=eventModuleNames[xn],[zn,Jn]=React$1.useState({isOpen:!1,canvas:null}),Kn=React$1.useRef(void 0),[er,or]=React$1.useState(""),hr=React$1.useRef(null),gr=React$1.useRef(!1),mr=React$1.useRef(!1),Ar=React$1.useRef(null),kr=React$1.useRef(!0),{t:Nn}=useTranslation(),{showNotification:Bn,showPriorityNotification:Yn,closeNotification:qn}=useNotifications(),{startRecording:Mr,stopRecording:Tr}=useMediaRecorder({token:Ct,type:`${Ue}Id`});function yr(dr){Rt==null||Rt(dr),dt&&Mr(dr)}const{notificationMessage:Tn,notificationVariant:wn}=ue(),En=React$1.useRef(null),Hn=!!isWebRtcSupported(),Pn=getIdType(Ue,He);useAutoFocus(En);const ar=async(dr,Fr)=>{qn(),Ft("blue"),clearTimeout(manualCaptureTimeout),clearTimeout(showFillRectangleNorificationTimeout),mr.current=!1,Ge(getLogObject(`capturing${Pn}`,{message:"Hold still. Capturing..."})),Qt.current!==Nn("notifications.takingPhoto")&&(addEvent({token:tt==null?void 0:tt.token,module:"ID capture",code:"cameraFeedbackDisplayed",screen:`${Pn} Camera Capture`,payload:{feedback:"Hold still. Capturing..."}}),Qt.current=Nn("notifications.takingPhoto")),Yn(jsxs("div",{style:{textAlign:"center"},children:[jsx("div",{children:Nn("notifications.dontMove")}),jsx("div",{children:Nn("notifications.takingPhoto")})]}),"dontMove"),await sleep(SLEEP_DURATION),qn(),Ei(dr,Fr),await sleep(SLEEP_DURATION),cr()},cr=async()=>{var fi,zi;if(mobile.isDesktop())return;const dr=(fi=document.querySelector("video"))==null?void 0:fi.srcObject,Fr=dr==null?void 0:dr.getVideoTracks()[0];Kn.current=(zi=Fr==null?void 0:Fr.getSettings())==null?void 0:zi.zoom;const li=await zoomCameraToTheMax(document.querySelector("video").srcObject);if(mobile.iOS()&&!li){await jr(Fr);return}await sleep(ZOOM_WAIT_DURATION);const ai=En.current.getCanvas();if(!ai){await jr(Fr);return}const ea=ai.getImageData(),Kr=ai.getBase64Image();sendZoomedFrame({base64Image:Kr,token:tt==null?void 0:tt.token,source:sources[Ue]}),await MlWasmJSApi$1.allocateImageBuffers(ea.width,ea.height),(await MlWasmJSApi$1.runIdCapture(ea)).quad.size()>0&&addDeviceStats(tt==null?void 0:tt.token,{virtualCameraDetected:!0}),await jr(Fr)},jr=async dr=>{Kn.current&&(await zoomCamera(dr,Kn.current),await sleep(ZOOM_WAIT_DURATION),Kn.current=dr.getSettings().zoom)},Br=()=>{Ge(getLogObject("IDNotDetected",{message:`${Nn("notifications.couldntCapture")}`})),Lt||Yn(Tn,wn)},Wr=dr=>{const Fr=Nn(dr?"notifications.glareDetectedChange":"notifications.glareDetected");Fr===Nn("notifications.glareDetectedChange")&&Qt.current!==Fr&&(Ge(getLogObject("glareDetectedChanged",{message:Nn("notifications.glareDetected")})),addEvent({token:tt==null?void 0:tt.token,code:"cameraFeedbackDisplayed",module:"ID capture",screen:`${Pn} Camera Capture`,payload:{feedback:"Change light conditions"}}),Qt.current=Fr),Ge(getLogObject("glareDetected",{message:Nn("notifications.glareDetected")})),Yn(jsx("div",{style:{textAlign:"center"},children:jsx("div",{children:Fr})}),"Focus")},_r=dr=>{const Fr=Nn(dr?"notifications.outOfFocusChange":"notifications.outOfFocus");Fr===Nn("notifications.outOfFocusChange")&&Qt.current!==Fr&&(addEvent({token:tt==null?void 0:tt.token,code:"cameraFeedbackDisplayed",module:"ID capture",screen:`${Pn} Camera Capture`,payload:{feedback:"Focusing camera"}}),Ge(getLogObject("outOfFocus",{message:Nn(dr?"notifications.outOfFocusChange":"notifications.outOfFocus")})),Qt.current=Fr),Yn(jsx("div",{style:{textAlign:"center"},children:jsx("div",{children:Fr})}),"Focus")},pi=()=>{On.current||(On.current=!0)},Ni=()=>{Yn(jsx("div",{style:{textAlign:"center"},children:jsx("div",{children:Nn("notifications.fitOverlay")})}),""),Ge(getLogObject("fitOverlay",{message:Nn("notifications.fitOverlay")}))},gi=(dr,Fr,li,ai="")=>{Lt||(ai!==er&&or(ai),Dn(dr),ln(Fr),mn(li))},Pr=()=>{qn(),mr.current=!1,kr.current=!1,Jt(!0),Dn(!0),ln(yt??!1),Ge(getLogObject("manualCaptureOn",{})),clearTimeout(showFillRectangleNorificationTimeout),addEvent({token:Ct,code:`switchToManualCapture${Pn}`,payload:{[`manualCapture${Pn}`]:!0}}),Ge(getLogObject("switchToManualCapture",{message:Nn("Switched to manual capture")}))},Mi=async()=>{hr.current=new IdCapture,await hr.current.initialize({onCapturing:ar,onFarAway:Ni,onGlare:Wr,onBlur:_r,onIDNotDetected:Br,onMaskChange:gi,onDetectionStarted:pi,onSwitchToManualCapture:Pr,idType:Pn,isFixedMask:Ut,isBlurCheckEnabled:!1,isGlareCheckEnabled:!1,pipelineProfile:DetectionSetup$1.getProfile(PipelineType.IdCapturePipeline),autocaptureTimeout:ot})};React$1.useEffect(()=>(document.body.style.position="fixed",()=>{document.body.style.position="unset"}),[]),React$1.useEffect(()=>()=>{Tr()},[]),React$1.useEffect(()=>{er&&(console.log(er,"orientation"),addEvent({token:Ct,code:"idOrientationChanged",module:"ID capture",payload:{orientation:er}}),Ge(getLogObject("idOrientationChanged",{message:"ID orientation changed"})))},[er]),React$1.useEffect(()=>{addScreenEvent({module:Qn,screen:eventScreenNames[`${xn}CameraCapture`],token:Ct,shouldOpen:!0}),Ge(getLogObject("lookingForID",{message:Nn(`Looking for ${Pn}`)}))},[]),React$1.useEffect(()=>{if(!(!mobile.isDesktop()&&!yt)&&It){const dr=setTimeout(()=>{Ma(Dt)},1500);return()=>clearInterval(dr)}},[It,sa,Dt]),React$1.useEffect(()=>{Lt&&Qt.current!==Nn("captureInstructions.step2")&&(addEvent({token:tt==null?void 0:tt.token,code:"cameraFeedbackDisplayed",module:"ID capture",screen:`${Pn} Camera Capture`,payload:{feedback:"Press capture button"}}),Ge(getLogObject("cameraFeedbackDisplayed",{message:Nn("Press capture button")})),Qt.current=Nn("captureInstructions.step2"))},[Lt]);const di=React$1.useCallback(async()=>{if(!(!mr.current||gr.current)){gr.current=!0,hr.current||await Mi();try{await MlWasmJSApi$1.handleDetectionCallAndUpdateState(PipelineType.IdCapturePipeline);const dr=En.current.getCanvas();if(!dr)return;await hr.current.detect(dr)}catch(dr){console.error(dr)}finally{gr.current=!1}}},[Mi]);React$1.useEffect(()=>(onFrameEmitter.on("newFrame",di),()=>{onFrameEmitter.off("newFrame",di)}),[di]);const Ri=React$1.useCallback(()=>{mr.current||(mr.current=!0,En.current.video.play())},[]);React$1.useEffect(()=>{gn&&(Sn(!1),Lt||Ri())},[Ri,Lt,gn]),React$1.useEffect(()=>(nn(!0),()=>{var dr;nn(!1),mr.current=!1,!rt&&(dr=En.current)!=null&&dr.mediaStreamTrack&&En.current.mediaStreamTrack.stop()}),[rt]),React$1.useEffect(()=>{addEvent({token:Ct,code:`camera${Pn}`,payload:{[`camera${Pn}`]:!0}})},[Pn,Ct]);const Zi=async dr=>{Bn(jsxs("div",{style:{textAlign:"center"},children:[jsx("div",{children:Nn("notifications.couldntCapture")}),jsx("div",{children:Nn("notifications.verifyLater")})]}),"skip"),await sleep(SLEEP_DURATION),Ge(getLogObject("noAttemps",{response:Ar.current,message:"No attempt left"})),qn(),dr&&dr()},wi=async({key:dr,value:Fr})=>{try{await updateSession({token:Ct,key:dr,value:Fr}),dn(!1)}catch{dn(!1)}},mi=()=>{if(dn(!1),qn(),un(en+1),An(!1),Je!==-1&&en+1>=Je)return wi({key:"manualIdCheckNeeded",value:!0}),Zi(()=>Qe({...Ar.current,type:"skip"}));Sn(!0)},Jr=()=>{var dr;return dn(!1),An(!1),Sn(!1),qn(),Ge(getLogObject("successCapture",{response:Ar.current})),(dr=Ar.current)!=null&&dr.showMandatoryConsent?(Mt(Ar.current),!0):(Ze(Ar.current),!0)},Di=()=>{qn(),_t(!0)},aa=Gt,Ei=async(dr,Fr)=>{if(clearTimeout(manualCaptureTimeout),manualCaptureTimeout=void 0,!dr)return;sa(),addEvent({token:Ct,code:Lt?`manualCapture${Pn}`:`capture${Pn}`,payload:{[`manualCapture${Pn}`]:!0}});const li=dr.getBase64Image(),{blob:ai,url:ea}=dr.getBlobData();if(Zt(ea),Di(),await OnboardingAnalytics$1.analyzeFrame(li),MlWasmJSApi$1.resetAllPipelines(),it)return Ze({imageBase64:li,blob:ai,url:ea});if(vt&&cn(!0),Lt||addScreenEvent({module:Qn,screen:eventScreenNames[`${xn}CameraCapture`],token:Ct,shouldOpen:!1}),addScreenEvent({module:Qn,screen:eventScreenNames[`${xn}UploadProgress`],token:Ct,shouldOpen:!0}),pt||Tt){const{success:Kr}=await pt?await addCreditCardFront({token:Ct,base64Image:li}):await addCreditCardBack({token:Ct,base64Image:li});addScreenEvent({module:Qn,screen:eventScreenNames[`${xn}UploadProgress`],token:Ct,shouldOpen:!1}),Kr?(addScreenEvent({module:Qn,screen:eventScreenNames[`${xn}UploadSuccess`],token:Ct,shouldOpen:!0}),ut(!0),await sleep(SLEEP_DURATION),addScreenEvent({module:Qn,screen:eventScreenNames[`${xn}UploadSuccess`],token:Ct,shouldOpen:!1}),Ge(getLogObject("captureSucessful",{message:Nn(`Capture for ${Pn} was successful`)})),Ft("white")):(addScreenEvent({module:Qn,screen:eventScreenNames[`${xn}AttemptFailed`],token:Ct,shouldOpen:!0}),Ge(getLogObject("attemptFailed",{attempt:en+1})),ut(!1),Kt("error"),await sleep(SLEEP_DURATION),addScreenEvent({module:Qn,screen:eventScreenNames[`${xn}AttemptFailed`],token:Ct,shouldOpen:!1}),addScreenEvent({module:Qn,screen:eventScreenNames[`${xn}CameraCapture`],token:Ct,shouldOpen:!0}),Ft("white")),Vt(!0),Gt(100)}else addEvent({token:tt==null?void 0:tt.token,code:"cameraFeedbackDisplayed",module:"ID capture",screen:`${Pn}image inspection`,payload:{feedback:"Inspecting..."}}),Ge(getLogObject("inspecting",{message:Nn(`Inspecting ${Pn}...`)})),addEvent({token:tt==null?void 0:tt.token,code:"captureAttemptFinished",module:`ID capture ${Pn}`,payload:{logs:OnboardingAnalytics$1.getPipelineLogs()}}),(Pn==="FrontId"||Pn==="Passport")&&addDeviceStats(tt==null?void 0:tt.token,{frontIdStatsAnalysisStatus:OnboardingAnalytics$1.getAnalysisStatus(),backIdStatsAnalysisStatus:"",selfieStatsAnalysisStatus:"",motionStatus:OnboardingAnalytics$1.getMotionStatus()}),Pn==="BackId"&&addDeviceStats(tt==null?void 0:tt.token,{frontIdStatsAnalysisStatus:"",backIdStatsAnalysisStatus:OnboardingAnalytics$1.getAnalysisStatus(),selfieStatsAnalysisStatus:"",motionStatus:OnboardingAnalytics$1.getMotionStatus()}),await sleep(ZOOM_WAIT_DURATION),await capture({token:Ct,image:et?li:ai,type:Ue,onProgress:aa,sendBase64:et,onlyFront:He,isRetry:st,isSecondId:ct,encrypted:!1,faceCoordinates:void 0,imageType:void 0,shouldSkipGlareBack:Vn==null?void 0:Vn.skipGlareBack,shouldSkipGlareFront:Vn==null?void 0:Vn.skipGlareFront,...Fr&&{glare:Fr.glare,sharpness:Fr.sharpness}}).then(async Kr=>{var Ka;const{skipGlareBack:ta,skipGlareFront:fi}=Kr;(ta||fi)&&$n({...Vn,skipGlareBack:ta,skipGlareFront:fi});const Si=await getImages$1({token:Ct,body:{images:["croppedIDFace",...vt?[Pn==="BackId"?"croppedBackID":"croppedFrontID"]:[]]},onDownloadProgress:Fa=>jt(Fa)}).catch(()=>({croppedIDFace:"",croppedFrontID:"",croppedBackID:""}));if(Ar.current={...Kr,originalImage:li,frontIdImage:Si.croppedIDFace,backIdImage:Si.croppedBackID,...Si},vt&&(Si.croppedFrontID||Si.croppedBackID)){const Fa=(Ka=IncodeCanvas==null?void 0:IncodeCanvas.base64ToBlob(Si.croppedFrontID??Si.croppedBackID))==null?void 0:Ka.url,Va=document.createElement("img");Va.src=Fa,Va.onload=()=>{hn(Va.width>Va.height)},Zt(Fa)}cn(!1);const{status:co,message:Ga,errorKey:Ha,logMessage:Xa}=me(Kr);addScreenEvent({module:Qn,screen:eventScreenNames[`${xn}UploadProgress`],token:Ct,shouldOpen:!1}),Ge(getLogObject(`uploading${Pn}`,{message:Nn(`Uploading ${Pn}`)}));const $a=(Kr==null?void 0:Kr.skipGlareFront)&&Pn==="FrontId",Bo=(Kr==null?void 0:Kr.skipGlareBack)&&Pn==="BackId";co&&!$a&&!Bo?(addScreenEvent({module:Qn,screen:eventScreenNames[`${xn}AttemptFailed`],token:Ct,shouldOpen:!0}),Ge(getLogObject("attemptFailed",{response:Ar.current,message:Ga,reason:Ha,attempt:en+1})),addEvent({token:tt==null?void 0:tt.token,code:"captureStatusDisplayed",module:"ID capture",screen:`${Pn} image inspection`,payload:{capture_status:"Scan failed",feedback:Xa??Ga}}),ut(!1),Kt(Ga),await sleep(SLEEP_DURATION),addScreenEvent({module:Qn,screen:eventScreenNames[`${xn}AttemptFailed`],token:Ct,shouldOpen:!1}),addScreenEvent({module:Qn,screen:eventScreenNames[`${xn}CameraCapture`],token:Ct,shouldOpen:!0}),Ft("white")):(addScreenEvent({module:Qn,screen:eventScreenNames[`${xn}UploadSuccess`],token:Ct,shouldOpen:!0}),addEvent({token:tt==null?void 0:tt.token,code:"captureStatusDisplayed",screen:`${Pn} image inspection`,module:"ID capture",payload:{capture_status:"Scan succeeded",feedback:"Success!"}}),Ge(getLogObject(`${Pn}UploadSuccessful`,{message:Nn(`${Pn} capture was successful`)})),zt(Si.croppedFace),ut(!0),await sleep(SUCESS_SLEEP_DURATION),addScreenEvent({module:Qn,screen:eventScreenNames[`${xn}UploadSuccess`],token:Ct,shouldOpen:!1}),Ft("white")),Vt(!0)}).catch(async Kr=>{const{message:ta,errorKey:fi}=me(Kr.response.data);addScreenEvent({module:Qn,screen:eventScreenNames[`${xn}AttemptFailed`],token:Ct,shouldOpen:!0}),Ge(getLogObject("attemptFailed",{response:Kr.response.data,message:ta,reason:fi,attempt:en+1})),hn(!1),Kt(ta),ut(!1),Gt(100),Vt(!0),await sleep(SLEEP_DURATION),addScreenEvent({module:Qn,screen:eventScreenNames[`${xn}AttemptFailed`],token:Ct,shouldOpen:!1}),addScreenEvent({module:Qn,screen:eventScreenNames[`${xn}CameraCapture`],token:Ct,shouldOpen:!0}),Ft("white")}).finally(()=>{})},oa=async()=>{gi(!0,mt,!1),mr.current=!1,Yn(Tn,wn),Lt||(await sleep(SLEEP_DURATION),Ri())},Ma=dr=>{dr?Jr():mi(),Kt(""),_t(!1),cn(!1),hn(!1),Gt(0),Vt(!1),ut(null),Ft("white")},Ya=async()=>{var dr,Fr;if(!Lt){if(Et&&yt){const li=(dr=document.querySelector("video"))==null?void 0:dr.srcObject,ai=li==null?void 0:li.getVideoTracks()[0];ai&&await zoomCamera(ai,Et)}(Fr=En.current)==null||Fr.setIsLoadingCamera(!1),oa()}};function Ca(){kn?(Lt||Ri(),addEvent({token:Ct,code:"tryAgainSelected",screen:"ID capture help",module:"ID capture"}),addScreenEvent({module:Qn,screen:eventScreenNames[`${xn}Help`],token:Ct,shouldOpen:!1}),addScreenEvent({module:Qn,screen:eventScreenNames[`${xn}CameraCapture`],token:Ct,shouldOpen:!0}),Ge(getLogObject("commonIssuesClosed",{}))):(addEvent({token:Ct,code:"needHelpSelected",screen:`${Pn} Camera Capture`,module:"ID capture"}),addScreenEvent({module:Qn,screen:eventScreenNames[`${xn}CameraCapture`],token:Ct,shouldOpen:!1}),addScreenEvent({module:Qn,screen:eventScreenNames[`${xn}Help`],token:Ct,shouldOpen:!0}),Ge(getLogObject("commonIssuesOpened",{})),mr.current=!1),Ln(!kn)}function xa(){if(Je!==-1&&en>=Je)return;const dr=En.current.getCanvas();dr.updateBase64Image(),dr.updateBlob(),lt?Ei(dr):Jn({isOpen:!0,canvas:dr})}function sa(){Jn({isOpen:!1,canvas:null})}if(!yn)return null;const so=(()=>yt?tn?"horizontalKiosk":"verticalKiosk":mobile.any()?tn?"horizontal":He?"passport":"vertical":"desktop")();if(yt)return jsxs(Fragment,{children:[jsx(NotificationsTitle,{className:classNames({surface:isSurface,kiosk:!0}),children:!Ht&&!zn.isOpen&&jsx(Notification,{inline:!0,center:!0,noPortal:!0,isKiosk:yt})}),Hn&&jsxs(CaptureContainer,{className:classNames({kiosk:!0}),children:[jsxs(WebcamContainer,{className:classNames({[Ht?Dt==null?"neutral":Dt?"success":"error":""]:!0,surface:isSurface,kiosk:!0}),children:[Ht?jsxs(Fragment,{children:[sn?jsx(Opacity,{}):null,jsx(TakenPicture,{src:Ot,shouldBlurImage:sn})]}):jsxs(Fragment,{children:[jsx(Webcam,{ref:En,onPlay:Ya,videoSource:"environment",permission:Xe,setPermission:$e,permissionMessage:Ke,permissionBackgroundColor:nt,onLog:Ge,stream:rt,onError:Qe,token:Ct,type:Pn,interviewId:tt.interviewId,showCustomCameraPermissionScreen:at,onStreamReady:dt?Mr:void 0,isRecordingEnabled:dt,onRestartOnboarding:ft,showDoublePermissionsRequest:gt,deviceId:bt,className:"kiosk",isKiosk:!0}),jsx(Mask,{className:"IncodeCaptureIdMask",show:Mn,top:an,frame:wt,animate:!Lt,type:so,showIDOverlay:!Lt&&At||Lt&&Nt||At&&Nt,isKiosk:!0})]}),jsx("span",{className:"step__video-overlay"}),Lt&&zn.isOpen&&jsx(Retake,{imageBase64:zn.canvas.getBase64Image(1,!0),onClose:sa,handleCapture:()=>Ei(zn.canvas),token:Ct,type:Ue})]}),Lt&&!Ht&&jsxs(FakeButtonContainer,{children:[jsxs(FakeButtonMessage,{children:[`${Nn("captureInstructions.step1")}
4886
+ `,SLEEP_DURATION=2e3,ZOOM_WAIT_DURATION=500,SUCESS_SLEEP_DURATION=300;let manualCaptureTimeout,showFillRectangleNorificationTimeout;function getIdType(ue,me){return ue==="back"?"BackId":me?"Passport":"FrontId"}function CaptureId({getInstructionsNotification:ue=emptyFunc,shouldTakeIdAgain:me=emptyFunc,type:Ue,onError:Qe,onSuccess:Ze,numberOfTries:Je,onLog:Ge,onlyFront:He,permission:Xe,setPermission:$e,permissionMessage:Ke,permissionBackgroundColor:nt,token:tt,sendBase64:et,stream:rt,onlyCapture:it,timeout:ot=18e3,showCustomCameraPermissionScreen:at,isRetry:st,isSecondId:ct,hideRetake:lt,isRecordingEnabled:dt=!1,onRestartOnboarding:ft,showDoublePermissionsRequest:gt,isCreditCard:pt,isCreditCardBack:Tt,onStreamReady:Rt,deviceId:bt,showAutoCaptureIDOverlay:At=!1,showManualCaptureIDOverlay:Nt=!1,defaultHorizontalMask:mt=!1,isFixedMask:Ut=!1,goNextCameraStep:Mt,isKiosk:yt=!1,ageAssurance:vt=!1,publishAudio:xt=!1,zoomLevel:Et=1}){const Ct=tt.token,[wt,Ft]=React$1.useState("white"),[Lt,Jt]=React$1.useState(!1),Qt=React$1.useRef(void 0),[$t,Gt]=React$1.useState(0),[Pt,jt]=React$1.useState(0),[Dt,ut]=React$1.useState(null),[It,Vt]=React$1.useState(!1),[Ot,Zt]=React$1.useState(""),[,zt]=React$1.useState(""),[Ht,_t]=React$1.useState(!1),[sn,cn]=React$1.useState(!1),[fn,hn]=React$1.useState(!1),[,An]=React$1.useState(!1),[en,un]=React$1.useState(0),[gn,Sn]=React$1.useState(!1),[,dn]=React$1.useState(!1),[yn,nn]=React$1.useState(!1),[Xt,Kt]=React$1.useState(""),[tn,ln]=React$1.useState(!1),[an,mn]=React$1.useState(null),[Mn,Dn]=React$1.useState(!1),[kn,Ln]=React$1.useState(!1),On=React$1.useRef(!1),[Vn,$n]=useSessionState(null),xn=cameraScreenNamesMapper[Ue],Qn=eventModuleNames[xn],[zn,Jn]=React$1.useState({isOpen:!1,canvas:null}),Kn=React$1.useRef(void 0),[er,or]=React$1.useState(""),hr=React$1.useRef(null),gr=React$1.useRef(!1),mr=React$1.useRef(!1),Ar=React$1.useRef(null),kr=React$1.useRef(!0),{t:Nn}=useTranslation(),{showNotification:Bn,showPriorityNotification:Yn,closeNotification:qn}=useNotifications(),{startRecording:Mr,stopRecording:Tr}=useMediaRecorder({token:Ct,type:`${Ue}Id`});function yr(dr){Rt==null||Rt(dr),dt&&Mr(dr)}const{notificationMessage:Tn,notificationVariant:wn}=ue(),En=React$1.useRef(null),Hn=!!isWebRtcSupported(),Pn=getIdType(Ue,He);useAutoFocus(En);const ar=async(dr,Fr)=>{qn(),Ft("blue"),clearTimeout(manualCaptureTimeout),clearTimeout(showFillRectangleNorificationTimeout),mr.current=!1,Ge(getLogObject(`capturing${Pn}`,{message:"Hold still. Capturing..."})),Qt.current!==Nn("notifications.takingPhoto")&&(addEvent({token:tt==null?void 0:tt.token,module:"ID capture",code:"cameraFeedbackDisplayed",screen:`${Pn} Camera Capture`,payload:{feedback:"Hold still. Capturing..."}}),Qt.current=Nn("notifications.takingPhoto")),Yn(jsxs("div",{style:{textAlign:"center"},children:[jsx("div",{children:Nn("notifications.dontMove")}),jsx("div",{children:Nn("notifications.takingPhoto")})]}),"dontMove"),await sleep(SLEEP_DURATION),qn(),Ei(dr,Fr),await sleep(SLEEP_DURATION),cr()},cr=async()=>{var fi,zi;if(mobile.isDesktop())return;const dr=(fi=document.querySelector("video"))==null?void 0:fi.srcObject,Fr=dr==null?void 0:dr.getVideoTracks()[0];Kn.current=(zi=Fr==null?void 0:Fr.getSettings())==null?void 0:zi.zoom;const li=await zoomCameraToTheMax(document.querySelector("video").srcObject);if(mobile.iOS()&&!li){await jr(Fr);return}await sleep(ZOOM_WAIT_DURATION);const ai=En.current.getCanvas();if(!ai){await jr(Fr);return}const ea=ai.getImageData(),Kr=ai.getBase64Image();logFrame({base64Image:Kr,token:tt==null?void 0:tt.token,source:sources[Ue]}),await MlWasmJSApi$1.allocateImageBuffers(ea.width,ea.height),(await MlWasmJSApi$1.runIdCapture(ea)).quad.size()>0&&addDeviceStats(tt==null?void 0:tt.token,{virtualCameraDetected:!0}),await jr(Fr)},jr=async dr=>{Kn.current&&(await zoomCamera(dr,Kn.current),await sleep(ZOOM_WAIT_DURATION),Kn.current=dr.getSettings().zoom)},Br=()=>{Ge(getLogObject("IDNotDetected",{message:`${Nn("notifications.couldntCapture")}`})),Lt||Yn(Tn,wn)},Wr=dr=>{const Fr=Nn(dr?"notifications.glareDetectedChange":"notifications.glareDetected");Fr===Nn("notifications.glareDetectedChange")&&Qt.current!==Fr&&(Ge(getLogObject("glareDetectedChanged",{message:Nn("notifications.glareDetected")})),addEvent({token:tt==null?void 0:tt.token,code:"cameraFeedbackDisplayed",module:"ID capture",screen:`${Pn} Camera Capture`,payload:{feedback:"Change light conditions"}}),Qt.current=Fr),Ge(getLogObject("glareDetected",{message:Nn("notifications.glareDetected")})),Yn(jsx("div",{style:{textAlign:"center"},children:jsx("div",{children:Fr})}),"Focus")},_r=dr=>{const Fr=Nn(dr?"notifications.outOfFocusChange":"notifications.outOfFocus");Fr===Nn("notifications.outOfFocusChange")&&Qt.current!==Fr&&(addEvent({token:tt==null?void 0:tt.token,code:"cameraFeedbackDisplayed",module:"ID capture",screen:`${Pn} Camera Capture`,payload:{feedback:"Focusing camera"}}),Ge(getLogObject("outOfFocus",{message:Nn(dr?"notifications.outOfFocusChange":"notifications.outOfFocus")})),Qt.current=Fr),Yn(jsx("div",{style:{textAlign:"center"},children:jsx("div",{children:Fr})}),"Focus")},pi=()=>{On.current||(On.current=!0)},Ni=()=>{Yn(jsx("div",{style:{textAlign:"center"},children:jsx("div",{children:Nn("notifications.fitOverlay")})}),""),Ge(getLogObject("fitOverlay",{message:Nn("notifications.fitOverlay")}))},gi=(dr,Fr,li,ai="")=>{Lt||(ai!==er&&or(ai),Dn(dr),ln(Fr),mn(li))},Pr=()=>{qn(),mr.current=!1,kr.current=!1,Jt(!0),Dn(!0),ln(yt??!1),Ge(getLogObject("manualCaptureOn",{})),clearTimeout(showFillRectangleNorificationTimeout),addEvent({token:Ct,code:`switchToManualCapture${Pn}`,payload:{[`manualCapture${Pn}`]:!0}}),Ge(getLogObject("switchToManualCapture",{message:Nn("Switched to manual capture")}))},Mi=async()=>{hr.current=new IdCapture,await hr.current.initialize({onCapturing:ar,onFarAway:Ni,onGlare:Wr,onBlur:_r,onIDNotDetected:Br,onMaskChange:gi,onDetectionStarted:pi,onSwitchToManualCapture:Pr,idType:Pn,isFixedMask:Ut,isBlurCheckEnabled:!1,isGlareCheckEnabled:!1,pipelineProfile:DetectionSetup$1.getProfile(PipelineType.IdCapturePipeline),autocaptureTimeout:ot})};React$1.useEffect(()=>(document.body.style.position="fixed",()=>{document.body.style.position="unset"}),[]),React$1.useEffect(()=>()=>{Tr()},[]),React$1.useEffect(()=>{er&&(console.log(er,"orientation"),addEvent({token:Ct,code:"idOrientationChanged",module:"ID capture",payload:{orientation:er}}),Ge(getLogObject("idOrientationChanged",{message:"ID orientation changed"})))},[er]),React$1.useEffect(()=>{addScreenEvent({module:Qn,screen:eventScreenNames[`${xn}CameraCapture`],token:Ct,shouldOpen:!0}),Ge(getLogObject("lookingForID",{message:Nn(`Looking for ${Pn}`)}))},[]),React$1.useEffect(()=>{if(!(!mobile.isDesktop()&&!yt)&&It){const dr=setTimeout(()=>{Ma(Dt)},1500);return()=>clearInterval(dr)}},[It,sa,Dt]),React$1.useEffect(()=>{Lt&&Qt.current!==Nn("captureInstructions.step2")&&(addEvent({token:tt==null?void 0:tt.token,code:"cameraFeedbackDisplayed",module:"ID capture",screen:`${Pn} Camera Capture`,payload:{feedback:"Press capture button"}}),Ge(getLogObject("cameraFeedbackDisplayed",{message:Nn("Press capture button")})),Qt.current=Nn("captureInstructions.step2"))},[Lt]);const di=React$1.useCallback(async()=>{if(!(!mr.current||gr.current)){gr.current=!0,hr.current||await Mi();try{await MlWasmJSApi$1.handleDetectionCallAndUpdateState(PipelineType.IdCapturePipeline);const dr=En.current.getCanvas();if(!dr)return;await hr.current.detect(dr)}catch(dr){console.error(dr)}finally{gr.current=!1}}},[Mi]);React$1.useEffect(()=>(onFrameEmitter.on("newFrame",di),()=>{onFrameEmitter.off("newFrame",di)}),[di]);const Ri=React$1.useCallback(()=>{mr.current||(mr.current=!0,En.current.video.play())},[]);React$1.useEffect(()=>{gn&&(Sn(!1),Lt||Ri())},[Ri,Lt,gn]),React$1.useEffect(()=>(nn(!0),()=>{var dr;nn(!1),mr.current=!1,!rt&&(dr=En.current)!=null&&dr.mediaStreamTrack&&En.current.mediaStreamTrack.stop()}),[rt]),React$1.useEffect(()=>{addEvent({token:Ct,code:`camera${Pn}`,payload:{[`camera${Pn}`]:!0}})},[Pn,Ct]);const Zi=async dr=>{Bn(jsxs("div",{style:{textAlign:"center"},children:[jsx("div",{children:Nn("notifications.couldntCapture")}),jsx("div",{children:Nn("notifications.verifyLater")})]}),"skip"),await sleep(SLEEP_DURATION),Ge(getLogObject("noAttemps",{response:Ar.current,message:"No attempt left"})),qn(),dr&&dr()},wi=async({key:dr,value:Fr})=>{try{await updateSession({token:Ct,key:dr,value:Fr}),dn(!1)}catch{dn(!1)}},mi=()=>{if(dn(!1),qn(),un(en+1),An(!1),Je!==-1&&en+1>=Je)return wi({key:"manualIdCheckNeeded",value:!0}),Zi(()=>Qe({...Ar.current,type:"skip"}));Sn(!0)},Jr=()=>{var dr;return dn(!1),An(!1),Sn(!1),qn(),Ge(getLogObject("successCapture",{response:Ar.current})),(dr=Ar.current)!=null&&dr.showMandatoryConsent?(Mt(Ar.current),!0):(Ze(Ar.current),!0)},Di=()=>{qn(),_t(!0)},aa=Gt,Ei=async(dr,Fr)=>{if(clearTimeout(manualCaptureTimeout),manualCaptureTimeout=void 0,!dr)return;sa(),addEvent({token:Ct,code:Lt?`manualCapture${Pn}`:`capture${Pn}`,payload:{[`manualCapture${Pn}`]:!0}});const li=dr.getBase64Image(),{blob:ai,url:ea}=dr.getBlobData();if(Zt(ea),Di(),await OnboardingAnalytics$1.analyzeFrame(li),MlWasmJSApi$1.resetAllPipelines(),it)return Ze({imageBase64:li,blob:ai,url:ea});if(vt&&cn(!0),Lt||addScreenEvent({module:Qn,screen:eventScreenNames[`${xn}CameraCapture`],token:Ct,shouldOpen:!1}),addScreenEvent({module:Qn,screen:eventScreenNames[`${xn}UploadProgress`],token:Ct,shouldOpen:!0}),pt||Tt){const{success:Kr}=await pt?await addCreditCardFront({token:Ct,base64Image:li}):await addCreditCardBack({token:Ct,base64Image:li});addScreenEvent({module:Qn,screen:eventScreenNames[`${xn}UploadProgress`],token:Ct,shouldOpen:!1}),Kr?(addScreenEvent({module:Qn,screen:eventScreenNames[`${xn}UploadSuccess`],token:Ct,shouldOpen:!0}),ut(!0),await sleep(SLEEP_DURATION),addScreenEvent({module:Qn,screen:eventScreenNames[`${xn}UploadSuccess`],token:Ct,shouldOpen:!1}),Ge(getLogObject("captureSucessful",{message:Nn(`Capture for ${Pn} was successful`)})),Ft("white")):(addScreenEvent({module:Qn,screen:eventScreenNames[`${xn}AttemptFailed`],token:Ct,shouldOpen:!0}),Ge(getLogObject("attemptFailed",{attempt:en+1})),ut(!1),Kt("error"),await sleep(SLEEP_DURATION),addScreenEvent({module:Qn,screen:eventScreenNames[`${xn}AttemptFailed`],token:Ct,shouldOpen:!1}),addScreenEvent({module:Qn,screen:eventScreenNames[`${xn}CameraCapture`],token:Ct,shouldOpen:!0}),Ft("white")),Vt(!0),Gt(100)}else addEvent({token:tt==null?void 0:tt.token,code:"cameraFeedbackDisplayed",module:"ID capture",screen:`${Pn}image inspection`,payload:{feedback:"Inspecting..."}}),Ge(getLogObject("inspecting",{message:Nn(`Inspecting ${Pn}...`)})),addEvent({token:tt==null?void 0:tt.token,code:"captureAttemptFinished",module:`ID capture ${Pn}`,payload:{logs:OnboardingAnalytics$1.getPipelineLogs()}}),(Pn==="FrontId"||Pn==="Passport")&&addDeviceStats(tt==null?void 0:tt.token,{frontIdStatsAnalysisStatus:OnboardingAnalytics$1.getAnalysisStatus(),backIdStatsAnalysisStatus:"",selfieStatsAnalysisStatus:"",motionStatus:OnboardingAnalytics$1.getMotionStatus()}),Pn==="BackId"&&addDeviceStats(tt==null?void 0:tt.token,{frontIdStatsAnalysisStatus:"",backIdStatsAnalysisStatus:OnboardingAnalytics$1.getAnalysisStatus(),selfieStatsAnalysisStatus:"",motionStatus:OnboardingAnalytics$1.getMotionStatus()}),await sleep(ZOOM_WAIT_DURATION),await capture({token:Ct,image:et?li:ai,type:Ue,onProgress:aa,sendBase64:et,onlyFront:He,isRetry:st,isSecondId:ct,encrypted:!1,faceCoordinates:void 0,imageType:void 0,shouldSkipGlareBack:Vn==null?void 0:Vn.skipGlareBack,shouldSkipGlareFront:Vn==null?void 0:Vn.skipGlareFront,...Fr&&{glare:Fr.glare,sharpness:Fr.sharpness}}).then(async Kr=>{var Ka;const{skipGlareBack:ta,skipGlareFront:fi}=Kr;(ta||fi)&&$n({...Vn,skipGlareBack:ta,skipGlareFront:fi});const Si=await getImages$1({token:Ct,body:{images:["croppedIDFace",...vt?[Pn==="BackId"?"croppedBackID":"croppedFrontID"]:[]]},onDownloadProgress:Fa=>jt(Fa)}).catch(()=>({croppedIDFace:"",croppedFrontID:"",croppedBackID:""}));if(Ar.current={...Kr,originalImage:li,frontIdImage:Si.croppedIDFace,backIdImage:Si.croppedBackID,...Si},vt&&(Si.croppedFrontID||Si.croppedBackID)){const Fa=(Ka=IncodeCanvas==null?void 0:IncodeCanvas.base64ToBlob(Si.croppedFrontID??Si.croppedBackID))==null?void 0:Ka.url,Va=document.createElement("img");Va.src=Fa,Va.onload=()=>{hn(Va.width>Va.height)},Zt(Fa)}cn(!1);const{status:co,message:Ga,errorKey:Ha,logMessage:Xa}=me(Kr);addScreenEvent({module:Qn,screen:eventScreenNames[`${xn}UploadProgress`],token:Ct,shouldOpen:!1}),Ge(getLogObject(`uploading${Pn}`,{message:Nn(`Uploading ${Pn}`)}));const $a=(Kr==null?void 0:Kr.skipGlareFront)&&Pn==="FrontId",Bo=(Kr==null?void 0:Kr.skipGlareBack)&&Pn==="BackId";co&&!$a&&!Bo?(addScreenEvent({module:Qn,screen:eventScreenNames[`${xn}AttemptFailed`],token:Ct,shouldOpen:!0}),Ge(getLogObject("attemptFailed",{response:Ar.current,message:Ga,reason:Ha,attempt:en+1})),addEvent({token:tt==null?void 0:tt.token,code:"captureStatusDisplayed",module:"ID capture",screen:`${Pn} image inspection`,payload:{capture_status:"Scan failed",feedback:Xa??Ga}}),ut(!1),Kt(Ga),await sleep(SLEEP_DURATION),addScreenEvent({module:Qn,screen:eventScreenNames[`${xn}AttemptFailed`],token:Ct,shouldOpen:!1}),addScreenEvent({module:Qn,screen:eventScreenNames[`${xn}CameraCapture`],token:Ct,shouldOpen:!0}),Ft("white")):(addScreenEvent({module:Qn,screen:eventScreenNames[`${xn}UploadSuccess`],token:Ct,shouldOpen:!0}),addEvent({token:tt==null?void 0:tt.token,code:"captureStatusDisplayed",screen:`${Pn} image inspection`,module:"ID capture",payload:{capture_status:"Scan succeeded",feedback:"Success!"}}),Ge(getLogObject(`${Pn}UploadSuccessful`,{message:Nn(`${Pn} capture was successful`)})),zt(Si.croppedFace),ut(!0),await sleep(SUCESS_SLEEP_DURATION),addScreenEvent({module:Qn,screen:eventScreenNames[`${xn}UploadSuccess`],token:Ct,shouldOpen:!1}),Ft("white")),Vt(!0)}).catch(async Kr=>{const{message:ta,errorKey:fi}=me(Kr.response.data);addScreenEvent({module:Qn,screen:eventScreenNames[`${xn}AttemptFailed`],token:Ct,shouldOpen:!0}),Ge(getLogObject("attemptFailed",{response:Kr.response.data,message:ta,reason:fi,attempt:en+1})),hn(!1),Kt(ta),ut(!1),Gt(100),Vt(!0),await sleep(SLEEP_DURATION),addScreenEvent({module:Qn,screen:eventScreenNames[`${xn}AttemptFailed`],token:Ct,shouldOpen:!1}),addScreenEvent({module:Qn,screen:eventScreenNames[`${xn}CameraCapture`],token:Ct,shouldOpen:!0}),Ft("white")}).finally(()=>{})},oa=async()=>{gi(!0,mt,!1),mr.current=!1,Yn(Tn,wn),Lt||(await sleep(SLEEP_DURATION),Ri())},Ma=dr=>{dr?Jr():mi(),Kt(""),_t(!1),cn(!1),hn(!1),Gt(0),Vt(!1),ut(null),Ft("white")},Ya=async()=>{var dr,Fr;if(!Lt){if(Et&&yt){const li=(dr=document.querySelector("video"))==null?void 0:dr.srcObject,ai=li==null?void 0:li.getVideoTracks()[0];ai&&await zoomCamera(ai,Et)}(Fr=En.current)==null||Fr.setIsLoadingCamera(!1),oa()}};function Ca(){kn?(Lt||Ri(),addEvent({token:Ct,code:"tryAgainSelected",screen:"ID capture help",module:"ID capture"}),addScreenEvent({module:Qn,screen:eventScreenNames[`${xn}Help`],token:Ct,shouldOpen:!1}),addScreenEvent({module:Qn,screen:eventScreenNames[`${xn}CameraCapture`],token:Ct,shouldOpen:!0}),Ge(getLogObject("commonIssuesClosed",{}))):(addEvent({token:Ct,code:"needHelpSelected",screen:`${Pn} Camera Capture`,module:"ID capture"}),addScreenEvent({module:Qn,screen:eventScreenNames[`${xn}CameraCapture`],token:Ct,shouldOpen:!1}),addScreenEvent({module:Qn,screen:eventScreenNames[`${xn}Help`],token:Ct,shouldOpen:!0}),Ge(getLogObject("commonIssuesOpened",{})),mr.current=!1),Ln(!kn)}function xa(){if(Je!==-1&&en>=Je)return;const dr=En.current.getCanvas();dr.updateBase64Image(),dr.updateBlob(),lt?Ei(dr):Jn({isOpen:!0,canvas:dr})}function sa(){Jn({isOpen:!1,canvas:null})}if(!yn)return null;const so=(()=>yt?tn?"horizontalKiosk":"verticalKiosk":mobile.any()?tn?"horizontal":He?"passport":"vertical":"desktop")();if(yt)return jsxs(Fragment,{children:[jsx(NotificationsTitle,{className:classNames({surface:isSurface,kiosk:!0}),children:!Ht&&!zn.isOpen&&jsx(Notification,{inline:!0,center:!0,noPortal:!0,isKiosk:yt})}),Hn&&jsxs(CaptureContainer,{className:classNames({kiosk:!0}),children:[jsxs(WebcamContainer,{className:classNames({[Ht?Dt==null?"neutral":Dt?"success":"error":""]:!0,surface:isSurface,kiosk:!0}),children:[Ht?jsxs(Fragment,{children:[sn?jsx(Opacity,{}):null,jsx(TakenPicture,{src:Ot,shouldBlurImage:sn})]}):jsxs(Fragment,{children:[jsx(Webcam,{ref:En,onPlay:Ya,videoSource:"environment",permission:Xe,setPermission:$e,permissionMessage:Ke,permissionBackgroundColor:nt,onLog:Ge,stream:rt,onError:Qe,token:Ct,type:Pn,interviewId:tt.interviewId,showCustomCameraPermissionScreen:at,onStreamReady:dt?Mr:void 0,isRecordingEnabled:dt,onRestartOnboarding:ft,showDoublePermissionsRequest:gt,deviceId:bt,className:"kiosk",isKiosk:!0}),jsx(Mask,{className:"IncodeCaptureIdMask",show:Mn,top:an,frame:wt,animate:!Lt,type:so,showIDOverlay:!Lt&&At||Lt&&Nt||At&&Nt,isKiosk:!0})]}),jsx("span",{className:"step__video-overlay"}),Lt&&zn.isOpen&&jsx(Retake,{imageBase64:zn.canvas.getBase64Image(1,!0),onClose:sa,handleCapture:()=>Ei(zn.canvas),token:Ct,type:Ue})]}),Lt&&!Ht&&jsxs(FakeButtonContainer,{children:[jsxs(FakeButtonMessage,{children:[`${Nn("captureInstructions.step1")}
4887
4887
  ${Nn("captureInstructions.step2")}`,jsx(FakeButtonArrowDown,{})]}),jsx(FakeButton$1,{surface:isSurface,onClick:()=>xa(),"aria-label":Nn("manualCapture.ariaLabel")})]}),Ht&&jsx(CaptureKioskFeedback,{children:Xt||Nn("desktopHome.uploading")})]}),jsx("canvas",{id:"canvasFrame"})]});function lo(){return vt?($t+Pt)/200*100:$t}return mobile.isDesktop()?jsxs(Fragment,{children:[kn&&jsx(CommonIssuesModal,{onClose:Ca}),jsx(NotificationsTitle,{className:classNames({surface:isSurface}),children:!Ht&&!zn.isOpen?jsx(Notification,{inline:!0,center:!0,noPortal:!0}):jsx(HiddenTitle,{children:"Capture Front ID"})}),!Ht&&jsxs(NativeButton,{onClick:Ca,role:"button",children:[jsxs(Trans,{t:Nn,i18nKey:"commonIssues.needHelp",children:["Need ",jsx("br",{})," Help"]}),jsx(QuestionMarkImg,{src:questionsMaskIcon,alt:"question mark","aria-hidden":!0})]}),Hn&&jsxs(CaptureContainer,{children:[jsxs(WebcamContainer,{className:classNames({[Ht?Dt==null?"neutral":Dt?"success":"error":""]:!0,surface:isSurface}),children:[Ht?jsxs(Fragment,{children:[sn?jsx(Opacity,{}):null,jsx(TakenPicture,{alt:Nn("capturePreview.ariaLabel"),src:Ot,shouldBlurImage:sn})]}):jsx(Fragment,{children:jsx(Webcam,{ref:En,onPlay:Ya,videoSource:"environment",permission:Xe,setPermission:$e,permissionMessage:Ke,permissionBackgroundColor:nt,onLog:Ge,stream:rt,onError:Qe,token:Ct,type:Pn,interviewId:tt.interviewId,showCustomCameraPermissionScreen:at,onStreamReady:dt?Mr:void 0,isRecordingEnabled:dt,onRestartOnboarding:ft,showDoublePermissionsRequest:gt,deviceId:bt,publishAudio:xt})}),jsx("span",{className:"step__video-overlay"}),Lt&&zn.isOpen&&jsx(Retake,{imageBase64:zn.canvas.getBase64Image(1,!0),onClose:sa,handleCapture:()=>Ei(zn.canvas),token:Ct,type:Ue})]}),Lt&&!Ht&&jsxs(FakeButtonContainer,{children:[jsxs(FakeButtonMessage,{children:[`${Nn("captureInstructions.step1")}
4888
4888
  ${Nn("captureInstructions.step2")}`,jsx(FakeButtonArrowDown,{})]}),jsx(FakeButton$1,{desktop:!0,onClick:()=>xa(),"aria-label":Nn("manualCapture.ariaLabel")})]}),Ht&&jsx(CaptureFeedback,{children:Xt||Nn("desktopHome.uploading")})]}),jsx("canvas",{id:"canvasFrame"})]}):jsxs(Fragment,{children:[!Ht&&jsxs(NativeButton,{className:"IncodeCaptureIdNativeButton",onClick:Ca,role:"button",children:[jsxs(Trans,{t:Nn,i18nKey:"commonIssues.needHelp",children:["Need ",jsx("br",{})," Help"]}),jsx(QuestionMarkImg,{className:"IncodeCaptureIdQuestionMarkImg",src:questionsMaskIcon,alt:"question mark"})]}),kn&&jsx(CommonIssuesModal,{onClose:Ca}),Hn&&jsxs(Fragment,{children:[jsx(Webcam,{className:"IncodeCaptureIdWebcam",ref:En,onPlay:Ya,videoSource:"environment",permission:Xe,setPermission:$e,permissionMessage:Ke,permissionBackgroundColor:nt,onLog:Ge,stream:rt,onError:Qe,token:Ct,interviewId:tt.interviewId,type:Pn,showCustomCameraPermissionScreen:at,onStreamReady:yr,isRecordingEnabled:dt,onRestartOnboarding:ft,showDoublePermissionsRequest:gt,publishAudio:xt}),jsx(Mask,{className:"IncodeCaptureIdMask",show:Mn,top:an,frame:wt,animate:!Lt,type:so,showIDOverlay:!Lt&&At||Lt&&Nt||At&&Nt}),Lt&&zn.isOpen&&jsx(Retake,{imageBase64:zn.canvas.getBase64Image(1,!0),onClose:sa,handleCapture:()=>Ei(zn.canvas),token:Ct,type:Ue}),Lt&&jsxs(FakeButtonContainer,{className:"IncodeCaptureIdFakeButton",role:"region","aria-live":"assertive",children:[jsxs(FakeButtonMessage,{className:"IncodeCaptureIdFakeButtonMessage",children:[`${Nn("captureInstructions.step1")}
4889
4889
  ${Nn("captureInstructions.step2")}`,jsx(FakeButtonArrowDown,{className:"IncodeCaptureIdFakeButtonArrowDown"})]}),jsx(FakeButton$1,{className:"IncodeCaptureIdFakeButtonImage",onClick:()=>xa(),"aria-label":Nn("manualCapture.ariaLabel")})]}),Ht&&jsx(CapturePreview,{message:Xt,progress:lo(),finishCapture:It,captureSuccessful:Dt,onClose:Ma,imageBase64:Ot,isSelfie:!1,isPassport:He,shouldRotate:fn,shouldBlurImage:sn}),jsx("span",{className:"step__video-overlay"}),!Ht&&!zn.isOpen&&!Lt&&jsx(Notification,{inline:!1,center:!0})]}),jsx("canvas",{id:"canvasFrame"})]})}const CaptureIdWithChooseCamera=ue=>{const[me,Ue]=useDeviceId();function Qe(Ze){Ue(Ze)}return mobile.any()||me==="error"?jsx(CaptureId,{...ue}):me?jsx(CaptureId,{...ue,deviceId:me}):jsx(ChooseCamera,{onCameraChosen:Qe,token:ue.token.token})},CaptureID=preloadScript$4(CaptureIdWithChooseCamera);function CaptureBackId(ue){const{t:me}=useTranslation(),[Ue]=useSessionState(null),Qe=React$1.useRef(void 0);return jsx(CaptureID,{...ue,shouldTakeIdAgain:({sharpness:Ge,glare:He,classification:Xe,failReason:$e})=>{const Ke="";if($e==="ID_TYPE_UNACCEPTABLE")return{status:!0,message:me("notifications.idTypeUnacceptable"),logMessage:Ke};if($e==="WRONG_DOCUMENT_SIDE")return{status:!0,message:me("notifications.wrongSide"),logMessage:"Wrong side detected. Scan back of ID card."};if(!Xe)return{status:!0,message:me("notifications.backClassificationFailed"),logMessage:Ke};const nt=mobile.isDesktop()?-1:10,tt=10;return Ge<nt?{status:!0,message:me("notifications.lowSharpness"),logMessage:Ke}:He<tt&&!(Ue!=null&&Ue.skipGlareBack)?{status:!0,message:me("notifications.glareDetected"),logMessage:Ke}:{status:!1,message:"",logMessage:Ke}},type:backType,getInstructionsNotification:Ge=>{var Xe;if(ue.scanPdf417)return{notificationMessage:jsx("div",{style:{textAlign:"center"},children:jsx("div",{children:me("notifications.showBack.pdf417")})})};const He=me(Ge?"notifications.showBackLowEnd.one":"notifications.showBack.one");return ue.onLog&&ue.onLog(getLogObject("showBack",{message:He})),Qe.current!==He&&(addEvent({token:(Xe=ue==null?void 0:ue.token)==null?void 0:Xe.token,code:"cameraFeedbackDisplayed",payload:{feedback:"Fill frame with front id"},module:"ID capture",screen:"Back ID camera capture"}),Qe.current=He),{notificationMessage:jsx("div",{style:{textAlign:"center"},children:jsx("div",{children:He})}),notificationVariant:"rotate"}},isCreditCardBack:ue.type==="creditCardBack"})}function CaptureAndTutorial$3(ue){const{currentStep:me,nextStep:Ue}=useSteps(),Qe=ue.type==="creditCardBack"?TutorialCreditCardBack:TutorialBack;return jsxs(Steps,{currentStep:me,children:[ue.showTutorial&&isWebRtcSupported()&&jsx(Qe,{className:"IncodeCaptureBackIdTutorial",...ue,onSuccess:Ue,token:ue.token}),jsx(CaptureBackId,{...ue})]})}const TutorialSelfieHeader=()=>{const{t:ue}=useTranslation();return jsxs(TutorialSHeader,{children:[jsx("h1",{children:ue("tutorial.selfie1")}),jsx("section",{children:jsx("span",{children:`${ue("tutorial.selfie2")} ${ue("tutorial.selfie3")}`})})]})};function TutorialSelfie({onSuccess:ue,token:me,...Ue}){const{t:Qe}=useTranslation(),Ze=()=>options.darkMode?"https://sdk.incode.com/sdk/tutorials/selfie-dark.mp4":"https://sdk.incode.com/sdk/tutorials/selfie.gif";React$1.useEffect(()=>{me!=null&&me.token&&addEvent({token:me.token,code:"tutorialSelfie",payload:{tutorialSelfie:!0}})},[me==null?void 0:me.token]);function Je(){addEvent({token:me==null?void 0:me.token,code:"continue"}),ue()}return jsx(Tutorial,{...Ue,token:me||{},selfie:!0,src:Ze(),header:jsx(TutorialSelfieHeader,{}),type:"selfie",children:jsx(ButtonsContainer$4,{children:jsx(StyledButton,{className:classNames("IncodeTutorialButton","IncodeTutorialButtonSelfie"),onClick:Je,children:Qe("common.continue")})})})}const CaptureButtonContainer=styled(CaptureButtonContainer$2)`
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "main": "./dist/onBoarding.umd.js",
4
4
  "module": "./dist/onBoarding.mjs",
5
5
  "types": "./dist/incode-welcome/src/index.d.ts",
6
- "version": "1.72.0-rc.20240614183418",
6
+ "version": "1.72.0",
7
7
  "publishConfig": {},
8
8
  "exports": {
9
9
  ".": {
@@ -65,12 +65,12 @@
65
65
  "react-pdf": "^5.7.2",
66
66
  "react-qr-code": "^2.0.5",
67
67
  "react-transition-group": "^4.4.2",
68
- "rehype-raw": "^7.0.0",
69
68
  "signature_pad": "^4.0.5",
70
69
  "styled-components": "^5.3.3",
71
70
  "swiper": "^9.0.3",
72
71
  "ua-parser-js": "^1.0.33",
73
- "vite-plugin-dts": "^3.6.4"
72
+ "vite-plugin-dts": "^3.6.4",
73
+ "rehype-raw": "^7.0.0"
74
74
  },
75
75
  "devDependencies": {
76
76
  "@biomejs/biome": "1.5.3",
@@ -1 +0,0 @@
1
- {"version":3,"file":"sendZoomedFrame.d.ts","sourceRoot":"","sources":["../../../../src/camera/sendZoomedFrame.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,OAAO;;;;CAIV,CAAC;AAEX,KAAK,IAAI,GAAG,MAAM,OAAO,OAAO,CAAC;AACjC,KAAK,WAAW,GAAG,CAAC,OAAO,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC;AAC1C,eAAO,MAAM,eAAe;YAKlB,WAAW;iBACN,MAAM;WACZ,MAAM;;aAGM,OAAO;EAgB3B,CAAC"}