@sekyro/elements 0.1.0-rc.28 → 0.1.0-rc.29

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 (84) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +3 -3
  3. package/dist/cdn/chunks/{capture-session-doc-SNOZ6SKC-NQQS4M2G.js → capture-session-doc-HGA7NCJI-PAHR5UED.js} +1 -1
  4. package/dist/cdn/chunks/{chunk-32LRPMCN.js → chunk-2CQQAB3Y.js} +1 -1
  5. package/dist/cdn/chunks/chunk-45BISCD7.js +1 -0
  6. package/dist/cdn/chunks/{chunk-YVMKJQDM.js → chunk-62ISTF5A.js} +1 -1
  7. package/dist/cdn/chunks/chunk-6OAH57ZL.js +1 -0
  8. package/dist/cdn/chunks/{chunk-TIVC2P6G.js → chunk-ACJWBI6P.js} +1 -1
  9. package/dist/cdn/chunks/{chunk-DHNLZ7K6.js → chunk-F4XXN364.js} +1 -1
  10. package/dist/cdn/chunks/{chunk-JHQIPL2L.js → chunk-FYHEA2LI.js} +1 -1
  11. package/dist/cdn/chunks/{chunk-IB2ADNNH.js → chunk-I7ZZMP7U.js} +1 -1
  12. package/dist/cdn/chunks/{chunk-R3JHFC62.js → chunk-IVTMNMUT.js} +1 -1
  13. package/dist/cdn/chunks/chunk-LAEGXG2I.js +3 -0
  14. package/dist/cdn/chunks/{chunk-KU3B6BDD.js → chunk-LPLPMWHJ.js} +1 -1
  15. package/dist/cdn/chunks/{chunk-QTYL46IQ.js → chunk-LVIQDNPD.js} +1 -1
  16. package/dist/cdn/chunks/chunk-M36CK35T.js +1 -0
  17. package/dist/cdn/chunks/{chunk-N3OO3ZW5.js → chunk-OC5UPJL5.js} +1 -1
  18. package/dist/cdn/chunks/{chunk-KEGAMCHW.js → chunk-OP6NSXRA.js} +1 -1
  19. package/dist/cdn/chunks/{chunk-QP5KJZU7.js → chunk-RPS5MI2Z.js} +1 -1
  20. package/dist/cdn/chunks/chunk-RY47T7P4.js +33 -0
  21. package/dist/cdn/chunks/{chunk-FKXVZGAM.js → chunk-S3DETOVP.js} +1 -1
  22. package/dist/cdn/chunks/{chunk-34ROD75I.js → chunk-TX7C4L3S.js} +1 -1
  23. package/dist/cdn/chunks/{chunk-KQMX2UO4.js → chunk-V2MJE7IH.js} +1 -1
  24. package/dist/cdn/chunks/{chunk-EGC3SJDE.js → chunk-ZQRIQWIK.js} +1 -1
  25. package/dist/cdn/chunks/{create-document-capture-D44AR5OI-R673MW5Y.js → create-document-capture-HHRMCAWL-7OHYRTAN.js} +1 -1
  26. package/dist/cdn/chunks/document-capture-view-CFKS7K5J-YDK5DUQJ.js +1 -0
  27. package/dist/cdn/chunks/{eid-view-BGDCFCPD-WQ74GPTW.js → eid-view-3G2EEGBI-C54IOJRT.js} +1 -1
  28. package/dist/cdn/chunks/{email-otp-view-SVAX2GHU-DOOWUF3B.js → email-otp-view-PNB5UXJZ-FK3XWFBY.js} +1 -1
  29. package/dist/cdn/chunks/flow-views-6TVHTMMX-6QNRGOHC.js +1 -0
  30. package/dist/cdn/chunks/{form-view-XNCTRA7M-LOR7RGOY.js → form-view-4HIBPKH7-QFAEVYU7.js} +1 -1
  31. package/dist/cdn/chunks/{overlay-de-WMDVOHQO-2R3CJSPX.js → overlay-de-SHNL7LAI-G24N6OC4.js} +1 -1
  32. package/dist/cdn/chunks/{overlay-es-IKLVPKGJ-CJZMWE5E.js → overlay-es-A6FGTLAH-EVEFVZOC.js} +1 -1
  33. package/dist/cdn/chunks/{overlay-pt-CYYJMZZA-BWRUQYY5.js → overlay-pt-LTTU3QMC-AKB6BK52.js} +1 -1
  34. package/dist/cdn/chunks/plan-runner-AUM4X5WF-XQRCBU72.js +1 -0
  35. package/dist/cdn/chunks/{portrait-capture-view-BOH77RPB-2LO3FLC5.js → portrait-capture-view-VGMA3DDR-TSACU3HP.js} +1 -1
  36. package/dist/cdn/chunks/{portrait-review-view-XVQYL2UA-HG4LWY2D.js → portrait-review-view-UGBWX5MS-SJLTTTW5.js} +1 -1
  37. package/dist/cdn/chunks/{proof-of-address-view-GOIZKE27-PY2P7GIQ.js → proof-of-address-view-JOIFXMMC-3KTUEBGM.js} +1 -1
  38. package/dist/cdn/define.js +1 -1
  39. package/dist/cdn/index.js +1 -1
  40. package/dist/{chunk-54KY532D.js → chunk-2X65ALSL.js} +1 -1
  41. package/dist/{chunk-ECO4HDPP.js → chunk-36B6FF7N.js} +1 -1
  42. package/dist/{chunk-O4E2U4XJ.js → chunk-3MS3OEXH.js} +1 -1
  43. package/dist/chunk-4VZPYERM.js +33 -0
  44. package/dist/{chunk-V42GSMOG.js → chunk-DBP7O23Y.js} +1 -1
  45. package/dist/{chunk-6PGOITBA.js → chunk-FCWRFBJ5.js} +1 -1
  46. package/dist/{chunk-EWAEIT5N.js → chunk-I2W7JAV3.js} +1 -1
  47. package/dist/{chunk-RNT34HNE.js → chunk-K2RX6MKD.js} +1 -1
  48. package/dist/{chunk-QTOUDK6B.js → chunk-ONLUBR6R.js} +1 -1
  49. package/dist/chunk-RKDMXMMR.js +1 -0
  50. package/dist/{chunk-HRRDUK2T.js → chunk-VMIPS4GV.js} +1 -1
  51. package/dist/{chunk-SDRPWM6A.js → chunk-XL5ZL55K.js} +1 -1
  52. package/dist/{chunk-TE665WZ6.js → chunk-YOH3GSLC.js} +1 -1
  53. package/dist/{chunk-XOM2CZTJ.js → chunk-ZX3DKTKJ.js} +1 -1
  54. package/dist/define.cjs +5 -5
  55. package/dist/define.js +1 -1
  56. package/dist/document-capture-view-CFKS7K5J-SAJ6PQWE.js +1 -0
  57. package/dist/{eid-view-BGDCFCPD-4QCJD5OL.js → eid-view-3G2EEGBI-LZVUJU6I.js} +1 -1
  58. package/dist/{email-otp-view-SVAX2GHU-VKXK7EDR.js → email-otp-view-PNB5UXJZ-QTVVXYTH.js} +1 -1
  59. package/dist/flow-views-6TVHTMMX-KNUYB6W7.js +1 -0
  60. package/dist/{form-view-XNCTRA7M-KKU5MXJT.js → form-view-4HIBPKH7-2HUEAOFF.js} +1 -1
  61. package/dist/index.cjs +5 -5
  62. package/dist/index.d.cts +20 -10
  63. package/dist/index.d.ts +20 -10
  64. package/dist/index.js +1 -1
  65. package/dist/{overlay-de-WMDVOHQO-DVRSDGG3.js → overlay-de-SHNL7LAI-UGRIY37I.js} +1 -1
  66. package/dist/{overlay-es-IKLVPKGJ-3DJ3PLYT.js → overlay-es-A6FGTLAH-4TTQSKC5.js} +1 -1
  67. package/dist/{overlay-pt-CYYJMZZA-PLJSYGKU.js → overlay-pt-LTTU3QMC-3TI32HHQ.js} +1 -1
  68. package/dist/{portrait-capture-view-BOH77RPB-PN5ML6HU.js → portrait-capture-view-VGMA3DDR-LFQ6FAYZ.js} +1 -1
  69. package/dist/{portrait-review-view-XVQYL2UA-R7GFI56G.js → portrait-review-view-UGBWX5MS-UPYQ75SA.js} +1 -1
  70. package/dist/{proof-of-address-view-GOIZKE27-KSBLMUVS.js → proof-of-address-view-JOIFXMMC-PQ4IIQV2.js} +1 -1
  71. package/package.json +2 -2
  72. package/sbom.cdx.json +4 -4
  73. package/dist/cdn/chunks/chunk-IPR33E6C.js +0 -1
  74. package/dist/cdn/chunks/chunk-JAO3ZUKP.js +0 -1
  75. package/dist/cdn/chunks/chunk-KUUROJLV.js +0 -33
  76. package/dist/cdn/chunks/chunk-LL5EZHIM.js +0 -1
  77. package/dist/cdn/chunks/chunk-LQOBVF4U.js +0 -3
  78. package/dist/cdn/chunks/document-capture-view-BXY2GVEJ-QELJLB7A.js +0 -1
  79. package/dist/cdn/chunks/flow-views-PX5YBDQG-CF4UQQOQ.js +0 -1
  80. package/dist/cdn/chunks/plan-runner-WNAXF6XR-JCQX3M7K.js +0 -1
  81. package/dist/chunk-C3VULGQL.js +0 -1
  82. package/dist/chunk-H7QTXWQ6.js +0 -33
  83. package/dist/document-capture-view-BXY2GVEJ-UJA5U7PL.js +0 -1
  84. package/dist/flow-views-PX5YBDQG-X2OMG5AG.js +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @sekyro/elements
2
2
 
3
+ ## 0.1.0-rc.29
4
+
5
+ ### Patch Changes
6
+
7
+ - 22247d5: Sandbox sessions open with a choice between test data and real checks as an enrolled tester. Real checks start with the tester face check as a page of its own, with no way out to test data; when no tester is enrolled, the screen says how to enroll one. Test data is labelled on the identity summary and the result says the mode ("Test data" or "Real checks, tester …"). The tester reasons have their own lines, and the "Run real checks as a tester" button under each page is removed.
8
+ - Updated dependencies [294bcbd]
9
+ - @sekyro/web@0.1.0-rc.52
10
+
3
11
  ## 0.1.0-rc.28
4
12
 
5
13
  ### Patch Changes
package/README.md CHANGED
@@ -236,9 +236,9 @@ page's resets: under Bootstrap's reboot or Tailwind's preflight the flow looks a
236
236
  ## Sandbox
237
237
 
238
238
  A Sandbox session shows its test chrome in the element exactly as in `@sekyro/react`: the "Test session" badge, the
239
- "Skip with test data" action, the tester check and, on the result screen of a session no enrolled tester ran, the
240
- "This was a simulation" notice. The `sekyro-result` detail then carries `sandbox: { simulated: true, reason }`.
241
- Nothing to configure: it follows the session.
239
+ choice between test data and real checks, the tester check, the "Skip with test data" action and, on the result
240
+ screen, the mode the session ran in. The `sekyro-result` detail carries `sandbox: { mode, testerName? }`. Nothing to
241
+ configure: it follows the session.
242
242
 
243
243
  ## Size
244
244
 
