@voltom.io/sdk 1.0.2 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/dist/assets/locales/ar.json +121 -0
  2. package/dist/assets/locales/ch.json +121 -0
  3. package/dist/assets/locales/de.json +121 -0
  4. package/dist/assets/locales/en.json +121 -0
  5. package/dist/assets/locales/es.json +121 -0
  6. package/dist/assets/locales/fr.json +121 -0
  7. package/dist/assets/locales/it.json +121 -0
  8. package/dist/assets/locales/ja.json +121 -0
  9. package/dist/assets/locales/pt.json +121 -0
  10. package/dist/assets/locales/ru.json +121 -0
  11. package/dist/assets/locales/zh.json +121 -0
  12. package/dist/sdk/PoseSilhouette-CTZ5kqI_.js +2 -0
  13. package/dist/sdk/PoseSuccess-CxL2ugaZ.js +2 -0
  14. package/dist/sdk/facegate/global.d.ts +5 -0
  15. package/dist/sdk/facegate.d.ts +51 -0
  16. package/dist/sdk/facegate.dist.js +56 -0
  17. package/dist/sdk/facegate.js +2 -0
  18. package/dist/sdk/facekey/global.d.ts +0 -2
  19. package/dist/sdk/facekey.browser-D_vfob8H.js +2 -0
  20. package/dist/sdk/facekey.d.ts +2 -3
  21. package/dist/sdk/facekey.dist.js +3 -2
  22. package/dist/sdk/facekey.js +1 -1
  23. package/dist/sdk/media-KU3CWepq.js +2 -0
  24. package/dist/sdk/poseGuidance-DLg3Dm3T.js +65 -0
  25. package/dist/sdk/presentation-BCIQkuw0.js +2 -0
  26. package/dist/sdk/presentation-D9v4ITH0.js +8 -0
  27. package/dist/sdk/verify/global.d.ts +0 -2
  28. package/dist/sdk/verify.d.ts +2 -5
  29. package/dist/sdk/verify.dist.js +18 -18
  30. package/dist/sdk/verify.js +1 -1
  31. package/dist/sdk/view-CsOmx3ht.js +3 -0
  32. package/dist/sdk/view-Dgrm0mpZ.js +3 -0
  33. package/dist/sdk/view-WiNYUW9A.js +2 -0
  34. package/package.json +27 -9
  35. package/dist/sdk/DebugPanel-BJqGy2Dp.js +0 -2
  36. package/dist/sdk/faceMatch.shared-D6B1I2T0.js +0 -65
  37. package/dist/sdk/feedback-Cs09W_hs.js +0 -2
  38. package/dist/sdk/presentation-BrCGZT1u.js +0 -8
  39. package/dist/sdk/presentation-Jz2euuHa.js +0 -2
  40. package/dist/sdk/view-usv6rHIE.js +0 -3
  41. package/dist/sdk/view-vxhVZZc1.js +0 -2
