@sekyro/web 0.1.0-rc.27 → 0.1.0-rc.29
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 +30 -0
- package/README.md +4 -1
- package/dist/barcode-detect-C5IOXMKI.js +1 -0
- package/dist/{capture-session-doc-FRBI7OKF.js → capture-session-doc-YC4CT2EQ.js} +1 -1
- package/dist/{capture-session-v3-DZmmTeDY.d.cts → capture-session-v3-CTQL6eFd.d.cts} +1 -1
- package/dist/{capture-session-v3-CjaciYJQ.d.ts → capture-session-v3-DHlOE6cS.d.ts} +1 -1
- package/dist/{challenge-frame-NUGPTWFP.js → challenge-frame-5GG4NDF5.js} +1 -1
- package/dist/{chunk-Y5ZLVLCU.js → chunk-34IITQFB.js} +1 -1
- package/dist/chunk-6AH7FXVC.js +1 -0
- package/dist/chunk-AL6LIOLW.js +1 -0
- package/dist/chunk-BF7CLNFA.js +1 -0
- package/dist/chunk-CKHBGAUA.js +1 -0
- package/dist/chunk-EVIGRYOX.js +3 -0
- package/dist/chunk-FVWFAO45.js +1 -0
- package/dist/{chunk-U3JUGEIW.js → chunk-IA5M34P7.js} +1 -1
- package/dist/chunk-JLVZ35QK.js +2 -0
- package/dist/{chunk-4DEPREJ3.js → chunk-KXFHVAYQ.js} +1 -1
- package/dist/chunk-VVUQ4PFU.js +1 -0
- package/dist/{chunk-HLV2XYHX.js → chunk-WOVWAJD4.js} +1 -1
- package/dist/chunk-XIKMTHHH.js +1 -0
- package/dist/chunk-ZKF2XMNX.js +1 -0
- package/dist/client/index.cjs +1 -1
- package/dist/client/index.d.cts +3 -3
- package/dist/client/index.d.ts +3 -3
- package/dist/client/index.js +1 -1
- package/dist/core/index.cjs +1 -1
- package/dist/core/index.d.cts +3 -3
- package/dist/core/index.d.ts +3 -3
- package/dist/core/index.js +1 -1
- package/dist/core/ocr/worker.js +1 -1
- package/dist/create-document-capture-O64FR2DA.js +1 -0
- package/dist/{create-verification-ClZ9Nvop.d.ts → create-verification-BvldYuLZ.d.ts} +131 -16
- package/dist/{create-verification-CnsFqT2E.d.cts → create-verification-DzPluhA3.d.cts} +131 -16
- package/dist/{detector-scanic-23DAYT3H.js → detector-scanic-SE3CL55N.js} +1 -1
- package/dist/{icao-gate-DWexlqVW.d.ts → icao-gate-DveU9Cr8.d.ts} +1 -1
- package/dist/{icao-gate-Dfpj4nT4.d.cts → icao-gate-xyWB7dz2.d.cts} +1 -1
- package/dist/{icao-policy-eLrX6Twc.d.ts → icao-policy-BWu1JLgi.d.cts} +12 -3
- package/dist/{icao-policy-BnXH_-WM.d.cts → icao-policy-OOEQDG9_.d.ts} +12 -3
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +40 -8
- package/dist/index.d.ts +40 -8
- package/dist/index.js +1 -1
- package/dist/internal/index.cjs +2 -2
- package/dist/internal/index.d.cts +6 -6
- package/dist/internal/index.d.ts +6 -6
- package/dist/internal/index.js +1 -1
- package/dist/plan-runner-WGMNUBWJ.js +1 -0
- package/dist/{types-BGUwaKjk.d.ts → types-CezFEXzl.d.cts} +169 -8
- package/dist/{types-BGUwaKjk.d.cts → types-CezFEXzl.d.ts} +169 -8
- package/package.json +6 -3
- package/sbom.cdx.json +125 -10
- package/dist/chunk-3XVIDHFY.js +0 -3
- package/dist/chunk-A3FUGHAH.js +0 -2
- package/dist/chunk-C5FD3ADY.js +0 -1
- package/dist/chunk-HVW2AB35.js +0 -1
- package/dist/chunk-NFHLJOHW.js +0 -1
- package/dist/chunk-SDDM5ZTK.js +0 -1
- package/dist/chunk-VXHK5YC6.js +0 -1
- package/dist/chunk-ZCOWTM46.js +0 -1
- package/dist/chunk-ZCZ2E2YN.js +0 -1
- package/dist/create-document-capture-2YBCDEUB.js +0 -1
- package/dist/plan-runner-KQM7I4MR.js +0 -1
package/dist/chunk-SDDM5ZTK.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{A as Re,D as w,E as j,d as K,e as ge,f as ye,g as be,i as _e,j as ee,l as q,m as te,o as Ce,p as Pe,t as ke}from"./chunk-ZCZ2E2YN.js";import{c as me,d as he,e as Se}from"./chunk-FPXL63KZ.js";import{c as F,h as Q,i as Me}from"./chunk-C5FD3ADY.js";var Ae=["AD","AE","AF","AG","AI","AL","AM","AO","AQ","AR","AS","AT","AU","AW","AX","AZ","BA","BB","BD","BE","BF","BG","BH","BI","BJ","BL","BM","BN","BO","BQ","BR","BS","BT","BV","BW","BY","BZ","CA","CC","CD","CF","CG","CH","CI","CK","CL","CM","CN","CO","CR","CU","CV","CW","CX","CY","CZ","DE","DJ","DK","DM","DO","DZ","EC","EE","EG","EH","ER","ES","ET","FI","FJ","FK","FM","FO","FR","GA","GB","GD","GE","GF","GG","GH","GI","GL","GM","GN","GP","GQ","GR","GS","GT","GU","GW","GY","HK","HM","HN","HR","HT","HU","ID","IE","IL","IM","IN","IO","IQ","IR","IS","IT","JE","JM","JO","JP","KE","KG","KH","KI","KM","KN","KP","KR","KW","KY","KZ","LA","LB","LC","LI","LK","LR","LS","LT","LU","LV","LY","MA","MC","MD","ME","MF","MG","MH","MK","ML","MM","MN","MO","MP","MQ","MR","MS","MT","MU","MV","MW","MX","MY","MZ","NA","NC","NE","NF","NG","NI","NL","NO","NP","NR","NU","NZ","OM","PA","PE","PF","PG","PH","PK","PL","PM","PN","PR","PS","PT","PW","PY","QA","RE","RO","RS","RU","RW","SA","SB","SC","SD","SE","SG","SH","SI","SJ","SK","SL","SM","SN","SO","SR","SS","ST","SV","SX","SY","SZ","TC","TD","TF","TG","TH","TJ","TK","TL","TM","TN","TO","TR","TT","TV","TW","TZ","UA","UG","UM","US","UY","UZ","VA","VC","VE","VG","VI","VN","VU","WF","WS","XK","YE","YT","ZA","ZM","ZW"];var qe=["carte_identite","passport","residence_permit","drivers_license"],Qe=["carte_identite","passport","residence_permit"];function Je(e,t){let o=e.byIssuer?.[t]??e.default;return qe.filter(s=>o==="*"?Qe.includes(s):o.includes(s))}function zt(e,t=Ae){return[...new Set([...t,...Object.keys(e.byIssuer??{})])].filter(s=>Je(e,s).length>0).sort()}function Ee(e){if(e.acceptedDocuments)return e.acceptedDocuments;let t=e.acceptedDocumentTypes?.length?[...e.acceptedDocumentTypes]:["carte_identite","passport"];return{default:[],byIssuer:{MR:t}}}var ze=640,Xe=new Set(["network_error","timeout","upload_failed","unknown_error","rate_limit_exceeded"]),Ie=6,ve=1500,Oe={sharpness:1,exposure:1,meanLuma:128},Te=null;function et(e,t){try{Te??(Te=document.createElement("canvas"));let o=Te,s=96/Math.max(1,t.width);o.width=Math.max(1,Math.round(t.width*s)),o.height=Math.max(1,Math.round(t.height*s));let i=o.getContext("2d");if(i===null)return Oe;i.drawImage(e,t.x,t.y,t.width,t.height,0,0,o.width,o.height);let c=i.getImageData(0,0,o.width,o.height);return{sharpness:he(c),exposure:Se(c),meanLuma:me(c)}}catch{return Oe}}async function tt(e,t){let o=e.source;return"convertToBlob"in o?o.convertToBlob({type:"image/jpeg",quality:t}):new Promise((s,i)=>{o.toBlob(c=>c===null?i(new Error("encode failed")):s(c),"image/jpeg",t)})}function on(e,t={}){let o=t.now??(()=>performance.now()),s=t.setTimer??((f,_)=>setTimeout(f,_)),i=t.clearTimer??(f=>clearTimeout(f)),c=t.encode??tt,d=t.quality??et,u=e.tuningVersion??null,p=new Set,S=!1,y=e.video??null,M=null,m=t.grabFrame??null,b=null,v=1e3/Ie,E=null,I=null,O=!1,L=!1,D=Number.NEGATIVE_INFINITY,A=null,G=0,V=null,B=null,z=Promise.all([import("./icao-gate-T3BTOKFJ.js"),import("./icao-tuning-4ETMF53W.js"),import("./create-portrait-capture-5VGYZUOK.js"),import("./landmarker-KB7LVXAU.js"),import("./background-monitor-A7FKJOAG.js")]).then(async([f,_,R,x,T])=>{let k=_.resolveIcaoTuning(e.tuning,e.tuningVersion??void 0);k.background.required&&(I=T.createBackgroundMonitor({tuning:k.backgroundCheck,assetBaseUrl:e.assetBaseUrl??"/models-v3",...t.createSegmenter!==void 0?{createSegmenter:t.createSegmenter}:{},now:o})),M=f.createIcaoGate(k,{policy:e.policy??"reject"}),m??(m=R.defaultGrabber()),b=R.observe,v=1e3/Math.min(Ie,k.cadenceHz);let n=(t.createLandmarker??x.createFaceLandmarker)(e.assetBaseUrl??"/models-v3"),r=await new Promise((a,l)=>{let h=setTimeout(()=>{l(new Error("landmarker init timeout")),n.then(g=>g.close(),()=>{})},x.LANDMARKER_INIT_TIMEOUT_MS);n.then(g=>{clearTimeout(h),a(g)},g=>{clearTimeout(h),l(g)})});S?r.close():E=r}).catch(()=>{O=!0}),H=f=>{for(let _ of p)_({holding:L||O,update:f})},Y=()=>{if(A=null,!(S||E===null||M===null||m===null||b===null||y===null)){if(o()-D>ve){H(null);return}try{let f=m(y,ze);if(f!==null){let _=Math.max(o(),G+1);G=_;let R=E.detect(f.source,_),x=y.videoWidth||f.width,T=y.videoHeight||f.height,k=b(R,f,x,T);k.geometry!==null&&I!==null&&(k.backgroundCheck=I.measure(f,k.geometry.box,x,T));let n=M.push(k,o());L=n.ready,H(n)}}catch{}A=s(Y,v)}},Z=()=>{let f=o()-D>ve;D=o(),f&&(M?.reset(),L=!1,V=null,B=null),A===null&&E!==null&&!S&&(A=s(Y,0))},X=()=>{let f=m===null||y===null?null:m(y,null);if(f===null||M===null||Math.max(f.width,f.height)<e.still.minLongSidePx)return Promise.resolve(null);let _=M.summary();return c(f,e.still.jpegQuality).then(R=>({image:R,width:f.width,height:f.height,gate:_}),()=>null)},W=null;return{engineOptions:{measureQuality:(f,_)=>{y=f,Z();let R=d(f,_);return L||O?R:{...R,sharpness:0}},telemetry:f=>{if(f.type!=="fired"||S)return;V=X();let _=W;_!==null&&V.then(R=>R===null?void 0:_(R).catch(()=>{})),L=!1,A!==null&&i(A),A=null,D=Number.NEGATIVE_INFINITY}},decorate:f=>{let _=new WeakMap,R=new Map,x=r=>{let a=_.get(r);return a===void 0&&(a=(async()=>{let l=await ke(f,"image","image/jpeg",r.image.size,{engine:"portrait"});return await f.uploadToSpaces(l.uploadUrl,r.image,"image/jpeg"),(await f.completeMedia(l.key)).key})(),a.catch(()=>_.delete(r)),_.set(r,a)),a};W=x;let T=async r=>{let a;try{a=await x(r)}catch(l){let h=l?.code;if(typeof h=="string"&&Xe.has(h))throw l;return null}return{media:{portrait:a},gate:Me(r.gate),...u!==null?{tuningVersion:u}:{}}},k=f.submitCheck.bind(f),n=(async(r,a,l)=>{if(r!=="liveness")return k(r,a,l);let h=l?.idempotencyKey,g=h===void 0?void 0:R.get(h);if(g===void 0){let pe=V;g=pe===null?Promise.resolve(null):pe.then(fe=>fe===null?null:T(fe)),h!==void 0&&(R.set(h,g),g.catch(()=>R.delete(h)))}let C=await g;if(C===null)return k("liveness",a,l);let P=await k("liveness",{...a,portraitIcao:C},l);return B=C,P});return new Proxy(f,{get(r,a){if(a==="submitCheck")return n;let l=Reflect.get(r,a);return typeof l=="function"?l.bind(r):l}})},onGate:f=>(p.add(f),()=>p.delete(f)),lastPortraitInput:()=>B,destroy:()=>{S=!0,V=null,B=null,A!==null&&i(A),A=null,p.clear(),z.then(()=>{E?.close(),E=null,I?.close(),I=null})}}}function xe(e){return e.idNumberBound??e.nniBound}function we(e){return e===void 0?void 0:e.idNumberFromDocument??e.nniFromDocument}function Ne(e){let t=e.idNumberMasked??e.nniMasked;return typeof t=="string"&&t!==""?t:void 0}var Le=Object.freeze({nni_invalid:"id_number_invalid",nni_not_found:"registry_record_not_found",nni_recheck:"id_number_recheck",document_nni_mismatch:"document_id_number_mismatch",nni_locked:"id_number_locked",nni_unbound:"id_number_unbound",missing_nni:"missing_id_number",registry_needs_nni_source:"registry_needs_id_number_source"}),nt=new Map(Object.entries(Le)),an=new Map(Object.entries(Le).map(([e,t])=>[t,e]));function Ve(e){return nt.get(e)??e}var ot=new Set(["phone_otp","email_otp","national_eid","document","nfc","population_registry","supplied_identity","summary_confirm","liveness","portrait","face_match","aml_screening","face_dedup","age_estimation","proof_of_address"]),it=new Set(["supplied_identity","aml_screening","face_dedup","age_estimation"]),oe=["document","population_registry","national_eid"],ie=["phone_otp","email_otp"],Ge={identity_method:oe,contact:ie},rt=["population_registry","document"],re="platform_unsupported",st=new Set(["prefilled","user_entered","prefilled_or_entered"]),at={phone_otp:"contact",email_otp:"contact",eid_auth:"identity",doc_ocr:"identity",nfc_chip:"identity",population_registry:"identity",liveness:"live_photo",portrait_icao:"live_photo",face_match:"live_photo",poa:"documents"};function N(e){return e.section??at[e.checkType]??null}function se(e,t){let o=e.plan?.choice;if(o===void 0||o.locked)return;let s=o.options.find(i=>i.id!==o.selected&&i.available!==!1&&t.includes(i.service));return s===void 0?void 0:{nodeId:o.nodeId,option:s}}function ae(e){let t=e.plan,o=t?.choice;if(t===void 0||o===void 0||o.locked||t.current===null||t.current===o.nodeId||ee(e))return null;let s=Ge[o.kind]??[...oe,...ie],i=o.options.flatMap(u=>u.available===!1||!s.includes(u.service)?[]:[u.nationalEid!=null?{id:u.id,service:u.service,nationalEid:u.nationalEid}:{id:u.id,service:u.service}]),c=t.steps.find(u=>u.id===t.current)?.service,d=o.selected??i.find(u=>u.service===c)?.id??null;return i.some(u=>u.id!==d)?{nodeId:o.nodeId,kind:o.kind,current:d,options:i}:null}function Be(e){return e==null?[]:e.options.filter(t=>t.id!==e.current)}function ct(e){let t=e.simulation;if(typeof t!="object"||t===null)return;let{otpCode:o,skipCapture:s}=t;return typeof o=="string"&&o!==""&&typeof s=="boolean"?{otpCode:o,skipCapture:s}:void 0}function ut(e){let t=(e.plan?.sections??[]).map(d=>({id:d.id,state:d.state})),o={sessionId:te(e.sessionId),orgName:e.orgName,sandbox:e.sandbox===!0,returning:e.returning===!0,consentRecorded:e.consentRecorded,expiresAt:e.expiresAt,sections:t.map(d=>d.id),progress:t,purpose:e.purpose??"identity"};e.branding!==void 0&&(o.branding=e.branding),e.cameraUnavailableHandled===!0&&(o.cameraUnavailableHandled=!0);let s=ct(e);s!==void 0&&(o.simulation=s);let i=e.testerGate;i?.offered===!0&&typeof i.attemptsLeft=="number"&&i.attemptsLeft>0&&(o.testerGate={attemptsLeft:i.attemptsLeft});let c=ae(e);return c!==null&&(o.switchable=c),o}function dt(e){let t={attemptsRemaining:ye(e),attemptsExhausted:e.attempts.used>=e.attempts.max};return e.reason!==void 0&&(t.reason=e.reason),e.retakeHint!==void 0&&(t.retakeHint=e.retakeHint),t}var Ue={phone_otp:"phone",email_otp:"email"};function lt(e,t){let o=se(e,[t==="phone_otp"?"email_otp":"phone_otp"]);return o===void 0?void 0:Ue[o.option.service]}function pt(e,t,o,s){let i=t.checkType==="email_otp",c=(i?t.emailOtp:t.otp)??{},d=i?t.emailOtp?.emailSource:t.otp?.numberSource,u=d!==void 0&&st.has(d)?d:i?"prefilled_or_entered":"user_entered",p=typeof c.sentToMasked=="string"&&c.sentToMasked.length>0,S=c.prefilled===!0,y=lt(e,i?"email_otp":"phone_otp"),M={key:t.checkType,context:o,section:N(t),phase:p?"verify":"send",canSwitch:y!==void 0,...s},m=i?{kind:"email_otp",...M,emailSource:u,needsEmail:u!=="prefilled"&&!S}:{kind:"phone_otp",...M,numberSource:u,needsPhone:u!=="prefilled"&&!S,channels:(t.otp?.channels??[]).filter(b=>b==="whatsapp"||b==="sms")};if(y!==void 0&&(m.switchChannel=y),S&&(m.prefilled=!0),p&&(m.sentToMasked=c.sentToMasked),!i&&t.otp?.channel!==void 0&&(m.channel=t.otp.channel),!i&&Array.isArray(t.phoneCountries)&&(m.phoneCountries=t.phoneCountries.filter(b=>typeof b=="string"&&/^[A-Z]{2}$/.test(b))),!i&&Array.isArray(t.phoneRules)){let b=m.phoneCountries??[];m.phoneRules=t.phoneRules.flatMap(v=>{let E=ht(v);return E!==void 0&&b.includes(E.code)?[E]:[]})}return!i&&t.phoneInternational===!0&&(m.phoneInternational=!0),c.expiresAt!==void 0&&(m.codeExpiresAt=c.expiresAt),c.resendAvailableAt!==void 0&&(m.resendAvailableAt=c.resendAvailableAt),m}var ft=/^[\d[\]\-|()?:^]{1,64}$/;function mt(e){try{return typeof e=="string"&&ft.test(e)&&new RegExp(e)!==null}catch{return!1}}var De=e=>typeof e=="number"&&Number.isInteger(e)&&e>=1&&e<=15;function ht(e){let{code:t,dial:o,trunk:s,lengths:i,formats:c}=e??{};if(typeof t!="string"||typeof o!="string"||!/^\d{1,3}$/.test(o)||s!==void 0&&(typeof s!="string"||!/^\d{1,3}$/.test(s))||!Array.isArray(i)||i.length===0||!i.every(De))return;let d={code:t,dial:o,lengths:[...i].sort((u,p)=>u-p)};if(s!==void 0&&(d.trunk=s),c!==void 0){if(!(Array.isArray(c)&&c.length<=8&&c.every(p=>mt(p?.leading)&&Array.isArray(p.groups)&&p.groups.every(De)&&i.includes(p.groups.reduce((S,y)=>S+y,0)))))return;d.formats=c.map(p=>({leading:p.leading,groups:[...p.groups]}))}return d}function St(e,t,o,s){let i=xe(e)===!0?"bound":we(t)===!0?"document":"typed",c=i==="typed"&&t.state==="input_required"&&t.reason!==void 0&&Ve(t.reason)==="id_number_recheck",d=Be(ae(e)),u=!s.attemptsExhausted&&d.length===1&&d[0]?.service==="document";return{kind:"registry",key:"registry",context:o,section:N(t),state:t.state==="input_required"?"input_required":"pending",source:i,recheck:c,canUseDocument:u,...s}}function gt(e,t,o,s,i){let c=[...t.acceptedSides??[]],d={kind:"document",key:"document",context:o,section:N(t),side:c.includes("recto")?"verso":"recto",acceptedSides:c,documents:Ee(e),photo:ue(ce(e.documents),i),...s};return e.detectedCountry!==void 0&&(d.detectedCountry=e.detectedCountry),_t(e)&&(d.ageStepUp=!0),d}function ce(e,t=!0){let o=e?.source==="upload"||e?.source==="choice"?e.source:"camera",s=e?.sourcePick==="camera"||e?.sourcePick==="upload"?e.sourcePick:null;return{source:o,pick:s,uploadOffered:t&&e?.uploadOffered===!0}}function ue(e,t){return t?{...e,cameraOnPhone:!0}:e}var yt=10*1024*1024;function bt(e,t,o,s,i){let c=e.proofOfAddress,d=c?.pdf?.maxBytes,u=c?.phase==="holder_letter"?"holder_letter":"document";return{kind:"proof_of_address",key:"proof_of_address",context:o,section:N(t),phase:u,rule:c?.rule??{country:null,countryFrom:"global",source:"preset_global",kinds:[]},nameMatch:c?.nameMatch??"exact_person",photo:ue(ce(c),i),maxPages:3,pdf:{maxBytes:typeof d=="number"&&d>0?d:yt,maxPages:3},licenceAddressAccepted:u==="document"&&c?.licenceAddressAccepted===!0,...s}}function _t(e){let t=ge(e).find(s=>s.checkType==="age_estimation"),o=t?.reason;return t?.state==="failed"&&(o==="age_uncertain"||o==="age_unavailable")}function Ct(e){let t=q(e,"liveness");return t?.state==="passed"||t?.state==="review"}function He(e,t,o,s,i,c=!1){let d=t.icao?.report,u=e.portrait,p=i==="capture"?u?.pendingFix??null:null;p!==null&&(i="review");let S=Fe(e);return{kind:"portrait",key:`portrait:${i}`,context:o,section:N(t),phase:i,report:Array.isArray(d)?d:null,review:t.state==="review",tuning:e.capture?.icao??null,tuningVersion:e.capture?.tuningVersion??null,icao:Q(e),retakeOnly:i==="capture"&&t.state==="input_required"&&S===void 0&&e.capture?.livePhoto?.oneCapture===!0&&Ct(e),photo:ue(ce(u,i==="capture"),c&&i==="capture"),pendingFix:p,...S!==void 0?{captureMode:S}:{},...u?.reuse?.pending===!0?{reuse:!0}:{},...s}}function Fe(e){let t=e.portrait?.captureMode;return t==="self"||t==="assisted"||t==="choice"?t:void 0}var ne={minLongSidePx:1280,jpegQuality:.95};function Pt(e,t){let o=e.capture?.livePhoto;if(o?.oneCapture!==!0)return null;let s=q(e,"portrait_icao"),i=o.still??ne;return{icao:t==="liveness"&&Q(e)!==null&&Fe(e)===void 0&&s!==void 0&&s.state==="pending"&&s.reason===void 0,still:{minLongSidePx:i.minLongSidePx??ne.minLongSidePx,jpegQuality:i.jpegQuality??ne.jpegQuality}}}function kt(e,t,o,s){let i=t.eid,c=N(t);if(i===void 0||i.challenge!=="app_code")return{kind:"unsupported",key:"unsupported:eid_auth",context:o,section:c,checkType:"eid_auth",reason:"update_required"};let d=Be(ae(e)),u=d.length===1&&rt.includes(d[0]?.service??"")?d[0]:void 0,p=u===void 0?void 0:K[u.service],S=p!==void 0,y={kind:"eid",key:"eid",context:o,section:c,provider:i.provider,providerName:i.providerName,country:i.country,challenge:"app_code",phase:i.awaiting==="code"?"code":"identifier",identifierBound:i.identifierBound===!0,canUseCamera:S,afterPass:i.afterPass==="continue"?"continue":"end",...s};return S&&(y.cameraMethod=p),i.expiresAt!==void 0&&(y.codeExpiresAt=i.expiresAt),i.resendAvailableAt!==void 0&&(y.resendAvailableAt=i.resendAvailableAt),i.resendsRemaining!==void 0&&(y.resendsRemaining=i.resendsRemaining),i.codeAttemptsRemaining!==void 0&&(y.codeAttemptsRemaining=i.codeAttemptsRemaining),y}function Rt(e,t){if(t.checkType!=="face_match"||t.reason!==void 0)return null;let o=q(e,"portrait_icao");return o!==void 0&&(o.state==="passed"||o.state==="review")?o:null}var Mt={rejected:"rejected",inconclusive:"inconclusive",unavailable:"unavailable",abandoned:"expired",not_opened:"expired",cancelled:"expired",superseded:"expired",policy:"policy"};function At(e){return e.reasonCode===re?"platform_unsupported":e.status==="review_pending"?"review":e.status==="verified"?"verified":e.reasonCode==="device_cooldown"?"cooldown":e.reasonCode==="starter_credit_claimed"?"policy":(e.status==="not_verified"&&e.reason!==void 0?Mt[e.reason]:void 0)??"rejected"}function Et(e,t){let o=At(e),s=o==="platform_unsupported"?{sessionId:te(e.sessionId),status:"unavailable",reasonCode:re}:Ce(e,{autoRetry:!1}),i={kind:"result",key:"result",context:t,section:null,display:o,result:s};return e.status==="not_verified"&&e.reason!==void 0&&(i.reason=e.reason),e.reasonCode!==void 0&&(i.reasonCode=e.reasonCode),e.status==="not_verified"&&e.step!==void 0&&(i.step=e.step),e.retryAfter!==void 0&&(i.retryAfter=e.retryAfter),i}function It(e,t,o){let s=e.identitySummary;if(s==null)return null;let i={kind:"identity_summary",key:"identity_summary",context:t,section:o??"identity",summaryKind:s.kind==="partial"?"partial":s.kind??"full",source:s.source,portraitAvailable:s.portrait?.available===!0,retakeAvailable:s.retakeAvailable===!0};for(let d of vt){let u=s[d];typeof u=="string"&&u!==""&&(i[d]=u)}let c=Ne(s);return c!==void 0&&(i.idNumberMasked=c,i.nniMasked=c),i}var vt=["fullName","birthDate","birthYear","nationality","documentType","documentNumberMasked","expiryDate","retakeTarget"];function U(e,t,o,s){return{kind:"unsupported",key:`unsupported:${o}`,context:e,section:t,checkType:o,reason:s}}function Ot(e){return e.kind==="contact"?"contact":(e.kind==="identity_method","identity")}function Tt(e,t){let o=Ge[e.kind]??[...oe,...ie],s=Ot(e),i=e.options.flatMap(d=>{if(d.available===!1||!o.includes(d.service))return[];let u={id:d.id,service:d.service};d.nationalEid!=null&&(u.nationalEid=d.nationalEid);let p=(d.channels??[]).filter(S=>S==="whatsapp"||S==="sms");return d.service==="phone_otp"&&p.length>0&&(u.channels=p),[u]});if(i.length===0){let d=e.options.length>0&&e.options.every(u=>u.service==="nfc");return U(t,s,"choice",d?"platform_unsupported":"update_required")}let c={nodeId:e.nodeId,kind:e.kind,selected:e.selected,options:i};if(e.kind==="identity_method"){let d={kind:"method",key:"method",context:t,section:s,options:i.map(p=>K[p.service]),choice:c},u=i.find(p=>p.nationalEid!==void 0)?.nationalEid;return u!==void 0&&(d.nationalEid=u),d}return e.kind==="contact"?{kind:"contact_choice",key:"contact_choice",context:t,section:s,options:i.map(d=>Ue[d.service]),selected:null,locked:!1,choice:c}:{kind:"choice",key:`choice:${e.nodeId}`,context:t,section:s,choice:c}}function J(e,t={}){let o=ut(e);if(ee(e)||e.reasonCode===re)return Et(e,o);let s=e.plan;if(s===void 0||!Array.isArray(s.sections))return U(o,null,"plan","update_required");let i=be(e);if(i!==null)return Tt(i,o);let c=s.current===null?void 0:s.steps.find(m=>m.id===s.current),d=m=>{let b={kind:"processing",key:"processing",context:o,section:m!==void 0?N(m):s.sections.find(v=>v.state==="current")?.id??null,stalled:!1};return typeof m?.service=="string"&&m.service!==""&&(b.service=m.service),b};if(s.current===null)return d(s.steps.find(m=>m.state==="processing"));if(c===void 0)return U(o,null,"step","update_required");if(!ot.has(c.service))return c.interaction==="server"?d(c):U(o,N(c),c.service,"update_required");if(it.has(c.service)||!_e(c))return d(c);let u=c,p=dt(u),S=u.checkType,y=N(u),M=t.isMobile===!1?Pe(e,u):null;if(M==="phone")return{kind:"mobile_required",key:"mobile_required",context:o,section:y,checkType:S};switch(S){case"phone_otp":case"email_otp":return pt(e,u,o,p);case"population_registry":return St(e,u,o,p);case"eid_auth":return kt(e,u,o,p);case"doc_ocr":return gt(e,u,o,p,M==="upload_or_phone");case"identity_confirm":return It(e,o,y)??d(u);case"portrait_icao":return He(e,u,o,p,"capture",M==="upload_or_phone");case"liveness":case"face_match":{let m=Rt(e,u);if(m!==null)return He(e,m,o,p,"match");let b=u.requiresMobile===!0,v=Q(e);return{kind:"liveness",key:"biometric",context:o,section:y,mode:S==="face_match"?"selfie":"liveness",requiresMobile:b,instructions:v===null?"standard":"icao",icao:v,livePhoto:Pt(e,S),...p}}case"poa":return bt(e,u,o,p,M==="upload_or_phone");case"nfc_chip":return U(o,y,S,"platform_unsupported");default:return U(o,y,S,"update_required")}}var xt=/^[A-Z0-9][A-Z0-9 -]{0,39}$/,wt=Object.freeze({normalize:e=>e.trim().toUpperCase().replace(/\s+/g," "),check:e=>xt.test(e),registrySources:Object.freeze([]),describe:"number must be 1 to 40 letters, digits, spaces or hyphens"}),Nt=/^[A-Z0-9]{4,20}$/,Ke=e=>e.trim().toUpperCase().replace(/[\s-]+/g,""),je=Object.freeze({normalize:Ke,check:e=>Nt.test(Ke(e)),registrySources:Object.freeze([]),describe:"number must be 4 to 20 letters or digits"});function Lt(e){return typeof e=="string"&&/^\d{10}$/.test(e)&&Number(e)%97===1}var Vt=Object.freeze({normalize:e=>e.trim(),check:e=>Lt(e),registrySources:Object.freeze(["MR.anrpts"]),describe:"number must be the 10-digit Mauritanian national ID number with a valid check digit"}),Dt=Object.freeze({...je,check:e=>/^\d{8}$/.test(e.trim()),describe:"number must be the 8-digit Mauritanian driver's license number"}),Ht=Object.freeze({"MR:national_id":Vt,"MR:drivers_license":Dt});function de(e,t){return Ht[`${e.toUpperCase()}:${t}`]??(t==="drivers_license"?je:wt)}var Gt=Object.freeze({MRT:"MR"});function Ye(e,t){let o=e.trim().toUpperCase();return de(Gt[o]??o,t)}function Ze(e){let t=Ye(e.issuingCountry,e.type);return t.check(t.normalize(e.number))}function We(e){return de("MR","national_id").check(e)}function le(e){let t="";for(let o of e){let s=o.codePointAt(0)??0;s>=1632&&s<=1641?t+=String(s-1632):s>=1776&&s<=1785?t+=String(s-1776):o!==" "&&o!=="-"&&o!==" "&&(t+=o)}return t}var Bt=[1e3,2e3,4e3,8e3,15e3],Ut=3e4,Ft=/^\+[1-9]\d{6,14}$/,Kt=/^\d{6}$/,jt=/^\d{6}$/,Yt=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,$e=new Set(["session_not_active","check_not_found","check_already_finalized","check_out_of_order","identity_confirm_required","identity_confirm_locked","choice_locked","choice_option_unavailable","choice_not_found","step_not_on_path","check_not_active"]),Zt={simulatedCapture:!0},Wt=new Set(["network_error","timeout","upload_failed","unknown_error","rate_limit_exceeded"]);function Mn(e){let t=!1,o=null,s="",i=!1,c=!1,d=!1,u={},p={},S=new Set,y=!1,M=!1,m=null,b="idle",v=new Map,E=new Map,I=(n,r,a)=>{let l=`${n}.${r}`,h=v.get(l);if(h!==void 0)return h;let g=E.get(n),C=(g===void 0?a():g.then(a)).finally(()=>{v.delete(l)});v.set(l,C);let P=C.then(()=>{},()=>{});return E.set(n,P),P.then(()=>{E.get(n)===P&&E.delete(n)}),C},O=async(n,r,a)=>{await e.ensureConsent();let l;try{l=await Re(e.runtime,r)}catch(g){if(g instanceof F&&$e.has(g.code)){await e.refreshView();return}throw g}if(a?.(l),e.destroyed())return;let h=l;h.plan!==void 0&&e.setView!==void 0?e.setView(h):await e.refreshView()},L=async n=>{await e.ensureConsent();let r;try{try{r=await n(e.runtime.client)}catch(a){if(!(a instanceof F)||a.code!=="consent_required")throw a;await e.runtime.ensureConsent({force:!0}),r=await n(e.runtime.client)}}catch(a){if(a instanceof F&&$e.has(a.code)){await e.refreshView();return}throw a}e.destroyed()||(r!==void 0&&e.setView!==void 0?e.setView(r):await e.refreshView())},D=(n,r)=>I("choice",`${n}:${r}`,()=>L(a=>a.choose(n,r))),A=(n,r)=>n.options.some(a=>a.id===r)?D(n.nodeId,r):Promise.reject(new RangeError(`option ${String(r)} is not offered`)),G=(n,r)=>{let a=e.currentView(),l=a===null?void 0:se(a,n);return l===void 0?Promise.reject(new RangeError(`the ${r} is not offered`)):D(l.nodeId,l.option.id)},V=n=>I("identity",n,()=>L(r=>r.confirmIdentity===void 0?Promise.reject(new Error("identity confirmation is not available in this build")):r.confirmIdentity(n))),B=(n,r)=>{let a=n.kind,l=a==="phone_otp",h=l?"phone":"email",g={action:"send"};if(l?n.needsPhone:n.needsEmail){let C=r[h]??p[a],P=l?C?.replace(/[\s().-]/g,""):C?.trim();if(P!==void 0||n.phase!=="verify"){if(P===void 0||!(l?Ft:Yt).test(P))return Promise.reject(l?new w("phone","format"):new j("email","format"));g[h]=P}}if(l){let C=n.channels,P=r.channel??(C.length===1?C[0]:void 0);if(C.length>0){if(P===void 0)return Promise.reject(new j("channel","required"));if(!C.includes(P))return Promise.reject(new j("channel","unavailable"))}P!==void 0&&(g.channel=P),g.phoneRules=1}return I(a,"send",()=>O(a,(C,P)=>C.submitCheck(a,g,{idempotencyKey:P}),C=>{qt(C,a)||(u[a]=e.now(),g[h]!==void 0&&(p[a]=g[h]))}))},z=(n,r)=>Kt.test(r)?I(n,"verify",()=>O(n,(a,l)=>a.submitCheck(n,{action:"verify",code:r},{idempotencyKey:l}))):Promise.reject(new w("code","format")),H=(n,r)=>I("eid_auth",n,()=>O("eid_auth",(a,l)=>a.submitCheck("eid_auth",r,{idempotencyKey:l}))),Y=(n,r)=>{if(n.identifierBound)return H("start",{action:"start"});let a=le(r??"");if(n.country==="MR"){if(!/^\d{10}$/.test(a))return Promise.reject(new w("nni","format"));if(!We(a))return Promise.reject(new w("nni","check_digit"))}else if(a==="")return Promise.reject(new w("nni","format"));return H("start",{action:"start",identifier:a})},Z=(n,r,a)=>{if(n.source!=="typed")return Promise.reject(new RangeError("this session already holds the ID number"));let l=le(r);return/^\d{10}$/.test(l)?Ze({type:"national_id",issuingCountry:"MR",number:l})?I("population_registry","submitIdNumber",()=>O("population_registry",(h,g)=>h.submitCheck("population_registry",{idNumber:l,nni:l},{idempotencyKey:g}),()=>{m=`\u2022\u2022\u2022\u2022\u2022\u2022${l.slice(-4)}`})):Promise.reject(new w(a,"check_digit")):Promise.reject(new w(a,"format"))},X=n=>(e.stopCameras?.(),I(n,"skipCapture",()=>O(n,(r,a)=>r.submitCheck(n,Zt,{idempotencyKey:a}),()=>{(n==="liveness"||n==="portrait_icao")&&(y=!0)}))),W=n=>{if(n.kind==="result"||n.context.simulation?.skipCapture!==!0)return n;let r=$t(n);return r===null?n:{...n,skipCapture:()=>X(r)}},$=n=>((n.kind==="document"||n.kind==="portrait"||n.kind==="proof_of_address")&&n.photo?.cameraOnPhone===!0&&(n.refresh=async()=>{await e.refreshView()}),n),f=n=>{switch(n.kind){case"phone_otp":case"email_otp":{let r={...n,send:(l={})=>B(n,l),verify:l=>z(n.kind,l),switchTo:()=>n.canSwitch&&n.switchChannel!==void 0?G([n.switchChannel==="email"?"email_otp":"phone_otp"],"other contact option"):Promise.reject(new RangeError("this session has no other contact option"))},a=u[n.kind];return r.resendAvailableAt===void 0&&a!==void 0&&(r.resendAvailableAt=new Date(a+Ut).toISOString()),r}case"eid":return{...n,start:r=>Y(n,r),verify:r=>jt.test(r)?H("verify",{action:"verify",code:r}):Promise.reject(new w("code","format")),resend:()=>n.resendsRemaining===0?Promise.reject(new RangeError("no new code can be sent for this session")):H("resend",{action:"resend"}),useCamera:()=>n.canUseCamera&&n.cameraMethod!==void 0?G(n.cameraMethod==="document_photo"?["document"]:["population_registry"],"camera path"):Promise.reject(new RangeError("the camera path is not offered"))};case"method":return{...n,select:r=>{let a=n.choice.options.find(l=>K[l.service]===r);return a!==void 0?A(n.choice,a.id):Promise.reject(new RangeError(`method ${String(r)} is not offered`))},choose:r=>A(n.choice,r)};case"choice":return{...n,choose:r=>A(n.choice,r)};case"registry":return{...n,submitIdNumber:r=>Z(n,r,"idNumber"),submitNni:r=>Z(n,r,"nni"),confirm:()=>I("population_registry","confirm",()=>O("population_registry",(r,a)=>r.submitCheck("population_registry",{},{idempotencyKey:a}))),useDocument:()=>n.canUseDocument?G(["document"],"document method"):Promise.reject(new RangeError("the document method is not offered"))};case"document":return e.bindDocument!==void 0?$(e.bindDocument(n,k)):{...n,issuer:null,documentType:null,captureSide:null,selectDocument:()=>{throw new Error("document capture is not available in this build")},capture:()=>{throw new Error("document capture is not available in this build")},uploadDocument:()=>Promise.reject(new Error("document upload is not available in this build"))};case"portrait":return e.bindPortrait!==void 0?$(e.bindPortrait(n,k)):{...n,uploadFailed:!1,resubmit:()=>Promise.resolve(),capture:()=>{throw new Error("portrait capture is not available in this build")},uploadPortrait:()=>Promise.reject(new Error("portrait upload is not available in this build")),confirmFix:()=>Promise.reject(new Error("portrait review is not available in this build"))};case"proof_of_address":return e.bindProofOfAddress!==void 0?$(e.bindProofOfAddress(n,k)):{...n,uploadPages:()=>Promise.reject(new Error("proof of address upload is not available in this build")),uploadHolderLetter:()=>Promise.reject(new Error("proof of address upload is not available in this build")),capturePage:()=>{throw new Error("proof of address capture is not available in this build")}};case"contact_choice":return{...n,select:r=>{let a=r==="phone"?"phone_otp":r==="email"?"email_otp":void 0,l=n.choice.options.find(h=>h.service===a);return l!==void 0?A(n.choice,l.id):Promise.reject(new RangeError(`contact ${String(r)} is not offered`))},choose:r=>A(n.choice,r)};case"identity_summary":return{...n,...n.idNumberMasked===void 0&&n.summaryKind==="partial"&&m!==null?{idNumberMasked:m,nniMasked:m}:{},portrait:async()=>{let r=e.runtime.client;if(!n.portraitAvailable||r.identityPortrait===void 0)return null;try{return await r.identityPortrait()}catch{return null}},confirm:()=>V("confirm"),retake:()=>n.retakeAvailable?V("retake"):Promise.reject(new RangeError("no retake is left"))};case"liveness":return{...n,capture:r=>e.liveness(r),onLivePhoto:r=>n.livePhoto?.icao===!0&&e.onLivePhoto!==void 0?e.onLivePhoto(r):()=>{}};case"mobile_required":case"processing":return{...n,refresh:async()=>{i=!1,await e.refreshView()}};case"unsupported":case"result":return{...n};default:{let r=n;throw new Error(`runner: unhandled step ${JSON.stringify(r)}`)}}},_=n=>W(f(n)),R=async()=>{if(!c){c=!0;try{for(let n of Bt){if(await e.sleep(n),!t||e.destroyed())return;let r=await e.refreshView().catch(()=>null);if(r!==null&&J(r,{isMobile:e.isMobile()}).kind!=="processing")return}i=!0,k()}finally{c=!1}}},x=n=>{if(n.kind!=="liveness"||n.mode!=="selfie")return null;let r={kind:"processing",key:"processing",context:n.context,section:n.section,stalled:!1};if(b==="inflight")return r;if(!M||b==="done")return null;let a=e.keptFaceKey?.()??null;return a===null?null:(b="inflight",O("face_match",(l,h)=>l.submitCheck("face_match",{imageKey:a},{idempotencyKey:h}),()=>{b="done"}).then(()=>{b==="inflight"&&(b="done",k())},()=>{b="done",k()}),r)},T=(n,r=!1)=>{if(!t||e.destroyed()||e.chainBusy())return;let a=J(n,{isMobile:e.isMobile()});a.kind==="registry"&&a.recheck&&(M=!0,b="idle"),a=x(a)??a,a.kind==="processing"?a.stalled=i:i=!1;let l=_(a),h=a.kind==="result"?void 0:a.context.switchable,g=h===void 0?l:{...l,chooseOption:P=>A({nodeId:h.nodeId,kind:h.kind,selected:h.current,options:h.options},P)},C=JSON.stringify(g);a.kind==="registry"&&a.source==="document"&&a.state==="pending"&&!S.has("registry")&&(S.add("registry"),g.confirm().catch(P=>{(!(P instanceof F)||Wt.has(P.code))&&S.delete("registry")})),!(!r&&C===s)&&(s=C,o=g,e.emitStep(g),a.kind==="processing"&&!i&&b!=="inflight"&&R(),a.kind==="result"&&!d&&(d=!0,e.emitResult(a.result)))};function k(){let n=e.currentView();n!==null&&T(n,!0)}return{run:async()=>{if(e.destroyed())throw new Error("verification destroyed");t=!0;let n=await e.ensureView();return o===null&&T(n),o??_(J(n,{isMobile:e.isMobile()}))},current:()=>o,onView:n=>T(n),onChainIdle:()=>{let n=e.currentView();n!==null&&T(n)},republish:k,submit:O,faceProbeSkipped:()=>y}}function $t(e){switch(e.kind){case"document":return"doc_ocr";case"liveness":return e.mode==="selfie"?"face_match":"liveness";case"portrait":return e.phase==="capture"?"portrait_icao":null;case"proof_of_address":return"poa";case"mobile_required":return e.checkType;case"unsupported":return e.checkType==="nfc_chip"?"nfc_chip":null;default:return null}}function qt(e,t){let o=e,s=o?.plan?.steps??o?.steps;return Array.isArray(s)?s.some(i=>i.checkType===t&&typeof i.reason=="string"):!1}export{Je as a,zt as b,Ie as c,ve as d,on as e,Fe as f,J as g,Bt as h,Ut as i,Mn as j};
|
package/dist/chunk-VXHK5YC6.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{d as Z,h as Se,i as Me,j as ke,l as De}from"./chunk-G6LKLN4U.js";import{e as he,f as ye}from"./chunk-NFHLJOHW.js";import{m as V}from"./chunk-Y5ZLVLCU.js";import{a as ge,g as be}from"./chunk-7QZWBDI5.js";import{k as J}from"./chunk-CPUECYAJ.js";var Xe={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 Ve(e){let{deviceMemory:t,effectiveType:n,saveData:r,downlinkMbps:i,sourceLongEdge:c}=e,s=r===!0||n==="slow-2g"||n==="2g"||i!=null&&i>0&&i<1,u=t!=null&&t<=2,l=n==="4g"||i!=null&&i>=5,f=t!=null&&t>=6,p;s||u?p="low":l&&f?p="good":p="mid";let b=Xe[p],S=c&&c>0?Math.min(b.maxLongEdge,c):b.maxLongEdge;return{tier:p,...b,maxLongEdge:S}}function we(e){let t={};try{let n=navigator;typeof n.deviceMemory=="number"&&(t.deviceMemory=n.deviceMemory);let r=n.connection;r&&(t.effectiveType=r.effectiveType,t.saveData=r.saveData,t.downlinkMbps=r.downlink)}catch{}return typeof e=="number"&&e>0&&(t.sourceLongEdge=e),Ve(t)}function Ye(e,t,n){let r=Math.min(1,Math.max(0,(e-.28)/.21999999999999997)),i=(t+n)/2;return Math.max(t,n-r*(n-i))}function Qe(e,t,n){let r=Math.max(e,t),i=r>0?Math.min(1,n/r):1;return{width:Math.max(1,Math.round(e*i)),height:Math.max(1,Math.round(t*i))}}async function Ke(e,t){let n=t.startQ,r=await e(n);for(let i=0;i<4&&!(r.size<=t.budgetBytes||n<=t.qMin);i++)n=Math.max(t.qMin,n-.08),r=await e(n);return{blob:r,quality:n}}async function Ce(e,t,n,r,i){if(t<=0||n<=0)return null;let{width:c,height:s}=Qe(t,n,r.maxLongEdge),u=document.createElement("canvas");u.width=c,u.height=s;let l=u.getContext("2d");if(!l)return null;l.drawImage(e,0,0,c,s);let f=B=>new Promise((h,w)=>{u.toBlob(d=>d?h(d):w(new Error("canvas toBlob returned null")),"image/jpeg",B)}),p=Ye(i,r.qMin,r.qMax),{blob:b,quality:S}=await Ke(f,{startQ:p,qMin:r.qMin,budgetBytes:r.payloadTargetBytes}).finally(()=>{u.width=0,u.height=0});if(b.size>5242880)throw new Error("encoded document exceeds the 5242880-byte media cap");return{blob:b,quality:S,width:c,height:s}}async function ee(e){let t=we(Math.max(e.width,e.height)),n=await Ce(e,e.width,e.height,t,.5);if(n===null)throw new Error("canvas encode unavailable");return{blob:n.blob,width:n.width,height:n.height}}async function ft(e){let t=await createImageBitmap(e);try{return await ee(t)}finally{t.close()}}var bt=250,ht=.6,yt=1800,St=6e3,Mt=2e3,Re=.16;function ne(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}}var xe=e=>e==="recto"?"verso":"recto",ve=e=>e.phase==="framing"||e.phase==="locking"||e.phase==="flipCue"||e.phase==="reaskRecto",re=e=>(e.captured.recto!==void 0?1:0)+(e.captured.verso!==void 0?1:0)+e.pending.length;function te(e,t){return e.lastCaptureAt>=0&&e.lastReportAt>=0?e:{...e,lastCaptureAt:e.lastCaptureAt<0?t:e.lastCaptureAt,lastReportAt:e.lastReportAt<0?t:e.lastReportAt}}function je(e,t,n){if(e.phase==="result")return{...e,lastReportAt:n};let r=!t.present||e.captureArea!==void 0&&t.areaFrac<.6*e.captureArea,{flipped:i,awaySince:c}=e;r&&(c=c??n),c!==void 0&&n-c>=250&&(i=!0),r||(c=void 0);let s=e.flipTimeoutSpent&&!(i&&!e.flipped),u={...e,lastReportAt:n,flipped:i,awaySince:c,flipTimeoutSpent:s,lastArea:t.areaFrac};if(!ve(e))return u;if(e.needFlip&&!i){if(!t.ready)return{...u,phase:e.restPhase,goodSince:void 0};let l=e.lastShot!==void 0&&e.pending.includes(e.lastShot);if(s||l)return{...u,goodSince:void 0,phase:e.restPhase};let f=e.goodSince??n;return n-f>=1800?{...u,goodSince:f,phase:"capturing",flipTimeoutSpent:!0,timeoutCapture:!0}:{...u,goodSince:f,phase:e.restPhase}}return t.ready?{...u,phase:"capturing",goodSince:e.goodSince??n}:{...u,goodSince:void 0,phase:t.locking?"locking":e.restPhase}}function $e(e,t){if(!ve(e)||e.manualShutter)return e;let n=t-e.lastReportAt>=2e3,r=t-e.lastCaptureAt>=6e3;return n||r?{...e,manualShutter:!0}:e}function Je(e,t,n){let r=e.layout==="singlePage",i=r?{recto:t}:e.captured,c=r?[]:[...e.pending,t],s={...e,captured:i,pending:c,lastShot:t,lastCaptureAt:n,lastReportAt:-1,manualShutter:!1,goodSince:void 0,notice:void 0,awaySince:void 0,flipped:!1,lastShotByTimeout:e.timeoutCapture,timeoutCapture:!1,captureArea:e.lastArea};return r||re({captured:i,pending:c})>=2?{...s,phase:"reading",restPhase:"framing",current:void 0,needFlip:!1}:{...s,phase:"flipCue",restPhase:"flipCue",current:void 0,needFlip:!0}}function Le(e,t,n){return e.pending.includes(t)?{...e,pending:e.pending.filter(r=>r!==t),lastShot:e.lastShot===t?void 0:e.lastShot,phase:e.phase==="capturing"?e.phase:"flipCue",restPhase:"flipCue",current:xe(n),needFlip:!0,flipTimeoutSpent:!0,goodSince:void 0,manualShutter:!0,notice:"same_face",lastCaptureAt:-1,lastReportAt:-1}:e}function Ze(e,t,n){if(!e.pending.includes(t))return e;if(e.captured[n]!==void 0)return Le(e,t,n);let r=e.pending.filter(l=>l!==t),i={...e,pending:r,captured:{...e.captured,[n]:t}};if(re(i)!==1||e.layout==="singlePage")return i;let c=xe(n),s=c==="recto"&&e.restPhase==="reaskRecto"?"reaskRecto":"flipCue",u=e.phase==="flipCue"||e.phase==="reaskRecto"||e.phase==="framing";return{...i,restPhase:s,current:c,phase:u?s:e.phase}}function et(e,t){let n=t.id??e.captured[t.side],r={...e.captured};(t.id===void 0||r[t.side]===t.id)&&delete r[t.side];let i=e.pending.filter(f=>f!==n),c=e.layout==="twoSided"&&re({captured:r,pending:i})>0,s=e.lastShotByTimeout||n===e.lastShot!==e.flipped,u=c&&!s,l=u?t.side==="recto"?"reaskRecto":"flipCue":"framing";return{...e,captured:r,pending:i,readSides:e.readSides.filter(f=>f!==t.side),lastShot:e.lastShot===n?void 0:e.lastShot,notice:t.issue,goodSince:void 0,manualShutter:!1,phase:l,restPhase:l,current:t.side,needFlip:u,flipped:!1,flipTimeoutSpent:!1,awaySince:void 0,lastCaptureAt:-1,lastReportAt:-1}}function Te(e,t){switch(t.type){case"report":return je(te(e,t.at),t.report,t.at);case"tick":return $e(te(e,t.at),t.at);case"captured":return Je(te(e,t.at),t.id,t.at);case"captureFailed":return{...e,phase:e.restPhase,goodSince:void 0,lastCaptureAt:t.at,manualShutter:!0,timeoutCapture:!1};case"classified":return Ze(e,t.id,t.side);case"duplicate":return Le(e,t.id,t.side);case"readOk":{let n=e.readSides.includes(t.side)?e.readSides:[...e.readSides,t.side],r=["recto","verso"].filter(c=>e.captured[c]!==void 0),i=e.phase==="reading"&&e.pending.length===0&&r.every(c=>n.includes(c));return{...e,readSides:n,flipTimeoutSpent:!1,phase:i?"result":e.phase}}case"readFailed":return et(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{...ne(e.layout,-1),lastCaptureAt:-1,lastReportAt:-1};default:return e}}function tt(e,t,n=!1){let r=e(t);return r===null?"recto":!n||r.y+r.height/2>=t.height/2?"verso":"recto"}async function nt(e,t=!1){let{detectMrzBand:n}=await import("./mrz-band-VYHOTDHY.js");return tt(n,e,t)}async function oe(e,t=480,n,r=n!=null){let i=n??{x:0,y:0,width:e.width,height:e.height},c=Math.max(1,Math.round(i.height/i.width*t)),s=document.createElement("canvas");s.width=t,s.height=c;try{let u=s.getContext("2d");return u===null?"recto":(u.drawImage(e,i.x,i.y,i.width,i.height,0,0,t,c),await nt(u.getImageData(0,0,t,c),r))}finally{s.width=0,s.height=0}}async function Dt(e,t=480){try{let n=await createImageBitmap(e),r=Math.max(1,Math.round(n.height/n.width*t)),i=document.createElement("canvas");i.width=t,i.height=r;let c=i.getContext("2d");return c===null?(n.close(),null):(c.drawImage(n,0,0,t,r),n.close(),c.getImageData(0,0,t,r))}catch{return null}}var ae=(e,t,n)=>Math.min(n,Math.max(t,Math.round(e))),Y=e=>Math.round(Math.min(1,Math.max(0,e))*1e4)/1e4;async function _e(e,t,n,r){let i=r.decode??(l=>createImageBitmap(l)),c=async()=>e.stillRead(await i(t),r.region??[0,0,1,1],r.detectorLimit),s;try{s=await c()}catch{try{await new Promise(l=>setTimeout(l,r.retryMs??300)),s=await c()}catch{return null}}let u=s.mrzBox;return u===void 0?null:{engine:r.engine,source:"live_mrz",format:n.format,lineCount:ae(n.lineCount,2,3),checkDigitsValid:!0,stillConfirmed:s.valid&&s.digest===n.digest,band:[Y(u[0]),Y(u[1]),Y(Math.min(u[2],1-u[0])),Y(Math.min(u[3],1-u[1]))],digest:n.digest,framesToValid:ae(n.framesToValid,1,1e3),msToValid:ae(n.msToValid,0,12e4)}}function Ct(e){let t=null;return e?.then(n=>{t=n}),()=>t}var rt=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]),ot=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 Ee(e,t=globalThis){let n=t.WebAssembly?.validate;if(typeof n!="function")return{ok:!1,reason:"simd"};try{if(!n.call(t.WebAssembly,rt)||!n.call(t.WebAssembly,ot))return{ok:!1,reason:"simd"}}catch{return{ok:!1,reason:"simd"}}if(typeof t.Worker!="function")return{ok:!1,reason:"worker"};if(typeof t.createImageBitmap!="function")return{ok:!1,reason:"bitmap"};let r=t.navigator?.deviceMemory;return typeof r=="number"&&r<e.minDeviceMemoryGb?{ok:!1,reason:"memory"}:{ok:!0}}function Oe(e=globalThis){let t=e.navigator?.connection;return t?.saveData===!0||["slow-2g","2g","3g"].includes(t?.effectiveType??"")}var _=class extends Error{constructor(t){super(t),this.name="OcrEngineError",this.code=t}};function Pe(){let e=t=>(t.close(),Promise.reject(new _("unsupported")));return{ready:Promise.resolve("unsupported"),busy:!1,bandRead:e,stillRead:e,layoutRead:e,dispose:()=>{}}}function Ae(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 Pe()}catch{return Pe()}let n=new Map,r=0,i=!1,c=!1,s=!1;t.addEventListener("message",d=>{let g=d.data,C=n.get(g.id);C&&(n.delete(g.id),C.resolve(g))});let u=()=>{for(let d of n.values())d.reject(new _("error"));n.clear(),f()};t.addEventListener("error",u),t.addEventListener("messageerror",u);function l(d,g=[]){if(i)return Promise.reject(new _("disposed"));let C=++r;return new Promise((A,O)=>{n.set(C,{resolve:A,reject:O});try{t.postMessage({...d,id:C},g)}catch{n.delete(C),O(new _("error"))}})}function f(){if(!i){i=!0;try{t.postMessage({id:++r,kind:"dispose"})}catch{}t.terminate();for(let d of n.values())d.reject(new _("disposed"));n.clear()}}let p=(async()=>{let d=await l({kind:"init",baseUrl:e.baseUrl,salt:e.salt,detectorLimit:e.tuning.detectorLimit,maxDownloadMs:e.tuning.maxDownloadMs});if(d.kind==="failed")return d.reason;if(d.kind!=="ready")return"error";let g=await l({kind:"warmup"});return g.kind!=="ready"?"error":{warmupMs:g.warmupMs,downloadMs:d.downloadMs,cached:d.cached}})().catch(()=>"error"),b,S=new Promise(d=>{b=setTimeout(()=>d("timeout"),e.tuning.loadTimeoutMs)}),B=Promise.race([p,S]).then(d=>(clearTimeout(b),typeof d=="string"?f():s=!0,i&&typeof d!="string"?"error":d));(e.page===void 0?globalThis.addEventListener?globalThis:null:e.page)?.addEventListener("pagehide",f,{once:!0});async function w(d,g,C){if(i)throw g.close(),new _("disposed");if(!s)throw g.close(),new _("not_ready");if(c)throw g.close(),new _("busy");c=!0;let A;try{let O=new Promise((Q,M)=>{A=setTimeout(()=>{M(new _("timeout")),f()},e.tuning.readTimeoutMs??1e4)}),P=await Promise.race([l(d,[g]),O]);if(P.kind===C){let{id:Q,...M}=P;return M}throw new _(P.kind==="error"?P.code:P.kind==="failed"?P.reason:"error")}finally{clearTimeout(A),c=!1}}return{ready:B,get busy(){return c},bandRead:(d,g=e.tuning.detectorLimit)=>w({kind:"band",bitmap:d,detectorLimit:g},d,"band"),stillRead:(d,g,C=e.tuning.detectorLimit)=>w({kind:"still",bitmap:d,region:g,detectorLimit:C},d,"band"),layoutRead:(d,g)=>w({kind:"layout",bitmap:d,detectorLimit:g},d,"layout"),dispose:f}}var U="sekyro-ocr-1",ie=e=>e!==null&&typeof e=="object"?e:{},v=(e,t,n,r)=>typeof e=="number"&&Number.isFinite(e)&&e>=t&&e<=n?e:r,Be=(e,t)=>typeof e=="boolean"?e:t,Ie=e=>{let t=typeof e=="string"?/^sekyro-ocr-(\d{1,4})$/.exec(e):null;return t?Number(t[1]):Number.POSITIVE_INFINITY};function We(e,t={}){let n=ie(e),r=ie(n.liveMrz),i=ie(n.frontLock),c=Ie(t.engine??U),s=t.mode==="off",u=d=>d.enabled===!0?d.arm==="live"?"live":"control":null,l=u(r),f=u(i),p=(d,g)=>!s&&g==="live"&&Ie(d.minEngine??U)<=c,b=ke,S=p(r,l)?{detectorLimit:v(r.detectorLimit,320,1600,b.detectorLimit),bandMaxWidthPx:v(r.bandMaxWidthPx,320,4096,b.bandMaxWidthPx),minBandWidthPx:v(r.minBandWidthPx,0,4096,b.minBandWidthPx),bandTop:v(r.bandTop,0,.95,b.bandTop),minIntervalMs:v(r.minIntervalMs,0,5e3,b.minIntervalMs),stableReads:Math.round(v(r.stableReads,1,10,b.stableReads)),profileReads:Math.round(v(r.profileReads,1,100,b.profileReads)),maxReadMs:v(r.maxReadMs,50,6e4,b.maxReadMs),searchTimeoutMs:v(r.searchTimeoutMs,1e3,12e4,b.searchTimeoutMs),hint:Be(r.hint,!0),stillConfirm:Be(r.stillConfirm,!0)}:null,B=Me,h=(d,g,C)=>v(i[d],g,C,B[d]),w=p(i,f)?{minLines:Math.round(h("minLines",1,50)),fillMin:h("fillMin",0,1),fillMax:h("fillMax",0,2),offsetMax:h("offsetMax",0,1),steadyFillDelta:h("steadyFillDelta",0,1),steadyOffsetDelta:h("steadyOffsetDelta",0,1),layoutShiftMax:h("layoutShiftMax",0,1),lineCountDelta:Math.round(h("lineCountDelta",0,50)),lockMs:h("lockMs",0,3e4),steadyMs:h("steadyMs",0,3e4),minFrames:Math.round(h("minFrames",1,100)),minIntervalMs:h("minIntervalMs",0,5e3),maxWidthPx:h("maxWidthPx",160,2048),detectorLimit:h("detectorLimit",320,1600),searchTimeoutMs:h("searchTimeoutMs",1e3,12e4)}:null;return{enabled:S!==null||w!==null,liveMrz:S,textLock:w,liveMrzArm:l,frontLockArm:f,load:{detectorLimit:S?.detectorLimit??w?.detectorLimit??b.detectorLimit,loadTimeoutMs:v(r.loadTimeoutMs,1e3,12e4,2e4),maxDownloadMs:v(r.maxDownloadMs,1e3,12e4,2e4),minDeviceMemoryGb:v(r.minDeviceMemoryGb,0,64,2)},reportSampleRate:v(r.reportSampleRate,0,1,1)}}function Fe(e,t){return e.enabled?!(t.probe??Ee)({minDeviceMemoryGb:e.load.minDeviceMemoryGb}).ok||(t.slow??Oe)()?{ok:!1,reason:"unsupported"}:{ok:!0,engine:Ae({baseUrl:t.baseUrl,salt:t.salt,tuning:{detectorLimit:e.load.detectorLimit,maxDownloadMs:e.load.maxDownloadMs,loadTimeoutMs:e.load.loadTimeoutMs},...t.workerUrl!==void 0?{workerUrl:t.workerUrl}:{},...t.createWorker!==void 0?{createWorker:t.createWorker}:{},...t.page!==void 0?{page:t.page}:{}})}:{ok:!1,reason:"off"}}function at(e=typeof navigator<"u"?navigator.userAgent:""){return/SamsungBrowser\//.test(e)?"samsung":/Firefox\/|FxiOS\//.test(e)?"firefox":/Chrome\/|CriOS\/|Chromium\//.test(e)&&!/Edg\/|OPR\//.test(e)?"chrome":/Safari\//.test(e)&&/Version\/|Mobile\//.test(e)&&!/Chrome\/|CriOS\//.test(e)?"safari":"other"}var W=e=>e===void 0||!Number.isFinite(e)?void 0:Math.min(6e5,Math.max(0,Math.round(e))),se=(e,t,n)=>e===void 0||!Number.isFinite(e)?void 0:Math.min(n,Math.max(t,Math.round(e)));function ze(e){let t=e.assist??null,n=e.load!==null&&e.load!==void 0&&typeof e.load=="object"?e.load:null,r=typeof e.load=="string"?e.load:null,i=t!==null?t.outcome:r==="unsupported"||r==="download"||r==="integrity"?r:r==="error"||r==="timeout"?"error":"off",c={kind:"live_mrz",platform:"web",engine:e.engine??U,arm:e.arm,capture:e.capture,outcome:i,reads:se(t?.reads??0,0,1e4)??0,browser:e.browser??at()},s=(u,l)=>{l!==void 0&&(c[u]=l)};return s("format",t?.format),s("framesToValid",se(t?.framesToValid,1,1e4)),s("msToValid",W(t?.msToValid)),s("framesToLock",se(t?.framesToLock,1,1e4)),s("msToLock",W(t?.msToLock)),s("msToCapture",W(e.msToCapture)),s("readP50Ms",W(t?.readP50Ms)),s("readP90Ms",W(t?.readP90Ms)),s("deviceClass",t?.deviceClass),n!==null&&(s("warmupMs",W(n.warmupMs)),s("downloadMs",W(n.downloadMs)),s("cached",n.cached)),s("stillConfirmed",e.stillConfirmed),s("typeMismatch",e.typeMismatch),c}function ue(e,t){return e===void 0?!1:t==="passport"?e!=="TD3":e==="TD3"}var it=2;async function st(e){let t=await import("./capture-session-doc-FRBI7OKF.js");return new t.CaptureSessionDoc(e)}function ut(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}}}function ct(e,t,n){let r=[e.topLeft,e.topRight,e.bottomRight,e.bottomLeft],i=0;for(let c=0;c<r.length;c+=1){let s=r[c],u=r[(c+1)%r.length];i+=s.x*u.y-u.x*s.y}return t>0&&n>0?Math.abs(i)/2/(t*n):0}function Ht(){import("./capture-session-doc-FRBI7OKF.js").then(e=>e.warmDocDetector()).catch(()=>{})}function Xt(e){return lt(e,{}).handle}function lt(e,t){let n=ge(),r=be({enabled:e.keepScreenAwake!==!1}),i=t.decode??(o=>createImageBitmap(o)),c=t.blurRefuseSharpnessMax??.16,s=t.now??(()=>performance.now()),u=e.documentType==="passport"||e.side==="single",l=ne(u?"singlePage":"twoSided",s());if(!u&&(e.side==="recto"||e.side==="verso")){let o=e.side==="recto"?"verso":"recto";l={...l,captured:{[o]:"server"},readSides:[o],current:e.side,phase:"flipCue",restPhase:"flipCue"}}let f="idle",p=null,b=null,S=!0,B=0,h=0,w=!1,d=!1,g="",C=null,A,O=null,P=[],Q=he.find(o=>o.docType===e.documentType)?.mrz==="none",M=t.webOcr!==void 0&&!Q?We(t.webOcr.captureDocument,{mode:e.liveMrz?.mode??"auto"}):null,N=null,F=M===null||!M.enabled?"off":null,G=null,q=null,ce=new WeakMap,K="";if(M!==null&&M.enabled&&t.webOcr!==void 0){let o=t.webOcr,a=Fe(M,{baseUrl:e.liveMrz?.assetBaseUrl??o.baseUrl,salt:o.salt,...e.liveMrz?.workerUrl!==void 0?{workerUrl:e.liveMrz.workerUrl}:{},...o.createWorker!==void 0?{createWorker:o.createWorker}:{}});if(a.ok){N=a.engine;let m=new De({textLock:M.textLock,liveMrz:M.liveMrz});G=m;let y=a.engine;y.ready.then(L=>{F=L,typeof L!="string"&&S&&m.setEngine(y)})}else F=a.reason}let z=o=>{let a=JSON.stringify(o);a!==K&&(K=a,n.emit("mrz",o))},le=(o,a)=>{let m=t.webOcr?.reports;if(m===void 0||M===null||o===void 0)return;let y=o.format==="ID-3"||o.side==="single"?"single":o.side==="verso"?"verso":"recto",L=y!=="recto"?M.liveMrzArm??M.frontLockArm:M.frontLockArm;if(L===null||Math.random()>=M.reportSampleRate)return;let T=o.via==="live_mrz"?q:null,x=()=>{let E=T?.value??null;m([ze({arm:L,capture:y,assist:o.ocr??null,load:L==="control"?"off":F,...o.msToCapture!==void 0?{msToCapture:o.msToCapture}:{},...E!==null&&E.stillConfirmed!==void 0?{stillConfirmed:E.stillConfirmed}:{},...a!==void 0?{typeMismatch:ue(a.format,e.documentType==="passport"?"passport":"card")}:{}})])};T!==null&&T.value===null?Promise.race([T.promise,new Promise(E=>setTimeout(E,3e3))]).then(x):x()},I=o=>{!S||o===f||(f=o,r.setActive(o==="starting"||o==="scanning"),n.emit("state",o))},Ne=(o,a)=>a===void 0?null:u?"single":o.captured.recto===a?"recto":o.captured.verso===a?"verso":null,Ue=o=>({phase:o.phase,captured:u?o.captured.recto!==void 0?["single"]:[]:["recto","verso"].filter(a=>o.captured[a]!==void 0),expected:u?null:o.current??null,notice:o.notice??null,lastShot:Ne(o,o.lastShot),manualShutter:o.manualShutter,torchAvailable:p?.torchAvailable()??!1,torch:d}),de=()=>{let o=p;o!==null&&o.captureNow().catch(()=>R({type:"captureFailed",at:s()}))};function R(o){if(!S)return;let a=l;l=Te(l,o),l.phase==="capturing"&&a.phase!=="capturing"&&Promise.resolve().then(de),l.phase==="result"&&a.phase!=="result"&&(I("done"),me());let m=Ue(l),y=JSON.stringify(m);y!==g&&(g=y,n.emit("scan",m))}function me(){O!==null&&clearInterval(O),O=null;for(let o of P.splice(0))o();p?.destroy(),p=null,r.setActive(!1)}let pe=()=>p?.captureReport?.(),j=!1,fe=(o,a)=>{if(!(o===void 0||t.onFaceReport===void 0))try{t.onFaceReport(o,a)}catch{}},H=o=>{K="",!(p===null||l.phase==="reading"||l.phase==="result")&&(j=!1,p.rearm(u?"single":l.current??o))},Ge=async(o,a,m,y)=>{if(q=null,y!==void 0&&N!==null&&M?.liveMrz?.hint===!0){let k={promise:_e(N,o,y,{engine:U,detectorLimit:M.liveMrz.detectorLimit}).catch(()=>null),value:null};k.promise.then(D=>{k.value=D}),q=k}y!==void 0&&ue(y.format,e.documentType==="passport"?"passport":"card")&&z({state:"mismatch",format:y.format});let L=pe();fe(L,"captured"),j=!0,le(L,y);let T=m===void 0?C:m===null?null:{quad:ut(m),frameWidth:0,frameHeight:0,inStill:!0},x={decoded:null},E=()=>(x.decoded??(x.decoded=Promise.resolve().then(()=>i(o)).catch(()=>null)),x.decoded);try{await qe(o,a,T,E,q)}finally{x.decoded!==null&&(await x.decoded)?.close()}},qe=async(o,a,m,y,L)=>{let T=`shot-${B+=1}`;if(R({type:"captured",id:T,at:s()}),e.haptics!==!1)try{globalThis.navigator?.vibrate?.(30)}catch{}if(!w&&c>0){let k=await(t.measureSharpness!==void 0?t.measureSharpness(o,m):y().then(D=>D===null?-1:Se(D,Z(m?.quad??null,m?.inStill===!0?D:{width:m?.frameWidth??0,height:m?.frameHeight??0},D)))).catch(()=>-1);if(!S)return;if(Number.isFinite(k)&&k>=0&&k<c){w=!0;let D=u?"recto":l.current??(l.captured.recto===void 0?"recto":"verso");R({type:"readFailed",side:D,id:T,issue:"blurry"}),H(D);return}}w=!1;let x;if(u)x="single";else{let k=l.current,D=await(t.classify!==void 0?t.classify(o):y().then(X=>X===null?k??"recto":m?.inStill===!0?oe(X,480,null,!0):oe(X,480,Z(m?.quad??null,{width:m?.frameWidth??0,height:m?.frameHeight??0},X)))).catch(()=>k??"recto");if(!S)return;if(l.captured[D]!==void 0&&h<it){h+=1,R({type:"duplicate",id:T,side:D}),H(D==="recto"?"verso":"recto");return}x=l.captured[D]!==void 0&&k!==void 0?k:D,h=0,R({type:"classified",id:T,side:x})}let E=x==="verso"?"verso":"recto";try{let k=t.encode!==void 0?await t.encode(o):await y().then(D=>{if(D===null)throw new Error("the still could not be decoded");return ee(D)});if(!S)return;L!==null&&ce.set(k.blob,L),n.emit("captured",{image:k.blob,side:x,documentType:e.documentType,...e.issuer!==void 0?{issuer:e.issuer}:{},width:k.width,height:k.height,previewDataUrl:a}),t.deferRead!==!0&&R({type:"readOk",side:E})}catch(k){R({type:"readFailed",side:E,id:T,issue:"technical"}),n.emit("error",V("generic",!0,{phase:"keyframes",name:J(k)}))}H(E==="recto"?"verso":"recto")},He=o=>{P.push(o.on("statechange",({state:a})=>{a==="preflight"||a==="acquiring"?I("starting"):a==="positioning"?I("scanning"):a==="captured"?I("captured"):a==="error"&&I("error")}),o.on("feedback",({key:a,reticle:m})=>n.emit("feedback",{key:a,reticle:m})),o.on("checks",a=>{n.emit("gate",{progress:a.p,quad:a.quad,frameWidth:a.frameWidth,frameHeight:a.frameHeight,...a.guide!==void 0?{guide:{detected:a.guide.detected,fill:a.guide.fill,offsetX:a.guide.offsetX??0,offsetY:a.guide.offsetY??0}}:{}});let m=a.ocr?.mrz;m!==void 0&&(m.state==="fallback"?z({state:"fallback",reason:m.reason}):m.state==="valid"?z({state:"valid",format:m.format}):m.state==="reading"?z({state:"reading",...m.format?{format:m.format}:{},...m.coach?{coach:m.coach}:{}}):z({state:"searching"}));let y=a.quad===null?0:ct(a.quad,a.frameWidth,a.frameHeight);C=a.quad===null?null:{quad:a.quad,frameWidth:a.frameWidth,frameHeight:a.frameHeight},R({type:"report",report:{present:a.quad!==null&&a.plausible||a.guide?.detected===!0,ready:a.ready===!0,locking:a.p>=.5,areaFrac:y},at:s()})}),o.on("error",({kind:a,retryable:m,detail:y})=>n.emit("error",V(a,m,y))),o.on("artifacts",a=>{Ge(a.keyframe,a.previewDataUrl,a.docRegion,a.liveMrz)}))},$=()=>(b??(b=(async()=>{if(S){if(p===null){let o;try{o=await(t.createEngine??st)({...t.engineOptions??{},...A!==void 0?{guide:A}:{},video:e.video,format:ye(e.documentType),side:u?"single":e.side??"recto",autoCapture:!1,...G!==null?{ocr:G}:{}})}catch(m){I("error"),n.emit("error",V("models",!0,{phase:"models",name:J(m)}));return}if(!S){o.destroy();return}p=o,He(o);let a=t.tickMs??500;a>0&&(O=setInterval(()=>R({type:"tick",at:s()}),a))}R({type:"clockRestart"}),M!==null&&M.liveMrzArm==="live"&&(F==="unsupported"||F==="off")&&z({state:"fallback",reason:F}),await p.start()}})().finally(()=>{b=null})),b);return{handle:{get state(){return f},on:(o,a)=>n.on(o,a),start:$,retry:()=>{if(p===null&&l.phase==="result"){R({type:"retake"}),h=0,w=!1,$();return}if(p!==null&&f!=="error"){R({type:"retake"}),h=0,w=!1,p.rearm(u?"single":void 0);return}$()},setSide:o=>{u||o==="single"||(l.current!==o&&(l={...l,current:o}),R({type:"clockRestart"}),l.phase!=="reading"&&l.phase!=="result"&&p?.rearm(o))},shutter:de,focusAt:(o,a)=>{p?.focusAt?.(o,a)},setGuide:o=>{A=o,p?.setGuide?.(o)},setTorch:o=>{d=o,p?.setTorch(o),R({type:"tick",at:s()})},destroy:()=>{if(S&&p!==null&&f!=="done"){let o=pe();!j&&o!==void 0&&o.ticks>0&&fe(o,"abandoned"),le(o,void 0)}S=!1,me(),G?.setEngine(null),N?.dispose(),N=null,n.clear()}},setFlowState:o=>{(l.phase==="reading"||l.phase==="result")&&I(o==="done"&&l.phase!=="result"?"scanning":o)},settle:(o,a)=>{let m=o==="verso"?"verso":"recto";R(a.ok?{type:"readOk",side:m}:{type:"readFailed",side:m,issue:a.issue}),a.ok||H(m)},takeDeviceRead:o=>ce.get(o.image)?.value??null}}export{ft as a,bt as b,ht as c,yt as d,St as e,Mt as f,Re as g,ne as h,Te as i,tt as j,nt as k,Dt as l,_e as m,Ct as n,U as o,We as p,Fe as q,at as r,ze as s,ue as t,it as u,Ht as v,Xt as w,lt as x};
|
package/dist/chunk-ZCOWTM46.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as re,b as ne}from"./chunk-SX7TUC3V.js";import{b as le,c as ce,d as ue}from"./chunk-POIQGEZM.js";import{a as Q,c as Y,e as j,g as $,h as A,k as R,m as J,n as te}from"./chunk-CPUECYAJ.js";import{b as G,c as de,d as L,e as pe}from"./chunk-FPXL63KZ.js";import{a as q,c as z,d as X,e as Z}from"./chunk-TSA6GHUG.js";import{d as ee}from"./chunk-U3JUGEIW.js";import{e as ie,f as ae,h as x,j as se,l as oe}from"./chunk-FSSMUAKC.js";var Ie=[...Q.filter(i=>i.startsWith("video/mp4")),"video/webm;codecs=h264","video/webm;codecs=avc1","video/webm;codecs=vp8","video/webm;codecs=vp9","video/webm"],me=new Set;function De(i){let e=/(?:Chrome|Chromium)\/(\d+)\./.exec(i??"");return e?Number(e[1]):null}function he(i=Oe(),e=globalThis.navigator?.userAgent){if(i===void 0)return"";let t=De(e)===126;for(let r of Ie)if(!(me.has(r)||t&&r.startsWith("video/mp4")))try{if(i(r))return r}catch{}return""}function F(i){i!==""&&me.add(i)}function fe(i){return i.replace(/^video\/x-matroska/i,"video/webm")}function ut(i){let e=/codecs=["']?([^,;"']+)/i.exec(i);return e?e[1].trim():i.split(";")[0].trim()}function Oe(){let i=globalThis.MediaRecorder;return i&&typeof i.isTypeSupported=="function"?e=>i.isTypeSupported(e):void 0}var N=2500,Pe=1e3,xe=1500,ve=25e5,Ge=100,Le=700,Fe=20,Ve=1500,V=null;function Ne(){return V??(V=import("./clip-inspect-DLJXVKV6.js").catch(i=>{throw V=null,i})),V.catch(()=>null)}var S=class extends Error{constructor(e,t){super(t??e),this.kind=e}},Ue=100;function U(i,e){return i.stats===void 0?!1:i.stats===null?!0:i.stats.durationMs<e-Ue}function ge(i,e){return i.stats?e.stats?i.stats.durationMs>e.stats.durationMs:!0:!1}var I=class{constructor(e={}){this.recorder=null;this.stream=null;this.chunks=[];this.bytes=0;this.hardStopTimer=null;this.graceTimer=null;this.pollTimer=null;this.settled=!1;this.now=e.now??(()=>globalThis.performance?.now?.()??Date.now())}clearTimers(){this.hardStopTimer&&clearTimeout(this.hardStopTimer),this.graceTimer&&clearTimeout(this.graceTimer),this.pollTimer&&clearInterval(this.pollTimer),this.hardStopTimer=null,this.graceTimer=null,this.pollTimer=null}record(e,t,r,n=N,a){let s=he(),o=Ne();return this.recordRaw(e,t,r,n,a,s).then(c=>He(c,o),c=>{throw c instanceof S&&(c.requestedMimeType=s),c})}recordRaw(e,t,r,n,a,s){return this.recorder&&!this.settled?Promise.reject(new S("generic","record() called while a recording is in flight \u2014 ClipRecorder handles one recording at a time")):(this.recorder=null,this.clearTimers(),this.chunks=[],this.bytes=0,this.settled=!1,this.stream=e,new Promise((o,c)=>{let l;try{l=new MediaRecorder(e,s?{mimeType:s,videoBitsPerSecond:ve}:{videoBitsPerSecond:ve})}catch{try{l=new MediaRecorder(e)}catch{c(new S("unsupported"));return}}this.recorder=l;let d=h=>{this.settled||(this.settled=!0,this.clearTimers(),h())},u=()=>d(()=>{let h=fe(l.mimeType||s||Y),b=new Blob(this.chunks,{type:h});if(b.size===0){c(new S("generic","empty clip"));return}if(A(b)){c(new S("cliptoolarge"));return}o({blob:b,mimeType:h,requestedMimeType:s})});l.ondataavailable=h=>{h.data&&h.data.size&&(this.chunks.push(h.data),this.bytes+=h.data.size,this.bytes>$&&d(()=>{try{l.state!=="inactive"&&l.stop()}catch{}c(new S("cliptoolarge"))}))},l.onstop=u,l.onerror=()=>d(()=>c(new S("generic")));let f=this.now();if(r!==void 0||a!==void 0){let h=!1;l.onstart=()=>{if(!(h||this.settled)&&(h=!0,f=this.now(),r!==void 0))try{r()}catch{}}}try{l.start(Pe)}catch{d(()=>c(new S("generic")));return}let v=()=>{if(this.pollTimer&&clearInterval(this.pollTimer),this.pollTimer=null,this.hardStopTimer&&clearTimeout(this.hardStopTimer),this.hardStopTimer=null,this.settled||t?.(),l.state!=="inactive"){try{l.stop()}catch{u()}this.graceTimer=setTimeout(u,xe)}else u()},p=this.now();if(a===void 0){this.hardStopTimer=setTimeout(v,n);return}let m=null,y=!1;this.hardStopTimer=setTimeout(v,n+Le),this.pollTimer=setInterval(()=>{if(this.settled||y)return;let h=null;try{h=a.latest()}catch{h=null}let b=h?.presentationTimeMs;b!==void 0&&Number.isFinite(b)&&b>=f&&m===null&&(m=b);let C=m!==null&&b!==void 0&&b-m>=n,E=m===null&&this.now()-p>=n;if(!(!C&&!E)){if(y=!0,this.pollTimer&&clearInterval(this.pollTimer),this.pollTimer=null,E){v();return}this.hardStopTimer&&clearTimeout(this.hardStopTimer),this.hardStopTimer=setTimeout(v,Ge)}},Fe)}))}stop(e){this.clearTimers();let t=this.recorder;if(t&&t.state!=="inactive")try{t.stop()}catch{}this.recorder=null,(e??this.stream)?.getTracks().forEach(n=>n.stop()),this.stream=null}};async function He(i,e){let t,r=new Promise(l=>{t=setTimeout(()=>l(null),Ve)}),n=await Promise.race([e,r]);if(clearTimeout(t),n===null)return i;let a;try{a=await n.blobBytes(i.blob)}catch{return{...i,stats:null}}let s=n.inspectClipBytes(a);if(s?.container!=="webm")return{...i,stats:s};let o=n.withWebmDuration(a,s.durationMs);if(o===null)return{...i,stats:s};let c=n.inspectClipBytes(o);return c===null||c.frames!==s.frames||c.durationMs!==s.durationMs?{...i,stats:s}:{...i,blob:new Blob([o],{type:i.blob.type}),stats:s}}var Ke=["magenta","yellow","green","blue"];var Be={magenta:"rgb(255, 72, 150)",yellow:"rgb(255, 190, 0)",green:"rgb(0, 238, 175)",blue:"rgb(25, 150, 255)",dark:"rgb(0, 0, 0)"};function ft(i){return Be[i]}var We=4,qe=4,D=i=>typeof i=="number"&&Number.isFinite(i);function be(i){if(typeof i!="object"||i===null)return!1;let e=i;if(typeof e.nonce!="string"||e.nonce.length===0||!Array.isArray(e.colours)||e.colours.length<1||e.colours.length>8||!e.colours.every(r=>Ke.includes(r))||!Array.isArray(e.onsetsMs)||e.onsetsMs.length!==e.colours.length)return!1;let t=-1;for(let r of e.onsetsMs){if(!D(r)||r<0||r<=t)return!1;t=r}return!(!D(e.holdMs)||e.holdMs<=0||!D(e.endMs)||e.endMs<=t||!D(e.clipMs)||e.clipMs<e.endMs||e.clipMs>8e3)}function ye(i,e){return be(i)?Math.max(e,Math.ceil(i.clipMs)):e}function Me(i,e){let t=e.now??(()=>performance.now()),r=be(i)?i:void 0,n=[],a=null,s=null,o=null,c=!1,l=null,d=p=>{l=p;try{e.paint(p)}catch{}},u=p=>{let m=e.frames?.()??null;return m!==null&&o!==null?m.mediaTimeMs+(p-m.presentationTimeMs)-o:p-(s??p)},f=(p,m,y=0)=>{if(c)return;let h=Math.max(0,p-u(t()));a=setTimeout(()=>{if(a=null,!c){if(y<We&&u(t())<p-qe){f(p,m,y+1);return}m()}},h)},v=p=>{if(r===void 0)return;let m=r.endMs;if(p>=r.colours.length){f(m,()=>d(null));return}let y=r.onsetsMs[p],h=p+1<r.onsetsMs.length?r.onsetsMs[p+1]:m;f(y,()=>{let b=u(t());if(b>m){l!==null&&d(null);return}let C=r.colours[p];d(C);let E=n.length===0?0:n[n.length-1].tMs;n.push({tMs:Math.max(E,Math.round(b)),colour:C});let M=y+r.holdMs;if(M<h){f(M,()=>{if(u(t())>m){l!==null&&d(null);return}d("dark"),v(p+1)});return}v(p+1)})};return{started(p){if(r===void 0||c||s!==null)return;s=p;let m=e.frames?.()??null;o=m===null?null:m.mediaTimeMs+(p-m.presentationTimeMs),v(0)},stop(){c||(c=!0,a!==null&&clearTimeout(a),a=null,l!==null&&d(null))},report(){return r===void 0?void 0:{nonce:r.nonce,rendered:[...n]}}}}function Se(i,e,t=.92){return new Promise((r,n)=>{let a=i.videoWidth,s=i.videoHeight;if(!a||!s){n(new Error("video-not-ready"));return}let o=e.getContext("2d");if(!o){n(new Error("no-2d-context"));return}e.width=a,e.height=s,o.scale(-1,1),o.drawImage(i,-a,0),e.toBlob(c=>c?r(c):n(new Error("empty-keyframe")),"image/jpeg",t)})}var O=class{constructor(e){this.timer=null;this.frameCallbackId=null;this.running=!1;this.busy=!1;this.lastRunAt=Number.NEGATIVE_INFINITY;this.degradeCount=0;this.durations=[];this.options=e,this.periodMs=1e3/e.cadenceHz}start(){if(this.running)return;this.running=!0;let e=this.options.video;if(typeof e?.requestVideoFrameCallback=="function"){let t=()=>{this.running&&(this.frameCallbackId=e.requestVideoFrameCallback?.(()=>{this.frameCallbackId=null,this.now()-this.lastRunAt>=this.periodMs&&this.tick(),t()}))};t();return}this.timer=setInterval(()=>this.tick(),this.periodMs)}stop(){this.running=!1,this.timer!==null&&(clearInterval(this.timer),this.timer=null),this.frameCallbackId!==null&&(this.options.video?.cancelVideoFrameCallback?.(this.frameCallbackId),this.frameCallbackId=null)}stats(){let e=this.durations.length===0?0:this.durations.reduce((t,r)=>t+r,0)/this.durations.length;return{degradeCount:this.degradeCount,meanDetectMs:e}}now(){return this.options.now?.()??performance.now()}tick(){if(!this.running)return;if(this.busy){this.degradeCount+=1;return}this.busy=!0,this.lastRunAt=this.now();let e=this.now();this.options.run().catch(()=>{}).finally(()=>{this.busy=!1,this.durations.push(this.now()-e),this.durations.length>20&&this.durations.shift()})}};var ze=Object.freeze({Q_GOOD:.6,RISE_PER_S:.9,FALL_PER_S:.25,CENTER_FALLOFF_IOD_MULTIPLE:1.35,BOX_EYE_OFFSET_FACTOR:.12,IOD_BOX_PROXY_FACTOR:.42,SIZE_IDEAL_MIN:.12,SIZE_IDEAL_MAX:.3,SIZE_HARD_MIN:.08,SIZE_HARD_MAX:.45,ROLL_MAX_DEG:25,MOTION_VELOCITY_IOD_PER_S:.5,MOTION_TAU_S:.4,MOTION_DEADBAND_IOD_PER_S:.1,READY_WINDOW_MS:500,GUIDE_SIZE:.6,GUIDE_CENTERING:.6,GUIDE_POSE:.6,GUIDE_EXPOSURE:.6,GUIDE_SHARPNESS:.35,GUIDE_MOTION:.5}),_=i=>Math.min(1,Math.max(0,i)),k=class{constructor(e={}){this.p=0;this.lastTickAt=null;this.lastCenter=null;this.velocityEma=0;this.qWindow=[];this.lastSizeDirection="ideal";this.t={...ze,...e}}reset(){this.p=0,this.lastTickAt=null,this.lastCenter=null,this.velocityEma=0,this.qWindow=[],this.lastSizeDirection="ideal"}tick(e){let{observation:t,quality:r,timestampMs:n}=e,a=this.lastTickAt===null?0:Math.max(0,(n-this.lastTickAt)/1e3);this.lastTickAt=n;let s={presence:0,single:1,centering:0,size:0,pose:0,sharpness:_(r.sharpness),exposure:_(r.exposure),motion:1};if(t!==null){s.presence=1,s.single=(t.extraFaces??0)>0?0:1;let d=this.geometryOf(t,e);s.centering=d.centering,s.size=d.size,s.pose=d.pose,s.motion=this.motionOf(d.center,d.iod,n)}else this.lastCenter=null,this.velocityEma=0;let o=Math.min(s.presence,s.single,s.centering,s.size,s.pose,s.sharpness,s.exposure,s.motion);this.p=_(this.p+(o>=this.t.Q_GOOD?this.t.RISE_PER_S*o:-this.t.FALL_PER_S*(1-o))*a),this.qWindow.push({at:n,q:o}),this.qWindow=this.qWindow.filter(d=>d.at>=n-this.t.READY_WINDOW_MS);let c=this.qWindow.map(d=>d.q);if(c.length>=3){let d=Math.min(...c),u=c.indexOf(d);c=c.filter((f,v)=>v!==u)}let l=this.p>=1&&c.every(d=>d>=this.t.Q_GOOD);return{at:n,q:o,p:this.p,factors:s,guidanceKey:this.guidanceOf(s,r,o),ready:l,accepted:o>=this.t.Q_GOOD}}geometryOf(e,t){let{box:r,eyes:n}=e,a={x:t.frameWidth/2,y:t.frameHeight/2},s=Math.min(t.frameWidth,t.frameHeight),o=n!==void 0?{x:(n.left.x+n.right.x)/2,y:(n.left.y+n.right.y)/2}:{x:r.x+r.width/2,y:r.y+r.height/2-this.t.BOX_EYE_OFFSET_FACTOR*r.height},c=n!==void 0?Math.hypot(n.right.x-n.left.x,n.right.y-n.left.y):this.t.IOD_BOX_PROXY_FACTOR*r.width,l=Math.hypot(o.x-a.x,o.y-a.y),d=c<=0?0:1-_(l/(this.t.CENTER_FALLOFF_IOD_MULTIPLE*c)),u=s>0?c/s:0;this.lastSizeDirection=u<this.t.SIZE_IDEAL_MIN?"far":u>this.t.SIZE_IDEAL_MAX?"close":"ideal";let f;u<this.t.SIZE_HARD_MIN||u>this.t.SIZE_HARD_MAX?f=0:u<this.t.SIZE_IDEAL_MIN?f=(u-this.t.SIZE_HARD_MIN)/(this.t.SIZE_IDEAL_MIN-this.t.SIZE_HARD_MIN):u>this.t.SIZE_IDEAL_MAX?f=(this.t.SIZE_HARD_MAX-u)/(this.t.SIZE_HARD_MAX-this.t.SIZE_IDEAL_MAX):f=1;let v=1;if(n!==void 0){let p=Math.abs(Math.atan2(n.right.y-n.left.y,n.right.x-n.left.x))*180/Math.PI;v=1-_(p/this.t.ROLL_MAX_DEG)}return{center:o,iod:c,centering:d,size:f,pose:v}}motionOf(e,t,r){let n=this.lastCenter;if(this.lastCenter={...e,at:r},n===null||t<=0)return 1;let a=(r-n.at)/1e3;if(a<=0)return 1;let s=Math.hypot(e.x-n.x,e.y-n.y)/t/a;s<=this.t.MOTION_DEADBAND_IOD_PER_S&&(s=0);let o=1-Math.exp(-a/this.t.MOTION_TAU_S);return this.velocityEma=o*s+(1-o)*this.velocityEma,1-_(this.velocityEma/this.t.MOTION_VELOCITY_IOD_PER_S)}guidanceOf(e,t,r){if(e.presence<=0)return"fcv3.no_face";if(e.single<=0)return"fcv3.one_face";if(e.size<this.t.GUIDE_SIZE)return this.sizeGuidance();if(e.centering<this.t.GUIDE_CENTERING)return"fcv3.center_face";if(e.pose<this.t.GUIDE_POSE)return"fcv3.straighten";if(e.exposure<this.t.GUIDE_EXPOSURE)return this.exposureGuidance(t);if(e.sharpness<this.t.GUIDE_SHARPNESS)return"fcv3.steady_camera";if(e.motion<this.t.GUIDE_MOTION)return"fcv3.hold_still";if(r<this.t.Q_GOOD){let n=[["size",this.sizeGuidance()],["centering","fcv3.center_face"],["pose","fcv3.straighten"],["exposure",this.exposureGuidance(t)],["sharpness","fcv3.steady_camera"],["motion","fcv3.hold_still"]],a=n[0];for(let s of n)e[s[0]]<e[a[0]]&&(a=s);return a[1]}return"fcv3.hold_still"}sizeGuidance(){return this.lastSizeDirection==="far"?"fcv3.come_closer":"fcv3.move_back"}exposureGuidance(e){let t=(G[0]+G[1])/2;return e.meanLuma<t?"fcv3.more_light":"fcv3.too_bright"}};var Xe=["single","size","centering","pose","exposure","sharpness","motion"];function Ze(i){if(i.accepted)return null;if(i.factors.presence<=0)return"no_face";let e="single";for(let t of Xe)i.factors[t]<i.factors[e]&&(e=t);return e}var w=class{constructor(){this.blocked={};this.acceptedMs=0;this.ticks=0;this.lastAt=null}record(e){let t=this.lastAt===null?0:Math.max(0,e.at-this.lastAt);this.lastAt=e.at,this.ticks+=1;let r=Ze(e);if(r===null){this.acceptedMs+=t;return}let n=this.blocked[r]??{count:0,ms:0};n.count+=1,n.ms+=t,this.blocked[r]=n}summary(){let e={};for(let[t,r]of Object.entries(this.blocked))e[t]={count:r.count,ms:Math.round(r.ms)};return{blocked:e,acceptedMs:Math.round(this.acceptedMs),ticks:this.ticks}}};var Qe=["obs","manycam","virtual","snap camera","xsplit","droidcam","iriun","camo"],Ye=[/^(front|back|rear)( [a-z ]+)? camera$/i,/^caméra (avant|arrière)\b/i,/^cámara (frontal|trasera|delantera)\b/i,/^câmera (frontal|traseira)\b/i,/^(front|rück)kamera\b/i,/^الكاميرا (الأمامية|الخلفية)/,/^camera2? ?\d+, facing (front|back|external)/i,/facetime/i,/\b(integrated|built-in|builtin) (web)?cam(era)?\b/i,/\b(hd )?web ?cam\b/i,/\([0-9a-f]{4}:[0-9a-f]{4}\)\s*$/i];function je(i){let e=(i??"").trim().toLowerCase();return e.length===0?"unknown":Qe.some(t=>e.includes(t))?"known_virtual":Ye.some(t=>t.test(e))?"platform":"unknown"}function Te(i){if(typeof i!="function")return!1;try{return/\{\s*\[native code\]\s*\}\s*$/.test(Function.prototype.toString.call(i))}catch{return!1}}function $e(i=globalThis){return Te(i.navigator?.mediaDevices?.getUserMedia)&&Te(i.MediaStreamTrack?.prototype?.getSettings)}async function Je(i,e=globalThis){let t=e.crypto?.subtle?.digest;if(typeof t=="function")try{let r=new Uint8Array(await t.call(e.crypto?.subtle,"SHA-256",new TextEncoder().encode(i)));return Array.from(r.subarray(0,8),n=>n.toString(16).padStart(2,"0")).join("")}catch{return}}async function Ce(i,e=globalThis){let t={};try{t=typeof i.getSettings=="function"?i.getSettings()??{}:{}}catch{t={}}let r={};if((t.facingMode==="user"||t.facingMode==="environment"||t.facingMode==="left"||t.facingMode==="right")&&(r.facingMode=t.facingMode),typeof t.frameRate=="number"&&Number.isFinite(t.frameRate)&&(r.frameRate=t.frameRate),typeof t.width=="number"&&Number.isFinite(t.width)&&(r.width=t.width),typeof t.height=="number"&&Number.isFinite(t.height)&&(r.height=t.height),typeof t.deviceId=="string"&&t.deviceId.length>0){let a=await Je(t.deviceId,e);a!==void 0&&(r.deviceIdHash=a)}let n;try{n=i.label}catch{n=void 0}return{trackSettings:r,capabilitiesPresent:typeof i.getCapabilities=="function",labelClass:je(n),prototypesIntact:$e(e)}}var H=i=>Math.round(i*100)/100;function Ee(i){let e=i,t=typeof e?.requestVideoFrameCallback=="function",r=null,n=null,a=0,s=0,o=0,c=0,l=0,d=0,u=()=>{!t||e?.requestVideoFrameCallback===void 0||(r=e.requestVideoFrameCallback((f,v)=>{if(r=null,!t)return;let p=v.presentationTime;if(n!==null){let m=p-n.presentationTimeMs;s+=1;let y=m-o;o+=y/s,c+=y*(m-o)}typeof v.captureTime=="number"&&Number.isFinite(v.captureTime)&&(l+=p-v.captureTime,d+=1),a+=1,n={mediaTimeMs:v.mediaTime*1e3,presentationTimeMs:p},u()}))};return u(),{latest:()=>n,stats:()=>({n:a,meanGapMs:s===0?0:H(o),stdGapMs:s<2?0:H(Math.sqrt(c/(s-1))),captureLatencyMs:d===0?null:H(l/d)}),stop:()=>{t&&(t=!1,r!==null&&e?.cancelVideoFrameCallback?.(r),r=null)}}}function _e(i,e,t){return{...i,rvfc:e,rampPainter:t}}var et=1e3,K="fcv3.hold_upright",tt=200,B=4,rt=600,nt=1e3,Re={sharpness:1,exposure:1,meanLuma:128};function it(i,e){return e.width=i.videoWidth,e.height=i.videoHeight,e.getContext("2d").drawImage(i,0,0),new Promise((t,r)=>e.toBlob(n=>n?t(n):r(new Error("empty-keyframe")),"image/jpeg",.92))}function at(){return z()==="phone"}var ke=class{constructor(e){this.handlers=new Map;this.stateValue="idle";this.attempt=0;this.stream=null;this.detector=null;this.scheduler=null;this.gate=null;this.profiler=null;this.lastGuidanceKey=null;this.positioningStartedAt=0;this.cameraRequestedAt=null;this.cameraReadyAt=null;this.faceAcquiredAt=null;this.captureCompleteAt=null;this.fired=!1;this.carriedDegrade=0;this.carriedMeans=[];this.blockStats=null;this.lastGateSnapshotAt=Number.NEGATIVE_INFINITY;this.uprightGuard=!1;this.trackProvenance=null;this.ramp=null;this.snapshotCanvas=null;this.options=e,this.facing=e.facingMode??"user"}get state(){return this.stateValue}on(e,t){let r=this.handlers.get(e);return r||(r=new Set,this.handlers.set(e,r)),r.add(t),()=>r?.delete(t)}emit(e,t){for(let r of[...this.handlers.get(e)??[]])r(t)}async start(e={}){e.facingMode!==void 0&&(this.facing=e.facingMode),this.attempt+=1,await this.run(this.attempt)}get facingMode(){return this.facing}retry(){this.teardownAttempt(),this.start()}switchCamera(){this.facing=this.facing==="user"?"environment":"user",this.teardownAttempt(),this.start()}restart(e){this.facing=e,this.teardownAttempt(),this.start()}destroy(){this.attempt+=1,this.teardownAttempt(),this.detector?.destroy(),this.detector=null,this.options.video.srcObject=null}async run(e){let{options:t}=this;this.fired=!1,this.lastGuidanceKey=null,this.carriedDegrade=0,this.carriedMeans=[],this.cameraRequestedAt=null,this.cameraReadyAt=null,this.faceAcquiredAt=null,this.captureCompleteAt=null,this.uprightGuard=(t.isPhone??at)(),this.setState("preflight");let r=j();if(r!=="OK"){this.fail(r==="INSECURE_CONTEXT"?"insecure":"unsupported",{phase:"preflight"});return}this.setState("acquiring");let n=t.getUserMedia??(l=>navigator.mediaDevices.getUserMedia(l)),a;this.cameraRequestedAt=this.now();try{let{facingMode:l,...d}=q(X(),this.facing).video;a=await ne(this.facing,d,{getUserMedia:n,enumerateDevices:lt(t)})}catch(l){if(e!==this.attempt)return;if(l instanceof re){this.fail("backcamera",{phase:"acquiring",name:R(l)});return}this.fail(J(l),{phase:"acquiring",name:R(l)});return}if(ee(a),te(a),e!==this.attempt){for(let l of a.getTracks())l.stop();return}this.stream=a;let s=a.getVideoTracks?.()[0];if(this.trackProvenance=s===void 0?null:Ce(s).catch(()=>null),this.facing=Z(a)??this.facing,t.video.srcObject=a,await t.video.play().catch(()=>{}),e!==this.attempt)return;if(this.cameraReadyAt=this.now(),this.detector===null){let l={v3AssetBaseUrl:t.v3AssetBaseUrl},d=t.createDetector??(t.createWorker!==void 0&&se()?async()=>{try{return await oe.create(t.createWorker(),l)}catch{return x(l)}}:()=>x(l)),u;try{u=await d()}catch(f){e===this.attempt&&this.fail("models",{phase:"models",name:R(f)},f instanceof ie?f.fallbackReason:ot(f));return}if(e!==this.attempt){u.destroy();return}this.detector=u,this.options.telemetry?.({type:"detector",tier:u.tier,fallbackReason:u.fallbackReason})}let o=le(),c=t.deviceClass??ce(o);this.profiler=new ue(c),this.options.telemetry?.({type:"profile",staticClass:c,activeClass:this.profiler.deviceClass,simd:o.simd}),this.gate=new k(t.thresholds??{}),this.blockStats=new w,this.lastGateSnapshotAt=this.now(),t.rankKeyframes?.()&&import("./keyframe-rank-YAJLYJYF.js").then(l=>W=l,()=>{}),this.setState("positioning"),this.positioningStartedAt=this.now(),this.startScheduler(e)}get animations(){return this.profiler?.profile.animations??"full"}startScheduler(e){let t=this.profiler;if(t===null)return;if(this.scheduler!==null){let n=this.scheduler.stats();this.carriedDegrade+=n.degradeCount,n.meanDetectMs>0&&this.carriedMeans.push(n.meanDetectMs),this.scheduler.stop()}let r=new O({cadenceHz:t.profile.cadenceHz,video:this.options.video,now:this.options.now,run:()=>this.detectTick(e)});this.scheduler=r,r.start()}async detectTick(e){let{detector:t,gate:r,profiler:n}=this,a=this.options.video;if(e!==this.attempt||t===null||r===null||n===null||this.fired||a.videoWidth===0)return;if(this.isLandscape()){this.holdUpright(e);return}let s=n.deviceClass,o=this.now(),c=this.options.makeSnapshot?.(a,n.profile.inputWidth)??this.defaultSnapshot(a,n.profile.inputWidth),l=null;try{l=await t.detect(c,a.videoWidth,a.videoHeight)}catch{l=null}if(e!==this.attempt||this.fired)return;n.record(this.now()-o),n.deviceClass!==s&&this.startScheduler(e);let d=l===null?Re:this.options.measureQuality?.(a,l.box)??this.defaultQuality(a,l.box),u=r.tick({timestampMs:this.now(),observation:l,quality:d,frameWidth:a.videoWidth,frameHeight:a.videoHeight});u.accepted&&this.faceAcquiredAt===null&&(this.faceAcquiredAt=u.at),this.blockStats?.record(u),!u.ready&&u.at-this.lastGateSnapshotAt>=et&&(this.lastGateSnapshotAt=u.at,this.reportGate(!1)),this.emit("checks",{engine:"v3",progress:u.p,q:u.q,factors:u.factors,attempt:e}),u.guidanceKey!==this.lastGuidanceKey&&(this.lastGuidanceKey=u.guidanceKey,this.emit("guidance",{key:u.guidanceKey})),u.ready&&this.stateValue==="positioning"&&(this.fired=!0,this.captureCompleteAt=u.at,this.fire(e))}async fire(e){let{options:t}=this,r=this.scheduler;r?.stop(),this.reportGate(!0);let n=r?.stats()??{degradeCount:0,meanDetectMs:0},a=[...this.carriedMeans,...n.meanDetectMs>0?[n.meanDetectMs]:[]];t.telemetry?.({type:"fired",timeToGateMs:this.now()-this.positioningStartedAt,degradeCount:this.carriedDegrade+n.degradeCount,meanDetectMs:a.length===0?0:a.reduce((M,g)=>M+g,0)/a.length});let s=t.mode??"clip",o=t.rankKeyframes?.()&&W?W.default(this,e).catch(()=>this.collectKeyframes(e)):this.collectKeyframes(e);if(s==="photo"){let M=this.watchRotation(e,null),g=await o;if(M(),e!==this.attempt)return;if(g===null){this.fail("generic",{phase:"keyframes"});return}let P=await this.provenance({n:0,meanGapMs:0,stdGapMs:0,captureLatencyMs:null},!1);if(e!==this.attempt)return;this.finishCapture({keyframe:g.blob,previewDataUrl:g.previewDataUrl,...P});return}this.setState("recording");let c=this.stream;if(c===null){this.fail("generic",{phase:"recording"});return}let l=t.screenRamp?.(),d=l!==void 0,u=null;o.then(M=>{u=M},()=>{});let f=()=>{e===this.attempt&&u!==null&&this.emit("frozen",{previewDataUrl:u.previewDataUrl})},v=ye(l,N),p=null,m,y=0;try{let M=this.recordTake(e,c,l,v,void 0).then(T=>T,T=>({failed:T})),[g,P]=await Promise.all([M,o]);if(m=P,e!==this.attempt)return;if("failed"in g){if(g.failed.kind==="cliptoolarge")throw g.failed;F(g.failed.requestedMimeType??"")}else p=g,U(g.clip,v)?g.clip.stats===null&&F(g.clip.requestedMimeType??""):f();if(p===null||U(p.clip,v)){y=1,t.telemetry?.({type:"clip_retake",reason:p===null?"error":p.clip.stats===null?"unreadable":"short"});let T=null;try{T=await this.recordTake(e,c,l,v,f)}catch(Ae){if(p===null)throw Ae}if(e!==this.attempt)return;T!==null&&(p===null||ge(T.clip,p.clip))&&(p=T),T===null&&f()}}catch(M){if(e!==this.attempt)return;let g=M.kind;this.fail(g==="cliptoolarge"?"cliptoolarge":"recorder",{phase:"recording",name:R(M)});return}if(p===null){this.fail("recorder",{phase:"recording"});return}let{clip:h,rvfc:b,report:C}=p;if(A(h.blob)){this.fail("cliptoolarge",{phase:"recording"});return}if(m===null){this.fail("generic",{phase:"keyframes"});return}let E=await this.provenance(b,d);e===this.attempt&&this.finishCapture({clip:h.blob,clipMimeType:h.mimeType,...h.stats?{clipStats:h.stats}:{},clipRetakes:y,keyframe:m.blob,previewDataUrl:m.previewDataUrl,...C!==void 0&&C.rendered.length>0?{screenRamp:C}:{},...E})}async recordTake(e,t,r,n,a){let s=this.options.createRecorder?.()??new I({now:()=>this.now()}),o=Ee(this.options.video),c=Me(r,{paint:u=>{(u===null||e===this.attempt)&&this.emit("ramp",{colour:u})},now:()=>this.now(),frames:o.latest});this.ramp=c;let l=()=>{o.stop(),c.stop(),this.ramp===c&&(this.ramp=null)},d=this.watchRotation(e,s);try{return{clip:await s.record(t,a,()=>c.started(this.now()),n,o),rvfc:o.stats(),report:c.report()}}finally{d(),l()}}async provenance(e,t){let r=this.trackProvenance;if(r===null)return{};let n,a=new Promise(o=>{n=setTimeout(()=>o(null),nt)}),s=await Promise.race([r,a]);return clearTimeout(n),s===null?{}:{provenance:_e(s,e,t)}}isLandscape(){let e=this.options.video;return this.uprightGuard&&e.videoWidth>e.videoHeight}holdUpright(e){this.gate?.reset(),this.emit("checks",{engine:"v3",progress:0,q:0,factors:{presence:0,single:1,centering:0,size:0,pose:0,sharpness:0,exposure:0,motion:0},attempt:e}),this.lastGuidanceKey!==K&&(this.lastGuidanceKey=K,this.emit("guidance",{key:K}))}watchRotation(e,t){if(!this.uprightGuard)return()=>{};let r=this.options.video,n=()=>{if(e!==this.attempt||t!==null&&this.stateValue!=="recording"){o();return}r.videoWidth>0&&this.isLandscape()&&(o(),this.abortRecording(e,t))},a=setInterval(n,tt);r.addEventListener?.("resize",n);let s=!1;function o(){s||(s=!0,clearInterval(a),r.removeEventListener?.("resize",n))}return o}abortRecording(e,t){if(e!==this.attempt)return;this.attempt+=1;let r=this.attempt;try{t?.stop()}catch{}this.ramp?.stop(),this.ramp=null,this.fired=!1,this.captureCompleteAt=null,this.gate=new k(this.options.thresholds??{}),this.blockStats=new w,this.lastGateSnapshotAt=this.now(),this.lastGuidanceKey=null,this.setState("positioning"),this.positioningStartedAt=this.now(),this.holdUpright(r),this.startScheduler(r)}async collectKeyframes(e){let t=this.options.captureKeyframe??(a=>this.defaultKeyframe(a)),r=rt/(B-1),n=null;for(let a=0;a<B;a+=1){if(e!==this.attempt)return n;try{let s=await t(this.options.video);(n===null||s.sharpness>n.sharpness)&&(n=s)}catch{}a<B-1&&await st(r)}return n}finishCapture(e){this.stopTracks(),this.setState("captured");let t=this.captureTiming();this.emit("artifacts",t===void 0?e:{...e,timing:t})}captureTiming(){let e={},t=(r,n,a)=>{n!==null&&a!==null&&(e[r]=Math.max(0,Math.round(a-n)))};return t("cameraReadyMs",this.cameraRequestedAt,this.cameraReadyAt),t("faceAcquireMs",this.cameraReadyAt,this.faceAcquiredAt),t("captureMs",this.faceAcquiredAt,this.captureCompleteAt),Object.keys(e).length>0?e:void 0}async defaultKeyframe(e){let t=document.createElement("canvas"),r=await(this.facing==="user"?Se:it)(e,t),n=t.toDataURL("image/jpeg",.92);return{blob:r,previewDataUrl:n,sharpness:this.centerSharpness(e)}}defaultSnapshot(e,t){try{let r=this.snapshotCanvas??document.createElement("canvas"),n=t/Math.max(1,e.videoWidth),a=Math.max(1,Math.round(e.videoWidth*n)),s=Math.max(1,Math.round(e.videoHeight*n)),o=r.getContext("2d");return o===null?e:(r.width!==a&&(r.width=a),r.height!==s&&(r.height=s),o.drawImage(e,0,0,a,s),this.snapshotCanvas=r,r)}catch{return e}}defaultQuality(e,t){let r=we(e,t,96);return r===null?Re:{sharpness:L(r),exposure:pe(r),meanLuma:de(r)}}centerSharpness(e){let t=ae(e),r=we(e,{x:t.width*.25,y:t.height*.25,width:t.width*.5,height:t.height*.5},96);return r===null?0:L(r)}teardownAttempt(){this.scheduler?.stop(),this.scheduler=null,this.reportGate(!0),this.gate=null,this.ramp?.stop(),this.ramp=null,this.stopTracks()}reportGate(e){let t=this.blockStats,r=this.profiler;if(t===null||r===null)return;let n=t.summary();e&&(this.blockStats=null),n.ticks!==0&&this.options.telemetry?.({type:"gate",final:e,activeClass:r.deviceClass,cadenceHz:r.profile.cadenceHz,...n})}stopTracks(){if(this.stream!==null){for(let e of this.stream.getTracks())e.stop();this.stream=null}}fail(e,t,r){this.scheduler?.stop(),this.reportGate(!0),this.stopTracks(),this.setState("error"),this.options.telemetry?.({type:"error",kind:e,fallbackReason:r});let{phase:n,name:a}=t;this.emit("error",{kind:e,retryable:e!=="insecure"&&e!=="unsupported",detail:a===void 0?{phase:n}:{phase:n,name:a}})}setState(e){this.stateValue=e,this.emit("statechange",{state:e})}now(){return this.options.now?.()??performance.now()}},W;function st(i){return new Promise(e=>setTimeout(e,i))}function ot(i){return i instanceof Error?i.message:String(i)}function we(i,e,t){try{let r=document.createElement("canvas"),n=t/Math.max(1,e.width);r.width=Math.max(1,Math.round(e.width*n)),r.height=Math.max(1,Math.round(e.height*n));let a=r.getContext("2d");return a===null?null:(a.drawImage(i,e.x,e.y,e.width,e.height,0,0,r.width,r.height),a.getImageData(0,0,r.width,r.height))}catch{return null}}function lt(i){if(i.enumerateDevices!==void 0)return i.enumerateDevices;if(i.getUserMedia===void 0&&!(typeof navigator>"u"||typeof navigator.mediaDevices?.enumerateDevices!="function"))return()=>navigator.mediaDevices.enumerateDevices()}export{ut as a,N as b,Pe as c,xe as d,ve as e,Ge as f,Le as g,Fe as h,Ve as i,S as j,Ue as k,U as l,ge as m,I as n,Ke as o,ft as p,Se as q,O as r,ze as s,k as t,Ze as u,w as v,et as w,K as x,tt as y,B as z,rt as A,nt as B,ke as C};
|
package/dist/chunk-ZCZ2E2YN.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{c as P,d as H,e as A}from"./chunk-C5FD3ADY.js";var Y=new Set(["nni_unbound","id_number_unbound","method_required","mobile_required","portrait_required"]);function _e(e){return Y.has(e)}function ge(e,n,t){let i=n.detail;return{check:e,kind:n.kind,...i?.name!==void 0?{name:i.name}:{},...i?.phase!==void 0?{phase:i.phase}:{},...i?.engineKind!==void 0?{engineKind:i.engineKind}:{},attempt:Math.max(0,Math.min(1e3,t))}}function Ce(){let e=-1,n="";return{note(t){t==="starting"&&n!=="starting"&&(e+=1),n=t},newHandle(){n=""},noteError(){e<0&&(e=0)},get value(){return e}}}var $={document:"document_photo",nfc:"document_chip",population_registry:"national_number",national_eid:"national_eid"};function p(e){return e.plan?.steps??[]}function V(e){return Math.max(0,e.attempts.max-e.attempts.used)}function j(e){let n=e.plan?.choice;return n!==void 0&&e.plan?.current===n.nodeId?n:null}function ke(e){let n=j(e);if(n?.kind!=="identity_method")return null;let t=n.options.map(o=>$[o.service]).filter(o=>o!==void 0),i=n.options.find(o=>o.nationalEid)?.nationalEid;return i?{available:!0,selected:null,options:t,nationalEid:i}:{available:!0,selected:null,options:t}}var z=new Set(["liveness","face_match"]);function _(e){return e!==void 0&&(e.state==="pending"||e.state==="input_required")}function I(e){return e.status!=="created"&&e.status!=="in_progress"}function x(e){let n=e.plan?.current,t=n==null?void 0:p(e).find(i=>i.id===n);return _(t)?t:void 0}function h(e,n){return p(e).find(t=>t.checkType===n)}function S(e){let n=p(e),t=n.findIndex(i=>i.checkType==="liveness");return n.find((i,o)=>o>t&&i.checkType==="face_match")}function T(e,n){let t=h(n,"liveness")?.state,i=S(n)?.state;return(S(e)?.state??"pending")==="pending"&&(t==="passed"||t==="review")&&i!==void 0&&i!=="pending"&&i!=="skipped"}function M(e,n){let t=new Map(p(e).map(i=>[i.id,i.state]));return p(n).filter(i=>i.checkType==="face_match"&&(t.get(i.id)??"pending")==="pending"&&i.state!=="pending"&&i.state!=="skipped").map(i=>i.id)}var G=/^[0-9a-f]{24}$/i;function g(e){return G.test(e)?`ses_${e}`:e}function R(e,n){let t=g(e);return n===void 0?{sessionId:t,status:"unavailable"}:{sessionId:t,status:"unavailable",reasonCode:n}}function O(e,n,t){let i=g(e);return t===void 0?{sessionId:i,status:n}:{sessionId:i,status:n,reasonCode:t}}function Re(e,n){let t=g(e.sessionId);switch(e.status){case"created":case"in_progress":return Z(e,n);case"verified":return v(e,{sessionId:t,status:"verified"});case"review_pending":return v(e,O(t,"review",L(e,"review")));case"not_verified":return v(e,X(e));default:return v(e,{sessionId:t,status:"not_verified"})}}var W=new Set([0,1,2,3]);function v(e,n){return W.has(e.level)&&(n.level=e.level),typeof e.assurance=="string"&&e.assurance.length>0&&(n.assurance=e.assurance),n}function X(e){let n={sessionId:g(e.sessionId),status:"not_verified"};return e.reason!==void 0&&(n.reason=e.reason),e.reasonCode!==void 0&&(n.reasonCode=e.reasonCode),e.reasonCode==="device_cooldown"&&e.retryAfter!==void 0&&(n.retryAfter=e.retryAfter),n}function J(e){return e==="rejected"?"rejected":e==="unavailable"?"unavailable":"inconclusive"}function Q(e,n){if(n===void 0)return!1;let t=p(n).find(i=>i.id===e.id);return t!==void 0&&t.attempts.used===e.attempts.used}function Z(e,n){let t=g(e.sessionId),i=p(e).find(r=>z.has(r.checkType)&&r.state==="input_required"&&r.reason!==void 0);if(i?.reason==="mobile_required")return R(t,"mobile_required");if(i?.reason!==void 0){if(i.result==="unavailable")return R(t,i.reason);let u=n.autoRetry&&(V(i)>0||Q(i,n.previous))?{sessionId:t,status:"retry",reasonCode:i.reason,attemptsRemaining:V(i)}:{sessionId:t,status:"not_verified",reason:J(i.result),reasonCode:i.reason,attemptsRemaining:V(i)};return i.retakeHint!==void 0&&(u.retakeHint=i.retakeHint),u}let o=x(e);return o===void 0&&p(e).some(r=>r.state==="review")?O(t,"review",L(e,"review")):o?.checkType==="portrait_icao"?R(t,"portrait_required"):R(t)}function L(e,n){return p(e).find(t=>t.state===n&&t.reason!==void 0)?.reason}function K(e,n,t,i,o){return e.presignCapture!==void 0?e.presignCapture(n,t,i,o):e.presign(n,t,i)}function N(e){return{engine:e?.engine,durationMs:e?.clipMs}}var ee=["video/webm","video/mp4"],F="image/jpeg",ne=2,te=1e3,ie=1e4,oe=3,re=10,se=3,ae=new Set(["network_error","timeout","upload_failed","unknown_error","rate_limit_exceeded"]),ue=new Set(["session_not_active","check_not_found","check_already_finalized","check_out_of_order","identity_confirm_required","check_not_active","step_not_on_path"]),C=class extends Error{constructor(){super("verification destroyed"),this.name="FlowCancelledError"}};function de(e){let n=S(e);return h(e,"portrait_icao")?.state!=="pending"&&(n!==void 0?_(n):e.capture?.livePhoto?.oneCapture===!0)}var w=class extends Error{constructor(n){super(n),this.name="AttestationError"}};async function q(e,n,t={}){let i=e.uuid(),o=!1,r=!1,u=0,l=0;for(;;)try{return await n(e.client,i)}catch(s){if(s instanceof w){if(r)throw s;r=!0,t.onAttestationInvalid?.(),i=e.uuid();continue}if(!(s instanceof P))throw s;if(s.code==="consent_required"&&!o){o=!0,await e.ensureConsent({force:!0}),i=e.uuid();continue}if(s.code==="attestation_invalid"&&!r){r=!0,t.onAttestationInvalid?.(),i=e.uuid();continue}if(s.code==="inference_unavailable"&&l<oe){l+=1;let a=H(s.retryAfterSeconds,re,e.random??Math.random);e.onBusy?.({attempt:l,retryAfterSeconds:a/1e3}),await e.sleep(a),t.onAttestationInvalid?.(),i=e.uuid();continue}if(ae.has(s.code)&&u<ne){u+=1;let a=s.retryAfterSeconds!==void 0?s.retryAfterSeconds*1e3:void 0;await e.sleep(a!==void 0?Math.min(a,ie):te);continue}throw s}}var ce=new Set(["passed","review","processing","skipped"]);async function Me(e){let{artifacts:n}=e,t=n.clip,i=A(n.clipMime??"");if(n.degraded==="NO_RECORDER"||t===void 0||!ee.includes(i))return{kind:"unavailable",reason:"no_recorder"};e.client.armCapture?.(2);let o=le(e,n.keyframe),r=fe(e,t,i,o),u=pe(e,o),l=!1,s=new Set,a=!0,k=0;for(;;){if(e.isCancelled())return{kind:"cancelled"};let f=e.getView();if(I(f))return{kind:"settled"};let d=x(f),y=d?.checkType,b=y==="liveness"&&!l?"liveness":y==="face_match"&&!s.has(d?.id)&&s.size<2&&a?"face_match":null;if(b===null)return{kind:"settled"};if(b==="liveness"&&n.captureChannel==="desktop")return{kind:"unavailable",reason:"mobile_required"};try{if(b==="liveness"){l=!0;let c=await r();if(e.isCancelled())return{kind:"cancelled"};T(f,c)&&s.add(S(c)?.id);for(let D of M(f,c))s.add(D);await e.applySubmit(c,"liveness");let m=h(e.getView(),"liveness")?.state;a=m===void 0||ce.has(m)}else{s.add(d?.id);let c=await u();if(e.isCancelled())return{kind:"cancelled"};for(let m of M(f,c))s.add(m);await e.applySubmit(c,"face_match")}}catch(c){if(e.isCancelled()||c instanceof C)return{kind:"cancelled"};let m=ye(c);if(m.kind!=="resync"||k>=se)return m;k+=1,await e.refreshView()}}}function le(e,n){let t=null,i=null,o=()=>t!==null?Promise.resolve(t):(i??(i=(async()=>{let r=await K(e.client,"image",F,n.size,N(e.artifacts));return await e.client.uploadToSpaces(r.uploadUrl,n,F),t=(await e.client.completeMedia(r.key)).key,e.onKeyframePromoted?.(t),t})().finally(()=>{i=null})),i);return{ensure:o,attempt:()=>o().catch(()=>null),current:()=>t}}function fe(e,n,t,i){let o=null,r,u=null,l=0,s;return()=>q(e,async(a,k)=>{if(o===null||r===void 0){if(e.isCancelled())throw new C;r===void 0&&!de(e.getView())&&(r=null),e.onPhase("uploading");let[f,d]=await Promise.all([o!==null?Promise.resolve(o):(async()=>{let y=await K(a,"clip",t,n.size,N(e.artifacts));return await a.uploadToSpaces(y.uploadUrl,n,t),(await a.completeMedia(y.key)).key})(),r!==void 0?Promise.resolve(r===null?null:r.imageKey):i.attempt()]);o=f,r===void 0&&(r=d===null?null:{imageKey:d})}if(u===null){let f=performance.now();try{u=await e.getAttestation(),s=e.attestationError?.()}catch(d){throw new w(d instanceof Error?d.message:String(d))}l=Math.round(performance.now()-f)}return e.onPhase("checking"),a.submitCheck("liveness",{clipKey:o,attestation:u,captureChannel:e.artifacts.captureChannel,capture:{...me(e.artifacts),attestationMs:l,attestationError:s},...r!==null?{faceMatch:r}:{}},{idempotencyKey:k})},{onAttestationInvalid:()=>{u=null}})}function pe(e,n){return()=>q(e,async(t,i)=>{if(n.current()===null){if(e.isCancelled())throw new C;e.onPhase("uploading")}let o=await n.ensure();return e.onPhase("checking"),t.submitCheck("face_match",{imageKey:o},{idempotencyKey:i})})}function me(e){let n={width:e.width,height:e.height};for(let t of he)e[t]!==void 0&&(n[t]=e[t]);return n}var he=["engine","facingMode","mode","formFactor","clipMs","clipFrames","fps","clipRetakes","codec","cameraReadyMs","faceAcquireMs","captureMs","screenRamp","provenance"];function ye(e){if(e instanceof w)return{kind:"unavailable",reason:"attestation"};if(e instanceof P){if(e.code==="attestation_invalid")return{kind:"unavailable",reason:"attestation"};if(e.code==="inference_unavailable")return{kind:"unavailable",reason:"inference_unavailable"};if(e.code==="mobile_required")return{kind:"unavailable",reason:"mobile_required"};if(ue.has(e.code))return{kind:"resync"}}return{kind:"unavailable",reason:"network"}}var B=class extends Error{constructor(n,t){super(`invalid ${n} (${t})`),this.name="InvalidInputError",this.field=n,this.kind=t}},U=class extends Error{constructor(n,t){super(`invalid ${n} (${t})`),this.name="OtpInputError",this.field=n,this.kind=t}};function E(e){return e?.source==="upload"?null:e?.source==="choice"&&e.sourcePick!=="camera"?"upload_or_phone":"phone"}function Ie(e,n){if(n===void 0||!_(n)||n.requiresMobile!==!0)return null;switch(n.checkType){case"liveness":return"phone";case"face_match":{if(n.reason!==void 0)return"phone";let t=h(e,"portrait_icao");return t?.state==="passed"||t?.state==="review"?null:"phone"}case"doc_ocr":return E(e.documents);case"poa":return E(e.proofOfAddress);case"portrait_icao":{let t=e.portrait;return t?.pendingFix!==void 0||t?.reuse?.pending===!0?null:E(t)}default:return null}}function Se(e){let n=e?.capture,t=n?.mode;return t==="assisted"||t==="self"||t==="choice"?t:n?.cameraSwitch===!0?"assisted":"self"}function Oe(e){let n=e?.capture?.pick;return Se(e)==="choice"&&(n==="self"||n==="assisted")?n:null}function Le(e,n,t=null){return e==="choice"?n??t??"self":e}export{_e as a,ge as b,Ce as c,$ as d,p as e,V as f,j as g,ke as h,_ as i,I as j,x as k,h as l,g as m,R as n,Re as o,Ie as p,Se as q,Oe as r,Le as s,K as t,ee as u,ne as v,te as w,oe as x,re as y,w as z,q as A,Me as B,me as C,B as D,U as E};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{u as a,v as b,w as c,x as d}from"./chunk-VXHK5YC6.js";import"./chunk-G6LKLN4U.js";import"./chunk-NFHLJOHW.js";import"./chunk-Y5ZLVLCU.js";import"./chunk-7QZWBDI5.js";import"./chunk-ZCOWTM46.js";import"./chunk-SX7TUC3V.js";import"./chunk-POIQGEZM.js";import"./chunk-CPUECYAJ.js";import"./chunk-FPXL63KZ.js";import"./chunk-TSA6GHUG.js";import"./chunk-U3JUGEIW.js";import"./chunk-FSSMUAKC.js";import"./chunk-DK5YPBDQ.js";export{a as SAME_FACE_MAX_DROPS,c as createDocumentCapture,d as createDocumentCaptureInternal,b as warmDocumentCapture};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{e as ee}from"./chunk-A3FUGHAH.js";import{a as q,b as J,e as X,f as B,g as x,j as Z}from"./chunk-SDDM5ZTK.js";import{x as Q}from"./chunk-VXHK5YC6.js";import{n as Y}from"./chunk-VWGKUQ3C.js";import"./chunk-53POX7U4.js";import"./chunk-33KKMPJ5.js";import"./chunk-CJHMFPL6.js";import"./chunk-RI3E7GBN.js";import"./chunk-GI3UFGRQ.js";import{F as $,i as K,x as N}from"./chunk-HLV2XYHX.js";import"./chunk-G6LKLN4U.js";import"./chunk-SMKCBUJL.js";import"./chunk-4DEPREJ3.js";import"./chunk-NFHLJOHW.js";import{b as H,c as G,q as j,s as z,t as L}from"./chunk-ZCZ2E2YN.js";import"./chunk-Y5ZLVLCU.js";import"./chunk-7QZWBDI5.js";import"./chunk-ZCOWTM46.js";import{b as U}from"./chunk-SX7TUC3V.js";import"./chunk-POIQGEZM.js";import"./chunk-CPUECYAJ.js";import"./chunk-FPXL63KZ.js";import{c as T,i as W}from"./chunk-C5FD3ADY.js";import"./chunk-TSA6GHUG.js";import{a as F}from"./chunk-U3JUGEIW.js";import"./chunk-FSSMUAKC.js";import"./chunk-DFTCAWMP.js";import"./chunk-DK5YPBDQ.js";var ie=2e4,ae=new Set(["media_type_unsupported","media_type_mismatch"]),te=new Set(["document_upload_not_allowed","portrait_source_not_allowed","uploaded_media_not_allowed"]);function ne(e){let o=null,f=Promise.resolve(),c=!1,b=null,I=null,_=!1,E=null,V=!1,C=!1,R=()=>{o?.controller.handle.destroy(),o=null},u=()=>{let t=e.currentView(),r=t===null?null:x(t,{isMobile:e.isMobile()});return r?.kind==="portrait"?r:null},a=()=>{if(e.destroyed())return"self";let t=e.currentView(),r=t===null?void 0:B(t);return r==="self"||r==="assisted"?r:r==="choice"&&e.captureModeSwitch!==void 0?e.captureModeSwitch.pick()??"self":e.cameraMode?.()??z(r??j(t),null)},h=e.captureModeSwitch,p=h===void 0?void 0:{session:()=>{let t=e.currentView();return t!==null&&B(t)==="choice"?"choice":a()},onModeChange:t=>h.choose(t)},g=async(t,r)=>{if(e.destroyed())return;let d=a();r.setFlowState("uploading"),c=!1;let l=null;try{await e.runner().submit("portrait_icao",async(n,w)=>{if(l===null){let k=await L(n,"image","image/jpeg",t.image.size,{engine:"portrait"});await n.uploadToSpaces(k.uploadUrl,t.image,"image/jpeg"),l=(await n.completeMedia(k.key)).key}r.setFlowState("checking");let D={media:{portrait:l},gate:W(t.gate),...t.tuningVersion!==void 0?{tuningVersion:t.tuningVersion}:{},source:"camera",capture:{mode:d,facingMode:t.facingMode}};return n.submitCheck("portrait_icao",D,{idempotencyKey:w})})}catch(n){c=!0,n instanceof T&&te.has(n.code)&&await e.refreshView?.().catch(()=>{})}if(r.setFlowState("done"),e.destroyed())return;let i=u();(i===null||i.phase!=="capture")&&o?.controller===r&&R(),e.runner().republish()},M=t=>e.runner().submit("face_match",(r,d)=>r.submitCheck("face_match",e.runner().faceProbeSkipped()?{simulatedCapture:!0}:{},{idempotencyKey:d})).then(()=>{},()=>{c=!0,t()}),P=null,y=async t=>{let r=u();if(r===null||r.phase!=="capture"||!r.photo.uploadOffered)throw new RangeError("upload_not_offered");let{prepareUploadFile:d}=await import("./upload-file-EGXXM6TQ.js"),l=await d(t,e.uploadInternals);if(e.destroyed())return;R(),c=!1;let i=null;try{await e.runner().submit("portrait_icao",async(n,w)=>{if(i===null){let k=await n.presign("image",l.contentType,l.blob.size,{source:"upload"});await n.uploadToSpaces(k.uploadUrl,l.blob,l.contentType),i=(await n.completeMedia(k.key)).key}let D={media:{portrait:i},source:"upload"};return n.submitCheck("portrait_icao",D,{idempotencyKey:w})})}catch(n){throw n instanceof T&&ae.has(n.code)?new TypeError("unsupported_file"):(n instanceof T&&te.has(n.code)&&await e.refreshView?.().catch(()=>{}),n)}},v=null,S=t=>{if(v!==null)return v;let r=u();if(r===null||r.phase!=="review")return Promise.reject(new RangeError("no_pending_fix"));let d={fixReview:{accept:t}},l=e.runner().submit("portrait_icao",(i,n)=>i.submitCheck("portrait_icao",d,{idempotencyKey:n})).catch(async i=>{throw i instanceof T&&i.code==="portrait_no_pending_fix"&&await e.refreshView?.().catch(()=>{}),i}).finally(()=>{v=null});return v=l,l},s=t=>{let r=()=>y(t),d=(P===null?r():P.then(r,r)).finally(()=>{P===d&&(P=null)});return P=d,d};return{bind:(t,r)=>{if(t.phase==="review")return R(),{...t,uploadFailed:c,resubmit:()=>Promise.resolve(),capture:()=>{throw new Error("the adjusted photo waits for confirmFix()")},uploadPortrait:()=>Promise.reject(new RangeError("upload_not_offered")),confirmFix:S};if(t.phase==="match")return R(),b!==t.attemptsRemaining&&!c&&(b=t.attemptsRemaining,M(r)),{...t,uploadFailed:c,resubmit:()=>(c=!1,b=t.attemptsRemaining,r(),M(r)),capture:()=>{throw new Error("the portrait was already accepted")},uploadPortrait:()=>Promise.reject(new RangeError("upload_not_offered")),confirmFix:S};if(b=null,t.reuse===!0&&t.phase==="capture")return R(),!V&&E!==t.attemptsRemaining&&(E=t.attemptsRemaining,V=!0,e.runner().submit("portrait_icao",(l,i)=>l.submitCheck("portrait_icao",{},{idempotencyKey:i})).then(()=>{C=!1},()=>{C=!0}).finally(()=>{V=!1,r()})),{kind:"processing",key:"processing",context:t.context,section:t.section,stalled:C&&!V,refresh:()=>(C=!1,E=null,r(),Promise.resolve())};let d=e.keptPortraitInput?.()??null;return d!==null&&(_||d!==I&&t.report===null&&t.reason===void 0&&!t.retakeOnly)?(_||(I=d,_=!0,e.runner().submit("portrait_icao",(l,i)=>l.submitCheck("portrait_icao",d,{idempotencyKey:i})).catch(()=>{}).finally(()=>{_=!1,r()})),{kind:"processing",key:"processing",context:t.context,section:t.section,stalled:!1,refresh:()=>Promise.resolve()}):{...t,uploadFailed:c,resubmit:()=>Promise.resolve(),capture:l=>{if(o!==null&&o.video===l.video)return o.controller.handle;R(),c=!1;let i=Y({video:l.video,tuning:t.tuning,tuningVersion:t.tuningVersion,...t.icao!=null?{policy:t.icao.policy}:{},...l.keepScreenAwake!==void 0?{keepScreenAwake:l.keepScreenAwake}:{},...l.assetBaseUrl!==void 0?{assetBaseUrl:l.assetBaseUrl}:{}},e.internals,a,p);o={video:l.video,controller:i};let n=i.handle.destroy;i.handle.destroy=()=>{o?.controller===i&&(o=null),n()},i.handle.on("error",k=>{e.reportCaptureIssue?.(H("portrait",k,0))});let w=!1,D=(k,O)=>{let A=i.gateScores();A!==null&&e.reportGate?.({kind:"portrait_gate",platform:"web",outcome:k,...O!==null?{failing:O}:{},...A})};return i.handle.on("gate",k=>{!w&&!k.ready&&(i.gateScores()?.elapsedMs??0)>=ie&&(w=!0,D("stuck",k.failing))}),i.handle.on("captured",k=>{D("captured",null),w=!1,f=f.then(()=>g(k,i)).catch(()=>{})}),i.handle},uploadPortrait:s,confirmFix:S}},destroy:R}}var le=.92,se=()=>U("environment",{width:{ideal:1920},height:{ideal:1080}},{getUserMedia:e=>navigator.mediaDevices.getUserMedia(e),enumerateDevices:()=>navigator.mediaDevices.enumerateDevices()}),ue=e=>{let o=document.createElement("canvas");o.width=e.videoWidth,o.height=e.videoHeight;let f=o.getContext("2d");return f===null||o.width===0||o.height===0?Promise.reject(new Error("the camera has no frame yet")):(f.drawImage(e,0,0,o.width,o.height),new Promise((c,b)=>o.toBlob(I=>I===null?b(new Error("the still could not be encoded")):c(I),"image/jpeg",le)))},de=(e,o)=>{try{e.muted=!0,e.playsInline=!0,e.srcObject=o,e.play().catch(()=>{})}catch{}};function re(e){let o=null,f=null,c=u=>{let a=(f===null?u():f.then(u,u)).finally(()=>{f===a&&(f=null)});return f=a,a},b=()=>{o?.handle.destroy(),o=null},I=()=>{let u=e.currentView(),a=u===null?null:x(u,{isMobile:e.isMobile()});return a?.kind==="proof_of_address"?a:null},_=async(u,a)=>{if(a.length===0)throw new RangeError("no_pages");if(a.length>u.maxPages)throw new RangeError("too_many_pages");let{pdfFileKind:h,prepareUploadFile:p}=await import("./upload-file-EGXXM6TQ.js"),g=await Promise.all(a.map(P=>h(P)));if(g.includes("bad"))throw new TypeError("unsupported_file");if(g.includes("pdf")){if(a.length>1)throw new RangeError("too_many_pages");let P=a[0];if(P.size>u.pdf.maxBytes)throw new RangeError("file_too_large");return[{kind:"document_file",blob:P,contentType:"application/pdf"}]}let M=[];for(let P of a){let y=await p(P,e.uploadInternals);M.push({kind:"image",blob:y.blob,contentType:y.contentType})}return M},E=async(u,a,h)=>{let p=null;try{await e.runner().submit("poa",async(g,M)=>{if(p===null){let y=[];for(let v of h){let S=a==="upload"?await g.presign(v.kind,v.contentType,v.blob.size,{source:"upload"}):await L(g,v.kind,v.contentType,v.blob.size,{engine:"poa_page"});await g.uploadToSpaces(S.uploadUrl,v.blob,v.contentType),y.push((await g.completeMedia(S.key)).key)}p=y}let P=h[0]?.kind==="document_file"?{part:u,source:"upload",pdfKey:p[0]}:{part:u,source:a,imageKeys:p};return g.submitCheck("poa",P,{idempotencyKey:M})})}catch(g){throw g instanceof T&&(g.code==="media_type_unsupported"||g.code==="media_type_mismatch")?new TypeError("unsupported_file"):(g instanceof T&&(g.code==="document_upload_not_allowed"||g.code==="uploaded_media_not_allowed")&&await e.refreshView?.().catch(()=>{}),g)}},V=async(u,a)=>{let h=I();if(h===null||!h.photo.uploadOffered)throw new RangeError("upload_not_offered");if(u==="holder_letter"&&h.phase!=="holder_letter")throw new RangeError("holder_letter_not_requested");let p=await _(h,a);e.destroyed()||(b(),await E(u,"upload",p))},C=(u,a)=>{let h=null,p=[],g=!0,M=()=>{for(let y of h?.getTracks()??[])y.stop();h=null},P={get pages(){return p},start:async()=>{if(!g||h!==null)return;let y=await(e.pageCamera?.open??se)();if(!g){for(let v of y.getTracks())v.stop();return}h=y,(e.pageCamera?.attach??de)(u,y)},takePage:async()=>{if(p.length>=a)throw new RangeError("too_many_pages");let y=await(e.pageCamera?.grab??ue)(u);if(p.length>=a)throw new RangeError("too_many_pages");return p=[...p,y],y},removePage:y=>{p=p.filter((v,S)=>S!==y)},submitPages:()=>c(async()=>{if(p.length===0)throw new RangeError("no_pages");let y=I();if(y===null)throw new RangeError("camera_not_offered");let v=y.phase==="holder_letter"?"holder_letter":"document";await E(v,"camera",p.map(S=>({kind:"image",blob:S,contentType:"image/jpeg"}))),o?.handle===P?b():P.destroy()}),destroy:()=>{g=!1,p=[],M(),o?.handle===P&&(o=null)}};return P},R=async()=>{let u=I();if(u===null||!u.licenceAddressAccepted)throw new RangeError("licence_address_not_accepted");if(e.destroyed())return;b();let a={part:"document"};await e.runner().submit("poa",(h,p)=>h.submitCheck("poa",a,{idempotencyKey:p}))};return{bind:u=>({...u,...u.licenceAddressAccepted?{useLicenceAddress:()=>c(R)}:{},uploadPages:a=>c(()=>V("document",a)),uploadHolderLetter:a=>c(()=>V("holder_letter",a)),capturePage:a=>{if(u.photo.source==="upload")throw new RangeError("camera_not_offered");if(o!==null&&o.video===a.video)return o.handle;b();let h=C(a.video,u.maxPages);return o={video:a.video,handle:h},h}}),destroy:b}}function oe(e){let o=e;if(typeof o.apiOrigin!="string"||typeof o.sessionToken!="string")return;let f=`${o.apiOrigin}/api/v2/hosted/capture-reports`,c=o.sessionToken;return b=>{try{fetch(f,{method:"POST",headers:{"content-type":"application/json","x-session-token":c,"x-sekyro-sdk":`@sekyro/web/${F}`},body:JSON.stringify({reports:b}),keepalive:!0}).catch(()=>{})}catch{}}}function ce(e){let o=e.apiOrigin;return ee("sdk",typeof o=="string"&&/staging|sandbox|localhost/.test(o)?"sandbox":"live")}function Ue(e){let o=null,f=null,c=null,b=G(),I=Promise.resolve(),_=()=>{c?.flow.handle.destroy(),c=null},E=()=>f?.documentType==="drivers_license"?{documentType:"drivers_license"}:{},V=async(s,m)=>{if(e.destroyed())return;m.setFlowState("uploading");let t=null,r,d=!1,l=e.currentView()?.documents!==void 0;try{await o.submit("doc_ocr",async(k,O)=>{if(t===null){let A=await L(k,"image","image/jpeg",s.image.size,{engine:"document"});await k.uploadToSpaces(A.uploadUrl,s.image,"image/jpeg"),t=(await k.completeMedia(A.key)).key}return m.setFlowState("checking"),r===void 0&&(r=m.takeDeviceRead(s)),k.submitCheck("doc_ocr",{imageKey:t,side:s.side,...r!==null?{deviceRead:r}:{},...l?{source:"camera"}:{},...E()},{idempotencyKey:O})})}catch{d=!0}finally{m.setFlowState("done")}if(e.destroyed())return;if(d){m.settle(s.side,{ok:!1,issue:"technical"});return}let i=e.currentView(),n=i===null?null:x(i,{isMobile:e.isMobile()});if(n?.kind!=="document"){m.settle(s.side,{ok:!0}),c?.flow===m?_():m.handle.destroy();return}if(n.reason==="document_type_not_accepted"){f=null,c?.flow===m&&_(),o.republish();return}let w=n.acceptedSides;s.side!=="single"&&(w.includes(s.side)||n.reason==="side_missing")&&!(w.includes("recto")&&w.includes("verso"))?(m.settle(s.side,{ok:!0}),f?.documentType!=="passport"&&m.handle.setSide(n.side)):m.settle(s.side,{ok:!1,issue:"reread"})},C=null,R=async s=>{let m=e.currentView(),t=m===null?null:x(m,{isMobile:e.isMobile()});if(m===null||t?.kind!=="document")throw new RangeError("upload_not_offered");if(!t.photo.uploadOffered)throw new RangeError("upload_not_offered");let r=f?.documentType==="passport"?"single":t.side,{prepareUploadFile:d}=await import("./upload-file-EGXXM6TQ.js"),l=await d(s,e.uploadInternals);if(e.destroyed())return;_();let i=null;try{await o.submit("doc_ocr",async(n,w)=>{if(i===null){let D=await n.presign("image",l.contentType,l.blob.size,{source:"upload"});await n.uploadToSpaces(D.uploadUrl,l.blob,l.contentType),i=(await n.completeMedia(D.key)).key}return n.submitCheck("doc_ocr",{imageKey:i,side:r,source:"upload",...E()},{idempotencyKey:w})})}catch(n){throw n instanceof T&&(n.code==="media_type_unsupported"||n.code==="media_type_mismatch")?new TypeError("unsupported_file"):(n instanceof T&&(n.code==="document_upload_not_allowed"||n.code==="uploaded_media_not_allowed")&&await e.refreshView().catch(()=>{}),n)}},u=(s,m)=>({...s,uploadDocument:t=>{let r=()=>R(t),d=(C===null?r():C.then(r,r)).finally(()=>{C===d&&(C=null)});return C=d,d},issuer:f?.issuer??null,documentType:f?.documentType??null,captureSide:f===null?null:f.documentType==="passport"?"single":s.side,selectDocument:(t,r)=>{if(!J(s.documents).includes(t)||!q(s.documents,t).includes(r))throw new RangeError(`${r} from ${t} is not accepted`);(f?.issuer!==t||f.documentType!==r)&&_(),f={issuer:t,documentType:r},m()},capture:t=>{if(f===null)throw new Error("selectDocument() first");if(c!==null&&c.video===t.video)return c.flow.handle;_();let r=f,d=r.documentType==="passport"?"single":s.acceptedSides.length>0?s.side:void 0,l=Q({video:t.video,documentType:r.documentType,issuer:r.issuer,...d!==void 0?{side:d}:{},...t.keepScreenAwake!==void 0?{keepScreenAwake:t.keepScreenAwake}:{},...t.liveMrz!==void 0?{liveMrz:t.liveMrz}:{}},{...e.documentInternals??{},...(()=>{let n=e.currentView()?.capture?.document,w=e.documentInternals?.blurRefuseSharpnessMax??n?.scan?.blurRefuseSharpnessMax;return{engineOptions:{camera:K(n?.camera),shutter:$(n?.scan),guideLock:N(n?.guide),...e.documentInternals?.engineOptions??{}},...typeof w=="number"&&Number.isFinite(w)&&w>=0&&w<=1?{blurRefuseSharpnessMax:w}:{}}})(),deferRead:!0,...(()=>{let n=e.currentView();if(n===null||e.documentInternals?.webOcr!==void 0)return{};let w=oe(e.runtime.client);return{webOcr:{captureDocument:n.capture?.document,salt:n.sessionId,baseUrl:ce(e.runtime.client),...w!==void 0?{reports:w}:{}}}})()});c={video:t.video,flow:l};let i=l.handle.destroy;return l.handle.destroy=()=>{c?.flow===l&&(c=null),i()},b.newHandle(),l.handle.on("state",n=>b.note(n)),l.handle.on("error",n=>{b.noteError(),e.reportCaptureIssue?.(H("document",n,b.value))}),l.handle.on("captured",n=>{I=I.then(()=>V(n,l)).catch(()=>{})}),l.handle}}),a=null,h=null,p=new Set,g=e.runtime.client;e.runtime.client=new Proxy(g,{get(s,m){if(m==="submitCheck")return(h??s).submitCheck.bind(h??s);let t=Reflect.get(s,m);return typeof t=="function"?t.bind(s):t}});let M=()=>{a?.destroy(),a=null,h=null},P=s=>{let m=e.currentView(),t=m===null?null:x(m,{isMobile:e.isMobile()});if(m===null||t?.kind!=="liveness"||t.livePhoto?.icao!==!0)return;if(a===null){let i=X({tuning:m.capture?.icao??null,tuningVersion:m.capture?.tuningVersion??null,...t.icao!=null?{policy:t.icao.policy}:{},still:t.livePhoto.still,...s.assetBaseUrl!==void 0?{assetBaseUrl:s.assetBaseUrl}:{}},e.livePhotoInternals);a=i,h=i.decorate(g),i.onGate(n=>{for(let w of p)w(n)})}let r=a,d=e.baseCapture??{},l=d.engineOptions?.telemetry;return{...d,engineOptions:{...d.engineOptions??{},measureQuality:r.engineOptions.measureQuality,telemetry:i=>{l?.(i),r.engineOptions.telemetry(i)}}}},y=ne({keptPortraitInput:()=>a?.lastPortraitInput()??null,runner:()=>o,currentView:e.currentView,...e.cameraMode!==void 0?{cameraMode:e.cameraMode}:{},...e.captureModeSwitch!==void 0?{captureModeSwitch:e.captureModeSwitch}:{},destroyed:e.destroyed,isMobile:e.isMobile,...e.portraitInternals!==void 0?{internals:e.portraitInternals}:{},...e.uploadInternals!==void 0?{uploadInternals:e.uploadInternals}:{},refreshView:()=>e.refreshView(),...e.reportCaptureIssue!==void 0?{reportCaptureIssue:e.reportCaptureIssue}:{},reportGate:s=>oe(e.runtime.client)?.([s])}),v=re({runner:()=>o,currentView:e.currentView,destroyed:e.destroyed,isMobile:e.isMobile,...e.uploadInternals!==void 0?{uploadInternals:e.uploadInternals}:{},...e.pageCameraInternals!==void 0?{pageCamera:e.pageCameraInternals}:{},refreshView:()=>e.refreshView()}),S=Z({...e,bindDocument:u,bindPortrait:y.bind,bindProofOfAddress:v.bind,stopCameras:()=>{_(),y.destroy(),v.destroy(),M(),e.stopLiveness?.()},onLivePhoto:s=>(p.add(s),()=>p.delete(s))});return o=S,{...S,captureInternals:P,destroy:()=>{_(),y.destroy(),v.destroy(),M(),p.clear()}}}export{Ue as createPlanRunner,oe as reportSink,ce as sdkAssetBase};
|