@sekyro/elements 0.1.0-rc.21 → 0.1.0-rc.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/cdn/chunks/{capture-session-doc-HZJLTWTY-XAP4ZT6R.js → capture-session-doc-ENDGVJ3L-IMAPC36N.js} +1 -1
  3. package/dist/cdn/chunks/{chunk-67YJZR73.js → chunk-4RREQCYP.js} +1 -1
  4. package/dist/cdn/chunks/{chunk-QAZ7TATZ.js → chunk-B7JVGTNG.js} +1 -1
  5. package/dist/cdn/chunks/{chunk-AUH3O7Y7.js → chunk-BG7ZLMF3.js} +1 -1
  6. package/dist/cdn/chunks/{chunk-YRZXUDPO.js → chunk-BZCLR3ZW.js} +1 -1
  7. package/dist/cdn/chunks/{chunk-IBCFJKIO.js → chunk-FUMXKBXY.js} +2 -2
  8. package/dist/cdn/chunks/{chunk-NUIGLBFF.js → chunk-HHBISLBD.js} +1 -1
  9. package/dist/cdn/chunks/{chunk-YI34K4SS.js → chunk-HM5EP25H.js} +1 -1
  10. package/dist/cdn/chunks/{chunk-KPGPSJ64.js → chunk-NGWIL3RI.js} +1 -1
  11. package/dist/cdn/chunks/{chunk-VJKFYIPK.js → chunk-NNIK6RGK.js} +1 -1
  12. package/dist/cdn/chunks/{chunk-QESNTWNP.js → chunk-PSLOZIUH.js} +2 -2
  13. package/dist/cdn/chunks/{chunk-B2KJUHRZ.js → chunk-PXF2CWO3.js} +1 -1
  14. package/dist/cdn/chunks/{chunk-WICQIC37.js → chunk-RCDZUOGM.js} +1 -1
  15. package/dist/cdn/chunks/{chunk-4QUL7TEF.js → chunk-RVPBL3KC.js} +1 -1
  16. package/dist/cdn/chunks/{chunk-ZPLN3VRG.js → chunk-TCXBCGZF.js} +1 -1
  17. package/dist/cdn/chunks/{chunk-QE347ZEI.js → chunk-UMGCNKDP.js} +1 -1
  18. package/dist/cdn/chunks/{create-document-capture-R7KKX6YY-5FG6AKTA.js → create-document-capture-SZ4SIVVC-P4MMZXVZ.js} +1 -1
  19. package/dist/cdn/chunks/{document-capture-view-2CSWLQWR-E6PKDMWJ.js → document-capture-view-ZQONDCSM-CX2F54ZS.js} +1 -1
  20. package/dist/cdn/chunks/{eid-view-FEJHQBSB-BA27H43Q.js → eid-view-FEJHQBSB-YSYB6LNM.js} +1 -1
  21. package/dist/cdn/chunks/{email-otp-view-4EY5CKR5-LVNJQLG6.js → email-otp-view-4EY5CKR5-QMWJOSCD.js} +1 -1
  22. package/dist/cdn/chunks/{flow-views-Q4Z2BS6Z-MZ4EFAQ6.js → flow-views-JC2DWBW3-GP5F4777.js} +1 -1
  23. package/dist/cdn/chunks/{form-view-GPITA6X5-LAPFWBZM.js → form-view-GPITA6X5-YDYPXP7W.js} +1 -1
  24. package/dist/cdn/chunks/plan-runner-MC6KC7PK-E55J5SPN.js +1 -0
  25. package/dist/cdn/chunks/{portrait-capture-view-5YLRWE4H-EGV5GCSU.js → portrait-capture-view-Q6XYTGE7-BL2EYATL.js} +1 -1
  26. package/dist/cdn/chunks/{portrait-review-view-ZAJ5TIXP-W6UQWTWP.js → portrait-review-view-KZVKR6XN-QEZYASJF.js} +1 -1
  27. package/dist/cdn/chunks/{proof-of-address-view-VH573XDT-JJCHDOH4.js → proof-of-address-view-YYZTILHQ-BVR6FUOS.js} +1 -1
  28. package/dist/cdn/define.js +1 -1
  29. package/dist/cdn/index.js +1 -1
  30. package/dist/{chunk-TKRB6RXI.js → chunk-GDJMAPFB.js} +2 -2
  31. package/dist/{chunk-3CAVDRYH.js → chunk-TEJOSW5W.js} +1 -1
  32. package/dist/{chunk-BGEGDQXU.js → chunk-ZTBXWO2O.js} +1 -1
  33. package/dist/define.cjs +3 -3
  34. package/dist/define.js +1 -1
  35. package/dist/{document-capture-view-2CSWLQWR-TB6SX3MZ.js → document-capture-view-ZQONDCSM-HUO7JCZZ.js} +1 -1
  36. package/dist/{flow-views-Q4Z2BS6Z-ZSPSSABE.js → flow-views-JC2DWBW3-YYRQOY3A.js} +1 -1
  37. package/dist/index.cjs +3 -3
  38. package/dist/index.js +1 -1
  39. package/dist/{portrait-capture-view-5YLRWE4H-4FZAEZS2.js → portrait-capture-view-Q6XYTGE7-VKH2G5FA.js} +1 -1
  40. package/dist/{portrait-review-view-ZAJ5TIXP-JKR2R7RK.js → portrait-review-view-KZVKR6XN-RIAO3V65.js} +1 -1
  41. package/dist/{proof-of-address-view-VH573XDT-UKGWSGG3.js → proof-of-address-view-YYZTILHQ-7OJWBD3P.js} +1 -1
  42. package/package.json +2 -2
  43. package/sbom.cdx.json +4 -4
  44. package/dist/cdn/chunks/plan-runner-HOMYGD6Y-GMUP34K3.js +0 -1
  45. /package/dist/cdn/chunks/{challenge-frame-YBTLAQ5G-NN763UU5.js → challenge-frame-FGQBS3HD-S3UO5OUT.js} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @sekyro/elements
2
2
 
3
+ ## 0.1.0-rc.23
4
+
5
+ ### Patch Changes
6
+
7
+ - Carries the @sekyro/react release of this version: the changes in its changelog reach the element.
8
+ - Updated dependencies [7c011c6]
9
+ - @sekyro/web@0.1.0-rc.44
10
+
11
+ ## 0.1.0-rc.22
12
+
13
+ ### Patch Changes
14
+
15
+ - Carries the @sekyro/react release of this version: the changes in its changelog reach the element.
16
+ - Updated dependencies [67d39fe]
17
+ - @sekyro/web@0.1.0-rc.43
18
+
3
19
  ## 0.1.0-rc.21
4
20
 
5
21
  ### Patch Changes