@@ -0,0 +1,2 @@
1
+ /*! Copyright (c) 2026 VOLTOM. All rights reserved. Proprietary software. See LICENSE at https://voltom.io/license. */
2
+ import{et as e}from"./poseGuidance-DLg3Dm3T.js";var t=()=>({operation:e(`enroll`),phase:e(`loading`),instruction:e(null),guidance:e(null),corrective:e(null),progress:e({completed:0,total:1}),feedback:e(null),failures:e(0),error:e(null),debug:e([]),debugEnabled:e(!1),match:e(null),facingMode:e(null)});export{t};
@@ -0,0 +1,8 @@
1
+ /*! Copyright (c) 2026 VOLTOM. All rights reserved. Proprietary software. See LICENSE at https://voltom.io/license. */
2
+ import{A as e,B as t,D as n,F as r,G as i,H as a,I as o,J as s,K as c,L as l,M as u,N as d,O as f,P as p,R as m,T as h,W as g,X as _,Y as v,Z as y,a as b,c as x,d as S,et as C,f as w,g as T,i as E,j as D,k as O,m as k,n as A,o as j,p as M,r as ee,t as te,u as N,v as P,z as F}from"./poseGuidance-DLg3Dm3T.js";import{D as ne,i as re,l as ie,m as I,n as ae,p as oe}from"./media-KU3CWepq.js";var se=({box:e,image:t})=>{let n=Math.max(0,Math.floor(e.left)),r=Math.max(0,Math.floor(e.top)),i=Math.min(t.width,Math.ceil(e.right)),a=Math.min(t.height,Math.ceil(e.bottom)),o=Math.max(1,i-n),s=Math.max(1,a-r),c=new Uint8ClampedArray(o*s*4);for(let e=0;e<s;e+=1){let i=((r+e)*t.width+n)*4,a=e*o*4;c.set(t.data.subarray(i,i+o*4),a)}return{data:c,height:s,width:o}},ce=({height:e,image:t,width:n})=>{let r=new Uint8ClampedArray(n*e*4),i=t.width/n,a=t.height/e;for(let o=0;o<e;o+=1){let e=Math.min(t.height-1,Math.floor((o+.5)*a));for(let a=0;a<n;a+=1){let s=Math.min(t.width-1,Math.floor((a+.5)*i)),c=(e*t.width+s)*4,l=(o*n+a)*4;r[l]=t.data[c]??0,r[l+1]=t.data[c+1]??0,r[l+2]=t.data[c+2]??0,r[l+3]=255}}return{data:r,height:e,width:n}},le=.3,ue=.6,de=12,fe=3,pe=async({session:e,tensor:t})=>{let n=performance.now();try{let n=await e.run({[e.inputNames[0]]:t}),r=n[e.outputNames[0]];if(!r){for(let e of Object.values(n))e.dispose();throw Error(v.INVALID_MODEL_OUTPUT)}for(let e of Object.values(n))e!==r&&e.dispose();return r}catch(e){throw Error(_({error:e,fallback:v.INFERENCE_FAILED}),{cause:e})}finally{i({category:`inference`,duration:performance.now()-n,key:`ocr`}),t.dispose()}},me=({text:e})=>e.normalize(`NFKC`).replace(/\r\n?/gu,`
3
+ `).replace(/[\t\f\v ]+/gu,` `).replace(/ *\n */gu,`
4
+ `).trim(),he=({pixels:e,runtime:t})=>{let n=Math.max(32,Math.ceil(e.width/32)*32),r=Math.max(32,Math.ceil(e.height/32)*32),i=new Float32Array(3*n*r),a=[.485,.456,.406],o=[.229,.224,.225];for(let e=0;e<3;e+=1)i.fill((1-(a[e]??0))/(o[e]??1),e*n*r,(e+1)*n*r);for(let t=0;t<e.height;t+=1)for(let s=0;s<e.width;s+=1){let c=(t*e.width+s)*4,l=t*n+s;for(let t=0;t<3;t+=1){let s=(e.data[c+t]??0)/255;i[t*n*r+l]=(s-(a[t]??0))/(o[t]??1)}}return{height:r,tensor:new t.Tensor(`float32`,i,[1,3,r,n]),width:n}},ge=({height:e,scores:t,width:n})=>{let r=new Uint8Array(n*e),i=[],a=new Int32Array(n*e);for(let o=0;o<t.length;o+=1){if(r[o]||(t[o]??0)<le)continue;let s=0,c=1,l=o%n,u=l,d=Math.floor(o/n),f=d,p=0,m=0;for(a[0]=o,r[o]=1;s<c;){let i=a[s]??0;s+=1;let o=i%n,h=Math.floor(i/n);l=Math.min(l,o),u=Math.max(u,o),d=Math.min(d,h),f=Math.max(f,h),p+=t[i]??0,m+=1;for(let i=-1;i<=1;i+=1)for(let s=-1;s<=1;s+=1){let l=o+s,u=h+i;if(l<0||l>=n||u<0||u>=e)continue;let d=u*n+l;r[d]||(t[d]??0)<le||(r[d]=1,a[c]=d,c+=1)}}let h=u-l+1,g=f-d+1;if(m<de||h<fe||g<fe||p/m<ue)continue;let _=h*.25,v=g*.35;i.push({bottom:f+1+v,left:l-_,right:u+1+_,score:p/m,top:d-v})}return i},_e=({boxes:e})=>e.sort((e,t)=>{let n=e.bottom-e.top,r=t.bottom-t.top,i=Math.max(n,r)*.6;return Math.abs(e.top-t.top)<=i?e.left-t.left:e.top-t.top}),ve=async({pixels:e,runtime:t,session:n})=>{let r=he({pixels:e,runtime:t}),i=await pe({session:n,tensor:r.tensor});try{let e=Number(i.dims.at(-2)),t=Number(i.dims.at(-1)),n=ge({height:e,scores:i.data,width:t}),a=r.width/t,o=r.height/e;return _e({boxes:n.map(({bottom:e,left:t,right:n,top:r})=>({bottom:e*o,left:t*a,right:n*a,top:r*o}))})}finally{i.dispose()}},ye=({pixels:e,runtime:t,model:n})=>{let r=n.recognitionHeight,i=Math.max(1,Math.round(e.width/e.height*r)),a=Math.max(32,Math.ceil(i/32)*32),o=ce({height:r,image:e,width:i}),s=new Float32Array(3*a*r);for(let e=0;e<r;e+=1)for(let t=0;t<i;t+=1){let c=(e*i+t)*4,l=e*a+t,u=o.data[c],d=o.data[c+1],f=o.data[c+2],p=u*.299+d*.587+f*.114;s[l]=((n.channels===`grayscale`?p:f)/255-.5)/.5,s[a*r+l]=((n.channels===`grayscale`?p:d)/255-.5)/.5,s[2*a*r+l]=((n.channels===`grayscale`?p:u)/255-.5)/.5}return new t.Tensor(`float32`,s,[1,3,r,a])},be=({text:e})=>{let t=[],n=``;for(let r of e)/[a-zA-Z0-9 :*./%+-]/u.test(r)?n+=r:(n&&t.push(n),t.push(r),n=``);return n&&t.push(n),t.reverse().join(``)},xe=({dictionary:e,output:t,reverse:n})=>{let r=Number(t.dims.at(-1)),i=Number(t.dims.at(-2)),a=e[0]===``?[...e]:[``,...e];if(a.length===r-1&&a.push(` `),a.length!==r)throw Error(v.OCR_DICTIONARY_MISMATCH);let o=-1,s=``;for(let e=0;e<i;e+=1){let n=e*r,i=0,c=t.data[n]??-1/0;for(let e=1;e<r;e+=1){let r=t.data[n+e]??-1/0;r<=c||(i=e,c=r)}i!==0&&i!==o&&(s+=a[i]??``),o=i}let c=s.trim();return n?be({text:c}):c},Se=({lines:e})=>e.filter((t,n)=>{let r=t.box.width*t.box.height;return!e.some((e,i)=>{if(i===n||!e.text.endsWith(t.text))return!1;let a=e.box.width*e.box.height;if(a<r||e.text.length===t.text.length&&a===r&&i>n)return!1;let o=Math.max(0,Math.min(t.box.x+t.box.width,e.box.x+e.box.width)-Math.max(t.box.x,e.box.x)),s=Math.max(0,Math.min(t.box.y+t.box.height,e.box.y+e.box.height)-Math.max(t.box.y,e.box.y));return r>0&&o*s>=r*.95})}),Ce=async({adapter:e,model:t})=>{let[n,r,i]=await Promise.all([e.session(t.detection),e.session(t.recognition),e.load(t.dictionary)]),a=new TextDecoder().decode(i).replace(/\r/gu,``).split(`
5
+ `);for(;a.at(-1)===``;)a.pop();return{model:t.id,assets:[t.detection,t.recognition,t.dictionary],recognize:async({image:i})=>{let o=await e.decode(i),s=await ve({pixels:o,runtime:e.runtime,session:n}),c=[];for(let n of s){let i=ye({pixels:se({box:n,image:o}),runtime:e.runtime,model:t}),s=await pe({session:r,tensor:i}),l;try{l=xe({dictionary:a,output:s,reverse:t.reverseArabic})}finally{s.dispose()}if(!l)continue;let u={height:Math.max(0,Math.min(o.height,n.bottom)-Math.max(0,n.top)),width:Math.max(0,Math.min(o.width,n.right)-Math.max(0,n.left)),x:Math.max(0,n.left),y:Math.max(0,n.top)};c.push({angle:0,box:u,confidence:null,text:l,words:[{box:u,confidence:null,text:l}]})}let l=Se({lines:c}),u=me({text:l.map(e=>e.text).join(`
6
+ `)});return{engine:t.id,height:o.height,lines:l,text:u,width:o.width}}}},L=`odm.ort`,we={tiny:{id:`tiny`,detection:`od.ort`,recognition:`or.ort`,dictionary:`ot.txt`,recognitionHeight:48,channels:`grayscale`,reverseArabic:!1},small:{id:`small`,detection:`ods.ort`,recognition:`ors.ort`,dictionary:`ots.txt`,recognitionHeight:48,channels:`grayscale`,reverseArabic:!1},japanese:{id:`japanese`,detection:L,recognition:`orj.ort`,dictionary:`otj.txt`,recognitionHeight:48,channels:`bgr`,reverseArabic:!1},"chinese-simplified":{id:`chinese-simplified`,detection:L,recognition:`orcs.ort`,dictionary:`otcs.txt`,recognitionHeight:48,channels:`bgr`,reverseArabic:!1},"chinese-traditional":{id:`chinese-traditional`,detection:L,recognition:`orct.ort`,dictionary:`otct.txt`,recognitionHeight:48,channels:`bgr`,reverseArabic:!1},cyrillic:{id:`cyrillic`,detection:L,recognition:`orc.ort`,dictionary:`otc.txt`,recognitionHeight:48,channels:`bgr`,reverseArabic:!1},arabic:{id:`arabic`,detection:L,recognition:`ora.ort`,dictionary:`ota.txt`,recognitionHeight:48,channels:`bgr`,reverseArabic:!0}},Te={eng:`eng`,en:`eng`,english:`eng`,latin:`latin`,deu:`latin`,de:`latin`,fra:`latin`,fr:`latin`,ita:`latin`,it:`latin`,por:`latin`,pt:`latin`,spa:`latin`,es:`latin`,jpn:`jpn`,ja:`jpn`,japan:`jpn`,chi_sim:`chi_sim`,zh:`chi_sim`,"zh-cn":`chi_sim`,"zh-hans":`chi_sim`,chi_tra:`chi_tra`,ch:`chi_tra`,"zh-tw":`chi_tra`,"zh-hant":`chi_tra`,rus:`rus`,ru:`rus`,ara:`ara`,ar:`ara`},R=({language:e})=>{let t=Te[e.trim().toLowerCase()];if(!t)throw Error(v.OCR_LANGUAGE_UNSUPPORTED);return t},Ee={eng:`tiny`,latin:`tiny`,jpn:`japanese`,chi_sim:`chinese-simplified`,chi_tra:`chinese-traditional`,rus:`cyrillic`,ara:`arabic`},z=({language:e,engine:t=`auto`})=>{let n=R({language:e}),r=we[t===`auto`?Ee[n]:t];if(!r)throw Error(v.OCR_MODEL_UNSUPPORTED);return r},De=({language:e,engine:t})=>{let n=z({environment:`browser`,language:e,engine:t});return[n.detection,n.recognition,n.dictionary]},Oe=({adapter:e,environment:t})=>{let n=new Map,r=async r=>{if(r.environment!==t)throw Error(v.OCR_ENVIRONMENT_MISMATCH);let i=z(r),a=n.get(i.id);a||(a=Ce({adapter:e,model:i}),n.set(i.id,a));try{return await a}catch(e){throw n.get(i.id)===a&&n.delete(i.id),e}};return{getOcr:r,ocr:async({image:e,language:n=`eng`,engine:i})=>await(await r({environment:t,language:n,engine:i})).recognize({image:e})}},ke=async({cache:e,key:t,load:n})=>{let r=e.get(t);r||(r=n(),e.set(t,r));try{return await r}catch(n){throw e.get(t)===r&&e.delete(t),n}},Ae=new Map,{getOcr:je,ocr:Me}=Oe({adapter:{decode:async e=>{if(!(e instanceof Blob)&&!(e instanceof Uint8Array))return e;let t=e instanceof Uint8Array?new Blob([e]):e,n=await l.createImageBitmap(t);try{return m({frame:n})}finally{n.close()}},load:async e=>await ke({cache:Ae,key:e,load:async()=>{try{let t=await fetch(c({filename:e}));if(!t.ok)throw Error(v.MODEL_LOAD_FAILED);return new Uint8Array(await t.arrayBuffer())}catch(e){throw Error(v.MODEL_LOAD_FAILED,{cause:e})}}}),session:async e=>await a({filename:e}),runtime:s},environment:`browser`}),Ne=.24,Pe=.7,Fe=.16,Ie=({data:e,height:t,text:n,width:r})=>{let i=new Uint8Array(r*t);for(let t=0;t<i.length;t+=1){let n=t*4;i[t]=Math.round((e[n]??0)*.299+(e[n+1]??0)*.587+(e[n+2]??0)*.114)}let a=[];for(let e=0;e<t;e+=1)for(let n=0;n<r;n+=1){let o=e*r+n,s=i[o]??0;n+1<r&&a.push(s>=(i[o+1]??0)),e+1<t&&a.push(s>=(i[o+r]??0))}let o=new Uint8Array(Math.ceil(a.length/8));for(let[e,t]of a.entries())t&&(o[Math.floor(e/8)]|=1<<e%8);let s=[];for(let e=0;e<8;e+=1)for(let n=0;n<8;n+=1){let a=0,o=0;for(let s=Math.floor(e*t/8);s<Math.floor((e+1)*t/8);s+=1)for(let e=Math.floor(n*r/8);e<Math.floor((n+1)*r/8);e+=1)a+=i[s*r+e]??0,o+=1;s.push(o?a/o:0)}let c=s.reduce((e,t)=>e+t,0)/s.length,l=new Uint8Array(Math.ceil(s.length/8));for(let[e,t]of s.entries())t>=c&&(l[Math.floor(e/8)]|=1<<e%8);return{edgeHash:o,appearanceHash:l,textTokens:[...new Set(n.toUpperCase().normalize(`NFKC`).split(/[^\p{L}\d]+/u).filter(e=>e.length>=3))]}},Le=({value:e})=>{let t=0,n=e;for(;n;)t+=n&1,n>>>=1;return t},B=({front:e,current:t})=>{if(!e||!t||e.edgeHash.length!==t.edgeHash.length||e.appearanceHash.length!==t.appearanceHash.length)return{distinct:!1,imageDistance:null,textOverlap:null};let n=e.edgeHash.reduce((e,n,r)=>e+Le({value:n^(t.edgeHash[r]??0)}),0)/(e.edgeHash.length*8),r=e.appearanceHash.reduce((e,n,r)=>e+Le({value:n^(t.appearanceHash[r]??0)}),0)/(e.appearanceHash.length*8),i=t.textTokens.filter(t=>e.textTokens.includes(t)).length,a=Math.min(e.textTokens.length,t.textTokens.length),o=e.textTokens.length>=3&&t.textTokens.length>=3?i/a:null;return{distinct:n>=Ne&&r>=Fe&&(o===null||o<Pe),imageDistance:n,textOverlap:o}},Re=({text:e})=>{let t=e.toUpperCase().normalize(`NFKC`).split(`
7
+ `).map(e=>e.replace(/\s+/g,``)),n=t.findIndex(e=>e.startsWith(`P<`)&&e.length>=44&&(e.match(/</g)||[]).length>=2);if(n>=0&&t.slice(n+1).find(e=>/^[A-Z0-9<]{44}$/u.test(e)))return!0;let r=t.findIndex(e=>/^[A-Z0-9]<[A-Z]{3}/u.test(e)&&e.length>=30);return r<0?!1:t.slice(r+1).filter(e=>/^[A-Z0-9<]{30}$/u.test(e)).length>=2},ze={A:`AUT`,B:`BEL`,BG:`BGR`,CY:`CYP`,CZ:`CZE`,D:`DEU`,DK:`DNK`,E:`ESP`,EST:`EST`,F:`FRA`,FIN:`FIN`,GR:`GRC`,H:`HUN`,HR:`HRV`,I:`ITA`,IRL:`IRL`,L:`LUX`,LT:`LTU`,LV:`LVA`,M:`MLT`,NL:`NLD`,P:`PRT`,PL:`POL`,RO:`ROU`,S:`SWE`,SK:`SVK`,SLO:`SVN`},Be=({line:e,start:t,end:n})=>{let r=[],i=0;for(let a of e.words){let o=e.text.indexOf(a.text,i);if(o<0||!a.text.length)continue;i=o+a.text.length;let s=Math.max(t,o),c=Math.min(n,i);c<=s||r.push({...a.box,x:a.box.x+a.box.width*(s-o)/a.text.length,width:a.box.width*(c-s)/a.text.length})}if(!r.length)return{...e.box,x:e.box.x+e.box.width*t/e.text.length,width:e.box.width*(n-t)/e.text.length};let a=Math.min(...r.map(e=>e.x)),o=Math.min(...r.map(e=>e.y));return{x:a,y:o,width:Math.max(...r.map(e=>e.x+e.width))-a,height:Math.max(...r.map(e=>e.y+e.height))-o}},Ve=({line:e})=>{let t=e.text;if(!t.trim()||e.confidence!==null&&e.confidence<=0)return[];if(/^\s*\d{1,2}[./-]\d{1,2}[./-]\d{2,4}\s*$/u.test(t))return[{text:t.trim(),box:e.box,label:null}];let n=[...t.matchAll(/(?:^|\s)(4[a-d]|1[0-4]|[1-9])(?:[.:)]\s*|\s+|$|(?=\d{1,2}[./-]\d))/giu)];if(!n.length)return[{text:t,box:e.box,label:null}];let r=[],i=n[0].index;i>0&&r.push({text:t.slice(0,i).trim(),box:Be({line:e,start:0,end:i}),label:null});for(let[i,a]of n.entries()){let o=a.index+a[0].indexOf(a[1]),s=n[i+1]?.index??t.length,c=t.slice(a.index+a[0].length,s).trim(),l=Be({line:e,start:o,end:s});r.push({text:c,box:l,label:a[1].toLowerCase()})}return r},V=({label:e,fragments:t})=>{let n=t.filter(t=>t.label===e);if(n.length!==1)return null;let r=n[0],i=r.box.height,a=r.text?[r]:[],o=t.filter(e=>e.label&&e!==r);for(let e of t){if(e.label||!e.text)continue;let t=e.box.y-r.box.y,n=Math.abs(t)<Math.max(i,e.box.height)*.5,s=t>=i*.5&&t<=i*2.5;(n||s)&&(e.box.x<r.box.x-i*.5||n&&r.text||o.some(t=>{let n=Math.abs(t.box.y-r.box.y)<i*.5&&t.box.x>r.box.x&&e.box.x>=t.box.x-i*.25,a=t.box.y>r.box.y+i*.5&&t.box.y<=e.box.y+e.box.height*.5&&Math.abs(t.box.x-r.box.x)<i*3;return n||a})||o.some(n=>{let a=e.box.y-n.box.y,o=a>=-i*.5&&a<=i*2.5&&e.box.x>=n.box.x-i*.5,s=Math.abs(t)+Math.abs(e.box.x-r.box.x),c=Math.abs(a)+Math.abs(e.box.x-n.box.x);return o&&c<=s})||a.push(e))}return a.sort((e,t)=>Math.abs(e.box.y-t.box.y)<i*.5?e.box.x-t.box.x:e.box.y-t.box.y),a.map(e=>e.text).join(` `).trim()||null},H=({text:e,allowTwoDigitYear:t=!1})=>{if(!e)return null;let n=e.match(/^(?:(\d{1,2})([./-])(\d{1,2})\2(\d{2,4})|(\d{4})-(\d{2})-(\d{2}))$/u);if(!n)return null;let r=n[4]??n[5],i=Number(n[3]??n[6]),a=Number(n[1]??n[7]),o=Number(r);if(r.length===2){if(!t)return null;let e=new Date,n=e.getUTCFullYear(),r=e.getUTCMonth()+1,s=e.getUTCDate(),c=[1900+o,2e3+o].filter(e=>{let t=n-e-+(r<i||r===i&&s<a);return t>=16&&t<=100});if(c.length!==1)return null;o=c[0]}return o<1e3||i<1||i>12||a<1||a>new Date(Date.UTC(o,i,0)).getUTCDate()?null:`${o}-${String(i).padStart(2,`0`)}-${String(a).padStart(2,`0`)}`},He=({ocr:e,image:t})=>{let n=new Set;for(let i of e.lines)for(let e of i.words.length?i.words:[i]){let i=ze[e.text.trim().toUpperCase()],{x:a,y:o,width:s,height:c}=e.box;if(e.confidence!==null&&e.confidence<=0||!i||a<0||o<0||a+s>t.width*.3||o+c>t.height*.35)continue;let l=Math.max(s,c);r({...t,xStart:Math.max(0,a-l)/t.width,xEnd:Math.min(t.width,a+s+l)/t.width,yStart:Math.max(0,o-l)/t.height,yEnd:Math.min(t.height,o+c+l)/t.height,predicate:(e,t,n)=>n>45&&n>e*1.08&&n>t*1.04})>=.15&&n.add(i)}return n.size===1?[...n][0]:null},U=({ocr:e,image:t})=>{if(o(e))return null;let n=e.lines.flatMap(e=>Ve({line:e})),r=new Set(n.map(e=>e.label));if(!(r.has(`1`)||r.has(`2`))||![`3`,`4a`,`4b`,`5`].some(e=>r.has(e)))return null;let i=V({label:`1`,fragments:n}),a=V({label:`2`,fragments:n}),s=i&&/\p{L}/u.test(i)?i:null,c=a&&/\p{L}/u.test(a)?a:null,l=V({label:`3`,fragments:n})?.match(/^(\d{1,2}[./-]\d{1,2}[./-]\d{2,4}|\d{4}-\d{2}-\d{2})(?:\s+(.+))?$/u),u=H({allowTwoDigitYear:!0,text:l?l[1]:null}),d=l&&l[2]?.trim()||null,f=H({text:V({label:`4a`,fragments:n})}),p=H({text:V({label:`4b`,fragments:n})}),m=V({label:`4c`,fragments:n}),h=V({label:`5`,fragments:n}),g=He({ocr:e,image:t});return[s,c,u,d,f,p,m,h,g].some(Boolean)?O.parse({document:{source:`OCR`,type:`DRV`,issuing_country:g,issuing_authority:m,number:h,issue_date:f,expiry_date:p,optional_data:null},holder:{first_name:c,last_name:s,middle_name:null,birth_date:u,birth_place:d,sex:null,nationality:null,personal_number:null},address:null,raw_data:{mrz_lines:[],aamva_version:null}}):null},W=null,Ue=()=>globalThis.window===void 0?`zxing-wasm/reader`:c({filename:`zxing-wasm/reader/index.js`}),We=async()=>{let e=await import(Ue());return globalThis.window!==void 0&&e.setZXingModuleOverrides({locateFile:e=>c({filename:`zxing-wasm/reader/${e}`})}),e},Ge=async()=>{W??=We();try{return await W}catch(e){throw W=null,e}},Ke=async()=>{await(await Ge()).prepareZXingModule({fireImmediately:!0})},qe=async({image:e})=>{let t=await(await Ge()).readBarcodes(e,{formats:[`PDF417`],tryHarder:!0});for(let e of t)try{let t=f(e.text);return{type:`aamva`,code:e.text,payload:t}}catch{}return null},Je=({runtime:t,detector:r,alignment:i,text:a,readImage:o})=>{let s=async({image:e,language:s,engine:c,scanBarcodes:l=!1})=>{let u=e instanceof Blob?e:new Blob([e]),f=await t.createImageBitmap(u);try{let e=await r.analyzeDocument({frame:f});if(!e.detection)throw Error(v.DOCUMENT_NOT_FOUND);let u=await i.orientDocumentFrame({frame:f,polygon:e.detection.polygon,orientation:e.detection.orientation});if(!u)throw Error(v.IMAGE_PROCESSING_FAILED);try{let r=d({image:o({frame:f}),polygon:e.detection.polygon,sourceOrientation:u.orientation.rotation}),i=await a.readRectifiedText({frame:u.frame,language:s,engine:c,image:r});if(!i)throw Error(v.DOCUMENT_TEXT_NOT_READABLE);let p=o({frame:u.frame}),m=null;if(l){let e=t.createImageData(p.width,p.height);e.data.set(p.data),m=await qe({image:e})}return{ocr:i,codes:[n({result:i}),m].filter(e=>e!==null),pixels:p,signature:Ie({...o({frame:u.frame,width:32,height:32}),text:i.text}),blurry:e.isBlurry}}finally{u.frame.close()}}finally{f.close()}};return{classifyDocument:async({document_front:t,document_back:n,language:r,engine:i})=>{let a=await s({image:t,language:r,engine:i}),o=p({image:a.pixels,text:a.ocr.text,codes:a.codes});if(!o)throw Error(v.DOCUMENT_NOT_RECOGNIZED);let c=o.europeanDrivingLicense?U({ocr:a.ocr,image:a.pixels}):null,l=e({document:o.document})&&n?await s({image:n,language:o.europeanDrivingLicense?`latin`:r,engine:o.europeanDrivingLicense?`tiny`:i,scanBarcodes:!0}):null,d=u({classification:{...o,identity:c},front:a,back:l}),f=[...d.reasons],m=l?l.blurry:!1;return(a.blurry||m)&&f.push(v.DOCUMENT_BLURRY),l&&!B({front:a.signature,current:l.signature}).distinct&&f.push(v.DOCUMENT_BACK_NOT_DISTINCT),{identity:c,...o,...d,reasons:f,valid:f.length===0,document_front:a.ocr,document_back:l?l.ocr:null}},detectDocument:async({image:e,language:t})=>{let n=await s({image:e,language:t,scanBarcodes:!0}),r=p({image:n.pixels,text:n.ocr.text,codes:n.codes});if(!r)throw Error(v.DOCUMENT_NOT_RECOGNIZED);let i=n.codes.find(e=>e.type===`mrz`),a=n.codes.find(e=>e.type===`aamva`),o=!!a||r.document===`id`&&!!i;return{identity:!o&&r.europeanDrivingLicense?U({ocr:n.ocr,image:n.pixels}):null,document_type:r.document===`driving_license`?`drv`:r.document,document_side:o?`back`:`front`,mrz_code:i?i.code:null,ammva_code:a?a.code:null}},extractDocumentCodes:async({images:e})=>{let t=[];for(let n of e){let e=await s({image:n,scanBarcodes:!0});t.push(...e.codes)}return[...new Map(t.map(e=>[`${e.type}:${e.code}`,e])).values()]}}},G=8,Ye=.16,Xe=({x:e,y:t,width:n,height:r})=>{let i=e/n,a=t/r;return i<.2||i>=.8||a<.2||a>=.8},Ze=({value:e})=>{let t=0,n=e;for(;n;)t+=n&1,n>>>=1;return t},Qe=({image:e})=>{let t=[];for(let n=0;n<G;n+=1)for(let r=0;r<G;r+=1){let i=0,a=0,o=Math.floor(n*e.height/G),s=Math.floor((n+1)*e.height/G),c=Math.floor(r*e.width/G),l=Math.floor((r+1)*e.width/G);for(let t=o;t<s;t+=1)for(let n=c;n<l;n+=1){if(!Xe({height:e.height,width:e.width,x:n,y:t}))continue;let r=(t*e.width+n)*4;i+=(e.data[r]??0)*.299+(e.data[r+1]??0)*.587+(e.data[r+2]??0)*.114,a+=1}t.push(a?i/a:0)}let n=t.reduce((e,t)=>e+t,0)/t.length,r=new Uint8Array(Math.ceil(t.length/8));for(let[e,i]of t.entries())i>=n&&(r[Math.floor(e/8)]|=1<<e%8);return{appearanceHash:r}},$e=({first:e,second:t})=>{if(e.appearanceHash.length!==t.appearanceHash.length)return{distance:1,matched:!1};let n=e.appearanceHash.reduce((e,n,r)=>e+Ze({value:n^(t.appearanceHash[r]??0)}),0)/(e.appearanceHash.length*8);return{distance:n,matched:n<=Ye}},et=({candidate:e,identity:t})=>[{missing:!t?.holder.last_name,pattern:/^\s*1[.:)]\s+\p{L}/u},{missing:!t?.holder.first_name,pattern:/^\s*2[.:)]\s+\p{L}/u},{missing:!t?.holder.birth_date,pattern:/^\s*3[.:)]\s+\d{1,2}[./-]\d{1,2}[./-]\d{2,4}/u},{missing:!t?.document.number,pattern:/^\s*5[.:)]\s+[A-Z0-9]/u}].flatMap(({missing:t,pattern:n})=>{if(!t)return[];let r=e.lines.find(e=>n.test(e.text));return r?[r]:[]}),tt=({runtime:e,orientDocumentFrame:t,getOcr:r})=>{let i=`auto`,a=F({runtime:e}),o=async({engine:t=i,language:n=`eng`}={})=>{await r({environment:e.environment,engine:t,language:n})},s=async({classificationImage:t,engine:o=i,frame:s,language:c,image:l})=>{if(s.width<200||s.height<100)return null;let u=l??d({image:a({frame:s}),polygon:[{x:0,y:0},{x:s.width,y:0},{x:s.width,y:s.height},{x:0,y:s.height}]}),f=await(await r({environment:e.environment,engine:`tiny`,language:`latin`})).recognize({image:u}),m=n({result:f}),h=t??a({frame:s}),g=p({image:h,text:f.text,codes:m?[m]:[]}),_=g&&(g.document===`passport`||g.europeanDrivingLicense);if(g?.europeanDrivingLicense){let t=U({ocr:f,image:h});if(!D({identity:t})){let n=await(await r({environment:e.environment,engine:`small`,language:`latin`})).recognize({image:u}),i=U({ocr:n,image:h}),a=p({image:h,text:n.text,codes:[]});if(a?.europeanDrivingLicense&&D({identity:i}))f=n;else if(a?.europeanDrivingLicense){let e=et({candidate:n,identity:t});if(e.length){let t=[...f.lines,...e];f={...f,lines:t,text:t.map(e=>e.text).join(`
8
+ `)}}}}}else if(!_){let t=R({language:c??`eng`}),n=await r({environment:e.environment,engine:o,language:t});n.model!==`tiny`&&(f=await n.recognize({image:u}))}let v=s.width/f.width,y=s.height/f.height,b=({x:e,y:t,width:n,height:r})=>({x:e*v,y:t*y,width:n*v,height:r*y});return{...f,width:s.width,height:s.height,lines:f.lines.map(e=>({...e,box:b(e.box),words:e.words.map(e=>({...e,box:b(e.box)}))}))}},c=async e=>await s(e)??{height:e.frame.height,lines:[],text:``,width:e.frame.width};return{loadTextDetector:o,readRectifiedText:s,detectRectifiedText:c,detectDocumentText:async({engine:e=i,frame:n,language:r,polygon:a})=>{let o=await t({frame:n,polygon:a});if(!o)return{height:0,lines:[],rotation:0,text:``,width:0};try{return{...await c({engine:e,frame:o.frame,language:r}),rotation:o.orientation.rotation}}finally{o.frame.close()}}}},nt=({runtime:e,documentAlignment:r,rectifiedDocumentFace:a,orientDocumentFrame:o,restoreRectifiedFace:s,analyzeDocument:c,faceDetection:l,faceMatch:f,textDetection:m})=>{let h=F({runtime:e}),_=({frame:n,text:r})=>{let i=e.createCanvas(32,32),a=i.getContext(`2d`,{willReadFrequently:!0});if(!a)throw Error(v.IMAGE_PROCESSING_FAILED);a.drawImage(n,0,0,i.width,i.height);let{data:o}=a.getImageData(0,0,i.width,i.height);return t({canvas:i}),Ie({data:o,height:32,text:r,width:32})},y=({current:e,front:t})=>{let n=B({current:e.signature,front:t}),r=[],i=e.signature?.textTokens.length??0,a=Re({text:e.text.text})||e.text.lines.length>=2&&i>=2;return e.detection||r.push(v.DOCUMENT_NOT_FOUND),e.documentAnalysis.isBlurry&&r.push(v.DOCUMENT_BLURRY),e.hasPictureFace&&r.push(v.DOCUMENT_BACK_CONTAINS_FACE),a||r.push(v.DOCUMENT_TEXT_NOT_READABLE),n.distinct||r.push(v.DOCUMENT_BACK_NOT_DISTINCT),{distinct:n.distinct,imageDistance:n.imageDistance,reasons:r,textOverlap:n.textOverlap,valid:r.length===0}},b=({alignment:e,detection:t,documentAnalysis:n,faceContained:r,requiresFace:i,text:a})=>{let o=[];return t||o.push(v.DOCUMENT_NOT_FOUND),n.isBlurry&&o.push(v.DOCUMENT_BLURRY),i&&!r&&o.push(v.DOCUMENT_FACE_NOT_CONTAINED),(!a.text||a.lines.length<2)&&o.push(v.DOCUMENT_TEXT_NOT_READABLE),!i||e.faceAreaValid&&e.faceDimensionsValid||o.push(v.DOCUMENT_FACE_GEOMETRY_INVALID),i&&(e.faceAdjacentTextLineCount<2||!e.textParallel||e.textSide!==`right`)&&o.push(v.DOCUMENT_TEXT_ALIGNMENT_INVALID),o},x=async({classification:e,codes:t,ocr:n,options:i,documentAnalysis:o,document:c,text:u,prepareForMatch:d})=>{let p=o.detection,m=i.requiresFace??!0,h={boundingRect:{height:c.height,width:c.width,x:0,y:0},polygon:[{x:0,y:0},{x:c.width,y:0},{x:c.width,y:c.height},{x:0,y:c.height}]},g=m?await l.detectDocumentFaces({detection:h,frame:c.frame}):{faces:[],pictureFaces:[],hasPictureFace:await l.detectDocumentFacePresence({detection:h,frame:c.frame})},y=g.pictureFaces.map(e=>s({document:c,face:e})),x=_({frame:c.frame,text:u.text}),S=t.find(e=>e.type===`mrz`)??null,C=null;for(let h of g.faces.length?g.faces:[null]){let _=h?s({document:c,face:h}):null,w=h?a({face:h}):null,T=m&&p?l.faceIsInsideDocument({detection:p,face:_})&&y.every(e=>l.faceIsInsideDocument({detection:p,face:e})):!1,E=r({documentSize:{height:u.height,width:u.width},face:w,lines:u.lines,maxAngleDifference:i.maxDocumentTextAngleDifference,maxFaceAreaRatio:i.maxDocumentFaceAreaRatio,maxFaceHeightRatio:i.maxDocumentFaceHeightRatio,maxFaceWidthRatio:i.maxDocumentFaceWidthRatio,minFaceAreaRatio:i.minDocumentFaceAreaRatio,minFaceHeightRatio:i.minDocumentFaceHeightRatio,minFaceWidthRatio:i.minDocumentFaceWidthRatio}),O=b({alignment:E,detection:p,documentAnalysis:o,faceContained:T,requiresFace:m,text:u});m&&!e&&O.push(v.DOCUMENT_NOT_RECOGNIZED),e?.europeanDrivingLicense&&!D({identity:e.identity})&&O.push(v.DOCUMENT_VALIDATION_FAILED);let k=O.length===0,A=null,j=null;if(m&&k&&h){let e=f.prepareFace({alignment:i.alignment??`eyes-nose-mouth`,face:h,frame:c.frame});if(!e)k=!1,O.push(v.FACE_NOT_USABLE);else if(d){let t=await f.preparedFaceArtifacts({face:e});A=t?.embeddings??null,j=t?.images??null,t||(k=!1,O.push(v.INVALID_MODEL_OUTPUT))}}let M={identity:e?e.identity:null,orientation:c.orientation,ocr:n,mrz:S,alignment:E,detection:p,documentAnalysis:o,documentKind:e?e.document:null,europeanDrivingLicense:e?e.europeanDrivingLicense:!1,codes:t,documentToSource:c.toSource,embeddings:A,images:j,face:_,faceContained:T,hasPictureFace:g.hasPictureFace??y.length>0,failureReasons:O,pictureFaces:y,signature:x,text:u,valid:k};if(M.valid)return M;C??=M}if(!C)throw Error(v.INTERNAL_ERROR);return C},S=async({frame:t,options:a,documentAnalysis:s,prepareForMatch:c=!1})=>{let l=s.detection;if(!l){let e={height:0,lines:[],text:``,width:0},t=r({documentSize:{height:e.height,width:e.width},face:null,lines:e.lines,maxAngleDifference:a.maxDocumentTextAngleDifference,maxFaceAreaRatio:a.maxDocumentFaceAreaRatio,maxFaceHeightRatio:a.maxDocumentFaceHeightRatio,maxFaceWidthRatio:a.maxDocumentFaceWidthRatio,minFaceAreaRatio:a.minDocumentFaceAreaRatio,minFaceHeightRatio:a.minDocumentFaceHeightRatio,minFaceWidthRatio:a.minDocumentFaceWidthRatio});return{identity:null,orientation:null,ocr:null,mrz:null,codes:[],europeanDrivingLicense:!1,alignment:t,detection:l,documentAnalysis:s,documentKind:null,documentToSource:null,embeddings:null,face:null,faceContained:!1,failureReasons:b({alignment:t,detection:l,documentAnalysis:s,faceContained:!1,requiresFace:a.requiresFace??!0,text:e}),images:null,pictureFaces:[],hasPictureFace:!1,signature:null,text:e,valid:!1}}let u=await o({frame:t,polygon:l.polygon,orientation:l.orientation});if(!u)throw Error(v.IMAGE_PROCESSING_FAILED);try{let r=performance.now(),o=d({image:h({frame:t}),polygon:l.polygon,sourceOrientation:u.orientation.rotation}),f=a.requiresFace===!1?`back`:`front`;i({category:`stages`,key:`ocr.prepare.${f}`,duration:performance.now()-r});let _=h({frame:u.frame}),v=await m.readRectifiedText({classificationImage:_,engine:a.ocrEngine,frame:u.frame,language:a.language,image:o}),y=v??{height:u.height,lines:[],text:``,width:u.width},b=v?n({result:v}):null,S=null;if(a.requiresFace===!1){let t=e.createImageData(_.width,_.height);t.data.set(_.data),S=await g({key:`barcode.back`,operation:()=>qe({image:t})})}let C=[b,S].filter(e=>e!==null),w=p({image:_,text:y.text,codes:C}),T=a.requiresFace!==!1&&w?.europeanDrivingLicense&&v?U({ocr:v,image:_}):null,E=w?{...w,identity:T}:null;return await x({ocr:v,classification:E,codes:C,options:a,documentAnalysis:s,document:u,prepareForMatch:c,text:y})}finally{u.frame.close()}},C=async({frame:e,options:t,prepareForMatch:n=!1})=>{let r=await c({frame:e,minDocumentBoxRatio:t.minDocumentBoxRatio});return await S({frame:e,options:t,documentAnalysis:r,prepareForMatch:n})},w=({analysis:e,isBack:t,front:n})=>{if(!e.ocr)return[v.DOCUMENT_TEXT_NOT_READABLE];if(t&&!n)return[v.CAPTURES_INCOMPLETE];if(!t&&!e.documentKind)return[v.DOCUMENT_NOT_RECOGNIZED];let r={ocr:e.ocr,codes:e.codes},i=t&&n?n:{document:e.documentKind,europeanDrivingLicense:e.europeanDrivingLicense,identity:e.identity};return u({classification:i,front:t&&n?n:r,back:t?r:null}).reasons.filter(e=>t||e!==v.DOCUMENT_BACK_REQUIRED)};return{validateDocumentBack:y,analyzeDocumentFrame:C,hasValidDocumentSideData:e=>w(e).length===0,documentSideFailureReasons:w}},rt=({runtime:e,document:n,readImage:r})=>async({image:i,timings:a})=>{let o=await e.createImageBitmap(new Blob([i]));try{let i=performance.now(),s=await n.analyzeDocument({frame:o});if(a&&(a.documentBoxDetectionMs=performance.now()-i),!s.detection)throw Error(v.DOCUMENT_NOT_FOUND);let{polygon:c,orientation:l}=s.detection,u=d({image:r({frame:o}),polygon:c,sourceOrientation:l?.rotation}),f=e.createCanvas(u.width,u.height);try{let t=f.getContext(`2d`);if(!t)throw Error(v.IMAGE_PROCESSING_FAILED);let n=e.createImageData(u.width,u.height);n.data.set(u.data),t.putImageData(n,0,0);let r=await f.convertToBlob({type:`image/png`});return new Uint8Array(await r.arrayBuffer())}finally{t({canvas:f})}}finally{o.close()}},{alignment:it,document:K,face:q,text:at,match:J,flow:ot,classify:st,prepareOcrImage:ct,warmup:lt}=(({runtime:e,getOcr:t,faceMatcher:n})=>{let r=F({runtime:e}),i=w({runtime:e}),a=k({runtime:e}),o=M({runtime:e,imageFromImageBitmap:r}),s=tt({runtime:e,getOcr:t,...i}),c=S({runtime:e,...i,...a,...o,faceDetection:o,faceMatcher:n});return{alignment:i,document:a,face:o,text:s,match:c,flow:nt({runtime:e,...i,...a,faceDetection:o,faceMatch:c,textDetection:s}),classify:Je({runtime:e,detector:a,alignment:i,text:s,readImage:r}),prepareOcrImage:rt({runtime:e,document:a,readImage:r}),warmup:async()=>{await Promise.all([o.loadFaceDetector({faceDetector:`standard`}),c.loadFaceMatch(),a.loadDocumentBoxDetector(),a.loadDocumentOrientationDetector(),s.loadTextDetector({engine:`tiny`,language:`latin`}),Ke()])}}})({runtime:l,getOcr:je}),{classifyDocument:ut,detectDocument:dt,extractDocumentCodes:ft}=st,{detectDocumentOrientation:pt,loadDocumentOrientationDetector:mt}=K,ht=[`faceStraight`,`faceUp`,`faceDown`,`faceLeft`,`faceRight`],Y=[`faceStraight`,`faceUp`,`faceLeft`,`faceRight`],X=[...ht,`faceSmile`,`faceWinkLeft`,`faceTiltLeft`,`faceTiltRight`];y(X);var gt={faceStraight:0,faceLeft:1,faceRight:1,faceUp:2,faceDown:2,faceTiltLeft:3,faceTiltRight:3,faceSmile:4,faceWinkLeft:5},Z={faceStraight:`face_straight`,faceUp:`face_up`,faceDown:`face_down`,faceLeft:`face_left`,faceRight:`face_right`,faceSmile:`face_smile`,faceWinkLeft:`face_wink_left`,faceTiltLeft:`face_tilt_left`,faceTiltRight:`face_tilt_right`};y(Z),ht.map(e=>Z[e]),Y.map(e=>Z[e]);var _t=async()=>{let e=await fetch(ne({filename:`faceMeshLines.json`}));if(!e.ok)throw Error(I.INVALID_SERVICE_RESPONSE);return await e.json()},vt=async()=>{await _t()},{transformPoint:yt}=it,bt=[`tessellation`,`contours`,`faceOval`,`lips`,`leftEye`,`rightEye`,`leftEyebrow`,`rightEyebrow`,`leftIris`,`rightIris`],xt=async({color:e,context:t,result:n})=>{let r=await _t();t.beginPath();for(let e of bt)for(let{start:i,end:a}of r[e]){let e=n.mesh.landmarks[i],r=n.mesh.landmarks[a];e&&r&&(t.moveTo(e.x,e.y),t.lineTo(r.x,r.y))}t.strokeStyle=e,t.lineWidth=1,t.stroke()},St=({backgroundColor:e,color:t,context:n,line:r,toSource:i})=>{if(!r.text)return;let{x:a,y:o,width:s,height:c}=r.box,l=[{x:a,y:o},{x:a+s,y:o},{x:a+s,y:o+c},{x:a,y:o+c}].map(e=>yt({homography:i,point:e})),u=l[0],d=l[1],f=l[3];if(!u||!d||!f)return;let p=Math.hypot(d.x-u.x,d.y-u.y),m=Math.hypot(f.x-u.x,f.y-u.y),h=Math.max(8,Math.min(16,m*.7)),g=Math.max(0,p-4),_=Math.atan2(d.y-u.y,d.x-u.x);n.beginPath(),n.moveTo(u.x,u.y);for(let e of l.slice(1))n.lineTo(e.x,e.y);n.closePath(),n.strokeStyle=t,n.lineWidth=1,n.stroke(),n.save(),n.clip(),n.translate(u.x+2,u.y+2),n.rotate(_),n.font=`${h}px sans-serif`,n.textBaseline=`top`,n.lineWidth=3,n.strokeStyle=e,n.strokeText(r.text,0,0,g),n.fillStyle=t,n.fillText(r.text,0,0,g),n.restore()},Ct=async({element:e,meshLineColor:t,overlayColor:n=`transparent`,result:r})=>{let i=e.getContext(`2d`);if(!i)throw Error(I.IMAGE_PROCESSING_FAILED);let a=r?.mesh.width??e.width,o=r?.mesh.height??e.height;e.width!==a&&(e.width=a),e.height!==o&&(e.height=o),ae({element:e}),n!==`transparent`&&(i.fillStyle=n,i.fillRect(0,0,a,o)),r&&await xt({color:t,context:i,result:r})},wt=async({documentFaceBoxColor:e,documentFaceMeshColor:t,documentBoxColor:n,element:r,detection:i,face:a,height:o,ocrLines:s=[],ocrToSource:c=null,overlayColor:l=`transparent`,textColor:u,width:d})=>{let f=r.getContext(`2d`);if(f&&d&&o){if(r.width!==d&&(r.width=d),r.height!==o&&(r.height=o),ae({element:r}),l!==`transparent`&&(f.fillStyle=l,f.fillRect(0,0,d,o)),i){f.strokeStyle=n,f.lineWidth=3,f.beginPath();for(let[e,t]of i.polygon.entries())e?f.lineTo(t.x,t.y):f.moveTo(t.x,t.y);f.closePath(),f.stroke()}if(a&&(f.strokeStyle=e,f.lineWidth=2,f.strokeRect(a.boundingRect.x,a.boundingRect.y,a.boundingRect.width,a.boundingRect.height),await xt({color:t,context:f,result:a})),c){let e=getComputedStyle(r).color;for(let t of s)St({backgroundColor:e,color:u,context:f,line:t,toSource:c})}}},Q={documentTargets:{front:`frameDocument`,back:`frameDocumentBack`,passport:`framePassport`},rejections:{FACE_NOT_DETECTED:`faceNotFound`,FACE_IN_POLYGON:`faceInPolygon`,FACE_TOO_SMALL:`faceTooSmall`,FACE_CENTER_MOVE_LEFT:`faceCenterMoveLeft`,FACE_CENTER_MOVE_RIGHT:`faceCenterMoveRight`,FACE_CENTER_MOVE_UP:`faceCenterMoveUp`,FACE_CENTER_MOVE_DOWN:`faceCenterMoveDown`,FACE_STABILITY_REQUIRED:`stayStill`,DOCUMENT_NOT_DETECTED:`documentNotDetected`,DOCUMENT_BOX_TOO_SMALL:`documentBoxTooSmall`,DOCUMENT_BOX_TOO_LARGE:`documentBoxTooLarge`,DOCUMENT_BOX_NEAR_EDGE:`documentBoxNearEdge`,DOCUMENT_BOX_TOUCHES_EDGES:`documentBoxTouchesEdges`,DOCUMENT_SHAPE_INVALID:`documentShapeInvalid`,DOCUMENT_NOT_SUPPORTED:`documentNotSupported`,DOCUMENT_BLURRY:`documentBlurry`,DOCUMENT_FRONT_FACE_NOT_DETECTED:`faceNotVisibleInDocument`,DOCUMENT_FRONT_FACE_NOT_CONTAINED:`faceNotVisibleInDocument`,DOCUMENT_FRONT_FACE_TOO_SMALL:`documentPhotoTooSmall`,DOCUMENT_FRONT_FACE_SIZE_INVALID:`documentAlignmentInvalid`,DOCUMENT_FRONT_LAYOUT_INVALID:`documentAlignmentInvalid`,DOCUMENT_TEXT_NOT_READABLE:`documentNotReadable`,DOCUMENT_NOT_RECOGNIZED:`invalidDocument`,DOCUMENT_CODE_NOT_READABLE:`passportMrzNotReadable`,DOCUMENT_BACK_HAS_FACE:`documentBackHasFace`,DOCUMENT_BACK_SAME_AS_FRONT:`documentBackSameAsFront`,DOCUMENT_STABILITY_REQUIRED:`holdDocumentStill`,DOCUMENT_VALIDATION_FAILED:`documentValidationFailed`}},Tt=({target:e})=>Q.documentTargets[e],Et=({code:e})=>e in Q.rejections?Q.rejections[e]:N({code:e}),{detectPictureFaces:Dt}=q,$={FACEKEY_LOWER_HEAD:`FACE_PITCH_LOOK_DOWN`,FACEKEY_LOWER_HEAD_LESS:`FACE_PITCH_LOWER_LESS`,FACEKEY_RAISE_HEAD:`FACE_PITCH_LOOK_UP`,FACEKEY_RAISE_HEAD_LESS:`FACE_PITCH_RAISE_LESS`,FACEKEY_TILT_HEAD_LEFT:`FACE_ROLL_TILT_LEFT`,FACEKEY_TILT_HEAD_LESS:`FACE_ROLL_TILT_LESS`,FACEKEY_TILT_HEAD_RIGHT:`FACE_ROLL_TILT_RIGHT`,FACEKEY_TURN_HEAD_LEFT:`FACE_YAW_TURN_LEFT`,FACEKEY_TURN_HEAD_LESS:`FACE_YAW_TURN_LESS`,FACEKEY_TURN_HEAD_RIGHT:`FACE_YAW_TURN_RIGHT`,FACEKEY_SMILE_REQUIRED:`FACE_SMILE_REQUIRED`,FACEKEY_WINK_LEFT_REQUIRED:`FACE_WINK_LEFT_REQUIRED`},Ot=({face:e,name:t})=>e.blendshapes[t]??0,kt=({face:e,frame:t})=>e.boundingRect.height/t.height<.4?`FACE_TOO_SMALL`:null,At=({face:e,pose:t,options:n})=>{let r=P({...e,pose:t,options:n});return r?$[r]:null},jt=({face:e,pose:t,options:n})=>At({face:e,pose:t,options:n})===null,Mt=async({capture:e,pose:t,options:n,poseOptions:r})=>{let i=await J.imageBitmap({blob:e});try{let e=await Dt(i),a=e.length===1?e[0]:null;if(!a||!jt({face:a,pose:t,options:r}))return null;let o=J.prepareFace({alignment:n.alignment,face:a,frame:i});return o?await J.preparedFaceArtifacts({face:o}):null}finally{i.close()}},{detectDocumentBox:Nt}=K,{detectFace:Pt}=q,Ft=({view:e,display:t,isActive:n,notifyCapturesChanged:r})=>{let i=e.ref,a=({state:e})=>e.faceSequence[e.poseIndex]??`faceStraight`,o=({face:e,frame:n})=>{let r=e.boundingRect.x+e.boundingRect.width/2,i=e.boundingRect.y+e.boundingRect.height/2,a=(t.cameraFacingMode.value===`user`?n.width-r:r)/n.width,o=i/n.height;return a<.4?`FACE_CENTER_MOVE_RIGHT`:a>.6?`FACE_CENTER_MOVE_LEFT`:o<.4?`FACE_CENTER_MOVE_DOWN`:o>.6?`FACE_CENTER_MOVE_UP`:null},s=async({frame:s,session:c,state:l,options:u})=>{let d=performance.now(),f=null,p=!1;try{f=await Pt(s);let e=f?await Nt(s):null;if(p=!!(f&&e&&h({face:f,polygon:e.polygon})),!n({flow:`face`,session:c,state:l}))return!1;if(u.showFaceOverlay&&await Ct({element:i.mesh,meshLineColor:u.faceMeshColor,overlayColor:u.faceOverlayColor,result:f}),!f){l.poseStableFrames=0;let e=a({state:l});return t.feedback.value={flow:`face`,code:`FACE_NOT_DETECTED`,pose:e},!1}if(p)return l.poseStableFrames=0,t.feedback.value={flow:`face`,code:`FACE_IN_POLYGON`,pose:a({state:l})},!1;let d=a({state:l}),m=kt({face:f,frame:s});if(m)return l.poseStableFrames=0,t.feedback.value={flow:`face`,code:m,pose:d},!1;let g=o({face:f,frame:s});if(g)return l.poseStableFrames=0,t.feedback.value={flow:`face`,code:g,pose:d},!1;let _={pitch:f.pitch,yaw:f.yaw,roll:f.roll},v=te({alignment:_,blendshapes:f.blendshapes,neutral:l.neutralPose,pose:d,options:u});l.guidanceCodeState=b({state:l.guidanceCodeState,code:v.code,requiredFrames:3}),t.guidance.value=v;let y=v.code?$[v.code]:null,S=l.guidanceCodeState.published?$[l.guidanceCodeState.published]:null,C=j({pose:d,corrective:S?Et({code:S}):null}).corrective,w=performance.now();if(l.correctiveState=E({label:C,now:w,state:l.correctiveState}),t.corrective.value=x({label:C,now:w,state:l.correctiveState}),y)return l.poseStableFrames=0,t.feedback.value={flow:`face`,code:S,pose:d},!1;if(d===`faceStraight`&&!l.neutralPose&&(l.neutralPose=_),l.poseStableFrames+=1,l.poseStableFrames<u.requiredFaceStableFrames)return t.feedback.value={flow:`face`,code:`FACE_STABILITY_REQUIRED`,pose:d},!1;t.feedback.value={flow:`face`,code:null,pose:d};let D=await re({frame:s}),O=await Mt({capture:D,pose:d,options:l.matchOptions,poseOptions:u});if(!n({flow:`face`,session:c,state:l}))return!1;if(!O)return l.poseStableFrames=0,t.feedback.value={flow:`face`,code:`FACE_STABILITY_REQUIRED`,pose:d},!1;let k=Qe({image:J.readImage({frame:s,width:32,height:32})}),M=l.previousPoseBackgroundSignature;if(M&&!$e({first:M,second:k}).matched)throw Error(I.POSE_BACKGROUND_MISMATCH);let N=l.faceEmbeddings.faceStraight;if(N&&T({first:N,second:O.embeddings})<=l.matchOptions.threshold)throw Error(I.POSE_IDENTITY_MISMATCH);let P=d;return l.captures[P]=D,l.preparedCaptures[P]=O.images,l.faceEmbeddings[P]=O.embeddings,l.previousPoseBackgroundSignature=k,r({state:l}),t.success.value=!0,await oe({milliseconds:400}),t.success.value=!1,n({flow:`face`,session:c,state:l})?(l.poseIndex+=1,l.poseStableFrames=0,l.guidanceCodeState=ee(),l.correctiveState=A(),t.corrective.value=null,t.progress.value={completed:l.poseIndex,total:l.faceSequence.length},l.poseIndex===l.faceSequence.length?(t.feedback.value=null,!0):(t.feedback.value={flow:`face`,pose:a({state:l}),code:null},!1)):!1}finally{n({flow:`face`,session:c,state:l})&&e.collectFaceDebug({face:f,faceInPolygon:p,processingTimeMilliseconds:performance.now()-d,state:l}),s.close()}};return{runFaceLoop:async({session:e,state:r,options:a})=>{for(;n({flow:`face`,session:e,state:r});){if(await ie({video:i.video}),!n({flow:`face`,session:e,state:r}))return;let o=await createImageBitmap(i.video);if(await s({frame:o,session:e,state:r,options:a})){r.flow=null,t.debug.value=[],t.guidance.value=null;return}}}}},It=({captures:e,state:t})=>t.faceSequence.every(n=>!!(e[n]&&t.preparedCaptures[n]&&t.faceEmbeddings[n])),Lt=({captures:e,state:t})=>{if(!It({captures:e,state:t}))throw Error(I.CAPTURES_INCOMPLETE);let n=[...t.faceSequence];return{faces:n.map(t=>e[t]).filter(e=>!!e),poses:n,embeddings:n.map(e=>t.faceEmbeddings[e]).filter(e=>!!e)}},Rt=({sequence:e})=>{let t=[...e];for(let e=t.length-1;e>0;--e){let n=Math.floor(Math.random()*(e+1));[t[e],t[n]]=[t[n],t[e]]}return t},zt=({sequence:e})=>[...e].sort((e,t)=>gt[e]-gt[t]),Bt=({poses:e,randomize:t})=>{let n=e===`all`?[...X]:e??Y;if(!n.length)throw Error(I.INVALID_POSES);let r=[...new Set(n)];if(r.length!==n.length||r.some(e=>!X.includes(e))||r[0]!==`faceStraight`||Y.some(e=>!r.includes(e)))throw Error(I.INVALID_POSES);let i=r.slice(1);return t?[`faceStraight`,...Rt({sequence:i})]:[`faceStraight`,...zt({sequence:i})]},Vt=()=>({activity:C(null),error:C(null),retry:C(null),feedback:C(null),guidance:C(null),corrective:C(null),progress:C({completed:0,total:0}),success:C(!1),cameraSize:C(null),cameraFacingMode:C(null),debug:C([]),debugEnabled:C(!1)});export{J as _,It as a,B as b,Et as c,Z as d,Y as f,mt as g,ot as h,Lt as i,wt as l,q as m,Ft as n,Bt as o,K as p,Ot as r,Tt as s,Vt as t,vt as u,at as v,De as x,Ke as y};
@@ -3,5 +3,3 @@ import type VoltomVerifyType from "../verify.js";
3
3
  declare global {
4
4
  var VoltomVerify: typeof VoltomVerifyType;
5
5
  }
