@sekyro/elements 0.1.0-rc.22 → 0.1.0-rc.23
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 +8 -0
- package/dist/cdn/chunks/{capture-session-doc-MF4JLCXV-VUUGFPYQ.js → capture-session-doc-ENDGVJ3L-IMAPC36N.js} +1 -1
- package/dist/cdn/chunks/{chunk-JHSQ6JZW.js → chunk-4RREQCYP.js} +1 -1
- package/dist/cdn/chunks/{chunk-VWGUPBQM.js → chunk-B7JVGTNG.js} +1 -1
- package/dist/cdn/chunks/{chunk-5TXJCIRO.js → chunk-BG7ZLMF3.js} +1 -1
- package/dist/cdn/chunks/{chunk-ZPGVBC4B.js → chunk-BZCLR3ZW.js} +1 -1
- package/dist/cdn/chunks/{chunk-E6VD556C.js → chunk-FUMXKBXY.js} +2 -2
- package/dist/cdn/chunks/{chunk-EMGQ4LGZ.js → chunk-HHBISLBD.js} +1 -1
- package/dist/cdn/chunks/{chunk-P3BHY3N3.js → chunk-HM5EP25H.js} +1 -1
- package/dist/cdn/chunks/{chunk-MQQT3Z5N.js → chunk-NGWIL3RI.js} +1 -1
- package/dist/cdn/chunks/{chunk-7LM65APF.js → chunk-NNIK6RGK.js} +1 -1
- package/dist/cdn/chunks/{chunk-M5S6ZWB6.js → chunk-PSLOZIUH.js} +2 -2
- package/dist/cdn/chunks/{chunk-IYLFOD6M.js → chunk-PXF2CWO3.js} +1 -1
- package/dist/cdn/chunks/{chunk-FKDRZIZ4.js → chunk-RCDZUOGM.js} +1 -1
- package/dist/cdn/chunks/{chunk-GFS5OS2G.js → chunk-RVPBL3KC.js} +1 -1
- package/dist/cdn/chunks/{chunk-HZGSVEL3.js → chunk-TCXBCGZF.js} +1 -1
- package/dist/cdn/chunks/{chunk-RZ2NUZZ7.js → chunk-UMGCNKDP.js} +1 -1
- package/dist/cdn/chunks/{create-document-capture-NQQV36S7-E7NZFJ6B.js → create-document-capture-SZ4SIVVC-P4MMZXVZ.js} +1 -1
- package/dist/cdn/chunks/{document-capture-view-ZQONDCSM-3BQH4UWM.js → document-capture-view-ZQONDCSM-CX2F54ZS.js} +1 -1
- package/dist/cdn/chunks/{eid-view-FEJHQBSB-3YVDTSKP.js → eid-view-FEJHQBSB-YSYB6LNM.js} +1 -1
- package/dist/cdn/chunks/{email-otp-view-4EY5CKR5-SMREIHCF.js → email-otp-view-4EY5CKR5-QMWJOSCD.js} +1 -1
- package/dist/cdn/chunks/{flow-views-JC2DWBW3-A6HKOURP.js → flow-views-JC2DWBW3-GP5F4777.js} +1 -1
- package/dist/cdn/chunks/{form-view-GPITA6X5-P6ZAGK3K.js → form-view-GPITA6X5-YDYPXP7W.js} +1 -1
- package/dist/cdn/chunks/{plan-runner-KGBHC6RO-CJJCUIMT.js → plan-runner-MC6KC7PK-E55J5SPN.js} +1 -1
- package/dist/cdn/chunks/{portrait-capture-view-Q6XYTGE7-2J55WRTJ.js → portrait-capture-view-Q6XYTGE7-BL2EYATL.js} +1 -1
- package/dist/cdn/chunks/{portrait-review-view-KZVKR6XN-GYD7KMKC.js → portrait-review-view-KZVKR6XN-QEZYASJF.js} +1 -1
- package/dist/cdn/chunks/{proof-of-address-view-YYZTILHQ-BARDS6NS.js → proof-of-address-view-YYZTILHQ-BVR6FUOS.js} +1 -1
- package/dist/cdn/define.js +1 -1
- package/dist/cdn/index.js +1 -1
- package/dist/{chunk-DER42MAE.js → chunk-GDJMAPFB.js} +1 -1
- package/dist/define.cjs +3 -3
- package/dist/define.js +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.js +1 -1
- package/package.json +2 -2
- package/sbom.cdx.json +4 -4
- /package/dist/cdn/chunks/{challenge-frame-YBTLAQ5G-NN763UU5.js → challenge-frame-FGQBS3HD-S3UO5OUT.js} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{d as I}from"./chunk-MLNUIPVU.js";import{a as C,b as P,c as H}from"./chunk-CUFOLAZN.js";import{a as T}from"./chunk-GFS5OS2G.js";import{a as u}from"./chunk-5QL6W6FW.js";import{a as s,b as D,c as N}from"./chunk-4FHWXBOB.js";var j=D(l=>{"use strict";var Q=C();function V(r){var e="https://react.dev/errors/"+r;if(1<arguments.length){e+="?args[]="+encodeURIComponent(arguments[1]);for(var t=2;t<arguments.length;t++)e+="&args[]="+encodeURIComponent(arguments[t])}return"Minified React error #"+r+"; visit "+e+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}s(V,"formatProdErrorMessage");function h(){}s(h,"noop");var c={d:{f:h,r:s(function(){throw Error(V(522))},"r"),D:h,C:h,L:h,m:h,X:h,S:h,M:h},p:0,findDOMNode:null},ee=Symbol.for("react.portal");function re(r,e,t){var n=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:ee,key:n==null?null:""+n,children:r,containerInfo:e,implementation:t}}s(re,"createPortal$1");var O=Q.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function M(r,e){if(r==="font")return"";if(typeof e=="string")return e==="use-credentials"?e:""}s(M,"getCrossOriginStringAs");l.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=c;l.createPortal=function(r,e){var t=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)throw Error(V(299));return re(r,e,null,t)};l.flushSync=function(r){var e=O.T,t=c.p;try{if(O.T=null,c.p=2,r)return r()}finally{O.T=e,c.p=t,c.d.f()}};l.preconnect=function(r,e){typeof r=="string"&&(e?(e=e.crossOrigin,e=typeof e=="string"?e==="use-credentials"?e:"":void 0):e=null,c.d.C(r,e))};l.prefetchDNS=function(r){typeof r=="string"&&c.d.D(r)};l.preinit=function(r,e){if(typeof r=="string"&&e&&typeof e.as=="string"){var t=e.as,n=M(t,e.crossOrigin),o=typeof e.integrity=="string"?e.integrity:void 0,i=typeof e.fetchPriority=="string"?e.fetchPriority:void 0;t==="style"?c.d.S(r,typeof e.precedence=="string"?e.precedence:void 0,{crossOrigin:n,integrity:o,fetchPriority:i}):t==="script"&&c.d.X(r,{crossOrigin:n,integrity:o,fetchPriority:i,nonce:typeof e.nonce=="string"?e.nonce:void 0})}};l.preinitModule=function(r,e){if(typeof r=="string")if(typeof e=="object"&&e!==null){if(e.as==null||e.as==="script"){var t=M(e.as,e.crossOrigin);c.d.M(r,{crossOrigin:t,integrity:typeof e.integrity=="string"?e.integrity:void 0,nonce:typeof e.nonce=="string"?e.nonce:void 0})}}else e==null&&c.d.M(r)};l.preload=function(r,e){if(typeof r=="string"&&typeof e=="object"&&e!==null&&typeof e.as=="string"){var t=e.as,n=M(t,e.crossOrigin);c.d.L(r,t,{crossOrigin:n,integrity:typeof e.integrity=="string"?e.integrity:void 0,nonce:typeof e.nonce=="string"?e.nonce:void 0,type:typeof e.type=="string"?e.type:void 0,fetchPriority:typeof e.fetchPriority=="string"?e.fetchPriority:void 0,referrerPolicy:typeof e.referrerPolicy=="string"?e.referrerPolicy:void 0,imageSrcSet:typeof e.imageSrcSet=="string"?e.imageSrcSet:void 0,imageSizes:typeof e.imageSizes=="string"?e.imageSizes:void 0,media:typeof e.media=="string"?e.media:void 0})}};l.preloadModule=function(r,e){if(typeof r=="string")if(e){var t=M(e.as,e.crossOrigin);c.d.m(r,{as:typeof e.as=="string"&&e.as!=="script"?e.as:void 0,crossOrigin:t,integrity:typeof e.integrity=="string"?e.integrity:void 0})}else c.d.m(r)};l.requestFormReset=function(r){c.d.r(r)};l.unstable_batchedUpdates=function(r,e){return r(e)};l.useFormState=function(r,e,t){return O.H.useFormState(r,e,t)};l.useFormStatus=function(){return O.H.useHostTransitionStatus()};l.version="19.2.0"});var W=D((de,B)=>{"use strict";function U(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(U)}catch(r){console.error(r)}}s(U,"checkDCE");U(),B.exports=j()});var z=N(C(),1),f=N(P(),1),a=N(P(),1);var E=N(C(),1),Z=N(W(),1),v=N(P(),1);var te=Array.from({length:56},(r,e)=>{let t=e/56*2*Math.PI-Math.PI/2,n=Math.cos(t),o=Math.sin(t);return{id:`tick-${e}`,frac:e/55,x1:150+108*n,y1:150+108*o,x2:150+138*n,y2:150+138*o,style:{transitionDelay:`${e*6}ms`}}});function F(r,e,t,n){return t?"var(--sekyro-color-success)":r?n?"color-mix(in srgb, var(--sekyro-color-warning) 75%, transparent)":e<.33?"color-mix(in srgb, var(--sekyro-color-brand) 55%, transparent)":e<.66?"color-mix(in srgb, var(--sekyro-color-brand) 80%, transparent)":"var(--sekyro-color-brand)":"color-mix(in srgb, var(--sekyro-color-surface) 32%, transparent)"}s(F,"T");u(F,"tickColor");var ae="M0 -50 H300 V350 H0 Z M50 150 a100,100 0 1 0 200,0 a100,100 0 1 0 -200,0 Z";function G({progress:r,phase:e,draining:t=!1}){let n=Math.min(1,Math.max(0,r)),o=Math.round(n*56),i=e==="checking",y=e==="recording",d=e==="frozen",m=i||d,p=i||y||d,k=e==="locked"||p,S=t&&!k;return(0,f.jsxs)("svg",{"aria-hidden":"true",viewBox:"0 0 300 300",preserveAspectRatio:"xMidYMid meet",className:"sekyro-stage__arc","data-testid":"sekyro-capture-arc","data-phase":e,"data-filled":o,"data-recording":y?"":void 0,"data-draining":S?"":void 0,children:[(0,f.jsx)("path",{fillRule:"evenodd",d:ae,fill:"color-mix(in srgb, var(--sekyro-color-fg) var(--sekyro-scrim, 96%), transparent)",style:{"--sekyro-scrim":m?"100%":"96%"},className:"sekyro-arc__scrim sekyro-capture-fade-in","data-testid":"sekyro-capture-scrim"}),(0,f.jsxs)("g",{className:e==="locked"?"sekyro-capture-settle":void 0,children:[(0,f.jsx)("g",{className:m?"sekyro-arc__ring sekyro-arc__ring--dim":"sekyro-arc__ring",children:te.map((g,x)=>(0,f.jsx)("line",{x1:g.x1,y1:g.y1,x2:g.x2,y2:g.y2,stroke:F(x<o,g.frac,k,S),strokeWidth:3,strokeLinecap:"round",style:g.style,className:"sekyro-arc__tick"},g.id))}),(0,f.jsx)("g",{className:e==="seeking"?"sekyro-capture-breathe":void 0,children:(0,f.jsx)("circle",{cx:150,cy:150,r:100,fill:"none",stroke:k?"var(--sekyro-color-success)":"var(--sekyro-color-surface)",strokeWidth:k?3.5:2.5,className:p?"sekyro-arc__guide sekyro-arc__guide--spin sekyro-capture-ring-spin":"sekyro-arc__guide sekyro-capture-fade-in","data-testid":"sekyro-capture-guide"})})]})]})}s(G,"x");u(G,"CaptureArc");function ne({videoRef:r,guidanceText:e,guidanceHint:t,guidanceKey:n,progress:o,phase:i,draining:y=!1,stillUrl:d,showChecking:m,operatorText:p=null,voicePrompt:k,overlay:S,reduceMotion:g=!1,modeSwitch:x=null}){let b=I(),w=i==="checking",_=w||i==="frozen",A=_&&m?b("capture.checking"):e,L=k?.(t,A,n);return(0,a.jsxs)("div",{className:g?"sekyro-stage sekyro-capture-reduce":"sekyro-stage","data-testid":"sekyro-capture-stage",children:[(0,a.jsx)("video",{ref:r,playsInline:!0,muted:!0,className:"sekyro-stage__video","data-testid":"sekyro-capture-video"}),d!==null&&_?(0,a.jsx)("img",{src:d,alt:b("capture.previewAlt"),className:"sekyro-stage__still sekyro-capture-develop","data-testid":"sekyro-capture-still"}):null,(0,a.jsx)(G,{progress:o,phase:i,draining:y}),S?.(r),L!=null&&!_?(0,a.jsx)("div",{className:"sekyro-stage__corner-start","data-testid":"sekyro-voice-slot",children:L}):null,x!==null&&!_?(0,a.jsx)($,{view:x,className:"sekyro-stage__corner-end sekyro-stage__mode-switch",kind:"chip"}):null,w&&m?(0,a.jsxs)("span",{className:"sekyro-stage__corner-end sekyro-stage__pill sekyro-capture-pill-in","data-testid":"sekyro-camera-off-pill",children:[(0,a.jsx)(Y,{}),b("capture.cameraOff")]}):null,(0,a.jsxs)("p",{"aria-live":"polite",className:"sekyro-stage__guidance","data-testid":"sekyro-capture-guidance",children:[(0,a.jsx)("span",{className:"sekyro-stage__guidance-text sekyro-capture-text-in",children:A},A),_&&m?(0,a.jsx)("span",{className:"sekyro-stage__guidance-hint",children:b("capture.checkingHint")}):p!==null&&!_?(0,a.jsx)("span",{className:"sekyro-stage__guidance-hint","data-testid":"sekyro-operator-line",children:p}):null]})]})}s(ne,"ne");u(ne,"CaptureStage");function $({view:r,className:e,kind:t}){let n=(0,z.useId)(),o=(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(K,{}),(0,a.jsx)("span",{children:r.label})]}),i={onClick:r.onSwitch,"aria-describedby":n,"data-testid":"sekyro-capture-mode-switch","data-mode":r.to};return(0,a.jsxs)(a.Fragment,{children:[t==="chip"?(0,a.jsx)(H,{kind:"chip",className:e,...i,children:o}):(0,a.jsx)("button",{type:"button",className:e,...i,children:o}),(0,a.jsx)("span",{id:n,className:"sekyro-visually-hidden",children:r.description})]})}s($,"H");u($,"ModeSwitchChip");function K(){return(0,a.jsxs)("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",className:"sekyro-icon",children:[(0,a.jsx)("path",{d:"M4 7.5h2.2l1.4-1.9h8.8l1.4 1.9H20a1.6 1.6 0 0 1 1.6 1.6v8.3A1.6 1.6 0 0 1 20 19H4a1.6 1.6 0 0 1-1.6-1.6V9.1A1.6 1.6 0 0 1 4 7.5Z"}),(0,a.jsx)("path",{d:"M15.4 11.9a3.5 3.5 0 0 0-6.1-1.4M15.4 11.9h-2.1m2.1 0V9.8"}),(0,a.jsx)("path",{d:"M8.6 13.4a3.5 3.5 0 0 0 6.1 1.4M8.6 13.4h2.1m-2.1 0v2.1"})]})}s(K,"D");u(K,"FlipCameraIcon");function Y(){return(0,a.jsxs)("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",className:"sekyro-icon sekyro-icon--sm",children:[(0,a.jsx)("path",{d:"M4 7.5h2.2l1.4-1.9h8.8l1.4 1.9H20a1.6 1.6 0 0 1 1.6 1.6v8.3A1.6 1.6 0 0 1 20 19H4a1.6 1.6 0 0 1-1.6-1.6V9.1A1.6 1.6 0 0 1 4 7.5Z"}),(0,a.jsx)("path",{d:"M3 3l18 18"})]})}s(Y,"G");u(Y,"CameraOffIcon");var ie=typeof window>"u"?E.useEffect:E.useLayoutEffect,R="data-sekyro-ramp",se=[["background-color","transparent"],["background-image","none"]];function q(r){let e=[],t=r.ownerDocument;for(let i=r;i!==null&&i!==t.documentElement;i=i.parentElement){if(!(i instanceof HTMLElement)&&!(i instanceof SVGElement))continue;let y=i.style;for(let[d,m]of se){let p=y.getPropertyValue(d),k=y.getPropertyPriority(d);y.setProperty(d,m,"important"),e.push(()=>{p===""?y.removeProperty(d):y.setProperty(d,p,k)})}}let n=t.documentElement,o=n.hasAttribute(R);return n.setAttribute(R,""),o||e.push(()=>n.removeAttribute(R)),()=>{for(let i of e.reverse())i()}}s(q,"z");u(q,"clearAncestorBackdrops");function X(r){return{position:"fixed",inset:0,minWidth:"100vw",minHeight:"100lvh",margin:0,padding:0,border:0,zIndex:-1,pointerEvents:"none",backgroundColor:T(r)}}s(X,"B");u(X,"washStyle");function J(r){return{position:"absolute",inset:0,pointerEvents:"none",backgroundColor:T(r)}}s(J,"Y");u(J,"coverStyle");function oe({colour:r}){let e=(0,E.useRef)(null),t=r!==null;return ie(()=>{let n=e.current?.parentElement;if(!(!t||n===null||n===void 0))return q(n)},[t]),r===null||typeof document>"u"?null:(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)("div",{ref:e,"aria-hidden":"true","data-testid":"sekyro-screen-ramp-cover","data-colour":r,style:J(r)}),(0,Z.createPortal)((0,v.jsx)("div",{"aria-hidden":"true","data-testid":"sekyro-screen-ramp","data-colour":r,style:X(r)}),document.body)]})}s(oe,"de");u(oe,"ScreenRampLayer");export{W as a,ne as b,$ as c,oe as d};
|
|
1
|
+
import{d as I}from"./chunk-MLNUIPVU.js";import{a as C,b as P,c as H}from"./chunk-CUFOLAZN.js";import{a as T}from"./chunk-RVPBL3KC.js";import{a as u}from"./chunk-5QL6W6FW.js";import{a as s,b as D,c as N}from"./chunk-4FHWXBOB.js";var j=D(l=>{"use strict";var Q=C();function V(r){var e="https://react.dev/errors/"+r;if(1<arguments.length){e+="?args[]="+encodeURIComponent(arguments[1]);for(var t=2;t<arguments.length;t++)e+="&args[]="+encodeURIComponent(arguments[t])}return"Minified React error #"+r+"; visit "+e+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}s(V,"formatProdErrorMessage");function h(){}s(h,"noop");var c={d:{f:h,r:s(function(){throw Error(V(522))},"r"),D:h,C:h,L:h,m:h,X:h,S:h,M:h},p:0,findDOMNode:null},ee=Symbol.for("react.portal");function re(r,e,t){var n=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:ee,key:n==null?null:""+n,children:r,containerInfo:e,implementation:t}}s(re,"createPortal$1");var O=Q.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function M(r,e){if(r==="font")return"";if(typeof e=="string")return e==="use-credentials"?e:""}s(M,"getCrossOriginStringAs");l.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=c;l.createPortal=function(r,e){var t=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)throw Error(V(299));return re(r,e,null,t)};l.flushSync=function(r){var e=O.T,t=c.p;try{if(O.T=null,c.p=2,r)return r()}finally{O.T=e,c.p=t,c.d.f()}};l.preconnect=function(r,e){typeof r=="string"&&(e?(e=e.crossOrigin,e=typeof e=="string"?e==="use-credentials"?e:"":void 0):e=null,c.d.C(r,e))};l.prefetchDNS=function(r){typeof r=="string"&&c.d.D(r)};l.preinit=function(r,e){if(typeof r=="string"&&e&&typeof e.as=="string"){var t=e.as,n=M(t,e.crossOrigin),o=typeof e.integrity=="string"?e.integrity:void 0,i=typeof e.fetchPriority=="string"?e.fetchPriority:void 0;t==="style"?c.d.S(r,typeof e.precedence=="string"?e.precedence:void 0,{crossOrigin:n,integrity:o,fetchPriority:i}):t==="script"&&c.d.X(r,{crossOrigin:n,integrity:o,fetchPriority:i,nonce:typeof e.nonce=="string"?e.nonce:void 0})}};l.preinitModule=function(r,e){if(typeof r=="string")if(typeof e=="object"&&e!==null){if(e.as==null||e.as==="script"){var t=M(e.as,e.crossOrigin);c.d.M(r,{crossOrigin:t,integrity:typeof e.integrity=="string"?e.integrity:void 0,nonce:typeof e.nonce=="string"?e.nonce:void 0})}}else e==null&&c.d.M(r)};l.preload=function(r,e){if(typeof r=="string"&&typeof e=="object"&&e!==null&&typeof e.as=="string"){var t=e.as,n=M(t,e.crossOrigin);c.d.L(r,t,{crossOrigin:n,integrity:typeof e.integrity=="string"?e.integrity:void 0,nonce:typeof e.nonce=="string"?e.nonce:void 0,type:typeof e.type=="string"?e.type:void 0,fetchPriority:typeof e.fetchPriority=="string"?e.fetchPriority:void 0,referrerPolicy:typeof e.referrerPolicy=="string"?e.referrerPolicy:void 0,imageSrcSet:typeof e.imageSrcSet=="string"?e.imageSrcSet:void 0,imageSizes:typeof e.imageSizes=="string"?e.imageSizes:void 0,media:typeof e.media=="string"?e.media:void 0})}};l.preloadModule=function(r,e){if(typeof r=="string")if(e){var t=M(e.as,e.crossOrigin);c.d.m(r,{as:typeof e.as=="string"&&e.as!=="script"?e.as:void 0,crossOrigin:t,integrity:typeof e.integrity=="string"?e.integrity:void 0})}else c.d.m(r)};l.requestFormReset=function(r){c.d.r(r)};l.unstable_batchedUpdates=function(r,e){return r(e)};l.useFormState=function(r,e,t){return O.H.useFormState(r,e,t)};l.useFormStatus=function(){return O.H.useHostTransitionStatus()};l.version="19.2.0"});var W=D((de,B)=>{"use strict";function U(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(U)}catch(r){console.error(r)}}s(U,"checkDCE");U(),B.exports=j()});var z=N(C(),1),f=N(P(),1),a=N(P(),1);var E=N(C(),1),Z=N(W(),1),v=N(P(),1);var te=Array.from({length:56},(r,e)=>{let t=e/56*2*Math.PI-Math.PI/2,n=Math.cos(t),o=Math.sin(t);return{id:`tick-${e}`,frac:e/55,x1:150+108*n,y1:150+108*o,x2:150+138*n,y2:150+138*o,style:{transitionDelay:`${e*6}ms`}}});function F(r,e,t,n){return t?"var(--sekyro-color-success)":r?n?"color-mix(in srgb, var(--sekyro-color-warning) 75%, transparent)":e<.33?"color-mix(in srgb, var(--sekyro-color-brand) 55%, transparent)":e<.66?"color-mix(in srgb, var(--sekyro-color-brand) 80%, transparent)":"var(--sekyro-color-brand)":"color-mix(in srgb, var(--sekyro-color-surface) 32%, transparent)"}s(F,"T");u(F,"tickColor");var ae="M0 -50 H300 V350 H0 Z M50 150 a100,100 0 1 0 200,0 a100,100 0 1 0 -200,0 Z";function G({progress:r,phase:e,draining:t=!1}){let n=Math.min(1,Math.max(0,r)),o=Math.round(n*56),i=e==="checking",y=e==="recording",d=e==="frozen",m=i||d,p=i||y||d,k=e==="locked"||p,S=t&&!k;return(0,f.jsxs)("svg",{"aria-hidden":"true",viewBox:"0 0 300 300",preserveAspectRatio:"xMidYMid meet",className:"sekyro-stage__arc","data-testid":"sekyro-capture-arc","data-phase":e,"data-filled":o,"data-recording":y?"":void 0,"data-draining":S?"":void 0,children:[(0,f.jsx)("path",{fillRule:"evenodd",d:ae,fill:"color-mix(in srgb, var(--sekyro-color-fg) var(--sekyro-scrim, 96%), transparent)",style:{"--sekyro-scrim":m?"100%":"96%"},className:"sekyro-arc__scrim sekyro-capture-fade-in","data-testid":"sekyro-capture-scrim"}),(0,f.jsxs)("g",{className:e==="locked"?"sekyro-capture-settle":void 0,children:[(0,f.jsx)("g",{className:m?"sekyro-arc__ring sekyro-arc__ring--dim":"sekyro-arc__ring",children:te.map((g,x)=>(0,f.jsx)("line",{x1:g.x1,y1:g.y1,x2:g.x2,y2:g.y2,stroke:F(x<o,g.frac,k,S),strokeWidth:3,strokeLinecap:"round",style:g.style,className:"sekyro-arc__tick"},g.id))}),(0,f.jsx)("g",{className:e==="seeking"?"sekyro-capture-breathe":void 0,children:(0,f.jsx)("circle",{cx:150,cy:150,r:100,fill:"none",stroke:k?"var(--sekyro-color-success)":"var(--sekyro-color-surface)",strokeWidth:k?3.5:2.5,className:p?"sekyro-arc__guide sekyro-arc__guide--spin sekyro-capture-ring-spin":"sekyro-arc__guide sekyro-capture-fade-in","data-testid":"sekyro-capture-guide"})})]})]})}s(G,"x");u(G,"CaptureArc");function ne({videoRef:r,guidanceText:e,guidanceHint:t,guidanceKey:n,progress:o,phase:i,draining:y=!1,stillUrl:d,showChecking:m,operatorText:p=null,voicePrompt:k,overlay:S,reduceMotion:g=!1,modeSwitch:x=null}){let b=I(),w=i==="checking",_=w||i==="frozen",A=_&&m?b("capture.checking"):e,L=k?.(t,A,n);return(0,a.jsxs)("div",{className:g?"sekyro-stage sekyro-capture-reduce":"sekyro-stage","data-testid":"sekyro-capture-stage",children:[(0,a.jsx)("video",{ref:r,playsInline:!0,muted:!0,className:"sekyro-stage__video","data-testid":"sekyro-capture-video"}),d!==null&&_?(0,a.jsx)("img",{src:d,alt:b("capture.previewAlt"),className:"sekyro-stage__still sekyro-capture-develop","data-testid":"sekyro-capture-still"}):null,(0,a.jsx)(G,{progress:o,phase:i,draining:y}),S?.(r),L!=null&&!_?(0,a.jsx)("div",{className:"sekyro-stage__corner-start","data-testid":"sekyro-voice-slot",children:L}):null,x!==null&&!_?(0,a.jsx)($,{view:x,className:"sekyro-stage__corner-end sekyro-stage__mode-switch",kind:"chip"}):null,w&&m?(0,a.jsxs)("span",{className:"sekyro-stage__corner-end sekyro-stage__pill sekyro-capture-pill-in","data-testid":"sekyro-camera-off-pill",children:[(0,a.jsx)(Y,{}),b("capture.cameraOff")]}):null,(0,a.jsxs)("p",{"aria-live":"polite",className:"sekyro-stage__guidance","data-testid":"sekyro-capture-guidance",children:[(0,a.jsx)("span",{className:"sekyro-stage__guidance-text sekyro-capture-text-in",children:A},A),_&&m?(0,a.jsx)("span",{className:"sekyro-stage__guidance-hint",children:b("capture.checkingHint")}):p!==null&&!_?(0,a.jsx)("span",{className:"sekyro-stage__guidance-hint","data-testid":"sekyro-operator-line",children:p}):null]})]})}s(ne,"ne");u(ne,"CaptureStage");function $({view:r,className:e,kind:t}){let n=(0,z.useId)(),o=(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(K,{}),(0,a.jsx)("span",{children:r.label})]}),i={onClick:r.onSwitch,"aria-describedby":n,"data-testid":"sekyro-capture-mode-switch","data-mode":r.to};return(0,a.jsxs)(a.Fragment,{children:[t==="chip"?(0,a.jsx)(H,{kind:"chip",className:e,...i,children:o}):(0,a.jsx)("button",{type:"button",className:e,...i,children:o}),(0,a.jsx)("span",{id:n,className:"sekyro-visually-hidden",children:r.description})]})}s($,"H");u($,"ModeSwitchChip");function K(){return(0,a.jsxs)("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",className:"sekyro-icon",children:[(0,a.jsx)("path",{d:"M4 7.5h2.2l1.4-1.9h8.8l1.4 1.9H20a1.6 1.6 0 0 1 1.6 1.6v8.3A1.6 1.6 0 0 1 20 19H4a1.6 1.6 0 0 1-1.6-1.6V9.1A1.6 1.6 0 0 1 4 7.5Z"}),(0,a.jsx)("path",{d:"M15.4 11.9a3.5 3.5 0 0 0-6.1-1.4M15.4 11.9h-2.1m2.1 0V9.8"}),(0,a.jsx)("path",{d:"M8.6 13.4a3.5 3.5 0 0 0 6.1 1.4M8.6 13.4h2.1m-2.1 0v2.1"})]})}s(K,"D");u(K,"FlipCameraIcon");function Y(){return(0,a.jsxs)("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",className:"sekyro-icon sekyro-icon--sm",children:[(0,a.jsx)("path",{d:"M4 7.5h2.2l1.4-1.9h8.8l1.4 1.9H20a1.6 1.6 0 0 1 1.6 1.6v8.3A1.6 1.6 0 0 1 20 19H4a1.6 1.6 0 0 1-1.6-1.6V9.1A1.6 1.6 0 0 1 4 7.5Z"}),(0,a.jsx)("path",{d:"M3 3l18 18"})]})}s(Y,"G");u(Y,"CameraOffIcon");var ie=typeof window>"u"?E.useEffect:E.useLayoutEffect,R="data-sekyro-ramp",se=[["background-color","transparent"],["background-image","none"]];function q(r){let e=[],t=r.ownerDocument;for(let i=r;i!==null&&i!==t.documentElement;i=i.parentElement){if(!(i instanceof HTMLElement)&&!(i instanceof SVGElement))continue;let y=i.style;for(let[d,m]of se){let p=y.getPropertyValue(d),k=y.getPropertyPriority(d);y.setProperty(d,m,"important"),e.push(()=>{p===""?y.removeProperty(d):y.setProperty(d,p,k)})}}let n=t.documentElement,o=n.hasAttribute(R);return n.setAttribute(R,""),o||e.push(()=>n.removeAttribute(R)),()=>{for(let i of e.reverse())i()}}s(q,"z");u(q,"clearAncestorBackdrops");function X(r){return{position:"fixed",inset:0,minWidth:"100vw",minHeight:"100lvh",margin:0,padding:0,border:0,zIndex:-1,pointerEvents:"none",backgroundColor:T(r)}}s(X,"B");u(X,"washStyle");function J(r){return{position:"absolute",inset:0,pointerEvents:"none",backgroundColor:T(r)}}s(J,"Y");u(J,"coverStyle");function oe({colour:r}){let e=(0,E.useRef)(null),t=r!==null;return ie(()=>{let n=e.current?.parentElement;if(!(!t||n===null||n===void 0))return q(n)},[t]),r===null||typeof document>"u"?null:(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)("div",{ref:e,"aria-hidden":"true","data-testid":"sekyro-screen-ramp-cover","data-colour":r,style:J(r)}),(0,Z.createPortal)((0,v.jsx)("div",{"aria-hidden":"true","data-testid":"sekyro-screen-ramp","data-colour":r,style:X(r)}),document.body)]})}s(oe,"de");u(oe,"ScreenRampLayer");export{W as a,ne as b,$ as c,oe as d};
|
|
2
2
|
/*! Bundled license information:
|
|
3
3
|
|
|
4
4
|
react-dom/cjs/react-dom.production.js:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as g}from"./chunk-ZWC7BGLD.js";import{L as b,a as k,b as y,c as x}from"./chunk-CUFOLAZN.js";import{a as n}from"./chunk-5QL6W6FW.js";import{a as c,c as f}from"./chunk-4FHWXBOB.js";var l=f(k(),1),t=f(k(),1),w=f(k(),1),r=f(y(),1),e=f(y(),1);var i,C=(i=class extends w.Component{constructor(){super(...arguments),this.state={failed:!1}}static getDerivedStateFromError(){return{failed:!0}}render(){return this.state.failed?this.props.fallback:this.props.children}},c(i,"c"),i);n(C,"LoadBoundary");var j=C,F={load:n(()=>import("./flow-views-JC2DWBW3-
|
|
1
|
+
import{a as g}from"./chunk-ZWC7BGLD.js";import{L as b,a as k,b as y,c as x}from"./chunk-CUFOLAZN.js";import{a as n}from"./chunk-5QL6W6FW.js";import{a as c,c as f}from"./chunk-4FHWXBOB.js";var l=f(k(),1),t=f(k(),1),w=f(k(),1),r=f(y(),1),e=f(y(),1);var i,C=(i=class extends w.Component{constructor(){super(...arguments),this.state={failed:!1}}static getDerivedStateFromError(){return{failed:!0}}render(){return this.state.failed?this.props.fallback:this.props.children}},c(i,"c"),i);n(C,"LoadBoundary");var j=C,F={load:n(()=>import("./flow-views-JC2DWBW3-GP5F4777.js"),"load")};function S({view:s,i18n:a,quiet:o,...m}){let[d,h]=(0,t.useState)(0),u=(0,t.useMemo)(()=>(0,t.lazy)(()=>F.load().then(v=>({default:v[s]}))),[s,d]),p=(0,r.jsxs)(b,{tone:"danger",children:[(0,r.jsx)("span",{children:a.t("errors.network_error")}),(0,r.jsx)(x,{kind:"secondary",onClick:c(()=>h(v=>v+1),"onClick"),children:a.t("common.retry")})]});return(0,r.jsx)(j,{fallback:p,children:(0,r.jsx)(t.Suspense,{fallback:o===!0?null:(0,r.jsx)("p",{role:"status","aria-busy":"true",className:"sekyro-text-muted",children:a.t("common.loading")}),children:(0,r.jsx)(u,{...m,i18n:a})})},d)}c(S,"k");n(S,"Flow");var q=(0,l.createContext)(void 0);function B({i18n:s,lead:a,refresh:o,actions:m}){let d=(0,l.useContext)(q),[h,u]=(0,l.useState)(!1);if(d!==void 0)return(0,e.jsx)(S,{view:"HandoffView",i18n:s,url:d,lead:a,...o!==void 0?{refresh:o}:{},footer:m});let p=n(()=>{o!==void 0&&(u(!0),o().catch(()=>{}).finally(()=>u(!1)))},"again");return(0,e.jsx)(g,{tone:"brand",icon:"smartphone",title:s.t("handoff.title"),testId:"sekyro-phone-handoff",actions:(0,e.jsxs)(e.Fragment,{children:[m,o!==void 0?(0,e.jsx)(x,{kind:"secondary",full:!0,disabled:h,onClick:p,children:s.t("common.refresh")}):null]}),children:(0,e.jsx)("p",{children:a})})}c(B,"K");n(B,"PhoneHandoff");export{j as a,S as b,q as c,B as d};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g as X}from"./chunk-E6VD556C.js";import{a as z,b as ee}from"./chunk-CUFOLAZN.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-FUMXKBXY.js";import{a as z,b as ee}from"./chunk-CUFOLAZN.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 +1 @@
|
|
|
1
|
-
import{a as I,b as vt,c as xt,d as B,e as St}from"./chunk-IWZRAEUN.js";import{c as ct,d as ut,e as dt,i as mt,j as gt,k as ft,l as pt,m as yt,p as wt,s as Mt}from"./chunk-LSBUNQZU.js";import{b as kt,c as bt}from"./chunk-F4Q2Q4OC.js";import{b as N}from"./chunk-HHII35OF.js";import{d as et,e as ot,f as nt}from"./chunk-FKDRZIZ4.js";import{a as G,b as q,c as D,d as lt}from"./chunk-P7K7ELYZ.js";import{g as it,i as st,j as at,k as ht,l as rt}from"./chunk-JS2IXPNL.js";import{a as l}from"./chunk-4FHWXBOB.js";var P=Object.freeze({sensing:{key:"sensing",reticle:"searching",minDurationMs:900},too_far:{key:"too_far",reticle:"coaching",minDurationMs:1400},too_close:{key:"too_close",reticle:"coaching",minDurationMs:1400},edge_clipped:{key:"edge_clipped",reticle:"coaching",minDurationMs:1400},wrong_shape:{key:"wrong_shape",reticle:"coaching",minDurationMs:1400},tilted:{key:"tilted",reticle:"coaching",minDurationMs:1400},too_dark:{key:"too_dark",reticle:"coaching",minDurationMs:1400},too_bright:{key:"too_bright",reticle:"coaching",minDurationMs:1400},blurry:{key:"blurry",reticle:"coaching",minDurationMs:1400},focus_far:{key:"focus_far",reticle:"coaching",minDurationMs:1600},glare:{key:"glare",reticle:"coaching",minDurationMs:1400},hold_still:{key:"hold_still",reticle:"locking",minDurationMs:900},processing:{key:"processing",reticle:"processing",minDurationMs:800},side_captured:{key:"side_captured",reticle:"flip",minDurationMs:2600},captured:{key:"captured",reticle:"done",minDurationMs:800}});function Xt(i){return i.framing==="no_document"?"sensing":i.framing==="too_far"?"too_far":i.framing==="too_close"?"too_close":i.framing==="edge_clipped"?"edge_clipped":i.framing==="wrong_shape"?"wrong_shape":i.framing==="tilted"?"tilted":i.lighting==="too_dark"?"too_dark":i.lighting==="too_bright"?"too_bright":i.glare==="glare"?"glare":i.blur==="blurry"?"blurry":"hold_still"}l(Xt,"Ct");var _,Vt=(_=class{constructor(t=2600,e=.35){this.windowMs=t,this.decayPerSecond=e,this.votes=[],this.current=P.sensing,this.currentSinceMs=null}reset(){this.votes=[],this.current=P.sensing,this.currentSinceMs=null}force(t,e){return this.votes=[],this.current=P[t],this.currentSinceMs=e,this.current}tick(t,e){if(this.currentSinceMs===null&&(this.currentSinceMs=e),this.votes.push({key:t,atMs:e}),this.votes=this.votes.filter(r=>e-r.atMs<=this.windowMs),e-this.currentSinceMs<this.current.minDurationMs)return this.current;let s=new Map;for(let r of this.votes){let o=(e-r.atMs)/1e3,n=this.decayPerSecond**o;s.set(r.key,(s.get(r.key)??0)+n)}let a=this.current.key,h=-1;for(let[r,o]of s)o>h&&(h=o,a=r);return a!==this.current.key&&(this.current=P[a],this.currentSinceMs=e),this.current}},l(_,"P"),_),Yt=Object.freeze({MAX_AREA_FRAC:.92,TILT_MAX_SIDE_RATIO:1.3,GLARE_MAX_SPECULAR_FRAC:.025});function Zt(i){let{data:t,width:e,height:s}=i,a=e*s;if(a===0)return 0;let h=0;for(let r=0;r<a;r++){let o=r*4;.299*(t[o]??0)+.587*(t[o+1]??0)+.114*(t[o+2]??0)>=252&&h++}return h/a}l(Zt,"Rt");function Jt(i){let t=l((n,u)=>Math.hypot(u.x-n.x,u.y-n.y),"t"),e=t(i.topLeft,i.topRight),s=t(i.bottomLeft,i.bottomRight),a=t(i.topLeft,i.bottomLeft),h=t(i.topRight,i.bottomRight),r=Math.max(e,s)/Math.max(1e-6,Math.min(e,s)),o=Math.max(a,h)/Math.max(1e-6,Math.min(a,h));return Math.max(r,o)}l(Jt,"he");function $t(i){let t={...vt,...i.thresholds},e=Yt,{quad:s,frameWidth:a,frameHeight:h,measures:r}=i,o=i.format==="ID-3",n="ok";if(s===null)n="no_document";else if(o){let d=B(s),m=a>0?d.width/a:0,y=d.height>0?d.width/d.height:0;m<t.ID3_BAND_MIN_WIDTH_FRAC?n="too_far":Rt(s,a,h,t.EDGE_CLIP_MARGIN_PX)?n="edge_clipped":(y<t.ID3_BAND_ASPECT_MIN||y>t.ID3_BAND_ASPECT_MAX)&&(n="wrong_shape")}else{let d=xt(s,a,h),m=B(s),y=Math.max(m.width,m.height)/Math.max(1e-6,Math.min(m.width,m.height));d<t.MIN_AREA_FRAC?n="too_far":d>e.MAX_AREA_FRAC?n="too_close":Rt(s,a,h,t.EDGE_CLIP_MARGIN_PX)?n="edge_clipped":bt(i.format,y)?Jt(s)>e.TILT_MAX_SIDE_RATIO&&(n="tilted"):n="wrong_shape"}let u=r.exposure>=t.GUIDE_EXPOSURE?"ok":r.meanLuma<(G[0]+G[1])/2?"too_dark":"too_bright",c=r.sharpness>=t.GUIDE_SHARPNESS?"ok":"blurry",g=r.specularFraction>=e.GLARE_MAX_SPECULAR_FRAC?"glare":"ok";return{framing:n,lighting:u,blur:c,glare:g,acceptable:n==="ok"&&u==="ok"&&c==="ok"&&g==="ok"}}l($t,"Ft");function Rt(i,t,e,s){return[i.topLeft,i.topRight,i.bottomRight,i.bottomLeft].some(a=>a.x<=s||a.y<=s||a.x>=t-s||a.y>=e-s)}l(Rt,"Tt");var H=Object.freeze({width:1920,height:1080}),te=Object.freeze({width:3840,height:2160}),Ft=4096,ee=2560,ie=640,E=.15,T=Object.freeze({side:.2,above:.9,below:.3});function R(i){let t=[i.topLeft.x,i.topRight.x,i.bottomRight.x,i.bottomLeft.x],e=[i.topLeft.y,i.topRight.y,i.bottomRight.y,i.bottomLeft.y],s=Math.min(...t),a=Math.min(...e);return{x:s,y:a,width:Math.max(...t)-s,height:Math.max(...e)-a}}l(R,"w");function Wt(i,t){let e=Math.max(0,Math.floor(i.x)),s=Math.max(0,Math.floor(i.y)),a=Math.min(t.width,Math.ceil(i.x+i.width)),h=Math.min(t.height,Math.ceil(i.y+i.height));return a-e<16||h-s<16?null:{x:e,y:s,width:a-e,height:h-s}}l(Wt,"Lt");function se(i,t,e){if(i===null||t.width<=0||t.height<=0)return null;let s=R(i);if(s.width<=0||s.height<=0)return null;let a=e==="ID-3"?{x:s.x-s.width*T.side,y:s.y-s.width*T.above,width:s.width*(1+2*T.side),height:s.height+s.width*(T.above+T.below)}:{x:s.x-s.width*E,y:s.y-s.height*E,width:s.width*(1+2*E),height:s.height*(1+2*E)};return Wt(a,t)}l(se,"de");function Gt(i,t,e){let s=Math.max(i,t);return s>0?Math.min(1,e/s):1}l(Gt,"V");function qt(i,t,e,s,a=ee){let h=t.width>0?e.width/t.width:1,r=t.height>0?e.height/t.height:1,o=i===null?null:{topLeft:{x:i.topLeft.x*h,y:i.topLeft.y*r},topRight:{x:i.topRight.x*h,y:i.topRight.y*r},bottomRight:{x:i.bottomRight.x*h,y:i.bottomRight.y*r},bottomLeft:{x:i.bottomLeft.x*h,y:i.bottomLeft.y*r}},n=se(o,e,s)??{x:0,y:0,width:e.width,height:e.height},u=Gt(n.width,n.height,a),c=Math.max(1,Math.round(n.width*u)),g=Math.max(1,Math.round(n.height*u)),d=null;if(o!==null){let m=R(o);d=Wt({x:(m.x-n.x)*u,y:(m.y-n.y)*u,width:m.width*u,height:m.height*u},{width:c,height:g})}return{crop:n,width:c,height:g,docRegion:d}}l(qt,"X");var ae=960,j=[{width:1920,height:1080},{width:2560,height:1440}];function he(i){let t=Number.isFinite(i)&&i>0?Math.min(1,i):.85;return j.find(e=>e.height*t>=ae)??j[j.length-1]}l(he,"pe");function re(i,t,e,s=te,a){if(e==="LOW")return null;let h=a===void 0?null:he(a.fill),r=h!==null&&Math.max(h.width,h.height)>Math.max(s.width,s.height)?h:s,o=i?.width?.max,n=i?.height?.max;if(typeof o!="number"||typeof n!="number"||o<=0||n<=0)return null;let u=Math.max(o,n),c=Math.min(o,n),g=Math.min(u,Math.max(r.width,r.height)),d=Math.min(c,Math.min(r.width,r.height));return g<=Math.max(t.width,t.height)?null:{width:{ideal:g},height:{ideal:d}}}l(re,"Pt");function oe(i){let t={},e=i?.imageWidth,s=i?.imageHeight;if(typeof e?.max=="number"&&e.max>0){let a=typeof s?.max=="number"&&s.max>0?e.max/s.max:1.3333333333333333,h=a>=1?Ft:Ft*a,r=Math.min(e.max,Math.floor(h)),o=typeof e.step=="number"&&e.step>0?e.step:1,n=typeof e.min=="number"?e.min:0;r=Math.max(n,n+Math.floor((r-n)/o)*o),t.imageWidth=r}return i?.fillLightMode?.includes("off")===!0&&(t.fillLightMode="off"),t}l(oe,"Ot");function ne(i,t){if(i.width<=0||i.height<=0||t.width<=0||t.height<=0)return!1;let e=i.width>i.height,s=t.width>t.height;return e!==s&&i.width!==i.height&&t.width!==t.height?!1:Math.max(i.width,i.height)>=1.2*Math.max(t.width,t.height)}l(ne,"It");function le(i,t,e,s){if(e===null)return!1;let a=R(i),h=R(e);if(t.width<=0||s.width<=0)return!1;let r=a.width/t.width,o=h.width/s.width;return o>0&&r>=.6*o&&r<=1.25*o}l(le,"zt");var _t=3500,ce=.92;function Nt(){let i=globalThis.ImageCapture;return typeof i=="function"?i:null}l(Nt,"Bt");function ue(i){return/AppleWebKit\//.test(i)&&!/(Chrome|Chromium|Edg|OPR)\//.test(i)}l(ue,"ge");function de(i,t=typeof navigator>"u"?"":navigator.userAgent){return Nt()!==null&&!ue(t)&&i!=null&&i.kind==="video"&&i.readyState==="live"}l(de,"Nt");function Dt(i,t){return new Promise((e,s)=>{let a=setTimeout(()=>s(new Error("takePhoto timed out")),t);i.then(h=>{clearTimeout(a),e(h)},h=>{clearTimeout(a),s(h)})})}l(Dt,"Qt");function U(i,t){let e=document.createElement("canvas");return e.width=i,e.height=t,e}l(U,"j");function me(i,t){return new Promise((e,s)=>{i.toBlob(a=>a?e(a):s(new Error("toBlob failed")),"image/jpeg",t)})}l(me,"be");async function Bt(i,t,e,s,a){let h=U(e,s),r=U(1,1);try{let o=h.getContext("2d");if(o===null)throw new Error("2d context unavailable");o.imageSmoothingQuality="high",o.drawImage(i,t.x,t.y,t.width,t.height,0,0,e,s);let n=await me(h,ce),u=a===null?null:ct({topLeft:{x:a.x,y:a.y},topRight:{x:a.x+a.width,y:a.y},bottomRight:{x:a.x+a.width,y:a.y+a.height},bottomLeft:{x:a.x,y:a.y+a.height}},{width:e,height:s},{width:e,height:s}),c=ut(h,u),g=Gt(e,s,ie);return r.width=Math.max(1,Math.round(e*g)),r.height=Math.max(1,Math.round(s*g)),r.getContext("2d")?.drawImage(h,0,0,r.width,r.height),{blob:n,previewDataUrl:r.toDataURL("image/jpeg",.85),sharpness:c}}finally{h.width=0,h.height=0,r.width=0,r.height=0}}l(Bt,"Wt");function ge(i,t){let e=Math.min(1,t/i.width),s=U(Math.max(1,Math.round(i.width*e)),Math.max(1,Math.round(i.height*e)));try{let a=s.getContext("2d",{willReadFrequently:!0});return a===null?null:(a.imageSmoothingQuality="high",a.drawImage(i,0,0,s.width,s.height),a.getImageData(0,0,s.width,s.height))}finally{s.width=0,s.height=0}}l(ge,"ye");async function fe(i,t,e,s){let a={width:Math.max(1,i.videoWidth),height:Math.max(1,i.videoHeight)},h=qt(t,e,a,s);return{...await Bt(i,h.crop,h.width,h.height,h.docRegion),docRegion:h.docRegion,source:"video",width:h.width,height:h.height}}l(fe,"Ut");async function pe(i,t,e,s,a){let h=Nt();if(h===null)return null;let r=null;try{let o=new h(a.track),n=await Dt(o.getPhotoCapabilities?.()??Promise.resolve({}),_t).catch(()=>({})),u=await Dt(o.takePhoto(oe(n)),_t);r=await createImageBitmap(u);let c={width:i.videoWidth,height:i.videoHeight};if(!ne(r,c))return null;let g=ge(r,a.detectWidth),d=null;g!==null&&t!==null&&(d=await a.detect(g).catch(()=>null));let m=g??{width:r.width,height:r.height};d!==null&&!le(d,m,t,e)&&(d=null);let y=qt(d,m,r,s);return{...await Bt(r,y.crop,y.width,y.height,y.docRegion),docRegion:y.docRegion,source:"photo",width:y.width,height:y.height}}catch{return null}finally{r?.close()}}l(pe,"Ht");var Z=Object.freeze({width:3840,height:2160,lensSelection:!0,continuousFocus:!0,refocusBeforePhotoMs:350,zoomMax:2,zoomNoFocusInfo:1.5,zoomMinSourcePx:2160,fillDistanceM:Object.freeze({id1:.11,id3:.15}),focusMarginFrac:.2,stillSharpnessMin:.16,stillRefusalsMax:2,focusFarFillFrac:.45,noDocFarHintMs:1500,zoomFallbackMs:8e3}),M=l((i,t,e)=>typeof i=="number"&&Number.isFinite(i)&&i>=t&&i<=e?i:void 0,"y");function Qe(i){let t=Z,e=i!==null&&typeof i=="object"?i:{},s=e.fillDistanceM!==null&&typeof e.fillDistanceM=="object"?e.fillDistanceM:{},a=l((h,r)=>typeof h=="boolean"?h:r,"o");return{width:M(e.width,640,7680)??t.width,height:M(e.height,480,4320)??t.height,lensSelection:a(e.lensSelection,t.lensSelection),continuousFocus:a(e.continuousFocus,t.continuousFocus),refocusBeforePhotoMs:M(e.refocusBeforePhotoMs,0,2e3)??t.refocusBeforePhotoMs,zoomMax:M(e.zoomMax,1,5)??t.zoomMax,zoomNoFocusInfo:M(e.zoomNoFocusInfo,1,5)??t.zoomNoFocusInfo,zoomMinSourcePx:M(e.zoomMinSourcePx,0,8e3)??t.zoomMinSourcePx,fillDistanceM:{id1:M(s.id1,.03,1)??t.fillDistanceM.id1,id3:M(s.id3,.03,1)??t.fillDistanceM.id3},focusMarginFrac:M(e.focusMarginFrac,0,2)??t.focusMarginFrac,stillSharpnessMin:M(e.stillSharpnessMin,0,10)??t.stillSharpnessMin,stillRefusalsMax:M(e.stillRefusalsMax,0,10)??t.stillRefusalsMax,focusFarFillFrac:M(e.focusFarFillFrac,0,1)??t.focusFarFillFrac,noDocFarHintMs:M(e.noDocFarHintMs,0,6e4)??t.noDocFarHintMs,zoomFallbackMs:M(e.zoomFallbackMs,0,12e4)??t.zoomFallbackMs}}l(Qe,"Xe");var K="sekyro.doc.camera";function ye(){try{let i=globalThis.localStorage?.getItem(K);return typeof i=="string"&&i!==""?i:null}catch{return null}}l(ye,"ke");function Tt(i){try{i===null?globalThis.localStorage?.removeItem(K):globalThis.localStorage?.setItem(K,i)}catch{}}l(Tt,"Kt");var X=l((i,t)=>Array.isArray(i?.focusMode)&&i.focusMode.includes(t),"G");function At(i,t,e){if(!X(i,"single-shot"))return null;let s=l(a=>Math.min(1,Math.max(0,Number.isFinite(a)?a:.5)),"s");return{focusMode:"single-shot",pointsOfInterest:[{x:s(t),y:s(e)}]}}l(At,"J");function we(i,t,e,s=Z){let a=i?.zoom?.min,h=i?.zoom?.max;if(typeof h!="number"||h<=1)return 1;let r=e==="ID-3"?s.fillDistanceM.id3:s.fillDistanceM.id1,o=i?.focusDistance?.min,n;if(typeof o=="number"&&o>0&&o<1){if(n=o*(1+s.focusMarginFrac)/r,n<=1.05)return 1}else{if(Math.min(t.width,t.height)<s.zoomMinSourcePx)return 1;n=s.zoomNoFocusInfo}let u=Math.min(n,s.zoomMax,h);typeof a=="number"&&(u=Math.max(u,a));let c=i?.zoom?.step;return typeof c=="number"&&c>0&&(u=Math.round(u/c)*c),u>1.01?Number(u.toFixed(2)):1}l(we,"Xt");function V(i){try{return i.getVideoTracks?.()[0]}catch{return}}l(V,"Z");function Ct(i){if(i!==null)for(let t of i.getTracks())t.stop()}l(Ct,"Vt");function Me(i){try{let t=V(i)?.getCapabilities?.();return!Array.isArray(t?.focusMode)||t.focusMode.includes("continuous")}catch{return!0}}l(Me,"Me");async function ke(i){let t=l(h=>({audio:!1,video:{...h,width:{ideal:i.base.width},height:{ideal:i.base.height}}}),"t"),e=l(h=>i.getUserMedia(t({deviceId:{exact:h}})),"e"),s=l(()=>i.getUserMedia(t({facingMode:{ideal:"environment"}})),"s");if(i.lensSelection){let h=ye();if(h!==null)try{return{stream:await e(h),lens:"stored"}}catch{Tt(null)}}let a=await s();if(!i.lensSelection||i.enumerateDevices===void 0)return{stream:a,lens:"default"};try{let h=rt(await i.enumerateDevices()).slice(0,3);if(h.length===0)return{stream:a,lens:"default"};let r=null;for(let o of h){let n=a!==null?V(a)?.getSettings?.().deviceId:void 0;if(a===null||n!==o){Ct(a),a=null;try{a=await e(o)}catch{continue}}if(r??(r=o),Me(a))return Tt(o),{stream:a,lens:"selected"}}if(a!==null&&r!==null&&V(a)?.getSettings?.().deviceId===r)return{stream:a,lens:"selected"};if(Ct(a),a=null,r!==null)try{return{stream:await e(r),lens:"selected"}}catch{}return{stream:await s(),lens:"default"}}catch{return{stream:a??await s(),lens:"default"}}}l(ke,"jt");var C=null;async function be(i){return C===null&&(C=(await import("./detector-scanic-P2RTEQUV-A5WTP2Q7.js")).detectQuad),C(i)}l(be,"De");async function ve(i){let t=N(i);return t===null?null:{topLeft:{x:t.x,y:t.y},topRight:{x:t.x+t.width,y:t.y},bottomRight:{x:t.x+t.width,y:t.y+t.height},bottomLeft:{x:t.x,y:t.y+t.height}}}l(ve,"we");function Ue(){C===null&&import("./detector-scanic-P2RTEQUV-A5WTP2Q7.js").then(i=>{C=i.detectQuad}).catch(()=>{})}l(Ue,"fi");var Lt=4e3,xe=2,zt=3,Ot=Object.freeze({LOW:3,MID:5,HIGH:6}),Se=600,Re=8,Fe=3,_e=90,Y=Object.freeze({manualShutterMs:6e3,detectedNoLockMs:1950});function Ke(i){let t=i!==null&&typeof i=="object"?i:{},e=l((s,a,h)=>typeof s=="number"&&Number.isFinite(s)&&s>=a&&s<=h?s:void 0,"e");return{manualShutterMs:e(t.manualShutterMs,1e3,6e4)??Y.manualShutterMs,detectedNoLockMs:e(t.steadyMs,300,3e4)!==void 0?t.steadyMs+(e(t.lockMs,0,1e4)??450):Y.detectedNoLockMs}}l(Ke,"gi");var x,Xe=(x=class{constructor(t){this.upgraded=!1,this.tickCosts=[],this.photoOff=!1,this.demotion=null,this.torchOn=!1,this.stillRefusals=0,this.zoom=1,this.positioningSince=null,this.detectedSince=null,this.lastSeenAt=null,this.lastGuideQuad=null,this.lastGuideCard=null,this.lastStillAt=null,this.probeAt=null,this.lastOcrReady=null,this.shutterOffered=!1,this.stats=x.freshStats(),this.handlers=new Map,this.stream=null,this.timer=null,this.state="idle",this.lastGuidance=null,this.attempt=0,this.capturing=!1,this.feedback=new Vt,this.lastFeedbackKey=null,this.lastQuad=null,this.lastDetect=null,this.frameWatch=null,this.reopened=!1,this.lit=!1,this.blackTicks=0,this.offEnded=null,this.opts=t,this.gate=new St(t.format??"ID-1",t.thresholds);let e=t.deviceClass??nt(ot());this.deviceClass=e,this.camera=t.camera??Z,this.shutterTuning=t.shutter??Y,this.guideTuning=t.guideLock??yt,this.guideLock=new wt(this.guideTuning),this.cadenceMs=1e3/Ot[e]}on(t,e){let s=this.handlers.get(t);return s||(s=new Set,this.handlers.set(t,s)),s.add(e),()=>s?.delete(e)}emit(t,e){for(let s of[...this.handlers.get(t)??[]])s(e)}async start(){let t=this.state==="error"?this.resumePlayback():null,e=++this.attempt;if(this.clearFrameWatch(),this.gate.reset(),this.resetSide(),this.feedback.reset(),this.lastFeedbackKey=null,this.lastGuidance=null,this.capturing=!1,this.lit=!1,this.blackTicks=0,t!==null&&await t&&e===this.attempt){this.setState("positioning"),this.scheduleTick(e),this.watchFrames(e);return}if(e===this.attempt){this.releaseStream(),ht(),this.setState("preflight");try{let s=this.opts.getUserMedia??(r=>navigator.mediaDevices.getUserMedia(r));this.setState("acquiring");let a=this.opts.enumerateDevices??(this.opts.getUserMedia===void 0&&typeof navigator<"u"&&navigator.mediaDevices?.enumerateDevices?()=>navigator.mediaDevices.enumerateDevices():void 0),h=await ke({getUserMedia:s,...a!==void 0?{enumerateDevices:a}:{},lensSelection:this.camera.lensSelection,base:H});if(e!==this.attempt){for(let r of h.stream.getTracks())r.stop();return}if(this.stream=h.stream,et(this.stream),at(this.stream),this.watchEnded(e),this.opts.upgradeResolution!==!1&&await this.upgradeResolution(),e!==this.attempt||(await this.applyFocusAndZoom(),e!==this.attempt)||(this.opts.video.srcObject=this.stream,await this.opts.video.play().catch(()=>{}),e!==this.attempt))return;this.setState("positioning"),this.scheduleTick(e),this.watchFrames(e)}catch(s){if(e!==this.attempt)return;let a=st(s),h=it(s);this.setState("error"),this.emit("error",{kind:a,retryable:!0,detail:h===void 0?{phase:"acquiring"}:{phase:"acquiring",name:h}})}}}resumePlayback(){let t=this.opts.video,e=this.videoTrack();if(this.stream===null||e===null||e.readyState!=="live"||t.srcObject!==this.stream)return null;try{return Promise.resolve(t.play()).then(()=>this.framesNow(),()=>!1)}catch{return null}}framesNow(){let t=this.opts.video;return this.opts.hasFrames!==void 0?this.opts.hasFrames(t):!t.paused&&t.readyState>=2&&t.videoWidth>0}watchFrames(t){let e=this.opts.firstFrameMs??Lt;e<=0||(this.clearFrameWatch(),this.frameWatch=setTimeout(()=>{if(this.frameWatch=null,!(t!==this.attempt||this.state!=="positioning")){if(this.framesNow()&&this.blackTicks<zt){this.reopened=!1;return}this.cameraDead(t)}},e))}clearFrameWatch(){this.frameWatch!==null&&clearTimeout(this.frameWatch),this.frameWatch=null}watchEnded(t){this.offEnded?.(),this.offEnded=null;let e=this.videoTrack();if(e===null||typeof e.addEventListener!="function")return;let s=l(()=>{t===this.attempt&&(this.state==="positioning"||this.state==="acquiring")&&this.cameraDead(t)},"s");e.addEventListener("ended",s),this.offEnded=()=>e.removeEventListener?.("ended",s)}cameraDead(t){if(t!==this.attempt)return;let e=this.videoTrack(),s=e!==null&&e.readyState==="live"&&!e.muted&&this.opts.video.paused&&!this.framesNow();if(!s&&!this.reopened){this.reopened=!0,this.start();return}this.attempt+=1,this.timer!==null&&(this.opts.clearTimer??clearTimeout)(this.timer),this.timer=null,this.clearFrameWatch(),s||this.releaseStream(),this.reopened=!1,this.setState("error"),this.emit("error",{kind:"generic",retryable:!0,detail:{phase:"acquiring"}})}releaseStream(){if(this.offEnded?.(),this.offEnded=null,this.stream)for(let t of this.stream.getTracks())t.stop();this.stream=null,this.opts.video.srcObject!==null&&this.opts.video.srcObject!==void 0&&(this.opts.video.srcObject=null)}rearm(t){t!==void 0&&(this.opts.side=t),this.probeAt=null,this.gate.reset(),this.resetSide(),this.feedback.reset(),this.lastFeedbackKey=null,this.lastGuidance=null,this.capturing=!1,this.stillRefusals=0,this.state==="captured"&&(this.setState("positioning"),this.scheduleTick(this.attempt))}async captureNow(){if(this.state!=="positioning"||this.capturing)return;let t=this.opts.video,e=this.lastDetect?.width??Math.max(1,t.videoWidth),s=this.lastDetect?.height??Math.max(1,t.videoHeight),a=this.lastQuad??this.lastGuideQuad??{topLeft:{x:0,y:0},topRight:{x:e,y:0},bottomRight:{x:e,y:s},bottomLeft:{x:0,y:s}},h=(this.opts.now??(()=>performance.now()))(),r=this.feedback.force("processing",h);this.lastFeedbackKey=r.key,this.emit("feedback",r),await this.fire(this.attempt,this.lastOcrReady!==null?this.lastOcrReady.quad:a,{width:e,height:s,tickSharpness:this.lastDetect?.tickSharpness??0},this.lastOcrReady?.via??"manual")}captureReport(){let t=this.stats;return{...this.opts.side!==void 0?{side:this.opts.side}:{},format:this.opts.format??"ID-1",deviceClass:this.deviceClass,video:{width:this.opts.video.videoWidth||0,height:this.opts.video.videoHeight||0},zoom:this.zoom,...t.zoomFallbackAtMs!==void 0?{zoomFallbackAtMs:t.zoomFallbackAtMs}:{},...t.msToCapture!==void 0?{msToCapture:t.msToCapture}:{},...t.via!==void 0?{via:t.via}:{},...t.shutterAtMs!==void 0?{shutterAtMs:t.shutterAtMs}:{},...t.shutterReason!==void 0?{shutterReason:t.shutterReason}:{},...t.shotGlare!==void 0?{shotGlare:t.shotGlare}:{},...t.shotSharpness!==void 0?{shotSharpness:t.shotSharpness}:{},...t.msSincePrevShot!==void 0?{msSincePrevShot:t.msSincePrevShot}:{},...this.demotion!==null?{demotedFrom:this.demotion.from,demotedBy:this.demotion.by,...this.demotion.tickMedianMs!==void 0?{tickMedianMs:this.demotion.tickMedianMs}:{}}:{},ticks:t.ticks,quadFraming:{...t.quadFraming},qualityBlockers:{...t.qualityBlockers},guideBlockers:{...t.guideBlockers},stillRefusals:t.stillRefusals,...this.ocrReport()}}ocrReport(){let t=this.opts.ocr;if(t===void 0)return{};let e=(this.opts.format??"ID-1")==="ID-3"||this.opts.side==="single"?"single":this.opts.side==="verso"?"verso":"recto",s=t.report(e,this.stats.via,(this.opts.now??(()=>performance.now()))());return s===null?{}:{ocr:s}}static freshStats(){return{ticks:0,quadFraming:{},qualityBlockers:{},guideBlockers:{},stillRefusals:0}}setLockTuning(t){this.guideTuning=t,this.guideLock.setTuning(t)}setGuide(t){t===void 0?delete this.opts.guide:this.opts.guide=t,this.guideLock.reset(),this.probeAt=null}sideProbe(t,e,s,a){if(this.opts.sideProbe!==!0||!e)return;if(this.probeAt===null){this.probeAt=a;return}if(a-this.probeAt<Se)return;this.probeAt=a;let h=this.guideRegion(t),r=h.x*t.width,o=h.y*t.height,n=h.width*t.width,u=h.height*t.height,c={topLeft:{x:r,y:o},topRight:{x:r+n,y:o},bottomRight:{x:r+n,y:o+u},bottomLeft:{x:r,y:o+u}};return dt(N,A(t,c),!0,s)}guideRegion(t){let e=t.width/Math.max(1,t.height),s=this.opts.guide;if(s!==void 0&&s.viewAspect>0){let o={width:s.viewAspect,height:1},n={x:s.rect.x*s.viewAspect,y:s.rect.y,width:s.rect.width*s.viewAspect,height:s.rect.height};return gt(o,n,e,0)}let a=kt(this.opts.format??"ID-1").center,h=.86,r=h*e/a;return r>.84&&(r=.84,h=r*a/e),{x:(1-h)/2,y:(1-r)/2,width:h,height:r}}resetSide(){this.positioningSince=null,this.detectedSince=null,this.lastSeenAt=null,this.guideLock.reset(),this.lastGuideQuad=null,this.lastGuideCard=null,this.lastOcrReady=null,this.opts.ocr?.reset(),this.stats=x.freshStats(),this.shutterOffered&&(this.shutterOffered=!1,this.emit("shutter",{available:!1}))}withdrawShutter(){this.shutterOffered&&(this.shutterOffered=!1,this.emit("shutter",{available:!1}))}zoomFallback(t){let e=this.videoTrack();if(e===null||this.zoom<=1)return;let s=this.focusCaps(),a=typeof s?.zoom?.min=="number"?Math.max(s.zoom.min,1):1;this.zoom=a,this.stats.zoomFallbackAtMs=Math.round(t-(this.positioningSince??t)),this.guideLock.reset(),this.gate.reset(),e.applyConstraints({advanced:[{zoom:a}]}).catch(()=>{})}offerShutter(t,e){this.shutterOffered||(this.shutterOffered=!0,this.stats.shutterAtMs=Math.round(e-(this.positioningSince??e)),this.stats.shutterReason=t,this.emit("shutter",{available:!0,reason:t}))}torchAvailable(){try{return this.stream?.getVideoTracks?.()[0]?.getCapabilities?.()?.torch===!0}catch{return!1}}async setTorch(t){this.torchOn=t;try{await this.stream?.getVideoTracks?.()[0]?.applyConstraints({advanced:[{torch:t}]})}catch{}}destroy(){if(this.attempt+=1,this.timer!==null&&(this.opts.clearTimer??clearTimeout)(this.timer),this.timer=null,this.clearFrameWatch(),this.offEnded?.(),this.offEnded=null,this.stream)for(let t of this.stream.getTracks())t.stop();this.stream=null,this.opts.video.srcObject=null}async upgradeResolution(){try{let t=this.stream?.getVideoTracks?.()[0];if(t===void 0)return;let e=t.getSettings?.()??{},s=re(t.getCapabilities?.(),{width:e.width??0,height:e.height??0},this.deviceClass,{width:this.camera.width,height:this.camera.height},this.opts.ocr?.liveMrzOn===!0?{fill:this.guideRegion({width:1080,height:1920}).width}:void 0);s!==null&&(await t.applyConstraints(s),this.upgraded=!0)}catch{}}demote(t,e){if(this.tickCosts=null,this.deviceClass==="LOW"||(this.demotion={from:this.deviceClass,by:t,...e!==null?{tickMedianMs:Math.round(Math.min(6e4,e))}:{}},this.deviceClass="LOW",this.cadenceMs=1e3/Ot.LOW,!this.upgraded))return;this.upgraded=!1;let s=this.videoTrack();s!==null&&(this.guideLock.reset(),this.gate.reset(),s.applyConstraints({width:{ideal:H.width},height:{ideal:H.height}}).catch(()=>{}))}profileTick(t){if(this.deviceClass!=="LOW"&&this.opts.ocr?.tier==="low"){this.demote("ocr_tier",null);return}let e=this.tickCosts;if(e===null||(e.push(t),e.length<Re))return;let s=[...e].sort((h,r)=>h-r),a=(s[s.length-1>>1]+s[s.length>>1])/2;a>_e?this.demote("tick_cost",a):this.tickCosts=null}focusCaps(){try{return this.videoTrack()?.getCapabilities?.()??null}catch{return null}}async applyFocusAndZoom(){let t=this.videoTrack();if(t===null)return;let e=this.focusCaps();this.camera.continuousFocus&&X(e,"continuous")&&await t.applyConstraints({advanced:[{focusMode:"continuous"}]}).catch(()=>{});let s={width:0,height:0};try{let h=t.getSettings?.()??{};s={width:h.width??0,height:h.height??0}}catch{}let a=we(e,s,this.opts.format??"ID-1",this.camera);if(a>1)try{await t.applyConstraints({advanced:[{zoom:a}]}),this.zoom=a}catch{this.zoom=1}}async focusAt(t,e){let s=this.videoTrack(),a=At(this.focusCaps(),t,e);if(!(s===null||a===null))try{await s.applyConstraints({advanced:[a]}),(this.opts.setTimer??setTimeout)(()=>{this.restoreContinuous()},1500)}catch{}}async restoreContinuous(){let t=this.videoTrack();t===null||!this.camera.continuousFocus||!X(this.focusCaps(),"continuous")||await t.applyConstraints({advanced:[{focusMode:"continuous"}]}).catch(()=>{})}async refocusOn(t,e){let s=this.camera.refocusBeforePhotoMs,a=this.videoTrack();if(s<=0||a===null||e.width<=0||e.height<=0)return;let h=R(t),r=At(this.focusCaps(),(h.x+h.width/2)/e.width,(h.y+h.height/2)/e.height);if(r!==null)try{let o=this.opts.setTimer??setTimeout;await Promise.race([a.applyConstraints({advanced:[r]}),new Promise(n=>{o(()=>n(),Le)})]),await new Promise(n=>{o(()=>n(),s)})}catch{}}videoTrack(){try{return this.stream?.getVideoTracks?.()[0]??null}catch{return null}}async takeStill(t,e,s){if(this.opts.captureStill!==void 0)return this.opts.captureStill(this.opts.video,t,e);let a=this.opts.format??"ID-1",h=this.videoTrack();if(s&&this.opts.photoCapture!==!1&&this.deviceClass!=="LOW"&&!this.photoOff&&!this.torchOn&&h!==null&&de(h)){await this.refocusOn(t,e);let r=await pe(this.opts.video,t,e,a,{track:h,detect:this.detector(),detectWidth:I});if(this.restoreContinuous(),r!==null)return r;this.photoOff=!0}return fe(this.opts.video,t,e,a)}detector(){return this.opts.detect??((this.opts.format??"ID-1")==="ID-3"?ve:be)}setState(t){this.state=t,this.emit("statechange",{state:t})}scheduleTick(t){let e=this.opts.setTimer??setTimeout;this.timer=e(()=>{this.tick(t)},this.cadenceMs)}async tick(t){if(t!==this.attempt||this.state!=="positioning"||this.capturing)return;let e=this.opts.now??(()=>performance.now()),s=this.opts.grabDetectFrame??Et,a=this.detector(),h=this.opts.workClock??(()=>performance.now()),r=h(),o=s(this.opts.video,I);if(o===null){this.scheduleTick(t);return}if(!this.lit){if(q(o)>xe)this.lit=!0,this.blackTicks=0;else if(++this.blackTicks>=zt&&this.frameWatch===null&&(this.opts.firstFrameMs??Lt)>0){this.cameraDead(t);return}}let n=null;try{n=await a(o)}catch{n=null}if(t!==this.attempt)return;let u=n!==null?A(o,n):o,c=e(),g={sharpness:D(u),exposure:lt(u),meanLuma:q(u),specularFraction:Zt(u)},d=$t({format:this.opts.format??"ID-1",quad:n,frameWidth:o.width,frameHeight:o.height,measures:g,...this.opts.thresholds!==void 0?{thresholds:this.opts.thresholds}:{}}),m=this.gate.tick({timestampMs:c,quad:n,quality:g,frameWidth:o.width,frameHeight:o.height}),y=(this.opts.format??"ID-1")!=="ID-3",p=y?ft(o,this.guideRegion(o),{edgePeakFrac:this.guideTuning.edgePeakFrac}):mt,f=this.guideLock.tick(p,c);this.lastGuideQuad=f.detected?pt(p):null,this.lastGuideCard=f.detected?{glare:p.cardGlare,sharpness:p.sharpness}:null;let S=this.sideProbe(o,f.detected,p.fill,c),w=this.capturing?null:this.ocrTick(o,n,p,f.detected,d,c),k=f.detected&&(f.still||f.blocker==="locking")||n!==null&&m.stableTicks>=2;this.lastOcrReady?.via==="live_mrz"&&y&&!k&&(this.lastOcrReady=null),this.positioningSince??(this.positioningSince=c);let b=this.stats;if(b.ticks+=1,b.quadFraming[d.framing]=(b.quadFraming[d.framing]??0)+1,d.framing==="ok"&&!m.ready){let v=d.lighting!=="ok"?d.lighting:d.glare!=="ok"?"glare":d.blur!=="ok"?"blurry":"steadying";b.qualityBlockers[v]=(b.qualityBlockers[v]??0)+1}b.guideBlockers[f.blocker]=(b.guideBlockers[f.blocker]??0)+1,n!==null||f.detected?(this.detectedSince??(this.detectedSince=c),this.lastSeenAt=c):this.detectedSince=null,this.lastSeenAt!==null&&c-this.lastSeenAt<=Ie?c-this.positioningSince>=this.shutterTuning.manualShutterMs?this.offerShutter("timeout",c):w?.suspendQuality!==!0&&this.detectedSince!==null&&c-this.detectedSince>=this.shutterTuning.detectedNoLockMs&&this.offerShutter("detected_no_lock",c):this.withdrawShutter();let J=c-(this.lastSeenAt??this.positioningSince);this.zoom>1&&this.camera.zoomFallbackMs>0&&J>=this.camera.zoomFallbackMs&&this.zoomFallback(c);let $=w?.suspendQuality!==!0&&(m.ready&&n!==null||f.ready&&this.lastGuideQuad!==null)||this.lastOcrReady!==null,Ht=!$&&w?.suspendQuality!==!0&&(f.detected&&f.blocker==="locking"||n!==null&&m.stableTicks>=2);this.emit("checks",{engine:"docv1",p:m.p,plausible:m.plausible,stableTicks:m.stableTicks,quad:m.quad,frameWidth:o.width,frameHeight:o.height,analysis:d,ready:$,locking:Ht,guide:{detected:f.detected,blocker:f.blocker,still:f.still,fill:p.fill,shape:p.shape,content:p.content,offsetX:p.offsetX,offsetY:p.offsetY},...w!==null&&w.mode!=="off"?{ocr:{mode:w.mode,...w.mrz?{mrz:w.mrz}:{},...w.lock?{lock:w.lock}:{}}}:w?.mrz?{ocr:{mode:w.mode,mrz:w.mrz}}:{},...S!==void 0?{side:S}:{}}),this.lastQuad=m.plausible?n:null,this.lastDetect={width:o.width,height:o.height,tickSharpness:g.sharpness};let F=Xt(d);d.framing!=="ok"&&f.detected&&(F=Oe(f.blocker,p.brightness<this.guideTuning.darkBrightness)),F==="blurry"&&n!==null&&Te(n,o,this.opts.format??"ID-1")>=this.camera.focusFarFillFrac&&(F="focus_far"),F==="sensing"&&this.zoom>1&&this.camera.noDocFarHintMs>0&&J>=this.camera.noDocFarHintMs&&(F="focus_far");let W=this.feedback.tick(F,c);W.key!==this.lastFeedbackKey&&(this.lastFeedbackKey=W.key,this.emit("feedback",W)),m.guidanceKey!==this.lastGuidance&&(this.lastGuidance=m.guidanceKey,this.emit("guidance",{key:m.guidanceKey}));let jt=h()-r;if(this.stats.ticks>Fe&&this.profileTick(jt),this.capturing)return;let tt=w?.suspendQuality!==!0,Qt=tt&&m.ready&&n!==null,L=tt&&f.ready&&this.lastGuideQuad!==null,z=this.lastOcrReady;if(z!==null&&this.opts.autoCapture!==!1){let v=this.feedback.force("processing",c);this.lastFeedbackKey=v.key,this.emit("feedback",v);let O=D(A(o,z.quad));await this.fire(t,z.quad,{width:o.width,height:o.height,tickSharpness:O},z.via);return}if((Qt||L)&&this.opts.autoCapture!==!1){let v=this.feedback.force("processing",c);this.lastFeedbackKey=v.key,this.emit("feedback",v);let O=L?this.lastGuideQuad:n,Ut=L?f.via==="steady"?"guide_steady":"guide_good":"quad",Kt=L?D(A(o,O)):g.sharpness;await this.fire(t,O,{width:o.width,height:o.height,tickSharpness:Kt},Ut);return}this.scheduleTick(t)}async fire(t,e,s,a){this.capturing=!0;let h=this.opts.grabDetectFrame??Et,r=this.opts.setTimer??setTimeout,o={width:s.width,height:s.height},n=this.opts.workClock??(()=>performance.now()),u=n();try{let c={still:await this.takeStill(e,o,!0),sharpness:s.tickSharpness};if(t!==this.attempt)return;let g=c.still.source==="photo"||this.deviceClass==="LOW"?0:Ae;for(let p=0;p<g;p++){let f=n()-u;if(f+Pt+f/(p+1)>Ce)break;if(await new Promise(k=>{r(()=>k(),Pt)}),t!==this.attempt)return;let S=h(this.opts.video,I);if(S===null)continue;let w=D(A(S,e));if(w>c.sharpness*ze){let k=await this.takeStill(e,o,!1);if(t!==this.attempt)return;c={still:k,sharpness:w}}}if(t!==this.attempt)return;let d=c.still.sharpness;if(this.opts.autoCapture!==!1&&a!=="manual"&&typeof d=="number"&&d>=0&&d<this.camera.stillSharpnessMin&&this.stillRefusals<this.camera.stillRefusalsMax){this.stillRefusals+=1,this.stats.stillRefusals+=1,this.guideLock.reset(),this.lastOcrReady=null,(a==="text_lock"||a==="live_mrz")&&this.opts.ocr?.rearmFace();let p=(this.opts.now??(()=>performance.now()))(),f=this.feedback.force("focus_far",p);this.lastFeedbackKey=f.key,this.emit("feedback",f),this.capturing=!1,this.gate.reset(),this.scheduleTick(t);return}this.stillRefusals=0;let m=(this.opts.now??(()=>performance.now()))();this.stats.via=a,this.stats.msToCapture=Math.round(m-(this.positioningSince??m));let y=this.lastGuideCard;y!==null&&(this.stats.shotGlare=Math.round(Math.min(1,Math.max(0,y.glare))*1e3)/1e3,this.stats.shotSharpness=Math.round(Math.min(1e6,Math.max(0,y.sharpness)))),this.lastStillAt!==null&&(this.stats.msSincePrevShot=Math.round(Math.min(36e5,Math.max(0,m-this.lastStillAt)))),this.lastStillAt=m,this.shutterOffered&&(this.shutterOffered=!1,this.emit("shutter",{available:!1})),this.setState("captured"),this.emit("artifacts",{keyframe:c.still.blob,previewDataUrl:c.still.previewDataUrl,...this.opts.side!==void 0?{side:this.opts.side}:{},...c.still.docRegion!==void 0?{docRegion:c.still.docRegion}:{},...(()=>{let p=a==="live_mrz"?this.opts.ocr?.liveCapture():null;return p?{liveMrz:p}:{}})()})}catch{if(t!==this.attempt)return;this.capturing=!1,this.gate.reset(),this.guideLock.reset(),this.lastOcrReady=null,(a==="text_lock"||a==="live_mrz")&&this.opts.ocr?.rearmFace(),this.scheduleTick(t)}}ocrTick(t,e,s,a,h,r){let o=this.opts.ocr,n=this.opts.video;if(o===void 0||!o.hasEngine)return this.lastOcrReady=null,null;let u=n.videoWidth,c=n.videoHeight;if(u<=0||c<=0||t.width<=0||t.height<=0)return null;let g=(this.opts.format??"ID-1")==="ID-3",d=this.guideRegion(t),m={x:d.x*u,y:d.y*c,w:d.width*u,h:d.height*c},y=u/t.width,p=c/t.height,f;g&&e!==null?f=De(R(e),y,p,u,c):f=Mt(m,o.bandTop,c);let S=g?h.glare==="ok":s.cardGlare<=this.guideTuning.glareMax,w=g?h.blur==="ok":s.sharpness>=this.guideTuning.sharpnessMin,k=o.tick({atMs:r,video:n,mrzFace:g||this.opts.side==="verso"||this.opts.side==="single",present:g||e!==null||a,card:m,band:f,portrait:c>u,glareOk:S,sharpOk:w});if(k.ready&&k.via!==void 0){let b=g?e??It(d,t):this.lastGuideQuad??It(d,t);this.lastOcrReady={quad:b,via:k.via}}else this.lastOcrReady=null;return k}},l(x,"i"),x);function De(i,t,e,s,a){let h=Math.min(s,i.width*1.06*t),r=Math.min(a,Math.max(i.height*1.6*e,h/5)),o=(i.y+i.height/2)*e,n=Math.max(0,Math.min(s-h,(i.x-i.width*.03)*t)),u=Math.max(0,Math.min(a-r,o-r/2));return{x:n,y:u,w:h,h:r}}l(De,"Te");function It(i,t){let e=i.x*t.width,s=i.y*t.height,a=(i.x+i.width)*t.width,h=(i.y+i.height)*t.height;return{topLeft:{x:e,y:s},topRight:{x:a,y:s},bottomRight:{x:a,y:h},bottomLeft:{x:e,y:h}}}l(It,"$t");function Te(i,t,e){let s=R(i);return t.width<=0||t.height<=0?0:e==="ID-3"?s.width/t.width:s.width*s.height/(t.width*t.height)}l(Te,"Re");var Ae=2,Pt=260,Ce=1200,Le=600,ze=1.08,Q=null;function Et(i,t){let e=i.videoWidth,s=i.videoHeight;if(e===0||s===0)return null;let a=Math.min(1,t/e),h=Math.round(e*a),r=Math.round(s*a);Q??(Q=document.createElement("canvas"));let o=Q;o.width!==h&&(o.width=h),o.height!==r&&(o.height=r);let n=o.getContext("2d",{willReadFrequently:!0});return n===null?null:(n.imageSmoothingQuality=e/Math.max(1,h)>4?"high":"low",n.drawImage(i,0,0,h,r),n.getImageData(0,0,h,r))}l(Et,"ie");function A(i,t){let e=[t.topLeft.x,t.topRight.x,t.bottomRight.x,t.bottomLeft.x],s=[t.topLeft.y,t.topRight.y,t.bottomRight.y,t.bottomLeft.y],a=Math.max(0,Math.floor(Math.min(...e))),h=Math.max(0,Math.floor(Math.min(...s))),r=Math.min(i.width,Math.ceil(Math.max(...e))),o=Math.min(i.height,Math.ceil(Math.max(...s))),n=Math.max(1,r-a),u=Math.max(1,o-h),c=new Uint8ClampedArray(n*u*4);for(let g=0;g<u;g++){let d=((h+g)*i.width+a)*4;c.set(i.data.subarray(d,d+n*4),g*n*4)}return{data:c,width:n,height:u,colorSpace:i.colorSpace}}l(A,"C");function Oe(i,t){return i==="glare"?"glare":i==="too_small"?"too_far":i==="too_big"?"too_close":t?"too_dark":i==="blurry"?"blurry":i==="off_center"?"edge_clipped":i==="no_card"?"sensing":"hold_still"}l(Oe,"Pe");var Ie=1200;export{Qe as a,Ue as b,Lt as c,xe as d,zt as e,Ot as f,Se as g,Re as h,Fe as i,_e as j,Y as k,Ke as l,Xe as m,De as n,Ae as o,Pt as p,Ce as q,Le as r};
|
|
1
|
+
import{a as I,b as vt,c as xt,d as B,e as St}from"./chunk-IWZRAEUN.js";import{c as ct,d as ut,e as dt,i as mt,j as gt,k as ft,l as pt,m as yt,p as wt,s as Mt}from"./chunk-LSBUNQZU.js";import{b as kt,c as bt}from"./chunk-F4Q2Q4OC.js";import{b as N}from"./chunk-HHII35OF.js";import{d as et,e as ot,f as nt}from"./chunk-RCDZUOGM.js";import{a as G,b as q,c as D,d as lt}from"./chunk-P7K7ELYZ.js";import{g as it,i as st,j as at,k as ht,l as rt}from"./chunk-JS2IXPNL.js";import{a as l}from"./chunk-4FHWXBOB.js";var P=Object.freeze({sensing:{key:"sensing",reticle:"searching",minDurationMs:900},too_far:{key:"too_far",reticle:"coaching",minDurationMs:1400},too_close:{key:"too_close",reticle:"coaching",minDurationMs:1400},edge_clipped:{key:"edge_clipped",reticle:"coaching",minDurationMs:1400},wrong_shape:{key:"wrong_shape",reticle:"coaching",minDurationMs:1400},tilted:{key:"tilted",reticle:"coaching",minDurationMs:1400},too_dark:{key:"too_dark",reticle:"coaching",minDurationMs:1400},too_bright:{key:"too_bright",reticle:"coaching",minDurationMs:1400},blurry:{key:"blurry",reticle:"coaching",minDurationMs:1400},focus_far:{key:"focus_far",reticle:"coaching",minDurationMs:1600},glare:{key:"glare",reticle:"coaching",minDurationMs:1400},hold_still:{key:"hold_still",reticle:"locking",minDurationMs:900},processing:{key:"processing",reticle:"processing",minDurationMs:800},side_captured:{key:"side_captured",reticle:"flip",minDurationMs:2600},captured:{key:"captured",reticle:"done",minDurationMs:800}});function Xt(i){return i.framing==="no_document"?"sensing":i.framing==="too_far"?"too_far":i.framing==="too_close"?"too_close":i.framing==="edge_clipped"?"edge_clipped":i.framing==="wrong_shape"?"wrong_shape":i.framing==="tilted"?"tilted":i.lighting==="too_dark"?"too_dark":i.lighting==="too_bright"?"too_bright":i.glare==="glare"?"glare":i.blur==="blurry"?"blurry":"hold_still"}l(Xt,"Ct");var _,Vt=(_=class{constructor(t=2600,e=.35){this.windowMs=t,this.decayPerSecond=e,this.votes=[],this.current=P.sensing,this.currentSinceMs=null}reset(){this.votes=[],this.current=P.sensing,this.currentSinceMs=null}force(t,e){return this.votes=[],this.current=P[t],this.currentSinceMs=e,this.current}tick(t,e){if(this.currentSinceMs===null&&(this.currentSinceMs=e),this.votes.push({key:t,atMs:e}),this.votes=this.votes.filter(r=>e-r.atMs<=this.windowMs),e-this.currentSinceMs<this.current.minDurationMs)return this.current;let s=new Map;for(let r of this.votes){let o=(e-r.atMs)/1e3,n=this.decayPerSecond**o;s.set(r.key,(s.get(r.key)??0)+n)}let a=this.current.key,h=-1;for(let[r,o]of s)o>h&&(h=o,a=r);return a!==this.current.key&&(this.current=P[a],this.currentSinceMs=e),this.current}},l(_,"P"),_),Yt=Object.freeze({MAX_AREA_FRAC:.92,TILT_MAX_SIDE_RATIO:1.3,GLARE_MAX_SPECULAR_FRAC:.025});function Zt(i){let{data:t,width:e,height:s}=i,a=e*s;if(a===0)return 0;let h=0;for(let r=0;r<a;r++){let o=r*4;.299*(t[o]??0)+.587*(t[o+1]??0)+.114*(t[o+2]??0)>=252&&h++}return h/a}l(Zt,"Rt");function Jt(i){let t=l((n,u)=>Math.hypot(u.x-n.x,u.y-n.y),"t"),e=t(i.topLeft,i.topRight),s=t(i.bottomLeft,i.bottomRight),a=t(i.topLeft,i.bottomLeft),h=t(i.topRight,i.bottomRight),r=Math.max(e,s)/Math.max(1e-6,Math.min(e,s)),o=Math.max(a,h)/Math.max(1e-6,Math.min(a,h));return Math.max(r,o)}l(Jt,"he");function $t(i){let t={...vt,...i.thresholds},e=Yt,{quad:s,frameWidth:a,frameHeight:h,measures:r}=i,o=i.format==="ID-3",n="ok";if(s===null)n="no_document";else if(o){let d=B(s),m=a>0?d.width/a:0,y=d.height>0?d.width/d.height:0;m<t.ID3_BAND_MIN_WIDTH_FRAC?n="too_far":Rt(s,a,h,t.EDGE_CLIP_MARGIN_PX)?n="edge_clipped":(y<t.ID3_BAND_ASPECT_MIN||y>t.ID3_BAND_ASPECT_MAX)&&(n="wrong_shape")}else{let d=xt(s,a,h),m=B(s),y=Math.max(m.width,m.height)/Math.max(1e-6,Math.min(m.width,m.height));d<t.MIN_AREA_FRAC?n="too_far":d>e.MAX_AREA_FRAC?n="too_close":Rt(s,a,h,t.EDGE_CLIP_MARGIN_PX)?n="edge_clipped":bt(i.format,y)?Jt(s)>e.TILT_MAX_SIDE_RATIO&&(n="tilted"):n="wrong_shape"}let u=r.exposure>=t.GUIDE_EXPOSURE?"ok":r.meanLuma<(G[0]+G[1])/2?"too_dark":"too_bright",c=r.sharpness>=t.GUIDE_SHARPNESS?"ok":"blurry",g=r.specularFraction>=e.GLARE_MAX_SPECULAR_FRAC?"glare":"ok";return{framing:n,lighting:u,blur:c,glare:g,acceptable:n==="ok"&&u==="ok"&&c==="ok"&&g==="ok"}}l($t,"Ft");function Rt(i,t,e,s){return[i.topLeft,i.topRight,i.bottomRight,i.bottomLeft].some(a=>a.x<=s||a.y<=s||a.x>=t-s||a.y>=e-s)}l(Rt,"Tt");var H=Object.freeze({width:1920,height:1080}),te=Object.freeze({width:3840,height:2160}),Ft=4096,ee=2560,ie=640,E=.15,T=Object.freeze({side:.2,above:.9,below:.3});function R(i){let t=[i.topLeft.x,i.topRight.x,i.bottomRight.x,i.bottomLeft.x],e=[i.topLeft.y,i.topRight.y,i.bottomRight.y,i.bottomLeft.y],s=Math.min(...t),a=Math.min(...e);return{x:s,y:a,width:Math.max(...t)-s,height:Math.max(...e)-a}}l(R,"w");function Wt(i,t){let e=Math.max(0,Math.floor(i.x)),s=Math.max(0,Math.floor(i.y)),a=Math.min(t.width,Math.ceil(i.x+i.width)),h=Math.min(t.height,Math.ceil(i.y+i.height));return a-e<16||h-s<16?null:{x:e,y:s,width:a-e,height:h-s}}l(Wt,"Lt");function se(i,t,e){if(i===null||t.width<=0||t.height<=0)return null;let s=R(i);if(s.width<=0||s.height<=0)return null;let a=e==="ID-3"?{x:s.x-s.width*T.side,y:s.y-s.width*T.above,width:s.width*(1+2*T.side),height:s.height+s.width*(T.above+T.below)}:{x:s.x-s.width*E,y:s.y-s.height*E,width:s.width*(1+2*E),height:s.height*(1+2*E)};return Wt(a,t)}l(se,"de");function Gt(i,t,e){let s=Math.max(i,t);return s>0?Math.min(1,e/s):1}l(Gt,"V");function qt(i,t,e,s,a=ee){let h=t.width>0?e.width/t.width:1,r=t.height>0?e.height/t.height:1,o=i===null?null:{topLeft:{x:i.topLeft.x*h,y:i.topLeft.y*r},topRight:{x:i.topRight.x*h,y:i.topRight.y*r},bottomRight:{x:i.bottomRight.x*h,y:i.bottomRight.y*r},bottomLeft:{x:i.bottomLeft.x*h,y:i.bottomLeft.y*r}},n=se(o,e,s)??{x:0,y:0,width:e.width,height:e.height},u=Gt(n.width,n.height,a),c=Math.max(1,Math.round(n.width*u)),g=Math.max(1,Math.round(n.height*u)),d=null;if(o!==null){let m=R(o);d=Wt({x:(m.x-n.x)*u,y:(m.y-n.y)*u,width:m.width*u,height:m.height*u},{width:c,height:g})}return{crop:n,width:c,height:g,docRegion:d}}l(qt,"X");var ae=960,j=[{width:1920,height:1080},{width:2560,height:1440}];function he(i){let t=Number.isFinite(i)&&i>0?Math.min(1,i):.85;return j.find(e=>e.height*t>=ae)??j[j.length-1]}l(he,"pe");function re(i,t,e,s=te,a){if(e==="LOW")return null;let h=a===void 0?null:he(a.fill),r=h!==null&&Math.max(h.width,h.height)>Math.max(s.width,s.height)?h:s,o=i?.width?.max,n=i?.height?.max;if(typeof o!="number"||typeof n!="number"||o<=0||n<=0)return null;let u=Math.max(o,n),c=Math.min(o,n),g=Math.min(u,Math.max(r.width,r.height)),d=Math.min(c,Math.min(r.width,r.height));return g<=Math.max(t.width,t.height)?null:{width:{ideal:g},height:{ideal:d}}}l(re,"Pt");function oe(i){let t={},e=i?.imageWidth,s=i?.imageHeight;if(typeof e?.max=="number"&&e.max>0){let a=typeof s?.max=="number"&&s.max>0?e.max/s.max:1.3333333333333333,h=a>=1?Ft:Ft*a,r=Math.min(e.max,Math.floor(h)),o=typeof e.step=="number"&&e.step>0?e.step:1,n=typeof e.min=="number"?e.min:0;r=Math.max(n,n+Math.floor((r-n)/o)*o),t.imageWidth=r}return i?.fillLightMode?.includes("off")===!0&&(t.fillLightMode="off"),t}l(oe,"Ot");function ne(i,t){if(i.width<=0||i.height<=0||t.width<=0||t.height<=0)return!1;let e=i.width>i.height,s=t.width>t.height;return e!==s&&i.width!==i.height&&t.width!==t.height?!1:Math.max(i.width,i.height)>=1.2*Math.max(t.width,t.height)}l(ne,"It");function le(i,t,e,s){if(e===null)return!1;let a=R(i),h=R(e);if(t.width<=0||s.width<=0)return!1;let r=a.width/t.width,o=h.width/s.width;return o>0&&r>=.6*o&&r<=1.25*o}l(le,"zt");var _t=3500,ce=.92;function Nt(){let i=globalThis.ImageCapture;return typeof i=="function"?i:null}l(Nt,"Bt");function ue(i){return/AppleWebKit\//.test(i)&&!/(Chrome|Chromium|Edg|OPR)\//.test(i)}l(ue,"ge");function de(i,t=typeof navigator>"u"?"":navigator.userAgent){return Nt()!==null&&!ue(t)&&i!=null&&i.kind==="video"&&i.readyState==="live"}l(de,"Nt");function Dt(i,t){return new Promise((e,s)=>{let a=setTimeout(()=>s(new Error("takePhoto timed out")),t);i.then(h=>{clearTimeout(a),e(h)},h=>{clearTimeout(a),s(h)})})}l(Dt,"Qt");function U(i,t){let e=document.createElement("canvas");return e.width=i,e.height=t,e}l(U,"j");function me(i,t){return new Promise((e,s)=>{i.toBlob(a=>a?e(a):s(new Error("toBlob failed")),"image/jpeg",t)})}l(me,"be");async function Bt(i,t,e,s,a){let h=U(e,s),r=U(1,1);try{let o=h.getContext("2d");if(o===null)throw new Error("2d context unavailable");o.imageSmoothingQuality="high",o.drawImage(i,t.x,t.y,t.width,t.height,0,0,e,s);let n=await me(h,ce),u=a===null?null:ct({topLeft:{x:a.x,y:a.y},topRight:{x:a.x+a.width,y:a.y},bottomRight:{x:a.x+a.width,y:a.y+a.height},bottomLeft:{x:a.x,y:a.y+a.height}},{width:e,height:s},{width:e,height:s}),c=ut(h,u),g=Gt(e,s,ie);return r.width=Math.max(1,Math.round(e*g)),r.height=Math.max(1,Math.round(s*g)),r.getContext("2d")?.drawImage(h,0,0,r.width,r.height),{blob:n,previewDataUrl:r.toDataURL("image/jpeg",.85),sharpness:c}}finally{h.width=0,h.height=0,r.width=0,r.height=0}}l(Bt,"Wt");function ge(i,t){let e=Math.min(1,t/i.width),s=U(Math.max(1,Math.round(i.width*e)),Math.max(1,Math.round(i.height*e)));try{let a=s.getContext("2d",{willReadFrequently:!0});return a===null?null:(a.imageSmoothingQuality="high",a.drawImage(i,0,0,s.width,s.height),a.getImageData(0,0,s.width,s.height))}finally{s.width=0,s.height=0}}l(ge,"ye");async function fe(i,t,e,s){let a={width:Math.max(1,i.videoWidth),height:Math.max(1,i.videoHeight)},h=qt(t,e,a,s);return{...await Bt(i,h.crop,h.width,h.height,h.docRegion),docRegion:h.docRegion,source:"video",width:h.width,height:h.height}}l(fe,"Ut");async function pe(i,t,e,s,a){let h=Nt();if(h===null)return null;let r=null;try{let o=new h(a.track),n=await Dt(o.getPhotoCapabilities?.()??Promise.resolve({}),_t).catch(()=>({})),u=await Dt(o.takePhoto(oe(n)),_t);r=await createImageBitmap(u);let c={width:i.videoWidth,height:i.videoHeight};if(!ne(r,c))return null;let g=ge(r,a.detectWidth),d=null;g!==null&&t!==null&&(d=await a.detect(g).catch(()=>null));let m=g??{width:r.width,height:r.height};d!==null&&!le(d,m,t,e)&&(d=null);let y=qt(d,m,r,s);return{...await Bt(r,y.crop,y.width,y.height,y.docRegion),docRegion:y.docRegion,source:"photo",width:y.width,height:y.height}}catch{return null}finally{r?.close()}}l(pe,"Ht");var Z=Object.freeze({width:3840,height:2160,lensSelection:!0,continuousFocus:!0,refocusBeforePhotoMs:350,zoomMax:2,zoomNoFocusInfo:1.5,zoomMinSourcePx:2160,fillDistanceM:Object.freeze({id1:.11,id3:.15}),focusMarginFrac:.2,stillSharpnessMin:.16,stillRefusalsMax:2,focusFarFillFrac:.45,noDocFarHintMs:1500,zoomFallbackMs:8e3}),M=l((i,t,e)=>typeof i=="number"&&Number.isFinite(i)&&i>=t&&i<=e?i:void 0,"y");function Qe(i){let t=Z,e=i!==null&&typeof i=="object"?i:{},s=e.fillDistanceM!==null&&typeof e.fillDistanceM=="object"?e.fillDistanceM:{},a=l((h,r)=>typeof h=="boolean"?h:r,"o");return{width:M(e.width,640,7680)??t.width,height:M(e.height,480,4320)??t.height,lensSelection:a(e.lensSelection,t.lensSelection),continuousFocus:a(e.continuousFocus,t.continuousFocus),refocusBeforePhotoMs:M(e.refocusBeforePhotoMs,0,2e3)??t.refocusBeforePhotoMs,zoomMax:M(e.zoomMax,1,5)??t.zoomMax,zoomNoFocusInfo:M(e.zoomNoFocusInfo,1,5)??t.zoomNoFocusInfo,zoomMinSourcePx:M(e.zoomMinSourcePx,0,8e3)??t.zoomMinSourcePx,fillDistanceM:{id1:M(s.id1,.03,1)??t.fillDistanceM.id1,id3:M(s.id3,.03,1)??t.fillDistanceM.id3},focusMarginFrac:M(e.focusMarginFrac,0,2)??t.focusMarginFrac,stillSharpnessMin:M(e.stillSharpnessMin,0,10)??t.stillSharpnessMin,stillRefusalsMax:M(e.stillRefusalsMax,0,10)??t.stillRefusalsMax,focusFarFillFrac:M(e.focusFarFillFrac,0,1)??t.focusFarFillFrac,noDocFarHintMs:M(e.noDocFarHintMs,0,6e4)??t.noDocFarHintMs,zoomFallbackMs:M(e.zoomFallbackMs,0,12e4)??t.zoomFallbackMs}}l(Qe,"Xe");var K="sekyro.doc.camera";function ye(){try{let i=globalThis.localStorage?.getItem(K);return typeof i=="string"&&i!==""?i:null}catch{return null}}l(ye,"ke");function Tt(i){try{i===null?globalThis.localStorage?.removeItem(K):globalThis.localStorage?.setItem(K,i)}catch{}}l(Tt,"Kt");var X=l((i,t)=>Array.isArray(i?.focusMode)&&i.focusMode.includes(t),"G");function At(i,t,e){if(!X(i,"single-shot"))return null;let s=l(a=>Math.min(1,Math.max(0,Number.isFinite(a)?a:.5)),"s");return{focusMode:"single-shot",pointsOfInterest:[{x:s(t),y:s(e)}]}}l(At,"J");function we(i,t,e,s=Z){let a=i?.zoom?.min,h=i?.zoom?.max;if(typeof h!="number"||h<=1)return 1;let r=e==="ID-3"?s.fillDistanceM.id3:s.fillDistanceM.id1,o=i?.focusDistance?.min,n;if(typeof o=="number"&&o>0&&o<1){if(n=o*(1+s.focusMarginFrac)/r,n<=1.05)return 1}else{if(Math.min(t.width,t.height)<s.zoomMinSourcePx)return 1;n=s.zoomNoFocusInfo}let u=Math.min(n,s.zoomMax,h);typeof a=="number"&&(u=Math.max(u,a));let c=i?.zoom?.step;return typeof c=="number"&&c>0&&(u=Math.round(u/c)*c),u>1.01?Number(u.toFixed(2)):1}l(we,"Xt");function V(i){try{return i.getVideoTracks?.()[0]}catch{return}}l(V,"Z");function Ct(i){if(i!==null)for(let t of i.getTracks())t.stop()}l(Ct,"Vt");function Me(i){try{let t=V(i)?.getCapabilities?.();return!Array.isArray(t?.focusMode)||t.focusMode.includes("continuous")}catch{return!0}}l(Me,"Me");async function ke(i){let t=l(h=>({audio:!1,video:{...h,width:{ideal:i.base.width},height:{ideal:i.base.height}}}),"t"),e=l(h=>i.getUserMedia(t({deviceId:{exact:h}})),"e"),s=l(()=>i.getUserMedia(t({facingMode:{ideal:"environment"}})),"s");if(i.lensSelection){let h=ye();if(h!==null)try{return{stream:await e(h),lens:"stored"}}catch{Tt(null)}}let a=await s();if(!i.lensSelection||i.enumerateDevices===void 0)return{stream:a,lens:"default"};try{let h=rt(await i.enumerateDevices()).slice(0,3);if(h.length===0)return{stream:a,lens:"default"};let r=null;for(let o of h){let n=a!==null?V(a)?.getSettings?.().deviceId:void 0;if(a===null||n!==o){Ct(a),a=null;try{a=await e(o)}catch{continue}}if(r??(r=o),Me(a))return Tt(o),{stream:a,lens:"selected"}}if(a!==null&&r!==null&&V(a)?.getSettings?.().deviceId===r)return{stream:a,lens:"selected"};if(Ct(a),a=null,r!==null)try{return{stream:await e(r),lens:"selected"}}catch{}return{stream:await s(),lens:"default"}}catch{return{stream:a??await s(),lens:"default"}}}l(ke,"jt");var C=null;async function be(i){return C===null&&(C=(await import("./detector-scanic-P2RTEQUV-A5WTP2Q7.js")).detectQuad),C(i)}l(be,"De");async function ve(i){let t=N(i);return t===null?null:{topLeft:{x:t.x,y:t.y},topRight:{x:t.x+t.width,y:t.y},bottomRight:{x:t.x+t.width,y:t.y+t.height},bottomLeft:{x:t.x,y:t.y+t.height}}}l(ve,"we");function Ue(){C===null&&import("./detector-scanic-P2RTEQUV-A5WTP2Q7.js").then(i=>{C=i.detectQuad}).catch(()=>{})}l(Ue,"fi");var Lt=4e3,xe=2,zt=3,Ot=Object.freeze({LOW:3,MID:5,HIGH:6}),Se=600,Re=8,Fe=3,_e=90,Y=Object.freeze({manualShutterMs:6e3,detectedNoLockMs:1950});function Ke(i){let t=i!==null&&typeof i=="object"?i:{},e=l((s,a,h)=>typeof s=="number"&&Number.isFinite(s)&&s>=a&&s<=h?s:void 0,"e");return{manualShutterMs:e(t.manualShutterMs,1e3,6e4)??Y.manualShutterMs,detectedNoLockMs:e(t.steadyMs,300,3e4)!==void 0?t.steadyMs+(e(t.lockMs,0,1e4)??450):Y.detectedNoLockMs}}l(Ke,"gi");var x,Xe=(x=class{constructor(t){this.upgraded=!1,this.tickCosts=[],this.photoOff=!1,this.demotion=null,this.torchOn=!1,this.stillRefusals=0,this.zoom=1,this.positioningSince=null,this.detectedSince=null,this.lastSeenAt=null,this.lastGuideQuad=null,this.lastGuideCard=null,this.lastStillAt=null,this.probeAt=null,this.lastOcrReady=null,this.shutterOffered=!1,this.stats=x.freshStats(),this.handlers=new Map,this.stream=null,this.timer=null,this.state="idle",this.lastGuidance=null,this.attempt=0,this.capturing=!1,this.feedback=new Vt,this.lastFeedbackKey=null,this.lastQuad=null,this.lastDetect=null,this.frameWatch=null,this.reopened=!1,this.lit=!1,this.blackTicks=0,this.offEnded=null,this.opts=t,this.gate=new St(t.format??"ID-1",t.thresholds);let e=t.deviceClass??nt(ot());this.deviceClass=e,this.camera=t.camera??Z,this.shutterTuning=t.shutter??Y,this.guideTuning=t.guideLock??yt,this.guideLock=new wt(this.guideTuning),this.cadenceMs=1e3/Ot[e]}on(t,e){let s=this.handlers.get(t);return s||(s=new Set,this.handlers.set(t,s)),s.add(e),()=>s?.delete(e)}emit(t,e){for(let s of[...this.handlers.get(t)??[]])s(e)}async start(){let t=this.state==="error"?this.resumePlayback():null,e=++this.attempt;if(this.clearFrameWatch(),this.gate.reset(),this.resetSide(),this.feedback.reset(),this.lastFeedbackKey=null,this.lastGuidance=null,this.capturing=!1,this.lit=!1,this.blackTicks=0,t!==null&&await t&&e===this.attempt){this.setState("positioning"),this.scheduleTick(e),this.watchFrames(e);return}if(e===this.attempt){this.releaseStream(),ht(),this.setState("preflight");try{let s=this.opts.getUserMedia??(r=>navigator.mediaDevices.getUserMedia(r));this.setState("acquiring");let a=this.opts.enumerateDevices??(this.opts.getUserMedia===void 0&&typeof navigator<"u"&&navigator.mediaDevices?.enumerateDevices?()=>navigator.mediaDevices.enumerateDevices():void 0),h=await ke({getUserMedia:s,...a!==void 0?{enumerateDevices:a}:{},lensSelection:this.camera.lensSelection,base:H});if(e!==this.attempt){for(let r of h.stream.getTracks())r.stop();return}if(this.stream=h.stream,et(this.stream),at(this.stream),this.watchEnded(e),this.opts.upgradeResolution!==!1&&await this.upgradeResolution(),e!==this.attempt||(await this.applyFocusAndZoom(),e!==this.attempt)||(this.opts.video.srcObject=this.stream,await this.opts.video.play().catch(()=>{}),e!==this.attempt))return;this.setState("positioning"),this.scheduleTick(e),this.watchFrames(e)}catch(s){if(e!==this.attempt)return;let a=st(s),h=it(s);this.setState("error"),this.emit("error",{kind:a,retryable:!0,detail:h===void 0?{phase:"acquiring"}:{phase:"acquiring",name:h}})}}}resumePlayback(){let t=this.opts.video,e=this.videoTrack();if(this.stream===null||e===null||e.readyState!=="live"||t.srcObject!==this.stream)return null;try{return Promise.resolve(t.play()).then(()=>this.framesNow(),()=>!1)}catch{return null}}framesNow(){let t=this.opts.video;return this.opts.hasFrames!==void 0?this.opts.hasFrames(t):!t.paused&&t.readyState>=2&&t.videoWidth>0}watchFrames(t){let e=this.opts.firstFrameMs??Lt;e<=0||(this.clearFrameWatch(),this.frameWatch=setTimeout(()=>{if(this.frameWatch=null,!(t!==this.attempt||this.state!=="positioning")){if(this.framesNow()&&this.blackTicks<zt){this.reopened=!1;return}this.cameraDead(t)}},e))}clearFrameWatch(){this.frameWatch!==null&&clearTimeout(this.frameWatch),this.frameWatch=null}watchEnded(t){this.offEnded?.(),this.offEnded=null;let e=this.videoTrack();if(e===null||typeof e.addEventListener!="function")return;let s=l(()=>{t===this.attempt&&(this.state==="positioning"||this.state==="acquiring")&&this.cameraDead(t)},"s");e.addEventListener("ended",s),this.offEnded=()=>e.removeEventListener?.("ended",s)}cameraDead(t){if(t!==this.attempt)return;let e=this.videoTrack(),s=e!==null&&e.readyState==="live"&&!e.muted&&this.opts.video.paused&&!this.framesNow();if(!s&&!this.reopened){this.reopened=!0,this.start();return}this.attempt+=1,this.timer!==null&&(this.opts.clearTimer??clearTimeout)(this.timer),this.timer=null,this.clearFrameWatch(),s||this.releaseStream(),this.reopened=!1,this.setState("error"),this.emit("error",{kind:"generic",retryable:!0,detail:{phase:"acquiring"}})}releaseStream(){if(this.offEnded?.(),this.offEnded=null,this.stream)for(let t of this.stream.getTracks())t.stop();this.stream=null,this.opts.video.srcObject!==null&&this.opts.video.srcObject!==void 0&&(this.opts.video.srcObject=null)}rearm(t){t!==void 0&&(this.opts.side=t),this.probeAt=null,this.gate.reset(),this.resetSide(),this.feedback.reset(),this.lastFeedbackKey=null,this.lastGuidance=null,this.capturing=!1,this.stillRefusals=0,this.state==="captured"&&(this.setState("positioning"),this.scheduleTick(this.attempt))}async captureNow(){if(this.state!=="positioning"||this.capturing)return;let t=this.opts.video,e=this.lastDetect?.width??Math.max(1,t.videoWidth),s=this.lastDetect?.height??Math.max(1,t.videoHeight),a=this.lastQuad??this.lastGuideQuad??{topLeft:{x:0,y:0},topRight:{x:e,y:0},bottomRight:{x:e,y:s},bottomLeft:{x:0,y:s}},h=(this.opts.now??(()=>performance.now()))(),r=this.feedback.force("processing",h);this.lastFeedbackKey=r.key,this.emit("feedback",r),await this.fire(this.attempt,this.lastOcrReady!==null?this.lastOcrReady.quad:a,{width:e,height:s,tickSharpness:this.lastDetect?.tickSharpness??0},this.lastOcrReady?.via??"manual")}captureReport(){let t=this.stats;return{...this.opts.side!==void 0?{side:this.opts.side}:{},format:this.opts.format??"ID-1",deviceClass:this.deviceClass,video:{width:this.opts.video.videoWidth||0,height:this.opts.video.videoHeight||0},zoom:this.zoom,...t.zoomFallbackAtMs!==void 0?{zoomFallbackAtMs:t.zoomFallbackAtMs}:{},...t.msToCapture!==void 0?{msToCapture:t.msToCapture}:{},...t.via!==void 0?{via:t.via}:{},...t.shutterAtMs!==void 0?{shutterAtMs:t.shutterAtMs}:{},...t.shutterReason!==void 0?{shutterReason:t.shutterReason}:{},...t.shotGlare!==void 0?{shotGlare:t.shotGlare}:{},...t.shotSharpness!==void 0?{shotSharpness:t.shotSharpness}:{},...t.msSincePrevShot!==void 0?{msSincePrevShot:t.msSincePrevShot}:{},...this.demotion!==null?{demotedFrom:this.demotion.from,demotedBy:this.demotion.by,...this.demotion.tickMedianMs!==void 0?{tickMedianMs:this.demotion.tickMedianMs}:{}}:{},ticks:t.ticks,quadFraming:{...t.quadFraming},qualityBlockers:{...t.qualityBlockers},guideBlockers:{...t.guideBlockers},stillRefusals:t.stillRefusals,...this.ocrReport()}}ocrReport(){let t=this.opts.ocr;if(t===void 0)return{};let e=(this.opts.format??"ID-1")==="ID-3"||this.opts.side==="single"?"single":this.opts.side==="verso"?"verso":"recto",s=t.report(e,this.stats.via,(this.opts.now??(()=>performance.now()))());return s===null?{}:{ocr:s}}static freshStats(){return{ticks:0,quadFraming:{},qualityBlockers:{},guideBlockers:{},stillRefusals:0}}setLockTuning(t){this.guideTuning=t,this.guideLock.setTuning(t)}setGuide(t){t===void 0?delete this.opts.guide:this.opts.guide=t,this.guideLock.reset(),this.probeAt=null}sideProbe(t,e,s,a){if(this.opts.sideProbe!==!0||!e)return;if(this.probeAt===null){this.probeAt=a;return}if(a-this.probeAt<Se)return;this.probeAt=a;let h=this.guideRegion(t),r=h.x*t.width,o=h.y*t.height,n=h.width*t.width,u=h.height*t.height,c={topLeft:{x:r,y:o},topRight:{x:r+n,y:o},bottomRight:{x:r+n,y:o+u},bottomLeft:{x:r,y:o+u}};return dt(N,A(t,c),!0,s)}guideRegion(t){let e=t.width/Math.max(1,t.height),s=this.opts.guide;if(s!==void 0&&s.viewAspect>0){let o={width:s.viewAspect,height:1},n={x:s.rect.x*s.viewAspect,y:s.rect.y,width:s.rect.width*s.viewAspect,height:s.rect.height};return gt(o,n,e,0)}let a=kt(this.opts.format??"ID-1").center,h=.86,r=h*e/a;return r>.84&&(r=.84,h=r*a/e),{x:(1-h)/2,y:(1-r)/2,width:h,height:r}}resetSide(){this.positioningSince=null,this.detectedSince=null,this.lastSeenAt=null,this.guideLock.reset(),this.lastGuideQuad=null,this.lastGuideCard=null,this.lastOcrReady=null,this.opts.ocr?.reset(),this.stats=x.freshStats(),this.shutterOffered&&(this.shutterOffered=!1,this.emit("shutter",{available:!1}))}withdrawShutter(){this.shutterOffered&&(this.shutterOffered=!1,this.emit("shutter",{available:!1}))}zoomFallback(t){let e=this.videoTrack();if(e===null||this.zoom<=1)return;let s=this.focusCaps(),a=typeof s?.zoom?.min=="number"?Math.max(s.zoom.min,1):1;this.zoom=a,this.stats.zoomFallbackAtMs=Math.round(t-(this.positioningSince??t)),this.guideLock.reset(),this.gate.reset(),e.applyConstraints({advanced:[{zoom:a}]}).catch(()=>{})}offerShutter(t,e){this.shutterOffered||(this.shutterOffered=!0,this.stats.shutterAtMs=Math.round(e-(this.positioningSince??e)),this.stats.shutterReason=t,this.emit("shutter",{available:!0,reason:t}))}torchAvailable(){try{return this.stream?.getVideoTracks?.()[0]?.getCapabilities?.()?.torch===!0}catch{return!1}}async setTorch(t){this.torchOn=t;try{await this.stream?.getVideoTracks?.()[0]?.applyConstraints({advanced:[{torch:t}]})}catch{}}destroy(){if(this.attempt+=1,this.timer!==null&&(this.opts.clearTimer??clearTimeout)(this.timer),this.timer=null,this.clearFrameWatch(),this.offEnded?.(),this.offEnded=null,this.stream)for(let t of this.stream.getTracks())t.stop();this.stream=null,this.opts.video.srcObject=null}async upgradeResolution(){try{let t=this.stream?.getVideoTracks?.()[0];if(t===void 0)return;let e=t.getSettings?.()??{},s=re(t.getCapabilities?.(),{width:e.width??0,height:e.height??0},this.deviceClass,{width:this.camera.width,height:this.camera.height},this.opts.ocr?.liveMrzOn===!0?{fill:this.guideRegion({width:1080,height:1920}).width}:void 0);s!==null&&(await t.applyConstraints(s),this.upgraded=!0)}catch{}}demote(t,e){if(this.tickCosts=null,this.deviceClass==="LOW"||(this.demotion={from:this.deviceClass,by:t,...e!==null?{tickMedianMs:Math.round(Math.min(6e4,e))}:{}},this.deviceClass="LOW",this.cadenceMs=1e3/Ot.LOW,!this.upgraded))return;this.upgraded=!1;let s=this.videoTrack();s!==null&&(this.guideLock.reset(),this.gate.reset(),s.applyConstraints({width:{ideal:H.width},height:{ideal:H.height}}).catch(()=>{}))}profileTick(t){if(this.deviceClass!=="LOW"&&this.opts.ocr?.tier==="low"){this.demote("ocr_tier",null);return}let e=this.tickCosts;if(e===null||(e.push(t),e.length<Re))return;let s=[...e].sort((h,r)=>h-r),a=(s[s.length-1>>1]+s[s.length>>1])/2;a>_e?this.demote("tick_cost",a):this.tickCosts=null}focusCaps(){try{return this.videoTrack()?.getCapabilities?.()??null}catch{return null}}async applyFocusAndZoom(){let t=this.videoTrack();if(t===null)return;let e=this.focusCaps();this.camera.continuousFocus&&X(e,"continuous")&&await t.applyConstraints({advanced:[{focusMode:"continuous"}]}).catch(()=>{});let s={width:0,height:0};try{let h=t.getSettings?.()??{};s={width:h.width??0,height:h.height??0}}catch{}let a=we(e,s,this.opts.format??"ID-1",this.camera);if(a>1)try{await t.applyConstraints({advanced:[{zoom:a}]}),this.zoom=a}catch{this.zoom=1}}async focusAt(t,e){let s=this.videoTrack(),a=At(this.focusCaps(),t,e);if(!(s===null||a===null))try{await s.applyConstraints({advanced:[a]}),(this.opts.setTimer??setTimeout)(()=>{this.restoreContinuous()},1500)}catch{}}async restoreContinuous(){let t=this.videoTrack();t===null||!this.camera.continuousFocus||!X(this.focusCaps(),"continuous")||await t.applyConstraints({advanced:[{focusMode:"continuous"}]}).catch(()=>{})}async refocusOn(t,e){let s=this.camera.refocusBeforePhotoMs,a=this.videoTrack();if(s<=0||a===null||e.width<=0||e.height<=0)return;let h=R(t),r=At(this.focusCaps(),(h.x+h.width/2)/e.width,(h.y+h.height/2)/e.height);if(r!==null)try{let o=this.opts.setTimer??setTimeout;await Promise.race([a.applyConstraints({advanced:[r]}),new Promise(n=>{o(()=>n(),Le)})]),await new Promise(n=>{o(()=>n(),s)})}catch{}}videoTrack(){try{return this.stream?.getVideoTracks?.()[0]??null}catch{return null}}async takeStill(t,e,s){if(this.opts.captureStill!==void 0)return this.opts.captureStill(this.opts.video,t,e);let a=this.opts.format??"ID-1",h=this.videoTrack();if(s&&this.opts.photoCapture!==!1&&this.deviceClass!=="LOW"&&!this.photoOff&&!this.torchOn&&h!==null&&de(h)){await this.refocusOn(t,e);let r=await pe(this.opts.video,t,e,a,{track:h,detect:this.detector(),detectWidth:I});if(this.restoreContinuous(),r!==null)return r;this.photoOff=!0}return fe(this.opts.video,t,e,a)}detector(){return this.opts.detect??((this.opts.format??"ID-1")==="ID-3"?ve:be)}setState(t){this.state=t,this.emit("statechange",{state:t})}scheduleTick(t){let e=this.opts.setTimer??setTimeout;this.timer=e(()=>{this.tick(t)},this.cadenceMs)}async tick(t){if(t!==this.attempt||this.state!=="positioning"||this.capturing)return;let e=this.opts.now??(()=>performance.now()),s=this.opts.grabDetectFrame??Et,a=this.detector(),h=this.opts.workClock??(()=>performance.now()),r=h(),o=s(this.opts.video,I);if(o===null){this.scheduleTick(t);return}if(!this.lit){if(q(o)>xe)this.lit=!0,this.blackTicks=0;else if(++this.blackTicks>=zt&&this.frameWatch===null&&(this.opts.firstFrameMs??Lt)>0){this.cameraDead(t);return}}let n=null;try{n=await a(o)}catch{n=null}if(t!==this.attempt)return;let u=n!==null?A(o,n):o,c=e(),g={sharpness:D(u),exposure:lt(u),meanLuma:q(u),specularFraction:Zt(u)},d=$t({format:this.opts.format??"ID-1",quad:n,frameWidth:o.width,frameHeight:o.height,measures:g,...this.opts.thresholds!==void 0?{thresholds:this.opts.thresholds}:{}}),m=this.gate.tick({timestampMs:c,quad:n,quality:g,frameWidth:o.width,frameHeight:o.height}),y=(this.opts.format??"ID-1")!=="ID-3",p=y?ft(o,this.guideRegion(o),{edgePeakFrac:this.guideTuning.edgePeakFrac}):mt,f=this.guideLock.tick(p,c);this.lastGuideQuad=f.detected?pt(p):null,this.lastGuideCard=f.detected?{glare:p.cardGlare,sharpness:p.sharpness}:null;let S=this.sideProbe(o,f.detected,p.fill,c),w=this.capturing?null:this.ocrTick(o,n,p,f.detected,d,c),k=f.detected&&(f.still||f.blocker==="locking")||n!==null&&m.stableTicks>=2;this.lastOcrReady?.via==="live_mrz"&&y&&!k&&(this.lastOcrReady=null),this.positioningSince??(this.positioningSince=c);let b=this.stats;if(b.ticks+=1,b.quadFraming[d.framing]=(b.quadFraming[d.framing]??0)+1,d.framing==="ok"&&!m.ready){let v=d.lighting!=="ok"?d.lighting:d.glare!=="ok"?"glare":d.blur!=="ok"?"blurry":"steadying";b.qualityBlockers[v]=(b.qualityBlockers[v]??0)+1}b.guideBlockers[f.blocker]=(b.guideBlockers[f.blocker]??0)+1,n!==null||f.detected?(this.detectedSince??(this.detectedSince=c),this.lastSeenAt=c):this.detectedSince=null,this.lastSeenAt!==null&&c-this.lastSeenAt<=Ie?c-this.positioningSince>=this.shutterTuning.manualShutterMs?this.offerShutter("timeout",c):w?.suspendQuality!==!0&&this.detectedSince!==null&&c-this.detectedSince>=this.shutterTuning.detectedNoLockMs&&this.offerShutter("detected_no_lock",c):this.withdrawShutter();let J=c-(this.lastSeenAt??this.positioningSince);this.zoom>1&&this.camera.zoomFallbackMs>0&&J>=this.camera.zoomFallbackMs&&this.zoomFallback(c);let $=w?.suspendQuality!==!0&&(m.ready&&n!==null||f.ready&&this.lastGuideQuad!==null)||this.lastOcrReady!==null,Ht=!$&&w?.suspendQuality!==!0&&(f.detected&&f.blocker==="locking"||n!==null&&m.stableTicks>=2);this.emit("checks",{engine:"docv1",p:m.p,plausible:m.plausible,stableTicks:m.stableTicks,quad:m.quad,frameWidth:o.width,frameHeight:o.height,analysis:d,ready:$,locking:Ht,guide:{detected:f.detected,blocker:f.blocker,still:f.still,fill:p.fill,shape:p.shape,content:p.content,offsetX:p.offsetX,offsetY:p.offsetY},...w!==null&&w.mode!=="off"?{ocr:{mode:w.mode,...w.mrz?{mrz:w.mrz}:{},...w.lock?{lock:w.lock}:{}}}:w?.mrz?{ocr:{mode:w.mode,mrz:w.mrz}}:{},...S!==void 0?{side:S}:{}}),this.lastQuad=m.plausible?n:null,this.lastDetect={width:o.width,height:o.height,tickSharpness:g.sharpness};let F=Xt(d);d.framing!=="ok"&&f.detected&&(F=Oe(f.blocker,p.brightness<this.guideTuning.darkBrightness)),F==="blurry"&&n!==null&&Te(n,o,this.opts.format??"ID-1")>=this.camera.focusFarFillFrac&&(F="focus_far"),F==="sensing"&&this.zoom>1&&this.camera.noDocFarHintMs>0&&J>=this.camera.noDocFarHintMs&&(F="focus_far");let W=this.feedback.tick(F,c);W.key!==this.lastFeedbackKey&&(this.lastFeedbackKey=W.key,this.emit("feedback",W)),m.guidanceKey!==this.lastGuidance&&(this.lastGuidance=m.guidanceKey,this.emit("guidance",{key:m.guidanceKey}));let jt=h()-r;if(this.stats.ticks>Fe&&this.profileTick(jt),this.capturing)return;let tt=w?.suspendQuality!==!0,Qt=tt&&m.ready&&n!==null,L=tt&&f.ready&&this.lastGuideQuad!==null,z=this.lastOcrReady;if(z!==null&&this.opts.autoCapture!==!1){let v=this.feedback.force("processing",c);this.lastFeedbackKey=v.key,this.emit("feedback",v);let O=D(A(o,z.quad));await this.fire(t,z.quad,{width:o.width,height:o.height,tickSharpness:O},z.via);return}if((Qt||L)&&this.opts.autoCapture!==!1){let v=this.feedback.force("processing",c);this.lastFeedbackKey=v.key,this.emit("feedback",v);let O=L?this.lastGuideQuad:n,Ut=L?f.via==="steady"?"guide_steady":"guide_good":"quad",Kt=L?D(A(o,O)):g.sharpness;await this.fire(t,O,{width:o.width,height:o.height,tickSharpness:Kt},Ut);return}this.scheduleTick(t)}async fire(t,e,s,a){this.capturing=!0;let h=this.opts.grabDetectFrame??Et,r=this.opts.setTimer??setTimeout,o={width:s.width,height:s.height},n=this.opts.workClock??(()=>performance.now()),u=n();try{let c={still:await this.takeStill(e,o,!0),sharpness:s.tickSharpness};if(t!==this.attempt)return;let g=c.still.source==="photo"||this.deviceClass==="LOW"?0:Ae;for(let p=0;p<g;p++){let f=n()-u;if(f+Pt+f/(p+1)>Ce)break;if(await new Promise(k=>{r(()=>k(),Pt)}),t!==this.attempt)return;let S=h(this.opts.video,I);if(S===null)continue;let w=D(A(S,e));if(w>c.sharpness*ze){let k=await this.takeStill(e,o,!1);if(t!==this.attempt)return;c={still:k,sharpness:w}}}if(t!==this.attempt)return;let d=c.still.sharpness;if(this.opts.autoCapture!==!1&&a!=="manual"&&typeof d=="number"&&d>=0&&d<this.camera.stillSharpnessMin&&this.stillRefusals<this.camera.stillRefusalsMax){this.stillRefusals+=1,this.stats.stillRefusals+=1,this.guideLock.reset(),this.lastOcrReady=null,(a==="text_lock"||a==="live_mrz")&&this.opts.ocr?.rearmFace();let p=(this.opts.now??(()=>performance.now()))(),f=this.feedback.force("focus_far",p);this.lastFeedbackKey=f.key,this.emit("feedback",f),this.capturing=!1,this.gate.reset(),this.scheduleTick(t);return}this.stillRefusals=0;let m=(this.opts.now??(()=>performance.now()))();this.stats.via=a,this.stats.msToCapture=Math.round(m-(this.positioningSince??m));let y=this.lastGuideCard;y!==null&&(this.stats.shotGlare=Math.round(Math.min(1,Math.max(0,y.glare))*1e3)/1e3,this.stats.shotSharpness=Math.round(Math.min(1e6,Math.max(0,y.sharpness)))),this.lastStillAt!==null&&(this.stats.msSincePrevShot=Math.round(Math.min(36e5,Math.max(0,m-this.lastStillAt)))),this.lastStillAt=m,this.shutterOffered&&(this.shutterOffered=!1,this.emit("shutter",{available:!1})),this.setState("captured"),this.emit("artifacts",{keyframe:c.still.blob,previewDataUrl:c.still.previewDataUrl,...this.opts.side!==void 0?{side:this.opts.side}:{},...c.still.docRegion!==void 0?{docRegion:c.still.docRegion}:{},...(()=>{let p=a==="live_mrz"?this.opts.ocr?.liveCapture():null;return p?{liveMrz:p}:{}})()})}catch{if(t!==this.attempt)return;this.capturing=!1,this.gate.reset(),this.guideLock.reset(),this.lastOcrReady=null,(a==="text_lock"||a==="live_mrz")&&this.opts.ocr?.rearmFace(),this.scheduleTick(t)}}ocrTick(t,e,s,a,h,r){let o=this.opts.ocr,n=this.opts.video;if(o===void 0||!o.hasEngine)return this.lastOcrReady=null,null;let u=n.videoWidth,c=n.videoHeight;if(u<=0||c<=0||t.width<=0||t.height<=0)return null;let g=(this.opts.format??"ID-1")==="ID-3",d=this.guideRegion(t),m={x:d.x*u,y:d.y*c,w:d.width*u,h:d.height*c},y=u/t.width,p=c/t.height,f;g&&e!==null?f=De(R(e),y,p,u,c):f=Mt(m,o.bandTop,c);let S=g?h.glare==="ok":s.cardGlare<=this.guideTuning.glareMax,w=g?h.blur==="ok":s.sharpness>=this.guideTuning.sharpnessMin,k=o.tick({atMs:r,video:n,mrzFace:g||this.opts.side==="verso"||this.opts.side==="single",present:g||e!==null||a,card:m,band:f,portrait:c>u,glareOk:S,sharpOk:w});if(k.ready&&k.via!==void 0){let b=g?e??It(d,t):this.lastGuideQuad??It(d,t);this.lastOcrReady={quad:b,via:k.via}}else this.lastOcrReady=null;return k}},l(x,"i"),x);function De(i,t,e,s,a){let h=Math.min(s,i.width*1.06*t),r=Math.min(a,Math.max(i.height*1.6*e,h/5)),o=(i.y+i.height/2)*e,n=Math.max(0,Math.min(s-h,(i.x-i.width*.03)*t)),u=Math.max(0,Math.min(a-r,o-r/2));return{x:n,y:u,w:h,h:r}}l(De,"Te");function It(i,t){let e=i.x*t.width,s=i.y*t.height,a=(i.x+i.width)*t.width,h=(i.y+i.height)*t.height;return{topLeft:{x:e,y:s},topRight:{x:a,y:s},bottomRight:{x:a,y:h},bottomLeft:{x:e,y:h}}}l(It,"$t");function Te(i,t,e){let s=R(i);return t.width<=0||t.height<=0?0:e==="ID-3"?s.width/t.width:s.width*s.height/(t.width*t.height)}l(Te,"Re");var Ae=2,Pt=260,Ce=1200,Le=600,ze=1.08,Q=null;function Et(i,t){let e=i.videoWidth,s=i.videoHeight;if(e===0||s===0)return null;let a=Math.min(1,t/e),h=Math.round(e*a),r=Math.round(s*a);Q??(Q=document.createElement("canvas"));let o=Q;o.width!==h&&(o.width=h),o.height!==r&&(o.height=r);let n=o.getContext("2d",{willReadFrequently:!0});return n===null?null:(n.imageSmoothingQuality=e/Math.max(1,h)>4?"high":"low",n.drawImage(i,0,0,h,r),n.getImageData(0,0,h,r))}l(Et,"ie");function A(i,t){let e=[t.topLeft.x,t.topRight.x,t.bottomRight.x,t.bottomLeft.x],s=[t.topLeft.y,t.topRight.y,t.bottomRight.y,t.bottomLeft.y],a=Math.max(0,Math.floor(Math.min(...e))),h=Math.max(0,Math.floor(Math.min(...s))),r=Math.min(i.width,Math.ceil(Math.max(...e))),o=Math.min(i.height,Math.ceil(Math.max(...s))),n=Math.max(1,r-a),u=Math.max(1,o-h),c=new Uint8ClampedArray(n*u*4);for(let g=0;g<u;g++){let d=((h+g)*i.width+a)*4;c.set(i.data.subarray(d,d+n*4),g*n*4)}return{data:c,width:n,height:u,colorSpace:i.colorSpace}}l(A,"C");function Oe(i,t){return i==="glare"?"glare":i==="too_small"?"too_far":i==="too_big"?"too_close":t?"too_dark":i==="blurry"?"blurry":i==="off_center"?"edge_clipped":i==="no_card"?"sensing":"hold_still"}l(Oe,"Pe");var Ie=1200;export{Qe as a,Ue as b,Lt as c,xe as d,zt as e,Ot as f,Se as g,Re as h,Fe as i,_e as j,Y as k,Ke as l,Xe as m,De as n,Ae as o,Pt as p,Ce as q,Le as r};
|