@sekyro/elements 0.1.0-rc.0 → 0.1.0-rc.1

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 (81) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/cdn/chunks/{capture-session-doc-K6LVXAGQ-SY3B27LY.js → capture-session-doc-ELX6VK6Z-SDM3ILRA.js} +1 -1
  3. package/dist/cdn/chunks/{chunk-2ZVKLBJD.js → chunk-36WGD7QV.js} +1 -1
  4. package/dist/cdn/chunks/chunk-5FLR7RPJ.js +1 -0
  5. package/dist/cdn/chunks/{chunk-TCW6XNLI.js → chunk-6H22RNSK.js} +1 -1
  6. package/dist/cdn/chunks/{chunk-C66GZ7NN.js → chunk-7Y73DZJB.js} +1 -1
  7. package/dist/cdn/chunks/{chunk-3VYQXVW4.js → chunk-BF6SE2AC.js} +1 -1
  8. package/dist/cdn/chunks/{chunk-YMGCOMYZ.js → chunk-BZ37D4FR.js} +1 -1
  9. package/dist/cdn/chunks/{chunk-KPGTFHQU.js → chunk-CFJJD6T2.js} +1 -1
  10. package/dist/cdn/chunks/{chunk-OIJVTJML.js → chunk-CYGAKCKG.js} +1 -1
  11. package/dist/cdn/chunks/{chunk-2SENV5CV.js → chunk-FCTRNWRU.js} +1 -1
  12. package/dist/cdn/chunks/{chunk-6MEPT5ZS.js → chunk-FDWO4KXK.js} +1 -1
  13. package/dist/cdn/chunks/{chunk-Z3EEB4CI.js → chunk-FEWP7HBJ.js} +1 -1
  14. package/dist/cdn/chunks/{chunk-7XAIG23G.js → chunk-HQF66Y6S.js} +1 -1
  15. package/dist/cdn/chunks/{chunk-XYQGAQBQ.js → chunk-KLE75SX4.js} +1 -1
  16. package/dist/cdn/chunks/{chunk-OBPBHX2J.js → chunk-LYYAVERP.js} +1 -1
  17. package/dist/cdn/chunks/chunk-PUO2VWDE.js +33 -0
  18. package/dist/cdn/chunks/chunk-U3UDWPBG.js +1 -0
  19. package/dist/cdn/chunks/chunk-X3BGM3B2.js +1 -0
  20. package/dist/cdn/chunks/{chunk-UYAVCSQ4.js → chunk-YWPZG2MZ.js} +1 -1
  21. package/dist/cdn/chunks/{chunk-IFGPCCJH.js → chunk-ZIC5GEH2.js} +1 -1
  22. package/dist/cdn/chunks/{chunk-HODE7UDG.js → chunk-ZKLSZJFN.js} +1 -1
  23. package/dist/cdn/chunks/{create-document-capture-LNX6NFSK-A4LP25Y5.js → create-document-capture-UHZJUZHC-YYZNCSW6.js} +1 -1
  24. package/dist/cdn/chunks/{document-capture-view-JIKJWCFG-MMCEL43X.js → document-capture-view-JE6IX4IE-2454PW6Z.js} +1 -1
  25. package/dist/cdn/chunks/{eid-view-IW2ZP2NG-EB5SCHBD.js → eid-view-RZS6MLT6-35VSHTV3.js} +1 -1
  26. package/dist/cdn/chunks/{email-otp-view-VDTMZ4R5-Y5QHQDIB.js → email-otp-view-WUQ5OGDD-YDSUKAN2.js} +1 -1
  27. package/dist/cdn/chunks/flow-views-5L7JF3MM-M6C3RXSX.js +1 -0
  28. package/dist/cdn/chunks/overlay-de-JQ2FDZBA-HLFTXIF6.js +1 -0
  29. package/dist/cdn/chunks/overlay-es-WDYRSRHH-UXHTYCHD.js +1 -0
  30. package/dist/cdn/chunks/overlay-pt-AQMDWDWX-BD7TO6Y4.js +1 -0
  31. package/dist/cdn/chunks/plan-runner-ZHOYMRAO-RDS523K5.js +1 -0
  32. package/dist/cdn/chunks/{portrait-capture-view-LWESDZPM-SEOHMLJQ.js → portrait-capture-view-GQIBQY4U-TJUYRCTI.js} +1 -1
  33. package/dist/cdn/chunks/{portrait-review-view-FU3QSO4K-DZHDIMQX.js → portrait-review-view-XOQYQNU7-LPONGGFW.js} +1 -1
  34. package/dist/cdn/define.js +1 -1
  35. package/dist/cdn/index.js +1 -1
  36. package/dist/{chunk-HSQWGTF7.js → chunk-6NQ7EWA4.js} +1 -1
  37. package/dist/{chunk-JJNFGW3A.js → chunk-72JW2LCH.js} +1 -1
  38. package/dist/{chunk-X5WMOOH2.js → chunk-7URX73UH.js} +1 -1
  39. package/dist/{chunk-W2UTL5PI.js → chunk-AGPBG22V.js} +1 -1
  40. package/dist/{chunk-UT2KIR2K.js → chunk-B6A5RXN4.js} +1 -1
  41. package/dist/chunk-EIRNIJXL.js +1 -0
  42. package/dist/{chunk-WWGJDMZQ.js → chunk-ESSKMX7I.js} +1 -1
  43. package/dist/{chunk-KU4DZ3OQ.js → chunk-IBPUWYHJ.js} +1 -1
  44. package/dist/{chunk-OSBGOI4W.js → chunk-IGC6OQZ2.js} +1 -1
  45. package/dist/{chunk-JQ3ANVKN.js → chunk-QE2B3MSJ.js} +1 -1
  46. package/dist/{chunk-X5K27NXI.js → chunk-RMV3BNWO.js} +1 -1
  47. package/dist/{chunk-4QI2LTJD.js → chunk-XEY5ANJ6.js} +1 -1
  48. package/dist/chunk-ZDF5JILV.js +33 -0
  49. package/dist/define.cjs +5 -5
  50. package/dist/define.js +1 -1
  51. package/dist/{document-capture-view-JIKJWCFG-OWMTF5A3.js → document-capture-view-JE6IX4IE-5HJYAEDX.js} +1 -1
  52. package/dist/{eid-view-IW2ZP2NG-SKEYTRTX.js → eid-view-RZS6MLT6-2W2T3AWK.js} +1 -1
  53. package/dist/{email-otp-view-VDTMZ4R5-EO7T6SL4.js → email-otp-view-WUQ5OGDD-NGI6PBX3.js} +1 -1
  54. package/dist/flow-views-5L7JF3MM-P55CCCOH.js +1 -0
  55. package/dist/index.cjs +5 -5
  56. package/dist/index.d.cts +16 -0
  57. package/dist/index.d.ts +16 -0
  58. package/dist/index.js +1 -1
  59. package/dist/overlay-de-JQ2FDZBA-FR25JPE4.js +1 -0
  60. package/dist/overlay-es-WDYRSRHH-PFDMX5D2.js +1 -0
  61. package/dist/overlay-pt-AQMDWDWX-LTD4N2DW.js +1 -0
  62. package/dist/{portrait-capture-view-LWESDZPM-XZOM6LXG.js → portrait-capture-view-GQIBQY4U-AFPEUDLY.js} +1 -1
  63. package/dist/{portrait-review-view-FU3QSO4K-AGWEX2EQ.js → portrait-review-view-XOQYQNU7-IPKAZBP6.js} +1 -1
  64. package/dist/styles.css +5 -1
  65. package/package.json +2 -2
  66. package/dist/cdn/chunks/chunk-3KIFGAEK.js +0 -1
  67. package/dist/cdn/chunks/chunk-562ANROG.js +0 -1
  68. package/dist/cdn/chunks/chunk-YEPHU5PX.js +0 -1
  69. package/dist/cdn/chunks/chunk-ZKEOHGBY.js +0 -33
  70. package/dist/cdn/chunks/flow-views-N4FMOYIR-FDN6ATHN.js +0 -1
  71. package/dist/cdn/chunks/overlay-de-F7GCMCGJ-FBTP3BSM.js +0 -1
  72. package/dist/cdn/chunks/overlay-es-HIO7CIKS-GDHVHUQW.js +0 -1
  73. package/dist/cdn/chunks/overlay-pt-YC4HRHKL-J3TGRZRW.js +0 -1
  74. package/dist/cdn/chunks/plan-runner-DIRERYBF-FANNXQNO.js +0 -1
  75. package/dist/chunk-43YHL2WG.js +0 -1
  76. package/dist/chunk-73JRPFCO.js +0 -33
  77. package/dist/flow-views-N4FMOYIR-J54ADNRO.js +0 -1
  78. package/dist/overlay-de-F7GCMCGJ-7OI7SGX4.js +0 -1
  79. package/dist/overlay-es-HIO7CIKS-LXC2SFGY.js +0 -1
  80. package/dist/overlay-pt-YC4HRHKL-2QCRICEV.js +0 -1
  81. package/sbom.cdx.json +0 -153