6
-
7
- export {};
@@ -1,4 +1,4 @@
1
- export type Mode = "fast" | "hard";
1
+ export type Mode = "hard";
2
2
 
3
3
  export type Pose =
4
4
  | "faceStraight"
@@ -28,9 +28,7 @@ export type FaceDetectorName = "high" | "standard" | "low";
28
28
  export type VerificationCapability = "verifyHuman" | "verifyDocument" | "matchID" | "matchPicture";
29
29
 
30
30
  export type VerificationOperationOptions = {
31
- mode?: Mode;
32
31
  poses?: Pose[] | "all";
33
- posesCount?: number;
34
32
  randomizeFaceSequence?: boolean;
35
33
  showFaceOverlay?: boolean;
36
34
  showDocumentOverlay?: boolean;
@@ -43,7 +41,6 @@ export type VoltomOptions = {
43
41
  root?: HTMLElement;
44
42
  video?: HTMLVideoElement;
45
43
  ui?: boolean;
46
- mode?: Mode;
47
44
  language?: Language;
48
45
  ocrEngine?: OcrEngine;
49
46
  faceDetector?: FaceDetectorName;
@@ -51,7 +48,6 @@ export type VoltomOptions = {
51
48
  apiUrl?: string;
52
49
  threshold: number;
53
50
  poses?: Pose[] | "all";
54
- posesCount?: number;
55
51
  randomizeFaceSequence?: boolean;
56
52
  requiredFaceStableFrames: number;
57
53
  requiredDocumentStableFrames: number;
@@ -185,6 +181,7 @@ declare class VoltomVerify {
185
181
  verifyHuman(settings?: VerificationOperationOptions): Promise<VoltomVerificationResult>;
186
182
  verifyDocument(settings?: VerificationOperationOptions): Promise<VoltomVerificationResult>;
187
183
  matchID(settings?: VerificationOperationOptions): Promise<VoltomVerificationResult>;
184
+ /** Accepts images or PDFs up to 10 MB. PDFs use only page 1, rendered at up to 1200 pixels. */
188
185
  matchPicture(picture: Blob, settings?: VerificationOperationOptions): Promise<VoltomVerificationResult>;
189
186
  forgetHuman(): void;
190
187
  forgetDocument(): void;