@sekyro/web 0.1.0-rc.20 → 0.1.0-rc.22

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 (96) hide show
  1. package/CHANGELOG.md +58 -0
  2. package/README.md +12 -11
  3. package/dist/camera-trait-V4UAOPIQ.js +1 -0
  4. package/dist/{capture-constraints-B5omafmk.d.cts → capture-constraints-CVqpMNGA.d.cts} +7 -3
  5. package/dist/{capture-constraints-B5omafmk.d.ts → capture-constraints-CVqpMNGA.d.ts} +7 -3
  6. package/dist/{capture-session-doc-QA4DOFRF.js → capture-session-doc-YDUKUN3P.js} +1 -1
  7. package/dist/{capture-session-v3-CNL-GX11.d.cts → capture-session-v3-CkcuPKSD.d.ts} +90 -13
  8. package/dist/{capture-session-v3-DaBqN8fO.d.ts → capture-session-v3-TJL-0Muv.d.cts} +90 -13
  9. package/dist/chunk-2KTSNAVR.js +1 -0
  10. package/dist/chunk-2LDOXGY3.js +1 -0
  11. package/dist/chunk-32ELI5BZ.js +1 -0
  12. package/dist/chunk-33KKMPJ5.js +1 -0
  13. package/dist/chunk-53POX7U4.js +1 -0
  14. package/dist/chunk-7QZWBDI5.js +1 -0
  15. package/dist/chunk-7XT5YDSC.js +1 -0
  16. package/dist/chunk-BATJN3VQ.js +1 -0
  17. package/dist/chunk-CPUECYAJ.js +1 -0
  18. package/dist/chunk-FSSMUAKC.js +1 -0
  19. package/dist/{chunk-IG466TOP.js → chunk-HYGINGDC.js} +1 -1
  20. package/dist/chunk-LJYMZQY2.js +1 -0
  21. package/dist/chunk-PZYVSLPG.js +1 -0
  22. package/dist/chunk-RALQBQPT.js +1 -0
  23. package/dist/chunk-SX7TUC3V.js +1 -0
  24. package/dist/chunk-TJUM65FN.js +1 -0
  25. package/dist/chunk-TSA6GHUG.js +1 -0
  26. package/dist/chunk-VWGKUQ3C.js +1 -0
  27. package/dist/chunk-Z2BIZYZQ.js +1 -0
  28. package/dist/chunk-Z5D7SZUW.js +1 -0
  29. package/dist/client/index.cjs +1 -1
  30. package/dist/client/index.d.cts +3 -3
  31. package/dist/client/index.d.ts +3 -3
  32. package/dist/client/index.js +1 -1
  33. package/dist/clip-inspect-DLJXVKV6.js +1 -0
  34. package/dist/core/index.cjs +1 -1
  35. package/dist/core/index.d.cts +5 -5
  36. package/dist/core/index.d.ts +5 -5
  37. package/dist/core/index.js +1 -1
  38. package/dist/core/v3/detect-worker.cjs +1 -1
  39. package/dist/core/v3/detect-worker.d.cts +1 -1
  40. package/dist/core/v3/detect-worker.d.ts +1 -1
  41. package/dist/core/v3/detect-worker.js +1 -1
  42. package/dist/create-document-capture-K6EHRCWN.js +1 -0
  43. package/dist/create-portrait-capture-5VGYZUOK.js +1 -0
  44. package/dist/{create-verification-COpe2hxf.d.ts → create-verification-DnyHCSu6.d.cts} +216 -82
  45. package/dist/{create-verification-BBOUYpga.d.cts → create-verification-DoISHOqL.d.ts} +216 -82
  46. package/dist/{detect-worker-DclNxkZT.d.cts → detect-worker-CHqsPJoM.d.cts} +19 -2
  47. package/dist/{detect-worker-DclNxkZT.d.ts → detect-worker-CHqsPJoM.d.ts} +19 -2
  48. package/dist/{icao-gate-CEGvJR3q.d.ts → icao-gate-BFlSZYCZ.d.cts} +36 -4
  49. package/dist/icao-gate-T3BTOKFJ.js +1 -0
  50. package/dist/{icao-gate-l40OU6x1.d.cts → icao-gate-lZ_fHE7k.d.ts} +36 -4
  51. package/dist/{icao-policy-BgI1Y870.d.ts → icao-policy-BOcutYdD.d.ts} +3 -3
  52. package/dist/{icao-policy-C7fIdRzo.d.cts → icao-policy-JZH0UdmD.d.cts} +3 -3
  53. package/dist/icao-tuning-4ETMF53W.js +1 -0
  54. package/dist/index.cjs +1 -1
  55. package/dist/index.d.cts +11 -15
  56. package/dist/index.d.ts +11 -15
  57. package/dist/index.js +1 -1
  58. package/dist/internal/index.cjs +1 -1
  59. package/dist/internal/index.d.cts +53 -34
  60. package/dist/internal/index.d.ts +53 -34
  61. package/dist/internal/index.js +1 -1
  62. package/dist/plan-runner-3ZMV7SFQ.js +1 -0
  63. package/dist/popup/index.cjs +1 -1
  64. package/dist/popup/index.d.cts +3 -3
  65. package/dist/popup/index.d.ts +3 -3
  66. package/dist/popup/index.js +1 -1
  67. package/dist/{print-AYSCRSZB.js → print-SEWS3VHQ.js} +1 -1
  68. package/dist/{turnstile-FATNZ4AG.js → turnstile-2J3LUHCG.js} +1 -1
  69. package/dist/{types-Dpfg2cO8.d.cts → types-DwfyBTte.d.cts} +167 -79
  70. package/dist/{types-Dpfg2cO8.d.ts → types-DwfyBTte.d.ts} +167 -79
  71. package/package.json +1 -1
  72. package/sbom.cdx.json +10 -10
  73. package/dist/camera-trait-45MJTW4K.js +0 -1
  74. package/dist/chunk-5ZKQHFFW.js +0 -1
  75. package/dist/chunk-7ZCZY3ZP.js +0 -1
  76. package/dist/chunk-BPE5NSQ2.js +0 -1
  77. package/dist/chunk-CQ7SKLMC.js +0 -1
  78. package/dist/chunk-FGOVIGGL.js +0 -1
  79. package/dist/chunk-FUHDOEBP.js +0 -1
  80. package/dist/chunk-GT2ZLGF7.js +0 -1
  81. package/dist/chunk-KHR4U2SZ.js +0 -1
  82. package/dist/chunk-KZBBB5B2.js +0 -1
  83. package/dist/chunk-NJML6FMD.js +0 -1
  84. package/dist/chunk-O5WKNZ2C.js +0 -1
  85. package/dist/chunk-OKWG3PVH.js +0 -1
  86. package/dist/chunk-TQB3URP2.js +0 -1
  87. package/dist/chunk-U6S7SCBY.js +0 -1
  88. package/dist/chunk-U6TYL2IJ.js +0 -1
  89. package/dist/chunk-W2WD7PR2.js +0 -1
  90. package/dist/chunk-XCKE2MJL.js +0 -1
  91. package/dist/chunk-ZLWH4RBO.js +0 -1
  92. package/dist/create-document-capture-GJXBQMTC.js +0 -1
  93. package/dist/create-portrait-capture-MOS2D7CL.js +0 -1
  94. package/dist/icao-gate-PWBMKRGC.js +0 -1
  95. package/dist/icao-tuning-4GGVX6B4.js +0 -1
  96. package/dist/plan-runner-35655N4Z.js +0 -1