@@ -1 +1 @@
1
- import{b as s,c as a,d as _,e as C,f as A,g as D,h as o,i as S,j as r,k as t,l as E,m as p,n as T,o as O,p as i,q as m,r as R}from"./chunk-VJKFYIPK.js";import"./chunk-IWZRAEUN.js";import"./chunk-LSBUNQZU.js";import"./chunk-F4Q2Q4OC.js";import"./chunk-HHII35OF.js";import"./chunk-WICQIC37.js";import"./chunk-P7K7ELYZ.js";import"./chunk-JS2IXPNL.js";import"./chunk-4FHWXBOB.js";export{i as CAPTURE_CANDIDATE_SPACING_MS,O as CAPTURE_EXTRA_CANDIDATES,m as CAPTURE_WINDOW_MS,p as CaptureSessionDoc,_ as DOC_BLACK_FRAME_LUMA,C as DOC_BLACK_FRAME_TICKS,A as DOC_CADENCE_HZ,a as DOC_FIRST_FRAME_MS,o as DOC_PROFILE_TICKS,t as DOC_SHUTTER_DEFAULTS,r as DOC_SLOW_TICK_MS,S as DOC_WARMUP_TICKS,R as REFOCUS_APPLY_MAX_MS,D as SIDE_PROBE_MS,T as passportBandOf,E as resolveDocShutterTuning,s as warmDocDetector};
1
+ import{b as s,c as a,d as _,e as C,f as A,g as D,h as o,i as S,j as r,k as t,l as E,m as p,n as T,o as O,p as i,q as m,r as R}from"./chunk-NNIK6RGK.js";import"./chunk-IWZRAEUN.js";import"./chunk-LSBUNQZU.js";import"./chunk-F4Q2Q4OC.js";import"./chunk-HHII35OF.js";import"./chunk-RCDZUOGM.js";import"./chunk-P7K7ELYZ.js";import"./chunk-JS2IXPNL.js";import"./chunk-4FHWXBOB.js";export{i as CAPTURE_CANDIDATE_SPACING_MS,O as CAPTURE_EXTRA_CANDIDATES,m as CAPTURE_WINDOW_MS,p as CaptureSessionDoc,_ as DOC_BLACK_FRAME_LUMA,C as DOC_BLACK_FRAME_TICKS,A as DOC_CADENCE_HZ,a as DOC_FIRST_FRAME_MS,o as DOC_PROFILE_TICKS,t as DOC_SHUTTER_DEFAULTS,r as DOC_SLOW_TICK_MS,S as DOC_WARMUP_TICKS,R as REFOCUS_APPLY_MAX_MS,D as SIDE_PROBE_MS,T as passportBandOf,E as resolveDocShutterTuning,s as warmDocDetector};
@@ -1 +1 @@
1
- import{b as L}from"./chunk-4QUL7TEF.js";import{a as J,c as R}from"./chunk-WICQIC37.js";import{b as U}from"./chunk-6MYG4HWP.js";import{a as r}from"./chunk-4FHWXBOB.js";var g,h=(g=class extends Error{constructor(t){super(t.message),this.name="HostedApiError",this.status=t.status,this.code=t.code,t.retryAfterSeconds!==void 0&&(this.retryAfterSeconds=t.retryAfterSeconds),t.details&&(this.details=t.details)}},r(g,"u"),g);function H(e,t,n=Math.random){let i=(e??t)*1e3,s=Math.min(Math.max(i,500),2e4),a=Math.round(s*(1+(n()*2-1)*.25));return Math.min(Math.max(a,500),2e4)}r(H,"T");var V=6e4,N=4,se=3e4,re=9e5,ae=200,oe=5,ce=400,de=new Set(["server_busy","request_timeout"]),ue=20,le=60,pe=600,he=2;function v(e){return(e.split(";")[0]??"").trim()}r(v,"l");var me={liveness:"clipKey",face_match:"imageKey",doc_ocr:"imageKey"},fe=`@sekyro/web/${J}`,ye=fe,b,st=(b=class{constructor(t){this.sessionId=null,this.bootstrap=null,this.captureNonces=[],this.captureFetch=null,this.reportedIssues=new Map,this.issueReports=0,this.issuesPausedUntil=0,this.apiOrigin=t.apiOrigin.replace(/\/+$/,""),this.sessionToken=t.sessionToken;let n=t.fetch;this.fetchImpl=(i,s)=>(n??globalThis.fetch).call(globalThis,i,s),this.requestTimeoutMs=t.requestTimeoutMs??se,this.retryAttempts=t.inProgressRetry?.attempts??oe,this.retryDelayMs=t.inProgressRetry?.delayMs??ce,this.random=t.random??Math.random,this.clientLocale=t.locale}async getSession(){let t=await this.api("GET","/hosted/session");return this.sessionId=t.sessionId,t}async recordConsent(t){let n=await this.api("POST","/hosted/consent",{body:{locale:t},busyRetry:!0}),i=this.captureHold;return this.captureHold=void 0,i&&this.armCapture(i),n}async reportCameraUnavailable(t){return this.api("POST","/hosted/camera-unavailable",{body:{cause:t}})}async testerGate(t){return this.api("POST","/hosted/tester-gate",{body:{input:t}})}async reportCaptureIssue(t){let n=typeof t.name=="string"?t.name.replace(/[^A-Za-z]/g,"").slice(0,40):"",i=typeof t.engineKind=="string"&&/^[a-z_]{1,32}$/.test(t.engineKind)?t.engineKind:void 0,s=typeof t.attempt=="number"&&Number.isInteger(t.attempt)&&t.attempt>=0&&t.attempt<=1e3?t.attempt:void 0,a=t.check==="attestation"?s??"":"",c=[t.check,a,t.kind,n,t.phase??"",i??""].join("|"),d=this.reportedIssues.get(c);if(d!==void 0)return d;if(Date.now()<this.issuesPausedUntil||this.issueReports>=ue)return;let o={check:t.check,kind:t.kind,...n!==""?{name:n}:{},...t.phase!==void 0?{phase:t.phase}:{},...i!==void 0?{engineKind:i}:{},...s!==void 0?{attempt:s}:{},...t.formFactor!==void 0?{formFactor:t.formFactor}:{},...typeof t.detail=="string"&&/^\d{1,10}$/.test(t.detail)?{detail:t.detail}:{},...G(t.challengeMs)?{challengeMs:t.challengeMs}:{},...G(t.readyMs)?{readyMs:t.readyMs}:{},...t.inApp===!0?{inApp:!0}:{}};this.issueReports+=1;let u=this.api("POST","/hosted/capture-issue",{body:o,empty:!0}).catch(l=>{if(l instanceof h&&l.status===429){let p=Math.min(Math.max(l.retryAfterSeconds??le,0),pe);this.issuesPausedUntil=Math.max(this.issuesPausedUntil,Date.now()+p*1e3);return}(!(l instanceof h)||l.status===0||l.status>=500)&&this.reportedIssues.delete(c)});return this.reportedIssues.set(c,u),u}async choose(t,n){let i=await this.api("POST","/hosted/choice",{body:{nodeId:t,option:n},busyRetry:!0});return this.sessionId=i.sessionId,i}async confirmIdentity(t){return this.api("POST","/hosted/identity/confirm",{body:{decision:t}})}async identityPortrait(){return this.api("GET","/hosted/identity/portrait",{blob:!0})}async presign(t,n,i,s={}){let a=await this.ensureSessionId(),c={kind:t,contentType:v(n),contentLength:i,...s.source==="upload"?{source:"upload"}:{}};return this.api("POST",`/sessions/${a}/media`,{body:c})}armCapture(t=2){let n=Date.now();this.captureNonces.filter(i=>i.expiresAt-V>n).length>=t||(this.captureHold===void 0?this.fillCaptureNonces(t,t):this.captureHold=Math.max(this.captureHold,t))}async armRamp(){try{let t=await this.ensureSessionId(),n=await this.api("POST",`/sessions/${t}/media/capture-nonces`,{body:{count:2,ramp:!0}}),i=Date.now(),s=L(n.screenRamp)?n.screenRamp:void 0,a=i+Math.max(0,n.expiresIn)*1e3;for(let d of Array.isArray(n.nonces)?n.nonces:[])typeof d!="string"||d.length===0||this.captureNonces.push({nonce:d,expiresAt:a,...s!==void 0?{arm:s.nonce}:{}});this.captureNonces=this.captureNonces.slice(-N),this.captureHold=void 0;let c=typeof n.rampExpiresIn=="number"&&n.rampExpiresIn>0?n.rampExpiresIn:0;return{...s!==void 0?{challenge:s}:{},expiresAt:i+c*1e3}}catch{return}}async presignCapture(t,n,i,s={}){let a=await this.ensureSessionId(),c=await this.takeCaptureNonce(s.arm),d=c===void 0?void 0:{nonce:c,...s.engine!==void 0?{engine:s.engine.slice(0,32)}:{},...s.durationMs!==void 0&&Number.isFinite(s.durationMs)?{captureMs:Math.min(36e5,Math.max(0,Math.round(s.durationMs)))}:{}},o={kind:t,contentType:v(n),contentLength:i,capture:d};return this.api("POST",`/sessions/${a}/media`,{body:o})}async takeCaptureNonce(t){let n=r(()=>{let i=Date.now();this.captureNonces=this.captureNonces.filter(a=>a.expiresAt-V>i);let s=this.captureNonces.findIndex(a=>a.arm===t);return this.captureNonces.splice(s<0?0:s,1)[0]?.nonce},"n");for(let i=0;i<2;i++){let s=n();if(s!==void 0)return s;await this.fillCaptureNonces(1)}return n()}fillCaptureNonces(t,n=0){return this.captureFetch??(this.captureFetch=(async()=>{try{let i=await this.ensureSessionId(),s=await this.api("POST",`/sessions/${i}/media/capture-nonces`,{body:{count:Math.min(N,Math.max(1,t))}}),a=Date.now()+Math.max(0,s.expiresIn)*1e3;for(let c of Array.isArray(s.nonces)?s.nonces:[])typeof c=="string"&&c.length>0&&this.captureNonces.push({nonce:c,expiresAt:a});this.captureNonces=this.captureNonces.slice(-N),this.captureHold=void 0}catch(i){i instanceof h&&i.code==="consent_required"&&(this.captureHold=Math.max(this.captureHold??0,n))}})().finally(()=>{this.captureFetch=null})),this.captureFetch}async uploadToSpaces(t,n,i){let s;try{s=await this.fetchImpl(t,{method:"PUT",headers:{"content-type":v(i)},body:n,signal:AbortSignal.timeout(re)})}catch(a){throw K(a)}if(!s.ok){let a=(await s.text().catch(()=>"")).slice(0,ae);throw new h({status:s.status,code:"upload_failed",message:`media upload failed (HTTP ${s.status})${a?`: ${a}`:""}`})}}async completeMedia(t){let n=await this.ensureSessionId();return this.api("POST",`/sessions/${n}/media/complete`,{body:{key:t}})}async submitCheck(t,n,i={}){let s=await this.ensureSessionId(),a={input:n,forceOutcome:i.forceOutcome};return this.api("POST",`/sessions/${s}/checks/${t}`,{body:a,idempotencyKey:i.idempotencyKey,...i.browserCheckToken!==void 0?{browserCheckToken:i.browserCheckToken}:{},busyRetry:i.idempotencyKey!==void 0})}async uploadAndSubmit(t,n,i,s={}){let a=v(n.contentType),c=await this.presign(n.kind,a,n.blob.size);await this.uploadToSpaces(c.uploadUrl,n.blob,a);let d=await this.completeMedia(c.key),o={...i,[me[t]]:d.key};return this.submitCheck(t,o,s)}async ensureSessionId(){return this.sessionId!==null?this.sessionId:(this.bootstrap??(this.bootstrap=this.getSession().finally(()=>{this.bootstrap=null})),(await this.bootstrap).sessionId)}async api(t,n,i={}){let s=t==="GET"||i.busyRetry===!0,a=`${this.apiOrigin}/api/v2${n}`,c={"x-session-token":this.sessionToken,"x-sekyro-sdk":ye};i.body!==void 0&&(c["content-type"]="application/json"),i.idempotencyKey!==void 0&&(c["x-idempotency-key"]=i.idempotencyKey),i.browserCheckToken!==void 0&&(c["sekyro-browser-check"]=i.browserCheckToken),this.clientLocale!==void 0&&(c["sekyro-client-locale"]=this.clientLocale);try{let d=R.timezone();d!==void 0&&(c["sekyro-client-timezone"]=d)}catch{}c["sekyro-client-form-factor"]=U();try{let d=await R.deviceHeader();d!==void 0&&(c["sekyro-client-device"]=d)}catch{}for(let d=0;;d++){let o;try{o=await this.fetchImpl(a,{method:t,headers:c,...i.body!==void 0?{body:JSON.stringify(i.body)}:{},cache:"no-store",signal:AbortSignal.timeout(this.requestTimeoutMs)})}catch(l){throw K(l)}if(o.ok){if(i.empty===!0)return;if(i.blob===!0)try{return await o.blob()}catch(p){throw K(p)}let l;try{l=await o.json()}catch{throw new h({status:o.status,code:"unknown_error",message:`response body was not valid JSON (HTTP ${o.status})`})}return _e(l)}let u=await ve(o);if(u.code==="idempotency_in_progress"&&d<this.retryAttempts){this.retryDelayMs>0&&await B(this.retryDelayMs);continue}if(s&&u.status===503&&de.has(u.code)){s=!1,await B(H(u.retryAfterSeconds,he,this.random));continue}throw u}}},r(b,"S"),b);function G(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0&&e<=6e5}r(G,"k");function K(e){if((typeof e=="object"&&e!==null?e.name:void 0)==="TimeoutError")return new h({status:0,code:"timeout",message:"request timed out"});let t=e instanceof Error?e.message:String(e);return new h({status:0,code:"network_error",message:`network request failed: ${t}`})}r(K,"f");function _e(e){return e!==null&&typeof e=="object"&&"success"in e&&"data"in e?e.data:e}r(_e,"L");async function ve(e){let t="unknown_error",n=`request failed (HTTP ${e.status})`,i=Number.NaN,s;try{let d=await e.json();if(d!==null&&typeof d=="object"){let o=d;typeof o.code=="string"&&o.code.length>0&&(t=o.code),typeof o.message=="string"&&o.message.length>0&&(n=o.message),typeof o.retryAfterSeconds=="number"&&(i=o.retryAfterSeconds),Array.isArray(o.details?.issues)?s=o.details:Array.isArray(o.details?.errors)&&(s={...o.details,issues:[]})}}catch{}let a=e.headers.get("retry-after"),c=a===null?Math.floor(i):Number.parseInt(a,10);return new h({status:e.status,code:t,message:n,...Number.isFinite(c)&&c>=0?{retryAfterSeconds:c}:{},details:s})}r(ve,"V");function B(e){return new Promise(t=>setTimeout(t,e))}r(B,"R");function rt(e){let t=e?.portrait,n=t?.icao,i=t?.purpose==="id_document";return n==null?i?{policy:"reject",profile:"id_document"}:null:{policy:n.policy==="alert"?"alert":"reject",profile:i||n.profile==="id_document"?"id_document":"selfie"}}r(rt,"J");function at(e){return{...e.baselineEyeOpenness!==void 0?{baselineEyeOpenness:e.baselineEyeOpenness}:{},...e.baselineEyeOpennessLeft!==void 0&&e.baselineEyeOpennessRight!==void 0?{baselineEyeOpennessLeft:e.baselineEyeOpennessLeft,baselineEyeOpennessRight:e.baselineEyeOpennessRight}:{},criteria:e.verdict??{},...e.backgroundCheck!==void 0?{backgroundCheck:e.backgroundCheck}:{}}}r(at,"Q");var ge=new Set(["nni_unbound","id_number_unbound","method_required","mobile_required","portrait_required"]);function ut(e){return ge.has(e)}r(ut,"ve");function lt(e,t,n){let i=t.detail;return{check:e,kind:t.kind,...i?.name!==void 0?{name:i.name}:{},...i?.phase!==void 0?{phase:i.phase}:{},...i?.engineKind!==void 0?{engineKind:i.engineKind}:{},attempt:Math.max(0,Math.min(1e3,n))}}r(lt,"Pe");function pt(){let e=-1,t="";return{note(n){n==="starting"&&t!=="starting"&&(e+=1),t=n},newHandle(){t=""},noteError(){e<0&&(e=0)},get value(){return e}}}r(pt,"xe");var be={document:"document_photo",nfc:"document_chip",population_registry:"national_number",national_eid:"national_eid"};function y(e){return e.plan?.steps??[]}r(y,"f");function F(e){return Math.max(0,e.attempts.max-e.attempts.used)}r(F,"x");function ke(e){let t=e.plan?.choice;return t!==void 0&&e.plan?.current===t.nodeId?t:null}r(ke,"J");function ht(e){let t=ke(e);if(t?.kind!=="identity_method")return null;let n=t.options.map(s=>be[s.service]).filter(s=>s!==void 0),i=t.options.find(s=>s.nationalEid)?.nationalEid;return i?{available:!0,selected:null,options:n,nationalEid:i}:{available:!0,selected:null,options:n}}r(ht,"Ve");var we=new Set(["liveness","face_match"]);function j(e){return e!==void 0&&(e.state==="pending"||e.state==="input_required")}r(j,"R");function Me(e){return e.status!=="created"&&e.status!=="in_progress"}r(Me,"T");function Y(e){let t=e.plan?.current,n=t==null?void 0:y(e).find(i=>i.id===t);return j(n)?n:void 0}r(Y,"M");function $(e,t){return y(e).find(n=>n.checkType===t)}r($,"_");function O(e){let t=y(e),n=t.findIndex(i=>i.checkType==="liveness");return t.find((i,s)=>s>n&&i.checkType==="face_match")}r(O,"S");function Se(e,t){let n=$(t,"liveness")?.state,i=O(t)?.state;return(O(e)?.state??"pending")==="pending"&&(n==="passed"||n==="review")&&i!==void 0&&i!=="pending"&&i!=="skipped"}r(Se,"F");function Z(e,t){let n=new Map(y(e).map(i=>[i.id,i.state]));return y(t).filter(i=>i.checkType==="face_match"&&(n.get(i.id)??"pending")==="pending"&&i.state!=="pending"&&i.state!=="skipped").map(i=>i.id)}r(Z,"V");var Ie=/^[0-9a-f]{24}$/i;function x(e){return Ie.test(e)?`ses_${e}`:e}r(x,"k");function E(e,t){let n=x(e);return t===void 0?{sessionId:n,status:"unavailable"}:{sessionId:n,status:"unavailable",reasonCode:t}}r(E,"C");function W(e,t,n){let i=x(e);return n===void 0?{sessionId:i,status:t}:{sessionId:i,status:t,reasonCode:n}}r(W,"O");function mt(e,t){let n=Ae(e,t),i=Te(e);return i!==void 0&&(n.sandbox={simulated:!0,reason:i}),n}r(mt,"Ee");var Ce=new Set(["no_testers","tester_gate_not_used","tester_gate_missed"]);function Te(e){if(e.sandbox!==!0)return;let t=e.simulation?.reason;return Ce.has(t)?t:void 0}r(Te,"Z");function Ae(e,t){let n=x(e.sessionId);switch(e.status){case"created":case"in_progress":return $e(e,t);case"verified":return P(e,{sessionId:n,status:"verified"});case"review_pending":return P(e,W(n,"review",X(e,"review")));case"not_verified":return P(e,Ee(e));default:return P(e,{sessionId:n,status:"not_verified"})}}r(Ae,"Q");var xe=new Set([0,1,2,3]);function P(e,t){return xe.has(e.level)&&(t.level=e.level),typeof e.assurance=="string"&&e.assurance.length>0&&(t.assurance=e.assurance),t}r(P,"v");function Ee(e){let t={sessionId:x(e.sessionId),status:"not_verified"};return e.reason!==void 0&&(t.reason=e.reason),e.reasonCode!==void 0&&(t.reasonCode=e.reasonCode),e.reasonCode==="device_cooldown"&&e.retryAfter!==void 0&&(t.retryAfter=e.retryAfter),t}r(Ee,"ne");function Pe(e){return e==="rejected"?"rejected":e==="unavailable"?"unavailable":"inconclusive"}r(Pe,"te");function Oe(e,t){if(t===void 0)return!1;let n=y(t).find(i=>i.id===e.id);return n!==void 0&&n.attempts.used===e.attempts.used}r(Oe,"ie");function $e(e,t){let n=x(e.sessionId),i=y(e).find(a=>we.has(a.checkType)&&a.state==="input_required"&&a.reason!==void 0);if(i?.reason==="mobile_required")return E(n,"mobile_required");if(i?.reason!==void 0){if(i.result==="unavailable")return E(n,i.reason);let a=t.autoRetry&&(F(i)>0||Oe(i,t.previous))?{sessionId:n,status:"retry",reasonCode:i.reason,attemptsRemaining:F(i)}:{sessionId:n,status:"not_verified",reason:Pe(i.result),reasonCode:i.reason,attemptsRemaining:F(i)};return i.retakeHint!==void 0&&(a.retakeHint=i.retakeHint),a}let s=Y(e);return s===void 0&&y(e).some(a=>a.state==="review")?W(n,"review",X(e,"review")):s?.checkType==="portrait_icao"?E(n,"portrait_required"):E(n)}r($e,"re");function X(e,t){return y(e).find(n=>n.state===t&&n.reason!==void 0)?.reason}r(X,"L");function ee(e,t,n,i,s){return e.presignCapture!==void 0?e.presignCapture(t,n,i,s):e.presign(t,n,i)}r(ee,"K");function te(e){return{engine:e?.engine,durationMs:e?.clipMs,arm:e?.screenRamp?.nonce}}r(te,"q");var qe=["video/webm","video/mp4"],Q="image/jpeg",Re=2,Ne=1e3,Ke=1e4,He=3,Fe=10,ze=3,je=new Set(["network_error","timeout","upload_failed","unknown_error","rate_limit_exceeded"]),De=new Set(["session_not_active","check_not_found","check_already_finalized","check_out_of_order","identity_confirm_required","check_not_active","step_not_on_path","native_app_required"]),k,D=(k=class extends Error{constructor(){super("verification destroyed"),this.name="FlowCancelledError"}},r(k,"b"),k);function Le(e){let t=O(e);return $(e,"portrait_icao")?.state!=="pending"&&(t!==void 0?j(t):e.capture?.livePhoto?.oneCapture===!0)}r(Le,"me");var w,A=(w=class extends Error{constructor(t){super(t),this.name="AttestationError"}},r(w,"h"),w),M,Ue=(M=class extends A{constructor(t){super(`no attestation token: ${t}`),this.name="AttestationUnavailableError",this.code=t}},r(M,"E"),M);function ft(e){return new h({status:400,code:"attestation_invalid",message:`browser check: ${e}`,details:{issues:[],browserCheck:e}})}r(ft,"Oe");function Je(e){if(!(e instanceof h)||e.code!=="attestation_invalid")return;let t=e.details?.browserCheck;return typeof t=="string"?t:void 0}r(Je,"he");async function ne(e,t,n={}){let i=e.uuid(),s=!1,a=!1,c=0,d=0;for(;;)try{return await t(e.client,i)}catch(o){if(o instanceof A){if(a||o instanceof Ue)throw o;a=!0,n.onAttestationInvalid?.(),i=e.uuid();continue}if(!(o instanceof h))throw o;if(o.code==="consent_required"&&!s){s=!0,await e.ensureConsent({force:!0}),i=e.uuid();continue}if(o.code==="attestation_invalid"&&!a&&Je(o)===void 0){a=!0,n.onAttestationInvalid?.(),i=e.uuid();continue}if(o.code==="inference_unavailable"&&d<He){d+=1;let u=H(o.retryAfterSeconds,Fe,e.random??Math.random);e.onBusy?.({attempt:d,retryAfterSeconds:u/1e3}),await e.sleep(u),n.onAttestationInvalid?.(),i=e.uuid();continue}if(je.has(o.code)&&c<Re){c+=1;let u=o.retryAfterSeconds!==void 0?o.retryAfterSeconds*1e3:void 0;await e.sleep(u!==void 0?Math.min(u,Ke):Ne);continue}throw o}}r(ne,"D");var Ve=new Set(["passed","review","processing","skipped"]);async function yt(e){let{artifacts:t}=e,n=t.clip,i=v(t.clipMime??"");if(t.degraded==="NO_RECORDER"||n===void 0||!qe.includes(i))return{kind:"unavailable",reason:"no_recorder"};e.client.armCapture?.(2);let s=Ge(e,t.keyframe),a=Be(e,n,i,s),c=Ze(e,s),d=!1,o=new Set,u=!0,l=0;for(;;){if(e.isCancelled())return{kind:"cancelled"};let p=e.getView();if(Me(p))return{kind:"settled"};let m=Y(p),T=m?.checkType,q=T==="liveness"&&!d?"liveness":T==="face_match"&&!o.has(m?.id)&&o.size<2&&u?"face_match":null;if(q===null)return{kind:"settled"};if(q==="liveness"&&t.captureChannel==="desktop")return{kind:"unavailable",reason:"mobile_required"};try{if(q==="liveness"){d=!0;let f=await a();if(e.isCancelled())return{kind:"cancelled"};Se(p,f)&&o.add(O(f)?.id);for(let ie of Z(p,f))o.add(ie);await e.applySubmit(f,"liveness");let _=$(e.getView(),"liveness")?.state;u=_===void 0||Ve.has(_)}else{o.add(m?.id);let f=await c();if(e.isCancelled())return{kind:"cancelled"};for(let _ of Z(p,f))o.add(_);await e.applySubmit(f,"face_match")}}catch(f){if(e.isCancelled()||f instanceof D)return{kind:"cancelled"};let _=Xe(f);if(_.kind!=="resync"||l>=ze)return _;l+=1,await e.refreshView()}}}r(yt,"Le");function Ge(e,t){let n=null,i=null,s=r(()=>n!==null?Promise.resolve(n):(i??(i=(async()=>{let a=await ee(e.client,"image",Q,t.size,te(e.artifacts));return await e.client.uploadToSpaces(a.uploadUrl,t,Q),n=(await e.client.completeMedia(a.key)).key,e.onKeyframePromoted?.(n),n})().finally(()=>{i=null})),i),"r");return{ensure:s,attempt:r(()=>s().catch(()=>null),"attempt"),current:r(()=>n,"current")}}r(Ge,"ge");function Be(e,t,n,i){let s=e.clipKeys?.get()??null,a,c=null,d=0,o;return()=>ne(e,async(u,l)=>{if(s===null||a===void 0){if(e.isCancelled())throw new D;a===void 0&&!Le(e.getView())&&(a=null),e.onPhase("uploading");let[p,m]=await Promise.all([s!==null?Promise.resolve(s):(async()=>{let T=await ee(u,"clip",n,t.size,te(e.artifacts));return await u.uploadToSpaces(T.uploadUrl,t,n),(await u.completeMedia(T.key)).key})(),a!==void 0?Promise.resolve(a===null?null:a.imageKey):i.attempt()]);s=p,e.clipKeys?.set(p),a===void 0&&(a=m===null?null:{imageKey:m})}if(c===null){let p=performance.now();try{c=await e.getAttestation(),o=e.attestationError?.()}catch(m){throw m instanceof A?m:new A(m instanceof Error?m.message:String(m))}d=Math.round(performance.now()-p)}return e.onPhase("checking"),u.submitCheck("liveness",{clipKey:s,attestation:c,captureChannel:e.artifacts.captureChannel,capture:{...Qe(e.artifacts),attestationMs:d,attestationError:o,...We(e.attestationFacts?.())},...a!==null?{faceMatch:a}:{}},{idempotencyKey:l})},{onAttestationInvalid:r(()=>{c=null},"onAttestationInvalid")})}r(Be,"ye");function Ze(e,t){return()=>ne(e,async(n,i)=>{if(t.current()===null){if(e.isCancelled())throw new D;e.onPhase("uploading")}let s=await t.ensure();return e.onPhase("checking"),n.submitCheck("face_match",{imageKey:s},{idempotencyKey:i})})}r(Ze,"Se");function Qe(e){let t={width:e.width,height:e.height};for(let n of Ye)e[n]!==void 0&&(t[n]=e[n]);return t}r(Qe,"Re");var Ye=["engine","facingMode","mode","formFactor","clipMs","clipFrames","fps","clipRetakes","codec","cameraReadyMs","faceAcquireMs","captureMs","screenRamp","provenance"];function We(e){return e===void 0?{}:{attestationChecks:e.checks,...e.challengeMs!==void 0?{attestationChallengeMs:e.challengeMs}:{}}}r(We,"be");function Xe(e){if(e instanceof A)return{kind:"unavailable",reason:"attestation"};if(e instanceof h){if(e.code==="attestation_invalid")return{kind:"unavailable",reason:"attestation"};if(e.code==="inference_unavailable")return{kind:"unavailable",reason:"inference_unavailable"};if(e.code==="mobile_required")return{kind:"unavailable",reason:"mobile_required"};if(De.has(e.code))return{kind:"resync"}}return{kind:"unavailable",reason:"network"}}r(Xe,"we");var _t="form_answers_invalid",S,vt=(S=class extends Error{constructor(t,n){super(`form answers refused (${t.map(i=>`${i.id}: ${i.code}`).join(", ")})`),this.name="FormAnswersError",this.issues=t,this.source=n}},r(S,"U"),S),I,gt=(I=class extends Error{constructor(t,n){super(`invalid ${t} (${n})`),this.name="InvalidInputError",this.field=t,this.kind=n}},r(I,"B"),I),C,bt=(C=class extends Error{constructor(t,n){super(`invalid ${t} (${n})`),this.name="OtpInputError",this.field=t,this.kind=n}},r(C,"$"),C);function z(e){return e?.source==="upload"?null:e?.source==="choice"&&e.sourcePick!=="camera"?"upload_or_phone":"phone"}r(z,"I");function kt(e,t){if(t===void 0||!j(t)||t.requiresMobile!==!0)return null;switch(t.checkType){case"liveness":return"phone";case"face_match":{if(t.reason!==void 0)return"phone";let n=$(e,"portrait_icao");return n?.state==="passed"||n?.state==="review"?null:"phone"}case"doc_ocr":return z(e.documents);case"poa":return z(e.proofOfAddress);case"portrait_icao":{let n=e.portrait;return n?.pendingFix!==void 0||n?.reuse?.pending===!0?null:z(n)}default:return null}}r(kt,"Be");function et(e){let t=e?.capture,n=t?.mode;return n==="assisted"||n==="self"||n==="choice"?n:t?.cameraSwitch===!0?"assisted":"self"}r(et,"Ce");function wt(e){let t=e?.capture?.pick;return et(e)==="choice"&&(t==="self"||t==="assisted")?t:null}r(wt,"Ye");function Mt(e,t,n=null){return e==="choice"?t??n??"self":e}r(Mt,"ze");var St={"JP:drivers_license":{normalize:"upper_no_space_or_hyphen",pattern:"^[0-9]{12}$",check:null,registrySources:[],describe:"number must be the 12-digit Japanese driving licence number"},"JP:residence_permit":{normalize:"upper_no_space_or_hyphen",pattern:"^[A-Z]{2}[0-9]{8}[A-Z]{2}$",check:null,registrySources:[],describe:"number must be the 12-character residence card number: two letters, eight digits, two letters"},"MR:drivers_license":{normalize:"upper_no_space_or_hyphen",pattern:"^[0-9]{8}$",check:null,registrySources:[],describe:"number must be the 8-digit Mauritanian driver's license number"},"MR:national_id":{normalize:"trim",pattern:"^[0-9]{10}$",check:"mr_nni_mod97",registrySources:["MR.anrpts"],describe:"number must be the 10-digit Mauritanian national ID number with a valid check digit"}};export{h as a,v as b,st as c,rt as d,at as e,ut as f,lt as g,pt as h,be as i,y as j,F as k,ke as l,ht as m,j as n,Me as o,Y as p,$ as q,x as r,E as s,mt as t,Te as u,ee as v,qe as w,Ue as x,ft as y,Je as z,ne as A,yt as B,Qe as C,_t as D,vt as E,gt as F,bt as G,kt as H,et as I,wt as J,Mt as K,St as L};
1
+ import{b as L}from"./chunk-RVPBL3KC.js";import{a as J,c as R}from"./chunk-RCDZUOGM.js";import{b as U}from"./chunk-6MYG4HWP.js";import{a as r}from"./chunk-4FHWXBOB.js";var g,h=(g=class extends Error{constructor(t){super(t.message),this.name="HostedApiError",this.status=t.status,this.code=t.code,t.retryAfterSeconds!==void 0&&(this.retryAfterSeconds=t.retryAfterSeconds),t.details&&(this.details=t.details)}},r(g,"u"),g);function H(e,t,n=Math.random){let i=(e??t)*1e3,s=Math.min(Math.max(i,500),2e4),a=Math.round(s*(1+(n()*2-1)*.25));return Math.min(Math.max(a,500),2e4)}r(H,"T");var V=6e4,N=4,se=3e4,re=9e5,ae=200,oe=5,ce=400,de=new Set(["server_busy","request_timeout"]),ue=20,le=60,pe=600,he=2;function v(e){return(e.split(";")[0]??"").trim()}r(v,"l");var me={liveness:"clipKey",face_match:"imageKey",doc_ocr:"imageKey"},fe=`@sekyro/web/${J}`,ye=fe,b,st=(b=class{constructor(t){this.sessionId=null,this.bootstrap=null,this.captureNonces=[],this.captureFetch=null,this.reportedIssues=new Map,this.issueReports=0,this.issuesPausedUntil=0,this.apiOrigin=t.apiOrigin.replace(/\/+$/,""),this.sessionToken=t.sessionToken;let n=t.fetch;this.fetchImpl=(i,s)=>(n??globalThis.fetch).call(globalThis,i,s),this.requestTimeoutMs=t.requestTimeoutMs??se,this.retryAttempts=t.inProgressRetry?.attempts??oe,this.retryDelayMs=t.inProgressRetry?.delayMs??ce,this.random=t.random??Math.random,this.clientLocale=t.locale}async getSession(){let t=await this.api("GET","/hosted/session");return this.sessionId=t.sessionId,t}async recordConsent(t){let n=await this.api("POST","/hosted/consent",{body:{locale:t},busyRetry:!0}),i=this.captureHold;return this.captureHold=void 0,i&&this.armCapture(i),n}async reportCameraUnavailable(t){return this.api("POST","/hosted/camera-unavailable",{body:{cause:t}})}async testerGate(t){return this.api("POST","/hosted/tester-gate",{body:{input:t}})}async reportCaptureIssue(t){let n=typeof t.name=="string"?t.name.replace(/[^A-Za-z]/g,"").slice(0,40):"",i=typeof t.engineKind=="string"&&/^[a-z_]{1,32}$/.test(t.engineKind)?t.engineKind:void 0,s=typeof t.attempt=="number"&&Number.isInteger(t.attempt)&&t.attempt>=0&&t.attempt<=1e3?t.attempt:void 0,a=t.check==="attestation"?s??"":"",c=[t.check,a,t.kind,n,t.phase??"",i??""].join("|"),d=this.reportedIssues.get(c);if(d!==void 0)return d;if(Date.now()<this.issuesPausedUntil||this.issueReports>=ue)return;let o={check:t.check,kind:t.kind,...n!==""?{name:n}:{},...t.phase!==void 0?{phase:t.phase}:{},...i!==void 0?{engineKind:i}:{},...s!==void 0?{attempt:s}:{},...t.formFactor!==void 0?{formFactor:t.formFactor}:{},...typeof t.detail=="string"&&/^\d{1,10}$/.test(t.detail)?{detail:t.detail}:{},...G(t.challengeMs)?{challengeMs:t.challengeMs}:{},...G(t.readyMs)?{readyMs:t.readyMs}:{},...t.inApp===!0?{inApp:!0}:{}};this.issueReports+=1;let u=this.api("POST","/hosted/capture-issue",{body:o,empty:!0}).catch(l=>{if(l instanceof h&&l.status===429){let p=Math.min(Math.max(l.retryAfterSeconds??le,0),pe);this.issuesPausedUntil=Math.max(this.issuesPausedUntil,Date.now()+p*1e3);return}(!(l instanceof h)||l.status===0||l.status>=500)&&this.reportedIssues.delete(c)});return this.reportedIssues.set(c,u),u}async choose(t,n){let i=await this.api("POST","/hosted/choice",{body:{nodeId:t,option:n},busyRetry:!0});return this.sessionId=i.sessionId,i}async confirmIdentity(t){return this.api("POST","/hosted/identity/confirm",{body:{decision:t}})}async identityPortrait(){return this.api("GET","/hosted/identity/portrait",{blob:!0})}async presign(t,n,i,s={}){let a=await this.ensureSessionId(),c={kind:t,contentType:v(n),contentLength:i,...s.source==="upload"?{source:"upload"}:{}};return this.api("POST",`/sessions/${a}/media`,{body:c})}armCapture(t=2){let n=Date.now();this.captureNonces.filter(i=>i.expiresAt-V>n).length>=t||(this.captureHold===void 0?this.fillCaptureNonces(t,t):this.captureHold=Math.max(this.captureHold,t))}async armRamp(){try{let t=await this.ensureSessionId(),n=await this.api("POST",`/sessions/${t}/media/capture-nonces`,{body:{count:2,ramp:!0}}),i=Date.now(),s=L(n.screenRamp)?n.screenRamp:void 0,a=i+Math.max(0,n.expiresIn)*1e3;for(let d of Array.isArray(n.nonces)?n.nonces:[])typeof d!="string"||d.length===0||this.captureNonces.push({nonce:d,expiresAt:a,...s!==void 0?{arm:s.nonce}:{}});this.captureNonces=this.captureNonces.slice(-N),this.captureHold=void 0;let c=typeof n.rampExpiresIn=="number"&&n.rampExpiresIn>0?n.rampExpiresIn:0;return{...s!==void 0?{challenge:s}:{},expiresAt:i+c*1e3}}catch{return}}async presignCapture(t,n,i,s={}){let a=await this.ensureSessionId(),c=await this.takeCaptureNonce(s.arm),d=c===void 0?void 0:{nonce:c,...s.engine!==void 0?{engine:s.engine.slice(0,32)}:{},...s.durationMs!==void 0&&Number.isFinite(s.durationMs)?{captureMs:Math.min(36e5,Math.max(0,Math.round(s.durationMs)))}:{}},o={kind:t,contentType:v(n),contentLength:i,capture:d};return this.api("POST",`/sessions/${a}/media`,{body:o})}async takeCaptureNonce(t){let n=r(()=>{let i=Date.now();this.captureNonces=this.captureNonces.filter(a=>a.expiresAt-V>i);let s=this.captureNonces.findIndex(a=>a.arm===t);return this.captureNonces.splice(s<0?0:s,1)[0]?.nonce},"n");for(let i=0;i<2;i++){let s=n();if(s!==void 0)return s;await this.fillCaptureNonces(1)}return n()}fillCaptureNonces(t,n=0){return this.captureFetch??(this.captureFetch=(async()=>{try{let i=await this.ensureSessionId(),s=await this.api("POST",`/sessions/${i}/media/capture-nonces`,{body:{count:Math.min(N,Math.max(1,t))}}),a=Date.now()+Math.max(0,s.expiresIn)*1e3;for(let c of Array.isArray(s.nonces)?s.nonces:[])typeof c=="string"&&c.length>0&&this.captureNonces.push({nonce:c,expiresAt:a});this.captureNonces=this.captureNonces.slice(-N),this.captureHold=void 0}catch(i){i instanceof h&&i.code==="consent_required"&&(this.captureHold=Math.max(this.captureHold??0,n))}})().finally(()=>{this.captureFetch=null})),this.captureFetch}async uploadToSpaces(t,n,i){let s;try{s=await this.fetchImpl(t,{method:"PUT",headers:{"content-type":v(i)},body:n,signal:AbortSignal.timeout(re)})}catch(a){throw K(a)}if(!s.ok){let a=(await s.text().catch(()=>"")).slice(0,ae);throw new h({status:s.status,code:"upload_failed",message:`media upload failed (HTTP ${s.status})${a?`: ${a}`:""}`})}}async completeMedia(t){let n=await this.ensureSessionId();return this.api("POST",`/sessions/${n}/media/complete`,{body:{key:t}})}async submitCheck(t,n,i={}){let s=await this.ensureSessionId(),a={input:n,forceOutcome:i.forceOutcome};return this.api("POST",`/sessions/${s}/checks/${t}`,{body:a,idempotencyKey:i.idempotencyKey,...i.browserCheckToken!==void 0?{browserCheckToken:i.browserCheckToken}:{},busyRetry:i.idempotencyKey!==void 0})}async uploadAndSubmit(t,n,i,s={}){let a=v(n.contentType),c=await this.presign(n.kind,a,n.blob.size);await this.uploadToSpaces(c.uploadUrl,n.blob,a);let d=await this.completeMedia(c.key),o={...i,[me[t]]:d.key};return this.submitCheck(t,o,s)}async ensureSessionId(){return this.sessionId!==null?this.sessionId:(this.bootstrap??(this.bootstrap=this.getSession().finally(()=>{this.bootstrap=null})),(await this.bootstrap).sessionId)}async api(t,n,i={}){let s=t==="GET"||i.busyRetry===!0,a=`${this.apiOrigin}/api/v2${n}`,c={"x-session-token":this.sessionToken,"x-sekyro-sdk":ye};i.body!==void 0&&(c["content-type"]="application/json"),i.idempotencyKey!==void 0&&(c["x-idempotency-key"]=i.idempotencyKey),i.browserCheckToken!==void 0&&(c["sekyro-browser-check"]=i.browserCheckToken),this.clientLocale!==void 0&&(c["sekyro-client-locale"]=this.clientLocale);try{let d=R.timezone();d!==void 0&&(c["sekyro-client-timezone"]=d)}catch{}c["sekyro-client-form-factor"]=U();try{let d=await R.deviceHeader();d!==void 0&&(c["sekyro-client-device"]=d)}catch{}for(let d=0;;d++){let o;try{o=await this.fetchImpl(a,{method:t,headers:c,...i.body!==void 0?{body:JSON.stringify(i.body)}:{},cache:"no-store",signal:AbortSignal.timeout(this.requestTimeoutMs)})}catch(l){throw K(l)}if(o.ok){if(i.empty===!0)return;if(i.blob===!0)try{return await o.blob()}catch(p){throw K(p)}let l;try{l=await o.json()}catch{throw new h({status:o.status,code:"unknown_error",message:`response body was not valid JSON (HTTP ${o.status})`})}return _e(l)}let u=await ve(o);if(u.code==="idempotency_in_progress"&&d<this.retryAttempts){this.retryDelayMs>0&&await B(this.retryDelayMs);continue}if(s&&u.status===503&&de.has(u.code)){s=!1,await B(H(u.retryAfterSeconds,he,this.random));continue}throw u}}},r(b,"S"),b);function G(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0&&e<=6e5}r(G,"k");function K(e){if((typeof e=="object"&&e!==null?e.name:void 0)==="TimeoutError")return new h({status:0,code:"timeout",message:"request timed out"});let t=e instanceof Error?e.message:String(e);return new h({status:0,code:"network_error",message:`network request failed: ${t}`})}r(K,"f");function _e(e){return e!==null&&typeof e=="object"&&"success"in e&&"data"in e?e.data:e}r(_e,"L");async function ve(e){let t="unknown_error",n=`request failed (HTTP ${e.status})`,i=Number.NaN,s;try{let d=await e.json();if(d!==null&&typeof d=="object"){let o=d;typeof o.code=="string"&&o.code.length>0&&(t=o.code),typeof o.message=="string"&&o.message.length>0&&(n=o.message),typeof o.retryAfterSeconds=="number"&&(i=o.retryAfterSeconds),Array.isArray(o.details?.issues)?s=o.details:Array.isArray(o.details?.errors)&&(s={...o.details,issues:[]})}}catch{}let a=e.headers.get("retry-after"),c=a===null?Math.floor(i):Number.parseInt(a,10);return new h({status:e.status,code:t,message:n,...Number.isFinite(c)&&c>=0?{retryAfterSeconds:c}:{},details:s})}r(ve,"V");function B(e){return new Promise(t=>setTimeout(t,e))}r(B,"R");function rt(e){let t=e?.portrait,n=t?.icao,i=t?.purpose==="id_document";return n==null?i?{policy:"reject",profile:"id_document"}:null:{policy:n.policy==="alert"?"alert":"reject",profile:i||n.profile==="id_document"?"id_document":"selfie"}}r(rt,"J");function at(e){return{...e.baselineEyeOpenness!==void 0?{baselineEyeOpenness:e.baselineEyeOpenness}:{},...e.baselineEyeOpennessLeft!==void 0&&e.baselineEyeOpennessRight!==void 0?{baselineEyeOpennessLeft:e.baselineEyeOpennessLeft,baselineEyeOpennessRight:e.baselineEyeOpennessRight}:{},criteria:e.verdict??{},...e.backgroundCheck!==void 0?{backgroundCheck:e.backgroundCheck}:{}}}r(at,"Q");var ge=new Set(["nni_unbound","id_number_unbound","method_required","mobile_required","portrait_required"]);function ut(e){return ge.has(e)}r(ut,"ve");function lt(e,t,n){let i=t.detail;return{check:e,kind:t.kind,...i?.name!==void 0?{name:i.name}:{},...i?.phase!==void 0?{phase:i.phase}:{},...i?.engineKind!==void 0?{engineKind:i.engineKind}:{},attempt:Math.max(0,Math.min(1e3,n))}}r(lt,"Pe");function pt(){let e=-1,t="";return{note(n){n==="starting"&&t!=="starting"&&(e+=1),t=n},newHandle(){t=""},noteError(){e<0&&(e=0)},get value(){return e}}}r(pt,"xe");var be={document:"document_photo",nfc:"document_chip",population_registry:"national_number",national_eid:"national_eid"};function y(e){return e.plan?.steps??[]}r(y,"f");function F(e){return Math.max(0,e.attempts.max-e.attempts.used)}r(F,"x");function ke(e){let t=e.plan?.choice;return t!==void 0&&e.plan?.current===t.nodeId?t:null}r(ke,"J");function ht(e){let t=ke(e);if(t?.kind!=="identity_method")return null;let n=t.options.map(s=>be[s.service]).filter(s=>s!==void 0),i=t.options.find(s=>s.nationalEid)?.nationalEid;return i?{available:!0,selected:null,options:n,nationalEid:i}:{available:!0,selected:null,options:n}}r(ht,"Ve");var we=new Set(["liveness","face_match"]);function j(e){return e!==void 0&&(e.state==="pending"||e.state==="input_required")}r(j,"R");function Me(e){return e.status!=="created"&&e.status!=="in_progress"}r(Me,"T");function Y(e){let t=e.plan?.current,n=t==null?void 0:y(e).find(i=>i.id===t);return j(n)?n:void 0}r(Y,"M");function $(e,t){return y(e).find(n=>n.checkType===t)}r($,"_");function O(e){let t=y(e),n=t.findIndex(i=>i.checkType==="liveness");return t.find((i,s)=>s>n&&i.checkType==="face_match")}r(O,"S");function Se(e,t){let n=$(t,"liveness")?.state,i=O(t)?.state;return(O(e)?.state??"pending")==="pending"&&(n==="passed"||n==="review")&&i!==void 0&&i!=="pending"&&i!=="skipped"}r(Se,"F");function Z(e,t){let n=new Map(y(e).map(i=>[i.id,i.state]));return y(t).filter(i=>i.checkType==="face_match"&&(n.get(i.id)??"pending")==="pending"&&i.state!=="pending"&&i.state!=="skipped").map(i=>i.id)}r(Z,"V");var Ie=/^[0-9a-f]{24}$/i;function x(e){return Ie.test(e)?`ses_${e}`:e}r(x,"k");function E(e,t){let n=x(e);return t===void 0?{sessionId:n,status:"unavailable"}:{sessionId:n,status:"unavailable",reasonCode:t}}r(E,"C");function W(e,t,n){let i=x(e);return n===void 0?{sessionId:i,status:t}:{sessionId:i,status:t,reasonCode:n}}r(W,"O");function mt(e,t){let n=Ae(e,t),i=Te(e);return i!==void 0&&(n.sandbox={simulated:!0,reason:i}),n}r(mt,"Ee");var Ce=new Set(["no_testers","tester_gate_not_used","tester_gate_missed"]);function Te(e){if(e.sandbox!==!0)return;let t=e.simulation?.reason;return Ce.has(t)?t:void 0}r(Te,"Z");function Ae(e,t){let n=x(e.sessionId);switch(e.status){case"created":case"in_progress":return $e(e,t);case"verified":return P(e,{sessionId:n,status:"verified"});case"review_pending":return P(e,W(n,"review",X(e,"review")));case"not_verified":return P(e,Ee(e));default:return P(e,{sessionId:n,status:"not_verified"})}}r(Ae,"Q");var xe=new Set([0,1,2,3]);function P(e,t){return xe.has(e.level)&&(t.level=e.level),typeof e.assurance=="string"&&e.assurance.length>0&&(t.assurance=e.assurance),t}r(P,"v");function Ee(e){let t={sessionId:x(e.sessionId),status:"not_verified"};return e.reason!==void 0&&(t.reason=e.reason),e.reasonCode!==void 0&&(t.reasonCode=e.reasonCode),e.reasonCode==="device_cooldown"&&e.retryAfter!==void 0&&(t.retryAfter=e.retryAfter),t}r(Ee,"ne");function Pe(e){return e==="rejected"?"rejected":e==="unavailable"?"unavailable":"inconclusive"}r(Pe,"te");function Oe(e,t){if(t===void 0)return!1;let n=y(t).find(i=>i.id===e.id);return n!==void 0&&n.attempts.used===e.attempts.used}r(Oe,"ie");function $e(e,t){let n=x(e.sessionId),i=y(e).find(a=>we.has(a.checkType)&&a.state==="input_required"&&a.reason!==void 0);if(i?.reason==="mobile_required")return E(n,"mobile_required");if(i?.reason!==void 0){if(i.result==="unavailable")return E(n,i.reason);let a=t.autoRetry&&(F(i)>0||Oe(i,t.previous))?{sessionId:n,status:"retry",reasonCode:i.reason,attemptsRemaining:F(i)}:{sessionId:n,status:"not_verified",reason:Pe(i.result),reasonCode:i.reason,attemptsRemaining:F(i)};return i.retakeHint!==void 0&&(a.retakeHint=i.retakeHint),a}let s=Y(e);return s===void 0&&y(e).some(a=>a.state==="review")?W(n,"review",X(e,"review")):s?.checkType==="portrait_icao"?E(n,"portrait_required"):E(n)}r($e,"re");function X(e,t){return y(e).find(n=>n.state===t&&n.reason!==void 0)?.reason}r(X,"L");function ee(e,t,n,i,s){return e.presignCapture!==void 0?e.presignCapture(t,n,i,s):e.presign(t,n,i)}r(ee,"K");function te(e){return{engine:e?.engine,durationMs:e?.clipMs,arm:e?.screenRamp?.nonce}}r(te,"q");var qe=["video/webm","video/mp4"],Q="image/jpeg",Re=2,Ne=1e3,Ke=1e4,He=3,Fe=10,ze=3,je=new Set(["network_error","timeout","upload_failed","unknown_error","rate_limit_exceeded"]),De=new Set(["session_not_active","check_not_found","check_already_finalized","check_out_of_order","identity_confirm_required","check_not_active","step_not_on_path","native_app_required"]),k,D=(k=class extends Error{constructor(){super("verification destroyed"),this.name="FlowCancelledError"}},r(k,"b"),k);function Le(e){let t=O(e);return $(e,"portrait_icao")?.state!=="pending"&&(t!==void 0?j(t):e.capture?.livePhoto?.oneCapture===!0)}r(Le,"me");var w,A=(w=class extends Error{constructor(t){super(t),this.name="AttestationError"}},r(w,"h"),w),M,Ue=(M=class extends A{constructor(t){super(`no attestation token: ${t}`),this.name="AttestationUnavailableError",this.code=t}},r(M,"E"),M);function ft(e){return new h({status:400,code:"attestation_invalid",message:`browser check: ${e}`,details:{issues:[],browserCheck:e}})}r(ft,"Oe");function Je(e){if(!(e instanceof h)||e.code!=="attestation_invalid")return;let t=e.details?.browserCheck;return typeof t=="string"?t:void 0}r(Je,"he");async function ne(e,t,n={}){let i=e.uuid(),s=!1,a=!1,c=0,d=0;for(;;)try{return await t(e.client,i)}catch(o){if(o instanceof A){if(a||o instanceof Ue)throw o;a=!0,n.onAttestationInvalid?.(),i=e.uuid();continue}if(!(o instanceof h))throw o;if(o.code==="consent_required"&&!s){s=!0,await e.ensureConsent({force:!0}),i=e.uuid();continue}if(o.code==="attestation_invalid"&&!a&&Je(o)===void 0){a=!0,n.onAttestationInvalid?.(),i=e.uuid();continue}if(o.code==="inference_unavailable"&&d<He){d+=1;let u=H(o.retryAfterSeconds,Fe,e.random??Math.random);e.onBusy?.({attempt:d,retryAfterSeconds:u/1e3}),await e.sleep(u),n.onAttestationInvalid?.(),i=e.uuid();continue}if(je.has(o.code)&&c<Re){c+=1;let u=o.retryAfterSeconds!==void 0?o.retryAfterSeconds*1e3:void 0;await e.sleep(u!==void 0?Math.min(u,Ke):Ne);continue}throw o}}r(ne,"D");var Ve=new Set(["passed","review","processing","skipped"]);async function yt(e){let{artifacts:t}=e,n=t.clip,i=v(t.clipMime??"");if(t.degraded==="NO_RECORDER"||n===void 0||!qe.includes(i))return{kind:"unavailable",reason:"no_recorder"};e.client.armCapture?.(2);let s=Ge(e,t.keyframe),a=Be(e,n,i,s),c=Ze(e,s),d=!1,o=new Set,u=!0,l=0;for(;;){if(e.isCancelled())return{kind:"cancelled"};let p=e.getView();if(Me(p))return{kind:"settled"};let m=Y(p),T=m?.checkType,q=T==="liveness"&&!d?"liveness":T==="face_match"&&!o.has(m?.id)&&o.size<2&&u?"face_match":null;if(q===null)return{kind:"settled"};if(q==="liveness"&&t.captureChannel==="desktop")return{kind:"unavailable",reason:"mobile_required"};try{if(q==="liveness"){d=!0;let f=await a();if(e.isCancelled())return{kind:"cancelled"};Se(p,f)&&o.add(O(f)?.id);for(let ie of Z(p,f))o.add(ie);await e.applySubmit(f,"liveness");let _=$(e.getView(),"liveness")?.state;u=_===void 0||Ve.has(_)}else{o.add(m?.id);let f=await c();if(e.isCancelled())return{kind:"cancelled"};for(let _ of Z(p,f))o.add(_);await e.applySubmit(f,"face_match")}}catch(f){if(e.isCancelled()||f instanceof D)return{kind:"cancelled"};let _=Xe(f);if(_.kind!=="resync"||l>=ze)return _;l+=1,await e.refreshView()}}}r(yt,"Le");function Ge(e,t){let n=null,i=null,s=r(()=>n!==null?Promise.resolve(n):(i??(i=(async()=>{let a=await ee(e.client,"image",Q,t.size,te(e.artifacts));return await e.client.uploadToSpaces(a.uploadUrl,t,Q),n=(await e.client.completeMedia(a.key)).key,e.onKeyframePromoted?.(n),n})().finally(()=>{i=null})),i),"r");return{ensure:s,attempt:r(()=>s().catch(()=>null),"attempt"),current:r(()=>n,"current")}}r(Ge,"ge");function Be(e,t,n,i){let s=e.clipKeys?.get()??null,a,c=null,d=0,o;return()=>ne(e,async(u,l)=>{if(s===null||a===void 0){if(e.isCancelled())throw new D;a===void 0&&!Le(e.getView())&&(a=null),e.onPhase("uploading");let[p,m]=await Promise.all([s!==null?Promise.resolve(s):(async()=>{let T=await ee(u,"clip",n,t.size,te(e.artifacts));return await u.uploadToSpaces(T.uploadUrl,t,n),(await u.completeMedia(T.key)).key})(),a!==void 0?Promise.resolve(a===null?null:a.imageKey):i.attempt()]);s=p,e.clipKeys?.set(p),a===void 0&&(a=m===null?null:{imageKey:m})}if(c===null){let p=performance.now();try{c=await e.getAttestation(),o=e.attestationError?.()}catch(m){throw m instanceof A?m:new A(m instanceof Error?m.message:String(m))}d=Math.round(performance.now()-p)}return e.onPhase("checking"),u.submitCheck("liveness",{clipKey:s,attestation:c,captureChannel:e.artifacts.captureChannel,capture:{...Qe(e.artifacts),attestationMs:d,attestationError:o,...We(e.attestationFacts?.())},...a!==null?{faceMatch:a}:{}},{idempotencyKey:l})},{onAttestationInvalid:r(()=>{c=null},"onAttestationInvalid")})}r(Be,"ye");function Ze(e,t){return()=>ne(e,async(n,i)=>{if(t.current()===null){if(e.isCancelled())throw new D;e.onPhase("uploading")}let s=await t.ensure();return e.onPhase("checking"),n.submitCheck("face_match",{imageKey:s},{idempotencyKey:i})})}r(Ze,"Se");function Qe(e){let t={width:e.width,height:e.height};for(let n of Ye)e[n]!==void 0&&(t[n]=e[n]);return t}r(Qe,"Re");var Ye=["engine","facingMode","mode","formFactor","clipMs","clipFrames","fps","clipRetakes","codec","cameraReadyMs","faceAcquireMs","captureMs","screenRamp","provenance"];function We(e){return e===void 0?{}:{attestationChecks:e.checks,...e.challengeMs!==void 0?{attestationChallengeMs:e.challengeMs}:{}}}r(We,"be");function Xe(e){if(e instanceof A)return{kind:"unavailable",reason:"attestation"};if(e instanceof h){if(e.code==="attestation_invalid")return{kind:"unavailable",reason:"attestation"};if(e.code==="inference_unavailable")return{kind:"unavailable",reason:"inference_unavailable"};if(e.code==="mobile_required")return{kind:"unavailable",reason:"mobile_required"};if(De.has(e.code))return{kind:"resync"}}return{kind:"unavailable",reason:"network"}}r(Xe,"we");var _t="form_answers_invalid",S,vt=(S=class extends Error{constructor(t,n){super(`form answers refused (${t.map(i=>`${i.id}: ${i.code}`).join(", ")})`),this.name="FormAnswersError",this.issues=t,this.source=n}},r(S,"U"),S),I,gt=(I=class extends Error{constructor(t,n){super(`invalid ${t} (${n})`),this.name="InvalidInputError",this.field=t,this.kind=n}},r(I,"B"),I),C,bt=(C=class extends Error{constructor(t,n){super(`invalid ${t} (${n})`),this.name="OtpInputError",this.field=t,this.kind=n}},r(C,"$"),C);function z(e){return e?.source==="upload"?null:e?.source==="choice"&&e.sourcePick!=="camera"?"upload_or_phone":"phone"}r(z,"I");function kt(e,t){if(t===void 0||!j(t)||t.requiresMobile!==!0)return null;switch(t.checkType){case"liveness":return"phone";case"face_match":{if(t.reason!==void 0)return"phone";let n=$(e,"portrait_icao");return n?.state==="passed"||n?.state==="review"?null:"phone"}case"doc_ocr":return z(e.documents);case"poa":return z(e.proofOfAddress);case"portrait_icao":{let n=e.portrait;return n?.pendingFix!==void 0||n?.reuse?.pending===!0?null:z(n)}default:return null}}r(kt,"Be");function et(e){let t=e?.capture,n=t?.mode;return n==="assisted"||n==="self"||n==="choice"?n:t?.cameraSwitch===!0?"assisted":"self"}r(et,"Ce");function wt(e){let t=e?.capture?.pick;return et(e)==="choice"&&(t==="self"||t==="assisted")?t:null}r(wt,"Ye");function Mt(e,t,n=null){return e==="choice"?t??n??"self":e}r(Mt,"ze");var St={"JP:drivers_license":{normalize:"upper_no_space_or_hyphen",pattern:"^[0-9]{12}$",check:null,registrySources:[],describe:"number must be the 12-digit Japanese driving licence number"},"JP:residence_permit":{normalize:"upper_no_space_or_hyphen",pattern:"^[A-Z]{2}[0-9]{8}[A-Z]{2}$",check:null,registrySources:[],describe:"number must be the 12-character residence card number: two letters, eight digits, two letters"},"MR:drivers_license":{normalize:"upper_no_space_or_hyphen",pattern:"^[0-9]{8}$",check:null,registrySources:[],describe:"number must be the 8-digit Mauritanian driver's license number"},"MR:national_id":{normalize:"trim",pattern:"^[0-9]{10}$",check:"mr_nni_mod97",registrySources:["MR.anrpts"],describe:"number must be the 10-digit Mauritanian national ID number with a valid check digit"}};export{h as a,v as b,st as c,rt as d,at as e,ut as f,lt as g,pt as h,be as i,y as j,F as k,ke as l,ht as m,j as n,Me as o,Y as p,$ as q,x as r,E as s,mt as t,Te as u,ee as v,qe as w,Ue as x,ft as y,Je as z,ne as A,yt as B,Qe as C,_t as D,vt as E,gt as F,bt as G,kt as H,et as I,wt as J,Mt as K,St as L};
@@ -1 +1 @@
1
- import{F as t,G as a,a as i}from"./chunk-67YJZR73.js";import{a as n}from"./chunk-5QL6W6FW.js";import{a as o}from"./chunk-4FHWXBOB.js";function d(r,c){if(r instanceof t)return r.field==="phone"?"otp.phoneInvalid":r.field==="code"?"otp.codeInvalid":r.kind==="check_digit"?"population.reason_id_number_invalid":"population.invalid";if(r instanceof a&&r.field==="channel")return"otp.reason_otp_channel_unavailable";if(r instanceof i){if(r.code==="attestation_invalid"&&r.details?.browserCheck==="clock_wrong")return"errors.device_clock";let e=`errors.${r.code}`;if(Object.hasOwn(c,e))return e}return"errors.network_error"}o(d,"d");n(d,"errorKey");export{d as a};
1
+ import{F as t,G as a,a as i}from"./chunk-4RREQCYP.js";import{a as n}from"./chunk-5QL6W6FW.js";import{a as o}from"./chunk-4FHWXBOB.js";function d(r,c){if(r instanceof t)return r.field==="phone"?"otp.phoneInvalid":r.field==="code"?"otp.codeInvalid":r.kind==="check_digit"?"population.reason_id_number_invalid":"population.invalid";if(r instanceof a&&r.field==="channel")return"otp.reason_otp_channel_unavailable";if(r instanceof i){if(r.code==="attestation_invalid"&&r.details?.browserCheck==="clock_wrong")return"errors.device_clock";let e=`errors.${r.code}`;if(Object.hasOwn(c,e))return e}return"errors.network_error"}o(d,"d");n(d,"errorKey");export{d as a};
@@ -1 +1 @@
1
- import{a as je,b as He,c as be,d as _e,f as Ge,g as Ye,h as $e,m as Je,q as Qe,r as Xe,t as Ke}from"./chunk-LSBUNQZU.js";import{a as Se,d as Ze,e as et}from"./chunk-F4Q2Q4OC.js";import{f as ne}from"./chunk-4QUL7TEF.js";import{e as Ie,k as Ve}from"./chunk-6MYG4HWP.js";import{g as Me}from"./chunk-JS2IXPNL.js";import{a}from"./chunk-4FHWXBOB.js";function tt(e,t){let r=new Set(e.flatMap(n=>n.sides.filter(l=>l[t]!==null).map(l=>l.side)));return r.size===1?[...r][0]:null}a(tt,"nt");function bt(e){let t=Ze.find(n=>n.docType===e),r=t.mrz==="none"?null:t.mrz==="td3"?"single":"verso";return{sides:t.sides,format:et(e),mrz:t.mrz==="none"?"none":"required",mrzSide:r,barcodeSide:null,portraitSide:t.portraitSide,scripts:null}}a(bt,"Bt");function St(e){let t=[];for(let r of e)for(let n of r.sides){if(!Array.isArray(n.scripts))return null;for(let l of n.scripts)t.includes(l)||t.push(l)}return t}a(St,"It");function kt(e,t){if(t.length===0)return bt(e);let r=t.some(d=>d.sides.length>1),n=new Set(t.map(d=>d.format)),l=n.size===1?[...n][0]:"card",c=t.filter(d=>d.sides.some(p=>p.mrz!==null)).length,u=t.find(d=>d.sides.length>1===r)?.sides.find(d=>d.portrait)?.side;return{sides:r?["recto","verso"]:["single"],format:l,mrz:c===t.length?"required":c===0?"none":"optional",mrzSide:tt(t,"mrz"),barcodeSide:tt(t,"barcode"),portraitSide:u??(r?"recto":"single"),scripts:St(t)}}a(kt,"rt");function xt(e,t){if(e===void 0)return[];let r=e.toUpperCase();return Object.prototype.hasOwnProperty.call(Se,r)?Se[r]?.[t]??[]:[]}a(xt,"ot");async function Tt(e,t,r){return await e(t)?r:r==="recto"?"verso":"recto"}a(Tt,"it");function Ct(e,t,r){return e!==t&&t==="verso"&&r.recto!==void 0&&r.verso===void 0?"verso":e}a(Ct,"at");var Rt={low:{maxLongEdge:1920,payloadTargetBytes:7e5,qMin:.7,qMax:.92},mid:{maxLongEdge:2240,payloadTargetBytes:12e5,qMin:.7,qMax:.92},good:{maxLongEdge:2560,payloadTargetBytes:16e5,qMin:.7,qMax:.92}};function Lt(e){let{deviceMemory:t,effectiveType:r,saveData:n,downlinkMbps:l,sourceLongEdge:c}=e,u=n===!0||r==="slow-2g"||r==="2g"||l!=null&&l>0&&l<1,d=t!=null&&t<=2,p=r==="4g"||l!=null&&l>=5,b=t!=null&&t>=6,s;u||d?s="low":p&&b?s="good":s="mid";let x=Rt[s],v=c&&c>0?Math.min(x.maxLongEdge,c):x.maxLongEdge;return{tier:s,...x,maxLongEdge:v}}a(Lt,"Wt");function Pt(e){let t={};try{let r=navigator;typeof r.deviceMemory=="number"&&(t.deviceMemory=r.deviceMemory);let n=r.connection;n&&(t.effectiveType=n.effectiveType,t.saveData=n.saveData,t.downlinkMbps=n.downlink)}catch{}return typeof e=="number"&&e>0&&(t.sourceLongEdge=e),Lt(t)}a(Pt,"st");function At(e,t,r){let n=Math.min(1,Math.max(0,(e-.28)/.21999999999999997)),l=(t+r)/2;return Math.max(t,r-n*(r-l))}a(At,"Nt");function zt(e,t,r){let n=Math.max(e,t),l=n>0?Math.min(1,r/n):1;return{width:Math.max(1,Math.round(e*l)),height:Math.max(1,Math.round(t*l))}}a(zt,"zt");async function Dt(e,t){let r=t.startQ,n=await e(r);for(let l=0;l<4&&!(n.size<=t.budgetBytes||r<=t.qMin);l++)r=Math.max(t.qMin,r-.08),n=await e(r);return{blob:n,quality:r}}a(Dt,"Ut");async function Wt(e,t,r,n,l){if(t<=0||r<=0)return null;let{width:c,height:u}=zt(t,r,n.maxLongEdge),d=document.createElement("canvas");d.width=c,d.height=u;let p=d.getContext("2d");if(!p)return null;p.drawImage(e,0,0,c,u);let b=a(S=>new Promise((k,h)=>{d.toBlob(g=>g?k(g):h(new Error("canvas toBlob returned null")),"image/jpeg",S)}),"y"),s=At(l,n.qMin,n.qMax),{blob:x,quality:v}=await Dt(b,{startQ:s,qMin:n.qMin,budgetBytes:n.payloadTargetBytes}).finally(()=>{d.width=0,d.height=0});if(x.size>5242880)throw new Error("encoded document exceeds the 5242880-byte media cap");return{blob:x,quality:v,width:c,height:u}}a(Wt,"dt");async function qt(e){let t=Pt(Math.max(e.width,e.height)),r=await Wt(e,e.width,e.height,t,.5);if(r===null)throw new Error("canvas encode unavailable");return{blob:r.blob,width:r.width,height:r.height}}a(qt,"Me");function st(e,t,r={safetyNetMs:null,sideChangeMs:null}){return{layout:e,phase:"framing",captured:{},pending:[],lastCaptureAt:t,lastReportAt:t,manualShutter:!1,restPhase:"framing",readSides:[],needFlip:!1,flipped:!1,flipTimeoutSpent:!1,timeoutCapture:!1,lastShotByTimeout:!1,tuning:r,safetyNetSpent:!1,sideHits:0,turnSeen:!1}}a(st,"we");var Re=a(e=>e==="recto"?"verso":"recto","Ce"),lt=a(e=>e.phase==="framing"||e.phase==="locking"||e.phase==="flipCue"||e.phase==="reaskRecto","ct"),J=a(e=>(e.captured.recto!==void 0?1:0)+(e.captured.verso!==void 0?1:0)+e.pending.length,"Q");function ke(e,t){return e.lastCaptureAt>=0&&e.lastReportAt>=0?e:{...e,lastCaptureAt:e.lastCaptureAt<0?t:e.lastCaptureAt,lastReportAt:e.lastReportAt<0?t:e.lastReportAt}}a(ke,"De");function Ot(e){if(J(e)===1)return e.captured.recto!==void 0?"recto":e.captured.verso!==void 0?"verso":void 0}a(Ot,"Gt");function Et(e,t,r){if(e.phase==="result")return{...e,lastReportAt:r};let n=!t.present||e.captureArea!==void 0&&t.areaFrac<.6*e.captureArea,{flipped:l,awaySince:c}=e,u=e.sideSince,d=e.sideHits,p=Ot(e),b=e.tuning.sideChangeMs!==null&&e.needFlip&&p!==void 0,s=!1;b&&p==="recto"&&t.side==="verso"?(u=u??r,d+=1,s=d>=2&&r-u>=e.tuning.sideChangeMs,s&&(l=!0)):(!b||t.side!==void 0)&&(u=void 0,d=0),n&&(c=c??r),c!==void 0&&r-c>=250&&(l=!0,s=!0),n||(c=void 0);let x=b&&p==="verso"&&t.side==="verso";x&&(l=!1);let v=x?!1:e.turnSeen||s,S=e.flipTimeoutSpent&&!(l&&!e.flipped),k=e.notice==="same_face"&&l&&!e.flipped?void 0:e.notice,h=t.present&&t.steady!==!1&&!x,g=l&&!e.flipped||v&&!e.turnSeen,M=h?g?r:e.presentSince??r:void 0,D={...e,lastReportAt:r,flipped:l,awaySince:c,sideSince:u,sideHits:d,presentSince:M,turnSeen:v,flipTimeoutSpent:S,notice:k,lastArea:t.areaFrac};if(!lt(e))return D;let B=Bt(e,D,t,r,l,S),E=e.tuning.safetyNetMs;return E!==null&&e.layout==="twoSided"&&J(e)===1&&!e.safetyNetSpent&&v&&M!==void 0&&r-M>=E&&B.phase!=="capturing"?{...B,phase:"capturing",safetyNetSpent:!0,shotVia:"safety_net"}:B}a(Et,"Ht");function Bt(e,t,r,n,l,c){if(e.needFlip&&!l){if(!r.ready)return{...t,phase:e.restPhase,goodSince:void 0};let u=e.lastShot!==void 0&&e.pending.includes(e.lastShot);if(c||u)return{...t,goodSince:void 0,phase:e.restPhase};let d=e.goodSince??n;return n-d>=1800?{...t,goodSince:d,phase:"capturing",flipTimeoutSpent:!0,timeoutCapture:!0}:{...t,goodSince:d,phase:e.restPhase}}return r.ready?{...t,phase:"capturing",goodSince:e.goodSince??n}:{...t,goodSince:void 0,phase:r.locking?"locking":e.restPhase}}a(Bt,"Vt");function Ft(e,t){if(!lt(e)||e.manualShutter)return e;let r=t-e.lastReportAt>=2e3,n=t-e.lastCaptureAt>=6e3;return r||n?{...e,manualShutter:!0}:e}a(Ft,"qt");function Nt(e,t,r){let n=e.layout==="singlePage",l=n?{recto:t}:e.captured,c=n?[]:[...e.pending,t],u={...e,captured:l,pending:c,lastShot:t,lastCaptureAt:r,lastReportAt:-1,manualShutter:!1,goodSince:void 0,notice:void 0,awaySince:void 0,flipped:!1,lastShotByTimeout:e.timeoutCapture,timeoutCapture:!1,captureArea:e.lastArea,sideSince:void 0,sideHits:0,presentSince:void 0,turnSeen:!1,shotVia:void 0,lastShotVia:e.phase==="capturing"?e.timeoutCapture?"flip_timeout":e.shotVia??"ready":"manual"};return n||J({captured:l,pending:c})>=2?{...u,phase:"reading",restPhase:"framing",current:void 0,needFlip:!1}:{...u,phase:"flipCue",restPhase:"flipCue",current:void 0,needFlip:!0}}a(Nt,"Xt");function dt(e,t,r){return e.pending.includes(t)?{...e,pending:e.pending.filter(n=>n!==t),lastShot:e.lastShot===t?void 0:e.lastShot,phase:e.phase==="capturing"?e.phase:"flipCue",restPhase:"flipCue",current:Re(r),needFlip:!0,flipTimeoutSpent:!1,goodSince:void 0,manualShutter:!0,notice:"same_face",lastCaptureAt:-1,lastReportAt:-1,turnSeen:!1,presentSince:void 0}:e}a(dt,"lt");function Ut(e,t,r,n=!1){if(!e.pending.includes(t))return e;if(e.captured[r]!==void 0)return dt(e,t,r);let l=e.pending.filter(b=>b!==t),c={...e,pending:l,captured:{...e.captured,[r]:t}};if(J(c)!==1||e.layout==="singlePage")return c;if(n)return{...c,unsure:t,phase:"reading",restPhase:"flipCue",current:void 0,needFlip:!1};let u=Re(r),d=u==="recto"&&e.restPhase==="reaskRecto"?"reaskRecto":"flipCue",p=e.phase==="flipCue"||e.phase==="reaskRecto"||e.phase==="framing";return{...c,restPhase:d,current:u,phase:p?d:e.phase}}a(Ut,"Yt");function It(e,t,r){let n=e.captured.recto===t?"recto":e.captured.verso===t?"verso":void 0;if(n===void 0||n===r&&e.unsure!==t)return e;let l=Re(r),c={[r]:t};e.captured[l]!==void 0&&e.captured[l]!==t&&(c[l]=e.captured[l]);let u=[c.recto,c.verso,...e.pending],d={...e,captured:c,unsure:void 0,readSides:e.readSides.filter(p=>c[p]!==void 0&&c[p]===e.captured[p]),lastShot:e.lastShot!==void 0&&u.includes(e.lastShot)?e.lastShot:void 0};return e.layout==="singlePage"||J(d)!==1||e.phase!=="reading"&&e.phase!=="result"?d:{...d,phase:"flipCue",restPhase:"flipCue",current:l,needFlip:!0,flipped:!1,flipTimeoutSpent:!1,goodSince:void 0,awaySince:void 0,turnSeen:!1,safetyNetSpent:!1,presentSince:void 0,sideSince:void 0,sideHits:0,captureArea:e.lastArea,lastCaptureAt:-1,lastReportAt:-1,manualShutter:!1}}a(It,"Qt");function Vt(e,t){if(t.id!==void 0&&e.captured.recto!==t.id&&e.captured.verso!==t.id&&!e.pending.includes(t.id))return e;let r=t.id??e.captured[t.side],n={...e.captured};(t.id===void 0||n[t.side]===t.id)&&delete n[t.side];let l=e.pending.filter(b=>b!==r),c=e.layout==="twoSided"&&J({captured:n,pending:l})>0,u=e.lastShotByTimeout||r===e.lastShot!==e.flipped,d=c&&!u,p=d?t.side==="recto"?"reaskRecto":"flipCue":"framing";return{...e,captured:n,pending:l,readSides:e.readSides.filter(b=>b!==t.side),unsure:e.unsure===r?void 0:e.unsure,lastShot:e.lastShot===r?void 0:e.lastShot,notice:t.issue,goodSince:void 0,manualShutter:!1,phase:p,restPhase:p,current:t.side,needFlip:d,flipped:!1,flipTimeoutSpent:!1,awaySince:void 0,lastCaptureAt:-1,lastReportAt:-1,safetyNetSpent:!1,sideSince:void 0,sideHits:0,presentSince:void 0,turnSeen:c&&!d&&r===e.lastShot&&!e.flipped&&!e.lastShotByTimeout}}a(Vt,"jt");function jt(e,t){switch(t.type){case"report":return Et(ke(e,t.at),t.report,t.at);case"tick":return Ft(ke(e,t.at),t.at);case"captured":return Nt(ke(e,t.at),t.id,t.at);case"captureFailed":return{...e,phase:e.restPhase,goodSince:void 0,lastCaptureAt:t.at,manualShutter:!0,timeoutCapture:!1,shotVia:void 0,...e.shotVia==="safety_net"?{safetyNetSpent:!1,presentSince:void 0}:{}};case"classified":return Ut(e,t.id,t.side,t.unsure===!0);case"held":return It(e,t.id,t.side);case"duplicate":return dt(e,t.id,t.side);case"readOk":{let r=e.readSides.includes(t.side)?e.readSides:[...e.readSides,t.side],n=["recto","verso"].filter(c=>e.captured[c]!==void 0),l=e.phase==="reading"&&e.pending.length===0&&n.every(c=>r.includes(c));return{...e,readSides:r,flipTimeoutSpent:!1,phase:l?"result":e.phase}}case"readFailed":return Vt(e,t);case"clockRestart":return e.lastCaptureAt<0&&e.lastReportAt<0&&e.awaySince===void 0&&e.presentSince===void 0&&e.sideSince===void 0&&e.sideHits===0?e:{...e,awaySince:void 0,presentSince:void 0,sideSince:void 0,sideHits:0,lastCaptureAt:-1,lastReportAt:-1};case"retake":return{...st(e.layout,-1,e.tuning),lastCaptureAt:-1,lastReportAt:-1};default:return e}}a(jt,"ft");var xe=a((e,t,r)=>Math.min(r,Math.max(t,Math.round(e))),"ke"),se=a(e=>Math.round(Math.min(1,Math.max(0,e))*1e4)/1e4,"ae");async function Ht(e,t,r,n){let l=n.decode??(p=>createImageBitmap(p)),c=a(async()=>e.stillRead(await l(t),n.region??[0,0,1,1],n.detectorLimit),"c"),u;try{u=await c()}catch{try{await new Promise(p=>setTimeout(p,n.retryMs??300)),u=await c()}catch{return null}}let d=u.mrzBox;return d===void 0?null:{engine:n.engine,source:"live_mrz",format:r.format,lineCount:xe(r.lineCount,2,3),checkDigitsValid:!0,stillConfirmed:u.valid&&u.digest===r.digest,band:[se(d[0]),se(d[1]),se(Math.min(d[2],1-d[0])),se(Math.min(d[3],1-d[1]))],digest:r.digest,framesToValid:xe(r.framesToValid,1,1e3),msToValid:xe(r.msToValid,0,12e4)}}a(Ht,"mt");var _t=new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11]),Gt=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,7,1,5,0,6,64,11,11]);function Yt(e=globalThis){let t=e.WebAssembly?.validate;if(typeof t!="function")return{ok:!1,reason:"simd"};try{if(!t.call(e.WebAssembly,_t)||!t.call(e.WebAssembly,Gt))return{ok:!1,reason:"simd"}}catch{return{ok:!1,reason:"simd"}}return typeof e.Worker!="function"?{ok:!1,reason:"worker"}:typeof e.createImageBitmap!="function"?{ok:!1,reason:"bitmap"}:{ok:!0}}a(Yt,"pt");function $t(e=globalThis){let t=e.navigator?.connection;return t?.saveData===!0||["slow-2g","2g","3g"].includes(t?.effectiveType??"")}a($t,"gt");var $,N=($=class extends Error{constructor(t){super(t),this.name="OcrEngineError",this.code=t}},a($,"I"),$);function rt(){let e=a(t=>(t.close(),Promise.reject(new N("unsupported"))),"e");return{ready:Promise.resolve("unsupported"),busy:!1,bandRead:e,stillRead:e,layoutRead:e,dispose:a(()=>{},"dispose")}}a(rt,"St");function Jt(e){let t;try{if(e.createWorker)t=e.createWorker();else if(e.workerUrl!==void 0)t=new Worker(e.workerUrl,{type:"module",name:"sekyro-ocr"});else return rt()}catch{return rt()}let r=new Map,n=0,l=!1,c=!1,u=!1;t.addEventListener("message",h=>{let g=h.data,M=r.get(g.id);M&&(r.delete(g.id),M.resolve(g))});let d=a(()=>{for(let h of r.values())h.reject(new N("error"));r.clear(),b()},"d");t.addEventListener("error",d),t.addEventListener("messageerror",d);function p(h,g=[]){if(l)return Promise.reject(new N("disposed"));let M=++n;return new Promise((D,B)=>{r.set(M,{resolve:D,reject:B});try{t.postMessage({...h,id:M},g)}catch{r.delete(M),B(new N("error"))}})}a(p,"l");function b(){if(!l){l=!0;try{t.postMessage({id:++n,kind:"dispose"})}catch{}t.terminate();for(let h of r.values())h.reject(new N("disposed"));r.clear()}}a(b,"y");let s=(async()=>{let h=await p({kind:"init",baseUrl:e.baseUrl,salt:e.salt,detectorLimit:e.tuning.detectorLimit,maxDownloadMs:e.tuning.maxDownloadMs});if(h.kind==="failed")return h.reason;if(h.kind!=="ready")return"error";let g=await p({kind:"warmup"});if(g.kind!=="ready")return"error";let M=g.benchMs??g.warmupMs,D=e.deviceMemoryGb===void 0?He():e.deviceMemoryGb;return{warmupMs:g.warmupMs,downloadMs:h.downloadMs,cached:h.cached,benchMs:M,tier:je(M,D)}})().catch(()=>"error"),x,v=new Promise(h=>{x=setTimeout(()=>h("timeout"),e.tuning.loadTimeoutMs)}),S=Promise.race([s,v]).then(h=>(clearTimeout(x),typeof h=="string"?b():u=!0,l&&typeof h!="string"?"error":h));(e.page===void 0?globalThis.addEventListener?globalThis:null:e.page)?.addEventListener("pagehide",b,{once:!0});async function k(h,g,M){if(l)throw g.close(),new N("disposed");if(!u)throw g.close(),new N("not_ready");if(c)throw g.close(),new N("busy");c=!0;let D;try{let B=new Promise((K,V)=>{D=setTimeout(()=>{V(new N("timeout")),b()},e.tuning.readTimeoutMs??1e4)}),E=await Promise.race([p(h,[g]),B]);if(E.kind===M){let{id:K,...V}=E;return V}throw new N(E.kind==="error"?E.code:E.kind==="failed"?E.reason:"error")}finally{clearTimeout(D),c=!1}}return a(k,"P"),{ready:S,get busy(){return c},bandRead:a((h,g=e.tuning.detectorLimit,M)=>k({kind:"band",bitmap:h,detectorLimit:g,...M!==void 0?{expiredBefore:M}:{}},h,"band"),"bandRead"),stillRead:a((h,g,M=e.tuning.detectorLimit)=>k({kind:"still",bitmap:h,region:g,detectorLimit:M},h,"band"),"stillRead"),layoutRead:a((h,g)=>k({kind:"layout",bitmap:h,detectorLimit:g},h,"layout"),"layoutRead"),dispose:b}}a(Jt,"ht");var le="sekyro-ocr-1",Te=a(e=>e!==null&&typeof e=="object"?e:{},"Re"),O=a((e,t,r,n)=>typeof e=="number"&&Number.isFinite(e)&&e>=t&&e<=r?e:n,"B"),it=a((e,t)=>typeof e=="boolean"?e:t,"bt"),at=a(e=>{let t=typeof e=="string"?/^sekyro-ocr-(\d{1,4})$/.exec(e):null;return t?Number(t[1]):Number.POSITIVE_INFINITY},"yt");function Qt(e,t={}){let r=Te(e),n=Te(r.liveMrz),l=Te(r.frontLock),c=at(t.engine??le),u=t.mode==="off",d=n.enabled===!0,p=l.enabled===!0,b=a((h,g)=>!u&&g&&at(h.minEngine??le)<=c,"y"),s=Xe,x=b(n,d)?{detectorLimit:O(n.detectorLimit,320,1600,s.detectorLimit),bandMaxWidthPx:O(n.bandMaxWidthPx,320,4096,s.bandMaxWidthPx),minBandWidthPx:O(n.minBandWidthPx,0,4096,s.minBandWidthPx),bandTop:O(n.bandTop,0,.95,s.bandTop),minIntervalMs:O(n.minIntervalMs,0,5e3,s.minIntervalMs),stableReads:Math.round(O(n.stableReads,1,10,s.stableReads)),profileReads:Math.round(O(n.profileReads,1,100,s.profileReads)),maxReadMs:O(n.maxReadMs,50,6e4,s.maxReadMs),searchTimeoutMs:O(n.searchTimeoutMs,1e3,12e4,s.searchTimeoutMs),hint:it(n.hint,!0),stillConfirm:it(n.stillConfirm,!0)}:null,v=Qe,S=a((h,g,M)=>O(l[h],g,M,v[h]),"M"),k=b(l,p)?{minLines:Math.round(S("minLines",1,50)),fillMin:S("fillMin",0,1),fillMax:S("fillMax",0,2),offsetMax:S("offsetMax",0,1),steadyFillDelta:S("steadyFillDelta",0,1),steadyOffsetDelta:S("steadyOffsetDelta",0,1),layoutShiftMax:S("layoutShiftMax",0,1),lineCountDelta:Math.round(S("lineCountDelta",0,50)),lockMs:S("lockMs",0,3e4),steadyMs:S("steadyMs",0,3e4),minFrames:Math.round(S("minFrames",1,100)),minIntervalMs:S("minIntervalMs",0,5e3),maxWidthPx:S("maxWidthPx",160,2048),detectorLimit:S("detectorLimit",320,1600),searchTimeoutMs:S("searchTimeoutMs",1e3,12e4)}:null;return{enabled:x!==null||k!==null,liveMrz:x,textLock:k,liveMrzOn:d,frontLockOn:p,load:{detectorLimit:x?.detectorLimit??k?.detectorLimit??s.detectorLimit,loadTimeoutMs:O(n.loadTimeoutMs,1e3,12e4,2e4),maxDownloadMs:O(n.maxDownloadMs,1e3,12e4,2e4)},reportSampleRate:O(n.reportSampleRate,0,1,1)}}a(Qt,"Mt");function Xt(e,t){return e.enabled?!(t.probe??Yt)().ok||(t.slow??$t)()?{ok:!1,reason:"unsupported"}:{ok:!0,engine:Jt({baseUrl:t.baseUrl,salt:t.salt,tuning:{detectorLimit:e.load.detectorLimit,maxDownloadMs:e.load.maxDownloadMs,loadTimeoutMs:e.load.loadTimeoutMs},...t.workerUrl!==void 0?{workerUrl:t.workerUrl}:{},...t.createWorker!==void 0?{createWorker:t.createWorker}:{},...t.page!==void 0?{page:t.page}:{},...t.deviceMemoryGb!==void 0?{deviceMemoryGb:t.deviceMemoryGb}:{}})}:{ok:!1,reason:"off"}}a(Xt,"Dt");function Kt(e=typeof navigator<"u"?navigator.userAgent:""){return/SamsungBrowser\//.test(e)?"samsung":/Firefox\/|FxiOS\//.test(e)?"firefox":/Chrome\/|CriOS\/|Chromium\//.test(e)&&!/Edg\/|OPR\//.test(e)?"chrome":/Safari\//.test(e)&&/Version\/|Mobile\//.test(e)&&!/Chrome\/|CriOS\//.test(e)?"safari":"other"}a(Kt,"Jt");var I=a(e=>e===void 0||!Number.isFinite(e)?void 0:Math.min(6e5,Math.max(0,Math.round(e))),"G"),Ce=a((e,t,r)=>e===void 0||!Number.isFinite(e)?void 0:Math.min(r,Math.max(t,Math.round(e))),"xe");function Zt(e){let t=e.assist??null,r=e.load!==null&&e.load!==void 0&&typeof e.load=="object"?e.load:null,n=typeof e.load=="string"?e.load:null,l=t!==null?t.outcome:n==="unsupported"||n==="download"||n==="integrity"?n:n==="error"||n==="timeout"?"error":"off",c={kind:"live_mrz",platform:"web",engine:e.engine??le,capture:e.capture,outcome:l,reads:Ce(t?.reads??0,0,1e4)??0,browser:e.browser??Kt()},u=a((d,p)=>{p!==void 0&&(c[d]=p)},"u");return u("format",t?.format),u("framesToValid",Ce(t?.framesToValid,1,1e4)),u("msToValid",I(t?.msToValid)),u("framesToLock",Ce(t?.framesToLock,1,1e4)),u("msToLock",I(t?.msToLock)),u("msToCapture",I(e.msToCapture)),u("readP50Ms",I(t?.readP50Ms)),u("readP90Ms",I(t?.readP90Ms)),u("deviceClass",t?.deviceClass),r!==null&&(u("warmupMs",I(r.warmupMs)),u("downloadMs",I(r.downloadMs)),u("cached",r.cached),u("tier",r.tier),u("benchMs",I(r.benchMs))),u("stillConfirmed",e.stillConfirmed),u("typeMismatch",e.typeMismatch),c}a(Zt,"wt");function ot(e,t){return e===void 0?!1:t==="passport"?e!=="TD3":e==="TD3"}a(ot,"Te");var er=2,tr=1500,rr=2500;async function ir(e){let t=await import("./capture-session-doc-HZJLTWTY-XAP4ZT6R.js");return new t.CaptureSessionDoc(e)}a(ir,"nn");function ar(e){return{topLeft:{x:e.x,y:e.y},topRight:{x:e.x+e.width,y:e.y},bottomRight:{x:e.x+e.width,y:e.y+e.height},bottomLeft:{x:e.x,y:e.y+e.height}}}a(ar,"rn");function nt(e){let t=[e.topLeft.x,e.topRight.x,e.bottomRight.x,e.bottomLeft.x],r=[e.topLeft.y,e.topRight.y,e.bottomRight.y,e.bottomLeft.y],n=Math.min(...t),l=Math.min(...r);return{x:n,y:l,width:Math.max(...t)-n,height:Math.max(...r)-l}}a(nt,"Ct");function or(e,t,r){let n=[e.topLeft,e.topRight,e.bottomRight,e.bottomLeft],l=0;for(let c=0;c<n.length;c+=1){let u=n[c],d=n[(c+1)%n.length];l+=u.x*d.y-d.x*u.y}return t>0&&r>0?Math.abs(l)/2/(t*r):0}a(or,"on");function X(e){return e.startsWith("shot-")?Number(e.slice(5)):0}a(X,"J");function mr(){import("./capture-session-doc-HZJLTWTY-XAP4ZT6R.js").then(e=>e.warmDocDetector()).catch(()=>{})}a(mr,"Kn");function hr(e){return nr(e,{}).handle}a(hr,"$n");function nr(e,t){let r=Ie(),n=Ve({enabled:e.keepScreenAwake!==!1}),l=t.decode??(i=>createImageBitmap(i)),c=t.blurRefuseSharpnessMax??.16,u=t.now??(()=>performance.now()),d=kt(e.documentType,t.catalogCapture===!0?t.captureSeries??xt(e.issuer,e.documentType):[]),p=d.sides.length===1||e.side==="single",b=t.secondSide,s=st(p?"singlePage":"twoSided",u(),b!==void 0?{safetyNetMs:b.safetyNetMs,sideChangeMs:b.sideChangeMs}:void 0);if(!p&&(e.side==="recto"||e.side==="verso")){let i=e.side==="recto"?"verso":"recto";s={...s,captured:{[i]:"server"},readSides:[i],current:e.side,phase:"flipCue",restPhase:"flipCue"}}let x="idle",v=null,S=null,k=!0,h=0,g=0,M=null,D=!1,B=!1,E="",K=null,V,Z=null,Le=[],de="base",ee=a(i=>{b===void 0||v===null||i===de||(de=i,v.setLockTuning?.(i==="second"?b.guide:t.engineOptions?.guideLock??Je))},"Z"),ue=a(()=>!p&&(s.captured.recto!==void 0?1:0)+(s.captured.verso!==void 0?1:0)==1,"de"),te=a(()=>ee(ue()?"second":"base"),"ee"),Pe=d.mrz==="none",ut=d.barcodeSide==="recto"||d.barcodeSide==="verso"?d.barcodeSide:null,G=Pe&&!p?t.barcode?.side??ut:null,Ae=e.barcodeAssetBaseUrl??t.barcode?.assetBaseUrl,ce=null,ze=a(()=>G===null||Ae===void 0||t.barcode?.seen!==void 0?Promise.resolve(null):(ce??(ce=import("./barcode-detect-C5IOXMKI-ZOZ2WOWU.js").then(i=>i.loadBarcodeDetect(Ae)).catch(()=>null)),ce),"Ee"),ct=a((i,o)=>{if(G===null)return Promise.resolve(null);let m,y=new Promise(f=>{m=setTimeout(()=>f(null),t.barcode?.budgetMs??tr)});return Promise.race([pt(i,o,G),y]).finally(()=>clearTimeout(m))},"Rt"),pt=a(async(i,o,m)=>{let y=m==="recto"?"verso":"recto";try{let f=t.barcode?.seen;if(f!==void 0)return await f(i)?m:y;let[P,T]=await Promise.all([ze(),o()]);if(P===null||T===null)return null;let w=Math.min(1600,T.width),C=document.createElement("canvas");C.width=w,C.height=Math.max(1,Math.round(T.height/T.width*w));try{let q=C.getContext("2d");return q===null?null:(q.drawImage(T,0,0,C.width,C.height),await Tt(P,q.getImageData(0,0,C.width,C.height),m))}finally{C.width=0,C.height=0}}catch{return null}},"xt"),A=t.webOcr!==void 0&&!Pe?Qt(t.webOcr.captureDocument,{mode:e.liveMrz?.mode??"auto"}):null,j=null,W=A===null||!A.enabled?"off":null,re=null,ie=null,De=new WeakMap,pe=new WeakMap,me=new Map,mt=a(async(i,o)=>{let m=j;if(m===null||W===null||typeof W!="object"||!("tier"in W))return null;let y=a(async()=>{let w=await l(i),C=o?.inStill===!0?Ye(nt(o.quad),w)[0]:{x:0,y:0,width:w.width,height:w.height},q=[C.x/w.width,C.y/w.height,C.width/w.width,C.height/w.height];return m.stillRead(w,q,A?.liveMrz?.detectorLimit)},"b"),f,P=new Promise(w=>{f=setTimeout(()=>w(null),rr)}),T=y().catch(()=>new Promise(w=>setTimeout(w,300)).then(y)).then(w=>w.valid&&w.digest!==void 0?{side:"verso",digest:w.digest}:w.lineCount===0?{side:"recto"}:null).catch(()=>null);return Promise.race([T,P]).finally(()=>clearTimeout(f))},"Tt"),he="";if(A!==null&&A.enabled&&t.webOcr!==void 0){let i=t.webOcr,o=Xt(A,{baseUrl:e.liveMrz?.assetBaseUrl??i.baseUrl,salt:i.salt,...e.liveMrz?.workerUrl!==void 0?{workerUrl:e.liveMrz.workerUrl}:{},...i.createWorker!==void 0?{createWorker:i.createWorker}:{}});if(o.ok){j=o.engine;let m=new Ke({textLock:A.textLock,liveMrz:A.liveMrz,...t.expiredBefore!==void 0?{expiredBefore:t.expiredBefore}:{}});re=m;let y=o.engine;y.ready.then(f=>{W=f,typeof f!="string"&&k&&m.setEngine(y,f.tier)})}else W=o.reason}let H=a(i=>{let o=JSON.stringify(i);o!==he&&(he=o,r.emit("mrz",i))},"V"),We=a((i,o)=>{let m=t.webOcr?.reports;if(m===void 0||A===null||i===void 0)return;let y=i.format==="ID-3"||i.side==="single"?"single":i.side==="verso"?"verso":"recto";if(!(y!=="recto"&&A.liveMrzOn||A.frontLockOn)||Math.random()>=A.reportSampleRate)return;let f=i.via==="live_mrz"?ie:null,P=a(()=>{let T=f?.value??null;m([Zt({capture:y,assist:i.ocr??null,load:W,...i.msToCapture!==void 0?{msToCapture:i.msToCapture}:{},...T!==null&&T.stillConfirmed!==void 0?{stillConfirmed:T.stillConfirmed}:{},...o!==void 0?{typeMismatch:ot(o.format,d.format==="ID-3"?"passport":"card")}:{}})])},"x");f!==null&&f.value===null?Promise.race([f.promise,new Promise(T=>setTimeout(T,3e3))]).then(P):P()},"Ae"),_=a(i=>{!k||i===x||(x=i,n.setActive(i==="starting"||i==="scanning"),r.emit("state",i))},"q"),ht=a((i,o)=>o===void 0?null:p?"single":i.captured.recto===o?"recto":i.captured.verso===o?"verso":null,"_t"),ft=a(i=>({phase:i.phase,captured:p?i.captured.recto!==void 0?["single"]:[]:["recto","verso"].filter(o=>i.captured[o]!==void 0&&i.captured[o]!==i.unsure),photos:p?i.captured.recto!==void 0&&X(i.captured.recto)>0?{single:X(i.captured.recto)}:{}:Object.fromEntries(["recto","verso"].filter(o=>i.captured[o]!==void 0&&i.captured[o]!==i.unsure&&X(i.captured[o])>0).map(o=>[o,X(i.captured[o])])),expected:p?null:i.current??null,notice:i.notice??null,lastShot:ht(i,i.lastShot),manualShutter:i.manualShutter,torchAvailable:v?.torchAvailable()??!1,torch:B}),"Lt"),qe=a(()=>{let i=v;if(i===null)return;let o=h,m=a(()=>{k&&v===i&&h===o&&s.phase==="capturing"&&R({type:"captureFailed",at:u()})},"f");i.captureNow().then(m,m)},"Be");function R(i){if(!k)return;let o=s;s=jt(s,i),s.phase==="capturing"&&o.phase!=="capturing"&&Promise.resolve().then(qe),s.phase==="result"&&o.phase!=="result"&&(_("done"),Oe());let m=ft(s),y=JSON.stringify(m);y!==E&&(E=y,r.emit("scan",m))}a(R,"T");function Oe(){Z!==null&&clearInterval(Z),Z=null;for(let i of Le.splice(0))i();v?.destroy(),v=null,n.setActive(!1)}a(Oe,"Ie");let Ee=a(()=>v?.captureReport?.(),"Fe"),fe=!1,Be=a((i,o)=>{if(!(i===void 0||t.onFaceReport===void 0))try{t.onFaceReport(i,o)}catch{}},"We"),Y=a(i=>{he="",!(v===null||s.phase==="reading"||s.phase==="result")&&(fe=!1,M=p?"single":s.current??i,v.rearm(M))},"Y"),gt=a(async(i,o,m,y)=>{ie=null;let f=W!==null&&typeof W=="object"&&W.tier==="low";if(y!==void 0&&j!==null&&A?.liveMrz?.hint===!0&&!f){let L={promise:Ht(j,i,y,{engine:le,detectorLimit:A.liveMrz.detectorLimit}).catch(()=>null),value:null};L.promise.then(ae=>{L.value=ae}),ie=L}y!==void 0&&ot(y.format,d.format==="ID-3"?"passport":"card")&&H({state:"mismatch",format:y.format});let P=`shot-${h+=1}`,T=s.current;R({type:"captured",id:P,at:u()});let w=s.lastShotVia,C=Ee();Be(C===void 0||s.lastShotVia===void 0?C:{...C,shotVia:s.lastShotVia},"captured"),fe=!0,We(C,y);let q=m===void 0?K:m===null?null:{quad:ar(m),frameWidth:0,frameHeight:0,inStill:!0},U={decoded:null},z=a(()=>(U.decoded??(U.decoded=Promise.resolve().then(()=>l(i)).catch(()=>null)),U.decoded),"O");try{await vt(P,T,i,o,q,z,ie,y,w)}finally{U.decoded!==null&&(await U.decoded)?.close()}},"Pt"),vt=a(async(i,o,m,y,f,P,T,w,C)=>{if(e.haptics!==!1)try{globalThis.navigator?.vibrate?.(30)}catch{}if(!D&&c>0){let z=await(t.measureSharpness!==void 0?t.measureSharpness(m,f):P().then(L=>L===null?-1:_e(L,be(f?.quad??null,f?.inStill===!0?L:{width:f?.frameWidth??0,height:f?.frameHeight??0},L)))).catch(()=>-1);if(!k)return;if(Number.isFinite(z)&&z>=0&&z<c){D=!0;let L=p?"recto":s.current??(s.captured.recto===void 0?"recto":"verso");R({type:"readFailed",side:L,id:i,issue:"blurry"}),te(),Y(L);return}}D=!1;let q;if(p)q="single";else{let z=w!==void 0&&w.format!=="TD3"&&(d.mrzSide==="recto"||d.mrzSide==="verso")?d.mrzSide:null,L=z===null&&t.classify===void 0?await ct(m,P):null,ae=L===null||G===null?L:Ct(L,G,s.captured),oe=z??ae??(ae===null&&G!==null&&o!==void 0?o:null),ve=oe!==null?null:await(t.classify!==void 0?t.classify(m):P().then(F=>F===null?o??"recto":f?.inStill===!0?Ge(F,nt(f.quad)):$e(F,480,be(f?.quad??null,{width:f?.frameWidth??0,height:f?.frameHeight??0},F)))).catch(()=>o??"recto"),wt=s.captured.recto===void 0&&s.captured.verso===void 0,Fe=oe??ve,Ne=!1,Mt=j!==null&&(W===null||typeof W=="object"&&"tier"in W);if(oe===null&&ve==="recto"&&wt&&d.mrzSide==="verso"&&Mt){let F=await mt(m,f);if(!k)return;F?.digest!==void 0&&me.set(i,F.digest),Fe=F?.side??null,Ne=F===null&&t.deferRead===!0}w!==void 0&&me.set(i,w.digest);let ye=w===void 0?void 0:["recto","verso"].find(F=>{let we=s.captured[F];return we!==void 0&&we!==i&&me.get(we)===w.digest});if(ye!==void 0){R({type:"duplicate",id:i,side:ye}),Y(ye==="recto"?"verso":"recto");return}let Q=oe??(ve==="recto"&&C!=="flip_timeout"&&s.captured.recto!==void 0&&s.captured.verso===void 0?"verso":Fe??"recto");if(!k)return;if(s.captured[Q]!==void 0&&g<er){g+=1,R({type:"duplicate",id:i,side:Q}),Y(Q==="recto"?"verso":"recto");return}let Ue=s.captured.recto===void 0?"recto":s.captured.verso===void 0?"verso":void 0;q=s.captured[Q]!==void 0&&Ue!==void 0?Ue:Q,g=0,R({type:"classified",id:i,side:q,...Ne?{unsure:!0}:{}}),ue()&&ee("second")}let U=q==="verso"?"verso":"recto";try{let z=t.encode!==void 0?await t.encode(m):await P().then(L=>{if(L===null)throw new Error("the still could not be decoded");return qt(L)});if(!k)return;T!==null&&De.set(z.blob,T),pe.set(z.blob,i),r.emit("captured",{image:z.blob,side:q,photo:X(i),documentType:e.documentType,...e.issuer!==void 0?{issuer:e.issuer}:{},width:z.width,height:z.height,previewDataUrl:y}),t.deferRead!==!0&&R({type:"readOk",side:U})}catch(z){R({type:"readFailed",side:U,id:i,issue:"technical"}),te(),r.emit("error",ne("generic",!0,{phase:"keyframes",name:Me(z)}))}Y(U==="recto"?"verso":"recto")},"Ot"),yt=a(i=>{Le.push(i.on("statechange",({state:o})=>{o==="preflight"||o==="acquiring"?_("starting"):o==="positioning"?_("scanning"):o==="captured"?_("captured"):o==="error"&&_("error")}),i.on("feedback",({key:o,reticle:m})=>r.emit("feedback",{key:o,reticle:m})),i.on("checks",o=>{r.emit("gate",{progress:o.p,quad:o.quad,frameWidth:o.frameWidth,frameHeight:o.frameHeight,...o.guide!==void 0?{guide:{detected:o.guide.detected,fill:o.guide.fill,offsetX:o.guide.offsetX??0,offsetY:o.guide.offsetY??0}}:{}});let m=o.ocr?.mrz;m!==void 0&&(m.state==="fallback"?H({state:"fallback",reason:m.reason}):m.state==="valid"?H({state:"valid",format:m.format}):m.state==="expired"?H({state:"expired",format:m.format}):m.state==="reading"?H({state:"reading",...m.format?{format:m.format}:{},...m.coach?{coach:m.coach}:{}}):H({state:"searching"}));let y=o.quad===null?0:or(o.quad,o.frameWidth,o.frameHeight);K=o.quad===null?null:{quad:o.quad,frameWidth:o.frameWidth,frameHeight:o.frameHeight},R({type:"report",report:{present:o.quad!==null&&o.plausible||o.guide?.detected===!0,ready:o.ready===!0,locking:o.ready===!0||o.locking===!0,areaFrac:y,...o.side!==void 0?{side:o.side}:{},...o.guide?.still!==void 0?{steady:o.guide.detected&&o.guide.still}:{}},at:u()})}),i.on("error",({kind:o,retryable:m,detail:y})=>r.emit("error",ne(o,m,y))),i.on("artifacts",o=>{gt(o.keyframe,o.previewDataUrl,o.docRegion,o.liveMrz)}))},"Et"),ge=a(()=>(S??(S=(async()=>{if(k){if(ze(),v===null){let i;try{i=await(t.createEngine??ir)({...t.engineOptions??{},...V!==void 0?{guide:V}:{},video:e.video,format:d.format,side:p?"single":e.side??"recto",autoCapture:!1,...re!==null?{ocr:re}:{},...b!==void 0&&!p&&d.mrzSide==="verso"?{sideProbe:!0}:{}})}catch(m){_("error"),r.emit("error",ne("models",!0,{phase:"models",name:Me(m)}));return}if(!k){i.destroy();return}v=i,de="base",M=p?"single":e.side??"recto",yt(i),ue()&&ee("second");let o=t.tickMs??500;o>0&&(Z=setInterval(()=>R({type:"tick",at:u()}),o))}R({type:"clockRestart"}),A!==null&&A.liveMrzOn&&(W==="unsupported"||W==="off")&&H({state:"fallback",reason:W}),await v.start()}})().finally(()=>{S=null})),S),"me");return{handle:{get state(){return x},on:a((i,o)=>r.on(i,o),"on"),start:ge,retry:a(()=>{if(v===null&&s.phase==="result"){R({type:"retake"}),g=0,D=!1,ge();return}if(v!==null&&x!=="error"){R({type:"retake"}),g=0,D=!1,ee("base"),M=p?"single":e.side??"recto",v.rearm(M);return}ge()},"retry"),setSide:a(i=>{p||i==="single"||v!==null&&s.current===i&&M===i&&s.phase!=="reading"&&s.phase!=="result"||(s.current!==i&&(s={...s,current:i}),R({type:"clockRestart"}),s.phase!=="reading"&&s.phase!=="result"&&v!==null&&(M=i,v.rearm(i)))},"setSide"),shutter:qe,focusAt:a((i,o)=>{v?.focusAt?.(i,o)},"focusAt"),setGuide:a(i=>{V=i,v?.setGuide?.(i)},"setGuide"),setTorch:a(i=>{B=i,v?.setTorch(i),R({type:"tick",at:u()})},"setTorch"),destroy:a(()=>{if(k&&v!==null&&x!=="done"){let i=Ee();!fe&&i!==void 0&&i.ticks>0&&Be(i,"abandoned"),We(i,void 0)}k=!1,Oe(),re?.setEngine(null),j?.dispose(),j=null,r.clear()},"destroy")},plan:d,setFlowState:a(i=>{(s.phase==="reading"||s.phase==="result")&&_(i==="done"&&s.phase!=="result"?"scanning":i)},"setFlowState"),settle:a((i,o,m)=>{let y=i==="verso"?"verso":"recto",f=m!==void 0?pe.get(m.image):s.unsure;if(f!==void 0&&s.captured.recto!==f&&s.captured.verso!==f&&!s.pending.includes(f))return;if(o.ok){let T=p?y:o.heldAs??y,w=s.phase;f!==void 0&&!p&&R({type:"held",id:f,side:T}),R({type:"readOk",side:T}),(w==="reading"||w==="result")&&s.phase!=="reading"&&s.phase!=="result"&&(te(),Y(s.current??(T==="recto"?"verso":"recto")));return}let P=s;R({type:"readFailed",side:y,...f!==void 0?{id:f}:{},issue:o.issue}),s!==P&&(te(),Y(y))},"settle"),takeDeviceRead:a(i=>De.get(i.image)?.value??null,"takeDeviceRead"),dropped:a(i=>{let o=pe.get(i.image);return o!==void 0&&!p&&s.captured.recto!==o&&s.captured.verso!==o&&!s.pending.includes(o)},"dropped")}}a(nr,"an");export{er as a,tr as b,rr as c,mr as d,hr as e,nr as f};
1
+ import{a as je,b as He,c as be,d as _e,f as Ge,g as Ye,h as $e,m as Je,q as Qe,r as Xe,t as Ke}from"./chunk-LSBUNQZU.js";import{a as Se,d as Ze,e as et}from"./chunk-F4Q2Q4OC.js";import{f as ne}from"./chunk-RVPBL3KC.js";import{e as Ie,k as Ve}from"./chunk-6MYG4HWP.js";import{g as Me}from"./chunk-JS2IXPNL.js";import{a}from"./chunk-4FHWXBOB.js";function tt(e,t){let r=new Set(e.flatMap(n=>n.sides.filter(l=>l[t]!==null).map(l=>l.side)));return r.size===1?[...r][0]:null}a(tt,"nt");function bt(e){let t=Ze.find(n=>n.docType===e),r=t.mrz==="none"?null:t.mrz==="td3"?"single":"verso";return{sides:t.sides,format:et(e),mrz:t.mrz==="none"?"none":"required",mrzSide:r,barcodeSide:null,portraitSide:t.portraitSide,scripts:null}}a(bt,"Bt");function St(e){let t=[];for(let r of e)for(let n of r.sides){if(!Array.isArray(n.scripts))return null;for(let l of n.scripts)t.includes(l)||t.push(l)}return t}a(St,"It");function kt(e,t){if(t.length===0)return bt(e);let r=t.some(d=>d.sides.length>1),n=new Set(t.map(d=>d.format)),l=n.size===1?[...n][0]:"card",c=t.filter(d=>d.sides.some(p=>p.mrz!==null)).length,u=t.find(d=>d.sides.length>1===r)?.sides.find(d=>d.portrait)?.side;return{sides:r?["recto","verso"]:["single"],format:l,mrz:c===t.length?"required":c===0?"none":"optional",mrzSide:tt(t,"mrz"),barcodeSide:tt(t,"barcode"),portraitSide:u??(r?"recto":"single"),scripts:St(t)}}a(kt,"rt");function xt(e,t){if(e===void 0)return[];let r=e.toUpperCase();return Object.prototype.hasOwnProperty.call(Se,r)?Se[r]?.[t]??[]:[]}a(xt,"ot");async function Tt(e,t,r){return await e(t)?r:r==="recto"?"verso":"recto"}a(Tt,"it");function Ct(e,t,r){return e!==t&&t==="verso"&&r.recto!==void 0&&r.verso===void 0?"verso":e}a(Ct,"at");var Rt={low:{maxLongEdge:1920,payloadTargetBytes:7e5,qMin:.7,qMax:.92},mid:{maxLongEdge:2240,payloadTargetBytes:12e5,qMin:.7,qMax:.92},good:{maxLongEdge:2560,payloadTargetBytes:16e5,qMin:.7,qMax:.92}};function Lt(e){let{deviceMemory:t,effectiveType:r,saveData:n,downlinkMbps:l,sourceLongEdge:c}=e,u=n===!0||r==="slow-2g"||r==="2g"||l!=null&&l>0&&l<1,d=t!=null&&t<=2,p=r==="4g"||l!=null&&l>=5,b=t!=null&&t>=6,s;u||d?s="low":p&&b?s="good":s="mid";let x=Rt[s],v=c&&c>0?Math.min(x.maxLongEdge,c):x.maxLongEdge;return{tier:s,...x,maxLongEdge:v}}a(Lt,"Wt");function Pt(e){let t={};try{let r=navigator;typeof r.deviceMemory=="number"&&(t.deviceMemory=r.deviceMemory);let n=r.connection;n&&(t.effectiveType=n.effectiveType,t.saveData=n.saveData,t.downlinkMbps=n.downlink)}catch{}return typeof e=="number"&&e>0&&(t.sourceLongEdge=e),Lt(t)}a(Pt,"st");function At(e,t,r){let n=Math.min(1,Math.max(0,(e-.28)/.21999999999999997)),l=(t+r)/2;return Math.max(t,r-n*(r-l))}a(At,"Nt");function zt(e,t,r){let n=Math.max(e,t),l=n>0?Math.min(1,r/n):1;return{width:Math.max(1,Math.round(e*l)),height:Math.max(1,Math.round(t*l))}}a(zt,"zt");async function Dt(e,t){let r=t.startQ,n=await e(r);for(let l=0;l<4&&!(n.size<=t.budgetBytes||r<=t.qMin);l++)r=Math.max(t.qMin,r-.08),n=await e(r);return{blob:n,quality:r}}a(Dt,"Ut");async function Wt(e,t,r,n,l){if(t<=0||r<=0)return null;let{width:c,height:u}=zt(t,r,n.maxLongEdge),d=document.createElement("canvas");d.width=c,d.height=u;let p=d.getContext("2d");if(!p)return null;p.drawImage(e,0,0,c,u);let b=a(S=>new Promise((k,h)=>{d.toBlob(g=>g?k(g):h(new Error("canvas toBlob returned null")),"image/jpeg",S)}),"y"),s=At(l,n.qMin,n.qMax),{blob:x,quality:v}=await Dt(b,{startQ:s,qMin:n.qMin,budgetBytes:n.payloadTargetBytes}).finally(()=>{d.width=0,d.height=0});if(x.size>5242880)throw new Error("encoded document exceeds the 5242880-byte media cap");return{blob:x,quality:v,width:c,height:u}}a(Wt,"dt");async function qt(e){let t=Pt(Math.max(e.width,e.height)),r=await Wt(e,e.width,e.height,t,.5);if(r===null)throw new Error("canvas encode unavailable");return{blob:r.blob,width:r.width,height:r.height}}a(qt,"Me");function st(e,t,r={safetyNetMs:null,sideChangeMs:null}){return{layout:e,phase:"framing",captured:{},pending:[],lastCaptureAt:t,lastReportAt:t,manualShutter:!1,restPhase:"framing",readSides:[],needFlip:!1,flipped:!1,flipTimeoutSpent:!1,timeoutCapture:!1,lastShotByTimeout:!1,tuning:r,safetyNetSpent:!1,sideHits:0,turnSeen:!1}}a(st,"we");var Re=a(e=>e==="recto"?"verso":"recto","Ce"),lt=a(e=>e.phase==="framing"||e.phase==="locking"||e.phase==="flipCue"||e.phase==="reaskRecto","ct"),J=a(e=>(e.captured.recto!==void 0?1:0)+(e.captured.verso!==void 0?1:0)+e.pending.length,"Q");function ke(e,t){return e.lastCaptureAt>=0&&e.lastReportAt>=0?e:{...e,lastCaptureAt:e.lastCaptureAt<0?t:e.lastCaptureAt,lastReportAt:e.lastReportAt<0?t:e.lastReportAt}}a(ke,"De");function Ot(e){if(J(e)===1)return e.captured.recto!==void 0?"recto":e.captured.verso!==void 0?"verso":void 0}a(Ot,"Gt");function Et(e,t,r){if(e.phase==="result")return{...e,lastReportAt:r};let n=!t.present||e.captureArea!==void 0&&t.areaFrac<.6*e.captureArea,{flipped:l,awaySince:c}=e,u=e.sideSince,d=e.sideHits,p=Ot(e),b=e.tuning.sideChangeMs!==null&&e.needFlip&&p!==void 0,s=!1;b&&p==="recto"&&t.side==="verso"?(u=u??r,d+=1,s=d>=2&&r-u>=e.tuning.sideChangeMs,s&&(l=!0)):(!b||t.side!==void 0)&&(u=void 0,d=0),n&&(c=c??r),c!==void 0&&r-c>=250&&(l=!0,s=!0),n||(c=void 0);let x=b&&p==="verso"&&t.side==="verso";x&&(l=!1);let v=x?!1:e.turnSeen||s,S=e.flipTimeoutSpent&&!(l&&!e.flipped),k=e.notice==="same_face"&&l&&!e.flipped?void 0:e.notice,h=t.present&&t.steady!==!1&&!x,g=l&&!e.flipped||v&&!e.turnSeen,M=h?g?r:e.presentSince??r:void 0,D={...e,lastReportAt:r,flipped:l,awaySince:c,sideSince:u,sideHits:d,presentSince:M,turnSeen:v,flipTimeoutSpent:S,notice:k,lastArea:t.areaFrac};if(!lt(e))return D;let B=Bt(e,D,t,r,l,S),E=e.tuning.safetyNetMs;return E!==null&&e.layout==="twoSided"&&J(e)===1&&!e.safetyNetSpent&&v&&M!==void 0&&r-M>=E&&B.phase!=="capturing"?{...B,phase:"capturing",safetyNetSpent:!0,shotVia:"safety_net"}:B}a(Et,"Ht");function Bt(e,t,r,n,l,c){if(e.needFlip&&!l){if(!r.ready)return{...t,phase:e.restPhase,goodSince:void 0};let u=e.lastShot!==void 0&&e.pending.includes(e.lastShot);if(c||u)return{...t,goodSince:void 0,phase:e.restPhase};let d=e.goodSince??n;return n-d>=1800?{...t,goodSince:d,phase:"capturing",flipTimeoutSpent:!0,timeoutCapture:!0}:{...t,goodSince:d,phase:e.restPhase}}return r.ready?{...t,phase:"capturing",goodSince:e.goodSince??n}:{...t,goodSince:void 0,phase:r.locking?"locking":e.restPhase}}a(Bt,"Vt");function Ft(e,t){if(!lt(e)||e.manualShutter)return e;let r=t-e.lastReportAt>=2e3,n=t-e.lastCaptureAt>=6e3;return r||n?{...e,manualShutter:!0}:e}a(Ft,"qt");function Nt(e,t,r){let n=e.layout==="singlePage",l=n?{recto:t}:e.captured,c=n?[]:[...e.pending,t],u={...e,captured:l,pending:c,lastShot:t,lastCaptureAt:r,lastReportAt:-1,manualShutter:!1,goodSince:void 0,notice:void 0,awaySince:void 0,flipped:!1,lastShotByTimeout:e.timeoutCapture,timeoutCapture:!1,captureArea:e.lastArea,sideSince:void 0,sideHits:0,presentSince:void 0,turnSeen:!1,shotVia:void 0,lastShotVia:e.phase==="capturing"?e.timeoutCapture?"flip_timeout":e.shotVia??"ready":"manual"};return n||J({captured:l,pending:c})>=2?{...u,phase:"reading",restPhase:"framing",current:void 0,needFlip:!1}:{...u,phase:"flipCue",restPhase:"flipCue",current:void 0,needFlip:!0}}a(Nt,"Xt");function dt(e,t,r){return e.pending.includes(t)?{...e,pending:e.pending.filter(n=>n!==t),lastShot:e.lastShot===t?void 0:e.lastShot,phase:e.phase==="capturing"?e.phase:"flipCue",restPhase:"flipCue",current:Re(r),needFlip:!0,flipTimeoutSpent:!1,goodSince:void 0,manualShutter:!0,notice:"same_face",lastCaptureAt:-1,lastReportAt:-1,turnSeen:!1,presentSince:void 0}:e}a(dt,"lt");function Ut(e,t,r,n=!1){if(!e.pending.includes(t))return e;if(e.captured[r]!==void 0)return dt(e,t,r);let l=e.pending.filter(b=>b!==t),c={...e,pending:l,captured:{...e.captured,[r]:t}};if(J(c)!==1||e.layout==="singlePage")return c;if(n)return{...c,unsure:t,phase:"reading",restPhase:"flipCue",current:void 0,needFlip:!1};let u=Re(r),d=u==="recto"&&e.restPhase==="reaskRecto"?"reaskRecto":"flipCue",p=e.phase==="flipCue"||e.phase==="reaskRecto"||e.phase==="framing";return{...c,restPhase:d,current:u,phase:p?d:e.phase}}a(Ut,"Yt");function It(e,t,r){let n=e.captured.recto===t?"recto":e.captured.verso===t?"verso":void 0;if(n===void 0||n===r&&e.unsure!==t)return e;let l=Re(r),c={[r]:t};e.captured[l]!==void 0&&e.captured[l]!==t&&(c[l]=e.captured[l]);let u=[c.recto,c.verso,...e.pending],d={...e,captured:c,unsure:void 0,readSides:e.readSides.filter(p=>c[p]!==void 0&&c[p]===e.captured[p]),lastShot:e.lastShot!==void 0&&u.includes(e.lastShot)?e.lastShot:void 0};return e.layout==="singlePage"||J(d)!==1||e.phase!=="reading"&&e.phase!=="result"?d:{...d,phase:"flipCue",restPhase:"flipCue",current:l,needFlip:!0,flipped:!1,flipTimeoutSpent:!1,goodSince:void 0,awaySince:void 0,turnSeen:!1,safetyNetSpent:!1,presentSince:void 0,sideSince:void 0,sideHits:0,captureArea:e.lastArea,lastCaptureAt:-1,lastReportAt:-1,manualShutter:!1}}a(It,"Qt");function Vt(e,t){if(t.id!==void 0&&e.captured.recto!==t.id&&e.captured.verso!==t.id&&!e.pending.includes(t.id))return e;let r=t.id??e.captured[t.side],n={...e.captured};(t.id===void 0||n[t.side]===t.id)&&delete n[t.side];let l=e.pending.filter(b=>b!==r),c=e.layout==="twoSided"&&J({captured:n,pending:l})>0,u=e.lastShotByTimeout||r===e.lastShot!==e.flipped,d=c&&!u,p=d?t.side==="recto"?"reaskRecto":"flipCue":"framing";return{...e,captured:n,pending:l,readSides:e.readSides.filter(b=>b!==t.side),unsure:e.unsure===r?void 0:e.unsure,lastShot:e.lastShot===r?void 0:e.lastShot,notice:t.issue,goodSince:void 0,manualShutter:!1,phase:p,restPhase:p,current:t.side,needFlip:d,flipped:!1,flipTimeoutSpent:!1,awaySince:void 0,lastCaptureAt:-1,lastReportAt:-1,safetyNetSpent:!1,sideSince:void 0,sideHits:0,presentSince:void 0,turnSeen:c&&!d&&r===e.lastShot&&!e.flipped&&!e.lastShotByTimeout}}a(Vt,"jt");function jt(e,t){switch(t.type){case"report":return Et(ke(e,t.at),t.report,t.at);case"tick":return Ft(ke(e,t.at),t.at);case"captured":return Nt(ke(e,t.at),t.id,t.at);case"captureFailed":return{...e,phase:e.restPhase,goodSince:void 0,lastCaptureAt:t.at,manualShutter:!0,timeoutCapture:!1,shotVia:void 0,...e.shotVia==="safety_net"?{safetyNetSpent:!1,presentSince:void 0}:{}};case"classified":return Ut(e,t.id,t.side,t.unsure===!0);case"held":return It(e,t.id,t.side);case"duplicate":return dt(e,t.id,t.side);case"readOk":{let r=e.readSides.includes(t.side)?e.readSides:[...e.readSides,t.side],n=["recto","verso"].filter(c=>e.captured[c]!==void 0),l=e.phase==="reading"&&e.pending.length===0&&n.every(c=>r.includes(c));return{...e,readSides:r,flipTimeoutSpent:!1,phase:l?"result":e.phase}}case"readFailed":return Vt(e,t);case"clockRestart":return e.lastCaptureAt<0&&e.lastReportAt<0&&e.awaySince===void 0&&e.presentSince===void 0&&e.sideSince===void 0&&e.sideHits===0?e:{...e,awaySince:void 0,presentSince:void 0,sideSince:void 0,sideHits:0,lastCaptureAt:-1,lastReportAt:-1};case"retake":return{...st(e.layout,-1,e.tuning),lastCaptureAt:-1,lastReportAt:-1};default:return e}}a(jt,"ft");var xe=a((e,t,r)=>Math.min(r,Math.max(t,Math.round(e))),"ke"),se=a(e=>Math.round(Math.min(1,Math.max(0,e))*1e4)/1e4,"ae");async function Ht(e,t,r,n){let l=n.decode??(p=>createImageBitmap(p)),c=a(async()=>e.stillRead(await l(t),n.region??[0,0,1,1],n.detectorLimit),"c"),u;try{u=await c()}catch{try{await new Promise(p=>setTimeout(p,n.retryMs??300)),u=await c()}catch{return null}}let d=u.mrzBox;return d===void 0?null:{engine:n.engine,source:"live_mrz",format:r.format,lineCount:xe(r.lineCount,2,3),checkDigitsValid:!0,stillConfirmed:u.valid&&u.digest===r.digest,band:[se(d[0]),se(d[1]),se(Math.min(d[2],1-d[0])),se(Math.min(d[3],1-d[1]))],digest:r.digest,framesToValid:xe(r.framesToValid,1,1e3),msToValid:xe(r.msToValid,0,12e4)}}a(Ht,"mt");var _t=new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11]),Gt=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,7,1,5,0,6,64,11,11]);function Yt(e=globalThis){let t=e.WebAssembly?.validate;if(typeof t!="function")return{ok:!1,reason:"simd"};try{if(!t.call(e.WebAssembly,_t)||!t.call(e.WebAssembly,Gt))return{ok:!1,reason:"simd"}}catch{return{ok:!1,reason:"simd"}}return typeof e.Worker!="function"?{ok:!1,reason:"worker"}:typeof e.createImageBitmap!="function"?{ok:!1,reason:"bitmap"}:{ok:!0}}a(Yt,"pt");function $t(e=globalThis){let t=e.navigator?.connection;return t?.saveData===!0||["slow-2g","2g","3g"].includes(t?.effectiveType??"")}a($t,"gt");var $,N=($=class extends Error{constructor(t){super(t),this.name="OcrEngineError",this.code=t}},a($,"I"),$);function rt(){let e=a(t=>(t.close(),Promise.reject(new N("unsupported"))),"e");return{ready:Promise.resolve("unsupported"),busy:!1,bandRead:e,stillRead:e,layoutRead:e,dispose:a(()=>{},"dispose")}}a(rt,"St");function Jt(e){let t;try{if(e.createWorker)t=e.createWorker();else if(e.workerUrl!==void 0)t=new Worker(e.workerUrl,{type:"module",name:"sekyro-ocr"});else return rt()}catch{return rt()}let r=new Map,n=0,l=!1,c=!1,u=!1;t.addEventListener("message",h=>{let g=h.data,M=r.get(g.id);M&&(r.delete(g.id),M.resolve(g))});let d=a(()=>{for(let h of r.values())h.reject(new N("error"));r.clear(),b()},"d");t.addEventListener("error",d),t.addEventListener("messageerror",d);function p(h,g=[]){if(l)return Promise.reject(new N("disposed"));let M=++n;return new Promise((D,B)=>{r.set(M,{resolve:D,reject:B});try{t.postMessage({...h,id:M},g)}catch{r.delete(M),B(new N("error"))}})}a(p,"l");function b(){if(!l){l=!0;try{t.postMessage({id:++n,kind:"dispose"})}catch{}t.terminate();for(let h of r.values())h.reject(new N("disposed"));r.clear()}}a(b,"y");let s=(async()=>{let h=await p({kind:"init",baseUrl:e.baseUrl,salt:e.salt,detectorLimit:e.tuning.detectorLimit,maxDownloadMs:e.tuning.maxDownloadMs});if(h.kind==="failed")return h.reason;if(h.kind!=="ready")return"error";let g=await p({kind:"warmup"});if(g.kind!=="ready")return"error";let M=g.benchMs??g.warmupMs,D=e.deviceMemoryGb===void 0?He():e.deviceMemoryGb;return{warmupMs:g.warmupMs,downloadMs:h.downloadMs,cached:h.cached,benchMs:M,tier:je(M,D)}})().catch(()=>"error"),x,v=new Promise(h=>{x=setTimeout(()=>h("timeout"),e.tuning.loadTimeoutMs)}),S=Promise.race([s,v]).then(h=>(clearTimeout(x),typeof h=="string"?b():u=!0,l&&typeof h!="string"?"error":h));(e.page===void 0?globalThis.addEventListener?globalThis:null:e.page)?.addEventListener("pagehide",b,{once:!0});async function k(h,g,M){if(l)throw g.close(),new N("disposed");if(!u)throw g.close(),new N("not_ready");if(c)throw g.close(),new N("busy");c=!0;let D;try{let B=new Promise((K,V)=>{D=setTimeout(()=>{V(new N("timeout")),b()},e.tuning.readTimeoutMs??1e4)}),E=await Promise.race([p(h,[g]),B]);if(E.kind===M){let{id:K,...V}=E;return V}throw new N(E.kind==="error"?E.code:E.kind==="failed"?E.reason:"error")}finally{clearTimeout(D),c=!1}}return a(k,"P"),{ready:S,get busy(){return c},bandRead:a((h,g=e.tuning.detectorLimit,M)=>k({kind:"band",bitmap:h,detectorLimit:g,...M!==void 0?{expiredBefore:M}:{}},h,"band"),"bandRead"),stillRead:a((h,g,M=e.tuning.detectorLimit)=>k({kind:"still",bitmap:h,region:g,detectorLimit:M},h,"band"),"stillRead"),layoutRead:a((h,g)=>k({kind:"layout",bitmap:h,detectorLimit:g},h,"layout"),"layoutRead"),dispose:b}}a(Jt,"ht");var le="sekyro-ocr-1",Te=a(e=>e!==null&&typeof e=="object"?e:{},"Re"),O=a((e,t,r,n)=>typeof e=="number"&&Number.isFinite(e)&&e>=t&&e<=r?e:n,"B"),it=a((e,t)=>typeof e=="boolean"?e:t,"bt"),at=a(e=>{let t=typeof e=="string"?/^sekyro-ocr-(\d{1,4})$/.exec(e):null;return t?Number(t[1]):Number.POSITIVE_INFINITY},"yt");function Qt(e,t={}){let r=Te(e),n=Te(r.liveMrz),l=Te(r.frontLock),c=at(t.engine??le),u=t.mode==="off",d=n.enabled===!0,p=l.enabled===!0,b=a((h,g)=>!u&&g&&at(h.minEngine??le)<=c,"y"),s=Xe,x=b(n,d)?{detectorLimit:O(n.detectorLimit,320,1600,s.detectorLimit),bandMaxWidthPx:O(n.bandMaxWidthPx,320,4096,s.bandMaxWidthPx),minBandWidthPx:O(n.minBandWidthPx,0,4096,s.minBandWidthPx),bandTop:O(n.bandTop,0,.95,s.bandTop),minIntervalMs:O(n.minIntervalMs,0,5e3,s.minIntervalMs),stableReads:Math.round(O(n.stableReads,1,10,s.stableReads)),profileReads:Math.round(O(n.profileReads,1,100,s.profileReads)),maxReadMs:O(n.maxReadMs,50,6e4,s.maxReadMs),searchTimeoutMs:O(n.searchTimeoutMs,1e3,12e4,s.searchTimeoutMs),hint:it(n.hint,!0),stillConfirm:it(n.stillConfirm,!0)}:null,v=Qe,S=a((h,g,M)=>O(l[h],g,M,v[h]),"M"),k=b(l,p)?{minLines:Math.round(S("minLines",1,50)),fillMin:S("fillMin",0,1),fillMax:S("fillMax",0,2),offsetMax:S("offsetMax",0,1),steadyFillDelta:S("steadyFillDelta",0,1),steadyOffsetDelta:S("steadyOffsetDelta",0,1),layoutShiftMax:S("layoutShiftMax",0,1),lineCountDelta:Math.round(S("lineCountDelta",0,50)),lockMs:S("lockMs",0,3e4),steadyMs:S("steadyMs",0,3e4),minFrames:Math.round(S("minFrames",1,100)),minIntervalMs:S("minIntervalMs",0,5e3),maxWidthPx:S("maxWidthPx",160,2048),detectorLimit:S("detectorLimit",320,1600),searchTimeoutMs:S("searchTimeoutMs",1e3,12e4)}:null;return{enabled:x!==null||k!==null,liveMrz:x,textLock:k,liveMrzOn:d,frontLockOn:p,load:{detectorLimit:x?.detectorLimit??k?.detectorLimit??s.detectorLimit,loadTimeoutMs:O(n.loadTimeoutMs,1e3,12e4,2e4),maxDownloadMs:O(n.maxDownloadMs,1e3,12e4,2e4)},reportSampleRate:O(n.reportSampleRate,0,1,1)}}a(Qt,"Mt");function Xt(e,t){return e.enabled?!(t.probe??Yt)().ok||(t.slow??$t)()?{ok:!1,reason:"unsupported"}:{ok:!0,engine:Jt({baseUrl:t.baseUrl,salt:t.salt,tuning:{detectorLimit:e.load.detectorLimit,maxDownloadMs:e.load.maxDownloadMs,loadTimeoutMs:e.load.loadTimeoutMs},...t.workerUrl!==void 0?{workerUrl:t.workerUrl}:{},...t.createWorker!==void 0?{createWorker:t.createWorker}:{},...t.page!==void 0?{page:t.page}:{},...t.deviceMemoryGb!==void 0?{deviceMemoryGb:t.deviceMemoryGb}:{}})}:{ok:!1,reason:"off"}}a(Xt,"Dt");function Kt(e=typeof navigator<"u"?navigator.userAgent:""){return/SamsungBrowser\//.test(e)?"samsung":/Firefox\/|FxiOS\//.test(e)?"firefox":/Chrome\/|CriOS\/|Chromium\//.test(e)&&!/Edg\/|OPR\//.test(e)?"chrome":/Safari\//.test(e)&&/Version\/|Mobile\//.test(e)&&!/Chrome\/|CriOS\//.test(e)?"safari":"other"}a(Kt,"Jt");var I=a(e=>e===void 0||!Number.isFinite(e)?void 0:Math.min(6e5,Math.max(0,Math.round(e))),"G"),Ce=a((e,t,r)=>e===void 0||!Number.isFinite(e)?void 0:Math.min(r,Math.max(t,Math.round(e))),"xe");function Zt(e){let t=e.assist??null,r=e.load!==null&&e.load!==void 0&&typeof e.load=="object"?e.load:null,n=typeof e.load=="string"?e.load:null,l=t!==null?t.outcome:n==="unsupported"||n==="download"||n==="integrity"?n:n==="error"||n==="timeout"?"error":"off",c={kind:"live_mrz",platform:"web",engine:e.engine??le,capture:e.capture,outcome:l,reads:Ce(t?.reads??0,0,1e4)??0,browser:e.browser??Kt()},u=a((d,p)=>{p!==void 0&&(c[d]=p)},"u");return u("format",t?.format),u("framesToValid",Ce(t?.framesToValid,1,1e4)),u("msToValid",I(t?.msToValid)),u("framesToLock",Ce(t?.framesToLock,1,1e4)),u("msToLock",I(t?.msToLock)),u("msToCapture",I(e.msToCapture)),u("readP50Ms",I(t?.readP50Ms)),u("readP90Ms",I(t?.readP90Ms)),u("deviceClass",t?.deviceClass),r!==null&&(u("warmupMs",I(r.warmupMs)),u("downloadMs",I(r.downloadMs)),u("cached",r.cached),u("tier",r.tier),u("benchMs",I(r.benchMs))),u("stillConfirmed",e.stillConfirmed),u("typeMismatch",e.typeMismatch),c}a(Zt,"wt");function ot(e,t){return e===void 0?!1:t==="passport"?e!=="TD3":e==="TD3"}a(ot,"Te");var er=2,tr=1500,rr=2500;async function ir(e){let t=await import("./capture-session-doc-ENDGVJ3L-IMAPC36N.js");return new t.CaptureSessionDoc(e)}a(ir,"nn");function ar(e){return{topLeft:{x:e.x,y:e.y},topRight:{x:e.x+e.width,y:e.y},bottomRight:{x:e.x+e.width,y:e.y+e.height},bottomLeft:{x:e.x,y:e.y+e.height}}}a(ar,"rn");function nt(e){let t=[e.topLeft.x,e.topRight.x,e.bottomRight.x,e.bottomLeft.x],r=[e.topLeft.y,e.topRight.y,e.bottomRight.y,e.bottomLeft.y],n=Math.min(...t),l=Math.min(...r);return{x:n,y:l,width:Math.max(...t)-n,height:Math.max(...r)-l}}a(nt,"Ct");function or(e,t,r){let n=[e.topLeft,e.topRight,e.bottomRight,e.bottomLeft],l=0;for(let c=0;c<n.length;c+=1){let u=n[c],d=n[(c+1)%n.length];l+=u.x*d.y-d.x*u.y}return t>0&&r>0?Math.abs(l)/2/(t*r):0}a(or,"on");function X(e){return e.startsWith("shot-")?Number(e.slice(5)):0}a(X,"J");function mr(){import("./capture-session-doc-ENDGVJ3L-IMAPC36N.js").then(e=>e.warmDocDetector()).catch(()=>{})}a(mr,"Kn");function hr(e){return nr(e,{}).handle}a(hr,"$n");function nr(e,t){let r=Ie(),n=Ve({enabled:e.keepScreenAwake!==!1}),l=t.decode??(i=>createImageBitmap(i)),c=t.blurRefuseSharpnessMax??.16,u=t.now??(()=>performance.now()),d=kt(e.documentType,t.catalogCapture===!0?t.captureSeries??xt(e.issuer,e.documentType):[]),p=d.sides.length===1||e.side==="single",b=t.secondSide,s=st(p?"singlePage":"twoSided",u(),b!==void 0?{safetyNetMs:b.safetyNetMs,sideChangeMs:b.sideChangeMs}:void 0);if(!p&&(e.side==="recto"||e.side==="verso")){let i=e.side==="recto"?"verso":"recto";s={...s,captured:{[i]:"server"},readSides:[i],current:e.side,phase:"flipCue",restPhase:"flipCue"}}let x="idle",v=null,S=null,k=!0,h=0,g=0,M=null,D=!1,B=!1,E="",K=null,V,Z=null,Le=[],de="base",ee=a(i=>{b===void 0||v===null||i===de||(de=i,v.setLockTuning?.(i==="second"?b.guide:t.engineOptions?.guideLock??Je))},"Z"),ue=a(()=>!p&&(s.captured.recto!==void 0?1:0)+(s.captured.verso!==void 0?1:0)==1,"de"),te=a(()=>ee(ue()?"second":"base"),"ee"),Pe=d.mrz==="none",ut=d.barcodeSide==="recto"||d.barcodeSide==="verso"?d.barcodeSide:null,G=Pe&&!p?t.barcode?.side??ut:null,Ae=e.barcodeAssetBaseUrl??t.barcode?.assetBaseUrl,ce=null,ze=a(()=>G===null||Ae===void 0||t.barcode?.seen!==void 0?Promise.resolve(null):(ce??(ce=import("./barcode-detect-C5IOXMKI-ZOZ2WOWU.js").then(i=>i.loadBarcodeDetect(Ae)).catch(()=>null)),ce),"Ee"),ct=a((i,o)=>{if(G===null)return Promise.resolve(null);let m,y=new Promise(f=>{m=setTimeout(()=>f(null),t.barcode?.budgetMs??tr)});return Promise.race([pt(i,o,G),y]).finally(()=>clearTimeout(m))},"Rt"),pt=a(async(i,o,m)=>{let y=m==="recto"?"verso":"recto";try{let f=t.barcode?.seen;if(f!==void 0)return await f(i)?m:y;let[P,T]=await Promise.all([ze(),o()]);if(P===null||T===null)return null;let w=Math.min(1600,T.width),C=document.createElement("canvas");C.width=w,C.height=Math.max(1,Math.round(T.height/T.width*w));try{let q=C.getContext("2d");return q===null?null:(q.drawImage(T,0,0,C.width,C.height),await Tt(P,q.getImageData(0,0,C.width,C.height),m))}finally{C.width=0,C.height=0}}catch{return null}},"xt"),A=t.webOcr!==void 0&&!Pe?Qt(t.webOcr.captureDocument,{mode:e.liveMrz?.mode??"auto"}):null,j=null,W=A===null||!A.enabled?"off":null,re=null,ie=null,De=new WeakMap,pe=new WeakMap,me=new Map,mt=a(async(i,o)=>{let m=j;if(m===null||W===null||typeof W!="object"||!("tier"in W))return null;let y=a(async()=>{let w=await l(i),C=o?.inStill===!0?Ye(nt(o.quad),w)[0]:{x:0,y:0,width:w.width,height:w.height},q=[C.x/w.width,C.y/w.height,C.width/w.width,C.height/w.height];return m.stillRead(w,q,A?.liveMrz?.detectorLimit)},"b"),f,P=new Promise(w=>{f=setTimeout(()=>w(null),rr)}),T=y().catch(()=>new Promise(w=>setTimeout(w,300)).then(y)).then(w=>w.valid&&w.digest!==void 0?{side:"verso",digest:w.digest}:w.lineCount===0?{side:"recto"}:null).catch(()=>null);return Promise.race([T,P]).finally(()=>clearTimeout(f))},"Tt"),he="";if(A!==null&&A.enabled&&t.webOcr!==void 0){let i=t.webOcr,o=Xt(A,{baseUrl:e.liveMrz?.assetBaseUrl??i.baseUrl,salt:i.salt,...e.liveMrz?.workerUrl!==void 0?{workerUrl:e.liveMrz.workerUrl}:{},...i.createWorker!==void 0?{createWorker:i.createWorker}:{}});if(o.ok){j=o.engine;let m=new Ke({textLock:A.textLock,liveMrz:A.liveMrz,...t.expiredBefore!==void 0?{expiredBefore:t.expiredBefore}:{}});re=m;let y=o.engine;y.ready.then(f=>{W=f,typeof f!="string"&&k&&m.setEngine(y,f.tier)})}else W=o.reason}let H=a(i=>{let o=JSON.stringify(i);o!==he&&(he=o,r.emit("mrz",i))},"V"),We=a((i,o)=>{let m=t.webOcr?.reports;if(m===void 0||A===null||i===void 0)return;let y=i.format==="ID-3"||i.side==="single"?"single":i.side==="verso"?"verso":"recto";if(!(y!=="recto"&&A.liveMrzOn||A.frontLockOn)||Math.random()>=A.reportSampleRate)return;let f=i.via==="live_mrz"?ie:null,P=a(()=>{let T=f?.value??null;m([Zt({capture:y,assist:i.ocr??null,load:W,...i.msToCapture!==void 0?{msToCapture:i.msToCapture}:{},...T!==null&&T.stillConfirmed!==void 0?{stillConfirmed:T.stillConfirmed}:{},...o!==void 0?{typeMismatch:ot(o.format,d.format==="ID-3"?"passport":"card")}:{}})])},"x");f!==null&&f.value===null?Promise.race([f.promise,new Promise(T=>setTimeout(T,3e3))]).then(P):P()},"Ae"),_=a(i=>{!k||i===x||(x=i,n.setActive(i==="starting"||i==="scanning"),r.emit("state",i))},"q"),ht=a((i,o)=>o===void 0?null:p?"single":i.captured.recto===o?"recto":i.captured.verso===o?"verso":null,"_t"),ft=a(i=>({phase:i.phase,captured:p?i.captured.recto!==void 0?["single"]:[]:["recto","verso"].filter(o=>i.captured[o]!==void 0&&i.captured[o]!==i.unsure),photos:p?i.captured.recto!==void 0&&X(i.captured.recto)>0?{single:X(i.captured.recto)}:{}:Object.fromEntries(["recto","verso"].filter(o=>i.captured[o]!==void 0&&i.captured[o]!==i.unsure&&X(i.captured[o])>0).map(o=>[o,X(i.captured[o])])),expected:p?null:i.current??null,notice:i.notice??null,lastShot:ht(i,i.lastShot),manualShutter:i.manualShutter,torchAvailable:v?.torchAvailable()??!1,torch:B}),"Lt"),qe=a(()=>{let i=v;if(i===null)return;let o=h,m=a(()=>{k&&v===i&&h===o&&s.phase==="capturing"&&R({type:"captureFailed",at:u()})},"f");i.captureNow().then(m,m)},"Be");function R(i){if(!k)return;let o=s;s=jt(s,i),s.phase==="capturing"&&o.phase!=="capturing"&&Promise.resolve().then(qe),s.phase==="result"&&o.phase!=="result"&&(_("done"),Oe());let m=ft(s),y=JSON.stringify(m);y!==E&&(E=y,r.emit("scan",m))}a(R,"T");function Oe(){Z!==null&&clearInterval(Z),Z=null;for(let i of Le.splice(0))i();v?.destroy(),v=null,n.setActive(!1)}a(Oe,"Ie");let Ee=a(()=>v?.captureReport?.(),"Fe"),fe=!1,Be=a((i,o)=>{if(!(i===void 0||t.onFaceReport===void 0))try{t.onFaceReport(i,o)}catch{}},"We"),Y=a(i=>{he="",!(v===null||s.phase==="reading"||s.phase==="result")&&(fe=!1,M=p?"single":s.current??i,v.rearm(M))},"Y"),gt=a(async(i,o,m,y)=>{ie=null;let f=W!==null&&typeof W=="object"&&W.tier==="low";if(y!==void 0&&j!==null&&A?.liveMrz?.hint===!0&&!f){let L={promise:Ht(j,i,y,{engine:le,detectorLimit:A.liveMrz.detectorLimit}).catch(()=>null),value:null};L.promise.then(ae=>{L.value=ae}),ie=L}y!==void 0&&ot(y.format,d.format==="ID-3"?"passport":"card")&&H({state:"mismatch",format:y.format});let P=`shot-${h+=1}`,T=s.current;R({type:"captured",id:P,at:u()});let w=s.lastShotVia,C=Ee();Be(C===void 0||s.lastShotVia===void 0?C:{...C,shotVia:s.lastShotVia},"captured"),fe=!0,We(C,y);let q=m===void 0?K:m===null?null:{quad:ar(m),frameWidth:0,frameHeight:0,inStill:!0},U={decoded:null},z=a(()=>(U.decoded??(U.decoded=Promise.resolve().then(()=>l(i)).catch(()=>null)),U.decoded),"O");try{await vt(P,T,i,o,q,z,ie,y,w)}finally{U.decoded!==null&&(await U.decoded)?.close()}},"Pt"),vt=a(async(i,o,m,y,f,P,T,w,C)=>{if(e.haptics!==!1)try{globalThis.navigator?.vibrate?.(30)}catch{}if(!D&&c>0){let z=await(t.measureSharpness!==void 0?t.measureSharpness(m,f):P().then(L=>L===null?-1:_e(L,be(f?.quad??null,f?.inStill===!0?L:{width:f?.frameWidth??0,height:f?.frameHeight??0},L)))).catch(()=>-1);if(!k)return;if(Number.isFinite(z)&&z>=0&&z<c){D=!0;let L=p?"recto":s.current??(s.captured.recto===void 0?"recto":"verso");R({type:"readFailed",side:L,id:i,issue:"blurry"}),te(),Y(L);return}}D=!1;let q;if(p)q="single";else{let z=w!==void 0&&w.format!=="TD3"&&(d.mrzSide==="recto"||d.mrzSide==="verso")?d.mrzSide:null,L=z===null&&t.classify===void 0?await ct(m,P):null,ae=L===null||G===null?L:Ct(L,G,s.captured),oe=z??ae??(ae===null&&G!==null&&o!==void 0?o:null),ve=oe!==null?null:await(t.classify!==void 0?t.classify(m):P().then(F=>F===null?o??"recto":f?.inStill===!0?Ge(F,nt(f.quad)):$e(F,480,be(f?.quad??null,{width:f?.frameWidth??0,height:f?.frameHeight??0},F)))).catch(()=>o??"recto"),wt=s.captured.recto===void 0&&s.captured.verso===void 0,Fe=oe??ve,Ne=!1,Mt=j!==null&&(W===null||typeof W=="object"&&"tier"in W);if(oe===null&&ve==="recto"&&wt&&d.mrzSide==="verso"&&Mt){let F=await mt(m,f);if(!k)return;F?.digest!==void 0&&me.set(i,F.digest),Fe=F?.side??null,Ne=F===null&&t.deferRead===!0}w!==void 0&&me.set(i,w.digest);let ye=w===void 0?void 0:["recto","verso"].find(F=>{let we=s.captured[F];return we!==void 0&&we!==i&&me.get(we)===w.digest});if(ye!==void 0){R({type:"duplicate",id:i,side:ye}),Y(ye==="recto"?"verso":"recto");return}let Q=oe??(ve==="recto"&&C!=="flip_timeout"&&s.captured.recto!==void 0&&s.captured.verso===void 0?"verso":Fe??"recto");if(!k)return;if(s.captured[Q]!==void 0&&g<er){g+=1,R({type:"duplicate",id:i,side:Q}),Y(Q==="recto"?"verso":"recto");return}let Ue=s.captured.recto===void 0?"recto":s.captured.verso===void 0?"verso":void 0;q=s.captured[Q]!==void 0&&Ue!==void 0?Ue:Q,g=0,R({type:"classified",id:i,side:q,...Ne?{unsure:!0}:{}}),ue()&&ee("second")}let U=q==="verso"?"verso":"recto";try{let z=t.encode!==void 0?await t.encode(m):await P().then(L=>{if(L===null)throw new Error("the still could not be decoded");return qt(L)});if(!k)return;T!==null&&De.set(z.blob,T),pe.set(z.blob,i),r.emit("captured",{image:z.blob,side:q,photo:X(i),documentType:e.documentType,...e.issuer!==void 0?{issuer:e.issuer}:{},width:z.width,height:z.height,previewDataUrl:y}),t.deferRead!==!0&&R({type:"readOk",side:U})}catch(z){R({type:"readFailed",side:U,id:i,issue:"technical"}),te(),r.emit("error",ne("generic",!0,{phase:"keyframes",name:Me(z)}))}Y(U==="recto"?"verso":"recto")},"Ot"),yt=a(i=>{Le.push(i.on("statechange",({state:o})=>{o==="preflight"||o==="acquiring"?_("starting"):o==="positioning"?_("scanning"):o==="captured"?_("captured"):o==="error"&&_("error")}),i.on("feedback",({key:o,reticle:m})=>r.emit("feedback",{key:o,reticle:m})),i.on("checks",o=>{r.emit("gate",{progress:o.p,quad:o.quad,frameWidth:o.frameWidth,frameHeight:o.frameHeight,...o.guide!==void 0?{guide:{detected:o.guide.detected,fill:o.guide.fill,offsetX:o.guide.offsetX??0,offsetY:o.guide.offsetY??0}}:{}});let m=o.ocr?.mrz;m!==void 0&&(m.state==="fallback"?H({state:"fallback",reason:m.reason}):m.state==="valid"?H({state:"valid",format:m.format}):m.state==="expired"?H({state:"expired",format:m.format}):m.state==="reading"?H({state:"reading",...m.format?{format:m.format}:{},...m.coach?{coach:m.coach}:{}}):H({state:"searching"}));let y=o.quad===null?0:or(o.quad,o.frameWidth,o.frameHeight);K=o.quad===null?null:{quad:o.quad,frameWidth:o.frameWidth,frameHeight:o.frameHeight},R({type:"report",report:{present:o.quad!==null&&o.plausible||o.guide?.detected===!0,ready:o.ready===!0,locking:o.ready===!0||o.locking===!0,areaFrac:y,...o.side!==void 0?{side:o.side}:{},...o.guide?.still!==void 0?{steady:o.guide.detected&&o.guide.still}:{}},at:u()})}),i.on("error",({kind:o,retryable:m,detail:y})=>r.emit("error",ne(o,m,y))),i.on("artifacts",o=>{gt(o.keyframe,o.previewDataUrl,o.docRegion,o.liveMrz)}))},"Et"),ge=a(()=>(S??(S=(async()=>{if(k){if(ze(),v===null){let i;try{i=await(t.createEngine??ir)({...t.engineOptions??{},...V!==void 0?{guide:V}:{},video:e.video,format:d.format,side:p?"single":e.side??"recto",autoCapture:!1,...re!==null?{ocr:re}:{},...b!==void 0&&!p&&d.mrzSide==="verso"?{sideProbe:!0}:{}})}catch(m){_("error"),r.emit("error",ne("models",!0,{phase:"models",name:Me(m)}));return}if(!k){i.destroy();return}v=i,de="base",M=p?"single":e.side??"recto",yt(i),ue()&&ee("second");let o=t.tickMs??500;o>0&&(Z=setInterval(()=>R({type:"tick",at:u()}),o))}R({type:"clockRestart"}),A!==null&&A.liveMrzOn&&(W==="unsupported"||W==="off")&&H({state:"fallback",reason:W}),await v.start()}})().finally(()=>{S=null})),S),"me");return{handle:{get state(){return x},on:a((i,o)=>r.on(i,o),"on"),start:ge,retry:a(()=>{if(v===null&&s.phase==="result"){R({type:"retake"}),g=0,D=!1,ge();return}if(v!==null&&x!=="error"){R({type:"retake"}),g=0,D=!1,ee("base"),M=p?"single":e.side??"recto",v.rearm(M);return}ge()},"retry"),setSide:a(i=>{p||i==="single"||v!==null&&s.current===i&&M===i&&s.phase!=="reading"&&s.phase!=="result"||(s.current!==i&&(s={...s,current:i}),R({type:"clockRestart"}),s.phase!=="reading"&&s.phase!=="result"&&v!==null&&(M=i,v.rearm(i)))},"setSide"),shutter:qe,focusAt:a((i,o)=>{v?.focusAt?.(i,o)},"focusAt"),setGuide:a(i=>{V=i,v?.setGuide?.(i)},"setGuide"),setTorch:a(i=>{B=i,v?.setTorch(i),R({type:"tick",at:u()})},"setTorch"),destroy:a(()=>{if(k&&v!==null&&x!=="done"){let i=Ee();!fe&&i!==void 0&&i.ticks>0&&Be(i,"abandoned"),We(i,void 0)}k=!1,Oe(),re?.setEngine(null),j?.dispose(),j=null,r.clear()},"destroy")},plan:d,setFlowState:a(i=>{(s.phase==="reading"||s.phase==="result")&&_(i==="done"&&s.phase!=="result"?"scanning":i)},"setFlowState"),settle:a((i,o,m)=>{let y=i==="verso"?"verso":"recto",f=m!==void 0?pe.get(m.image):s.unsure;if(f!==void 0&&s.captured.recto!==f&&s.captured.verso!==f&&!s.pending.includes(f))return;if(o.ok){let T=p?y:o.heldAs??y,w=s.phase;f!==void 0&&!p&&R({type:"held",id:f,side:T}),R({type:"readOk",side:T}),(w==="reading"||w==="result")&&s.phase!=="reading"&&s.phase!=="result"&&(te(),Y(s.current??(T==="recto"?"verso":"recto")));return}let P=s;R({type:"readFailed",side:y,...f!==void 0?{id:f}:{},issue:o.issue}),s!==P&&(te(),Y(y))},"settle"),takeDeviceRead:a(i=>De.get(i.image)?.value??null,"takeDeviceRead"),dropped:a(i=>{let o=pe.get(i.image);return o!==void 0&&!p&&s.captured.recto!==o&&s.captured.verso!==o&&!s.pending.includes(o)},"dropped")}}a(nr,"an");export{er as a,tr as b,rr as c,mr as d,hr as e,nr as f};
@@ -1 +1 @@
1
- import{a as j}from"./chunk-POVLMWGM.js";import{d as U}from"./chunk-YI34K4SS.js";import{L as k,M as I,a as A,b as V,c as h,v as T,w as _,y as C}from"./chunk-CUFOLAZN.js";import{a as n}from"./chunk-5QL6W6FW.js";import{a as s,c as N}from"./chunk-4FHWXBOB.js";var f=N(A(),1),e=N(V(),1);var D={"portrait.source.title":"كيف تريد إضافة صورتك الشخصية؟","portrait.source.description":"التقط صورة جديدة بالكاميرا، أو ارفع صورة حديثة من هذا الجهاز.","portrait.source.camera":"التقاط صورة","portrait.source.upload":"رفع صورة","portrait.source.uploadInstead":"رفع صورة بدلًا من ذلك","portrait.upload.title":"ارفع صورتك الشخصية","portrait.upload.hint":"صورة حديثة لوجهك، تنظر فيها مباشرة إلى الكاميرا، أمام جدار فاتح وبلون واحد.","portrait.upload.choose":"اختيار صورة","portrait.upload.unsupported":"اختر صورة بصيغة JPEG أو PNG أو HEIC.","portrait.upload.failed":"تعذّر إرسال هذه الصورة. حاول مرة أخرى.","portrait.review.title":"تحقّق من صورتك المعدّلة","portrait.review.description":"عدّلنا صورتك لتطابق قواعد صور الهوية. لم نغيّر وجهك.","portrait.review.original":"صورتك","portrait.review.fixed":"الصورة المعدّلة","portrait.review.fixesTitle":"ما الذي غيّرناه","portrait.review.accept":"استخدام هذه الصورة","portrait.review.retake":"إعادة الالتقاط","portrait.review.uploadAnother":"رفع صورة أخرى","portrait.fixes.crop":"قُصّت","portrait.fixes.scale":"غُيّر حجمها","portrait.fixes.straighten":"عُدّل ميلها","portrait.fixes.background":"استُبدلت الخلفية","portrait.fixes.exposure":"عُدّل السطوع","portrait.fixes.white_balance":"وُزنت الألوان","reasons.portrait_morph_suspected":"لا يمكن استخدام هذه الصورة. التقط صورة جديدة للشخص.","reasons.portrait_reference_mismatch":"لا تطابق الصورة المرجع. التقط صورة جديدة للشخص.","reasons.portrait_declined_fix":"التقط صورة أخرى أو ارفعها."},y={"portrait.source.title":"How do you want to add your ID photo?","portrait.source.description":"Take a new photo with the camera, or upload a recent photo from this device.","portrait.source.camera":"Take a photo","portrait.source.upload":"Upload a photo","portrait.source.uploadInstead":"Upload a photo instead","portrait.upload.title":"Upload your ID photo","portrait.upload.hint":"A recent photo of your face, looking straight at the camera, in front of a plain, light wall.","portrait.upload.choose":"Choose a photo","portrait.upload.unsupported":"Choose a JPEG, PNG or HEIC photo.","portrait.upload.failed":"We could not send this photo. Try again.","portrait.review.title":"Check your adjusted photo","portrait.review.description":"We adjusted your photo to meet the ID photo rules. Your face was not changed.","portrait.review.original":"Your photo","portrait.review.fixed":"Adjusted photo","portrait.review.fixesTitle":"What we changed","portrait.review.accept":"Use this photo","portrait.review.retake":"Take another","portrait.review.uploadAnother":"Upload another","portrait.fixes.crop":"Cropped","portrait.fixes.scale":"Resized","portrait.fixes.straighten":"Straightened","portrait.fixes.background":"Background replaced","portrait.fixes.exposure":"Brightness adjusted","portrait.fixes.white_balance":"Colours balanced","reasons.portrait_morph_suspected":"This photo cannot be used. Take a new photo of the person.","reasons.portrait_reference_mismatch":"The photo does not match the reference. Take a new photo of the person.","reasons.portrait_declined_fix":"Take or upload another photo."},G={"portrait.source.title":"Comment voulez-vous ajouter votre photo d'identité ?","portrait.source.description":"Prenez une nouvelle photo avec la caméra, ou importez une photo récente depuis cet appareil.","portrait.source.camera":"Prendre une photo","portrait.source.upload":"Importer une photo","portrait.source.uploadInstead":"Importer une photo à la place","portrait.upload.title":"Importez votre photo d'identité","portrait.upload.hint":"Une photo récente de votre visage, de face, devant un mur clair et uni.","portrait.upload.choose":"Choisir une photo","portrait.upload.unsupported":"Choisissez une photo JPEG, PNG ou HEIC.","portrait.upload.failed":"Nous n'avons pas pu envoyer cette photo. Réessayez.","portrait.review.title":"Vérifiez votre photo ajustée","portrait.review.description":"Nous avons ajusté votre photo pour qu'elle respecte les règles des photos d'identité. Votre visage n'a pas été modifié.","portrait.review.original":"Votre photo","portrait.review.fixed":"Photo ajustée","portrait.review.fixesTitle":"Ce que nous avons modifié","portrait.review.accept":"Utiliser cette photo","portrait.review.retake":"Reprendre","portrait.review.uploadAnother":"Importer une autre","portrait.fixes.crop":"Recadrée","portrait.fixes.scale":"Redimensionnée","portrait.fixes.straighten":"Redressée","portrait.fixes.background":"Fond remplacé","portrait.fixes.exposure":"Luminosité ajustée","portrait.fixes.white_balance":"Couleurs équilibrées","reasons.portrait_morph_suspected":"Cette photo ne peut pas être utilisée. Prenez une nouvelle photo de la personne.","reasons.portrait_reference_mismatch":"La photo ne correspond pas à la référence. Prenez une nouvelle photo de la personne.","reasons.portrait_declined_fix":"Prenez ou importez une autre photo."},H={en:y,fr:G,ar:D,es:y,pt:y,de:y},S="image/jpeg,image/png,image/heic,image/heif";function m(r){let o=r.strings,a=H[r.locale];return t=>o[t]??a[t]??""}s(m,"v");n(m,"portraitCopy");function b({step:r,i18n:o}){if(r.reason===void 0||r.reason==="portrait_fix_review")return null;let a=m(o)(`reasons.${r.reason}`)||o.t("portrait.retryTitle");return(0,e.jsxs)(k,{tone:"warning",children:[(0,e.jsx)("span",{children:a}),(0,e.jsx)("span",{children:I(o,r.attemptsRemaining,r.attemptsExhausted)})]})}s(b,"R");n(b,"ReasonNotice");function z({step:r,i18n:o,onCamera:a,onUpload:t}){let i=m(o),p=r.photo?.cameraOnPhone===!0;return(0,e.jsx)(j,{testId:"sekyro-portrait-source",title:i("portrait.source.title"),lead:i("portrait.source.description"),cameraLabel:p?o.t("capture.source.phone"):i("portrait.source.camera"),onPhone:p,uploadLabel:i("portrait.source.upload"),notice:(0,e.jsx)(b,{step:r,i18n:o}),onCamera:a,onUpload:t})}s(z,"z");n(z,"PortraitSourceView");function R({step:r,i18n:o,onCamera:a}){let t=m(o),i=(0,f.useRef)(null),[p,v]=(0,f.useState)("idle"),u=p==="sending",d=r.photo?.uploadOffered===!0,g=n(async c=>{let x=c.currentTarget.files?.[0];if(c.currentTarget.value="",x!==void 0){v("sending");try{await r.uploadPortrait(x),v("idle")}catch(w){v(w instanceof TypeError&&w.message==="unsupported_file"?"unsupported":"failed")}}},"onFile");return(0,e.jsxs)("section",{className:"sekyro-step","data-testid":"sekyro-portrait-upload-screen",children:[(0,e.jsx)(_,{title:t("portrait.upload.title"),lead:t("portrait.upload.hint")}),p==="idle"||p==="sending"?(0,e.jsx)(b,{step:r,i18n:o}):null,p==="unsupported"||p==="failed"?(0,e.jsx)(k,{tone:"warning",children:(0,e.jsx)("span",{children:t(p==="unsupported"?"portrait.upload.unsupported":"portrait.upload.failed")})}):null,u?(0,e.jsx)("p",{className:"sekyro-text-muted",role:"status","aria-busy":"true",children:o.t("portrait.uploading")}):null,(0,e.jsx)("input",{ref:i,type:"file",accept:S,hidden:!0,"data-testid":"sekyro-portrait-upload","aria-label":t("portrait.upload.title"),onChange:s(c=>{g(c)},"onChange")}),(0,e.jsxs)(C,{children:[(0,e.jsx)(h,{full:!0,onClick:s(()=>i.current?.click(),"onClick"),disabled:u||!d||r.attemptsExhausted,children:t("portrait.upload.choose")}),a!==void 0?(0,e.jsxs)(h,{full:!0,kind:"ghost",onClick:a,disabled:u,children:[(0,e.jsx)(T,{name:"camera"}),t("portrait.source.camera")]}):null]})]})}s(R,"A");n(R,"PortraitUploadView");function E({step:r,i18n:o,onDeclined:a}){let t=m(o),[i,p]=(0,f.useState)(!1),[v,u]=(0,f.useState)(!1),d=r.pendingFix;if(d==null)return null;let g=n(async l=>{p(!0),u(!1);try{await r.confirmFix(l),l||a?.()}catch{u(!0)}finally{p(!1)}},"answer"),c=r.photo?.source==="upload"?t("portrait.review.uploadAnother"):t("portrait.review.retake"),x=n(l=>t(`portrait.fixes.${l}`)||l,"fixName"),w=t("portrait.review.original"),P=t("portrait.review.fixed");return(0,e.jsxs)("section",{className:"sekyro-step","data-testid":"sekyro-portrait-review",children:[(0,e.jsx)(_,{title:t("portrait.review.title"),lead:t("portrait.review.description")}),(0,e.jsxs)("div",{className:"sekyro-portrait-pair",children:[(0,e.jsxs)("figure",{className:"sekyro-portrait-pair__item",children:[(0,e.jsx)("img",{src:d.originalUrl,alt:w}),(0,e.jsx)("figcaption",{className:"sekyro-text-muted",children:w})]}),(0,e.jsxs)("figure",{className:"sekyro-portrait-pair__item",children:[(0,e.jsx)("img",{src:d.fixedUrl,alt:P}),(0,e.jsx)("figcaption",{className:"sekyro-text-muted",children:P})]})]}),d.fixes.length>0?(0,e.jsxs)("div",{className:"sekyro-stack sekyro-stack--1",children:[(0,e.jsx)("p",{className:"sekyro-text-body",children:t("portrait.review.fixesTitle")}),(0,e.jsx)("ul",{className:"sekyro-portrait-fixes","data-testid":"sekyro-portrait-fixes",children:d.fixes.map(l=>(0,e.jsx)("li",{children:x(l)},l))})]}):null,v?(0,e.jsx)(k,{tone:"danger",children:(0,e.jsx)("span",{children:o.t("errors.network_error")})}):null,(0,e.jsxs)(C,{children:[(0,e.jsx)(h,{full:!0,onClick:s(()=>{g(!0)},"onClick"),disabled:i,"data-testid":"sekyro-portrait-accept",children:t("portrait.review.accept")}),(0,e.jsx)(h,{full:!0,kind:"ghost",onClick:s(()=>{g(!1)},"onClick"),disabled:i,"data-testid":"sekyro-portrait-decline",children:c})]})]})}s(E,"j");n(E,"PortraitReviewView");function q({screen:r,step:o,i18n:a,onCamera:t,onUpload:i,onDeclined:p}){return r==="phone"?(0,e.jsx)(U,{i18n:a,lead:a.t("handoff.lead.portrait"),refresh:o.refresh,actions:(0,e.jsx)(h,{kind:"ghost",full:!0,onClick:i,children:m(a)("portrait.source.upload")})}):r==="review"?(0,e.jsx)(E,{step:o,i18n:a,onDeclined:p}):r==="upload"?(0,e.jsx)(R,{step:o,i18n:a,...t!==void 0?{onCamera:t}:{}}):(0,e.jsx)(z,{step:o,i18n:a,onCamera:t??i,onUpload:i})}s(q,"Q");n(q,"PortraitScreens");export{m as a,z as b,R as c,E as d,q as e};
1
+ import{a as j}from"./chunk-POVLMWGM.js";import{d as U}from"./chunk-HM5EP25H.js";import{L as k,M as I,a as A,b as V,c as h,v as T,w as _,y as C}from"./chunk-CUFOLAZN.js";import{a as n}from"./chunk-5QL6W6FW.js";import{a as s,c as N}from"./chunk-4FHWXBOB.js";var f=N(A(),1),e=N(V(),1);var D={"portrait.source.title":"كيف تريد إضافة صورتك الشخصية؟","portrait.source.description":"التقط صورة جديدة بالكاميرا، أو ارفع صورة حديثة من هذا الجهاز.","portrait.source.camera":"التقاط صورة","portrait.source.upload":"رفع صورة","portrait.source.uploadInstead":"رفع صورة بدلًا من ذلك","portrait.upload.title":"ارفع صورتك الشخصية","portrait.upload.hint":"صورة حديثة لوجهك، تنظر فيها مباشرة إلى الكاميرا، أمام جدار فاتح وبلون واحد.","portrait.upload.choose":"اختيار صورة","portrait.upload.unsupported":"اختر صورة بصيغة JPEG أو PNG أو HEIC.","portrait.upload.failed":"تعذّر إرسال هذه الصورة. حاول مرة أخرى.","portrait.review.title":"تحقّق من صورتك المعدّلة","portrait.review.description":"عدّلنا صورتك لتطابق قواعد صور الهوية. لم نغيّر وجهك.","portrait.review.original":"صورتك","portrait.review.fixed":"الصورة المعدّلة","portrait.review.fixesTitle":"ما الذي غيّرناه","portrait.review.accept":"استخدام هذه الصورة","portrait.review.retake":"إعادة الالتقاط","portrait.review.uploadAnother":"رفع صورة أخرى","portrait.fixes.crop":"قُصّت","portrait.fixes.scale":"غُيّر حجمها","portrait.fixes.straighten":"عُدّل ميلها","portrait.fixes.background":"استُبدلت الخلفية","portrait.fixes.exposure":"عُدّل السطوع","portrait.fixes.white_balance":"وُزنت الألوان","reasons.portrait_morph_suspected":"لا يمكن استخدام هذه الصورة. التقط صورة جديدة للشخص.","reasons.portrait_reference_mismatch":"لا تطابق الصورة المرجع. التقط صورة جديدة للشخص.","reasons.portrait_declined_fix":"التقط صورة أخرى أو ارفعها."},y={"portrait.source.title":"How do you want to add your ID photo?","portrait.source.description":"Take a new photo with the camera, or upload a recent photo from this device.","portrait.source.camera":"Take a photo","portrait.source.upload":"Upload a photo","portrait.source.uploadInstead":"Upload a photo instead","portrait.upload.title":"Upload your ID photo","portrait.upload.hint":"A recent photo of your face, looking straight at the camera, in front of a plain, light wall.","portrait.upload.choose":"Choose a photo","portrait.upload.unsupported":"Choose a JPEG, PNG or HEIC photo.","portrait.upload.failed":"We could not send this photo. Try again.","portrait.review.title":"Check your adjusted photo","portrait.review.description":"We adjusted your photo to meet the ID photo rules. Your face was not changed.","portrait.review.original":"Your photo","portrait.review.fixed":"Adjusted photo","portrait.review.fixesTitle":"What we changed","portrait.review.accept":"Use this photo","portrait.review.retake":"Take another","portrait.review.uploadAnother":"Upload another","portrait.fixes.crop":"Cropped","portrait.fixes.scale":"Resized","portrait.fixes.straighten":"Straightened","portrait.fixes.background":"Background replaced","portrait.fixes.exposure":"Brightness adjusted","portrait.fixes.white_balance":"Colours balanced","reasons.portrait_morph_suspected":"This photo cannot be used. Take a new photo of the person.","reasons.portrait_reference_mismatch":"The photo does not match the reference. Take a new photo of the person.","reasons.portrait_declined_fix":"Take or upload another photo."},G={"portrait.source.title":"Comment voulez-vous ajouter votre photo d'identité ?","portrait.source.description":"Prenez une nouvelle photo avec la caméra, ou importez une photo récente depuis cet appareil.","portrait.source.camera":"Prendre une photo","portrait.source.upload":"Importer une photo","portrait.source.uploadInstead":"Importer une photo à la place","portrait.upload.title":"Importez votre photo d'identité","portrait.upload.hint":"Une photo récente de votre visage, de face, devant un mur clair et uni.","portrait.upload.choose":"Choisir une photo","portrait.upload.unsupported":"Choisissez une photo JPEG, PNG ou HEIC.","portrait.upload.failed":"Nous n'avons pas pu envoyer cette photo. Réessayez.","portrait.review.title":"Vérifiez votre photo ajustée","portrait.review.description":"Nous avons ajusté votre photo pour qu'elle respecte les règles des photos d'identité. Votre visage n'a pas été modifié.","portrait.review.original":"Votre photo","portrait.review.fixed":"Photo ajustée","portrait.review.fixesTitle":"Ce que nous avons modifié","portrait.review.accept":"Utiliser cette photo","portrait.review.retake":"Reprendre","portrait.review.uploadAnother":"Importer une autre","portrait.fixes.crop":"Recadrée","portrait.fixes.scale":"Redimensionnée","portrait.fixes.straighten":"Redressée","portrait.fixes.background":"Fond remplacé","portrait.fixes.exposure":"Luminosité ajustée","portrait.fixes.white_balance":"Couleurs équilibrées","reasons.portrait_morph_suspected":"Cette photo ne peut pas être utilisée. Prenez une nouvelle photo de la personne.","reasons.portrait_reference_mismatch":"La photo ne correspond pas à la référence. Prenez une nouvelle photo de la personne.","reasons.portrait_declined_fix":"Prenez ou importez une autre photo."},H={en:y,fr:G,ar:D,es:y,pt:y,de:y},S="image/jpeg,image/png,image/heic,image/heif";function m(r){let o=r.strings,a=H[r.locale];return t=>o[t]??a[t]??""}s(m,"v");n(m,"portraitCopy");function b({step:r,i18n:o}){if(r.reason===void 0||r.reason==="portrait_fix_review")return null;let a=m(o)(`reasons.${r.reason}`)||o.t("portrait.retryTitle");return(0,e.jsxs)(k,{tone:"warning",children:[(0,e.jsx)("span",{children:a}),(0,e.jsx)("span",{children:I(o,r.attemptsRemaining,r.attemptsExhausted)})]})}s(b,"R");n(b,"ReasonNotice");function z({step:r,i18n:o,onCamera:a,onUpload:t}){let i=m(o),p=r.photo?.cameraOnPhone===!0;return(0,e.jsx)(j,{testId:"sekyro-portrait-source",title:i("portrait.source.title"),lead:i("portrait.source.description"),cameraLabel:p?o.t("capture.source.phone"):i("portrait.source.camera"),onPhone:p,uploadLabel:i("portrait.source.upload"),notice:(0,e.jsx)(b,{step:r,i18n:o}),onCamera:a,onUpload:t})}s(z,"z");n(z,"PortraitSourceView");function R({step:r,i18n:o,onCamera:a}){let t=m(o),i=(0,f.useRef)(null),[p,v]=(0,f.useState)("idle"),u=p==="sending",d=r.photo?.uploadOffered===!0,g=n(async c=>{let x=c.currentTarget.files?.[0];if(c.currentTarget.value="",x!==void 0){v("sending");try{await r.uploadPortrait(x),v("idle")}catch(w){v(w instanceof TypeError&&w.message==="unsupported_file"?"unsupported":"failed")}}},"onFile");return(0,e.jsxs)("section",{className:"sekyro-step","data-testid":"sekyro-portrait-upload-screen",children:[(0,e.jsx)(_,{title:t("portrait.upload.title"),lead:t("portrait.upload.hint")}),p==="idle"||p==="sending"?(0,e.jsx)(b,{step:r,i18n:o}):null,p==="unsupported"||p==="failed"?(0,e.jsx)(k,{tone:"warning",children:(0,e.jsx)("span",{children:t(p==="unsupported"?"portrait.upload.unsupported":"portrait.upload.failed")})}):null,u?(0,e.jsx)("p",{className:"sekyro-text-muted",role:"status","aria-busy":"true",children:o.t("portrait.uploading")}):null,(0,e.jsx)("input",{ref:i,type:"file",accept:S,hidden:!0,"data-testid":"sekyro-portrait-upload","aria-label":t("portrait.upload.title"),onChange:s(c=>{g(c)},"onChange")}),(0,e.jsxs)(C,{children:[(0,e.jsx)(h,{full:!0,onClick:s(()=>i.current?.click(),"onClick"),disabled:u||!d||r.attemptsExhausted,children:t("portrait.upload.choose")}),a!==void 0?(0,e.jsxs)(h,{full:!0,kind:"ghost",onClick:a,disabled:u,children:[(0,e.jsx)(T,{name:"camera"}),t("portrait.source.camera")]}):null]})]})}s(R,"A");n(R,"PortraitUploadView");function E({step:r,i18n:o,onDeclined:a}){let t=m(o),[i,p]=(0,f.useState)(!1),[v,u]=(0,f.useState)(!1),d=r.pendingFix;if(d==null)return null;let g=n(async l=>{p(!0),u(!1);try{await r.confirmFix(l),l||a?.()}catch{u(!0)}finally{p(!1)}},"answer"),c=r.photo?.source==="upload"?t("portrait.review.uploadAnother"):t("portrait.review.retake"),x=n(l=>t(`portrait.fixes.${l}`)||l,"fixName"),w=t("portrait.review.original"),P=t("portrait.review.fixed");return(0,e.jsxs)("section",{className:"sekyro-step","data-testid":"sekyro-portrait-review",children:[(0,e.jsx)(_,{title:t("portrait.review.title"),lead:t("portrait.review.description")}),(0,e.jsxs)("div",{className:"sekyro-portrait-pair",children:[(0,e.jsxs)("figure",{className:"sekyro-portrait-pair__item",children:[(0,e.jsx)("img",{src:d.originalUrl,alt:w}),(0,e.jsx)("figcaption",{className:"sekyro-text-muted",children:w})]}),(0,e.jsxs)("figure",{className:"sekyro-portrait-pair__item",children:[(0,e.jsx)("img",{src:d.fixedUrl,alt:P}),(0,e.jsx)("figcaption",{className:"sekyro-text-muted",children:P})]})]}),d.fixes.length>0?(0,e.jsxs)("div",{className:"sekyro-stack sekyro-stack--1",children:[(0,e.jsx)("p",{className:"sekyro-text-body",children:t("portrait.review.fixesTitle")}),(0,e.jsx)("ul",{className:"sekyro-portrait-fixes","data-testid":"sekyro-portrait-fixes",children:d.fixes.map(l=>(0,e.jsx)("li",{children:x(l)},l))})]}):null,v?(0,e.jsx)(k,{tone:"danger",children:(0,e.jsx)("span",{children:o.t("errors.network_error")})}):null,(0,e.jsxs)(C,{children:[(0,e.jsx)(h,{full:!0,onClick:s(()=>{g(!0)},"onClick"),disabled:i,"data-testid":"sekyro-portrait-accept",children:t("portrait.review.accept")}),(0,e.jsx)(h,{full:!0,kind:"ghost",onClick:s(()=>{g(!1)},"onClick"),disabled:i,"data-testid":"sekyro-portrait-decline",children:c})]})]})}s(E,"j");n(E,"PortraitReviewView");function q({screen:r,step:o,i18n:a,onCamera:t,onUpload:i,onDeclined:p}){return r==="phone"?(0,e.jsx)(U,{i18n:a,lead:a.t("handoff.lead.portrait"),refresh:o.refresh,actions:(0,e.jsx)(h,{kind:"ghost",full:!0,onClick:i,children:m(a)("portrait.source.upload")})}):r==="review"?(0,e.jsx)(E,{step:o,i18n:a,onDeclined:p}):r==="upload"?(0,e.jsx)(R,{step:o,i18n:a,...t!==void 0?{onCamera:t}:{}}):(0,e.jsx)(z,{step:o,i18n:a,onCamera:t??i,onUpload:i})}s(q,"Q");n(q,"PortraitScreens");export{m as a,z as b,R as c,E as d,q as e};
@@ -1,3 +1,3 @@
1
- import{A as Qe,B as Xe,C as et,H as me,I as ee,J as tt,K as nt,L as rt,a as U,b as je,c as Ke,f as Be,g as Ve,h as He,i as $e,j as pe,k as ze,m as F,o as N,p as q,q as $,r as X,s as D,t as fe,v as Ze,w as We,x as Je,y as Ye}from"./chunk-67YJZR73.js";import{g as at}from"./chunk-4QUL7TEF.js";import{b as Ge}from"./chunk-WICQIC37.js";import{b as qe,c as de,e as it}from"./chunk-6MYG4HWP.js";import{a as t}from"./chunk-4FHWXBOB.js";function Ot(n){let i=n.now??(()=>Date.now()),f=n.setTimer??((A,c)=>setTimeout(A,c)),m=n.clearTimer??(A=>clearTimeout(A)),_=null,b=!1,d=!1,M=!1,j=0,P=null,C=t(()=>{P!==null&&m(P),P=null},"_"),S=t(()=>{let A=n.armRamp;A===void 0||b||d||M||i()<j||(b=!0,A().catch(()=>{}).then(c=>{if(b=!1,!M){if(c===void 0){j=i()+2e3;return}if(c.challenge===void 0){d=!0;return}_={challenge:c.challenge,expiresAt:c.expiresAt},C(),P=f(()=>{P=null,!M&&_!==null&&n.waiting()&&S()},Math.max(1e3,c.expiresAt-i()-2e4))}}))},"R");return{arm(){_!==null&&_.expiresAt-i()>2e4||S()},take(){let A=_;return _=null,C(),A!==null&&A.expiresAt-i()>=12e3?A.challenge:void 0},stop(){M=!0,_=null,C()}}}t(Ot,"St");function Dt(n){return n.idNumberBound??n.nniBound}t(Dt,"ue");function ot(n){return n===void 0?void 0:n.idNumberFromDocument??n.nniFromDocument}t(ot,"ee");var ct="https://api.sekyro.ai",Lt=5e3,Ut=24e4,dt=3e4,pt=9e4;function st(n,i){return n==="portrait_icao"||n==="poa"||n==="doc_ocr"&&i.source==="upload"?pt:dt}t(st,"kt");var Ft=25*6e4,qt=20*6e4,Gt=3,jt=3e3,Kt=1500,Bt=10;function lt(n){return n instanceof Error&&n.name==="ChallengeError"&&n.code||"challenge_failed"}t(lt,"Ct");var ut=new Set(["aborted","embedder_opaque","site_key_rejected","clock_wrong"]);function Vt(n){return new Promise(i=>setTimeout(i,n))}t(Vt,"pn");function Ht(){let n=globalThis.crypto;if(n!==void 0&&typeof n.randomUUID=="function")return n.randomUUID();let i=new Uint8Array(16);if(n!==void 0&&typeof n.getRandomValues=="function")n.getRandomValues(i);else for(let m=0;m<16;m+=1)i[m]=Math.floor(Math.random()*256);i[6]=(i[6]??0)&15|64,i[8]=(i[8]??0)&63|128;let f=[...i].map(m=>m.toString(16).padStart(2,"0")).join("");return`${f.slice(0,8)}-${f.slice(8,12)}-${f.slice(12,16)}-${f.slice(16,20)}-${f.slice(20)}`}t(Ht,"fn");function $t(n){return zt(n,{})}t($t,"Oo");function zt(n,i){let f=n.apiOrigin??ct,m=n.autoRetry??!0,_=n.rearm??"auto",b=i.client??new Ke({apiOrigin:f,sessionToken:n.clientToken,fetch:n.fetch,locale:n.locale}),d=new Proxy(b,{get(e,r){if(r==="submitCheck")return wt;let a=Reflect.get(e,r,e);return typeof a=="function"?a.bind(e):a}}),M=i.sleep??Vt,j=i.uuid??Ht,P=i.getChallengeToken??((e,r)=>import("./challenge-frame-YBTLAQ5G-NN763UU5.js").then(a=>a.executeChallenge({frameUrl:e.url,siteKey:e.siteKey,action:"liveness",subject:r.subject,signal:r.signal}))),C=it(),S=null,A=null,c=!1,ve=new AbortController,h=null,z=null,Z=null,W=t(()=>Z??tt(h),"ne"),J=t(()=>nt(ee(h),W()),"oe"),T=t(e=>{h=e,!N(e)&&(Re(qt)||bt(e))&&ue(e),C.emit("view",e),S?.onView(e)},"I"),k=t(()=>h!==null?Promise.resolve(h):(z??(z=d.getSession().then(e=>(T(e),e)).finally(()=>{z=null})),z),"P"),x=t(async()=>{let e=await d.getSession();return T(e),e},"v"),te=t(async(e,r)=>{e.plan!==void 0?T(e):await x()},"le"),Y=null,ge=t(async e=>{let r=await k();if(e||!r.consentRecorded){let a=await d.recordConsent(n.locale);a.plan!==void 0?T(a):h!==null&&T({...h,consentRecorded:!0})}Q()&&ue(r)},"Me"),R=t(e=>e?.force===!0?ge(!0):(Y??(Y=ge(!1).finally(()=>{Y=null})),Y),"N"),ne={client:d,ensureConsent:t(e=>R(e),"ensureConsent"),sleep:M,uuid:j,...i.random!==void 0?{random:i.random}:{},onBusy:t(e=>{c||C.emit("busy",e)},"onBusy")},_e=!1,be=null,re=t(e=>{if(e.status==="verified"||e.status==="not_verified"||e.status==="review"){if(_e)return;_e=!0}be=JSON.stringify(e),C.emit("result",e)},"me"),vt=t(e=>{be!==JSON.stringify(e)&&re(e)},"Ut"),ke=t(async e=>{let r=h;e&&(r=await x().catch(()=>h));let a=r===null?null:F(r);return a!==null&&!c&&C.emit("method",a),a!==null},"Ie"),ie=null,we=!1,Ae=!1,Ce=t(()=>Qe(ne,(e,r)=>e.submitCheck("population_registry",{},{idempotencyKey:r})),"Fe"),Me=t(e=>Dt(e)===!0||ot($(e,"population_registry"))===!0,"Ne"),gt=t(async()=>{try{let e=await k();if(N(e)||F(e)!==null||q(e)?.checkType!=="population_registry")return;if(!Me(e)&&ot($(e,"population_registry"))===void 0&&(e=await x()),!Me(e)){Ae=!0;return}await R(),await te(await Ce(),"population_registry");let r=h===null?void 0:$(h,"population_registry");if(r?.state==="input_required"&&r.reason==="registry_unavailable"&&ze(r)>0){if(await M(Lt),c)return;await te(await Ce(),"population_registry")}}catch(e){if(e instanceof U&&(e.code==="check_not_active"||e.code==="step_not_on_path")){await x().catch(()=>{});return}we=!0;return}h!==null&&N(h)&&re(fe(h,{autoRetry:m}))},"Bt"),Se=t(()=>(ie??(ie=gt()),ie),"He"),I=i.now??Date.now,L=null,K,ae,_t=0,oe=t((e,r)=>`${e.url}
1
+ import{A as Qe,B as Xe,C as et,H as me,I as ee,J as tt,K as nt,L as rt,a as U,b as je,c as Ke,f as Be,g as Ve,h as He,i as $e,j as pe,k as ze,m as F,o as N,p as q,q as $,r as X,s as D,t as fe,v as Ze,w as We,x as Je,y as Ye}from"./chunk-4RREQCYP.js";import{g as at}from"./chunk-RVPBL3KC.js";import{b as Ge}from"./chunk-RCDZUOGM.js";import{b as qe,c as de,e as it}from"./chunk-6MYG4HWP.js";import{a as t}from"./chunk-4FHWXBOB.js";function Ot(n){let i=n.now??(()=>Date.now()),f=n.setTimer??((A,c)=>setTimeout(A,c)),m=n.clearTimer??(A=>clearTimeout(A)),_=null,b=!1,d=!1,M=!1,j=0,P=null,C=t(()=>{P!==null&&m(P),P=null},"_"),S=t(()=>{let A=n.armRamp;A===void 0||b||d||M||i()<j||(b=!0,A().catch(()=>{}).then(c=>{if(b=!1,!M){if(c===void 0){j=i()+2e3;return}if(c.challenge===void 0){d=!0;return}_={challenge:c.challenge,expiresAt:c.expiresAt},C(),P=f(()=>{P=null,!M&&_!==null&&n.waiting()&&S()},Math.max(1e3,c.expiresAt-i()-2e4))}}))},"R");return{arm(){_!==null&&_.expiresAt-i()>2e4||S()},take(){let A=_;return _=null,C(),A!==null&&A.expiresAt-i()>=12e3?A.challenge:void 0},stop(){M=!0,_=null,C()}}}t(Ot,"St");function Dt(n){return n.idNumberBound??n.nniBound}t(Dt,"ue");function ot(n){return n===void 0?void 0:n.idNumberFromDocument??n.nniFromDocument}t(ot,"ee");var ct="https://api.sekyro.ai",Lt=5e3,Ut=24e4,dt=3e4,pt=9e4;function st(n,i){return n==="portrait_icao"||n==="poa"||n==="doc_ocr"&&i.source==="upload"?pt:dt}t(st,"kt");var Ft=25*6e4,qt=20*6e4,Gt=3,jt=3e3,Kt=1500,Bt=10;function lt(n){return n instanceof Error&&n.name==="ChallengeError"&&n.code||"challenge_failed"}t(lt,"Ct");var ut=new Set(["aborted","embedder_opaque","site_key_rejected","clock_wrong"]);function Vt(n){return new Promise(i=>setTimeout(i,n))}t(Vt,"pn");function Ht(){let n=globalThis.crypto;if(n!==void 0&&typeof n.randomUUID=="function")return n.randomUUID();let i=new Uint8Array(16);if(n!==void 0&&typeof n.getRandomValues=="function")n.getRandomValues(i);else for(let m=0;m<16;m+=1)i[m]=Math.floor(Math.random()*256);i[6]=(i[6]??0)&15|64,i[8]=(i[8]??0)&63|128;let f=[...i].map(m=>m.toString(16).padStart(2,"0")).join("");return`${f.slice(0,8)}-${f.slice(8,12)}-${f.slice(12,16)}-${f.slice(16,20)}-${f.slice(20)}`}t(Ht,"fn");function $t(n){return zt(n,{})}t($t,"Oo");function zt(n,i){let f=n.apiOrigin??ct,m=n.autoRetry??!0,_=n.rearm??"auto",b=i.client??new Ke({apiOrigin:f,sessionToken:n.clientToken,fetch:n.fetch,locale:n.locale}),d=new Proxy(b,{get(e,r){if(r==="submitCheck")return wt;let a=Reflect.get(e,r,e);return typeof a=="function"?a.bind(e):a}}),M=i.sleep??Vt,j=i.uuid??Ht,P=i.getChallengeToken??((e,r)=>import("./challenge-frame-FGQBS3HD-S3UO5OUT.js").then(a=>a.executeChallenge({frameUrl:e.url,siteKey:e.siteKey,action:"liveness",subject:r.subject,signal:r.signal}))),C=it(),S=null,A=null,c=!1,ve=new AbortController,h=null,z=null,Z=null,W=t(()=>Z??tt(h),"ne"),J=t(()=>nt(ee(h),W()),"oe"),T=t(e=>{h=e,!N(e)&&(Re(qt)||bt(e))&&ue(e),C.emit("view",e),S?.onView(e)},"I"),k=t(()=>h!==null?Promise.resolve(h):(z??(z=d.getSession().then(e=>(T(e),e)).finally(()=>{z=null})),z),"P"),x=t(async()=>{let e=await d.getSession();return T(e),e},"v"),te=t(async(e,r)=>{e.plan!==void 0?T(e):await x()},"le"),Y=null,ge=t(async e=>{let r=await k();if(e||!r.consentRecorded){let a=await d.recordConsent(n.locale);a.plan!==void 0?T(a):h!==null&&T({...h,consentRecorded:!0})}Q()&&ue(r)},"Me"),R=t(e=>e?.force===!0?ge(!0):(Y??(Y=ge(!1).finally(()=>{Y=null})),Y),"N"),ne={client:d,ensureConsent:t(e=>R(e),"ensureConsent"),sleep:M,uuid:j,...i.random!==void 0?{random:i.random}:{},onBusy:t(e=>{c||C.emit("busy",e)},"onBusy")},_e=!1,be=null,re=t(e=>{if(e.status==="verified"||e.status==="not_verified"||e.status==="review"){if(_e)return;_e=!0}be=JSON.stringify(e),C.emit("result",e)},"me"),vt=t(e=>{be!==JSON.stringify(e)&&re(e)},"Ut"),ke=t(async e=>{let r=h;e&&(r=await x().catch(()=>h));let a=r===null?null:F(r);return a!==null&&!c&&C.emit("method",a),a!==null},"Ie"),ie=null,we=!1,Ae=!1,Ce=t(()=>Qe(ne,(e,r)=>e.submitCheck("population_registry",{},{idempotencyKey:r})),"Fe"),Me=t(e=>Dt(e)===!0||ot($(e,"population_registry"))===!0,"Ne"),gt=t(async()=>{try{let e=await k();if(N(e)||F(e)!==null||q(e)?.checkType!=="population_registry")return;if(!Me(e)&&ot($(e,"population_registry"))===void 0&&(e=await x()),!Me(e)){Ae=!0;return}await R(),await te(await Ce(),"population_registry");let r=h===null?void 0:$(h,"population_registry");if(r?.state==="input_required"&&r.reason==="registry_unavailable"&&ze(r)>0){if(await M(Lt),c)return;await te(await Ce(),"population_registry")}}catch(e){if(e instanceof U&&(e.code==="check_not_active"||e.code==="step_not_on_path")){await x().catch(()=>{});return}we=!0;return}h!==null&&N(h)&&re(fe(h,{autoRetry:m}))},"Bt"),Se=t(()=>(ie??(ie=gt()),ie),"He"),I=i.now??Date.now,L=null,K,ae,_t=0,oe=t((e,r)=>`${e.url}
2
2
  ${e.siteKey}
3
- ${r}`,"ye"),Te=0,se,le=t((e,r)=>{Te+=1;let a=I(),u=P(e,{signal:ve.signal,subject:r}),s={key:oe(e,r),at:a,token:u};return u.then(()=>{s.issuedAt=I(),ae=void 0},p=>{let l=lt(p);if(s.failed=l,c||l==="aborted")return;ae=l;let{detail:y,readyMs:o}=p;B({check:"attestation",kind:"unavailable",engineKind:l,attempt:_t++,challengeMs:I()-a,readyMs:o,detail:y,inApp:Ge()})}),u.catch(()=>{}),s},"Se"),xe=t((e,r)=>e!==null&&e.key===r&&(e.issuedAt===void 0||I()-e.issuedAt<Ut),"De"),ue=t((e,r={})=>{let a=e?.challenge??null;if(e===null||a===null||c)return;let u=X(e.sessionId),s=L;(r.replaceFailed===!0&&s?.failed!==void 0&&!ut.has(s.failed)||!xe(s,oe(a,u)))&&(L=le(a,u))},"_e"),Ie=t(async(e,r,a)=>{let u=oe(e,r),s=L;L=null;let p=xe(s,u)?s:le(e,r),l=p===s?0:1,y,o=new Promise(v=>{y=setTimeout(()=>v("late"),a)});try{for(;;){let v=await Promise.race([p.token.then(w=>({token:w}),w=>({error:lt(w)})),o]);if(v==="late")return!c&&L===null&&(L=p),{error:ae??"timeout"};if("token"in v)return se=Math.max(0,Math.round((p.issuedAt??I())-p.at)),v;if(c||ut.has(v.error)||l>=Gt||l>0&&await Promise.race([M(jt*l),o])==="late")return v;if(c)return{error:"aborted"};l+=1,p=le(e,r)}}finally{clearTimeout(y)}},"Ue"),O=null,bt=t(e=>pe(e).some(r=>(r.checkType==="phone_otp"||r.checkType==="email_otp")&&r.state!=="passed"&&r.state!=="skipped"),"Gt"),Re=t(e=>O===null||I()-O>=e,"Be"),Q=t(()=>Re(Ft),"re"),kt=t(e=>{let r=e.attestation;return typeof r?.turnstileToken=="string"&&r.turnstileToken.length>0},"Kt"),Ee=new Map,Ne=t(async e=>{let r=await k(),a=r.challenge;if(a==null||r.simulation!==void 0)return;let u=await Ie(a,X(r.sessionId),e);if(!("token"in u))throw Ye(u.error);return u.token},"Ge"),wt=t(async(e,r,a={})=>{let u=r;if("attestation"in u)try{let o=await b.submitCheck(e,r,a);return kt(u)&&(O=I()),o}catch(o){throw o instanceof U&&o.code==="attestation_invalid"&&(O=null),o}let s=(e==="phone_otp"||e==="email_otp")&&u.action!=="verify",p=a.idempotencyKey,l=p!==void 0?Ee.get(p):void 0;l===void 0&&(s||Q())&&(l=await Ne(st(e,u)),p!==void 0&&l!==void 0&&Ee.set(p,l));let y=t((o,v)=>o!==void 0?{...v,browserCheckToken:o}:v,"b");try{let o=await b.submitCheck(e,r,y(l,a));return l!==void 0&&(O=I()),o}catch(o){if(!(o instanceof U)||o.code!=="attestation_invalid"||(O=null,l!==void 0))throw o;let v=await Ne(st(e,u)),w=p!==void 0?{...a,idempotencyKey:j()}:a,E=await b.submitCheck(e,r,y(v,w));return v!==void 0&&(O=I()),E}},"jt"),Pe=t(async(e={})=>{if(K=void 0,e.always!==!0&&!Q())return{};let r=await k(),a=r.challenge;if(a==null)return{};let u=e.always===!0?pt:dt,s=await Ie(a,X(r.sessionId),u);if("token"in s)return{channel:"hosted_web",turnstileToken:s.token};if(K=s.error,r.simulation!==void 0)return{channel:"hosted_web"};throw new Je(s.error)},"Ke"),At=t(()=>K,"Yt"),Ct=t(()=>({checks:Math.min(50,Te),...se!==void 0?{challengeMs:Math.min(6e5,se)}:{}}),"Wt"),B=t(e=>{if(c)return;let r=d.reportCaptureIssue;if(r===void 0)return;let a=e.formFactor;try{a??(a=qe())}catch{}try{Promise.resolve(r.call(d,{...e,...a!==void 0?{formFactor:a}:{}})).catch(()=>{})}catch{}},"Y"),g=null,V=null,Oe=new WeakMap,De=Promise.resolve(),H=0,Mt=t(async()=>{let e=await k();for(let r=0;r<Bt&&!c&&!N(e)&&q(e)===void 0&&pe(e).some(a=>a.state==="processing")&&(await M(Kt),!c);r+=1)e=await x();return e},"$t"),St=t(async(e,r,a)=>{let{capture:u}=e,s=t(()=>c,"m"),p=t(()=>e.alive&&e.attempt===a,"C"),l=t(o=>{p()&&u.setFlowState(o)},"h"),y=t(o=>{if(!s()&&(o.status==="unavailable"&&o.reasonCode!==void 0&&!Be(o.reasonCode)&&B({check:"liveness",kind:"unavailable",phase:"upload",engineKind:o.reasonCode,attempt:Math.max(0,e.issues.value)}),re(o),!!p())){if(o.status==="retry"&&_==="auto"){u.handle.retry();return}u.setFlowState("done")}},"b");if(r.degraded==="NO_RECORDER"){let o=h?.sessionId??(await k().catch(()=>null))?.sessionId??"";y(D(o,"no_recorder"));return}l("uploading");try{if(await Se(),s())return;let o=await k(),v;if(!N(o)&&F(o)!==null){await ke(!1),y(D(o.sessionId,"method_required"));return}if(!N(o)){if(q(o)?.checkType==="population_registry"){y(D(o.sessionId,Ae?"nni_unbound":we?"network":"registry_unavailable"));return}if(await R(),s())return;v=h??o;let w=await Xe({...ne,artifacts:r,getAttestation:Pe,attestationError:At,attestationFacts:Ct,clipKeys:{get:t(()=>Oe.get(r)??null,"get"),set:t(E=>{Oe.set(r,E)},"set")},getView:t(()=>h??o,"getView"),refreshView:x,applySubmit:te,onPhase:l,isCancelled:s,onKeyframePromoted:t(E=>{A=E},"onKeyframePromoted")});if(s())return;if(w.kind==="unavailable"){w.reason==="attestation"&&(V={bound:e,artifacts:r});let E=D(o.sessionId,w.reason),Fe=w.reason==="attestation"?K:void 0;y(Fe!==void 0?{...E,attestationError:Fe}:E);return}if(w.kind==="resync"&&await x(),h!==null&&F(h)!==null){await ke(!1),y(D(o.sessionId,"method_required"));return}o=await Mt()}y(fe(o,{autoRetry:m,previous:v}))}catch{if(s())return;y(D(h?.sessionId??"","network"))}},"Qt"),Le=t((e,r)=>{let a=e.attempt;H>0&&e.alive&&e.capture.setFlowState("uploading"),H+=1,De=De.then(()=>St(e,r,a)).finally(()=>{H-=1,H===0&&S?.onChainIdle()}).catch(()=>{})},"We"),Ue=t(e=>{g?.capture.handle.destroy(),g!==null&&(g.alive=!1,g.ramp.stop());let r=Ot({armRamp:typeof d.armRamp=="function"?()=>d.armRamp():void 0,waiting:t(()=>s.alive&&J()==="self"&&(u.handle.state==="starting"||u.handle.state==="gating"),"waiting")}),a=Promise.resolve(),u=at(e,S?.captureInternals?.(e)??i.capture,()=>h?.capture?.liveness?.keyframe?.rank===!0,J,()=>r.take()??h?.capture?.liveness?.screenRamp,{session:t(()=>ee(h),"session"),onModeChange:t(l=>{Z=l},"onModeChange")}),s={capture:u,alive:!0,ramp:r,attempt:0,issues:He()};g=s,u.handle.on("error",l=>{B(Ve("liveness",l,s.issues.value))}),u.handle.on("state",l=>{if(s.issues.note(l),l==="starting"){s.attempt+=1,V?.bound===s&&(V=null),Q()&&ue(h,{replaceFailed:!0});let y=h===null?void 0:q(h)?.checkType;a=y==="liveness"||y==="face_match"?R().catch(()=>{}):Promise.resolve()}(l==="starting"||l==="gating")&&J()==="self"&&a.then(()=>{s.alive&&r.arm()})}),u.handle.on("captured",l=>{Promise.resolve().then(()=>Le(s,l))});let p=u.handle;return{get state(){return p.state},get captureMode(){return p.captureMode},get facingMode(){return p.facingMode},on:t((l,y)=>p.on(l,y),"on"),start:t(async l=>{if(h===null&&await k().catch(()=>{}),!!s.alive)return p.start(l)},"start"),retry:t(()=>{let l=V;if(l!==null&&l.bound===s&&s.alive){V=null,Le(s,l.artifacts);return}p.retry()},"retry"),switchCamera:t(()=>p.switchCamera(),"switchCamera"),canSwitchCaptureMode:t(()=>p.canSwitchCaptureMode(),"canSwitchCaptureMode"),setCaptureMode:t(l=>p.setCaptureMode(l),"setCaptureMode"),destroy:t(()=>{s.alive=!1,r.stop(),g===s&&(g=null),p.destroy()},"destroy")}},"$e"),Tt=t(async()=>{if(c)return null;try{let e=await k();return c?null:F(e)}catch{return null}},"Zt"),xt=t(async()=>{if(c)return"self";try{let e=await k();if(c)return"self";let r=ee(e);return r==="choice"?W()??r:r}catch{return"self"}},"Jt"),It=t(async()=>{if(c)return!1;try{let e=await k();return c||N(e)||de()?!1:me(e,q(e))==="phone"||me(e,$(e,"liveness"))==="phone"}catch{return!1}},"Xt"),Rt=t(async()=>{if(c)return!1;try{let e=await k();return!c&&e.returning===!0}catch{return!1}},"zt"),Et=t(async e=>{let r=(await k()).plan?.choice,a=r?.options.find(s=>$e[s.service]===e);if(!a)throw new RangeError(`method ${String(e)} is not offered`);let u=await d.choose(r.nodeId,a.id);c||T(u)},"en"),ce=null,Nt=t(()=>(ce??(ce=import("./plan-runner-HOMYGD6Y-GMUP34K3.js").then(e=>{let r=e.createPlanRunner({runtime:ne,currentView:t(()=>h,"currentView"),cameraMode:J,captureModeSwitch:{pick:W,choose:t(a=>{Z=a},"choose")},ensureView:k,refreshView:x,ensureConsent:t(()=>R(),"ensureConsent"),liveness:Ue,stopLiveness:t(()=>{g!==null&&(g.alive=!1,g.ramp.stop(),g.capture.handle.destroy(),g=null)},"stopLiveness"),chainBusy:t(()=>H>0,"chainBusy"),destroyed:t(()=>c,"destroyed"),sleep:M,isMobile:de,now:i.now??Date.now,keptFaceKey:t(()=>A,"keptFaceKey"),setView:T,baseCapture:i.capture,emitStep:t(a=>{c||C.emit("step",a)},"emitStep"),emitResult:vt,reportCaptureIssue:B,documentInternals:i.document,documentFacts:i.documentFacts,portraitInternals:i.portrait,livePhotoInternals:i.livePhoto,uploadInternals:i.upload,pageCameraInternals:i.pageCamera});return S=r,r})),ce),"tn");return{consent:t(()=>R(),"consent"),startRegistry:Se,methodChoice:Tt,selectMethod:Et,reportCameraUnavailable:t(async e=>{await R();let r=d.reportCameraUnavailable;if(r===void 0)throw new TypeError("this client cannot report a missing camera");let a=await r.call(d,e).catch(u=>{if(u instanceof U&&u.code==="check_out_of_order")return d.getSession();throw u});c||T(a)},"reportCameraUnavailable"),reportCaptureIssue:B,testerGate:t(async e=>{let r=d.testerGate;if(r===void 0)throw new TypeError("this client cannot run the tester gate");let a=e.clip,u=je(e.clipMime??"");if(a===void 0||!We.includes(u))throw new TypeError("the capture has no clip");await R();let s=await Ze(d,"clip",u,a.size,{engine:e.engine,durationMs:e.clipMs});await d.uploadToSpaces(s.uploadUrl,a,u);let{key:p}=await d.completeMedia(s.key),l=await Pe({always:!0}),y=await r.call(d,{clipKey:p,attestation:l,captureChannel:e.captureChannel,capture:{...et(e),attestationError:K}}),{bound:o,missReason:v,...w}=y;return c||(w.plan!==void 0?T(w):await x()),o===!0||v===void 0?{bound:o===!0}:{bound:!1,missReason:v}},"testerGate"),mobileRequired:It,captureMode:xt,chooseCaptureMode:t(e=>{Z=e},"chooseCaptureMode"),get captureChoice(){return W()},returning:Rt,liveness:Ue,run:t(async()=>{if(c)throw new Error("verification destroyed");return(await Nt()).run()},"run"),currentStep:t(()=>S?.current()??null,"currentStep"),voiceClips:t(async()=>{if(c)return null;try{let e=await k();return c?null:e.voice??null}catch{return null}},"voiceClips"),on:t((e,r)=>C.on(e,r),"on"),destroy:t(()=>{c=!0,ve.abort(),S?.destroy(),g!==null&&(g.alive=!1,g.capture.handle.destroy(),g=null),C.clear()},"destroy")}}t(zt,"mn");var ft=["AD","AE","AF","AG","AI","AL","AM","AO","AQ","AR","AS","AT","AU","AW","AX","AZ","BA","BB","BD","BE","BF","BG","BH","BI","BJ","BL","BM","BN","BO","BQ","BR","BS","BT","BV","BW","BY","BZ","CA","CC","CD","CF","CG","CH","CI","CK","CL","CM","CN","CO","CR","CU","CV","CW","CX","CY","CZ","DE","DJ","DK","DM","DO","DZ","EC","EE","EG","EH","ER","ES","ET","FI","FJ","FK","FM","FO","FR","GA","GB","GD","GE","GF","GG","GH","GI","GL","GM","GN","GP","GQ","GR","GS","GT","GU","GW","GY","HK","HM","HN","HR","HT","HU","ID","IE","IL","IM","IN","IO","IQ","IR","IS","IT","JE","JM","JO","JP","KE","KG","KH","KI","KM","KN","KP","KR","KW","KY","KZ","LA","LB","LC","LI","LK","LR","LS","LT","LU","LV","LY","MA","MC","MD","ME","MF","MG","MH","MK","ML","MM","MN","MO","MP","MQ","MR","MS","MT","MU","MV","MW","MX","MY","MZ","NA","NC","NE","NF","NG","NI","NL","NO","NP","NR","NU","NZ","OM","PA","PE","PF","PG","PH","PK","PL","PM","PN","PR","PS","PT","PW","PY","QA","RE","RO","RS","RU","RW","SA","SB","SC","SD","SE","SG","SH","SI","SJ","SK","SL","SM","SN","SO","SR","SS","ST","SV","SX","SY","SZ","TC","TD","TF","TG","TH","TJ","TK","TL","TM","TN","TO","TR","TT","TV","TW","TZ","UA","UG","UM","US","UY","UZ","VA","VC","VE","VG","VI","VN","VU","WF","WS","XK","YE","YT","ZA","ZM","ZW"],mt=["carte_identite","passport","residence_permit","drivers_license"],Zt=["carte_identite","passport","residence_permit"];function he(n,i){let f=n.byIssuer?.[i]??n.default;return mt.filter(m=>f==="*"?Zt.includes(m):f.includes(m))}t(he,"gn");function ht(n,i=ft){return[...new Set([...i,...Object.keys(n.byIssuer??{})])].filter(f=>he(n,f).length>0).sort()}t(ht,"Vo");var G={fullNameMin:2,fullName:200,email:254,occupation:120,shortText:120,longText:1e3,addressLine:120,addressLines:4,city:80,postcode:16,number:1e12,dateMin:"1900-01-01",dateMax:"2100-12-31"};var An={full_name:G.fullName,occupation:G.occupation,email:G.email,short_text:G.shortText,long_text:G.longText},yt=Object.freeze({nni_invalid:"id_number_invalid",nni_not_found:"registry_record_not_found",nni_recheck:"id_number_recheck",document_nni_mismatch:"document_id_number_mismatch",nni_locked:"id_number_locked",nni_unbound:"id_number_unbound",missing_nni:"missing_id_number",registry_needs_nni_source:"registry_needs_id_number_source"}),Cn=new Map(Object.entries(yt)),Mn=new Map(Object.entries(yt).map(([n,i])=>[i,n]));function Wt(n,i){let f=n.options.filter(d=>d.id!==n.current);if(i===void 0)return{switchTo:f,methods:[]};let m=t(d=>d.countries!==void 0&&d.countries.length>0,"i");if(i===null)return{switchTo:f.filter(d=>!m(d)),methods:[]};let _=i.toUpperCase(),b=t(d=>!m(d)||d.countries.includes(_),"u");return{switchTo:f.filter(b),methods:f.filter(d=>m(d)&&b(d))}}t(Wt,"Zo");function Jt(n,i,f){let m=n.names?.[i.toUpperCase()],_=m?.[f]??m?.en;if(_!==void 0&&_!=="")return _;let b=n.nationalEid?.providerName;return b!==void 0&&b!==""?b:void 0}t(Jt,"Jo");function Yt(n){return n===void 0?[]:[...new Set(n.options.filter(i=>i.id!==n.current).flatMap(i=>i.countries??[]).map(i=>i.toUpperCase()))]}t(Yt,"Xo");var Sn=10*1024*1024;function dr(n){if(n==="permission")return"denied";if(n==="notfound"||n==="insecure"||n==="unsupported")return"no_camera"}t(dr,"Ce");var Qt=/^[A-Z0-9][A-Z0-9 -]{0,39}$/,Xt=Object.freeze({normalize:t(n=>n.trim().toUpperCase().replace(/\s+/g," "),"normalize"),check:t(n=>Qt.test(n),"check"),registrySources:Object.freeze([]),describe:"number must be 1 to 40 letters, digits, spaces or hyphens"}),en=/^[A-Z0-9]{4,20}$/,ye=t(n=>n.trim().toUpperCase().replace(/[\s-]+/g,""),"m"),tn=Object.freeze({normalize:ye,check:t(n=>en.test(ye(n)),"check"),registrySources:Object.freeze([]),describe:"number must be 4 to 20 letters or digits"});function nn(n){return typeof n=="string"&&/^\d{10}$/.test(n)&&Number(n)%97===1}t(nn,"he");var rn={trim:t(n=>n.trim(),"trim"),upper_single_space:t(n=>n.trim().toUpperCase().replace(/\s+/g," "),"upper_single_space"),upper_no_space_or_hyphen:ye},an={mr_nni_mod97:t(n=>nn(n),"mr_nni_mod97")};function on(n){let i=new RegExp(n.pattern,"u"),f=n.check===null?void 0:an[n.check];return Object.freeze({normalize:rn[n.normalize],check:t(m=>i.test(m.trim())&&(f===void 0||f(m)),"check"),registrySources:Object.freeze([...n.registrySources]),describe:n.describe})}t(on,"ge");var sn=Object.freeze(Object.fromEntries(Object.entries(rt).map(([n,i])=>[n,on(i)])));function ln(n,i){return sn[`${n.toUpperCase()}:${i}`]??(i==="drivers_license"?tn:Xt)}t(ln,"C");var pr=Object.freeze({JPN:"JP",MRT:"MR"});function fr(n){return ln("MR","national_id").check(n)}t(fr,"Ae");function un(n){let i="";for(let f of n){let m=f.codePointAt(0)??0;m>=1632&&m<=1641?i+=String(m-1632):m>=1776&&m<=1785?i+=String(m-1776):f!==" "&&f!=="-"&&f!==" "&&(i+=f)}return i}t(un,"H");function mr(n){return un(n)}t(mr,"De");var hr=he,yr=ht;var cn=t(()=>import("./create-document-capture-R7KKX6YY-5FG6AKTA.js"),"E");function dn(){cn().then(n=>n.warmDocumentCapture()).catch(()=>{})}t(dn,"D");function vr(){dn()}t(vr,"rt");var pn=t(()=>import("./create-portrait-capture-5VGYZUOK-KTCFCHTN.js"),"O");function fn(){pn().then(n=>n.warmPortraitCapture()).catch(()=>{})}t(fn,"b");function gr(){fn()}t(gr,"dt");export{$t as a,Wt as b,Jt as c,Yt as d,dr as e,fr as f,mr as g,hr as h,yr as i,vr as j,gr as k};
3
+ ${r}`,"ye"),Te=0,se,le=t((e,r)=>{Te+=1;let a=I(),u=P(e,{signal:ve.signal,subject:r}),s={key:oe(e,r),at:a,token:u};return u.then(()=>{s.issuedAt=I(),ae=void 0},p=>{let l=lt(p);if(s.failed=l,c||l==="aborted")return;ae=l;let{detail:y,readyMs:o}=p;B({check:"attestation",kind:"unavailable",engineKind:l,attempt:_t++,challengeMs:I()-a,readyMs:o,detail:y,inApp:Ge()})}),u.catch(()=>{}),s},"Se"),xe=t((e,r)=>e!==null&&e.key===r&&(e.issuedAt===void 0||I()-e.issuedAt<Ut),"De"),ue=t((e,r={})=>{let a=e?.challenge??null;if(e===null||a===null||c)return;let u=X(e.sessionId),s=L;(r.replaceFailed===!0&&s?.failed!==void 0&&!ut.has(s.failed)||!xe(s,oe(a,u)))&&(L=le(a,u))},"_e"),Ie=t(async(e,r,a)=>{let u=oe(e,r),s=L;L=null;let p=xe(s,u)?s:le(e,r),l=p===s?0:1,y,o=new Promise(v=>{y=setTimeout(()=>v("late"),a)});try{for(;;){let v=await Promise.race([p.token.then(w=>({token:w}),w=>({error:lt(w)})),o]);if(v==="late")return!c&&L===null&&(L=p),{error:ae??"timeout"};if("token"in v)return se=Math.max(0,Math.round((p.issuedAt??I())-p.at)),v;if(c||ut.has(v.error)||l>=Gt||l>0&&await Promise.race([M(jt*l),o])==="late")return v;if(c)return{error:"aborted"};l+=1,p=le(e,r)}}finally{clearTimeout(y)}},"Ue"),O=null,bt=t(e=>pe(e).some(r=>(r.checkType==="phone_otp"||r.checkType==="email_otp")&&r.state!=="passed"&&r.state!=="skipped"),"Gt"),Re=t(e=>O===null||I()-O>=e,"Be"),Q=t(()=>Re(Ft),"re"),kt=t(e=>{let r=e.attestation;return typeof r?.turnstileToken=="string"&&r.turnstileToken.length>0},"Kt"),Ee=new Map,Ne=t(async e=>{let r=await k(),a=r.challenge;if(a==null||r.simulation!==void 0)return;let u=await Ie(a,X(r.sessionId),e);if(!("token"in u))throw Ye(u.error);return u.token},"Ge"),wt=t(async(e,r,a={})=>{let u=r;if("attestation"in u)try{let o=await b.submitCheck(e,r,a);return kt(u)&&(O=I()),o}catch(o){throw o instanceof U&&o.code==="attestation_invalid"&&(O=null),o}let s=(e==="phone_otp"||e==="email_otp")&&u.action!=="verify",p=a.idempotencyKey,l=p!==void 0?Ee.get(p):void 0;l===void 0&&(s||Q())&&(l=await Ne(st(e,u)),p!==void 0&&l!==void 0&&Ee.set(p,l));let y=t((o,v)=>o!==void 0?{...v,browserCheckToken:o}:v,"b");try{let o=await b.submitCheck(e,r,y(l,a));return l!==void 0&&(O=I()),o}catch(o){if(!(o instanceof U)||o.code!=="attestation_invalid"||(O=null,l!==void 0))throw o;let v=await Ne(st(e,u)),w=p!==void 0?{...a,idempotencyKey:j()}:a,E=await b.submitCheck(e,r,y(v,w));return v!==void 0&&(O=I()),E}},"jt"),Pe=t(async(e={})=>{if(K=void 0,e.always!==!0&&!Q())return{};let r=await k(),a=r.challenge;if(a==null)return{};let u=e.always===!0?pt:dt,s=await Ie(a,X(r.sessionId),u);if("token"in s)return{channel:"hosted_web",turnstileToken:s.token};if(K=s.error,r.simulation!==void 0)return{channel:"hosted_web"};throw new Je(s.error)},"Ke"),At=t(()=>K,"Yt"),Ct=t(()=>({checks:Math.min(50,Te),...se!==void 0?{challengeMs:Math.min(6e5,se)}:{}}),"Wt"),B=t(e=>{if(c)return;let r=d.reportCaptureIssue;if(r===void 0)return;let a=e.formFactor;try{a??(a=qe())}catch{}try{Promise.resolve(r.call(d,{...e,...a!==void 0?{formFactor:a}:{}})).catch(()=>{})}catch{}},"Y"),g=null,V=null,Oe=new WeakMap,De=Promise.resolve(),H=0,Mt=t(async()=>{let e=await k();for(let r=0;r<Bt&&!c&&!N(e)&&q(e)===void 0&&pe(e).some(a=>a.state==="processing")&&(await M(Kt),!c);r+=1)e=await x();return e},"$t"),St=t(async(e,r,a)=>{let{capture:u}=e,s=t(()=>c,"m"),p=t(()=>e.alive&&e.attempt===a,"C"),l=t(o=>{p()&&u.setFlowState(o)},"h"),y=t(o=>{if(!s()&&(o.status==="unavailable"&&o.reasonCode!==void 0&&!Be(o.reasonCode)&&B({check:"liveness",kind:"unavailable",phase:"upload",engineKind:o.reasonCode,attempt:Math.max(0,e.issues.value)}),re(o),!!p())){if(o.status==="retry"&&_==="auto"){u.handle.retry();return}u.setFlowState("done")}},"b");if(r.degraded==="NO_RECORDER"){let o=h?.sessionId??(await k().catch(()=>null))?.sessionId??"";y(D(o,"no_recorder"));return}l("uploading");try{if(await Se(),s())return;let o=await k(),v;if(!N(o)&&F(o)!==null){await ke(!1),y(D(o.sessionId,"method_required"));return}if(!N(o)){if(q(o)?.checkType==="population_registry"){y(D(o.sessionId,Ae?"nni_unbound":we?"network":"registry_unavailable"));return}if(await R(),s())return;v=h??o;let w=await Xe({...ne,artifacts:r,getAttestation:Pe,attestationError:At,attestationFacts:Ct,clipKeys:{get:t(()=>Oe.get(r)??null,"get"),set:t(E=>{Oe.set(r,E)},"set")},getView:t(()=>h??o,"getView"),refreshView:x,applySubmit:te,onPhase:l,isCancelled:s,onKeyframePromoted:t(E=>{A=E},"onKeyframePromoted")});if(s())return;if(w.kind==="unavailable"){w.reason==="attestation"&&(V={bound:e,artifacts:r});let E=D(o.sessionId,w.reason),Fe=w.reason==="attestation"?K:void 0;y(Fe!==void 0?{...E,attestationError:Fe}:E);return}if(w.kind==="resync"&&await x(),h!==null&&F(h)!==null){await ke(!1),y(D(o.sessionId,"method_required"));return}o=await Mt()}y(fe(o,{autoRetry:m,previous:v}))}catch{if(s())return;y(D(h?.sessionId??"","network"))}},"Qt"),Le=t((e,r)=>{let a=e.attempt;H>0&&e.alive&&e.capture.setFlowState("uploading"),H+=1,De=De.then(()=>St(e,r,a)).finally(()=>{H-=1,H===0&&S?.onChainIdle()}).catch(()=>{})},"We"),Ue=t(e=>{g?.capture.handle.destroy(),g!==null&&(g.alive=!1,g.ramp.stop());let r=Ot({armRamp:typeof d.armRamp=="function"?()=>d.armRamp():void 0,waiting:t(()=>s.alive&&J()==="self"&&(u.handle.state==="starting"||u.handle.state==="gating"),"waiting")}),a=Promise.resolve(),u=at(e,S?.captureInternals?.(e)??i.capture,()=>h?.capture?.liveness?.keyframe?.rank===!0,J,()=>r.take()??h?.capture?.liveness?.screenRamp,{session:t(()=>ee(h),"session"),onModeChange:t(l=>{Z=l},"onModeChange")}),s={capture:u,alive:!0,ramp:r,attempt:0,issues:He()};g=s,u.handle.on("error",l=>{B(Ve("liveness",l,s.issues.value))}),u.handle.on("state",l=>{if(s.issues.note(l),l==="starting"){s.attempt+=1,V?.bound===s&&(V=null),Q()&&ue(h,{replaceFailed:!0});let y=h===null?void 0:q(h)?.checkType;a=y==="liveness"||y==="face_match"?R().catch(()=>{}):Promise.resolve()}(l==="starting"||l==="gating")&&J()==="self"&&a.then(()=>{s.alive&&r.arm()})}),u.handle.on("captured",l=>{Promise.resolve().then(()=>Le(s,l))});let p=u.handle;return{get state(){return p.state},get captureMode(){return p.captureMode},get facingMode(){return p.facingMode},on:t((l,y)=>p.on(l,y),"on"),start:t(async l=>{if(h===null&&await k().catch(()=>{}),!!s.alive)return p.start(l)},"start"),retry:t(()=>{let l=V;if(l!==null&&l.bound===s&&s.alive){V=null,Le(s,l.artifacts);return}p.retry()},"retry"),switchCamera:t(()=>p.switchCamera(),"switchCamera"),canSwitchCaptureMode:t(()=>p.canSwitchCaptureMode(),"canSwitchCaptureMode"),setCaptureMode:t(l=>p.setCaptureMode(l),"setCaptureMode"),destroy:t(()=>{s.alive=!1,r.stop(),g===s&&(g=null),p.destroy()},"destroy")}},"$e"),Tt=t(async()=>{if(c)return null;try{let e=await k();return c?null:F(e)}catch{return null}},"Zt"),xt=t(async()=>{if(c)return"self";try{let e=await k();if(c)return"self";let r=ee(e);return r==="choice"?W()??r:r}catch{return"self"}},"Jt"),It=t(async()=>{if(c)return!1;try{let e=await k();return c||N(e)||de()?!1:me(e,q(e))==="phone"||me(e,$(e,"liveness"))==="phone"}catch{return!1}},"Xt"),Rt=t(async()=>{if(c)return!1;try{let e=await k();return!c&&e.returning===!0}catch{return!1}},"zt"),Et=t(async e=>{let r=(await k()).plan?.choice,a=r?.options.find(s=>$e[s.service]===e);if(!a)throw new RangeError(`method ${String(e)} is not offered`);let u=await d.choose(r.nodeId,a.id);c||T(u)},"en"),ce=null,Nt=t(()=>(ce??(ce=import("./plan-runner-MC6KC7PK-E55J5SPN.js").then(e=>{let r=e.createPlanRunner({runtime:ne,currentView:t(()=>h,"currentView"),cameraMode:J,captureModeSwitch:{pick:W,choose:t(a=>{Z=a},"choose")},ensureView:k,refreshView:x,ensureConsent:t(()=>R(),"ensureConsent"),liveness:Ue,stopLiveness:t(()=>{g!==null&&(g.alive=!1,g.ramp.stop(),g.capture.handle.destroy(),g=null)},"stopLiveness"),chainBusy:t(()=>H>0,"chainBusy"),destroyed:t(()=>c,"destroyed"),sleep:M,isMobile:de,now:i.now??Date.now,keptFaceKey:t(()=>A,"keptFaceKey"),setView:T,baseCapture:i.capture,emitStep:t(a=>{c||C.emit("step",a)},"emitStep"),emitResult:vt,reportCaptureIssue:B,documentInternals:i.document,documentFacts:i.documentFacts,portraitInternals:i.portrait,livePhotoInternals:i.livePhoto,uploadInternals:i.upload,pageCameraInternals:i.pageCamera});return S=r,r})),ce),"tn");return{consent:t(()=>R(),"consent"),startRegistry:Se,methodChoice:Tt,selectMethod:Et,reportCameraUnavailable:t(async e=>{await R();let r=d.reportCameraUnavailable;if(r===void 0)throw new TypeError("this client cannot report a missing camera");let a=await r.call(d,e).catch(u=>{if(u instanceof U&&u.code==="check_out_of_order")return d.getSession();throw u});c||T(a)},"reportCameraUnavailable"),reportCaptureIssue:B,testerGate:t(async e=>{let r=d.testerGate;if(r===void 0)throw new TypeError("this client cannot run the tester gate");let a=e.clip,u=je(e.clipMime??"");if(a===void 0||!We.includes(u))throw new TypeError("the capture has no clip");await R();let s=await Ze(d,"clip",u,a.size,{engine:e.engine,durationMs:e.clipMs});await d.uploadToSpaces(s.uploadUrl,a,u);let{key:p}=await d.completeMedia(s.key),l=await Pe({always:!0}),y=await r.call(d,{clipKey:p,attestation:l,captureChannel:e.captureChannel,capture:{...et(e),attestationError:K}}),{bound:o,missReason:v,...w}=y;return c||(w.plan!==void 0?T(w):await x()),o===!0||v===void 0?{bound:o===!0}:{bound:!1,missReason:v}},"testerGate"),mobileRequired:It,captureMode:xt,chooseCaptureMode:t(e=>{Z=e},"chooseCaptureMode"),get captureChoice(){return W()},returning:Rt,liveness:Ue,run:t(async()=>{if(c)throw new Error("verification destroyed");return(await Nt()).run()},"run"),currentStep:t(()=>S?.current()??null,"currentStep"),voiceClips:t(async()=>{if(c)return null;try{let e=await k();return c?null:e.voice??null}catch{return null}},"voiceClips"),on:t((e,r)=>C.on(e,r),"on"),destroy:t(()=>{c=!0,ve.abort(),S?.destroy(),g!==null&&(g.alive=!1,g.capture.handle.destroy(),g=null),C.clear()},"destroy")}}t(zt,"mn");var ft=["AD","AE","AF","AG","AI","AL","AM","AO","AQ","AR","AS","AT","AU","AW","AX","AZ","BA","BB","BD","BE","BF","BG","BH","BI","BJ","BL","BM","BN","BO","BQ","BR","BS","BT","BV","BW","BY","BZ","CA","CC","CD","CF","CG","CH","CI","CK","CL","CM","CN","CO","CR","CU","CV","CW","CX","CY","CZ","DE","DJ","DK","DM","DO","DZ","EC","EE","EG","EH","ER","ES","ET","FI","FJ","FK","FM","FO","FR","GA","GB","GD","GE","GF","GG","GH","GI","GL","GM","GN","GP","GQ","GR","GS","GT","GU","GW","GY","HK","HM","HN","HR","HT","HU","ID","IE","IL","IM","IN","IO","IQ","IR","IS","IT","JE","JM","JO","JP","KE","KG","KH","KI","KM","KN","KP","KR","KW","KY","KZ","LA","LB","LC","LI","LK","LR","LS","LT","LU","LV","LY","MA","MC","MD","ME","MF","MG","MH","MK","ML","MM","MN","MO","MP","MQ","MR","MS","MT","MU","MV","MW","MX","MY","MZ","NA","NC","NE","NF","NG","NI","NL","NO","NP","NR","NU","NZ","OM","PA","PE","PF","PG","PH","PK","PL","PM","PN","PR","PS","PT","PW","PY","QA","RE","RO","RS","RU","RW","SA","SB","SC","SD","SE","SG","SH","SI","SJ","SK","SL","SM","SN","SO","SR","SS","ST","SV","SX","SY","SZ","TC","TD","TF","TG","TH","TJ","TK","TL","TM","TN","TO","TR","TT","TV","TW","TZ","UA","UG","UM","US","UY","UZ","VA","VC","VE","VG","VI","VN","VU","WF","WS","XK","YE","YT","ZA","ZM","ZW"],mt=["carte_identite","passport","residence_permit","drivers_license"],Zt=["carte_identite","passport","residence_permit"];function he(n,i){let f=n.byIssuer?.[i]??n.default;return mt.filter(m=>f==="*"?Zt.includes(m):f.includes(m))}t(he,"gn");function ht(n,i=ft){return[...new Set([...i,...Object.keys(n.byIssuer??{})])].filter(f=>he(n,f).length>0).sort()}t(ht,"Vo");var G={fullNameMin:2,fullName:200,email:254,occupation:120,shortText:120,longText:1e3,addressLine:120,addressLines:4,city:80,postcode:16,number:1e12,dateMin:"1900-01-01",dateMax:"2100-12-31"};var An={full_name:G.fullName,occupation:G.occupation,email:G.email,short_text:G.shortText,long_text:G.longText},yt=Object.freeze({nni_invalid:"id_number_invalid",nni_not_found:"registry_record_not_found",nni_recheck:"id_number_recheck",document_nni_mismatch:"document_id_number_mismatch",nni_locked:"id_number_locked",nni_unbound:"id_number_unbound",missing_nni:"missing_id_number",registry_needs_nni_source:"registry_needs_id_number_source"}),Cn=new Map(Object.entries(yt)),Mn=new Map(Object.entries(yt).map(([n,i])=>[i,n]));function Wt(n,i){let f=n.options.filter(d=>d.id!==n.current);if(i===void 0)return{switchTo:f,methods:[]};let m=t(d=>d.countries!==void 0&&d.countries.length>0,"i");if(i===null)return{switchTo:f.filter(d=>!m(d)),methods:[]};let _=i.toUpperCase(),b=t(d=>!m(d)||d.countries.includes(_),"u");return{switchTo:f.filter(b),methods:f.filter(d=>m(d)&&b(d))}}t(Wt,"Zo");function Jt(n,i,f){let m=n.names?.[i.toUpperCase()],_=m?.[f]??m?.en;if(_!==void 0&&_!=="")return _;let b=n.nationalEid?.providerName;return b!==void 0&&b!==""?b:void 0}t(Jt,"Jo");function Yt(n){return n===void 0?[]:[...new Set(n.options.filter(i=>i.id!==n.current).flatMap(i=>i.countries??[]).map(i=>i.toUpperCase()))]}t(Yt,"Xo");var Sn=10*1024*1024;function dr(n){if(n==="permission")return"denied";if(n==="notfound"||n==="insecure"||n==="unsupported")return"no_camera"}t(dr,"Ce");var Qt=/^[A-Z0-9][A-Z0-9 -]{0,39}$/,Xt=Object.freeze({normalize:t(n=>n.trim().toUpperCase().replace(/\s+/g," "),"normalize"),check:t(n=>Qt.test(n),"check"),registrySources:Object.freeze([]),describe:"number must be 1 to 40 letters, digits, spaces or hyphens"}),en=/^[A-Z0-9]{4,20}$/,ye=t(n=>n.trim().toUpperCase().replace(/[\s-]+/g,""),"m"),tn=Object.freeze({normalize:ye,check:t(n=>en.test(ye(n)),"check"),registrySources:Object.freeze([]),describe:"number must be 4 to 20 letters or digits"});function nn(n){return typeof n=="string"&&/^\d{10}$/.test(n)&&Number(n)%97===1}t(nn,"he");var rn={trim:t(n=>n.trim(),"trim"),upper_single_space:t(n=>n.trim().toUpperCase().replace(/\s+/g," "),"upper_single_space"),upper_no_space_or_hyphen:ye},an={mr_nni_mod97:t(n=>nn(n),"mr_nni_mod97")};function on(n){let i=new RegExp(n.pattern,"u"),f=n.check===null?void 0:an[n.check];return Object.freeze({normalize:rn[n.normalize],check:t(m=>i.test(m.trim())&&(f===void 0||f(m)),"check"),registrySources:Object.freeze([...n.registrySources]),describe:n.describe})}t(on,"ge");var sn=Object.freeze(Object.fromEntries(Object.entries(rt).map(([n,i])=>[n,on(i)])));function ln(n,i){return sn[`${n.toUpperCase()}:${i}`]??(i==="drivers_license"?tn:Xt)}t(ln,"C");var pr=Object.freeze({JPN:"JP",MRT:"MR"});function fr(n){return ln("MR","national_id").check(n)}t(fr,"Ae");function un(n){let i="";for(let f of n){let m=f.codePointAt(0)??0;m>=1632&&m<=1641?i+=String(m-1632):m>=1776&&m<=1785?i+=String(m-1776):f!==" "&&f!=="-"&&f!==" "&&(i+=f)}return i}t(un,"H");function mr(n){return un(n)}t(mr,"De");var hr=he,yr=ht;var cn=t(()=>import("./create-document-capture-SZ4SIVVC-P4MMZXVZ.js"),"E");function dn(){cn().then(n=>n.warmDocumentCapture()).catch(()=>{})}t(dn,"D");function vr(){dn()}t(vr,"rt");var pn=t(()=>import("./create-portrait-capture-5VGYZUOK-KTCFCHTN.js"),"O");function fn(){pn().then(n=>n.warmPortraitCapture()).catch(()=>{})}t(fn,"b");function gr(){fn()}t(gr,"dt");export{$t as a,Wt as b,Jt as c,Yt as d,dr as e,fr as f,mr as g,hr as h,yr as i,vr as j,gr as k};