@sekyro/elements 0.1.0-rc.30 → 0.1.0-rc.31
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.
- package/CHANGELOG.md +18 -0
- package/dist/cdn/chunks/{capture-session-doc-NJKFAWHW-5ISANLWB.js → capture-session-doc-2JNGYSH6-GFUM3RZY.js} +1 -1
- package/dist/cdn/chunks/challenge-frame-HTZ2ZBIE-5JRAFZOU.js +1 -0
- package/dist/cdn/chunks/chunk-44UA2IDQ.js +1 -0
- package/dist/cdn/chunks/{chunk-4GDGJEJ6.js → chunk-4MHDMYKP.js} +1 -1
- package/dist/cdn/chunks/chunk-5AGMJYMI.js +1 -0
- package/dist/cdn/chunks/{chunk-W2IBE5PM.js → chunk-5OPKZZON.js} +1 -1
- package/dist/cdn/chunks/chunk-6T7VBPLY.js +3 -0
- package/dist/cdn/chunks/{chunk-KEO772AF.js → chunk-7V3YMJPI.js} +1 -1
- package/dist/cdn/chunks/{chunk-XZKF2U76.js → chunk-AKU6DWJM.js} +1 -1
- package/dist/cdn/chunks/{chunk-GR6JK2ML.js → chunk-DO66BOHU.js} +1 -1
- package/dist/cdn/chunks/{chunk-2HKOE6CN.js → chunk-EB2QC3GA.js} +1 -1
- package/dist/cdn/chunks/chunk-EGCT7K5E.js +1 -0
- package/dist/cdn/chunks/{chunk-FOPIRIC2.js → chunk-HTIKUYTU.js} +1 -1
- package/dist/cdn/chunks/{chunk-IWRPGU4X.js → chunk-JICBF2XL.js} +1 -1
- package/dist/cdn/chunks/{chunk-JU4XNPJJ.js → chunk-LBEHJATK.js} +1 -1
- package/dist/cdn/chunks/chunk-PRZX4CTP.js +33 -0
- package/dist/cdn/chunks/{chunk-4H47RI64.js → chunk-PWGUNXYH.js} +1 -1
- package/dist/cdn/chunks/{chunk-52X5ZO4S.js → chunk-SOCYEC7N.js} +1 -1
- package/dist/cdn/chunks/{chunk-5KTQLZKN.js → chunk-SYUAQ7BF.js} +1 -1
- package/dist/cdn/chunks/{chunk-5JSOPXYS.js → chunk-T5IBMUSY.js} +1 -1
- package/dist/cdn/chunks/chunk-V6PELUV7.js +1 -0
- package/dist/cdn/chunks/{chunk-DEDYOTBZ.js → chunk-XVHJIXFH.js} +1 -1
- package/dist/cdn/chunks/{chunk-TBQUAM5Z.js → chunk-Y6MS7VVL.js} +1 -1
- package/dist/cdn/chunks/chunk-ZWGMVZWP.js +1 -0
- package/dist/cdn/chunks/create-document-capture-DNJSSCWA-M73L4ODE.js +1 -0
- package/dist/cdn/chunks/{create-portrait-capture-5VGYZUOK-KTCFCHTN.js → create-portrait-capture-3MHP4DGA-4XIQSUJ3.js} +1 -1
- package/dist/cdn/chunks/{document-capture-view-SCXJCJET-YFWA53XE.js → document-capture-view-RFBBBM3S-MO6WL377.js} +1 -1
- package/dist/cdn/chunks/{eid-view-F75DTWPK-AE6YBJNY.js → eid-view-XM5VHPPM-6KKXEHDA.js} +1 -1
- package/dist/cdn/chunks/{email-otp-view-T3NRXENJ-K6FY5XVU.js → email-otp-view-RQV5WU3T-TP222TAL.js} +1 -1
- package/dist/cdn/chunks/flow-views-GYVML5BT-MTJUSGHX.js +1 -0
- package/dist/cdn/chunks/{form-view-7NPB2AJE-TCOF3XPH.js → form-view-Z7ODA3GO-2R5H32O2.js} +1 -1
- package/dist/cdn/chunks/overlay-de-ZQRK2WPD-YEE555KF.js +1 -0
- package/dist/cdn/chunks/overlay-es-XSQAIH32-DCYWAHRS.js +1 -0
- package/dist/cdn/chunks/overlay-pt-2LMQDJ4F-EWEOFJ27.js +1 -0
- package/dist/cdn/chunks/plan-runner-JXCJC5MM-BF6RMCBJ.js +1 -0
- package/dist/cdn/chunks/{portrait-capture-view-4HUAQUIA-G3YLZEHM.js → portrait-capture-view-ZBOXEM6H-LSOMBP5R.js} +1 -1
- package/dist/cdn/chunks/{portrait-review-view-VKRWP4HK-6NZPPDWZ.js → portrait-review-view-BWCMLEID-JA7RWO6C.js} +1 -1
- package/dist/cdn/chunks/{proof-of-address-view-BXQ4O2CU-RFNWZRUP.js → proof-of-address-view-LW5RYD5I-Q3UXH6YT.js} +1 -1
- package/dist/cdn/chunks/session-events-W5DRVA6F-BNHYAEHE.js +8 -0
- package/dist/cdn/chunks/session-watch-7HMFAHQI-WNCXXNDK.js +1 -0
- package/dist/cdn/define.js +1 -1
- package/dist/cdn/index.js +1 -1
- package/dist/{chunk-Q47EK3FL.js → chunk-35LCXJCF.js} +1 -1
- package/dist/chunk-3DAPWPSR.js +1 -0
- package/dist/{chunk-2XRKOCPR.js → chunk-A5EHF3BR.js} +1 -1
- package/dist/{chunk-RSXZISUG.js → chunk-BA2AJKJM.js} +1 -1
- package/dist/{chunk-QDHTMKLS.js → chunk-CMJWPBX6.js} +1 -1
- package/dist/chunk-H7LR746C.js +33 -0
- package/dist/chunk-JGYTOIH7.js +1 -0
- package/dist/{chunk-ZG77WO25.js → chunk-JREXIOVU.js} +1 -1
- package/dist/{chunk-5MOE4EK4.js → chunk-QEDULGVW.js} +1 -1
- package/dist/{chunk-YHJQJMRS.js → chunk-SVNDR2JE.js} +1 -1
- package/dist/{chunk-7GCPE3LG.js → chunk-W4G27O4B.js} +1 -1
- package/dist/{chunk-SCZ22CNO.js → chunk-WQIU4I3K.js} +1 -1
- package/dist/{chunk-D2KOFFZS.js → chunk-YHNEYMR2.js} +1 -1
- package/dist/{chunk-L7NFG55Y.js → chunk-YLWJXCPT.js} +1 -1
- package/dist/define.cjs +5 -5
- package/dist/define.js +1 -1
- package/dist/{document-capture-view-SCXJCJET-WFZYQEU2.js → document-capture-view-RFBBBM3S-ZNPUP6QX.js} +1 -1
- package/dist/{eid-view-F75DTWPK-QMS64USC.js → eid-view-XM5VHPPM-XKR4NZTZ.js} +1 -1
- package/dist/{email-otp-view-T3NRXENJ-WF5ZRHQS.js → email-otp-view-RQV5WU3T-JY72E4XM.js} +1 -1
- package/dist/flow-views-GYVML5BT-WVKFYYSN.js +1 -0
- package/dist/{form-view-7NPB2AJE-5GEBWQJ7.js → form-view-Z7ODA3GO-2ONECUO5.js} +1 -1
- package/dist/index.cjs +5 -5
- package/dist/index.d.cts +13 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +1 -1
- package/dist/overlay-de-ZQRK2WPD-FMRJWQQX.js +1 -0
- package/dist/overlay-es-XSQAIH32-VTIW3L6E.js +1 -0
- package/dist/overlay-pt-2LMQDJ4F-BB366XXI.js +1 -0
- package/dist/{portrait-capture-view-4HUAQUIA-LYTXJIEX.js → portrait-capture-view-ZBOXEM6H-PNCYH3WV.js} +1 -1
- package/dist/{portrait-review-view-VKRWP4HK-4XFARABZ.js → portrait-review-view-BWCMLEID-MAO4RY74.js} +1 -1
- package/dist/{proof-of-address-view-BXQ4O2CU-455UQJ3O.js → proof-of-address-view-LW5RYD5I-RDTH7FUR.js} +1 -1
- package/dist/styles.css +2 -1
- package/package.json +3 -3
- package/sbom.cdx.json +4 -4
- package/dist/cdn/chunks/challenge-frame-LWDSKM5K-J3CNO3XT.js +0 -1
- package/dist/cdn/chunks/chunk-GORELL4J.js +0 -1
- package/dist/cdn/chunks/chunk-IAPQGT6L.js +0 -1
- package/dist/cdn/chunks/chunk-JB27ZDFD.js +0 -1
- package/dist/cdn/chunks/chunk-KPUG7TMO.js +0 -33
- package/dist/cdn/chunks/chunk-LNE2P3TV.js +0 -1
- package/dist/cdn/chunks/chunk-RVL4N5KZ.js +0 -1
- package/dist/cdn/chunks/chunk-X6SULJS2.js +0 -3
- package/dist/cdn/chunks/create-document-capture-3DB2Y3GP-SMSQUDH2.js +0 -1
- package/dist/cdn/chunks/flow-views-TVG4PFSE-2UL4L6TO.js +0 -1
- package/dist/cdn/chunks/overlay-de-SYWE2LZE-AZG4RYMA.js +0 -1
- package/dist/cdn/chunks/overlay-es-D43QR7EF-ZODSTOP2.js +0 -1
- package/dist/cdn/chunks/overlay-pt-2YUWBZX7-UTMWWMN7.js +0 -1
- package/dist/cdn/chunks/plan-runner-432VPNQW-OBQFQCWK.js +0 -1
- package/dist/chunk-3SFLN33V.js +0 -1
- package/dist/chunk-4BQSPVSM.js +0 -33
- package/dist/chunk-CX7T4ADY.js +0 -1
- package/dist/flow-views-TVG4PFSE-OWVBXJ2R.js +0 -1
- package/dist/overlay-de-SYWE2LZE-QIFDHKT6.js +0 -1
- package/dist/overlay-es-D43QR7EF-FZNYZGGS.js +0 -1
- package/dist/overlay-pt-2YUWBZX7-4AFNZWV2.js +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @sekyro/elements
|
|
2
2
|
|
|
3
|
+
## 0.1.0-rc.31
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 48e4573: The consent terms say the organization that requested the verification sets how long the data is kept.
|
|
8
|
+
- 356fe3e: A second device on a session reads: This verification continues on another device. Finish on the device that is taking the photos. When the session already ended on the other device it reads: This verification ended on another device. There is nothing more to do on this device. While the other device is capturing, the button "Try again on this device" reads the session again; once the session ended there, the screen offers no retry. The screen is in every locale and follows the partner's branding. The desktop that shows the QR code keeps its consent line and its close button as before.
|
|
9
|
+
- Updated dependencies [43efc5b]
|
|
10
|
+
- Updated dependencies [16f3690]
|
|
11
|
+
- Updated dependencies [6f41492]
|
|
12
|
+
- Updated dependencies [189bd25]
|
|
13
|
+
- Updated dependencies [daee7dc]
|
|
14
|
+
- Updated dependencies [6cc6a5a]
|
|
15
|
+
- Updated dependencies [356fe3e]
|
|
16
|
+
- Updated dependencies [241ab8a]
|
|
17
|
+
- Updated dependencies [e538702]
|
|
18
|
+
- Updated dependencies [1e0236f]
|
|
19
|
+
- @sekyro/web@0.1.0-rc.54
|
|
20
|
+
|
|
3
21
|
## 0.1.0-rc.30
|
|
4
22
|
|
|
5
23
|
### Minor Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as s,c as a,d as _,e as C,f as A,g as D,h as o,i as S,j as r,k as t,l as E,m as p,n as T,o as O,p as i,q as m,r as R}from"./chunk-
|
|
1
|
+
import{b as s,c as a,d as _,e as C,f as A,g as D,h as o,i as S,j as r,k as t,l as E,m as p,n as T,o as O,p as i,q as m,r as R}from"./chunk-JICBF2XL.js";import"./chunk-XKZZC74I.js";import"./chunk-W5WWCOOW.js";import"./chunk-5Y7NCFTK.js";import"./chunk-37BKUH3E.js";import"./chunk-EGCT7K5E.js";import"./chunk-P7K7ELYZ.js";import"./chunk-JS2IXPNL.js";import"./chunk-4FHWXBOB.js";export{i as CAPTURE_CANDIDATE_SPACING_MS,O as CAPTURE_EXTRA_CANDIDATES,m as CAPTURE_WINDOW_MS,p as CaptureSessionDoc,_ as DOC_BLACK_FRAME_LUMA,C as DOC_BLACK_FRAME_TICKS,A as DOC_CADENCE_HZ,a as DOC_FIRST_FRAME_MS,o as DOC_PROFILE_TICKS,t as DOC_SHUTTER_DEFAULTS,r as DOC_SLOW_TICK_MS,S as DOC_WARMUP_TICKS,R as REFOCUS_APPLY_MAX_MS,D as SIDE_PROBE_MS,T as passportBandOf,E as resolveDocShutterTuning,s as warmDocDetector};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as i}from"./chunk-4FHWXBOB.js";var q=new Set(["challenge_frame_blocked","challenge_script_blocked","site_key_rejected","challenge_failed","timeout","embedder_opaque"]),y,a=(y=class extends Error{constructor(t,r){super(`Sekyro challenge failed: ${t}${r!==void 0?` (${r})`:""}`),this.name="ChallengeError",this.code=t,r!==void 0&&(this.detail=r)}},i(y,"o"),y),L=3e4,R=12e4,U=18e4,B=3e4,_=5e3,H=new Set(["script","widget","run"]),z="sekyro.challenge.",I="position:fixed;width:1px;height:1px;inset-block-start:0;inset-inline-start:0;opacity:0;pointer-events:none;border:0",N=i(e=>`position:fixed;top:50%;left:50%;transform:translate(-50%,-50%);width:min(360px,calc(100vw - 16px));min-width:300px;height:${e}px;opacity:1;pointer-events:auto;border:0;border-radius:8px;z-index:2147483647;background:transparent;color-scheme:normal`,"R"),p=65,C=200,G="position:fixed;inset:0;background:rgba(0,0,0,0.55);z-index:2147483646";function K(e,t=p){if(e.backdrop!==null)return;let r=document.createElement("div");r.setAttribute("style",G),r.setAttribute("data-sekyro-challenge-backdrop",""),document.body.appendChild(r),e.backdrop=r,e.focusBefore=document.activeElement,e.iframe.setAttribute("style",N(t)),e.iframe.removeAttribute("aria-hidden"),e.iframe.setAttribute("tabindex","0");try{e.iframe.focus()}catch{}}i(K,"B");function b(e){if(e.backdrop===null)return;e.backdrop.remove(),e.backdrop=null,e.iframe.setAttribute("style",I),e.iframe.setAttribute("aria-hidden","true"),e.iframe.setAttribute("tabindex","-1");let t=e.focusBefore;if(e.focusBefore=null,t instanceof HTMLElement&&t.isConnected)try{t.focus()}catch{}}i(b,"g");var h=null,M=Promise.resolve();function W(){w(),M=Promise.resolve(),E=!1}i(W,"J");function m(){return new a("aborted")}i(m,"m");function O(){let e=globalThis.crypto;return e!==void 0&&typeof e.randomUUID=="function"?e.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}i(O,"$");function j(e){return new URL(e,document.baseURI).origin}i(j,"F");function w(){let e=h;if(e!==null){h=null,window.removeEventListener("message",e.listener),b(e),e.iframe.remove();for(let t of e.waiters.values())t.reject(new a("challenge_frame_blocked"));e.waiters.clear()}}i(w,"b");function X(e,t){if(t.source!==e.iframe.contentWindow||t.origin!==e.origin)return;let r=t.data;if(typeof r!="object"||r===null)return;let n=r;if(typeof n.type!="string"||!n.type.startsWith(z)||n.v!==1)return;if(n.type==="sekyro.challenge.ready"){e.readyMs??(e.readyMs=Date.now()-e.insertedAt),e.isReady=!0,e.onReady?.();return}if(typeof n.id!="string")return;let d=e.waiters.get(n.id);if(d===void 0)return;if(n.type==="sekyro.challenge.interactive"){let{state:o,maxMs:c,height:l}=r;if(o==="show"){let u=typeof l=="number"&&Number.isFinite(l)?Math.round(l):p;K(e,Math.min(C,Math.max(p,u))),d.interactive(!0,typeof c=="number"&&Number.isFinite(c)?c:void 0)}else o==="resize"?e.backdrop!==null&&typeof l=="number"&&Number.isFinite(l)&&e.iframe.setAttribute("style",N(Math.min(C,Math.max(p,Math.round(l))))):o==="hide"&&(b(e),d.interactive(!1));return}let s=r.runs;if((n.type==="sekyro.challenge.token"||n.type==="sekyro.challenge.error")&&typeof s=="number"&&Number.isInteger(s)&&s>=1&&s<=10&&d.runs(s),n.type==="sekyro.challenge.token"&&typeof n.token=="string"&&n.token!=="")e.waiters.delete(n.id),b(e),d.resolve(n.token);else if(n.type==="sekyro.challenge.error"){e.waiters.delete(n.id),b(e);let o=typeof n.code=="string"&&q.has(n.code)?n.code:"challenge_failed",c=typeof n.detail=="string"||typeof n.detail=="number"?String(n.detail).slice(0,32):void 0,l=new a(o==="challenge_failed"&&c==="200100"?"clock_wrong":o,c),u=r.stage;typeof u=="string"&&H.has(u)&&(l.stage=u),d.reject(l)}}i(X,"j");function V(e){if(h!==null&&h.url===e)return h;w();let t=document.createElement("iframe");t.setAttribute("title","Security check"),t.setAttribute("aria-hidden","true"),t.setAttribute("tabindex","-1"),t.setAttribute("referrerpolicy","no-referrer"),t.setAttribute("style",I);let r={url:e,origin:j(e),iframe:t,isReady:!1,insertedAt:Date.now(),onReady:null,waiters:new Map,listener:i(n=>X(r,n),"listener"),backdrop:null,focusBefore:null};return window.addEventListener("message",r.listener),t.src=e,document.body.appendChild(t),h=r,r}i(V,"q");function Y(e,t,r){return e.isReady?Promise.resolve():new Promise((n,d)=>{let s=i(()=>{clearTimeout(c),r?.removeEventListener("abort",o),e.onReady=null},"s"),o=i(()=>{s(),d(m())},"i"),c=setTimeout(()=>{s(),d(new a("challenge_frame_blocked"))},t);r?.addEventListener("abort",o,{once:!0}),e.onReady=()=>{s(),n()}})}i(Y,"X");async function D(e){if(e.signal?.aborted)throw m();let t=V(e.frameUrl);try{return await J(t,e)}catch(r){throw r instanceof a&&t.readyMs!==void 0&&(r.readyMs??(r.readyMs=t.readyMs)),r}}i(D,"k");async function J(e,t){let r=t.signal;await Y(e,t.readyTimeoutMs??L,r);let n=e.iframe.contentWindow;if(n===null)throw new a("challenge_frame_blocked");let d=t.timeoutMs??R,s=O(),o,c,l=!1,u=d,x=Date.now(),g=U,A=0;try{return await new Promise(($,v)=>{let k=i(()=>v(new a("timeout")),"E"),P=i((f,S)=>{if(l!==f){if(l=f,clearTimeout(o),f){u=Math.max(B,u-(Date.now()-x)),A=Date.now();let F=S!==void 0?Math.max(0,S):g;o=setTimeout(k,Math.min(g,F)+_)}else g=Math.max(0,g-(Date.now()-A)),x=Date.now(),o=setTimeout(k,u+_);try{t.onInteractive?.(f)}catch{}}},"I"),T=i(f=>{try{f>0&&t.onRuns?.(f)}catch{}},"C");e.waiters.set(s,{resolve:$,reject:v,interactive:P,runs:i(f=>T(f-1),"runs")}),T(1),o=setTimeout(k,d+_),r!==void 0&&(c=i(()=>v(m()),"l"),r.addEventListener("abort",c,{once:!0})),n.postMessage({type:"sekyro.challenge.request",v:1,id:s,siteKey:t.siteKey,action:t.action,subject:t.subject,ui:1,...t.locale!==void 0?{locale:t.locale}:{}},e.origin)})}finally{if(clearTimeout(o),r!==void 0&&c!==void 0&&r.removeEventListener("abort",c),e.waiters.delete(s),b(e),l){l=!1;try{t.onInteractive?.(!1)}catch{}}}}i(J,"z");var E=!1;function Q(e,t){if(E)return;let r;if(t==="challenge_frame_blocked"){let n=e;try{n=j(e)}catch{}r=`Sekyro: the security check frame could not load. Allow \`frame-src ${n}\` in your Content-Security-Policy.`}else if(t==="embedder_opaque")r="Sekyro: the security check needs a page with an origin. Do not run the SDK in a sandboxed or data: document.";else return;E=!0,console.warn(r)}i(Q,"Y");async function Z(e){if(globalThis.origin==="null")throw new a("embedder_opaque");if(e.signal?.aborted)throw m();try{return await D(e)}catch(t){if(w(),e.signal?.aborted||t instanceof a&&t.code==="aborted")throw m();if(!(t instanceof a)||t.code!=="challenge_frame_blocked"&&t.code!=="challenge_script_blocked")throw t instanceof a?t:new a("challenge_failed");try{return await D(e)}catch(r){throw w(),e.signal?.aborted?m():r instanceof a?r:new a("challenge_failed")}}}i(Z,"V");function ee(e){let t=i(()=>Z(e).catch(n=>{throw n instanceof a&&Q(e.frameUrl,n.code),n}),"n"),r=M.then(t,t);return M=r.catch(()=>{}),r}i(ee,"Q");export{R as CHALLENGE_EXECUTE_TIMEOUT_MS,U as CHALLENGE_INTERACTIVE_MAX_MS,L as CHALLENGE_READY_TIMEOUT_MS,a as ChallengeError,ee as executeChallenge,W as resetChallengeFrameForTests};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as V}from"./chunk-5OPKZZON.js";import{a as B,c as F}from"./chunk-EGCT7K5E.js";import{b as H}from"./chunk-6MYG4HWP.js";import{a}from"./chunk-4FHWXBOB.js";var b,h=(b=class extends Error{constructor(t){super(t.message),this.name="HostedApiError",this.status=t.status,this.code=t.code,t.retryAfterSeconds!==void 0&&(this.retryAfterSeconds=t.retryAfterSeconds),t.details&&(this.details=t.details)}},a(b,"u"),b);function A(e){return e instanceof h&&e.code==="session_continues_elsewhere"}a(A,"y");function O(e,t,n=Math.random){let i=(e??t)*1e3,s=Math.min(Math.max(i,500),2e4),r=Math.round(s*(1+(n()*2-1)*.25));return Math.min(Math.max(r,500),2e4)}a(O,"b");var Z=6e4,j=4,oe=3e4,ce=9e5,de=200,ue=5,le=400,pe=new Set(["server_busy","request_timeout"]),he=20,fe=60,me=600,ye=3,_e=5,ve=2;function v(e){return(e.split(";")[0]??"").trim()}a(v,"m");var be={liveness:"clipKey",face_match:"imageKey",doc_ocr:"imageKey"},ke=`@sekyro/web/${B}`,Y=ke,k,at=(k=class{constructor(t){this.sessionId=null,this.bootstrap=null,this.captureNonces=[],this.captureFetch=null,this.reportedIssues=new Map,this.issueReports=0,this.issuesPausedUntil=0,this.apiOrigin=t.apiOrigin.replace(/\/+$/,""),this.sessionToken=t.sessionToken;let n=t.fetch;this.fetchImpl=(i,s)=>(n??globalThis.fetch).call(globalThis,i,s),this.requestTimeoutMs=t.requestTimeoutMs??oe,this.retryAttempts=t.inProgressRetry?.attempts??ue,this.retryDelayMs=t.inProgressRetry?.delayMs??le,this.random=t.random??Math.random,this.clientLocale=t.locale}async getSession(){let t=await this.api("GET","/hosted/session");return this.sessionId=t.sessionId,t}async*sessionEvents(t){let n={"x-session-token":this.sessionToken,"x-sekyro-sdk":Y,accept:"text/event-stream","sekyro-client-form-factor":H()};this.clientLocale!==void 0&&(n["sekyro-client-locale"]=this.clientLocale);let i;try{i=await this.fetchImpl(`${this.apiOrigin}/api/v2/hosted/session/events`,{method:"GET",headers:n,cache:"no-store",signal:t})}catch(r){throw C(r)}if(!i.ok)throw await Q(i);if(i.body===null||typeof TextDecoder>"u")throw new h({status:0,code:"unknown_error",message:"streamed responses are not supported here"});let{readSessionEvents:s}=await import("./session-events-W5DRVA6F-BNHYAEHE.js");try{for await(let r of s(i.body))r.type==="view"&&(this.sessionId=r.view.sessionId),yield r}catch(r){throw C(r)}}async recordConsent(t){let n=await this.api("POST","/hosted/consent",{body:{locale:t},busyRetry:!0}),i=this.captureHold;return this.captureHold=void 0,i&&this.armCapture(i),n}async reportCameraUnavailable(t){return this.api("POST","/hosted/camera-unavailable",{body:{cause:t}})}async testerGate(t){return this.api("POST","/hosted/tester-gate",{body:{input:t}})}async chooseSandboxMode(t){return this.api("POST","/hosted/sandbox-mode",{body:{mode:t}})}async reportCaptureIssue(t){let n=typeof t.name=="string"?t.name.replace(/[^A-Za-z]/g,"").slice(0,40):"",i=typeof t.engineKind=="string"&&/^[a-z_]{1,32}$/.test(t.engineKind)?t.engineKind:void 0,s=typeof t.attempt=="number"&&Number.isInteger(t.attempt)&&t.attempt>=0&&t.attempt<=1e3?t.attempt:void 0,r=t.check==="attestation"?s??"":"",c=[t.check,r,t.kind,n,t.phase??"",i??""].join("|"),d=this.reportedIssues.get(c);if(d!==void 0)return d;if(Date.now()<this.issuesPausedUntil||this.issueReports>=he)return;let o={check:t.check,kind:t.kind,...n!==""?{name:n}:{},...t.phase!==void 0?{phase:t.phase}:{},...i!==void 0?{engineKind:i}:{},...s!==void 0?{attempt:s}:{},...t.formFactor!==void 0?{formFactor:t.formFactor}:{},...typeof t.detail=="string"&&/^\d{1,10}$/.test(t.detail)?{detail:t.detail}:{},...z(t.challengeMs)?{challengeMs:t.challengeMs}:{},...z(t.readyMs)?{readyMs:t.readyMs}:{},...t.inApp===!0?{inApp:!0}:{},...t.interactive===!0?{interactive:!0}:{},...typeof t.checks=="number"&&Number.isInteger(t.checks)&&t.checks>=0&&t.checks<=50?{checks:t.checks}:{},...z(t.hiddenMs)?{hiddenMs:t.hiddenMs}:{},...t.hidden===!0?{hidden:!0}:{},...t.stage==="script"||t.stage==="widget"||t.stage==="run"?{stage:t.stage}:{},...t.check==="attestation"?{deviceTime:Date.now()}:{}};this.issueReports+=1;let u=this.api("POST","/hosted/capture-issue",{body:o,empty:!0,noRateRetry:!0}).catch(l=>{if(l instanceof h&&l.status===429){let p=Math.min(Math.max(l.retryAfterSeconds??fe,0),me);this.issuesPausedUntil=Math.max(this.issuesPausedUntil,Date.now()+p*1e3);return}(!(l instanceof h)||l.status===0||l.status>=500)&&this.reportedIssues.delete(c)});return this.reportedIssues.set(c,u),u}async choose(t,n){let i=await this.api("POST","/hosted/choice",{body:{nodeId:t,option:n},busyRetry:!0});return this.sessionId=i.sessionId,i}async confirmIdentity(t){return this.api("POST","/hosted/identity/confirm",{body:{decision:t}})}async identityPortrait(){return this.api("GET","/hosted/identity/portrait",{blob:!0})}async presign(t,n,i,s={}){let r=await this.ensureSessionId(),c={kind:t,contentType:v(n),contentLength:i,...s.source==="upload"?{source:"upload"}:{}};return this.api("POST",`/sessions/${r}/media`,{body:c})}armCapture(t=2,n){let i=Date.now();this.captureNonces.filter(s=>s.expiresAt-Z>i).length>=t||(this.captureHold===void 0?this.fillCaptureNonces(t,t).catch(s=>{A(s)&&n?.(s)}):this.captureHold=Math.max(this.captureHold,t))}async armRamp(){try{let t=await this.ensureSessionId(),n=await this.api("POST",`/sessions/${t}/media/capture-nonces`,{body:{count:2,ramp:!0}}),i=Date.now(),s=V(n.screenRamp)?n.screenRamp:void 0,r=i+Math.max(0,n.expiresIn)*1e3;for(let d of Array.isArray(n.nonces)?n.nonces:[])typeof d!="string"||d.length===0||this.captureNonces.push({nonce:d,expiresAt:r,...s!==void 0?{arm:s.nonce}:{}});this.captureNonces=this.captureNonces.slice(-j),this.captureHold=void 0;let c=typeof n.rampExpiresIn=="number"&&n.rampExpiresIn>0?n.rampExpiresIn:0;return{...s!==void 0?{challenge:s}:{},expiresAt:i+c*1e3}}catch(t){if(A(t))throw t;return}}async presignCapture(t,n,i,s={}){let r=await this.ensureSessionId(),c=await this.takeCaptureNonce(s.arm),d=c===void 0?void 0:{nonce:c,...s.engine!==void 0?{engine:s.engine.slice(0,32)}:{},...s.durationMs!==void 0&&Number.isFinite(s.durationMs)?{captureMs:Math.min(36e5,Math.max(0,Math.round(s.durationMs)))}:{}},o={kind:t,contentType:v(n),contentLength:i,capture:d};return this.api("POST",`/sessions/${r}/media`,{body:o})}async takeCaptureNonce(t){let n=a(()=>{let i=Date.now();this.captureNonces=this.captureNonces.filter(r=>r.expiresAt-Z>i);let s=this.captureNonces.findIndex(r=>r.arm===t);return this.captureNonces.splice(s<0?0:s,1)[0]?.nonce},"n");for(let i=0;i<2;i++){let s=n();if(s!==void 0)return s;await this.fillCaptureNonces(1)}return n()}fillCaptureNonces(t,n=0){return this.captureFetch??(this.captureFetch=(async()=>{try{let i=await this.ensureSessionId(),s=await this.api("POST",`/sessions/${i}/media/capture-nonces`,{body:{count:Math.min(j,Math.max(1,t))}}),r=Date.now()+Math.max(0,s.expiresIn)*1e3;for(let c of Array.isArray(s.nonces)?s.nonces:[])typeof c=="string"&&c.length>0&&this.captureNonces.push({nonce:c,expiresAt:r});this.captureNonces=this.captureNonces.slice(-j),this.captureHold=void 0}catch(i){if(A(i))throw i;i instanceof h&&i.code==="consent_required"&&(this.captureHold=Math.max(this.captureHold??0,n))}})().finally(()=>{this.captureFetch=null})),this.captureFetch}async uploadToSpaces(t,n,i){let s;try{s=await this.fetchImpl(t,{method:"PUT",headers:{"content-type":v(i)},body:n,signal:AbortSignal.timeout(ce)})}catch(r){throw C(r)}if(!s.ok){let r=(await s.text().catch(()=>"")).slice(0,de);throw new h({status:s.status,code:"upload_failed",message:`media upload failed (HTTP ${s.status})${r?`: ${r}`:""}`})}}async completeMedia(t){let n=await this.ensureSessionId();return this.api("POST",`/sessions/${n}/media/complete`,{body:{key:t}})}async submitCheck(t,n,i={}){let s=await this.ensureSessionId(),r={input:n,forceOutcome:i.forceOutcome};return this.api("POST",`/sessions/${s}/checks/${t}`,{body:r,idempotencyKey:i.idempotencyKey,...i.browserCheckToken!==void 0?{browserCheckToken:i.browserCheckToken}:{},busyRetry:i.idempotencyKey!==void 0})}async uploadAndSubmit(t,n,i,s={}){let r=v(n.contentType),c=await this.presign(n.kind,r,n.blob.size);await this.uploadToSpaces(c.uploadUrl,n.blob,r);let d=await this.completeMedia(c.key),o={...i,[be[t]]:d.key};return this.submitCheck(t,o,s)}async ensureSessionId(){return this.sessionId!==null?this.sessionId:(this.bootstrap??(this.bootstrap=this.getSession().finally(()=>{this.bootstrap=null})),(await this.bootstrap).sessionId)}async api(t,n,i={}){let s=t==="GET"||i.busyRetry===!0,r=t==="GET"||i.noRateRetry===!0?0:ye,c=`${this.apiOrigin}/api/v2${n}`,d={"x-session-token":this.sessionToken,"x-sekyro-sdk":Y};i.body!==void 0&&(d["content-type"]="application/json"),i.idempotencyKey!==void 0&&(d["x-idempotency-key"]=i.idempotencyKey),i.browserCheckToken!==void 0&&(d["sekyro-browser-check"]=i.browserCheckToken),this.clientLocale!==void 0&&(d["sekyro-client-locale"]=this.clientLocale);try{let o=F.timezone();o!==void 0&&(d["sekyro-client-timezone"]=o)}catch{}d["sekyro-client-form-factor"]=H();try{let o=await F.deviceHeader();o!==void 0&&(d["sekyro-client-device"]=o)}catch{}for(let o=0;;o++){let u;try{u=await this.fetchImpl(c,{method:t,headers:d,...i.body!==void 0?{body:JSON.stringify(i.body)}:{},cache:"no-store",signal:AbortSignal.timeout(this.requestTimeoutMs)})}catch(p){throw C(p)}if(u.ok){if(i.empty===!0)return;if(i.blob===!0)try{return await u.blob()}catch(f){throw C(f)}let p;try{p=await u.json()}catch{throw new h({status:u.status,code:"unknown_error",message:`response body was not valid JSON (HTTP ${u.status})`})}return we(p)}let l=await Q(u);if(l.code==="idempotency_in_progress"&&o<this.retryAttempts){this.retryDelayMs>0&&await D(this.retryDelayMs);continue}if(r>0&&l.status===429&&l.code==="rate_limit_exceeded"){r-=1,await D(O(l.retryAfterSeconds,_e,this.random));continue}if(s&&l.status===503&&pe.has(l.code)){s=!1,await D(O(l.retryAfterSeconds,ve,this.random));continue}throw l}}},a(k,"I"),k);function z(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0&&e<=6e5}a(z,"T");function C(e){if((typeof e=="object"&&e!==null?e.name:void 0)==="TimeoutError")return new h({status:0,code:"timeout",message:"request timed out"});let t=e instanceof Error?e.message:String(e);return new h({status:0,code:"network_error",message:`network request failed: ${t}`})}a(C,"h");function we(e){return e!==null&&typeof e=="object"&&"success"in e&&"data"in e?e.data:e}a(we,"F");async function Q(e){let t="unknown_error",n=`request failed (HTTP ${e.status})`,i=Number.NaN,s;try{let d=await e.json();if(d!==null&&typeof d=="object"){let o=d;typeof o.code=="string"&&o.code.length>0&&(t=o.code),typeof o.message=="string"&&o.message.length>0&&(n=o.message),typeof o.retryAfterSeconds=="number"&&(i=o.retryAfterSeconds),Array.isArray(o.details?.issues)?s=o.details:Array.isArray(o.details?.errors)&&(s={...o.details,issues:[]})}}catch{}let r=e.headers.get("retry-after"),c=r===null?Math.floor(i):Number.parseInt(r,10);return new h({status:e.status,code:t,message:n,...Number.isFinite(c)&&c>=0?{retryAfterSeconds:c}:{},details:s})}a(Q,"M");function D(e){return new Promise(t=>setTimeout(t,e))}a(D,"w");function ot(e){let t=e?.portrait,n=t?.icao,i=t?.purpose==="id_document";return n==null?i?{policy:"reject",profile:"id_document"}:null:{policy:n.policy==="alert"?"alert":"reject",profile:i||n.profile==="id_document"?"id_document":"selfie"}}a(ot,"te");function ct(e){return{...e.baselineEyeOpenness!==void 0?{baselineEyeOpenness:e.baselineEyeOpenness}:{},...e.baselineEyeOpennessLeft!==void 0&&e.baselineEyeOpennessRight!==void 0?{baselineEyeOpennessLeft:e.baselineEyeOpennessLeft,baselineEyeOpennessRight:e.baselineEyeOpennessRight}:{},criteria:e.verdict??{},...e.backgroundCheck!==void 0?{backgroundCheck:e.backgroundCheck}:{}}}a(ct,"ne");var ge=new Set(["nni_unbound","id_number_unbound","method_required","mobile_required","portrait_required"]);function pt(e){return ge.has(e)}a(pt,"ve");function ht(e,t,n){let i=t.detail;return{check:e,kind:t.kind,...i?.name!==void 0?{name:i.name}:{},...i?.phase!==void 0?{phase:i.phase}:{},...i?.engineKind!==void 0?{engineKind:i.engineKind}:{},attempt:Math.max(0,Math.min(1e3,n))}}a(ht,"Pe");function ft(){let e=-1,t="";return{note(n){n==="starting"&&t!=="starting"&&(e+=1),t=n},newHandle(){t=""},noteError(){e<0&&(e=0)},get value(){return e}}}a(ft,"xe");var Me={document:"document_photo",nfc:"document_chip",population_registry:"national_number",national_eid:"national_eid"};function y(e){return e.plan?.steps??[]}a(y,"f");function L(e){return Math.max(0,e.attempts.max-e.attempts.used)}a(L,"x");function Se(e){let t=e.plan?.choice;return t!==void 0&&e.plan?.current===t.nodeId?t:null}a(Se,"W");function mt(e){let t=Se(e);if(t?.kind!=="identity_method")return null;let n=t.options.map(s=>Me[s.service]).filter(s=>s!==void 0),i=t.options.find(s=>s.nationalEid)?.nationalEid;return i?{available:!0,selected:null,options:n,nationalEid:i}:{available:!0,selected:null,options:n}}a(mt,"Ve");var Ie=new Set(["liveness","face_match"]);function G(e){return e!==void 0&&(e.state==="pending"||e.state==="input_required")}a(G,"k");function Te(e){return e.status!=="created"&&e.status!=="in_progress"}a(Te,"F");function ee(e){let t=e.plan?.current,n=t==null?void 0:y(e).find(i=>i.id===t);return G(n)?n:void 0}a(ee,"M");function q(e,t){return y(e).find(n=>n.checkType===t)}a(q,"g");function N(e){let t=y(e),n=t.findIndex(i=>i.checkType==="liveness");return t.find((i,s)=>s>n&&i.checkType==="face_match")}a(N,"S");function xe(e,t){let n=q(t,"liveness")?.state,i=N(t)?.state;return(N(e)?.state??"pending")==="pending"&&(n==="passed"||n==="review")&&i!==void 0&&i!=="pending"&&i!=="skipped"}a(xe,"O");function W(e,t){let n=new Map(y(e).map(i=>[i.id,i.state]));return y(t).filter(i=>i.checkType==="face_match"&&(n.get(i.id)??"pending")==="pending"&&i.state!=="pending"&&i.state!=="skipped").map(i=>i.id)}a(W,"V");var Ce=/^[0-9a-f]{24}$/i;function P(e){return Ce.test(e)?`ses_${e}`:e}a(P,"b");function $(e,t){let n=P(e);return t===void 0?{sessionId:n,status:"unavailable"}:{sessionId:n,status:"unavailable",reasonCode:t}}a($,"C");function te(e,t,n){let i=P(e);return n===void 0?{sessionId:i,status:t}:{sessionId:i,status:t,reasonCode:n}}a(te,"L");function yt(e,t){let n=Ee(e,t),i=Ae(e);return i!==void 0&&(n.sandbox=i),n}a(yt,"Ee");function Ae(e){if(e.sandbox!==!0)return;let t=e.sandboxRun;if(typeof t!="object"||t===null)return;let{mode:n,testerName:i}=t;if(!(n!=="simulated"&&n!=="tester"))return n==="tester"&&typeof i=="string"&&i.trim()!==""?{mode:n,testerName:i.trim()}:{mode:n}}a(Ae,"Z");function Ee(e,t){let n=P(e.sessionId);switch(e.status){case"created":case"in_progress":return Ne(e,t);case"verified":return R(e,{sessionId:n,status:"verified"});case"review_pending":return R(e,te(n,"review",ne(e,"review")));case"not_verified":return R(e,Oe(e));default:return R(e,{sessionId:n,status:"not_verified"})}}a(Ee,"Q");var Pe=new Set([0,1,2,3]);function R(e,t){return Pe.has(e.level)&&(t.level=e.level),typeof e.assurance=="string"&&e.assurance.length>0&&(t.assurance=e.assurance),t}a(R,"v");function Oe(e){let t={sessionId:P(e.sessionId),status:"not_verified"};return e.reason!==void 0&&(t.reason=e.reason),e.reasonCode!==void 0&&(t.reasonCode=e.reasonCode),e.reasonCode==="device_cooldown"&&e.retryAfter!==void 0&&(t.retryAfter=e.retryAfter),t}a(Oe,"ne");function $e(e){return e==="rejected"?"rejected":e==="unavailable"?"unavailable":"inconclusive"}a($e,"te");function Re(e,t){if(t===void 0)return!1;let n=y(t).find(i=>i.id===e.id);return n!==void 0&&n.attempts.used===e.attempts.used}a(Re,"ie");function Ne(e,t){let n=P(e.sessionId),i=y(e).find(r=>Ie.has(r.checkType)&&r.state==="input_required"&&r.reason!==void 0);if(i?.reason==="mobile_required")return $(n,"mobile_required");if(i?.reason!==void 0){if(i.result==="unavailable")return $(n,i.reason);let r=t.autoRetry&&(L(i)>0||Re(i,t.previous))?{sessionId:n,status:"retry",reasonCode:i.reason,attemptsRemaining:L(i)}:{sessionId:n,status:"not_verified",reason:$e(i.result),reasonCode:i.reason,attemptsRemaining:L(i)};return i.retakeHint!==void 0&&(r.retakeHint=i.retakeHint),r}let s=ee(e);return s===void 0&&y(e).some(r=>r.state==="review")?te(n,"review",ne(e,"review")):s?.checkType==="portrait_icao"?$(n,"portrait_required"):$(n)}a(Ne,"re");function ne(e,t){return y(e).find(n=>n.state===t&&n.reason!==void 0)?.reason}a(ne,"N");function ie(e,t,n,i,s){return e.presignCapture!==void 0?e.presignCapture(t,n,i,s):e.presign(t,n,i)}a(ie,"q");function se(e){return{engine:e?.engine,durationMs:e?.clipMs,arm:e?.screenRamp?.nonce}}a(se,"D");var qe=["video/webm","video/mp4"],X="image/jpeg",Ke=2,He=1e3,Fe=1e4,je=3,ze=10,De=3,Le=new Set(["network_error","timeout","upload_failed","unknown_error","rate_limit_exceeded"]),Ue=new Set(["session_not_active","check_not_found","check_already_finalized","check_out_of_order","check_not_active","step_not_on_path","native_app_required"]),w,J=(w=class extends Error{constructor(){super("verification destroyed"),this.name="FlowCancelledError"}},a(w,"w"),w);function Ge(e){let t=N(e);return q(e,"portrait_icao")?.state!=="pending"&&(t!==void 0?G(t):e.capture?.livePhoto?.oneCapture===!0)}a(Ge,"me");var g,E=(g=class extends Error{constructor(t){super(t),this.name="AttestationError"}},a(g,"h"),g),M,Je=(M=class extends E{constructor(t){super(`no attestation token: ${t}`),this.name="AttestationUnavailableError",this.code=t}},a(M,"E"),M);function _t(e){return new h({status:400,code:"attestation_invalid",message:`browser check: ${e}`,details:{issues:[],browserCheck:e}})}a(_t,"Oe");function Ve(e){if(!(e instanceof h)||e.code!=="attestation_invalid")return;let t=e.details?.browserCheck;return typeof t=="string"?t:void 0}a(Ve,"he");async function re(e,t,n={}){let i=e.uuid(),s=!1,r=!1,c=0,d=0;for(;;)try{return await t(e.client,i)}catch(o){if(o instanceof E){if(r||o instanceof Je)throw o;r=!0,n.onAttestationInvalid?.(),i=e.uuid();continue}if(!(o instanceof h))throw o;if(o.code==="consent_required"&&!s){s=!0,await e.ensureConsent({force:!0}),i=e.uuid();continue}if(o.code==="attestation_invalid"&&!r&&Ve(o)===void 0){r=!0,n.onAttestationInvalid?.(),i=e.uuid();continue}if(o.code==="inference_unavailable"&&d<je){d+=1;let u=O(o.retryAfterSeconds,ze,e.random??Math.random);e.onBusy?.({attempt:d,retryAfterSeconds:u/1e3}),await e.sleep(u),n.onAttestationInvalid?.(),i=e.uuid();continue}if(Le.has(o.code)&&c<Ke){c+=1;let u=o.retryAfterSeconds!==void 0?o.retryAfterSeconds*1e3:void 0;await e.sleep(u!==void 0?Math.min(u,Fe):He);continue}throw o}}a(re,"U");var Be=new Set(["passed","review","processing","skipped"]);async function vt(e){let{artifacts:t}=e,n=t.clip,i=v(t.clipMime??"");if(t.degraded==="NO_RECORDER"||n===void 0||!qe.includes(i))return{kind:"unavailable",reason:"no_recorder"};e.client.armCapture?.(2);let s=Ze(e,t.keyframe),r=Ye(e,n,i,s),c=Qe(e,s),d=!1,o=new Set,u=!0,l=0;for(;;){if(e.isCancelled())return{kind:"cancelled"};let p=e.getView();if(Te(p))return{kind:"settled"};let f=ee(p),x=f?.checkType,K=x==="liveness"&&!d?"liveness":x==="face_match"&&!o.has(f?.id)&&o.size<2&&u?"face_match":null;if(K===null)return{kind:"settled"};if(K==="liveness"&&t.captureChannel==="desktop")return{kind:"unavailable",reason:"mobile_required"};try{if(K==="liveness"){d=!0;let m=await r();if(e.isCancelled())return{kind:"cancelled"};xe(p,m)&&o.add(N(m)?.id);for(let ae of W(p,m))o.add(ae);await e.applySubmit(m,"liveness");let _=q(e.getView(),"liveness")?.state;u=_===void 0||Be.has(_)}else{o.add(f?.id);let m=await c();if(e.isCancelled())return{kind:"cancelled"};for(let _ of W(p,m))o.add(_);await e.applySubmit(m,"face_match")}}catch(m){if(e.isCancelled()||m instanceof J)return{kind:"cancelled"};let _=tt(m);if(_.kind!=="resync"||l>=De)return _;l+=1,await e.refreshView()}}}a(vt,"Le");function Ze(e,t){let n=null,i=null,s=a(()=>n!==null?Promise.resolve(n):(i??(i=(async()=>{let r=await ie(e.client,"image",X,t.size,se(e.artifacts));return await e.client.uploadToSpaces(r.uploadUrl,t,X),n=(await e.client.completeMedia(r.key)).key,e.onKeyframePromoted?.(n),n})().finally(()=>{i=null})),i),"r");return{ensure:s,attempt:a(()=>s().catch(()=>null),"attempt"),current:a(()=>n,"current")}}a(Ze,"_e");function Ye(e,t,n,i){let s=e.clipKeys?.get()??null,r,c=null,d=0,o;return()=>re(e,async(u,l)=>{if(s===null||r===void 0){if(e.isCancelled())throw new J;r===void 0&&!Ge(e.getView())&&(r=null),e.onPhase("uploading");let[p,f]=await Promise.all([s!==null?Promise.resolve(s):(async()=>{let x=await ie(u,"clip",n,t.size,se(e.artifacts));return await u.uploadToSpaces(x.uploadUrl,t,n),(await u.completeMedia(x.key)).key})(),r!==void 0?Promise.resolve(r===null?null:r.imageKey):i.attempt()]);s=p,e.clipKeys?.set(p),r===void 0&&(r=f===null?null:{imageKey:f})}if(c===null){let p=performance.now();try{c=await e.getAttestation(),o=e.attestationError?.()}catch(f){throw f instanceof E?f:new E(f instanceof Error?f.message:String(f))}d=Math.round(performance.now()-p)}return e.onPhase("checking"),u.submitCheck("liveness",{clipKey:s,attestation:c,captureChannel:e.artifacts.captureChannel,capture:{...We(e.artifacts),attestationMs:d,attestationError:o,...et(e.attestationFacts?.())},...r!==null?{faceMatch:r}:{}},{idempotencyKey:l})},{onAttestationInvalid:a(()=>{c=null},"onAttestationInvalid")})}a(Ye,"ye");function Qe(e,t){return()=>re(e,async(n,i)=>{if(t.current()===null){if(e.isCancelled())throw new J;e.onPhase("uploading")}let s=await t.ensure();return e.onPhase("checking"),n.submitCheck("face_match",{imageKey:s},{idempotencyKey:i})})}a(Qe,"Se");function We(e){let t={width:e.width,height:e.height};for(let n of Xe)e[n]!==void 0&&(t[n]=e[n]);return t}a(We,"ke");var Xe=["engine","facingMode","mode","formFactor","clipMs","clipFrames","fps","clipRetakes","codec","cameraReadyMs","faceAcquireMs","captureMs","screenRamp","provenance"];function et(e){return e===void 0?{}:{attestationChecks:e.checks,...e.challengeMs!==void 0?{attestationChallengeMs:e.challengeMs}:{}}}a(et,"we");function tt(e){if(e instanceof E)return{kind:"unavailable",reason:"attestation"};if(A(e))return{kind:"elsewhere"};if(e instanceof h){if(e.code==="attestation_invalid")return{kind:"unavailable",reason:"attestation"};if(e.code==="inference_unavailable")return{kind:"unavailable",reason:"inference_unavailable"};if(e.code==="mobile_required")return{kind:"unavailable",reason:"mobile_required"};if(Ue.has(e.code))return{kind:"resync"}}return{kind:"unavailable",reason:"network"}}a(tt,"Re");var bt="form_answers_invalid",S,kt=(S=class extends Error{constructor(t,n){super(`form answers refused (${t.map(i=>`${i.id}: ${i.code}`).join(", ")})`),this.name="FormAnswersError",this.issues=t,this.source=n}},a(S,"B"),S),I,wt=(I=class extends Error{constructor(t,n){super(`invalid ${t} (${n})`),this.name="InvalidInputError",this.field=t,this.kind=n}},a(I,"$"),I),T,gt=(T=class extends Error{constructor(t,n){super(`invalid ${t} (${n})`),this.name="OtpInputError",this.field=t,this.kind=n}},a(T,"Y"),T);function U(e){return e?.source==="upload"?null:e?.source==="choice"&&e.sourcePick!=="camera"?"upload_or_phone":"phone"}a(U,"H");function Mt(e,t){if(t===void 0||!G(t)||t.requiresMobile!==!0)return null;switch(t.checkType){case"liveness":return"phone";case"face_match":{if(t.reason!==void 0)return"phone";let n=q(e,"portrait_icao");return n?.state==="passed"||n?.state==="review"?null:"phone"}case"doc_ocr":return U(e.documents);case"poa":return U(e.proofOfAddress);case"portrait_icao":{let n=e.portrait;return n?.pendingFix!==void 0||n?.reuse?.pending===!0?null:U(n)}default:return null}}a(Mt,"Be");function nt(e){let t=e?.capture,n=t?.mode;return n==="assisted"||n==="self"||n==="choice"?n:t?.cameraSwitch===!0?"assisted":"self"}a(nt,"Ce");function St(e){let t=e?.capture?.pick;return nt(e)==="choice"&&(t==="self"||t==="assisted")?t:null}a(St,"Ye");function It(e,t,n=null){return e==="choice"?t??n??"self":e}a(It,"ze");var Tt={"JP:drivers_license":{normalize:"upper_no_space_or_hyphen",pattern:"^[0-9]{12}$",check:null,registrySources:[],describe:"number must be the 12-digit Japanese driving licence number"},"JP:residence_permit":{normalize:"upper_no_space_or_hyphen",pattern:"^[A-Z]{2}[0-9]{8}[A-Z]{2}$",check:null,registrySources:[],describe:"number must be the 12-character residence card number: two letters, eight digits, two letters"},"MR:drivers_license":{normalize:"upper_no_space_or_hyphen",pattern:"^[0-9]{8}$",check:null,registrySources:[],describe:"number must be the 8-digit Mauritanian driver's license number"},"MR:national_id":{normalize:"trim",pattern:"^[0-9]{10}$",check:"mr_nni_mod97",registrySources:["MR.anrpts"],describe:"number must be the 10-digit Mauritanian national ID number with a valid check digit"}};export{h as a,A as b,v as c,at as d,ot as e,ct as f,pt as g,ht as h,ft as i,Me as j,y as k,L as l,Se as m,mt as n,G as o,Te as p,ee as q,q as r,P as s,$ as t,yt as u,Ae as v,ie as w,qe as x,Je as y,_t as z,Ve as A,re as B,vt as C,We as D,bt as E,kt as F,wt as G,gt as H,Mt as I,nt as J,St as K,It as L,Tt as M};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g as X}from"./chunk-X6SULJS2.js";import{a as z,b as ee}from"./chunk-2HKOE6CN.js";import{a as n}from"./chunk-5QL6W6FW.js";import{a,c as Z}from"./chunk-4FHWXBOB.js";var u=Z(z(),1),J=Z(z(),1),s=Z(ee(),1);var h=Z(ee(),1);var he="AC247 AD376 AE971/0 AF93/0 AG1/1 AI1/1 AL355/0 AM374/0 AO244 AR54/0 AS1/1 AT43/0 AU61/0 AW297 AX358/0 AZ994/0 BA387/0 BB1/1 BD880/0 BE32/0 BF226 BG359/0 BH973 BI257 BJ229 BL590/0 BM1/1 BN673 BO591/0 BQ599 BR55/0 BS1/1 BT975 BW267 BY375/8 BZ501 CA1/1 CC61/0 CD243/0 CF236 CG242 CH41/0 CI225 CK682 CL56 CM237 CN86/0 CO57/0 CR506 CU53/0 CV238 CW599 CX61/0 CY357 CZ420 DE49/0 DJ253 DK45 DM1/1 DO1/1 DZ213/0 EC593/0 EE372 EG20/0 EH212/0 ER291/0 ES34 ET251/0 FI358/0 FJ679 FK500 FM691 FO298 FR33/0 GA241 GB44/0 GD1/1 GE995/0 GF594/0 GG44/0 GH233/0 GI350 GL299 GM220 GN224 GP590/0 GQ240 GR30 GT502 GU1/1 GW245 GY592 HK852 HN504 HR385/0 HT509 HU36/06 ID62/0 IE353/0 IL972/0 IM44/0 IN91/0 IO246 IQ964/0 IR98/0 IS354 IT39 JE44/0 JM1/1 JO962/0 JP81/0 KE254/0 KG996/0 KH855/0 KI686/0 KM269 KN1/1 KP850/0 KR82/0 KW965 KY1/1 KZ7/8 LA856/0 LB961/0 LC1/1 LI423/0 LK94/0 LR231/0 LS266 LT370/0 LU352 LV371 LY218/0 MA212/0 MC377/0 MD373/0 ME382/0 MF590/0 MG261/0 MH692/1 MK389/0 ML223 MM95/0 MN976/0 MO853 MP1/1 MQ596/0 MR222 MS1/1 MT356 MU230 MV960 MW265/0 MX52 MY60/0 MZ258 NA264/0 NC687 NE227 NF672 NG234/0 NI505 NL31/0 NO47 NP977/0 NR674 NU683 NZ64/0 OM968 PA507 PE51/0 PF689 PG675 PH63/0 PK92/0 PL48 PM508/0 PR1/1 PS970/0 PT351 PW680 PY595/0 QA974 RE262/0 RO40/0 RS381/0 RU7/8 RW250/0 SA966/0 SB677 SC248 SD249/0 SE46/0 SG65 SH290 SI386/0 SJ47 SK421/0 SL232/0 SM378 SN221 SO252/0 SR597 SS211/0 ST239 SV503 SX1/1 SY963/0 SZ268 TA290 TC1/1 TD235 TG228 TH66/0 TJ992 TK690 TL670 TM993/8 TN216 TO676 TR90/0 TT1/1 TV688 TW886/0 TZ255/0 UA380/0 UG256/0 US1/1 UY598/0 UZ998 VA39 VC1/1 VE58/0 VG1/1 VI1/1 VN84/0 VU678 WF681 WS685 XK383/0 YE967/0 YT262/0 ZA27/0 ZM260/0 ZW263/0",j;function Q(e){return j??(j=new Map(he.split(" ").map(l=>{let[r,t]=l.slice(2).split("/");return[l.slice(0,2),[r,t]]}))),j.get(e.toUpperCase())}a(Q,"z");n(Q,"entryOf");function pe(e){return Q(e)?.[0]}a(pe,"Ne");n(pe,"dialCodeOf");function ne(e){return Q(e)?.[1]}a(ne,"ee");n(ne,"nationalPrefixOf");var le=n(e=>e.normalize("NFD").replace(/\p{Diacritic}/gu,"").toLocaleLowerCase(),"fold");function ae(e,l){let r=le(l.trim());return r===""?e:e.filter(t=>le(t.name).includes(r)||t.code.toLowerCase()===r)}a(ae,"ce");n(ae,"matchCountries");function oe({countries:e,label:l,searchPlaceholder:r,noMatch:t,onPick:v,selected:P,searchRef:f,scroll:E=!1,searchable:w=!0,detail:D,extra:y}){let[M,b]=(0,J.useState)(""),c=(0,J.useId)(),T=ae(e,M),N=(0,s.jsxs)("ul",{className:`sekyro-rows${E?" sekyro-rows--scroll":""}`,children:[T.map(d=>{let S=D?.(d.code);return(0,s.jsx)("li",{children:(0,s.jsxs)("button",{type:"button",className:"sekyro-row-btn","aria-current":P===d.code||void 0,onClick:a(()=>v(d.code),"onClick"),children:[(0,s.jsx)("span",{className:"sekyro-row-btn__flag","aria-hidden":"true",children:ce(d.code)}),(0,s.jsx)("span",{className:"sekyro-row-btn__name",children:d.name}),S!==void 0?(0,s.jsx)("bdi",{className:"sekyro-row-btn__detail",dir:"ltr",children:S}):null]})},d.code)}),y!==void 0?(0,s.jsx)("li",{children:(0,s.jsxs)("button",{type:"button",className:"sekyro-row-btn","aria-current":y.current||void 0,onClick:y.onPick,children:[(0,s.jsx)("span",{className:"sekyro-row-btn__flag","aria-hidden":"true",children:"🌐"}),(0,s.jsx)("span",{className:"sekyro-row-btn__name",children:y.label})]})}):null]});return w?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"sekyro-field",children:[(0,s.jsx)("label",{className:"sekyro-label",htmlFor:c,children:l}),(0,s.jsx)("input",{ref:f,id:c,type:"search",className:"sekyro-input",placeholder:r,value:M,onChange:a(d=>b(d.target.value),"onChange")})]}),T.length===0&&y===void 0?(0,s.jsx)("p",{className:"sekyro-text-muted",children:t}):N]}):N}a(oe,"te");n(oe,"CountryList");function U(e){let l=X(e).replace(/\D/g,"");return/^\D*\+/.test(e)?`+${l}`:l.startsWith("00")?`+${l.slice(2)}`:l}a(U,"H");n(U,"digitsOf");var te=n((e,l)=>(l.trunk!==void 0&&e.startsWith(l.trunk)?e.slice(l.trunk.length):e).slice(0,Math.max(...l.lengths)),"fitDigits");function Y(e,l){let r="",t=0;for(let v of l?.formats?.find(P=>new RegExp(`^(?:${P.leading})`).test(e))?.groups??[])t<e.length&&(r+=(t>0?" ":"")+e.slice(t,t+v)),t+=v;return r+e.slice(t)}a(Y,"Z");n(Y,"groupDigits");function ie(e,l){let r=0;for(let t=l;t>0&&r<e.length;r+=1)e[r]!==" "&&(t-=1);return r}a(ie,"oe");n(ie,"caretAfter");var se=n((e,l)=>l.find(r=>e.startsWith(r.dial)),"countryOfNumber"),me=n((e,l)=>e.lengths.join(", ").replace(/, (\d+)$/,` ${l} $1`),"lengthsLabel");function q(e){let l=U(e).replace("+","");return/^\d{8,15}$/.test(l)?`+${l}`:null}a(q,"le");n(q,"normalizedPhone");var ce=n(e=>String.fromCodePoint(...Array.from(e.toUpperCase(),l=>127397+l.charCodeAt(0))),"flagOf");function de(e,l){if(l===null||!e.startsWith(l.dial))return q(e);let r=e.slice(l.dial.length).replace(/\D/g,""),t=ne(l.code);return t!==void 0&&r.startsWith(t)&&(r=r.slice(t.length)),q(l.dial+r)}a(de,"ye");n(de,"e164Of");var re=n((e,l)=>(se(e,l)??l[0])?.code??null,"countryFor");function ue(e){let l=null;try{l=new Intl.DisplayNames([e],{type:"region"})}catch{}return r=>`${l?.of(r.code)??r.code} (${r.dial})`}a(ue,"me");n(ue,"countryLabels");var fe="other",ye=8;function ge({countries:e,international:l,closed:r,defaultPhone:t}){let[v,P]=(0,u.useState)(()=>re(t,e)),[f,E]=(0,u.useState)(t),[w,D]=(0,u.useState)(!1),[y,M]=(0,u.useState)(!1),b=e.map(o=>o.code).join(","),c=e.find(o=>o.code===v)??null,T=(0,u.useRef)(c);c!==null&&(T.current=c),(0,u.useEffect)(()=>{if(v===null||!e.some(o=>o.code===v)){let o=re(t,e);P(o);let i=T.current,k=e.find(C=>C.code===o)?.dial;k!==void 0&&E(C=>i!==null&&C.startsWith(i.dial)?k+C.slice(i.dial.length):C.startsWith("+")?C:k)}},[b,t]);let N=w||c===null,d=N||f.startsWith("+")&&!f.startsWith(c.dial),S=d?void 0:c.rule,x=d?f:f.replace(c.dial,"").replace(/\D/g,""),p=S?te(x,S):x,W=d&&!N&&!l&&r&&!e.some(o=>o.dial.startsWith(f)),I=W?null:S?S.lengths.includes(p.length)?c.dial+p:null:N&&!f.startsWith("+")?null:de(f,w?null:c),H=d||c===null?I??f:`${c.dial} ${Y(p,S)}`,B=d?U(f).replace("+","")==="":p==="";return{countries:e,international:l,phone:f,selected:c,other:w,whole:d,free:N,rule:S,national:p,refused:W,typed:I,shown:H,empty:B,lengthShown:y,setLengthShown:M,onNumber:n(o=>{let i=o.target,k=o.nativeEvent.inputType,C=Math.max(0,i.value.lastIndexOf("+")),G=U(i.value.slice(C)),A=se(G,e),_=U(i.value.slice(C,i.selectionStart)).length,F=G,V=G;if(M(!1),!A&&(N||G.startsWith("+")))l&&D(!0);else{let R=A??c,g=A?G.slice(A.dial.length):G;if(P(R.code),D(!1),g===p&&k?.startsWith("delete")&&(k.endsWith("Forward")||(_-=1),g=g.slice(0,_)+g.slice(_+1)),R.rule){let $=te(g,R.rule),O=g.length-$.length;_-=O,g=O>0&&!A&&p.length===$.length?p:$}V=R.dial+g,F=Y(g,R.rule)}E(V),i.value=F;let K=ie(F,_);i.setSelectionRange(K,K)},"onNumber"),onCountry:n(o=>{M(!1);let i=e.find(k=>k.code===o);D(i===void 0),i!==void 0&&P(i.code),E(i===void 0?"":i.dial+(d?"":p))},"onCountry")}}a(ge,"_e");n(ge,"usePhoneField");function Ne({field:e,id:l,locale:r,t,inputRef:v,invalid:P=!1,describedby:f,required:E,compact:w=!1,ready:D}){let{selected:y,whole:M,other:b,free:c,national:T,rule:N,phone:d,refused:S,typed:x,countries:p,international:W}=e,[I,H]=(0,u.useState)(!1),B=(0,u.useRef)(null),o=(0,u.useRef)(null),i=(0,u.useRef)(null),k=(0,u.useRef)(null),C=v??k,G=(0,u.useId)(),A=S?t("otp.reason_otp_destination_not_allowed"):e.lengthShown&&N?t("otp.phoneLengthError",{digits:me(N,t("otp.or"))}):"",_=p.length>1||W,F=ue(r),V=(0,u.useMemo)(()=>{let m=null;try{m=new Intl.DisplayNames([r],{type:"region"})}catch{}return p.map(L=>({code:L.code,name:m?.of(L.code)??L.code}))},[p,r]),K=p.length>ye,R=[M?"":`${l}-dial ${l}-hint`,A?`${l}-error`:"",f??""].join(" ").trim()||void 0,g=n(m=>{H(!1),requestAnimationFrame(()=>(m==="lead"?B.current:C.current)?.focus())},"close"),$=n(()=>{if(I)return g("lead");H(!0),requestAnimationFrame(()=>(i.current??o.current?.querySelector('[aria-current="true"]')??o.current?.querySelector("button"))?.focus())},"toggle"),O=n(()=>(0,h.jsxs)("span",{className:"sekyro-phone__dial",id:`${l}-dial`,"aria-hidden":_||void 0,children:[(0,h.jsx)("span",{className:"sekyro-phone__flag","aria-hidden":"true",children:b?"🌐":ce(y.code)}),b?null:y.dial]}),"dial");return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)("div",{className:`sekyro-phone${w?" sekyro-phone--compact":""}`,dir:"ltr",children:[y===null||M&&!b?null:_?(0,h.jsx)("button",{ref:B,type:"button",className:"sekyro-phone__lead sekyro-phone__pick","aria-label":`${t("otp.countryLabel")}: ${b?t("otp.otherCountry"):F(y)}`,"aria-expanded":I,"aria-controls":I?G:void 0,onClick:$,children:O()}):(0,h.jsx)("div",{className:"sekyro-phone__lead",children:O()}),(0,h.jsx)("input",{ref:C,id:l,className:"sekyro-phone__input",type:"tel",dir:"ltr",inputMode:"tel",autoComplete:"tel",required:E,"aria-describedby":R,"aria-invalid":!!A||P||void 0,placeholder:c?"+":void 0,value:M?d:Y(T,N),onChange:e.onNumber,onKeyDown:a(m=>{m.key==="Enter"&&D===!1&&e.setLengthShown(!0)},"onKeyDown"),onBlur:a(m=>{let L=m.relatedTarget;L!==null&&(B.current?.contains(L)||o.current?.contains(L))||e.setLengthShown(T!==""&&x===null)},"onBlur")})]}),I?(0,h.jsx)("div",{ref:o,id:G,className:"sekyro-phone__list",onKeyDown:a(m=>{m.key==="Escape"&&(m.preventDefault(),g("lead"))},"onKeyDown"),children:(0,h.jsx)(oe,{countries:V,label:(0,h.jsx)("span",{className:"sekyro-visually-hidden",children:t("otp.countrySearch")}),searchPlaceholder:t("otp.countrySearch"),noMatch:t("doc.noCountryMatch"),searchable:K,scroll:!0,...K?{searchRef:i}:{},...!b&&y!==null?{selected:y.code}:{},detail:a(m=>p.find(L=>L.code===m)?.dial,"detail"),onPick:a(m=>{e.onCountry(m),g("number")},"onPick"),...W?{extra:{label:t("otp.otherCountry"),current:b,onPick:n(()=>{e.onCountry(fe),g("number")},"onPick")}}:{}})}):null,M?null:(0,h.jsx)("span",{className:"sekyro-help",id:`${l}-hint`,children:t("otp.phonePlaceholderGeneric")}),A?(0,h.jsx)("span",{className:"sekyro-help is-danger",id:`${l}-error`,role:"alert",children:A}):null]})}a(Ne,"xe");n(Ne,"PhoneField");export{pe as a,oe as b,ce as c,ge as d,Ne as e};
|
|
1
|
+
import{g as X}from"./chunk-6T7VBPLY.js";import{a as z,b as ee}from"./chunk-EB2QC3GA.js";import{a as n}from"./chunk-5QL6W6FW.js";import{a,c as Z}from"./chunk-4FHWXBOB.js";var u=Z(z(),1),J=Z(z(),1),s=Z(ee(),1);var h=Z(ee(),1);var he="AC247 AD376 AE971/0 AF93/0 AG1/1 AI1/1 AL355/0 AM374/0 AO244 AR54/0 AS1/1 AT43/0 AU61/0 AW297 AX358/0 AZ994/0 BA387/0 BB1/1 BD880/0 BE32/0 BF226 BG359/0 BH973 BI257 BJ229 BL590/0 BM1/1 BN673 BO591/0 BQ599 BR55/0 BS1/1 BT975 BW267 BY375/8 BZ501 CA1/1 CC61/0 CD243/0 CF236 CG242 CH41/0 CI225 CK682 CL56 CM237 CN86/0 CO57/0 CR506 CU53/0 CV238 CW599 CX61/0 CY357 CZ420 DE49/0 DJ253 DK45 DM1/1 DO1/1 DZ213/0 EC593/0 EE372 EG20/0 EH212/0 ER291/0 ES34 ET251/0 FI358/0 FJ679 FK500 FM691 FO298 FR33/0 GA241 GB44/0 GD1/1 GE995/0 GF594/0 GG44/0 GH233/0 GI350 GL299 GM220 GN224 GP590/0 GQ240 GR30 GT502 GU1/1 GW245 GY592 HK852 HN504 HR385/0 HT509 HU36/06 ID62/0 IE353/0 IL972/0 IM44/0 IN91/0 IO246 IQ964/0 IR98/0 IS354 IT39 JE44/0 JM1/1 JO962/0 JP81/0 KE254/0 KG996/0 KH855/0 KI686/0 KM269 KN1/1 KP850/0 KR82/0 KW965 KY1/1 KZ7/8 LA856/0 LB961/0 LC1/1 LI423/0 LK94/0 LR231/0 LS266 LT370/0 LU352 LV371 LY218/0 MA212/0 MC377/0 MD373/0 ME382/0 MF590/0 MG261/0 MH692/1 MK389/0 ML223 MM95/0 MN976/0 MO853 MP1/1 MQ596/0 MR222 MS1/1 MT356 MU230 MV960 MW265/0 MX52 MY60/0 MZ258 NA264/0 NC687 NE227 NF672 NG234/0 NI505 NL31/0 NO47 NP977/0 NR674 NU683 NZ64/0 OM968 PA507 PE51/0 PF689 PG675 PH63/0 PK92/0 PL48 PM508/0 PR1/1 PS970/0 PT351 PW680 PY595/0 QA974 RE262/0 RO40/0 RS381/0 RU7/8 RW250/0 SA966/0 SB677 SC248 SD249/0 SE46/0 SG65 SH290 SI386/0 SJ47 SK421/0 SL232/0 SM378 SN221 SO252/0 SR597 SS211/0 ST239 SV503 SX1/1 SY963/0 SZ268 TA290 TC1/1 TD235 TG228 TH66/0 TJ992 TK690 TL670 TM993/8 TN216 TO676 TR90/0 TT1/1 TV688 TW886/0 TZ255/0 UA380/0 UG256/0 US1/1 UY598/0 UZ998 VA39 VC1/1 VE58/0 VG1/1 VI1/1 VN84/0 VU678 WF681 WS685 XK383/0 YE967/0 YT262/0 ZA27/0 ZM260/0 ZW263/0",j;function Q(e){return j??(j=new Map(he.split(" ").map(l=>{let[r,t]=l.slice(2).split("/");return[l.slice(0,2),[r,t]]}))),j.get(e.toUpperCase())}a(Q,"z");n(Q,"entryOf");function pe(e){return Q(e)?.[0]}a(pe,"Ne");n(pe,"dialCodeOf");function ne(e){return Q(e)?.[1]}a(ne,"ee");n(ne,"nationalPrefixOf");var le=n(e=>e.normalize("NFD").replace(/\p{Diacritic}/gu,"").toLocaleLowerCase(),"fold");function ae(e,l){let r=le(l.trim());return r===""?e:e.filter(t=>le(t.name).includes(r)||t.code.toLowerCase()===r)}a(ae,"ce");n(ae,"matchCountries");function oe({countries:e,label:l,searchPlaceholder:r,noMatch:t,onPick:v,selected:P,searchRef:f,scroll:E=!1,searchable:w=!0,detail:D,extra:y}){let[M,b]=(0,J.useState)(""),c=(0,J.useId)(),T=ae(e,M),N=(0,s.jsxs)("ul",{className:`sekyro-rows${E?" sekyro-rows--scroll":""}`,children:[T.map(d=>{let S=D?.(d.code);return(0,s.jsx)("li",{children:(0,s.jsxs)("button",{type:"button",className:"sekyro-row-btn","aria-current":P===d.code||void 0,onClick:a(()=>v(d.code),"onClick"),children:[(0,s.jsx)("span",{className:"sekyro-row-btn__flag","aria-hidden":"true",children:ce(d.code)}),(0,s.jsx)("span",{className:"sekyro-row-btn__name",children:d.name}),S!==void 0?(0,s.jsx)("bdi",{className:"sekyro-row-btn__detail",dir:"ltr",children:S}):null]})},d.code)}),y!==void 0?(0,s.jsx)("li",{children:(0,s.jsxs)("button",{type:"button",className:"sekyro-row-btn","aria-current":y.current||void 0,onClick:y.onPick,children:[(0,s.jsx)("span",{className:"sekyro-row-btn__flag","aria-hidden":"true",children:"🌐"}),(0,s.jsx)("span",{className:"sekyro-row-btn__name",children:y.label})]})}):null]});return w?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"sekyro-field",children:[(0,s.jsx)("label",{className:"sekyro-label",htmlFor:c,children:l}),(0,s.jsx)("input",{ref:f,id:c,type:"search",className:"sekyro-input",placeholder:r,value:M,onChange:a(d=>b(d.target.value),"onChange")})]}),T.length===0&&y===void 0?(0,s.jsx)("p",{className:"sekyro-text-muted",children:t}):N]}):N}a(oe,"te");n(oe,"CountryList");function U(e){let l=X(e).replace(/\D/g,"");return/^\D*\+/.test(e)?`+${l}`:l.startsWith("00")?`+${l.slice(2)}`:l}a(U,"H");n(U,"digitsOf");var te=n((e,l)=>(l.trunk!==void 0&&e.startsWith(l.trunk)?e.slice(l.trunk.length):e).slice(0,Math.max(...l.lengths)),"fitDigits");function Y(e,l){let r="",t=0;for(let v of l?.formats?.find(P=>new RegExp(`^(?:${P.leading})`).test(e))?.groups??[])t<e.length&&(r+=(t>0?" ":"")+e.slice(t,t+v)),t+=v;return r+e.slice(t)}a(Y,"Z");n(Y,"groupDigits");function ie(e,l){let r=0;for(let t=l;t>0&&r<e.length;r+=1)e[r]!==" "&&(t-=1);return r}a(ie,"oe");n(ie,"caretAfter");var se=n((e,l)=>l.find(r=>e.startsWith(r.dial)),"countryOfNumber"),me=n((e,l)=>e.lengths.join(", ").replace(/, (\d+)$/,` ${l} $1`),"lengthsLabel");function q(e){let l=U(e).replace("+","");return/^\d{8,15}$/.test(l)?`+${l}`:null}a(q,"le");n(q,"normalizedPhone");var ce=n(e=>String.fromCodePoint(...Array.from(e.toUpperCase(),l=>127397+l.charCodeAt(0))),"flagOf");function de(e,l){if(l===null||!e.startsWith(l.dial))return q(e);let r=e.slice(l.dial.length).replace(/\D/g,""),t=ne(l.code);return t!==void 0&&r.startsWith(t)&&(r=r.slice(t.length)),q(l.dial+r)}a(de,"ye");n(de,"e164Of");var re=n((e,l)=>(se(e,l)??l[0])?.code??null,"countryFor");function ue(e){let l=null;try{l=new Intl.DisplayNames([e],{type:"region"})}catch{}return r=>`${l?.of(r.code)??r.code} (${r.dial})`}a(ue,"me");n(ue,"countryLabels");var fe="other",ye=8;function ge({countries:e,international:l,closed:r,defaultPhone:t}){let[v,P]=(0,u.useState)(()=>re(t,e)),[f,E]=(0,u.useState)(t),[w,D]=(0,u.useState)(!1),[y,M]=(0,u.useState)(!1),b=e.map(o=>o.code).join(","),c=e.find(o=>o.code===v)??null,T=(0,u.useRef)(c);c!==null&&(T.current=c),(0,u.useEffect)(()=>{if(v===null||!e.some(o=>o.code===v)){let o=re(t,e);P(o);let i=T.current,k=e.find(C=>C.code===o)?.dial;k!==void 0&&E(C=>i!==null&&C.startsWith(i.dial)?k+C.slice(i.dial.length):C.startsWith("+")?C:k)}},[b,t]);let N=w||c===null,d=N||f.startsWith("+")&&!f.startsWith(c.dial),S=d?void 0:c.rule,x=d?f:f.replace(c.dial,"").replace(/\D/g,""),p=S?te(x,S):x,W=d&&!N&&!l&&r&&!e.some(o=>o.dial.startsWith(f)),I=W?null:S?S.lengths.includes(p.length)?c.dial+p:null:N&&!f.startsWith("+")?null:de(f,w?null:c),H=d||c===null?I??f:`${c.dial} ${Y(p,S)}`,B=d?U(f).replace("+","")==="":p==="";return{countries:e,international:l,phone:f,selected:c,other:w,whole:d,free:N,rule:S,national:p,refused:W,typed:I,shown:H,empty:B,lengthShown:y,setLengthShown:M,onNumber:n(o=>{let i=o.target,k=o.nativeEvent.inputType,C=Math.max(0,i.value.lastIndexOf("+")),G=U(i.value.slice(C)),A=se(G,e),_=U(i.value.slice(C,i.selectionStart)).length,F=G,V=G;if(M(!1),!A&&(N||G.startsWith("+")))l&&D(!0);else{let R=A??c,g=A?G.slice(A.dial.length):G;if(P(R.code),D(!1),g===p&&k?.startsWith("delete")&&(k.endsWith("Forward")||(_-=1),g=g.slice(0,_)+g.slice(_+1)),R.rule){let $=te(g,R.rule),O=g.length-$.length;_-=O,g=O>0&&!A&&p.length===$.length?p:$}V=R.dial+g,F=Y(g,R.rule)}E(V),i.value=F;let K=ie(F,_);i.setSelectionRange(K,K)},"onNumber"),onCountry:n(o=>{M(!1);let i=e.find(k=>k.code===o);D(i===void 0),i!==void 0&&P(i.code),E(i===void 0?"":i.dial+(d?"":p))},"onCountry")}}a(ge,"_e");n(ge,"usePhoneField");function Ne({field:e,id:l,locale:r,t,inputRef:v,invalid:P=!1,describedby:f,required:E,compact:w=!1,ready:D}){let{selected:y,whole:M,other:b,free:c,national:T,rule:N,phone:d,refused:S,typed:x,countries:p,international:W}=e,[I,H]=(0,u.useState)(!1),B=(0,u.useRef)(null),o=(0,u.useRef)(null),i=(0,u.useRef)(null),k=(0,u.useRef)(null),C=v??k,G=(0,u.useId)(),A=S?t("otp.reason_otp_destination_not_allowed"):e.lengthShown&&N?t("otp.phoneLengthError",{digits:me(N,t("otp.or"))}):"",_=p.length>1||W,F=ue(r),V=(0,u.useMemo)(()=>{let m=null;try{m=new Intl.DisplayNames([r],{type:"region"})}catch{}return p.map(L=>({code:L.code,name:m?.of(L.code)??L.code}))},[p,r]),K=p.length>ye,R=[M?"":`${l}-dial ${l}-hint`,A?`${l}-error`:"",f??""].join(" ").trim()||void 0,g=n(m=>{H(!1),requestAnimationFrame(()=>(m==="lead"?B.current:C.current)?.focus())},"close"),$=n(()=>{if(I)return g("lead");H(!0),requestAnimationFrame(()=>(i.current??o.current?.querySelector('[aria-current="true"]')??o.current?.querySelector("button"))?.focus())},"toggle"),O=n(()=>(0,h.jsxs)("span",{className:"sekyro-phone__dial",id:`${l}-dial`,"aria-hidden":_||void 0,children:[(0,h.jsx)("span",{className:"sekyro-phone__flag","aria-hidden":"true",children:b?"🌐":ce(y.code)}),b?null:y.dial]}),"dial");return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)("div",{className:`sekyro-phone${w?" sekyro-phone--compact":""}`,dir:"ltr",children:[y===null||M&&!b?null:_?(0,h.jsx)("button",{ref:B,type:"button",className:"sekyro-phone__lead sekyro-phone__pick","aria-label":`${t("otp.countryLabel")}: ${b?t("otp.otherCountry"):F(y)}`,"aria-expanded":I,"aria-controls":I?G:void 0,onClick:$,children:O()}):(0,h.jsx)("div",{className:"sekyro-phone__lead",children:O()}),(0,h.jsx)("input",{ref:C,id:l,className:"sekyro-phone__input",type:"tel",dir:"ltr",inputMode:"tel",autoComplete:"tel",required:E,"aria-describedby":R,"aria-invalid":!!A||P||void 0,placeholder:c?"+":void 0,value:M?d:Y(T,N),onChange:e.onNumber,onKeyDown:a(m=>{m.key==="Enter"&&D===!1&&e.setLengthShown(!0)},"onKeyDown"),onBlur:a(m=>{let L=m.relatedTarget;L!==null&&(B.current?.contains(L)||o.current?.contains(L))||e.setLengthShown(T!==""&&x===null)},"onBlur")})]}),I?(0,h.jsx)("div",{ref:o,id:G,className:"sekyro-phone__list",onKeyDown:a(m=>{m.key==="Escape"&&(m.preventDefault(),g("lead"))},"onKeyDown"),children:(0,h.jsx)(oe,{countries:V,label:(0,h.jsx)("span",{className:"sekyro-visually-hidden",children:t("otp.countrySearch")}),searchPlaceholder:t("otp.countrySearch"),noMatch:t("doc.noCountryMatch"),searchable:K,scroll:!0,...K?{searchRef:i}:{},...!b&&y!==null?{selected:y.code}:{},detail:a(m=>p.find(L=>L.code===m)?.dial,"detail"),onPick:a(m=>{e.onCountry(m),g("number")},"onPick"),...W?{extra:{label:t("otp.otherCountry"),current:b,onPick:n(()=>{e.onCountry(fe),g("number")},"onPick")}}:{}})}):null,M?null:(0,h.jsx)("span",{className:"sekyro-help",id:`${l}-hint`,children:t("otp.phonePlaceholderGeneric")}),A?(0,h.jsx)("span",{className:"sekyro-help is-danger",id:`${l}-error`,role:"alert",children:A}):null]})}a(Ne,"xe");n(Ne,"PhoneField");export{pe as a,oe as b,ce as c,ge as d,Ne as e};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as Mr,d as Ar}from"./chunk-SYUAQ7BF.js";import{a as Ir}from"./chunk-AKU6DWJM.js";import{b as Lr,c as Nt}from"./chunk-DO66BOHU.js";import{d as _t}from"./chunk-6T7VBPLY.js";import{c as at}from"./chunk-ZWGMVZWP.js";import{a as xr,b as Rr,c as Nr,d as Ee}from"./chunk-PWGUNXYH.js";import{F as Er,K as xt,L as Rt,a as W,b as de,c as Y,m as Cr,n as Fe,p as _r,q as nt,r as wr,s as Sr,t as wt,u as le,v as me,w as $e,y as St}from"./chunk-EB2QC3GA.js";import{a}from"./chunk-5QL6W6FW.js";import{c as gr,d as vr,e as kr,h as br}from"./chunk-5OPKZZON.js";import{b as Ct}from"./chunk-EGCT7K5E.js";import{g as yr}from"./chunk-6MYG4HWP.js";import{a as l,c as T}from"./chunk-4FHWXBOB.js";var jr=T(W(),1),g=T(de(),1),ne=T(de(),1),ve=T(W(),1),K=T(de(),1),_=T(W(),1),y=T(W(),1),ot=T(W(),1),ye=T(de(),1),nn=T(W(),1),ee=T(W(),1),ct=T(W(),1),Se=T(de(),1),xe=T(de(),1),P=T(de(),1);var ut=T(W(),1),pe=T(W(),1);var J=T(W(),1);var L=T(W(),1),ge=T(W(),1),He=T(W(),1),Ut=T(de(),1),k=T(de(),1);function ce({className:e,children:t}){return(0,g.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})}l(ce,"ne");a(ce,"Svg");var jt="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 Tr(e){return(0,g.jsxs)(ce,{...e,children:[(0,g.jsx)("circle",{cx:"12",cy:"12",r:"4"}),(0,g.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"})]})}l(Tr,"pn");a(Tr,"SunIcon");function Hr(e){return(0,g.jsxs)(ce,{...e,children:[(0,g.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,g.jsx)("path",{d:"M9 10h.01M15 10h.01M8.8 14.6a4.2 4.2 0 0 0 6.4 0"})]})}l(Hr,"fn");a(Hr,"FaceUncoveredIcon");function Or(e){return(0,g.jsxs)(ce,{...e,children:[(0,g.jsx)("rect",{x:"7",y:"2.5",width:"10",height:"19",rx:"2"}),(0,g.jsx)("path",{d:"M10.5 18.5h3M2.5 9.5h2.5M19 9.5h2.5"}),(0,g.jsx)("circle",{cx:"12",cy:"9.5",r:"1.6"})]})}l(Or,"mn");a(Or,"PhoneEyeLevelIcon");function Pr(e){return(0,g.jsxs)(ce,{...e,children:[(0,g.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,g.jsx)("circle",{cx:"12",cy:"12",r:"2.8"})]})}l(Pr,"yn");a(Pr,"LookStraightIcon");function Br(e){return(0,g.jsxs)(ce,{...e,children:[(0,g.jsx)("path",{d:jt}),(0,g.jsx)("path",{d:"M9 13l2 2 4-4"})]})}l(Br,"gn");a(Br,"CameraCheckIcon");function qr(e){return(0,g.jsxs)(ce,{...e,children:[(0,g.jsx)("path",{d:jt}),(0,g.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"})]})}l(qr,"hn");a(qr,"CameraAskIcon");function Vr(e){return(0,g.jsxs)(ce,{...e,children:[(0,g.jsx)("path",{d:jt}),(0,g.jsx)("path",{d:"M3 3l18 18"})]})}l(Vr,"vn");a(Vr,"CameraBlockedIcon");function it({off:e,className:t}){return(0,g.jsxs)(ce,{className:t,children:[(0,g.jsx)("path",{d:"M4.5 9.5v5H8l4 3.5v-12L8 9.5H4.5Z"}),e?(0,g.jsx)("path",{d:"M4 4l16 16"}):(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("path",{d:"M15.5 9.7a3.6 3.6 0 0 1 0 4.6"}),(0,g.jsx)("path",{d:"M18 7.6a6.6 6.6 0 0 1 0 8.8"})]})]})}l(it,"Ve");a(it,"SpeakerIcon");function Dr(e){return(0,g.jsx)(ce,{...e,children:(0,g.jsx)("path",{d:"M5 12.5l4.5 4.5L19 7.5"})})}l(Dr,"Cn");a(Dr,"CheckIcon");function Fr(e){return(0,g.jsxs)(ce,{className:e.className??"sekyro-spinner",children:[(0,g.jsx)("circle",{cx:"12",cy:"12",r:"9",opacity:"0.25"}),(0,g.jsx)("path",{d:"M21 12a9 9 0 0 0-9-9"})]})}l(Fr,"kn");a(Fr,"SpinnerIcon");var Mt=["light","uncover","eyeLevel","straight"],qn={light:{key:"capture.tips.light",icon:a(()=>(0,ne.jsx)(Tr,{}),"icon")},uncover:{key:"capture.tips.uncover",icon:a(()=>(0,ne.jsx)(Hr,{}),"icon")},eyeLevel:{key:"capture.tips.eyeLevel",icon:a(()=>(0,ne.jsx)(Or,{}),"icon")},straight:{key:"capture.tips.straight",icon:a(()=>(0,ne.jsx)(Pr,{}),"icon")}};function $r({tips:e}){let t=Ee(),n=(0,jr.useId)();return e.length===0?null:(0,ne.jsxs)("section",{className:"sekyro-tips","aria-labelledby":n,"data-testid":"sekyro-tips",children:[(0,ne.jsx)("p",{className:"sekyro-tips__title",id:n,children:t("capture.tips.title")}),(0,ne.jsx)("ul",{className:"sekyro-tips__list",children:e.map(r=>{let s=typeof r=="string"?qn[r]:void 0,i=typeof r=="string"?r:r.id,c=s!==void 0?s.icon():typeof r=="string"?void 0:r.icon,p=s!==void 0?t(s.key):typeof r=="string"?r:r.text;return(0,ne.jsxs)("li",{className:"sekyro-tips__item",children:[c!=null?(0,ne.jsx)("span",{className:"sekyro-tips__icon","aria-hidden":"true",children:c}):null,(0,ne.jsx)("span",{children:p})]},i)})})]})}l($r,"Sn");a($r,"TipList");var Vn=220;function Kr({title:e,description:t,options:n,busy:r,error:s,focus:i,testId:c,look:p="cards",marked:w,onChoose:h}){let m=(0,ve.useId)(),R=wt(),[x,U]=(0,ve.useState)(null),M=(0,ve.useRef)(null);(0,ve.useEffect)(()=>{s!==null&&U(null)},[s]),(0,ve.useEffect)(()=>()=>{M.current!==null&&clearTimeout(M.current)},[]);let B=a(A=>{r||x!==null||(U(A),M.current=setTimeout(()=>{M.current=null,U(null),h(A)},Vn))},"choose");return(0,K.jsxs)("section",{className:"sekyro-stack sekyro-stack--4 sekyro-choice","aria-labelledby":m,"data-testid":c,children:[(0,K.jsxs)("div",{className:p==="cards"?"sekyro-heading":"sekyro-stack sekyro-stack--1",children:[(0,K.jsx)("h2",{id:m,ref:i?R:void 0,tabIndex:-1,className:"sekyro-text-body",children:e}),t!==void 0&&t!==""?(0,K.jsx)("p",{className:"sekyro-text-muted",children:t}):null]}),s!==null?(0,K.jsx)(le,{tone:"danger",children:(0,K.jsx)("span",{children:s})}):null,p==="buttons"?(0,K.jsx)("div",{className:"sekyro-stack sekyro-stack--3",children:n.map((A,te)=>(0,K.jsx)(Y,{kind:te===0?"primary":"ghost",full:!0,disabled:r,"aria-busy":r||void 0,onClick:l(()=>h(A.id),"onClick"),children:A.label},A.id))}):(0,K.jsx)("div",{className:"sekyro-choices",children:n.map(A=>(0,K.jsxs)("button",{type:"button",className:"sekyro-card","aria-pressed":(x??w)===A.id,"aria-busy":r||void 0,disabled:r||x!==null&&x!==A.id,onClick:l(()=>B(A.id),"onClick"),children:[A.glyph!==void 0?(0,K.jsx)("span",{className:"sekyro-card__tile",children:A.glyph}):null,(0,K.jsxs)("span",{className:"sekyro-card__body",children:[(0,K.jsx)("span",{className:"sekyro-card__title",children:A.label}),A.sub!==void 0?(0,K.jsx)("span",{className:"sekyro-card__sub",children:A.sub}):null]}),(0,K.jsx)("span",{className:"sekyro-radio","aria-hidden":"true"})]},A.id))})]})}l(Kr,"Vn");a(Kr,"ChoiceScreen");var Gr=["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","capture.lookAtColours"];function lt(e){return e!==null&&Gr.includes(e)}l(lt,"he");a(lt,"isVoiceKey");var Dn=a((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 s=e[n];r=s!=null&&Dn(s,t)?s[t]:null}}catch{return null}return typeof r=="string"&&r!==""?r:null}l(je,"we");a(je,"resolveClip");var Fn="UklGRiQAAABXQVZFZm10IBAAAAABAAEAESsAACJWAAACABAAZGF0YQAAAAA=",$n={ar:"ar-SA",fr:"fr-FR",en:"en-US",es:"es-ES",pt:"pt-BR",de:"de-DE"};function oe(){return typeof window<"u"&&"speechSynthesis"in window?window.speechSynthesis:null}l(oe,"re");a(oe,"synth");function zr(){return oe()!==null&&typeof SpeechSynthesisUtterance=="function"}l(zr,"Ir");a(zr,"speechAvailable");function At(e){return(e.split(/[-_]/)[0]??e).toLowerCase()}l(At,"wn");a(At,"baseLang");function Tt(e,t){let n=a(s=>s.replace(/_/g,"-").toLowerCase(),"norm"),r=At(t);return e.find(s=>n(s.lang)===n(t))??e.find(s=>At(s.lang)===r)}l(Tt,"_n");a(Tt,"pickVoice");function Wr(e){if(!zr())return!1;let t=[];try{t=oe()?.getVoices()??[]}catch{return!0}return t.length===0||Tt(t,e)!==void 0}l(Wr,"In");a(Wr,"speechUsable");function Zr(e){let t=oe();return t===null||typeof t.addEventListener!="function"?()=>{}:(t.addEventListener("voiceschanged",e),()=>t.removeEventListener?.("voiceschanged",e))}l(Zr,"xn");a(Zr,"subscribeVoices");function Ge(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}`}}l(Ge,"He");a(Ge,"clipIdentity");function Et(e){e.pause(),e.removeAttribute("src"),e.load()}l(Et,"Mn");a(Et,"release");function Qr(){let e=null,t=null,n=0,r=null,s=null,i=null,c=!1,p=null,w=[],h=new Map,m=a(()=>{w=oe()?.getVoices()??[]},"loadVoices"),R=!1,x=a(()=>{let f=oe();R||f===null||(R=!0,m(),f.addEventListener?.("voiceschanged",m))},"bindVoices"),U=a(()=>(e??(e=new Audio),e),"element"),M=a((f,N,S,b)=>{let u=oe();if(u!==null&&f!==""&&typeof SpeechSynthesisUtterance=="function"){x();let E=Tt(w,N);if(w.length===0||E!==void 0){u.cancel();let j=new SpeechSynthesisUtterance(f);j.lang=N,E!==void 0&&(j.voice=E),j.rate=.95,S!==void 0&&(j.onend=S),(S!==void 0||b!==void 0)&&(j.onerror=D=>{b!==void 0&&D.error==="not-allowed"?b():S?.()}),u.speak(j);return}}S?.()},"speak"),B=a(()=>{n+=1,r=null,s=i=null,e!==null&&(e.pause(),e.currentTime=0),oe()?.cancel()},"stop"),A=a(f=>{for(let N of f){let S=Ge(N);if(h.has(S))continue;let b=new Audio;b.preload="auto",b.src=N,h.set(S,b)}},"warmClips"),te=a((f,N,S)=>{let b={utterance:f,generation:N,end:S};p=b;let u=a(()=>N===n&&p===b,"live"),E=a(()=>{u()&&(s=b)},"block");if(oe()?.cancel(),f.url!==null){let j=U();j.pause(),j.muted=!1,j.src=f.url,j.currentTime=0,j.onended=S??null;let D=a(()=>{i===b&&(i=null)},"settled"),o=j.play();if(o===void 0)return;i=b,o.then(D,H=>{if(D(),!u())return;let O=H?.name;if(O!=="AbortError"){if(O==="NotAllowedError")return E();f.speech?M(f.text,f.lang,S,E):S?.()}});return}f.speech?M(f.text,f.lang,S,E):S?.()},"start");return{say(f){let N=f.url!==null?Ge(f.url):`tts:${f.lang}:${f.text}`;if(N===r)return;r=N,s=i=null,n+=1;let S=n,b=f.onEnd;te(f,S,b!==void 0?()=>{S===n&&b()}:void 0)},unlock({lang:f,speech:N,prefetch:S}){let b=s??(c?null:i);c=!0;let u=b!==null&&b.generation===n?b:null;s=i=null,u!==null&&te(u.utterance,u.generation,u.end);let E=U();if(t===null&&typeof Blob=="function"&&typeof URL.createObjectURL=="function"){let H=Uint8Array.from(atob(Fn),O=>O.charCodeAt(0));t=URL.createObjectURL(new Blob([H],{type:"audio/wav"}))}let j=E.paused===!1&&t!==null&&E.src!==t;t!==null&&!j&&(u===null||u.utterance.url===null)&&(E.muted=!0,E.onended=null,E.src=t,E.play()?.catch(()=>{}));let D=oe(),o=u!==null&&u.utterance.url===null;if(N&&!o&&D!==null&&typeof SpeechSynthesisUtterance=="function"){x();let H=new SpeechSynthesisUtterance(" ");H.volume=0,H.lang=f,D.speak(H)}A(S??[])},prefetch:A,stop:B,dispose(){B(),R&&oe()?.removeEventListener?.("voiceschanged",m),R=!1,t!==null&&URL.revokeObjectURL(t),t=null,e!==null&&Et(e),e=null;for(let f of h.values())Et(f);h.clear()}}}l(Qr,"En");a(Qr,"createVoicePlayer");var Kn="sekyro.voiceGuidance";function Xr(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}}l(Xr,"Nn");a(Xr,"readVoicePreference");function Yr(e,t){try{if(typeof window>"u")return;window.localStorage.setItem(e,t?"1":"0")}catch{}}l(Yr,"Pn");a(Yr,"writeVoicePreference");var Ke="capture.tips.summary",Gn=typeof window<"u"?_.useLayoutEffect:_.useEffect,zn=Object.freeze({});function st(e,t){let n=new Set,r=[];for(let s of Gr){let i=s===Ke?null:je(e,s,t);i===null||n.has(Ge(i))||(n.add(Ge(i)),r.push(i))}return r}l(st,"vt");a(st,"resolvedClipUrls");function Jr({locale:e,defaultClips:t,options:n}){let r=n===!1,s=r?{}:n??{},i=s.storageKey===void 0?Kn:s.storageKey,[c,p]=(0,_.useState)(s.defaultEnabled??!0),w=(0,_.useRef)(c),[h,m]=(0,_.useState)(!1),[R,x]=(0,_.useState)("none"),[U,M]=(0,_.useState)(!1),B=(0,_.useRef)(!1),[A,te]=(0,_.useState)(0),f=(0,_.useRef)(null),N=(0,_.useCallback)(()=>(f.current??(f.current=Qr()),f.current),[]),S=$n[e],b=s.speechFallback,u=b===void 0||b===!0?!0:b===!1?!1:b.includes(e),E=s.clips??t??zn,j=(0,_.useRef)(!1),D=(0,_.useRef)(E);Gn(()=>{D.current=E,w.current=c}),(0,_.useEffect)(()=>{if(r||i===null)return;let I=Xr(i);I!==null&&(w.current=I,p(I))},[r,i]),(0,_.useEffect)(()=>{if(!(r||!u))return Zr(()=>te(I=>I+1))},[r,u]);let o=s.clips;(0,_.useEffect)(()=>{if(r)return;let I=u&&Wr(S);m(st(E,e).length>0||I),x(o!==void 0&&je(o,Ke,e)!==null?"partner":je(E,Ke,e)!==null||I?"default":"none")},[r,E,o,e,u,S,A]),(0,_.useEffect)(()=>{if(r||!c||!j.current)return;let I=st(E,e);I.length>0&&N().prefetch(I)},[r,c,E,e,N]),(0,_.useEffect)(()=>()=>{f.current?.dispose(),f.current=null,j.current=!1},[]);let H=(0,_.useCallback)(I=>{r||(j.current=!0,N().unlock({lang:S,speech:u,...I?{prefetch:st(D.current,e)}:{}}))},[r,N,S,u,e]),O=(0,_.useCallback)(()=>H(w.current),[H]),Z=(0,_.useCallback)(()=>{B.current=!1,M(!1)},[]),F=(0,_.useCallback)(()=>{Z(),f.current?.stop()},[Z]),ke=(0,_.useCallback)(()=>{B.current&&F()},[F]),he=(0,_.useCallback)((I,Re)=>{if(r)return;if(B.current){F();return}let be=N();be.stop(),B.current=!0,M(!0);let q=Re?.clip===!1?null:je(D.current,Ke,e);be.say({url:q,text:I,lang:S,speech:u,onEnd:Z})},[r,F,N,e,S,u,Z]),Q=(0,_.useCallback)(I=>{r||(I?H(!0):F(),i!==null&&Yr(i,I),w.current=I,p(I))},[r,H,F,i]),X=(0,_.useCallback)(()=>Q(!w.current),[Q]),ae=(0,_.useCallback)((I,Re)=>{if(r||!c)return;B.current&&Z();let be=je(D.current,I,e);N().say({url:be,text:Re,lang:S,speech:u})},[r,c,e,N,S,u,Z]);return(0,_.useMemo)(()=>({supported:!r&&h,enabled:!r&&c,setEnabled:Q,toggle:X,unlock:O,speakKey:ae,stop:F,summary:r?"none":R,summaryPlaying:U,toggleSummary:he,stopSummary:ke}),[r,h,c,Q,X,O,ae,F,R,U,he,ke])}l(Jr,"Ct");a(Jr,"useVoiceGuidance");function en(e,t,n,r){let{speakKey:s,stop:i,enabled:c}=e,p=(0,_.useRef)(!1);(0,_.useEffect)(()=>{if(!r||!c){p.current&&i(),p.current=!1;return}p.current=!0,lt(t)&&t!==Ke&&n!==""&&s(t,n)},[r,c,t,n,s,i])}l(en,"kt");a(en,"useSpeakGuidance");function ze(e,t){let n=tn(e);return n==="face"&&(t==="lighting"||e==="liveness_inconclusive")?"again":n}l(ze,"On");a(ze,"retryCoachingOf");function tn(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"}}l(tn,"Kr");a(tn,"coachingOfReason");var Te={face:{title:"capture.retryCoaching.title",tips:["capture.retryCoaching.light","capture.retryCoaching.eyeLevel","capture.retryCoaching.head"]},again:{title:"capture.retryTips.title",tips:["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 rn({showCoaching:e,coaching:t="face",attemptsText:n,showRetake:r,onRetake:s}){let i=Ee(),c=(0,ot.useRef)(null);return(0,ot.useEffect)(()=>{r&&c.current?.focus()},[r]),!e&&!r?null:(0,ye.jsxs)("div",{className:"sekyro-stack sekyro-stack--3","data-testid":"sekyro-captured-panel",children:[e?(0,ye.jsxs)("div",{className:"sekyro-stack sekyro-stack--1",children:[(0,ye.jsx)("p",{className:"sekyro-text-body",children:i(Te[t].title)}),(0,ye.jsx)("ul",{className:"sekyro-coaching",children:Te[t].tips.map(p=>(0,ye.jsx)("li",{children:i(p)},p))}),n!==null?(0,ye.jsx)("p",{className:"sekyro-text-muted","data-testid":"sekyro-attempts-remaining",children:n}):null]}):null,r?(0,ye.jsx)(Y,{ref:c,className:"sekyro-btn--start",onClick:s,children:i("capture.recordAgain")}):null]})}l(rn,"Hn");a(rn,"CapturedPanel");function Ht(){try{return!1}catch{return!1}}l(Ht,"rt");a(Ht,"isDevBuild");var Wn=(0,nn.createContext)(null);function an({state:e}){let t=Ee(),[n,r]=(0,ct.useState)(!1);(0,ct.useEffect)(()=>{e!=="unknown"&&r(!0)},[e]);let s=e==="granted"?(0,Se.jsx)(Br,{}):e==="denied"?(0,Se.jsx)(Vr,{}):(0,Se.jsx)(qr,{});return(0,Se.jsxs)("div",{role:n?"status":void 0,className:`sekyro-permission sekyro-permission--${e}`,"data-testid":"sekyro-permission","data-state":e,children:[(0,Se.jsx)("span",{className:"sekyro-permission__icon","aria-hidden":"true",children:s}),(0,Se.jsx)("span",{children:t(`capture.permission.${e}`)})]})}l(an,"Gn");a(an,"PermissionRow");function sn({voice:e}){let t=Ee();if(!e.supported)return null;let n=e.enabled;return(0,xe.jsxs)("button",{type:"button",role:"switch","aria-checked":n,className:"sekyro-switch","data-testid":"sekyro-voice-switch",onClick:l(()=>e.toggle(),"onClick"),children:[(0,xe.jsxs)("span",{className:"sekyro-switch__label",children:[(0,xe.jsx)(it,{off:!n}),t("capture.voiceGuidance")]}),(0,xe.jsx)("span",{className:"sekyro-switch__track","aria-hidden":"true",children:(0,xe.jsx)("span",{className:"sekyro-switch__thumb",children:n?(0,xe.jsx)(Dr,{className:"sekyro-switch__check"}):null})})]})}l(sn,"Fn");a(sn,"VoiceSwitch");function ln({assets:e,onRetryAssets:t,permission:n,captureMode:r="self",voice:s,tips:i,summary:c,startLabel:p,startDisabled:w,onStart:h}){let m=Ee(),R=(0,ee.useRef)(c?.stop);R.current=c?.stop,(0,ee.useEffect)(()=>()=>R.current?.(),[]);let x=(0,ee.useRef)(null),U=(0,ee.useRef)(null),M=(0,ee.useRef)(null),B=(0,ee.useRef)(e),A=(0,ee.useRef)(!1);(0,ee.useEffect)(()=>{let u=B.current;if(B.current=e,u===e)return;let E=A.current;e!=="loading"&&(A.current=!1),on(x.current)&&(e==="failed"?M.current?.focus():E&&U.current?.focus())},[e]);let te=(0,ee.useCallback)(()=>{A.current=!0,t()},[t]),f=e==="loading",N=f||w,S=(0,ee.useCallback)(()=>{N||(R.current?.(),h())},[N,h]),b;return e==="failed"?b=(0,P.jsxs)(le,{tone:"danger",testId:"sekyro-assets-error",children:[(0,P.jsx)("p",{className:"sekyro-text-body",children:m("fcv2.err.models")}),(0,P.jsx)(Y,{kind:"ghost",ref:M,className:"sekyro-btn--start",onClick:te,"data-testid":"sekyro-assets-retry",children:m("common.retry")})]}):b=(0,P.jsxs)("div",{className:"sekyro-stack sekyro-stack--1",children:[(0,P.jsx)(Y,{ref:U,full:!0,"data-testid":"sekyro-start","aria-disabled":N?"true":void 0,"aria-busy":f?"true":void 0,onClick:S,children:f?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(Fr,{}),m("capture.preparing.title")]}):p??m("capture.start")}),f?(0,P.jsx)("p",{className:"sekyro-text-muted",children:m("capture.preparing.hint")}):null]}),(0,P.jsxs)("div",{ref:x,className:"sekyro-stack sekyro-stack--4","data-testid":"sekyro-intro","data-assets":e,children:[r==="assisted"?(0,P.jsxs)("div",{className:"sekyro-stack sekyro-stack--1","data-testid":"sekyro-assisted-intro",children:[(0,P.jsx)("h2",{className:"sekyro-text-body",children:m("capture.assisted.title")}),(0,P.jsx)("p",{className:"sekyro-text-muted",children:m("capture.assisted.lead")})]}):null,i!==!1?(0,P.jsx)($r,{tips:i}):null,c!==void 0?(0,P.jsxs)(Y,{kind:"ghost",className:"sekyro-btn--start",onClick:c.toggle,"data-testid":"sekyro-tips-listen",children:[(0,P.jsx)(it,{off:!1}),m(c.playing?"capture.tips.stop":"capture.tips.listen")]}):null,(0,P.jsx)(an,{state:n}),(0,P.jsx)(sn,{voice:s}),(0,P.jsx)("p",{className:"sekyro-text-muted",children:m("capture.securityNote")}),b,(0,P.jsx)("p",{role:"status",className:"sekyro-visually-hidden","data-testid":"sekyro-intro-status",children:e==="loading"?m("capture.preparing.title"):e==="ready"?m("capture.ready"):""})]})}l(ln,"jn");a(ln,"PreCaptureScreen");function on(e){if(typeof document>"u")return!1;let t=document.activeElement;return t===null||t===document.body||e!==null&&e.contains(t)}l(on,"Br");a(on,"focusIsOurs");function cn(){let[e,t]=(0,ut.useState)({state:"unknown",settled:!1});return(0,ut.useEffect)(()=>yr(n=>t({state:n,settled:!0})),[]),{permission:e.state,permissionSettled:e.settled}}l(cn,"Yn");a(cn,"useCameraStatus");function un(e){return Ot(e,"mobileRequired")}l(un,"$n");a(un,"useMobileRequired");function dn(e){return Ot(e,"returning").required}l(dn,"zn");a(dn,"useReturning");function Ot(e,t){let[n,r]=(0,pe.useState)({required:!1,settled:e===void 0});return(0,pe.useEffect)(()=>{let s=e?.[t];if(e===void 0||typeof s!="function"){r({required:!1,settled:!0});return}let i=!0;return r({required:!1,settled:!1}),Promise.resolve().then(()=>s.call(e)).then(c=>{i&&r({required:c===!0,settled:!0})},()=>{i&&r({required:!1,settled:!0})}),()=>{i=!1}},[e,t]),n}l(Ot,"Zn");a(Ot,"useFlag");function pn(e){let t=a(()=>e?.captureChoice??null,"initialChoice"),[n,r]=(0,pe.useState)(()=>({session:"self",choice:t(),settled:e===void 0}));(0,pe.useEffect)(()=>{let i=e?.captureMode,c=e?.captureChoice??null;if(e===void 0||typeof i!="function"){r({session:"self",choice:c,settled:!0});return}let p=!0;return r({session:"self",choice:c,settled:!1}),Promise.resolve().then(()=>i.call(e)).then(w=>{let h=e.captureChoice??null;p&&r({session:h!==null&&w===h?"choice":w==="assisted"||w==="choice"?w:"self",choice:h,settled:!0})},()=>{p&&r({session:"self",choice:null,settled:!0})}),()=>{p=!1}},[e]);let s=(0,pe.useCallback)(i=>{e?.chooseCaptureMode?.(i),r(c=>({...c,choice:i}))},[e]);return{mode:n.session==="choice"?n.choice??"self":n.session==="assisted"?"assisted":"self",session:n.session,choice:n.choice,settled:n.settled,choose:s}}l(pn,"Wn");a(pn,"useCaptureMode");function hn(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)),s=e.on("result",()=>n(!1));return()=>{r(),s()}},[e]),t}l(hn,"Qn");a(hn,"useBusy");var Zn=a(()=>"idle","serverSnapshot");function Lt(e){return gr(e!==void 0?{assetBaseUrl:e}:{})}l(Lt,"er");a(Lt,"preload");function fn(e,t=!0){let n=(0,J.useSyncExternalStore)((0,J.useCallback)(h=>kr(h,e),[e]),()=>vr(e),Zn),[r,s]=(0,J.useState)(null),i=(0,J.useRef)(!1),c=(0,J.useCallback)(()=>{Lt(e).then(h=>{i.current&&h==="idle"&&s({base:e})})},[e]);(0,J.useEffect)(()=>(i.current=!0,c(),()=>{i.current=!1}),[c]);let p=(0,J.useRef)(null);(0,J.useEffect)(()=>{if(n!=="idle"){p.current={base:e};return}!t||p.current===null||p.current.base!==e||(p.current=null,c())},[n,e,c,t]);let w=(0,J.useCallback)(()=>{Lt(e)},[e]);return{gate:r!==null&&r.base===e&&n==="idle"||n==="ready"?"ready":n==="failed"?"failed":"loading",retry:w}}l(fn,"tr");a(fn,"useLivenessAssets");var Ur={progress:0,hint:null,faceDetected:!1};function mn(e){let{videoRef:t,assetBaseUrl:n}=e,r=(0,L.useRef)(e.verification).current,s=(0,L.useRef)(!1);e.verification!==r&&!s.current&&Ht()&&(s.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 i=(0,L.useRef)(null),[c,p]=(0,L.useState)("idle"),[w,h]=(0,L.useState)(Ur),[m,R]=(0,L.useState)(!1),[x,U]=(0,L.useState)(!1),[M,B]=(0,L.useState)(null),[A,te]=(0,L.useState)(!1),[f,N]=(0,L.useState)(null),[S,b]=(0,L.useState)(null),[u,E]=(0,L.useState)(null),[j,D]=(0,L.useState)(null),[o,H]=(0,L.useState)(null),[O,Z]=(0,L.useState)(!1),F=(0,L.useRef)(null),ke=(0,L.useRef)("idle"),he=(0,L.useRef)(-1),[Q,X]=(0,L.useState)(0),ae=(0,L.useRef)(e);ae.current=e,(0,L.useEffect)(()=>{let re=t.current;if(re===null)return;let ue={video:re,...n!==void 0?{assetBaseUrl:n}:{}},G=r!==void 0?r.liveness(ue):br(ue);i.current=G;let Ne=a(()=>H(G.facingMode??null),"readFacing");Ne();let We=[G.on("state",C=>{C==="mode_switch"?Z(!0):C!=="starting"&&C!=="gating"&&Z(!1),C==="starting"?(ke.current!=="starting"&&(he.current+=1,X(Math.max(0,he.current))),b(null),E(null),h(Ur),U(!1),R(!1),B(null),N(null),F.current=null):C==="gating"&&ke.current==="recording"&&(U(!1),R(!1),B(null),F.current=null),ke.current=C,Ne(),p(C),ae.current.onStateChange?.(C)}),G.on("gate",C=>{let Ce=F.current;F.current=C.progress,R(Ce!==null&&C.progress<Ce-.001&&C.progress>0&&C.progress<1),C.progress>=1&&U(!0),h(C)}),G.on("frozen",({previewDataUrl:C})=>B(C)),G.on("profile",({animations:C})=>te(C==="reduced")),G.on("ramp",({colour:C})=>N(C)),G.on("captured",C=>{b(C),D(null),ae.current.onCaptured?.(C)}),G.on("error",C=>{E(C);let Ce=r?.reportCaptureIssue;Ce!==void 0&&Nt(Le=>Ce.call(r,Le),Lr("liveness",C,Math.max(0,he.current))),ae.current.onError?.(C)}),r?.on("result",C=>{D(C),ae.current.onResult?.(C)})];return()=>{for(let C of We)C?.();i.current=null,G.destroy()}},[r,t,n]);let I=(0,L.useCallback)(()=>{i.current?.start()},[]),Re=(0,L.useCallback)(()=>{i.current?.retry()},[]),be=(0,L.useCallback)(async()=>{let re=i.current;return re===null||typeof re.canSwitchCaptureMode!="function"?!1:await re.canSwitchCaptureMode().catch(()=>!1)===!0},[]),q=(0,L.useCallback)(async re=>{let ue=i.current;if(ue===null||typeof ue.setCaptureMode!="function")return!1;let G=await ue.setCaptureMode(re).catch(()=>!1)===!0;return G&&H(ue.facingMode??null),G},[]);return{state:c,gate:w,draining:m,gateLocked:x,frozenPreview:M,reduceMotion:A,rampColour:f,artifacts:S,error:u,result:j,facingMode:o,start:I,retry:Re,canSwitchCaptureMode:be,setCaptureMode:q,modeRestarted:O,attempt:Q}}l(mn,"rr");a(mn,"useLivenessHandle");var Qn=new Set(["national_number"]);function It(e){if(e==null||!e.available||e.selected!==null)return null;let t=e.options.filter(n=>Qn.has(n));return t.length>0?{...e,options:t}:null}l(It,"or");a(It,"pending");function yn(e){let[t,n]=(0,ge.useState)(null),[r,s]=(0,ge.useState)(e===void 0),[i,c]=(0,ge.useState)(!1),[p,w]=(0,ge.useState)(!1);(0,ge.useEffect)(()=>{if(n(null),e===void 0){s(!0);return}let R=!0,x=e.methodChoice;typeof x=="function"?(s(!1),Promise.resolve().then(()=>x.call(e)).then(M=>{R&&n(It(M))},()=>{}).finally(()=>{R&&s(!0)})):s(!0);let U=e.on("method",M=>n(It(M)));return()=>{R=!1,U()}},[e]);let h=(0,ge.useCallback)(async R=>{if(e===void 0)return!1;c(!0),w(!1);try{return await e.selectMethod(R),n(null),!0}catch{return w(!0),!1}finally{c(!1)}},[e]),m=t!==null&&t.options.length===1?t.options[0]:null;return{choice:t,auto:m==="national_number"&&!p?m:null,settled:r,busy:i,failed:p,select:h}}l(yn,"sr");a(yn,"useMethodChoice");var Xn=["ar","fr","en"];function gn(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}}l(gn,"co");a(gn,"isClipUrl");function vn(e){let t=e.clips;if(typeof t!="object"||t===null)return null;let n={};for(let r of Xn){let s=t[r];if(!(typeof s!="object"||s===null))for(let[i,c]of Object.entries(s))!lt(i)||!gn(c)||((n[r]??(n[r]={}))[i]=c)}return Object.keys(n).length>0?n:null}l(vn,"lo");a(vn,"toVoiceClipMap");function kn(e){let[t,n]=(0,He.useState)(null);(0,He.useEffect)(()=>{if(n(null),e===void 0)return;let s=!0,i=a(p=>{if(!s)return;let w=typeof p=="object"&&p!==null&&typeof p.setId=="string"?p:null;n(h=>h?.setId===w?.setId?h:w)},"take");try{typeof e.voiceClips=="function"&&Promise.resolve(e.voiceClips()).then(i,()=>i(null))}catch{i(null)}let c=e.on("view",p=>i(p.voice));return()=>{s=!1,c()}},[e]);let r=(0,He.useMemo)(()=>t!==null?vn(t):null,[t]);return e===void 0?null:r}l(kn,"ir");a(kn,"useServerVoiceClips");function bn({voice:e}){let t=Ee();return(0,Ut.jsx)(Y,{kind:"chip","aria-pressed":e.enabled,"aria-label":t("capture.voiceGuidance"),"data-testid":"sekyro-voice-toggle",onClick:l(()=>e.toggle(),"onClick"),children:(0,Ut.jsx)(it,{off:!e.enabled,className:"sekyro-icon"})})}l(bn,"cr");a(bn,"VoiceChip");var Yn=new Set(["abandoned","not_opened","cancelled","superseded"]),Jn=800,ea="capture.lookAtColours";function Cn(e){return e===void 0||e!==!1&&e.length===Mt.length&&Mt.every(t=>e.includes(t))}l(Cn,"go");a(Cn,"isDefaultTips");function _n(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}l(_n,"ho");a(_n,"carriesActivation");function wn(e){return typeof e=="object"&&e!==null&&!(0,y.isValidElement)(e)&&"tone"in e&&"text"in e}l(wn,"vo");a(wn,"isNoticeObject");var ta=new Set(["nni_unbound","id_number_unbound","method_required","mobile_required","portrait_required"]);function Sn(e){return e==="starting"||e==="gating"||e==="recording"||e==="mode_switch"}l(Sn,"ko");a(Sn,"isCapturing");function xn(e){return e==="captured"||e==="uploading"||e==="checking"}l(xn,"bo");a(xn,"isPostCapture");function ra({verification:e,locale:t,dir:n,strings:r,slots:s,autoStart:i=!1,notice:c,startDisabled:p=!1,startLabel:w,tips:h,tipsSummary:m,coach:R,voice:x,onGuidance:U,onCaptured:M,onResult:B,onError:A,onStateChange:te,assetBaseUrl:f,className:N}){let S=Rr(t),b=(0,y.useMemo)(()=>xr(t,r),[t,r,S]),u=(0,y.useMemo)(()=>v=>b[v]??"",[b]),E=n??(t==="ar"?"rtl":"ltr"),j=(0,y.useRef)(null),D=(0,y.useContext)(Wn),o=mn({verification:e,videoRef:j,assetBaseUrl:f,onCaptured:M,onResult:B,onError:A,onStateChange:te}),H=fn(f,o.state==="idle"&&o.error===null),O=yn(e),Z=O.choice!==null,F=un(e),ke=dn(e),he=hn(e),Q=cn(),X=pn(e),ae=X.session==="choice",I=X.mode==="assisted",Re=x!==!1&&x?.clips===void 0,be=kn(Re?e:void 0),q=Jr({locale:t,defaultClips:be,options:x}),re=I?"environment":"user",ue=X.settled,G=(0,y.useRef)(null),Ne=(0,y.useRef)(!1),We=(0,y.useRef)(q.unlock);We.current=q.unlock,(0,y.useEffect)(()=>{let v=G.current;if(v===null)return;let ie=["pointerup","touchend","click","keydown"],we=a(()=>{for(let De of ie)v.removeEventListener(De,Ae,!0)},"disarm");function Ae(De){if(Ne.current){we();return}_n(De)&&(Ne.current=!0,we(),We.current())}l(Ae,"Re"),a(Ae,"onGesture");for(let De of ie)v.addEventListener(De,Ae,{capture:!0,passive:!0});return we},[]);let C=(0,y.useCallback)(()=>{Ne.current||(Ne.current=!0,q.unlock()),o.start()},[q.unlock,o.start]),Ce=(0,y.useCallback)(()=>o.start(),[o.start]),Le=(0,y.useRef)(!1),Oe=o.state==="idle"&&o.error===null,Vt=!Z&&!F.required&&(i===!0||i==="when-permitted"&&Q.permission==="granted"),Dt=Vt&&O.settled&&F.settled&&ue,Ln=i==="when-permitted"&&!Q.permissionSettled&&!Le.current,Ft=Vt&&Oe&&!Le.current,pt=(Ln||Ft||!ue)&&H.gate==="ready"?"loading":H.gate;(0,y.useEffect)(()=>{!Dt||!Oe||H.gate!=="ready"||Le.current||(Le.current=!0,Ce())},[Dt,Oe,H.gate,Ce]);let In=Oe&&!Z&&!F.required&&!(Ft&&H.gate==="ready"),[$t,Kt]=(0,y.useState)(!1),{canSwitchCaptureMode:Gt,setCaptureMode:zt}=o;(0,y.useEffect)(()=>{if(!X.settled||!ae){Kt(!1);return}let v=!0;return Gt().then(ie=>{v&&Kt(ie)}),()=>{v=!1}},[X.settled,ae,Gt]);let{choose:Wt}=X,Ie=I?"self":"assisted",Un=(0,y.useCallback)(async()=>{await zt(Ie)&&Wt(Ie)},[zt,Wt,Ie]),Zt=o.state!=="idle"&&o.facingMode!==null?o.facingMode:re;(0,y.useEffect)(()=>{let v=j.current?.style;Zt==="user"?v?.removeProperty("transform"):v&&(v.transform="none")},[Zt]);let Ze=(0,y.useMemo)(()=>o.artifacts!==null&&typeof URL.createObjectURL=="function"?URL.createObjectURL(o.artifacts.keyframe):null,[o.artifacts]);(0,y.useEffect)(()=>{if(Ze!==null)return()=>URL.revokeObjectURL(Ze)},[Ze]);let Qt=o.frozenPreview??Ze,Ue=e!==void 0,$=Sn(o.state),fe=xn(o.state),Pe=$||fe,se=o.result,Xt=o.state==="done"&&se!==null,Qe=$&&o.rampColour!==null,ht=o.state==="recording"&&o.frozenPreview!==null&&!Qe,Be=D!==null,Yt=$t&&$&&!ht?{to:Ie,label:u(Ie==="assisted"?"capture.modeSwitch.toAssisted":"capture.modeSwitch.toSelf"),description:u(Ie==="assisted"?"capture.modeSwitch.toAssistedLabel":"capture.modeSwitch.toSelfLabel"),onSwitch:a(()=>{Un()},"onSwitch")}:null,Xe=o.modeRestarted&&$?u("capture.modeSwitch.restarted"):null,qe=fe||ht,Jt=fe?"checking":ht?"frozen":o.state==="recording"||Qe?"recording":o.gateLocked||o.gate.progress>=1?"locked":o.gate.faceDetected?"aligning":"seeking",Ye=$?o.gate.hint:null,Je=o.state==="starting"?"capture.preparing.title":Ye===null?null:Ye==="center"&&!o.gate.faceDetected?"fcv3.no_face":Cr(Ye),[jn,er]=(0,y.useState)(null);(0,y.useEffect)(()=>{if(Je!=="fcv3.no_face"){er(Je);return}if(!$)return;let v=setTimeout(()=>er(Je),Jn);return()=>clearTimeout(v)},[Je,$]);let ft=$&&!Qe&&typeof R=="string"&&R!=="",tr=I&&$?u("capture.assisted.stage"):null,Me=$&&!ft?Qe?ea:jn:null,mt=ft?R:Me===null?"":u(Me);en(q,Me,mt,$);let rr=(0,y.useRef)(U);rr.current=U,(0,y.useEffect)(()=>{if(lt(Me))try{rr.current?.(Me)}catch(v){console.error("[@sekyro/react] onGuidance threw:",v)}},[Me]);let Ve=(0,y.useMemo)(()=>({supported:q.supported,enabled:q.enabled,setEnabled:q.setEnabled,toggle:q.toggle}),[q.supported,q.enabled,q.setEnabled,q.toggle]),yt=s?.voicePrompt,nr=yt!==void 0,ar=x===void 0,sr=(0,y.useRef)(!1);(0,y.useEffect)(()=>{!nr||!ar||sr.current||!Ht()||(sr.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."))},[nr,ar]);let Tn=yt!==void 0?(v,ie,we)=>yt(v,ie,we,Ve):q.supported?()=>(0,k.jsx)(bn,{voice:Ve}):void 0,{summary:gt,summaryPlaying:ir,toggleSummary:lr,stopSummary:or}=q,et=m!==void 0&&m!=="",cr=et?m:u("capture.tips.summary"),ur=et?gt!=="none":gt==="partner"||gt==="default"&&Cn(h),Hn=(0,y.useMemo)(()=>ur?{playing:ir,toggle:a(()=>lr(cr,{clip:!et}),"toggle"),stop:or}:void 0,[ur,ir,lr,cr,or,et]),dr=(0,y.useMemo)(()=>({assets:pt,retryAssets:H.retry,permission:Q.permission,permissionSettled:Q.permissionSettled,captureMode:X.mode,facing:re,voice:Ve}),[pt,H.retry,Q.permission,Q.permissionSettled,X.mode,re,Ve]),On=wn(c)?(0,k.jsx)(le,{tone:c.tone,testId:"sekyro-host-notice",children:(0,k.jsx)("span",{children:c.text})}):c??null,V=se!==null&&se.status==="retry"?se:null,tt=V!==null&&s?.intro!==void 0&&!$&&!fe&&o.error===null,pr=V===null?void 0:{reason:String(V.reasonCode??""),...V.retakeHint!==void 0?{retakeHint:V.retakeHint}:{},...V.attemptsRemaining!==void 0?{attemptsRemaining:V.attemptsRemaining}:{}},z=Xt&&se.status==="unavailable"&&!Z&&se.reasonCode!=="portrait_required"?se:null,_e=Xt&&(se.status==="verified"||se.status==="not_verified"||se.status==="review")?se:null,vt=a((v,ie)=>{if(v===void 0)return null;if(v==="device_cooldown"){let Ae=wr(t,ie);if(Ae!==null)return u(Ae.key).replace("{time}",Ae.time)}let we=nt(v);return we===null?null:u(we)},"reasonText"),kt=a(v=>{let ie=v.retakeHint===void 0?null:Fe(v.retakeHint);return ie===null?vt(v.reasonCode):u(ie)},"retryText"),hr=_e===null?null:vt(_e.reasonCode,_e.retryAfter)??(_e.status==="not_verified"&&_e.reason!==void 0&&Yn.has(_e.reason)?u("errors.session_expired"):null),Pn=z!==null&&z.reasonCode!==void 0&&z.reasonCode!=="nni_unbound"&&z.reasonCode!=="id_number_unbound"&&z.reasonCode!=="method_required"&&z.reasonCode!=="mobile_required"&&!(z.reasonCode==="no_recorder"&&o.artifacts?.degraded==="NO_RECORDER"),rt=z?.reasonCode,fr=o.attempt;(0,y.useEffect)(()=>{z===null||rt===void 0||e?.reportCaptureIssue===void 0||ta.has(rt)||Nt(v=>e.reportCaptureIssue?.(v),{check:"liveness",kind:"unavailable",phase:"upload",engineKind:rt,attempt:Math.min(1e3,fr)})},[z,rt,fr,e]);let mr=wt(),Bn=Z&&O.auto===null&&!$&&!fe&&o.error===null,bt=(0,y.useCallback)(async v=>{await O.select(v)&&o.state==="done"&&o.retry()},[O.select,o.state,o.retry]);return(0,y.useEffect)(()=>{O.auto!==null&&!O.busy&&!$&&!fe&&bt(O.auto)},[O.auto,O.busy,$,fe,bt]),(0,k.jsx)(Nr,{value:u,children:(0,k.jsxs)("div",{ref:G,className:N===void 0?"sekyro-capture":`sekyro-capture ${N}`,dir:E,lang:t,"data-testid":"sekyro-liveness-capture","data-state":o.state,children:[s?.header,V!==null&&kt(V)!==null&&!(Be&&Pe)&&!tt?(0,k.jsx)(le,{tone:"warning",role:"status",testId:"sekyro-retry-notice",children:(0,k.jsx)("span",{children:kt(V)})}):null,Xe!==null&&!Be?(0,k.jsx)(le,{tone:"info",role:"status",testId:"sekyro-mode-switch-status",children:(0,k.jsx)("span",{children:Xe})}):null,he&&fe&&!Be?(0,k.jsx)(le,{tone:"info",role:"status",testId:"sekyro-busy-notice",children:(0,k.jsx)("span",{children:u("capture.busy")})}):null,F.required&&Oe?(0,k.jsx)(le,{tone:"info",role:"status",testId:"sekyro-mobile-required",children:(0,k.jsx)("span",{children:u("reasons.mobile_required")})}):null,o.error!==null?s?.errorPanel!==void 0?s.errorPanel(o.error,o.retry):(0,k.jsxs)(le,{tone:"danger",testId:"sekyro-error-notice",children:[(0,k.jsx)("span",{children:u(_r(o.error))}),o.error.retryable?(0,k.jsx)(Y,{ref:mr,kind:"ghost",className:"sekyro-btn--start",onClick:o.retry,children:u("common.retry")}):null]}):null,z!==null?(0,k.jsxs)(le,{tone:"danger",testId:"sekyro-unavailable-notice",children:[(0,k.jsx)("span",{children:(z.reasonCode==="attestation"&&z.attestationError==="clock_wrong"?u("errors.device_clock"):vt(z.reasonCode))??u(z.reasonCode===void 0?"errors.session_expired":"errors.network_error")}),Pn?(0,k.jsx)(Y,{ref:mr,kind:"ghost",className:"sekyro-btn--start",onClick:o.retry,children:u(z.reasonCode==="attestation"?"common.retry":"capture.recordAgain")}):null]}):null,hr!==null&&_e!==null?(0,k.jsx)(le,{tone:_e.status==="not_verified"?"danger":"info",testId:"sekyro-result-notice",children:(0,k.jsx)("span",{children:hr})}):null,(0,k.jsx)("div",{className:Pe?void 0:"sekyro-hidden","data-capture-live":Pe?"":void 0,children:Be?D({videoRef:j,guidance:qe&&Ue?u("capture.checking"):mt,coached:ft&&!(qe&&Ue),note:qe?Ue?u(he?"capture.busy":"capture.checkingHint"):null:Xe??tr,settled:qe&&Ue,progress:o.gate.progress,phase:Jt,still:qe?Qt:null,live:Pe,modeSwitch:Yt,...$t||V!==null?{status:Xe??(V!==null&&$?kt(V):null)}:{},ramp:o.rampColour===null?null:{colour:o.rampColour}}):(0,k.jsx)(Mr,{videoRef:j,guidanceText:mt,guidanceHint:Ye,guidanceKey:Me,progress:o.gate.progress,phase:Jt,draining:o.draining,stillUrl:Qt,showChecking:Ue,operatorText:tr,voicePrompt:Tn,overlay:l(v=>(0,k.jsxs)(k.Fragment,{children:[s?.stageOverlay?.(v),(0,k.jsx)(Ar,{colour:o.rampColour})]}),"overlay"),reduceMotion:o.reduceMotion,modeSwitch:Yt})}),Bn&&O.choice!==null?(0,k.jsx)(Kr,{title:u("method.title"),description:u("method.description"),options:O.choice.options.map(v=>({id:v,label:u(`method.${v}`)})),busy:O.busy,error:O.failed?u("errors.network_error"):null,focus:o.state==="done",testId:"sekyro-method",look:"buttons",onChoose:l(v=>{bt(v)},"onChoose")}):null,tt&&s?.intro!==void 0&&pr!==void 0?s.intro(o.retry,{...dr,retry:pr}):null,In?(0,k.jsxs)(k.Fragment,{children:[ke&&s?.header===void 0&&s?.intro===void 0?(0,k.jsxs)("div",{className:"sekyro-stack sekyro-stack--1",children:[(0,k.jsx)("h2",{className:"sekyro-text-body",children:u("returning.title")}),(0,k.jsx)("p",{className:"sekyro-text-muted",children:u("returning.description")})]}):null,On,s?.intro!==void 0?s.intro(C,dr):(0,k.jsx)(ln,{assets:pt,onRetryAssets:H.retry,permission:Q.permission,captureMode:X.mode,voice:Ve,tips:h??Mt,summary:Hn,startLabel:w,startDisabled:p,onStart:C})]}):null,(0,k.jsx)(rn,{showCoaching:V!==null&&!(Be&&Pe)&&!tt,coaching:ze(V?.reasonCode,V?.retakeHint),attemptsText:V?.attemptsRemaining!==void 0?Sr(b,t,V.attemptsRemaining):null,showRetake:V!==null&&!$&&!fe&&!tt||!Ue&&o.state==="captured",onRetake:o.retry}),s?.footer]})})}l(ra,"Ni");a(ra,"LivenessCapture");var Pt=T(W(),1),dt=T(W(),1),d=T(de(),1);var La={document:"card",population_registry:"id",national_eid:"smartphone",phone_otp:"phone",email_otp:"email"};function na(e,t){switch(e.service){case"document":return t.t("method.document_photo");case"population_registry":return _t(e,t.locale)??t.t("method.nationalNumber");case"national_eid":return _t(e,t.locale)??t.t("method.nationalEid");default:return null}}l(na,"J");a(na,"identityLabel");function aa(e,t){let[n,r]=(0,Pt.useState)(!1),[s,i]=(0,Pt.useState)(null);return{busy:n,error:s,run:a(c=>{r(!0),i(null),c().then(()=>r(!1),p=>{r(!1),i(e.t(Ir(p,e.strings))),t?.(p)})},"run")}}l(aa,"Q");a(aa,"useChoiceAction");function Bt(){let e=`sekyro-face-light-${(0,dt.useId)().replace(/[^A-Za-z0-9_-]/g,"")}`;return(0,d.jsxs)("svg",{className:"sekyro-mark sekyro-mark--face",viewBox:"0 0 168 206","aria-hidden":"true",focusable:"false",children:[(0,d.jsx)("defs",{children:(0,d.jsx)("mask",{id:e,children:(0,d.jsx)("ellipse",{className:"sekyro-mark__arc",cx:"84",cy:"103",rx:"76",ry:"95",pathLength:"1",fill:"none",stroke:"#fff",strokeWidth:"16"})})}),(0,d.jsx)("ellipse",{cx:"84",cy:"103",rx:"64",ry:"83",fill:"none",className:"sekyro-mark__line"}),(0,d.jsx)("path",{className:"sekyro-mark__face",d:"M68 64v10M100 64v10M84 66v25q0 2-6 1M60 108q24 18 48 0"}),(0,d.jsx)("ellipse",{className:"sekyro-mark__ticks",cx:"84",cy:"103",rx:"76",ry:"95",pathLength:"56"}),(0,d.jsx)("ellipse",{className:"sekyro-mark__ticks sekyro-mark__ticks--light",cx:"84",cy:"103",rx:"76",ry:"95",pathLength:"56",mask:`url(#${e})`})]})}l(Bt,"O");a(Bt,"FaceMark");var sa={glasses:"jGlasses",lighting:"light",faceCamera:"camera"};function ia(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}}l(ia,"le");a(ia,"faceIntroRetryOf");var Nn={"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 la({start:e,context:t,tips:n,tipsTitle:r,human:s=!1,returning:i=!1,notice:c,retry:p}){let w=at(),{t:h}=w,m=p??An(t),R=(0,dt.useContext)(Er)?.busy===!0;if(m!==void 0&&c===void 0&&t.captureMode!=="assisted")return(0,d.jsx)(En,{retry:m,start:e,context:t,disabled:R});let x=m===void 0?"face":ze(m.reason,m.retakeHint),U=x==="face"?null:Te[x].tips;return(0,d.jsxs)("section",{className:"sekyro-step",children:[(0,d.jsx)(Bt,{}),t.captureMode==="assisted"?(0,d.jsx)($e,{title:h("capture.assisted.heading"),lead:h("capture.assisted.lead")}):i?(0,d.jsx)($e,{title:h("returning.heading"),lead:h("returning.description")}):(0,d.jsx)($e,{title:h(s?"native.face.humanIntroTitle":"native.face.introTitle"),lead:h(s?"native.face.humanIntroLead":"native.face.introLead")}),m!==void 0?(0,d.jsx)(Mn,{retry:m,title:Te[x].title}):null,r!==void 0&&U===null?(0,d.jsx)("p",{className:"sekyro-section-label",children:r}):null,(0,d.jsx)("ul",{className:"sekyro-tiprows",children:U!==null?U.map(M=>(0,d.jsxs)("li",{children:[(0,d.jsx)(me,{name:Nn[M]??"face"}),h(M)]},M)):n!==void 0?n.map(M=>(0,d.jsxs)("li",{children:[(0,d.jsx)(me,{name:sa[M.id]??"face"}),M.text]},M.id)):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("li",{children:[(0,d.jsx)(me,{name:"light"}),h("capture.tips.light")]}),(0,d.jsxs)("li",{children:[(0,d.jsx)(me,{name:"jGlasses"}),h("capture.tips.uncover")]}),(0,d.jsxs)("li",{children:[(0,d.jsx)(me,{name:"smartphone"}),h("capture.tips.eyeLevel")]})]})}),c??null,c!==void 0?null:t.assets==="failed"?(0,d.jsx)(Y,{kind:"secondary",full:!0,onClick:t.retryAssets,children:h("common.retry")}):null,c!==void 0?null:(0,d.jsx)(St,{children:(0,d.jsxs)(Y,{full:!0,disabled:t.assets!=="ready"||R,"aria-busy":t.assets==="loading"||void 0,onClick:e,children:[(0,d.jsx)(me,{name:"camera"}),h("capture.start")]})})]})}l(la,"ue");a(la,"FaceIntro");var oa=new Set(["match_inconclusive","no_face_source","below_threshold"]);function qt(e){return e==="probe_not_from_liveness"?"capture.retrySamePerson.message":e==="faces_differ"?"reasons.faces_differ":oa.has(e)?"capture.retryMatch.message":nt(e)}l(qt,"F");a(qt,"retryReasonKey");function Mn({retry:e,title:t}){let n=at(),r=e.retakeHint===void 0?null:Fe(e.retakeHint),s=qt(e.reason);return(0,d.jsxs)(xt,{tone:"warning",children:[r!==null?(0,d.jsx)("span",{children:n.t(r)}):s!==null?(0,d.jsx)("span",{children:n.t(s)}):null,r===null?(0,d.jsx)("span",{children:n.t(t)}):null,(0,d.jsx)("span",{children:Rt(n,e.attemptsRemaining,e.attemptsExhausted)})]})}l(Mn,"U");a(Mn,"RetryNotice");function An(e){let t=e.retry;if(t!==void 0)return{reason:t.reason,...t.retakeHint!==void 0?{retakeHint:t.retakeHint}:{},attemptsRemaining:t.attemptsRemaining??0,attemptsExhausted:t.attemptsRemaining===0}}l(An,"G");a(An,"faceIntroRetryOfContext");var Rn=[{key:"capture.retryCoaching.light",icon:"light"},{key:"capture.retryCoaching.eyeLevel",icon:"smartphone"},{key:"capture.retryCoaching.head",icon:"face"}],ca={appearance:"hintTitles.appearance",motion:"hintTitles.motion",lighting:"hintTitles.lighting",framing:"hintTitles.framing"};function En({retry:e,start:t,context:n,disabled:r}){let s=at(),{t:i}=s,c=ze(e.reason,e.retakeHint),p=c==="face"?Rn:Te[c].tips.map(x=>({key:x,icon:Rn.find(U=>U.key===x)?.icon??Nn[x]??"face"})),w=e.retakeHint===void 0?null:Fe(e.retakeHint),h=qt(e.reason),m=w!==null?i(w):h!==null?i(h):void 0,R=i((e.retakeHint!==void 0?ca[e.retakeHint]:void 0)??"hintTitles.default");return(0,d.jsxs)("section",{className:"sekyro-step","data-testid":"sekyro-face-retry",children:[(0,d.jsx)(Bt,{}),(0,d.jsx)($e,{title:R}),m!==void 0?(0,d.jsx)(xt,{tone:"warning",children:(0,d.jsx)("span",{children:m})}):null,(0,d.jsx)("ul",{className:"sekyro-tiprows",children:p.slice(0,3).map(x=>(0,d.jsxs)("li",{children:[(0,d.jsx)(me,{name:x.icon}),i(x.key)]},x.key))}),n.assets==="failed"?(0,d.jsx)(Y,{kind:"secondary",full:!0,onClick:n.retryAssets,children:i("common.retry")}):null,(0,d.jsxs)(St,{children:[(0,d.jsx)("p",{className:"sekyro-text-muted","data-testid":"sekyro-attempts-remaining",children:Rt(s,e.attemptsRemaining,e.attemptsExhausted)}),(0,d.jsxs)(Y,{full:!0,disabled:n.assets!=="ready"||r||e.attemptsExhausted,"aria-busy":n.assets==="loading"||void 0,onClick:t,children:[(0,d.jsx)(me,{name:"camera"}),i("capture.recordAgain")]})]})]})}l(En,"q");a(En,"FaceRetry");function ua(e){return Ct(e)}l(ua,"ye");a(ua,"isInAppBrowser");function da(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 s=r.protocol.slice(0,-1);return`intent://${r.host}${r.pathname}${r.search}#Intent;scheme=${s};action=android.intent.action.VIEW;S.browser_fallback_url=${encodeURIComponent(e)};end`}l(da,"ge");a(da,"androidBrowserIntent");export{Kr as a,Ht as b,Wn as c,pn as d,ra as e,La as f,na as g,aa as h,ia as i,la as j,ua as k,da as l};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as Re,e as Xe,f as Ze,g as Ve}from"./chunk-GORELL4J.js";import{a as le,b as je,c as ce,d as $e}from"./chunk-P7K7ELYZ.js";import{a as Se,b as Q,c as Ae,d as Ie,e as Ce,h as Oe,i as ne,j as Pe,k as Ge,l as He,m as Ke}from"./chunk-6MYG4HWP.js";import{a as Ue,b as Fe,c as Ne,d as Le,e as Be,f as oe,g as j,h as qe,i as We,j as ze}from"./chunk-JS2IXPNL.js";import{b as xe,c as De}from"./chunk-SLLJX5QK.js";import{a as o}from"./chunk-4FHWXBOB.js";var Tt=["magenta","yellow","green","blue"],_t={magenta:"rgb(255, 72, 150)",yellow:"rgb(255, 190, 0)",green:"rgb(0, 238, 175)",blue:"rgb(25, 150, 255)",dark:"rgb(0, 0, 0)"};function zi(i){return _t[i]}o(zi,"P");var Et=4,St=4,J=o(i=>typeof i=="number"&&Number.isFinite(i),"R");function ee(i){if(typeof i!="object"||i===null)return!1;let e=i;if(typeof e.nonce!="string"||e.nonce.length===0||!Array.isArray(e.colours)||e.colours.length<1||e.colours.length>8||!e.colours.every(r=>Tt.includes(r))||!Array.isArray(e.onsetsMs)||e.onsetsMs.length!==e.colours.length)return!1;let t=-1;for(let r of e.onsetsMs){if(!J(r)||r<0||r<=t)return!1;t=r}return!(!J(e.holdMs)||e.holdMs<=0||!J(e.endMs)||e.endMs<=t||!J(e.clipMs)||e.clipMs<e.endMs||e.clipMs>8e3)}o(ee,"_");function Ye(i,e){return ee(i)?Math.max(e,Math.ceil(i.clipMs)):e}o(Ye,"O");function Qe(i,e){let t=e.now??(()=>performance.now()),r=ee(i)?i:void 0,s=[],a=null,n=null,l=null,c=!1,h=null,d=o(p=>{h=p;try{e.paint(p)}catch{}},"s"),u=o(p=>{let v=e.frames?.()??null;return v!==null&&l!==null?v.mediaTimeMs+(p-v.presentationTimeMs)-l:p-(n??p)},"p"),m=o((p,v,y=0)=>{if(c)return;let g=Math.max(0,p-u(t()));a=setTimeout(()=>{if(a=null,!c){if(y<Et&&u(t())<p-St){m(p,v,y+1);return}v()}},g)},"f"),w=o(p=>{if(r===void 0)return;let v=r.endMs;if(p>=r.colours.length){m(v,()=>d(null));return}let y=r.onsetsMs[p],g=p+1<r.onsetsMs.length?r.onsetsMs[p+1]:v;m(y,()=>{let M=u(t());if(M>v){h!==null&&d(null);return}let E=r.colours[p];d(E);let A=s.length===0?0:s[s.length-1].tMs;s.push({tMs:Math.max(A,Math.round(M)),colour:E});let I=y+r.holdMs;if(I<g){m(I,()=>{if(u(t())>v){h!==null&&d(null);return}d("dark"),w(p+1)});return}w(p+1)})},"S");return{started(p){if(r===void 0||c||n!==null)return;n=p;let v=e.frames?.()??null;l=v===null?null:v.mediaTimeMs+(p-v.presentationTimeMs),w(0)},stop(){c||(c=!0,a!==null&&clearTimeout(a),a=null,h!==null&&d(null))},report(){return r===void 0?void 0:{nonce:r.nonce,rendered:[...s]}}}}o(Qe,"w");var At=1e4,O,It=(O=class{constructor(e,t){this.tier="blaze",this.inner=e,t!==void 0&&(this.fallbackReason=t)}static async create(e,t){let r=await import("./vision_bundle-WBHR7TEE.js"),s=await r.FilesetResolver.forVisionTasks(e),a=await r.FaceDetector.createFromOptions(s,{baseOptions:{modelAssetPath:`${e}/blaze_face_short_range.tflite`,delegate:"CPU"},runningMode:"IMAGE"});return new O(a,t)}async detect(e,t,r){let s;try{s=this.inner.detect(e).detections}catch{return null}let a=xt(s);if(a?.boundingBox===void 0)return null;let n=te(e),l=Dt(a.keypoints,n),c=a.keypoints?.[2],h={box:{x:a.boundingBox.originX,y:a.boundingBox.originY,width:a.boundingBox.width,height:a.boundingBox.height},...l!==void 0?{eyes:l}:{},...c!==void 0?{nose:{x:c.x*n.width,y:c.y*n.height}}:{},score:a.categories[0]?.score??0,extraFaces:Je(s.map(d=>d.boundingBox??{width:0,height:0}),s.indexOf(a))};return et(h,e,t,r)}destroy(){try{this.inner.close()}catch{}}},o(O,"t"),O);function xt(i){let e,t=-1;for(let r of i){let s=r.categories[0]?.score??0;s>t&&(e=r,t=s)}return e}o(xt,"R");function Dt(i,e){let t=i?.[0],r=i?.[1];if(t===void 0||r===void 0)return;let s=o(l=>({x:l.x*e.width,y:l.y*e.height}),"n"),[a,n]=[s(t),s(r)];return a.x<=n.x?{left:a,right:n}:{left:n,right:a}}o(Dt,"T");function Rt(){if(typeof OffscreenCanvas=="function")return new OffscreenCanvas(2,2);let i=document.createElement("canvas");return i.width=2,i.height=2,i}o(Rt,"E");var Ct=4;async function Ot(){let i=globalThis.FaceDetector;if(typeof i!="function")return{ok:!1,reason:"unsupported"};try{let e=new i({fastMode:!0,maxDetectedFaces:Ct});return await e.detect(Rt()),{ok:!0,instance:e}}catch(e){return{ok:!1,reason:`smoke_failed:${e instanceof Error?e.message:String(e)}`}}}o(Ot,"w");var U,Pt=(U=class{constructor(e,t){this.tier="native",this.inner=e,t!==void 0&&(this.fallbackReason=t)}async detect(e,t,r){let s;try{s=await this.inner.detect(e)}catch{return null}let a=s.map(d=>d.boundingBox),n=-1;a.forEach((d,u)=>{let m=a[n];(m===void 0||d.width*d.height>m.width*m.height)&&(n=u)});let l=s[n];if(l===void 0)return null;let c=Gt(l.landmarks),h={box:{x:l.boundingBox.x,y:l.boundingBox.y,width:l.boundingBox.width,height:l.boundingBox.height},...c!==void 0?{eyes:c}:{},score:1,extraFaces:Je(a,n)};return et(h,e,t,r)}destroy(){}},o(U,"b"),U);function Gt(i){if(i===void 0)return;let e=i.filter(s=>s.type==="eye").map(s=>s.locations[0]).filter(s=>s!==void 0),[t,r]=e;if(!(t===void 0||r===void 0))return t.x<=r.x?{left:t,right:r}:{left:r,right:t}}o(Gt,"S");var Ut=.25;function Je(i,e){let t=i[e],r=t===void 0?0:t.width*t.height;if(!(r>0))return 0;let s=0;return i.forEach((a,n)=>{n!==e&&a.width*a.height>=Ut*r&&(s+=1)}),s}o(Je,"f");var ue="/models-v3",Ft=["native","blaze"],F,de=(F=class extends Error{constructor(e){super(`no detector tier available (${e})`),this.name="DetectorLadderError",this.fallbackReason=e}},o(F,"x"),F);function te(i){let e=i;if(typeof e.videoWidth=="number"&&e.videoWidth>0)return{width:e.videoWidth,height:e.videoHeight??0};if(typeof e.naturalWidth=="number"&&e.naturalWidth>0)return{width:e.naturalWidth,height:e.naturalHeight??0};let t=typeof e.width=="number"?e.width:0,r=typeof e.height=="number"?e.height:0;return{width:t,height:r}}o(te,"y");function et(i,e,t,r){let s=te(e),a=s.width>0?t/s.width:1,n=s.height>0?r/s.height:1,l=o(c=>({x:c.x*a,y:c.y*n}),"s");return{box:{x:i.box.x*a,y:i.box.y*n,width:i.box.width*a,height:i.box.height*n},...i.eyes!==void 0?{eyes:{left:l(i.eyes.left),right:l(i.eyes.right)}}:{},...i.nose!==void 0?{nose:l(i.nose)}:{},score:i.score,...i.extraFaces!==void 0?{extraFaces:i.extraFaces}:{}}}o(et,"h");function Nt(i){return i instanceof Error?i.message:String(i)}o(Nt,"C");async function x(i){let e=i.preferred??Ft,t=[];for(let r of e){if(r==="native"){let s=await Ot();if(s.ok)return new Pt(s.instance,he(t));t.push(`native:${s.reason}`);continue}try{return await Lt(It.create(i.v3AssetBaseUrl??ue,he(t)),i.blazeInitTimeoutMs??At)}catch(s){t.push(s instanceof tt?"blaze:blaze_init_timeout":`blaze:${Nt(s)}`)}}throw new de(he(t)??"no_tier_available")}o(x,"O");function he(i){return i.length>0?i.join("; "):void 0}o(he,"v");var N,tt=(N=class extends Error{},o(N,"g"),N);function Lt(i,e){return new Promise((t,r)=>{let s=setTimeout(()=>{r(new tt(`init exceeded ${e}ms`)),i.then(a=>a.destroy(),()=>{})},e);i.then(a=>{clearTimeout(s),t(a)},a=>{clearTimeout(s),r(a)})})}o(Lt,"W");var C=1;function it(){return typeof OffscreenCanvas=="function"&&typeof createImageBitmap=="function"&&typeof Worker=="function"}o(it,"K");function Bt(i,e={}){let t=e.createDetector??x,r=null;i.onmessage=s=>{let a=s.data;if(a.v!==C){a.bitmap?.close?.();return}if(a.type==="init"){t(a.options).then(n=>{r=n;let l={v:C,type:"ready",tier:n.tier,...n.fallbackReason!==void 0?{fallbackReason:n.fallbackReason}:{}};i.postMessage(l)});return}if(a.type==="detect"){let n=o(l=>{let c={v:C,type:"result",id:a.id,observation:l};i.postMessage(c),a.bitmap.close?.()},"a");if(r===null){n(null);return}r.detect(a.bitmap,a.streamWidth,a.streamHeight).then(n,()=>n(null))}}}o(Bt,"B");typeof self<"u"&&typeof self.importScripts=="function"&&Bt(self);var P,rt=(P=class{constructor(e,t){this.pending=new Map,this.nextId=1,this.worker=e,this.tier=t.tier,t.fallbackReason!==void 0&&(this.fallbackReason=t.fallbackReason),e.addEventListener("message",r=>{let s=r.data;if(s.v!==C||s.type!=="result")return;let a=this.pending.get(s.id);this.pending.delete(s.id),a?.(s.observation)})}static create(e,t,r=1e4){return new Promise((s,a)=>{let n=setTimeout(()=>{e.removeEventListener("message",l),e.terminate(),a(new Error(`worker detector not ready within ${r}ms`))},r),l=o(h=>{let d=h.data;d.v!==C||d.type!=="ready"||(clearTimeout(n),e.removeEventListener("message",l),s(new P(e,d)))},"s");e.addEventListener("message",l);let c={v:C,type:"init",options:t};e.postMessage(c)})}async detect(e,t,r){let s;try{typeof ImageBitmap<"u"&&e instanceof ImageBitmap?s=e:typeof createImageBitmap=="function"?s=await createImageBitmap(e):s=e}catch{return null}let a=this.nextId;return this.nextId+=1,new Promise(n=>{this.pending.set(a,n);let l={v:C,type:"detect",id:a,bitmap:s,streamWidth:t,streamHeight:r};this.worker.postMessage(l,[s])})}destroy(){for(let e of this.pending.values())e(null);this.pending.clear(),this.worker.terminate()}},o(P,"t"),P);var qt=[...Ue.filter(i=>i.startsWith("video/mp4")),"video/webm;codecs=h264","video/webm;codecs=avc1","video/webm;codecs=vp8","video/webm;codecs=vp9","video/webm"],dt=new Set;function Wt(i){let e=/(?:Chrome|Chromium)\/(\d+)\./.exec(i??"");return e?Number(e[1]):null}o(Wt,"Pe");function zt(i=Kt(),e=globalThis.navigator?.userAgent){if(i===void 0)return"";let t=Wt(e)===126;for(let r of qt)if(!(dt.has(r)||t&&r.startsWith("video/mp4")))try{if(i(r))return r}catch{}return""}o(zt,"be");function st(i){i!==""&&dt.add(i)}o(st,"L");function Ht(i){return i.replace(/^video\/x-matroska/i,"video/webm")}o(Ht,"ye");function ft(i){let e=/codecs=["']?([^,;"']+)/i.exec(i);return e?e[1].trim():i.split(";")[0].trim()}o(ft,"lt");function Kt(){let i=globalThis.MediaRecorder;return i&&typeof i.isTypeSupported=="function"?e=>i.isTypeSupported(e):void 0}o(Kt,"xe");var pt=2500,Xt=1e3,Zt=1500,at=25e5,Vt=100,jt=700,$t=20,Yt=1500,ie=null;function Qt(){return ie??(ie=import("./clip-inspect-DLJXVKV6-TNHTD4LV.js").catch(i=>{throw ie=null,i})),ie.catch(()=>null)}o(Qt,"He");var B,D=(B=class extends Error{constructor(e,t){super(t??e),this.kind=e}},o(B,"T"),B),Jt=100;function nt(i,e){return i.stats===void 0?!1:i.stats===null?!0:i.stats.durationMs<e-Jt}o(nt,"N");function ei(i,e){return i.stats?e.stats?i.stats.durationMs>e.stats.durationMs:!0:!1}o(ei,"Ee");var q,ti=(q=class{constructor(e={}){this.recorder=null,this.stream=null,this.chunks=[],this.bytes=0,this.hardStopTimer=null,this.graceTimer=null,this.pollTimer=null,this.settled=!1,this.now=e.now??(()=>globalThis.performance?.now?.()??Date.now())}clearTimers(){this.hardStopTimer&&clearTimeout(this.hardStopTimer),this.graceTimer&&clearTimeout(this.graceTimer),this.pollTimer&&clearInterval(this.pollTimer),this.hardStopTimer=null,this.graceTimer=null,this.pollTimer=null}record(e,t,r,s=pt,a){let n=zt(),l=Qt();return this.recordRaw(e,t,r,s,a,n).then(c=>ii(c,l),c=>{throw c instanceof D&&(c.requestedMimeType=n),c})}recordRaw(e,t,r,s,a,n){return this.recorder&&!this.settled?Promise.reject(new D("generic","record() called while a recording is in flight — ClipRecorder handles one recording at a time")):(this.recorder=null,this.clearTimers(),this.chunks=[],this.bytes=0,this.settled=!1,this.stream=e,new Promise((l,c)=>{let h;try{h=new MediaRecorder(e,n?{mimeType:n,videoBitsPerSecond:at}:{videoBitsPerSecond:at})}catch{try{h=new MediaRecorder(e)}catch{c(new D("unsupported"));return}}this.recorder=h;let d=o(g=>{this.settled||(this.settled=!0,this.clearTimers(),g())},"d"),u=o(()=>d(()=>{let g=Ht(h.mimeType||n||Fe),M=new Blob(this.chunks,{type:g});if(M.size===0){c(new D("generic","empty clip"));return}if(oe(M)){c(new D("cliptoolarge"));return}l({blob:M,mimeType:g,requestedMimeType:n})}),"u");h.ondataavailable=g=>{g.data&&g.data.size&&(this.chunks.push(g.data),this.bytes+=g.data.size,this.bytes>Be&&d(()=>{try{h.state!=="inactive"&&h.stop()}catch{}c(new D("cliptoolarge"))}))},h.onstop=u,h.onerror=()=>d(()=>c(new D("generic")));let m=this.now();if(r!==void 0||a!==void 0){let g=!1;h.onstart=()=>{if(!(g||this.settled)&&(g=!0,m=this.now(),r!==void 0))try{r()}catch{}}}try{h.start(Xt)}catch{d(()=>c(new D("generic")));return}let w=o(()=>{if(this.pollTimer&&clearInterval(this.pollTimer),this.pollTimer=null,this.hardStopTimer&&clearTimeout(this.hardStopTimer),this.hardStopTimer=null,this.settled||t?.(),h.state!=="inactive"){try{h.stop()}catch{u()}this.graceTimer=setTimeout(u,Zt)}else u()},"m"),p=this.now();if(a===void 0){this.hardStopTimer=setTimeout(w,s);return}let v=null,y=!1;this.hardStopTimer=setTimeout(w,s+jt),this.pollTimer=setInterval(()=>{if(this.settled||y)return;let g=null;try{g=a.latest()}catch{g=null}let M=g?.presentationTimeMs;M!==void 0&&Number.isFinite(M)&&M>=m&&v===null&&(v=M);let E=v!==null&&M!==void 0&&M-v>=s,A=v===null&&this.now()-p>=s;if(!(!E&&!A)){if(y=!0,this.pollTimer&&clearInterval(this.pollTimer),this.pollTimer=null,A){w();return}this.hardStopTimer&&clearTimeout(this.hardStopTimer),this.hardStopTimer=setTimeout(w,Vt)}},$t)}))}stop(e){this.clearTimers();let t=this.recorder;if(t&&t.state!=="inactive")try{t.stop()}catch{}this.recorder=null,(e??this.stream)?.getTracks().forEach(r=>r.stop()),this.stream=null}},o(q,"A"),q);async function ii(i,e){let t,r=new Promise(h=>{t=setTimeout(()=>h(null),Yt)}),s=await Promise.race([e,r]);if(clearTimeout(t),s===null)return i;let a;try{a=await s.blobBytes(i.blob)}catch{return{...i,stats:null}}let n=s.inspectClipBytes(a);if(n?.container!=="webm")return{...i,stats:n};let l=s.withWebmDuration(a,n.durationMs);if(l===null)return{...i,stats:n};let c=s.inspectClipBytes(l);return c===null||c.frames!==n.frames||c.durationMs!==n.durationMs?{...i,stats:n}:{...i,blob:new Blob([l],{type:i.blob.type}),stats:n}}o(ii,"Be");function ri(i,e,t=.92){return new Promise((r,s)=>{let a=i.videoWidth,n=i.videoHeight;if(!a||!n){s(new Error("video-not-ready"));return}let l=e.getContext("2d");if(!l){s(new Error("no-2d-context"));return}e.width=a,e.height=n,l.scale(-1,1),l.drawImage(i,-a,0),e.toBlob(c=>c?r(c):s(new Error("empty-keyframe")),"image/jpeg",t)})}o(ri,"Me");var W,si=(W=class{constructor(e){this.timer=null,this.frameCallbackId=null,this.running=!1,this.busy=!1,this.lastRunAt=Number.NEGATIVE_INFINITY,this.degradeCount=0,this.durations=[],this.options=e,this.periodMs=1e3/e.cadenceHz}start(){if(this.running)return;this.running=!0;let e=this.options.video;if(typeof e?.requestVideoFrameCallback=="function"){let t=o(()=>{this.running&&(this.frameCallbackId=e.requestVideoFrameCallback?.(()=>{this.frameCallbackId=null,this.now()-this.lastRunAt>=this.periodMs&&this.tick(),t()}))},"t");t();return}this.timer=setInterval(()=>this.tick(),this.periodMs)}stop(){this.running=!1,this.timer!==null&&(clearInterval(this.timer),this.timer=null),this.frameCallbackId!==null&&(this.options.video?.cancelVideoFrameCallback?.(this.frameCallbackId),this.frameCallbackId=null)}stats(){let e=this.durations.length===0?0:this.durations.reduce((t,r)=>t+r,0)/this.durations.length;return{degradeCount:this.degradeCount,meanDetectMs:e}}now(){return this.options.now?.()??performance.now()}tick(){if(!this.running)return;if(this.busy){this.degradeCount+=1;return}this.busy=!0,this.lastRunAt=this.now();let e=this.now();this.options.run().catch(()=>{}).finally(()=>{this.busy=!1,this.durations.push(this.now()-e),this.durations.length>20&&this.durations.shift()})}},o(W,"D"),W),ai=Object.freeze({Q_GOOD:.6,RISE_PER_S:.9,FALL_PER_S:.25,CENTER_FALLOFF_IOD_MULTIPLE:1.35,BOX_EYE_OFFSET_FACTOR:.12,IOD_BOX_PROXY_FACTOR:.42,SIZE_IDEAL_MIN:.12,SIZE_IDEAL_MAX:.3,SIZE_HARD_MIN:.08,SIZE_HARD_MAX:.45,ROLL_MAX_DEG:25,MOTION_VELOCITY_IOD_PER_S:.5,MOTION_TAU_S:.4,MOTION_DEADBAND_IOD_PER_S:.1,READY_WINDOW_MS:500,GUIDE_SIZE:.6,GUIDE_CENTERING:.6,GUIDE_POSE:.6,GUIDE_EXPOSURE:.6,GUIDE_SHARPNESS:.35,GUIDE_MOTION:.5}),L=o(i=>Math.min(1,Math.max(0,i)),"C"),z,ot=(z=class{constructor(e={}){this.p=0,this.lastTickAt=null,this.lastCenter=null,this.velocityEma=0,this.qWindow=[],this.lastSizeDirection="ideal",this.t={...ai,...e}}reset(){this.p=0,this.lastTickAt=null,this.lastCenter=null,this.velocityEma=0,this.qWindow=[],this.lastSizeDirection="ideal"}tick(e){let{observation:t,quality:r,timestampMs:s}=e,a=this.lastTickAt===null?0:Math.max(0,(s-this.lastTickAt)/1e3);this.lastTickAt=s;let n={presence:0,single:1,centering:0,size:0,pose:0,sharpness:L(r.sharpness),exposure:L(r.exposure),motion:1};if(t!==null){n.presence=1,n.single=(t.extraFaces??0)>0?0:1;let d=this.geometryOf(t,e);n.centering=d.centering,n.size=d.size,n.pose=d.pose,n.motion=this.motionOf(d.center,d.iod,s)}else this.lastCenter=null,this.velocityEma=0;let l=Math.min(n.presence,n.single,n.centering,n.size,n.pose,n.sharpness,n.exposure,n.motion);this.p=L(this.p+(l>=this.t.Q_GOOD?this.t.RISE_PER_S*l:-this.t.FALL_PER_S*(1-l))*a),this.qWindow.push({at:s,q:l}),this.qWindow=this.qWindow.filter(d=>d.at>=s-this.t.READY_WINDOW_MS);let c=this.qWindow.map(d=>d.q);if(c.length>=3){let d=Math.min(...c),u=c.indexOf(d);c=c.filter((m,w)=>w!==u)}let h=this.p>=1&&c.every(d=>d>=this.t.Q_GOOD);return{at:s,q:l,p:this.p,factors:n,guidanceKey:this.guidanceOf(n,r,l),ready:h,accepted:l>=this.t.Q_GOOD}}geometryOf(e,t){let{box:r,eyes:s}=e,a={x:t.frameWidth/2,y:t.frameHeight/2},n=Math.min(t.frameWidth,t.frameHeight),l=s!==void 0?{x:(s.left.x+s.right.x)/2,y:(s.left.y+s.right.y)/2}:{x:r.x+r.width/2,y:r.y+r.height/2-this.t.BOX_EYE_OFFSET_FACTOR*r.height},c=s!==void 0?Math.hypot(s.right.x-s.left.x,s.right.y-s.left.y):this.t.IOD_BOX_PROXY_FACTOR*r.width,h=Math.hypot(l.x-a.x,l.y-a.y),d=c<=0?0:1-L(h/(this.t.CENTER_FALLOFF_IOD_MULTIPLE*c)),u=n>0?c/n:0;this.lastSizeDirection=u<this.t.SIZE_IDEAL_MIN?"far":u>this.t.SIZE_IDEAL_MAX?"close":"ideal";let m;u<this.t.SIZE_HARD_MIN||u>this.t.SIZE_HARD_MAX?m=0:u<this.t.SIZE_IDEAL_MIN?m=(u-this.t.SIZE_HARD_MIN)/(this.t.SIZE_IDEAL_MIN-this.t.SIZE_HARD_MIN):u>this.t.SIZE_IDEAL_MAX?m=(this.t.SIZE_HARD_MAX-u)/(this.t.SIZE_HARD_MAX-this.t.SIZE_IDEAL_MAX):m=1;let w=1;if(s!==void 0){let p=Math.abs(Math.atan2(s.right.y-s.left.y,s.right.x-s.left.x))*180/Math.PI;w=1-L(p/this.t.ROLL_MAX_DEG)}return{center:l,iod:c,centering:d,size:m,pose:w}}motionOf(e,t,r){let s=this.lastCenter;if(this.lastCenter={...e,at:r},s===null||t<=0)return 1;let a=(r-s.at)/1e3;if(a<=0)return 1;let n=Math.hypot(e.x-s.x,e.y-s.y)/t/a;n<=this.t.MOTION_DEADBAND_IOD_PER_S&&(n=0);let l=1-Math.exp(-a/this.t.MOTION_TAU_S);return this.velocityEma=l*n+(1-l)*this.velocityEma,1-L(this.velocityEma/this.t.MOTION_VELOCITY_IOD_PER_S)}guidanceOf(e,t,r){if(e.presence<=0)return"fcv3.no_face";if(e.single<=0)return"fcv3.one_face";if(e.size<this.t.GUIDE_SIZE)return this.sizeGuidance();if(e.centering<this.t.GUIDE_CENTERING)return"fcv3.center_face";if(e.pose<this.t.GUIDE_POSE)return"fcv3.straighten";if(e.exposure<this.t.GUIDE_EXPOSURE)return this.exposureGuidance(t);if(e.sharpness<this.t.GUIDE_SHARPNESS)return"fcv3.steady_camera";if(e.motion<this.t.GUIDE_MOTION)return"fcv3.hold_still";if(r<this.t.Q_GOOD){let s=[["size",this.sizeGuidance()],["centering","fcv3.center_face"],["pose","fcv3.straighten"],["exposure",this.exposureGuidance(t)],["sharpness","fcv3.steady_camera"],["motion","fcv3.hold_still"]],a=s[0];for(let n of s)e[n[0]]<e[a[0]]&&(a=n);return a[1]}return"fcv3.hold_still"}sizeGuidance(){return this.lastSizeDirection==="far"?"fcv3.come_closer":"fcv3.move_back"}exposureGuidance(e){let t=(le[0]+le[1])/2;return e.meanLuma<t?"fcv3.more_light":"fcv3.too_bright"}},o(z,"_"),z),ni=["single","size","centering","pose","exposure","sharpness","motion"];function oi(i){if(i.accepted)return null;if(i.factors.presence<=0)return"no_face";let e="single";for(let t of ni)i.factors[t]<i.factors[e]&&(e=t);return e}o(oi,"ze");var H,lt=(H=class{constructor(){this.blocked={},this.acceptedMs=0,this.ticks=0,this.lastAt=null}record(e){let t=this.lastAt===null?0:Math.max(0,e.at-this.lastAt);this.lastAt=e.at,this.ticks+=1;let r=oi(e);if(r===null){this.acceptedMs+=t;return}let s=this.blocked[r]??{count:0,ms:0};s.count+=1,s.ms+=t,this.blocked[r]=s}summary(){let e={};for(let[t,r]of Object.entries(this.blocked))e[t]={count:r.count,ms:Math.round(r.ms)};return{blocked:e,acceptedMs:Math.round(this.acceptedMs),ticks:this.ticks}}},o(H,"w"),H),li=["obs","manycam","virtual","snap camera","xsplit","droidcam","iriun","camo","fake_device","fake-capture-device"],ci=[/^(front|back|rear)( [a-z ]+)? camera$/i,/^caméra (avant|arrière)\b/i,/^cámara (frontal|trasera|delantera)\b/i,/^câmera (frontal|traseira)\b/i,/^(front|rück)kamera\b/i,/^الكاميرا (الأمامية|الخلفية)/,/^camera2? ?\d+, facing (front|back|external)/i,/facetime/i,/\b(integrated|built-in|builtin) (web)?cam(era)?\b/i,/\b(hd )?web ?cam\b/i,/\([0-9a-f]{4}:[0-9a-f]{4}\)\s*$/i];function hi(i){let e=(i??"").trim().toLowerCase();return e.length===0?"unknown":li.some(t=>e.includes(t))?"known_virtual":ci.some(t=>t.test(e))?"platform":"unknown"}o(hi,"Qe");function ct(i){if(typeof i!="function")return!1;try{return/\{\s*\[native code\]\s*\}\s*$/.test(Function.prototype.toString.call(i))}catch{return!1}}o(ct,"Ce");function ui(i=globalThis){return ct(i.navigator?.mediaDevices?.getUserMedia)&&ct(i.MediaStreamTrack?.prototype?.getSettings)}o(ui,"Ye");async function di(i,e=globalThis){let t=e.crypto?.subtle?.digest;if(typeof t=="function")try{let r=new Uint8Array(await t.call(e.crypto?.subtle,"SHA-256",new TextEncoder().encode(i)));return Array.from(r.subarray(0,8),s=>s.toString(16).padStart(2,"0")).join("")}catch{return}}o(di,"je");async function fi(i,e=globalThis){let t={};try{t=typeof i.getSettings=="function"?i.getSettings()??{}:{}}catch{t={}}let r={};if((t.facingMode==="user"||t.facingMode==="environment"||t.facingMode==="left"||t.facingMode==="right")&&(r.facingMode=t.facingMode),typeof t.frameRate=="number"&&Number.isFinite(t.frameRate)&&(r.frameRate=t.frameRate),typeof t.width=="number"&&Number.isFinite(t.width)&&(r.width=t.width),typeof t.height=="number"&&Number.isFinite(t.height)&&(r.height=t.height),typeof t.deviceId=="string"&&t.deviceId.length>0){let a=await di(t.deviceId,e);a!==void 0&&(r.deviceIdHash=a)}let s;try{s=i.label}catch{s=void 0}return{trackSettings:r,capabilitiesPresent:typeof i.getCapabilities=="function",labelClass:hi(s),prototypesIntact:ui(e)}}o(fi,"Se");var fe=o(i=>Math.round(i*100)/100,"U");function pi(i){let e=i,t=typeof e?.requestVideoFrameCallback=="function",r=null,s=null,a=0,n=0,l=0,c=0,h=0,d=0,u=o(()=>{!t||e?.requestVideoFrameCallback===void 0||(r=e.requestVideoFrameCallback((m,w)=>{if(r=null,!t)return;let p=w.presentationTime;if(s!==null){let v=p-s.presentationTimeMs;n+=1;let y=v-l;l+=y/n,c+=y*(v-l)}typeof w.captureTime=="number"&&Number.isFinite(w.captureTime)&&(h+=p-w.captureTime,d+=1),a+=1,s={mediaTimeMs:w.mediaTime*1e3,presentationTimeMs:p},u()}))},"u");return u(),{latest:o(()=>s,"latest"),stats:o(()=>({n:a,meanGapMs:n===0?0:fe(l),stdGapMs:n<2?0:fe(Math.sqrt(c/(n-1))),captureLatencyMs:d===0?null:fe(h/d)}),"stats"),stop:o(()=>{t&&(t=!1,r!==null&&e?.cancelVideoFrameCallback?.(r),r=null)},"stop")}}o(pi,"ke");function mi(i,e,t){return{...i,rvfc:e,rampPainter:t}}o(mi,"_e");var gi=1e3,pe="fcv3.hold_upright",vi=200,me=4,yi=600,wi=1e3,ht={sharpness:1,exposure:1,meanLuma:128};function bi(i,e){return e.width=i.videoWidth,e.height=i.videoHeight,e.getContext("2d").drawImage(i,0,0),new Promise((t,r)=>e.toBlob(s=>s?t(s):r(new Error("empty-keyframe")),"image/jpeg",.92))}o(bi,"rt");function Mi(){return Q()==="phone"}o(Mi,"it");var K,mt=(K=class{constructor(e){this.handlers=new Map,this.stateValue="idle",this.attempt=0,this.stream=null,this.detector=null,this.scheduler=null,this.gate=null,this.profiler=null,this.lastGuidanceKey=null,this.positioningStartedAt=0,this.cameraRequestedAt=null,this.cameraReadyAt=null,this.faceAcquiredAt=null,this.captureCompleteAt=null,this.fired=!1,this.carriedDegrade=0,this.carriedMeans=[],this.blockStats=null,this.lastGateSnapshotAt=Number.NEGATIVE_INFINITY,this.uprightGuard=!1,this.trackProvenance=null,this.openEnvironment=null,this.ramp=null,this.snapshotCanvas=null,this.options=e,this.facing=e.facingMode??"user"}get state(){return this.stateValue}on(e,t){let r=this.handlers.get(e);return r||(r=new Set,this.handlers.set(e,r)),r.add(t),()=>r?.delete(t)}emit(e,t){for(let r of[...this.handlers.get(e)??[]])r(t)}async start(e={}){e.facingMode!==void 0&&(this.facing=e.facingMode),this.attempt+=1,await this.run(this.attempt)}get facingMode(){return this.facing}retry(){this.teardownAttempt(),this.start()}switchCamera(){this.facing=this.facing==="user"?"environment":"user",this.teardownAttempt(),this.start()}restart(e){this.facing=e,this.teardownAttempt(),this.start()}destroy(){this.attempt+=1,this.teardownAttempt(),this.detector?.destroy(),this.detector=null,this.options.video.srcObject=null}async run(e){let{options:t}=this;this.fired=!1,this.lastGuidanceKey=null,this.carriedDegrade=0,this.carriedMeans=[],this.cameraRequestedAt=null,this.cameraReadyAt=null,this.faceAcquiredAt=null,this.captureCompleteAt=null,this.uprightGuard=(t.isPhone??Mi)(),this.setState("preflight");let r=Ne();if(r!=="OK"){this.fail(r==="INSECURE_CONTEXT"?"insecure":"unsupported",{phase:"preflight"});return}this.setState("acquiring");let s=t.getUserMedia??(h=>navigator.mediaDevices.getUserMedia(h)),a;this.cameraRequestedAt=this.now();try{let{facingMode:h,...d}=Se(Ae(),this.facing).video;a=await Ke(this.facing,d,{getUserMedia:s,enumerateDevices:_i(t)})}catch(h){if(e!==this.attempt)return;if(h instanceof He){this.fail("backcamera",{phase:"acquiring",name:j(h)});return}this.fail(We(h),{phase:"acquiring",name:j(h)});return}if(Re(a),ze(a),e!==this.attempt){for(let h of a.getTracks())h.stop();return}this.stream=a;let n=a.getVideoTracks?.()[0];if(this.trackProvenance=n===void 0?null:fi(n).catch(()=>null),this.openEnvironment=n===void 0?null:xe(n).catch(()=>({})),this.facing=Ie(a)??this.facing,t.video.srcObject=a,await t.video.play().catch(()=>{}),e!==this.attempt)return;if(this.cameraReadyAt=this.now(),this.detector===null){let h={v3AssetBaseUrl:t.v3AssetBaseUrl},d=t.createDetector??(t.createWorker!==void 0&&it()?async()=>{try{return await rt.create(t.createWorker(),h)}catch{return x(h)}}:()=>x(h)),u;try{u=await d()}catch(m){e===this.attempt&&this.fail("models",{phase:"models",name:j(m)},m instanceof de?m.fallbackReason:Ti(m));return}if(e!==this.attempt){u.destroy();return}this.detector=u,this.options.telemetry?.({type:"detector",tier:u.tier,fallbackReason:u.fallbackReason})}let l=Xe(),c=t.deviceClass??Ze(l);this.profiler=new Ve(c),this.options.telemetry?.({type:"profile",staticClass:c,activeClass:this.profiler.deviceClass,simd:l.simd}),this.gate=new ot(t.thresholds??{}),this.blockStats=new lt,this.lastGateSnapshotAt=this.now(),t.rankKeyframes?.()&&import("./keyframe-rank-YAJLYJYF-WCA6RPMD.js").then(h=>ge=h,()=>{}),this.setState("positioning"),this.positioningStartedAt=this.now(),this.startScheduler(e)}get animations(){return this.profiler?.profile.animations??"full"}startScheduler(e){let t=this.profiler;if(t===null)return;if(this.scheduler!==null){let s=this.scheduler.stats();this.carriedDegrade+=s.degradeCount,s.meanDetectMs>0&&this.carriedMeans.push(s.meanDetectMs),this.scheduler.stop()}let r=new si({cadenceHz:t.profile.cadenceHz,video:this.options.video,now:this.options.now,run:o(()=>this.detectTick(e),"run")});this.scheduler=r,r.start()}async detectTick(e){let{detector:t,gate:r,profiler:s}=this,a=this.options.video;if(e!==this.attempt||t===null||r===null||s===null||this.fired||a.videoWidth===0)return;if(this.isLandscape()){this.holdUpright(e);return}let n=s.deviceClass,l=this.now(),c=this.options.makeSnapshot?.(a,s.profile.inputWidth)??this.defaultSnapshot(a,s.profile.inputWidth),h=null;try{h=await t.detect(c,a.videoWidth,a.videoHeight)}catch{h=null}if(e!==this.attempt||this.fired)return;s.record(this.now()-l),s.deviceClass!==n&&this.startScheduler(e);let d=h===null?ht:this.options.measureQuality?.(a,h.box)??this.defaultQuality(a,h.box),u=r.tick({timestampMs:this.now(),observation:h,quality:d,frameWidth:a.videoWidth,frameHeight:a.videoHeight});u.accepted&&this.faceAcquiredAt===null&&(this.faceAcquiredAt=u.at),this.blockStats?.record(u),!u.ready&&u.at-this.lastGateSnapshotAt>=gi&&(this.lastGateSnapshotAt=u.at,this.reportGate(!1)),this.emit("checks",{engine:"v3",progress:u.p,q:u.q,factors:u.factors,attempt:e}),u.guidanceKey!==this.lastGuidanceKey&&(this.lastGuidanceKey=u.guidanceKey,this.emit("guidance",{key:u.guidanceKey})),u.ready&&this.stateValue==="positioning"&&(this.fired=!0,this.captureCompleteAt=u.at,this.fire(e))}async fire(e){let{options:t}=this,r=this.scheduler;r?.stop(),this.reportGate(!0);let s=r?.stats()??{degradeCount:0,meanDetectMs:0},a=[...this.carriedMeans,...s.meanDetectMs>0?[s.meanDetectMs]:[]];t.telemetry?.({type:"fired",timeToGateMs:this.now()-this.positioningStartedAt,degradeCount:this.carriedDegrade+s.degradeCount,meanDetectMs:a.length===0?0:a.reduce((_,b)=>_+b,0)/a.length});let n=t.mode??"clip",l=t.rankKeyframes?.()&&ge?ge.default(this,e).catch(()=>this.collectKeyframes(e)):this.collectKeyframes(e);if(n==="photo"){let _=this.watchRotation(e,null),b=await l;if(_(),e!==this.attempt)return;if(b===null){this.fail("generic",{phase:"keyframes"});return}let R=await this.provenance({n:0,meanGapMs:0,stdGapMs:0,captureLatencyMs:null},!1);if(e!==this.attempt)return;this.finishCapture({keyframe:b.blob,previewDataUrl:b.previewDataUrl,...R});return}this.setState("recording");let c=this.stream;if(c===null){this.fail("generic",{phase:"recording"});return}let h=t.screenRamp?.(),d=ee(h),u=null;l.then(_=>{u=_},()=>{});let m=o(()=>{e===this.attempt&&u!==null&&this.emit("frozen",{previewDataUrl:u.previewDataUrl})},"p"),w=Ye(h,pt),p=null,v,y=0;try{let _=this.recordTake(e,c,h,w,void 0).then(S=>S,S=>({failed:S})),[b,R]=await Promise.all([_,l]);if(v=R,e!==this.attempt)return;if("failed"in b){if(b.failed.kind==="cliptoolarge")throw b.failed;st(b.failed.requestedMimeType??"")}else p=b,nt(b.clip,w)?b.clip.stats===null&&st(b.clip.requestedMimeType??""):m();if(p===null||nt(p.clip,w)){y=1,t.telemetry?.({type:"clip_retake",reason:p===null?"error":p.clip.stats===null?"unreadable":"short"});let S=null;try{S=await this.recordTake(e,c,h,w,m)}catch($){if(p===null)throw $}if(e!==this.attempt)return;S!==null&&(p===null||ei(S.clip,p.clip))&&(p=S),S===null&&m()}}catch(_){if(e!==this.attempt)return;let b=_.kind;this.fail(b==="cliptoolarge"?"cliptoolarge":"recorder",{phase:"recording",name:j(_)});return}if(p===null){this.fail("recorder",{phase:"recording"});return}let{clip:g,rvfc:M,report:E,watched:A}=p;if(oe(g.blob)){this.fail("cliptoolarge",{phase:"recording"});return}if(v===null){this.fail("generic",{phase:"keyframes"});return}let I=await this.provenance(M,d,A);e===this.attempt&&this.finishCapture({clip:g.blob,clipMimeType:g.mimeType,...g.stats?{clipStats:g.stats}:{},clipRetakes:y,keyframe:v.blob,previewDataUrl:v.previewDataUrl,...E!==void 0&&E.rendered.length>0?{screenRamp:E}:{},...I})}async recordTake(e,t,r,s,a){let n=this.options.createRecorder?.()??new ti({now:o(()=>this.now(),"now")}),l=pi(this.options.video),c=Qe(r,{paint:o(m=>{(m===null||e===this.attempt)&&this.emit("ramp",{colour:m})},"paint"),now:o(()=>this.now(),"now"),frames:l.latest});this.ramp=c;let h=o(()=>{l.stop(),c.stop(),this.ramp===c&&(this.ramp=null)},"l"),d=this.watchRotation(e,n),u=De();try{return{clip:await n.record(t,a,()=>c.started(this.now()),s,l),rvfc:l.stats(),report:c.report(),watched:u.stop()}}finally{u.stop(),d(),h()}}async provenance(e,t,r={}){let s=this.trackProvenance;if(s===null)return{};let a,n=new Promise(d=>{a=setTimeout(()=>d(null),wi)}),l=await Promise.race([s,n]),c=l===null?null:await Promise.race([this.openEnvironment,n]);if(clearTimeout(a),l===null)return{};let h={...c,...r};return{provenance:{...mi(l,e,t),...Object.keys(h).length>0?{env:h}:{}}}}isLandscape(){let e=this.options.video;return this.uprightGuard&&e.videoWidth>e.videoHeight}holdUpright(e){this.gate?.reset(),this.emit("checks",{engine:"v3",progress:0,q:0,factors:{presence:0,single:1,centering:0,size:0,pose:0,sharpness:0,exposure:0,motion:0},attempt:e}),this.lastGuidanceKey!==pe&&(this.lastGuidanceKey=pe,this.emit("guidance",{key:pe}))}watchRotation(e,t){if(!this.uprightGuard)return()=>{};let r=this.options.video,s=o(()=>{if(e!==this.attempt||t!==null&&this.stateValue!=="recording"){l();return}r.videoWidth>0&&this.isLandscape()&&(l(),this.abortRecording(e,t))},"i"),a=setInterval(s,vi);r.addEventListener?.("resize",s);let n=!1;function l(){n||(n=!0,clearInterval(a),r.removeEventListener?.("resize",s))}return o(l,"o"),l}abortRecording(e,t){if(e!==this.attempt)return;this.attempt+=1;let r=this.attempt;try{t?.stop()}catch{}this.ramp?.stop(),this.ramp=null,this.fired=!1,this.captureCompleteAt=null,this.gate=new ot(this.options.thresholds??{}),this.blockStats=new lt,this.lastGateSnapshotAt=this.now(),this.lastGuidanceKey=null,this.setState("positioning"),this.positioningStartedAt=this.now(),this.holdUpright(r),this.startScheduler(r)}async collectKeyframes(e){let t=this.options.captureKeyframe??(a=>this.defaultKeyframe(a)),r=yi/(me-1),s=null;for(let a=0;a<me;a+=1){if(e!==this.attempt)return s;try{let n=await t(this.options.video);(s===null||n.sharpness>s.sharpness)&&(s=n)}catch{}a<me-1&&await ki(r)}return s}finishCapture(e){this.stopTracks(),this.setState("captured");let t=this.captureTiming();this.emit("artifacts",t===void 0?e:{...e,timing:t})}captureTiming(){let e={},t=o((r,s,a)=>{s!==null&&a!==null&&(e[r]=Math.max(0,Math.round(a-s)))},"t");return t("cameraReadyMs",this.cameraRequestedAt,this.cameraReadyAt),t("faceAcquireMs",this.cameraReadyAt,this.faceAcquiredAt),t("captureMs",this.faceAcquiredAt,this.captureCompleteAt),Object.keys(e).length>0?e:void 0}async defaultKeyframe(e){let t=document.createElement("canvas"),r=await(this.facing==="user"?ri:bi)(e,t),s=t.toDataURL("image/jpeg",.92);return{blob:r,previewDataUrl:s,sharpness:this.centerSharpness(e)}}defaultSnapshot(e,t){try{let r=this.snapshotCanvas??document.createElement("canvas"),s=t/Math.max(1,e.videoWidth),a=Math.max(1,Math.round(e.videoWidth*s)),n=Math.max(1,Math.round(e.videoHeight*s)),l=r.getContext("2d");return l===null?e:(r.width!==a&&(r.width=a),r.height!==n&&(r.height=n),l.drawImage(e,0,0,a,n),this.snapshotCanvas=r,r)}catch{return e}}defaultQuality(e,t){let r=ut(e,t,96);return r===null?ht:{sharpness:ce(r),exposure:$e(r),meanLuma:je(r)}}centerSharpness(e){let t=te(e),r=ut(e,{x:t.width*.25,y:t.height*.25,width:t.width*.5,height:t.height*.5},96);return r===null?0:ce(r)}teardownAttempt(){this.scheduler?.stop(),this.scheduler=null,this.reportGate(!0),this.gate=null,this.ramp?.stop(),this.ramp=null,this.stopTracks()}reportGate(e){let t=this.blockStats,r=this.profiler;if(t===null||r===null)return;let s=t.summary();e&&(this.blockStats=null),s.ticks!==0&&this.options.telemetry?.({type:"gate",final:e,activeClass:r.deviceClass,cadenceHz:r.profile.cadenceHz,...s})}stopTracks(){if(this.stream!==null){for(let e of this.stream.getTracks())e.stop();this.stream=null}}fail(e,t,r){this.scheduler?.stop(),this.reportGate(!0),this.stopTracks(),this.setState("error"),this.options.telemetry?.({type:"error",kind:e,fallbackReason:r});let{phase:s,name:a}=t;this.emit("error",{kind:e,retryable:e!=="insecure"&&e!=="unsupported",detail:a===void 0?{phase:s}:{phase:s,name:a}})}setState(e){this.stateValue=e,this.emit("statechange",{state:e})}now(){return this.options.now?.()??performance.now()}},o(K,"Ie"),K),ge;function ki(i){return new Promise(e=>setTimeout(e,i))}o(ki,"nt");function Ti(i){return i instanceof Error?i.message:String(i)}o(Ti,"at");function ut(i,e,t){try{let r=document.createElement("canvas"),s=t/Math.max(1,e.width);r.width=Math.max(1,Math.round(e.width*s)),r.height=Math.max(1,Math.round(e.height*s));let a=r.getContext("2d");return a===null?null:(a.drawImage(i,e.x,e.y,e.width,e.height,0,0,r.width,r.height),a.getImageData(0,0,r.width,r.height))}catch{return null}}o(ut,"Re");function _i(i){if(i.enumerateDevices!==void 0)return i.enumerateDevices;if(i.getUserMedia===void 0&&!(typeof navigator>"u"||typeof navigator.mediaDevices?.enumerateDevices!="function"))return()=>navigator.mediaDevices.enumerateDevices()}o(_i,"st");var Ei=12e4,gt=13e4,Si=3e3,Ai=1200,ve=Symbol.for("@sekyro/web.preload.v1");function we(){let i=globalThis;return i[ve]??(i[ve]=new Map),i[ve]}o(we,"h");function re(i){let e=(i??ue).replace(/\/+$/,"");return e===""?"/":e}o(re,"b");function yt(i){let e=we(),t=e.get(i);return t===void 0&&(t={status:"idle",promise:null,scheduled:null,detectorPromise:null,detector:null,listeners:new Set},e.set(i,t)),t}o(yt,"ae");function ye(i,e){if(i.status!==e){i.status=e;for(let t of[...i.listeners])t(e)}}o(ye,"k");var Ii=o(i=>x({preferred:["blaze"],v3AssetBaseUrl:i,blazeInitTimeoutMs:Ei}),"K"),xi=Ii;function Di(){return typeof window<"u"&&typeof navigator<"u"&&typeof navigator.mediaDevices?.getUserMedia=="function"}o(Di,"Ce");function Ri(){return navigator.connection?.saveData===!0}o(Ri,"Se");function Ci(i){let e=window;if(typeof e.requestIdleCallback=="function"){let r=e.requestIdleCallback(i,{timeout:Si});return()=>e.cancelIdleCallback?.(r)}let t=setTimeout(i,Ai);return()=>clearTimeout(t)}o(Ci,"Ee");function Oi(i,e){let t,r=new Promise(l=>{t=l}),s=!1,a=o(()=>{},"u"),n={promise:r,settle:o(l=>{s||(s=!0,a(),i.scheduled===n&&(i.scheduled=null),t(l))},"settle")};return i.scheduled=n,a=Ci(()=>{s||n.settle(be(i,e))}),r}o(Oi,"ye");function be(i,e){if((i.status==="loading"||i.status==="ready")&&i.promise!==null)return i.promise;ye(i,"loading");let t=new Promise(n=>n(xi(e)));i.detectorPromise=t;let r,s=new Promise((n,l)=>{r=setTimeout(()=>{t.then(c=>c.destroy(),()=>{}),l(new Error(`detector preload exceeded ${gt} ms`))},gt)}),a=Promise.race([t,s]).then(n=>i.detectorPromise!==t?(n.destroy(),i.status):(i.detector=n,ye(i,"ready"),"ready"),n=>(i.detectorPromise===t&&(i.detectorPromise=null,i.detector=null,ye(i,"failed"),console.warn("[@sekyro/web] face-detector preload failed:",n)),i.status)).finally(()=>clearTimeout(r));return i.promise=a,i.scheduled?.settle(a),a}o(be,"U");function hr(i={}){if(!Di())return Promise.resolve("idle");let e=re(i.assetBaseUrl),t=yt(e);return i.respectSaveData===!0&&Ri()?Promise.resolve(t.status):(t.status==="loading"||t.status==="ready")&&t.promise!==null?t.promise:i.idle===!0?t.scheduled?.promise??Oi(t,e):be(t,e)}o(hr,"xe");function ur(i){return we().get(re(i))?.status??"idle"}o(ur,"Fe");function dr(i,e){let t=yt(re(e));return t.listeners.add(i),()=>{t.listeners.delete(i)}}o(dr,"Ie");function Pi(i){return{get tier(){return i.tier},get fallbackReason(){return i.fallbackReason},detect:o((...e)=>i.detect(...e),"detect"),destroy:o(()=>{},"destroy")}}o(Pi,"Le");function Gi(i){let e=re(i),t=we().get(e);if(!(t===void 0||t.detector===null&&t.detectorPromise===null&&t.scheduled===null))return async()=>{t.scheduled!==null&&be(t,e);let r=t.promise;for(;t.detector===null&&r!==null&&(await r,t.promise!==r);)r=t.promise;return t.detector!==null?Pi(t.detector):x({v3AssetBaseUrl:e})}}o(Gi,"de");var Ui=new Set(["inuse","overconstrained","notfound"]),Fi=[500,1500];function Ni(i){switch(i){case"fcv3.no_face":case"fcv3.center_face":case"fcv3.straighten":return"center";case"fcv3.come_closer":return"closer";case"fcv3.move_back":return"farther";case"fcv3.more_light":case"fcv3.too_bright":return"light";case"fcv3.hold_still":case"fcv3.steady_camera":return"still";case"fcv3.hold_upright":return"upright";case"fcv3.one_face":return"one_face";default:return null}}o(Ni,"Ae");function Li(i){switch(i){case"preflight":case"acquiring":return"starting";case"positioning":return"gating";default:return i}}o(Li,"Pe");function vt(i){switch(i){case"permission":case"notfound":case"inuse":case"insecure":case"unsupported":return i;case"backcamera":return"notfound";default:{let e=i;return"generic"}}}o(vt,"ue");function Bi(i,e,t){if(t===void 0)return{kind:vt(i),retryable:e};let r=qe(t.name);return{kind:vt(i),retryable:e,detail:{...r!==void 0?{name:r}:{},phase:t.phase,engineKind:i}}}o(Bi,"we");var qi=new Set(["captured","uploading","checking"]);function Wi(i,e={},t,r=()=>"self",s=()=>{},a){let n=e.now??(()=>performance.now()),l=e.canChooseFacing??Oe,c="user",h=Pe(),d=r(),u=Ce(),m=!Le(),w=e.engineOptions,p=w?.createDetector===void 0&&w?.createWorker===void 0?{createDetector:o(()=>{let f=Gi(i.assetBaseUrl);return f!==void 0?f():x({v3AssetBaseUrl:i.assetBaseUrl})},"createDetector")}:{},v={video:i.video,mode:m?"photo":"clip",rankKeyframes:t,facingMode:void 0,v3AssetBaseUrl:i.assetBaseUrl,screenRamp:o(()=>d==="self"&&u.count("ramp")>0?s():void 0,"screenRamp"),...e.engineOptions??{},...p},y=e.createEngine?.(v)??new mt(v),g="idle",M=null,E=0,A=!1,I="full",_=null,b=null,R=0,S=0,$=o(()=>{i.video.videoWidth>0&&i.video.videoHeight>0&&(R=i.video.videoWidth,S=i.video.videoHeight)},"W"),Me=Ge({enabled:i.keepScreenAwake!==!1}),X=o(f=>{g=f,Me.setActive(f==="starting"||f==="gating"||f==="recording"),u.emit("state",f)},"S"),se=o(()=>u.emit("gate",{progress:E,hint:M,faceDetected:A}),"F"),ae=o(()=>{let f=y.animations??"full";f!==I&&(I=f,u.emit("profile",{animations:I}))},"I"),G=0,Y=null,wt=e.schedule??((f,k)=>{let T=setTimeout(f,k);return()=>clearTimeout(T)}),Z=o(()=>{Y?.(),Y=null},"E"),bt=o((f,k)=>{if(V||!Ui.has(f)||k?.phase!=="acquiring")return!1;let T=Fi[G];return T===void 0?!1:(G+=1,Z(),Y=wt(()=>{Y=null,V||y.retry()},T),!0)},"fe"),Mt=[y.on("statechange",({state:f})=>{if(f==="error")return;let k=Li(f);k==="gating"&&(G=0),k==="starting"&&g!=="starting"&&(M=null,E=0,A=!1,_=null,b=null,R=0,S=0),X(k),ae(),k==="recording"&&($(),_=n(),M="hold",E=1,se())}),y.on("checks",f=>{$(),E=f.progress,A=f.factors.presence>0,se(),ae()}),y.on("guidance",({key:f})=>{M=Ni(f),se()}),y.on("frozen",({previewDataUrl:f})=>{b=n(),u.emit("frozen",{previewDataUrl:f})}),y.on("ramp",f=>u.emit("ramp",f)),y.on("artifacts",f=>{if(g!=="captured")return;let k=Q(),T=f.clipStats,_e=T!==void 0?Math.round(T.durationMs):_!==null&&b!==null?Math.max(0,Math.round(b-_)):void 0,Ee=T!==void 0&&T.frames>1&&T.durationMs>0?Math.round(T.frames*1e4/T.durationMs)/10:void 0;u.emit("captured",{keyframe:f.keyframe,...f.clip!==void 0?{clip:f.clip}:{},...f.clipMimeType!==void 0?{clipMime:f.clipMimeType}:{},width:i.video.videoWidth||R,height:i.video.videoHeight||S,..._e!==void 0?{clipMs:_e}:{},...T!==void 0?{clipFrames:T.frames}:{},...Ee!==void 0?{fps:Ee}:{},...f.clipRetakes!==void 0?{clipRetakes:f.clipRetakes}:{},...f.clipMimeType!==void 0?{codec:ft(f.clipMimeType)}:{},captureChannel:k==="desktop"?"desktop":"mobile",formFactor:k,...m?{degraded:"NO_RECORDER"}:{},engine:"v3",facingMode:y.facingMode,mode:d,...f.timing,...f.screenRamp!==void 0?{screenRamp:f.screenRamp}:{},...f.provenance!==void 0?{provenance:f.provenance}:{}})}),y.on("error",({kind:f,retryable:k,detail:T})=>{f==="backcamera"&&kt()||bt(f,T)||(X("error"),ae(),u.emit("error",Bi(f,k,T)))})],ke=!1;function kt(){return V||ke||d!=="assisted"||a===void 0||a.session()!=="choice"?!1:(ke=!0,a.onModeChange("self"),d="self",c=ne("self"),X("mode_switch"),y.restart(c),!0)}o(kt,"me");let Te=o(async()=>a!==void 0&&a.session()==="choice"&&await l().catch(()=>!1),"$"),V=!1;return{handle:{get state(){return g},get captureMode(){return r()},get facingMode(){return y.facingMode??c},on:o((f,k)=>u.on(f,k),"on"),start:o(f=>(d=r(),h.facing(d,i.facing),c=h.facing(d,f?.facing),Z(),G=0,y.start({facingMode:c})),"start"),retry:o(()=>{Z(),G=0,y.retry()},"retry"),switchCamera:o(()=>h.refuseSwitch(r()),"switchCamera"),canSwitchCaptureMode:Te,setCaptureMode:o(async f=>{if(f===r()||!await Te()||V||qi.has(g)||a===void 0)return!1;a.onModeChange(f),d=f;let k=ne(f);return c=k,g==="idle"||(X("mode_switch"),Z(),G=0,y.restart(k)),!0},"setCaptureMode"),destroy:o(()=>{V=!0,Z();for(let f of Mt)f();Me.setActive(!1),y.destroy(),u.clear()},"destroy")},setFlowState:o(f=>{g!==f&&X(f)},"setFlowState")}}o(Wi,"De");function fr(i){return Wi(i).handle}o(fr,"Ze");export{zi as a,ee as b,hr as c,ur as d,dr as e,Bi as f,Wi as g,fr as h};
|
|
1
|
+
import{d as Re,e as Xe,f as Ze,g as Ve}from"./chunk-EGCT7K5E.js";import{a as le,b as je,c as ce,d as $e}from"./chunk-P7K7ELYZ.js";import{a as Se,b as Q,c as Ae,d as Ie,e as Ce,h as Oe,i as ne,j as Pe,k as Ge,l as He,m as Ke}from"./chunk-6MYG4HWP.js";import{a as Ue,b as Fe,c as Ne,d as Le,e as Be,f as oe,g as j,h as qe,i as We,j as ze}from"./chunk-JS2IXPNL.js";import{b as xe,c as De}from"./chunk-SLLJX5QK.js";import{a as o}from"./chunk-4FHWXBOB.js";var Tt=["magenta","yellow","green","blue"],_t={magenta:"rgb(255, 72, 150)",yellow:"rgb(255, 190, 0)",green:"rgb(0, 238, 175)",blue:"rgb(25, 150, 255)",dark:"rgb(0, 0, 0)"};function zi(i){return _t[i]}o(zi,"P");var Et=4,St=4,J=o(i=>typeof i=="number"&&Number.isFinite(i),"R");function ee(i){if(typeof i!="object"||i===null)return!1;let e=i;if(typeof e.nonce!="string"||e.nonce.length===0||!Array.isArray(e.colours)||e.colours.length<1||e.colours.length>8||!e.colours.every(r=>Tt.includes(r))||!Array.isArray(e.onsetsMs)||e.onsetsMs.length!==e.colours.length)return!1;let t=-1;for(let r of e.onsetsMs){if(!J(r)||r<0||r<=t)return!1;t=r}return!(!J(e.holdMs)||e.holdMs<=0||!J(e.endMs)||e.endMs<=t||!J(e.clipMs)||e.clipMs<e.endMs||e.clipMs>8e3)}o(ee,"_");function Ye(i,e){return ee(i)?Math.max(e,Math.ceil(i.clipMs)):e}o(Ye,"O");function Qe(i,e){let t=e.now??(()=>performance.now()),r=ee(i)?i:void 0,s=[],a=null,n=null,l=null,c=!1,h=null,d=o(p=>{h=p;try{e.paint(p)}catch{}},"s"),u=o(p=>{let v=e.frames?.()??null;return v!==null&&l!==null?v.mediaTimeMs+(p-v.presentationTimeMs)-l:p-(n??p)},"p"),m=o((p,v,y=0)=>{if(c)return;let g=Math.max(0,p-u(t()));a=setTimeout(()=>{if(a=null,!c){if(y<Et&&u(t())<p-St){m(p,v,y+1);return}v()}},g)},"f"),w=o(p=>{if(r===void 0)return;let v=r.endMs;if(p>=r.colours.length){m(v,()=>d(null));return}let y=r.onsetsMs[p],g=p+1<r.onsetsMs.length?r.onsetsMs[p+1]:v;m(y,()=>{let M=u(t());if(M>v){h!==null&&d(null);return}let E=r.colours[p];d(E);let A=s.length===0?0:s[s.length-1].tMs;s.push({tMs:Math.max(A,Math.round(M)),colour:E});let I=y+r.holdMs;if(I<g){m(I,()=>{if(u(t())>v){h!==null&&d(null);return}d("dark"),w(p+1)});return}w(p+1)})},"S");return{started(p){if(r===void 0||c||n!==null)return;n=p;let v=e.frames?.()??null;l=v===null?null:v.mediaTimeMs+(p-v.presentationTimeMs),w(0)},stop(){c||(c=!0,a!==null&&clearTimeout(a),a=null,h!==null&&d(null))},report(){return r===void 0?void 0:{nonce:r.nonce,rendered:[...s]}}}}o(Qe,"w");var At=1e4,O,It=(O=class{constructor(e,t){this.tier="blaze",this.inner=e,t!==void 0&&(this.fallbackReason=t)}static async create(e,t){let r=await import("./vision_bundle-WBHR7TEE.js"),s=await r.FilesetResolver.forVisionTasks(e),a=await r.FaceDetector.createFromOptions(s,{baseOptions:{modelAssetPath:`${e}/blaze_face_short_range.tflite`,delegate:"CPU"},runningMode:"IMAGE"});return new O(a,t)}async detect(e,t,r){let s;try{s=this.inner.detect(e).detections}catch{return null}let a=xt(s);if(a?.boundingBox===void 0)return null;let n=te(e),l=Dt(a.keypoints,n),c=a.keypoints?.[2],h={box:{x:a.boundingBox.originX,y:a.boundingBox.originY,width:a.boundingBox.width,height:a.boundingBox.height},...l!==void 0?{eyes:l}:{},...c!==void 0?{nose:{x:c.x*n.width,y:c.y*n.height}}:{},score:a.categories[0]?.score??0,extraFaces:Je(s.map(d=>d.boundingBox??{width:0,height:0}),s.indexOf(a))};return et(h,e,t,r)}destroy(){try{this.inner.close()}catch{}}},o(O,"t"),O);function xt(i){let e,t=-1;for(let r of i){let s=r.categories[0]?.score??0;s>t&&(e=r,t=s)}return e}o(xt,"R");function Dt(i,e){let t=i?.[0],r=i?.[1];if(t===void 0||r===void 0)return;let s=o(l=>({x:l.x*e.width,y:l.y*e.height}),"n"),[a,n]=[s(t),s(r)];return a.x<=n.x?{left:a,right:n}:{left:n,right:a}}o(Dt,"T");function Rt(){if(typeof OffscreenCanvas=="function")return new OffscreenCanvas(2,2);let i=document.createElement("canvas");return i.width=2,i.height=2,i}o(Rt,"E");var Ct=4;async function Ot(){let i=globalThis.FaceDetector;if(typeof i!="function")return{ok:!1,reason:"unsupported"};try{let e=new i({fastMode:!0,maxDetectedFaces:Ct});return await e.detect(Rt()),{ok:!0,instance:e}}catch(e){return{ok:!1,reason:`smoke_failed:${e instanceof Error?e.message:String(e)}`}}}o(Ot,"w");var U,Pt=(U=class{constructor(e,t){this.tier="native",this.inner=e,t!==void 0&&(this.fallbackReason=t)}async detect(e,t,r){let s;try{s=await this.inner.detect(e)}catch{return null}let a=s.map(d=>d.boundingBox),n=-1;a.forEach((d,u)=>{let m=a[n];(m===void 0||d.width*d.height>m.width*m.height)&&(n=u)});let l=s[n];if(l===void 0)return null;let c=Gt(l.landmarks),h={box:{x:l.boundingBox.x,y:l.boundingBox.y,width:l.boundingBox.width,height:l.boundingBox.height},...c!==void 0?{eyes:c}:{},score:1,extraFaces:Je(a,n)};return et(h,e,t,r)}destroy(){}},o(U,"b"),U);function Gt(i){if(i===void 0)return;let e=i.filter(s=>s.type==="eye").map(s=>s.locations[0]).filter(s=>s!==void 0),[t,r]=e;if(!(t===void 0||r===void 0))return t.x<=r.x?{left:t,right:r}:{left:r,right:t}}o(Gt,"S");var Ut=.25;function Je(i,e){let t=i[e],r=t===void 0?0:t.width*t.height;if(!(r>0))return 0;let s=0;return i.forEach((a,n)=>{n!==e&&a.width*a.height>=Ut*r&&(s+=1)}),s}o(Je,"f");var ue="/models-v3",Ft=["native","blaze"],F,de=(F=class extends Error{constructor(e){super(`no detector tier available (${e})`),this.name="DetectorLadderError",this.fallbackReason=e}},o(F,"x"),F);function te(i){let e=i;if(typeof e.videoWidth=="number"&&e.videoWidth>0)return{width:e.videoWidth,height:e.videoHeight??0};if(typeof e.naturalWidth=="number"&&e.naturalWidth>0)return{width:e.naturalWidth,height:e.naturalHeight??0};let t=typeof e.width=="number"?e.width:0,r=typeof e.height=="number"?e.height:0;return{width:t,height:r}}o(te,"y");function et(i,e,t,r){let s=te(e),a=s.width>0?t/s.width:1,n=s.height>0?r/s.height:1,l=o(c=>({x:c.x*a,y:c.y*n}),"s");return{box:{x:i.box.x*a,y:i.box.y*n,width:i.box.width*a,height:i.box.height*n},...i.eyes!==void 0?{eyes:{left:l(i.eyes.left),right:l(i.eyes.right)}}:{},...i.nose!==void 0?{nose:l(i.nose)}:{},score:i.score,...i.extraFaces!==void 0?{extraFaces:i.extraFaces}:{}}}o(et,"h");function Nt(i){return i instanceof Error?i.message:String(i)}o(Nt,"C");async function x(i){let e=i.preferred??Ft,t=[];for(let r of e){if(r==="native"){let s=await Ot();if(s.ok)return new Pt(s.instance,he(t));t.push(`native:${s.reason}`);continue}try{return await Lt(It.create(i.v3AssetBaseUrl??ue,he(t)),i.blazeInitTimeoutMs??At)}catch(s){t.push(s instanceof tt?"blaze:blaze_init_timeout":`blaze:${Nt(s)}`)}}throw new de(he(t)??"no_tier_available")}o(x,"O");function he(i){return i.length>0?i.join("; "):void 0}o(he,"v");var N,tt=(N=class extends Error{},o(N,"g"),N);function Lt(i,e){return new Promise((t,r)=>{let s=setTimeout(()=>{r(new tt(`init exceeded ${e}ms`)),i.then(a=>a.destroy(),()=>{})},e);i.then(a=>{clearTimeout(s),t(a)},a=>{clearTimeout(s),r(a)})})}o(Lt,"W");var C=1;function it(){return typeof OffscreenCanvas=="function"&&typeof createImageBitmap=="function"&&typeof Worker=="function"}o(it,"K");function Bt(i,e={}){let t=e.createDetector??x,r=null;i.onmessage=s=>{let a=s.data;if(a.v!==C){a.bitmap?.close?.();return}if(a.type==="init"){t(a.options).then(n=>{r=n;let l={v:C,type:"ready",tier:n.tier,...n.fallbackReason!==void 0?{fallbackReason:n.fallbackReason}:{}};i.postMessage(l)});return}if(a.type==="detect"){let n=o(l=>{let c={v:C,type:"result",id:a.id,observation:l};i.postMessage(c),a.bitmap.close?.()},"a");if(r===null){n(null);return}r.detect(a.bitmap,a.streamWidth,a.streamHeight).then(n,()=>n(null))}}}o(Bt,"B");typeof self<"u"&&typeof self.importScripts=="function"&&Bt(self);var P,rt=(P=class{constructor(e,t){this.pending=new Map,this.nextId=1,this.worker=e,this.tier=t.tier,t.fallbackReason!==void 0&&(this.fallbackReason=t.fallbackReason),e.addEventListener("message",r=>{let s=r.data;if(s.v!==C||s.type!=="result")return;let a=this.pending.get(s.id);this.pending.delete(s.id),a?.(s.observation)})}static create(e,t,r=1e4){return new Promise((s,a)=>{let n=setTimeout(()=>{e.removeEventListener("message",l),e.terminate(),a(new Error(`worker detector not ready within ${r}ms`))},r),l=o(h=>{let d=h.data;d.v!==C||d.type!=="ready"||(clearTimeout(n),e.removeEventListener("message",l),s(new P(e,d)))},"s");e.addEventListener("message",l);let c={v:C,type:"init",options:t};e.postMessage(c)})}async detect(e,t,r){let s;try{typeof ImageBitmap<"u"&&e instanceof ImageBitmap?s=e:typeof createImageBitmap=="function"?s=await createImageBitmap(e):s=e}catch{return null}let a=this.nextId;return this.nextId+=1,new Promise(n=>{this.pending.set(a,n);let l={v:C,type:"detect",id:a,bitmap:s,streamWidth:t,streamHeight:r};this.worker.postMessage(l,[s])})}destroy(){for(let e of this.pending.values())e(null);this.pending.clear(),this.worker.terminate()}},o(P,"t"),P);var qt=[...Ue.filter(i=>i.startsWith("video/mp4")),"video/webm;codecs=h264","video/webm;codecs=avc1","video/webm;codecs=vp8","video/webm;codecs=vp9","video/webm"],dt=new Set;function Wt(i){let e=/(?:Chrome|Chromium)\/(\d+)\./.exec(i??"");return e?Number(e[1]):null}o(Wt,"Pe");function zt(i=Kt(),e=globalThis.navigator?.userAgent){if(i===void 0)return"";let t=Wt(e)===126;for(let r of qt)if(!(dt.has(r)||t&&r.startsWith("video/mp4")))try{if(i(r))return r}catch{}return""}o(zt,"be");function st(i){i!==""&&dt.add(i)}o(st,"L");function Ht(i){return i.replace(/^video\/x-matroska/i,"video/webm")}o(Ht,"ye");function ft(i){let e=/codecs=["']?([^,;"']+)/i.exec(i);return e?e[1].trim():i.split(";")[0].trim()}o(ft,"lt");function Kt(){let i=globalThis.MediaRecorder;return i&&typeof i.isTypeSupported=="function"?e=>i.isTypeSupported(e):void 0}o(Kt,"xe");var pt=2500,Xt=1e3,Zt=1500,at=25e5,Vt=100,jt=700,$t=20,Yt=1500,ie=null;function Qt(){return ie??(ie=import("./clip-inspect-DLJXVKV6-TNHTD4LV.js").catch(i=>{throw ie=null,i})),ie.catch(()=>null)}o(Qt,"He");var B,D=(B=class extends Error{constructor(e,t){super(t??e),this.kind=e}},o(B,"T"),B),Jt=100;function nt(i,e){return i.stats===void 0?!1:i.stats===null?!0:i.stats.durationMs<e-Jt}o(nt,"N");function ei(i,e){return i.stats?e.stats?i.stats.durationMs>e.stats.durationMs:!0:!1}o(ei,"Ee");var q,ti=(q=class{constructor(e={}){this.recorder=null,this.stream=null,this.chunks=[],this.bytes=0,this.hardStopTimer=null,this.graceTimer=null,this.pollTimer=null,this.settled=!1,this.now=e.now??(()=>globalThis.performance?.now?.()??Date.now())}clearTimers(){this.hardStopTimer&&clearTimeout(this.hardStopTimer),this.graceTimer&&clearTimeout(this.graceTimer),this.pollTimer&&clearInterval(this.pollTimer),this.hardStopTimer=null,this.graceTimer=null,this.pollTimer=null}record(e,t,r,s=pt,a){let n=zt(),l=Qt();return this.recordRaw(e,t,r,s,a,n).then(c=>ii(c,l),c=>{throw c instanceof D&&(c.requestedMimeType=n),c})}recordRaw(e,t,r,s,a,n){return this.recorder&&!this.settled?Promise.reject(new D("generic","record() called while a recording is in flight — ClipRecorder handles one recording at a time")):(this.recorder=null,this.clearTimers(),this.chunks=[],this.bytes=0,this.settled=!1,this.stream=e,new Promise((l,c)=>{let h;try{h=new MediaRecorder(e,n?{mimeType:n,videoBitsPerSecond:at}:{videoBitsPerSecond:at})}catch{try{h=new MediaRecorder(e)}catch{c(new D("unsupported"));return}}this.recorder=h;let d=o(g=>{this.settled||(this.settled=!0,this.clearTimers(),g())},"d"),u=o(()=>d(()=>{let g=Ht(h.mimeType||n||Fe),M=new Blob(this.chunks,{type:g});if(M.size===0){c(new D("generic","empty clip"));return}if(oe(M)){c(new D("cliptoolarge"));return}l({blob:M,mimeType:g,requestedMimeType:n})}),"u");h.ondataavailable=g=>{g.data&&g.data.size&&(this.chunks.push(g.data),this.bytes+=g.data.size,this.bytes>Be&&d(()=>{try{h.state!=="inactive"&&h.stop()}catch{}c(new D("cliptoolarge"))}))},h.onstop=u,h.onerror=()=>d(()=>c(new D("generic")));let m=this.now();if(r!==void 0||a!==void 0){let g=!1;h.onstart=()=>{if(!(g||this.settled)&&(g=!0,m=this.now(),r!==void 0))try{r()}catch{}}}try{h.start(Xt)}catch{d(()=>c(new D("generic")));return}let w=o(()=>{if(this.pollTimer&&clearInterval(this.pollTimer),this.pollTimer=null,this.hardStopTimer&&clearTimeout(this.hardStopTimer),this.hardStopTimer=null,this.settled||t?.(),h.state!=="inactive"){try{h.stop()}catch{u()}this.graceTimer=setTimeout(u,Zt)}else u()},"m"),p=this.now();if(a===void 0){this.hardStopTimer=setTimeout(w,s);return}let v=null,y=!1;this.hardStopTimer=setTimeout(w,s+jt),this.pollTimer=setInterval(()=>{if(this.settled||y)return;let g=null;try{g=a.latest()}catch{g=null}let M=g?.presentationTimeMs;M!==void 0&&Number.isFinite(M)&&M>=m&&v===null&&(v=M);let E=v!==null&&M!==void 0&&M-v>=s,A=v===null&&this.now()-p>=s;if(!(!E&&!A)){if(y=!0,this.pollTimer&&clearInterval(this.pollTimer),this.pollTimer=null,A){w();return}this.hardStopTimer&&clearTimeout(this.hardStopTimer),this.hardStopTimer=setTimeout(w,Vt)}},$t)}))}stop(e){this.clearTimers();let t=this.recorder;if(t&&t.state!=="inactive")try{t.stop()}catch{}this.recorder=null,(e??this.stream)?.getTracks().forEach(r=>r.stop()),this.stream=null}},o(q,"A"),q);async function ii(i,e){let t,r=new Promise(h=>{t=setTimeout(()=>h(null),Yt)}),s=await Promise.race([e,r]);if(clearTimeout(t),s===null)return i;let a;try{a=await s.blobBytes(i.blob)}catch{return{...i,stats:null}}let n=s.inspectClipBytes(a);if(n?.container!=="webm")return{...i,stats:n};let l=s.withWebmDuration(a,n.durationMs);if(l===null)return{...i,stats:n};let c=s.inspectClipBytes(l);return c===null||c.frames!==n.frames||c.durationMs!==n.durationMs?{...i,stats:n}:{...i,blob:new Blob([l],{type:i.blob.type}),stats:n}}o(ii,"Be");function ri(i,e,t=.92){return new Promise((r,s)=>{let a=i.videoWidth,n=i.videoHeight;if(!a||!n){s(new Error("video-not-ready"));return}let l=e.getContext("2d");if(!l){s(new Error("no-2d-context"));return}e.width=a,e.height=n,l.scale(-1,1),l.drawImage(i,-a,0),e.toBlob(c=>c?r(c):s(new Error("empty-keyframe")),"image/jpeg",t)})}o(ri,"Me");var W,si=(W=class{constructor(e){this.timer=null,this.frameCallbackId=null,this.running=!1,this.busy=!1,this.lastRunAt=Number.NEGATIVE_INFINITY,this.degradeCount=0,this.durations=[],this.options=e,this.periodMs=1e3/e.cadenceHz}start(){if(this.running)return;this.running=!0;let e=this.options.video;if(typeof e?.requestVideoFrameCallback=="function"){let t=o(()=>{this.running&&(this.frameCallbackId=e.requestVideoFrameCallback?.(()=>{this.frameCallbackId=null,this.now()-this.lastRunAt>=this.periodMs&&this.tick(),t()}))},"t");t();return}this.timer=setInterval(()=>this.tick(),this.periodMs)}stop(){this.running=!1,this.timer!==null&&(clearInterval(this.timer),this.timer=null),this.frameCallbackId!==null&&(this.options.video?.cancelVideoFrameCallback?.(this.frameCallbackId),this.frameCallbackId=null)}stats(){let e=this.durations.length===0?0:this.durations.reduce((t,r)=>t+r,0)/this.durations.length;return{degradeCount:this.degradeCount,meanDetectMs:e}}now(){return this.options.now?.()??performance.now()}tick(){if(!this.running)return;if(this.busy){this.degradeCount+=1;return}this.busy=!0,this.lastRunAt=this.now();let e=this.now();this.options.run().catch(()=>{}).finally(()=>{this.busy=!1,this.durations.push(this.now()-e),this.durations.length>20&&this.durations.shift()})}},o(W,"D"),W),ai=Object.freeze({Q_GOOD:.6,RISE_PER_S:.9,FALL_PER_S:.25,CENTER_FALLOFF_IOD_MULTIPLE:1.35,BOX_EYE_OFFSET_FACTOR:.12,IOD_BOX_PROXY_FACTOR:.42,SIZE_IDEAL_MIN:.12,SIZE_IDEAL_MAX:.3,SIZE_HARD_MIN:.08,SIZE_HARD_MAX:.45,ROLL_MAX_DEG:25,MOTION_VELOCITY_IOD_PER_S:.5,MOTION_TAU_S:.4,MOTION_DEADBAND_IOD_PER_S:.1,READY_WINDOW_MS:500,GUIDE_SIZE:.6,GUIDE_CENTERING:.6,GUIDE_POSE:.6,GUIDE_EXPOSURE:.6,GUIDE_SHARPNESS:.35,GUIDE_MOTION:.5}),L=o(i=>Math.min(1,Math.max(0,i)),"C"),z,ot=(z=class{constructor(e={}){this.p=0,this.lastTickAt=null,this.lastCenter=null,this.velocityEma=0,this.qWindow=[],this.lastSizeDirection="ideal",this.t={...ai,...e}}reset(){this.p=0,this.lastTickAt=null,this.lastCenter=null,this.velocityEma=0,this.qWindow=[],this.lastSizeDirection="ideal"}tick(e){let{observation:t,quality:r,timestampMs:s}=e,a=this.lastTickAt===null?0:Math.max(0,(s-this.lastTickAt)/1e3);this.lastTickAt=s;let n={presence:0,single:1,centering:0,size:0,pose:0,sharpness:L(r.sharpness),exposure:L(r.exposure),motion:1};if(t!==null){n.presence=1,n.single=(t.extraFaces??0)>0?0:1;let d=this.geometryOf(t,e);n.centering=d.centering,n.size=d.size,n.pose=d.pose,n.motion=this.motionOf(d.center,d.iod,s)}else this.lastCenter=null,this.velocityEma=0;let l=Math.min(n.presence,n.single,n.centering,n.size,n.pose,n.sharpness,n.exposure,n.motion);this.p=L(this.p+(l>=this.t.Q_GOOD?this.t.RISE_PER_S*l:-this.t.FALL_PER_S*(1-l))*a),this.qWindow.push({at:s,q:l}),this.qWindow=this.qWindow.filter(d=>d.at>=s-this.t.READY_WINDOW_MS);let c=this.qWindow.map(d=>d.q);if(c.length>=3){let d=Math.min(...c),u=c.indexOf(d);c=c.filter((m,w)=>w!==u)}let h=this.p>=1&&c.every(d=>d>=this.t.Q_GOOD);return{at:s,q:l,p:this.p,factors:n,guidanceKey:this.guidanceOf(n,r,l),ready:h,accepted:l>=this.t.Q_GOOD}}geometryOf(e,t){let{box:r,eyes:s}=e,a={x:t.frameWidth/2,y:t.frameHeight/2},n=Math.min(t.frameWidth,t.frameHeight),l=s!==void 0?{x:(s.left.x+s.right.x)/2,y:(s.left.y+s.right.y)/2}:{x:r.x+r.width/2,y:r.y+r.height/2-this.t.BOX_EYE_OFFSET_FACTOR*r.height},c=s!==void 0?Math.hypot(s.right.x-s.left.x,s.right.y-s.left.y):this.t.IOD_BOX_PROXY_FACTOR*r.width,h=Math.hypot(l.x-a.x,l.y-a.y),d=c<=0?0:1-L(h/(this.t.CENTER_FALLOFF_IOD_MULTIPLE*c)),u=n>0?c/n:0;this.lastSizeDirection=u<this.t.SIZE_IDEAL_MIN?"far":u>this.t.SIZE_IDEAL_MAX?"close":"ideal";let m;u<this.t.SIZE_HARD_MIN||u>this.t.SIZE_HARD_MAX?m=0:u<this.t.SIZE_IDEAL_MIN?m=(u-this.t.SIZE_HARD_MIN)/(this.t.SIZE_IDEAL_MIN-this.t.SIZE_HARD_MIN):u>this.t.SIZE_IDEAL_MAX?m=(this.t.SIZE_HARD_MAX-u)/(this.t.SIZE_HARD_MAX-this.t.SIZE_IDEAL_MAX):m=1;let w=1;if(s!==void 0){let p=Math.abs(Math.atan2(s.right.y-s.left.y,s.right.x-s.left.x))*180/Math.PI;w=1-L(p/this.t.ROLL_MAX_DEG)}return{center:l,iod:c,centering:d,size:m,pose:w}}motionOf(e,t,r){let s=this.lastCenter;if(this.lastCenter={...e,at:r},s===null||t<=0)return 1;let a=(r-s.at)/1e3;if(a<=0)return 1;let n=Math.hypot(e.x-s.x,e.y-s.y)/t/a;n<=this.t.MOTION_DEADBAND_IOD_PER_S&&(n=0);let l=1-Math.exp(-a/this.t.MOTION_TAU_S);return this.velocityEma=l*n+(1-l)*this.velocityEma,1-L(this.velocityEma/this.t.MOTION_VELOCITY_IOD_PER_S)}guidanceOf(e,t,r){if(e.presence<=0)return"fcv3.no_face";if(e.single<=0)return"fcv3.one_face";if(e.size<this.t.GUIDE_SIZE)return this.sizeGuidance();if(e.centering<this.t.GUIDE_CENTERING)return"fcv3.center_face";if(e.pose<this.t.GUIDE_POSE)return"fcv3.straighten";if(e.exposure<this.t.GUIDE_EXPOSURE)return this.exposureGuidance(t);if(e.sharpness<this.t.GUIDE_SHARPNESS)return"fcv3.steady_camera";if(e.motion<this.t.GUIDE_MOTION)return"fcv3.hold_still";if(r<this.t.Q_GOOD){let s=[["size",this.sizeGuidance()],["centering","fcv3.center_face"],["pose","fcv3.straighten"],["exposure",this.exposureGuidance(t)],["sharpness","fcv3.steady_camera"],["motion","fcv3.hold_still"]],a=s[0];for(let n of s)e[n[0]]<e[a[0]]&&(a=n);return a[1]}return"fcv3.hold_still"}sizeGuidance(){return this.lastSizeDirection==="far"?"fcv3.come_closer":"fcv3.move_back"}exposureGuidance(e){let t=(le[0]+le[1])/2;return e.meanLuma<t?"fcv3.more_light":"fcv3.too_bright"}},o(z,"_"),z),ni=["single","size","centering","pose","exposure","sharpness","motion"];function oi(i){if(i.accepted)return null;if(i.factors.presence<=0)return"no_face";let e="single";for(let t of ni)i.factors[t]<i.factors[e]&&(e=t);return e}o(oi,"ze");var H,lt=(H=class{constructor(){this.blocked={},this.acceptedMs=0,this.ticks=0,this.lastAt=null}record(e){let t=this.lastAt===null?0:Math.max(0,e.at-this.lastAt);this.lastAt=e.at,this.ticks+=1;let r=oi(e);if(r===null){this.acceptedMs+=t;return}let s=this.blocked[r]??{count:0,ms:0};s.count+=1,s.ms+=t,this.blocked[r]=s}summary(){let e={};for(let[t,r]of Object.entries(this.blocked))e[t]={count:r.count,ms:Math.round(r.ms)};return{blocked:e,acceptedMs:Math.round(this.acceptedMs),ticks:this.ticks}}},o(H,"w"),H),li=["obs","manycam","virtual","snap camera","xsplit","droidcam","iriun","camo","fake_device","fake-capture-device"],ci=[/^(front|back|rear)( [a-z ]+)? camera$/i,/^caméra (avant|arrière)\b/i,/^cámara (frontal|trasera|delantera)\b/i,/^câmera (frontal|traseira)\b/i,/^(front|rück)kamera\b/i,/^الكاميرا (الأمامية|الخلفية)/,/^camera2? ?\d+, facing (front|back|external)/i,/facetime/i,/\b(integrated|built-in|builtin) (web)?cam(era)?\b/i,/\b(hd )?web ?cam\b/i,/\([0-9a-f]{4}:[0-9a-f]{4}\)\s*$/i];function hi(i){let e=(i??"").trim().toLowerCase();return e.length===0?"unknown":li.some(t=>e.includes(t))?"known_virtual":ci.some(t=>t.test(e))?"platform":"unknown"}o(hi,"Qe");function ct(i){if(typeof i!="function")return!1;try{return/\{\s*\[native code\]\s*\}\s*$/.test(Function.prototype.toString.call(i))}catch{return!1}}o(ct,"Ce");function ui(i=globalThis){return ct(i.navigator?.mediaDevices?.getUserMedia)&&ct(i.MediaStreamTrack?.prototype?.getSettings)}o(ui,"Ye");async function di(i,e=globalThis){let t=e.crypto?.subtle?.digest;if(typeof t=="function")try{let r=new Uint8Array(await t.call(e.crypto?.subtle,"SHA-256",new TextEncoder().encode(i)));return Array.from(r.subarray(0,8),s=>s.toString(16).padStart(2,"0")).join("")}catch{return}}o(di,"je");async function fi(i,e=globalThis){let t={};try{t=typeof i.getSettings=="function"?i.getSettings()??{}:{}}catch{t={}}let r={};if((t.facingMode==="user"||t.facingMode==="environment"||t.facingMode==="left"||t.facingMode==="right")&&(r.facingMode=t.facingMode),typeof t.frameRate=="number"&&Number.isFinite(t.frameRate)&&(r.frameRate=t.frameRate),typeof t.width=="number"&&Number.isFinite(t.width)&&(r.width=t.width),typeof t.height=="number"&&Number.isFinite(t.height)&&(r.height=t.height),typeof t.deviceId=="string"&&t.deviceId.length>0){let a=await di(t.deviceId,e);a!==void 0&&(r.deviceIdHash=a)}let s;try{s=i.label}catch{s=void 0}return{trackSettings:r,capabilitiesPresent:typeof i.getCapabilities=="function",labelClass:hi(s),prototypesIntact:ui(e)}}o(fi,"Se");var fe=o(i=>Math.round(i*100)/100,"U");function pi(i){let e=i,t=typeof e?.requestVideoFrameCallback=="function",r=null,s=null,a=0,n=0,l=0,c=0,h=0,d=0,u=o(()=>{!t||e?.requestVideoFrameCallback===void 0||(r=e.requestVideoFrameCallback((m,w)=>{if(r=null,!t)return;let p=w.presentationTime;if(s!==null){let v=p-s.presentationTimeMs;n+=1;let y=v-l;l+=y/n,c+=y*(v-l)}typeof w.captureTime=="number"&&Number.isFinite(w.captureTime)&&(h+=p-w.captureTime,d+=1),a+=1,s={mediaTimeMs:w.mediaTime*1e3,presentationTimeMs:p},u()}))},"u");return u(),{latest:o(()=>s,"latest"),stats:o(()=>({n:a,meanGapMs:n===0?0:fe(l),stdGapMs:n<2?0:fe(Math.sqrt(c/(n-1))),captureLatencyMs:d===0?null:fe(h/d)}),"stats"),stop:o(()=>{t&&(t=!1,r!==null&&e?.cancelVideoFrameCallback?.(r),r=null)},"stop")}}o(pi,"ke");function mi(i,e,t){return{...i,rvfc:e,rampPainter:t}}o(mi,"_e");var gi=1e3,pe="fcv3.hold_upright",vi=200,me=4,yi=600,wi=1e3,ht={sharpness:1,exposure:1,meanLuma:128};function bi(i,e){return e.width=i.videoWidth,e.height=i.videoHeight,e.getContext("2d").drawImage(i,0,0),new Promise((t,r)=>e.toBlob(s=>s?t(s):r(new Error("empty-keyframe")),"image/jpeg",.92))}o(bi,"rt");function Mi(){return Q()==="phone"}o(Mi,"it");var K,mt=(K=class{constructor(e){this.handlers=new Map,this.stateValue="idle",this.attempt=0,this.stream=null,this.detector=null,this.scheduler=null,this.gate=null,this.profiler=null,this.lastGuidanceKey=null,this.positioningStartedAt=0,this.cameraRequestedAt=null,this.cameraReadyAt=null,this.faceAcquiredAt=null,this.captureCompleteAt=null,this.fired=!1,this.carriedDegrade=0,this.carriedMeans=[],this.blockStats=null,this.lastGateSnapshotAt=Number.NEGATIVE_INFINITY,this.uprightGuard=!1,this.trackProvenance=null,this.openEnvironment=null,this.ramp=null,this.snapshotCanvas=null,this.options=e,this.facing=e.facingMode??"user"}get state(){return this.stateValue}on(e,t){let r=this.handlers.get(e);return r||(r=new Set,this.handlers.set(e,r)),r.add(t),()=>r?.delete(t)}emit(e,t){for(let r of[...this.handlers.get(e)??[]])r(t)}async start(e={}){e.facingMode!==void 0&&(this.facing=e.facingMode),this.attempt+=1,await this.run(this.attempt)}get facingMode(){return this.facing}retry(){this.teardownAttempt(),this.start()}switchCamera(){this.facing=this.facing==="user"?"environment":"user",this.teardownAttempt(),this.start()}restart(e){this.facing=e,this.teardownAttempt(),this.start()}destroy(){this.attempt+=1,this.teardownAttempt(),this.detector?.destroy(),this.detector=null,this.options.video.srcObject=null}async run(e){let{options:t}=this;this.fired=!1,this.lastGuidanceKey=null,this.carriedDegrade=0,this.carriedMeans=[],this.cameraRequestedAt=null,this.cameraReadyAt=null,this.faceAcquiredAt=null,this.captureCompleteAt=null,this.uprightGuard=(t.isPhone??Mi)(),this.setState("preflight");let r=Ne();if(r!=="OK"){this.fail(r==="INSECURE_CONTEXT"?"insecure":"unsupported",{phase:"preflight"});return}this.setState("acquiring");let s=t.getUserMedia??(h=>navigator.mediaDevices.getUserMedia(h)),a;this.cameraRequestedAt=this.now();try{let{facingMode:h,...d}=Se(Ae(),this.facing).video;a=await Ke(this.facing,d,{getUserMedia:s,enumerateDevices:_i(t)})}catch(h){if(e!==this.attempt)return;if(h instanceof He){this.fail("backcamera",{phase:"acquiring",name:j(h)});return}this.fail(We(h),{phase:"acquiring",name:j(h)});return}if(Re(a),ze(a),e!==this.attempt){for(let h of a.getTracks())h.stop();return}this.stream=a;let n=a.getVideoTracks?.()[0];if(this.trackProvenance=n===void 0?null:fi(n).catch(()=>null),this.openEnvironment=n===void 0?null:xe(n).catch(()=>({})),this.facing=Ie(a)??this.facing,t.video.srcObject=a,await t.video.play().catch(()=>{}),e!==this.attempt)return;if(this.cameraReadyAt=this.now(),this.detector===null){let h={v3AssetBaseUrl:t.v3AssetBaseUrl},d=t.createDetector??(t.createWorker!==void 0&&it()?async()=>{try{return await rt.create(t.createWorker(),h)}catch{return x(h)}}:()=>x(h)),u;try{u=await d()}catch(m){e===this.attempt&&this.fail("models",{phase:"models",name:j(m)},m instanceof de?m.fallbackReason:Ti(m));return}if(e!==this.attempt){u.destroy();return}this.detector=u,this.options.telemetry?.({type:"detector",tier:u.tier,fallbackReason:u.fallbackReason})}let l=Xe(),c=t.deviceClass??Ze(l);this.profiler=new Ve(c),this.options.telemetry?.({type:"profile",staticClass:c,activeClass:this.profiler.deviceClass,simd:l.simd}),this.gate=new ot(t.thresholds??{}),this.blockStats=new lt,this.lastGateSnapshotAt=this.now(),t.rankKeyframes?.()&&import("./keyframe-rank-YAJLYJYF-WCA6RPMD.js").then(h=>ge=h,()=>{}),this.setState("positioning"),this.positioningStartedAt=this.now(),this.startScheduler(e)}get animations(){return this.profiler?.profile.animations??"full"}startScheduler(e){let t=this.profiler;if(t===null)return;if(this.scheduler!==null){let s=this.scheduler.stats();this.carriedDegrade+=s.degradeCount,s.meanDetectMs>0&&this.carriedMeans.push(s.meanDetectMs),this.scheduler.stop()}let r=new si({cadenceHz:t.profile.cadenceHz,video:this.options.video,now:this.options.now,run:o(()=>this.detectTick(e),"run")});this.scheduler=r,r.start()}async detectTick(e){let{detector:t,gate:r,profiler:s}=this,a=this.options.video;if(e!==this.attempt||t===null||r===null||s===null||this.fired||a.videoWidth===0)return;if(this.isLandscape()){this.holdUpright(e);return}let n=s.deviceClass,l=this.now(),c=this.options.makeSnapshot?.(a,s.profile.inputWidth)??this.defaultSnapshot(a,s.profile.inputWidth),h=null;try{h=await t.detect(c,a.videoWidth,a.videoHeight)}catch{h=null}if(e!==this.attempt||this.fired)return;s.record(this.now()-l),s.deviceClass!==n&&this.startScheduler(e);let d=h===null?ht:this.options.measureQuality?.(a,h.box)??this.defaultQuality(a,h.box),u=r.tick({timestampMs:this.now(),observation:h,quality:d,frameWidth:a.videoWidth,frameHeight:a.videoHeight});u.accepted&&this.faceAcquiredAt===null&&(this.faceAcquiredAt=u.at),this.blockStats?.record(u),!u.ready&&u.at-this.lastGateSnapshotAt>=gi&&(this.lastGateSnapshotAt=u.at,this.reportGate(!1)),this.emit("checks",{engine:"v3",progress:u.p,q:u.q,factors:u.factors,attempt:e}),u.guidanceKey!==this.lastGuidanceKey&&(this.lastGuidanceKey=u.guidanceKey,this.emit("guidance",{key:u.guidanceKey})),u.ready&&this.stateValue==="positioning"&&(this.fired=!0,this.captureCompleteAt=u.at,this.fire(e))}async fire(e){let{options:t}=this,r=this.scheduler;r?.stop(),this.reportGate(!0);let s=r?.stats()??{degradeCount:0,meanDetectMs:0},a=[...this.carriedMeans,...s.meanDetectMs>0?[s.meanDetectMs]:[]];t.telemetry?.({type:"fired",timeToGateMs:this.now()-this.positioningStartedAt,degradeCount:this.carriedDegrade+s.degradeCount,meanDetectMs:a.length===0?0:a.reduce((_,b)=>_+b,0)/a.length});let n=t.mode??"clip",l=t.rankKeyframes?.()&&ge?ge.default(this,e).catch(()=>this.collectKeyframes(e)):this.collectKeyframes(e);if(n==="photo"){let _=this.watchRotation(e,null),b=await l;if(_(),e!==this.attempt)return;if(b===null){this.fail("generic",{phase:"keyframes"});return}let R=await this.provenance({n:0,meanGapMs:0,stdGapMs:0,captureLatencyMs:null},!1);if(e!==this.attempt)return;this.finishCapture({keyframe:b.blob,previewDataUrl:b.previewDataUrl,...R});return}this.setState("recording");let c=this.stream;if(c===null){this.fail("generic",{phase:"recording"});return}let h=t.screenRamp?.(),d=ee(h),u=null;l.then(_=>{u=_},()=>{});let m=o(()=>{e===this.attempt&&u!==null&&this.emit("frozen",{previewDataUrl:u.previewDataUrl})},"p"),w=Ye(h,pt),p=null,v,y=0;try{let _=this.recordTake(e,c,h,w,void 0).then(S=>S,S=>({failed:S})),[b,R]=await Promise.all([_,l]);if(v=R,e!==this.attempt)return;if("failed"in b){if(b.failed.kind==="cliptoolarge")throw b.failed;st(b.failed.requestedMimeType??"")}else p=b,nt(b.clip,w)?b.clip.stats===null&&st(b.clip.requestedMimeType??""):m();if(p===null||nt(p.clip,w)){y=1,t.telemetry?.({type:"clip_retake",reason:p===null?"error":p.clip.stats===null?"unreadable":"short"});let S=null;try{S=await this.recordTake(e,c,h,w,m)}catch($){if(p===null)throw $}if(e!==this.attempt)return;S!==null&&(p===null||ei(S.clip,p.clip))&&(p=S),S===null&&m()}}catch(_){if(e!==this.attempt)return;let b=_.kind;this.fail(b==="cliptoolarge"?"cliptoolarge":"recorder",{phase:"recording",name:j(_)});return}if(p===null){this.fail("recorder",{phase:"recording"});return}let{clip:g,rvfc:M,report:E,watched:A}=p;if(oe(g.blob)){this.fail("cliptoolarge",{phase:"recording"});return}if(v===null){this.fail("generic",{phase:"keyframes"});return}let I=await this.provenance(M,d,A);e===this.attempt&&this.finishCapture({clip:g.blob,clipMimeType:g.mimeType,...g.stats?{clipStats:g.stats}:{},clipRetakes:y,keyframe:v.blob,previewDataUrl:v.previewDataUrl,...E!==void 0&&E.rendered.length>0?{screenRamp:E}:{},...I})}async recordTake(e,t,r,s,a){let n=this.options.createRecorder?.()??new ti({now:o(()=>this.now(),"now")}),l=pi(this.options.video),c=Qe(r,{paint:o(m=>{(m===null||e===this.attempt)&&this.emit("ramp",{colour:m})},"paint"),now:o(()=>this.now(),"now"),frames:l.latest});this.ramp=c;let h=o(()=>{l.stop(),c.stop(),this.ramp===c&&(this.ramp=null)},"l"),d=this.watchRotation(e,n),u=De();try{return{clip:await n.record(t,a,()=>c.started(this.now()),s,l),rvfc:l.stats(),report:c.report(),watched:u.stop()}}finally{u.stop(),d(),h()}}async provenance(e,t,r={}){let s=this.trackProvenance;if(s===null)return{};let a,n=new Promise(d=>{a=setTimeout(()=>d(null),wi)}),l=await Promise.race([s,n]),c=l===null?null:await Promise.race([this.openEnvironment,n]);if(clearTimeout(a),l===null)return{};let h={...c,...r};return{provenance:{...mi(l,e,t),...Object.keys(h).length>0?{env:h}:{}}}}isLandscape(){let e=this.options.video;return this.uprightGuard&&e.videoWidth>e.videoHeight}holdUpright(e){this.gate?.reset(),this.emit("checks",{engine:"v3",progress:0,q:0,factors:{presence:0,single:1,centering:0,size:0,pose:0,sharpness:0,exposure:0,motion:0},attempt:e}),this.lastGuidanceKey!==pe&&(this.lastGuidanceKey=pe,this.emit("guidance",{key:pe}))}watchRotation(e,t){if(!this.uprightGuard)return()=>{};let r=this.options.video,s=o(()=>{if(e!==this.attempt||t!==null&&this.stateValue!=="recording"){l();return}r.videoWidth>0&&this.isLandscape()&&(l(),this.abortRecording(e,t))},"i"),a=setInterval(s,vi);r.addEventListener?.("resize",s);let n=!1;function l(){n||(n=!0,clearInterval(a),r.removeEventListener?.("resize",s))}return o(l,"o"),l}abortRecording(e,t){if(e!==this.attempt)return;this.attempt+=1;let r=this.attempt;try{t?.stop()}catch{}this.ramp?.stop(),this.ramp=null,this.fired=!1,this.captureCompleteAt=null,this.gate=new ot(this.options.thresholds??{}),this.blockStats=new lt,this.lastGateSnapshotAt=this.now(),this.lastGuidanceKey=null,this.setState("positioning"),this.positioningStartedAt=this.now(),this.holdUpright(r),this.startScheduler(r)}async collectKeyframes(e){let t=this.options.captureKeyframe??(a=>this.defaultKeyframe(a)),r=yi/(me-1),s=null;for(let a=0;a<me;a+=1){if(e!==this.attempt)return s;try{let n=await t(this.options.video);(s===null||n.sharpness>s.sharpness)&&(s=n)}catch{}a<me-1&&await ki(r)}return s}finishCapture(e){this.stopTracks(),this.setState("captured");let t=this.captureTiming();this.emit("artifacts",t===void 0?e:{...e,timing:t})}captureTiming(){let e={},t=o((r,s,a)=>{s!==null&&a!==null&&(e[r]=Math.max(0,Math.round(a-s)))},"t");return t("cameraReadyMs",this.cameraRequestedAt,this.cameraReadyAt),t("faceAcquireMs",this.cameraReadyAt,this.faceAcquiredAt),t("captureMs",this.faceAcquiredAt,this.captureCompleteAt),Object.keys(e).length>0?e:void 0}async defaultKeyframe(e){let t=document.createElement("canvas"),r=await(this.facing==="user"?ri:bi)(e,t),s=t.toDataURL("image/jpeg",.92);return{blob:r,previewDataUrl:s,sharpness:this.centerSharpness(e)}}defaultSnapshot(e,t){try{let r=this.snapshotCanvas??document.createElement("canvas"),s=t/Math.max(1,e.videoWidth),a=Math.max(1,Math.round(e.videoWidth*s)),n=Math.max(1,Math.round(e.videoHeight*s)),l=r.getContext("2d");return l===null?e:(r.width!==a&&(r.width=a),r.height!==n&&(r.height=n),l.drawImage(e,0,0,a,n),this.snapshotCanvas=r,r)}catch{return e}}defaultQuality(e,t){let r=ut(e,t,96);return r===null?ht:{sharpness:ce(r),exposure:$e(r),meanLuma:je(r)}}centerSharpness(e){let t=te(e),r=ut(e,{x:t.width*.25,y:t.height*.25,width:t.width*.5,height:t.height*.5},96);return r===null?0:ce(r)}teardownAttempt(){this.scheduler?.stop(),this.scheduler=null,this.reportGate(!0),this.gate=null,this.ramp?.stop(),this.ramp=null,this.stopTracks()}reportGate(e){let t=this.blockStats,r=this.profiler;if(t===null||r===null)return;let s=t.summary();e&&(this.blockStats=null),s.ticks!==0&&this.options.telemetry?.({type:"gate",final:e,activeClass:r.deviceClass,cadenceHz:r.profile.cadenceHz,...s})}stopTracks(){if(this.stream!==null){for(let e of this.stream.getTracks())e.stop();this.stream=null}}fail(e,t,r){this.scheduler?.stop(),this.reportGate(!0),this.stopTracks(),this.setState("error"),this.options.telemetry?.({type:"error",kind:e,fallbackReason:r});let{phase:s,name:a}=t;this.emit("error",{kind:e,retryable:e!=="insecure"&&e!=="unsupported",detail:a===void 0?{phase:s}:{phase:s,name:a}})}setState(e){this.stateValue=e,this.emit("statechange",{state:e})}now(){return this.options.now?.()??performance.now()}},o(K,"Ie"),K),ge;function ki(i){return new Promise(e=>setTimeout(e,i))}o(ki,"nt");function Ti(i){return i instanceof Error?i.message:String(i)}o(Ti,"at");function ut(i,e,t){try{let r=document.createElement("canvas"),s=t/Math.max(1,e.width);r.width=Math.max(1,Math.round(e.width*s)),r.height=Math.max(1,Math.round(e.height*s));let a=r.getContext("2d");return a===null?null:(a.drawImage(i,e.x,e.y,e.width,e.height,0,0,r.width,r.height),a.getImageData(0,0,r.width,r.height))}catch{return null}}o(ut,"Re");function _i(i){if(i.enumerateDevices!==void 0)return i.enumerateDevices;if(i.getUserMedia===void 0&&!(typeof navigator>"u"||typeof navigator.mediaDevices?.enumerateDevices!="function"))return()=>navigator.mediaDevices.enumerateDevices()}o(_i,"st");var Ei=12e4,gt=13e4,Si=3e3,Ai=1200,ve=Symbol.for("@sekyro/web.preload.v1");function we(){let i=globalThis;return i[ve]??(i[ve]=new Map),i[ve]}o(we,"h");function re(i){let e=(i??ue).replace(/\/+$/,"");return e===""?"/":e}o(re,"b");function yt(i){let e=we(),t=e.get(i);return t===void 0&&(t={status:"idle",promise:null,scheduled:null,detectorPromise:null,detector:null,listeners:new Set},e.set(i,t)),t}o(yt,"ae");function ye(i,e){if(i.status!==e){i.status=e;for(let t of[...i.listeners])t(e)}}o(ye,"k");var Ii=o(i=>x({preferred:["blaze"],v3AssetBaseUrl:i,blazeInitTimeoutMs:Ei}),"K"),xi=Ii;function Di(){return typeof window<"u"&&typeof navigator<"u"&&typeof navigator.mediaDevices?.getUserMedia=="function"}o(Di,"Ce");function Ri(){return navigator.connection?.saveData===!0}o(Ri,"Se");function Ci(i){let e=window;if(typeof e.requestIdleCallback=="function"){let r=e.requestIdleCallback(i,{timeout:Si});return()=>e.cancelIdleCallback?.(r)}let t=setTimeout(i,Ai);return()=>clearTimeout(t)}o(Ci,"Ee");function Oi(i,e){let t,r=new Promise(l=>{t=l}),s=!1,a=o(()=>{},"u"),n={promise:r,settle:o(l=>{s||(s=!0,a(),i.scheduled===n&&(i.scheduled=null),t(l))},"settle")};return i.scheduled=n,a=Ci(()=>{s||n.settle(be(i,e))}),r}o(Oi,"ye");function be(i,e){if((i.status==="loading"||i.status==="ready")&&i.promise!==null)return i.promise;ye(i,"loading");let t=new Promise(n=>n(xi(e)));i.detectorPromise=t;let r,s=new Promise((n,l)=>{r=setTimeout(()=>{t.then(c=>c.destroy(),()=>{}),l(new Error(`detector preload exceeded ${gt} ms`))},gt)}),a=Promise.race([t,s]).then(n=>i.detectorPromise!==t?(n.destroy(),i.status):(i.detector=n,ye(i,"ready"),"ready"),n=>(i.detectorPromise===t&&(i.detectorPromise=null,i.detector=null,ye(i,"failed"),console.warn("[@sekyro/web] face-detector preload failed:",n)),i.status)).finally(()=>clearTimeout(r));return i.promise=a,i.scheduled?.settle(a),a}o(be,"U");function hr(i={}){if(!Di())return Promise.resolve("idle");let e=re(i.assetBaseUrl),t=yt(e);return i.respectSaveData===!0&&Ri()?Promise.resolve(t.status):(t.status==="loading"||t.status==="ready")&&t.promise!==null?t.promise:i.idle===!0?t.scheduled?.promise??Oi(t,e):be(t,e)}o(hr,"xe");function ur(i){return we().get(re(i))?.status??"idle"}o(ur,"Fe");function dr(i,e){let t=yt(re(e));return t.listeners.add(i),()=>{t.listeners.delete(i)}}o(dr,"Ie");function Pi(i){return{get tier(){return i.tier},get fallbackReason(){return i.fallbackReason},detect:o((...e)=>i.detect(...e),"detect"),destroy:o(()=>{},"destroy")}}o(Pi,"Le");function Gi(i){let e=re(i),t=we().get(e);if(!(t===void 0||t.detector===null&&t.detectorPromise===null&&t.scheduled===null))return async()=>{t.scheduled!==null&&be(t,e);let r=t.promise;for(;t.detector===null&&r!==null&&(await r,t.promise!==r);)r=t.promise;return t.detector!==null?Pi(t.detector):x({v3AssetBaseUrl:e})}}o(Gi,"de");var Ui=new Set(["inuse","overconstrained","notfound"]),Fi=[500,1500];function Ni(i){switch(i){case"fcv3.no_face":case"fcv3.center_face":case"fcv3.straighten":return"center";case"fcv3.come_closer":return"closer";case"fcv3.move_back":return"farther";case"fcv3.more_light":case"fcv3.too_bright":return"light";case"fcv3.hold_still":case"fcv3.steady_camera":return"still";case"fcv3.hold_upright":return"upright";case"fcv3.one_face":return"one_face";default:return null}}o(Ni,"Ae");function Li(i){switch(i){case"preflight":case"acquiring":return"starting";case"positioning":return"gating";default:return i}}o(Li,"Pe");function vt(i){switch(i){case"permission":case"notfound":case"inuse":case"insecure":case"unsupported":return i;case"backcamera":return"notfound";default:{let e=i;return"generic"}}}o(vt,"ue");function Bi(i,e,t){if(t===void 0)return{kind:vt(i),retryable:e};let r=qe(t.name);return{kind:vt(i),retryable:e,detail:{...r!==void 0?{name:r}:{},phase:t.phase,engineKind:i}}}o(Bi,"we");var qi=new Set(["captured","uploading","checking"]);function Wi(i,e={},t,r=()=>"self",s=()=>{},a){let n=e.now??(()=>performance.now()),l=e.canChooseFacing??Oe,c="user",h=Pe(),d=r(),u=Ce(),m=!Le(),w=e.engineOptions,p=w?.createDetector===void 0&&w?.createWorker===void 0?{createDetector:o(()=>{let f=Gi(i.assetBaseUrl);return f!==void 0?f():x({v3AssetBaseUrl:i.assetBaseUrl})},"createDetector")}:{},v={video:i.video,mode:m?"photo":"clip",rankKeyframes:t,facingMode:void 0,v3AssetBaseUrl:i.assetBaseUrl,screenRamp:o(()=>d==="self"&&u.count("ramp")>0?s():void 0,"screenRamp"),...e.engineOptions??{},...p},y=e.createEngine?.(v)??new mt(v),g="idle",M=null,E=0,A=!1,I="full",_=null,b=null,R=0,S=0,$=o(()=>{i.video.videoWidth>0&&i.video.videoHeight>0&&(R=i.video.videoWidth,S=i.video.videoHeight)},"W"),Me=Ge({enabled:i.keepScreenAwake!==!1}),X=o(f=>{g=f,Me.setActive(f==="starting"||f==="gating"||f==="recording"),u.emit("state",f)},"S"),se=o(()=>u.emit("gate",{progress:E,hint:M,faceDetected:A}),"F"),ae=o(()=>{let f=y.animations??"full";f!==I&&(I=f,u.emit("profile",{animations:I}))},"I"),G=0,Y=null,wt=e.schedule??((f,k)=>{let T=setTimeout(f,k);return()=>clearTimeout(T)}),Z=o(()=>{Y?.(),Y=null},"E"),bt=o((f,k)=>{if(V||!Ui.has(f)||k?.phase!=="acquiring")return!1;let T=Fi[G];return T===void 0?!1:(G+=1,Z(),Y=wt(()=>{Y=null,V||y.retry()},T),!0)},"fe"),Mt=[y.on("statechange",({state:f})=>{if(f==="error")return;let k=Li(f);k==="gating"&&(G=0),k==="starting"&&g!=="starting"&&(M=null,E=0,A=!1,_=null,b=null,R=0,S=0),X(k),ae(),k==="recording"&&($(),_=n(),M="hold",E=1,se())}),y.on("checks",f=>{$(),E=f.progress,A=f.factors.presence>0,se(),ae()}),y.on("guidance",({key:f})=>{M=Ni(f),se()}),y.on("frozen",({previewDataUrl:f})=>{b=n(),u.emit("frozen",{previewDataUrl:f})}),y.on("ramp",f=>u.emit("ramp",f)),y.on("artifacts",f=>{if(g!=="captured")return;let k=Q(),T=f.clipStats,_e=T!==void 0?Math.round(T.durationMs):_!==null&&b!==null?Math.max(0,Math.round(b-_)):void 0,Ee=T!==void 0&&T.frames>1&&T.durationMs>0?Math.round(T.frames*1e4/T.durationMs)/10:void 0;u.emit("captured",{keyframe:f.keyframe,...f.clip!==void 0?{clip:f.clip}:{},...f.clipMimeType!==void 0?{clipMime:f.clipMimeType}:{},width:i.video.videoWidth||R,height:i.video.videoHeight||S,..._e!==void 0?{clipMs:_e}:{},...T!==void 0?{clipFrames:T.frames}:{},...Ee!==void 0?{fps:Ee}:{},...f.clipRetakes!==void 0?{clipRetakes:f.clipRetakes}:{},...f.clipMimeType!==void 0?{codec:ft(f.clipMimeType)}:{},captureChannel:k==="desktop"?"desktop":"mobile",formFactor:k,...m?{degraded:"NO_RECORDER"}:{},engine:"v3",facingMode:y.facingMode,mode:d,...f.timing,...f.screenRamp!==void 0?{screenRamp:f.screenRamp}:{},...f.provenance!==void 0?{provenance:f.provenance}:{}})}),y.on("error",({kind:f,retryable:k,detail:T})=>{f==="backcamera"&&kt()||bt(f,T)||(X("error"),ae(),u.emit("error",Bi(f,k,T)))})],ke=!1;function kt(){return V||ke||d!=="assisted"||a===void 0||a.session()!=="choice"?!1:(ke=!0,a.onModeChange("self"),d="self",c=ne("self"),X("mode_switch"),y.restart(c),!0)}o(kt,"me");let Te=o(async()=>a!==void 0&&a.session()==="choice"&&await l().catch(()=>!1),"$"),V=!1;return{handle:{get state(){return g},get captureMode(){return r()},get facingMode(){return y.facingMode??c},on:o((f,k)=>u.on(f,k),"on"),start:o(f=>(d=r(),h.facing(d,i.facing),c=h.facing(d,f?.facing),Z(),G=0,y.start({facingMode:c})),"start"),retry:o(()=>{Z(),G=0,y.retry()},"retry"),switchCamera:o(()=>h.refuseSwitch(r()),"switchCamera"),canSwitchCaptureMode:Te,setCaptureMode:o(async f=>{if(f===r()||!await Te()||V||qi.has(g)||a===void 0)return!1;a.onModeChange(f),d=f;let k=ne(f);return c=k,g==="idle"||(X("mode_switch"),Z(),G=0,y.restart(k)),!0},"setCaptureMode"),destroy:o(()=>{V=!0,Z();for(let f of Mt)f();Me.setActive(!1),y.destroy(),u.clear()},"destroy")},setFlowState:o(f=>{g!==f&&X(f)},"setFlowState")}}o(Wi,"De");function fr(i){return Wi(i).handle}o(fr,"Ze");export{zi as a,ee as b,hr as c,ur as d,dr as e,Bi as f,Wi as g,fr as h};
|