@@ -0,0 +1 @@
1
+ import{a as G,e as me,g as fe,m as he}from"./chunk-53POX7U4.js";import{b as ge}from"./chunk-33KKMPJ5.js";import{a as pe,d as ye}from"./chunk-CJHMFPL6.js";import{a as be}from"./chunk-RI3E7GBN.js";import{a as ce,d as ue,e as K,f as le,g as de}from"./chunk-7QZWBDI5.js";import{a as V,b as se}from"./chunk-SX7TUC3V.js";import{k as N,m as oe,n as ie}from"./chunk-CPUECYAJ.js";import{e as ae}from"./chunk-TSA6GHUG.js";var Ee=250,Ie=180,Re=96;function xe(n){let{data:e,width:t,height:a}=n,r=new Uint8Array(t*a);for(let o=0,s=0;o<r.length;o+=1,s+=4)r[o]=Math.round(.299*(e[s]??0)+.587*(e[s+1]??0)+.114*(e[s+2]??0));return{data:r,width:t,height:a}}function W(n,e){return{x0:Math.max(0,Math.floor(n.x)),y0:Math.max(0,Math.floor(n.y)),x1:Math.min(e.width,Math.ceil(n.x+n.width)),y1:Math.min(e.height,Math.ceil(n.y+n.height))}}function T(n,e,t){let a=W(e,n),r=t===void 0?null:W(t,n),o=0,s=0,l=0,m=0;for(let c=a.y0;c<a.y1;c+=1)for(let b=a.x0;b<a.x1;b+=1){if(r!==null&&b>=r.x0&&b<r.x1&&c>=r.y0&&c<r.y1)continue;let L=n.data[c*n.width+b];o+=1,s+=L,l+=L*L,L>=Ee&&(m+=1)}if(o===0)return{mean:0,sd:0,clipped:0,count:0};let d=s/o;return{mean:d,sd:Math.sqrt(Math.max(0,l/o-d*d)),clipped:m/o,count:o}}function ve(n){let{box:e}=n,a=(n.leftEye.y+n.rightEye.y)/2-.1*e.height,r=e.y+.85*e.height;return{x:e.x+.15*e.width,y:a,width:.7*e.width,height:Math.max(1,r-a)}}function Be(n,e){let t=ve(e),a=T(n,t);if(a.count===0)return null;let r=Math.min(Math.max(e.nose.x,t.x+1),t.x+t.width-1),o=T(n,{x:t.x,y:t.y,width:r-t.x,height:t.height}),s=T(n,{x:r,y:t.y,width:t.x+t.width-r,height:t.height}),l=s.mean>0?o.mean/s.mean:o.mean>0?Number.POSITIVE_INFINITY:1;return{faceLuma:a.mean,halfRatio:l,clipped:a.clipped}}function Ge(n,e){let t=0,a=0;for(let r of[e.leftEyeBox,e.rightEyeBox]){let o=r.width*.15,s=r.height*.5,l=T(n,{x:r.x-o,y:r.y-s,width:r.width+2*o,height:r.height+2*s});t+=l.count,a+=l.clipped*l.count}return t===0?null:a/t}function Ae(n,e){let t=me(e),{box:a}=e,r={x:a.x-.2*a.width,y:t.y,width:1.4*a.width,height:a.y+a.height-t.y},o=0,s=0,l=0;for(let d of[t.x,t.x+.8*t.width]){let c=T(n,{x:d,y:t.y+.04*t.height,width:.2*t.width,height:.25*t.height},r);o+=c.count,s+=c.mean*c.count,l+=(c.sd*c.sd+c.mean*c.mean)*c.count}if(o===0)return null;let m=s/o;return{luma:m,sd:Math.sqrt(Math.max(0,l/o-m*m)),count:o}}function Oe(n,e){let t=W(ve(e),n),a=Math.max(1,Math.floor(Math.max(t.x1-t.x0,t.y1-t.y0)/Re)),r=(d,c)=>n.data[c*n.width+d],o=0,s=0,l=0;for(let d=t.y0+a;d<t.y1-a;d+=a)for(let c=t.x0+a;c<t.x1-a;c+=a){let b=r(c,d-a)+r(c-a,d)+r(c+a,d)+r(c,d+a)-4*r(c,d);o+=1,s+=b,l+=b*b}if(o===0)return null;let m=s/o;return Math.min(1,Math.max(0,l/o-m*m)/Ie)}function we(n,e){return{lighting:Be(n,e),eyeSpecular:Ge(n,e),background:Ae(n,e),sharpness:Oe(n,e)}}var Ue="/models-v3",De=640,_e=.92;function Y(n){return{width:n.videoWidth||0,height:n.videoHeight||0}}function j(n,e){if(typeof document<"u"){let t=document.createElement("canvas");return t.width=n,t.height=e,t}return typeof OffscreenCanvas=="function"?new OffscreenCanvas(n,e):null}function He(){let n=null;return(e,t)=>{let{width:a,height:r}=Y(e);if(a===0||r===0)return null;let o=t===null?1:Math.min(1,t/Math.max(a,r)),s=Math.round(a*o),l=Math.round(r*o),m;t===null?m=j(s,l):((n===null||n.width!==s||n.height!==l)&&(n=j(s,l)),m=n);let d=m?.getContext("2d",{willReadFrequently:!0});if(m==null||d==null)return null;d.drawImage(e,0,0,s,l);let c=null;try{c=d.getImageData(0,0,s,l)}catch{c=null}return{source:m,width:s,height:l,pixels:c}}}async function qe(n,e,t,a){let r=Math.round(t*e.width/e.height),o=j(r,t),s=o?.getContext("2d");if(o==null||s==null)throw new Error("canvas unavailable");return s.fillStyle="#fff",s.fillRect(0,0,r,t),s.drawImage(n.source,e.x,e.y,e.width,e.height,0,0,r,t),"convertToBlob"in o?o.convertToBlob({type:"image/jpeg",quality:a}):new Promise((l,m)=>{o.toBlob(d=>d===null?m(new Error("encode failed")):l(d),"image/jpeg",a)})}var z=class extends Error{};function Ne(n,e,t){return new Promise((a,r)=>{let o=setTimeout(()=>{r(new z(`init exceeded ${e}ms`)),n.then(t,()=>{})},e);n.then(s=>{clearTimeout(o),a(s)},s=>{clearTimeout(o),r(s)})})}function Ve(n){if(n instanceof V)return{kind:"notfound",retryable:!0,detail:{name:n.name,phase:"acquiring",engineKind:"backcamera"}};let e=oe(n),t=e==="overconstrained"?"generic":e,a=N(n);return{kind:t,retryable:t!=="insecure"&&t!=="unsupported",detail:{...a!==void 0?{name:a}:{},phase:"acquiring",engineKind:e}}}function Ke(n,e,t,a){let r=n.length===1?n[0]:void 0,o=r===void 0?null:G(r.landmarks,t,a),s=null;if(r!==void 0&&e.pixels!==null){let l=G(r.landmarks,e.width,e.height),m=xe(e.pixels);l!==null&&(s=we(m,l))}return{frameWidth:t,frameHeight:a,faces:n.length,geometry:o,matrix:r?.matrix??null,blendshapes:r?.blendshapes??null,stats:s}}function ct(n,e={},t=()=>"self",a){let r=ge(n.tuning,n.tuningVersion),o=ce(),s=e.now??(()=>performance.now()),l=e.setTimer??((i,u)=>setTimeout(i,u)),m=e.clearTimer??(i=>clearTimeout(i)),d=e.grabFrame??He(),c=e.encodeRegion??qe,b=e.getUserMedia??(i=>navigator.mediaDevices.getUserMedia(i)),L=e.enumerateDevices??(e.getUserMedia===void 0&&typeof navigator<"u"&&typeof navigator.mediaDevices?.enumerateDevices=="function"?()=>navigator.mediaDevices.enumerateDevices():void 0),Ce=e.createLandmarker??ye,J=n.assetBaseUrl??Ue,Q=de({enabled:n.keepScreenAwake!==!1}),S=he(r,{policy:n.policy??"reject"}),w=n.video,X=be({tuning:r.backgroundCheck,assetBaseUrl:J,...e.createSegmenter!==void 0?{createSegmenter:e.createSegmenter}:{},now:s}),f="idle",C=null,x=null,E=null,A=!1,g=!1,p=0,$=0,O=[],v="user",U=le(),Z=!1,ke=e.canChooseFacing??ue,k=i=>{f===i||g||(f=i,Q.setActive(i==="starting"||i==="gating"),o.emit("state",i))},D=()=>{E!==null&&m(E),E=null},I=()=>{D();for(let i of C?.getTracks()??[])i.stop();C=null;try{w.srcObject=null}catch{}},_=i=>{I(),k("error"),o.emit("error",i)},ee=()=>{let i=Math.max(s(),$+1);return $=i,i},Me=async i=>{let u=d(w,null),{width:M,height:P}=u??Y(w);if(u===null||x===null){S.reset();return}let h=x.detect(u.source,ee()),y=(h.length===1?h:O.length===1?O:[])[0],F=y===void 0?null:G(y.landmarks,M,P);if(F===null){S.reset();return}let B=fe(F,M,P,{margin:r.cropMargin,minWidth:r.resolution.minWidth,minHeight:r.resolution.minHeight}),q=Math.max(r.resolution.minHeight,B.height),Te=await c(u,B,q,_e);if(g||i!==p)return;let re={image:Te,width:Math.round(q*B.width/B.height),height:q,gate:S.summary(),facingMode:v};r.tuningVersion!==null&&(re.tuningVersion=r.tuningVersion),D(),k("captured"),o.emit("captured",re)},H=async i=>{if(!(g||i!==p||f!=="gating"||x===null)){if(!A){A=!0;try{let u=d(w,De);if(u!==null){let{width:M,height:P}=Y(w),h=x.detect(u.source,ee());O=h;let y=Ke(h,u,M||u.width,P||u.height);y.geometry!==null&&r.background.required&&(y.backgroundCheck=X.measure(u,y.geometry.box,M||u.width,P||u.height));let F=S.push(y,s());if(g||i!==p||(o.emit("gate",F),F.ready&&(await Me(i),f!=="gating")))return}}catch{}finally{A=!1}}!g&&i===p&&f==="gating"&&(E=l(()=>{H(i)},1e3/r.cadenceHz))}},Pe=()=>Ne(Ce(J),2e4,i=>i.close()),Le=i=>{let u=t()==="assisted"?"assisted":"self";return Z||U.facing(u,n.facing),U.facing(u,i)},te=!1;function Se(){return te||a===void 0||a.session()!=="choice"||t()!=="assisted"?!1:(te=!0,a.onModeChange("self"),v=K("self"),k("mode_switch"),R({facing:v}),!0)}let R=async i=>{if(g||f==="starting"||f==="gating")return;p+=1;let u=p;S.reset(),k("starting");let M=Le(i?.facing);if(C!==null&&M!==v&&I(),v=M,Z=!0,C===null&&e.getUserMedia===void 0&&(typeof navigator>"u"||typeof navigator.mediaDevices?.getUserMedia!="function")){let h=typeof window<"u"&&window.isSecureContext===!1?"insecure":"unsupported";_({kind:h,retryable:!1,detail:{phase:"preflight",engineKind:h}});return}let P=x!==null?Promise.resolve(x):Pe();P.catch(()=>{});try{if(C===null){let h=await se(v,{width:{ideal:r.camera.width},height:{ideal:r.camera.height}},{getUserMedia:b,...L!==void 0?{enumerateDevices:L}:{}});if(g||u!==p){for(let y of h.getTracks())y.stop();return}C=h,ie(h),v=ae(h)??v,w.srcObject=C,w.muted=!0,w.playsInline=!0,await w.play().catch(()=>{})}}catch(h){if(g||u!==p||h instanceof V&&Se())return;_(Ve(h));return}try{x=await P}catch(h){if(!g&&u===p){let y=N(h);_({kind:"generic",retryable:!0,detail:{...y!==void 0?{name:y}:{},phase:"models",engineKind:"models"}})}return}g||u!==p||(k("gating"),H(u))},ne=async()=>a!==void 0&&a.session()==="choice"&&await ke().catch(()=>!1),Fe=()=>f==="idle"||f==="starting"||f==="gating"||f==="error";return{handle:{get state(){return f},get captureMode(){return t()},get facingMode(){return v},on:(i,u)=>o.on(i,u),start:R,retry:()=>{if(!g){if(C!==null&&x!==null&&f!=="error"){p+=1;let i=p;D(),S.reset(),k("gating"),H(i);return}f="idle",R()}},switchCamera:()=>U.refuseSwitch(t()==="assisted"?"assisted":"self"),canSwitchCaptureMode:ne,setCaptureMode:async i=>{if(g||a===void 0||i===t()||!await ne()||g||!Fe())return!1;a.onModeChange(i);let u=K(i);return f==="idle"&&C===null||(p+=1,I(),v=u,k("mode_switch"),R({facing:u})),!0},destroy:()=>{g||(p+=1,I(),Q.setActive(!1),g=!0,x?.close(),x=null,X.close(),o.clear())}},gateScores:()=>S.scores(),setFlowState:i=>{(f==="captured"||f==="uploading"||f==="checking"||f==="done"&&i==="done")&&k(i)}}}function ut(){import("@mediapipe/tasks-vision").catch(()=>{})}export{Ee as a,Ie as b,xe as c,T as d,Be as e,Ge as f,Ae as g,Oe as h,we as i,De as j,_e as k,He as l,Ke as m,ct as n,ut as o};
@@ -0,0 +1 @@
1
+ var E="https://challenges.cloudflare.com/turnstile/v0/api.js",x=1e4;function T(){return window.turnstile}var l=null,r=null,p=Promise.resolve();function b(){l=null,r?.container.remove(),r=null,p=Promise.resolve()}function v(){return l??(l=new Promise((i,n)=>{let t=T();if(t){i(t);return}let e=document.createElement("script");e.src=E,e.async=!0,e.onload=()=>{let s=T();s?i(s):(l=null,n(new Error("Turnstile script loaded but exposed no API")))},e.onerror=()=>{l=null,e.remove(),n(new Error("Turnstile script failed to load"))},document.head.appendChild(e)})),l}function c(){return new Error("Turnstile challenge aborted")}function w(i,n){if(r!==null&&r.siteKey===n)return r;if(r!==null){try{i.remove(r.id)}catch{}r.container.remove(),r=null}let t=document.createElement("div");document.body.appendChild(t);let e={siteKey:n,container:t,fresh:!0,pending:null},s=i.render(t,{sitekey:n,execution:"execute",appearance:"execute",callback:o=>e.pending?.resolve(o),"error-callback":o=>e.pending?.reject(new Error(`Turnstile challenge failed${o?` (${o})`:""}`))});if(s===void 0)throw t.remove(),new Error("Turnstile render returned no widget id");return e.id=s,r=e,r}function h(i,n){try{i.reset(n.id),n.fresh=!1}catch{r===n&&(n.container.remove(),r=null)}}function P(i,n={}){let t=p.then(()=>m(i,n),()=>m(i,n));return p=t.catch(()=>{}),t}async function m(i,n){let t=n.timeoutMs??1e4,e=n.signal;if(e?.aborted)throw c();let s=await v();if(e?.aborted)throw c();let o=w(s,i),f,u,g=!1;try{return await new Promise((d,a)=>{o.pending={resolve:d,reject:a},f=setTimeout(()=>a(new Error(`Turnstile challenge timed out (${t} ms)`)),t),e!==void 0&&(u=()=>a(c()),e.addEventListener("abort",u,{once:!0})),o.fresh||s.reset(o.id),o.fresh=!1,s.execute(o.id)}).then(d=>(g=!0,d))}finally{clearTimeout(f),e!==void 0&&u!==void 0&&e.removeEventListener("abort",u),o.pending=null,g||h(s,o)}}export{E as a,x as b,b as c,v as d,P as e};
@@ -0,0 +1 @@
1
+ import{d as Jt,h as qt,k as te}from"./chunk-G6LKLN4U.js";import{b as $t}from"./chunk-SMKCBUJL.js";import{a as et,b as ee,c as ie,e as mt,f as oe}from"./chunk-MXWLCDFX.js";import{b as Yt,c as Zt}from"./chunk-TDLIXFDT.js";import{b as Vt,c as Xt}from"./chunk-POIQGEZM.js";import{k as Qt,m as Bt,n as Wt,o as Ht,p as Kt,r as ut}from"./chunk-CPUECYAJ.js";import{b as ht,c as dt,d as j,e as jt}from"./chunk-FPXL63KZ.js";import{d as Ut}from"./chunk-BATJN3VQ.js";var it=Object.freeze({sensing:{key:"sensing",reticle:"searching",minDurationMs:900},too_far:{key:"too_far",reticle:"coaching",minDurationMs:1400},too_close:{key:"too_close",reticle:"coaching",minDurationMs:1400},edge_clipped:{key:"edge_clipped",reticle:"coaching",minDurationMs:1400},wrong_shape:{key:"wrong_shape",reticle:"coaching",minDurationMs:1400},tilted:{key:"tilted",reticle:"coaching",minDurationMs:1400},too_dark:{key:"too_dark",reticle:"coaching",minDurationMs:1400},too_bright:{key:"too_bright",reticle:"coaching",minDurationMs:1400},blurry:{key:"blurry",reticle:"coaching",minDurationMs:1400},focus_far:{key:"focus_far",reticle:"coaching",minDurationMs:1600},glare:{key:"glare",reticle:"coaching",minDurationMs:1400},hold_still:{key:"hold_still",reticle:"locking",minDurationMs:900},processing:{key:"processing",reticle:"processing",minDurationMs:800},side_captured:{key:"side_captured",reticle:"flip",minDurationMs:2600},captured:{key:"captured",reticle:"done",minDurationMs:800}});function ne(i){return i.framing==="no_document"?"sensing":i.framing==="too_far"?"too_far":i.framing==="too_close"?"too_close":i.framing==="edge_clipped"?"edge_clipped":i.framing==="wrong_shape"?"wrong_shape":i.framing==="tilted"?"tilted":i.lighting==="too_dark"?"too_dark":i.lighting==="too_bright"?"too_bright":i.glare==="glare"?"glare":i.blur==="blurry"?"blurry":"hold_still"}var ot=class{constructor(t=2600,e=.35){this.windowMs=t;this.decayPerSecond=e;this.votes=[];this.current=it.sensing;this.currentSinceMs=null}reset(){this.votes=[],this.current=it.sensing,this.currentSinceMs=null}force(t,e){return this.votes=[],this.current=it[t],this.currentSinceMs=e,this.current}tick(t,e){if(this.currentSinceMs===null&&(this.currentSinceMs=e),this.votes.push({key:t,atMs:e}),this.votes=this.votes.filter(r=>e-r.atMs<=this.windowMs),e-this.currentSinceMs<this.current.minDurationMs)return this.current;let o=new Map;for(let r of this.votes){let c=(e-r.atMs)/1e3,a=this.decayPerSecond**c;o.set(r.key,(o.get(r.key)??0)+a)}let n=this.current.key,s=-1;for(let[r,c]of o)c>s&&(s=c,n=r);return n!==this.current.key&&(this.current=it[n],this.currentSinceMs=e),this.current}};var Xe=Object.freeze({MAX_AREA_FRAC:.92,TILT_MAX_SIDE_RATIO:1.3,GLARE_MAX_SPECULAR_FRAC:.025});function re(i){let{data:t,width:e,height:o}=i,n=e*o;if(n===0)return 0;let s=0;for(let r=0;r<n;r++){let c=r*4;.299*(t[c]??0)+.587*(t[c+1]??0)+.114*(t[c+2]??0)>=252&&s++}return s/n}function je(i){let t=(a,l)=>Math.hypot(l.x-a.x,l.y-a.y),e=t(i.topLeft,i.topRight),o=t(i.bottomLeft,i.bottomRight),n=t(i.topLeft,i.bottomLeft),s=t(i.topRight,i.bottomRight),r=Math.max(e,o)/Math.max(1e-6,Math.min(e,o)),c=Math.max(n,s)/Math.max(1e-6,Math.min(n,s));return Math.max(r,c)}function ae(i){let t={...ee,...i.thresholds},e=Xe,{quad:o,frameWidth:n,frameHeight:s,measures:r}=i,c=i.format==="ID-3",a="ok";if(o===null)a="no_document";else if(c){let m=mt(o),h=n>0?m.width/n:0,f=m.height>0?m.width/m.height:0;h<t.ID3_BAND_MIN_WIDTH_FRAC?a="too_far":se(o,n,s,t.EDGE_CLIP_MARGIN_PX)?a="edge_clipped":(f<t.ID3_BAND_ASPECT_MIN||f>t.ID3_BAND_ASPECT_MAX)&&(a="wrong_shape")}else{let m=ie(o,n,s),h=mt(o),f=Math.max(h.width,h.height)/Math.max(1e-6,Math.min(h.width,h.height));m<t.MIN_AREA_FRAC?a="too_far":m>e.MAX_AREA_FRAC?a="too_close":se(o,n,s,t.EDGE_CLIP_MARGIN_PX)?a="edge_clipped":Zt(i.format,f)?je(o)>e.TILT_MAX_SIDE_RATIO&&(a="tilted"):a="wrong_shape"}let l=r.exposure>=t.GUIDE_EXPOSURE?"ok":r.meanLuma<(ht[0]+ht[1])/2?"too_dark":"too_bright",u=r.sharpness>=t.GUIDE_SHARPNESS?"ok":"blurry",d=r.specularFraction>=e.GLARE_MAX_SPECULAR_FRAC?"glare":"ok";return{framing:a,lighting:l,blur:u,glare:d,acceptable:a==="ok"&&l==="ok"&&u==="ok"&&d==="ok"}}function se(i,t,e,o){return[i.topLeft,i.topRight,i.bottomRight,i.bottomLeft].some(s=>s.x<=o||s.y<=o||s.x>=t-o||s.y>=e-o)}var le=Object.freeze({width:1920,height:1080}),Ye=Object.freeze({width:3840,height:2160}),ce=4096,Ze=2560,ue=640,nt=.15,Y=Object.freeze({side:.2,above:.9,below:.3});function E(i){let t=[i.topLeft.x,i.topRight.x,i.bottomRight.x,i.bottomLeft.x],e=[i.topLeft.y,i.topRight.y,i.bottomRight.y,i.bottomLeft.y],o=Math.min(...t),n=Math.min(...e);return{x:o,y:n,width:Math.max(...t)-o,height:Math.max(...e)-n}}function he(i,t){let e=Math.max(0,Math.floor(i.x)),o=Math.max(0,Math.floor(i.y)),n=Math.min(t.width,Math.ceil(i.x+i.width)),s=Math.min(t.height,Math.ceil(i.y+i.height));return n-e<16||s-o<16?null:{x:e,y:o,width:n-e,height:s-o}}function Je(i,t,e){if(i===null||t.width<=0||t.height<=0)return null;let o=E(i);if(o.width<=0||o.height<=0)return null;let n=e==="ID-3"?{x:o.x-o.width*Y.side,y:o.y-o.width*Y.above,width:o.width*(1+2*Y.side),height:o.height+o.width*(Y.above+Y.below)}:{x:o.x-o.width*nt,y:o.y-o.height*nt,width:o.width*(1+2*nt),height:o.height*(1+2*nt)};return he(n,t)}function ft(i,t,e){let o=Math.max(i,t);return o>0?Math.min(1,e/o):1}function pt(i,t,e,o,n=Ze){let s=t.width>0?e.width/t.width:1,r=t.height>0?e.height/t.height:1,c=i===null?null:{topLeft:{x:i.topLeft.x*s,y:i.topLeft.y*r},topRight:{x:i.topRight.x*s,y:i.topRight.y*r},bottomRight:{x:i.bottomRight.x*s,y:i.bottomRight.y*r},bottomLeft:{x:i.bottomLeft.x*s,y:i.bottomLeft.y*r}},a=Je(c,e,o)??{x:0,y:0,width:e.width,height:e.height},l=ft(a.width,a.height,n),u=Math.max(1,Math.round(a.width*l)),d=Math.max(1,Math.round(a.height*l)),m=null;if(c!==null){let h=E(c);m=he({x:(h.x-a.x)*l,y:(h.y-a.y)*l,width:h.width*l,height:h.height*l},{width:u,height:d})}return{crop:a,width:u,height:d,docRegion:m}}function de(i,t,e,o=Ye){if(e==="LOW")return null;let n=i?.width?.max,s=i?.height?.max;if(typeof n!="number"||typeof s!="number"||n<=0||s<=0)return null;let r=Math.max(n,s),c=Math.min(n,s),a=Math.min(r,Math.max(o.width,o.height)),l=Math.min(c,Math.min(o.width,o.height));return a<=Math.max(t.width,t.height)?null:{width:{ideal:a},height:{ideal:l}}}function me(i){let t={},e=i?.imageWidth,o=i?.imageHeight;if(typeof e?.max=="number"&&e.max>0){let n=typeof o?.max=="number"&&o.max>0?e.max/o.max:1.3333333333333333,s=n>=1?ce:ce*n,r=Math.min(e.max,Math.floor(s)),c=typeof e.step=="number"&&e.step>0?e.step:1,a=typeof e.min=="number"?e.min:0;r=Math.max(a,a+Math.floor((r-a)/c)*c),t.imageWidth=r}return i?.fillLightMode?.includes("off")===!0&&(t.fillLightMode="off"),t}function fe(i,t){if(i.width<=0||i.height<=0||t.width<=0||t.height<=0)return!1;let e=i.width>i.height,o=t.width>t.height;return e!==o&&i.width!==i.height&&t.width!==t.height?!1:Math.max(i.width,i.height)>=1.2*Math.max(t.width,t.height)}function pe(i,t,e,o){if(e===null)return!1;let n=E(i),s=E(e);if(t.width<=0||o.width<=0)return!1;let r=n.width/t.width,c=s.width/o.width;return c>0&&r>=.6*c&&r<=1.25*c}var ge=3500,qe=.92;function ye(){let i=globalThis.ImageCapture;return typeof i=="function"?i:null}function $e(i){return/AppleWebKit\//.test(i)&&!/(Chrome|Chromium|Edg|OPR)\//.test(i)}function Me(i,t=typeof navigator>"u"?"":navigator.userAgent){return ye()!==null&&!$e(t)&&i!=null&&i.kind==="video"&&i.readyState==="live"}function be(i,t){return new Promise((e,o)=>{let n=setTimeout(()=>o(new Error("takePhoto timed out")),t);i.then(s=>{clearTimeout(n),e(s)},s=>{clearTimeout(n),o(s)})})}function gt(i,t){let e=document.createElement("canvas");return e.width=i,e.height=t,e}function ti(i,t){return new Promise((e,o)=>{i.toBlob(n=>n?e(n):o(new Error("toBlob failed")),"image/jpeg",t)})}async function ke(i,t,e,o,n){let s=gt(e,o),r=gt(1,1);try{let c=s.getContext("2d");if(c===null)throw new Error("2d context unavailable");c.imageSmoothingQuality="high",c.drawImage(i,t.x,t.y,t.width,t.height,0,0,e,o);let a=await ti(s,qe),l=n===null?null:Jt({topLeft:{x:n.x,y:n.y},topRight:{x:n.x+n.width,y:n.y},bottomRight:{x:n.x+n.width,y:n.y+n.height},bottomLeft:{x:n.x,y:n.y+n.height}},{width:e,height:o},{width:e,height:o}),u=qt(s,l),d=ft(e,o,ue);return r.width=Math.max(1,Math.round(e*d)),r.height=Math.max(1,Math.round(o*d)),r.getContext("2d")?.drawImage(s,0,0,r.width,r.height),{blob:a,previewDataUrl:r.toDataURL("image/jpeg",.85),sharpness:u}}finally{s.width=0,s.height=0,r.width=0,r.height=0}}function ei(i,t){let e=Math.min(1,t/i.width),o=gt(Math.max(1,Math.round(i.width*e)),Math.max(1,Math.round(i.height*e)));try{let n=o.getContext("2d",{willReadFrequently:!0});return n===null?null:(n.imageSmoothingQuality="high",n.drawImage(i,0,0,o.width,o.height),n.getImageData(0,0,o.width,o.height))}finally{o.width=0,o.height=0}}async function De(i,t,e,o){let n={width:Math.max(1,i.videoWidth),height:Math.max(1,i.videoHeight)},s=pt(t,e,n,o);return{...await ke(i,s.crop,s.width,s.height,s.docRegion),docRegion:s.docRegion,source:"video",width:s.width,height:s.height}}async function xe(i,t,e,o,n){let s=ye();if(s===null)return null;let r=null;try{let c=new s(n.track),a=await be(c.getPhotoCapabilities?.()??Promise.resolve({}),ge).catch(()=>({})),l=await be(c.takePhoto(me(a)),ge);r=await createImageBitmap(l);let u={width:i.videoWidth,height:i.videoHeight};if(!fe(r,u))return null;let d=ei(r,n.detectWidth),m=null;d!==null&&t!==null&&(m=await n.detect(d).catch(()=>null));let h=d??{width:r.width,height:r.height};m!==null&&!pe(m,h,t,e)&&(m=null);let f=pt(m,h,r,o);return{...await ke(r,f.crop,f.width,f.height,f.docRegion),docRegion:f.docRegion,source:"photo",width:f.width,height:f.height}}catch{return null}finally{r?.close()}}var st=Object.freeze({width:3840,height:2160,lensSelection:!0,continuousFocus:!0,refocusBeforePhotoMs:350,zoomMax:2,zoomNoFocusInfo:1.5,zoomMinSourcePx:2160,fillDistanceM:Object.freeze({id1:.11,id3:.15}),focusMarginFrac:.2,stillSharpnessMin:.16,stillRefusalsMax:2,focusFarFillFrac:.45,noDocFarHintMs:1500,zoomFallbackMs:8e3}),S=(i,t,e)=>typeof i=="number"&&Number.isFinite(i)&&i>=t&&i<=e?i:void 0;function Si(i){let t=st,e=i!==null&&typeof i=="object"?i:{},o=e.fillDistanceM!==null&&typeof e.fillDistanceM=="object"?e.fillDistanceM:{},n=(s,r)=>typeof s=="boolean"?s:r;return{width:S(e.width,640,7680)??t.width,height:S(e.height,480,4320)??t.height,lensSelection:n(e.lensSelection,t.lensSelection),continuousFocus:n(e.continuousFocus,t.continuousFocus),refocusBeforePhotoMs:S(e.refocusBeforePhotoMs,0,2e3)??t.refocusBeforePhotoMs,zoomMax:S(e.zoomMax,1,5)??t.zoomMax,zoomNoFocusInfo:S(e.zoomNoFocusInfo,1,5)??t.zoomNoFocusInfo,zoomMinSourcePx:S(e.zoomMinSourcePx,0,8e3)??t.zoomMinSourcePx,fillDistanceM:{id1:S(o.id1,.03,1)??t.fillDistanceM.id1,id3:S(o.id3,.03,1)??t.fillDistanceM.id3},focusMarginFrac:S(e.focusMarginFrac,0,2)??t.focusMarginFrac,stillSharpnessMin:S(e.stillSharpnessMin,0,10)??t.stillSharpnessMin,stillRefusalsMax:S(e.stillRefusalsMax,0,10)??t.stillRefusalsMax,focusFarFillFrac:S(e.focusFarFillFrac,0,1)??t.focusFarFillFrac,noDocFarHintMs:S(e.noDocFarHintMs,0,6e4)??t.noDocFarHintMs,zoomFallbackMs:S(e.zoomFallbackMs,0,12e4)??t.zoomFallbackMs}}var bt="sekyro.doc.camera";function ii(){try{let i=globalThis.localStorage?.getItem(bt);return typeof i=="string"&&i!==""?i:null}catch{return null}}function we(i){try{i===null?globalThis.localStorage?.removeItem(bt):globalThis.localStorage?.setItem(bt,i)}catch{}}var rt=(i,t)=>Array.isArray(i?.focusMode)&&i.focusMode.includes(t);function Mt(i,t,e){if(!rt(i,"single-shot"))return null;let o=n=>Math.min(1,Math.max(0,Number.isFinite(n)?n:.5));return{focusMode:"single-shot",pointsOfInterest:[{x:o(t),y:o(e)}]}}function _i(i,t,e,o){if(!Number.isFinite(i)||!Number.isFinite(t)||e.width<=0||e.height<=0||o.width<=0||o.height<=0)return null;let n=Math.max(e.width/o.width,e.height/o.height),s=o.width*n,r=o.height*n,c=(i-e.left+(s-e.width)/2)/s,a=(t-e.top+(r-e.height)/2)/r;return{x:Math.min(1,Math.max(0,c)),y:Math.min(1,Math.max(0,a))}}function Se(i,t,e,o=st){let n=i?.zoom?.min,s=i?.zoom?.max;if(typeof s!="number"||s<=1)return 1;let r=e==="ID-3"?o.fillDistanceM.id3:o.fillDistanceM.id1,c=i?.focusDistance?.min,a;if(typeof c=="number"&&c>0&&c<1){if(a=c*(1+o.focusMarginFrac)/r,a<=1.05)return 1}else{if(Math.min(t.width,t.height)<o.zoomMinSourcePx)return 1;a=o.zoomNoFocusInfo}let l=Math.min(a,o.zoomMax,s);typeof n=="number"&&(l=Math.max(l,n));let u=i?.zoom?.step;return typeof u=="number"&&u>0&&(l=Math.round(l/u)*u),l>1.01?Number(l.toFixed(2)):1}function yt(i){try{return i.getVideoTracks?.()[0]}catch{return}}function ve(i){if(i!==null)for(let t of i.getTracks())t.stop()}function oi(i){try{let t=yt(i)?.getCapabilities?.();return!Array.isArray(t?.focusMode)||t.focusMode.includes("continuous")}catch{return!0}}async function Te(i){let t=s=>({audio:!1,video:{...s,width:{ideal:i.base.width},height:{ideal:i.base.height}}}),e=s=>i.getUserMedia(t({deviceId:{exact:s}})),o=()=>i.getUserMedia(t({facingMode:{ideal:"environment"}}));if(i.lensSelection){let s=ii();if(s!==null)try{return{stream:await e(s),lens:"stored"}}catch{we(null)}}let n=await o();if(!i.lensSelection||i.enumerateDevices===void 0)return{stream:n,lens:"default"};try{let s=ut(await i.enumerateDevices()).slice(0,3);if(s.length===0)return{stream:n,lens:"default"};let r=null;for(let c of s){let a=n!==null?yt(n)?.getSettings?.().deviceId:void 0;if(n===null||a!==c){ve(n),n=null;try{n=await e(c)}catch{continue}}if(r??(r=c),oi(n))return we(c),{stream:n,lens:"selected"}}if(n!==null&&r!==null&&yt(n)?.getSettings?.().deviceId===r)return{stream:n,lens:"selected"};if(ve(n),n=null,r!==null)try{return{stream:await e(r),lens:"selected"}}catch{}return{stream:await o(),lens:"default"}}catch{return{stream:n??await o(),lens:"default"}}}var Z=Object.freeze({brightness:0,glare:0,cardGlare:0,sharpness:0,fill:0,shape:0,content:0,offsetX:0,offsetY:0,edgeConfidence:0,box:null}),L=i=>Math.min(1,Math.max(0,i));function Re(i,t,e,o=.06){let n=Math.max(i.width/e,i.height),s=n*e,r=(i.width-s)/2,c=(i.height-n)/2,a=L((t.x-t.width*o-r)/s),l=L((t.y-t.height*o-c)/n),u=L((t.x+t.width*(1+o)-r)/s),d=L((t.y+t.height*(1+o)-c)/n);return{x:a,y:l,width:u-a,height:d-l}}function Fe(i,t,e={}){let o=e.edgePeakFrac??0,{width:n,height:s,data:r}=i;if(n<=0||s<=0)return Z;let c=L(t.x),a=L(t.y),l={x:c,y:a,width:Math.max(0,L(t.x+t.width)-c),height:Math.max(0,L(t.y+t.height)-a)};if(l.width<=0||l.height<=0)return Z;let u=l.x*n,d=l.y*s,m=(l.x+l.width)*n,h=(l.y+l.height)*s,f=(m-u)*.15,g=(h-d)*.15,y=(p,b,R)=>Math.min(R,Math.max(b,p)),D=y(Math.floor(u-f),0,n-1),w=y(Math.floor(d-g),0,s-1),O=y(Math.ceil(m+f),D+1,n),v=y(Math.ceil(h+g),w+1,s),x=Math.max(1,Math.ceil(Math.max(O-D,v-w)/320)),M=Math.floor((O-D+x-1)/x),T=Math.floor((v-w+x-1)/x);if(M<3||T<3)return Z;let k=new Int32Array(M*T);for(let p=0;p<T;p++){let b=w+p*x;for(let R=0;R<M;R++){let F=(b*n+D+R*x)*4;k[p*M+R]=(r[F]??0)*77+(r[F+1]??0)*150+(r[F+2]??0)*29>>8}}let C=(p,b)=>(p-b-.5)/x,_=C(u,D),A=C(m,D),B=C(d,w),U=C(h,w),Dt=(m-u)/x,xt=(h-d)/x,wt=y(Math.ceil(_),0,M-1),Ie=y(Math.floor(A),wt,M-1),vt=y(Math.ceil(B),0,T-1),Ge=y(Math.floor(U),vt,T-1),St=0,Tt=0,W=0,_t=0,Rt=0,H=0;for(let p=vt;p<=Ge;p++)for(let b=wt;b<=Ie;b++){let R=k[p*M+b];if(St+=R,R>=248&&Tt++,W++,b>=1&&b<M-1&&p>=1&&p<T-1){let F=k[p*M+b-1]+k[p*M+b+1]+k[(p-1)*M+b]+k[(p+1)*M+b]-4*R;_t+=F,Rt+=F*F,H++}}let ze=W>0?St/W:0,Ft=W>0?Tt/W:0,Ct=H>0?_t/H:0,Ne=H>0?Math.max(0,Rt/H-Ct*Ct):0,K=new Float64Array(M),V=new Float64Array(T);for(let p=0;p<T;p++)for(let b=1;b<M-1;b++)K[b]=K[b]+Math.abs(k[p*M+b+1]-k[p*M+b-1]);for(let p=1;p<T-1;p++)for(let b=0;b<M;b++)V[p]=V[p]+Math.abs(k[(p+1)*M+b]-k[(p-1)*M+b]);let P=at(K,!0,_,o),I=at(K,!1,A,o),G=at(V,!0,B,o),z=at(V,!1,U,o),At=(I.position-P.position)/Dt,Et=(z.position-G.position)/xt,Qe=Et>0?At/Et:0,Be=((P.position+I.position)/2-(_+A)/2)/Dt,Ue=((G.position+z.position)/2-(B+U)/2)/xt,Lt=_e(K),Ot=_e(V),We=Lt<=0||Ot<=0?0:Math.min(Math.min(P.value,I.value)/Lt,Math.min(G.value,z.value)/Ot),$=(p,b)=>b+(p+.5)*x,Pt=Ft,It=0;{let p=(I.position-P.position)*.06,b=(z.position-G.position)*.06,R=y(Math.ceil(P.position+p),0,M-1),F=y(Math.floor(I.position-p),0,M-1),He=y(Math.ceil(G.position+b),0,T-1),Gt=y(Math.floor(z.position-b),0,T-1),zt=0,tt=0,Nt=0;for(let N=He;N<=Gt;N++)for(let Q=R;Q<=F;Q++){tt++;let X=k[N*M+Q];X>=248&&zt++;let Ke=Q+2<=F?k[N*M+Q+2]:X,Ve=N+2<=Gt?k[(N+2)*M+Q]:X;(Math.abs(Ke-X)>=24||Math.abs(Ve-X)>=24)&&Nt++}tt>=16&&(Pt=zt/tt,It=Nt/tt)}return{brightness:ze,glare:Ft,cardGlare:Pt,sharpness:Ne,fill:At,shape:Qe,content:It,offsetX:Be,offsetY:Ue,edgeConfidence:We,box:{left:$(P.position,D),right:$(I.position,D),top:$(G.position,w),bottom:$(z.position,w)}}}function at(i,t,e,o){let n=i.length,s=Math.max(1,Math.floor(n*.45)),r=t?1:Math.max(1,n-1-s),c=t?Math.min(n-2,s):n-2,a=r;for(let h=r;h<=c;h++)i[h]>i[a]&&(a=h);if(o>0&&o<1){let h=i[a]*o,f=a,g=Math.abs(a-e);for(let y=r;y<=c;y++){let D=i[y];if(D<h||D<(i[y-1]??0)||D<(i[y+1]??0))continue;let w=Math.abs(y-e);w<g&&(f=y,g=w)}a=f}let l=a>0?i[a-1]:0,u=i[a],d=a<n-1?i[a+1]:0,m=l+u+d;return{position:m>0?a+(d-l)/m:a,value:u}}function _e(i){if(i.length<3)return 0;let t=0;for(let e=1;e<i.length-1;e++)t+=i[e];return t/(i.length-2)}function Ce(i){let t=i.box;return t===null||t.right-t.left<4||t.bottom-t.top<4?null:{topLeft:{x:t.left,y:t.top},topRight:{x:t.right,y:t.top},bottomRight:{x:t.right,y:t.bottom},bottomLeft:{x:t.left,y:t.bottom}}}var J=Object.freeze({fillMin:.82,fillMax:1.06,offsetMax:.06,glareMax:.025,sharpnessMin:180,edgeConfidenceMin:1.6,darkBrightness:70,lockMs:450,steadyMs:900,steadyFillMin:.45,steadyFillMax:1.3,steadyFillDelta:.06,steadyOffsetDelta:.04,steadyRefMs:100,edgePeakFrac:.4,shapeTolerance:.2,contentMin:.1});function Ai(i){let t=i!==null&&typeof i=="object"?i:{},e={...J};for(let o of Object.keys(J)){let n=t[o];typeof n=="number"&&Number.isFinite(n)&&n>=0&&n<=1e6&&(e[o]=n)}return e}var ct=class{constructor(t=J){this.t=t;this.goodSince=null;this.steadySince=null;this.last=null}reset(){this.goodSince=null,this.steadySince=null,this.last=null}tick(t,e){let o=this.t,n=o.shapeTolerance<=0||Math.abs(t.shape-1)<=o.shapeTolerance,s=t.edgeConfidence>=o.edgeConfidenceMin&&n&&t.content>=o.contentMin,r=t.fill>=o.fillMin&&t.fill<=o.fillMax,c=Math.abs(t.offsetX)<=o.offsetMax&&Math.abs(t.offsetY)<=o.offsetMax,a=t.cardGlare<=o.glareMax,l=t.sharpness>=o.sharpnessMin,u=this.last;this.last={fill:t.fill,offsetX:t.offsetX,offsetY:t.offsetY,at:e};let d=u!==null&&o.steadyRefMs>0?Math.min(3,Math.max(1,(e-u.at)/o.steadyRefMs)):1,m=s&&a&&l&&t.fill>=o.steadyFillMin&&t.fill<=o.steadyFillMax&&u!==null&&Math.abs(t.fill-u.fill)<=o.steadyFillDelta*d&&Math.abs(t.offsetX-u.offsetX)<=o.steadyOffsetDelta*d&&Math.abs(t.offsetY-u.offsetY)<=o.steadyOffsetDelta*d,h=s&&r&&c&&a&&l,f;if(s?a?t.fill<o.fillMin?f="too_small":t.fill>o.fillMax?f="too_big":l?c?f="locking":f="off_center":f="blurry":f="glare":f="no_card",h){if(m&&(this.steadySince??(this.steadySince=e)),this.goodSince??(this.goodSince=e),e-this.goodSince>=o.lockMs)return{detected:s,ready:!0,via:"good",blocker:"locking"};let g=this.steadySince!==null&&e-this.steadySince>=o.steadyMs;return{detected:s,ready:g,via:g?"steady":null,blocker:"locking"}}if(this.goodSince=null,m){this.steadySince??(this.steadySince=e);let g=e-this.steadySince>=o.steadyMs;return{detected:s,ready:g,via:g?"steady":null,blocker:g?"locking":"steadying"}}return this.steadySince=null,{detected:s,ready:!1,via:null,blocker:f}}};var q=null;async function ni(i){return q===null&&(q=(await import("./detector-scanic-YCDNLCGV.js")).detectQuad),q(i)}async function si(i){let t=$t(i);return t===null?null:{topLeft:{x:t.x,y:t.y},topRight:{x:t.x+t.width,y:t.y},bottomRight:{x:t.x+t.width,y:t.y+t.height},bottomLeft:{x:t.x,y:t.y+t.height}}}function ji(){q===null&&import("./detector-scanic-YCDNLCGV.js").then(i=>{q=i.detectQuad}).catch(()=>{})}var Ae=4e3,ri=2,Ee=3,ai=Object.freeze({LOW:3,MID:5,HIGH:6}),kt=Object.freeze({manualShutterMs:6e3,detectedNoLockMs:1950});function Yi(i){let t=i!==null&&typeof i=="object"?i:{},e=(o,n,s)=>typeof o=="number"&&Number.isFinite(o)&&o>=n&&o<=s?o:void 0;return{manualShutterMs:e(t.manualShutterMs,1e3,6e4)??kt.manualShutterMs,detectedNoLockMs:e(t.steadyMs,300,3e4)!==void 0?t.steadyMs+(e(t.lockMs,0,1e4)??450):kt.detectedNoLockMs}}var Le=class i{constructor(t){this.torchOn=!1;this.stillRefusals=0;this.zoom=1;this.positioningSince=null;this.detectedSince=null;this.lastSeenAt=null;this.lastGuideQuad=null;this.lastOcrReady=null;this.shutterOffered=!1;this.stats=i.freshStats();this.handlers=new Map;this.stream=null;this.timer=null;this.state="idle";this.lastGuidance=null;this.attempt=0;this.capturing=!1;this.feedback=new ot;this.lastFeedbackKey=null;this.lastQuad=null;this.lastDetect=null;this.frameWatch=null;this.reopened=!1;this.lit=!1;this.blackTicks=0;this.offEnded=null;this.opts=t,this.gate=new oe(t.format??"ID-1",t.thresholds);let e=t.deviceClass??Xt(Vt());this.deviceClass=e,this.camera=t.camera??st,this.shutterTuning=t.shutter??kt,this.guideTuning=t.guideLock??J,this.guideLock=new ct(this.guideTuning),this.cadenceMs=1e3/ai[e]}on(t,e){let o=this.handlers.get(t);return o||(o=new Set,this.handlers.set(t,o)),o.add(e),()=>o?.delete(e)}emit(t,e){for(let o of[...this.handlers.get(t)??[]])o(e)}async start(){let t=this.state==="error"?this.resumePlayback():null,e=++this.attempt;if(this.clearFrameWatch(),this.gate.reset(),this.resetSide(),this.feedback.reset(),this.lastFeedbackKey=null,this.lastGuidance=null,this.capturing=!1,this.lit=!1,this.blackTicks=0,t!==null&&await t&&e===this.attempt){this.setState("positioning"),this.scheduleTick(e),this.watchFrames(e);return}if(e===this.attempt){this.releaseStream(),Ht(),this.setState("preflight");try{let o=this.opts.getUserMedia??(r=>navigator.mediaDevices.getUserMedia(r));this.setState("acquiring");let n=this.opts.enumerateDevices??(this.opts.getUserMedia===void 0&&typeof navigator<"u"&&navigator.mediaDevices?.enumerateDevices?()=>navigator.mediaDevices.enumerateDevices():void 0),s=await Te({getUserMedia:o,...n!==void 0?{enumerateDevices:n}:{},lensSelection:this.camera.lensSelection,base:le});if(e!==this.attempt){for(let r of s.stream.getTracks())r.stop();return}if(this.stream=s.stream,Ut(this.stream),Wt(this.stream),this.watchEnded(e),this.opts.upgradeResolution!==!1&&await this.upgradeResolution(),e!==this.attempt||(await this.applyFocusAndZoom(),e!==this.attempt)||(this.opts.video.srcObject=this.stream,await this.opts.video.play().catch(()=>{}),e!==this.attempt))return;this.setState("positioning"),this.scheduleTick(e),this.watchFrames(e)}catch(o){if(e!==this.attempt)return;let n=Bt(o),s=Qt(o);this.setState("error"),this.emit("error",{kind:n,retryable:!0,detail:s===void 0?{phase:"acquiring"}:{phase:"acquiring",name:s}})}}}resumePlayback(){let t=this.opts.video,e=this.videoTrack();if(this.stream===null||e===null||e.readyState!=="live"||t.srcObject!==this.stream)return null;try{return Promise.resolve(t.play()).then(()=>this.framesNow(),()=>!1)}catch{return null}}framesNow(){let t=this.opts.video;return this.opts.hasFrames!==void 0?this.opts.hasFrames(t):!t.paused&&t.readyState>=2&&t.videoWidth>0}watchFrames(t){let e=this.opts.firstFrameMs??Ae;e<=0||(this.clearFrameWatch(),this.frameWatch=setTimeout(()=>{if(this.frameWatch=null,!(t!==this.attempt||this.state!=="positioning")){if(this.framesNow()&&this.blackTicks<Ee){this.reopened=!1;return}this.cameraDead(t)}},e))}clearFrameWatch(){this.frameWatch!==null&&clearTimeout(this.frameWatch),this.frameWatch=null}watchEnded(t){this.offEnded?.(),this.offEnded=null;let e=this.videoTrack();if(e===null||typeof e.addEventListener!="function")return;let o=()=>{t===this.attempt&&(this.state==="positioning"||this.state==="acquiring")&&this.cameraDead(t)};e.addEventListener("ended",o),this.offEnded=()=>e.removeEventListener?.("ended",o)}cameraDead(t){if(t!==this.attempt)return;let e=this.videoTrack(),o=e!==null&&e.readyState==="live"&&!e.muted&&this.opts.video.paused&&!this.framesNow();if(!o&&!this.reopened){this.reopened=!0,this.start();return}this.attempt+=1,this.timer!==null&&(this.opts.clearTimer??clearTimeout)(this.timer),this.timer=null,this.clearFrameWatch(),o||this.releaseStream(),this.reopened=!1,this.setState("error"),this.emit("error",{kind:"generic",retryable:!0,detail:{phase:"acquiring"}})}releaseStream(){if(this.offEnded?.(),this.offEnded=null,this.stream)for(let t of this.stream.getTracks())t.stop();this.stream=null,this.opts.video.srcObject!==null&&this.opts.video.srcObject!==void 0&&(this.opts.video.srcObject=null)}rearm(t){t!==void 0&&(this.opts.side=t),this.gate.reset(),this.resetSide(),this.feedback.reset(),this.lastFeedbackKey=null,this.lastGuidance=null,this.capturing=!1,this.stillRefusals=0,this.state==="captured"&&(this.setState("positioning"),this.scheduleTick(this.attempt))}async captureNow(){if(this.state!=="positioning"||this.capturing)return;let t=this.opts.video,e=this.lastDetect?.width??Math.max(1,t.videoWidth),o=this.lastDetect?.height??Math.max(1,t.videoHeight),n=this.lastQuad??this.lastGuideQuad??{topLeft:{x:0,y:0},topRight:{x:e,y:0},bottomRight:{x:e,y:o},bottomLeft:{x:0,y:o}},s=(this.opts.now??(()=>performance.now()))(),r=this.feedback.force("processing",s);this.lastFeedbackKey=r.key,this.emit("feedback",r),await this.fire(this.attempt,this.lastOcrReady!==null?this.lastOcrReady.quad:n,{width:e,height:o,tickSharpness:this.lastDetect?.tickSharpness??0},this.lastOcrReady?.via??"manual")}captureReport(){let t=this.stats;return{...this.opts.side!==void 0?{side:this.opts.side}:{},format:this.opts.format??"ID-1",deviceClass:this.deviceClass,video:{width:this.opts.video.videoWidth||0,height:this.opts.video.videoHeight||0},zoom:this.zoom,...t.zoomFallbackAtMs!==void 0?{zoomFallbackAtMs:t.zoomFallbackAtMs}:{},...t.msToCapture!==void 0?{msToCapture:t.msToCapture}:{},...t.via!==void 0?{via:t.via}:{},...t.shutterAtMs!==void 0?{shutterAtMs:t.shutterAtMs}:{},...t.shutterReason!==void 0?{shutterReason:t.shutterReason}:{},ticks:t.ticks,quadFraming:{...t.quadFraming},qualityBlockers:{...t.qualityBlockers},guideBlockers:{...t.guideBlockers},stillRefusals:t.stillRefusals,...this.ocrReport()}}ocrReport(){let t=this.opts.ocr;if(t===void 0)return{};let e=(this.opts.format??"ID-1")==="ID-3"||this.opts.side==="single"?"single":this.opts.side==="verso"?"verso":"recto",o=t.report(e,this.stats.via,(this.opts.now??(()=>performance.now()))());return o===null?{}:{ocr:o}}static freshStats(){return{ticks:0,quadFraming:{},qualityBlockers:{},guideBlockers:{},stillRefusals:0}}setGuide(t){t===void 0?delete this.opts.guide:this.opts.guide=t,this.guideLock.reset()}guideRegion(t){let e=t.width/Math.max(1,t.height),o=this.opts.guide;if(o!==void 0&&o.viewAspect>0){let c={width:o.viewAspect,height:1},a={x:o.rect.x*o.viewAspect,y:o.rect.y,width:o.rect.width*o.viewAspect,height:o.rect.height};return Re(c,a,e,0)}let n=Yt(this.opts.format??"ID-1").center,s=.86,r=s*e/n;return r>.84&&(r=.84,s=r*n/e),{x:(1-s)/2,y:(1-r)/2,width:s,height:r}}resetSide(){this.positioningSince=null,this.detectedSince=null,this.lastSeenAt=null,this.guideLock.reset(),this.lastGuideQuad=null,this.lastOcrReady=null,this.opts.ocr?.reset(),this.stats=i.freshStats(),this.shutterOffered&&(this.shutterOffered=!1,this.emit("shutter",{available:!1}))}withdrawShutter(){this.shutterOffered&&(this.shutterOffered=!1,this.emit("shutter",{available:!1}))}zoomFallback(t){let e=this.videoTrack();if(e===null||this.zoom<=1)return;let o=this.focusCaps(),n=typeof o?.zoom?.min=="number"?Math.max(o.zoom.min,1):1;this.zoom=n,this.stats.zoomFallbackAtMs=Math.round(t-(this.positioningSince??t)),this.guideLock.reset(),this.gate.reset(),e.applyConstraints({advanced:[{zoom:n}]}).catch(()=>{})}offerShutter(t,e){this.shutterOffered||(this.shutterOffered=!0,this.stats.shutterAtMs=Math.round(e-(this.positioningSince??e)),this.stats.shutterReason=t,this.emit("shutter",{available:!0,reason:t}))}torchAvailable(){try{return this.stream?.getVideoTracks?.()[0]?.getCapabilities?.()?.torch===!0}catch{return!1}}async setTorch(t){this.torchOn=t;try{await this.stream?.getVideoTracks?.()[0]?.applyConstraints({advanced:[{torch:t}]})}catch{}}destroy(){if(this.attempt+=1,this.timer!==null&&(this.opts.clearTimer??clearTimeout)(this.timer),this.timer=null,this.clearFrameWatch(),this.offEnded?.(),this.offEnded=null,this.stream)for(let t of this.stream.getTracks())t.stop();this.stream=null,this.opts.video.srcObject=null}async upgradeResolution(){try{let t=this.stream?.getVideoTracks?.()[0];if(t===void 0)return;let e=t.getSettings?.()??{},o=de(t.getCapabilities?.(),{width:e.width??0,height:e.height??0},this.deviceClass,{width:this.camera.width,height:this.camera.height});o!==null&&await t.applyConstraints(o)}catch{}}focusCaps(){try{return this.videoTrack()?.getCapabilities?.()??null}catch{return null}}async applyFocusAndZoom(){let t=this.videoTrack();if(t===null)return;let e=this.focusCaps();this.camera.continuousFocus&&rt(e,"continuous")&&await t.applyConstraints({advanced:[{focusMode:"continuous"}]}).catch(()=>{});let o={width:0,height:0};try{let s=t.getSettings?.()??{};o={width:s.width??0,height:s.height??0}}catch{}let n=Se(e,o,this.opts.format??"ID-1",this.camera);if(n>1)try{await t.applyConstraints({advanced:[{zoom:n}]}),this.zoom=n}catch{this.zoom=1}}async focusAt(t,e){let o=this.videoTrack(),n=Mt(this.focusCaps(),t,e);if(!(o===null||n===null))try{await o.applyConstraints({advanced:[n]}),(this.opts.setTimer??setTimeout)(()=>{this.restoreContinuous()},1500)}catch{}}async restoreContinuous(){let t=this.videoTrack();t===null||!this.camera.continuousFocus||!rt(this.focusCaps(),"continuous")||await t.applyConstraints({advanced:[{focusMode:"continuous"}]}).catch(()=>{})}async refocusOn(t,e){let o=this.camera.refocusBeforePhotoMs,n=this.videoTrack();if(o<=0||n===null||e.width<=0||e.height<=0)return;let s=E(t),r=Mt(this.focusCaps(),(s.x+s.width/2)/e.width,(s.y+s.height/2)/e.height);if(r!==null)try{await n.applyConstraints({advanced:[r]});let c=this.opts.setTimer??setTimeout;await new Promise(a=>{c(()=>a(),o)})}catch{}}videoTrack(){try{return this.stream?.getVideoTracks?.()[0]??null}catch{return null}}async takeStill(t,e,o){if(this.opts.captureStill!==void 0)return this.opts.captureStill(this.opts.video,t,e);let n=this.opts.format??"ID-1",s=this.videoTrack();if(o&&this.opts.photoCapture!==!1&&this.deviceClass!=="LOW"&&!this.torchOn&&s!==null&&Me(s)){await this.refocusOn(t,e);let r=await xe(this.opts.video,t,e,n,{track:s,detect:this.detector(),detectWidth:et});if(this.restoreContinuous(),r!==null)return r}return De(this.opts.video,t,e,n)}detector(){return this.opts.detect??((this.opts.format??"ID-1")==="ID-3"?si:ni)}setState(t){this.state=t,this.emit("statechange",{state:t})}scheduleTick(t){let e=this.opts.setTimer??setTimeout;this.timer=e(()=>{this.tick(t)},this.cadenceMs)}async tick(t){if(t!==this.attempt||this.state!=="positioning"||this.capturing)return;let e=this.opts.now??(()=>performance.now()),o=this.opts.grabDetectFrame??Pe,n=this.detector(),s=o(this.opts.video,et);if(s===null){this.scheduleTick(t);return}if(!this.lit){if(dt(s)>ri)this.lit=!0,this.blackTicks=0;else if(++this.blackTicks>=Ee&&this.frameWatch===null&&(this.opts.firstFrameMs??Ae)>0){this.cameraDead(t);return}}let r=null;try{r=await n(s)}catch{r=null}if(t!==this.attempt)return;let c=r!==null?lt(s,r):s,a=e(),l={sharpness:j(c),exposure:jt(c),meanLuma:dt(c),specularFraction:re(c)},u=ae({format:this.opts.format??"ID-1",quad:r,frameWidth:s.width,frameHeight:s.height,measures:l,...this.opts.thresholds!==void 0?{thresholds:this.opts.thresholds}:{}}),d=this.gate.tick({timestampMs:a,quad:r,quality:l,frameWidth:s.width,frameHeight:s.height}),h=(this.opts.format??"ID-1")!=="ID-3"?Fe(s,this.guideRegion(s),{edgePeakFrac:this.guideTuning.edgePeakFrac}):Z,f=this.guideLock.tick(h,a);this.lastGuideQuad=f.detected?Ce(h):null;let g=this.capturing?null:this.ocrTick(s,r,h,f.detected,u,a);this.positioningSince??(this.positioningSince=a);let y=this.stats;if(y.ticks+=1,y.quadFraming[u.framing]=(y.quadFraming[u.framing]??0)+1,u.framing==="ok"&&!d.ready){let _=u.lighting!=="ok"?u.lighting:u.glare!=="ok"?"glare":u.blur!=="ok"?"blurry":"steadying";y.qualityBlockers[_]=(y.qualityBlockers[_]??0)+1}y.guideBlockers[f.blocker]=(y.guideBlockers[f.blocker]??0)+1,r!==null||f.detected?(this.detectedSince??(this.detectedSince=a),this.lastSeenAt=a):this.detectedSince=null,this.lastSeenAt!==null&&a-this.lastSeenAt<=fi?a-this.positioningSince>=this.shutterTuning.manualShutterMs?this.offerShutter("timeout",a):g?.suspendQuality!==!0&&this.detectedSince!==null&&a-this.detectedSince>=this.shutterTuning.detectedNoLockMs&&this.offerShutter("detected_no_lock",a):this.withdrawShutter();let O=a-(this.lastSeenAt??this.positioningSince);this.zoom>1&&this.camera.zoomFallbackMs>0&&O>=this.camera.zoomFallbackMs&&this.zoomFallback(a),this.emit("checks",{engine:"docv1",p:d.p,plausible:d.plausible,stableTicks:d.stableTicks,quad:d.quad,frameWidth:s.width,frameHeight:s.height,analysis:u,ready:g?.suspendQuality!==!0&&(d.ready&&r!==null||f.ready&&this.lastGuideQuad!==null)||this.lastOcrReady!==null,guide:{detected:f.detected,blocker:f.blocker,fill:h.fill,shape:h.shape,content:h.content,offsetX:h.offsetX,offsetY:h.offsetY},...g!==null&&g.mode!=="off"?{ocr:{mode:g.mode,...g.mrz?{mrz:g.mrz}:{},...g.lock?{lock:g.lock}:{}}}:g?.mrz?{ocr:{mode:g.mode,mrz:g.mrz}}:{}}),this.lastQuad=d.plausible?r:null,this.lastDetect={width:s.width,height:s.height,tickSharpness:l.sharpness};let v=ne(u);u.framing!=="ok"&&f.detected&&(v=mi(f.blocker,h.brightness<this.guideTuning.darkBrightness)),v==="blurry"&&r!==null&&li(r,s,this.opts.format??"ID-1")>=this.camera.focusFarFillFrac&&(v="focus_far"),v==="sensing"&&this.zoom>1&&this.camera.noDocFarHintMs>0&&O>=this.camera.noDocFarHintMs&&(v="focus_far");let x=this.feedback.tick(v,a);if(x.key!==this.lastFeedbackKey&&(this.lastFeedbackKey=x.key,this.emit("feedback",x)),d.guidanceKey!==this.lastGuidance&&(this.lastGuidance=d.guidanceKey,this.emit("guidance",{key:d.guidanceKey})),this.capturing)return;let M=g?.suspendQuality!==!0,T=M&&d.ready&&r!==null,k=M&&f.ready&&this.lastGuideQuad!==null,C=this.lastOcrReady;if(C!==null&&this.opts.autoCapture!==!1){let _=this.feedback.force("processing",a);this.lastFeedbackKey=_.key,this.emit("feedback",_);let A=j(lt(s,C.quad));await this.fire(t,C.quad,{width:s.width,height:s.height,tickSharpness:A},C.via);return}if((T||k)&&this.opts.autoCapture!==!1){let _=this.feedback.force("processing",a);this.lastFeedbackKey=_.key,this.emit("feedback",_);let A=k?this.lastGuideQuad:r,B=k?f.via==="steady"?"guide_steady":"guide_good":"quad",U=k?j(lt(s,A)):l.sharpness;await this.fire(t,A,{width:s.width,height:s.height,tickSharpness:U},B);return}this.scheduleTick(t)}async fire(t,e,o,n){this.capturing=!0;let s=this.opts.grabDetectFrame??Pe,r=this.opts.setTimer??setTimeout,c={width:o.width,height:o.height};try{let a={still:await this.takeStill(e,c,!0),sharpness:o.tickSharpness};if(t!==this.attempt)return;let l=a.still.source==="photo"?0:ui;for(let m=0;m<l;m++){if(await new Promise(g=>{r(()=>g(),hi)}),t!==this.attempt)return;let h=s(this.opts.video,et);if(h===null)continue;let f=j(lt(h,e));if(f>a.sharpness*di){let g=await this.takeStill(e,c,!1);if(t!==this.attempt)return;a={still:g,sharpness:f}}}if(t!==this.attempt)return;let u=a.still.sharpness;if(this.opts.autoCapture!==!1&&n!=="manual"&&typeof u=="number"&&u>=0&&u<this.camera.stillSharpnessMin&&this.stillRefusals<this.camera.stillRefusalsMax){this.stillRefusals+=1,this.stats.stillRefusals+=1,this.guideLock.reset(),this.lastOcrReady=null,(n==="text_lock"||n==="live_mrz")&&this.opts.ocr?.rearmFace();let m=(this.opts.now??(()=>performance.now()))(),h=this.feedback.force("focus_far",m);this.lastFeedbackKey=h.key,this.emit("feedback",h),this.capturing=!1,this.gate.reset(),this.scheduleTick(t);return}this.stillRefusals=0;let d=(this.opts.now??(()=>performance.now()))();this.stats.via=n,this.stats.msToCapture=Math.round(d-(this.positioningSince??d)),this.shutterOffered&&(this.shutterOffered=!1,this.emit("shutter",{available:!1})),this.setState("captured"),this.emit("artifacts",{keyframe:a.still.blob,previewDataUrl:a.still.previewDataUrl,...this.opts.side!==void 0?{side:this.opts.side}:{},...a.still.docRegion!==void 0?{docRegion:a.still.docRegion}:{},...(()=>{let m=n==="live_mrz"?this.opts.ocr?.liveCapture():null;return m?{liveMrz:m}:{}})()})}catch{if(t!==this.attempt)return;this.capturing=!1,this.gate.reset(),this.guideLock.reset(),this.lastOcrReady=null,(n==="text_lock"||n==="live_mrz")&&this.opts.ocr?.rearmFace(),this.scheduleTick(t)}}ocrTick(t,e,o,n,s,r){let c=this.opts.ocr,a=this.opts.video;if(c===void 0||!c.hasEngine)return this.lastOcrReady=null,null;let l=a.videoWidth,u=a.videoHeight;if(l<=0||u<=0||t.width<=0||t.height<=0)return null;let m=(this.opts.format??"ID-1")==="ID-3",h=this.guideRegion(t),f={x:h.x*l,y:h.y*u,w:h.width*l,h:h.height*u},g=l/t.width,y=u/t.height,D;m&&e!==null?D=ci(E(e),g,y,l,u):D=te(f,c.bandTop,u);let w=m?s.glare==="ok":o.cardGlare<=this.guideTuning.glareMax,O=m?s.blur==="ok":o.sharpness>=this.guideTuning.sharpnessMin,v=c.tick({atMs:r,video:a,mrzFace:m||this.opts.side==="verso"||this.opts.side==="single",present:m||e!==null||n,card:f,band:D,portrait:u>l,glareOk:w,sharpOk:O});if(v.ready&&v.via!==void 0){let x=m?e??Oe(h,t):this.lastGuideQuad??Oe(h,t);this.lastOcrReady={quad:x,via:v.via}}else this.lastOcrReady=null;return v}};function ci(i,t,e,o,n){let s=Math.min(o,i.width*1.06*t),r=Math.min(n,Math.max(i.height*1.6*e,s/5)),c=(i.y+i.height/2)*e,a=Math.max(0,Math.min(o-s,(i.x-i.width*.03)*t)),l=Math.max(0,Math.min(n-r,c-r/2));return{x:a,y:l,w:s,h:r}}function Oe(i,t){let e=i.x*t.width,o=i.y*t.height,n=(i.x+i.width)*t.width,s=(i.y+i.height)*t.height;return{topLeft:{x:e,y:o},topRight:{x:n,y:o},bottomRight:{x:n,y:s},bottomLeft:{x:e,y:s}}}function li(i,t,e){let o=E(i);return t.width<=0||t.height<=0?0:e==="ID-3"?o.width/t.width:o.width*o.height/(t.width*t.height)}var ui=2,hi=260,di=1.08;function Pe(i,t){let e=i.videoWidth,o=i.videoHeight;if(e===0||o===0)return null;let n=Math.min(1,t/e),s=Math.round(e*n),r=Math.round(o*n),c=document.createElement("canvas");c.width=s,c.height=r;let a=c.getContext("2d",{willReadFrequently:!0});return a===null?null:(e/Math.max(1,s)>4&&(a.imageSmoothingQuality="high"),a.drawImage(i,0,0,s,r),a.getImageData(0,0,s,r))}function lt(i,t){let e=[t.topLeft.x,t.topRight.x,t.bottomRight.x,t.bottomLeft.x],o=[t.topLeft.y,t.topRight.y,t.bottomRight.y,t.bottomLeft.y],n=Math.max(0,Math.floor(Math.min(...e))),s=Math.max(0,Math.floor(Math.min(...o))),r=Math.min(i.width,Math.ceil(Math.max(...e))),c=Math.min(i.height,Math.ceil(Math.max(...o))),a=Math.max(1,r-n),l=Math.max(1,c-s),u=new Uint8ClampedArray(a*l*4);for(let d=0;d<l;d++){let m=((s+d)*i.width+n)*4;u.set(i.data.subarray(m,m+a*4),d*a*4)}return{data:u,width:a,height:l,colorSpace:i.colorSpace}}function mi(i,t){return i==="glare"?"glare":i==="too_small"?"too_far":i==="too_big"?"too_close":t?"too_dark":i==="blurry"?"blurry":i==="off_center"?"edge_clipped":i==="no_card"?"sensing":"hold_still"}var fi=1200;export{it as a,ne as b,ot as c,Xe as d,re as e,je as f,ae as g,st as h,Si as i,bt as j,ii as k,we as l,rt as m,Mt as n,_i as o,Se as p,oi as q,Te as r,Z as s,Re as t,Fe as u,Ce as v,J as w,Ai as x,ct as y,ji as z,Ae as A,ri as B,Ee as C,ai as D,kt as E,Yi as F,Le as G,ci as H,ui as I,hi as J};
@@ -1 +1 @@
1
- "use strict";var g=Object.defineProperty;var W=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var G=Object.prototype.hasOwnProperty;var b=(t,e)=>()=>(t&&(e=t(t=0)),e);var I=(t,e)=>{for(var n in e)g(t,n,{get:e[n],enumerable:!0})},z=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of j(e))!G.call(t,o)&&o!==n&&g(t,o,{get:()=>e[o],enumerable:!(i=W(e,o))||i.enumerable});return t};var J=t=>z(g({},"__esModule",{value:!0}),t);var v=b(()=>{"use strict"});function _(t,e){return new Promise(n=>{let i=setTimeout(()=>n(void 0),e),o=r=>{clearTimeout(i),n(r)};try{t().then(o,()=>o(void 0))}catch{o(void 0)}})}async function M(t){let e=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(JSON.stringify(t)));return Array.from(new Uint8Array(e).subarray(0,8),n=>n.toString(16).padStart(2,"0")).join("")}var R=b(()=>{"use strict";v()});var O={};I(O,{computePrint:()=>de,readHints:()=>x});function E(t,e){if(typeof t!="string")return;let n=t.trim();return n.length>0&&n.length<=e?n:void 0}async function x(){let t=navigator.userAgentData;if(typeof t?.getHighEntropyValues!="function")return;let e=await _(()=>t.getHighEntropyValues(["model","platformVersion"]),te);if(e==null)return;let n=E(e.model,ie),i=E(e.platformVersion,oe),o={...n!==void 0?{model:n}:{},...i!==void 0?{platformVersion:i}:{}};return Object.keys(o).length>0?o:void 0}async function ae(){let[t,e]=await Promise.all([new A.Thumbmark({stabilize:["private","iframe"],exclude:["permissions","webrtc","speech"],logging:!1,collect_beacon:!1,timeout:Q}).get(),x()]),n=t?.thumbmark;if(typeof n!="string"||n.length<re||n.length>se)return;let i={};for(let o of Z){let r=t.components?.[o];r==null||r.timeout==="true"||(i[o]=await M(r))}return{hash:n,c:i,...e!==void 0?{hints:e}:{}}}function ce(){return new Promise(t=>{typeof globalThis.requestIdleCallback=="function"?globalThis.requestIdleCallback(()=>t(),{timeout:ne}):t()})}async function de(t){return t()||(await ce(),t())?"busy":_(ae,ee)}var A,Z,Q,ee,te,ne,ie,oe,re,se,H=b(()=>{"use strict";A=require("@thumbmarkjs/thumbmarkjs");R();Z=["canvas","webgl","audio","fonts","hardware","screen","system","locales","math","plugins"],Q=2e3,ee=4e3,te=1e3,ne=2e3,ie=64,oe=32,re=8,se=128});var Me={};I(Me,{HostedApiError:()=>u,HostedClient:()=>h,KNOWN_CODES:()=>P,SEKYRO_SDK_HEADER:()=>k,icaoPolicyOf:()=>B,isInAppBrowser:()=>y,isKnownCode:()=>F,portraitIcaoGate:()=>q,stripMimeParams:()=>p});module.exports=J(Me);var f="0.1.0-rc.20";var X=/FBAN|FBAV|FB_IAB|FBIOS|MessengerForiOS|Instagram|WhatsApp|musical_ly|BytedanceWebview|TikTok|Snapchat|\bLine\/|LinkedInApp|Pinterest|MicroMessenger|; wv\)/i;function y(t){let e=t??(typeof navigator>"u"?"":String(navigator.userAgent??""));return X.test(e)}var N="sekyro.did",ue=1e4,le=()=>globalThis.process?.versions?.node,D;function V(){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,n=>n.toString(16).padStart(2,"0")).join("")}}catch{}}function pe(){try{let t=localStorage.getItem(N);if(t)return t;let e=V();return e!==void 0&&localStorage.setItem(N,e),e}catch{return D??(D=V()),D}}async function me(){let t=globalThis.crypto?.subtle;if(!t)return"";let e=navigator,n=JSON.stringify([e.userAgent,e.platform,e.hardwareConcurrency??null,e.deviceMemory??null,e.maxTouchPoints??0,screen.width,screen.height,screen.colorDepth,globalThis.devicePixelRatio??1,Intl.DateTimeFormat().resolvedOptions().timeZone,e.languages?.join(",")??e.language]),i=await t.digest("SHA-256",new TextEncoder().encode(n));return Array.from(new Uint8Array(i),o=>o.toString(16).padStart(2,"0")).join("").slice(0,32)}function fe(t){let e=new TextEncoder().encode(t),n="";for(let i of e)n+=String.fromCharCode(i);return btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function ye(t){let e,n,i,o,r,c,d=()=>c?.readyState==="live",s=()=>{r!==void 0||!globalThis.crypto?.subtle||le()||d()||(r=Promise.race([Promise.resolve().then(()=>(H(),O)),new Promise(a=>setTimeout(a,ue))]).then(a=>a?.computePrint(d)).then(a=>{a==="busy"?r=void 0:o=a}).catch(()=>{}))};return{timezone(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone?.slice(0,64)||void 0}catch{return}},noteCameraLabel(a){a&&(e=a.slice(0,128))},noteCamera(a){n=a},noteCameraTrack(a){c=a},async deviceHeader(){try{i??(i=me().catch(()=>""));let a=[];navigator.webdriver&&a.push("webdriver"),/HeadlessChrome/.test(navigator.userAgent)&&a.push("headless");let l=await i,m=pe(),$={v:1,platform:"web",sdk:t.sdk.slice(0,64),ids:[...m?[{kind:"web_local",value:m.slice(0,128)}]:[],...l?[{kind:"web_fp",value:l}]:[]],screen:{w:screen.width,h:screen.height,dpr:globalThis.devicePixelRatio??1},...e?{cameraLabel:e}:{},...a.length?{signals:a}:{},...o?{print:{v:2,...o,...n?{camera:n}:{}}}:{},...y()?{inApp:!0}:{}},Y=fe(JSON.stringify($));return s(),Y}catch{return}},printReady(){return r??Promise.resolve()}}}var T=Symbol.for("sekyro.web.clientContext"),S=globalThis,w=S[T]??(S[T]=ye({sdk:`@sekyro/web@${f}`}));var P=["session_token_invalid","session_token_required","session_token_session_mismatch","session_not_found","rate_limit_exceeded","consent_required","session_not_active","check_not_found","check_already_finalized","check_out_of_order","check_type_unsupported","force_outcome_forbidden","attestation_invalid","platform_unregistered","app_attest_invalid","too_many_challenges","inference_unavailable","mobile_required","nni_locked","document_nni_mismatch","media_content_type_not_allowed","media_too_large","media_key_invalid","media_key_forbidden","media_not_found","media_unreadable","media_session_invalid","idempotency_key_collision","idempotency_in_progress","idempotency_key_required","validation_error","internal_error","unknown_error","upload_failed","network_error","timeout","nfc_outcome_not_accepted","identity_confirm_required","identity_confirm_locked","choice_not_found","choice_locked","choice_option_unavailable","step_not_on_path","check_not_active","sekyro_app_not_allowed","sekyro_app_unverified","id_number_locked","document_id_number_mismatch"];function F(t){return P.includes(t)}var u=class extends Error{constructor(e){super(e.message),this.name="HostedApiError",this.status=e.status,this.code=e.code,e.retryAfterSeconds!==void 0&&(this.retryAfterSeconds=e.retryAfterSeconds),e.details&&(this.details=e.details)}};function L(t,e,n=Math.random){let i=(t??e)*1e3,o=Math.min(Math.max(i,500),2e4),r=Math.round(o*(1+(n()*2-1)*.25));return Math.min(Math.max(r,500),2e4)}var he=6e4,U=4,ge=3e4,be=9e5,_e=200,Te=5,Se=400,we=new Set(["server_busy","request_timeout"]),Pe=2;function p(t){return(t.split(";")[0]??"").trim()}var Ce={liveness:"clipKey",face_match:"imageKey",doc_ocr:"imageKey"},k=`@sekyro/web/${f}`,ke=k,h=class{constructor(e){this.sessionId=null;this.bootstrap=null;this.captureNonces=[];this.captureFetch=null;this.reportedIssues=new Map;this.apiOrigin=e.apiOrigin.replace(/\/+$/,""),this.sessionToken=e.sessionToken;let n=e.fetch;this.fetchImpl=(i,o)=>(n??globalThis.fetch).call(globalThis,i,o),this.requestTimeoutMs=e.requestTimeoutMs??ge,this.retryAttempts=e.inProgressRetry?.attempts??Te,this.retryDelayMs=e.inProgressRetry?.delayMs??Se,this.random=e.random??Math.random}async getSession(){let e=await this.api("GET","/hosted/session");return this.sessionId=e.sessionId,e}async recordConsent(e){return this.api("POST","/hosted/consent",{body:{locale:e},busyRetry:!0})}async reportCameraUnavailable(e){return this.api("POST","/hosted/camera-unavailable",{body:{cause:e}})}async reportCaptureIssue(e){let n=typeof e.name=="string"?e.name.replace(/[^A-Za-z]/g,"").slice(0,40):"",i=typeof e.engineKind=="string"&&/^[a-z_]{1,32}$/.test(e.engineKind)?e.engineKind:void 0,o=typeof e.attempt=="number"&&Number.isInteger(e.attempt)&&e.attempt>=0&&e.attempt<=1e3?e.attempt:void 0,r=[e.check,o??"",e.kind,n,e.phase??""].join("|"),c=this.reportedIssues.get(r);if(c!==void 0)return c;let d={check:e.check,kind:e.kind,...n!==""?{name:n}:{},...e.phase!==void 0?{phase:e.phase}:{},...i!==void 0?{engineKind:i}:{},...o!==void 0?{attempt:o}:{},...e.formFactor!==void 0?{formFactor:e.formFactor}:{}},s=this.api("POST","/hosted/capture-issue",{body:d,empty:!0}).catch(()=>{this.reportedIssues.delete(r)});return this.reportedIssues.set(r,s),s}async choose(e,n){let i=await this.api("POST","/hosted/choice",{body:{nodeId:e,option:n},busyRetry:!0});return this.sessionId=i.sessionId,i}async confirmIdentity(e){return this.api("POST","/hosted/identity/confirm",{body:{decision:e}})}async identityPortrait(){return this.api("GET","/hosted/identity/portrait",{blob:!0})}async presign(e,n,i,o={}){let r=await this.ensureSessionId(),c={kind:e,contentType:p(n),contentLength:i,...o.source==="upload"?{source:"upload"}:{}};return this.api("POST",`/sessions/${r}/media`,{body:c})}armCapture(e=2){this.fillCaptureNonces(e)}async presignCapture(e,n,i,o={}){let r=await this.ensureSessionId(),c=await this.takeCaptureNonce(),d=c===void 0?void 0:{nonce:c,...o.engine!==void 0?{engine:o.engine.slice(0,32)}:{},...o.durationMs!==void 0&&Number.isFinite(o.durationMs)?{captureMs:Math.min(36e5,Math.max(0,Math.round(o.durationMs)))}:{}},s={kind:e,contentType:p(n),contentLength:i,capture:d};return this.api("POST",`/sessions/${r}/media`,{body:s})}async takeCaptureNonce(){let e=()=>{let n=Date.now();return this.captureNonces=this.captureNonces.filter(i=>i.expiresAt-he>n),this.captureNonces.shift()?.nonce};for(let n=0;n<2;n++){let i=e();if(i!==void 0)return i;await this.fillCaptureNonces(1)}return e()}fillCaptureNonces(e){return this.captureFetch??(this.captureFetch=(async()=>{try{let n=await this.ensureSessionId(),i=await this.api("POST",`/sessions/${n}/media/capture-nonces`,{body:{count:Math.min(U,Math.max(1,e))}}),o=Date.now()+Math.max(0,i.expiresIn)*1e3;for(let r of Array.isArray(i.nonces)?i.nonces:[])typeof r=="string"&&r.length>0&&this.captureNonces.push({nonce:r,expiresAt:o});this.captureNonces=this.captureNonces.slice(-U)}catch{}})().finally(()=>{this.captureFetch=null})),this.captureFetch}async uploadToSpaces(e,n,i){let o;try{o=await this.fetchImpl(e,{method:"PUT",headers:{"content-type":p(i)},body:n,signal:AbortSignal.timeout(be)})}catch(r){throw C(r)}if(!o.ok){let r=(await o.text().catch(()=>"")).slice(0,_e);throw new u({status:o.status,code:"upload_failed",message:`media upload failed (HTTP ${o.status})${r?`: ${r}`:""}`})}}async completeMedia(e){let n=await this.ensureSessionId();return this.api("POST",`/sessions/${n}/media/complete`,{body:{key:e}})}async submitCheck(e,n,i={}){let o=await this.ensureSessionId(),r={input:n,forceOutcome:i.forceOutcome};return this.api("POST",`/sessions/${o}/checks/${e}`,{body:r,idempotencyKey:i.idempotencyKey,busyRetry:i.idempotencyKey!==void 0})}async uploadAndSubmit(e,n,i,o={}){let r=p(n.contentType),c=await this.presign(n.kind,r,n.blob.size);await this.uploadToSpaces(c.uploadUrl,n.blob,r);let d=await this.completeMedia(c.key),s={...i,[Ce[e]]:d.key};return this.submitCheck(e,s,o)}async ensureSessionId(){return this.sessionId!==null?this.sessionId:(this.bootstrap??(this.bootstrap=this.getSession().finally(()=>{this.bootstrap=null})),(await this.bootstrap).sessionId)}async api(e,n,i={}){let o=e==="GET"||i.busyRetry===!0,r=`${this.apiOrigin}/api/v2${n}`,c={"x-session-token":this.sessionToken,"x-sekyro-sdk":ke};i.body!==void 0&&(c["content-type"]="application/json"),i.idempotencyKey!==void 0&&(c["x-idempotency-key"]=i.idempotencyKey);try{let d=w.timezone();d!==void 0&&(c["sekyro-client-timezone"]=d)}catch{}try{let d=await w.deviceHeader();d!==void 0&&(c["sekyro-client-device"]=d)}catch{}for(let d=0;;d++){let s;try{s=await this.fetchImpl(r,{method:e,headers:c,...i.body!==void 0?{body:JSON.stringify(i.body)}:{},cache:"no-store",signal:AbortSignal.timeout(this.requestTimeoutMs)})}catch(l){throw C(l)}if(s.ok){if(i.empty===!0)return;if(i.blob===!0)try{return await s.blob()}catch(m){throw C(m)}let l;try{l=await s.json()}catch{throw new u({status:s.status,code:"unknown_error",message:`response body was not valid JSON (HTTP ${s.status})`})}return Ie(l)}let a=await ve(s);if(a.code==="idempotency_in_progress"&&d<this.retryAttempts){this.retryDelayMs>0&&await K(this.retryDelayMs);continue}if(o&&a.status===503&&we.has(a.code)){o=!1,await K(L(a.retryAfterSeconds,Pe,this.random));continue}throw a}}};function C(t){if((typeof t=="object"&&t!==null?t.name:void 0)==="TimeoutError")return new u({status:0,code:"timeout",message:"request timed out"});let n=t instanceof Error?t.message:String(t);return new u({status:0,code:"network_error",message:`network request failed: ${n}`})}function Ie(t){return t!==null&&typeof t=="object"&&"success"in t&&"data"in t?t.data:t}async function ve(t){let e="unknown_error",n=`request failed (HTTP ${t.status})`,i=Number.NaN,o;try{let d=await t.json();if(d!==null&&typeof d=="object"){let s=d;typeof s.code=="string"&&s.code.length>0&&(e=s.code),typeof s.message=="string"&&s.message.length>0&&(n=s.message),typeof s.retryAfterSeconds=="number"&&(i=s.retryAfterSeconds),Array.isArray(s.details?.issues)&&(o=s.details)}}catch{}let r=t.headers.get("retry-after"),c=r===null?Math.floor(i):Number.parseInt(r,10);return new u({status:t.status,code:e,message:n,...Number.isFinite(c)&&c>=0?{retryAfterSeconds:c}:{},details:o})}function K(t){return new Promise(e=>setTimeout(e,t))}function B(t){let e=t?.portrait,n=e?.icao,i=e?.purpose==="id_document";return n==null?i?{policy:"reject",profile:"id_document"}:null:{policy:n.policy==="alert"?"alert":"reject",profile:i||n.profile==="id_document"?"id_document":"selfie"}}function q(t){return{...t.baselineEyeOpenness!==void 0?{baselineEyeOpenness:t.baselineEyeOpenness}:{},criteria:t.verdict??{},...t.backgroundCheck!==void 0?{backgroundCheck:t.backgroundCheck}:{}}}0&&(module.exports={HostedApiError,HostedClient,KNOWN_CODES,SEKYRO_SDK_HEADER,icaoPolicyOf,isInAppBrowser,isKnownCode,portraitIcaoGate,stripMimeParams});
1
+ "use strict";var g=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var G=Object.getOwnPropertyNames;var z=Object.prototype.hasOwnProperty;var b=(t,e)=>()=>(t&&(e=t(t=0)),e);var M=(t,e)=>{for(var n in e)g(t,n,{get:e[n],enumerable:!0})},X=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of G(e))!z.call(t,o)&&o!==n&&g(t,o,{get:()=>e[o],enumerable:!(i=j(e,o))||i.enumerable});return t};var J=t=>X(g({},"__esModule",{value:!0}),t);var I=b(()=>{"use strict"});function _(t,e){return new Promise(n=>{let i=setTimeout(()=>n(void 0),e),o=r=>{clearTimeout(i),n(r)};try{t().then(o,()=>o(void 0))}catch{o(void 0)}})}async function R(t){let e=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(JSON.stringify(t)));return Array.from(new Uint8Array(e).subarray(0,8),n=>n.toString(16).padStart(2,"0")).join("")}var E=b(()=>{"use strict";I()});var H={};M(H,{computePrint:()=>me,readHints:()=>O});function A(t,e){if(typeof t!="string")return;let n=t.trim();return n.length>0&&n.length<=e?n:void 0}async function O(){let t=navigator.userAgentData;if(typeof t?.getHighEntropyValues!="function")return;let e=await _(()=>t.getHighEntropyValues(["model","platformVersion"]),re);if(e==null)return;let n=A(e.model,ae),i=A(e.platformVersion,ce),o={...n!==void 0?{model:n}:{},...i!==void 0?{platformVersion:i}:{}};return Object.keys(o).length>0?o:void 0}async function le(){let[t,e]=await Promise.all([new x.Thumbmark({stabilize:["private","iframe"],exclude:["permissions","webrtc","speech"],logging:!1,collect_beacon:!1,timeout:ie}).get(),O()]),n=t?.thumbmark;if(typeof n!="string"||n.length<de||n.length>ue)return;let i={};for(let o of ne){let r=t.components?.[o];r==null||r.timeout==="true"||(i[o]=await R(r))}return{hash:n,c:i,...e!==void 0?{hints:e}:{}}}function pe(){return new Promise(t=>{typeof globalThis.requestIdleCallback=="function"?globalThis.requestIdleCallback(()=>t(),{timeout:se}):t()})}async function me(t){return t()||(await pe(),t())?"busy":_(le,oe)}var x,ne,ie,oe,re,se,ae,ce,de,ue,N=b(()=>{"use strict";x=require("@thumbmarkjs/thumbmarkjs");E();ne=["canvas","webgl","audio","fonts","hardware","screen","system","locales","math","plugins"],ie=2e3,oe=4e3,re=1e3,se=2e3,ae=64,ce=32,de=8,ue=128});var Oe={};M(Oe,{HostedApiError:()=>u,HostedClient:()=>h,KNOWN_CODES:()=>P,SEKYRO_SDK_HEADER:()=>k,icaoPolicyOf:()=>q,isInAppBrowser:()=>y,isKnownCode:()=>L,portraitIcaoGate:()=>$,stripMimeParams:()=>p});module.exports=J(Oe);var Z=600;function v(){if(typeof window>"u"||typeof navigator>"u")return"desktop";let t=navigator.userAgentData,e=t?.mobile||/Android|i(Pad)?OS/.test(String(t?.platform)),n=String(navigator.userAgent??"");if(/iPhone|iPod/i.test(n))return"phone";if(/iPad/i.test(n))return"tablet";if(/Android/i.test(n))return/Mobile/i.test(n)?"phone":"tablet";if(/BlackBerry|IEMobile|Opera Mini/i.test(n))return"phone";if(!e){if(Number(navigator.maxTouchPoints??0)<=1)return"desktop";if(/Macintosh/.test(n))return"tablet";if(/Windows NT|CrOS/.test(n)||!ee())return"desktop"}let i=Q();return i>0&&i<Z?"phone":"tablet"}function Q(){try{let t=window.screen,e=Number(t?.width??0),n=Number(t?.height??0);return e>0&&n>0?Math.min(e,n):0}catch{return 0}}function ee(){try{return typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}catch{return!1}}var f="0.1.0-rc.22";var te=/FBAN|FBAV|FB_IAB|FBIOS|MessengerForiOS|Instagram|WhatsApp|musical_ly|BytedanceWebview|TikTok|Snapchat|\bLine\/|LinkedInApp|Pinterest|MicroMessenger|; wv\)/i;function y(t){let e=t??(typeof navigator>"u"?"":String(navigator.userAgent??""));return te.test(e)}var D="sekyro.did",fe=1e4,ye=()=>globalThis.process?.versions?.node,V;function F(){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,n=>n.toString(16).padStart(2,"0")).join("")}}catch{}}function he(){try{let t=localStorage.getItem(D);if(t)return t;let e=F();return e!==void 0&&localStorage.setItem(D,e),e}catch{return V??(V=F()),V}}async function ge(){let t=globalThis.crypto?.subtle;if(!t)return"";let e=navigator,n=JSON.stringify([e.userAgent,e.platform,e.hardwareConcurrency??null,e.deviceMemory??null,e.maxTouchPoints??0,screen.width,screen.height,screen.colorDepth,globalThis.devicePixelRatio??1,Intl.DateTimeFormat().resolvedOptions().timeZone,e.languages?.join(",")??e.language]),i=await t.digest("SHA-256",new TextEncoder().encode(n));return Array.from(new Uint8Array(i),o=>o.toString(16).padStart(2,"0")).join("").slice(0,32)}function be(){try{let t=Number(navigator.maxTouchPoints);return Number.isFinite(t)&&t>=0?{touch:Math.min(64,Math.trunc(t))}:{}}catch{return{}}}function _e(t){let e=new TextEncoder().encode(t),n="";for(let i of e)n+=String.fromCharCode(i);return btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function Se(t){let e,n,i,o,r,a,d=()=>a?.readyState==="live",s=()=>{r!==void 0||!globalThis.crypto?.subtle||ye()||d()||(r=Promise.race([Promise.resolve().then(()=>(N(),H)),new Promise(c=>setTimeout(c,fe))]).then(c=>c?.computePrint(d)).then(c=>{c==="busy"?r=void 0:o=c}).catch(()=>{}))};return{timezone(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone?.slice(0,64)||void 0}catch{return}},noteCameraLabel(c){c&&(e=c.slice(0,128))},noteCamera(c){n=c},noteCameraTrack(c){a=c},async deviceHeader(){try{i??(i=ge().catch(()=>""));let c=[];navigator.webdriver&&c.push("webdriver"),/HeadlessChrome/.test(navigator.userAgent)&&c.push("headless");let l=await i,m=he(),Y={v:1,platform:"web",sdk:t.sdk.slice(0,64),ids:[...m?[{kind:"web_local",value:m.slice(0,128)}]:[],...l?[{kind:"web_fp",value:l}]:[]],screen:{w:screen.width,h:screen.height,dpr:globalThis.devicePixelRatio??1},...be(),...e?{cameraLabel:e}:{},...c.length?{signals:c}:{},...o?{print:{v:2,...o,...n?{camera:n}:{}}}:{},...y()?{inApp:!0}:{}},W=_e(JSON.stringify(Y));return s(),W}catch{return}},printReady(){return r??Promise.resolve()}}}var S=Symbol.for("sekyro.web.clientContext"),T=globalThis,w=T[S]??(T[S]=Se({sdk:`@sekyro/web@${f}`}));var P=["session_token_invalid","session_token_required","session_token_session_mismatch","session_not_found","rate_limit_exceeded","consent_required","session_not_active","check_not_found","check_already_finalized","check_out_of_order","check_type_unsupported","force_outcome_forbidden","attestation_invalid","platform_unregistered","app_attest_invalid","too_many_challenges","inference_unavailable","mobile_required","nni_locked","document_nni_mismatch","media_content_type_not_allowed","media_too_large","media_key_invalid","media_key_forbidden","media_not_found","media_unreadable","media_session_invalid","idempotency_key_collision","idempotency_in_progress","idempotency_key_required","validation_error","internal_error","unknown_error","upload_failed","network_error","timeout","nfc_outcome_not_accepted","identity_confirm_required","identity_confirm_locked","choice_not_found","choice_locked","choice_option_unavailable","step_not_on_path","check_not_active","sekyro_app_not_allowed","sekyro_app_unverified","id_number_locked","document_id_number_mismatch","simulated_capture_forbidden"];function L(t){return P.includes(t)}var u=class extends Error{constructor(e){super(e.message),this.name="HostedApiError",this.status=e.status,this.code=e.code,e.retryAfterSeconds!==void 0&&(this.retryAfterSeconds=e.retryAfterSeconds),e.details&&(this.details=e.details)}};function U(t,e,n=Math.random){let i=(t??e)*1e3,o=Math.min(Math.max(i,500),2e4),r=Math.round(o*(1+(n()*2-1)*.25));return Math.min(Math.max(r,500),2e4)}var Te=6e4,K=4,we=3e4,Pe=9e5,Ce=200,ke=5,Me=400,ve=new Set(["server_busy","request_timeout"]),Ie=2;function p(t){return(t.split(";")[0]??"").trim()}var Re={liveness:"clipKey",face_match:"imageKey",doc_ocr:"imageKey"},k=`@sekyro/web/${f}`,Ee=k,h=class{constructor(e){this.sessionId=null;this.bootstrap=null;this.captureNonces=[];this.captureFetch=null;this.reportedIssues=new Map;this.apiOrigin=e.apiOrigin.replace(/\/+$/,""),this.sessionToken=e.sessionToken;let n=e.fetch;this.fetchImpl=(i,o)=>(n??globalThis.fetch).call(globalThis,i,o),this.requestTimeoutMs=e.requestTimeoutMs??we,this.retryAttempts=e.inProgressRetry?.attempts??ke,this.retryDelayMs=e.inProgressRetry?.delayMs??Me,this.random=e.random??Math.random}async getSession(){let e=await this.api("GET","/hosted/session");return this.sessionId=e.sessionId,e}async recordConsent(e){return this.api("POST","/hosted/consent",{body:{locale:e},busyRetry:!0})}async reportCameraUnavailable(e){return this.api("POST","/hosted/camera-unavailable",{body:{cause:e}})}async reportCaptureIssue(e){let n=typeof e.name=="string"?e.name.replace(/[^A-Za-z]/g,"").slice(0,40):"",i=typeof e.engineKind=="string"&&/^[a-z_]{1,32}$/.test(e.engineKind)?e.engineKind:void 0,o=typeof e.attempt=="number"&&Number.isInteger(e.attempt)&&e.attempt>=0&&e.attempt<=1e3?e.attempt:void 0,r=[e.check,o??"",e.kind,n,e.phase??""].join("|"),a=this.reportedIssues.get(r);if(a!==void 0)return a;let d={check:e.check,kind:e.kind,...n!==""?{name:n}:{},...e.phase!==void 0?{phase:e.phase}:{},...i!==void 0?{engineKind:i}:{},...o!==void 0?{attempt:o}:{},...e.formFactor!==void 0?{formFactor:e.formFactor}:{}},s=this.api("POST","/hosted/capture-issue",{body:d,empty:!0}).catch(()=>{this.reportedIssues.delete(r)});return this.reportedIssues.set(r,s),s}async choose(e,n){let i=await this.api("POST","/hosted/choice",{body:{nodeId:e,option:n},busyRetry:!0});return this.sessionId=i.sessionId,i}async confirmIdentity(e){return this.api("POST","/hosted/identity/confirm",{body:{decision:e}})}async identityPortrait(){return this.api("GET","/hosted/identity/portrait",{blob:!0})}async presign(e,n,i,o={}){let r=await this.ensureSessionId(),a={kind:e,contentType:p(n),contentLength:i,...o.source==="upload"?{source:"upload"}:{}};return this.api("POST",`/sessions/${r}/media`,{body:a})}armCapture(e=2){this.fillCaptureNonces(e)}async presignCapture(e,n,i,o={}){let r=await this.ensureSessionId(),a=await this.takeCaptureNonce(),d=a===void 0?void 0:{nonce:a,...o.engine!==void 0?{engine:o.engine.slice(0,32)}:{},...o.durationMs!==void 0&&Number.isFinite(o.durationMs)?{captureMs:Math.min(36e5,Math.max(0,Math.round(o.durationMs)))}:{}},s={kind:e,contentType:p(n),contentLength:i,capture:d};return this.api("POST",`/sessions/${r}/media`,{body:s})}async takeCaptureNonce(){let e=()=>{let n=Date.now();return this.captureNonces=this.captureNonces.filter(i=>i.expiresAt-Te>n),this.captureNonces.shift()?.nonce};for(let n=0;n<2;n++){let i=e();if(i!==void 0)return i;await this.fillCaptureNonces(1)}return e()}fillCaptureNonces(e){return this.captureFetch??(this.captureFetch=(async()=>{try{let n=await this.ensureSessionId(),i=await this.api("POST",`/sessions/${n}/media/capture-nonces`,{body:{count:Math.min(K,Math.max(1,e))}}),o=Date.now()+Math.max(0,i.expiresIn)*1e3;for(let r of Array.isArray(i.nonces)?i.nonces:[])typeof r=="string"&&r.length>0&&this.captureNonces.push({nonce:r,expiresAt:o});this.captureNonces=this.captureNonces.slice(-K)}catch{}})().finally(()=>{this.captureFetch=null})),this.captureFetch}async uploadToSpaces(e,n,i){let o;try{o=await this.fetchImpl(e,{method:"PUT",headers:{"content-type":p(i)},body:n,signal:AbortSignal.timeout(Pe)})}catch(r){throw C(r)}if(!o.ok){let r=(await o.text().catch(()=>"")).slice(0,Ce);throw new u({status:o.status,code:"upload_failed",message:`media upload failed (HTTP ${o.status})${r?`: ${r}`:""}`})}}async completeMedia(e){let n=await this.ensureSessionId();return this.api("POST",`/sessions/${n}/media/complete`,{body:{key:e}})}async submitCheck(e,n,i={}){let o=await this.ensureSessionId(),r={input:n,forceOutcome:i.forceOutcome};return this.api("POST",`/sessions/${o}/checks/${e}`,{body:r,idempotencyKey:i.idempotencyKey,busyRetry:i.idempotencyKey!==void 0})}async uploadAndSubmit(e,n,i,o={}){let r=p(n.contentType),a=await this.presign(n.kind,r,n.blob.size);await this.uploadToSpaces(a.uploadUrl,n.blob,r);let d=await this.completeMedia(a.key),s={...i,[Re[e]]:d.key};return this.submitCheck(e,s,o)}async ensureSessionId(){return this.sessionId!==null?this.sessionId:(this.bootstrap??(this.bootstrap=this.getSession().finally(()=>{this.bootstrap=null})),(await this.bootstrap).sessionId)}async api(e,n,i={}){let o=e==="GET"||i.busyRetry===!0,r=`${this.apiOrigin}/api/v2${n}`,a={"x-session-token":this.sessionToken,"x-sekyro-sdk":Ee};i.body!==void 0&&(a["content-type"]="application/json"),i.idempotencyKey!==void 0&&(a["x-idempotency-key"]=i.idempotencyKey);try{let d=w.timezone();d!==void 0&&(a["sekyro-client-timezone"]=d)}catch{}a["sekyro-client-form-factor"]=v();try{let d=await w.deviceHeader();d!==void 0&&(a["sekyro-client-device"]=d)}catch{}for(let d=0;;d++){let s;try{s=await this.fetchImpl(r,{method:e,headers:a,...i.body!==void 0?{body:JSON.stringify(i.body)}:{},cache:"no-store",signal:AbortSignal.timeout(this.requestTimeoutMs)})}catch(l){throw C(l)}if(s.ok){if(i.empty===!0)return;if(i.blob===!0)try{return await s.blob()}catch(m){throw C(m)}let l;try{l=await s.json()}catch{throw new u({status:s.status,code:"unknown_error",message:`response body was not valid JSON (HTTP ${s.status})`})}return Ae(l)}let c=await xe(s);if(c.code==="idempotency_in_progress"&&d<this.retryAttempts){this.retryDelayMs>0&&await B(this.retryDelayMs);continue}if(o&&c.status===503&&ve.has(c.code)){o=!1,await B(U(c.retryAfterSeconds,Ie,this.random));continue}throw c}}};function C(t){if((typeof t=="object"&&t!==null?t.name:void 0)==="TimeoutError")return new u({status:0,code:"timeout",message:"request timed out"});let n=t instanceof Error?t.message:String(t);return new u({status:0,code:"network_error",message:`network request failed: ${n}`})}function Ae(t){return t!==null&&typeof t=="object"&&"success"in t&&"data"in t?t.data:t}async function xe(t){let e="unknown_error",n=`request failed (HTTP ${t.status})`,i=Number.NaN,o;try{let d=await t.json();if(d!==null&&typeof d=="object"){let s=d;typeof s.code=="string"&&s.code.length>0&&(e=s.code),typeof s.message=="string"&&s.message.length>0&&(n=s.message),typeof s.retryAfterSeconds=="number"&&(i=s.retryAfterSeconds),Array.isArray(s.details?.issues)&&(o=s.details)}}catch{}let r=t.headers.get("retry-after"),a=r===null?Math.floor(i):Number.parseInt(r,10);return new u({status:t.status,code:e,message:n,...Number.isFinite(a)&&a>=0?{retryAfterSeconds:a}:{},details:o})}function B(t){return new Promise(e=>setTimeout(e,t))}function q(t){let e=t?.portrait,n=e?.icao,i=e?.purpose==="id_document";return n==null?i?{policy:"reject",profile:"id_document"}:null:{policy:n.policy==="alert"?"alert":"reject",profile:i||n.profile==="id_document"?"id_document":"selfie"}}function $(t){return{...t.baselineEyeOpenness!==void 0?{baselineEyeOpenness:t.baselineEyeOpenness}:{},...t.baselineEyeOpennessLeft!==void 0&&t.baselineEyeOpennessRight!==void 0?{baselineEyeOpennessLeft:t.baselineEyeOpennessLeft,baselineEyeOpennessRight:t.baselineEyeOpennessRight}:{},criteria:t.verdict??{},...t.backgroundCheck!==void 0?{backgroundCheck:t.backgroundCheck}:{}}}0&&(module.exports={HostedApiError,HostedClient,KNOWN_CODES,SEKYRO_SDK_HEADER,icaoPolicyOf,isInAppBrowser,isKnownCode,portraitIcaoGate,stripMimeParams});
@@ -1,6 +1,6 @@
1
- export { H as HostedClient, a as HostedClientOptions, M as MediaCheckType, S as SEKYRO_SDK_HEADER, b as SubmitOptions, U as UploadMedia, s as stripMimeParams } from '../icao-gate-l40OU6x1.cjs';
2
- export { H as HostedApiError, a as HostedErrorDetails, b as HostedErrorIssue, K as KNOWN_CODES, c as KnownCode, i as icaoPolicyOf, d as isKnownCode, p as portraitIcaoGate } from '../icao-policy-C7fIdRzo.cjs';
3
- export { A as AcceptedDocumentType, a as AttestationInput, C as CaptureContext, b as CaptureMode, c as CaptureNoncesResult, d as CaptureProof, e as CheckInputByType, f as CheckReason, g as CheckState, h as CheckType, i as CompleteMediaResult, j as ConsentLocale, k as ContactChannel, D as DecisionReason, l as DocDeviceRead, m as DocOcrInput, n as DocReason, o as DocSide, E as EidAfterPass, p as EidAuthInput, q as EidReason, r as EmailOtpInput, s as EmailOtpReason, F as FaceMatchInput, t as FaceMatchReason, H as HostedAcceptedDocuments, u as HostedCaptureTuning, v as HostedConsentView, w as HostedDocumentCaptureTuning, x as HostedDocumentScanTuning, y as HostedDocumentsView, z as HostedEidView, B as HostedEmailOtpView, G as HostedFlowRef, I as HostedIcaoPolicy, J as HostedIntegrity, K as HostedLivePhotoTuning, L as HostedNativeCaptureTuning, M as HostedOcrTuning, N as HostedOtpView, O as HostedPlanView, P as HostedPortraitPendingFix, Q as HostedPortraitView, R as HostedSessionView, S as HostedStepView, T as HostedVoiceLocale, U as HostedVoiceView, V as IcaoCriterion, W as IcaoReportEntry, X as IdentityConfirmDecision, Y as IdentityMethod, Z as IdentitySummarySource, _ as IdentitySummaryView, $ as LivenessCaptureInput, a0 as LivenessInput, a1 as LivenessReason, a2 as MatchReason, a3 as MediaKind, a4 as MethodChoiceView, a5 as NationalEidOption, a6 as NfcChipReason, a7 as NfcStepView, a8 as OtpChoiceView, a9 as PhoneCountryRule, aa as PhoneFormat, ab as PhoneOtpInput, ac as PhoneOtpReason, ad as PhotoSource, ae as PhotoSourcePick, af as PlanAttempts, ag as PlanChoiceKind, ah as PlanChoiceOption, ai as PlanChoiceView, aj as PlanSectionView, ak as PlanStepView, al as PolicyFailureReason, am as PopulationInput, an as PopulationReason, ao as PortraitFix, ap as PortraitFixReviewInput, aq as PortraitIcaoInput, ar as PortraitIcaoReason, as as PortraitOutputFormat, at as PresignRequest, au as PresignUploadResult, av as RecordConsentResult, aw as ResolvedCaptureMode, ax as SessionFailureReason, ay as SessionOutcome, az as SessionStatus, aA as SessionStepView, aB as SessionView, aC as StepSection, aD as SubmitCheckBody, aE as VerificationAssurance, aF as VerificationLevel } from '../types-Dpfg2cO8.cjs';
1
+ export { H as HostedClient, a as HostedClientOptions, M as MediaCheckType, S as SEKYRO_SDK_HEADER, b as SubmitOptions, U as UploadMedia, s as stripMimeParams } from '../icao-gate-BFlSZYCZ.cjs';
2
+ export { H as HostedApiError, a as HostedErrorDetails, b as HostedErrorIssue, K as KNOWN_CODES, c as KnownCode, i as icaoPolicyOf, d as isKnownCode, p as portraitIcaoGate } from '../icao-policy-JZH0UdmD.cjs';
3
+ export { A as AcceptedDocumentType, a as AttestationInput, C as CaptureContext, b as CaptureMode, c as CaptureNoncesResult, d as CaptureProof, e as CheckInputByType, f as CheckReason, g as CheckState, h as CheckType, i as ClosedBy, j as CompleteMediaResult, k as ConsentLocale, l as ContactChannel, D as DecisionReason, m as DocDeviceRead, n as DocOcrInput, o as DocReason, p as DocSide, E as EidAfterPass, q as EidAuthInput, r as EidReason, s as EmailOtpInput, t as EmailOtpReason, F as FaceMatchInput, u as FaceMatchReason, H as HostedAcceptedDocuments, v as HostedCaptureTuning, w as HostedConsentView, x as HostedDocumentCaptureTuning, y as HostedDocumentScanTuning, z as HostedDocumentsView, B as HostedEidView, G as HostedEmailOtpView, I as HostedFlowRef, J as HostedIcaoPolicy, K as HostedIntegrity, L as HostedLivePhotoTuning, M as HostedNativeCaptureTuning, N as HostedOcrTuning, O as HostedOtpView, P as HostedPlanView, Q as HostedPortraitPendingFix, R as HostedPortraitView, S as HostedSessionView, T as HostedSimulationView, U as HostedStepView, V as HostedVoiceLocale, W as HostedVoiceView, X as IcaoCriterion, Y as IcaoReportEntry, Z as IdentityConfirmDecision, _ as IdentityMethod, $ as IdentitySummarySource, a0 as IdentitySummaryView, a1 as LivenessCaptureInput, a2 as LivenessInput, a3 as LivenessReason, a4 as MatchReason, a5 as MediaKind, a6 as MethodChoiceView, a7 as NationalEidOption, a8 as NfcChipReason, a9 as NfcStepView, aa as OtpChoiceView, ab as PhoneCountryRule, ac as PhoneFormat, ad as PhoneOtpInput, ae as PhoneOtpReason, af as PhotoSource, ag as PhotoSourcePick, ah as PlanAttempts, ai as PlanChoiceKind, aj as PlanChoiceOption, ak as PlanChoiceView, al as PlanSectionView, am as PlanStepView, an as PopulationInput, ao as PopulationReason, ap as PortraitFix, aq as PortraitFixReviewInput, ar as PortraitIcaoInput, as as PortraitIcaoReason, at as PortraitOutputFormat, au as PresignRequest, av as PresignUploadResult, aw as RecordConsentResult, ax as ResolvedCaptureMode, ay as SessionDecidingStep, az as SessionFailureReason, aA as SessionReason, aB as SessionStatus, aC as SessionStepView, aD as SessionView, aE as SimulatedCaptureInput, aF as StepResult, aG as StepSection, aH as SubmitCheckBody, aI as VerificationAssurance, aJ as VerificationLevel } from '../types-DwfyBTte.cjs';
4
4
 
