@sekyro/elements 0.1.0-rc.12 → 0.1.0-rc.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cdn/chunks/{capture-session-doc-FAMDLRRZ-QPOFTNTG.js → capture-session-doc-GCL2FYQH-X7QTUFGI.js} +1 -1
  3. package/dist/cdn/chunks/{chunk-SDK2YXFV.js → chunk-26HXTRWG.js} +1 -1
  4. package/dist/cdn/chunks/{chunk-XDRH4VWV.js → chunk-3I6AVO6X.js} +1 -1
  5. package/dist/cdn/chunks/chunk-3NOBU7TE.js +1 -0
  6. package/dist/cdn/chunks/chunk-A5SXWFOO.js +1 -0
  7. package/dist/cdn/chunks/{chunk-CVFJQIMW.js → chunk-CK3CQAFP.js} +1 -1
  8. package/dist/cdn/chunks/{chunk-YFJBTK3L.js → chunk-CPVOHNLU.js} +1 -1
  9. package/dist/cdn/chunks/{chunk-LBZCFEU4.js → chunk-CSPTLSJY.js} +2 -2
  10. package/dist/cdn/chunks/{chunk-JI5WT66H.js → chunk-CX52FPYW.js} +1 -1
  11. package/dist/cdn/chunks/chunk-DEGFGNRM.js +3 -0
  12. package/dist/cdn/chunks/{chunk-GPGK6XZM.js → chunk-DKZUKWGP.js} +1 -1
  13. package/dist/cdn/chunks/{chunk-4YBL75VD.js → chunk-F7DKVXQW.js} +1 -1
  14. package/dist/cdn/chunks/chunk-FZXXMIZ4.js +1 -0
  15. package/dist/cdn/chunks/{chunk-UN4V3UNQ.js → chunk-LHEWQFCZ.js} +1 -1
  16. package/dist/cdn/chunks/{chunk-BMUUDLFA.js → chunk-PYUD6W3P.js} +1 -1
  17. package/dist/cdn/chunks/chunk-QTPSRWXY.js +1 -0
  18. package/dist/cdn/chunks/{chunk-VHNWBOKW.js → chunk-SHOVUF5C.js} +1 -1
  19. package/dist/cdn/chunks/chunk-VXXXAUQD.js +1 -0
  20. package/dist/cdn/chunks/{chunk-7JUL7AKT.js → chunk-ZPSZDTDP.js} +1 -1
  21. package/dist/cdn/chunks/{create-document-capture-WFTNVMCE-QOCPJSAU.js → create-document-capture-IMDGCTMM-TBX7G2XG.js} +1 -1
  22. package/dist/cdn/chunks/{detector-scanic-S4PB2RNW-3KSM3MW5.js → detector-scanic-QVQVJI3C-K3ZARXJR.js} +1 -1
  23. package/dist/cdn/chunks/{document-capture-view-GENB535Z-YBRM7NWN.js → document-capture-view-GENB535Z-J72QDPT4.js} +1 -1
  24. package/dist/cdn/chunks/{eid-view-IQRZGEMP-SPGYQDQP.js → eid-view-IQRZGEMP-RHLNP5ZM.js} +1 -1
  25. package/dist/cdn/chunks/{email-otp-view-CL76K5TY-TJMSLYLZ.js → email-otp-view-CL76K5TY-ZSNIDTY3.js} +1 -1
  26. package/dist/cdn/chunks/{flow-views-C3EIMXME-ODOF67JZ.js → flow-views-C3EIMXME-U7PKRKNU.js} +1 -1
  27. package/dist/cdn/chunks/{form-view-MEYCK437-JBO5DNG5.js → form-view-MEYCK437-HDYDY2QI.js} +1 -1
  28. package/dist/cdn/chunks/plan-runner-HBUVNDGH-6DM4PNGI.js +1 -0
  29. package/dist/cdn/chunks/{portrait-capture-view-VTN2VU3E-JH34ISLI.js → portrait-capture-view-VTN2VU3E-WCQNHK3E.js} +1 -1
  30. package/dist/cdn/chunks/{portrait-review-view-JTRGDYNV-C2O6OFYY.js → portrait-review-view-JTRGDYNV-25TZW6WY.js} +1 -1
  31. package/dist/cdn/chunks/{proof-of-address-view-UQOZZXQO-T3QOIQNE.js → proof-of-address-view-UQOZZXQO-DITYLW35.js} +1 -1
  32. package/dist/cdn/define.js +1 -1
  33. package/dist/cdn/index.js +1 -1
  34. package/package.json +2 -2
  35. package/sbom.cdx.json +4 -4
  36. package/dist/cdn/chunks/chunk-2FETDQV5.js +0 -1
  37. package/dist/cdn/chunks/chunk-FVWYONHZ.js +0 -1
  38. package/dist/cdn/chunks/chunk-K4BLQMYZ.js +0 -1
  39. package/dist/cdn/chunks/chunk-Q5BUNNRN.js +0 -3
  40. package/dist/cdn/chunks/chunk-XSGZY4JI.js +0 -1
  41. package/dist/cdn/chunks/chunk-YLH3WX7Y.js +0 -1
  42. package/dist/cdn/chunks/plan-runner-LSQTIO6L-XZJIKXPZ.js +0 -1
package/sbom.cdx.json CHANGED
@@ -97,8 +97,8 @@
97
97
  "type": "application",
98
98
  "name": "elements",
99
99
  "group": "@sekyro",
100
- "version": "0.1.0-rc.12",
101
- "bom-ref": "@sekyro/elements@0.1.0-rc.12",
100
+ "version": "0.1.0-rc.13",
101
+ "bom-ref": "@sekyro/elements@0.1.0-rc.13",
102
102
  "description": "Sekyro AI custom elements: <sekyro-verification> for Vue, Angular, Svelte and plain HTML, the @sekyro/react flow with React bundled inside",
103
103
  "licenses": [
104
104
  {
@@ -108,7 +108,7 @@
108
108
  }
109
109
  }
110
110
  ],
