@sekyro/web 0.1.0-rc.7 → 0.1.0-rc.8
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 +87 -0
- package/LICENSE +25 -16
- package/README.md +3 -5
- package/THIRD-PARTY-NOTICES.txt +154 -0
- package/dist/background-monitor-A7FKJOAG.js +1 -0
- package/dist/capture-session-doc-YBE3UMJJ.js +1 -0
- package/dist/{capture-session-v3-Okq0EQHG.d.ts → capture-session-v3-CQK-G-qX.d.ts} +72 -3
- package/dist/{capture-session-v3-UQU_WjO2.d.cts → capture-session-v3-Dvob-uH2.d.cts} +72 -3
- package/dist/chunk-4RS2YIL4.js +1 -0
- package/dist/chunk-7V2M6Y2W.js +1 -0
- package/dist/chunk-7ZCZY3ZP.js +1 -0
- package/dist/chunk-A3FUGHAH.js +2 -0
- package/dist/chunk-BPE5NSQ2.js +1 -0
- package/dist/chunk-CJHMFPL6.js +1 -0
- package/dist/chunk-DFTCAWMP.js +1 -0
- package/dist/chunk-DK5YPBDQ.js +1 -0
- package/dist/chunk-DQWW4OCK.js +1 -0
- package/dist/chunk-FHJ7HO3M.js +1 -0
- package/dist/chunk-G6LKLN4U.js +1 -0
- package/dist/chunk-GI3UFGRQ.js +1 -0
- package/dist/{chunk-IYUOYINS.js → chunk-LQ7C44JG.js} +1 -1
- package/dist/chunk-M43ET4NJ.js +1 -0
- package/dist/chunk-MXWLCDFX.js +1 -0
- package/dist/chunk-MY6EXEL2.js +1 -0
- package/dist/chunk-O5WKNZ2C.js +1 -0
- package/dist/chunk-OKWG3PVH.js +1 -0
- package/dist/chunk-POIQGEZM.js +1 -0
- package/dist/chunk-RI3E7GBN.js +1 -0
- package/dist/chunk-RNRFHUJA.js +1 -0
- package/dist/chunk-RVHAKRAI.js +1 -0
- package/dist/chunk-SMKCBUJL.js +1 -0
- package/dist/chunk-TDLIXFDT.js +1 -0
- package/dist/chunk-XLN5OT25.js +1 -0
- package/dist/chunk-YDQBVWXG.js +1 -0
- package/dist/chunk-YPG7CB4O.js +1 -0
- package/dist/client/index.cjs +1 -1
- package/dist/client/index.d.cts +13 -3
- package/dist/client/index.d.ts +13 -3
- package/dist/client/index.js +1 -1
- package/dist/core/index.cjs +1 -1
- package/dist/core/index.d.cts +3 -3
- package/dist/core/index.d.ts +3 -3
- package/dist/core/index.js +1 -1
- 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 -1
- 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 -1
- package/dist/create-document-capture-T4APHJMY.js +1 -0
- package/dist/create-portrait-capture-B57GE5FU.js +1 -0
- package/dist/create-verification-C0AVIcVW.d.ts +2787 -0
- package/dist/create-verification-DoFpgzok.d.cts +2787 -0
- package/dist/{detect-worker-CKXHlXx9.d.cts → detect-worker-DclNxkZT.d.cts} +6 -0
- package/dist/{detect-worker-CKXHlXx9.d.ts → detect-worker-DclNxkZT.d.ts} +6 -0
- package/dist/detector-scanic-YCDNLCGV.js +1 -0
- package/dist/icao-gate-D8qm1O2t.d.cts +1655 -0
- package/dist/icao-gate-D8qm1O2t.d.ts +1655 -0
- package/dist/icao-gate-PWBMKRGC.js +1 -0
- package/dist/icao-tuning-4GGVX6B4.js +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +52 -6
- package/dist/index.d.ts +52 -6
- package/dist/index.js +1 -1
- package/dist/internal/index.cjs +1 -1
- package/dist/internal/index.d.cts +345 -308
- package/dist/internal/index.d.ts +345 -308
- package/dist/internal/index.js +1 -1
- 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-UBK4B4CG.js +1 -0
- package/dist/segmenter-USLNBX65.js +1 -0
- package/dist/turnstile-FATNZ4AG.js +1 -0
- package/package.json +22 -4
- package/sbom.cdx.json +8 -8
- package/dist/chunk-B45J4KC3.js +0 -1
- package/dist/chunk-BMA36W2W.js +0 -1
- package/dist/chunk-P7ECRN47.js +0 -1
- package/dist/chunk-YOB4ZTYN.js +0 -1
- package/dist/chunk-YQBK6OIM.js +0 -1
- package/dist/create-verification-C2JhOO6Y.d.cts +0 -533
- package/dist/create-verification-CGazwtAh.d.ts +0 -533
- package/dist/detector-scanic-VQFFXKTL.js +0 -1
- package/dist/hosted-client-kBeq-mnJ.d.cts +0 -602
- package/dist/hosted-client-kBeq-mnJ.d.ts +0 -602
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function k(){let t=new Map;return{on(o,n){let e=t.get(o);e===void 0&&(e=new Set,t.set(o,e));let l=n;return e.add(l),()=>{e?.delete(l)}},emit(o,n){let e=t.get(o);if(e!==void 0)for(let l of[...e])l(n)},clear(){t.clear()}}}function u(){if(typeof navigator>"u"||!("wakeLock"in navigator))return null;let t=navigator.wakeLock;return typeof t?.request=="function"?t:null}function f(){return typeof document>"u"||document.visibilityState==="visible"}function v(t){try{t.release().catch(()=>{})}catch{}}function p(t={}){if(t.enabled===!1)return{setActive:()=>{}};let o=!1,n=null,e=!1,l=!1,s=()=>{if(!o||e||n!==null&&!n.released)return;let i=u();if(i===null||!f())return;let r;try{r=i.request("screen")}catch{return}e=!0,r.then(a=>{if(e=!1,!o){v(a);return}n=a,a.addEventListener?.("release",()=>{n===a&&(n=null)})},()=>{e=!1})},c=()=>{f()&&s()},d=i=>{typeof document>"u"||i===l||(l=i,i?document.addEventListener("visibilitychange",c):document.removeEventListener("visibilitychange",c))};return{setActive:i=>{if(o=i,i){if(u()===null)return;d(!0),s();return}if(d(!1),n!==null){let r=n;n=null,v(r)}}}}export{k as a,p as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var w=[468,473],K=[[33,133],[362,263]],V=[[33,7,163,144,145,153,154,155,133,173,157,158,159,160,161,246],[362,382,381,380,374,373,390,249,263,466,388,387,386,385,384,398]],D=1;function S(e){let n=Number.POSITIVE_INFINITY,o=Number.POSITIVE_INFINITY,t=Number.NEGATIVE_INFINITY,s=Number.NEGATIVE_INFINITY;for(let r of e)r.x<n&&(n=r.x),r.y<o&&(o=r.y),r.x>t&&(t=r.x),r.y>s&&(s=r.y);return e.length===0?{x:0,y:0,width:0,height:0}:{x:n,y:o,width:t-n,height:s-o}}var _=(e,n)=>({x:(e.x+n.x)/2,y:(e.y+n.y)/2});function $(e,n,o){if(e.length<468)return null;let t=l=>{let i=e[l];return{x:i.x*n,y:i.y*o}},s=[0,1].map(l=>{let i=e.length>w[1]?t(w[l]):null,[c,p]=K[l];return i??_(t(c),t(p))}),r=V.map(l=>S(l.map(t))),h=[];for(let l=0;l<Math.min(e.length,468);l+=1)h.push(t(l));let[d,m]=s,u=d.x>m.x,b=u?m:d,f=u?d:m;return{leftEye:b,rightEye:f,iod:Math.hypot(f.x-b.x,f.y-b.y),box:S(h),nose:t(D),leftEyeBox:u?r[1]:r[0],rightEyeBox:u?r[0]:r[1]}}var R=180/Math.PI;function F(e,n="column"){if(e.length<16||e.some(l=>!Number.isFinite(l)))return null;let o=(l,i)=>n==="column"?e[i*4+l]:e[l*4+i],t=Math.hypot(o(0,0),o(1,0),o(2,0))||1,s=o(0,0)/t,r=o(1,0)/t,h=o(2,0)/t,d=o(2,1)/t,m=o(2,2)/t,u=Math.asin(Math.max(-1,Math.min(1,-h)))*R,b=Math.atan2(d,m)*R,f=Math.atan2(r,s)*R;return{yaw:u,pitch:b,roll:f}}function B(e){return Math.atan2(e.rightEye.y-e.leftEye.y,e.rightEye.x-e.leftEye.x)*R}var E={width:480,height:640,eyeX:240,eyeY:289,iodMin:120,iodMax:160};function G(e){let n=E,o=e.iod>=n.iodMin&&e.iod<=n.iodMax?1:n.iodMin/Math.max(e.iod,1e-6),t=n.width/o,s=n.height/o,r=_(e.leftEye,e.rightEye);return{x:r.x-n.eyeX/n.width*t,y:r.y-n.eyeY/n.height*s,width:t,height:s}}function N(e,n,o){let t=Math.max(0,-e.x),s=Math.max(0,-e.y),r=Math.max(0,e.x+e.width-n),h=Math.max(0,e.y+e.height-o);return Math.max((t+r)/e.width,(s+h)/e.height)}function ee(e,n,o,t){let s=G(e),r=s.x+s.width/2,h=s.y+s.height/2,d=E.width/E.height,m=Math.max(s.height*t.margin,t.minHeight,t.minWidth/d);m=Math.min(m,o,n/d);let u=m*d,b=Math.min(Math.max(r-u/2,0),Math.max(0,n-u)),f=Math.min(Math.max(h-m/2,0),Math.max(0,o-m));return{x:Math.round(b),y:Math.round(f),width:Math.round(u),height:Math.round(m)}}var v=["face","framing","pose","eyes","mouth","glare","lighting","background","resolution","sharpness"],H=new Set(["glare","background"]),x=e=>({pass:!0,value:e,coach:null}),y=(e,n)=>({pass:!1,value:e,coach:n}),I=(e,n)=>({pass:e,value:null,coach:e?null:n,none:!0});function X(e,n){let o=e.pose,t;if(o!==null){let c=o.pitch-n.pitchOffsetDeg,p=Math.max(Math.abs(o.yaw),Math.abs(c),Math.abs(o.roll));t=Math.abs(o.yaw)<=n.yawDeg&&Math.abs(c)<=n.pitchDeg&&Math.abs(o.roll)<=n.rollDeg?x(p):y(p,"pose")}else t={...I(!1,"pose"),value:e.eyeLineRoll??null};let s=I(!1,"eyes");if(e.eyes!==null){let c=e.baseline,p=Math.min(e.eyes.left,e.eyes.right),M=Math.max(1-n.eyes.blinkMax,c!==null&&c>0&&c<=1?n.eyes.relativeMin*c:0),g=c!==null&&c>0?p/c:null;s=p>=M-1e-9?x(g):y(g,"eyes")}let r=I(!1,"mouth");if(e.mouth!==null){let{jawOpen:c,smile:p,pucker:M}=e.mouth,g=Math.max(c/n.mouth.jawOpenMax,p/n.mouth.smileMax,M/n.mouth.puckerMax);r=c<=n.mouth.jawOpenMax&&p<=n.mouth.smileMax&&M<=n.mouth.puckerMax?x(g):y(g,"mouth")}let h=e.lighting,d=I(!0,"lighting");if(h!==null){let[c,p]=n.lighting.faceLuma,[M,g]=n.lighting.halfRatio;d=h.faceLuma<c||h.faceLuma>p||h.clipped>n.lighting.clippedMax?y(h.faceLuma,"lighting"):h.halfRatio<M||h.halfRatio>g?y(h.halfRatio,"lighting_side"):x(h.faceLuma)}let m=e.uniformity,u=e.background,b=n.background.required?m!=null&&n.backgroundCheck.enabled?m.uniform?x(m.colorStd):y(m.colorStd,"background"):u===null?I(!0,"background"):u.luma>=n.background.lumaMin&&u.sd<=n.background.lumaSdMax?x(u.luma):y(u.luma,"background"):I(!0,"background"),f=n.resolution,l=Math.min(e.frameWidth,e.frameHeight)>=f.minWidth&&Math.max(e.frameWidth,e.frameHeight)>=f.minHeight,i=e.iod>=f.minIodPx&&l?x(e.iod):y(e.iod,"resolution");return{pose:t,eyes:s,mouth:r,lighting:d,background:b,resolution:i}}function L(e){let n=e?.eyeBlinkLeft,o=e?.eyeBlinkRight;return typeof n!="number"||typeof o!="number"?null:{left:1-n,right:1-o,blinkLeft:n,blinkRight:o}}function q(e,n){if(e.length===0)return null;let o=[...e].sort((s,r)=>s-r),t=Math.min(o.length-1,Math.max(0,Math.ceil(n*o.length)-1));return o[t]}function T(e,n,o){let t={},s=e.geometry;if(e.faces!==1||s===null){let c=e.faces>1?y(e.faces,"multiple_faces"):y(e.faces,"no_face");for(let p of v)t[p]=p==="face"?c:I(!1,"no_face");return{results:t,pose:null}}t.face=x(1);let r=G(s),h=N(r,e.frameWidth,e.frameHeight);t.framing=r.height>e.frameHeight*1.02||r.width>e.frameWidth*1.02?y(h,"too_close"):h>.02?y(h,"center"):x(h);let d=e.matrix!=null?F(e.matrix):null,m=L(e.blendshapes),u=e.blendshapes,b=e.stats??null,f=X({pose:d,eyeLineRoll:Math.abs(B(s)),eyes:m,baseline:o,mouth:u==null?null:{jawOpen:u.jawOpen??0,smile:Math.max(u.mouthSmileLeft??0,u.mouthSmileRight??0),pucker:u.mouthPucker??0},lighting:b?.lighting??null,background:b?.background??null,uniformity:e.backgroundCheck??null,iod:s.iod,frameWidth:e.frameWidth,frameHeight:e.frameHeight},n);Object.assign(t,f);let l=b?.eyeSpecular??null;t.glare=l===null?I(!0,"glare"):l<=n.glare.specularMax?x(l):y(l,"glare");let i=b?.sharpness??null;return t.sharpness=i===null||i>=n.sharpnessMin?x(i):y(i,"hold_still"),{results:t,pose:d}}var J={pose:"pose",eyes:"eyes",mouth:"mouth",glare:"glare",lighting:"lighting",background:"background",framing:"resolution",resolution:"resolution"};function oe(e,n={}){let o=n.policy==="alert",t=new Map,s=0,r=null,h=null,d={},m=[],u=null,b=null,f=l=>{if(m=m.filter(c=>l-c.at<=e.baseline.windowMs),m.length<e.baseline.minSamples)return null;let i=q(m.map(c=>c.open),e.baseline.percentile);return i===null||i<=0?null:Math.min(1,i)};return{push(l,i){let c=T(l,e,null),p=L(l.blendshapes);p!==null&&c.results.face.pass&&c.results.pose.pass&&m.push({at:i,open:(p.left+p.right)/2});let M=f(i),{results:g,pose:A}=T(l,e,M);for(let a of v)g[a].pass&&(a!=="eyes"||M!==null)?t.has(a)||t.set(a,i):t.delete(a);let P=a=>{let C=t.get(a);return C!==void 0&&i-C>=e.holdMs};v.filter(a=>!H.has(a)).every(P)?r??(r=i):r=null;let W=a=>a==="background"&&l.backgroundCheck!=null?e.backgroundCheck.timeoutMs:e.softGraceMs,U=a=>H.has(a)&&!g[a].pass&&r!==null&&i-r>=W(a),k=v.map(a=>({criterion:a,pass:g[a].pass,held:P(a),waived:U(a),value:g[a].value,coach:g[a].pass?null:g[a].coach}));s=k.every(a=>a.pass||a.waived)?s+1:0;let O=k.find(a=>!a.pass&&!a.waived)??null,j=k.filter(a=>a.held||a.waived).length;g.face.pass&&g.framing.pass?h??(h=i):h=null;let Y=k.every(a=>a.held||a.waived)&&s>=e.holdFrames||o&&h!==null&&i-h>=e.alertGraceMs;d={};for(let a of v){let C=J[a];C!==void 0&&g[a].none!==!0&&(d[C]=(d[C]??!0)&&g[a].pass)}return b=l.backgroundCheck??null,u={criteria:k,coach:O?.coach??"hold",failing:O?.criterion??null,progress:j/k.length,ready:Y,baseline:M,pose:A},u},last:()=>u,summary(){let l={criteria:{}};if(u===null)return l;l.verdict={...d},u.baseline!==null&&Math.round(u.baseline*1e3)>0&&(l.baselineEyeOpenness=Math.round(u.baseline*1e3)/1e3);for(let i of u.criteria){let c=i.value===null||!Number.isFinite(i.value)?null:Math.round(i.value*1e3)/1e3;l.criteria[i.criterion]=i.waived?{pass:i.pass,value:c,waived:!0}:{pass:i.pass,value:c}}if(b!==null&&e.background.required){let{pixels:i,...c}=b;l.backgroundCheck=c}return l},reset(){t.clear(),s=0,r=null,h=null,d={},u=null,b=null}}}export{$ as a,F as b,B as c,E as d,G as e,N as f,ee as g,v as h,X as i,L as j,q as k,T as l,oe as m};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as o}from"./chunk-DFTCAWMP.js";var A="sekyro-mrz-1";function w(e){return Array.from(new Uint8Array(e),t=>t.toString(16).padStart(2,"0")).join("")}async function m(e){return w(await crypto.subtle.digest("SHA-256",e))}function x(e,t){return m(new TextEncoder().encode(`${A}\0${e}\0${t.join(`
|
|
2
|
+
`)}`))}var i=class extends Error{constructor(t){super(t),this.name="AssetFailure",this.reason=t}},B=Object.keys(o.files).filter(e=>o.files[e].tier==="live"),N=Object.keys(o.files).filter(e=>o.files[e].tier==="lazy");function g(e,t){return`${e.replace(/\/+$/,"")}/${o.fp12}/${t}`}async function b(e,t,d,p=fetch,n=()=>performance.now()){let c=o.files[t],y=n(),f=async s=>{try{let r=await p(g(e,t),{cache:s,signal:d,credentials:"omit"});if(!r.ok)throw new i("download");return await r.arrayBuffer()}catch(r){throw r instanceof i?r:new i("download")}},l=async s=>s.byteLength===c.bytes&&await m(s)===c.sha256,a=await f("force-cache");if(!await l(a)&&(a=await f("reload"),!await l(a)))throw new i("integrity");return{bytes:a,ms:n()-y}}async function T(e,t,d,p=fetch,n=()=>performance.now()){let c=new AbortController,y=new Map,f=t.reduce((r,u)=>r+o.files[u].bytes,0),l=n(),a=!0,s=0;for(let r of t){let u=await b(e,r,c.signal,p,n);y.set(r,u.bytes),u.ms>=50&&(a=!1),s+=u.bytes.byteLength;let h=n()-l;if(s<f&&h>0&&h*f/s>d)throw c.abort(),new i("download")}return{files:y,downloadMs:Math.round(n()-l),cached:a}}function _(e,t){return e==="hosted"?"/models-ocr":t==="live"?"https://assets.sekyro.ai/sdk/web/ocr":"https://assets-staging.sekyro.ai/sdk/web/ocr"}export{x as a,i as b,B as c,T as d,_ as e};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as M,c as p}from"./chunk-GI3UFGRQ.js";var f={id_document:{pose:{yawDeg:7,pitchDeg:7,rollDeg:5,pitchOffsetDeg:4},eyes:{relativeMin:.62,blinkMax:.48},mouth:{jawOpenMax:.13,smileMax:.28,puckerMax:.28},lighting:{faceLuma:[95,185],halfRatio:[.77,1.31],clippedMax:.015},background:{required:!0,lumaMin:165,lumaSdMax:20},resolution:{minIodPx:110,minWidth:480,minHeight:640}},selfie:{pose:{yawDeg:7,pitchDeg:7,rollDeg:7,pitchOffsetDeg:4},eyes:{relativeMin:.62,blinkMax:.48},mouth:{jawOpenMax:.13,smileMax:.28,puckerMax:.28},lighting:{faceLuma:[95,185],halfRatio:[.77,1.31],clippedMax:.015},background:{required:!1,lumaMin:165,lumaSdMax:20},resolution:{minIodPx:100,minWidth:480,minHeight:640}}};function k(a){let i=f[a];return{profile:a,backgroundCheck:M,...i.pose,holdMs:500,alertGraceMs:3e3,eyes:{...i.eyes},mouth:{...i.mouth},lighting:{...i.lighting,faceLuma:[i.lighting.faceLuma[0],i.lighting.faceLuma[1]],halfRatio:[i.lighting.halfRatio[0],i.lighting.halfRatio[1]]},background:{...i.background},resolution:{...i.resolution},holdFrames:3,cadenceHz:10,baseline:{windowMs:3e3,minSamples:6,percentile:.8},sharpnessMin:.25,glare:{specularMax:.01},softGraceMs:4e3,cropMargin:1.25,camera:{width:1920,height:1080}}}var I=k("id_document"),D=/^[A-Za-z0-9._-]{1,64}$/;function n(a,i,r,u){return typeof a=="number"&&Number.isFinite(a)&&a>=r&&a<=u?a:i}function x(a,i,r,u){if(!Array.isArray(a)||a.length!==2)return[i[0],i[1]];let[e,l]=a,t=n(e,Number.NaN,r,u),m=n(l,Number.NaN,r,u);return Number.isNaN(t)||Number.isNaN(m)||t>m?[i[0],i[1]]:[t,m]}function o(a){return typeof a=="object"&&a!==null&&!Array.isArray(a)?a:{}}function R(a,i){let r=o(a),u=r.profile==="selfie"?"selfie":"id_document",e=u==="selfie"?k(u):I,l=o(r.eyes),t=o(r.mouth),m=o(r.lighting),c=o(r.background),s=o(r.resolution),g=o(r.baseline),w=o(r.glare),b=o(r.camera),h=typeof c.required=="boolean"?c.required:e.background.required,d=p(r.backgroundCheck);return{profile:u,yawDeg:n(r.yawDeg,e.yawDeg,1,45),pitchDeg:n(r.pitchDeg,e.pitchDeg,1,45),pitchOffsetDeg:n(r.pitchOffsetDeg,e.pitchOffsetDeg,-20,20),rollDeg:n(r.rollDeg,e.rollDeg,1,45),holdMs:n(r.holdMs,e.holdMs,0,5e3),alertGraceMs:n(r.alertGraceMs,e.alertGraceMs,0,6e4),eyes:{relativeMin:n(l.relativeMin,e.eyes.relativeMin,0,1),blinkMax:n(l.blinkMax,e.eyes.blinkMax,0,1)},mouth:{jawOpenMax:n(t.jawOpenMax,e.mouth.jawOpenMax,0,1),smileMax:n(t.smileMax,e.mouth.smileMax,0,1),puckerMax:n(t.puckerMax,e.mouth.puckerMax,0,1)},lighting:{faceLuma:x(m.faceLuma,e.lighting.faceLuma,0,255),halfRatio:x(m.halfRatio,e.lighting.halfRatio,0,10),clippedMax:n(m.clippedMax,e.lighting.clippedMax,0,1)},background:{required:h,lumaMin:n(c.lumaMin,e.background.lumaMin,0,255),lumaSdMax:n(c.lumaSdMax,e.background.lumaSdMax,0,255)},resolution:{minIodPx:n(s.minIodPx,e.resolution.minIodPx,1,2e3),minWidth:n(s.minWidth,e.resolution.minWidth,1,8e3),minHeight:n(s.minHeight,e.resolution.minHeight,1,8e3)},holdFrames:Math.round(n(r.holdFrames,e.holdFrames,1,60)),cadenceHz:n(r.cadenceHz,e.cadenceHz,1,30),baseline:{windowMs:n(g.windowMs,e.baseline.windowMs,200,3e4),minSamples:Math.round(n(g.minSamples,e.baseline.minSamples,1,300)),percentile:n(g.percentile,e.baseline.percentile,.5,1)},sharpnessMin:n(r.sharpnessMin,e.sharpnessMin,0,1),glare:{specularMax:n(w.specularMax,e.glare.specularMax,0,1)},softGraceMs:n(r.softGraceMs,e.softGraceMs,0,6e4),cropMargin:n(r.cropMargin,e.cropMargin,1,2),camera:{width:Math.round(n(b.width,e.camera.width,320,4096)),height:Math.round(n(b.height,e.camera.height,240,4096))},backgroundCheck:h?d:{...d,enabled:!1},tuningVersion:typeof i=="string"&&D.test(i)?i:null}}export{I as a,R as b};
|
|
@@ -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 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
|
+
import{b as N,c as F,d as U}from"./chunk-POIQGEZM.js";import{b as D,c as k,d as O,e as R,g as w,h as y}from"./chunk-FHJ7HO3M.js";import{b as C,c as K,d as I,e as H}from"./chunk-FPXL63KZ.js";import{b as G}from"./chunk-LQ7C44JG.js";import{c as x,d as V,f as M,h as P,j as L}from"./chunk-OKWG3PVH.js";function B(u,e){return{video:{width:{ideal:1280,max:1280},height:{ideal:720,max:720},facingMode:e,frameRate:{ideal:24,max:30}},audio:!1}}function W(){return typeof window>"u"||typeof navigator>"u"?!1:window.innerWidth<=768||/Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(String(navigator.userAgent??""))}var ne=.45,oe=.9,ce=.4;var Y=2500,j=1e3,J=1500,z=25e5,f=class extends Error{constructor(e,t){super(t??e),this.kind=e}},b=class{constructor(){this.recorder=null;this.stream=null;this.chunks=[];this.bytes=0;this.hardStopTimer=null;this.graceTimer=null;this.settled=!1}clearTimers(){this.hardStopTimer&&clearTimeout(this.hardStopTimer),this.graceTimer&&clearTimeout(this.graceTimer),this.hardStopTimer=null,this.graceTimer=null}record(e,t){if(this.recorder&&!this.settled)return Promise.reject(new f("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;let r=D();return new Promise((i,a)=>{let s;try{s=new MediaRecorder(e,r?{mimeType:r,videoBitsPerSecond:z}:{videoBitsPerSecond:z})}catch{try{s=new MediaRecorder(e)}catch{a(new f("unsupported"));return}}this.recorder=s;let n=d=>{this.settled||(this.settled=!0,this.clearTimers(),d())},o=()=>n(()=>{let d=s.mimeType||r||k,c=new Blob(this.chunks,{type:d});if(c.size===0){a(new f("generic","empty clip"));return}if(y(c)){a(new f("cliptoolarge"));return}i({blob:c,mimeType:d})});s.ondataavailable=d=>{d.data&&d.data.size&&(this.chunks.push(d.data),this.bytes+=d.data.size,this.bytes>w&&n(()=>{try{s.state!=="inactive"&&s.stop()}catch{}a(new f("cliptoolarge"))}))},s.onstop=o,s.onerror=()=>n(()=>a(new f("generic")));try{s.start(j)}catch{n(()=>a(new f("generic")));return}this.hardStopTimer=setTimeout(()=>{if(this.settled||t?.(),s.state!=="inactive"){try{s.stop()}catch{o()}this.graceTimer=setTimeout(o,J)}else o()},Y)})}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(i=>i.stop()),this.stream=null}};function q(u,e,t=.92){return new Promise((r,i)=>{let a=u.videoWidth,s=u.videoHeight;if(!a||!s){i(new Error("video-not-ready"));return}let n=e.getContext("2d");if(!n){i(new Error("no-2d-context"));return}e.width=a,e.height=s,n.scale(-1,1),n.drawImage(u,-a,0),e.toBlob(o=>o?r(o):i(new Error("empty-keyframe")),"image/jpeg",t)})}var g=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 $=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}),v=u=>Math.min(1,Math.max(0,u)),E=class{constructor(e={}){this.p=0;this.lastTickAt=null;this.lastCenter=null;this.velocityEma=0;this.qWindow=[];this.lastSizeDirection="ideal";this.t={...$,...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:i}=e,a=this.lastTickAt===null?0:Math.max(0,(i-this.lastTickAt)/1e3);this.lastTickAt=i;let s={presence:0,centering:0,size:0,pose:0,sharpness:v(r.sharpness),exposure:v(r.exposure),motion:1};if(t!==null){s.presence=1;let c=this.geometryOf(t,e);s.centering=c.centering,s.size=c.size,s.pose=c.pose,s.motion=this.motionOf(c.center,c.iod,i)}else this.lastCenter=null,this.velocityEma=0;let n=Math.min(s.presence,s.centering,s.size,s.pose,s.sharpness,s.exposure,s.motion);this.p=v(this.p+(n>=this.t.Q_GOOD?this.t.RISE_PER_S*n:-this.t.FALL_PER_S*(1-n))*a),this.qWindow.push({at:i,q:n}),this.qWindow=this.qWindow.filter(c=>c.at>=i-this.t.READY_WINDOW_MS);let o=this.qWindow.map(c=>c.q);if(o.length>=3){let c=Math.min(...o),l=o.indexOf(c);o=o.filter((h,m)=>m!==l)}let d=this.p>=1&&o.every(c=>c>=this.t.Q_GOOD);return{at:i,q:n,p:this.p,factors:s,guidanceKey:this.guidanceOf(s,r,n),ready:d,accepted:n>=this.t.Q_GOOD}}geometryOf(e,t){let{box:r,eyes:i}=e,a={x:t.frameWidth/2,y:t.frameHeight/2},s=Math.min(t.frameWidth,t.frameHeight),n=i!==void 0?{x:(i.left.x+i.right.x)/2,y:(i.left.y+i.right.y)/2}:{x:r.x+r.width/2,y:r.y+r.height/2-this.t.BOX_EYE_OFFSET_FACTOR*r.height},o=i!==void 0?Math.hypot(i.right.x-i.left.x,i.right.y-i.left.y):this.t.IOD_BOX_PROXY_FACTOR*r.width,d=Math.hypot(n.x-a.x,n.y-a.y),c=o<=0?0:1-v(d/(this.t.CENTER_FALLOFF_IOD_MULTIPLE*o)),l=s>0?o/s:0;this.lastSizeDirection=l<this.t.SIZE_IDEAL_MIN?"far":l>this.t.SIZE_IDEAL_MAX?"close":"ideal";let h;l<this.t.SIZE_HARD_MIN||l>this.t.SIZE_HARD_MAX?h=0:l<this.t.SIZE_IDEAL_MIN?h=(l-this.t.SIZE_HARD_MIN)/(this.t.SIZE_IDEAL_MIN-this.t.SIZE_HARD_MIN):l>this.t.SIZE_IDEAL_MAX?h=(this.t.SIZE_HARD_MAX-l)/(this.t.SIZE_HARD_MAX-this.t.SIZE_IDEAL_MAX):h=1;let m=1;if(i!==void 0){let p=Math.abs(Math.atan2(i.right.y-i.left.y,i.right.x-i.left.x))*180/Math.PI;m=1-v(p/this.t.ROLL_MAX_DEG)}return{center:n,iod:o,centering:c,size:h,pose:m}}motionOf(e,t,r){let i=this.lastCenter;if(this.lastCenter={...e,at:r},i===null||t<=0)return 1;let a=(r-i.at)/1e3;if(a<=0)return 1;let s=Math.hypot(e.x-i.x,e.y-i.y)/t/a;s<=this.t.MOTION_DEADBAND_IOD_PER_S&&(s=0);let n=1-Math.exp(-a/this.t.MOTION_TAU_S);return this.velocityEma=n*s+(1-n)*this.velocityEma,1-v(this.velocityEma/this.t.MOTION_VELOCITY_IOD_PER_S)}guidanceOf(e,t,r){if(e.presence<=0)return"fcv3.no_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 i=[["size",this.sizeGuidance()],["centering","fcv3.center_face"],["pose","fcv3.straighten"],["exposure",this.exposureGuidance(t)],["sharpness","fcv3.steady_camera"],["motion","fcv3.hold_still"]],a=i[0];for(let s of i)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=(C[0]+C[1])/2;return e.meanLuma<t?"fcv3.more_light":"fcv3.too_bright"}};var ee=["size","centering","pose","exposure","sharpness","motion"];function te(u){if(u.accepted)return null;if(u.factors.presence<=0)return"no_face";let e="size";for(let t of ee)u.factors[t]<u.factors[e]&&(e=t);return e}var _=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=te(e);if(r===null){this.acceptedMs+=t;return}let i=this.blocked[r]??{count:0,ms:0};i.count+=1,i.ms+=t,this.blocked[r]=i}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 re=1e3,A=4,ie=600,X={sharpness:1,exposure:1,meanLuma:128},Z=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.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()}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.setState("preflight");let r=R();if(r!=="OK"){this.fail(r==="INSECURE_CONTEXT"?"insecure":"unsupported");return}this.setState("acquiring");let i=t.getUserMedia??(o=>navigator.mediaDevices.getUserMedia(o)),a;this.cameraRequestedAt=this.now();try{a=await i(B(W(),this.facing))}catch(o){if(e!==this.attempt)return;this.fail(O(o));return}if(G(a),e!==this.attempt){for(let o of a.getTracks())o.stop();return}if(this.stream=a,t.video.srcObject=a,await t.video.play().catch(()=>{}),e!==this.attempt)return;if(this.cameraReadyAt=this.now(),this.detector===null){let o={...t.v3AssetBaseUrl!==void 0?{v3AssetBaseUrl:t.v3AssetBaseUrl}:{}},d=t.createDetector??(t.createWorker!==void 0&&P()?async()=>{try{return await L.create(t.createWorker(),o)}catch{return M(o)}}:()=>M(o)),c;try{c=await d()}catch(l){e===this.attempt&&this.fail("models",l instanceof x?l.fallbackReason:se(l));return}if(e!==this.attempt){c.destroy();return}this.detector=c,this.options.telemetry?.({type:"detector",tier:c.tier,fallbackReason:c.fallbackReason})}let s=N(),n=t.deviceClass??F(s);this.profiler=new U(n),this.options.telemetry?.({type:"profile",staticClass:n,activeClass:this.profiler.deviceClass,simd:s.simd}),this.gate=new E(t.thresholds??{}),this.blockStats=new _,this.lastGateSnapshotAt=this.now(),t.rankKeyframes?.()&&import("./keyframe-rank-YAJLYJYF.js").then(o=>T=o,()=>{}),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 i=this.scheduler.stats();this.carriedDegrade+=i.degradeCount,i.meanDetectMs>0&&this.carriedMeans.push(i.meanDetectMs),this.scheduler.stop()}let r=new g({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:i}=this,a=this.options.video;if(e!==this.attempt||t===null||r===null||i===null||this.fired||a.videoWidth===0)return;let s=i.deviceClass,n=this.now(),o=this.options.makeSnapshot?.(a,i.profile.inputWidth)??this.defaultSnapshot(a,i.profile.inputWidth),d=null;try{d=await t.detect(o,a.videoWidth,a.videoHeight)}catch{d=null}if(e!==this.attempt||this.fired)return;i.record(this.now()-n),i.deviceClass!==s&&this.startScheduler(e);let c=d===null?X:this.options.measureQuality?.(a,d.box)??this.defaultQuality(a,d.box),l=r.tick({timestampMs:this.now(),observation:d,quality:c,frameWidth:a.videoWidth,frameHeight:a.videoHeight});l.accepted&&this.faceAcquiredAt===null&&(this.faceAcquiredAt=l.at),this.blockStats?.record(l),!l.ready&&l.at-this.lastGateSnapshotAt>=re&&(this.lastGateSnapshotAt=l.at,this.reportGate(!1)),this.emit("checks",{engine:"v3",progress:l.p,q:l.q,factors:l.factors,attempt:e}),l.guidanceKey!==this.lastGuidanceKey&&(this.lastGuidanceKey=l.guidanceKey,this.emit("guidance",{key:l.guidanceKey})),l.ready&&this.stateValue==="positioning"&&(this.fired=!0,this.captureCompleteAt=l.at,this.fire(e))}async fire(e){let{options:t}=this,r=this.scheduler;r?.stop(),this.reportGate(!0);let i=r?.stats()??{degradeCount:0,meanDetectMs:0},a=[...this.carriedMeans,...i.meanDetectMs>0?[i.meanDetectMs]:[]];t.telemetry?.({type:"fired",timeToGateMs:this.now()-this.positioningStartedAt,degradeCount:this.carriedDegrade+i.degradeCount,meanDetectMs:a.length===0?0:a.reduce((p,S)=>p+S,0)/a.length});let s=t.mode??"clip",n=t.rankKeyframes?.()&&T?T.default(this,e).catch(()=>this.collectKeyframes(e)):this.collectKeyframes(e);if(s==="photo"){let p=await n;if(e!==this.attempt)return;if(p===null){this.fail("generic");return}this.finishCapture({keyframe:p.blob,previewDataUrl:p.previewDataUrl});return}this.setState("recording");let o=t.createRecorder?.()??new b,d=this.stream;if(d===null){this.fail("generic");return}let c=null;n.then(p=>{c=p},()=>{});let l=()=>{e===this.attempt&&c!==null&&this.emit("frozen",{previewDataUrl:c.previewDataUrl})},h,m;try{[h,m]=await Promise.all([o.record(d,l),n])}catch(p){if(e!==this.attempt)return;let S=p.kind;this.fail(S==="cliptoolarge"?"cliptoolarge":"recorder");return}if(e===this.attempt){if(y(h.blob)){this.fail("cliptoolarge");return}if(m===null){this.fail("generic");return}this.finishCapture({clip:h.blob,clipMimeType:h.mimeType,keyframe:m.blob,previewDataUrl:m.previewDataUrl})}}async collectKeyframes(e){let t=this.options.captureKeyframe??(a=>this.defaultKeyframe(a)),r=ie/(A-1),i=null;for(let a=0;a<A;a+=1){if(e!==this.attempt)return i;try{let s=await t(this.options.video);(i===null||s.sharpness>i.sharpness)&&(i=s)}catch{}a<A-1&&await ae(r)}return i}finishCapture(e){this.stopTracks(),this.setState("captured");let t=this.captureTiming();this.emit("artifacts",t===void 0?e:{...e,timing:t})}captureTiming(){let e=(s,n)=>s!==null&&n!==null?Math.max(0,Math.round(n-s)):void 0,t=e(this.cameraRequestedAt,this.cameraReadyAt),r=e(this.cameraReadyAt,this.faceAcquiredAt),i=e(this.faceAcquiredAt,this.captureCompleteAt),a={...t!==void 0?{cameraReadyMs:t}:{},...r!==void 0?{faceAcquireMs:r}:{},...i!==void 0?{captureMs:i}:{}};return Object.keys(a).length>0?a:void 0}async defaultKeyframe(e){let t=document.createElement("canvas"),r=await q(e,t),i=t.toDataURL("image/jpeg",.92);return{blob:r,previewDataUrl:i,sharpness:this.centerSharpness(e)}}defaultSnapshot(e,t){try{let r=this.snapshotCanvas??document.createElement("canvas"),i=t/Math.max(1,e.videoWidth),a=Math.max(1,Math.round(e.videoWidth*i)),s=Math.max(1,Math.round(e.videoHeight*i)),n=r.getContext("2d");return n===null?e:(r.width!==a&&(r.width=a),r.height!==s&&(r.height=s),n.drawImage(e,0,0,a,s),this.snapshotCanvas=r,r)}catch{return e}}defaultQuality(e,t){let r=Q(e,t,96);return r===null?X:{sharpness:I(r),exposure:H(r),meanLuma:K(r)}}centerSharpness(e){let t=V(e),r=Q(e,{x:t.width*.25,y:t.height*.25,width:t.width*.5,height:t.height*.5},96);return r===null?0:I(r)}teardownAttempt(){this.scheduler?.stop(),this.scheduler=null,this.reportGate(!0),this.gate=null,this.stopTracks()}reportGate(e){let t=this.blockStats,r=this.profiler;if(t===null||r===null)return;let i=t.summary();e&&(this.blockStats=null),i.ticks!==0&&this.options.telemetry?.({type:"gate",final:e,activeClass:r.deviceClass,cadenceHz:r.profile.cadenceHz,...i})}stopTracks(){if(this.stream!==null){for(let e of this.stream.getTracks())e.stop();this.stream=null}}fail(e,t){this.scheduler?.stop(),this.reportGate(!0),this.stopTracks(),this.setState("error"),this.options.telemetry?.({type:"error",kind:e,fallbackReason:t}),this.emit("error",{kind:e,retryable:e!=="insecure"&&e!=="unsupported"})}setState(e){this.stateValue=e,this.emit("statechange",{state:e})}now(){return this.options.now?.()??performance.now()}},T;function ae(u){return new Promise(e=>setTimeout(e,u))}function se(u){return u instanceof Error?u.message:String(u)}function Q(u,e,t){try{let r=document.createElement("canvas"),i=t/Math.max(1,e.width);r.width=Math.max(1,Math.round(e.width*i)),r.height=Math.max(1,Math.round(e.height*i));let a=r.getContext("2d");return a===null?null:(a.drawImage(u,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}}export{B as a,W as b,ne as c,oe as d,ce as e,Y as f,j as g,J as h,z as i,f as j,b as k,q as l,g as m,$ as n,E as o,te as p,_ as q,re as r,A as s,ie as t,Z as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var c=["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 m(){let e=globalThis.MediaRecorder;return!e||typeof e.isTypeSupported!="function"?"":c.find(o=>e.isTypeSupported(o))??""}var d="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 w(){let e=globalThis;if(typeof e.window<"u"&&e.window.isSecureContext===!1)return"INSECURE_CONTEXT";let o=e.navigator?.mediaDevices;return!o||typeof o.getUserMedia!="function"?"UNSUPPORTED":"OK"}function E(){let e=globalThis.MediaRecorder;return typeof e<"u"&&typeof e.isTypeSupported=="function"}var u=8*1024*1024;function l(e){return e.size>u}function p(e){let o=(e||"").toLowerCase();return o.startsWith("image/jpeg")?"jpg":o.startsWith("video/mp4")?"mp4":(o.startsWith("video/webm"),"webm")}function v(e){let{token:o,clip:n,keyframe:t}=e,i=e.ts??Date.now(),s=n.type||d,a=t.type||"image/jpeg",r=new FormData;return r.append("token",o),r.append("clip",new File([n],`liveness-${i}.${p(s)}`,{type:s})),r.append("keyframe",new File([t],`keyframe-${i}.${p(a)}`,{type:a})),r}export{c as a,m as b,d as c,f as d,w as e,E as f,u as g,l as h,p as i,v as j};
|
|
@@ -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 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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var c="0.1.0-rc.
|
|
1
|
+
var c="0.1.0-rc.8";var d="sekyro.did",l;function g(){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 f(){try{let t=localStorage.getItem(d);if(t)return t;let e=g();return e!==void 0&&localStorage.setItem(d,e),e}catch{return l??(l=g()),l}}async function m(){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]),n=await t.digest("SHA-256",new TextEncoder().encode(r));return Array.from(new Uint8Array(n),i=>i.toString(16).padStart(2,"0")).join("").slice(0,32)}function p(t){let e=new TextEncoder().encode(t),r="";for(let n of e)r+=String.fromCharCode(n);return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function y(t){let e,r;return{timezone(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone?.slice(0,64)||void 0}catch{return}},noteCameraLabel(n){n&&(e=n.slice(0,128))},async deviceHeader(){try{r??(r=m().catch(()=>""));let n=[];navigator.webdriver&&n.push("webdriver"),/HeadlessChrome/.test(navigator.userAgent)&&n.push("headless");let i=await r,s=f(),u={v:1,platform:"web",sdk:t.sdk.slice(0,64),ids:[...s?[{kind:"web_local",value:s.slice(0,128)}]:[],...i?[{kind:"web_fp",value:i}]:[]],screen:{w:screen.width,h:screen.height,dpr:globalThis.devicePixelRatio??1},...e?{cameraLabel:e}:{},...n.length?{signals:n}:{}};return p(JSON.stringify(u))}catch{return}}}}var o=Symbol.for("sekyro.web.clientContext"),a=globalThis,b=a[o]??(a[o]=y({sdk:`@sekyro/web@${c}`}));function C(t){try{let e=t.getVideoTracks?.()[0];e&&b.noteCameraLabel(e.label)}catch{}}export{b as a,C as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as te,d as ne}from"./chunk-CJHMFPL6.js";import{a as re}from"./chunk-RI3E7GBN.js";import{a as I,e as Q,g as $,m as Z}from"./chunk-7ZCZY3ZP.js";import{b as ee}from"./chunk-BPE5NSQ2.js";import{a as X,b as J}from"./chunk-7V2M6Y2W.js";import{d as z}from"./chunk-FHJ7HO3M.js";var le=250,me=180,de=96;function ae(n){let{data:t,width:e,height:r}=n,a=new Uint8Array(e*r);for(let o=0,u=0;o<a.length;o+=1,u+=4)a[o]=Math.round(.299*(t[u]??0)+.587*(t[u+1]??0)+.114*(t[u+2]??0));return{data:a,width:e,height:r}}function H(n,t){return{x0:Math.max(0,Math.floor(n.x)),y0:Math.max(0,Math.floor(n.y)),x1:Math.min(t.width,Math.ceil(n.x+n.width)),y1:Math.min(t.height,Math.ceil(n.y+n.height))}}function T(n,t,e){let r=H(t,n),a=e===void 0?null:H(e,n),o=0,u=0,s=0,m=0;for(let c=r.y0;c<r.y1;c+=1)for(let p=r.x0;p<r.x1;p+=1){if(a!==null&&p>=a.x0&&p<a.x1&&c>=a.y0&&c<a.y1)continue;let v=n.data[c*n.width+p];o+=1,u+=v,s+=v*v,v>=le&&(m+=1)}if(o===0)return{mean:0,sd:0,clipped:0,count:0};let l=u/o;return{mean:l,sd:Math.sqrt(Math.max(0,s/o-l*l)),clipped:m/o,count:o}}function oe(n){let{box:t}=n,r=(n.leftEye.y+n.rightEye.y)/2-.1*t.height,a=t.y+.85*t.height;return{x:t.x+.15*t.width,y:r,width:.7*t.width,height:Math.max(1,a-r)}}function he(n,t){let e=oe(t),r=T(n,e);if(r.count===0)return null;let a=Math.min(Math.max(t.nose.x,e.x+1),e.x+e.width-1),o=T(n,{x:e.x,y:e.y,width:a-e.x,height:e.height}),u=T(n,{x:a,y:e.y,width:e.x+e.width-a,height:e.height}),s=u.mean>0?o.mean/u.mean:o.mean>0?Number.POSITIVE_INFINITY:1;return{faceLuma:r.mean,halfRatio:s,clipped:r.clipped}}function fe(n,t){let e=0,r=0;for(let a of[t.leftEyeBox,t.rightEyeBox]){let o=a.width*.15,u=a.height*.5,s=T(n,{x:a.x-o,y:a.y-u,width:a.width+2*o,height:a.height+2*u});e+=s.count,r+=s.clipped*s.count}return e===0?null:r/e}function ge(n,t){let e=Q(t),{box:r}=t,a={x:r.x-.2*r.width,y:e.y,width:1.4*r.width,height:r.y+r.height-e.y},o=0,u=0,s=0;for(let l of[e.x,e.x+.8*e.width]){let c=T(n,{x:l,y:e.y+.04*e.height,width:.2*e.width,height:.25*e.height},a);o+=c.count,u+=c.mean*c.count,s+=(c.sd*c.sd+c.mean*c.mean)*c.count}if(o===0)return null;let m=u/o;return{luma:m,sd:Math.sqrt(Math.max(0,s/o-m*m)),count:o}}function pe(n,t){let e=H(oe(t),n),r=Math.max(1,Math.floor(Math.max(e.x1-e.x0,e.y1-e.y0)/de)),a=(l,c)=>n.data[c*n.width+l],o=0,u=0,s=0;for(let l=e.y0+r;l<e.y1-r;l+=r)for(let c=e.x0+r;c<e.x1-r;c+=r){let p=a(c,l-r)+a(c-r,l)+a(c+r,l)+a(c,l+r)-4*a(c,l);o+=1,u+=p,s+=p*p}if(o===0)return null;let m=u/o;return Math.min(1,Math.max(0,s/o-m*m)/me)}function ie(n,t){return{lighting:he(n,t),eyeSpecular:fe(n,t),background:ge(n,t),sharpness:pe(n,t)}}var ye="/models-v3",xe=640,be=1600,we=.92;function _(n){return{width:n.videoWidth||0,height:n.videoHeight||0}}function D(n,t){if(typeof document<"u"){let e=document.createElement("canvas");return e.width=n,e.height=t,e}return typeof OffscreenCanvas=="function"?new OffscreenCanvas(n,t):null}function ve(){let n=null;return(t,e)=>{let{width:r,height:a}=_(t);if(r===0||a===0)return null;let o=e===null?1:Math.min(1,e/Math.max(r,a)),u=Math.round(r*o),s=Math.round(a*o),m;e===null?m=D(u,s):((n===null||n.width!==u||n.height!==s)&&(n=D(u,s)),m=n);let l=m?.getContext("2d",{willReadFrequently:!0});if(m==null||l==null)return null;l.drawImage(t,0,0,u,s);let c=null;try{c=l.getImageData(0,0,u,s)}catch{c=null}return{source:m,width:u,height:s,pixels:c}}}async function Ce(n,t,e,r){let a=Math.round(e*t.width/t.height),o=D(a,e),u=o?.getContext("2d");if(o==null||u==null)throw new Error("canvas unavailable");return u.fillStyle="#fff",u.fillRect(0,0,a,e),u.drawImage(n.source,t.x,t.y,t.width,t.height,0,0,a,e),"convertToBlob"in o?o.convertToBlob({type:"image/jpeg",quality:r}):new Promise((s,m)=>{o.toBlob(l=>l===null?m(new Error("encode failed")):s(l),"image/jpeg",r)})}var V=class extends Error{};function ke(n,t,e){return new Promise((r,a)=>{let o=setTimeout(()=>{a(new V(`init exceeded ${t}ms`)),n.then(e,()=>{})},t);n.then(u=>{clearTimeout(o),r(u)},u=>{clearTimeout(o),a(u)})})}function Le(n){let t=z(n),e=t==="overconstrained"?"generic":t;return{kind:e,retryable:e!=="insecure"&&e!=="unsupported"}}function Pe(n,t,e,r){let a=n.length===1?n[0]:void 0,o=a===void 0?null:I(a.landmarks,e,r),u=null;if(a!==void 0&&t.pixels!==null){let s=I(a.landmarks,t.width,t.height),m=ae(t.pixels);s!==null&&(u=ie(m,s))}return{frameWidth:e,frameHeight:r,faces:n.length,geometry:o,matrix:a?.matrix??null,blendshapes:a?.blendshapes??null,stats:u}}function He(n,t={}){let e=ee(n.tuning,n.tuningVersion),r=X(),a=t.now??(()=>performance.now()),o=t.setTimer??((i,d)=>setTimeout(i,d)),u=t.clearTimer??(i=>clearTimeout(i)),s=t.grabFrame??ve(),m=t.encodeRegion??Ce,l=t.getUserMedia??(i=>navigator.mediaDevices.getUserMedia(i)),c=t.createLandmarker??ne,p=n.assetBaseUrl??ye,v=J({enabled:n.keepScreenAwake!==!1}),k=Z(e,{policy:n.policy??"reject"}),x=n.video,q=re({tuning:e.backgroundCheck,assetBaseUrl:p,...t.createSegmenter!==void 0?{createSegmenter:t.createSegmenter}:{},now:a}),h="idle",b=null,y=null,E=null,R=!1,f=!1,g=0,N=0,G=[],L=i=>{h===i||f||(h=i,v.setActive(i==="starting"||i==="gating"),r.emit("state",i))},B=()=>{E!==null&&u(E),E=null},W=()=>{B();for(let i of b?.getTracks()??[])i.stop();b=null;try{x.srcObject=null}catch{}},A=i=>{W(),L("error"),r.emit("error",i)},Y=()=>{let i=Math.max(a(),N+1);return N=i,i},ue=async i=>{let d=s(x,null),{width:w,height:P}=d??_(x);if(d===null||y===null){k.reset();return}let M=y.detect(d.source,Y()),C=(M.length===1?M:G.length===1?G:[])[0],S=C===void 0?null:I(C.landmarks,w,P);if(S===null){k.reset();return}let F=$(S,w,P,{margin:e.cropMargin,minWidth:e.resolution.minWidth,minHeight:e.resolution.minHeight}),O=Math.max(e.resolution.minHeight,Math.min(F.height,be)),se=await m(d,F,O,we);if(f||i!==g)return;let K={image:se,width:Math.round(O*F.width/F.height),height:O,gate:k.summary()};e.tuningVersion!==null&&(K.tuningVersion=e.tuningVersion),B(),L("captured"),r.emit("captured",K)},U=async i=>{if(!(f||i!==g||h!=="gating"||y===null)){if(!R){R=!0;try{let d=s(x,xe);if(d!==null){let{width:w,height:P}=_(x),M=y.detect(d.source,Y());G=M;let C=Pe(M,d,w||d.width,P||d.height);C.geometry!==null&&e.background.required&&(C.backgroundCheck=q.measure(d,C.geometry.box,w||d.width,P||d.height));let S=k.push(C,a());if(f||i!==g||(r.emit("gate",S),S.ready&&(await ue(i),h!=="gating")))return}}catch{}finally{R=!1}}!f&&i===g&&h==="gating"&&(E=o(()=>{U(i)},1e3/e.cadenceHz))}},ce=()=>ke(c(p),2e4,i=>i.close()),j=async()=>{if(f||h==="starting"||h==="gating")return;g+=1;let i=g;if(k.reset(),L("starting"),b===null&&t.getUserMedia===void 0&&(typeof navigator>"u"||typeof navigator.mediaDevices?.getUserMedia!="function")){A({kind:typeof window<"u"&&window.isSecureContext===!1?"insecure":"unsupported",retryable:!1});return}let d=y!==null?Promise.resolve(y):ce();d.catch(()=>{});try{if(b===null){if(b=await l({video:{facingMode:"user",width:{ideal:e.camera.width},height:{ideal:e.camera.height}},audio:!1}),f||i!==g){for(let w of b.getTracks())w.stop();f&&(b=null);return}x.srcObject=b,x.muted=!0,x.playsInline=!0,await x.play().catch(()=>{})}}catch(w){!f&&i===g&&A(Le(w));return}try{y=await d}catch{!f&&i===g&&A({kind:"generic",retryable:!0});return}f||i!==g||(L("gating"),U(i))};return{handle:{get state(){return h},on:(i,d)=>r.on(i,d),start:j,retry:()=>{if(!f){if(b!==null&&y!==null&&h!=="error"){g+=1;let i=g;B(),k.reset(),L("gating"),U(i);return}h="idle",j()}},destroy:()=>{f||(g+=1,W(),v.setActive(!1),f=!0,y?.close(),y=null,q.close(),r.clear())}},setFlowState:i=>{(h==="captured"||h==="uploading"||h==="checking"||h==="done"&&i==="done")&&L(i)}}}function _e(){import("@mediapipe/tasks-vision").catch(()=>{})}export{le as a,me as b,ae as c,T as d,he as e,fe as f,ge as g,pe as h,ie as i,xe as j,be as k,we as l,ve as m,Pe as n,He as o,_e as p};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as x}from"./chunk-TDLIXFDT.js";import{b}from"./chunk-FPXL63KZ.js";var T=480,y=Object.freeze({MIN_AREA_FRAC:.15,EDGE_CLIP_MARGIN_PX:4,STABLE_TICKS:3,IOU_STABLE_MIN:.85,RISE_PER_S:.9,FALL_PER_S:.25,GUIDE_EXPOSURE:.6,GUIDE_SHARPNESS:.35,ID3_BAND_MIN_WIDTH_FRAC:.55,ID3_BAND_ASPECT_MIN:4,ID3_BAND_ASPECT_MAX:40}),p=e=>Math.min(1,Math.max(0,e));function E(e,o,t){let n=[e.topLeft,e.topRight,e.bottomRight,e.bottomLeft],i=0;for(let s=0;s<4;s++){let r=n[s],c=n[(s+1)%4];i+=r.x*c.y-c.x*r.y}let a=o*t;return a>0?Math.abs(i/2)/a:0}function I(e,o){let t=D(e),n=D(o),i=Math.max(t.x1,n.x1),a=Math.max(t.y1,n.y1),s=Math.min(t.x2,n.x2),r=Math.min(t.y2,n.y2),c=Math.max(0,s-i)*Math.max(0,r-a),u=(t.x2-t.x1)*(t.y2-t.y1),_=(n.x2-n.x1)*(n.y2-n.y1),m=u+_-c;return m>0?c/m:0}function R(e){let o=D(e);return{width:o.x2-o.x1,height:o.y2-o.y1}}function D(e){let o=[e.topLeft,e.topRight,e.bottomRight,e.bottomLeft];return{x1:Math.min(...o.map(t=>t.x)),y1:Math.min(...o.map(t=>t.y)),x2:Math.max(...o.map(t=>t.x)),y2:Math.max(...o.map(t=>t.y))}}function M(e){let o=Math.hypot(e.topRight.x-e.topLeft.x,e.topRight.y-e.topLeft.y),t=Math.hypot(e.bottomRight.x-e.bottomLeft.x,e.bottomRight.y-e.bottomLeft.y),n=Math.hypot(e.bottomLeft.x-e.topLeft.x,e.bottomLeft.y-e.topLeft.y),i=Math.hypot(e.bottomRight.x-e.topRight.x,e.bottomRight.y-e.topRight.y),a=(o+t)/2,s=(n+i)/2;return a<=0||s<=0?0:Math.max(a,s)/Math.min(a,s)}var d=class{constructor(o,t={}){this.p=0;this.lastTickAt=null;this.lastQuad=null;this.streak=0;this.format=o,this.t={...y,...t}}reset(){this.p=0,this.lastTickAt=null,this.lastQuad=null,this.streak=0}tick(o){let{quad:t,quality:n,timestampMs:i}=o,a=this.lastTickAt===null?0:Math.max(0,(i-this.lastTickAt)/1e3);this.lastTickAt=i;let s=null;if(t===null)s="dcv1.no_doc";else if(this.format==="ID-3"){let h=R(t),f=h.height>0?h.width/h.height:0;h.width<this.t.ID3_BAND_MIN_WIDTH_FRAC*o.frameWidth?s="dcv1.come_closer":this.edgeClipped(t,o.frameWidth,o.frameHeight)?s="dcv1.fit_document":(f<this.t.ID3_BAND_ASPECT_MIN||f>this.t.ID3_BAND_ASPECT_MAX)&&(s="dcv1.wrong_shape")}else E(t,o.frameWidth,o.frameHeight)<this.t.MIN_AREA_FRAC?s="dcv1.come_closer":this.edgeClipped(t,o.frameWidth,o.frameHeight)?s="dcv1.fit_document":x(this.format,M(t))||(s="dcv1.wrong_shape");let r=s===null,c=p(n.exposure)>=this.t.GUIDE_EXPOSURE,u=p(n.sharpness)>=this.t.GUIDE_SHARPNESS,_=c&&u;if(r&&_&&t!==null){let h=this.lastQuad===null||I(t,this.lastQuad)>=this.t.IOU_STABLE_MIN;this.streak=h?this.streak+1:1}else this.streak=0;this.lastQuad=t;let m=r&&_;this.p=p(this.p+(m?this.t.RISE_PER_S:-this.t.FALL_PER_S)*a);let A=m&&this.streak>=this.t.STABLE_TICKS,l;if(s!==null)l=s;else if(c)u?l="dcv1.hold_still":l="dcv1.steady";else{let h=(b[0]+b[1])/2;l=n.meanLuma<h?"dcv1.more_light":"dcv1.too_bright"}return{at:i,quad:t,plausible:r,p:this.p,guidanceKey:l,ready:A,stableTicks:this.streak}}edgeClipped(o,t,n){let i=this.t.EDGE_CLIP_MARGIN_PX;return[o.topLeft,o.topRight,o.bottomRight,o.bottomLeft].some(s=>s.x<=i||s.y<=i||s.x>=t-i||s.y>=n-i)}};export{T as a,y as b,E as c,I as d,R as e,d as f};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as oe,d as re,e as se,i as ae,j as ce,q as le,s as I,t as F}from"./chunk-YDQBVWXG.js";import{c as te,d as ne,e as ie}from"./chunk-FPXL63KZ.js";import{c as B,f as q,g as ue}from"./chunk-4RS2YIL4.js";var de=["AD","AE","AF","AG","AI","AL","AM","AO","AQ","AR","AS","AT","AU","AW","AX","AZ","BA","BB","BD","BE","BF","BG","BH","BI","BJ","BL","BM","BN","BO","BQ","BR","BS","BT","BV","BW","BY","BZ","CA","CC","CD","CF","CG","CH","CI","CK","CL","CM","CN","CO","CR","CU","CV","CW","CX","CY","CZ","DE","DJ","DK","DM","DO","DZ","EC","EE","EG","EH","ER","ES","ET","FI","FJ","FK","FM","FO","FR","GA","GB","GD","GE","GF","GG","GH","GI","GL","GM","GN","GP","GQ","GR","GS","GT","GU","GW","GY","HK","HM","HN","HR","HT","HU","ID","IE","IL","IM","IN","IO","IQ","IR","IS","IT","JE","JM","JO","JP","KE","KG","KH","KI","KM","KN","KP","KR","KW","KY","KZ","LA","LB","LC","LI","LK","LR","LS","LT","LU","LV","LY","MA","MC","MD","ME","MF","MG","MH","MK","ML","MM","MN","MO","MP","MQ","MR","MS","MT","MU","MV","MW","MX","MY","MZ","NA","NC","NE","NF","NG","NI","NL","NO","NP","NR","NU","NZ","OM","PA","PE","PF","PG","PH","PK","PL","PM","PN","PR","PS","PT","PW","PY","QA","RE","RO","RS","RU","RW","SA","SB","SC","SD","SE","SG","SH","SI","SJ","SK","SL","SM","SN","SO","SR","SS","ST","SV","SX","SY","SZ","TC","TD","TF","TG","TH","TJ","TK","TL","TM","TN","TO","TR","TT","TV","TW","TZ","UA","UG","UM","US","UY","UZ","VA","VC","VE","VG","VI","VN","VU","WF","WS","XK","YE","YT","ZA","ZM","ZW"];var ve=["carte_identite","passport","residence_permit"];function _e(e,n){let i=e.byIssuer?.[n]??e.default;return ve.filter(s=>i==="*"||i.includes(s))}function tt(e,n=de){return[...new Set([...n,...Object.keys(e.byIssuer??{})])].filter(s=>_e(e,s).length>0).sort()}function pe(e){if(e.acceptedDocuments)return e.acceptedDocuments;let n=e.acceptedDocumentTypes?.length?[...e.acceptedDocumentTypes]:["carte_identite","passport"];return{default:[],byIssuer:{MR:n}}}var Ce=640,Pe=new Set(["network_error","timeout","upload_failed","unknown_error","rate_limit_exceeded"]),me=6,fe=1500,he={sharpness:1,exposure:1,meanLuma:128},ye=null;function we(e,n){try{ye??(ye=document.createElement("canvas"));let i=ye,s=96/Math.max(1,n.width);i.width=Math.max(1,Math.round(n.width*s)),i.height=Math.max(1,Math.round(n.height*s));let a=i.getContext("2d");if(a===null)return he;a.drawImage(e,n.x,n.y,n.width,n.height,0,0,i.width,i.height);let c=a.getImageData(0,0,i.width,i.height);return{sharpness:ne(c),exposure:ie(c),meanLuma:te(c)}}catch{return he}}async function xe(e,n){let i=e.source;return"convertToBlob"in i?i.convertToBlob({type:"image/jpeg",quality:n}):new Promise((s,a)=>{i.toBlob(c=>c===null?a(new Error("encode failed")):s(c),"image/jpeg",n)})}function st(e,n={}){let i=n.now??(()=>performance.now()),s=n.setTimer??((t,r)=>setTimeout(t,r)),a=n.clearTimer??(t=>clearTimeout(t)),c=n.encode??xe,y=n.quality??we,S=e.tuningVersion??null,g=new Set,u=!1,p=e.video??null,f=null,b=n.grabFrame??null,O=null,V=1e3/me,v=null,x=null,N=!1,R=!1,D=Number.NEGATIVE_INFINITY,w=null,K=0,H=null,A=null,Y=Promise.all([import("./icao-gate-PWBMKRGC.js"),import("./icao-tuning-4GGVX6B4.js"),import("./create-portrait-capture-B57GE5FU.js"),import("./landmarker-KB7LVXAU.js"),import("./background-monitor-A7FKJOAG.js")]).then(async([t,r,l,m,k])=>{let d=r.resolveIcaoTuning(e.tuning,e.tuningVersion??void 0);d.background.required&&(x=k.createBackgroundMonitor({tuning:d.backgroundCheck,assetBaseUrl:e.assetBaseUrl??"/models-v3",...n.createSegmenter!==void 0?{createSegmenter:n.createSegmenter}:{},now:i})),f=t.createIcaoGate(d,{policy:e.policy??"reject"}),b??(b=l.defaultGrabber()),O=l.observe,V=1e3/Math.min(me,d.cadenceHz);let h=(n.createLandmarker??m.createFaceLandmarker)(e.assetBaseUrl??"/models-v3"),_=await new Promise((C,P)=>{let E=setTimeout(()=>{P(new Error("landmarker init timeout")),h.then(T=>T.close(),()=>{})},m.LANDMARKER_INIT_TIMEOUT_MS);h.then(T=>{clearTimeout(E),C(T)},T=>{clearTimeout(E),P(T)})});u?_.close():v=_}).catch(()=>{N=!0}),U=t=>{for(let r of g)r({holding:R||N,update:t})},j=()=>{if(w=null,!(u||v===null||f===null||b===null||O===null||p===null)){if(i()-D>fe){U(null);return}try{let t=b(p,Ce);if(t!==null){let r=Math.max(i(),K+1);K=r;let l=v.detect(t.source,r),m=p.videoWidth||t.width,k=p.videoHeight||t.height,d=O(l,t,m,k);d.geometry!==null&&x!==null&&(d.backgroundCheck=x.measure(t,d.geometry.box,m,k));let h=f.push(d,i());R=h.ready,U(h)}}catch{}w=s(j,V)}},W=()=>{let t=i()-D>fe;D=i(),t&&(f?.reset(),R=!1,H=null,A=null),w===null&&v!==null&&!u&&(w=s(j,0))},G=()=>{let t=b===null||p===null?null:b(p,null);if(t===null||f===null||Math.max(t.width,t.height)<e.still.minLongSidePx)return Promise.resolve(null);let r=f.summary();return c(t,e.still.jpegQuality).then(l=>({image:l,width:t.width,height:t.height,gate:r}),()=>null)},M=null;return{engineOptions:{measureQuality:(t,r)=>{p=t,W();let l=y(t,r);return R||N?l:{...l,sharpness:0}},telemetry:t=>{if(t.type!=="fired"||u)return;H=G();let r=M;r!==null&&H.then(l=>l===null?void 0:r(l).catch(()=>{})),R=!1,w!==null&&a(w),w=null,D=Number.NEGATIVE_INFINITY}},decorate:t=>{let r=new WeakMap,l=new Map,m=_=>{let C=r.get(_);return C===void 0&&(C=(async()=>{let P=await ce(t,"image","image/jpeg",_.image.size,{engine:"portrait"});return await t.uploadToSpaces(P.uploadUrl,_.image,"image/jpeg"),(await t.completeMedia(P.key)).key})(),C.catch(()=>r.delete(_)),r.set(_,C)),C};M=m;let k=async _=>{let C;try{C=await m(_)}catch(P){let E=P?.code;if(typeof E=="string"&&Pe.has(E))throw P;return null}return{media:{portrait:C},gate:ue(_.gate),...S!==null?{tuningVersion:S}:{}}},d=t.submitCheck.bind(t),h=(async(_,C,P)=>{if(_!=="liveness")return d(_,C,P);let E=P?.idempotencyKey,T=E===void 0?void 0:l.get(E);if(T===void 0){let z=H;T=z===null?Promise.resolve(null):z.then(ee=>ee===null?null:k(ee)),E!==void 0&&(l.set(E,T),T.catch(()=>l.delete(E)))}let $=await T;if($===null)return d("liveness",C,P);let ke=await d("liveness",{...C,portraitIcao:$},P);return A=$,ke});return new Proxy(t,{get(_,C){if(C==="submitCheck")return h;let P=Reflect.get(_,C);return typeof P=="function"?P.bind(_):P}})},onGate:t=>(g.add(t),()=>g.delete(t)),lastPortraitInput:()=>A,destroy:()=>{u=!0,H=null,A=null,w!==null&&a(w),w=null,g.clear(),Y.then(()=>{v?.close(),v=null,x?.close(),x=null})}}}var Ee=["national_number","document_photo","national_eid"],Te=["national_number","document_photo"],Ie=new Set(["eid_not_enrolled","eid_unavailable","eid_locked"]),ge="platform_unsupported",Ae=new Set(["prefilled","user_entered","prefilled_or_entered"]),Me={phone_otp:"contact",email_otp:"contact",eid_auth:"identity",doc_ocr:"identity",nfc_chip:"identity",population_registry:"identity",liveness:"live_photo",portrait_icao:"live_photo",face_match:"live_photo"};function L(e){return e.section??Me[e.checkType]??null}function Re(e){let n={sessionId:e.sessionId,orgName:e.orgName,returning:e.returning===!0,consentRecorded:e.consentRecorded,expiresAt:e.expiresAt,sections:[]};for(let i of e.steps){let s=L(i);s!==null&&!n.sections.includes(s)&&n.sections.push(s)}return e.branding!==void 0&&(n.branding=e.branding),n}function Le(e){let n={attemptsRemaining:e.attemptsRemaining,attemptsExhausted:e.attemptsExhausted===!0};return e.reason!==void 0&&(n.reason=e.reason),n}function Oe(e,n){let i=e.otpChoice;if(i===void 0||i.locked||i.selected===null)return;let s=n==="phone_otp"?"email":"phone";return i.options.includes(s)?s:void 0}function Ve(e,n,i,s){let a=n.checkType==="email_otp",c=(a?n.emailOtp:n.otp)??{},y=a?n.emailOtp?.emailSource:n.otp?.numberSource,S=y!==void 0&&Ae.has(y)?y:a?"prefilled_or_entered":"user_entered",g=typeof c.sentToMasked=="string"&&c.sentToMasked.length>0,u=Oe(e,a?"email_otp":"phone_otp"),p={key:n.checkType,context:i,section:L(n),phase:g?"verify":"send",canSwitch:u!==void 0,...s},f=a?{kind:"email_otp",...p,emailSource:S,needsEmail:S!=="prefilled"}:{kind:"phone_otp",...p,numberSource:S,needsPhone:S!=="prefilled",channels:(n.otp?.channels??[]).filter(b=>b==="whatsapp"||b==="sms")};return u!==void 0&&(f.switchChannel=u),g&&(f.sentToMasked=c.sentToMasked),!a&&n.otp?.channel!==void 0&&(f.channel=n.otp.channel),c.expiresAt!==void 0&&(f.codeExpiresAt=c.expiresAt),c.resendAvailableAt!==void 0&&(f.resendAvailableAt=c.resendAvailableAt),f}function De(e,n,i,s){let a=e.nniBound===!0?"bound":n.nniFromDocument===!0?"document":"typed",c=a==="typed"&&n.state==="input_required"&&n.reason==="nni_recheck",y=n.reason==="nni_not_found"&&n.state==="input_required"&&!s.attemptsExhausted&&e.methodChoice?.available===!0&&e.methodChoice.options.includes("document_photo");return{kind:"registry",key:"registry",context:i,section:L(n),state:n.state==="input_required"?"input_required":"pending",source:a,recheck:c,canUseDocument:y,...s}}function He(e,n,i,s){let a=[...n.acceptedSides??[]];return{kind:"document",key:"document",context:i,section:L(n),side:a.includes("recto")?"verso":"recto",acceptedSides:a,documents:pe(e),...s}}function Ne(e){let n=e.steps.find(i=>i.checkType==="liveness");return n?.state==="passed"||n?.state==="review"}function Se(e,n,i,s,a){let c=n.icao?.report;return{kind:"portrait",key:`portrait:${a}`,context:i,section:L(n),phase:a,report:Array.isArray(c)?c:null,review:n.state==="review",tuning:e.capture?.icao??null,tuningVersion:e.capture?.tuningVersion??null,icao:q(e),retakeOnly:a==="capture"&&n.state==="input_required"&&e.capture?.livePhoto?.oneCapture===!0&&Ne(e),...s}}var Z={minLongSidePx:1280,jpegQuality:.95};function Ge(e,n){let i=e.capture?.livePhoto;if(i?.oneCapture!==!0)return null;let s=e.steps.find(c=>c.checkType==="portrait_icao"),a=i.still??Z;return{icao:n==="liveness"&&q(e)!==null&&s!==void 0&&s.state==="pending"&&s.reason===void 0,still:{minLongSidePx:a.minLongSidePx??Z.minLongSidePx,jpegQuality:a.jpegQuality??Z.jpegQuality}}}function Be(e,n,i,s){let a=n.eid,c=L(n);if(a===void 0||a.challenge!=="app_code")return{kind:"unsupported",key:"unsupported:eid_auth",context:i,section:c,checkType:"eid_auth",reason:"update_required"};let y=e.methodChoice,S=y?.available===!0?y.options.find(p=>Te.includes(p)):void 0,g=S!==void 0&&n.state==="input_required"&&(n.reason!==void 0&&Ie.has(n.reason)||n.attemptsExhausted===!0||n.attemptsRemaining===0||n.reason==="eid_resend_limit"&&a.awaiting!=="code"),u={kind:"eid",key:"eid",context:i,section:c,provider:a.provider,providerName:a.providerName,country:a.country,challenge:"app_code",phase:a.awaiting==="code"?"code":"identifier",identifierBound:a.identifierBound===!0,canUseCamera:g,afterPass:a.afterPass==="continue"?"continue":"end",...s};return g&&(u.cameraMethod=S),a.expiresAt!==void 0&&(u.codeExpiresAt=a.expiresAt),a.resendAvailableAt!==void 0&&(u.resendAvailableAt=a.resendAvailableAt),a.resendsRemaining!==void 0&&(u.resendsRemaining=a.resendsRemaining),a.codeAttemptsRemaining!==void 0&&(u.codeAttemptsRemaining=a.codeAttemptsRemaining),u}function Ue(e,n){if(n.checkType!=="face_match"||n.reason!==void 0)return null;let i=e.steps.find(s=>s.checkType==="portrait_icao");return i!==void 0&&(i.state==="passed"||i.state==="review")?i:null}function Fe(e){return e.steps.some(n=>n.attemptsExhausted===!0)}function Ke(e,n){let i=e.failureReason,s;i===ge?s="platform_unsupported":e.status==="expired"?s="expired":e.status==="review_pending"?s="review":e.status==="completed"&&e.outcome==="approved"?s="approved":e.status==="completed"&&e.outcome==="review"?s="review":i==="device_cooldown"?s="cooldown":i!==void 0?s="policy_stop":Fe(e)?s="attempts_exhausted":s="rejected";let a=s==="platform_unsupported"?{sessionId:e.sessionId,status:"unavailable"}:ae(e,{autoRetry:!1}),c={kind:"result",key:"result",context:n,section:null,display:s,result:a};return i!==void 0&&(c.failureReason=i),e.retryAfter!==void 0&&(c.retryAfter=e.retryAfter),c}function je(e,n){let i=e.identitySummary;if(i==null)return null;let s={kind:"identity_summary",key:"identity_summary",context:n,section:"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 qe){let c=i[a];typeof c=="string"&&c!==""&&(s[a]=c)}return s}var qe=["fullName","birthDate","birthYear","nationality","documentType","documentNumberMasked","nniMasked","expiryDate","retakeTarget"];function Q(e,n={}){let i=Re(e);if(re(e)||e.failureReason===ge)return Ke(e,i);let s=je(e,i);if(s!==null)return s;let a=oe(e);if(a!==null){let u=a.options.filter(f=>Ee.includes(f));if(u.length===0)return{kind:"unsupported",key:"unsupported:method",context:i,section:"identity",checkType:"method",reason:"platform_unsupported"};let p={kind:"method",key:"method",context:i,section:"identity",options:u};return u.includes("national_eid")&&a.nationalEid!==void 0&&(p.nationalEid=a.nationalEid),p}let c=se(e);if(c===void 0){let u=e.steps.find(p=>p.state==="processing");return{kind:"processing",key:"processing",context:i,section:u===void 0?null:L(u),stalled:!1}}let y=Le(c),S=c.checkType,g=L(c);switch(S){case"phone_otp":case"email_otp":{let u=e.otpChoice;return u!==void 0&&u.selected===null&&!u.locked?{kind:"contact_choice",key:"contact_choice",context:i,section:g,options:u.options.filter(p=>p==="phone"||p==="email"),selected:null,locked:!1}:Ve(e,c,i,y)}case"population_registry":return De(e,c,i,y);case"eid_auth":return Be(e,c,i,y);case"doc_ocr":return He(e,c,i,y);case"portrait_icao":return Se(e,c,i,y,"capture");case"liveness":case"face_match":{let u=Ue(e,c);if(u!==null)return Se(e,u,i,y,"match");let p=c.requiresMobile===!0,f=q(e);return p&&n.isMobile===!1?{kind:"mobile_required",key:"mobile_required",context:i,section:g,checkType:S}:{kind:"liveness",key:"biometric",context:i,section:g,mode:S==="face_match"?"selfie":"liveness",requiresMobile:p,instructions:f===null?"standard":"icao",icao:f,livePhoto:Ge(e,S),...y}}default:return{kind:"unsupported",key:`unsupported:${S}`,context:i,section:g,checkType:S,reason:S==="nfc_chip"?"platform_unsupported":"update_required"}}}function J(e){return/^\d{10}$/.test(e)&&Number(e)%97===1}function X(e){let n="";for(let i of e){let s=i.codePointAt(0)??0;s>=1632&&s<=1641?n+=String(s-1632):s>=1776&&s<=1785?n+=String(s-1776):i!==" "&&i!=="-"&&i!=="\xA0"&&(n+=i)}return n}var Qe=[1e3,2e3,4e3,8e3,15e3],Ye=3e4,We=/^\+[1-9]\d{7,14}$/,$e=/^\d{6}$/,Ze=/^\d{6}$/,Je=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,be=new Set(["session_not_active","check_not_found","check_already_finalized","check_out_of_order","method_required","contact_locked","identity_confirm_required","identity_confirm_locked"]),Xe=new Set(["network_error","timeout","upload_failed","unknown_error","rate_limit_exceeded"]);function gt(e){let n=!1,i=null,s="",a=!1,c=!1,y=!1,S={},g={},u=new Set,p=!1,f=null,b="idle",O=new Map,V=new Map,v=(o,t,r)=>{let l=`${o}.${t}`,m=O.get(l);if(m!==void 0)return m;let k=V.get(o),d=(k===void 0?r():k.then(r)).finally(()=>{O.delete(l)});O.set(l,d);let h=d.then(()=>{},()=>{});return V.set(o,h),h.then(()=>{V.get(o)===h&&V.delete(o)}),d},x=async(o,t,r)=>{await e.ensureConsent();try{await le(e.runtime,t)}catch(l){if(l instanceof B&&be.has(l.code)){await e.refreshView();return}throw l}r?.(),e.destroyed()||await e.refreshView()},N=async o=>{await e.ensureConsent();let t;try{try{t=await o(e.runtime.client)}catch(r){if(!(r instanceof B)||r.code!=="consent_required")throw r;await e.runtime.ensureConsent({force:!0}),t=await o(e.runtime.client)}}catch(r){if(r instanceof B&&be.has(r.code)){await e.refreshView();return}throw r}e.destroyed()||(t!==void 0&&e.setView!==void 0?e.setView(t):await e.refreshView())},R=o=>v("contact",`select:${o}`,()=>N(t=>t.selectContact===void 0?Promise.reject(new Error("contact choice is not available in this build")):t.selectContact(o))),D=o=>v("identity",o,()=>N(t=>t.confirmIdentity===void 0?Promise.reject(new Error("identity confirmation is not available in this build")):t.confirmIdentity(o))),w=async o=>{await e.ensureConsent();try{await e.selectMethod(o)}catch(t){if(!(t instanceof B)||t.code!=="consent_required")throw t;await e.runtime.ensureConsent({force:!0}),await e.selectMethod(o)}},K=(o,t)=>{let r=o.kind,l=r==="phone_otp",m=l?"phone":"email",k={action:"send"};if(l?o.needsPhone:o.needsEmail){let d=t[m]??g[r],h=l?d?.replace(/[\s().-]/g,""):d?.trim();if(h===void 0||!(l?We:Je).test(h))return Promise.reject(l?new I("phone","format"):new F("email","format"));k[m]=h}if(l){let d=o.channels,h=t.channel??(d.length===1?d[0]:void 0);if(d.length>0){if(h===void 0)return Promise.reject(new F("channel","required"));if(!d.includes(h))return Promise.reject(new F("channel","unavailable"))}h!==void 0&&(k.channel=h)}return v(r,"send",()=>x(r,(d,h)=>d.submitCheck(r,k,{idempotencyKey:h}),()=>{S[r]=e.now(),k[m]!==void 0&&(g[r]=k[m])}))},H=(o,t)=>$e.test(t)?v(o,"verify",()=>x(o,(r,l)=>r.submitCheck(o,{action:"verify",code:t},{idempotencyKey:l}))):Promise.reject(new I("code","format")),A=(o,t)=>v("eid_auth",o,()=>x("eid_auth",(r,l)=>r.submitCheck("eid_auth",t,{idempotencyKey:l}))),Y=(o,t)=>{if(o.identifierBound)return A("start",{action:"start"});let r=X(t??"");if(o.country==="MR"){if(!/^\d{10}$/.test(r))return Promise.reject(new I("nni","format"));if(!J(r))return Promise.reject(new I("nni","check_digit"))}else if(r==="")return Promise.reject(new I("nni","format"));return A("start",{action:"start",identifier:r})},U=o=>{switch(o.kind){case"phone_otp":case"email_otp":{let t={...o,send:(l={})=>K(o,l),verify:l=>H(o.kind,l),switchTo:()=>o.canSwitch&&o.switchChannel!==void 0?R(o.switchChannel):Promise.reject(new RangeError("this session has no other contact option"))},r=S[o.kind];return t.resendAvailableAt===void 0&&r!==void 0&&(t.resendAvailableAt=new Date(r+Ye).toISOString()),t}case"eid":return{...o,start:t=>Y(o,t),verify:t=>Ze.test(t)?A("verify",{action:"verify",code:t}):Promise.reject(new I("code","format")),resend:()=>o.resendsRemaining===0?Promise.reject(new RangeError("no new code can be sent for this session")):A("resend",{action:"resend"}),useCamera:()=>o.canUseCamera&&o.cameraMethod!==void 0?v("method","useCamera",()=>w(o.cameraMethod)):Promise.reject(new RangeError("the camera path is not offered"))};case"method":return{...o,select:t=>o.options.includes(t)?v("method","select",()=>w(t)):Promise.reject(new RangeError(`method ${String(t)} is not offered`))};case"registry":return{...o,submitNni:t=>{if(o.source!=="typed")return Promise.reject(new RangeError("this session already holds the NNI"));let r=X(t);return/^\d{10}$/.test(r)?J(r)?v("population_registry","submitNni",()=>x("population_registry",(l,m)=>l.submitCheck("population_registry",{nni:r},{idempotencyKey:m}),()=>{f=`\u2022\u2022\u2022\u2022\u2022\u2022${r.slice(-4)}`})):Promise.reject(new I("nni","check_digit")):Promise.reject(new I("nni","format"))},confirm:()=>v("population_registry","confirm",()=>x("population_registry",(t,r)=>t.submitCheck("population_registry",{},{idempotencyKey:r}))),useDocument:()=>o.canUseDocument?v("method","useDocument",()=>w("document_photo")):Promise.reject(new RangeError("the document method is not offered"))};case"document":return e.bindDocument!==void 0?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")}};case"portrait":return e.bindPortrait!==void 0?e.bindPortrait(o,M):{...o,uploadFailed:!1,resubmit:()=>Promise.resolve(),capture:()=>{throw new Error("portrait capture is not available in this build")}};case"contact_choice":return{...o,select:t=>o.options.includes(t)?R(t):Promise.reject(new RangeError(`contact ${String(t)} is not offered`))};case"identity_summary":return{...o,...o.nniMasked===void 0&&o.summaryKind==="partial"&&f!==null?{nniMasked:f}:{},portrait:async()=>{let t=e.runtime.client;if(!o.portraitAvailable||t.identityPortrait===void 0)return null;try{return await t.identityPortrait()}catch{return null}},confirm:()=>D("confirm"),retake:()=>o.retakeAvailable?D("retake"):Promise.reject(new RangeError("no retake is left"))};case"liveness":return{...o,capture:t=>e.liveness(t),onLivePhoto:t=>o.livePhoto?.icao===!0&&e.onLivePhoto!==void 0?e.onLivePhoto(t):()=>{}};case"mobile_required":case"processing":return{...o,refresh:async()=>{a=!1,await e.refreshView()}};case"unsupported":case"result":return{...o};default:{let t=o;throw new Error(`runner: unhandled step ${JSON.stringify(t)}`)}}},j=async()=>{if(!c){c=!0;try{for(let o of Qe){if(await e.sleep(o),!n||e.destroyed())return;let t=await e.refreshView().catch(()=>null);if(t!==null&&Q(t,{isMobile:e.isMobile()}).kind!=="processing")return}a=!0,M()}finally{c=!1}}},W=o=>{if(o.kind!=="liveness"||o.mode!=="selfie")return null;let t={kind:"processing",key:"processing",context:o.context,section:o.section,stalled:!1};if(b==="inflight")return t;if(!p||b==="done")return null;let r=e.keptFaceKey?.()??null;return r===null?null:(b="inflight",x("face_match",(l,m)=>l.submitCheck("face_match",{imageKey:r},{idempotencyKey:m}),()=>{b="done"}).then(()=>{b==="inflight"&&(b="done",M())},()=>{b="done",M()}),t)},G=(o,t=!1)=>{if(!n||e.destroyed()||e.chainBusy())return;let r=Q(o,{isMobile:e.isMobile()});r.kind==="registry"&&r.recheck&&(p=!0,b="idle"),r=W(r)??r,r.kind==="processing"?r.stalled=a:a=!1;let l=U(r),m=JSON.stringify(l);r.kind==="registry"&&r.source==="document"&&r.state==="pending"&&!u.has("registry")&&(u.add("registry"),l.confirm().catch(k=>{(!(k instanceof B)||Xe.has(k.code))&&u.delete("registry")})),!(!t&&m===s)&&(s=m,i=l,e.emitStep(l),r.kind==="processing"&&!a&&b!=="inflight"&&j(),r.kind==="result"&&!y&&(y=!0,e.emitResult(r.result)))};function M(){let o=e.currentView();o!==null&&G(o,!0)}return{run:async()=>{if(e.destroyed())throw new Error("verification destroyed");n=!0;let o=await e.ensureView();return i===null&&G(o),i??U(Q(o,{isMobile:e.isMobile()}))},current:()=>i,onView:o=>G(o),onChainIdle:()=>{let o=e.currentView();o!==null&&G(o)},republish:M,submit:x}}export{_e as a,tt as b,me as c,fe as d,st as e,Q as f,Qe as g,Ye as h,gt as i};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var f="https://challenges.cloudflare.com/turnstile/v0/api.js",g=3e4;function p(){return window.turnstile}var o=null;function w(){o=null}function E(){return o??(o=new Promise((s,t)=>{let r=p();if(r){s(r);return}let e=document.createElement("script");e.src=f,e.async=!0,e.onload=()=>{let n=p();n?s(n):(o=null,t(new Error("Turnstile script loaded but exposed no API")))},e.onerror=()=>{o=null,e.remove(),t(new Error("Turnstile script failed to load"))},document.head.appendChild(e)})),o}function d(){return new Error("Turnstile challenge aborted")}async function x(s,t={}){let r=t.timeoutMs??3e4,e=t.signal;if(e?.aborted)throw d();let n=await E();if(e?.aborted)throw d();let a=document.createElement("div");document.body.appendChild(a);let i,c,u;try{return await new Promise((m,l)=>{if(c=setTimeout(()=>l(new Error(`Turnstile challenge timed out (${r} ms)`)),r),e!==void 0&&(u=()=>l(d()),e.addEventListener("abort",u,{once:!0})),i=n.render(a,{sitekey:s,execution:"execute",appearance:"execute",callback:m,"error-callback":T=>{l(new Error(`Turnstile challenge failed${T?` (${T})`:""}`))}}),i===void 0){l(new Error("Turnstile render returned no widget id"));return}n.execute(i)})}finally{if(clearTimeout(c),e!==void 0&&u!==void 0&&e.removeEventListener("abort",u),i!==void 0)try{n.remove(i)}catch{}a.remove()}}export{f as a,g as b,w as c,E as d,x as e};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var v=1e4,u=class t{constructor(e,i){this.tier="blaze";this.inner=e,i!==void 0&&(this.fallbackReason=i)}static async create(e,i){let o=await import("@mediapipe/tasks-vision"),n=await o.FilesetResolver.forVisionTasks(e),r=await o.FaceDetector.createFromOptions(n,{baseOptions:{modelAssetPath:`${e}/blaze_face_short_range.tflite`,delegate:"CPU"},runningMode:"IMAGE"});return new t(r,i)}async detect(e,i,o){let n;try{n=this.inner.detect(e).detections}catch{return null}let r=O(n);if(r?.boundingBox===void 0)return null;let a=g(e),s=w(r.keypoints,a),c=r.keypoints?.[2],b={box:{x:r.boundingBox.originX,y:r.boundingBox.originY,width:r.boundingBox.width,height:r.boundingBox.height},...s!==void 0?{eyes:s}:{},...c!==void 0?{nose:{x:c.x*a.width,y:c.y*a.height}}:{},score:r.categories[0]?.score??0};return l(b,e,i,o)}destroy(){try{this.inner.close()}catch{}}};function O(t){let e,i=-1;for(let o of t){let n=o.categories[0]?.score??0;n>i&&(e=o,i=n)}return e}function w(t,e){let i=t?.[0],o=t?.[1];if(i===void 0||o===void 0)return;let n=s=>({x:s.x*e.width,y:s.y*e.height}),[r,a]=[n(i),n(o)];return r.x<=a.x?{left:r,right:a}:{left:a,right:r}}function R(){if(typeof OffscreenCanvas=="function")return new OffscreenCanvas(2,2);let t=document.createElement("canvas");return t.width=2,t.height=2,t}async function x(){let t=globalThis.FaceDetector;if(typeof t!="function")return{ok:!1,reason:"unsupported"};try{let e=new t({fastMode:!0,maxDetectedFaces:1});return await e.detect(R()),{ok:!0,instance:e}}catch(e){return{ok:!1,reason:`smoke_failed:${e instanceof Error?e.message:String(e)}`}}}var m=class{constructor(e,i){this.tier="native";this.inner=e,i!==void 0&&(this.fallbackReason=i)}async detect(e,i,o){let n;try{n=await this.inner.detect(e)}catch{return null}let r=n[0];if(r===void 0)return null;let a=T(r.landmarks),s={box:{x:r.boundingBox.x,y:r.boundingBox.y,width:r.boundingBox.width,height:r.boundingBox.height},...a!==void 0?{eyes:a}:{},score:1};return l(s,e,i,o)}destroy(){}};function T(t){if(t===void 0)return;let e=t.filter(n=>n.type==="eye").map(n=>n.locations[0]).filter(n=>n!==void 0),[i,o]=e;if(!(i===void 0||o===void 0))return i.x<=o.x?{left:i,right:o}:{left:o,right:i}}var F="/models-v3",I=["native","blaze"],y=class extends Error{constructor(e){super(`no detector tier available (${e})`),this.name="DetectorLadderError",this.fallbackReason=e}};function g(t){let e=t;if(typeof e.videoWidth=="number"&&e.videoWidth>0)return{width:e.videoWidth,height:e.videoHeight??0};if(typeof e.naturalWidth=="number"&&e.naturalWidth>0)return{width:e.naturalWidth,height:e.naturalHeight??0};let i=typeof e.width=="number"?e.width:0,o=typeof e.height=="number"?e.height:0;return{width:i,height:o}}function l(t,e,i,o){let n=g(e),r=n.width>0?i/n.width:1,a=n.height>0?o/n.height:1,s=c=>({x:c.x*r,y:c.y*a});return{box:{x:t.box.x*r,y:t.box.y*a,width:t.box.width*r,height:t.box.height*a},...t.eyes!==void 0?{eyes:{left:s(t.eyes.left),right:s(t.eyes.right)}}:{},...t.nose!==void 0?{nose:s(t.nose)}:{},score:t.score}}function E(t){return t instanceof Error?t.message:String(t)}async function k(t){let e=t.preferred??I,i=[];for(let o of e){if(o==="native"){let n=await x();if(n.ok)return new m(n.instance,h(i));i.push(`native:${n.reason}`);continue}try{return await S(u.create(t.v3AssetBaseUrl??F,h(i)),t.blazeInitTimeoutMs??v)}catch(n){i.push(n instanceof f?"blaze:blaze_init_timeout":`blaze:${E(n)}`)}}throw new y(h(i)??"no_tier_available")}function h(t){return t.length>0?t.join("; "):void 0}var f=class extends Error{};function S(t,e){return new Promise((i,o)=>{let n=setTimeout(()=>{o(new f(`init exceeded ${e}ms`)),t.then(r=>r.destroy(),()=>{})},e);t.then(r=>{clearTimeout(n),i(r)},r=>{clearTimeout(n),o(r)})})}var d=1;function A(){return typeof OffscreenCanvas=="function"&&typeof createImageBitmap=="function"&&typeof Worker=="function"}function M(t,e={}){let i=e.createDetector??k,o=null;t.onmessage=n=>{let r=n.data;if(r.v!==d){r.bitmap?.close?.();return}if(r.type==="init"){i(r.options).then(a=>{o=a;let s={v:d,type:"ready",tier:a.tier,...a.fallbackReason!==void 0?{fallbackReason:a.fallbackReason}:{}};t.postMessage(s)});return}if(r.type==="detect"){let a=s=>{let c={v:d,type:"result",id:r.id,observation:s};t.postMessage(c),r.bitmap.close?.()};if(o===null){a(null);return}o.detect(r.bitmap,r.streamWidth,r.streamHeight).then(a,()=>a(null))}}}typeof self<"u"&&typeof self.importScripts=="function"&&M(self);var D=class t{constructor(e,i){this.pending=new Map;this.nextId=1;this.worker=e,this.tier=i.tier,i.fallbackReason!==void 0&&(this.fallbackReason=i.fallbackReason),e.addEventListener("message",o=>{let n=o.data;if(n.v!==d||n.type!=="result")return;let r=this.pending.get(n.id);this.pending.delete(n.id),r?.(n.observation)})}static create(e,i,o=1e4){return new Promise((n,r)=>{let a=setTimeout(()=>{e.removeEventListener("message",s),e.terminate(),r(new Error(`worker detector not ready within ${o}ms`))},o),s=b=>{let p=b.data;p.v!==d||p.type!=="ready"||(clearTimeout(a),e.removeEventListener("message",s),n(new t(e,p)))};e.addEventListener("message",s);let c={v:d,type:"init",options:i};e.postMessage(c)})}async detect(e,i,o){let n;try{typeof ImageBitmap<"u"&&e instanceof ImageBitmap?n=e:typeof createImageBitmap=="function"?n=await createImageBitmap(e):n=e}catch{return null}let r=this.nextId;return this.nextId+=1,new Promise(a=>{this.pending.set(r,a);let s={v:d,type:"detect",id:r,bitmap:n,streamWidth:i,streamHeight:o};this.worker.postMessage(s,[n])})}destroy(){for(let e of this.pending.values())e(null);this.pending.clear(),this.worker.terminate()}};export{F as a,I as b,y as c,g as d,l as e,k as f,d as g,A as h,M as i,D as j};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var a=Object.freeze({LOW:Object.freeze({cadenceHz:5,inputWidth:128,animations:"reduced"}),MID:Object.freeze({cadenceHz:8,inputWidth:160,animations:"full"}),HIGH:Object.freeze({cadenceHz:10,inputWidth:192,animations:"full"})}),u=new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11]);function o(){let t=typeof navigator>"u"?void 0:navigator,e=!1;try{e=typeof WebAssembly<"u"&&WebAssembly.validate(u)}catch{e=!1}return{cores:t?.hardwareConcurrency??2,memGB:t?.deviceMemory??null,simd:e}}function l(t){let e=t.memGB??4;return t.cores<4||e<3?"LOW":t.cores>=8&&e>=6?"HIGH":"MID"}var n=["LOW","MID","HIGH"],i=class{constructor(e){this.samples=[];this.adjusted=!1;this.current=e}get deviceClass(){return this.current}get profile(){return a[this.current]}record(e){if(this.adjusted||this.samples.length>=10)return this.current;if(this.samples.push(e),this.samples.length<10)return this.current;this.adjusted=!0;let s=this.samples.reduce((r,c)=>r+c,0)/this.samples.length;if(s>70)this.current="LOW";else if(s<25){let r=n.indexOf(this.current);this.current=n[Math.min(n.length-1,r+1)]??this.current}return this.current}};export{a,o as b,l as c,i as d};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as M}from"./chunk-GI3UFGRQ.js";var A=2;function L(u){let l=u.tuning,s=u.now??(()=>performance.now()),t=null,o=!1,g=!1,d=Number.NEGATIVE_INFINITY,a=null,h=0,i=null,n=null,f=0,p=!1,T=()=>{if(p||!l.enabled)return;p=!0;let r=(u.createSegmenter??(e=>import("./segmenter-USLNBX65.js").then(m=>m.createSelfieSegmenter(e))))(u.assetBaseUrl);n=setTimeout(()=>{t===null&&(o=!0)},l.segmenterTimeoutMs),r.then(e=>{n!==null&&clearTimeout(n),g||o?e.close():t=e},()=>{n!==null&&clearTimeout(n),o=!0})};return{measure(r,e,m,S){if(!l.enabled||r.pixels===null)return null;T();let c=s();if(c-d<1e3/l.hz)return a;d=c;let k=r.width/Math.max(1,m),y=r.height/Math.max(1,S),w={x:e.x*k,y:e.y*y,width:e.width*k,height:e.height*y},B=null;if(t!==null&&!o){let x=Math.max(c,h+1);h=x;let U=s();B=t.segment(r.source,x);let b=s()-U;f+=1,f>A&&(i=i===null?b:i*.7+b*.3),i!==null&&i>l.segmenterBudgetMs&&(o=!0,t.close(),t=null)}return a=M(r.pixels,w,B,l),a},close(){g=!0,n!==null&&clearTimeout(n),t?.close(),t=null}}}export{L as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{d as j,h as be,i as he,j as ye,l as Se}from"./chunk-G6LKLN4U.js";import{f as ge}from"./chunk-TDLIXFDT.js";import{l as fe}from"./chunk-RVHAKRAI.js";import{a as me,b as pe}from"./chunk-7V2M6Y2W.js";var Ge={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 qe(e){let{deviceMemory:t,effectiveType:n,saveData:r,downlinkMbps:i,sourceLongEdge:l}=e,s=r===!0||n==="slow-2g"||n==="2g"||i!=null&&i>0&&i<1,u=t!=null&&t<=2,c=n==="4g"||i!=null&&i>=5,f=t!=null&&t>=6,p;s||u?p="low":c&&f?p="good":p="mid";let b=Ge[p],S=l&&l>0?Math.min(b.maxLongEdge,l):b.maxLongEdge;return{tier:p,...b,maxLongEdge:S}}function Me(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),qe(t)}function He(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 Xe(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 Ve(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 ke(e,t,n,r,i){if(t<=0||n<=0)return null;let{width:l,height:s}=Xe(t,n,r.maxLongEdge),u=document.createElement("canvas");u.width=l,u.height=s;let c=u.getContext("2d");if(!c)return null;c.drawImage(e,0,0,l,s);let f=I=>new Promise((h,w)=>{u.toBlob(d=>d?h(d):w(new Error("canvas toBlob returned null")),"image/jpeg",I)}),p=He(i,r.qMin,r.qMax),{blob:b,quality:S}=await Ve(f,{startQ:p,qMin:r.qMin,budgetBytes:r.payloadTargetBytes}).finally(()=>{u.width=0,u.height=0});if(b.size>5242880)throw new Error("encoded document exceeds the 5242880-byte media cap");return{blob:b,quality:S,width:l,height:s}}async function $(e){let t=Me(Math.max(e.width,e.height)),n=await ke(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 dt(e){let t=await createImageBitmap(e);try{return await $(t)}finally{t.close()}}var pt=250,ft=.6,gt=1800,bt=6e3,ht=2e3,De=.16;function Z(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 we=e=>e==="recto"?"verso":"recto",Ce=e=>e.phase==="framing"||e.phase==="locking"||e.phase==="flipCue"||e.phase==="reaskRecto",ee=e=>(e.captured.recto!==void 0?1:0)+(e.captured.verso!==void 0?1:0)+e.pending.length;function J(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 Ye(e,t,n){if(e.phase==="result")return{...e,lastReportAt:n};let r=!t.present||e.captureArea!==void 0&&t.areaFrac<.6*e.captureArea,{flipped:i,awaySince:l}=e;r&&(l=l??n),l!==void 0&&n-l>=250&&(i=!0),r||(l=void 0);let s=e.flipTimeoutSpent&&!(i&&!e.flipped),u={...e,lastReportAt:n,flipped:i,awaySince:l,flipTimeoutSpent:s,lastArea:t.areaFrac};if(!Ce(e))return u;if(e.needFlip&&!i){if(!t.ready)return{...u,phase:e.restPhase,goodSince:void 0};let c=e.lastShot!==void 0&&e.pending.includes(e.lastShot);if(s||c)return{...u,goodSince:void 0,phase:e.restPhase};let f=e.goodSince??n;return n-f>=1800?{...u,goodSince:f,phase:"capturing",flipTimeoutSpent:!0,timeoutCapture:!0}:{...u,goodSince:f,phase:e.restPhase}}return t.ready?{...u,phase:"capturing",goodSince:e.goodSince??n}:{...u,goodSince:void 0,phase:t.locking?"locking":e.restPhase}}function Qe(e,t){if(!Ce(e)||e.manualShutter)return e;let n=t-e.lastReportAt>=2e3,r=t-e.lastCaptureAt>=6e3;return n||r?{...e,manualShutter:!0}:e}function Ke(e,t,n){let r=e.layout==="singlePage",i=r?{recto:t}:e.captured,l=r?[]:[...e.pending,t],s={...e,captured:i,pending:l,lastShot:t,lastCaptureAt:n,lastReportAt:-1,manualShutter:!1,goodSince:void 0,notice:void 0,awaySince:void 0,flipped:!1,lastShotByTimeout:e.timeoutCapture,timeoutCapture:!1,captureArea:e.lastArea};return r||ee({captured:i,pending:l})>=2?{...s,phase:"reading",restPhase:"framing",current:void 0,needFlip:!1}:{...s,phase:"flipCue",restPhase:"flipCue",current:void 0,needFlip:!0}}function Re(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:we(n),needFlip:!0,flipTimeoutSpent:!0,goodSince:void 0,manualShutter:!0,notice:"same_face",lastCaptureAt:-1,lastReportAt:-1}:e}function je(e,t,n){if(!e.pending.includes(t))return e;if(e.captured[n]!==void 0)return Re(e,t,n);let r=e.pending.filter(c=>c!==t),i={...e,pending:r,captured:{...e.captured,[n]:t}};if(ee(i)!==1||e.layout==="singlePage")return i;let l=we(n),s=l==="recto"&&e.restPhase==="reaskRecto"?"reaskRecto":"flipCue",u=e.phase==="flipCue"||e.phase==="reaskRecto"||e.phase==="framing";return{...i,restPhase:s,current:l,phase:u?s:e.phase}}function $e(e,t){let n=t.id??e.captured[t.side],r={...e.captured};(t.id===void 0||r[t.side]===t.id)&&delete r[t.side];let i=e.pending.filter(f=>f!==n),l=e.layout==="twoSided"&&ee({captured:r,pending:i})>0,s=e.lastShotByTimeout||n===e.lastShot!==e.flipped,u=l&&!s,c=u?t.side==="recto"?"reaskRecto":"flipCue":"framing";return{...e,captured:r,pending:i,readSides:e.readSides.filter(f=>f!==t.side),lastShot:e.lastShot===n?void 0:e.lastShot,notice:t.issue,goodSince:void 0,manualShutter:!1,phase:c,restPhase:c,current:t.side,needFlip:u,flipped:!1,flipTimeoutSpent:!1,awaySince:void 0,lastCaptureAt:-1,lastReportAt:-1}}function xe(e,t){switch(t.type){case"report":return Ye(J(e,t.at),t.report,t.at);case"tick":return Qe(J(e,t.at),t.at);case"captured":return Ke(J(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 je(e,t.id,t.side);case"duplicate":return Re(e,t.id,t.side);case"readOk":{let n=e.readSides.includes(t.side)?e.readSides:[...e.readSides,t.side],r=["recto","verso"].filter(l=>e.captured[l]!==void 0),i=e.phase==="reading"&&e.pending.length===0&&r.every(l=>n.includes(l));return{...e,readSides:n,flipTimeoutSpent:!1,phase:i?"result":e.phase}}case"readFailed":return $e(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{...Z(e.layout,-1),lastCaptureAt:-1,lastReportAt:-1};default:return e}}function Je(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 Ze(e,t=!1){let{detectMrzBand:n}=await import("./mrz-band-VYHOTDHY.js");return Je(n,e,t)}async function te(e,t=480,n,r=n!=null){let i=n??{x:0,y:0,width:e.width,height:e.height},l=Math.max(1,Math.round(i.height/i.width*t)),s=document.createElement("canvas");s.width=t,s.height=l;try{let u=s.getContext("2d");return u===null?"recto":(u.drawImage(e,i.x,i.y,i.width,i.height,0,0,t,l),await Ze(u.getImageData(0,0,t,l),r))}finally{s.width=0,s.height=0}}async function St(e,t=480){try{let n=await createImageBitmap(e),r=Math.max(1,Math.round(n.height/n.width*t)),i=document.createElement("canvas");i.width=t,i.height=r;let l=i.getContext("2d");return l===null?(n.close(),null):(l.drawImage(n,0,0,t,r),n.close(),l.getImageData(0,0,t,r))}catch{return null}}var ne=(e,t,n)=>Math.min(n,Math.max(t,Math.round(e))),V=e=>Math.round(Math.min(1,Math.max(0,e))*1e4)/1e4;async function ve(e,t,n,r){let i=r.decode??(c=>createImageBitmap(c)),l=async()=>e.stillRead(await i(t),r.region??[0,0,1,1],r.detectorLimit),s;try{s=await l()}catch{try{await new Promise(c=>setTimeout(c,r.retryMs??300)),s=await l()}catch{return null}}let u=s.mrzBox;return u===void 0?null:{engine:r.engine,source:"live_mrz",format:n.format,lineCount:ne(n.lineCount,2,3),checkDigitsValid:!0,stillConfirmed:s.valid&&s.digest===n.digest,band:[V(u[0]),V(u[1]),V(Math.min(u[2],1-u[0])),V(Math.min(u[3],1-u[1]))],digest:n.digest,framesToValid:ne(n.framesToValid,1,1e3),msToValid:ne(n.msToValid,0,12e4)}}function kt(e){let t=null;return e?.then(n=>{t=n}),()=>t}var et=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]),tt=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 Le(e,t=globalThis){let n=t.WebAssembly?.validate;if(typeof n!="function")return{ok:!1,reason:"simd"};try{if(!n.call(t.WebAssembly,et)||!n.call(t.WebAssembly,tt))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 _e(e=globalThis){let t=e.navigator?.connection;return t?.saveData===!0||["slow-2g","2g","3g"].includes(t?.effectiveType??"")}var T=class extends Error{constructor(t){super(t),this.name="OcrEngineError",this.code=t}};function Te(){let e=t=>(t.close(),Promise.reject(new T("unsupported")));return{ready:Promise.resolve("unsupported"),busy:!1,bandRead:e,stillRead:e,layoutRead:e,dispose:()=>{}}}function Ee(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 Te()}catch{return Te()}let n=new Map,r=0,i=!1,l=!1,s=!1;t.addEventListener("message",d=>{let g=d.data,C=n.get(g.id);C&&(n.delete(g.id),C.resolve(g))});let u=()=>{for(let d of n.values())d.reject(new T("error"));n.clear(),f()};t.addEventListener("error",u),t.addEventListener("messageerror",u);function c(d,g=[]){if(i)return Promise.reject(new T("disposed"));let C=++r;return new Promise((B,O)=>{n.set(C,{resolve:B,reject:O});try{t.postMessage({...d,id:C},g)}catch{n.delete(C),O(new T("error"))}})}function f(){if(!i){i=!0;try{t.postMessage({id:++r,kind:"dispose"})}catch{}t.terminate();for(let d of n.values())d.reject(new T("disposed"));n.clear()}}let p=(async()=>{let d=await c({kind:"init",baseUrl:e.baseUrl,salt:e.salt,detectorLimit:e.tuning.detectorLimit,maxDownloadMs:e.tuning.maxDownloadMs});if(d.kind==="failed")return d.reason;if(d.kind!=="ready")return"error";let g=await c({kind:"warmup"});return g.kind!=="ready"?"error":{warmupMs:g.warmupMs,downloadMs:d.downloadMs,cached:d.cached}})().catch(()=>"error"),b,S=new Promise(d=>{b=setTimeout(()=>d("timeout"),e.tuning.loadTimeoutMs)}),I=Promise.race([p,S]).then(d=>(clearTimeout(b),typeof d=="string"?f():s=!0,i&&typeof d!="string"?"error":d));(e.page===void 0?globalThis.addEventListener?globalThis:null:e.page)?.addEventListener("pagehide",f,{once:!0});async function w(d,g,C){if(i)throw g.close(),new T("disposed");if(!s)throw g.close(),new T("not_ready");if(l)throw g.close(),new T("busy");l=!0;let B;try{let O=new Promise((M,A)=>{B=setTimeout(()=>{A(new T("timeout")),f()},e.tuning.readTimeoutMs??1e4)}),P=await Promise.race([c(d,[g]),O]);if(P.kind===C){let{id:M,...A}=P;return A}throw new T(P.kind==="error"?P.code:P.kind==="failed"?P.reason:"error")}finally{clearTimeout(B),l=!1}}return{ready:I,get busy(){return l},bandRead:(d,g=e.tuning.detectorLimit)=>w({kind:"band",bitmap:d,detectorLimit:g},d,"band"),stillRead:(d,g,C=e.tuning.detectorLimit)=>w({kind:"still",bitmap:d,region:g,detectorLimit:C},d,"band"),layoutRead:(d,g)=>w({kind:"layout",bitmap:d,detectorLimit:g},d,"layout"),dispose:f}}var U="sekyro-ocr-1",re=e=>e!==null&&typeof e=="object"?e:{},v=(e,t,n,r)=>typeof e=="number"&&Number.isFinite(e)&&e>=t&&e<=n?e:r,Oe=(e,t)=>typeof e=="boolean"?e:t,Pe=e=>{let t=typeof e=="string"?/^sekyro-ocr-(\d{1,4})$/.exec(e):null;return t?Number(t[1]):Number.POSITIVE_INFINITY};function Ae(e,t={}){let n=re(e),r=re(n.liveMrz),i=re(n.frontLock),l=Pe(t.engine??U),s=t.mode==="off",u=d=>d.enabled===!0?d.arm==="live"?"live":"control":null,c=u(r),f=u(i),p=(d,g)=>!s&&g==="live"&&Pe(d.minEngine??U)<=l,b=ye,S=p(r,c)?{detectorLimit:v(r.detectorLimit,320,1600,b.detectorLimit),bandMaxWidthPx:v(r.bandMaxWidthPx,320,4096,b.bandMaxWidthPx),minBandWidthPx:v(r.minBandWidthPx,0,4096,b.minBandWidthPx),bandTop:v(r.bandTop,0,.95,b.bandTop),minIntervalMs:v(r.minIntervalMs,0,5e3,b.minIntervalMs),stableReads:Math.round(v(r.stableReads,1,10,b.stableReads)),profileReads:Math.round(v(r.profileReads,1,100,b.profileReads)),maxReadMs:v(r.maxReadMs,50,6e4,b.maxReadMs),searchTimeoutMs:v(r.searchTimeoutMs,1e3,12e4,b.searchTimeoutMs),hint:Oe(r.hint,!0),stillConfirm:Oe(r.stillConfirm,!0)}:null,I=he,h=(d,g,C)=>v(i[d],g,C,I[d]),w=p(i,f)?{minLines:Math.round(h("minLines",1,50)),fillMin:h("fillMin",0,1),fillMax:h("fillMax",0,2),offsetMax:h("offsetMax",0,1),steadyFillDelta:h("steadyFillDelta",0,1),steadyOffsetDelta:h("steadyOffsetDelta",0,1),layoutShiftMax:h("layoutShiftMax",0,1),lineCountDelta:Math.round(h("lineCountDelta",0,50)),lockMs:h("lockMs",0,3e4),steadyMs:h("steadyMs",0,3e4),minFrames:Math.round(h("minFrames",1,100)),minIntervalMs:h("minIntervalMs",0,5e3),maxWidthPx:h("maxWidthPx",160,2048),detectorLimit:h("detectorLimit",320,1600),searchTimeoutMs:h("searchTimeoutMs",1e3,12e4)}:null;return{enabled:S!==null||w!==null,liveMrz:S,textLock:w,liveMrzArm:c,frontLockArm:f,load:{detectorLimit:S?.detectorLimit??w?.detectorLimit??b.detectorLimit,loadTimeoutMs:v(r.loadTimeoutMs,1e3,12e4,2e4),maxDownloadMs:v(r.maxDownloadMs,1e3,12e4,2e4),minDeviceMemoryGb:v(r.minDeviceMemoryGb,0,64,2)},reportSampleRate:v(r.reportSampleRate,0,1,1)}}function Be(e,t){return e.enabled?!(t.probe??Le)({minDeviceMemoryGb:e.load.minDeviceMemoryGb}).ok||(t.slow??_e)()?{ok:!1,reason:"unsupported"}:{ok:!0,engine:Ee({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 nt(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 W=e=>e===void 0||!Number.isFinite(e)?void 0:Math.min(6e5,Math.max(0,Math.round(e))),oe=(e,t,n)=>e===void 0||!Number.isFinite(e)?void 0:Math.min(n,Math.max(t,Math.round(e)));function Ie(e){let t=e.assist??null,n=e.load!==null&&e.load!==void 0&&typeof e.load=="object"?e.load:null,r=typeof e.load=="string"?e.load:null,i=t!==null?t.outcome:r==="unsupported"||r==="download"||r==="integrity"?r:r==="error"||r==="timeout"?"error":"off",l={kind:"live_mrz",platform:"web",engine:e.engine??U,arm:e.arm,capture:e.capture,outcome:i,reads:oe(t?.reads??0,0,1e4)??0,browser:e.browser??nt()},s=(u,c)=>{c!==void 0&&(l[u]=c)};return s("format",t?.format),s("framesToValid",oe(t?.framesToValid,1,1e4)),s("msToValid",W(t?.msToValid)),s("framesToLock",oe(t?.framesToLock,1,1e4)),s("msToLock",W(t?.msToLock)),s("msToCapture",W(e.msToCapture)),s("readP50Ms",W(t?.readP50Ms)),s("readP90Ms",W(t?.readP90Ms)),s("deviceClass",t?.deviceClass),n!==null&&(s("warmupMs",W(n.warmupMs)),s("downloadMs",W(n.downloadMs)),s("cached",n.cached)),s("stillConfirmed",e.stillConfirmed),s("typeMismatch",e.typeMismatch),l}function ae(e,t){return e===void 0?!1:t==="passport"?e!=="TD3":e==="TD3"}var rt=2;async function ot(e){let t=await import("./capture-session-doc-YBE3UMJJ.js");return new t.CaptureSessionDoc(e)}function at(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 it(e,t,n){let r=[e.topLeft,e.topRight,e.bottomRight,e.bottomLeft],i=0;for(let l=0;l<r.length;l+=1){let s=r[l],u=r[(l+1)%r.length];i+=s.x*u.y-u.x*s.y}return t>0&&n>0?Math.abs(i)/2/(t*n):0}function Nt(){import("./capture-session-doc-YBE3UMJJ.js").then(e=>e.warmDocDetector()).catch(()=>{})}function Ut(e){return st(e,{}).handle}function st(e,t){let n=me(),r=pe({enabled:e.keepScreenAwake!==!1}),i=t.decode??(o=>createImageBitmap(o)),l=t.blurRefuseSharpnessMax??.16,s=t.now??(()=>performance.now()),u=e.documentType==="passport"||e.side==="single",c=Z(u?"singlePage":"twoSided",s());if(!u&&(e.side==="recto"||e.side==="verso")){let o=e.side==="recto"?"verso":"recto";c={...c,captured:{[o]:"server"},readSides:[o],current:e.side,phase:"flipCue",restPhase:"flipCue"}}let f="idle",p=null,b=null,S=!0,I=0,h=0,w=!1,d=!1,g="",C=null,B,O=null,P=[],M=t.webOcr!==void 0?Ae(t.webOcr.captureDocument,{mode:e.liveMrz?.mode??"auto"}):null,A=null,F=M===null||!M.enabled?"off":null,G=null,q=null,ie=new WeakMap,Y="";if(M!==null&&M.enabled&&t.webOcr!==void 0){let o=t.webOcr,a=Be(M,{baseUrl:e.liveMrz?.assetBaseUrl??o.baseUrl,salt:o.salt,...e.liveMrz?.workerUrl!==void 0?{workerUrl:e.liveMrz.workerUrl}:{},...o.createWorker!==void 0?{createWorker:o.createWorker}:{}});if(a.ok){A=a.engine;let m=new Se({textLock:M.textLock,liveMrz:M.liveMrz});G=m;let y=a.engine;y.ready.then(L=>{F=L,typeof L!="string"&&S&&m.setEngine(y)})}else F=a.reason}let z=o=>{let a=JSON.stringify(o);a!==Y&&(Y=a,n.emit("mrz",o))},se=(o,a)=>{let m=t.webOcr?.reports;if(m===void 0||M===null||o===void 0)return;let y=o.format==="ID-3"||o.side==="single"?"single":o.side==="verso"?"verso":"recto",L=y!=="recto"?M.liveMrzArm??M.frontLockArm:M.frontLockArm;if(L===null||Math.random()>=M.reportSampleRate)return;let _=o.via==="live_mrz"?q:null,x=()=>{let E=_?.value??null;m([Ie({arm:L,capture:y,assist:o.ocr??null,load:L==="control"?"off":F,...o.msToCapture!==void 0?{msToCapture:o.msToCapture}:{},...E!==null&&E.stillConfirmed!==void 0?{stillConfirmed:E.stillConfirmed}:{},...a!==void 0?{typeMismatch:ae(a.format,e.documentType==="passport"?"passport":"card")}:{}})])};_!==null&&_.value===null?Promise.race([_.promise,new Promise(E=>setTimeout(E,3e3))]).then(x):x()},N=o=>{!S||o===f||(f=o,r.setActive(o==="starting"||o==="scanning"),n.emit("state",o))},We=(o,a)=>a===void 0?null:u?"single":o.captured.recto===a?"recto":o.captured.verso===a?"verso":null,Fe=o=>({phase:o.phase,captured:u?o.captured.recto!==void 0?["single"]:[]:["recto","verso"].filter(a=>o.captured[a]!==void 0),expected:u?null:o.current??null,notice:o.notice??null,lastShot:We(o,o.lastShot),manualShutter:o.manualShutter,torchAvailable:p?.torchAvailable()??!1,torch:d}),ue=()=>{let o=p;o!==null&&o.captureNow().catch(()=>R({type:"captureFailed",at:s()}))};function R(o){if(!S)return;let a=c;c=xe(c,o),c.phase==="capturing"&&a.phase!=="capturing"&&Promise.resolve().then(ue),c.phase==="result"&&a.phase!=="result"&&(N("done"),le());let m=Fe(c),y=JSON.stringify(m);y!==g&&(g=y,n.emit("scan",m))}function le(){O!==null&&clearInterval(O),O=null;for(let o of P.splice(0))o();p?.destroy(),p=null,r.setActive(!1)}let ce=()=>p?.captureReport?.(),Q=!1,de=(o,a)=>{if(!(o===void 0||t.onFaceReport===void 0))try{t.onFaceReport(o,a)}catch{}},H=o=>{Y="",!(p===null||c.phase==="reading"||c.phase==="result")&&(Q=!1,p.rearm(u?"single":c.current??o))},ze=async(o,a,m,y)=>{if(q=null,y!==void 0&&A!==null&&M?.liveMrz?.hint===!0){let D={promise:ve(A,o,y,{engine:U,detectorLimit:M.liveMrz.detectorLimit}).catch(()=>null),value:null};D.promise.then(k=>{D.value=k}),q=D}y!==void 0&&ae(y.format,e.documentType==="passport"?"passport":"card")&&z({state:"mismatch",format:y.format});let L=ce();de(L,"captured"),Q=!0,se(L,y);let _=m===void 0?C:m===null?null:{quad:at(m),frameWidth:0,frameHeight:0,inStill:!0},x={decoded:null},E=()=>(x.decoded??(x.decoded=Promise.resolve().then(()=>i(o)).catch(()=>null)),x.decoded);try{await Ne(o,a,_,E,q)}finally{x.decoded!==null&&(await x.decoded)?.close()}},Ne=async(o,a,m,y,L)=>{let _=`shot-${I+=1}`;if(R({type:"captured",id:_,at:s()}),e.haptics!==!1)try{globalThis.navigator?.vibrate?.(30)}catch{}if(!w&&l>0){let D=await(t.measureSharpness!==void 0?t.measureSharpness(o,m):y().then(k=>k===null?-1:be(k,j(m?.quad??null,m?.inStill===!0?k:{width:m?.frameWidth??0,height:m?.frameHeight??0},k)))).catch(()=>-1);if(!S)return;if(Number.isFinite(D)&&D>=0&&D<l){w=!0;let k=u?"recto":c.current??(c.captured.recto===void 0?"recto":"verso");R({type:"readFailed",side:k,id:_,issue:"blurry"}),H(k);return}}w=!1;let x;if(u)x="single";else{let D=c.current,k=await(t.classify!==void 0?t.classify(o):y().then(X=>X===null?D??"recto":m?.inStill===!0?te(X,480,null,!0):te(X,480,j(m?.quad??null,{width:m?.frameWidth??0,height:m?.frameHeight??0},X)))).catch(()=>D??"recto");if(!S)return;if(c.captured[k]!==void 0&&h<rt){h+=1,R({type:"duplicate",id:_,side:k}),H(k==="recto"?"verso":"recto");return}x=c.captured[k]!==void 0&&D!==void 0?D:k,h=0,R({type:"classified",id:_,side:x})}let E=x==="verso"?"verso":"recto";try{let D=t.encode!==void 0?await t.encode(o):await y().then(k=>{if(k===null)throw new Error("the still could not be decoded");return $(k)});if(!S)return;L!==null&&ie.set(D.blob,L),n.emit("captured",{image:D.blob,side:x,documentType:e.documentType,...e.issuer!==void 0?{issuer:e.issuer}:{},width:D.width,height:D.height,previewDataUrl:a}),t.deferRead!==!0&&R({type:"readOk",side:E})}catch{R({type:"readFailed",side:E,id:_,issue:"technical"}),n.emit("error",{kind:"generic",retryable:!0})}H(E==="recto"?"verso":"recto")},Ue=o=>{P.push(o.on("statechange",({state:a})=>{a==="preflight"||a==="acquiring"?N("starting"):a==="positioning"?N("scanning"):a==="captured"?N("captured"):a==="error"&&N("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"?z({state:"fallback",reason:m.reason}):m.state==="valid"?z({state:"valid",format:m.format}):m.state==="reading"?z({state:"reading",...m.format?{format:m.format}:{},...m.coach?{coach:m.coach}:{}}):z({state:"searching"}));let y=a.quad===null?0:it(a.quad,a.frameWidth,a.frameHeight);C=a.quad===null?null:{quad:a.quad,frameWidth:a.frameWidth,frameHeight:a.frameHeight},R({type:"report",report:{present:a.quad!==null&&a.plausible||a.guide?.detected===!0,ready:a.ready===!0,locking:a.p>=.5,areaFrac:y},at:s()})}),o.on("error",({kind:a,retryable:m})=>n.emit("error",{kind:fe(a),retryable:m})),o.on("artifacts",a=>{ze(a.keyframe,a.previewDataUrl,a.docRegion,a.liveMrz)}))},K=()=>(b??(b=(async()=>{if(S){if(p===null){let o=await(t.createEngine??ot)({...t.engineOptions??{},...B!==void 0?{guide:B}:{},video:e.video,format:ge(e.documentType),side:u?"single":e.side??"recto",autoCapture:!1,...G!==null?{ocr:G}:{}});if(!S){o.destroy();return}p=o,Ue(o);let a=t.tickMs??500;a>0&&(O=setInterval(()=>R({type:"tick",at:s()}),a))}R({type:"clockRestart"}),M!==null&&M.liveMrzArm==="live"&&(F==="unsupported"||F==="off")&&z({state:"fallback",reason:F}),await p.start()}})().finally(()=>{b=null})),b);return{handle:{get state(){return f},on:(o,a)=>n.on(o,a),start:K,retry:()=>{if(p===null&&c.phase==="result"){R({type:"retake"}),h=0,w=!1,K();return}if(p!==null&&f!=="error"){R({type:"retake"}),h=0,w=!1,p.rearm(u?"single":void 0);return}K()},setSide:o=>{u||o==="single"||(c.current!==o&&(c={...c,current:o}),R({type:"clockRestart"}),c.phase!=="reading"&&c.phase!=="result"&&p?.rearm(o))},shutter:ue,focusAt:(o,a)=>{p?.focusAt?.(o,a)},setGuide:o=>{B=o,p?.setGuide?.(o)},setTorch:o=>{d=o,p?.setTorch(o),R({type:"tick",at:s()})},destroy:()=>{if(S&&p!==null&&f!=="done"){let o=ce();!Q&&o!==void 0&&o.ticks>0&&de(o,"abandoned"),se(o,void 0)}S=!1,le(),G?.setEngine(null),A?.dispose(),A=null,n.clear()}},setFlowState:o=>{(c.phase==="reading"||c.phase==="result")&&N(o==="done"&&c.phase!=="result"?"scanning":o)},settle:(o,a)=>{let m=o==="verso"?"verso":"recto";R(a.ok?{type:"readOk",side:m}:{type:"readFailed",side:m,issue:a.issue}),a.ok||H(m)},takeDeviceRead:o=>ie.get(o.image)?.value??null}}export{dt as a,pt as b,ft as c,gt as d,bt as e,ht as f,De as g,Z as h,xe as i,Je as j,Ze as k,St as l,ve as m,kt as n,U as o,Ae as p,Be as q,nt as r,Ie as s,ae as t,rt as u,Nt as v,Ut as w,st as x};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as R,b as K}from"./chunk-7V2M6Y2W.js";import{b as I,u as B}from"./chunk-DQWW4OCK.js";import{f as H}from"./chunk-FHJ7HO3M.js";import{a as U,f as p}from"./chunk-OKWG3PVH.js";var G=12e4,V=13e4,q=3e3,N=1200,y=Symbol.for("@sekyro/web.preload.v1");function u(){let e=globalThis;return e[y]??(e[y]=new Map),e[y]}function f(e){let t=(e??U).replace(/\/+$/,"");return t===""?"/":t}function F(e){let t=u(),s=t.get(e);return s===void 0&&(s={status:"idle",promise:null,scheduled:null,detectorPromise:null,detector:null,listeners:new Set},t.set(e,s)),s}function C(e,t){if(e.status!==t){e.status=t;for(let s of[...e.listeners])s(t)}}var D=e=>p({preferred:["blaze"],v3AssetBaseUrl:e,blazeInitTimeoutMs:G}),k=D;function ne(e){k=e??D}function oe(){for(let e of u().values())e.detector?.destroy();u().clear(),k=D}function $(){return typeof window<"u"&&typeof navigator<"u"&&typeof navigator.mediaDevices?.getUserMedia=="function"}function Q(){return navigator.connection?.saveData===!0}function Z(e){let t=window;if(typeof t.requestIdleCallback=="function"){let n=t.requestIdleCallback(e,{timeout:q});return()=>t.cancelIdleCallback?.(n)}let s=setTimeout(e,N);return()=>clearTimeout(s)}function j(e,t){let s,n=new Promise(i=>{s=i}),o=!1,c=()=>{},l={promise:n,settle:i=>{o||(o=!0,c(),e.scheduled===l&&(e.scheduled=null),s(i))}};return e.scheduled=l,c=Z(()=>{o||l.settle(_(e,t))}),n}function _(e,t){if((e.status==="loading"||e.status==="ready")&&e.promise!==null)return e.promise;C(e,"loading");let s=new Promise(i=>i(k(t)));e.detectorPromise=s;let n,o=new Promise((i,m)=>{n=setTimeout(()=>{s.then(a=>a.destroy(),()=>{}),m(new Error(`detector preload exceeded ${V} ms`))},V)}),l=Promise.race([s,o]).then(i=>e.detectorPromise!==s?(i.destroy(),e.status):(e.detector=i,C(e,"ready"),"ready"),i=>(e.detectorPromise===s&&(e.detectorPromise=null,e.detector=null,C(e,"failed"),console.warn("[@sekyro/web] face-detector preload failed:",i)),e.status)).finally(()=>clearTimeout(n));return e.promise=l,e.scheduled?.settle(l),l}function ie(e={}){if(!$())return Promise.resolve("idle");let t=f(e.assetBaseUrl),s=F(t);return e.respectSaveData===!0&&Q()?Promise.resolve(s.status):(s.status==="loading"||s.status==="ready")&&s.promise!==null?s.promise:e.idle===!0?s.scheduled?.promise??j(s,t):_(s,t)}function ae(e){return u().get(f(e))?.status??"idle"}function le(e,t){let s=F(f(t));return s.listeners.add(e),()=>{s.listeners.delete(e)}}function de(e){let t=u().get(f(e));t!==void 0&&(t.scheduled?.settle("idle"),t.detector?.destroy(),t.detector=null,t.detectorPromise=null,t.promise=null,C(t,"idle"))}function J(e){return{get tier(){return e.tier},get fallbackReason(){return e.fallbackReason},detect:(...t)=>e.detect(...t),destroy:()=>{}}}function W(e){let t=f(e),s=u().get(t);if(!(s===void 0||s.detector===null&&s.detectorPromise===null&&s.scheduled===null))return async()=>{s.scheduled!==null&&_(s,t);let n=s.promise;for(;s.detector===null&&n!==null&&(await n,s.promise!==n);)n=s.promise;return s.detector!==null?J(s.detector):p({v3AssetBaseUrl:t})}}function X(e){switch(e){case"fcv3.no_face":case"fcv3.center_face":case"fcv3.straighten":return"center";case"fcv3.come_closer":return"closer";case"fcv3.move_back":return"farther";case"fcv3.more_light":case"fcv3.too_bright":return"light";case"fcv3.hold_still":case"fcv3.steady_camera":return"still";default:return null}}function Y(e){switch(e){case"preflight":case"acquiring":return"starting";case"positioning":return"gating";default:return e}}function ee(e){switch(e){case"permission":case"notfound":case"inuse":case"insecure":case"unsupported":return e;default:{let t=e;return"generic"}}}function te(e,t={},s){let n=t.now??(()=>performance.now()),o=R(),c=!H(),l=t.engineOptions,i=l?.createDetector===void 0&&l?.createWorker===void 0?{createDetector:()=>{let r=W(e.assetBaseUrl);return r!==void 0?r():p({v3AssetBaseUrl:e.assetBaseUrl})}}:{},m={video:e.video,mode:c?"photo":"clip",rankKeyframes:s,facingMode:e.facing,v3AssetBaseUrl:e.assetBaseUrl,...t.engineOptions??{},...i},a=t.createEngine?.(m)??new B(m),v="idle",g=null,S=0,E=!1,b="full",L=null,h=null,A=0,P=0,O=()=>{e.video.videoWidth>0&&e.video.videoHeight>0&&(A=e.video.videoWidth,P=e.video.videoHeight)},M=K({enabled:e.keepScreenAwake!==!1}),T=r=>{v=r,M.setActive(r==="starting"||r==="gating"||r==="recording"),o.emit("state",r)},w=()=>o.emit("gate",{progress:S,hint:g,faceDetected:E}),x=()=>{let r=a.animations??"full";r!==b&&(b=r,o.emit("profile",{animations:b}))},z=[a.on("statechange",({state:r})=>{let d=Y(r);d==="starting"&&v!=="starting"&&(g=null,S=0,E=!1,L=null,h=null,A=0,P=0),T(d),x(),d==="recording"&&(O(),L=n(),g="hold",S=1,w())}),a.on("checks",r=>{O(),S=r.progress,E=r.factors.presence>0,w(),x()}),a.on("guidance",({key:r})=>{g=X(r),w()}),a.on("frozen",({previewDataUrl:r})=>{h=n(),o.emit("frozen",{previewDataUrl:r})}),a.on("artifacts",r=>{let d=L!==null&&h!==null?Math.max(0,Math.round(h-L)):void 0;o.emit("captured",{keyframe:r.keyframe,...r.clip!==void 0?{clip:r.clip}:{},...r.clipMimeType!==void 0?{clipMime:r.clipMimeType}:{},width:e.video.videoWidth||A,height:e.video.videoHeight||P,...d!==void 0?{clipMs:d}:{},captureChannel:I()?"mobile":"desktop",...c?{degraded:"NO_RECORDER"}:{},engine:"v3",...r.timing})}),a.on("error",({kind:r,retryable:d})=>{o.emit("error",{kind:ee(r),retryable:d})})];return{handle:{get state(){return v},on:(r,d)=>o.on(r,d),start:r=>a.start({facingMode:r?.facing}),retry:()=>a.retry(),switchCamera:()=>a.switchCamera(),destroy:()=>{for(let r of z)r();M.setActive(!1),a.destroy(),o.clear()}},setFlowState:r=>{v!==r&&T(r)}}}function Le(e){return te(e).handle}export{G as a,V as b,ne as c,oe as d,ie as e,ae as f,le as g,de as h,W as i,X as j,Y as k,ee as l,te as m,Le as n};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var p=Object.freeze({EDGE_LUMA_DELTA:40,MIN_ROW_DENSITY:.08,MIN_COLUMN_COVERAGE:.6,MIN_WIDTH_FRAC:.55,MIN_HEIGHT_FRAC:.02,MAX_HEIGHT_FRAC:.16,ROW_MERGE_GAP:18}),I=12;function F(H,D={}){let r={...p,...D},{data:s,width:n,height:t}=H;if(n<32||t<32)return null;let c=new Array(t).fill(!1),R=new Float32Array(t),u=new Int32Array(t).fill(n),a=new Int32Array(t).fill(-1),w=n/I,d=new Array(I);for(let e=0;e<t;e++){let M=0;d.fill(!1);let E=e*n*4,G=.299*(s[E]??0)+.587*(s[E+1]??0)+.114*(s[E+2]??0);for(let o=1;o<n;o++){let T=E+o*4,y=.299*(s[T]??0)+.587*(s[T+1]??0)+.114*(s[T+2]??0);Math.abs(y-G)>=r.EDGE_LUMA_DELTA&&(M+=1,d[Math.min(I-1,Math.floor(o/w))]=!0,o<u[e]&&(u[e]=o),o>a[e]&&(a[e]=o)),G=y}R[e]=M/n;let O=d.filter(Boolean).length/I;c[e]=R[e]>=r.MIN_ROW_DENSITY&&O>=r.MIN_COLUMN_COVERAGE&&a[e]-u[e]>=r.MIN_WIDTH_FRAC*n}let _=null,l=-1,f=-1,i=0,N=e=>{if(l<0)return;let M=e-l+1;M>=r.MIN_HEIGHT_FRAC*t&&M<=r.MAX_HEIGHT_FRAC*t&&i>=4&&(_===null||i>_.rows)&&(_={top:l,bottom:e,rows:i}),l=-1,i=0};for(let e=0;e<t;e++)c[e]&&(l<0?l=e:e-f>r.ROW_MERGE_GAP&&(N(f),l=e),f=e,i+=1);if(N(f),_===null)return null;let b=_,m=n,A=-1,C=0,h=0;for(let e=b.top;e<=b.bottom;e++)c[e]&&(u[e]<m&&(m=u[e]),a[e]>A&&(A=a[e]),C+=R[e],h+=1);return A-m<r.MIN_WIDTH_FRAC*n?null:{x:m,y:b.top,width:A-m,height:b.bottom-b.top+1,density:h>0?C/h:0}}export{p as a,F as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var o={"ID-1":{center:1.586,tolerance:.15},"ID-2":{center:1.419,tolerance:.12},"ID-3":{center:1.42,tolerance:.2}},c={"ID-1":["ID-1"],"ID-2":["ID-2"],"ID-3":["ID-3"],card:["ID-1","ID-2"]};function i(e){return o[e==="card"?"ID-1":e]}function d(e,r){return c[e].some(t=>Math.abs(r-o[t].center)<=o[t].tolerance)}var a=[{docType:"carte_identite",format:"ID-1",sides:["recto","verso"],mrz:"td1",portraitSide:"recto",aspectRatio:1.586,identifierSource:"mrz"},{docType:"passport",format:"ID-3",sides:["single"],mrz:"td3",portraitSide:"single",aspectRatio:1.42,identifierSource:"mrz"}],n=[...a,{docType:"residence_permit",format:"ID-1",sides:["recto","verso"],mrz:"td1",portraitSide:"recto",aspectRatio:1.586,identifierSource:"mrz"}];function s(e){let r=n.find(t=>t.docType===e);return r===void 0||r.format==="ID-1"?"card":r.format}export{o as a,i as b,d as c,a as d,n as e,s as f};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as R,c as le,d as x,e as T,f as w,g as de,h as E,i as V,q as pe,r as me}from"./chunk-YDQBVWXG.js";import{m as ae}from"./chunk-RVHAKRAI.js";import{a as se}from"./chunk-7V2M6Y2W.js";import{b as F}from"./chunk-DQWW4OCK.js";import{c as ce,e as ue,f as L}from"./chunk-4RS2YIL4.js";var Ee="https://api.sekyro.ai",ve=5e3,Me=1500,we=10;function Ve(e){return new Promise(t=>setTimeout(t,e))}function Oe(){let e=globalThis.crypto;if(e!==void 0&&typeof e.randomUUID=="function")return e.randomUUID();let t=new Uint8Array(16);if(e!==void 0&&typeof e.getRandomValues=="function")e.getRandomValues(t);else for(let i=0;i<16;i+=1)t[i]=Math.floor(Math.random()*256);t[6]=(t[6]??0)&15|64,t[8]=(t[8]??0)&63|128;let o=[...t].map(i=>i.toString(16).padStart(2,"0")).join("");return`${o.slice(0,8)}-${o.slice(8,12)}-${o.slice(12,16)}-${o.slice(16,20)}-${o.slice(20)}`}function lt(e){return De(e,{})}function De(e,t){let o=e.apiOrigin??Ee,i=e.autoRetry??!0,r=e.rearm??"auto",s=t.client??new ue({apiOrigin:o,sessionToken:e.clientToken,...e.fetch!==void 0?{fetch:e.fetch}:{}}),d=t.sleep??Ve,f=t.uuid??Oe,g=t.getTurnstileToken??((n,a)=>import("./turnstile-FATNZ4AG.js").then(m=>m.executeTurnstile(n,a))),c=se(),u=null,y=null,l=!1,q=new AbortController,p=null,H=null,P=n=>{p=n,c.emit("view",n),u?.onView(n)},C=()=>p!==null?Promise.resolve(p):(H??(H=s.getSession().then(n=>(P(n),n)).finally(()=>{H=null})),H),b=async()=>{let n=await s.getSession();return P(n),n},N=(n,a)=>{p!==null&&P(de(p,n,a))},B=null,Y=async n=>{let a=await C();!n&&a.consentRecorded||(await s.recordConsent(e.locale),p!==null&&P({...p,consentRecorded:!0}))},v=n=>n?.force===!0?Y(!0):(B??(B=Y(!1).finally(()=>{B=null})),B),U={client:s,ensureConsent:n=>v(n),sleep:d,uuid:f,onBusy:n=>{l||c.emit("busy",n)}},W=!1,Z=null,G=n=>{if(n.status==="approved"||n.status==="rejected"||n.status==="review"){if(W)return;W=!0}Z=JSON.stringify(n),c.emit("result",n)},ge=n=>{Z!==JSON.stringify(n)&&G(n)},J=async n=>{let a=p;n&&(a=await b().catch(()=>p));let m=a===null?null:R(a);return m!==null&&!l&&c.emit("method",m),m!==null},Q=null,j=!1,$=!1,X=()=>pe(U,(n,a)=>n.submitCheck("population_registry",{},{idempotencyKey:a})),z=n=>n.nniBound===!0||w(n,"population_registry")?.nniFromDocument===!0,Ce=async()=>{try{let n=await C();if(x(n)||R(n)!==null||T(n)?.checkType!=="population_registry")return;if(!z(n)&&w(n,"population_registry")?.nniFromDocument===void 0&&(n=await b()),!z(n)){$=!0;return}await v(),N(await X(),"population_registry");let a=p===null?void 0:w(p,"population_registry");if(a?.state==="input_required"&&a.reason==="registry_unavailable"&&a.attemptsRemaining>0){if(await d(ve),l)return;N(await X(),"population_registry")}}catch(n){if(n instanceof ce&&n.code==="method_required"){await b().catch(()=>{});return}j=!0;return}p!==null&&x(p)&&G(V(p,{autoRetry:i}))},ee=()=>(Q??(Q=Ce()),Q),_e=async()=>{let a=(await C()).turnstileSiteKey;return a===null?{sandbox:!0}:{channel:"hosted_web",siteKey:a,turnstileToken:await g(a,{signal:q.signal})}},_=null,te=Promise.resolve(),M=0,ke=async()=>{let n=await C();for(let a=0;a<we&&!l&&!x(n)&&T(n)===void 0&&n.steps.some(m=>m.state==="processing")&&(await d(Me),!l);a+=1)n=await b();return n},xe=async(n,a,m)=>{let{capture:k}=n,h=()=>l,O=()=>n.alive&&n.attempt===m,re=S=>{O()&&k.setFlowState(S)},I=S=>{if(!h()&&(G(S),!!O())){if(S.status==="retry"&&r==="auto"){k.handle.retry();return}k.setFlowState("done")}};if(a.degraded==="NO_RECORDER"){let S=p?.sessionId??(await C().catch(()=>null))?.sessionId??"";I(E(S,"no_recorder"));return}re("uploading");try{if(await ee(),h())return;let S=await C();if(!x(S)&&R(S)!==null){await J(!1),I(E(S.sessionId,"method_required"));return}if(!x(S)){if(T(S)?.checkType==="population_registry"){I(E(S.sessionId,$?"nni_unbound":j?"network":"registry_unavailable"));return}if(await v(),h())return;let D=await me({...U,artifacts:a,getAttestation:_e,getView:()=>p??S,refreshView:b,applySubmit:N,onPhase:re,isCancelled:h,onKeyframePromoted:Te=>{y=Te}});if(h())return;if(D.kind==="unavailable"){if(D.reason==="method_required"&&await J(!0),h())return;I(E(S.sessionId,D.reason));return}D.kind==="resync"&&await b(),S=await ke()}I(V(S,{autoRetry:i}))}catch{if(h())return;I(E(p?.sessionId??"","network"))}},Ae=(n,a)=>{let m=n.attempt;M>0&&n.alive&&n.capture.setFlowState("uploading"),M+=1,te=te.then(()=>xe(n,a,m)).finally(()=>{M-=1,M===0&&u?.onChainIdle()}).catch(()=>{})},ne=n=>{_?.capture.handle.destroy(),_!==null&&(_.alive=!1);let a=ae(n,u?.captureInternals?.(n)??t.capture,()=>p?.capture?.liveness?.keyframe?.rank===!0),m={capture:a,alive:!0,attempt:0};_=m,a.handle.on("state",h=>{h==="starting"&&(m.attempt+=1)}),a.handle.on("captured",h=>{Promise.resolve().then(()=>Ae(m,h))});let k=a.handle;return{get state(){return k.state},on:(h,O)=>k.on(h,O),start:h=>k.start(h),retry:()=>k.retry(),switchCamera:()=>k.switchCamera(),destroy:()=>{m.alive=!1,_===m&&(_=null),k.destroy()}}},be=async()=>{if(l)return null;try{let n=await C();return l?null:R(n)}catch{return null}},Re=async()=>{if(l)return!1;try{let n=await C();if(l||x(n))return!1;let a=w(n,"liveness");return le(a)&&a?.requiresMobile===!0&&!F()}catch{return!1}},Pe=async()=>{if(l)return!1;try{let n=await C();return!l&&n.returning===!0}catch{return!1}},oe=async n=>{let a=await s.selectMethod(n);l||P(a)},ie=null,Ie=()=>(ie??(ie=import("./plan-runner-UBK4B4CG.js").then(n=>{let a=n.createPlanRunner({runtime:U,currentView:()=>p,ensureView:C,refreshView:b,ensureConsent:()=>v(),selectMethod:oe,liveness:ne,chainBusy:()=>M>0,destroyed:()=>l,sleep:d,isMobile:F,now:t.now??Date.now,keptFaceKey:()=>y,setView:P,baseCapture:t.capture,emitStep:m=>{l||c.emit("step",m)},emitResult:ge,...t.document!==void 0?{documentInternals:t.document}:{},...t.portrait!==void 0?{portraitInternals:t.portrait}:{},livePhotoInternals:t.livePhoto});return u=a,a})),ie);return{consent:()=>v(),startRegistry:ee,methodChoice:be,selectMethod:oe,mobileRequired:Re,returning:Pe,liveness:ne,run:async()=>{if(l)throw new Error("verification destroyed");return(await Ie()).run()},currentStep:()=>u?.current()??null,voiceClips:async()=>{if(l)return null;try{let n=await C();return l?null:n.voice??null}catch{return null}},on:(n,a)=>c.on(n,a),destroy:()=>{l=!0,q.abort(),u?.destroy(),_!==null&&(_.alive=!1,_.capture.handle.destroy(),_=null),c.clear()}}}var fe=["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 Le=["carte_identite","passport","residence_permit"];function He(e,t){let o=e.byIssuer?.[t]??e.default;return Le.filter(i=>o==="*"||o.includes(i))}function ft(e,t=fe){return[...new Set([...t,...Object.keys(e.byIssuer??{})])].filter(i=>He(e,i).length>0).sort()}function Se(e){if(e.acceptedDocuments)return e.acceptedDocuments;let t=e.acceptedDocumentTypes?.length?[...e.acceptedDocumentTypes]:["carte_identite","passport"];return{default:[],byIssuer:{MR:t}}}function St(e){return/^[A-Z]{2}$/.test(e)?String.fromCodePoint(...[...e].map(t=>127462+t.charCodeAt(0)-65)):""}var Ne=["national_number","document_photo","national_eid"],Be=["national_number","document_photo"],Ue=new Set(["eid_not_enrolled","eid_unavailable","eid_locked"]),ye="platform_unsupported",Ge=new Set(["prefilled","user_entered","prefilled_or_entered"]),Fe={phone_otp:"contact",email_otp:"contact",eid_auth:"identity",doc_ocr:"identity",nfc_chip:"identity",population_registry:"identity",liveness:"live_photo",portrait_icao:"live_photo",face_match:"live_photo"};function A(e){return e.section??Fe[e.checkType]??null}function Ke(e){let t={sessionId:e.sessionId,orgName:e.orgName,returning:e.returning===!0,consentRecorded:e.consentRecorded,expiresAt:e.expiresAt,sections:[]};for(let o of e.steps){let i=A(o);i!==null&&!t.sections.includes(i)&&t.sections.push(i)}return e.branding!==void 0&&(t.branding=e.branding),t}function qe(e){let t={attemptsRemaining:e.attemptsRemaining,attemptsExhausted:e.attemptsExhausted===!0};return e.reason!==void 0&&(t.reason=e.reason),t}function Ye(e,t){let o=e.otpChoice;if(o===void 0||o.locked||o.selected===null)return;let i=t==="phone_otp"?"email":"phone";return o.options.includes(i)?i:void 0}function We(e,t,o,i){let r=t.checkType==="email_otp",s=(r?t.emailOtp:t.otp)??{},d=r?t.emailOtp?.emailSource:t.otp?.numberSource,f=d!==void 0&&Ge.has(d)?d:r?"prefilled_or_entered":"user_entered",g=typeof s.sentToMasked=="string"&&s.sentToMasked.length>0,c=Ye(e,r?"email_otp":"phone_otp"),u={key:t.checkType,context:o,section:A(t),phase:g?"verify":"send",canSwitch:c!==void 0,...i},y=r?{kind:"email_otp",...u,emailSource:f,needsEmail:f!=="prefilled"}:{kind:"phone_otp",...u,numberSource:f,needsPhone:f!=="prefilled",channels:(t.otp?.channels??[]).filter(l=>l==="whatsapp"||l==="sms")};return c!==void 0&&(y.switchChannel=c),g&&(y.sentToMasked=s.sentToMasked),!r&&t.otp?.channel!==void 0&&(y.channel=t.otp.channel),s.expiresAt!==void 0&&(y.codeExpiresAt=s.expiresAt),s.resendAvailableAt!==void 0&&(y.resendAvailableAt=s.resendAvailableAt),y}function Ze(e,t,o,i){let r=e.nniBound===!0?"bound":t.nniFromDocument===!0?"document":"typed",s=r==="typed"&&t.state==="input_required"&&t.reason==="nni_recheck",d=t.reason==="nni_not_found"&&t.state==="input_required"&&!i.attemptsExhausted&&e.methodChoice?.available===!0&&e.methodChoice.options.includes("document_photo");return{kind:"registry",key:"registry",context:o,section:A(t),state:t.state==="input_required"?"input_required":"pending",source:r,recheck:s,canUseDocument:d,...i}}function Je(e,t,o,i){let r=[...t.acceptedSides??[]];return{kind:"document",key:"document",context:o,section:A(t),side:r.includes("recto")?"verso":"recto",acceptedSides:r,documents:Se(e),...i}}function Qe(e){let t=e.steps.find(o=>o.checkType==="liveness");return t?.state==="passed"||t?.state==="review"}function he(e,t,o,i,r){let s=t.icao?.report;return{kind:"portrait",key:`portrait:${r}`,context:o,section:A(t),phase:r,report:Array.isArray(s)?s:null,review:t.state==="review",tuning:e.capture?.icao??null,tuningVersion:e.capture?.tuningVersion??null,icao:L(e),retakeOnly:r==="capture"&&t.state==="input_required"&&e.capture?.livePhoto?.oneCapture===!0&&Qe(e),...i}}var K={minLongSidePx:1280,jpegQuality:.95};function je(e,t){let o=e.capture?.livePhoto;if(o?.oneCapture!==!0)return null;let i=e.steps.find(s=>s.checkType==="portrait_icao"),r=o.still??K;return{icao:t==="liveness"&&L(e)!==null&&i!==void 0&&i.state==="pending"&&i.reason===void 0,still:{minLongSidePx:r.minLongSidePx??K.minLongSidePx,jpegQuality:r.jpegQuality??K.jpegQuality}}}function $e(e,t,o,i){let r=t.eid,s=A(t);if(r===void 0||r.challenge!=="app_code")return{kind:"unsupported",key:"unsupported:eid_auth",context:o,section:s,checkType:"eid_auth",reason:"update_required"};let d=e.methodChoice,f=d?.available===!0?d.options.find(u=>Be.includes(u)):void 0,g=f!==void 0&&t.state==="input_required"&&(t.reason!==void 0&&Ue.has(t.reason)||t.attemptsExhausted===!0||t.attemptsRemaining===0||t.reason==="eid_resend_limit"&&r.awaiting!=="code"),c={kind:"eid",key:"eid",context:o,section:s,provider:r.provider,providerName:r.providerName,country:r.country,challenge:"app_code",phase:r.awaiting==="code"?"code":"identifier",identifierBound:r.identifierBound===!0,canUseCamera:g,afterPass:r.afterPass==="continue"?"continue":"end",...i};return g&&(c.cameraMethod=f),r.expiresAt!==void 0&&(c.codeExpiresAt=r.expiresAt),r.resendAvailableAt!==void 0&&(c.resendAvailableAt=r.resendAvailableAt),r.resendsRemaining!==void 0&&(c.resendsRemaining=r.resendsRemaining),r.codeAttemptsRemaining!==void 0&&(c.codeAttemptsRemaining=r.codeAttemptsRemaining),c}function Xe(e,t){if(t.checkType!=="face_match"||t.reason!==void 0)return null;let o=e.steps.find(i=>i.checkType==="portrait_icao");return o!==void 0&&(o.state==="passed"||o.state==="review")?o:null}function ze(e){return e.steps.some(t=>t.attemptsExhausted===!0)}function et(e,t){let o=e.failureReason,i;o===ye?i="platform_unsupported":e.status==="expired"?i="expired":e.status==="review_pending"?i="review":e.status==="completed"&&e.outcome==="approved"?i="approved":e.status==="completed"&&e.outcome==="review"?i="review":o==="device_cooldown"?i="cooldown":o!==void 0?i="policy_stop":ze(e)?i="attempts_exhausted":i="rejected";let r=i==="platform_unsupported"?{sessionId:e.sessionId,status:"unavailable"}:V(e,{autoRetry:!1}),s={kind:"result",key:"result",context:t,section:null,display:i,result:r};return o!==void 0&&(s.failureReason=o),e.retryAfter!==void 0&&(s.retryAfter=e.retryAfter),s}function tt(e,t){let o=e.identitySummary;if(o==null)return null;let i={kind:"identity_summary",key:"identity_summary",context:t,section:"identity",summaryKind:o.kind==="partial"?"partial":o.kind??"full",source:o.source,portraitAvailable:o.portrait?.available===!0,retakeAvailable:o.retakeAvailable===!0};for(let r of nt){let s=o[r];typeof s=="string"&&s!==""&&(i[r]=s)}return i}var nt=["fullName","birthDate","birthYear","nationality","documentType","documentNumberMasked","nniMasked","expiryDate","retakeTarget"];function _t(e,t={}){let o=Ke(e);if(x(e)||e.failureReason===ye)return et(e,o);let i=tt(e,o);if(i!==null)return i;let r=R(e);if(r!==null){let c=r.options.filter(y=>Ne.includes(y));if(c.length===0)return{kind:"unsupported",key:"unsupported:method",context:o,section:"identity",checkType:"method",reason:"platform_unsupported"};let u={kind:"method",key:"method",context:o,section:"identity",options:c};return c.includes("national_eid")&&r.nationalEid!==void 0&&(u.nationalEid=r.nationalEid),u}let s=T(e);if(s===void 0){let c=e.steps.find(u=>u.state==="processing");return{kind:"processing",key:"processing",context:o,section:c===void 0?null:A(c),stalled:!1}}let d=qe(s),f=s.checkType,g=A(s);switch(f){case"phone_otp":case"email_otp":{let c=e.otpChoice;return c!==void 0&&c.selected===null&&!c.locked?{kind:"contact_choice",key:"contact_choice",context:o,section:g,options:c.options.filter(u=>u==="phone"||u==="email"),selected:null,locked:!1}:We(e,s,o,d)}case"population_registry":return Ze(e,s,o,d);case"eid_auth":return $e(e,s,o,d);case"doc_ocr":return Je(e,s,o,d);case"portrait_icao":return he(e,s,o,d,"capture");case"liveness":case"face_match":{let c=Xe(e,s);if(c!==null)return he(e,c,o,d,"match");let u=s.requiresMobile===!0,y=L(e);return u&&t.isMobile===!1?{kind:"mobile_required",key:"mobile_required",context:o,section:g,checkType:f}:{kind:"liveness",key:"biometric",context:o,section:g,mode:f==="face_match"?"selfie":"liveness",requiresMobile:u,instructions:y===null?"standard":"icao",icao:y,livePhoto:je(e,f),...d}}default:return{kind:"unsupported",key:`unsupported:${f}`,context:o,section:g,checkType:f,reason:f==="nfc_chip"?"platform_unsupported":"update_required"}}}export{Ee as a,ve as b,Me as c,we as d,Oe as e,lt as f,De as g,fe as h,Le as i,He as j,ft as k,Se as l,St as m,Ne as n,ye as o,A as p,Xe as q,_t as r};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as v,d as E}from"./chunk-4RS2YIL4.js";var L=new Set(["no_face","media_unreadable","clip_too_short","no_face_source","side_missing","unreadable","registry_unavailable","otp_mismatch","otp_expired","otp_send_failed","document_type_not_accepted","age_unverifiable","nationality_unreadable","liveness_inconclusive","match_inconclusive","document_authenticity","probe_not_from_liveness","chip_read_failed","chip_access_denied","chip_parse_failed","icao_pose","icao_eyes","icao_mouth","icao_occlusion","icao_lighting","icao_background","icao_resolution","portrait_not_from_liveness","nni_recheck","device_integrity_failed","eid_identifier_invalid","eid_code_invalid","eid_code_expired","eid_unavailable","eid_resend_too_soon"]);function Z(e){let t=e.methodChoice;if(t===void 0||!t.available||t.selected!==null)return null;let n=w(e)?.checkType;return n==="phone_otp"||n==="email_otp"?null:t}var F=new Set(["liveness","face_match"]);function C(e){return e!==void 0&&(e.state==="pending"||e.state==="input_required")}function M(e){return e.status!=="created"&&e.status!=="in_progress"}function w(e){return e.steps.find(t=>C(t))}function S(e,t){return e.steps.find(n=>n.checkType===t)}function R(e,t){let n=t.steps.find(o=>o.checkType==="liveness"),i=t.steps.find(o=>o.checkType==="face_match");return S(e,"face_match")?.state==="pending"&&(n?.state==="passed"||n?.state==="review")&&i!==void 0&&i.state!=="pending"&&i.state!=="skipped"}function ee(e,t,n){let i=new Map(e.steps.map(r=>[r.checkType,r])),o=n==="liveness"&&R(e,t),s=t.steps.map(r=>{let u=i.get(r.checkType),a=u?.attemptsRemaining??0,c={...u??{},checkType:r.checkType,state:r.state,attemptsRemaining:r.checkType===n||r.checkType==="face_match"&&o?Math.max(0,a-1):a};return r.reason!==void 0?c.reason=r.reason:delete c.reason,r.attemptsExhausted!==void 0?c.attemptsExhausted=r.attemptsExhausted:delete c.attemptsExhausted,c});return{...e,status:t.status,outcome:t.outcome,failureReason:t.failureReason,steps:s,expiresAt:t.expiresAt}}function g(e,t){return t===void 0?{sessionId:e,status:"unavailable"}:{sessionId:e,status:"unavailable",reason:t}}function m(e,t,n){return n===void 0?{sessionId:e,status:t}:{sessionId:e,status:t,reason:n}}function te(e,t){let{sessionId:n}=e;switch(e.status){case"completed":return e.outcome==="approved"?{sessionId:n,status:"approved"}:e.outcome==="review"?m(n,"review",h(e,"review")):m(n,"rejected",h(e,"failed"));case"failed":{let s=m(n,"rejected",e.failureReason??h(e,"failed"));return e.failureReason==="device_cooldown"&&e.retryAfter!==void 0&&(s.retryAfter=e.retryAfter),s}case"review_pending":return m(n,"review",h(e,"review"));case"expired":return g(n);case"created":case"in_progress":break;default:{let s=e.status;throw new Error(`mapSessionResult: unhandled status ${s}`)}}let i=e.steps.find(s=>F.has(s.checkType)&&s.state==="input_required"&&s.reason!==void 0);if(i?.reason==="mobile_required")return g(n,"mobile_required");if(i?.reason!==void 0){let s=t.autoRetry&&L.has(i.reason)&&i.attemptsRemaining>0;return{sessionId:n,status:s?"retry":"rejected",reason:i.reason,attemptsRemaining:i.attemptsRemaining}}let o=w(e);return o===void 0&&e.steps.some(s=>s.state==="review")?m(n,"review",h(e,"review")):o?.checkType==="portrait_icao"?g(n,"portrait_required"):g(n)}function h(e,t){return e.steps.find(n=>n.state===t&&n.reason!==void 0)?.reason}function T(e,t,n,i,o){return e.presignCapture!==void 0?e.presignCapture(t,n,i,o):e.presign(t,n,i)}function V(e){return{...e?.engine!==void 0?{engine:e.engine}:{},...e?.clipMs!==void 0?{durationMs:e.clipMs}:{}}}var I=["video/webm","video/mp4"],x="image/jpeg",q=2,K=1e3,O=1e4,N=3,Y=10,B=30,D=3,U=new Set(["network_error","timeout","upload_failed","unknown_error","rate_limit_exceeded"]),$=new Set(["session_not_active","check_not_found","check_already_finalized","check_out_of_order","identity_confirm_required"]),_=class extends Error{constructor(){super("verification destroyed"),this.name="FlowCancelledError"}};function j(e){let t=e.steps.findIndex(i=>i.checkType==="liveness");return t<0?!1:e.steps.slice(t+1).find(i=>C(i))?.checkType==="face_match"}var y=class extends Error{constructor(t){super(t),this.name="AttestationError"}};async function A(e,t,n={}){let i=e.uuid(),o=!1,s=!1,r=0,u=0;for(;;)try{return await t(e.client,i)}catch(a){if(a instanceof y){if(s)throw a;s=!0,n.onAttestationInvalid?.(),i=e.uuid();continue}if(!(a instanceof v))throw a;if(a.code==="consent_required"&&!o){o=!0,await e.ensureConsent({force:!0}),i=e.uuid();continue}if(a.code==="attestation_invalid"&&!s){s=!0,n.onAttestationInvalid?.(),i=e.uuid();continue}if(a.code==="inference_unavailable"&&u<N){u+=1;let c=Math.min(a.retryAfterSeconds??Y,B);e.onBusy?.({attempt:u,retryAfterSeconds:c}),await e.sleep(c*1e3),n.onAttestationInvalid?.(),i=e.uuid();continue}if(U.has(a.code)&&r<q){r+=1;let c=a.retryAfterSeconds!==void 0?a.retryAfterSeconds*1e3:void 0;await e.sleep(c!==void 0?Math.min(c,O):K);continue}throw a}}var z=new Set(["passed","review","processing","skipped"]);async function re(e){let{artifacts:t}=e,n=t.clip,i=E(t.clipMime??"");if(t.degraded==="NO_RECORDER"||n===void 0||!I.includes(i))return{kind:"unavailable",reason:"no_recorder"};e.client.armCapture?.(2);let o=X(e,t.keyframe),s=W(e,n,i,o),r=G(e,o),u=!1,a=!1,c=!0,f=0;for(;;){if(e.isCancelled())return{kind:"cancelled"};let l=e.getView();if(M(l))return{kind:"settled"};let b=w(l)?.checkType,k=b==="liveness"&&!u?"liveness":b==="face_match"&&!a&&c?"face_match":null;if(k===null)return{kind:"settled"};if(k==="liveness"&&t.captureChannel==="desktop"&&S(l,"liveness")?.requiresMobile===!0)return{kind:"unavailable",reason:"mobile_required"};try{if(k==="liveness"){u=!0;let d=await s();if(e.isCancelled())return{kind:"cancelled"};a=R(l,d),e.applySubmit(d,"liveness");let p=S(e.getView(),"liveness")?.state;c=p===void 0||z.has(p)}else{a=!0;let d=await r();if(e.isCancelled())return{kind:"cancelled"};e.applySubmit(d,"face_match")}}catch(d){if(e.isCancelled()||d instanceof _)return{kind:"cancelled"};let p=Q(d);if(p.kind!=="resync"||f>=D)return p;f+=1,await e.refreshView()}}}function X(e,t){let n=null,i=null,o=()=>n!==null?Promise.resolve(n):(i??(i=(async()=>{let s=await T(e.client,"image",x,t.size,V(e.artifacts));return await e.client.uploadToSpaces(s.uploadUrl,t,x),n=(await e.client.completeMedia(s.key)).key,e.onKeyframePromoted?.(n),n})().finally(()=>{i=null})),i);return{ensure:o,attempt:()=>o().catch(()=>null),current:()=>n}}function W(e,t,n,i){let o=null,s,r=null;return()=>A(e,async(u,a)=>{if(o===null||s===void 0){if(e.isCancelled())throw new _;s===void 0&&!j(e.getView())&&(s=null),e.onPhase("uploading");let[c,f]=await Promise.all([o!==null?Promise.resolve(o):(async()=>{let l=await T(u,"clip",n,t.size,V(e.artifacts));return await u.uploadToSpaces(l.uploadUrl,t,n),(await u.completeMedia(l.key)).key})(),s!==void 0?Promise.resolve(s===null?null:s.imageKey):i.attempt()]);o=c,s===void 0&&(s=f===null?null:{imageKey:f})}if(r===null)try{r=await e.getAttestation()}catch(c){throw new y(c instanceof Error?c.message:String(c))}return e.onPhase("checking"),u.submitCheck("liveness",{clipKey:o,attestation:r,captureChannel:e.artifacts.captureChannel,capture:J(e.artifacts),...s!==null?{faceMatch:s}:{}},{idempotencyKey:a})},{onAttestationInvalid:()=>{r=null}})}function G(e,t){return()=>A(e,async(n,i)=>{if(t.current()===null){if(e.isCancelled())throw new _;e.onPhase("uploading")}let o=await t.ensure();return e.onPhase("checking"),n.submitCheck("face_match",{imageKey:o},{idempotencyKey:i})})}function J(e){return{...e.engine!==void 0?{engine:e.engine}:{},width:e.width,height:e.height,...e.clipMs!==void 0?{clipMs:e.clipMs}:{},...e.cameraReadyMs!==void 0?{cameraReadyMs:e.cameraReadyMs}:{},...e.faceAcquireMs!==void 0?{faceAcquireMs:e.faceAcquireMs}:{},...e.captureMs!==void 0?{captureMs:e.captureMs}:{}}}function Q(e){if(e instanceof y)return{kind:"unavailable",reason:"attestation"};if(e instanceof v){if(e.code==="attestation_invalid")return{kind:"unavailable",reason:"attestation"};if(e.code==="method_required")return{kind:"unavailable",reason:"method_required"};if(e.code==="inference_unavailable")return{kind:"unavailable",reason:"inference_unavailable"};if(e.code==="mobile_required")return{kind:"unavailable",reason:"mobile_required"};if($.has(e.code))return{kind:"resync"}}return{kind:"unavailable",reason:"network"}}var P=class extends Error{constructor(t,n){super(`invalid ${t} (${n})`),this.name="InvalidInputError",this.field=t,this.kind=n}},H=class extends Error{constructor(t,n){super(`invalid ${t} (${n})`),this.name="OtpInputError",this.field=t,this.kind=n}};export{L as a,Z as b,C as c,M as d,w as e,S as f,ee as g,g as h,te as i,T as j,I as k,q as l,K as m,N as n,Y as o,y as p,A as q,re as r,P as s,H as t};
|