5
5
  /** The page runs inside an app's WebView (WhatsApp, Instagram, Facebook, TikTok, Snapchat, LINE, LinkedIn, WeChat, an Android WebView…). */
6
6
  declare function isInAppBrowser(userAgent?: string): boolean;
@@ -1,6 +1,6 @@
1
- export { H as HostedClient, a as HostedClientOptions, M as MediaCheckType, S as SEKYRO_SDK_HEADER, b as SubmitOptions, U as UploadMedia, s as stripMimeParams } from '../icao-gate-CEGvJR3q.js';
2
- export { H as HostedApiError, a as HostedErrorDetails, b as HostedErrorIssue, K as KNOWN_CODES, c as KnownCode, i as icaoPolicyOf, d as isKnownCode, p as portraitIcaoGate } from '../icao-policy-BgI1Y870.js';
3
- export { A as AcceptedDocumentType, a as AttestationInput, C as CaptureContext, b as CaptureMode, c as CaptureNoncesResult, d as CaptureProof, e as CheckInputByType, f as CheckReason, g as CheckState, h as CheckType, i as CompleteMediaResult, j as ConsentLocale, k as ContactChannel, D as DecisionReason, l as DocDeviceRead, m as DocOcrInput, n as DocReason, o as DocSide, E as EidAfterPass, p as EidAuthInput, q as EidReason, r as EmailOtpInput, s as EmailOtpReason, F as FaceMatchInput, t as FaceMatchReason, H as HostedAcceptedDocuments, u as HostedCaptureTuning, v as HostedConsentView, w as HostedDocumentCaptureTuning, x as HostedDocumentScanTuning, y as HostedDocumentsView, z as HostedEidView, B as HostedEmailOtpView, G as HostedFlowRef, I as HostedIcaoPolicy, J as HostedIntegrity, K as HostedLivePhotoTuning, L as HostedNativeCaptureTuning, M as HostedOcrTuning, N as HostedOtpView, O as HostedPlanView, P as HostedPortraitPendingFix, Q as HostedPortraitView, R as HostedSessionView, S as HostedStepView, T as HostedVoiceLocale, U as HostedVoiceView, V as IcaoCriterion, W as IcaoReportEntry, X as IdentityConfirmDecision, Y as IdentityMethod, Z as IdentitySummarySource, _ as IdentitySummaryView, $ as LivenessCaptureInput, a0 as LivenessInput, a1 as LivenessReason, a2 as MatchReason, a3 as MediaKind, a4 as MethodChoiceView, a5 as NationalEidOption, a6 as NfcChipReason, a7 as NfcStepView, a8 as OtpChoiceView, a9 as PhoneCountryRule, aa as PhoneFormat, ab as PhoneOtpInput, ac as PhoneOtpReason, ad as PhotoSource, ae as PhotoSourcePick, af as PlanAttempts, ag as PlanChoiceKind, ah as PlanChoiceOption, ai as PlanChoiceView, aj as PlanSectionView, ak as PlanStepView, al as PolicyFailureReason, am as PopulationInput, an as PopulationReason, ao as PortraitFix, ap as PortraitFixReviewInput, aq as PortraitIcaoInput, ar as PortraitIcaoReason, as as PortraitOutputFormat, at as PresignRequest, au as PresignUploadResult, av as RecordConsentResult, aw as ResolvedCaptureMode, ax as SessionFailureReason, ay as SessionOutcome, az as SessionStatus, aA as SessionStepView, aB as SessionView, aC as StepSection, aD as SubmitCheckBody, aE as VerificationAssurance, aF as VerificationLevel } from '../types-Dpfg2cO8.js';
1
+ export { H as HostedClient, a as HostedClientOptions, M as MediaCheckType, S as SEKYRO_SDK_HEADER, b as SubmitOptions, U as UploadMedia, s as stripMimeParams } from '../icao-gate-lZ_fHE7k.js';
2
+ export { H as HostedApiError, a as HostedErrorDetails, b as HostedErrorIssue, K as KNOWN_CODES, c as KnownCode, i as icaoPolicyOf, d as isKnownCode, p as portraitIcaoGate } from '../icao-policy-BOcutYdD.js';
3
+ export { A as AcceptedDocumentType, a as AttestationInput, C as CaptureContext, b as CaptureMode, c as CaptureNoncesResult, d as CaptureProof, e as CheckInputByType, f as CheckReason, g as CheckState, h as CheckType, i as ClosedBy, j as CompleteMediaResult, k as ConsentLocale, l as ContactChannel, D as DecisionReason, m as DocDeviceRead, n as DocOcrInput, o as DocReason, p as DocSide, E as EidAfterPass, q as EidAuthInput, r as EidReason, s as EmailOtpInput, t as EmailOtpReason, F as FaceMatchInput, u as FaceMatchReason, H as HostedAcceptedDocuments, v as HostedCaptureTuning, w as HostedConsentView, x as HostedDocumentCaptureTuning, y as HostedDocumentScanTuning, z as HostedDocumentsView, B as HostedEidView, G as HostedEmailOtpView, I as HostedFlowRef, J as HostedIcaoPolicy, K as HostedIntegrity, L as HostedLivePhotoTuning, M as HostedNativeCaptureTuning, N as HostedOcrTuning, O as HostedOtpView, P as HostedPlanView, Q as HostedPortraitPendingFix, R as HostedPortraitView, S as HostedSessionView, T as HostedSimulationView, U as HostedStepView, V as HostedVoiceLocale, W as HostedVoiceView, X as IcaoCriterion, Y as IcaoReportEntry, Z as IdentityConfirmDecision, _ as IdentityMethod, $ as IdentitySummarySource, a0 as IdentitySummaryView, a1 as LivenessCaptureInput, a2 as LivenessInput, a3 as LivenessReason, a4 as MatchReason, a5 as MediaKind, a6 as MethodChoiceView, a7 as NationalEidOption, a8 as NfcChipReason, a9 as NfcStepView, aa as OtpChoiceView, ab as PhoneCountryRule, ac as PhoneFormat, ad as PhoneOtpInput, ae as PhoneOtpReason, af as PhotoSource, ag as PhotoSourcePick, ah as PlanAttempts, ai as PlanChoiceKind, aj as PlanChoiceOption, ak as PlanChoiceView, al as PlanSectionView, am as PlanStepView, an as PopulationInput, ao as PopulationReason, ap as PortraitFix, aq as PortraitFixReviewInput, ar as PortraitIcaoInput, as as PortraitIcaoReason, at as PortraitOutputFormat, au as PresignRequest, av as PresignUploadResult, aw as RecordConsentResult, ax as ResolvedCaptureMode, ay as SessionDecidingStep, az as SessionFailureReason, aA as SessionReason, aB as SessionStatus, aC as SessionStepView, aD as SessionView, aE as SimulatedCaptureInput, aF as StepResult, aG as StepSection, aH as SubmitCheckBody, aI as VerificationAssurance, aJ as VerificationLevel } from '../types-DwfyBTte.js';
4
4
 
