@sekyro/elements 0.0.0-stage → 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 (122) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/LICENSE +29 -0
  3. package/README.md +247 -2
  4. package/custom-elements.json +355 -0
  5. package/dist/cdn/chunks/background-monitor-GCMNCJMG-UXYQ5GX7.js +1 -0
  6. package/dist/cdn/chunks/camera-trait-HVV5ZEDI-JB4HN6S3.js +1 -0
  7. package/dist/cdn/chunks/capture-session-doc-ELX6VK6Z-SDM3ILRA.js +1 -0
  8. package/dist/cdn/chunks/chunk-36WGD7QV.js +14 -0
  9. package/dist/cdn/chunks/chunk-4FHWXBOB.js +1 -0
  10. package/dist/cdn/chunks/chunk-5FLR7RPJ.js +1 -0
  11. package/dist/cdn/chunks/chunk-6H22RNSK.js +1 -0
  12. package/dist/cdn/chunks/chunk-7HJH5Q4M.js +1 -0
  13. package/dist/cdn/chunks/chunk-7Y73DZJB.js +1 -0
  14. package/dist/cdn/chunks/chunk-BF6SE2AC.js +1 -0
  15. package/dist/cdn/chunks/chunk-BZ37D4FR.js +1 -0
  16. package/dist/cdn/chunks/chunk-CFJJD6T2.js +1 -0
  17. package/dist/cdn/chunks/chunk-CMDITVXF.js +1 -0
  18. package/dist/cdn/chunks/chunk-CMS5FVGM.js +1 -0
  19. package/dist/cdn/chunks/chunk-CYGAKCKG.js +1 -0
  20. package/dist/cdn/chunks/chunk-D334IAZJ.js +1 -0
  21. package/dist/cdn/chunks/chunk-ET7NCKUV.js +1 -0
  22. package/dist/cdn/chunks/chunk-FAIDO3QL.js +1 -0
  23. package/dist/cdn/chunks/chunk-FCTRNWRU.js +1 -0
  24. package/dist/cdn/chunks/chunk-FDWO4KXK.js +1 -0
  25. package/dist/cdn/chunks/chunk-FEWP7HBJ.js +1 -0
  26. package/dist/cdn/chunks/chunk-HDJ6JFXX.js +1 -0
  27. package/dist/cdn/chunks/chunk-HQF66Y6S.js +1 -0
  28. package/dist/cdn/chunks/chunk-IBOJTLL7.js +1 -0
  29. package/dist/cdn/chunks/chunk-JM3CYFFZ.js +1 -0
  30. package/dist/cdn/chunks/chunk-JOZCJGRV.js +1 -0
  31. package/dist/cdn/chunks/chunk-KLE75SX4.js +1 -0
  32. package/dist/cdn/chunks/chunk-LYYAVERP.js +1 -0
  33. package/dist/cdn/chunks/chunk-PUO2VWDE.js +33 -0
  34. package/dist/cdn/chunks/chunk-RK4HVNRS.js +1 -0
  35. package/dist/cdn/chunks/chunk-RRLXNT33.js +1 -0
  36. package/dist/cdn/chunks/chunk-SK6UAYX2.js +1 -0
  37. package/dist/cdn/chunks/chunk-T4M2J44L.js +1 -0
  38. package/dist/cdn/chunks/chunk-U3UDWPBG.js +1 -0
  39. package/dist/cdn/chunks/chunk-UZWMCNZI.js +1 -0
  40. package/dist/cdn/chunks/chunk-X3BGM3B2.js +1 -0
  41. package/dist/cdn/chunks/chunk-X767DBO7.js +1 -0
  42. package/dist/cdn/chunks/chunk-YWPZG2MZ.js +25 -0
  43. package/dist/cdn/chunks/chunk-ZIC5GEH2.js +1 -0
  44. package/dist/cdn/chunks/chunk-ZKLSZJFN.js +1 -0
  45. package/dist/cdn/chunks/clip-inspect-HZ7N2YOP-DCDXB76T.js +1 -0
  46. package/dist/cdn/chunks/create-document-capture-UHZJUZHC-YYZNCSW6.js +1 -0
  47. package/dist/cdn/chunks/create-portrait-capture-VRZZOMJS-I4FBRNBP.js +1 -0
  48. package/dist/cdn/chunks/detector-scanic-F3Y5X3DF-FGVR4NEM.js +1 -0
  49. package/dist/cdn/chunks/document-capture-view-JE6IX4IE-2454PW6Z.js +1 -0
  50. package/dist/cdn/chunks/eid-view-RZS6MLT6-35VSHTV3.js +1 -0
  51. package/dist/cdn/chunks/email-otp-view-WUQ5OGDD-YDSUKAN2.js +1 -0
  52. package/dist/cdn/chunks/flow-views-5L7JF3MM-M6C3RXSX.js +1 -0
  53. package/dist/cdn/chunks/icao-gate-SO6YJ7RV-MPW6W3QN.js +1 -0
  54. package/dist/cdn/chunks/icao-tuning-DCZCMCEQ-ZQSK7ZOV.js +1 -0
  55. package/dist/cdn/chunks/keyframe-rank-R4NPQGN3-VRURE6OQ.js +1 -0
  56. package/dist/cdn/chunks/landmarker-3BBP3RBY-DDXMOLGK.js +1 -0
  57. package/dist/cdn/chunks/mrz-band-DCXFWDBD-OPMO6HYS.js +1 -0
  58. package/dist/cdn/chunks/overlay-de-JQ2FDZBA-HLFTXIF6.js +1 -0
  59. package/dist/cdn/chunks/overlay-es-WDYRSRHH-UXHTYCHD.js +1 -0
  60. package/dist/cdn/chunks/overlay-pt-AQMDWDWX-BD7TO6Y4.js +1 -0
  61. package/dist/cdn/chunks/plan-runner-ZHOYMRAO-RDS523K5.js +1 -0
  62. package/dist/cdn/chunks/portrait-capture-view-GQIBQY4U-TJUYRCTI.js +1 -0
  63. package/dist/cdn/chunks/portrait-review-view-XOQYQNU7-LPONGGFW.js +1 -0
  64. package/dist/cdn/chunks/print-4WOMNRBE-DNXJ7ERA.js +11 -0
  65. package/dist/cdn/chunks/scanic-ml-stub-XPNKT2N3-YSXFN7KY.js +1 -0
  66. package/dist/cdn/chunks/segmenter-3CVPTZMM-WGI6XGWN.js +1 -0
  67. package/dist/cdn/chunks/turnstile-N4K4U2AI-SLP55XAA.js +1 -0
  68. package/dist/cdn/chunks/upload-file-C4MFKLT3-DXCNEDXP.js +1 -0
  69. package/dist/cdn/chunks/vision_bundle-WBHR7TEE.js +41 -0
  70. package/dist/cdn/define.js +1 -0
  71. package/dist/cdn/index.js +1 -0
  72. package/dist/chunk-6NQ7EWA4.js +1 -0
  73. package/dist/chunk-72JW2LCH.js +25 -0
  74. package/dist/chunk-7URX73UH.js +1 -0
  75. package/dist/chunk-AGPBG22V.js +1 -0
  76. package/dist/chunk-B6A5RXN4.js +1 -0
  77. package/dist/chunk-EIRNIJXL.js +1 -0
  78. package/dist/chunk-ESSKMX7I.js +1 -0
  79. package/dist/chunk-IBPUWYHJ.js +1 -0
  80. package/dist/chunk-IGC6OQZ2.js +14 -0
  81. package/dist/chunk-QE2B3MSJ.js +1 -0
  82. package/dist/chunk-RMV3BNWO.js +1 -0
  83. package/dist/chunk-RPLVIGTS.js +1 -0
  84. package/dist/chunk-SEE6MST7.js +1 -0
  85. package/dist/chunk-TPIBYY2S.js +1 -0
  86. package/dist/chunk-XEY5ANJ6.js +1 -0
  87. package/dist/chunk-ZDF5JILV.js +33 -0
  88. package/dist/define.cjs +66 -0
  89. package/dist/define.d.cts +7 -0
  90. package/dist/define.d.ts +7 -0
  91. package/dist/define.js +1 -0
  92. package/dist/document-capture-view-JE6IX4IE-5HJYAEDX.js +1 -0
  93. package/dist/eid-view-RZS6MLT6-2W2T3AWK.js +1 -0
  94. package/dist/email-otp-view-WUQ5OGDD-NGI6PBX3.js +1 -0
  95. package/dist/flow-views-5L7JF3MM-P55CCCOH.js +1 -0
  96. package/dist/fonts/Cairo-OFL.txt +93 -0
  97. package/dist/fonts/Geist-OFL.txt +93 -0
  98. package/dist/fonts/Inter-OFL.txt +93 -0
  99. package/dist/fonts/SekyroCairo-Bold.woff2 +0 -0
  100. package/dist/fonts/SekyroCairo-Regular.woff2 +0 -0
  101. package/dist/fonts/SekyroCairo-SemiBold.woff2 +0 -0
  102. package/dist/fonts/SekyroGeist-Bold.woff2 +0 -0
  103. package/dist/fonts/SekyroGeist-SemiBold.woff2 +0 -0
  104. package/dist/fonts/SekyroInter-Medium.woff2 +0 -0
  105. package/dist/fonts/SekyroInter-Regular.woff2 +0 -0
  106. package/dist/fonts/SekyroInter-SemiBold.woff2 +0 -0
  107. package/dist/index.cjs +66 -0
  108. package/dist/index.d.cts +1115 -0
  109. package/dist/index.d.ts +1115 -0
  110. package/dist/index.js +1 -0
  111. package/dist/overlay-de-JQ2FDZBA-FR25JPE4.js +1 -0
  112. package/dist/overlay-es-WDYRSRHH-PFDMX5D2.js +1 -0
  113. package/dist/overlay-pt-AQMDWDWX-LTD4N2DW.js +1 -0
  114. package/dist/portrait-capture-view-GQIBQY4U-AFPEUDLY.js +1 -0
  115. package/dist/portrait-review-view-XOQYQNU7-IPKAZBP6.js +1 -0
  116. package/dist/styles.css +1479 -0
  117. package/package.json +117 -4
  118. package/types/empty.js +2 -0
  119. package/types/events.d.ts +9 -0
  120. package/types/jsx.d.ts +15 -0
  121. package/types/svelte.d.ts +16 -0
  122. package/types/vue.d.ts +15 -0
