@sekyro/web 0.1.0-rc.2 → 0.1.0-rc.20
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.
- package/CHANGELOG.md +300 -0
- package/LICENSE +25 -16
- package/README.md +111 -60
- package/THIRD-PARTY-NOTICES.txt +154 -0
- package/dist/background-monitor-A7FKJOAG.js +1 -0
- package/dist/camera-trait-45MJTW4K.js +1 -0
- package/dist/capture-constraints-B5omafmk.d.cts +44 -0
- package/dist/capture-constraints-B5omafmk.d.ts +44 -0
- package/dist/capture-session-doc-QA4DOFRF.js +1 -0
- package/dist/{capture-session-v3-CAoWM8iT.d.cts → capture-session-v3-CNL-GX11.d.cts} +185 -15
- package/dist/{capture-session-v3-BJ8ciaWl.d.ts → capture-session-v3-DaBqN8fO.d.ts} +185 -15
- package/dist/chunk-5ZKQHFFW.js +1 -0
- package/dist/chunk-7ZCZY3ZP.js +1 -0
- package/dist/chunk-A3FUGHAH.js +2 -0
- package/dist/chunk-BPE5NSQ2.js +1 -0
- package/dist/chunk-CJHMFPL6.js +1 -0
- package/dist/chunk-CQ7SKLMC.js +1 -0
- package/dist/chunk-DFTCAWMP.js +1 -0
- package/dist/chunk-DK5YPBDQ.js +1 -0
- package/dist/chunk-FGOVIGGL.js +1 -0
- package/dist/chunk-FPXL63KZ.js +1 -0
- package/dist/chunk-FUHDOEBP.js +1 -0
- package/dist/chunk-G6LKLN4U.js +1 -0
- package/dist/chunk-GI3UFGRQ.js +1 -0
- package/dist/chunk-GT2ZLGF7.js +1 -0
- package/dist/chunk-IG466TOP.js +1 -0
- package/dist/chunk-KHR4U2SZ.js +1 -0
- package/dist/chunk-KZBBB5B2.js +1 -0
- package/dist/chunk-MXWLCDFX.js +1 -0
- package/dist/chunk-NJML6FMD.js +1 -0
- package/dist/chunk-O5WKNZ2C.js +1 -0
- package/dist/chunk-OKWG3PVH.js +1 -0
- package/dist/chunk-POIQGEZM.js +1 -0
- package/dist/chunk-RI3E7GBN.js +1 -0
- package/dist/chunk-SMKCBUJL.js +1 -0
- package/dist/chunk-TDLIXFDT.js +1 -0
- package/dist/chunk-TQB3URP2.js +1 -0
- package/dist/chunk-U6S7SCBY.js +1 -0
- package/dist/chunk-U6TYL2IJ.js +1 -0
- package/dist/chunk-W2WD7PR2.js +1 -0
- package/dist/chunk-XCKE2MJL.js +1 -0
- package/dist/chunk-ZLWH4RBO.js +1 -0
- package/dist/client/index.cjs +1 -357
- package/dist/client/index.d.cts +6 -37
- package/dist/client/index.d.ts +6 -37
- package/dist/client/index.js +1 -15
- package/dist/core/index.cjs +1 -1605
- package/dist/core/index.d.cts +5 -4
- package/dist/core/index.d.ts +5 -4
- package/dist/core/index.js +1 -139
- package/dist/core/ocr/worker.bundle.js +42 -0
- package/dist/core/ocr/worker.cjs +42 -0
- package/dist/core/ocr/worker.d.cts +84 -0
- package/dist/core/ocr/worker.d.ts +84 -0
- package/dist/core/ocr/worker.js +41 -0
- package/dist/core/v3/detect-worker.cjs +1 -392
- package/dist/core/v3/detect-worker.d.cts +1 -1
- package/dist/core/v3/detect-worker.d.ts +1 -1
- package/dist/core/v3/detect-worker.js +1 -13
- package/dist/create-document-capture-GJXBQMTC.js +1 -0
- package/dist/create-portrait-capture-MOS2D7CL.js +1 -0
- package/dist/create-verification-BBOUYpga.d.cts +3274 -0
- package/dist/create-verification-COpe2hxf.d.ts +3274 -0
- package/dist/{detect-worker-CKXHlXx9.d.cts → detect-worker-DclNxkZT.d.cts} +6 -0
- package/dist/{detect-worker-CKXHlXx9.d.ts → detect-worker-DclNxkZT.d.ts} +6 -0
- package/dist/detector-scanic-YCDNLCGV.js +1 -0
- package/dist/icao-gate-CEGvJR3q.d.ts +534 -0
- package/dist/icao-gate-PWBMKRGC.js +1 -0
- package/dist/icao-gate-l40OU6x1.d.cts +534 -0
- package/dist/icao-policy-BgI1Y870.d.ts +71 -0
- package/dist/icao-policy-C7fIdRzo.d.cts +71 -0
- package/dist/icao-tuning-4GGVX6B4.js +1 -0
- package/dist/index.cjs +1 -2636
- package/dist/index.d.cts +110 -5
- package/dist/index.d.ts +110 -5
- package/dist/index.js +1 -28
- package/dist/internal/index.cjs +1 -4166
- package/dist/internal/index.d.cts +365 -324
- package/dist/internal/index.d.ts +365 -324
- package/dist/internal/index.js +1 -647
- package/dist/keyframe-rank-YAJLYJYF.js +1 -0
- package/dist/landmarker-KB7LVXAU.js +1 -0
- package/dist/mrz-band-VYHOTDHY.js +1 -0
- package/dist/plan-runner-35655N4Z.js +1 -0
- package/dist/popup/index.cjs +1 -76
- package/dist/popup/index.d.cts +7 -1
- package/dist/popup/index.d.ts +7 -1
- package/dist/popup/index.js +1 -11
- package/dist/print-AYSCRSZB.js +1 -0
- package/dist/scanic-ml-stub-KW7IZHUT.js +1 -0
- package/dist/segmenter-USLNBX65.js +1 -0
- package/dist/turnstile-FATNZ4AG.js +1 -0
- package/dist/types-Dpfg2cO8.d.cts +1699 -0
- package/dist/types-Dpfg2cO8.d.ts +1699 -0
- package/dist/upload-file-UYXOHCRG.js +1 -0
- package/package.json +27 -11
- package/sbom.cdx.json +234 -0
- package/dist/capture-constraints-BujkZcfb.d.cts +0 -21
- package/dist/capture-constraints-BujkZcfb.d.ts +0 -21
- package/dist/chunk-BPYVZUJA.js +0 -852
- package/dist/chunk-BPYVZUJA.js.map +0 -1
- package/dist/chunk-LOTAJDRE.js +0 -1094
- package/dist/chunk-LOTAJDRE.js.map +0 -1
- package/dist/chunk-MWNFSNMP.js +0 -52
- package/dist/chunk-MWNFSNMP.js.map +0 -1
- package/dist/chunk-NILNKLK6.js +0 -50
- package/dist/chunk-NILNKLK6.js.map +0 -1
- package/dist/chunk-NWF46H7K.js +0 -359
- package/dist/chunk-NWF46H7K.js.map +0 -1
- package/dist/chunk-WY6U7AIK.js +0 -193
- package/dist/chunk-WY6U7AIK.js.map +0 -1
- package/dist/chunk-YVFF4Q4G.js +0 -327
- package/dist/chunk-YVFF4Q4G.js.map +0 -1
- package/dist/client/index.cjs.map +0 -1
- package/dist/client/index.js.map +0 -1
- package/dist/core/index.cjs.map +0 -1
- package/dist/core/index.js.map +0 -1
- package/dist/core/v3/detect-worker.cjs.map +0 -1
- package/dist/core/v3/detect-worker.js.map +0 -1
- package/dist/create-verification-CjLnJ0w6.d.ts +0 -348
- package/dist/create-verification-EnZ13uY4.d.cts +0 -348
- package/dist/detector-scanic-4C6IEW2K.js +0 -787
- package/dist/detector-scanic-4C6IEW2K.js.map +0 -1
- package/dist/hosted-client-BpvBqu9f.d.cts +0 -408
- package/dist/hosted-client-BpvBqu9f.d.ts +0 -408
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/internal/index.cjs.map +0 -1
- package/dist/internal/index.js.map +0 -1
- package/dist/popup/index.cjs.map +0 -1
- package/dist/popup/index.js.map +0 -1
- package/dist/scanic-ml-stub-S2OZ6HEF.js +0 -10
- package/dist/scanic-ml-stub-S2OZ6HEF.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{d as J,h as he,i as ye,j as Se,l as Me}from"./chunk-G6LKLN4U.js";import{f as be}from"./chunk-TDLIXFDT.js";import{m as V}from"./chunk-W2WD7PR2.js";import{a as fe,e as ge}from"./chunk-GT2ZLGF7.js";import{k as $}from"./chunk-CQ7SKLMC.js";var qe={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 He(e){let{deviceMemory:t,effectiveType:n,saveData:r,downlinkMbps:i,sourceLongEdge:l}=e,s=r===!0||n==="slow-2g"||n==="2g"||i!=null&&i>0&&i<1,u=t!=null&&t<=2,c=n==="4g"||i!=null&&i>=5,f=t!=null&&t>=6,p;s||u?p="low":c&&f?p="good":p="mid";let b=qe[p],S=l&&l>0?Math.min(b.maxLongEdge,l):b.maxLongEdge;return{tier:p,...b,maxLongEdge:S}}function ke(e){let t={};try{let n=navigator;typeof n.deviceMemory=="number"&&(t.deviceMemory=n.deviceMemory);let r=n.connection;r&&(t.effectiveType=r.effectiveType,t.saveData=r.saveData,t.downlinkMbps=r.downlink)}catch{}return typeof e=="number"&&e>0&&(t.sourceLongEdge=e),He(t)}function Xe(e,t,n){let r=Math.min(1,Math.max(0,(e-.28)/.21999999999999997)),i=(t+n)/2;return Math.max(t,n-r*(n-i))}function Ve(e,t,n){let r=Math.max(e,t),i=r>0?Math.min(1,n/r):1;return{width:Math.max(1,Math.round(e*i)),height:Math.max(1,Math.round(t*i))}}async function Ye(e,t){let n=t.startQ,r=await e(n);for(let i=0;i<4&&!(r.size<=t.budgetBytes||n<=t.qMin);i++)n=Math.max(t.qMin,n-.08),r=await e(n);return{blob:r,quality:n}}async function De(e,t,n,r,i){if(t<=0||n<=0)return null;let{width:l,height:s}=Ve(t,n,r.maxLongEdge),u=document.createElement("canvas");u.width=l,u.height=s;let c=u.getContext("2d");if(!c)return null;c.drawImage(e,0,0,l,s);let f=I=>new Promise((h,w)=>{u.toBlob(d=>d?h(d):w(new Error("canvas toBlob returned null")),"image/jpeg",I)}),p=Xe(i,r.qMin,r.qMax),{blob:b,quality:S}=await Ye(f,{startQ:p,qMin:r.qMin,budgetBytes:r.payloadTargetBytes}).finally(()=>{u.width=0,u.height=0});if(b.size>5242880)throw new Error("encoded document exceeds the 5242880-byte media cap");return{blob:b,quality:S,width:l,height:s}}async function Z(e){let t=ke(Math.max(e.width,e.height)),n=await De(e,e.width,e.height,t,.5);if(n===null)throw new Error("canvas encode unavailable");return{blob:n.blob,width:n.width,height:n.height}}async function mt(e){let t=await createImageBitmap(e);try{return await Z(t)}finally{t.close()}}var ft=250,gt=.6,bt=1800,ht=6e3,yt=2e3,we=.16;function te(e,t){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}}var Ce=e=>e==="recto"?"verso":"recto",Re=e=>e.phase==="framing"||e.phase==="locking"||e.phase==="flipCue"||e.phase==="reaskRecto",ne=e=>(e.captured.recto!==void 0?1:0)+(e.captured.verso!==void 0?1:0)+e.pending.length;function ee(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}}function Qe(e,t,n){if(e.phase==="result")return{...e,lastReportAt:n};let r=!t.present||e.captureArea!==void 0&&t.areaFrac<.6*e.captureArea,{flipped:i,awaySince:l}=e;r&&(l=l??n),l!==void 0&&n-l>=250&&(i=!0),r||(l=void 0);let s=e.flipTimeoutSpent&&!(i&&!e.flipped),u={...e,lastReportAt:n,flipped:i,awaySince:l,flipTimeoutSpent:s,lastArea:t.areaFrac};if(!Re(e))return u;if(e.needFlip&&!i){if(!t.ready)return{...u,phase:e.restPhase,goodSince:void 0};let c=e.lastShot!==void 0&&e.pending.includes(e.lastShot);if(s||c)return{...u,goodSince:void 0,phase:e.restPhase};let f=e.goodSince??n;return n-f>=1800?{...u,goodSince:f,phase:"capturing",flipTimeoutSpent:!0,timeoutCapture:!0}:{...u,goodSince:f,phase:e.restPhase}}return t.ready?{...u,phase:"capturing",goodSince:e.goodSince??n}:{...u,goodSince:void 0,phase:t.locking?"locking":e.restPhase}}function Ke(e,t){if(!Re(e)||e.manualShutter)return e;let n=t-e.lastReportAt>=2e3,r=t-e.lastCaptureAt>=6e3;return n||r?{...e,manualShutter:!0}:e}function je(e,t,n){let r=e.layout==="singlePage",i=r?{recto:t}:e.captured,l=r?[]:[...e.pending,t],s={...e,captured:i,pending:l,lastShot:t,lastCaptureAt:n,lastReportAt:-1,manualShutter:!1,goodSince:void 0,notice:void 0,awaySince:void 0,flipped:!1,lastShotByTimeout:e.timeoutCapture,timeoutCapture:!1,captureArea:e.lastArea};return r||ne({captured:i,pending:l})>=2?{...s,phase:"reading",restPhase:"framing",current:void 0,needFlip:!1}:{...s,phase:"flipCue",restPhase:"flipCue",current:void 0,needFlip:!0}}function xe(e,t,n){return e.pending.includes(t)?{...e,pending:e.pending.filter(r=>r!==t),lastShot:e.lastShot===t?void 0:e.lastShot,phase:e.phase==="capturing"?e.phase:"flipCue",restPhase:"flipCue",current:Ce(n),needFlip:!0,flipTimeoutSpent:!0,goodSince:void 0,manualShutter:!0,notice:"same_face",lastCaptureAt:-1,lastReportAt:-1}:e}function $e(e,t,n){if(!e.pending.includes(t))return e;if(e.captured[n]!==void 0)return xe(e,t,n);let r=e.pending.filter(c=>c!==t),i={...e,pending:r,captured:{...e.captured,[n]:t}};if(ne(i)!==1||e.layout==="singlePage")return i;let l=Ce(n),s=l==="recto"&&e.restPhase==="reaskRecto"?"reaskRecto":"flipCue",u=e.phase==="flipCue"||e.phase==="reaskRecto"||e.phase==="framing";return{...i,restPhase:s,current:l,phase:u?s:e.phase}}function Je(e,t){let n=t.id??e.captured[t.side],r={...e.captured};(t.id===void 0||r[t.side]===t.id)&&delete r[t.side];let i=e.pending.filter(f=>f!==n),l=e.layout==="twoSided"&&ne({captured:r,pending:i})>0,s=e.lastShotByTimeout||n===e.lastShot!==e.flipped,u=l&&!s,c=u?t.side==="recto"?"reaskRecto":"flipCue":"framing";return{...e,captured:r,pending:i,readSides:e.readSides.filter(f=>f!==t.side),lastShot:e.lastShot===n?void 0:e.lastShot,notice:t.issue,goodSince:void 0,manualShutter:!1,phase:c,restPhase:c,current:t.side,needFlip:u,flipped:!1,flipTimeoutSpent:!1,awaySince:void 0,lastCaptureAt:-1,lastReportAt:-1}}function ve(e,t){switch(t.type){case"report":return Qe(ee(e,t.at),t.report,t.at);case"tick":return Ke(ee(e,t.at),t.at);case"captured":return je(ee(e,t.at),t.id,t.at);case"captureFailed":return{...e,phase:e.restPhase,goodSince:void 0,lastCaptureAt:t.at,manualShutter:!0,timeoutCapture:!1};case"classified":return $e(e,t.id,t.side);case"duplicate":return xe(e,t.id,t.side);case"readOk":{let n=e.readSides.includes(t.side)?e.readSides:[...e.readSides,t.side],r=["recto","verso"].filter(l=>e.captured[l]!==void 0),i=e.phase==="reading"&&e.pending.length===0&&r.every(l=>n.includes(l));return{...e,readSides:n,flipTimeoutSpent:!1,phase:i?"result":e.phase}}case"readFailed":return Je(e,t);case"clockRestart":return e.lastCaptureAt<0&&e.lastReportAt<0&&e.awaySince===void 0?e:{...e,awaySince:void 0,lastCaptureAt:-1,lastReportAt:-1};case"retake":return{...te(e.layout,-1),lastCaptureAt:-1,lastReportAt:-1};default:return e}}function Ze(e,t,n=!1){let r=e(t);return r===null?"recto":!n||r.y+r.height/2>=t.height/2?"verso":"recto"}async function et(e,t=!1){let{detectMrzBand:n}=await import("./mrz-band-VYHOTDHY.js");return Ze(n,e,t)}async function re(e,t=480,n,r=n!=null){let i=n??{x:0,y:0,width:e.width,height:e.height},l=Math.max(1,Math.round(i.height/i.width*t)),s=document.createElement("canvas");s.width=t,s.height=l;try{let u=s.getContext("2d");return u===null?"recto":(u.drawImage(e,i.x,i.y,i.width,i.height,0,0,t,l),await et(u.getImageData(0,0,t,l),r))}finally{s.width=0,s.height=0}}async function Mt(e,t=480){try{let n=await createImageBitmap(e),r=Math.max(1,Math.round(n.height/n.width*t)),i=document.createElement("canvas");i.width=t,i.height=r;let l=i.getContext("2d");return l===null?(n.close(),null):(l.drawImage(n,0,0,t,r),n.close(),l.getImageData(0,0,t,r))}catch{return null}}var oe=(e,t,n)=>Math.min(n,Math.max(t,Math.round(e))),Y=e=>Math.round(Math.min(1,Math.max(0,e))*1e4)/1e4;async function Le(e,t,n,r){let i=r.decode??(c=>createImageBitmap(c)),l=async()=>e.stillRead(await i(t),r.region??[0,0,1,1],r.detectorLimit),s;try{s=await l()}catch{try{await new Promise(c=>setTimeout(c,r.retryMs??300)),s=await l()}catch{return null}}let u=s.mrzBox;return u===void 0?null:{engine:r.engine,source:"live_mrz",format:n.format,lineCount:oe(n.lineCount,2,3),checkDigitsValid:!0,stillConfirmed:s.valid&&s.digest===n.digest,band:[Y(u[0]),Y(u[1]),Y(Math.min(u[2],1-u[0])),Y(Math.min(u[3],1-u[1]))],digest:n.digest,framesToValid:oe(n.framesToValid,1,1e3),msToValid:oe(n.msToValid,0,12e4)}}function Dt(e){let t=null;return e?.then(n=>{t=n}),()=>t}var tt=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]),nt=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 _e(e,t=globalThis){let n=t.WebAssembly?.validate;if(typeof n!="function")return{ok:!1,reason:"simd"};try{if(!n.call(t.WebAssembly,tt)||!n.call(t.WebAssembly,nt))return{ok:!1,reason:"simd"}}catch{return{ok:!1,reason:"simd"}}if(typeof t.Worker!="function")return{ok:!1,reason:"worker"};if(typeof t.createImageBitmap!="function")return{ok:!1,reason:"bitmap"};let r=t.navigator?.deviceMemory;return typeof r=="number"&&r<e.minDeviceMemoryGb?{ok:!1,reason:"memory"}:{ok:!0}}function Te(e=globalThis){let t=e.navigator?.connection;return t?.saveData===!0||["slow-2g","2g","3g"].includes(t?.effectiveType??"")}var T=class extends Error{constructor(t){super(t),this.name="OcrEngineError",this.code=t}};function Ee(){let e=t=>(t.close(),Promise.reject(new T("unsupported")));return{ready:Promise.resolve("unsupported"),busy:!1,bandRead:e,stillRead:e,layoutRead:e,dispose:()=>{}}}function Oe(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 Ee()}catch{return Ee()}let n=new Map,r=0,i=!1,l=!1,s=!1;t.addEventListener("message",d=>{let g=d.data,C=n.get(g.id);C&&(n.delete(g.id),C.resolve(g))});let u=()=>{for(let d of n.values())d.reject(new T("error"));n.clear(),f()};t.addEventListener("error",u),t.addEventListener("messageerror",u);function c(d,g=[]){if(i)return Promise.reject(new T("disposed"));let C=++r;return new Promise((B,O)=>{n.set(C,{resolve:B,reject:O});try{t.postMessage({...d,id:C},g)}catch{n.delete(C),O(new T("error"))}})}function f(){if(!i){i=!0;try{t.postMessage({id:++r,kind:"dispose"})}catch{}t.terminate();for(let d of n.values())d.reject(new T("disposed"));n.clear()}}let p=(async()=>{let d=await c({kind:"init",baseUrl:e.baseUrl,salt:e.salt,detectorLimit:e.tuning.detectorLimit,maxDownloadMs:e.tuning.maxDownloadMs});if(d.kind==="failed")return d.reason;if(d.kind!=="ready")return"error";let g=await c({kind:"warmup"});return g.kind!=="ready"?"error":{warmupMs:g.warmupMs,downloadMs:d.downloadMs,cached:d.cached}})().catch(()=>"error"),b,S=new Promise(d=>{b=setTimeout(()=>d("timeout"),e.tuning.loadTimeoutMs)}),I=Promise.race([p,S]).then(d=>(clearTimeout(b),typeof d=="string"?f():s=!0,i&&typeof d!="string"?"error":d));(e.page===void 0?globalThis.addEventListener?globalThis:null:e.page)?.addEventListener("pagehide",f,{once:!0});async function w(d,g,C){if(i)throw g.close(),new T("disposed");if(!s)throw g.close(),new T("not_ready");if(l)throw g.close(),new T("busy");l=!0;let B;try{let O=new Promise((k,A)=>{B=setTimeout(()=>{A(new T("timeout")),f()},e.tuning.readTimeoutMs??1e4)}),P=await Promise.race([c(d,[g]),O]);if(P.kind===C){let{id:k,...A}=P;return A}throw new T(P.kind==="error"?P.code:P.kind==="failed"?P.reason:"error")}finally{clearTimeout(B),l=!1}}return{ready:I,get busy(){return l},bandRead:(d,g=e.tuning.detectorLimit)=>w({kind:"band",bitmap:d,detectorLimit:g},d,"band"),stillRead:(d,g,C=e.tuning.detectorLimit)=>w({kind:"still",bitmap:d,region:g,detectorLimit:C},d,"band"),layoutRead:(d,g)=>w({kind:"layout",bitmap:d,detectorLimit:g},d,"layout"),dispose:f}}var U="sekyro-ocr-1",ae=e=>e!==null&&typeof e=="object"?e:{},v=(e,t,n,r)=>typeof e=="number"&&Number.isFinite(e)&&e>=t&&e<=n?e:r,Pe=(e,t)=>typeof e=="boolean"?e:t,Ae=e=>{let t=typeof e=="string"?/^sekyro-ocr-(\d{1,4})$/.exec(e):null;return t?Number(t[1]):Number.POSITIVE_INFINITY};function Be(e,t={}){let n=ae(e),r=ae(n.liveMrz),i=ae(n.frontLock),l=Ae(t.engine??U),s=t.mode==="off",u=d=>d.enabled===!0?d.arm==="live"?"live":"control":null,c=u(r),f=u(i),p=(d,g)=>!s&&g==="live"&&Ae(d.minEngine??U)<=l,b=Se,S=p(r,c)?{detectorLimit:v(r.detectorLimit,320,1600,b.detectorLimit),bandMaxWidthPx:v(r.bandMaxWidthPx,320,4096,b.bandMaxWidthPx),minBandWidthPx:v(r.minBandWidthPx,0,4096,b.minBandWidthPx),bandTop:v(r.bandTop,0,.95,b.bandTop),minIntervalMs:v(r.minIntervalMs,0,5e3,b.minIntervalMs),stableReads:Math.round(v(r.stableReads,1,10,b.stableReads)),profileReads:Math.round(v(r.profileReads,1,100,b.profileReads)),maxReadMs:v(r.maxReadMs,50,6e4,b.maxReadMs),searchTimeoutMs:v(r.searchTimeoutMs,1e3,12e4,b.searchTimeoutMs),hint:Pe(r.hint,!0),stillConfirm:Pe(r.stillConfirm,!0)}:null,I=ye,h=(d,g,C)=>v(i[d],g,C,I[d]),w=p(i,f)?{minLines:Math.round(h("minLines",1,50)),fillMin:h("fillMin",0,1),fillMax:h("fillMax",0,2),offsetMax:h("offsetMax",0,1),steadyFillDelta:h("steadyFillDelta",0,1),steadyOffsetDelta:h("steadyOffsetDelta",0,1),layoutShiftMax:h("layoutShiftMax",0,1),lineCountDelta:Math.round(h("lineCountDelta",0,50)),lockMs:h("lockMs",0,3e4),steadyMs:h("steadyMs",0,3e4),minFrames:Math.round(h("minFrames",1,100)),minIntervalMs:h("minIntervalMs",0,5e3),maxWidthPx:h("maxWidthPx",160,2048),detectorLimit:h("detectorLimit",320,1600),searchTimeoutMs:h("searchTimeoutMs",1e3,12e4)}:null;return{enabled:S!==null||w!==null,liveMrz:S,textLock:w,liveMrzArm:c,frontLockArm:f,load:{detectorLimit:S?.detectorLimit??w?.detectorLimit??b.detectorLimit,loadTimeoutMs:v(r.loadTimeoutMs,1e3,12e4,2e4),maxDownloadMs:v(r.maxDownloadMs,1e3,12e4,2e4),minDeviceMemoryGb:v(r.minDeviceMemoryGb,0,64,2)},reportSampleRate:v(r.reportSampleRate,0,1,1)}}function Ie(e,t){return e.enabled?!(t.probe??_e)({minDeviceMemoryGb:e.load.minDeviceMemoryGb}).ok||(t.slow??Te)()?{ok:!1,reason:"unsupported"}:{ok:!0,engine:Oe({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}:{}})}:{ok:!1,reason:"off"}}function rt(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"}var F=e=>e===void 0||!Number.isFinite(e)?void 0:Math.min(6e5,Math.max(0,Math.round(e))),ie=(e,t,n)=>e===void 0||!Number.isFinite(e)?void 0:Math.min(n,Math.max(t,Math.round(e)));function We(e){let t=e.assist??null,n=e.load!==null&&e.load!==void 0&&typeof e.load=="object"?e.load:null,r=typeof e.load=="string"?e.load:null,i=t!==null?t.outcome:r==="unsupported"||r==="download"||r==="integrity"?r:r==="error"||r==="timeout"?"error":"off",l={kind:"live_mrz",platform:"web",engine:e.engine??U,arm:e.arm,capture:e.capture,outcome:i,reads:ie(t?.reads??0,0,1e4)??0,browser:e.browser??rt()},s=(u,c)=>{c!==void 0&&(l[u]=c)};return s("format",t?.format),s("framesToValid",ie(t?.framesToValid,1,1e4)),s("msToValid",F(t?.msToValid)),s("framesToLock",ie(t?.framesToLock,1,1e4)),s("msToLock",F(t?.msToLock)),s("msToCapture",F(e.msToCapture)),s("readP50Ms",F(t?.readP50Ms)),s("readP90Ms",F(t?.readP90Ms)),s("deviceClass",t?.deviceClass),n!==null&&(s("warmupMs",F(n.warmupMs)),s("downloadMs",F(n.downloadMs)),s("cached",n.cached)),s("stillConfirmed",e.stillConfirmed),s("typeMismatch",e.typeMismatch),l}function se(e,t){return e===void 0?!1:t==="passport"?e!=="TD3":e==="TD3"}var ot=2;async function at(e){let t=await import("./capture-session-doc-QA4DOFRF.js");return new t.CaptureSessionDoc(e)}function it(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}}}function st(e,t,n){let r=[e.topLeft,e.topRight,e.bottomRight,e.bottomLeft],i=0;for(let l=0;l<r.length;l+=1){let s=r[l],u=r[(l+1)%r.length];i+=s.x*u.y-u.x*s.y}return t>0&&n>0?Math.abs(i)/2/(t*n):0}function Gt(){import("./capture-session-doc-QA4DOFRF.js").then(e=>e.warmDocDetector()).catch(()=>{})}function qt(e){return ut(e,{}).handle}function ut(e,t){let n=fe(),r=ge({enabled:e.keepScreenAwake!==!1}),i=t.decode??(o=>createImageBitmap(o)),l=t.blurRefuseSharpnessMax??.16,s=t.now??(()=>performance.now()),u=e.documentType==="passport"||e.side==="single",c=te(u?"singlePage":"twoSided",s());if(!u&&(e.side==="recto"||e.side==="verso")){let o=e.side==="recto"?"verso":"recto";c={...c,captured:{[o]:"server"},readSides:[o],current:e.side,phase:"flipCue",restPhase:"flipCue"}}let f="idle",p=null,b=null,S=!0,I=0,h=0,w=!1,d=!1,g="",C=null,B,O=null,P=[],k=t.webOcr!==void 0?Be(t.webOcr.captureDocument,{mode:e.liveMrz?.mode??"auto"}):null,A=null,z=k===null||!k.enabled?"off":null,G=null,q=null,ue=new WeakMap,Q="";if(k!==null&&k.enabled&&t.webOcr!==void 0){let o=t.webOcr,a=Ie(k,{baseUrl:e.liveMrz?.assetBaseUrl??o.baseUrl,salt:o.salt,...e.liveMrz?.workerUrl!==void 0?{workerUrl:e.liveMrz.workerUrl}:{},...o.createWorker!==void 0?{createWorker:o.createWorker}:{}});if(a.ok){A=a.engine;let m=new Me({textLock:k.textLock,liveMrz:k.liveMrz});G=m;let y=a.engine;y.ready.then(L=>{z=L,typeof L!="string"&&S&&m.setEngine(y)})}else z=a.reason}let N=o=>{let a=JSON.stringify(o);a!==Q&&(Q=a,n.emit("mrz",o))},le=(o,a)=>{let m=t.webOcr?.reports;if(m===void 0||k===null||o===void 0)return;let y=o.format==="ID-3"||o.side==="single"?"single":o.side==="verso"?"verso":"recto",L=y!=="recto"?k.liveMrzArm??k.frontLockArm:k.frontLockArm;if(L===null||Math.random()>=k.reportSampleRate)return;let _=o.via==="live_mrz"?q:null,x=()=>{let E=_?.value??null;m([We({arm:L,capture:y,assist:o.ocr??null,load:L==="control"?"off":z,...o.msToCapture!==void 0?{msToCapture:o.msToCapture}:{},...E!==null&&E.stillConfirmed!==void 0?{stillConfirmed:E.stillConfirmed}:{},...a!==void 0?{typeMismatch:se(a.format,e.documentType==="passport"?"passport":"card")}:{}})])};_!==null&&_.value===null?Promise.race([_.promise,new Promise(E=>setTimeout(E,3e3))]).then(x):x()},W=o=>{!S||o===f||(f=o,r.setActive(o==="starting"||o==="scanning"),n.emit("state",o))},Fe=(o,a)=>a===void 0?null:u?"single":o.captured.recto===a?"recto":o.captured.verso===a?"verso":null,ze=o=>({phase:o.phase,captured:u?o.captured.recto!==void 0?["single"]:[]:["recto","verso"].filter(a=>o.captured[a]!==void 0),expected:u?null:o.current??null,notice:o.notice??null,lastShot:Fe(o,o.lastShot),manualShutter:o.manualShutter,torchAvailable:p?.torchAvailable()??!1,torch:d}),ce=()=>{let o=p;o!==null&&o.captureNow().catch(()=>R({type:"captureFailed",at:s()}))};function R(o){if(!S)return;let a=c;c=ve(c,o),c.phase==="capturing"&&a.phase!=="capturing"&&Promise.resolve().then(ce),c.phase==="result"&&a.phase!=="result"&&(W("done"),de());let m=ze(c),y=JSON.stringify(m);y!==g&&(g=y,n.emit("scan",m))}function de(){O!==null&&clearInterval(O),O=null;for(let o of P.splice(0))o();p?.destroy(),p=null,r.setActive(!1)}let me=()=>p?.captureReport?.(),K=!1,pe=(o,a)=>{if(!(o===void 0||t.onFaceReport===void 0))try{t.onFaceReport(o,a)}catch{}},H=o=>{Q="",!(p===null||c.phase==="reading"||c.phase==="result")&&(K=!1,p.rearm(u?"single":c.current??o))},Ne=async(o,a,m,y)=>{if(q=null,y!==void 0&&A!==null&&k?.liveMrz?.hint===!0){let M={promise:Le(A,o,y,{engine:U,detectorLimit:k.liveMrz.detectorLimit}).catch(()=>null),value:null};M.promise.then(D=>{M.value=D}),q=M}y!==void 0&&se(y.format,e.documentType==="passport"?"passport":"card")&&N({state:"mismatch",format:y.format});let L=me();pe(L,"captured"),K=!0,le(L,y);let _=m===void 0?C:m===null?null:{quad:it(m),frameWidth:0,frameHeight:0,inStill:!0},x={decoded:null},E=()=>(x.decoded??(x.decoded=Promise.resolve().then(()=>i(o)).catch(()=>null)),x.decoded);try{await Ue(o,a,_,E,q)}finally{x.decoded!==null&&(await x.decoded)?.close()}},Ue=async(o,a,m,y,L)=>{let _=`shot-${I+=1}`;if(R({type:"captured",id:_,at:s()}),e.haptics!==!1)try{globalThis.navigator?.vibrate?.(30)}catch{}if(!w&&l>0){let M=await(t.measureSharpness!==void 0?t.measureSharpness(o,m):y().then(D=>D===null?-1:he(D,J(m?.quad??null,m?.inStill===!0?D:{width:m?.frameWidth??0,height:m?.frameHeight??0},D)))).catch(()=>-1);if(!S)return;if(Number.isFinite(M)&&M>=0&&M<l){w=!0;let D=u?"recto":c.current??(c.captured.recto===void 0?"recto":"verso");R({type:"readFailed",side:D,id:_,issue:"blurry"}),H(D);return}}w=!1;let x;if(u)x="single";else{let M=c.current,D=await(t.classify!==void 0?t.classify(o):y().then(X=>X===null?M??"recto":m?.inStill===!0?re(X,480,null,!0):re(X,480,J(m?.quad??null,{width:m?.frameWidth??0,height:m?.frameHeight??0},X)))).catch(()=>M??"recto");if(!S)return;if(c.captured[D]!==void 0&&h<ot){h+=1,R({type:"duplicate",id:_,side:D}),H(D==="recto"?"verso":"recto");return}x=c.captured[D]!==void 0&&M!==void 0?M:D,h=0,R({type:"classified",id:_,side:x})}let E=x==="verso"?"verso":"recto";try{let M=t.encode!==void 0?await t.encode(o):await y().then(D=>{if(D===null)throw new Error("the still could not be decoded");return Z(D)});if(!S)return;L!==null&&ue.set(M.blob,L),n.emit("captured",{image:M.blob,side:x,documentType:e.documentType,...e.issuer!==void 0?{issuer:e.issuer}:{},width:M.width,height:M.height,previewDataUrl:a}),t.deferRead!==!0&&R({type:"readOk",side:E})}catch(M){R({type:"readFailed",side:E,id:_,issue:"technical"}),n.emit("error",V("generic",!0,{phase:"keyframes",name:$(M)}))}H(E==="recto"?"verso":"recto")},Ge=o=>{P.push(o.on("statechange",({state:a})=>{a==="preflight"||a==="acquiring"?W("starting"):a==="positioning"?W("scanning"):a==="captured"?W("captured"):a==="error"&&W("error")}),o.on("feedback",({key:a,reticle:m})=>n.emit("feedback",{key:a,reticle:m})),o.on("checks",a=>{n.emit("gate",{progress:a.p,quad:a.quad,frameWidth:a.frameWidth,frameHeight:a.frameHeight,...a.guide!==void 0?{guide:{detected:a.guide.detected,fill:a.guide.fill,offsetX:a.guide.offsetX??0,offsetY:a.guide.offsetY??0}}:{}});let m=a.ocr?.mrz;m!==void 0&&(m.state==="fallback"?N({state:"fallback",reason:m.reason}):m.state==="valid"?N({state:"valid",format:m.format}):m.state==="reading"?N({state:"reading",...m.format?{format:m.format}:{},...m.coach?{coach:m.coach}:{}}):N({state:"searching"}));let y=a.quad===null?0:st(a.quad,a.frameWidth,a.frameHeight);C=a.quad===null?null:{quad:a.quad,frameWidth:a.frameWidth,frameHeight:a.frameHeight},R({type:"report",report:{present:a.quad!==null&&a.plausible||a.guide?.detected===!0,ready:a.ready===!0,locking:a.p>=.5,areaFrac:y},at:s()})}),o.on("error",({kind:a,retryable:m,detail:y})=>n.emit("error",V(a,m,y))),o.on("artifacts",a=>{Ne(a.keyframe,a.previewDataUrl,a.docRegion,a.liveMrz)}))},j=()=>(b??(b=(async()=>{if(S){if(p===null){let o;try{o=await(t.createEngine??at)({...t.engineOptions??{},...B!==void 0?{guide:B}:{},video:e.video,format:be(e.documentType),side:u?"single":e.side??"recto",autoCapture:!1,...G!==null?{ocr:G}:{}})}catch(m){W("error"),n.emit("error",V("models",!0,{phase:"models",name:$(m)}));return}if(!S){o.destroy();return}p=o,Ge(o);let a=t.tickMs??500;a>0&&(O=setInterval(()=>R({type:"tick",at:s()}),a))}R({type:"clockRestart"}),k!==null&&k.liveMrzArm==="live"&&(z==="unsupported"||z==="off")&&N({state:"fallback",reason:z}),await p.start()}})().finally(()=>{b=null})),b);return{handle:{get state(){return f},on:(o,a)=>n.on(o,a),start:j,retry:()=>{if(p===null&&c.phase==="result"){R({type:"retake"}),h=0,w=!1,j();return}if(p!==null&&f!=="error"){R({type:"retake"}),h=0,w=!1,p.rearm(u?"single":void 0);return}j()},setSide:o=>{u||o==="single"||(c.current!==o&&(c={...c,current:o}),R({type:"clockRestart"}),c.phase!=="reading"&&c.phase!=="result"&&p?.rearm(o))},shutter:ce,focusAt:(o,a)=>{p?.focusAt?.(o,a)},setGuide:o=>{B=o,p?.setGuide?.(o)},setTorch:o=>{d=o,p?.setTorch(o),R({type:"tick",at:s()})},destroy:()=>{if(S&&p!==null&&f!=="done"){let o=me();!K&&o!==void 0&&o.ticks>0&&pe(o,"abandoned"),le(o,void 0)}S=!1,de(),G?.setEngine(null),A?.dispose(),A=null,n.clear()}},setFlowState:o=>{(c.phase==="reading"||c.phase==="result")&&W(o==="done"&&c.phase!=="result"?"scanning":o)},settle:(o,a)=>{let m=o==="verso"?"verso":"recto";R(a.ok?{type:"readOk",side:m}:{type:"readFailed",side:m,issue:a.issue}),a.ok||H(m)},takeDeviceRead:o=>ue.get(o.image)?.value??null}}export{mt as a,ft as b,gt as c,bt as d,ht as e,yt as f,we as g,te as h,ve as i,Ze as j,et as k,Mt as l,Le as m,Dt as n,U as o,Be as p,Ie as q,rt as r,We as s,se as t,ot as u,Gt as v,qt as w,ut as x};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as B,e as re,g as ae,m as oe}from"./chunk-7ZCZY3ZP.js";import{b as ie}from"./chunk-BPE5NSQ2.js";import{a as ue,d as ce}from"./chunk-CJHMFPL6.js";import{a as se}from"./chunk-RI3E7GBN.js";import{a as ee,d as te,e as ne}from"./chunk-GT2ZLGF7.js";import{e as X}from"./chunk-FUHDOEBP.js";import{m as $,n as Z}from"./chunk-CQ7SKLMC.js";var xe=250,be=180,we=96;function le(n){let{data:t,width:e,height:r}=n,a=new Uint8Array(e*r);for(let o=0,u=0;o<a.length;o+=1,u+=4)a[o]=Math.round(.299*(t[u]??0)+.587*(t[u+1]??0)+.114*(t[u+2]??0));return{data:a,width:e,height:r}}function q(n,t){return{x0:Math.max(0,Math.floor(n.x)),y0:Math.max(0,Math.floor(n.y)),x1:Math.min(t.width,Math.ceil(n.x+n.width)),y1:Math.min(t.height,Math.ceil(n.y+n.height))}}function T(n,t,e){let r=q(t,n),a=e===void 0?null:q(e,n),o=0,u=0,s=0,d=0;for(let c=r.y0;c<r.y1;c+=1)for(let y=r.x0;y<r.x1;y+=1){if(a!==null&&y>=a.x0&&y<a.x1&&c>=a.y0&&c<a.y1)continue;let M=n.data[c*n.width+y];o+=1,u+=M,s+=M*M,M>=xe&&(d+=1)}if(o===0)return{mean:0,sd:0,clipped:0,count:0};let m=u/o;return{mean:m,sd:Math.sqrt(Math.max(0,s/o-m*m)),clipped:d/o,count:o}}function me(n){let{box:t}=n,r=(n.leftEye.y+n.rightEye.y)/2-.1*t.height,a=t.y+.85*t.height;return{x:t.x+.15*t.width,y:r,width:.7*t.width,height:Math.max(1,a-r)}}function ve(n,t){let e=me(t),r=T(n,e);if(r.count===0)return null;let a=Math.min(Math.max(t.nose.x,e.x+1),e.x+e.width-1),o=T(n,{x:e.x,y:e.y,width:a-e.x,height:e.height}),u=T(n,{x:a,y:e.y,width:e.x+e.width-a,height:e.height}),s=u.mean>0?o.mean/u.mean:o.mean>0?Number.POSITIVE_INFINITY:1;return{faceLuma:r.mean,halfRatio:s,clipped:r.clipped}}function Ce(n,t){let e=0,r=0;for(let a of[t.leftEyeBox,t.rightEyeBox]){let o=a.width*.15,u=a.height*.5,s=T(n,{x:a.x-o,y:a.y-u,width:a.width+2*o,height:a.height+2*u});e+=s.count,r+=s.clipped*s.count}return e===0?null:r/e}function Pe(n,t){let e=re(t),{box:r}=t,a={x:r.x-.2*r.width,y:e.y,width:1.4*r.width,height:r.y+r.height-e.y},o=0,u=0,s=0;for(let m of[e.x,e.x+.8*e.width]){let c=T(n,{x:m,y:e.y+.04*e.height,width:.2*e.width,height:.25*e.height},a);o+=c.count,u+=c.mean*c.count,s+=(c.sd*c.sd+c.mean*c.mean)*c.count}if(o===0)return null;let d=u/o;return{luma:d,sd:Math.sqrt(Math.max(0,s/o-d*d)),count:o}}function ke(n,t){let e=q(me(t),n),r=Math.max(1,Math.floor(Math.max(e.x1-e.x0,e.y1-e.y0)/we)),a=(m,c)=>n.data[c*n.width+m],o=0,u=0,s=0;for(let m=e.y0+r;m<e.y1-r;m+=r)for(let c=e.x0+r;c<e.x1-r;c+=r){let y=a(c,m-r)+a(c-r,m)+a(c+r,m)+a(c,m+r)-4*a(c,m);o+=1,u+=y,s+=y*y}if(o===0)return null;let d=u/o;return Math.min(1,Math.max(0,s/o-d*d)/be)}function de(n,t){return{lighting:ve(n,t),eyeSpecular:Ce(n,t),background:Pe(n,t),sharpness:ke(n,t)}}var Me="/models-v3",Le=640,Se=.92;function N(n){return{width:n.videoWidth||0,height:n.videoHeight||0}}function W(n,t){if(typeof document<"u"){let e=document.createElement("canvas");return e.width=n,e.height=t,e}return typeof OffscreenCanvas=="function"?new OffscreenCanvas(n,t):null}function Fe(){let n=null;return(t,e)=>{let{width:r,height:a}=N(t);if(r===0||a===0)return null;let o=e===null?1:Math.min(1,e/Math.max(r,a)),u=Math.round(r*o),s=Math.round(a*o),d;e===null?d=W(u,s):((n===null||n.width!==u||n.height!==s)&&(n=W(u,s)),d=n);let m=d?.getContext("2d",{willReadFrequently:!0});if(d==null||m==null)return null;m.drawImage(t,0,0,u,s);let c=null;try{c=m.getImageData(0,0,u,s)}catch{c=null}return{source:d,width:u,height:s,pixels:c}}}async function Te(n,t,e,r){let a=Math.round(e*t.width/t.height),o=W(a,e),u=o?.getContext("2d");if(o==null||u==null)throw new Error("canvas unavailable");return u.fillStyle="#fff",u.fillRect(0,0,a,e),u.drawImage(n.source,t.x,t.y,t.width,t.height,0,0,a,e),"convertToBlob"in o?o.convertToBlob({type:"image/jpeg",quality:r}):new Promise((s,d)=>{o.toBlob(m=>m===null?d(new Error("encode failed")):s(m),"image/jpeg",r)})}var Y=class extends Error{};function Ee(n,t,e){return new Promise((r,a)=>{let o=setTimeout(()=>{a(new Y(`init exceeded ${t}ms`)),n.then(e,()=>{})},t);n.then(u=>{clearTimeout(o),r(u)},u=>{clearTimeout(o),a(u)})})}function Ie(n){let t=$(n),e=t==="overconstrained"?"generic":t;return{kind:e,retryable:e!=="insecure"&&e!=="unsupported"}}function Re(n,t,e,r){let a=n.length===1?n[0]:void 0,o=a===void 0?null:B(a.landmarks,e,r),u=null;if(a!==void 0&&t.pixels!==null){let s=B(a.landmarks,t.width,t.height),d=le(t.pixels);s!==null&&(u=de(d,s))}return{frameWidth:e,frameHeight:r,faces:n.length,geometry:o,matrix:a?.matrix??null,blendshapes:a?.blendshapes??null,stats:u}}function ze(n,t={},e=()=>"self"){let r=ie(n.tuning,n.tuningVersion),a=ee(),o=t.now??(()=>performance.now()),u=t.setTimer??((i,l)=>setTimeout(i,l)),s=t.clearTimer??(i=>clearTimeout(i)),d=t.grabFrame??Fe(),m=t.encodeRegion??Te,c=t.getUserMedia??(i=>navigator.mediaDevices.getUserMedia(i)),y=t.createLandmarker??ce,M=n.assetBaseUrl??Me,j=ne({enabled:n.keepScreenAwake!==!1}),L=oe(r,{policy:n.policy??"reject"}),b=n.video,K=se({tuning:r.backgroundCheck,assetBaseUrl:M,...t.createSegmenter!==void 0?{createSegmenter:t.createSegmenter}:{},now:o}),h="idle",C=null,x=null,E=null,G=!1,f=!1,g=0,z=0,A=[],w="user",O=!1,he=t.canChooseFacing??te,S=i=>{h===i||f||(h=i,j.setActive(i==="starting"||i==="gating"),a.emit("state",i))},U=()=>{E!==null&&s(E),E=null},I=()=>{U();for(let i of C?.getTracks()??[])i.stop();C=null;try{b.srcObject=null}catch{}},H=i=>{I(),S("error"),a.emit("error",i)},J=()=>{let i=Math.max(o(),z+1);return z=i,i},fe=async i=>{let l=d(b,null),{width:P,height:k}=l??N(b);if(l===null||x===null){L.reset();return}let p=x.detect(l.source,J()),v=(p.length===1?p:A.length===1?A:[])[0],F=v===void 0?null:B(v.landmarks,P,k);if(F===null){L.reset();return}let R=ae(F,P,k,{margin:r.cropMargin,minWidth:r.resolution.minWidth,minHeight:r.resolution.minHeight}),V=Math.max(r.resolution.minHeight,R.height),ye=await m(l,R,V,Se);if(f||i!==g)return;let Q={image:ye,width:Math.round(V*R.width/R.height),height:V,gate:L.summary()};r.tuningVersion!==null&&(Q.tuningVersion=r.tuningVersion),U(),S("captured"),a.emit("captured",Q)},_=async i=>{if(!(f||i!==g||h!=="gating"||x===null)){if(!G){G=!0;try{let l=d(b,Le);if(l!==null){let{width:P,height:k}=N(b),p=x.detect(l.source,J());A=p;let v=Re(p,l,P||l.width,k||l.height);v.geometry!==null&&r.background.required&&(v.backgroundCheck=K.measure(l,v.geometry.box,P||l.width,k||l.height));let F=L.push(v,o());if(f||i!==g||(a.emit("gate",F),F.ready&&(await fe(i),h!=="gating")))return}}catch{}finally{G=!1}}!f&&i===g&&h==="gating"&&(E=u(()=>{_(i)},1e3/r.cadenceHz))}},ge=()=>Ee(y(M),2e4,i=>i.close()),pe=async i=>{if(e()!=="assisted")return"user";let l=i??(O?void 0:n.facing);if(l!==void 0)return l;if(O)return w;try{return await he()?"environment":"user"}catch{return"user"}},D=async i=>{if(f||h==="starting"||h==="gating")return;g+=1;let l=g;L.reset(),S("starting");let P=await pe(i?.facing);if(f||l!==g)return;if(C!==null&&P!==w&&I(),w=P,O=!0,C===null&&t.getUserMedia===void 0&&(typeof navigator>"u"||typeof navigator.mediaDevices?.getUserMedia!="function")){H({kind:typeof window<"u"&&window.isSecureContext===!1?"insecure":"unsupported",retryable:!1});return}let k=x!==null?Promise.resolve(x):ge();k.catch(()=>{});try{if(C===null){let p=await c({video:{facingMode:w,width:{ideal:r.camera.width},height:{ideal:r.camera.height}},audio:!1});if(f||l!==g){for(let v of p.getTracks())v.stop();return}C=p,Z(p),w=X(p)??w,b.srcObject=C,b.muted=!0,b.playsInline=!0,await b.play().catch(()=>{})}}catch(p){!f&&l===g&&H(Ie(p));return}try{x=await k}catch{!f&&l===g&&H({kind:"generic",retryable:!0});return}f||l!==g||(S("gating"),_(l))};return{handle:{get state(){return h},get captureMode(){return e()},get facingMode(){return w},on:(i,l)=>a.on(i,l),start:D,retry:()=>{if(!f){if(C!==null&&x!==null&&h!=="error"){g+=1;let i=g;U(),L.reset(),S("gating"),_(i);return}h="idle",D()}},switchCamera:()=>{if(f||e()!=="assisted"||h!=="idle"&&h!=="starting"&&h!=="gating"&&h!=="error")return!1;let i=w==="user"?"environment":"user";return g+=1,I(),w=i,h="idle",D({facing:i}),!0},destroy:()=>{f||(g+=1,I(),j.setActive(!1),f=!0,x?.close(),x=null,K.close(),a.clear())}},setFlowState:i=>{(h==="captured"||h==="uploading"||h==="checking"||h==="done"&&i==="done")&&S(i)}}}function Je(){import("@mediapipe/tasks-vision").catch(()=>{})}export{xe as a,be as b,le as c,T as d,ve as e,Ce as f,Pe as g,ke as h,de as i,Le as j,Se as k,Fe as l,Re as m,ze as n,Je as o};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{A as Ee,B as Te,a as Re,b as Ie,c as Ae,d as ee,e as Oe,f as we,h as D,i as H,j as G,k as Me,l as E,m as K,n as b,o as q,p as x,q as te,r as w,s as N}from"./chunk-5ZKQHFFW.js";import{n as xe}from"./chunk-W2WD7PR2.js";import{a as be}from"./chunk-GT2ZLGF7.js";import{c as Pe,d as X}from"./chunk-FUHDOEBP.js";import{c as z,g as ve,h as Y}from"./chunk-NJML6FMD.js";function Z(e){return e.idNumberBound??e.nniBound}function L(e){return e===void 0?void 0:e.idNumberFromDocument??e.nniFromDocument}function Ve(e){let t=e.idNumberMasked??e.nniMasked;return typeof t=="string"&&t!==""?t:void 0}var it="https://api.sekyro.ai",rt=5e3,st=1500,at=10;function ct(e){return new Promise(t=>setTimeout(t,e))}function ut(){let e=globalThis.crypto;if(e!==void 0&&typeof e.randomUUID=="function")return e.randomUUID();let t=new Uint8Array(16);if(e!==void 0&&typeof e.getRandomValues=="function")e.getRandomValues(t);else for(let i=0;i<16;i+=1)t[i]=Math.floor(Math.random()*256);t[6]=(t[6]??0)&15|64,t[8]=(t[8]??0)&63|128;let o=[...t].map(i=>i.toString(16).padStart(2,"0")).join("");return`${o.slice(0,8)}-${o.slice(8,12)}-${o.slice(12,16)}-${o.slice(16,20)}-${o.slice(20)}`}function Qt(e){return dt(e,{})}function dt(e,t){let o=e.apiOrigin??it,i=e.autoRetry??!0,r=e.rearm??"auto",s=t.client??new ve({apiOrigin:o,sessionToken:e.clientToken,fetch:e.fetch}),u=t.sleep??ct,a=t.uuid??ut,l=t.getTurnstileToken??((n,c)=>import("./turnstile-FATNZ4AG.js").then(p=>p.executeTurnstile(n,c))),f=be(),m=null,g=null,d=!1,k=new AbortController,h=null,A=null,U=null,se=()=>Oe(ee(h),U),v=n=>{h=n,f.emit("view",n),m?.onView(n)},_=()=>h!==null?Promise.resolve(h):(A??(A=s.getSession().then(n=>(v(n),n)).finally(()=>{A=null})),A),R=async()=>{let n=await s.getSession();return v(n),n},W=async(n,c)=>{n.plan!==void 0?v(n):await R()},$=null,ae=async n=>{let c=await _();if(!n&&c.consentRecorded)return;let p=await s.recordConsent(e.locale);p.plan!==void 0?v(p):h!==null&&v({...h,consentRecorded:!0})},M=n=>n?.force===!0?ae(!0):($??($=ae(!1).finally(()=>{$=null})),$),J={client:s,ensureConsent:n=>M(n),sleep:u,uuid:a,...t.random!==void 0?{random:t.random}:{},onBusy:n=>{d||f.emit("busy",n)}},ce=!1,ue=null,Q=n=>{if(n.status==="approved"||n.status==="rejected"||n.status==="review"){if(ce)return;ce=!0}ue=JSON.stringify(n),f.emit("result",n)},Ye=n=>{ue!==JSON.stringify(n)&&Q(n)},de=async n=>{let c=h;n&&(c=await R().catch(()=>h));let p=c===null?null:E(c);return p!==null&&!d&&f.emit("method",p),p!==null},le=null,pe=!1,fe=!1,me=()=>Ee(J,(n,c)=>n.submitCheck("population_registry",{},{idempotencyKey:c})),he=n=>Z(n)===!0||L(x(n,"population_registry"))===!0,Ze=async()=>{try{let n=await _();if(b(n)||E(n)!==null||q(n)?.checkType!=="population_registry")return;if(!he(n)&&L(x(n,"population_registry"))===void 0&&(n=await R()),!he(n)){fe=!0;return}await M(),await W(await me(),"population_registry");let c=h===null?void 0:x(h,"population_registry");if(c?.state==="input_required"&&c.reason==="registry_unavailable"&&G(c)>0){if(await u(rt),d)return;await W(await me(),"population_registry")}}catch(n){if(n instanceof z&&(n.code==="check_not_active"||n.code==="step_not_on_path")){await R().catch(()=>{});return}pe=!0;return}h!==null&&b(h)&&Q(N(h,{autoRetry:i}))},Se=()=>(le??(le=Ze()),le),We=async()=>{let c=(await _()).turnstileSiteKey;return c===null?{sandbox:!0}:{channel:"hosted_web",siteKey:c,turnstileToken:await l(c,{signal:k.signal})}},F=n=>{if(d)return;let c=s.reportCaptureIssue;if(c===void 0)return;let p=n.formFactor;try{p??(p=Pe())}catch{}try{Promise.resolve(c.call(s,{...n,...p!==void 0?{formFactor:p}:{}})).catch(()=>{})}catch{}},P=null,ye=Promise.resolve(),V=0,$e=async()=>{let n=await _();for(let c=0;c<at&&!d&&!b(n)&&q(n)===void 0&&H(n).some(p=>p.state==="processing")&&(await u(st),!d);c+=1)n=await R();return n},Je=async(n,c,p)=>{let{capture:C}=n,y=()=>d,B=()=>n.alive&&n.attempt===p,ke=S=>{B()&&C.setFlowState(S)},O=S=>{if(!y()&&(S.status==="unavailable"&&S.reason!==void 0&&!Re(S.reason)&&F({check:"liveness",kind:"unavailable",phase:"upload",engineKind:S.reason,attempt:Math.max(0,n.issues.value)}),Q(S),!!B())){if(S.status==="retry"&&r==="auto"){C.handle.retry();return}C.setFlowState("done")}};if(c.degraded==="NO_RECORDER"){let S=h?.sessionId??(await _().catch(()=>null))?.sessionId??"";O(w(S,"no_recorder"));return}ke("uploading");try{if(await Se(),y())return;let S=await _(),_e;if(!b(S)&&E(S)!==null){await de(!1),O(w(S.sessionId,"method_required"));return}if(!b(S)){if(q(S)?.checkType==="population_registry"){O(w(S.sessionId,fe?"nni_unbound":pe?"network":"registry_unavailable"));return}if(await M(),y())return;_e=h??S;let j=await Te({...J,artifacts:c,getAttestation:We,getView:()=>h??S,refreshView:R,applySubmit:W,onPhase:ke,isCancelled:y,onKeyframePromoted:ot=>{g=ot}});if(y())return;if(j.kind==="unavailable"){O(w(S.sessionId,j.reason));return}if(j.kind==="resync"&&await R(),h!==null&&E(h)!==null){await de(!1),O(w(S.sessionId,"method_required"));return}S=await $e()}O(N(S,{autoRetry:i,previous:_e}))}catch{if(y())return;O(w(h?.sessionId??"","network"))}},Qe=(n,c)=>{let p=n.attempt;V>0&&n.alive&&n.capture.setFlowState("uploading"),V+=1,ye=ye.then(()=>Je(n,c,p)).finally(()=>{V-=1,V===0&&m?.onChainIdle()}).catch(()=>{})},ge=n=>{P?.capture.handle.destroy(),P!==null&&(P.alive=!1);let c=xe(n,m?.captureInternals?.(n)??t.capture,()=>h?.capture?.liveness?.keyframe?.rank===!0,se,()=>h?.capture?.liveness?.screenRamp),p={capture:c,alive:!0,attempt:0,issues:Ae()};P=p,c.handle.on("error",y=>{F(Ie("liveness",y,p.issues.value))}),c.handle.on("state",y=>{p.issues.note(y),y==="starting"&&(p.attempt+=1)}),c.handle.on("captured",y=>{Promise.resolve().then(()=>Qe(p,y))});let C=c.handle;return{get state(){return C.state},get captureMode(){return C.captureMode},get facingMode(){return C.facingMode},on:(y,B)=>C.on(y,B),start:async y=>{if(h===null&&await _().catch(()=>{}),!!p.alive)return C.start(y)},retry:()=>C.retry(),switchCamera:()=>C.switchCamera(),destroy:()=>{p.alive=!1,P===p&&(P=null),C.destroy()}}},je=async()=>{if(d)return null;try{let n=await _();return d?null:E(n)}catch{return null}},Xe=async()=>{if(d)return"self";try{let n=await _();if(d)return"self";let c=ee(n);return c==="choice"?U??c:c}catch{return"self"}},ze=async()=>{if(d)return!1;try{let n=await _();if(d||b(n))return!1;let c=x(n,"liveness");return K(c)&&c?.requiresMobile===!0&&!X()}catch{return!1}},et=async()=>{if(d)return!1;try{let n=await _();return!d&&n.returning===!0}catch{return!1}},tt=async n=>{let c=(await _()).plan?.choice,p=c?.options.find(y=>D[y.service]===n);if(!p)throw new RangeError(`method ${String(n)} is not offered`);let C=await s.choose(c.nodeId,p.id);d||v(C)},Ce=null,nt=()=>(Ce??(Ce=import("./plan-runner-35655N4Z.js").then(n=>{let c=n.createPlanRunner({runtime:J,currentView:()=>h,cameraMode:se,ensureView:_,refreshView:R,ensureConsent:()=>M(),liveness:ge,chainBusy:()=>V>0,destroyed:()=>d,sleep:u,isMobile:X,now:t.now??Date.now,keptFaceKey:()=>g,setView:v,baseCapture:t.capture,emitStep:p=>{d||f.emit("step",p)},emitResult:Ye,reportCaptureIssue:F,documentInternals:t.document,portraitInternals:t.portrait,livePhotoInternals:t.livePhoto,uploadInternals:t.upload});return m=c,c})),Ce);return{consent:()=>M(),startRegistry:Se,methodChoice:je,selectMethod:tt,reportCameraUnavailable:async n=>{await M();let c=s.reportCameraUnavailable;if(c===void 0)throw new TypeError("this client cannot report a missing camera");let p=await c.call(s,n).catch(C=>{if(C instanceof z&&C.code==="check_out_of_order")return s.getSession();throw C});d||v(p)},reportCaptureIssue:F,mobileRequired:ze,captureMode:Xe,chooseCaptureMode:n=>{U=n},get captureChoice(){return U},returning:et,liveness:ge,run:async()=>{if(d)throw new Error("verification destroyed");return(await nt()).run()},currentStep:()=>m?.current()??null,voiceClips:async()=>{if(d)return null;try{let n=await _();return d?null:n.voice??null}catch{return null}},on:(n,c)=>f.on(n,c),destroy:()=>{d=!0,k.abort(),m?.destroy(),P!==null&&(P.alive=!1,P.capture.handle.destroy(),P=null),f.clear()}}}var De=["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"];var lt=["carte_identite","passport","residence_permit"];function pt(e,t){let o=e.byIssuer?.[t]??e.default;return lt.filter(i=>o==="*"||o.includes(i))}function en(e,t=De){return[...new Set([...t,...Object.keys(e.byIssuer??{})])].filter(i=>pt(e,i).length>0).sort()}function He(e){if(e.acceptedDocuments)return e.acceptedDocuments;let t=e.acceptedDocumentTypes?.length?[...e.acceptedDocumentTypes]:["carte_identite","passport"];return{default:[],byIssuer:{MR:t}}}function tn(e){return/^[A-Z]{2}$/.test(e)?String.fromCodePoint(...[...e].map(t=>127462+t.charCodeAt(0)-65)):""}var un=["national_number","document_photo","national_eid"],ft=new Set(["phone_otp","email_otp","national_eid","document","nfc","population_registry","supplied_identity","summary_confirm","liveness","portrait","face_match","aml_screening","face_dedup","age_estimation"]),mt=new Set(["supplied_identity","aml_screening","face_dedup","age_estimation"]),oe=["document","population_registry","national_eid"],ie=["phone_otp","email_otp"],Ue={identity_method:oe,contact:ie},ht=["population_registry","document"],Fe="platform_unsupported",St=new Set(["prefilled","user_entered","prefilled_or_entered"]),yt={phone_otp:"contact",email_otp:"contact",eid_auth:"identity",doc_ocr:"identity",nfc_chip:"identity",population_registry:"identity",liveness:"live_photo",portrait_icao:"live_photo",face_match:"live_photo"};function I(e){return e.section??yt[e.checkType]??null}function gt(e,t){let o=e.plan?.choice;if(o===void 0||o.locked)return;let i=o.options.find(r=>r.id!==o.selected&&r.available!==!1&&t.includes(r.service));return i===void 0?void 0:{nodeId:o.nodeId,option:i}}function re(e){let t=e.plan,o=t?.choice;if(t===void 0||o===void 0||o.locked||t.current===null||t.current===o.nodeId||b(e))return null;let i=Ue[o.kind]??[...oe,...ie],r=o.options.flatMap(a=>a.available===!1||!i.includes(a.service)?[]:[a.nationalEid!=null?{id:a.id,service:a.service,nationalEid:a.nationalEid}:{id:a.id,service:a.service}]),s=t.steps.find(a=>a.id===t.current)?.service,u=o.selected??r.find(a=>a.service===s)?.id??null;return r.some(a=>a.id!==u)?{nodeId:o.nodeId,kind:o.kind,current:u,options:r}:null}function Be(e){return e==null?[]:e.options.filter(t=>t.id!==e.current)}function Ct(e){let t=(e.plan?.sections??[]).map(r=>({id:r.id,state:r.state})),o={sessionId:te(e.sessionId),orgName:e.orgName,returning:e.returning===!0,consentRecorded:e.consentRecorded,expiresAt:e.expiresAt,sections:t.map(r=>r.id),progress:t,purpose:e.purpose??"identity"};e.branding!==void 0&&(o.branding=e.branding),e.cameraUnavailableHandled===!0&&(o.cameraUnavailableHandled=!0);let i=re(e);return i!==null&&(o.switchable=i),o}function kt(e){let t={attemptsRemaining:G(e),attemptsExhausted:e.attemptsExhausted===!0};return e.reason!==void 0&&(t.reason=e.reason),e.retakeHint!==void 0&&(t.retakeHint=e.retakeHint),t}var Ge={phone_otp:"phone",email_otp:"email"};function _t(e,t){let o=gt(e,[t==="phone_otp"?"email_otp":"phone_otp"]);return o===void 0?void 0:Ge[o.option.service]}function Pt(e,t,o,i){let r=t.checkType==="email_otp",s=(r?t.emailOtp:t.otp)??{},u=r?t.emailOtp?.emailSource:t.otp?.numberSource,a=u!==void 0&&St.has(u)?u:r?"prefilled_or_entered":"user_entered",l=typeof s.sentToMasked=="string"&&s.sentToMasked.length>0,f=s.prefilled===!0,m=_t(e,r?"email_otp":"phone_otp"),g={key:t.checkType,context:o,section:I(t),phase:l?"verify":"send",canSwitch:m!==void 0,...i},d=r?{kind:"email_otp",...g,emailSource:a,needsEmail:a!=="prefilled"&&!f}:{kind:"phone_otp",...g,numberSource:a,needsPhone:a!=="prefilled"&&!f,channels:(t.otp?.channels??[]).filter(k=>k==="whatsapp"||k==="sms")};if(m!==void 0&&(d.switchChannel=m),f&&(d.prefilled=!0),l&&(d.sentToMasked=s.sentToMasked),!r&&t.otp?.channel!==void 0&&(d.channel=t.otp.channel),!r&&Array.isArray(t.phoneCountries)&&(d.phoneCountries=t.phoneCountries.filter(k=>typeof k=="string"&&/^[A-Z]{2}$/.test(k))),!r&&Array.isArray(t.phoneRules)){let k=d.phoneCountries??[];d.phoneRules=t.phoneRules.flatMap(h=>{let A=vt(h);return A!==void 0&&k.includes(A.code)?[A]:[]})}return!r&&t.phoneInternational===!0&&(d.phoneInternational=!0),s.expiresAt!==void 0&&(d.codeExpiresAt=s.expiresAt),s.resendAvailableAt!==void 0&&(d.resendAvailableAt=s.resendAvailableAt),d}var bt=/^[\d[\]\-|()?:^]{1,64}$/;function xt(e){try{return typeof e=="string"&&bt.test(e)&&new RegExp(e)!==null}catch{return!1}}var Ne=e=>typeof e=="number"&&Number.isInteger(e)&&e>=1&&e<=15;function vt(e){let{code:t,dial:o,trunk:i,lengths:r,formats:s}=e??{};if(typeof t!="string"||typeof o!="string"||!/^\d{1,3}$/.test(o)||i!==void 0&&(typeof i!="string"||!/^\d{1,3}$/.test(i))||!Array.isArray(r)||r.length===0||!r.every(Ne))return;let u={code:t,dial:o,lengths:[...r].sort((a,l)=>a-l)};if(i!==void 0&&(u.trunk=i),s!==void 0){if(!(Array.isArray(s)&&s.length<=8&&s.every(l=>xt(l?.leading)&&Array.isArray(l.groups)&&l.groups.every(Ne)&&r.includes(l.groups.reduce((f,m)=>f+m,0)))))return;u.formats=s.map(l=>({leading:l.leading,groups:[...l.groups]}))}return u}function Rt(e,t,o,i){let r=Z(e)===!0?"bound":L(t)===!0?"document":"typed",s=r==="typed"&&t.state==="input_required"&&t.reason!==void 0&&we(t.reason)==="id_number_recheck",u=Be(re(e)),a=!i.attemptsExhausted&&u.length===1&&u[0]?.service==="document";return{kind:"registry",key:"registry",context:o,section:I(t),state:t.state==="input_required"?"input_required":"pending",source:r,recheck:s,canUseDocument:a,...i}}function It(e,t,o,i){let r=[...t.acceptedSides??[]],s={kind:"document",key:"document",context:o,section:I(t),side:r.includes("recto")?"verso":"recto",acceptedSides:r,documents:He(e),photo:Ke(e.documents),...i};return At(e)&&(s.ageStepUp=!0),s}function Ke(e,t=!0){let o=e?.source==="upload"||e?.source==="choice"?e.source:"camera",i=e?.sourcePick==="camera"||e?.sourcePick==="upload"?e.sourcePick:null;return{source:o,pick:i,uploadOffered:t&&e?.uploadOffered===!0}}function At(e){let t=H(e).find(i=>i.checkType==="age_estimation"),o=t?.reason;return t?.state==="failed"&&(o==="age_uncertain"||o==="age_unavailable")}function Ot(e){let t=x(e,"liveness");return t?.state==="passed"||t?.state==="review"}function Le(e,t,o,i,r){let s=t.icao?.report,u=e.portrait,a=r==="capture"?u?.pendingFix??null:null;a!==null&&(r="review");let l=qe(e);return{kind:"portrait",key:`portrait:${r}`,context:o,section:I(t),phase:r,report:Array.isArray(s)?s:null,review:t.state==="review",tuning:e.capture?.icao??null,tuningVersion:e.capture?.tuningVersion??null,icao:Y(e),retakeOnly:r==="capture"&&t.state==="input_required"&&l===void 0&&e.capture?.livePhoto?.oneCapture===!0&&Ot(e),photo:Ke(u,r==="capture"),pendingFix:a,...l!==void 0?{captureMode:l}:{},...u?.reuse?.pending===!0?{reuse:!0}:{},...i}}function qe(e){let t=e.portrait?.captureMode;return t==="self"||t==="assisted"||t==="choice"?t:void 0}var ne={minLongSidePx:1280,jpegQuality:.95};function wt(e,t){let o=e.capture?.livePhoto;if(o?.oneCapture!==!0)return null;let i=x(e,"portrait_icao"),r=o.still??ne;return{icao:t==="liveness"&&Y(e)!==null&&qe(e)===void 0&&i!==void 0&&i.state==="pending"&&i.reason===void 0,still:{minLongSidePx:r.minLongSidePx??ne.minLongSidePx,jpegQuality:r.jpegQuality??ne.jpegQuality}}}function Mt(e,t,o,i){let r=t.eid,s=I(t);if(r===void 0||r.challenge!=="app_code")return{kind:"unsupported",key:"unsupported:eid_auth",context:o,section:s,checkType:"eid_auth",reason:"update_required"};let u=Be(re(e)),a=u.length===1&&ht.includes(u[0]?.service??"")?u[0]:void 0,l=a===void 0?void 0:D[a.service],f=l!==void 0,m={kind:"eid",key:"eid",context:o,section:s,provider:r.provider,providerName:r.providerName,country:r.country,challenge:"app_code",phase:r.awaiting==="code"?"code":"identifier",identifierBound:r.identifierBound===!0,canUseCamera:f,afterPass:r.afterPass==="continue"?"continue":"end",...i};return f&&(m.cameraMethod=l),r.expiresAt!==void 0&&(m.codeExpiresAt=r.expiresAt),r.resendAvailableAt!==void 0&&(m.resendAvailableAt=r.resendAvailableAt),r.resendsRemaining!==void 0&&(m.resendsRemaining=r.resendsRemaining),r.codeAttemptsRemaining!==void 0&&(m.codeAttemptsRemaining=r.codeAttemptsRemaining),m}function Et(e,t){if(t.checkType!=="face_match"||t.reason!==void 0)return null;let o=x(e,"portrait_icao");return o!==void 0&&(o.state==="passed"||o.state==="review")?o:null}function Tt(e){return H(e).filter(t=>t.state==="failed").pop()?.attemptsExhausted===!0}function Vt(e,t){let o=e.failureReason,i;o===Fe?i="platform_unsupported":e.status==="expired"?i="expired":e.status==="review_pending"?i="review":e.status==="completed"&&e.outcome==="approved"?i="approved":e.status==="completed"&&e.outcome==="review"?i="review":o==="device_cooldown"?i="cooldown":o!==void 0?i="policy_stop":Tt(e)?i="attempts_exhausted":i="rejected";let r=i==="platform_unsupported"?{sessionId:te(e.sessionId),status:"unavailable"}:N(e,{autoRetry:!1}),s={kind:"result",key:"result",context:t,section:null,display:i,result:r};return o!==void 0&&(s.failureReason=o),e.retryAfter!==void 0&&(s.retryAfter=e.retryAfter),s}function Dt(e,t,o){let i=e.identitySummary;if(i==null)return null;let r={kind:"identity_summary",key:"identity_summary",context:t,section:o??"identity",summaryKind:i.kind==="partial"?"partial":i.kind??"full",source:i.source,portraitAvailable:i.portrait?.available===!0,retakeAvailable:i.retakeAvailable===!0};for(let u of Ht){let a=i[u];typeof a=="string"&&a!==""&&(r[u]=a)}let s=Ve(i);return s!==void 0&&(r.idNumberMasked=s,r.nniMasked=s),r}var Ht=["fullName","birthDate","birthYear","nationality","documentType","documentNumberMasked","expiryDate","retakeTarget"];function T(e,t,o,i){return{kind:"unsupported",key:`unsupported:${o}`,context:e,section:t,checkType:o,reason:i}}function Nt(e){return e.kind==="contact"?"contact":(e.kind==="identity_method","identity")}function Lt(e,t){let o=Ue[e.kind]??[...oe,...ie],i=Nt(e),r=e.options.flatMap(u=>{if(u.available===!1||!o.includes(u.service))return[];let a={id:u.id,service:u.service};u.nationalEid!=null&&(a.nationalEid=u.nationalEid);let l=(u.channels??[]).filter(f=>f==="whatsapp"||f==="sms");return u.service==="phone_otp"&&l.length>0&&(a.channels=l),[a]});if(r.length===0){let u=e.options.length>0&&e.options.every(a=>a.service==="nfc");return T(t,i,"choice",u?"platform_unsupported":"update_required")}let s={nodeId:e.nodeId,kind:e.kind,selected:e.selected,options:r};if(e.kind==="identity_method"){let u={kind:"method",key:"method",context:t,section:i,options:r.map(l=>D[l.service]),choice:s},a=r.find(l=>l.nationalEid!==void 0)?.nationalEid;return a!==void 0&&(u.nationalEid=a),u}return e.kind==="contact"?{kind:"contact_choice",key:"contact_choice",context:t,section:i,options:r.map(u=>Ge[u.service]),selected:null,locked:!1,choice:s}:{kind:"choice",key:`choice:${e.nodeId}`,context:t,section:i,choice:s}}function dn(e,t={}){let o=Ct(e);if(b(e)||e.failureReason===Fe)return Vt(e,o);let i=e.plan;if(i===void 0||!Array.isArray(i.sections))return T(o,null,"plan","update_required");let r=Me(e);if(r!==null)return Lt(r,o);let s=i.current===null?void 0:i.steps.find(g=>g.id===i.current),u=g=>{let d={kind:"processing",key:"processing",context:o,section:g!==void 0?I(g):i.sections.find(k=>k.state==="current")?.id??null,stalled:!1};return typeof g?.service=="string"&&g.service!==""&&(d.service=g.service),d};if(i.current===null)return u(i.steps.find(g=>g.state==="processing"));if(s===void 0)return T(o,null,"step","update_required");if(!ft.has(s.service))return s.interaction==="server"?u(s):T(o,I(s),s.service,"update_required");if(mt.has(s.service)||!K(s))return u(s);let a=s,l=kt(a),f=a.checkType,m=I(a);switch(f){case"phone_otp":case"email_otp":return Pt(e,a,o,l);case"population_registry":return Rt(e,a,o,l);case"eid_auth":return Mt(e,a,o,l);case"doc_ocr":return It(e,a,o,l);case"identity_confirm":return Dt(e,o,m)??u(a);case"portrait_icao":return Le(e,a,o,l,"capture");case"liveness":case"face_match":{let g=Et(e,a);if(g!==null)return Le(e,g,o,l,"match");let d=a.requiresMobile===!0,k=Y(e);return d&&t.isMobile===!1?{kind:"mobile_required",key:"mobile_required",context:o,section:m,checkType:f}:{kind:"liveness",key:"biometric",context:o,section:m,mode:f==="face_match"?"selfie":"liveness",requiresMobile:d,instructions:k===null?"standard":"icao",icao:k,livePhoto:wt(e,f),...l}}case"nfc_chip":return T(o,m,f,"platform_unsupported");default:return T(o,m,f,"update_required")}}export{it as a,rt as b,st as c,at as d,ut as e,Qt as f,dt as g,De as h,lt as i,pt as j,en as k,He as l,tn as m,un as n,Fe as o,I as p,re as q,Be as r,Et as s,dn as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as x}from"./chunk-TDLIXFDT.js";import{b}from"./chunk-FPXL63KZ.js";var T=480,y=Object.freeze({MIN_AREA_FRAC:.15,EDGE_CLIP_MARGIN_PX:4,STABLE_TICKS:3,IOU_STABLE_MIN:.85,RISE_PER_S:.9,FALL_PER_S:.25,GUIDE_EXPOSURE:.6,GUIDE_SHARPNESS:.35,ID3_BAND_MIN_WIDTH_FRAC:.55,ID3_BAND_ASPECT_MIN:4,ID3_BAND_ASPECT_MAX:40}),p=e=>Math.min(1,Math.max(0,e));function E(e,o,t){let n=[e.topLeft,e.topRight,e.bottomRight,e.bottomLeft],i=0;for(let s=0;s<4;s++){let r=n[s],c=n[(s+1)%4];i+=r.x*c.y-c.x*r.y}let a=o*t;return a>0?Math.abs(i/2)/a:0}function I(e,o){let t=D(e),n=D(o),i=Math.max(t.x1,n.x1),a=Math.max(t.y1,n.y1),s=Math.min(t.x2,n.x2),r=Math.min(t.y2,n.y2),c=Math.max(0,s-i)*Math.max(0,r-a),u=(t.x2-t.x1)*(t.y2-t.y1),_=(n.x2-n.x1)*(n.y2-n.y1),m=u+_-c;return m>0?c/m:0}function R(e){let o=D(e);return{width:o.x2-o.x1,height:o.y2-o.y1}}function D(e){let o=[e.topLeft,e.topRight,e.bottomRight,e.bottomLeft];return{x1:Math.min(...o.map(t=>t.x)),y1:Math.min(...o.map(t=>t.y)),x2:Math.max(...o.map(t=>t.x)),y2:Math.max(...o.map(t=>t.y))}}function M(e){let o=Math.hypot(e.topRight.x-e.topLeft.x,e.topRight.y-e.topLeft.y),t=Math.hypot(e.bottomRight.x-e.bottomLeft.x,e.bottomRight.y-e.bottomLeft.y),n=Math.hypot(e.bottomLeft.x-e.topLeft.x,e.bottomLeft.y-e.topLeft.y),i=Math.hypot(e.bottomRight.x-e.topRight.x,e.bottomRight.y-e.topRight.y),a=(o+t)/2,s=(n+i)/2;return a<=0||s<=0?0:Math.max(a,s)/Math.min(a,s)}var d=class{constructor(o,t={}){this.p=0;this.lastTickAt=null;this.lastQuad=null;this.streak=0;this.format=o,this.t={...y,...t}}reset(){this.p=0,this.lastTickAt=null,this.lastQuad=null,this.streak=0}tick(o){let{quad:t,quality:n,timestampMs:i}=o,a=this.lastTickAt===null?0:Math.max(0,(i-this.lastTickAt)/1e3);this.lastTickAt=i;let s=null;if(t===null)s="dcv1.no_doc";else if(this.format==="ID-3"){let h=R(t),f=h.height>0?h.width/h.height:0;h.width<this.t.ID3_BAND_MIN_WIDTH_FRAC*o.frameWidth?s="dcv1.come_closer":this.edgeClipped(t,o.frameWidth,o.frameHeight)?s="dcv1.fit_document":(f<this.t.ID3_BAND_ASPECT_MIN||f>this.t.ID3_BAND_ASPECT_MAX)&&(s="dcv1.wrong_shape")}else E(t,o.frameWidth,o.frameHeight)<this.t.MIN_AREA_FRAC?s="dcv1.come_closer":this.edgeClipped(t,o.frameWidth,o.frameHeight)?s="dcv1.fit_document":x(this.format,M(t))||(s="dcv1.wrong_shape");let r=s===null,c=p(n.exposure)>=this.t.GUIDE_EXPOSURE,u=p(n.sharpness)>=this.t.GUIDE_SHARPNESS,_=c&&u;if(r&&_&&t!==null){let h=this.lastQuad===null||I(t,this.lastQuad)>=this.t.IOU_STABLE_MIN;this.streak=h?this.streak+1:1}else this.streak=0;this.lastQuad=t;let m=r&&_;this.p=p(this.p+(m?this.t.RISE_PER_S:-this.t.FALL_PER_S)*a);let A=m&&this.streak>=this.t.STABLE_TICKS,l;if(s!==null)l=s;else if(c)u?l="dcv1.hold_still":l="dcv1.steady";else{let h=(b[0]+b[1])/2;l=n.meanLuma<h?"dcv1.more_light":"dcv1.too_bright"}return{at:i,quad:t,plausible:r,p:this.p,guidanceKey:l,ready:A,stableTicks:this.streak}}edgeClipped(o,t,n){let i=this.t.EDGE_CLIP_MARGIN_PX;return[o.topLeft,o.topRight,o.bottomRight,o.bottomLeft].some(s=>s.x<=i||s.y<=i||s.x>=t-i||s.y>=n-i)}};export{T as a,y as b,E as c,I as d,R as e,d as f};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as _,c as y}from"./chunk-ZLWH4RBO.js";var S=["session_token_invalid","session_token_required","session_token_session_mismatch","session_not_found","rate_limit_exceeded","consent_required","session_not_active","check_not_found","check_already_finalized","check_out_of_order","check_type_unsupported","force_outcome_forbidden","attestation_invalid","platform_unregistered","app_attest_invalid","too_many_challenges","inference_unavailable","mobile_required","nni_locked","document_nni_mismatch","media_content_type_not_allowed","media_too_large","media_key_invalid","media_key_forbidden","media_not_found","media_unreadable","media_session_invalid","idempotency_key_collision","idempotency_in_progress","idempotency_key_required","validation_error","internal_error","unknown_error","upload_failed","network_error","timeout","nfc_outcome_not_accepted","identity_confirm_required","identity_confirm_locked","choice_not_found","choice_locked","choice_option_unavailable","step_not_on_path","check_not_active","sekyro_app_not_allowed","sekyro_app_unverified","id_number_locked","document_id_number_mismatch"];function x(s){return S.includes(s)}var c=class extends Error{constructor(e){super(e.message),this.name="HostedApiError",this.status=e.status,this.code=e.code,e.retryAfterSeconds!==void 0&&(this.retryAfterSeconds=e.retryAfterSeconds),e.details&&(this.details=e.details)}};function f(s,e,n=Math.random){let t=(s??e)*1e3,o=Math.min(Math.max(t,500),2e4),i=Math.round(o*(1+(n()*2-1)*.25));return Math.min(Math.max(i,500),2e4)}var w=6e4,h=4,k=3e4,I=9e5,R=200,P=5,M=400,E=new Set(["server_busy","request_timeout"]),C=2;function l(s){return(s.split(";")[0]??"").trim()}var A={liveness:"clipKey",face_match:"imageKey",doc_ocr:"imageKey"},v=`@sekyro/web/${_}`,O=v,b=class{constructor(e){this.sessionId=null;this.bootstrap=null;this.captureNonces=[];this.captureFetch=null;this.reportedIssues=new Map;this.apiOrigin=e.apiOrigin.replace(/\/+$/,""),this.sessionToken=e.sessionToken;let n=e.fetch;this.fetchImpl=(t,o)=>(n??globalThis.fetch).call(globalThis,t,o),this.requestTimeoutMs=e.requestTimeoutMs??k,this.retryAttempts=e.inProgressRetry?.attempts??P,this.retryDelayMs=e.inProgressRetry?.delayMs??M,this.random=e.random??Math.random}async getSession(){let e=await this.api("GET","/hosted/session");return this.sessionId=e.sessionId,e}async recordConsent(e){return this.api("POST","/hosted/consent",{body:{locale:e},busyRetry:!0})}async reportCameraUnavailable(e){return this.api("POST","/hosted/camera-unavailable",{body:{cause:e}})}async reportCaptureIssue(e){let n=typeof e.name=="string"?e.name.replace(/[^A-Za-z]/g,"").slice(0,40):"",t=typeof e.engineKind=="string"&&/^[a-z_]{1,32}$/.test(e.engineKind)?e.engineKind:void 0,o=typeof e.attempt=="number"&&Number.isInteger(e.attempt)&&e.attempt>=0&&e.attempt<=1e3?e.attempt:void 0,i=[e.check,o??"",e.kind,n,e.phase??""].join("|"),a=this.reportedIssues.get(i);if(a!==void 0)return a;let d={check:e.check,kind:e.kind,...n!==""?{name:n}:{},...e.phase!==void 0?{phase:e.phase}:{},...t!==void 0?{engineKind:t}:{},...o!==void 0?{attempt:o}:{},...e.formFactor!==void 0?{formFactor:e.formFactor}:{}},r=this.api("POST","/hosted/capture-issue",{body:d,empty:!0}).catch(()=>{this.reportedIssues.delete(i)});return this.reportedIssues.set(i,r),r}async choose(e,n){let t=await this.api("POST","/hosted/choice",{body:{nodeId:e,option:n},busyRetry:!0});return this.sessionId=t.sessionId,t}async confirmIdentity(e){return this.api("POST","/hosted/identity/confirm",{body:{decision:e}})}async identityPortrait(){return this.api("GET","/hosted/identity/portrait",{blob:!0})}async presign(e,n,t,o={}){let i=await this.ensureSessionId(),a={kind:e,contentType:l(n),contentLength:t,...o.source==="upload"?{source:"upload"}:{}};return this.api("POST",`/sessions/${i}/media`,{body:a})}armCapture(e=2){this.fillCaptureNonces(e)}async presignCapture(e,n,t,o={}){let i=await this.ensureSessionId(),a=await this.takeCaptureNonce(),d=a===void 0?void 0:{nonce:a,...o.engine!==void 0?{engine:o.engine.slice(0,32)}:{},...o.durationMs!==void 0&&Number.isFinite(o.durationMs)?{captureMs:Math.min(36e5,Math.max(0,Math.round(o.durationMs)))}:{}},r={kind:e,contentType:l(n),contentLength:t,capture:d};return this.api("POST",`/sessions/${i}/media`,{body:r})}async takeCaptureNonce(){let e=()=>{let n=Date.now();return this.captureNonces=this.captureNonces.filter(t=>t.expiresAt-w>n),this.captureNonces.shift()?.nonce};for(let n=0;n<2;n++){let t=e();if(t!==void 0)return t;await this.fillCaptureNonces(1)}return e()}fillCaptureNonces(e){return this.captureFetch??(this.captureFetch=(async()=>{try{let n=await this.ensureSessionId(),t=await this.api("POST",`/sessions/${n}/media/capture-nonces`,{body:{count:Math.min(h,Math.max(1,e))}}),o=Date.now()+Math.max(0,t.expiresIn)*1e3;for(let i of Array.isArray(t.nonces)?t.nonces:[])typeof i=="string"&&i.length>0&&this.captureNonces.push({nonce:i,expiresAt:o});this.captureNonces=this.captureNonces.slice(-h)}catch{}})().finally(()=>{this.captureFetch=null})),this.captureFetch}async uploadToSpaces(e,n,t){let o;try{o=await this.fetchImpl(e,{method:"PUT",headers:{"content-type":l(t)},body:n,signal:AbortSignal.timeout(I)})}catch(i){throw m(i)}if(!o.ok){let i=(await o.text().catch(()=>"")).slice(0,R);throw new c({status:o.status,code:"upload_failed",message:`media upload failed (HTTP ${o.status})${i?`: ${i}`:""}`})}}async completeMedia(e){let n=await this.ensureSessionId();return this.api("POST",`/sessions/${n}/media/complete`,{body:{key:e}})}async submitCheck(e,n,t={}){let o=await this.ensureSessionId(),i={input:n,forceOutcome:t.forceOutcome};return this.api("POST",`/sessions/${o}/checks/${e}`,{body:i,idempotencyKey:t.idempotencyKey,busyRetry:t.idempotencyKey!==void 0})}async uploadAndSubmit(e,n,t,o={}){let i=l(n.contentType),a=await this.presign(n.kind,i,n.blob.size);await this.uploadToSpaces(a.uploadUrl,n.blob,i);let d=await this.completeMedia(a.key),r={...t,[A[e]]:d.key};return this.submitCheck(e,r,o)}async ensureSessionId(){return this.sessionId!==null?this.sessionId:(this.bootstrap??(this.bootstrap=this.getSession().finally(()=>{this.bootstrap=null})),(await this.bootstrap).sessionId)}async api(e,n,t={}){let o=e==="GET"||t.busyRetry===!0,i=`${this.apiOrigin}/api/v2${n}`,a={"x-session-token":this.sessionToken,"x-sekyro-sdk":O};t.body!==void 0&&(a["content-type"]="application/json"),t.idempotencyKey!==void 0&&(a["x-idempotency-key"]=t.idempotencyKey);try{let d=y.timezone();d!==void 0&&(a["sekyro-client-timezone"]=d)}catch{}try{let d=await y.deviceHeader();d!==void 0&&(a["sekyro-client-device"]=d)}catch{}for(let d=0;;d++){let r;try{r=await this.fetchImpl(i,{method:e,headers:a,...t.body!==void 0?{body:JSON.stringify(t.body)}:{},cache:"no-store",signal:AbortSignal.timeout(this.requestTimeoutMs)})}catch(p){throw m(p)}if(r.ok){if(t.empty===!0)return;if(t.blob===!0)try{return await r.blob()}catch(T){throw m(T)}let p;try{p=await r.json()}catch{throw new c({status:r.status,code:"unknown_error",message:`response body was not valid JSON (HTTP ${r.status})`})}return N(p)}let u=await H(r);if(u.code==="idempotency_in_progress"&&d<this.retryAttempts){this.retryDelayMs>0&&await g(this.retryDelayMs);continue}if(o&&u.status===503&&E.has(u.code)){o=!1,await g(f(u.retryAfterSeconds,C,this.random));continue}throw u}}};function m(s){if((typeof s=="object"&&s!==null?s.name:void 0)==="TimeoutError")return new c({status:0,code:"timeout",message:"request timed out"});let n=s instanceof Error?s.message:String(s);return new c({status:0,code:"network_error",message:`network request failed: ${n}`})}function N(s){return s!==null&&typeof s=="object"&&"success"in s&&"data"in s?s.data:s}async function H(s){let e="unknown_error",n=`request failed (HTTP ${s.status})`,t=Number.NaN,o;try{let d=await s.json();if(d!==null&&typeof d=="object"){let r=d;typeof r.code=="string"&&r.code.length>0&&(e=r.code),typeof r.message=="string"&&r.message.length>0&&(n=r.message),typeof r.retryAfterSeconds=="number"&&(t=r.retryAfterSeconds),Array.isArray(r.details?.issues)&&(o=r.details)}}catch{}let i=s.headers.get("retry-after"),a=i===null?Math.floor(t):Number.parseInt(i,10);return new c({status:s.status,code:e,message:n,...Number.isFinite(a)&&a>=0?{retryAfterSeconds:a}:{},details:o})}function g(s){return new Promise(e=>setTimeout(e,s))}function F(s){let e=s?.portrait,n=e?.icao,t=e?.purpose==="id_document";return n==null?t?{policy:"reject",profile:"id_document"}:null:{policy:n.policy==="alert"?"alert":"reject",profile:t||n.profile==="id_document"?"id_document":"selfie"}}function j(s){return{...s.baselineEyeOpenness!==void 0?{baselineEyeOpenness:s.baselineEyeOpenness}:{},criteria:s.verdict??{},...s.backgroundCheck!==void 0?{backgroundCheck:s.backgroundCheck}:{}}}export{S as a,x as b,c,f as d,l as e,v as f,b as g,F as h,j as i};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var f="https://challenges.cloudflare.com/turnstile/v0/api.js",g=3e4;function p(){return window.turnstile}var o=null;function w(){o=null}function E(){return o??(o=new Promise((s,t)=>{let r=p();if(r){s(r);return}let e=document.createElement("script");e.src=f,e.async=!0,e.onload=()=>{let n=p();n?s(n):(o=null,t(new Error("Turnstile script loaded but exposed no API")))},e.onerror=()=>{o=null,e.remove(),t(new Error("Turnstile script failed to load"))},document.head.appendChild(e)})),o}function d(){return new Error("Turnstile challenge aborted")}async function x(s,t={}){let r=t.timeoutMs??3e4,e=t.signal;if(e?.aborted)throw d();let n=await E();if(e?.aborted)throw d();let a=document.createElement("div");document.body.appendChild(a);let i,c,u;try{return await new Promise((m,l)=>{if(c=setTimeout(()=>l(new Error(`Turnstile challenge timed out (${r} ms)`)),r),e!==void 0&&(u=()=>l(d()),e.addEventListener("abort",u,{once:!0})),i=n.render(a,{sitekey:s,execution:"execute",appearance:"execute",callback:m,"error-callback":T=>{l(new Error(`Turnstile challenge failed${T?` (${T})`:""}`))}}),i===void 0){l(new Error("Turnstile render returned no widget id"));return}n.execute(i)})}finally{if(clearTimeout(c),e!==void 0&&u!==void 0&&e.removeEventListener("abort",u),i!==void 0)try{n.remove(i)}catch{}a.remove()}}export{f as a,g as b,w as c,E as d,x as e};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var v=1e4,u=class t{constructor(e,i){this.tier="blaze";this.inner=e,i!==void 0&&(this.fallbackReason=i)}static async create(e,i){let o=await import("@mediapipe/tasks-vision"),n=await o.FilesetResolver.forVisionTasks(e),r=await o.FaceDetector.createFromOptions(n,{baseOptions:{modelAssetPath:`${e}/blaze_face_short_range.tflite`,delegate:"CPU"},runningMode:"IMAGE"});return new t(r,i)}async detect(e,i,o){let n;try{n=this.inner.detect(e).detections}catch{return null}let r=O(n);if(r?.boundingBox===void 0)return null;let a=g(e),s=w(r.keypoints,a),c=r.keypoints?.[2],b={box:{x:r.boundingBox.originX,y:r.boundingBox.originY,width:r.boundingBox.width,height:r.boundingBox.height},...s!==void 0?{eyes:s}:{},...c!==void 0?{nose:{x:c.x*a.width,y:c.y*a.height}}:{},score:r.categories[0]?.score??0};return l(b,e,i,o)}destroy(){try{this.inner.close()}catch{}}};function O(t){let e,i=-1;for(let o of t){let n=o.categories[0]?.score??0;n>i&&(e=o,i=n)}return e}function w(t,e){let i=t?.[0],o=t?.[1];if(i===void 0||o===void 0)return;let n=s=>({x:s.x*e.width,y:s.y*e.height}),[r,a]=[n(i),n(o)];return r.x<=a.x?{left:r,right:a}:{left:a,right:r}}function R(){if(typeof OffscreenCanvas=="function")return new OffscreenCanvas(2,2);let t=document.createElement("canvas");return t.width=2,t.height=2,t}async function x(){let t=globalThis.FaceDetector;if(typeof t!="function")return{ok:!1,reason:"unsupported"};try{let e=new t({fastMode:!0,maxDetectedFaces:1});return await e.detect(R()),{ok:!0,instance:e}}catch(e){return{ok:!1,reason:`smoke_failed:${e instanceof Error?e.message:String(e)}`}}}var m=class{constructor(e,i){this.tier="native";this.inner=e,i!==void 0&&(this.fallbackReason=i)}async detect(e,i,o){let n;try{n=await this.inner.detect(e)}catch{return null}let r=n[0];if(r===void 0)return null;let a=T(r.landmarks),s={box:{x:r.boundingBox.x,y:r.boundingBox.y,width:r.boundingBox.width,height:r.boundingBox.height},...a!==void 0?{eyes:a}:{},score:1};return l(s,e,i,o)}destroy(){}};function T(t){if(t===void 0)return;let e=t.filter(n=>n.type==="eye").map(n=>n.locations[0]).filter(n=>n!==void 0),[i,o]=e;if(!(i===void 0||o===void 0))return i.x<=o.x?{left:i,right:o}:{left:o,right:i}}var F="/models-v3",I=["native","blaze"],y=class extends Error{constructor(e){super(`no detector tier available (${e})`),this.name="DetectorLadderError",this.fallbackReason=e}};function g(t){let e=t;if(typeof e.videoWidth=="number"&&e.videoWidth>0)return{width:e.videoWidth,height:e.videoHeight??0};if(typeof e.naturalWidth=="number"&&e.naturalWidth>0)return{width:e.naturalWidth,height:e.naturalHeight??0};let i=typeof e.width=="number"?e.width:0,o=typeof e.height=="number"?e.height:0;return{width:i,height:o}}function l(t,e,i,o){let n=g(e),r=n.width>0?i/n.width:1,a=n.height>0?o/n.height:1,s=c=>({x:c.x*r,y:c.y*a});return{box:{x:t.box.x*r,y:t.box.y*a,width:t.box.width*r,height:t.box.height*a},...t.eyes!==void 0?{eyes:{left:s(t.eyes.left),right:s(t.eyes.right)}}:{},...t.nose!==void 0?{nose:s(t.nose)}:{},score:t.score}}function E(t){return t instanceof Error?t.message:String(t)}async function k(t){let e=t.preferred??I,i=[];for(let o of e){if(o==="native"){let n=await x();if(n.ok)return new m(n.instance,h(i));i.push(`native:${n.reason}`);continue}try{return await S(u.create(t.v3AssetBaseUrl??F,h(i)),t.blazeInitTimeoutMs??v)}catch(n){i.push(n instanceof f?"blaze:blaze_init_timeout":`blaze:${E(n)}`)}}throw new y(h(i)??"no_tier_available")}function h(t){return t.length>0?t.join("; "):void 0}var f=class extends Error{};function S(t,e){return new Promise((i,o)=>{let n=setTimeout(()=>{o(new f(`init exceeded ${e}ms`)),t.then(r=>r.destroy(),()=>{})},e);t.then(r=>{clearTimeout(n),i(r)},r=>{clearTimeout(n),o(r)})})}var d=1;function A(){return typeof OffscreenCanvas=="function"&&typeof createImageBitmap=="function"&&typeof Worker=="function"}function M(t,e={}){let i=e.createDetector??k,o=null;t.onmessage=n=>{let r=n.data;if(r.v!==d){r.bitmap?.close?.();return}if(r.type==="init"){i(r.options).then(a=>{o=a;let s={v:d,type:"ready",tier:a.tier,...a.fallbackReason!==void 0?{fallbackReason:a.fallbackReason}:{}};t.postMessage(s)});return}if(r.type==="detect"){let a=s=>{let c={v:d,type:"result",id:r.id,observation:s};t.postMessage(c),r.bitmap.close?.()};if(o===null){a(null);return}o.detect(r.bitmap,r.streamWidth,r.streamHeight).then(a,()=>a(null))}}}typeof self<"u"&&typeof self.importScripts=="function"&&M(self);var D=class t{constructor(e,i){this.pending=new Map;this.nextId=1;this.worker=e,this.tier=i.tier,i.fallbackReason!==void 0&&(this.fallbackReason=i.fallbackReason),e.addEventListener("message",o=>{let n=o.data;if(n.v!==d||n.type!=="result")return;let r=this.pending.get(n.id);this.pending.delete(n.id),r?.(n.observation)})}static create(e,i,o=1e4){return new Promise((n,r)=>{let a=setTimeout(()=>{e.removeEventListener("message",s),e.terminate(),r(new Error(`worker detector not ready within ${o}ms`))},o),s=b=>{let p=b.data;p.v!==d||p.type!=="ready"||(clearTimeout(a),e.removeEventListener("message",s),n(new t(e,p)))};e.addEventListener("message",s);let c={v:d,type:"init",options:i};e.postMessage(c)})}async detect(e,i,o){let n;try{typeof ImageBitmap<"u"&&e instanceof ImageBitmap?n=e:typeof createImageBitmap=="function"?n=await createImageBitmap(e):n=e}catch{return null}let r=this.nextId;return this.nextId+=1,new Promise(a=>{this.pending.set(r,a);let s={v:d,type:"detect",id:r,bitmap:n,streamWidth:i,streamHeight:o};this.worker.postMessage(s,[n])})}destroy(){for(let e of this.pending.values())e(null);this.pending.clear(),this.worker.terminate()}};export{F as a,I as b,y as c,g as d,l as e,k as f,d as g,A as h,M as i,D as j};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var a=Object.freeze({LOW:Object.freeze({cadenceHz:5,inputWidth:128,animations:"reduced"}),MID:Object.freeze({cadenceHz:8,inputWidth:160,animations:"full"}),HIGH:Object.freeze({cadenceHz:10,inputWidth:192,animations:"full"})}),u=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]);function o(){let t=typeof navigator>"u"?void 0:navigator,e=!1;try{e=typeof WebAssembly<"u"&&WebAssembly.validate(u)}catch{e=!1}return{cores:t?.hardwareConcurrency??2,memGB:t?.deviceMemory??null,simd:e}}function l(t){let e=t.memGB??4;return t.cores<4||e<3?"LOW":t.cores>=8&&e>=6?"HIGH":"MID"}var n=["LOW","MID","HIGH"],i=class{constructor(e){this.samples=[];this.adjusted=!1;this.current=e}get deviceClass(){return this.current}get profile(){return a[this.current]}record(e){if(this.adjusted||this.samples.length>=10)return this.current;if(this.samples.push(e),this.samples.length<10)return this.current;this.adjusted=!0;let s=this.samples.reduce((r,c)=>r+c,0)/this.samples.length;if(s>70)this.current="LOW";else if(s<25){let r=n.indexOf(this.current);this.current=n[Math.min(n.length-1,r+1)]??this.current}return this.current}};export{a,o as b,l as c,i as d};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as M}from"./chunk-GI3UFGRQ.js";var A=2;function L(u){let l=u.tuning,s=u.now??(()=>performance.now()),t=null,o=!1,g=!1,d=Number.NEGATIVE_INFINITY,a=null,h=0,i=null,n=null,f=0,p=!1,T=()=>{if(p||!l.enabled)return;p=!0;let r=(u.createSegmenter??(e=>import("./segmenter-USLNBX65.js").then(m=>m.createSelfieSegmenter(e))))(u.assetBaseUrl);n=setTimeout(()=>{t===null&&(o=!0)},l.segmenterTimeoutMs),r.then(e=>{n!==null&&clearTimeout(n),g||o?e.close():t=e},()=>{n!==null&&clearTimeout(n),o=!0})};return{measure(r,e,m,S){if(!l.enabled||r.pixels===null)return null;T();let c=s();if(c-d<1e3/l.hz)return a;d=c;let k=r.width/Math.max(1,m),y=r.height/Math.max(1,S),w={x:e.x*k,y:e.y*y,width:e.width*k,height:e.height*y},B=null;if(t!==null&&!o){let x=Math.max(c,h+1);h=x;let U=s();B=t.segment(r.source,x);let b=s()-U;f+=1,f>A&&(i=i===null?b:i*.7+b*.3),i!==null&&i>l.segmenterBudgetMs&&(o=!0,t.close(),t=null)}return a=M(r.pixels,w,B,l),a},close(){g=!0,n!==null&&clearTimeout(n),t?.close(),t=null}}}export{L as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var p=Object.freeze({EDGE_LUMA_DELTA:40,MIN_ROW_DENSITY:.08,MIN_COLUMN_COVERAGE:.6,MIN_WIDTH_FRAC:.55,MIN_HEIGHT_FRAC:.02,MAX_HEIGHT_FRAC:.16,ROW_MERGE_GAP:18}),I=12;function F(H,D={}){let r={...p,...D},{data:s,width:n,height:t}=H;if(n<32||t<32)return null;let c=new Array(t).fill(!1),R=new Float32Array(t),u=new Int32Array(t).fill(n),a=new Int32Array(t).fill(-1),w=n/I,d=new Array(I);for(let e=0;e<t;e++){let M=0;d.fill(!1);let E=e*n*4,G=.299*(s[E]??0)+.587*(s[E+1]??0)+.114*(s[E+2]??0);for(let o=1;o<n;o++){let T=E+o*4,y=.299*(s[T]??0)+.587*(s[T+1]??0)+.114*(s[T+2]??0);Math.abs(y-G)>=r.EDGE_LUMA_DELTA&&(M+=1,d[Math.min(I-1,Math.floor(o/w))]=!0,o<u[e]&&(u[e]=o),o>a[e]&&(a[e]=o)),G=y}R[e]=M/n;let O=d.filter(Boolean).length/I;c[e]=R[e]>=r.MIN_ROW_DENSITY&&O>=r.MIN_COLUMN_COVERAGE&&a[e]-u[e]>=r.MIN_WIDTH_FRAC*n}let _=null,l=-1,f=-1,i=0,N=e=>{if(l<0)return;let M=e-l+1;M>=r.MIN_HEIGHT_FRAC*t&&M<=r.MAX_HEIGHT_FRAC*t&&i>=4&&(_===null||i>_.rows)&&(_={top:l,bottom:e,rows:i}),l=-1,i=0};for(let e=0;e<t;e++)c[e]&&(l<0?l=e:e-f>r.ROW_MERGE_GAP&&(N(f),l=e),f=e,i+=1);if(N(f),_===null)return null;let b=_,m=n,A=-1,C=0,h=0;for(let e=b.top;e<=b.bottom;e++)c[e]&&(u[e]<m&&(m=u[e]),a[e]>A&&(A=a[e]),C+=R[e],h+=1);return A-m<r.MIN_WIDTH_FRAC*n?null:{x:m,y:b.top,width:A-m,height:b.bottom-b.top+1,density:h>0?C/h:0}}export{p as a,F as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var o={"ID-1":{center:1.586,tolerance:.15},"ID-2":{center:1.419,tolerance:.12},"ID-3":{center:1.42,tolerance:.2}},c={"ID-1":["ID-1"],"ID-2":["ID-2"],"ID-3":["ID-3"],card:["ID-1","ID-2"]};function i(e){return o[e==="card"?"ID-1":e]}function d(e,r){return c[e].some(t=>Math.abs(r-o[t].center)<=o[t].tolerance)}var a=[{docType:"carte_identite",format:"ID-1",sides:["recto","verso"],mrz:"td1",portraitSide:"recto",aspectRatio:1.586,identifierSource:"mrz"},{docType:"passport",format:"ID-3",sides:["single"],mrz:"td3",portraitSide:"single",aspectRatio:1.42,identifierSource:"mrz"}],n=[...a,{docType:"residence_permit",format:"ID-1",sides:["recto","verso"],mrz:"td1",portraitSide:"recto",aspectRatio:1.586,identifierSource:"mrz"}];function s(e){let r=n.find(t=>t.docType===e);return r===void 0||r.format==="ID-1"?"card":r.format}export{o as a,i as b,d as c,a as d,n as e,s as f};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var u=["obs","manycam","virtual","snap camera","xsplit","droidcam","iriun","camo"],l=[/^(front|back|rear)( [a-z ]+)? camera$/i,/^camera2? ?\d+, facing (front|back|external)/i,/facetime/i,/\b(integrated|built-in|builtin) (web)?cam(era)?\b/i,/\b(hd )?web ?cam\b/i,/\([0-9a-f]{4}:[0-9a-f]{4}\)\s*$/i];function c(n){let e=(n??"").trim().toLowerCase();return e.length===0?"unknown":u.some(t=>e.includes(t))?"known_virtual":l.some(t=>t.test(e))?"platform":"unknown"}var d=1e3;function m(n,e){return new Promise(t=>{let a=setTimeout(()=>t(void 0),e),r=s=>{clearTimeout(a),t(s)};try{n().then(r,()=>r(void 0))}catch{r(void 0)}})}async function f(n){let e=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(JSON.stringify(n)));return Array.from(new Uint8Array(e).subarray(0,8),t=>t.toString(16).padStart(2,"0")).join("")}var i=n=>Array.isArray(n)?[...n].sort():null,o=n=>{let e=n;return e==null?null:[e.min??null,e.max??null]};function p(n){try{return n.getSettings?.().facingMode==="environment"}catch{return!1}}async function g(n){try{if(n.readyState==="ended"||p(n))return;let e={};try{e=n.getCapabilities?.()??{}}catch{}let t=await m(()=>navigator.mediaDevices.enumerateDevices(),d);return await f([o(e.width),o(e.height),o(e.frameRate),i(e.facingMode),i(e.focusMode),i(e.exposureMode),c(n.label),t?.filter(a=>a.kind==="videoinput").length??null])}catch{return}}async function v(n,e){let t=await g(n);t&&e.noteCamera(t)}export{m as a,f as b,g as c,v as d};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as Jt}from"./chunk-SMKCBUJL.js";import{a as et,b as $t,c as te,e as dt,f as ee}from"./chunk-MXWLCDFX.js";import{d as Yt,h as Zt,k as qt}from"./chunk-G6LKLN4U.js";import{b as Xt,c as jt}from"./chunk-TDLIXFDT.js";import{b as Ht,c as Kt}from"./chunk-POIQGEZM.js";import{k as Nt,m as Qt,n as Ut,o as Wt}from"./chunk-CQ7SKLMC.js";import{b as ut,c as ht,d as j,e as Vt}from"./chunk-FPXL63KZ.js";import{d as Bt}from"./chunk-ZLWH4RBO.js";var it=Object.freeze({sensing:{key:"sensing",reticle:"searching",minDurationMs:900},too_far:{key:"too_far",reticle:"coaching",minDurationMs:1400},too_close:{key:"too_close",reticle:"coaching",minDurationMs:1400},edge_clipped:{key:"edge_clipped",reticle:"coaching",minDurationMs:1400},wrong_shape:{key:"wrong_shape",reticle:"coaching",minDurationMs:1400},tilted:{key:"tilted",reticle:"coaching",minDurationMs:1400},too_dark:{key:"too_dark",reticle:"coaching",minDurationMs:1400},too_bright:{key:"too_bright",reticle:"coaching",minDurationMs:1400},blurry:{key:"blurry",reticle:"coaching",minDurationMs:1400},focus_far:{key:"focus_far",reticle:"coaching",minDurationMs:1600},glare:{key:"glare",reticle:"coaching",minDurationMs:1400},hold_still:{key:"hold_still",reticle:"locking",minDurationMs:900},processing:{key:"processing",reticle:"processing",minDurationMs:800},side_captured:{key:"side_captured",reticle:"flip",minDurationMs:2600},captured:{key:"captured",reticle:"done",minDurationMs:800}});function ie(i){return i.framing==="no_document"?"sensing":i.framing==="too_far"?"too_far":i.framing==="too_close"?"too_close":i.framing==="edge_clipped"?"edge_clipped":i.framing==="wrong_shape"?"wrong_shape":i.framing==="tilted"?"tilted":i.lighting==="too_dark"?"too_dark":i.lighting==="too_bright"?"too_bright":i.glare==="glare"?"glare":i.blur==="blurry"?"blurry":"hold_still"}var nt=class{constructor(t=2600,e=.35){this.windowMs=t;this.decayPerSecond=e;this.votes=[];this.current=it.sensing;this.currentSinceMs=null}reset(){this.votes=[],this.current=it.sensing,this.currentSinceMs=null}force(t,e){return this.votes=[],this.current=it[t],this.currentSinceMs=e,this.current}tick(t,e){if(this.currentSinceMs===null&&(this.currentSinceMs=e),this.votes.push({key:t,atMs:e}),this.votes=this.votes.filter(r=>e-r.atMs<=this.windowMs),e-this.currentSinceMs<this.current.minDurationMs)return this.current;let n=new Map;for(let r of this.votes){let c=(e-r.atMs)/1e3,a=this.decayPerSecond**c;n.set(r.key,(n.get(r.key)??0)+a)}let o=this.current.key,s=-1;for(let[r,c]of n)c>s&&(s=c,o=r);return o!==this.current.key&&(this.current=it[o],this.currentSinceMs=e),this.current}};var Ke=Object.freeze({MAX_AREA_FRAC:.92,TILT_MAX_SIDE_RATIO:1.3,GLARE_MAX_SPECULAR_FRAC:.025});function oe(i){let{data:t,width:e,height:n}=i,o=e*n;if(o===0)return 0;let s=0;for(let r=0;r<o;r++){let c=r*4;.299*(t[c]??0)+.587*(t[c+1]??0)+.114*(t[c+2]??0)>=252&&s++}return s/o}function Ve(i){let t=(a,l)=>Math.hypot(l.x-a.x,l.y-a.y),e=t(i.topLeft,i.topRight),n=t(i.bottomLeft,i.bottomRight),o=t(i.topLeft,i.bottomLeft),s=t(i.topRight,i.bottomRight),r=Math.max(e,n)/Math.max(1e-6,Math.min(e,n)),c=Math.max(o,s)/Math.max(1e-6,Math.min(o,s));return Math.max(r,c)}function se(i){let t={...$t,...i.thresholds},e=Ke,{quad:n,frameWidth:o,frameHeight:s,measures:r}=i,c=i.format==="ID-3",a="ok";if(n===null)a="no_document";else if(c){let m=dt(n),h=o>0?m.width/o:0,f=m.height>0?m.width/m.height:0;h<t.ID3_BAND_MIN_WIDTH_FRAC?a="too_far":ne(n,o,s,t.EDGE_CLIP_MARGIN_PX)?a="edge_clipped":(f<t.ID3_BAND_ASPECT_MIN||f>t.ID3_BAND_ASPECT_MAX)&&(a="wrong_shape")}else{let m=te(n,o,s),h=dt(n),f=Math.max(h.width,h.height)/Math.max(1e-6,Math.min(h.width,h.height));m<t.MIN_AREA_FRAC?a="too_far":m>e.MAX_AREA_FRAC?a="too_close":ne(n,o,s,t.EDGE_CLIP_MARGIN_PX)?a="edge_clipped":jt(i.format,f)?Ve(n)>e.TILT_MAX_SIDE_RATIO&&(a="tilted"):a="wrong_shape"}let l=r.exposure>=t.GUIDE_EXPOSURE?"ok":r.meanLuma<(ut[0]+ut[1])/2?"too_dark":"too_bright",u=r.sharpness>=t.GUIDE_SHARPNESS?"ok":"blurry",d=r.specularFraction>=e.GLARE_MAX_SPECULAR_FRAC?"glare":"ok";return{framing:a,lighting:l,blur:u,glare:d,acceptable:a==="ok"&&l==="ok"&&u==="ok"&&d==="ok"}}function ne(i,t,e,n){return[i.topLeft,i.topRight,i.bottomRight,i.bottomLeft].some(s=>s.x<=n||s.y<=n||s.x>=t-n||s.y>=e-n)}var ae=Object.freeze({width:1920,height:1080}),Xe=Object.freeze({width:3840,height:2160}),re=4096,je=2560,ce=640,ot=.15,Y=Object.freeze({side:.2,above:.9,below:.3});function E(i){let t=[i.topLeft.x,i.topRight.x,i.bottomRight.x,i.bottomLeft.x],e=[i.topLeft.y,i.topRight.y,i.bottomRight.y,i.bottomLeft.y],n=Math.min(...t),o=Math.min(...e);return{x:n,y:o,width:Math.max(...t)-n,height:Math.max(...e)-o}}function le(i,t){let e=Math.max(0,Math.floor(i.x)),n=Math.max(0,Math.floor(i.y)),o=Math.min(t.width,Math.ceil(i.x+i.width)),s=Math.min(t.height,Math.ceil(i.y+i.height));return o-e<16||s-n<16?null:{x:e,y:n,width:o-e,height:s-n}}function Ye(i,t,e){if(i===null||t.width<=0||t.height<=0)return null;let n=E(i);if(n.width<=0||n.height<=0)return null;let o=e==="ID-3"?{x:n.x-n.width*Y.side,y:n.y-n.width*Y.above,width:n.width*(1+2*Y.side),height:n.height+n.width*(Y.above+Y.below)}:{x:n.x-n.width*ot,y:n.y-n.height*ot,width:n.width*(1+2*ot),height:n.height*(1+2*ot)};return le(o,t)}function mt(i,t,e){let n=Math.max(i,t);return n>0?Math.min(1,e/n):1}function ft(i,t,e,n,o=je){let s=t.width>0?e.width/t.width:1,r=t.height>0?e.height/t.height:1,c=i===null?null:{topLeft:{x:i.topLeft.x*s,y:i.topLeft.y*r},topRight:{x:i.topRight.x*s,y:i.topRight.y*r},bottomRight:{x:i.bottomRight.x*s,y:i.bottomRight.y*r},bottomLeft:{x:i.bottomLeft.x*s,y:i.bottomLeft.y*r}},a=Ye(c,e,n)??{x:0,y:0,width:e.width,height:e.height},l=mt(a.width,a.height,o),u=Math.max(1,Math.round(a.width*l)),d=Math.max(1,Math.round(a.height*l)),m=null;if(c!==null){let h=E(c);m=le({x:(h.x-a.x)*l,y:(h.y-a.y)*l,width:h.width*l,height:h.height*l},{width:u,height:d})}return{crop:a,width:u,height:d,docRegion:m}}function ue(i,t,e,n=Xe){if(e==="LOW")return null;let o=i?.width?.max,s=i?.height?.max;if(typeof o!="number"||typeof s!="number"||o<=0||s<=0)return null;let r=Math.max(o,s),c=Math.min(o,s),a=Math.min(r,Math.max(n.width,n.height)),l=Math.min(c,Math.min(n.width,n.height));return a<=Math.max(t.width,t.height)?null:{width:{ideal:a},height:{ideal:l}}}function he(i){let t={},e=i?.imageWidth,n=i?.imageHeight;if(typeof e?.max=="number"&&e.max>0){let o=typeof n?.max=="number"&&n.max>0?e.max/n.max:1.3333333333333333,s=o>=1?re:re*o,r=Math.min(e.max,Math.floor(s)),c=typeof e.step=="number"&&e.step>0?e.step:1,a=typeof e.min=="number"?e.min:0;r=Math.max(a,a+Math.floor((r-a)/c)*c),t.imageWidth=r}return i?.fillLightMode?.includes("off")===!0&&(t.fillLightMode="off"),t}function de(i,t){if(i.width<=0||i.height<=0||t.width<=0||t.height<=0)return!1;let e=i.width>i.height,n=t.width>t.height;return e!==n&&i.width!==i.height&&t.width!==t.height?!1:Math.max(i.width,i.height)>=1.2*Math.max(t.width,t.height)}function me(i,t,e,n){if(e===null)return!1;let o=E(i),s=E(e);if(t.width<=0||n.width<=0)return!1;let r=o.width/t.width,c=s.width/n.width;return c>0&&r>=.6*c&&r<=1.25*c}var fe=3500,Ze=.92;function ge(){let i=globalThis.ImageCapture;return typeof i=="function"?i:null}function Je(i){return/AppleWebKit\//.test(i)&&!/(Chrome|Chromium|Edg|OPR)\//.test(i)}function be(i,t=typeof navigator>"u"?"":navigator.userAgent){return ge()!==null&&!Je(t)&&i!=null&&i.kind==="video"&&i.readyState==="live"}function pe(i,t){return new Promise((e,n)=>{let o=setTimeout(()=>n(new Error("takePhoto timed out")),t);i.then(s=>{clearTimeout(o),e(s)},s=>{clearTimeout(o),n(s)})})}function pt(i,t){let e=document.createElement("canvas");return e.width=i,e.height=t,e}function qe(i,t){return new Promise((e,n)=>{i.toBlob(o=>o?e(o):n(new Error("toBlob failed")),"image/jpeg",t)})}async function ye(i,t,e,n,o){let s=pt(e,n),r=pt(1,1);try{let c=s.getContext("2d");if(c===null)throw new Error("2d context unavailable");c.imageSmoothingQuality="high",c.drawImage(i,t.x,t.y,t.width,t.height,0,0,e,n);let a=await qe(s,Ze),l=o===null?null:Yt({topLeft:{x:o.x,y:o.y},topRight:{x:o.x+o.width,y:o.y},bottomRight:{x:o.x+o.width,y:o.y+o.height},bottomLeft:{x:o.x,y:o.y+o.height}},{width:e,height:n},{width:e,height:n}),u=Zt(s,l),d=mt(e,n,ce);return r.width=Math.max(1,Math.round(e*d)),r.height=Math.max(1,Math.round(n*d)),r.getContext("2d")?.drawImage(s,0,0,r.width,r.height),{blob:a,previewDataUrl:r.toDataURL("image/jpeg",.85),sharpness:u}}finally{s.width=0,s.height=0,r.width=0,r.height=0}}function $e(i,t){let e=Math.min(1,t/i.width),n=pt(Math.max(1,Math.round(i.width*e)),Math.max(1,Math.round(i.height*e)));try{let o=n.getContext("2d",{willReadFrequently:!0});return o===null?null:(o.imageSmoothingQuality="high",o.drawImage(i,0,0,n.width,n.height),o.getImageData(0,0,n.width,n.height))}finally{n.width=0,n.height=0}}async function Me(i,t,e,n){let o={width:Math.max(1,i.videoWidth),height:Math.max(1,i.videoHeight)},s=ft(t,e,o,n);return{...await ye(i,s.crop,s.width,s.height,s.docRegion),docRegion:s.docRegion,source:"video",width:s.width,height:s.height}}async function ke(i,t,e,n,o){let s=ge();if(s===null)return null;let r=null;try{let c=new s(o.track),a=await pe(c.getPhotoCapabilities?.()??Promise.resolve({}),fe).catch(()=>({})),l=await pe(c.takePhoto(he(a)),fe);r=await createImageBitmap(l);let u={width:i.videoWidth,height:i.videoHeight};if(!de(r,u))return null;let d=$e(r,o.detectWidth),m=null;d!==null&&t!==null&&(m=await o.detect(d).catch(()=>null));let h=d??{width:r.width,height:r.height};m!==null&&!me(m,h,t,e)&&(m=null);let f=ft(m,h,r,n);return{...await ye(r,f.crop,f.width,f.height,f.docRegion),docRegion:f.docRegion,source:"photo",width:f.width,height:f.height}}catch{return null}finally{r?.close()}}var st=Object.freeze({width:3840,height:2160,lensSelection:!0,continuousFocus:!0,refocusBeforePhotoMs:350,zoomMax:2,zoomNoFocusInfo:1.5,zoomMinSourcePx:2160,fillDistanceM:Object.freeze({id1:.11,id3:.15}),focusMarginFrac:.2,stillSharpnessMin:.16,stillRefusalsMax:2,focusFarFillFrac:.45,noDocFarHintMs:1500,zoomFallbackMs:8e3}),S=(i,t,e)=>typeof i=="number"&&Number.isFinite(i)&&i>=t&&i<=e?i:void 0;function Ti(i){let t=st,e=i!==null&&typeof i=="object"?i:{},n=e.fillDistanceM!==null&&typeof e.fillDistanceM=="object"?e.fillDistanceM:{},o=(s,r)=>typeof s=="boolean"?s:r;return{width:S(e.width,640,7680)??t.width,height:S(e.height,480,4320)??t.height,lensSelection:o(e.lensSelection,t.lensSelection),continuousFocus:o(e.continuousFocus,t.continuousFocus),refocusBeforePhotoMs:S(e.refocusBeforePhotoMs,0,2e3)??t.refocusBeforePhotoMs,zoomMax:S(e.zoomMax,1,5)??t.zoomMax,zoomNoFocusInfo:S(e.zoomNoFocusInfo,1,5)??t.zoomNoFocusInfo,zoomMinSourcePx:S(e.zoomMinSourcePx,0,8e3)??t.zoomMinSourcePx,fillDistanceM:{id1:S(n.id1,.03,1)??t.fillDistanceM.id1,id3:S(n.id3,.03,1)??t.fillDistanceM.id3},focusMarginFrac:S(e.focusMarginFrac,0,2)??t.focusMarginFrac,stillSharpnessMin:S(e.stillSharpnessMin,0,10)??t.stillSharpnessMin,stillRefusalsMax:S(e.stillRefusalsMax,0,10)??t.stillRefusalsMax,focusFarFillFrac:S(e.focusFarFillFrac,0,1)??t.focusFarFillFrac,noDocFarHintMs:S(e.noDocFarHintMs,0,6e4)??t.noDocFarHintMs,zoomFallbackMs:S(e.zoomFallbackMs,0,12e4)??t.zoomFallbackMs}}function ti(i){let t=i.toLowerCase();return t===""?"unknown":/front|facing front|user|selfie|face ?time/.test(t)?"front":/ultra|0\.5x|wide angle/.test(t)?"ultra":/tele|zoom|periscope|[2-9]x/.test(t)?"tele":/depth|tof|infrared|\bir\b|truedepth|lidar|macro|monochrome|mono\b/.test(t)?"depth":/dual|triple/.test(t)?"virtual":/back|rear|environment|facing back|arrière|خلفية/.test(t)?"main":"unknown"}function ei(i){let t=/camera2?\s*(\d+)/i.exec(i);return t?Number(t[1]):Number.POSITIVE_INFINITY}function ii(i){let t={main:0,virtual:1,ultra:9,tele:9,depth:9,front:9,unknown:9};return i.filter(e=>(e.kind===void 0||e.kind==="videoinput")&&e.deviceId!=="").map((e,n)=>({id:e.deviceId,kind:ti(e.label),index:ei(e.label),i:n})).filter(e=>t[e.kind]<9).sort((e,n)=>t[e.kind]-t[n.kind]||e.index-n.index||e.i-n.i).map(e=>e.id)}var gt="sekyro.doc.camera";function ni(){try{let i=globalThis.localStorage?.getItem(gt);return typeof i=="string"&&i!==""?i:null}catch{return null}}function xe(i){try{i===null?globalThis.localStorage?.removeItem(gt):globalThis.localStorage?.setItem(gt,i)}catch{}}var rt=(i,t)=>Array.isArray(i?.focusMode)&&i.focusMode.includes(t);function yt(i,t,e){if(!rt(i,"single-shot"))return null;let n=o=>Math.min(1,Math.max(0,Number.isFinite(o)?o:.5));return{focusMode:"single-shot",pointsOfInterest:[{x:n(t),y:n(e)}]}}function _i(i,t,e,n){if(!Number.isFinite(i)||!Number.isFinite(t)||e.width<=0||e.height<=0||n.width<=0||n.height<=0)return null;let o=Math.max(e.width/n.width,e.height/n.height),s=n.width*o,r=n.height*o,c=(i-e.left+(s-e.width)/2)/s,a=(t-e.top+(r-e.height)/2)/r;return{x:Math.min(1,Math.max(0,c)),y:Math.min(1,Math.max(0,a))}}function we(i,t,e,n=st){let o=i?.zoom?.min,s=i?.zoom?.max;if(typeof s!="number"||s<=1)return 1;let r=e==="ID-3"?n.fillDistanceM.id3:n.fillDistanceM.id1,c=i?.focusDistance?.min,a;if(typeof c=="number"&&c>0&&c<1){if(a=c*(1+n.focusMarginFrac)/r,a<=1.05)return 1}else{if(Math.min(t.width,t.height)<n.zoomMinSourcePx)return 1;a=n.zoomNoFocusInfo}let l=Math.min(a,n.zoomMax,s);typeof o=="number"&&(l=Math.max(l,o));let u=i?.zoom?.step;return typeof u=="number"&&u>0&&(l=Math.round(l/u)*u),l>1.01?Number(l.toFixed(2)):1}function bt(i){try{return i.getVideoTracks?.()[0]}catch{return}}function De(i){if(i!==null)for(let t of i.getTracks())t.stop()}function oi(i){try{let t=bt(i)?.getCapabilities?.();return!Array.isArray(t?.focusMode)||t.focusMode.includes("continuous")}catch{return!0}}var si=3;async function ve(i){let t=s=>({audio:!1,video:{...s,width:{ideal:i.base.width},height:{ideal:i.base.height}}}),e=s=>i.getUserMedia(t({deviceId:{exact:s}})),n=()=>i.getUserMedia(t({facingMode:{ideal:"environment"}}));if(i.lensSelection){let s=ni();if(s!==null)try{return{stream:await e(s),lens:"stored"}}catch{xe(null)}}let o=await n();if(!i.lensSelection||i.enumerateDevices===void 0)return{stream:o,lens:"default"};try{let s=ii(await i.enumerateDevices()).slice(0,si);if(s.length===0)return{stream:o,lens:"default"};let r=null;for(let c of s){let a=o!==null?bt(o)?.getSettings?.().deviceId:void 0;if(o===null||a!==c){De(o),o=null;try{o=await e(c)}catch{continue}}if(r??(r=c),oi(o))return xe(c),{stream:o,lens:"selected"}}if(o!==null&&r!==null&&bt(o)?.getSettings?.().deviceId===r)return{stream:o,lens:"selected"};if(De(o),o=null,r!==null)try{return{stream:await e(r),lens:"selected"}}catch{}return{stream:await n(),lens:"default"}}catch{return{stream:o??await n(),lens:"default"}}}var Z=Object.freeze({brightness:0,glare:0,cardGlare:0,sharpness:0,fill:0,shape:0,content:0,offsetX:0,offsetY:0,edgeConfidence:0,box:null}),L=i=>Math.min(1,Math.max(0,i));function Te(i,t,e,n=.06){let o=Math.max(i.width/e,i.height),s=o*e,r=(i.width-s)/2,c=(i.height-o)/2,a=L((t.x-t.width*n-r)/s),l=L((t.y-t.height*n-c)/o),u=L((t.x+t.width*(1+n)-r)/s),d=L((t.y+t.height*(1+n)-c)/o);return{x:a,y:l,width:u-a,height:d-l}}function _e(i,t,e={}){let n=e.edgePeakFrac??0,{width:o,height:s,data:r}=i;if(o<=0||s<=0)return Z;let c=L(t.x),a=L(t.y),l={x:c,y:a,width:Math.max(0,L(t.x+t.width)-c),height:Math.max(0,L(t.y+t.height)-a)};if(l.width<=0||l.height<=0)return Z;let u=l.x*o,d=l.y*s,m=(l.x+l.width)*o,h=(l.y+l.height)*s,f=(m-u)*.15,g=(h-d)*.15,y=(p,b,R)=>Math.min(R,Math.max(b,p)),x=y(Math.floor(u-f),0,o-1),w=y(Math.floor(d-g),0,s-1),I=y(Math.ceil(m+f),x+1,o),v=y(Math.ceil(h+g),w+1,s),D=Math.max(1,Math.ceil(Math.max(I-x,v-w)/320)),M=Math.floor((I-x+D-1)/D),T=Math.floor((v-w+D-1)/D);if(M<3||T<3)return Z;let k=new Int32Array(M*T);for(let p=0;p<T;p++){let b=w+p*D;for(let R=0;R<M;R++){let F=(b*o+x+R*D)*4;k[p*M+R]=(r[F]??0)*77+(r[F+1]??0)*150+(r[F+2]??0)*29>>8}}let C=(p,b)=>(p-b-.5)/D,_=C(u,x),A=C(m,x),B=C(d,w),U=C(h,w),kt=(m-u)/D,xt=(h-d)/D,Dt=y(Math.ceil(_),0,M-1),Ie=y(Math.floor(A),Dt,M-1),wt=y(Math.ceil(B),0,T-1),Oe=y(Math.floor(U),wt,T-1),vt=0,St=0,W=0,Tt=0,_t=0,H=0;for(let p=wt;p<=Oe;p++)for(let b=Dt;b<=Ie;b++){let R=k[p*M+b];if(vt+=R,R>=248&&St++,W++,b>=1&&b<M-1&&p>=1&&p<T-1){let F=k[p*M+b-1]+k[p*M+b+1]+k[(p-1)*M+b]+k[(p+1)*M+b]-4*R;Tt+=F,_t+=F*F,H++}}let Pe=W>0?vt/W:0,Rt=W>0?St/W:0,Ft=H>0?Tt/H:0,Ge=H>0?Math.max(0,_t/H-Ft*Ft):0,K=new Float64Array(M),V=new Float64Array(T);for(let p=0;p<T;p++)for(let b=1;b<M-1;b++)K[b]=K[b]+Math.abs(k[p*M+b+1]-k[p*M+b-1]);for(let p=1;p<T-1;p++)for(let b=0;b<M;b++)V[p]=V[p]+Math.abs(k[(p+1)*M+b]-k[(p-1)*M+b]);let O=at(K,!0,_,n),P=at(K,!1,A,n),G=at(V,!0,B,n),z=at(V,!1,U,n),Ct=(P.position-O.position)/kt,At=(z.position-G.position)/xt,ze=At>0?Ct/At:0,Ne=((O.position+P.position)/2-(_+A)/2)/kt,Qe=((G.position+z.position)/2-(B+U)/2)/xt,Et=Se(K),Lt=Se(V),Be=Et<=0||Lt<=0?0:Math.min(Math.min(O.value,P.value)/Et,Math.min(G.value,z.value)/Lt),$=(p,b)=>b+(p+.5)*D,It=Rt,Ot=0;{let p=(P.position-O.position)*.06,b=(z.position-G.position)*.06,R=y(Math.ceil(O.position+p),0,M-1),F=y(Math.floor(P.position-p),0,M-1),Ue=y(Math.ceil(G.position+b),0,T-1),Pt=y(Math.floor(z.position-b),0,T-1),Gt=0,tt=0,zt=0;for(let N=Ue;N<=Pt;N++)for(let Q=R;Q<=F;Q++){tt++;let X=k[N*M+Q];X>=248&&Gt++;let We=Q+2<=F?k[N*M+Q+2]:X,He=N+2<=Pt?k[(N+2)*M+Q]:X;(Math.abs(We-X)>=24||Math.abs(He-X)>=24)&&zt++}tt>=16&&(It=Gt/tt,Ot=zt/tt)}return{brightness:Pe,glare:Rt,cardGlare:It,sharpness:Ge,fill:Ct,shape:ze,content:Ot,offsetX:Ne,offsetY:Qe,edgeConfidence:Be,box:{left:$(O.position,x),right:$(P.position,x),top:$(G.position,w),bottom:$(z.position,w)}}}function at(i,t,e,n){let o=i.length,s=Math.max(1,Math.floor(o*.45)),r=t?1:Math.max(1,o-1-s),c=t?Math.min(o-2,s):o-2,a=r;for(let h=r;h<=c;h++)i[h]>i[a]&&(a=h);if(n>0&&n<1){let h=i[a]*n,f=a,g=Math.abs(a-e);for(let y=r;y<=c;y++){let x=i[y];if(x<h||x<(i[y-1]??0)||x<(i[y+1]??0))continue;let w=Math.abs(y-e);w<g&&(f=y,g=w)}a=f}let l=a>0?i[a-1]:0,u=i[a],d=a<o-1?i[a+1]:0,m=l+u+d;return{position:m>0?a+(d-l)/m:a,value:u}}function Se(i){if(i.length<3)return 0;let t=0;for(let e=1;e<i.length-1;e++)t+=i[e];return t/(i.length-2)}function Re(i){let t=i.box;return t===null||t.right-t.left<4||t.bottom-t.top<4?null:{topLeft:{x:t.left,y:t.top},topRight:{x:t.right,y:t.top},bottomRight:{x:t.right,y:t.bottom},bottomLeft:{x:t.left,y:t.bottom}}}var J=Object.freeze({fillMin:.82,fillMax:1.06,offsetMax:.06,glareMax:.025,sharpnessMin:180,edgeConfidenceMin:1.6,darkBrightness:70,lockMs:450,steadyMs:900,steadyFillMin:.45,steadyFillMax:1.3,steadyFillDelta:.06,steadyOffsetDelta:.04,steadyRefMs:100,edgePeakFrac:.4,shapeTolerance:.2,contentMin:.1});function Fi(i){let t=i!==null&&typeof i=="object"?i:{},e={...J};for(let n of Object.keys(J)){let o=t[n];typeof o=="number"&&Number.isFinite(o)&&o>=0&&o<=1e6&&(e[n]=o)}return e}var ct=class{constructor(t=J){this.t=t;this.goodSince=null;this.steadySince=null;this.last=null}reset(){this.goodSince=null,this.steadySince=null,this.last=null}tick(t,e){let n=this.t,o=n.shapeTolerance<=0||Math.abs(t.shape-1)<=n.shapeTolerance,s=t.edgeConfidence>=n.edgeConfidenceMin&&o&&t.content>=n.contentMin,r=t.fill>=n.fillMin&&t.fill<=n.fillMax,c=Math.abs(t.offsetX)<=n.offsetMax&&Math.abs(t.offsetY)<=n.offsetMax,a=t.cardGlare<=n.glareMax,l=t.sharpness>=n.sharpnessMin,u=this.last;this.last={fill:t.fill,offsetX:t.offsetX,offsetY:t.offsetY,at:e};let d=u!==null&&n.steadyRefMs>0?Math.min(3,Math.max(1,(e-u.at)/n.steadyRefMs)):1,m=s&&a&&l&&t.fill>=n.steadyFillMin&&t.fill<=n.steadyFillMax&&u!==null&&Math.abs(t.fill-u.fill)<=n.steadyFillDelta*d&&Math.abs(t.offsetX-u.offsetX)<=n.steadyOffsetDelta*d&&Math.abs(t.offsetY-u.offsetY)<=n.steadyOffsetDelta*d,h=s&&r&&c&&a&&l,f;if(s?a?t.fill<n.fillMin?f="too_small":t.fill>n.fillMax?f="too_big":l?c?f="locking":f="off_center":f="blurry":f="glare":f="no_card",h){if(m&&(this.steadySince??(this.steadySince=e)),this.goodSince??(this.goodSince=e),e-this.goodSince>=n.lockMs)return{detected:s,ready:!0,via:"good",blocker:"locking"};let g=this.steadySince!==null&&e-this.steadySince>=n.steadyMs;return{detected:s,ready:g,via:g?"steady":null,blocker:"locking"}}if(this.goodSince=null,m){this.steadySince??(this.steadySince=e);let g=e-this.steadySince>=n.steadyMs;return{detected:s,ready:g,via:g?"steady":null,blocker:g?"locking":"steadying"}}return this.steadySince=null,{detected:s,ready:!1,via:null,blocker:f}}};var q=null;async function ri(i){return q===null&&(q=(await import("./detector-scanic-YCDNLCGV.js")).detectQuad),q(i)}async function ai(i){let t=Jt(i);return t===null?null:{topLeft:{x:t.x,y:t.y},topRight:{x:t.x+t.width,y:t.y},bottomRight:{x:t.x+t.width,y:t.y+t.height},bottomLeft:{x:t.x,y:t.y+t.height}}}function Vi(){q===null&&import("./detector-scanic-YCDNLCGV.js").then(i=>{q=i.detectQuad}).catch(()=>{})}var Fe=4e3,ci=2,Ce=3,li=Object.freeze({LOW:3,MID:5,HIGH:6}),Mt=Object.freeze({manualShutterMs:6e3,detectedNoLockMs:1950});function Xi(i){let t=i!==null&&typeof i=="object"?i:{},e=(n,o,s)=>typeof n=="number"&&Number.isFinite(n)&&n>=o&&n<=s?n:void 0;return{manualShutterMs:e(t.manualShutterMs,1e3,6e4)??Mt.manualShutterMs,detectedNoLockMs:e(t.steadyMs,300,3e4)!==void 0?t.steadyMs+(e(t.lockMs,0,1e4)??450):Mt.detectedNoLockMs}}var Ae=class i{constructor(t){this.torchOn=!1;this.stillRefusals=0;this.zoom=1;this.positioningSince=null;this.detectedSince=null;this.lastSeenAt=null;this.lastGuideQuad=null;this.lastOcrReady=null;this.shutterOffered=!1;this.stats=i.freshStats();this.handlers=new Map;this.stream=null;this.timer=null;this.state="idle";this.lastGuidance=null;this.attempt=0;this.capturing=!1;this.feedback=new nt;this.lastFeedbackKey=null;this.lastQuad=null;this.lastDetect=null;this.frameWatch=null;this.reopened=!1;this.lit=!1;this.blackTicks=0;this.offEnded=null;this.opts=t,this.gate=new ee(t.format??"ID-1",t.thresholds);let e=t.deviceClass??Kt(Ht());this.deviceClass=e,this.camera=t.camera??st,this.shutterTuning=t.shutter??Mt,this.guideTuning=t.guideLock??J,this.guideLock=new ct(this.guideTuning),this.cadenceMs=1e3/li[e]}on(t,e){let n=this.handlers.get(t);return n||(n=new Set,this.handlers.set(t,n)),n.add(e),()=>n?.delete(e)}emit(t,e){for(let n of[...this.handlers.get(t)??[]])n(e)}async start(){let t=this.state==="error"?this.resumePlayback():null,e=++this.attempt;if(this.clearFrameWatch(),this.gate.reset(),this.resetSide(),this.feedback.reset(),this.lastFeedbackKey=null,this.lastGuidance=null,this.capturing=!1,this.lit=!1,this.blackTicks=0,t!==null&&await t&&e===this.attempt){this.setState("positioning"),this.scheduleTick(e),this.watchFrames(e);return}if(e===this.attempt){this.releaseStream(),Wt(),this.setState("preflight");try{let n=this.opts.getUserMedia??(r=>navigator.mediaDevices.getUserMedia(r));this.setState("acquiring");let o=this.opts.enumerateDevices??(this.opts.getUserMedia===void 0&&typeof navigator<"u"&&navigator.mediaDevices?.enumerateDevices?()=>navigator.mediaDevices.enumerateDevices():void 0),s=await ve({getUserMedia:n,...o!==void 0?{enumerateDevices:o}:{},lensSelection:this.camera.lensSelection,base:ae});if(e!==this.attempt){for(let r of s.stream.getTracks())r.stop();return}if(this.stream=s.stream,Bt(this.stream),Ut(this.stream),this.watchEnded(e),this.opts.upgradeResolution!==!1&&await this.upgradeResolution(),e!==this.attempt||(await this.applyFocusAndZoom(),e!==this.attempt)||(this.opts.video.srcObject=this.stream,await this.opts.video.play().catch(()=>{}),e!==this.attempt))return;this.setState("positioning"),this.scheduleTick(e),this.watchFrames(e)}catch(n){if(e!==this.attempt)return;let o=Qt(n),s=Nt(n);this.setState("error"),this.emit("error",{kind:o,retryable:!0,detail:s===void 0?{phase:"acquiring"}:{phase:"acquiring",name:s}})}}}resumePlayback(){let t=this.opts.video,e=this.videoTrack();if(this.stream===null||e===null||e.readyState!=="live"||t.srcObject!==this.stream)return null;try{return Promise.resolve(t.play()).then(()=>this.framesNow(),()=>!1)}catch{return null}}framesNow(){let t=this.opts.video;return this.opts.hasFrames!==void 0?this.opts.hasFrames(t):!t.paused&&t.readyState>=2&&t.videoWidth>0}watchFrames(t){let e=this.opts.firstFrameMs??Fe;e<=0||(this.clearFrameWatch(),this.frameWatch=setTimeout(()=>{if(this.frameWatch=null,!(t!==this.attempt||this.state!=="positioning")){if(this.framesNow()&&this.blackTicks<Ce){this.reopened=!1;return}this.cameraDead(t)}},e))}clearFrameWatch(){this.frameWatch!==null&&clearTimeout(this.frameWatch),this.frameWatch=null}watchEnded(t){this.offEnded?.(),this.offEnded=null;let e=this.videoTrack();if(e===null||typeof e.addEventListener!="function")return;let n=()=>{t===this.attempt&&(this.state==="positioning"||this.state==="acquiring")&&this.cameraDead(t)};e.addEventListener("ended",n),this.offEnded=()=>e.removeEventListener?.("ended",n)}cameraDead(t){if(t!==this.attempt)return;let e=this.videoTrack(),n=e!==null&&e.readyState==="live"&&!e.muted&&this.opts.video.paused&&!this.framesNow();if(!n&&!this.reopened){this.reopened=!0,this.start();return}this.attempt+=1,this.timer!==null&&(this.opts.clearTimer??clearTimeout)(this.timer),this.timer=null,this.clearFrameWatch(),n||this.releaseStream(),this.reopened=!1,this.setState("error"),this.emit("error",{kind:"generic",retryable:!0,detail:{phase:"acquiring"}})}releaseStream(){if(this.offEnded?.(),this.offEnded=null,this.stream)for(let t of this.stream.getTracks())t.stop();this.stream=null,this.opts.video.srcObject!==null&&this.opts.video.srcObject!==void 0&&(this.opts.video.srcObject=null)}rearm(t){t!==void 0&&(this.opts.side=t),this.gate.reset(),this.resetSide(),this.feedback.reset(),this.lastFeedbackKey=null,this.lastGuidance=null,this.capturing=!1,this.stillRefusals=0,this.state==="captured"&&(this.setState("positioning"),this.scheduleTick(this.attempt))}async captureNow(){if(this.state!=="positioning"||this.capturing)return;let t=this.opts.video,e=this.lastDetect?.width??Math.max(1,t.videoWidth),n=this.lastDetect?.height??Math.max(1,t.videoHeight),o=this.lastQuad??this.lastGuideQuad??{topLeft:{x:0,y:0},topRight:{x:e,y:0},bottomRight:{x:e,y:n},bottomLeft:{x:0,y:n}},s=(this.opts.now??(()=>performance.now()))(),r=this.feedback.force("processing",s);this.lastFeedbackKey=r.key,this.emit("feedback",r),await this.fire(this.attempt,this.lastOcrReady!==null?this.lastOcrReady.quad:o,{width:e,height:n,tickSharpness:this.lastDetect?.tickSharpness??0},this.lastOcrReady?.via??"manual")}captureReport(){let t=this.stats;return{...this.opts.side!==void 0?{side:this.opts.side}:{},format:this.opts.format??"ID-1",deviceClass:this.deviceClass,video:{width:this.opts.video.videoWidth||0,height:this.opts.video.videoHeight||0},zoom:this.zoom,...t.zoomFallbackAtMs!==void 0?{zoomFallbackAtMs:t.zoomFallbackAtMs}:{},...t.msToCapture!==void 0?{msToCapture:t.msToCapture}:{},...t.via!==void 0?{via:t.via}:{},...t.shutterAtMs!==void 0?{shutterAtMs:t.shutterAtMs}:{},...t.shutterReason!==void 0?{shutterReason:t.shutterReason}:{},ticks:t.ticks,quadFraming:{...t.quadFraming},qualityBlockers:{...t.qualityBlockers},guideBlockers:{...t.guideBlockers},stillRefusals:t.stillRefusals,...this.ocrReport()}}ocrReport(){let t=this.opts.ocr;if(t===void 0)return{};let e=(this.opts.format??"ID-1")==="ID-3"||this.opts.side==="single"?"single":this.opts.side==="verso"?"verso":"recto",n=t.report(e,this.stats.via,(this.opts.now??(()=>performance.now()))());return n===null?{}:{ocr:n}}static freshStats(){return{ticks:0,quadFraming:{},qualityBlockers:{},guideBlockers:{},stillRefusals:0}}setGuide(t){t===void 0?delete this.opts.guide:this.opts.guide=t,this.guideLock.reset()}guideRegion(t){let e=t.width/Math.max(1,t.height),n=this.opts.guide;if(n!==void 0&&n.viewAspect>0){let c={width:n.viewAspect,height:1},a={x:n.rect.x*n.viewAspect,y:n.rect.y,width:n.rect.width*n.viewAspect,height:n.rect.height};return Te(c,a,e,0)}let o=Xt(this.opts.format??"ID-1").center,s=.86,r=s*e/o;return r>.84&&(r=.84,s=r*o/e),{x:(1-s)/2,y:(1-r)/2,width:s,height:r}}resetSide(){this.positioningSince=null,this.detectedSince=null,this.lastSeenAt=null,this.guideLock.reset(),this.lastGuideQuad=null,this.lastOcrReady=null,this.opts.ocr?.reset(),this.stats=i.freshStats(),this.shutterOffered&&(this.shutterOffered=!1,this.emit("shutter",{available:!1}))}withdrawShutter(){this.shutterOffered&&(this.shutterOffered=!1,this.emit("shutter",{available:!1}))}zoomFallback(t){let e=this.videoTrack();if(e===null||this.zoom<=1)return;let n=this.focusCaps(),o=typeof n?.zoom?.min=="number"?Math.max(n.zoom.min,1):1;this.zoom=o,this.stats.zoomFallbackAtMs=Math.round(t-(this.positioningSince??t)),this.guideLock.reset(),this.gate.reset(),e.applyConstraints({advanced:[{zoom:o}]}).catch(()=>{})}offerShutter(t,e){this.shutterOffered||(this.shutterOffered=!0,this.stats.shutterAtMs=Math.round(e-(this.positioningSince??e)),this.stats.shutterReason=t,this.emit("shutter",{available:!0,reason:t}))}torchAvailable(){try{return this.stream?.getVideoTracks?.()[0]?.getCapabilities?.()?.torch===!0}catch{return!1}}async setTorch(t){this.torchOn=t;try{await this.stream?.getVideoTracks?.()[0]?.applyConstraints({advanced:[{torch:t}]})}catch{}}destroy(){if(this.attempt+=1,this.timer!==null&&(this.opts.clearTimer??clearTimeout)(this.timer),this.timer=null,this.clearFrameWatch(),this.offEnded?.(),this.offEnded=null,this.stream)for(let t of this.stream.getTracks())t.stop();this.stream=null,this.opts.video.srcObject=null}async upgradeResolution(){try{let t=this.stream?.getVideoTracks?.()[0];if(t===void 0)return;let e=t.getSettings?.()??{},n=ue(t.getCapabilities?.(),{width:e.width??0,height:e.height??0},this.deviceClass,{width:this.camera.width,height:this.camera.height});n!==null&&await t.applyConstraints(n)}catch{}}focusCaps(){try{return this.videoTrack()?.getCapabilities?.()??null}catch{return null}}async applyFocusAndZoom(){let t=this.videoTrack();if(t===null)return;let e=this.focusCaps();this.camera.continuousFocus&&rt(e,"continuous")&&await t.applyConstraints({advanced:[{focusMode:"continuous"}]}).catch(()=>{});let n={width:0,height:0};try{let s=t.getSettings?.()??{};n={width:s.width??0,height:s.height??0}}catch{}let o=we(e,n,this.opts.format??"ID-1",this.camera);if(o>1)try{await t.applyConstraints({advanced:[{zoom:o}]}),this.zoom=o}catch{this.zoom=1}}async focusAt(t,e){let n=this.videoTrack(),o=yt(this.focusCaps(),t,e);if(!(n===null||o===null))try{await n.applyConstraints({advanced:[o]}),(this.opts.setTimer??setTimeout)(()=>{this.restoreContinuous()},1500)}catch{}}async restoreContinuous(){let t=this.videoTrack();t===null||!this.camera.continuousFocus||!rt(this.focusCaps(),"continuous")||await t.applyConstraints({advanced:[{focusMode:"continuous"}]}).catch(()=>{})}async refocusOn(t,e){let n=this.camera.refocusBeforePhotoMs,o=this.videoTrack();if(n<=0||o===null||e.width<=0||e.height<=0)return;let s=E(t),r=yt(this.focusCaps(),(s.x+s.width/2)/e.width,(s.y+s.height/2)/e.height);if(r!==null)try{await o.applyConstraints({advanced:[r]});let c=this.opts.setTimer??setTimeout;await new Promise(a=>{c(()=>a(),n)})}catch{}}videoTrack(){try{return this.stream?.getVideoTracks?.()[0]??null}catch{return null}}async takeStill(t,e,n){if(this.opts.captureStill!==void 0)return this.opts.captureStill(this.opts.video,t,e);let o=this.opts.format??"ID-1",s=this.videoTrack();if(n&&this.opts.photoCapture!==!1&&this.deviceClass!=="LOW"&&!this.torchOn&&s!==null&&be(s)){await this.refocusOn(t,e);let r=await ke(this.opts.video,t,e,o,{track:s,detect:this.detector(),detectWidth:et});if(this.restoreContinuous(),r!==null)return r}return Me(this.opts.video,t,e,o)}detector(){return this.opts.detect??((this.opts.format??"ID-1")==="ID-3"?ai:ri)}setState(t){this.state=t,this.emit("statechange",{state:t})}scheduleTick(t){let e=this.opts.setTimer??setTimeout;this.timer=e(()=>{this.tick(t)},this.cadenceMs)}async tick(t){if(t!==this.attempt||this.state!=="positioning"||this.capturing)return;let e=this.opts.now??(()=>performance.now()),n=this.opts.grabDetectFrame??Le,o=this.detector(),s=n(this.opts.video,et);if(s===null){this.scheduleTick(t);return}if(!this.lit){if(ht(s)>ci)this.lit=!0,this.blackTicks=0;else if(++this.blackTicks>=Ce&&this.frameWatch===null&&(this.opts.firstFrameMs??Fe)>0){this.cameraDead(t);return}}let r=null;try{r=await o(s)}catch{r=null}if(t!==this.attempt)return;let c=r!==null?lt(s,r):s,a=e(),l={sharpness:j(c),exposure:Vt(c),meanLuma:ht(c),specularFraction:oe(c)},u=se({format:this.opts.format??"ID-1",quad:r,frameWidth:s.width,frameHeight:s.height,measures:l,...this.opts.thresholds!==void 0?{thresholds:this.opts.thresholds}:{}}),d=this.gate.tick({timestampMs:a,quad:r,quality:l,frameWidth:s.width,frameHeight:s.height}),h=(this.opts.format??"ID-1")!=="ID-3"?_e(s,this.guideRegion(s),{edgePeakFrac:this.guideTuning.edgePeakFrac}):Z,f=this.guideLock.tick(h,a);this.lastGuideQuad=f.detected?Re(h):null;let g=this.capturing?null:this.ocrTick(s,r,h,f.detected,u,a);this.positioningSince??(this.positioningSince=a);let y=this.stats;if(y.ticks+=1,y.quadFraming[u.framing]=(y.quadFraming[u.framing]??0)+1,u.framing==="ok"&&!d.ready){let _=u.lighting!=="ok"?u.lighting:u.glare!=="ok"?"glare":u.blur!=="ok"?"blurry":"steadying";y.qualityBlockers[_]=(y.qualityBlockers[_]??0)+1}y.guideBlockers[f.blocker]=(y.guideBlockers[f.blocker]??0)+1,r!==null||f.detected?(this.detectedSince??(this.detectedSince=a),this.lastSeenAt=a):this.detectedSince=null,this.lastSeenAt!==null&&a-this.lastSeenAt<=gi?a-this.positioningSince>=this.shutterTuning.manualShutterMs?this.offerShutter("timeout",a):g?.suspendQuality!==!0&&this.detectedSince!==null&&a-this.detectedSince>=this.shutterTuning.detectedNoLockMs&&this.offerShutter("detected_no_lock",a):this.withdrawShutter();let I=a-(this.lastSeenAt??this.positioningSince);this.zoom>1&&this.camera.zoomFallbackMs>0&&I>=this.camera.zoomFallbackMs&&this.zoomFallback(a),this.emit("checks",{engine:"docv1",p:d.p,plausible:d.plausible,stableTicks:d.stableTicks,quad:d.quad,frameWidth:s.width,frameHeight:s.height,analysis:u,ready:g?.suspendQuality!==!0&&(d.ready&&r!==null||f.ready&&this.lastGuideQuad!==null)||this.lastOcrReady!==null,guide:{detected:f.detected,blocker:f.blocker,fill:h.fill,shape:h.shape,content:h.content,offsetX:h.offsetX,offsetY:h.offsetY},...g!==null&&g.mode!=="off"?{ocr:{mode:g.mode,...g.mrz?{mrz:g.mrz}:{},...g.lock?{lock:g.lock}:{}}}:g?.mrz?{ocr:{mode:g.mode,mrz:g.mrz}}:{}}),this.lastQuad=d.plausible?r:null,this.lastDetect={width:s.width,height:s.height,tickSharpness:l.sharpness};let v=ie(u);u.framing!=="ok"&&f.detected&&(v=pi(f.blocker,h.brightness<this.guideTuning.darkBrightness)),v==="blurry"&&r!==null&&hi(r,s,this.opts.format??"ID-1")>=this.camera.focusFarFillFrac&&(v="focus_far"),v==="sensing"&&this.zoom>1&&this.camera.noDocFarHintMs>0&&I>=this.camera.noDocFarHintMs&&(v="focus_far");let D=this.feedback.tick(v,a);if(D.key!==this.lastFeedbackKey&&(this.lastFeedbackKey=D.key,this.emit("feedback",D)),d.guidanceKey!==this.lastGuidance&&(this.lastGuidance=d.guidanceKey,this.emit("guidance",{key:d.guidanceKey})),this.capturing)return;let M=g?.suspendQuality!==!0,T=M&&d.ready&&r!==null,k=M&&f.ready&&this.lastGuideQuad!==null,C=this.lastOcrReady;if(C!==null&&this.opts.autoCapture!==!1){let _=this.feedback.force("processing",a);this.lastFeedbackKey=_.key,this.emit("feedback",_);let A=j(lt(s,C.quad));await this.fire(t,C.quad,{width:s.width,height:s.height,tickSharpness:A},C.via);return}if((T||k)&&this.opts.autoCapture!==!1){let _=this.feedback.force("processing",a);this.lastFeedbackKey=_.key,this.emit("feedback",_);let A=k?this.lastGuideQuad:r,B=k?f.via==="steady"?"guide_steady":"guide_good":"quad",U=k?j(lt(s,A)):l.sharpness;await this.fire(t,A,{width:s.width,height:s.height,tickSharpness:U},B);return}this.scheduleTick(t)}async fire(t,e,n,o){this.capturing=!0;let s=this.opts.grabDetectFrame??Le,r=this.opts.setTimer??setTimeout,c={width:n.width,height:n.height};try{let a={still:await this.takeStill(e,c,!0),sharpness:n.tickSharpness};if(t!==this.attempt)return;let l=a.still.source==="photo"?0:di;for(let m=0;m<l;m++){if(await new Promise(g=>{r(()=>g(),mi)}),t!==this.attempt)return;let h=s(this.opts.video,et);if(h===null)continue;let f=j(lt(h,e));if(f>a.sharpness*fi){let g=await this.takeStill(e,c,!1);if(t!==this.attempt)return;a={still:g,sharpness:f}}}if(t!==this.attempt)return;let u=a.still.sharpness;if(this.opts.autoCapture!==!1&&o!=="manual"&&typeof u=="number"&&u>=0&&u<this.camera.stillSharpnessMin&&this.stillRefusals<this.camera.stillRefusalsMax){this.stillRefusals+=1,this.stats.stillRefusals+=1,this.guideLock.reset(),this.lastOcrReady=null,(o==="text_lock"||o==="live_mrz")&&this.opts.ocr?.rearmFace();let m=(this.opts.now??(()=>performance.now()))(),h=this.feedback.force("focus_far",m);this.lastFeedbackKey=h.key,this.emit("feedback",h),this.capturing=!1,this.gate.reset(),this.scheduleTick(t);return}this.stillRefusals=0;let d=(this.opts.now??(()=>performance.now()))();this.stats.via=o,this.stats.msToCapture=Math.round(d-(this.positioningSince??d)),this.shutterOffered&&(this.shutterOffered=!1,this.emit("shutter",{available:!1})),this.setState("captured"),this.emit("artifacts",{keyframe:a.still.blob,previewDataUrl:a.still.previewDataUrl,...this.opts.side!==void 0?{side:this.opts.side}:{},...a.still.docRegion!==void 0?{docRegion:a.still.docRegion}:{},...(()=>{let m=o==="live_mrz"?this.opts.ocr?.liveCapture():null;return m?{liveMrz:m}:{}})()})}catch{if(t!==this.attempt)return;this.capturing=!1,this.gate.reset(),this.guideLock.reset(),this.lastOcrReady=null,(o==="text_lock"||o==="live_mrz")&&this.opts.ocr?.rearmFace(),this.scheduleTick(t)}}ocrTick(t,e,n,o,s,r){let c=this.opts.ocr,a=this.opts.video;if(c===void 0||!c.hasEngine)return this.lastOcrReady=null,null;let l=a.videoWidth,u=a.videoHeight;if(l<=0||u<=0||t.width<=0||t.height<=0)return null;let m=(this.opts.format??"ID-1")==="ID-3",h=this.guideRegion(t),f={x:h.x*l,y:h.y*u,w:h.width*l,h:h.height*u},g=l/t.width,y=u/t.height,x;m&&e!==null?x=ui(E(e),g,y,l,u):x=qt(f,c.bandTop,u);let w=m?s.glare==="ok":n.cardGlare<=this.guideTuning.glareMax,I=m?s.blur==="ok":n.sharpness>=this.guideTuning.sharpnessMin,v=c.tick({atMs:r,video:a,mrzFace:m||this.opts.side==="verso"||this.opts.side==="single",present:m||e!==null||o,card:f,band:x,portrait:u>l,glareOk:w,sharpOk:I});if(v.ready&&v.via!==void 0){let D=m?e??Ee(h,t):this.lastGuideQuad??Ee(h,t);this.lastOcrReady={quad:D,via:v.via}}else this.lastOcrReady=null;return v}};function ui(i,t,e,n,o){let s=Math.min(n,i.width*1.06*t),r=Math.min(o,Math.max(i.height*1.6*e,s/5)),c=(i.y+i.height/2)*e,a=Math.max(0,Math.min(n-s,(i.x-i.width*.03)*t)),l=Math.max(0,Math.min(o-r,c-r/2));return{x:a,y:l,w:s,h:r}}function Ee(i,t){let e=i.x*t.width,n=i.y*t.height,o=(i.x+i.width)*t.width,s=(i.y+i.height)*t.height;return{topLeft:{x:e,y:n},topRight:{x:o,y:n},bottomRight:{x:o,y:s},bottomLeft:{x:e,y:s}}}function hi(i,t,e){let n=E(i);return t.width<=0||t.height<=0?0:e==="ID-3"?n.width/t.width:n.width*n.height/(t.width*t.height)}var di=2,mi=260,fi=1.08;function Le(i,t){let e=i.videoWidth,n=i.videoHeight;if(e===0||n===0)return null;let o=Math.min(1,t/e),s=Math.round(e*o),r=Math.round(n*o),c=document.createElement("canvas");c.width=s,c.height=r;let a=c.getContext("2d",{willReadFrequently:!0});return a===null?null:(e/Math.max(1,s)>4&&(a.imageSmoothingQuality="high"),a.drawImage(i,0,0,s,r),a.getImageData(0,0,s,r))}function lt(i,t){let e=[t.topLeft.x,t.topRight.x,t.bottomRight.x,t.bottomLeft.x],n=[t.topLeft.y,t.topRight.y,t.bottomRight.y,t.bottomLeft.y],o=Math.max(0,Math.floor(Math.min(...e))),s=Math.max(0,Math.floor(Math.min(...n))),r=Math.min(i.width,Math.ceil(Math.max(...e))),c=Math.min(i.height,Math.ceil(Math.max(...n))),a=Math.max(1,r-o),l=Math.max(1,c-s),u=new Uint8ClampedArray(a*l*4);for(let d=0;d<l;d++){let m=((s+d)*i.width+o)*4;u.set(i.data.subarray(m,m+a*4),d*a*4)}return{data:u,width:a,height:l,colorSpace:i.colorSpace}}function pi(i,t){return i==="glare"?"glare":i==="too_small"?"too_far":i==="too_big"?"too_close":t?"too_dark":i==="blurry"?"blurry":i==="off_center"?"edge_clipped":i==="no_card"?"sensing":"hold_still"}var gi=1200;export{it as a,ie as b,nt as c,Ke as d,oe as e,Ve as f,se as g,st as h,Ti as i,ti as j,ii as k,gt as l,ni as m,xe as n,rt as o,yt as p,_i as q,we as r,oi as s,si as t,ve as u,Z as v,Te as w,_e as x,Re as y,J as z,Fi as A,ct as B,Vi as C,Fe as D,ci as E,Ce as F,li as G,Mt as H,Xi as I,Ae as J,ui as K,di as L,mi as M};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var v=["session.completed","session.failed","session.review_pending","session.expired","session.cancelled"],u=new Set([0,1,2,3]),a="sekyro-verify",E="width=480,height=720,noopener=false",f=new Set(v);function y(e){if(e===null||typeof e!="object")return!1;let n=e;return n.source==="sekyro"&&n.version===1&&typeof n.sessionId=="string"&&typeof n.event=="string"&&f.has(n.event)}function S(e){let n=new URL(e.hostedUrl).origin,t=window.open(e.hostedUrl,a,E);if(!t)return{error:"popup_blocked"};let r=o=>{if(o.source!==t||o.origin!==n||!y(o.data))return;let{source:p,version:d,event:c,sessionId:l,level:s}=o.data,i={source:p,version:d,event:c,sessionId:l};u.has(s)&&(i.level=s),e.onEvent(i)};return window.addEventListener("message",r),{close(){window.removeEventListener("message",r),t.close()}}}function k(e,n){return n.mode==="redirect"?(window.location.assign(e),{close(){}}):S({hostedUrl:e,onEvent:n.onEvent??(()=>{})})}export{v as a,S as b,k as c};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as Z,d as j,e as J}from"./chunk-GT2ZLGF7.js";import{w as Q}from"./chunk-FGOVIGGL.js";import{c as q}from"./chunk-FUHDOEBP.js";import{f as G,l as N}from"./chunk-CQ7SKLMC.js";import{a as $,f as v}from"./chunk-OKWG3PVH.js";var se=12e4,X=13e4,oe=3e3,ie=1200,P=Symbol.for("@sekyro/web.preload.v1");function p(){let e=globalThis;return e[P]??(e[P]=new Map),e[P]}function g(e){let t=(e??$).replace(/\/+$/,"");return t===""?"/":t}function Y(e){let t=p(),r=t.get(e);return r===void 0&&(r={status:"idle",promise:null,scheduled:null,detectorPromise:null,detector:null,listeners:new Set},t.set(e,r)),r}function A(e,t){if(e.status!==t){e.status=t;for(let r of[...e.listeners])r(t)}}var T=e=>v({preferred:["blaze"],v3AssetBaseUrl:e,blazeInitTimeoutMs:se}),x=T;function Se(e){x=e??T}function Ce(){for(let e of p().values())e.detector?.destroy();p().clear(),x=T}function ae(){return typeof window<"u"&&typeof navigator<"u"&&typeof navigator.mediaDevices?.getUserMedia=="function"}function ce(){return navigator.connection?.saveData===!0}function de(e){let t=window;if(typeof t.requestIdleCallback=="function"){let s=t.requestIdleCallback(e,{timeout:oe});return()=>t.cancelIdleCallback?.(s)}let r=setTimeout(e,ie);return()=>clearTimeout(r)}function ue(e,t){let r,s=new Promise(o=>{r=o}),u=!1,f=()=>{},d={promise:s,settle:o=>{u||(u=!0,f(),e.scheduled===d&&(e.scheduled=null),r(o))}};return e.scheduled=d,f=de(()=>{u||d.settle(I(e,t))}),s}function I(e,t){if((e.status==="loading"||e.status==="ready")&&e.promise!==null)return e.promise;A(e,"loading");let r=new Promise(o=>o(x(t)));e.detectorPromise=r;let s,u=new Promise((o,h)=>{s=setTimeout(()=>{r.then(S=>S.destroy(),()=>{}),h(new Error(`detector preload exceeded ${X} ms`))},X)}),d=Promise.race([r,u]).then(o=>e.detectorPromise!==r?(o.destroy(),e.status):(e.detector=o,A(e,"ready"),"ready"),o=>(e.detectorPromise===r&&(e.detectorPromise=null,e.detector=null,A(e,"failed"),console.warn("[@sekyro/web] face-detector preload failed:",o)),e.status)).finally(()=>clearTimeout(s));return e.promise=d,e.scheduled?.settle(d),d}function Le(e={}){if(!ae())return Promise.resolve("idle");let t=g(e.assetBaseUrl),r=Y(t);return e.respectSaveData===!0&&ce()?Promise.resolve(r.status):(r.status==="loading"||r.status==="ready")&&r.promise!==null?r.promise:e.idle===!0?r.scheduled?.promise??ue(r,t):I(r,t)}function Ee(e){return p().get(g(e))?.status??"idle"}function ye(e,t){let r=Y(g(t));return r.listeners.add(e),()=>{r.listeners.delete(e)}}function be(e){let t=p().get(g(e));t!==void 0&&(t.scheduled?.settle("idle"),t.detector?.destroy(),t.detector=null,t.detectorPromise=null,t.promise=null,A(t,"idle"))}function le(e){return{get tier(){return e.tier},get fallbackReason(){return e.fallbackReason},detect:(...t)=>e.detect(...t),destroy:()=>{}}}function ee(e){let t=g(e),r=p().get(t);if(!(r===void 0||r.detector===null&&r.detectorPromise===null&&r.scheduled===null))return async()=>{r.scheduled!==null&&I(r,t);let s=r.promise;for(;r.detector===null&&s!==null&&(await s,r.promise!==s);)s=r.promise;return r.detector!==null?le(r.detector):v({v3AssetBaseUrl:t})}}function fe(e){switch(e){case"fcv3.no_face":case"fcv3.center_face":case"fcv3.straighten":return"center";case"fcv3.come_closer":return"closer";case"fcv3.move_back":return"farther";case"fcv3.more_light":case"fcv3.too_bright":return"light";case"fcv3.hold_still":case"fcv3.steady_camera":return"still";case"fcv3.hold_upright":return"upright";default:return null}}function pe(e){switch(e){case"preflight":case"acquiring":return"starting";case"positioning":return"gating";default:return e}}function te(e){switch(e){case"permission":case"notfound":case"inuse":case"insecure":case"unsupported":return e;default:{let t=e;return"generic"}}}function me(e,t,r){if(r===void 0)return{kind:te(e),retryable:t};let s=N(r.name);return{kind:te(e),retryable:t,detail:{...s!==void 0?{name:s}:{},phase:r.phase,engineKind:e}}}function ve(e,t={},r,s=()=>"self",u=()=>{}){let f=t.now??(()=>performance.now()),d=t.canChooseFacing??j,o="user",h=!1,S=n=>(n==="environment"&&!h&&(h=!0,console.warn('[@sekyro/web] facing "environment" ignored: this capture is a self capture (the person films themselves), which uses the front camera only. The back camera is for assisted capture, set in the flow.')),"user"),D=!1,m=s(),c=Z(),H=!G(),U=t.engineOptions,re=U?.createDetector===void 0&&U?.createWorker===void 0?{createDetector:()=>{let n=ee(e.assetBaseUrl);return n!==void 0?n():v({v3AssetBaseUrl:e.assetBaseUrl})}}:{},B={video:e.video,mode:H?"photo":"clip",rankKeyframes:r,facingMode:void 0,v3AssetBaseUrl:e.assetBaseUrl,screenRamp:()=>m==="self"&&c.count("ramp")>0?u():void 0,...t.engineOptions??{},...re},i=t.createEngine?.(B)??new Q(B),C="idle",L=null,E=0,k=!1,M="full",y=null,b=null,_=0,F=0,K=()=>{e.video.videoWidth>0&&e.video.videoHeight>0&&(_=e.video.videoWidth,F=e.video.videoHeight)},V=J({enabled:e.keepScreenAwake!==!1}),z=n=>{C=n,V.setActive(n==="starting"||n==="gating"||n==="recording"),c.emit("state",n)},O=()=>c.emit("gate",{progress:E,hint:L,faceDetected:k}),W=()=>{let n=i.animations??"full";n!==M&&(M=n,c.emit("profile",{animations:M}))},ne=[i.on("statechange",({state:n})=>{let a=pe(n);a==="starting"&&C!=="starting"&&(L=null,E=0,k=!1,y=null,b=null,_=0,F=0),z(a),W(),a==="recording"&&(K(),y=f(),L="hold",E=1,O())}),i.on("checks",n=>{K(),E=n.progress,k=n.factors.presence>0,O(),W()}),i.on("guidance",({key:n})=>{L=fe(n),O()}),i.on("frozen",({previewDataUrl:n})=>{b=f(),c.emit("frozen",{previewDataUrl:n})}),i.on("ramp",n=>c.emit("ramp",n)),i.on("artifacts",n=>{let a=q(),l=y!==null&&b!==null?Math.max(0,Math.round(b-y)):void 0;c.emit("captured",{keyframe:n.keyframe,...n.clip!==void 0?{clip:n.clip}:{},...n.clipMimeType!==void 0?{clipMime:n.clipMimeType}:{},width:e.video.videoWidth||_,height:e.video.videoHeight||F,...l!==void 0?{clipMs:l}:{},captureChannel:a==="desktop"?"desktop":"mobile",formFactor:a,...H?{degraded:"NO_RECORDER"}:{},engine:"v3",facingMode:i.facingMode,mode:m,...n.timing,...n.screenRamp!==void 0?{screenRamp:n.screenRamp}:{},...n.provenance!==void 0?{provenance:n.provenance}:{}})}),i.on("error",({kind:n,retryable:a,detail:l})=>{c.emit("error",me(n,a,l))})];return{handle:{get state(){return C},get captureMode(){return s()},get facingMode(){return i.facingMode??o},on:(n,a)=>c.on(n,a),start:n=>{if(m=s(),m==="self")return S(e.facing),S(n?.facing),D=!0,o="user",i.start({facingMode:"user"});let a=!D;D=!0;let l=n?.facing??(a?e.facing:void 0),R=w=>(o=w,i.start({facingMode:w}));return l!==void 0?R(l):a?d().then(w=>R(w?"environment":"user"),()=>R("user")):i.start({})},retry:()=>i.retry(),switchCamera:()=>s()!=="assisted"?!1:(m="assisted",o=o==="user"?"environment":"user",i.switchCamera(),!0),destroy:()=>{for(let n of ne)n();V.setActive(!1),i.destroy(),c.clear()}},setFlowState:n=>{C!==n&&z(n)}}}function Te(e){return ve(e).handle}export{se as a,X as b,Se as c,Ce as d,Le as e,Ee as f,ye as g,be as h,ee as i,fe as j,pe as k,te as l,me as m,ve as n,Te as o};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{A as be,C as T,D as Z,h as K,i as X,j as fe,k as he,m as Se,n as ee,p as Q,q as te,s as ge,t as ye}from"./chunk-5ZKQHFFW.js";import{c as le,d as pe,e as me}from"./chunk-FPXL63KZ.js";import{c as F,h as $,i as Ce}from"./chunk-NJML6FMD.js";var Pe=["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"];var je=["carte_identite","passport","residence_permit"];function Ye(e,t){let n=e.byIssuer?.[t]??e.default;return je.filter(o=>n==="*"||n.includes(o))}function Ht(e,t=Pe){return[...new Set([...t,...Object.keys(e.byIssuer??{})])].filter(o=>Ye(e,o).length>0).sort()}function _e(e){if(e.acceptedDocuments)return e.acceptedDocuments;let t=e.acceptedDocumentTypes?.length?[...e.acceptedDocumentTypes]:["carte_identite","passport"];return{default:[],byIssuer:{MR:t}}}var We=640,Qe=new Set(["network_error","timeout","upload_failed","unknown_error","rate_limit_exceeded"]),ke=6,Re=1500,Me={sharpness:1,exposure:1,meanLuma:128},Ee=null;function $e(e,t){try{Ee??(Ee=document.createElement("canvas"));let n=Ee,o=96/Math.max(1,t.width);n.width=Math.max(1,Math.round(t.width*o)),n.height=Math.max(1,Math.round(t.height*o));let r=n.getContext("2d");if(r===null)return Me;r.drawImage(e,t.x,t.y,t.width,t.height,0,0,n.width,n.height);let c=r.getImageData(0,0,n.width,n.height);return{sharpness:pe(c),exposure:me(c),meanLuma:le(c)}}catch{return Me}}async function qe(e,t){let n=e.source;return"convertToBlob"in n?n.convertToBlob({type:"image/jpeg",quality:t}):new Promise((o,r)=>{n.toBlob(c=>c===null?r(new Error("encode failed")):o(c),"image/jpeg",t)})}function Zt(e,t={}){let n=t.now??(()=>performance.now()),o=t.setTimer??((p,i)=>setTimeout(p,i)),r=t.clearTimer??(p=>clearTimeout(p)),c=t.encode??qe,d=t.quality??$e,u=e.tuningVersion??null,m=new Set,b=!1,y=e.video??null,P=null,g=t.grabFrame??null,_=null,w=1e3/ke,k=null,E=null,L=!1,O=!1,A=Number.NEGATIVE_INFINITY,M=null,H=0,N=null,V=null,D=Promise.all([import("./icao-gate-PWBMKRGC.js"),import("./icao-tuning-4GGVX6B4.js"),import("./create-portrait-capture-MOS2D7CL.js"),import("./landmarker-KB7LVXAU.js"),import("./background-monitor-A7FKJOAG.js")]).then(async([p,i,s,a,l])=>{let h=i.resolveIcaoTuning(e.tuning,e.tuningVersion??void 0);h.background.required&&(E=l.createBackgroundMonitor({tuning:h.backgroundCheck,assetBaseUrl:e.assetBaseUrl??"/models-v3",...t.createSegmenter!==void 0?{createSegmenter:t.createSegmenter}:{},now:n})),P=p.createIcaoGate(h,{policy:e.policy??"reject"}),g??(g=s.defaultGrabber()),_=s.observe,w=1e3/Math.min(ke,h.cadenceHz);let C=(t.createLandmarker??a.createFaceLandmarker)(e.assetBaseUrl??"/models-v3"),S=await new Promise((f,R)=>{let v=setTimeout(()=>{R(new Error("landmarker init timeout")),C.then(I=>I.close(),()=>{})},a.LANDMARKER_INIT_TIMEOUT_MS);C.then(I=>{clearTimeout(v),f(I)},I=>{clearTimeout(v),R(I)})});b?S.close():k=S}).catch(()=>{L=!0}),j=p=>{for(let i of m)i({holding:O||L,update:p})},B=()=>{if(M=null,!(b||k===null||P===null||g===null||_===null||y===null)){if(n()-A>Re){j(null);return}try{let p=g(y,We);if(p!==null){let i=Math.max(n(),H+1);H=i;let s=k.detect(p.source,i),a=y.videoWidth||p.width,l=y.videoHeight||p.height,h=_(s,p,a,l);h.geometry!==null&&E!==null&&(h.backgroundCheck=E.measure(p,h.geometry.box,a,l));let C=P.push(h,n());O=C.ready,j(C)}}catch{}M=o(B,w)}},Y=()=>{let p=n()-A>Re;A=n(),p&&(P?.reset(),O=!1,N=null,V=null),M===null&&k!==null&&!b&&(M=o(B,0))},J=()=>{let p=g===null||y===null?null:g(y,null);if(p===null||P===null||Math.max(p.width,p.height)<e.still.minLongSidePx)return Promise.resolve(null);let i=P.summary();return c(p,e.still.jpegQuality).then(s=>({image:s,width:p.width,height:p.height,gate:i}),()=>null)},W=null;return{engineOptions:{measureQuality:(p,i)=>{y=p,Y();let s=d(p,i);return O||L?s:{...s,sharpness:0}},telemetry:p=>{if(p.type!=="fired"||b)return;N=J();let i=W;i!==null&&N.then(s=>s===null?void 0:i(s).catch(()=>{})),O=!1,M!==null&&r(M),M=null,A=Number.NEGATIVE_INFINITY}},decorate:p=>{let i=new WeakMap,s=new Map,a=S=>{let f=i.get(S);return f===void 0&&(f=(async()=>{let R=await ye(p,"image","image/jpeg",S.image.size,{engine:"portrait"});return await p.uploadToSpaces(R.uploadUrl,S.image,"image/jpeg"),(await p.completeMedia(R.key)).key})(),f.catch(()=>i.delete(S)),i.set(S,f)),f};W=a;let l=async S=>{let f;try{f=await a(S)}catch(R){let v=R?.code;if(typeof v=="string"&&Qe.has(v))throw R;return null}return{media:{portrait:f},gate:Ce(S.gate),...u!==null?{tuningVersion:u}:{}}},h=p.submitCheck.bind(p),C=(async(S,f,R)=>{if(S!=="liveness")return h(S,f,R);let v=R?.idempotencyKey,I=v===void 0?void 0:s.get(v);if(I===void 0){let ue=N;I=ue===null?Promise.resolve(null):ue.then(de=>de===null?null:l(de)),v!==void 0&&(s.set(v,I),I.catch(()=>s.delete(v)))}let z=await I;if(z===null)return h("liveness",f,R);let Ze=await h("liveness",{...f,portraitIcao:z},R);return V=z,Ze});return new Proxy(p,{get(S,f){if(f==="submitCheck")return C;let R=Reflect.get(S,f);return typeof R=="function"?R.bind(S):R}})},onGate:p=>(m.add(p),()=>m.delete(p)),lastPortraitInput:()=>V,destroy:()=>{b=!0,N=null,V=null,M!==null&&r(M),M=null,m.clear(),D.then(()=>{k?.close(),k=null,E?.close(),E=null})}}}function Ae(e){return e.idNumberBound??e.nniBound}function ve(e){return e===void 0?void 0:e.idNumberFromDocument??e.nniFromDocument}function Ie(e){let t=e.idNumberMasked??e.nniMasked;return typeof t=="string"&&t!==""?t:void 0}var Te=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",sandbox_nni_not_seeded:"sandbox_id_number_not_seeded",missing_nni:"missing_id_number",registry_needs_nni_source:"registry_needs_id_number_source"}),Je=new Map(Object.entries(Te)),Wt=new Map(Object.entries(Te).map(([e,t])=>[t,e]));function we(e){return Je.get(e)??e}var ze=new Set(["phone_otp","email_otp","national_eid","document","nfc","population_registry","supplied_identity","summary_confirm","liveness","portrait","face_match","aml_screening","face_dedup","age_estimation"]),Xe=new Set(["supplied_identity","aml_screening","face_dedup","age_estimation"]),ie=["document","population_registry","national_eid"],oe=["phone_otp","email_otp"],Ne={identity_method:ie,contact:oe},et=["population_registry","document"],Le="platform_unsupported",tt=new Set(["prefilled","user_entered","prefilled_or_entered"]),nt={phone_otp:"contact",email_otp:"contact",eid_auth:"identity",doc_ocr:"identity",nfc_chip:"identity",population_registry:"identity",liveness:"live_photo",portrait_icao:"live_photo",face_match:"live_photo"};function x(e){return e.section??nt[e.checkType]??null}function re(e,t){let n=e.plan?.choice;if(n===void 0||n.locked)return;let o=n.options.find(r=>r.id!==n.selected&&r.available!==!1&&t.includes(r.service));return o===void 0?void 0:{nodeId:n.nodeId,option:o}}function se(e){let t=e.plan,n=t?.choice;if(t===void 0||n===void 0||n.locked||t.current===null||t.current===n.nodeId||ee(e))return null;let o=Ne[n.kind]??[...ie,...oe],r=n.options.flatMap(u=>u.available===!1||!o.includes(u.service)?[]:[u.nationalEid!=null?{id:u.id,service:u.service,nationalEid:u.nationalEid}:{id:u.id,service:u.service}]),c=t.steps.find(u=>u.id===t.current)?.service,d=n.selected??r.find(u=>u.service===c)?.id??null;return r.some(u=>u.id!==d)?{nodeId:n.nodeId,kind:n.kind,current:d,options:r}:null}function Ve(e){return e==null?[]:e.options.filter(t=>t.id!==e.current)}function it(e){let t=(e.plan?.sections??[]).map(r=>({id:r.id,state:r.state})),n={sessionId:te(e.sessionId),orgName:e.orgName,returning:e.returning===!0,consentRecorded:e.consentRecorded,expiresAt:e.expiresAt,sections:t.map(r=>r.id),progress:t,purpose:e.purpose??"identity"};e.branding!==void 0&&(n.branding=e.branding),e.cameraUnavailableHandled===!0&&(n.cameraUnavailableHandled=!0);let o=se(e);return o!==null&&(n.switchable=o),n}function ot(e){let t={attemptsRemaining:fe(e),attemptsExhausted:e.attemptsExhausted===!0};return e.reason!==void 0&&(t.reason=e.reason),e.retakeHint!==void 0&&(t.retakeHint=e.retakeHint),t}var De={phone_otp:"phone",email_otp:"email"};function rt(e,t){let n=re(e,[t==="phone_otp"?"email_otp":"phone_otp"]);return n===void 0?void 0:De[n.option.service]}function st(e,t,n,o){let r=t.checkType==="email_otp",c=(r?t.emailOtp:t.otp)??{},d=r?t.emailOtp?.emailSource:t.otp?.numberSource,u=d!==void 0&&tt.has(d)?d:r?"prefilled_or_entered":"user_entered",m=typeof c.sentToMasked=="string"&&c.sentToMasked.length>0,b=c.prefilled===!0,y=rt(e,r?"email_otp":"phone_otp"),P={key:t.checkType,context:n,section:x(t),phase:m?"verify":"send",canSwitch:y!==void 0,...o},g=r?{kind:"email_otp",...P,emailSource:u,needsEmail:u!=="prefilled"&&!b}:{kind:"phone_otp",...P,numberSource:u,needsPhone:u!=="prefilled"&&!b,channels:(t.otp?.channels??[]).filter(_=>_==="whatsapp"||_==="sms")};if(y!==void 0&&(g.switchChannel=y),b&&(g.prefilled=!0),m&&(g.sentToMasked=c.sentToMasked),!r&&t.otp?.channel!==void 0&&(g.channel=t.otp.channel),!r&&Array.isArray(t.phoneCountries)&&(g.phoneCountries=t.phoneCountries.filter(_=>typeof _=="string"&&/^[A-Z]{2}$/.test(_))),!r&&Array.isArray(t.phoneRules)){let _=g.phoneCountries??[];g.phoneRules=t.phoneRules.flatMap(w=>{let k=ut(w);return k!==void 0&&_.includes(k.code)?[k]:[]})}return!r&&t.phoneInternational===!0&&(g.phoneInternational=!0),c.expiresAt!==void 0&&(g.codeExpiresAt=c.expiresAt),c.resendAvailableAt!==void 0&&(g.resendAvailableAt=c.resendAvailableAt),g}var at=/^[\d[\]\-|()?:^]{1,64}$/;function ct(e){try{return typeof e=="string"&&at.test(e)&&new RegExp(e)!==null}catch{return!1}}var Oe=e=>typeof e=="number"&&Number.isInteger(e)&&e>=1&&e<=15;function ut(e){let{code:t,dial:n,trunk:o,lengths:r,formats:c}=e??{};if(typeof t!="string"||typeof n!="string"||!/^\d{1,3}$/.test(n)||o!==void 0&&(typeof o!="string"||!/^\d{1,3}$/.test(o))||!Array.isArray(r)||r.length===0||!r.every(Oe))return;let d={code:t,dial:n,lengths:[...r].sort((u,m)=>u-m)};if(o!==void 0&&(d.trunk=o),c!==void 0){if(!(Array.isArray(c)&&c.length<=8&&c.every(m=>ct(m?.leading)&&Array.isArray(m.groups)&&m.groups.every(Oe)&&r.includes(m.groups.reduce((b,y)=>b+y,0)))))return;d.formats=c.map(m=>({leading:m.leading,groups:[...m.groups]}))}return d}function dt(e,t,n,o){let r=Ae(e)===!0?"bound":ve(t)===!0?"document":"typed",c=r==="typed"&&t.state==="input_required"&&t.reason!==void 0&&we(t.reason)==="id_number_recheck",d=Ve(se(e)),u=!o.attemptsExhausted&&d.length===1&&d[0]?.service==="document";return{kind:"registry",key:"registry",context:n,section:x(t),state:t.state==="input_required"?"input_required":"pending",source:r,recheck:c,canUseDocument:u,...o}}function lt(e,t,n,o){let r=[...t.acceptedSides??[]],c={kind:"document",key:"document",context:n,section:x(t),side:r.includes("recto")?"verso":"recto",acceptedSides:r,documents:_e(e),photo:Ge(e.documents),...o};return pt(e)&&(c.ageStepUp=!0),c}function Ge(e,t=!0){let n=e?.source==="upload"||e?.source==="choice"?e.source:"camera",o=e?.sourcePick==="camera"||e?.sourcePick==="upload"?e.sourcePick:null;return{source:n,pick:o,uploadOffered:t&&e?.uploadOffered===!0}}function pt(e){let t=X(e).find(o=>o.checkType==="age_estimation"),n=t?.reason;return t?.state==="failed"&&(n==="age_uncertain"||n==="age_unavailable")}function mt(e){let t=Q(e,"liveness");return t?.state==="passed"||t?.state==="review"}function xe(e,t,n,o,r){let c=t.icao?.report,d=e.portrait,u=r==="capture"?d?.pendingFix??null:null;u!==null&&(r="review");let m=He(e);return{kind:"portrait",key:`portrait:${r}`,context:n,section:x(t),phase:r,report:Array.isArray(c)?c:null,review:t.state==="review",tuning:e.capture?.icao??null,tuningVersion:e.capture?.tuningVersion??null,icao:$(e),retakeOnly:r==="capture"&&t.state==="input_required"&&m===void 0&&e.capture?.livePhoto?.oneCapture===!0&&mt(e),photo:Ge(d,r==="capture"),pendingFix:u,...m!==void 0?{captureMode:m}:{},...d?.reuse?.pending===!0?{reuse:!0}:{},...o}}function He(e){let t=e.portrait?.captureMode;return t==="self"||t==="assisted"||t==="choice"?t:void 0}var ne={minLongSidePx:1280,jpegQuality:.95};function ft(e,t){let n=e.capture?.livePhoto;if(n?.oneCapture!==!0)return null;let o=Q(e,"portrait_icao"),r=n.still??ne;return{icao:t==="liveness"&&$(e)!==null&&He(e)===void 0&&o!==void 0&&o.state==="pending"&&o.reason===void 0,still:{minLongSidePx:r.minLongSidePx??ne.minLongSidePx,jpegQuality:r.jpegQuality??ne.jpegQuality}}}function ht(e,t,n,o){let r=t.eid,c=x(t);if(r===void 0||r.challenge!=="app_code")return{kind:"unsupported",key:"unsupported:eid_auth",context:n,section:c,checkType:"eid_auth",reason:"update_required"};let d=Ve(se(e)),u=d.length===1&&et.includes(d[0]?.service??"")?d[0]:void 0,m=u===void 0?void 0:K[u.service],b=m!==void 0,y={kind:"eid",key:"eid",context:n,section:c,provider:r.provider,providerName:r.providerName,country:r.country,challenge:"app_code",phase:r.awaiting==="code"?"code":"identifier",identifierBound:r.identifierBound===!0,canUseCamera:b,afterPass:r.afterPass==="continue"?"continue":"end",...o};return b&&(y.cameraMethod=m),r.expiresAt!==void 0&&(y.codeExpiresAt=r.expiresAt),r.resendAvailableAt!==void 0&&(y.resendAvailableAt=r.resendAvailableAt),r.resendsRemaining!==void 0&&(y.resendsRemaining=r.resendsRemaining),r.codeAttemptsRemaining!==void 0&&(y.codeAttemptsRemaining=r.codeAttemptsRemaining),y}function St(e,t){if(t.checkType!=="face_match"||t.reason!==void 0)return null;let n=Q(e,"portrait_icao");return n!==void 0&&(n.state==="passed"||n.state==="review")?n:null}function gt(e){return X(e).filter(t=>t.state==="failed").pop()?.attemptsExhausted===!0}function yt(e,t){let n=e.failureReason,o;n===Le?o="platform_unsupported":e.status==="expired"?o="expired":e.status==="review_pending"?o="review":e.status==="completed"&&e.outcome==="approved"?o="approved":e.status==="completed"&&e.outcome==="review"?o="review":n==="device_cooldown"?o="cooldown":n!==void 0?o="policy_stop":gt(e)?o="attempts_exhausted":o="rejected";let r=o==="platform_unsupported"?{sessionId:te(e.sessionId),status:"unavailable"}:ge(e,{autoRetry:!1}),c={kind:"result",key:"result",context:t,section:null,display:o,result:r};return n!==void 0&&(c.failureReason=n),e.retryAfter!==void 0&&(c.retryAfter=e.retryAfter),c}function bt(e,t,n){let o=e.identitySummary;if(o==null)return null;let r={kind:"identity_summary",key:"identity_summary",context:t,section:n??"identity",summaryKind:o.kind==="partial"?"partial":o.kind??"full",source:o.source,portraitAvailable:o.portrait?.available===!0,retakeAvailable:o.retakeAvailable===!0};for(let d of Ct){let u=o[d];typeof u=="string"&&u!==""&&(r[d]=u)}let c=Ie(o);return c!==void 0&&(r.idNumberMasked=c,r.nniMasked=c),r}var Ct=["fullName","birthDate","birthYear","nationality","documentType","documentNumberMasked","expiryDate","retakeTarget"];function G(e,t,n,o){return{kind:"unsupported",key:`unsupported:${n}`,context:e,section:t,checkType:n,reason:o}}function Pt(e){return e.kind==="contact"?"contact":(e.kind==="identity_method","identity")}function _t(e,t){let n=Ne[e.kind]??[...ie,...oe],o=Pt(e),r=e.options.flatMap(d=>{if(d.available===!1||!n.includes(d.service))return[];let u={id:d.id,service:d.service};d.nationalEid!=null&&(u.nationalEid=d.nationalEid);let m=(d.channels??[]).filter(b=>b==="whatsapp"||b==="sms");return d.service==="phone_otp"&&m.length>0&&(u.channels=m),[u]});if(r.length===0){let d=e.options.length>0&&e.options.every(u=>u.service==="nfc");return G(t,o,"choice",d?"platform_unsupported":"update_required")}let c={nodeId:e.nodeId,kind:e.kind,selected:e.selected,options:r};if(e.kind==="identity_method"){let d={kind:"method",key:"method",context:t,section:o,options:r.map(m=>K[m.service]),choice:c},u=r.find(m=>m.nationalEid!==void 0)?.nationalEid;return u!==void 0&&(d.nationalEid=u),d}return e.kind==="contact"?{kind:"contact_choice",key:"contact_choice",context:t,section:o,options:r.map(d=>De[d.service]),selected:null,locked:!1,choice:c}:{kind:"choice",key:`choice:${e.nodeId}`,context:t,section:o,choice:c}}function q(e,t={}){let n=it(e);if(ee(e)||e.failureReason===Le)return yt(e,n);let o=e.plan;if(o===void 0||!Array.isArray(o.sections))return G(n,null,"plan","update_required");let r=he(e);if(r!==null)return _t(r,n);let c=o.current===null?void 0:o.steps.find(P=>P.id===o.current),d=P=>{let g={kind:"processing",key:"processing",context:n,section:P!==void 0?x(P):o.sections.find(_=>_.state==="current")?.id??null,stalled:!1};return typeof P?.service=="string"&&P.service!==""&&(g.service=P.service),g};if(o.current===null)return d(o.steps.find(P=>P.state==="processing"));if(c===void 0)return G(n,null,"step","update_required");if(!ze.has(c.service))return c.interaction==="server"?d(c):G(n,x(c),c.service,"update_required");if(Xe.has(c.service)||!Se(c))return d(c);let u=c,m=ot(u),b=u.checkType,y=x(u);switch(b){case"phone_otp":case"email_otp":return st(e,u,n,m);case"population_registry":return dt(e,u,n,m);case"eid_auth":return ht(e,u,n,m);case"doc_ocr":return lt(e,u,n,m);case"identity_confirm":return bt(e,n,y)??d(u);case"portrait_icao":return xe(e,u,n,m,"capture");case"liveness":case"face_match":{let P=St(e,u);if(P!==null)return xe(e,P,n,m,"match");let g=u.requiresMobile===!0,_=$(e);return g&&t.isMobile===!1?{kind:"mobile_required",key:"mobile_required",context:n,section:y,checkType:b}:{kind:"liveness",key:"biometric",context:n,section:y,mode:b==="face_match"?"selfie":"liveness",requiresMobile:g,instructions:_===null?"standard":"icao",icao:_,livePhoto:ft(e,b),...m}}case"nfc_chip":return G(n,y,b,"platform_unsupported");default:return G(n,y,b,"update_required")}}var kt=/^[A-Z0-9][A-Z0-9 -]{0,39}$/,Rt=Object.freeze({normalize:e=>e.trim().toUpperCase().replace(/\s+/g," "),check:e=>kt.test(e),registrySources:Object.freeze([]),describe:"number must be 1 to 40 letters, digits, spaces or hyphens"});function Mt(e){return typeof e=="string"&&/^\d{10}$/.test(e)&&Number(e)%97===1}var Et=Object.freeze({normalize:e=>e.trim(),check:e=>Mt(e),registrySources:Object.freeze(["MR.anrpts"]),describe:"number must be the 10-digit Mauritanian national ID number with a valid check digit"}),At=Object.freeze({"MR:national_id":Et});function ae(e,t){return At[`${e.toUpperCase()}:${t}`]??Rt}var vt=Object.freeze({MRT:"MR"});function Be(e,t){let n=e.trim().toUpperCase();return ae(vt[n]??n,t)}function Ue(e){let t=Be(e.issuingCountry,e.type);return t.check(t.normalize(e.number))}function Fe(e){return ae("MR","national_id").check(e)}function ce(e){let t="";for(let n of e){let o=n.codePointAt(0)??0;o>=1632&&o<=1641?t+=String(o-1632):o>=1776&&o<=1785?t+=String(o-1776):n!==" "&&n!=="-"&&n!==" "&&(t+=n)}return t}var It=[1e3,2e3,4e3,8e3,15e3],Tt=3e4,wt=/^\+[1-9]\d{6,14}$/,Ot=/^\d{6}$/,xt=/^\d{6}$/,Nt=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Ke=new Set(["session_not_active","check_not_found","check_already_finalized","check_out_of_order","identity_confirm_required","identity_confirm_locked","choice_locked","choice_option_unavailable","choice_not_found","step_not_on_path","check_not_active"]),Lt=new Set(["network_error","timeout","upload_failed","unknown_error","rate_limit_exceeded"]);function ln(e){let t=!1,n=null,o="",r=!1,c=!1,d=!1,u={},m={},b=new Set,y=!1,P=null,g="idle",_=new Map,w=new Map,k=(i,s,a)=>{let l=`${i}.${s}`,h=_.get(l);if(h!==void 0)return h;let C=w.get(i),S=(C===void 0?a():C.then(a)).finally(()=>{_.delete(l)});_.set(l,S);let f=S.then(()=>{},()=>{});return w.set(i,f),f.then(()=>{w.get(i)===f&&w.delete(i)}),S},E=async(i,s,a)=>{await e.ensureConsent();let l;try{l=await be(e.runtime,s)}catch(C){if(C instanceof F&&Ke.has(C.code)){await e.refreshView();return}throw C}if(a?.(l),e.destroyed())return;let h=l;h.plan!==void 0&&e.setView!==void 0?e.setView(h):await e.refreshView()},L=async i=>{await e.ensureConsent();let s;try{try{s=await i(e.runtime.client)}catch(a){if(!(a instanceof F)||a.code!=="consent_required")throw a;await e.runtime.ensureConsent({force:!0}),s=await i(e.runtime.client)}}catch(a){if(a instanceof F&&Ke.has(a.code)){await e.refreshView();return}throw a}e.destroyed()||(s!==void 0&&e.setView!==void 0?e.setView(s):await e.refreshView())},O=(i,s)=>k("choice",`${i}:${s}`,()=>L(a=>a.choose(i,s))),A=(i,s)=>i.options.some(a=>a.id===s)?O(i.nodeId,s):Promise.reject(new RangeError(`option ${String(s)} is not offered`)),M=(i,s)=>{let a=e.currentView(),l=a===null?void 0:re(a,i);return l===void 0?Promise.reject(new RangeError(`the ${s} is not offered`)):O(l.nodeId,l.option.id)},H=i=>k("identity",i,()=>L(s=>s.confirmIdentity===void 0?Promise.reject(new Error("identity confirmation is not available in this build")):s.confirmIdentity(i))),N=(i,s)=>{let a=i.kind,l=a==="phone_otp",h=l?"phone":"email",C={action:"send"};if(l?i.needsPhone:i.needsEmail){let S=s[h]??m[a],f=l?S?.replace(/[\s().-]/g,""):S?.trim();if(f!==void 0||i.phase!=="verify"){if(f===void 0||!(l?wt:Nt).test(f))return Promise.reject(l?new T("phone","format"):new Z("email","format"));C[h]=f}}if(l){let S=i.channels,f=s.channel??(S.length===1?S[0]:void 0);if(S.length>0){if(f===void 0)return Promise.reject(new Z("channel","required"));if(!S.includes(f))return Promise.reject(new Z("channel","unavailable"))}f!==void 0&&(C.channel=f),C.phoneRules=1}return k(a,"send",()=>E(a,(S,f)=>S.submitCheck(a,C,{idempotencyKey:f}),S=>{Vt(S,a)||(u[a]=e.now(),C[h]!==void 0&&(m[a]=C[h]))}))},V=(i,s)=>Ot.test(s)?k(i,"verify",()=>E(i,(a,l)=>a.submitCheck(i,{action:"verify",code:s},{idempotencyKey:l}))):Promise.reject(new T("code","format")),D=(i,s)=>k("eid_auth",i,()=>E("eid_auth",(a,l)=>a.submitCheck("eid_auth",s,{idempotencyKey:l}))),j=(i,s)=>{if(i.identifierBound)return D("start",{action:"start"});let a=ce(s??"");if(i.country==="MR"){if(!/^\d{10}$/.test(a))return Promise.reject(new T("nni","format"));if(!Fe(a))return Promise.reject(new T("nni","check_digit"))}else if(a==="")return Promise.reject(new T("nni","format"));return D("start",{action:"start",identifier:a})},B=(i,s,a)=>{if(i.source!=="typed")return Promise.reject(new RangeError("this session already holds the ID number"));let l=ce(s);return/^\d{10}$/.test(l)?Ue({type:"national_id",issuingCountry:"MR",number:l})?k("population_registry","submitIdNumber",()=>E("population_registry",(h,C)=>h.submitCheck("population_registry",{idNumber:l,nni:l},{idempotencyKey:C}),()=>{P=`\u2022\u2022\u2022\u2022\u2022\u2022${l.slice(-4)}`})):Promise.reject(new T(a,"check_digit")):Promise.reject(new T(a,"format"))},Y=i=>{switch(i.kind){case"phone_otp":case"email_otp":{let s={...i,send:(l={})=>N(i,l),verify:l=>V(i.kind,l),switchTo:()=>i.canSwitch&&i.switchChannel!==void 0?M([i.switchChannel==="email"?"email_otp":"phone_otp"],"other contact option"):Promise.reject(new RangeError("this session has no other contact option"))},a=u[i.kind];return s.resendAvailableAt===void 0&&a!==void 0&&(s.resendAvailableAt=new Date(a+Tt).toISOString()),s}case"eid":return{...i,start:s=>j(i,s),verify:s=>xt.test(s)?D("verify",{action:"verify",code:s}):Promise.reject(new T("code","format")),resend:()=>i.resendsRemaining===0?Promise.reject(new RangeError("no new code can be sent for this session")):D("resend",{action:"resend"}),useCamera:()=>i.canUseCamera&&i.cameraMethod!==void 0?M(i.cameraMethod==="document_photo"?["document"]:["population_registry"],"camera path"):Promise.reject(new RangeError("the camera path is not offered"))};case"method":return{...i,select:s=>{let a=i.choice.options.find(l=>K[l.service]===s);return a!==void 0?A(i.choice,a.id):Promise.reject(new RangeError(`method ${String(s)} is not offered`))},choose:s=>A(i.choice,s)};case"choice":return{...i,choose:s=>A(i.choice,s)};case"registry":return{...i,submitIdNumber:s=>B(i,s,"idNumber"),submitNni:s=>B(i,s,"nni"),confirm:()=>k("population_registry","confirm",()=>E("population_registry",(s,a)=>s.submitCheck("population_registry",{},{idempotencyKey:a}))),useDocument:()=>i.canUseDocument?M(["document"],"document method"):Promise.reject(new RangeError("the document method is not offered"))};case"document":return e.bindDocument!==void 0?e.bindDocument(i,p):{...i,issuer:null,documentType:null,captureSide:null,selectDocument:()=>{throw new Error("document capture is not available in this build")},capture:()=>{throw new Error("document capture is not available in this build")},uploadDocument:()=>Promise.reject(new Error("document upload is not available in this build"))};case"portrait":return e.bindPortrait!==void 0?e.bindPortrait(i,p):{...i,uploadFailed:!1,resubmit:()=>Promise.resolve(),capture:()=>{throw new Error("portrait capture is not available in this build")},uploadPortrait:()=>Promise.reject(new Error("portrait upload is not available in this build")),confirmFix:()=>Promise.reject(new Error("portrait review is not available in this build"))};case"contact_choice":return{...i,select:s=>{let a=s==="phone"?"phone_otp":s==="email"?"email_otp":void 0,l=i.choice.options.find(h=>h.service===a);return l!==void 0?A(i.choice,l.id):Promise.reject(new RangeError(`contact ${String(s)} is not offered`))},choose:s=>A(i.choice,s)};case"identity_summary":return{...i,...i.idNumberMasked===void 0&&i.summaryKind==="partial"&&P!==null?{idNumberMasked:P,nniMasked:P}:{},portrait:async()=>{let s=e.runtime.client;if(!i.portraitAvailable||s.identityPortrait===void 0)return null;try{return await s.identityPortrait()}catch{return null}},confirm:()=>H("confirm"),retake:()=>i.retakeAvailable?H("retake"):Promise.reject(new RangeError("no retake is left"))};case"liveness":return{...i,capture:s=>e.liveness(s),onLivePhoto:s=>i.livePhoto?.icao===!0&&e.onLivePhoto!==void 0?e.onLivePhoto(s):()=>{}};case"mobile_required":case"processing":return{...i,refresh:async()=>{r=!1,await e.refreshView()}};case"unsupported":case"result":return{...i};default:{let s=i;throw new Error(`runner: unhandled step ${JSON.stringify(s)}`)}}},J=async()=>{if(!c){c=!0;try{for(let i of It){if(await e.sleep(i),!t||e.destroyed())return;let s=await e.refreshView().catch(()=>null);if(s!==null&&q(s,{isMobile:e.isMobile()}).kind!=="processing")return}r=!0,p()}finally{c=!1}}},W=i=>{if(i.kind!=="liveness"||i.mode!=="selfie")return null;let s={kind:"processing",key:"processing",context:i.context,section:i.section,stalled:!1};if(g==="inflight")return s;if(!y||g==="done")return null;let a=e.keptFaceKey?.()??null;return a===null?null:(g="inflight",E("face_match",(l,h)=>l.submitCheck("face_match",{imageKey:a},{idempotencyKey:h}),()=>{g="done"}).then(()=>{g==="inflight"&&(g="done",p())},()=>{g="done",p()}),s)},U=(i,s=!1)=>{if(!t||e.destroyed()||e.chainBusy())return;let a=q(i,{isMobile:e.isMobile()});a.kind==="registry"&&a.recheck&&(y=!0,g="idle"),a=W(a)??a,a.kind==="processing"?a.stalled=r:r=!1;let l=Y(a),h=a.kind==="result"?void 0:a.context.switchable,C=h===void 0?l:{...l,chooseOption:f=>A({nodeId:h.nodeId,kind:h.kind,selected:h.current,options:h.options},f)},S=JSON.stringify(C);a.kind==="registry"&&a.source==="document"&&a.state==="pending"&&!b.has("registry")&&(b.add("registry"),C.confirm().catch(f=>{(!(f instanceof F)||Lt.has(f.code))&&b.delete("registry")})),!(!s&&S===o)&&(o=S,n=C,e.emitStep(C),a.kind==="processing"&&!r&&g!=="inflight"&&J(),a.kind==="result"&&!d&&(d=!0,e.emitResult(a.result)))};function p(){let i=e.currentView();i!==null&&U(i,!0)}return{run:async()=>{if(e.destroyed())throw new Error("verification destroyed");t=!0;let i=await e.ensureView();return n===null&&U(i),n??Y(q(i,{isMobile:e.isMobile()}))},current:()=>n,onView:i=>U(i),onChainIdle:()=>{let i=e.currentView();i!==null&&U(i)},republish:p,submit:E}}function Vt(e,t){let n=e,o=n?.plan?.steps??n?.steps;return Array.isArray(o)?o.some(r=>r.checkType===t&&typeof r.reason=="string"):!1}export{Ye as a,Ht as b,ke as c,Re as d,Zt as e,He as f,q as g,It as h,Tt as i,ln as j};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var m="0.1.0-rc.20";var T=/FBAN|FBAV|FB_IAB|FBIOS|MessengerForiOS|Instagram|WhatsApp|musical_ly|BytedanceWebview|TikTok|Snapchat|\bLine\/|LinkedInApp|Pinterest|MicroMessenger|; wv\)/i;function p(t){let e=t??(typeof navigator>"u"?"":String(navigator.userAgent??""));return T.test(e)}var y="sekyro.did",I=1e4,v=()=>globalThis.process?.versions?.node,h;function b(){let t=globalThis.crypto;try{if(typeof t?.randomUUID=="function")return t.randomUUID()}catch{}try{if(typeof t?.getRandomValues=="function"){let e=t.getRandomValues(new Uint8Array(16));return Array.from(e,r=>r.toString(16).padStart(2,"0")).join("")}}catch{}}function w(){try{let t=localStorage.getItem(y);if(t)return t;let e=b();return e!==void 0&&localStorage.setItem(y,e),e}catch{return h??(h=b()),h}}async function P(){let t=globalThis.crypto?.subtle;if(!t)return"";let e=navigator,r=JSON.stringify([e.userAgent,e.platform,e.hardwareConcurrency??null,e.deviceMemory??null,e.maxTouchPoints??0,screen.width,screen.height,screen.colorDepth,globalThis.devicePixelRatio??1,Intl.DateTimeFormat().resolvedOptions().timeZone,e.languages?.join(",")??e.language]),i=await t.digest("SHA-256",new TextEncoder().encode(r));return Array.from(new Uint8Array(i),o=>o.toString(16).padStart(2,"0")).join("").slice(0,32)}function k(t){let e=new TextEncoder().encode(t),r="";for(let i of e)r+=String.fromCharCode(i);return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function x(t){let e,r,i,o,a,l,u=()=>l?.readyState==="live",_=()=>{a!==void 0||!globalThis.crypto?.subtle||v()||u()||(a=Promise.race([import("./print-AYSCRSZB.js"),new Promise(n=>setTimeout(n,I))]).then(n=>n?.computePrint(u)).then(n=>{n==="busy"?a=void 0:o=n}).catch(()=>{}))};return{timezone(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone?.slice(0,64)||void 0}catch{return}},noteCameraLabel(n){n&&(e=n.slice(0,128))},noteCamera(n){r=n},noteCameraTrack(n){l=n},async deviceHeader(){try{i??(i=P().catch(()=>""));let n=[];navigator.webdriver&&n.push("webdriver"),/HeadlessChrome/.test(navigator.userAgent)&&n.push("headless");let g=await i,f=w(),S={v:1,platform:"web",sdk:t.sdk.slice(0,64),ids:[...f?[{kind:"web_local",value:f.slice(0,128)}]:[],...g?[{kind:"web_fp",value:g}]:[]],screen:{w:screen.width,h:screen.height,dpr:globalThis.devicePixelRatio??1},...e?{cameraLabel:e}:{},...n.length?{signals:n}:{},...o?{print:{v:2,...o,...r?{camera:r}:{}}}:{},...p()?{inApp:!0}:{}},C=k(JSON.stringify(S));return _(),C}catch{return}},printReady(){return a??Promise.resolve()}}}var s=Symbol.for("sekyro.web.clientContext"),c=globalThis,d=c[s]??(c[s]=x({sdk:`@sekyro/web@${m}`}));function N(t){try{let e=t.getVideoTracks?.()[0];if(e){if(d.noteCameraLabel(e.label),d.noteCameraTrack(e),v())return;import("./camera-trait-45MJTW4K.js").then(r=>r.noteCameraTrait(e,d)).catch(()=>{})}}catch{}}export{m as a,p as b,d as c,N as d};
|