@@ -1 +1 @@
1
- import{b as s,c as a,d as _,e as C,f as A,g as D,h as o,i as S,j as r,k as t,l as E,m as p,n as T,o as O,p as i,q as m,r as R}from"./chunk-QTYL46IQ.js";import"./chunk-5Y7NCFTK.js";import"./chunk-XKZZC74I.js";import"./chunk-37BKUH3E.js";import"./chunk-W5WWCOOW.js";import"./chunk-32LRPMCN.js";import"./chunk-P7K7ELYZ.js";import"./chunk-JS2IXPNL.js";import"./chunk-4FHWXBOB.js";export{i as CAPTURE_CANDIDATE_SPACING_MS,O as CAPTURE_EXTRA_CANDIDATES,m as CAPTURE_WINDOW_MS,p as CaptureSessionDoc,_ as DOC_BLACK_FRAME_LUMA,C as DOC_BLACK_FRAME_TICKS,A as DOC_CADENCE_HZ,a as DOC_FIRST_FRAME_MS,o as DOC_PROFILE_TICKS,t as DOC_SHUTTER_DEFAULTS,r as DOC_SLOW_TICK_MS,S as DOC_WARMUP_TICKS,R as REFOCUS_APPLY_MAX_MS,D as SIDE_PROBE_MS,T as passportBandOf,E as resolveDocShutterTuning,s as warmDocDetector};
1
+ import{b as s,c as a,d as _,e as C,f as A,g as D,h as o,i as S,j as r,k as t,l as E,m as p,n as T,o as O,p as i,q as m,r as R}from"./chunk-LVIQDNPD.js";import"./chunk-5Y7NCFTK.js";import"./chunk-XKZZC74I.js";import"./chunk-37BKUH3E.js";import"./chunk-W5WWCOOW.js";import"./chunk-2CQQAB3Y.js";import"./chunk-P7K7ELYZ.js";import"./chunk-JS2IXPNL.js";import"./chunk-4FHWXBOB.js";export{i as CAPTURE_CANDIDATE_SPACING_MS,O as CAPTURE_EXTRA_CANDIDATES,m as CAPTURE_WINDOW_MS,p as CaptureSessionDoc,_ as DOC_BLACK_FRAME_LUMA,C as DOC_BLACK_FRAME_TICKS,A as DOC_CADENCE_HZ,a as DOC_FIRST_FRAME_MS,o as DOC_PROFILE_TICKS,t as DOC_SHUTTER_DEFAULTS,r as DOC_SLOW_TICK_MS,S as DOC_WARMUP_TICKS,R as REFOCUS_APPLY_MAX_MS,D as SIDE_PROBE_MS,T as passportBandOf,E as resolveDocShutterTuning,s as warmDocDetector};
@@ -1 +1 @@
1
- import{a as n}from"./chunk-4FHWXBOB.js";var S="0.1.0-rc.50",k=/FBAN|FBAV|FB_IAB|FBIOS|MessengerForiOS|Instagram|WhatsApp|musical_ly|BytedanceWebview|TikTok|Snapchat|\bLine\/|LinkedInApp|Pinterest|MicroMessenger|; wv\)/i;function O(t){let e=t??(typeof navigator>"u"?"":String(navigator.userAgent??""));return k.test(e)}n(O,"p");var f="sekyro.did",C=1e4,w=n(()=>globalThis.process?.versions?.node,"v"),l;function y(){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,a=>a.toString(16).padStart(2,"0")).join("")}}catch{}}n(y,"b");function H(){try{let t=localStorage.getItem(f);if(t)return t;let e=y();return e!==void 0&&localStorage.setItem(f,e),e}catch{return l??(l=y()),l}}n(H,"I");async function M(){let t=globalThis.crypto?.subtle;if(!t)return"";let e=navigator,a=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(a));return Array.from(new Uint8Array(i),s=>s.toString(16).padStart(2,"0")).join("").slice(0,32)}n(M,"w");function x(){try{let t=Number(navigator.maxTouchPoints);return Number.isFinite(t)&&t>=0?{touch:Math.min(64,Math.trunc(t))}:{}}catch{return{}}}n(x,"k");function W(t){let e=new TextEncoder().encode(t),a="";for(let i of e)a+=String.fromCharCode(i);return btoa(a).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}n(W,"x");function j(t){let e,a,i,s,c,d,m=n(()=>d?.readyState==="live","u"),T=n(()=>{c!==void 0||!globalThis.crypto?.subtle||w()||m()||(c=Promise.race([import("./print-DCYX3CZD-DLQCPZZE.js"),new Promise(r=>setTimeout(r,C))]).then(r=>r?.computePrint(m)).then(r=>{r==="busy"?c=void 0:s=r}).catch(()=>{}))},"_");return{timezone(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone?.slice(0,64)||void 0}catch{return}},noteCameraLabel(r){r&&(e=r.slice(0,128))},noteCamera(r){a=r},noteCameraTrack(r){d=r},async deviceHeader(){try{i??(i=M().catch(()=>""));let r=[];navigator.webdriver&&r.push("webdriver"),/HeadlessChrome/.test(navigator.userAgent)&&r.push("headless");let p=await i,g=H(),A={v:1,platform:"web",sdk:t.sdk.slice(0,64),caps:["session_proof"],rampAtArm:!0,ids:[...g?[{kind:"web_local",value:g.slice(0,128)}]:[],...p?[{kind:"web_fp",value:p}]:[]],screen:{w:screen.width,h:screen.height,dpr:globalThis.devicePixelRatio??1},...x(),...e?{cameraLabel:e}:{},...r.length?{signals:r}:{},...s?{print:{v:2,...s,...a?{camera:a}:{}}}:{},...O()?{inApp:!0}:{}},I=W(JSON.stringify(A));return T(),I}catch{return}},printReady(){return c??Promise.resolve()}}}n(j,"A");var v=Symbol.for("sekyro.web.clientContext"),b=globalThis,u=b[v]??(b[v]=j({sdk:`@sekyro/web@${S}`}));function z(t){try{let e=t.getVideoTracks?.()[0];if(e){if(u.noteCameraLabel(e.label),u.noteCameraTrack(e),w())return;import("./camera-trait-DELAK3YN-4I2GHAFU.js").then(a=>a.noteCameraTrait(e,u)).catch(()=>{})}}catch{}}n(z,"M");var P=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"})}),L=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 F(){let t=typeof navigator>"u"?void 0:navigator,e=!1;try{e=typeof WebAssembly<"u"&&WebAssembly.validate(L)}catch{e=!1}return{cores:t?.hardwareConcurrency??2,memGB:t?.deviceMemory??null,simd:e}}n(F,"o");function U(t){let e=t.memGB??4;return t.cores<4||e<3?"LOW":t.cores>=8&&e>=6?"HIGH":"MID"}n(U,"l");var h=["LOW","MID","HIGH"],o,_=(o=class{constructor(e){this.samples=[],this.adjusted=!1,this.current=e}get deviceClass(){return this.current}get profile(){return P[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 a=this.samples.reduce((i,s)=>i+s,0)/this.samples.length;if(a>70)this.current="LOW";else if(a<25){let i=h.indexOf(this.current);this.current=h[Math.min(h.length-1,i+1)]??this.current}return this.current}},n(o,"i"),o);export{S as a,O as b,u as c,z as d,F as e,U as f,_ as g};
1
+ import{a as n}from"./chunk-4FHWXBOB.js";var S="0.1.0-rc.52",k=/FBAN|FBAV|FB_IAB|FBIOS|MessengerForiOS|Instagram|WhatsApp|musical_ly|BytedanceWebview|TikTok|Snapchat|\bLine\/|LinkedInApp|Pinterest|MicroMessenger|; wv\)/i;function O(t){let e=t??(typeof navigator>"u"?"":String(navigator.userAgent??""));return k.test(e)}n(O,"p");var f="sekyro.did",C=1e4,w=n(()=>globalThis.process?.versions?.node,"v"),l;function y(){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,a=>a.toString(16).padStart(2,"0")).join("")}}catch{}}n(y,"b");function H(){try{let t=localStorage.getItem(f);if(t)return t;let e=y();return e!==void 0&&localStorage.setItem(f,e),e}catch{return l??(l=y()),l}}n(H,"I");async function M(){let t=globalThis.crypto?.subtle;if(!t)return"";let e=navigator,a=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(a));return Array.from(new Uint8Array(i),s=>s.toString(16).padStart(2,"0")).join("").slice(0,32)}n(M,"w");function x(){try{let t=Number(navigator.maxTouchPoints);return Number.isFinite(t)&&t>=0?{touch:Math.min(64,Math.trunc(t))}:{}}catch{return{}}}n(x,"k");function W(t){let e=new TextEncoder().encode(t),a="";for(let i of e)a+=String.fromCharCode(i);return btoa(a).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}n(W,"x");function j(t){let e,a,i,s,c,d,m=n(()=>d?.readyState==="live","u"),T=n(()=>{c!==void 0||!globalThis.crypto?.subtle||w()||m()||(c=Promise.race([import("./print-DCYX3CZD-DLQCPZZE.js"),new Promise(r=>setTimeout(r,C))]).then(r=>r?.computePrint(m)).then(r=>{r==="busy"?c=void 0:s=r}).catch(()=>{}))},"_");return{timezone(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone?.slice(0,64)||void 0}catch{return}},noteCameraLabel(r){r&&(e=r.slice(0,128))},noteCamera(r){a=r},noteCameraTrack(r){d=r},async deviceHeader(){try{i??(i=M().catch(()=>""));let r=[];navigator.webdriver&&r.push("webdriver"),/HeadlessChrome/.test(navigator.userAgent)&&r.push("headless");let p=await i,g=H(),A={v:1,platform:"web",sdk:t.sdk.slice(0,64),caps:["session_proof"],rampAtArm:!0,ids:[...g?[{kind:"web_local",value:g.slice(0,128)}]:[],...p?[{kind:"web_fp",value:p}]:[]],screen:{w:screen.width,h:screen.height,dpr:globalThis.devicePixelRatio??1},...x(),...e?{cameraLabel:e}:{},...r.length?{signals:r}:{},...s?{print:{v:2,...s,...a?{camera:a}:{}}}:{},...O()?{inApp:!0}:{}},I=W(JSON.stringify(A));return T(),I}catch{return}},printReady(){return c??Promise.resolve()}}}n(j,"A");var v=Symbol.for("sekyro.web.clientContext"),b=globalThis,u=b[v]??(b[v]=j({sdk:`@sekyro/web@${S}`}));function z(t){try{let e=t.getVideoTracks?.()[0];if(e){if(u.noteCameraLabel(e.label),u.noteCameraTrack(e),w())return;import("./camera-trait-DELAK3YN-4I2GHAFU.js").then(a=>a.noteCameraTrait(e,u)).catch(()=>{})}}catch{}}n(z,"M");var P=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"})}),L=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 F(){let t=typeof navigator>"u"?void 0:navigator,e=!1;try{e=typeof WebAssembly<"u"&&WebAssembly.validate(L)}catch{e=!1}return{cores:t?.hardwareConcurrency??2,memGB:t?.deviceMemory??null,simd:e}}n(F,"o");function U(t){let e=t.memGB??4;return t.cores<4||e<3?"LOW":t.cores>=8&&e>=6?"HIGH":"MID"}n(U,"l");var h=["LOW","MID","HIGH"],o,_=(o=class{constructor(e){this.samples=[],this.adjusted=!1,this.current=e}get deviceClass(){return this.current}get profile(){return P[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 a=this.samples.reduce((i,s)=>i+s,0)/this.samples.length;if(a>70)this.current="LOW";else if(a<25){let i=h.indexOf(this.current);this.current=h[Math.min(h.length-1,i+1)]??this.current}return this.current}},n(o,"i"),o);export{S as a,O as b,u as c,z as d,F as e,U as f,_ as g};
@@ -0,0 +1 @@
1
+ import{b as U}from"./chunk-I7ZZMP7U.js";import{a as J,c as q}from"./chunk-2CQQAB3Y.js";import{b as L}from"./chunk-6MYG4HWP.js";import{a as r}from"./chunk-4FHWXBOB.js";var b,h=(b=class extends Error{constructor(t){super(t.message),this.name="HostedApiError",this.status=t.status,this.code=t.code,t.retryAfterSeconds!==void 0&&(this.retryAfterSeconds=t.retryAfterSeconds),t.details&&(this.details=t.details)}},r(b,"u"),b);function H(e,t,n=Math.random){let i=(e??t)*1e3,s=Math.min(Math.max(i,500),2e4),a=Math.round(s*(1+(n()*2-1)*.25));return Math.min(Math.max(a,500),2e4)}r(H,"T");var V=6e4,R=4,se=3e4,re=9e5,ae=200,oe=5,ce=400,de=new Set(["server_busy","request_timeout"]),ue=20,le=60,pe=600,he=2;function v(e){return(e.split(";")[0]??"").trim()}r(v,"l");var me={liveness:"clipKey",face_match:"imageKey",doc_ocr:"imageKey"},fe=`@sekyro/web/${J}`,ye=fe,k,it=(k=class{constructor(t){this.sessionId=null,this.bootstrap=null,this.captureNonces=[],this.captureFetch=null,this.reportedIssues=new Map,this.issueReports=0,this.issuesPausedUntil=0,this.apiOrigin=t.apiOrigin.replace(/\/+$/,""),this.sessionToken=t.sessionToken;let n=t.fetch;this.fetchImpl=(i,s)=>(n??globalThis.fetch).call(globalThis,i,s),this.requestTimeoutMs=t.requestTimeoutMs??se,this.retryAttempts=t.inProgressRetry?.attempts??oe,this.retryDelayMs=t.inProgressRetry?.delayMs??ce,this.random=t.random??Math.random,this.clientLocale=t.locale}async getSession(){let t=await this.api("GET","/hosted/session");return this.sessionId=t.sessionId,t}async recordConsent(t){let n=await this.api("POST","/hosted/consent",{body:{locale:t},busyRetry:!0}),i=this.captureHold;return this.captureHold=void 0,i&&this.armCapture(i),n}async reportCameraUnavailable(t){return this.api("POST","/hosted/camera-unavailable",{body:{cause:t}})}async testerGate(t){return this.api("POST","/hosted/tester-gate",{body:{input:t}})}async chooseSandboxMode(t){return this.api("POST","/hosted/sandbox-mode",{body:{mode:t}})}async reportCaptureIssue(t){let n=typeof t.name=="string"?t.name.replace(/[^A-Za-z]/g,"").slice(0,40):"",i=typeof t.engineKind=="string"&&/^[a-z_]{1,32}$/.test(t.engineKind)?t.engineKind:void 0,s=typeof t.attempt=="number"&&Number.isInteger(t.attempt)&&t.attempt>=0&&t.attempt<=1e3?t.attempt:void 0,a=t.check==="attestation"?s??"":"",c=[t.check,a,t.kind,n,t.phase??"",i??""].join("|"),d=this.reportedIssues.get(c);if(d!==void 0)return d;if(Date.now()<this.issuesPausedUntil||this.issueReports>=ue)return;let o={check:t.check,kind:t.kind,...n!==""?{name:n}:{},...t.phase!==void 0?{phase:t.phase}:{},...i!==void 0?{engineKind:i}:{},...s!==void 0?{attempt:s}:{},...t.formFactor!==void 0?{formFactor:t.formFactor}:{},...typeof t.detail=="string"&&/^\d{1,10}$/.test(t.detail)?{detail:t.detail}:{},...G(t.challengeMs)?{challengeMs:t.challengeMs}:{},...G(t.readyMs)?{readyMs:t.readyMs}:{},...t.inApp===!0?{inApp:!0}:{},...t.interactive===!0?{interactive:!0}:{},...typeof t.checks=="number"&&Number.isInteger(t.checks)&&t.checks>=0&&t.checks<=50?{checks:t.checks}:{}};this.issueReports+=1;let u=this.api("POST","/hosted/capture-issue",{body:o,empty:!0}).catch(l=>{if(l instanceof h&&l.status===429){let p=Math.min(Math.max(l.retryAfterSeconds??le,0),pe);this.issuesPausedUntil=Math.max(this.issuesPausedUntil,Date.now()+p*1e3);return}(!(l instanceof h)||l.status===0||l.status>=500)&&this.reportedIssues.delete(c)});return this.reportedIssues.set(c,u),u}async choose(t,n){let i=await this.api("POST","/hosted/choice",{body:{nodeId:t,option:n},busyRetry:!0});return this.sessionId=i.sessionId,i}async confirmIdentity(t){return this.api("POST","/hosted/identity/confirm",{body:{decision:t}})}async identityPortrait(){return this.api("GET","/hosted/identity/portrait",{blob:!0})}async presign(t,n,i,s={}){let a=await this.ensureSessionId(),c={kind:t,contentType:v(n),contentLength:i,...s.source==="upload"?{source:"upload"}:{}};return this.api("POST",`/sessions/${a}/media`,{body:c})}armCapture(t=2){let n=Date.now();this.captureNonces.filter(i=>i.expiresAt-V>n).length>=t||(this.captureHold===void 0?this.fillCaptureNonces(t,t):this.captureHold=Math.max(this.captureHold,t))}async armRamp(){try{let t=await this.ensureSessionId(),n=await this.api("POST",`/sessions/${t}/media/capture-nonces`,{body:{count:2,ramp:!0}}),i=Date.now(),s=U(n.screenRamp)?n.screenRamp:void 0,a=i+Math.max(0,n.expiresIn)*1e3;for(let d of Array.isArray(n.nonces)?n.nonces:[])typeof d!="string"||d.length===0||this.captureNonces.push({nonce:d,expiresAt:a,...s!==void 0?{arm:s.nonce}:{}});this.captureNonces=this.captureNonces.slice(-R),this.captureHold=void 0;let c=typeof n.rampExpiresIn=="number"&&n.rampExpiresIn>0?n.rampExpiresIn:0;return{...s!==void 0?{challenge:s}:{},expiresAt:i+c*1e3}}catch{return}}async presignCapture(t,n,i,s={}){let a=await this.ensureSessionId(),c=await this.takeCaptureNonce(s.arm),d=c===void 0?void 0:{nonce:c,...s.engine!==void 0?{engine:s.engine.slice(0,32)}:{},...s.durationMs!==void 0&&Number.isFinite(s.durationMs)?{captureMs:Math.min(36e5,Math.max(0,Math.round(s.durationMs)))}:{}},o={kind:t,contentType:v(n),contentLength:i,capture:d};return this.api("POST",`/sessions/${a}/media`,{body:o})}async takeCaptureNonce(t){let n=r(()=>{let i=Date.now();this.captureNonces=this.captureNonces.filter(a=>a.expiresAt-V>i);let s=this.captureNonces.findIndex(a=>a.arm===t);return this.captureNonces.splice(s<0?0:s,1)[0]?.nonce},"n");for(let i=0;i<2;i++){let s=n();if(s!==void 0)return s;await this.fillCaptureNonces(1)}return n()}fillCaptureNonces(t,n=0){return this.captureFetch??(this.captureFetch=(async()=>{try{let i=await this.ensureSessionId(),s=await this.api("POST",`/sessions/${i}/media/capture-nonces`,{body:{count:Math.min(R,Math.max(1,t))}}),a=Date.now()+Math.max(0,s.expiresIn)*1e3;for(let c of Array.isArray(s.nonces)?s.nonces:[])typeof c=="string"&&c.length>0&&this.captureNonces.push({nonce:c,expiresAt:a});this.captureNonces=this.captureNonces.slice(-R),this.captureHold=void 0}catch(i){i instanceof h&&i.code==="consent_required"&&(this.captureHold=Math.max(this.captureHold??0,n))}})().finally(()=>{this.captureFetch=null})),this.captureFetch}async uploadToSpaces(t,n,i){let s;try{s=await this.fetchImpl(t,{method:"PUT",headers:{"content-type":v(i)},body:n,signal:AbortSignal.timeout(re)})}catch(a){throw K(a)}if(!s.ok){let a=(await s.text().catch(()=>"")).slice(0,ae);throw new h({status:s.status,code:"upload_failed",message:`media upload failed (HTTP ${s.status})${a?`: ${a}`:""}`})}}async completeMedia(t){let n=await this.ensureSessionId();return this.api("POST",`/sessions/${n}/media/complete`,{body:{key:t}})}async submitCheck(t,n,i={}){let s=await this.ensureSessionId(),a={input:n,forceOutcome:i.forceOutcome};return this.api("POST",`/sessions/${s}/checks/${t}`,{body:a,idempotencyKey:i.idempotencyKey,...i.browserCheckToken!==void 0?{browserCheckToken:i.browserCheckToken}:{},busyRetry:i.idempotencyKey!==void 0})}async uploadAndSubmit(t,n,i,s={}){let a=v(n.contentType),c=await this.presign(n.kind,a,n.blob.size);await this.uploadToSpaces(c.uploadUrl,n.blob,a);let d=await this.completeMedia(c.key),o={...i,[me[t]]:d.key};return this.submitCheck(t,o,s)}async ensureSessionId(){return this.sessionId!==null?this.sessionId:(this.bootstrap??(this.bootstrap=this.getSession().finally(()=>{this.bootstrap=null})),(await this.bootstrap).sessionId)}async api(t,n,i={}){let s=t==="GET"||i.busyRetry===!0,a=`${this.apiOrigin}/api/v2${n}`,c={"x-session-token":this.sessionToken,"x-sekyro-sdk":ye};i.body!==void 0&&(c["content-type"]="application/json"),i.idempotencyKey!==void 0&&(c["x-idempotency-key"]=i.idempotencyKey),i.browserCheckToken!==void 0&&(c["sekyro-browser-check"]=i.browserCheckToken),this.clientLocale!==void 0&&(c["sekyro-client-locale"]=this.clientLocale);try{let d=q.timezone();d!==void 0&&(c["sekyro-client-timezone"]=d)}catch{}c["sekyro-client-form-factor"]=L();try{let d=await q.deviceHeader();d!==void 0&&(c["sekyro-client-device"]=d)}catch{}for(let d=0;;d++){let o;try{o=await this.fetchImpl(a,{method:t,headers:c,...i.body!==void 0?{body:JSON.stringify(i.body)}:{},cache:"no-store",signal:AbortSignal.timeout(this.requestTimeoutMs)})}catch(l){throw K(l)}if(o.ok){if(i.empty===!0)return;if(i.blob===!0)try{return await o.blob()}catch(p){throw K(p)}let l;try{l=await o.json()}catch{throw new h({status:o.status,code:"unknown_error",message:`response body was not valid JSON (HTTP ${o.status})`})}return _e(l)}let u=await ve(o);if(u.code==="idempotency_in_progress"&&d<this.retryAttempts){this.retryDelayMs>0&&await Z(this.retryDelayMs);continue}if(s&&u.status===503&&de.has(u.code)){s=!1,await Z(H(u.retryAfterSeconds,he,this.random));continue}throw u}}},r(k,"k"),k);function G(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0&&e<=6e5}r(G,"w");function K(e){if((typeof e=="object"&&e!==null?e.name:void 0)==="TimeoutError")return new h({status:0,code:"timeout",message:"request timed out"});let t=e instanceof Error?e.message:String(e);return new h({status:0,code:"network_error",message:`network request failed: ${t}`})}r(K,"f");function _e(e){return e!==null&&typeof e=="object"&&"success"in e&&"data"in e?e.data:e}r(_e,"V");async function ve(e){let t="unknown_error",n=`request failed (HTTP ${e.status})`,i=Number.NaN,s;try{let d=await e.json();if(d!==null&&typeof d=="object"){let o=d;typeof o.code=="string"&&o.code.length>0&&(t=o.code),typeof o.message=="string"&&o.message.length>0&&(n=o.message),typeof o.retryAfterSeconds=="number"&&(i=o.retryAfterSeconds),Array.isArray(o.details?.issues)?s=o.details:Array.isArray(o.details?.errors)&&(s={...o.details,issues:[]})}}catch{}let a=e.headers.get("retry-after"),c=a===null?Math.floor(i):Number.parseInt(a,10);return new h({status:e.status,code:t,message:n,...Number.isFinite(c)&&c>=0?{retryAfterSeconds:c}:{},details:s})}r(ve,"L");function Z(e){return new Promise(t=>setTimeout(t,e))}r(Z,"R");function st(e){let t=e?.portrait,n=t?.icao,i=t?.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"}}r(st,"J");function rt(e){return{...e.baselineEyeOpenness!==void 0?{baselineEyeOpenness:e.baselineEyeOpenness}:{},...e.baselineEyeOpennessLeft!==void 0&&e.baselineEyeOpennessRight!==void 0?{baselineEyeOpennessLeft:e.baselineEyeOpennessLeft,baselineEyeOpennessRight:e.baselineEyeOpennessRight}:{},criteria:e.verdict??{},...e.backgroundCheck!==void 0?{backgroundCheck:e.backgroundCheck}:{}}}r(rt,"Q");var be=new Set(["nni_unbound","id_number_unbound","method_required","mobile_required","portrait_required"]);function dt(e){return be.has(e)}r(dt,"Ce");function ut(e,t,n){let i=t.detail;return{check:e,kind:t.kind,...i?.name!==void 0?{name:i.name}:{},...i?.phase!==void 0?{phase:i.phase}:{},...i?.engineKind!==void 0?{engineKind:i.engineKind}:{},attempt:Math.max(0,Math.min(1e3,n))}}r(ut,"ve");function lt(){let e=-1,t="";return{note(n){n==="starting"&&t!=="starting"&&(e+=1),t=n},newHandle(){t=""},noteError(){e<0&&(e=0)},get value(){return e}}}r(lt,"Pe");var ke={document:"document_photo",nfc:"document_chip",population_registry:"national_number",national_eid:"national_eid"};function y(e){return e.plan?.steps??[]}r(y,"f");function F(e){return Math.max(0,e.attempts.max-e.attempts.used)}r(F,"x");function ge(e){let t=e.plan?.choice;return t!==void 0&&e.plan?.current===t.nodeId?t:null}r(ge,"J");function pt(e){let t=ge(e);if(t?.kind!=="identity_method")return null;let n=t.options.map(s=>ke[s.service]).filter(s=>s!==void 0),i=t.options.find(s=>s.nationalEid)?.nationalEid;return i?{available:!0,selected:null,options:n,nationalEid:i}:{available:!0,selected:null,options:n}}r(pt,"Me");var we=new Set(["liveness","face_match"]);function z(e){return e!==void 0&&(e.state==="pending"||e.state==="input_required")}r(z,"b");function Me(e){return e.status!=="created"&&e.status!=="in_progress"}r(Me,"T");function Y(e){let t=e.plan?.current,n=t==null?void 0:y(e).find(i=>i.id===t);return z(n)?n:void 0}r(Y,"M");function $(e,t){return y(e).find(n=>n.checkType===t)}r($,"g");function O(e){let t=y(e),n=t.findIndex(i=>i.checkType==="liveness");return t.find((i,s)=>s>n&&i.checkType==="face_match")}r(O,"S");function Se(e,t){let n=$(t,"liveness")?.state,i=O(t)?.state;return(O(e)?.state??"pending")==="pending"&&(n==="passed"||n==="review")&&i!==void 0&&i!=="pending"&&i!=="skipped"}r(Se,"F");function B(e,t){let n=new Map(y(e).map(i=>[i.id,i.state]));return y(t).filter(i=>i.checkType==="face_match"&&(n.get(i.id)??"pending")==="pending"&&i.state!=="pending"&&i.state!=="skipped").map(i=>i.id)}r(B,"V");var Ie=/^[0-9a-f]{24}$/i;function x(e){return Ie.test(e)?`ses_${e}`:e}r(x,"k");function E(e,t){let n=x(e);return t===void 0?{sessionId:n,status:"unavailable"}:{sessionId:n,status:"unavailable",reasonCode:t}}r(E,"C");function W(e,t,n){let i=x(e);return n===void 0?{sessionId:i,status:t}:{sessionId:i,status:t,reasonCode:n}}r(W,"O");function ht(e,t){let n=Te(e,t),i=Ce(e);return i!==void 0&&(n.sandbox=i),n}r(ht,"Ve");function Ce(e){if(e.sandbox!==!0)return;let t=e.sandboxRun;if(typeof t!="object"||t===null)return;let{mode:n,testerName:i}=t;if(!(n!=="simulated"&&n!=="tester"))return n==="tester"&&typeof i=="string"&&i.trim()!==""?{mode:n,testerName:i.trim()}:{mode:n}}r(Ce,"X");function Te(e,t){let n=x(e.sessionId);switch(e.status){case"created":case"in_progress":return Oe(e,t);case"verified":return P(e,{sessionId:n,status:"verified"});case"review_pending":return P(e,W(n,"review",X(e,"review")));case"not_verified":return P(e,xe(e));default:return P(e,{sessionId:n,status:"not_verified"})}}r(Te,"Z");var Ae=new Set([0,1,2,3]);function P(e,t){return Ae.has(e.level)&&(t.level=e.level),typeof e.assurance=="string"&&e.assurance.length>0&&(t.assurance=e.assurance),t}r(P,"v");function xe(e){let t={sessionId:x(e.sessionId),status:"not_verified"};return e.reason!==void 0&&(t.reason=e.reason),e.reasonCode!==void 0&&(t.reasonCode=e.reasonCode),e.reasonCode==="device_cooldown"&&e.retryAfter!==void 0&&(t.retryAfter=e.retryAfter),t}r(xe,"ee");function Ee(e){return e==="rejected"?"rejected":e==="unavailable"?"unavailable":"inconclusive"}r(Ee,"ne");function Pe(e,t){if(t===void 0)return!1;let n=y(t).find(i=>i.id===e.id);return n!==void 0&&n.attempts.used===e.attempts.used}r(Pe,"te");function Oe(e,t){let n=x(e.sessionId),i=y(e).find(a=>we.has(a.checkType)&&a.state==="input_required"&&a.reason!==void 0);if(i?.reason==="mobile_required")return E(n,"mobile_required");if(i?.reason!==void 0){if(i.result==="unavailable")return E(n,i.reason);let a=t.autoRetry&&(F(i)>0||Pe(i,t.previous))?{sessionId:n,status:"retry",reasonCode:i.reason,attemptsRemaining:F(i)}:{sessionId:n,status:"not_verified",reason:Ee(i.result),reasonCode:i.reason,attemptsRemaining:F(i)};return i.retakeHint!==void 0&&(a.retakeHint=i.retakeHint),a}let s=Y(e);return s===void 0&&y(e).some(a=>a.state==="review")?W(n,"review",X(e,"review")):s?.checkType==="portrait_icao"?E(n,"portrait_required"):E(n)}r(Oe,"ie");function X(e,t){return y(e).find(n=>n.state===t&&n.reason!==void 0)?.reason}r(X,"L");function ee(e,t,n,i,s){return e.presignCapture!==void 0?e.presignCapture(t,n,i,s):e.presign(t,n,i)}r(ee,"K");function te(e){return{engine:e?.engine,durationMs:e?.clipMs,arm:e?.screenRamp?.nonce}}r(te,"q");var $e=["video/webm","video/mp4"],Q="image/jpeg",Ne=2,qe=1e3,Re=1e4,Ke=3,He=10,Fe=3,je=new Set(["network_error","timeout","upload_failed","unknown_error","rate_limit_exceeded"]),ze=new Set(["session_not_active","check_not_found","check_already_finalized","check_out_of_order","identity_confirm_required","check_not_active","step_not_on_path","native_app_required"]),g,D=(g=class extends Error{constructor(){super("verification destroyed"),this.name="FlowCancelledError"}},r(g,"R"),g);function De(e){let t=O(e);return $(e,"portrait_icao")?.state!=="pending"&&(t!==void 0?z(t):e.capture?.livePhoto?.oneCapture===!0)}r(De,"fe");var w,A=(w=class extends Error{constructor(t){super(t),this.name="AttestationError"}},r(w,"h"),w),M,Ue=(M=class extends A{constructor(t){super(`no attestation token: ${t}`),this.name="AttestationUnavailableError",this.code=t}},r(M,"E"),M);function mt(e){return new h({status:400,code:"attestation_invalid",message:`browser check: ${e}`,details:{issues:[],browserCheck:e}})}r(mt,"Fe");function Le(e){if(!(e instanceof h)||e.code!=="attestation_invalid")return;let t=e.details?.browserCheck;return typeof t=="string"?t:void 0}r(Le,"me");async function ne(e,t,n={}){let i=e.uuid(),s=!1,a=!1,c=0,d=0;for(;;)try{return await t(e.client,i)}catch(o){if(o instanceof A){if(a||o instanceof Ue)throw o;a=!0,n.onAttestationInvalid?.(),i=e.uuid();continue}if(!(o instanceof h))throw o;if(o.code==="consent_required"&&!s){s=!0,await e.ensureConsent({force:!0}),i=e.uuid();continue}if(o.code==="attestation_invalid"&&!a&&Le(o)===void 0){a=!0,n.onAttestationInvalid?.(),i=e.uuid();continue}if(o.code==="inference_unavailable"&&d<Ke){d+=1;let u=H(o.retryAfterSeconds,He,e.random??Math.random);e.onBusy?.({attempt:d,retryAfterSeconds:u/1e3}),await e.sleep(u),n.onAttestationInvalid?.(),i=e.uuid();continue}if(je.has(o.code)&&c<Ne){c+=1;let u=o.retryAfterSeconds!==void 0?o.retryAfterSeconds*1e3:void 0;await e.sleep(u!==void 0?Math.min(u,Re):qe);continue}throw o}}r(ne,"D");var Je=new Set(["passed","review","processing","skipped"]);async function ft(e){let{artifacts:t}=e,n=t.clip,i=v(t.clipMime??"");if(t.degraded==="NO_RECORDER"||n===void 0||!$e.includes(i))return{kind:"unavailable",reason:"no_recorder"};e.client.armCapture?.(2);let s=Ve(e,t.keyframe),a=Ge(e,n,i,s),c=Ze(e,s),d=!1,o=new Set,u=!0,l=0;for(;;){if(e.isCancelled())return{kind:"cancelled"};let p=e.getView();if(Me(p))return{kind:"settled"};let m=Y(p),T=m?.checkType,N=T==="liveness"&&!d?"liveness":T==="face_match"&&!o.has(m?.id)&&o.size<2&&u?"face_match":null;if(N===null)return{kind:"settled"};if(N==="liveness"&&t.captureChannel==="desktop")return{kind:"unavailable",reason:"mobile_required"};try{if(N==="liveness"){d=!0;let f=await a();if(e.isCancelled())return{kind:"cancelled"};Se(p,f)&&o.add(O(f)?.id);for(let ie of B(p,f))o.add(ie);await e.applySubmit(f,"liveness");let _=$(e.getView(),"liveness")?.state;u=_===void 0||Je.has(_)}else{o.add(m?.id);let f=await c();if(e.isCancelled())return{kind:"cancelled"};for(let _ of B(p,f))o.add(_);await e.applySubmit(f,"face_match")}}catch(f){if(e.isCancelled()||f instanceof D)return{kind:"cancelled"};let _=We(f);if(_.kind!=="resync"||l>=Fe)return _;l+=1,await e.refreshView()}}}r(ft,"Oe");function Ve(e,t){let n=null,i=null,s=r(()=>n!==null?Promise.resolve(n):(i??(i=(async()=>{let a=await ee(e.client,"image",Q,t.size,te(e.artifacts));return await e.client.uploadToSpaces(a.uploadUrl,t,Q),n=(await e.client.completeMedia(a.key)).key,e.onKeyframePromoted?.(n),n})().finally(()=>{i=null})),i),"r");return{ensure:s,attempt:r(()=>s().catch(()=>null),"attempt"),current:r(()=>n,"current")}}r(Ve,"ge");function Ge(e,t,n,i){let s=e.clipKeys?.get()??null,a,c=null,d=0,o;return()=>ne(e,async(u,l)=>{if(s===null||a===void 0){if(e.isCancelled())throw new D;a===void 0&&!De(e.getView())&&(a=null),e.onPhase("uploading");let[p,m]=await Promise.all([s!==null?Promise.resolve(s):(async()=>{let T=await ee(u,"clip",n,t.size,te(e.artifacts));return await u.uploadToSpaces(T.uploadUrl,t,n),(await u.completeMedia(T.key)).key})(),a!==void 0?Promise.resolve(a===null?null:a.imageKey):i.attempt()]);s=p,e.clipKeys?.set(p),a===void 0&&(a=m===null?null:{imageKey:m})}if(c===null){let p=performance.now();try{c=await e.getAttestation(),o=e.attestationError?.()}catch(m){throw m instanceof A?m:new A(m instanceof Error?m.message:String(m))}d=Math.round(performance.now()-p)}return e.onPhase("checking"),u.submitCheck("liveness",{clipKey:s,attestation:c,captureChannel:e.artifacts.captureChannel,capture:{...Be(e.artifacts),attestationMs:d,attestationError:o,...Ye(e.attestationFacts?.())},...a!==null?{faceMatch:a}:{}},{idempotencyKey:l})},{onAttestationInvalid:r(()=>{c=null},"onAttestationInvalid")})}r(Ge,"_e");function Ze(e,t){return()=>ne(e,async(n,i)=>{if(t.current()===null){if(e.isCancelled())throw new D;e.onPhase("uploading")}let s=await t.ensure();return e.onPhase("checking"),n.submitCheck("face_match",{imageKey:s},{idempotencyKey:i})})}r(Ze,"ye");function Be(e){let t={width:e.width,height:e.height};for(let n of Qe)e[n]!==void 0&&(t[n]=e[n]);return t}r(Be,"Se");var Qe=["engine","facingMode","mode","formFactor","clipMs","clipFrames","fps","clipRetakes","codec","cameraReadyMs","faceAcquireMs","captureMs","screenRamp","provenance"];function Ye(e){return e===void 0?{}:{attestationChecks:e.checks,...e.challengeMs!==void 0?{attestationChallengeMs:e.challengeMs}:{}}}r(Ye,"ke");function We(e){if(e instanceof A)return{kind:"unavailable",reason:"attestation"};if(e instanceof h){if(e.code==="attestation_invalid")return{kind:"unavailable",reason:"attestation"};if(e.code==="inference_unavailable")return{kind:"unavailable",reason:"inference_unavailable"};if(e.code==="mobile_required")return{kind:"unavailable",reason:"mobile_required"};if(ze.has(e.code))return{kind:"resync"}}return{kind:"unavailable",reason:"network"}}r(We,"Re");var yt="form_answers_invalid",S,_t=(S=class extends Error{constructor(t,n){super(`form answers refused (${t.map(i=>`${i.id}: ${i.code}`).join(", ")})`),this.name="FormAnswersError",this.issues=t,this.source=n}},r(S,"U"),S),I,vt=(I=class extends Error{constructor(t,n){super(`invalid ${t} (${n})`),this.name="InvalidInputError",this.field=t,this.kind=n}},r(I,"B"),I),C,bt=(C=class extends Error{constructor(t,n){super(`invalid ${t} (${n})`),this.name="OtpInputError",this.field=t,this.kind=n}},r(C,"$"),C);function j(e){return e?.source==="upload"?null:e?.source==="choice"&&e.sourcePick!=="camera"?"upload_or_phone":"phone"}r(j,"I");function kt(e,t){if(t===void 0||!z(t)||t.requiresMobile!==!0)return null;switch(t.checkType){case"liveness":return"phone";case"face_match":{if(t.reason!==void 0)return"phone";let n=$(e,"portrait_icao");return n?.state==="passed"||n?.state==="review"?null:"phone"}case"doc_ocr":return j(e.documents);case"poa":return j(e.proofOfAddress);case"portrait_icao":{let n=e.portrait;return n?.pendingFix!==void 0||n?.reuse?.pending===!0?null:j(n)}default:return null}}r(kt,"Ue");function Xe(e){let t=e?.capture,n=t?.mode;return n==="assisted"||n==="self"||n==="choice"?n:t?.cameraSwitch===!0?"assisted":"self"}r(Xe,"we");function gt(e){let t=e?.capture?.pick;return Xe(e)==="choice"&&(t==="self"||t==="assisted")?t:null}r(gt,"$e");function wt(e,t,n=null){return e==="choice"?t??n??"self":e}r(wt,"Ye");var Mt={"JP:drivers_license":{normalize:"upper_no_space_or_hyphen",pattern:"^[0-9]{12}$",check:null,registrySources:[],describe:"number must be the 12-digit Japanese driving licence number"},"JP:residence_permit":{normalize:"upper_no_space_or_hyphen",pattern:"^[A-Z]{2}[0-9]{8}[A-Z]{2}$",check:null,registrySources:[],describe:"number must be the 12-character residence card number: two letters, eight digits, two letters"},"MR:drivers_license":{normalize:"upper_no_space_or_hyphen",pattern:"^[0-9]{8}$",check:null,registrySources:[],describe:"number must be the 8-digit Mauritanian driver's license number"},"MR:national_id":{normalize:"trim",pattern:"^[0-9]{10}$",check:"mr_nni_mod97",registrySources:["MR.anrpts"],describe:"number must be the 10-digit Mauritanian national ID number with a valid check digit"}};export{h as a,v as b,it as c,st as d,rt as e,dt as f,ut as g,lt as h,ke as i,y as j,F as k,ge as l,pt as m,z as n,Me as o,Y as p,$ as q,x as r,E as s,ht as t,Ce as u,ee as v,$e as w,Ue as x,mt as y,Le as z,ne as A,ft as B,Be as C,yt as D,_t as E,vt as F,bt as G,kt as H,Xe as I,gt as J,wt as K,Mt as L};
@@ -1 +1 @@
1
- import{a as C,d as f,e as l,f as d,g as m,h as v,i as p,j as g,l as x}from"./chunk-KU3B6BDD.js";import{a as i}from"./chunk-5QL6W6FW.js";import{a as o,c as b}from"./chunk-4FHWXBOB.js";var r=b(C(),1);var y={ar:l,fr:d,en:f};function h(e,t){let s=v(e),a=s===void 0?y[m(e)]:{...y.en,...s};if(t===void 0)return a;let n={...a};for(let u of Object.keys(t)){let c=t[u];typeof c=="string"&&(n[u]=c)}return x(n,t),n}o(h,"T");i(h,"resolveStrings");function j(e){let[,t]=(0,r.useState)(0),s=p(e);return(0,r.useEffect)(()=>{if(!s)return;let a=!0;return g(e).then(()=>a&&t(n=>n+1)),()=>{a=!1}},[e,s]),!s}o(j,"w");i(j,"useLocaleReady");var S=(0,r.createContext)(e=>f[e]??""),E=S.Provider;function k(){return(0,r.useContext)(S)}o(k,"I");i(k,"useStrings");export{h as a,j as b,E as c,k as d};
1
+ import{a as C,d as f,e as l,f as d,g as m,h as v,i as p,j as g,l as x}from"./chunk-LPLPMWHJ.js";import{a as i}from"./chunk-5QL6W6FW.js";import{a as o,c as b}from"./chunk-4FHWXBOB.js";var r=b(C(),1);var y={ar:l,fr:d,en:f};function h(e,t){let s=v(e),a=s===void 0?y[m(e)]:{...y.en,...s};if(t===void 0)return a;let n={...a};for(let u of Object.keys(t)){let c=t[u];typeof c=="string"&&(n[u]=c)}return x(n,t),n}o(h,"T");i(h,"resolveStrings");function j(e){let[,t]=(0,r.useState)(0),s=p(e);return(0,r.useEffect)(()=>{if(!s)return;let a=!0;return g(e).then(()=>a&&t(n=>n+1)),()=>{a=!1}},[e,s]),!s}o(j,"w");i(j,"useLocaleReady");var S=(0,r.createContext)(e=>f[e]??""),E=S.Provider;function k(){return(0,r.useContext)(S)}o(k,"I");i(k,"useStrings");export{h as a,j as b,E as c,k as d};
@@ -0,0 +1 @@
1
+ import{a as tt,b as rt,c as Fe,d as it,f as at,g as ot,h as nt,r as st,w as dt,x as lt,z as ut}from"./chunk-XKZZC74I.js";import{a as ct,b as Ee,e as pt,f as ht}from"./chunk-37BKUH3E.js";import{f as ge}from"./chunk-I7ZZMP7U.js";import{e as Qe,k as et}from"./chunk-6MYG4HWP.js";import{g as ze}from"./chunk-JS2IXPNL.js";import{a}from"./chunk-4FHWXBOB.js";function mt(e,t){let r=new Set(e.flatMap(o=>o.sides.filter(s=>s[t]!==null).map(s=>s.side)));return r.size===1?[...r][0]:null}a(mt,"gt");function qt(e){let t=pt.find(o=>o.docType===e),r=t.mrz==="none"?null:t.mrz==="td3"?"single":"verso";return{sides:t.sides,format:ht(e),mrz:t.mrz==="none"?"none":"required",mrzSide:r,barcodeSide:null,portraitSide:t.portraitSide,scripts:null}}a(qt,"Jt");function Ot(e){let t=[];for(let r of e)for(let o of r.sides){if(!Array.isArray(o.scripts))return null;for(let s of o.scripts)t.includes(s)||t.push(s)}return t}a(Ot,"en");function Nt(e,t){if(t.length===0)return qt(e);let r=t.some(l=>l.sides.length>1),o=new Set(t.map(l=>l.format)),s=o.size===1?[...o][0]:"card",u=t.filter(l=>l.sides.some(f=>f.mrz!==null)).length,c=t.find(l=>l.sides.length>1===r)?.sides.find(l=>l.portrait)?.side;return{sides:r?["recto","verso"]:["single"],format:s,mrz:u===t.length?"required":u===0?"none":"optional",mrzSide:mt(t,"mrz"),barcodeSide:mt(t,"barcode"),portraitSide:c??(r?"recto":"single"),scripts:Ot(t)}}a(Nt,"bt");function Dt(e,t,r){let o=Mt(e,t).flatMap(s=>s.sides.find(u=>u.side===r)?.zones??[]);return o.length>0?o:ct[t]?.sides.find(s=>s.side===r)?.zones??[]}a(Dt,"yt");function Mt(e,t){if(e===void 0)return[];let r=e.toUpperCase();return Object.prototype.hasOwnProperty.call(Ee,r)?Ee[r]?.[t]??[]:[]}a(Mt,"Le");async function Ht(e,t,r){return await e(t)?r:r==="recto"?"verso":"recto"}a(Ht,"Mt");function Ut(e,t,r){return e!==t&&t==="verso"&&r.recto!==void 0&&r.verso===void 0?"verso":e}a(Ut,"wt");var _t={low:{maxLongEdge:1920,payloadTargetBytes:7e5,qMin:.7,qMax:.92},mid:{maxLongEdge:2240,payloadTargetBytes:12e5,qMin:.7,qMax:.92},good:{maxLongEdge:2560,payloadTargetBytes:16e5,qMin:.7,qMax:.92}};function Vt(e){let{deviceMemory:t,effectiveType:r,saveData:o,downlinkMbps:s,sourceLongEdge:u}=e,c=o===!0||r==="slow-2g"||r==="2g"||s!=null&&s>0&&s<1,l=t!=null&&t<=2,f=r==="4g"||s!=null&&s>=5,p=t!=null&&t>=6,k;c||l?k="low":f&&p?k="good":k="mid";let d=_t[k],z=u&&u>0?Math.min(d.maxLongEdge,u):d.maxLongEdge;return{tier:k,...d,maxLongEdge:z}}a(Vt,"nn");function It(e){let t={};try{let r=navigator;typeof r.deviceMemory=="number"&&(t.deviceMemory=r.deviceMemory);let o=r.connection;o&&(t.effectiveType=o.effectiveType,t.saveData=o.saveData,t.downlinkMbps=o.downlink)}catch{}return typeof e=="number"&&e>0&&(t.sourceLongEdge=e),Vt(t)}a(It,"Ct");function Gt(e,t,r){let o=Math.min(1,Math.max(0,(e-.28)/.21999999999999997)),s=(t+r)/2;return Math.max(t,r-o*(r-s))}a(Gt,"rn");function jt(e,t,r){let o=Math.max(e,t),s=o>0?Math.min(1,r/o):1;return{width:Math.max(1,Math.round(e*s)),height:Math.max(1,Math.round(t*s))}}a(jt,"on");async function Zt(e,t){let r=t.startQ,o=await e(r);for(let s=0;s<4&&!(o.size<=t.budgetBytes||r<=t.qMin);s++)r=Math.max(t.qMin,r-.08),o=await e(r);return{blob:o,quality:r}}a(Zt,"an");async function Xt(e,t,r,o,s){if(t<=0||r<=0)return null;let{width:u,height:c}=jt(t,r,o.maxLongEdge),l=document.createElement("canvas");l.width=u,l.height=c;let f=l.getContext("2d");if(!f)return null;f.drawImage(e,0,0,u,c);let p=a(y=>new Promise((F,m)=>{l.toBlob(T=>T?F(T):m(new Error("canvas toBlob returned null")),"image/jpeg",y)}),"l"),k=Gt(s,o.qMin,o.qMax),{blob:d,quality:z}=await Zt(p,{startQ:k,qMin:o.qMin,budgetBytes:o.payloadTargetBytes}).finally(()=>{l.width=0,l.height=0});if(d.size>5242880)throw new Error("encoded document exceeds the 5242880-byte media cap");return{blob:d,quality:z,width:u,height:c}}a(Xt,"kt");async function Yt(e){let t=It(Math.max(e.width,e.height)),r=await Xt(e,e.width,e.height,t,.5);if(r===null)throw new Error("canvas encode unavailable");return{blob:r.blob,width:r.width,height:r.height}}a(Yt,"ve");function St(e,t,r={safetyNetMs:null,sideChangeMs:null}){return{layout:e,phase:"framing",captured:{},pending:[],lastCaptureAt:t,lastReportAt:t,manualShutter:!1,restPhase:"framing",readSides:[],needFlip:!1,flipped:!1,flipTimeoutSpent:!1,timeoutCapture:!1,lastShotByTimeout:!1,tuning:r,safetyNetSpent:!1,sideHits:0,turnSeen:!1}}a(St,"Be");var De=a(e=>e==="recto"?"verso":"recto","Fe"),kt=a(e=>e.phase==="framing"||e.phase==="locking"||e.phase==="flipCue"||e.phase==="reaskRecto","Rt"),K=a(e=>(e.captured.recto!==void 0?1:0)+(e.captured.verso!==void 0?1:0)+e.pending.length,"K");function Be(e,t){return e.lastCaptureAt>=0&&e.lastReportAt>=0?e:{...e,lastCaptureAt:e.lastCaptureAt<0?t:e.lastCaptureAt,lastReportAt:e.lastReportAt<0?t:e.lastReportAt}}a(Be,"Oe");function $t(e){if(K(e)===1)return e.captured.recto!==void 0?"recto":e.captured.verso!==void 0?"verso":void 0}a($t,"sn");function Jt(e,t,r){if(e.phase==="result")return{...e,lastReportAt:r};let o=!t.present||e.captureArea!==void 0&&t.areaFrac<.6*e.captureArea,{flipped:s,awaySince:u}=e,c=e.sideSince,l=e.sideHits,f=$t(e),p=e.tuning.sideChangeMs!==null&&e.needFlip&&f!==void 0,k=!1;p&&f==="recto"&&t.side==="verso"?(c=c??r,l+=1,k=l>=2&&r-c>=e.tuning.sideChangeMs,k&&(s=!0)):(!p||t.side!==void 0)&&(c=void 0,l=0),o&&(u=u??r),u!==void 0&&r-u>=250&&(s=!0,k=!0),o||(u=void 0);let d=p&&f==="verso"&&t.side==="verso";d&&(s=!1);let z=d?!1:e.turnSeen||k,y=e.flipTimeoutSpent&&!(s&&!e.flipped),F=e.notice==="same_face"&&s&&!e.flipped?void 0:e.notice,m=t.present&&t.steady!==!1&&t.dark!==!0&&t.glare!==!0&&!d,T=s&&!e.flipped||z&&!e.turnSeen,A=m?T?r:e.presentSince??r:void 0,x={...e,lastReportAt:r,flipped:s,awaySince:u,sideSince:c,sideHits:l,presentSince:A,turnSeen:z,flipTimeoutSpent:y,notice:F,lastArea:t.areaFrac};if(!kt(e))return x;let N=Kt(e,x,t,r,s,y),D=e.tuning.safetyNetMs;return D!==null&&e.layout==="twoSided"&&K(e)===1&&!e.safetyNetSpent&&z&&A!==void 0&&r-A>=D&&N.phase!=="capturing"?{...N,phase:"capturing",safetyNetSpent:!0,shotVia:"safety_net"}:N}a(Jt,"dn");function Kt(e,t,r,o,s,u){if(e.needFlip&&!s){if(!r.ready)return{...t,phase:e.restPhase,goodSince:void 0};let c=e.lastShot!==void 0&&e.pending.includes(e.lastShot);if(u||c)return{...t,goodSince:void 0,phase:e.restPhase};let l=e.goodSince??o;return o-l>=1800?{...t,goodSince:l,phase:"capturing",flipTimeoutSpent:!0,timeoutCapture:!0}:{...t,goodSince:l,phase:e.restPhase}}return r.ready?{...t,phase:"capturing",goodSince:e.goodSince??o}:{...t,goodSince:void 0,phase:r.locking?"locking":e.restPhase}}a(Kt,"un");function Qt(e,t){if(!kt(e)||e.manualShutter)return e;let r=t-e.lastReportAt>=2e3,o=t-e.lastCaptureAt>=6e3;return r||o?{...e,manualShutter:!0}:e}a(Qt,"cn");function er(e,t,r){let o=e.layout==="singlePage",s=o?{recto:t}:e.captured,u=o?[]:[...e.pending,t],c={...e,captured:s,pending:u,lastShot:t,lastCaptureAt:r,lastReportAt:-1,manualShutter:!1,goodSince:void 0,notice:void 0,awaySince:void 0,flipped:!1,lastShotByTimeout:e.timeoutCapture,timeoutCapture:!1,captureArea:e.lastArea,sideSince:void 0,sideHits:0,presentSince:void 0,turnSeen:!1,shotVia:void 0,lastShotVia:e.phase==="capturing"?e.timeoutCapture?"flip_timeout":e.shotVia??"ready":"manual"};return o||K({captured:s,pending:u})>=2?{...c,phase:"reading",restPhase:"framing",current:void 0,needFlip:!1}:{...c,phase:"flipCue",restPhase:"flipCue",current:void 0,needFlip:!0}}a(er,"ln");function xt(e,t,r){return e.pending.includes(t)?{...e,pending:e.pending.filter(o=>o!==t),lastShot:e.lastShot===t?void 0:e.lastShot,phase:e.phase==="capturing"?e.phase:"flipCue",restPhase:"flipCue",current:De(r),needFlip:!0,flipTimeoutSpent:!1,goodSince:void 0,manualShutter:!0,notice:"same_face",lastCaptureAt:-1,lastReportAt:-1,turnSeen:!1,presentSince:void 0}:e}a(xt,"_t");function tr(e,t,r,o=!1){if(!e.pending.includes(t))return e;if(e.captured[r]!==void 0)return xt(e,t,r);let s=e.pending.filter(p=>p!==t),u={...e,pending:s,captured:{...e.captured,[r]:t}};if(K(u)!==1||e.layout==="singlePage")return u;if(o)return{...u,unsure:t,phase:"reading",restPhase:"flipCue",current:void 0,needFlip:!1};let c=De(r),l=c==="recto"&&e.restPhase==="reaskRecto"?"reaskRecto":"flipCue",f=e.phase==="flipCue"||e.phase==="reaskRecto"||e.phase==="framing";return{...u,restPhase:l,current:c,phase:f?l:e.phase}}a(tr,"fn");function rr(e,t,r){let o=e.captured.recto===t?"recto":e.captured.verso===t?"verso":void 0;if(o===void 0||o===r&&e.unsure!==t)return e;let s=De(r),u={[r]:t};e.captured[s]!==void 0&&e.captured[s]!==t&&(u[s]=e.captured[s]);let c=[u.recto,u.verso,...e.pending],l={...e,captured:u,unsure:void 0,readSides:e.readSides.filter(f=>u[f]!==void 0&&u[f]===e.captured[f]),lastShot:e.lastShot!==void 0&&c.includes(e.lastShot)?e.lastShot:void 0};return e.layout==="singlePage"||K(l)!==1||e.phase!=="reading"&&e.phase!=="result"?l:{...l,phase:"flipCue",restPhase:"flipCue",current:s,needFlip:!0,flipped:!1,flipTimeoutSpent:!1,goodSince:void 0,awaySince:void 0,turnSeen:!1,safetyNetSpent:!1,presentSince:void 0,sideSince:void 0,sideHits:0,captureArea:e.lastArea,lastCaptureAt:-1,lastReportAt:-1,manualShutter:!1}}a(rr,"mn");var ft="server";function ir(e,t,r){if(e.layout==="singlePage")return e;let o={...e.captured},s=e.readSides,u=!1;for(let p of["recto","verso"]){let k=o[p];t.includes(p)?(k===void 0&&(o[p]=ft,u=!0),s.includes(p)||(s=[...s,p],u=!0)):k!==void 0&&(k===ft||r.includes(k))&&(delete o[p],s=s.filter(d=>d!==p),u=!0)}if(!u)return e;let c=[o.recto,o.verso,...e.pending],l={...e,captured:o,readSides:s,unsure:e.unsure!==void 0&&c.includes(e.unsure)?e.unsure:void 0,lastShot:e.lastShot!==void 0&&c.includes(e.lastShot)?e.lastShot:void 0};if(K(l)>=2||e.phase!=="reading"&&e.phase!=="result")return l;if(K(l)===0)return{...l,phase:"framing",restPhase:"framing",current:void 0,needFlip:!1,goodSince:void 0,lastCaptureAt:-1,lastReportAt:-1};let f=o.recto===void 0?"recto":"verso";return{...l,phase:"flipCue",restPhase:"flipCue",current:f,needFlip:!0,flipped:!1,flipTimeoutSpent:!1,goodSince:void 0,awaySince:void 0,turnSeen:!1,safetyNetSpent:!1,presentSince:void 0,sideSince:void 0,sideHits:0,captureArea:e.lastArea,lastCaptureAt:-1,lastReportAt:-1,manualShutter:!1}}a(ir,"pn");function ar(e,t){if(t.id!==void 0&&e.captured.recto!==t.id&&e.captured.verso!==t.id&&!e.pending.includes(t.id))return e;let r=t.id??e.captured[t.side],o={...e.captured};(t.id===void 0||o[t.side]===t.id)&&delete o[t.side];let s=e.pending.filter(p=>p!==r),u=e.layout==="twoSided"&&K({captured:o,pending:s})>0,c=e.lastShotByTimeout||r===e.lastShot!==e.flipped,l=u&&!c,f=l?t.side==="recto"?"reaskRecto":"flipCue":"framing";return{...e,captured:o,pending:s,readSides:e.readSides.filter(p=>p!==t.side),unsure:e.unsure===r?void 0:e.unsure,lastShot:e.lastShot===r?void 0:e.lastShot,notice:t.issue,goodSince:void 0,manualShutter:t.shutter===!0,phase:f,restPhase:f,current:t.side,needFlip:l,flipped:!1,flipTimeoutSpent:!1,awaySince:void 0,lastCaptureAt:-1,lastReportAt:-1,safetyNetSpent:!1,sideSince:void 0,sideHits:0,presentSince:void 0,turnSeen:u&&!l&&r===e.lastShot&&!e.flipped&&!e.lastShotByTimeout}}a(ar,"hn");function or(e,t){switch(t.type){case"report":return Jt(Be(e,t.at),t.report,t.at);case"tick":return Qt(Be(e,t.at),t.at);case"captured":return er(Be(e,t.at),t.id,t.at);case"captureFailed":return{...e,phase:e.restPhase,goodSince:void 0,lastCaptureAt:t.at,manualShutter:!0,timeoutCapture:!1,shotVia:void 0,...e.shotVia==="safety_net"?{safetyNetSpent:!1,presentSince:void 0}:{}};case"classified":return tr(e,t.id,t.side,t.unsure===!0);case"held":return rr(e,t.id,t.side);case"serverHeld":return ir(e,t.sides,t.answered);case"duplicate":return xt(e,t.id,t.side);case"readOk":{let r=e.readSides.includes(t.side)?e.readSides:[...e.readSides,t.side],o=e.layout==="twoSided"?["recto","verso"]:["recto","verso"].filter(u=>e.captured[u]!==void 0),s=e.phase==="reading"&&e.pending.length===0&&o.every(u=>r.includes(u));return{...e,readSides:r,flipTimeoutSpent:!1,phase:s?"result":e.phase}}case"readFailed":return ar(e,t);case"clockRestart":return e.lastCaptureAt<0&&e.lastReportAt<0&&e.awaySince===void 0&&e.presentSince===void 0&&e.sideSince===void 0&&e.sideHits===0?e:{...e,awaySince:void 0,presentSince:void 0,sideSince:void 0,sideHits:0,lastCaptureAt:-1,lastReportAt:-1};case"retake":return{...St(e.layout,-1,e.tuning),lastCaptureAt:-1,lastReportAt:-1};default:return e}}a(or,"Pt");var nr={card:80,probe:40,phase:160,hold:80},We=36e5,sr=0;function G(e){if(e===void 0||!e.startsWith("shot-"))return 0;let t=Number(e.slice(5));return Number.isInteger(t)&&t>0?Math.min(t,999):0}a(G,"V");var ce=a(e=>Math.round(Math.min(1,Math.max(0,e))*1e3)/1e3,"ue"),X=a((e,t)=>Math.max(0,Math.min(t,Math.round(e))),"j");function dr(e){return e.mrzFace!==null?"live_mrz":e.byBarcode!==null?"barcode":e.banded===null?"order":e.verdict==="recto"&&e.confirmed===void 0&&e.seen==="verso"?"turn":e.confirmed!==void 0?"reader":"band"}a(dr,"Et");function lr(e){let t=Math.min(sr+=1,999),r=null,o=0,s=0,u=[],c=new Map,l=new Set,f=null,p=null,k,d=null,z="{}",y=!1,F=a(()=>r===null?0:X(e.now()-r,We),"W"),m=!1,T=a(()=>m?F():(m=!0,0),"M"),A=a(()=>{if(u.length===0)return;let w=u;if(u=[],o>=20||e.sink===void 0){s+=w.length;return}let b={kind:"capture_trace",platform:"web",step:"document",run:t,seq:o++,events:w,...s>0?{dropped:Math.min(s,1e5)}:{}};s=0;try{e.sink([b])}catch{}},"k"),x=a((w,b=F())=>{if(y)return;let h=nr[w.e];if(h!==void 0){let R=(c.get(w.e)??0)+1;if(c.set(w.e,R),R>h){s+=1;return}}if(o>=20){s+=1;return}u.push({t:b,...w}),u.length>=40&&A()},"b"),N=a(w=>{if(w.layout==="singlePage")return w.captured.recto!==void 0?{single:G(w.captured.recto)}:{};let b={};for(let h of["recto","verso"]){let R=w.captured[h];R!==void 0&&R!==w.unsure&&(b[h]=G(R))}return b},"A"),D={start(w,b){r===null&&(r=e.now()),x({e:"start",layout:w,...b==="recto"||b==="verso"?{expect:b}:{}},T())},observe(w,b,h){if(h.type==="report"){let{present:P,steady:H,side:W}=h.report;P!==p&&(x({e:"card",present:P,...H!==void 0?{steady:H}:{}}),p=P),k=H,(W==="recto"||W==="verso")&&W!==d&&(d=W,x({e:"probe",side:W}))}if(b===w)return;if(!w.flipped&&b.flipped&&x({e:"turn",by:b.awaySince!==void 0?"away":"probe"}),!w.manualShutter&&b.manualShutter){let P=h.type==="tick"?"timer":h.type==="duplicate"?"same_side":h.type==="captureFailed"?"no_photo":"other";x({e:"shutter",why:P})}if(h.type==="classified")x({e:"filed",photo:G(h.id),side:b.layout==="singlePage"?"single":h.side,...h.unsure===!0?{unsure:!0}:{}});else if(h.type==="duplicate"){let P=G(h.id);x({e:"same_side",photo:P,side:h.side,why:l.has(P)?"classifier":"mrz_twin"})}else if(h.type==="held")x({e:"held",photo:G(h.id),side:h.side});else if(h.type==="serverHeld")for(let P of h.sides)w.captured[P]===void 0&&b.captured[P]!==void 0&&x({e:"held",photo:G(b.captured[P]),side:P});else h.type==="readFailed"&&x({e:"refused",...h.id!==void 0?{photo:G(h.id)}:{},side:h.side,issue:h.issue});if(w.phase!==b.phase){let P=F();w.phase==="locking"&&f!==null&&(x({e:"hold",ms:X(P-f,We),end:b.phase==="capturing"?"shot":"lost"}),f=null),b.phase==="locking"&&(f=P),x({e:"phase",phase:b.phase,...b.current!==void 0?{expect:b.current}:{}})}let R=N(b),g=JSON.stringify(R);g!==z&&(z=g,x({e:"tray",...R})),b.phase==="result"&&w.phase!=="result"&&Promise.resolve().then(A)},shot(w,b,h,R){let g=b,P={};for(let[H,W]of Object.entries(g?.guideBlockers??{}))ur.has(H)&&typeof W=="number"&&W>0&&(P[H]=X(W,1e5));x({e:"shot",photo:w,...h!==void 0?{via:h}:{},...g?.via!==void 0?{engineVia:g.via}:{},...g?.stillSource==="photo"||g?.stillSource==="video"?{still:g.stillSource}:{},...R!==void 0?{expect:R}:{},...k!==void 0?{steady:k}:{},...g?.msToCapture!==void 0?{ms:X(g.msToCapture,We)}:{},...typeof g?.ticks=="number"?{ticks:X(g.ticks,1e5)}:{},...g?.shotGlare!==void 0?{glare:ce(g.shotGlare)}:{},...g?.shotTorch!==void 0?{torch:g.shotTorch}:{},...g?.shotGlareZone!==void 0?{glareZone:g.shotGlareZone}:{},...g?.shotSharpness!==void 0?{sharpness:X(g.shotSharpness,1e6)}:{},...g?.deviceClass!==void 0?{deviceClass:g.deviceClass}:{},...g?.demotedFrom!==void 0?{demotedFrom:g.demotedFrom}:{},...g?.demotedBy!==void 0?{demotedBy:g.demotedBy}:{},...g?.tickMedianMs!==void 0?{tickMedianMs:X(g.tickMedianMs,6e4)}:{},...g?.video!==void 0?{videoWidth:X(g.video.width,16384),videoHeight:X(g.video.height,16384)}:{},...typeof g?.zoom=="number"?{zoom:Math.round(Math.min(Math.max(g.zoom,0),20)*100)/100}:{},...Object.keys(P).length>0?{blockers:P}:{}})},band(w){return b=>(h,R={})=>{let g=b(h,R),P=R.EDGE_LUMA_DELTA!==void 0?"soft":R.MAX_HEIGHT_FRAC!==void 0?"td1":R.LONE_EDGE_PX!==void 0?"default":"plain",H=h.width||1,W=h.height||1;return x({e:"band",photo:w,pass:P,px:X(h.width,16384),found:g!==null,...g!==null?{x:ce(g.x/H),y:ce(g.y/W),w:ce(g.width/H),h:ce(g.height/W)}:{}}),g}},reader(w,b){x({e:"reader",photo:w,lines:X(b.lineCount,9),valid:b.valid===!0,...b.format!==void 0?{format:b.format}:{}})},side(w,b,h,R){l.add(w),x({e:"side",photo:w,side:b,path:h,...R!==void 0?{format:R}:{}})},answer(w,b,h,R){let g=typeof R=="string"?R.split("/")[2]?.split(".")[0]:void 0;x({e:"answer",photo:w,accepted:(b??[]).filter(P=>P==="recto"||P==="verso"),...b===null?{done:!0}:{},...g!==void 0&&/^[0-9a-f-]{8,64}$/i.test(g)?{media:g.toLowerCase()}:{},...h!==void 0&&/^[a-z][a-z0-9_]{0,63}$/.test(h)?{reason:h}:{}})},settle(w,b,h){x({e:"settle",...w!==void 0?{photo:w}:{},sent:b,ok:h.ok,...h.ok&&h.heldAs!==void 0?{keptAs:h.heldAs}:{},...h.ok?{}:{issue:h.issue}}),Promise.resolve().then(A)},end(w){x({e:"end",outcome:w}),y=!0,A()},flush:A},Q={};for(let[w,b]of Object.entries(D))Q[w]=w==="band"?h=>R=>{let g;try{g=D.band(h)(R)}catch{return R}return(P,H)=>{try{return g(P,H)}catch{return R(P,H)}}}:(...h)=>{try{return b(...h)}catch{return}};return Q}a(lr,"xt");var ur=new Set(["no_card","too_small","too_big","off_center","glare","blurry","steadying","locking","surface","dark"]),qe=a((e,t,r)=>Math.min(r,Math.max(t,Math.round(e))),"ze"),ye=a(e=>Math.round(Math.min(1,Math.max(0,e))*1e4)/1e4,"ge");async function cr(e,t,r,o){let s=o.decode??(f=>createImageBitmap(f)),u=a(async()=>e.stillRead(await s(t),o.region??[0,0,1,1],o.detectorLimit),"u"),c;try{c=await u()}catch{try{await new Promise(f=>setTimeout(f,o.retryMs??300)),c=await u()}catch{return null}}let l=c.mrzBox;return l===void 0?null:{engine:o.engine,source:"live_mrz",format:r.format,lineCount:qe(r.lineCount,2,3),checkDigitsValid:!0,stillConfirmed:c.valid&&c.digest===r.digest,band:[ye(l[0]),ye(l[1]),ye(Math.min(l[2],1-l[0])),ye(Math.min(l[3],1-l[1]))],digest:r.digest,framesToValid:qe(r.framesToValid,1,1e3),msToValid:qe(r.msToValid,0,12e4)}}a(cr,"Lt");var pr=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]),hr=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,7,1,5,0,6,64,11,11]);function mr(e=globalThis){let t=e.WebAssembly?.validate;if(typeof t!="function")return{ok:!1,reason:"simd"};try{if(!t.call(e.WebAssembly,pr)||!t.call(e.WebAssembly,hr))return{ok:!1,reason:"simd"}}catch{return{ok:!1,reason:"simd"}}return typeof e.Worker!="function"?{ok:!1,reason:"worker"}:typeof e.createImageBitmap!="function"?{ok:!1,reason:"bitmap"}:{ok:!0}}a(mr,"vt");function fr(e=globalThis){let t=e.navigator?.connection;return t?.saveData===!0||["slow-2g","2g","3g"].includes(t?.effectiveType??"")}a(fr,"Ot");var ne,Y=(ne=class extends Error{constructor(t){super(t),this.name="OcrEngineError",this.code=t}},a(ne,"Y"),ne);function vt(){let e=a(t=>(t.close(),Promise.reject(new Y("unsupported"))),"e");return{ready:Promise.resolve("unsupported"),busy:!1,bandRead:e,stillRead:e,layoutRead:e,dispose:a(()=>{},"dispose")}}a(vt,"At");function vr(e){let t;try{if(e.createWorker)t=e.createWorker();else if(e.workerUrl!==void 0)t=new Worker(e.workerUrl,{type:"module",name:"sekyro-ocr"});else return vt()}catch{return vt()}let r=new Map,o=0,s=!1,u=!1,c=!1;t.addEventListener("message",m=>{let T=m.data,A=r.get(T.id);A&&(r.delete(T.id),A.resolve(T))});let l=a(()=>{for(let m of r.values())m.reject(new Y("error"));r.clear(),p()},"d");t.addEventListener("error",l),t.addEventListener("messageerror",l);function f(m,T=[]){if(s)return Promise.reject(new Y("disposed"));let A=++o;return new Promise((x,N)=>{r.set(A,{resolve:x,reject:N});try{t.postMessage({...m,id:A},T)}catch{r.delete(A),N(new Y("error"))}})}a(f,"m");function p(){if(!s){s=!0;try{t.postMessage({id:++o,kind:"dispose"})}catch{}t.terminate();for(let m of r.values())m.reject(new Y("disposed"));r.clear()}}a(p,"l");let k=(async()=>{let m=await f({kind:"init",baseUrl:e.baseUrl,salt:e.salt,detectorLimit:e.tuning.detectorLimit,maxDownloadMs:e.tuning.maxDownloadMs});if(m.kind==="failed")return m.reason;if(m.kind!=="ready")return"error";let T=await f({kind:"warmup"});if(T.kind!=="ready")return"error";let A=T.benchMs??T.warmupMs,x=e.deviceMemoryGb===void 0?rt():e.deviceMemoryGb;return{warmupMs:T.warmupMs,downloadMs:m.downloadMs,cached:m.cached,benchMs:A,tier:tt(A,x)}})().catch(()=>"error"),d,z=new Promise(m=>{d=setTimeout(()=>m("timeout"),e.tuning.loadTimeoutMs)}),y=Promise.race([k,z]).then(m=>(clearTimeout(d),typeof m=="string"?p():c=!0,s&&typeof m!="string"?"error":m));(e.page===void 0?globalThis.addEventListener?globalThis:null:e.page)?.addEventListener("pagehide",p,{once:!0});async function F(m,T,A){if(s)throw T.close(),new Y("disposed");if(!c)throw T.close(),new Y("not_ready");if(u)throw T.close(),new Y("busy");u=!0;let x;try{let N=new Promise((Q,w)=>{x=setTimeout(()=>{w(new Y("timeout")),p()},e.tuning.readTimeoutMs??1e4)}),D=await Promise.race([f(m,[T]),N]);if(D.kind===A){let{id:Q,...w}=D;return w}throw new Y(D.kind==="error"?D.code:D.kind==="failed"?D.reason:"error")}finally{clearTimeout(x),u=!1}}return a(F,"P"),{ready:y,get busy(){return u},bandRead:a((m,T=e.tuning.detectorLimit,A)=>F({kind:"band",bitmap:m,detectorLimit:T,...A!==void 0?{expiredBefore:A}:{}},m,"band"),"bandRead"),stillRead:a((m,T,A=e.tuning.detectorLimit)=>F({kind:"still",bitmap:m,region:T,detectorLimit:A},m,"band"),"stillRead"),layoutRead:a((m,T)=>F({kind:"layout",bitmap:m,detectorLimit:T},m,"layout"),"layoutRead"),dispose:p}}a(vr,"Bt");var we="sekyro-ocr-1",Oe=a(e=>e!==null&&typeof e=="object"?e:{},"We"),j=a((e,t,r,o)=>typeof e=="number"&&Number.isFinite(e)&&e>=t&&e<=r?e:o,"X"),gt=a((e,t)=>typeof e=="boolean"?e:t,"Ft"),yt=a(e=>{let t=typeof e=="string"?/^sekyro-ocr-(\d{1,4})$/.exec(e):null;return t?Number(t[1]):Number.POSITIVE_INFINITY},"It");function gr(e,t={}){let r=Oe(e),o=Oe(r.liveMrz),s=Oe(r.frontLock),u=yt(t.engine??we),c=t.mode==="off",l=o.enabled===!0,f=s.enabled===!0,p=a((m,T)=>!c&&T&&yt(m.minEngine??we)<=u,"l"),k=lt,d=p(o,l)?{detectorLimit:j(o.detectorLimit,320,1600,k.detectorLimit),bandMaxWidthPx:j(o.bandMaxWidthPx,320,4096,k.bandMaxWidthPx),minBandWidthPx:j(o.minBandWidthPx,0,4096,k.minBandWidthPx),bandTop:j(o.bandTop,0,.95,k.bandTop),minIntervalMs:j(o.minIntervalMs,0,5e3,k.minIntervalMs),stableReads:Math.round(j(o.stableReads,1,10,k.stableReads)),profileReads:Math.round(j(o.profileReads,1,100,k.profileReads)),maxReadMs:j(o.maxReadMs,50,6e4,k.maxReadMs),searchTimeoutMs:j(o.searchTimeoutMs,1e3,12e4,k.searchTimeoutMs),hint:gt(o.hint,!0),stillConfirm:gt(o.stillConfirm,!0)}:null,z=dt,y=a((m,T,A)=>j(s[m],T,A,z[m]),"g"),F=p(s,f)?{minLines:Math.round(y("minLines",1,50)),fillMin:y("fillMin",0,1),fillMax:y("fillMax",0,2),offsetMax:y("offsetMax",0,1),steadyFillDelta:y("steadyFillDelta",0,1),steadyOffsetDelta:y("steadyOffsetDelta",0,1),layoutShiftMax:y("layoutShiftMax",0,1),lineCountDelta:Math.round(y("lineCountDelta",0,50)),lockMs:y("lockMs",0,3e4),steadyMs:y("steadyMs",0,3e4),minFrames:Math.round(y("minFrames",1,100)),minIntervalMs:y("minIntervalMs",0,5e3),maxWidthPx:y("maxWidthPx",160,2048),detectorLimit:y("detectorLimit",320,1600),searchTimeoutMs:y("searchTimeoutMs",1e3,12e4)}:null;return{enabled:d!==null||F!==null,liveMrz:d,textLock:F,liveMrzOn:l,frontLockOn:f,load:{detectorLimit:d?.detectorLimit??F?.detectorLimit??k.detectorLimit,loadTimeoutMs:j(o.loadTimeoutMs,1e3,12e4,2e4),maxDownloadMs:j(o.maxDownloadMs,1e3,12e4,2e4)},reportSampleRate:j(o.reportSampleRate,0,1,1)}}a(gr,"zt");function yr(e,t){return e.enabled?!(t.probe??mr)().ok||(t.slow??fr)()?{ok:!1,reason:"unsupported"}:{ok:!0,engine:vr({baseUrl:t.baseUrl,salt:t.salt,tuning:{detectorLimit:e.load.detectorLimit,maxDownloadMs:e.load.maxDownloadMs,loadTimeoutMs:e.load.loadTimeoutMs},...t.workerUrl!==void 0?{workerUrl:t.workerUrl}:{},...t.createWorker!==void 0?{createWorker:t.createWorker}:{},...t.page!==void 0?{page:t.page}:{},...t.deviceMemoryGb!==void 0?{deviceMemoryGb:t.deviceMemoryGb}:{}})}:{ok:!1,reason:"off"}}a(yr,"Wt");function wr(e=typeof navigator<"u"?navigator.userAgent:""){return/SamsungBrowser\//.test(e)?"samsung":/Firefox\/|FxiOS\//.test(e)?"firefox":/Chrome\/|CriOS\/|Chromium\//.test(e)&&!/Edg\/|OPR\//.test(e)?"chrome":/Safari\//.test(e)&&/Version\/|Mobile\//.test(e)&&!/Chrome\/|CriOS\//.test(e)?"safari":"other"}a(wr,"wn");var J=a(e=>e===void 0||!Number.isFinite(e)?void 0:Math.min(6e5,Math.max(0,Math.round(e))),"$"),Ne=a((e,t,r)=>e===void 0||!Number.isFinite(e)?void 0:Math.min(r,Math.max(t,Math.round(e))),"Ne");function br(e){let t=e.assist??null,r=e.load!==null&&e.load!==void 0&&typeof e.load=="object"?e.load:null,o=typeof e.load=="string"?e.load:null,s=t!==null?t.outcome:o==="unsupported"||o==="download"||o==="integrity"?o:o==="error"||o==="timeout"?"error":"off",u={kind:"live_mrz",platform:"web",engine:e.engine??we,capture:e.capture,outcome:s,reads:Ne(t?.reads??0,0,1e4)??0,browser:e.browser??wr()},c=a((l,f)=>{f!==void 0&&(u[l]=f)},"c");return c("format",t?.format),c("framesToValid",Ne(t?.framesToValid,1,1e4)),c("msToValid",J(t?.msToValid)),c("framesToLock",Ne(t?.framesToLock,1,1e4)),c("msToLock",J(t?.msToLock)),c("msToCapture",J(e.msToCapture)),c("readP50Ms",J(t?.readP50Ms)),c("readP90Ms",J(t?.readP90Ms)),c("deviceClass",t?.deviceClass),r!==null&&(c("warmupMs",J(r.warmupMs)),c("downloadMs",J(r.downloadMs)),c("cached",r.cached),c("tier",r.tier),c("benchMs",J(r.benchMs))),c("stillConfirmed",e.stillConfirmed),c("typeMismatch",e.typeMismatch),u}a(br,"Nt");function wt(e,t){return e===void 0?!1:t==="passport"?e!=="TD3":e==="TD3"}a(wt,"Ge");var Mr=2,Sr=1500,kr=2500;async function xr(e){let t=await import("./capture-session-doc-HGA7NCJI-PAHR5UED.js");return new t.CaptureSessionDoc(e)}a(xr,"Tn");function Cr(e){return{topLeft:{x:e.x,y:e.y},topRight:{x:e.x+e.width,y:e.y},bottomRight:{x:e.x+e.width,y:e.y+e.height},bottomLeft:{x:e.x,y:e.y+e.height}}}a(Cr,"Rn");function bt(e){let t=[e.topLeft.x,e.topRight.x,e.bottomRight.x,e.bottomLeft.x],r=[e.topLeft.y,e.topRight.y,e.bottomRight.y,e.bottomLeft.y],o=Math.min(...t),s=Math.min(...r);return{x:o,y:s,width:Math.max(...t)-o,height:Math.max(...r)-s}}a(bt,"Gt");function Tr(e,t,r){let o=[e.topLeft,e.topRight,e.bottomRight,e.bottomLeft],s=0;for(let u=0;u<o.length;u+=1){let c=o[u],l=o[(u+1)%o.length];s+=c.x*l.y-l.x*c.y}return t>0&&r>0?Math.abs(s)/2/(t*r):0}a(Tr,"_n");function Ar(e,t){return t==="verso"?"verso":t==="recto"?e==="recto"||e===null?"recto":"unsure":t===null?"unsure":e??"unsure"}a(Ar,"Pn");function pe(e){return e.startsWith("shot-")?Number(e.slice(5)):0}a(pe,"le");function Wr(){import("./capture-session-doc-HGA7NCJI-PAHR5UED.js").then(e=>e.warmDocDetector()).catch(()=>{})}a(Wr,"wr");function qr(e){return Pr(e,{}).handle}a(qr,"Cr");function Pr(e,t){let r=Qe(),o=et({enabled:e.keepScreenAwake!==!1}),s=t.decode??(i=>createImageBitmap(i)),u=t.blurRefuseSharpnessMax??.16,c=t.now??(()=>performance.now()),l=lr({now:c,sink:t.traceSink});r.on("captured",()=>l.flush());let f=Nt(e.documentType,t.catalogCapture===!0?t.captureSeries??Mt(e.issuer,e.documentType):[]),p=f.sides.length===1||e.side==="single",k=t.secondSide,d=St(p?"singlePage":"twoSided",c(),k!==void 0?{safetyNetMs:k.safetyNetMs,sideChangeMs:k.sideChangeMs}:void 0);if(!p&&(e.side==="recto"||e.side==="verso")){let i=e.side==="recto"?"verso":"recto";d={...d,captured:{[i]:"server"},readSides:[i],current:e.side,phase:"flipCue",restPhase:"flipCue"}}let z="idle",y=null,F=null,m=!0,T=0,A=0,x=null,N=0,D=!1,Q="",w=null,b,h=null,R=[],g="base",P=a(i=>{k===void 0||y===null||i===g||(g=i,y.setLockTuning?.(i==="second"?k.guide:t.engineOptions?.guideLock??st))},"R"),H=a(()=>!p&&(d.captured.recto!==void 0?1:0)+(d.captured.verso!==void 0?1:0)==1,"N"),W=a(()=>P(H()?"second":"base"),"B"),He=f.mrz==="none",Ct=f.barcodeSide==="recto"||f.barcodeSide==="verso"?f.barcodeSide:null,oe=He&&!p?t.barcode?.side??Ct:null,Ue=e.barcodeAssetBaseUrl??t.barcode?.assetBaseUrl,be=null,_e=a(()=>oe===null||Ue===void 0||t.barcode?.seen!==void 0?Promise.resolve(null):(be??(be=import("./barcode-detect-C5IOXMKI-ZOZ2WOWU.js").then(i=>i.loadBarcodeDetect(Ue)).catch(()=>null)),be),"qe"),Tt=a((i,n)=>{if(oe===null)return Promise.resolve(null);let v,C=new Promise(M=>{v=setTimeout(()=>M(null),t.barcode?.budgetMs??Sr)});return Promise.race([At(i,n,oe),C]).finally(()=>clearTimeout(v))},"Ut"),At=a(async(i,n,v)=>{let C=v==="recto"?"verso":"recto";try{let M=t.barcode?.seen;if(M!==void 0)return await M(i)?v:C;let[B,L]=await Promise.all([_e(),n()]);if(B===null||L===null)return null;let I=Math.min(1600,L.width),S=document.createElement("canvas");S.width=I,S.height=Math.max(1,Math.round(L.height/L.width*I));try{let _=S.getContext("2d");return _===null?null:(_.drawImage(L,0,0,S.width,S.height),await Ht(B,_.getImageData(0,0,S.width,S.height),v))}finally{S.width=0,S.height=0}}catch{return null}},"Vt"),U=t.webOcr!==void 0&&!He?gr(t.webOcr.captureDocument,{mode:e.liveMrz?.mode??"auto"}):null,ee=null,V=U===null||!U.enabled?"off":null,he=null,me=null,Ve=new WeakMap,fe=new WeakMap,Ie=new WeakMap,Me=new Map,Ge=a(i=>Dt(e.issuer,e.documentType,i),"Ye"),Se=new Set,je=new Map,Pt=a(async(i,n,v=0)=>{let C=ee;if(C===null||V===null||typeof V!="object"||!("tier"in V))return null;let M=a(async()=>{let S=await s(i),_=n?.inStill===!0?ot(bt(n.quad),S)[0]:{x:0,y:0,width:S.width,height:S.height},Z=[_.x/S.width,_.y/S.height,_.width/S.width,_.height/S.height];return C.stillRead(S,Z,U?.liveMrz?.detectorLimit)},"D"),B,L=new Promise(S=>{B=setTimeout(()=>S(null),kr)}),I=M().catch(()=>new Promise(S=>setTimeout(S,300)).then(M)).then(S=>(l.reader(v,S),S)).then(S=>S.valid&&S.digest!==void 0?{side:"verso",digest:S.digest}:S.lineCount===0?{side:"recto"}:null).catch(()=>null);return Promise.race([I,L]).finally(()=>clearTimeout(B))},"qt"),ke="";if(U!==null&&U.enabled&&t.webOcr!==void 0){let i=t.webOcr,n=yr(U,{baseUrl:e.liveMrz?.assetBaseUrl??i.baseUrl,salt:i.salt,...e.liveMrz?.workerUrl!==void 0?{workerUrl:e.liveMrz.workerUrl}:{},...i.createWorker!==void 0?{createWorker:i.createWorker}:{}});if(n.ok){ee=n.engine;let v=new ut({textLock:U.textLock,liveMrz:U.liveMrz,...t.expiredBefore!==void 0?{expiredBefore:t.expiredBefore}:{}});he=v;let C=n.engine;C.ready.then(M=>{V=M,typeof M!="string"&&m&&v.setEngine(C,M.tier)})}else V=n.reason}let te=a(i=>{let n=JSON.stringify(i);n!==ke&&(ke=n,r.emit("mrz",i))},"ee"),Ze=a((i,n)=>{let v=t.webOcr?.reports;if(v===void 0||U===null||i===void 0)return;let C=i.format==="ID-3"||i.side==="single"?"single":i.side==="verso"?"verso":"recto";if(!(C!=="recto"&&U.liveMrzOn||U.frontLockOn)||Math.random()>=U.reportSampleRate)return;let M=i.via==="live_mrz"?me:null,B=a(()=>{let L=M?.value??null;v([br({capture:C,assist:i.ocr??null,load:V,...i.msToCapture!==void 0?{msToCapture:i.msToCapture}:{},...L!==null&&L.stillConfirmed!==void 0?{stillConfirmed:L.stillConfirmed}:{},...n!==void 0?{typeMismatch:wt(n.format,f.format==="ID-3"?"passport":"card")}:{}})])},"L");M!==null&&M.value===null?Promise.race([M.promise,new Promise(L=>setTimeout(L,3e3))]).then(B):B()},"Qe"),re=a(i=>{!m||i===z||(z=i,o.setActive(i==="starting"||i==="scanning"),r.emit("state",i))},"te"),Rt=a((i,n)=>n===void 0?null:p?"single":i.captured.recto===n?"recto":i.captured.verso===n?"verso":null,"Xt"),Lt=a(i=>({phase:i.phase,captured:p?i.captured.recto!==void 0?["single"]:[]:["recto","verso"].filter(n=>i.captured[n]!==void 0&&i.captured[n]!==i.unsure),photos:p?i.captured.recto!==void 0&&pe(i.captured.recto)>0?{single:pe(i.captured.recto)}:{}:Object.fromEntries(["recto","verso"].filter(n=>i.captured[n]!==void 0&&i.captured[n]!==i.unsure&&pe(i.captured[n])>0).map(n=>[n,pe(i.captured[n])])),expected:p?null:i.current??null,notice:i.notice??null,lastShot:Rt(i,i.lastShot),manualShutter:i.manualShutter,torchAvailable:y?.torchAvailable()??!1,torch:D}),"Zt"),Xe=a(()=>{let i=y;if(i===null)return;let n=T,v=a(()=>{m&&y===i&&T===n&&d.phase==="capturing"&&E({type:"captureFailed",at:c()})},"p");i.captureNow().then(v,v)},"Ke");function E(i){if(!m)return;let n=d;d=or(d,i),l.observe(n,d,i),d.phase==="capturing"&&n.phase!=="capturing"&&Promise.resolve().then(Xe),d.phase==="result"&&n.phase!=="result"&&(re("done"),Ye());let v=Lt(d),C=JSON.stringify(v);C!==Q&&(Q=C,r.emit("scan",v))}a(E,"O");function Ye(){h!==null&&clearInterval(h),h=null;for(let i of R.splice(0))i();y?.destroy(),y=null,o.setActive(!1)}a(Ye,"$e");let $e=a(()=>y?.captureReport?.(),"Je"),xe=!1,Je=a((i,n)=>{if(!(i===void 0||t.onFaceReport===void 0))try{t.onFaceReport(i,n)}catch{}},"et"),ie=a(i=>{ke="",!(y===null||d.phase==="reading"||d.phase==="result")&&(xe=!1,x=p?"single":d.current??i,y.rearm(x),y.setZones?.(Ge(x)))},"ne"),zt=a(async(i,n,v,C)=>{me=null;let M=V!==null&&typeof V=="object"&&V.tier==="low";if(C!==void 0&&ee!==null&&U?.liveMrz?.hint===!0&&!M){let O={promise:cr(ee,i,C,{engine:we,detectorLimit:U.liveMrz.detectorLimit}).catch(()=>null),value:null};O.promise.then(se=>{O.value=se}),me=O}C!==void 0&&wt(C.format,f.format==="ID-3"?"passport":"card")&&te({state:"mismatch",format:C.format});let B=`shot-${T+=1}`,L=d.current;E({type:"captured",id:B,at:c()});let I=d.lastShotVia,S=$e();Me.set(B,{torch:S?.shotTorch??D,...S?.shotGlareZone!==void 0?{glareZone:S.shotGlareZone}:{}}),l.shot(G(B),S,I,L),Je(S===void 0||d.lastShotVia===void 0?S:{...S,shotVia:d.lastShotVia},"captured"),xe=!0,Ze(S,C);let _=v===void 0?w:v===null?null:{quad:Cr(v),frameWidth:0,frameHeight:0,inStill:!0},Z={decoded:null},q=a(()=>(Z.decoded??(Z.decoded=Promise.resolve().then(()=>s(i)).catch(()=>null)),Z.decoded),"F");try{await Ft(B,L,i,n,_,q,me,C,I)}finally{Z.decoded!==null&&(await Z.decoded)?.close()}},"Yt"),Ft=a(async(i,n,v,C,M,B,L,I,S)=>{if(e.haptics!==!1)try{globalThis.navigator?.vibrate?.(30)}catch{}if(u>0&&!(S==="manual"&&N>=2)){let q=await(t.measureSharpness!==void 0?t.measureSharpness(v,M):B().then(O=>O===null?-1:it(O,Fe(M?.quad??null,M?.inStill===!0?O:{width:M?.frameWidth??0,height:M?.frameHeight??0},O)))).catch(()=>-1);if(!m)return;if(Number.isFinite(q)&&q>=0&&q<u){N+=1;let O=p?"recto":d.current??(d.captured.recto===void 0?"recto":"verso");E({type:"readFailed",side:O,id:i,issue:"blurry",...N>=2?{shutter:!0}:{}}),W(),ie(O);return}}N=0;let _;if(p)_="single";else{let q=I!==void 0&&I.format!=="TD3"&&(f.mrzSide==="recto"||f.mrzSide==="verso")?f.mrzSide:null,O=q===null&&t.classify===void 0?await Tt(v,B):null,se=O===null||oe===null?O:Ut(O,oe,d.captured),Te=q??se??(se===null&&oe!==null&&n!==void 0?n:null),de=Te!==null?null:await(t.classify!==void 0?t.classify(v):B().then($=>$===null?"unsure":M?.inStill===!0?at($,bt(M.quad),480,l.band(G(i))):nt($,480,Fe(M?.quad??null,{width:M?.frameWidth??0,height:M?.frameHeight??0},$),void 0,void 0,l.band(G(i))))).catch(()=>"unsure"),Ae=d.captured.recto===void 0&&d.captured.verso===void 0,Bt=ee!==null&&(V===null||typeof V=="object"&&"tier"in V),le,Ke;if(de!==null&&Bt&&f.mrzSide==="verso"&&(Ae||de!=="recto"&&d.captured.verso!==void 0)){let $=await Pt(v,M,G(i));if(!m)return;le=$?.side??null,Ke=$?.digest}let ue=Ar(de,le),ve=I?.digest??Ke;ve!==void 0&&je.set(i,ve);let Pe=ve===void 0?void 0:["recto","verso"].find($=>{let Le=d.captured[$];return Le!==void 0&&Le!==i&&je.get(Le)===ve});if(Pe!==void 0){E({type:"duplicate",id:i,side:Pe}),ie(Pe==="recto"?"verso":"recto");return}let Re=d.captured.recto===void 0?"recto":d.captured.verso===void 0?"verso":void 0,Wt=Ae&&Te===null&&ue==="unsure"&&t.deferRead===!0,ae=Te??(ue==="unsure"?Ae?de==="verso"&&le!=="recto"?"verso":"recto":Re??"recto":ue==="recto"&&le===void 0&&S!=="flip_timeout"&&d.captured.recto!==void 0&&d.captured.verso===void 0?"verso":ue);if(l.side(G(i),ae,dr({mrzFace:q,byBarcode:se,banded:de,confirmed:le,verdict:ue,seen:ae}),I?.format),!m)return;if(d.captured[ae]!==void 0&&A<Mr){A+=1,E({type:"duplicate",id:i,side:ae}),ie(ae==="recto"?"verso":"recto");return}_=d.captured[ae]!==void 0&&Re!==void 0?Re:ae,A=0,E({type:"classified",id:i,side:_,...Wt?{unsure:!0}:{}}),H()&&P("second")}let Z=_==="verso"?"verso":"recto";try{let q=t.encode!==void 0?await t.encode(v):await B().then(O=>{if(O===null)throw new Error("the still could not be decoded");return Yt(O)});if(!m)return;L!==null&&Ve.set(q.blob,L),fe.set(q.blob,i),Ie.set(q.blob,Me.get(i)??{torch:D}),Me.delete(i),r.emit("captured",{image:q.blob,side:_,photo:pe(i),documentType:e.documentType,...e.issuer!==void 0?{issuer:e.issuer}:{},width:q.width,height:q.height,previewDataUrl:C}),t.deferRead!==!0&&E({type:"readOk",side:Z})}catch(q){E({type:"readFailed",side:Z,id:i,issue:"technical"}),W(),r.emit("error",ge("generic",!0,{phase:"keyframes",name:ze(q)}))}ie(Z==="recto"?"verso":"recto")},"jt"),Et=a(i=>{R.push(i.on("statechange",({state:n})=>{n==="preflight"||n==="acquiring"?re("starting"):n==="positioning"?re("scanning"):n==="captured"?re("captured"):n==="error"&&re("error")}),i.on("feedback",({key:n,reticle:v})=>r.emit("feedback",{key:n,reticle:v})),i.on("checks",n=>{r.emit("gate",{progress:n.p,quad:n.quad,frameWidth:n.frameWidth,frameHeight:n.frameHeight,...n.guide!==void 0?{guide:{detected:n.guide.detected,fill:n.guide.fill,offsetX:n.guide.offsetX??0,offsetY:n.guide.offsetY??0}}:{}});let v=n.ocr?.mrz;v!==void 0&&(v.state==="fallback"?te({state:"fallback",reason:v.reason}):v.state==="valid"?te({state:"valid",format:v.format}):v.state==="expired"?te({state:"expired",format:v.format}):v.state==="reading"?te({state:"reading",...v.format?{format:v.format}:{},...v.coach?{coach:v.coach}:{}}):te({state:"searching"}));let C=n.quad===null?0:Tr(n.quad,n.frameWidth,n.frameHeight);w=n.quad===null?null:{quad:n.quad,frameWidth:n.frameWidth,frameHeight:n.frameHeight},E({type:"report",report:{present:n.quad!==null&&n.plausible||n.guide?.detected===!0,ready:n.ready===!0,locking:n.ready===!0||n.locking===!0,areaFrac:C,...n.side!==void 0?{side:n.side}:{},...n.guide?.still!==void 0?{steady:n.guide.detected&&n.guide.still}:{},...n.dark===!0?{dark:!0}:{},...n.glareZone!==void 0&&n.glareZone!=="none"?{glare:!0}:{}},at:c()})}),i.on("error",({kind:n,retryable:v,detail:C})=>r.emit("error",ge(n,v,C))),i.on("artifacts",n=>{zt(n.keyframe,n.previewDataUrl,n.docRegion,n.liveMrz)}))},"Qt"),Ce=a(()=>(F??(F=(async()=>{if(m){if(_e(),y===null){let i;try{i=await(t.createEngine??xr)({...t.engineOptions??{},...b!==void 0?{guide:b}:{},video:e.video,format:f.format,side:p?"single":e.side??"recto",autoCapture:!1,zones:Ge(p?"single":e.side??"recto"),...he!==null?{ocr:he}:{},...k!==void 0&&!p&&f.mrzSide==="verso"?{sideProbe:!0}:{}})}catch(v){re("error"),r.emit("error",ge("models",!0,{phase:"models",name:ze(v)}));return}if(!m){i.destroy();return}y=i,l.start(p?"singlePage":"twoSided",e.side),g="base",x=p?"single":e.side??"recto",Et(i),H()&&P("second");let n=t.tickMs??500;n>0&&(h=setInterval(()=>E({type:"tick",at:c()}),n))}E({type:"clockRestart"}),U!==null&&U.liveMrzOn&&(V==="unsupported"||V==="off")&&te({state:"fallback",reason:V}),await y.start()}})().finally(()=>{F=null})),F),"Ce");return{handle:{get state(){return z},on:a((i,n)=>r.on(i,n),"on"),start:Ce,retry:a(()=>{if(y===null&&d.phase==="result"){E({type:"retake"}),A=0,N=0,Ce();return}if(y!==null&&z!=="error"){E({type:"retake"}),A=0,N=0,P("base"),x=p?"single":e.side??"recto",y.rearm(x);return}Ce()},"retry"),setSide:a(i=>{p||i==="single"||y!==null&&d.current===i&&x===i&&d.phase!=="reading"&&d.phase!=="result"||(d.current!==i&&(d={...d,current:i}),E({type:"clockRestart"}),d.phase!=="reading"&&d.phase!=="result"&&y!==null&&(x=i,y.rearm(i)))},"setSide"),shutter:Xe,focusAt:a((i,n)=>{y?.focusAt?.(i,n)},"focusAt"),setGuide:a(i=>{b=i,y?.setGuide?.(i)},"setGuide"),setTorch:a(i=>{D=i,y?.setTorch(i),E({type:"tick",at:c()})},"setTorch"),destroy:a(()=>{if(m&&l.end(z==="done"?"done":"abandoned"),m&&y!==null&&z!=="done"){let i=$e();!xe&&i!==void 0&&i.ticks>0&&Je(i,"abandoned"),Ze(i,void 0)}m=!1,Ye(),he?.setEngine(null),ee?.dispose(),ee=null,r.clear()},"destroy")},plan:f,setFlowState:a(i=>{(d.phase==="reading"||d.phase==="result")&&re(i==="done"&&d.phase!=="result"?"scanning":i)},"setFlowState"),settle:a((i,n,v)=>{let C=i==="verso"?"verso":"recto",M=v!==void 0?fe.get(v.image):d.unsure;if(M!==void 0&&d.captured.recto!==M&&d.captured.verso!==M&&!d.pending.includes(M))return;if(M!==void 0&&Se.add(M),l.settle(M!==void 0?G(M):void 0,p?"single":C,n),n.ok){let L=p?C:n.heldAs??C,I=d.phase;M!==void 0&&!p&&E({type:"held",id:M,side:L}),n.held!==void 0&&!p&&E({type:"serverHeld",sides:n.held,answered:[...Se]}),(p||n.held===void 0||n.held.includes(L))&&E({type:"readOk",side:L}),(I==="reading"||I==="result")&&d.phase!=="reading"&&d.phase!=="result"&&(W(),ie(d.current??(L==="recto"?"verso":"recto")));return}let B=d;E({type:"readFailed",side:C,...M!==void 0?{id:M}:{},issue:n.issue}),d!==B&&(W(),ie(C))},"settle"),takeDeviceRead:a(i=>Ve.get(i.image)?.value??null,"takeDeviceRead"),shotFacts:a(i=>Ie.get(i.image)??null,"shotFacts"),traceAnswer:a((i,n,v,C)=>l.answer(G(fe.get(i.image)),n,v,C),"traceAnswer"),serverHeld:a(i=>{if(p)return;let n=d.phase;E({type:"serverHeld",sides:i,answered:[...Se]}),(n==="reading"||n==="result")&&d.phase!=="reading"&&d.phase!=="result"&&(W(),ie(d.current??"recto"))},"serverHeld"),dropped:a(i=>{let n=fe.get(i.image);return n!==void 0&&!p&&d.captured.recto!==n&&d.captured.verso!==n&&!d.pending.includes(n)},"dropped")}}a(Pr,"En");export{Mr as a,Sr as b,kr as c,Ar as d,Wr as e,qr as f,Pr as g};
@@ -1 +1 @@
1
- import{a as g}from"./chunk-R3JHFC62.js";import{K as b,a as k,b as y,c as x}from"./chunk-KU3B6BDD.js";import{a as n}from"./chunk-5QL6W6FW.js";import{a as c,c as f}from"./chunk-4FHWXBOB.js";var l=f(k(),1),t=f(k(),1),w=f(k(),1),r=f(y(),1),e=f(y(),1);var i,C=(i=class extends w.Component{constructor(){super(...arguments),this.state={failed:!1}}static getDerivedStateFromError(){return{failed:!0}}render(){return this.state.failed?this.props.fallback:this.props.children}},c(i,"c"),i);n(C,"LoadBoundary");var j=C,F={load:n(()=>import("./flow-views-PX5YBDQG-CF4UQQOQ.js"),"load")};function S({view:s,i18n:a,quiet:o,...m}){let[d,h]=(0,t.useState)(0),u=(0,t.useMemo)(()=>(0,t.lazy)(()=>F.load().then(v=>({default:v[s]}))),[s,d]),p=(0,r.jsxs)(b,{tone:"danger",children:[(0,r.jsx)("span",{children:a.t("errors.network_error")}),(0,r.jsx)(x,{kind:"secondary",onClick:c(()=>h(v=>v+1),"onClick"),children:a.t("common.retry")})]});return(0,r.jsx)(j,{fallback:p,children:(0,r.jsx)(t.Suspense,{fallback:o===!0?null:(0,r.jsx)("p",{role:"status","aria-busy":"true",className:"sekyro-text-muted",children:a.t("common.loading")}),children:(0,r.jsx)(u,{...m,i18n:a})})},d)}c(S,"k");n(S,"Flow");var B=(0,l.createContext)(void 0);function H({i18n:s,lead:a,refresh:o,actions:m}){let d=(0,l.useContext)(B),[h,u]=(0,l.useState)(!1);if(d!==void 0)return(0,e.jsx)(S,{view:"HandoffView",i18n:s,url:d,lead:a,...o!==void 0?{refresh:o}:{},footer:m});let p=n(()=>{o!==void 0&&(u(!0),o().catch(()=>{}).finally(()=>u(!1)))},"again");return(0,e.jsx)(g,{tone:"brand",icon:"smartphone",title:s.t("handoff.title"),testId:"sekyro-phone-handoff",actions:(0,e.jsxs)(e.Fragment,{children:[m,o!==void 0?(0,e.jsx)(x,{kind:"secondary",full:!0,disabled:h,onClick:p,children:s.t("common.refresh")}):null]}),children:(0,e.jsx)("p",{children:a})})}c(H,"K");n(H,"PhoneHandoff");export{j as a,S as b,B as c,H as d};
1
+ import{a as g}from"./chunk-IVTMNMUT.js";import{K as b,a as k,b as y,c as x}from"./chunk-LPLPMWHJ.js";import{a as n}from"./chunk-5QL6W6FW.js";import{a as c,c as f}from"./chunk-4FHWXBOB.js";var l=f(k(),1),t=f(k(),1),w=f(k(),1),r=f(y(),1),e=f(y(),1);var i,C=(i=class extends w.Component{constructor(){super(...arguments),this.state={failed:!1}}static getDerivedStateFromError(){return{failed:!0}}render(){return this.state.failed?this.props.fallback:this.props.children}},c(i,"c"),i);n(C,"LoadBoundary");var j=C,F={load:n(()=>import("./flow-views-6TVHTMMX-6QNRGOHC.js"),"load")};function S({view:s,i18n:a,quiet:o,...m}){let[d,h]=(0,t.useState)(0),u=(0,t.useMemo)(()=>(0,t.lazy)(()=>F.load().then(v=>({default:v[s]}))),[s,d]),p=(0,r.jsxs)(b,{tone:"danger",children:[(0,r.jsx)("span",{children:a.t("errors.network_error")}),(0,r.jsx)(x,{kind:"secondary",onClick:c(()=>h(v=>v+1),"onClick"),children:a.t("common.retry")})]});return(0,r.jsx)(j,{fallback:p,children:(0,r.jsx)(t.Suspense,{fallback:o===!0?null:(0,r.jsx)("p",{role:"status","aria-busy":"true",className:"sekyro-text-muted",children:a.t("common.loading")}),children:(0,r.jsx)(u,{...m,i18n:a})})},d)}c(S,"k");n(S,"Flow");var B=(0,l.createContext)(void 0);function H({i18n:s,lead:a,refresh:o,actions:m}){let d=(0,l.useContext)(B),[h,u]=(0,l.useState)(!1);if(d!==void 0)return(0,e.jsx)(S,{view:"HandoffView",i18n:s,url:d,lead:a,...o!==void 0?{refresh:o}:{},footer:m});let p=n(()=>{o!==void 0&&(u(!0),o().catch(()=>{}).finally(()=>u(!1)))},"again");return(0,e.jsx)(g,{tone:"brand",icon:"smartphone",title:s.t("handoff.title"),testId:"sekyro-phone-handoff",actions:(0,e.jsxs)(e.Fragment,{children:[m,o!==void 0?(0,e.jsx)(x,{kind:"secondary",full:!0,disabled:h,onClick:p,children:s.t("common.refresh")}):null]}),children:(0,e.jsx)("p",{children:a})})}c(H,"K");n(H,"PhoneHandoff");export{j as a,S as b,B as c,H as d};
@@ -1 +1 @@
1
- import{b,c as t,v as s,w as i,y as l}from"./chunk-KU3B6BDD.js";import{a as r}from"./chunk-5QL6W6FW.js";import{a as o,c as k}from"./chunk-4FHWXBOB.js";var a=k(b(),1);function x({title:n,lead:d,cameraLabel:c,uploadLabel:m,notice:p,testId:e,onCamera:h,onUpload:u,onPhone:f=!1}){return(0,a.jsxs)("section",{className:"sekyro-step","data-testid":e,children:[(0,a.jsx)(i,{title:n,lead:d}),p,(0,a.jsxs)(l,{children:[(0,a.jsxs)(t,{full:!0,onClick:h,"data-testid":`${e}-camera`,children:[(0,a.jsx)(s,{name:f?"smartphone":"camera"}),c]}),(0,a.jsx)(t,{full:!0,kind:"ghost",onClick:u,"data-testid":`${e}-upload`,children:m})]})]})}o(x,"k");r(x,"PhotoSourceView");export{x as a};
1
+ import{b,c as t,v as s,w as i,y as l}from"./chunk-LPLPMWHJ.js";import{a as r}from"./chunk-5QL6W6FW.js";import{a as o,c as k}from"./chunk-4FHWXBOB.js";var a=k(b(),1);function x({title:n,lead:d,cameraLabel:c,uploadLabel:m,notice:p,testId:e,onCamera:h,onUpload:u,onPhone:f=!1}){return(0,a.jsxs)("section",{className:"sekyro-step","data-testid":e,children:[(0,a.jsx)(i,{title:n,lead:d}),p,(0,a.jsxs)(l,{children:[(0,a.jsxs)(t,{full:!0,onClick:h,"data-testid":`${e}-camera`,children:[(0,a.jsx)(s,{name:f?"smartphone":"camera"}),c]}),(0,a.jsx)(t,{full:!0,kind:"ghost",onClick:u,"data-testid":`${e}-upload`,children:m})]})]})}o(x,"k");r(x,"PhotoSourceView");export{x as a};
@@ -1 +1 @@
1
- import{a as d}from"./chunk-KU3B6BDD.js";import{a as t}from"./chunk-5QL6W6FW.js";import{a as i,c as r}from"./chunk-4FHWXBOB.js";var s=r(d(),1);var u=(0,s.createContext)(null);function c(a,n,o){let e=n.detail;return{check:a,kind:n.kind,...e?.name!==void 0?{name:e.name}:{},...e?.phase!==void 0?{phase:e.phase}:{},...e?.engineKind!==void 0?{engineKind:e.engineKind}:{},attempt:Math.max(0,Math.min(1e3,o))}}i(c,"a");t(c,"captureIssueOf");function m(a,n){if(a!==void 0)try{a(n)}catch{}}i(m,"o");t(m,"sendCaptureIssue");export{u as a,c as b,m as c};
1
+ import{a as d}from"./chunk-LPLPMWHJ.js";import{a as t}from"./chunk-5QL6W6FW.js";import{a as i,c as r}from"./chunk-4FHWXBOB.js";var s=r(d(),1);var u=(0,s.createContext)(null);function c(a,n,o){let e=n.detail;return{check:a,kind:n.kind,...e?.name!==void 0?{name:e.name}:{},...e?.phase!==void 0?{phase:e.phase}:{},...e?.engineKind!==void 0?{engineKind:e.engineKind}:{},attempt:Math.max(0,Math.min(1e3,o))}}i(c,"a");t(c,"captureIssueOf");function m(a,n){if(a!==void 0)try{a(n)}catch{}}i(m,"o");t(m,"sendCaptureIssue");export{u as a,c as b,m as c};
@@ -1 +1 @@
1
- import{d as Re,e as Xe,f as Ze,g as Ve}from"./chunk-32LRPMCN.js";import{a as le,b as je,c as ce,d as $e}from"./chunk-P7K7ELYZ.js";import{a as Se,b as Q,c as Ae,d as Ie,e as Ce,h as Oe,i as ne,j as Pe,k as Ge,l as He,m as Ke}from"./chunk-6MYG4HWP.js";import{a as Ue,b as Fe,c as Ne,d as Le,e as Be,f as oe,g as j,h as qe,i as We,j as ze}from"./chunk-JS2IXPNL.js";import{b as xe,c as De}from"./chunk-SLLJX5QK.js";import{a as o}from"./chunk-4FHWXBOB.js";var Tt=["magenta","yellow","green","blue"],_t={magenta:"rgb(255, 72, 150)",yellow:"rgb(255, 190, 0)",green:"rgb(0, 238, 175)",blue:"rgb(25, 150, 255)",dark:"rgb(0, 0, 0)"};function zi(i){return _t[i]}o(zi,"P");var Et=4,St=4,J=o(i=>typeof i=="number"&&Number.isFinite(i),"R");function ee(i){if(typeof i!="object"||i===null)return!1;let e=i;if(typeof e.nonce!="string"||e.nonce.length===0||!Array.isArray(e.colours)||e.colours.length<1||e.colours.length>8||!e.colours.every(r=>Tt.includes(r))||!Array.isArray(e.onsetsMs)||e.onsetsMs.length!==e.colours.length)return!1;let t=-1;for(let r of e.onsetsMs){if(!J(r)||r<0||r<=t)return!1;t=r}return!(!J(e.holdMs)||e.holdMs<=0||!J(e.endMs)||e.endMs<=t||!J(e.clipMs)||e.clipMs<e.endMs||e.clipMs>8e3)}o(ee,"_");function Ye(i,e){return ee(i)?Math.max(e,Math.ceil(i.clipMs)):e}o(Ye,"O");function Qe(i,e){let t=e.now??(()=>performance.now()),r=ee(i)?i:void 0,s=[],a=null,n=null,l=null,c=!1,h=null,d=o(p=>{h=p;try{e.paint(p)}catch{}},"s"),u=o(p=>{let v=e.frames?.()??null;return v!==null&&l!==null?v.mediaTimeMs+(p-v.presentationTimeMs)-l:p-(n??p)},"p"),m=o((p,v,y=0)=>{if(c)return;let g=Math.max(0,p-u(t()));a=setTimeout(()=>{if(a=null,!c){if(y<Et&&u(t())<p-St){m(p,v,y+1);return}v()}},g)},"f"),w=o(p=>{if(r===void 0)return;let v=r.endMs;if(p>=r.colours.length){m(v,()=>d(null));return}let y=r.onsetsMs[p],g=p+1<r.onsetsMs.length?r.onsetsMs[p+1]:v;m(y,()=>{let M=u(t());if(M>v){h!==null&&d(null);return}let E=r.colours[p];d(E);let A=s.length===0?0:s[s.length-1].tMs;s.push({tMs:Math.max(A,Math.round(M)),colour:E});let I=y+r.holdMs;if(I<g){m(I,()=>{if(u(t())>v){h!==null&&d(null);return}d("dark"),w(p+1)});return}w(p+1)})},"S");return{started(p){if(r===void 0||c||n!==null)return;n=p;let v=e.frames?.()??null;l=v===null?null:v.mediaTimeMs+(p-v.presentationTimeMs),w(0)},stop(){c||(c=!0,a!==null&&clearTimeout(a),a=null,h!==null&&d(null))},report(){return r===void 0?void 0:{nonce:r.nonce,rendered:[...s]}}}}o(Qe,"w");var At=1e4,O,It=(O=class{constructor(e,t){this.tier="blaze",this.inner=e,t!==void 0&&(this.fallbackReason=t)}static async create(e,t){let r=await import("./vision_bundle-WBHR7TEE.js"),s=await r.FilesetResolver.forVisionTasks(e),a=await r.FaceDetector.createFromOptions(s,{baseOptions:{modelAssetPath:`${e}/blaze_face_short_range.tflite`,delegate:"CPU"},runningMode:"IMAGE"});return new O(a,t)}async detect(e,t,r){let s;try{s=this.inner.detect(e).detections}catch{return null}let a=xt(s);if(a?.boundingBox===void 0)return null;let n=te(e),l=Dt(a.keypoints,n),c=a.keypoints?.[2],h={box:{x:a.boundingBox.originX,y:a.boundingBox.originY,width:a.boundingBox.width,height:a.boundingBox.height},...l!==void 0?{eyes:l}:{},...c!==void 0?{nose:{x:c.x*n.width,y:c.y*n.height}}:{},score:a.categories[0]?.score??0,extraFaces:Je(s.map(d=>d.boundingBox??{width:0,height:0}),s.indexOf(a))};return et(h,e,t,r)}destroy(){try{this.inner.close()}catch{}}},o(O,"t"),O);function xt(i){let e,t=-1;for(let r of i){let s=r.categories[0]?.score??0;s>t&&(e=r,t=s)}return e}o(xt,"R");function Dt(i,e){let t=i?.[0],r=i?.[1];if(t===void 0||r===void 0)return;let s=o(l=>({x:l.x*e.width,y:l.y*e.height}),"n"),[a,n]=[s(t),s(r)];return a.x<=n.x?{left:a,right:n}:{left:n,right:a}}o(Dt,"T");function Rt(){if(typeof OffscreenCanvas=="function")return new OffscreenCanvas(2,2);let i=document.createElement("canvas");return i.width=2,i.height=2,i}o(Rt,"E");var Ct=4;async function Ot(){let i=globalThis.FaceDetector;if(typeof i!="function")return{ok:!1,reason:"unsupported"};try{let e=new i({fastMode:!0,maxDetectedFaces:Ct});return await e.detect(Rt()),{ok:!0,instance:e}}catch(e){return{ok:!1,reason:`smoke_failed:${e instanceof Error?e.message:String(e)}`}}}o(Ot,"w");var U,Pt=(U=class{constructor(e,t){this.tier="native",this.inner=e,t!==void 0&&(this.fallbackReason=t)}async detect(e,t,r){let s;try{s=await this.inner.detect(e)}catch{return null}let a=s.map(d=>d.boundingBox),n=-1;a.forEach((d,u)=>{let m=a[n];(m===void 0||d.width*d.height>m.width*m.height)&&(n=u)});let l=s[n];if(l===void 0)return null;let c=Gt(l.landmarks),h={box:{x:l.boundingBox.x,y:l.boundingBox.y,width:l.boundingBox.width,height:l.boundingBox.height},...c!==void 0?{eyes:c}:{},score:1,extraFaces:Je(a,n)};return et(h,e,t,r)}destroy(){}},o(U,"b"),U);function Gt(i){if(i===void 0)return;let e=i.filter(s=>s.type==="eye").map(s=>s.locations[0]).filter(s=>s!==void 0),[t,r]=e;if(!(t===void 0||r===void 0))return t.x<=r.x?{left:t,right:r}:{left:r,right:t}}o(Gt,"S");var Ut=.25;function Je(i,e){let t=i[e],r=t===void 0?0:t.width*t.height;if(!(r>0))return 0;let s=0;return i.forEach((a,n)=>{n!==e&&a.width*a.height>=Ut*r&&(s+=1)}),s}o(Je,"f");var ue="/models-v3",Ft=["native","blaze"],F,de=(F=class extends Error{constructor(e){super(`no detector tier available (${e})`),this.name="DetectorLadderError",this.fallbackReason=e}},o(F,"x"),F);function te(i){let e=i;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 t=typeof e.width=="number"?e.width:0,r=typeof e.height=="number"?e.height:0;return{width:t,height:r}}o(te,"y");function et(i,e,t,r){let s=te(e),a=s.width>0?t/s.width:1,n=s.height>0?r/s.height:1,l=o(c=>({x:c.x*a,y:c.y*n}),"s");return{box:{x:i.box.x*a,y:i.box.y*n,width:i.box.width*a,height:i.box.height*n},...i.eyes!==void 0?{eyes:{left:l(i.eyes.left),right:l(i.eyes.right)}}:{},...i.nose!==void 0?{nose:l(i.nose)}:{},score:i.score,...i.extraFaces!==void 0?{extraFaces:i.extraFaces}:{}}}o(et,"h");function Nt(i){return i instanceof Error?i.message:String(i)}o(Nt,"C");async function x(i){let e=i.preferred??Ft,t=[];for(let r of e){if(r==="native"){let s=await Ot();if(s.ok)return new Pt(s.instance,he(t));t.push(`native:${s.reason}`);continue}try{return await Lt(It.create(i.v3AssetBaseUrl??ue,he(t)),i.blazeInitTimeoutMs??At)}catch(s){t.push(s instanceof tt?"blaze:blaze_init_timeout":`blaze:${Nt(s)}`)}}throw new de(he(t)??"no_tier_available")}o(x,"O");function he(i){return i.length>0?i.join("; "):void 0}o(he,"v");var N,tt=(N=class extends Error{},o(N,"g"),N);function Lt(i,e){return new Promise((t,r)=>{let s=setTimeout(()=>{r(new tt(`init exceeded ${e}ms`)),i.then(a=>a.destroy(),()=>{})},e);i.then(a=>{clearTimeout(s),t(a)},a=>{clearTimeout(s),r(a)})})}o(Lt,"W");var C=1;function it(){return typeof OffscreenCanvas=="function"&&typeof createImageBitmap=="function"&&typeof Worker=="function"}o(it,"K");function Bt(i,e={}){let t=e.createDetector??x,r=null;i.onmessage=s=>{let a=s.data;if(a.v!==C){a.bitmap?.close?.();return}if(a.type==="init"){t(a.options).then(n=>{r=n;let l={v:C,type:"ready",tier:n.tier,...n.fallbackReason!==void 0?{fallbackReason:n.fallbackReason}:{}};i.postMessage(l)});return}if(a.type==="detect"){let n=o(l=>{let c={v:C,type:"result",id:a.id,observation:l};i.postMessage(c),a.bitmap.close?.()},"a");if(r===null){n(null);return}r.detect(a.bitmap,a.streamWidth,a.streamHeight).then(n,()=>n(null))}}}o(Bt,"B");typeof self<"u"&&typeof self.importScripts=="function"&&Bt(self);var P,rt=(P=class{constructor(e,t){this.pending=new Map,this.nextId=1,this.worker=e,this.tier=t.tier,t.fallbackReason!==void 0&&(this.fallbackReason=t.fallbackReason),e.addEventListener("message",r=>{let s=r.data;if(s.v!==C||s.type!=="result")return;let a=this.pending.get(s.id);this.pending.delete(s.id),a?.(s.observation)})}static create(e,t,r=1e4){return new Promise((s,a)=>{let n=setTimeout(()=>{e.removeEventListener("message",l),e.terminate(),a(new Error(`worker detector not ready within ${r}ms`))},r),l=o(h=>{let d=h.data;d.v!==C||d.type!=="ready"||(clearTimeout(n),e.removeEventListener("message",l),s(new P(e,d)))},"s");e.addEventListener("message",l);let c={v:C,type:"init",options:t};e.postMessage(c)})}async detect(e,t,r){let s;try{typeof ImageBitmap<"u"&&e instanceof ImageBitmap?s=e:typeof createImageBitmap=="function"?s=await createImageBitmap(e):s=e}catch{return null}let a=this.nextId;return this.nextId+=1,new Promise(n=>{this.pending.set(a,n);let l={v:C,type:"detect",id:a,bitmap:s,streamWidth:t,streamHeight:r};this.worker.postMessage(l,[s])})}destroy(){for(let e of this.pending.values())e(null);this.pending.clear(),this.worker.terminate()}},o(P,"t"),P);var qt=[...Ue.filter(i=>i.startsWith("video/mp4")),"video/webm;codecs=h264","video/webm;codecs=avc1","video/webm;codecs=vp8","video/webm;codecs=vp9","video/webm"],dt=new Set;function Wt(i){let e=/(?:Chrome|Chromium)\/(\d+)\./.exec(i??"");return e?Number(e[1]):null}o(Wt,"Pe");function zt(i=Kt(),e=globalThis.navigator?.userAgent){if(i===void 0)return"";let t=Wt(e)===126;for(let r of qt)if(!(dt.has(r)||t&&r.startsWith("video/mp4")))try{if(i(r))return r}catch{}return""}o(zt,"be");function st(i){i!==""&&dt.add(i)}o(st,"L");function Ht(i){return i.replace(/^video\/x-matroska/i,"video/webm")}o(Ht,"ye");function ft(i){let e=/codecs=["']?([^,;"']+)/i.exec(i);return e?e[1].trim():i.split(";")[0].trim()}o(ft,"lt");function Kt(){let i=globalThis.MediaRecorder;return i&&typeof i.isTypeSupported=="function"?e=>i.isTypeSupported(e):void 0}o(Kt,"xe");var pt=2500,Xt=1e3,Zt=1500,at=25e5,Vt=100,jt=700,$t=20,Yt=1500,ie=null;function Qt(){return ie??(ie=import("./clip-inspect-DLJXVKV6-TNHTD4LV.js").catch(i=>{throw ie=null,i})),ie.catch(()=>null)}o(Qt,"He");var B,D=(B=class extends Error{constructor(e,t){super(t??e),this.kind=e}},o(B,"T"),B),Jt=100;function nt(i,e){return i.stats===void 0?!1:i.stats===null?!0:i.stats.durationMs<e-Jt}o(nt,"N");function ei(i,e){return i.stats?e.stats?i.stats.durationMs>e.stats.durationMs:!0:!1}o(ei,"Ee");var q,ti=(q=class{constructor(e={}){this.recorder=null,this.stream=null,this.chunks=[],this.bytes=0,this.hardStopTimer=null,this.graceTimer=null,this.pollTimer=null,this.settled=!1,this.now=e.now??(()=>globalThis.performance?.now?.()??Date.now())}clearTimers(){this.hardStopTimer&&clearTimeout(this.hardStopTimer),this.graceTimer&&clearTimeout(this.graceTimer),this.pollTimer&&clearInterval(this.pollTimer),this.hardStopTimer=null,this.graceTimer=null,this.pollTimer=null}record(e,t,r,s=pt,a){let n=zt(),l=Qt();return this.recordRaw(e,t,r,s,a,n).then(c=>ii(c,l),c=>{throw c instanceof D&&(c.requestedMimeType=n),c})}recordRaw(e,t,r,s,a,n){return this.recorder&&!this.settled?Promise.reject(new D("generic","record() called while a recording is in flight — 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((l,c)=>{let h;try{h=new MediaRecorder(e,n?{mimeType:n,videoBitsPerSecond:at}:{videoBitsPerSecond:at})}catch{try{h=new MediaRecorder(e)}catch{c(new D("unsupported"));return}}this.recorder=h;let d=o(g=>{this.settled||(this.settled=!0,this.clearTimers(),g())},"d"),u=o(()=>d(()=>{let g=Ht(h.mimeType||n||Fe),M=new Blob(this.chunks,{type:g});if(M.size===0){c(new D("generic","empty clip"));return}if(oe(M)){c(new D("cliptoolarge"));return}l({blob:M,mimeType:g,requestedMimeType:n})}),"u");h.ondataavailable=g=>{g.data&&g.data.size&&(this.chunks.push(g.data),this.bytes+=g.data.size,this.bytes>Be&&d(()=>{try{h.state!=="inactive"&&h.stop()}catch{}c(new D("cliptoolarge"))}))},h.onstop=u,h.onerror=()=>d(()=>c(new D("generic")));let m=this.now();if(r!==void 0||a!==void 0){let g=!1;h.onstart=()=>{if(!(g||this.settled)&&(g=!0,m=this.now(),r!==void 0))try{r()}catch{}}}try{h.start(Xt)}catch{d(()=>c(new D("generic")));return}let w=o(()=>{if(this.pollTimer&&clearInterval(this.pollTimer),this.pollTimer=null,this.hardStopTimer&&clearTimeout(this.hardStopTimer),this.hardStopTimer=null,this.settled||t?.(),h.state!=="inactive"){try{h.stop()}catch{u()}this.graceTimer=setTimeout(u,Zt)}else u()},"m"),p=this.now();if(a===void 0){this.hardStopTimer=setTimeout(w,s);return}let v=null,y=!1;this.hardStopTimer=setTimeout(w,s+jt),this.pollTimer=setInterval(()=>{if(this.settled||y)return;let g=null;try{g=a.latest()}catch{g=null}let M=g?.presentationTimeMs;M!==void 0&&Number.isFinite(M)&&M>=m&&v===null&&(v=M);let E=v!==null&&M!==void 0&&M-v>=s,A=v===null&&this.now()-p>=s;if(!(!E&&!A)){if(y=!0,this.pollTimer&&clearInterval(this.pollTimer),this.pollTimer=null,A){w();return}this.hardStopTimer&&clearTimeout(this.hardStopTimer),this.hardStopTimer=setTimeout(w,Vt)}},$t)}))}stop(e){this.clearTimers();let t=this.recorder;if(t&&t.state!=="inactive")try{t.stop()}catch{}this.recorder=null,(e??this.stream)?.getTracks().forEach(r=>r.stop()),this.stream=null}},o(q,"A"),q);async function ii(i,e){let t,r=new Promise(h=>{t=setTimeout(()=>h(null),Yt)}),s=await Promise.race([e,r]);if(clearTimeout(t),s===null)return i;let a;try{a=await s.blobBytes(i.blob)}catch{return{...i,stats:null}}let n=s.inspectClipBytes(a);if(n?.container!=="webm")return{...i,stats:n};let l=s.withWebmDuration(a,n.durationMs);if(l===null)return{...i,stats:n};let c=s.inspectClipBytes(l);return c===null||c.frames!==n.frames||c.durationMs!==n.durationMs?{...i,stats:n}:{...i,blob:new Blob([l],{type:i.blob.type}),stats:n}}o(ii,"Be");function ri(i,e,t=.92){return new Promise((r,s)=>{let a=i.videoWidth,n=i.videoHeight;if(!a||!n){s(new Error("video-not-ready"));return}let l=e.getContext("2d");if(!l){s(new Error("no-2d-context"));return}e.width=a,e.height=n,l.scale(-1,1),l.drawImage(i,-a,0),e.toBlob(c=>c?r(c):s(new Error("empty-keyframe")),"image/jpeg",t)})}o(ri,"Me");var W,si=(W=class{constructor(e){this.timer=null,this.frameCallbackId=null,this.running=!1,this.busy=!1,this.lastRunAt=Number.NEGATIVE_INFINITY,this.degradeCount=0,this.durations=[],this.options=e,this.periodMs=1e3/e.cadenceHz}start(){if(this.running)return;this.running=!0;let e=this.options.video;if(typeof e?.requestVideoFrameCallback=="function"){let t=o(()=>{this.running&&(this.frameCallbackId=e.requestVideoFrameCallback?.(()=>{this.frameCallbackId=null,this.now()-this.lastRunAt>=this.periodMs&&this.tick(),t()}))},"t");t();return}this.timer=setInterval(()=>this.tick(),this.periodMs)}stop(){this.running=!1,this.timer!==null&&(clearInterval(this.timer),this.timer=null),this.frameCallbackId!==null&&(this.options.video?.cancelVideoFrameCallback?.(this.frameCallbackId),this.frameCallbackId=null)}stats(){let e=this.durations.length===0?0:this.durations.reduce((t,r)=>t+r,0)/this.durations.length;return{degradeCount:this.degradeCount,meanDetectMs:e}}now(){return this.options.now?.()??performance.now()}tick(){if(!this.running)return;if(this.busy){this.degradeCount+=1;return}this.busy=!0,this.lastRunAt=this.now();let e=this.now();this.options.run().catch(()=>{}).finally(()=>{this.busy=!1,this.durations.push(this.now()-e),this.durations.length>20&&this.durations.shift()})}},o(W,"D"),W),ai=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}),L=o(i=>Math.min(1,Math.max(0,i)),"C"),z,ot=(z=class{constructor(e={}){this.p=0,this.lastTickAt=null,this.lastCenter=null,this.velocityEma=0,this.qWindow=[],this.lastSizeDirection="ideal",this.t={...ai,...e}}reset(){this.p=0,this.lastTickAt=null,this.lastCenter=null,this.velocityEma=0,this.qWindow=[],this.lastSizeDirection="ideal"}tick(e){let{observation:t,quality:r,timestampMs:s}=e,a=this.lastTickAt===null?0:Math.max(0,(s-this.lastTickAt)/1e3);this.lastTickAt=s;let n={presence:0,single:1,centering:0,size:0,pose:0,sharpness:L(r.sharpness),exposure:L(r.exposure),motion:1};if(t!==null){n.presence=1,n.single=(t.extraFaces??0)>0?0:1;let d=this.geometryOf(t,e);n.centering=d.centering,n.size=d.size,n.pose=d.pose,n.motion=this.motionOf(d.center,d.iod,s)}else this.lastCenter=null,this.velocityEma=0;let l=Math.min(n.presence,n.single,n.centering,n.size,n.pose,n.sharpness,n.exposure,n.motion);this.p=L(this.p+(l>=this.t.Q_GOOD?this.t.RISE_PER_S*l:-this.t.FALL_PER_S*(1-l))*a),this.qWindow.push({at:s,q:l}),this.qWindow=this.qWindow.filter(d=>d.at>=s-this.t.READY_WINDOW_MS);let c=this.qWindow.map(d=>d.q);if(c.length>=3){let d=Math.min(...c),u=c.indexOf(d);c=c.filter((m,w)=>w!==u)}let h=this.p>=1&&c.every(d=>d>=this.t.Q_GOOD);return{at:s,q:l,p:this.p,factors:n,guidanceKey:this.guidanceOf(n,r,l),ready:h,accepted:l>=this.t.Q_GOOD}}geometryOf(e,t){let{box:r,eyes:s}=e,a={x:t.frameWidth/2,y:t.frameHeight/2},n=Math.min(t.frameWidth,t.frameHeight),l=s!==void 0?{x:(s.left.x+s.right.x)/2,y:(s.left.y+s.right.y)/2}:{x:r.x+r.width/2,y:r.y+r.height/2-this.t.BOX_EYE_OFFSET_FACTOR*r.height},c=s!==void 0?Math.hypot(s.right.x-s.left.x,s.right.y-s.left.y):this.t.IOD_BOX_PROXY_FACTOR*r.width,h=Math.hypot(l.x-a.x,l.y-a.y),d=c<=0?0:1-L(h/(this.t.CENTER_FALLOFF_IOD_MULTIPLE*c)),u=n>0?c/n:0;this.lastSizeDirection=u<this.t.SIZE_IDEAL_MIN?"far":u>this.t.SIZE_IDEAL_MAX?"close":"ideal";let m;u<this.t.SIZE_HARD_MIN||u>this.t.SIZE_HARD_MAX?m=0:u<this.t.SIZE_IDEAL_MIN?m=(u-this.t.SIZE_HARD_MIN)/(this.t.SIZE_IDEAL_MIN-this.t.SIZE_HARD_MIN):u>this.t.SIZE_IDEAL_MAX?m=(this.t.SIZE_HARD_MAX-u)/(this.t.SIZE_HARD_MAX-this.t.SIZE_IDEAL_MAX):m=1;let w=1;if(s!==void 0){let p=Math.abs(Math.atan2(s.right.y-s.left.y,s.right.x-s.left.x))*180/Math.PI;w=1-L(p/this.t.ROLL_MAX_DEG)}return{center:l,iod:c,centering:d,size:m,pose:w}}motionOf(e,t,r){let s=this.lastCenter;if(this.lastCenter={...e,at:r},s===null||t<=0)return 1;let a=(r-s.at)/1e3;if(a<=0)return 1;let n=Math.hypot(e.x-s.x,e.y-s.y)/t/a;n<=this.t.MOTION_DEADBAND_IOD_PER_S&&(n=0);let l=1-Math.exp(-a/this.t.MOTION_TAU_S);return this.velocityEma=l*n+(1-l)*this.velocityEma,1-L(this.velocityEma/this.t.MOTION_VELOCITY_IOD_PER_S)}guidanceOf(e,t,r){if(e.presence<=0)return"fcv3.no_face";if(e.single<=0)return"fcv3.one_face";if(e.size<this.t.GUIDE_SIZE)return this.sizeGuidance();if(e.centering<this.t.GUIDE_CENTERING)return"fcv3.center_face";if(e.pose<this.t.GUIDE_POSE)return"fcv3.straighten";if(e.exposure<this.t.GUIDE_EXPOSURE)return this.exposureGuidance(t);if(e.sharpness<this.t.GUIDE_SHARPNESS)return"fcv3.steady_camera";if(e.motion<this.t.GUIDE_MOTION)return"fcv3.hold_still";if(r<this.t.Q_GOOD){let s=[["size",this.sizeGuidance()],["centering","fcv3.center_face"],["pose","fcv3.straighten"],["exposure",this.exposureGuidance(t)],["sharpness","fcv3.steady_camera"],["motion","fcv3.hold_still"]],a=s[0];for(let n of s)e[n[0]]<e[a[0]]&&(a=n);return a[1]}return"fcv3.hold_still"}sizeGuidance(){return this.lastSizeDirection==="far"?"fcv3.come_closer":"fcv3.move_back"}exposureGuidance(e){let t=(le[0]+le[1])/2;return e.meanLuma<t?"fcv3.more_light":"fcv3.too_bright"}},o(z,"_"),z),ni=["single","size","centering","pose","exposure","sharpness","motion"];function oi(i){if(i.accepted)return null;if(i.factors.presence<=0)return"no_face";let e="single";for(let t of ni)i.factors[t]<i.factors[e]&&(e=t);return e}o(oi,"ze");var H,lt=(H=class{constructor(){this.blocked={},this.acceptedMs=0,this.ticks=0,this.lastAt=null}record(e){let t=this.lastAt===null?0:Math.max(0,e.at-this.lastAt);this.lastAt=e.at,this.ticks+=1;let r=oi(e);if(r===null){this.acceptedMs+=t;return}let s=this.blocked[r]??{count:0,ms:0};s.count+=1,s.ms+=t,this.blocked[r]=s}summary(){let e={};for(let[t,r]of Object.entries(this.blocked))e[t]={count:r.count,ms:Math.round(r.ms)};return{blocked:e,acceptedMs:Math.round(this.acceptedMs),ticks:this.ticks}}},o(H,"w"),H),li=["obs","manycam","virtual","snap camera","xsplit","droidcam","iriun","camo","fake_device","fake-capture-device"],ci=[/^(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 hi(i){let e=(i??"").trim().toLowerCase();return e.length===0?"unknown":li.some(t=>e.includes(t))?"known_virtual":ci.some(t=>t.test(e))?"platform":"unknown"}o(hi,"Qe");function ct(i){if(typeof i!="function")return!1;try{return/\{\s*\[native code\]\s*\}\s*$/.test(Function.prototype.toString.call(i))}catch{return!1}}o(ct,"Ce");function ui(i=globalThis){return ct(i.navigator?.mediaDevices?.getUserMedia)&&ct(i.MediaStreamTrack?.prototype?.getSettings)}o(ui,"Ye");async function di(i,e=globalThis){let t=e.crypto?.subtle?.digest;if(typeof t=="function")try{let r=new Uint8Array(await t.call(e.crypto?.subtle,"SHA-256",new TextEncoder().encode(i)));return Array.from(r.subarray(0,8),s=>s.toString(16).padStart(2,"0")).join("")}catch{return}}o(di,"je");async function fi(i,e=globalThis){let t={};try{t=typeof i.getSettings=="function"?i.getSettings()??{}:{}}catch{t={}}let r={};if((t.facingMode==="user"||t.facingMode==="environment"||t.facingMode==="left"||t.facingMode==="right")&&(r.facingMode=t.facingMode),typeof t.frameRate=="number"&&Number.isFinite(t.frameRate)&&(r.frameRate=t.frameRate),typeof t.width=="number"&&Number.isFinite(t.width)&&(r.width=t.width),typeof t.height=="number"&&Number.isFinite(t.height)&&(r.height=t.height),typeof t.deviceId=="string"&&t.deviceId.length>0){let a=await di(t.deviceId,e);a!==void 0&&(r.deviceIdHash=a)}let s;try{s=i.label}catch{s=void 0}return{trackSettings:r,capabilitiesPresent:typeof i.getCapabilities=="function",labelClass:hi(s),prototypesIntact:ui(e)}}o(fi,"Se");var fe=o(i=>Math.round(i*100)/100,"U");function pi(i){let e=i,t=typeof e?.requestVideoFrameCallback=="function",r=null,s=null,a=0,n=0,l=0,c=0,h=0,d=0,u=o(()=>{!t||e?.requestVideoFrameCallback===void 0||(r=e.requestVideoFrameCallback((m,w)=>{if(r=null,!t)return;let p=w.presentationTime;if(s!==null){let v=p-s.presentationTimeMs;n+=1;let y=v-l;l+=y/n,c+=y*(v-l)}typeof w.captureTime=="number"&&Number.isFinite(w.captureTime)&&(h+=p-w.captureTime,d+=1),a+=1,s={mediaTimeMs:w.mediaTime*1e3,presentationTimeMs:p},u()}))},"u");return u(),{latest:o(()=>s,"latest"),stats:o(()=>({n:a,meanGapMs:n===0?0:fe(l),stdGapMs:n<2?0:fe(Math.sqrt(c/(n-1))),captureLatencyMs:d===0?null:fe(h/d)}),"stats"),stop:o(()=>{t&&(t=!1,r!==null&&e?.cancelVideoFrameCallback?.(r),r=null)},"stop")}}o(pi,"ke");function mi(i,e,t){return{...i,rvfc:e,rampPainter:t}}o(mi,"_e");var gi=1e3,pe="fcv3.hold_upright",vi=200,me=4,yi=600,wi=1e3,ht={sharpness:1,exposure:1,meanLuma:128};function bi(i,e){return e.width=i.videoWidth,e.height=i.videoHeight,e.getContext("2d").drawImage(i,0,0),new Promise((t,r)=>e.toBlob(s=>s?t(s):r(new Error("empty-keyframe")),"image/jpeg",.92))}o(bi,"rt");function Mi(){return Q()==="phone"}o(Mi,"it");var K,mt=(K=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.openEnvironment=null,this.ramp=null,this.snapshotCanvas=null,this.options=e,this.facing=e.facingMode??"user"}get state(){return this.stateValue}on(e,t){let r=this.handlers.get(e);return r||(r=new Set,this.handlers.set(e,r)),r.add(t),()=>r?.delete(t)}emit(e,t){for(let r of[...this.handlers.get(e)??[]])r(t)}async start(e={}){e.facingMode!==void 0&&(this.facing=e.facingMode),this.attempt+=1,await this.run(this.attempt)}get facingMode(){return this.facing}retry(){this.teardownAttempt(),this.start()}switchCamera(){this.facing=this.facing==="user"?"environment":"user",this.teardownAttempt(),this.start()}restart(e){this.facing=e,this.teardownAttempt(),this.start()}destroy(){this.attempt+=1,this.teardownAttempt(),this.detector?.destroy(),this.detector=null,this.options.video.srcObject=null}async run(e){let{options:t}=this;this.fired=!1,this.lastGuidanceKey=null,this.carriedDegrade=0,this.carriedMeans=[],this.cameraRequestedAt=null,this.cameraReadyAt=null,this.faceAcquiredAt=null,this.captureCompleteAt=null,this.uprightGuard=(t.isPhone??Mi)(),this.setState("preflight");let r=Ne();if(r!=="OK"){this.fail(r==="INSECURE_CONTEXT"?"insecure":"unsupported",{phase:"preflight"});return}this.setState("acquiring");let s=t.getUserMedia??(h=>navigator.mediaDevices.getUserMedia(h)),a;this.cameraRequestedAt=this.now();try{let{facingMode:h,...d}=Se(Ae(),this.facing).video;a=await Ke(this.facing,d,{getUserMedia:s,enumerateDevices:_i(t)})}catch(h){if(e!==this.attempt)return;if(h instanceof He){this.fail("backcamera",{phase:"acquiring",name:j(h)});return}this.fail(We(h),{phase:"acquiring",name:j(h)});return}if(Re(a),ze(a),e!==this.attempt){for(let h of a.getTracks())h.stop();return}this.stream=a;let n=a.getVideoTracks?.()[0];if(this.trackProvenance=n===void 0?null:fi(n).catch(()=>null),this.openEnvironment=n===void 0?null:xe(n).catch(()=>({})),this.facing=Ie(a)??this.facing,t.video.srcObject=a,await t.video.play().catch(()=>{}),e!==this.attempt)return;if(this.cameraReadyAt=this.now(),this.detector===null){let h={v3AssetBaseUrl:t.v3AssetBaseUrl},d=t.createDetector??(t.createWorker!==void 0&&it()?async()=>{try{return await rt.create(t.createWorker(),h)}catch{return x(h)}}:()=>x(h)),u;try{u=await d()}catch(m){e===this.attempt&&this.fail("models",{phase:"models",name:j(m)},m instanceof de?m.fallbackReason:Ti(m));return}if(e!==this.attempt){u.destroy();return}this.detector=u,this.options.telemetry?.({type:"detector",tier:u.tier,fallbackReason:u.fallbackReason})}let l=Xe(),c=t.deviceClass??Ze(l);this.profiler=new Ve(c),this.options.telemetry?.({type:"profile",staticClass:c,activeClass:this.profiler.deviceClass,simd:l.simd}),this.gate=new ot(t.thresholds??{}),this.blockStats=new lt,this.lastGateSnapshotAt=this.now(),t.rankKeyframes?.()&&import("./keyframe-rank-YAJLYJYF-WCA6RPMD.js").then(h=>ge=h,()=>{}),this.setState("positioning"),this.positioningStartedAt=this.now(),this.startScheduler(e)}get animations(){return this.profiler?.profile.animations??"full"}startScheduler(e){let t=this.profiler;if(t===null)return;if(this.scheduler!==null){let s=this.scheduler.stats();this.carriedDegrade+=s.degradeCount,s.meanDetectMs>0&&this.carriedMeans.push(s.meanDetectMs),this.scheduler.stop()}let r=new si({cadenceHz:t.profile.cadenceHz,video:this.options.video,now:this.options.now,run:o(()=>this.detectTick(e),"run")});this.scheduler=r,r.start()}async detectTick(e){let{detector:t,gate:r,profiler:s}=this,a=this.options.video;if(e!==this.attempt||t===null||r===null||s===null||this.fired||a.videoWidth===0)return;if(this.isLandscape()){this.holdUpright(e);return}let n=s.deviceClass,l=this.now(),c=this.options.makeSnapshot?.(a,s.profile.inputWidth)??this.defaultSnapshot(a,s.profile.inputWidth),h=null;try{h=await t.detect(c,a.videoWidth,a.videoHeight)}catch{h=null}if(e!==this.attempt||this.fired)return;s.record(this.now()-l),s.deviceClass!==n&&this.startScheduler(e);let d=h===null?ht:this.options.measureQuality?.(a,h.box)??this.defaultQuality(a,h.box),u=r.tick({timestampMs:this.now(),observation:h,quality:d,frameWidth:a.videoWidth,frameHeight:a.videoHeight});u.accepted&&this.faceAcquiredAt===null&&(this.faceAcquiredAt=u.at),this.blockStats?.record(u),!u.ready&&u.at-this.lastGateSnapshotAt>=gi&&(this.lastGateSnapshotAt=u.at,this.reportGate(!1)),this.emit("checks",{engine:"v3",progress:u.p,q:u.q,factors:u.factors,attempt:e}),u.guidanceKey!==this.lastGuidanceKey&&(this.lastGuidanceKey=u.guidanceKey,this.emit("guidance",{key:u.guidanceKey})),u.ready&&this.stateValue==="positioning"&&(this.fired=!0,this.captureCompleteAt=u.at,this.fire(e))}async fire(e){let{options:t}=this,r=this.scheduler;r?.stop(),this.reportGate(!0);let s=r?.stats()??{degradeCount:0,meanDetectMs:0},a=[...this.carriedMeans,...s.meanDetectMs>0?[s.meanDetectMs]:[]];t.telemetry?.({type:"fired",timeToGateMs:this.now()-this.positioningStartedAt,degradeCount:this.carriedDegrade+s.degradeCount,meanDetectMs:a.length===0?0:a.reduce((_,b)=>_+b,0)/a.length});let n=t.mode??"clip",l=t.rankKeyframes?.()&&ge?ge.default(this,e).catch(()=>this.collectKeyframes(e)):this.collectKeyframes(e);if(n==="photo"){let _=this.watchRotation(e,null),b=await l;if(_(),e!==this.attempt)return;if(b===null){this.fail("generic",{phase:"keyframes"});return}let R=await this.provenance({n:0,meanGapMs:0,stdGapMs:0,captureLatencyMs:null},!1);if(e!==this.attempt)return;this.finishCapture({keyframe:b.blob,previewDataUrl:b.previewDataUrl,...R});return}this.setState("recording");let c=this.stream;if(c===null){this.fail("generic",{phase:"recording"});return}let h=t.screenRamp?.(),d=ee(h),u=null;l.then(_=>{u=_},()=>{});let m=o(()=>{e===this.attempt&&u!==null&&this.emit("frozen",{previewDataUrl:u.previewDataUrl})},"p"),w=Ye(h,pt),p=null,v,y=0;try{let _=this.recordTake(e,c,h,w,void 0).then(S=>S,S=>({failed:S})),[b,R]=await Promise.all([_,l]);if(v=R,e!==this.attempt)return;if("failed"in b){if(b.failed.kind==="cliptoolarge")throw b.failed;st(b.failed.requestedMimeType??"")}else p=b,nt(b.clip,w)?b.clip.stats===null&&st(b.clip.requestedMimeType??""):m();if(p===null||nt(p.clip,w)){y=1,t.telemetry?.({type:"clip_retake",reason:p===null?"error":p.clip.stats===null?"unreadable":"short"});let S=null;try{S=await this.recordTake(e,c,h,w,m)}catch($){if(p===null)throw $}if(e!==this.attempt)return;S!==null&&(p===null||ei(S.clip,p.clip))&&(p=S),S===null&&m()}}catch(_){if(e!==this.attempt)return;let b=_.kind;this.fail(b==="cliptoolarge"?"cliptoolarge":"recorder",{phase:"recording",name:j(_)});return}if(p===null){this.fail("recorder",{phase:"recording"});return}let{clip:g,rvfc:M,report:E,watched:A}=p;if(oe(g.blob)){this.fail("cliptoolarge",{phase:"recording"});return}if(v===null){this.fail("generic",{phase:"keyframes"});return}let I=await this.provenance(M,d,A);e===this.attempt&&this.finishCapture({clip:g.blob,clipMimeType:g.mimeType,...g.stats?{clipStats:g.stats}:{},clipRetakes:y,keyframe:v.blob,previewDataUrl:v.previewDataUrl,...E!==void 0&&E.rendered.length>0?{screenRamp:E}:{},...I})}async recordTake(e,t,r,s,a){let n=this.options.createRecorder?.()??new ti({now:o(()=>this.now(),"now")}),l=pi(this.options.video),c=Qe(r,{paint:o(m=>{(m===null||e===this.attempt)&&this.emit("ramp",{colour:m})},"paint"),now:o(()=>this.now(),"now"),frames:l.latest});this.ramp=c;let h=o(()=>{l.stop(),c.stop(),this.ramp===c&&(this.ramp=null)},"l"),d=this.watchRotation(e,n),u=De();try{return{clip:await n.record(t,a,()=>c.started(this.now()),s,l),rvfc:l.stats(),report:c.report(),watched:u.stop()}}finally{u.stop(),d(),h()}}async provenance(e,t,r={}){let s=this.trackProvenance;if(s===null)return{};let a,n=new Promise(d=>{a=setTimeout(()=>d(null),wi)}),l=await Promise.race([s,n]),c=l===null?null:await Promise.race([this.openEnvironment,n]);if(clearTimeout(a),l===null)return{};let h={...c,...r};return{provenance:{...mi(l,e,t),...Object.keys(h).length>0?{env:h}:{}}}}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!==pe&&(this.lastGuidanceKey=pe,this.emit("guidance",{key:pe}))}watchRotation(e,t){if(!this.uprightGuard)return()=>{};let r=this.options.video,s=o(()=>{if(e!==this.attempt||t!==null&&this.stateValue!=="recording"){l();return}r.videoWidth>0&&this.isLandscape()&&(l(),this.abortRecording(e,t))},"i"),a=setInterval(s,vi);r.addEventListener?.("resize",s);let n=!1;function l(){n||(n=!0,clearInterval(a),r.removeEventListener?.("resize",s))}return o(l,"o"),l}abortRecording(e,t){if(e!==this.attempt)return;this.attempt+=1;let r=this.attempt;try{t?.stop()}catch{}this.ramp?.stop(),this.ramp=null,this.fired=!1,this.captureCompleteAt=null,this.gate=new ot(this.options.thresholds??{}),this.blockStats=new lt,this.lastGateSnapshotAt=this.now(),this.lastGuidanceKey=null,this.setState("positioning"),this.positioningStartedAt=this.now(),this.holdUpright(r),this.startScheduler(r)}async collectKeyframes(e){let t=this.options.captureKeyframe??(a=>this.defaultKeyframe(a)),r=yi/(me-1),s=null;for(let a=0;a<me;a+=1){if(e!==this.attempt)return s;try{let n=await t(this.options.video);(s===null||n.sharpness>s.sharpness)&&(s=n)}catch{}a<me-1&&await ki(r)}return s}finishCapture(e){this.stopTracks(),this.setState("captured");let t=this.captureTiming();this.emit("artifacts",t===void 0?e:{...e,timing:t})}captureTiming(){let e={},t=o((r,s,a)=>{s!==null&&a!==null&&(e[r]=Math.max(0,Math.round(a-s)))},"t");return t("cameraReadyMs",this.cameraRequestedAt,this.cameraReadyAt),t("faceAcquireMs",this.cameraReadyAt,this.faceAcquiredAt),t("captureMs",this.faceAcquiredAt,this.captureCompleteAt),Object.keys(e).length>0?e:void 0}async defaultKeyframe(e){let t=document.createElement("canvas"),r=await(this.facing==="user"?ri:bi)(e,t),s=t.toDataURL("image/jpeg",.92);return{blob:r,previewDataUrl:s,sharpness:this.centerSharpness(e)}}defaultSnapshot(e,t){try{let r=this.snapshotCanvas??document.createElement("canvas"),s=t/Math.max(1,e.videoWidth),a=Math.max(1,Math.round(e.videoWidth*s)),n=Math.max(1,Math.round(e.videoHeight*s)),l=r.getContext("2d");return l===null?e:(r.width!==a&&(r.width=a),r.height!==n&&(r.height=n),l.drawImage(e,0,0,a,n),this.snapshotCanvas=r,r)}catch{return e}}defaultQuality(e,t){let r=ut(e,t,96);return r===null?ht:{sharpness:ce(r),exposure:$e(r),meanLuma:je(r)}}centerSharpness(e){let t=te(e),r=ut(e,{x:t.width*.25,y:t.height*.25,width:t.width*.5,height:t.height*.5},96);return r===null?0:ce(r)}teardownAttempt(){this.scheduler?.stop(),this.scheduler=null,this.reportGate(!0),this.gate=null,this.ramp?.stop(),this.ramp=null,this.stopTracks()}reportGate(e){let t=this.blockStats,r=this.profiler;if(t===null||r===null)return;let s=t.summary();e&&(this.blockStats=null),s.ticks!==0&&this.options.telemetry?.({type:"gate",final:e,activeClass:r.deviceClass,cadenceHz:r.profile.cadenceHz,...s})}stopTracks(){if(this.stream!==null){for(let e of this.stream.getTracks())e.stop();this.stream=null}}fail(e,t,r){this.scheduler?.stop(),this.reportGate(!0),this.stopTracks(),this.setState("error"),this.options.telemetry?.({type:"error",kind:e,fallbackReason:r});let{phase:s,name:a}=t;this.emit("error",{kind:e,retryable:e!=="insecure"&&e!=="unsupported",detail:a===void 0?{phase:s}:{phase:s,name:a}})}setState(e){this.stateValue=e,this.emit("statechange",{state:e})}now(){return this.options.now?.()??performance.now()}},o(K,"Ie"),K),ge;function ki(i){return new Promise(e=>setTimeout(e,i))}o(ki,"nt");function Ti(i){return i instanceof Error?i.message:String(i)}o(Ti,"at");function ut(i,e,t){try{let r=document.createElement("canvas"),s=t/Math.max(1,e.width);r.width=Math.max(1,Math.round(e.width*s)),r.height=Math.max(1,Math.round(e.height*s));let a=r.getContext("2d");return a===null?null:(a.drawImage(i,e.x,e.y,e.width,e.height,0,0,r.width,r.height),a.getImageData(0,0,r.width,r.height))}catch{return null}}o(ut,"Re");function _i(i){if(i.enumerateDevices!==void 0)return i.enumerateDevices;if(i.getUserMedia===void 0&&!(typeof navigator>"u"||typeof navigator.mediaDevices?.enumerateDevices!="function"))return()=>navigator.mediaDevices.enumerateDevices()}o(_i,"st");var Ei=12e4,gt=13e4,Si=3e3,Ai=1200,ve=Symbol.for("@sekyro/web.preload.v1");function we(){let i=globalThis;return i[ve]??(i[ve]=new Map),i[ve]}o(we,"h");function re(i){let e=(i??ue).replace(/\/+$/,"");return e===""?"/":e}o(re,"b");function yt(i){let e=we(),t=e.get(i);return t===void 0&&(t={status:"idle",promise:null,scheduled:null,detectorPromise:null,detector:null,listeners:new Set},e.set(i,t)),t}o(yt,"ae");function ye(i,e){if(i.status!==e){i.status=e;for(let t of[...i.listeners])t(e)}}o(ye,"k");var Ii=o(i=>x({preferred:["blaze"],v3AssetBaseUrl:i,blazeInitTimeoutMs:Ei}),"K"),xi=Ii;function Di(){return typeof window<"u"&&typeof navigator<"u"&&typeof navigator.mediaDevices?.getUserMedia=="function"}o(Di,"Ce");function Ri(){return navigator.connection?.saveData===!0}o(Ri,"Se");function Ci(i){let e=window;if(typeof e.requestIdleCallback=="function"){let r=e.requestIdleCallback(i,{timeout:Si});return()=>e.cancelIdleCallback?.(r)}let t=setTimeout(i,Ai);return()=>clearTimeout(t)}o(Ci,"Ee");function Oi(i,e){let t,r=new Promise(l=>{t=l}),s=!1,a=o(()=>{},"u"),n={promise:r,settle:o(l=>{s||(s=!0,a(),i.scheduled===n&&(i.scheduled=null),t(l))},"settle")};return i.scheduled=n,a=Ci(()=>{s||n.settle(be(i,e))}),r}o(Oi,"ye");function be(i,e){if((i.status==="loading"||i.status==="ready")&&i.promise!==null)return i.promise;ye(i,"loading");let t=new Promise(n=>n(xi(e)));i.detectorPromise=t;let r,s=new Promise((n,l)=>{r=setTimeout(()=>{t.then(c=>c.destroy(),()=>{}),l(new Error(`detector preload exceeded ${gt} ms`))},gt)}),a=Promise.race([t,s]).then(n=>i.detectorPromise!==t?(n.destroy(),i.status):(i.detector=n,ye(i,"ready"),"ready"),n=>(i.detectorPromise===t&&(i.detectorPromise=null,i.detector=null,ye(i,"failed"),console.warn("[@sekyro/web] face-detector preload failed:",n)),i.status)).finally(()=>clearTimeout(r));return i.promise=a,i.scheduled?.settle(a),a}o(be,"U");function hr(i={}){if(!Di())return Promise.resolve("idle");let e=re(i.assetBaseUrl),t=yt(e);return i.respectSaveData===!0&&Ri()?Promise.resolve(t.status):(t.status==="loading"||t.status==="ready")&&t.promise!==null?t.promise:i.idle===!0?t.scheduled?.promise??Oi(t,e):be(t,e)}o(hr,"xe");function ur(i){return we().get(re(i))?.status??"idle"}o(ur,"Fe");function dr(i,e){let t=yt(re(e));return t.listeners.add(i),()=>{t.listeners.delete(i)}}o(dr,"Ie");function Pi(i){return{get tier(){return i.tier},get fallbackReason(){return i.fallbackReason},detect:o((...e)=>i.detect(...e),"detect"),destroy:o(()=>{},"destroy")}}o(Pi,"Le");function Gi(i){let e=re(i),t=we().get(e);if(!(t===void 0||t.detector===null&&t.detectorPromise===null&&t.scheduled===null))return async()=>{t.scheduled!==null&&be(t,e);let r=t.promise;for(;t.detector===null&&r!==null&&(await r,t.promise!==r);)r=t.promise;return t.detector!==null?Pi(t.detector):x({v3AssetBaseUrl:e})}}o(Gi,"de");var Ui=new Set(["inuse","overconstrained","notfound"]),Fi=[500,1500];function Ni(i){switch(i){case"fcv3.no_face":case"fcv3.center_face":case"fcv3.straighten":return"center";case"fcv3.come_closer":return"closer";case"fcv3.move_back":return"farther";case"fcv3.more_light":case"fcv3.too_bright":return"light";case"fcv3.hold_still":case"fcv3.steady_camera":return"still";case"fcv3.hold_upright":return"upright";case"fcv3.one_face":return"one_face";default:return null}}o(Ni,"Ae");function Li(i){switch(i){case"preflight":case"acquiring":return"starting";case"positioning":return"gating";default:return i}}o(Li,"Pe");function vt(i){switch(i){case"permission":case"notfound":case"inuse":case"insecure":case"unsupported":return i;case"backcamera":return"notfound";default:{let e=i;return"generic"}}}o(vt,"ue");function Bi(i,e,t){if(t===void 0)return{kind:vt(i),retryable:e};let r=qe(t.name);return{kind:vt(i),retryable:e,detail:{...r!==void 0?{name:r}:{},phase:t.phase,engineKind:i}}}o(Bi,"we");var qi=new Set(["captured","uploading","checking"]);function Wi(i,e={},t,r=()=>"self",s=()=>{},a){let n=e.now??(()=>performance.now()),l=e.canChooseFacing??Oe,c="user",h=Pe(),d=r(),u=Ce(),m=!Le(),w=e.engineOptions,p=w?.createDetector===void 0&&w?.createWorker===void 0?{createDetector:o(()=>{let f=Gi(i.assetBaseUrl);return f!==void 0?f():x({v3AssetBaseUrl:i.assetBaseUrl})},"createDetector")}:{},v={video:i.video,mode:m?"photo":"clip",rankKeyframes:t,facingMode:void 0,v3AssetBaseUrl:i.assetBaseUrl,screenRamp:o(()=>d==="self"&&u.count("ramp")>0?s():void 0,"screenRamp"),...e.engineOptions??{},...p},y=e.createEngine?.(v)??new mt(v),g="idle",M=null,E=0,A=!1,I="full",_=null,b=null,R=0,S=0,$=o(()=>{i.video.videoWidth>0&&i.video.videoHeight>0&&(R=i.video.videoWidth,S=i.video.videoHeight)},"W"),Me=Ge({enabled:i.keepScreenAwake!==!1}),X=o(f=>{g=f,Me.setActive(f==="starting"||f==="gating"||f==="recording"),u.emit("state",f)},"S"),se=o(()=>u.emit("gate",{progress:E,hint:M,faceDetected:A}),"F"),ae=o(()=>{let f=y.animations??"full";f!==I&&(I=f,u.emit("profile",{animations:I}))},"I"),G=0,Y=null,wt=e.schedule??((f,k)=>{let T=setTimeout(f,k);return()=>clearTimeout(T)}),Z=o(()=>{Y?.(),Y=null},"E"),bt=o((f,k)=>{if(V||!Ui.has(f)||k?.phase!=="acquiring")return!1;let T=Fi[G];return T===void 0?!1:(G+=1,Z(),Y=wt(()=>{Y=null,V||y.retry()},T),!0)},"fe"),Mt=[y.on("statechange",({state:f})=>{if(f==="error")return;let k=Li(f);k==="gating"&&(G=0),k==="starting"&&g!=="starting"&&(M=null,E=0,A=!1,_=null,b=null,R=0,S=0),X(k),ae(),k==="recording"&&($(),_=n(),M="hold",E=1,se())}),y.on("checks",f=>{$(),E=f.progress,A=f.factors.presence>0,se(),ae()}),y.on("guidance",({key:f})=>{M=Ni(f),se()}),y.on("frozen",({previewDataUrl:f})=>{b=n(),u.emit("frozen",{previewDataUrl:f})}),y.on("ramp",f=>u.emit("ramp",f)),y.on("artifacts",f=>{if(g!=="captured")return;let k=Q(),T=f.clipStats,_e=T!==void 0?Math.round(T.durationMs):_!==null&&b!==null?Math.max(0,Math.round(b-_)):void 0,Ee=T!==void 0&&T.frames>1&&T.durationMs>0?Math.round(T.frames*1e4/T.durationMs)/10:void 0;u.emit("captured",{keyframe:f.keyframe,...f.clip!==void 0?{clip:f.clip}:{},...f.clipMimeType!==void 0?{clipMime:f.clipMimeType}:{},width:i.video.videoWidth||R,height:i.video.videoHeight||S,..._e!==void 0?{clipMs:_e}:{},...T!==void 0?{clipFrames:T.frames}:{},...Ee!==void 0?{fps:Ee}:{},...f.clipRetakes!==void 0?{clipRetakes:f.clipRetakes}:{},...f.clipMimeType!==void 0?{codec:ft(f.clipMimeType)}:{},captureChannel:k==="desktop"?"desktop":"mobile",formFactor:k,...m?{degraded:"NO_RECORDER"}:{},engine:"v3",facingMode:y.facingMode,mode:d,...f.timing,...f.screenRamp!==void 0?{screenRamp:f.screenRamp}:{},...f.provenance!==void 0?{provenance:f.provenance}:{}})}),y.on("error",({kind:f,retryable:k,detail:T})=>{f==="backcamera"&&kt()||bt(f,T)||(X("error"),ae(),u.emit("error",Bi(f,k,T)))})],ke=!1;function kt(){return V||ke||d!=="assisted"||a===void 0||a.session()!=="choice"?!1:(ke=!0,a.onModeChange("self"),d="self",c=ne("self"),X("mode_switch"),y.restart(c),!0)}o(kt,"me");let Te=o(async()=>a!==void 0&&a.session()==="choice"&&await l().catch(()=>!1),"$"),V=!1;return{handle:{get state(){return g},get captureMode(){return r()},get facingMode(){return y.facingMode??c},on:o((f,k)=>u.on(f,k),"on"),start:o(f=>(d=r(),h.facing(d,i.facing),c=h.facing(d,f?.facing),Z(),G=0,y.start({facingMode:c})),"start"),retry:o(()=>{Z(),G=0,y.retry()},"retry"),switchCamera:o(()=>h.refuseSwitch(r()),"switchCamera"),canSwitchCaptureMode:Te,setCaptureMode:o(async f=>{if(f===r()||!await Te()||V||qi.has(g)||a===void 0)return!1;a.onModeChange(f),d=f;let k=ne(f);return c=k,g==="idle"||(X("mode_switch"),Z(),G=0,y.restart(k)),!0},"setCaptureMode"),destroy:o(()=>{V=!0,Z();for(let f of Mt)f();Me.setActive(!1),y.destroy(),u.clear()},"destroy")},setFlowState:o(f=>{g!==f&&X(f)},"setFlowState")}}o(Wi,"De");function fr(i){return Wi(i).handle}o(fr,"Ze");export{zi as a,ee as b,hr as c,ur as d,dr as e,Bi as f,Wi as g,fr as h};
1
+ import{d as Re,e as Xe,f as Ze,g as Ve}from"./chunk-2CQQAB3Y.js";import{a as le,b as je,c as ce,d as $e}from"./chunk-P7K7ELYZ.js";import{a as Se,b as Q,c as Ae,d as Ie,e as Ce,h as Oe,i as ne,j as Pe,k as Ge,l as He,m as Ke}from"./chunk-6MYG4HWP.js";import{a as Ue,b as Fe,c as Ne,d as Le,e as Be,f as oe,g as j,h as qe,i as We,j as ze}from"./chunk-JS2IXPNL.js";import{b as xe,c as De}from"./chunk-SLLJX5QK.js";import{a as o}from"./chunk-4FHWXBOB.js";var Tt=["magenta","yellow","green","blue"],_t={magenta:"rgb(255, 72, 150)",yellow:"rgb(255, 190, 0)",green:"rgb(0, 238, 175)",blue:"rgb(25, 150, 255)",dark:"rgb(0, 0, 0)"};function zi(i){return _t[i]}o(zi,"P");var Et=4,St=4,J=o(i=>typeof i=="number"&&Number.isFinite(i),"R");function ee(i){if(typeof i!="object"||i===null)return!1;let e=i;if(typeof e.nonce!="string"||e.nonce.length===0||!Array.isArray(e.colours)||e.colours.length<1||e.colours.length>8||!e.colours.every(r=>Tt.includes(r))||!Array.isArray(e.onsetsMs)||e.onsetsMs.length!==e.colours.length)return!1;let t=-1;for(let r of e.onsetsMs){if(!J(r)||r<0||r<=t)return!1;t=r}return!(!J(e.holdMs)||e.holdMs<=0||!J(e.endMs)||e.endMs<=t||!J(e.clipMs)||e.clipMs<e.endMs||e.clipMs>8e3)}o(ee,"_");function Ye(i,e){return ee(i)?Math.max(e,Math.ceil(i.clipMs)):e}o(Ye,"O");function Qe(i,e){let t=e.now??(()=>performance.now()),r=ee(i)?i:void 0,s=[],a=null,n=null,l=null,c=!1,h=null,d=o(p=>{h=p;try{e.paint(p)}catch{}},"s"),u=o(p=>{let v=e.frames?.()??null;return v!==null&&l!==null?v.mediaTimeMs+(p-v.presentationTimeMs)-l:p-(n??p)},"p"),m=o((p,v,y=0)=>{if(c)return;let g=Math.max(0,p-u(t()));a=setTimeout(()=>{if(a=null,!c){if(y<Et&&u(t())<p-St){m(p,v,y+1);return}v()}},g)},"f"),w=o(p=>{if(r===void 0)return;let v=r.endMs;if(p>=r.colours.length){m(v,()=>d(null));return}let y=r.onsetsMs[p],g=p+1<r.onsetsMs.length?r.onsetsMs[p+1]:v;m(y,()=>{let M=u(t());if(M>v){h!==null&&d(null);return}let E=r.colours[p];d(E);let A=s.length===0?0:s[s.length-1].tMs;s.push({tMs:Math.max(A,Math.round(M)),colour:E});let I=y+r.holdMs;if(I<g){m(I,()=>{if(u(t())>v){h!==null&&d(null);return}d("dark"),w(p+1)});return}w(p+1)})},"S");return{started(p){if(r===void 0||c||n!==null)return;n=p;let v=e.frames?.()??null;l=v===null?null:v.mediaTimeMs+(p-v.presentationTimeMs),w(0)},stop(){c||(c=!0,a!==null&&clearTimeout(a),a=null,h!==null&&d(null))},report(){return r===void 0?void 0:{nonce:r.nonce,rendered:[...s]}}}}o(Qe,"w");var At=1e4,O,It=(O=class{constructor(e,t){this.tier="blaze",this.inner=e,t!==void 0&&(this.fallbackReason=t)}static async create(e,t){let r=await import("./vision_bundle-WBHR7TEE.js"),s=await r.FilesetResolver.forVisionTasks(e),a=await r.FaceDetector.createFromOptions(s,{baseOptions:{modelAssetPath:`${e}/blaze_face_short_range.tflite`,delegate:"CPU"},runningMode:"IMAGE"});return new O(a,t)}async detect(e,t,r){let s;try{s=this.inner.detect(e).detections}catch{return null}let a=xt(s);if(a?.boundingBox===void 0)return null;let n=te(e),l=Dt(a.keypoints,n),c=a.keypoints?.[2],h={box:{x:a.boundingBox.originX,y:a.boundingBox.originY,width:a.boundingBox.width,height:a.boundingBox.height},...l!==void 0?{eyes:l}:{},...c!==void 0?{nose:{x:c.x*n.width,y:c.y*n.height}}:{},score:a.categories[0]?.score??0,extraFaces:Je(s.map(d=>d.boundingBox??{width:0,height:0}),s.indexOf(a))};return et(h,e,t,r)}destroy(){try{this.inner.close()}catch{}}},o(O,"t"),O);function xt(i){let e,t=-1;for(let r of i){let s=r.categories[0]?.score??0;s>t&&(e=r,t=s)}return e}o(xt,"R");function Dt(i,e){let t=i?.[0],r=i?.[1];if(t===void 0||r===void 0)return;let s=o(l=>({x:l.x*e.width,y:l.y*e.height}),"n"),[a,n]=[s(t),s(r)];return a.x<=n.x?{left:a,right:n}:{left:n,right:a}}o(Dt,"T");function Rt(){if(typeof OffscreenCanvas=="function")return new OffscreenCanvas(2,2);let i=document.createElement("canvas");return i.width=2,i.height=2,i}o(Rt,"E");var Ct=4;async function Ot(){let i=globalThis.FaceDetector;if(typeof i!="function")return{ok:!1,reason:"unsupported"};try{let e=new i({fastMode:!0,maxDetectedFaces:Ct});return await e.detect(Rt()),{ok:!0,instance:e}}catch(e){return{ok:!1,reason:`smoke_failed:${e instanceof Error?e.message:String(e)}`}}}o(Ot,"w");var U,Pt=(U=class{constructor(e,t){this.tier="native",this.inner=e,t!==void 0&&(this.fallbackReason=t)}async detect(e,t,r){let s;try{s=await this.inner.detect(e)}catch{return null}let a=s.map(d=>d.boundingBox),n=-1;a.forEach((d,u)=>{let m=a[n];(m===void 0||d.width*d.height>m.width*m.height)&&(n=u)});let l=s[n];if(l===void 0)return null;let c=Gt(l.landmarks),h={box:{x:l.boundingBox.x,y:l.boundingBox.y,width:l.boundingBox.width,height:l.boundingBox.height},...c!==void 0?{eyes:c}:{},score:1,extraFaces:Je(a,n)};return et(h,e,t,r)}destroy(){}},o(U,"b"),U);function Gt(i){if(i===void 0)return;let e=i.filter(s=>s.type==="eye").map(s=>s.locations[0]).filter(s=>s!==void 0),[t,r]=e;if(!(t===void 0||r===void 0))return t.x<=r.x?{left:t,right:r}:{left:r,right:t}}o(Gt,"S");var Ut=.25;function Je(i,e){let t=i[e],r=t===void 0?0:t.width*t.height;if(!(r>0))return 0;let s=0;return i.forEach((a,n)=>{n!==e&&a.width*a.height>=Ut*r&&(s+=1)}),s}o(Je,"f");var ue="/models-v3",Ft=["native","blaze"],F,de=(F=class extends Error{constructor(e){super(`no detector tier available (${e})`),this.name="DetectorLadderError",this.fallbackReason=e}},o(F,"x"),F);function te(i){let e=i;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 t=typeof e.width=="number"?e.width:0,r=typeof e.height=="number"?e.height:0;return{width:t,height:r}}o(te,"y");function et(i,e,t,r){let s=te(e),a=s.width>0?t/s.width:1,n=s.height>0?r/s.height:1,l=o(c=>({x:c.x*a,y:c.y*n}),"s");return{box:{x:i.box.x*a,y:i.box.y*n,width:i.box.width*a,height:i.box.height*n},...i.eyes!==void 0?{eyes:{left:l(i.eyes.left),right:l(i.eyes.right)}}:{},...i.nose!==void 0?{nose:l(i.nose)}:{},score:i.score,...i.extraFaces!==void 0?{extraFaces:i.extraFaces}:{}}}o(et,"h");function Nt(i){return i instanceof Error?i.message:String(i)}o(Nt,"C");async function x(i){let e=i.preferred??Ft,t=[];for(let r of e){if(r==="native"){let s=await Ot();if(s.ok)return new Pt(s.instance,he(t));t.push(`native:${s.reason}`);continue}try{return await Lt(It.create(i.v3AssetBaseUrl??ue,he(t)),i.blazeInitTimeoutMs??At)}catch(s){t.push(s instanceof tt?"blaze:blaze_init_timeout":`blaze:${Nt(s)}`)}}throw new de(he(t)??"no_tier_available")}o(x,"O");function he(i){return i.length>0?i.join("; "):void 0}o(he,"v");var N,tt=(N=class extends Error{},o(N,"g"),N);function Lt(i,e){return new Promise((t,r)=>{let s=setTimeout(()=>{r(new tt(`init exceeded ${e}ms`)),i.then(a=>a.destroy(),()=>{})},e);i.then(a=>{clearTimeout(s),t(a)},a=>{clearTimeout(s),r(a)})})}o(Lt,"W");var C=1;function it(){return typeof OffscreenCanvas=="function"&&typeof createImageBitmap=="function"&&typeof Worker=="function"}o(it,"K");function Bt(i,e={}){let t=e.createDetector??x,r=null;i.onmessage=s=>{let a=s.data;if(a.v!==C){a.bitmap?.close?.();return}if(a.type==="init"){t(a.options).then(n=>{r=n;let l={v:C,type:"ready",tier:n.tier,...n.fallbackReason!==void 0?{fallbackReason:n.fallbackReason}:{}};i.postMessage(l)});return}if(a.type==="detect"){let n=o(l=>{let c={v:C,type:"result",id:a.id,observation:l};i.postMessage(c),a.bitmap.close?.()},"a");if(r===null){n(null);return}r.detect(a.bitmap,a.streamWidth,a.streamHeight).then(n,()=>n(null))}}}o(Bt,"B");typeof self<"u"&&typeof self.importScripts=="function"&&Bt(self);var P,rt=(P=class{constructor(e,t){this.pending=new Map,this.nextId=1,this.worker=e,this.tier=t.tier,t.fallbackReason!==void 0&&(this.fallbackReason=t.fallbackReason),e.addEventListener("message",r=>{let s=r.data;if(s.v!==C||s.type!=="result")return;let a=this.pending.get(s.id);this.pending.delete(s.id),a?.(s.observation)})}static create(e,t,r=1e4){return new Promise((s,a)=>{let n=setTimeout(()=>{e.removeEventListener("message",l),e.terminate(),a(new Error(`worker detector not ready within ${r}ms`))},r),l=o(h=>{let d=h.data;d.v!==C||d.type!=="ready"||(clearTimeout(n),e.removeEventListener("message",l),s(new P(e,d)))},"s");e.addEventListener("message",l);let c={v:C,type:"init",options:t};e.postMessage(c)})}async detect(e,t,r){let s;try{typeof ImageBitmap<"u"&&e instanceof ImageBitmap?s=e:typeof createImageBitmap=="function"?s=await createImageBitmap(e):s=e}catch{return null}let a=this.nextId;return this.nextId+=1,new Promise(n=>{this.pending.set(a,n);let l={v:C,type:"detect",id:a,bitmap:s,streamWidth:t,streamHeight:r};this.worker.postMessage(l,[s])})}destroy(){for(let e of this.pending.values())e(null);this.pending.clear(),this.worker.terminate()}},o(P,"t"),P);var qt=[...Ue.filter(i=>i.startsWith("video/mp4")),"video/webm;codecs=h264","video/webm;codecs=avc1","video/webm;codecs=vp8","video/webm;codecs=vp9","video/webm"],dt=new Set;function Wt(i){let e=/(?:Chrome|Chromium)\/(\d+)\./.exec(i??"");return e?Number(e[1]):null}o(Wt,"Pe");function zt(i=Kt(),e=globalThis.navigator?.userAgent){if(i===void 0)return"";let t=Wt(e)===126;for(let r of qt)if(!(dt.has(r)||t&&r.startsWith("video/mp4")))try{if(i(r))return r}catch{}return""}o(zt,"be");function st(i){i!==""&&dt.add(i)}o(st,"L");function Ht(i){return i.replace(/^video\/x-matroska/i,"video/webm")}o(Ht,"ye");function ft(i){let e=/codecs=["']?([^,;"']+)/i.exec(i);return e?e[1].trim():i.split(";")[0].trim()}o(ft,"lt");function Kt(){let i=globalThis.MediaRecorder;return i&&typeof i.isTypeSupported=="function"?e=>i.isTypeSupported(e):void 0}o(Kt,"xe");var pt=2500,Xt=1e3,Zt=1500,at=25e5,Vt=100,jt=700,$t=20,Yt=1500,ie=null;function Qt(){return ie??(ie=import("./clip-inspect-DLJXVKV6-TNHTD4LV.js").catch(i=>{throw ie=null,i})),ie.catch(()=>null)}o(Qt,"He");var B,D=(B=class extends Error{constructor(e,t){super(t??e),this.kind=e}},o(B,"T"),B),Jt=100;function nt(i,e){return i.stats===void 0?!1:i.stats===null?!0:i.stats.durationMs<e-Jt}o(nt,"N");function ei(i,e){return i.stats?e.stats?i.stats.durationMs>e.stats.durationMs:!0:!1}o(ei,"Ee");var q,ti=(q=class{constructor(e={}){this.recorder=null,this.stream=null,this.chunks=[],this.bytes=0,this.hardStopTimer=null,this.graceTimer=null,this.pollTimer=null,this.settled=!1,this.now=e.now??(()=>globalThis.performance?.now?.()??Date.now())}clearTimers(){this.hardStopTimer&&clearTimeout(this.hardStopTimer),this.graceTimer&&clearTimeout(this.graceTimer),this.pollTimer&&clearInterval(this.pollTimer),this.hardStopTimer=null,this.graceTimer=null,this.pollTimer=null}record(e,t,r,s=pt,a){let n=zt(),l=Qt();return this.recordRaw(e,t,r,s,a,n).then(c=>ii(c,l),c=>{throw c instanceof D&&(c.requestedMimeType=n),c})}recordRaw(e,t,r,s,a,n){return this.recorder&&!this.settled?Promise.reject(new D("generic","record() called while a recording is in flight — 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((l,c)=>{let h;try{h=new MediaRecorder(e,n?{mimeType:n,videoBitsPerSecond:at}:{videoBitsPerSecond:at})}catch{try{h=new MediaRecorder(e)}catch{c(new D("unsupported"));return}}this.recorder=h;let d=o(g=>{this.settled||(this.settled=!0,this.clearTimers(),g())},"d"),u=o(()=>d(()=>{let g=Ht(h.mimeType||n||Fe),M=new Blob(this.chunks,{type:g});if(M.size===0){c(new D("generic","empty clip"));return}if(oe(M)){c(new D("cliptoolarge"));return}l({blob:M,mimeType:g,requestedMimeType:n})}),"u");h.ondataavailable=g=>{g.data&&g.data.size&&(this.chunks.push(g.data),this.bytes+=g.data.size,this.bytes>Be&&d(()=>{try{h.state!=="inactive"&&h.stop()}catch{}c(new D("cliptoolarge"))}))},h.onstop=u,h.onerror=()=>d(()=>c(new D("generic")));let m=this.now();if(r!==void 0||a!==void 0){let g=!1;h.onstart=()=>{if(!(g||this.settled)&&(g=!0,m=this.now(),r!==void 0))try{r()}catch{}}}try{h.start(Xt)}catch{d(()=>c(new D("generic")));return}let w=o(()=>{if(this.pollTimer&&clearInterval(this.pollTimer),this.pollTimer=null,this.hardStopTimer&&clearTimeout(this.hardStopTimer),this.hardStopTimer=null,this.settled||t?.(),h.state!=="inactive"){try{h.stop()}catch{u()}this.graceTimer=setTimeout(u,Zt)}else u()},"m"),p=this.now();if(a===void 0){this.hardStopTimer=setTimeout(w,s);return}let v=null,y=!1;this.hardStopTimer=setTimeout(w,s+jt),this.pollTimer=setInterval(()=>{if(this.settled||y)return;let g=null;try{g=a.latest()}catch{g=null}let M=g?.presentationTimeMs;M!==void 0&&Number.isFinite(M)&&M>=m&&v===null&&(v=M);let E=v!==null&&M!==void 0&&M-v>=s,A=v===null&&this.now()-p>=s;if(!(!E&&!A)){if(y=!0,this.pollTimer&&clearInterval(this.pollTimer),this.pollTimer=null,A){w();return}this.hardStopTimer&&clearTimeout(this.hardStopTimer),this.hardStopTimer=setTimeout(w,Vt)}},$t)}))}stop(e){this.clearTimers();let t=this.recorder;if(t&&t.state!=="inactive")try{t.stop()}catch{}this.recorder=null,(e??this.stream)?.getTracks().forEach(r=>r.stop()),this.stream=null}},o(q,"A"),q);async function ii(i,e){let t,r=new Promise(h=>{t=setTimeout(()=>h(null),Yt)}),s=await Promise.race([e,r]);if(clearTimeout(t),s===null)return i;let a;try{a=await s.blobBytes(i.blob)}catch{return{...i,stats:null}}let n=s.inspectClipBytes(a);if(n?.container!=="webm")return{...i,stats:n};let l=s.withWebmDuration(a,n.durationMs);if(l===null)return{...i,stats:n};let c=s.inspectClipBytes(l);return c===null||c.frames!==n.frames||c.durationMs!==n.durationMs?{...i,stats:n}:{...i,blob:new Blob([l],{type:i.blob.type}),stats:n}}o(ii,"Be");function ri(i,e,t=.92){return new Promise((r,s)=>{let a=i.videoWidth,n=i.videoHeight;if(!a||!n){s(new Error("video-not-ready"));return}let l=e.getContext("2d");if(!l){s(new Error("no-2d-context"));return}e.width=a,e.height=n,l.scale(-1,1),l.drawImage(i,-a,0),e.toBlob(c=>c?r(c):s(new Error("empty-keyframe")),"image/jpeg",t)})}o(ri,"Me");var W,si=(W=class{constructor(e){this.timer=null,this.frameCallbackId=null,this.running=!1,this.busy=!1,this.lastRunAt=Number.NEGATIVE_INFINITY,this.degradeCount=0,this.durations=[],this.options=e,this.periodMs=1e3/e.cadenceHz}start(){if(this.running)return;this.running=!0;let e=this.options.video;if(typeof e?.requestVideoFrameCallback=="function"){let t=o(()=>{this.running&&(this.frameCallbackId=e.requestVideoFrameCallback?.(()=>{this.frameCallbackId=null,this.now()-this.lastRunAt>=this.periodMs&&this.tick(),t()}))},"t");t();return}this.timer=setInterval(()=>this.tick(),this.periodMs)}stop(){this.running=!1,this.timer!==null&&(clearInterval(this.timer),this.timer=null),this.frameCallbackId!==null&&(this.options.video?.cancelVideoFrameCallback?.(this.frameCallbackId),this.frameCallbackId=null)}stats(){let e=this.durations.length===0?0:this.durations.reduce((t,r)=>t+r,0)/this.durations.length;return{degradeCount:this.degradeCount,meanDetectMs:e}}now(){return this.options.now?.()??performance.now()}tick(){if(!this.running)return;if(this.busy){this.degradeCount+=1;return}this.busy=!0,this.lastRunAt=this.now();let e=this.now();this.options.run().catch(()=>{}).finally(()=>{this.busy=!1,this.durations.push(this.now()-e),this.durations.length>20&&this.durations.shift()})}},o(W,"D"),W),ai=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}),L=o(i=>Math.min(1,Math.max(0,i)),"C"),z,ot=(z=class{constructor(e={}){this.p=0,this.lastTickAt=null,this.lastCenter=null,this.velocityEma=0,this.qWindow=[],this.lastSizeDirection="ideal",this.t={...ai,...e}}reset(){this.p=0,this.lastTickAt=null,this.lastCenter=null,this.velocityEma=0,this.qWindow=[],this.lastSizeDirection="ideal"}tick(e){let{observation:t,quality:r,timestampMs:s}=e,a=this.lastTickAt===null?0:Math.max(0,(s-this.lastTickAt)/1e3);this.lastTickAt=s;let n={presence:0,single:1,centering:0,size:0,pose:0,sharpness:L(r.sharpness),exposure:L(r.exposure),motion:1};if(t!==null){n.presence=1,n.single=(t.extraFaces??0)>0?0:1;let d=this.geometryOf(t,e);n.centering=d.centering,n.size=d.size,n.pose=d.pose,n.motion=this.motionOf(d.center,d.iod,s)}else this.lastCenter=null,this.velocityEma=0;let l=Math.min(n.presence,n.single,n.centering,n.size,n.pose,n.sharpness,n.exposure,n.motion);this.p=L(this.p+(l>=this.t.Q_GOOD?this.t.RISE_PER_S*l:-this.t.FALL_PER_S*(1-l))*a),this.qWindow.push({at:s,q:l}),this.qWindow=this.qWindow.filter(d=>d.at>=s-this.t.READY_WINDOW_MS);let c=this.qWindow.map(d=>d.q);if(c.length>=3){let d=Math.min(...c),u=c.indexOf(d);c=c.filter((m,w)=>w!==u)}let h=this.p>=1&&c.every(d=>d>=this.t.Q_GOOD);return{at:s,q:l,p:this.p,factors:n,guidanceKey:this.guidanceOf(n,r,l),ready:h,accepted:l>=this.t.Q_GOOD}}geometryOf(e,t){let{box:r,eyes:s}=e,a={x:t.frameWidth/2,y:t.frameHeight/2},n=Math.min(t.frameWidth,t.frameHeight),l=s!==void 0?{x:(s.left.x+s.right.x)/2,y:(s.left.y+s.right.y)/2}:{x:r.x+r.width/2,y:r.y+r.height/2-this.t.BOX_EYE_OFFSET_FACTOR*r.height},c=s!==void 0?Math.hypot(s.right.x-s.left.x,s.right.y-s.left.y):this.t.IOD_BOX_PROXY_FACTOR*r.width,h=Math.hypot(l.x-a.x,l.y-a.y),d=c<=0?0:1-L(h/(this.t.CENTER_FALLOFF_IOD_MULTIPLE*c)),u=n>0?c/n:0;this.lastSizeDirection=u<this.t.SIZE_IDEAL_MIN?"far":u>this.t.SIZE_IDEAL_MAX?"close":"ideal";let m;u<this.t.SIZE_HARD_MIN||u>this.t.SIZE_HARD_MAX?m=0:u<this.t.SIZE_IDEAL_MIN?m=(u-this.t.SIZE_HARD_MIN)/(this.t.SIZE_IDEAL_MIN-this.t.SIZE_HARD_MIN):u>this.t.SIZE_IDEAL_MAX?m=(this.t.SIZE_HARD_MAX-u)/(this.t.SIZE_HARD_MAX-this.t.SIZE_IDEAL_MAX):m=1;let w=1;if(s!==void 0){let p=Math.abs(Math.atan2(s.right.y-s.left.y,s.right.x-s.left.x))*180/Math.PI;w=1-L(p/this.t.ROLL_MAX_DEG)}return{center:l,iod:c,centering:d,size:m,pose:w}}motionOf(e,t,r){let s=this.lastCenter;if(this.lastCenter={...e,at:r},s===null||t<=0)return 1;let a=(r-s.at)/1e3;if(a<=0)return 1;let n=Math.hypot(e.x-s.x,e.y-s.y)/t/a;n<=this.t.MOTION_DEADBAND_IOD_PER_S&&(n=0);let l=1-Math.exp(-a/this.t.MOTION_TAU_S);return this.velocityEma=l*n+(1-l)*this.velocityEma,1-L(this.velocityEma/this.t.MOTION_VELOCITY_IOD_PER_S)}guidanceOf(e,t,r){if(e.presence<=0)return"fcv3.no_face";if(e.single<=0)return"fcv3.one_face";if(e.size<this.t.GUIDE_SIZE)return this.sizeGuidance();if(e.centering<this.t.GUIDE_CENTERING)return"fcv3.center_face";if(e.pose<this.t.GUIDE_POSE)return"fcv3.straighten";if(e.exposure<this.t.GUIDE_EXPOSURE)return this.exposureGuidance(t);if(e.sharpness<this.t.GUIDE_SHARPNESS)return"fcv3.steady_camera";if(e.motion<this.t.GUIDE_MOTION)return"fcv3.hold_still";if(r<this.t.Q_GOOD){let s=[["size",this.sizeGuidance()],["centering","fcv3.center_face"],["pose","fcv3.straighten"],["exposure",this.exposureGuidance(t)],["sharpness","fcv3.steady_camera"],["motion","fcv3.hold_still"]],a=s[0];for(let n of s)e[n[0]]<e[a[0]]&&(a=n);return a[1]}return"fcv3.hold_still"}sizeGuidance(){return this.lastSizeDirection==="far"?"fcv3.come_closer":"fcv3.move_back"}exposureGuidance(e){let t=(le[0]+le[1])/2;return e.meanLuma<t?"fcv3.more_light":"fcv3.too_bright"}},o(z,"_"),z),ni=["single","size","centering","pose","exposure","sharpness","motion"];function oi(i){if(i.accepted)return null;if(i.factors.presence<=0)return"no_face";let e="single";for(let t of ni)i.factors[t]<i.factors[e]&&(e=t);return e}o(oi,"ze");var H,lt=(H=class{constructor(){this.blocked={},this.acceptedMs=0,this.ticks=0,this.lastAt=null}record(e){let t=this.lastAt===null?0:Math.max(0,e.at-this.lastAt);this.lastAt=e.at,this.ticks+=1;let r=oi(e);if(r===null){this.acceptedMs+=t;return}let s=this.blocked[r]??{count:0,ms:0};s.count+=1,s.ms+=t,this.blocked[r]=s}summary(){let e={};for(let[t,r]of Object.entries(this.blocked))e[t]={count:r.count,ms:Math.round(r.ms)};return{blocked:e,acceptedMs:Math.round(this.acceptedMs),ticks:this.ticks}}},o(H,"w"),H),li=["obs","manycam","virtual","snap camera","xsplit","droidcam","iriun","camo","fake_device","fake-capture-device"],ci=[/^(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 hi(i){let e=(i??"").trim().toLowerCase();return e.length===0?"unknown":li.some(t=>e.includes(t))?"known_virtual":ci.some(t=>t.test(e))?"platform":"unknown"}o(hi,"Qe");function ct(i){if(typeof i!="function")return!1;try{return/\{\s*\[native code\]\s*\}\s*$/.test(Function.prototype.toString.call(i))}catch{return!1}}o(ct,"Ce");function ui(i=globalThis){return ct(i.navigator?.mediaDevices?.getUserMedia)&&ct(i.MediaStreamTrack?.prototype?.getSettings)}o(ui,"Ye");async function di(i,e=globalThis){let t=e.crypto?.subtle?.digest;if(typeof t=="function")try{let r=new Uint8Array(await t.call(e.crypto?.subtle,"SHA-256",new TextEncoder().encode(i)));return Array.from(r.subarray(0,8),s=>s.toString(16).padStart(2,"0")).join("")}catch{return}}o(di,"je");async function fi(i,e=globalThis){let t={};try{t=typeof i.getSettings=="function"?i.getSettings()??{}:{}}catch{t={}}let r={};if((t.facingMode==="user"||t.facingMode==="environment"||t.facingMode==="left"||t.facingMode==="right")&&(r.facingMode=t.facingMode),typeof t.frameRate=="number"&&Number.isFinite(t.frameRate)&&(r.frameRate=t.frameRate),typeof t.width=="number"&&Number.isFinite(t.width)&&(r.width=t.width),typeof t.height=="number"&&Number.isFinite(t.height)&&(r.height=t.height),typeof t.deviceId=="string"&&t.deviceId.length>0){let a=await di(t.deviceId,e);a!==void 0&&(r.deviceIdHash=a)}let s;try{s=i.label}catch{s=void 0}return{trackSettings:r,capabilitiesPresent:typeof i.getCapabilities=="function",labelClass:hi(s),prototypesIntact:ui(e)}}o(fi,"Se");var fe=o(i=>Math.round(i*100)/100,"U");function pi(i){let e=i,t=typeof e?.requestVideoFrameCallback=="function",r=null,s=null,a=0,n=0,l=0,c=0,h=0,d=0,u=o(()=>{!t||e?.requestVideoFrameCallback===void 0||(r=e.requestVideoFrameCallback((m,w)=>{if(r=null,!t)return;let p=w.presentationTime;if(s!==null){let v=p-s.presentationTimeMs;n+=1;let y=v-l;l+=y/n,c+=y*(v-l)}typeof w.captureTime=="number"&&Number.isFinite(w.captureTime)&&(h+=p-w.captureTime,d+=1),a+=1,s={mediaTimeMs:w.mediaTime*1e3,presentationTimeMs:p},u()}))},"u");return u(),{latest:o(()=>s,"latest"),stats:o(()=>({n:a,meanGapMs:n===0?0:fe(l),stdGapMs:n<2?0:fe(Math.sqrt(c/(n-1))),captureLatencyMs:d===0?null:fe(h/d)}),"stats"),stop:o(()=>{t&&(t=!1,r!==null&&e?.cancelVideoFrameCallback?.(r),r=null)},"stop")}}o(pi,"ke");function mi(i,e,t){return{...i,rvfc:e,rampPainter:t}}o(mi,"_e");var gi=1e3,pe="fcv3.hold_upright",vi=200,me=4,yi=600,wi=1e3,ht={sharpness:1,exposure:1,meanLuma:128};function bi(i,e){return e.width=i.videoWidth,e.height=i.videoHeight,e.getContext("2d").drawImage(i,0,0),new Promise((t,r)=>e.toBlob(s=>s?t(s):r(new Error("empty-keyframe")),"image/jpeg",.92))}o(bi,"rt");function Mi(){return Q()==="phone"}o(Mi,"it");var K,mt=(K=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.openEnvironment=null,this.ramp=null,this.snapshotCanvas=null,this.options=e,this.facing=e.facingMode??"user"}get state(){return this.stateValue}on(e,t){let r=this.handlers.get(e);return r||(r=new Set,this.handlers.set(e,r)),r.add(t),()=>r?.delete(t)}emit(e,t){for(let r of[...this.handlers.get(e)??[]])r(t)}async start(e={}){e.facingMode!==void 0&&(this.facing=e.facingMode),this.attempt+=1,await this.run(this.attempt)}get facingMode(){return this.facing}retry(){this.teardownAttempt(),this.start()}switchCamera(){this.facing=this.facing==="user"?"environment":"user",this.teardownAttempt(),this.start()}restart(e){this.facing=e,this.teardownAttempt(),this.start()}destroy(){this.attempt+=1,this.teardownAttempt(),this.detector?.destroy(),this.detector=null,this.options.video.srcObject=null}async run(e){let{options:t}=this;this.fired=!1,this.lastGuidanceKey=null,this.carriedDegrade=0,this.carriedMeans=[],this.cameraRequestedAt=null,this.cameraReadyAt=null,this.faceAcquiredAt=null,this.captureCompleteAt=null,this.uprightGuard=(t.isPhone??Mi)(),this.setState("preflight");let r=Ne();if(r!=="OK"){this.fail(r==="INSECURE_CONTEXT"?"insecure":"unsupported",{phase:"preflight"});return}this.setState("acquiring");let s=t.getUserMedia??(h=>navigator.mediaDevices.getUserMedia(h)),a;this.cameraRequestedAt=this.now();try{let{facingMode:h,...d}=Se(Ae(),this.facing).video;a=await Ke(this.facing,d,{getUserMedia:s,enumerateDevices:_i(t)})}catch(h){if(e!==this.attempt)return;if(h instanceof He){this.fail("backcamera",{phase:"acquiring",name:j(h)});return}this.fail(We(h),{phase:"acquiring",name:j(h)});return}if(Re(a),ze(a),e!==this.attempt){for(let h of a.getTracks())h.stop();return}this.stream=a;let n=a.getVideoTracks?.()[0];if(this.trackProvenance=n===void 0?null:fi(n).catch(()=>null),this.openEnvironment=n===void 0?null:xe(n).catch(()=>({})),this.facing=Ie(a)??this.facing,t.video.srcObject=a,await t.video.play().catch(()=>{}),e!==this.attempt)return;if(this.cameraReadyAt=this.now(),this.detector===null){let h={v3AssetBaseUrl:t.v3AssetBaseUrl},d=t.createDetector??(t.createWorker!==void 0&&it()?async()=>{try{return await rt.create(t.createWorker(),h)}catch{return x(h)}}:()=>x(h)),u;try{u=await d()}catch(m){e===this.attempt&&this.fail("models",{phase:"models",name:j(m)},m instanceof de?m.fallbackReason:Ti(m));return}if(e!==this.attempt){u.destroy();return}this.detector=u,this.options.telemetry?.({type:"detector",tier:u.tier,fallbackReason:u.fallbackReason})}let l=Xe(),c=t.deviceClass??Ze(l);this.profiler=new Ve(c),this.options.telemetry?.({type:"profile",staticClass:c,activeClass:this.profiler.deviceClass,simd:l.simd}),this.gate=new ot(t.thresholds??{}),this.blockStats=new lt,this.lastGateSnapshotAt=this.now(),t.rankKeyframes?.()&&import("./keyframe-rank-YAJLYJYF-WCA6RPMD.js").then(h=>ge=h,()=>{}),this.setState("positioning"),this.positioningStartedAt=this.now(),this.startScheduler(e)}get animations(){return this.profiler?.profile.animations??"full"}startScheduler(e){let t=this.profiler;if(t===null)return;if(this.scheduler!==null){let s=this.scheduler.stats();this.carriedDegrade+=s.degradeCount,s.meanDetectMs>0&&this.carriedMeans.push(s.meanDetectMs),this.scheduler.stop()}let r=new si({cadenceHz:t.profile.cadenceHz,video:this.options.video,now:this.options.now,run:o(()=>this.detectTick(e),"run")});this.scheduler=r,r.start()}async detectTick(e){let{detector:t,gate:r,profiler:s}=this,a=this.options.video;if(e!==this.attempt||t===null||r===null||s===null||this.fired||a.videoWidth===0)return;if(this.isLandscape()){this.holdUpright(e);return}let n=s.deviceClass,l=this.now(),c=this.options.makeSnapshot?.(a,s.profile.inputWidth)??this.defaultSnapshot(a,s.profile.inputWidth),h=null;try{h=await t.detect(c,a.videoWidth,a.videoHeight)}catch{h=null}if(e!==this.attempt||this.fired)return;s.record(this.now()-l),s.deviceClass!==n&&this.startScheduler(e);let d=h===null?ht:this.options.measureQuality?.(a,h.box)??this.defaultQuality(a,h.box),u=r.tick({timestampMs:this.now(),observation:h,quality:d,frameWidth:a.videoWidth,frameHeight:a.videoHeight});u.accepted&&this.faceAcquiredAt===null&&(this.faceAcquiredAt=u.at),this.blockStats?.record(u),!u.ready&&u.at-this.lastGateSnapshotAt>=gi&&(this.lastGateSnapshotAt=u.at,this.reportGate(!1)),this.emit("checks",{engine:"v3",progress:u.p,q:u.q,factors:u.factors,attempt:e}),u.guidanceKey!==this.lastGuidanceKey&&(this.lastGuidanceKey=u.guidanceKey,this.emit("guidance",{key:u.guidanceKey})),u.ready&&this.stateValue==="positioning"&&(this.fired=!0,this.captureCompleteAt=u.at,this.fire(e))}async fire(e){let{options:t}=this,r=this.scheduler;r?.stop(),this.reportGate(!0);let s=r?.stats()??{degradeCount:0,meanDetectMs:0},a=[...this.carriedMeans,...s.meanDetectMs>0?[s.meanDetectMs]:[]];t.telemetry?.({type:"fired",timeToGateMs:this.now()-this.positioningStartedAt,degradeCount:this.carriedDegrade+s.degradeCount,meanDetectMs:a.length===0?0:a.reduce((_,b)=>_+b,0)/a.length});let n=t.mode??"clip",l=t.rankKeyframes?.()&&ge?ge.default(this,e).catch(()=>this.collectKeyframes(e)):this.collectKeyframes(e);if(n==="photo"){let _=this.watchRotation(e,null),b=await l;if(_(),e!==this.attempt)return;if(b===null){this.fail("generic",{phase:"keyframes"});return}let R=await this.provenance({n:0,meanGapMs:0,stdGapMs:0,captureLatencyMs:null},!1);if(e!==this.attempt)return;this.finishCapture({keyframe:b.blob,previewDataUrl:b.previewDataUrl,...R});return}this.setState("recording");let c=this.stream;if(c===null){this.fail("generic",{phase:"recording"});return}let h=t.screenRamp?.(),d=ee(h),u=null;l.then(_=>{u=_},()=>{});let m=o(()=>{e===this.attempt&&u!==null&&this.emit("frozen",{previewDataUrl:u.previewDataUrl})},"p"),w=Ye(h,pt),p=null,v,y=0;try{let _=this.recordTake(e,c,h,w,void 0).then(S=>S,S=>({failed:S})),[b,R]=await Promise.all([_,l]);if(v=R,e!==this.attempt)return;if("failed"in b){if(b.failed.kind==="cliptoolarge")throw b.failed;st(b.failed.requestedMimeType??"")}else p=b,nt(b.clip,w)?b.clip.stats===null&&st(b.clip.requestedMimeType??""):m();if(p===null||nt(p.clip,w)){y=1,t.telemetry?.({type:"clip_retake",reason:p===null?"error":p.clip.stats===null?"unreadable":"short"});let S=null;try{S=await this.recordTake(e,c,h,w,m)}catch($){if(p===null)throw $}if(e!==this.attempt)return;S!==null&&(p===null||ei(S.clip,p.clip))&&(p=S),S===null&&m()}}catch(_){if(e!==this.attempt)return;let b=_.kind;this.fail(b==="cliptoolarge"?"cliptoolarge":"recorder",{phase:"recording",name:j(_)});return}if(p===null){this.fail("recorder",{phase:"recording"});return}let{clip:g,rvfc:M,report:E,watched:A}=p;if(oe(g.blob)){this.fail("cliptoolarge",{phase:"recording"});return}if(v===null){this.fail("generic",{phase:"keyframes"});return}let I=await this.provenance(M,d,A);e===this.attempt&&this.finishCapture({clip:g.blob,clipMimeType:g.mimeType,...g.stats?{clipStats:g.stats}:{},clipRetakes:y,keyframe:v.blob,previewDataUrl:v.previewDataUrl,...E!==void 0&&E.rendered.length>0?{screenRamp:E}:{},...I})}async recordTake(e,t,r,s,a){let n=this.options.createRecorder?.()??new ti({now:o(()=>this.now(),"now")}),l=pi(this.options.video),c=Qe(r,{paint:o(m=>{(m===null||e===this.attempt)&&this.emit("ramp",{colour:m})},"paint"),now:o(()=>this.now(),"now"),frames:l.latest});this.ramp=c;let h=o(()=>{l.stop(),c.stop(),this.ramp===c&&(this.ramp=null)},"l"),d=this.watchRotation(e,n),u=De();try{return{clip:await n.record(t,a,()=>c.started(this.now()),s,l),rvfc:l.stats(),report:c.report(),watched:u.stop()}}finally{u.stop(),d(),h()}}async provenance(e,t,r={}){let s=this.trackProvenance;if(s===null)return{};let a,n=new Promise(d=>{a=setTimeout(()=>d(null),wi)}),l=await Promise.race([s,n]),c=l===null?null:await Promise.race([this.openEnvironment,n]);if(clearTimeout(a),l===null)return{};let h={...c,...r};return{provenance:{...mi(l,e,t),...Object.keys(h).length>0?{env:h}:{}}}}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!==pe&&(this.lastGuidanceKey=pe,this.emit("guidance",{key:pe}))}watchRotation(e,t){if(!this.uprightGuard)return()=>{};let r=this.options.video,s=o(()=>{if(e!==this.attempt||t!==null&&this.stateValue!=="recording"){l();return}r.videoWidth>0&&this.isLandscape()&&(l(),this.abortRecording(e,t))},"i"),a=setInterval(s,vi);r.addEventListener?.("resize",s);let n=!1;function l(){n||(n=!0,clearInterval(a),r.removeEventListener?.("resize",s))}return o(l,"o"),l}abortRecording(e,t){if(e!==this.attempt)return;this.attempt+=1;let r=this.attempt;try{t?.stop()}catch{}this.ramp?.stop(),this.ramp=null,this.fired=!1,this.captureCompleteAt=null,this.gate=new ot(this.options.thresholds??{}),this.blockStats=new lt,this.lastGateSnapshotAt=this.now(),this.lastGuidanceKey=null,this.setState("positioning"),this.positioningStartedAt=this.now(),this.holdUpright(r),this.startScheduler(r)}async collectKeyframes(e){let t=this.options.captureKeyframe??(a=>this.defaultKeyframe(a)),r=yi/(me-1),s=null;for(let a=0;a<me;a+=1){if(e!==this.attempt)return s;try{let n=await t(this.options.video);(s===null||n.sharpness>s.sharpness)&&(s=n)}catch{}a<me-1&&await ki(r)}return s}finishCapture(e){this.stopTracks(),this.setState("captured");let t=this.captureTiming();this.emit("artifacts",t===void 0?e:{...e,timing:t})}captureTiming(){let e={},t=o((r,s,a)=>{s!==null&&a!==null&&(e[r]=Math.max(0,Math.round(a-s)))},"t");return t("cameraReadyMs",this.cameraRequestedAt,this.cameraReadyAt),t("faceAcquireMs",this.cameraReadyAt,this.faceAcquiredAt),t("captureMs",this.faceAcquiredAt,this.captureCompleteAt),Object.keys(e).length>0?e:void 0}async defaultKeyframe(e){let t=document.createElement("canvas"),r=await(this.facing==="user"?ri:bi)(e,t),s=t.toDataURL("image/jpeg",.92);return{blob:r,previewDataUrl:s,sharpness:this.centerSharpness(e)}}defaultSnapshot(e,t){try{let r=this.snapshotCanvas??document.createElement("canvas"),s=t/Math.max(1,e.videoWidth),a=Math.max(1,Math.round(e.videoWidth*s)),n=Math.max(1,Math.round(e.videoHeight*s)),l=r.getContext("2d");return l===null?e:(r.width!==a&&(r.width=a),r.height!==n&&(r.height=n),l.drawImage(e,0,0,a,n),this.snapshotCanvas=r,r)}catch{return e}}defaultQuality(e,t){let r=ut(e,t,96);return r===null?ht:{sharpness:ce(r),exposure:$e(r),meanLuma:je(r)}}centerSharpness(e){let t=te(e),r=ut(e,{x:t.width*.25,y:t.height*.25,width:t.width*.5,height:t.height*.5},96);return r===null?0:ce(r)}teardownAttempt(){this.scheduler?.stop(),this.scheduler=null,this.reportGate(!0),this.gate=null,this.ramp?.stop(),this.ramp=null,this.stopTracks()}reportGate(e){let t=this.blockStats,r=this.profiler;if(t===null||r===null)return;let s=t.summary();e&&(this.blockStats=null),s.ticks!==0&&this.options.telemetry?.({type:"gate",final:e,activeClass:r.deviceClass,cadenceHz:r.profile.cadenceHz,...s})}stopTracks(){if(this.stream!==null){for(let e of this.stream.getTracks())e.stop();this.stream=null}}fail(e,t,r){this.scheduler?.stop(),this.reportGate(!0),this.stopTracks(),this.setState("error"),this.options.telemetry?.({type:"error",kind:e,fallbackReason:r});let{phase:s,name:a}=t;this.emit("error",{kind:e,retryable:e!=="insecure"&&e!=="unsupported",detail:a===void 0?{phase:s}:{phase:s,name:a}})}setState(e){this.stateValue=e,this.emit("statechange",{state:e})}now(){return this.options.now?.()??performance.now()}},o(K,"Ie"),K),ge;function ki(i){return new Promise(e=>setTimeout(e,i))}o(ki,"nt");function Ti(i){return i instanceof Error?i.message:String(i)}o(Ti,"at");function ut(i,e,t){try{let r=document.createElement("canvas"),s=t/Math.max(1,e.width);r.width=Math.max(1,Math.round(e.width*s)),r.height=Math.max(1,Math.round(e.height*s));let a=r.getContext("2d");return a===null?null:(a.drawImage(i,e.x,e.y,e.width,e.height,0,0,r.width,r.height),a.getImageData(0,0,r.width,r.height))}catch{return null}}o(ut,"Re");function _i(i){if(i.enumerateDevices!==void 0)return i.enumerateDevices;if(i.getUserMedia===void 0&&!(typeof navigator>"u"||typeof navigator.mediaDevices?.enumerateDevices!="function"))return()=>navigator.mediaDevices.enumerateDevices()}o(_i,"st");var Ei=12e4,gt=13e4,Si=3e3,Ai=1200,ve=Symbol.for("@sekyro/web.preload.v1");function we(){let i=globalThis;return i[ve]??(i[ve]=new Map),i[ve]}o(we,"h");function re(i){let e=(i??ue).replace(/\/+$/,"");return e===""?"/":e}o(re,"b");function yt(i){let e=we(),t=e.get(i);return t===void 0&&(t={status:"idle",promise:null,scheduled:null,detectorPromise:null,detector:null,listeners:new Set},e.set(i,t)),t}o(yt,"ae");function ye(i,e){if(i.status!==e){i.status=e;for(let t of[...i.listeners])t(e)}}o(ye,"k");var Ii=o(i=>x({preferred:["blaze"],v3AssetBaseUrl:i,blazeInitTimeoutMs:Ei}),"K"),xi=Ii;function Di(){return typeof window<"u"&&typeof navigator<"u"&&typeof navigator.mediaDevices?.getUserMedia=="function"}o(Di,"Ce");function Ri(){return navigator.connection?.saveData===!0}o(Ri,"Se");function Ci(i){let e=window;if(typeof e.requestIdleCallback=="function"){let r=e.requestIdleCallback(i,{timeout:Si});return()=>e.cancelIdleCallback?.(r)}let t=setTimeout(i,Ai);return()=>clearTimeout(t)}o(Ci,"Ee");function Oi(i,e){let t,r=new Promise(l=>{t=l}),s=!1,a=o(()=>{},"u"),n={promise:r,settle:o(l=>{s||(s=!0,a(),i.scheduled===n&&(i.scheduled=null),t(l))},"settle")};return i.scheduled=n,a=Ci(()=>{s||n.settle(be(i,e))}),r}o(Oi,"ye");function be(i,e){if((i.status==="loading"||i.status==="ready")&&i.promise!==null)return i.promise;ye(i,"loading");let t=new Promise(n=>n(xi(e)));i.detectorPromise=t;let r,s=new Promise((n,l)=>{r=setTimeout(()=>{t.then(c=>c.destroy(),()=>{}),l(new Error(`detector preload exceeded ${gt} ms`))},gt)}),a=Promise.race([t,s]).then(n=>i.detectorPromise!==t?(n.destroy(),i.status):(i.detector=n,ye(i,"ready"),"ready"),n=>(i.detectorPromise===t&&(i.detectorPromise=null,i.detector=null,ye(i,"failed"),console.warn("[@sekyro/web] face-detector preload failed:",n)),i.status)).finally(()=>clearTimeout(r));return i.promise=a,i.scheduled?.settle(a),a}o(be,"U");function hr(i={}){if(!Di())return Promise.resolve("idle");let e=re(i.assetBaseUrl),t=yt(e);return i.respectSaveData===!0&&Ri()?Promise.resolve(t.status):(t.status==="loading"||t.status==="ready")&&t.promise!==null?t.promise:i.idle===!0?t.scheduled?.promise??Oi(t,e):be(t,e)}o(hr,"xe");function ur(i){return we().get(re(i))?.status??"idle"}o(ur,"Fe");function dr(i,e){let t=yt(re(e));return t.listeners.add(i),()=>{t.listeners.delete(i)}}o(dr,"Ie");function Pi(i){return{get tier(){return i.tier},get fallbackReason(){return i.fallbackReason},detect:o((...e)=>i.detect(...e),"detect"),destroy:o(()=>{},"destroy")}}o(Pi,"Le");function Gi(i){let e=re(i),t=we().get(e);if(!(t===void 0||t.detector===null&&t.detectorPromise===null&&t.scheduled===null))return async()=>{t.scheduled!==null&&be(t,e);let r=t.promise;for(;t.detector===null&&r!==null&&(await r,t.promise!==r);)r=t.promise;return t.detector!==null?Pi(t.detector):x({v3AssetBaseUrl:e})}}o(Gi,"de");var Ui=new Set(["inuse","overconstrained","notfound"]),Fi=[500,1500];function Ni(i){switch(i){case"fcv3.no_face":case"fcv3.center_face":case"fcv3.straighten":return"center";case"fcv3.come_closer":return"closer";case"fcv3.move_back":return"farther";case"fcv3.more_light":case"fcv3.too_bright":return"light";case"fcv3.hold_still":case"fcv3.steady_camera":return"still";case"fcv3.hold_upright":return"upright";case"fcv3.one_face":return"one_face";default:return null}}o(Ni,"Ae");function Li(i){switch(i){case"preflight":case"acquiring":return"starting";case"positioning":return"gating";default:return i}}o(Li,"Pe");function vt(i){switch(i){case"permission":case"notfound":case"inuse":case"insecure":case"unsupported":return i;case"backcamera":return"notfound";default:{let e=i;return"generic"}}}o(vt,"ue");function Bi(i,e,t){if(t===void 0)return{kind:vt(i),retryable:e};let r=qe(t.name);return{kind:vt(i),retryable:e,detail:{...r!==void 0?{name:r}:{},phase:t.phase,engineKind:i}}}o(Bi,"we");var qi=new Set(["captured","uploading","checking"]);function Wi(i,e={},t,r=()=>"self",s=()=>{},a){let n=e.now??(()=>performance.now()),l=e.canChooseFacing??Oe,c="user",h=Pe(),d=r(),u=Ce(),m=!Le(),w=e.engineOptions,p=w?.createDetector===void 0&&w?.createWorker===void 0?{createDetector:o(()=>{let f=Gi(i.assetBaseUrl);return f!==void 0?f():x({v3AssetBaseUrl:i.assetBaseUrl})},"createDetector")}:{},v={video:i.video,mode:m?"photo":"clip",rankKeyframes:t,facingMode:void 0,v3AssetBaseUrl:i.assetBaseUrl,screenRamp:o(()=>d==="self"&&u.count("ramp")>0?s():void 0,"screenRamp"),...e.engineOptions??{},...p},y=e.createEngine?.(v)??new mt(v),g="idle",M=null,E=0,A=!1,I="full",_=null,b=null,R=0,S=0,$=o(()=>{i.video.videoWidth>0&&i.video.videoHeight>0&&(R=i.video.videoWidth,S=i.video.videoHeight)},"W"),Me=Ge({enabled:i.keepScreenAwake!==!1}),X=o(f=>{g=f,Me.setActive(f==="starting"||f==="gating"||f==="recording"),u.emit("state",f)},"S"),se=o(()=>u.emit("gate",{progress:E,hint:M,faceDetected:A}),"F"),ae=o(()=>{let f=y.animations??"full";f!==I&&(I=f,u.emit("profile",{animations:I}))},"I"),G=0,Y=null,wt=e.schedule??((f,k)=>{let T=setTimeout(f,k);return()=>clearTimeout(T)}),Z=o(()=>{Y?.(),Y=null},"E"),bt=o((f,k)=>{if(V||!Ui.has(f)||k?.phase!=="acquiring")return!1;let T=Fi[G];return T===void 0?!1:(G+=1,Z(),Y=wt(()=>{Y=null,V||y.retry()},T),!0)},"fe"),Mt=[y.on("statechange",({state:f})=>{if(f==="error")return;let k=Li(f);k==="gating"&&(G=0),k==="starting"&&g!=="starting"&&(M=null,E=0,A=!1,_=null,b=null,R=0,S=0),X(k),ae(),k==="recording"&&($(),_=n(),M="hold",E=1,se())}),y.on("checks",f=>{$(),E=f.progress,A=f.factors.presence>0,se(),ae()}),y.on("guidance",({key:f})=>{M=Ni(f),se()}),y.on("frozen",({previewDataUrl:f})=>{b=n(),u.emit("frozen",{previewDataUrl:f})}),y.on("ramp",f=>u.emit("ramp",f)),y.on("artifacts",f=>{if(g!=="captured")return;let k=Q(),T=f.clipStats,_e=T!==void 0?Math.round(T.durationMs):_!==null&&b!==null?Math.max(0,Math.round(b-_)):void 0,Ee=T!==void 0&&T.frames>1&&T.durationMs>0?Math.round(T.frames*1e4/T.durationMs)/10:void 0;u.emit("captured",{keyframe:f.keyframe,...f.clip!==void 0?{clip:f.clip}:{},...f.clipMimeType!==void 0?{clipMime:f.clipMimeType}:{},width:i.video.videoWidth||R,height:i.video.videoHeight||S,..._e!==void 0?{clipMs:_e}:{},...T!==void 0?{clipFrames:T.frames}:{},...Ee!==void 0?{fps:Ee}:{},...f.clipRetakes!==void 0?{clipRetakes:f.clipRetakes}:{},...f.clipMimeType!==void 0?{codec:ft(f.clipMimeType)}:{},captureChannel:k==="desktop"?"desktop":"mobile",formFactor:k,...m?{degraded:"NO_RECORDER"}:{},engine:"v3",facingMode:y.facingMode,mode:d,...f.timing,...f.screenRamp!==void 0?{screenRamp:f.screenRamp}:{},...f.provenance!==void 0?{provenance:f.provenance}:{}})}),y.on("error",({kind:f,retryable:k,detail:T})=>{f==="backcamera"&&kt()||bt(f,T)||(X("error"),ae(),u.emit("error",Bi(f,k,T)))})],ke=!1;function kt(){return V||ke||d!=="assisted"||a===void 0||a.session()!=="choice"?!1:(ke=!0,a.onModeChange("self"),d="self",c=ne("self"),X("mode_switch"),y.restart(c),!0)}o(kt,"me");let Te=o(async()=>a!==void 0&&a.session()==="choice"&&await l().catch(()=>!1),"$"),V=!1;return{handle:{get state(){return g},get captureMode(){return r()},get facingMode(){return y.facingMode??c},on:o((f,k)=>u.on(f,k),"on"),start:o(f=>(d=r(),h.facing(d,i.facing),c=h.facing(d,f?.facing),Z(),G=0,y.start({facingMode:c})),"start"),retry:o(()=>{Z(),G=0,y.retry()},"retry"),switchCamera:o(()=>h.refuseSwitch(r()),"switchCamera"),canSwitchCaptureMode:Te,setCaptureMode:o(async f=>{if(f===r()||!await Te()||V||qi.has(g)||a===void 0)return!1;a.onModeChange(f),d=f;let k=ne(f);return c=k,g==="idle"||(X("mode_switch"),Z(),G=0,y.restart(k)),!0},"setCaptureMode"),destroy:o(()=>{V=!0,Z();for(let f of Mt)f();Me.setActive(!1),y.destroy(),u.clear()},"destroy")},setFlowState:o(f=>{g!==f&&X(f)},"setFlowState")}}o(Wi,"De");function fr(i){return Wi(i).handle}o(fr,"Ze");export{zi as a,ee as b,hr as c,ur as d,dr as e,Bi as f,Wi as g,fr as h};
@@ -1 +1 @@
1
- import{b,t as r,v as l,y as o}from"./chunk-KU3B6BDD.js";import{a as i}from"./chunk-5QL6W6FW.js";import{a,c as p}from"./chunk-4FHWXBOB.js";var s=p(b(),1);function f({tone:d,icon:n,busy:c,title:m,titleId:e,children:u,actions:t,live:y,testId:h}){let k=r();return(0,s.jsxs)("section",{className:"sekyro-step sekyro-status",...e!==void 0?{"aria-labelledby":e}:{},...y?{role:"status","aria-live":"polite"}:{},"data-testid":h,children:[(0,s.jsxs)("div",{className:"sekyro-status__body",children:[(0,s.jsx)("span",{className:`sekyro-tile sekyro-tile--${d}${c?" is-busy":""}`,"aria-hidden":"true",children:(0,s.jsx)(l,{name:n})}),(0,s.jsxs)("div",{className:"sekyro-heading sekyro-status__text",children:[(0,s.jsx)("h2",{id:e,ref:k,tabIndex:-1,className:"sekyro-text-body",children:m}),u]})]}),t!=null&&t!==!1?(0,s.jsx)(o,{children:t}):null]})}a(f,"g");i(f,"StatusPage");export{f as a};
1
+ import{b,t as r,v as l,y as o}from"./chunk-LPLPMWHJ.js";import{a as i}from"./chunk-5QL6W6FW.js";import{a,c as p}from"./chunk-4FHWXBOB.js";var s=p(b(),1);function f({tone:d,icon:n,busy:c,title:m,titleId:e,children:u,actions:t,live:y,testId:h}){let k=r();return(0,s.jsxs)("section",{className:"sekyro-step sekyro-status",...e!==void 0?{"aria-labelledby":e}:{},...y?{role:"status","aria-live":"polite"}:{},"data-testid":h,children:[(0,s.jsxs)("div",{className:"sekyro-status__body",children:[(0,s.jsx)("span",{className:`sekyro-tile sekyro-tile--${d}${c?" is-busy":""}`,"aria-hidden":"true",children:(0,s.jsx)(l,{name:n})}),(0,s.jsxs)("div",{className:"sekyro-heading sekyro-status__text",children:[(0,s.jsx)("h2",{id:e,ref:k,tabIndex:-1,className:"sekyro-text-body",children:m}),u]})]}),t!=null&&t!==!1?(0,s.jsx)(o,{children:t}):null]})}a(f,"g");i(f,"StatusPage");export{f as a};