@@ -1 +1 @@
1
- import{d as Et,e as Bt,f as Wt,g as qt}from"./chunk-TCW6XNLI.js";import{a as it,b as zt,c as rt,d as Ht}from"./chunk-UZWMCNZI.js";import{a as kt,b as V,c as Tt,d as _t,e as St,g as At,h as tt,i as It,j as xt,k as Nt,l as Lt}from"./chunk-D334IAZJ.js";import{a as Dt,b as Rt,c as Ct,d as Ot,e as Pt,f as et,g as K,h as Gt,i as Ut,j as Ft}from"./chunk-RRLXNT33.js";import{a as o}from"./chunk-4FHWXBOB.js";var me=1e4,C,pe=(C=class{constructor(t,e){this.tier="blaze",this.inner=t,e!==void 0&&(this.fallbackReason=e)}static async create(t,e){let r=await import("./vision_bundle-WBHR7TEE.js"),s=await r.FilesetResolver.forVisionTasks(t),a=await r.FaceDetector.createFromOptions(s,{baseOptions:{modelAssetPath:`${t}/blaze_face_short_range.tflite`,delegate:"CPU"},runningMode:"IMAGE"});return new C(a,e)}async detect(t,e,r){let s;try{s=this.inner.detect(t).detections}catch{return null}let a=ge(s);if(a?.boundingBox===void 0)return null;let n=Z(t),l=ve(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:Kt(s.map(d=>d.boundingBox??{width:0,height:0}),s.indexOf(a))};return Xt(h,t,e,r)}destroy(){try{this.inner.close()}catch{}}},o(C,"t"),C);function ge(i){let t,e=-1;for(let r of i){let s=r.categories[0]?.score??0;s>e&&(t=r,e=s)}return t}o(ge,"R");function ve(i,t){let e=i?.[0],r=i?.[1];if(e===void 0||r===void 0)return;let s=o(l=>({x:l.x*t.width,y:l.y*t.height}),"n"),[a,n]=[s(e),s(r)];return a.x<=n.x?{left:a,right:n}:{left:n,right:a}}o(ve,"T");function ye(){if(typeof OffscreenCanvas=="function")return new OffscreenCanvas(2,2);let i=document.createElement("canvas");return i.width=2,i.height=2,i}o(ye,"E");var we=4;async function be(){let i=globalThis.FaceDetector;if(typeof i!="function")return{ok:!1,reason:"unsupported"};try{let t=new i({fastMode:!0,maxDetectedFaces:we});return await t.detect(ye()),{ok:!0,instance:t}}catch(t){return{ok:!1,reason:`smoke_failed:${t instanceof Error?t.message:String(t)}`}}}o(be,"w");var P,Me=(P=class{constructor(t,e){this.tier="native",this.inner=t,e!==void 0&&(this.fallbackReason=e)}async detect(t,e,r){let s;try{s=await this.inner.detect(t)}catch{return null}let a=s.map(d=>d.boundingBox),n=-1;a.forEach((d,u)=>{let v=a[n];(v===void 0||d.width*d.height>v.width*v.height)&&(n=u)});let l=s[n];if(l===void 0)return null;let c=ke(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:Kt(a,n)};return Xt(h,t,e,r)}destroy(){}},o(P,"b"),P);function ke(i){if(i===void 0)return;let t=i.filter(s=>s.type==="eye").map(s=>s.locations[0]).filter(s=>s!==void 0),[e,r]=t;if(!(e===void 0||r===void 0))return e.x<=r.x?{left:e,right:r}:{left:r,right:e}}o(ke,"S");var Te=.25;function Kt(i,t){let e=i[t],r=e===void 0?0:e.width*e.height;if(!(r>0))return 0;let s=0;return i.forEach((a,n)=>{n!==t&&a.width*a.height>=Te*r&&(s+=1)}),s}o(Kt,"f");var at="/models-v3",_e=["native","blaze"],G,nt=(G=class extends Error{constructor(t){super(`no detector tier available (${t})`),this.name="DetectorLadderError",this.fallbackReason=t}},o(G,"x"),G);function Z(i){let t=i;if(typeof t.videoWidth=="number"&&t.videoWidth>0)return{width:t.videoWidth,height:t.videoHeight??0};if(typeof t.naturalWidth=="number"&&t.naturalWidth>0)return{width:t.naturalWidth,height:t.naturalHeight??0};let e=typeof t.width=="number"?t.width:0,r=typeof t.height=="number"?t.height:0;return{width:e,height:r}}o(Z,"y");function Xt(i,t,e,r){let s=Z(t),a=s.width>0?e/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(Xt,"h");function Ee(i){return i instanceof Error?i.message:String(i)}o(Ee,"C");async function x(i){let t=i.preferred??_e,e=[];for(let r of t){if(r==="native"){let s=await be();if(s.ok)return new Me(s.instance,st(e));e.push(`native:${s.reason}`);continue}try{return await Se(pe.create(i.v3AssetBaseUrl??at,st(e)),i.blazeInitTimeoutMs??me)}catch(s){e.push(s instanceof Vt?"blaze:blaze_init_timeout":`blaze:${Ee(s)}`)}}throw new nt(st(e)??"no_tier_available")}o(x,"O");function st(i){return i.length>0?i.join("; "):void 0}o(st,"v");var U,Vt=(U=class extends Error{},o(U,"g"),U);function Se(i,t){return new Promise((e,r)=>{let s=setTimeout(()=>{r(new Vt(`init exceeded ${t}ms`)),i.then(a=>a.destroy(),()=>{})},t);i.then(a=>{clearTimeout(s),e(a)},a=>{clearTimeout(s),r(a)})})}o(Se,"W");var R=1;function Zt(){return typeof OffscreenCanvas=="function"&&typeof createImageBitmap=="function"&&typeof Worker=="function"}o(Zt,"K");function Ae(i,t={}){let e=t.createDetector??x,r=null;i.onmessage=s=>{let a=s.data;if(a.v!==R){a.bitmap?.close?.();return}if(a.type==="init"){e(a.options).then(n=>{r=n;let l={v:R,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:R,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(Ae,"B");typeof self<"u"&&typeof self.importScripts=="function"&&Ae(self);var O,jt=(O=class{constructor(t,e){this.pending=new Map,this.nextId=1,this.worker=t,this.tier=e.tier,e.fallbackReason!==void 0&&(this.fallbackReason=e.fallbackReason),t.addEventListener("message",r=>{let s=r.data;if(s.v!==R||s.type!=="result")return;let a=this.pending.get(s.id);this.pending.delete(s.id),a?.(s.observation)})}static create(t,e,r=1e4){return new Promise((s,a)=>{let n=setTimeout(()=>{t.removeEventListener("message",l),t.terminate(),a(new Error(`worker detector not ready within ${r}ms`))},r),l=o(h=>{let d=h.data;d.v!==R||d.type!=="ready"||(clearTimeout(n),t.removeEventListener("message",l),s(new O(t,d)))},"s");t.addEventListener("message",l);let c={v:R,type:"init",options:e};t.postMessage(c)})}async detect(t,e,r){let s;try{typeof ImageBitmap<"u"&&t instanceof ImageBitmap?s=t:typeof createImageBitmap=="function"?s=await createImageBitmap(t):s=t}catch{return null}let a=this.nextId;return this.nextId+=1,new Promise(n=>{this.pending.set(a,n);let l={v:R,type:"detect",id:a,bitmap:s,streamWidth:e,streamHeight:r};this.worker.postMessage(l,[s])})}destroy(){for(let t of this.pending.values())t(null);this.pending.clear(),this.worker.terminate()}},o(O,"t"),O);var Ie=[...Dt.filter(i=>i.startsWith("video/mp4")),"video/webm;codecs=h264","video/webm;codecs=avc1","video/webm;codecs=vp8","video/webm;codecs=vp9","video/webm"],se=new Set;function xe(i){let t=/(?:Chrome|Chromium)\/(\d+)\./.exec(i??"");return t?Number(t[1]):null}o(xe,"De");function De(i=Ce(),t=globalThis.navigator?.userAgent){if(i===void 0)return"";let e=xe(t)===126;for(let r of Ie)if(!(se.has(r)||e&&r.startsWith("video/mp4")))try{if(i(r))return r}catch{}return""}o(De,"he");function $t(i){i!==""&&se.add(i)}o($t,"F");function Re(i){return i.replace(/^video\/x-matroska/i,"video/webm")}o(Re,"fe");function ae(i){let t=/codecs=["']?([^,;"']+)/i.exec(i);return t?t[1].trim():i.split(";")[0].trim()}o(ae,"ut");function Ce(){let i=globalThis.MediaRecorder;return i&&typeof i.isTypeSupported=="function"?t=>i.isTypeSupported(t):void 0}o(Ce,"Oe");var ne=2500,Oe=1e3,Pe=1500,Yt=25e5,Ge=100,Ue=700,Fe=20,Ne=1500,j=null;function Le(){return j??(j=import("./clip-inspect-HZ7N2YOP-DCDXB76T.js").catch(i=>{throw j=null,i})),j.catch(()=>null)}o(Le,"Ne");var N,D=(N=class extends Error{constructor(t,e){super(e??t),this.kind=t}},o(N,"S"),N),Be=100;function Qt(i,t){return i.stats===void 0?!1:i.stats===null?!0:i.stats.durationMs<t-Be}o(Qt,"U");function We(i,t){return i.stats?t.stats?i.stats.durationMs>t.stats.durationMs:!0:!1}o(We,"ge");var L,qe=(L=class{constructor(t={}){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=t.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(t,e,r,s=ne,a){let n=De(),l=Le();return this.recordRaw(t,e,r,s,a,n).then(c=>ze(c,l),c=>{throw c instanceof D&&(c.requestedMimeType=n),c})}recordRaw(t,e,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=t,new Promise((l,c)=>{let h;try{h=new MediaRecorder(t,n?{mimeType:n,videoBitsPerSecond:Yt}:{videoBitsPerSecond:Yt})}catch{try{h=new MediaRecorder(t)}catch{c(new D("unsupported"));return}}this.recorder=h;let d=o(p=>{this.settled||(this.settled=!0,this.clearTimers(),p())},"d"),u=o(()=>d(()=>{let p=Re(h.mimeType||n||Rt),M=new Blob(this.chunks,{type:p});if(M.size===0){c(new D("generic","empty clip"));return}if(et(M)){c(new D("cliptoolarge"));return}l({blob:M,mimeType:p,requestedMimeType:n})}),"u");h.ondataavailable=p=>{p.data&&p.data.size&&(this.chunks.push(p.data),this.bytes+=p.data.size,this.bytes>Pt&&d(()=>{try{h.state!=="inactive"&&h.stop()}catch{}c(new D("cliptoolarge"))}))},h.onstop=u,h.onerror=()=>d(()=>c(new D("generic")));let v=this.now();if(r!==void 0||a!==void 0){let p=!1;h.onstart=()=>{if(!(p||this.settled)&&(p=!0,v=this.now(),r!==void 0))try{r()}catch{}}}try{h.start(Oe)}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||e?.(),h.state!=="inactive"){try{h.stop()}catch{u()}this.graceTimer=setTimeout(u,Pe)}else u()},"v"),m=this.now();if(a===void 0){this.hardStopTimer=setTimeout(w,s);return}let g=null,y=!1;this.hardStopTimer=setTimeout(w,s+Ue),this.pollTimer=setInterval(()=>{if(this.settled||y)return;let p=null;try{p=a.latest()}catch{p=null}let M=p?.presentationTimeMs;M!==void 0&&Number.isFinite(M)&&M>=v&&g===null&&(g=M);let T=g!==null&&M!==void 0&&M-g>=s,A=g===null&&this.now()-m>=s;if(!(!T&&!A)){if(y=!0,this.pollTimer&&clearInterval(this.pollTimer),this.pollTimer=null,A){w();return}this.hardStopTimer&&clearTimeout(this.hardStopTimer),this.hardStopTimer=setTimeout(w,Ge)}},Fe)}))}stop(t){this.clearTimers();let e=this.recorder;if(e&&e.state!=="inactive")try{e.stop()}catch{}this.recorder=null,(t??this.stream)?.getTracks().forEach(r=>r.stop()),this.stream=null}},o(L,"I"),L);async function ze(i,t){let e,r=new Promise(h=>{e=setTimeout(()=>h(null),Ne)}),s=await Promise.race([t,r]);if(clearTimeout(e),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(ze,"He");var He=["magenta","yellow","green","blue"],Ke={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 Ke[i]}o(zi,"ft");var Xe=4,Ve=4,$=o(i=>typeof i=="number"&&Number.isFinite(i),"D");function oe(i){if(typeof i!="object"||i===null)return!1;let t=i;if(typeof t.nonce!="string"||t.nonce.length===0||!Array.isArray(t.colours)||t.colours.length<1||t.colours.length>8||!t.colours.every(r=>He.includes(r))||!Array.isArray(t.onsetsMs)||t.onsetsMs.length!==t.colours.length)return!1;let e=-1;for(let r of t.onsetsMs){if(!$(r)||r<0||r<=e)return!1;e=r}return!(!$(t.holdMs)||t.holdMs<=0||!$(t.endMs)||t.endMs<=e||!$(t.clipMs)||t.clipMs<t.endMs||t.clipMs>8e3)}o(oe,"be");function Ze(i,t){return oe(i)?Math.max(t,Math.ceil(i.clipMs)):t}o(Ze,"ye");function je(i,t){let e=t.now??(()=>performance.now()),r=oe(i)?i:void 0,s=[],a=null,n=null,l=null,c=!1,h=null,d=o(m=>{h=m;try{t.paint(m)}catch{}},"d"),u=o(m=>{let g=t.frames?.()??null;return g!==null&&l!==null?g.mediaTimeMs+(m-g.presentationTimeMs)-l:m-(n??m)},"u"),v=o((m,g,y=0)=>{if(c)return;let p=Math.max(0,m-u(e()));a=setTimeout(()=>{if(a=null,!c){if(y<Xe&&u(e())<m-Ve){v(m,g,y+1);return}g()}},p)},"f"),w=o(m=>{if(r===void 0)return;let g=r.endMs;if(m>=r.colours.length){v(g,()=>d(null));return}let y=r.onsetsMs[m],p=m+1<r.onsetsMs.length?r.onsetsMs[m+1]:g;v(y,()=>{let M=u(e());if(M>g){h!==null&&d(null);return}let T=r.colours[m];d(T);let A=s.length===0?0:s[s.length-1].tMs;s.push({tMs:Math.max(A,Math.round(M)),colour:T});let k=y+r.holdMs;if(k<p){v(k,()=>{if(u(e())>g){h!==null&&d(null);return}d("dark"),w(m+1)});return}w(m+1)})},"v");return{started(m){if(r===void 0||c||n!==null)return;n=m;let g=t.frames?.()??null;l=g===null?null:g.mediaTimeMs+(m-g.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(je,"Me");function $e(i,t,e=.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=t.getContext("2d");if(!l){s(new Error("no-2d-context"));return}t.width=a,t.height=n,l.scale(-1,1),l.drawImage(i,-a,0),t.toBlob(c=>c?r(c):s(new Error("empty-keyframe")),"image/jpeg",e)})}o($e,"Se");var B,Ye=(B=class{constructor(t){this.timer=null,this.frameCallbackId=null,this.running=!1,this.busy=!1,this.lastRunAt=Number.NEGATIVE_INFINITY,this.degradeCount=0,this.durations=[],this.options=t,this.periodMs=1e3/t.cadenceHz}start(){if(this.running)return;this.running=!0;let t=this.options.video;if(typeof t?.requestVideoFrameCallback=="function"){let e=o(()=>{this.running&&(this.frameCallbackId=t.requestVideoFrameCallback?.(()=>{this.frameCallbackId=null,this.now()-this.lastRunAt>=this.periodMs&&this.tick(),e()}))},"t");e();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 t=this.durations.length===0?0:this.durations.reduce((e,r)=>e+r,0)/this.durations.length;return{degradeCount:this.degradeCount,meanDetectMs:t}}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 t=this.now();this.options.run().catch(()=>{}).finally(()=>{this.busy=!1,this.durations.push(this.now()-t),this.durations.length>20&&this.durations.shift()})}},o(B,"O"),B),Qe=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}),F=o(i=>Math.min(1,Math.max(0,i)),"_"),W,Jt=(W=class{constructor(t={}){this.p=0,this.lastTickAt=null,this.lastCenter=null,this.velocityEma=0,this.qWindow=[],this.lastSizeDirection="ideal",this.t={...Qe,...t}}reset(){this.p=0,this.lastTickAt=null,this.lastCenter=null,this.velocityEma=0,this.qWindow=[],this.lastSizeDirection="ideal"}tick(t){let{observation:e,quality:r,timestampMs:s}=t,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:F(r.sharpness),exposure:F(r.exposure),motion:1};if(e!==null){n.presence=1,n.single=(e.extraFaces??0)>0?0:1;let d=this.geometryOf(e,t);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=F(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((v,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(t,e){let{box:r,eyes:s}=t,a={x:e.frameWidth/2,y:e.frameHeight/2},n=Math.min(e.frameWidth,e.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-F(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 v;u<this.t.SIZE_HARD_MIN||u>this.t.SIZE_HARD_MAX?v=0:u<this.t.SIZE_IDEAL_MIN?v=(u-this.t.SIZE_HARD_MIN)/(this.t.SIZE_IDEAL_MIN-this.t.SIZE_HARD_MIN):u>this.t.SIZE_IDEAL_MAX?v=(this.t.SIZE_HARD_MAX-u)/(this.t.SIZE_HARD_MAX-this.t.SIZE_IDEAL_MAX):v=1;let w=1;if(s!==void 0){let m=Math.abs(Math.atan2(s.right.y-s.left.y,s.right.x-s.left.x))*180/Math.PI;w=1-F(m/this.t.ROLL_MAX_DEG)}return{center:l,iod:c,centering:d,size:v,pose:w}}motionOf(t,e,r){let s=this.lastCenter;if(this.lastCenter={...t,at:r},s===null||e<=0)return 1;let a=(r-s.at)/1e3;if(a<=0)return 1;let n=Math.hypot(t.x-s.x,t.y-s.y)/e/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-F(this.velocityEma/this.t.MOTION_VELOCITY_IOD_PER_S)}guidanceOf(t,e,r){if(t.presence<=0)return"fcv3.no_face";if(t.single<=0)return"fcv3.one_face";if(t.size<this.t.GUIDE_SIZE)return this.sizeGuidance();if(t.centering<this.t.GUIDE_CENTERING)return"fcv3.center_face";if(t.pose<this.t.GUIDE_POSE)return"fcv3.straighten";if(t.exposure<this.t.GUIDE_EXPOSURE)return this.exposureGuidance(e);if(t.sharpness<this.t.GUIDE_SHARPNESS)return"fcv3.steady_camera";if(t.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(e)],["sharpness","fcv3.steady_camera"],["motion","fcv3.hold_still"]],a=s[0];for(let n of s)t[n[0]]<t[a[0]]&&(a=n);return a[1]}return"fcv3.hold_still"}sizeGuidance(){return this.lastSizeDirection==="far"?"fcv3.come_closer":"fcv3.move_back"}exposureGuidance(t){let e=(it[0]+it[1])/2;return t.meanLuma<e?"fcv3.more_light":"fcv3.too_bright"}},o(W,"k"),W),Je=["single","size","centering","pose","exposure","sharpness","motion"];function ti(i){if(i.accepted)return null;if(i.factors.presence<=0)return"no_face";let t="single";for(let e of Je)i.factors[e]<i.factors[t]&&(t=e);return t}o(ti,"Ze");var q,te=(q=class{constructor(){this.blocked={},this.acceptedMs=0,this.ticks=0,this.lastAt=null}record(t){let e=this.lastAt===null?0:Math.max(0,t.at-this.lastAt);this.lastAt=t.at,this.ticks+=1;let r=ti(t);if(r===null){this.acceptedMs+=e;return}let s=this.blocked[r]??{count:0,ms:0};s.count+=1,s.ms+=e,this.blocked[r]=s}summary(){let t={};for(let[e,r]of Object.entries(this.blocked))t[e]={count:r.count,ms:Math.round(r.ms)};return{blocked:t,acceptedMs:Math.round(this.acceptedMs),ticks:this.ticks}}},o(q,"w"),q),ei=["obs","manycam","virtual","snap camera","xsplit","droidcam","iriun","camo"],ii=[/^(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 ri(i){let t=(i??"").trim().toLowerCase();return t.length===0?"unknown":ei.some(e=>t.includes(e))?"known_virtual":ii.some(e=>e.test(t))?"platform":"unknown"}o(ri,"je");function ee(i){if(typeof i!="function")return!1;try{return/\{\s*\[native code\]\s*\}\s*$/.test(Function.prototype.toString.call(i))}catch{return!1}}o(ee,"Te");function si(i=globalThis){return ee(i.navigator?.mediaDevices?.getUserMedia)&&ee(i.MediaStreamTrack?.prototype?.getSettings)}o(si,"$e");async function ai(i,t=globalThis){let e=t.crypto?.subtle?.digest;if(typeof e=="function")try{let r=new Uint8Array(await e.call(t.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(ai,"Je");async function ni(i,t=globalThis){let e={};try{e=typeof i.getSettings=="function"?i.getSettings()??{}:{}}catch{e={}}let r={};if((e.facingMode==="user"||e.facingMode==="environment"||e.facingMode==="left"||e.facingMode==="right")&&(r.facingMode=e.facingMode),typeof e.frameRate=="number"&&Number.isFinite(e.frameRate)&&(r.frameRate=e.frameRate),typeof e.width=="number"&&Number.isFinite(e.width)&&(r.width=e.width),typeof e.height=="number"&&Number.isFinite(e.height)&&(r.height=e.height),typeof e.deviceId=="string"&&e.deviceId.length>0){let a=await ai(e.deviceId,t);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:ri(s),prototypesIntact:si(t)}}o(ni,"Ce");var ot=o(i=>Math.round(i*100)/100,"H");function oi(i){let t=i,e=typeof t?.requestVideoFrameCallback=="function",r=null,s=null,a=0,n=0,l=0,c=0,h=0,d=0,u=o(()=>{!e||t?.requestVideoFrameCallback===void 0||(r=t.requestVideoFrameCallback((v,w)=>{if(r=null,!e)return;let m=w.presentationTime;if(s!==null){let g=m-s.presentationTimeMs;n+=1;let y=g-l;l+=y/n,c+=y*(g-l)}typeof w.captureTime=="number"&&Number.isFinite(w.captureTime)&&(h+=m-w.captureTime,d+=1),a+=1,s={mediaTimeMs:w.mediaTime*1e3,presentationTimeMs:m},u()}))},"u");return u(),{latest:o(()=>s,"latest"),stats:o(()=>({n:a,meanGapMs:n===0?0:ot(l),stdGapMs:n<2?0:ot(Math.sqrt(c/(n-1))),captureLatencyMs:d===0?null:ot(h/d)}),"stats"),stop:o(()=>{e&&(e=!1,r!==null&&t?.cancelVideoFrameCallback?.(r),r=null)},"stop")}}o(oi,"Ee");function li(i,t,e){return{...i,rvfc:t,rampPainter:e}}o(li,"_e");var ci=1e3,lt="fcv3.hold_upright",hi=200,ct=4,ui=600,di=1e3,ie={sharpness:1,exposure:1,meanLuma:128};function fi(i,t){return t.width=i.videoWidth,t.height=i.videoHeight,t.getContext("2d").drawImage(i,0,0),new Promise((e,r)=>t.toBlob(s=>s?e(s):r(new Error("empty-keyframe")),"image/jpeg",.92))}o(fi,"it");function mi(){return V()==="phone"}o(mi,"at");var z,le=(z=class{constructor(t){this.handlers=new Map,this.stateValue="idle",this.attempt=0,this.stream=null,this.detector=null,this.scheduler=null,this.gate=null,this.profiler=null,this.lastGuidanceKey=null,this.positioningStartedAt=0,this.cameraRequestedAt=null,this.cameraReadyAt=null,this.faceAcquiredAt=null,this.captureCompleteAt=null,this.fired=!1,this.carriedDegrade=0,this.carriedMeans=[],this.blockStats=null,this.lastGateSnapshotAt=Number.NEGATIVE_INFINITY,this.uprightGuard=!1,this.trackProvenance=null,this.ramp=null,this.snapshotCanvas=null,this.options=t,this.facing=t.facingMode??"user"}get state(){return this.stateValue}on(t,e){let r=this.handlers.get(t);return r||(r=new Set,this.handlers.set(t,r)),r.add(e),()=>r?.delete(e)}emit(t,e){for(let r of[...this.handlers.get(t)??[]])r(e)}async start(t={}){t.facingMode!==void 0&&(this.facing=t.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(t){this.facing=t,this.teardownAttempt(),this.start()}destroy(){this.attempt+=1,this.teardownAttempt(),this.detector?.destroy(),this.detector=null,this.options.video.srcObject=null}async run(t){let{options:e}=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=(e.isPhone??mi)(),this.setState("preflight");let r=Ct();if(r!=="OK"){this.fail(r==="INSECURE_CONTEXT"?"insecure":"unsupported",{phase:"preflight"});return}this.setState("acquiring");let s=e.getUserMedia??(h=>navigator.mediaDevices.getUserMedia(h)),a;this.cameraRequestedAt=this.now();try{let{facingMode:h,...d}=kt(Tt(),this.facing).video;a=await Lt(this.facing,d,{getUserMedia:s,enumerateDevices:vi(e)})}catch(h){if(t!==this.attempt)return;if(h instanceof Nt){this.fail("backcamera",{phase:"acquiring",name:K(h)});return}this.fail(Ut(h),{phase:"acquiring",name:K(h)});return}if(Et(a),Ft(a),t!==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:ni(n).catch(()=>null),this.facing=_t(a)??this.facing,e.video.srcObject=a,await e.video.play().catch(()=>{}),t!==this.attempt)return;if(this.cameraReadyAt=this.now(),this.detector===null){let h={v3AssetBaseUrl:e.v3AssetBaseUrl},d=e.createDetector??(e.createWorker!==void 0&&Zt()?async()=>{try{return await jt.create(e.createWorker(),h)}catch{return x(h)}}:()=>x(h)),u;try{u=await d()}catch(v){t===this.attempt&&this.fail("models",{phase:"models",name:K(v)},v instanceof nt?v.fallbackReason:gi(v));return}if(t!==this.attempt){u.destroy();return}this.detector=u,this.options.telemetry?.({type:"detector",tier:u.tier,fallbackReason:u.fallbackReason})}let l=Bt(),c=e.deviceClass??Wt(l);this.profiler=new qt(c),this.options.telemetry?.({type:"profile",staticClass:c,activeClass:this.profiler.deviceClass,simd:l.simd}),this.gate=new Jt(e.thresholds??{}),this.blockStats=new te,this.lastGateSnapshotAt=this.now(),e.rankKeyframes?.()&&import("./keyframe-rank-R4NPQGN3-VRURE6OQ.js").then(h=>ht=h,()=>{}),this.setState("positioning"),this.positioningStartedAt=this.now(),this.startScheduler(t)}get animations(){return this.profiler?.profile.animations??"full"}startScheduler(t){let e=this.profiler;if(e===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 Ye({cadenceHz:e.profile.cadenceHz,video:this.options.video,now:this.options.now,run:o(()=>this.detectTick(t),"run")});this.scheduler=r,r.start()}async detectTick(t){let{detector:e,gate:r,profiler:s}=this,a=this.options.video;if(t!==this.attempt||e===null||r===null||s===null||this.fired||a.videoWidth===0)return;if(this.isLandscape()){this.holdUpright(t);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 e.detect(c,a.videoWidth,a.videoHeight)}catch{h=null}if(t!==this.attempt||this.fired)return;s.record(this.now()-l),s.deviceClass!==n&&this.startScheduler(t);let d=h===null?ie: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>=ci&&(this.lastGateSnapshotAt=u.at,this.reportGate(!1)),this.emit("checks",{engine:"v3",progress:u.p,q:u.q,factors:u.factors,attempt:t}),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(t))}async fire(t){let{options:e}=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]:[]];e.telemetry?.({type:"fired",timeToGateMs:this.now()-this.positioningStartedAt,degradeCount:this.carriedDegrade+s.degradeCount,meanDetectMs:a.length===0?0:a.reduce((k,b)=>k+b,0)/a.length});let n=e.mode??"clip",l=e.rankKeyframes?.()&&ht?ht.default(this,t).catch(()=>this.collectKeyframes(t)):this.collectKeyframes(t);if(n==="photo"){let k=this.watchRotation(t,null),b=await l;if(k(),t!==this.attempt)return;if(b===null){this.fail("generic",{phase:"keyframes"});return}let I=await this.provenance({n:0,meanGapMs:0,stdGapMs:0,captureLatencyMs:null},!1);if(t!==this.attempt)return;this.finishCapture({keyframe:b.blob,previewDataUrl:b.previewDataUrl,...I});return}this.setState("recording");let c=this.stream;if(c===null){this.fail("generic",{phase:"recording"});return}let h=e.screenRamp?.(),d=h!==void 0,u=null;l.then(k=>{u=k},()=>{});let v=o(()=>{t===this.attempt&&u!==null&&this.emit("frozen",{previewDataUrl:u.previewDataUrl})},"f"),w=Ze(h,ne),m=null,g,y=0;try{let k=this.recordTake(t,c,h,w,void 0).then(_=>_,_=>({failed:_})),[b,I]=await Promise.all([k,l]);if(g=I,t!==this.attempt)return;if("failed"in b){if(b.failed.kind==="cliptoolarge")throw b.failed;$t(b.failed.requestedMimeType??"")}else m=b,Qt(b.clip,w)?b.clip.stats===null&&$t(b.clip.requestedMimeType??""):v();if(m===null||Qt(m.clip,w)){y=1,e.telemetry?.({type:"clip_retake",reason:m===null?"error":m.clip.stats===null?"unreadable":"short"});let _=null;try{_=await this.recordTake(t,c,h,w,v)}catch(H){if(m===null)throw H}if(t!==this.attempt)return;_!==null&&(m===null||We(_.clip,m.clip))&&(m=_),_===null&&v()}}catch(k){if(t!==this.attempt)return;let b=k.kind;this.fail(b==="cliptoolarge"?"cliptoolarge":"recorder",{phase:"recording",name:K(k)});return}if(m===null){this.fail("recorder",{phase:"recording"});return}let{clip:p,rvfc:M,report:T}=m;if(et(p.blob)){this.fail("cliptoolarge",{phase:"recording"});return}if(g===null){this.fail("generic",{phase:"keyframes"});return}let A=await this.provenance(M,d);t===this.attempt&&this.finishCapture({clip:p.blob,clipMimeType:p.mimeType,...p.stats?{clipStats:p.stats}:{},clipRetakes:y,keyframe:g.blob,previewDataUrl:g.previewDataUrl,...T!==void 0&&T.rendered.length>0?{screenRamp:T}:{},...A})}async recordTake(t,e,r,s,a){let n=this.options.createRecorder?.()??new qe({now:o(()=>this.now(),"now")}),l=oi(this.options.video),c=je(r,{paint:o(u=>{(u===null||t===this.attempt)&&this.emit("ramp",{colour:u})},"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(t,n);try{return{clip:await n.record(e,a,()=>c.started(this.now()),s,l),rvfc:l.stats(),report:c.report()}}finally{d(),h()}}async provenance(t,e){let r=this.trackProvenance;if(r===null)return{};let s,a=new Promise(l=>{s=setTimeout(()=>l(null),di)}),n=await Promise.race([r,a]);return clearTimeout(s),n===null?{}:{provenance:li(n,t,e)}}isLandscape(){let t=this.options.video;return this.uprightGuard&&t.videoWidth>t.videoHeight}holdUpright(t){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:t}),this.lastGuidanceKey!==lt&&(this.lastGuidanceKey=lt,this.emit("guidance",{key:lt}))}watchRotation(t,e){if(!this.uprightGuard)return()=>{};let r=this.options.video,s=o(()=>{if(t!==this.attempt||e!==null&&this.stateValue!=="recording"){l();return}r.videoWidth>0&&this.isLandscape()&&(l(),this.abortRecording(t,e))},"n"),a=setInterval(s,hi);r.addEventListener?.("resize",s);let n=!1;function l(){n||(n=!0,clearInterval(a),r.removeEventListener?.("resize",s))}return o(l,"o"),l}abortRecording(t,e){if(t!==this.attempt)return;this.attempt+=1;let r=this.attempt;try{e?.stop()}catch{}this.ramp?.stop(),this.ramp=null,this.fired=!1,this.captureCompleteAt=null,this.gate=new Jt(this.options.thresholds??{}),this.blockStats=new te,this.lastGateSnapshotAt=this.now(),this.lastGuidanceKey=null,this.setState("positioning"),this.positioningStartedAt=this.now(),this.holdUpright(r),this.startScheduler(r)}async collectKeyframes(t){let e=this.options.captureKeyframe??(a=>this.defaultKeyframe(a)),r=ui/(ct-1),s=null;for(let a=0;a<ct;a+=1){if(t!==this.attempt)return s;try{let n=await e(this.options.video);(s===null||n.sharpness>s.sharpness)&&(s=n)}catch{}a<ct-1&&await pi(r)}return s}finishCapture(t){this.stopTracks(),this.setState("captured");let e=this.captureTiming();this.emit("artifacts",e===void 0?t:{...t,timing:e})}captureTiming(){let t={},e=o((r,s,a)=>{s!==null&&a!==null&&(t[r]=Math.max(0,Math.round(a-s)))},"t");return e("cameraReadyMs",this.cameraRequestedAt,this.cameraReadyAt),e("faceAcquireMs",this.cameraReadyAt,this.faceAcquiredAt),e("captureMs",this.faceAcquiredAt,this.captureCompleteAt),Object.keys(t).length>0?t:void 0}async defaultKeyframe(t){let e=document.createElement("canvas"),r=await(this.facing==="user"?$e:fi)(t,e),s=e.toDataURL("image/jpeg",.92);return{blob:r,previewDataUrl:s,sharpness:this.centerSharpness(t)}}defaultSnapshot(t,e){try{let r=this.snapshotCanvas??document.createElement("canvas"),s=e/Math.max(1,t.videoWidth),a=Math.max(1,Math.round(t.videoWidth*s)),n=Math.max(1,Math.round(t.videoHeight*s)),l=r.getContext("2d");return l===null?t:(r.width!==a&&(r.width=a),r.height!==n&&(r.height=n),l.drawImage(t,0,0,a,n),this.snapshotCanvas=r,r)}catch{return t}}defaultQuality(t,e){let r=re(t,e,96);return r===null?ie:{sharpness:rt(r),exposure:Ht(r),meanLuma:zt(r)}}centerSharpness(t){let e=Z(t),r=re(t,{x:e.width*.25,y:e.height*.25,width:e.width*.5,height:e.height*.5},96);return r===null?0:rt(r)}teardownAttempt(){this.scheduler?.stop(),this.scheduler=null,this.reportGate(!0),this.gate=null,this.ramp?.stop(),this.ramp=null,this.stopTracks()}reportGate(t){let e=this.blockStats,r=this.profiler;if(e===null||r===null)return;let s=e.summary();t&&(this.blockStats=null),s.ticks!==0&&this.options.telemetry?.({type:"gate",final:t,activeClass:r.deviceClass,cadenceHz:r.profile.cadenceHz,...s})}stopTracks(){if(this.stream!==null){for(let t of this.stream.getTracks())t.stop();this.stream=null}}fail(t,e,r){this.scheduler?.stop(),this.reportGate(!0),this.stopTracks(),this.setState("error"),this.options.telemetry?.({type:"error",kind:t,fallbackReason:r});let{phase:s,name:a}=e;this.emit("error",{kind:t,retryable:t!=="insecure"&&t!=="unsupported",detail:a===void 0?{phase:s}:{phase:s,name:a}})}setState(t){this.stateValue=t,this.emit("statechange",{state:t})}now(){return this.options.now?.()??performance.now()}},o(z,"ke"),z),ht;function pi(i){return new Promise(t=>setTimeout(t,i))}o(pi,"st");function gi(i){return i instanceof Error?i.message:String(i)}o(gi,"ot");function re(i,t,e){try{let r=document.createElement("canvas"),s=e/Math.max(1,t.width);r.width=Math.max(1,Math.round(t.width*s)),r.height=Math.max(1,Math.round(t.height*s));let a=r.getContext("2d");return a===null?null:(a.drawImage(i,t.x,t.y,t.width,t.height,0,0,r.width,r.height),a.getImageData(0,0,r.width,r.height))}catch{return null}}o(re,"we");function vi(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(vi,"lt");var yi=12e4,ce=13e4,wi=3e3,bi=1200,ut=Symbol.for("@sekyro/web.preload.v1");function ft(){let i=globalThis;return i[ut]??(i[ut]=new Map),i[ut]}o(ft,"g");function Y(i){let t=(i??at).replace(/\/+$/,"");return t===""?"/":t}o(Y,"S");function ue(i){let t=ft(),e=t.get(i);return e===void 0&&(e={status:"idle",promise:null,scheduled:null,detectorPromise:null,detector:null,listeners:new Set},t.set(i,e)),e}o(ue,"se");function dt(i,t){if(i.status!==t){i.status=t;for(let e of[...i.listeners])e(t)}}o(dt,"A");var Mi=o(i=>x({preferred:["blaze"],v3AssetBaseUrl:i,blazeInitTimeoutMs:yi}),"x"),ki=Mi;function Ti(){return typeof window<"u"&&typeof navigator<"u"&&typeof navigator.mediaDevices?.getUserMedia=="function"}o(Ti,"pe");function _i(){return navigator.connection?.saveData===!0}o(_i,"me");function Ei(i){let t=window;if(typeof t.requestIdleCallback=="function"){let r=t.requestIdleCallback(i,{timeout:wi});return()=>t.cancelIdleCallback?.(r)}let e=setTimeout(i,bi);return()=>clearTimeout(e)}o(Ei,"ve");function Si(i,t){let e,r=new Promise(l=>{e=l}),s=!1,a=o(()=>{},"d"),n={promise:r,settle:o(l=>{s||(s=!0,a(),i.scheduled===n&&(i.scheduled=null),e(l))},"settle")};return i.scheduled=n,a=Ei(()=>{s||n.settle(mt(i,t))}),r}o(Si,"ge");function mt(i,t){if((i.status==="loading"||i.status==="ready")&&i.promise!==null)return i.promise;dt(i,"loading");let e=new Promise(n=>n(ki(t)));i.detectorPromise=e;let r,s=new Promise((n,l)=>{r=setTimeout(()=>{e.then(c=>c.destroy(),()=>{}),l(new Error(`detector preload exceeded ${ce} ms`))},ce)}),a=Promise.race([e,s]).then(n=>i.detectorPromise!==e?(n.destroy(),i.status):(i.detector=n,dt(i,"ready"),"ready"),n=>(i.detectorPromise===e&&(i.detectorPromise=null,i.detector=null,dt(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(mt,"I");function Yi(i={}){if(!Ti())return Promise.resolve("idle");let t=Y(i.assetBaseUrl),e=ue(t);return i.respectSaveData===!0&&_i()?Promise.resolve(e.status):(e.status==="loading"||e.status==="ready")&&e.promise!==null?e.promise:i.idle===!0?e.scheduled?.promise??Si(e,t):mt(e,t)}o(Yi,"we");function Qi(i){return ft().get(Y(i))?.status??"idle"}o(Qi,"ke");function Ji(i,t){let e=ue(Y(t));return e.listeners.add(i),()=>{e.listeners.delete(i)}}o(Ji,"De");function Ai(i){return{get tier(){return i.tier},get fallbackReason(){return i.fallbackReason},detect:o((...t)=>i.detect(...t),"detect"),destroy:o(()=>{},"destroy")}}o(Ai,"he");function Ii(i){let t=Y(i),e=ft().get(t);if(!(e===void 0||e.detector===null&&e.detectorPromise===null&&e.scheduled===null))return async()=>{e.scheduled!==null&&mt(e,t);let r=e.promise;for(;e.detector===null&&r!==null&&(await r,e.promise!==r);)r=e.promise;return e.detector!==null?Ai(e.detector):x({v3AssetBaseUrl:t})}}o(Ii,"oe");function xi(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(xi,"Ce");function Di(i){switch(i){case"preflight":case"acquiring":return"starting";case"positioning":return"gating";default:return i}}o(Di,"Se");function he(i){switch(i){case"permission":case"notfound":case"inuse":case"insecure":case"unsupported":return i;case"backcamera":return"notfound";default:{let t=i;return"generic"}}}o(he,"ie");function Ri(i,t,e){if(e===void 0)return{kind:he(i),retryable:t};let r=Gt(e.name);return{kind:he(i),retryable:t,detail:{...r!==void 0?{name:r}:{},phase:e.phase,engineKind:i}}}o(Ri,"Le");var Ci=new Set(["captured","uploading","checking"]);function Oi(i,t={},e,r=()=>"self",s=()=>{},a){let n=t.now??(()=>performance.now()),l=t.canChooseFacing??At,c="user",h=It(),d=r(),u=St(),v=!Ot(),w=t.engineOptions,m=w?.createDetector===void 0&&w?.createWorker===void 0?{createDetector:o(()=>{let f=Ii(i.assetBaseUrl);return f!==void 0?f():x({v3AssetBaseUrl:i.assetBaseUrl})},"createDetector")}:{},g={video:i.video,mode:v?"photo":"clip",rankKeyframes:e,facingMode:void 0,v3AssetBaseUrl:i.assetBaseUrl,screenRamp:o(()=>d==="self"&&u.count("ramp")>0?s():void 0,"screenRamp"),...t.engineOptions??{},...m},y=t.createEngine?.(g)??new le(g),p="idle",M=null,T=0,A=!1,k="full",b=null,I=null,_=0,H=0,pt=o(()=>{i.video.videoWidth>0&&i.video.videoHeight>0&&(_=i.video.videoWidth,H=i.video.videoHeight)},"K"),gt=xt({enabled:i.keepScreenAwake!==!1}),X=o(f=>{p=f,gt.setActive(f==="starting"||f==="gating"||f==="recording"),u.emit("state",f)},"M"),Q=o(()=>u.emit("gate",{progress:T,hint:M,faceDetected:A}),"R"),vt=o(()=>{let f=y.animations??"full";f!==k&&(k=f,u.emit("profile",{animations:k}))},"G"),de=[y.on("statechange",({state:f})=>{let E=Di(f);E==="starting"&&p!=="starting"&&(M=null,T=0,A=!1,b=null,I=null,_=0,H=0),X(E),vt(),E==="recording"&&(pt(),b=n(),M="hold",T=1,Q())}),y.on("checks",f=>{pt(),T=f.progress,A=f.factors.presence>0,Q(),vt()}),y.on("guidance",({key:f})=>{M=xi(f),Q()}),y.on("frozen",({previewDataUrl:f})=>{I=n(),u.emit("frozen",{previewDataUrl:f})}),y.on("ramp",f=>u.emit("ramp",f)),y.on("artifacts",f=>{if(p!=="captured")return;let E=V(),S=f.clipStats,bt=S!==void 0?Math.round(S.durationMs):b!==null&&I!==null?Math.max(0,Math.round(I-b)):void 0,Mt=S!==void 0&&S.frames>1&&S.durationMs>0?Math.round(S.frames*1e4/S.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||_,height:i.video.videoHeight||H,...bt!==void 0?{clipMs:bt}:{},...S!==void 0?{clipFrames:S.frames}:{},...Mt!==void 0?{fps:Mt}:{},...f.clipRetakes!==void 0?{clipRetakes:f.clipRetakes}:{},...f.clipMimeType!==void 0?{codec:ae(f.clipMimeType)}:{},captureChannel:E==="desktop"?"desktop":"mobile",formFactor:E,...v?{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:E,detail:S})=>{f==="backcamera"&&fe()||u.emit("error",Ri(f,E,S))})],yt=!1;function fe(){return J||yt||d!=="assisted"||a===void 0||a.session()!=="choice"?!1:(yt=!0,a.onModeChange("self"),d="self",c=tt("self"),X("mode_switch"),y.restart(c),!0)}o(fe,"ce");let wt=o(async()=>a!==void 0&&a.session()==="choice"&&await l().catch(()=>!1),"W"),J=!1;return{handle:{get state(){return p},get captureMode(){return r()},get facingMode(){return y.facingMode??c},on:o((f,E)=>u.on(f,E),"on"),start:o(f=>(d=r(),h.facing(d,i.facing),c=h.facing(d,f?.facing),y.start({facingMode:c})),"start"),retry:o(()=>y.retry(),"retry"),switchCamera:o(()=>h.refuseSwitch(r()),"switchCamera"),canSwitchCaptureMode:wt,setCaptureMode:o(async f=>{if(f===r()||!await wt()||J||Ci.has(p)||a===void 0)return!1;a.onModeChange(f),d=f;let E=tt(f);return c=E,p==="idle"||(X("mode_switch"),y.restart(E)),!0},"setCaptureMode"),destroy:o(()=>{J=!0;for(let f of de)f();gt.setActive(!1),y.destroy(),u.clear()},"destroy")},setFlowState:o(f=>{p!==f&&X(f)},"setFlowState")}}o(Oi,"Ee");function tr(i){return Oi(i).handle}o(tr,"ze");export{zi as a,Yi as b,Qi as c,Ji as d,Ri as e,Oi as f,tr as g};
1
+ import{d as Et,e as Bt,f as Wt,g as qt}from"./chunk-6H22RNSK.js";import{a as it,b as zt,c as rt,d as Ht}from"./chunk-UZWMCNZI.js";import{a as kt,b as V,c as Tt,d as _t,e as St,g as At,h as tt,i as It,j as xt,k as Nt,l as Lt}from"./chunk-D334IAZJ.js";import{a as Dt,b as Rt,c as Ct,d as Ot,e as Pt,f as et,g as K,h as Gt,i as Ut,j as Ft}from"./chunk-RRLXNT33.js";import{a as o}from"./chunk-4FHWXBOB.js";var me=1e4,C,pe=(C=class{constructor(t,e){this.tier="blaze",this.inner=t,e!==void 0&&(this.fallbackReason=e)}static async create(t,e){let r=await import("./vision_bundle-WBHR7TEE.js"),s=await r.FilesetResolver.forVisionTasks(t),a=await r.FaceDetector.createFromOptions(s,{baseOptions:{modelAssetPath:`${t}/blaze_face_short_range.tflite`,delegate:"CPU"},runningMode:"IMAGE"});return new C(a,e)}async detect(t,e,r){let s;try{s=this.inner.detect(t).detections}catch{return null}let a=ge(s);if(a?.boundingBox===void 0)return null;let n=Z(t),l=ve(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:Kt(s.map(d=>d.boundingBox??{width:0,height:0}),s.indexOf(a))};return Xt(h,t,e,r)}destroy(){try{this.inner.close()}catch{}}},o(C,"t"),C);function ge(i){let t,e=-1;for(let r of i){let s=r.categories[0]?.score??0;s>e&&(t=r,e=s)}return t}o(ge,"R");function ve(i,t){let e=i?.[0],r=i?.[1];if(e===void 0||r===void 0)return;let s=o(l=>({x:l.x*t.width,y:l.y*t.height}),"n"),[a,n]=[s(e),s(r)];return a.x<=n.x?{left:a,right:n}:{left:n,right:a}}o(ve,"T");function ye(){if(typeof OffscreenCanvas=="function")return new OffscreenCanvas(2,2);let i=document.createElement("canvas");return i.width=2,i.height=2,i}o(ye,"E");var we=4;async function be(){let i=globalThis.FaceDetector;if(typeof i!="function")return{ok:!1,reason:"unsupported"};try{let t=new i({fastMode:!0,maxDetectedFaces:we});return await t.detect(ye()),{ok:!0,instance:t}}catch(t){return{ok:!1,reason:`smoke_failed:${t instanceof Error?t.message:String(t)}`}}}o(be,"w");var P,Me=(P=class{constructor(t,e){this.tier="native",this.inner=t,e!==void 0&&(this.fallbackReason=e)}async detect(t,e,r){let s;try{s=await this.inner.detect(t)}catch{return null}let a=s.map(d=>d.boundingBox),n=-1;a.forEach((d,u)=>{let v=a[n];(v===void 0||d.width*d.height>v.width*v.height)&&(n=u)});let l=s[n];if(l===void 0)return null;let c=ke(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:Kt(a,n)};return Xt(h,t,e,r)}destroy(){}},o(P,"b"),P);function ke(i){if(i===void 0)return;let t=i.filter(s=>s.type==="eye").map(s=>s.locations[0]).filter(s=>s!==void 0),[e,r]=t;if(!(e===void 0||r===void 0))return e.x<=r.x?{left:e,right:r}:{left:r,right:e}}o(ke,"S");var Te=.25;function Kt(i,t){let e=i[t],r=e===void 0?0:e.width*e.height;if(!(r>0))return 0;let s=0;return i.forEach((a,n)=>{n!==t&&a.width*a.height>=Te*r&&(s+=1)}),s}o(Kt,"f");var at="/models-v3",_e=["native","blaze"],G,nt=(G=class extends Error{constructor(t){super(`no detector tier available (${t})`),this.name="DetectorLadderError",this.fallbackReason=t}},o(G,"x"),G);function Z(i){let t=i;if(typeof t.videoWidth=="number"&&t.videoWidth>0)return{width:t.videoWidth,height:t.videoHeight??0};if(typeof t.naturalWidth=="number"&&t.naturalWidth>0)return{width:t.naturalWidth,height:t.naturalHeight??0};let e=typeof t.width=="number"?t.width:0,r=typeof t.height=="number"?t.height:0;return{width:e,height:r}}o(Z,"y");function Xt(i,t,e,r){let s=Z(t),a=s.width>0?e/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(Xt,"h");function Ee(i){return i instanceof Error?i.message:String(i)}o(Ee,"C");async function x(i){let t=i.preferred??_e,e=[];for(let r of t){if(r==="native"){let s=await be();if(s.ok)return new Me(s.instance,st(e));e.push(`native:${s.reason}`);continue}try{return await Se(pe.create(i.v3AssetBaseUrl??at,st(e)),i.blazeInitTimeoutMs??me)}catch(s){e.push(s instanceof Vt?"blaze:blaze_init_timeout":`blaze:${Ee(s)}`)}}throw new nt(st(e)??"no_tier_available")}o(x,"O");function st(i){return i.length>0?i.join("; "):void 0}o(st,"v");var U,Vt=(U=class extends Error{},o(U,"g"),U);function Se(i,t){return new Promise((e,r)=>{let s=setTimeout(()=>{r(new Vt(`init exceeded ${t}ms`)),i.then(a=>a.destroy(),()=>{})},t);i.then(a=>{clearTimeout(s),e(a)},a=>{clearTimeout(s),r(a)})})}o(Se,"W");var R=1;function Zt(){return typeof OffscreenCanvas=="function"&&typeof createImageBitmap=="function"&&typeof Worker=="function"}o(Zt,"K");function Ae(i,t={}){let e=t.createDetector??x,r=null;i.onmessage=s=>{let a=s.data;if(a.v!==R){a.bitmap?.close?.();return}if(a.type==="init"){e(a.options).then(n=>{r=n;let l={v:R,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:R,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(Ae,"B");typeof self<"u"&&typeof self.importScripts=="function"&&Ae(self);var O,jt=(O=class{constructor(t,e){this.pending=new Map,this.nextId=1,this.worker=t,this.tier=e.tier,e.fallbackReason!==void 0&&(this.fallbackReason=e.fallbackReason),t.addEventListener("message",r=>{let s=r.data;if(s.v!==R||s.type!=="result")return;let a=this.pending.get(s.id);this.pending.delete(s.id),a?.(s.observation)})}static create(t,e,r=1e4){return new Promise((s,a)=>{let n=setTimeout(()=>{t.removeEventListener("message",l),t.terminate(),a(new Error(`worker detector not ready within ${r}ms`))},r),l=o(h=>{let d=h.data;d.v!==R||d.type!=="ready"||(clearTimeout(n),t.removeEventListener("message",l),s(new O(t,d)))},"s");t.addEventListener("message",l);let c={v:R,type:"init",options:e};t.postMessage(c)})}async detect(t,e,r){let s;try{typeof ImageBitmap<"u"&&t instanceof ImageBitmap?s=t:typeof createImageBitmap=="function"?s=await createImageBitmap(t):s=t}catch{return null}let a=this.nextId;return this.nextId+=1,new Promise(n=>{this.pending.set(a,n);let l={v:R,type:"detect",id:a,bitmap:s,streamWidth:e,streamHeight:r};this.worker.postMessage(l,[s])})}destroy(){for(let t of this.pending.values())t(null);this.pending.clear(),this.worker.terminate()}},o(O,"t"),O);var Ie=[...Dt.filter(i=>i.startsWith("video/mp4")),"video/webm;codecs=h264","video/webm;codecs=avc1","video/webm;codecs=vp8","video/webm;codecs=vp9","video/webm"],se=new Set;function xe(i){let t=/(?:Chrome|Chromium)\/(\d+)\./.exec(i??"");return t?Number(t[1]):null}o(xe,"De");function De(i=Ce(),t=globalThis.navigator?.userAgent){if(i===void 0)return"";let e=xe(t)===126;for(let r of Ie)if(!(se.has(r)||e&&r.startsWith("video/mp4")))try{if(i(r))return r}catch{}return""}o(De,"he");function $t(i){i!==""&&se.add(i)}o($t,"F");function Re(i){return i.replace(/^video\/x-matroska/i,"video/webm")}o(Re,"fe");function ae(i){let t=/codecs=["']?([^,;"']+)/i.exec(i);return t?t[1].trim():i.split(";")[0].trim()}o(ae,"ut");function Ce(){let i=globalThis.MediaRecorder;return i&&typeof i.isTypeSupported=="function"?t=>i.isTypeSupported(t):void 0}o(Ce,"Oe");var ne=2500,Oe=1e3,Pe=1500,Yt=25e5,Ge=100,Ue=700,Fe=20,Ne=1500,j=null;function Le(){return j??(j=import("./clip-inspect-HZ7N2YOP-DCDXB76T.js").catch(i=>{throw j=null,i})),j.catch(()=>null)}o(Le,"Ne");var N,D=(N=class extends Error{constructor(t,e){super(e??t),this.kind=t}},o(N,"S"),N),Be=100;function Qt(i,t){return i.stats===void 0?!1:i.stats===null?!0:i.stats.durationMs<t-Be}o(Qt,"U");function We(i,t){return i.stats?t.stats?i.stats.durationMs>t.stats.durationMs:!0:!1}o(We,"ge");var L,qe=(L=class{constructor(t={}){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=t.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(t,e,r,s=ne,a){let n=De(),l=Le();return this.recordRaw(t,e,r,s,a,n).then(c=>ze(c,l),c=>{throw c instanceof D&&(c.requestedMimeType=n),c})}recordRaw(t,e,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=t,new Promise((l,c)=>{let h;try{h=new MediaRecorder(t,n?{mimeType:n,videoBitsPerSecond:Yt}:{videoBitsPerSecond:Yt})}catch{try{h=new MediaRecorder(t)}catch{c(new D("unsupported"));return}}this.recorder=h;let d=o(p=>{this.settled||(this.settled=!0,this.clearTimers(),p())},"d"),u=o(()=>d(()=>{let p=Re(h.mimeType||n||Rt),M=new Blob(this.chunks,{type:p});if(M.size===0){c(new D("generic","empty clip"));return}if(et(M)){c(new D("cliptoolarge"));return}l({blob:M,mimeType:p,requestedMimeType:n})}),"u");h.ondataavailable=p=>{p.data&&p.data.size&&(this.chunks.push(p.data),this.bytes+=p.data.size,this.bytes>Pt&&d(()=>{try{h.state!=="inactive"&&h.stop()}catch{}c(new D("cliptoolarge"))}))},h.onstop=u,h.onerror=()=>d(()=>c(new D("generic")));let v=this.now();if(r!==void 0||a!==void 0){let p=!1;h.onstart=()=>{if(!(p||this.settled)&&(p=!0,v=this.now(),r!==void 0))try{r()}catch{}}}try{h.start(Oe)}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||e?.(),h.state!=="inactive"){try{h.stop()}catch{u()}this.graceTimer=setTimeout(u,Pe)}else u()},"v"),m=this.now();if(a===void 0){this.hardStopTimer=setTimeout(w,s);return}let g=null,y=!1;this.hardStopTimer=setTimeout(w,s+Ue),this.pollTimer=setInterval(()=>{if(this.settled||y)return;let p=null;try{p=a.latest()}catch{p=null}let M=p?.presentationTimeMs;M!==void 0&&Number.isFinite(M)&&M>=v&&g===null&&(g=M);let T=g!==null&&M!==void 0&&M-g>=s,A=g===null&&this.now()-m>=s;if(!(!T&&!A)){if(y=!0,this.pollTimer&&clearInterval(this.pollTimer),this.pollTimer=null,A){w();return}this.hardStopTimer&&clearTimeout(this.hardStopTimer),this.hardStopTimer=setTimeout(w,Ge)}},Fe)}))}stop(t){this.clearTimers();let e=this.recorder;if(e&&e.state!=="inactive")try{e.stop()}catch{}this.recorder=null,(t??this.stream)?.getTracks().forEach(r=>r.stop()),this.stream=null}},o(L,"I"),L);async function ze(i,t){let e,r=new Promise(h=>{e=setTimeout(()=>h(null),Ne)}),s=await Promise.race([t,r]);if(clearTimeout(e),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(ze,"He");var He=["magenta","yellow","green","blue"],Ke={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 Ke[i]}o(zi,"ft");var Xe=4,Ve=4,$=o(i=>typeof i=="number"&&Number.isFinite(i),"D");function oe(i){if(typeof i!="object"||i===null)return!1;let t=i;if(typeof t.nonce!="string"||t.nonce.length===0||!Array.isArray(t.colours)||t.colours.length<1||t.colours.length>8||!t.colours.every(r=>He.includes(r))||!Array.isArray(t.onsetsMs)||t.onsetsMs.length!==t.colours.length)return!1;let e=-1;for(let r of t.onsetsMs){if(!$(r)||r<0||r<=e)return!1;e=r}return!(!$(t.holdMs)||t.holdMs<=0||!$(t.endMs)||t.endMs<=e||!$(t.clipMs)||t.clipMs<t.endMs||t.clipMs>8e3)}o(oe,"be");function Ze(i,t){return oe(i)?Math.max(t,Math.ceil(i.clipMs)):t}o(Ze,"ye");function je(i,t){let e=t.now??(()=>performance.now()),r=oe(i)?i:void 0,s=[],a=null,n=null,l=null,c=!1,h=null,d=o(m=>{h=m;try{t.paint(m)}catch{}},"d"),u=o(m=>{let g=t.frames?.()??null;return g!==null&&l!==null?g.mediaTimeMs+(m-g.presentationTimeMs)-l:m-(n??m)},"u"),v=o((m,g,y=0)=>{if(c)return;let p=Math.max(0,m-u(e()));a=setTimeout(()=>{if(a=null,!c){if(y<Xe&&u(e())<m-Ve){v(m,g,y+1);return}g()}},p)},"f"),w=o(m=>{if(r===void 0)return;let g=r.endMs;if(m>=r.colours.length){v(g,()=>d(null));return}let y=r.onsetsMs[m],p=m+1<r.onsetsMs.length?r.onsetsMs[m+1]:g;v(y,()=>{let M=u(e());if(M>g){h!==null&&d(null);return}let T=r.colours[m];d(T);let A=s.length===0?0:s[s.length-1].tMs;s.push({tMs:Math.max(A,Math.round(M)),colour:T});let k=y+r.holdMs;if(k<p){v(k,()=>{if(u(e())>g){h!==null&&d(null);return}d("dark"),w(m+1)});return}w(m+1)})},"v");return{started(m){if(r===void 0||c||n!==null)return;n=m;let g=t.frames?.()??null;l=g===null?null:g.mediaTimeMs+(m-g.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(je,"Me");function $e(i,t,e=.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=t.getContext("2d");if(!l){s(new Error("no-2d-context"));return}t.width=a,t.height=n,l.scale(-1,1),l.drawImage(i,-a,0),t.toBlob(c=>c?r(c):s(new Error("empty-keyframe")),"image/jpeg",e)})}o($e,"Se");var B,Ye=(B=class{constructor(t){this.timer=null,this.frameCallbackId=null,this.running=!1,this.busy=!1,this.lastRunAt=Number.NEGATIVE_INFINITY,this.degradeCount=0,this.durations=[],this.options=t,this.periodMs=1e3/t.cadenceHz}start(){if(this.running)return;this.running=!0;let t=this.options.video;if(typeof t?.requestVideoFrameCallback=="function"){let e=o(()=>{this.running&&(this.frameCallbackId=t.requestVideoFrameCallback?.(()=>{this.frameCallbackId=null,this.now()-this.lastRunAt>=this.periodMs&&this.tick(),e()}))},"t");e();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 t=this.durations.length===0?0:this.durations.reduce((e,r)=>e+r,0)/this.durations.length;return{degradeCount:this.degradeCount,meanDetectMs:t}}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 t=this.now();this.options.run().catch(()=>{}).finally(()=>{this.busy=!1,this.durations.push(this.now()-t),this.durations.length>20&&this.durations.shift()})}},o(B,"O"),B),Qe=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}),F=o(i=>Math.min(1,Math.max(0,i)),"_"),W,Jt=(W=class{constructor(t={}){this.p=0,this.lastTickAt=null,this.lastCenter=null,this.velocityEma=0,this.qWindow=[],this.lastSizeDirection="ideal",this.t={...Qe,...t}}reset(){this.p=0,this.lastTickAt=null,this.lastCenter=null,this.velocityEma=0,this.qWindow=[],this.lastSizeDirection="ideal"}tick(t){let{observation:e,quality:r,timestampMs:s}=t,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:F(r.sharpness),exposure:F(r.exposure),motion:1};if(e!==null){n.presence=1,n.single=(e.extraFaces??0)>0?0:1;let d=this.geometryOf(e,t);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=F(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((v,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(t,e){let{box:r,eyes:s}=t,a={x:e.frameWidth/2,y:e.frameHeight/2},n=Math.min(e.frameWidth,e.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-F(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 v;u<this.t.SIZE_HARD_MIN||u>this.t.SIZE_HARD_MAX?v=0:u<this.t.SIZE_IDEAL_MIN?v=(u-this.t.SIZE_HARD_MIN)/(this.t.SIZE_IDEAL_MIN-this.t.SIZE_HARD_MIN):u>this.t.SIZE_IDEAL_MAX?v=(this.t.SIZE_HARD_MAX-u)/(this.t.SIZE_HARD_MAX-this.t.SIZE_IDEAL_MAX):v=1;let w=1;if(s!==void 0){let m=Math.abs(Math.atan2(s.right.y-s.left.y,s.right.x-s.left.x))*180/Math.PI;w=1-F(m/this.t.ROLL_MAX_DEG)}return{center:l,iod:c,centering:d,size:v,pose:w}}motionOf(t,e,r){let s=this.lastCenter;if(this.lastCenter={...t,at:r},s===null||e<=0)return 1;let a=(r-s.at)/1e3;if(a<=0)return 1;let n=Math.hypot(t.x-s.x,t.y-s.y)/e/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-F(this.velocityEma/this.t.MOTION_VELOCITY_IOD_PER_S)}guidanceOf(t,e,r){if(t.presence<=0)return"fcv3.no_face";if(t.single<=0)return"fcv3.one_face";if(t.size<this.t.GUIDE_SIZE)return this.sizeGuidance();if(t.centering<this.t.GUIDE_CENTERING)return"fcv3.center_face";if(t.pose<this.t.GUIDE_POSE)return"fcv3.straighten";if(t.exposure<this.t.GUIDE_EXPOSURE)return this.exposureGuidance(e);if(t.sharpness<this.t.GUIDE_SHARPNESS)return"fcv3.steady_camera";if(t.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(e)],["sharpness","fcv3.steady_camera"],["motion","fcv3.hold_still"]],a=s[0];for(let n of s)t[n[0]]<t[a[0]]&&(a=n);return a[1]}return"fcv3.hold_still"}sizeGuidance(){return this.lastSizeDirection==="far"?"fcv3.come_closer":"fcv3.move_back"}exposureGuidance(t){let e=(it[0]+it[1])/2;return t.meanLuma<e?"fcv3.more_light":"fcv3.too_bright"}},o(W,"k"),W),Je=["single","size","centering","pose","exposure","sharpness","motion"];function ti(i){if(i.accepted)return null;if(i.factors.presence<=0)return"no_face";let t="single";for(let e of Je)i.factors[e]<i.factors[t]&&(t=e);return t}o(ti,"Ze");var q,te=(q=class{constructor(){this.blocked={},this.acceptedMs=0,this.ticks=0,this.lastAt=null}record(t){let e=this.lastAt===null?0:Math.max(0,t.at-this.lastAt);this.lastAt=t.at,this.ticks+=1;let r=ti(t);if(r===null){this.acceptedMs+=e;return}let s=this.blocked[r]??{count:0,ms:0};s.count+=1,s.ms+=e,this.blocked[r]=s}summary(){let t={};for(let[e,r]of Object.entries(this.blocked))t[e]={count:r.count,ms:Math.round(r.ms)};return{blocked:t,acceptedMs:Math.round(this.acceptedMs),ticks:this.ticks}}},o(q,"w"),q),ei=["obs","manycam","virtual","snap camera","xsplit","droidcam","iriun","camo"],ii=[/^(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 ri(i){let t=(i??"").trim().toLowerCase();return t.length===0?"unknown":ei.some(e=>t.includes(e))?"known_virtual":ii.some(e=>e.test(t))?"platform":"unknown"}o(ri,"je");function ee(i){if(typeof i!="function")return!1;try{return/\{\s*\[native code\]\s*\}\s*$/.test(Function.prototype.toString.call(i))}catch{return!1}}o(ee,"Te");function si(i=globalThis){return ee(i.navigator?.mediaDevices?.getUserMedia)&&ee(i.MediaStreamTrack?.prototype?.getSettings)}o(si,"$e");async function ai(i,t=globalThis){let e=t.crypto?.subtle?.digest;if(typeof e=="function")try{let r=new Uint8Array(await e.call(t.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(ai,"Je");async function ni(i,t=globalThis){let e={};try{e=typeof i.getSettings=="function"?i.getSettings()??{}:{}}catch{e={}}let r={};if((e.facingMode==="user"||e.facingMode==="environment"||e.facingMode==="left"||e.facingMode==="right")&&(r.facingMode=e.facingMode),typeof e.frameRate=="number"&&Number.isFinite(e.frameRate)&&(r.frameRate=e.frameRate),typeof e.width=="number"&&Number.isFinite(e.width)&&(r.width=e.width),typeof e.height=="number"&&Number.isFinite(e.height)&&(r.height=e.height),typeof e.deviceId=="string"&&e.deviceId.length>0){let a=await ai(e.deviceId,t);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:ri(s),prototypesIntact:si(t)}}o(ni,"Ce");var ot=o(i=>Math.round(i*100)/100,"H");function oi(i){let t=i,e=typeof t?.requestVideoFrameCallback=="function",r=null,s=null,a=0,n=0,l=0,c=0,h=0,d=0,u=o(()=>{!e||t?.requestVideoFrameCallback===void 0||(r=t.requestVideoFrameCallback((v,w)=>{if(r=null,!e)return;let m=w.presentationTime;if(s!==null){let g=m-s.presentationTimeMs;n+=1;let y=g-l;l+=y/n,c+=y*(g-l)}typeof w.captureTime=="number"&&Number.isFinite(w.captureTime)&&(h+=m-w.captureTime,d+=1),a+=1,s={mediaTimeMs:w.mediaTime*1e3,presentationTimeMs:m},u()}))},"u");return u(),{latest:o(()=>s,"latest"),stats:o(()=>({n:a,meanGapMs:n===0?0:ot(l),stdGapMs:n<2?0:ot(Math.sqrt(c/(n-1))),captureLatencyMs:d===0?null:ot(h/d)}),"stats"),stop:o(()=>{e&&(e=!1,r!==null&&t?.cancelVideoFrameCallback?.(r),r=null)},"stop")}}o(oi,"Ee");function li(i,t,e){return{...i,rvfc:t,rampPainter:e}}o(li,"_e");var ci=1e3,lt="fcv3.hold_upright",hi=200,ct=4,ui=600,di=1e3,ie={sharpness:1,exposure:1,meanLuma:128};function fi(i,t){return t.width=i.videoWidth,t.height=i.videoHeight,t.getContext("2d").drawImage(i,0,0),new Promise((e,r)=>t.toBlob(s=>s?e(s):r(new Error("empty-keyframe")),"image/jpeg",.92))}o(fi,"it");function mi(){return V()==="phone"}o(mi,"at");var z,le=(z=class{constructor(t){this.handlers=new Map,this.stateValue="idle",this.attempt=0,this.stream=null,this.detector=null,this.scheduler=null,this.gate=null,this.profiler=null,this.lastGuidanceKey=null,this.positioningStartedAt=0,this.cameraRequestedAt=null,this.cameraReadyAt=null,this.faceAcquiredAt=null,this.captureCompleteAt=null,this.fired=!1,this.carriedDegrade=0,this.carriedMeans=[],this.blockStats=null,this.lastGateSnapshotAt=Number.NEGATIVE_INFINITY,this.uprightGuard=!1,this.trackProvenance=null,this.ramp=null,this.snapshotCanvas=null,this.options=t,this.facing=t.facingMode??"user"}get state(){return this.stateValue}on(t,e){let r=this.handlers.get(t);return r||(r=new Set,this.handlers.set(t,r)),r.add(e),()=>r?.delete(e)}emit(t,e){for(let r of[...this.handlers.get(t)??[]])r(e)}async start(t={}){t.facingMode!==void 0&&(this.facing=t.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(t){this.facing=t,this.teardownAttempt(),this.start()}destroy(){this.attempt+=1,this.teardownAttempt(),this.detector?.destroy(),this.detector=null,this.options.video.srcObject=null}async run(t){let{options:e}=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=(e.isPhone??mi)(),this.setState("preflight");let r=Ct();if(r!=="OK"){this.fail(r==="INSECURE_CONTEXT"?"insecure":"unsupported",{phase:"preflight"});return}this.setState("acquiring");let s=e.getUserMedia??(h=>navigator.mediaDevices.getUserMedia(h)),a;this.cameraRequestedAt=this.now();try{let{facingMode:h,...d}=kt(Tt(),this.facing).video;a=await Lt(this.facing,d,{getUserMedia:s,enumerateDevices:vi(e)})}catch(h){if(t!==this.attempt)return;if(h instanceof Nt){this.fail("backcamera",{phase:"acquiring",name:K(h)});return}this.fail(Ut(h),{phase:"acquiring",name:K(h)});return}if(Et(a),Ft(a),t!==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:ni(n).catch(()=>null),this.facing=_t(a)??this.facing,e.video.srcObject=a,await e.video.play().catch(()=>{}),t!==this.attempt)return;if(this.cameraReadyAt=this.now(),this.detector===null){let h={v3AssetBaseUrl:e.v3AssetBaseUrl},d=e.createDetector??(e.createWorker!==void 0&&Zt()?async()=>{try{return await jt.create(e.createWorker(),h)}catch{return x(h)}}:()=>x(h)),u;try{u=await d()}catch(v){t===this.attempt&&this.fail("models",{phase:"models",name:K(v)},v instanceof nt?v.fallbackReason:gi(v));return}if(t!==this.attempt){u.destroy();return}this.detector=u,this.options.telemetry?.({type:"detector",tier:u.tier,fallbackReason:u.fallbackReason})}let l=Bt(),c=e.deviceClass??Wt(l);this.profiler=new qt(c),this.options.telemetry?.({type:"profile",staticClass:c,activeClass:this.profiler.deviceClass,simd:l.simd}),this.gate=new Jt(e.thresholds??{}),this.blockStats=new te,this.lastGateSnapshotAt=this.now(),e.rankKeyframes?.()&&import("./keyframe-rank-R4NPQGN3-VRURE6OQ.js").then(h=>ht=h,()=>{}),this.setState("positioning"),this.positioningStartedAt=this.now(),this.startScheduler(t)}get animations(){return this.profiler?.profile.animations??"full"}startScheduler(t){let e=this.profiler;if(e===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 Ye({cadenceHz:e.profile.cadenceHz,video:this.options.video,now:this.options.now,run:o(()=>this.detectTick(t),"run")});this.scheduler=r,r.start()}async detectTick(t){let{detector:e,gate:r,profiler:s}=this,a=this.options.video;if(t!==this.attempt||e===null||r===null||s===null||this.fired||a.videoWidth===0)return;if(this.isLandscape()){this.holdUpright(t);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 e.detect(c,a.videoWidth,a.videoHeight)}catch{h=null}if(t!==this.attempt||this.fired)return;s.record(this.now()-l),s.deviceClass!==n&&this.startScheduler(t);let d=h===null?ie: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>=ci&&(this.lastGateSnapshotAt=u.at,this.reportGate(!1)),this.emit("checks",{engine:"v3",progress:u.p,q:u.q,factors:u.factors,attempt:t}),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(t))}async fire(t){let{options:e}=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]:[]];e.telemetry?.({type:"fired",timeToGateMs:this.now()-this.positioningStartedAt,degradeCount:this.carriedDegrade+s.degradeCount,meanDetectMs:a.length===0?0:a.reduce((k,b)=>k+b,0)/a.length});let n=e.mode??"clip",l=e.rankKeyframes?.()&&ht?ht.default(this,t).catch(()=>this.collectKeyframes(t)):this.collectKeyframes(t);if(n==="photo"){let k=this.watchRotation(t,null),b=await l;if(k(),t!==this.attempt)return;if(b===null){this.fail("generic",{phase:"keyframes"});return}let I=await this.provenance({n:0,meanGapMs:0,stdGapMs:0,captureLatencyMs:null},!1);if(t!==this.attempt)return;this.finishCapture({keyframe:b.blob,previewDataUrl:b.previewDataUrl,...I});return}this.setState("recording");let c=this.stream;if(c===null){this.fail("generic",{phase:"recording"});return}let h=e.screenRamp?.(),d=h!==void 0,u=null;l.then(k=>{u=k},()=>{});let v=o(()=>{t===this.attempt&&u!==null&&this.emit("frozen",{previewDataUrl:u.previewDataUrl})},"f"),w=Ze(h,ne),m=null,g,y=0;try{let k=this.recordTake(t,c,h,w,void 0).then(_=>_,_=>({failed:_})),[b,I]=await Promise.all([k,l]);if(g=I,t!==this.attempt)return;if("failed"in b){if(b.failed.kind==="cliptoolarge")throw b.failed;$t(b.failed.requestedMimeType??"")}else m=b,Qt(b.clip,w)?b.clip.stats===null&&$t(b.clip.requestedMimeType??""):v();if(m===null||Qt(m.clip,w)){y=1,e.telemetry?.({type:"clip_retake",reason:m===null?"error":m.clip.stats===null?"unreadable":"short"});let _=null;try{_=await this.recordTake(t,c,h,w,v)}catch(H){if(m===null)throw H}if(t!==this.attempt)return;_!==null&&(m===null||We(_.clip,m.clip))&&(m=_),_===null&&v()}}catch(k){if(t!==this.attempt)return;let b=k.kind;this.fail(b==="cliptoolarge"?"cliptoolarge":"recorder",{phase:"recording",name:K(k)});return}if(m===null){this.fail("recorder",{phase:"recording"});return}let{clip:p,rvfc:M,report:T}=m;if(et(p.blob)){this.fail("cliptoolarge",{phase:"recording"});return}if(g===null){this.fail("generic",{phase:"keyframes"});return}let A=await this.provenance(M,d);t===this.attempt&&this.finishCapture({clip:p.blob,clipMimeType:p.mimeType,...p.stats?{clipStats:p.stats}:{},clipRetakes:y,keyframe:g.blob,previewDataUrl:g.previewDataUrl,...T!==void 0&&T.rendered.length>0?{screenRamp:T}:{},...A})}async recordTake(t,e,r,s,a){let n=this.options.createRecorder?.()??new qe({now:o(()=>this.now(),"now")}),l=oi(this.options.video),c=je(r,{paint:o(u=>{(u===null||t===this.attempt)&&this.emit("ramp",{colour:u})},"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(t,n);try{return{clip:await n.record(e,a,()=>c.started(this.now()),s,l),rvfc:l.stats(),report:c.report()}}finally{d(),h()}}async provenance(t,e){let r=this.trackProvenance;if(r===null)return{};let s,a=new Promise(l=>{s=setTimeout(()=>l(null),di)}),n=await Promise.race([r,a]);return clearTimeout(s),n===null?{}:{provenance:li(n,t,e)}}isLandscape(){let t=this.options.video;return this.uprightGuard&&t.videoWidth>t.videoHeight}holdUpright(t){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:t}),this.lastGuidanceKey!==lt&&(this.lastGuidanceKey=lt,this.emit("guidance",{key:lt}))}watchRotation(t,e){if(!this.uprightGuard)return()=>{};let r=this.options.video,s=o(()=>{if(t!==this.attempt||e!==null&&this.stateValue!=="recording"){l();return}r.videoWidth>0&&this.isLandscape()&&(l(),this.abortRecording(t,e))},"n"),a=setInterval(s,hi);r.addEventListener?.("resize",s);let n=!1;function l(){n||(n=!0,clearInterval(a),r.removeEventListener?.("resize",s))}return o(l,"o"),l}abortRecording(t,e){if(t!==this.attempt)return;this.attempt+=1;let r=this.attempt;try{e?.stop()}catch{}this.ramp?.stop(),this.ramp=null,this.fired=!1,this.captureCompleteAt=null,this.gate=new Jt(this.options.thresholds??{}),this.blockStats=new te,this.lastGateSnapshotAt=this.now(),this.lastGuidanceKey=null,this.setState("positioning"),this.positioningStartedAt=this.now(),this.holdUpright(r),this.startScheduler(r)}async collectKeyframes(t){let e=this.options.captureKeyframe??(a=>this.defaultKeyframe(a)),r=ui/(ct-1),s=null;for(let a=0;a<ct;a+=1){if(t!==this.attempt)return s;try{let n=await e(this.options.video);(s===null||n.sharpness>s.sharpness)&&(s=n)}catch{}a<ct-1&&await pi(r)}return s}finishCapture(t){this.stopTracks(),this.setState("captured");let e=this.captureTiming();this.emit("artifacts",e===void 0?t:{...t,timing:e})}captureTiming(){let t={},e=o((r,s,a)=>{s!==null&&a!==null&&(t[r]=Math.max(0,Math.round(a-s)))},"t");return e("cameraReadyMs",this.cameraRequestedAt,this.cameraReadyAt),e("faceAcquireMs",this.cameraReadyAt,this.faceAcquiredAt),e("captureMs",this.faceAcquiredAt,this.captureCompleteAt),Object.keys(t).length>0?t:void 0}async defaultKeyframe(t){let e=document.createElement("canvas"),r=await(this.facing==="user"?$e:fi)(t,e),s=e.toDataURL("image/jpeg",.92);return{blob:r,previewDataUrl:s,sharpness:this.centerSharpness(t)}}defaultSnapshot(t,e){try{let r=this.snapshotCanvas??document.createElement("canvas"),s=e/Math.max(1,t.videoWidth),a=Math.max(1,Math.round(t.videoWidth*s)),n=Math.max(1,Math.round(t.videoHeight*s)),l=r.getContext("2d");return l===null?t:(r.width!==a&&(r.width=a),r.height!==n&&(r.height=n),l.drawImage(t,0,0,a,n),this.snapshotCanvas=r,r)}catch{return t}}defaultQuality(t,e){let r=re(t,e,96);return r===null?ie:{sharpness:rt(r),exposure:Ht(r),meanLuma:zt(r)}}centerSharpness(t){let e=Z(t),r=re(t,{x:e.width*.25,y:e.height*.25,width:e.width*.5,height:e.height*.5},96);return r===null?0:rt(r)}teardownAttempt(){this.scheduler?.stop(),this.scheduler=null,this.reportGate(!0),this.gate=null,this.ramp?.stop(),this.ramp=null,this.stopTracks()}reportGate(t){let e=this.blockStats,r=this.profiler;if(e===null||r===null)return;let s=e.summary();t&&(this.blockStats=null),s.ticks!==0&&this.options.telemetry?.({type:"gate",final:t,activeClass:r.deviceClass,cadenceHz:r.profile.cadenceHz,...s})}stopTracks(){if(this.stream!==null){for(let t of this.stream.getTracks())t.stop();this.stream=null}}fail(t,e,r){this.scheduler?.stop(),this.reportGate(!0),this.stopTracks(),this.setState("error"),this.options.telemetry?.({type:"error",kind:t,fallbackReason:r});let{phase:s,name:a}=e;this.emit("error",{kind:t,retryable:t!=="insecure"&&t!=="unsupported",detail:a===void 0?{phase:s}:{phase:s,name:a}})}setState(t){this.stateValue=t,this.emit("statechange",{state:t})}now(){return this.options.now?.()??performance.now()}},o(z,"ke"),z),ht;function pi(i){return new Promise(t=>setTimeout(t,i))}o(pi,"st");function gi(i){return i instanceof Error?i.message:String(i)}o(gi,"ot");function re(i,t,e){try{let r=document.createElement("canvas"),s=e/Math.max(1,t.width);r.width=Math.max(1,Math.round(t.width*s)),r.height=Math.max(1,Math.round(t.height*s));let a=r.getContext("2d");return a===null?null:(a.drawImage(i,t.x,t.y,t.width,t.height,0,0,r.width,r.height),a.getImageData(0,0,r.width,r.height))}catch{return null}}o(re,"we");function vi(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(vi,"lt");var yi=12e4,ce=13e4,wi=3e3,bi=1200,ut=Symbol.for("@sekyro/web.preload.v1");function ft(){let i=globalThis;return i[ut]??(i[ut]=new Map),i[ut]}o(ft,"g");function Y(i){let t=(i??at).replace(/\/+$/,"");return t===""?"/":t}o(Y,"S");function ue(i){let t=ft(),e=t.get(i);return e===void 0&&(e={status:"idle",promise:null,scheduled:null,detectorPromise:null,detector:null,listeners:new Set},t.set(i,e)),e}o(ue,"se");function dt(i,t){if(i.status!==t){i.status=t;for(let e of[...i.listeners])e(t)}}o(dt,"A");var Mi=o(i=>x({preferred:["blaze"],v3AssetBaseUrl:i,blazeInitTimeoutMs:yi}),"x"),ki=Mi;function Ti(){return typeof window<"u"&&typeof navigator<"u"&&typeof navigator.mediaDevices?.getUserMedia=="function"}o(Ti,"pe");function _i(){return navigator.connection?.saveData===!0}o(_i,"me");function Ei(i){let t=window;if(typeof t.requestIdleCallback=="function"){let r=t.requestIdleCallback(i,{timeout:wi});return()=>t.cancelIdleCallback?.(r)}let e=setTimeout(i,bi);return()=>clearTimeout(e)}o(Ei,"ve");function Si(i,t){let e,r=new Promise(l=>{e=l}),s=!1,a=o(()=>{},"d"),n={promise:r,settle:o(l=>{s||(s=!0,a(),i.scheduled===n&&(i.scheduled=null),e(l))},"settle")};return i.scheduled=n,a=Ei(()=>{s||n.settle(mt(i,t))}),r}o(Si,"ge");function mt(i,t){if((i.status==="loading"||i.status==="ready")&&i.promise!==null)return i.promise;dt(i,"loading");let e=new Promise(n=>n(ki(t)));i.detectorPromise=e;let r,s=new Promise((n,l)=>{r=setTimeout(()=>{e.then(c=>c.destroy(),()=>{}),l(new Error(`detector preload exceeded ${ce} ms`))},ce)}),a=Promise.race([e,s]).then(n=>i.detectorPromise!==e?(n.destroy(),i.status):(i.detector=n,dt(i,"ready"),"ready"),n=>(i.detectorPromise===e&&(i.detectorPromise=null,i.detector=null,dt(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(mt,"I");function Yi(i={}){if(!Ti())return Promise.resolve("idle");let t=Y(i.assetBaseUrl),e=ue(t);return i.respectSaveData===!0&&_i()?Promise.resolve(e.status):(e.status==="loading"||e.status==="ready")&&e.promise!==null?e.promise:i.idle===!0?e.scheduled?.promise??Si(e,t):mt(e,t)}o(Yi,"we");function Qi(i){return ft().get(Y(i))?.status??"idle"}o(Qi,"ke");function Ji(i,t){let e=ue(Y(t));return e.listeners.add(i),()=>{e.listeners.delete(i)}}o(Ji,"De");function Ai(i){return{get tier(){return i.tier},get fallbackReason(){return i.fallbackReason},detect:o((...t)=>i.detect(...t),"detect"),destroy:o(()=>{},"destroy")}}o(Ai,"he");function Ii(i){let t=Y(i),e=ft().get(t);if(!(e===void 0||e.detector===null&&e.detectorPromise===null&&e.scheduled===null))return async()=>{e.scheduled!==null&&mt(e,t);let r=e.promise;for(;e.detector===null&&r!==null&&(await r,e.promise!==r);)r=e.promise;return e.detector!==null?Ai(e.detector):x({v3AssetBaseUrl:t})}}o(Ii,"oe");function xi(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(xi,"Ce");function Di(i){switch(i){case"preflight":case"acquiring":return"starting";case"positioning":return"gating";default:return i}}o(Di,"Se");function he(i){switch(i){case"permission":case"notfound":case"inuse":case"insecure":case"unsupported":return i;case"backcamera":return"notfound";default:{let t=i;return"generic"}}}o(he,"ie");function Ri(i,t,e){if(e===void 0)return{kind:he(i),retryable:t};let r=Gt(e.name);return{kind:he(i),retryable:t,detail:{...r!==void 0?{name:r}:{},phase:e.phase,engineKind:i}}}o(Ri,"Le");var Ci=new Set(["captured","uploading","checking"]);function Oi(i,t={},e,r=()=>"self",s=()=>{},a){let n=t.now??(()=>performance.now()),l=t.canChooseFacing??At,c="user",h=It(),d=r(),u=St(),v=!Ot(),w=t.engineOptions,m=w?.createDetector===void 0&&w?.createWorker===void 0?{createDetector:o(()=>{let f=Ii(i.assetBaseUrl);return f!==void 0?f():x({v3AssetBaseUrl:i.assetBaseUrl})},"createDetector")}:{},g={video:i.video,mode:v?"photo":"clip",rankKeyframes:e,facingMode:void 0,v3AssetBaseUrl:i.assetBaseUrl,screenRamp:o(()=>d==="self"&&u.count("ramp")>0?s():void 0,"screenRamp"),...t.engineOptions??{},...m},y=t.createEngine?.(g)??new le(g),p="idle",M=null,T=0,A=!1,k="full",b=null,I=null,_=0,H=0,pt=o(()=>{i.video.videoWidth>0&&i.video.videoHeight>0&&(_=i.video.videoWidth,H=i.video.videoHeight)},"K"),gt=xt({enabled:i.keepScreenAwake!==!1}),X=o(f=>{p=f,gt.setActive(f==="starting"||f==="gating"||f==="recording"),u.emit("state",f)},"M"),Q=o(()=>u.emit("gate",{progress:T,hint:M,faceDetected:A}),"R"),vt=o(()=>{let f=y.animations??"full";f!==k&&(k=f,u.emit("profile",{animations:k}))},"G"),de=[y.on("statechange",({state:f})=>{let E=Di(f);E==="starting"&&p!=="starting"&&(M=null,T=0,A=!1,b=null,I=null,_=0,H=0),X(E),vt(),E==="recording"&&(pt(),b=n(),M="hold",T=1,Q())}),y.on("checks",f=>{pt(),T=f.progress,A=f.factors.presence>0,Q(),vt()}),y.on("guidance",({key:f})=>{M=xi(f),Q()}),y.on("frozen",({previewDataUrl:f})=>{I=n(),u.emit("frozen",{previewDataUrl:f})}),y.on("ramp",f=>u.emit("ramp",f)),y.on("artifacts",f=>{if(p!=="captured")return;let E=V(),S=f.clipStats,bt=S!==void 0?Math.round(S.durationMs):b!==null&&I!==null?Math.max(0,Math.round(I-b)):void 0,Mt=S!==void 0&&S.frames>1&&S.durationMs>0?Math.round(S.frames*1e4/S.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||_,height:i.video.videoHeight||H,...bt!==void 0?{clipMs:bt}:{},...S!==void 0?{clipFrames:S.frames}:{},...Mt!==void 0?{fps:Mt}:{},...f.clipRetakes!==void 0?{clipRetakes:f.clipRetakes}:{},...f.clipMimeType!==void 0?{codec:ae(f.clipMimeType)}:{},captureChannel:E==="desktop"?"desktop":"mobile",formFactor:E,...v?{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:E,detail:S})=>{f==="backcamera"&&fe()||u.emit("error",Ri(f,E,S))})],yt=!1;function fe(){return J||yt||d!=="assisted"||a===void 0||a.session()!=="choice"?!1:(yt=!0,a.onModeChange("self"),d="self",c=tt("self"),X("mode_switch"),y.restart(c),!0)}o(fe,"ce");let wt=o(async()=>a!==void 0&&a.session()==="choice"&&await l().catch(()=>!1),"W"),J=!1;return{handle:{get state(){return p},get captureMode(){return r()},get facingMode(){return y.facingMode??c},on:o((f,E)=>u.on(f,E),"on"),start:o(f=>(d=r(),h.facing(d,i.facing),c=h.facing(d,f?.facing),y.start({facingMode:c})),"start"),retry:o(()=>y.retry(),"retry"),switchCamera:o(()=>h.refuseSwitch(r()),"switchCamera"),canSwitchCaptureMode:wt,setCaptureMode:o(async f=>{if(f===r()||!await wt()||J||Ci.has(p)||a===void 0)return!1;a.onModeChange(f),d=f;let E=tt(f);return c=E,p==="idle"||(X("mode_switch"),y.restart(E)),!0},"setCaptureMode"),destroy:o(()=>{J=!0;for(let f of de)f();gt.setActive(!1),y.destroy(),u.clear()},"destroy")},setFlowState:o(f=>{p!==f&&X(f)},"setFlowState")}}o(Oi,"Ee");function tr(i){return Oi(i).handle}o(tr,"ze");export{zi as a,Yi as b,Qi as c,Ji as d,Ri as e,Oi as f,tr as g};
@@ -1 +1 @@
1
- import{a as t,b as r,c as m,d as o}from"./chunk-KPGTFHQU.js";import"./chunk-SK6UAYX2.js";import"./chunk-CMS5FVGM.js";import"./chunk-HODE7UDG.js";import"./chunk-TCW6XNLI.js";import"./chunk-UZWMCNZI.js";import"./chunk-D334IAZJ.js";import"./chunk-RRLXNT33.js";import"./chunk-4FHWXBOB.js";export{t as SAME_FACE_MAX_DROPS,m as createDocumentCapture,o as createDocumentCaptureInternal,r as warmDocumentCapture};
1
+ import{a as t,b as r,c as m,d as o}from"./chunk-CFJJD6T2.js";import"./chunk-SK6UAYX2.js";import"./chunk-CMS5FVGM.js";import"./chunk-ZKLSZJFN.js";import"./chunk-6H22RNSK.js";import"./chunk-UZWMCNZI.js";import"./chunk-D334IAZJ.js";import"./chunk-RRLXNT33.js";import"./chunk-4FHWXBOB.js";export{t as SAME_FACE_MAX_DROPS,m as createDocumentCapture,o as createDocumentCaptureInternal,r as warmDocumentCapture};
@@ -1 +1 @@
1
- "use client";import{a as Ge}from"./chunk-Z3EEB4CI.js";import{a as Ve}from"./chunk-562ANROG.js";import{a as Ie,b as Oe,c as Ee}from"./chunk-2SENV5CV.js";import"./chunk-OBPBHX2J.js";import{d as Be}from"./chunk-3VYQXVW4.js";import"./chunk-OIJVTJML.js";import{E as Ae,F as Re,G as Pe,I as Ue,K as pe,L as me,a as ct,b as dt,c as O,o as He,q as De,v as Y,w as ue,y as he}from"./chunk-UYAVCSQ4.js";import{a as h}from"./chunk-RK4HVNRS.js";import{a as c,c as _e}from"./chunk-4FHWXBOB.js";var i=_e(ct(),1),e=_e(dt(),1);var ut={image:'<path d="M2 12C2 7.29 2 4.93 3.46 3.46C4.93 2 7.29 2 12 2C16.71 2 19.07 2 20.54 3.46C22 4.93 22 7.29 22 12C22 16.71 22 19.07 20.54 20.54C19.07 22 16.71 22 12 22C7.29 22 4.93 22 3.46 20.54C2 19.07 2 16.71 2 12Z" stroke="currentColor"/><path d="M14 8A2 2 0 1 0 18 8A2 2 0 1 0 14 8Z" stroke="currentColor"/><path d="M2 12.5L3.75 10.97C4.66 10.17 6.04 10.22 6.89 11.07L11.18 15.36C11.87 16.05 12.95 16.14 13.75 15.58L14.04 15.37C15.19 14.57 16.74 14.66 17.78 15.6L21 18.5" stroke="currentColor" stroke-linecap="round"/>',flashlight:'<path d="M9 11.66V19C9 19.93 9 20.4 9.15 20.77C9.36 21.26 9.74 21.64 10.23 21.85C10.6 22 11.07 22 12 22C12.93 22 13.4 22 13.77 21.85C14.26 21.64 14.64 21.26 14.85 20.77C15 20.4 15 19.93 15 19V11.66C15 10.84 15 10.43 15.15 10.06C15.3 9.7 15.59 9.41 16.17 8.83L16.17 8.83L19.41 5.59C19.7 5.3 19.85 5.15 19.92 4.97C20 4.78 20 4.58 20 4.17V4C20 3.06 20 2.59 19.71 2.29C19.41 2 18.94 2 18 2H6C5.06 2 4.59 2 4.29 2.29C4 2.59 4 3.06 4 4V4.17C4 4.58 4 4.78 4.08 4.97C4.15 5.15 4.3 5.3 4.59 5.59L7.83 8.83C8.41 9.41 8.7 9.7 8.85 10.06C9 10.43 9 10.84 9 11.66Z" stroke="currentColor" stroke-linecap="round"/><path d="M15 10H9" stroke="currentColor" stroke-linecap="round"/><path d="M12 13V15" stroke="currentColor" stroke-linecap="round"/><path d="M4.5 5H19.5" stroke="currentColor" stroke-linecap="round"/>'},ht={"dcv3.mrz.searching":"ضع صفحة جواز السفر كاملة داخل الإطار","dcv3.mrz.showMrzSide":"اعرض الوجه الذي يحتوي على سطرين أو ثلاثة أسطر من الحروف","dcv3.mrz.reading":"جارٍ قراءة الوثيقة… ثبّتها","dcv3.mrz.moveCloser":"اقترب حتى تملأ أسطر الحروف الإطار","dcv3.mrz.turnSideways":"أدر هاتفك أفقيًا لقراءة أسطر الحروف","dcv3.mrz.glare":"أمِل الوثيقة لإزالة الانعكاس","dcv3.mrz.holdStill":"لا تتحرك","dcv3.mrz.valid":"تمت قراءة الوثيقة. جارٍ التقاط الصورة","dcv3.mrz.looksLikePassport":"يبدو أن هذا جواز سفر","dcv3.mrz.looksLikeCard":"يبدو أن هذه بطاقة تعريف أو بطاقة إقامة"},ee={"dcv3.mrz.searching":"Fit the whole passport page in the frame","dcv3.mrz.showMrzSide":"Show the side with the two or three lines of characters","dcv3.mrz.reading":"Reading the document… hold it steady","dcv3.mrz.moveCloser":"Move closer so the lines of characters fill the frame","dcv3.mrz.turnSideways":"Turn your phone sideways to read the lines of characters","dcv3.mrz.glare":"Tilt the document to remove the reflection","dcv3.mrz.holdStill":"Hold still","dcv3.mrz.valid":"Document read. Taking the photo","dcv3.mrz.looksLikePassport":"This looks like a passport","dcv3.mrz.looksLikeCard":"This looks like an identity card or residence permit"},pt={"dcv3.mrz.searching":"Cadrez toute la page du passeport","dcv3.mrz.showMrzSide":"Montrez la face avec les deux ou trois lignes de caractères","dcv3.mrz.reading":"Lecture du document… tenez-le immobile","dcv3.mrz.moveCloser":"Rapprochez-vous pour que les lignes de caractères remplissent le cadre","dcv3.mrz.turnSideways":"Tournez votre téléphone à l’horizontale pour lire les lignes de caractères","dcv3.mrz.glare":"Inclinez le document pour supprimer le reflet","dcv3.mrz.holdStill":"Ne bougez plus","dcv3.mrz.valid":"Document lu. Prise de la photo","dcv3.mrz.looksLikePassport":"Ceci ressemble à un passeport","dcv3.mrz.looksLikeCard":"Ceci ressemble à une carte d’identité ou un titre de séjour"},mt={"doc.uploadInstead":"رفع صورة بدلًا من ذلك","doc.uploadTitle":"ارفع صورة لوثيقتك","doc.uploadHint":"صورة واضحة للوثيقة كاملة، ملتقطة بكاميرا.","doc.uploadUnsupported":"اختر صورة للوثيقة بصيغة JPEG أو PNG أو HEIC.","doc.uploadFailed":"تعذّر إرسال هذه الصورة. أعد المحاولة.","doc.source.title":"كيف تريد إضافة وثيقتك؟","doc.source.description":"التقط صورة بالكاميرا، أو ارفع صورة للوثيقة من هذا الجهاز.","doc.source.camera":"التقاط صورة","doc.source.upload":"رفع صورة"},te={"doc.uploadInstead":"Upload a photo instead","doc.uploadTitle":"Upload a photo of your document","doc.uploadHint":"A clear photo of the whole document, taken with a camera.","doc.uploadUnsupported":"Choose a JPEG, PNG or HEIC photo of the document.","doc.uploadFailed":"We could not send this photo. Try again.","doc.source.title":"How do you want to add your document?","doc.source.description":"Take a photo with the camera, or upload a photo of the document from this device.","doc.source.camera":"Take a photo","doc.source.upload":"Upload a photo"},vt={"doc.uploadInstead":"Téléverser une photo à la place","doc.uploadTitle":"Téléversez une photo de votre document","doc.uploadHint":"Une photo nette du document entier, prise avec un appareil photo.","doc.uploadUnsupported":"Choisissez une photo JPEG, PNG ou HEIC du document.","doc.uploadFailed":"Nous n'avons pas pu envoyer cette photo. Réessayez.","doc.source.title":"Comment voulez-vous ajouter votre document ?","doc.source.description":"Prenez une photo avec la caméra, ou importez une photo du document depuis cet appareil.","doc.source.camera":"Prendre une photo","doc.source.upload":"Importer une photo"},ft={"native.doc.introTitle":"سنلتقط صورة لوثيقتك","native.doc.introLead":"ستُفتح كاميرا هاتفك، وتُلتقط الصورة تلقائيًا بمجرد أن تكون الوثيقة داخل الإطار.","native.doc.tip.flat":"ضع الوثيقة مسطحة على سطح داكن.","native.doc.tip.glare":"تجنّب انعكاسات المصابيح أو الشمس.","native.doc.tip.frame":"أبقِ الوثيقة كاملة داخل الإطار.","native.doc.openCamera":"افتح الكاميرا","native.doc.changeDocument":"تغيير الوثيقة","native.scan.closer":"اقترب قليلًا","native.scan.farther":"ابتعد قليلًا","native.scan.glare":"أمِل البطاقة قليلًا","native.scan.dark":"الإضاءة ضعيفة. شغّل المصباح.","native.scan.blurry":"الصورة غير واضحة. ثبّت الهاتف.","native.scan.holdStill":"لا تتحرك","native.scan.reading":"جارٍ التحقق من وثيقتك…","native.scan.putDown":"يمكنك وضع وثيقتك جانبًا.","native.scan.retry":"لنحاول مرة أخرى"},ae={"native.doc.introTitle":"Photograph your document","native.doc.introLead":"Your phone's camera will open. The photo is taken by itself as soon as the document is well framed.","native.doc.tip.flat":"Lay the document flat on a dark surface.","native.doc.tip.glare":"Avoid glare from lamps or sunlight.","native.doc.tip.frame":"Keep the whole document in the frame.","native.doc.openCamera":"Open the camera","native.doc.changeDocument":"Change document","native.scan.closer":"Move a little closer","native.scan.farther":"Move back a little","native.scan.glare":"Tilt the card a little","native.scan.dark":"Too dark. Turn on the light.","native.scan.blurry":"Blurry image. Hold the phone still.","native.scan.holdStill":"Hold still","native.scan.reading":"Checking your document…","native.scan.putDown":"You can put your document down.","native.scan.retry":"Let's try that again"},kt={"native.doc.introTitle":"Photographiez votre pièce","native.doc.introLead":"La caméra de votre téléphone va s'ouvrir. La photo est prise automatiquement dès que la pièce est bien cadrée.","native.doc.tip.flat":"Posez la pièce à plat, sur une surface sombre.","native.doc.tip.glare":"Évitez les reflets de lampe ou de soleil.","native.doc.tip.frame":"Gardez toute la pièce dans le cadre.","native.doc.openCamera":"Ouvrir la caméra","native.doc.changeDocument":"Changer de document","native.scan.closer":"Approchez un peu","native.scan.farther":"Reculez un peu","native.scan.glare":"Inclinez un peu la carte","native.scan.dark":"Trop sombre. Allumez la lampe.","native.scan.blurry":"Image floue. Tenez le téléphone immobile.","native.scan.holdStill":"Ne bougez plus","native.scan.reading":"Vérification de votre document…","native.scan.putDown":"Vous pouvez poser votre pièce.","native.scan.retry":"Réessayons"},gt=["locking","capturing"],W,Ye=(W=class{constructor(){this.shown={hint:null,locking:!1,card:null,manualShutter:!1},this.candidate=null,this.candidateSince=0,this.hintShownAt=0,this.lockLostAt=null,this.detectedSince=null,this.lostSince=null,this.shutterSince=null}present(t,n){return this.presentHint(t,n),this.presentLock(t,n),this.presentCard(t,n),this.shutterSince=t.manualShutter?this.shutterSince??n:null,this.shown={...this.shown,manualShutter:this.shutterSince!==null&&n-this.shutterSince>=1e3},this.shown}presentHint(t,n){let o=t.phase==="framing"&&!(t.hint==="blurry"&&t.card===null)?t.hint:null;if(t.phase!=="framing"){this.shown={...this.shown,hint:null},this.candidate=null;return}if(o!==this.candidate&&(this.candidate=o,this.candidateSince=n),o===this.shown.hint)return;let r=n-this.candidateSince>=(o===null?0:350),f=this.shown.hint===null||n-this.hintShownAt>=1200;r&&f&&(this.shown={...this.shown,hint:o},this.hintShownAt=n)}presentLock(t,n){if(gt.includes(t.phase)){this.shown={...this.shown,locking:!0},this.lockLostAt=null;return}if(this.shown.locking){if(t.phase!=="framing"){this.shown={...this.shown,locking:!1},this.lockLostAt=null;return}this.lockLostAt??(this.lockLostAt=n),n-this.lockLostAt>=300&&(this.shown={...this.shown,locking:!1},this.lockLostAt=null)}}presentCard(t,n){let o=t.card;if(o===null||t.phase!=="framing"){if(t.phase!=="framing"){this.shown={...this.shown,card:null},this.detectedSince=null,this.lostSince=null;return}this.detectedSince=null,this.lostSince??(this.lostSince=n),n-this.lostSince>=300&&(this.shown={...this.shown,card:null});return}if(this.lostSince=null,this.detectedSince??(this.detectedSince=n),n-this.detectedSince<250)return;let r=this.shown.card;if(r===null){this.shown={...this.shown,card:{...o}};return}let f=.35;this.shown={...this.shown,card:{fill:r.fill+(o.fill-r.fill)*f,offsetX:r.offsetX+(o.offsetX-r.offsetX)*f,offsetY:r.offsetY+(o.offsetY-r.offsetY)*f}}}},c(W,"fe"),W);h(Ye,"ScanPresenter");var yt=Ye,wt={en:ae,fr:kt,ar:ft,es:ae,pt:ae,de:ae},Ct=450,fe=h(a=>t=>Ve(a.strings[t]??wt[a.locale][t]??""),"useScanCopy");function j({name:a}){return(0,e.jsx)("svg",{className:"sekyro-glyph",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",focusable:"false",dangerouslySetInnerHTML:{__html:ut[a]}})}c(j,"ae");h(j,"ScanGlyph");var zt={en:ee,fr:pt,ar:ht,es:ee,pt:ee,de:ee},bt={en:te,fr:vt,ar:mt,es:te,pt:te,de:te},St="image/jpeg,image/png,image/heic,image/heif";function E(a){let t=a.strings,n=h(o=>t[o]??bt[a.locale][o],"text");return{t:h(o=>n(o)??"","t")}}c(E,"F");h(E,"uploadCopy");function We(a,t){return a===null||a.state==="fallback"||a.state==="mismatch"?null:a.state==="searching"?t?"dcv3.mrz.searching":"dcv3.mrz.showMrzSide":a.state==="valid"?"dcv3.mrz.valid":a.coach!==void 0?`dcv3.mrz.${a.coach}`:"dcv3.mrz.reading"}c(We,"vt");h(We,"mrzInstruction");function ne(a){return a.reason==="unreadable"?"doc.reason_unreadable":a.reason==="tester_document_mismatch"?"reasons.tester_document_mismatch":a.reason!==void 0&&a.reason!=="side_missing"?De(a.reason):null}c(ne,"ve");h(ne,"reasonOf");var Nt=new Set(["document_type_not_accepted","tester_document_mismatch"]);function xt({step:a,i18n:t,liveMrz:n,ageLead:o,...r}){let[f,g]=(0,i.useState)(!1),y=(0,i.useRef)(-1),[v,k]=(0,i.useState)("idle"),w=(0,i.useRef)(null),x=typeof a.uploadDocument=="function",z=x?a.photo?.source??"camera":"camera",M=x&&z!=="camera"&&a.photo?.uploadOffered===!0,[C,V]=(0,i.useState)(null),_=z==="upload"?"upload":z==="choice"?C??a.photo?.pick??"source":"camera",H=v==="sending"?void 0:()=>w.current?.click(),m=h(async D=>{let q=D.currentTarget.files?.[0];if(D.currentTarget.value="",q!==void 0){g(!1),k("sending");try{await a.uploadDocument(q),k("idle")}catch(F){k(F instanceof TypeError&&F.message==="unsupported_file"?"unsupported":"failed")}}},"onFile"),Q=M?(0,e.jsx)("input",{ref:w,type:"file",accept:St,hidden:!0,"data-testid":"sekyro-doc-upload","aria-label":E(t).t("doc.uploadTitle"),onChange:c(D=>{m(D)},"onChange")}):null,b=E(t),X=a.photo?.cameraOnPhone===!0;return _==="camera"&&X?(0,e.jsx)(Be,{i18n:t,lead:t.t("handoff.lead.document"),refresh:a.refresh,actions:(0,e.jsx)(O,{kind:"ghost",full:!0,onClick:c(()=>V("upload"),"onClick"),children:b.t("doc.source.upload")})}):_==="source"?(0,e.jsx)(Ge,{testId:"sekyro-doc-source",title:b.t("doc.source.title"),lead:b.t("doc.source.description"),cameraLabel:X?t.t("capture.source.phone"):b.t("doc.source.camera"),onPhone:X,uploadLabel:b.t("doc.source.upload"),notice:(0,e.jsx)(oe,{step:a,i18n:t}),onCamera:c(()=>V("camera"),"onCamera"),onUpload:c(()=>V("upload"),"onUpload")}):_==="upload"?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(je,{step:a,i18n:t,ageLead:o===!0,upload:v,offered:M,onPick:c(()=>w.current?.click(),"onPick"),...z==="choice"?{onCamera:h(()=>V("camera"),"onCamera")}:{},...r}),Q]}):(0,e.jsxs)(e.Fragment,{children:[f?(0,e.jsx)(Qe,{step:a,i18n:t,attempts:y,...n!==void 0?{liveMrz:n}:{},...M&&H!==void 0?{onUpload:H}:{},onClose:c(()=>g(!1),"onClose")}):(0,e.jsx)(Fe,{step:a,i18n:t,ageLead:o===!0,onOpen:c(()=>g(!0),"onOpen"),upload:v,...M&&H!==void 0?{onUpload:H}:{},...r}),Q]})}c(xt,"ln");h(xt,"DocumentCaptureView");function ke({passport:a}){let t=Math.round(228/(a?1.42:1.586));return(0,e.jsxs)("svg",{className:"sekyro-mark sekyro-mark--card",viewBox:`-12 -12 252 ${t+24}`,"aria-hidden":"true",focusable:"false",children:[(0,e.jsx)("defs",{children:(0,e.jsx)("clipPath",{id:"sekyro-card-clip",children:(0,e.jsx)("rect",{width:228,height:t,rx:"12.5"})})}),(0,e.jsx)("rect",{className:"sekyro-mark__card",width:228,height:t,rx:"12.5"}),(0,e.jsx)("rect",{className:"sekyro-mark__photo",x:"17",y:"17",width:"55",height:t*.52,rx:"6"}),[0,1,2].map(n=>(0,e.jsx)("rect",{className:"sekyro-mark__text",x:"88",y:23+n*t*.12,width:100-n*20,height:"6",rx:"3"},n)),[0,1].map(n=>(0,e.jsx)("rect",{className:"sekyro-mark__text",x:"17",y:t*.74+n*9,width:194,height:"4",rx:"2"},n)),(0,e.jsx)("g",{clipPath:"url(#sekyro-card-clip)",children:(0,e.jsx)("g",{className:"sekyro-mark__read",style:{"--sekyro-read-w":"228px"},children:(0,e.jsx)("rect",{x:"-1",width:"2",height:t,className:"sekyro-mark__beam"})})}),(0,e.jsx)("path",{className:"sekyro-mark__brackets",d:Xe(-10,-10,248,t+20,16,30)})]})}c(ke,"qe");h(ke,"ScanMark");function Xe(a,t,n,o,r,f){let g=Math.min(r,f*.6);return[[a,t,1,1],[a+n,t,-1,1],[a,t+o,1,-1],[a+n,t+o,-1,-1]].map(([y,v,k,w])=>`M${y} ${v+w*f}V${v+w*g}Q${y} ${v} ${y+k*g} ${v}H${y+k*f}`).join("")}c(Xe,"kt");h(Xe,"brackets");function Fe({step:a,i18n:t,ageLead:n,onOpen:o,onChangeCountry:r,onChangeDocument:f,upload:g,onUpload:y}){let v=fe(t),k=E(t),w=a.documentType==="passport",x=ne(a),z=g==="sending",M=(0,i.useContext)(Re)?.busy===!0;return(0,e.jsxs)("section",{className:"sekyro-step","data-testid":"sekyro-document",children:[(0,e.jsx)(ke,{passport:w}),(0,e.jsx)(ue,{title:v("native.doc.introTitle"),lead:n?t.t("doc.ageStepUp"):v("native.doc.introLead")}),(0,e.jsx)(oe,{step:a,i18n:t}),a.reason!==void 0&&Nt.has(a.reason)?null:(0,e.jsxs)("ul",{className:"sekyro-tiprows",children:[(0,e.jsxs)("li",{children:[(0,e.jsx)(Y,{name:w?"passport":"card"}),v("native.doc.tip.flat")]}),(0,e.jsxs)("li",{children:[(0,e.jsx)(Y,{name:"light"}),v("native.doc.tip.glare")]}),(0,e.jsxs)("li",{children:[(0,e.jsx)(j,{name:"image"}),v("native.doc.tip.frame")]})]}),(0,e.jsx)(ge,{i18n:t,...f!==void 0?{onChangeDocument:f}:{},...r!==void 0?{onChangeCountry:r}:{}}),(0,e.jsx)(ye,{i18n:t,upload:g}),z?(0,e.jsx)("p",{className:"sekyro-text-muted",role:"status",children:t.t("doc.uploading")}):y!==void 0?(0,e.jsx)("p",{className:"sekyro-text-muted",children:k.t("doc.uploadHint")}):null,(0,e.jsxs)(he,{children:[(0,e.jsxs)(O,{full:!0,onClick:o,disabled:z||M,children:[(0,e.jsx)(Y,{name:"camera"}),v("native.doc.openCamera")]}),y!==void 0?(0,e.jsxs)(O,{full:!0,kind:"ghost",onClick:y,children:[(0,e.jsx)(j,{name:"image"}),k.t("doc.uploadInstead")]}):null]})]})}c(Fe,"bt");h(Fe,"DocumentIntro");function oe({step:a,i18n:t}){let n=ne(a);return n===null?null:(0,e.jsxs)(pe,{tone:"warning",children:[(0,e.jsx)("span",{children:t.t(n)}),(0,e.jsx)("span",{children:me(t,a.attemptsRemaining,a.attemptsExhausted)})]})}c(oe,"ye");h(oe,"ReasonNotice");function ge({i18n:a,onChangeCountry:t,onChangeDocument:n}){let o=fe(a);return n===void 0&&t===void 0?null:(0,e.jsxs)("div",{className:"sekyro-links",children:[n!==void 0?(0,e.jsx)("button",{type:"button",className:"sekyro-link",onClick:n,children:o("native.doc.changeDocument")}):null,t!==void 0?(0,e.jsx)("button",{type:"button",className:"sekyro-link",onClick:t,children:a.t("native.doc.changeCountry")}):null]})}c(ge,"Je");h(ge,"ChangeLinks");function ye({i18n:a,upload:t}){return t!=="unsupported"&&t!=="failed"?null:(0,e.jsx)(pe,{tone:"warning",children:(0,e.jsx)("span",{children:E(a).t(t==="unsupported"?"doc.uploadUnsupported":"doc.uploadFailed")})})}c(ye,"et");h(ye,"UploadNotice");function je({step:a,i18n:t,ageLead:n,upload:o,offered:r,onPick:f,onCamera:g,onChangeCountry:y,onChangeDocument:v}){let k=E(t),w=o==="sending";return(0,e.jsxs)("section",{className:"sekyro-step","data-testid":"sekyro-doc-upload-screen",children:[(0,e.jsx)(ke,{passport:a.documentType==="passport"}),(0,e.jsx)(ue,{title:k.t("doc.uploadTitle"),lead:n?t.t("doc.ageStepUp"):k.t("doc.uploadHint")}),n?(0,e.jsx)("p",{className:"sekyro-text-muted",children:k.t("doc.uploadHint")}):null,(0,e.jsx)(oe,{step:a,i18n:t}),(0,e.jsx)(ge,{i18n:t,...v!==void 0?{onChangeDocument:v}:{},...y!==void 0?{onChangeCountry:y}:{}}),(0,e.jsx)(ye,{i18n:t,upload:o}),w?(0,e.jsx)("p",{className:"sekyro-text-muted",role:"status",children:t.t("doc.uploading")}):null,(0,e.jsxs)(he,{children:[(0,e.jsxs)(O,{full:!0,onClick:f,disabled:w||!r||a.attemptsExhausted,children:[(0,e.jsx)(j,{name:"image"}),k.t("doc.source.upload")]}),g!==void 0?(0,e.jsxs)(O,{full:!0,kind:"ghost",onClick:g,disabled:w,children:[(0,e.jsx)(Y,{name:"camera"}),k.t("doc.source.camera")]}):null]})]})}c(je,"wt");h(je,"DocumentUploadScreen");function ve(a,t,n){let o=a*.88,r=o/n;return{x:(a-o)/2,y:t*.42-r/2,w:o,h:r}}c(ve,"Qe");h(ve,"guideRect");var $t={too_far:"native.scan.closer",too_close:"native.scan.farther",focus_far:"native.scan.farther",glare:"native.scan.glare",too_bright:"native.scan.glare",too_dark:"native.scan.dark",blurry:"native.scan.blurry"},Lt=h(()=>typeof window<"u"&&window.matchMedia?.("(prefers-reduced-motion: reduce)").matches===!0,"reduceMotion");function Qe({step:a,i18n:t,liveMrz:n,onClose:o,attempts:r,onUpload:f}){let g=fe(t),y=(0,i.useContext)(Ie),v=(0,i.useRef)(y);v.current=y;let k=(0,i.useRef)(null),w=(0,i.useRef)(null),x=(0,i.useRef)(null),[z,M]=(0,i.useState)("idle"),[C,V]=(0,i.useState)(null),[_,H]=(0,i.useState)(null),[m,Q]=(0,i.useState)({w:0,h:0}),[b,X]=(0,i.useState)({hint:null,locking:!1,card:null,manualShutter:!1}),[D,q]=(0,i.useState)({}),[F,Ke]=(0,i.useState)(null),[we,et]=(0,i.useState)(null),[Ce,ze]=(0,i.useState)(0),[be,Se]=(0,i.useState)(null),[Z,Ne]=(0,i.useState)(null),A=a.documentType==="passport",J=A?1.42:1.586;Ae(!0),(0,i.useLayoutEffect)(()=>{let s=k.current;if(s===null)return;let u=h(()=>Q({w:s.clientWidth,h:s.clientHeight}),"measure");if(u(),typeof ResizeObserver>"u")return;let d=new ResizeObserver(u);return d.observe(s),()=>d.disconnect()},[]);let l=ve(m.w,m.h,J);(0,i.useEffect)(()=>{m.w===0||m.h===0||x.current?.setGuide?.({viewAspect:m.w/m.h,rect:{x:l.x/m.w,y:l.y/m.h,width:l.w/m.w,height:l.h/m.h}})},[m.w,m.h,l.x,l.y,l.w,l.h]),(0,i.useEffect)(()=>{let s=w.current;if(s===null)return;let u=a.capture({video:s,...n!==void 0?{liveMrz:n}:{}});x.current=u;let d=k.current;if(d!==null&&d.clientWidth>0&&d.clientHeight>0){let p=ve(d.clientWidth,d.clientHeight,J);u.setGuide?.({viewAspect:d.clientWidth/d.clientHeight,rect:{x:p.x/d.clientWidth,y:p.y/d.clientHeight,width:p.w/d.clientWidth,height:p.h/d.clientHeight}})}let T=new yt,N={scan:null,feedback:null,gate:null},P=h(p=>{N={...N,...p};let L=N.gate?.guide,st={phase:N.scan?.phase??"framing",hint:N.feedback?.reticle==="coaching"?N.feedback.key:null,card:L?.detected?{fill:L.fill,offsetX:L.offsetX,offsetY:L.offsetY}:null,manualShutter:N.scan?.manualShutter??!1},U=T.present(st,performance.now());X(I=>I.hint===U.hint&&I.locking===U.locking&&I.manualShutter===U.manualShutter&&I.card?.fill===U.card?.fill&&I.card?.offsetX===U.card?.offsetX&&I.card?.offsetY===U.card?.offsetY?I:U)},"present"),it=[u.on("state",M),u.on("feedback",p=>P({feedback:p})),u.on("gate",p=>P({gate:p})),u.on("scan",p=>{V(p),P({scan:p})}),u.on("captured",p=>{q(L=>({...L,[qe(p.side,A,L)]:p.previewDataUrl})),Ke(p.previewDataUrl),et(Je(s))}),u.on("error",p=>{H(p);let L=v.current;L!==null&&Ee(L,Oe("document",p,Math.max(0,r.current)))}),u.on("mrz",p=>{p.state==="mismatch"?Ne(p.format??null):Se(p)})];return r.current+=1,u.start().catch(()=>{}),()=>{for(let p of it)p();u.destroy(),x.current=null}},[a.issuer,a.documentType]);let $=C?.phase??"framing",R=$==="reading"||$==="result",re=$==="flipCue"||$==="reaskRecto",B=b.locking,xe=C?.captured.length??0;(0,i.useEffect)(()=>{B&&ze(s=>s+1)},[B]),(0,i.useEffect)(()=>{xe>0&&ze(s=>s+1)},[xe]);let tt=C?.expected??null;(0,i.useEffect)(()=>{Se(null)},[tt]),(0,i.useEffect)(()=>{if(Z===null)return;let s=setTimeout(()=>Ne(null),2e3);return()=>clearTimeout(s)},[Z]);let $e=re||R?null:We(be,A),le=Z!==null?Z==="TD3"?"dcv3.mrz.looksLikePassport":"dcv3.mrz.looksLikeCard":$e,at=le===null?null:t.strings[le]??zt[t.locale][le],ie=ne(a),Le=b.hint===null?null:$t[b.hint]??`dcv2.${b.hint}`,nt=Le??($==="flipCue"?C?.notice==="same_face"?"doc.sameFace":"doc.flip":$==="reaskRecto"?"doc.reaskRecto":R?"native.scan.reading":$==="locking"||$==="capturing"||B?"native.scan.holdStill":C?.notice==="reread"?ie??"doc.reread":C?.notice==="technical"?"native.scan.retry":C?.notice==="blurry"?"native.scan.blurry":ie??(A?"doc.showPage":"doc.showSide")),se=at??g(nt),G=b.card,S=l;if(!B&&G!==null&&G.fill>=.45&&G.fill<=1.25&&!Lt()){let s=l.w*G.fill,u=s/J,d=l.x+l.w/2+l.w*Math.max(-.25,Math.min(.25,G.offsetX)),T=l.y+l.h/2+l.h*Math.max(-.25,Math.min(.25,G.offsetY));S={x:d-s/2,y:T-u/2,w:s,h:u}}let K=l.w*.045,ce=28,Me=Math.min(K,ce*.6),ot=[[S.x,S.y,1,1],[S.x+S.w,S.y,-1,1],[S.x,S.y+S.h,1,-1],[S.x+S.w,S.y+S.h,-1,-1]],rt=B?"is-locked":b.hint!==null?"is-coaching":"",lt=A?[{side:"single",label:"doc.progressPage"}]:[{side:"recto",label:"doc.progressFront"},{side:"verso",label:"doc.progressBack"}],Te=l.y+l.h+48,de={insetInlineStart:l.x,insetBlockStart:l.y,inlineSize:l.w,blockSize:l.h,borderRadius:K};return(0,e.jsx)("section",{className:"sekyro-lm","aria-label":se,"data-testid":"sekyro-document",children:(0,e.jsxs)("div",{ref:k,className:`sekyro-lm-stage${R?" is-reading":""}${re?" is-flip":""}`,style:{"--sekyro-guide-w":`${l.w}px`},children:[(0,e.jsx)("video",{ref:w,className:"sekyro-lm-video",playsInline:!0,muted:!0,autoPlay:!0,"aria-hidden":"true",onPointerUp:c(s=>{let u=s.currentTarget,d=u.getBoundingClientRect(),T=Math.max(d.width/(u.videoWidth||1),d.height/(u.videoHeight||1)),N=u.videoWidth*T,P=u.videoHeight*T;N>0&&P>0&&x.current?.focusAt((s.clientX-d.left+(N-d.width)/2)/N,(s.clientY-d.top+(P-d.height)/2)/P)},"onPointerUp")}),m.w>0?(0,e.jsxs)(e.Fragment,{children:[R&&we!==null?(0,e.jsx)("img",{className:"sekyro-lm-scene",src:we,alt:""}):null,R&&F!==null?(0,e.jsx)("img",{className:"sekyro-lm-frozen",src:F,alt:"",style:de}):null,(0,e.jsxs)("svg",{className:"sekyro-lm-overlay",viewBox:`0 0 ${m.w} ${m.h}`,"aria-hidden":"true",focusable:"false",children:[(0,e.jsxs)("defs",{children:[(0,e.jsxs)("linearGradient",{id:"sekyro-lm-top",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,e.jsx)("stop",{offset:"0",className:"sekyro-lm-ink",stopOpacity:"0.85"}),(0,e.jsx)("stop",{offset:"1",className:"sekyro-lm-ink",stopOpacity:"0"})]}),(0,e.jsxs)("linearGradient",{id:"sekyro-lm-bottom",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,e.jsx)("stop",{offset:"0",className:"sekyro-lm-ink",stopOpacity:"0"}),(0,e.jsx)("stop",{offset:"1",className:"sekyro-lm-ink",stopOpacity:"0.9"})]})]}),(0,e.jsx)("path",{className:"sekyro-lm-scrim",fillRule:"evenodd",d:`M0 0H${m.w}V${m.h}H0Z${Ze(l,K)}`}),(0,e.jsx)("rect",{width:m.w,height:Math.max(0,l.y),fill:"url(#sekyro-lm-top)"}),(0,e.jsx)("rect",{y:l.y+l.h,width:m.w,height:Math.max(0,m.h-l.y-l.h),fill:"url(#sekyro-lm-bottom)"}),(0,e.jsx)("g",{className:`sekyro-lm-brackets ${rt}`,children:ot.map(([s,u,d,T],N)=>(0,e.jsx)("path",{style:{transform:`translate(${s}px, ${u}px) scale(${d}, ${T})`},d:`M0 ${ce}V${Me}Q0 0 ${Me} 0H${ce}`},N))}),B?(0,e.jsx)("rect",{className:"sekyro-lm-trace",x:l.x,y:l.y,width:l.w,height:l.h,rx:K,pathLength:"1",style:{animationDuration:`${Ct}ms`}}):null]}),(0,e.jsx)("div",{className:"sekyro-lm-slot",style:de,"aria-hidden":"true",children:R?(0,e.jsx)("span",{className:"sekyro-lm-read is-repeating"}):Ce>0?(0,e.jsx)("span",{className:"sekyro-lm-read"},Ce):null})]}):null,$e!==null?(0,e.jsx)("div",{className:"sekyro-lm-slot",style:de,"aria-hidden":"true",children:(0,e.jsx)("span",{"data-testid":"sekyro-mrz-strip",className:`sekyro-lm-mrz${A?" is-page":""}${be?.state==="valid"?" is-valid":""}`})}):null,(0,e.jsxs)("div",{className:"sekyro-lm-instruction",style:{insetBlockStart:l.y-64},children:[(0,e.jsx)("div",{role:"status","aria-live":"polite",children:(0,e.jsx)(Ue,{swapKey:se,className:"sekyro-lm-line",children:se})}),ie!==null&&$==="framing"&&Le===null?(0,e.jsx)("p",{className:"sekyro-lm-attempts",children:me(t,a.attemptsRemaining,a.attemptsExhausted)}):null]}),R?(0,e.jsxs)("p",{className:"sekyro-lm-under sekyro-lm-note",style:{insetBlockStart:Te-12},children:[(0,e.jsx)("span",{className:"sekyro-lm-spinner","aria-hidden":"true"}),g("native.scan.putDown")]}):re?(0,e.jsx)("div",{className:`sekyro-lm-under sekyro-lm-flip${$==="reaskRecto"?" is-toFront":""}`,style:{insetBlockStart:Te-20},"data-testid":"sekyro-flip-cue","aria-hidden":"true",children:(0,e.jsxs)("span",{className:"sekyro-lm-flip-card",style:{aspectRatio:String(J)},children:[(0,e.jsx)("span",{className:"sekyro-lm-flip-front"}),(0,e.jsx)("span",{className:"sekyro-lm-flip-back"})]})}):null,(0,e.jsxs)("div",{className:"sekyro-lm-controls",children:[(0,e.jsxs)("div",{className:"sekyro-lm-bar",children:[(0,e.jsx)("button",{type:"button",className:"sekyro-glass","aria-label":t.t("native.close"),onClick:o,children:(0,e.jsx)(Y,{name:"close"})}),C?.torchAvailable?(0,e.jsx)("button",{type:"button",className:`sekyro-glass${C.torch?" is-on":""}`,"aria-label":t.t("doc.torchOn"),"aria-pressed":C.torch,onClick:c(()=>x.current?.setTorch(!C.torch),"onClick"),children:(0,e.jsx)(j,{name:"flashlight"})}):null]}),_!==null?(0,e.jsxs)("div",{className:"sekyro-lm-error",role:"alert",children:[(0,e.jsx)("p",{children:t.t("doc.cameraBlocked")}),(0,e.jsx)("p",{children:t.t(_.kind==="permission"?"doc.cameraBlockedHint":He(_.kind))}),(0,e.jsx)(O,{onClick:c(()=>{H(null),r.current+=1,x.current?.retry()},"onClick"),children:t.t("doc.retryCamera")})]}):null,b.manualShutter?(0,e.jsx)("button",{type:"button",className:"sekyro-shutter","aria-label":t.t("doc.shutter"),onClick:c(()=>x.current?.shutter(),"onClick")}):null,(0,e.jsx)("ol",{className:"sekyro-lm-tray",children:lt.map(({side:s,label:u})=>{let d=C?.captured.includes(s)??!1;return(0,e.jsxs)("li",{className:d?"is-done":void 0,"aria-current":!d&&(A||C?.expected===s)?"step":void 0,children:[d?(0,e.jsxs)("span",{className:"sekyro-lm-thumb",children:[D[s]!==void 0?(0,e.jsx)("img",{src:D[s],alt:""}):null,(0,e.jsx)("svg",{className:"sekyro-lm-check",viewBox:"0 0 18 18","aria-hidden":"true",children:(0,e.jsx)("path",{d:"M5 9.2l2.6 2.6L13 6.4"})})]}):null,g(u)]},s)})}),f!==void 0?(0,e.jsx)("button",{type:"button",className:"sekyro-lm-upload",onClick:f,children:E(t).t("doc.uploadInstead")}):null,z==="uploading"||z==="checking"?null:(0,e.jsx)(Pe,{onStop:o})]}),z==="uploading"||z==="checking"?(0,e.jsx)("span",{className:"sekyro-visually-hidden",role:"status",children:z==="uploading"?t.t("doc.uploading"):g("native.scan.reading")}):null]})})}c(Qe,"Nt");h(Qe,"LumiereScan");function qe(a,t,n){return t?"single":a==="recto"||a==="verso"?a:n.recto===void 0?"recto":"verso"}c(qe,"Lt");h(qe,"slotOf");function Ze({x:a,y:t,w:n,h:o},r){return`M${a+r} ${t}H${a+n-r}Q${a+n} ${t} ${a+n} ${t+r}V${t+o-r}Q${a+n} ${t+o} ${a+n-r} ${t+o}H${a+r}Q${a} ${t+o} ${a} ${t+o-r}V${t+r}Q${a} ${t} ${a+r} ${t}Z`}c(Ze,"zt");h(Ze,"roundedRect");function Je(a){let t=Math.round(a.videoWidth/4),n=Math.round(a.videoHeight/4);if(t===0||n===0||typeof document>"u")return null;try{let o=document.createElement("canvas");o.width=t,o.height=n;let r=o.getContext("2d");return r===null?null:(r.drawImage(a,0,0,t,n),o.toDataURL("image/jpeg",.7))}catch{return null}}c(Je,"xt");h(Je,"sceneSnapshot");export{xt as DocumentCaptureView,Ct as LOCK_TRACE_MS,St as UPLOAD_ACCEPT,ve as guideRect,We as mrzInstruction,qe as slotOf};
1
+ "use client";import{a as Ge}from"./chunk-FEWP7HBJ.js";import{a as Ve}from"./chunk-X3BGM3B2.js";import{a as Ie,b as Oe,c as Ee}from"./chunk-FCTRNWRU.js";import"./chunk-LYYAVERP.js";import{d as Be}from"./chunk-BF6SE2AC.js";import"./chunk-CYGAKCKG.js";import{E as Ae,F as Re,G as Pe,I as Ue,K as pe,L as me,a as ct,b as dt,c as O,o as He,q as De,v as Y,w as ue,y as he}from"./chunk-YWPZG2MZ.js";import{a as h}from"./chunk-RK4HVNRS.js";import{a as c,c as _e}from"./chunk-4FHWXBOB.js";var i=_e(ct(),1),e=_e(dt(),1);var ut={image:'<path d="M2 12C2 7.29 2 4.93 3.46 3.46C4.93 2 7.29 2 12 2C16.71 2 19.07 2 20.54 3.46C22 4.93 22 7.29 22 12C22 16.71 22 19.07 20.54 20.54C19.07 22 16.71 22 12 22C7.29 22 4.93 22 3.46 20.54C2 19.07 2 16.71 2 12Z" stroke="currentColor"/><path d="M14 8A2 2 0 1 0 18 8A2 2 0 1 0 14 8Z" stroke="currentColor"/><path d="M2 12.5L3.75 10.97C4.66 10.17 6.04 10.22 6.89 11.07L11.18 15.36C11.87 16.05 12.95 16.14 13.75 15.58L14.04 15.37C15.19 14.57 16.74 14.66 17.78 15.6L21 18.5" stroke="currentColor" stroke-linecap="round"/>',flashlight:'<path d="M9 11.66V19C9 19.93 9 20.4 9.15 20.77C9.36 21.26 9.74 21.64 10.23 21.85C10.6 22 11.07 22 12 22C12.93 22 13.4 22 13.77 21.85C14.26 21.64 14.64 21.26 14.85 20.77C15 20.4 15 19.93 15 19V11.66C15 10.84 15 10.43 15.15 10.06C15.3 9.7 15.59 9.41 16.17 8.83L16.17 8.83L19.41 5.59C19.7 5.3 19.85 5.15 19.92 4.97C20 4.78 20 4.58 20 4.17V4C20 3.06 20 2.59 19.71 2.29C19.41 2 18.94 2 18 2H6C5.06 2 4.59 2 4.29 2.29C4 2.59 4 3.06 4 4V4.17C4 4.58 4 4.78 4.08 4.97C4.15 5.15 4.3 5.3 4.59 5.59L7.83 8.83C8.41 9.41 8.7 9.7 8.85 10.06C9 10.43 9 10.84 9 11.66Z" stroke="currentColor" stroke-linecap="round"/><path d="M15 10H9" stroke="currentColor" stroke-linecap="round"/><path d="M12 13V15" stroke="currentColor" stroke-linecap="round"/><path d="M4.5 5H19.5" stroke="currentColor" stroke-linecap="round"/>'},ht={"dcv3.mrz.searching":"ضع صفحة جواز السفر كاملة داخل الإطار","dcv3.mrz.showMrzSide":"اعرض الوجه الذي يحتوي على سطرين أو ثلاثة أسطر من الحروف","dcv3.mrz.reading":"جارٍ قراءة الوثيقة… ثبّتها","dcv3.mrz.moveCloser":"اقترب حتى تملأ أسطر الحروف الإطار","dcv3.mrz.turnSideways":"أدر هاتفك أفقيًا لقراءة أسطر الحروف","dcv3.mrz.glare":"أمِل الوثيقة لإزالة الانعكاس","dcv3.mrz.holdStill":"لا تتحرك","dcv3.mrz.valid":"تمت قراءة الوثيقة. جارٍ التقاط الصورة","dcv3.mrz.looksLikePassport":"يبدو أن هذا جواز سفر","dcv3.mrz.looksLikeCard":"يبدو أن هذه بطاقة تعريف أو بطاقة إقامة"},ee={"dcv3.mrz.searching":"Fit the whole passport page in the frame","dcv3.mrz.showMrzSide":"Show the side with the two or three lines of characters","dcv3.mrz.reading":"Reading the document… hold it steady","dcv3.mrz.moveCloser":"Move closer so the lines of characters fill the frame","dcv3.mrz.turnSideways":"Turn your phone sideways to read the lines of characters","dcv3.mrz.glare":"Tilt the document to remove the reflection","dcv3.mrz.holdStill":"Hold still","dcv3.mrz.valid":"Document read. Taking the photo","dcv3.mrz.looksLikePassport":"This looks like a passport","dcv3.mrz.looksLikeCard":"This looks like an identity card or residence permit"},pt={"dcv3.mrz.searching":"Cadrez toute la page du passeport","dcv3.mrz.showMrzSide":"Montrez la face avec les deux ou trois lignes de caractères","dcv3.mrz.reading":"Lecture du document… tenez-le immobile","dcv3.mrz.moveCloser":"Rapprochez-vous pour que les lignes de caractères remplissent le cadre","dcv3.mrz.turnSideways":"Tournez votre téléphone à l’horizontale pour lire les lignes de caractères","dcv3.mrz.glare":"Inclinez le document pour supprimer le reflet","dcv3.mrz.holdStill":"Ne bougez plus","dcv3.mrz.valid":"Document lu. Prise de la photo","dcv3.mrz.looksLikePassport":"Ceci ressemble à un passeport","dcv3.mrz.looksLikeCard":"Ceci ressemble à une carte d’identité ou un titre de séjour"},mt={"doc.uploadInstead":"رفع صورة بدلًا من ذلك","doc.uploadTitle":"ارفع صورة لوثيقتك","doc.uploadHint":"صورة واضحة للوثيقة كاملة، ملتقطة بكاميرا.","doc.uploadUnsupported":"اختر صورة للوثيقة بصيغة JPEG أو PNG أو HEIC.","doc.uploadFailed":"تعذّر إرسال هذه الصورة. أعد المحاولة.","doc.source.title":"كيف تريد إضافة وثيقتك؟","doc.source.description":"التقط صورة بالكاميرا، أو ارفع صورة للوثيقة من هذا الجهاز.","doc.source.camera":"التقاط صورة","doc.source.upload":"رفع صورة"},te={"doc.uploadInstead":"Upload a photo instead","doc.uploadTitle":"Upload a photo of your document","doc.uploadHint":"A clear photo of the whole document, taken with a camera.","doc.uploadUnsupported":"Choose a JPEG, PNG or HEIC photo of the document.","doc.uploadFailed":"We could not send this photo. Try again.","doc.source.title":"How do you want to add your document?","doc.source.description":"Take a photo with the camera, or upload a photo of the document from this device.","doc.source.camera":"Take a photo","doc.source.upload":"Upload a photo"},vt={"doc.uploadInstead":"Téléverser une photo à la place","doc.uploadTitle":"Téléversez une photo de votre document","doc.uploadHint":"Une photo nette du document entier, prise avec un appareil photo.","doc.uploadUnsupported":"Choisissez une photo JPEG, PNG ou HEIC du document.","doc.uploadFailed":"Nous n'avons pas pu envoyer cette photo. Réessayez.","doc.source.title":"Comment voulez-vous ajouter votre document ?","doc.source.description":"Prenez une photo avec la caméra, ou importez une photo du document depuis cet appareil.","doc.source.camera":"Prendre une photo","doc.source.upload":"Importer une photo"},ft={"native.doc.introTitle":"سنلتقط صورة لوثيقتك","native.doc.introLead":"ستُفتح كاميرا هاتفك، وتُلتقط الصورة تلقائيًا بمجرد أن تكون الوثيقة داخل الإطار.","native.doc.tip.flat":"ضع الوثيقة مسطحة على سطح داكن.","native.doc.tip.glare":"تجنّب انعكاسات المصابيح أو الشمس.","native.doc.tip.frame":"أبقِ الوثيقة كاملة داخل الإطار.","native.doc.openCamera":"افتح الكاميرا","native.doc.changeDocument":"تغيير الوثيقة","native.scan.closer":"اقترب قليلًا","native.scan.farther":"ابتعد قليلًا","native.scan.glare":"أمِل البطاقة قليلًا","native.scan.dark":"الإضاءة ضعيفة. شغّل المصباح.","native.scan.blurry":"الصورة غير واضحة. ثبّت الهاتف.","native.scan.holdStill":"لا تتحرك","native.scan.reading":"جارٍ التحقق من وثيقتك…","native.scan.putDown":"يمكنك وضع وثيقتك جانبًا.","native.scan.retry":"لنحاول مرة أخرى"},ae={"native.doc.introTitle":"Photograph your document","native.doc.introLead":"Your phone's camera will open. The photo is taken by itself as soon as the document is well framed.","native.doc.tip.flat":"Lay the document flat on a dark surface.","native.doc.tip.glare":"Avoid glare from lamps or sunlight.","native.doc.tip.frame":"Keep the whole document in the frame.","native.doc.openCamera":"Open the camera","native.doc.changeDocument":"Change document","native.scan.closer":"Move a little closer","native.scan.farther":"Move back a little","native.scan.glare":"Tilt the card a little","native.scan.dark":"Too dark. Turn on the light.","native.scan.blurry":"Blurry image. Hold the phone still.","native.scan.holdStill":"Hold still","native.scan.reading":"Checking your document…","native.scan.putDown":"You can put your document down.","native.scan.retry":"Let's try that again"},kt={"native.doc.introTitle":"Photographiez votre pièce","native.doc.introLead":"La caméra de votre téléphone va s'ouvrir. La photo est prise automatiquement dès que la pièce est bien cadrée.","native.doc.tip.flat":"Posez la pièce à plat, sur une surface sombre.","native.doc.tip.glare":"Évitez les reflets de lampe ou de soleil.","native.doc.tip.frame":"Gardez toute la pièce dans le cadre.","native.doc.openCamera":"Ouvrir la caméra","native.doc.changeDocument":"Changer de document","native.scan.closer":"Approchez un peu","native.scan.farther":"Reculez un peu","native.scan.glare":"Inclinez un peu la carte","native.scan.dark":"Trop sombre. Allumez la lampe.","native.scan.blurry":"Image floue. Tenez le téléphone immobile.","native.scan.holdStill":"Ne bougez plus","native.scan.reading":"Vérification de votre document…","native.scan.putDown":"Vous pouvez poser votre pièce.","native.scan.retry":"Réessayons"},gt=["locking","capturing"],W,Ye=(W=class{constructor(){this.shown={hint:null,locking:!1,card:null,manualShutter:!1},this.candidate=null,this.candidateSince=0,this.hintShownAt=0,this.lockLostAt=null,this.detectedSince=null,this.lostSince=null,this.shutterSince=null}present(t,n){return this.presentHint(t,n),this.presentLock(t,n),this.presentCard(t,n),this.shutterSince=t.manualShutter?this.shutterSince??n:null,this.shown={...this.shown,manualShutter:this.shutterSince!==null&&n-this.shutterSince>=1e3},this.shown}presentHint(t,n){let o=t.phase==="framing"&&!(t.hint==="blurry"&&t.card===null)?t.hint:null;if(t.phase!=="framing"){this.shown={...this.shown,hint:null},this.candidate=null;return}if(o!==this.candidate&&(this.candidate=o,this.candidateSince=n),o===this.shown.hint)return;let r=n-this.candidateSince>=(o===null?0:350),f=this.shown.hint===null||n-this.hintShownAt>=1200;r&&f&&(this.shown={...this.shown,hint:o},this.hintShownAt=n)}presentLock(t,n){if(gt.includes(t.phase)){this.shown={...this.shown,locking:!0},this.lockLostAt=null;return}if(this.shown.locking){if(t.phase!=="framing"){this.shown={...this.shown,locking:!1},this.lockLostAt=null;return}this.lockLostAt??(this.lockLostAt=n),n-this.lockLostAt>=300&&(this.shown={...this.shown,locking:!1},this.lockLostAt=null)}}presentCard(t,n){let o=t.card;if(o===null||t.phase!=="framing"){if(t.phase!=="framing"){this.shown={...this.shown,card:null},this.detectedSince=null,this.lostSince=null;return}this.detectedSince=null,this.lostSince??(this.lostSince=n),n-this.lostSince>=300&&(this.shown={...this.shown,card:null});return}if(this.lostSince=null,this.detectedSince??(this.detectedSince=n),n-this.detectedSince<250)return;let r=this.shown.card;if(r===null){this.shown={...this.shown,card:{...o}};return}let f=.35;this.shown={...this.shown,card:{fill:r.fill+(o.fill-r.fill)*f,offsetX:r.offsetX+(o.offsetX-r.offsetX)*f,offsetY:r.offsetY+(o.offsetY-r.offsetY)*f}}}},c(W,"fe"),W);h(Ye,"ScanPresenter");var yt=Ye,wt={en:ae,fr:kt,ar:ft,es:ae,pt:ae,de:ae},Ct=450,fe=h(a=>t=>Ve(a.strings[t]??wt[a.locale][t]??""),"useScanCopy");function j({name:a}){return(0,e.jsx)("svg",{className:"sekyro-glyph",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",focusable:"false",dangerouslySetInnerHTML:{__html:ut[a]}})}c(j,"ae");h(j,"ScanGlyph");var zt={en:ee,fr:pt,ar:ht,es:ee,pt:ee,de:ee},bt={en:te,fr:vt,ar:mt,es:te,pt:te,de:te},St="image/jpeg,image/png,image/heic,image/heif";function E(a){let t=a.strings,n=h(o=>t[o]??bt[a.locale][o],"text");return{t:h(o=>n(o)??"","t")}}c(E,"F");h(E,"uploadCopy");function We(a,t){return a===null||a.state==="fallback"||a.state==="mismatch"?null:a.state==="searching"?t?"dcv3.mrz.searching":"dcv3.mrz.showMrzSide":a.state==="valid"?"dcv3.mrz.valid":a.coach!==void 0?`dcv3.mrz.${a.coach}`:"dcv3.mrz.reading"}c(We,"vt");h(We,"mrzInstruction");function ne(a){return a.reason==="unreadable"?"doc.reason_unreadable":a.reason==="tester_document_mismatch"?"reasons.tester_document_mismatch":a.reason!==void 0&&a.reason!=="side_missing"?De(a.reason):null}c(ne,"ve");h(ne,"reasonOf");var Nt=new Set(["document_type_not_accepted","tester_document_mismatch"]);function xt({step:a,i18n:t,liveMrz:n,ageLead:o,...r}){let[f,g]=(0,i.useState)(!1),y=(0,i.useRef)(-1),[v,k]=(0,i.useState)("idle"),w=(0,i.useRef)(null),x=typeof a.uploadDocument=="function",z=x?a.photo?.source??"camera":"camera",M=x&&z!=="camera"&&a.photo?.uploadOffered===!0,[C,V]=(0,i.useState)(null),_=z==="upload"?"upload":z==="choice"?C??a.photo?.pick??"source":"camera",H=v==="sending"?void 0:()=>w.current?.click(),m=h(async D=>{let q=D.currentTarget.files?.[0];if(D.currentTarget.value="",q!==void 0){g(!1),k("sending");try{await a.uploadDocument(q),k("idle")}catch(F){k(F instanceof TypeError&&F.message==="unsupported_file"?"unsupported":"failed")}}},"onFile"),Q=M?(0,e.jsx)("input",{ref:w,type:"file",accept:St,hidden:!0,"data-testid":"sekyro-doc-upload","aria-label":E(t).t("doc.uploadTitle"),onChange:c(D=>{m(D)},"onChange")}):null,b=E(t),X=a.photo?.cameraOnPhone===!0;return _==="camera"&&X?(0,e.jsx)(Be,{i18n:t,lead:t.t("handoff.lead.document"),refresh:a.refresh,actions:(0,e.jsx)(O,{kind:"ghost",full:!0,onClick:c(()=>V("upload"),"onClick"),children:b.t("doc.source.upload")})}):_==="source"?(0,e.jsx)(Ge,{testId:"sekyro-doc-source",title:b.t("doc.source.title"),lead:b.t("doc.source.description"),cameraLabel:X?t.t("capture.source.phone"):b.t("doc.source.camera"),onPhone:X,uploadLabel:b.t("doc.source.upload"),notice:(0,e.jsx)(oe,{step:a,i18n:t}),onCamera:c(()=>V("camera"),"onCamera"),onUpload:c(()=>V("upload"),"onUpload")}):_==="upload"?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(je,{step:a,i18n:t,ageLead:o===!0,upload:v,offered:M,onPick:c(()=>w.current?.click(),"onPick"),...z==="choice"?{onCamera:h(()=>V("camera"),"onCamera")}:{},...r}),Q]}):(0,e.jsxs)(e.Fragment,{children:[f?(0,e.jsx)(Qe,{step:a,i18n:t,attempts:y,...n!==void 0?{liveMrz:n}:{},...M&&H!==void 0?{onUpload:H}:{},onClose:c(()=>g(!1),"onClose")}):(0,e.jsx)(Fe,{step:a,i18n:t,ageLead:o===!0,onOpen:c(()=>g(!0),"onOpen"),upload:v,...M&&H!==void 0?{onUpload:H}:{},...r}),Q]})}c(xt,"ln");h(xt,"DocumentCaptureView");function ke({passport:a}){let t=Math.round(228/(a?1.42:1.586));return(0,e.jsxs)("svg",{className:"sekyro-mark sekyro-mark--card",viewBox:`-12 -12 252 ${t+24}`,"aria-hidden":"true",focusable:"false",children:[(0,e.jsx)("defs",{children:(0,e.jsx)("clipPath",{id:"sekyro-card-clip",children:(0,e.jsx)("rect",{width:228,height:t,rx:"12.5"})})}),(0,e.jsx)("rect",{className:"sekyro-mark__card",width:228,height:t,rx:"12.5"}),(0,e.jsx)("rect",{className:"sekyro-mark__photo",x:"17",y:"17",width:"55",height:t*.52,rx:"6"}),[0,1,2].map(n=>(0,e.jsx)("rect",{className:"sekyro-mark__text",x:"88",y:23+n*t*.12,width:100-n*20,height:"6",rx:"3"},n)),[0,1].map(n=>(0,e.jsx)("rect",{className:"sekyro-mark__text",x:"17",y:t*.74+n*9,width:194,height:"4",rx:"2"},n)),(0,e.jsx)("g",{clipPath:"url(#sekyro-card-clip)",children:(0,e.jsx)("g",{className:"sekyro-mark__read",style:{"--sekyro-read-w":"228px"},children:(0,e.jsx)("rect",{x:"-1",width:"2",height:t,className:"sekyro-mark__beam"})})}),(0,e.jsx)("path",{className:"sekyro-mark__brackets",d:Xe(-10,-10,248,t+20,16,30)})]})}c(ke,"qe");h(ke,"ScanMark");function Xe(a,t,n,o,r,f){let g=Math.min(r,f*.6);return[[a,t,1,1],[a+n,t,-1,1],[a,t+o,1,-1],[a+n,t+o,-1,-1]].map(([y,v,k,w])=>`M${y} ${v+w*f}V${v+w*g}Q${y} ${v} ${y+k*g} ${v}H${y+k*f}`).join("")}c(Xe,"kt");h(Xe,"brackets");function Fe({step:a,i18n:t,ageLead:n,onOpen:o,onChangeCountry:r,onChangeDocument:f,upload:g,onUpload:y}){let v=fe(t),k=E(t),w=a.documentType==="passport",x=ne(a),z=g==="sending",M=(0,i.useContext)(Re)?.busy===!0;return(0,e.jsxs)("section",{className:"sekyro-step","data-testid":"sekyro-document",children:[(0,e.jsx)(ke,{passport:w}),(0,e.jsx)(ue,{title:v("native.doc.introTitle"),lead:n?t.t("doc.ageStepUp"):v("native.doc.introLead")}),(0,e.jsx)(oe,{step:a,i18n:t}),a.reason!==void 0&&Nt.has(a.reason)?null:(0,e.jsxs)("ul",{className:"sekyro-tiprows",children:[(0,e.jsxs)("li",{children:[(0,e.jsx)(Y,{name:w?"passport":"card"}),v("native.doc.tip.flat")]}),(0,e.jsxs)("li",{children:[(0,e.jsx)(Y,{name:"light"}),v("native.doc.tip.glare")]}),(0,e.jsxs)("li",{children:[(0,e.jsx)(j,{name:"image"}),v("native.doc.tip.frame")]})]}),(0,e.jsx)(ge,{i18n:t,...f!==void 0?{onChangeDocument:f}:{},...r!==void 0?{onChangeCountry:r}:{}}),(0,e.jsx)(ye,{i18n:t,upload:g}),z?(0,e.jsx)("p",{className:"sekyro-text-muted",role:"status",children:t.t("doc.uploading")}):y!==void 0?(0,e.jsx)("p",{className:"sekyro-text-muted",children:k.t("doc.uploadHint")}):null,(0,e.jsxs)(he,{children:[(0,e.jsxs)(O,{full:!0,onClick:o,disabled:z||M,children:[(0,e.jsx)(Y,{name:"camera"}),v("native.doc.openCamera")]}),y!==void 0?(0,e.jsxs)(O,{full:!0,kind:"ghost",onClick:y,children:[(0,e.jsx)(j,{name:"image"}),k.t("doc.uploadInstead")]}):null]})]})}c(Fe,"bt");h(Fe,"DocumentIntro");function oe({step:a,i18n:t}){let n=ne(a);return n===null?null:(0,e.jsxs)(pe,{tone:"warning",children:[(0,e.jsx)("span",{children:t.t(n)}),(0,e.jsx)("span",{children:me(t,a.attemptsRemaining,a.attemptsExhausted)})]})}c(oe,"ye");h(oe,"ReasonNotice");function ge({i18n:a,onChangeCountry:t,onChangeDocument:n}){let o=fe(a);return n===void 0&&t===void 0?null:(0,e.jsxs)("div",{className:"sekyro-links",children:[n!==void 0?(0,e.jsx)("button",{type:"button",className:"sekyro-link",onClick:n,children:o("native.doc.changeDocument")}):null,t!==void 0?(0,e.jsx)("button",{type:"button",className:"sekyro-link",onClick:t,children:a.t("native.doc.changeCountry")}):null]})}c(ge,"Je");h(ge,"ChangeLinks");function ye({i18n:a,upload:t}){return t!=="unsupported"&&t!=="failed"?null:(0,e.jsx)(pe,{tone:"warning",children:(0,e.jsx)("span",{children:E(a).t(t==="unsupported"?"doc.uploadUnsupported":"doc.uploadFailed")})})}c(ye,"et");h(ye,"UploadNotice");function je({step:a,i18n:t,ageLead:n,upload:o,offered:r,onPick:f,onCamera:g,onChangeCountry:y,onChangeDocument:v}){let k=E(t),w=o==="sending";return(0,e.jsxs)("section",{className:"sekyro-step","data-testid":"sekyro-doc-upload-screen",children:[(0,e.jsx)(ke,{passport:a.documentType==="passport"}),(0,e.jsx)(ue,{title:k.t("doc.uploadTitle"),lead:n?t.t("doc.ageStepUp"):k.t("doc.uploadHint")}),n?(0,e.jsx)("p",{className:"sekyro-text-muted",children:k.t("doc.uploadHint")}):null,(0,e.jsx)(oe,{step:a,i18n:t}),(0,e.jsx)(ge,{i18n:t,...v!==void 0?{onChangeDocument:v}:{},...y!==void 0?{onChangeCountry:y}:{}}),(0,e.jsx)(ye,{i18n:t,upload:o}),w?(0,e.jsx)("p",{className:"sekyro-text-muted",role:"status",children:t.t("doc.uploading")}):null,(0,e.jsxs)(he,{children:[(0,e.jsxs)(O,{full:!0,onClick:f,disabled:w||!r||a.attemptsExhausted,children:[(0,e.jsx)(j,{name:"image"}),k.t("doc.source.upload")]}),g!==void 0?(0,e.jsxs)(O,{full:!0,kind:"ghost",onClick:g,disabled:w,children:[(0,e.jsx)(Y,{name:"camera"}),k.t("doc.source.camera")]}):null]})]})}c(je,"wt");h(je,"DocumentUploadScreen");function ve(a,t,n){let o=a*.88,r=o/n;return{x:(a-o)/2,y:t*.42-r/2,w:o,h:r}}c(ve,"Qe");h(ve,"guideRect");var $t={too_far:"native.scan.closer",too_close:"native.scan.farther",focus_far:"native.scan.farther",glare:"native.scan.glare",too_bright:"native.scan.glare",too_dark:"native.scan.dark",blurry:"native.scan.blurry"},Lt=h(()=>typeof window<"u"&&window.matchMedia?.("(prefers-reduced-motion: reduce)").matches===!0,"reduceMotion");function Qe({step:a,i18n:t,liveMrz:n,onClose:o,attempts:r,onUpload:f}){let g=fe(t),y=(0,i.useContext)(Ie),v=(0,i.useRef)(y);v.current=y;let k=(0,i.useRef)(null),w=(0,i.useRef)(null),x=(0,i.useRef)(null),[z,M]=(0,i.useState)("idle"),[C,V]=(0,i.useState)(null),[_,H]=(0,i.useState)(null),[m,Q]=(0,i.useState)({w:0,h:0}),[b,X]=(0,i.useState)({hint:null,locking:!1,card:null,manualShutter:!1}),[D,q]=(0,i.useState)({}),[F,Ke]=(0,i.useState)(null),[we,et]=(0,i.useState)(null),[Ce,ze]=(0,i.useState)(0),[be,Se]=(0,i.useState)(null),[Z,Ne]=(0,i.useState)(null),A=a.documentType==="passport",J=A?1.42:1.586;Ae(!0),(0,i.useLayoutEffect)(()=>{let s=k.current;if(s===null)return;let u=h(()=>Q({w:s.clientWidth,h:s.clientHeight}),"measure");if(u(),typeof ResizeObserver>"u")return;let d=new ResizeObserver(u);return d.observe(s),()=>d.disconnect()},[]);let l=ve(m.w,m.h,J);(0,i.useEffect)(()=>{m.w===0||m.h===0||x.current?.setGuide?.({viewAspect:m.w/m.h,rect:{x:l.x/m.w,y:l.y/m.h,width:l.w/m.w,height:l.h/m.h}})},[m.w,m.h,l.x,l.y,l.w,l.h]),(0,i.useEffect)(()=>{let s=w.current;if(s===null)return;let u=a.capture({video:s,...n!==void 0?{liveMrz:n}:{}});x.current=u;let d=k.current;if(d!==null&&d.clientWidth>0&&d.clientHeight>0){let p=ve(d.clientWidth,d.clientHeight,J);u.setGuide?.({viewAspect:d.clientWidth/d.clientHeight,rect:{x:p.x/d.clientWidth,y:p.y/d.clientHeight,width:p.w/d.clientWidth,height:p.h/d.clientHeight}})}let T=new yt,N={scan:null,feedback:null,gate:null},P=h(p=>{N={...N,...p};let L=N.gate?.guide,st={phase:N.scan?.phase??"framing",hint:N.feedback?.reticle==="coaching"?N.feedback.key:null,card:L?.detected?{fill:L.fill,offsetX:L.offsetX,offsetY:L.offsetY}:null,manualShutter:N.scan?.manualShutter??!1},U=T.present(st,performance.now());X(I=>I.hint===U.hint&&I.locking===U.locking&&I.manualShutter===U.manualShutter&&I.card?.fill===U.card?.fill&&I.card?.offsetX===U.card?.offsetX&&I.card?.offsetY===U.card?.offsetY?I:U)},"present"),it=[u.on("state",M),u.on("feedback",p=>P({feedback:p})),u.on("gate",p=>P({gate:p})),u.on("scan",p=>{V(p),P({scan:p})}),u.on("captured",p=>{q(L=>({...L,[qe(p.side,A,L)]:p.previewDataUrl})),Ke(p.previewDataUrl),et(Je(s))}),u.on("error",p=>{H(p);let L=v.current;L!==null&&Ee(L,Oe("document",p,Math.max(0,r.current)))}),u.on("mrz",p=>{p.state==="mismatch"?Ne(p.format??null):Se(p)})];return r.current+=1,u.start().catch(()=>{}),()=>{for(let p of it)p();u.destroy(),x.current=null}},[a.issuer,a.documentType]);let $=C?.phase??"framing",R=$==="reading"||$==="result",re=$==="flipCue"||$==="reaskRecto",B=b.locking,xe=C?.captured.length??0;(0,i.useEffect)(()=>{B&&ze(s=>s+1)},[B]),(0,i.useEffect)(()=>{xe>0&&ze(s=>s+1)},[xe]);let tt=C?.expected??null;(0,i.useEffect)(()=>{Se(null)},[tt]),(0,i.useEffect)(()=>{if(Z===null)return;let s=setTimeout(()=>Ne(null),2e3);return()=>clearTimeout(s)},[Z]);let $e=re||R?null:We(be,A),le=Z!==null?Z==="TD3"?"dcv3.mrz.looksLikePassport":"dcv3.mrz.looksLikeCard":$e,at=le===null?null:t.strings[le]??zt[t.locale][le],ie=ne(a),Le=b.hint===null?null:$t[b.hint]??`dcv2.${b.hint}`,nt=Le??($==="flipCue"?C?.notice==="same_face"?"doc.sameFace":"doc.flip":$==="reaskRecto"?"doc.reaskRecto":R?"native.scan.reading":$==="locking"||$==="capturing"||B?"native.scan.holdStill":C?.notice==="reread"?ie??"doc.reread":C?.notice==="technical"?"native.scan.retry":C?.notice==="blurry"?"native.scan.blurry":ie??(A?"doc.showPage":"doc.showSide")),se=at??g(nt),G=b.card,S=l;if(!B&&G!==null&&G.fill>=.45&&G.fill<=1.25&&!Lt()){let s=l.w*G.fill,u=s/J,d=l.x+l.w/2+l.w*Math.max(-.25,Math.min(.25,G.offsetX)),T=l.y+l.h/2+l.h*Math.max(-.25,Math.min(.25,G.offsetY));S={x:d-s/2,y:T-u/2,w:s,h:u}}let K=l.w*.045,ce=28,Me=Math.min(K,ce*.6),ot=[[S.x,S.y,1,1],[S.x+S.w,S.y,-1,1],[S.x,S.y+S.h,1,-1],[S.x+S.w,S.y+S.h,-1,-1]],rt=B?"is-locked":b.hint!==null?"is-coaching":"",lt=A?[{side:"single",label:"doc.progressPage"}]:[{side:"recto",label:"doc.progressFront"},{side:"verso",label:"doc.progressBack"}],Te=l.y+l.h+48,de={insetInlineStart:l.x,insetBlockStart:l.y,inlineSize:l.w,blockSize:l.h,borderRadius:K};return(0,e.jsx)("section",{className:"sekyro-lm","aria-label":se,"data-testid":"sekyro-document",children:(0,e.jsxs)("div",{ref:k,className:`sekyro-lm-stage${R?" is-reading":""}${re?" is-flip":""}`,style:{"--sekyro-guide-w":`${l.w}px`},children:[(0,e.jsx)("video",{ref:w,className:"sekyro-lm-video",playsInline:!0,muted:!0,autoPlay:!0,"aria-hidden":"true",onPointerUp:c(s=>{let u=s.currentTarget,d=u.getBoundingClientRect(),T=Math.max(d.width/(u.videoWidth||1),d.height/(u.videoHeight||1)),N=u.videoWidth*T,P=u.videoHeight*T;N>0&&P>0&&x.current?.focusAt((s.clientX-d.left+(N-d.width)/2)/N,(s.clientY-d.top+(P-d.height)/2)/P)},"onPointerUp")}),m.w>0?(0,e.jsxs)(e.Fragment,{children:[R&&we!==null?(0,e.jsx)("img",{className:"sekyro-lm-scene",src:we,alt:""}):null,R&&F!==null?(0,e.jsx)("img",{className:"sekyro-lm-frozen",src:F,alt:"",style:de}):null,(0,e.jsxs)("svg",{className:"sekyro-lm-overlay",viewBox:`0 0 ${m.w} ${m.h}`,"aria-hidden":"true",focusable:"false",children:[(0,e.jsxs)("defs",{children:[(0,e.jsxs)("linearGradient",{id:"sekyro-lm-top",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,e.jsx)("stop",{offset:"0",className:"sekyro-lm-ink",stopOpacity:"0.85"}),(0,e.jsx)("stop",{offset:"1",className:"sekyro-lm-ink",stopOpacity:"0"})]}),(0,e.jsxs)("linearGradient",{id:"sekyro-lm-bottom",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,e.jsx)("stop",{offset:"0",className:"sekyro-lm-ink",stopOpacity:"0"}),(0,e.jsx)("stop",{offset:"1",className:"sekyro-lm-ink",stopOpacity:"0.9"})]})]}),(0,e.jsx)("path",{className:"sekyro-lm-scrim",fillRule:"evenodd",d:`M0 0H${m.w}V${m.h}H0Z${Ze(l,K)}`}),(0,e.jsx)("rect",{width:m.w,height:Math.max(0,l.y),fill:"url(#sekyro-lm-top)"}),(0,e.jsx)("rect",{y:l.y+l.h,width:m.w,height:Math.max(0,m.h-l.y-l.h),fill:"url(#sekyro-lm-bottom)"}),(0,e.jsx)("g",{className:`sekyro-lm-brackets ${rt}`,children:ot.map(([s,u,d,T],N)=>(0,e.jsx)("path",{style:{transform:`translate(${s}px, ${u}px) scale(${d}, ${T})`},d:`M0 ${ce}V${Me}Q0 0 ${Me} 0H${ce}`},N))}),B?(0,e.jsx)("rect",{className:"sekyro-lm-trace",x:l.x,y:l.y,width:l.w,height:l.h,rx:K,pathLength:"1",style:{animationDuration:`${Ct}ms`}}):null]}),(0,e.jsx)("div",{className:"sekyro-lm-slot",style:de,"aria-hidden":"true",children:R?(0,e.jsx)("span",{className:"sekyro-lm-read is-repeating"}):Ce>0?(0,e.jsx)("span",{className:"sekyro-lm-read"},Ce):null})]}):null,$e!==null?(0,e.jsx)("div",{className:"sekyro-lm-slot",style:de,"aria-hidden":"true",children:(0,e.jsx)("span",{"data-testid":"sekyro-mrz-strip",className:`sekyro-lm-mrz${A?" is-page":""}${be?.state==="valid"?" is-valid":""}`})}):null,(0,e.jsxs)("div",{className:"sekyro-lm-instruction",style:{insetBlockStart:l.y-64},children:[(0,e.jsx)("div",{role:"status","aria-live":"polite",children:(0,e.jsx)(Ue,{swapKey:se,className:"sekyro-lm-line",children:se})}),ie!==null&&$==="framing"&&Le===null?(0,e.jsx)("p",{className:"sekyro-lm-attempts",children:me(t,a.attemptsRemaining,a.attemptsExhausted)}):null]}),R?(0,e.jsxs)("p",{className:"sekyro-lm-under sekyro-lm-note",style:{insetBlockStart:Te-12},children:[(0,e.jsx)("span",{className:"sekyro-lm-spinner","aria-hidden":"true"}),g("native.scan.putDown")]}):re?(0,e.jsx)("div",{className:`sekyro-lm-under sekyro-lm-flip${$==="reaskRecto"?" is-toFront":""}`,style:{insetBlockStart:Te-20},"data-testid":"sekyro-flip-cue","aria-hidden":"true",children:(0,e.jsxs)("span",{className:"sekyro-lm-flip-card",style:{aspectRatio:String(J)},children:[(0,e.jsx)("span",{className:"sekyro-lm-flip-front"}),(0,e.jsx)("span",{className:"sekyro-lm-flip-back"})]})}):null,(0,e.jsxs)("div",{className:"sekyro-lm-controls",children:[(0,e.jsxs)("div",{className:"sekyro-lm-bar",children:[(0,e.jsx)("button",{type:"button",className:"sekyro-glass","aria-label":t.t("native.close"),onClick:o,children:(0,e.jsx)(Y,{name:"close"})}),C?.torchAvailable?(0,e.jsx)("button",{type:"button",className:`sekyro-glass${C.torch?" is-on":""}`,"aria-label":t.t("doc.torchOn"),"aria-pressed":C.torch,onClick:c(()=>x.current?.setTorch(!C.torch),"onClick"),children:(0,e.jsx)(j,{name:"flashlight"})}):null]}),_!==null?(0,e.jsxs)("div",{className:"sekyro-lm-error",role:"alert",children:[(0,e.jsx)("p",{children:t.t("doc.cameraBlocked")}),(0,e.jsx)("p",{children:t.t(_.kind==="permission"?"doc.cameraBlockedHint":He(_.kind))}),(0,e.jsx)(O,{onClick:c(()=>{H(null),r.current+=1,x.current?.retry()},"onClick"),children:t.t("doc.retryCamera")})]}):null,b.manualShutter?(0,e.jsx)("button",{type:"button",className:"sekyro-shutter","aria-label":t.t("doc.shutter"),onClick:c(()=>x.current?.shutter(),"onClick")}):null,(0,e.jsx)("ol",{className:"sekyro-lm-tray",children:lt.map(({side:s,label:u})=>{let d=C?.captured.includes(s)??!1;return(0,e.jsxs)("li",{className:d?"is-done":void 0,"aria-current":!d&&(A||C?.expected===s)?"step":void 0,children:[d?(0,e.jsxs)("span",{className:"sekyro-lm-thumb",children:[D[s]!==void 0?(0,e.jsx)("img",{src:D[s],alt:""}):null,(0,e.jsx)("svg",{className:"sekyro-lm-check",viewBox:"0 0 18 18","aria-hidden":"true",children:(0,e.jsx)("path",{d:"M5 9.2l2.6 2.6L13 6.4"})})]}):null,g(u)]},s)})}),f!==void 0?(0,e.jsx)("button",{type:"button",className:"sekyro-lm-upload",onClick:f,children:E(t).t("doc.uploadInstead")}):null,z==="uploading"||z==="checking"?null:(0,e.jsx)(Pe,{onStop:o})]}),z==="uploading"||z==="checking"?(0,e.jsx)("span",{className:"sekyro-visually-hidden",role:"status",children:z==="uploading"?t.t("doc.uploading"):g("native.scan.reading")}):null]})})}c(Qe,"Nt");h(Qe,"LumiereScan");function qe(a,t,n){return t?"single":a==="recto"||a==="verso"?a:n.recto===void 0?"recto":"verso"}c(qe,"Lt");h(qe,"slotOf");function Ze({x:a,y:t,w:n,h:o},r){return`M${a+r} ${t}H${a+n-r}Q${a+n} ${t} ${a+n} ${t+r}V${t+o-r}Q${a+n} ${t+o} ${a+n-r} ${t+o}H${a+r}Q${a} ${t+o} ${a} ${t+o-r}V${t+r}Q${a} ${t} ${a+r} ${t}Z`}c(Ze,"zt");h(Ze,"roundedRect");function Je(a){let t=Math.round(a.videoWidth/4),n=Math.round(a.videoHeight/4);if(t===0||n===0||typeof document>"u")return null;try{let o=document.createElement("canvas");o.width=t,o.height=n;let r=o.getContext("2d");return r===null?null:(r.drawImage(a,0,0,t,n),o.toDataURL("image/jpeg",.7))}catch{return null}}c(Je,"xt");h(Je,"sceneSnapshot");export{xt as DocumentCaptureView,Ct as LOCK_TRACE_MS,St as UPLOAD_ACCEPT,ve as guideRect,We as mrzInstruction,qe as slotOf};
@@ -1 +1 @@
1
- "use client";import{a as O,b as v,c as W}from"./chunk-JOZCJGRV.js";import{a as q,b as J,c as K}from"./chunk-IFGPCCJH.js";import{a as z}from"./chunk-6MEPT5ZS.js";import{a as w}from"./chunk-562ANROG.js";import{c as T,d as A}from"./chunk-YEPHU5PX.js";import"./chunk-OBPBHX2J.js";import{H as j,K as E,a as oe,b as ce,c as N,t as U,y as R}from"./chunk-UYAVCSQ4.js";import"./chunk-3KIFGAEK.js";import"./chunk-HODE7UDG.js";import"./chunk-TCW6XNLI.js";import"./chunk-UZWMCNZI.js";import{a as o}from"./chunk-RK4HVNRS.js";import"./chunk-D334IAZJ.js";import"./chunk-RRLXNT33.js";import{a as u,c as P}from"./chunk-4FHWXBOB.js";var a=P(oe(),1),i=P(ce(),1);var Q={en:v,fr:W,ar:O,es:v,pt:v,de:v},C=6,pe=new Set(["eid_identifier_invalid","eid_code_invalid","eid_locked","eid_not_enrolled"]),X=o((e,d)=>{if(e===void 0)return 0;let h=Date.parse(e)-d;return Number.isFinite(h)?Math.max(0,Math.ceil(h/1e3)):0},"secondsUntil"),me=o(e=>`${Math.floor(e/60)}:${String(e%60).padStart(2,"0")}`,"mmss");function ue({step:e,i18n:d,className:h,onError:Y}){let I=d.strings,r=o((n,t)=>w(I[n]??Q[d.locale][n]??"",t),"t"),B=o((n,t)=>{let le=new Intl.PluralRules(d.locale).select(t),L=`${n}.${le}`,te=I[L]??Q[d.locale][L]??r(`${n}.other`);return w(te,{count:new Intl.NumberFormat(d.locale).format(t)})},"plural"),y=o(n=>e.providerName?r(`eid.${n}`,{provider:e.providerName}):r(`eid.${n}Generic`),"named"),[S,Z]=(0,a.useState)(""),[f,_]=(0,a.useState)(""),[c,D]=(0,a.useState)(!1),[b,p]=(0,a.useState)(null),s=e.phase==="code",F=K(s),l=(0,a.useId)(),ee=U(),[ie,ne]=q(e.reason==="eid_code_invalid",e.codeAttemptsRemaining??0,()=>_("")),m=o(async n=>{D(!0),p(null);try{await n()}catch(t){p(z(t,d.strings)),Y?.(t)}finally{D(!1)}},"run"),M=(0,a.useRef)(!1);(0,a.useEffect)(()=>{!e.identifierBound||s||e.reason!==void 0||M.current||(M.current=!0,m(()=>e.start()))},[e.identifierBound,s,e.reason]),(0,a.useEffect)(()=>{(e.reason==="eid_code_invalid"||e.codeExpiresAt!==void 0)&&_("")},[e.reason,e.codeExpiresAt,e.codeAttemptsRemaining]);let H=(0,a.useRef)(s);(0,a.useEffect)(()=>{s&&!H.current&&document.getElementById(`${l}-code`)?.focus(),H.current=s},[s,l]);let k=e.reason==="eid_locked",V=X(e.codeExpiresAt,F),x=s&&e.codeExpiresAt!==void 0&&V===0,$=X(e.resendAvailableAt,F),G=e.resendsRemaining===0||e.reason==="eid_resend_limit",re=o(n=>{if(n.preventDefault(),s){f.length===C&&!k&&m(()=>e.verify(f));return}if(e.identifierBound){m(()=>e.start());return}let t=A(S);if(e.country==="MR"){if(!/^\d{10}$/.test(t))return p("population.invalid");if(!T(t))return p("population.reason_nni_invalid")}m(()=>e.start(t))},"onSubmit"),g=e.reason?.startsWith("eid_")?e.reason:void 0,ae=(0,i.jsxs)(i.Fragment,{children:[g!==void 0?(0,i.jsxs)(E,{tone:pe.has(g)?"danger":"warning",children:[(0,i.jsx)("span",{children:r(`reasons.${g}`)}),g==="eid_code_invalid"&&e.codeAttemptsRemaining!==void 0?(0,i.jsx)("span",{children:B("eid.codeAttemptsRemaining",e.codeAttemptsRemaining)}):null,e.canUseCamera?(0,i.jsx)(N,{kind:"secondary",disabled:c,onClick:u(()=>{m(()=>e.useCamera())},"onClick"),children:r("eid.useCamera")}):null]}):null,b!==null?(0,i.jsx)(E,{tone:"danger",children:(0,i.jsx)("span",{children:d.t(b)})}):null]}),[de,se]=s?[y("codeTitle"),y("codeHelp")]:[y("identifierTitle"),y(e.identifierBound?"boundDescription":"identifierDescription")];return(0,i.jsxs)("form",{className:`sekyro-step sekyro-otp${h?` ${h}`:""}`,"aria-labelledby":l,onSubmit:re,noValidate:!0,"data-testid":"sekyro-eid",children:[(0,i.jsxs)("div",{className:"sekyro-heading",children:[(0,i.jsx)("h2",{id:l,ref:ee,tabIndex:-1,className:"sekyro-text-body",children:de}),(0,i.jsx)("p",{className:"sekyro-text-muted",children:s&&e.context.simulation!==void 0?(0,i.jsx)(j,{template:d.t("sandbox.otpHint"),code:e.context.simulation.otpCode}):se}),e.afterPass==="continue"?(0,i.jsx)("p",{className:"sekyro-text-muted","data-testid":"sekyro-eid-continue",children:e.providerName?r("eid.continueHint",{provider:e.providerName}):r("eid.continueHintGeneric")}):null]}),ae,s?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("div",{className:"sekyro-field",children:[(0,i.jsx)("label",{className:"sekyro-label",htmlFor:`${l}-code`,children:r("eid.codeLabel")}),k?(0,i.jsx)("input",{id:`${l}-code`,className:"sekyro-input sekyro-input--number",dir:"ltr",value:f,disabled:!0,readOnly:!0}):(0,i.jsx)(J,{id:`${l}-code`,value:f,length:C,invalid:ie,onChange:u(n=>{p(null),n!==""&&ne(),_(n)},"onChange")}),e.codeExpiresAt!==void 0?(0,i.jsx)("span",{className:`sekyro-help sekyro-otp-expiry${x?" is-danger":""}`,children:x?r("eid.expired"):r("eid.expiresIn",{time:me(V)})}):null]}),(0,i.jsx)("span",{className:"sekyro-visually-hidden",role:"status","aria-live":"polite",children:x?r("eid.expired"):""}),(0,i.jsxs)(R,{children:[(0,i.jsx)(N,{type:"submit",full:!0,disabled:c||f.length!==C||k,"aria-busy":c||void 0,children:r("eid.verify")}),(0,i.jsx)("div",{className:"sekyro-resend-row",children:G?(0,i.jsx)("p",{className:"sekyro-resend is-waiting",children:r("eid.noResendsLeft")}):(0,i.jsx)("button",{type:"button",className:"sekyro-link sekyro-resend",disabled:c||$>0||k,onClick:u(()=>{m(()=>e.resend())},"onClick"),children:$>0?r("eid.resendIn",{seconds:$}):r("eid.resend")})}),!G&&e.resendsRemaining!==void 0?(0,i.jsx)("p",{className:"sekyro-help sekyro-center",children:B("eid.resendsRemaining",e.resendsRemaining)}):null]})]}):(0,i.jsxs)(i.Fragment,{children:[e.identifierBound?null:(0,i.jsxs)("div",{className:"sekyro-field",children:[(0,i.jsx)("label",{className:"sekyro-label",htmlFor:`${l}-nni`,children:d.t("population.label")}),(0,i.jsx)("input",{id:`${l}-nni`,className:"sekyro-input sekyro-input--number",dir:"ltr",inputMode:"numeric",autoComplete:"off",placeholder:d.t("population.placeholder"),value:S,"aria-describedby":`${l}-nni-help`,"aria-invalid":b==="population.invalid"||b==="population.reason_nni_invalid"||void 0,onChange:u(n=>{p(null),Z(A(n.target.value).replace(/\D/g,"").slice(0,10))},"onChange")}),(0,i.jsx)("span",{id:`${l}-nni-help`,className:"sekyro-help",children:d.t("population.helper")})]}),(0,i.jsx)(R,{children:(0,i.jsx)(N,{type:"submit",full:!0,disabled:c,"aria-busy":c||void 0,children:r("eid.start")})})]})]})}u(ue,"Ae");o(ue,"EidView");export{ue as EidView};
1
+ "use client";import{a as O,b as v,c as W}from"./chunk-JOZCJGRV.js";import{a as q,b as J,c as K}from"./chunk-ZIC5GEH2.js";import{a as z}from"./chunk-FDWO4KXK.js";import{a as w}from"./chunk-X3BGM3B2.js";import{c as T,d as A}from"./chunk-5FLR7RPJ.js";import"./chunk-LYYAVERP.js";import{H as j,K as E,a as oe,b as ce,c as N,t as U,y as R}from"./chunk-YWPZG2MZ.js";import"./chunk-U3UDWPBG.js";import"./chunk-ZKLSZJFN.js";import"./chunk-6H22RNSK.js";import"./chunk-UZWMCNZI.js";import{a as o}from"./chunk-RK4HVNRS.js";import"./chunk-D334IAZJ.js";import"./chunk-RRLXNT33.js";import{a as u,c as P}from"./chunk-4FHWXBOB.js";var a=P(oe(),1),i=P(ce(),1);var Q={en:v,fr:W,ar:O,es:v,pt:v,de:v},C=6,pe=new Set(["eid_identifier_invalid","eid_code_invalid","eid_locked","eid_not_enrolled"]),X=o((e,d)=>{if(e===void 0)return 0;let h=Date.parse(e)-d;return Number.isFinite(h)?Math.max(0,Math.ceil(h/1e3)):0},"secondsUntil"),me=o(e=>`${Math.floor(e/60)}:${String(e%60).padStart(2,"0")}`,"mmss");function ue({step:e,i18n:d,className:h,onError:Y}){let I=d.strings,r=o((n,t)=>w(I[n]??Q[d.locale][n]??"",t),"t"),B=o((n,t)=>{let le=new Intl.PluralRules(d.locale).select(t),L=`${n}.${le}`,te=I[L]??Q[d.locale][L]??r(`${n}.other`);return w(te,{count:new Intl.NumberFormat(d.locale).format(t)})},"plural"),y=o(n=>e.providerName?r(`eid.${n}`,{provider:e.providerName}):r(`eid.${n}Generic`),"named"),[S,Z]=(0,a.useState)(""),[f,_]=(0,a.useState)(""),[c,D]=(0,a.useState)(!1),[b,p]=(0,a.useState)(null),s=e.phase==="code",F=K(s),l=(0,a.useId)(),ee=U(),[ie,ne]=q(e.reason==="eid_code_invalid",e.codeAttemptsRemaining??0,()=>_("")),m=o(async n=>{D(!0),p(null);try{await n()}catch(t){p(z(t,d.strings)),Y?.(t)}finally{D(!1)}},"run"),M=(0,a.useRef)(!1);(0,a.useEffect)(()=>{!e.identifierBound||s||e.reason!==void 0||M.current||(M.current=!0,m(()=>e.start()))},[e.identifierBound,s,e.reason]),(0,a.useEffect)(()=>{(e.reason==="eid_code_invalid"||e.codeExpiresAt!==void 0)&&_("")},[e.reason,e.codeExpiresAt,e.codeAttemptsRemaining]);let H=(0,a.useRef)(s);(0,a.useEffect)(()=>{s&&!H.current&&document.getElementById(`${l}-code`)?.focus(),H.current=s},[s,l]);let k=e.reason==="eid_locked",V=X(e.codeExpiresAt,F),x=s&&e.codeExpiresAt!==void 0&&V===0,$=X(e.resendAvailableAt,F),G=e.resendsRemaining===0||e.reason==="eid_resend_limit",re=o(n=>{if(n.preventDefault(),s){f.length===C&&!k&&m(()=>e.verify(f));return}if(e.identifierBound){m(()=>e.start());return}let t=A(S);if(e.country==="MR"){if(!/^\d{10}$/.test(t))return p("population.invalid");if(!T(t))return p("population.reason_nni_invalid")}m(()=>e.start(t))},"onSubmit"),g=e.reason?.startsWith("eid_")?e.reason:void 0,ae=(0,i.jsxs)(i.Fragment,{children:[g!==void 0?(0,i.jsxs)(E,{tone:pe.has(g)?"danger":"warning",children:[(0,i.jsx)("span",{children:r(`reasons.${g}`)}),g==="eid_code_invalid"&&e.codeAttemptsRemaining!==void 0?(0,i.jsx)("span",{children:B("eid.codeAttemptsRemaining",e.codeAttemptsRemaining)}):null,e.canUseCamera?(0,i.jsx)(N,{kind:"secondary",disabled:c,onClick:u(()=>{m(()=>e.useCamera())},"onClick"),children:r("eid.useCamera")}):null]}):null,b!==null?(0,i.jsx)(E,{tone:"danger",children:(0,i.jsx)("span",{children:d.t(b)})}):null]}),[de,se]=s?[y("codeTitle"),y("codeHelp")]:[y("identifierTitle"),y(e.identifierBound?"boundDescription":"identifierDescription")];return(0,i.jsxs)("form",{className:`sekyro-step sekyro-otp${h?` ${h}`:""}`,"aria-labelledby":l,onSubmit:re,noValidate:!0,"data-testid":"sekyro-eid",children:[(0,i.jsxs)("div",{className:"sekyro-heading",children:[(0,i.jsx)("h2",{id:l,ref:ee,tabIndex:-1,className:"sekyro-text-body",children:de}),(0,i.jsx)("p",{className:"sekyro-text-muted",children:s&&e.context.simulation!==void 0?(0,i.jsx)(j,{template:d.t("sandbox.otpHint"),code:e.context.simulation.otpCode}):se}),e.afterPass==="continue"?(0,i.jsx)("p",{className:"sekyro-text-muted","data-testid":"sekyro-eid-continue",children:e.providerName?r("eid.continueHint",{provider:e.providerName}):r("eid.continueHintGeneric")}):null]}),ae,s?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("div",{className:"sekyro-field",children:[(0,i.jsx)("label",{className:"sekyro-label",htmlFor:`${l}-code`,children:r("eid.codeLabel")}),k?(0,i.jsx)("input",{id:`${l}-code`,className:"sekyro-input sekyro-input--number",dir:"ltr",value:f,disabled:!0,readOnly:!0}):(0,i.jsx)(J,{id:`${l}-code`,value:f,length:C,invalid:ie,onChange:u(n=>{p(null),n!==""&&ne(),_(n)},"onChange")}),e.codeExpiresAt!==void 0?(0,i.jsx)("span",{className:`sekyro-help sekyro-otp-expiry${x?" is-danger":""}`,children:x?r("eid.expired"):r("eid.expiresIn",{time:me(V)})}):null]}),(0,i.jsx)("span",{className:"sekyro-visually-hidden",role:"status","aria-live":"polite",children:x?r("eid.expired"):""}),(0,i.jsxs)(R,{children:[(0,i.jsx)(N,{type:"submit",full:!0,disabled:c||f.length!==C||k,"aria-busy":c||void 0,children:r("eid.verify")}),(0,i.jsx)("div",{className:"sekyro-resend-row",children:G?(0,i.jsx)("p",{className:"sekyro-resend is-waiting",children:r("eid.noResendsLeft")}):(0,i.jsx)("button",{type:"button",className:"sekyro-link sekyro-resend",disabled:c||$>0||k,onClick:u(()=>{m(()=>e.resend())},"onClick"),children:$>0?r("eid.resendIn",{seconds:$}):r("eid.resend")})}),!G&&e.resendsRemaining!==void 0?(0,i.jsx)("p",{className:"sekyro-help sekyro-center",children:B("eid.resendsRemaining",e.resendsRemaining)}):null]})]}):(0,i.jsxs)(i.Fragment,{children:[e.identifierBound?null:(0,i.jsxs)("div",{className:"sekyro-field",children:[(0,i.jsx)("label",{className:"sekyro-label",htmlFor:`${l}-nni`,children:d.t("population.label")}),(0,i.jsx)("input",{id:`${l}-nni`,className:"sekyro-input sekyro-input--number",dir:"ltr",inputMode:"numeric",autoComplete:"off",placeholder:d.t("population.placeholder"),value:S,"aria-describedby":`${l}-nni-help`,"aria-invalid":b==="population.invalid"||b==="population.reason_nni_invalid"||void 0,onChange:u(n=>{p(null),Z(A(n.target.value).replace(/\D/g,"").slice(0,10))},"onChange")}),(0,i.jsx)("span",{id:`${l}-nni-help`,className:"sekyro-help",children:d.t("population.helper")})]}),(0,i.jsx)(R,{children:(0,i.jsx)(N,{type:"submit",full:!0,disabled:c,"aria-busy":c||void 0,children:r("eid.start")})})]})]})}u(ue,"Ae");o(ue,"EidView");export{ue as EidView};
@@ -1 +1 @@
1
- "use client";import{a as J,b as K,c as Q}from"./chunk-IFGPCCJH.js";import{a as B}from"./chunk-6MEPT5ZS.js";import{a as G}from"./chunk-562ANROG.js";import"./chunk-YEPHU5PX.js";import"./chunk-OBPBHX2J.js";import{A as j,H as U,K as f,L as Y,a as me,b as pe,c as N,w as F,y as E}from"./chunk-UYAVCSQ4.js";import{x as P}from"./chunk-3KIFGAEK.js";import"./chunk-HODE7UDG.js";import"./chunk-TCW6XNLI.js";import"./chunk-UZWMCNZI.js";import{a as n}from"./chunk-RK4HVNRS.js";import"./chunk-D334IAZJ.js";import"./chunk-RRLXNT33.js";import{a as p,c as q}from"./chunk-4FHWXBOB.js";var t=q(me(),1),e=q(pe(),1);var ce={"emailOtp.reason_otp_daily_cap_reached":"لا يمكننا إرسال رمز إلى بريدك الإلكتروني اليوم. اختر طريقة أخرى للتحقق إن كانت متاحة، أو حاول مرة أخرى لاحقًا.","emailOtp.sendTitle":"تحقّق من بريدك الإلكتروني","emailOtp.sendDescription":"سنرسل إليك عبر البريد الإلكتروني رمزًا يُستخدم مرة واحدة لتأكيد أن هذا العنوان يخصّك","emailOtp.prefilledNotice":"سنرسل رمز تحقّق إلى بريدك الإلكتروني المسجّل.","emailOtp.emailLabel":"البريد الإلكتروني","emailOtp.emailHelper":"سنرسل رمزًا يُستخدم مرة واحدة إلى هذا العنوان","emailOtp.emailPlaceholder":"عنوان بريدك الإلكتروني","emailOtp.emailInvalid":"أدخل عنوان بريد إلكتروني صالحًا","emailOtp.send":"أرسل لي رمزًا عبر البريد الإلكتروني","emailOtp.verifyTitle":"أدخل الرمز","emailOtp.verifyDescription":"أدخل الرمز المكوّن من 6 أرقام الذي أرسلناه إلى بريدك الإلكتروني لإتمام التحقّق من عنوانك","emailOtp.sentTo":"أرسلنا رمزًا مكوّنًا من 6 أرقام إلى {email}","emailOtp.codeLabel":"رمز التحقّق","emailOtp.codeHelper":"أدخل الرمز المكوّن من 6 أرقام الوارد في الرسالة","emailOtp.verify":"تحقّق من الرمز","emailOtp.resend":"إعادة إرسال الرمز","emailOtp.resendIn":"إعادة إرسال الرمز خلال {seconds} ثانية","emailOtp.expiresIn":"ينتهي الرمز خلال {time}","emailOtp.expired":"انتهت صلاحية الرمز. أعد إرسال رمز جديد","emailOtp.reason_otp_mismatch":"الرمز غير صحيح. تحقّق منه وأعد إدخاله","emailOtp.reason_otp_expired":"انتهت صلاحية الرمز. أعد إرسال رمز جديد للمتابعة","emailOtp.reason_otp_send_failed":"تعذّر إرسال الرسالة. أعد المحاولة بعد قليل","emailOtp.reason_otp_rate_limited":"طلبت رموزًا كثيرة. انتظر قليلًا ثم أعد المحاولة","emailOtp.reason_email_invalid":"لا يمكننا الإرسال إلى هذا العنوان. تحقّق منه أو أدخل عنوانًا آخر","emailOtp.reason_email_disposable":"استخدم بريدًا إلكترونيًا دائمًا، وليس عنوانًا مؤقتًا","emailOtp.changeEmail":"تغيير البريد الإلكتروني","emailOtp.backToCode":"العودة إلى الرمز","emailOtp.reason_otp_resend_limit":"لا يمكنك طلب رموز أخرى. أدخل آخر رمز وصلك"},b={"emailOtp.reason_otp_daily_cap_reached":"We can't email you a code today. Choose another way to verify if one is offered, or try again later.","emailOtp.sendTitle":"Verify your email address","emailOtp.sendDescription":"We'll email you a one-time code to confirm this address is yours","emailOtp.prefilledNotice":"We'll send a verification code to your registered email address.","emailOtp.emailLabel":"Email address","emailOtp.emailHelper":"We'll send a one-time code to this address","emailOtp.emailPlaceholder":"Your email address","emailOtp.emailInvalid":"Enter a valid email address","emailOtp.send":"Email me a code","emailOtp.verifyTitle":"Enter the code","emailOtp.verifyDescription":"Type the 6-digit code we emailed you to finish verifying your address","emailOtp.sentTo":"We sent a 6-digit code to {email}","emailOtp.codeLabel":"Verification code","emailOtp.codeHelper":"Enter the 6-digit code from the email","emailOtp.verify":"Verify code","emailOtp.resend":"Resend code","emailOtp.resendIn":"Resend code in {seconds}s","emailOtp.expiresIn":"Code expires in {time}","emailOtp.expired":"That code has expired. Resend a new one","emailOtp.reason_otp_mismatch":"That code was incorrect. Check it and enter it again","emailOtp.reason_otp_expired":"That code has expired. Resend a new code to continue","emailOtp.reason_otp_send_failed":"We couldn't send the email. Try again in a moment","emailOtp.reason_otp_rate_limited":"Too many codes requested. Wait a moment, then try again","emailOtp.reason_email_invalid":"We can't send to this address. Check it or enter another one","emailOtp.reason_email_disposable":"Use a permanent email address, not a temporary one","emailOtp.changeEmail":"Change email","emailOtp.backToCode":"Back to code","emailOtp.reason_otp_resend_limit":"You can't get more codes. Enter the last code you received"},ue={"emailOtp.reason_otp_daily_cap_reached":"Nous ne pouvons pas vous envoyer de code par e-mail aujourd'hui. Choisissez une autre méthode si elle est proposée, ou réessayez plus tard.","emailOtp.sendTitle":"Vérifiez votre e-mail","emailOtp.sendDescription":"Nous vous enverrons par e-mail un code à usage unique pour confirmer que cette adresse vous appartient","emailOtp.prefilledNotice":"Nous enverrons un code de vérification à votre adresse e-mail enregistrée.","emailOtp.emailLabel":"Adresse e-mail","emailOtp.emailHelper":"Nous enverrons un code à usage unique à cette adresse","emailOtp.emailPlaceholder":"Votre adresse e-mail","emailOtp.emailInvalid":"Saisissez une adresse e-mail valide","emailOtp.send":"M'envoyer un code par e-mail","emailOtp.verifyTitle":"Saisissez le code","emailOtp.verifyDescription":"Saisissez le code à 6 chiffres que nous vous avons envoyé par e-mail pour finaliser la vérification de votre adresse","emailOtp.sentTo":"Nous avons envoyé un code à 6 chiffres à {email}","emailOtp.codeLabel":"Code de vérification","emailOtp.codeHelper":"Saisissez le code à 6 chiffres reçu par e-mail","emailOtp.verify":"Vérifier le code","emailOtp.resend":"Renvoyer le code","emailOtp.resendIn":"Renvoyer le code dans {seconds} s","emailOtp.expiresIn":"Le code expire dans {time}","emailOtp.expired":"Ce code a expiré. Renvoyez-en un nouveau","emailOtp.reason_otp_mismatch":"Ce code est incorrect. Vérifiez-le et saisissez-le à nouveau","emailOtp.reason_otp_expired":"Ce code a expiré. Renvoyez un nouveau code pour continuer","emailOtp.reason_otp_send_failed":"Nous n'avons pas pu envoyer l'e-mail. Réessayez dans un instant","emailOtp.reason_otp_rate_limited":"Trop de codes demandés. Patientez un instant, puis réessayez","emailOtp.reason_email_invalid":"Nous ne pouvons pas envoyer à cette adresse. Vérifiez-la ou saisissez-en une autre","emailOtp.reason_email_disposable":"Utilisez une adresse e-mail permanente, pas une adresse temporaire","emailOtp.changeEmail":"Changer d'adresse e-mail","emailOtp.backToCode":"Retour au code","emailOtp.reason_otp_resend_limit":"Vous ne pouvez plus demander de code. Saisissez le dernier code reçu"},Oe={en:b,fr:ue,ar:ce,es:b,pt:b,de:b},X=n((a,o,O)=>{if(a===void 0)return 0;let h=Date.parse(a)-o;return Number.isFinite(h)?Math.min(O,Math.max(0,Math.ceil(h/1e3))):0},"secondsUntil"),he=600,ye=60,ve=n(a=>`${Math.floor(a/60)}:${String(a%60).padStart(2,"0")}`,"mmss"),Z=new Set(["otp_expired","otp_send_failed","otp_rate_limited","otp_resend_limit","email_invalid","email_disposable","otp_daily_cap_reached"]);function _e({step:a,i18n:o,className:O,defaultEmail:h="",onError:ee}){let i=n((l,s)=>G(o.strings[l]??Oe[o.locale][l],s),"t"),[C,ae]=(0,t.useState)(h),[y,T]=(0,t.useState)(""),[r,z]=(0,t.useState)(!1),[I,w]=(0,t.useState)(null),[k,c]=(0,t.useState)(!1),[R,ie]=(0,t.useState)(null),u=(0,t.useRef)(null),v=a.phase==="verify",m=v&&!k,V=Q(v),d=(0,t.useId)(),[le,te]=J(a.reason==="otp_mismatch",a.attemptsRemaining,()=>T("")),$=v?a.codeExpiresAt??"sent":null;(0,t.useEffect)(()=>{$!==null&&(c(!1),u.current!==null&&!Z.has(a.reason??"")&&ie(u.current),u.current=null)},[$]);let S=n(async l=>{z(!0),w(null);try{await l()}catch(s){w(s instanceof P&&s.field==="email"?i("emailOtp.emailInvalid"):o.t(B(s,o.strings))),ee?.(s)}finally{z(!1)}},"run"),D=n(l=>{let s=a.needsEmail?l?R:C.trim():null;u.current=s,S(async()=>{try{await a.send(s!==null?{email:s}:{})}catch(de){throw u.current=null,de}})},"send"),L=n(l=>{S(()=>a.verify(l))},"submitCode"),se=n(l=>{l.preventDefault(),m?L(y):D(!1)},"onSubmit"),g=X(a.codeExpiresAt,V,he),x=X(a.resendAvailableAt,V,ye),_=m&&a.codeExpiresAt!==void 0&&g===0,A=a.needsEmail&&!a.attemptsExhausted,H=v&&(a.codeExpiresAt===void 0||g>0),W=m&&A?()=>c(!0):k&&H?()=>c(!1):null;j(W===null?null:r?()=>{}:W);let[re,ne]=i("emailOtp.sentTo").split("{email}"),M=a.context.simulation?.otpCode,oe=a.reason==="otp_mismatch"?(0,e.jsxs)(f,{tone:"danger",children:[(0,e.jsx)("span",{children:i("emailOtp.reason_otp_mismatch")}),(0,e.jsx)("span",{children:Y(o,a.attemptsRemaining,a.attemptsExhausted)})]}):a.reason!==void 0&&Z.has(a.reason)?(0,e.jsx)(f,{tone:"warning",children:(0,e.jsx)("span",{children:i(`emailOtp.reason_${a.reason}`)})}):null;return(0,e.jsxs)("form",{className:`sekyro-step sekyro-otp${O?` ${O}`:""}`,"aria-labelledby":d,onSubmit:se,noValidate:!0,children:[(0,e.jsx)(F,{id:d,title:i(m?"emailOtp.verifyTitle":"emailOtp.sendTitle"),lead:m&&M!==void 0?(0,e.jsx)(U,{template:o.t("sandbox.otpHint"),code:M}):m?(0,e.jsxs)(e.Fragment,{children:[re,(0,e.jsx)("bdi",{dir:"ltr",className:"sekyro-mono",children:R??a.sentToMasked}),ne]}):i("emailOtp.sendDescription")}),oe,I!==null?(0,e.jsx)(f,{tone:"danger",children:(0,e.jsx)("span",{children:I})}):null,m?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"sekyro-field",children:[(0,e.jsx)("label",{className:"sekyro-label",htmlFor:`${d}-code`,children:i("emailOtp.codeLabel")}),(0,e.jsx)(K,{id:`${d}-code`,value:y,invalid:le,onChange:p(l=>{l!==""&&te(),T(l),l.length===6&&y.length!==6&&!r&&!a.attemptsExhausted&&L(l)},"onChange")}),(0,e.jsx)("span",{className:`sekyro-help sekyro-otp-expiry${_?" is-danger":""}`,"aria-hidden":!_||void 0,children:_?i("emailOtp.expired"):i("emailOtp.expiresIn",{time:ve(g)})})]}),(0,e.jsx)("span",{className:"sekyro-visually-hidden",role:"status","aria-live":"polite",children:_?i("emailOtp.expired"):""}),(0,e.jsxs)(E,{children:[(0,e.jsx)(N,{type:"submit",full:!0,disabled:r||y.length!==6,"aria-busy":r||void 0,children:i("emailOtp.verify")}),(0,e.jsxs)("div",{className:"sekyro-resend-row",children:[(0,e.jsx)("button",{type:"button",className:"sekyro-link sekyro-resend",disabled:r||x>0,onClick:p(()=>D(!0),"onClick"),children:x>0?i("emailOtp.resendIn",{seconds:x}):i("emailOtp.resend")}),A?(0,e.jsx)("button",{type:"button",className:"sekyro-link sekyro-resend",disabled:r,onClick:p(()=>c(!0),"onClick"),"data-testid":"sekyro-otp-change",children:i("emailOtp.changeEmail")}):null]})]})]}):(0,e.jsxs)(e.Fragment,{children:[a.needsEmail?(0,e.jsxs)("div",{className:"sekyro-field",children:[(0,e.jsx)("label",{className:"sekyro-label",htmlFor:`${d}-email`,children:i("emailOtp.emailLabel")}),(0,e.jsx)("input",{id:`${d}-email`,className:"sekyro-input",type:"email",dir:"ltr",inputMode:"email",autoComplete:"email",autoCapitalize:"none",spellCheck:!1,placeholder:i("emailOtp.emailPlaceholder"),value:C,"aria-describedby":`${d}-email-help`,onChange:p(l=>ae(l.target.value),"onChange")}),(0,e.jsx)("span",{id:`${d}-email-help`,className:"sekyro-help",children:i("emailOtp.emailHelper")})]}):(0,e.jsx)("p",{className:"sekyro-text-muted",children:i("emailOtp.prefilledNotice")}),(0,e.jsxs)(E,{children:[(0,e.jsx)(N,{type:"submit",full:!0,disabled:r,"aria-busy":r||void 0,children:i("emailOtp.send")}),k&&H?(0,e.jsx)("button",{type:"button",className:"sekyro-link sekyro-resend",disabled:r,onClick:p(()=>c(!1),"onClick"),"data-testid":"sekyro-otp-back-to-code",children:i("emailOtp.backToCode")}):null]})]})]})}p(_e,"Ae");n(_e,"EmailOtpView");export{_e as EmailOtpView};
1
+ "use client";import{a as J,b as K,c as Q}from"./chunk-ZIC5GEH2.js";import{a as B}from"./chunk-FDWO4KXK.js";import{a as G}from"./chunk-X3BGM3B2.js";import"./chunk-5FLR7RPJ.js";import"./chunk-LYYAVERP.js";import{A as j,H as U,K as f,L as Y,a as me,b as pe,c as N,w as F,y as E}from"./chunk-YWPZG2MZ.js";import{A as P}from"./chunk-U3UDWPBG.js";import"./chunk-ZKLSZJFN.js";import"./chunk-6H22RNSK.js";import"./chunk-UZWMCNZI.js";import{a as n}from"./chunk-RK4HVNRS.js";import"./chunk-D334IAZJ.js";import"./chunk-RRLXNT33.js";import{a as p,c as q}from"./chunk-4FHWXBOB.js";var t=q(me(),1),e=q(pe(),1);var ce={"emailOtp.reason_otp_daily_cap_reached":"لا يمكننا إرسال رمز إلى بريدك الإلكتروني اليوم. اختر طريقة أخرى للتحقق إن كانت متاحة، أو حاول مرة أخرى لاحقًا.","emailOtp.sendTitle":"تحقّق من بريدك الإلكتروني","emailOtp.sendDescription":"سنرسل إليك عبر البريد الإلكتروني رمزًا يُستخدم مرة واحدة لتأكيد أن هذا العنوان يخصّك","emailOtp.prefilledNotice":"سنرسل رمز تحقّق إلى بريدك الإلكتروني المسجّل.","emailOtp.emailLabel":"البريد الإلكتروني","emailOtp.emailHelper":"سنرسل رمزًا يُستخدم مرة واحدة إلى هذا العنوان","emailOtp.emailPlaceholder":"عنوان بريدك الإلكتروني","emailOtp.emailInvalid":"أدخل عنوان بريد إلكتروني صالحًا","emailOtp.send":"أرسل لي رمزًا عبر البريد الإلكتروني","emailOtp.verifyTitle":"أدخل الرمز","emailOtp.verifyDescription":"أدخل الرمز المكوّن من 6 أرقام الذي أرسلناه إلى بريدك الإلكتروني لإتمام التحقّق من عنوانك","emailOtp.sentTo":"أرسلنا رمزًا مكوّنًا من 6 أرقام إلى {email}","emailOtp.codeLabel":"رمز التحقّق","emailOtp.codeHelper":"أدخل الرمز المكوّن من 6 أرقام الوارد في الرسالة","emailOtp.verify":"تحقّق من الرمز","emailOtp.resend":"إعادة إرسال الرمز","emailOtp.resendIn":"إعادة إرسال الرمز خلال {seconds} ثانية","emailOtp.expiresIn":"ينتهي الرمز خلال {time}","emailOtp.expired":"انتهت صلاحية الرمز. أعد إرسال رمز جديد","emailOtp.reason_otp_mismatch":"الرمز غير صحيح. تحقّق منه وأعد إدخاله","emailOtp.reason_otp_expired":"انتهت صلاحية الرمز. أعد إرسال رمز جديد للمتابعة","emailOtp.reason_otp_send_failed":"تعذّر إرسال الرسالة. أعد المحاولة بعد قليل","emailOtp.reason_otp_rate_limited":"طلبت رموزًا كثيرة. انتظر قليلًا ثم أعد المحاولة","emailOtp.reason_email_invalid":"لا يمكننا الإرسال إلى هذا العنوان. تحقّق منه أو أدخل عنوانًا آخر","emailOtp.reason_email_disposable":"استخدم بريدًا إلكترونيًا دائمًا، وليس عنوانًا مؤقتًا","emailOtp.changeEmail":"تغيير البريد الإلكتروني","emailOtp.backToCode":"العودة إلى الرمز","emailOtp.reason_otp_resend_limit":"لا يمكنك طلب رموز أخرى. أدخل آخر رمز وصلك"},b={"emailOtp.reason_otp_daily_cap_reached":"We can't email you a code today. Choose another way to verify if one is offered, or try again later.","emailOtp.sendTitle":"Verify your email address","emailOtp.sendDescription":"We'll email you a one-time code to confirm this address is yours","emailOtp.prefilledNotice":"We'll send a verification code to your registered email address.","emailOtp.emailLabel":"Email address","emailOtp.emailHelper":"We'll send a one-time code to this address","emailOtp.emailPlaceholder":"Your email address","emailOtp.emailInvalid":"Enter a valid email address","emailOtp.send":"Email me a code","emailOtp.verifyTitle":"Enter the code","emailOtp.verifyDescription":"Type the 6-digit code we emailed you to finish verifying your address","emailOtp.sentTo":"We sent a 6-digit code to {email}","emailOtp.codeLabel":"Verification code","emailOtp.codeHelper":"Enter the 6-digit code from the email","emailOtp.verify":"Verify code","emailOtp.resend":"Resend code","emailOtp.resendIn":"Resend code in {seconds}s","emailOtp.expiresIn":"Code expires in {time}","emailOtp.expired":"That code has expired. Resend a new one","emailOtp.reason_otp_mismatch":"That code was incorrect. Check it and enter it again","emailOtp.reason_otp_expired":"That code has expired. Resend a new code to continue","emailOtp.reason_otp_send_failed":"We couldn't send the email. Try again in a moment","emailOtp.reason_otp_rate_limited":"Too many codes requested. Wait a moment, then try again","emailOtp.reason_email_invalid":"We can't send to this address. Check it or enter another one","emailOtp.reason_email_disposable":"Use a permanent email address, not a temporary one","emailOtp.changeEmail":"Change email","emailOtp.backToCode":"Back to code","emailOtp.reason_otp_resend_limit":"You can't get more codes. Enter the last code you received"},ue={"emailOtp.reason_otp_daily_cap_reached":"Nous ne pouvons pas vous envoyer de code par e-mail aujourd'hui. Choisissez une autre méthode si elle est proposée, ou réessayez plus tard.","emailOtp.sendTitle":"Vérifiez votre e-mail","emailOtp.sendDescription":"Nous vous enverrons par e-mail un code à usage unique pour confirmer que cette adresse vous appartient","emailOtp.prefilledNotice":"Nous enverrons un code de vérification à votre adresse e-mail enregistrée.","emailOtp.emailLabel":"Adresse e-mail","emailOtp.emailHelper":"Nous enverrons un code à usage unique à cette adresse","emailOtp.emailPlaceholder":"Votre adresse e-mail","emailOtp.emailInvalid":"Saisissez une adresse e-mail valide","emailOtp.send":"M'envoyer un code par e-mail","emailOtp.verifyTitle":"Saisissez le code","emailOtp.verifyDescription":"Saisissez le code à 6 chiffres que nous vous avons envoyé par e-mail pour finaliser la vérification de votre adresse","emailOtp.sentTo":"Nous avons envoyé un code à 6 chiffres à {email}","emailOtp.codeLabel":"Code de vérification","emailOtp.codeHelper":"Saisissez le code à 6 chiffres reçu par e-mail","emailOtp.verify":"Vérifier le code","emailOtp.resend":"Renvoyer le code","emailOtp.resendIn":"Renvoyer le code dans {seconds} s","emailOtp.expiresIn":"Le code expire dans {time}","emailOtp.expired":"Ce code a expiré. Renvoyez-en un nouveau","emailOtp.reason_otp_mismatch":"Ce code est incorrect. Vérifiez-le et saisissez-le à nouveau","emailOtp.reason_otp_expired":"Ce code a expiré. Renvoyez un nouveau code pour continuer","emailOtp.reason_otp_send_failed":"Nous n'avons pas pu envoyer l'e-mail. Réessayez dans un instant","emailOtp.reason_otp_rate_limited":"Trop de codes demandés. Patientez un instant, puis réessayez","emailOtp.reason_email_invalid":"Nous ne pouvons pas envoyer à cette adresse. Vérifiez-la ou saisissez-en une autre","emailOtp.reason_email_disposable":"Utilisez une adresse e-mail permanente, pas une adresse temporaire","emailOtp.changeEmail":"Changer d'adresse e-mail","emailOtp.backToCode":"Retour au code","emailOtp.reason_otp_resend_limit":"Vous ne pouvez plus demander de code. Saisissez le dernier code reçu"},Oe={en:b,fr:ue,ar:ce,es:b,pt:b,de:b},X=n((a,o,O)=>{if(a===void 0)return 0;let h=Date.parse(a)-o;return Number.isFinite(h)?Math.min(O,Math.max(0,Math.ceil(h/1e3))):0},"secondsUntil"),he=600,ye=60,ve=n(a=>`${Math.floor(a/60)}:${String(a%60).padStart(2,"0")}`,"mmss"),Z=new Set(["otp_expired","otp_send_failed","otp_rate_limited","otp_resend_limit","email_invalid","email_disposable","otp_daily_cap_reached"]);function _e({step:a,i18n:o,className:O,defaultEmail:h="",onError:ee}){let i=n((l,s)=>G(o.strings[l]??Oe[o.locale][l],s),"t"),[C,ae]=(0,t.useState)(h),[y,T]=(0,t.useState)(""),[r,z]=(0,t.useState)(!1),[I,w]=(0,t.useState)(null),[k,c]=(0,t.useState)(!1),[R,ie]=(0,t.useState)(null),u=(0,t.useRef)(null),v=a.phase==="verify",m=v&&!k,V=Q(v),d=(0,t.useId)(),[le,te]=J(a.reason==="otp_mismatch",a.attemptsRemaining,()=>T("")),$=v?a.codeExpiresAt??"sent":null;(0,t.useEffect)(()=>{$!==null&&(c(!1),u.current!==null&&!Z.has(a.reason??"")&&ie(u.current),u.current=null)},[$]);let S=n(async l=>{z(!0),w(null);try{await l()}catch(s){w(s instanceof P&&s.field==="email"?i("emailOtp.emailInvalid"):o.t(B(s,o.strings))),ee?.(s)}finally{z(!1)}},"run"),D=n(l=>{let s=a.needsEmail?l?R:C.trim():null;u.current=s,S(async()=>{try{await a.send(s!==null?{email:s}:{})}catch(de){throw u.current=null,de}})},"send"),L=n(l=>{S(()=>a.verify(l))},"submitCode"),se=n(l=>{l.preventDefault(),m?L(y):D(!1)},"onSubmit"),g=X(a.codeExpiresAt,V,he),x=X(a.resendAvailableAt,V,ye),_=m&&a.codeExpiresAt!==void 0&&g===0,A=a.needsEmail&&!a.attemptsExhausted,H=v&&(a.codeExpiresAt===void 0||g>0),W=m&&A?()=>c(!0):k&&H?()=>c(!1):null;j(W===null?null:r?()=>{}:W);let[re,ne]=i("emailOtp.sentTo").split("{email}"),M=a.context.simulation?.otpCode,oe=a.reason==="otp_mismatch"?(0,e.jsxs)(f,{tone:"danger",children:[(0,e.jsx)("span",{children:i("emailOtp.reason_otp_mismatch")}),(0,e.jsx)("span",{children:Y(o,a.attemptsRemaining,a.attemptsExhausted)})]}):a.reason!==void 0&&Z.has(a.reason)?(0,e.jsx)(f,{tone:"warning",children:(0,e.jsx)("span",{children:i(`emailOtp.reason_${a.reason}`)})}):null;return(0,e.jsxs)("form",{className:`sekyro-step sekyro-otp${O?` ${O}`:""}`,"aria-labelledby":d,onSubmit:se,noValidate:!0,children:[(0,e.jsx)(F,{id:d,title:i(m?"emailOtp.verifyTitle":"emailOtp.sendTitle"),lead:m&&M!==void 0?(0,e.jsx)(U,{template:o.t("sandbox.otpHint"),code:M}):m?(0,e.jsxs)(e.Fragment,{children:[re,(0,e.jsx)("bdi",{dir:"ltr",className:"sekyro-mono",children:R??a.sentToMasked}),ne]}):i("emailOtp.sendDescription")}),oe,I!==null?(0,e.jsx)(f,{tone:"danger",children:(0,e.jsx)("span",{children:I})}):null,m?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"sekyro-field",children:[(0,e.jsx)("label",{className:"sekyro-label",htmlFor:`${d}-code`,children:i("emailOtp.codeLabel")}),(0,e.jsx)(K,{id:`${d}-code`,value:y,invalid:le,onChange:p(l=>{l!==""&&te(),T(l),l.length===6&&y.length!==6&&!r&&!a.attemptsExhausted&&L(l)},"onChange")}),(0,e.jsx)("span",{className:`sekyro-help sekyro-otp-expiry${_?" is-danger":""}`,"aria-hidden":!_||void 0,children:_?i("emailOtp.expired"):i("emailOtp.expiresIn",{time:ve(g)})})]}),(0,e.jsx)("span",{className:"sekyro-visually-hidden",role:"status","aria-live":"polite",children:_?i("emailOtp.expired"):""}),(0,e.jsxs)(E,{children:[(0,e.jsx)(N,{type:"submit",full:!0,disabled:r||y.length!==6,"aria-busy":r||void 0,children:i("emailOtp.verify")}),(0,e.jsxs)("div",{className:"sekyro-resend-row",children:[(0,e.jsx)("button",{type:"button",className:"sekyro-link sekyro-resend",disabled:r||x>0,onClick:p(()=>D(!0),"onClick"),children:x>0?i("emailOtp.resendIn",{seconds:x}):i("emailOtp.resend")}),A?(0,e.jsx)("button",{type:"button",className:"sekyro-link sekyro-resend",disabled:r,onClick:p(()=>c(!0),"onClick"),"data-testid":"sekyro-otp-change",children:i("emailOtp.changeEmail")}):null]})]})]}):(0,e.jsxs)(e.Fragment,{children:[a.needsEmail?(0,e.jsxs)("div",{className:"sekyro-field",children:[(0,e.jsx)("label",{className:"sekyro-label",htmlFor:`${d}-email`,children:i("emailOtp.emailLabel")}),(0,e.jsx)("input",{id:`${d}-email`,className:"sekyro-input",type:"email",dir:"ltr",inputMode:"email",autoComplete:"email",autoCapitalize:"none",spellCheck:!1,placeholder:i("emailOtp.emailPlaceholder"),value:C,"aria-describedby":`${d}-email-help`,onChange:p(l=>ae(l.target.value),"onChange")}),(0,e.jsx)("span",{id:`${d}-email-help`,className:"sekyro-help",children:i("emailOtp.emailHelper")})]}):(0,e.jsx)("p",{className:"sekyro-text-muted",children:i("emailOtp.prefilledNotice")}),(0,e.jsxs)(E,{children:[(0,e.jsx)(N,{type:"submit",full:!0,disabled:r,"aria-busy":r||void 0,children:i("emailOtp.send")}),k&&H?(0,e.jsx)("button",{type:"button",className:"sekyro-link sekyro-resend",disabled:r,onClick:p(()=>c(!1),"onClick"),"data-testid":"sekyro-otp-back-to-code",children:i("emailOtp.backToCode")}):null]})]})]})}p(_e,"Ae");n(_e,"EmailOtpView");export{_e as EmailOtpView};