@sekyro/elements 0.1.0-rc.16 → 0.1.0-rc.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/dist/cdn/chunks/{camera-trait-V4UAOPIQ-TFCPOCSU.js → camera-trait-DELAK3YN-4I2GHAFU.js} +1 -1
- package/dist/cdn/chunks/{capture-session-doc-LKMMJG4H-GQNWHWDA.js → capture-session-doc-J4MIDQOS-DYA3TI2D.js} +1 -1
- package/dist/cdn/chunks/chunk-2TFK736S.js +1 -0
- package/dist/cdn/chunks/{chunk-QR7XWTXK.js → chunk-3XCA56FW.js} +1 -1
- package/dist/cdn/chunks/{chunk-7T4LO7VD.js → chunk-4QPD5ZMB.js} +1 -1
- package/dist/cdn/chunks/{chunk-YLCUWE22.js → chunk-62FWEZDF.js} +1 -1
- package/dist/cdn/chunks/{chunk-3DAULGZ2.js → chunk-C5LJ5ZHE.js} +1 -1
- package/dist/cdn/chunks/chunk-CH3JN7FV.js +1 -0
- package/dist/cdn/chunks/{chunk-BR5RW4XZ.js → chunk-ECAWI75T.js} +1 -1
- package/dist/cdn/chunks/{chunk-UTTEUW7M.js → chunk-EHIN4Z6H.js} +1 -1
- package/dist/cdn/chunks/chunk-F4Q2Q4OC.js +1 -0
- package/dist/cdn/chunks/{chunk-Z25MPNSU.js → chunk-IWZRAEUN.js} +1 -1
- package/dist/cdn/chunks/{chunk-R5I4TYXJ.js → chunk-KOTLQOUY.js} +1 -1
- package/dist/cdn/chunks/{chunk-VGBSCCXD.js → chunk-MK5WGJZO.js} +1 -1
- package/dist/cdn/chunks/chunk-NPEJKEWK.js +1 -0
- package/dist/cdn/chunks/chunk-PND4F7JQ.js +1 -0
- package/dist/cdn/chunks/chunk-PP4PZVFR.js +3 -0
- package/dist/cdn/chunks/chunk-QWBHA4YX.js +33 -0
- package/dist/cdn/chunks/chunk-SLLJX5QK.js +1 -0
- package/dist/cdn/chunks/{chunk-XFUL5N47.js → chunk-SYZUFSPK.js} +1 -1
- package/dist/cdn/chunks/chunk-TODKCK6A.js +1 -0
- package/dist/cdn/chunks/{chunk-DHMC5D6M.js → chunk-UE6IZTZA.js} +1 -1
- package/dist/cdn/chunks/{chunk-Z6KNLRUW.js → chunk-VYFRJNC5.js} +1 -1
- package/dist/cdn/chunks/{chunk-TDAUIJGS.js → chunk-WVDCPIC3.js} +1 -1
- package/dist/cdn/chunks/chunk-WZFFQZE2.js +1 -0
- package/dist/cdn/chunks/chunk-Y6VKSYVY.js +1 -0
- package/dist/cdn/chunks/chunk-YZE7YZVV.js +1 -0
- package/dist/cdn/chunks/{chunk-TGVU2IVC.js → chunk-ZF7TAXXU.js} +1 -1
- package/dist/cdn/chunks/create-document-capture-SMEKDBGF-DISVYLXM.js +1 -0
- package/dist/cdn/chunks/{detector-scanic-GGIKCF6B-OP62MOM6.js → detector-scanic-P2RTEQUV-A5WTP2Q7.js} +1 -1
- package/dist/cdn/chunks/document-capture-view-TV2VKLPV-6ZFRPTO3.js +1 -0
- package/dist/cdn/chunks/eid-view-VC3DHQWV-IBAI3YPF.js +1 -0
- package/dist/cdn/chunks/email-otp-view-QCELBL7U-XSYVFDW7.js +1 -0
- package/dist/cdn/chunks/flow-views-VCE6CEBN-Y6VVTJPN.js +1 -0
- package/dist/cdn/chunks/form-view-P2GVOYAC-ZWBQXCK3.js +1 -0
- package/dist/cdn/chunks/overlay-de-EMTSLK3M-LA7EI7SW.js +1 -0
- package/dist/cdn/chunks/overlay-es-6WMAHH33-66DPI2L6.js +1 -0
- package/dist/cdn/chunks/overlay-pt-WBGMJQTQ-IOBB3HFB.js +1 -0
- package/dist/cdn/chunks/plan-runner-ZVYJ3UI3-PDRZPFOE.js +1 -0
- package/dist/cdn/chunks/portrait-capture-view-QYEEV2D6-XMKA6YZR.js +1 -0
- package/dist/cdn/chunks/{portrait-review-view-NJHH2E4W-5UKV267T.js → portrait-review-view-E3SBOU4F-QVDIDUCS.js} +1 -1
- package/dist/cdn/chunks/print-DCYX3CZD-DLQCPZZE.js +11 -0
- package/dist/cdn/chunks/{proof-of-address-view-LS3JZUTD-WPPCFOIG.js → proof-of-address-view-NIAKWB6B-43ZQX5T6.js} +1 -1
- package/dist/cdn/define.js +1 -1
- package/dist/cdn/index.js +1 -1
- package/dist/{chunk-MWTOWGEI.js → chunk-46JFMIK7.js} +1 -1
- package/dist/{chunk-6NNMOFMF.js → chunk-5S5OC2EE.js} +1 -1
- package/dist/{chunk-WLCS5VAA.js → chunk-77AEILD6.js} +1 -1
- package/dist/chunk-BMRETLHG.js +33 -0
- package/dist/chunk-C3WB5BAA.js +1 -0
- package/dist/{chunk-5NSMKCTW.js → chunk-ELSYMAAW.js} +1 -1
- package/dist/{chunk-734Y6RUV.js → chunk-ENXYUW3S.js} +1 -1
- package/dist/{chunk-VJZANYM3.js → chunk-FKGVTX2Y.js} +1 -1
- package/dist/{chunk-D3TZZ4SI.js → chunk-IBMR3ZXU.js} +1 -1
- package/dist/{chunk-2WYXQYNY.js → chunk-JKDI3DQD.js} +1 -1
- package/dist/{chunk-ICJ544T4.js → chunk-N5JOXWJJ.js} +1 -1
- package/dist/{chunk-AJHRPKD4.js → chunk-SBLFJ2MR.js} +1 -1
- package/dist/{chunk-YVGOUZ7T.js → chunk-VFLMBXU5.js} +1 -1
- package/dist/{chunk-ZUFN5VIE.js → chunk-X2RZOTUB.js} +1 -1
- package/dist/define.cjs +5 -5
- package/dist/define.js +1 -1
- package/dist/document-capture-view-TV2VKLPV-7EOLXSFW.js +1 -0
- package/dist/{eid-view-ZM7QAEME-7FRC3TV6.js → eid-view-VC3DHQWV-IB3JCWRI.js} +1 -1
- package/dist/{email-otp-view-EYS26ZZM-EESWRHKM.js → email-otp-view-QCELBL7U-K6OU6CWG.js} +1 -1
- package/dist/flow-views-VCE6CEBN-EYXMVPZI.js +1 -0
- package/dist/{form-view-Y5KA6R5T-DOZFYGBK.js → form-view-P2GVOYAC-R5HGNTAJ.js} +1 -1
- package/dist/index.cjs +5 -5
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -1
- package/dist/overlay-de-EMTSLK3M-KNNEJ2DR.js +1 -0
- package/dist/overlay-es-6WMAHH33-YZN2JC7A.js +1 -0
- package/dist/overlay-pt-WBGMJQTQ-Y6AG6QUZ.js +1 -0
- package/dist/{portrait-capture-view-E5LKQQ5Y-E3BRULLL.js → portrait-capture-view-QYEEV2D6-OD3VHIKE.js} +1 -1
- package/dist/{portrait-review-view-NJHH2E4W-CKMVD7ME.js → portrait-review-view-E3SBOU4F-DJAWJV6V.js} +1 -1
- package/dist/{proof-of-address-view-LS3JZUTD-ZQ4BDFNP.js → proof-of-address-view-NIAKWB6B-4ZP6SD46.js} +1 -1
- package/package.json +2 -2
- package/sbom.cdx.json +4 -4
- package/dist/cdn/chunks/chunk-3NOBU7TE.js +0 -1
- package/dist/cdn/chunks/chunk-DQGAOSBX.js +0 -1
- package/dist/cdn/chunks/chunk-EMKK7NJU.js +0 -1
- package/dist/cdn/chunks/chunk-F5GIBIWU.js +0 -1
- package/dist/cdn/chunks/chunk-H5T4U7DM.js +0 -1
- package/dist/cdn/chunks/chunk-HOSTJBJM.js +0 -1
- package/dist/cdn/chunks/chunk-IO5LQDY2.js +0 -33
- package/dist/cdn/chunks/chunk-KVTY4E6J.js +0 -1
- package/dist/cdn/chunks/chunk-Q7ACZDU4.js +0 -1
- package/dist/cdn/chunks/chunk-QWPURAKS.js +0 -1
- package/dist/cdn/chunks/chunk-TIOXYUT7.js +0 -3
- package/dist/cdn/chunks/create-document-capture-PG6NLCPH-SB25EXKH.js +0 -1
- package/dist/cdn/chunks/document-capture-view-I72R2TZK-IPPKCL3Y.js +0 -1
- package/dist/cdn/chunks/eid-view-ZM7QAEME-HFAGVDCQ.js +0 -1
- package/dist/cdn/chunks/email-otp-view-EYS26ZZM-5WX42RSL.js +0 -1
- package/dist/cdn/chunks/flow-views-7SAYQQ62-4RKPVVBZ.js +0 -1
- package/dist/cdn/chunks/form-view-Y5KA6R5T-KP2XRJQ7.js +0 -1
- package/dist/cdn/chunks/overlay-de-4OISTBDL-WWT74VG7.js +0 -1
- package/dist/cdn/chunks/overlay-es-YO5UCAO2-U3OAELIS.js +0 -1
- package/dist/cdn/chunks/overlay-pt-E7PSFLLQ-ZPN4CLS4.js +0 -1
- package/dist/cdn/chunks/plan-runner-BZ7LODPB-KXZ5UKVT.js +0 -1
- package/dist/cdn/chunks/portrait-capture-view-E5LKQQ5Y-MZ3BOZEU.js +0 -1
- package/dist/cdn/chunks/print-SEWS3VHQ-HWJTHADG.js +0 -11
- package/dist/chunk-4JHVEBTX.js +0 -33
- package/dist/chunk-XI37ATRU.js +0 -1
- package/dist/document-capture-view-I72R2TZK-LCX5EQJR.js +0 -1
- package/dist/flow-views-7SAYQQ62-3NIWXTDB.js +0 -1
- package/dist/overlay-de-4OISTBDL-TH46LT3S.js +0 -1
- package/dist/overlay-es-YO5UCAO2-NBICE576.js +0 -1
- package/dist/overlay-pt-E7PSFLLQ-NCA5NABT.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{a as N}from"./chunk-
|
|
1
|
+
"use client";import{a as N}from"./chunk-77AEILD6.js";import"./chunk-N5JOXWJJ.js";import{a as te}from"./chunk-FKGVTX2Y.js";import"./chunk-VFLMBXU5.js";import{c as X}from"./chunk-ELSYMAAW.js";import{a as ae,b as re,c as ie}from"./chunk-46JFMIK7.js";import"./chunk-5S5OC2EE.js";import"./chunk-JKDI3DQD.js";import{C as Y,H as Z,L as f,M as ee,a as ke,b as ye,c as C,t as Q}from"./chunk-SBLFJ2MR.js";import{a as S,c as O,i as n}from"./chunk-SSU37LFQ.js";var i=O(ke(),1),e=O(ye(),1);var x=["pose","eyes","mouth","lighting","background","resolution"],se="occlusion";function le(r){return r?.startsWith("icao_")===!0?r.slice(5):null}S(le,"Se");n(le,"reasonCriterion");function ve({step:r,i18n:c,assetBaseUrl:M,onUpload:P}){let{t:a}=c,B=(0,i.useRef)(null),p=(0,i.useRef)(null),[s,oe]=(0,i.useState)("idle"),[k,L]=(0,i.useState)(null),[_,y]=(0,i.useState)(null),[$,E]=(0,i.useState)({facing:"user",assisted:!1}),[F,ne]=(0,i.useState)(!1),[de,I]=(0,i.useState)(!1),[j,ce]=(0,i.useState)(!1),pe=Q(),T=(0,i.useContext)(Y),U=(0,i.useContext)(ae),A=(0,i.useRef)(U);A.current=U,(0,i.useEffect)(()=>{let t=B.current;if(t===null)return;let l=r.capture({video:t,...M!==void 0?{assetBaseUrl:M}:{}});p.current=l;let g=n(()=>E({facing:l.facingMode??"user",assisted:l.captureMode==="assisted"}),"readCamera");g();let fe=[l.on("state",o=>{g(),o==="mode_switch"?I(!0):o!=="starting"&&o!=="gating"&&I(!1),oe(o)}),l.on("gate",L),l.on("error",o=>{y(o);let K=A.current;K!==null&&ie(K,re("portrait",o,0))})],J=!0;return Promise.resolve(l.canSwitchCaptureMode?.()??!1).catch(()=>!1).then(o=>{J&&ne(o===!0)}),l.start().catch(()=>{}),()=>{J=!1;for(let o of fe)o();l.destroy(),p.current=null}},[]);let u=s==="uploading"||s==="checking",h=s==="done",v=h&&r.reason!==void 0&&!r.uploadFailed,ue=s==="starting"||s==="idle"||s==="mode_switch"?"portrait.starting":s==="captured"?"portrait.taken":s==="uploading"?"portrait.uploading":s==="checking"?"portrait.checking":`portrait.coach.${k?.coach??"no_face"}`,R=(r.report??[]).filter(t=>!t.pass),V=r.reason!==void 0?`reasons.${r.reason}`:null,m=le(r.reason),q=R.filter(t=>t.criterion!==m),H=new Set([...R.map(t=>t.criterion),...m!==null?[m]:[]]),he=H.has(se),W=n(()=>{y(null),p.current?.retry()},"retake"),w=n(t=>{let l=k?.criteria.find(g=>g.criterion===t);return l!==void 0&&(l.held||l.waived)},"met"),me=k?.ready||s==="captured"||u?1:x.filter(w).length/x.length;v&&!j&&ce(!0);let z=V!==null&&(v||s==="gating"&&(m===null||!j)),ge=!v,D=s==="starting"||s==="gating"||s==="error"||s==="mode_switch",d=$.assisted?"self":"assisted",G=F&&D?{to:d,label:a(d==="assisted"?"capture.modeSwitch.toAssisted":"capture.modeSwitch.toSelfPhoto"),description:a(d==="assisted"?"capture.modeSwitch.toAssistedLabelPhoto":"capture.modeSwitch.toSelfLabelPhoto"),onSwitch:n(()=>{let t=p.current;t?.setCaptureMode(d).then(l=>{l&&(y(null),L(null),E({facing:t.facingMode??"user",assisted:d==="assisted"}))})},"onSwitch")}:null,b=de&&D?a("capture.modeSwitch.restarted"):null;return(0,e.jsxs)(te,{testId:"sekyro-portrait",video:(0,e.jsx)("video",{ref:B,className:`sekyro-lm-video sekyro-fc-video${$.facing==="environment"?" is-rear":""}`,playsInline:!0,muted:!0,autoPlay:!0,"aria-hidden":"true"}),instruction:a(ue),...b!==null?{note:b}:{},...F?{status:b}:{},progress:me,closeLabel:a("native.close"),...T!==void 0?{onClose:T}:{},...G!==null?{end:(0,e.jsx)(X,{view:G,className:"sekyro-glass sekyro-glass--label"})}:{},children:[(0,e.jsx)("h2",{ref:pe,tabIndex:-1,className:"sekyro-visually-hidden",children:a(r.reason!==void 0?"portrait.retryTitle":"session.steps.portrait.title")}),z||_!==null||h&&(r.uploadFailed||!r.attemptsExhausted)?(0,e.jsxs)("div",{className:"sekyro-fc-panel",children:[z?(0,e.jsxs)(f,{tone:"warning",children:[(0,e.jsx)("span",{children:N(c)(V)||a("portrait.retryTitle")}),q.length>0?(0,e.jsxs)("span",{children:[a("portrait.reportTitle"),": ",q.map(t=>a(`portrait.report.${t.criterion}`)).join(", ")]}):null,(0,e.jsx)("span",{children:ee(c,r.attemptsRemaining,r.attemptsExhausted)})]}):null,_!==null?(0,e.jsxs)(f,{tone:"danger",children:[(0,e.jsx)("span",{children:a("portrait.cameraBlocked")}),(0,e.jsx)("span",{children:a("portrait.cameraBlockedHint")}),(0,e.jsx)(C,{kind:"secondary",onClick:W,children:a("portrait.retryCamera")})]}):null,r.uploadFailed&&h?(0,e.jsx)(f,{tone:"danger",children:(0,e.jsx)("span",{children:a("portrait.uploadFailed")})}):null,h&&!r.attemptsExhausted?(0,e.jsx)(C,{full:!0,onClick:W,disabled:u,children:a("portrait.retake")}):null]}):null,ge?(0,e.jsxs)("ul",{className:"sekyro-fc-checks","aria-label":a("portrait.checksLabel"),children:[x.map(t=>(0,e.jsxs)("li",{className:w(t)?"is-met":H.has(t)?"is-flagged":void 0,"data-criterion":t,children:[(0,e.jsx)("span",{className:"sekyro-fc-mark","aria-hidden":"true",children:(0,e.jsx)("svg",{viewBox:"0 0 18 18",children:(0,e.jsx)("path",{d:"M5 9.2l2.6 2.6L13 6.4"})})}),(0,e.jsx)("span",{children:a(`portrait.criteria.${t}`)}),(0,e.jsx)("span",{className:"sekyro-visually-hidden",children:a(w(t)?"portrait.met":"portrait.notMet")})]},t)),he?(0,e.jsxs)("li",{className:"is-flagged","data-criterion":se,children:[(0,e.jsx)("span",{className:"sekyro-fc-mark","aria-hidden":"true",children:(0,e.jsx)("svg",{viewBox:"0 0 18 18",children:(0,e.jsx)("path",{d:"M5 9.2l2.6 2.6L13 6.4"})})}),(0,e.jsx)("span",{children:a("portrait.report.occlusion")}),(0,e.jsx)("span",{className:"sekyro-visually-hidden",children:a("portrait.notMet")})]}):null]}):null,P!==void 0&&!u?(0,e.jsx)("button",{type:"button",className:"sekyro-lm-upload",onClick:P,"data-testid":"sekyro-portrait-upload-instead",children:N(c)("portrait.source.uploadInstead")}):null,u?null:(0,e.jsx)(Z,{})]})}S(ve,"Le");n(ve,"PortraitCaptureView");export{ve as PortraitCaptureView};
|
package/dist/{portrait-review-view-NJHH2E4W-CKMVD7ME.js → portrait-review-view-E3SBOU4F-DJAWJV6V.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{a as r,b as t,c as i,d as o,e as a}from"./chunk-
|
|
1
|
+
"use client";import{a as r,b as t,c as i,d as o,e as a}from"./chunk-77AEILD6.js";import"./chunk-N5JOXWJJ.js";import"./chunk-VFLMBXU5.js";import"./chunk-5S5OC2EE.js";import"./chunk-SBLFJ2MR.js";import"./chunk-SSU37LFQ.js";export{o as PortraitReviewView,a as PortraitScreens,t as PortraitSourceView,i as PortraitUploadView,r as portraitCopy};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{a as S}from"./chunk-ICJ544T4.js";import{a as J}from"./chunk-P223YKM3.js";import{d as M}from"./chunk-YVGOUZ7T.js";import"./chunk-6NNMOFMF.js";import{a as q}from"./chunk-XI37ATRU.js";import"./chunk-2WYXQYNY.js";import{K as b,L as G,a as O,b as j,c as k,v as N,w as D,y as R}from"./chunk-AJHRPKD4.js";import{a as l,c as x,i as p}from"./chunk-SSU37LFQ.js";var v=x(O(),1),f=x(O(),1),o=x(j(),1),t=x(j(),1);var ee={"poa.title":"إثبات العنوان","poa.lead":"ارفع وثيقة حديثة تُظهر اسمك وعنوانك الحالي.","poa.accepted":"الوثائق المقبولة","poa.acceptedFor":"مقبول في {country}","poa.kindDated":"{kind}، صادر خلال آخر {days} يومًا","poa.kinds.utility_bill":"فاتورة كهرباء أو ماء أو غاز","poa.kinds.telecom_bill":"فاتورة هاتف أو إنترنت","poa.kinds.bank_statement":"كشف حساب بنكي","poa.kinds.tax_notice":"إشعار ضريبي","poa.kinds.rental_agreement":"عقد إيجار","poa.kinds.government_certificate":"شهادة السكن","poa.kinds.insurance_statement":"وثيقة تأمين","poa.source.camera":"التقاط صورة","poa.source.upload":"رفع ملف","poa.source.lead":"صورة للوثيقة، أو ملف PDF أو صورة من جهازك","poa.upload.hint":"PDF أو JPEG أو PNG، بحد أقصى 3 صفحات و10 ميغابايت","poa.upload.choose":"اختيار ملف","poa.upload.addPage":"إضافة صفحة","poa.upload.pages":"{count} من 3 صفحات","poa.upload.send":"إرسال الوثيقة","poa.upload.sending":"جارٍ إرسال وثيقتك…","poa.upload.unsupported":"نوع الملف هذا غير مقبول. اختر ملف PDF أو JPEG أو PNG","poa.upload.tooManyPages":"أرسل 3 صفحات على الأكثر. احذف صفحة أو اختر ملفًا أقصر","poa.upload.tooLarge":"حجم الملف يتجاوز 10 ميغابايت. اختر ملفًا أصغر","poa.upload.failed":"تعذّر إرسال الوثيقة. تحقّق من اتصالك وحاول مرة أخرى","poa.camera.lead":"ضع الوثيقة بشكل مسطّح واملأ الإطار. التقط صورة واحدة لكل صفحة","poa.camera.capture":"التقاط الصورة","poa.camera.retake":"إعادة الالتقاط","poa.camera.next":"الصفحة التالية","poa.camera.page":"الصفحة {number}","poa.letter.title":"رسالة من صاحب الفاتورة","poa.letter.lead":"الوثيقة باسم شخص آخر. أضف رسالة موقّعة من هذا الشخص تفيد بأنك تسكن في هذا العنوان","poa.letter.send":"إرسال الرسالة","poa.licence.use":"استخدام العنوان المذكور في رخصة القيادة","poa.licence.note":"قرأنا هذا العنوان من رخصتك. لا تحتاج إلى وثيقة أخرى.","poa.retry.document_too_old":"هذه الوثيقة أقدم من المسموح. ارفع وثيقة أحدث من القائمة أدناه","poa.retry.document_date_invalid":"تاريخ الوثيقة في المستقبل. ارفع وثيقة بتاريخ اليوم أو قبله","poa.retry.document_kind_not_accepted":"نوع هذه الوثيقة غير مقبول. ارفع إحدى الوثائق المذكورة أدناه","poa.retry.name_mismatch":"الاسم في الوثيقة لا يطابق اسمك. ارفع وثيقة باسمك","poa.retry.address_mismatch":"العنوان في الوثيقة لا يطابق العنوان الذي وصلنا. ارفع وثيقة لهذا العنوان","poa.retry.holder_letter_missing":"يجب أن تكون الرسالة موقّعة وأن تذكر اسمك واسم صاحب الفاتورة. ارفع رسالة كاملة","poa.retry.unreadable":"تعذّرت قراءة الوثيقة. ارفع نسخة كاملة وأكثر وضوحًا","poa.retry.pdf_protected":"أزل كلمة المرور من ملف PDF وحاول مرة أخرى","poa.retry.provider_unavailable":"تعذّر فحص الوثيقة حاليًا. حاول مرة أخرى بعد قليل","poa.hint.blurry":"الصورة غير واضحة","poa.hint.cropped":"جزء من الوثيقة مقطوع","poa.hint.glare":"يوجد انعكاس ضوء على الوثيقة","reasons.provider_unavailable":"تعذّر فحص الوثيقة حاليًا","reasons.pdf_protected":"ملف PDF محمي بكلمة مرور أو يحتوي على محتوى نشط","reasons.document_kind_not_accepted":"نوع الوثيقة غير مقبول","reasons.document_date_invalid":"تاريخ الوثيقة في المستقبل","reasons.document_too_old":"الوثيقة قديمة جدًا","reasons.document_tampered":"يبدو أن الوثيقة قد عُدّلت","reasons.holder_letter_required":"يلزم تقديم رسالة من صاحب الفاتورة","reasons.holder_letter_missing":"رسالة صاحب الفاتورة مفقودة أو غير مكتملة","reasons.address_mismatch":"العنوان لا يطابق العنوان المقدَّم"},U={"poa.title":"Proof of address","poa.lead":"Upload a recent document that shows your name and your current address.","poa.accepted":"Accepted documents","poa.acceptedFor":"Accepted for {country}","poa.kindDated":"{kind}, dated within the last {days} days","poa.kinds.utility_bill":"Electricity, water or gas bill","poa.kinds.telecom_bill":"Phone or internet bill","poa.kinds.bank_statement":"Bank statement","poa.kinds.tax_notice":"Tax notice","poa.kinds.rental_agreement":"Rental agreement","poa.kinds.government_certificate":"Residence certificate","poa.kinds.insurance_statement":"Insurance statement","poa.source.camera":"Take a photo","poa.source.upload":"Upload a file","poa.source.lead":"A photo of the document, or a PDF or image from your device","poa.upload.hint":"PDF, JPEG or PNG, up to 3 pages and 10 MB","poa.upload.choose":"Choose a file","poa.upload.addPage":"Add a page","poa.upload.pages":"{count} of 3 pages","poa.upload.send":"Send document","poa.upload.sending":"Sending your document…","poa.upload.unsupported":"This file type is not accepted. Choose a PDF, JPEG or PNG","poa.upload.tooManyPages":"Send at most 3 pages. Remove a page or choose a shorter file","poa.upload.tooLarge":"The file is over 10 MB. Choose a smaller file","poa.upload.failed":"We could not send the document. Check your connection and try again","poa.camera.lead":"Lay the document flat and fill the frame. Take one photo per page","poa.camera.capture":"Take photo","poa.camera.retake":"Retake","poa.camera.next":"Next page","poa.camera.page":"Page {number}","poa.letter.title":"Letter from the bill holder","poa.letter.lead":"The document is in another person's name. Add a signed letter from that person saying that you live at this address","poa.letter.send":"Send letter","poa.licence.use":"Use the address on my driver's license","poa.licence.note":"We read this address from your license. You don't need another document.","poa.retry.document_too_old":"This document is older than allowed. Upload a more recent one from the list below","poa.retry.document_date_invalid":"The date on the document is in the future. Upload a document with today's date or earlier","poa.retry.document_kind_not_accepted":"This document type is not accepted. Upload one of the documents listed below","poa.retry.name_mismatch":"The name on the document does not match yours. Upload a document in your name","poa.retry.address_mismatch":"The address on the document does not match the one we were given. Upload a document for that address","poa.retry.holder_letter_missing":"The letter must be signed and name both you and the bill holder. Upload a complete letter","poa.retry.unreadable":"We could not read the document. Upload a sharper, complete copy","poa.retry.pdf_protected":"Remove the password from the PDF and try again","poa.retry.provider_unavailable":"The document could not be checked right now. Try again in a moment","poa.hint.blurry":"The image is blurry","poa.hint.cropped":"Part of the document is cut off","poa.hint.glare":"There is glare on the document","reasons.provider_unavailable":"The document could not be checked right now","reasons.pdf_protected":"The PDF is password-protected or contains active content","reasons.document_kind_not_accepted":"The document type is not accepted","reasons.document_date_invalid":"The document date is in the future","reasons.document_too_old":"The document is too old","reasons.document_tampered":"The document appears to have been edited","reasons.holder_letter_required":"A letter from the bill holder is needed","reasons.holder_letter_missing":"The letter from the bill holder is missing or incomplete","reasons.address_mismatch":"The address does not match the one supplied"},ae={"poa.title":"Justificatif de domicile","poa.lead":"Importez un document récent qui indique votre nom et votre adresse actuelle.","poa.accepted":"Documents acceptés","poa.acceptedFor":"Accepté pour {country}","poa.kindDated":"{kind}, daté des {days} derniers jours","poa.kinds.utility_bill":"Facture d'électricité, d'eau ou de gaz","poa.kinds.telecom_bill":"Facture de téléphone ou d'internet","poa.kinds.bank_statement":"Relevé bancaire","poa.kinds.tax_notice":"Avis d'imposition","poa.kinds.rental_agreement":"Bail ou quittance de loyer","poa.kinds.government_certificate":"Certificat de résidence","poa.kinds.insurance_statement":"Attestation d'assurance","poa.source.camera":"Prendre une photo","poa.source.upload":"Importer un fichier","poa.source.lead":"Une photo du document, ou un PDF ou une image depuis votre appareil","poa.upload.hint":"PDF, JPEG ou PNG, 3 pages et 10 Mo au maximum","poa.upload.choose":"Choisir un fichier","poa.upload.addPage":"Ajouter une page","poa.upload.pages":"{count} sur 3 pages","poa.upload.send":"Envoyer le document","poa.upload.sending":"Envoi de votre document…","poa.upload.unsupported":"Ce type de fichier n'est pas accepté. Choisissez un PDF, un JPEG ou un PNG","poa.upload.tooManyPages":"Envoyez 3 pages au maximum. Retirez une page ou choisissez un fichier plus court","poa.upload.tooLarge":"Le fichier dépasse 10 Mo. Choisissez un fichier plus léger","poa.upload.failed":"Nous n'avons pas pu envoyer le document. Vérifiez votre connexion et réessayez","poa.camera.lead":"Posez le document à plat et remplissez le cadre. Prenez une photo par page","poa.camera.capture":"Prendre la photo","poa.camera.retake":"Reprendre","poa.camera.next":"Page suivante","poa.camera.page":"Page {number}","poa.letter.title":"Lettre du titulaire de la facture","poa.letter.lead":"Le document est au nom d'une autre personne. Ajoutez une lettre signée de cette personne attestant que vous habitez à cette adresse","poa.letter.send":"Envoyer la lettre","poa.licence.use":"Utiliser l'adresse de mon permis de conduire","poa.licence.note":"Nous avons lu cette adresse sur votre permis. Vous n'avez pas besoin d'un autre document.","poa.retry.document_too_old":"Ce document est plus ancien que la limite. Importez un document plus récent parmi ceux de la liste ci-dessous","poa.retry.document_date_invalid":"La date du document est dans le futur. Importez un document daté d'aujourd'hui ou d'avant","poa.retry.document_kind_not_accepted":"Ce type de document n'est pas accepté. Importez l'un des documents de la liste ci-dessous","poa.retry.name_mismatch":"Le nom sur le document ne correspond pas au vôtre. Importez un document à votre nom","poa.retry.address_mismatch":"L'adresse du document ne correspond pas à celle qui nous a été transmise. Importez un document pour cette adresse","poa.retry.holder_letter_missing":"La lettre doit être signée et nommer à la fois vous et le titulaire de la facture. Importez une lettre complète","poa.retry.unreadable":"Nous n'avons pas pu lire le document. Importez une copie plus nette et complète","poa.retry.pdf_protected":"Retirez le mot de passe du PDF et réessayez","poa.retry.provider_unavailable":"Le document n'a pas pu être vérifié pour le moment. Réessayez dans un instant","poa.hint.blurry":"L'image est floue","poa.hint.cropped":"Une partie du document est coupée","poa.hint.glare":"Il y a un reflet sur le document","reasons.provider_unavailable":"Le document n'a pas pu être vérifié pour le moment","reasons.pdf_protected":"Le PDF est protégé par un mot de passe ou contient du contenu actif","reasons.document_kind_not_accepted":"Ce type de document n'est pas accepté","reasons.document_date_invalid":"La date du document est dans le futur","reasons.document_too_old":"Le document est trop ancien","reasons.document_tampered":"Le document semble avoir été modifié","reasons.holder_letter_required":"Une lettre du titulaire de la facture est nécessaire","reasons.holder_letter_missing":"La lettre du titulaire de la facture est absente ou incomplète","reasons.address_mismatch":"L'adresse ne correspond pas à celle qui a été transmise"};function B({blob:a,label:n}){let[e,r]=(0,f.useState)(void 0);return(0,f.useEffect)(()=>{if(typeof URL.createObjectURL!="function")return;let d=URL.createObjectURL(a);return r(d),()=>URL.revokeObjectURL(d)},[a]),(0,o.jsx)("img",{src:e,alt:n})}l(B,"Q");p(B,"PageThumb");function $({step:a,i18n:n,c:e,title:r,notice:d,intro:m,onUpload:i}){let y=(0,f.useRef)(null),s=(0,f.useRef)(null),[c,_]=(0,f.useState)([]),[h,P]=(0,f.useState)(!1),[L,C]=(0,f.useState)("idle"),[K,F]=(0,f.useState)(!1),A=p(u=>{P(!1),u.start().catch(()=>P(!0))},"open");(0,f.useEffect)(()=>{let u=y.current;if(u===null)return;let g;try{g=a.capturePage({video:u})}catch{P(!0);return}return s.current=g,A(g),()=>{g.destroy(),s.current=null}},[]);let E=c.length>=a.maxPages,Q=p(async()=>{let u=s.current;if(!(u===null||E)){C("taking"),F(!1);try{await u.takePage()}catch{}_([...u.pages]),C("idle")}},"take"),X=p(u=>{let g=s.current;g!==null&&(g.removePage(u),_([...g.pages]))},"retake"),Z=p(async()=>{let u=s.current;if(!(u===null||c.length===0)){C("sending"),F(!1);try{await u.submitPages()}catch{F(!0)}C("idle")}},"send"),T=L==="sending";return(0,o.jsxs)("section",{className:"sekyro-step","data-testid":"sekyro-poa-camera",children:[(0,o.jsx)(D,{title:r,lead:e("poa.camera.lead")}),d,K?(0,o.jsx)(b,{tone:"danger",children:(0,o.jsx)("span",{children:e("poa.upload.failed")})}):null,h?(0,o.jsxs)(b,{tone:"danger",children:[(0,o.jsx)("span",{children:e("doc.cameraBlocked")}),(0,o.jsx)("span",{children:e("doc.cameraBlockedHint")}),s.current!==null?(0,o.jsx)(k,{kind:"secondary",onClick:l(()=>s.current!==null&&A(s.current),"onClick"),children:e("doc.retryCamera")}):null]}):null,c.length===0?m:null,(0,o.jsx)("video",{ref:y,className:"sekyro-poa-video",playsInline:!0,muted:!0,autoPlay:!0,"aria-hidden":"true"}),c.length>0?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("p",{className:"sekyro-text-muted",role:"status",children:e("poa.upload.pages",{count:c.length})}),(0,o.jsx)("ul",{className:"sekyro-poa-pages",children:c.map((u,g)=>{let I=e("poa.camera.page",{number:g+1});return(0,o.jsxs)("li",{children:[(0,o.jsx)(B,{blob:u,label:I}),(0,o.jsx)(k,{kind:"ghost",onClick:l(()=>X(g),"onClick"),disabled:T,"aria-label":`${e("poa.camera.retake")} ${I}`,children:e("poa.camera.retake")})]},g)})})]}):null,T?(0,o.jsx)("p",{className:"sekyro-text-muted",role:"status","aria-busy":"true",children:e("poa.upload.sending")}):null,(0,o.jsxs)(R,{children:[(0,o.jsxs)(k,{full:!0,kind:c.length>0?"secondary":"primary",onClick:l(()=>{Q()},"onClick"),disabled:E||h||L!=="idle"||a.attemptsExhausted,"aria-busy":L==="taking"||void 0,children:[(0,o.jsx)(N,{name:"camera"}),e("poa.camera.capture")]}),c.length>0?(0,o.jsx)(k,{full:!0,onClick:l(()=>{Z()},"onClick"),disabled:L!=="idle","aria-busy":T||void 0,children:e("poa.upload.send")}):null,i!==void 0?(0,o.jsx)(k,{full:!0,kind:"ghost",onClick:i,disabled:T,children:e("poa.source.upload")}):null]})]})}l($,"J");p($,"PageCamera");var te={en:U,fr:ae,ar:ee,es:U,pt:U,de:U},oe="image/jpeg,image/png,image/heic,image/heif,application/pdf";function V(a){let n=a.strings,e=te[a.locale];return(r,d)=>q(n[r]??e[r]??"",d)}l(V,"ae");p(V,"poaCopy");function z({step:a,i18n:n,c:e}){if(a.reason===void 0)return null;let r=e(`poa.retry.${a.reason}`)||e(`reasons.${a.reason}`)||e("poa.retry.unreadable");return(0,t.jsxs)(b,{tone:"warning",children:[(0,t.jsx)("span",{children:r}),(0,t.jsx)("span",{children:G(n,a.attemptsRemaining,a.attemptsExhausted)})]})}l(z,"U");p(z,"RetryNotice");function w({step:a,i18n:n,c:e}){let r=(0,v.useId)(),{country:d}=a.rule,m=d===null?e("poa.accepted"):e("poa.acceptedFor",{country:J(d,n.locale)});return(0,t.jsxs)("div",{className:"sekyro-poa-accepted",children:[(0,t.jsx)("p",{id:r,className:"sekyro-poa-accepted__title",children:m}),(0,t.jsx)("ul",{className:"sekyro-poa-list","aria-labelledby":r,children:a.rule.kinds.map(i=>(0,t.jsx)("li",{children:e("poa.kindDated",{kind:e(`poa.kinds.${i.kind}`)||i.kind,days:i.maxAgeDays})},i.kind))})]})}l(w,"j");p(w,"AcceptedList");var re={unsupported:"poa.upload.unsupported",tooMany:"poa.upload.tooManyPages",tooLarge:"poa.upload.tooLarge",failed:"poa.upload.failed"};function W(a){return a instanceof TypeError&&a.message==="unsupported_file"?"unsupported":a instanceof RangeError&&a.message==="file_too_large"?"tooLarge":a instanceof RangeError&&(a.message==="too_many_pages"||a.message==="no_pages")?"tooMany":"failed"}l(W,"re");p(W,"refusalOf");function H({step:a,i18n:n,c:e,letter:r,onCamera:d}){let m=(0,v.useRef)(null),[i,y]=(0,v.useState)("idle"),s=i==="sending",c=p(async _=>{let h=Array.from(_.currentTarget.files??[]);if(_.currentTarget.value="",h.length!==0){if(h.length>a.maxPages){y("tooMany");return}y("sending");try{await(r?a.uploadHolderLetter(h):a.uploadPages(h)),y("idle")}catch(P){y(W(P))}}},"onFiles");return(0,t.jsxs)("section",{className:"sekyro-step","data-testid":r?"sekyro-poa-letter":"sekyro-poa-upload",children:[(0,t.jsx)(D,{title:e(r?"poa.letter.title":"poa.title"),lead:e(r?"poa.letter.lead":"poa.lead")}),i==="idle"||s?(0,t.jsx)(z,{step:a,i18n:n,c:e}):null,i!=="idle"&&!s?(0,t.jsx)(b,{tone:"danger",children:(0,t.jsx)("span",{children:e(re[i])})}):null,r?null:(0,t.jsx)(w,{step:a,i18n:n,c:e}),(0,t.jsx)("p",{className:"sekyro-text-muted",children:e("poa.upload.hint")}),s?(0,t.jsx)("p",{className:"sekyro-text-muted",role:"status","aria-busy":"true",children:e("poa.upload.sending")}):null,(0,t.jsx)("input",{ref:m,type:"file",accept:oe,multiple:!0,hidden:!0,"data-testid":"sekyro-poa-file","aria-label":e(r?"poa.letter.title":"poa.title"),onChange:l(_=>{c(_)},"onChange")}),(0,t.jsxs)(R,{children:[(0,t.jsx)(k,{full:!0,onClick:l(()=>m.current?.click(),"onClick"),disabled:s||!a.photo.uploadOffered||a.attemptsExhausted,"aria-busy":s||void 0,children:e("poa.upload.choose")}),d!==void 0?(0,t.jsxs)(k,{full:!0,kind:"ghost",onClick:d,disabled:s,children:[(0,t.jsx)(N,{name:a.photo.cameraOnPhone===!0?"smartphone":"camera"}),a.photo.cameraOnPhone===!0?e("capture.source.phone"):e("poa.source.camera")]}):null]})]})}l(H,"se");p(H,"UploadScreen");function Y({step:a,c:n}){let[e,r]=(0,v.useState)("idle"),d=a.useLicenceAddress;if(d===void 0)return null;let m=p(async()=>{r("sending");try{await d(),r("idle")}catch{r("failed")}},"onUse");return(0,t.jsxs)("div",{className:"sekyro-poa-licence","data-testid":"sekyro-poa-licence",children:[(0,t.jsx)("p",{className:"sekyro-text-muted",children:n("poa.licence.note")}),e==="failed"?(0,t.jsx)(b,{tone:"danger",children:(0,t.jsx)("span",{children:n("poa.upload.failed")})}):null,(0,t.jsx)(k,{full:!0,kind:"secondary",onClick:l(()=>{m()},"onClick"),disabled:e==="sending"||a.attemptsExhausted,"aria-busy":e==="sending"||void 0,children:n("poa.licence.use")})]})}l(Y,"de");p(Y,"LicenceShortcut");function ne({step:a,i18n:n}){let e=V(n),[r,d]=(0,v.useState)(null),m=a.phase==="holder_letter",i=a.photo.source,y=i==="choice"?r??a.photo.pick:i,s=a.photo.cameraOnPhone===!0,c=a.photo.uploadOffered?()=>d("upload"):void 0,_=e(m?"poa.letter.title":"poa.title"),h;return y===null?h=(0,t.jsx)(S,{testId:"sekyro-poa-source",title:_,lead:e("poa.source.lead"),cameraLabel:e(s?"capture.source.phone":"poa.source.camera"),uploadLabel:e("poa.source.upload"),onPhone:s,notice:(0,t.jsx)(z,{step:a,i18n:n,c:e}),onCamera:l(()=>d("camera"),"onCamera"),onUpload:l(()=>d("upload"),"onUpload")}):y==="camera"&&s?h=(0,t.jsx)(M,{i18n:n,lead:e("handoff.lead.poa"),refresh:a.refresh,actions:c!==void 0?(0,t.jsx)(k,{kind:"ghost",full:!0,onClick:c,children:e("poa.source.upload")}):null}):y==="camera"?h=(0,t.jsx)($,{step:a,i18n:n,c:e,title:_,notice:(0,t.jsx)(z,{step:a,i18n:n,c:e}),intro:m?null:(0,t.jsx)(w,{step:a,i18n:n,c:e}),...i==="choice"&&c!==void 0?{onUpload:c}:{}}):h=(0,t.jsx)(H,{step:a,i18n:n,c:e,letter:m,...i==="choice"?{onCamera:p(()=>d("camera"),"onCamera")}:{}}),(0,t.jsxs)(t.Fragment,{children:[m?null:(0,t.jsx)(Y,{step:a,c:e}),h]})}l(ne,"we");p(ne,"ProofOfAddressView");export{oe as POA_UPLOAD_ACCEPT,ne as ProofOfAddressView,V as poaCopy};
|
|
1
|
+
"use client";import{a as S}from"./chunk-N5JOXWJJ.js";import{a as J}from"./chunk-P223YKM3.js";import{d as M}from"./chunk-VFLMBXU5.js";import"./chunk-5S5OC2EE.js";import{a as q}from"./chunk-C3WB5BAA.js";import"./chunk-JKDI3DQD.js";import{L as b,M as G,a as O,b as j,c as k,v as N,w as D,y as R}from"./chunk-SBLFJ2MR.js";import{a as l,c as x,i as p}from"./chunk-SSU37LFQ.js";var v=x(O(),1),f=x(O(),1),o=x(j(),1),t=x(j(),1);var ee={"poa.title":"إثبات العنوان","poa.lead":"ارفع وثيقة حديثة تُظهر اسمك وعنوانك الحالي.","poa.accepted":"الوثائق المقبولة","poa.acceptedFor":"مقبول في {country}","poa.kindDated":"{kind}، صادر خلال آخر {days} يومًا","poa.kinds.utility_bill":"فاتورة كهرباء أو ماء أو غاز","poa.kinds.telecom_bill":"فاتورة هاتف أو إنترنت","poa.kinds.bank_statement":"كشف حساب بنكي","poa.kinds.tax_notice":"إشعار ضريبي","poa.kinds.rental_agreement":"عقد إيجار","poa.kinds.government_certificate":"شهادة السكن","poa.kinds.insurance_statement":"وثيقة تأمين","poa.source.camera":"التقاط صورة","poa.source.upload":"رفع ملف","poa.source.lead":"صورة للوثيقة، أو ملف PDF أو صورة من جهازك","poa.upload.hint":"PDF أو JPEG أو PNG، بحد أقصى 3 صفحات و10 ميغابايت","poa.upload.choose":"اختيار ملف","poa.upload.addPage":"إضافة صفحة","poa.upload.pages":"{count} من 3 صفحات","poa.upload.send":"إرسال الوثيقة","poa.upload.sending":"جارٍ إرسال وثيقتك…","poa.upload.unsupported":"نوع الملف هذا غير مقبول. اختر ملف PDF أو JPEG أو PNG","poa.upload.tooManyPages":"أرسل 3 صفحات على الأكثر. احذف صفحة أو اختر ملفًا أقصر","poa.upload.tooLarge":"حجم الملف يتجاوز 10 ميغابايت. اختر ملفًا أصغر","poa.upload.failed":"تعذّر إرسال الوثيقة. تحقّق من اتصالك وحاول مرة أخرى","poa.camera.lead":"ضع الوثيقة بشكل مسطّح واملأ الإطار. التقط صورة واحدة لكل صفحة","poa.camera.capture":"التقاط الصورة","poa.camera.retake":"إعادة الالتقاط","poa.camera.next":"الصفحة التالية","poa.camera.page":"الصفحة {number}","poa.letter.title":"رسالة من صاحب الفاتورة","poa.letter.lead":"الوثيقة باسم شخص آخر. أضف رسالة موقّعة من هذا الشخص تفيد بأنك تسكن في هذا العنوان","poa.letter.send":"إرسال الرسالة","poa.licence.use":"استخدام العنوان المذكور في رخصة القيادة","poa.licence.note":"قرأنا هذا العنوان من رخصتك. لا تحتاج إلى وثيقة أخرى.","poa.retry.document_too_old":"هذه الوثيقة أقدم من المسموح. ارفع وثيقة أحدث من القائمة أدناه","poa.retry.document_date_invalid":"تاريخ الوثيقة في المستقبل. ارفع وثيقة بتاريخ اليوم أو قبله","poa.retry.document_kind_not_accepted":"نوع هذه الوثيقة غير مقبول. ارفع إحدى الوثائق المذكورة أدناه","poa.retry.name_mismatch":"الاسم في الوثيقة لا يطابق اسمك. ارفع وثيقة باسمك","poa.retry.address_mismatch":"العنوان في الوثيقة لا يطابق العنوان الذي وصلنا. ارفع وثيقة لهذا العنوان","poa.retry.holder_letter_missing":"يجب أن تكون الرسالة موقّعة وأن تذكر اسمك واسم صاحب الفاتورة. ارفع رسالة كاملة","poa.retry.unreadable":"تعذّرت قراءة الوثيقة. ارفع نسخة كاملة وأكثر وضوحًا","poa.retry.pdf_protected":"أزل كلمة المرور من ملف PDF وحاول مرة أخرى","poa.retry.provider_unavailable":"تعذّر فحص الوثيقة حاليًا. حاول مرة أخرى بعد قليل","poa.hint.blurry":"الصورة غير واضحة","poa.hint.cropped":"جزء من الوثيقة مقطوع","poa.hint.glare":"يوجد انعكاس ضوء على الوثيقة","reasons.provider_unavailable":"تعذّر فحص الوثيقة حاليًا","reasons.pdf_protected":"ملف PDF محمي بكلمة مرور أو يحتوي على محتوى نشط","reasons.document_kind_not_accepted":"نوع الوثيقة غير مقبول","reasons.document_date_invalid":"تاريخ الوثيقة في المستقبل","reasons.document_too_old":"الوثيقة قديمة جدًا","reasons.document_tampered":"يبدو أن الوثيقة قد عُدّلت","reasons.holder_letter_required":"يلزم تقديم رسالة من صاحب الفاتورة","reasons.holder_letter_missing":"رسالة صاحب الفاتورة مفقودة أو غير مكتملة","reasons.address_mismatch":"العنوان لا يطابق العنوان المقدَّم"},U={"poa.title":"Proof of address","poa.lead":"Upload a recent document that shows your name and your current address.","poa.accepted":"Accepted documents","poa.acceptedFor":"Accepted for {country}","poa.kindDated":"{kind}, dated within the last {days} days","poa.kinds.utility_bill":"Electricity, water or gas bill","poa.kinds.telecom_bill":"Phone or internet bill","poa.kinds.bank_statement":"Bank statement","poa.kinds.tax_notice":"Tax notice","poa.kinds.rental_agreement":"Rental agreement","poa.kinds.government_certificate":"Residence certificate","poa.kinds.insurance_statement":"Insurance statement","poa.source.camera":"Take a photo","poa.source.upload":"Upload a file","poa.source.lead":"A photo of the document, or a PDF or image from your device","poa.upload.hint":"PDF, JPEG or PNG, up to 3 pages and 10 MB","poa.upload.choose":"Choose a file","poa.upload.addPage":"Add a page","poa.upload.pages":"{count} of 3 pages","poa.upload.send":"Send document","poa.upload.sending":"Sending your document…","poa.upload.unsupported":"This file type is not accepted. Choose a PDF, JPEG or PNG","poa.upload.tooManyPages":"Send at most 3 pages. Remove a page or choose a shorter file","poa.upload.tooLarge":"The file is over 10 MB. Choose a smaller file","poa.upload.failed":"We could not send the document. Check your connection and try again","poa.camera.lead":"Lay the document flat and fill the frame. Take one photo per page","poa.camera.capture":"Take photo","poa.camera.retake":"Retake","poa.camera.next":"Next page","poa.camera.page":"Page {number}","poa.letter.title":"Letter from the bill holder","poa.letter.lead":"The document is in another person's name. Add a signed letter from that person saying that you live at this address","poa.letter.send":"Send letter","poa.licence.use":"Use the address on my driver's license","poa.licence.note":"We read this address from your license. You don't need another document.","poa.retry.document_too_old":"This document is older than allowed. Upload a more recent one from the list below","poa.retry.document_date_invalid":"The date on the document is in the future. Upload a document with today's date or earlier","poa.retry.document_kind_not_accepted":"This document type is not accepted. Upload one of the documents listed below","poa.retry.name_mismatch":"The name on the document does not match yours. Upload a document in your name","poa.retry.address_mismatch":"The address on the document does not match the one we were given. Upload a document for that address","poa.retry.holder_letter_missing":"The letter must be signed and name both you and the bill holder. Upload a complete letter","poa.retry.unreadable":"We could not read the document. Upload a sharper, complete copy","poa.retry.pdf_protected":"Remove the password from the PDF and try again","poa.retry.provider_unavailable":"The document could not be checked right now. Try again in a moment","poa.hint.blurry":"The image is blurry","poa.hint.cropped":"Part of the document is cut off","poa.hint.glare":"There is glare on the document","reasons.provider_unavailable":"The document could not be checked right now","reasons.pdf_protected":"The PDF is password-protected or contains active content","reasons.document_kind_not_accepted":"The document type is not accepted","reasons.document_date_invalid":"The document date is in the future","reasons.document_too_old":"The document is too old","reasons.document_tampered":"The document appears to have been edited","reasons.holder_letter_required":"A letter from the bill holder is needed","reasons.holder_letter_missing":"The letter from the bill holder is missing or incomplete","reasons.address_mismatch":"The address does not match the one supplied"},ae={"poa.title":"Justificatif de domicile","poa.lead":"Importez un document récent qui indique votre nom et votre adresse actuelle.","poa.accepted":"Documents acceptés","poa.acceptedFor":"Accepté pour {country}","poa.kindDated":"{kind}, daté des {days} derniers jours","poa.kinds.utility_bill":"Facture d'électricité, d'eau ou de gaz","poa.kinds.telecom_bill":"Facture de téléphone ou d'internet","poa.kinds.bank_statement":"Relevé bancaire","poa.kinds.tax_notice":"Avis d'imposition","poa.kinds.rental_agreement":"Bail ou quittance de loyer","poa.kinds.government_certificate":"Certificat de résidence","poa.kinds.insurance_statement":"Attestation d'assurance","poa.source.camera":"Prendre une photo","poa.source.upload":"Importer un fichier","poa.source.lead":"Une photo du document, ou un PDF ou une image depuis votre appareil","poa.upload.hint":"PDF, JPEG ou PNG, 3 pages et 10 Mo au maximum","poa.upload.choose":"Choisir un fichier","poa.upload.addPage":"Ajouter une page","poa.upload.pages":"{count} sur 3 pages","poa.upload.send":"Envoyer le document","poa.upload.sending":"Envoi de votre document…","poa.upload.unsupported":"Ce type de fichier n'est pas accepté. Choisissez un PDF, un JPEG ou un PNG","poa.upload.tooManyPages":"Envoyez 3 pages au maximum. Retirez une page ou choisissez un fichier plus court","poa.upload.tooLarge":"Le fichier dépasse 10 Mo. Choisissez un fichier plus léger","poa.upload.failed":"Nous n'avons pas pu envoyer le document. Vérifiez votre connexion et réessayez","poa.camera.lead":"Posez le document à plat et remplissez le cadre. Prenez une photo par page","poa.camera.capture":"Prendre la photo","poa.camera.retake":"Reprendre","poa.camera.next":"Page suivante","poa.camera.page":"Page {number}","poa.letter.title":"Lettre du titulaire de la facture","poa.letter.lead":"Le document est au nom d'une autre personne. Ajoutez une lettre signée de cette personne attestant que vous habitez à cette adresse","poa.letter.send":"Envoyer la lettre","poa.licence.use":"Utiliser l'adresse de mon permis de conduire","poa.licence.note":"Nous avons lu cette adresse sur votre permis. Vous n'avez pas besoin d'un autre document.","poa.retry.document_too_old":"Ce document est plus ancien que la limite. Importez un document plus récent parmi ceux de la liste ci-dessous","poa.retry.document_date_invalid":"La date du document est dans le futur. Importez un document daté d'aujourd'hui ou d'avant","poa.retry.document_kind_not_accepted":"Ce type de document n'est pas accepté. Importez l'un des documents de la liste ci-dessous","poa.retry.name_mismatch":"Le nom sur le document ne correspond pas au vôtre. Importez un document à votre nom","poa.retry.address_mismatch":"L'adresse du document ne correspond pas à celle qui nous a été transmise. Importez un document pour cette adresse","poa.retry.holder_letter_missing":"La lettre doit être signée et nommer à la fois vous et le titulaire de la facture. Importez une lettre complète","poa.retry.unreadable":"Nous n'avons pas pu lire le document. Importez une copie plus nette et complète","poa.retry.pdf_protected":"Retirez le mot de passe du PDF et réessayez","poa.retry.provider_unavailable":"Le document n'a pas pu être vérifié pour le moment. Réessayez dans un instant","poa.hint.blurry":"L'image est floue","poa.hint.cropped":"Une partie du document est coupée","poa.hint.glare":"Il y a un reflet sur le document","reasons.provider_unavailable":"Le document n'a pas pu être vérifié pour le moment","reasons.pdf_protected":"Le PDF est protégé par un mot de passe ou contient du contenu actif","reasons.document_kind_not_accepted":"Ce type de document n'est pas accepté","reasons.document_date_invalid":"La date du document est dans le futur","reasons.document_too_old":"Le document est trop ancien","reasons.document_tampered":"Le document semble avoir été modifié","reasons.holder_letter_required":"Une lettre du titulaire de la facture est nécessaire","reasons.holder_letter_missing":"La lettre du titulaire de la facture est absente ou incomplète","reasons.address_mismatch":"L'adresse ne correspond pas à celle qui a été transmise"};function B({blob:a,label:n}){let[e,r]=(0,f.useState)(void 0);return(0,f.useEffect)(()=>{if(typeof URL.createObjectURL!="function")return;let d=URL.createObjectURL(a);return r(d),()=>URL.revokeObjectURL(d)},[a]),(0,o.jsx)("img",{src:e,alt:n})}l(B,"Q");p(B,"PageThumb");function $({step:a,i18n:n,c:e,title:r,notice:d,intro:m,onUpload:i}){let y=(0,f.useRef)(null),s=(0,f.useRef)(null),[c,_]=(0,f.useState)([]),[h,P]=(0,f.useState)(!1),[L,C]=(0,f.useState)("idle"),[K,F]=(0,f.useState)(!1),A=p(u=>{P(!1),u.start().catch(()=>P(!0))},"open");(0,f.useEffect)(()=>{let u=y.current;if(u===null)return;let g;try{g=a.capturePage({video:u})}catch{P(!0);return}return s.current=g,A(g),()=>{g.destroy(),s.current=null}},[]);let E=c.length>=a.maxPages,Q=p(async()=>{let u=s.current;if(!(u===null||E)){C("taking"),F(!1);try{await u.takePage()}catch{}_([...u.pages]),C("idle")}},"take"),X=p(u=>{let g=s.current;g!==null&&(g.removePage(u),_([...g.pages]))},"retake"),Z=p(async()=>{let u=s.current;if(!(u===null||c.length===0)){C("sending"),F(!1);try{await u.submitPages()}catch{F(!0)}C("idle")}},"send"),T=L==="sending";return(0,o.jsxs)("section",{className:"sekyro-step","data-testid":"sekyro-poa-camera",children:[(0,o.jsx)(D,{title:r,lead:e("poa.camera.lead")}),d,K?(0,o.jsx)(b,{tone:"danger",children:(0,o.jsx)("span",{children:e("poa.upload.failed")})}):null,h?(0,o.jsxs)(b,{tone:"danger",children:[(0,o.jsx)("span",{children:e("doc.cameraBlocked")}),(0,o.jsx)("span",{children:e("doc.cameraBlockedHint")}),s.current!==null?(0,o.jsx)(k,{kind:"secondary",onClick:l(()=>s.current!==null&&A(s.current),"onClick"),children:e("doc.retryCamera")}):null]}):null,c.length===0?m:null,(0,o.jsx)("video",{ref:y,className:"sekyro-poa-video",playsInline:!0,muted:!0,autoPlay:!0,"aria-hidden":"true"}),c.length>0?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("p",{className:"sekyro-text-muted",role:"status",children:e("poa.upload.pages",{count:c.length})}),(0,o.jsx)("ul",{className:"sekyro-poa-pages",children:c.map((u,g)=>{let I=e("poa.camera.page",{number:g+1});return(0,o.jsxs)("li",{children:[(0,o.jsx)(B,{blob:u,label:I}),(0,o.jsx)(k,{kind:"ghost",onClick:l(()=>X(g),"onClick"),disabled:T,"aria-label":`${e("poa.camera.retake")} ${I}`,children:e("poa.camera.retake")})]},g)})})]}):null,T?(0,o.jsx)("p",{className:"sekyro-text-muted",role:"status","aria-busy":"true",children:e("poa.upload.sending")}):null,(0,o.jsxs)(R,{children:[(0,o.jsxs)(k,{full:!0,kind:c.length>0?"secondary":"primary",onClick:l(()=>{Q()},"onClick"),disabled:E||h||L!=="idle"||a.attemptsExhausted,"aria-busy":L==="taking"||void 0,children:[(0,o.jsx)(N,{name:"camera"}),e("poa.camera.capture")]}),c.length>0?(0,o.jsx)(k,{full:!0,onClick:l(()=>{Z()},"onClick"),disabled:L!=="idle","aria-busy":T||void 0,children:e("poa.upload.send")}):null,i!==void 0?(0,o.jsx)(k,{full:!0,kind:"ghost",onClick:i,disabled:T,children:e("poa.source.upload")}):null]})]})}l($,"J");p($,"PageCamera");var te={en:U,fr:ae,ar:ee,es:U,pt:U,de:U},oe="image/jpeg,image/png,image/heic,image/heif,application/pdf";function V(a){let n=a.strings,e=te[a.locale];return(r,d)=>q(n[r]??e[r]??"",d)}l(V,"ae");p(V,"poaCopy");function z({step:a,i18n:n,c:e}){if(a.reason===void 0)return null;let r=e(`poa.retry.${a.reason}`)||e(`reasons.${a.reason}`)||e("poa.retry.unreadable");return(0,t.jsxs)(b,{tone:"warning",children:[(0,t.jsx)("span",{children:r}),(0,t.jsx)("span",{children:G(n,a.attemptsRemaining,a.attemptsExhausted)})]})}l(z,"U");p(z,"RetryNotice");function w({step:a,i18n:n,c:e}){let r=(0,v.useId)(),{country:d}=a.rule,m=d===null?e("poa.accepted"):e("poa.acceptedFor",{country:J(d,n.locale)});return(0,t.jsxs)("div",{className:"sekyro-poa-accepted",children:[(0,t.jsx)("p",{id:r,className:"sekyro-poa-accepted__title",children:m}),(0,t.jsx)("ul",{className:"sekyro-poa-list","aria-labelledby":r,children:a.rule.kinds.map(i=>(0,t.jsx)("li",{children:e("poa.kindDated",{kind:e(`poa.kinds.${i.kind}`)||i.kind,days:i.maxAgeDays})},i.kind))})]})}l(w,"j");p(w,"AcceptedList");var re={unsupported:"poa.upload.unsupported",tooMany:"poa.upload.tooManyPages",tooLarge:"poa.upload.tooLarge",failed:"poa.upload.failed"};function W(a){return a instanceof TypeError&&a.message==="unsupported_file"?"unsupported":a instanceof RangeError&&a.message==="file_too_large"?"tooLarge":a instanceof RangeError&&(a.message==="too_many_pages"||a.message==="no_pages")?"tooMany":"failed"}l(W,"re");p(W,"refusalOf");function H({step:a,i18n:n,c:e,letter:r,onCamera:d}){let m=(0,v.useRef)(null),[i,y]=(0,v.useState)("idle"),s=i==="sending",c=p(async _=>{let h=Array.from(_.currentTarget.files??[]);if(_.currentTarget.value="",h.length!==0){if(h.length>a.maxPages){y("tooMany");return}y("sending");try{await(r?a.uploadHolderLetter(h):a.uploadPages(h)),y("idle")}catch(P){y(W(P))}}},"onFiles");return(0,t.jsxs)("section",{className:"sekyro-step","data-testid":r?"sekyro-poa-letter":"sekyro-poa-upload",children:[(0,t.jsx)(D,{title:e(r?"poa.letter.title":"poa.title"),lead:e(r?"poa.letter.lead":"poa.lead")}),i==="idle"||s?(0,t.jsx)(z,{step:a,i18n:n,c:e}):null,i!=="idle"&&!s?(0,t.jsx)(b,{tone:"danger",children:(0,t.jsx)("span",{children:e(re[i])})}):null,r?null:(0,t.jsx)(w,{step:a,i18n:n,c:e}),(0,t.jsx)("p",{className:"sekyro-text-muted",children:e("poa.upload.hint")}),s?(0,t.jsx)("p",{className:"sekyro-text-muted",role:"status","aria-busy":"true",children:e("poa.upload.sending")}):null,(0,t.jsx)("input",{ref:m,type:"file",accept:oe,multiple:!0,hidden:!0,"data-testid":"sekyro-poa-file","aria-label":e(r?"poa.letter.title":"poa.title"),onChange:l(_=>{c(_)},"onChange")}),(0,t.jsxs)(R,{children:[(0,t.jsx)(k,{full:!0,onClick:l(()=>m.current?.click(),"onClick"),disabled:s||!a.photo.uploadOffered||a.attemptsExhausted,"aria-busy":s||void 0,children:e("poa.upload.choose")}),d!==void 0?(0,t.jsxs)(k,{full:!0,kind:"ghost",onClick:d,disabled:s,children:[(0,t.jsx)(N,{name:a.photo.cameraOnPhone===!0?"smartphone":"camera"}),a.photo.cameraOnPhone===!0?e("capture.source.phone"):e("poa.source.camera")]}):null]})]})}l(H,"se");p(H,"UploadScreen");function Y({step:a,c:n}){let[e,r]=(0,v.useState)("idle"),d=a.useLicenceAddress;if(d===void 0)return null;let m=p(async()=>{r("sending");try{await d(),r("idle")}catch{r("failed")}},"onUse");return(0,t.jsxs)("div",{className:"sekyro-poa-licence","data-testid":"sekyro-poa-licence",children:[(0,t.jsx)("p",{className:"sekyro-text-muted",children:n("poa.licence.note")}),e==="failed"?(0,t.jsx)(b,{tone:"danger",children:(0,t.jsx)("span",{children:n("poa.upload.failed")})}):null,(0,t.jsx)(k,{full:!0,kind:"secondary",onClick:l(()=>{m()},"onClick"),disabled:e==="sending"||a.attemptsExhausted,"aria-busy":e==="sending"||void 0,children:n("poa.licence.use")})]})}l(Y,"de");p(Y,"LicenceShortcut");function ne({step:a,i18n:n}){let e=V(n),[r,d]=(0,v.useState)(null),m=a.phase==="holder_letter",i=a.photo.source,y=i==="choice"?r??a.photo.pick:i,s=a.photo.cameraOnPhone===!0,c=a.photo.uploadOffered?()=>d("upload"):void 0,_=e(m?"poa.letter.title":"poa.title"),h;return y===null?h=(0,t.jsx)(S,{testId:"sekyro-poa-source",title:_,lead:e("poa.source.lead"),cameraLabel:e(s?"capture.source.phone":"poa.source.camera"),uploadLabel:e("poa.source.upload"),onPhone:s,notice:(0,t.jsx)(z,{step:a,i18n:n,c:e}),onCamera:l(()=>d("camera"),"onCamera"),onUpload:l(()=>d("upload"),"onUpload")}):y==="camera"&&s?h=(0,t.jsx)(M,{i18n:n,lead:e("handoff.lead.poa"),refresh:a.refresh,actions:c!==void 0?(0,t.jsx)(k,{kind:"ghost",full:!0,onClick:c,children:e("poa.source.upload")}):null}):y==="camera"?h=(0,t.jsx)($,{step:a,i18n:n,c:e,title:_,notice:(0,t.jsx)(z,{step:a,i18n:n,c:e}),intro:m?null:(0,t.jsx)(w,{step:a,i18n:n,c:e}),...i==="choice"&&c!==void 0?{onUpload:c}:{}}):h=(0,t.jsx)(H,{step:a,i18n:n,c:e,letter:m,...i==="choice"?{onCamera:p(()=>d("camera"),"onCamera")}:{}}),(0,t.jsxs)(t.Fragment,{children:[m?null:(0,t.jsx)(Y,{step:a,c:e}),h]})}l(ne,"we");p(ne,"ProofOfAddressView");export{oe as POA_UPLOAD_ACCEPT,ne as ProofOfAddressView,V as poaCopy};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sekyro/elements",
|
|
3
|
-
"version": "0.1.0-rc.
|
|
3
|
+
"version": "0.1.0-rc.18",
|
|
4
4
|
"description": "Sekyro AI custom elements: <sekyro-verification> for Vue, Angular, Svelte and plain HTML, the @sekyro/react flow with React bundled inside",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"repository": {
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
"api:check": "api-extractor run"
|
|
95
95
|
},
|
|
96
96
|
"peerDependencies": {
|
|
97
|
-
"@sekyro/web": "^0.1.0-rc.
|
|
97
|
+
"@sekyro/web": "^0.1.0-rc.39 || ^0.2.0-rc.0"
|
|
98
98
|
},
|
|
99
99
|
"devDependencies": {
|
|
100
100
|
"@microsoft/api-extractor": "^7.59.4",
|
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.
|
|
101
|
-
"bom-ref": "@sekyro/elements@0.1.0-rc.
|
|
100
|
+
"version": "0.1.0-rc.18",
|
|
101
|
+
"bom-ref": "@sekyro/elements@0.1.0-rc.18",
|
|
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.
|
|
111
|
+
"purl": "pkg:npm/%40sekyro/elements@0.1.0-rc.18?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.
|
|
150
|
+
"ref": "@sekyro/elements@0.1.0-rc.18"
|
|
151
151
|
}
|
|
152
152
|
]
|
|
153
153
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as o}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 _(h,t){let e=h.lineBoxes;if(e.length===0)return{lineCount:0,detected:!1,fill:0,offsetX:0,offsetY:0,centers:[]};let l=Math.min(...e.map(s=>s[0])),i=Math.max(...e.map(s=>s[0]+s[2])),a=Math.min(...e.map(s=>s[1])),r=Math.max(...e.map(s=>s[1]+s[3]));return{lineCount:e.length,detected:e.length>=t.minLines,fill:i-l,offsetX:(l+i)/2-.5,offsetY:(a+r)/2-.5,centers:e.map(s=>[s[0]+s[2]/2,s[1]+s[3]/2])}}o(_,"M");function P(h,t){if(h.centers.length===0||t.centers.length===0)return Number.POSITIVE_INFINITY;let e=0;for(let[l,i]of t.centers){let a=Number.POSITIVE_INFINITY;for(let[r,s]of h.centers)a=Math.min(a,Math.hypot(l-r,i-s));e+=a}return e/t.centers.length}o(P,"p");var b,O=(b=class{constructor(t=z){this.t=t,this.last=null,this.goodSince=null,this.steadySince=null,this.frames=0}offer(t,e,l={glareOk:!0,sharpOk:!0}){let i=this.t,a=_(t,i),r=this.last;this.last=a;let s=a.fill>=i.fillMin&&a.fill<=i.fillMax,n=Math.abs(a.offsetX)<=i.offsetMax&&Math.abs(a.offsetY)<=i.offsetMax,c=r!==null&&r.detected&&Math.abs(a.lineCount-r.lineCount)<=i.lineCountDelta&&P(r,a)<=i.layoutShiftMax,m=a.detected&&l.glareOk&&l.sharpOk&&s&&c&&r!==null&&Math.abs(a.fill-r.fill)<=i.steadyFillDelta&&Math.abs(a.offsetX-r.offsetX)<=i.steadyOffsetDelta&&Math.abs(a.offsetY-r.offsetY)<=i.steadyOffsetDelta,g=m&&n,u=a.detected?l.glareOk?a.fill<i.fillMin?"closer":a.fill>i.fillMax?"farther":n?l.sharpOk?void 0:"blurry":"center":"glare":void 0;return m?(this.frames++,this.steadySince??(this.steadySince=e),this.goodSince=g?this.goodSince??e:null,(this.goodSince!==null&&e-this.goodSince>=i.lockMs||e-this.steadySince>=i.steadyMs)&&this.frames>=i.minFrames?{state:"locked"}:{state:"locking",...u?{hint:u}:{}}):(this.goodSince=null,this.steadySince=null,this.frames=a.detected?1:0,{state:a.detected?"locking":"searching",...u?{hint:u}:{}})}reset(){this.last=null,this.goodSince=null,this.steadySince=null,this.frames=0}},o(b,"y"),b);function D(h,t){if(!Number.isFinite(h)||h<0)return"low";if(h<=150)return"high";let e=typeof t!="number"||!Number.isFinite(t)||t>3;return h<=400&&e?"mid":"low"}o(D,"S");var N=Object.freeze({low:Object.freeze({stride:1,bandWidthPx:960}),mid:Object.freeze({stride:2,bandWidthPx:1280}),high:Object.freeze({stride:1,bandWidthPx:1280})});function j(h=globalThis){let t=h.navigator?.deviceMemory;return typeof t=="number"&&Number.isFinite(t)&&t>0?t:null}o(j,"O");var C=[[1,0],[0,1],[1,1],[1,-1]];function E(h){let{width:t,height:e,data:l}=h;if(t<16||e<16)return-1;let i=new Uint8Array(t*e);for(let r=0,s=0;r<i.length;r+=1,s+=4)i[r]=Math.round(.299*(l[s]??0)+.587*(l[s+1]??0)+.114*(l[s+2]??0));let a=-1;for(let[r,s]of C){let n=new Uint32Array(256),c=new Float64Array(256),m=0;for(let d=1;d<e-1;d+=1){let f=d*t,F=(d+s)*t,R=(d-s)*t;for(let y=1;y<t-1;y+=1){let I=i[F+y+r]??0,T=i[R+y-r]??0,p=Math.abs(I-T);n[p]=(n[p]??0)+1,c[p]=(c[p]??0)+Math.abs(I+T-2*(i[f+y]??0)),m+=1}}let g=Math.max(1,Math.floor(m/20)),u=0,M=0,k=0;for(let d=255;d>=0&&u<g;d-=1){let f=n[d]??0;u+=f,M+=f*d,k+=c[d]??0}if(M===0)return 0;let S=k/M;a=a<0?S:Math.min(a,S)}return a}o(E,"L");var A=.06;function q(h,t,e,l=A){if(h===null||t.width<=0||t.height<=0)return null;let i=[h.topLeft,h.topRight,h.bottomRight,h.bottomLeft],a=e.width/t.width,r=e.height/t.height,s=Math.min(...i.map(f=>f.x))*a,n=Math.max(...i.map(f=>f.x))*a,c=Math.min(...i.map(f=>f.y))*r,m=Math.max(...i.map(f=>f.y))*r,g=(n-s)*l,u=(m-c)*l,M=Math.max(0,Math.floor(s-g)),k=Math.max(0,Math.floor(c-u)),S=Math.min(e.width,Math.ceil(n+g)),d=Math.min(e.height,Math.ceil(m+u));return S-M<16||d-k<16?null:{x:M,y:k,width:S-M,height:d-k}}o(q,"W");function Z(h,t){let e=t??{x:0,y:0,width:h.width,height:h.height},l=Math.min(1,1e3/Math.max(e.width,e.height)),i=Math.max(1,Math.round(e.width*l)),a=Math.max(1,Math.round(e.height*l)),r=document.createElement("canvas");r.width=i,r.height=a;try{let s=r.getContext("2d",{willReadFrequently:!0});return s===null?-1:(s.imageSmoothingQuality="high",s.drawImage(h,e.x,e.y,e.width,e.height,0,0,i,a),E(s.getImageData(0,0,i,a)))}catch{return-1}finally{r.width=0,r.height=0}}o(Z,"Q");var v,G=(v=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}},o(v,"g"),v),W=Object.freeze({...z,minIntervalMs:150,maxWidthPx:480,detectorLimit:960,searchTimeoutMs:12e3}),L=Object.freeze({detectorLimit:960,bandMaxWidthPx:1280,minBandWidthPx:900,bandTop:.55,minIntervalMs:150,stableReads:2,profileReads:5,maxReadMs:1200,searchTimeoutMs:12e3}),V=o(()=>typeof document>"u"||document.visibilityState!=="hidden","P"),Y=o((h,t,e)=>createImageBitmap(h,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=o((h,t)=>{if(h.length===0)return 0;let e=[...h].sort((l,i)=>l-i);return e[Math.min(e.length-1,Math.floor(e.length*t))]},"x");function Q(h){return h<=250?"fast":h<=600?"mid":"slow"}o(Q,"G");function H(h,t,e){let l=h.y+h.h*t,i=Math.min(e,h.y+h.h*1.05);return{x:h.x,y:l,w:h.w,h:Math.max(1,i-l)}}o(H,"Z");var x,J=(x=class{constructor(t){this.o=t,this.engine=null,this.tier=null,this.gen=0,this.ticksSinceRead=Number.POSITIVE_INFINITY,this.hiddenSince=null,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??Y,this.visible=t.visible??V,this.mrzGate=new G(t.liveMrz?.stableReads??2),this.lockGate=new O(t.textLock??W)}setEngine(t,e){this.engine=t,e!==void 0&&(this.tier=e)}liveCadence(t){let e=this.tier===null?null:N[this.tier];return{stride:e?.stride??1,bandWidthPx:Math.min(t.bandMaxWidthPx,e?.bandWidthPx??t.bandMaxWidthPx)}}get bandTop(){return this.o.liveMrz?.bandTop??L.bandTop}get liveMrzOn(){return this.o.liveMrz!==null}get hasEngine(){return this.engine!==null&&!this.disabled}reset(){this.gen++,this.inFlight=!1,this.lastReadAt=Number.NEGATIVE_INFINITY,this.ticksSinceRead=Number.POSITIVE_INFINITY,this.hiddenSince=null,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.ticksSinceRead=Number.POSITIVE_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!=="off"&&!this.visible()?(this.hiddenSince??(this.hiddenSince=t.atMs),this.mrzGate.reset(),{ready:!1,suspendQuality:e==="live_mrz"&&this.fallback===null,mode:e,...this.states()}):(this.hiddenSince!==null&&(this.firstSeen!==null&&(this.firstSeen+=t.atMs-this.hiddenSince),this.hiddenSince=null),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 l=this.engine;return l!==null&&!this.inFlight&&!l.busy&&t-this.lastReadAt>=e}fall(t){this.fallback=t,this.mrzGate.reset()}liveTick(t,e){let l=o(()=>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"},l();if(this.firstSeen??(this.firstSeen=t.atMs),t.atMs-this.firstSeen>e.searchTimeoutMs)return this.fall("timeout"),l();if(t.band.w<e.minBandWidthPx)return t.card!==null&&t.card.w<e.minBandWidthPx?(this.fall("unsupported"),l()):(this.mrzState={state:"reading",coach:t.portrait?"turnSideways":"moveCloser"},{ready:!1,suspendQuality:!1,mode:"live_mrz",mrz:this.mrzState});let i=this.liveCadence(e);if(this.ticksSinceRead++,this.ticksSinceRead<i.stride||!this.canRead(t.atMs,e.minIntervalMs))return l();this.inFlight=!0,this.lastReadAt=t.atMs,this.ticksSinceRead=0;let a=this.gen,r=this.engine,s=t.glareOk?t.sharpOk?void 0:"holdStill":"glare";return this.crop(t.video,t.band,i.bandWidthPx).then(n=>r.bandRead(n,e.detectorLimit)).then(n=>{if(a===this.gen){if(this.reads++,this.times.push(n.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(n.valid?n.digest??null:null)&&n.format&&n.digest){this.valid={format:n.format,...n.documentCode!==void 0?{documentCode:n.documentCode}:{},digest:n.digest,lineCount:n.lineCount,framesToValid:this.reads,msToValid:Math.round(t.atMs-(this.firstSeen??t.atMs))},this.mrzState={state:"valid",format:n.format},this.fired={via:"live_mrz",at:t.atMs};return}this.mrzState={state:"reading",...s?{coach:s}:{},...n.format?{format:n.format}:{}}}}).catch(()=>{a===this.gen&&this.fall("error")}).finally(()=>{a===this.gen&&(this.inFlight=!1)}),l()}lockTick(t,e){let l=o(()=>({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"},l();if(this.firstSeen??(this.firstSeen=t.atMs),t.atMs-this.firstSeen>e.searchTimeoutMs)return this.lockOff=!0,l();if(!this.canRead(t.atMs,e.minIntervalMs))return l();this.inFlight=!0,this.lastReadAt=t.atMs;let i=this.gen,a=this.engine,r={glareOk:t.glareOk,sharpOk:t.sharpOk};return this.crop(t.video,t.card,e.maxWidthPx).then(s=>a.layoutRead(s,e.detectorLimit)).then(s=>{if(i!==this.gen)return;this.reads++,this.times.push(s.ms),this.times.length>8&&this.times.shift();let n=this.lockGate.offer(s,t.atMs,r);this.lockState=n.state==="locked"?{state:"locked"}:{state:n.state,...n.hint?{hint:n.hint}:{}},n.state==="locked"&&(this.fired={via:"text_lock",at:t.atMs})}).catch(()=>{i===this.gen&&(this.lockOff=!0,this.lockError=!0)}).finally(()=>{i===this.gen&&(this.inFlight=!1)}),l()}disable(){this.disabled=!0,this.reset()}report(t,e,l){let i=this.faceMode;if(i==="off")return null;let a=w(this.times,.5),r={capture:t,mode:i,reads:this.reads,...this.times.length>0?{readP50Ms:Math.round(a),readP90Ms:Math.round(w(this.times,.9)),deviceClass:Q(a)}:{}};return i==="live_mrz"?this.fired?.via==="live_mrz"&&this.valid!==null&&e==="live_mrz"?{...r,outcome:"valid",format:this.valid.format,framesToValid:this.valid.framesToValid,msToValid:this.valid.msToValid}:this.fallback!==null?{...r,outcome:this.fallback}:{...r,outcome:l-(this.firstSeen??l)>=(this.o.liveMrz?.searchTimeoutMs??1/0)?"timeout":"off"}:this.fired?.via==="text_lock"?{...r,outcome:"locked",framesToLock:Math.max(1,this.reads),msToLock:Math.round(this.fired.at-(this.firstSeen??this.fired.at))}:{...r,outcome:this.lockError?"error":this.lockOff?"timeout":"off"}}},o(x,"w"),x);export{D as a,j as b,q as c,Z as d,W as e,L as f,H as g,J as h};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as ke,b as Se,c as ie,d as xe,e as Te,f as Ce,h as Ae}from"./chunk-3NOBU7TE.js";import{a as ne,d as Le,e as Re}from"./chunk-QWPURAKS.js";import{e as Q}from"./chunk-H5T4U7DM.js";import{e as Me,k as be}from"./chunk-6MYG4HWP.js";import{g as ae}from"./chunk-JS2IXPNL.js";import{a as n}from"./chunk-4FHWXBOB.js";function Pe(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(Pe,"Ee");function Xe(e){let t=Le.find(i=>i.docType===e),r=t.mrz==="none"?null:t.mrz==="td3"?"single":"verso";return{sides:t.sides,format:Re(e),mrz:t.mrz==="none"?"none":"required",mrzSide:r,barcodeSide:null,portraitSide:t.portraitSide,scripts:null}}n(Xe,"st");function Ye(e){let t=[];for(let r of e)for(let i of r.sides){if(!Array.isArray(i.scripts))return null;for(let l of i.scripts)t.includes(l)||t.push(l)}return t}n(Ye,"ct");function Je(e,t){if(t.length===0)return Xe(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:Pe(t,"mrz"),barcodeSide:Pe(t,"barcode"),portraitSide:d??(r?"recto":"single"),scripts:Ye(t)}}n(Je,"Oe");function Qe(e,t){if(e===void 0)return[];let r=e.toUpperCase();return Object.prototype.hasOwnProperty.call(ne,r)?ne[r]?.[t]??[]:[]}n(Qe,"Ae");async function $e(e,t,r){return await e(t)?r:r==="recto"?"verso":"recto"}n($e,"Be");function Ze(e,t,r){return e!==t&&t==="verso"&&r.recto!==void 0&&r.verso===void 0?"verso":e}n(Ze,"Ie");var Ke={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 et(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,k;d||s?k="low":h&&c?k="good":k="mid";let f=Ke[k],P=u&&u>0?Math.min(f.maxLongEdge,u):f.maxLongEdge;return{tier:k,...f,maxLongEdge:P}}n(et,"lt");function tt(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),et(t)}n(tt,"Fe");function rt(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(rt,"dt");function at(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(at,"mt");async function it(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(it,"pt");async function nt(e,t,r,i,l){if(t<=0||r<=0)return null;let{width:u,height:d}=at(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(T=>new Promise((y,m)=>{s.toBlob(g=>g?y(g):m(new Error("canvas toBlob returned null")),"image/jpeg",T)}),"l"),k=rt(l,i.qMin,i.qMax),{blob:f,quality:P}=await it(c,{startQ:k,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(nt,"We");async function ot(e){let t=tt(Math.max(e.width,e.height)),r=await nt(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(ot,"oe");function We(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(We,"ie");var Ie=n(e=>e==="recto"?"verso":"recto","Ue"),Be=n(e=>e.phase==="framing"||e.phase==="locking"||e.phase==="flipCue"||e.phase==="reaskRecto","Ne"),ue=n(e=>(e.captured.recto!==void 0?1:0)+(e.captured.verso!==void 0?1:0)+e.pending.length,"se");function oe(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(oe,"ae");function lt(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(!Be(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(lt,"ft");function st(e,t){if(!Be(e)||e.manualShutter)return e;let r=t-e.lastReportAt>=2e3,i=t-e.lastCaptureAt>=6e3;return r||i?{...e,manualShutter:!0}:e}n(st,"gt");function dt(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||ue({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(dt,"ht");function Ue(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:Ie(r),needFlip:!0,flipTimeoutSpent:!0,goodSince:void 0,manualShutter:!0,notice:"same_face",lastCaptureAt:-1,lastReportAt:-1}:e}n(Ue,"Ge");function ut(e,t,r){if(!e.pending.includes(t))return e;if(e.captured[r]!==void 0)return Ue(e,t,r);let i=e.pending.filter(h=>h!==t),l={...e,pending:i,captured:{...e.captured,[r]:t}};if(ue(l)!==1||e.layout==="singlePage")return l;let u=Ie(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(ut,"bt");function ct(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"&&ue({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(ct,"yt");function pt(e,t){switch(t.type){case"report":return lt(oe(e,t.at),t.report,t.at);case"tick":return st(oe(e,t.at),t.at);case"captured":return dt(oe(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 ut(e,t.id,t.side);case"duplicate":return Ue(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 ct(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{...We(e.layout,-1),lastCaptureAt:-1,lastReportAt:-1};default:return e}}n(pt,"qe");function mt(e,t,r=!1){let i=e(t);return i===null?"recto":!r||i.y+i.height/2>=t.height/2?"verso":"recto"}n(mt,"St");async function ht(e,t=!1){let{detectMrzBand:r}=await import("./mrz-band-VYHOTDHY-VEZ2J5IL.js");return mt(r,e,t)}n(ht,"Mt");async function ze(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 ht(s.getImageData(0,0,t,u),i))}finally{d.width=0,d.height=0}}n(ze,"ce");var le=n((e,t,r)=>Math.min(r,Math.max(t,Math.round(e))),"ue"),$=n(e=>Math.round(Math.min(1,Math.max(0,e))*1e4)/1e4,"$");async function ft(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),"u"),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:le(r.lineCount,2,3),checkDigitsValid:!0,stillConfirmed:d.valid&&d.digest===r.digest,band:[$(s[0]),$(s[1]),$(Math.min(s[2],1-s[0])),$(Math.min(s[3],1-s[1]))],digest:r.digest,framesToValid:le(r.framesToValid,1,1e3),msToValid:le(r.msToValid,0,12e4)}}n(ft,"He");var gt=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]),vt=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 yt(e=globalThis){let t=e.WebAssembly?.validate;if(typeof t!="function")return{ok:!1,reason:"simd"};try{if(!t.call(e.WebAssembly,gt)||!t.call(e.WebAssembly,vt))return{ok:!1,reason:"simd"}}catch{return{ok:!1,reason:"simd"}}return typeof e.Worker!="function"?{ok:!1,reason:"worker"}:typeof e.createImageBitmap!="function"?{ok:!1,reason:"bitmap"}:{ok:!0}}n(yt,"Xe");function wt(e=globalThis){let t=e.navigator?.connection;return t?.saveData===!0||["slow-2g","2g","3g"].includes(t?.effectiveType??"")}n(wt,"Ye");var j,E=(j=class extends Error{constructor(t){super(t),this.name="OcrEngineError",this.code=t}},n(j,"E"),j);function De(){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(De,"Ve");function Mt(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 De()}catch{return De()}let r=new Map,i=0,l=!1,u=!1,d=!1;t.addEventListener("message",m=>{let g=m.data,b=r.get(g.id);b&&(r.delete(g.id),b.resolve(g))});let s=n(()=>{for(let m of r.values())m.reject(new E("error"));r.clear(),c()},"s");t.addEventListener("error",s),t.addEventListener("messageerror",s);function h(m,g=[]){if(l)return Promise.reject(new E("disposed"));let b=++i;return new Promise((D,W)=>{r.set(b,{resolve:D,reject:W});try{t.postMessage({...m,id:b},g)}catch{r.delete(b),W(new E("error"))}})}n(h,"p");function c(){if(!l){l=!0;try{t.postMessage({id:++i,kind:"dispose"})}catch{}t.terminate();for(let m of r.values())m.reject(new E("disposed"));r.clear()}}n(c,"l");let k=(async()=>{let m=await h({kind:"init",baseUrl:e.baseUrl,salt:e.salt,detectorLimit:e.tuning.detectorLimit,maxDownloadMs:e.tuning.maxDownloadMs});if(m.kind==="failed")return m.reason;if(m.kind!=="ready")return"error";let g=await h({kind:"warmup"});if(g.kind!=="ready")return"error";let b=g.benchMs??g.warmupMs,D=e.deviceMemoryGb===void 0?Se():e.deviceMemoryGb;return{warmupMs:g.warmupMs,downloadMs:m.downloadMs,cached:m.cached,benchMs:b,tier:ke(b,D)}})().catch(()=>"error"),f,P=new Promise(m=>{f=setTimeout(()=>m("timeout"),e.tuning.loadTimeoutMs)}),T=Promise.race([k,P]).then(m=>(clearTimeout(f),typeof m=="string"?c():d=!0,l&&typeof m!="string"?"error":m));(e.page===void 0?globalThis.addEventListener?globalThis:null:e.page)?.addEventListener("pagehide",c,{once:!0});async function y(m,g,b){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 D;try{let W=new Promise((U,O)=>{D=setTimeout(()=>{O(new E("timeout")),c()},e.tuning.readTimeoutMs??1e4)}),q=await Promise.race([h(m,[g]),W]);if(q.kind===b){let{id:U,...O}=q;return O}throw new E(q.kind==="error"?q.code:q.kind==="failed"?q.reason:"error")}finally{clearTimeout(D),u=!1}}return n(y,"P"),{ready:T,get busy(){return u},bandRead:n((m,g=e.tuning.detectorLimit)=>y({kind:"band",bitmap:m,detectorLimit:g},m,"band"),"bandRead"),stillRead:n((m,g,b=e.tuning.detectorLimit)=>y({kind:"still",bitmap:m,region:g,detectorLimit:b},m,"band"),"stillRead"),layoutRead:n((m,g)=>y({kind:"layout",bitmap:m,detectorLimit:g},m,"layout"),"layoutRead"),dispose:c}}n(Mt,"Qe");var Z="sekyro-ocr-1",se=n(e=>e!==null&&typeof e=="object"?e:{},"le"),z=n((e,t,r,i)=>typeof e=="number"&&Number.isFinite(e)&&e>=t&&e<=r?e:i,"_"),qe=n((e,t)=>typeof e=="boolean"?e:t,"Ke"),Ee=n(e=>{let t=typeof e=="string"?/^sekyro-ocr-(\d{1,4})$/.exec(e):null;return t?Number(t[1]):Number.POSITIVE_INFINITY},"je");function bt(e,t={}){let r=se(e),i=se(r.liveMrz),l=se(r.frontLock),u=Ee(t.engine??Z),d=t.mode==="off",s=n(g=>g.enabled===!0?g.arm==="live"?"live":"control":null,"s"),h=s(i),c=s(l),k=n((g,b)=>!d&&b==="live"&&Ee(g.minEngine??Z)<=u,"M"),f=Ce,P=k(i,h)?{detectorLimit:z(i.detectorLimit,320,1600,f.detectorLimit),bandMaxWidthPx:z(i.bandMaxWidthPx,320,4096,f.bandMaxWidthPx),minBandWidthPx:z(i.minBandWidthPx,0,4096,f.minBandWidthPx),bandTop:z(i.bandTop,0,.95,f.bandTop),minIntervalMs:z(i.minIntervalMs,0,5e3,f.minIntervalMs),stableReads:Math.round(z(i.stableReads,1,10,f.stableReads)),profileReads:Math.round(z(i.profileReads,1,100,f.profileReads)),maxReadMs:z(i.maxReadMs,50,6e4,f.maxReadMs),searchTimeoutMs:z(i.searchTimeoutMs,1e3,12e4,f.searchTimeoutMs),hint:qe(i.hint,!0),stillConfirm:qe(i.stillConfirm,!0)}:null,T=Te,y=n((g,b,D)=>z(l[g],b,D,T[g]),"S"),m=k(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||m!==null,liveMrz:P,textLock:m,liveMrzArm:h,frontLockArm:c,load:{detectorLimit:P?.detectorLimit??m?.detectorLimit??f.detectorLimit,loadTimeoutMs:z(i.loadTimeoutMs,1e3,12e4,2e4),maxDownloadMs:z(i.maxDownloadMs,1e3,12e4,2e4)},reportSampleRate:z(i.reportSampleRate,0,1,1)}}n(bt,"$e");function kt(e,t){return e.enabled?!(t.probe??yt)().ok||(t.slow??wt)()?{ok:!1,reason:"unsupported"}:{ok:!0,engine:Mt({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}:{},...t.deviceMemoryGb!==void 0?{deviceMemoryGb:t.deviceMemoryGb}:{}})}:{ok:!1,reason:"off"}}n(kt,"Je");function St(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(St,"kt");var F=n(e=>e===void 0||!Number.isFinite(e)?void 0:Math.min(6e5,Math.max(0,Math.round(e))),"I"),de=n((e,t,r)=>e===void 0||!Number.isFinite(e)?void 0:Math.min(r,Math.max(t,Math.round(e))),"de");function xt(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??Z,arm:e.arm,capture:e.capture,outcome:l,reads:de(t?.reads??0,0,1e4)??0,browser:e.browser??St()},d=n((s,h)=>{h!==void 0&&(u[s]=h)},"c");return d("format",t?.format),d("framesToValid",de(t?.framesToValid,1,1e4)),d("msToValid",F(t?.msToValid)),d("framesToLock",de(t?.framesToLock,1,1e4)),d("msToLock",F(t?.msToLock)),d("msToCapture",F(e.msToCapture)),d("readP50Ms",F(t?.readP50Ms)),d("readP90Ms",F(t?.readP90Ms)),d("deviceClass",t?.deviceClass),r!==null&&(d("warmupMs",F(r.warmupMs)),d("downloadMs",F(r.downloadMs)),d("cached",r.cached),d("tier",r.tier),d("benchMs",F(r.benchMs))),d("stillConfirmed",e.stillConfirmed),d("typeMismatch",e.typeMismatch),u}n(xt,"Ze");function Fe(e,t){return e===void 0?!1:t==="passport"?e!=="TD3":e==="TD3"}n(Fe,"me");var Tt=2;async function Ct(e){let t=await import("./capture-session-doc-LKMMJG4H-GQNWHWDA.js");return new t.CaptureSessionDoc(e)}n(Ct,"xt");function At(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(At,"vt");function Lt(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(Lt,"Rt");function Wt(){import("./capture-session-doc-LKMMJG4H-GQNWHWDA.js").then(e=>e.warmDocDetector()).catch(()=>{})}n(Wt,"hn");function It(e){return Rt(e,{}).handle}n(It,"bn");function Rt(e,t){let r=Me(),i=be({enabled:e.keepScreenAwake!==!1}),l=t.decode??(a=>createImageBitmap(a)),u=t.blurRefuseSharpnessMax??.16,d=t.now??(()=>performance.now()),s=Je(e.documentType,t.catalogCapture===!0?t.captureSeries??Qe(e.issuer,e.documentType):[]),h=s.sides.length===1||e.side==="single",c=We(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 k="idle",f=null,P=null,T=!0,y=0,m=0,g=!1,b=!1,D="",W=null,q,U=null,O=[],ce=s.mrz==="none",Oe=s.barcodeSide==="recto"||s.barcodeSide==="verso"?s.barcodeSide:null,I=ce&&!h?t.barcode?.side??Oe:null,pe=e.barcodeAssetBaseUrl??t.barcode?.assetBaseUrl,K=null,me=n(()=>I===null||pe===void 0||t.barcode?.seen!==void 0?Promise.resolve(null):(K??(K=import("./barcode-detect-C5IOXMKI-ZOZ2WOWU.js").then(a=>a.loadBarcodeDetect(pe)).catch(()=>null)),K),"ge"),Ne=n(async(a,o)=>{if(I===null)return null;let p=I==="recto"?"verso":"recto";try{let v=t.barcode?.seen;if(v!==void 0)return await v(a)?I:p;let[A,S]=await Promise.all([me(),o()]);if(A===null||S===null)return null;let x=Math.min(1600,S.width),M=document.createElement("canvas");M.width=x,M.height=Math.max(1,Math.round(S.height/S.width*x));try{let w=M.getContext("2d");return w===null?null:(w.drawImage(S,0,0,M.width,M.height),await $e(A,w.getImageData(0,0,M.width,M.height),I))}finally{M.width=0,M.height=0}}catch{return null}},"tt"),C=t.webOcr!==void 0&&!ce?bt(t.webOcr.captureDocument,{mode:e.liveMrz?.mode??"auto"}):null,G=null,N=C===null||!C.enabled?"off":null,_=null,X=null,he=new WeakMap,ee="";if(C!==null&&C.enabled&&t.webOcr!==void 0){let a=t.webOcr,o=kt(C,{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){G=o.engine;let p=new Ae({textLock:C.textLock,liveMrz:C.liveMrz});_=p;let v=o.engine;v.ready.then(A=>{N=A,typeof A!="string"&&T&&p.setEngine(v,A.tier)})}else N=o.reason}let V=n(a=>{let o=JSON.stringify(a);o!==ee&&(ee=o,r.emit("mrz",a))},"N"),fe=n((a,o)=>{let p=t.webOcr?.reports;if(p===void 0||C===null||a===void 0)return;let v=a.format==="ID-3"||a.side==="single"?"single":a.side==="verso"?"verso":"recto",A=v!=="recto"?C.liveMrzArm??C.frontLockArm:C.frontLockArm;if(A===null||Math.random()>=C.reportSampleRate)return;let S=a.via==="live_mrz"?X:null,x=n(()=>{let M=S?.value??null;p([xt({arm:A,capture:v,assist:a.ocr??null,load:A==="control"?"off":N,...a.msToCapture!==void 0?{msToCapture:a.msToCapture}:{},...M!==null&&M.stillConfirmed!==void 0?{stillConfirmed:M.stillConfirmed}:{},...o!==void 0?{typeMismatch:Fe(o.format,s.format==="ID-3"?"passport":"card")}:{}})])},"k");S!==null&&S.value===null?Promise.race([S.promise,new Promise(M=>setTimeout(M,3e3))]).then(x):x()},"be"),B=n(a=>{!T||a===k||(k=a,i.setActive(a==="starting"||a==="scanning"),r.emit("state",a))},"W"),Ve=n((a,o)=>o===void 0?null:h?"single":a.captured.recto===o?"recto":a.captured.verso===o?"verso":null,"nt"),je=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:Ve(a,a.lastShot),manualShutter:a.manualShutter,torchAvailable:f?.torchAvailable()??!1,torch:b}),"rt"),ge=n(()=>{let a=f;a!==null&&a.captureNow().catch(()=>R({type:"captureFailed",at:d()}))},"ye");function R(a){if(!T)return;let o=c;c=pt(c,a),c.phase==="capturing"&&o.phase!=="capturing"&&Promise.resolve().then(ge),c.phase==="result"&&o.phase!=="result"&&(B("done"),ve());let p=je(c),v=JSON.stringify(p);v!==D&&(D=v,r.emit("scan",p))}n(R,"L");function ve(){U!==null&&clearInterval(U),U=null;for(let a of O.splice(0))a();f?.destroy(),f=null,i.setActive(!1)}n(ve,"Se");let ye=n(()=>f?.captureReport?.(),"Me"),te=!1,we=n((a,o)=>{if(!(a===void 0||t.onFaceReport===void 0))try{t.onFaceReport(a,o)}catch{}},"De"),Y=n(a=>{ee="",!(f===null||c.phase==="reading"||c.phase==="result")&&(te=!1,f.rearm(h?"single":c.current??a))},"Q"),Ge=n(async(a,o,p,v)=>{if(X=null,v!==void 0&&G!==null&&C?.liveMrz?.hint===!0){let w={promise:ft(G,a,v,{engine:Z,detectorLimit:C.liveMrz.detectorLimit}).catch(()=>null),value:null};w.promise.then(L=>{w.value=L}),X=w}v!==void 0&&Fe(v.format,s.format==="ID-3"?"passport":"card")&&V({state:"mismatch",format:v.format});let A=ye();we(A,"captured"),te=!0,fe(A,v);let S=p===void 0?W:p===null?null:{quad:At(p),frameWidth:0,frameHeight:0,inStill:!0},x={decoded:null},M=n(()=>(x.decoded??(x.decoded=Promise.resolve().then(()=>l(a)).catch(()=>null)),x.decoded),"y");try{await He(a,o,S,M,X)}finally{x.decoded!==null&&(await x.decoded)?.close()}},"ot"),He=n(async(a,o,p,v,A)=>{let S=`shot-${y+=1}`;if(R({type:"captured",id:S,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,p):v().then(L=>L===null?-1:xe(L,ie(p?.quad??null,p?.inStill===!0?L:{width:p?.frameWidth??0,height:p?.frameHeight??0},L)))).catch(()=>-1);if(!T)return;if(Number.isFinite(w)&&w>=0&&w<u){g=!0;let L=h?"recto":c.current??(c.captured.recto===void 0?"recto":"verso");R({type:"readFailed",side:L,id:S,issue:"blurry"}),Y(L);return}}g=!1;let x;if(h)x="single";else{let w=c.current,L=t.classify===void 0?await Ne(a,v):null,H=(L===null||I===null?L:Ze(L,I,c.captured))??await(t.classify!==void 0?t.classify(a):v().then(J=>J===null?w??"recto":p?.inStill===!0?ze(J,480,null,!0):ze(J,480,ie(p?.quad??null,{width:p?.frameWidth??0,height:p?.frameHeight??0},J)))).catch(()=>w??"recto");if(!T)return;if(c.captured[H]!==void 0&&m<Tt){m+=1,R({type:"duplicate",id:S,side:H}),Y(H==="recto"?"verso":"recto");return}x=c.captured[H]!==void 0&&w!==void 0?w:H,m=0,R({type:"classified",id:S,side:x})}let M=x==="verso"?"verso":"recto";try{let w=t.encode!==void 0?await t.encode(a):await v().then(L=>{if(L===null)throw new Error("the still could not be decoded");return ot(L)});if(!T)return;A!==null&&he.set(w.blob,A),r.emit("captured",{image:w.blob,side:x,documentType:e.documentType,...e.issuer!==void 0?{issuer:e.issuer}:{},width:w.width,height:w.height,previewDataUrl:o}),t.deferRead!==!0&&R({type:"readOk",side:M})}catch(w){R({type:"readFailed",side:M,id:S,issue:"technical"}),r.emit("error",Q("generic",!0,{phase:"keyframes",name:ae(w)}))}Y(M==="recto"?"verso":"recto")},"at"),_e=n(a=>{O.push(a.on("statechange",({state:o})=>{o==="preflight"||o==="acquiring"?B("starting"):o==="positioning"?B("scanning"):o==="captured"?B("captured"):o==="error"&&B("error")}),a.on("feedback",({key:o,reticle:p})=>r.emit("feedback",{key:o,reticle:p})),a.on("checks",o=>{r.emit("gate",{progress:o.p,quad:o.quad,frameWidth:o.frameWidth,frameHeight:o.frameHeight,...o.guide!==void 0?{guide:{detected:o.guide.detected,fill:o.guide.fill,offsetX:o.guide.offsetX??0,offsetY:o.guide.offsetY??0}}:{}});let p=o.ocr?.mrz;p!==void 0&&(p.state==="fallback"?V({state:"fallback",reason:p.reason}):p.state==="valid"?V({state:"valid",format:p.format}):p.state==="reading"?V({state:"reading",...p.format?{format:p.format}:{},...p.coach?{coach:p.coach}:{}}):V({state:"searching"}));let v=o.quad===null?0:Lt(o.quad,o.frameWidth,o.frameHeight);W=o.quad===null?null:{quad:o.quad,frameWidth:o.frameWidth,frameHeight:o.frameHeight},R({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:p,detail:v})=>r.emit("error",Q(o,p,v))),a.on("artifacts",o=>{Ge(o.keyframe,o.previewDataUrl,o.docRegion,o.liveMrz)}))},"it"),re=n(()=>(P??(P=(async()=>{if(T){if(me(),f===null){let a;try{a=await(t.createEngine??Ct)({...t.engineOptions??{},...q!==void 0?{guide:q}:{},video:e.video,format:s.format,side:h?"single":e.side??"recto",autoCapture:!1,..._!==null?{ocr:_}:{}})}catch(p){B("error"),r.emit("error",Q("models",!0,{phase:"models",name:ae(p)}));return}if(!T){a.destroy();return}f=a,_e(a);let o=t.tickMs??500;o>0&&(U=setInterval(()=>R({type:"tick",at:d()}),o))}R({type:"clockRestart"}),C!==null&&C.liveMrzArm==="live"&&(N==="unsupported"||N==="off")&&V({state:"fallback",reason:N}),await f.start()}})().finally(()=>{P=null})),P),"ee");return{handle:{get state(){return k},on:n((a,o)=>r.on(a,o),"on"),start:re,retry:n(()=>{if(f===null&&c.phase==="result"){R({type:"retake"}),m=0,g=!1,re();return}if(f!==null&&k!=="error"){R({type:"retake"}),m=0,g=!1,f.rearm(h?"single":void 0);return}re()},"retry"),setSide:n(a=>{h||a==="single"||(c.current!==a&&(c={...c,current:a}),R({type:"clockRestart"}),c.phase!=="reading"&&c.phase!=="result"&&f?.rearm(a))},"setSide"),shutter:ge,focusAt:n((a,o)=>{f?.focusAt?.(a,o)},"focusAt"),setGuide:n(a=>{q=a,f?.setGuide?.(a)},"setGuide"),setTorch:n(a=>{b=a,f?.setTorch(a),R({type:"tick",at:d()})},"setTorch"),destroy:n(()=>{if(T&&f!==null&&k!=="done"){let a=ye();!te&&a!==void 0&&a.ticks>0&&we(a,"abandoned"),fe(a,void 0)}T=!1,ve(),_?.setEngine(null),G?.dispose(),G=null,r.clear()},"destroy")},plan:s,setFlowState:n(a=>{(c.phase==="reading"||c.phase==="result")&&B(a==="done"&&c.phase!=="result"?"scanning":a)},"setFlowState"),settle:n((a,o)=>{let p=a==="verso"?"verso":"recto";R(o.ok?{type:"readOk",side:p}:{type:"readFailed",side:p,issue:o.issue}),o.ok||Y(p)},"settle"),takeDeviceRead:n(a=>he.get(a.image)?.value??null,"takeDeviceRead")}}n(Rt,"Pt");export{Tt as a,Wt as b,It as c,Rt as d};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as tt,b as te,c as ee,d as dt,e as ie}from"./chunk-Z25MPNSU.js";import{c as Kt,d as Yt,g as Vt}from"./chunk-3NOBU7TE.js";import{b as Jt,c as Zt}from"./chunk-QWPURAKS.js";import{b as $t}from"./chunk-L22GFJQV.js";import{d as Nt,e as Qt,f as Xt}from"./chunk-HOSTJBJM.js";import{a as ct,b as ut,c as Y,d as Ut}from"./chunk-P7K7ELYZ.js";import{g as qt,i as Gt,j as jt,k as Bt,l as Ht}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 ze(i){return i.framing==="no_document"?"sensing":i.framing==="too_far"?"too_far":i.framing==="too_close"?"too_close":i.framing==="edge_clipped"?"edge_clipped":i.framing==="wrong_shape"?"wrong_shape":i.framing==="tilted"?"tilted":i.lighting==="too_dark"?"too_dark":i.lighting==="too_bright"?"too_bright":i.glare==="glare"?"glare":i.blur==="blurry"?"blurry":"hold_still"}n(ze,"se");var G,Ce=(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 s=new Map;for(let o of this.votes){let l=(e-o.atMs)/1e3,r=this.decayPerSecond**l;s.set(o.key,(s.get(o.key)??0)+r)}let a=this.current.key,h=-1;for(let[o,l]of s)l>h&&(h=l,a=o);return a!==this.current.key&&(this.current=et[a],this.currentSinceMs=e),this.current}},n(G,"ot"),G),Ie=Object.freeze({MAX_AREA_FRAC:.92,TILT_MAX_SIDE_RATIO:1.3,GLARE_MAX_SPECULAR_FRAC:.025});function Le(i){let{data:t,width:e,height:s}=i,a=e*s;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(Le,"ae");function Oe(i){let t=n((r,c)=>Math.hypot(c.x-r.x,c.y-r.y),"t"),e=t(i.topLeft,i.topRight),s=t(i.bottomLeft,i.bottomRight),a=t(i.topLeft,i.bottomLeft),h=t(i.topRight,i.bottomRight),o=Math.max(e,s)/Math.max(1e-6,Math.min(e,s)),l=Math.max(a,h)/Math.max(1e-6,Math.min(a,h));return Math.max(o,l)}n(Oe,"Ye");function Ee(i){let t={...te,...i.thresholds},e=Ie,{quad:s,frameWidth:a,frameHeight:h,measures:o}=i,l=i.format==="ID-3",r="ok";if(s===null)r="no_document";else if(l){let d=dt(s),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":se(s,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=ee(s,a,h),m=dt(s),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":se(s,a,h,t.EDGE_CLIP_MARGIN_PX)?r="edge_clipped":Zt(i.format,g)?Oe(s)>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(Ee,"ce");function se(i,t,e,s){return[i.topLeft,i.topRight,i.bottomRight,i.bottomLeft].some(a=>a.x<=s||a.y<=s||a.x>=t-s||a.y>=e-s)}n(se,"re");var Pe=Object.freeze({width:1920,height:1080}),We=Object.freeze({width:3840,height:2160}),ae=4096,Ne=2560,qe=640,it=.15,V=Object.freeze({side:.2,above:.9,below:.3});function C(i){let t=[i.topLeft.x,i.topRight.x,i.bottomRight.x,i.bottomLeft.x],e=[i.topLeft.y,i.topRight.y,i.bottomRight.y,i.bottomLeft.y],s=Math.min(...t),a=Math.min(...e);return{x:s,y:a,width:Math.max(...t)-s,height:Math.max(...e)-a}}n(C,"E");function ge(i,t){let e=Math.max(0,Math.floor(i.x)),s=Math.max(0,Math.floor(i.y)),a=Math.min(t.width,Math.ceil(i.x+i.width)),h=Math.min(t.height,Math.ceil(i.y+i.height));return a-e<16||h-s<16?null:{x:e,y:s,width:a-e,height:h-s}}n(ge,"de");function Ge(i,t,e){if(i===null||t.width<=0||t.height<=0)return null;let s=C(i);if(s.width<=0||s.height<=0)return null;let a=e==="ID-3"?{x:s.x-s.width*V.side,y:s.y-s.width*V.above,width:s.width*(1+2*V.side),height:s.height+s.width*(V.above+V.below)}:{x:s.x-s.width*it,y:s.y-s.height*it,width:s.width*(1+2*it),height:s.height*(1+2*it)};return ge(a,t)}n(Ge,"qe");function pe(i,t,e){let s=Math.max(i,t);return s>0?Math.min(1,e/s):1}n(pe,"pt");function Me(i,t,e,s,a=Ne){let h=t.width>0?e.width/t.width:1,o=t.height>0?e.height/t.height:1,l=i===null?null:{topLeft:{x:i.topLeft.x*h,y:i.topLeft.y*o},topRight:{x:i.topRight.x*h,y:i.topRight.y*o},bottomRight:{x:i.bottomRight.x*h,y:i.bottomRight.y*o},bottomLeft:{x:i.bottomLeft.x*h,y:i.bottomLeft.y*o}},r=Ge(l,e,s)??{x:0,y:0,width:e.width,height:e.height},c=pe(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=ge({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(Me,"gt");var je=960,ft=[{width:1920,height:1080},{width:2560,height:1440}];function Be(i){let t=Number.isFinite(i)&&i>0?Math.min(1,i):.85;return ft.find(e=>e.height*t>=je)??ft[ft.length-1]}n(Be,"ti");function He(i,t,e,s=We,a){let h=a===void 0?null:Be(a.fill);if(e==="LOW"&&h===null)return null;let o=e==="LOW"||h!==null&&Math.max(h.width,h.height)>Math.max(s.width,s.height)?h:s,l=i?.width?.max,r=i?.height?.max;if(typeof l!="number"||typeof r!="number"||l<=0||r<=0)return null;let c=Math.max(l,r),u=Math.min(l,r),f=Math.min(c,Math.max(o.width,o.height)),d=Math.min(u,Math.min(o.width,o.height));return f<=Math.max(t.width,t.height)?null:{width:{ideal:f},height:{ideal:d}}}n(He,"me");function Qe(i){let t={},e=i?.imageWidth,s=i?.imageHeight;if(typeof e?.max=="number"&&e.max>0){let a=typeof s?.max=="number"&&s.max>0?e.max/s.max:1.3333333333333333,h=a>=1?ae:ae*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 i?.fillLightMode?.includes("off")===!0&&(t.fillLightMode="off"),t}n(Qe,"fe");function Xe(i,t){if(i.width<=0||i.height<=0||t.width<=0||t.height<=0)return!1;let e=i.width>i.height,s=t.width>t.height;return e!==s&&i.width!==i.height&&t.width!==t.height?!1:Math.max(i.width,i.height)>=1.2*Math.max(t.width,t.height)}n(Xe,"pe");function Ue(i,t,e,s){if(e===null)return!1;let a=C(i),h=C(e);if(t.width<=0||s.width<=0)return!1;let o=a.width/t.width,l=h.width/s.width;return l>0&&o>=.6*l&&o<=1.25*l}n(Ue,"ge");var he=3500,Ke=.92;function ye(){let i=globalThis.ImageCapture;return typeof i=="function"?i:null}n(ye,"Me");function Ye(i){return/AppleWebKit\//.test(i)&&!/(Chrome|Chromium|Edg|OPR)\//.test(i)}n(Ye,"ii");function Ve(i,t=typeof navigator>"u"?"":navigator.userAgent){return ye()!==null&&!Ye(t)&&i!=null&&i.kind==="video"&&i.readyState==="live"}n(Ve,"ke");function oe(i,t){return new Promise((e,s)=>{let a=setTimeout(()=>s(new Error("takePhoto timed out")),t);i.then(h=>{clearTimeout(a),e(h)},h=>{clearTimeout(a),s(h)})})}n(oe,"ye");function mt(i,t){let e=document.createElement("canvas");return e.width=i,e.height=t,e}n(mt,"bt");function Je(i,t){return new Promise((e,s)=>{i.toBlob(a=>a?e(a):s(new Error("toBlob failed")),"image/jpeg",t)})}n(Je,"oi");async function we(i,t,e,s,a){let h=mt(e,s),o=mt(1,1);try{let l=h.getContext("2d");if(l===null)throw new Error("2d context unavailable");l.imageSmoothingQuality="high",l.drawImage(i,t.x,t.y,t.width,t.height,0,0,e,s);let r=await Je(h,Ke),c=a===null?null:Kt({topLeft:{x:a.x,y:a.y},topRight:{x:a.x+a.width,y:a.y},bottomRight:{x:a.x+a.width,y:a.y+a.height},bottomLeft:{x:a.x,y:a.y+a.height}},{width:e,height:s},{width:e,height:s}),u=Yt(h,c),f=pe(e,s,qe);return o.width=Math.max(1,Math.round(e*f)),o.height=Math.max(1,Math.round(s*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(we,"xe");function Ze(i,t){let e=Math.min(1,t/i.width),s=mt(Math.max(1,Math.round(i.width*e)),Math.max(1,Math.round(i.height*e)));try{let a=s.getContext("2d",{willReadFrequently:!0});return a===null?null:(a.imageSmoothingQuality="high",a.drawImage(i,0,0,s.width,s.height),a.getImageData(0,0,s.width,s.height))}finally{s.width=0,s.height=0}}n(Ze,"ni");async function $e(i,t,e,s){let a={width:Math.max(1,i.videoWidth),height:Math.max(1,i.videoHeight)},h=Me(t,e,a,s);return{...await we(i,h.crop,h.width,h.height,h.docRegion),docRegion:h.docRegion,source:"video",width:h.width,height:h.height}}n($e,"De");async function ti(i,t,e,s,a){let h=ye();if(h===null)return null;let o=null;try{let l=new h(a.track),r=await oe(l.getPhotoCapabilities?.()??Promise.resolve({}),he).catch(()=>({})),c=await oe(l.takePhoto(Qe(r)),he);o=await createImageBitmap(c);let u={width:i.videoWidth,height:i.videoHeight};if(!Xe(o,u))return null;let f=Ze(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&&!Ue(d,m,t,e)&&(d=null);let g=Me(d,m,o,s);return{...await we(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(ti,"we");var wt=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((i,t,e)=>typeof i=="number"&&Number.isFinite(i)&&i>=t&&i<=e?i:void 0,"S");function Ti(i){let t=wt,e=i!==null&&typeof i=="object"?i:{},s=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(s.id1,.03,1)??t.fillDistanceM.id1,id3:R(s.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(Ti,"Ri");var gt="sekyro.doc.camera";function ei(){try{let i=globalThis.localStorage?.getItem(gt);return typeof i=="string"&&i!==""?i:null}catch{return null}}n(ei,"si");function re(i){try{i===null?globalThis.localStorage?.removeItem(gt):globalThis.localStorage?.setItem(gt,i)}catch{}}n(re,"ve");var pt=n((i,t)=>Array.isArray(i?.focusMode)&&i.focusMode.includes(t),"rt");function le(i,t,e){if(!pt(i,"single-shot"))return null;let s=n(a=>Math.min(1,Math.max(0,Number.isFinite(a)?a:.5)),"o");return{focusMode:"single-shot",pointsOfInterest:[{x:s(t),y:s(e)}]}}n(le,"kt");function ii(i,t,e,s=wt){let a=i?.zoom?.min,h=i?.zoom?.max;if(typeof h!="number"||h<=1)return 1;let o=e==="ID-3"?s.fillDistanceM.id3:s.fillDistanceM.id1,l=i?.focusDistance?.min,r;if(typeof l=="number"&&l>0&&l<1){if(r=l*(1+s.focusMarginFrac)/o,r<=1.05)return 1}else{if(Math.min(t.width,t.height)<s.zoomMinSourcePx)return 1;r=s.zoomNoFocusInfo}let c=Math.min(r,s.zoomMax,h);typeof a=="number"&&(c=Math.max(c,a));let u=i?.zoom?.step;return typeof u=="number"&&u>0&&(c=Math.round(c/u)*u),c>1.01?Number(c.toFixed(2)):1}n(ii,"_e");function Mt(i){try{return i.getVideoTracks?.()[0]}catch{return}}n(Mt,"Mt");function ne(i){if(i!==null)for(let t of i.getTracks())t.stop()}n(ne,"Se");function si(i){try{let t=Mt(i)?.getCapabilities?.();return!Array.isArray(t?.focusMode)||t.focusMode.includes("continuous")}catch{return!0}}n(si,"ri");async function ai(i){let t=n(h=>({audio:!1,video:{...h,width:{ideal:i.base.width},height:{ideal:i.base.height}}}),"t"),e=n(h=>i.getUserMedia(t({deviceId:{exact:h}})),"e"),s=n(()=>i.getUserMedia(t({facingMode:{ideal:"environment"}})),"o");if(i.lensSelection){let h=ei();if(h!==null)try{return{stream:await e(h),lens:"stored"}}catch{re(null)}}let a=await s();if(!i.lensSelection||i.enumerateDevices===void 0)return{stream:a,lens:"default"};try{let h=Ht(await i.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?Mt(a)?.getSettings?.().deviceId:void 0;if(a===null||r!==l){ne(a),a=null;try{a=await e(l)}catch{continue}}if(o??(o=l),si(a))return re(l),{stream:a,lens:"selected"}}if(a!==null&&o!==null&&Mt(a)?.getSettings?.().deviceId===o)return{stream:a,lens:"selected"};if(ne(a),a=null,o!==null)try{return{stream:await e(o),lens:"selected"}}catch{}return{stream:await s(),lens:"default"}}catch{return{stream:a??await s(),lens:"default"}}}n(ai,"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(i=>Math.min(1,Math.max(0,i)),"L");function hi(i,t,e,s=.06){let a=Math.max(i.width/e,i.height),h=a*e,o=(i.width-h)/2,l=(i.height-a)/2,r=A((t.x-t.width*s-o)/h),c=A((t.y-t.height*s-l)/a),u=A((t.x+t.width*(1+s)-o)/h),f=A((t.y+t.height*(1+s)-l)/a);return{x:r,y:c,width:u-r,height:f-c}}n(hi,"Fe");function oi(i,t,e={}){let s=e.edgePeakFrac??0,{width:a,height:h,data:o}=i;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),v=Math.floor((I-S+F-1)/F);if(y<3||v<3)return ht;let x=new Int32Array(y*v);for(let p=0;p<v;p++){let M=S+p*F;for(let _=0;_<y;_++){let T=(M*a+k+_*F)*4;x[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),bt=(d-u)/F,kt=(m-f)/F,vt=w(Math.ceil(B),0,y-1),be=w(Math.floor(rt),vt,y-1),xt=w(Math.ceil(lt),0,v-1),ke=w(Math.floor(nt),xt,v-1),St=0,Ft=0,H=0,Rt=0,_t=0,Q=0;for(let p=xt;p<=ke;p++)for(let M=vt;M<=be;M++){let _=x[p*y+M];if(St+=_,_>=248&&Ft++,H++,M>=1&&M<y-1&&p>=1&&p<v-1){let T=x[p*y+M-1]+x[p*y+M+1]+x[(p-1)*y+M]+x[(p+1)*y+M]-4*_;Rt+=T,_t+=T*T,Q++}}let ve=H>0?St/H:0,Dt=H>0?Ft/H:0,Tt=Q>0?Rt/Q:0,xe=Q>0?Math.max(0,_t/Q-Tt*Tt):0,X=new Float64Array(y),U=new Float64Array(v);for(let p=0;p<v;p++)for(let M=1;M<y-1;M++)X[M]=X[M]+Math.abs(x[p*y+M+1]-x[p*y+M-1]);for(let p=1;p<v-1;p++)for(let M=0;M<y;M++)U[p]=U[p]+Math.abs(x[(p+1)*y+M]-x[(p-1)*y+M]);let O=st(X,!0,B,s),E=st(X,!1,rt,s),P=st(U,!0,lt,s),W=st(U,!1,nt,s),At=(E.position-O.position)/bt,zt=(W.position-P.position)/kt,Se=zt>0?At/zt:0,Fe=((O.position+E.position)/2-(B+rt)/2)/bt,Re=((P.position+W.position)/2-(lt+nt)/2)/kt,Ct=ce(X),It=ce(U),_e=Ct<=0||It<=0?0:Math.min(Math.min(O.value,E.value)/Ct,Math.min(P.value,W.value)/It),Z=n((p,M)=>M+(p+.5)*F,"$"),Lt=Dt,Ot=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),De=w(Math.ceil(P.position+M),0,v-1),Et=w(Math.floor(W.position-M),0,v-1),Pt=0,$=0,Wt=0;for(let N=De;N<=Et;N++)for(let q=_;q<=T;q++){$++;let K=x[N*y+q];K>=248&&Pt++;let Te=q+2<=T?x[N*y+q+2]:K,Ae=N+2<=Et?x[(N+2)*y+q]:K;(Math.abs(Te-K)>=24||Math.abs(Ae-K)>=24)&&Wt++}$>=16&&(Lt=Pt/$,Ot=Wt/$)}return{brightness:ve,glare:Dt,cardGlare:Lt,sharpness:xe,fill:At,shape:Se,content:Ot,offsetX:Fe,offsetY:Re,edgeConfidence:_e,box:{left:Z(O.position,k),right:Z(E.position,k),top:Z(P.position,S),bottom:Z(W.position,S)}}}n(oi,"Ce");function st(i,t,e,s){let a=i.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++)i[m]>i[r]&&(r=m);if(s>0&&s<1){let m=i[r]*s,g=r,b=Math.abs(r-e);for(let w=o;w<=l;w++){let k=i[w];if(k<m||k<(i[w-1]??0)||k<(i[w+1]??0))continue;let S=Math.abs(w-e);S<b&&(g=w,b=S)}r=g}let c=r>0?i[r-1]:0,u=i[r],f=r<a-1?i[r+1]:0,d=c+u+f;return{position:d>0?r+(f-c)/d:r,value:u}}n(st,"at");function ce(i){if(i.length<3)return 0;let t=0;for(let e=1;e<i.length-1;e++)t+=i[e];return t/(i.length-2)}n(ce,"Re");function ri(i){let t=i.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(ri,"Ae");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 Ai(i){let t=i!==null&&typeof i=="object"?i:{},e={...ot};for(let s of Object.keys(ot)){let a=t[s];typeof a=="number"&&Number.isFinite(a)&&a>=0&&a<=1e6&&(e[s]=a)}return e}n(Ai,"Oi");var j,li=(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 s=this.t,a=s.shapeTolerance<=0||Math.abs(t.shape-1)<=s.shapeTolerance,h=t.edgeConfidence>=s.edgeConfidenceMin&&a&&t.content>=s.contentMin,o=t.fill>=s.fillMin&&t.fill<=s.fillMax,l=Math.abs(t.offsetX)<=s.offsetMax&&Math.abs(t.offsetY)<=s.offsetMax,r=t.cardGlare<=s.glareMax,c=t.sharpness>=s.sharpnessMin,u=this.last;this.last={fill:t.fill,offsetX:t.offsetX,offsetY:t.offsetY,at:e};let f=u!==null&&s.steadyRefMs>0?Math.min(3,Math.max(1,(e-u.at)/s.steadyRefMs)):1,d=h&&r&&c&&t.fill>=s.steadyFillMin&&t.fill<=s.steadyFillMax&&u!==null&&Math.abs(t.fill-u.fill)<=s.steadyFillDelta*f&&Math.abs(t.offsetX-u.offsetX)<=s.steadyOffsetDelta*f&&Math.abs(t.offsetY-u.offsetY)<=s.steadyOffsetDelta*f,m=h&&o&&l&&r&&c,g;if(h?r?t.fill<s.fillMin?g="too_small":t.fill>s.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>=s.lockMs)return{detected:h,ready:!0,via:"good",blocker:"locking"};let b=this.steadySince!==null&&e-this.steadySince>=s.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>=s.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),J=null;async function ni(i){return J===null&&(J=(await import("./detector-scanic-GGIKCF6B-OP62MOM6.js")).detectQuad),J(i)}n(ni,"ai");async function ci(i){let t=$t(i);return t===null?null:{topLeft:{x:t.x,y:t.y},topRight:{x:t.x+t.width,y:t.y},bottomRight:{x:t.x+t.width,y:t.y+t.height},bottomLeft:{x:t.x,y:t.y+t.height}}}n(ci,"ci");function zi(){J===null&&import("./detector-scanic-GGIKCF6B-OP62MOM6.js").then(i=>{J=i.detectQuad}).catch(()=>{})}n(zi,"Ji");var ue=4e3,ui=2,de=3,di=Object.freeze({LOW:3,MID:5,HIGH:6}),yt=Object.freeze({manualShutterMs:6e3,detectedNoLockMs:1950});function Ci(i){let t=i!==null&&typeof i=="object"?i:{},e=n((s,a,h)=>typeof s=="number"&&Number.isFinite(s)&&s>=a&&s<=h?s:void 0,"e");return{manualShutterMs:e(t.manualShutterMs,1e3,6e4)??yt.manualShutterMs,detectedNoLockMs:e(t.steadyMs,300,3e4)!==void 0?t.steadyMs+(e(t.lockMs,0,1e4)??450):yt.detectedNoLockMs}}n(Ci,"qi");var z,Ii=(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 Ce,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 ie(t.format??"ID-1",t.thresholds);let e=t.deviceClass??Xt(Qt());this.deviceClass=e,this.camera=t.camera??wt,this.shutterTuning=t.shutter??yt,this.guideTuning=t.guideLock??ot,this.guideLock=new li(this.guideTuning),this.cadenceMs=1e3/di[e]}on(t,e){let s=this.handlers.get(t);return s||(s=new Set,this.handlers.set(t,s)),s.add(e),()=>s?.delete(e)}emit(t,e){for(let s of[...this.handlers.get(t)??[]])s(e)}async start(){let t=this.state==="error"?this.resumePlayback():null,e=++this.attempt;if(this.clearFrameWatch(),this.gate.reset(),this.resetSide(),this.feedback.reset(),this.lastFeedbackKey=null,this.lastGuidance=null,this.capturing=!1,this.lit=!1,this.blackTicks=0,t!==null&&await t&&e===this.attempt){this.setState("positioning"),this.scheduleTick(e),this.watchFrames(e);return}if(e===this.attempt){this.releaseStream(),Bt(),this.setState("preflight");try{let s=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 ai({getUserMedia:s,...a!==void 0?{enumerateDevices:a}:{},lensSelection:this.camera.lensSelection,base:Pe});if(e!==this.attempt){for(let o of h.stream.getTracks())o.stop();return}if(this.stream=h.stream,Nt(this.stream),jt(this.stream),this.watchEnded(e),this.opts.upgradeResolution!==!1&&await this.upgradeResolution(),e!==this.attempt||(await this.applyFocusAndZoom(),e!==this.attempt)||(this.opts.video.srcObject=this.stream,await this.opts.video.play().catch(()=>{}),e!==this.attempt))return;this.setState("positioning"),this.scheduleTick(e),this.watchFrames(e)}catch(s){if(e!==this.attempt)return;let a=Gt(s),h=qt(s);this.setState("error"),this.emit("error",{kind:a,retryable:!0,detail:h===void 0?{phase:"acquiring"}:{phase:"acquiring",name:h}})}}}resumePlayback(){let t=this.opts.video,e=this.videoTrack();if(this.stream===null||e===null||e.readyState!=="live"||t.srcObject!==this.stream)return null;try{return Promise.resolve(t.play()).then(()=>this.framesNow(),()=>!1)}catch{return null}}framesNow(){let t=this.opts.video;return this.opts.hasFrames!==void 0?this.opts.hasFrames(t):!t.paused&&t.readyState>=2&&t.videoWidth>0}watchFrames(t){let e=this.opts.firstFrameMs??ue;e<=0||(this.clearFrameWatch(),this.frameWatch=setTimeout(()=>{if(this.frameWatch=null,!(t!==this.attempt||this.state!=="positioning")){if(this.framesNow()&&this.blackTicks<de){this.reopened=!1;return}this.cameraDead(t)}},e))}clearFrameWatch(){this.frameWatch!==null&&clearTimeout(this.frameWatch),this.frameWatch=null}watchEnded(t){this.offEnded?.(),this.offEnded=null;let e=this.videoTrack();if(e===null||typeof e.addEventListener!="function")return;let s=n(()=>{t===this.attempt&&(this.state==="positioning"||this.state==="acquiring")&&this.cameraDead(t)},"o");e.addEventListener("ended",s),this.offEnded=()=>e.removeEventListener?.("ended",s)}cameraDead(t){if(t!==this.attempt)return;let e=this.videoTrack(),s=e!==null&&e.readyState==="live"&&!e.muted&&this.opts.video.paused&&!this.framesNow();if(!s&&!this.reopened){this.reopened=!0,this.start();return}this.attempt+=1,this.timer!==null&&(this.opts.clearTimer??clearTimeout)(this.timer),this.timer=null,this.clearFrameWatch(),s||this.releaseStream(),this.reopened=!1,this.setState("error"),this.emit("error",{kind:"generic",retryable:!0,detail:{phase:"acquiring"}})}releaseStream(){if(this.offEnded?.(),this.offEnded=null,this.stream)for(let t of this.stream.getTracks())t.stop();this.stream=null,this.opts.video.srcObject!==null&&this.opts.video.srcObject!==void 0&&(this.opts.video.srcObject=null)}rearm(t){t!==void 0&&(this.opts.side=t),this.gate.reset(),this.resetSide(),this.feedback.reset(),this.lastFeedbackKey=null,this.lastGuidance=null,this.capturing=!1,this.stillRefusals=0,this.state==="captured"&&(this.setState("positioning"),this.scheduleTick(this.attempt))}async captureNow(){if(this.state!=="positioning"||this.capturing)return;let t=this.opts.video,e=this.lastDetect?.width??Math.max(1,t.videoWidth),s=this.lastDetect?.height??Math.max(1,t.videoHeight),a=this.lastQuad??this.lastGuideQuad??{topLeft:{x:0,y:0},topRight:{x:e,y:0},bottomRight:{x:e,y:s},bottomLeft:{x:0,y:s}},h=(this.opts.now??(()=>performance.now()))(),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:s,tickSharpness:this.lastDetect?.tickSharpness??0},this.lastOcrReady?.via??"manual")}captureReport(){let t=this.stats;return{...this.opts.side!==void 0?{side:this.opts.side}:{},format:this.opts.format??"ID-1",deviceClass:this.deviceClass,video:{width:this.opts.video.videoWidth||0,height:this.opts.video.videoHeight||0},zoom:this.zoom,...t.zoomFallbackAtMs!==void 0?{zoomFallbackAtMs:t.zoomFallbackAtMs}:{},...t.msToCapture!==void 0?{msToCapture:t.msToCapture}:{},...t.via!==void 0?{via:t.via}:{},...t.shutterAtMs!==void 0?{shutterAtMs:t.shutterAtMs}:{},...t.shutterReason!==void 0?{shutterReason:t.shutterReason}:{},ticks:t.ticks,quadFraming:{...t.quadFraming},qualityBlockers:{...t.qualityBlockers},guideBlockers:{...t.guideBlockers},stillRefusals:t.stillRefusals,...this.ocrReport()}}ocrReport(){let t=this.opts.ocr;if(t===void 0)return{};let e=(this.opts.format??"ID-1")==="ID-3"||this.opts.side==="single"?"single":this.opts.side==="verso"?"verso":"recto",s=t.report(e,this.stats.via,(this.opts.now??(()=>performance.now()))());return s===null?{}:{ocr:s}}static freshStats(){return{ticks:0,quadFraming:{},qualityBlockers:{},guideBlockers:{},stillRefusals:0}}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),s=this.opts.guide;if(s!==void 0&&s.viewAspect>0){let l={width:s.viewAspect,height:1},r={x:s.rect.x*s.viewAspect,y:s.rect.y,width:s.rect.width*s.viewAspect,height:s.rect.height};return hi(l,r,e,0)}let a=Jt(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 s=this.focusCaps(),a=typeof s?.zoom?.min=="number"?Math.max(s.zoom.min,1):1;this.zoom=a,this.stats.zoomFallbackAtMs=Math.round(t-(this.positioningSince??t)),this.guideLock.reset(),this.gate.reset(),e.applyConstraints({advanced:[{zoom:a}]}).catch(()=>{})}offerShutter(t,e){this.shutterOffered||(this.shutterOffered=!0,this.stats.shutterAtMs=Math.round(e-(this.positioningSince??e)),this.stats.shutterReason=t,this.emit("shutter",{available:!0,reason:t}))}torchAvailable(){try{return this.stream?.getVideoTracks?.()[0]?.getCapabilities?.()?.torch===!0}catch{return!1}}async setTorch(t){this.torchOn=t;try{await this.stream?.getVideoTracks?.()[0]?.applyConstraints({advanced:[{torch:t}]})}catch{}}destroy(){if(this.attempt+=1,this.timer!==null&&(this.opts.clearTimer??clearTimeout)(this.timer),this.timer=null,this.clearFrameWatch(),this.offEnded?.(),this.offEnded=null,this.stream)for(let t of this.stream.getTracks())t.stop();this.stream=null,this.opts.video.srcObject=null}async upgradeResolution(){try{let t=this.stream?.getVideoTracks?.()[0];if(t===void 0)return;let e=t.getSettings?.()??{},s=He(t.getCapabilities?.(),{width:e.width??0,height:e.height??0},this.deviceClass,{width:this.camera.width,height:this.camera.height},this.opts.ocr?.liveMrzOn===!0?{fill:this.guideRegion({width:1080,height:1920}).width}:void 0);s!==null&&await t.applyConstraints(s)}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&&pt(e,"continuous")&&await t.applyConstraints({advanced:[{focusMode:"continuous"}]}).catch(()=>{});let s={width:0,height:0};try{let h=t.getSettings?.()??{};s={width:h.width??0,height:h.height??0}}catch{}let a=ii(e,s,this.opts.format??"ID-1",this.camera);if(a>1)try{await t.applyConstraints({advanced:[{zoom:a}]}),this.zoom=a}catch{this.zoom=1}}async focusAt(t,e){let s=this.videoTrack(),a=le(this.focusCaps(),t,e);if(!(s===null||a===null))try{await s.applyConstraints({advanced:[a]}),(this.opts.setTimer??setTimeout)(()=>{this.restoreContinuous()},1500)}catch{}}async restoreContinuous(){let t=this.videoTrack();t===null||!this.camera.continuousFocus||!pt(this.focusCaps(),"continuous")||await t.applyConstraints({advanced:[{focusMode:"continuous"}]}).catch(()=>{})}async refocusOn(t,e){let s=this.camera.refocusBeforePhotoMs,a=this.videoTrack();if(s<=0||a===null||e.width<=0||e.height<=0)return;let h=C(t),o=le(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(),s)})}catch{}}videoTrack(){try{return this.stream?.getVideoTracks?.()[0]??null}catch{return null}}async takeStill(t,e,s){if(this.opts.captureStill!==void 0)return this.opts.captureStill(this.opts.video,t,e);let a=this.opts.format??"ID-1",h=this.videoTrack();if(s&&this.opts.photoCapture!==!1&&this.deviceClass!=="LOW"&&!this.torchOn&&h!==null&&Ve(h)){await this.refocusOn(t,e);let o=await ti(this.opts.video,t,e,a,{track:h,detect:this.detector(),detectWidth:tt});if(this.restoreContinuous(),o!==null)return o}return $e(this.opts.video,t,e,a)}detector(){return this.opts.detect??((this.opts.format??"ID-1")==="ID-3"?ci:ni)}setState(t){this.state=t,this.emit("statechange",{state:t})}scheduleTick(t){let e=this.opts.setTimer??setTimeout;this.timer=e(()=>{this.tick(t)},this.cadenceMs)}async tick(t){if(t!==this.attempt||this.state!=="positioning"||this.capturing)return;let e=this.opts.now??(()=>performance.now()),s=this.opts.grabDetectFrame??me,a=this.detector(),h=s(this.opts.video,tt);if(h===null){this.scheduleTick(t);return}if(!this.lit){if(ut(h)>ui)this.lit=!0,this.blackTicks=0;else if(++this.blackTicks>=de&&this.frameWatch===null&&(this.opts.firstFrameMs??ue)>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:Ut(l),meanLuma:ut(l),specularFraction:Le(l)},u=Ee({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"?oi(h,this.guideRegion(h),{edgePeakFrac:this.guideTuning.edgePeakFrac}):ht,m=this.guideLock.tick(d,r);this.lastGuideQuad=m.detected?ri(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 v=u.lighting!=="ok"?u.lighting:u.glare!=="ok"?"glare":u.blur!=="ok"?"blurry":"steadying";b.qualityBlockers[v]=(b.qualityBlockers[v]??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<=wi?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=ze(u);u.framing!=="ok"&&m.detected&&(k=yi(m.blocker,d.brightness<this.guideTuning.darkBrightness)),k==="blurry"&&o!==null&&mi(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 v=this.feedback.force("processing",r);this.lastFeedbackKey=v.key,this.emit("feedback",v);let x=Y(at(h,y.quad));await this.fire(t,y.quad,{width:h.width,height:h.height,tickSharpness:x},y.via);return}if((I||F)&&this.opts.autoCapture!==!1){let v=this.feedback.force("processing",r);this.lastFeedbackKey=v.key,this.emit("feedback",v);let x=F?this.lastGuideQuad:o,L=F?m.via==="steady"?"guide_steady":"guide_good":"quad",B=F?Y(at(h,x)):c.sharpness;await this.fire(t,x,{width:h.width,height:h.height,tickSharpness:B},L);return}this.scheduleTick(t)}async fire(t,e,s,a){this.capturing=!0;let h=this.opts.grabDetectFrame??me,o=this.opts.setTimer??setTimeout,l={width:s.width,height:s.height};try{let r={still:await this.takeStill(e,l,!0),sharpness:s.tickSharpness};if(t!==this.attempt)return;let c=r.still.source==="photo"?0:gi;for(let d=0;d<c;d++){if(await new Promise(b=>{o(()=>b(),pi)}),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,s,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=fi(C(e),g,b,c,u):w=Vt(m,l.bandTop,u);let k=f?h.glare==="ok":s.cardGlare<=this.guideTuning.glareMax,S=f?h.blur==="ok":s.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??fe(d,t):this.lastGuideQuad??fe(d,t);this.lastOcrReady={quad:I,via:D.via}}else this.lastOcrReady=null;return D}},n(z,"i"),z);function fi(i,t,e,s,a){let h=Math.min(s,i.width*1.06*t),o=Math.min(a,Math.max(i.height*1.6*e,h/5)),l=(i.y+i.height/2)*e,r=Math.max(0,Math.min(s-h,(i.x-i.width*.03)*t)),c=Math.max(0,Math.min(a-o,l-o/2));return{x:r,y:c,w:h,h:o}}n(fi,"hi");function fe(i,t){let e=i.x*t.width,s=i.y*t.height,a=(i.x+i.width)*t.width,h=(i.y+i.height)*t.height;return{topLeft:{x:e,y:s},topRight:{x:a,y:s},bottomRight:{x:a,y:h},bottomLeft:{x:e,y:h}}}n(fe,"Ie");function mi(i,t,e){let s=C(i);return t.width<=0||t.height<=0?0:e==="ID-3"?s.width/t.width:s.width*s.height/(t.width*t.height)}n(mi,"di");var gi=2,pi=260,Mi=1.08;function me(i,t){let e=i.videoWidth,s=i.videoHeight;if(e===0||s===0)return null;let a=Math.min(1,t/e),h=Math.round(e*a),o=Math.round(s*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(i,0,0,h,o),r.getImageData(0,0,h,o))}n(me,"Pe");function at(i,t){let e=[t.topLeft.x,t.topRight.x,t.bottomRight.x,t.bottomLeft.x],s=[t.topLeft.y,t.topRight.y,t.bottomRight.y,t.bottomLeft.y],a=Math.max(0,Math.floor(Math.min(...e))),h=Math.max(0,Math.floor(Math.min(...s))),o=Math.min(i.width,Math.ceil(Math.max(...e))),l=Math.min(i.height,Math.ceil(Math.max(...s))),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)*i.width+a)*4;u.set(i.data.subarray(d,d+r*4),f*r*4)}return{data:u,width:r,height:c,colorSpace:i.colorSpace}}n(at,"lt");function yi(i,t){return i==="glare"?"glare":i==="too_small"?"too_far":i==="too_big"?"too_close":t?"too_dark":i==="blurry"?"blurry":i==="off_center"?"edge_clipped":i==="no_card"?"sensing":"hold_still"}n(yi,"gi");var wi=1200;export{Ti as a,Ai as b,zi as c,ue as d,ui as e,de as f,di as g,yt as h,Ci as i,Ii as j,fi as k,gi as l,pi as m};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as U,c as R}from"./chunk-HOSTJBJM.js";import{b as D}from"./chunk-6MYG4HWP.js";import{a}from"./chunk-4FHWXBOB.js";var k,f=(k=class extends Error{constructor(t){super(t.message),this.name="HostedApiError",this.status=t.status,this.code=t.code,t.retryAfterSeconds!==void 0&&(this.retryAfterSeconds=t.retryAfterSeconds),t.details&&(this.details=t.details)}},a(k,"u"),k);function N(e,t,i=Math.random){let n=(e??t)*1e3,s=Math.min(Math.max(n,500),2e4),r=Math.round(s*(1+(i()*2-1)*.25));return Math.min(Math.max(r,500),2e4)}a(N,"b");var ie=6e4,L=4,ne=3e4,se=9e5,ae=200,re=5,oe=400,ce=new Set(["server_busy","request_timeout"]),de=20,ue=60,le=600,pe=2;function v(e){return(e.split(";")[0]??"").trim()}a(v,"p");var he={liveness:"clipKey",face_match:"imageKey",doc_ocr:"imageKey"},fe=`@sekyro/web/${U}`,me=fe,g,tt=(g=class{constructor(t){this.sessionId=null,this.bootstrap=null,this.captureNonces=[],this.captureFetch=null,this.reportedIssues=new Map,this.issueReports=0,this.issuesPausedUntil=0,this.apiOrigin=t.apiOrigin.replace(/\/+$/,""),this.sessionToken=t.sessionToken;let i=t.fetch;this.fetchImpl=(n,s)=>(i??globalThis.fetch).call(globalThis,n,s),this.requestTimeoutMs=t.requestTimeoutMs??ne,this.retryAttempts=t.inProgressRetry?.attempts??re,this.retryDelayMs=t.inProgressRetry?.delayMs??oe,this.random=t.random??Math.random,this.clientLocale=t.locale}async getSession(){let t=await this.api("GET","/hosted/session");return this.sessionId=t.sessionId,t}async recordConsent(t){let i=await this.api("POST","/hosted/consent",{body:{locale:t},busyRetry:!0}),n=this.captureHold;return this.captureHold=void 0,n&&this.armCapture(n),i}async reportCameraUnavailable(t){return this.api("POST","/hosted/camera-unavailable",{body:{cause:t}})}async testerGate(t){return this.api("POST","/hosted/tester-gate",{body:{input:t}})}async reportCaptureIssue(t){let i=typeof t.name=="string"?t.name.replace(/[^A-Za-z]/g,"").slice(0,40):"",n=typeof t.engineKind=="string"&&/^[a-z_]{1,32}$/.test(t.engineKind)?t.engineKind:void 0,s=typeof t.attempt=="number"&&Number.isInteger(t.attempt)&&t.attempt>=0&&t.attempt<=1e3?t.attempt:void 0,r=t.check==="attestation"?s??"":"",c=[t.check,r,t.kind,i,t.phase??"",n??""].join("|"),d=this.reportedIssues.get(c);if(d!==void 0)return d;if(Date.now()<this.issuesPausedUntil||this.issueReports>=de)return;let o={check:t.check,kind:t.kind,...i!==""?{name:i}:{},...t.phase!==void 0?{phase:t.phase}:{},...n!==void 0?{engineKind:n}:{},...s!==void 0?{attempt:s}:{},...t.formFactor!==void 0?{formFactor:t.formFactor}:{},...typeof t.detail=="string"&&/^\d{1,10}$/.test(t.detail)?{detail:t.detail}:{},...V(t.challengeMs)?{challengeMs:t.challengeMs}:{},...V(t.readyMs)?{readyMs:t.readyMs}:{},...t.inApp===!0?{inApp:!0}:{}};this.issueReports+=1;let u=this.api("POST","/hosted/capture-issue",{body:o,empty:!0}).catch(l=>{if(l instanceof f&&l.status===429){let p=Math.min(Math.max(l.retryAfterSeconds??ue,0),le);this.issuesPausedUntil=Math.max(this.issuesPausedUntil,Date.now()+p*1e3);return}(!(l instanceof f)||l.status===0||l.status>=500)&&this.reportedIssues.delete(c)});return this.reportedIssues.set(c,u),u}async choose(t,i){let n=await this.api("POST","/hosted/choice",{body:{nodeId:t,option:i},busyRetry:!0});return this.sessionId=n.sessionId,n}async confirmIdentity(t){return this.api("POST","/hosted/identity/confirm",{body:{decision:t}})}async identityPortrait(){return this.api("GET","/hosted/identity/portrait",{blob:!0})}async presign(t,i,n,s={}){let r=await this.ensureSessionId(),c={kind:t,contentType:v(i),contentLength:n,...s.source==="upload"?{source:"upload"}:{}};return this.api("POST",`/sessions/${r}/media`,{body:c})}armCapture(t=2){this.captureHold===void 0?this.fillCaptureNonces(t,t):this.captureHold=Math.max(this.captureHold,t)}async presignCapture(t,i,n,s={}){let r=await this.ensureSessionId(),c=await this.takeCaptureNonce(),d=c===void 0?void 0:{nonce:c,...s.engine!==void 0?{engine:s.engine.slice(0,32)}:{},...s.durationMs!==void 0&&Number.isFinite(s.durationMs)?{captureMs:Math.min(36e5,Math.max(0,Math.round(s.durationMs)))}:{}},o={kind:t,contentType:v(i),contentLength:n,capture:d};return this.api("POST",`/sessions/${r}/media`,{body:o})}async takeCaptureNonce(){let t=a(()=>{let i=Date.now();return this.captureNonces=this.captureNonces.filter(n=>n.expiresAt-ie>i),this.captureNonces.shift()?.nonce},"e");for(let i=0;i<2;i++){let n=t();if(n!==void 0)return n;await this.fillCaptureNonces(1)}return t()}fillCaptureNonces(t,i=0){return this.captureFetch??(this.captureFetch=(async()=>{try{let n=await this.ensureSessionId(),s=await this.api("POST",`/sessions/${n}/media/capture-nonces`,{body:{count:Math.min(L,Math.max(1,t))}}),r=Date.now()+Math.max(0,s.expiresIn)*1e3;for(let c of Array.isArray(s.nonces)?s.nonces:[])typeof c=="string"&&c.length>0&&this.captureNonces.push({nonce:c,expiresAt:r});this.captureNonces=this.captureNonces.slice(-L),this.captureHold=void 0}catch(n){n instanceof f&&n.code==="consent_required"&&(this.captureHold=Math.max(this.captureHold??0,i))}})().finally(()=>{this.captureFetch=null})),this.captureFetch}async uploadToSpaces(t,i,n){let s;try{s=await this.fetchImpl(t,{method:"PUT",headers:{"content-type":v(n)},body:i,signal:AbortSignal.timeout(se)})}catch(r){throw K(r)}if(!s.ok){let r=(await s.text().catch(()=>"")).slice(0,ae);throw new f({status:s.status,code:"upload_failed",message:`media upload failed (HTTP ${s.status})${r?`: ${r}`:""}`})}}async completeMedia(t){let i=await this.ensureSessionId();return this.api("POST",`/sessions/${i}/media/complete`,{body:{key:t}})}async submitCheck(t,i,n={}){let s=await this.ensureSessionId(),r={input:i,forceOutcome:n.forceOutcome};return this.api("POST",`/sessions/${s}/checks/${t}`,{body:r,idempotencyKey:n.idempotencyKey,...n.browserCheckToken!==void 0?{browserCheckToken:n.browserCheckToken}:{},busyRetry:n.idempotencyKey!==void 0})}async uploadAndSubmit(t,i,n,s={}){let r=v(i.contentType),c=await this.presign(i.kind,r,i.blob.size);await this.uploadToSpaces(c.uploadUrl,i.blob,r);let d=await this.completeMedia(c.key),o={...n,[he[t]]:d.key};return this.submitCheck(t,o,s)}async ensureSessionId(){return this.sessionId!==null?this.sessionId:(this.bootstrap??(this.bootstrap=this.getSession().finally(()=>{this.bootstrap=null})),(await this.bootstrap).sessionId)}async api(t,i,n={}){let s=t==="GET"||n.busyRetry===!0,r=`${this.apiOrigin}/api/v2${i}`,c={"x-session-token":this.sessionToken,"x-sekyro-sdk":me};n.body!==void 0&&(c["content-type"]="application/json"),n.idempotencyKey!==void 0&&(c["x-idempotency-key"]=n.idempotencyKey),n.browserCheckToken!==void 0&&(c["sekyro-browser-check"]=n.browserCheckToken),this.clientLocale!==void 0&&(c["sekyro-client-locale"]=this.clientLocale);try{let d=R.timezone();d!==void 0&&(c["sekyro-client-timezone"]=d)}catch{}c["sekyro-client-form-factor"]=D();try{let d=await R.deviceHeader();d!==void 0&&(c["sekyro-client-device"]=d)}catch{}for(let d=0;;d++){let o;try{o=await this.fetchImpl(r,{method:t,headers:c,...n.body!==void 0?{body:JSON.stringify(n.body)}:{},cache:"no-store",signal:AbortSignal.timeout(this.requestTimeoutMs)})}catch(l){throw K(l)}if(o.ok){if(n.empty===!0)return;if(n.blob===!0)try{return await o.blob()}catch(p){throw K(p)}let l;try{l=await o.json()}catch{throw new f({status:o.status,code:"unknown_error",message:`response body was not valid JSON (HTTP ${o.status})`})}return ye(l)}let u=await _e(o);if(u.code==="idempotency_in_progress"&&d<this.retryAttempts){this.retryDelayMs>0&&await G(this.retryDelayMs);continue}if(s&&u.status===503&&ce.has(u.code)){s=!1,await G(N(u.retryAfterSeconds,pe,this.random));continue}throw u}}},a(g,"T"),g);function V(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0&&e<=6e5}a(V,"k");function K(e){if((typeof e=="object"&&e!==null?e.name:void 0)==="TimeoutError")return new f({status:0,code:"timeout",message:"request timed out"});let t=e instanceof Error?e.message:String(e);return new f({status:0,code:"network_error",message:`network request failed: ${t}`})}a(K,"h");function ye(e){return e!==null&&typeof e=="object"&&"success"in e&&"data"in e?e.data:e}a(ye,"K");async function _e(e){let t="unknown_error",i=`request failed (HTTP ${e.status})`,n=Number.NaN,s;try{let d=await e.json();if(d!==null&&typeof d=="object"){let o=d;typeof o.code=="string"&&o.code.length>0&&(t=o.code),typeof o.message=="string"&&o.message.length>0&&(i=o.message),typeof o.retryAfterSeconds=="number"&&(n=o.retryAfterSeconds),Array.isArray(o.details?.issues)?s=o.details:Array.isArray(o.details?.errors)&&(s={...o.details,issues:[]})}}catch{}let r=e.headers.get("retry-after"),c=r===null?Math.floor(n):Number.parseInt(r,10);return new f({status:e.status,code:t,message:i,...Number.isFinite(c)&&c>=0?{retryAfterSeconds:c}:{},details:s})}a(_e,"L");function G(e){return new Promise(t=>setTimeout(t,e))}a(G,"S");function it(e){let t=e?.portrait,i=t?.icao,n=t?.purpose==="id_document";return i==null?n?{policy:"reject",profile:"id_document"}:null:{policy:i.policy==="alert"?"alert":"reject",profile:n||i.profile==="id_document"?"id_document":"selfie"}}a(it,"z");function nt(e){return{...e.baselineEyeOpenness!==void 0?{baselineEyeOpenness:e.baselineEyeOpenness}:{},...e.baselineEyeOpennessLeft!==void 0&&e.baselineEyeOpennessRight!==void 0?{baselineEyeOpennessLeft:e.baselineEyeOpennessLeft,baselineEyeOpennessRight:e.baselineEyeOpennessRight}:{},criteria:e.verdict??{},...e.backgroundCheck!==void 0?{backgroundCheck:e.backgroundCheck}:{}}}a(nt,"X");var ve=new Set(["nni_unbound","id_number_unbound","method_required","mobile_required","portrait_required"]);function ot(e){return ve.has(e)}a(ot,"be");function ct(e,t,i){let n=t.detail;return{check:e,kind:t.kind,...n?.name!==void 0?{name:n.name}:{},...n?.phase!==void 0?{phase:n.phase}:{},...n?.engineKind!==void 0?{engineKind:n.engineKind}:{},attempt:Math.max(0,Math.min(1e3,i))}}a(ct,"ve");function dt(){let e=-1,t="";return{note(i){i==="starting"&&t!=="starting"&&(e+=1),t=i},newHandle(){t=""},noteError(){e<0&&(e=0)},get value(){return e}}}a(dt,"Pe");var ke={document:"document_photo",nfc:"document_chip",population_registry:"national_number",national_eid:"national_eid"};function y(e){return e.plan?.steps??[]}a(y,"f");function H(e){return Math.max(0,e.attempts.max-e.attempts.used)}a(H,"x");function ge(e){let t=e.plan?.choice;return t!==void 0&&e.plan?.current===t.nodeId?t:null}a(ge,"W");function ut(e){let t=ge(e);if(t?.kind!=="identity_method")return null;let i=t.options.map(s=>ke[s.service]).filter(s=>s!==void 0),n=t.options.find(s=>s.nationalEid)?.nationalEid;return n?{available:!0,selected:null,options:i,nationalEid:n}:{available:!0,selected:null,options:i}}a(ut,"Me");var be=new Set(["liveness","face_match"]);function z(e){return e!==void 0&&(e.state==="pending"||e.state==="input_required")}a(z,"y");function we(e){return e.status!=="created"&&e.status!=="in_progress"}a(we,"T");function X(e){let t=e.plan?.current,i=t==null?void 0:y(e).find(n=>n.id===t);return z(i)?i:void 0}a(X,"M");function q(e,t){return y(e).find(i=>i.checkType===t)}a(q,"_");function O(e){let t=y(e),i=t.findIndex(n=>n.checkType==="liveness");return t.find((n,s)=>s>i&&n.checkType==="face_match")}a(O,"S");function Me(e,t){let i=q(t,"liveness")?.state,n=O(t)?.state;return(O(e)?.state??"pending")==="pending"&&(i==="passed"||i==="review")&&n!==void 0&&n!=="pending"&&n!=="skipped"}a(Me,"F");function B(e,t){let i=new Map(y(e).map(n=>[n.id,n.state]));return y(t).filter(n=>n.checkType==="face_match"&&(i.get(n.id)??"pending")==="pending"&&n.state!=="pending"&&n.state!=="skipped").map(n=>n.id)}a(B,"V");var Se=/^[0-9a-f]{24}$/i;function E(e){return Se.test(e)?`ses_${e}`:e}a(E,"R");function x(e,t){let i=E(e);return t===void 0?{sessionId:i,status:"unavailable"}:{sessionId:i,status:"unavailable",reasonCode:t}}a(x,"w");function Z(e,t,i){let n=E(e);return i===void 0?{sessionId:n,status:t}:{sessionId:n,status:t,reasonCode:i}}a(Z,"O");function lt(e,t){let i=Te(e,t),n=Ie(e);return n!==void 0&&(i.sandbox={simulated:!0,reason:n}),i}a(lt,"Ve");var Ce=new Set(["no_testers","tester_gate_not_used","tester_gate_missed"]);function Ie(e){if(e.sandbox!==!0)return;let t=e.simulation?.reason;return Ce.has(t)?t:void 0}a(Ie,"Q");function Te(e,t){let i=E(e.sessionId);switch(e.status){case"created":case"in_progress":return Oe(e,t);case"verified":return P(e,{sessionId:i,status:"verified"});case"review_pending":return P(e,Z(i,"review",Q(e,"review")));case"not_verified":return P(e,Ee(e));default:return P(e,{sessionId:i,status:"not_verified"})}}a(Te,"Z");var Ae=new Set([0,1,2,3]);function P(e,t){return Ae.has(e.level)&&(t.level=e.level),typeof e.assurance=="string"&&e.assurance.length>0&&(t.assurance=e.assurance),t}a(P,"b");function Ee(e){let t={sessionId:E(e.sessionId),status:"not_verified"};return e.reason!==void 0&&(t.reason=e.reason),e.reasonCode!==void 0&&(t.reasonCode=e.reasonCode),e.reasonCode==="device_cooldown"&&e.retryAfter!==void 0&&(t.retryAfter=e.retryAfter),t}a(Ee,"ne");function xe(e){return e==="rejected"?"rejected":e==="unavailable"?"unavailable":"inconclusive"}a(xe,"te");function Pe(e,t){if(t===void 0)return!1;let i=y(t).find(n=>n.id===e.id);return i!==void 0&&i.attempts.used===e.attempts.used}a(Pe,"ie");function Oe(e,t){let i=E(e.sessionId),n=y(e).find(r=>be.has(r.checkType)&&r.state==="input_required"&&r.reason!==void 0);if(n?.reason==="mobile_required")return x(i,"mobile_required");if(n?.reason!==void 0){if(n.result==="unavailable")return x(i,n.reason);let r=t.autoRetry&&(H(n)>0||Pe(n,t.previous))?{sessionId:i,status:"retry",reasonCode:n.reason,attemptsRemaining:H(n)}:{sessionId:i,status:"not_verified",reason:xe(n.result),reasonCode:n.reason,attemptsRemaining:H(n)};return n.retakeHint!==void 0&&(r.retakeHint=n.retakeHint),r}let s=X(e);return s===void 0&&y(e).some(r=>r.state==="review")?Z(i,"review",Q(e,"review")):s?.checkType==="portrait_icao"?x(i,"portrait_required"):x(i)}a(Oe,"re");function Q(e,t){return y(e).find(i=>i.state===t&&i.reason!==void 0)?.reason}a(Q,"L");function W(e,t,i,n,s){return e.presignCapture!==void 0?e.presignCapture(t,i,n,s):e.presign(t,i,n)}a(W,"K");function Y(e){return{engine:e?.engine,durationMs:e?.clipMs}}a(Y,"q");var qe=["video/webm","video/mp4"],J="image/jpeg",$e=2,Re=1e3,Ke=1e4,Ne=3,He=10,Fe=3,ze=new Set(["network_error","timeout","upload_failed","unknown_error","rate_limit_exceeded"]),je=new Set(["session_not_active","check_not_found","check_already_finalized","check_out_of_order","identity_confirm_required","check_not_active","step_not_on_path","native_app_required"]),b,j=(b=class extends Error{constructor(){super("verification destroyed"),this.name="FlowCancelledError"}},a(b,"k"),b);function De(e){let t=O(e);return q(e,"portrait_icao")?.state!=="pending"&&(t!==void 0?z(t):e.capture?.livePhoto?.oneCapture===!0)}a(De,"me");var w,A=(w=class extends Error{constructor(t){super(t),this.name="AttestationError"}},a(w,"h"),w),M,Ue=(M=class extends A{constructor(t){super(`no attestation token: ${t}`),this.name="AttestationUnavailableError",this.code=t}},a(M,"E"),M);async function ee(e,t,i={}){let n=e.uuid(),s=!1,r=!1,c=0,d=0;for(;;)try{return await t(e.client,n)}catch(o){if(o instanceof A){if(r||o instanceof Ue)throw o;r=!0,i.onAttestationInvalid?.(),n=e.uuid();continue}if(!(o instanceof f))throw o;if(o.code==="consent_required"&&!s){s=!0,await e.ensureConsent({force:!0}),n=e.uuid();continue}if(o.code==="attestation_invalid"&&!r){r=!0,i.onAttestationInvalid?.(),n=e.uuid();continue}if(o.code==="inference_unavailable"&&d<Ne){d+=1;let u=N(o.retryAfterSeconds,He,e.random??Math.random);e.onBusy?.({attempt:d,retryAfterSeconds:u/1e3}),await e.sleep(u),i.onAttestationInvalid?.(),n=e.uuid();continue}if(ze.has(o.code)&&c<$e){c+=1;let u=o.retryAfterSeconds!==void 0?o.retryAfterSeconds*1e3:void 0;await e.sleep(u!==void 0?Math.min(u,Ke):Re);continue}throw o}}a(ee,"D");var Le=new Set(["passed","review","processing","skipped"]);async function pt(e){let{artifacts:t}=e,i=t.clip,n=v(t.clipMime??"");if(t.degraded==="NO_RECORDER"||i===void 0||!qe.includes(n))return{kind:"unavailable",reason:"no_recorder"};e.client.armCapture?.(2);let s=Ve(e,t.keyframe),r=Ge(e,i,n,s),c=Be(e,s),d=!1,o=new Set,u=!0,l=0;for(;;){if(e.isCancelled())return{kind:"cancelled"};let p=e.getView();if(we(p))return{kind:"settled"};let h=X(p),T=h?.checkType,$=T==="liveness"&&!d?"liveness":T==="face_match"&&!o.has(h?.id)&&o.size<2&&u?"face_match":null;if($===null)return{kind:"settled"};if($==="liveness"&&t.captureChannel==="desktop")return{kind:"unavailable",reason:"mobile_required"};try{if($==="liveness"){d=!0;let m=await r();if(e.isCancelled())return{kind:"cancelled"};Me(p,m)&&o.add(O(m)?.id);for(let te of B(p,m))o.add(te);await e.applySubmit(m,"liveness");let _=q(e.getView(),"liveness")?.state;u=_===void 0||Le.has(_)}else{o.add(h?.id);let m=await c();if(e.isCancelled())return{kind:"cancelled"};for(let _ of B(p,m))o.add(_);await e.applySubmit(m,"face_match")}}catch(m){if(e.isCancelled()||m instanceof j)return{kind:"cancelled"};let _=Qe(m);if(_.kind!=="resync"||l>=Fe)return _;l+=1,await e.refreshView()}}}a(pt,"Fe");function Ve(e,t){let i=null,n=null,s=a(()=>i!==null?Promise.resolve(i):(n??(n=(async()=>{let r=await W(e.client,"image",J,t.size,Y(e.artifacts));return await e.client.uploadToSpaces(r.uploadUrl,t,J),i=(await e.client.completeMedia(r.key)).key,e.onKeyframePromoted?.(i),i})().finally(()=>{n=null})),n),"r");return{ensure:s,attempt:a(()=>s().catch(()=>null),"attempt"),current:a(()=>i,"current")}}a(Ve,"_e");function Ge(e,t,i,n){let s=e.clipKeys?.get()??null,r,c=null,d=0,o;return()=>ee(e,async(u,l)=>{if(s===null||r===void 0){if(e.isCancelled())throw new j;r===void 0&&!De(e.getView())&&(r=null),e.onPhase("uploading");let[p,h]=await Promise.all([s!==null?Promise.resolve(s):(async()=>{let T=await W(u,"clip",i,t.size,Y(e.artifacts));return await u.uploadToSpaces(T.uploadUrl,t,i),(await u.completeMedia(T.key)).key})(),r!==void 0?Promise.resolve(r===null?null:r.imageKey):n.attempt()]);s=p,e.clipKeys?.set(p),r===void 0&&(r=h===null?null:{imageKey:h})}if(c===null){let p=performance.now();try{c=await e.getAttestation(),o=e.attestationError?.()}catch(h){throw h instanceof A?h:new A(h instanceof Error?h.message:String(h))}d=Math.round(performance.now()-p)}return e.onPhase("checking"),u.submitCheck("liveness",{clipKey:s,attestation:c,captureChannel:e.artifacts.captureChannel,capture:{...Je(e.artifacts),attestationMs:d,attestationError:o,...Ze(e.attestationFacts?.())},...r!==null?{faceMatch:r}:{}},{idempotencyKey:l})},{onAttestationInvalid:a(()=>{c=null},"onAttestationInvalid")})}a(Ge,"ge");function Be(e,t){return()=>ee(e,async(i,n)=>{if(t.current()===null){if(e.isCancelled())throw new j;e.onPhase("uploading")}let s=await t.ensure();return e.onPhase("checking"),i.submitCheck("face_match",{imageKey:s},{idempotencyKey:n})})}a(Be,"Se");function Je(e){let t={width:e.width,height:e.height};for(let i of Xe)e[i]!==void 0&&(t[i]=e[i]);return t}a(Je,"ye");var Xe=["engine","facingMode","mode","formFactor","clipMs","clipFrames","fps","clipRetakes","codec","cameraReadyMs","faceAcquireMs","captureMs","screenRamp","provenance"];function Ze(e){return e===void 0?{}:{attestationChecks:e.checks,...e.challengeMs!==void 0?{attestationChallengeMs:e.challengeMs}:{}}}a(Ze,"ke");function Qe(e){if(e instanceof A)return{kind:"unavailable",reason:"attestation"};if(e instanceof f){if(e.code==="attestation_invalid")return{kind:"unavailable",reason:"attestation"};if(e.code==="inference_unavailable")return{kind:"unavailable",reason:"inference_unavailable"};if(e.code==="mobile_required")return{kind:"unavailable",reason:"mobile_required"};if(je.has(e.code))return{kind:"resync"}}return{kind:"unavailable",reason:"network"}}a(Qe,"Ce");var ht="form_answers_invalid",S,ft=(S=class extends Error{constructor(t,i){super(`form answers refused (${t.map(n=>`${n.id}: ${n.code}`).join(", ")})`),this.name="FormAnswersError",this.issues=t,this.source=i}},a(S,"U"),S),C,mt=(C=class extends Error{constructor(t,i){super(`invalid ${t} (${i})`),this.name="InvalidInputError",this.field=t,this.kind=i}},a(C,"B"),C),I,yt=(I=class extends Error{constructor(t,i){super(`invalid ${t} (${i})`),this.name="OtpInputError",this.field=t,this.kind=i}},a(I,"$"),I);function F(e){return e?.source==="upload"?null:e?.source==="choice"&&e.sourcePick!=="camera"?"upload_or_phone":"phone"}a(F,"I");function _t(e,t){if(t===void 0||!z(t)||t.requiresMobile!==!0)return null;switch(t.checkType){case"liveness":return"phone";case"face_match":{if(t.reason!==void 0)return"phone";let i=q(e,"portrait_icao");return i?.state==="passed"||i?.state==="review"?null:"phone"}case"doc_ocr":return F(e.documents);case"poa":return F(e.proofOfAddress);case"portrait_icao":{let i=e.portrait;return i?.pendingFix!==void 0||i?.reuse?.pending===!0?null:F(i)}default:return null}}a(_t,"De");function We(e){let t=e?.capture,i=t?.mode;return i==="assisted"||i==="self"||i==="choice"?i:t?.cameraSwitch===!0?"assisted":"self"}a(We,"we");function vt(e){let t=e?.capture?.pick;return We(e)==="choice"&&(t==="self"||t==="assisted")?t:null}a(vt,"Be");function kt(e,t,i=null){return e==="choice"?t??i??"self":e}a(kt,"$e");var gt={"MR:drivers_license":{normalize:"upper_no_space_or_hyphen",pattern:"^[0-9]{8}$",check:null,registrySources:[],describe:"number must be the 8-digit Mauritanian driver's license number"},"MR:national_id":{normalize:"trim",pattern:"^[0-9]{10}$",check:"mr_nni_mod97",registrySources:["MR.anrpts"],describe:"number must be the 10-digit Mauritanian national ID number with a valid check digit"}};export{f as a,v as b,tt as c,it as d,nt as e,ot as f,ct as g,dt as h,ke as i,y as j,H as k,ge as l,ut as m,z as n,we as o,X as p,q,E as r,x as s,lt as t,Ie as u,W as v,qe as w,Ue as x,ee as y,pt as z,Je as A,ht as B,ft as C,mt as D,yt as E,_t as F,We as G,vt as H,kt as I,gt as J};
|