@@ -0,0 +1,14 @@
1
+ import{d as I}from"./chunk-LYYAVERP.js";import{a as C,b as P,c as H}from"./chunk-YWPZG2MZ.js";import{a as T}from"./chunk-ZKLSZJFN.js";import{a as u}from"./chunk-RK4HVNRS.js";import{a as s,b as D,c as N}from"./chunk-4FHWXBOB.js";var j=D(l=>{"use strict";var Q=C();function V(r){var e="https://react.dev/errors/"+r;if(1<arguments.length){e+="?args[]="+encodeURIComponent(arguments[1]);for(var t=2;t<arguments.length;t++)e+="&args[]="+encodeURIComponent(arguments[t])}return"Minified React error #"+r+"; visit "+e+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}s(V,"formatProdErrorMessage");function h(){}s(h,"noop");var c={d:{f:h,r:s(function(){throw Error(V(522))},"r"),D:h,C:h,L:h,m:h,X:h,S:h,M:h},p:0,findDOMNode:null},ee=Symbol.for("react.portal");function re(r,e,t){var n=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:ee,key:n==null?null:""+n,children:r,containerInfo:e,implementation:t}}s(re,"createPortal$1");var O=Q.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function M(r,e){if(r==="font")return"";if(typeof e=="string")return e==="use-credentials"?e:""}s(M,"getCrossOriginStringAs");l.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=c;l.createPortal=function(r,e){var t=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)throw Error(V(299));return re(r,e,null,t)};l.flushSync=function(r){var e=O.T,t=c.p;try{if(O.T=null,c.p=2,r)return r()}finally{O.T=e,c.p=t,c.d.f()}};l.preconnect=function(r,e){typeof r=="string"&&(e?(e=e.crossOrigin,e=typeof e=="string"?e==="use-credentials"?e:"":void 0):e=null,c.d.C(r,e))};l.prefetchDNS=function(r){typeof r=="string"&&c.d.D(r)};l.preinit=function(r,e){if(typeof r=="string"&&e&&typeof e.as=="string"){var t=e.as,n=M(t,e.crossOrigin),o=typeof e.integrity=="string"?e.integrity:void 0,i=typeof e.fetchPriority=="string"?e.fetchPriority:void 0;t==="style"?c.d.S(r,typeof e.precedence=="string"?e.precedence:void 0,{crossOrigin:n,integrity:o,fetchPriority:i}):t==="script"&&c.d.X(r,{crossOrigin:n,integrity:o,fetchPriority:i,nonce:typeof e.nonce=="string"?e.nonce:void 0})}};l.preinitModule=function(r,e){if(typeof r=="string")if(typeof e=="object"&&e!==null){if(e.as==null||e.as==="script"){var t=M(e.as,e.crossOrigin);c.d.M(r,{crossOrigin:t,integrity:typeof e.integrity=="string"?e.integrity:void 0,nonce:typeof e.nonce=="string"?e.nonce:void 0})}}else e==null&&c.d.M(r)};l.preload=function(r,e){if(typeof r=="string"&&typeof e=="object"&&e!==null&&typeof e.as=="string"){var t=e.as,n=M(t,e.crossOrigin);c.d.L(r,t,{crossOrigin:n,integrity:typeof e.integrity=="string"?e.integrity:void 0,nonce:typeof e.nonce=="string"?e.nonce:void 0,type:typeof e.type=="string"?e.type:void 0,fetchPriority:typeof e.fetchPriority=="string"?e.fetchPriority:void 0,referrerPolicy:typeof e.referrerPolicy=="string"?e.referrerPolicy:void 0,imageSrcSet:typeof e.imageSrcSet=="string"?e.imageSrcSet:void 0,imageSizes:typeof e.imageSizes=="string"?e.imageSizes:void 0,media:typeof e.media=="string"?e.media:void 0})}};l.preloadModule=function(r,e){if(typeof r=="string")if(e){var t=M(e.as,e.crossOrigin);c.d.m(r,{as:typeof e.as=="string"&&e.as!=="script"?e.as:void 0,crossOrigin:t,integrity:typeof e.integrity=="string"?e.integrity:void 0})}else c.d.m(r)};l.requestFormReset=function(r){c.d.r(r)};l.unstable_batchedUpdates=function(r,e){return r(e)};l.useFormState=function(r,e,t){return O.H.useFormState(r,e,t)};l.useFormStatus=function(){return O.H.useHostTransitionStatus()};l.version="19.2.0"});var W=D((de,B)=>{"use strict";function U(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(U)}catch(r){console.error(r)}}s(U,"checkDCE");U(),B.exports=j()});var z=N(C(),1),f=N(P(),1),a=N(P(),1);var E=N(C(),1),Z=N(W(),1),v=N(P(),1);var te=Array.from({length:56},(r,e)=>{let t=e/56*2*Math.PI-Math.PI/2,n=Math.cos(t),o=Math.sin(t);return{id:`tick-${e}`,frac:e/55,x1:150+108*n,y1:150+108*o,x2:150+138*n,y2:150+138*o,style:{transitionDelay:`${e*6}ms`}}});function F(r,e,t,n){return t?"var(--sekyro-color-success)":r?n?"color-mix(in srgb, var(--sekyro-color-warning) 75%, transparent)":e<.33?"color-mix(in srgb, var(--sekyro-color-brand) 55%, transparent)":e<.66?"color-mix(in srgb, var(--sekyro-color-brand) 80%, transparent)":"var(--sekyro-color-brand)":"color-mix(in srgb, var(--sekyro-color-surface) 32%, transparent)"}s(F,"T");u(F,"tickColor");var ae="M0 -50 H300 V350 H0 Z M50 150 a100,100 0 1 0 200,0 a100,100 0 1 0 -200,0 Z";function G({progress:r,phase:e,draining:t=!1}){let n=Math.min(1,Math.max(0,r)),o=Math.round(n*56),i=e==="checking",y=e==="recording",d=e==="frozen",m=i||d,p=i||y||d,k=e==="locked"||p,S=t&&!k;return(0,f.jsxs)("svg",{"aria-hidden":"true",viewBox:"0 0 300 300",preserveAspectRatio:"xMidYMid meet",className:"sekyro-stage__arc","data-testid":"sekyro-capture-arc","data-phase":e,"data-filled":o,"data-recording":y?"":void 0,"data-draining":S?"":void 0,children:[(0,f.jsx)("path",{fillRule:"evenodd",d:ae,fill:"color-mix(in srgb, var(--sekyro-color-fg) var(--sekyro-scrim, 96%), transparent)",style:{"--sekyro-scrim":m?"100%":"96%"},className:"sekyro-arc__scrim sekyro-capture-fade-in","data-testid":"sekyro-capture-scrim"}),(0,f.jsxs)("g",{className:e==="locked"?"sekyro-capture-settle":void 0,children:[(0,f.jsx)("g",{className:m?"sekyro-arc__ring sekyro-arc__ring--dim":"sekyro-arc__ring",children:te.map((g,x)=>(0,f.jsx)("line",{x1:g.x1,y1:g.y1,x2:g.x2,y2:g.y2,stroke:F(x<o,g.frac,k,S),strokeWidth:3,strokeLinecap:"round",style:g.style,className:"sekyro-arc__tick"},g.id))}),(0,f.jsx)("g",{className:e==="seeking"?"sekyro-capture-breathe":void 0,children:(0,f.jsx)("circle",{cx:150,cy:150,r:100,fill:"none",stroke:k?"var(--sekyro-color-success)":"var(--sekyro-color-surface)",strokeWidth:k?3.5:2.5,className:p?"sekyro-arc__guide sekyro-arc__guide--spin sekyro-capture-ring-spin":"sekyro-arc__guide sekyro-capture-fade-in","data-testid":"sekyro-capture-guide"})})]})]})}s(G,"x");u(G,"CaptureArc");function ne({videoRef:r,guidanceText:e,guidanceHint:t,guidanceKey:n,progress:o,phase:i,draining:y=!1,stillUrl:d,showChecking:m,operatorText:p=null,voicePrompt:k,overlay:S,reduceMotion:g=!1,modeSwitch:x=null}){let b=I(),w=i==="checking",_=w||i==="frozen",A=_&&m?b("capture.checking"):e,L=k?.(t,A,n);return(0,a.jsxs)("div",{className:g?"sekyro-stage sekyro-capture-reduce":"sekyro-stage","data-testid":"sekyro-capture-stage",children:[(0,a.jsx)("video",{ref:r,playsInline:!0,muted:!0,className:"sekyro-stage__video","data-testid":"sekyro-capture-video"}),d!==null&&_?(0,a.jsx)("img",{src:d,alt:b("capture.previewAlt"),className:"sekyro-stage__still sekyro-capture-develop","data-testid":"sekyro-capture-still"}):null,(0,a.jsx)(G,{progress:o,phase:i,draining:y}),S?.(r),L!=null&&!_?(0,a.jsx)("div",{className:"sekyro-stage__corner-start","data-testid":"sekyro-voice-slot",children:L}):null,x!==null&&!_?(0,a.jsx)($,{view:x,className:"sekyro-stage__corner-end sekyro-stage__mode-switch",kind:"chip"}):null,w&&m?(0,a.jsxs)("span",{className:"sekyro-stage__corner-end sekyro-stage__pill sekyro-capture-pill-in","data-testid":"sekyro-camera-off-pill",children:[(0,a.jsx)(Y,{}),b("capture.cameraOff")]}):null,(0,a.jsxs)("p",{"aria-live":"polite",className:"sekyro-stage__guidance","data-testid":"sekyro-capture-guidance",children:[(0,a.jsx)("span",{className:"sekyro-stage__guidance-text sekyro-capture-text-in",children:A},A),_&&m?(0,a.jsx)("span",{className:"sekyro-stage__guidance-hint",children:b("capture.checkingHint")}):p!==null&&!_?(0,a.jsx)("span",{className:"sekyro-stage__guidance-hint","data-testid":"sekyro-operator-line",children:p}):null]})]})}s(ne,"ne");u(ne,"CaptureStage");function $({view:r,className:e,kind:t}){let n=(0,z.useId)(),o=(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(K,{}),(0,a.jsx)("span",{children:r.label})]}),i={onClick:r.onSwitch,"aria-describedby":n,"data-testid":"sekyro-capture-mode-switch","data-mode":r.to};return(0,a.jsxs)(a.Fragment,{children:[t==="chip"?(0,a.jsx)(H,{kind:"chip",className:e,...i,children:o}):(0,a.jsx)("button",{type:"button",className:e,...i,children:o}),(0,a.jsx)("span",{id:n,className:"sekyro-visually-hidden",children:r.description})]})}s($,"H");u($,"ModeSwitchChip");function K(){return(0,a.jsxs)("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",className:"sekyro-icon",children:[(0,a.jsx)("path",{d:"M4 7.5h2.2l1.4-1.9h8.8l1.4 1.9H20a1.6 1.6 0 0 1 1.6 1.6v8.3A1.6 1.6 0 0 1 20 19H4a1.6 1.6 0 0 1-1.6-1.6V9.1A1.6 1.6 0 0 1 4 7.5Z"}),(0,a.jsx)("path",{d:"M15.4 11.9a3.5 3.5 0 0 0-6.1-1.4M15.4 11.9h-2.1m2.1 0V9.8"}),(0,a.jsx)("path",{d:"M8.6 13.4a3.5 3.5 0 0 0 6.1 1.4M8.6 13.4h2.1m-2.1 0v2.1"})]})}s(K,"D");u(K,"FlipCameraIcon");function Y(){return(0,a.jsxs)("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",className:"sekyro-icon sekyro-icon--sm",children:[(0,a.jsx)("path",{d:"M4 7.5h2.2l1.4-1.9h8.8l1.4 1.9H20a1.6 1.6 0 0 1 1.6 1.6v8.3A1.6 1.6 0 0 1 20 19H4a1.6 1.6 0 0 1-1.6-1.6V9.1A1.6 1.6 0 0 1 4 7.5Z"}),(0,a.jsx)("path",{d:"M3 3l18 18"})]})}s(Y,"G");u(Y,"CameraOffIcon");var ie=typeof window>"u"?E.useEffect:E.useLayoutEffect,R="data-sekyro-ramp",se=[["background-color","transparent"],["background-image","none"]];function q(r){let e=[],t=r.ownerDocument;for(let i=r;i!==null&&i!==t.documentElement;i=i.parentElement){if(!(i instanceof HTMLElement)&&!(i instanceof SVGElement))continue;let y=i.style;for(let[d,m]of se){let p=y.getPropertyValue(d),k=y.getPropertyPriority(d);y.setProperty(d,m,"important"),e.push(()=>{p===""?y.removeProperty(d):y.setProperty(d,p,k)})}}let n=t.documentElement,o=n.hasAttribute(R);return n.setAttribute(R,""),o||e.push(()=>n.removeAttribute(R)),()=>{for(let i of e.reverse())i()}}s(q,"z");u(q,"clearAncestorBackdrops");function X(r){return{position:"fixed",inset:0,minWidth:"100vw",minHeight:"100lvh",margin:0,padding:0,border:0,zIndex:-1,pointerEvents:"none",backgroundColor:T(r)}}s(X,"B");u(X,"washStyle");function J(r){return{position:"absolute",inset:0,pointerEvents:"none",backgroundColor:T(r)}}s(J,"Y");u(J,"coverStyle");function oe({colour:r}){let e=(0,E.useRef)(null),t=r!==null;return ie(()=>{let n=e.current?.parentElement;if(!(!t||n===null||n===void 0))return q(n)},[t]),r===null||typeof document>"u"?null:(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)("div",{ref:e,"aria-hidden":"true","data-testid":"sekyro-screen-ramp-cover","data-colour":r,style:J(r)}),(0,Z.createPortal)((0,v.jsx)("div",{"aria-hidden":"true","data-testid":"sekyro-screen-ramp","data-colour":r,style:X(r)}),document.body)]})}s(oe,"de");u(oe,"ScreenRampLayer");export{W as a,ne as b,$ as c,oe as d};
2
+ /*! Bundled license information:
3
+
4
+ react-dom/cjs/react-dom.production.js:
5
+ (**
6
+ * @license React
7
+ * react-dom.production.js
8
+ *
9
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
10
+ *
11
+ * This source code is licensed under the MIT license found in the
12
+ * LICENSE file in the root directory of this source tree.
13
+ *)
14
+ */
@@ -0,0 +1 @@
1
+ var i=Object.create;var f=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var k=Object.getOwnPropertyNames;var l=Object.getPrototypeOf,m=Object.prototype.hasOwnProperty;var h=a=>{throw TypeError(a)};var n=(a,b,c)=>b in a?f(a,b,{enumerable:!0,configurable:!0,writable:!0,value:c}):a[b]=c;var p=(a,b)=>f(a,"name",{value:b,configurable:!0});var q=(a,b)=>()=>(b||a((b={exports:{}}).exports,b),b.exports);var o=(a,b,c,d)=>{if(b&&typeof b=="object"||typeof b=="function")for(let e of k(b))!m.call(a,e)&&e!==c&&f(a,e,{get:()=>b[e],enumerable:!(d=j(b,e))||d.enumerable});return a};var r=(a,b,c)=>(c=a!=null?i(l(a)):{},o(b||!a||!a.__esModule?f(c,"default",{value:a,enumerable:!0}):c,a));var s=(a,b,c)=>n(a,typeof b!="symbol"?b+"":b,c),g=(a,b,c)=>b.has(a)||h("Cannot "+c);var t=(a,b,c)=>(g(a,b,"read from private field"),c?c.call(a):b.get(a)),u=(a,b,c)=>b.has(a)?h("Cannot add the same private member more than once"):b instanceof WeakSet?b.add(a):b.set(a,c),v=(a,b,c,d)=>(g(a,b,"write to private field"),d?d.call(a,c):b.set(a,c),c),w=(a,b,c)=>(g(a,b,"access private method"),c);export{p as a,q as b,r as c,s as d,t as e,u as f,v as g,w as h};
@@ -0,0 +1 @@
1
+ import{B as Y,C as U,D as Re,E as Ee,a as L,b as ve,c as ye,f as _e,g as ge,h as we,i as ke,j as be,k as Ce,m as A,o as b,p as S,q as I,s as C,t as Z,u as Me,v as Ae,w as Se,x as Te,y as Ie}from"./chunk-U3UDWPBG.js";import{f as Oe}from"./chunk-ZKLSZJFN.js";import{b as he,c as $,e as Pe}from"./chunk-D334IAZJ.js";import{a as t}from"./chunk-4FHWXBOB.js";function nt(n){return n.idNumberBound??n.nniBound}t(nt,"J");function Ne(n){return n===void 0?void 0:n.idNumberFromDocument??n.nniFromDocument}t(Ne,"F");var xe="https://api.sekyro.ai",rt=5e3,it=24e4,at=1500,ot=10;function st(n){return new Promise(a=>setTimeout(a,n))}t(st,"Rt");function lt(){let n=globalThis.crypto;if(n!==void 0&&typeof n.randomUUID=="function")return n.randomUUID();let a=new Uint8Array(16);if(n!==void 0&&typeof n.getRandomValues=="function")n.getRandomValues(a);else for(let p=0;p<16;p+=1)a[p]=Math.floor(Math.random()*256);a[6]=(a[6]??0)&15|64,a[8]=(a[8]??0)&63|128;let d=[...a].map(p=>p.toString(16).padStart(2,"0")).join("");return`${d.slice(0,8)}-${d.slice(8,12)}-${d.slice(12,16)}-${d.slice(16,20)}-${d.slice(20)}`}t(lt,"xt");function ut(n){return ct(n,{})}t(ut,"gn");function ct(n,a){let d=n.apiOrigin??xe,p=n.autoRetry??!0,Ke=n.rearm??"auto",f=a.client??new ye({apiOrigin:d,sessionToken:n.clientToken,fetch:n.fetch}),R=a.sleep??st,Be=a.uuid??lt,Ve=a.getTurnstileToken??((e,r)=>import("./turnstile-N4K4U2AI-SLP55XAA.js").then(i=>i.executeTurnstile(e,r))),k=Pe(),M=null,z=null,u=!1,J=new AbortController,o=null,E=null,P=null,O=t(()=>P??Re(o),"G"),Q=t(()=>Ee(U(o),O()),"le"),v=t(e=>{o=e,k.emit("view",e),M?.onView(e)},"R"),m=t(()=>o!==null?Promise.resolve(o):(E??(E=f.getSession().then(e=>(v(e),e)).finally(()=>{E=null})),E),"_"),y=t(async()=>{let e=await f.getSession();return v(e),e},"x"),K=t(async(e,r)=>{e.plan!==void 0?v(e):await y()},"Q"),N=null,X=t(async e=>{let r=await m();if(e||!r.consentRecorded){let i=await f.recordConsent(n.locale);i.plan!==void 0?v(i):o!==null&&v({...o,consentRecorded:!0})}ce(r.turnstileSiteKey)},"pe"),w=t(e=>e?.force===!0?X(!0):(N??(N=X(!1).finally(()=>{N=null})),N),"I"),B={client:f,ensureConsent:t(e=>w(e),"ensureConsent"),sleep:R,uuid:Be,...a.random!==void 0?{random:a.random}:{},onBusy:t(e=>{u||k.emit("busy",e)},"onBusy")},ee=!1,te=null,V=t(e=>{if(e.status==="verified"||e.status==="not_verified"||e.status==="review"){if(ee)return;ee=!0}te=JSON.stringify(e),k.emit("result",e)},"ee"),Fe=t(e=>{te!==JSON.stringify(e)&&V(e)},"st"),ne=t(async e=>{let r=o;e&&(r=await y().catch(()=>o));let i=r===null?null:A(r);return i!==null&&!u&&k.emit("method",i),i!==null},"he"),F=null,re=!1,ie=!1,ae=t(()=>Se(B,(e,r)=>e.submitCheck("population_registry",{},{idempotencyKey:r})),"Ce"),oe=t(e=>nt(e)===!0||Ne(I(e,"population_registry"))===!0,"_e"),He=t(async()=>{try{let e=await m();if(b(e)||A(e)!==null||S(e)?.checkType!=="population_registry")return;if(!oe(e)&&Ne(I(e,"population_registry"))===void 0&&(e=await y()),!oe(e)){ie=!0;return}await w(),await K(await ae(),"population_registry");let r=o===null?void 0:I(o,"population_registry");if(r?.state==="input_required"&&r.reason==="registry_unavailable"&&Ce(r)>0){if(await R(rt),u)return;await K(await ae(),"population_registry")}}catch(e){if(e instanceof L&&(e.code==="check_not_active"||e.code==="step_not_on_path")){await y().catch(()=>{});return}re=!0;return}o!==null&&b(o)&&V(Z(o,{autoRetry:p}))},"at"),se=t(()=>(F??(F=He()),F),"ke"),le=a.now??Date.now,x=null,H=t(e=>Ve(e,{signal:J.signal}),"te"),ue=t((e,r)=>e!==null&&e.siteKey===r&&le()-e.at<it,"be"),ce=t(e=>{if(e===null||u||ue(x,e))return;let r=H(e);r.catch(()=>{}),x={siteKey:e,at:le(),token:r}},"Re"),je=t(e=>{let r=x;return x=null,ue(r,e)?r.token.catch(()=>H(e)):H(e)},"ct"),de=t(async()=>{let e=(await m()).turnstileSiteKey;return e===null?{}:{channel:"hosted_web",siteKey:e,turnstileToken:await je(e)}},"xe"),D=t(e=>{if(u)return;let r=f.reportCaptureIssue;if(r===void 0)return;let i=e.formFactor;try{i??(i=he())}catch{}try{Promise.resolve(r.call(f,{...e,...i!==void 0?{formFactor:i}:{}})).catch(()=>{})}catch{}},"q"),h=null,pe=Promise.resolve(),T=0,qe=t(async()=>{let e=await m();for(let r=0;r<ot&&!u&&!b(e)&&S(e)===void 0&&be(e).some(i=>i.state==="processing")&&(await R(at),!u);r+=1)e=await y();return e},"ut"),$e=t(async(e,r,i)=>{let{capture:c}=e,s=t(()=>u,"h"),_=t(()=>e.alive&&e.attempt===i,"O"),G=t(l=>{_()&&c.setFlowState(l)},"Y"),g=t(l=>{if(!s()&&(l.status==="unavailable"&&l.reasonCode!==void 0&&!_e(l.reasonCode)&&D({check:"liveness",kind:"unavailable",phase:"upload",engineKind:l.reasonCode,attempt:Math.max(0,e.issues.value)}),V(l),!!_())){if(l.status==="retry"&&Ke==="auto"){c.handle.retry();return}c.setFlowState("done")}},"v");if(r.degraded==="NO_RECORDER"){let l=o?.sessionId??(await m().catch(()=>null))?.sessionId??"";g(C(l,"no_recorder"));return}G("uploading");try{if(await se(),s())return;let l=await m(),me;if(!b(l)&&A(l)!==null){await ne(!1),g(C(l.sessionId,"method_required"));return}if(!b(l)){if(S(l)?.checkType==="population_registry"){g(C(l.sessionId,ie?"nni_unbound":re?"network":"registry_unavailable"));return}if(await w(),s())return;me=o??l;let q=await Te({...B,artifacts:r,getAttestation:de,getView:t(()=>o??l,"getView"),refreshView:y,applySubmit:K,onPhase:G,isCancelled:s,onKeyframePromoted:t(et=>{z=et},"onKeyframePromoted")});if(s())return;if(q.kind==="unavailable"){g(C(l.sessionId,q.reason));return}if(q.kind==="resync"&&await y(),o!==null&&A(o)!==null){await ne(!1),g(C(l.sessionId,"method_required"));return}l=await qe()}g(Z(l,{autoRetry:p,previous:me}))}catch{if(s())return;g(C(o?.sessionId??"","network"))}},"dt"),Ze=t((e,r)=>{let i=e.attempt;T>0&&e.alive&&e.capture.setFlowState("uploading"),T+=1,pe=pe.then(()=>$e(e,r,i)).finally(()=>{T-=1,T===0&&M?.onChainIdle()}).catch(()=>{})},"lt"),fe=t(e=>{h?.capture.handle.destroy(),h!==null&&(h.alive=!1);let r=Oe(e,M?.captureInternals?.(e)??a.capture,()=>o?.capture?.liveness?.keyframe?.rank===!0,Q,()=>o?.capture?.liveness?.screenRamp,{session:t(()=>U(o),"session"),onModeChange:t(s=>{P=s},"onModeChange")}),i={capture:r,alive:!0,attempt:0,issues:we()};h=i,r.handle.on("error",s=>{D(ge("liveness",s,i.issues.value))}),r.handle.on("state",s=>{if(i.issues.note(s),s==="starting"){i.attempt+=1,ce(o?.turnstileSiteKey??null);let _=o===null?void 0:S(o)?.checkType;(_==="liveness"||_==="face_match")&&w().catch(()=>{})}}),r.handle.on("captured",s=>{Promise.resolve().then(()=>Ze(i,s))});let c=r.handle;return{get state(){return c.state},get captureMode(){return c.captureMode},get facingMode(){return c.facingMode},on:t((s,_)=>c.on(s,_),"on"),start:t(async s=>{if(o===null&&await m().catch(()=>{}),!!i.alive)return c.start(s)},"start"),retry:t(()=>c.retry(),"retry"),switchCamera:t(()=>c.switchCamera(),"switchCamera"),canSwitchCaptureMode:t(()=>c.canSwitchCaptureMode(),"canSwitchCaptureMode"),setCaptureMode:t(s=>c.setCaptureMode(s),"setCaptureMode"),destroy:t(()=>{i.alive=!1,h===i&&(h=null),c.destroy()},"destroy")}},"ve"),Ye=t(async()=>{if(u)return null;try{let e=await m();return u?null:A(e)}catch{return null}},"pt"),We=t(async()=>{if(u)return"self";try{let e=await m();if(u)return"self";let r=U(e);return r==="choice"?O()??r:r}catch{return"self"}},"ft"),ze=t(async()=>{if(u)return!1;try{let e=await m();return u||b(e)||$()?!1:Y(e,S(e))==="phone"||Y(e,I(e,"liveness"))==="phone"}catch{return!1}},"mt"),Je=t(async()=>{if(u)return!1;try{let e=await m();return!u&&e.returning===!0}catch{return!1}},"ht"),Qe=t(async e=>{let r=(await m()).plan?.choice,i=r?.options.find(s=>ke[s.service]===e);if(!i)throw new RangeError(`method ${String(e)} is not offered`);let c=await f.choose(r.nodeId,i.id);u||v(c)},"St"),j=null,Xe=t(()=>(j??(j=import("./plan-runner-ZHOYMRAO-RDS523K5.js").then(e=>{let r=e.createPlanRunner({runtime:B,currentView:t(()=>o,"currentView"),cameraMode:Q,captureModeSwitch:{pick:O,choose:t(i=>{P=i},"choose")},ensureView:m,refreshView:y,ensureConsent:t(()=>w(),"ensureConsent"),liveness:fe,stopLiveness:t(()=>{h!==null&&(h.alive=!1,h.capture.handle.destroy(),h=null)},"stopLiveness"),chainBusy:t(()=>T>0,"chainBusy"),destroyed:t(()=>u,"destroyed"),sleep:R,isMobile:$,now:a.now??Date.now,keptFaceKey:t(()=>z,"keptFaceKey"),setView:v,baseCapture:a.capture,emitStep:t(i=>{u||k.emit("step",i)},"emitStep"),emitResult:Fe,reportCaptureIssue:D,documentInternals:a.document,portraitInternals:a.portrait,livePhotoInternals:a.livePhoto,uploadInternals:a.upload});return M=r,r})),j),"yt");return{consent:t(()=>w(),"consent"),startRegistry:se,methodChoice:Ye,selectMethod:Qe,reportCameraUnavailable:t(async e=>{await w();let r=f.reportCameraUnavailable;if(r===void 0)throw new TypeError("this client cannot report a missing camera");let i=await r.call(f,e).catch(c=>{if(c instanceof L&&c.code==="check_out_of_order")return f.getSession();throw c});u||v(i)},"reportCameraUnavailable"),reportCaptureIssue:D,testerGate:t(async e=>{let r=f.testerGate;if(r===void 0)throw new TypeError("this client cannot run the tester gate");let i=e.clip,c=ve(e.clipMime??"");if(i===void 0||!Ae.includes(c))throw new TypeError("the capture has no clip");await w();let s=await Me(f,"clip",c,i.size,{engine:e.engine,durationMs:e.clipMs});await f.uploadToSpaces(s.uploadUrl,i,c);let{key:_}=await f.completeMedia(s.key),G=await r.call(f,{clipKey:_,attestation:await de(),captureChannel:e.captureChannel,capture:Ie(e)}),{bound:g,...l}=G;return u||(l.plan!==void 0?v(l):await y()),{bound:g===!0}},"testerGate"),mobileRequired:ze,captureMode:We,chooseCaptureMode:t(e=>{P=e},"chooseCaptureMode"),get captureChoice(){return O()},returning:Je,liveness:fe,run:t(async()=>{if(u)throw new Error("verification destroyed");return(await Xe()).run()},"run"),currentStep:t(()=>M?.current()??null,"currentStep"),voiceClips:t(async()=>{if(u)return null;try{let e=await m();return u?null:e.voice??null}catch{return null}},"voiceClips"),on:t((e,r)=>k.on(e,r),"on"),destroy:t(()=>{u=!0,J.abort(),M?.destroy(),h!==null&&(h.alive=!1,h.capture.handle.destroy(),h=null),k.clear()},"destroy")}}t(ct,"Ot");var De=["AD","AE","AF","AG","AI","AL","AM","AO","AQ","AR","AS","AT","AU","AW","AX","AZ","BA","BB","BD","BE","BF","BG","BH","BI","BJ","BL","BM","BN","BO","BQ","BR","BS","BT","BV","BW","BY","BZ","CA","CC","CD","CF","CG","CH","CI","CK","CL","CM","CN","CO","CR","CU","CV","CW","CX","CY","CZ","DE","DJ","DK","DM","DO","DZ","EC","EE","EG","EH","ER","ES","ET","FI","FJ","FK","FM","FO","FR","GA","GB","GD","GE","GF","GG","GH","GI","GL","GM","GN","GP","GQ","GR","GS","GT","GU","GW","GY","HK","HM","HN","HR","HT","HU","ID","IE","IL","IM","IN","IO","IQ","IR","IS","IT","JE","JM","JO","JP","KE","KG","KH","KI","KM","KN","KP","KR","KW","KY","KZ","LA","LB","LC","LI","LK","LR","LS","LT","LU","LV","LY","MA","MC","MD","ME","MF","MG","MH","MK","ML","MM","MN","MO","MP","MQ","MR","MS","MT","MU","MV","MW","MX","MY","MZ","NA","NC","NE","NF","NG","NI","NL","NO","NP","NR","NU","NZ","OM","PA","PE","PF","PG","PH","PK","PL","PM","PN","PR","PS","PT","PW","PY","QA","RE","RO","RS","RU","RW","SA","SB","SC","SD","SE","SG","SH","SI","SJ","SK","SL","SM","SN","SO","SR","SS","ST","SV","SX","SY","SZ","TC","TD","TF","TG","TH","TJ","TK","TL","TM","TN","TO","TR","TT","TV","TW","TZ","UA","UG","UM","US","UY","UZ","VA","VC","VE","VG","VI","VN","VU","WF","WS","XK","YE","YT","ZA","ZM","ZW"],Ge=["carte_identite","passport","residence_permit"];function W(n,a){let d=n.byIssuer?.[a]??n.default;return Ge.filter(p=>d==="*"||d.includes(p))}t(W,"At");function Le(n,a=De){return[...new Set([...a,...Object.keys(n.byIssuer??{})])].filter(d=>W(n,d).length>0).sort()}t(Le,"Pn");var Ue=Object.freeze({nni_invalid:"id_number_invalid",nni_not_found:"registry_record_not_found",nni_recheck:"id_number_recheck",document_nni_mismatch:"document_id_number_mismatch",nni_locked:"id_number_locked",nni_unbound:"id_number_unbound",sandbox_nni_not_seeded:"sandbox_id_number_not_seeded",missing_nni:"missing_id_number",registry_needs_nni_source:"registry_needs_id_number_source"}),Et=new Map(Object.entries(Ue)),Pt=new Map(Object.entries(Ue).map(([n,a])=>[a,n]));function un(n){if(n==="permission")return"denied";if(n==="notfound"||n==="insecure"||n==="unsupported")return"no_camera"}t(un,"ee");var dt=/^[A-Z0-9][A-Z0-9 -]{0,39}$/,pt=Object.freeze({normalize:t(n=>n.trim().toUpperCase().replace(/\s+/g," "),"normalize"),check:t(n=>dt.test(n),"check"),registrySources:Object.freeze([]),describe:"number must be 1 to 40 letters, digits, spaces or hyphens"});function ft(n){return typeof n=="string"&&/^\d{10}$/.test(n)&&Number(n)%97===1}t(ft,"re");var mt=Object.freeze({normalize:t(n=>n.trim(),"normalize"),check:t(n=>ft(n),"check"),registrySources:Object.freeze(["MR.anrpts"]),describe:"number must be the 10-digit Mauritanian national ID number with a valid check digit"}),ht=Object.freeze({"MR:national_id":mt});function vt(n,a){return ht[`${n.toUpperCase()}:${a}`]??pt}t(vt,"m");var cn=Object.freeze({MRT:"MR"});function dn(n){return vt("MR","national_id").check(n)}t(dn,"pe");function yt(n){let a="";for(let d of n){let p=d.codePointAt(0)??0;p>=1632&&p<=1641?a+=String(p-1632):p>=1776&&p<=1785?a+=String(p-1776):d!==" "&&d!=="-"&&d!==" "&&(a+=d)}return a}t(yt,"g");function pn(n){return yt(n)}t(pn,"ue");var fn=W,mn=Le;var _t=t(()=>import("./create-document-capture-UHZJUZHC-YYZNCSW6.js"),"M");function gt(){_t().then(n=>n.warmDocumentCapture()).catch(()=>{})}t(gt,"E");function hn(){gt()}t(hn,"Ge");var wt=t(()=>import("./create-portrait-capture-VRZZOMJS-I4FBRNBP.js"),"D");function kt(){wt().then(n=>n.warmPortraitCapture()).catch(()=>{})}t(kt,"L");function vn(){kt()}t(vn,"ke");export{ut as a,un as b,dn as c,pn as d,fn as e,mn as f,hn as g,vn as h};
@@ -0,0 +1 @@
1
+ import{a as n}from"./chunk-4FHWXBOB.js";var S="0.1.0-rc.23",k=/FBAN|FBAV|FB_IAB|FBIOS|MessengerForiOS|Instagram|WhatsApp|musical_ly|BytedanceWebview|TikTok|Snapchat|\bLine\/|LinkedInApp|Pinterest|MicroMessenger|; wv\)/i;function O(t){let e=t??(typeof navigator>"u"?"":String(navigator.userAgent??""));return k.test(e)}n(O,"p");var f="sekyro.did",C=1e4,w=n(()=>globalThis.process?.versions?.node,"v"),l;function y(){let t=globalThis.crypto;try{if(typeof t?.randomUUID=="function")return t.randomUUID()}catch{}try{if(typeof t?.getRandomValues=="function"){let e=t.getRandomValues(new Uint8Array(16));return Array.from(e,a=>a.toString(16).padStart(2,"0")).join("")}}catch{}}n(y,"b");function H(){try{let t=localStorage.getItem(f);if(t)return t;let e=y();return e!==void 0&&localStorage.setItem(f,e),e}catch{return l??(l=y()),l}}n(H,"I");async function M(){let t=globalThis.crypto?.subtle;if(!t)return"";let e=navigator,a=JSON.stringify([e.userAgent,e.platform,e.hardwareConcurrency??null,e.deviceMemory??null,e.maxTouchPoints??0,screen.width,screen.height,screen.colorDepth,globalThis.devicePixelRatio??1,Intl.DateTimeFormat().resolvedOptions().timeZone,e.languages?.join(",")??e.language]),i=await t.digest("SHA-256",new TextEncoder().encode(a));return Array.from(new Uint8Array(i),s=>s.toString(16).padStart(2,"0")).join("").slice(0,32)}n(M,"w");function x(){try{let t=Number(navigator.maxTouchPoints);return Number.isFinite(t)&&t>=0?{touch:Math.min(64,Math.trunc(t))}:{}}catch{return{}}}n(x,"k");function W(t){let e=new TextEncoder().encode(t),a="";for(let i of e)a+=String.fromCharCode(i);return btoa(a).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}n(W,"x");function j(t){let e,a,i,s,c,d,m=n(()=>d?.readyState==="live","u"),T=n(()=>{c!==void 0||!globalThis.crypto?.subtle||w()||m()||(c=Promise.race([import("./print-4WOMNRBE-DNXJ7ERA.js"),new Promise(r=>setTimeout(r,C))]).then(r=>r?.computePrint(m)).then(r=>{r==="busy"?c=void 0:s=r}).catch(()=>{}))},"_");return{timezone(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone?.slice(0,64)||void 0}catch{return}},noteCameraLabel(r){r&&(e=r.slice(0,128))},noteCamera(r){a=r},noteCameraTrack(r){d=r},async deviceHeader(){try{i??(i=M().catch(()=>""));let r=[];navigator.webdriver&&r.push("webdriver"),/HeadlessChrome/.test(navigator.userAgent)&&r.push("headless");let g=await i,p=H(),A={v:1,platform:"web",sdk:t.sdk.slice(0,64),ids:[...p?[{kind:"web_local",value:p.slice(0,128)}]:[],...g?[{kind:"web_fp",value:g}]:[]],screen:{w:screen.width,h:screen.height,dpr:globalThis.devicePixelRatio??1},...x(),...e?{cameraLabel:e}:{},...r.length?{signals:r}:{},...s?{print:{v:2,...s,...a?{camera:a}:{}}}:{},...O()?{inApp:!0}:{}},I=W(JSON.stringify(A));return T(),I}catch{return}},printReady(){return c??Promise.resolve()}}}n(j,"A");var v=Symbol.for("sekyro.web.clientContext"),b=globalThis,u=b[v]??(b[v]=j({sdk:`@sekyro/web@${S}`}));function z(t){try{let e=t.getVideoTracks?.()[0];if(e){if(u.noteCameraLabel(e.label),u.noteCameraTrack(e),w())return;import("./camera-trait-HVV5ZEDI-JB4HN6S3.js").then(a=>a.noteCameraTrait(e,u)).catch(()=>{})}}catch{}}n(z,"M");var P=Object.freeze({LOW:Object.freeze({cadenceHz:5,inputWidth:128,animations:"reduced"}),MID:Object.freeze({cadenceHz:8,inputWidth:160,animations:"full"}),HIGH:Object.freeze({cadenceHz:10,inputWidth:192,animations:"full"})}),L=new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11]);function F(){let t=typeof navigator>"u"?void 0:navigator,e=!1;try{e=typeof WebAssembly<"u"&&WebAssembly.validate(L)}catch{e=!1}return{cores:t?.hardwareConcurrency??2,memGB:t?.deviceMemory??null,simd:e}}n(F,"o");function U(t){let e=t.memGB??4;return t.cores<4||e<3?"LOW":t.cores>=8&&e>=6?"HIGH":"MID"}n(U,"l");var h=["LOW","MID","HIGH"],o,_=(o=class{constructor(e){this.samples=[],this.adjusted=!1,this.current=e}get deviceClass(){return this.current}get profile(){return P[this.current]}record(e){if(this.adjusted||this.samples.length>=10)return this.current;if(this.samples.push(e),this.samples.length<10)return this.current;this.adjusted=!0;let a=this.samples.reduce((i,s)=>i+s,0)/this.samples.length;if(a>70)this.current="LOW";else if(a<25){let i=h.indexOf(this.current);this.current=h[Math.min(h.length-1,i+1)]??this.current}return this.current}},n(o,"i"),o);export{S as a,O as b,u as c,z as d,F as e,U as f,_ as g};
@@ -0,0 +1 @@
1
+ import{a as O}from"./chunk-4FHWXBOB.js";var d=Object.freeze({EDGE_LUMA_DELTA:40,MIN_ROW_DENSITY:.08,MIN_COLUMN_COVERAGE:.6,MIN_WIDTH_FRAC:.55,MIN_HEIGHT_FRAC:.02,MAX_HEIGHT_FRAC:.16,ROW_MERGE_GAP:18}),u=12;function m(s,W={}){let _={...d,...W},{data:o,width:l,height:e}=s;if(l<32||e<32)return null;let C=new Array(e).fill(!1),T=new Float32Array(e),A=new Int32Array(e).fill(l),M=new Int32Array(e).fill(-1),p=l/u,h=new Array(u);for(let t=0;t<e;t++){let i=0;h.fill(!1);let G=t*l*4,y=.299*(o[G]??0)+.587*(o[G+1]??0)+.114*(o[G+2]??0);for(let r=1;r<l;r++){let w=G+r*4,b=.299*(o[w]??0)+.587*(o[w+1]??0)+.114*(o[w+2]??0);Math.abs(b-y)>=_.EDGE_LUMA_DELTA&&(i+=1,h[Math.min(u-1,Math.floor(r/p))]=!0,r<A[t]&&(A[t]=r),r>M[t]&&(M[t]=r)),y=b}T[t]=i/l;let L=h.filter(Boolean).length/u;C[t]=T[t]>=_.MIN_ROW_DENSITY&&L>=_.MIN_COLUMN_COVERAGE&&M[t]-A[t]>=_.MIN_WIDTH_FRAC*l}let E=null,n=-1,R=-1,I=0,D=O(t=>{if(n<0)return;let i=t-n+1;i>=_.MIN_HEIGHT_FRAC*e&&i<=_.MAX_HEIGHT_FRAC*e&&I>=4&&(E===null||I>E.rows)&&(E={top:n,bottom:t,rows:I}),n=-1,I=0},"N");for(let t=0;t<e;t++)C[t]&&(n<0?n=t:t-R>_.ROW_MERGE_GAP&&(D(R),n=t),R=t,I+=1);if(D(R),E===null)return null;let a=E,f=l,N=-1,F=0,H=0;for(let t=a.top;t<=a.bottom;t++)C[t]&&(A[t]<f&&(f=A[t]),M[t]>N&&(N=M[t]),F+=T[t],H+=1);return N-f<_.MIN_WIDTH_FRAC*l?null:{x:f,y:a.top,width:N-f,height:a.bottom-a.top+1,density:H>0?F/H:0}}O(m,"F");export{d as a,m as b};
@@ -0,0 +1 @@
1
+ import{a as tt,b as $t,c as te,d as dt,e as ee}from"./chunk-X767DBO7.js";import{a as Ut,b as Kt,e as Yt}from"./chunk-SK6UAYX2.js";import{a as Vt,b as Zt}from"./chunk-CMS5FVGM.js";import{b as Jt}from"./chunk-7HJH5Q4M.js";import{d as Wt,e as Ht,f as Qt}from"./chunk-6H22RNSK.js";import{a as ct,b as ut,c as Y,d as Xt}from"./chunk-UZWMCNZI.js";import{g as Nt,i as qt,j as Gt,k as jt,l as Bt}from"./chunk-RRLXNT33.js";import{a as n}from"./chunk-4FHWXBOB.js";var et=Object.freeze({sensing:{key:"sensing",reticle:"searching",minDurationMs:900},too_far:{key:"too_far",reticle:"coaching",minDurationMs:1400},too_close:{key:"too_close",reticle:"coaching",minDurationMs:1400},edge_clipped:{key:"edge_clipped",reticle:"coaching",minDurationMs:1400},wrong_shape:{key:"wrong_shape",reticle:"coaching",minDurationMs:1400},tilted:{key:"tilted",reticle:"coaching",minDurationMs:1400},too_dark:{key:"too_dark",reticle:"coaching",minDurationMs:1400},too_bright:{key:"too_bright",reticle:"coaching",minDurationMs:1400},blurry:{key:"blurry",reticle:"coaching",minDurationMs:1400},focus_far:{key:"focus_far",reticle:"coaching",minDurationMs:1600},glare:{key:"glare",reticle:"coaching",minDurationMs:1400},hold_still:{key:"hold_still",reticle:"locking",minDurationMs:900},processing:{key:"processing",reticle:"processing",minDurationMs:800},side_captured:{key:"side_captured",reticle:"flip",minDurationMs:2600},captured:{key:"captured",reticle:"done",minDurationMs:800}});function Ae(s){return s.framing==="no_document"?"sensing":s.framing==="too_far"?"too_far":s.framing==="too_close"?"too_close":s.framing==="edge_clipped"?"edge_clipped":s.framing==="wrong_shape"?"wrong_shape":s.framing==="tilted"?"tilted":s.lighting==="too_dark"?"too_dark":s.lighting==="too_bright"?"too_bright":s.glare==="glare"?"glare":s.blur==="blurry"?"blurry":"hold_still"}n(Ae,"ne");var G,ze=(G=class{constructor(t=2600,e=.35){this.windowMs=t,this.decayPerSecond=e,this.votes=[],this.current=et.sensing,this.currentSinceMs=null}reset(){this.votes=[],this.current=et.sensing,this.currentSinceMs=null}force(t,e){return this.votes=[],this.current=et[t],this.currentSinceMs=e,this.current}tick(t,e){if(this.currentSinceMs===null&&(this.currentSinceMs=e),this.votes.push({key:t,atMs:e}),this.votes=this.votes.filter(o=>e-o.atMs<=this.windowMs),e-this.currentSinceMs<this.current.minDurationMs)return this.current;let i=new Map;for(let o of this.votes){let l=(e-o.atMs)/1e3,r=this.decayPerSecond**l;i.set(o.key,(i.get(o.key)??0)+r)}let a=this.current.key,h=-1;for(let[o,l]of i)l>h&&(h=l,a=o);return a!==this.current.key&&(this.current=et[a],this.currentSinceMs=e),this.current}},n(G,"ot"),G),Ce=Object.freeze({MAX_AREA_FRAC:.92,TILT_MAX_SIDE_RATIO:1.3,GLARE_MAX_SPECULAR_FRAC:.025});function Ie(s){let{data:t,width:e,height:i}=s,a=e*i;if(a===0)return 0;let h=0;for(let o=0;o<a;o++){let l=o*4;.299*(t[l]??0)+.587*(t[l+1]??0)+.114*(t[l+2]??0)>=252&&h++}return h/a}n(Ie,"re");function Le(s){let t=n((r,c)=>Math.hypot(c.x-r.x,c.y-r.y),"t"),e=t(s.topLeft,s.topRight),i=t(s.bottomLeft,s.bottomRight),a=t(s.topLeft,s.bottomLeft),h=t(s.topRight,s.bottomRight),o=Math.max(e,i)/Math.max(1e-6,Math.min(e,i)),l=Math.max(a,h)/Math.max(1e-6,Math.min(a,h));return Math.max(o,l)}n(Le,"je");function Oe(s){let t={...$t,...s.thresholds},e=Ce,{quad:i,frameWidth:a,frameHeight:h,measures:o}=s,l=s.format==="ID-3",r="ok";if(i===null)r="no_document";else if(l){let d=dt(i),m=a>0?d.width/a:0,g=d.height>0?d.width/d.height:0;m<t.ID3_BAND_MIN_WIDTH_FRAC?r="too_far":ie(i,a,h,t.EDGE_CLIP_MARGIN_PX)?r="edge_clipped":(g<t.ID3_BAND_ASPECT_MIN||g>t.ID3_BAND_ASPECT_MAX)&&(r="wrong_shape")}else{let d=te(i,a,h),m=dt(i),g=Math.max(m.width,m.height)/Math.max(1e-6,Math.min(m.width,m.height));d<t.MIN_AREA_FRAC?r="too_far":d>e.MAX_AREA_FRAC?r="too_close":ie(i,a,h,t.EDGE_CLIP_MARGIN_PX)?r="edge_clipped":Zt(s.format,g)?Le(i)>e.TILT_MAX_SIDE_RATIO&&(r="tilted"):r="wrong_shape"}let c=o.exposure>=t.GUIDE_EXPOSURE?"ok":o.meanLuma<(ct[0]+ct[1])/2?"too_dark":"too_bright",u=o.sharpness>=t.GUIDE_SHARPNESS?"ok":"blurry",f=o.specularFraction>=e.GLARE_MAX_SPECULAR_FRAC?"glare":"ok";return{framing:r,lighting:c,blur:u,glare:f,acceptable:r==="ok"&&c==="ok"&&u==="ok"&&f==="ok"}}n(Oe,"ae");function ie(s,t,e,i){return[s.topLeft,s.topRight,s.bottomRight,s.bottomLeft].some(a=>a.x<=i||a.y<=i||a.x>=t-i||a.y>=e-i)}n(ie,"se");var Ee=Object.freeze({width:1920,height:1080}),Pe=Object.freeze({width:3840,height:2160}),se=4096,We=2560,Ne=640,it=.15,V=Object.freeze({side:.2,above:.9,below:.3});function C(s){let t=[s.topLeft.x,s.topRight.x,s.bottomRight.x,s.bottomLeft.x],e=[s.topLeft.y,s.topRight.y,s.bottomRight.y,s.bottomLeft.y],i=Math.min(...t),a=Math.min(...e);return{x:i,y:a,width:Math.max(...t)-i,height:Math.max(...e)-a}}n(C,"E");function me(s,t){let e=Math.max(0,Math.floor(s.x)),i=Math.max(0,Math.floor(s.y)),a=Math.min(t.width,Math.ceil(s.x+s.width)),h=Math.min(t.height,Math.ceil(s.y+s.height));return a-e<16||h-i<16?null:{x:e,y:i,width:a-e,height:h-i}}n(me,"he");function qe(s,t,e){if(s===null||t.width<=0||t.height<=0)return null;let i=C(s);if(i.width<=0||i.height<=0)return null;let a=e==="ID-3"?{x:i.x-i.width*V.side,y:i.y-i.width*V.above,width:i.width*(1+2*V.side),height:i.height+i.width*(V.above+V.below)}:{x:i.x-i.width*it,y:i.y-i.height*it,width:i.width*(1+2*it),height:i.height*(1+2*it)};return me(a,t)}n(qe,"Je");function ge(s,t,e){let i=Math.max(s,t);return i>0?Math.min(1,e/i):1}n(ge,"ft");function pe(s,t,e,i,a=We){let h=t.width>0?e.width/t.width:1,o=t.height>0?e.height/t.height:1,l=s===null?null:{topLeft:{x:s.topLeft.x*h,y:s.topLeft.y*o},topRight:{x:s.topRight.x*h,y:s.topRight.y*o},bottomRight:{x:s.bottomRight.x*h,y:s.bottomRight.y*o},bottomLeft:{x:s.bottomLeft.x*h,y:s.bottomLeft.y*o}},r=qe(l,e,i)??{x:0,y:0,width:e.width,height:e.height},c=ge(r.width,r.height,a),u=Math.max(1,Math.round(r.width*c)),f=Math.max(1,Math.round(r.height*c)),d=null;if(l!==null){let m=C(l);d=me({x:(m.x-r.x)*c,y:(m.y-r.y)*c,width:m.width*c,height:m.height*c},{width:u,height:f})}return{crop:r,width:u,height:f,docRegion:d}}n(pe,"pt");function Ge(s,t,e,i=Pe){if(e==="LOW")return null;let a=s?.width?.max,h=s?.height?.max;if(typeof a!="number"||typeof h!="number"||a<=0||h<=0)return null;let o=Math.max(a,h),l=Math.min(a,h),r=Math.min(o,Math.max(i.width,i.height)),c=Math.min(l,Math.min(i.width,i.height));return r<=Math.max(t.width,t.height)?null:{width:{ideal:r},height:{ideal:c}}}n(Ge,"de");function je(s){let t={},e=s?.imageWidth,i=s?.imageHeight;if(typeof e?.max=="number"&&e.max>0){let a=typeof i?.max=="number"&&i.max>0?e.max/i.max:1.3333333333333333,h=a>=1?se:se*a,o=Math.min(e.max,Math.floor(h)),l=typeof e.step=="number"&&e.step>0?e.step:1,r=typeof e.min=="number"?e.min:0;o=Math.max(r,r+Math.floor((o-r)/l)*l),t.imageWidth=o}return s?.fillLightMode?.includes("off")===!0&&(t.fillLightMode="off"),t}n(je,"me");function Be(s,t){if(s.width<=0||s.height<=0||t.width<=0||t.height<=0)return!1;let e=s.width>s.height,i=t.width>t.height;return e!==i&&s.width!==s.height&&t.width!==t.height?!1:Math.max(s.width,s.height)>=1.2*Math.max(t.width,t.height)}n(Be,"fe");function He(s,t,e,i){if(e===null)return!1;let a=C(s),h=C(e);if(t.width<=0||i.width<=0)return!1;let o=a.width/t.width,l=h.width/i.width;return l>0&&o>=.6*l&&o<=1.25*l}n(He,"pe");var ae=3500,Qe=.92;function Me(){let s=globalThis.ImageCapture;return typeof s=="function"?s:null}n(Me,"ye");function Xe(s){return/AppleWebKit\//.test(s)&&!/(Chrome|Chromium|Edg|OPR)\//.test(s)}n(Xe,"$e");function Ue(s,t=typeof navigator>"u"?"":navigator.userAgent){return Me()!==null&&!Xe(t)&&s!=null&&s.kind==="video"&&s.readyState==="live"}n(Ue,"Me");function he(s,t){return new Promise((e,i)=>{let a=setTimeout(()=>i(new Error("takePhoto timed out")),t);s.then(h=>{clearTimeout(a),e(h)},h=>{clearTimeout(a),i(h)})})}n(he,"be");function ft(s,t){let e=document.createElement("canvas");return e.width=s,e.height=t,e}n(ft,"gt");function Ke(s,t){return new Promise((e,i)=>{s.toBlob(a=>a?e(a):i(new Error("toBlob failed")),"image/jpeg",t)})}n(Ke,"ti");async function ye(s,t,e,i,a){let h=ft(e,i),o=ft(1,1);try{let l=h.getContext("2d");if(l===null)throw new Error("2d context unavailable");l.imageSmoothingQuality="high",l.drawImage(s,t.x,t.y,t.width,t.height,0,0,e,i);let r=await Ke(h,Qe),c=a===null?null:Ut({topLeft:{x:a.x,y:a.y},topRight:{x:a.x+a.width,y:a.y},bottomRight:{x:a.x+a.width,y:a.y+a.height},bottomLeft:{x:a.x,y:a.y+a.height}},{width:e,height:i},{width:e,height:i}),u=Kt(h,c),f=ge(e,i,Ne);return o.width=Math.max(1,Math.round(e*f)),o.height=Math.max(1,Math.round(i*f)),o.getContext("2d")?.drawImage(h,0,0,o.width,o.height),{blob:r,previewDataUrl:o.toDataURL("image/jpeg",.85),sharpness:u}}finally{h.width=0,h.height=0,o.width=0,o.height=0}}n(ye,"ke");function Ye(s,t){let e=Math.min(1,t/s.width),i=ft(Math.max(1,Math.round(s.width*e)),Math.max(1,Math.round(s.height*e)));try{let a=i.getContext("2d",{willReadFrequently:!0});return a===null?null:(a.imageSmoothingQuality="high",a.drawImage(s,0,0,i.width,i.height),a.getImageData(0,0,i.width,i.height))}finally{i.width=0,i.height=0}}n(Ye,"ei");async function Ve(s,t,e,i){let a={width:Math.max(1,s.videoWidth),height:Math.max(1,s.videoHeight)},h=pe(t,e,a,i);return{...await ye(s,h.crop,h.width,h.height,h.docRegion),docRegion:h.docRegion,source:"video",width:h.width,height:h.height}}n(Ve,"De");async function Ze(s,t,e,i,a){let h=Me();if(h===null)return null;let o=null;try{let l=new h(a.track),r=await he(l.getPhotoCapabilities?.()??Promise.resolve({}),ae).catch(()=>({})),c=await he(l.takePhoto(je(r)),ae);o=await createImageBitmap(c);let u={width:s.videoWidth,height:s.videoHeight};if(!Be(o,u))return null;let f=Ye(o,a.detectWidth),d=null;f!==null&&t!==null&&(d=await a.detect(f).catch(()=>null));let m=f??{width:o.width,height:o.height};d!==null&&!He(d,m,t,e)&&(d=null);let g=pe(d,m,o,i);return{...await ye(o,g.crop,g.width,g.height,g.docRegion),docRegion:g.docRegion,source:"photo",width:g.width,height:g.height}}catch{return null}finally{o?.close()}}n(Ze,"xe");var yt=Object.freeze({width:3840,height:2160,lensSelection:!0,continuousFocus:!0,refocusBeforePhotoMs:350,zoomMax:2,zoomNoFocusInfo:1.5,zoomMinSourcePx:2160,fillDistanceM:Object.freeze({id1:.11,id3:.15}),focusMarginFrac:.2,stillSharpnessMin:.16,stillRefusalsMax:2,focusFarFillFrac:.45,noDocFarHintMs:1500,zoomFallbackMs:8e3}),R=n((s,t,e)=>typeof s=="number"&&Number.isFinite(s)&&s>=t&&s<=e?s:void 0,"S");function Ri(s){let t=yt,e=s!==null&&typeof s=="object"?s:{},i=e.fillDistanceM!==null&&typeof e.fillDistanceM=="object"?e.fillDistanceM:{},a=n((h,o)=>typeof h=="boolean"?h:o,"n");return{width:R(e.width,640,7680)??t.width,height:R(e.height,480,4320)??t.height,lensSelection:a(e.lensSelection,t.lensSelection),continuousFocus:a(e.continuousFocus,t.continuousFocus),refocusBeforePhotoMs:R(e.refocusBeforePhotoMs,0,2e3)??t.refocusBeforePhotoMs,zoomMax:R(e.zoomMax,1,5)??t.zoomMax,zoomNoFocusInfo:R(e.zoomNoFocusInfo,1,5)??t.zoomNoFocusInfo,zoomMinSourcePx:R(e.zoomMinSourcePx,0,8e3)??t.zoomMinSourcePx,fillDistanceM:{id1:R(i.id1,.03,1)??t.fillDistanceM.id1,id3:R(i.id3,.03,1)??t.fillDistanceM.id3},focusMarginFrac:R(e.focusMarginFrac,0,2)??t.focusMarginFrac,stillSharpnessMin:R(e.stillSharpnessMin,0,10)??t.stillSharpnessMin,stillRefusalsMax:R(e.stillRefusalsMax,0,10)??t.stillRefusalsMax,focusFarFillFrac:R(e.focusFarFillFrac,0,1)??t.focusFarFillFrac,noDocFarHintMs:R(e.noDocFarHintMs,0,6e4)??t.noDocFarHintMs,zoomFallbackMs:R(e.zoomFallbackMs,0,12e4)??t.zoomFallbackMs}}n(Ri,"Si");var mt="sekyro.doc.camera";function Je(){try{let s=globalThis.localStorage?.getItem(mt);return typeof s=="string"&&s!==""?s:null}catch{return null}}n(Je,"ii");function oe(s){try{s===null?globalThis.localStorage?.removeItem(mt):globalThis.localStorage?.setItem(mt,s)}catch{}}n(oe,"we");var gt=n((s,t)=>Array.isArray(s?.focusMode)&&s.focusMode.includes(t),"rt");function re(s,t,e){if(!gt(s,"single-shot"))return null;let i=n(a=>Math.min(1,Math.max(0,Number.isFinite(a)?a:.5)),"o");return{focusMode:"single-shot",pointsOfInterest:[{x:i(t),y:i(e)}]}}n(re,"Mt");function $e(s,t,e,i=yt){let a=s?.zoom?.min,h=s?.zoom?.max;if(typeof h!="number"||h<=1)return 1;let o=e==="ID-3"?i.fillDistanceM.id3:i.fillDistanceM.id1,l=s?.focusDistance?.min,r;if(typeof l=="number"&&l>0&&l<1){if(r=l*(1+i.focusMarginFrac)/o,r<=1.05)return 1}else{if(Math.min(t.width,t.height)<i.zoomMinSourcePx)return 1;r=i.zoomNoFocusInfo}let c=Math.min(r,i.zoomMax,h);typeof a=="number"&&(c=Math.max(c,a));let u=s?.zoom?.step;return typeof u=="number"&&u>0&&(c=Math.round(c/u)*u),c>1.01?Number(c.toFixed(2)):1}n($e,"Se");function pt(s){try{return s.getVideoTracks?.()[0]}catch{return}}n(pt,"yt");function le(s){if(s!==null)for(let t of s.getTracks())t.stop()}n(le,"ve");function ti(s){try{let t=pt(s)?.getCapabilities?.();return!Array.isArray(t?.focusMode)||t.focusMode.includes("continuous")}catch{return!0}}n(ti,"oi");async function ei(s){let t=n(h=>({audio:!1,video:{...h,width:{ideal:s.base.width},height:{ideal:s.base.height}}}),"t"),e=n(h=>s.getUserMedia(t({deviceId:{exact:h}})),"e"),i=n(()=>s.getUserMedia(t({facingMode:{ideal:"environment"}})),"o");if(s.lensSelection){let h=Je();if(h!==null)try{return{stream:await e(h),lens:"stored"}}catch{oe(null)}}let a=await i();if(!s.lensSelection||s.enumerateDevices===void 0)return{stream:a,lens:"default"};try{let h=Bt(await s.enumerateDevices()).slice(0,3);if(h.length===0)return{stream:a,lens:"default"};let o=null;for(let l of h){let r=a!==null?pt(a)?.getSettings?.().deviceId:void 0;if(a===null||r!==l){le(a),a=null;try{a=await e(l)}catch{continue}}if(o??(o=l),ti(a))return oe(l),{stream:a,lens:"selected"}}if(a!==null&&o!==null&&pt(a)?.getSettings?.().deviceId===o)return{stream:a,lens:"selected"};if(le(a),a=null,o!==null)try{return{stream:await e(o),lens:"selected"}}catch{}return{stream:await i(),lens:"default"}}catch{return{stream:a??await i(),lens:"default"}}}n(ei,"Te");var ht=Object.freeze({brightness:0,glare:0,cardGlare:0,sharpness:0,fill:0,shape:0,content:0,offsetX:0,offsetY:0,edgeConfidence:0,box:null}),A=n(s=>Math.min(1,Math.max(0,s)),"L");function ii(s,t,e,i=.06){let a=Math.max(s.width/e,s.height),h=a*e,o=(s.width-h)/2,l=(s.height-a)/2,r=A((t.x-t.width*i-o)/h),c=A((t.y-t.height*i-l)/a),u=A((t.x+t.width*(1+i)-o)/h),f=A((t.y+t.height*(1+i)-l)/a);return{x:r,y:c,width:u-r,height:f-c}}n(ii,"Re");function si(s,t,e={}){let i=e.edgePeakFrac??0,{width:a,height:h,data:o}=s;if(a<=0||h<=0)return ht;let l=A(t.x),r=A(t.y),c={x:l,y:r,width:Math.max(0,A(t.x+t.width)-l),height:Math.max(0,A(t.y+t.height)-r)};if(c.width<=0||c.height<=0)return ht;let u=c.x*a,f=c.y*h,d=(c.x+c.width)*a,m=(c.y+c.height)*h,g=(d-u)*.15,b=(m-f)*.15,w=n((p,M,_)=>Math.min(_,Math.max(M,p)),"y"),k=w(Math.floor(u-g),0,a-1),S=w(Math.floor(f-b),0,h-1),D=w(Math.ceil(d+g),k+1,a),I=w(Math.ceil(m+b),S+1,h),F=Math.max(1,Math.ceil(Math.max(D-k,I-S)/320)),y=Math.floor((D-k+F-1)/F),x=Math.floor((I-S+F-1)/F);if(y<3||x<3)return ht;let v=new Int32Array(y*x);for(let p=0;p<x;p++){let M=S+p*F;for(let _=0;_<y;_++){let T=(M*a+k+_*F)*4;v[p*y+_]=(o[T]??0)*77+(o[T+1]??0)*150+(o[T+2]??0)*29>>8}}let L=n((p,M)=>(p-M-.5)/F,"C"),B=L(u,k),rt=L(d,k),lt=L(f,S),nt=L(m,S),wt=(d-u)/F,bt=(m-f)/F,kt=w(Math.ceil(B),0,y-1),we=w(Math.floor(rt),kt,y-1),xt=w(Math.ceil(lt),0,x-1),be=w(Math.floor(nt),xt,x-1),vt=0,St=0,H=0,Ft=0,Rt=0,Q=0;for(let p=xt;p<=be;p++)for(let M=kt;M<=we;M++){let _=v[p*y+M];if(vt+=_,_>=248&&St++,H++,M>=1&&M<y-1&&p>=1&&p<x-1){let T=v[p*y+M-1]+v[p*y+M+1]+v[(p-1)*y+M]+v[(p+1)*y+M]-4*_;Ft+=T,Rt+=T*T,Q++}}let ke=H>0?vt/H:0,_t=H>0?St/H:0,Dt=Q>0?Ft/Q:0,xe=Q>0?Math.max(0,Rt/Q-Dt*Dt):0,X=new Float64Array(y),U=new Float64Array(x);for(let p=0;p<x;p++)for(let M=1;M<y-1;M++)X[M]=X[M]+Math.abs(v[p*y+M+1]-v[p*y+M-1]);for(let p=1;p<x-1;p++)for(let M=0;M<y;M++)U[p]=U[p]+Math.abs(v[(p+1)*y+M]-v[(p-1)*y+M]);let O=st(X,!0,B,i),E=st(X,!1,rt,i),P=st(U,!0,lt,i),W=st(U,!1,nt,i),Tt=(E.position-O.position)/wt,At=(W.position-P.position)/bt,ve=At>0?Tt/At:0,Se=((O.position+E.position)/2-(B+rt)/2)/wt,Fe=((P.position+W.position)/2-(lt+nt)/2)/bt,zt=ne(X),Ct=ne(U),Re=zt<=0||Ct<=0?0:Math.min(Math.min(O.value,E.value)/zt,Math.min(P.value,W.value)/Ct),J=n((p,M)=>M+(p+.5)*F,"$"),It=_t,Lt=0;{let p=(E.position-O.position)*.06,M=(W.position-P.position)*.06,_=w(Math.ceil(O.position+p),0,y-1),T=w(Math.floor(E.position-p),0,y-1),_e=w(Math.ceil(P.position+M),0,x-1),Ot=w(Math.floor(W.position-M),0,x-1),Et=0,$=0,Pt=0;for(let N=_e;N<=Ot;N++)for(let q=_;q<=T;q++){$++;let K=v[N*y+q];K>=248&&Et++;let De=q+2<=T?v[N*y+q+2]:K,Te=N+2<=Ot?v[(N+2)*y+q]:K;(Math.abs(De-K)>=24||Math.abs(Te-K)>=24)&&Pt++}$>=16&&(It=Et/$,Lt=Pt/$)}return{brightness:ke,glare:_t,cardGlare:It,sharpness:xe,fill:Tt,shape:ve,content:Lt,offsetX:Se,offsetY:Fe,edgeConfidence:Re,box:{left:J(O.position,k),right:J(E.position,k),top:J(P.position,S),bottom:J(W.position,S)}}}n(si,"Fe");function st(s,t,e,i){let a=s.length,h=Math.max(1,Math.floor(a*.45)),o=t?1:Math.max(1,a-1-h),l=t?Math.min(a-2,h):a-2,r=o;for(let m=o;m<=l;m++)s[m]>s[r]&&(r=m);if(i>0&&i<1){let m=s[r]*i,g=r,b=Math.abs(r-e);for(let w=o;w<=l;w++){let k=s[w];if(k<m||k<(s[w-1]??0)||k<(s[w+1]??0))continue;let S=Math.abs(w-e);S<b&&(g=w,b=S)}r=g}let c=r>0?s[r-1]:0,u=s[r],f=r<a-1?s[r+1]:0,d=c+u+f;return{position:d>0?r+(f-c)/d:r,value:u}}n(st,"at");function ne(s){if(s.length<3)return 0;let t=0;for(let e=1;e<s.length-1;e++)t+=s[e];return t/(s.length-2)}n(ne,"_e");function ai(s){let t=s.box;return t===null||t.right-t.left<4||t.bottom-t.top<4?null:{topLeft:{x:t.left,y:t.top},topRight:{x:t.right,y:t.top},bottomRight:{x:t.right,y:t.bottom},bottomLeft:{x:t.left,y:t.bottom}}}n(ai,"Ce");var ot=Object.freeze({fillMin:.82,fillMax:1.06,offsetMax:.06,glareMax:.025,sharpnessMin:180,edgeConfidenceMin:1.6,darkBrightness:70,lockMs:450,steadyMs:900,steadyFillMin:.45,steadyFillMax:1.3,steadyFillDelta:.06,steadyOffsetDelta:.04,steadyRefMs:100,edgePeakFrac:.4,shapeTolerance:.2,contentMin:.1});function _i(s){let t=s!==null&&typeof s=="object"?s:{},e={...ot};for(let i of Object.keys(ot)){let a=t[i];typeof a=="number"&&Number.isFinite(a)&&a>=0&&a<=1e6&&(e[i]=a)}return e}n(_i,"Ai");var j,hi=(j=class{constructor(t=ot){this.t=t,this.goodSince=null,this.steadySince=null,this.last=null}reset(){this.goodSince=null,this.steadySince=null,this.last=null}tick(t,e){let i=this.t,a=i.shapeTolerance<=0||Math.abs(t.shape-1)<=i.shapeTolerance,h=t.edgeConfidence>=i.edgeConfidenceMin&&a&&t.content>=i.contentMin,o=t.fill>=i.fillMin&&t.fill<=i.fillMax,l=Math.abs(t.offsetX)<=i.offsetMax&&Math.abs(t.offsetY)<=i.offsetMax,r=t.cardGlare<=i.glareMax,c=t.sharpness>=i.sharpnessMin,u=this.last;this.last={fill:t.fill,offsetX:t.offsetX,offsetY:t.offsetY,at:e};let f=u!==null&&i.steadyRefMs>0?Math.min(3,Math.max(1,(e-u.at)/i.steadyRefMs)):1,d=h&&r&&c&&t.fill>=i.steadyFillMin&&t.fill<=i.steadyFillMax&&u!==null&&Math.abs(t.fill-u.fill)<=i.steadyFillDelta*f&&Math.abs(t.offsetX-u.offsetX)<=i.steadyOffsetDelta*f&&Math.abs(t.offsetY-u.offsetY)<=i.steadyOffsetDelta*f,m=h&&o&&l&&r&&c,g;if(h?r?t.fill<i.fillMin?g="too_small":t.fill>i.fillMax?g="too_big":c?l?g="locking":g="off_center":g="blurry":g="glare":g="no_card",m){if(d&&(this.steadySince??(this.steadySince=e)),this.goodSince??(this.goodSince=e),e-this.goodSince>=i.lockMs)return{detected:h,ready:!0,via:"good",blocker:"locking"};let b=this.steadySince!==null&&e-this.steadySince>=i.steadyMs;return{detected:h,ready:b,via:b?"steady":null,blocker:"locking"}}if(this.goodSince=null,d){this.steadySince??(this.steadySince=e);let b=e-this.steadySince>=i.steadyMs;return{detected:h,ready:b,via:b?"steady":null,blocker:b?"locking":"steadying"}}return this.steadySince=null,{detected:h,ready:!1,via:null,blocker:g}}},n(j,"ct"),j),Z=null;async function oi(s){return Z===null&&(Z=(await import("./detector-scanic-F3Y5X3DF-FGVR4NEM.js")).detectQuad),Z(s)}n(oi,"ni");async function ri(s){let t=Jt(s);return t===null?null:{topLeft:{x:t.x,y:t.y},topRight:{x:t.x+t.width,y:t.y},bottomRight:{x:t.x+t.width,y:t.y+t.height},bottomLeft:{x:t.x,y:t.y+t.height}}}n(ri,"si");function Di(){Z===null&&import("./detector-scanic-F3Y5X3DF-FGVR4NEM.js").then(s=>{Z=s.detectQuad}).catch(()=>{})}n(Di,"ji");var ce=4e3,li=2,ue=3,ni=Object.freeze({LOW:3,MID:5,HIGH:6}),Mt=Object.freeze({manualShutterMs:6e3,detectedNoLockMs:1950});function Ti(s){let t=s!==null&&typeof s=="object"?s:{},e=n((i,a,h)=>typeof i=="number"&&Number.isFinite(i)&&i>=a&&i<=h?i:void 0,"e");return{manualShutterMs:e(t.manualShutterMs,1e3,6e4)??Mt.manualShutterMs,detectedNoLockMs:e(t.steadyMs,300,3e4)!==void 0?t.steadyMs+(e(t.lockMs,0,1e4)??450):Mt.detectedNoLockMs}}n(Ti,"Yi");var z,Ai=(z=class{constructor(t){this.torchOn=!1,this.stillRefusals=0,this.zoom=1,this.positioningSince=null,this.detectedSince=null,this.lastSeenAt=null,this.lastGuideQuad=null,this.lastOcrReady=null,this.shutterOffered=!1,this.stats=z.freshStats(),this.handlers=new Map,this.stream=null,this.timer=null,this.state="idle",this.lastGuidance=null,this.attempt=0,this.capturing=!1,this.feedback=new ze,this.lastFeedbackKey=null,this.lastQuad=null,this.lastDetect=null,this.frameWatch=null,this.reopened=!1,this.lit=!1,this.blackTicks=0,this.offEnded=null,this.opts=t,this.gate=new ee(t.format??"ID-1",t.thresholds);let e=t.deviceClass??Qt(Ht());this.deviceClass=e,this.camera=t.camera??yt,this.shutterTuning=t.shutter??Mt,this.guideTuning=t.guideLock??ot,this.guideLock=new hi(this.guideTuning),this.cadenceMs=1e3/ni[e]}on(t,e){let i=this.handlers.get(t);return i||(i=new Set,this.handlers.set(t,i)),i.add(e),()=>i?.delete(e)}emit(t,e){for(let i of[...this.handlers.get(t)??[]])i(e)}async start(){let t=this.state==="error"?this.resumePlayback():null,e=++this.attempt;if(this.clearFrameWatch(),this.gate.reset(),this.resetSide(),this.feedback.reset(),this.lastFeedbackKey=null,this.lastGuidance=null,this.capturing=!1,this.lit=!1,this.blackTicks=0,t!==null&&await t&&e===this.attempt){this.setState("positioning"),this.scheduleTick(e),this.watchFrames(e);return}if(e===this.attempt){this.releaseStream(),jt(),this.setState("preflight");try{let i=this.opts.getUserMedia??(o=>navigator.mediaDevices.getUserMedia(o));this.setState("acquiring");let a=this.opts.enumerateDevices??(this.opts.getUserMedia===void 0&&typeof navigator<"u"&&navigator.mediaDevices?.enumerateDevices?()=>navigator.mediaDevices.enumerateDevices():void 0),h=await ei({getUserMedia:i,...a!==void 0?{enumerateDevices:a}:{},lensSelection:this.camera.lensSelection,base:Ee});if(e!==this.attempt){for(let o of h.stream.getTracks())o.stop();return}if(this.stream=h.stream,Wt(this.stream),Gt(this.stream),this.watchEnded(e),this.opts.upgradeResolution!==!1&&await this.upgradeResolution(),e!==this.attempt||(await this.applyFocusAndZoom(),e!==this.attempt)||(this.opts.video.srcObject=this.stream,await this.opts.video.play().catch(()=>{}),e!==this.attempt))return;this.setState("positioning"),this.scheduleTick(e),this.watchFrames(e)}catch(i){if(e!==this.attempt)return;let a=qt(i),h=Nt(i);this.setState("error"),this.emit("error",{kind:a,retryable:!0,detail:h===void 0?{phase:"acquiring"}:{phase:"acquiring",name:h}})}}}resumePlayback(){let t=this.opts.video,e=this.videoTrack();if(this.stream===null||e===null||e.readyState!=="live"||t.srcObject!==this.stream)return null;try{return Promise.resolve(t.play()).then(()=>this.framesNow(),()=>!1)}catch{return null}}framesNow(){let t=this.opts.video;return this.opts.hasFrames!==void 0?this.opts.hasFrames(t):!t.paused&&t.readyState>=2&&t.videoWidth>0}watchFrames(t){let e=this.opts.firstFrameMs??ce;e<=0||(this.clearFrameWatch(),this.frameWatch=setTimeout(()=>{if(this.frameWatch=null,!(t!==this.attempt||this.state!=="positioning")){if(this.framesNow()&&this.blackTicks<ue){this.reopened=!1;return}this.cameraDead(t)}},e))}clearFrameWatch(){this.frameWatch!==null&&clearTimeout(this.frameWatch),this.frameWatch=null}watchEnded(t){this.offEnded?.(),this.offEnded=null;let e=this.videoTrack();if(e===null||typeof e.addEventListener!="function")return;let i=n(()=>{t===this.attempt&&(this.state==="positioning"||this.state==="acquiring")&&this.cameraDead(t)},"o");e.addEventListener("ended",i),this.offEnded=()=>e.removeEventListener?.("ended",i)}cameraDead(t){if(t!==this.attempt)return;let e=this.videoTrack(),i=e!==null&&e.readyState==="live"&&!e.muted&&this.opts.video.paused&&!this.framesNow();if(!i&&!this.reopened){this.reopened=!0,this.start();return}this.attempt+=1,this.timer!==null&&(this.opts.clearTimer??clearTimeout)(this.timer),this.timer=null,this.clearFrameWatch(),i||this.releaseStream(),this.reopened=!1,this.setState("error"),this.emit("error",{kind:"generic",retryable:!0,detail:{phase:"acquiring"}})}releaseStream(){if(this.offEnded?.(),this.offEnded=null,this.stream)for(let t of this.stream.getTracks())t.stop();this.stream=null,this.opts.video.srcObject!==null&&this.opts.video.srcObject!==void 0&&(this.opts.video.srcObject=null)}rearm(t){t!==void 0&&(this.opts.side=t),this.gate.reset(),this.resetSide(),this.feedback.reset(),this.lastFeedbackKey=null,this.lastGuidance=null,this.capturing=!1,this.stillRefusals=0,this.state==="captured"&&(this.setState("positioning"),this.scheduleTick(this.attempt))}async captureNow(){if(this.state!=="positioning"||this.capturing)return;let t=this.opts.video,e=this.lastDetect?.width??Math.max(1,t.videoWidth),i=this.lastDetect?.height??Math.max(1,t.videoHeight),a=this.lastQuad??this.lastGuideQuad??{topLeft:{x:0,y:0},topRight:{x:e,y:0},bottomRight:{x:e,y:i},bottomLeft:{x:0,y:i}},h=(this.opts.now??(()=>performance.now()))(),o=this.feedback.force("processing",h);this.lastFeedbackKey=o.key,this.emit("feedback",o),await this.fire(this.attempt,this.lastOcrReady!==null?this.lastOcrReady.quad:a,{width:e,height:i,tickSharpness:this.lastDetect?.tickSharpness??0},this.lastOcrReady?.via??"manual")}captureReport(){let t=this.stats;return{...this.opts.side!==void 0?{side:this.opts.side}:{},format:this.opts.format??"ID-1",deviceClass:this.deviceClass,video:{width:this.opts.video.videoWidth||0,height:this.opts.video.videoHeight||0},zoom:this.zoom,...t.zoomFallbackAtMs!==void 0?{zoomFallbackAtMs:t.zoomFallbackAtMs}:{},...t.msToCapture!==void 0?{msToCapture:t.msToCapture}:{},...t.via!==void 0?{via:t.via}:{},...t.shutterAtMs!==void 0?{shutterAtMs:t.shutterAtMs}:{},...t.shutterReason!==void 0?{shutterReason:t.shutterReason}:{},ticks:t.ticks,quadFraming:{...t.quadFraming},qualityBlockers:{...t.qualityBlockers},guideBlockers:{...t.guideBlockers},stillRefusals:t.stillRefusals,...this.ocrReport()}}ocrReport(){let t=this.opts.ocr;if(t===void 0)return{};let e=(this.opts.format??"ID-1")==="ID-3"||this.opts.side==="single"?"single":this.opts.side==="verso"?"verso":"recto",i=t.report(e,this.stats.via,(this.opts.now??(()=>performance.now()))());return i===null?{}:{ocr:i}}static freshStats(){return{ticks:0,quadFraming:{},qualityBlockers:{},guideBlockers:{},stillRefusals:0}}setGuide(t){t===void 0?delete this.opts.guide:this.opts.guide=t,this.guideLock.reset()}guideRegion(t){let e=t.width/Math.max(1,t.height),i=this.opts.guide;if(i!==void 0&&i.viewAspect>0){let l={width:i.viewAspect,height:1},r={x:i.rect.x*i.viewAspect,y:i.rect.y,width:i.rect.width*i.viewAspect,height:i.rect.height};return ii(l,r,e,0)}let a=Vt(this.opts.format??"ID-1").center,h=.86,o=h*e/a;return o>.84&&(o=.84,h=o*a/e),{x:(1-h)/2,y:(1-o)/2,width:h,height:o}}resetSide(){this.positioningSince=null,this.detectedSince=null,this.lastSeenAt=null,this.guideLock.reset(),this.lastGuideQuad=null,this.lastOcrReady=null,this.opts.ocr?.reset(),this.stats=z.freshStats(),this.shutterOffered&&(this.shutterOffered=!1,this.emit("shutter",{available:!1}))}withdrawShutter(){this.shutterOffered&&(this.shutterOffered=!1,this.emit("shutter",{available:!1}))}zoomFallback(t){let e=this.videoTrack();if(e===null||this.zoom<=1)return;let i=this.focusCaps(),a=typeof i?.zoom?.min=="number"?Math.max(i.zoom.min,1):1;this.zoom=a,this.stats.zoomFallbackAtMs=Math.round(t-(this.positioningSince??t)),this.guideLock.reset(),this.gate.reset(),e.applyConstraints({advanced:[{zoom:a}]}).catch(()=>{})}offerShutter(t,e){this.shutterOffered||(this.shutterOffered=!0,this.stats.shutterAtMs=Math.round(e-(this.positioningSince??e)),this.stats.shutterReason=t,this.emit("shutter",{available:!0,reason:t}))}torchAvailable(){try{return this.stream?.getVideoTracks?.()[0]?.getCapabilities?.()?.torch===!0}catch{return!1}}async setTorch(t){this.torchOn=t;try{await this.stream?.getVideoTracks?.()[0]?.applyConstraints({advanced:[{torch:t}]})}catch{}}destroy(){if(this.attempt+=1,this.timer!==null&&(this.opts.clearTimer??clearTimeout)(this.timer),this.timer=null,this.clearFrameWatch(),this.offEnded?.(),this.offEnded=null,this.stream)for(let t of this.stream.getTracks())t.stop();this.stream=null,this.opts.video.srcObject=null}async upgradeResolution(){try{let t=this.stream?.getVideoTracks?.()[0];if(t===void 0)return;let e=t.getSettings?.()??{},i=Ge(t.getCapabilities?.(),{width:e.width??0,height:e.height??0},this.deviceClass,{width:this.camera.width,height:this.camera.height});i!==null&&await t.applyConstraints(i)}catch{}}focusCaps(){try{return this.videoTrack()?.getCapabilities?.()??null}catch{return null}}async applyFocusAndZoom(){let t=this.videoTrack();if(t===null)return;let e=this.focusCaps();this.camera.continuousFocus&&gt(e,"continuous")&&await t.applyConstraints({advanced:[{focusMode:"continuous"}]}).catch(()=>{});let i={width:0,height:0};try{let h=t.getSettings?.()??{};i={width:h.width??0,height:h.height??0}}catch{}let a=$e(e,i,this.opts.format??"ID-1",this.camera);if(a>1)try{await t.applyConstraints({advanced:[{zoom:a}]}),this.zoom=a}catch{this.zoom=1}}async focusAt(t,e){let i=this.videoTrack(),a=re(this.focusCaps(),t,e);if(!(i===null||a===null))try{await i.applyConstraints({advanced:[a]}),(this.opts.setTimer??setTimeout)(()=>{this.restoreContinuous()},1500)}catch{}}async restoreContinuous(){let t=this.videoTrack();t===null||!this.camera.continuousFocus||!gt(this.focusCaps(),"continuous")||await t.applyConstraints({advanced:[{focusMode:"continuous"}]}).catch(()=>{})}async refocusOn(t,e){let i=this.camera.refocusBeforePhotoMs,a=this.videoTrack();if(i<=0||a===null||e.width<=0||e.height<=0)return;let h=C(t),o=re(this.focusCaps(),(h.x+h.width/2)/e.width,(h.y+h.height/2)/e.height);if(o!==null)try{await a.applyConstraints({advanced:[o]});let l=this.opts.setTimer??setTimeout;await new Promise(r=>{l(()=>r(),i)})}catch{}}videoTrack(){try{return this.stream?.getVideoTracks?.()[0]??null}catch{return null}}async takeStill(t,e,i){if(this.opts.captureStill!==void 0)return this.opts.captureStill(this.opts.video,t,e);let a=this.opts.format??"ID-1",h=this.videoTrack();if(i&&this.opts.photoCapture!==!1&&this.deviceClass!=="LOW"&&!this.torchOn&&h!==null&&Ue(h)){await this.refocusOn(t,e);let o=await Ze(this.opts.video,t,e,a,{track:h,detect:this.detector(),detectWidth:tt});if(this.restoreContinuous(),o!==null)return o}return Ve(this.opts.video,t,e,a)}detector(){return this.opts.detect??((this.opts.format??"ID-1")==="ID-3"?ri:oi)}setState(t){this.state=t,this.emit("statechange",{state:t})}scheduleTick(t){let e=this.opts.setTimer??setTimeout;this.timer=e(()=>{this.tick(t)},this.cadenceMs)}async tick(t){if(t!==this.attempt||this.state!=="positioning"||this.capturing)return;let e=this.opts.now??(()=>performance.now()),i=this.opts.grabDetectFrame??fe,a=this.detector(),h=i(this.opts.video,tt);if(h===null){this.scheduleTick(t);return}if(!this.lit){if(ut(h)>li)this.lit=!0,this.blackTicks=0;else if(++this.blackTicks>=ue&&this.frameWatch===null&&(this.opts.firstFrameMs??ce)>0){this.cameraDead(t);return}}let o=null;try{o=await a(h)}catch{o=null}if(t!==this.attempt)return;let l=o!==null?at(h,o):h,r=e(),c={sharpness:Y(l),exposure:Xt(l),meanLuma:ut(l),specularFraction:Ie(l)},u=Oe({format:this.opts.format??"ID-1",quad:o,frameWidth:h.width,frameHeight:h.height,measures:c,...this.opts.thresholds!==void 0?{thresholds:this.opts.thresholds}:{}}),f=this.gate.tick({timestampMs:r,quad:o,quality:c,frameWidth:h.width,frameHeight:h.height}),d=(this.opts.format??"ID-1")!=="ID-3"?si(h,this.guideRegion(h),{edgePeakFrac:this.guideTuning.edgePeakFrac}):ht,m=this.guideLock.tick(d,r);this.lastGuideQuad=m.detected?ai(d):null;let g=this.capturing?null:this.ocrTick(h,o,d,m.detected,u,r);this.positioningSince??(this.positioningSince=r);let b=this.stats;if(b.ticks+=1,b.quadFraming[u.framing]=(b.quadFraming[u.framing]??0)+1,u.framing==="ok"&&!f.ready){let x=u.lighting!=="ok"?u.lighting:u.glare!=="ok"?"glare":u.blur!=="ok"?"blurry":"steadying";b.qualityBlockers[x]=(b.qualityBlockers[x]??0)+1}b.guideBlockers[m.blocker]=(b.guideBlockers[m.blocker]??0)+1,o!==null||m.detected?(this.detectedSince??(this.detectedSince=r),this.lastSeenAt=r):this.detectedSince=null,this.lastSeenAt!==null&&r-this.lastSeenAt<=pi?r-this.positioningSince>=this.shutterTuning.manualShutterMs?this.offerShutter("timeout",r):g?.suspendQuality!==!0&&this.detectedSince!==null&&r-this.detectedSince>=this.shutterTuning.detectedNoLockMs&&this.offerShutter("detected_no_lock",r):this.withdrawShutter();let w=r-(this.lastSeenAt??this.positioningSince);this.zoom>1&&this.camera.zoomFallbackMs>0&&w>=this.camera.zoomFallbackMs&&this.zoomFallback(r),this.emit("checks",{engine:"docv1",p:f.p,plausible:f.plausible,stableTicks:f.stableTicks,quad:f.quad,frameWidth:h.width,frameHeight:h.height,analysis:u,ready:g?.suspendQuality!==!0&&(f.ready&&o!==null||m.ready&&this.lastGuideQuad!==null)||this.lastOcrReady!==null,guide:{detected:m.detected,blocker:m.blocker,fill:d.fill,shape:d.shape,content:d.content,offsetX:d.offsetX,offsetY:d.offsetY},...g!==null&&g.mode!=="off"?{ocr:{mode:g.mode,...g.mrz?{mrz:g.mrz}:{},...g.lock?{lock:g.lock}:{}}}:g?.mrz?{ocr:{mode:g.mode,mrz:g.mrz}}:{}}),this.lastQuad=f.plausible?o:null,this.lastDetect={width:h.width,height:h.height,tickSharpness:c.sharpness};let k=Ae(u);u.framing!=="ok"&&m.detected&&(k=gi(m.blocker,d.brightness<this.guideTuning.darkBrightness)),k==="blurry"&&o!==null&&ui(o,h,this.opts.format??"ID-1")>=this.camera.focusFarFillFrac&&(k="focus_far"),k==="sensing"&&this.zoom>1&&this.camera.noDocFarHintMs>0&&w>=this.camera.noDocFarHintMs&&(k="focus_far");let S=this.feedback.tick(k,r);if(S.key!==this.lastFeedbackKey&&(this.lastFeedbackKey=S.key,this.emit("feedback",S)),f.guidanceKey!==this.lastGuidance&&(this.lastGuidance=f.guidanceKey,this.emit("guidance",{key:f.guidanceKey})),this.capturing)return;let D=g?.suspendQuality!==!0,I=D&&f.ready&&o!==null,F=D&&m.ready&&this.lastGuideQuad!==null,y=this.lastOcrReady;if(y!==null&&this.opts.autoCapture!==!1){let x=this.feedback.force("processing",r);this.lastFeedbackKey=x.key,this.emit("feedback",x);let v=Y(at(h,y.quad));await this.fire(t,y.quad,{width:h.width,height:h.height,tickSharpness:v},y.via);return}if((I||F)&&this.opts.autoCapture!==!1){let x=this.feedback.force("processing",r);this.lastFeedbackKey=x.key,this.emit("feedback",x);let v=F?this.lastGuideQuad:o,L=F?m.via==="steady"?"guide_steady":"guide_good":"quad",B=F?Y(at(h,v)):c.sharpness;await this.fire(t,v,{width:h.width,height:h.height,tickSharpness:B},L);return}this.scheduleTick(t)}async fire(t,e,i,a){this.capturing=!0;let h=this.opts.grabDetectFrame??fe,o=this.opts.setTimer??setTimeout,l={width:i.width,height:i.height};try{let r={still:await this.takeStill(e,l,!0),sharpness:i.tickSharpness};if(t!==this.attempt)return;let c=r.still.source==="photo"?0:di;for(let d=0;d<c;d++){if(await new Promise(b=>{o(()=>b(),fi)}),t!==this.attempt)return;let m=h(this.opts.video,tt);if(m===null)continue;let g=Y(at(m,e));if(g>r.sharpness*mi){let b=await this.takeStill(e,l,!1);if(t!==this.attempt)return;r={still:b,sharpness:g}}}if(t!==this.attempt)return;let u=r.still.sharpness;if(this.opts.autoCapture!==!1&&a!=="manual"&&typeof u=="number"&&u>=0&&u<this.camera.stillSharpnessMin&&this.stillRefusals<this.camera.stillRefusalsMax){this.stillRefusals+=1,this.stats.stillRefusals+=1,this.guideLock.reset(),this.lastOcrReady=null,(a==="text_lock"||a==="live_mrz")&&this.opts.ocr?.rearmFace();let d=(this.opts.now??(()=>performance.now()))(),m=this.feedback.force("focus_far",d);this.lastFeedbackKey=m.key,this.emit("feedback",m),this.capturing=!1,this.gate.reset(),this.scheduleTick(t);return}this.stillRefusals=0;let f=(this.opts.now??(()=>performance.now()))();this.stats.via=a,this.stats.msToCapture=Math.round(f-(this.positioningSince??f)),this.shutterOffered&&(this.shutterOffered=!1,this.emit("shutter",{available:!1})),this.setState("captured"),this.emit("artifacts",{keyframe:r.still.blob,previewDataUrl:r.still.previewDataUrl,...this.opts.side!==void 0?{side:this.opts.side}:{},...r.still.docRegion!==void 0?{docRegion:r.still.docRegion}:{},...(()=>{let d=a==="live_mrz"?this.opts.ocr?.liveCapture():null;return d?{liveMrz:d}:{}})()})}catch{if(t!==this.attempt)return;this.capturing=!1,this.gate.reset(),this.guideLock.reset(),this.lastOcrReady=null,(a==="text_lock"||a==="live_mrz")&&this.opts.ocr?.rearmFace(),this.scheduleTick(t)}}ocrTick(t,e,i,a,h,o){let l=this.opts.ocr,r=this.opts.video;if(l===void 0||!l.hasEngine)return this.lastOcrReady=null,null;let c=r.videoWidth,u=r.videoHeight;if(c<=0||u<=0||t.width<=0||t.height<=0)return null;let f=(this.opts.format??"ID-1")==="ID-3",d=this.guideRegion(t),m={x:d.x*c,y:d.y*u,w:d.width*c,h:d.height*u},g=c/t.width,b=u/t.height,w;f&&e!==null?w=ci(C(e),g,b,c,u):w=Yt(m,l.bandTop,u);let k=f?h.glare==="ok":i.cardGlare<=this.guideTuning.glareMax,S=f?h.blur==="ok":i.sharpness>=this.guideTuning.sharpnessMin,D=l.tick({atMs:o,video:r,mrzFace:f||this.opts.side==="verso"||this.opts.side==="single",present:f||e!==null||a,card:m,band:w,portrait:u>c,glareOk:k,sharpOk:S});if(D.ready&&D.via!==void 0){let I=f?e??de(d,t):this.lastGuideQuad??de(d,t);this.lastOcrReady={quad:I,via:D.via}}else this.lastOcrReady=null;return D}},n(z,"i"),z);function ci(s,t,e,i,a){let h=Math.min(i,s.width*1.06*t),o=Math.min(a,Math.max(s.height*1.6*e,h/5)),l=(s.y+s.height/2)*e,r=Math.max(0,Math.min(i-h,(s.x-s.width*.03)*t)),c=Math.max(0,Math.min(a-o,l-o/2));return{x:r,y:c,w:h,h:o}}n(ci,"ci");function de(s,t){let e=s.x*t.width,i=s.y*t.height,a=(s.x+s.width)*t.width,h=(s.y+s.height)*t.height;return{topLeft:{x:e,y:i},topRight:{x:a,y:i},bottomRight:{x:a,y:h},bottomLeft:{x:e,y:h}}}n(de,"Oe");function ui(s,t,e){let i=C(s);return t.width<=0||t.height<=0?0:e==="ID-3"?i.width/t.width:i.width*i.height/(t.width*t.height)}n(ui,"li");var di=2,fi=260,mi=1.08;function fe(s,t){let e=s.videoWidth,i=s.videoHeight;if(e===0||i===0)return null;let a=Math.min(1,t/e),h=Math.round(e*a),o=Math.round(i*a),l=document.createElement("canvas");l.width=h,l.height=o;let r=l.getContext("2d",{willReadFrequently:!0});return r===null?null:(e/Math.max(1,h)>4&&(r.imageSmoothingQuality="high"),r.drawImage(s,0,0,h,o),r.getImageData(0,0,h,o))}n(fe,"Pe");function at(s,t){let e=[t.topLeft.x,t.topRight.x,t.bottomRight.x,t.bottomLeft.x],i=[t.topLeft.y,t.topRight.y,t.bottomRight.y,t.bottomLeft.y],a=Math.max(0,Math.floor(Math.min(...e))),h=Math.max(0,Math.floor(Math.min(...i))),o=Math.min(s.width,Math.ceil(Math.max(...e))),l=Math.min(s.height,Math.ceil(Math.max(...i))),r=Math.max(1,o-a),c=Math.max(1,l-h),u=new Uint8ClampedArray(r*c*4);for(let f=0;f<c;f++){let d=((h+f)*s.width+a)*4;u.set(s.data.subarray(d,d+r*4),f*r*4)}return{data:u,width:r,height:c,colorSpace:s.colorSpace}}n(at,"lt");function gi(s,t){return s==="glare"?"glare":s==="too_small"?"too_far":s==="too_big"?"too_close":t?"too_dark":s==="blurry"?"blurry":s==="off_center"?"edge_clipped":s==="no_card"?"sensing":"hold_still"}n(gi,"mi");var pi=1200;export{Ri as a,_i as b,Di as c,ce as d,li as e,ue as f,ni as g,Mt as h,Ti as i,Ai as j,ci as k,di as l,fi as m};
@@ -0,0 +1 @@
1
+ import{a as g}from"./chunk-CYGAKCKG.js";import{K as b,a as k,b as y,c as x}from"./chunk-YWPZG2MZ.js";import{a as n}from"./chunk-RK4HVNRS.js";import{a as c,c as f}from"./chunk-4FHWXBOB.js";var l=f(k(),1),t=f(k(),1),w=f(k(),1),r=f(y(),1),e=f(y(),1);var i,C=(i=class extends w.Component{constructor(){super(...arguments),this.state={failed:!1}}static getDerivedStateFromError(){return{failed:!0}}render(){return this.state.failed?this.props.fallback:this.props.children}},c(i,"c"),i);n(C,"LoadBoundary");var j=C,F={load:n(()=>import("./flow-views-5L7JF3MM-M6C3RXSX.js"),"load")};function S({view:s,i18n:a,quiet:o,...m}){let[d,h]=(0,t.useState)(0),u=(0,t.useMemo)(()=>(0,t.lazy)(()=>F.load().then(v=>({default:v[s]}))),[s,d]),p=(0,r.jsxs)(b,{tone:"danger",children:[(0,r.jsx)("span",{children:a.t("errors.network_error")}),(0,r.jsx)(x,{kind:"secondary",onClick:c(()=>h(v=>v+1),"onClick"),children:a.t("common.retry")})]});return(0,r.jsx)(j,{fallback:p,children:(0,r.jsx)(t.Suspense,{fallback:o===!0?null:(0,r.jsx)("p",{role:"status","aria-busy":"true",className:"sekyro-text-muted",children:a.t("common.loading")}),children:(0,r.jsx)(u,{...m,i18n:a})})},d)}c(S,"k");n(S,"Flow");var B=(0,l.createContext)(void 0);function H({i18n:s,lead:a,refresh:o,actions:m}){let d=(0,l.useContext)(B),[h,u]=(0,l.useState)(!1);if(d!==void 0)return(0,e.jsx)(S,{view:"HandoffView",i18n:s,url:d,lead:a,...o!==void 0?{refresh:o}:{},footer:m});let p=n(()=>{o!==void 0&&(u(!0),o().catch(()=>{}).finally(()=>u(!1)))},"again");return(0,e.jsx)(g,{tone:"brand",icon:"smartphone",title:s.t("handoff.title"),testId:"sekyro-phone-handoff",actions:(0,e.jsxs)(e.Fragment,{children:[m,o!==void 0?(0,e.jsx)(x,{kind:"secondary",full:!0,disabled:h,onClick:p,children:s.t("common.refresh")}):null]}),children:(0,e.jsx)("p",{children:a})})}c(H,"K");n(H,"PhoneHandoff");export{j as a,S as b,B as c,H as d};
@@ -0,0 +1 @@
1
+ import{d as U}from"./chunk-36WGD7QV.js";import{E as C,I as H,a as Z,b as E,v as B}from"./chunk-YWPZG2MZ.js";import{a as d}from"./chunk-RK4HVNRS.js";import{a as N,c as R}from"./chunk-4FHWXBOB.js";var y=R(Z(),1),s=R(E(),1);var b=72;function P(c,t){let r=c*.72,a=r*1.32;return{cx:c/2,cy:(t-a)/2.1+a/2,a:r/2,b:a/2}}N(P,"B");d(P,"faceOval");function z({cx:c,cy:t,a:r,b:a}){return Array.from({length:b},(j,M)=>{let m=-Math.PI/2+M/b*2*Math.PI,h=Math.cos(m),i=Math.sin(m),u=c+r*h,f=t+a*i,k=Math.hypot(a*h,r*i),p=a*h/k,$=r*i/k,o=d(v=>Math.round(v*10)/10,"r");return`M${o(u+p*16)} ${o(f+$*16)}L${o(u+p*28)} ${o(f+$*28)}`})}N(z,"E");d(z,"ticks");function F({video:c,instruction:t,note:r,status:a,busy:j,progress:M,still:m,overlay:h,ramp:i,onClose:u,closeLabel:f,end:k,live:p=!0,children:$,testId:o}){C(p);let v=(0,y.useRef)(null),[l,A]=(0,y.useState)({w:0,h:0});(0,y.useLayoutEffect)(()=>{let x=v.current;if(x===null)return;let I=d(()=>A({w:x.clientWidth,h:x.clientHeight}),"measure");if(I(),typeof ResizeObserver>"u")return;let L=new ResizeObserver(I);return L.observe(x),()=>L.disconnect()},[]);let e=P(l.w,l.h),g=l.w>0?z(e):[],w=Math.round(Math.min(1,Math.max(0,M))*b),S=e.cy-e.b,n=Math.max(e.a,e.b)+40,O=70*Math.PI/180;return(0,s.jsx)("section",{className:"sekyro-lm sekyro-fc","aria-label":t,"data-testid":o,"data-ramp":i?"":void 0,children:(0,s.jsxs)("div",{ref:v,className:"sekyro-lm-stage",children:[c,m?(0,s.jsx)("img",{className:"sekyro-lm-video sekyro-fc-still",src:m,alt:""}):null,h,(0,s.jsx)(U,{colour:i??null}),l.w>0?(0,s.jsxs)("svg",{className:"sekyro-lm-overlay",viewBox:`0 0 ${l.w} ${l.h}`,"aria-hidden":"true",focusable:"false",children:[(0,s.jsxs)("defs",{children:[(0,s.jsxs)("linearGradient",{id:"sekyro-fc-fade",gradientUnits:"userSpaceOnUse",x1:e.cx-n*Math.sin(O),y1:e.cy,x2:e.cx,y2:e.cy,children:[(0,s.jsx)("stop",{offset:"0",className:"sekyro-fc-fade",stopOpacity:"0"}),(0,s.jsx)("stop",{offset:"1",className:"sekyro-fc-fade"})]}),(0,s.jsx)("mask",{id:"sekyro-fc-light",maskUnits:"userSpaceOnUse",x:"0",y:"0",width:l.w,height:l.h,children:(0,s.jsx)("path",{className:"sekyro-fc-sweep",style:{transformOrigin:`${e.cx}px ${e.cy}px`},d:`M${e.cx} ${e.cy}L${e.cx-n*Math.sin(O)} ${e.cy-n*Math.cos(O)}A${n} ${n} 0 0 1 ${e.cx} ${e.cy-n}Z`,fill:"url(#sekyro-fc-fade)"})})]}),(0,s.jsx)("path",{className:"sekyro-fc-scrim",fillRule:"evenodd",d:`M0 0H${l.w}V${l.h}H0Z M${e.cx-e.a} ${e.cy}a${e.a} ${e.b} 0 1 0 ${2*e.a} 0a${e.a} ${e.b} 0 1 0 ${-2*e.a} 0Z`}),(0,s.jsx)("ellipse",{className:"sekyro-fc-rim",cx:e.cx,cy:e.cy,rx:e.a,ry:e.b}),(0,s.jsx)("path",{className:"sekyro-fc-ticks",d:g.join("")}),w>0?(0,s.jsx)("path",{className:"sekyro-fc-ticks is-done",d:g.slice(0,w).join("")}):null,w<b?(0,s.jsx)("path",{className:"sekyro-fc-ticks is-light",d:g.join(""),mask:"url(#sekyro-fc-light)"}):null]}):null,(0,s.jsx)("div",{className:"sekyro-lm-instruction sekyro-fc-instruction",style:{insetBlockStart:S-80},children:(0,s.jsx)("div",{role:"status","aria-live":"polite",children:(0,s.jsx)(H,{swapKey:t,className:"sekyro-lm-line",children:t})})}),a!==void 0?(0,s.jsx)("p",{role:"status",className:"sekyro-visually-hidden","data-testid":"sekyro-camera-status",children:a??""}):null,r?(0,s.jsxs)("p",{className:"sekyro-lm-under sekyro-lm-note",style:{insetBlockStart:S+2*e.b+48},children:[j?(0,s.jsx)("span",{className:"sekyro-lm-spinner","aria-hidden":"true"}):null,(0,s.jsx)("span",{children:r})]}):null,(0,s.jsxs)("div",{className:"sekyro-lm-controls",children:[(0,s.jsxs)("div",{className:"sekyro-lm-bar",children:[u!==void 0?(0,s.jsx)("button",{type:"button",className:"sekyro-glass","aria-label":f,onClick:u,children:(0,s.jsx)(B,{name:"close"})}):null,k]}),$]})]})})}N(F,"T");d(F,"FaceCamera");export{F as a};
@@ -0,0 +1 @@
1
+ import{a as ee,b as he,c as fe,d as ge,f as ve}from"./chunk-SK6UAYX2.js";import{c as ye}from"./chunk-CMS5FVGM.js";import{e as Y}from"./chunk-ZKLSZJFN.js";import{e as pe,j as me}from"./chunk-D334IAZJ.js";import{g as X}from"./chunk-RRLXNT33.js";import{a as n}from"./chunk-4FHWXBOB.js";var We={low:{maxLongEdge:1920,payloadTargetBytes:7e5,qMin:.7,qMax:.92},mid:{maxLongEdge:2240,payloadTargetBytes:12e5,qMin:.7,qMax:.92},good:{maxLongEdge:2560,payloadTargetBytes:16e5,qMin:.7,qMax:.92}};function qe(e){let{deviceMemory:t,effectiveType:r,saveData:i,downlinkMbps:l,sourceLongEdge:u}=e,s=i===!0||r==="slow-2g"||r==="2g"||l!=null&&l>0&&l<1,d=t!=null&&t<=2,c=r==="4g"||l!=null&&l>=5,v=t!=null&&t>=6,f;s||d?f="low":c&&v?f="good":f="mid";let y=We[f],M=u&&u>0?Math.min(y.maxLongEdge,u):y.maxLongEdge;return{tier:f,...y,maxLongEdge:M}}n(qe,"He");function Fe(e){let t={};try{let r=navigator;typeof r.deviceMemory=="number"&&(t.deviceMemory=r.deviceMemory);let i=r.connection;i&&(t.effectiveType=i.effectiveType,t.saveData=i.saveData,t.downlinkMbps=i.downlink)}catch{}return typeof e=="number"&&e>0&&(t.sourceLongEdge=e),qe(t)}n(Fe,"ke");function Ie(e,t,r){let i=Math.min(1,Math.max(0,(e-.28)/.21999999999999997)),l=(t+r)/2;return Math.max(t,r-i*(r-l))}n(Ie,"Xe");function Be(e,t,r){let i=Math.max(e,t),l=i>0?Math.min(1,r/i):1;return{width:Math.max(1,Math.round(e*l)),height:Math.max(1,Math.round(t*l))}}n(Be,"Ve");async function ze(e,t){let r=t.startQ,i=await e(r);for(let l=0;l<4&&!(i.size<=t.budgetBytes||r<=t.qMin);l++)r=Math.max(t.qMin,r-.08),i=await e(r);return{blob:i,quality:r}}n(ze,"Ye");async function Oe(e,t,r,i,l){if(t<=0||r<=0)return null;let{width:u,height:s}=Be(t,r,i.maxLongEdge),d=document.createElement("canvas");d.width=u,d.height=s;let c=d.getContext("2d");if(!c)return null;c.drawImage(e,0,0,u,s);let v=n(F=>new Promise((g,m)=>{d.toBlob(h=>h?g(h):m(new Error("canvas toBlob returned null")),"image/jpeg",F)}),"f"),f=Ie(l,i.qMin,i.qMax),{blob:y,quality:M}=await ze(v,{startQ:f,qMin:i.qMin,budgetBytes:i.payloadTargetBytes}).finally(()=>{d.width=0,d.height=0});if(y.size>5242880)throw new Error("encoded document exceeds the 5242880-byte media cap");return{blob:y,quality:M,width:u,height:s}}n(Oe,"De");async function Ue(e){let t=Fe(Math.max(e.width,e.height)),r=await Oe(e,e.width,e.height,t,.5);if(r===null)throw new Error("canvas encode unavailable");return{blob:r.blob,width:r.width,height:r.height}}n(Ue,"Z");function xe(e,t){return{layout:e,phase:"framing",captured:{},pending:[],lastCaptureAt:t,lastReportAt:t,manualShutter:!1,restPhase:"framing",readSides:[],needFlip:!1,flipped:!1,flipTimeoutSpent:!1,timeoutCapture:!1,lastShotByTimeout:!1}}n(xe,"te");var Te=n(e=>e==="recto"?"verso":"recto","Ce"),Ce=n(e=>e.phase==="framing"||e.phase==="locking"||e.phase==="flipCue"||e.phase==="reaskRecto","Re"),ne=n(e=>(e.captured.recto!==void 0?1:0)+(e.captured.verso!==void 0?1:0)+e.pending.length,"ne");function te(e,t){return e.lastCaptureAt>=0&&e.lastReportAt>=0?e:{...e,lastCaptureAt:e.lastCaptureAt<0?t:e.lastCaptureAt,lastReportAt:e.lastReportAt<0?t:e.lastReportAt}}n(te,"ee");function Ne(e,t,r){if(e.phase==="result")return{...e,lastReportAt:r};let i=!t.present||e.captureArea!==void 0&&t.areaFrac<.6*e.captureArea,{flipped:l,awaySince:u}=e;i&&(u=u??r),u!==void 0&&r-u>=250&&(l=!0),i||(u=void 0);let s=e.flipTimeoutSpent&&!(l&&!e.flipped),d={...e,lastReportAt:r,flipped:l,awaySince:u,flipTimeoutSpent:s,lastArea:t.areaFrac};if(!Ce(e))return d;if(e.needFlip&&!l){if(!t.ready)return{...d,phase:e.restPhase,goodSince:void 0};let c=e.lastShot!==void 0&&e.pending.includes(e.lastShot);if(s||c)return{...d,goodSince:void 0,phase:e.restPhase};let v=e.goodSince??r;return r-v>=1800?{...d,goodSince:v,phase:"capturing",flipTimeoutSpent:!0,timeoutCapture:!0}:{...d,goodSince:v,phase:e.restPhase}}return t.ready?{...d,phase:"capturing",goodSince:e.goodSince??r}:{...d,goodSince:void 0,phase:t.locking?"locking":e.restPhase}}n(Ne,"Qe");function Ve(e,t){if(!Ce(e)||e.manualShutter)return e;let r=t-e.lastReportAt>=2e3,i=t-e.lastCaptureAt>=6e3;return r||i?{...e,manualShutter:!0}:e}n(Ve,"Ke");function je(e,t,r){let i=e.layout==="singlePage",l=i?{recto:t}:e.captured,u=i?[]:[...e.pending,t],s={...e,captured:l,pending:u,lastShot:t,lastCaptureAt:r,lastReportAt:-1,manualShutter:!1,goodSince:void 0,notice:void 0,awaySince:void 0,flipped:!1,lastShotByTimeout:e.timeoutCapture,timeoutCapture:!1,captureArea:e.lastArea};return i||ne({captured:l,pending:u})>=2?{...s,phase:"reading",restPhase:"framing",current:void 0,needFlip:!1}:{...s,phase:"flipCue",restPhase:"flipCue",current:void 0,needFlip:!0}}n(je,"je");function Re(e,t,r){return e.pending.includes(t)?{...e,pending:e.pending.filter(i=>i!==t),lastShot:e.lastShot===t?void 0:e.lastShot,phase:e.phase==="capturing"?e.phase:"flipCue",restPhase:"flipCue",current:Te(r),needFlip:!0,flipTimeoutSpent:!0,goodSince:void 0,manualShutter:!0,notice:"same_face",lastCaptureAt:-1,lastReportAt:-1}:e}n(Re,"xe");function Ge(e,t,r){if(!e.pending.includes(t))return e;if(e.captured[r]!==void 0)return Re(e,t,r);let i=e.pending.filter(c=>c!==t),l={...e,pending:i,captured:{...e.captured,[r]:t}};if(ne(l)!==1||e.layout==="singlePage")return l;let u=Te(r),s=u==="recto"&&e.restPhase==="reaskRecto"?"reaskRecto":"flipCue",d=e.phase==="flipCue"||e.phase==="reaskRecto"||e.phase==="framing";return{...l,restPhase:s,current:u,phase:d?s:e.phase}}n(Ge,"$e");function He(e,t){let r=t.id??e.captured[t.side],i={...e.captured};(t.id===void 0||i[t.side]===t.id)&&delete i[t.side];let l=e.pending.filter(v=>v!==r),u=e.layout==="twoSided"&&ne({captured:i,pending:l})>0,s=e.lastShotByTimeout||r===e.lastShot!==e.flipped,d=u&&!s,c=d?t.side==="recto"?"reaskRecto":"flipCue":"framing";return{...e,captured:i,pending:l,readSides:e.readSides.filter(v=>v!==t.side),lastShot:e.lastShot===r?void 0:e.lastShot,notice:t.issue,goodSince:void 0,manualShutter:!1,phase:c,restPhase:c,current:t.side,needFlip:d,flipped:!1,flipTimeoutSpent:!1,awaySince:void 0,lastCaptureAt:-1,lastReportAt:-1}}n(He,"Je");function _e(e,t){switch(t.type){case"report":return Ne(te(e,t.at),t.report,t.at);case"tick":return Ve(te(e,t.at),t.at);case"captured":return je(te(e,t.at),t.id,t.at);case"captureFailed":return{...e,phase:e.restPhase,goodSince:void 0,lastCaptureAt:t.at,manualShutter:!0,timeoutCapture:!1};case"classified":return Ge(e,t.id,t.side);case"duplicate":return Re(e,t.id,t.side);case"readOk":{let r=e.readSides.includes(t.side)?e.readSides:[...e.readSides,t.side],i=["recto","verso"].filter(u=>e.captured[u]!==void 0),l=e.phase==="reading"&&e.pending.length===0&&i.every(u=>r.includes(u));return{...e,readSides:r,flipTimeoutSpent:!1,phase:l?"result":e.phase}}case"readFailed":return He(e,t);case"clockRestart":return e.lastCaptureAt<0&&e.lastReportAt<0&&e.awaySince===void 0?e:{...e,awaySince:void 0,lastCaptureAt:-1,lastReportAt:-1};case"retake":return{...xe(e.layout,-1),lastCaptureAt:-1,lastReportAt:-1};default:return e}}n(_e,"ve");function Ye(e,t,r=!1){let i=e(t);return i===null?"recto":!r||i.y+i.height/2>=t.height/2?"verso":"recto"}n(Ye,"Ze");async function Je(e,t=!1){let{detectMrzBand:r}=await import("./mrz-band-DCXFWDBD-OPMO6HYS.js");return Ye(r,e,t)}n(Je,"et");async function we(e,t=480,r,i=r!=null){let l=r??{x:0,y:0,width:e.width,height:e.height},u=Math.max(1,Math.round(l.height/l.width*t)),s=document.createElement("canvas");s.width=t,s.height=u;try{let d=s.getContext("2d");return d===null?"recto":(d.drawImage(e,l.x,l.y,l.width,l.height,0,0,t,u),await Je(d.getImageData(0,0,t,u),i))}finally{s.width=0,s.height=0}}n(we,"re");var re=n((e,t,r)=>Math.min(r,Math.max(t,Math.round(e))),"oe"),J=n(e=>Math.round(Math.min(1,Math.max(0,e))*1e4)/1e4,"Y");async function Qe(e,t,r,i){let l=i.decode??(c=>createImageBitmap(c)),u=n(async()=>e.stillRead(await l(t),i.region??[0,0,1,1],i.detectorLimit),"l"),s;try{s=await u()}catch{try{await new Promise(c=>setTimeout(c,i.retryMs??300)),s=await u()}catch{return null}}let d=s.mrzBox;return d===void 0?null:{engine:i.engine,source:"live_mrz",format:r.format,lineCount:re(r.lineCount,2,3),checkDigitsValid:!0,stillConfirmed:s.valid&&s.digest===r.digest,band:[J(d[0]),J(d[1]),J(Math.min(d[2],1-d[0])),J(Math.min(d[3],1-d[1]))],digest:r.digest,framesToValid:re(r.framesToValid,1,1e3),msToValid:re(r.msToValid,0,12e4)}}n(Qe,"Le");var $e=new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11]),Ke=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,7,1,5,0,6,64,11,11]);function Ze(e,t=globalThis){let r=t.WebAssembly?.validate;if(typeof r!="function")return{ok:!1,reason:"simd"};try{if(!r.call(t.WebAssembly,$e)||!r.call(t.WebAssembly,Ke))return{ok:!1,reason:"simd"}}catch{return{ok:!1,reason:"simd"}}if(typeof t.Worker!="function")return{ok:!1,reason:"worker"};if(typeof t.createImageBitmap!="function")return{ok:!1,reason:"bitmap"};let i=t.navigator?.deviceMemory;return typeof i=="number"&&i<e.minDeviceMemoryGb?{ok:!1,reason:"memory"}:{ok:!0}}n(Ze,"_e");function Xe(e=globalThis){let t=e.navigator?.connection;return t?.saveData===!0||["slow-2g","2g","3g"].includes(t?.effectiveType??"")}n(Xe,"Te");var U,E=(U=class extends Error{constructor(t){super(t),this.name="OcrEngineError",this.code=t}},n(U,"T"),U);function Me(){let e=n(t=>(t.close(),Promise.reject(new E("unsupported"))),"e");return{ready:Promise.resolve("unsupported"),busy:!1,bandRead:e,stillRead:e,layoutRead:e,dispose:n(()=>{},"dispose")}}n(Me,"Ee");function et(e){let t;try{if(e.createWorker)t=e.createWorker();else if(e.workerUrl!==void 0)t=new Worker(e.workerUrl,{type:"module",name:"sekyro-ocr"});else return Me()}catch{return Me()}let r=new Map,i=0,l=!1,u=!1,s=!1;t.addEventListener("message",m=>{let h=m.data,x=r.get(h.id);x&&(r.delete(h.id),x.resolve(h))});let d=n(()=>{for(let m of r.values())m.reject(new E("error"));r.clear(),v()},"u");t.addEventListener("error",d),t.addEventListener("messageerror",d);function c(m,h=[]){if(l)return Promise.reject(new E("disposed"));let x=++i;return new Promise((W,q)=>{r.set(x,{resolve:W,reject:q});try{t.postMessage({...m,id:x},h)}catch{r.delete(x),q(new E("error"))}})}n(c,"c");function v(){if(!l){l=!0;try{t.postMessage({id:++i,kind:"dispose"})}catch{}t.terminate();for(let m of r.values())m.reject(new E("disposed"));r.clear()}}n(v,"f");let f=(async()=>{let m=await c({kind:"init",baseUrl:e.baseUrl,salt:e.salt,detectorLimit:e.tuning.detectorLimit,maxDownloadMs:e.tuning.maxDownloadMs});if(m.kind==="failed")return m.reason;if(m.kind!=="ready")return"error";let h=await c({kind:"warmup"});return h.kind!=="ready"?"error":{warmupMs:h.warmupMs,downloadMs:m.downloadMs,cached:m.cached}})().catch(()=>"error"),y,M=new Promise(m=>{y=setTimeout(()=>m("timeout"),e.tuning.loadTimeoutMs)}),F=Promise.race([f,M]).then(m=>(clearTimeout(y),typeof m=="string"?v():s=!0,l&&typeof m!="string"?"error":m));(e.page===void 0?globalThis.addEventListener?globalThis:null:e.page)?.addEventListener("pagehide",v,{once:!0});async function g(m,h,x){if(l)throw h.close(),new E("disposed");if(!s)throw h.close(),new E("not_ready");if(u)throw h.close(),new E("busy");u=!0;let W;try{let q=new Promise((V,b)=>{W=setTimeout(()=>{b(new E("timeout")),v()},e.tuning.readTimeoutMs??1e4)}),P=await Promise.race([c(m,[h]),q]);if(P.kind===x){let{id:V,...b}=P;return b}throw new E(P.kind==="error"?P.code:P.kind==="failed"?P.reason:"error")}finally{clearTimeout(W),u=!1}}return n(g,"w"),{ready:F,get busy(){return u},bandRead:n((m,h=e.tuning.detectorLimit)=>g({kind:"band",bitmap:m,detectorLimit:h},m,"band"),"bandRead"),stillRead:n((m,h,x=e.tuning.detectorLimit)=>g({kind:"still",bitmap:m,region:h,detectorLimit:x},m,"band"),"stillRead"),layoutRead:n((m,h)=>g({kind:"layout",bitmap:m,detectorLimit:h},m,"layout"),"layoutRead"),dispose:v}}n(et,"Oe");var Q="sekyro-ocr-1",ae=n(e=>e!==null&&typeof e=="object"?e:{},"ae"),R=n((e,t,r,i)=>typeof e=="number"&&Number.isFinite(e)&&e>=t&&e<=r?e:i,"v"),be=n((e,t)=>typeof e=="boolean"?e:t,"Pe"),ke=n(e=>{let t=typeof e=="string"?/^sekyro-ocr-(\d{1,4})$/.exec(e):null;return t?Number(t[1]):Number.POSITIVE_INFINITY},"Ae");function tt(e,t={}){let r=ae(e),i=ae(r.liveMrz),l=ae(r.frontLock),u=ke(t.engine??Q),s=t.mode==="off",d=n(h=>h.enabled===!0?h.arm==="live"?"live":"control":null,"u"),c=d(i),v=d(l),f=n((h,x)=>!s&&x==="live"&&ke(h.minEngine??Q)<=u,"p"),y=ge,M=f(i,c)?{detectorLimit:R(i.detectorLimit,320,1600,y.detectorLimit),bandMaxWidthPx:R(i.bandMaxWidthPx,320,4096,y.bandMaxWidthPx),minBandWidthPx:R(i.minBandWidthPx,0,4096,y.minBandWidthPx),bandTop:R(i.bandTop,0,.95,y.bandTop),minIntervalMs:R(i.minIntervalMs,0,5e3,y.minIntervalMs),stableReads:Math.round(R(i.stableReads,1,10,y.stableReads)),profileReads:Math.round(R(i.profileReads,1,100,y.profileReads)),maxReadMs:R(i.maxReadMs,50,6e4,y.maxReadMs),searchTimeoutMs:R(i.searchTimeoutMs,1e3,12e4,y.searchTimeoutMs),hint:be(i.hint,!0),stillConfirm:be(i.stillConfirm,!0)}:null,F=fe,g=n((h,x,W)=>R(l[h],x,W,F[h]),"h"),m=f(l,v)?{minLines:Math.round(g("minLines",1,50)),fillMin:g("fillMin",0,1),fillMax:g("fillMax",0,2),offsetMax:g("offsetMax",0,1),steadyFillDelta:g("steadyFillDelta",0,1),steadyOffsetDelta:g("steadyOffsetDelta",0,1),layoutShiftMax:g("layoutShiftMax",0,1),lineCountDelta:Math.round(g("lineCountDelta",0,50)),lockMs:g("lockMs",0,3e4),steadyMs:g("steadyMs",0,3e4),minFrames:Math.round(g("minFrames",1,100)),minIntervalMs:g("minIntervalMs",0,5e3),maxWidthPx:g("maxWidthPx",160,2048),detectorLimit:g("detectorLimit",320,1600),searchTimeoutMs:g("searchTimeoutMs",1e3,12e4)}:null;return{enabled:M!==null||m!==null,liveMrz:M,textLock:m,liveMrzArm:c,frontLockArm:v,load:{detectorLimit:M?.detectorLimit??m?.detectorLimit??y.detectorLimit,loadTimeoutMs:R(i.loadTimeoutMs,1e3,12e4,2e4),maxDownloadMs:R(i.maxDownloadMs,1e3,12e4,2e4),minDeviceMemoryGb:R(i.minDeviceMemoryGb,0,64,2)},reportSampleRate:R(i.reportSampleRate,0,1,1)}}n(tt,"Be");function rt(e,t){return e.enabled?!(t.probe??Ze)({minDeviceMemoryGb:e.load.minDeviceMemoryGb}).ok||(t.slow??Xe)()?{ok:!1,reason:"unsupported"}:{ok:!0,engine:et({baseUrl:t.baseUrl,salt:t.salt,tuning:{detectorLimit:e.load.detectorLimit,maxDownloadMs:e.load.maxDownloadMs,loadTimeoutMs:e.load.loadTimeoutMs},...t.workerUrl!==void 0?{workerUrl:t.workerUrl}:{},...t.createWorker!==void 0?{createWorker:t.createWorker}:{},...t.page!==void 0?{page:t.page}:{}})}:{ok:!1,reason:"off"}}n(rt,"Ie");function at(e=typeof navigator<"u"?navigator.userAgent:""){return/SamsungBrowser\//.test(e)?"samsung":/Firefox\/|FxiOS\//.test(e)?"firefox":/Chrome\/|CriOS\/|Chromium\//.test(e)&&!/Edg\/|OPR\//.test(e)?"chrome":/Safari\//.test(e)&&/Version\/|Mobile\//.test(e)&&!/Chrome\/|CriOS\//.test(e)?"safari":"other"}n(at,"rt");var B=n(e=>e===void 0||!Number.isFinite(e)?void 0:Math.min(6e5,Math.max(0,Math.round(e))),"F"),ie=n((e,t,r)=>e===void 0||!Number.isFinite(e)?void 0:Math.min(r,Math.max(t,Math.round(e))),"ie");function it(e){let t=e.assist??null,r=e.load!==null&&e.load!==void 0&&typeof e.load=="object"?e.load:null,i=typeof e.load=="string"?e.load:null,l=t!==null?t.outcome:i==="unsupported"||i==="download"||i==="integrity"?i:i==="error"||i==="timeout"?"error":"off",u={kind:"live_mrz",platform:"web",engine:e.engine??Q,arm:e.arm,capture:e.capture,outcome:l,reads:ie(t?.reads??0,0,1e4)??0,browser:e.browser??at()},s=n((d,c)=>{c!==void 0&&(u[d]=c)},"s");return s("format",t?.format),s("framesToValid",ie(t?.framesToValid,1,1e4)),s("msToValid",B(t?.msToValid)),s("framesToLock",ie(t?.framesToLock,1,1e4)),s("msToLock",B(t?.msToLock)),s("msToCapture",B(e.msToCapture)),s("readP50Ms",B(t?.readP50Ms)),s("readP90Ms",B(t?.readP90Ms)),s("deviceClass",t?.deviceClass),r!==null&&(s("warmupMs",B(r.warmupMs)),s("downloadMs",B(r.downloadMs)),s("cached",r.cached)),s("stillConfirmed",e.stillConfirmed),s("typeMismatch",e.typeMismatch),u}n(it,"We");function Se(e,t){return e===void 0?!1:t==="passport"?e!=="TD3":e==="TD3"}n(Se,"se");var nt=2;async function ot(e){let t=await import("./capture-session-doc-ELX6VK6Z-SDM3ILRA.js");return new t.CaptureSessionDoc(e)}n(ot,"at");function lt(e){return{topLeft:{x:e.x,y:e.y},topRight:{x:e.x+e.width,y:e.y},bottomRight:{x:e.x+e.width,y:e.y+e.height},bottomLeft:{x:e.x,y:e.y+e.height}}}n(lt,"it");function st(e,t,r){let i=[e.topLeft,e.topRight,e.bottomRight,e.bottomLeft],l=0;for(let u=0;u<i.length;u+=1){let s=i[u],d=i[(u+1)%i.length];l+=s.x*d.y-d.x*s.y}return t>0&&r>0?Math.abs(l)/2/(t*r):0}n(st,"st");function ft(){import("./capture-session-doc-ELX6VK6Z-SDM3ILRA.js").then(e=>e.warmDocDetector()).catch(()=>{})}n(ft,"Gt");function gt(e){return dt(e,{}).handle}n(gt,"qt");function dt(e,t){let r=pe(),i=me({enabled:e.keepScreenAwake!==!1}),l=t.decode??(a=>createImageBitmap(a)),u=t.blurRefuseSharpnessMax??.16,s=t.now??(()=>performance.now()),d=e.documentType==="passport"||e.side==="single",c=xe(d?"singlePage":"twoSided",s());if(!d&&(e.side==="recto"||e.side==="verso")){let a=e.side==="recto"?"verso":"recto";c={...c,captured:{[a]:"server"},readSides:[a],current:e.side,phase:"flipCue",restPhase:"flipCue"}}let v="idle",f=null,y=null,M=!0,F=0,g=0,m=!1,h=!1,x="",W=null,q,P=null,V=[],b=t.webOcr!==void 0?tt(t.webOcr.captureDocument,{mode:e.liveMrz?.mode??"auto"}):null,N=null,z=b===null||!b.enabled?"off":null,j=null,G=null,oe=new WeakMap,$="";if(b!==null&&b.enabled&&t.webOcr!==void 0){let a=t.webOcr,o=rt(b,{baseUrl:e.liveMrz?.assetBaseUrl??a.baseUrl,salt:a.salt,...e.liveMrz?.workerUrl!==void 0?{workerUrl:e.liveMrz.workerUrl}:{},...a.createWorker!==void 0?{createWorker:a.createWorker}:{}});if(o.ok){N=o.engine;let p=new ve({textLock:b.textLock,liveMrz:b.liveMrz});j=p;let w=o.engine;w.ready.then(A=>{z=A,typeof A!="string"&&M&&p.setEngine(w)})}else z=o.reason}let O=n(a=>{let o=JSON.stringify(a);o!==$&&($=o,r.emit("mrz",a))},"N"),le=n((a,o)=>{let p=t.webOcr?.reports;if(p===void 0||b===null||a===void 0)return;let w=a.format==="ID-3"||a.side==="single"?"single":a.side==="verso"?"verso":"recto",A=w!=="recto"?b.liveMrzArm??b.frontLockArm:b.frontLockArm;if(A===null||Math.random()>=b.reportSampleRate)return;let L=a.via==="live_mrz"?G:null,C=n(()=>{let D=L?.value??null;p([it({arm:A,capture:w,assist:a.ocr??null,load:A==="control"?"off":z,...a.msToCapture!==void 0?{msToCapture:a.msToCapture}:{},...D!==null&&D.stillConfirmed!==void 0?{stillConfirmed:D.stillConfirmed}:{},...o!==void 0?{typeMismatch:Se(o.format,e.documentType==="passport"?"passport":"card")}:{}})])},"x");L!==null&&L.value===null?Promise.race([L.promise,new Promise(D=>setTimeout(D,3e3))]).then(C):C()},"le"),I=n(a=>{!M||a===v||(v=a,i.setActive(a==="starting"||a==="scanning"),r.emit("state",a))},"W"),Ae=n((a,o)=>o===void 0?null:d?"single":a.captured.recto===o?"recto":a.captured.verso===o?"verso":null,"Fe"),Le=n(a=>({phase:a.phase,captured:d?a.captured.recto!==void 0?["single"]:[]:["recto","verso"].filter(o=>a.captured[o]!==void 0),expected:d?null:a.current??null,notice:a.notice??null,lastShot:Ae(a,a.lastShot),manualShutter:a.manualShutter,torchAvailable:f?.torchAvailable()??!1,torch:h}),"ze"),se=n(()=>{let a=f;a!==null&&a.captureNow().catch(()=>T({type:"captureFailed",at:s()}))},"ce");function T(a){if(!M)return;let o=c;c=_e(c,a),c.phase==="capturing"&&o.phase!=="capturing"&&Promise.resolve().then(se),c.phase==="result"&&o.phase!=="result"&&(I("done"),de());let p=Le(c),w=JSON.stringify(p);w!==x&&(x=w,r.emit("scan",p))}n(T,"R");function de(){P!==null&&clearInterval(P),P=null;for(let a of V.splice(0))a();f?.destroy(),f=null,i.setActive(!1)}n(de,"de");let ue=n(()=>f?.captureReport?.(),"me"),K=!1,ce=n((a,o)=>{if(!(a===void 0||t.onFaceReport===void 0))try{t.onFaceReport(a,o)}catch{}},"pe"),H=n(a=>{$="",!(f===null||c.phase==="reading"||c.phase==="result")&&(K=!1,f.rearm(d?"single":c.current??a))},"H"),Pe=n(async(a,o,p,w)=>{if(G=null,w!==void 0&&N!==null&&b?.liveMrz?.hint===!0){let k={promise:Qe(N,a,w,{engine:Q,detectorLimit:b.liveMrz.detectorLimit}).catch(()=>null),value:null};k.promise.then(S=>{k.value=S}),G=k}w!==void 0&&Se(w.format,e.documentType==="passport"?"passport":"card")&&O({state:"mismatch",format:w.format});let A=ue();ce(A,"captured"),K=!0,le(A,w);let L=p===void 0?W:p===null?null:{quad:lt(p),frameWidth:0,frameHeight:0,inStill:!0},C={decoded:null},D=n(()=>(C.decoded??(C.decoded=Promise.resolve().then(()=>l(a)).catch(()=>null)),C.decoded),"E");try{await De(a,o,L,D,G)}finally{C.decoded!==null&&(await C.decoded)?.close()}},"Ne"),De=n(async(a,o,p,w,A)=>{let L=`shot-${F+=1}`;if(T({type:"captured",id:L,at:s()}),e.haptics!==!1)try{globalThis.navigator?.vibrate?.(30)}catch{}if(!m&&u>0){let k=await(t.measureSharpness!==void 0?t.measureSharpness(a,p):w().then(S=>S===null?-1:he(S,ee(p?.quad??null,p?.inStill===!0?S:{width:p?.frameWidth??0,height:p?.frameHeight??0},S)))).catch(()=>-1);if(!M)return;if(Number.isFinite(k)&&k>=0&&k<u){m=!0;let S=d?"recto":c.current??(c.captured.recto===void 0?"recto":"verso");T({type:"readFailed",side:S,id:L,issue:"blurry"}),H(S);return}}m=!1;let C;if(d)C="single";else{let k=c.current,S=await(t.classify!==void 0?t.classify(a):w().then(_=>_===null?k??"recto":p?.inStill===!0?we(_,480,null,!0):we(_,480,ee(p?.quad??null,{width:p?.frameWidth??0,height:p?.frameHeight??0},_)))).catch(()=>k??"recto");if(!M)return;if(c.captured[S]!==void 0&&g<nt){g+=1,T({type:"duplicate",id:L,side:S}),H(S==="recto"?"verso":"recto");return}C=c.captured[S]!==void 0&&k!==void 0?k:S,g=0,T({type:"classified",id:L,side:C})}let D=C==="verso"?"verso":"recto";try{let k=t.encode!==void 0?await t.encode(a):await w().then(S=>{if(S===null)throw new Error("the still could not be decoded");return Ue(S)});if(!M)return;A!==null&&oe.set(k.blob,A),r.emit("captured",{image:k.blob,side:C,documentType:e.documentType,...e.issuer!==void 0?{issuer:e.issuer}:{},width:k.width,height:k.height,previewDataUrl:o}),t.deferRead!==!0&&T({type:"readOk",side:D})}catch(k){T({type:"readFailed",side:D,id:L,issue:"technical"}),r.emit("error",Y("generic",!0,{phase:"keyframes",name:X(k)}))}H(D==="recto"?"verso":"recto")},"Ue"),Ee=n(a=>{V.push(a.on("statechange",({state:o})=>{o==="preflight"||o==="acquiring"?I("starting"):o==="positioning"?I("scanning"):o==="captured"?I("captured"):o==="error"&&I("error")}),a.on("feedback",({key:o,reticle:p})=>r.emit("feedback",{key:o,reticle:p})),a.on("checks",o=>{r.emit("gate",{progress:o.p,quad:o.quad,frameWidth:o.frameWidth,frameHeight:o.frameHeight,...o.guide!==void 0?{guide:{detected:o.guide.detected,fill:o.guide.fill,offsetX:o.guide.offsetX??0,offsetY:o.guide.offsetY??0}}:{}});let p=o.ocr?.mrz;p!==void 0&&(p.state==="fallback"?O({state:"fallback",reason:p.reason}):p.state==="valid"?O({state:"valid",format:p.format}):p.state==="reading"?O({state:"reading",...p.format?{format:p.format}:{},...p.coach?{coach:p.coach}:{}}):O({state:"searching"}));let w=o.quad===null?0:st(o.quad,o.frameWidth,o.frameHeight);W=o.quad===null?null:{quad:o.quad,frameWidth:o.frameWidth,frameHeight:o.frameHeight},T({type:"report",report:{present:o.quad!==null&&o.plausible||o.guide?.detected===!0,ready:o.ready===!0,locking:o.p>=.5,areaFrac:w},at:s()})}),a.on("error",({kind:o,retryable:p,detail:w})=>r.emit("error",Y(o,p,w))),a.on("artifacts",o=>{Pe(o.keyframe,o.previewDataUrl,o.docRegion,o.liveMrz)}))},"Ge"),Z=n(()=>(y??(y=(async()=>{if(M){if(f===null){let a;try{a=await(t.createEngine??ot)({...t.engineOptions??{},...q!==void 0?{guide:q}:{},video:e.video,format:ye(e.documentType),side:d?"single":e.side??"recto",autoCapture:!1,...j!==null?{ocr:j}:{}})}catch(p){I("error"),r.emit("error",Y("models",!0,{phase:"models",name:X(p)}));return}if(!M){a.destroy();return}f=a,Ee(a);let o=t.tickMs??500;o>0&&(P=setInterval(()=>T({type:"tick",at:s()}),o))}T({type:"clockRestart"}),b!==null&&b.liveMrzArm==="live"&&(z==="unsupported"||z==="off")&&O({state:"fallback",reason:z}),await f.start()}})().finally(()=>{y=null})),y),"j");return{handle:{get state(){return v},on:n((a,o)=>r.on(a,o),"on"),start:Z,retry:n(()=>{if(f===null&&c.phase==="result"){T({type:"retake"}),g=0,m=!1,Z();return}if(f!==null&&v!=="error"){T({type:"retake"}),g=0,m=!1,f.rearm(d?"single":void 0);return}Z()},"retry"),setSide:n(a=>{d||a==="single"||(c.current!==a&&(c={...c,current:a}),T({type:"clockRestart"}),c.phase!=="reading"&&c.phase!=="result"&&f?.rearm(a))},"setSide"),shutter:se,focusAt:n((a,o)=>{f?.focusAt?.(a,o)},"focusAt"),setGuide:n(a=>{q=a,f?.setGuide?.(a)},"setGuide"),setTorch:n(a=>{h=a,f?.setTorch(a),T({type:"tick",at:s()})},"setTorch"),destroy:n(()=>{if(M&&f!==null&&v!=="done"){let a=ue();!K&&a!==void 0&&a.ticks>0&&ce(a,"abandoned"),le(a,void 0)}M=!1,de(),j?.setEngine(null),N?.dispose(),N=null,r.clear()},"destroy")},setFlowState:n(a=>{(c.phase==="reading"||c.phase==="result")&&I(a==="done"&&c.phase!=="result"?"scanning":a)},"setFlowState"),settle:n((a,o)=>{let p=a==="verso"?"verso":"recto";T(o.ok?{type:"readOk",side:p}:{type:"readFailed",side:p,issue:o.issue}),o.ok||H(p)},"settle"),takeDeviceRead:n(a=>oe.get(a.image)?.value??null,"takeDeviceRead")}}n(dt,"ut");export{nt as a,ft as b,gt as c,dt as d};
@@ -0,0 +1 @@
1
+ import{a as r}from"./chunk-4FHWXBOB.js";var u=["obs","manycam","virtual","snap camera","xsplit","droidcam","iriun","camo"],s=[/^(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 m(a){let e=(a??"").trim().toLowerCase();return e.length===0?"unknown":u.some(t=>e.includes(t))?"known_virtual":s.some(t=>t.test(e))?"platform":"unknown"}r(m,"c");var d=1e3;function f(a,e){return new Promise(t=>{let n=setTimeout(()=>t(void 0),e),i=r(l=>{clearTimeout(n),t(l)},"r");try{a().then(i,()=>i(void 0))}catch{i(void 0)}})}r(f,"m");async function b(a){let e=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(JSON.stringify(a)));return Array.from(new Uint8Array(e).subarray(0,8),t=>t.toString(16).padStart(2,"0")).join("")}r(b,"f");var o=r(a=>Array.isArray(a)?[...a].sort():null,"i"),c=r(a=>{let e=a;return e==null?null:[e.min??null,e.max??null]},"o");function y(a){try{return a.getSettings?.().facingMode==="environment"}catch{return!1}}r(y,"p");async function v(a){try{if(a.readyState==="ended"||y(a))return;let e={};try{e=a.getCapabilities?.()??{}}catch{}let t=await f(()=>navigator.mediaDevices.enumerateDevices(),d);return await b([c(e.width),c(e.height),c(e.frameRate),o(e.facingMode),o(e.focusMode),o(e.exposureMode),m(a.label),t?.filter(n=>n.kind==="videoinput").length??null])}catch{return}}r(v,"b");async function g(a,e){let t=await v(a);t&&e.noteCamera(t)}r(g,"v");export{f as a,b,v as c,g as d};
@@ -0,0 +1 @@
1
+ import{a as o}from"./chunk-4FHWXBOB.js";var a={"ID-1":{center:1.586,tolerance:.15},"ID-2":{center:1.419,tolerance:.12},"ID-3":{center:1.42,tolerance:.2}},i={"ID-1":["ID-1"],"ID-2":["ID-2"],"ID-3":["ID-3"],card:["ID-1","ID-2"]};function d(e){return a[e==="card"?"ID-1":e]}o(d,"i");function s(e,r){return i[e].some(t=>Math.abs(r-a[t].center)<=a[t].tolerance)}o(s,"d");var c=[{docType:"carte_identite",format:"ID-1",sides:["recto","verso"],mrz:"td1",portraitSide:"recto",aspectRatio:1.586,identifierSource:"mrz"},{docType:"passport",format:"ID-3",sides:["single"],mrz:"td3",portraitSide:"single",aspectRatio:1.42,identifierSource:"mrz"}],n=[...c,{docType:"residence_permit",format:"ID-1",sides:["recto","verso"],mrz:"td1",portraitSide:"recto",aspectRatio:1.586,identifierSource:"mrz"}];function D(e){let r=n.find(t=>t.docType===e);return r===void 0||r.format==="ID-1"?"card":r.format}o(D,"s");export{d as a,s as b,D as c};
@@ -0,0 +1 @@
1
+ import{b,t as r,v as l,y as o}from"./chunk-YWPZG2MZ.js";import{a as i}from"./chunk-RK4HVNRS.js";import{a,c as p}from"./chunk-4FHWXBOB.js";var s=p(b(),1);function f({tone:d,icon:n,busy:c,title:m,titleId:e,children:u,actions:t,live:y,testId:h}){let k=r();return(0,s.jsxs)("section",{className:"sekyro-step sekyro-status",...e!==void 0?{"aria-labelledby":e}:{},...y?{role:"status","aria-live":"polite"}:{},"data-testid":h,children:[(0,s.jsxs)("div",{className:"sekyro-status__body",children:[(0,s.jsx)("span",{className:`sekyro-tile sekyro-tile--${d}${c?" is-busy":""}`,"aria-hidden":"true",children:(0,s.jsx)(l,{name:n})}),(0,s.jsxs)("div",{className:"sekyro-heading sekyro-status__text",children:[(0,s.jsx)("h2",{id:e,ref:k,tabIndex:-1,className:"sekyro-text-body",children:m}),u]})]}),t!=null&&t!==!1?(0,s.jsx)(o,{children:t}):null]})}a(f,"g");i(f,"StatusPage");export{f as a};
@@ -0,0 +1 @@
1
+ import{l as v}from"./chunk-RRLXNT33.js";import{a as n}from"./chunk-4FHWXBOB.js";function U(e,r){return{video:{width:{ideal:1280,max:1280},height:{ideal:720,max:720},facingMode:r,frameRate:{ideal:24,max:30}},audio:!1}}n(U,"c");var E=600;function P(){if(typeof window>"u"||typeof navigator>"u")return"desktop";let e=navigator.userAgentData,r=e?.mobile||/Android|i(Pad)?OS/.test(String(e?.platform)),t=String(navigator.userAgent??"");if(/iPhone|iPod/i.test(t))return"phone";if(/iPad/i.test(t))return"tablet";if(/Android/i.test(t))return/Mobile/i.test(t)?"phone":"tablet";if(/BlackBerry|IEMobile|Opera Mini/i.test(t))return"phone";if(!r){if(Number(navigator.maxTouchPoints??0)<=1)return"desktop";if(/Macintosh/.test(t))return"tablet";if(/Windows NT|CrOS/.test(t)||!L())return"desktop"}let i=A();return i>0&&i<E?"phone":"tablet"}n(P,"i");function q(){return P()!=="desktop"}n(q,"u");function A(){try{let e=window.screen,r=Number(e?.width??0),t=Number(e?.height??0);return r>0&&t>0?Math.min(r,t):0}catch{return 0}}n(A,"a");function p(e){try{let r=e?.getVideoTracks?.()[0]?.getSettings?.().facingMode;return r==="user"||r==="environment"?r:null}catch{return null}}n(p,"d");function L(){try{return typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}catch{return!1}}n(L,"s");function B(){let e=new Map;return{on(r,t){let i=e.get(r);i===void 0&&(i=new Set,e.set(r,i));let a=t;return i.add(a),()=>{i?.delete(a)}},emit(r,t){let i=e.get(r);if(i!==void 0)for(let a of[...i])a(t)},count(r){return e.get(r)?.size??0},clear(){e.clear()}}}n(B,"y");async function T(){try{return typeof navigator>"u"||typeof navigator.permissions?.query!="function"?null:await navigator.permissions.query({name:"camera"})}catch{return null}}n(T,"f");function w(e){return e==="granted"||e==="prompt"||e==="denied"?e:"unknown"}n(w,"c");function O(e){let r=!1,t=null,i=n(()=>{!r&&t!==null&&e(w(t.state))},"t");return T().then(a=>{r||(t=a,e(a===null?"unknown":w(a.state)),a?.addEventListener?.("change",i))}),()=>{r=!0,t?.removeEventListener?.("change",i)}}n(O,"w");async function I(){if(typeof navigator>"u")return!1;let e=String(navigator.userAgent??"");if(/Android|iPhone|iPad|iPod/i.test(e)||/Macintosh/.test(e)&&(navigator.maxTouchPoints??0)>1)return!0;try{return(await navigator.mediaDevices?.enumerateDevices?.()??[]).filter(r=>r.kind==="videoinput").length>=2}catch{return!1}}n(I,"b");var D=n(e=>e==="self"?"user":"environment","h");function z(){let e=!1,r=n(i=>{e||(e=!0,console.warn(`[@sekyro/web] ${i}`))},"i"),t=n(i=>i==="self"?"this capture is a self capture (the person films themselves), which uses the front camera only. The back camera is for assisted capture, set in the flow.":"this capture is an assisted capture (another person films the face), which uses the back camera only. The front camera is for self capture, set in the flow.","n");return{facing:n((i,a)=>{let s=D(i);return a!==void 0&&a!==s&&r(`facing "${a}" ignored: ${t(i)}`),s},"facing"),refuseSwitch:n(i=>(r(`switchCamera() ignored: ${t(i)}`),!1),"refuseSwitch")}}n(z,"S");function y(){if(typeof navigator>"u"||!("wakeLock"in navigator))return null;let e=navigator.wakeLock;return typeof e?.request=="function"?e:null}n(y,"v");function b(){return typeof document>"u"||document.visibilityState==="visible"}n(b,"m");function k(e){try{e.release().catch(()=>{})}catch{}}n(k,"p");function R(e={}){if(e.enabled===!1)return{setActive:n(()=>{},"setActive")};let r=!1,t=null,i=!1,a=!1,s=n(()=>{if(!r||i||t!==null&&!t.released)return;let u=y();if(u===null||!b())return;let c;try{c=u.request("screen")}catch{return}i=!0,c.then(o=>{if(i=!1,!r){k(o);return}t=o,o.addEventListener?.("release",()=>{t===o&&(t=null)})},()=>{i=!1})},"o"),f=n(()=>{b()&&s()},"l"),d=n(u=>{typeof document>"u"||u===a||(a=u,u?document.addEventListener("visibilitychange",f):document.removeEventListener("visibilitychange",f))},"d");return{setActive:n(u=>{if(r=u,u){if(y()===null)return;d(!0),s();return}if(d(!1),t!==null){let c=t;t=null,k(c)}},"setActive")}}n(R,"P");var l,N=(l=class extends Error{constructor(){super("the back camera could not be opened"),this.name="BackCameraUnavailableError"}},n(l,"u"),l),M=new Set(["NotAllowedError","PermissionDeniedError","SecurityError"]);function S(e){try{return String(e?.name??"")}catch{return""}}n(S,"h");function m(e){if(e!==null)for(let r of e.getTracks())r.stop()}n(m,"c");async function H(e,r,t){let i=n(o=>({video:{...r,...o},audio:!1}),"a");if(e==="user")return t.getUserMedia(i({facingMode:"user"}));let a=n(o=>p(o)!=="user","o");try{let o=await t.getUserMedia(i({facingMode:{exact:"environment"}}));if(a(o))return o;m(o)}catch(o){if(M.has(S(o)))throw o}let s=!1,f=n(async()=>{if(t.enumerateDevices===void 0||s)return null;let o;try{o=v(await t.enumerateDevices()).slice(0,3)}catch{return null}s=o.length>0;for(let x of o){let h;try{h=await t.getUserMedia(i({deviceId:{exact:x}}))}catch(g){if(M.has(S(g)))throw g;continue}if(a(h))return h;m(h)}return null},"l"),d=await f();if(d!==null)return d;let u=await t.getUserMedia(i({facingMode:"environment"}));if(a(u))return u;m(u);let c=await f();if(c!==null)return c;throw new N}n(H,"C");export{U as a,P as b,q as c,p as d,B as e,O as f,I as g,D as h,z as i,R as j,N as k,H as l};
@@ -0,0 +1 @@
1
+ import{a as n}from"./chunk-4FHWXBOB.js";var O={enabled:!0,hz:3,segmenterTimeoutMs:8e3,segmenterBudgetMs:120,maskThreshold:.5,maxColorStd:28,maxEdgeDensity:.08,edgeLuma:24,maxGradient:.18,minPixels:300,timeoutMs:4e3},Y=12e3,w=n((a,h,t)=>Math.min(t,Math.max(h,Math.round(a))),"b");function Z(a,h,t){let{x:i,y:r,width:d,height:o}=a;if(t)return[{x:i-1.5*d,y:r-.8*o,width:4*d,height:2.8*o}];let s=r-.4*o,p=1.4*o;return[{x:i-.9*d,y:s,width:.75*d,height:p},{x:i+1.15*d,y:s,width:.75*d,height:p}].map(u=>{let y=Math.max(0,u.x),x=Math.min(h.width,u.x+u.width);return{x:y,y:u.y,width:Math.max(0,x-y),height:u.height}})}n(Z,"W");function _(a,h,t,i=O){let r=t!==null&&t.width>0&&t.height>0,d=Z(h,a,r),o=d.reduce((e,m)=>e+Math.max(0,m.width)*Math.max(0,m.height),0);if(o<=0)return null;let s=Math.max(1,Math.floor(Math.sqrt(o/Y))),p=r?t.data instanceof Float32Array?1:1/255:1,u=n((e,m)=>{if(!r)return!1;let T=w(e/a.width*t.width-.5,0,t.width-1),k=w(m/a.height*t.height-.5,0,t.height-1);return t.data[k*t.width+T]*p>=i.maskThreshold},"h"),y=n(e=>.299*a.data[e]+.587*a.data[e+1]+.114*a.data[e+2],"M"),x=0,C=[0,0,0],D=[0,0,0],S=0,E=0,G=0,L=0,P=0,z=0,B=0,q=0,F=0,j=0,Q=Math.min(...d.map(e=>e.x)),R=Math.max(...d.map(e=>e.x+e.width)),U=Math.min(...d.map(e=>e.y)),V=Math.max(...d.map(e=>e.y+e.height)),W=(Q+R)/2,X=(U+V)/2;for(let e of d){let m=w(e.x,0,a.width),T=w(e.x+e.width,0,a.width),k=w(e.y,0,a.height),J=w(e.y+e.height,0,a.height);for(let g=k;g<J;g+=s)for(let M=m;M<T;M+=s){if(u(M,g))continue;let K=(g*a.width+M)*4;for(let l=0;l<3;l+=1){let f=a.data[K+l];C[l]=C[l]+f,D[l]=D[l]+f*f}x+=1;let b=y(K);M<W?(G+=b,L+=1):(P+=b,z+=1),g<X?(B+=b,q+=1):(F+=b,j+=1);for(let[l,f]of[[M+s,g],[M,g+s]])l>=T||f>=J||u(l,f)||(S+=1,Math.abs(y((f*a.width+l)*4)-b)>i.edgeLuma&&(E+=1))}}if(x<i.minPixels)return null;let A=0;for(let e=0;e<3;e+=1){let m=C[e]/x;A+=Math.max(0,D[e]/x-m*m)}let N=Math.sqrt(A/3),v=S===0?0:E/S,c=n((e,m)=>m===0?null:e/m,"f"),H=n((e,m)=>e===null||m===null?0:Math.abs(e-m)/255,"R"),I=Math.max(H(c(G,L),c(P,z)),H(c(B,q),c(F,j)));return{method:r?"segmenter":"strip",uniform:N<=i.maxColorStd&&v<=i.maxEdgeDensity&&I<=i.maxGradient,colorStd:Math.round(N*10)/10,edgeDensity:Math.round(v*1e3)/1e3,gradient:Math.round(I*1e3)/1e3,pixels:x}}n(_,"Z");function $(a){let h=a!==null&&typeof a=="object"?a:{},t=O,i=n((r,d,o,s)=>typeof r=="number"&&Number.isFinite(r)&&r>=o&&r<=s?r:d,"r");return{enabled:typeof h.enabled=="boolean"?h.enabled:t.enabled,hz:i(h.hz,t.hz,.5,15),segmenterTimeoutMs:i(h.segmenterTimeoutMs,t.segmenterTimeoutMs,0,6e4),segmenterBudgetMs:i(h.segmenterBudgetMs,t.segmenterBudgetMs,1,2e3),maskThreshold:i(h.maskThreshold,t.maskThreshold,0,1),maxColorStd:i(h.maxColorStd,t.maxColorStd,0,255),maxEdgeDensity:i(h.maxEdgeDensity,t.maxEdgeDensity,0,1),edgeLuma:i(h.edgeLuma,t.edgeLuma,0,255),maxGradient:i(h.maxGradient,t.maxGradient,0,1),minPixels:i(h.minPixels,t.minPixels,1,1e6),timeoutMs:i(h.timeoutMs,t.timeoutMs,0,6e4)}}n($,"$");export{O as a,_ as b,$ as c};
@@ -0,0 +1 @@
1
+ import{a as i}from"./chunk-4FHWXBOB.js";var m=2e4,d="face_landmarker.task";function u(a){let t=[],r=a.faceLandmarks??[];for(let e=0;e<r.length;e+=1){let o=r[e]??[],l=a.faceBlendshapes?.[e]?.categories,s=null;if(l!==void 0){s={};for(let n of l)s[n.categoryName]=n.score}let c=a.facialTransformationMatrixes?.[e]?.data;t.push({landmarks:o.map(n=>({x:n.x,y:n.y})),blendshapes:s,matrix:c!==void 0&&c.length>=16?[...c]:null})}return t}i(u,"d");async function f(a){let t=a.replace(/\/+$/,""),r=await import("./vision_bundle-WBHR7TEE.js"),e=await r.FilesetResolver.forVisionTasks(t),o=await r.FaceLandmarker.createFromOptions(e,{baseOptions:{modelAssetPath:`${t}/${d}`,delegate:"CPU"},runningMode:"VIDEO",numFaces:2,outputFaceBlendshapes:!0,outputFacialTransformationMatrixes:!0});return{detect(l,s){try{return u(o.detectForVideo(l,s))}catch{return[]}},close(){try{o.close()}catch{}}}}i(f,"u");export{m as a,d as b,u as c,f as d};
@@ -0,0 +1 @@
1
+ import{a as d}from"./chunk-YWPZG2MZ.js";import{a as t}from"./chunk-RK4HVNRS.js";import{a as i,c as r}from"./chunk-4FHWXBOB.js";var s=r(d(),1);var u=(0,s.createContext)(null);function c(a,n,o){let e=n.detail;return{check:a,kind:n.kind,...e?.name!==void 0?{name:e.name}:{},...e?.phase!==void 0?{phase:e.phase}:{},...e?.engineKind!==void 0?{engineKind:e.engineKind}:{},attempt:Math.max(0,Math.min(1e3,o))}}i(c,"a");t(c,"captureIssueOf");function m(a,n){if(a!==void 0)try{a(n)}catch{}}i(m,"o");t(m,"sendCaptureIssue");export{u as a,c as b,m as c};
@@ -0,0 +1 @@
1
+ import{A as a,a as i,z as n}from"./chunk-U3UDWPBG.js";import{a as t}from"./chunk-RK4HVNRS.js";import{a as o}from"./chunk-4FHWXBOB.js";function d(r,p){if(r instanceof n)return r.field==="phone"?"otp.phoneInvalid":r.field==="code"?"otp.codeInvalid":r.kind==="check_digit"?"population.reason_id_number_invalid":"population.invalid";if(r instanceof a&&r.field==="channel")return"otp.reason_otp_channel_unavailable";if(r instanceof i){let e=`errors.${r.code}`;if(Object.hasOwn(p,e))return e}return"errors.network_error"}o(d,"d");t(d,"errorKey");export{d as a};
@@ -0,0 +1 @@
1
+ import{b,c as t,v as s,w as i,y as l}from"./chunk-YWPZG2MZ.js";import{a as r}from"./chunk-RK4HVNRS.js";import{a as o,c as k}from"./chunk-4FHWXBOB.js";var a=k(b(),1);function x({title:n,lead:d,cameraLabel:c,uploadLabel:m,notice:p,testId:e,onCamera:h,onUpload:u,onPhone:f=!1}){return(0,a.jsxs)("section",{className:"sekyro-step","data-testid":e,children:[(0,a.jsx)(i,{title:n,lead:d}),p,(0,a.jsxs)(l,{children:[(0,a.jsxs)(t,{full:!0,onClick:h,"data-testid":`${e}-camera`,children:[(0,a.jsx)(s,{name:f?"smartphone":"camera"}),c]}),(0,a.jsx)(t,{full:!0,kind:"ghost",onClick:u,"data-testid":`${e}-upload`,children:m})]})]})}o(x,"k");r(x,"PhotoSourceView");export{x as a};
@@ -0,0 +1 @@
1
+ import{a as g}from"./chunk-4FHWXBOB.js";var P=[468,473],U=[[33,133],[362,263]],$=[[33,7,163,144,145,153,154,155,133,173,157,158,159,160,161,246],[362,382,381,380,374,373,390,249,263,466,388,387,386,385,384,398]],Z=1;function Y(e){let l=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,n=Number.NEGATIVE_INFINITY,r=Number.NEGATIVE_INFINITY;for(let i of e)i.x<l&&(l=i.x),i.y<a&&(a=i.y),i.x>n&&(n=i.x),i.y>r&&(r=i.y);return e.length===0?{x:0,y:0,width:0,height:0}:{x:l,y:a,width:n-l,height:r-a}}g(Y,"j");var G=g((e,l)=>({x:(e.x+l.x)/2,y:(e.y+l.y)/2}),"A");function re(e,l,a){if(e.length<468)return null;let n=g(M=>{let b=e[M];return{x:b.x*l,y:b.y*a}},"a"),r=[0,1].map(M=>{let b=e.length>P[1]?n(P[M]):null,[u,h]=U[M];return b??G(n(u),n(h))}),i=$.map(M=>Y(M.map(n))),s=[];for(let M=0;M<Math.min(e.length,468);M+=1)s.push(n(M));let[f,m]=r,o=f.x>m.x,y=o?m:f,p=o?f:m;return{leftEye:y,rightEye:p,iod:Math.hypot(p.x-y.x,p.y-y.y),box:Y(s),nose:n(Z),leftEyeBox:o?i[1]:i[0],rightEyeBox:o?i[0]:i[1]}}g(re,"se");var S=180/Math.PI;function ee(e,l="column"){if(e.length<16||e.some(M=>!Number.isFinite(M)))return null;let a=g((M,b)=>l==="column"?e[b*4+M]:e[M*4+b],"o"),n=Math.hypot(a(0,0),a(1,0),a(2,0))||1,r=a(0,0)/n,i=a(1,0)/n,s=a(2,0)/n,f=a(2,1)/n,m=a(2,2)/n,o=Math.asin(Math.max(-1,Math.min(1,-s)))*S,y=Math.atan2(f,m)*S,p=Math.atan2(i,r)*S;return{yaw:o,pitch:y,roll:p}}g(ee,"W");function le(e){return Math.atan2(e.rightEye.y-e.leftEye.y,e.rightEye.x-e.leftEye.x)*S}g(le,"U");var H={width:480,height:640,eyeX:240,eyeY:289,iodMin:120,iodMax:160};function V(e){let l=H,a=e.iod>=l.iodMin&&e.iod<=l.iodMax?1:l.iodMin/Math.max(e.iod,1e-6),n=l.width/a,r=l.height/a,i=G(e.leftEye,e.rightEye);return{x:i.x-l.eyeX/l.width*n,y:i.y-l.eyeY/l.height*r,width:n,height:r}}g(V,"F");function te(e,l,a){let n=Math.max(0,-e.x),r=Math.max(0,-e.y),i=Math.max(0,e.x+e.width-l),s=Math.max(0,e.y+e.height-a);return Math.max((n+i)/e.width,(r+s)/e.height)}g(te,"Y");function ue(e,l,a,n){let r=V(e),i=r.x+r.width/2,s=r.y+r.height/2,f=H.width/H.height,m=Math.max(r.height*n.margin,n.minHeight,n.minWidth/f);m=Math.min(m,a,l/f);let o=m*f,y=Math.min(Math.max(i-o/2,0),Math.max(0,l-o)),p=Math.min(Math.max(s-m/2,0),Math.max(0,a-m));return{x:Math.round(y),y:Math.round(p),width:Math.round(o),height:Math.round(m)}}g(ue,"ue");var R=["face","framing","pose","eyes","mouth","glare","lighting","background","resolution","sharpness"],B=new Set(["glare","background"]),v=g(e=>({pass:!0,value:e,coach:null}),"k"),x=g((e,l)=>({pass:!1,value:e,coach:l}),"x"),O=g((e,l)=>({pass:e,value:null,coach:e?null:l,none:!0}),"O");function ae(e,l){let a=e.pose,n;if(a!==null){let u=a.pitch-l.pitchOffsetDeg,h=Math.max(Math.abs(a.yaw),Math.abs(u),Math.abs(a.roll));n=Math.abs(a.yaw)<=l.yawDeg&&Math.abs(u)<=l.pitchDeg&&Math.abs(a.roll)<=l.rollDeg?v(h):x(h,"pose")}else n={...O(!1,"pose"),value:e.eyeLineRoll??null};let r=O(!1,"eyes");if(e.eyes!==null){let{left:u,right:h}=e.eyes,d=Math.min(u,h),c=e.baselines,N=1-l.eyes.blinkMax;if(c!=null&&c.left>0&&c.left<=1&&c.right>0&&c.right<=1){let k=Math.max(u,h)>=N-1e-9&&d>=l.eyes.lowerEyeMin-1e-9&&u>=l.eyes.relativeMin*c.left-1e-9&&h>=l.eyes.relativeMin*c.right-1e-9,I=Math.min(u/c.left,h/c.right);r=k?v(I):x(I,"eyes")}else{let k=e.baseline,I=Math.max(N,k!==null&&k>0&&k<=1?l.eyes.relativeMin*k:0),L=k!==null&&k>0?d/k:null;r=d>=I-1e-9?v(L):x(L,"eyes")}}let i=O(!1,"mouth");if(e.mouth!==null){let{jawOpen:u,smile:h,pucker:d}=e.mouth,c=Math.max(u/l.mouth.jawOpenMax,h/l.mouth.smileMax,d/l.mouth.puckerMax);i=u<=l.mouth.jawOpenMax&&h<=l.mouth.smileMax&&d<=l.mouth.puckerMax?v(c):x(c,"mouth")}let s=e.lighting,f=O(!0,"lighting");if(s!==null){let[u,h]=l.lighting.faceLuma,[d,c]=l.lighting.halfRatio;f=s.faceLuma<u||s.faceLuma>h||s.clipped>l.lighting.clippedMax?x(s.faceLuma,"lighting"):s.halfRatio<d||s.halfRatio>c?x(s.halfRatio,"lighting_side"):v(s.faceLuma)}let m=e.uniformity,o=e.background,y=l.background.required?m!=null&&l.backgroundCheck.enabled?m.uniform?v(m.colorStd):x(m.colorStd,"background"):o===null?O(!0,"background"):o.luma>=l.background.lumaMin&&o.sd<=l.background.lumaSdMax?v(o.luma):x(o.luma,"background"):O(!0,"background"),p=l.resolution,M=Math.min(e.frameWidth,e.frameHeight)>=p.minWidth&&Math.max(e.frameWidth,e.frameHeight)>=p.minHeight,b=e.iod>=p.minIodPx&&M?v(e.iod):x(e.iod,"resolution");return{pose:n,eyes:r,mouth:i,lighting:f,background:y,resolution:b}}g(ae,"te");function q(e){let l=e?.eyeBlinkLeft,a=e?.eyeBlinkRight;return typeof l!="number"||typeof a!="number"?null:{left:1-l,right:1-a,blinkLeft:l,blinkRight:a}}g(q,"D");function ne(e,l){if(e.length===0)return null;let a=[...e].sort((r,i)=>r-i),n=Math.min(a.length-1,Math.max(0,Math.ceil(l*a.length)-1));return a[n]}g(ne,"oe");function D(e,l,a,n=null){let r={},i=e.geometry;if(e.faces!==1||i===null){let h=e.faces>1?x(e.faces,"multiple_faces"):x(e.faces,"no_face");for(let d of R)r[d]=d==="face"?h:O(!1,"no_face");return{results:r,pose:null}}r.face=v(1);let s=V(i),f=te(s,e.frameWidth,e.frameHeight);r.framing=s.height>e.frameHeight*1.02||s.width>e.frameWidth*1.02?x(f,"too_close"):f>.02?x(f,"center"):v(f);let m=e.matrix!=null?ee(e.matrix):null,o=q(e.blendshapes),y=e.blendshapes,p=e.stats??null,M=ae({pose:m,eyeLineRoll:Math.abs(le(i)),eyes:o,baseline:a,baselines:n,mouth:y==null?null:{jawOpen:y.jawOpen??0,smile:Math.max(y.mouthSmileLeft??0,y.mouthSmileRight??0),pucker:y.mouthPucker??0},lighting:p?.lighting??null,background:p?.background??null,uniformity:e.backgroundCheck??null,iod:i.iod,frameWidth:e.frameWidth,frameHeight:e.frameHeight},l);Object.assign(r,M);let b=p?.eyeSpecular??null;r.glare=b===null?O(!0,"glare"):b<=l.glare.specularMax?v(b):x(b,"glare");let u=p?.sharpness??null;return r.sharpness=u===null||u>=l.sharpnessMin?v(u):x(u,"hold_still"),{results:r,pose:m}}g(D,"V");var ie={pose:"pose",eyes:"eyes",mouth:"mouth",glare:"glare",lighting:"lighting",background:"background",framing:"resolution",resolution:"resolution"};function he(e,l={}){let a=l.policy==="alert",n=new Map,r=0,i=null,s=null,f={},m=[],o=null,y=null,p=null,M=0,b=g(u=>{let h=ne(m.map(u),e.baseline.percentile);return h===null||h<=0?null:Math.min(1,h)},"y");return{push(u,h){let d=D(u,e,null),c=u.blendshapes;if(d.results.face.pass&&c!=null){let t=g(Q=>Math.round(Math.min(1,Math.max(0,Q??0))*1e3)/1e3,"t"),w={jawOpen:t(c.jawOpen),smile:t(Math.max(c.mouthSmileLeft??0,c.mouthSmileRight??0)),pucker:t(c.mouthPucker)};p===null&&(M=h);let _=p?.lowest??w;p={elapsedMs:Math.round(h-M),latest:w,lowest:{jawOpen:Math.min(_.jawOpen,w.jawOpen),smile:Math.min(_.smile,w.smile),pucker:Math.min(_.pucker,w.pucker)}}}let N=q(u.blendshapes);N!==null&&d.results.face.pass&&d.results.pose.pass&&m.push({at:h,left:N.left,right:N.right}),m=m.filter(t=>h-t.at<=e.baseline.windowMs);let k=m.length>=e.baseline.minSamples,I=k?b(t=>(t.left+t.right)/2):null,L=k?b(t=>t.left):null,T=k?b(t=>t.right):null,W=L!==null&&T!==null?{left:L,right:T}:null,{results:E,pose:A}=D(u,e,I,W);for(let t of R)E[t].pass&&(t!=="eyes"||I!==null)?n.has(t)||n.set(t,h):n.delete(t);let F=g(t=>{let w=n.get(t);return w!==void 0&&h-w>=e.holdMs},"H");R.filter(t=>!B.has(t)).every(F)?i??(i=h):i=null;let X=g(t=>t==="background"&&u.backgroundCheck!=null?e.backgroundCheck.timeoutMs:e.softGraceMs,"X"),z=g(t=>B.has(t)&&!E[t].pass&&i!==null&&h-i>=X(t),"J"),j=R.map(t=>({criterion:t,pass:E[t].pass,held:F(t),waived:z(t),value:E[t].value,coach:E[t].pass?null:E[t].coach}));r=j.every(t=>t.pass||t.waived)?r+1:0;let C=j.find(t=>!t.pass&&!t.waived)??null,J=j.filter(t=>t.held||t.waived).length;E.face.pass&&E.framing.pass?s??(s=h):s=null;let K=j.every(t=>t.held||t.waived)&&r>=e.holdFrames||a&&s!==null&&h-s>=e.alertGraceMs;f={};for(let t of R){let w=ie[t];w!==void 0&&E[t].none!==!0&&(f[w]=(f[w]??!0)&&E[t].pass)}return y=u.backgroundCheck??null,o={criteria:j,coach:C?.coach??"hold",failing:C?.criterion??null,progress:J/j.length,ready:K,baseline:I,baselines:W,pose:A},o},last:g(()=>o,"last"),scores:g(()=>p,"scores"),summary(){let u={criteria:{}};if(o===null)return u;u.verdict={...f},o.baseline!==null&&Math.round(o.baseline*1e3)>0&&(u.baselineEyeOpenness=Math.round(o.baseline*1e3)/1e3);let h=o.baselines;h!==null&&Math.round(h.left*1e3)>0&&Math.round(h.right*1e3)>0&&(u.baselineEyeOpennessLeft=Math.round(h.left*1e3)/1e3,u.baselineEyeOpennessRight=Math.round(h.right*1e3)/1e3);for(let d of o.criteria){let c=d.value===null||!Number.isFinite(d.value)?null:Math.round(d.value*1e3)/1e3;u.criteria[d.criterion]=d.waived?{pass:d.pass,value:c,waived:!0}:{pass:d.pass,value:c}}if(y!==null&&e.background.required){let{pixels:d,...c}=y;u.backgroundCheck=c}return u},reset(){n.clear(),r=0,i=null,s=null,f={},o=null,y=null,p=null}}}g(he,"me");export{re as a,V as b,ue as c,R as d,ae as e,q as f,ne as g,D as h,he as i};
@@ -0,0 +1 @@
1
+ import{a as xr}from"./chunk-FDWO4KXK.js";import{c as _t}from"./chunk-X3BGM3B2.js";import{b as gr,d as kr}from"./chunk-36WGD7QV.js";import{b as Sr,c as bt}from"./chunk-FCTRNWRU.js";import{a as mr,b as yr,c as vr,d as Le}from"./chunk-LYYAVERP.js";import{F as _r,K as Cr,L as wr,a as D,b as de,c as X,m as dr,n as Je,p as pr,q as Xe,r as hr,s as fr,t as kt,u as se,v as Ae,w as et,y as br}from"./chunk-YWPZG2MZ.js";import{b as or,c as lr,d as cr,g as ur}from"./chunk-ZKLSZJFN.js";import{b as gt}from"./chunk-6H22RNSK.js";import{a as s}from"./chunk-RK4HVNRS.js";import{f as ir}from"./chunk-D334IAZJ.js";import{a as i,c as E}from"./chunk-4FHWXBOB.js";var Mr=E(D(),1),v=E(de(),1),ee=E(de(),1),ye=E(D(),1),B=E(de(),1),_=E(D(),1),y=E(D(),1),st=E(D(),1),fe=E(de(),1),Qr=E(D(),1),Y=E(D(),1),it=E(D(),1),we=E(de(),1),Se=E(de(),1),U=E(de(),1);var ot=E(D(),1),pe=E(D(),1);var Q=E(D(),1);var M=E(D(),1),me=E(D(),1),Te=E(D(),1),Mt=E(de(),1),k=E(de(),1);function ie({className:e,children:t}){return(0,v.jsx)("svg",{"aria-hidden":"true",focusable:"false",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",className:e??"sekyro-icon sekyro-icon--sm",children:t})}i(ie,"te");s(ie,"Svg");var Rt="M4 7.5h2.2l1.4-1.9h8.8l1.4 1.9H20a1.6 1.6 0 0 1 1.6 1.6v8.3A1.6 1.6 0 0 1 20 19H4a1.6 1.6 0 0 1-1.6-1.6V9.1A1.6 1.6 0 0 1 4 7.5Z";function Rr(e){return(0,v.jsxs)(ie,{...e,children:[(0,v.jsx)("circle",{cx:"12",cy:"12",r:"4"}),(0,v.jsx)("path",{d:"M12 2.5v2M12 19.5v2M2.5 12h2M19.5 12h2M5.3 5.3l1.4 1.4M17.3 17.3l1.4 1.4M5.3 18.7l1.4-1.4M17.3 6.7l1.4-1.4"})]})}i(Rr,"cn");s(Rr,"SunIcon");function Lr(e){return(0,v.jsxs)(ie,{...e,children:[(0,v.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,v.jsx)("path",{d:"M9 10h.01M15 10h.01M8.8 14.6a4.2 4.2 0 0 0 6.4 0"})]})}i(Lr,"ln");s(Lr,"FaceUncoveredIcon");function Ar(e){return(0,v.jsxs)(ie,{...e,children:[(0,v.jsx)("rect",{x:"7",y:"2.5",width:"10",height:"19",rx:"2"}),(0,v.jsx)("path",{d:"M10.5 18.5h3M2.5 9.5h2.5M19 9.5h2.5"}),(0,v.jsx)("circle",{cx:"12",cy:"9.5",r:"1.6"})]})}i(Ar,"un");s(Ar,"PhoneEyeLevelIcon");function Er(e){return(0,v.jsxs)(ie,{...e,children:[(0,v.jsx)("path",{d:"M2.5 12S6 5.5 12 5.5 21.5 12 21.5 12 18 18.5 12 18.5 2.5 12 2.5 12Z"}),(0,v.jsx)("circle",{cx:"12",cy:"12",r:"2.8"})]})}i(Er,"dn");s(Er,"LookStraightIcon");function Ir(e){return(0,v.jsxs)(ie,{...e,children:[(0,v.jsx)("path",{d:Rt}),(0,v.jsx)("path",{d:"M9 13l2 2 4-4"})]})}i(Ir,"pn");s(Ir,"CameraCheckIcon");function Ur(e){return(0,v.jsxs)(ie,{...e,children:[(0,v.jsx)("path",{d:Rt}),(0,v.jsx)("path",{d:"M10.2 11.2a1.9 1.9 0 1 1 2.6 1.8c-.5.2-.8.6-.8 1.1v.3M12 16.4h.01"})]})}i(Ur,"fn");s(Ur,"CameraAskIcon");function jr(e){return(0,v.jsxs)(ie,{...e,children:[(0,v.jsx)("path",{d:Rt}),(0,v.jsx)("path",{d:"M3 3l18 18"})]})}i(jr,"mn");s(jr,"CameraBlockedIcon");function rt({off:e,className:t}){return(0,v.jsxs)(ie,{className:t,children:[(0,v.jsx)("path",{d:"M4.5 9.5v5H8l4 3.5v-12L8 9.5H4.5Z"}),e?(0,v.jsx)("path",{d:"M4 4l16 16"}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)("path",{d:"M15.5 9.7a3.6 3.6 0 0 1 0 4.6"}),(0,v.jsx)("path",{d:"M18 7.6a6.6 6.6 0 0 1 0 8.8"})]})]})}i(rt,"Ve");s(rt,"SpeakerIcon");function Tr(e){return(0,v.jsx)(ie,{...e,children:(0,v.jsx)("path",{d:"M5 12.5l4.5 4.5L19 7.5"})})}i(Tr,"yn");s(Tr,"CheckIcon");function Pr(e){return(0,v.jsxs)(ie,{className:e.className??"sekyro-spinner",children:[(0,v.jsx)("circle",{cx:"12",cy:"12",r:"9",opacity:"0.25"}),(0,v.jsx)("path",{d:"M21 12a9 9 0 0 0-9-9"})]})}i(Pr,"gn");s(Pr,"SpinnerIcon");var Ct=["light","uncover","eyeLevel","straight"],An={light:{key:"capture.tips.light",icon:s(()=>(0,ee.jsx)(Rr,{}),"icon")},uncover:{key:"capture.tips.uncover",icon:s(()=>(0,ee.jsx)(Lr,{}),"icon")},eyeLevel:{key:"capture.tips.eyeLevel",icon:s(()=>(0,ee.jsx)(Ar,{}),"icon")},straight:{key:"capture.tips.straight",icon:s(()=>(0,ee.jsx)(Er,{}),"icon")}};function Or({tips:e}){let t=Le(),n=(0,Mr.useId)();return e.length===0?null:(0,ee.jsxs)("section",{className:"sekyro-tips","aria-labelledby":n,"data-testid":"sekyro-tips",children:[(0,ee.jsx)("p",{className:"sekyro-tips__title",id:n,children:t("capture.tips.title")}),(0,ee.jsx)("ul",{className:"sekyro-tips__list",children:e.map(r=>{let a=typeof r=="string"?An[r]:void 0,o=typeof r=="string"?r:r.id,l=a!==void 0?a.icon():typeof r=="string"?void 0:r.icon,u=a!==void 0?t(a.key):typeof r=="string"?r:r.text;return(0,ee.jsxs)("li",{className:"sekyro-tips__item",children:[l!=null?(0,ee.jsx)("span",{className:"sekyro-tips__icon","aria-hidden":"true",children:l}):null,(0,ee.jsx)("span",{children:u})]},o)})})]})}i(Or,"vn");s(Or,"TipList");var En=220;function Br({title:e,description:t,options:n,busy:r,error:a,focus:o,testId:l,look:u="cards",marked:S,onChoose:h}){let w=(0,ye.useId)(),x=kt(),[I,d]=(0,ye.useState)(null),N=(0,ye.useRef)(null);(0,ye.useEffect)(()=>{a!==null&&d(null)},[a]),(0,ye.useEffect)(()=>()=>{N.current!==null&&clearTimeout(N.current)},[]);let R=s(p=>{r||I!==null||(d(p),N.current=setTimeout(()=>{N.current=null,d(null),h(p)},En))},"choose");return(0,B.jsxs)("section",{className:"sekyro-stack sekyro-stack--4 sekyro-choice","aria-labelledby":w,"data-testid":l,children:[(0,B.jsxs)("div",{className:u==="cards"?"sekyro-heading":"sekyro-stack sekyro-stack--1",children:[(0,B.jsx)("h2",{id:w,ref:o?x:void 0,tabIndex:-1,className:"sekyro-text-body",children:e}),t!==void 0&&t!==""?(0,B.jsx)("p",{className:"sekyro-text-muted",children:t}):null]}),a!==null?(0,B.jsx)(se,{tone:"danger",children:(0,B.jsx)("span",{children:a})}):null,u==="buttons"?(0,B.jsx)("div",{className:"sekyro-stack sekyro-stack--3",children:n.map((p,j)=>(0,B.jsx)(X,{kind:j===0?"primary":"ghost",full:!0,disabled:r,"aria-busy":r||void 0,onClick:i(()=>h(p.id),"onClick"),children:p.label},p.id))}):(0,B.jsx)("div",{className:"sekyro-choices",children:n.map(p=>(0,B.jsxs)("button",{type:"button",className:"sekyro-card","aria-pressed":(I??S)===p.id,"aria-busy":r||void 0,disabled:r||I!==null&&I!==p.id,onClick:i(()=>R(p.id),"onClick"),children:[p.glyph!==void 0?(0,B.jsx)("span",{className:"sekyro-card__tile",children:p.glyph}):null,(0,B.jsxs)("span",{className:"sekyro-card__body",children:[(0,B.jsx)("span",{className:"sekyro-card__title",children:p.label}),p.sub!==void 0?(0,B.jsx)("span",{className:"sekyro-card__sub",children:p.sub}):null]}),(0,B.jsx)("span",{className:"sekyro-radio","aria-hidden":"true"})]},p.id))})]})}i(Br,"kn");s(Br,"ChoiceScreen");var qr=["fcv3.no_face","fcv3.come_closer","fcv3.move_back","fcv3.center_face","fcv3.straighten","fcv3.more_light","fcv3.too_bright","fcv3.hold_still","fcv3.steady_camera","fcv3.hold_upright","fcv3.one_face","capture.tips.summary"];function nt(e){return e!==null&&qr.includes(e)}i(nt,"he");s(nt,"isVoiceKey");var In=s((e,t)=>Object.prototype.hasOwnProperty.call(e,t),"own");function je(e,t,n){let r;try{if(typeof e=="function")r=e(t,n);else{let a=e[n];r=a!=null&&In(a,t)?a[t]:null}}catch{return null}return typeof r=="string"&&r!==""?r:null}i(je,"Me");s(je,"resolveClip");var Un="UklGRiQAAABXQVZFZm10IBAAAAABAAEAESsAACJWAAACABAAZGF0YQAAAAA=",jn={ar:"ar-SA",fr:"fr-FR",en:"en-US",es:"es-ES",pt:"pt-BR",de:"de-DE"};function ae(){return typeof window<"u"&&"speechSynthesis"in window?window.speechSynthesis:null}i(ae,"ne");s(ae,"synth");function Vr(){return ae()!==null&&typeof SpeechSynthesisUtterance=="function"}i(Vr,"wr");s(Vr,"speechAvailable");function wt(e){return(e.split(/[-_]/)[0]??e).toLowerCase()}i(wt,"bn");s(wt,"baseLang");function Lt(e,t){let n=s(a=>a.replace(/_/g,"-").toLowerCase(),"norm"),r=wt(t);return e.find(a=>n(a.lang)===n(t))??e.find(a=>wt(a.lang)===r)}i(Lt,"Vn");s(Lt,"pickVoice");function Hr(e){if(!Vr())return!1;let t=[];try{t=ae()?.getVoices()??[]}catch{return!0}return t.length===0||Lt(t,e)!==void 0}i(Hr,"Mn");s(Hr,"speechUsable");function Dr(e){let t=ae();return t===null||typeof t.addEventListener!="function"?()=>{}:(t.addEventListener("voiceschanged",e),()=>t.removeEventListener?.("voiceschanged",e))}i(Dr,"wn");s(Dr,"subscribeVoices");function He(e){try{let t=typeof location<"u"?location.href:"http://localhost/",n=new URL(e,t);return`clip:${n.origin}${n.pathname}`}catch{return`clip:${e}`}}i(He,"Ke");s(He,"clipIdentity");function St(e){e.pause(),e.removeAttribute("src"),e.load()}i(St,"Sn");s(St,"release");function $r(){let e=null,t=null,n=0,r=null,a=[],o=new Map,l=s(()=>{a=ae()?.getVoices()??[]},"loadVoices"),u=!1,S=s(()=>{let d=ae();u||d===null||(u=!0,l(),d.addEventListener?.("voiceschanged",l))},"bindVoices"),h=s(()=>(e??(e=new Audio),e),"element"),w=s((d,N,R)=>{let p=ae();if(p!==null&&d!==""&&typeof SpeechSynthesisUtterance=="function"){S();let j=Lt(a,N);if(a.length===0||j!==void 0){p.cancel();let C=new SpeechSynthesisUtterance(d);C.lang=N,j!==void 0&&(C.voice=j),C.rate=.95,R!==void 0&&(C.onend=C.onerror=R),p.speak(C);return}}R?.()},"speak"),x=s(()=>{n+=1,r=null,e!==null&&(e.pause(),e.currentTime=0),ae()?.cancel()},"stop"),I=s(d=>{for(let N of d){let R=He(N);if(o.has(R))continue;let p=new Audio;p.preload="auto",p.src=N,o.set(R,p)}},"warmClips");return{say(d){let N=d.url!==null?He(d.url):`tts:${d.lang}:${d.text}`;if(N===r)return;r=N,n+=1;let R=n,p=d.onEnd,j=p!==void 0?()=>{R===n&&p()}:void 0;if(ae()?.cancel(),d.url!==null){let C=h();C.pause(),C.muted=!1,C.src=d.url,C.currentTime=0,C.onended=j??null,C.play()?.catch(A=>{R===n&&A?.name!=="AbortError"&&(d.speech?w(d.text,d.lang,j):j?.())});return}d.speech?w(d.text,d.lang,j):j?.()},unlock({lang:d,speech:N,prefetch:R}){let p=h();if(t===null&&typeof Blob=="function"&&typeof URL.createObjectURL=="function"){let A=Uint8Array.from(atob(Un),q=>q.charCodeAt(0));t=URL.createObjectURL(new Blob([A],{type:"audio/wav"}))}let j=p.paused===!1&&t!==null&&p.src!==t;t!==null&&!j&&(p.muted=!0,p.onended=null,p.src=t,p.play()?.catch(()=>{}));let C=ae();if(N&&C!==null&&typeof SpeechSynthesisUtterance=="function"){S();let A=new SpeechSynthesisUtterance(" ");A.volume=0,A.lang=d,C.speak(A)}I(R??[])},prefetch:I,stop:x,dispose(){x(),u&&ae()?.removeEventListener?.("voiceschanged",l),u=!1,t!==null&&URL.revokeObjectURL(t),t=null,e!==null&&St(e),e=null;for(let d of o.values())St(d);o.clear()}}}i($r,"Ln");s($r,"createVoicePlayer");var Tn="sekyro.voiceGuidance";function Fr(e){try{if(typeof window>"u")return null;let t=window.localStorage.getItem(e);return t==="1"?!0:t==="0"?!1:null}catch{return null}}i(Fr,"xn");s(Fr,"readVoicePreference");function Gr(e,t){try{if(typeof window>"u")return;window.localStorage.setItem(e,t?"1":"0")}catch{}}i(Gr,"In");s(Gr,"writeVoicePreference");var Ve="capture.tips.summary",Pn=typeof window<"u"?_.useLayoutEffect:_.useEffect,On=Object.freeze({});function tt(e,t){let n=new Set,r=[];for(let a of qr){let o=a===Ve?null:je(e,a,t);o===null||n.has(He(o))||(n.add(He(o)),r.push(o))}return r}i(tt,"gt");s(tt,"resolvedClipUrls");function Kr({locale:e,defaultClips:t,options:n}){let r=n===!1,a=r?{}:n??{},o=a.storageKey===void 0?Tn:a.storageKey,[l,u]=(0,_.useState)(a.defaultEnabled??!0),S=(0,_.useRef)(l),[h,w]=(0,_.useState)(!1),[x,I]=(0,_.useState)("none"),[d,N]=(0,_.useState)(!1),R=(0,_.useRef)(!1),[p,j]=(0,_.useState)(0),C=(0,_.useRef)(null),A=(0,_.useCallback)(()=>(C.current??(C.current=$r()),C.current),[]),q=jn[e],$=a.speechFallback,f=$===void 0||$===!0?!0:$===!1?!1:$.includes(e),F=a.clips??t??On,oe=(0,_.useRef)(!1),le=(0,_.useRef)(F);Pn(()=>{le.current=F,S.current=l}),(0,_.useEffect)(()=>{if(r||o===null)return;let L=Fr(o);L!==null&&(S.current=L,u(L))},[r,o]),(0,_.useEffect)(()=>{if(!(r||!f))return Dr(()=>j(L=>L+1))},[r,f]);let c=a.clips;(0,_.useEffect)(()=>{if(r)return;let L=f&&Hr(q);w(tt(F,e).length>0||L),I(c!==void 0&&je(c,Ve,e)!==null?"partner":je(F,Ve,e)!==null||L?"default":"none")},[r,F,c,e,f,q,p]),(0,_.useEffect)(()=>{if(r||!l||!oe.current)return;let L=tt(F,e);L.length>0&&A().prefetch(L)},[r,l,F,e,A]),(0,_.useEffect)(()=>()=>{C.current?.dispose(),C.current=null,oe.current=!1},[]);let V=(0,_.useCallback)(L=>{r||(oe.current=!0,A().unlock({lang:q,speech:f,...L?{prefetch:tt(le.current,e)}:{}}))},[r,A,q,f,e]),T=(0,_.useCallback)(()=>V(S.current),[V]),G=(0,_.useCallback)(()=>{R.current=!1,N(!1)},[]),O=(0,_.useCallback)(()=>{G(),C.current?.stop()},[G]),ve=(0,_.useCallback)(()=>{R.current&&O()},[O]),he=(0,_.useCallback)((L,xe)=>{if(r)return;if(R.current){O();return}let ge=A();ge.stop(),R.current=!0,N(!0);let P=xe?.clip===!1?null:je(le.current,Ve,e);ge.say({url:P,text:L,lang:q,speech:f,onEnd:G})},[r,O,A,e,q,f,G]),K=(0,_.useCallback)(L=>{r||(L?V(!0):O(),o!==null&&Gr(o,L),S.current=L,u(L))},[r,V,O,o]),z=(0,_.useCallback)(()=>K(!S.current),[K]),te=(0,_.useCallback)((L,xe)=>{if(r||!l)return;R.current&&G();let ge=je(le.current,L,e);A().say({url:ge,text:xe,lang:q,speech:f})},[r,l,e,A,q,f,G]);return(0,_.useMemo)(()=>({supported:!r&&h,enabled:!r&&l,setEnabled:K,toggle:z,unlock:T,speakKey:te,stop:O,summary:r?"none":x,summaryPlaying:d,toggleSummary:he,stopSummary:ve}),[r,h,l,K,z,T,te,O,x,d,he,ve])}i(Kr,"ht");s(Kr,"useVoiceGuidance");function zr(e,t,n,r){let{speakKey:a,stop:o,enabled:l}=e,u=(0,_.useRef)(!1);(0,_.useEffect)(()=>{if(!r||!l){u.current&&o(),u.current=!1;return}u.current=!0,nt(t)&&t!==Ve&&n!==""&&a(t,n)},[r,l,t,n,a,o])}i(zr,"vt");s(zr,"useSpeakGuidance");function at(e){switch(e){case"multiple_faces":return"one_face";case"capture_back_camera":return"front_camera";case"capture_front_camera":return"back_camera";case"capture_not_upright":return"upright";case"media_unreadable":case"clip_too_short":return"recording";case"device_integrity_failed":return"device";default:return"face"}}i(at,"Pn");s(at,"retryCoachingOf");var De={face:{title:"capture.retryCoaching.title",tips:["capture.retryCoaching.light","capture.retryCoaching.eyeLevel","capture.retryCoaching.head"]},one_face:{title:"capture.retryTips.title",tips:["capture.retryOneFace.alone","capture.retryOneFace.screens"]},front_camera:{title:"capture.retryTips.title",tips:["capture.retryFrontCamera.screenSide"]},back_camera:{title:"capture.retryTips.title",tips:["capture.retryBackCamera.backSide","capture.retryBackCamera.circle"]},upright:{title:"capture.retryTips.title",tips:["capture.retryUpright.vertical","capture.retryUpright.untilEnd"]},recording:{title:"capture.retryTips.title",tips:["capture.retryRecording.cameraOn","capture.retryRecording.stay","capture.retryRecording.network"]},device:{title:"capture.retryTips.title",tips:["capture.retryDevice.screenRecording","capture.retryDevice.phone"]}};function Zr({showCoaching:e,coaching:t="face",attemptsText:n,showRetake:r,onRetake:a}){let o=Le(),l=(0,st.useRef)(null);return(0,st.useEffect)(()=>{r&&l.current?.focus()},[r]),!e&&!r?null:(0,fe.jsxs)("div",{className:"sekyro-stack sekyro-stack--3","data-testid":"sekyro-captured-panel",children:[e?(0,fe.jsxs)("div",{className:"sekyro-stack sekyro-stack--1",children:[(0,fe.jsx)("p",{className:"sekyro-text-body",children:o(De[t].title)}),(0,fe.jsx)("ul",{className:"sekyro-coaching",children:De[t].tips.map(u=>(0,fe.jsx)("li",{children:o(u)},u))}),n!==null?(0,fe.jsx)("p",{className:"sekyro-text-muted","data-testid":"sekyro-attempts-remaining",children:n}):null]}):null,r?(0,fe.jsx)(X,{ref:l,className:"sekyro-btn--start",onClick:a,children:o("capture.recordAgain")}):null]})}i(Zr,"An");s(Zr,"CapturedPanel");function At(){try{return!1}catch{return!1}}i(At,"tt");s(At,"isDevBuild");var Bn=(0,Qr.createContext)(null);function Wr({state:e}){let t=Le(),[n,r]=(0,it.useState)(!1);(0,it.useEffect)(()=>{e!=="unknown"&&r(!0)},[e]);let a=e==="granted"?(0,we.jsx)(Ir,{}):e==="denied"?(0,we.jsx)(jr,{}):(0,we.jsx)(Ur,{});return(0,we.jsxs)("div",{role:n?"status":void 0,className:`sekyro-permission sekyro-permission--${e}`,"data-testid":"sekyro-permission","data-state":e,children:[(0,we.jsx)("span",{className:"sekyro-permission__icon","aria-hidden":"true",children:a}),(0,we.jsx)("span",{children:t(`capture.permission.${e}`)})]})}i(Wr,"Kn");s(Wr,"PermissionRow");function Yr({voice:e}){let t=Le();if(!e.supported)return null;let n=e.enabled;return(0,Se.jsxs)("button",{type:"button",role:"switch","aria-checked":n,className:"sekyro-switch","data-testid":"sekyro-voice-switch",onClick:i(()=>e.toggle(),"onClick"),children:[(0,Se.jsxs)("span",{className:"sekyro-switch__label",children:[(0,Se.jsx)(rt,{off:!n}),t("capture.voiceGuidance")]}),(0,Se.jsx)("span",{className:"sekyro-switch__track","aria-hidden":"true",children:(0,Se.jsx)("span",{className:"sekyro-switch__thumb",children:n?(0,Se.jsx)(Tr,{className:"sekyro-switch__check"}):null})})]})}i(Yr,"Un");s(Yr,"VoiceSwitch");function Jr({assets:e,onRetryAssets:t,permission:n,captureMode:r="self",voice:a,tips:o,summary:l,startLabel:u,startDisabled:S,onStart:h}){let w=Le(),x=(0,Y.useRef)(l?.stop);x.current=l?.stop,(0,Y.useEffect)(()=>()=>x.current?.(),[]);let I=(0,Y.useRef)(null),d=(0,Y.useRef)(null),N=(0,Y.useRef)(null),R=(0,Y.useRef)(e),p=(0,Y.useRef)(!1);(0,Y.useEffect)(()=>{let f=R.current;if(R.current=e,f===e)return;let F=p.current;e!=="loading"&&(p.current=!1),Xr(I.current)&&(e==="failed"?N.current?.focus():F&&d.current?.focus())},[e]);let j=(0,Y.useCallback)(()=>{p.current=!0,t()},[t]),C=e==="loading",A=C||S,q=(0,Y.useCallback)(()=>{A||(x.current?.(),h())},[A,h]),$;return e==="failed"?$=(0,U.jsxs)(se,{tone:"danger",testId:"sekyro-assets-error",children:[(0,U.jsx)("p",{className:"sekyro-text-body",children:w("fcv2.err.models")}),(0,U.jsx)(X,{kind:"ghost",ref:N,className:"sekyro-btn--start",onClick:j,"data-testid":"sekyro-assets-retry",children:w("common.retry")})]}):$=(0,U.jsxs)("div",{className:"sekyro-stack sekyro-stack--1",children:[(0,U.jsx)(X,{ref:d,full:!0,"data-testid":"sekyro-start","aria-disabled":A?"true":void 0,"aria-busy":C?"true":void 0,onClick:q,children:C?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Pr,{}),w("capture.preparing.title")]}):u??w("capture.start")}),C?(0,U.jsx)("p",{className:"sekyro-text-muted",children:w("capture.preparing.hint")}):null]}),(0,U.jsxs)("div",{ref:I,className:"sekyro-stack sekyro-stack--4","data-testid":"sekyro-intro","data-assets":e,children:[r==="assisted"?(0,U.jsxs)("div",{className:"sekyro-stack sekyro-stack--1","data-testid":"sekyro-assisted-intro",children:[(0,U.jsx)("h2",{className:"sekyro-text-body",children:w("capture.assisted.title")}),(0,U.jsx)("p",{className:"sekyro-text-muted",children:w("capture.assisted.lead")})]}):null,o!==!1?(0,U.jsx)(Or,{tips:o}):null,l!==void 0?(0,U.jsxs)(X,{kind:"ghost",className:"sekyro-btn--start",onClick:l.toggle,"data-testid":"sekyro-tips-listen",children:[(0,U.jsx)(rt,{off:!1}),w(l.playing?"capture.tips.stop":"capture.tips.listen")]}):null,(0,U.jsx)(Wr,{state:n}),(0,U.jsx)(Yr,{voice:a}),(0,U.jsx)("p",{className:"sekyro-text-muted",children:w("capture.securityNote")}),$,(0,U.jsx)("p",{role:"status",className:"sekyro-visually-hidden","data-testid":"sekyro-intro-status",children:e==="loading"?w("capture.preparing.title"):e==="ready"?w("capture.ready"):""})]})}i(Jr,"Gn");s(Jr,"PreCaptureScreen");function Xr(e){if(typeof document>"u")return!1;let t=document.activeElement;return t===null||t===document.body||e!==null&&e.contains(t)}i(Xr,"Or");s(Xr,"focusIsOurs");function en(){let[e,t]=(0,ot.useState)({state:"unknown",settled:!1});return(0,ot.useEffect)(()=>ir(n=>t({state:n,settled:!0})),[]),{permission:e.state,permissionSettled:e.settled}}i(en,"Fn");s(en,"useCameraStatus");function tn(e){return Et(e,"mobileRequired")}i(tn,"qn");s(tn,"useMobileRequired");function rn(e){return Et(e,"returning").required}i(rn,"Dn");s(rn,"useReturning");function Et(e,t){let[n,r]=(0,pe.useState)({required:!1,settled:e===void 0});return(0,pe.useEffect)(()=>{let a=e?.[t];if(e===void 0||typeof a!="function"){r({required:!1,settled:!0});return}let o=!0;return r({required:!1,settled:!1}),Promise.resolve().then(()=>a.call(e)).then(l=>{o&&r({required:l===!0,settled:!0})},()=>{o&&r({required:!1,settled:!0})}),()=>{o=!1}},[e,t]),n}i(Et,"jn");s(Et,"useFlag");function nn(e){let t=s(()=>e?.captureChoice??null,"initialChoice"),[n,r]=(0,pe.useState)(()=>({session:"self",choice:t(),settled:e===void 0}));(0,pe.useEffect)(()=>{let o=e?.captureMode,l=e?.captureChoice??null;if(e===void 0||typeof o!="function"){r({session:"self",choice:l,settled:!0});return}let u=!0;return r({session:"self",choice:l,settled:!1}),Promise.resolve().then(()=>o.call(e)).then(S=>{let h=e.captureChoice??null;u&&r({session:h!==null&&S===h?"choice":S==="assisted"||S==="choice"?S:"self",choice:h,settled:!0})},()=>{u&&r({session:"self",choice:null,settled:!0})}),()=>{u=!1}},[e]);let a=(0,pe.useCallback)(o=>{e?.chooseCaptureMode?.(o),r(l=>({...l,choice:o}))},[e]);return{mode:n.session==="choice"?n.choice??"self":n.session==="assisted"?"assisted":"self",session:n.session,choice:n.choice,settled:n.settled,choose:a}}i(nn,"$n");s(nn,"useCaptureMode");function sn(e){let[t,n]=(0,pe.useState)(!1);return(0,pe.useEffect)(()=>{if(n(!1),e===void 0)return;let r=e.on("busy",()=>n(!0)),a=e.on("result",()=>n(!1));return()=>{r(),a()}},[e]),t}i(sn,"zn");s(sn,"useBusy");var qn=s(()=>"idle","serverSnapshot");function xt(e){return or(e!==void 0?{assetBaseUrl:e}:{})}i(xt,"Wn");s(xt,"preload");function an(e,t=!0){let n=(0,Q.useSyncExternalStore)((0,Q.useCallback)(h=>cr(h,e),[e]),()=>lr(e),qn),[r,a]=(0,Q.useState)(null),o=(0,Q.useRef)(!1),l=(0,Q.useCallback)(()=>{xt(e).then(h=>{o.current&&h==="idle"&&a({base:e})})},[e]);(0,Q.useEffect)(()=>(o.current=!0,l(),()=>{o.current=!1}),[l]);let u=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{if(n!=="idle"){u.current={base:e};return}!t||u.current===null||u.current.base!==e||(u.current=null,l())},[n,e,l,t]);let S=(0,Q.useCallback)(()=>{xt(e)},[e]);return{gate:r!==null&&r.base===e&&n==="idle"||n==="ready"?"ready":n==="failed"?"failed":"loading",retry:S}}i(an,"Qn");s(an,"useLivenessAssets");var Nr={progress:0,hint:null,faceDetected:!1};function on(e){let{videoRef:t,assetBaseUrl:n}=e,r=(0,M.useRef)(e.verification).current,a=(0,M.useRef)(!1);e.verification!==r&&!a.current&&At()&&(a.current=!0,console.warn("[@sekyro/react] <LivenessCapture>: the `verification` prop changed identity after mount. The first instance stays bound (the camera is not rebuilt); create the verification once (useMemo / useState / outside render) instead of on every render."));let o=(0,M.useRef)(null),[l,u]=(0,M.useState)("idle"),[S,h]=(0,M.useState)(Nr),[w,x]=(0,M.useState)(!1),[I,d]=(0,M.useState)(!1),[N,R]=(0,M.useState)(null),[p,j]=(0,M.useState)(!1),[C,A]=(0,M.useState)(null),[q,$]=(0,M.useState)(null),[f,F]=(0,M.useState)(null),[oe,le]=(0,M.useState)(null),[c,V]=(0,M.useState)(null),[T,G]=(0,M.useState)(!1),O=(0,M.useRef)(null),ve=(0,M.useRef)("idle"),he=(0,M.useRef)(-1),[K,z]=(0,M.useState)(0),te=(0,M.useRef)(e);te.current=e,(0,M.useEffect)(()=>{let J=t.current;if(J===null)return;let ce={video:J,...n!==void 0?{assetBaseUrl:n}:{}},H=r!==void 0?r.liveness(ce):ur(ce);o.current=H;let Ne=s(()=>V(H.facingMode??null),"readFacing");Ne();let $e=[H.on("state",b=>{b==="mode_switch"?G(!0):b!=="starting"&&b!=="gating"&&G(!1),b==="starting"?(ve.current!=="starting"&&(he.current+=1,z(Math.max(0,he.current))),$(null),F(null),h(Nr),d(!1),x(!1),R(null),A(null),O.current=null):b==="gating"&&ve.current==="recording"&&(d(!1),x(!1),R(null),O.current=null),ve.current=b,Ne(),u(b),te.current.onStateChange?.(b)}),H.on("gate",b=>{let ke=O.current;O.current=b.progress,x(ke!==null&&b.progress<ke-.001&&b.progress>0&&b.progress<1),b.progress>=1&&d(!0),h(b)}),H.on("frozen",({previewDataUrl:b})=>R(b)),H.on("profile",({animations:b})=>j(b==="reduced")),H.on("ramp",({colour:b})=>A(b)),H.on("captured",b=>{$(b),le(null),te.current.onCaptured?.(b)}),H.on("error",b=>{F(b);let ke=r?.reportCaptureIssue;ke!==void 0&&bt(Ee=>ke.call(r,Ee),Sr("liveness",b,Math.max(0,he.current))),te.current.onError?.(b)}),r?.on("result",b=>{le(b),te.current.onResult?.(b)})];return()=>{for(let b of $e)b?.();o.current=null,H.destroy()}},[r,t,n]);let L=(0,M.useCallback)(()=>{o.current?.start()},[]),xe=(0,M.useCallback)(()=>{o.current?.retry()},[]),ge=(0,M.useCallback)(async()=>{let J=o.current;return J===null||typeof J.canSwitchCaptureMode!="function"?!1:await J.canSwitchCaptureMode().catch(()=>!1)===!0},[]),P=(0,M.useCallback)(async J=>{let ce=o.current;if(ce===null||typeof ce.setCaptureMode!="function")return!1;let H=await ce.setCaptureMode(J).catch(()=>!1)===!0;return H&&V(ce.facingMode??null),H},[]);return{state:l,gate:S,draining:w,gateLocked:I,frozenPreview:N,reduceMotion:p,rampColour:C,artifacts:q,error:f,result:oe,facingMode:c,start:L,retry:xe,canSwitchCaptureMode:ge,setCaptureMode:P,modeRestarted:T,attempt:K}}i(on,"Xn");s(on,"useLivenessHandle");var Vn=new Set(["national_number"]);function Nt(e){if(e==null||!e.available||e.selected!==null)return null;let t=e.options.filter(n=>Vn.has(n));return t.length>0?{...e,options:t}:null}i(Nt,"er");s(Nt,"pending");function ln(e){let[t,n]=(0,me.useState)(null),[r,a]=(0,me.useState)(e===void 0),[o,l]=(0,me.useState)(!1),[u,S]=(0,me.useState)(!1);(0,me.useEffect)(()=>{if(n(null),e===void 0){a(!0);return}let x=!0,I=e.methodChoice;typeof I=="function"?(a(!1),Promise.resolve().then(()=>I.call(e)).then(N=>{x&&n(Nt(N))},()=>{}).finally(()=>{x&&a(!0)})):a(!0);let d=e.on("method",N=>n(Nt(N)));return()=>{x=!1,d()}},[e]);let h=(0,me.useCallback)(async x=>{if(e===void 0)return!1;l(!0),S(!1);try{return await e.selectMethod(x),n(null),!0}catch{return S(!0),!1}finally{l(!1)}},[e]),w=t!==null&&t.options.length===1?t.options[0]:null;return{choice:t,auto:w==="national_number"&&!u?w:null,settled:r,busy:o,failed:u,select:h}}i(ln,"tr");s(ln,"useMethodChoice");var Hn=["ar","fr","en"];function cn(e){if(typeof e!="string")return!1;try{let t=new URL(e);return t.protocol==="https:"||t.protocol==="http:"&&/^(localhost|127\.0\.0\.1)$/.test(t.hostname)}catch{return!1}}i(cn,"oo");s(cn,"isClipUrl");function un(e){let t=e.clips;if(typeof t!="object"||t===null)return null;let n={};for(let r of Hn){let a=t[r];if(!(typeof a!="object"||a===null))for(let[o,l]of Object.entries(a))!nt(o)||!cn(l)||((n[r]??(n[r]={}))[o]=l)}return Object.keys(n).length>0?n:null}i(un,"so");s(un,"toVoiceClipMap");function dn(e){let[t,n]=(0,Te.useState)(null);(0,Te.useEffect)(()=>{if(n(null),e===void 0)return;let a=!0,o=s(u=>{if(!a)return;let S=typeof u=="object"&&u!==null&&typeof u.setId=="string"?u:null;n(h=>h?.setId===S?.setId?h:S)},"take");try{typeof e.voiceClips=="function"&&Promise.resolve(e.voiceClips()).then(o,()=>o(null))}catch{o(null)}let l=e.on("view",u=>o(u.voice));return()=>{a=!1,l()}},[e]);let r=(0,Te.useMemo)(()=>t!==null?un(t):null,[t]);return e===void 0?null:r}i(dn,"nr");s(dn,"useServerVoiceClips");function pn({voice:e}){let t=Le();return(0,Mt.jsx)(X,{kind:"chip","aria-pressed":e.enabled,"aria-label":t("capture.voiceGuidance"),"data-testid":"sekyro-voice-toggle",onClick:i(()=>e.toggle(),"onClick"),children:(0,Mt.jsx)(rt,{off:!e.enabled,className:"sekyro-icon"})})}i(pn,"or");s(pn,"VoiceChip");var Dn=new Set(["abandoned","not_opened","cancelled","superseded"]),$n=800;function hn(e){return e===void 0||e!==!1&&e.length===Ct.length&&Ct.every(t=>e.includes(t))}i(hn,"uo");s(hn,"isDefaultTips");function fn(e){if(e.type==="keydown"&&e.key==="Escape")return!1;let t=globalThis.navigator?.userActivation;return t===void 0?!(e.type==="pointerup"&&e.pointerType==="touch"):t.isActive}i(fn,"po");s(fn,"carriesActivation");function mn(e){return typeof e=="object"&&e!==null&&!(0,y.isValidElement)(e)&&"tone"in e&&"text"in e}i(mn,"fo");s(mn,"isNoticeObject");var Fn=new Set(["nni_unbound","id_number_unbound","method_required","mobile_required","portrait_required"]);function yn(e){return e==="starting"||e==="gating"||e==="recording"||e==="mode_switch"}i(yn,"yo");s(yn,"isCapturing");function vn(e){return e==="captured"||e==="uploading"||e==="checking"}i(vn,"go");s(vn,"isPostCapture");function Gn({verification:e,locale:t,dir:n,strings:r,slots:a,autoStart:o=!1,notice:l,startDisabled:u=!1,startLabel:S,tips:h,tipsSummary:w,coach:x,voice:I,onGuidance:d,onCaptured:N,onResult:R,onError:p,onStateChange:j,assetBaseUrl:C,className:A}){let q=yr(t),$=(0,y.useMemo)(()=>mr(t,r),[t,r,q]),f=(0,y.useMemo)(()=>g=>$[g]??"",[$]),F=n??(t==="ar"?"rtl":"ltr"),oe=(0,y.useRef)(null),le=(0,y.useContext)(Bn),c=on({verification:e,videoRef:oe,assetBaseUrl:C,onCaptured:N,onResult:R,onError:p,onStateChange:j}),V=an(C,c.state==="idle"&&c.error===null),T=ln(e),G=T.choice!==null,O=tn(e),ve=rn(e),he=sn(e),K=en(),z=nn(e),te=z.session==="choice",L=z.mode==="assisted",xe=I!==!1&&I?.clips===void 0,ge=dn(xe?e:void 0),P=Kr({locale:t,defaultClips:ge,options:I}),J=L?"environment":"user",ce=z.settled,H=(0,y.useRef)(null),Ne=(0,y.useRef)(!1),$e=(0,y.useRef)(P.unlock);$e.current=P.unlock,(0,y.useEffect)(()=>{let g=H.current;if(g===null)return;let ne=["pointerup","touchend","click","keydown"],Ce=s(()=>{for(let qe of ne)g.removeEventListener(qe,Re,!0)},"disarm");function Re(qe){if(Ne.current){Ce();return}fn(qe)&&(Ne.current=!0,Ce(),$e.current())}i(Re,"Re"),s(Re,"onGesture");for(let qe of ne)g.addEventListener(qe,Re,{capture:!0,passive:!0});return Ce},[]);let b=(0,y.useCallback)(()=>{Ne.current||(Ne.current=!0,P.unlock()),c.start()},[P.unlock,c.start]),ke=(0,y.useCallback)(()=>c.start(),[c.start]),Ee=(0,y.useRef)(!1),Pe=c.state==="idle"&&c.error===null,Ut=!G&&!O.required&&(o===!0||o==="when-permitted"&&K.permission==="granted"),jt=Ut&&T.settled&&O.settled&&ce,bn=o==="when-permitted"&&!K.permissionSettled&&!Ee.current,Tt=Ut&&Pe&&!Ee.current,ct=(bn||Tt||!ce)&&V.gate==="ready"?"loading":V.gate;(0,y.useEffect)(()=>{!jt||!Pe||V.gate!=="ready"||Ee.current||(Ee.current=!0,ke())},[jt,Pe,V.gate,ke]);let _n=Pe&&!G&&!O.required&&!(Tt&&V.gate==="ready"),[Pt,Ot]=(0,y.useState)(!1),{canSwitchCaptureMode:Bt,setCaptureMode:qt}=c;(0,y.useEffect)(()=>{if(!z.settled||!te){Ot(!1);return}let g=!0;return Bt().then(ne=>{g&&Ot(ne)}),()=>{g=!1}},[z.settled,te,Bt]);let{choose:Vt}=z,Ie=L?"self":"assisted",Cn=(0,y.useCallback)(async()=>{await qt(Ie)&&Vt(Ie)},[qt,Vt,Ie]),Ht=c.state!=="idle"&&c.facingMode!==null?c.facingMode:J;(0,y.useEffect)(()=>{let g=oe.current?.style;Ht==="user"?g?.removeProperty("transform"):g&&(g.transform="none")},[Ht]);let Fe=(0,y.useMemo)(()=>c.artifacts!==null&&typeof URL.createObjectURL=="function"?URL.createObjectURL(c.artifacts.keyframe):null,[c.artifacts]);(0,y.useEffect)(()=>{if(Fe!==null)return()=>URL.revokeObjectURL(Fe)},[Fe]);let Dt=c.frozenPreview??Fe,Ue=e!==void 0,Z=yn(c.state),be=vn(c.state),Ge=Z||be,re=c.result,$t=c.state==="done"&&re!==null,ut=c.state==="recording"&&c.frozenPreview!==null,Ke=le!==null,Ft=Pt&&Z&&!ut?{to:Ie,label:f(Ie==="assisted"?"capture.modeSwitch.toAssisted":"capture.modeSwitch.toSelf"),description:f(Ie==="assisted"?"capture.modeSwitch.toAssistedLabel":"capture.modeSwitch.toSelfLabel"),onSwitch:s(()=>{Cn()},"onSwitch")}:null,ze=c.modeRestarted&&Z?f("capture.modeSwitch.restarted"):null,Oe=be||ut,Gt=be?"checking":ut?"frozen":c.state==="recording"?"recording":c.gateLocked||c.gate.progress>=1?"locked":c.gate.faceDetected?"aligning":"seeking",Ze=Z?c.gate.hint:null,Qe=c.state==="starting"?"capture.preparing.title":Ze===null?null:Ze==="center"&&!c.gate.faceDetected?"fcv3.no_face":dr(Ze),[wn,Kt]=(0,y.useState)(null);(0,y.useEffect)(()=>{if(Qe!=="fcv3.no_face"){Kt(Qe);return}if(!Z)return;let g=setTimeout(()=>Kt(Qe),$n);return()=>clearTimeout(g)},[Qe,Z]);let dt=Z&&typeof x=="string"&&x!=="",zt=L&&Z?f("capture.assisted.stage"):null,Me=Z&&!dt?wn:null,pt=dt?x:Me===null?"":f(Me);zr(P,Me,pt,Z);let Zt=(0,y.useRef)(d);Zt.current=d,(0,y.useEffect)(()=>{if(nt(Me))try{Zt.current?.(Me)}catch(g){console.error("[@sekyro/react] onGuidance threw:",g)}},[Me]);let Be=(0,y.useMemo)(()=>({supported:P.supported,enabled:P.enabled,setEnabled:P.setEnabled,toggle:P.toggle}),[P.supported,P.enabled,P.setEnabled,P.toggle]),ht=a?.voicePrompt,Qt=ht!==void 0,Wt=I===void 0,Yt=(0,y.useRef)(!1);(0,y.useEffect)(()=>{!Qt||!Wt||Yt.current||!At()||(Yt.current=!0,console.warn("[@sekyro/react] <LivenessCapture>: `slots.voicePrompt` is set and `voice` is undefined, so the component speaks the guidance itself. If your slot plays audio, pass voice={false} or the person hears every hint twice; pass voice={{}} to keep the built-in voice and silence this warning."))},[Qt,Wt]);let Sn=ht!==void 0?(g,ne,Ce)=>ht(g,ne,Ce,Be):P.supported?()=>(0,k.jsx)(pn,{voice:Be}):void 0,{summary:ft,summaryPlaying:Jt,toggleSummary:Xt,stopSummary:er}=P,We=w!==void 0&&w!=="",tr=We?w:f("capture.tips.summary"),rr=We?ft!=="none":ft==="partner"||ft==="default"&&hn(h),xn=(0,y.useMemo)(()=>rr?{playing:Jt,toggle:s(()=>Xt(tr,{clip:!We}),"toggle"),stop:er}:void 0,[rr,Jt,Xt,tr,er,We]),Nn=(0,y.useMemo)(()=>({assets:ct,retryAssets:V.retry,permission:K.permission,permissionSettled:K.permissionSettled,captureMode:z.mode,facing:J,voice:Be}),[ct,V.retry,K.permission,K.permissionSettled,z.mode,J,Be]),Mn=mn(l)?(0,k.jsx)(se,{tone:l.tone,testId:"sekyro-host-notice",children:(0,k.jsx)("span",{children:l.text})}):l??null,ue=re!==null&&re.status==="retry"?re:null,W=$t&&re.status==="unavailable"&&!G&&re.reasonCode!=="portrait_required"?re:null,_e=$t&&(re.status==="verified"||re.status==="not_verified"||re.status==="review")?re:null,mt=s((g,ne)=>{if(g===void 0)return null;if(g==="device_cooldown"){let Re=hr(t,ne);if(Re!==null)return f(Re.key).replace("{time}",Re.time)}let Ce=Xe(g);return Ce===null?null:f(Ce)},"reasonText"),yt=s(g=>{let ne=g.retakeHint===void 0?null:Je(g.retakeHint);return ne===null?mt(g.reasonCode):f(ne)},"retryText"),nr=_e===null?null:mt(_e.reasonCode,_e.retryAfter)??(_e.status==="not_verified"&&_e.reason!==void 0&&Dn.has(_e.reason)?f("errors.session_expired"):null),Rn=W!==null&&W.reasonCode!==void 0&&W.reasonCode!=="nni_unbound"&&W.reasonCode!=="id_number_unbound"&&W.reasonCode!=="method_required"&&W.reasonCode!=="mobile_required"&&!(W.reasonCode==="no_recorder"&&c.artifacts?.degraded==="NO_RECORDER"),Ye=W?.reasonCode,sr=c.attempt;(0,y.useEffect)(()=>{W===null||Ye===void 0||e?.reportCaptureIssue===void 0||Fn.has(Ye)||bt(g=>e.reportCaptureIssue?.(g),{check:"liveness",kind:"unavailable",phase:"upload",engineKind:Ye,attempt:Math.min(1e3,sr)})},[W,Ye,sr,e]);let ar=kt(),Ln=G&&T.auto===null&&!Z&&!be&&c.error===null,vt=(0,y.useCallback)(async g=>{await T.select(g)&&c.state==="done"&&c.retry()},[T.select,c.state,c.retry]);return(0,y.useEffect)(()=>{T.auto!==null&&!T.busy&&!Z&&!be&&vt(T.auto)},[T.auto,T.busy,Z,be,vt]),(0,k.jsx)(vr,{value:f,children:(0,k.jsxs)("div",{ref:H,className:A===void 0?"sekyro-capture":`sekyro-capture ${A}`,dir:F,lang:t,"data-testid":"sekyro-liveness-capture","data-state":c.state,children:[a?.header,ue!==null&&yt(ue)!==null&&!(Ke&&Ge)?(0,k.jsx)(se,{tone:"warning",role:"status",testId:"sekyro-retry-notice",children:(0,k.jsx)("span",{children:yt(ue)})}):null,ze!==null&&!Ke?(0,k.jsx)(se,{tone:"info",role:"status",testId:"sekyro-mode-switch-status",children:(0,k.jsx)("span",{children:ze})}):null,he&&be&&!Ke?(0,k.jsx)(se,{tone:"info",role:"status",testId:"sekyro-busy-notice",children:(0,k.jsx)("span",{children:f("capture.busy")})}):null,O.required&&Pe?(0,k.jsx)(se,{tone:"info",role:"status",testId:"sekyro-mobile-required",children:(0,k.jsx)("span",{children:f("reasons.mobile_required")})}):null,c.error!==null?a?.errorPanel!==void 0?a.errorPanel(c.error,c.retry):(0,k.jsxs)(se,{tone:"danger",testId:"sekyro-error-notice",children:[(0,k.jsx)("span",{children:f(pr(c.error))}),c.error.retryable?(0,k.jsx)(X,{ref:ar,kind:"ghost",className:"sekyro-btn--start",onClick:c.retry,children:f("common.retry")}):null]}):null,W!==null?(0,k.jsxs)(se,{tone:"danger",testId:"sekyro-unavailable-notice",children:[(0,k.jsx)("span",{children:mt(W.reasonCode)??f(W.reasonCode===void 0?"errors.session_expired":"errors.network_error")}),Rn?(0,k.jsx)(X,{ref:ar,kind:"ghost",className:"sekyro-btn--start",onClick:c.retry,children:f("capture.recordAgain")}):null]}):null,nr!==null&&_e!==null?(0,k.jsx)(se,{tone:_e.status==="not_verified"?"danger":"info",testId:"sekyro-result-notice",children:(0,k.jsx)("span",{children:nr})}):null,(0,k.jsx)("div",{className:Ge?void 0:"sekyro-hidden","data-capture-live":Ge?"":void 0,children:Ke?le({videoRef:oe,guidance:Oe&&Ue?f("capture.checking"):pt,coached:dt&&!(Oe&&Ue),note:Oe?Ue?f(he?"capture.busy":"capture.checkingHint"):null:ze??(ue!==null?yt(ue):zt),settled:Oe&&Ue,progress:c.gate.progress,phase:Gt,still:Oe?Dt:null,live:Ge,modeSwitch:Ft,...Pt?{status:ze}:{},ramp:c.rampColour===null?null:{colour:c.rampColour}}):(0,k.jsx)(gr,{videoRef:oe,guidanceText:pt,guidanceHint:Ze,guidanceKey:Me,progress:c.gate.progress,phase:Gt,draining:c.draining,stillUrl:Dt,showChecking:Ue,operatorText:zt,voicePrompt:Sn,overlay:i(g=>(0,k.jsxs)(k.Fragment,{children:[a?.stageOverlay?.(g),(0,k.jsx)(kr,{colour:c.rampColour})]}),"overlay"),reduceMotion:c.reduceMotion,modeSwitch:Ft})}),Ln&&T.choice!==null?(0,k.jsx)(Br,{title:f("method.title"),description:f("method.description"),options:T.choice.options.map(g=>({id:g,label:f(`method.${g}`)})),busy:T.busy,error:T.failed?f("errors.network_error"):null,focus:c.state==="done",testId:"sekyro-method",look:"buttons",onChoose:i(g=>{vt(g)},"onChoose")}):null,_n?(0,k.jsxs)(k.Fragment,{children:[ve&&a?.header===void 0&&a?.intro===void 0?(0,k.jsxs)("div",{className:"sekyro-stack sekyro-stack--1",children:[(0,k.jsx)("h2",{className:"sekyro-text-body",children:f("returning.title")}),(0,k.jsx)("p",{className:"sekyro-text-muted",children:f("returning.description")})]}):null,Mn,a?.intro!==void 0?a.intro(b,Nn):(0,k.jsx)(Jr,{assets:ct,onRetryAssets:V.retry,permission:K.permission,captureMode:z.mode,voice:Be,tips:h??Ct,summary:xn,startLabel:S,startDisabled:u,onStart:b})]}):null,(0,k.jsx)(Zr,{showCoaching:ue!==null,coaching:at(ue?.reasonCode),attemptsText:ue?.attemptsRemaining!==void 0?fr($,t,ue.attemptsRemaining):null,showRetake:ue!==null&&!Z&&!be||!Ue&&c.state==="captured",onRetake:c.retry}),a?.footer]})})}i(Gn,"_i");s(Gn,"LivenessCapture");var It=E(D(),1),lt=E(D(),1),m=E(de(),1);var ks={document:"card",population_registry:"id",national_eid:"smartphone",phone_otp:"phone",email_otp:"email"};function Kn(e,t){switch(e.service){case"document":return t.t("method.document_photo");case"population_registry":return t.t("method.national_number");case"national_eid":{let n=e.nationalEid?.providerName;return n?t.t("method.national_eid",{provider:n}):t.t("method.national_eidGeneric")}default:return null}}i(Kn,"Y");s(Kn,"identityLabel");function zn(e,t){let[n,r]=(0,It.useState)(!1),[a,o]=(0,It.useState)(null);return{busy:n,error:a,run:s(l=>{r(!0),o(null),l().then(()=>r(!1),u=>{r(!1),o(e.t(xr(u,e.strings))),t?.(u)})},"run")}}i(zn,"q");s(zn,"useChoiceAction");function gn(){let e=`sekyro-face-light-${(0,lt.useId)().replace(/[^A-Za-z0-9_-]/g,"")}`;return(0,m.jsxs)("svg",{className:"sekyro-mark sekyro-mark--face",viewBox:"0 0 168 206","aria-hidden":"true",focusable:"false",children:[(0,m.jsx)("defs",{children:(0,m.jsx)("mask",{id:e,children:(0,m.jsx)("ellipse",{className:"sekyro-mark__arc",cx:"84",cy:"103",rx:"76",ry:"95",pathLength:"1",fill:"none",stroke:"#fff",strokeWidth:"16"})})}),(0,m.jsx)("ellipse",{cx:"84",cy:"103",rx:"64",ry:"83",fill:"none",className:"sekyro-mark__line"}),(0,m.jsx)("path",{className:"sekyro-mark__face",d:"M68 64v10M100 64v10M84 66v25q0 2-6 1M60 108q24 18 48 0"}),(0,m.jsx)("ellipse",{className:"sekyro-mark__ticks",cx:"84",cy:"103",rx:"76",ry:"95",pathLength:"56"}),(0,m.jsx)("ellipse",{className:"sekyro-mark__ticks sekyro-mark__ticks--light",cx:"84",cy:"103",rx:"76",ry:"95",pathLength:"56",mask:`url(#${e})`})]})}i(gn,"O");s(gn,"FaceMark");var Zn={glasses:"jGlasses",lighting:"light",faceCamera:"camera"};function Qn(e){if(!(e?.kind!=="liveness"||e.reason===void 0))return{reason:e.reason,...e.retakeHint!==void 0?{retakeHint:e.retakeHint}:{},attemptsRemaining:e.attemptsRemaining??0,attemptsExhausted:e.attemptsExhausted===!0}}i(Qn,"te");s(Qn,"faceIntroRetryOf");var Wn={"capture.retryFrontCamera.screenSide":"camera","capture.retryBackCamera.backSide":"camera","capture.retryUpright.vertical":"smartphone","capture.retryUpright.untilEnd":"smartphone","capture.retryRecording.cameraOn":"camera","capture.retryRecording.stay":"smartphone","capture.retryRecording.network":"smartphone","capture.retryDevice.screenRecording":"smartphone","capture.retryDevice.phone":"smartphone"};function Yn({start:e,context:t,tips:n,tipsTitle:r,human:a=!1,returning:o=!1,notice:l,retry:u}){let S=_t(),{t:h}=S,w=u===void 0?"face":at(u.reason),x=w==="face"?null:De[w].tips,I=(0,lt.useContext)(_r)?.busy===!0;return(0,m.jsxs)("section",{className:"sekyro-step",children:[(0,m.jsx)(gn,{}),t.captureMode==="assisted"?(0,m.jsx)(et,{title:h("capture.assisted.heading"),lead:h("capture.assisted.lead")}):o?(0,m.jsx)(et,{title:h("returning.heading"),lead:h("returning.description")}):(0,m.jsx)(et,{title:h(a?"native.face.humanIntroTitle":"native.face.introTitle"),lead:h(a?"native.face.humanIntroLead":"native.face.introLead")}),u!==void 0?(0,m.jsx)(kn,{retry:u,title:De[w].title}):null,r!==void 0&&x===null?(0,m.jsx)("p",{className:"sekyro-section-label",children:r}):null,(0,m.jsx)("ul",{className:"sekyro-tiprows",children:x!==null?x.map(d=>(0,m.jsxs)("li",{children:[(0,m.jsx)(Ae,{name:Wn[d]??"face"}),h(d)]},d)):n!==void 0?n.map(d=>(0,m.jsxs)("li",{children:[(0,m.jsx)(Ae,{name:Zn[d.id]??"face"}),d.text]},d.id)):(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)("li",{children:[(0,m.jsx)(Ae,{name:"light"}),h("capture.tips.light")]}),(0,m.jsxs)("li",{children:[(0,m.jsx)(Ae,{name:"jGlasses"}),h("capture.tips.uncover")]}),(0,m.jsxs)("li",{children:[(0,m.jsx)(Ae,{name:"smartphone"}),h("capture.tips.eyeLevel")]})]})}),l??null,l!==void 0?null:t.assets==="failed"?(0,m.jsx)(X,{kind:"secondary",full:!0,onClick:t.retryAssets,children:h("common.retry")}):null,l!==void 0?null:(0,m.jsx)(br,{children:(0,m.jsxs)(X,{full:!0,disabled:t.assets!=="ready"||I,"aria-busy":t.assets==="loading"||void 0,onClick:e,children:[(0,m.jsx)(Ae,{name:"camera"}),h("capture.start")]})})]})}i(Yn,"ne");s(Yn,"FaceIntro");var Jn=new Set(["match_inconclusive","no_face_source","below_threshold"]);function kn({retry:e,title:t}){let n=_t(),r=e.retakeHint===void 0?null:Je(e.retakeHint),a=e.reason==="probe_not_from_liveness"?"capture.retrySamePerson.message":Jn.has(e.reason)?"capture.retryMatch.message":Xe(e.reason);return(0,m.jsxs)(Cr,{tone:"warning",children:[r!==null?(0,m.jsx)("span",{children:n.t(r)}):a!==null?(0,m.jsx)("span",{children:n.t(a)}):null,r===null?(0,m.jsx)("span",{children:n.t(t)}):null,(0,m.jsx)("span",{children:wr(n,e.attemptsRemaining,e.attemptsExhausted)})]})}i(kn,"T");s(kn,"RetryNotice");function Xn(e){return gt(e)}i(Xn,"se");s(Xn,"isInAppBrowser");function es(e,t){let n=t??(typeof navigator>"u"?"":String(navigator.userAgent??""));if(!/Android/i.test(n))return null;let r;try{r=new URL(e)}catch{return null}if(r.protocol!=="https:"&&r.protocol!=="http:")return null;let a=r.protocol.slice(0,-1);return`intent://${r.host}${r.pathname}${r.search}#Intent;scheme=${a};action=android.intent.action.VIEW;S.browser_fallback_url=${encodeURIComponent(e)};end`}i(es,"ce");s(es,"androidBrowserIntent");export{Br as a,At as b,Bn as c,nn as d,Gn as e,ks as f,Kn as g,zn as h,Qn as i,Yn as j,Xn as k,es as l};
@@ -0,0 +1 @@
1
+ import{b as N}from"./chunk-ET7NCKUV.js";import{a as c}from"./chunk-4FHWXBOB.js";var E=2;function k(a){let u=a.tuning,s=a.now??(()=>performance.now()),l=null,r=!1,g=!1,f=Number.NEGATIVE_INFINITY,m=null,x=0,i=null,t=null,T=0,d=!1,y=c(()=>{if(d||!u.enabled)return;d=!0;let n=(a.createSegmenter??(e=>import("./segmenter-3CVPTZMM-WGI6XGWN.js").then(o=>o.createSelfieSegmenter(e))))(a.assetBaseUrl);t=setTimeout(()=>{l===null&&(r=!0)},u.segmenterTimeoutMs),n.then(e=>{t!==null&&clearTimeout(t),g||r?e.close():l=e},()=>{t!==null&&clearTimeout(t),r=!0})},"T");return{measure(n,e,o,B){if(!u.enabled||n.pixels===null)return null;y();let h=s();if(h-f<1e3/u.hz)return m;f=h;let p=n.width/Math.max(1,o),w=n.height/Math.max(1,B),S={x:e.x*p,y:e.y*w,width:e.width*p,height:e.height*w},M=null;if(l!==null&&!r){let b=Math.max(h,x+1);x=b;let A=s();M=l.segment(n.source,b);let I=s()-A;T+=1,T>E&&(i=i===null?I:i*.7+I*.3),i!==null&&i>u.segmenterBudgetMs&&(r=!0,l.close(),l=null)}return m=N(n.pixels,S,M,u),m},close(){g=!0,t!==null&&clearTimeout(t),l?.close(),l=null}}}c(k,"L");export{k as a};
@@ -0,0 +1 @@
1
+ import{a as j,b as ge,c as me,i as fe}from"./chunk-HDJ6JFXX.js";import{b as ye}from"./chunk-T4M2J44L.js";import{d as we}from"./chunk-FAIDO3QL.js";import{a as pe}from"./chunk-IBOJTLL7.js";import{d as re,e as le,g as oe,h as W,i as se,j as ue,k as z,l as de}from"./chunk-D334IAZJ.js";import{g as _,i as he,j as ce}from"./chunk-RRLXNT33.js";import{a as s}from"./chunk-4FHWXBOB.js";var Ee=250,Ie=180,Ue=96;function qe(i){let{data:t,width:e,height:a}=i,n=new Uint8Array(e*a);for(let r=0,o=0;r<n.length;r+=1,o+=4)n[r]=Math.round(.299*(t[o]??0)+.587*(t[o+1]??0)+.114*(t[o+2]??0));return{data:n,width:e,height:a}}s(qe,"xe");function G(i,t){return{x0:Math.max(0,Math.floor(i.x)),y0:Math.max(0,Math.floor(i.y)),x1:Math.min(t.width,Math.ceil(i.x+i.width)),y1:Math.min(t.height,Math.ceil(i.y+i.height))}}s(G,"W");function q(i,t,e){let a=G(t,i),n=e===void 0?null:G(e,i),r=0,o=0,c=0,g=0;for(let u=a.y0;u<a.y1;u+=1)for(let x=a.x0;x<a.x1;x+=1){if(n!==null&&x>=n.x0&&x<n.x1&&u>=n.y0&&u<n.y1)continue;let D=i.data[u*i.width+x];r+=1,o+=D,c+=D*D,D>=Ee&&(g+=1)}if(r===0)return{mean:0,sd:0,clipped:0,count:0};let d=o/r;return{mean:d,sd:Math.sqrt(Math.max(0,c/r-d*d)),clipped:g/r,count:r}}s(q,"T");function xe(i){let{box:t}=i,e=(i.leftEye.y+i.rightEye.y)/2-.1*t.height,a=t.y+.85*t.height;return{x:t.x+.15*t.width,y:e,width:.7*t.width,height:Math.max(1,a-e)}}s(xe,"ve");function Be(i,t){let e=xe(t),a=q(i,e);if(a.count===0)return null;let n=Math.min(Math.max(t.nose.x,e.x+1),e.x+e.width-1),r=q(i,{x:e.x,y:e.y,width:n-e.x,height:e.height}),o=q(i,{x:n,y:e.y,width:e.x+e.width-n,height:e.height}),c=o.mean>0?r.mean/o.mean:r.mean>0?Number.POSITIVE_INFINITY:1;return{faceLuma:a.mean,halfRatio:c,clipped:a.clipped}}s(Be,"Be");function Fe(i,t){let e=0,a=0;for(let n of[t.leftEyeBox,t.rightEyeBox]){let r=n.width*.15,o=n.height*.5,c=q(i,{x:n.x-r,y:n.y-o,width:n.width+2*r,height:n.height+2*o});e+=c.count,a+=c.clipped*c.count}return e===0?null:a/e}s(Fe,"Ge");function He(i,t){let e=ge(t),{box:a}=t,n={x:a.x-.2*a.width,y:e.y,width:1.4*a.width,height:a.y+a.height-e.y},r=0,o=0,c=0;for(let d of[e.x,e.x+.8*e.width]){let u=q(i,{x:d,y:e.y+.04*e.height,width:.2*e.width,height:.25*e.height},n);r+=u.count,o+=u.mean*u.count,c+=(u.sd*u.sd+u.mean*u.mean)*u.count}if(r===0)return null;let g=o/r;return{luma:g,sd:Math.sqrt(Math.max(0,c/r-g*g)),count:r}}s(He,"Ae");function Pe(i,t){let e=G(xe(t),i),a=Math.max(1,Math.floor(Math.max(e.x1-e.x0,e.y1-e.y0)/Ue)),n=s((d,u)=>i.data[u*i.width+d],"r"),r=0,o=0,c=0;for(let d=e.y0+a;d<e.y1-a;d+=a)for(let u=e.x0+a;u<e.x1-a;u+=a){let x=n(u,d-a)+n(u-a,d)+n(u+a,d)+n(u,d+a)-4*n(u,d);r+=1,o+=x,c+=x*x}if(r===0)return null;let g=o/r;return Math.min(1,Math.max(0,c/r-g*g)/Ie)}s(Pe,"Oe");function je(i,t){return{lighting:Be(i,t),eyeSpecular:Fe(i,t),background:He(i,t),sharpness:Pe(i,t)}}s(je,"we");var Oe="/models-v3",Ve=640,Ae=.92;function Y(i){return{width:i.videoWidth||0,height:i.videoHeight||0}}s(Y,"Y");function $(i,t){if(typeof document<"u"){let e=document.createElement("canvas");return e.width=i,e.height=t,e}return typeof OffscreenCanvas=="function"?new OffscreenCanvas(i,t):null}s($,"j");function Ke(){let i=null;return(t,e)=>{let{width:a,height:n}=Y(t);if(a===0||n===0)return null;let r=e===null?1:Math.min(1,e/Math.max(a,n)),o=Math.round(a*r),c=Math.round(n*r),g;e===null?g=$(o,c):((i===null||i.width!==o||i.height!==c)&&(i=$(o,c)),g=i);let d=g?.getContext("2d",{willReadFrequently:!0});if(g==null||d==null)return null;d.drawImage(t,0,0,o,c);let u=null;try{u=d.getImageData(0,0,o,c)}catch{u=null}return{source:g,width:o,height:c,pixels:u}}}s(Ke,"He");async function Re(i,t,e,a){let n=Math.round(e*t.width/t.height),r=$(n,e),o=r?.getContext("2d");if(r==null||o==null)throw new Error("canvas unavailable");return o.fillStyle="#fff",o.fillRect(0,0,n,e),o.drawImage(i.source,t.x,t.y,t.width,t.height,0,0,n,e),"convertToBlob"in r?r.convertToBlob({type:"image/jpeg",quality:a}):new Promise((c,g)=>{r.toBlob(d=>d===null?g(new Error("encode failed")):c(d),"image/jpeg",a)})}s(Re,"qe");var I,Le=(I=class extends Error{},s(I,"z"),I);function Ne(i,t,e){return new Promise((a,n)=>{let r=setTimeout(()=>{n(new Le(`init exceeded ${t}ms`)),i.then(e,()=>{})},t);i.then(o=>{clearTimeout(r),a(o)},o=>{clearTimeout(r),n(o)})})}s(Ne,"Ne");function We(i){if(i instanceof z)return{kind:"notfound",retryable:!0,detail:{name:i.name,phase:"acquiring",engineKind:"backcamera"}};let t=he(i),e=t==="overconstrained"?"generic":t,a=_(i);return{kind:e,retryable:e!=="insecure"&&e!=="unsupported",detail:{...a!==void 0?{name:a}:{},phase:"acquiring",engineKind:t}}}s(We,"Ve");function _e(i,t,e,a){let n=i.length===1?i[0]:void 0,r=n===void 0?null:j(n.landmarks,e,a),o=null;if(n!==void 0&&t.pixels!==null){let c=j(n.landmarks,t.width,t.height),g=qe(t.pixels);c!==null&&(o=je(g,c))}return{frameWidth:e,frameHeight:a,faces:i.length,geometry:r,matrix:n?.matrix??null,blendshapes:n?.blendshapes??null,stats:o}}s(_e,"Ke");function tt(i,t={},e=()=>"self",a){let n=ye(i.tuning,i.tuningVersion),r=le(),o=t.now??(()=>performance.now()),c=t.setTimer??((l,h)=>setTimeout(l,h)),g=t.clearTimer??(l=>clearTimeout(l)),d=t.grabFrame??Ke(),u=t.encodeRegion??Re,x=t.getUserMedia??(l=>navigator.mediaDevices.getUserMedia(l)),D=t.enumerateDevices??(t.getUserMedia===void 0&&typeof navigator<"u"&&typeof navigator.mediaDevices?.enumerateDevices=="function"?()=>navigator.mediaDevices.enumerateDevices():void 0),ve=t.createLandmarker??we,J=i.assetBaseUrl??Oe,Q=ue({enabled:i.keepScreenAwake!==!1}),E=fe(n,{policy:i.policy??"reject"}),b=i.video,X=pe({tuning:n.backgroundCheck,assetBaseUrl:J,...t.createSegmenter!==void 0?{createSegmenter:t.createSegmenter}:{},now:o}),m="idle",k=null,v=null,B=null,O=!1,y=!1,w=0,Z=0,V=[],M="user",A=se(),ee=!1,Me=t.canChooseFacing??oe,C=s(l=>{m===l||y||(m=l,Q.setActive(l==="starting"||l==="gating"),r.emit("state",l))},"k"),K=s(()=>{B!==null&&g(B),B=null},"D"),F=s(()=>{K();for(let l of k?.getTracks()??[])l.stop();k=null;try{b.srcObject=null}catch{}},"I"),R=s(l=>{F(),C("error"),r.emit("error",l)},"_"),te=s(()=>{let l=Math.max(o(),Z+1);return Z=l,l},"ee"),be=s(async l=>{let h=d(b,null),{width:T,height:S}=h??Y(b);if(h===null||v===null){E.reset();return}let f=v.detect(h.source,te()),p=(f.length===1?f:V.length===1?V:[])[0],U=p===void 0?null:j(p.landmarks,T,S);if(U===null){E.reset();return}let P=me(U,T,S,{margin:n.cropMargin,minWidth:n.resolution.minWidth,minHeight:n.resolution.minHeight}),N=Math.max(n.resolution.minHeight,P.height),De=await u(h,P,N,Ae);if(y||l!==w)return;let ae={image:De,width:Math.round(N*P.width/P.height),height:N,gate:E.summary(),facingMode:M};n.tuningVersion!==null&&(ae.tuningVersion=n.tuningVersion),K(),C("captured"),r.emit("captured",ae)},"Me"),L=s(async l=>{if(!(y||l!==w||m!=="gating"||v===null)){if(!O){O=!0;try{let h=d(b,Ve);if(h!==null){let{width:T,height:S}=Y(b),f=v.detect(h.source,te());V=f;let p=_e(f,h,T||h.width,S||h.height);p.geometry!==null&&n.background.required&&(p.backgroundCheck=X.measure(h,p.geometry.box,T||h.width,S||h.height));let U=E.push(p,o());if(y||l!==w||(r.emit("gate",U),U.ready&&(await be(l),m!=="gating")))return}}catch{}finally{O=!1}}!y&&l===w&&m==="gating"&&(B=c(()=>{L(l)},1e3/n.cadenceHz))}},"H"),ke=s(()=>Ne(ve(J),2e4,l=>l.close()),"Pe"),Ce=s(l=>{let h=e()==="assisted"?"assisted":"self";return ee||A.facing(h,i.facing),A.facing(h,l)},"Le"),ie=!1;function Te(){return ie||a===void 0||a.session()!=="choice"||e()!=="assisted"?!1:(ie=!0,a.onModeChange("self"),M=W("self"),C("mode_switch"),H({facing:M}),!0)}s(Te,"Se");let H=s(async l=>{if(y||m==="starting"||m==="gating")return;w+=1;let h=w;E.reset(),C("starting");let T=Ce(l?.facing);if(k!==null&&T!==M&&F(),M=T,ee=!0,k===null&&t.getUserMedia===void 0&&(typeof navigator>"u"||typeof navigator.mediaDevices?.getUserMedia!="function")){let f=typeof window<"u"&&window.isSecureContext===!1?"insecure":"unsupported";R({kind:f,retryable:!1,detail:{phase:"preflight",engineKind:f}});return}let S=v!==null?Promise.resolve(v):ke();S.catch(()=>{});try{if(k===null){let f=await de(M,{width:{ideal:n.camera.width},height:{ideal:n.camera.height}},{getUserMedia:x,...D!==void 0?{enumerateDevices:D}:{}});if(y||h!==w){for(let p of f.getTracks())p.stop();return}k=f,ce(f),M=re(f)??M,b.srcObject=k,b.muted=!0,b.playsInline=!0,await b.play().catch(()=>{})}}catch(f){if(y||h!==w||f instanceof z&&Te())return;R(We(f));return}try{v=await S}catch(f){if(!y&&h===w){let p=_(f);R({kind:"generic",retryable:!0,detail:{...p!==void 0?{name:p}:{},phase:"models",engineKind:"models"}})}return}y||h!==w||(C("gating"),L(h))},"R"),ne=s(async()=>a!==void 0&&a.session()==="choice"&&await Me().catch(()=>!1),"ne"),Se=s(()=>m==="idle"||m==="starting"||m==="gating"||m==="error","Fe");return{handle:{get state(){return m},get captureMode(){return e()},get facingMode(){return M},on:s((l,h)=>r.on(l,h),"on"),start:H,retry:s(()=>{if(!y){if(k!==null&&v!==null&&m!=="error"){w+=1;let l=w;K(),E.reset(),C("gating"),L(l);return}m="idle",H()}},"retry"),switchCamera:s(()=>A.refuseSwitch(e()==="assisted"?"assisted":"self"),"switchCamera"),canSwitchCaptureMode:ne,setCaptureMode:s(async l=>{if(y||a===void 0||l===e()||!await ne()||y||!Se())return!1;a.onModeChange(l);let h=W(l);return m==="idle"&&k===null||(w+=1,F(),M=h,C("mode_switch"),H({facing:h})),!0},"setCaptureMode"),destroy:s(()=>{y||(w+=1,F(),Q.setActive(!1),y=!0,v?.close(),v=null,X.close(),r.clear())},"destroy")},gateScores:s(()=>E.scores(),"gateScores"),setFlowState:s(l=>{(m==="captured"||m==="uploading"||m==="checking"||m==="done"&&l==="done")&&C(l)},"setFlowState")}}s(tt,"ct");function it(){import("./vision_bundle-WBHR7TEE.js").catch(()=>{})}s(it,"ut");export{Ve as a,Ae as b,Ke as c,_e as d,tt as e,it as f};