@sekyro/web 0.1.0-rc.3 → 0.1.0-rc.30
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 +427 -0
- package/LICENSE +25 -16
- package/README.md +150 -62
- package/THIRD-PARTY-NOTICES.txt +154 -0
- package/dist/background-monitor-A7FKJOAG.js +1 -0
- package/dist/barcode-detect-C5IOXMKI.js +1 -0
- package/dist/camera-trait-V4UAOPIQ.js +1 -0
- package/dist/capture-constraints-CVqpMNGA.d.cts +48 -0
- package/dist/capture-constraints-CVqpMNGA.d.ts +48 -0
- package/dist/capture-session-doc-ESEZJBQM.js +1 -0
- package/dist/{capture-session-v3-CvIfcwST.d.ts → capture-session-v3-CTQL6eFd.d.cts} +259 -13
- package/dist/{capture-session-v3-COIO_F2w.d.cts → capture-session-v3-DHlOE6cS.d.ts} +259 -13
- package/dist/challenge-frame-YAQJ5YMB.js +1 -0
- package/dist/chunk-2LDOXGY3.js +1 -0
- package/dist/chunk-33KKMPJ5.js +1 -0
- package/dist/chunk-3LMJ4335.js +1 -0
- package/dist/chunk-53POX7U4.js +1 -0
- package/dist/chunk-7252SFZ6.js +1 -0
- package/dist/chunk-7QZWBDI5.js +1 -0
- package/dist/chunk-A7QFTU6M.js +1 -0
- package/dist/chunk-CJHMFPL6.js +1 -0
- package/dist/chunk-CMXN4SOZ.js +1 -0
- package/dist/chunk-CPUECYAJ.js +1 -0
- package/dist/chunk-DFTCAWMP.js +1 -0
- package/dist/chunk-DK5YPBDQ.js +1 -0
- package/dist/chunk-FPXL63KZ.js +1 -0
- package/dist/chunk-FSSMUAKC.js +1 -0
- package/dist/chunk-G6LKLN4U.js +1 -0
- package/dist/chunk-GFJATPUR.js +1 -0
- package/dist/chunk-GI3UFGRQ.js +1 -0
- package/dist/chunk-JLVZ35QK.js +2 -0
- package/dist/chunk-KA43AAM7.js +1 -0
- package/dist/chunk-KXFHVAYQ.js +1 -0
- package/dist/chunk-ODI4A5K4.js +1 -0
- package/dist/chunk-OEQJ62CC.js +3 -0
- package/dist/chunk-POIQGEZM.js +1 -0
- package/dist/chunk-RI3E7GBN.js +1 -0
- package/dist/chunk-S5BUCUZ4.js +1 -0
- package/dist/chunk-SLKRT74K.js +1 -0
- package/dist/chunk-SMKCBUJL.js +1 -0
- package/dist/chunk-SX7TUC3V.js +1 -0
- package/dist/chunk-TSA6GHUG.js +1 -0
- package/dist/chunk-UTPUHE4J.js +1 -0
- package/dist/chunk-VVUQ4PFU.js +1 -0
- package/dist/chunk-VWGKUQ3C.js +1 -0
- package/dist/chunk-ZKF2XMNX.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/clip-inspect-DLJXVKV6.js +1 -0
- package/dist/core/index.cjs +1 -1606
- 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-V7XCRRDV.js +1 -0
- package/dist/create-portrait-capture-5VGYZUOK.js +1 -0
- package/dist/create-verification-CGBe2yLE.d.cts +3719 -0
- package/dist/create-verification-aoY2QoRx.d.ts +3719 -0
- package/dist/{detect-worker-CKXHlXx9.d.ts → detect-worker-CHqsPJoM.d.cts} +25 -2
- package/dist/{detect-worker-CKXHlXx9.d.cts → detect-worker-CHqsPJoM.d.ts} +25 -2
- package/dist/detector-scanic-SE3CL55N.js +1 -0
- package/dist/icao-gate-DveU9Cr8.d.ts +573 -0
- package/dist/icao-gate-T3BTOKFJ.js +1 -0
- package/dist/icao-gate-xyWB7dz2.d.cts +573 -0
- package/dist/icao-policy-BWu1JLgi.d.cts +80 -0
- package/dist/icao-policy-OOEQDG9_.d.ts +80 -0
- package/dist/icao-tuning-4ETMF53W.js +1 -0
- package/dist/index.cjs +3 -2649
- package/dist/index.d.cts +138 -5
- package/dist/index.d.ts +138 -5
- package/dist/index.js +1 -28
- package/dist/internal/index.cjs +3 -4179
- package/dist/internal/index.d.cts +390 -371
- package/dist/internal/index.d.ts +390 -371
- 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-IXCKR4DB.js +1 -0
- package/dist/popup/index.cjs +1 -76
- package/dist/popup/index.d.cts +9 -3
- package/dist/popup/index.d.ts +9 -3
- package/dist/popup/index.js +1 -11
- package/dist/print-SEWS3VHQ.js +1 -0
- package/dist/scanic-ml-stub-KW7IZHUT.js +1 -0
- package/dist/segmenter-USLNBX65.js +1 -0
- package/dist/types-CezFEXzl.d.cts +2103 -0
- package/dist/types-CezFEXzl.d.ts +2103 -0
- package/dist/upload-file-EGXXM6TQ.js +1 -0
- package/package.json +30 -11
- package/sbom.cdx.json +349 -0
- package/dist/capture-constraints-BujkZcfb.d.cts +0 -21
- package/dist/capture-constraints-BujkZcfb.d.ts +0 -21
- package/dist/chunk-7TC6TOZ4.js +0 -1095
- package/dist/chunk-7TC6TOZ4.js.map +0 -1
- package/dist/chunk-FIXX2AXC.js +0 -864
- package/dist/chunk-FIXX2AXC.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-CP18eq1Q.d.cts +0 -348
- package/dist/create-verification-CswF2As-.d.ts +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
|
+
var f="0.1.0-rc.30";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 h="sekyro.did",P=1e4,v=()=>globalThis.process?.versions?.node,y;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 I(){try{let t=localStorage.getItem(h);if(t)return t;let e=b();return e!==void 0&&localStorage.setItem(h,e),e}catch{return y??(y=b()),y}}async function w(){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(){try{let t=Number(navigator.maxTouchPoints);return Number.isFinite(t)&&t>=0?{touch:Math.min(64,Math.trunc(t))}:{}}catch{return{}}}function x(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 A(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-SEWS3VHQ.js"),new Promise(n=>setTimeout(n,P))]).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=w().catch(()=>""));let n=[];navigator.webdriver&&n.push("webdriver"),/HeadlessChrome/.test(navigator.userAgent)&&n.push("headless");let g=await i,m=I(),S={v:1,platform:"web",sdk:t.sdk.slice(0,64),ids:[...m?[{kind:"web_local",value:m.slice(0,128)}]:[],...g?[{kind:"web_fp",value:g}]:[]],screen:{w:screen.width,h:screen.height,dpr:globalThis.devicePixelRatio??1},...k(),...e?{cameraLabel:e}:{},...n.length?{signals:n}:{},...o?{print:{v:2,...o,...r?{camera:r}:{}}}:{},...p()?{inApp:!0}:{}},C=x(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]=A({sdk:`@sekyro/web@${f}`}));function M(t){try{let e=t.getVideoTracks?.()[0];if(e){if(d.noteCameraLabel(e.label),d.noteCameraTrack(e),v())return;import("./camera-trait-V4UAOPIQ.js").then(r=>r.noteCameraTrait(e,d)).catch(()=>{})}}catch{}}export{f as a,p as b,d as c,M as d};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var l=2e4,m="face_landmarker.task";function d(a){let r=[],n=a.faceLandmarks??[];for(let e=0;e<n.length;e+=1){let o=n[e]??[],c=a.faceBlendshapes?.[e]?.categories,t=null;if(c!==void 0){t={};for(let s of c)t[s.categoryName]=s.score}let i=a.facialTransformationMatrixes?.[e]?.data;r.push({landmarks:o.map(s=>({x:s.x,y:s.y})),blendshapes:t,matrix:i!==void 0&&i.length>=16?[...i]:null})}return r}async function u(a){let r=a.replace(/\/+$/,""),n=await import("@mediapipe/tasks-vision"),e=await n.FilesetResolver.forVisionTasks(r),o=await n.FaceLandmarker.createFromOptions(e,{baseOptions:{modelAssetPath:`${r}/${m}`,delegate:"CPU"},runningMode:"VIDEO",numFaces:2,outputFaceBlendshapes:!0,outputFacialTransformationMatrixes:!0});return{detect(c,t){try{return d(o.detectForVideo(c,t))}catch{return[]}},close(){try{o.close()}catch{}}}}export{l as a,m as b,d as c,u as d};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var b=new Set(["challenge_frame_blocked","challenge_script_blocked","site_key_rejected","challenge_failed","timeout","embedder_opaque"]),i=class extends Error{constructor(n,t){super(`Sekyro challenge failed: ${n}${t!==void 0?` (${t})`:""}`),this.name="ChallengeError",this.code=n,t!==void 0&&(this.detail=t)}},E=3e4,_=12e4,p="sekyro.challenge.",v="position:fixed;width:1px;height:1px;inset-block-start:0;inset-inline-start:0;opacity:0;pointer-events:none;border:0",d=null,g=Promise.resolve();function F(){u(),g=Promise.resolve(),m=!1}function c(){return new i("aborted")}function C(){let e=globalThis.crypto;return e!==void 0&&typeof e.randomUUID=="function"?e.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}function h(e){return new URL(e,document.baseURI).origin}function u(){let e=d;if(e!==null){d=null,window.removeEventListener("message",e.listener),e.iframe.remove();for(let n of e.waiters.values())n.reject(new i("challenge_frame_blocked"));e.waiters.clear()}}function M(e,n){if(n.source!==e.iframe.contentWindow||n.origin!==e.origin)return;let t=n.data;if(typeof t!="object"||t===null)return;let r=t;if(typeof r.type!="string"||!r.type.startsWith(p)||r.v!==1)return;if(r.type==="sekyro.challenge.ready"){e.readyMs??(e.readyMs=Date.now()-e.insertedAt),e.isReady=!0,e.onReady?.();return}if(typeof r.id!="string")return;let a=e.waiters.get(r.id);if(a!==void 0){if(r.type==="sekyro.challenge.token"&&typeof r.token=="string"&&r.token!=="")e.waiters.delete(r.id),a.resolve(r.token);else if(r.type==="sekyro.challenge.error"){e.waiters.delete(r.id);let o=typeof r.code=="string"&&b.has(r.code)?r.code:"challenge_failed",s=typeof r.detail=="string"||typeof r.detail=="number"?String(r.detail).slice(0,32):void 0;a.reject(new i(o,s))}}}function k(e){if(d!==null&&d.url===e)return d;u();let n=document.createElement("iframe");n.setAttribute("title","Security check"),n.setAttribute("aria-hidden","true"),n.setAttribute("tabindex","-1"),n.setAttribute("referrerpolicy","no-referrer"),n.setAttribute("style",v);let t={url:e,origin:h(e),iframe:n,isReady:!1,insertedAt:Date.now(),onReady:null,waiters:new Map,listener:r=>M(t,r)};return window.addEventListener("message",t.listener),n.src=e,document.body.appendChild(n),d=t,t}function A(e,n,t){return e.isReady?Promise.resolve():new Promise((r,a)=>{let o=()=>{clearTimeout(l),t?.removeEventListener("abort",s),e.onReady=null},s=()=>{o(),a(c())},l=setTimeout(()=>{o(),a(new i("challenge_frame_blocked"))},n);t?.addEventListener("abort",s,{once:!0}),e.onReady=()=>{o(),r()}})}async function y(e){if(e.signal?.aborted)throw c();let n=k(e.frameUrl);try{return await x(n,e)}catch(t){throw t instanceof i&&n.readyMs!==void 0&&(t.readyMs??(t.readyMs=n.readyMs)),t}}async function x(e,n){let t=n.signal;await A(e,n.readyTimeoutMs??E,t);let r=e.iframe.contentWindow;if(r===null)throw new i("challenge_frame_blocked");let a=n.timeoutMs??_,o=C(),s,l;try{return await new Promise((w,f)=>{e.waiters.set(o,{resolve:w,reject:f}),s=setTimeout(()=>f(new i("timeout")),a),t!==void 0&&(l=()=>f(c()),t.addEventListener("abort",l,{once:!0})),r.postMessage({type:"sekyro.challenge.request",v:1,id:o,siteKey:n.siteKey,action:n.action,subject:n.subject},e.origin)})}finally{clearTimeout(s),t!==void 0&&l!==void 0&&t.removeEventListener("abort",l),e.waiters.delete(o)}}var m=!1;function R(e,n){if(m)return;let t;if(n==="challenge_frame_blocked"){let r=e;try{r=h(e)}catch{}t=`Sekyro: the security check frame could not load. Allow \`frame-src ${r}\` in your Content-Security-Policy.`}else if(n==="embedder_opaque")t="Sekyro: the security check needs a page with an origin. Do not run the SDK in a sandboxed or data: document.";else return;m=!0,console.warn(t)}async function S(e){if(globalThis.origin==="null")throw new i("embedder_opaque");if(e.signal?.aborted)throw c();try{return await y(e)}catch(n){if(u(),e.signal?.aborted||n instanceof i&&n.code==="aborted")throw c();if(n instanceof i&&n.code==="timeout")throw n;try{return await y(e)}catch(t){throw u(),e.signal?.aborted?c():t instanceof i?t:new i("challenge_failed")}}}function T(e){let n=()=>S(e).catch(r=>{throw r instanceof i&&R(e.frameUrl,r.code),r}),t=g.then(n,n);return g=t.catch(()=>{}),t}export{i as a,E as b,_ as c,F as d,T as e};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var m=["video/mp4;codecs=avc1.42E01E,mp4a.40.2","video/mp4;codecs=avc1.42E01E","video/mp4","video/webm;codecs=vp9,opus","video/webm;codecs=vp9","video/webm;codecs=vp8,opus","video/webm;codecs=vp8","video/webm"];function v(){let e=globalThis.MediaRecorder;return!e||typeof e.isTypeSupported!="function"?"":m.find(r=>e.isTypeSupported(r))??""}var l="video/webm";function f(e){if(e instanceof TypeError)return"insecure";switch(e?.name??""){case"NotAllowedError":case"PermissionDeniedError":return"permission";case"NotFoundError":case"DevicesNotFoundError":return"notfound";case"NotReadableError":case"TrackStartError":return"inuse";case"OverconstrainedError":case"ConstraintNotSatisfiedError":return"overconstrained";default:return"generic"}}function x(){let e=globalThis;if(typeof e.window<"u"&&e.window.isSecureContext===!1)return"INSECURE_CONTEXT";let r=e.navigator?.mediaDevices;return!r||typeof r.getUserMedia!="function"?"UNSUPPORTED":"OK"}function S(){let e=globalThis.MediaRecorder;return typeof e<"u"&&typeof e.isTypeSupported=="function"}var g=8*1024*1024;function T(e){return e.size>g}function p(e){let r=(e||"").toLowerCase();return r.startsWith("image/jpeg")?"jpg":r.startsWith("video/mp4")?"mp4":(r.startsWith("video/webm"),"webm")}function h(e){let{token:r,clip:n,keyframe:t}=e,d=e.ts??Date.now(),u=n.type||l,c=t.type||"image/jpeg",o=new FormData;return o.append("token",r),o.append("clip",new File([n],`liveness-${d}.${p(u)}`,{type:u})),o.append("keyframe",new File([t],`keyframe-${d}.${p(c)}`,{type:c})),o}var w=40;function E(e){if(e===null||typeof e!="object"&&typeof e!="function")return;let r;try{r=e.name}catch{return}return k(r)}function k(e){if(typeof e!="string")return;let r=e.replace(/[^A-Za-z]/g,"").slice(0,w);return r===""?void 0:r}function N(e){let r=f(e);if(r!=="generic")return r;switch(E(e)){case"AbortError":return"inuse";case"SecurityError":return"permission";default:return r}}var i=Symbol.for("sekyro.web.cameraStreams"),a=globalThis,s=a[i]??(a[i]=new Set);function I(e){try{s.add(e)}catch{}}function D(e){let r=0;for(let n of[...s])if(n!==e){s.delete(n);try{for(let t of n.getTracks())t.readyState!=="ended"&&(t.stop(),r+=1)}catch{}}return r}var A=3;function y(e){let r=e.toLowerCase();return r===""?"unknown":/front|facing front|user|selfie|face ?time/.test(r)?"front":/ultra|0\.5x|wide angle/.test(r)?"ultra":/tele|zoom|periscope|[2-9]x/.test(r)?"tele":/depth|tof|infrared|\bir\b|truedepth|lidar|macro|monochrome|mono\b/.test(r)?"depth":/dual|triple/.test(r)?"virtual":/back|rear|environment|facing back|arrière|خلفية/.test(r)?"main":"unknown"}function b(e){let r=/camera2?\s*(\d+)/i.exec(e);return r?Number(r[1]):Number.POSITIVE_INFINITY}function L(e){let r={main:0,virtual:1,ultra:9,tele:9,depth:9,front:9,unknown:9};return e.filter(n=>(n.kind===void 0||n.kind==="videoinput")&&n.deviceId!=="").map((n,t)=>({id:n.deviceId,kind:y(n.label),index:b(n.label),i:t})).filter(n=>r[n.kind]<9).sort((n,t)=>r[n.kind]-r[t.kind]||n.index-t.index||n.i-t.i).map(n=>n.id)}export{m as a,v as b,l as c,f as d,x as e,S as f,g,T as h,p as i,h as j,E as k,k as l,N as m,I as n,D as o,A as p,y as q,L as r};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e={fp12:"08390000c48a",engine:"sekyro-ocr-1",precision:"fp32",files:{"sekyro-ocr.wasm":{bytes:3550608,sha256:"c15968a6de3d2225e2fdbf36d71a9214c2910419056c6878444fd2d0567bb748",tier:"live",contentType:"application/wasm"},"sekyro-ocr.mjs":{bytes:4270,sha256:"209a78d96ca53344996a0c2300aed4ff8a5c69e142713216975a2840eec08cac",tier:"bundled",contentType:"text/javascript"},"det.param":{bytes:24252,sha256:"c39ba0b1195e8ad37cfc5bdd7acedcfc1d9cb901e7b8eb1c9c4f6e5a66c04eb3",tier:"live",contentType:"text/plain"},"det.bin":{bytes:4685856,sha256:"652bafe366565109a1a5766caf482bc46f01481f8044d3a785bd9a1be67c63bb",tier:"live",contentType:"application/octet-stream"},"mrz-rec.param":{bytes:3510,sha256:"bc69b1b9683e35f6605b21001fadeb81468063459c00c0fc83c67c139f23df01",tier:"live",contentType:"text/plain"},"mrz-rec.bin":{bytes:494196,sha256:"de93a2aa2f08670cc7dedd17ba378d2f5d7cf6ae409054a9eac863a02c2febae",tier:"live",contentType:"application/octet-stream"},"mrz_dict.txt":{bytes:73,sha256:"b19858a4de2ccbbbdd4b53982188ea2c7664013183bbd1ae9d20ab52c661f97f",tier:"live",contentType:"text/plain"},"latin-rec.param":{bytes:19602,sha256:"2ae30dfdc7ee482c6cbbc0419c16ee125e880e9eaf69053d61953694bb0fcf4c",tier:"lazy",contentType:"text/plain"},"latin-rec.bin":{bytes:10750388,sha256:"f91ebdcf4d6b58c58a87704160e59d07ae56bc2d5021eae09d095c5a20bf7525",tier:"lazy",contentType:"application/octet-stream"},"ppocr_keys_v1.txt":{bytes:26249,sha256:"28b2362ad4ab2dc38769aa72feb535e3a9ddb3fd2a7585a05920e6393b1dc7f7",tier:"lazy",contentType:"text/plain"},"arabic-rec.param":{bytes:9858,sha256:"4e5cc85667dfaaa0c67d3f308400645a578c08bd43f952cab6c55b7bce143ea9",tier:"lazy",contentType:"text/plain"},"arabic-rec.bin":{bytes:8853572,sha256:"5acc3265a1738dc31316258383830d5dbdfa5e8ebc2e710f9001f832ecfbffb0",tier:"lazy",contentType:"application/octet-stream"},"arabic_dict.txt":{bytes:405,sha256:"637c27c88512c22089bef927b34ada08f748dc132ac70facd68d8202384c2726",tier:"lazy",contentType:"text/plain"}}};export{e as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var h=Object.freeze({minLines:4,fillMin:.55,fillMax:.98,offsetMax:.12,steadyFillDelta:.04,steadyOffsetDelta:.03,layoutShiftMax:.025,lineCountDelta:1,lockMs:600,steadyMs:900,minFrames:3});function y(a,r){let o=a.lineBoxes;if(o.length===0)return{lineCount:0,detected:!1,fill:0,offsetX:0,offsetY:0,centers:[]};let s=Math.min(...o.map(n=>n[0])),e=Math.max(...o.map(n=>n[0]+n[2])),t=Math.min(...o.map(n=>n[1])),l=Math.max(...o.map(n=>n[1]+n[3]));return{lineCount:o.length,detected:o.length>=r.minLines,fill:e-s,offsetX:(s+e)/2-.5,offsetY:(t+l)/2-.5,centers:o.map(n=>[n[0]+n[2]/2,n[1]+n[3]/2])}}function x(a,r){if(a.centers.length===0||r.centers.length===0)return Number.POSITIVE_INFINITY;let o=0;for(let[s,e]of r.centers){let t=Number.POSITIVE_INFINITY;for(let[l,n]of a.centers)t=Math.min(t,Math.hypot(s-l,e-n));o+=t}return o/r.centers.length}var c=class{constructor(r=h){this.t=r;this.last=null;this.goodSince=null;this.steadySince=null;this.frames=0}offer(r,o,s={glareOk:!0,sharpOk:!0}){let e=this.t,t=y(r,e),l=this.last;this.last=t;let n=t.fill>=e.fillMin&&t.fill<=e.fillMax,i=Math.abs(t.offsetX)<=e.offsetMax&&Math.abs(t.offsetY)<=e.offsetMax,m=l!==null&&l.detected&&Math.abs(t.lineCount-l.lineCount)<=e.lineCountDelta&&x(l,t)<=e.layoutShiftMax,f=t.detected&&s.glareOk&&s.sharpOk&&n&&m&&l!==null&&Math.abs(t.fill-l.fill)<=e.steadyFillDelta&&Math.abs(t.offsetX-l.offsetX)<=e.steadyOffsetDelta&&Math.abs(t.offsetY-l.offsetY)<=e.steadyOffsetDelta,d=f&&i,u=t.detected?s.glareOk?t.fill<e.fillMin?"closer":t.fill>e.fillMax?"farther":i?s.sharpOk?void 0:"blurry":"center":"glare":void 0;return f?(this.frames++,this.steadySince??(this.steadySince=o),this.goodSince=d?this.goodSince??o:null,(this.goodSince!==null&&o-this.goodSince>=e.lockMs||o-this.steadySince>=e.steadyMs)&&this.frames>=e.minFrames?{state:"locked"}:{state:"locking",...u?{hint:u}:{}}):(this.goodSince=null,this.steadySince=null,this.frames=t.detected?1:0,{state:t.detected?"locking":"searching",...u?{hint:u}:{}})}reset(){this.last=null,this.goodSince=null,this.steadySince=null,this.frames=0}};function M(a,r,o){let s=e=>Math.round(Math.min(1,Math.max(0,e))*1e4)/1e4;return a.map(e=>{let t=[e[0],e[2],e[4],e[6]],l=[e[1],e[3],e[5],e[7]],n=Math.min(...t),i=Math.min(...l);return[s(n/r),s(i/o),s((Math.max(...t)-n)/r),s((Math.max(...l)-i)/o)]}).sort((e,t)=>e[1]-t[1]||e[0]-t[0])}export{h as a,c as b,M as c};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var A=180,g=[100,190],x=64;function f(r,n){return .299*(r[n]??0)+.587*(r[n+1]??0)+.114*(r[n+2]??0)}function b(r){let{data:n,width:e,height:o}=r,t=e*o;if(t===0)return 0;let u=0;for(let s=0;s<t;s+=1)u+=f(n,s*4);return u/t}function E(r){let{data:n,width:e,height:o}=r;if(e<3||o<3)return 0;let t=new Float32Array(e*o);for(let a=0;a<t.length;a+=1)t[a]=f(n,a*4);let u=0,s=0,c=0;for(let a=1;a<o-1;a+=1)for(let i=1;i<e-1;i+=1){let m=a*e+i,l=(t[m-e]??0)+(t[m-1]??0)+(t[m+1]??0)+(t[m+e]??0)-4*(t[m]??0);u+=l,s+=l*l,c+=1}if(c===0)return 0;let h=u/c,p=s/c-h*h;return Math.min(1,Math.max(0,p)/180)}function F(r){let n=b(r),[e,o]=g,t=n<e?e-n:n>o?n-o:0;return Math.max(0,1-t/x)}export{A as a,g as b,b as c,E as d,F as e};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var k=1e4,l=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=R(n);if(r?.boundingBox===void 0)return null;let a=y(e),s=T(r.keypoints,a),c=r.keypoints?.[2],m={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,extraFaces:f(n.map(u=>u.boundingBox??{width:0,height:0}),n.indexOf(r))};return h(m,e,i,o)}destroy(){try{this.inner.close()}catch{}}};function R(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 T(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 E(){if(typeof OffscreenCanvas=="function")return new OffscreenCanvas(2,2);let t=document.createElement("canvas");return t.width=2,t.height=2,t}var I=4;async function w(){let t=globalThis.FaceDetector;if(typeof t!="function")return{ok:!1,reason:"unsupported"};try{let e=new t({fastMode:!0,maxDetectedFaces:I});return await e.detect(E()),{ok:!0,instance:e}}catch(e){return{ok:!1,reason:`smoke_failed:${e instanceof Error?e.message:String(e)}`}}}var b=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.map(u=>u.boundingBox),a=-1;r.forEach((u,F)=>{let p=r[a];(p===void 0||u.width*u.height>p.width*p.height)&&(a=F)});let s=n[a];if(s===void 0)return null;let c=S(s.landmarks),m={box:{x:s.boundingBox.x,y:s.boundingBox.y,width:s.boundingBox.width,height:s.boundingBox.height},...c!==void 0?{eyes:c}:{},score:1,extraFaces:f(r,a)};return h(m,e,i,o)}destroy(){}};function S(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 _=.25;function f(t,e){let i=t[e],o=i===void 0?0:i.width*i.height;if(!(o>0))return 0;let n=0;return t.forEach((r,a)=>{a!==e&&r.width*r.height>=_*o&&(n+=1)}),n}var M="/models-v3",L=["native","blaze"],x=class extends Error{constructor(e){super(`no detector tier available (${e})`),this.name="DetectorLadderError",this.fallbackReason=e}};function y(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 h(t,e,i,o){let n=y(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,...t.extraFaces!==void 0?{extraFaces:t.extraFaces}:{}}}function C(t){return t instanceof Error?t.message:String(t)}async function O(t){let e=t.preferred??L,i=[];for(let o of e){if(o==="native"){let n=await w();if(n.ok)return new b(n.instance,v(i));i.push(`native:${n.reason}`);continue}try{return await W(l.create(t.v3AssetBaseUrl??M,v(i)),t.blazeInitTimeoutMs??k)}catch(n){i.push(n instanceof g?"blaze:blaze_init_timeout":`blaze:${C(n)}`)}}throw new x(v(i)??"no_tier_available")}function v(t){return t.length>0?t.join("; "):void 0}var g=class extends Error{};function W(t,e){return new Promise((i,o)=>{let n=setTimeout(()=>{o(new g(`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 K(){return typeof OffscreenCanvas=="function"&&typeof createImageBitmap=="function"&&typeof Worker=="function"}function B(t,e={}){let i=e.createDetector??O,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"&&B(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=m=>{let u=m.data;u.v!==d||u.type!=="ready"||(clearTimeout(a),e.removeEventListener("message",s),n(new t(e,u)))};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{_ as a,f as b,M as c,L as d,x as e,y as f,h as g,O as h,d as i,K as j,B as k,D as l};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as T,b as R}from"./chunk-DK5YPBDQ.js";var N=1e3,_=[[1,0],[0,1],[1,1],[1,-1]];function w(i){let{width:t,height:e,data:r}=i;if(t<16||e<16)return-1;let s=new Uint8Array(t*e);for(let n=0,a=0;n<s.length;n+=1,a+=4)s[n]=Math.round(.299*(r[a]??0)+.587*(r[a+1]??0)+.114*(r[a+2]??0));let o=-1;for(let[n,a]of _){let l=new Uint32Array(256),c=new Float64Array(256),p=0;for(let h=1;h<e-1;h+=1){let u=h*t,S=(h+a)*t,A=(h-a)*t;for(let g=1;g<t-1;g+=1){let y=s[S+g+n]??0,z=s[A+g-n]??0,v=Math.abs(y-z);l[v]=(l[v]??0)+1,c[v]=(c[v]??0)+Math.abs(y+z-2*(s[u+g]??0)),p+=1}}let M=Math.max(1,Math.floor(p/20)),m=0,d=0,f=0;for(let h=255;h>=0&&m<M;h-=1){let u=l[h]??0;m+=u,d+=u*h,f+=c[h]??0}if(d===0)return 0;let b=f/d;o=o<0?b:Math.min(o,b)}return o}var I=.06;function P(i,t,e,r=I){if(i===null||t.width<=0||t.height<=0)return null;let s=[i.topLeft,i.topRight,i.bottomRight,i.bottomLeft],o=e.width/t.width,n=e.height/t.height,a=Math.min(...s.map(u=>u.x))*o,l=Math.max(...s.map(u=>u.x))*o,c=Math.min(...s.map(u=>u.y))*n,p=Math.max(...s.map(u=>u.y))*n,M=(l-a)*r,m=(p-c)*r,d=Math.max(0,Math.floor(a-M)),f=Math.max(0,Math.floor(c-m)),b=Math.min(e.width,Math.ceil(l+M)),h=Math.min(e.height,Math.ceil(p+m));return b-d<16||h-f<16?null:{x:d,y:f,width:b-d,height:h-f}}function F(i,t){let e=new Uint8ClampedArray(t.width*t.height*4);for(let r=0;r<t.height;r+=1)for(let s=0;s<t.width*4;s+=1)e[r*t.width*4+s]=i.data[((t.y+r)*i.width+t.x)*4+s]??0;return{data:e,width:t.width,height:t.height}}function E(i,t=1e3){let e=t/Math.max(i.width,i.height);if(e>=1)return i;let r=Math.max(1,Math.round(i.width*e)),s=Math.max(1,Math.round(i.height*e)),o=new Uint8ClampedArray(r*s*4);for(let n=0;n<s;n+=1){let a=Math.floor(n/e),l=Math.min(i.height,Math.max(a+1,Math.floor((n+1)/e)));for(let c=0;c<r;c+=1){let p=Math.floor(c/e),M=Math.min(i.width,Math.max(p+1,Math.floor((c+1)/e)));for(let m=0;m<3;m+=1){let d=0;for(let f=a;f<l;f+=1)for(let b=p;b<M;b+=1)d+=i.data[(f*i.width+b)*4+m]??0;o[(n*r+c)*4+m]=d/((l-a)*(M-p))}o[(n*r+c)*4+3]=255}}return{data:o,width:r,height:s}}function V(i,t){return w(E(t===null?i:F(i,t)))}function B(i,t){let e=t??{x:0,y:0,width:i.width,height:i.height},r=Math.min(1,1e3/Math.max(e.width,e.height)),s=Math.max(1,Math.round(e.width*r)),o=Math.max(1,Math.round(e.height*r)),n=document.createElement("canvas");n.width=s,n.height=o;try{let a=n.getContext("2d",{willReadFrequently:!0});return a===null?-1:(a.imageSmoothingQuality="high",a.drawImage(i,e.x,e.y,e.width,e.height,0,0,s,o),w(a.getImageData(0,0,s,o)))}catch{return-1}finally{n.width=0,n.height=0}}var k=class{constructor(t=2){this.stableReads=t;this.last=null;this.run=0}offer(t){return t===null?(this.reset(),!1):(this.run=t===this.last?this.run+1:1,this.last=t,this.run>=this.stableReads)}reset(){this.last=null,this.run=0}};var D=Object.freeze({...T,minIntervalMs:150,maxWidthPx:480,detectorLimit:960,searchTimeoutMs:12e3}),O=Object.freeze({detectorLimit:960,bandMaxWidthPx:1280,minBandWidthPx:900,bandTop:.55,minIntervalMs:150,stableReads:2,profileReads:5,maxReadMs:1200,searchTimeoutMs:12e3}),C=(i,t,e)=>createImageBitmap(i,Math.round(t.x),Math.round(t.y),Math.max(1,Math.round(t.w)),Math.max(1,Math.round(t.h)),{resizeWidth:Math.max(1,Math.round(Math.min(t.w,e))),resizeQuality:"high"}),x=(i,t)=>{if(i.length===0)return 0;let e=[...i].sort((r,s)=>r-s);return e[Math.min(e.length-1,Math.floor(e.length*t))]};function G(i){return i<=250?"fast":i<=600?"mid":"slow"}function Y(i,t,e){let r=i.y+i.h*t,s=Math.min(e,i.y+i.h*1.05);return{x:i.x,y:r,w:i.w,h:Math.max(1,s-r)}}var L=class{constructor(t){this.o=t;this.engine=null;this.gen=0;this.inFlight=!1;this.lastReadAt=Number.NEGATIVE_INFINITY;this.firstSeen=null;this.reads=0;this.times=[];this.mrzState={state:"searching"};this.lockState={state:"searching"};this.fallback=null;this.lockOff=!1;this.lockError=!1;this.fired=null;this.valid=null;this.faceMode="off";this.disabled=!1;this.crop=t.crop??C,this.mrzGate=new k(t.liveMrz?.stableReads??2),this.lockGate=new R(t.textLock??D)}setEngine(t){this.engine=t}get bandTop(){return this.o.liveMrz?.bandTop??O.bandTop}get hasEngine(){return this.engine!==null&&!this.disabled}reset(){this.gen++,this.inFlight=!1,this.lastReadAt=Number.NEGATIVE_INFINITY,this.firstSeen=null,this.reads=0,this.times=[],this.mrzGate.reset(),this.lockGate.reset(),this.mrzState={state:"searching"},this.lockState={state:"searching"},this.fallback=null,this.lockOff=!1,this.lockError=!1,this.fired=null,this.valid=null,this.faceMode="off"}rearmFace(){this.gen++,this.inFlight=!1,this.lastReadAt=Number.NEGATIVE_INFINITY,this.mrzGate.reset(),this.lockGate.reset(),this.fired=null,this.valid=null,this.fallback===null&&(this.mrzState={state:"searching"}),this.lockOff||(this.lockState={state:"searching"})}liveCapture(){return this.fired?.via==="live_mrz"?this.valid:null}modeFor(t){return this.engine===null||this.disabled?"off":t.mrzFace&&this.o.liveMrz!==null&&this.fallback===null?"live_mrz":this.o.textLock!==null&&!this.lockOff?"text_lock":"off"}tick(t){let e=this.modeFor(t);return e!=="off"&&(this.faceMode=e),this.fired!==null?{ready:!0,via:this.fired.via,suspendQuality:this.fired.via==="live_mrz",mode:e,...this.states()}:e==="live_mrz"?this.liveTick(t,this.o.liveMrz):e==="text_lock"?this.lockTick(t,this.o.textLock):{ready:!1,suspendQuality:!1,mode:e,...this.states()}}states(){return{...this.faceMode==="live_mrz"||this.fallback!==null?{mrz:this.fallback!==null?{state:"fallback",reason:this.fallback}:this.mrzState}:{},...this.faceMode==="text_lock"?{lock:this.lockState}:{}}}canRead(t,e){let r=this.engine;return r!==null&&!this.inFlight&&!r.busy&&t-this.lastReadAt>=e}fall(t){this.fallback=t,this.mrzGate.reset()}liveTick(t,e){let r=()=>this.fallback!==null?{ready:!1,suspendQuality:!1,mode:"live_mrz",mrz:{state:"fallback",reason:this.fallback}}:{ready:!1,suspendQuality:!0,mode:"live_mrz",mrz:this.mrzState};if(!t.present||t.band===null)return this.mrzGate.reset(),this.mrzState={state:"searching"},r();if(this.firstSeen??(this.firstSeen=t.atMs),t.atMs-this.firstSeen>e.searchTimeoutMs)return this.fall("timeout"),r();if(t.band.w<e.minBandWidthPx)return t.card!==null&&t.card.w<e.minBandWidthPx?(this.fall("unsupported"),r()):(this.mrzState={state:"reading",coach:t.portrait?"turnSideways":"moveCloser"},{ready:!1,suspendQuality:!1,mode:"live_mrz",mrz:this.mrzState});if(!this.canRead(t.atMs,e.minIntervalMs))return r();this.inFlight=!0,this.lastReadAt=t.atMs;let s=this.gen,o=this.engine,n=t.glareOk?t.sharpOk?void 0:"holdStill":"glare";return this.crop(t.video,t.band,e.bandMaxWidthPx).then(a=>o.bandRead(a,e.detectorLimit)).then(a=>{if(s===this.gen){if(this.reads++,this.times.push(a.ms),this.times.length>8&&this.times.shift(),this.reads>=e.profileReads&&x(this.times,.5)>e.maxReadMs)return this.fall("slow");if(this.mrzGate.offer(a.valid?a.digest??null:null)&&a.format&&a.digest){this.valid={format:a.format,...a.documentCode!==void 0?{documentCode:a.documentCode}:{},digest:a.digest,lineCount:a.lineCount,framesToValid:this.reads,msToValid:Math.round(t.atMs-(this.firstSeen??t.atMs))},this.mrzState={state:"valid",format:a.format},this.fired={via:"live_mrz",at:t.atMs};return}this.mrzState={state:"reading",...n?{coach:n}:{},...a.format?{format:a.format}:{}}}}).catch(()=>{s===this.gen&&this.fall("error")}).finally(()=>{s===this.gen&&(this.inFlight=!1)}),r()}lockTick(t,e){let r=()=>({ready:!1,suspendQuality:!1,mode:"text_lock",lock:this.lockState,...this.fallback!==null?{mrz:{state:"fallback",reason:this.fallback}}:{}});if(!t.present||t.card===null)return this.lockGate.reset(),this.lockState={state:"searching"},r();if(this.firstSeen??(this.firstSeen=t.atMs),t.atMs-this.firstSeen>e.searchTimeoutMs)return this.lockOff=!0,r();if(!this.canRead(t.atMs,e.minIntervalMs))return r();this.inFlight=!0,this.lastReadAt=t.atMs;let s=this.gen,o=this.engine,n={glareOk:t.glareOk,sharpOk:t.sharpOk};return this.crop(t.video,t.card,e.maxWidthPx).then(a=>o.layoutRead(a,e.detectorLimit)).then(a=>{if(s!==this.gen)return;this.reads++,this.times.push(a.ms),this.times.length>8&&this.times.shift();let l=this.lockGate.offer(a,t.atMs,n);this.lockState=l.state==="locked"?{state:"locked"}:{state:l.state,...l.hint?{hint:l.hint}:{}},l.state==="locked"&&(this.fired={via:"text_lock",at:t.atMs})}).catch(()=>{s===this.gen&&(this.lockOff=!0,this.lockError=!0)}).finally(()=>{s===this.gen&&(this.inFlight=!1)}),r()}disable(){this.disabled=!0,this.reset()}report(t,e,r){let s=this.faceMode;if(s==="off")return null;let o=x(this.times,.5),n={capture:t,mode:s,reads:this.reads,...this.times.length>0?{readP50Ms:Math.round(o),readP90Ms:Math.round(x(this.times,.9)),deviceClass:G(o)}:{}};return s==="live_mrz"?this.fired?.via==="live_mrz"&&this.valid!==null&&e==="live_mrz"?{...n,outcome:"valid",format:this.valid.format,framesToValid:this.valid.framesToValid,msToValid:this.valid.msToValid}:this.fallback!==null?{...n,outcome:this.fallback}:{...n,outcome:r-(this.firstSeen??r)>=(this.o.liveMrz?.searchTimeoutMs??1/0)?"timeout":"off"}:this.fired?.via==="text_lock"?{...n,outcome:"locked",framesToLock:Math.max(1,this.reads),msToLock:Math.round(this.fired.at-(this.firstSeen??this.fired.at))}:{...n,outcome:this.lockError?"error":this.lockOff?"timeout":"off"}}};export{N as a,w as b,I as c,P as d,F as e,E as f,V as g,B as h,D as i,O as j,Y as k,L as l};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var l=["session.verified","session.not_verified","session.review_pending","session.cancelled"],u=new Set([0,1,2,3]),E="sekyro-verify",a="width=480,height=720,noopener=false",f=new Set(l);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,E,a);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:v,level:s}=o.data,i={source:p,version:d,event:c,sessionId:v};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{l as a,S as b,k as c};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var K={enabled:!0,hz:3,segmenterTimeoutMs:8e3,segmenterBudgetMs:120,maskThreshold:.5,maxColorStd:28,maxEdgeDensity:.08,edgeLuma:24,maxGradient:.18,minPixels:300,timeoutMs:4e3},V=12e3,b=(n,o,t)=>Math.min(t,Math.max(o,Math.round(n)));function W(n,o,t){let{x:r,y:m,width:a,height:u}=n;if(t)return[{x:r-1.5*a,y:m-.8*u,width:4*a,height:2.8*u}];let d=m-.4*u,p=1.4*u;return[{x:r-.9*a,y:d,width:.75*a,height:p},{x:r+1.15*a,y:d,width:.75*a,height:p}].map(h=>{let M=Math.max(0,h.x),l=Math.min(o.width,h.x+h.width);return{x:M,y:h.y,width:Math.max(0,l-M),height:h.height}})}function Z(n,o,t,r=K){let m=t!==null&&t.width>0&&t.height>0,a=W(o,n,m),u=a.reduce((e,s)=>e+Math.max(0,s.width)*Math.max(0,s.height),0);if(u<=0)return null;let d=Math.max(1,Math.floor(Math.sqrt(u/V))),p=m?t.data instanceof Float32Array?1:1/255:1,h=(e,s)=>{if(!m)return!1;let w=b(e/n.width*t.width-.5,0,t.width-1),C=b(s/n.height*t.height-.5,0,t.height-1);return t.data[C*t.width+w]*p>=r.maskThreshold},M=e=>.299*n.data[e]+.587*n.data[e+1]+.114*n.data[e+2],l=0,B=[0,0,0],S=[0,0,0],k=0,T=0,D=0,_=0,P=0,A=0,E=0,L=0,F=0,G=0,O=Math.min(...a.map(e=>e.x)),j=Math.max(...a.map(e=>e.x+e.width)),H=Math.min(...a.map(e=>e.y)),I=Math.max(...a.map(e=>e.y+e.height)),J=(O+j)/2,Q=(H+I)/2;for(let e of a){let s=b(e.x,0,n.width),w=b(e.x+e.width,0,n.width),C=b(e.y,0,n.height),q=b(e.y+e.height,0,n.height);for(let c=C;c<q;c+=d)for(let g=s;g<w;g+=d){if(h(g,c))continue;let Y=(c*n.width+g)*4;for(let i=0;i<3;i+=1){let x=n.data[Y+i];B[i]=B[i]+x,S[i]=S[i]+x*x}l+=1;let y=M(Y);g<J?(D+=y,_+=1):(P+=y,A+=1),c<Q?(E+=y,L+=1):(F+=y,G+=1);for(let[i,x]of[[g+d,c],[g,c+d]])i>=w||x>=q||h(i,x)||(k+=1,Math.abs(M((x*n.width+i)*4)-y)>r.edgeLuma&&(T+=1))}}if(l<r.minPixels)return null;let U=0;for(let e=0;e<3;e+=1){let s=B[e]/l;U+=Math.max(0,S[e]/l-s*s)}let N=Math.sqrt(U/3),z=k===0?0:T/k,f=(e,s)=>s===0?null:e/s,R=(e,s)=>e===null||s===null?0:Math.abs(e-s)/255,X=Math.max(R(f(D,_),f(P,A)),R(f(E,L),f(F,G)));return{method:m?"segmenter":"strip",uniform:N<=r.maxColorStd&&z<=r.maxEdgeDensity&&X<=r.maxGradient,colorStd:Math.round(N*10)/10,edgeDensity:Math.round(z*1e3)/1e3,gradient:Math.round(X*1e3)/1e3,pixels:l}}function $(n){let o=n!==null&&typeof n=="object"?n:{},t=K,r=(m,a,u,d)=>typeof m=="number"&&Number.isFinite(m)&&m>=u&&m<=d?m:a;return{enabled:typeof o.enabled=="boolean"?o.enabled:t.enabled,hz:r(o.hz,t.hz,.5,15),segmenterTimeoutMs:r(o.segmenterTimeoutMs,t.segmenterTimeoutMs,0,6e4),segmenterBudgetMs:r(o.segmenterBudgetMs,t.segmenterBudgetMs,1,2e3),maskThreshold:r(o.maskThreshold,t.maskThreshold,0,1),maxColorStd:r(o.maxColorStd,t.maxColorStd,0,255),maxEdgeDensity:r(o.maxEdgeDensity,t.maxEdgeDensity,0,1),edgeLuma:r(o.edgeLuma,t.edgeLuma,0,255),maxGradient:r(o.maxGradient,t.maxGradient,0,1),minPixels:r(o.minPixels,t.minPixels,1,1e6),timeoutMs:r(o.timeoutMs,t.timeoutMs,0,6e4)}}export{K as a,Z as b,$ as c};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var n="sekyro-mrz-1";function e(r){return Array.from(new Uint8Array(r),t=>t.toString(16).padStart(2,"0")).join("")}async function o(r){return e(await crypto.subtle.digest("SHA-256",r))}function i(r,t){return o(new TextEncoder().encode(`${n}\0${r}\0${t.join(`
|
|
2
|
+
`)}`))}export{o as a,i as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{C as Me,F as ve,G as ie,H as Te,I as N,J as Y,d as q,e as Ce,f as Pe,g as Ae,i as Re,j as re,l as $,m as oe,o as we,p as xe,q as Ee,u as Ie}from"./chunk-UTPUHE4J.js";import{c as _e,d as be,e as ke}from"./chunk-FPXL63KZ.js";import{c as j,h as J,i as Oe}from"./chunk-ODI4A5K4.js";var Ne=["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 ut=["carte_identite","passport","residence_permit","drivers_license"],ct=["carte_identite","passport","residence_permit"];function dt(e,t){let n=e.byIssuer?.[t]??e.default;return ut.filter(i=>n==="*"?ct.includes(i):n.includes(i))}function Nn(e,t=Ne){return[...new Set([...t,...Object.keys(e.byIssuer??{})])].filter(i=>dt(e,i).length>0).sort()}function Le(e){if(e.acceptedDocuments)return e.acceptedDocuments;let t=e.acceptedDocumentTypes?.length?[...e.acceptedDocumentTypes]:["carte_identite","passport"];return{default:[],byIssuer:{MR:t}}}var lt=640,pt=new Set(["network_error","timeout","upload_failed","unknown_error","rate_limit_exceeded"]),Ve=6,Fe=1500,He={sharpness:1,exposure:1,meanLuma:128},De=null;function ft(e,t){try{De??(De=document.createElement("canvas"));let n=De,i=96/Math.max(1,t.width);n.width=Math.max(1,Math.round(t.width*i)),n.height=Math.max(1,Math.round(t.height*i));let r=n.getContext("2d");if(r===null)return He;r.drawImage(e,t.x,t.y,t.width,t.height,0,0,n.width,n.height);let a=r.getImageData(0,0,n.width,n.height);return{sharpness:be(a),exposure:ke(a),meanLuma:_e(a)}}catch{return He}}async function mt(e,t){let n=e.source;return"convertToBlob"in n?n.convertToBlob({type:"image/jpeg",quality:t}):new Promise((i,r)=>{n.toBlob(a=>a===null?r(new Error("encode failed")):i(a),"image/jpeg",t)})}function Dn(e,t={}){let n=t.now??(()=>performance.now()),i=t.setTimer??((m,k)=>setTimeout(m,k)),r=t.clearTimer??(m=>clearTimeout(m)),a=t.encode??mt,d=t.quality??ft,c=e.tuningVersion??null,p=new Set,S=!1,g=e.video??null,w=null,h=t.grabFrame??null,y=null,O=1e3/Ve,E=null,I=null,v=!1,V=!1,D=Number.NEGATIVE_INFINITY,x=null,U=0,F=null,K=null,te=Promise.all([import("./icao-gate-T3BTOKFJ.js"),import("./icao-tuning-4ETMF53W.js"),import("./create-portrait-capture-5VGYZUOK.js"),import("./landmarker-KB7LVXAU.js"),import("./background-monitor-A7FKJOAG.js")]).then(async([m,k,A,T,H])=>{let R=k.resolveIcaoTuning(e.tuning,e.tuningVersion??void 0);R.background.required&&(I=H.createBackgroundMonitor({tuning:R.backgroundCheck,assetBaseUrl:e.assetBaseUrl??"/models-v3",...t.createSegmenter!==void 0?{createSegmenter:t.createSegmenter}:{},now:n})),w=m.createIcaoGate(R,{policy:e.policy??"reject"}),h??(h=A.defaultGrabber()),y=A.observe,O=1e3/Math.min(Ve,R.cadenceHz);let M=(t.createLandmarker??T.createFaceLandmarker)(e.assetBaseUrl??"/models-v3"),o=await new Promise((s,u)=>{let l=setTimeout(()=>{u(new Error("landmarker init timeout")),M.then(f=>f.close(),()=>{})},T.LANDMARKER_INIT_TIMEOUT_MS);M.then(f=>{clearTimeout(l),s(f)},f=>{clearTimeout(l),u(f)})});S?o.close():E=o}).catch(()=>{v=!0}),Z=m=>{for(let k of p)k({holding:V||v,update:m})},G=()=>{if(x=null,!(S||E===null||w===null||h===null||y===null||g===null)){if(n()-D>Fe){Z(null);return}try{let m=h(g,lt);if(m!==null){let k=Math.max(n(),U+1);U=k;let A=E.detect(m.source,k),T=g.videoWidth||m.width,H=g.videoHeight||m.height,R=y(A,m,T,H);R.geometry!==null&&I!==null&&(R.backgroundCheck=I.measure(m,R.geometry.box,T,H));let M=w.push(R,n());V=M.ready,Z(M)}}catch{}x=i(G,O)}},ne=()=>{let m=n()-D>Fe;D=n(),m&&(w?.reset(),V=!1,F=null,K=null),x===null&&E!==null&&!S&&(x=i(G,0))},W=()=>{let m=h===null||g===null?null:h(g,null);if(m===null||w===null||Math.max(m.width,m.height)<e.still.minLongSidePx)return Promise.resolve(null);let k=w.summary();return a(m,e.still.jpegQuality).then(A=>({image:A,width:m.width,height:m.height,gate:k}),()=>null)},Q=null;return{engineOptions:{measureQuality:(m,k)=>{g=m,ne();let A=d(m,k);return V||v?A:{...A,sharpness:0}},telemetry:m=>{if(m.type!=="fired"||S)return;F=W();let k=Q;k!==null&&F.then(A=>A===null?void 0:k(A).catch(()=>{})),V=!1,x!==null&&r(x),x=null,D=Number.NEGATIVE_INFINITY}},decorate:m=>{let k=new WeakMap,A=new Map,T=o=>{let s=k.get(o);return s===void 0&&(s=(async()=>{let u=await Ie(m,"image","image/jpeg",o.image.size,{engine:"portrait"});return await m.uploadToSpaces(u.uploadUrl,o.image,"image/jpeg"),(await m.completeMedia(u.key)).key})(),s.catch(()=>k.delete(o)),k.set(o,s)),s};Q=T;let H=async o=>{let s;try{s=await T(o)}catch(u){let l=u?.code;if(typeof l=="string"&&pt.has(l))throw u;return null}return{media:{portrait:s},gate:Oe(o.gate),...c!==null?{tuningVersion:c}:{}}},R=m.submitCheck.bind(m),M=(async(o,s,u)=>{if(o!=="liveness")return R(o,s,u);let l=u?.idempotencyKey,f=l===void 0?void 0:A.get(l);if(f===void 0){let b=F;f=b===null?Promise.resolve(null):b.then(ye=>ye===null?null:H(ye)),l!==void 0&&(A.set(l,f),f.catch(()=>A.delete(l)))}let _=await f;if(_===null)return R("liveness",s,u);let P=await R("liveness",{...s,portraitIcao:_},u);return K=_,P});return new Proxy(m,{get(o,s){if(s==="submitCheck")return M;let u=Reflect.get(o,s);return typeof u=="function"?u.bind(o):u}})},onGate:m=>(p.add(m),()=>p.delete(m)),lastPortraitInput:()=>K,destroy:()=>{S=!0,F=null,K=null,x!==null&&r(x),x=null,p.clear(),te.then(()=>{E?.close(),E=null,I?.close(),I=null})}}}function Ge(e){return e.idNumberBound??e.nniBound}function Be(e){return e===void 0?void 0:e.idNumberFromDocument??e.nniFromDocument}function Ue(e){let t=e.idNumberMasked??e.nniMasked;return typeof t=="string"&&t!==""?t:void 0}var Ke=Object.freeze({nni_invalid:"id_number_invalid",nni_not_found:"registry_record_not_found",nni_recheck:"id_number_recheck",document_nni_mismatch:"document_id_number_mismatch",nni_locked:"id_number_locked",nni_unbound:"id_number_unbound",missing_nni:"missing_id_number",registry_needs_nni_source:"registry_needs_id_number_source"}),ht=new Map(Object.entries(Ke)),Un=new Map(Object.entries(Ke).map(([e,t])=>[t,e]));function je(e){return ht.get(e)??e}var C={fullNameMin:2,fullName:200,email:254,occupation:120,shortText:120,longText:1e3,addressLine:120,addressLines:4,city:80,postcode:16,number:1e12,dateMin:"1900-01-01",dateMax:"2100-12-31"},St=new Set(["full_name","birth_date","email","phone","address","country","occupation"]),gt=new Set(["short_text","long_text","single_choice","multiple_choice","yes_no","date","number"]),yt=new Set(["ar","fa","he","ur"]);function qe(e){return yt.has(e.split("-")[0]?.toLowerCase()??"")?"rtl":"ltr"}function Ye(e){if(typeof e!="object"||e===null)return null;let t=e;if(typeof t.locale!="string"||!Array.isArray(t.questions)||t.questions.length===0)return null;let n=t.consents??[];if(!Array.isArray(n))return null;for(let r of t.questions)if(!_t(r))return null;for(let r of n)if(!bt(r))return null;let i={locale:t.locale,questions:t.questions,consents:n};return typeof t.title=="string"&&t.title.trim()!==""&&(i.title=t.title),typeof t.intro=="string"&&t.intro.trim()!==""&&(i.intro=t.intro),typeof t.prefill=="object"&&t.prefill!==null&&!Array.isArray(t.prefill)&&(i.prefill=t.prefill),i}function _t(e){if(typeof e!="object"||e===null)return!1;let t=e;return typeof t.id!="string"||typeof t.required!="boolean"?!1:t.kind==="field"?typeof t.field=="string"&&St.has(t.field):t.kind!=="custom"||typeof t.type!="string"||!gt.has(t.type)||typeof t.label!="string"?!1:t.type==="single_choice"||t.type==="multiple_choice"?Array.isArray(t.choices)&&t.choices.length>=2&&t.choices.every(n=>typeof n=="object"&&n!==null&&typeof n.value=="string"&&typeof n.label=="string"):!0}function bt(e){if(typeof e!="object"||e===null)return!1;let t=e;if(typeof t.id!="string"||typeof t.required!="boolean"||typeof t.text!="string")return!1;if(t.link===void 0)return!0;let n=t.link;return typeof n=="object"&&n!==null&&typeof n.url=="string"&&/^https:\/\//.test(n.url)&&typeof n.label=="string"}var kt=/^(\d{4})-(\d{2})-(\d{2})$/;function Ct(e){if(typeof e!="string")return!1;let t=kt.exec(e);return t===null?!1:new Date(Date.UTC(Number(t[1]),Number(t[2])-1,Number(t[3]))).toISOString().slice(0,10)===e&&e>=C.dateMin&&e<=C.dateMax}function Pt(e){return typeof e=="number"&&Number.isFinite(e)&&Math.abs(e)<C.number&&Math.round(e*100)/100===e}function Ze(e){for(let t of e.matchAll(/\d[\d -]{11,}\d/g)){let n=t[0].replace(/[ -]/g,"");if(n.length>=13&&n.length<=19&&At(n))return!0}return!1}function At(e){let t=0;for(let n=0;n<e.length;n++){let i=Number(e[e.length-1-n]);n%2===1&&(i*=2,i>9&&(i-=9)),t+=i}return t%10===0}var Rt=/^[^\s@]+@[^\s@.]+(\.[^\s@.]+)+$/,wt=/^\+[1-9]\d{6,14}$/,We=/^[A-Z]{2}$/,xt=e=>e===void 0||typeof e=="string"&&e.trim()===""||Array.isArray(e)&&e.length===0;function Qe(e=Date.now()){return new Date(e).toISOString().slice(0,10)}function X(e,t,n=Qe()){let i=[];for(let r of e.questions){let a=t.answers[r.id];if(xt(a)){r.required&&i.push({id:r.id,code:"required"});continue}let d=r.kind==="field"?Et(r.field,a,n):Mt(r,a,n);d!==null&&i.push({id:r.id,...d})}for(let r of e.consents)r.required&&t.consents[r.id]!==!0&&i.push({id:r.id,code:"consent_required"});return i}function z(e,t,n=1){if(typeof e!="string")return{code:"required"};let i=e.trim();return[...i].length>t?{code:"too_long",params:{max:t}}:[...i].length<n?{code:"too_short",params:{min:n}}:Ze(i)?{code:"card_number"}:null}function $e(e,t,n={}){return Ct(e)?n.period==="past"&&e>=t?{code:"date_not_past"}:n.period==="future"&&e<=t?{code:"date_not_future"}:n.min!==void 0&&e<n.min?{code:"date_too_early",params:{date:n.min}}:n.max!==void 0&&e>n.max?{code:"date_too_late",params:{date:n.max}}:null:{code:"date_invalid"}}function Et(e,t,n){switch(e){case"full_name":return z(t,C.fullName,C.fullNameMin);case"occupation":return z(t,C.occupation);case"birth_date":return $e(t,n,{period:"past"});case"email":return typeof t=="string"&&t.trim().length<=C.email&&Rt.test(t.trim())?null:{code:"email_invalid"};case"phone":return typeof t=="string"&&wt.test(t)?null:{code:"phone_invalid"};case"country":return typeof t=="string"&&We.test(t)?null:{code:"choice_invalid"};case"address":return It(t)?null:{code:"address_invalid"};default:return null}}function It(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=e,n=Array.isArray(t.lines)?t.lines.filter(i=>typeof i=="string"&&i.trim()!==""):[];return typeof t.country=="string"&&We.test(t.country)&&typeof t.city=="string"&&t.city.trim()!==""&&t.city.trim().length<=C.city&&n.length>=1&&n.length<=C.addressLines&&n.every(i=>i.trim().length<=C.addressLine&&!Ze(i))&&(t.postcode===void 0||typeof t.postcode=="string"&&t.postcode.trim().length<=C.postcode)}function Mt(e,t,n){let i=new Set((e.choices??[]).map(r=>r.value));switch(e.type){case"short_text":return z(t,C.shortText);case"long_text":return z(t,C.longText);case"single_choice":return typeof t=="string"&&i.has(t)?null:{code:"choice_invalid"};case"multiple_choice":return Array.isArray(t)&&t.length>0&&new Set(t).size===t.length&&t.every(r=>i.has(r))?null:{code:"choice_invalid"};case"yes_no":return typeof t=="boolean"?null:{code:"choice_invalid"};case"date":{let r=e.options??{};return $e(t,n,{...typeof r.min=="string"?{min:r.min}:{},...typeof r.max=="string"?{max:r.max}:{},...r.period==="past"||r.period==="future"?{period:r.period}:{}})}case"number":{if(typeof t!="number"||!Number.isFinite(t)||Math.abs(t)>=C.number)return{code:"number_invalid"};let r=e.options??{};return r.integer===!0&&!Number.isInteger(t)?{code:"number_not_integer"}:Pt(t)?typeof r.min=="number"&&t<r.min?{code:"number_too_small",params:{min:r.min}}:typeof r.max=="number"&&t>r.max?{code:"number_too_large",params:{max:r.max}}:null:{code:"number_decimals"}}default:return null}}function Je(e,t,n,i=Qe()){let r=e?.errors;return Array.isArray(r)?r.flatMap(a=>{if(typeof a!="object"||a===null)return[];let{id:d,code:c}=a;return typeof d!="string"||typeof c!="string"?[]:[vt(d,c,t,n)]}):X(t,n,i)}var Ot={full_name:C.fullName,occupation:C.occupation,email:C.email,short_text:C.shortText,long_text:C.longText};function vt(e,t,n,i){let r=n.questions.find(p=>p.id===e),a=r===void 0?void 0:r.kind==="field"?r.field:r.type,d=i.answers[e],c=r!==void 0&&r.kind==="custom"?r.options??{}:{};switch(t){case"required":case"card_number":return{id:e,code:t};case"consent_required":return{id:e,code:"consent_required"};case"too_short":return{id:e,code:t,params:{min:a==="full_name"?C.fullNameMin:1}};case"too_long":{let p=a===void 0?void 0:Ot[a];return p===void 0?{id:e,code:t}:{id:e,code:t,params:{max:p}}}case"not_a_choice":return{id:e,code:"choice_invalid"};case"not_in_past":return{id:e,code:"date_not_past"};case"not_in_future":return{id:e,code:"date_not_future"};case"not_an_integer":return{id:e,code:"number_not_integer"};case"out_of_range":return Tt(e,a,d,c);case"invalid":return r===void 0?n.consents.some(p=>p.id===e)?{id:e,code:"consent_required"}:{id:e,code:t}:{id:e,code:Nt(a,d)};default:return{id:e,code:t}}}function Tt(e,t,n,i){if(t==="date"){let c=typeof i.min=="string"?i.min:void 0,p=typeof i.max=="string"?i.max:void 0;return p!==void 0&&(c===void 0||typeof n=="string"&&n>p)?{id:e,code:"date_too_late",params:{date:p}}:c!==void 0?{id:e,code:"date_too_early",params:{date:c}}:{id:e,code:"date_invalid"}}let r=typeof i.min=="number"?i.min:void 0,a=typeof i.max=="number"?i.max:void 0;return a!==void 0&&(r===void 0||typeof n=="number"&&n>a)?{id:e,code:"number_too_large",params:{max:a}}:r!==void 0?{id:e,code:"number_too_small",params:{min:r}}:{id:e,code:"number_invalid"}}function Nt(e,t){switch(e){case"email":return"email_invalid";case"phone":return"phone_invalid";case"birth_date":case"date":return"date_invalid";case"number":return typeof t=="number"&&Number.isFinite(t)&&Math.abs(t)<C.number?"number_decimals":"number_invalid";case"address":return"address_invalid";case"full_name":case"occupation":case"short_text":case"long_text":return"required";default:return"choice_invalid"}}var Lt=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","proof_of_address","form"]),Vt=new Set(["supplied_identity","aml_screening","face_dedup","age_estimation"]),ae=["document","population_registry","national_eid"],ue=["phone_otp","email_otp"],et={identity_method:ae,contact:ue},Ft=["population_registry","document"],ce="platform_unsupported",Ht=new Set(["prefilled","user_entered","prefilled_or_entered"]),Dt={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",poa:"documents",form:"form"};function L(e){return e.section??Dt[e.checkType]??null}function de(e,t){let n=e.plan?.choice;if(n===void 0||n.locked)return;let i=n.options.find(r=>r.id!==n.selected&&r.available!==!1&&t.includes(r.service));return i===void 0?void 0:{nodeId:n.nodeId,option:i}}function le(e){let t=e.plan,n=t?.choice;if(t===void 0||n===void 0||n.locked||t.current===null||t.current===n.nodeId||re(e))return null;let i=et[n.kind]??[...ae,...ue],r=n.options.flatMap(c=>c.available===!1||!i.includes(c.service)?[]:[c.nationalEid!=null?{id:c.id,service:c.service,nationalEid:c.nationalEid}:{id:c.id,service:c.service}]),a=t.steps.find(c=>c.id===t.current)?.service,d=n.selected??r.find(c=>c.service===a)?.id??null;return r.some(c=>c.id!==d)?{nodeId:n.nodeId,kind:n.kind,current:d,options:r}:null}function tt(e){return e==null?[]:e.options.filter(t=>t.id!==e.current)}function Gt(e){let t=e.simulation;if(typeof t!="object"||t===null)return;let{otpCode:n,skipCapture:i}=t;if(typeof n!="string"||n===""||typeof i!="boolean")return;let r=xe(e);return r!==void 0?{otpCode:n,skipCapture:i,reason:r}:{otpCode:n,skipCapture:i}}function Bt(e){let t=(e.plan?.sections??[]).map(d=>({id:d.id,state:d.state})),n={sessionId:oe(e.sessionId),orgName:e.orgName,sandbox:e.sandbox===!0,returning:e.returning===!0,consentRecorded:e.consentRecorded,expiresAt:e.expiresAt,sections:t.map(d=>d.id),progress:t,purpose:e.purpose??"identity"};e.branding!==void 0&&(n.branding=e.branding),e.cameraUnavailableHandled===!0&&(n.cameraUnavailableHandled=!0);let i=Gt(e);i!==void 0&&(n.simulation=i);let r=e.testerGate;r?.offered===!0&&typeof r.attemptsLeft=="number"&&r.attemptsLeft>0&&(n.testerGate={attemptsLeft:r.attemptsLeft});let a=le(e);return a!==null&&(n.switchable=a),n}function Ut(e){let t={attemptsRemaining:Pe(e),attemptsExhausted:e.attempts.used>=e.attempts.max};return e.reason!==void 0&&(t.reason=e.reason),e.retakeHint!==void 0&&(t.retakeHint=e.retakeHint),t}var nt={phone_otp:"phone",email_otp:"email"};function Kt(e,t){let n=de(e,[t==="phone_otp"?"email_otp":"phone_otp"]);return n===void 0?void 0:nt[n.option.service]}function jt(e,t,n,i){let r=t.checkType==="email_otp",a=(r?t.emailOtp:t.otp)??{},d=r?t.emailOtp?.emailSource:t.otp?.numberSource,c=d!==void 0&&Ht.has(d)?d:r?"prefilled_or_entered":"user_entered",p=typeof a.sentToMasked=="string"&&a.sentToMasked.length>0,S=a.prefilled===!0,g=Kt(e,r?"email_otp":"phone_otp"),w={key:t.checkType,context:n,section:L(t),phase:p?"verify":"send",canSwitch:g!==void 0,...i},h=r?{kind:"email_otp",...w,emailSource:c,needsEmail:c!=="prefilled"&&!S}:{kind:"phone_otp",...w,numberSource:c,needsPhone:c!=="prefilled"&&!S,channels:(t.otp?.channels??[]).filter(y=>y==="whatsapp"||y==="sms")};if(g!==void 0&&(h.switchChannel=g),S&&(h.prefilled=!0),p&&(h.sentToMasked=a.sentToMasked),!r&&t.otp?.channel!==void 0&&(h.channel=t.otp.channel),!r&&Array.isArray(t.phoneCountries)&&(h.phoneCountries=t.phoneCountries.filter(y=>typeof y=="string"&&/^[A-Z]{2}$/.test(y))),!r&&Array.isArray(t.phoneRules)){let y=h.phoneCountries??[];h.phoneRules=t.phoneRules.flatMap(O=>{let E=Zt(O);return E!==void 0&&y.includes(E.code)?[E]:[]})}return!r&&t.phoneInternational===!0&&(h.phoneInternational=!0),a.expiresAt!==void 0&&(h.codeExpiresAt=a.expiresAt),a.resendAvailableAt!==void 0&&(h.resendAvailableAt=a.resendAvailableAt),h}var qt=/^[\d[\]\-|()?:^]{1,64}$/;function Yt(e){try{return typeof e=="string"&&qt.test(e)&&new RegExp(e)!==null}catch{return!1}}var ze=e=>typeof e=="number"&&Number.isInteger(e)&&e>=1&&e<=15;function Zt(e){let{code:t,dial:n,trunk:i,lengths:r,formats:a}=e??{};if(typeof t!="string"||typeof n!="string"||!/^\d{1,3}$/.test(n)||i!==void 0&&(typeof i!="string"||!/^\d{1,3}$/.test(i))||!Array.isArray(r)||r.length===0||!r.every(ze))return;let d={code:t,dial:n,lengths:[...r].sort((c,p)=>c-p)};if(i!==void 0&&(d.trunk=i),a!==void 0){if(!(Array.isArray(a)&&a.length<=8&&a.every(p=>Yt(p?.leading)&&Array.isArray(p.groups)&&p.groups.every(ze)&&r.includes(p.groups.reduce((S,g)=>S+g,0)))))return;d.formats=a.map(p=>({leading:p.leading,groups:[...p.groups]}))}return d}function Wt(e,t,n,i){let r=Ge(e)===!0?"bound":Be(t)===!0?"document":"typed",a=r==="typed"&&t.state==="input_required"&&t.reason!==void 0&&je(t.reason)==="id_number_recheck",d=tt(le(e)),c=!i.attemptsExhausted&&d.length===1&&d[0]?.service==="document";return{kind:"registry",key:"registry",context:n,section:L(t),state:t.state==="input_required"?"input_required":"pending",source:r,recheck:a,canUseDocument:c,...i}}function Qt(e,t,n,i,r){let a=[...t.acceptedSides??[]],d={kind:"document",key:"document",context:n,section:L(t),side:a.includes("recto")?"verso":"recto",acceptedSides:a,documents:Le(e),photo:fe(pe(e.documents),r),...i};return e.detectedCountry!==void 0&&(d.detectedCountry=e.detectedCountry),zt(e)&&(d.ageStepUp=!0),d}function pe(e,t=!0){let n=e?.source==="upload"||e?.source==="choice"?e.source:"camera",i=e?.sourcePick==="camera"||e?.sourcePick==="upload"?e.sourcePick:null;return{source:n,pick:i,uploadOffered:t&&e?.uploadOffered===!0}}function fe(e,t){return t?{...e,cameraOnPhone:!0}:e}var $t=10*1024*1024;function Jt(e,t,n,i,r){let a=e.proofOfAddress,d=a?.pdf?.maxBytes,c=a?.phase==="holder_letter"?"holder_letter":"document";return{kind:"proof_of_address",key:"proof_of_address",context:n,section:L(t),phase:c,rule:a?.rule??{country:null,countryFrom:"global",source:"preset_global",kinds:[]},nameMatch:a?.nameMatch??"exact_person",photo:fe(pe(a),r),maxPages:3,pdf:{maxBytes:typeof d=="number"&&d>0?d:$t,maxPages:3},licenceAddressAccepted:c==="document"&&a?.licenceAddressAccepted===!0,...i}}function zt(e){let t=Ce(e).find(i=>i.checkType==="age_estimation"),n=t?.reason;return t?.state==="failed"&&(n==="age_uncertain"||n==="age_unavailable")}function Xt(e){let t=$(e,"liveness");return t?.state==="passed"||t?.state==="review"}function Xe(e,t,n,i,r,a=!1){let d=t.icao?.report,c=e.portrait,p=r==="capture"?c?.pendingFix??null:null;p!==null&&(r="review");let S=rt(e);return{kind:"portrait",key:`portrait:${r}`,context:n,section:L(t),phase:r,report:Array.isArray(d)?d:null,review:t.state==="review",tuning:e.capture?.icao??null,tuningVersion:e.capture?.tuningVersion??null,icao:J(e),retakeOnly:r==="capture"&&t.state==="input_required"&&S===void 0&&e.capture?.livePhoto?.oneCapture===!0&&Xt(e),photo:fe(pe(c,r==="capture"),a&&r==="capture"),pendingFix:p,...S!==void 0?{captureMode:S}:{},...c?.reuse?.pending===!0?{reuse:!0}:{},...i}}function rt(e){let t=e.portrait?.captureMode;return t==="self"||t==="assisted"||t==="choice"?t:void 0}var se={minLongSidePx:1280,jpegQuality:.95};function en(e,t){let n=e.capture?.livePhoto;if(n?.oneCapture!==!0)return null;let i=$(e,"portrait_icao"),r=n.still??se;return{icao:t==="liveness"&&J(e)!==null&&rt(e)===void 0&&i!==void 0&&i.state==="pending"&&i.reason===void 0,still:{minLongSidePx:r.minLongSidePx??se.minLongSidePx,jpegQuality:r.jpegQuality??se.jpegQuality}}}function tn(e,t,n,i){let r=t.eid,a=L(t);if(r===void 0||r.challenge!=="app_code")return{kind:"unsupported",key:"unsupported:eid_auth",context:n,section:a,checkType:"eid_auth",reason:"update_required"};let d=tt(le(e)),c=d.length===1&&Ft.includes(d[0]?.service??"")?d[0]:void 0,p=c===void 0?void 0:q[c.service],S=p!==void 0,g={kind:"eid",key:"eid",context:n,section:a,provider:r.provider,providerName:r.providerName,country:r.country,challenge:"app_code",phase:r.awaiting==="code"?"code":"identifier",identifierBound:r.identifierBound===!0,canUseCamera:S,afterPass:r.afterPass==="continue"?"continue":"end",...i};return S&&(g.cameraMethod=p),r.expiresAt!==void 0&&(g.codeExpiresAt=r.expiresAt),r.resendAvailableAt!==void 0&&(g.resendAvailableAt=r.resendAvailableAt),r.resendsRemaining!==void 0&&(g.resendsRemaining=r.resendsRemaining),r.codeAttemptsRemaining!==void 0&&(g.codeAttemptsRemaining=r.codeAttemptsRemaining),g}function nn(e,t){if(t.checkType!=="face_match"||t.reason!==void 0)return null;let n=$(e,"portrait_icao");return n!==void 0&&(n.state==="passed"||n.state==="review")?n:null}var rn={rejected:"rejected",inconclusive:"inconclusive",unavailable:"unavailable",abandoned:"expired",not_opened:"expired",cancelled:"expired",superseded:"expired",policy:"policy"};function on(e){return e.reasonCode===ce?"platform_unsupported":e.status==="review_pending"?"review":e.status==="verified"?"verified":e.reasonCode==="device_cooldown"?"cooldown":e.reasonCode==="starter_credit_claimed"?"policy":(e.status==="not_verified"&&e.reason!==void 0?rn[e.reason]:void 0)??"rejected"}function sn(e,t){let n=on(e),i=n==="platform_unsupported"?{sessionId:oe(e.sessionId),status:"unavailable",reasonCode:ce}:we(e,{autoRetry:!1}),r={kind:"result",key:"result",context:t,section:null,display:n,result:i};return e.status==="not_verified"&&e.reason!==void 0&&(r.reason=e.reason),e.reasonCode!==void 0&&(r.reasonCode=e.reasonCode),e.status==="not_verified"&&e.step!==void 0&&(r.step=e.step),e.retryAfter!==void 0&&(r.retryAfter=e.retryAfter),r}function an(e,t,n){let i=e.identitySummary;if(i==null)return null;let r={kind:"identity_summary",key:"identity_summary",context:t,section:n??"identity",summaryKind:i.kind==="partial"?"partial":i.kind??"full",source:i.source,portraitAvailable:i.portrait?.available===!0,retakeAvailable:i.retakeAvailable===!0};for(let d of un){let c=i[d];typeof c=="string"&&c!==""&&(r[d]=c)}let a=Ue(i);return a!==void 0&&(r.idNumberMasked=a,r.nniMasked=a),r}var un=["fullName","birthDate","birthYear","nationality","documentType","documentNumberMasked","expiryDate","retakeTarget"];function B(e,t,n,i){return{kind:"unsupported",key:`unsupported:${n}`,context:e,section:t,checkType:n,reason:i}}function cn(e){return e.kind==="contact"?"contact":(e.kind==="identity_method","identity")}function dn(e,t){let n=et[e.kind]??[...ae,...ue],i=cn(e),r=e.options.flatMap(d=>{if(d.available===!1||!n.includes(d.service))return[];let c={id:d.id,service:d.service};d.nationalEid!=null&&(c.nationalEid=d.nationalEid);let p=(d.channels??[]).filter(S=>S==="whatsapp"||S==="sms");return d.service==="phone_otp"&&p.length>0&&(c.channels=p),[c]});if(r.length===0){let d=e.options.length>0&&e.options.every(c=>c.service==="nfc");return B(t,i,"choice",d?"platform_unsupported":"update_required")}let a={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:i,options:r.map(p=>q[p.service]),choice:a},c=r.find(p=>p.nationalEid!==void 0)?.nationalEid;return c!==void 0&&(d.nationalEid=c),d}return e.kind==="contact"?{kind:"contact_choice",key:"contact_choice",context:t,section:i,options:r.map(d=>nt[d.service]),selected:null,locked:!1,choice:a}:{kind:"choice",key:`choice:${e.nodeId}`,context:t,section:i,choice:a}}function ln(e,t,n,i){let r=e.nativeApp,a=typeof r=="object"&&r!==null?r:{},d={sekyroApp:a.sekyroApp===!0};return typeof a.link=="string"&&a.link!==""&&(d.link=a.link),d.sekyroApp&&typeof a.sekyroAppLink=="string"&&a.sekyroAppLink.startsWith("sekyro://")&&(d.sekyroAppLink=a.sekyroAppLink),{kind:"native_app_required",key:`native_app_required:${i}`,context:t,section:n,checkType:i,nativeApp:d}}function ee(e,t={}){let n=Bt(e);if(re(e)||e.reasonCode===ce)return sn(e,n);let i=e.plan;if(i===void 0||!Array.isArray(i.sections))return B(n,null,"plan","update_required");let r=Ae(e);if(r!==null)return dn(r,n);let a=i.current===null?void 0:i.steps.find(h=>h.id===i.current),d=h=>{let y={kind:"processing",key:"processing",context:n,section:h!==void 0?L(h):i.sections.find(O=>O.state==="current")?.id??null,stalled:!1};return typeof h?.service=="string"&&h.service!==""&&(y.service=h.service),y};if(i.current===null)return d(i.steps.find(h=>h.state==="processing"));if(a===void 0)return B(n,null,"step","update_required");if(!Lt.has(a.service))return a.interaction==="server"?d(a):B(n,L(a),a.service,"update_required");if(Vt.has(a.service)||!Re(a))return d(a);let c=a,p=Ut(c),S=c.checkType,g=L(c);if(c.requiresNativeApp===!0)return ln(e,n,g,S);let w=t.isMobile===!1?Ee(e,c):null;if(w==="phone")return{kind:"mobile_required",key:"mobile_required",context:n,section:g,checkType:S};switch(S){case"phone_otp":case"email_otp":return jt(e,c,n,p);case"population_registry":return Wt(e,c,n,p);case"eid_auth":return tn(e,c,n,p);case"doc_ocr":return Qt(e,c,n,p,w==="upload_or_phone");case"identity_confirm":return an(e,n,g)??d(c);case"portrait_icao":return Xe(e,c,n,p,"capture",w==="upload_or_phone");case"liveness":case"face_match":{let h=nn(e,c);if(h!==null)return Xe(e,h,n,p,"match");let y=c.requiresMobile===!0,O=J(e);return{kind:"liveness",key:"biometric",context:n,section:g,mode:S==="face_match"?"selfie":"liveness",requiresMobile:y,instructions:O===null?"standard":"icao",icao:O,livePhoto:en(e,S),...p}}case"poa":return Jt(e,c,n,p,w==="upload_or_phone");case"form":{let h=Ye(c.form);return h===null?B(n,g,S,"update_required"):{kind:"form",key:"form",context:n,section:g,form:h,dir:qe(h.locale),...p}}case"nfc_chip":return B(n,g,S,"platform_unsupported");default:return B(n,g,S,"update_required")}}var pn=/^[A-Z0-9][A-Z0-9 -]{0,39}$/,fn=Object.freeze({normalize:e=>e.trim().toUpperCase().replace(/\s+/g," "),check:e=>pn.test(e),registrySources:Object.freeze([]),describe:"number must be 1 to 40 letters, digits, spaces or hyphens"}),mn=/^[A-Z0-9]{4,20}$/,me=e=>e.trim().toUpperCase().replace(/[\s-]+/g,""),hn=Object.freeze({normalize:me,check:e=>mn.test(me(e)),registrySources:Object.freeze([]),describe:"number must be 4 to 20 letters or digits"});function Sn(e){return typeof e=="string"&&/^\d{10}$/.test(e)&&Number(e)%97===1}var gn={trim:e=>e.trim(),upper_single_space:e=>e.trim().toUpperCase().replace(/\s+/g," "),upper_no_space_or_hyphen:me},yn={mr_nni_mod97:e=>Sn(e)};function _n(e){let t=new RegExp(e.pattern,"u"),n=e.check===null?void 0:yn[e.check];return Object.freeze({normalize:gn[e.normalize],check:i=>t.test(i.trim())&&(n===void 0||n(i)),registrySources:Object.freeze([...e.registrySources]),describe:e.describe})}var bn=Object.freeze(Object.fromEntries(Object.entries(Te).map(([e,t])=>[e,_n(t)])));function he(e,t){return bn[`${e.toUpperCase()}:${t}`]??(t==="drivers_license"?hn:fn)}var kn=Object.freeze({MRT:"MR"});function ot(e,t){let n=e.trim().toUpperCase();return he(kn[n]??n,t)}function it(e){let t=ot(e.issuingCountry,e.type);return t.check(t.normalize(e.number))}function st(e){return he("MR","national_id").check(e)}function Se(e){let t="";for(let n of e){let i=n.codePointAt(0)??0;i>=1632&&i<=1641?t+=String(i-1632):i>=1776&&i<=1785?t+=String(i-1776):n!==" "&&n!=="-"&&n!==" "&&(t+=n)}return t}var Cn=[1e3,2e3,4e3,8e3,15e3],Pn=3e4,An=/^\+[1-9]\d{6,14}$/,Rn=/^\d{6}$/,wn=/^\d{6}$/,xn=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,at=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","native_app_required"]),En={simulatedCapture:!0},In=new Set(["network_error","timeout","upload_failed","unknown_error","rate_limit_exceeded"]);function lr(e){let t=!1,n=null,i="",r=!1,a=!1,d=!1,c={},p={},S=new Set,g=!1,w=!1,h=null,y="idle",O=new Map,E=new Map,I=(o,s,u)=>{let l=`${o}.${s}`,f=O.get(l);if(f!==void 0)return f;let _=E.get(o),P=(_===void 0?u():_.then(u)).finally(()=>{O.delete(l)});O.set(l,P);let b=P.then(()=>{},()=>{});return E.set(o,b),b.then(()=>{E.get(o)===b&&E.delete(o)}),P},v=async(o,s,u)=>{await e.ensureConsent();let l;try{l=await Me(e.runtime,s)}catch(_){if(_ instanceof j&&at.has(_.code)){await e.refreshView();return}throw _}if(u?.(l),e.destroyed())return;let f=l;f.plan!==void 0&&e.setView!==void 0?e.setView(f):await e.refreshView()},V=async o=>{await e.ensureConsent();let s;try{try{s=await o(e.runtime.client)}catch(u){if(!(u instanceof j)||u.code!=="consent_required")throw u;await e.runtime.ensureConsent({force:!0}),s=await o(e.runtime.client)}}catch(u){if(u instanceof j&&at.has(u.code)){await e.refreshView();return}throw u}e.destroyed()||(s!==void 0&&e.setView!==void 0?e.setView(s):await e.refreshView())},D=(o,s)=>I("choice",`${o}:${s}`,()=>V(u=>u.choose(o,s))),x=(o,s)=>o.options.some(u=>u.id===s)?D(o.nodeId,s):Promise.reject(new RangeError(`option ${String(s)} is not offered`)),U=(o,s)=>{let u=e.currentView(),l=u===null?void 0:de(u,o);return l===void 0?Promise.reject(new RangeError(`the ${s} is not offered`)):D(l.nodeId,l.option.id)},F=o=>I("identity",o,()=>V(s=>s.confirmIdentity===void 0?Promise.reject(new Error("identity confirmation is not available in this build")):s.confirmIdentity(o))),K=(o,s)=>{let u=X(o.form,s);if(u.length>0)return Promise.reject(new ie(u,"client"));let l={answers:{...s.answers},consents:{}};for(let f of o.form.consents)l.consents[f.id]=s.consents[f.id]===!0;return I("form","submit",()=>v("form",(f,_)=>f.submitCheck("form",l,{idempotencyKey:_})).catch(f=>{throw f instanceof j&&f.code===ve?new ie(Je(f.details,o.form,l),"server"):f}))},te=(o,s)=>{let u=o.kind,l=u==="phone_otp",f=l?"phone":"email",_={action:"send"};if(l?o.needsPhone:o.needsEmail){let P=s[f]??p[u],b=l?P?.replace(/[\s().-]/g,""):P?.trim();if(b!==void 0||o.phase!=="verify"){if(b===void 0||!(l?An:xn).test(b))return Promise.reject(l?new N("phone","format"):new Y("email","format"));_[f]=b}}if(l){let P=o.channels,b=s.channel??(P.length===1?P[0]:void 0);if(P.length>0){if(b===void 0)return Promise.reject(new Y("channel","required"));if(!P.includes(b))return Promise.reject(new Y("channel","unavailable"))}b!==void 0&&(_.channel=b),_.phoneRules=1}return I(u,"send",()=>v(u,(P,b)=>P.submitCheck(u,_,{idempotencyKey:b}),P=>{On(P,u)||(c[u]=e.now(),_[f]!==void 0&&(p[u]=_[f]))}))},Z=(o,s)=>Rn.test(s)?I(o,"verify",()=>v(o,(u,l)=>u.submitCheck(o,{action:"verify",code:s},{idempotencyKey:l}))):Promise.reject(new N("code","format")),G=(o,s)=>I("eid_auth",o,()=>v("eid_auth",(u,l)=>u.submitCheck("eid_auth",s,{idempotencyKey:l}))),ne=(o,s)=>{if(o.identifierBound)return G("start",{action:"start"});let u=Se(s??"");if(o.country==="MR"){if(!/^\d{10}$/.test(u))return Promise.reject(new N("nni","format"));if(!st(u))return Promise.reject(new N("nni","check_digit"))}else if(u==="")return Promise.reject(new N("nni","format"));return G("start",{action:"start",identifier:u})},W=(o,s,u)=>{if(o.source!=="typed")return Promise.reject(new RangeError("this session already holds the ID number"));let l=Se(s);return/^\d{10}$/.test(l)?it({type:"national_id",issuingCountry:"MR",number:l})?I("population_registry","submitIdNumber",()=>v("population_registry",(f,_)=>f.submitCheck("population_registry",{idNumber:l,nni:l},{idempotencyKey:_}),()=>{h=`\u2022\u2022\u2022\u2022\u2022\u2022${l.slice(-4)}`})):Promise.reject(new N(u,"check_digit")):Promise.reject(new N(u,"format"))},Q=o=>(e.stopCameras?.(),I(o,"skipCapture",()=>v(o,(s,u)=>s.submitCheck(o,En,{idempotencyKey:u}),()=>{(o==="liveness"||o==="portrait_icao")&&(g=!0)}))),ge=o=>{if(o.kind==="result"||o.context.simulation?.skipCapture!==!0)return o;let s=Mn(o);return s===null?o:{...o,skipCapture:()=>Q(s)}},m=o=>((o.kind==="document"||o.kind==="portrait"||o.kind==="proof_of_address")&&o.photo?.cameraOnPhone===!0&&(o.refresh=async()=>{await e.refreshView()}),o),k=o=>{switch(o.kind){case"phone_otp":case"email_otp":{let s={...o,send:(l={})=>te(o,l),verify:l=>Z(o.kind,l),switchTo:()=>o.canSwitch&&o.switchChannel!==void 0?U([o.switchChannel==="email"?"email_otp":"phone_otp"],"other contact option"):Promise.reject(new RangeError("this session has no other contact option"))},u=c[o.kind];return s.resendAvailableAt===void 0&&u!==void 0&&(s.resendAvailableAt=new Date(u+Pn).toISOString()),s}case"eid":return{...o,start:s=>ne(o,s),verify:s=>wn.test(s)?G("verify",{action:"verify",code:s}):Promise.reject(new N("code","format")),resend:()=>o.resendsRemaining===0?Promise.reject(new RangeError("no new code can be sent for this session")):G("resend",{action:"resend"}),useCamera:()=>o.canUseCamera&&o.cameraMethod!==void 0?U(o.cameraMethod==="document_photo"?["document"]:["population_registry"],"camera path"):Promise.reject(new RangeError("the camera path is not offered"))};case"method":return{...o,select:s=>{let u=o.choice.options.find(l=>q[l.service]===s);return u!==void 0?x(o.choice,u.id):Promise.reject(new RangeError(`method ${String(s)} is not offered`))},choose:s=>x(o.choice,s)};case"choice":return{...o,choose:s=>x(o.choice,s)};case"registry":return{...o,submitIdNumber:s=>W(o,s,"idNumber"),submitNni:s=>W(o,s,"nni"),confirm:()=>I("population_registry","confirm",()=>v("population_registry",(s,u)=>s.submitCheck("population_registry",{},{idempotencyKey:u}))),useDocument:()=>o.canUseDocument?U(["document"],"document method"):Promise.reject(new RangeError("the document method is not offered"))};case"document":return e.bindDocument!==void 0?m(e.bindDocument(o,M)):{...o,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?m(e.bindPortrait(o,M)):{...o,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"proof_of_address":return e.bindProofOfAddress!==void 0?m(e.bindProofOfAddress(o,M)):{...o,uploadPages:()=>Promise.reject(new Error("proof of address upload is not available in this build")),uploadHolderLetter:()=>Promise.reject(new Error("proof of address upload is not available in this build")),capturePage:()=>{throw new Error("proof of address capture is not available in this build")}};case"form":return{...o,validate:s=>X(o.form,s),submit:s=>K(o,s)};case"contact_choice":return{...o,select:s=>{let u=s==="phone"?"phone_otp":s==="email"?"email_otp":void 0,l=o.choice.options.find(f=>f.service===u);return l!==void 0?x(o.choice,l.id):Promise.reject(new RangeError(`contact ${String(s)} is not offered`))},choose:s=>x(o.choice,s)};case"identity_summary":return{...o,...o.idNumberMasked===void 0&&o.summaryKind==="partial"&&h!==null?{idNumberMasked:h,nniMasked:h}:{},portrait:async()=>{let s=e.runtime.client;if(!o.portraitAvailable||s.identityPortrait===void 0)return null;try{return await s.identityPortrait()}catch{return null}},confirm:()=>F("confirm"),retake:()=>o.retakeAvailable?F("retake"):Promise.reject(new RangeError("no retake is left"))};case"liveness":return{...o,capture:s=>e.liveness(s),onLivePhoto:s=>o.livePhoto?.icao===!0&&e.onLivePhoto!==void 0?e.onLivePhoto(s):()=>{}};case"mobile_required":case"native_app_required":case"processing":return{...o,refresh:async()=>{r=!1,await e.refreshView()}};case"unsupported":case"result":return{...o};default:{let s=o;throw new Error(`runner: unhandled step ${JSON.stringify(s)}`)}}},A=o=>ge(k(o)),T=async()=>{if(!a){a=!0;try{for(let o of Cn){if(await e.sleep(o),!t||e.destroyed())return;let s=await e.refreshView().catch(()=>null);if(s!==null&&ee(s,{isMobile:e.isMobile()}).kind!=="processing")return}r=!0,M()}finally{a=!1}}},H=o=>{if(o.kind!=="liveness"||o.mode!=="selfie")return null;let s={kind:"processing",key:"processing",context:o.context,section:o.section,stalled:!1};if(y==="inflight")return s;if(!w||y==="done")return null;let u=e.keptFaceKey?.()??null;return u===null?null:(y="inflight",v("face_match",(l,f)=>l.submitCheck("face_match",{imageKey:u},{idempotencyKey:f}),()=>{y="done"}).then(()=>{y==="inflight"&&(y="done",M())},()=>{y="done",M()}),s)},R=(o,s=!1)=>{if(!t||e.destroyed()||e.chainBusy())return;let u=ee(o,{isMobile:e.isMobile()});u.kind==="registry"&&u.recheck&&(w=!0,y="idle"),u=H(u)??u,u.kind==="processing"?u.stalled=r:r=!1;let l=A(u),f=u.kind==="result"?void 0:u.context.switchable,_=f===void 0?l:{...l,chooseOption:b=>x({nodeId:f.nodeId,kind:f.kind,selected:f.current,options:f.options},b)},P=JSON.stringify(_);u.kind==="registry"&&u.source==="document"&&u.state==="pending"&&!S.has("registry")&&(S.add("registry"),_.confirm().catch(b=>{(!(b instanceof j)||In.has(b.code))&&S.delete("registry")})),!(!s&&P===i)&&(i=P,n=_,e.emitStep(_),u.kind==="processing"&&!r&&y!=="inflight"&&T(),u.kind==="result"&&!d&&(d=!0,e.emitResult(u.result)))};function M(){let o=e.currentView();o!==null&&R(o,!0)}return{run:async()=>{if(e.destroyed())throw new Error("verification destroyed");t=!0;let o=await e.ensureView();return n===null&&R(o),n??A(ee(o,{isMobile:e.isMobile()}))},current:()=>n,onView:o=>R(o),onChainIdle:()=>{let o=e.currentView();o!==null&&R(o)},republish:M,submit:v,faceProbeSkipped:()=>g}}function Mn(e){switch(e.kind){case"document":return"doc_ocr";case"liveness":return e.mode==="selfie"?"face_match":"liveness";case"portrait":return e.phase==="capture"?"portrait_icao":null;case"proof_of_address":return"poa";case"mobile_required":case"native_app_required":return e.checkType;case"unsupported":return e.checkType==="nfc_chip"?"nfc_chip":null;default:return null}}function On(e,t){let n=e,i=n?.plan?.steps??n?.steps;return Array.isArray(i)?i.some(r=>r.checkType===t&&typeof r.reason=="string"):!1}export{dt as a,Nn as b,Ve as c,Fe as d,Dn as e,rt as f,ee as g,Cn as h,Pn as i,lr as j};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{d as x}from"./chunk-VVUQ4PFU.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{c as f}from"./chunk-TSA6GHUG.js";import{a as h,c as y}from"./chunk-A7QFTU6M.js";var k=["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","simulated_capture_forbidden","native_app_required"];function K(t){return k.includes(t)}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 _(t,e,s=Math.random){let n=(t??e)*1e3,o=Math.min(Math.max(n,500),2e4),i=Math.round(o*(1+(s()*2-1)*.25));return Math.min(Math.max(i,500),2e4)}var R=6e4,b=4,I=3e4,M=9e5,E=200,P=5,C=400,A=new Set(["server_busy","request_timeout"]),v=2;function l(t){return(t.split(";")[0]??"").trim()}var O={liveness:"clipKey",face_match:"imageKey",doc_ocr:"imageKey"},N=`@sekyro/web/${h}`,H=N,g=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 s=e.fetch;this.fetchImpl=(n,o)=>(s??globalThis.fetch).call(globalThis,n,o),this.requestTimeoutMs=e.requestTimeoutMs??I,this.retryAttempts=e.inProgressRetry?.attempts??P,this.retryDelayMs=e.inProgressRetry?.delayMs??C,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 testerGate(e){return this.api("POST","/hosted/tester-gate",{body:{input:e}})}async reportCaptureIssue(e){let s=typeof e.name=="string"?e.name.replace(/[^A-Za-z]/g,"").slice(0,40):"",n=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,s,e.phase??""].join("|"),a=this.reportedIssues.get(i);if(a!==void 0)return a;let d={check:e.check,kind:e.kind,...s!==""?{name:s}:{},...e.phase!==void 0?{phase:e.phase}:{},...n!==void 0?{engineKind:n}:{},...o!==void 0?{attempt:o}:{},...e.formFactor!==void 0?{formFactor:e.formFactor}:{},...typeof e.detail=="string"&&/^\d{1,10}$/.test(e.detail)?{detail:e.detail}:{},...T(e.challengeMs)?{challengeMs:e.challengeMs}:{},...T(e.readyMs)?{readyMs:e.readyMs}:{},...e.inApp===!0?{inApp:!0}:{}},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,s){let n=await this.api("POST","/hosted/choice",{body:{nodeId:e,option:s},busyRetry:!0});return this.sessionId=n.sessionId,n}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,s,n,o={}){let i=await this.ensureSessionId(),a={kind:e,contentType:l(s),contentLength:n,...o.source==="upload"?{source:"upload"}:{}};return this.api("POST",`/sessions/${i}/media`,{body:a})}armCapture(e=2){this.fillCaptureNonces(e)}async presignCapture(e,s,n,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(s),contentLength:n,capture:d};return this.api("POST",`/sessions/${i}/media`,{body:r})}async takeCaptureNonce(){let e=()=>{let s=Date.now();return this.captureNonces=this.captureNonces.filter(n=>n.expiresAt-R>s),this.captureNonces.shift()?.nonce};for(let s=0;s<2;s++){let n=e();if(n!==void 0)return n;await this.fillCaptureNonces(1)}return e()}fillCaptureNonces(e){return this.captureFetch??(this.captureFetch=(async()=>{try{let s=await this.ensureSessionId(),n=await this.api("POST",`/sessions/${s}/media/capture-nonces`,{body:{count:Math.min(b,Math.max(1,e))}}),o=Date.now()+Math.max(0,n.expiresIn)*1e3;for(let i of Array.isArray(n.nonces)?n.nonces:[])typeof i=="string"&&i.length>0&&this.captureNonces.push({nonce:i,expiresAt:o});this.captureNonces=this.captureNonces.slice(-b)}catch{}})().finally(()=>{this.captureFetch=null})),this.captureFetch}async uploadToSpaces(e,s,n){let o;try{o=await this.fetchImpl(e,{method:"PUT",headers:{"content-type":l(n)},body:s,signal:AbortSignal.timeout(M)})}catch(i){throw m(i)}if(!o.ok){let i=(await o.text().catch(()=>"")).slice(0,E);throw new c({status:o.status,code:"upload_failed",message:`media upload failed (HTTP ${o.status})${i?`: ${i}`:""}`})}}async completeMedia(e){let s=await this.ensureSessionId();return this.api("POST",`/sessions/${s}/media/complete`,{body:{key:e}})}async submitCheck(e,s,n={}){let o=await this.ensureSessionId(),i={input:s,forceOutcome:n.forceOutcome};return this.api("POST",`/sessions/${o}/checks/${e}`,{body:i,idempotencyKey:n.idempotencyKey,busyRetry:n.idempotencyKey!==void 0})}async uploadAndSubmit(e,s,n,o={}){let i=l(s.contentType),a=await this.presign(s.kind,i,s.blob.size);await this.uploadToSpaces(a.uploadUrl,s.blob,i);let d=await this.completeMedia(a.key),r={...n,[O[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,s,n={}){let o=e==="GET"||n.busyRetry===!0,i=`${this.apiOrigin}/api/v2${s}`,a={"x-session-token":this.sessionToken,"x-sekyro-sdk":H};n.body!==void 0&&(a["content-type"]="application/json"),n.idempotencyKey!==void 0&&(a["x-idempotency-key"]=n.idempotencyKey);try{let d=y.timezone();d!==void 0&&(a["sekyro-client-timezone"]=d)}catch{}a["sekyro-client-form-factor"]=f();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,...n.body!==void 0?{body:JSON.stringify(n.body)}:{},cache:"no-store",signal:AbortSignal.timeout(this.requestTimeoutMs)})}catch(p){throw m(p)}if(r.ok){if(n.empty===!0)return;if(n.blob===!0)try{return await r.blob()}catch(w){throw m(w)}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 x(p)}let u=await D(r);if(u.code==="idempotency_in_progress"&&d<this.retryAttempts){this.retryDelayMs>0&&await S(this.retryDelayMs);continue}if(o&&u.status===503&&A.has(u.code)){o=!1,await S(_(u.retryAfterSeconds,v,this.random));continue}throw u}}};function T(t){return typeof t=="number"&&Number.isInteger(t)&&t>=0&&t<=6e5}function m(t){if((typeof t=="object"&&t!==null?t.name:void 0)==="TimeoutError")return new c({status:0,code:"timeout",message:"request timed out"});let s=t instanceof Error?t.message:String(t);return new c({status:0,code:"network_error",message:`network request failed: ${s}`})}function x(t){return t!==null&&typeof t=="object"&&"success"in t&&"data"in t?t.data:t}async function D(t){let e="unknown_error",s=`request failed (HTTP ${t.status})`,n=Number.NaN,o;try{let d=await t.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&&(s=r.message),typeof r.retryAfterSeconds=="number"&&(n=r.retryAfterSeconds),Array.isArray(r.details?.issues)?o=r.details:Array.isArray(r.details?.errors)&&(o={...r.details,issues:[]})}}catch{}let i=t.headers.get("retry-after"),a=i===null?Math.floor(n):Number.parseInt(i,10);return new c({status:t.status,code:e,message:s,...Number.isFinite(a)&&a>=0?{retryAfterSeconds:a}:{},details:o})}function S(t){return new Promise(e=>setTimeout(e,t))}function j(t){let e=t?.portrait,s=e?.icao,n=e?.purpose==="id_document";return s==null?n?{policy:"reject",profile:"id_document"}:null:{policy:s.policy==="alert"?"alert":"reject",profile:n||s.profile==="id_document"?"id_document":"selfie"}}function B(t){return{...t.baselineEyeOpenness!==void 0?{baselineEyeOpenness:t.baselineEyeOpenness}:{},...t.baselineEyeOpennessLeft!==void 0&&t.baselineEyeOpennessRight!==void 0?{baselineEyeOpennessLeft:t.baselineEyeOpennessLeft,baselineEyeOpennessRight:t.baselineEyeOpennessRight}:{},criteria:t.verdict??{},...t.backgroundCheck!==void 0?{backgroundCheck:t.backgroundCheck}:{}}}export{k as a,K as b,c,_ as d,l as e,N as f,g,j as h,B as i};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{B as tt,C as nt,D as ot,E as rt,a as je,b as Ye,c as $e,d as K,e as z,f as ee,g as We,h as L,i as Qe,j as R,k as D,l as M,m as U,n as N,o as j,p as Ze,q as Y,r as te,s as Je,t as Xe,u as ze,v as et}from"./chunk-UTPUHE4J.js";import{n as qe}from"./chunk-7252SFZ6.js";import{a as Be}from"./chunk-7QZWBDI5.js";import{c as fe,e as Ge,g as Ke,h as ne}from"./chunk-ODI4A5K4.js";import{c as De,d as pe}from"./chunk-TSA6GHUG.js";import{b as Ue}from"./chunk-A7QFTU6M.js";function oe(e){return e.idNumberBound??e.nniBound}function $(e){return e===void 0?void 0:e.idNumberFromDocument??e.nniFromDocument}function it(e){let t=e.idNumberMasked??e.nniMasked;return typeof t=="string"&&t!==""?t:void 0}var Ht="https://api.sekyro.ai",Lt=5e3,Dt=24e4,Ut=12e4,Bt=3,qt=3e3,Gt=1500,Kt=10;function st(e){return e instanceof Error&&e.name==="ChallengeError"&&e.code||"challenge_failed"}var at=new Set(["aborted","embedder_opaque","site_key_rejected"]);function jt(e){return new Promise(t=>setTimeout(t,e))}function Yt(){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 n=[...t].map(i=>i.toString(16).padStart(2,"0")).join("");return`${n.slice(0,8)}-${n.slice(8,12)}-${n.slice(12,16)}-${n.slice(16,20)}-${n.slice(20)}`}function so(e){return $t(e,{})}function $t(e,t){let n=e.apiOrigin??Ht,i=e.autoRetry??!0,o=e.rearm??"auto",s=t.client??new Ke({apiOrigin:n,sessionToken:e.clientToken,fetch:e.fetch}),a=t.sleep??jt,c=t.uuid??Yt,f=t.getChallengeToken??((r,u)=>import("./challenge-frame-YAQJ5YMB.js").then(l=>l.executeChallenge({frameUrl:r.url,siteKey:r.siteKey,action:"liveness",subject:u.subject,signal:u.signal}))),g=Be(),S=null,P=null,d=!1,k=new AbortController,m=null,T=null,W=null,Q=()=>W??Je(m),ke=()=>Xe(te(m),Q()),I=r=>{m=r,g.emit("view",r),S?.onView(r)},b=()=>m!==null?Promise.resolve(m):(T??(T=s.getSession().then(r=>(I(r),r)).finally(()=>{T=null})),T),O=async()=>{let r=await s.getSession();return I(r),r},ie=async(r,u)=>{r.plan!==void 0?I(r):await O()},se=null,be=async r=>{let u=await b();if(r||!u.consentRecorded){let l=await s.recordConsent(e.locale);l.plan!==void 0?I(l):m!==null&&I({...m,consentRecorded:!0})}Ve(u)},V=r=>r?.force===!0?be(!0):(se??(se=be(!1).finally(()=>{se=null})),se),ae={client:s,ensureConsent:r=>V(r),sleep:a,uuid:c,...t.random!==void 0?{random:t.random}:{},onBusy:r=>{d||g.emit("busy",r)}},xe=!1,Ae=null,ue=r=>{if(r.status==="verified"||r.status==="not_verified"||r.status==="review"){if(xe)return;xe=!0}Ae=JSON.stringify(r),g.emit("result",r)},xt=r=>{Ae!==JSON.stringify(r)&&ue(r)},we=async r=>{let u=m;r&&(u=await O().catch(()=>m));let l=u===null?null:L(u);return l!==null&&!d&&g.emit("method",l),l!==null},Pe=null,Re=!1,Ie=!1,Oe=()=>nt(ae,(r,u)=>r.submitCheck("population_registry",{},{idempotencyKey:u})),Ee=r=>oe(r)===!0||$(M(r,"population_registry"))===!0,At=async()=>{try{let r=await b();if(R(r)||L(r)!==null||D(r)?.checkType!=="population_registry")return;if(!Ee(r)&&$(M(r,"population_registry"))===void 0&&(r=await O()),!Ee(r)){Ie=!0;return}await V(),await ie(await Oe(),"population_registry");let u=m===null?void 0:M(m,"population_registry");if(u?.state==="input_required"&&u.reason==="registry_unavailable"&&ee(u)>0){if(await a(Lt),d)return;await ie(await Oe(),"population_registry")}}catch(r){if(r instanceof fe&&(r.code==="check_not_active"||r.code==="step_not_on_path")){await O().catch(()=>{});return}Re=!0;return}m!==null&&R(m)&&ue(j(m,{autoRetry:i}))},Me=()=>(Pe??(Pe=At()),Pe),Z=t.now??Date.now,H=null,B,ce,wt=0,de=(r,u)=>`${r.url}
|
|
2
|
+
${r.siteKey}
|
|
3
|
+
${u}`,le=(r,u)=>{let l=Z(),h=f(r,{signal:k.signal,subject:u}),p={key:de(r,u),at:l,token:h};return h.then(()=>{p.issuedAt=Z(),ce=void 0},C=>{let w=st(C);if(p.failed=w,d||w==="aborted")return;ce=w;let{detail:A,readyMs:y}=C;q({check:"attestation",kind:"unavailable",engineKind:w,attempt:wt++,challengeMs:Z()-l,readyMs:y,detail:A,inApp:Ue()})}),h.catch(()=>{}),p},ve=(r,u)=>r!==null&&r.key===u&&(r.issuedAt===void 0||Z()-r.issuedAt<Dt),Ve=(r,u={})=>{let l=r?.challenge??null;if(r===null||l===null||d)return;let h=U(r.sessionId),p=H;(u.replaceFailed===!0&&p?.failed!==void 0&&!at.has(p.failed)||!ve(p,de(l,h)))&&(H=le(l,h))},Pt=async(r,u)=>{let l=de(r,u),h=H;H=null;let p=ve(h,l)?h:le(r,u),C=p===h?0:1,w,A=new Promise(y=>{w=setTimeout(()=>y("late"),Ut)});try{for(;;){let y=await Promise.race([p.token.then(E=>({token:E}),E=>({error:st(E)})),A]);if(y==="late")return!d&&H===null&&(H=p),{error:ce??"timeout"};if("token"in y||d||at.has(y.error)||C>=Bt||C>0&&await Promise.race([a(qt*C),A])==="late")return y;if(d)return{error:"aborted"};C+=1,p=le(r,u)}}finally{clearTimeout(w)}},Te=async()=>{B=void 0;let r=await b(),u=r.challenge;if(u==null)return{};let l=await Pt(u,U(r.sessionId));if("token"in l)return{channel:"hosted_web",turnstileToken:l.token};if(B=l.error,r.simulation!==void 0)return{channel:"hosted_web"};throw new tt(l.error)},Rt=()=>B,q=r=>{if(d)return;let u=s.reportCaptureIssue;if(u===void 0)return;let l=r.formFactor;try{l??(l=De())}catch{}try{Promise.resolve(u.call(s,{...r,...l!==void 0?{formFactor:l}:{}})).catch(()=>{})}catch{}},x=null,Ne=Promise.resolve(),G=0,It=async()=>{let r=await b();for(let u=0;u<Kt&&!d&&!R(r)&&D(r)===void 0&&z(r).some(l=>l.state==="processing")&&(await a(Gt),!d);u+=1)r=await O();return r},Ot=async(r,u,l)=>{let{capture:h}=r,p=()=>d,C=()=>r.alive&&r.attempt===l,w=y=>{C()&&h.setFlowState(y)},A=y=>{if(!p()&&(y.status==="unavailable"&&y.reasonCode!==void 0&&!je(y.reasonCode)&&q({check:"liveness",kind:"unavailable",phase:"upload",engineKind:y.reasonCode,attempt:Math.max(0,r.issues.value)}),ue(y),!!C())){if(y.status==="retry"&&o==="auto"){h.handle.retry();return}h.setFlowState("done")}};if(u.degraded==="NO_RECORDER"){let y=m?.sessionId??(await b().catch(()=>null))?.sessionId??"";A(N(y,"no_recorder"));return}w("uploading");try{if(await Me(),p())return;let y=await b(),E;if(!R(y)&&L(y)!==null){await we(!1),A(N(y.sessionId,"method_required"));return}if(!R(y)){if(D(y)?.checkType==="population_registry"){A(N(y.sessionId,Ie?"nni_unbound":Re?"network":"registry_unavailable"));return}if(await V(),p())return;E=m??y;let J=await ot({...ae,artifacts:u,getAttestation:Te,attestationError:Rt,getView:()=>m??y,refreshView:O,applySubmit:ie,onPhase:w,isCancelled:p,onKeyframePromoted:X=>{P=X}});if(p())return;if(J.kind==="unavailable"){let X=N(y.sessionId,J.reason),Le=J.reason==="attestation"?B:void 0;A(Le!==void 0?{...X,attestationError:Le}:X);return}if(J.kind==="resync"&&await O(),m!==null&&L(m)!==null){await we(!1),A(N(y.sessionId,"method_required"));return}y=await It()}A(j(y,{autoRetry:i,previous:E}))}catch{if(p())return;A(N(m?.sessionId??"","network"))}},Et=(r,u)=>{let l=r.attempt;G>0&&r.alive&&r.capture.setFlowState("uploading"),G+=1,Ne=Ne.then(()=>Ot(r,u,l)).finally(()=>{G-=1,G===0&&S?.onChainIdle()}).catch(()=>{})},Fe=r=>{x?.capture.handle.destroy(),x!==null&&(x.alive=!1);let u=qe(r,S?.captureInternals?.(r)??t.capture,()=>m?.capture?.liveness?.keyframe?.rank===!0,ke,()=>m?.capture?.liveness?.screenRamp,{session:()=>te(m),onModeChange:p=>{W=p}}),l={capture:u,alive:!0,attempt:0,issues:$e()};x=l,u.handle.on("error",p=>{q(Ye("liveness",p,l.issues.value))}),u.handle.on("state",p=>{if(l.issues.note(p),p==="starting"){l.attempt+=1,Ve(m,{replaceFailed:!0});let C=m===null?void 0:D(m)?.checkType;(C==="liveness"||C==="face_match")&&V().catch(()=>{})}}),u.handle.on("captured",p=>{Promise.resolve().then(()=>Et(l,p))});let h=u.handle;return{get state(){return h.state},get captureMode(){return h.captureMode},get facingMode(){return h.facingMode},on:(p,C)=>h.on(p,C),start:async p=>{if(m===null&&await b().catch(()=>{}),!!l.alive)return h.start(p)},retry:()=>h.retry(),switchCamera:()=>h.switchCamera(),canSwitchCaptureMode:()=>h.canSwitchCaptureMode(),setCaptureMode:p=>h.setCaptureMode(p),destroy:()=>{l.alive=!1,x===l&&(x=null),h.destroy()}}},Mt=async()=>{if(d)return null;try{let r=await b();return d?null:L(r)}catch{return null}},vt=async()=>{if(d)return"self";try{let r=await b();if(d)return"self";let u=te(r);return u==="choice"?Q()??u:u}catch{return"self"}},Vt=async()=>{if(d)return!1;try{let r=await b();return d||R(r)||pe()?!1:Y(r,D(r))==="phone"||Y(r,M(r,"liveness"))==="phone"}catch{return!1}},Tt=async()=>{if(d)return!1;try{let r=await b();return!d&&r.returning===!0}catch{return!1}},Nt=async r=>{let u=(await b()).plan?.choice,l=u?.options.find(p=>K[p.service]===r);if(!l)throw new RangeError(`method ${String(r)} is not offered`);let h=await s.choose(u.nodeId,l.id);d||I(h)},He=null,Ft=()=>(He??(He=import("./plan-runner-IXCKR4DB.js").then(r=>{let u=r.createPlanRunner({runtime:ae,currentView:()=>m,cameraMode:ke,captureModeSwitch:{pick:Q,choose:l=>{W=l}},ensureView:b,refreshView:O,ensureConsent:()=>V(),liveness:Fe,stopLiveness:()=>{x!==null&&(x.alive=!1,x.capture.handle.destroy(),x=null)},chainBusy:()=>G>0,destroyed:()=>d,sleep:a,isMobile:pe,now:t.now??Date.now,keptFaceKey:()=>P,setView:I,baseCapture:t.capture,emitStep:l=>{d||g.emit("step",l)},emitResult:xt,reportCaptureIssue:q,documentInternals:t.document,portraitInternals:t.portrait,livePhotoInternals:t.livePhoto,uploadInternals:t.upload,pageCameraInternals:t.pageCamera});return S=u,u})),He);return{consent:()=>V(),startRegistry:Me,methodChoice:Mt,selectMethod:Nt,reportCameraUnavailable:async r=>{await V();let u=s.reportCameraUnavailable;if(u===void 0)throw new TypeError("this client cannot report a missing camera");let l=await u.call(s,r).catch(h=>{if(h instanceof fe&&h.code==="check_out_of_order")return s.getSession();throw h});d||I(l)},reportCaptureIssue:q,testerGate:async r=>{let u=s.testerGate;if(u===void 0)throw new TypeError("this client cannot run the tester gate");let l=r.clip,h=Ge(r.clipMime??"");if(l===void 0||!et.includes(h))throw new TypeError("the capture has no clip");await V();let p=await ze(s,"clip",h,l.size,{engine:r.engine,durationMs:r.clipMs});await s.uploadToSpaces(p.uploadUrl,l,h);let{key:C}=await s.completeMedia(p.key),w=await Te(),A=await u.call(s,{clipKey:C,attestation:w,captureChannel:r.captureChannel,capture:{...rt(r),attestationError:B}}),{bound:y,...E}=A;return d||(E.plan!==void 0?I(E):await O()),{bound:y===!0}},mobileRequired:Vt,captureMode:vt,chooseCaptureMode:r=>{W=r},get captureChoice(){return Q()},returning:Tt,liveness:Fe,run:async()=>{if(d)throw new Error("verification destroyed");return(await Ft()).run()},currentStep:()=>S?.current()??null,voiceClips:async()=>{if(d)return null;try{let r=await b();return d?null:r.voice??null}catch{return null}},on:(r,u)=>g.on(r,u),destroy:()=>{d=!0,k.abort(),S?.destroy(),x!==null&&(x.alive=!1,x.capture.handle.destroy(),x=null),g.clear()}}}var ut=["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 Wt=["carte_identite","passport","residence_permit","drivers_license"],Qt=["carte_identite","passport","residence_permit"];function Zt(e,t){let n=e.byIssuer?.[t]??e.default;return Wt.filter(i=>n==="*"?Qt.includes(i):n.includes(i))}function lo(e,t=ut){return[...new Set([...t,...Object.keys(e.byIssuer??{})])].filter(i=>Zt(e,i).length>0).sort()}function ct(e){if(e.acceptedDocuments)return e.acceptedDocuments;let t=e.acceptedDocumentTypes?.length?[...e.acceptedDocumentTypes]:["carte_identite","passport"];return{default:[],byIssuer:{MR:t}}}function po(e){return/^[A-Z]{2}$/.test(e)?String.fromCodePoint(...[...e].map(t=>127462+t.charCodeAt(0)-65)):""}var _={fullNameMin:2,fullName:200,email:254,occupation:120,shortText:120,longText:1e3,addressLine:120,addressLines:4,city:80,postcode:16,number:1e12,dateMin:"1900-01-01",dateMax:"2100-12-31"},Jt=new Set(["full_name","birth_date","email","phone","address","country","occupation"]),Xt=new Set(["short_text","long_text","single_choice","multiple_choice","yes_no","date","number"]),zt=new Set(["ar","fa","he","ur"]);function dt(e){return zt.has(e.split("-")[0]?.toLowerCase()??"")?"rtl":"ltr"}function lt(e){if(typeof e!="object"||e===null)return null;let t=e;if(typeof t.locale!="string"||!Array.isArray(t.questions)||t.questions.length===0)return null;let n=t.consents??[];if(!Array.isArray(n))return null;for(let o of t.questions)if(!en(o))return null;for(let o of n)if(!tn(o))return null;let i={locale:t.locale,questions:t.questions,consents:n};return typeof t.title=="string"&&t.title.trim()!==""&&(i.title=t.title),typeof t.intro=="string"&&t.intro.trim()!==""&&(i.intro=t.intro),typeof t.prefill=="object"&&t.prefill!==null&&!Array.isArray(t.prefill)&&(i.prefill=t.prefill),i}function en(e){if(typeof e!="object"||e===null)return!1;let t=e;return typeof t.id!="string"||typeof t.required!="boolean"?!1:t.kind==="field"?typeof t.field=="string"&&Jt.has(t.field):t.kind!=="custom"||typeof t.type!="string"||!Xt.has(t.type)||typeof t.label!="string"?!1:t.type==="single_choice"||t.type==="multiple_choice"?Array.isArray(t.choices)&&t.choices.length>=2&&t.choices.every(n=>typeof n=="object"&&n!==null&&typeof n.value=="string"&&typeof n.label=="string"):!0}function tn(e){if(typeof e!="object"||e===null)return!1;let t=e;if(typeof t.id!="string"||typeof t.required!="boolean"||typeof t.text!="string")return!1;if(t.link===void 0)return!0;let n=t.link;return typeof n=="object"&&n!==null&&typeof n.url=="string"&&/^https:\/\//.test(n.url)&&typeof n.label=="string"}var nn=/^(\d{4})-(\d{2})-(\d{2})$/;function on(e){if(typeof e!="string")return!1;let t=nn.exec(e);return t===null?!1:new Date(Date.UTC(Number(t[1]),Number(t[2])-1,Number(t[3]))).toISOString().slice(0,10)===e&&e>=_.dateMin&&e<=_.dateMax}function rn(e){return typeof e=="number"&&Number.isFinite(e)&&Math.abs(e)<_.number&&Math.round(e*100)/100===e}function pt(e){for(let t of e.matchAll(/\d[\d -]{11,}\d/g)){let n=t[0].replace(/[ -]/g,"");if(n.length>=13&&n.length<=19&&sn(n))return!0}return!1}function sn(e){let t=0;for(let n=0;n<e.length;n++){let i=Number(e[e.length-1-n]);n%2===1&&(i*=2,i>9&&(i-=9)),t+=i}return t%10===0}var an=/^[^\s@]+@[^\s@.]+(\.[^\s@.]+)+$/,un=/^\+[1-9]\d{6,14}$/,ft=/^[A-Z]{2}$/,cn=e=>e===void 0||typeof e=="string"&&e.trim()===""||Array.isArray(e)&&e.length===0;function dn(e=Date.now()){return new Date(e).toISOString().slice(0,10)}function mo(e,t,n=dn()){let i=[];for(let o of e.questions){let s=t.answers[o.id];if(cn(s)){o.required&&i.push({id:o.id,code:"required"});continue}let a=o.kind==="field"?ln(o.field,s,n):fn(o,s,n);a!==null&&i.push({id:o.id,...a})}for(let o of e.consents)o.required&&t.consents[o.id]!==!0&&i.push({id:o.id,code:"consent_required"});return i}function re(e,t,n=1){if(typeof e!="string")return{code:"required"};let i=e.trim();return[...i].length>t?{code:"too_long",params:{max:t}}:[...i].length<n?{code:"too_short",params:{min:n}}:pt(i)?{code:"card_number"}:null}function mt(e,t,n={}){return on(e)?n.period==="past"&&e>=t?{code:"date_not_past"}:n.period==="future"&&e<=t?{code:"date_not_future"}:n.min!==void 0&&e<n.min?{code:"date_too_early",params:{date:n.min}}:n.max!==void 0&&e>n.max?{code:"date_too_late",params:{date:n.max}}:null:{code:"date_invalid"}}function ln(e,t,n){switch(e){case"full_name":return re(t,_.fullName,_.fullNameMin);case"occupation":return re(t,_.occupation);case"birth_date":return mt(t,n,{period:"past"});case"email":return typeof t=="string"&&t.trim().length<=_.email&&an.test(t.trim())?null:{code:"email_invalid"};case"phone":return typeof t=="string"&&un.test(t)?null:{code:"phone_invalid"};case"country":return typeof t=="string"&&ft.test(t)?null:{code:"choice_invalid"};case"address":return pn(t)?null:{code:"address_invalid"};default:return null}}function pn(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=e,n=Array.isArray(t.lines)?t.lines.filter(i=>typeof i=="string"&&i.trim()!==""):[];return typeof t.country=="string"&&ft.test(t.country)&&typeof t.city=="string"&&t.city.trim()!==""&&t.city.trim().length<=_.city&&n.length>=1&&n.length<=_.addressLines&&n.every(i=>i.trim().length<=_.addressLine&&!pt(i))&&(t.postcode===void 0||typeof t.postcode=="string"&&t.postcode.trim().length<=_.postcode)}function fn(e,t,n){let i=new Set((e.choices??[]).map(o=>o.value));switch(e.type){case"short_text":return re(t,_.shortText);case"long_text":return re(t,_.longText);case"single_choice":return typeof t=="string"&&i.has(t)?null:{code:"choice_invalid"};case"multiple_choice":return Array.isArray(t)&&t.length>0&&new Set(t).size===t.length&&t.every(o=>i.has(o))?null:{code:"choice_invalid"};case"yes_no":return typeof t=="boolean"?null:{code:"choice_invalid"};case"date":{let o=e.options??{};return mt(t,n,{...typeof o.min=="string"?{min:o.min}:{},...typeof o.max=="string"?{max:o.max}:{},...o.period==="past"||o.period==="future"?{period:o.period}:{}})}case"number":{if(typeof t!="number"||!Number.isFinite(t)||Math.abs(t)>=_.number)return{code:"number_invalid"};let o=e.options??{};return o.integer===!0&&!Number.isInteger(t)?{code:"number_not_integer"}:rn(t)?typeof o.min=="number"&&t<o.min?{code:"number_too_small",params:{min:o.min}}:typeof o.max=="number"&&t>o.max?{code:"number_too_large",params:{max:o.max}}:null:{code:"number_decimals"}}default:return null}}var ho={full_name:_.fullName,occupation:_.occupation,email:_.email,short_text:_.shortText,long_text:_.longText};var ht=Object.freeze({nni_invalid:"id_number_invalid",nni_not_found:"registry_record_not_found",nni_recheck:"id_number_recheck",document_nni_mismatch:"document_id_number_mismatch",nni_locked:"id_number_locked",nni_unbound:"id_number_unbound",missing_nni:"missing_id_number",registry_needs_nni_source:"registry_needs_id_number_source"}),mn=new Map(Object.entries(ht)),go=new Map(Object.entries(ht).map(([e,t])=>[t,e]));function yt(e){return mn.get(e)??e}var Po=["national_number","document_photo","national_eid"],hn=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","proof_of_address","form"]),yn=new Set(["supplied_identity","aml_screening","face_dedup","age_estimation"]),he=["document","population_registry","national_eid"],ye=["phone_otp","email_otp"],_t={identity_method:he,contact:ye},gn=["population_registry","document"],ge="platform_unsupported",Sn=new Set(["prefilled","user_entered","prefilled_or_entered"]),_n={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",poa:"documents",form:"form"};function v(e){return e.section??_n[e.checkType]??null}function Cn(e,t){let n=e.plan?.choice;if(n===void 0||n.locked)return;let i=n.options.find(o=>o.id!==n.selected&&o.available!==!1&&t.includes(o.service));return i===void 0?void 0:{nodeId:n.nodeId,option:i}}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||R(e))return null;let i=_t[n.kind]??[...he,...ye],o=n.options.flatMap(c=>c.available===!1||!i.includes(c.service)?[]:[c.nationalEid!=null?{id:c.id,service:c.service,nationalEid:c.nationalEid}:{id:c.id,service:c.service}]),s=t.steps.find(c=>c.id===t.current)?.service,a=n.selected??o.find(c=>c.service===s)?.id??null;return o.some(c=>c.id!==a)?{nodeId:n.nodeId,kind:n.kind,current:a,options:o}:null}function Ct(e){return e==null?[]:e.options.filter(t=>t.id!==e.current)}function kn(e){let t=e.simulation;if(typeof t!="object"||t===null)return;let{otpCode:n,skipCapture:i}=t;if(typeof n!="string"||n===""||typeof i!="boolean")return;let o=Ze(e);return o!==void 0?{otpCode:n,skipCapture:i,reason:o}:{otpCode:n,skipCapture:i}}function bn(e){let t=(e.plan?.sections??[]).map(a=>({id:a.id,state:a.state})),n={sessionId:U(e.sessionId),orgName:e.orgName,sandbox:e.sandbox===!0,returning:e.returning===!0,consentRecorded:e.consentRecorded,expiresAt:e.expiresAt,sections:t.map(a=>a.id),progress:t,purpose:e.purpose??"identity"};e.branding!==void 0&&(n.branding=e.branding),e.cameraUnavailableHandled===!0&&(n.cameraUnavailableHandled=!0);let i=kn(e);i!==void 0&&(n.simulation=i);let o=e.testerGate;o?.offered===!0&&typeof o.attemptsLeft=="number"&&o.attemptsLeft>0&&(n.testerGate={attemptsLeft:o.attemptsLeft});let s=Se(e);return s!==null&&(n.switchable=s),n}function xn(e){let t={attemptsRemaining:ee(e),attemptsExhausted:e.attempts.used>=e.attempts.max};return e.reason!==void 0&&(t.reason=e.reason),e.retakeHint!==void 0&&(t.retakeHint=e.retakeHint),t}var kt={phone_otp:"phone",email_otp:"email"};function An(e,t){let n=Cn(e,[t==="phone_otp"?"email_otp":"phone_otp"]);return n===void 0?void 0:kt[n.option.service]}function wn(e,t,n,i){let o=t.checkType==="email_otp",s=(o?t.emailOtp:t.otp)??{},a=o?t.emailOtp?.emailSource:t.otp?.numberSource,c=a!==void 0&&Sn.has(a)?a:o?"prefilled_or_entered":"user_entered",f=typeof s.sentToMasked=="string"&&s.sentToMasked.length>0,g=s.prefilled===!0,S=An(e,o?"email_otp":"phone_otp"),P={key:t.checkType,context:n,section:v(t),phase:f?"verify":"send",canSwitch:S!==void 0,...i},d=o?{kind:"email_otp",...P,emailSource:c,needsEmail:c!=="prefilled"&&!g}:{kind:"phone_otp",...P,numberSource:c,needsPhone:c!=="prefilled"&&!g,channels:(t.otp?.channels??[]).filter(k=>k==="whatsapp"||k==="sms")};if(S!==void 0&&(d.switchChannel=S),g&&(d.prefilled=!0),f&&(d.sentToMasked=s.sentToMasked),!o&&t.otp?.channel!==void 0&&(d.channel=t.otp.channel),!o&&Array.isArray(t.phoneCountries)&&(d.phoneCountries=t.phoneCountries.filter(k=>typeof k=="string"&&/^[A-Z]{2}$/.test(k))),!o&&Array.isArray(t.phoneRules)){let k=d.phoneCountries??[];d.phoneRules=t.phoneRules.flatMap(m=>{let T=In(m);return T!==void 0&&k.includes(T.code)?[T]:[]})}return!o&&t.phoneInternational===!0&&(d.phoneInternational=!0),s.expiresAt!==void 0&&(d.codeExpiresAt=s.expiresAt),s.resendAvailableAt!==void 0&&(d.resendAvailableAt=s.resendAvailableAt),d}var Pn=/^[\d[\]\-|()?:^]{1,64}$/;function Rn(e){try{return typeof e=="string"&&Pn.test(e)&&new RegExp(e)!==null}catch{return!1}}var gt=e=>typeof e=="number"&&Number.isInteger(e)&&e>=1&&e<=15;function In(e){let{code:t,dial:n,trunk:i,lengths:o,formats:s}=e??{};if(typeof t!="string"||typeof n!="string"||!/^\d{1,3}$/.test(n)||i!==void 0&&(typeof i!="string"||!/^\d{1,3}$/.test(i))||!Array.isArray(o)||o.length===0||!o.every(gt))return;let a={code:t,dial:n,lengths:[...o].sort((c,f)=>c-f)};if(i!==void 0&&(a.trunk=i),s!==void 0){if(!(Array.isArray(s)&&s.length<=8&&s.every(f=>Rn(f?.leading)&&Array.isArray(f.groups)&&f.groups.every(gt)&&o.includes(f.groups.reduce((g,S)=>g+S,0)))))return;a.formats=s.map(f=>({leading:f.leading,groups:[...f.groups]}))}return a}function On(e,t,n,i){let o=oe(e)===!0?"bound":$(t)===!0?"document":"typed",s=o==="typed"&&t.state==="input_required"&&t.reason!==void 0&&yt(t.reason)==="id_number_recheck",a=Ct(Se(e)),c=!i.attemptsExhausted&&a.length===1&&a[0]?.service==="document";return{kind:"registry",key:"registry",context:n,section:v(t),state:t.state==="input_required"?"input_required":"pending",source:o,recheck:s,canUseDocument:c,...i}}function En(e,t,n,i,o){let s=[...t.acceptedSides??[]],a={kind:"document",key:"document",context:n,section:v(t),side:s.includes("recto")?"verso":"recto",acceptedSides:s,documents:ct(e),photo:Ce(_e(e.documents),o),...i};return e.detectedCountry!==void 0&&(a.detectedCountry=e.detectedCountry),Vn(e)&&(a.ageStepUp=!0),a}function _e(e,t=!0){let n=e?.source==="upload"||e?.source==="choice"?e.source:"camera",i=e?.sourcePick==="camera"||e?.sourcePick==="upload"?e.sourcePick:null;return{source:n,pick:i,uploadOffered:t&&e?.uploadOffered===!0}}function Ce(e,t){return t?{...e,cameraOnPhone:!0}:e}var Mn=10*1024*1024;function vn(e,t,n,i,o){let s=e.proofOfAddress,a=s?.pdf?.maxBytes,c=s?.phase==="holder_letter"?"holder_letter":"document";return{kind:"proof_of_address",key:"proof_of_address",context:n,section:v(t),phase:c,rule:s?.rule??{country:null,countryFrom:"global",source:"preset_global",kinds:[]},nameMatch:s?.nameMatch??"exact_person",photo:Ce(_e(s),o),maxPages:3,pdf:{maxBytes:typeof a=="number"&&a>0?a:Mn,maxPages:3},licenceAddressAccepted:c==="document"&&s?.licenceAddressAccepted===!0,...i}}function Vn(e){let t=z(e).find(i=>i.checkType==="age_estimation"),n=t?.reason;return t?.state==="failed"&&(n==="age_uncertain"||n==="age_unavailable")}function Tn(e){let t=M(e,"liveness");return t?.state==="passed"||t?.state==="review"}function St(e,t,n,i,o,s=!1){let a=t.icao?.report,c=e.portrait,f=o==="capture"?c?.pendingFix??null:null;f!==null&&(o="review");let g=bt(e);return{kind:"portrait",key:`portrait:${o}`,context:n,section:v(t),phase:o,report:Array.isArray(a)?a:null,review:t.state==="review",tuning:e.capture?.icao??null,tuningVersion:e.capture?.tuningVersion??null,icao:ne(e),retakeOnly:o==="capture"&&t.state==="input_required"&&g===void 0&&e.capture?.livePhoto?.oneCapture===!0&&Tn(e),photo:Ce(_e(c,o==="capture"),s&&o==="capture"),pendingFix:f,...g!==void 0?{captureMode:g}:{},...c?.reuse?.pending===!0?{reuse:!0}:{},...i}}function bt(e){let t=e.portrait?.captureMode;return t==="self"||t==="assisted"||t==="choice"?t:void 0}var me={minLongSidePx:1280,jpegQuality:.95};function Nn(e,t){let n=e.capture?.livePhoto;if(n?.oneCapture!==!0)return null;let i=M(e,"portrait_icao"),o=n.still??me;return{icao:t==="liveness"&&ne(e)!==null&&bt(e)===void 0&&i!==void 0&&i.state==="pending"&&i.reason===void 0,still:{minLongSidePx:o.minLongSidePx??me.minLongSidePx,jpegQuality:o.jpegQuality??me.jpegQuality}}}function Fn(e,t,n,i){let o=t.eid,s=v(t);if(o===void 0||o.challenge!=="app_code")return{kind:"unsupported",key:"unsupported:eid_auth",context:n,section:s,checkType:"eid_auth",reason:"update_required"};let a=Ct(Se(e)),c=a.length===1&&gn.includes(a[0]?.service??"")?a[0]:void 0,f=c===void 0?void 0:K[c.service],g=f!==void 0,S={kind:"eid",key:"eid",context:n,section:s,provider:o.provider,providerName:o.providerName,country:o.country,challenge:"app_code",phase:o.awaiting==="code"?"code":"identifier",identifierBound:o.identifierBound===!0,canUseCamera:g,afterPass:o.afterPass==="continue"?"continue":"end",...i};return g&&(S.cameraMethod=f),o.expiresAt!==void 0&&(S.codeExpiresAt=o.expiresAt),o.resendAvailableAt!==void 0&&(S.resendAvailableAt=o.resendAvailableAt),o.resendsRemaining!==void 0&&(S.resendsRemaining=o.resendsRemaining),o.codeAttemptsRemaining!==void 0&&(S.codeAttemptsRemaining=o.codeAttemptsRemaining),S}function Hn(e,t){if(t.checkType!=="face_match"||t.reason!==void 0)return null;let n=M(e,"portrait_icao");return n!==void 0&&(n.state==="passed"||n.state==="review")?n:null}var Ln={rejected:"rejected",inconclusive:"inconclusive",unavailable:"unavailable",abandoned:"expired",not_opened:"expired",cancelled:"expired",superseded:"expired",policy:"policy"};function Dn(e){return e.reasonCode===ge?"platform_unsupported":e.status==="review_pending"?"review":e.status==="verified"?"verified":e.reasonCode==="device_cooldown"?"cooldown":e.reasonCode==="starter_credit_claimed"?"policy":(e.status==="not_verified"&&e.reason!==void 0?Ln[e.reason]:void 0)??"rejected"}function Un(e,t){let n=Dn(e),i=n==="platform_unsupported"?{sessionId:U(e.sessionId),status:"unavailable",reasonCode:ge}:j(e,{autoRetry:!1}),o={kind:"result",key:"result",context:t,section:null,display:n,result:i};return e.status==="not_verified"&&e.reason!==void 0&&(o.reason=e.reason),e.reasonCode!==void 0&&(o.reasonCode=e.reasonCode),e.status==="not_verified"&&e.step!==void 0&&(o.step=e.step),e.retryAfter!==void 0&&(o.retryAfter=e.retryAfter),o}function Bn(e,t,n){let i=e.identitySummary;if(i==null)return null;let o={kind:"identity_summary",key:"identity_summary",context:t,section:n??"identity",summaryKind:i.kind==="partial"?"partial":i.kind??"full",source:i.source,portraitAvailable:i.portrait?.available===!0,retakeAvailable:i.retakeAvailable===!0};for(let a of qn){let c=i[a];typeof c=="string"&&c!==""&&(o[a]=c)}let s=it(i);return s!==void 0&&(o.idNumberMasked=s,o.nniMasked=s),o}var qn=["fullName","birthDate","birthYear","nationality","documentType","documentNumberMasked","expiryDate","retakeTarget"];function F(e,t,n,i){return{kind:"unsupported",key:`unsupported:${n}`,context:e,section:t,checkType:n,reason:i}}function Gn(e){return e.kind==="contact"?"contact":(e.kind==="identity_method","identity")}function Kn(e,t){let n=_t[e.kind]??[...he,...ye],i=Gn(e),o=e.options.flatMap(a=>{if(a.available===!1||!n.includes(a.service))return[];let c={id:a.id,service:a.service};a.nationalEid!=null&&(c.nationalEid=a.nationalEid);let f=(a.channels??[]).filter(g=>g==="whatsapp"||g==="sms");return a.service==="phone_otp"&&f.length>0&&(c.channels=f),[c]});if(o.length===0){let a=e.options.length>0&&e.options.every(c=>c.service==="nfc");return F(t,i,"choice",a?"platform_unsupported":"update_required")}let s={nodeId:e.nodeId,kind:e.kind,selected:e.selected,options:o};if(e.kind==="identity_method"){let a={kind:"method",key:"method",context:t,section:i,options:o.map(f=>K[f.service]),choice:s},c=o.find(f=>f.nationalEid!==void 0)?.nationalEid;return c!==void 0&&(a.nationalEid=c),a}return e.kind==="contact"?{kind:"contact_choice",key:"contact_choice",context:t,section:i,options:o.map(a=>kt[a.service]),selected:null,locked:!1,choice:s}:{kind:"choice",key:`choice:${e.nodeId}`,context:t,section:i,choice:s}}function jn(e,t,n,i){let o=e.nativeApp,s=typeof o=="object"&&o!==null?o:{},a={sekyroApp:s.sekyroApp===!0};return typeof s.link=="string"&&s.link!==""&&(a.link=s.link),a.sekyroApp&&typeof s.sekyroAppLink=="string"&&s.sekyroAppLink.startsWith("sekyro://")&&(a.sekyroAppLink=s.sekyroAppLink),{kind:"native_app_required",key:`native_app_required:${i}`,context:t,section:n,checkType:i,nativeApp:a}}function Ro(e,t={}){let n=bn(e);if(R(e)||e.reasonCode===ge)return Un(e,n);let i=e.plan;if(i===void 0||!Array.isArray(i.sections))return F(n,null,"plan","update_required");let o=We(e);if(o!==null)return Kn(o,n);let s=i.current===null?void 0:i.steps.find(d=>d.id===i.current),a=d=>{let k={kind:"processing",key:"processing",context:n,section:d!==void 0?v(d):i.sections.find(m=>m.state==="current")?.id??null,stalled:!1};return typeof d?.service=="string"&&d.service!==""&&(k.service=d.service),k};if(i.current===null)return a(i.steps.find(d=>d.state==="processing"));if(s===void 0)return F(n,null,"step","update_required");if(!hn.has(s.service))return s.interaction==="server"?a(s):F(n,v(s),s.service,"update_required");if(yn.has(s.service)||!Qe(s))return a(s);let c=s,f=xn(c),g=c.checkType,S=v(c);if(c.requiresNativeApp===!0)return jn(e,n,S,g);let P=t.isMobile===!1?Y(e,c):null;if(P==="phone")return{kind:"mobile_required",key:"mobile_required",context:n,section:S,checkType:g};switch(g){case"phone_otp":case"email_otp":return wn(e,c,n,f);case"population_registry":return On(e,c,n,f);case"eid_auth":return Fn(e,c,n,f);case"doc_ocr":return En(e,c,n,f,P==="upload_or_phone");case"identity_confirm":return Bn(e,n,S)??a(c);case"portrait_icao":return St(e,c,n,f,"capture",P==="upload_or_phone");case"liveness":case"face_match":{let d=Hn(e,c);if(d!==null)return St(e,d,n,f,"match");let k=c.requiresMobile===!0,m=ne(e);return{kind:"liveness",key:"biometric",context:n,section:S,mode:g==="face_match"?"selfie":"liveness",requiresMobile:k,instructions:m===null?"standard":"icao",icao:m,livePhoto:Nn(e,g),...f}}case"poa":return vn(e,c,n,f,P==="upload_or_phone");case"form":{let d=lt(c.form);return d===null?F(n,S,g,"update_required"):{kind:"form",key:"form",context:n,section:S,form:d,dir:dt(d.locale),...f}}case"nfc_chip":return F(n,S,g,"platform_unsupported");default:return F(n,S,g,"update_required")}}export{Ht as a,Lt as b,Gt as c,Kt as d,Yt as e,so as f,$t as g,ut as h,Wt as i,Zt as j,lo as k,ct as l,po as m,_ as n,dt as o,on as p,rn as q,pt as r,dn as s,mo as t,Po as u,ge as v,v as w,Se as x,Ct as y,Hn as z,Ro as A};
|
|
@@ -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
|
+
import{a as ne,b as ie}from"./chunk-SX7TUC3V.js";import{b as ce,c as ue,d as de}from"./chunk-POIQGEZM.js";import{a as Y,c as j,e as $,g as J,h as A,k as R,m as ee,n as re}from"./chunk-CPUECYAJ.js";import{b as L,c as pe,d as F,e as me}from"./chunk-FPXL63KZ.js";import{a as z,c as X,d as Z,e as Q}from"./chunk-TSA6GHUG.js";import{d as te}from"./chunk-A7QFTU6M.js";import{e as ae,f as se,h as G,j as oe,l as le}from"./chunk-FSSMUAKC.js";var Ie=[...Y.filter(i=>i.startsWith("video/mp4")),"video/webm;codecs=h264","video/webm;codecs=avc1","video/webm;codecs=vp8","video/webm;codecs=vp9","video/webm"],he=new Set;function De(i){let e=/(?:Chrome|Chromium)\/(\d+)\./.exec(i??"");return e?Number(e[1]):null}function fe(i=Oe(),e=globalThis.navigator?.userAgent){if(i===void 0)return"";let t=De(e)===126;for(let r of Ie)if(!(he.has(r)||t&&r.startsWith("video/mp4")))try{if(i(r))return r}catch{}return""}function V(i){i!==""&&he.add(i)}function ge(i){return i.replace(/^video\/x-matroska/i,"video/webm")}function ut(i){let e=/codecs=["']?([^,;"']+)/i.exec(i);return e?e[1].trim():i.split(";")[0].trim()}function Oe(){let i=globalThis.MediaRecorder;return i&&typeof i.isTypeSupported=="function"?e=>i.isTypeSupported(e):void 0}var U=2500,Pe=1e3,xe=1500,ve=25e5,Ge=100,Le=700,Fe=20,Ve=1500,N=null;function Ne(){return N??(N=import("./clip-inspect-DLJXVKV6.js").catch(i=>{throw N=null,i})),N.catch(()=>null)}var S=class extends Error{constructor(e,t){super(t??e),this.kind=e}},Ue=100;function H(i,e){return i.stats===void 0?!1:i.stats===null?!0:i.stats.durationMs<e-Ue}function be(i,e){return i.stats?e.stats?i.stats.durationMs>e.stats.durationMs:!0:!1}var I=class{constructor(e={}){this.recorder=null;this.stream=null;this.chunks=[];this.bytes=0;this.hardStopTimer=null;this.graceTimer=null;this.pollTimer=null;this.settled=!1;this.now=e.now??(()=>globalThis.performance?.now?.()??Date.now())}clearTimers(){this.hardStopTimer&&clearTimeout(this.hardStopTimer),this.graceTimer&&clearTimeout(this.graceTimer),this.pollTimer&&clearInterval(this.pollTimer),this.hardStopTimer=null,this.graceTimer=null,this.pollTimer=null}record(e,t,r,n=U,a){let s=fe(),o=Ne();return this.recordRaw(e,t,r,n,a,s).then(c=>He(c,o),c=>{throw c instanceof S&&(c.requestedMimeType=s),c})}recordRaw(e,t,r,n,a,s){return this.recorder&&!this.settled?Promise.reject(new S("generic","record() called while a recording is in flight \u2014 ClipRecorder handles one recording at a time")):(this.recorder=null,this.clearTimers(),this.chunks=[],this.bytes=0,this.settled=!1,this.stream=e,new Promise((o,c)=>{let l;try{l=new MediaRecorder(e,s?{mimeType:s,videoBitsPerSecond:ve}:{videoBitsPerSecond:ve})}catch{try{l=new MediaRecorder(e)}catch{c(new S("unsupported"));return}}this.recorder=l;let d=h=>{this.settled||(this.settled=!0,this.clearTimers(),h())},u=()=>d(()=>{let h=ge(l.mimeType||s||j),b=new Blob(this.chunks,{type:h});if(b.size===0){c(new S("generic","empty clip"));return}if(A(b)){c(new S("cliptoolarge"));return}o({blob:b,mimeType:h,requestedMimeType:s})});l.ondataavailable=h=>{h.data&&h.data.size&&(this.chunks.push(h.data),this.bytes+=h.data.size,this.bytes>J&&d(()=>{try{l.state!=="inactive"&&l.stop()}catch{}c(new S("cliptoolarge"))}))},l.onstop=u,l.onerror=()=>d(()=>c(new S("generic")));let f=this.now();if(r!==void 0||a!==void 0){let h=!1;l.onstart=()=>{if(!(h||this.settled)&&(h=!0,f=this.now(),r!==void 0))try{r()}catch{}}}try{l.start(Pe)}catch{d(()=>c(new S("generic")));return}let g=()=>{if(this.pollTimer&&clearInterval(this.pollTimer),this.pollTimer=null,this.hardStopTimer&&clearTimeout(this.hardStopTimer),this.hardStopTimer=null,this.settled||t?.(),l.state!=="inactive"){try{l.stop()}catch{u()}this.graceTimer=setTimeout(u,xe)}else u()},p=this.now();if(a===void 0){this.hardStopTimer=setTimeout(g,n);return}let m=null,y=!1;this.hardStopTimer=setTimeout(g,n+Le),this.pollTimer=setInterval(()=>{if(this.settled||y)return;let h=null;try{h=a.latest()}catch{h=null}let b=h?.presentationTimeMs;b!==void 0&&Number.isFinite(b)&&b>=f&&m===null&&(m=b);let C=m!==null&&b!==void 0&&b-m>=n,E=m===null&&this.now()-p>=n;if(!(!C&&!E)){if(y=!0,this.pollTimer&&clearInterval(this.pollTimer),this.pollTimer=null,E){g();return}this.hardStopTimer&&clearTimeout(this.hardStopTimer),this.hardStopTimer=setTimeout(g,Ge)}},Fe)}))}stop(e){this.clearTimers();let t=this.recorder;if(t&&t.state!=="inactive")try{t.stop()}catch{}this.recorder=null,(e??this.stream)?.getTracks().forEach(n=>n.stop()),this.stream=null}};async function He(i,e){let t,r=new Promise(l=>{t=setTimeout(()=>l(null),Ve)}),n=await Promise.race([e,r]);if(clearTimeout(t),n===null)return i;let a;try{a=await n.blobBytes(i.blob)}catch{return{...i,stats:null}}let s=n.inspectClipBytes(a);if(s?.container!=="webm")return{...i,stats:s};let o=n.withWebmDuration(a,s.durationMs);if(o===null)return{...i,stats:s};let c=n.inspectClipBytes(o);return c===null||c.frames!==s.frames||c.durationMs!==s.durationMs?{...i,stats:s}:{...i,blob:new Blob([o],{type:i.blob.type}),stats:s}}var Ke=["magenta","yellow","green","blue"];var Be={magenta:"rgb(255, 72, 150)",yellow:"rgb(255, 190, 0)",green:"rgb(0, 238, 175)",blue:"rgb(25, 150, 255)",dark:"rgb(0, 0, 0)"};function ft(i){return Be[i]}var We=4,qe=4,D=i=>typeof i=="number"&&Number.isFinite(i);function O(i){if(typeof i!="object"||i===null)return!1;let e=i;if(typeof e.nonce!="string"||e.nonce.length===0||!Array.isArray(e.colours)||e.colours.length<1||e.colours.length>8||!e.colours.every(r=>Ke.includes(r))||!Array.isArray(e.onsetsMs)||e.onsetsMs.length!==e.colours.length)return!1;let t=-1;for(let r of e.onsetsMs){if(!D(r)||r<0||r<=t)return!1;t=r}return!(!D(e.holdMs)||e.holdMs<=0||!D(e.endMs)||e.endMs<=t||!D(e.clipMs)||e.clipMs<e.endMs||e.clipMs>8e3)}function ye(i,e){return O(i)?Math.max(e,Math.ceil(i.clipMs)):e}function Me(i,e){let t=e.now??(()=>performance.now()),r=O(i)?i:void 0,n=[],a=null,s=null,o=null,c=!1,l=null,d=p=>{l=p;try{e.paint(p)}catch{}},u=p=>{let m=e.frames?.()??null;return m!==null&&o!==null?m.mediaTimeMs+(p-m.presentationTimeMs)-o:p-(s??p)},f=(p,m,y=0)=>{if(c)return;let h=Math.max(0,p-u(t()));a=setTimeout(()=>{if(a=null,!c){if(y<We&&u(t())<p-qe){f(p,m,y+1);return}m()}},h)},g=p=>{if(r===void 0)return;let m=r.endMs;if(p>=r.colours.length){f(m,()=>d(null));return}let y=r.onsetsMs[p],h=p+1<r.onsetsMs.length?r.onsetsMs[p+1]:m;f(y,()=>{let b=u(t());if(b>m){l!==null&&d(null);return}let C=r.colours[p];d(C);let E=n.length===0?0:n[n.length-1].tMs;n.push({tMs:Math.max(E,Math.round(b)),colour:C});let M=y+r.holdMs;if(M<h){f(M,()=>{if(u(t())>m){l!==null&&d(null);return}d("dark"),g(p+1)});return}g(p+1)})};return{started(p){if(r===void 0||c||s!==null)return;s=p;let m=e.frames?.()??null;o=m===null?null:m.mediaTimeMs+(p-m.presentationTimeMs),g(0)},stop(){c||(c=!0,a!==null&&clearTimeout(a),a=null,l!==null&&d(null))},report(){return r===void 0?void 0:{nonce:r.nonce,rendered:[...n]}}}}function Se(i,e,t=.92){return new Promise((r,n)=>{let a=i.videoWidth,s=i.videoHeight;if(!a||!s){n(new Error("video-not-ready"));return}let o=e.getContext("2d");if(!o){n(new Error("no-2d-context"));return}e.width=a,e.height=s,o.scale(-1,1),o.drawImage(i,-a,0),e.toBlob(c=>c?r(c):n(new Error("empty-keyframe")),"image/jpeg",t)})}var P=class{constructor(e){this.timer=null;this.frameCallbackId=null;this.running=!1;this.busy=!1;this.lastRunAt=Number.NEGATIVE_INFINITY;this.degradeCount=0;this.durations=[];this.options=e,this.periodMs=1e3/e.cadenceHz}start(){if(this.running)return;this.running=!0;let e=this.options.video;if(typeof e?.requestVideoFrameCallback=="function"){let t=()=>{this.running&&(this.frameCallbackId=e.requestVideoFrameCallback?.(()=>{this.frameCallbackId=null,this.now()-this.lastRunAt>=this.periodMs&&this.tick(),t()}))};t();return}this.timer=setInterval(()=>this.tick(),this.periodMs)}stop(){this.running=!1,this.timer!==null&&(clearInterval(this.timer),this.timer=null),this.frameCallbackId!==null&&(this.options.video?.cancelVideoFrameCallback?.(this.frameCallbackId),this.frameCallbackId=null)}stats(){let e=this.durations.length===0?0:this.durations.reduce((t,r)=>t+r,0)/this.durations.length;return{degradeCount:this.degradeCount,meanDetectMs:e}}now(){return this.options.now?.()??performance.now()}tick(){if(!this.running)return;if(this.busy){this.degradeCount+=1;return}this.busy=!0,this.lastRunAt=this.now();let e=this.now();this.options.run().catch(()=>{}).finally(()=>{this.busy=!1,this.durations.push(this.now()-e),this.durations.length>20&&this.durations.shift()})}};var ze=Object.freeze({Q_GOOD:.6,RISE_PER_S:.9,FALL_PER_S:.25,CENTER_FALLOFF_IOD_MULTIPLE:1.35,BOX_EYE_OFFSET_FACTOR:.12,IOD_BOX_PROXY_FACTOR:.42,SIZE_IDEAL_MIN:.12,SIZE_IDEAL_MAX:.3,SIZE_HARD_MIN:.08,SIZE_HARD_MAX:.45,ROLL_MAX_DEG:25,MOTION_VELOCITY_IOD_PER_S:.5,MOTION_TAU_S:.4,MOTION_DEADBAND_IOD_PER_S:.1,READY_WINDOW_MS:500,GUIDE_SIZE:.6,GUIDE_CENTERING:.6,GUIDE_POSE:.6,GUIDE_EXPOSURE:.6,GUIDE_SHARPNESS:.35,GUIDE_MOTION:.5}),_=i=>Math.min(1,Math.max(0,i)),k=class{constructor(e={}){this.p=0;this.lastTickAt=null;this.lastCenter=null;this.velocityEma=0;this.qWindow=[];this.lastSizeDirection="ideal";this.t={...ze,...e}}reset(){this.p=0,this.lastTickAt=null,this.lastCenter=null,this.velocityEma=0,this.qWindow=[],this.lastSizeDirection="ideal"}tick(e){let{observation:t,quality:r,timestampMs:n}=e,a=this.lastTickAt===null?0:Math.max(0,(n-this.lastTickAt)/1e3);this.lastTickAt=n;let s={presence:0,single:1,centering:0,size:0,pose:0,sharpness:_(r.sharpness),exposure:_(r.exposure),motion:1};if(t!==null){s.presence=1,s.single=(t.extraFaces??0)>0?0:1;let d=this.geometryOf(t,e);s.centering=d.centering,s.size=d.size,s.pose=d.pose,s.motion=this.motionOf(d.center,d.iod,n)}else this.lastCenter=null,this.velocityEma=0;let o=Math.min(s.presence,s.single,s.centering,s.size,s.pose,s.sharpness,s.exposure,s.motion);this.p=_(this.p+(o>=this.t.Q_GOOD?this.t.RISE_PER_S*o:-this.t.FALL_PER_S*(1-o))*a),this.qWindow.push({at:n,q:o}),this.qWindow=this.qWindow.filter(d=>d.at>=n-this.t.READY_WINDOW_MS);let c=this.qWindow.map(d=>d.q);if(c.length>=3){let d=Math.min(...c),u=c.indexOf(d);c=c.filter((f,g)=>g!==u)}let l=this.p>=1&&c.every(d=>d>=this.t.Q_GOOD);return{at:n,q:o,p:this.p,factors:s,guidanceKey:this.guidanceOf(s,r,o),ready:l,accepted:o>=this.t.Q_GOOD}}geometryOf(e,t){let{box:r,eyes:n}=e,a={x:t.frameWidth/2,y:t.frameHeight/2},s=Math.min(t.frameWidth,t.frameHeight),o=n!==void 0?{x:(n.left.x+n.right.x)/2,y:(n.left.y+n.right.y)/2}:{x:r.x+r.width/2,y:r.y+r.height/2-this.t.BOX_EYE_OFFSET_FACTOR*r.height},c=n!==void 0?Math.hypot(n.right.x-n.left.x,n.right.y-n.left.y):this.t.IOD_BOX_PROXY_FACTOR*r.width,l=Math.hypot(o.x-a.x,o.y-a.y),d=c<=0?0:1-_(l/(this.t.CENTER_FALLOFF_IOD_MULTIPLE*c)),u=s>0?c/s:0;this.lastSizeDirection=u<this.t.SIZE_IDEAL_MIN?"far":u>this.t.SIZE_IDEAL_MAX?"close":"ideal";let f;u<this.t.SIZE_HARD_MIN||u>this.t.SIZE_HARD_MAX?f=0:u<this.t.SIZE_IDEAL_MIN?f=(u-this.t.SIZE_HARD_MIN)/(this.t.SIZE_IDEAL_MIN-this.t.SIZE_HARD_MIN):u>this.t.SIZE_IDEAL_MAX?f=(this.t.SIZE_HARD_MAX-u)/(this.t.SIZE_HARD_MAX-this.t.SIZE_IDEAL_MAX):f=1;let g=1;if(n!==void 0){let p=Math.abs(Math.atan2(n.right.y-n.left.y,n.right.x-n.left.x))*180/Math.PI;g=1-_(p/this.t.ROLL_MAX_DEG)}return{center:o,iod:c,centering:d,size:f,pose:g}}motionOf(e,t,r){let n=this.lastCenter;if(this.lastCenter={...e,at:r},n===null||t<=0)return 1;let a=(r-n.at)/1e3;if(a<=0)return 1;let s=Math.hypot(e.x-n.x,e.y-n.y)/t/a;s<=this.t.MOTION_DEADBAND_IOD_PER_S&&(s=0);let o=1-Math.exp(-a/this.t.MOTION_TAU_S);return this.velocityEma=o*s+(1-o)*this.velocityEma,1-_(this.velocityEma/this.t.MOTION_VELOCITY_IOD_PER_S)}guidanceOf(e,t,r){if(e.presence<=0)return"fcv3.no_face";if(e.single<=0)return"fcv3.one_face";if(e.size<this.t.GUIDE_SIZE)return this.sizeGuidance();if(e.centering<this.t.GUIDE_CENTERING)return"fcv3.center_face";if(e.pose<this.t.GUIDE_POSE)return"fcv3.straighten";if(e.exposure<this.t.GUIDE_EXPOSURE)return this.exposureGuidance(t);if(e.sharpness<this.t.GUIDE_SHARPNESS)return"fcv3.steady_camera";if(e.motion<this.t.GUIDE_MOTION)return"fcv3.hold_still";if(r<this.t.Q_GOOD){let n=[["size",this.sizeGuidance()],["centering","fcv3.center_face"],["pose","fcv3.straighten"],["exposure",this.exposureGuidance(t)],["sharpness","fcv3.steady_camera"],["motion","fcv3.hold_still"]],a=n[0];for(let s of n)e[s[0]]<e[a[0]]&&(a=s);return a[1]}return"fcv3.hold_still"}sizeGuidance(){return this.lastSizeDirection==="far"?"fcv3.come_closer":"fcv3.move_back"}exposureGuidance(e){let t=(L[0]+L[1])/2;return e.meanLuma<t?"fcv3.more_light":"fcv3.too_bright"}};var Xe=["single","size","centering","pose","exposure","sharpness","motion"];function Ze(i){if(i.accepted)return null;if(i.factors.presence<=0)return"no_face";let e="single";for(let t of Xe)i.factors[t]<i.factors[e]&&(e=t);return e}var w=class{constructor(){this.blocked={};this.acceptedMs=0;this.ticks=0;this.lastAt=null}record(e){let t=this.lastAt===null?0:Math.max(0,e.at-this.lastAt);this.lastAt=e.at,this.ticks+=1;let r=Ze(e);if(r===null){this.acceptedMs+=t;return}let n=this.blocked[r]??{count:0,ms:0};n.count+=1,n.ms+=t,this.blocked[r]=n}summary(){let e={};for(let[t,r]of Object.entries(this.blocked))e[t]={count:r.count,ms:Math.round(r.ms)};return{blocked:e,acceptedMs:Math.round(this.acceptedMs),ticks:this.ticks}}};var Qe=["obs","manycam","virtual","snap camera","xsplit","droidcam","iriun","camo"],Ye=[/^(front|back|rear)( [a-z ]+)? camera$/i,/^caméra (avant|arrière)\b/i,/^cámara (frontal|trasera|delantera)\b/i,/^câmera (frontal|traseira)\b/i,/^(front|rück)kamera\b/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 je(i){let e=(i??"").trim().toLowerCase();return e.length===0?"unknown":Qe.some(t=>e.includes(t))?"known_virtual":Ye.some(t=>t.test(e))?"platform":"unknown"}function Te(i){if(typeof i!="function")return!1;try{return/\{\s*\[native code\]\s*\}\s*$/.test(Function.prototype.toString.call(i))}catch{return!1}}function $e(i=globalThis){return Te(i.navigator?.mediaDevices?.getUserMedia)&&Te(i.MediaStreamTrack?.prototype?.getSettings)}async function Je(i,e=globalThis){let t=e.crypto?.subtle?.digest;if(typeof t=="function")try{let r=new Uint8Array(await t.call(e.crypto?.subtle,"SHA-256",new TextEncoder().encode(i)));return Array.from(r.subarray(0,8),n=>n.toString(16).padStart(2,"0")).join("")}catch{return}}async function Ce(i,e=globalThis){let t={};try{t=typeof i.getSettings=="function"?i.getSettings()??{}:{}}catch{t={}}let r={};if((t.facingMode==="user"||t.facingMode==="environment"||t.facingMode==="left"||t.facingMode==="right")&&(r.facingMode=t.facingMode),typeof t.frameRate=="number"&&Number.isFinite(t.frameRate)&&(r.frameRate=t.frameRate),typeof t.width=="number"&&Number.isFinite(t.width)&&(r.width=t.width),typeof t.height=="number"&&Number.isFinite(t.height)&&(r.height=t.height),typeof t.deviceId=="string"&&t.deviceId.length>0){let a=await Je(t.deviceId,e);a!==void 0&&(r.deviceIdHash=a)}let n;try{n=i.label}catch{n=void 0}return{trackSettings:r,capabilitiesPresent:typeof i.getCapabilities=="function",labelClass:je(n),prototypesIntact:$e(e)}}var K=i=>Math.round(i*100)/100;function Ee(i){let e=i,t=typeof e?.requestVideoFrameCallback=="function",r=null,n=null,a=0,s=0,o=0,c=0,l=0,d=0,u=()=>{!t||e?.requestVideoFrameCallback===void 0||(r=e.requestVideoFrameCallback((f,g)=>{if(r=null,!t)return;let p=g.presentationTime;if(n!==null){let m=p-n.presentationTimeMs;s+=1;let y=m-o;o+=y/s,c+=y*(m-o)}typeof g.captureTime=="number"&&Number.isFinite(g.captureTime)&&(l+=p-g.captureTime,d+=1),a+=1,n={mediaTimeMs:g.mediaTime*1e3,presentationTimeMs:p},u()}))};return u(),{latest:()=>n,stats:()=>({n:a,meanGapMs:s===0?0:K(o),stdGapMs:s<2?0:K(Math.sqrt(c/(s-1))),captureLatencyMs:d===0?null:K(l/d)}),stop:()=>{t&&(t=!1,r!==null&&e?.cancelVideoFrameCallback?.(r),r=null)}}}function _e(i,e,t){return{...i,rvfc:e,rampPainter:t}}var et=1e3,B="fcv3.hold_upright",tt=200,W=4,rt=600,nt=1e3,Re={sharpness:1,exposure:1,meanLuma:128};function it(i,e){return e.width=i.videoWidth,e.height=i.videoHeight,e.getContext("2d").drawImage(i,0,0),new Promise((t,r)=>e.toBlob(n=>n?t(n):r(new Error("empty-keyframe")),"image/jpeg",.92))}function at(){return X()==="phone"}var ke=class{constructor(e){this.handlers=new Map;this.stateValue="idle";this.attempt=0;this.stream=null;this.detector=null;this.scheduler=null;this.gate=null;this.profiler=null;this.lastGuidanceKey=null;this.positioningStartedAt=0;this.cameraRequestedAt=null;this.cameraReadyAt=null;this.faceAcquiredAt=null;this.captureCompleteAt=null;this.fired=!1;this.carriedDegrade=0;this.carriedMeans=[];this.blockStats=null;this.lastGateSnapshotAt=Number.NEGATIVE_INFINITY;this.uprightGuard=!1;this.trackProvenance=null;this.ramp=null;this.snapshotCanvas=null;this.options=e,this.facing=e.facingMode??"user"}get state(){return this.stateValue}on(e,t){let r=this.handlers.get(e);return r||(r=new Set,this.handlers.set(e,r)),r.add(t),()=>r?.delete(t)}emit(e,t){for(let r of[...this.handlers.get(e)??[]])r(t)}async start(e={}){e.facingMode!==void 0&&(this.facing=e.facingMode),this.attempt+=1,await this.run(this.attempt)}get facingMode(){return this.facing}retry(){this.teardownAttempt(),this.start()}switchCamera(){this.facing=this.facing==="user"?"environment":"user",this.teardownAttempt(),this.start()}restart(e){this.facing=e,this.teardownAttempt(),this.start()}destroy(){this.attempt+=1,this.teardownAttempt(),this.detector?.destroy(),this.detector=null,this.options.video.srcObject=null}async run(e){let{options:t}=this;this.fired=!1,this.lastGuidanceKey=null,this.carriedDegrade=0,this.carriedMeans=[],this.cameraRequestedAt=null,this.cameraReadyAt=null,this.faceAcquiredAt=null,this.captureCompleteAt=null,this.uprightGuard=(t.isPhone??at)(),this.setState("preflight");let r=$();if(r!=="OK"){this.fail(r==="INSECURE_CONTEXT"?"insecure":"unsupported",{phase:"preflight"});return}this.setState("acquiring");let n=t.getUserMedia??(l=>navigator.mediaDevices.getUserMedia(l)),a;this.cameraRequestedAt=this.now();try{let{facingMode:l,...d}=z(Z(),this.facing).video;a=await ie(this.facing,d,{getUserMedia:n,enumerateDevices:lt(t)})}catch(l){if(e!==this.attempt)return;if(l instanceof ne){this.fail("backcamera",{phase:"acquiring",name:R(l)});return}this.fail(ee(l),{phase:"acquiring",name:R(l)});return}if(te(a),re(a),e!==this.attempt){for(let l of a.getTracks())l.stop();return}this.stream=a;let s=a.getVideoTracks?.()[0];if(this.trackProvenance=s===void 0?null:Ce(s).catch(()=>null),this.facing=Q(a)??this.facing,t.video.srcObject=a,await t.video.play().catch(()=>{}),e!==this.attempt)return;if(this.cameraReadyAt=this.now(),this.detector===null){let l={v3AssetBaseUrl:t.v3AssetBaseUrl},d=t.createDetector??(t.createWorker!==void 0&&oe()?async()=>{try{return await le.create(t.createWorker(),l)}catch{return G(l)}}:()=>G(l)),u;try{u=await d()}catch(f){e===this.attempt&&this.fail("models",{phase:"models",name:R(f)},f instanceof ae?f.fallbackReason:ot(f));return}if(e!==this.attempt){u.destroy();return}this.detector=u,this.options.telemetry?.({type:"detector",tier:u.tier,fallbackReason:u.fallbackReason})}let o=ce(),c=t.deviceClass??ue(o);this.profiler=new de(c),this.options.telemetry?.({type:"profile",staticClass:c,activeClass:this.profiler.deviceClass,simd:o.simd}),this.gate=new k(t.thresholds??{}),this.blockStats=new w,this.lastGateSnapshotAt=this.now(),t.rankKeyframes?.()&&import("./keyframe-rank-YAJLYJYF.js").then(l=>q=l,()=>{}),this.setState("positioning"),this.positioningStartedAt=this.now(),this.startScheduler(e)}get animations(){return this.profiler?.profile.animations??"full"}startScheduler(e){let t=this.profiler;if(t===null)return;if(this.scheduler!==null){let n=this.scheduler.stats();this.carriedDegrade+=n.degradeCount,n.meanDetectMs>0&&this.carriedMeans.push(n.meanDetectMs),this.scheduler.stop()}let r=new P({cadenceHz:t.profile.cadenceHz,video:this.options.video,now:this.options.now,run:()=>this.detectTick(e)});this.scheduler=r,r.start()}async detectTick(e){let{detector:t,gate:r,profiler:n}=this,a=this.options.video;if(e!==this.attempt||t===null||r===null||n===null||this.fired||a.videoWidth===0)return;if(this.isLandscape()){this.holdUpright(e);return}let s=n.deviceClass,o=this.now(),c=this.options.makeSnapshot?.(a,n.profile.inputWidth)??this.defaultSnapshot(a,n.profile.inputWidth),l=null;try{l=await t.detect(c,a.videoWidth,a.videoHeight)}catch{l=null}if(e!==this.attempt||this.fired)return;n.record(this.now()-o),n.deviceClass!==s&&this.startScheduler(e);let d=l===null?Re:this.options.measureQuality?.(a,l.box)??this.defaultQuality(a,l.box),u=r.tick({timestampMs:this.now(),observation:l,quality:d,frameWidth:a.videoWidth,frameHeight:a.videoHeight});u.accepted&&this.faceAcquiredAt===null&&(this.faceAcquiredAt=u.at),this.blockStats?.record(u),!u.ready&&u.at-this.lastGateSnapshotAt>=et&&(this.lastGateSnapshotAt=u.at,this.reportGate(!1)),this.emit("checks",{engine:"v3",progress:u.p,q:u.q,factors:u.factors,attempt:e}),u.guidanceKey!==this.lastGuidanceKey&&(this.lastGuidanceKey=u.guidanceKey,this.emit("guidance",{key:u.guidanceKey})),u.ready&&this.stateValue==="positioning"&&(this.fired=!0,this.captureCompleteAt=u.at,this.fire(e))}async fire(e){let{options:t}=this,r=this.scheduler;r?.stop(),this.reportGate(!0);let n=r?.stats()??{degradeCount:0,meanDetectMs:0},a=[...this.carriedMeans,...n.meanDetectMs>0?[n.meanDetectMs]:[]];t.telemetry?.({type:"fired",timeToGateMs:this.now()-this.positioningStartedAt,degradeCount:this.carriedDegrade+n.degradeCount,meanDetectMs:a.length===0?0:a.reduce((M,v)=>M+v,0)/a.length});let s=t.mode??"clip",o=t.rankKeyframes?.()&&q?q.default(this,e).catch(()=>this.collectKeyframes(e)):this.collectKeyframes(e);if(s==="photo"){let M=this.watchRotation(e,null),v=await o;if(M(),e!==this.attempt)return;if(v===null){this.fail("generic",{phase:"keyframes"});return}let x=await this.provenance({n:0,meanGapMs:0,stdGapMs:0,captureLatencyMs:null},!1);if(e!==this.attempt)return;this.finishCapture({keyframe:v.blob,previewDataUrl:v.previewDataUrl,...x});return}this.setState("recording");let c=this.stream;if(c===null){this.fail("generic",{phase:"recording"});return}let l=t.screenRamp?.(),d=O(l),u=null;o.then(M=>{u=M},()=>{});let f=()=>{e===this.attempt&&u!==null&&this.emit("frozen",{previewDataUrl:u.previewDataUrl})},g=ye(l,U),p=null,m,y=0;try{let M=this.recordTake(e,c,l,g,void 0).then(T=>T,T=>({failed:T})),[v,x]=await Promise.all([M,o]);if(m=x,e!==this.attempt)return;if("failed"in v){if(v.failed.kind==="cliptoolarge")throw v.failed;V(v.failed.requestedMimeType??"")}else p=v,H(v.clip,g)?v.clip.stats===null&&V(v.clip.requestedMimeType??""):f();if(p===null||H(p.clip,g)){y=1,t.telemetry?.({type:"clip_retake",reason:p===null?"error":p.clip.stats===null?"unreadable":"short"});let T=null;try{T=await this.recordTake(e,c,l,g,f)}catch(Ae){if(p===null)throw Ae}if(e!==this.attempt)return;T!==null&&(p===null||be(T.clip,p.clip))&&(p=T),T===null&&f()}}catch(M){if(e!==this.attempt)return;let v=M.kind;this.fail(v==="cliptoolarge"?"cliptoolarge":"recorder",{phase:"recording",name:R(M)});return}if(p===null){this.fail("recorder",{phase:"recording"});return}let{clip:h,rvfc:b,report:C}=p;if(A(h.blob)){this.fail("cliptoolarge",{phase:"recording"});return}if(m===null){this.fail("generic",{phase:"keyframes"});return}let E=await this.provenance(b,d);e===this.attempt&&this.finishCapture({clip:h.blob,clipMimeType:h.mimeType,...h.stats?{clipStats:h.stats}:{},clipRetakes:y,keyframe:m.blob,previewDataUrl:m.previewDataUrl,...C!==void 0&&C.rendered.length>0?{screenRamp:C}:{},...E})}async recordTake(e,t,r,n,a){let s=this.options.createRecorder?.()??new I({now:()=>this.now()}),o=Ee(this.options.video),c=Me(r,{paint:u=>{(u===null||e===this.attempt)&&this.emit("ramp",{colour:u})},now:()=>this.now(),frames:o.latest});this.ramp=c;let l=()=>{o.stop(),c.stop(),this.ramp===c&&(this.ramp=null)},d=this.watchRotation(e,s);try{return{clip:await s.record(t,a,()=>c.started(this.now()),n,o),rvfc:o.stats(),report:c.report()}}finally{d(),l()}}async provenance(e,t){let r=this.trackProvenance;if(r===null)return{};let n,a=new Promise(o=>{n=setTimeout(()=>o(null),nt)}),s=await Promise.race([r,a]);return clearTimeout(n),s===null?{}:{provenance:_e(s,e,t)}}isLandscape(){let e=this.options.video;return this.uprightGuard&&e.videoWidth>e.videoHeight}holdUpright(e){this.gate?.reset(),this.emit("checks",{engine:"v3",progress:0,q:0,factors:{presence:0,single:1,centering:0,size:0,pose:0,sharpness:0,exposure:0,motion:0},attempt:e}),this.lastGuidanceKey!==B&&(this.lastGuidanceKey=B,this.emit("guidance",{key:B}))}watchRotation(e,t){if(!this.uprightGuard)return()=>{};let r=this.options.video,n=()=>{if(e!==this.attempt||t!==null&&this.stateValue!=="recording"){o();return}r.videoWidth>0&&this.isLandscape()&&(o(),this.abortRecording(e,t))},a=setInterval(n,tt);r.addEventListener?.("resize",n);let s=!1;function o(){s||(s=!0,clearInterval(a),r.removeEventListener?.("resize",n))}return o}abortRecording(e,t){if(e!==this.attempt)return;this.attempt+=1;let r=this.attempt;try{t?.stop()}catch{}this.ramp?.stop(),this.ramp=null,this.fired=!1,this.captureCompleteAt=null,this.gate=new k(this.options.thresholds??{}),this.blockStats=new w,this.lastGateSnapshotAt=this.now(),this.lastGuidanceKey=null,this.setState("positioning"),this.positioningStartedAt=this.now(),this.holdUpright(r),this.startScheduler(r)}async collectKeyframes(e){let t=this.options.captureKeyframe??(a=>this.defaultKeyframe(a)),r=rt/(W-1),n=null;for(let a=0;a<W;a+=1){if(e!==this.attempt)return n;try{let s=await t(this.options.video);(n===null||s.sharpness>n.sharpness)&&(n=s)}catch{}a<W-1&&await st(r)}return n}finishCapture(e){this.stopTracks(),this.setState("captured");let t=this.captureTiming();this.emit("artifacts",t===void 0?e:{...e,timing:t})}captureTiming(){let e={},t=(r,n,a)=>{n!==null&&a!==null&&(e[r]=Math.max(0,Math.round(a-n)))};return t("cameraReadyMs",this.cameraRequestedAt,this.cameraReadyAt),t("faceAcquireMs",this.cameraReadyAt,this.faceAcquiredAt),t("captureMs",this.faceAcquiredAt,this.captureCompleteAt),Object.keys(e).length>0?e:void 0}async defaultKeyframe(e){let t=document.createElement("canvas"),r=await(this.facing==="user"?Se:it)(e,t),n=t.toDataURL("image/jpeg",.92);return{blob:r,previewDataUrl:n,sharpness:this.centerSharpness(e)}}defaultSnapshot(e,t){try{let r=this.snapshotCanvas??document.createElement("canvas"),n=t/Math.max(1,e.videoWidth),a=Math.max(1,Math.round(e.videoWidth*n)),s=Math.max(1,Math.round(e.videoHeight*n)),o=r.getContext("2d");return o===null?e:(r.width!==a&&(r.width=a),r.height!==s&&(r.height=s),o.drawImage(e,0,0,a,s),this.snapshotCanvas=r,r)}catch{return e}}defaultQuality(e,t){let r=we(e,t,96);return r===null?Re:{sharpness:F(r),exposure:me(r),meanLuma:pe(r)}}centerSharpness(e){let t=se(e),r=we(e,{x:t.width*.25,y:t.height*.25,width:t.width*.5,height:t.height*.5},96);return r===null?0:F(r)}teardownAttempt(){this.scheduler?.stop(),this.scheduler=null,this.reportGate(!0),this.gate=null,this.ramp?.stop(),this.ramp=null,this.stopTracks()}reportGate(e){let t=this.blockStats,r=this.profiler;if(t===null||r===null)return;let n=t.summary();e&&(this.blockStats=null),n.ticks!==0&&this.options.telemetry?.({type:"gate",final:e,activeClass:r.deviceClass,cadenceHz:r.profile.cadenceHz,...n})}stopTracks(){if(this.stream!==null){for(let e of this.stream.getTracks())e.stop();this.stream=null}}fail(e,t,r){this.scheduler?.stop(),this.reportGate(!0),this.stopTracks(),this.setState("error"),this.options.telemetry?.({type:"error",kind:e,fallbackReason:r});let{phase:n,name:a}=t;this.emit("error",{kind:e,retryable:e!=="insecure"&&e!=="unsupported",detail:a===void 0?{phase:n}:{phase:n,name:a}})}setState(e){this.stateValue=e,this.emit("statechange",{state:e})}now(){return this.options.now?.()??performance.now()}},q;function st(i){return new Promise(e=>setTimeout(e,i))}function ot(i){return i instanceof Error?i.message:String(i)}function we(i,e,t){try{let r=document.createElement("canvas"),n=t/Math.max(1,e.width);r.width=Math.max(1,Math.round(e.width*n)),r.height=Math.max(1,Math.round(e.height*n));let a=r.getContext("2d");return a===null?null:(a.drawImage(i,e.x,e.y,e.width,e.height,0,0,r.width,r.height),a.getImageData(0,0,r.width,r.height))}catch{return null}}function lt(i){if(i.enumerateDevices!==void 0)return i.enumerateDevices;if(i.getUserMedia===void 0&&!(typeof navigator>"u"||typeof navigator.mediaDevices?.enumerateDevices!="function"))return()=>navigator.mediaDevices.enumerateDevices()}export{ut as a,U as b,Pe as c,xe as d,ve as e,Ge as f,Le as g,Fe as h,Ve as i,S as j,Ue as k,H as l,be as m,I as n,Ke as o,ft as p,Se as q,P as r,ze as s,k as t,Ze as u,w as v,et as w,B as x,tt as y,W as z,rt as A,nt as B,ke as C};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{d as re,h as Re,i as ve,j as Le,l as Te}from"./chunk-G6LKLN4U.js";import{a as ne,e as Ce,g as xe}from"./chunk-VVUQ4PFU.js";import{m as j}from"./chunk-7252SFZ6.js";import{a as we,g as ke}from"./chunk-7QZWBDI5.js";import{k as te}from"./chunk-CPUECYAJ.js";function _e(e,t){let n=new Set(e.flatMap(r=>r.sides.filter(i=>i[t]!==null).map(i=>i.side)));return n.size===1?[...n][0]:null}function ot(e){let t=Ce.find(r=>r.docType===e),n=t.mrz==="none"?null:t.mrz==="td3"?"single":"verso";return{sides:t.sides,format:xe(e),mrz:t.mrz==="none"?"none":"required",mrzSide:n,barcodeSide:null,portraitSide:t.portraitSide}}function Pe(e,t){if(t.length===0)return ot(e);let n=t.some(s=>s.sides.length>1),r=new Set(t.map(s=>s.format)),i=r.size===1?[...r][0]:"card",c=t.filter(s=>s.sides.some(p=>p.mrz!==null)).length,u=t.find(s=>s.sides.length>1===n)?.sides.find(s=>s.portrait)?.side;return{sides:n?["recto","verso"]:["single"],format:i,mrz:c===t.length?"required":c===0?"none":"optional",mrzSide:_e(t,"mrz"),barcodeSide:_e(t,"barcode"),portraitSide:u??(n?"recto":"single")}}function Ee(e,t){if(e===void 0)return[];let n=e.toUpperCase();return Object.prototype.hasOwnProperty.call(ne,n)?ne[n]?.[t]??[]:[]}async function Oe(e,t,n){return await e(t)?n:n==="recto"?"verso":"recto"}var at={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 it(e){let{deviceMemory:t,effectiveType:n,saveData:r,downlinkMbps:i,sourceLongEdge:c}=e,u=r===!0||n==="slow-2g"||n==="2g"||i!=null&&i>0&&i<1,s=t!=null&&t<=2,p=n==="4g"||i!=null&&i>=5,d=t!=null&&t>=6,M;u||s?M="low":p&&d?M="good":M="mid";let f=at[M],_=c&&c>0?Math.min(f.maxLongEdge,c):f.maxLongEdge;return{tier:M,...f,maxLongEdge:_}}function Ae(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),it(t)}function st(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 ut(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 ct(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 Be(e,t,n,r,i){if(t<=0||n<=0)return null;let{width:c,height:u}=ut(t,n,r.maxLongEdge),s=document.createElement("canvas");s.width=c,s.height=u;let p=s.getContext("2d");if(!p)return null;p.drawImage(e,0,0,c,u);let d=k=>new Promise((S,x)=>{s.toBlob(l=>l?S(l):x(new Error("canvas toBlob returned null")),"image/jpeg",k)}),M=st(i,r.qMin,r.qMax),{blob:f,quality:_}=await ct(d,{startQ:M,qMin:r.qMin,budgetBytes:r.payloadTargetBytes}).finally(()=>{s.width=0,s.height=0});if(f.size>5242880)throw new Error("encoded document exceeds the 5242880-byte media cap");return{blob:f,quality:_,width:c,height:u}}async function oe(e){let t=Ae(Math.max(e.width,e.height)),n=await Be(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 Et(e){let t=await createImageBitmap(e);try{return await oe(t)}finally{t.close()}}var At=250,Bt=.6,It=1800,Ft=6e3,Wt=2e3,Ie=.16;function ie(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 Fe=e=>e==="recto"?"verso":"recto",We=e=>e.phase==="framing"||e.phase==="locking"||e.phase==="flipCue"||e.phase==="reaskRecto",se=e=>(e.captured.recto!==void 0?1:0)+(e.captured.verso!==void 0?1:0)+e.pending.length;function ae(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 lt(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:c}=e;r&&(c=c??n),c!==void 0&&n-c>=250&&(i=!0),r||(c=void 0);let u=e.flipTimeoutSpent&&!(i&&!e.flipped),s={...e,lastReportAt:n,flipped:i,awaySince:c,flipTimeoutSpent:u,lastArea:t.areaFrac};if(!We(e))return s;if(e.needFlip&&!i){if(!t.ready)return{...s,phase:e.restPhase,goodSince:void 0};let p=e.lastShot!==void 0&&e.pending.includes(e.lastShot);if(u||p)return{...s,goodSince:void 0,phase:e.restPhase};let d=e.goodSince??n;return n-d>=1800?{...s,goodSince:d,phase:"capturing",flipTimeoutSpent:!0,timeoutCapture:!0}:{...s,goodSince:d,phase:e.restPhase}}return t.ready?{...s,phase:"capturing",goodSince:e.goodSince??n}:{...s,goodSince:void 0,phase:t.locking?"locking":e.restPhase}}function dt(e,t){if(!We(e)||e.manualShutter)return e;let n=t-e.lastReportAt>=2e3,r=t-e.lastCaptureAt>=6e3;return n||r?{...e,manualShutter:!0}:e}function mt(e,t,n){let r=e.layout==="singlePage",i=r?{recto:t}:e.captured,c=r?[]:[...e.pending,t],u={...e,captured:i,pending:c,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||se({captured:i,pending:c})>=2?{...u,phase:"reading",restPhase:"framing",current:void 0,needFlip:!1}:{...u,phase:"flipCue",restPhase:"flipCue",current:void 0,needFlip:!0}}function ze(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:Fe(n),needFlip:!0,flipTimeoutSpent:!0,goodSince:void 0,manualShutter:!0,notice:"same_face",lastCaptureAt:-1,lastReportAt:-1}:e}function pt(e,t,n){if(!e.pending.includes(t))return e;if(e.captured[n]!==void 0)return ze(e,t,n);let r=e.pending.filter(p=>p!==t),i={...e,pending:r,captured:{...e.captured,[n]:t}};if(se(i)!==1||e.layout==="singlePage")return i;let c=Fe(n),u=c==="recto"&&e.restPhase==="reaskRecto"?"reaskRecto":"flipCue",s=e.phase==="flipCue"||e.phase==="reaskRecto"||e.phase==="framing";return{...i,restPhase:u,current:c,phase:s?u:e.phase}}function ft(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(d=>d!==n),c=e.layout==="twoSided"&&se({captured:r,pending:i})>0,u=e.lastShotByTimeout||n===e.lastShot!==e.flipped,s=c&&!u,p=s?t.side==="recto"?"reaskRecto":"flipCue":"framing";return{...e,captured:r,pending:i,readSides:e.readSides.filter(d=>d!==t.side),lastShot:e.lastShot===n?void 0:e.lastShot,notice:t.issue,goodSince:void 0,manualShutter:!1,phase:p,restPhase:p,current:t.side,needFlip:s,flipped:!1,flipTimeoutSpent:!1,awaySince:void 0,lastCaptureAt:-1,lastReportAt:-1}}function Ue(e,t){switch(t.type){case"report":return lt(ae(e,t.at),t.report,t.at);case"tick":return dt(ae(e,t.at),t.at);case"captured":return mt(ae(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 pt(e,t.id,t.side);case"duplicate":return ze(e,t.id,t.side);case"readOk":{let n=e.readSides.includes(t.side)?e.readSides:[...e.readSides,t.side],r=["recto","verso"].filter(c=>e.captured[c]!==void 0),i=e.phase==="reading"&&e.pending.length===0&&r.every(c=>n.includes(c));return{...e,readSides:n,flipTimeoutSpent:!1,phase:i?"result":e.phase}}case"readFailed":return ft(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{...ie(e.layout,-1),lastCaptureAt:-1,lastReportAt:-1};default:return e}}function gt(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 ht(e,t=!1){let{detectMrzBand:n}=await import("./mrz-band-VYHOTDHY.js");return gt(n,e,t)}async function ue(e,t=480,n,r=n!=null){let i=n??{x:0,y:0,width:e.width,height:e.height},c=Math.max(1,Math.round(i.height/i.width*t)),u=document.createElement("canvas");u.width=t,u.height=c;try{let s=u.getContext("2d");return s===null?"recto":(s.drawImage(e,i.x,i.y,i.width,i.height,0,0,t,c),await ht(s.getImageData(0,0,t,c),r))}finally{u.width=0,u.height=0}}async function Ut(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 c=i.getContext("2d");return c===null?(n.close(),null):(c.drawImage(n,0,0,t,r),n.close(),c.getImageData(0,0,t,r))}catch{return null}}var ce=(e,t,n)=>Math.min(n,Math.max(t,Math.round(e))),$=e=>Math.round(Math.min(1,Math.max(0,e))*1e4)/1e4;async function Ne(e,t,n,r){let i=r.decode??(p=>createImageBitmap(p)),c=async()=>e.stillRead(await i(t),r.region??[0,0,1,1],r.detectorLimit),u;try{u=await c()}catch{try{await new Promise(p=>setTimeout(p,r.retryMs??300)),u=await c()}catch{return null}}let s=u.mrzBox;return s===void 0?null:{engine:r.engine,source:"live_mrz",format:n.format,lineCount:ce(n.lineCount,2,3),checkDigitsValid:!0,stillConfirmed:u.valid&&u.digest===n.digest,band:[$(s[0]),$(s[1]),$(Math.min(s[2],1-s[0])),$(Math.min(s[3],1-s[1]))],digest:n.digest,framesToValid:ce(n.framesToValid,1,1e3),msToValid:ce(n.msToValid,0,12e4)}}function Gt(e){let t=null;return e?.then(n=>{t=n}),()=>t}var bt=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]),yt=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 Ge(e,t=globalThis){let n=t.WebAssembly?.validate;if(typeof n!="function")return{ok:!1,reason:"simd"};try{if(!n.call(t.WebAssembly,bt)||!n.call(t.WebAssembly,yt))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 qe(e=globalThis){let t=e.navigator?.connection;return t?.saveData===!0||["slow-2g","2g","3g"].includes(t?.effectiveType??"")}var E=class extends Error{constructor(t){super(t),this.name="OcrEngineError",this.code=t}};function He(){let e=t=>(t.close(),Promise.reject(new E("unsupported")));return{ready:Promise.resolve("unsupported"),busy:!1,bandRead:e,stillRead:e,layoutRead:e,dispose:()=>{}}}function Xe(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 He()}catch{return He()}let n=new Map,r=0,i=!1,c=!1,u=!1;t.addEventListener("message",l=>{let h=l.data,R=n.get(h.id);R&&(n.delete(h.id),R.resolve(h))});let s=()=>{for(let l of n.values())l.reject(new E("error"));n.clear(),d()};t.addEventListener("error",s),t.addEventListener("messageerror",s);function p(l,h=[]){if(i)return Promise.reject(new E("disposed"));let R=++r;return new Promise((B,A)=>{n.set(R,{resolve:B,reject:A});try{t.postMessage({...l,id:R},h)}catch{n.delete(R),A(new E("error"))}})}function d(){if(!i){i=!0;try{t.postMessage({id:++r,kind:"dispose"})}catch{}t.terminate();for(let l of n.values())l.reject(new E("disposed"));n.clear()}}let M=(async()=>{let l=await p({kind:"init",baseUrl:e.baseUrl,salt:e.salt,detectorLimit:e.tuning.detectorLimit,maxDownloadMs:e.tuning.maxDownloadMs});if(l.kind==="failed")return l.reason;if(l.kind!=="ready")return"error";let h=await p({kind:"warmup"});return h.kind!=="ready"?"error":{warmupMs:h.warmupMs,downloadMs:l.downloadMs,cached:l.cached}})().catch(()=>"error"),f,_=new Promise(l=>{f=setTimeout(()=>l("timeout"),e.tuning.loadTimeoutMs)}),k=Promise.race([M,_]).then(l=>(clearTimeout(f),typeof l=="string"?d():u=!0,i&&typeof l!="string"?"error":l));(e.page===void 0?globalThis.addEventListener?globalThis:null:e.page)?.addEventListener("pagehide",d,{once:!0});async function x(l,h,R){if(i)throw h.close(),new E("disposed");if(!u)throw h.close(),new E("not_ready");if(c)throw h.close(),new E("busy");c=!0;let B;try{let A=new Promise((X,W)=>{B=setTimeout(()=>{W(new E("timeout")),d()},e.tuning.readTimeoutMs??1e4)}),O=await Promise.race([p(l,[h]),A]);if(O.kind===R){let{id:X,...W}=O;return W}throw new E(O.kind==="error"?O.code:O.kind==="failed"?O.reason:"error")}finally{clearTimeout(B),c=!1}}return{ready:k,get busy(){return c},bandRead:(l,h=e.tuning.detectorLimit)=>x({kind:"band",bitmap:l,detectorLimit:h},l,"band"),stillRead:(l,h,R=e.tuning.detectorLimit)=>x({kind:"still",bitmap:l,region:h,detectorLimit:R},l,"band"),layoutRead:(l,h)=>x({kind:"layout",bitmap:l,detectorLimit:h},l,"layout"),dispose:d}}var H="sekyro-ocr-1",le=e=>e!==null&&typeof e=="object"?e:{},T=(e,t,n,r)=>typeof e=="number"&&Number.isFinite(e)&&e>=t&&e<=n?e:r,Ye=(e,t)=>typeof e=="boolean"?e:t,Ve=e=>{let t=typeof e=="string"?/^sekyro-ocr-(\d{1,4})$/.exec(e):null;return t?Number(t[1]):Number.POSITIVE_INFINITY};function Qe(e,t={}){let n=le(e),r=le(n.liveMrz),i=le(n.frontLock),c=Ve(t.engine??H),u=t.mode==="off",s=l=>l.enabled===!0?l.arm==="live"?"live":"control":null,p=s(r),d=s(i),M=(l,h)=>!u&&h==="live"&&Ve(l.minEngine??H)<=c,f=Le,_=M(r,p)?{detectorLimit:T(r.detectorLimit,320,1600,f.detectorLimit),bandMaxWidthPx:T(r.bandMaxWidthPx,320,4096,f.bandMaxWidthPx),minBandWidthPx:T(r.minBandWidthPx,0,4096,f.minBandWidthPx),bandTop:T(r.bandTop,0,.95,f.bandTop),minIntervalMs:T(r.minIntervalMs,0,5e3,f.minIntervalMs),stableReads:Math.round(T(r.stableReads,1,10,f.stableReads)),profileReads:Math.round(T(r.profileReads,1,100,f.profileReads)),maxReadMs:T(r.maxReadMs,50,6e4,f.maxReadMs),searchTimeoutMs:T(r.searchTimeoutMs,1e3,12e4,f.searchTimeoutMs),hint:Ye(r.hint,!0),stillConfirm:Ye(r.stillConfirm,!0)}:null,k=ve,S=(l,h,R)=>T(i[l],h,R,k[l]),x=M(i,d)?{minLines:Math.round(S("minLines",1,50)),fillMin:S("fillMin",0,1),fillMax:S("fillMax",0,2),offsetMax:S("offsetMax",0,1),steadyFillDelta:S("steadyFillDelta",0,1),steadyOffsetDelta:S("steadyOffsetDelta",0,1),layoutShiftMax:S("layoutShiftMax",0,1),lineCountDelta:Math.round(S("lineCountDelta",0,50)),lockMs:S("lockMs",0,3e4),steadyMs:S("steadyMs",0,3e4),minFrames:Math.round(S("minFrames",1,100)),minIntervalMs:S("minIntervalMs",0,5e3),maxWidthPx:S("maxWidthPx",160,2048),detectorLimit:S("detectorLimit",320,1600),searchTimeoutMs:S("searchTimeoutMs",1e3,12e4)}:null;return{enabled:_!==null||x!==null,liveMrz:_,textLock:x,liveMrzArm:p,frontLockArm:d,load:{detectorLimit:_?.detectorLimit??x?.detectorLimit??f.detectorLimit,loadTimeoutMs:T(r.loadTimeoutMs,1e3,12e4,2e4),maxDownloadMs:T(r.maxDownloadMs,1e3,12e4,2e4),minDeviceMemoryGb:T(r.minDeviceMemoryGb,0,64,2)},reportSampleRate:T(r.reportSampleRate,0,1,1)}}function Ke(e,t){return e.enabled?!(t.probe??Ge)({minDeviceMemoryGb:e.load.minDeviceMemoryGb}).ok||(t.slow??qe)()?{ok:!1,reason:"unsupported"}:{ok:!0,engine:Xe({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 St(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))),de=(e,t,n)=>e===void 0||!Number.isFinite(e)?void 0:Math.min(n,Math.max(t,Math.round(e)));function je(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",c={kind:"live_mrz",platform:"web",engine:e.engine??H,arm:e.arm,capture:e.capture,outcome:i,reads:de(t?.reads??0,0,1e4)??0,browser:e.browser??St()},u=(s,p)=>{p!==void 0&&(c[s]=p)};return u("format",t?.format),u("framesToValid",de(t?.framesToValid,1,1e4)),u("msToValid",F(t?.msToValid)),u("framesToLock",de(t?.framesToLock,1,1e4)),u("msToLock",F(t?.msToLock)),u("msToCapture",F(e.msToCapture)),u("readP50Ms",F(t?.readP50Ms)),u("readP90Ms",F(t?.readP90Ms)),u("deviceClass",t?.deviceClass),n!==null&&(u("warmupMs",F(n.warmupMs)),u("downloadMs",F(n.downloadMs)),u("cached",n.cached)),u("stillConfirmed",e.stillConfirmed),u("typeMismatch",e.typeMismatch),c}function me(e,t){return e===void 0?!1:t==="passport"?e!=="TD3":e==="TD3"}var Mt=2;async function Dt(e){let t=await import("./capture-session-doc-ESEZJBQM.js");return new t.CaptureSessionDoc(e)}function wt(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 kt(e,t,n){let r=[e.topLeft,e.topRight,e.bottomRight,e.bottomLeft],i=0;for(let c=0;c<r.length;c+=1){let u=r[c],s=r[(c+1)%r.length];i+=u.x*s.y-s.x*u.y}return t>0&&n>0?Math.abs(i)/2/(t*n):0}function ln(){import("./capture-session-doc-ESEZJBQM.js").then(e=>e.warmDocDetector()).catch(()=>{})}function dn(e){return Ct(e,{}).handle}function Ct(e,t){let n=we(),r=ke({enabled:e.keepScreenAwake!==!1}),i=t.decode??(o=>createImageBitmap(o)),c=t.blurRefuseSharpnessMax??.16,u=t.now??(()=>performance.now()),s=Pe(e.documentType,t.catalogCapture===!0?Ee(e.issuer,e.documentType):[]),p=s.sides.length===1||e.side==="single",d=ie(p?"singlePage":"twoSided",u());if(!p&&(e.side==="recto"||e.side==="verso")){let o=e.side==="recto"?"verso":"recto";d={...d,captured:{[o]:"server"},readSides:[o],current:e.side,phase:"flipCue",restPhase:"flipCue"}}let M="idle",f=null,_=null,k=!0,S=0,x=0,l=!1,h=!1,R="",B=null,A,O=null,X=[],W=s.mrz==="none",$e=s.barcodeSide==="recto"||s.barcodeSide==="verso"?s.barcodeSide:null,N=W&&!p?t.barcode?.side??$e:null,pe=e.barcodeAssetBaseUrl??t.barcode?.assetBaseUrl,fe=null,ge=()=>N===null||pe===void 0||t.barcode?.seen!==void 0?Promise.resolve(null):(fe??(fe=import("./barcode-detect-C5IOXMKI.js").then(o=>o.loadBarcodeDetect(pe)).catch(()=>null)),fe),Je=async(o,a)=>{if(N===null)return null;let m=N==="recto"?"verso":"recto";try{let g=t.barcode?.seen;if(g!==void 0)return await g(o)?N:m;let[L,D]=await Promise.all([ge(),a()]);if(L===null||D===null)return null;let w=Math.min(1600,D.width),y=document.createElement("canvas");y.width=w,y.height=Math.max(1,Math.round(D.height/D.width*w));try{let b=y.getContext("2d");return b===null?null:(b.drawImage(D,0,0,y.width,y.height),await Oe(L,b.getImageData(0,0,y.width,y.height),N))}finally{y.width=0,y.height=0}}catch{return null}},C=t.webOcr!==void 0&&!W?Qe(t.webOcr.captureDocument,{mode:e.liveMrz?.mode??"auto"}):null,G=null,z=C===null||!C.enabled?"off":null,Y=null,V=null,he=new WeakMap,J="";if(C!==null&&C.enabled&&t.webOcr!==void 0){let o=t.webOcr,a=Ke(C,{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){G=a.engine;let m=new Te({textLock:C.textLock,liveMrz:C.liveMrz});Y=m;let g=a.engine;g.ready.then(L=>{z=L,typeof L!="string"&&k&&m.setEngine(g)})}else z=a.reason}let U=o=>{let a=JSON.stringify(o);a!==J&&(J=a,n.emit("mrz",o))},be=(o,a)=>{let m=t.webOcr?.reports;if(m===void 0||C===null||o===void 0)return;let g=o.format==="ID-3"||o.side==="single"?"single":o.side==="verso"?"verso":"recto",L=g!=="recto"?C.liveMrzArm??C.frontLockArm:C.frontLockArm;if(L===null||Math.random()>=C.reportSampleRate)return;let D=o.via==="live_mrz"?V:null,w=()=>{let y=D?.value??null;m([je({arm:L,capture:g,assist:o.ocr??null,load:L==="control"?"off":z,...o.msToCapture!==void 0?{msToCapture:o.msToCapture}:{},...y!==null&&y.stillConfirmed!==void 0?{stillConfirmed:y.stillConfirmed}:{},...a!==void 0?{typeMismatch:me(a.format,s.format==="ID-3"?"passport":"card")}:{}})])};D!==null&&D.value===null?Promise.race([D.promise,new Promise(y=>setTimeout(y,3e3))]).then(w):w()},I=o=>{!k||o===M||(M=o,r.setActive(o==="starting"||o==="scanning"),n.emit("state",o))},Ze=(o,a)=>a===void 0?null:p?"single":o.captured.recto===a?"recto":o.captured.verso===a?"verso":null,et=o=>({phase:o.phase,captured:p?o.captured.recto!==void 0?["single"]:[]:["recto","verso"].filter(a=>o.captured[a]!==void 0),expected:p?null:o.current??null,notice:o.notice??null,lastShot:Ze(o,o.lastShot),manualShutter:o.manualShutter,torchAvailable:f?.torchAvailable()??!1,torch:h}),ye=()=>{let o=f;o!==null&&o.captureNow().catch(()=>v({type:"captureFailed",at:u()}))};function v(o){if(!k)return;let a=d;d=Ue(d,o),d.phase==="capturing"&&a.phase!=="capturing"&&Promise.resolve().then(ye),d.phase==="result"&&a.phase!=="result"&&(I("done"),Se());let m=et(d),g=JSON.stringify(m);g!==R&&(R=g,n.emit("scan",m))}function Se(){O!==null&&clearInterval(O),O=null;for(let o of X.splice(0))o();f?.destroy(),f=null,r.setActive(!1)}let Me=()=>f?.captureReport?.(),Z=!1,De=(o,a)=>{if(!(o===void 0||t.onFaceReport===void 0))try{t.onFaceReport(o,a)}catch{}},Q=o=>{J="",!(f===null||d.phase==="reading"||d.phase==="result")&&(Z=!1,f.rearm(p?"single":d.current??o))},tt=async(o,a,m,g)=>{if(V=null,g!==void 0&&G!==null&&C?.liveMrz?.hint===!0){let b={promise:Ne(G,o,g,{engine:H,detectorLimit:C.liveMrz.detectorLimit}).catch(()=>null),value:null};b.promise.then(P=>{b.value=P}),V=b}g!==void 0&&me(g.format,s.format==="ID-3"?"passport":"card")&&U({state:"mismatch",format:g.format});let L=Me();De(L,"captured"),Z=!0,be(L,g);let D=m===void 0?B:m===null?null:{quad:wt(m),frameWidth:0,frameHeight:0,inStill:!0},w={decoded:null},y=()=>(w.decoded??(w.decoded=Promise.resolve().then(()=>i(o)).catch(()=>null)),w.decoded);try{await nt(o,a,D,y,V)}finally{w.decoded!==null&&(await w.decoded)?.close()}},nt=async(o,a,m,g,L)=>{let D=`shot-${S+=1}`;if(v({type:"captured",id:D,at:u()}),e.haptics!==!1)try{globalThis.navigator?.vibrate?.(30)}catch{}if(!l&&c>0){let b=await(t.measureSharpness!==void 0?t.measureSharpness(o,m):g().then(P=>P===null?-1:Re(P,re(m?.quad??null,m?.inStill===!0?P:{width:m?.frameWidth??0,height:m?.frameHeight??0},P)))).catch(()=>-1);if(!k)return;if(Number.isFinite(b)&&b>=0&&b<c){l=!0;let P=p?"recto":d.current??(d.captured.recto===void 0?"recto":"verso");v({type:"readFailed",side:P,id:D,issue:"blurry"}),Q(P);return}}l=!1;let w;if(p)w="single";else{let b=d.current,q=(t.classify===void 0?await Je(o,g):null)??await(t.classify!==void 0?t.classify(o):g().then(K=>K===null?b??"recto":m?.inStill===!0?ue(K,480,null,!0):ue(K,480,re(m?.quad??null,{width:m?.frameWidth??0,height:m?.frameHeight??0},K)))).catch(()=>b??"recto");if(!k)return;if(d.captured[q]!==void 0&&x<Mt){x+=1,v({type:"duplicate",id:D,side:q}),Q(q==="recto"?"verso":"recto");return}w=d.captured[q]!==void 0&&b!==void 0?b:q,x=0,v({type:"classified",id:D,side:w})}let y=w==="verso"?"verso":"recto";try{let b=t.encode!==void 0?await t.encode(o):await g().then(P=>{if(P===null)throw new Error("the still could not be decoded");return oe(P)});if(!k)return;L!==null&&he.set(b.blob,L),n.emit("captured",{image:b.blob,side:w,documentType:e.documentType,...e.issuer!==void 0?{issuer:e.issuer}:{},width:b.width,height:b.height,previewDataUrl:a}),t.deferRead!==!0&&v({type:"readOk",side:y})}catch(b){v({type:"readFailed",side:y,id:D,issue:"technical"}),n.emit("error",j("generic",!0,{phase:"keyframes",name:te(b)}))}Q(y==="recto"?"verso":"recto")},rt=o=>{X.push(o.on("statechange",({state:a})=>{a==="preflight"||a==="acquiring"?I("starting"):a==="positioning"?I("scanning"):a==="captured"?I("captured"):a==="error"&&I("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"?U({state:"fallback",reason:m.reason}):m.state==="valid"?U({state:"valid",format:m.format}):m.state==="reading"?U({state:"reading",...m.format?{format:m.format}:{},...m.coach?{coach:m.coach}:{}}):U({state:"searching"}));let g=a.quad===null?0:kt(a.quad,a.frameWidth,a.frameHeight);B=a.quad===null?null:{quad:a.quad,frameWidth:a.frameWidth,frameHeight:a.frameHeight},v({type:"report",report:{present:a.quad!==null&&a.plausible||a.guide?.detected===!0,ready:a.ready===!0,locking:a.p>=.5,areaFrac:g},at:u()})}),o.on("error",({kind:a,retryable:m,detail:g})=>n.emit("error",j(a,m,g))),o.on("artifacts",a=>{tt(a.keyframe,a.previewDataUrl,a.docRegion,a.liveMrz)}))},ee=()=>(_??(_=(async()=>{if(k){if(ge(),f===null){let o;try{o=await(t.createEngine??Dt)({...t.engineOptions??{},...A!==void 0?{guide:A}:{},video:e.video,format:s.format,side:p?"single":e.side??"recto",autoCapture:!1,...Y!==null?{ocr:Y}:{}})}catch(m){I("error"),n.emit("error",j("models",!0,{phase:"models",name:te(m)}));return}if(!k){o.destroy();return}f=o,rt(o);let a=t.tickMs??500;a>0&&(O=setInterval(()=>v({type:"tick",at:u()}),a))}v({type:"clockRestart"}),C!==null&&C.liveMrzArm==="live"&&(z==="unsupported"||z==="off")&&U({state:"fallback",reason:z}),await f.start()}})().finally(()=>{_=null})),_);return{handle:{get state(){return M},on:(o,a)=>n.on(o,a),start:ee,retry:()=>{if(f===null&&d.phase==="result"){v({type:"retake"}),x=0,l=!1,ee();return}if(f!==null&&M!=="error"){v({type:"retake"}),x=0,l=!1,f.rearm(p?"single":void 0);return}ee()},setSide:o=>{p||o==="single"||(d.current!==o&&(d={...d,current:o}),v({type:"clockRestart"}),d.phase!=="reading"&&d.phase!=="result"&&f?.rearm(o))},shutter:ye,focusAt:(o,a)=>{f?.focusAt?.(o,a)},setGuide:o=>{A=o,f?.setGuide?.(o)},setTorch:o=>{h=o,f?.setTorch(o),v({type:"tick",at:u()})},destroy:()=>{if(k&&f!==null&&M!=="done"){let o=Me();!Z&&o!==void 0&&o.ticks>0&&De(o,"abandoned"),be(o,void 0)}k=!1,Se(),Y?.setEngine(null),G?.dispose(),G=null,n.clear()}},setFlowState:o=>{(d.phase==="reading"||d.phase==="result")&&I(o==="done"&&d.phase!=="result"?"scanning":o)},settle:(o,a)=>{let m=o==="verso"?"verso":"recto";v(a.ok?{type:"readOk",side:m}:{type:"readFailed",side:m,issue:a.issue}),a.ok||Q(m)},takeDeviceRead:o=>he.get(o.image)?.value??null}}export{Et as a,At as b,Bt as c,It as d,Ft as e,Wt as f,Ie as g,ie as h,Ue as i,gt as j,ht as k,Ut as l,Ne as m,Gt as n,H as o,Qe as p,Ke as q,St as r,je as s,me as t,Mt as u,ln as v,dn as w,Ct as x};
|
|
@@ -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
|
+
import{p as k,r as w}from"./chunk-CPUECYAJ.js";import{e as M}from"./chunk-TSA6GHUG.js";var u=class extends Error{constructor(){super("the back camera could not be opened");this.name="BackCameraUnavailableError"}},S=new Set(["NotAllowedError","PermissionDeniedError","SecurityError"]);function h(r){try{return String(r?.name??"")}catch{return""}}function c(r){if(r!==null)for(let t of r.getTracks())t.stop()}async function C(r,t,n){let a=e=>({video:{...t,...e},audio:!1});if(r==="user")return n.getUserMedia(a({facingMode:"user"}));let o=e=>M(e)!=="user";try{let e=await n.getUserMedia(a({facingMode:{exact:"environment"}}));if(o(e))return e;c(e)}catch(e){if(S.has(h(e)))throw e}let d=!1,l=async()=>{if(n.enumerateDevices===void 0||d)return null;let e;try{e=w(await n.enumerateDevices()).slice(0,3)}catch{return null}d=e.length>0;for(let v of e){let i;try{i=await n.getUserMedia(a({deviceId:{exact:v}}))}catch(g){if(S.has(h(g)))throw g;continue}if(o(i))return i;c(i)}return null},m=await l();if(m!==null)return m;let s=await n.getUserMedia(a({facingMode:"environment"}));if(o(s))return s;c(s);let f=await l();if(f!==null)return f;throw new u}export{u as a,C as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function c(e,n){return{video:{width:{ideal:1280,max:1280},height:{ideal:720,max:720},facingMode:n,frameRate:{ideal:24,max:30}},audio:!1}}var o=600;function i(){if(typeof window>"u"||typeof navigator>"u")return"desktop";let e=navigator.userAgentData,n=e?.mobile||/Android|i(Pad)?OS/.test(String(e?.platform)),t=String(navigator.userAgent??"");if(/iPhone|iPod/i.test(t))return"phone";if(/iPad/i.test(t))return"tablet";if(/Android/i.test(t))return/Mobile/i.test(t)?"phone":"tablet";if(/BlackBerry|IEMobile|Opera Mini/i.test(t))return"phone";if(!n){if(Number(navigator.maxTouchPoints??0)<=1)return"desktop";if(/Macintosh/.test(t))return"tablet";if(/Windows NT|CrOS/.test(t)||!s())return"desktop"}let r=a();return r>0&&r<o?"phone":"tablet"}function u(){return i()!=="desktop"}function a(){try{let e=window.screen,n=Number(e?.width??0),t=Number(e?.height??0);return n>0&&t>0?Math.min(n,t):0}catch{return 0}}function d(e){try{let t=e?.getVideoTracks?.()[0]?.getSettings?.().facingMode;return t==="user"||t==="environment"?t:null}catch{return null}}function s(){try{return typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}catch{return!1}}var l=.45,f=.9,p=.4;export{c as a,o as b,i as c,u as d,d as e,l as f,f as g,p as h};
|