111
- "purl": "pkg:npm/%40sekyro/elements@0.1.0-rc.12?vcs_url=git%2Bhttps%3A%2F%2Fgithub.com%2FIBTIKAR-Technologies%2Fibtikar-identity.git%23packages%2Fsekyro-elements",
111
+ "purl": "pkg:npm/%40sekyro/elements@0.1.0-rc.13?vcs_url=git%2Bhttps%3A%2F%2Fgithub.com%2FIBTIKAR-Technologies%2Fibtikar-identity.git%23packages%2Fsekyro-elements",
112
112
  "externalReferences": [
113
113
  {
114
114
  "url": "https://github.com/IBTIKAR-Technologies/ibtikar-identity/issues",
@@ -147,7 +147,7 @@
147
147
  "components": [],
148
148
  "dependencies": [
149
149
  {
150
- "ref": "@sekyro/elements@0.1.0-rc.12"
150
+ "ref": "@sekyro/elements@0.1.0-rc.13"
151
151
  }
152
152
  ]
153
153
  }
@@ -1 +0,0 @@
1
- import{a as n}from"./chunk-4FHWXBOB.js";var z=Object.freeze({minLines:4,fillMin:.55,fillMax:.98,offsetMax:.12,steadyFillDelta:.04,steadyOffsetDelta:.03,layoutShiftMax:.025,lineCountDelta:1,lockMs:600,steadyMs:900,minFrames:3});function R(r,t){let e=r.lineBoxes;if(e.length===0)return{lineCount:0,detected:!1,fill:0,offsetX:0,offsetY:0,centers:[]};let s=Math.min(...e.map(i=>i[0])),a=Math.max(...e.map(i=>i[0]+i[2])),l=Math.min(...e.map(i=>i[1])),h=Math.max(...e.map(i=>i[1]+i[3]));return{lineCount:e.length,detected:e.length>=t.minLines,fill:a-s,offsetX:(s+a)/2-.5,offsetY:(l+h)/2-.5,centers:e.map(i=>[i[0]+i[2]/2,i[1]+i[3]/2])}}n(R,"y");function N(r,t){if(r.centers.length===0||t.centers.length===0)return Number.POSITIVE_INFINITY;let e=0;for(let[s,a]of t.centers){let l=Number.POSITIVE_INFINITY;for(let[h,i]of r.centers)l=Math.min(l,Math.hypot(s-h,a-i));e+=l}return e/t.centers.length}n(N,"x");var x,O=(x=class{constructor(t=z){this.t=t,this.last=null,this.goodSince=null,this.steadySince=null,this.frames=0}offer(t,e,s={glareOk:!0,sharpOk:!0}){let a=this.t,l=R(t,a),h=this.last;this.last=l;let i=l.fill>=a.fillMin&&l.fill<=a.fillMax,o=Math.abs(l.offsetX)<=a.offsetMax&&Math.abs(l.offsetY)<=a.offsetMax,c=h!==null&&h.detected&&Math.abs(l.lineCount-h.lineCount)<=a.lineCountDelta&&N(h,l)<=a.layoutShiftMax,u=l.detected&&s.glareOk&&s.sharpOk&&i&&c&&h!==null&&Math.abs(l.fill-h.fill)<=a.steadyFillDelta&&Math.abs(l.offsetX-h.offsetX)<=a.steadyOffsetDelta&&Math.abs(l.offsetY-h.offsetY)<=a.steadyOffsetDelta,g=u&&o,m=l.detected?s.glareOk?l.fill<a.fillMin?"closer":l.fill>a.fillMax?"farther":o?s.sharpOk?void 0:"blurry":"center":"glare":void 0;return u?(this.frames++,this.steadySince??(this.steadySince=e),this.goodSince=g?this.goodSince??e:null,(this.goodSince!==null&&e-this.goodSince>=a.lockMs||e-this.steadySince>=a.steadyMs)&&this.frames>=a.minFrames?{state:"locked"}:{state:"locking",...m?{hint:m}:{}}):(this.goodSince=null,this.steadySince=null,this.frames=l.detected?1:0,{state:l.detected?"locking":"searching",...m?{hint:m}:{}})}reset(){this.last=null,this.goodSince=null,this.steadySince=null,this.frames=0}},n(x,"c"),x);var C=[[1,0],[0,1],[1,1],[1,-1]];function E(r){let{width:t,height:e,data:s}=r;if(t<16||e<16)return-1;let a=new Uint8Array(t*e);for(let h=0,i=0;h<a.length;h+=1,i+=4)a[h]=Math.round(.299*(s[i]??0)+.587*(s[i+1]??0)+.114*(s[i+2]??0));let l=-1;for(let[h,i]of C){let o=new Uint32Array(256),c=new Float64Array(256),u=0;for(let d=1;d<e-1;d+=1){let f=d*t,F=(d+i)*t,_=(d-i)*t;for(let p=1;p<t-1;p+=1){let T=a[F+p+h]??0,I=a[_+p-h]??0,S=Math.abs(T-I);o[S]=(o[S]??0)+1,c[S]=(c[S]??0)+Math.abs(T+I-2*(a[f+p]??0)),u+=1}}let g=Math.max(1,Math.floor(u/20)),m=0,M=0,k=0;for(let d=255;d>=0&&m<g;d-=1){let f=o[d]??0;m+=f,M+=f*d,k+=c[d]??0}if(M===0)return 0;let y=k/M;l=l<0?y:Math.min(l,y)}return l}n(E,"w");var A=.06;function B(r,t,e,s=A){if(r===null||t.width<=0||t.height<=0)return null;let a=[r.topLeft,r.topRight,r.bottomRight,r.bottomLeft],l=e.width/t.width,h=e.height/t.height,i=Math.min(...a.map(f=>f.x))*l,o=Math.max(...a.map(f=>f.x))*l,c=Math.min(...a.map(f=>f.y))*h,u=Math.max(...a.map(f=>f.y))*h,g=(o-i)*s,m=(u-c)*s,M=Math.max(0,Math.floor(i-g)),k=Math.max(0,Math.floor(c-m)),y=Math.min(e.width,Math.ceil(o+g)),d=Math.min(e.height,Math.ceil(u+m));return y-M<16||d-k<16?null:{x:M,y:k,width:y-M,height:d-k}}n(B,"P");function X(r,t){let e=t??{x:0,y:0,width:r.width,height:r.height},s=Math.min(1,1e3/Math.max(e.width,e.height)),a=Math.max(1,Math.round(e.width*s)),l=Math.max(1,Math.round(e.height*s)),h=document.createElement("canvas");h.width=a,h.height=l;try{let i=h.getContext("2d",{willReadFrequently:!0});return i===null?-1:(i.imageSmoothingQuality="high",i.drawImage(r,e.x,e.y,e.width,e.height,0,0,a,l),E(i.getImageData(0,0,a,l)))}catch{return-1}finally{h.width=0,h.height=0}}n(X,"B");var b,G=(b=class{constructor(t=2){this.stableReads=t,this.last=null,this.run=0}offer(t){return t===null?(this.reset(),!1):(this.run=t===this.last?this.run+1:1,this.last=t,this.run>=this.stableReads)}reset(){this.last=null,this.run=0}},n(b,"k"),b),L=Object.freeze({...z,minIntervalMs:150,maxWidthPx:480,detectorLimit:960,searchTimeoutMs:12e3}),P=Object.freeze({detectorLimit:960,bandMaxWidthPx:1280,minBandWidthPx:900,bandTop:.55,minIntervalMs:150,stableReads:2,profileReads:5,maxReadMs:1200,searchTimeoutMs:12e3}),V=n((r,t,e)=>createImageBitmap(r,Math.round(t.x),Math.round(t.y),Math.max(1,Math.round(t.w)),Math.max(1,Math.round(t.h)),{resizeWidth:Math.max(1,Math.round(Math.min(t.w,e))),resizeQuality:"high"}),"C"),w=n((r,t)=>{if(r.length===0)return 0;let e=[...r].sort((s,a)=>s-a);return e[Math.min(e.length-1,Math.floor(e.length*t))]},"x");function Y(r){return r<=250?"fast":r<=600?"mid":"slow"}n(Y,"G");function j(r,t,e){let s=r.y+r.h*t,a=Math.min(e,r.y+r.h*1.05);return{x:r.x,y:s,w:r.w,h:Math.max(1,a-s)}}n(j,"Y");var v,U=(v=class{constructor(t){this.o=t,this.engine=null,this.gen=0,this.inFlight=!1,this.lastReadAt=Number.NEGATIVE_INFINITY,this.firstSeen=null,this.reads=0,this.times=[],this.mrzState={state:"searching"},this.lockState={state:"searching"},this.fallback=null,this.lockOff=!1,this.lockError=!1,this.fired=null,this.valid=null,this.faceMode="off",this.disabled=!1,this.crop=t.crop??V,this.mrzGate=new G(t.liveMrz?.stableReads??2),this.lockGate=new O(t.textLock??L)}setEngine(t){this.engine=t}get bandTop(){return this.o.liveMrz?.bandTop??P.bandTop}get hasEngine(){return this.engine!==null&&!this.disabled}reset(){this.gen++,this.inFlight=!1,this.lastReadAt=Number.NEGATIVE_INFINITY,this.firstSeen=null,this.reads=0,this.times=[],this.mrzGate.reset(),this.lockGate.reset(),this.mrzState={state:"searching"},this.lockState={state:"searching"},this.fallback=null,this.lockOff=!1,this.lockError=!1,this.fired=null,this.valid=null,this.faceMode="off"}rearmFace(){this.gen++,this.inFlight=!1,this.lastReadAt=Number.NEGATIVE_INFINITY,this.mrzGate.reset(),this.lockGate.reset(),this.fired=null,this.valid=null,this.fallback===null&&(this.mrzState={state:"searching"}),this.lockOff||(this.lockState={state:"searching"})}liveCapture(){return this.fired?.via==="live_mrz"?this.valid:null}modeFor(t){return this.engine===null||this.disabled?"off":t.mrzFace&&this.o.liveMrz!==null&&this.fallback===null?"live_mrz":this.o.textLock!==null&&!this.lockOff?"text_lock":"off"}tick(t){let e=this.modeFor(t);return e!=="off"&&(this.faceMode=e),this.fired!==null?{ready:!0,via:this.fired.via,suspendQuality:this.fired.via==="live_mrz",mode:e,...this.states()}:e==="live_mrz"?this.liveTick(t,this.o.liveMrz):e==="text_lock"?this.lockTick(t,this.o.textLock):{ready:!1,suspendQuality:!1,mode:e,...this.states()}}states(){return{...this.faceMode==="live_mrz"||this.fallback!==null?{mrz:this.fallback!==null?{state:"fallback",reason:this.fallback}:this.mrzState}:{},...this.faceMode==="text_lock"?{lock:this.lockState}:{}}}canRead(t,e){let s=this.engine;return s!==null&&!this.inFlight&&!s.busy&&t-this.lastReadAt>=e}fall(t){this.fallback=t,this.mrzGate.reset()}liveTick(t,e){let s=n(()=>this.fallback!==null?{ready:!1,suspendQuality:!1,mode:"live_mrz",mrz:{state:"fallback",reason:this.fallback}}:{ready:!1,suspendQuality:!0,mode:"live_mrz",mrz:this.mrzState},"r");if(!t.present||t.band===null)return this.mrzGate.reset(),this.mrzState={state:"searching"},s();if(this.firstSeen??(this.firstSeen=t.atMs),t.atMs-this.firstSeen>e.searchTimeoutMs)return this.fall("timeout"),s();if(t.band.w<e.minBandWidthPx)return t.card!==null&&t.card.w<e.minBandWidthPx?(this.fall("unsupported"),s()):(this.mrzState={state:"reading",coach:t.portrait?"turnSideways":"moveCloser"},{ready:!1,suspendQuality:!1,mode:"live_mrz",mrz:this.mrzState});if(!this.canRead(t.atMs,e.minIntervalMs))return s();this.inFlight=!0,this.lastReadAt=t.atMs;let a=this.gen,l=this.engine,h=t.glareOk?t.sharpOk?void 0:"holdStill":"glare";return this.crop(t.video,t.band,e.bandMaxWidthPx).then(i=>l.bandRead(i,e.detectorLimit)).then(i=>{if(a===this.gen){if(this.reads++,this.times.push(i.ms),this.times.length>8&&this.times.shift(),this.reads>=e.profileReads&&w(this.times,.5)>e.maxReadMs)return this.fall("slow");if(this.mrzGate.offer(i.valid?i.digest??null:null)&&i.format&&i.digest){this.valid={format:i.format,...i.documentCode!==void 0?{documentCode:i.documentCode}:{},digest:i.digest,lineCount:i.lineCount,framesToValid:this.reads,msToValid:Math.round(t.atMs-(this.firstSeen??t.atMs))},this.mrzState={state:"valid",format:i.format},this.fired={via:"live_mrz",at:t.atMs};return}this.mrzState={state:"reading",...h?{coach:h}:{},...i.format?{format:i.format}:{}}}}).catch(()=>{a===this.gen&&this.fall("error")}).finally(()=>{a===this.gen&&(this.inFlight=!1)}),s()}lockTick(t,e){let s=n(()=>({ready:!1,suspendQuality:!1,mode:"text_lock",lock:this.lockState,...this.fallback!==null?{mrz:{state:"fallback",reason:this.fallback}}:{}}),"r");if(!t.present||t.card===null)return this.lockGate.reset(),this.lockState={state:"searching"},s();if(this.firstSeen??(this.firstSeen=t.atMs),t.atMs-this.firstSeen>e.searchTimeoutMs)return this.lockOff=!0,s();if(!this.canRead(t.atMs,e.minIntervalMs))return s();this.inFlight=!0,this.lastReadAt=t.atMs;let a=this.gen,l=this.engine,h={glareOk:t.glareOk,sharpOk:t.sharpOk};return this.crop(t.video,t.card,e.maxWidthPx).then(i=>l.layoutRead(i,e.detectorLimit)).then(i=>{if(a!==this.gen)return;this.reads++,this.times.push(i.ms),this.times.length>8&&this.times.shift();let o=this.lockGate.offer(i,t.atMs,h);this.lockState=o.state==="locked"?{state:"locked"}:{state:o.state,...o.hint?{hint:o.hint}:{}},o.state==="locked"&&(this.fired={via:"text_lock",at:t.atMs})}).catch(()=>{a===this.gen&&(this.lockOff=!0,this.lockError=!0)}).finally(()=>{a===this.gen&&(this.inFlight=!1)}),s()}disable(){this.disabled=!0,this.reset()}report(t,e,s){let a=this.faceMode;if(a==="off")return null;let l=w(this.times,.5),h={capture:t,mode:a,reads:this.reads,...this.times.length>0?{readP50Ms:Math.round(l),readP90Ms:Math.round(w(this.times,.9)),deviceClass:Y(l)}:{}};return a==="live_mrz"?this.fired?.via==="live_mrz"&&this.valid!==null&&e==="live_mrz"?{...h,outcome:"valid",format:this.valid.format,framesToValid:this.valid.framesToValid,msToValid:this.valid.msToValid}:this.fallback!==null?{...h,outcome:this.fallback}:{...h,outcome:s-(this.firstSeen??s)>=(this.o.liveMrz?.searchTimeoutMs??1/0)?"timeout":"off"}:this.fired?.via==="text_lock"?{...h,outcome:"locked",framesToLock:Math.max(1,this.reads),msToLock:Math.round(this.fired.at-(this.firstSeen??this.fired.at))}:{...h,outcome:this.lockError?"error":this.lockOff?"timeout":"off"}}},n(v,"L"),v);export{B as a,X as b,L as c,P as d,j as e,U as f};
@@ -1 +0,0 @@
1
- import{a as tt,b as $t,c as te,d as dt,e as ee}from"./chunk-JI5WT66H.js";import{a as Ut,b as Kt,e as Yt}from"./chunk-2FETDQV5.js";import{b as Vt,c as Zt}from"./chunk-XSGZY4JI.js";import{b as Jt}from"./chunk-L22GFJQV.js";import{d as Wt,e as Ht,f as Qt}from"./chunk-4YBL75VD.js";import{a as ct,b as ut,c as Y,d as Xt}from"./chunk-P7K7ELYZ.js";import{g as Nt,i as qt,j as Gt,k as jt,l as Bt}from"./chunk-JS2IXPNL.js";import{a as n}from"./chunk-4FHWXBOB.js";var et=Object.freeze({sensing:{key:"sensing",reticle:"searching",minDurationMs:900},too_far:{key:"too_far",reticle:"coaching",minDurationMs:1400},too_close:{key:"too_close",reticle:"coaching",minDurationMs:1400},edge_clipped:{key:"edge_clipped",reticle:"coaching",minDurationMs:1400},wrong_shape:{key:"wrong_shape",reticle:"coaching",minDurationMs:1400},tilted:{key:"tilted",reticle:"coaching",minDurationMs:1400},too_dark:{key:"too_dark",reticle:"coaching",minDurationMs:1400},too_bright:{key:"too_bright",reticle:"coaching",minDurationMs:1400},blurry:{key:"blurry",reticle:"coaching",minDurationMs:1400},focus_far:{key:"focus_far",reticle:"coaching",minDurationMs:1600},glare:{key:"glare",reticle:"coaching",minDurationMs:1400},hold_still:{key:"hold_still",reticle:"locking",minDurationMs:900},processing:{key:"processing",reticle:"processing",minDurationMs:800},side_captured:{key:"side_captured",reticle:"flip",minDurationMs:2600},captured:{key:"captured",reticle:"done",minDurationMs:800}});function Ae(s){return s.framing==="no_document"?"sensing":s.framing==="too_far"?"too_far":s.framing==="too_close"?"too_close":s.framing==="edge_clipped"?"edge_clipped":s.framing==="wrong_shape"?"wrong_shape":s.framing==="tilted"?"tilted":s.lighting==="too_dark"?"too_dark":s.lighting==="too_bright"?"too_bright":s.glare==="glare"?"glare":s.blur==="blurry"?"blurry":"hold_still"}n(Ae,"ne");var G,ze=(G=class{constructor(t=2600,e=.35){this.windowMs=t,this.decayPerSecond=e,this.votes=[],this.current=et.sensing,this.currentSinceMs=null}reset(){this.votes=[],this.current=et.sensing,this.currentSinceMs=null}force(t,e){return this.votes=[],this.current=et[t],this.currentSinceMs=e,this.current}tick(t,e){if(this.currentSinceMs===null&&(this.currentSinceMs=e),this.votes.push({key:t,atMs:e}),this.votes=this.votes.filter(o=>e-o.atMs<=this.windowMs),e-this.currentSinceMs<this.current.minDurationMs)return this.current;let i=new Map;for(let o of this.votes){let l=(e-o.atMs)/1e3,r=this.decayPerSecond**l;i.set(o.key,(i.get(o.key)??0)+r)}let a=this.current.key,h=-1;for(let[o,l]of i)l>h&&(h=l,a=o);return a!==this.current.key&&(this.current=et[a],this.currentSinceMs=e),this.current}},n(G,"ot"),G),Ce=Object.freeze({MAX_AREA_FRAC:.92,TILT_MAX_SIDE_RATIO:1.3,GLARE_MAX_SPECULAR_FRAC:.025});function Ie(s){let{data:t,width:e,height:i}=s,a=e*i;if(a===0)return 0;let h=0;for(let o=0;o<a;o++){let l=o*4;.299*(t[l]??0)+.587*(t[l+1]??0)+.114*(t[l+2]??0)>=252&&h++}return h/a}n(Ie,"re");function Le(s){let t=n((r,c)=>Math.hypot(c.x-r.x,c.y-r.y),"t"),e=t(s.topLeft,s.topRight),i=t(s.bottomLeft,s.bottomRight),a=t(s.topLeft,s.bottomLeft),h=t(s.topRight,s.bottomRight),o=Math.max(e,i)/Math.max(1e-6,Math.min(e,i)),l=Math.max(a,h)/Math.max(1e-6,Math.min(a,h));return Math.max(o,l)}n(Le,"je");function Oe(s){let t={...$t,...s.thresholds},e=Ce,{quad:i,frameWidth:a,frameHeight:h,measures:o}=s,l=s.format==="ID-3",r="ok";if(i===null)r="no_document";else if(l){let d=dt(i),m=a>0?d.width/a:0,g=d.height>0?d.width/d.height:0;m<t.ID3_BAND_MIN_WIDTH_FRAC?r="too_far":ie(i,a,h,t.EDGE_CLIP_MARGIN_PX)?r="edge_clipped":(g<t.ID3_BAND_ASPECT_MIN||g>t.ID3_BAND_ASPECT_MAX)&&(r="wrong_shape")}else{let d=te(i,a,h),m=dt(i),g=Math.max(m.width,m.height)/Math.max(1e-6,Math.min(m.width,m.height));d<t.MIN_AREA_FRAC?r="too_far":d>e.MAX_AREA_FRAC?r="too_close":ie(i,a,h,t.EDGE_CLIP_MARGIN_PX)?r="edge_clipped":Zt(s.format,g)?Le(i)>e.TILT_MAX_SIDE_RATIO&&(r="tilted"):r="wrong_shape"}let c=o.exposure>=t.GUIDE_EXPOSURE?"ok":o.meanLuma<(ct[0]+ct[1])/2?"too_dark":"too_bright",u=o.sharpness>=t.GUIDE_SHARPNESS?"ok":"blurry",f=o.specularFraction>=e.GLARE_MAX_SPECULAR_FRAC?"glare":"ok";return{framing:r,lighting:c,blur:u,glare:f,acceptable:r==="ok"&&c==="ok"&&u==="ok"&&f==="ok"}}n(Oe,"ae");function ie(s,t,e,i){return[s.topLeft,s.topRight,s.bottomRight,s.bottomLeft].some(a=>a.x<=i||a.y<=i||a.x>=t-i||a.y>=e-i)}n(ie,"se");var Ee=Object.freeze({width:1920,height:1080}),Pe=Object.freeze({width:3840,height:2160}),se=4096,We=2560,Ne=640,it=.15,V=Object.freeze({side:.2,above:.9,below:.3});function C(s){let t=[s.topLeft.x,s.topRight.x,s.bottomRight.x,s.bottomLeft.x],e=[s.topLeft.y,s.topRight.y,s.bottomRight.y,s.bottomLeft.y],i=Math.min(...t),a=Math.min(...e);return{x:i,y:a,width:Math.max(...t)-i,height:Math.max(...e)-a}}n(C,"E");function me(s,t){let e=Math.max(0,Math.floor(s.x)),i=Math.max(0,Math.floor(s.y)),a=Math.min(t.width,Math.ceil(s.x+s.width)),h=Math.min(t.height,Math.ceil(s.y+s.height));return a-e<16||h-i<16?null:{x:e,y:i,width:a-e,height:h-i}}n(me,"he");function qe(s,t,e){if(s===null||t.width<=0||t.height<=0)return null;let i=C(s);if(i.width<=0||i.height<=0)return null;let a=e==="ID-3"?{x:i.x-i.width*V.side,y:i.y-i.width*V.above,width:i.width*(1+2*V.side),height:i.height+i.width*(V.above+V.below)}:{x:i.x-i.width*it,y:i.y-i.height*it,width:i.width*(1+2*it),height:i.height*(1+2*it)};return me(a,t)}n(qe,"Je");function ge(s,t,e){let i=Math.max(s,t);return i>0?Math.min(1,e/i):1}n(ge,"ft");function pe(s,t,e,i,a=We){let h=t.width>0?e.width/t.width:1,o=t.height>0?e.height/t.height:1,l=s===null?null:{topLeft:{x:s.topLeft.x*h,y:s.topLeft.y*o},topRight:{x:s.topRight.x*h,y:s.topRight.y*o},bottomRight:{x:s.bottomRight.x*h,y:s.bottomRight.y*o},bottomLeft:{x:s.bottomLeft.x*h,y:s.bottomLeft.y*o}},r=qe(l,e,i)??{x:0,y:0,width:e.width,height:e.height},c=ge(r.width,r.height,a),u=Math.max(1,Math.round(r.width*c)),f=Math.max(1,Math.round(r.height*c)),d=null;if(l!==null){let m=C(l);d=me({x:(m.x-r.x)*c,y:(m.y-r.y)*c,width:m.width*c,height:m.height*c},{width:u,height:f})}return{crop:r,width:u,height:f,docRegion:d}}n(pe,"pt");function Ge(s,t,e,i=Pe){if(e==="LOW")return null;let a=s?.width?.max,h=s?.height?.max;if(typeof a!="number"||typeof h!="number"||a<=0||h<=0)return null;let o=Math.max(a,h),l=Math.min(a,h),r=Math.min(o,Math.max(i.width,i.height)),c=Math.min(l,Math.min(i.width,i.height));return r<=Math.max(t.width,t.height)?null:{width:{ideal:r},height:{ideal:c}}}n(Ge,"de");function je(s){let t={},e=s?.imageWidth,i=s?.imageHeight;if(typeof e?.max=="number"&&e.max>0){let a=typeof i?.max=="number"&&i.max>0?e.max/i.max:1.3333333333333333,h=a>=1?se:se*a,o=Math.min(e.max,Math.floor(h)),l=typeof e.step=="number"&&e.step>0?e.step:1,r=typeof e.min=="number"?e.min:0;o=Math.max(r,r+Math.floor((o-r)/l)*l),t.imageWidth=o}return s?.fillLightMode?.includes("off")===!0&&(t.fillLightMode="off"),t}n(je,"me");function Be(s,t){if(s.width<=0||s.height<=0||t.width<=0||t.height<=0)return!1;let e=s.width>s.height,i=t.width>t.height;return e!==i&&s.width!==s.height&&t.width!==t.height?!1:Math.max(s.width,s.height)>=1.2*Math.max(t.width,t.height)}n(Be,"fe");function He(s,t,e,i){if(e===null)return!1;let a=C(s),h=C(e);if(t.width<=0||i.width<=0)return!1;let o=a.width/t.width,l=h.width/i.width;return l>0&&o>=.6*l&&o<=1.25*l}n(He,"pe");var ae=3500,Qe=.92;function Me(){let s=globalThis.ImageCapture;return typeof s=="function"?s:null}n(Me,"ye");function Xe(s){return/AppleWebKit\//.test(s)&&!/(Chrome|Chromium|Edg|OPR)\//.test(s)}n(Xe,"$e");function Ue(s,t=typeof navigator>"u"?"":navigator.userAgent){return Me()!==null&&!Xe(t)&&s!=null&&s.kind==="video"&&s.readyState==="live"}n(Ue,"Me");function he(s,t){return new Promise((e,i)=>{let a=setTimeout(()=>i(new Error("takePhoto timed out")),t);s.then(h=>{clearTimeout(a),e(h)},h=>{clearTimeout(a),i(h)})})}n(he,"be");function ft(s,t){let e=document.createElement("canvas");return e.width=s,e.height=t,e}n(ft,"gt");function Ke(s,t){return new Promise((e,i)=>{s.toBlob(a=>a?e(a):i(new Error("toBlob failed")),"image/jpeg",t)})}n(Ke,"ti");async function ye(s,t,e,i,a){let h=ft(e,i),o=ft(1,1);try{let l=h.getContext("2d");if(l===null)throw new Error("2d context unavailable");l.imageSmoothingQuality="high",l.drawImage(s,t.x,t.y,t.width,t.height,0,0,e,i);let r=await Ke(h,Qe),c=a===null?null:Ut({topLeft:{x:a.x,y:a.y},topRight:{x:a.x+a.width,y:a.y},bottomRight:{x:a.x+a.width,y:a.y+a.height},bottomLeft:{x:a.x,y:a.y+a.height}},{width:e,height:i},{width:e,height:i}),u=Kt(h,c),f=ge(e,i,Ne);return o.width=Math.max(1,Math.round(e*f)),o.height=Math.max(1,Math.round(i*f)),o.getContext("2d")?.drawImage(h,0,0,o.width,o.height),{blob:r,previewDataUrl:o.toDataURL("image/jpeg",.85),sharpness:u}}finally{h.width=0,h.height=0,o.width=0,o.height=0}}n(ye,"ke");function Ye(s,t){let e=Math.min(1,t/s.width),i=ft(Math.max(1,Math.round(s.width*e)),Math.max(1,Math.round(s.height*e)));try{let a=i.getContext("2d",{willReadFrequently:!0});return a===null?null:(a.imageSmoothingQuality="high",a.drawImage(s,0,0,i.width,i.height),a.getImageData(0,0,i.width,i.height))}finally{i.width=0,i.height=0}}n(Ye,"ei");async function Ve(s,t,e,i){let a={width:Math.max(1,s.videoWidth),height:Math.max(1,s.videoHeight)},h=pe(t,e,a,i);return{...await ye(s,h.crop,h.width,h.height,h.docRegion),docRegion:h.docRegion,source:"video",width:h.width,height:h.height}}n(Ve,"De");async function Ze(s,t,e,i,a){let h=Me();if(h===null)return null;let o=null;try{let l=new h(a.track),r=await he(l.getPhotoCapabilities?.()??Promise.resolve({}),ae).catch(()=>({})),c=await he(l.takePhoto(je(r)),ae);o=await createImageBitmap(c);let u={width:s.videoWidth,height:s.videoHeight};if(!Be(o,u))return null;let f=Ye(o,a.detectWidth),d=null;f!==null&&t!==null&&(d=await a.detect(f).catch(()=>null));let m=f??{width:o.width,height:o.height};d!==null&&!He(d,m,t,e)&&(d=null);let g=pe(d,m,o,i);return{...await ye(o,g.crop,g.width,g.height,g.docRegion),docRegion:g.docRegion,source:"photo",width:g.width,height:g.height}}catch{return null}finally{o?.close()}}n(Ze,"xe");var yt=Object.freeze({width:3840,height:2160,lensSelection:!0,continuousFocus:!0,refocusBeforePhotoMs:350,zoomMax:2,zoomNoFocusInfo:1.5,zoomMinSourcePx:2160,fillDistanceM:Object.freeze({id1:.11,id3:.15}),focusMarginFrac:.2,stillSharpnessMin:.16,stillRefusalsMax:2,focusFarFillFrac:.45,noDocFarHintMs:1500,zoomFallbackMs:8e3}),R=n((s,t,e)=>typeof s=="number"&&Number.isFinite(s)&&s>=t&&s<=e?s:void 0,"S");function Ri(s){let t=yt,e=s!==null&&typeof s=="object"?s:{},i=e.fillDistanceM!==null&&typeof e.fillDistanceM=="object"?e.fillDistanceM:{},a=n((h,o)=>typeof h=="boolean"?h:o,"n");return{width:R(e.width,640,7680)??t.width,height:R(e.height,480,4320)??t.height,lensSelection:a(e.lensSelection,t.lensSelection),continuousFocus:a(e.continuousFocus,t.continuousFocus),refocusBeforePhotoMs:R(e.refocusBeforePhotoMs,0,2e3)??t.refocusBeforePhotoMs,zoomMax:R(e.zoomMax,1,5)??t.zoomMax,zoomNoFocusInfo:R(e.zoomNoFocusInfo,1,5)??t.zoomNoFocusInfo,zoomMinSourcePx:R(e.zoomMinSourcePx,0,8e3)??t.zoomMinSourcePx,fillDistanceM:{id1:R(i.id1,.03,1)??t.fillDistanceM.id1,id3:R(i.id3,.03,1)??t.fillDistanceM.id3},focusMarginFrac:R(e.focusMarginFrac,0,2)??t.focusMarginFrac,stillSharpnessMin:R(e.stillSharpnessMin,0,10)??t.stillSharpnessMin,stillRefusalsMax:R(e.stillRefusalsMax,0,10)??t.stillRefusalsMax,focusFarFillFrac:R(e.focusFarFillFrac,0,1)??t.focusFarFillFrac,noDocFarHintMs:R(e.noDocFarHintMs,0,6e4)??t.noDocFarHintMs,zoomFallbackMs:R(e.zoomFallbackMs,0,12e4)??t.zoomFallbackMs}}n(Ri,"Si");var mt="sekyro.doc.camera";function Je(){try{let s=globalThis.localStorage?.getItem(mt);return typeof s=="string"&&s!==""?s:null}catch{return null}}n(Je,"ii");function oe(s){try{s===null?globalThis.localStorage?.removeItem(mt):globalThis.localStorage?.setItem(mt,s)}catch{}}n(oe,"we");var gt=n((s,t)=>Array.isArray(s?.focusMode)&&s.focusMode.includes(t),"rt");function re(s,t,e){if(!gt(s,"single-shot"))return null;let i=n(a=>Math.min(1,Math.max(0,Number.isFinite(a)?a:.5)),"o");return{focusMode:"single-shot",pointsOfInterest:[{x:i(t),y:i(e)}]}}n(re,"Mt");function $e(s,t,e,i=yt){let a=s?.zoom?.min,h=s?.zoom?.max;if(typeof h!="number"||h<=1)return 1;let o=e==="ID-3"?i.fillDistanceM.id3:i.fillDistanceM.id1,l=s?.focusDistance?.min,r;if(typeof l=="number"&&l>0&&l<1){if(r=l*(1+i.focusMarginFrac)/o,r<=1.05)return 1}else{if(Math.min(t.width,t.height)<i.zoomMinSourcePx)return 1;r=i.zoomNoFocusInfo}let c=Math.min(r,i.zoomMax,h);typeof a=="number"&&(c=Math.max(c,a));let u=s?.zoom?.step;return typeof u=="number"&&u>0&&(c=Math.round(c/u)*u),c>1.01?Number(c.toFixed(2)):1}n($e,"Se");function pt(s){try{return s.getVideoTracks?.()[0]}catch{return}}n(pt,"yt");function le(s){if(s!==null)for(let t of s.getTracks())t.stop()}n(le,"ve");function ti(s){try{let t=pt(s)?.getCapabilities?.();return!Array.isArray(t?.focusMode)||t.focusMode.includes("continuous")}catch{return!0}}n(ti,"oi");async function ei(s){let t=n(h=>({audio:!1,video:{...h,width:{ideal:s.base.width},height:{ideal:s.base.height}}}),"t"),e=n(h=>s.getUserMedia(t({deviceId:{exact:h}})),"e"),i=n(()=>s.getUserMedia(t({facingMode:{ideal:"environment"}})),"o");if(s.lensSelection){let h=Je();if(h!==null)try{return{stream:await e(h),lens:"stored"}}catch{oe(null)}}let a=await i();if(!s.lensSelection||s.enumerateDevices===void 0)return{stream:a,lens:"default"};try{let h=Bt(await s.enumerateDevices()).slice(0,3);if(h.length===0)return{stream:a,lens:"default"};let o=null;for(let l of h){let r=a!==null?pt(a)?.getSettings?.().deviceId:void 0;if(a===null||r!==l){le(a),a=null;try{a=await e(l)}catch{continue}}if(o??(o=l),ti(a))return oe(l),{stream:a,lens:"selected"}}if(a!==null&&o!==null&&pt(a)?.getSettings?.().deviceId===o)return{stream:a,lens:"selected"};if(le(a),a=null,o!==null)try{return{stream:await e(o),lens:"selected"}}catch{}return{stream:await i(),lens:"default"}}catch{return{stream:a??await i(),lens:"default"}}}n(ei,"Te");var ht=Object.freeze({brightness:0,glare:0,cardGlare:0,sharpness:0,fill:0,shape:0,content:0,offsetX:0,offsetY:0,edgeConfidence:0,box:null}),A=n(s=>Math.min(1,Math.max(0,s)),"L");function ii(s,t,e,i=.06){let a=Math.max(s.width/e,s.height),h=a*e,o=(s.width-h)/2,l=(s.height-a)/2,r=A((t.x-t.width*i-o)/h),c=A((t.y-t.height*i-l)/a),u=A((t.x+t.width*(1+i)-o)/h),f=A((t.y+t.height*(1+i)-l)/a);return{x:r,y:c,width:u-r,height:f-c}}n(ii,"Re");function si(s,t,e={}){let i=e.edgePeakFrac??0,{width:a,height:h,data:o}=s;if(a<=0||h<=0)return ht;let l=A(t.x),r=A(t.y),c={x:l,y:r,width:Math.max(0,A(t.x+t.width)-l),height:Math.max(0,A(t.y+t.height)-r)};if(c.width<=0||c.height<=0)return ht;let u=c.x*a,f=c.y*h,d=(c.x+c.width)*a,m=(c.y+c.height)*h,g=(d-u)*.15,b=(m-f)*.15,w=n((p,M,_)=>Math.min(_,Math.max(M,p)),"y"),k=w(Math.floor(u-g),0,a-1),S=w(Math.floor(f-b),0,h-1),D=w(Math.ceil(d+g),k+1,a),I=w(Math.ceil(m+b),S+1,h),F=Math.max(1,Math.ceil(Math.max(D-k,I-S)/320)),y=Math.floor((D-k+F-1)/F),x=Math.floor((I-S+F-1)/F);if(y<3||x<3)return ht;let v=new Int32Array(y*x);for(let p=0;p<x;p++){let M=S+p*F;for(let _=0;_<y;_++){let T=(M*a+k+_*F)*4;v[p*y+_]=(o[T]??0)*77+(o[T+1]??0)*150+(o[T+2]??0)*29>>8}}let L=n((p,M)=>(p-M-.5)/F,"C"),B=L(u,k),rt=L(d,k),lt=L(f,S),nt=L(m,S),wt=(d-u)/F,bt=(m-f)/F,kt=w(Math.ceil(B),0,y-1),we=w(Math.floor(rt),kt,y-1),xt=w(Math.ceil(lt),0,x-1),be=w(Math.floor(nt),xt,x-1),vt=0,St=0,H=0,Ft=0,Rt=0,Q=0;for(let p=xt;p<=be;p++)for(let M=kt;M<=we;M++){let _=v[p*y+M];if(vt+=_,_>=248&&St++,H++,M>=1&&M<y-1&&p>=1&&p<x-1){let T=v[p*y+M-1]+v[p*y+M+1]+v[(p-1)*y+M]+v[(p+1)*y+M]-4*_;Ft+=T,Rt+=T*T,Q++}}let ke=H>0?vt/H:0,_t=H>0?St/H:0,Dt=Q>0?Ft/Q:0,xe=Q>0?Math.max(0,Rt/Q-Dt*Dt):0,X=new Float64Array(y),U=new Float64Array(x);for(let p=0;p<x;p++)for(let M=1;M<y-1;M++)X[M]=X[M]+Math.abs(v[p*y+M+1]-v[p*y+M-1]);for(let p=1;p<x-1;p++)for(let M=0;M<y;M++)U[p]=U[p]+Math.abs(v[(p+1)*y+M]-v[(p-1)*y+M]);let O=st(X,!0,B,i),E=st(X,!1,rt,i),P=st(U,!0,lt,i),W=st(U,!1,nt,i),Tt=(E.position-O.position)/wt,At=(W.position-P.position)/bt,ve=At>0?Tt/At:0,Se=((O.position+E.position)/2-(B+rt)/2)/wt,Fe=((P.position+W.position)/2-(lt+nt)/2)/bt,zt=ne(X),Ct=ne(U),Re=zt<=0||Ct<=0?0:Math.min(Math.min(O.value,E.value)/zt,Math.min(P.value,W.value)/Ct),J=n((p,M)=>M+(p+.5)*F,"$"),It=_t,Lt=0;{let p=(E.position-O.position)*.06,M=(W.position-P.position)*.06,_=w(Math.ceil(O.position+p),0,y-1),T=w(Math.floor(E.position-p),0,y-1),_e=w(Math.ceil(P.position+M),0,x-1),Ot=w(Math.floor(W.position-M),0,x-1),Et=0,$=0,Pt=0;for(let N=_e;N<=Ot;N++)for(let q=_;q<=T;q++){$++;let K=v[N*y+q];K>=248&&Et++;let De=q+2<=T?v[N*y+q+2]:K,Te=N+2<=Ot?v[(N+2)*y+q]:K;(Math.abs(De-K)>=24||Math.abs(Te-K)>=24)&&Pt++}$>=16&&(It=Et/$,Lt=Pt/$)}return{brightness:ke,glare:_t,cardGlare:It,sharpness:xe,fill:Tt,shape:ve,content:Lt,offsetX:Se,offsetY:Fe,edgeConfidence:Re,box:{left:J(O.position,k),right:J(E.position,k),top:J(P.position,S),bottom:J(W.position,S)}}}n(si,"Fe");function st(s,t,e,i){let a=s.length,h=Math.max(1,Math.floor(a*.45)),o=t?1:Math.max(1,a-1-h),l=t?Math.min(a-2,h):a-2,r=o;for(let m=o;m<=l;m++)s[m]>s[r]&&(r=m);if(i>0&&i<1){let m=s[r]*i,g=r,b=Math.abs(r-e);for(let w=o;w<=l;w++){let k=s[w];if(k<m||k<(s[w-1]??0)||k<(s[w+1]??0))continue;let S=Math.abs(w-e);S<b&&(g=w,b=S)}r=g}let c=r>0?s[r-1]:0,u=s[r],f=r<a-1?s[r+1]:0,d=c+u+f;return{position:d>0?r+(f-c)/d:r,value:u}}n(st,"at");function ne(s){if(s.length<3)return 0;let t=0;for(let e=1;e<s.length-1;e++)t+=s[e];return t/(s.length-2)}n(ne,"_e");function ai(s){let t=s.box;return t===null||t.right-t.left<4||t.bottom-t.top<4?null:{topLeft:{x:t.left,y:t.top},topRight:{x:t.right,y:t.top},bottomRight:{x:t.right,y:t.bottom},bottomLeft:{x:t.left,y:t.bottom}}}n(ai,"Ce");var ot=Object.freeze({fillMin:.82,fillMax:1.06,offsetMax:.06,glareMax:.025,sharpnessMin:180,edgeConfidenceMin:1.6,darkBrightness:70,lockMs:450,steadyMs:900,steadyFillMin:.45,steadyFillMax:1.3,steadyFillDelta:.06,steadyOffsetDelta:.04,steadyRefMs:100,edgePeakFrac:.4,shapeTolerance:.2,contentMin:.1});function _i(s){let t=s!==null&&typeof s=="object"?s:{},e={...ot};for(let i of Object.keys(ot)){let a=t[i];typeof a=="number"&&Number.isFinite(a)&&a>=0&&a<=1e6&&(e[i]=a)}return e}n(_i,"Ai");var j,hi=(j=class{constructor(t=ot){this.t=t,this.goodSince=null,this.steadySince=null,this.last=null}reset(){this.goodSince=null,this.steadySince=null,this.last=null}tick(t,e){let i=this.t,a=i.shapeTolerance<=0||Math.abs(t.shape-1)<=i.shapeTolerance,h=t.edgeConfidence>=i.edgeConfidenceMin&&a&&t.content>=i.contentMin,o=t.fill>=i.fillMin&&t.fill<=i.fillMax,l=Math.abs(t.offsetX)<=i.offsetMax&&Math.abs(t.offsetY)<=i.offsetMax,r=t.cardGlare<=i.glareMax,c=t.sharpness>=i.sharpnessMin,u=this.last;this.last={fill:t.fill,offsetX:t.offsetX,offsetY:t.offsetY,at:e};let f=u!==null&&i.steadyRefMs>0?Math.min(3,Math.max(1,(e-u.at)/i.steadyRefMs)):1,d=h&&r&&c&&t.fill>=i.steadyFillMin&&t.fill<=i.steadyFillMax&&u!==null&&Math.abs(t.fill-u.fill)<=i.steadyFillDelta*f&&Math.abs(t.offsetX-u.offsetX)<=i.steadyOffsetDelta*f&&Math.abs(t.offsetY-u.offsetY)<=i.steadyOffsetDelta*f,m=h&&o&&l&&r&&c,g;if(h?r?t.fill<i.fillMin?g="too_small":t.fill>i.fillMax?g="too_big":c?l?g="locking":g="off_center":g="blurry":g="glare":g="no_card",m){if(d&&(this.steadySince??(this.steadySince=e)),this.goodSince??(this.goodSince=e),e-this.goodSince>=i.lockMs)return{detected:h,ready:!0,via:"good",blocker:"locking"};let b=this.steadySince!==null&&e-this.steadySince>=i.steadyMs;return{detected:h,ready:b,via:b?"steady":null,blocker:"locking"}}if(this.goodSince=null,d){this.steadySince??(this.steadySince=e);let b=e-this.steadySince>=i.steadyMs;return{detected:h,ready:b,via:b?"steady":null,blocker:b?"locking":"steadying"}}return this.steadySince=null,{detected:h,ready:!1,via:null,blocker:g}}},n(j,"ct"),j),Z=null;async function oi(s){return Z===null&&(Z=(await import("./detector-scanic-S4PB2RNW-3KSM3MW5.js")).detectQuad),Z(s)}n(oi,"ni");async function ri(s){let t=Jt(s);return t===null?null:{topLeft:{x:t.x,y:t.y},topRight:{x:t.x+t.width,y:t.y},bottomRight:{x:t.x+t.width,y:t.y+t.height},bottomLeft:{x:t.x,y:t.y+t.height}}}n(ri,"si");function Di(){Z===null&&import("./detector-scanic-S4PB2RNW-3KSM3MW5.js").then(s=>{Z=s.detectQuad}).catch(()=>{})}n(Di,"ji");var ce=4e3,li=2,ue=3,ni=Object.freeze({LOW:3,MID:5,HIGH:6}),Mt=Object.freeze({manualShutterMs:6e3,detectedNoLockMs:1950});function Ti(s){let t=s!==null&&typeof s=="object"?s:{},e=n((i,a,h)=>typeof i=="number"&&Number.isFinite(i)&&i>=a&&i<=h?i:void 0,"e");return{manualShutterMs:e(t.manualShutterMs,1e3,6e4)??Mt.manualShutterMs,detectedNoLockMs:e(t.steadyMs,300,3e4)!==void 0?t.steadyMs+(e(t.lockMs,0,1e4)??450):Mt.detectedNoLockMs}}n(Ti,"Yi");var z,Ai=(z=class{constructor(t){this.torchOn=!1,this.stillRefusals=0,this.zoom=1,this.positioningSince=null,this.detectedSince=null,this.lastSeenAt=null,this.lastGuideQuad=null,this.lastOcrReady=null,this.shutterOffered=!1,this.stats=z.freshStats(),this.handlers=new Map,this.stream=null,this.timer=null,this.state="idle",this.lastGuidance=null,this.attempt=0,this.capturing=!1,this.feedback=new ze,this.lastFeedbackKey=null,this.lastQuad=null,this.lastDetect=null,this.frameWatch=null,this.reopened=!1,this.lit=!1,this.blackTicks=0,this.offEnded=null,this.opts=t,this.gate=new ee(t.format??"ID-1",t.thresholds);let e=t.deviceClass??Qt(Ht());this.deviceClass=e,this.camera=t.camera??yt,this.shutterTuning=t.shutter??Mt,this.guideTuning=t.guideLock??ot,this.guideLock=new hi(this.guideTuning),this.cadenceMs=1e3/ni[e]}on(t,e){let i=this.handlers.get(t);return i||(i=new Set,this.handlers.set(t,i)),i.add(e),()=>i?.delete(e)}emit(t,e){for(let i of[...this.handlers.get(t)??[]])i(e)}async start(){let t=this.state==="error"?this.resumePlayback():null,e=++this.attempt;if(this.clearFrameWatch(),this.gate.reset(),this.resetSide(),this.feedback.reset(),this.lastFeedbackKey=null,this.lastGuidance=null,this.capturing=!1,this.lit=!1,this.blackTicks=0,t!==null&&await t&&e===this.attempt){this.setState("positioning"),this.scheduleTick(e),this.watchFrames(e);return}if(e===this.attempt){this.releaseStream(),jt(),this.setState("preflight");try{let i=this.opts.getUserMedia??(o=>navigator.mediaDevices.getUserMedia(o));this.setState("acquiring");let a=this.opts.enumerateDevices??(this.opts.getUserMedia===void 0&&typeof navigator<"u"&&navigator.mediaDevices?.enumerateDevices?()=>navigator.mediaDevices.enumerateDevices():void 0),h=await ei({getUserMedia:i,...a!==void 0?{enumerateDevices:a}:{},lensSelection:this.camera.lensSelection,base:Ee});if(e!==this.attempt){for(let o of h.stream.getTracks())o.stop();return}if(this.stream=h.stream,Wt(this.stream),Gt(this.stream),this.watchEnded(e),this.opts.upgradeResolution!==!1&&await this.upgradeResolution(),e!==this.attempt||(await this.applyFocusAndZoom(),e!==this.attempt)||(this.opts.video.srcObject=this.stream,await this.opts.video.play().catch(()=>{}),e!==this.attempt))return;this.setState("positioning"),this.scheduleTick(e),this.watchFrames(e)}catch(i){if(e!==this.attempt)return;let a=qt(i),h=Nt(i);this.setState("error"),this.emit("error",{kind:a,retryable:!0,detail:h===void 0?{phase:"acquiring"}:{phase:"acquiring",name:h}})}}}resumePlayback(){let t=this.opts.video,e=this.videoTrack();if(this.stream===null||e===null||e.readyState!=="live"||t.srcObject!==this.stream)return null;try{return Promise.resolve(t.play()).then(()=>this.framesNow(),()=>!1)}catch{return null}}framesNow(){let t=this.opts.video;return this.opts.hasFrames!==void 0?this.opts.hasFrames(t):!t.paused&&t.readyState>=2&&t.videoWidth>0}watchFrames(t){let e=this.opts.firstFrameMs??ce;e<=0||(this.clearFrameWatch(),this.frameWatch=setTimeout(()=>{if(this.frameWatch=null,!(t!==this.attempt||this.state!=="positioning")){if(this.framesNow()&&this.blackTicks<ue){this.reopened=!1;return}this.cameraDead(t)}},e))}clearFrameWatch(){this.frameWatch!==null&&clearTimeout(this.frameWatch),this.frameWatch=null}watchEnded(t){this.offEnded?.(),this.offEnded=null;let e=this.videoTrack();if(e===null||typeof e.addEventListener!="function")return;let i=n(()=>{t===this.attempt&&(this.state==="positioning"||this.state==="acquiring")&&this.cameraDead(t)},"o");e.addEventListener("ended",i),this.offEnded=()=>e.removeEventListener?.("ended",i)}cameraDead(t){if(t!==this.attempt)return;let e=this.videoTrack(),i=e!==null&&e.readyState==="live"&&!e.muted&&this.opts.video.paused&&!this.framesNow();if(!i&&!this.reopened){this.reopened=!0,this.start();return}this.attempt+=1,this.timer!==null&&(this.opts.clearTimer??clearTimeout)(this.timer),this.timer=null,this.clearFrameWatch(),i||this.releaseStream(),this.reopened=!1,this.setState("error"),this.emit("error",{kind:"generic",retryable:!0,detail:{phase:"acquiring"}})}releaseStream(){if(this.offEnded?.(),this.offEnded=null,this.stream)for(let t of this.stream.getTracks())t.stop();this.stream=null,this.opts.video.srcObject!==null&&this.opts.video.srcObject!==void 0&&(this.opts.video.srcObject=null)}rearm(t){t!==void 0&&(this.opts.side=t),this.gate.reset(),this.resetSide(),this.feedback.reset(),this.lastFeedbackKey=null,this.lastGuidance=null,this.capturing=!1,this.stillRefusals=0,this.state==="captured"&&(this.setState("positioning"),this.scheduleTick(this.attempt))}async captureNow(){if(this.state!=="positioning"||this.capturing)return;let t=this.opts.video,e=this.lastDetect?.width??Math.max(1,t.videoWidth),i=this.lastDetect?.height??Math.max(1,t.videoHeight),a=this.lastQuad??this.lastGuideQuad??{topLeft:{x:0,y:0},topRight:{x:e,y:0},bottomRight:{x:e,y:i},bottomLeft:{x:0,y:i}},h=(this.opts.now??(()=>performance.now()))(),o=this.feedback.force("processing",h);this.lastFeedbackKey=o.key,this.emit("feedback",o),await this.fire(this.attempt,this.lastOcrReady!==null?this.lastOcrReady.quad:a,{width:e,height:i,tickSharpness:this.lastDetect?.tickSharpness??0},this.lastOcrReady?.via??"manual")}captureReport(){let t=this.stats;return{...this.opts.side!==void 0?{side:this.opts.side}:{},format:this.opts.format??"ID-1",deviceClass:this.deviceClass,video:{width:this.opts.video.videoWidth||0,height:this.opts.video.videoHeight||0},zoom:this.zoom,...t.zoomFallbackAtMs!==void 0?{zoomFallbackAtMs:t.zoomFallbackAtMs}:{},...t.msToCapture!==void 0?{msToCapture:t.msToCapture}:{},...t.via!==void 0?{via:t.via}:{},...t.shutterAtMs!==void 0?{shutterAtMs:t.shutterAtMs}:{},...t.shutterReason!==void 0?{shutterReason:t.shutterReason}:{},ticks:t.ticks,quadFraming:{...t.quadFraming},qualityBlockers:{...t.qualityBlockers},guideBlockers:{...t.guideBlockers},stillRefusals:t.stillRefusals,...this.ocrReport()}}ocrReport(){let t=this.opts.ocr;if(t===void 0)return{};let e=(this.opts.format??"ID-1")==="ID-3"||this.opts.side==="single"?"single":this.opts.side==="verso"?"verso":"recto",i=t.report(e,this.stats.via,(this.opts.now??(()=>performance.now()))());return i===null?{}:{ocr:i}}static freshStats(){return{ticks:0,quadFraming:{},qualityBlockers:{},guideBlockers:{},stillRefusals:0}}setGuide(t){t===void 0?delete this.opts.guide:this.opts.guide=t,this.guideLock.reset()}guideRegion(t){let e=t.width/Math.max(1,t.height),i=this.opts.guide;if(i!==void 0&&i.viewAspect>0){let l={width:i.viewAspect,height:1},r={x:i.rect.x*i.viewAspect,y:i.rect.y,width:i.rect.width*i.viewAspect,height:i.rect.height};return ii(l,r,e,0)}let a=Vt(this.opts.format??"ID-1").center,h=.86,o=h*e/a;return o>.84&&(o=.84,h=o*a/e),{x:(1-h)/2,y:(1-o)/2,width:h,height:o}}resetSide(){this.positioningSince=null,this.detectedSince=null,this.lastSeenAt=null,this.guideLock.reset(),this.lastGuideQuad=null,this.lastOcrReady=null,this.opts.ocr?.reset(),this.stats=z.freshStats(),this.shutterOffered&&(this.shutterOffered=!1,this.emit("shutter",{available:!1}))}withdrawShutter(){this.shutterOffered&&(this.shutterOffered=!1,this.emit("shutter",{available:!1}))}zoomFallback(t){let e=this.videoTrack();if(e===null||this.zoom<=1)return;let i=this.focusCaps(),a=typeof i?.zoom?.min=="number"?Math.max(i.zoom.min,1):1;this.zoom=a,this.stats.zoomFallbackAtMs=Math.round(t-(this.positioningSince??t)),this.guideLock.reset(),this.gate.reset(),e.applyConstraints({advanced:[{zoom:a}]}).catch(()=>{})}offerShutter(t,e){this.shutterOffered||(this.shutterOffered=!0,this.stats.shutterAtMs=Math.round(e-(this.positioningSince??e)),this.stats.shutterReason=t,this.emit("shutter",{available:!0,reason:t}))}torchAvailable(){try{return this.stream?.getVideoTracks?.()[0]?.getCapabilities?.()?.torch===!0}catch{return!1}}async setTorch(t){this.torchOn=t;try{await this.stream?.getVideoTracks?.()[0]?.applyConstraints({advanced:[{torch:t}]})}catch{}}destroy(){if(this.attempt+=1,this.timer!==null&&(this.opts.clearTimer??clearTimeout)(this.timer),this.timer=null,this.clearFrameWatch(),this.offEnded?.(),this.offEnded=null,this.stream)for(let t of this.stream.getTracks())t.stop();this.stream=null,this.opts.video.srcObject=null}async upgradeResolution(){try{let t=this.stream?.getVideoTracks?.()[0];if(t===void 0)return;let e=t.getSettings?.()??{},i=Ge(t.getCapabilities?.(),{width:e.width??0,height:e.height??0},this.deviceClass,{width:this.camera.width,height:this.camera.height});i!==null&&await t.applyConstraints(i)}catch{}}focusCaps(){try{return this.videoTrack()?.getCapabilities?.()??null}catch{return null}}async applyFocusAndZoom(){let t=this.videoTrack();if(t===null)return;let e=this.focusCaps();this.camera.continuousFocus&&gt(e,"continuous")&&await t.applyConstraints({advanced:[{focusMode:"continuous"}]}).catch(()=>{});let i={width:0,height:0};try{let h=t.getSettings?.()??{};i={width:h.width??0,height:h.height??0}}catch{}let a=$e(e,i,this.opts.format??"ID-1",this.camera);if(a>1)try{await t.applyConstraints({advanced:[{zoom:a}]}),this.zoom=a}catch{this.zoom=1}}async focusAt(t,e){let i=this.videoTrack(),a=re(this.focusCaps(),t,e);if(!(i===null||a===null))try{await i.applyConstraints({advanced:[a]}),(this.opts.setTimer??setTimeout)(()=>{this.restoreContinuous()},1500)}catch{}}async restoreContinuous(){let t=this.videoTrack();t===null||!this.camera.continuousFocus||!gt(this.focusCaps(),"continuous")||await t.applyConstraints({advanced:[{focusMode:"continuous"}]}).catch(()=>{})}async refocusOn(t,e){let i=this.camera.refocusBeforePhotoMs,a=this.videoTrack();if(i<=0||a===null||e.width<=0||e.height<=0)return;let h=C(t),o=re(this.focusCaps(),(h.x+h.width/2)/e.width,(h.y+h.height/2)/e.height);if(o!==null)try{await a.applyConstraints({advanced:[o]});let l=this.opts.setTimer??setTimeout;await new Promise(r=>{l(()=>r(),i)})}catch{}}videoTrack(){try{return this.stream?.getVideoTracks?.()[0]??null}catch{return null}}async takeStill(t,e,i){if(this.opts.captureStill!==void 0)return this.opts.captureStill(this.opts.video,t,e);let a=this.opts.format??"ID-1",h=this.videoTrack();if(i&&this.opts.photoCapture!==!1&&this.deviceClass!=="LOW"&&!this.torchOn&&h!==null&&Ue(h)){await this.refocusOn(t,e);let o=await Ze(this.opts.video,t,e,a,{track:h,detect:this.detector(),detectWidth:tt});if(this.restoreContinuous(),o!==null)return o}return Ve(this.opts.video,t,e,a)}detector(){return this.opts.detect??((this.opts.format??"ID-1")==="ID-3"?ri:oi)}setState(t){this.state=t,this.emit("statechange",{state:t})}scheduleTick(t){let e=this.opts.setTimer??setTimeout;this.timer=e(()=>{this.tick(t)},this.cadenceMs)}async tick(t){if(t!==this.attempt||this.state!=="positioning"||this.capturing)return;let e=this.opts.now??(()=>performance.now()),i=this.opts.grabDetectFrame??fe,a=this.detector(),h=i(this.opts.video,tt);if(h===null){this.scheduleTick(t);return}if(!this.lit){if(ut(h)>li)this.lit=!0,this.blackTicks=0;else if(++this.blackTicks>=ue&&this.frameWatch===null&&(this.opts.firstFrameMs??ce)>0){this.cameraDead(t);return}}let o=null;try{o=await a(h)}catch{o=null}if(t!==this.attempt)return;let l=o!==null?at(h,o):h,r=e(),c={sharpness:Y(l),exposure:Xt(l),meanLuma:ut(l),specularFraction:Ie(l)},u=Oe({format:this.opts.format??"ID-1",quad:o,frameWidth:h.width,frameHeight:h.height,measures:c,...this.opts.thresholds!==void 0?{thresholds:this.opts.thresholds}:{}}),f=this.gate.tick({timestampMs:r,quad:o,quality:c,frameWidth:h.width,frameHeight:h.height}),d=(this.opts.format??"ID-1")!=="ID-3"?si(h,this.guideRegion(h),{edgePeakFrac:this.guideTuning.edgePeakFrac}):ht,m=this.guideLock.tick(d,r);this.lastGuideQuad=m.detected?ai(d):null;let g=this.capturing?null:this.ocrTick(h,o,d,m.detected,u,r);this.positioningSince??(this.positioningSince=r);let b=this.stats;if(b.ticks+=1,b.quadFraming[u.framing]=(b.quadFraming[u.framing]??0)+1,u.framing==="ok"&&!f.ready){let x=u.lighting!=="ok"?u.lighting:u.glare!=="ok"?"glare":u.blur!=="ok"?"blurry":"steadying";b.qualityBlockers[x]=(b.qualityBlockers[x]??0)+1}b.guideBlockers[m.blocker]=(b.guideBlockers[m.blocker]??0)+1,o!==null||m.detected?(this.detectedSince??(this.detectedSince=r),this.lastSeenAt=r):this.detectedSince=null,this.lastSeenAt!==null&&r-this.lastSeenAt<=pi?r-this.positioningSince>=this.shutterTuning.manualShutterMs?this.offerShutter("timeout",r):g?.suspendQuality!==!0&&this.detectedSince!==null&&r-this.detectedSince>=this.shutterTuning.detectedNoLockMs&&this.offerShutter("detected_no_lock",r):this.withdrawShutter();let w=r-(this.lastSeenAt??this.positioningSince);this.zoom>1&&this.camera.zoomFallbackMs>0&&w>=this.camera.zoomFallbackMs&&this.zoomFallback(r),this.emit("checks",{engine:"docv1",p:f.p,plausible:f.plausible,stableTicks:f.stableTicks,quad:f.quad,frameWidth:h.width,frameHeight:h.height,analysis:u,ready:g?.suspendQuality!==!0&&(f.ready&&o!==null||m.ready&&this.lastGuideQuad!==null)||this.lastOcrReady!==null,guide:{detected:m.detected,blocker:m.blocker,fill:d.fill,shape:d.shape,content:d.content,offsetX:d.offsetX,offsetY:d.offsetY},...g!==null&&g.mode!=="off"?{ocr:{mode:g.mode,...g.mrz?{mrz:g.mrz}:{},...g.lock?{lock:g.lock}:{}}}:g?.mrz?{ocr:{mode:g.mode,mrz:g.mrz}}:{}}),this.lastQuad=f.plausible?o:null,this.lastDetect={width:h.width,height:h.height,tickSharpness:c.sharpness};let k=Ae(u);u.framing!=="ok"&&m.detected&&(k=gi(m.blocker,d.brightness<this.guideTuning.darkBrightness)),k==="blurry"&&o!==null&&ui(o,h,this.opts.format??"ID-1")>=this.camera.focusFarFillFrac&&(k="focus_far"),k==="sensing"&&this.zoom>1&&this.camera.noDocFarHintMs>0&&w>=this.camera.noDocFarHintMs&&(k="focus_far");let S=this.feedback.tick(k,r);if(S.key!==this.lastFeedbackKey&&(this.lastFeedbackKey=S.key,this.emit("feedback",S)),f.guidanceKey!==this.lastGuidance&&(this.lastGuidance=f.guidanceKey,this.emit("guidance",{key:f.guidanceKey})),this.capturing)return;let D=g?.suspendQuality!==!0,I=D&&f.ready&&o!==null,F=D&&m.ready&&this.lastGuideQuad!==null,y=this.lastOcrReady;if(y!==null&&this.opts.autoCapture!==!1){let x=this.feedback.force("processing",r);this.lastFeedbackKey=x.key,this.emit("feedback",x);let v=Y(at(h,y.quad));await this.fire(t,y.quad,{width:h.width,height:h.height,tickSharpness:v},y.via);return}if((I||F)&&this.opts.autoCapture!==!1){let x=this.feedback.force("processing",r);this.lastFeedbackKey=x.key,this.emit("feedback",x);let v=F?this.lastGuideQuad:o,L=F?m.via==="steady"?"guide_steady":"guide_good":"quad",B=F?Y(at(h,v)):c.sharpness;await this.fire(t,v,{width:h.width,height:h.height,tickSharpness:B},L);return}this.scheduleTick(t)}async fire(t,e,i,a){this.capturing=!0;let h=this.opts.grabDetectFrame??fe,o=this.opts.setTimer??setTimeout,l={width:i.width,height:i.height};try{let r={still:await this.takeStill(e,l,!0),sharpness:i.tickSharpness};if(t!==this.attempt)return;let c=r.still.source==="photo"?0:di;for(let d=0;d<c;d++){if(await new Promise(b=>{o(()=>b(),fi)}),t!==this.attempt)return;let m=h(this.opts.video,tt);if(m===null)continue;let g=Y(at(m,e));if(g>r.sharpness*mi){let b=await this.takeStill(e,l,!1);if(t!==this.attempt)return;r={still:b,sharpness:g}}}if(t!==this.attempt)return;let u=r.still.sharpness;if(this.opts.autoCapture!==!1&&a!=="manual"&&typeof u=="number"&&u>=0&&u<this.camera.stillSharpnessMin&&this.stillRefusals<this.camera.stillRefusalsMax){this.stillRefusals+=1,this.stats.stillRefusals+=1,this.guideLock.reset(),this.lastOcrReady=null,(a==="text_lock"||a==="live_mrz")&&this.opts.ocr?.rearmFace();let d=(this.opts.now??(()=>performance.now()))(),m=this.feedback.force("focus_far",d);this.lastFeedbackKey=m.key,this.emit("feedback",m),this.capturing=!1,this.gate.reset(),this.scheduleTick(t);return}this.stillRefusals=0;let f=(this.opts.now??(()=>performance.now()))();this.stats.via=a,this.stats.msToCapture=Math.round(f-(this.positioningSince??f)),this.shutterOffered&&(this.shutterOffered=!1,this.emit("shutter",{available:!1})),this.setState("captured"),this.emit("artifacts",{keyframe:r.still.blob,previewDataUrl:r.still.previewDataUrl,...this.opts.side!==void 0?{side:this.opts.side}:{},...r.still.docRegion!==void 0?{docRegion:r.still.docRegion}:{},...(()=>{let d=a==="live_mrz"?this.opts.ocr?.liveCapture():null;return d?{liveMrz:d}:{}})()})}catch{if(t!==this.attempt)return;this.capturing=!1,this.gate.reset(),this.guideLock.reset(),this.lastOcrReady=null,(a==="text_lock"||a==="live_mrz")&&this.opts.ocr?.rearmFace(),this.scheduleTick(t)}}ocrTick(t,e,i,a,h,o){let l=this.opts.ocr,r=this.opts.video;if(l===void 0||!l.hasEngine)return this.lastOcrReady=null,null;let c=r.videoWidth,u=r.videoHeight;if(c<=0||u<=0||t.width<=0||t.height<=0)return null;let f=(this.opts.format??"ID-1")==="ID-3",d=this.guideRegion(t),m={x:d.x*c,y:d.y*u,w:d.width*c,h:d.height*u},g=c/t.width,b=u/t.height,w;f&&e!==null?w=ci(C(e),g,b,c,u):w=Yt(m,l.bandTop,u);let k=f?h.glare==="ok":i.cardGlare<=this.guideTuning.glareMax,S=f?h.blur==="ok":i.sharpness>=this.guideTuning.sharpnessMin,D=l.tick({atMs:o,video:r,mrzFace:f||this.opts.side==="verso"||this.opts.side==="single",present:f||e!==null||a,card:m,band:w,portrait:u>c,glareOk:k,sharpOk:S});if(D.ready&&D.via!==void 0){let I=f?e??de(d,t):this.lastGuideQuad??de(d,t);this.lastOcrReady={quad:I,via:D.via}}else this.lastOcrReady=null;return D}},n(z,"i"),z);function ci(s,t,e,i,a){let h=Math.min(i,s.width*1.06*t),o=Math.min(a,Math.max(s.height*1.6*e,h/5)),l=(s.y+s.height/2)*e,r=Math.max(0,Math.min(i-h,(s.x-s.width*.03)*t)),c=Math.max(0,Math.min(a-o,l-o/2));return{x:r,y:c,w:h,h:o}}n(ci,"ci");function de(s,t){let e=s.x*t.width,i=s.y*t.height,a=(s.x+s.width)*t.width,h=(s.y+s.height)*t.height;return{topLeft:{x:e,y:i},topRight:{x:a,y:i},bottomRight:{x:a,y:h},bottomLeft:{x:e,y:h}}}n(de,"Oe");function ui(s,t,e){let i=C(s);return t.width<=0||t.height<=0?0:e==="ID-3"?i.width/t.width:i.width*i.height/(t.width*t.height)}n(ui,"li");var di=2,fi=260,mi=1.08;function fe(s,t){let e=s.videoWidth,i=s.videoHeight;if(e===0||i===0)return null;let a=Math.min(1,t/e),h=Math.round(e*a),o=Math.round(i*a),l=document.createElement("canvas");l.width=h,l.height=o;let r=l.getContext("2d",{willReadFrequently:!0});return r===null?null:(e/Math.max(1,h)>4&&(r.imageSmoothingQuality="high"),r.drawImage(s,0,0,h,o),r.getImageData(0,0,h,o))}n(fe,"Pe");function at(s,t){let e=[t.topLeft.x,t.topRight.x,t.bottomRight.x,t.bottomLeft.x],i=[t.topLeft.y,t.topRight.y,t.bottomRight.y,t.bottomLeft.y],a=Math.max(0,Math.floor(Math.min(...e))),h=Math.max(0,Math.floor(Math.min(...i))),o=Math.min(s.width,Math.ceil(Math.max(...e))),l=Math.min(s.height,Math.ceil(Math.max(...i))),r=Math.max(1,o-a),c=Math.max(1,l-h),u=new Uint8ClampedArray(r*c*4);for(let f=0;f<c;f++){let d=((h+f)*s.width+a)*4;u.set(s.data.subarray(d,d+r*4),f*r*4)}return{data:u,width:r,height:c,colorSpace:s.colorSpace}}n(at,"lt");function gi(s,t){return s==="glare"?"glare":s==="too_small"?"too_far":s==="too_big"?"too_close":t?"too_dark":s==="blurry"?"blurry":s==="off_center"?"edge_clipped":s==="no_card"?"sensing":"hold_still"}n(gi,"mi");var pi=1200;export{Ri as a,_i as b,Di as c,ce as d,li as e,ue as f,ni as g,Mt as h,Ti as i,Ai as j,ci as k,di as l,fi as m};
@@ -1 +0,0 @@
1
- import{a as ae,b as be,c as ke,d as Se,f as xe}from"./chunk-2FETDQV5.js";import{a as ie,d as Te,e as Ce}from"./chunk-XSGZY4JI.js";import{e as J}from"./chunk-GPGK6XZM.js";import{e as we,k as Me}from"./chunk-6MYG4HWP.js";import{g as re}from"./chunk-JS2IXPNL.js";import{a as n}from"./chunk-4FHWXBOB.js";function Re(e,t){let r=new Set(e.flatMap(i=>i.sides.filter(l=>l[t]!==null).map(l=>l.side)));return r.size===1?[...r][0]:null}n(Re,"_e");function _e(e){let t=Te.find(i=>i.docType===e),r=t.mrz==="none"?null:t.mrz==="td3"?"single":"verso";return{sides:t.sides,format:Ce(e),mrz:t.mrz==="none"?"none":"required",mrzSide:r,barcodeSide:null,portraitSide:t.portraitSide}}n(_e,"ot");function Ge(e,t){if(t.length===0)return _e(e);let r=t.some(s=>s.sides.length>1),i=new Set(t.map(s=>s.format)),l=i.size===1?[...i][0]:"card",u=t.filter(s=>s.sides.some(h=>h.mrz!==null)).length,d=t.find(s=>s.sides.length>1===r)?.sides.find(s=>s.portrait)?.side;return{sides:r?["recto","verso"]:["single"],format:l,mrz:u===t.length?"required":u===0?"none":"optional",mrzSide:Re(t,"mrz"),barcodeSide:Re(t,"barcode"),portraitSide:d??(r?"recto":"single")}}n(Ge,"Pe");function He(e,t){if(e===void 0)return[];let r=e.toUpperCase();return Object.prototype.hasOwnProperty.call(ie,r)?ie[r]?.[t]??[]:[]}n(He,"Ee");async function Xe(e,t,r){return await e(t)?r:r==="recto"?"verso":"recto"}n(Xe,"Oe");var Ye={low:{maxLongEdge:1920,payloadTargetBytes:7e5,qMin:.7,qMax:.92},mid:{maxLongEdge:2240,payloadTargetBytes:12e5,qMin:.7,qMax:.92},good:{maxLongEdge:2560,payloadTargetBytes:16e5,qMin:.7,qMax:.92}};function Je(e){let{deviceMemory:t,effectiveType:r,saveData:i,downlinkMbps:l,sourceLongEdge:u}=e,d=i===!0||r==="slow-2g"||r==="2g"||l!=null&&l>0&&l<1,s=t!=null&&t<=2,h=r==="4g"||l!=null&&l>=5,c=t!=null&&t>=6,b;d||s?b="low":h&&c?b="good":b="mid";let f=Ye[b],P=u&&u>0?Math.min(f.maxLongEdge,u):f.maxLongEdge;return{tier:b,...f,maxLongEdge:P}}n(Je,"it");function Qe(e){let t={};try{let r=navigator;typeof r.deviceMemory=="number"&&(t.deviceMemory=r.deviceMemory);let i=r.connection;i&&(t.effectiveType=i.effectiveType,t.saveData=i.saveData,t.downlinkMbps=i.downlink)}catch{}return typeof e=="number"&&e>0&&(t.sourceLongEdge=e),Je(t)}n(Qe,"Ae");function $e(e,t,r){let i=Math.min(1,Math.max(0,(e-.28)/.21999999999999997)),l=(t+r)/2;return Math.max(t,r-i*(r-l))}n($e,"st");function Ze(e,t,r){let i=Math.max(e,t),l=i>0?Math.min(1,r/i):1;return{width:Math.max(1,Math.round(e*l)),height:Math.max(1,Math.round(t*l))}}n(Ze,"ut");async function Ke(e,t){let r=t.startQ,i=await e(r);for(let l=0;l<4&&!(i.size<=t.budgetBytes||r<=t.qMin);l++)r=Math.max(t.qMin,r-.08),i=await e(r);return{blob:i,quality:r}}n(Ke,"ct");async function et(e,t,r,i,l){if(t<=0||r<=0)return null;let{width:u,height:d}=Ze(t,r,i.maxLongEdge),s=document.createElement("canvas");s.width=u,s.height=d;let h=s.getContext("2d");if(!h)return null;h.drawImage(e,0,0,u,d);let c=n(C=>new Promise((y,p)=>{s.toBlob(g=>g?y(g):p(new Error("canvas toBlob returned null")),"image/jpeg",C)}),"d"),b=$e(l,i.qMin,i.qMax),{blob:f,quality:P}=await Ke(c,{startQ:b,qMin:i.qMin,budgetBytes:i.payloadTargetBytes}).finally(()=>{s.width=0,s.height=0});if(f.size>5242880)throw new Error("encoded document exceeds the 5242880-byte media cap");return{blob:f,quality:P,width:u,height:d}}n(et,"Be");async function tt(e){let t=Qe(Math.max(e.width,e.height)),r=await et(e,e.width,e.height,t,.5);if(r===null)throw new Error("canvas encode unavailable");return{blob:r.blob,width:r.width,height:r.height}}n(tt,"oe");function Ee(e,t){return{layout:e,phase:"framing",captured:{},pending:[],lastCaptureAt:t,lastReportAt:t,manualShutter:!1,restPhase:"framing",readSides:[],needFlip:!1,flipped:!1,flipTimeoutSpent:!1,timeoutCapture:!1,lastShotByTimeout:!1}}n(Ee,"ie");var We=n(e=>e==="recto"?"verso":"recto","Fe"),qe=n(e=>e.phase==="framing"||e.phase==="locking"||e.phase==="flipCue"||e.phase==="reaskRecto","We"),de=n(e=>(e.captured.recto!==void 0?1:0)+(e.captured.verso!==void 0?1:0)+e.pending.length,"se");function ne(e,t){return e.lastCaptureAt>=0&&e.lastReportAt>=0?e:{...e,lastCaptureAt:e.lastCaptureAt<0?t:e.lastCaptureAt,lastReportAt:e.lastReportAt<0?t:e.lastReportAt}}n(ne,"ae");function rt(e,t,r){if(e.phase==="result")return{...e,lastReportAt:r};let i=!t.present||e.captureArea!==void 0&&t.areaFrac<.6*e.captureArea,{flipped:l,awaySince:u}=e;i&&(u=u??r),u!==void 0&&r-u>=250&&(l=!0),i||(u=void 0);let d=e.flipTimeoutSpent&&!(l&&!e.flipped),s={...e,lastReportAt:r,flipped:l,awaySince:u,flipTimeoutSpent:d,lastArea:t.areaFrac};if(!qe(e))return s;if(e.needFlip&&!l){if(!t.ready)return{...s,phase:e.restPhase,goodSince:void 0};let h=e.lastShot!==void 0&&e.pending.includes(e.lastShot);if(d||h)return{...s,goodSince:void 0,phase:e.restPhase};let c=e.goodSince??r;return r-c>=1800?{...s,goodSince:c,phase:"capturing",flipTimeoutSpent:!0,timeoutCapture:!0}:{...s,goodSince:c,phase:e.restPhase}}return t.ready?{...s,phase:"capturing",goodSince:e.goodSince??r}:{...s,goodSince:void 0,phase:t.locking?"locking":e.restPhase}}n(rt,"lt");function at(e,t){if(!qe(e)||e.manualShutter)return e;let r=t-e.lastReportAt>=2e3,i=t-e.lastCaptureAt>=6e3;return r||i?{...e,manualShutter:!0}:e}n(at,"dt");function it(e,t,r){let i=e.layout==="singlePage",l=i?{recto:t}:e.captured,u=i?[]:[...e.pending,t],d={...e,captured:l,pending:u,lastShot:t,lastCaptureAt:r,lastReportAt:-1,manualShutter:!1,goodSince:void 0,notice:void 0,awaySince:void 0,flipped:!1,lastShotByTimeout:e.timeoutCapture,timeoutCapture:!1,captureArea:e.lastArea};return i||de({captured:l,pending:u})>=2?{...d,phase:"reading",restPhase:"framing",current:void 0,needFlip:!1}:{...d,phase:"flipCue",restPhase:"flipCue",current:void 0,needFlip:!0}}n(it,"mt");function Fe(e,t,r){return e.pending.includes(t)?{...e,pending:e.pending.filter(i=>i!==t),lastShot:e.lastShot===t?void 0:e.lastShot,phase:e.phase==="capturing"?e.phase:"flipCue",restPhase:"flipCue",current:We(r),needFlip:!0,flipTimeoutSpent:!0,goodSince:void 0,manualShutter:!0,notice:"same_face",lastCaptureAt:-1,lastReportAt:-1}:e}n(Fe,"ze");function nt(e,t,r){if(!e.pending.includes(t))return e;if(e.captured[r]!==void 0)return Fe(e,t,r);let i=e.pending.filter(h=>h!==t),l={...e,pending:i,captured:{...e.captured,[r]:t}};if(de(l)!==1||e.layout==="singlePage")return l;let u=We(r),d=u==="recto"&&e.restPhase==="reaskRecto"?"reaskRecto":"flipCue",s=e.phase==="flipCue"||e.phase==="reaskRecto"||e.phase==="framing";return{...l,restPhase:d,current:u,phase:s?d:e.phase}}n(nt,"pt");function ot(e,t){let r=t.id??e.captured[t.side],i={...e.captured};(t.id===void 0||i[t.side]===t.id)&&delete i[t.side];let l=e.pending.filter(c=>c!==r),u=e.layout==="twoSided"&&de({captured:i,pending:l})>0,d=e.lastShotByTimeout||r===e.lastShot!==e.flipped,s=u&&!d,h=s?t.side==="recto"?"reaskRecto":"flipCue":"framing";return{...e,captured:i,pending:l,readSides:e.readSides.filter(c=>c!==t.side),lastShot:e.lastShot===r?void 0:e.lastShot,notice:t.issue,goodSince:void 0,manualShutter:!1,phase:h,restPhase:h,current:t.side,needFlip:s,flipped:!1,flipTimeoutSpent:!1,awaySince:void 0,lastCaptureAt:-1,lastReportAt:-1}}n(ot,"ft");function lt(e,t){switch(t.type){case"report":return rt(ne(e,t.at),t.report,t.at);case"tick":return at(ne(e,t.at),t.at);case"captured":return it(ne(e,t.at),t.id,t.at);case"captureFailed":return{...e,phase:e.restPhase,goodSince:void 0,lastCaptureAt:t.at,manualShutter:!0,timeoutCapture:!1};case"classified":return nt(e,t.id,t.side);case"duplicate":return Fe(e,t.id,t.side);case"readOk":{let r=e.readSides.includes(t.side)?e.readSides:[...e.readSides,t.side],i=["recto","verso"].filter(u=>e.captured[u]!==void 0),l=e.phase==="reading"&&e.pending.length===0&&i.every(u=>r.includes(u));return{...e,readSides:r,flipTimeoutSpent:!1,phase:l?"result":e.phase}}case"readFailed":return ot(e,t);case"clockRestart":return e.lastCaptureAt<0&&e.lastReportAt<0&&e.awaySince===void 0?e:{...e,awaySince:void 0,lastCaptureAt:-1,lastReportAt:-1};case"retake":return{...Ee(e.layout,-1),lastCaptureAt:-1,lastReportAt:-1};default:return e}}n(lt,"Ue");function st(e,t,r=!1){let i=e(t);return i===null?"recto":!r||i.y+i.height/2>=t.height/2?"verso":"recto"}n(st,"gt");async function dt(e,t=!1){let{detectMrzBand:r}=await import("./mrz-band-VYHOTDHY-VEZ2J5IL.js");return st(r,e,t)}n(dt,"ht");async function Ae(e,t=480,r,i=r!=null){let l=r??{x:0,y:0,width:e.width,height:e.height},u=Math.max(1,Math.round(l.height/l.width*t)),d=document.createElement("canvas");d.width=t,d.height=u;try{let s=d.getContext("2d");return s===null?"recto":(s.drawImage(e,l.x,l.y,l.width,l.height,0,0,t,u),await dt(s.getImageData(0,0,t,u),i))}finally{d.width=0,d.height=0}}n(Ae,"ue");var oe=n((e,t,r)=>Math.min(r,Math.max(t,Math.round(e))),"ce"),Q=n(e=>Math.round(Math.min(1,Math.max(0,e))*1e4)/1e4,"$");async function ut(e,t,r,i){let l=i.decode??(h=>createImageBitmap(h)),u=n(async()=>e.stillRead(await l(t),i.region??[0,0,1,1],i.detectorLimit),"c"),d;try{d=await u()}catch{try{await new Promise(h=>setTimeout(h,i.retryMs??300)),d=await u()}catch{return null}}let s=d.mrzBox;return s===void 0?null:{engine:i.engine,source:"live_mrz",format:r.format,lineCount:oe(r.lineCount,2,3),checkDigitsValid:!0,stillConfirmed:d.valid&&d.digest===r.digest,band:[Q(s[0]),Q(s[1]),Q(Math.min(s[2],1-s[0])),Q(Math.min(s[3],1-s[1]))],digest:r.digest,framesToValid:oe(r.framesToValid,1,1e3),msToValid:oe(r.msToValid,0,12e4)}}n(ut,"Ne");var ct=new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11]),mt=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,7,1,5,0,6,64,11,11]);function pt(e,t=globalThis){let r=t.WebAssembly?.validate;if(typeof r!="function")return{ok:!1,reason:"simd"};try{if(!r.call(t.WebAssembly,ct)||!r.call(t.WebAssembly,mt))return{ok:!1,reason:"simd"}}catch{return{ok:!1,reason:"simd"}}if(typeof t.Worker!="function")return{ok:!1,reason:"worker"};if(typeof t.createImageBitmap!="function")return{ok:!1,reason:"bitmap"};let i=t.navigator?.deviceMemory;return typeof i=="number"&&i<e.minDeviceMemoryGb?{ok:!1,reason:"memory"}:{ok:!0}}n(pt,"Ge");function ht(e=globalThis){let t=e.navigator?.connection;return t?.saveData===!0||["slow-2g","2g","3g"].includes(t?.effectiveType??"")}n(ht,"qe");var N,E=(N=class extends Error{constructor(t){super(t),this.name="OcrEngineError",this.code=t}},n(N,"E"),N);function Le(){let e=n(t=>(t.close(),Promise.reject(new E("unsupported"))),"e");return{ready:Promise.resolve("unsupported"),busy:!1,bandRead:e,stillRead:e,layoutRead:e,dispose:n(()=>{},"dispose")}}n(Le,"He");function ft(e){let t;try{if(e.createWorker)t=e.createWorker();else if(e.workerUrl!==void 0)t=new Worker(e.workerUrl,{type:"module",name:"sekyro-ocr"});else return Le()}catch{return Le()}let r=new Map,i=0,l=!1,u=!1,d=!1;t.addEventListener("message",p=>{let g=p.data,x=r.get(g.id);x&&(r.delete(g.id),x.resolve(g))});let s=n(()=>{for(let p of r.values())p.reject(new E("error"));r.clear(),c()},"s");t.addEventListener("error",s),t.addEventListener("messageerror",s);function h(p,g=[]){if(l)return Promise.reject(new E("disposed"));let x=++i;return new Promise((W,q)=>{r.set(x,{resolve:W,reject:q});try{t.postMessage({...p,id:x},g)}catch{r.delete(x),q(new E("error"))}})}n(h,"p");function c(){if(!l){l=!0;try{t.postMessage({id:++i,kind:"dispose"})}catch{}t.terminate();for(let p of r.values())p.reject(new E("disposed"));r.clear()}}n(c,"d");let b=(async()=>{let p=await h({kind:"init",baseUrl:e.baseUrl,salt:e.salt,detectorLimit:e.tuning.detectorLimit,maxDownloadMs:e.tuning.maxDownloadMs});if(p.kind==="failed")return p.reason;if(p.kind!=="ready")return"error";let g=await h({kind:"warmup"});return g.kind!=="ready"?"error":{warmupMs:g.warmupMs,downloadMs:p.downloadMs,cached:p.cached}})().catch(()=>"error"),f,P=new Promise(p=>{f=setTimeout(()=>p("timeout"),e.tuning.loadTimeoutMs)}),C=Promise.race([b,P]).then(p=>(clearTimeout(f),typeof p=="string"?c():d=!0,l&&typeof p!="string"?"error":p));(e.page===void 0?globalThis.addEventListener?globalThis:null:e.page)?.addEventListener("pagehide",c,{once:!0});async function y(p,g,x){if(l)throw g.close(),new E("disposed");if(!d)throw g.close(),new E("not_ready");if(u)throw g.close(),new E("busy");u=!0;let W;try{let q=new Promise((I,U)=>{W=setTimeout(()=>{U(new E("timeout")),c()},e.tuning.readTimeoutMs??1e4)}),z=await Promise.race([h(p,[g]),q]);if(z.kind===x){let{id:I,...U}=z;return U}throw new E(z.kind==="error"?z.code:z.kind==="failed"?z.reason:"error")}finally{clearTimeout(W),u=!1}}return n(y,"x"),{ready:C,get busy(){return u},bandRead:n((p,g=e.tuning.detectorLimit)=>y({kind:"band",bitmap:p,detectorLimit:g},p,"band"),"bandRead"),stillRead:n((p,g,x=e.tuning.detectorLimit)=>y({kind:"still",bitmap:p,region:g,detectorLimit:x},p,"band"),"stillRead"),layoutRead:n((p,g)=>y({kind:"layout",bitmap:p,detectorLimit:g},p,"layout"),"layoutRead"),dispose:c}}n(ft,"Xe");var $="sekyro-ocr-1",le=n(e=>e!==null&&typeof e=="object"?e:{},"le"),D=n((e,t,r,i)=>typeof e=="number"&&Number.isFinite(e)&&e>=t&&e<=r?e:i,"T"),Pe=n((e,t)=>typeof e=="boolean"?e:t,"Ye"),De=n(e=>{let t=typeof e=="string"?/^sekyro-ocr-(\d{1,4})$/.exec(e):null;return t?Number(t[1]):Number.POSITIVE_INFINITY},"Ve");function gt(e,t={}){let r=le(e),i=le(r.liveMrz),l=le(r.frontLock),u=De(t.engine??$),d=t.mode==="off",s=n(g=>g.enabled===!0?g.arm==="live"?"live":"control":null,"s"),h=s(i),c=s(l),b=n((g,x)=>!d&&x==="live"&&De(g.minEngine??$)<=u,"M"),f=Se,P=b(i,h)?{detectorLimit:D(i.detectorLimit,320,1600,f.detectorLimit),bandMaxWidthPx:D(i.bandMaxWidthPx,320,4096,f.bandMaxWidthPx),minBandWidthPx:D(i.minBandWidthPx,0,4096,f.minBandWidthPx),bandTop:D(i.bandTop,0,.95,f.bandTop),minIntervalMs:D(i.minIntervalMs,0,5e3,f.minIntervalMs),stableReads:Math.round(D(i.stableReads,1,10,f.stableReads)),profileReads:Math.round(D(i.profileReads,1,100,f.profileReads)),maxReadMs:D(i.maxReadMs,50,6e4,f.maxReadMs),searchTimeoutMs:D(i.searchTimeoutMs,1e3,12e4,f.searchTimeoutMs),hint:Pe(i.hint,!0),stillConfirm:Pe(i.stillConfirm,!0)}:null,C=ke,y=n((g,x,W)=>D(l[g],x,W,C[g]),"S"),p=b(l,c)?{minLines:Math.round(y("minLines",1,50)),fillMin:y("fillMin",0,1),fillMax:y("fillMax",0,2),offsetMax:y("offsetMax",0,1),steadyFillDelta:y("steadyFillDelta",0,1),steadyOffsetDelta:y("steadyOffsetDelta",0,1),layoutShiftMax:y("layoutShiftMax",0,1),lineCountDelta:Math.round(y("lineCountDelta",0,50)),lockMs:y("lockMs",0,3e4),steadyMs:y("steadyMs",0,3e4),minFrames:Math.round(y("minFrames",1,100)),minIntervalMs:y("minIntervalMs",0,5e3),maxWidthPx:y("maxWidthPx",160,2048),detectorLimit:y("detectorLimit",320,1600),searchTimeoutMs:y("searchTimeoutMs",1e3,12e4)}:null;return{enabled:P!==null||p!==null,liveMrz:P,textLock:p,liveMrzArm:h,frontLockArm:c,load:{detectorLimit:P?.detectorLimit??p?.detectorLimit??f.detectorLimit,loadTimeoutMs:D(i.loadTimeoutMs,1e3,12e4,2e4),maxDownloadMs:D(i.maxDownloadMs,1e3,12e4,2e4),minDeviceMemoryGb:D(i.minDeviceMemoryGb,0,64,2)},reportSampleRate:D(i.reportSampleRate,0,1,1)}}n(gt,"Qe");function vt(e,t){return e.enabled?!(t.probe??pt)({minDeviceMemoryGb:e.load.minDeviceMemoryGb}).ok||(t.slow??ht)()?{ok:!1,reason:"unsupported"}:{ok:!0,engine:ft({baseUrl:t.baseUrl,salt:t.salt,tuning:{detectorLimit:e.load.detectorLimit,maxDownloadMs:e.load.maxDownloadMs,loadTimeoutMs:e.load.loadTimeoutMs},...t.workerUrl!==void 0?{workerUrl:t.workerUrl}:{},...t.createWorker!==void 0?{createWorker:t.createWorker}:{},...t.page!==void 0?{page:t.page}:{}})}:{ok:!1,reason:"off"}}n(vt,"Ke");function yt(e=typeof navigator<"u"?navigator.userAgent:""){return/SamsungBrowser\//.test(e)?"samsung":/Firefox\/|FxiOS\//.test(e)?"firefox":/Chrome\/|CriOS\/|Chromium\//.test(e)&&!/Edg\/|OPR\//.test(e)?"chrome":/Safari\//.test(e)&&/Version\/|Mobile\//.test(e)&&!/Chrome\/|CriOS\//.test(e)?"safari":"other"}n(yt,"St");var B=n(e=>e===void 0||!Number.isFinite(e)?void 0:Math.min(6e5,Math.max(0,Math.round(e))),"F"),se=n((e,t,r)=>e===void 0||!Number.isFinite(e)?void 0:Math.min(r,Math.max(t,Math.round(e))),"de");function wt(e){let t=e.assist??null,r=e.load!==null&&e.load!==void 0&&typeof e.load=="object"?e.load:null,i=typeof e.load=="string"?e.load:null,l=t!==null?t.outcome:i==="unsupported"||i==="download"||i==="integrity"?i:i==="error"||i==="timeout"?"error":"off",u={kind:"live_mrz",platform:"web",engine:e.engine??$,arm:e.arm,capture:e.capture,outcome:l,reads:se(t?.reads??0,0,1e4)??0,browser:e.browser??yt()},d=n((s,h)=>{h!==void 0&&(u[s]=h)},"u");return d("format",t?.format),d("framesToValid",se(t?.framesToValid,1,1e4)),d("msToValid",B(t?.msToValid)),d("framesToLock",se(t?.framesToLock,1,1e4)),d("msToLock",B(t?.msToLock)),d("msToCapture",B(e.msToCapture)),d("readP50Ms",B(t?.readP50Ms)),d("readP90Ms",B(t?.readP90Ms)),d("deviceClass",t?.deviceClass),r!==null&&(d("warmupMs",B(r.warmupMs)),d("downloadMs",B(r.downloadMs)),d("cached",r.cached)),d("stillConfirmed",e.stillConfirmed),d("typeMismatch",e.typeMismatch),u}n(wt,"je");function ze(e,t){return e===void 0?!1:t==="passport"?e!=="TD3":e==="TD3"}n(ze,"me");var Mt=2;async function bt(e){let t=await import("./capture-session-doc-FAMDLRRZ-QPOFTNTG.js");return new t.CaptureSessionDoc(e)}n(bt,"Dt");function kt(e){return{topLeft:{x:e.x,y:e.y},topRight:{x:e.x+e.width,y:e.y},bottomRight:{x:e.x+e.width,y:e.y+e.height},bottomLeft:{x:e.x,y:e.y+e.height}}}n(kt,"wt");function St(e,t,r){let i=[e.topLeft,e.topRight,e.bottomRight,e.bottomLeft],l=0;for(let u=0;u<i.length;u+=1){let d=i[u],s=i[(u+1)%i.length];l+=d.x*s.y-s.x*d.y}return t>0&&r>0?Math.abs(l)/2/(t*r):0}n(St,"kt");function Pt(){import("./capture-session-doc-FAMDLRRZ-QPOFTNTG.js").then(e=>e.warmDocDetector()).catch(()=>{})}n(Pt,"ln");function Dt(e){return xt(e,{}).handle}n(Dt,"dn");function xt(e,t){let r=we(),i=Me({enabled:e.keepScreenAwake!==!1}),l=t.decode??(a=>createImageBitmap(a)),u=t.blurRefuseSharpnessMax??.16,d=t.now??(()=>performance.now()),s=Ge(e.documentType,t.catalogCapture===!0?He(e.issuer,e.documentType):[]),h=s.sides.length===1||e.side==="single",c=Ee(h?"singlePage":"twoSided",d());if(!h&&(e.side==="recto"||e.side==="verso")){let a=e.side==="recto"?"verso":"recto";c={...c,captured:{[a]:"server"},readSides:[a],current:e.side,phase:"flipCue",restPhase:"flipCue"}}let b="idle",f=null,P=null,C=!0,y=0,p=0,g=!1,x=!1,W="",q=null,z,I=null,U=[],ue=s.mrz==="none",Be=s.barcodeSide==="recto"||s.barcodeSide==="verso"?s.barcodeSide:null,V=ue&&!h?t.barcode?.side??Be:null,ce=e.barcodeAssetBaseUrl??t.barcode?.assetBaseUrl,Z=null,me=n(()=>V===null||ce===void 0||t.barcode?.seen!==void 0?Promise.resolve(null):(Z??(Z=import("./barcode-detect-C5IOXMKI-ZOZ2WOWU.js").then(a=>a.loadBarcodeDetect(ce)).catch(()=>null)),Z),"ge"),Ie=n(async(a,o)=>{if(V===null)return null;let m=V==="recto"?"verso":"recto";try{let v=t.barcode?.seen;if(v!==void 0)return await v(a)?V:m;let[L,k]=await Promise.all([me(),o()]);if(L===null||k===null)return null;let T=Math.min(1600,k.width),M=document.createElement("canvas");M.width=T,M.height=Math.max(1,Math.round(k.height/k.width*T));try{let w=M.getContext("2d");return w===null?null:(w.drawImage(k,0,0,M.width,M.height),await Xe(L,w.getImageData(0,0,M.width,M.height),V))}finally{M.width=0,M.height=0}}catch{return null}},"Je"),R=t.webOcr!==void 0&&!ue?gt(t.webOcr.captureDocument,{mode:e.liveMrz?.mode??"auto"}):null,_=null,O=R===null||!R.enabled?"off":null,G=null,H=null,pe=new WeakMap,K="";if(R!==null&&R.enabled&&t.webOcr!==void 0){let a=t.webOcr,o=vt(R,{baseUrl:e.liveMrz?.assetBaseUrl??a.baseUrl,salt:a.salt,...e.liveMrz?.workerUrl!==void 0?{workerUrl:e.liveMrz.workerUrl}:{},...a.createWorker!==void 0?{createWorker:a.createWorker}:{}});if(o.ok){_=o.engine;let m=new xe({textLock:R.textLock,liveMrz:R.liveMrz});G=m;let v=o.engine;v.ready.then(L=>{O=L,typeof L!="string"&&C&&m.setEngine(v)})}else O=o.reason}let j=n(a=>{let o=JSON.stringify(a);o!==K&&(K=o,r.emit("mrz",a))},"U"),he=n((a,o)=>{let m=t.webOcr?.reports;if(m===void 0||R===null||a===void 0)return;let v=a.format==="ID-3"||a.side==="single"?"single":a.side==="verso"?"verso":"recto",L=v!=="recto"?R.liveMrzArm??R.frontLockArm:R.frontLockArm;if(L===null||Math.random()>=R.reportSampleRate)return;let k=a.via==="live_mrz"?H:null,T=n(()=>{let M=k?.value??null;m([wt({arm:L,capture:v,assist:a.ocr??null,load:L==="control"?"off":O,...a.msToCapture!==void 0?{msToCapture:a.msToCapture}:{},...M!==null&&M.stillConfirmed!==void 0?{stillConfirmed:M.stillConfirmed}:{},...o!==void 0?{typeMismatch:ze(o.format,s.format==="ID-3"?"passport":"card")}:{}})])},"w");k!==null&&k.value===null?Promise.race([k.promise,new Promise(M=>setTimeout(M,3e3))]).then(T):T()},"be"),F=n(a=>{!C||a===b||(b=a,i.setActive(a==="starting"||a==="scanning"),r.emit("state",a))},"I"),Ue=n((a,o)=>o===void 0?null:h?"single":a.captured.recto===o?"recto":a.captured.verso===o?"verso":null,"Ze"),Oe=n(a=>({phase:a.phase,captured:h?a.captured.recto!==void 0?["single"]:[]:["recto","verso"].filter(o=>a.captured[o]!==void 0),expected:h?null:a.current??null,notice:a.notice??null,lastShot:Ue(a,a.lastShot),manualShutter:a.manualShutter,torchAvailable:f?.torchAvailable()??!1,torch:x}),"et"),fe=n(()=>{let a=f;a!==null&&a.captureNow().catch(()=>A({type:"captureFailed",at:d()}))},"ye");function A(a){if(!C)return;let o=c;c=lt(c,a),c.phase==="capturing"&&o.phase!=="capturing"&&Promise.resolve().then(fe),c.phase==="result"&&o.phase!=="result"&&(F("done"),ge());let m=Oe(c),v=JSON.stringify(m);v!==W&&(W=v,r.emit("scan",m))}n(A,"v");function ge(){I!==null&&clearInterval(I),I=null;for(let a of U.splice(0))a();f?.destroy(),f=null,i.setActive(!1)}n(ge,"Se");let ve=n(()=>f?.captureReport?.(),"Me"),ee=!1,ye=n((a,o)=>{if(!(a===void 0||t.onFaceReport===void 0))try{t.onFaceReport(a,o)}catch{}},"De"),X=n(a=>{K="",!(f===null||c.phase==="reading"||c.phase==="result")&&(ee=!1,f.rearm(h?"single":c.current??a))},"Q"),je=n(async(a,o,m,v)=>{if(H=null,v!==void 0&&_!==null&&R?.liveMrz?.hint===!0){let w={promise:ut(_,a,v,{engine:$,detectorLimit:R.liveMrz.detectorLimit}).catch(()=>null),value:null};w.promise.then(S=>{w.value=S}),H=w}v!==void 0&&ze(v.format,s.format==="ID-3"?"passport":"card")&&j({state:"mismatch",format:v.format});let L=ve();ye(L,"captured"),ee=!0,he(L,v);let k=m===void 0?q:m===null?null:{quad:kt(m),frameWidth:0,frameHeight:0,inStill:!0},T={decoded:null},M=n(()=>(T.decoded??(T.decoded=Promise.resolve().then(()=>l(a)).catch(()=>null)),T.decoded),"y");try{await Ne(a,o,k,M,H)}finally{T.decoded!==null&&(await T.decoded)?.close()}},"tt"),Ne=n(async(a,o,m,v,L)=>{let k=`shot-${y+=1}`;if(A({type:"captured",id:k,at:d()}),e.haptics!==!1)try{globalThis.navigator?.vibrate?.(30)}catch{}if(!g&&u>0){let w=await(t.measureSharpness!==void 0?t.measureSharpness(a,m):v().then(S=>S===null?-1:be(S,ae(m?.quad??null,m?.inStill===!0?S:{width:m?.frameWidth??0,height:m?.frameHeight??0},S)))).catch(()=>-1);if(!C)return;if(Number.isFinite(w)&&w>=0&&w<u){g=!0;let S=h?"recto":c.current??(c.captured.recto===void 0?"recto":"verso");A({type:"readFailed",side:S,id:k,issue:"blurry"}),X(S);return}}g=!1;let T;if(h)T="single";else{let w=c.current,S=(t.classify===void 0?await Ie(a,v):null)??await(t.classify!==void 0?t.classify(a):v().then(Y=>Y===null?w??"recto":m?.inStill===!0?Ae(Y,480,null,!0):Ae(Y,480,ae(m?.quad??null,{width:m?.frameWidth??0,height:m?.frameHeight??0},Y)))).catch(()=>w??"recto");if(!C)return;if(c.captured[S]!==void 0&&p<Mt){p+=1,A({type:"duplicate",id:k,side:S}),X(S==="recto"?"verso":"recto");return}T=c.captured[S]!==void 0&&w!==void 0?w:S,p=0,A({type:"classified",id:k,side:T})}let M=T==="verso"?"verso":"recto";try{let w=t.encode!==void 0?await t.encode(a):await v().then(S=>{if(S===null)throw new Error("the still could not be decoded");return tt(S)});if(!C)return;L!==null&&pe.set(w.blob,L),r.emit("captured",{image:w.blob,side:T,documentType:e.documentType,...e.issuer!==void 0?{issuer:e.issuer}:{},width:w.width,height:w.height,previewDataUrl:o}),t.deferRead!==!0&&A({type:"readOk",side:M})}catch(w){A({type:"readFailed",side:M,id:k,issue:"technical"}),r.emit("error",J("generic",!0,{phase:"keyframes",name:re(w)}))}X(M==="recto"?"verso":"recto")},"nt"),Ve=n(a=>{U.push(a.on("statechange",({state:o})=>{o==="preflight"||o==="acquiring"?F("starting"):o==="positioning"?F("scanning"):o==="captured"?F("captured"):o==="error"&&F("error")}),a.on("feedback",({key:o,reticle:m})=>r.emit("feedback",{key:o,reticle:m})),a.on("checks",o=>{r.emit("gate",{progress:o.p,quad:o.quad,frameWidth:o.frameWidth,frameHeight:o.frameHeight,...o.guide!==void 0?{guide:{detected:o.guide.detected,fill:o.guide.fill,offsetX:o.guide.offsetX??0,offsetY:o.guide.offsetY??0}}:{}});let m=o.ocr?.mrz;m!==void 0&&(m.state==="fallback"?j({state:"fallback",reason:m.reason}):m.state==="valid"?j({state:"valid",format:m.format}):m.state==="reading"?j({state:"reading",...m.format?{format:m.format}:{},...m.coach?{coach:m.coach}:{}}):j({state:"searching"}));let v=o.quad===null?0:St(o.quad,o.frameWidth,o.frameHeight);q=o.quad===null?null:{quad:o.quad,frameWidth:o.frameWidth,frameHeight:o.frameHeight},A({type:"report",report:{present:o.quad!==null&&o.plausible||o.guide?.detected===!0,ready:o.ready===!0,locking:o.p>=.5,areaFrac:v},at:d()})}),a.on("error",({kind:o,retryable:m,detail:v})=>r.emit("error",J(o,m,v))),a.on("artifacts",o=>{je(o.keyframe,o.previewDataUrl,o.docRegion,o.liveMrz)}))},"rt"),te=n(()=>(P??(P=(async()=>{if(C){if(me(),f===null){let a;try{a=await(t.createEngine??bt)({...t.engineOptions??{},...z!==void 0?{guide:z}:{},video:e.video,format:s.format,side:h?"single":e.side??"recto",autoCapture:!1,...G!==null?{ocr:G}:{}})}catch(m){F("error"),r.emit("error",J("models",!0,{phase:"models",name:re(m)}));return}if(!C){a.destroy();return}f=a,Ve(a);let o=t.tickMs??500;o>0&&(I=setInterval(()=>A({type:"tick",at:d()}),o))}A({type:"clockRestart"}),R!==null&&R.liveMrzArm==="live"&&(O==="unsupported"||O==="off")&&j({state:"fallback",reason:O}),await f.start()}})().finally(()=>{P=null})),P),"ee");return{handle:{get state(){return b},on:n((a,o)=>r.on(a,o),"on"),start:te,retry:n(()=>{if(f===null&&c.phase==="result"){A({type:"retake"}),p=0,g=!1,te();return}if(f!==null&&b!=="error"){A({type:"retake"}),p=0,g=!1,f.rearm(h?"single":void 0);return}te()},"retry"),setSide:n(a=>{h||a==="single"||(c.current!==a&&(c={...c,current:a}),A({type:"clockRestart"}),c.phase!=="reading"&&c.phase!=="result"&&f?.rearm(a))},"setSide"),shutter:fe,focusAt:n((a,o)=>{f?.focusAt?.(a,o)},"focusAt"),setGuide:n(a=>{z=a,f?.setGuide?.(a)},"setGuide"),setTorch:n(a=>{x=a,f?.setTorch(a),A({type:"tick",at:d()})},"setTorch"),destroy:n(()=>{if(C&&f!==null&&b!=="done"){let a=ve();!ee&&a!==void 0&&a.ticks>0&&ye(a,"abandoned"),he(a,void 0)}C=!1,ge(),G?.setEngine(null),_?.dispose(),_=null,r.clear()},"destroy")},setFlowState:n(a=>{(c.phase==="reading"||c.phase==="result")&&F(a==="done"&&c.phase!=="result"?"scanning":a)},"setFlowState"),settle:n((a,o)=>{let m=a==="verso"?"verso":"recto";A(o.ok?{type:"readOk",side:m}:{type:"readFailed",side:m,issue:o.issue}),o.ok||X(m)},"settle"),takeDeviceRead:n(a=>pe.get(a.image)?.value??null,"takeDeviceRead")}}n(xt,"Ct");export{Mt as a,Pt as b,Dt as c,xt as d};
@@ -1,3 +0,0 @@
1
- import{A as Je,F as ue,G as W,H as Qe,I as Xe,J as et,a as I,b as Ue,c as Fe,f as je,g as Ke,h as Be,i as Ve,j as se,k as $e,m as P,o as M,p as O,q as j,r as Z,s as E,t as le,v as He,w as ze,x as Ze,y as We,z as Ye}from"./chunk-YLH3WX7Y.js";import{f as nt}from"./chunk-GPGK6XZM.js";import{b as Ge}from"./chunk-4YBL75VD.js";import{b as qe,c as oe,e as tt}from"./chunk-6MYG4HWP.js";import{a as t}from"./chunk-4FHWXBOB.js";function Et(r){return r.idNumberBound??r.nniBound}t(Et,"ae");function rt(r){return r===void 0?void 0:r.idNumberFromDocument??r.nniFromDocument}t(rt,"ee");var ot="https://api.sekyro.ai",Rt=5e3,Nt=24e4,Pt=9e4,Ot=25*6e4,Lt=20*6e4,Dt=3,qt=3e3,Gt=1500,Ut=10;function it(r){return r instanceof Error&&r.name==="ChallengeError"&&r.code||"challenge_failed"}t(it,"St");var at=new Set(["aborted","embedder_opaque","site_key_rejected"]);function Ft(r){return new Promise(l=>setTimeout(l,r))}t(Ft,"un");function jt(){let r=globalThis.crypto;if(r!==void 0&&typeof r.randomUUID=="function")return r.randomUUID();let l=new Uint8Array(16);if(r!==void 0&&typeof r.getRandomValues=="function")r.getRandomValues(l);else for(let f=0;f<16;f+=1)l[f]=Math.floor(Math.random()*256);l[6]=(l[6]??0)&15|64,l[8]=(l[8]??0)&63|128;let p=[...l].map(f=>f.toString(16).padStart(2,"0")).join("");return`${p.slice(0,8)}-${p.slice(8,12)}-${p.slice(12,16)}-${p.slice(16,20)}-${p.slice(20)}`}t(jt,"cn");function Kt(r){return Bt(r,{})}t(Kt,"wo");function Bt(r,l){let p=r.apiOrigin??ot,f=r.autoRetry??!0,dt=r.rearm??"auto",K=l.client??new Fe({apiOrigin:p,sessionToken:r.clientToken,fetch:r.fetch}),y=new Proxy(K,{get(e,n){if(n==="submitCheck")return _t;let i=Reflect.get(e,n,e);return typeof i=="function"?i.bind(e):i}}),D=l.sleep??Ft,pe=l.uuid??jt,pt=l.getChallengeToken??((e,n)=>import("./challenge-frame-YBTLAQ5G-NN763UU5.js").then(i=>i.executeChallenge({frameUrl:e.url,siteKey:e.siteKey,action:"liveness",subject:n.subject,signal:n.signal}))),S=tt(),R=null,fe=null,u=!1,me=new AbortController,c=null,B=null,V=null,$=t(()=>V??Qe(c),"ne"),he=t(()=>Xe(W(c),$()),"Re"),b=t(e=>{c=e,!M(e)&&(xe(Lt)||yt(e))&&ie(e),S.emit("view",e),R?.onView(e)},"O"),v=t(()=>c!==null?Promise.resolve(c):(B??(B=y.getSession().then(e=>(b(e),e)).finally(()=>{B=null})),B),"A"),k=t(async()=>{let e=await y.getSession();return b(e),e},"E"),Y=t(async(e,n)=>{e.plan!==void 0?b(e):await k()},"de"),H=null,ye=t(async e=>{let n=await v();if(e||!n.consentRecorded){let i=await y.recordConsent(r.locale);i.plan!==void 0?b(i):c!==null&&b({...c,consentRecorded:!0})}z()&&ie(n)},"Ie"),A=t(e=>e?.force===!0?ye(!0):(H??(H=ye(!1).finally(()=>{H=null})),H),"N"),J={client:y,ensureConsent:t(e=>A(e),"ensureConsent"),sleep:D,uuid:pe,...l.random!==void 0?{random:l.random}:{},onBusy:t(e=>{u||S.emit("busy",e)},"onBusy")},ve=!1,_e=null,Q=t(e=>{if(e.status==="verified"||e.status==="not_verified"||e.status==="review"){if(ve)return;ve=!0}_e=JSON.stringify(e),S.emit("result",e)},"fe"),ft=t(e=>{_e!==JSON.stringify(e)&&Q(e)},"Nt"),ge=t(async e=>{let n=c;e&&(n=await k().catch(()=>c));let i=n===null?null:P(n);return i!==null&&!u&&S.emit("method",i),i!==null},"Ee"),X=null,be=!1,ke=!1,we=t(()=>We(J,(e,n)=>e.submitCheck("population_registry",{},{idempotencyKey:n})),"Ne"),Ae=t(e=>Et(e)===!0||rt(j(e,"population_registry"))===!0,"Fe"),mt=t(async()=>{try{let e=await v();if(M(e)||P(e)!==null||O(e)?.checkType!=="population_registry")return;if(!Ae(e)&&rt(j(e,"population_registry"))===void 0&&(e=await k()),!Ae(e)){ke=!0;return}await A(),await Y(await we(),"population_registry");let n=c===null?void 0:j(c,"population_registry");if(n?.state==="input_required"&&n.reason==="registry_unavailable"&&$e(n)>0){if(await D(Rt),u)return;await Y(await we(),"population_registry")}}catch(e){if(e instanceof I&&(e.code==="check_not_active"||e.code==="step_not_on_path")){await k().catch(()=>{});return}be=!0;return}c!==null&&M(c)&&Q(le(c,{autoRetry:f}))},"Ft"),Ce=t(()=>(X??(X=mt()),X),"He"),w=l.now??Date.now,N=null,q,ee,ht=0,te=t((e,n)=>`${e.url}
2
- ${e.siteKey}
3
- ${n}`,"he"),Me=0,ne,re=t((e,n)=>{Me+=1;let i=w(),s=pt(e,{signal:me.signal,subject:n}),o={key:te(e,n),at:i,token:s};return s.then(()=>{o.issuedAt=w(),ee=void 0},d=>{let m=it(d);if(o.failed=m,u||m==="aborted")return;ee=m;let{detail:h,readyMs:a}=d;G({check:"attestation",kind:"unavailable",engineKind:m,attempt:ht++,challengeMs:w()-i,readyMs:a,detail:h,inApp:Ge()})}),s.catch(()=>{}),o},"ge"),Se=t((e,n)=>e!==null&&e.key===n&&(e.issuedAt===void 0||w()-e.issuedAt<Nt),"De"),ie=t((e,n={})=>{let i=e?.challenge??null;if(e===null||i===null||u)return;let s=Z(e.sessionId),o=N;(n.replaceFailed===!0&&o?.failed!==void 0&&!at.has(o.failed)||!Se(o,te(i,s)))&&(N=re(i,s))},"Se"),Te=t(async(e,n)=>{let i=te(e,n),s=N;N=null;let o=Se(s,i)?s:re(e,n),d=o===s?0:1,m,h=new Promise(a=>{m=setTimeout(()=>a("late"),Pt)});try{for(;;){let a=await Promise.race([o.token.then(_=>({token:_}),_=>({error:it(_)})),h]);if(a==="late")return!u&&N===null&&(N=o),{error:ee??"timeout"};if("token"in a)return ne=Math.max(0,Math.round((o.issuedAt??w())-o.at)),a;if(u||at.has(a.error)||d>=Dt||d>0&&await Promise.race([D(qt*d),h])==="late")return a;if(u)return{error:"aborted"};d+=1,o=re(e,n)}}finally{clearTimeout(m)}},"Ue"),T=null,yt=t(e=>se(e).some(n=>(n.checkType==="phone_otp"||n.checkType==="email_otp")&&n.state!=="passed"&&n.state!=="skipped"),"Lt"),xe=t(e=>T===null||w()-T>=e,"Be"),z=t(()=>xe(Ot),"oe"),vt=t(e=>{let n=e.attestation;return typeof n?.turnstileToken=="string"&&n.turnstileToken.length>0},"Dt"),Ie=new Map,Ee=t(async()=>{let e=await v(),n=e.challenge;if(n==null||e.simulation!==void 0)return;let i=await Te(n,Z(e.sessionId));if(!("token"in i))throw new I({status:400,code:"attestation_invalid",message:`browser check: ${i.error}`});return i.token},"Ge"),_t=t(async(e,n,i={})=>{let s=n;if("attestation"in s)try{let a=await K.submitCheck(e,n,i);return vt(s)&&(T=w()),a}catch(a){throw a instanceof I&&a.code==="attestation_invalid"&&(T=null),a}let o=(e==="phone_otp"||e==="email_otp")&&s.action!=="verify",d=i.idempotencyKey,m=d!==void 0?Ie.get(d):void 0;m===void 0&&(o||z())&&(m=await Ee(),d!==void 0&&m!==void 0&&Ie.set(d,m));let h=t((a,_)=>a!==void 0?{..._,browserCheckToken:a}:_,"w");try{let a=await K.submitCheck(e,n,h(m,i));return m!==void 0&&(T=w()),a}catch(a){if(!(a instanceof I)||a.code!=="attestation_invalid"||(T=null,m!==void 0))throw a;let _=await Ee(),x=d!==void 0?{...i,idempotencyKey:pe()}:i,C=await K.submitCheck(e,n,h(_,x));return _!==void 0&&(T=w()),C}},"Ut"),Re=t(async(e={})=>{if(q=void 0,e.always!==!0&&!z())return{};let n=await v(),i=n.challenge;if(i==null)return{};let s=await Te(i,Z(n.sessionId));if("token"in s)return{channel:"hosted_web",turnstileToken:s.token};if(q=s.error,n.simulation!==void 0)return{channel:"hosted_web"};throw new Ze(s.error)},"Ke"),gt=t(()=>q,"Bt"),bt=t(()=>({checks:Math.min(50,Me),...ne!==void 0?{challengeMs:Math.min(6e5,ne)}:{}}),"qt"),G=t(e=>{if(u)return;let n=y.reportCaptureIssue;if(n===void 0)return;let i=e.formFactor;try{i??(i=qe())}catch{}try{Promise.resolve(n.call(y,{...e,...i!==void 0?{formFactor:i}:{}})).catch(()=>{})}catch{}},"W"),g=null,U=null,Ne=new WeakMap,Pe=Promise.resolve(),F=0,kt=t(async()=>{let e=await v();for(let n=0;n<Ut&&!u&&!M(e)&&O(e)===void 0&&se(e).some(i=>i.state==="processing")&&(await D(Gt),!u);n+=1)e=await k();return e},"Gt"),wt=t(async(e,n,i)=>{let{capture:s}=e,o=t(()=>u,"p"),d=t(()=>e.alive&&e.attempt===i,"k"),m=t(a=>{d()&&s.setFlowState(a)},"C"),h=t(a=>{if(!o()&&(a.status==="unavailable"&&a.reasonCode!==void 0&&!je(a.reasonCode)&&G({check:"liveness",kind:"unavailable",phase:"upload",engineKind:a.reasonCode,attempt:Math.max(0,e.issues.value)}),Q(a),!!d())){if(a.status==="retry"&&dt==="auto"){s.handle.retry();return}s.setFlowState("done")}},"w");if(n.degraded==="NO_RECORDER"){let a=c?.sessionId??(await v().catch(()=>null))?.sessionId??"";h(E(a,"no_recorder"));return}m("uploading");try{if(await Ce(),o())return;let a=await v(),_;if(!M(a)&&P(a)!==null){await ge(!1),h(E(a.sessionId,"method_required"));return}if(!M(a)){if(O(a)?.checkType==="population_registry"){h(E(a.sessionId,ke?"nni_unbound":be?"network":"registry_unavailable"));return}if(await A(),o())return;_=c??a;let x=await Ye({...J,artifacts:n,getAttestation:Re,attestationError:gt,attestationFacts:bt,clipKeys:{get:t(()=>Ne.get(n)??null,"get"),set:t(C=>{Ne.set(n,C)},"set")},getView:t(()=>c??a,"getView"),refreshView:k,applySubmit:Y,onPhase:m,isCancelled:o,onKeyframePromoted:t(C=>{fe=C},"onKeyframePromoted")});if(o())return;if(x.kind==="unavailable"){x.reason==="attestation"&&(U={bound:e,artifacts:n});let C=E(a.sessionId,x.reason),De=x.reason==="attestation"?q:void 0;h(De!==void 0?{...C,attestationError:De}:C);return}if(x.kind==="resync"&&await k(),c!==null&&P(c)!==null){await ge(!1),h(E(a.sessionId,"method_required"));return}a=await kt()}h(le(a,{autoRetry:f,previous:_}))}catch{if(o())return;h(E(c?.sessionId??"","network"))}},"Kt"),Oe=t((e,n)=>{let i=e.attempt;F>0&&e.alive&&e.capture.setFlowState("uploading"),F+=1,Pe=Pe.then(()=>wt(e,n,i)).finally(()=>{F-=1,F===0&&R?.onChainIdle()}).catch(()=>{})},"We"),Le=t(e=>{g?.capture.handle.destroy(),g!==null&&(g.alive=!1);let n=nt(e,R?.captureInternals?.(e)??l.capture,()=>c?.capture?.liveness?.keyframe?.rank===!0,he,()=>c?.capture?.liveness?.screenRamp,{session:t(()=>W(c),"session"),onModeChange:t(o=>{V=o},"onModeChange")}),i={capture:n,alive:!0,attempt:0,issues:Be()};g=i,n.handle.on("error",o=>{G(Ke("liveness",o,i.issues.value))}),n.handle.on("state",o=>{if(i.issues.note(o),o==="starting"){i.attempt+=1,U?.bound===i&&(U=null),z()&&ie(c,{replaceFailed:!0});let d=c===null?void 0:O(c)?.checkType;(d==="liveness"||d==="face_match")&&A().catch(()=>{})}}),n.handle.on("captured",o=>{Promise.resolve().then(()=>Oe(i,o))});let s=n.handle;return{get state(){return s.state},get captureMode(){return s.captureMode},get facingMode(){return s.facingMode},on:t((o,d)=>s.on(o,d),"on"),start:t(async o=>{if(c===null&&await v().catch(()=>{}),!!i.alive)return s.start(o)},"start"),retry:t(()=>{let o=U;if(o!==null&&o.bound===i&&i.alive){U=null,Oe(i,o.artifacts);return}s.retry()},"retry"),switchCamera:t(()=>s.switchCamera(),"switchCamera"),canSwitchCaptureMode:t(()=>s.canSwitchCaptureMode(),"canSwitchCaptureMode"),setCaptureMode:t(o=>s.setCaptureMode(o),"setCaptureMode"),destroy:t(()=>{i.alive=!1,g===i&&(g=null),s.destroy()},"destroy")}},"$e"),At=t(async()=>{if(u)return null;try{let e=await v();return u?null:P(e)}catch{return null}},"jt"),Ct=t(async()=>{if(u)return"self";try{let e=await v();if(u)return"self";let n=W(e);return n==="choice"?$()??n:n}catch{return"self"}},"Yt"),Mt=t(async()=>{if(u)return!1;try{let e=await v();return u||M(e)||oe()?!1:ue(e,O(e))==="phone"||ue(e,j(e,"liveness"))==="phone"}catch{return!1}},"Wt"),St=t(async()=>{if(u)return!1;try{let e=await v();return!u&&e.returning===!0}catch{return!1}},"$t"),Tt=t(async e=>{let n=(await v()).plan?.choice,i=n?.options.find(o=>Ve[o.service]===e);if(!i)throw new RangeError(`method ${String(e)} is not offered`);let s=await y.choose(n.nodeId,i.id);u||b(s)},"Qt"),ae=null,xt=t(()=>(ae??(ae=import("./plan-runner-LSQTIO6L-XZJIKXPZ.js").then(e=>{let n=e.createPlanRunner({runtime:J,currentView:t(()=>c,"currentView"),cameraMode:he,captureModeSwitch:{pick:$,choose:t(i=>{V=i},"choose")},ensureView:v,refreshView:k,ensureConsent:t(()=>A(),"ensureConsent"),liveness:Le,stopLiveness:t(()=>{g!==null&&(g.alive=!1,g.capture.handle.destroy(),g=null)},"stopLiveness"),chainBusy:t(()=>F>0,"chainBusy"),destroyed:t(()=>u,"destroyed"),sleep:D,isMobile:oe,now:l.now??Date.now,keptFaceKey:t(()=>fe,"keptFaceKey"),setView:b,baseCapture:l.capture,emitStep:t(i=>{u||S.emit("step",i)},"emitStep"),emitResult:ft,reportCaptureIssue:G,documentInternals:l.document,portraitInternals:l.portrait,livePhotoInternals:l.livePhoto,uploadInternals:l.upload,pageCameraInternals:l.pageCamera});return R=n,n})),ae),"Zt");return{consent:t(()=>A(),"consent"),startRegistry:Ce,methodChoice:At,selectMethod:Tt,reportCameraUnavailable:t(async e=>{await A();let n=y.reportCameraUnavailable;if(n===void 0)throw new TypeError("this client cannot report a missing camera");let i=await n.call(y,e).catch(s=>{if(s instanceof I&&s.code==="check_out_of_order")return y.getSession();throw s});u||b(i)},"reportCameraUnavailable"),reportCaptureIssue:G,testerGate:t(async e=>{let n=y.testerGate;if(n===void 0)throw new TypeError("this client cannot run the tester gate");let i=e.clip,s=Ue(e.clipMime??"");if(i===void 0||!ze.includes(s))throw new TypeError("the capture has no clip");await A();let o=await He(y,"clip",s,i.size,{engine:e.engine,durationMs:e.clipMs});await y.uploadToSpaces(o.uploadUrl,i,s);let{key:d}=await y.completeMedia(o.key),m=await Re({always:!0}),h=await n.call(y,{clipKey:d,attestation:m,captureChannel:e.captureChannel,capture:{...Je(e),attestationError:q}}),{bound:a,..._}=h;return u||(_.plan!==void 0?b(_):await k()),{bound:a===!0}},"testerGate"),mobileRequired:Mt,captureMode:Ct,chooseCaptureMode:t(e=>{V=e},"chooseCaptureMode"),get captureChoice(){return $()},returning:St,liveness:Le,run:t(async()=>{if(u)throw new Error("verification destroyed");return(await xt()).run()},"run"),currentStep:t(()=>R?.current()??null,"currentStep"),voiceClips:t(async()=>{if(u)return null;try{let e=await v();return u?null:e.voice??null}catch{return null}},"voiceClips"),on:t((e,n)=>S.on(e,n),"on"),destroy:t(()=>{u=!0,me.abort(),R?.destroy(),g!==null&&(g.alive=!1,g.capture.handle.destroy(),g=null),S.clear()},"destroy")}}t(Bt,"dn");var st=["AD","AE","AF","AG","AI","AL","AM","AO","AQ","AR","AS","AT","AU","AW","AX","AZ","BA","BB","BD","BE","BF","BG","BH","BI","BJ","BL","BM","BN","BO","BQ","BR","BS","BT","BV","BW","BY","BZ","CA","CC","CD","CF","CG","CH","CI","CK","CL","CM","CN","CO","CR","CU","CV","CW","CX","CY","CZ","DE","DJ","DK","DM","DO","DZ","EC","EE","EG","EH","ER","ES","ET","FI","FJ","FK","FM","FO","FR","GA","GB","GD","GE","GF","GG","GH","GI","GL","GM","GN","GP","GQ","GR","GS","GT","GU","GW","GY","HK","HM","HN","HR","HT","HU","ID","IE","IL","IM","IN","IO","IQ","IR","IS","IT","JE","JM","JO","JP","KE","KG","KH","KI","KM","KN","KP","KR","KW","KY","KZ","LA","LB","LC","LI","LK","LR","LS","LT","LU","LV","LY","MA","MC","MD","ME","MF","MG","MH","MK","ML","MM","MN","MO","MP","MQ","MR","MS","MT","MU","MV","MW","MX","MY","MZ","NA","NC","NE","NF","NG","NI","NL","NO","NP","NR","NU","NZ","OM","PA","PE","PF","PG","PH","PK","PL","PM","PN","PR","PS","PT","PW","PY","QA","RE","RO","RS","RU","RW","SA","SB","SC","SD","SE","SG","SH","SI","SJ","SK","SL","SM","SN","SO","SR","SS","ST","SV","SX","SY","SZ","TC","TD","TF","TG","TH","TJ","TK","TL","TM","TN","TO","TR","TT","TV","TW","TZ","UA","UG","UM","US","UY","UZ","VA","VC","VE","VG","VI","VN","VU","WF","WS","XK","YE","YT","ZA","ZM","ZW"],lt=["carte_identite","passport","residence_permit","drivers_license"],Vt=["carte_identite","passport","residence_permit"];function ce(r,l){let p=r.byIssuer?.[l]??r.default;return lt.filter(f=>p==="*"?Vt.includes(f):p.includes(f))}t(ce,"fn");function ut(r,l=st){return[...new Set([...l,...Object.keys(r.byIssuer??{})])].filter(p=>ce(r,p).length>0).sort()}t(ut,"Ro");var L={fullNameMin:2,fullName:200,email:254,occupation:120,shortText:120,longText:1e3,addressLine:120,addressLines:4,city:80,postcode:16,number:1e12,dateMin:"1900-01-01",dateMax:"2100-12-31"};var yn={full_name:L.fullName,occupation:L.occupation,email:L.email,short_text:L.shortText,long_text:L.longText},ct=Object.freeze({nni_invalid:"id_number_invalid",nni_not_found:"registry_record_not_found",nni_recheck:"id_number_recheck",document_nni_mismatch:"document_id_number_mismatch",nni_locked:"id_number_locked",nni_unbound:"id_number_unbound",missing_nni:"missing_id_number",registry_needs_nni_source:"registry_needs_id_number_source"}),vn=new Map(Object.entries(ct)),_n=new Map(Object.entries(ct).map(([r,l])=>[l,r]));var gn=10*1024*1024;function ir(r){if(r==="permission")return"denied";if(r==="notfound"||r==="insecure"||r==="unsupported")return"no_camera"}t(ir,"ce");var $t=/^[A-Z0-9][A-Z0-9 -]{0,39}$/,Ht=Object.freeze({normalize:t(r=>r.trim().toUpperCase().replace(/\s+/g," "),"normalize"),check:t(r=>$t.test(r),"check"),registrySources:Object.freeze([]),describe:"number must be 1 to 40 letters, digits, spaces or hyphens"}),zt=/^[A-Z0-9]{4,20}$/,de=t(r=>r.trim().toUpperCase().replace(/[\s-]+/g,""),"m"),Zt=Object.freeze({normalize:de,check:t(r=>zt.test(de(r)),"check"),registrySources:Object.freeze([]),describe:"number must be 4 to 20 letters or digits"});function Wt(r){return typeof r=="string"&&/^\d{10}$/.test(r)&&Number(r)%97===1}t(Wt,"fe");var Yt={trim:t(r=>r.trim(),"trim"),upper_single_space:t(r=>r.trim().toUpperCase().replace(/\s+/g," "),"upper_single_space"),upper_no_space_or_hyphen:de},Jt={mr_nni_mod97:t(r=>Wt(r),"mr_nni_mod97")};function Qt(r){let l=new RegExp(r.pattern,"u"),p=r.check===null?void 0:Jt[r.check];return Object.freeze({normalize:Yt[r.normalize],check:t(f=>l.test(f.trim())&&(p===void 0||p(f)),"check"),registrySources:Object.freeze([...r.registrySources]),describe:r.describe})}t(Qt,"Pe");var Xt=Object.freeze(Object.fromEntries(Object.entries(et).map(([r,l])=>[r,Qt(l)])));function en(r,l){return Xt[`${r.toUpperCase()}:${l}`]??(l==="drivers_license"?Zt:Ht)}t(en,"C");var ar=Object.freeze({MRT:"MR"});function or(r){return en("MR","national_id").check(r)}t(or,"Me");function tn(r){let l="";for(let p of r){let f=p.codePointAt(0)??0;f>=1632&&f<=1641?l+=String(f-1632):f>=1776&&f<=1785?l+=String(f-1776):p!==" "&&p!=="-"&&p!==" "&&(l+=p)}return l}t(tn,"H");function sr(r){return tn(r)}t(sr,"He");var lr=ce,ur=ut;var nn=t(()=>import("./create-document-capture-WFTNVMCE-QOCPJSAU.js"),"E");function rn(){nn().then(r=>r.warmDocumentCapture()).catch(()=>{})}t(rn,"D");function cr(){rn()}t(cr,"et");var an=t(()=>import("./create-portrait-capture-5VGYZUOK-KTCFCHTN.js"),"O");function on(){an().then(r=>r.warmPortraitCapture()).catch(()=>{})}t(on,"I");function dr(){on()}t(dr,"at");export{Kt as a,ir as b,or as c,sr as d,lr as e,ur as f,cr as g,dr as h};