5
5
  /** The page runs inside an app's WebView (WhatsApp, Instagram, Facebook, TikTok, Snapchat, LINE, LinkedIn, WeChat, an Android WebView…). */
6
6
  declare function isInAppBrowser(userAgent?: string): boolean;
@@ -1 +1 @@
1
- import{a as t,b as o,c as i,e as n,f as s,g as a,h as r,i as p}from"../chunk-NJML6FMD.js";import{b as e}from"../chunk-ZLWH4RBO.js";export{i as HostedApiError,a as HostedClient,t as KNOWN_CODES,s as SEKYRO_SDK_HEADER,r as icaoPolicyOf,e as isInAppBrowser,o as isKnownCode,p as portraitIcaoGate,n as stripMimeParams};
1
+ import{a as t,b as o,c as i,e as n,f as s,g as a,h as p,i as r}from"../chunk-2KTSNAVR.js";import"../chunk-TSA6GHUG.js";import{b as e}from"../chunk-BATJN3VQ.js";export{i as HostedApiError,a as HostedClient,t as KNOWN_CODES,s as SEKYRO_SDK_HEADER,p as icaoPolicyOf,e as isInAppBrowser,o as isKnownCode,r as portraitIcaoGate,n as stripMimeParams};
@@ -0,0 +1 @@
1
+ async function j(t){try{return O(await B(t))}catch{return null}}async function B(t){return typeof t.arrayBuffer=="function"?new Uint8Array(await t.arrayBuffer()):new Promise((r,a)=>{let e=new FileReader;e.onload=()=>r(new Uint8Array(e.result)),e.onerror=()=>a(e.error),e.readAsArrayBuffer(t)})}function O(t){if(t.length<8)return null;try{if(t[0]===26&&t[1]===69&&t[2]===223&&t[3]===163)return H(t);if(A(t,4,4)==="ftyp")return L(t)}catch{return null}return null}var R=new Set(["moov","trak","mdia","minf","stbl","mvex","moof","traf","edts"]);function L(t){let r=new DataView(t.buffer,t.byteOffset,t.byteLength),a=[],e=null,n=null,s=0,d=(l,f)=>{let o=l;for(;o+8<=f;){let m=r.getUint32(o),h=A(t,o+4,4),U=8;if(m===1){if(o+16>f)return;m=Number(r.getBigUint64(o+8)),U=16}else m===0&&(m=f-o);if(m<U)return;let x=Math.min(o+m,f),i=o+U;if(h==="trak"&&(e={id:0,video:!1,timescale:0,frames:0,units:0,defaultDuration:0},a.push(e)),h==="traf"&&(n=null,s=0),R.has(h))d(i,x);else if(h==="tkhd"&&e)e.id=r.getUint32(i+(t[i]===1?20:12));else if(h==="hdlr"&&e)e.video=A(t,i+8,4)==="vide";else if(h==="mdhd"&&e)e.timescale=r.getUint32(i+(t[i]===1?20:12));else if(h==="stts"&&e){let u=r.getUint32(i+4);for(let g=0;g<u;g++){let y=r.getUint32(i+8+g*8);e.frames+=y,e.units+=y*r.getUint32(i+12+g*8)}}else if(h==="trex"){let u=a.find(g=>g.id===r.getUint32(i+4));u&&(u.defaultDuration=r.getUint32(i+12))}else if(h==="tfhd"){let u=r.getUint32(i)&16777215;n=a.find(y=>y.id===r.getUint32(i+4))??null;let g=i+8;u&1&&(g+=8),u&2&&(g+=4),s=u&8?r.getUint32(g):n?.defaultDuration??0}else if(h==="trun"&&n){let u=r.getUint32(i)&16777215,g=r.getUint32(i+4),y=i+8;u&1&&(y+=4),u&4&&(y+=4);let D=(u&256?4:0)+(u&512?4:0)+(u&1024?4:0)+(u&2048?4:0);for(let b=0;b<g;b++)n.units+=u&256?r.getUint32(y+b*D):s;n.frames+=g}o=x}};d(0,t.length);let c=a.find(l=>l.video&&l.timescale>0);return!c||c.frames===0?null:{container:"mp4",frames:c.frames,durationMs:z(c.units*1e3/c.timescale)}}var E=408125543,M=357149030,N=374648427,C=174,T=524531317,I=160,w=2807729,S=17545,K=215,P=131,F=231,V=163,G=161,W=290298740,v=new Set([E,M,N,C,T,I]);function Y(t,r){let a=t[r];if(a===void 0||a===0)return null;let e=Math.clz32(a)-23;if(e<1||e>4||r+e>t.length)return null;let n=0;for(let s=0;s<e;s++)n=n*256+t[r+s];return[n,e]}function _(t,r){let a=t[r];if(a===void 0||a===0)return null;let e=Math.clz32(a)-23;if(e<1||e>8||r+e>t.length)return null;let n=a&255>>e,s=n===255>>e;for(let d=1;d<e;d++){let c=t[r+d];n=n*256+c,c!==255&&(s=!1)}return[s?-1:n,e]}function p(t,r,a){let e=0;for(let n=0;n<a;n++)e=e*256+t[r+n];return e}function k(t){let r=[],a=0;for(;a<t.length;){let e=Y(t,a);if(!e)break;let n=_(t,a+e[1]);if(!n)break;let s={id:e[0],start:a,sizeAt:a+e[1],data:a+e[1]+n[1],size:n[0]};if(r.push(s),v.has(s.id))a=s.data;else{if(s.size<0)break;a=s.data+s.size}}return r}function H(t){let r=new DataView(t.buffer,t.byteOffset,t.byteLength),a=1e6,e=[],n=0,s=[];for(let l of k(t)){if(l.data+Math.max(0,l.size)>t.length&&!v.has(l.id))break;switch(l.id){case w:a=p(t,l.data,l.size)||a;break;case C:e.push({num:0,type:0});break;case K:e.length&&(e[e.length-1].num=p(t,l.data,l.size));break;case P:e.length&&(e[e.length-1].type=p(t,l.data,l.size));break;case F:n=p(t,l.data,l.size);break;case V:case G:{let f=_(t,l.data);if(!f||l.data+f[1]+2>t.length)break;let o=e.filter(m=>m.type===1).map(m=>m.num);if(o.length>0&&!o.includes(f[0]))break;s.push((n+r.getInt16(l.data+f[1]))*a/1e6);break}default:break}}if(s.length===0)return null;s.sort((l,f)=>l-f);let d=s.slice(1).map((l,f)=>l-s[f]),c=d.length?d.sort((l,f)=>l-f)[Math.floor(d.length/2)]:0;return{container:"webm",frames:s.length,durationMs:z(s[s.length-1]-s[0]+c)}}function q(t,r){if(!(r>0))return null;let a=k(t),e=a.find(i=>i.id===E);if(!e||e.size!==-1||a.some(i=>i.id===W))return null;let n=a.find(i=>i.id===M);if(!n||n.size<0||n.data+n.size>t.length)return null;let s=1e6,d=[];for(let i of a)i.start<n.data||i.start>=n.data+n.size||(i.id===w&&(s=p(t,i.data,i.size)||s),i.id!==S&&d.push(t.subarray(i.start,i.data+i.size)));let c=new Uint8Array(11);c.set([68,137,136]),new DataView(c.buffer).setFloat64(3,r*1e6/s);let l=d.reduce((i,u)=>i+u.length,0)+c.length,f=new Uint8Array(12);f.set([21,73,169,102,1]);let o=l;for(let i=11;i>=5;i--)f[i]=o&255,o=Math.floor(o/256);let m=t.subarray(n.data+n.size),h=new Uint8Array(n.start+f.length+l+m.length),U=0,x=i=>{h.set(i,U),U+=i.length};return x(t.subarray(0,n.start)),x(f),d.forEach(x),x(c),x(m),h}function J(t){let r=1e6,a=null,e=new DataView(t.buffer,t.byteOffset,t.byteLength);for(let n of k(t))if(n.id===w&&(r=p(t,n.data,n.size)||r),n.id===S&&(a=n.size===8?e.getFloat64(n.data):n.size===4?e.getFloat32(n.data):null),n.id===T)break;return a===null?null:z(a*r/1e6)}function A(t,r,a){let e="";for(let n=0;n<a&&r+n<t.length;n++)e+=String.fromCharCode(t[r+n]);return e}function z(t){return Math.round(t*10)/10}export{B as blobBytes,j as inspectClip,O as inspectClipBytes,J as webmDurationMs,q as withWebmDuration};
@@ -1 +1 @@
1
- "use strict";var Rt=Object.create;var B=Object.defineProperty;var Dt=Object.getOwnPropertyDescriptor;var It=Object.getOwnPropertyNames;var At=Object.getPrototypeOf,Ot=Object.prototype.hasOwnProperty;var W=(t,e)=>()=>(t&&(e=t(t=0)),e);var K=(t,e)=>{for(var r in e)B(t,r,{get:e[r],enumerable:!0})},Re=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of It(e))!Ot.call(t,n)&&n!==r&&B(t,n,{get:()=>e[n],enumerable:!(i=Dt(e,n))||i.enumerable});return t};var Pt=(t,e,r)=>(r=t!=null?Rt(At(t)):{},Re(e||!t||!t.__esModule?B(r,"default",{value:t,enumerable:!0}):r,t)),Ft=t=>Re(B({},"__esModule",{value:!0}),t);function Ue(t){let e=(t??"").trim().toLowerCase();return e.length===0?"unknown":er.some(r=>e.includes(r))?"known_virtual":tr.some(r=>r.test(e))?"platform":"unknown"}var er,tr,ze=W(()=>{"use strict";er=["obs","manycam","virtual","snap camera","xsplit","droidcam","iriun","camo"],tr=[/^(front|back|rear)( [a-z ]+)? camera$/i,/^camera2? ?\d+, facing (front|back|external)/i,/facetime/i,/\b(integrated|built-in|builtin) (web)?cam(era)?\b/i,/\b(hd )?web ?cam\b/i,/\([0-9a-f]{4}:[0-9a-f]{4}\)\s*$/i]});var Xe={};K(Xe,{bounded:()=>G,cameraHash:()=>qe,hex16:()=>$,noteCameraTrait:()=>ir});function G(t,e){return new Promise(r=>{let i=setTimeout(()=>r(void 0),e),n=a=>{clearTimeout(i),r(a)};try{t().then(n,()=>n(void 0))}catch{n(void 0)}})}async function $(t){let e=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(JSON.stringify(t)));return Array.from(new Uint8Array(e).subarray(0,8),r=>r.toString(16).padStart(2,"0")).join("")}function nr(t){try{return t.getSettings?.().facingMode==="environment"}catch{return!1}}async function qe(t){try{if(t.readyState==="ended"||nr(t))return;let e={};try{e=t.getCapabilities?.()??{}}catch{}let r=await G(()=>navigator.mediaDevices.enumerateDevices(),rr);return await $([ve(e.width),ve(e.height),ve(e.frameRate),ye(e.facingMode),ye(e.focusMode),ye(e.exposureMode),Ue(t.label),r?.filter(i=>i.kind==="videoinput").length??null])}catch{return}}async function ir(t,e){let r=await qe(t);r&&e.noteCamera(r)}var rr,ye,ve,Se=W(()=>{"use strict";ze();rr=1e3;ye=t=>Array.isArray(t)?[...t].sort():null,ve=t=>{let e=t;return e==null?null:[e.min??null,e.max??null]}});var Qe={};K(Qe,{computePrint:()=>gr,readHints:()=>je});function Ye(t,e){if(typeof t!="string")return;let r=t.trim();return r.length>0&&r.length<=e?r:void 0}async function je(){let t=navigator.userAgentData;if(typeof t?.getHighEntropyValues!="function")return;let e=await G(()=>t.getHighEntropyValues(["model","platformVersion"]),cr);if(e==null)return;let r=Ye(e.model,lr),i=Ye(e.platformVersion,dr),n={...r!==void 0?{model:r}:{},...i!==void 0?{platformVersion:i}:{}};return Object.keys(n).length>0?n:void 0}async function fr(){let[t,e]=await Promise.all([new Ze.Thumbmark({stabilize:["private","iframe"],exclude:["permissions","webrtc","speech"],logging:!1,collect_beacon:!1,timeout:or}).get(),je()]),r=t?.thumbmark;if(typeof r!="string"||r.length<mr||r.length>pr)return;let i={};for(let n of ar){let a=t.components?.[n];a==null||a.timeout==="true"||(i[n]=await $(a))}return{hash:r,c:i,...e!==void 0?{hints:e}:{}}}function hr(){return new Promise(t=>{typeof globalThis.requestIdleCallback=="function"?globalThis.requestIdleCallback(()=>t(),{timeout:ur}):t()})}async function gr(t){return t()||(await hr(),t())?"busy":G(fr,sr)}var Ze,ar,or,sr,cr,ur,lr,dr,mr,pr,$e=W(()=>{"use strict";Ze=require("@thumbmarkjs/thumbmarkjs");Se();ar=["canvas","webgl","audio","fonts","hardware","screen","system","locales","math","plugins"],or=2e3,sr=4e3,cr=1e3,ur=2e3,lr=64,dr=32,mr=8,pr=128});var St={};K(St,{RANK_CANDIDATES:()=>Lr,RANK_TOLERANCE:()=>ee,RANK_WINDOW_MS:()=>Nr,ROLL_ZERO_DEG:()=>Gr,SHARPNESS_REPORT_MAX:()=>yt,YAW_REPORT_MAX:()=>bt,YAW_ZERO_IOD:()=>Vr,collectRankedKeyframes:()=>vt,default:()=>Br,featuresOf:()=>ht,frontalOf:()=>ft,rankKeyframes:()=>gt});function ft(t){let e=t.eyes;if(e===void 0)return{frontal:1,yaw:null,roll:null};let r=e.right.x-e.left.x,i=e.right.y-e.left.y,n=r*r+i*i;if(n===0)return{frontal:1,yaw:null,roll:null};let a=Math.abs(Math.atan2(i,Math.abs(r))*180/Math.PI),o=pt(1-a/30),s=null,l=t.nose;if(l!==void 0){let c=(e.left.x+e.right.x)/2,u=(e.left.y+e.right.y)/2;s=Math.abs(((l.x-c)*r+(l.y-u)*i)/n),o*=pt(1-s/.5)}return{frontal:o,yaw:s,roll:a}}function ht(t,e){return t===null?{face:!1,frontal:0,yaw:null,roll:null,eyes:null,score:0,sharpness:e}:{face:!0,...ft(t),eyes:null,score:t.score,sharpness:e}}function gt(t){let e=t.map((n,a)=>a),r=(n,a)=>{let o=Number.NEGATIVE_INFINITY;for(let s of e)o=Math.max(o,n(t[s]));e=e.filter(s=>n(t[s])>=o-a)};r(n=>n.frontal,ee.frontal),r(n=>n.eyes??1,ee.eyes),r(n=>n.score,ee.score);let i=-1;for(let n of e)(i===-1||t[n].sharpness>t[i].sharpness)&&(i=n);return i}function Hr(t){return{face:t.face,frontal:I(t.frontal),...t.yaw!==null?{yaw:Math.min(I(t.yaw),bt)}:{},...t.roll!==null?{roll:I(t.roll)}:{},...t.eyes!==null?{eyes:I(t.eyes)}:{},score:I(t.score),sharpness:Math.min(I(t.sharpness),yt)}}async function vt(t,e){let{options:r}=t,i=r.video,n=r.now??(()=>performance.now()),a=r.captureKeyframe??(m=>t.defaultKeyframe(m)),o=600/3,s=[],l=[],c=0;for(let m=0;m<4;m+=1){if(e!==t.attempt)return null;let p=t.detector,f=Promise.resolve(null),h,g=0;try{if(p!==null){let k=t.profiler?.profile.inputWidth??160,A=r.makeSnapshot?.(i,k)??t.defaultSnapshot(i,k);h=a(i).then(b=>(g=n(),b));let ne=n();f=p.detect(A,i.videoWidth,i.videoHeight).then(b=>(c+=n()-ne,b),()=>null)}else h=a(i).then(k=>(g=n(),k));let[v,T]=await Promise.all([h,f]);s.push(v),l.push(ht(T,v.sharpness))}catch{h?.catch(()=>{})}let S=g>0?Math.max(0,n()-g):0;m<3&&await new Promise(v=>setTimeout(v,Math.max(0,o-S)))}if(e!==t.attempt)return null;let u=gt(l);if(u===-1)return null;let d=0;l.forEach((m,p)=>{m.sharpness>l[d].sharpness&&(d=p)});try{r.telemetry?.({type:"keyframe",tier:t.detector?.tier??null,chosen:u,sharpest:d,detectMs:Math.round(c),candidates:l.map(Hr)})}catch{}return s[u]??null}var Lr,Nr,Vr,Gr,ee,pt,I,bt,yt,Br,Et=W(()=>{"use strict";Lr=4,Nr=600,Vr=.5,Gr=30,ee={frontal:.1,eyes:.1,score:.05},pt=t=>t<0?0:t>1?1:t;I=t=>Number.isFinite(t)?Math.round(t*1e3)/1e3:0,bt=99,yt=999999;Br=vt});var qr={};K(qr,{CENTERED_FACTOR:()=>Ut,CIRCLE_RADIUS_FACTOR:()=>Wt,CLIP_MS:()=>Ie,CaptureSessionV3:()=>_e,ClipError:()=>y,ClipRecorder:()=>P,DEFAULT_CLIP_MIME:()=>U,DEFAULT_TIER_ORDER:()=>Ve,DEFAULT_V3_ASSET_BASE_URL:()=>Ne,DEVICE_PROFILES:()=>Be,DetectScheduler:()=>V,DetectorLadderError:()=>w,DeviceProfiler:()=>N,EXPOSURE_BAND:()=>L,FaceGateV3:()=>R,GATE_SNAPSHOT_MS:()=>kt,GateBlockStats:()=>D,HOLD_UPRIGHT_KEY:()=>te,IN_CIRCLE_FACTOR:()=>Kt,KEYFRAME_CANDIDATES:()=>re,KEYFRAME_WINDOW_MS:()=>wt,MAX_CLIP_BYTES:()=>z,MIME_CANDIDATES:()=>De,PHONE_MAX_SHORT_SIDE:()=>Pe,PROVENANCE_WAIT_MS:()=>xt,SHARP_REF:()=>cn,STOP_GRACE_MS:()=>Oe,TIMESLICE_MS:()=>Ae,UPRIGHT_WATCH_MS:()=>Ct,V3_GATE_DEFAULTS:()=>He,VIDEO_BPS:()=>ue,blockReasonOf:()=>mt,buildCaptureConstraints:()=>le,buildLivenessV2FormData:()=>Nt,cameraPreflight:()=>se,captureMirroredKeyframe:()=>ce,classifyDevice:()=>be,createDetector:()=>x,detectFormFactor:()=>q,detectIsMobile:()=>de,errorCopy:()=>Vt,exposure:()=>fe,extForMime:()=>ie,intrinsicSize:()=>C,isClipTooLarge:()=>O,isMediaRecorderSupported:()=>Lt,mapGetUserMediaError:()=>oe,meanLuma:()=>j,pickMimeType:()=>ae,probeDevice:()=>ge,sharpness:()=>Q,toStreamPixels:()=>F,trackFacingMode:()=>me,uiCopy:()=>Gt});module.exports=Ft(qr);var De=["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 ae(){let t=globalThis.MediaRecorder;return!t||typeof t.isTypeSupported!="function"?"":De.find(e=>t.isTypeSupported(e))??""}var U="video/webm";function oe(t){if(t instanceof TypeError)return"insecure";switch(t?.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 se(){let t=globalThis;if(typeof t.window<"u"&&t.window.isSecureContext===!1)return"INSECURE_CONTEXT";let e=t.navigator?.mediaDevices;return!e||typeof e.getUserMedia!="function"?"UNSUPPORTED":"OK"}function Lt(){let t=globalThis.MediaRecorder;return typeof t<"u"&&typeof t.isTypeSupported=="function"}var z=8*1024*1024;function O(t){return t.size>z}function ie(t){let e=(t||"").toLowerCase();return e.startsWith("image/jpeg")?"jpg":e.startsWith("video/mp4")?"mp4":(e.startsWith("video/webm"),"webm")}function Nt(t){let{token:e,clip:r,keyframe:i}=t,n=t.ts??Date.now(),a=r.type||U,o=i.type||"image/jpeg",s=new FormData;return s.append("token",e),s.append("clip",new File([r],`liveness-${n}.${ie(a)}`,{type:a})),s.append("keyframe",new File([i],`keyframe-${n}.${ie(o)}`,{type:o})),s}function ce(t,e,r=.92){return new Promise((i,n)=>{let a=t.videoWidth,o=t.videoHeight;if(!a||!o){n(new Error("video-not-ready"));return}let s=e.getContext("2d");if(!s){n(new Error("no-2d-context"));return}e.width=a,e.height=o,s.scale(-1,1),s.drawImage(t,-a,0),e.toBlob(l=>l?i(l):n(new Error("empty-keyframe")),"image/jpeg",r)})}var Vt={permission:{key:"fcv2.err.permission",fr:"Autorisez la cam\xE9ra dans les r\xE9glages du navigateur (ic\xF4ne cam\xE9ra dans la barre d\u2019adresse), puis r\xE9essayez."},notfound:{key:"fcv2.err.notfound",fr:"Aucune cam\xE9ra d\xE9tect\xE9e. Branchez ou activez une cam\xE9ra, puis r\xE9essayez."},inuse:{key:"fcv2.err.inuse",fr:"La cam\xE9ra est utilis\xE9e par une autre application. Fermez-la puis r\xE9essayez."},overconstrained:{key:"fcv2.err.overconstrained",fr:"La cam\xE9ra ne prend pas en charge les r\xE9glages demand\xE9s. Nouvel essai en cours\u2026"},insecure:{key:"fcv2.err.insecure",fr:"La cam\xE9ra n\xE9cessite une connexion s\xE9curis\xE9e (HTTPS). Ouvrez la page en HTTPS."},unsupported:{key:"fcv2.err.unsupported",fr:"Votre navigateur ne prend pas en charge l\u2019enregistrement vid\xE9o. Utilisez un navigateur r\xE9cent."},generic:{key:"fcv2.err.generic",fr:"Cam\xE9ra indisponible. R\xE9essayez ou contactez le support."}},Gt={recording:{key:"fcv2.recording",fr:"Enregistrement en cours\u2026"},uploading:{key:"fcv2.uploading",fr:"Envoi en cours\u2026"},clipTooLarge:{key:"fcv2.err.cliptoolarge",fr:"La vid\xE9o est trop volumineuse. R\xE9essayez dans un endroit mieux \xE9clair\xE9."},retry:{key:"fcv2.retry",fr:"R\xE9essayer"},listen:{key:"fcv2.listen",fr:"\xC9couter"}};var Ie=2500,Ae=1e3,Oe=1500,ue=25e5,y=class extends Error{constructor(e,r){super(r??e),this.kind=e}},P=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,r,i){if(this.recorder&&!this.settled)return Promise.reject(new y("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 n=ae();return new Promise((a,o)=>{let s;try{s=new MediaRecorder(e,n?{mimeType:n,videoBitsPerSecond:ue}:{videoBitsPerSecond:ue})}catch{try{s=new MediaRecorder(e)}catch{o(new y("unsupported"));return}}this.recorder=s;let l=u=>{this.settled||(this.settled=!0,this.clearTimers(),u())},c=()=>l(()=>{let u=s.mimeType||n||U,d=new Blob(this.chunks,{type:u});if(d.size===0){o(new y("generic","empty clip"));return}if(O(d)){o(new y("cliptoolarge"));return}a({blob:d,mimeType:u})});if(s.ondataavailable=u=>{u.data&&u.data.size&&(this.chunks.push(u.data),this.bytes+=u.data.size,this.bytes>z&&l(()=>{try{s.state!=="inactive"&&s.stop()}catch{}o(new y("cliptoolarge"))}))},s.onstop=c,s.onerror=()=>l(()=>o(new y("generic"))),i!==void 0){let u=!1;s.onstart=()=>{if(!(u||this.settled)){u=!0;try{i()}catch{}}}}try{s.start(Ae)}catch{l(()=>o(new y("generic")));return}this.hardStopTimer=setTimeout(()=>{if(this.settled||r?.(),s.state!=="inactive"){try{s.stop()}catch{c()}this.graceTimer=setTimeout(c,Oe)}else c()},Ie)})}stop(e){this.clearTimers();let r=this.recorder;if(r&&r.state!=="inactive")try{r.stop()}catch{}this.recorder=null,(e??this.stream)?.getTracks().forEach(n=>n.stop()),this.stream=null}};function le(t,e){return{video:{width:{ideal:1280,max:1280},height:{ideal:720,max:720},facingMode:e,frameRate:{ideal:24,max:30}},audio:!1}}var Pe=600;function q(){if(typeof window>"u"||typeof navigator>"u")return"desktop";let t=String(navigator.userAgent??"");if(/iPhone|iPod/i.test(t))return"phone";if(/iPad/i.test(t))return"tablet";if(/Android/i.test(t))return/Mobile/i.test(t)?"phone":"tablet";if(/BlackBerry|IEMobile|Opera Mini/i.test(t))return"phone";if(Number(navigator.maxTouchPoints??0)<=1)return"desktop";if(/Macintosh/.test(t))return"tablet";if(!Bt())return"desktop";let r=Ht();return r>0&&r<Pe?"phone":"tablet"}function de(){return q()!=="desktop"}function Ht(){try{let t=window.screen,e=Number(t?.width??0),r=Number(t?.height??0);return e>0&&r>0?Math.min(e,r):0}catch{return 0}}function me(t){try{let r=t?.getVideoTracks?.()[0]?.getSettings?.().facingMode;return r==="user"||r==="environment"?r:null}catch{return null}}function Bt(){try{return typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}catch{return!1}}var Wt=.45,Kt=.9,Ut=.4;var Fe=1e4,X=class t{constructor(e,r){this.tier="blaze";this.inner=e,r!==void 0&&(this.fallbackReason=r)}static async create(e,r){let i=await import("@mediapipe/tasks-vision"),n=await i.FilesetResolver.forVisionTasks(e),a=await i.FaceDetector.createFromOptions(n,{baseOptions:{modelAssetPath:`${e}/blaze_face_short_range.tflite`,delegate:"CPU"},runningMode:"IMAGE"});return new t(a,r)}async detect(e,r,i){let n;try{n=this.inner.detect(e).detections}catch{return null}let a=zt(n);if(a?.boundingBox===void 0)return null;let o=C(e),s=qt(a.keypoints,o),l=a.keypoints?.[2],c={box:{x:a.boundingBox.originX,y:a.boundingBox.originY,width:a.boundingBox.width,height:a.boundingBox.height},...s!==void 0?{eyes:s}:{},...l!==void 0?{nose:{x:l.x*o.width,y:l.y*o.height}}:{},score:a.categories[0]?.score??0};return F(c,e,r,i)}destroy(){try{this.inner.close()}catch{}}};function zt(t){let e,r=-1;for(let i of t){let n=i.categories[0]?.score??0;n>r&&(e=i,r=n)}return e}function qt(t,e){let r=t?.[0],i=t?.[1];if(r===void 0||i===void 0)return;let n=s=>({x:s.x*e.width,y:s.y*e.height}),[a,o]=[n(r),n(i)];return a.x<=o.x?{left:a,right:o}:{left:o,right:a}}function Xt(){if(typeof OffscreenCanvas=="function")return new OffscreenCanvas(2,2);let t=document.createElement("canvas");return t.width=2,t.height=2,t}async function Le(){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(Xt()),{ok:!0,instance:e}}catch(e){return{ok:!1,reason:`smoke_failed:${e instanceof Error?e.message:String(e)}`}}}var Y=class{constructor(e,r){this.tier="native";this.inner=e,r!==void 0&&(this.fallbackReason=r)}async detect(e,r,i){let n;try{n=await this.inner.detect(e)}catch{return null}let a=n[0];if(a===void 0)return null;let o=Yt(a.landmarks),s={box:{x:a.boundingBox.x,y:a.boundingBox.y,width:a.boundingBox.width,height:a.boundingBox.height},...o!==void 0?{eyes:o}:{},score:1};return F(s,e,r,i)}destroy(){}};function Yt(t){if(t===void 0)return;let e=t.filter(n=>n.type==="eye").map(n=>n.locations[0]).filter(n=>n!==void 0),[r,i]=e;if(!(r===void 0||i===void 0))return r.x<=i.x?{left:r,right:i}:{left:i,right:r}}var Ne="/models-v3",Ve=["native","blaze"],w=class extends Error{constructor(e){super(`no detector tier available (${e})`),this.name="DetectorLadderError",this.fallbackReason=e}};function C(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 r=typeof e.width=="number"?e.width:0,i=typeof e.height=="number"?e.height:0;return{width:r,height:i}}function F(t,e,r,i){let n=C(e),a=n.width>0?r/n.width:1,o=n.height>0?i/n.height:1,s=l=>({x:l.x*a,y:l.y*o});return{box:{x:t.box.x*a,y:t.box.y*o,width:t.box.width*a,height:t.box.height*o},...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 Zt(t){return t instanceof Error?t.message:String(t)}async function x(t){let e=t.preferred??Ve,r=[];for(let i of e){if(i==="native"){let n=await Le();if(n.ok)return new Y(n.instance,pe(r));r.push(`native:${n.reason}`);continue}try{return await jt(X.create(t.v3AssetBaseUrl??Ne,pe(r)),t.blazeInitTimeoutMs??Fe)}catch(n){r.push(n instanceof Z?"blaze:blaze_init_timeout":`blaze:${Zt(n)}`)}}throw new w(pe(r)??"no_tier_available")}function pe(t){return t.length>0?t.join("; "):void 0}var Z=class extends Error{};function jt(t,e){return new Promise((r,i)=>{let n=setTimeout(()=>{i(new Z(`init exceeded ${e}ms`)),t.then(a=>a.destroy(),()=>{})},e);t.then(a=>{clearTimeout(n),r(a)},a=>{clearTimeout(n),i(a)})})}var cn=180,L=[100,190],Qt=64;function Ge(t,e){return .299*(t[e]??0)+.587*(t[e+1]??0)+.114*(t[e+2]??0)}function j(t){let{data:e,width:r,height:i}=t,n=r*i;if(n===0)return 0;let a=0;for(let o=0;o<n;o+=1)a+=Ge(e,o*4);return a/n}function Q(t){let{data:e,width:r,height:i}=t;if(r<3||i<3)return 0;let n=new Float32Array(r*i);for(let u=0;u<n.length;u+=1)n[u]=Ge(e,u*4);let a=0,o=0,s=0;for(let u=1;u<i-1;u+=1)for(let d=1;d<r-1;d+=1){let m=u*r+d,p=(n[m-r]??0)+(n[m-1]??0)+(n[m+1]??0)+(n[m+r]??0)-4*(n[m]??0);a+=p,o+=p*p,s+=1}if(s===0)return 0;let l=a/s,c=o/s-l*l;return Math.min(1,Math.max(0,c)/180)}function fe(t){let e=j(t),[r,i]=L,n=e<r?r-e:e>i?e-i:0;return Math.max(0,1-n/Qt)}var He=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}),_=t=>Math.min(1,Math.max(0,t)),R=class{constructor(e={}){this.p=0;this.lastTickAt=null;this.lastCenter=null;this.velocityEma=0;this.qWindow=[];this.lastSizeDirection="ideal";this.t={...He,...e}}reset(){this.p=0,this.lastTickAt=null,this.lastCenter=null,this.velocityEma=0,this.qWindow=[],this.lastSizeDirection="ideal"}tick(e){let{observation:r,quality:i,timestampMs:n}=e,a=this.lastTickAt===null?0:Math.max(0,(n-this.lastTickAt)/1e3);this.lastTickAt=n;let o={presence:0,centering:0,size:0,pose:0,sharpness:_(i.sharpness),exposure:_(i.exposure),motion:1};if(r!==null){o.presence=1;let u=this.geometryOf(r,e);o.centering=u.centering,o.size=u.size,o.pose=u.pose,o.motion=this.motionOf(u.center,u.iod,n)}else this.lastCenter=null,this.velocityEma=0;let s=Math.min(o.presence,o.centering,o.size,o.pose,o.sharpness,o.exposure,o.motion);this.p=_(this.p+(s>=this.t.Q_GOOD?this.t.RISE_PER_S*s:-this.t.FALL_PER_S*(1-s))*a),this.qWindow.push({at:n,q:s}),this.qWindow=this.qWindow.filter(u=>u.at>=n-this.t.READY_WINDOW_MS);let l=this.qWindow.map(u=>u.q);if(l.length>=3){let u=Math.min(...l),d=l.indexOf(u);l=l.filter((m,p)=>p!==d)}let c=this.p>=1&&l.every(u=>u>=this.t.Q_GOOD);return{at:n,q:s,p:this.p,factors:o,guidanceKey:this.guidanceOf(o,i,s),ready:c,accepted:s>=this.t.Q_GOOD}}geometryOf(e,r){let{box:i,eyes:n}=e,a={x:r.frameWidth/2,y:r.frameHeight/2},o=Math.min(r.frameWidth,r.frameHeight),s=n!==void 0?{x:(n.left.x+n.right.x)/2,y:(n.left.y+n.right.y)/2}:{x:i.x+i.width/2,y:i.y+i.height/2-this.t.BOX_EYE_OFFSET_FACTOR*i.height},l=n!==void 0?Math.hypot(n.right.x-n.left.x,n.right.y-n.left.y):this.t.IOD_BOX_PROXY_FACTOR*i.width,c=Math.hypot(s.x-a.x,s.y-a.y),u=l<=0?0:1-_(c/(this.t.CENTER_FALLOFF_IOD_MULTIPLE*l)),d=o>0?l/o:0;this.lastSizeDirection=d<this.t.SIZE_IDEAL_MIN?"far":d>this.t.SIZE_IDEAL_MAX?"close":"ideal";let m;d<this.t.SIZE_HARD_MIN||d>this.t.SIZE_HARD_MAX?m=0:d<this.t.SIZE_IDEAL_MIN?m=(d-this.t.SIZE_HARD_MIN)/(this.t.SIZE_IDEAL_MIN-this.t.SIZE_HARD_MIN):d>this.t.SIZE_IDEAL_MAX?m=(this.t.SIZE_HARD_MAX-d)/(this.t.SIZE_HARD_MAX-this.t.SIZE_IDEAL_MAX):m=1;let p=1;if(n!==void 0){let f=Math.abs(Math.atan2(n.right.y-n.left.y,n.right.x-n.left.x))*180/Math.PI;p=1-_(f/this.t.ROLL_MAX_DEG)}return{center:s,iod:l,centering:u,size:m,pose:p}}motionOf(e,r,i){let n=this.lastCenter;if(this.lastCenter={...e,at:i},n===null||r<=0)return 1;let a=(i-n.at)/1e3;if(a<=0)return 1;let o=Math.hypot(e.x-n.x,e.y-n.y)/r/a;o<=this.t.MOTION_DEADBAND_IOD_PER_S&&(o=0);let s=1-Math.exp(-a/this.t.MOTION_TAU_S);return this.velocityEma=s*o+(1-s)*this.velocityEma,1-_(this.velocityEma/this.t.MOTION_VELOCITY_IOD_PER_S)}guidanceOf(e,r,i){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(r);if(e.sharpness<this.t.GUIDE_SHARPNESS)return"fcv3.steady_camera";if(e.motion<this.t.GUIDE_MOTION)return"fcv3.hold_still";if(i<this.t.Q_GOOD){let n=[["size",this.sizeGuidance()],["centering","fcv3.center_face"],["pose","fcv3.straighten"],["exposure",this.exposureGuidance(r)],["sharpness","fcv3.steady_camera"],["motion","fcv3.hold_still"]],a=n[0];for(let o of n)e[o[0]]<e[a[0]]&&(a=o);return a[1]}return"fcv3.hold_still"}sizeGuidance(){return this.lastSizeDirection==="far"?"fcv3.come_closer":"fcv3.move_back"}exposureGuidance(e){let r=(L[0]+L[1])/2;return e.meanLuma<r?"fcv3.more_light":"fcv3.too_bright"}};var Be=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"})}),$t=new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11]);function ge(){let t=typeof navigator>"u"?void 0:navigator,e=!1;try{e=typeof WebAssembly<"u"&&WebAssembly.validate($t)}catch{e=!1}return{cores:t?.hardwareConcurrency??2,memGB:t?.deviceMemory??null,simd:e}}function be(t){let e=t.memGB??4;return t.cores<4||e<3?"LOW":t.cores>=8&&e>=6?"HIGH":"MID"}var he=["LOW","MID","HIGH"],N=class{constructor(e){this.samples=[];this.adjusted=!1;this.current=e}get deviceClass(){return this.current}get profile(){return Be[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 r=this.samples.reduce((i,n)=>i+n,0)/this.samples.length;if(r>70)this.current="LOW";else if(r<25){let i=he.indexOf(this.current);this.current=he[Math.min(he.length-1,i+1)]??this.current}return this.current}};var V=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 r=()=>{this.running&&(this.frameCallbackId=e.requestVideoFrameCallback?.(()=>{this.frameCallbackId=null,this.now()-this.lastRunAt>=this.periodMs&&this.tick(),r()}))};r();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((r,i)=>r+i,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 We="0.1.0-rc.20";var Jt=/FBAN|FBAV|FB_IAB|FBIOS|MessengerForiOS|Instagram|WhatsApp|musical_ly|BytedanceWebview|TikTok|Snapchat|\bLine\/|LinkedInApp|Pinterest|MicroMessenger|; wv\)/i;function Ke(t){let e=t??(typeof navigator>"u"?"":String(navigator.userAgent??""));return Jt.test(e)}var Je="sekyro.did",br=1e4,rt=()=>globalThis.process?.versions?.node,et;function tt(){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 yr(){try{let t=localStorage.getItem(Je);if(t)return t;let e=tt();return e!==void 0&&localStorage.setItem(Je,e),e}catch{return et??(et=tt()),et}}async function vr(){let t=globalThis.crypto?.subtle;if(!t)return"";let e=navigator,r=JSON.stringify([e.userAgent,e.platform,e.hardwareConcurrency??null,e.deviceMemory??null,e.maxTouchPoints??0,screen.width,screen.height,screen.colorDepth,globalThis.devicePixelRatio??1,Intl.DateTimeFormat().resolvedOptions().timeZone,e.languages?.join(",")??e.language]),i=await t.digest("SHA-256",new TextEncoder().encode(r));return Array.from(new Uint8Array(i),n=>n.toString(16).padStart(2,"0")).join("").slice(0,32)}function Sr(t){let e=new TextEncoder().encode(t),r="";for(let i of e)r+=String.fromCharCode(i);return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function Er(t){let e,r,i,n,a,o,s=()=>o?.readyState==="live",l=()=>{a!==void 0||!globalThis.crypto?.subtle||rt()||s()||(a=Promise.race([Promise.resolve().then(()=>($e(),Qe)),new Promise(c=>setTimeout(c,br))]).then(c=>c?.computePrint(s)).then(c=>{c==="busy"?a=void 0:n=c}).catch(()=>{}))};return{timezone(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone?.slice(0,64)||void 0}catch{return}},noteCameraLabel(c){c&&(e=c.slice(0,128))},noteCamera(c){r=c},noteCameraTrack(c){o=c},async deviceHeader(){try{i??(i=vr().catch(()=>""));let c=[];navigator.webdriver&&c.push("webdriver"),/HeadlessChrome/.test(navigator.userAgent)&&c.push("headless");let u=await i,d=yr(),m={v:1,platform:"web",sdk:t.sdk.slice(0,64),ids:[...d?[{kind:"web_local",value:d.slice(0,128)}]:[],...u?[{kind:"web_fp",value:u}]:[]],screen:{w:screen.width,h:screen.height,dpr:globalThis.devicePixelRatio??1},...e?{cameraLabel:e}:{},...c.length?{signals:c}:{},...n?{print:{v:2,...n,...r?{camera:r}:{}}}:{},...Ke()?{inApp:!0}:{}},p=Sr(JSON.stringify(m));return l(),p}catch{return}},printReady(){return a??Promise.resolve()}}}var Ee=Symbol.for("sekyro.web.clientContext"),Me=globalThis,Te=Me[Ee]??(Me[Ee]=Er({sdk:`@sekyro/web@${We}`}));function nt(t){try{let e=t.getVideoTracks?.()[0];if(e){if(Te.noteCameraLabel(e.label),Te.noteCameraTrack(e),rt())return;Promise.resolve().then(()=>(Se(),Xe)).then(r=>r.noteCameraTrait(e,Te)).catch(()=>{})}}catch{}}var ke=Symbol.for("sekyro.web.cameraStreams"),Ce=globalThis,Mr=Ce[ke]??(Ce[ke]=new Set);function it(t){try{Mr.add(t)}catch{}}var Tr=["obs","manycam","virtual","snap camera","xsplit","droidcam","iriun","camo"],kr=[/^(front|back|rear)( [a-z ]+)? camera$/i,/^camera2? ?\d+, facing (front|back|external)/i,/facetime/i,/\b(integrated|built-in|builtin) (web)?cam(era)?\b/i,/\b(hd )?web ?cam\b/i,/\([0-9a-f]{4}:[0-9a-f]{4}\)\s*$/i];function Cr(t){let e=(t??"").trim().toLowerCase();return e.length===0?"unknown":Tr.some(r=>e.includes(r))?"known_virtual":kr.some(r=>r.test(e))?"platform":"unknown"}function at(t){if(typeof t!="function")return!1;try{return/\{\s*\[native code\]\s*\}\s*$/.test(Function.prototype.toString.call(t))}catch{return!1}}function wr(t=globalThis){return at(t.navigator?.mediaDevices?.getUserMedia)&&at(t.MediaStreamTrack?.prototype?.getSettings)}async function xr(t,e=globalThis){let r=e.crypto?.subtle?.digest;if(typeof r=="function")try{let i=new Uint8Array(await r.call(e.crypto?.subtle,"SHA-256",new TextEncoder().encode(t)));return Array.from(i.subarray(0,8),n=>n.toString(16).padStart(2,"0")).join("")}catch{return}}async function ot(t,e=globalThis){let r={};try{r=typeof t.getSettings=="function"?t.getSettings()??{}:{}}catch{r={}}let i={};if((r.facingMode==="user"||r.facingMode==="environment"||r.facingMode==="left"||r.facingMode==="right")&&(i.facingMode=r.facingMode),typeof r.frameRate=="number"&&Number.isFinite(r.frameRate)&&(i.frameRate=r.frameRate),typeof r.width=="number"&&Number.isFinite(r.width)&&(i.width=r.width),typeof r.height=="number"&&Number.isFinite(r.height)&&(i.height=r.height),typeof r.deviceId=="string"&&r.deviceId.length>0){let a=await xr(r.deviceId,e);a!==void 0&&(i.deviceIdHash=a)}let n;try{n=t.label}catch{n=void 0}return{trackSettings:i,capabilitiesPresent:typeof t.getCapabilities=="function",labelClass:Cr(n),prototypesIntact:wr(e)}}var we=t=>Math.round(t*100)/100;function st(t){let e=t,r=typeof e?.requestVideoFrameCallback=="function",i=null,n=null,a=0,o=0,s=0,l=0,c=0,u=0,d=()=>{!r||e?.requestVideoFrameCallback===void 0||(i=e.requestVideoFrameCallback((m,p)=>{if(i=null,!r)return;let f=p.presentationTime;if(n!==null){let h=f-n.presentationTimeMs;o+=1;let g=h-s;s+=g/o,l+=g*(h-s)}typeof p.captureTime=="number"&&Number.isFinite(p.captureTime)&&(c+=f-p.captureTime,u+=1),a+=1,n={mediaTimeMs:p.mediaTime*1e3,presentationTimeMs:f},d()}))};return d(),{latest:()=>n,stats:()=>({n:a,meanGapMs:o===0?0:we(s),stdGapMs:o<2?0:we(Math.sqrt(l/(o-1))),captureLatencyMs:u===0?null:we(c/u)}),stop:()=>{r&&(r=!1,i!==null&&e?.cancelVideoFrameCallback?.(i),i=null)}}}function ct(t,e,r){return{...t,rvfc:e,rampPainter:r}}var _r=["rose","peach","sand","mint","sky","lilac"];var Rr=4,Dr=4;function Ir(t){if(typeof t!="object"||t===null)return!1;let e=t;if(typeof e.nonce!="string"||e.nonce.length===0||!Array.isArray(e.colours)||e.colours.length!==3||!e.colours.every(i=>_r.includes(i))||!Array.isArray(e.onsetsMs)||e.onsetsMs.length!==3)return!1;let r=-1;for(let i of e.onsetsMs){if(typeof i!="number"||!Number.isFinite(i)||i<=r||i>=2e3)return!1;r=i}return!0}function ut(t,e){let r=e.now??(()=>performance.now()),i=Ir(t)?t:void 0,n=[],a=null,o=null,s=null,l=!1,c=null,u=f=>{c=f;try{e.paint(f)}catch{}},d=f=>{let h=e.frames?.()??null;return h!==null&&s!==null?h.mediaTimeMs+(f-h.presentationTimeMs)-s:f-(o??f)},m=(f,h,g=0)=>{if(l)return;let S=Math.max(0,f-d(r()));a=setTimeout(()=>{if(a=null,!l){if(g<Rr&&d(r())<f-Dr){m(f,h,g+1);return}h()}},S)},p=f=>{if(i!==void 0){if(f>=3){m(2e3,()=>u(null));return}m(i.onsetsMs[f],()=>{let h=d(r());if(h>2e3){c!==null&&u(null);return}let g=i.colours[f];u(g);let S=n.length===0?0:n[n.length-1].tMs;n.push({tMs:Math.max(S,Math.round(h)),colour:g}),p(f+1)})}};return{started(f){if(i===void 0||l||o!==null)return;o=f;let h=e.frames?.()??null;s=h===null?null:h.mediaTimeMs+(f-h.presentationTimeMs),p(0)},stop(){l||(l=!0,a!==null&&clearTimeout(a),a=null,c!==null&&u(null))},report(){return i===void 0?void 0:{nonce:i.nonce,rendered:[...n]}}}}var Ar=40;function H(t){if(t===null||typeof t!="object"&&typeof t!="function")return;let e;try{e=t.name}catch{return}return Or(e)}function Or(t){if(typeof t!="string")return;let e=t.replace(/[^A-Za-z]/g,"").slice(0,Ar);return e===""?void 0:e}function lt(t){let e=oe(t);if(e!=="generic")return e;switch(H(t)){case"AbortError":return"inuse";case"SecurityError":return"permission";default:return e}}var M=1;function dt(){return typeof OffscreenCanvas=="function"&&typeof createImageBitmap=="function"&&typeof Worker=="function"}function Pr(t,e={}){let r=e.createDetector??x,i=null;t.onmessage=n=>{let a=n.data;if(a.v!==M){a.bitmap?.close?.();return}if(a.type==="init"){r(a.options).then(o=>{i=o;let s={v:M,type:"ready",tier:o.tier,...o.fallbackReason!==void 0?{fallbackReason:o.fallbackReason}:{}};t.postMessage(s)});return}if(a.type==="detect"){let o=s=>{let l={v:M,type:"result",id:a.id,observation:s};t.postMessage(l),a.bitmap.close?.()};if(i===null){o(null);return}i.detect(a.bitmap,a.streamWidth,a.streamHeight).then(o,()=>o(null))}}}typeof self<"u"&&typeof self.importScripts=="function"&&Pr(self);var J=class t{constructor(e,r){this.pending=new Map;this.nextId=1;this.worker=e,this.tier=r.tier,r.fallbackReason!==void 0&&(this.fallbackReason=r.fallbackReason),e.addEventListener("message",i=>{let n=i.data;if(n.v!==M||n.type!=="result")return;let a=this.pending.get(n.id);this.pending.delete(n.id),a?.(n.observation)})}static create(e,r,i=1e4){return new Promise((n,a)=>{let o=setTimeout(()=>{e.removeEventListener("message",s),e.terminate(),a(new Error(`worker detector not ready within ${i}ms`))},i),s=c=>{let u=c.data;u.v!==M||u.type!=="ready"||(clearTimeout(o),e.removeEventListener("message",s),n(new t(e,u)))};e.addEventListener("message",s);let l={v:M,type:"init",options:r};e.postMessage(l)})}async detect(e,r,i){let n;try{typeof ImageBitmap<"u"&&e instanceof ImageBitmap?n=e:typeof createImageBitmap=="function"?n=await createImageBitmap(e):n=e}catch{return null}let a=this.nextId;return this.nextId+=1,new Promise(o=>{this.pending.set(a,o);let s={v:M,type:"detect",id:a,bitmap:n,streamWidth:r,streamHeight:i};this.worker.postMessage(s,[n])})}destroy(){for(let e of this.pending.values())e(null);this.pending.clear(),this.worker.terminate()}};var Fr=["size","centering","pose","exposure","sharpness","motion"];function mt(t){if(t.accepted)return null;if(t.factors.presence<=0)return"no_face";let e="size";for(let r of Fr)t.factors[r]<t.factors[e]&&(e=r);return e}var D=class{constructor(){this.blocked={};this.acceptedMs=0;this.ticks=0;this.lastAt=null}record(e){let r=this.lastAt===null?0:Math.max(0,e.at-this.lastAt);this.lastAt=e.at,this.ticks+=1;let i=mt(e);if(i===null){this.acceptedMs+=r;return}let n=this.blocked[i]??{count:0,ms:0};n.count+=1,n.ms+=r,this.blocked[i]=n}summary(){let e={};for(let[r,i]of Object.entries(this.blocked))e[r]={count:i.count,ms:Math.round(i.ms)};return{blocked:e,acceptedMs:Math.round(this.acceptedMs),ticks:this.ticks}}};var kt=1e3,te="fcv3.hold_upright",Ct=200,re=4,wt=600,xt=1e3,Mt={sharpness:1,exposure:1,meanLuma:128};function Wr(t,e){return e.width=t.videoWidth,e.height=t.videoHeight,e.getContext("2d").drawImage(t,0,0),new Promise((r,i)=>e.toBlob(n=>n?r(n):i(new Error("empty-keyframe")),"image/jpeg",.92))}function Kr(){return q()==="phone"}var _e=class{constructor(e){this.handlers=new Map;this.stateValue="idle";this.attempt=0;this.stream=null;this.detector=null;this.scheduler=null;this.gate=null;this.profiler=null;this.lastGuidanceKey=null;this.positioningStartedAt=0;this.cameraRequestedAt=null;this.cameraReadyAt=null;this.faceAcquiredAt=null;this.captureCompleteAt=null;this.fired=!1;this.carriedDegrade=0;this.carriedMeans=[];this.blockStats=null;this.lastGateSnapshotAt=Number.NEGATIVE_INFINITY;this.uprightGuard=!1;this.trackProvenance=null;this.ramp=null;this.snapshotCanvas=null;this.options=e,this.facing=e.facingMode??"user"}get state(){return this.stateValue}on(e,r){let i=this.handlers.get(e);return i||(i=new Set,this.handlers.set(e,i)),i.add(r),()=>i?.delete(r)}emit(e,r){for(let i of[...this.handlers.get(e)??[]])i(r)}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:r}=this;this.fired=!1,this.lastGuidanceKey=null,this.carriedDegrade=0,this.carriedMeans=[],this.cameraRequestedAt=null,this.cameraReadyAt=null,this.faceAcquiredAt=null,this.captureCompleteAt=null,this.uprightGuard=(r.isPhone??Kr)(),this.setState("preflight");let i=se();if(i!=="OK"){this.fail(i==="INSECURE_CONTEXT"?"insecure":"unsupported",{phase:"preflight"});return}this.setState("acquiring");let n=r.getUserMedia??(c=>navigator.mediaDevices.getUserMedia(c)),a;this.cameraRequestedAt=this.now();try{a=await n(le(de(),this.facing))}catch(c){if(e!==this.attempt)return;this.fail(lt(c),{phase:"acquiring",name:H(c)});return}if(nt(a),it(a),e!==this.attempt){for(let c of a.getTracks())c.stop();return}this.stream=a;let o=a.getVideoTracks?.()[0];if(this.trackProvenance=o===void 0?null:ot(o).catch(()=>null),this.facing=me(a)??this.facing,r.video.srcObject=a,await r.video.play().catch(()=>{}),e!==this.attempt)return;if(this.cameraReadyAt=this.now(),this.detector===null){let c={v3AssetBaseUrl:r.v3AssetBaseUrl},u=r.createDetector??(r.createWorker!==void 0&&dt()?async()=>{try{return await J.create(r.createWorker(),c)}catch{return x(c)}}:()=>x(c)),d;try{d=await u()}catch(m){e===this.attempt&&this.fail("models",{phase:"models",name:H(m)},m instanceof w?m.fallbackReason:zr(m));return}if(e!==this.attempt){d.destroy();return}this.detector=d,this.options.telemetry?.({type:"detector",tier:d.tier,fallbackReason:d.fallbackReason})}let s=ge(),l=r.deviceClass??be(s);this.profiler=new N(l),this.options.telemetry?.({type:"profile",staticClass:l,activeClass:this.profiler.deviceClass,simd:s.simd}),this.gate=new R(r.thresholds??{}),this.blockStats=new D,this.lastGateSnapshotAt=this.now(),r.rankKeyframes?.()&&Promise.resolve().then(()=>(Et(),St)).then(c=>xe=c,()=>{}),this.setState("positioning"),this.positioningStartedAt=this.now(),this.startScheduler(e)}get animations(){return this.profiler?.profile.animations??"full"}startScheduler(e){let r=this.profiler;if(r===null)return;if(this.scheduler!==null){let n=this.scheduler.stats();this.carriedDegrade+=n.degradeCount,n.meanDetectMs>0&&this.carriedMeans.push(n.meanDetectMs),this.scheduler.stop()}let i=new V({cadenceHz:r.profile.cadenceHz,video:this.options.video,now:this.options.now,run:()=>this.detectTick(e)});this.scheduler=i,i.start()}async detectTick(e){let{detector:r,gate:i,profiler:n}=this,a=this.options.video;if(e!==this.attempt||r===null||i===null||n===null||this.fired||a.videoWidth===0)return;if(this.isLandscape()){this.holdUpright(e);return}let o=n.deviceClass,s=this.now(),l=this.options.makeSnapshot?.(a,n.profile.inputWidth)??this.defaultSnapshot(a,n.profile.inputWidth),c=null;try{c=await r.detect(l,a.videoWidth,a.videoHeight)}catch{c=null}if(e!==this.attempt||this.fired)return;n.record(this.now()-s),n.deviceClass!==o&&this.startScheduler(e);let u=c===null?Mt:this.options.measureQuality?.(a,c.box)??this.defaultQuality(a,c.box),d=i.tick({timestampMs:this.now(),observation:c,quality:u,frameWidth:a.videoWidth,frameHeight:a.videoHeight});d.accepted&&this.faceAcquiredAt===null&&(this.faceAcquiredAt=d.at),this.blockStats?.record(d),!d.ready&&d.at-this.lastGateSnapshotAt>=kt&&(this.lastGateSnapshotAt=d.at,this.reportGate(!1)),this.emit("checks",{engine:"v3",progress:d.p,q:d.q,factors:d.factors,attempt:e}),d.guidanceKey!==this.lastGuidanceKey&&(this.lastGuidanceKey=d.guidanceKey,this.emit("guidance",{key:d.guidanceKey})),d.ready&&this.stateValue==="positioning"&&(this.fired=!0,this.captureCompleteAt=d.at,this.fire(e))}async fire(e){let{options:r}=this,i=this.scheduler;i?.stop(),this.reportGate(!0);let n=i?.stats()??{degradeCount:0,meanDetectMs:0},a=[...this.carriedMeans,...n.meanDetectMs>0?[n.meanDetectMs]:[]];r.telemetry?.({type:"fired",timeToGateMs:this.now()-this.positioningStartedAt,degradeCount:this.carriedDegrade+n.degradeCount,meanDetectMs:a.length===0?0:a.reduce((b,E)=>b+E,0)/a.length});let o=r.mode??"clip",s=r.rankKeyframes?.()&&xe?xe.default(this,e).catch(()=>this.collectKeyframes(e)):this.collectKeyframes(e);if(o==="photo"){let b=this.watchRotation(e,null),E=await s;if(b(),e!==this.attempt)return;if(E===null){this.fail("generic",{phase:"keyframes"});return}let _t=await this.provenance({n:0,meanGapMs:0,stdGapMs:0,captureLatencyMs:null},!1);if(e!==this.attempt)return;this.finishCapture({keyframe:E.blob,previewDataUrl:E.previewDataUrl,..._t});return}this.setState("recording");let l=r.createRecorder?.()??new P,c=this.stream;if(c===null){this.fail("generic",{phase:"recording"});return}let u=st(r.video),d=r.screenRamp?.(),m=d!==void 0,p=ut(d,{paint:b=>{(b===null||e===this.attempt)&&this.emit("ramp",{colour:b})},now:()=>this.now(),frames:u.latest});this.ramp=p;let f=()=>{u.stop(),p.stop(),this.ramp===p&&(this.ramp=null)},h=this.watchRotation(e,l),g=null;s.then(b=>{g=b},()=>{});let S=()=>{e===this.attempt&&g!==null&&this.emit("frozen",{previewDataUrl:g.previewDataUrl})},v,T;try{[v,T]=await Promise.all([l.record(c,S,()=>p.started(this.now())),s])}catch(b){if(h(),f(),e!==this.attempt)return;let E=b.kind;this.fail(E==="cliptoolarge"?"cliptoolarge":"recorder",{phase:"recording",name:H(b)});return}h();let k=u.stats();if(f(),e!==this.attempt)return;if(O(v.blob)){this.fail("cliptoolarge",{phase:"recording"});return}if(T===null){this.fail("generic",{phase:"keyframes"});return}let A=p.report(),ne=await this.provenance(k,m);e===this.attempt&&this.finishCapture({clip:v.blob,clipMimeType:v.mimeType,keyframe:T.blob,previewDataUrl:T.previewDataUrl,...A!==void 0&&A.rendered.length>0?{screenRamp:A}:{},...ne})}async provenance(e,r){let i=this.trackProvenance;if(i===null)return{};let n,a=new Promise(s=>{n=setTimeout(()=>s(null),xt)}),o=await Promise.race([i,a]);return clearTimeout(n),o===null?{}:{provenance:ct(o,e,r)}}isLandscape(){let e=this.options.video;return this.uprightGuard&&e.videoWidth>e.videoHeight}holdUpright(e){this.gate?.reset(),this.emit("checks",{engine:"v3",progress:0,q:0,factors:{presence:0,centering:0,size:0,pose:0,sharpness:0,exposure:0,motion:0},attempt:e}),this.lastGuidanceKey!==te&&(this.lastGuidanceKey=te,this.emit("guidance",{key:te}))}watchRotation(e,r){if(!this.uprightGuard)return()=>{};let i=this.options.video,n=()=>{if(e!==this.attempt||r!==null&&this.stateValue!=="recording"){s();return}i.videoWidth>0&&this.isLandscape()&&(s(),this.abortRecording(e,r))},a=setInterval(n,Ct);i.addEventListener?.("resize",n);let o=!1;function s(){o||(o=!0,clearInterval(a),i.removeEventListener?.("resize",n))}return s}abortRecording(e,r){if(e!==this.attempt)return;this.attempt+=1;let i=this.attempt;try{r?.stop()}catch{}this.ramp?.stop(),this.ramp=null,this.fired=!1,this.captureCompleteAt=null,this.gate=new R(this.options.thresholds??{}),this.blockStats=new D,this.lastGateSnapshotAt=this.now(),this.lastGuidanceKey=null,this.setState("positioning"),this.positioningStartedAt=this.now(),this.holdUpright(i),this.startScheduler(i)}async collectKeyframes(e){let r=this.options.captureKeyframe??(a=>this.defaultKeyframe(a)),i=wt/(re-1),n=null;for(let a=0;a<re;a+=1){if(e!==this.attempt)return n;try{let o=await r(this.options.video);(n===null||o.sharpness>n.sharpness)&&(n=o)}catch{}a<re-1&&await Ur(i)}return n}finishCapture(e){this.stopTracks(),this.setState("captured");let r=this.captureTiming();this.emit("artifacts",r===void 0?e:{...e,timing:r})}captureTiming(){let e={},r=(i,n,a)=>{n!==null&&a!==null&&(e[i]=Math.max(0,Math.round(a-n)))};return r("cameraReadyMs",this.cameraRequestedAt,this.cameraReadyAt),r("faceAcquireMs",this.cameraReadyAt,this.faceAcquiredAt),r("captureMs",this.faceAcquiredAt,this.captureCompleteAt),Object.keys(e).length>0?e:void 0}async defaultKeyframe(e){let r=document.createElement("canvas"),i=await(this.facing==="user"?ce:Wr)(e,r),n=r.toDataURL("image/jpeg",.92);return{blob:i,previewDataUrl:n,sharpness:this.centerSharpness(e)}}defaultSnapshot(e,r){try{let i=this.snapshotCanvas??document.createElement("canvas"),n=r/Math.max(1,e.videoWidth),a=Math.max(1,Math.round(e.videoWidth*n)),o=Math.max(1,Math.round(e.videoHeight*n)),s=i.getContext("2d");return s===null?e:(i.width!==a&&(i.width=a),i.height!==o&&(i.height=o),s.drawImage(e,0,0,a,o),this.snapshotCanvas=i,i)}catch{return e}}defaultQuality(e,r){let i=Tt(e,r,96);return i===null?Mt:{sharpness:Q(i),exposure:fe(i),meanLuma:j(i)}}centerSharpness(e){let r=C(e),i=Tt(e,{x:r.width*.25,y:r.height*.25,width:r.width*.5,height:r.height*.5},96);return i===null?0:Q(i)}teardownAttempt(){this.scheduler?.stop(),this.scheduler=null,this.reportGate(!0),this.gate=null,this.ramp?.stop(),this.ramp=null,this.stopTracks()}reportGate(e){let r=this.blockStats,i=this.profiler;if(r===null||i===null)return;let n=r.summary();e&&(this.blockStats=null),n.ticks!==0&&this.options.telemetry?.({type:"gate",final:e,activeClass:i.deviceClass,cadenceHz:i.profile.cadenceHz,...n})}stopTracks(){if(this.stream!==null){for(let e of this.stream.getTracks())e.stop();this.stream=null}}fail(e,r,i){this.scheduler?.stop(),this.reportGate(!0),this.stopTracks(),this.setState("error"),this.options.telemetry?.({type:"error",kind:e,fallbackReason:i});let{phase:n,name:a}=r;this.emit("error",{kind:e,retryable:e!=="insecure"&&e!=="unsupported",detail:a===void 0?{phase:n}:{phase:n,name:a}})}setState(e){this.stateValue=e,this.emit("statechange",{state:e})}now(){return this.options.now?.()??performance.now()}},xe;function Ur(t){return new Promise(e=>setTimeout(e,t))}function zr(t){return t instanceof Error?t.message:String(t)}function Tt(t,e,r){try{let i=document.createElement("canvas"),n=r/Math.max(1,e.width);i.width=Math.max(1,Math.round(e.width*n)),i.height=Math.max(1,Math.round(e.height*n));let a=i.getContext("2d");return a===null?null:(a.drawImage(t,e.x,e.y,e.width,e.height,0,0,i.width,i.height),a.getImageData(0,0,i.width,i.height))}catch{return null}}0&&(module.exports={CENTERED_FACTOR,CIRCLE_RADIUS_FACTOR,CLIP_MS,CaptureSessionV3,ClipError,ClipRecorder,DEFAULT_CLIP_MIME,DEFAULT_TIER_ORDER,DEFAULT_V3_ASSET_BASE_URL,DEVICE_PROFILES,DetectScheduler,DetectorLadderError,DeviceProfiler,EXPOSURE_BAND,FaceGateV3,GATE_SNAPSHOT_MS,GateBlockStats,HOLD_UPRIGHT_KEY,IN_CIRCLE_FACTOR,KEYFRAME_CANDIDATES,KEYFRAME_WINDOW_MS,MAX_CLIP_BYTES,MIME_CANDIDATES,PHONE_MAX_SHORT_SIDE,PROVENANCE_WAIT_MS,SHARP_REF,STOP_GRACE_MS,TIMESLICE_MS,UPRIGHT_WATCH_MS,V3_GATE_DEFAULTS,VIDEO_BPS,blockReasonOf,buildCaptureConstraints,buildLivenessV2FormData,cameraPreflight,captureMirroredKeyframe,classifyDevice,createDetector,detectFormFactor,detectIsMobile,errorCopy,exposure,extForMime,intrinsicSize,isClipTooLarge,isMediaRecorderSupported,mapGetUserMediaError,meanLuma,pickMimeType,probeDevice,sharpness,toStreamPixels,trackFacingMode,uiCopy});
1
+ "use strict";var fr=Object.create;var Y=Object.defineProperty;var pr=Object.getOwnPropertyDescriptor;var hr=Object.getOwnPropertyNames;var gr=Object.getPrototypeOf,br=Object.prototype.hasOwnProperty;var L=(t,e)=>()=>(t&&(e=t(t=0)),e);var N=(t,e)=>{for(var r in e)Y(t,r,{get:e[r],enumerable:!0})},Ke=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of hr(e))!br.call(t,i)&&i!==r&&Y(t,i,{get:()=>e[i],enumerable:!(n=pr(e,i))||n.enumerable});return t};var yr=(t,e,r)=>(r=t!=null?fr(gr(t)):{},Ke(e||!t||!t.__esModule?Y(r,"default",{value:t,enumerable:!0}):r,t)),vr=t=>Ke(Y({},"__esModule",{value:!0}),t);var rt={};N(rt,{blobBytes:()=>Xe,inspectClip:()=>Rr,inspectClipBytes:()=>Ye,webmDurationMs:()=>Hr,withWebmDuration:()=>Br});async function Rr(t){try{return Ye(await Xe(t))}catch{return null}}async function Xe(t){return typeof t.arrayBuffer=="function"?new Uint8Array(await t.arrayBuffer()):new Promise((e,r)=>{let n=new FileReader;n.onload=()=>e(new Uint8Array(n.result)),n.onerror=()=>r(n.error),n.readAsArrayBuffer(t)})}function Ye(t){if(t.length<8)return null;try{if(t[0]===26&&t[1]===69&&t[2]===223&&t[3]===163)return Gr(t);if(be(t,4,4)==="ftyp")return Ar(t)}catch{return null}return null}function Ar(t){let e=new DataView(t.buffer,t.byteOffset,t.byteLength),r=[],n=null,i=null,a=0,o=(c,u)=>{let l=c;for(;l+8<=u;){let d=e.getUint32(l),f=be(t,l+4,4),h=8;if(d===1){if(l+16>u)return;d=Number(e.getBigUint64(l+8)),h=16}else d===0&&(d=u-l);if(d<h)return;let p=Math.min(l+d,u),m=l+h;if(f==="trak"&&(n={id:0,video:!1,timescale:0,frames:0,units:0,defaultDuration:0},r.push(n)),f==="traf"&&(i=null,a=0),_r.has(f))o(m,p);else if(f==="tkhd"&&n)n.id=e.getUint32(m+(t[m]===1?20:12));else if(f==="hdlr"&&n)n.video=be(t,m+8,4)==="vide";else if(f==="mdhd"&&n)n.timescale=e.getUint32(m+(t[m]===1?20:12));else if(f==="stts"&&n){let b=e.getUint32(m+4);for(let g=0;g<b;g++){let y=e.getUint32(m+8+g*8);n.frames+=y,n.units+=y*e.getUint32(m+12+g*8)}}else if(f==="trex"){let b=r.find(g=>g.id===e.getUint32(m+4));b&&(b.defaultDuration=e.getUint32(m+12))}else if(f==="tfhd"){let b=e.getUint32(m)&16777215;i=r.find(y=>y.id===e.getUint32(m+4))??null;let g=m+8;b&1&&(g+=8),b&2&&(g+=4),a=b&8?e.getUint32(g):i?.defaultDuration??0}else if(f==="trun"&&i){let b=e.getUint32(m)&16777215,g=e.getUint32(m+4),y=m+8;b&1&&(y+=4),b&4&&(y+=4);let S=(b&256?4:0)+(b&512?4:0)+(b&1024?4:0)+(b&2048?4:0);for(let M=0;M<g;M++)i.units+=b&256?e.getUint32(y+M*S):a;i.frames+=g}l=p}};o(0,t.length);let s=r.find(c=>c.video&&c.timescale>0);return!s||s.frames===0?null:{container:"mp4",frames:s.frames,durationMs:Me(s.units*1e3/s.timescale)}}function Ur(t,e){let r=t[e];if(r===void 0||r===0)return null;let n=Math.clz32(r)-23;if(n<1||n>4||e+n>t.length)return null;let i=0;for(let a=0;a<n;a++)i=i*256+t[e+a];return[i,n]}function tt(t,e){let r=t[e];if(r===void 0||r===0)return null;let n=Math.clz32(r)-23;if(n<1||n>8||e+n>t.length)return null;let i=r&255>>n,a=i===255>>n;for(let o=1;o<n;o++){let s=t[e+o];i=i*256+s,s!==255&&(a=!1)}return[a?-1:i,n]}function C(t,e,r){let n=0;for(let i=0;i<r;i++)n=n*256+t[e+i];return n}function ve(t){let e=[],r=0;for(;r<t.length;){let n=Ur(t,r);if(!n)break;let i=tt(t,r+n[1]);if(!i)break;let a={id:n[0],start:r,sizeAt:r+n[1],data:r+n[1]+i[1],size:i[0]};if(e.push(a),et.has(a.id))r=a.data;else{if(a.size<0)break;r=a.data+a.size}}return e}function Gr(t){let e=new DataView(t.buffer,t.byteOffset,t.byteLength),r=1e6,n=[],i=0,a=[];for(let c of ve(t)){if(c.data+Math.max(0,c.size)>t.length&&!et.has(c.id))break;switch(c.id){case ye:r=C(t,c.data,c.size)||r;break;case Qe:n.push({num:0,type:0});break;case Or:n.length&&(n[n.length-1].num=C(t,c.data,c.size));break;case Pr:n.length&&(n[n.length-1].type=C(t,c.data,c.size));break;case Fr:i=C(t,c.data,c.size);break;case Lr:case Nr:{let u=tt(t,c.data);if(!u||c.data+u[1]+2>t.length)break;let l=n.filter(d=>d.type===1).map(d=>d.num);if(l.length>0&&!l.includes(u[0]))break;a.push((i+e.getInt16(c.data+u[1]))*r/1e6);break}default:break}}if(a.length===0)return null;a.sort((c,u)=>c-u);let o=a.slice(1).map((c,u)=>c-a[u]),s=o.length?o.sort((c,u)=>c-u)[Math.floor(o.length/2)]:0;return{container:"webm",frames:a.length,durationMs:Me(a[a.length-1]-a[0]+s)}}function Br(t,e){if(!(e>0))return null;let r=ve(t),n=r.find(m=>m.id===Ze);if(!n||n.size!==-1||r.some(m=>m.id===Vr))return null;let i=r.find(m=>m.id===je);if(!i||i.size<0||i.data+i.size>t.length)return null;let a=1e6,o=[];for(let m of r)m.start<i.data||m.start>=i.data+i.size||(m.id===ye&&(a=C(t,m.data,m.size)||a),m.id!==Je&&o.push(t.subarray(m.start,m.data+m.size)));let s=new Uint8Array(11);s.set([68,137,136]),new DataView(s.buffer).setFloat64(3,e*1e6/a);let c=o.reduce((m,b)=>m+b.length,0)+s.length,u=new Uint8Array(12);u.set([21,73,169,102,1]);let l=c;for(let m=11;m>=5;m--)u[m]=l&255,l=Math.floor(l/256);let d=t.subarray(i.data+i.size),f=new Uint8Array(i.start+u.length+c+d.length),h=0,p=m=>{f.set(m,h),h+=m.length};return p(t.subarray(0,i.start)),p(u),o.forEach(p),p(s),p(d),f}function Hr(t){let e=1e6,r=null,n=new DataView(t.buffer,t.byteOffset,t.byteLength);for(let i of ve(t))if(i.id===ye&&(e=C(t,i.data,i.size)||e),i.id===Je&&(r=i.size===8?n.getFloat64(i.data):i.size===4?n.getFloat32(i.data):null),i.id===$e)break;return r===null?null:Me(r*e/1e6)}function be(t,e,r){let n="";for(let i=0;i<r&&e+i<t.length;i++)n+=String.fromCharCode(t[e+i]);return n}function Me(t){return Math.round(t*10)/10}var _r,Ze,je,Dr,Qe,$e,Ir,ye,Je,Or,Pr,Fr,Lr,Nr,Vr,et,nt=L(()=>{"use strict";_r=new Set(["moov","trak","mdia","minf","stbl","mvex","moof","traf","edts"]);Ze=408125543,je=357149030,Dr=374648427,Qe=174,$e=524531317,Ir=160,ye=2807729,Je=17545,Or=215,Pr=131,Fr=231,Lr=163,Nr=161,Vr=290298740,et=new Set([Ze,je,Dr,Qe,$e,Ir])});function St(t){let e=(t??"").trim().toLowerCase();return e.length===0?"unknown":sn.some(r=>e.includes(r))?"known_virtual":cn.some(r=>r.test(e))?"platform":"unknown"}var sn,cn,Tt=L(()=>{"use strict";sn=["obs","manycam","virtual","snap camera","xsplit","droidcam","iriun","camo"],cn=[/^(front|back|rear)( [a-z ]+)? camera$/i,/^caméra (avant|arrière)\b/i,/^cámara (frontal|trasera|delantera)\b/i,/^câmera (frontal|traseira)\b/i,/^(front|rück)kamera\b/i,/^الكاميرا (الأمامية|الخلفية)/,/^camera2? ?\d+, facing (front|back|external)/i,/facetime/i,/\b(integrated|built-in|builtin) (web)?cam(era)?\b/i,/\b(hd )?web ?cam\b/i,/\([0-9a-f]{4}:[0-9a-f]{4}\)\s*$/i]});var Et={};N(Et,{bounded:()=>q,cameraHash:()=>wt,hex16:()=>oe,noteCameraTrait:()=>dn});function q(t,e){return new Promise(r=>{let n=setTimeout(()=>r(void 0),e),i=a=>{clearTimeout(n),r(a)};try{t().then(i,()=>i(void 0))}catch{i(void 0)}})}async function oe(t){let e=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(JSON.stringify(t)));return Array.from(new Uint8Array(e).subarray(0,8),r=>r.toString(16).padStart(2,"0")).join("")}function ln(t){try{return t.getSettings?.().facingMode==="environment"}catch{return!1}}async function wt(t){try{if(t.readyState==="ended"||ln(t))return;let e={};try{e=t.getCapabilities?.()??{}}catch{}let r=await q(()=>navigator.mediaDevices.enumerateDevices(),un);return await oe([Ie(e.width),Ie(e.height),Ie(e.frameRate),De(e.facingMode),De(e.focusMode),De(e.exposureMode),St(t.label),r?.filter(n=>n.kind==="videoinput").length??null])}catch{return}}async function dn(t,e){let r=await wt(t);r&&e.noteCamera(r)}var un,De,Ie,Oe=L(()=>{"use strict";Tt();un=1e3;De=t=>Array.isArray(t)?[...t].sort():null,Ie=t=>{let e=t;return e==null?null:[e.min??null,e.max??null]}});var _t={};N(_t,{computePrint:()=>Tn,readHints:()=>Rt});function xt(t,e){if(typeof t!="string")return;let r=t.trim();return r.length>0&&r.length<=e?r:void 0}async function Rt(){let t=navigator.userAgentData;if(typeof t?.getHighEntropyValues!="function")return;let e=await q(()=>t.getHighEntropyValues(["model","platformVersion"]),hn);if(e==null)return;let r=xt(e.model,bn),n=xt(e.platformVersion,yn),i={...r!==void 0?{model:r}:{},...n!==void 0?{platformVersion:n}:{}};return Object.keys(i).length>0?i:void 0}async function kn(){let[t,e]=await Promise.all([new Ct.Thumbmark({stabilize:["private","iframe"],exclude:["permissions","webrtc","speech"],logging:!1,collect_beacon:!1,timeout:fn}).get(),Rt()]),r=t?.thumbmark;if(typeof r!="string"||r.length<vn||r.length>Mn)return;let n={};for(let i of mn){let a=t.components?.[i];a==null||a.timeout==="true"||(n[i]=await oe(a))}return{hash:r,c:n,...e!==void 0?{hints:e}:{}}}function Sn(){return new Promise(t=>{typeof globalThis.requestIdleCallback=="function"?globalThis.requestIdleCallback(()=>t(),{timeout:gn}):t()})}async function Tn(t){return t()||(await Sn(),t())?"busy":q(kn,pn)}var Ct,mn,fn,pn,hn,gn,bn,yn,vn,Mn,At=L(()=>{"use strict";Ct=require("@thumbmarkjs/thumbmarkjs");Oe();mn=["canvas","webgl","audio","fonts","hardware","screen","system","locales","math","plugins"],fn=2e3,pn=4e3,hn=1e3,gn=2e3,bn=64,yn=32,vn=8,Mn=128});var ir={};N(ir,{RANK_CANDIDATES:()=>qn,RANK_TOLERANCE:()=>ue,RANK_WINDOW_MS:()=>Xn,ROLL_ZERO_DEG:()=>Zn,SHARPNESS_REPORT_MAX:()=>rr,YAW_REPORT_MAX:()=>tr,YAW_ZERO_IOD:()=>Yn,collectRankedKeyframes:()=>nr,default:()=>Qn,featuresOf:()=>Jt,frontalOf:()=>$t,rankKeyframes:()=>er});function $t(t){let e=t.eyes;if(e===void 0)return{frontal:1,yaw:null,roll:null};let r=e.right.x-e.left.x,n=e.right.y-e.left.y,i=r*r+n*n;if(i===0)return{frontal:1,yaw:null,roll:null};let a=Math.abs(Math.atan2(n,Math.abs(r))*180/Math.PI),o=Qt(1-a/30),s=null,c=t.nose;if(c!==void 0){let u=(e.left.x+e.right.x)/2,l=(e.left.y+e.right.y)/2;s=Math.abs(((c.x-u)*r+(c.y-l)*n)/i),o*=Qt(1-s/.5)}return{frontal:o,yaw:s,roll:a}}function Jt(t,e){return t===null?{face:!1,frontal:0,yaw:null,roll:null,eyes:null,score:0,sharpness:e}:{face:!0,...$t(t),eyes:null,score:t.score,sharpness:e}}function er(t){let e=t.map((i,a)=>a),r=(i,a)=>{let o=Number.NEGATIVE_INFINITY;for(let s of e)o=Math.max(o,i(t[s]));e=e.filter(s=>i(t[s])>=o-a)};r(i=>i.frontal,ue.frontal),r(i=>i.eyes??1,ue.eyes),r(i=>i.score,ue.score);let n=-1;for(let i of e)(n===-1||t[i].sharpness>t[n].sharpness)&&(n=i);return n}function jn(t){return{face:t.face,frontal:F(t.frontal),...t.yaw!==null?{yaw:Math.min(F(t.yaw),tr)}:{},...t.roll!==null?{roll:F(t.roll)}:{},...t.eyes!==null?{eyes:F(t.eyes)}:{},score:F(t.score),sharpness:Math.min(F(t.sharpness),rr)}}async function nr(t,e){let{options:r}=t,n=r.video,i=r.now??(()=>performance.now()),a=r.captureKeyframe??(f=>t.defaultKeyframe(f)),o=600/3,s=[],c=[],u=0;for(let f=0;f<4;f+=1){if(e!==t.attempt)return null;let h=t.detector,p=Promise.resolve(null),m,b=0;try{if(h!==null){let M=t.profiler?.profile.inputWidth??160,k=r.makeSnapshot?.(n,M)??t.defaultSnapshot(n,M);m=a(n).then(E=>(b=i(),E));let v=i();p=h.detect(k,n.videoWidth,n.videoHeight).then(E=>(u+=i()-v,E),()=>null)}else m=a(n).then(M=>(b=i(),M));let[y,S]=await Promise.all([m,p]);s.push(y),c.push(Jt(S,y.sharpness))}catch{m?.catch(()=>{})}let g=b>0?Math.max(0,i()-b):0;f<3&&await new Promise(y=>setTimeout(y,Math.max(0,o-g)))}if(e!==t.attempt)return null;let l=er(c);if(l===-1)return null;let d=0;c.forEach((f,h)=>{f.sharpness>c[d].sharpness&&(d=h)});try{r.telemetry?.({type:"keyframe",tier:t.detector?.tier??null,chosen:l,sharpest:d,detectMs:Math.round(u),candidates:c.map(jn)})}catch{}return s[l]??null}var qn,Xn,Yn,Zn,ue,Qt,F,tr,rr,Qn,ar=L(()=>{"use strict";qn=4,Xn=600,Yn=.5,Zn=30,ue={frontal:.1,eyes:.1,score:.05},Qt=t=>t<0?0:t>1?1:t;F=t=>Number.isFinite(t)?Math.round(t*1e3)/1e3:0,tr=99,rr=999999;Qn=nr});var ni={};N(ni,{CENTERED_FACTOR:()=>Zr,CIRCLE_RADIUS_FACTOR:()=>Xr,CLIP_MS:()=>$,CaptureSessionV3:()=>He,ClipError:()=>T,ClipRecorder:()=>U,DEFAULT_CLIP_MIME:()=>j,DEFAULT_TIER_ORDER:()=>gt,DEFAULT_V3_ASSET_BASE_URL:()=>ht,DEVICE_PROFILES:()=>vt,DetectScheduler:()=>z,DetectorLadderError:()=>_,DeviceProfiler:()=>W,ENCODER_TAIL_MS:()=>ot,EXPOSURE_BAND:()=>K,FRAME_POLL_MS:()=>ct,FaceGateV3:()=>I,GATE_SNAPSHOT_MS:()=>cr,GateBlockStats:()=>P,HOLD_UPRIGHT_KEY:()=>le,INSPECT_WAIT_MS:()=>ut,IN_CIRCLE_FACTOR:()=>Yr,KEYFRAME_CANDIDATES:()=>de,KEYFRAME_WINDOW_MS:()=>lr,MAX_CLIP_BYTES:()=>Q,MAX_OVERRUN_MS:()=>st,MIME_CANDIDATES:()=>Z,PHONE_MAX_SHORT_SIDE:()=>dt,PROVENANCE_WAIT_MS:()=>dr,SECOND_FACE_AREA_RATIO:()=>pt,SHARP_REF:()=>ki,SHORT_CLIP_TOLERANCE_MS:()=>lt,STOP_GRACE_MS:()=>at,TIMESLICE_MS:()=>it,UPRIGHT_WATCH_MS:()=>ur,V3_GATE_DEFAULTS:()=>yt,VIDEO_BPS:()=>Se,betterTake:()=>Te,blockReasonOf:()=>jt,buildCaptureConstraints:()=>we,buildLivenessV2FormData:()=>Sr,cameraPreflight:()=>pe,captureMirroredKeyframe:()=>he,classifyDevice:()=>Ae,countExtraFaces:()=>B,createDetector:()=>A,detectFormFactor:()=>ee,detectIsMobile:()=>Ee,errorCopy:()=>Tr,exposure:()=>Ce,extForMime:()=>me,intrinsicSize:()=>R,isClipTooLarge:()=>V,isMediaRecorderSupported:()=>kr,mapGetUserMediaError:()=>fe,meanLuma:()=>ie,needsRetake:()=>J,pickMimeType:()=>Mr,probeDevice:()=>_e,sharpness:()=>ae,toStreamPixels:()=>H,trackFacingMode:()=>G,uiCopy:()=>wr});module.exports=vr(ni);var Z=["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 Mr(){let t=globalThis.MediaRecorder;return!t||typeof t.isTypeSupported!="function"?"":Z.find(e=>t.isTypeSupported(e))??""}var j="video/webm";function fe(t){if(t instanceof TypeError)return"insecure";switch(t?.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 pe(){let t=globalThis;if(typeof t.window<"u"&&t.window.isSecureContext===!1)return"INSECURE_CONTEXT";let e=t.navigator?.mediaDevices;return!e||typeof e.getUserMedia!="function"?"UNSUPPORTED":"OK"}function kr(){let t=globalThis.MediaRecorder;return typeof t<"u"&&typeof t.isTypeSupported=="function"}var Q=8*1024*1024;function V(t){return t.size>Q}function me(t){let e=(t||"").toLowerCase();return e.startsWith("image/jpeg")?"jpg":e.startsWith("video/mp4")?"mp4":(e.startsWith("video/webm"),"webm")}function Sr(t){let{token:e,clip:r,keyframe:n}=t,i=t.ts??Date.now(),a=r.type||j,o=n.type||"image/jpeg",s=new FormData;return s.append("token",e),s.append("clip",new File([r],`liveness-${i}.${me(a)}`,{type:a})),s.append("keyframe",new File([n],`keyframe-${i}.${me(o)}`,{type:o})),s}function he(t,e,r=.92){return new Promise((n,i)=>{let a=t.videoWidth,o=t.videoHeight;if(!a||!o){i(new Error("video-not-ready"));return}let s=e.getContext("2d");if(!s){i(new Error("no-2d-context"));return}e.width=a,e.height=o,s.scale(-1,1),s.drawImage(t,-a,0),e.toBlob(c=>c?n(c):i(new Error("empty-keyframe")),"image/jpeg",r)})}var Tr={permission:{key:"fcv2.err.permission",fr:"Autorisez la cam\xE9ra dans les r\xE9glages du navigateur (ic\xF4ne cam\xE9ra dans la barre d\u2019adresse), puis r\xE9essayez."},notfound:{key:"fcv2.err.notfound",fr:"Aucune cam\xE9ra d\xE9tect\xE9e. Branchez ou activez une cam\xE9ra, puis r\xE9essayez."},inuse:{key:"fcv2.err.inuse",fr:"La cam\xE9ra est utilis\xE9e par une autre application. Fermez-la puis r\xE9essayez."},overconstrained:{key:"fcv2.err.overconstrained",fr:"La cam\xE9ra ne prend pas en charge les r\xE9glages demand\xE9s. Nouvel essai en cours\u2026"},insecure:{key:"fcv2.err.insecure",fr:"La cam\xE9ra n\xE9cessite une connexion s\xE9curis\xE9e (HTTPS). Ouvrez la page en HTTPS."},unsupported:{key:"fcv2.err.unsupported",fr:"Votre navigateur ne prend pas en charge l\u2019enregistrement vid\xE9o. Utilisez un navigateur r\xE9cent."},generic:{key:"fcv2.err.generic",fr:"Cam\xE9ra indisponible. R\xE9essayez ou contactez le support."}},wr={recording:{key:"fcv2.recording",fr:"Enregistrement en cours\u2026"},uploading:{key:"fcv2.uploading",fr:"Envoi en cours\u2026"},clipTooLarge:{key:"fcv2.err.cliptoolarge",fr:"La vid\xE9o est trop volumineuse. R\xE9essayez dans un endroit mieux \xE9clair\xE9."},retry:{key:"fcv2.retry",fr:"R\xE9essayer"},listen:{key:"fcv2.listen",fr:"\xC9couter"}};var Er=[...Z.filter(t=>t.startsWith("video/mp4")),"video/webm;codecs=h264","video/webm;codecs=avc1","video/webm;codecs=vp8","video/webm;codecs=vp9","video/webm"],We=new Set;function xr(t){let e=/(?:Chrome|Chromium)\/(\d+)\./.exec(t??"");return e?Number(e[1]):null}function ze(t=Cr(),e=globalThis.navigator?.userAgent){if(t===void 0)return"";let r=xr(e)===126;for(let n of Er)if(!(We.has(n)||r&&n.startsWith("video/mp4")))try{if(t(n))return n}catch{}return""}function ge(t){t!==""&&We.add(t)}function qe(t){return t.replace(/^video\/x-matroska/i,"video/webm")}function Cr(){let t=globalThis.MediaRecorder;return t&&typeof t.isTypeSupported=="function"?e=>t.isTypeSupported(e):void 0}var $=2500,it=1e3,at=1500,Se=25e5,ot=100,st=700,ct=20,ut=1500,ke=null;function Kr(){return ke??(ke=Promise.resolve().then(()=>(nt(),rt)).catch(t=>{throw ke=null,t})),ke.catch(()=>null)}var T=class extends Error{constructor(e,r){super(r??e),this.kind=e}},lt=100;function J(t,e){return t.stats===void 0?!1:t.stats===null?!0:t.stats.durationMs<e-lt}function Te(t,e){return t.stats?e.stats?t.stats.durationMs>e.stats.durationMs:!0:!1}var U=class{constructor(e={}){this.recorder=null;this.stream=null;this.chunks=[];this.bytes=0;this.hardStopTimer=null;this.graceTimer=null;this.pollTimer=null;this.settled=!1;this.now=e.now??(()=>globalThis.performance?.now?.()??Date.now())}clearTimers(){this.hardStopTimer&&clearTimeout(this.hardStopTimer),this.graceTimer&&clearTimeout(this.graceTimer),this.pollTimer&&clearInterval(this.pollTimer),this.hardStopTimer=null,this.graceTimer=null,this.pollTimer=null}record(e,r,n,i=$,a){let o=ze(),s=Kr();return this.recordRaw(e,r,n,i,a,o).then(c=>Wr(c,s),c=>{throw c instanceof T&&(c.requestedMimeType=o),c})}recordRaw(e,r,n,i,a,o){return this.recorder&&!this.settled?Promise.reject(new T("generic","record() called while a recording is in flight \u2014 ClipRecorder handles one recording at a time")):(this.recorder=null,this.clearTimers(),this.chunks=[],this.bytes=0,this.settled=!1,this.stream=e,new Promise((s,c)=>{let u;try{u=new MediaRecorder(e,o?{mimeType:o,videoBitsPerSecond:Se}:{videoBitsPerSecond:Se})}catch{try{u=new MediaRecorder(e)}catch{c(new T("unsupported"));return}}this.recorder=u;let l=g=>{this.settled||(this.settled=!0,this.clearTimers(),g())},d=()=>l(()=>{let g=qe(u.mimeType||o||j),y=new Blob(this.chunks,{type:g});if(y.size===0){c(new T("generic","empty clip"));return}if(V(y)){c(new T("cliptoolarge"));return}s({blob:y,mimeType:g,requestedMimeType:o})});u.ondataavailable=g=>{g.data&&g.data.size&&(this.chunks.push(g.data),this.bytes+=g.data.size,this.bytes>Q&&l(()=>{try{u.state!=="inactive"&&u.stop()}catch{}c(new T("cliptoolarge"))}))},u.onstop=d,u.onerror=()=>l(()=>c(new T("generic")));let f=this.now();if(n!==void 0||a!==void 0){let g=!1;u.onstart=()=>{if(!(g||this.settled)&&(g=!0,f=this.now(),n!==void 0))try{n()}catch{}}}try{u.start(it)}catch{l(()=>c(new T("generic")));return}let h=()=>{if(this.pollTimer&&clearInterval(this.pollTimer),this.pollTimer=null,this.hardStopTimer&&clearTimeout(this.hardStopTimer),this.hardStopTimer=null,this.settled||r?.(),u.state!=="inactive"){try{u.stop()}catch{d()}this.graceTimer=setTimeout(d,at)}else d()},p=this.now();if(a===void 0){this.hardStopTimer=setTimeout(h,i);return}let m=null,b=!1;this.hardStopTimer=setTimeout(h,i+st),this.pollTimer=setInterval(()=>{if(this.settled||b)return;let g=null;try{g=a.latest()}catch{g=null}let y=g?.presentationTimeMs;y!==void 0&&Number.isFinite(y)&&y>=f&&m===null&&(m=y);let S=m!==null&&y!==void 0&&y-m>=i,M=m===null&&this.now()-p>=i;if(!(!S&&!M)){if(b=!0,this.pollTimer&&clearInterval(this.pollTimer),this.pollTimer=null,M){h();return}this.hardStopTimer&&clearTimeout(this.hardStopTimer),this.hardStopTimer=setTimeout(h,ot)}},ct)}))}stop(e){this.clearTimers();let r=this.recorder;if(r&&r.state!=="inactive")try{r.stop()}catch{}this.recorder=null,(e??this.stream)?.getTracks().forEach(i=>i.stop()),this.stream=null}};async function Wr(t,e){let r,n=new Promise(u=>{r=setTimeout(()=>u(null),ut)}),i=await Promise.race([e,n]);if(clearTimeout(r),i===null)return t;let a;try{a=await i.blobBytes(t.blob)}catch{return{...t,stats:null}}let o=i.inspectClipBytes(a);if(o?.container!=="webm")return{...t,stats:o};let s=i.withWebmDuration(a,o.durationMs);if(s===null)return{...t,stats:o};let c=i.inspectClipBytes(s);return c===null||c.frames!==o.frames||c.durationMs!==o.durationMs?{...t,stats:o}:{...t,blob:new Blob([s],{type:t.blob.type}),stats:o}}function we(t,e){return{video:{width:{ideal:1280,max:1280},height:{ideal:720,max:720},facingMode:e,frameRate:{ideal:24,max:30}},audio:!1}}var dt=600;function ee(){if(typeof window>"u"||typeof navigator>"u")return"desktop";let t=navigator.userAgentData,e=t?.mobile||/Android|i(Pad)?OS/.test(String(t?.platform)),r=String(navigator.userAgent??"");if(/iPhone|iPod/i.test(r))return"phone";if(/iPad/i.test(r))return"tablet";if(/Android/i.test(r))return/Mobile/i.test(r)?"phone":"tablet";if(/BlackBerry|IEMobile|Opera Mini/i.test(r))return"phone";if(!e){if(Number(navigator.maxTouchPoints??0)<=1)return"desktop";if(/Macintosh/.test(r))return"tablet";if(/Windows NT|CrOS/.test(r)||!qr())return"desktop"}let n=zr();return n>0&&n<dt?"phone":"tablet"}function Ee(){return ee()!=="desktop"}function zr(){try{let t=window.screen,e=Number(t?.width??0),r=Number(t?.height??0);return e>0&&r>0?Math.min(e,r):0}catch{return 0}}function G(t){try{let r=t?.getVideoTracks?.()[0]?.getSettings?.().facingMode;return r==="user"||r==="environment"?r:null}catch{return null}}function qr(){try{return typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}catch{return!1}}var Xr=.45,Yr=.9,Zr=.4;var mt=1e4,te=class t{constructor(e,r){this.tier="blaze";this.inner=e,r!==void 0&&(this.fallbackReason=r)}static async create(e,r){let n=await import("@mediapipe/tasks-vision"),i=await n.FilesetResolver.forVisionTasks(e),a=await n.FaceDetector.createFromOptions(i,{baseOptions:{modelAssetPath:`${e}/blaze_face_short_range.tflite`,delegate:"CPU"},runningMode:"IMAGE"});return new t(a,r)}async detect(e,r,n){let i;try{i=this.inner.detect(e).detections}catch{return null}let a=jr(i);if(a?.boundingBox===void 0)return null;let o=R(e),s=Qr(a.keypoints,o),c=a.keypoints?.[2],u={box:{x:a.boundingBox.originX,y:a.boundingBox.originY,width:a.boundingBox.width,height:a.boundingBox.height},...s!==void 0?{eyes:s}:{},...c!==void 0?{nose:{x:c.x*o.width,y:c.y*o.height}}:{},score:a.categories[0]?.score??0,extraFaces:B(i.map(l=>l.boundingBox??{width:0,height:0}),i.indexOf(a))};return H(u,e,r,n)}destroy(){try{this.inner.close()}catch{}}};function jr(t){let e,r=-1;for(let n of t){let i=n.categories[0]?.score??0;i>r&&(e=n,r=i)}return e}function Qr(t,e){let r=t?.[0],n=t?.[1];if(r===void 0||n===void 0)return;let i=s=>({x:s.x*e.width,y:s.y*e.height}),[a,o]=[i(r),i(n)];return a.x<=o.x?{left:a,right:o}:{left:o,right:a}}function $r(){if(typeof OffscreenCanvas=="function")return new OffscreenCanvas(2,2);let t=document.createElement("canvas");return t.width=2,t.height=2,t}var Jr=4;async function ft(){let t=globalThis.FaceDetector;if(typeof t!="function")return{ok:!1,reason:"unsupported"};try{let e=new t({fastMode:!0,maxDetectedFaces:Jr});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 re=class{constructor(e,r){this.tier="native";this.inner=e,r!==void 0&&(this.fallbackReason=r)}async detect(e,r,n){let i;try{i=await this.inner.detect(e)}catch{return null}let a=i.map(l=>l.boundingBox),o=-1;a.forEach((l,d)=>{let f=a[o];(f===void 0||l.width*l.height>f.width*f.height)&&(o=d)});let s=i[o];if(s===void 0)return null;let c=en(s.landmarks),u={box:{x:s.boundingBox.x,y:s.boundingBox.y,width:s.boundingBox.width,height:s.boundingBox.height},...c!==void 0?{eyes:c}:{},score:1,extraFaces:B(a,o)};return H(u,e,r,n)}destroy(){}};function en(t){if(t===void 0)return;let e=t.filter(i=>i.type==="eye").map(i=>i.locations[0]).filter(i=>i!==void 0),[r,n]=e;if(!(r===void 0||n===void 0))return r.x<=n.x?{left:r,right:n}:{left:n,right:r}}var pt=.25;function B(t,e){let r=t[e],n=r===void 0?0:r.width*r.height;if(!(n>0))return 0;let i=0;return t.forEach((a,o)=>{o!==e&&a.width*a.height>=pt*n&&(i+=1)}),i}var ht="/models-v3",gt=["native","blaze"],_=class extends Error{constructor(e){super(`no detector tier available (${e})`),this.name="DetectorLadderError",this.fallbackReason=e}};function R(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 r=typeof e.width=="number"?e.width:0,n=typeof e.height=="number"?e.height:0;return{width:r,height:n}}function H(t,e,r,n){let i=R(e),a=i.width>0?r/i.width:1,o=i.height>0?n/i.height:1,s=c=>({x:c.x*a,y:c.y*o});return{box:{x:t.box.x*a,y:t.box.y*o,width:t.box.width*a,height:t.box.height*o},...t.eyes!==void 0?{eyes:{left:s(t.eyes.left),right:s(t.eyes.right)}}:{},...t.nose!==void 0?{nose:s(t.nose)}:{},score:t.score,...t.extraFaces!==void 0?{extraFaces:t.extraFaces}:{}}}function tn(t){return t instanceof Error?t.message:String(t)}async function A(t){let e=t.preferred??gt,r=[];for(let n of e){if(n==="native"){let i=await ft();if(i.ok)return new re(i.instance,xe(r));r.push(`native:${i.reason}`);continue}try{return await rn(te.create(t.v3AssetBaseUrl??ht,xe(r)),t.blazeInitTimeoutMs??mt)}catch(i){r.push(i instanceof ne?"blaze:blaze_init_timeout":`blaze:${tn(i)}`)}}throw new _(xe(r)??"no_tier_available")}function xe(t){return t.length>0?t.join("; "):void 0}var ne=class extends Error{};function rn(t,e){return new Promise((r,n)=>{let i=setTimeout(()=>{n(new ne(`init exceeded ${e}ms`)),t.then(a=>a.destroy(),()=>{})},e);t.then(a=>{clearTimeout(i),r(a)},a=>{clearTimeout(i),n(a)})})}var ki=180,K=[100,190],nn=64;function bt(t,e){return .299*(t[e]??0)+.587*(t[e+1]??0)+.114*(t[e+2]??0)}function ie(t){let{data:e,width:r,height:n}=t,i=r*n;if(i===0)return 0;let a=0;for(let o=0;o<i;o+=1)a+=bt(e,o*4);return a/i}function ae(t){let{data:e,width:r,height:n}=t;if(r<3||n<3)return 0;let i=new Float32Array(r*n);for(let l=0;l<i.length;l+=1)i[l]=bt(e,l*4);let a=0,o=0,s=0;for(let l=1;l<n-1;l+=1)for(let d=1;d<r-1;d+=1){let f=l*r+d,h=(i[f-r]??0)+(i[f-1]??0)+(i[f+1]??0)+(i[f+r]??0)-4*(i[f]??0);a+=h,o+=h*h,s+=1}if(s===0)return 0;let c=a/s,u=o/s-c*c;return Math.min(1,Math.max(0,u)/180)}function Ce(t){let e=ie(t),[r,n]=K,i=e<r?r-e:e>n?e-n:0;return Math.max(0,1-i/nn)}var yt=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}),D=t=>Math.min(1,Math.max(0,t)),I=class{constructor(e={}){this.p=0;this.lastTickAt=null;this.lastCenter=null;this.velocityEma=0;this.qWindow=[];this.lastSizeDirection="ideal";this.t={...yt,...e}}reset(){this.p=0,this.lastTickAt=null,this.lastCenter=null,this.velocityEma=0,this.qWindow=[],this.lastSizeDirection="ideal"}tick(e){let{observation:r,quality:n,timestampMs:i}=e,a=this.lastTickAt===null?0:Math.max(0,(i-this.lastTickAt)/1e3);this.lastTickAt=i;let o={presence:0,single:1,centering:0,size:0,pose:0,sharpness:D(n.sharpness),exposure:D(n.exposure),motion:1};if(r!==null){o.presence=1,o.single=(r.extraFaces??0)>0?0:1;let l=this.geometryOf(r,e);o.centering=l.centering,o.size=l.size,o.pose=l.pose,o.motion=this.motionOf(l.center,l.iod,i)}else this.lastCenter=null,this.velocityEma=0;let s=Math.min(o.presence,o.single,o.centering,o.size,o.pose,o.sharpness,o.exposure,o.motion);this.p=D(this.p+(s>=this.t.Q_GOOD?this.t.RISE_PER_S*s:-this.t.FALL_PER_S*(1-s))*a),this.qWindow.push({at:i,q:s}),this.qWindow=this.qWindow.filter(l=>l.at>=i-this.t.READY_WINDOW_MS);let c=this.qWindow.map(l=>l.q);if(c.length>=3){let l=Math.min(...c),d=c.indexOf(l);c=c.filter((f,h)=>h!==d)}let u=this.p>=1&&c.every(l=>l>=this.t.Q_GOOD);return{at:i,q:s,p:this.p,factors:o,guidanceKey:this.guidanceOf(o,n,s),ready:u,accepted:s>=this.t.Q_GOOD}}geometryOf(e,r){let{box:n,eyes:i}=e,a={x:r.frameWidth/2,y:r.frameHeight/2},o=Math.min(r.frameWidth,r.frameHeight),s=i!==void 0?{x:(i.left.x+i.right.x)/2,y:(i.left.y+i.right.y)/2}:{x:n.x+n.width/2,y:n.y+n.height/2-this.t.BOX_EYE_OFFSET_FACTOR*n.height},c=i!==void 0?Math.hypot(i.right.x-i.left.x,i.right.y-i.left.y):this.t.IOD_BOX_PROXY_FACTOR*n.width,u=Math.hypot(s.x-a.x,s.y-a.y),l=c<=0?0:1-D(u/(this.t.CENTER_FALLOFF_IOD_MULTIPLE*c)),d=o>0?c/o:0;this.lastSizeDirection=d<this.t.SIZE_IDEAL_MIN?"far":d>this.t.SIZE_IDEAL_MAX?"close":"ideal";let f;d<this.t.SIZE_HARD_MIN||d>this.t.SIZE_HARD_MAX?f=0:d<this.t.SIZE_IDEAL_MIN?f=(d-this.t.SIZE_HARD_MIN)/(this.t.SIZE_IDEAL_MIN-this.t.SIZE_HARD_MIN):d>this.t.SIZE_IDEAL_MAX?f=(this.t.SIZE_HARD_MAX-d)/(this.t.SIZE_HARD_MAX-this.t.SIZE_IDEAL_MAX):f=1;let h=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;h=1-D(p/this.t.ROLL_MAX_DEG)}return{center:s,iod:c,centering:l,size:f,pose:h}}motionOf(e,r,n){let i=this.lastCenter;if(this.lastCenter={...e,at:n},i===null||r<=0)return 1;let a=(n-i.at)/1e3;if(a<=0)return 1;let o=Math.hypot(e.x-i.x,e.y-i.y)/r/a;o<=this.t.MOTION_DEADBAND_IOD_PER_S&&(o=0);let s=1-Math.exp(-a/this.t.MOTION_TAU_S);return this.velocityEma=s*o+(1-s)*this.velocityEma,1-D(this.velocityEma/this.t.MOTION_VELOCITY_IOD_PER_S)}guidanceOf(e,r,n){if(e.presence<=0)return"fcv3.no_face";if(e.single<=0)return"fcv3.one_face";if(e.size<this.t.GUIDE_SIZE)return this.sizeGuidance();if(e.centering<this.t.GUIDE_CENTERING)return"fcv3.center_face";if(e.pose<this.t.GUIDE_POSE)return"fcv3.straighten";if(e.exposure<this.t.GUIDE_EXPOSURE)return this.exposureGuidance(r);if(e.sharpness<this.t.GUIDE_SHARPNESS)return"fcv3.steady_camera";if(e.motion<this.t.GUIDE_MOTION)return"fcv3.hold_still";if(n<this.t.Q_GOOD){let i=[["size",this.sizeGuidance()],["centering","fcv3.center_face"],["pose","fcv3.straighten"],["exposure",this.exposureGuidance(r)],["sharpness","fcv3.steady_camera"],["motion","fcv3.hold_still"]],a=i[0];for(let o of i)e[o[0]]<e[a[0]]&&(a=o);return a[1]}return"fcv3.hold_still"}sizeGuidance(){return this.lastSizeDirection==="far"?"fcv3.come_closer":"fcv3.move_back"}exposureGuidance(e){let r=(K[0]+K[1])/2;return e.meanLuma<r?"fcv3.more_light":"fcv3.too_bright"}};var vt=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"})}),an=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 _e(){let t=typeof navigator>"u"?void 0:navigator,e=!1;try{e=typeof WebAssembly<"u"&&WebAssembly.validate(an)}catch{e=!1}return{cores:t?.hardwareConcurrency??2,memGB:t?.deviceMemory??null,simd:e}}function Ae(t){let e=t.memGB??4;return t.cores<4||e<3?"LOW":t.cores>=8&&e>=6?"HIGH":"MID"}var Re=["LOW","MID","HIGH"],W=class{constructor(e){this.samples=[];this.adjusted=!1;this.current=e}get deviceClass(){return this.current}get profile(){return vt[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 r=this.samples.reduce((n,i)=>n+i,0)/this.samples.length;if(r>70)this.current="LOW";else if(r<25){let n=Re.indexOf(this.current);this.current=Re[Math.min(Re.length-1,n+1)]??this.current}return this.current}};var z=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 r=()=>{this.running&&(this.frameCallbackId=e.requestVideoFrameCallback?.(()=>{this.frameCallbackId=null,this.now()-this.lastRunAt>=this.periodMs&&this.tick(),r()}))};r();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((r,n)=>r+n,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 Mt="0.1.0-rc.22";var on=/FBAN|FBAV|FB_IAB|FBIOS|MessengerForiOS|Instagram|WhatsApp|musical_ly|BytedanceWebview|TikTok|Snapchat|\bLine\/|LinkedInApp|Pinterest|MicroMessenger|; wv\)/i;function kt(t){let e=t??(typeof navigator>"u"?"":String(navigator.userAgent??""));return on.test(e)}var Dt="sekyro.did",wn=1e4,Pt=()=>globalThis.process?.versions?.node,It;function Ot(){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 En(){try{let t=localStorage.getItem(Dt);if(t)return t;let e=Ot();return e!==void 0&&localStorage.setItem(Dt,e),e}catch{return It??(It=Ot()),It}}async function xn(){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 Cn(){try{let t=Number(navigator.maxTouchPoints);return Number.isFinite(t)&&t>=0?{touch:Math.min(64,Math.trunc(t))}:{}}catch{return{}}}function Rn(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 _n(t){let e,r,n,i,a,o,s=()=>o?.readyState==="live",c=()=>{a!==void 0||!globalThis.crypto?.subtle||Pt()||s()||(a=Promise.race([Promise.resolve().then(()=>(At(),_t)),new Promise(u=>setTimeout(u,wn))]).then(u=>u?.computePrint(s)).then(u=>{u==="busy"?a=void 0:i=u}).catch(()=>{}))};return{timezone(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone?.slice(0,64)||void 0}catch{return}},noteCameraLabel(u){u&&(e=u.slice(0,128))},noteCamera(u){r=u},noteCameraTrack(u){o=u},async deviceHeader(){try{n??(n=xn().catch(()=>""));let u=[];navigator.webdriver&&u.push("webdriver"),/HeadlessChrome/.test(navigator.userAgent)&&u.push("headless");let l=await n,d=En(),f={v:1,platform:"web",sdk:t.sdk.slice(0,64),ids:[...d?[{kind:"web_local",value:d.slice(0,128)}]:[],...l?[{kind:"web_fp",value:l}]:[]],screen:{w:screen.width,h:screen.height,dpr:globalThis.devicePixelRatio??1},...Cn(),...e?{cameraLabel:e}:{},...u.length?{signals:u}:{},...i?{print:{v:2,...i,...r?{camera:r}:{}}}:{},...kt()?{inApp:!0}:{}},h=Rn(JSON.stringify(f));return c(),h}catch{return}},printReady(){return a??Promise.resolve()}}}var Pe=Symbol.for("sekyro.web.clientContext"),Fe=globalThis,Le=Fe[Pe]??(Fe[Pe]=_n({sdk:`@sekyro/web@${Mt}`}));function Ft(t){try{let e=t.getVideoTracks?.()[0];if(e){if(Le.noteCameraLabel(e.label),Le.noteCameraTrack(e),Pt())return;Promise.resolve().then(()=>(Oe(),Et)).then(r=>r.noteCameraTrait(e,Le)).catch(()=>{})}}catch{}}var Ne=Symbol.for("sekyro.web.cameraStreams"),Ve=globalThis,An=Ve[Ne]??(Ve[Ne]=new Set);function Lt(t){try{An.add(t)}catch{}}var Dn=["obs","manycam","virtual","snap camera","xsplit","droidcam","iriun","camo"],In=[/^(front|back|rear)( [a-z ]+)? camera$/i,/^caméra (avant|arrière)\b/i,/^cámara (frontal|trasera|delantera)\b/i,/^câmera (frontal|traseira)\b/i,/^(front|rück)kamera\b/i,/^الكاميرا (الأمامية|الخلفية)/,/^camera2? ?\d+, facing (front|back|external)/i,/facetime/i,/\b(integrated|built-in|builtin) (web)?cam(era)?\b/i,/\b(hd )?web ?cam\b/i,/\([0-9a-f]{4}:[0-9a-f]{4}\)\s*$/i];function On(t){let e=(t??"").trim().toLowerCase();return e.length===0?"unknown":Dn.some(r=>e.includes(r))?"known_virtual":In.some(r=>r.test(e))?"platform":"unknown"}function Nt(t){if(typeof t!="function")return!1;try{return/\{\s*\[native code\]\s*\}\s*$/.test(Function.prototype.toString.call(t))}catch{return!1}}function Pn(t=globalThis){return Nt(t.navigator?.mediaDevices?.getUserMedia)&&Nt(t.MediaStreamTrack?.prototype?.getSettings)}async function Fn(t,e=globalThis){let r=e.crypto?.subtle?.digest;if(typeof r=="function")try{let n=new Uint8Array(await r.call(e.crypto?.subtle,"SHA-256",new TextEncoder().encode(t)));return Array.from(n.subarray(0,8),i=>i.toString(16).padStart(2,"0")).join("")}catch{return}}async function Vt(t,e=globalThis){let r={};try{r=typeof t.getSettings=="function"?t.getSettings()??{}:{}}catch{r={}}let n={};if((r.facingMode==="user"||r.facingMode==="environment"||r.facingMode==="left"||r.facingMode==="right")&&(n.facingMode=r.facingMode),typeof r.frameRate=="number"&&Number.isFinite(r.frameRate)&&(n.frameRate=r.frameRate),typeof r.width=="number"&&Number.isFinite(r.width)&&(n.width=r.width),typeof r.height=="number"&&Number.isFinite(r.height)&&(n.height=r.height),typeof r.deviceId=="string"&&r.deviceId.length>0){let a=await Fn(r.deviceId,e);a!==void 0&&(n.deviceIdHash=a)}let i;try{i=t.label}catch{i=void 0}return{trackSettings:n,capabilitiesPresent:typeof t.getCapabilities=="function",labelClass:On(i),prototypesIntact:Pn(e)}}var Ue=t=>Math.round(t*100)/100;function Ut(t){let e=t,r=typeof e?.requestVideoFrameCallback=="function",n=null,i=null,a=0,o=0,s=0,c=0,u=0,l=0,d=()=>{!r||e?.requestVideoFrameCallback===void 0||(n=e.requestVideoFrameCallback((f,h)=>{if(n=null,!r)return;let p=h.presentationTime;if(i!==null){let m=p-i.presentationTimeMs;o+=1;let b=m-s;s+=b/o,c+=b*(m-s)}typeof h.captureTime=="number"&&Number.isFinite(h.captureTime)&&(u+=p-h.captureTime,l+=1),a+=1,i={mediaTimeMs:h.mediaTime*1e3,presentationTimeMs:p},d()}))};return d(),{latest:()=>i,stats:()=>({n:a,meanGapMs:o===0?0:Ue(s),stdGapMs:o<2?0:Ue(Math.sqrt(c/(o-1))),captureLatencyMs:l===0?null:Ue(u/l)}),stop:()=>{r&&(r=!1,n!==null&&e?.cancelVideoFrameCallback?.(n),n=null)}}}function Gt(t,e,r){return{...t,rvfc:e,rampPainter:r}}var Ln=["magenta","yellow","green","blue"];var Nn=4,Vn=4,se=t=>typeof t=="number"&&Number.isFinite(t);function Bt(t){if(typeof t!="object"||t===null)return!1;let e=t;if(typeof e.nonce!="string"||e.nonce.length===0||!Array.isArray(e.colours)||e.colours.length<1||e.colours.length>8||!e.colours.every(n=>Ln.includes(n))||!Array.isArray(e.onsetsMs)||e.onsetsMs.length!==e.colours.length)return!1;let r=-1;for(let n of e.onsetsMs){if(!se(n)||n<0||n<=r)return!1;r=n}return!(!se(e.holdMs)||e.holdMs<=0||!se(e.endMs)||e.endMs<=r||!se(e.clipMs)||e.clipMs<e.endMs||e.clipMs>8e3)}function Ht(t,e){return Bt(t)?Math.max(e,Math.ceil(t.clipMs)):e}function Kt(t,e){let r=e.now??(()=>performance.now()),n=Bt(t)?t:void 0,i=[],a=null,o=null,s=null,c=!1,u=null,l=p=>{u=p;try{e.paint(p)}catch{}},d=p=>{let m=e.frames?.()??null;return m!==null&&s!==null?m.mediaTimeMs+(p-m.presentationTimeMs)-s:p-(o??p)},f=(p,m,b=0)=>{if(c)return;let g=Math.max(0,p-d(r()));a=setTimeout(()=>{if(a=null,!c){if(b<Nn&&d(r())<p-Vn){f(p,m,b+1);return}m()}},g)},h=p=>{if(n===void 0)return;let m=n.endMs;if(p>=n.colours.length){f(m,()=>l(null));return}let b=n.onsetsMs[p],g=p+1<n.onsetsMs.length?n.onsetsMs[p+1]:m;f(b,()=>{let y=d(r());if(y>m){u!==null&&l(null);return}let S=n.colours[p];l(S);let M=i.length===0?0:i[i.length-1].tMs;i.push({tMs:Math.max(M,Math.round(y)),colour:S});let k=b+n.holdMs;if(k<g){f(k,()=>{if(d(r())>m){u!==null&&l(null);return}l("dark"),h(p+1)});return}h(p+1)})};return{started(p){if(n===void 0||c||o!==null)return;o=p;let m=e.frames?.()??null;s=m===null?null:m.mediaTimeMs+(p-m.presentationTimeMs),h(0)},stop(){c||(c=!0,a!==null&&clearTimeout(a),a=null,u!==null&&l(null))},report(){return n===void 0?void 0:{nonce:n.nonce,rendered:[...i]}}}}var Un=40;function O(t){if(t===null||typeof t!="object"&&typeof t!="function")return;let e;try{e=t.name}catch{return}return Gn(e)}function Gn(t){if(typeof t!="string")return;let e=t.replace(/[^A-Za-z]/g,"").slice(0,Un);return e===""?void 0:e}function Wt(t){let e=fe(t);if(e!=="generic")return e;switch(O(t)){case"AbortError":return"inuse";case"SecurityError":return"permission";default:return e}}function Bn(t){let e=t.toLowerCase();return e===""?"unknown":/front|facing front|user|selfie|face ?time/.test(e)?"front":/ultra|0\.5x|wide angle/.test(e)?"ultra":/tele|zoom|periscope|[2-9]x/.test(e)?"tele":/depth|tof|infrared|\bir\b|truedepth|lidar|macro|monochrome|mono\b/.test(e)?"depth":/dual|triple/.test(e)?"virtual":/back|rear|environment|facing back|arrière|خلفية/.test(e)?"main":"unknown"}function Hn(t){let e=/camera2?\s*(\d+)/i.exec(t);return e?Number(e[1]):Number.POSITIVE_INFINITY}function zt(t){let e={main:0,virtual:1,ultra:9,tele:9,depth:9,front:9,unknown:9};return t.filter(r=>(r.kind===void 0||r.kind==="videoinput")&&r.deviceId!=="").map((r,n)=>({id:r.deviceId,kind:Bn(r.label),index:Hn(r.label),i:n})).filter(r=>e[r.kind]<9).sort((r,n)=>e[r.kind]-e[n.kind]||r.index-n.index||r.i-n.i).map(r=>r.id)}var X=class extends Error{constructor(){super("the back camera could not be opened");this.name="BackCameraUnavailableError"}},qt=new Set(["NotAllowedError","PermissionDeniedError","SecurityError"]);function Xt(t){try{return String(t?.name??"")}catch{return""}}function Ge(t){if(t!==null)for(let e of t.getTracks())e.stop()}async function Yt(t,e,r){let n=l=>({video:{...e,...l},audio:!1});if(t==="user")return r.getUserMedia(n({facingMode:"user"}));let i=l=>G(l)!=="user";try{let l=await r.getUserMedia(n({facingMode:{exact:"environment"}}));if(i(l))return l;Ge(l)}catch(l){if(qt.has(Xt(l)))throw l}let a=!1,o=async()=>{if(r.enumerateDevices===void 0||a)return null;let l;try{l=zt(await r.enumerateDevices()).slice(0,3)}catch{return null}a=l.length>0;for(let d of l){let f;try{f=await r.getUserMedia(n({deviceId:{exact:d}}))}catch(h){if(qt.has(Xt(h)))throw h;continue}if(i(f))return f;Ge(f)}return null},s=await o();if(s!==null)return s;let c=await r.getUserMedia(n({facingMode:"environment"}));if(i(c))return c;Ge(c);let u=await o();if(u!==null)return u;throw new X}var x=1;function Zt(){return typeof OffscreenCanvas=="function"&&typeof createImageBitmap=="function"&&typeof Worker=="function"}function Wn(t,e={}){let r=e.createDetector??A,n=null;t.onmessage=i=>{let a=i.data;if(a.v!==x){a.bitmap?.close?.();return}if(a.type==="init"){r(a.options).then(o=>{n=o;let s={v:x,type:"ready",tier:o.tier,...o.fallbackReason!==void 0?{fallbackReason:o.fallbackReason}:{}};t.postMessage(s)});return}if(a.type==="detect"){let o=s=>{let c={v:x,type:"result",id:a.id,observation:s};t.postMessage(c),a.bitmap.close?.()};if(n===null){o(null);return}n.detect(a.bitmap,a.streamWidth,a.streamHeight).then(o,()=>o(null))}}}typeof self<"u"&&typeof self.importScripts=="function"&&Wn(self);var ce=class t{constructor(e,r){this.pending=new Map;this.nextId=1;this.worker=e,this.tier=r.tier,r.fallbackReason!==void 0&&(this.fallbackReason=r.fallbackReason),e.addEventListener("message",n=>{let i=n.data;if(i.v!==x||i.type!=="result")return;let a=this.pending.get(i.id);this.pending.delete(i.id),a?.(i.observation)})}static create(e,r,n=1e4){return new Promise((i,a)=>{let o=setTimeout(()=>{e.removeEventListener("message",s),e.terminate(),a(new Error(`worker detector not ready within ${n}ms`))},n),s=u=>{let l=u.data;l.v!==x||l.type!=="ready"||(clearTimeout(o),e.removeEventListener("message",s),i(new t(e,l)))};e.addEventListener("message",s);let c={v:x,type:"init",options:r};e.postMessage(c)})}async detect(e,r,n){let i;try{typeof ImageBitmap<"u"&&e instanceof ImageBitmap?i=e:typeof createImageBitmap=="function"?i=await createImageBitmap(e):i=e}catch{return null}let a=this.nextId;return this.nextId+=1,new Promise(o=>{this.pending.set(a,o);let s={v:x,type:"detect",id:a,bitmap:i,streamWidth:r,streamHeight:n};this.worker.postMessage(s,[i])})}destroy(){for(let e of this.pending.values())e(null);this.pending.clear(),this.worker.terminate()}};var zn=["single","size","centering","pose","exposure","sharpness","motion"];function jt(t){if(t.accepted)return null;if(t.factors.presence<=0)return"no_face";let e="single";for(let r of zn)t.factors[r]<t.factors[e]&&(e=r);return e}var P=class{constructor(){this.blocked={};this.acceptedMs=0;this.ticks=0;this.lastAt=null}record(e){let r=this.lastAt===null?0:Math.max(0,e.at-this.lastAt);this.lastAt=e.at,this.ticks+=1;let n=jt(e);if(n===null){this.acceptedMs+=r;return}let i=this.blocked[n]??{count:0,ms:0};i.count+=1,i.ms+=r,this.blocked[n]=i}summary(){let e={};for(let[r,n]of Object.entries(this.blocked))e[r]={count:n.count,ms:Math.round(n.ms)};return{blocked:e,acceptedMs:Math.round(this.acceptedMs),ticks:this.ticks}}};var cr=1e3,le="fcv3.hold_upright",ur=200,de=4,lr=600,dr=1e3,or={sharpness:1,exposure:1,meanLuma:128};function $n(t,e){return e.width=t.videoWidth,e.height=t.videoHeight,e.getContext("2d").drawImage(t,0,0),new Promise((r,n)=>e.toBlob(i=>i?r(i):n(new Error("empty-keyframe")),"image/jpeg",.92))}function Jn(){return ee()==="phone"}var He=class{constructor(e){this.handlers=new Map;this.stateValue="idle";this.attempt=0;this.stream=null;this.detector=null;this.scheduler=null;this.gate=null;this.profiler=null;this.lastGuidanceKey=null;this.positioningStartedAt=0;this.cameraRequestedAt=null;this.cameraReadyAt=null;this.faceAcquiredAt=null;this.captureCompleteAt=null;this.fired=!1;this.carriedDegrade=0;this.carriedMeans=[];this.blockStats=null;this.lastGateSnapshotAt=Number.NEGATIVE_INFINITY;this.uprightGuard=!1;this.trackProvenance=null;this.ramp=null;this.snapshotCanvas=null;this.options=e,this.facing=e.facingMode??"user"}get state(){return this.stateValue}on(e,r){let n=this.handlers.get(e);return n||(n=new Set,this.handlers.set(e,n)),n.add(r),()=>n?.delete(r)}emit(e,r){for(let n of[...this.handlers.get(e)??[]])n(r)}async start(e={}){e.facingMode!==void 0&&(this.facing=e.facingMode),this.attempt+=1,await this.run(this.attempt)}get facingMode(){return this.facing}retry(){this.teardownAttempt(),this.start()}switchCamera(){this.facing=this.facing==="user"?"environment":"user",this.teardownAttempt(),this.start()}restart(e){this.facing=e,this.teardownAttempt(),this.start()}destroy(){this.attempt+=1,this.teardownAttempt(),this.detector?.destroy(),this.detector=null,this.options.video.srcObject=null}async run(e){let{options:r}=this;this.fired=!1,this.lastGuidanceKey=null,this.carriedDegrade=0,this.carriedMeans=[],this.cameraRequestedAt=null,this.cameraReadyAt=null,this.faceAcquiredAt=null,this.captureCompleteAt=null,this.uprightGuard=(r.isPhone??Jn)(),this.setState("preflight");let n=pe();if(n!=="OK"){this.fail(n==="INSECURE_CONTEXT"?"insecure":"unsupported",{phase:"preflight"});return}this.setState("acquiring");let i=r.getUserMedia??(u=>navigator.mediaDevices.getUserMedia(u)),a;this.cameraRequestedAt=this.now();try{let{facingMode:u,...l}=we(Ee(),this.facing).video;a=await Yt(this.facing,l,{getUserMedia:i,enumerateDevices:ri(r)})}catch(u){if(e!==this.attempt)return;if(u instanceof X){this.fail("backcamera",{phase:"acquiring",name:O(u)});return}this.fail(Wt(u),{phase:"acquiring",name:O(u)});return}if(Ft(a),Lt(a),e!==this.attempt){for(let u of a.getTracks())u.stop();return}this.stream=a;let o=a.getVideoTracks?.()[0];if(this.trackProvenance=o===void 0?null:Vt(o).catch(()=>null),this.facing=G(a)??this.facing,r.video.srcObject=a,await r.video.play().catch(()=>{}),e!==this.attempt)return;if(this.cameraReadyAt=this.now(),this.detector===null){let u={v3AssetBaseUrl:r.v3AssetBaseUrl},l=r.createDetector??(r.createWorker!==void 0&&Zt()?async()=>{try{return await ce.create(r.createWorker(),u)}catch{return A(u)}}:()=>A(u)),d;try{d=await l()}catch(f){e===this.attempt&&this.fail("models",{phase:"models",name:O(f)},f instanceof _?f.fallbackReason:ti(f));return}if(e!==this.attempt){d.destroy();return}this.detector=d,this.options.telemetry?.({type:"detector",tier:d.tier,fallbackReason:d.fallbackReason})}let s=_e(),c=r.deviceClass??Ae(s);this.profiler=new W(c),this.options.telemetry?.({type:"profile",staticClass:c,activeClass:this.profiler.deviceClass,simd:s.simd}),this.gate=new I(r.thresholds??{}),this.blockStats=new P,this.lastGateSnapshotAt=this.now(),r.rankKeyframes?.()&&Promise.resolve().then(()=>(ar(),ir)).then(u=>Be=u,()=>{}),this.setState("positioning"),this.positioningStartedAt=this.now(),this.startScheduler(e)}get animations(){return this.profiler?.profile.animations??"full"}startScheduler(e){let r=this.profiler;if(r===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 n=new z({cadenceHz:r.profile.cadenceHz,video:this.options.video,now:this.options.now,run:()=>this.detectTick(e)});this.scheduler=n,n.start()}async detectTick(e){let{detector:r,gate:n,profiler:i}=this,a=this.options.video;if(e!==this.attempt||r===null||n===null||i===null||this.fired||a.videoWidth===0)return;if(this.isLandscape()){this.holdUpright(e);return}let o=i.deviceClass,s=this.now(),c=this.options.makeSnapshot?.(a,i.profile.inputWidth)??this.defaultSnapshot(a,i.profile.inputWidth),u=null;try{u=await r.detect(c,a.videoWidth,a.videoHeight)}catch{u=null}if(e!==this.attempt||this.fired)return;i.record(this.now()-s),i.deviceClass!==o&&this.startScheduler(e);let l=u===null?or:this.options.measureQuality?.(a,u.box)??this.defaultQuality(a,u.box),d=n.tick({timestampMs:this.now(),observation:u,quality:l,frameWidth:a.videoWidth,frameHeight:a.videoHeight});d.accepted&&this.faceAcquiredAt===null&&(this.faceAcquiredAt=d.at),this.blockStats?.record(d),!d.ready&&d.at-this.lastGateSnapshotAt>=cr&&(this.lastGateSnapshotAt=d.at,this.reportGate(!1)),this.emit("checks",{engine:"v3",progress:d.p,q:d.q,factors:d.factors,attempt:e}),d.guidanceKey!==this.lastGuidanceKey&&(this.lastGuidanceKey=d.guidanceKey,this.emit("guidance",{key:d.guidanceKey})),d.ready&&this.stateValue==="positioning"&&(this.fired=!0,this.captureCompleteAt=d.at,this.fire(e))}async fire(e){let{options:r}=this,n=this.scheduler;n?.stop(),this.reportGate(!0);let i=n?.stats()??{degradeCount:0,meanDetectMs:0},a=[...this.carriedMeans,...i.meanDetectMs>0?[i.meanDetectMs]:[]];r.telemetry?.({type:"fired",timeToGateMs:this.now()-this.positioningStartedAt,degradeCount:this.carriedDegrade+i.degradeCount,meanDetectMs:a.length===0?0:a.reduce((k,v)=>k+v,0)/a.length});let o=r.mode??"clip",s=r.rankKeyframes?.()&&Be?Be.default(this,e).catch(()=>this.collectKeyframes(e)):this.collectKeyframes(e);if(o==="photo"){let k=this.watchRotation(e,null),v=await s;if(k(),e!==this.attempt)return;if(v===null){this.fail("generic",{phase:"keyframes"});return}let E=await this.provenance({n:0,meanGapMs:0,stdGapMs:0,captureLatencyMs:null},!1);if(e!==this.attempt)return;this.finishCapture({keyframe:v.blob,previewDataUrl:v.previewDataUrl,...E});return}this.setState("recording");let c=this.stream;if(c===null){this.fail("generic",{phase:"recording"});return}let u=r.screenRamp?.(),l=u!==void 0,d=null;s.then(k=>{d=k},()=>{});let f=()=>{e===this.attempt&&d!==null&&this.emit("frozen",{previewDataUrl:d.previewDataUrl})},h=Ht(u,$),p=null,m,b=0;try{let k=this.recordTake(e,c,u,h,void 0).then(w=>w,w=>({failed:w})),[v,E]=await Promise.all([k,s]);if(m=E,e!==this.attempt)return;if("failed"in v){if(v.failed.kind==="cliptoolarge")throw v.failed;ge(v.failed.requestedMimeType??"")}else p=v,J(v.clip,h)?v.clip.stats===null&&ge(v.clip.requestedMimeType??""):f();if(p===null||J(p.clip,h)){b=1,r.telemetry?.({type:"clip_retake",reason:p===null?"error":p.clip.stats===null?"unreadable":"short"});let w=null;try{w=await this.recordTake(e,c,u,h,f)}catch(mr){if(p===null)throw mr}if(e!==this.attempt)return;w!==null&&(p===null||Te(w.clip,p.clip))&&(p=w),w===null&&f()}}catch(k){if(e!==this.attempt)return;let v=k.kind;this.fail(v==="cliptoolarge"?"cliptoolarge":"recorder",{phase:"recording",name:O(k)});return}if(p===null){this.fail("recorder",{phase:"recording"});return}let{clip:g,rvfc:y,report:S}=p;if(V(g.blob)){this.fail("cliptoolarge",{phase:"recording"});return}if(m===null){this.fail("generic",{phase:"keyframes"});return}let M=await this.provenance(y,l);e===this.attempt&&this.finishCapture({clip:g.blob,clipMimeType:g.mimeType,...g.stats?{clipStats:g.stats}:{},clipRetakes:b,keyframe:m.blob,previewDataUrl:m.previewDataUrl,...S!==void 0&&S.rendered.length>0?{screenRamp:S}:{},...M})}async recordTake(e,r,n,i,a){let o=this.options.createRecorder?.()??new U({now:()=>this.now()}),s=Ut(this.options.video),c=Kt(n,{paint:d=>{(d===null||e===this.attempt)&&this.emit("ramp",{colour:d})},now:()=>this.now(),frames:s.latest});this.ramp=c;let u=()=>{s.stop(),c.stop(),this.ramp===c&&(this.ramp=null)},l=this.watchRotation(e,o);try{return{clip:await o.record(r,a,()=>c.started(this.now()),i,s),rvfc:s.stats(),report:c.report()}}finally{l(),u()}}async provenance(e,r){let n=this.trackProvenance;if(n===null)return{};let i,a=new Promise(s=>{i=setTimeout(()=>s(null),dr)}),o=await Promise.race([n,a]);return clearTimeout(i),o===null?{}:{provenance:Gt(o,e,r)}}isLandscape(){let e=this.options.video;return this.uprightGuard&&e.videoWidth>e.videoHeight}holdUpright(e){this.gate?.reset(),this.emit("checks",{engine:"v3",progress:0,q:0,factors:{presence:0,single:1,centering:0,size:0,pose:0,sharpness:0,exposure:0,motion:0},attempt:e}),this.lastGuidanceKey!==le&&(this.lastGuidanceKey=le,this.emit("guidance",{key:le}))}watchRotation(e,r){if(!this.uprightGuard)return()=>{};let n=this.options.video,i=()=>{if(e!==this.attempt||r!==null&&this.stateValue!=="recording"){s();return}n.videoWidth>0&&this.isLandscape()&&(s(),this.abortRecording(e,r))},a=setInterval(i,ur);n.addEventListener?.("resize",i);let o=!1;function s(){o||(o=!0,clearInterval(a),n.removeEventListener?.("resize",i))}return s}abortRecording(e,r){if(e!==this.attempt)return;this.attempt+=1;let n=this.attempt;try{r?.stop()}catch{}this.ramp?.stop(),this.ramp=null,this.fired=!1,this.captureCompleteAt=null,this.gate=new I(this.options.thresholds??{}),this.blockStats=new P,this.lastGateSnapshotAt=this.now(),this.lastGuidanceKey=null,this.setState("positioning"),this.positioningStartedAt=this.now(),this.holdUpright(n),this.startScheduler(n)}async collectKeyframes(e){let r=this.options.captureKeyframe??(a=>this.defaultKeyframe(a)),n=lr/(de-1),i=null;for(let a=0;a<de;a+=1){if(e!==this.attempt)return i;try{let o=await r(this.options.video);(i===null||o.sharpness>i.sharpness)&&(i=o)}catch{}a<de-1&&await ei(n)}return i}finishCapture(e){this.stopTracks(),this.setState("captured");let r=this.captureTiming();this.emit("artifacts",r===void 0?e:{...e,timing:r})}captureTiming(){let e={},r=(n,i,a)=>{i!==null&&a!==null&&(e[n]=Math.max(0,Math.round(a-i)))};return r("cameraReadyMs",this.cameraRequestedAt,this.cameraReadyAt),r("faceAcquireMs",this.cameraReadyAt,this.faceAcquiredAt),r("captureMs",this.faceAcquiredAt,this.captureCompleteAt),Object.keys(e).length>0?e:void 0}async defaultKeyframe(e){let r=document.createElement("canvas"),n=await(this.facing==="user"?he:$n)(e,r),i=r.toDataURL("image/jpeg",.92);return{blob:n,previewDataUrl:i,sharpness:this.centerSharpness(e)}}defaultSnapshot(e,r){try{let n=this.snapshotCanvas??document.createElement("canvas"),i=r/Math.max(1,e.videoWidth),a=Math.max(1,Math.round(e.videoWidth*i)),o=Math.max(1,Math.round(e.videoHeight*i)),s=n.getContext("2d");return s===null?e:(n.width!==a&&(n.width=a),n.height!==o&&(n.height=o),s.drawImage(e,0,0,a,o),this.snapshotCanvas=n,n)}catch{return e}}defaultQuality(e,r){let n=sr(e,r,96);return n===null?or:{sharpness:ae(n),exposure:Ce(n),meanLuma:ie(n)}}centerSharpness(e){let r=R(e),n=sr(e,{x:r.width*.25,y:r.height*.25,width:r.width*.5,height:r.height*.5},96);return n===null?0:ae(n)}teardownAttempt(){this.scheduler?.stop(),this.scheduler=null,this.reportGate(!0),this.gate=null,this.ramp?.stop(),this.ramp=null,this.stopTracks()}reportGate(e){let r=this.blockStats,n=this.profiler;if(r===null||n===null)return;let i=r.summary();e&&(this.blockStats=null),i.ticks!==0&&this.options.telemetry?.({type:"gate",final:e,activeClass:n.deviceClass,cadenceHz:n.profile.cadenceHz,...i})}stopTracks(){if(this.stream!==null){for(let e of this.stream.getTracks())e.stop();this.stream=null}}fail(e,r,n){this.scheduler?.stop(),this.reportGate(!0),this.stopTracks(),this.setState("error"),this.options.telemetry?.({type:"error",kind:e,fallbackReason:n});let{phase:i,name:a}=r;this.emit("error",{kind:e,retryable:e!=="insecure"&&e!=="unsupported",detail:a===void 0?{phase:i}:{phase:i,name:a}})}setState(e){this.stateValue=e,this.emit("statechange",{state:e})}now(){return this.options.now?.()??performance.now()}},Be;function ei(t){return new Promise(e=>setTimeout(e,t))}function ti(t){return t instanceof Error?t.message:String(t)}function sr(t,e,r){try{let n=document.createElement("canvas"),i=r/Math.max(1,e.width);n.width=Math.max(1,Math.round(e.width*i)),n.height=Math.max(1,Math.round(e.height*i));let a=n.getContext("2d");return a===null?null:(a.drawImage(t,e.x,e.y,e.width,e.height,0,0,n.width,n.height),a.getImageData(0,0,n.width,n.height))}catch{return null}}function ri(t){if(t.enumerateDevices!==void 0)return t.enumerateDevices;if(t.getUserMedia===void 0&&!(typeof navigator>"u"||typeof navigator.mediaDevices?.enumerateDevices!="function"))return()=>navigator.mediaDevices.enumerateDevices()}0&&(module.exports={CENTERED_FACTOR,CIRCLE_RADIUS_FACTOR,CLIP_MS,CaptureSessionV3,ClipError,ClipRecorder,DEFAULT_CLIP_MIME,DEFAULT_TIER_ORDER,DEFAULT_V3_ASSET_BASE_URL,DEVICE_PROFILES,DetectScheduler,DetectorLadderError,DeviceProfiler,ENCODER_TAIL_MS,EXPOSURE_BAND,FRAME_POLL_MS,FaceGateV3,GATE_SNAPSHOT_MS,GateBlockStats,HOLD_UPRIGHT_KEY,INSPECT_WAIT_MS,IN_CIRCLE_FACTOR,KEYFRAME_CANDIDATES,KEYFRAME_WINDOW_MS,MAX_CLIP_BYTES,MAX_OVERRUN_MS,MIME_CANDIDATES,PHONE_MAX_SHORT_SIDE,PROVENANCE_WAIT_MS,SECOND_FACE_AREA_RATIO,SHARP_REF,SHORT_CLIP_TOLERANCE_MS,STOP_GRACE_MS,TIMESLICE_MS,UPRIGHT_WATCH_MS,V3_GATE_DEFAULTS,VIDEO_BPS,betterTake,blockReasonOf,buildCaptureConstraints,buildLivenessV2FormData,cameraPreflight,captureMirroredKeyframe,classifyDevice,countExtraFaces,createDetector,detectFormFactor,detectIsMobile,errorCopy,exposure,extForMime,intrinsicSize,isClipTooLarge,isMediaRecorderSupported,mapGetUserMediaError,meanLuma,needsRetake,pickMimeType,probeDevice,sharpness,toStreamPixels,trackFacingMode,uiCopy});