@sekyro/elements 0.1.0-rc.15 → 0.1.0-rc.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/cdn/chunks/{capture-session-doc-KAKQJPCO-AIHWPBYL.js → capture-session-doc-LKMMJG4H-GQNWHWDA.js} +1 -1
- package/dist/cdn/chunks/{chunk-QXCB7CMC.js → chunk-3DAULGZ2.js} +1 -1
- package/dist/cdn/chunks/{chunk-CAEMCBEY.js → chunk-7T4LO7VD.js} +1 -1
- package/dist/cdn/chunks/{chunk-BSMEALQQ.js → chunk-BR5RW4XZ.js} +1 -1
- package/dist/cdn/chunks/{chunk-SI3OCSQL.js → chunk-DHMC5D6M.js} +1 -1
- package/dist/cdn/chunks/{chunk-IEZ4K3YX.js → chunk-DQGAOSBX.js} +1 -1
- package/dist/cdn/chunks/{chunk-PJT5EI2V.js → chunk-EMKK7NJU.js} +1 -1
- package/dist/cdn/chunks/{chunk-JDVZXXYF.js → chunk-F5GIBIWU.js} +1 -1
- package/dist/cdn/chunks/{chunk-NLTAFWIN.js → chunk-H5T4U7DM.js} +1 -1
- package/dist/cdn/chunks/{chunk-ZEUFK4EC.js → chunk-HOSTJBJM.js} +1 -1
- package/dist/cdn/chunks/chunk-IO5LQDY2.js +33 -0
- package/dist/cdn/chunks/chunk-Q7ACZDU4.js +1 -0
- package/dist/cdn/chunks/{chunk-OCMUHHDC.js → chunk-QR7XWTXK.js} +1 -1
- package/dist/cdn/chunks/{chunk-TWWD2WAW.js → chunk-R5I4TYXJ.js} +1 -1
- package/dist/cdn/chunks/{chunk-OGJRFKPJ.js → chunk-TDAUIJGS.js} +1 -1
- package/dist/cdn/chunks/{chunk-LVBGPPKD.js → chunk-TGVU2IVC.js} +1 -1
- package/dist/cdn/chunks/{chunk-TT57CQGK.js → chunk-TIOXYUT7.js} +2 -2
- package/dist/cdn/chunks/{chunk-2YPWGFSK.js → chunk-UTTEUW7M.js} +1 -1
- package/dist/cdn/chunks/{chunk-HOUFBXEP.js → chunk-VGBSCCXD.js} +1 -1
- package/dist/cdn/chunks/{chunk-BLN4F6B2.js → chunk-XFUL5N47.js} +1 -1
- package/dist/cdn/chunks/{chunk-3SVGT2PS.js → chunk-YLCUWE22.js} +1 -1
- package/dist/cdn/chunks/{chunk-E75YC36S.js → chunk-Z6KNLRUW.js} +1 -1
- package/dist/cdn/chunks/{create-document-capture-AITCB4ZU-QA2Z7I3D.js → create-document-capture-PG6NLCPH-SB25EXKH.js} +1 -1
- package/dist/cdn/chunks/document-capture-view-I72R2TZK-IPPKCL3Y.js +1 -0
- package/dist/cdn/chunks/{eid-view-PWROMDEV-NH4432Y2.js → eid-view-ZM7QAEME-HFAGVDCQ.js} +1 -1
- package/dist/cdn/chunks/{email-otp-view-Q334LLOM-RYZD4GMU.js → email-otp-view-EYS26ZZM-5WX42RSL.js} +1 -1
- package/dist/cdn/chunks/{flow-views-I3YI3NWV-ENMBLDRD.js → flow-views-7SAYQQ62-4RKPVVBZ.js} +1 -1
- package/dist/cdn/chunks/{form-view-XPOGTYL6-R34DVU6J.js → form-view-Y5KA6R5T-KP2XRJQ7.js} +1 -1
- package/dist/cdn/chunks/overlay-de-4OISTBDL-WWT74VG7.js +1 -0
- package/dist/cdn/chunks/overlay-es-YO5UCAO2-U3OAELIS.js +1 -0
- package/dist/cdn/chunks/overlay-pt-E7PSFLLQ-ZPN4CLS4.js +1 -0
- package/dist/cdn/chunks/plan-runner-BZ7LODPB-KXZ5UKVT.js +1 -0
- package/dist/cdn/chunks/{portrait-capture-view-G4BE6IVC-73TWN235.js → portrait-capture-view-E5LKQQ5Y-MZ3BOZEU.js} +1 -1
- package/dist/cdn/chunks/{portrait-review-view-WGI5PXWF-ZJH3G4DR.js → portrait-review-view-NJHH2E4W-5UKV267T.js} +1 -1
- package/dist/cdn/chunks/{proof-of-address-view-CFVHB2XR-3RJQNRNW.js → proof-of-address-view-LS3JZUTD-WPPCFOIG.js} +1 -1
- package/dist/cdn/define.js +1 -1
- package/dist/cdn/index.js +1 -1
- package/dist/{chunk-YEY23NFE.js → chunk-2WYXQYNY.js} +1 -1
- package/dist/chunk-4JHVEBTX.js +33 -0
- package/dist/{chunk-YYQZMOGI.js → chunk-5NSMKCTW.js} +1 -1
- package/dist/{chunk-QESP3Y4J.js → chunk-6NNMOFMF.js} +1 -1
- package/dist/{chunk-BLT5ZVGV.js → chunk-734Y6RUV.js} +1 -1
- package/dist/{chunk-4LFDPSOL.js → chunk-AJHRPKD4.js} +1 -1
- package/dist/{chunk-DGVIPMH7.js → chunk-D3TZZ4SI.js} +1 -1
- package/dist/{chunk-L2D3XWI2.js → chunk-ICJ544T4.js} +1 -1
- package/dist/{chunk-JLKISVND.js → chunk-MWTOWGEI.js} +1 -1
- package/dist/{chunk-DZ64G3BB.js → chunk-VJZANYM3.js} +1 -1
- package/dist/{chunk-M6FHHGY7.js → chunk-WLCS5VAA.js} +1 -1
- package/dist/chunk-XI37ATRU.js +1 -0
- package/dist/{chunk-H2EODYM3.js → chunk-YVGOUZ7T.js} +1 -1
- package/dist/{chunk-PDYEWDSG.js → chunk-ZUFN5VIE.js} +1 -1
- package/dist/define.cjs +5 -5
- package/dist/define.js +1 -1
- package/dist/document-capture-view-I72R2TZK-LCX5EQJR.js +1 -0
- package/dist/{eid-view-PWROMDEV-5AMVHINZ.js → eid-view-ZM7QAEME-7FRC3TV6.js} +1 -1
- package/dist/{email-otp-view-Q334LLOM-WWVHZUZ3.js → email-otp-view-EYS26ZZM-EESWRHKM.js} +1 -1
- package/dist/{flow-views-I3YI3NWV-5FHNXBHD.js → flow-views-7SAYQQ62-3NIWXTDB.js} +1 -1
- package/dist/{form-view-XPOGTYL6-NGLOEF3Y.js → form-view-Y5KA6R5T-DOZFYGBK.js} +1 -1
- package/dist/index.cjs +5 -5
- package/dist/index.d.cts +9 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +1 -1
- package/dist/overlay-de-4OISTBDL-TH46LT3S.js +1 -0
- package/dist/overlay-es-YO5UCAO2-NBICE576.js +1 -0
- package/dist/overlay-pt-E7PSFLLQ-NCA5NABT.js +1 -0
- package/dist/{portrait-capture-view-G4BE6IVC-5UKZX7HH.js → portrait-capture-view-E5LKQQ5Y-E3BRULLL.js} +1 -1
- package/dist/{portrait-review-view-WGI5PXWF-PITOWYGV.js → portrait-review-view-NJHH2E4W-CKMVD7ME.js} +1 -1
- package/dist/{proof-of-address-view-CFVHB2XR-Y6DJUU4V.js → proof-of-address-view-LS3JZUTD-ZQ4BDFNP.js} +1 -1
- package/dist/styles.css +9 -1
- package/package.json +2 -2
- package/sbom.cdx.json +4 -4
- package/dist/cdn/chunks/chunk-2QSUUXLJ.js +0 -1
- package/dist/cdn/chunks/chunk-I7TF57NI.js +0 -33
- package/dist/cdn/chunks/document-capture-view-FSMO25KF-2Q3A6GDQ.js +0 -1
- package/dist/cdn/chunks/overlay-de-VMGXTY3V-VVLXUOLW.js +0 -1
- package/dist/cdn/chunks/overlay-es-45YNJBVM-RHH5Z6UY.js +0 -1
- package/dist/cdn/chunks/overlay-pt-EU4FBZ2U-OHSSK5RZ.js +0 -1
- package/dist/cdn/chunks/plan-runner-HPXZHAQB-N2UJCZUV.js +0 -1
- package/dist/chunk-73RGTE4Z.js +0 -1
- package/dist/chunk-AXDGT3L2.js +0 -33
- package/dist/document-capture-view-FSMO25KF-FFRQD2FZ.js +0 -1
- package/dist/overlay-de-VMGXTY3V-3AGJDOK3.js +0 -1
- package/dist/overlay-es-45YNJBVM-WHWUGDQ6.js +0 -1
- package/dist/overlay-pt-EU4FBZ2U-F34MGCNE.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as xe,e as He,f as Ke,g as Xe}from"./chunk-ZEUFK4EC.js";import{a as ne,b as Ze,c as oe,d as Ve}from"./chunk-P7K7ELYZ.js";import{a as Se,b as Y,c as Ie,d as Ae,e as De,h as Re,i as se,j as Ce,k as Oe,l as We,m as ze}from"./chunk-6MYG4HWP.js";import{a as Ge,b as Pe,c as Ue,d as Fe,e as Ne,f as ae,g as j,h as Be,i as Le,j as qe}from"./chunk-JS2IXPNL.js";import{a as n}from"./chunk-4FHWXBOB.js";var wt=1e4,C,bt=(C=class{constructor(e,t){this.tier="blaze",this.inner=e,t!==void 0&&(this.fallbackReason=t)}static async create(e,t){let r=await import("./vision_bundle-WBHR7TEE.js"),s=await r.FilesetResolver.forVisionTasks(e),a=await r.FaceDetector.createFromOptions(s,{baseOptions:{modelAssetPath:`${e}/blaze_face_short_range.tflite`,delegate:"CPU"},runningMode:"IMAGE"});return new C(a,t)}async detect(e,t,r){let s;try{s=this.inner.detect(e).detections}catch{return null}let a=Mt(s);if(a?.boundingBox===void 0)return null;let o=Q(e),l=kt(a.keypoints,o),c=a.keypoints?.[2],h={box:{x:a.boundingBox.originX,y:a.boundingBox.originY,width:a.boundingBox.width,height:a.boundingBox.height},...l!==void 0?{eyes:l}:{},...c!==void 0?{nose:{x:c.x*o.width,y:c.y*o.height}}:{},score:a.categories[0]?.score??0,extraFaces:je(s.map(d=>d.boundingBox??{width:0,height:0}),s.indexOf(a))};return $e(h,e,t,r)}destroy(){try{this.inner.close()}catch{}}},n(C,"t"),C);function Mt(i){let e,t=-1;for(let r of i){let s=r.categories[0]?.score??0;s>t&&(e=r,t=s)}return e}n(Mt,"R");function kt(i,e){let t=i?.[0],r=i?.[1];if(t===void 0||r===void 0)return;let s=n(l=>({x:l.x*e.width,y:l.y*e.height}),"n"),[a,o]=[s(t),s(r)];return a.x<=o.x?{left:a,right:o}:{left:o,right:a}}n(kt,"T");function Tt(){if(typeof OffscreenCanvas=="function")return new OffscreenCanvas(2,2);let i=document.createElement("canvas");return i.width=2,i.height=2,i}n(Tt,"E");var _t=4;async function Et(){let i=globalThis.FaceDetector;if(typeof i!="function")return{ok:!1,reason:"unsupported"};try{let e=new i({fastMode:!0,maxDetectedFaces:_t});return await e.detect(Tt()),{ok:!0,instance:e}}catch(e){return{ok:!1,reason:`smoke_failed:${e instanceof Error?e.message:String(e)}`}}}n(Et,"w");var P,St=(P=class{constructor(e,t){this.tier="native",this.inner=e,t!==void 0&&(this.fallbackReason=t)}async detect(e,t,r){let s;try{s=await this.inner.detect(e)}catch{return null}let a=s.map(d=>d.boundingBox),o=-1;a.forEach((d,u)=>{let v=a[o];(v===void 0||d.width*d.height>v.width*v.height)&&(o=u)});let l=s[o];if(l===void 0)return null;let c=It(l.landmarks),h={box:{x:l.boundingBox.x,y:l.boundingBox.y,width:l.boundingBox.width,height:l.boundingBox.height},...c!==void 0?{eyes:c}:{},score:1,extraFaces:je(a,o)};return $e(h,e,t,r)}destroy(){}},n(P,"b"),P);function It(i){if(i===void 0)return;let e=i.filter(s=>s.type==="eye").map(s=>s.locations[0]).filter(s=>s!==void 0),[t,r]=e;if(!(t===void 0||r===void 0))return t.x<=r.x?{left:t,right:r}:{left:r,right:t}}n(It,"S");var At=.25;function je(i,e){let t=i[e],r=t===void 0?0:t.width*t.height;if(!(r>0))return 0;let s=0;return i.forEach((a,o)=>{o!==e&&a.width*a.height>=At*r&&(s+=1)}),s}n(je,"f");var ce="/models-v3",xt=["native","blaze"],U,he=(U=class extends Error{constructor(e){super(`no detector tier available (${e})`),this.name="DetectorLadderError",this.fallbackReason=e}},n(U,"x"),U);function Q(i){let e=i;if(typeof e.videoWidth=="number"&&e.videoWidth>0)return{width:e.videoWidth,height:e.videoHeight??0};if(typeof e.naturalWidth=="number"&&e.naturalWidth>0)return{width:e.naturalWidth,height:e.naturalHeight??0};let t=typeof e.width=="number"?e.width:0,r=typeof e.height=="number"?e.height:0;return{width:t,height:r}}n(Q,"y");function $e(i,e,t,r){let s=Q(e),a=s.width>0?t/s.width:1,o=s.height>0?r/s.height:1,l=n(c=>({x:c.x*a,y:c.y*o}),"s");return{box:{x:i.box.x*a,y:i.box.y*o,width:i.box.width*a,height:i.box.height*o},...i.eyes!==void 0?{eyes:{left:l(i.eyes.left),right:l(i.eyes.right)}}:{},...i.nose!==void 0?{nose:l(i.nose)}:{},score:i.score,...i.extraFaces!==void 0?{extraFaces:i.extraFaces}:{}}}n($e,"h");function Dt(i){return i instanceof Error?i.message:String(i)}n(Dt,"C");async function x(i){let e=i.preferred??xt,t=[];for(let r of e){if(r==="native"){let s=await Et();if(s.ok)return new St(s.instance,le(t));t.push(`native:${s.reason}`);continue}try{return await Rt(bt.create(i.v3AssetBaseUrl??ce,le(t)),i.blazeInitTimeoutMs??wt)}catch(s){t.push(s instanceof Ye?"blaze:blaze_init_timeout":`blaze:${Dt(s)}`)}}throw new he(le(t)??"no_tier_available")}n(x,"O");function le(i){return i.length>0?i.join("; "):void 0}n(le,"v");var F,Ye=(F=class extends Error{},n(F,"g"),F);function Rt(i,e){return new Promise((t,r)=>{let s=setTimeout(()=>{r(new Ye(`init exceeded ${e}ms`)),i.then(a=>a.destroy(),()=>{})},e);i.then(a=>{clearTimeout(s),t(a)},a=>{clearTimeout(s),r(a)})})}n(Rt,"W");var R=1;function Qe(){return typeof OffscreenCanvas=="function"&&typeof createImageBitmap=="function"&&typeof Worker=="function"}n(Qe,"K");function Ct(i,e={}){let t=e.createDetector??x,r=null;i.onmessage=s=>{let a=s.data;if(a.v!==R){a.bitmap?.close?.();return}if(a.type==="init"){t(a.options).then(o=>{r=o;let l={v:R,type:"ready",tier:o.tier,...o.fallbackReason!==void 0?{fallbackReason:o.fallbackReason}:{}};i.postMessage(l)});return}if(a.type==="detect"){let o=n(l=>{let c={v:R,type:"result",id:a.id,observation:l};i.postMessage(c),a.bitmap.close?.()},"a");if(r===null){o(null);return}r.detect(a.bitmap,a.streamWidth,a.streamHeight).then(o,()=>o(null))}}}n(Ct,"B");typeof self<"u"&&typeof self.importScripts=="function"&&Ct(self);var O,Je=(O=class{constructor(e,t){this.pending=new Map,this.nextId=1,this.worker=e,this.tier=t.tier,t.fallbackReason!==void 0&&(this.fallbackReason=t.fallbackReason),e.addEventListener("message",r=>{let s=r.data;if(s.v!==R||s.type!=="result")return;let a=this.pending.get(s.id);this.pending.delete(s.id),a?.(s.observation)})}static create(e,t,r=1e4){return new Promise((s,a)=>{let o=setTimeout(()=>{e.removeEventListener("message",l),e.terminate(),a(new Error(`worker detector not ready within ${r}ms`))},r),l=n(h=>{let d=h.data;d.v!==R||d.type!=="ready"||(clearTimeout(o),e.removeEventListener("message",l),s(new O(e,d)))},"s");e.addEventListener("message",l);let c={v:R,type:"init",options:t};e.postMessage(c)})}async detect(e,t,r){let s;try{typeof ImageBitmap<"u"&&e instanceof ImageBitmap?s=e:typeof createImageBitmap=="function"?s=await createImageBitmap(e):s=e}catch{return null}let a=this.nextId;return this.nextId+=1,new Promise(o=>{this.pending.set(a,o);let l={v:R,type:"detect",id:a,bitmap:s,streamWidth:t,streamHeight:r};this.worker.postMessage(l,[s])})}destroy(){for(let e of this.pending.values())e(null);this.pending.clear(),this.worker.terminate()}},n(O,"t"),O);var Ot=[...Ge.filter(i=>i.startsWith("video/mp4")),"video/webm;codecs=h264","video/webm;codecs=avc1","video/webm;codecs=vp8","video/webm;codecs=vp9","video/webm"],lt=new Set;function Gt(i){let e=/(?:Chrome|Chromium)\/(\d+)\./.exec(i??"");return e?Number(e[1]):null}n(Gt,"De");function Pt(i=Ft(),e=globalThis.navigator?.userAgent){if(i===void 0)return"";let t=Gt(e)===126;for(let r of Ot)if(!(lt.has(r)||t&&r.startsWith("video/mp4")))try{if(i(r))return r}catch{}return""}n(Pt,"fe");function et(i){i!==""&<.add(i)}n(et,"V");function Ut(i){return i.replace(/^video\/x-matroska/i,"video/webm")}n(Ut,"ge");function ct(i){let e=/codecs=["']?([^,;"']+)/i.exec(i);return e?e[1].trim():i.split(";")[0].trim()}n(ct,"ut");function Ft(){let i=globalThis.MediaRecorder;return i&&typeof i.isTypeSupported=="function"?e=>i.isTypeSupported(e):void 0}n(Ft,"Oe");var ht=2500,Nt=1e3,Bt=1500,tt=25e5,Lt=100,qt=700,Wt=20,zt=1500,J=null;function Ht(){return J??(J=import("./clip-inspect-DLJXVKV6-TNHTD4LV.js").catch(i=>{throw J=null,i})),J.catch(()=>null)}n(Ht,"Ne");var B,D=(B=class extends Error{constructor(e,t){super(t??e),this.kind=e}},n(B,"S"),B),Kt=100;function it(i,e){return i.stats===void 0?!1:i.stats===null?!0:i.stats.durationMs<e-Kt}n(it,"H");function Xt(i,e){return i.stats?e.stats?i.stats.durationMs>e.stats.durationMs:!0:!1}n(Xt,"be");var L,Zt=(L=class{constructor(e={}){this.recorder=null,this.stream=null,this.chunks=[],this.bytes=0,this.hardStopTimer=null,this.graceTimer=null,this.pollTimer=null,this.settled=!1,this.now=e.now??(()=>globalThis.performance?.now?.()??Date.now())}clearTimers(){this.hardStopTimer&&clearTimeout(this.hardStopTimer),this.graceTimer&&clearTimeout(this.graceTimer),this.pollTimer&&clearInterval(this.pollTimer),this.hardStopTimer=null,this.graceTimer=null,this.pollTimer=null}record(e,t,r,s=ht,a){let o=Pt(),l=Ht();return this.recordRaw(e,t,r,s,a,o).then(c=>Vt(c,l),c=>{throw c instanceof D&&(c.requestedMimeType=o),c})}recordRaw(e,t,r,s,a,o){return this.recorder&&!this.settled?Promise.reject(new D("generic","record() called while a recording is in flight — ClipRecorder handles one recording at a time")):(this.recorder=null,this.clearTimers(),this.chunks=[],this.bytes=0,this.settled=!1,this.stream=e,new Promise((l,c)=>{let h;try{h=new MediaRecorder(e,o?{mimeType:o,videoBitsPerSecond:tt}:{videoBitsPerSecond:tt})}catch{try{h=new MediaRecorder(e)}catch{c(new D("unsupported"));return}}this.recorder=h;let d=n(p=>{this.settled||(this.settled=!0,this.clearTimers(),p())},"d"),u=n(()=>d(()=>{let p=Ut(h.mimeType||o||Pe),M=new Blob(this.chunks,{type:p});if(M.size===0){c(new D("generic","empty clip"));return}if(ae(M)){c(new D("cliptoolarge"));return}l({blob:M,mimeType:p,requestedMimeType:o})}),"u");h.ondataavailable=p=>{p.data&&p.data.size&&(this.chunks.push(p.data),this.bytes+=p.data.size,this.bytes>Ne&&d(()=>{try{h.state!=="inactive"&&h.stop()}catch{}c(new D("cliptoolarge"))}))},h.onstop=u,h.onerror=()=>d(()=>c(new D("generic")));let v=this.now();if(r!==void 0||a!==void 0){let p=!1;h.onstart=()=>{if(!(p||this.settled)&&(p=!0,v=this.now(),r!==void 0))try{r()}catch{}}}try{h.start(Nt)}catch{d(()=>c(new D("generic")));return}let w=n(()=>{if(this.pollTimer&&clearInterval(this.pollTimer),this.pollTimer=null,this.hardStopTimer&&clearTimeout(this.hardStopTimer),this.hardStopTimer=null,this.settled||t?.(),h.state!=="inactive"){try{h.stop()}catch{u()}this.graceTimer=setTimeout(u,Bt)}else u()},"g"),m=this.now();if(a===void 0){this.hardStopTimer=setTimeout(w,s);return}let g=null,y=!1;this.hardStopTimer=setTimeout(w,s+qt),this.pollTimer=setInterval(()=>{if(this.settled||y)return;let p=null;try{p=a.latest()}catch{p=null}let M=p?.presentationTimeMs;M!==void 0&&Number.isFinite(M)&&M>=v&&g===null&&(g=M);let E=g!==null&&M!==void 0&&M-g>=s,I=g===null&&this.now()-m>=s;if(!(!E&&!I)){if(y=!0,this.pollTimer&&clearInterval(this.pollTimer),this.pollTimer=null,I){w();return}this.hardStopTimer&&clearTimeout(this.hardStopTimer),this.hardStopTimer=setTimeout(w,Lt)}},Wt)}))}stop(e){this.clearTimers();let t=this.recorder;if(t&&t.state!=="inactive")try{t.stop()}catch{}this.recorder=null,(e??this.stream)?.getTracks().forEach(r=>r.stop()),this.stream=null}},n(L,"I"),L);async function Vt(i,e){let t,r=new Promise(h=>{t=setTimeout(()=>h(null),zt)}),s=await Promise.race([e,r]);if(clearTimeout(t),s===null)return i;let a;try{a=await s.blobBytes(i.blob)}catch{return{...i,stats:null}}let o=s.inspectClipBytes(a);if(o?.container!=="webm")return{...i,stats:o};let l=s.withWebmDuration(a,o.durationMs);if(l===null)return{...i,stats:o};let c=s.inspectClipBytes(l);return c===null||c.frames!==o.frames||c.durationMs!==o.durationMs?{...i,stats:o}:{...i,blob:new Blob([l],{type:i.blob.type}),stats:o}}n(Vt,"He");var jt=["magenta","yellow","green","blue"],$t={magenta:"rgb(255, 72, 150)",yellow:"rgb(255, 190, 0)",green:"rgb(0, 238, 175)",blue:"rgb(25, 150, 255)",dark:"rgb(0, 0, 0)"};function $i(i){return $t[i]}n($i,"ft");var Yt=4,Qt=4,ee=n(i=>typeof i=="number"&&Number.isFinite(i),"D");function pe(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=>jt.includes(r))||!Array.isArray(e.onsetsMs)||e.onsetsMs.length!==e.colours.length)return!1;let t=-1;for(let r of e.onsetsMs){if(!ee(r)||r<0||r<=t)return!1;t=r}return!(!ee(e.holdMs)||e.holdMs<=0||!ee(e.endMs)||e.endMs<=t||!ee(e.clipMs)||e.clipMs<e.endMs||e.clipMs>8e3)}n(pe,"O");function Jt(i,e){return pe(i)?Math.max(e,Math.ceil(i.clipMs)):e}n(Jt,"ye");function ei(i,e){let t=e.now??(()=>performance.now()),r=pe(i)?i:void 0,s=[],a=null,o=null,l=null,c=!1,h=null,d=n(m=>{h=m;try{e.paint(m)}catch{}},"d"),u=n(m=>{let g=e.frames?.()??null;return g!==null&&l!==null?g.mediaTimeMs+(m-g.presentationTimeMs)-l:m-(o??m)},"u"),v=n((m,g,y=0)=>{if(c)return;let p=Math.max(0,m-u(t()));a=setTimeout(()=>{if(a=null,!c){if(y<Yt&&u(t())<m-Qt){v(m,g,y+1);return}g()}},p)},"f"),w=n(m=>{if(r===void 0)return;let g=r.endMs;if(m>=r.colours.length){v(g,()=>d(null));return}let y=r.onsetsMs[m],p=m+1<r.onsetsMs.length?r.onsetsMs[m+1]:g;v(y,()=>{let M=u(t());if(M>g){h!==null&&d(null);return}let E=r.colours[m];d(E);let I=s.length===0?0:s[s.length-1].tMs;s.push({tMs:Math.max(I,Math.round(M)),colour:E});let T=y+r.holdMs;if(T<p){v(T,()=>{if(u(t())>g){h!==null&&d(null);return}d("dark"),w(m+1)});return}w(m+1)})},"g");return{started(m){if(r===void 0||c||o!==null)return;o=m;let g=e.frames?.()??null;l=g===null?null:g.mediaTimeMs+(m-g.presentationTimeMs),w(0)},stop(){c||(c=!0,a!==null&&clearTimeout(a),a=null,h!==null&&d(null))},report(){return r===void 0?void 0:{nonce:r.nonce,rendered:[...s]}}}}n(ei,"Me");function ti(i,e,t=.92){return new Promise((r,s)=>{let a=i.videoWidth,o=i.videoHeight;if(!a||!o){s(new Error("video-not-ready"));return}let l=e.getContext("2d");if(!l){s(new Error("no-2d-context"));return}e.width=a,e.height=o,l.scale(-1,1),l.drawImage(i,-a,0),e.toBlob(c=>c?r(c):s(new Error("empty-keyframe")),"image/jpeg",t)})}n(ti,"Se");var q,ii=(q=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=n(()=>{this.running&&(this.frameCallbackId=e.requestVideoFrameCallback?.(()=>{this.frameCallbackId=null,this.now()-this.lastRunAt>=this.periodMs&&this.tick(),t()}))},"t");t();return}this.timer=setInterval(()=>this.tick(),this.periodMs)}stop(){this.running=!1,this.timer!==null&&(clearInterval(this.timer),this.timer=null),this.frameCallbackId!==null&&(this.options.video?.cancelVideoFrameCallback?.(this.frameCallbackId),this.frameCallbackId=null)}stats(){let e=this.durations.length===0?0:this.durations.reduce((t,r)=>t+r,0)/this.durations.length;return{degradeCount:this.degradeCount,meanDetectMs:e}}now(){return this.options.now?.()??performance.now()}tick(){if(!this.running)return;if(this.busy){this.degradeCount+=1;return}this.busy=!0,this.lastRunAt=this.now();let e=this.now();this.options.run().catch(()=>{}).finally(()=>{this.busy=!1,this.durations.push(this.now()-e),this.durations.length>20&&this.durations.shift()})}},n(q,"P"),q),ri=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}),N=n(i=>Math.min(1,Math.max(0,i)),"_"),W,rt=(W=class{constructor(e={}){this.p=0,this.lastTickAt=null,this.lastCenter=null,this.velocityEma=0,this.qWindow=[],this.lastSizeDirection="ideal",this.t={...ri,...e}}reset(){this.p=0,this.lastTickAt=null,this.lastCenter=null,this.velocityEma=0,this.qWindow=[],this.lastSizeDirection="ideal"}tick(e){let{observation:t,quality:r,timestampMs:s}=e,a=this.lastTickAt===null?0:Math.max(0,(s-this.lastTickAt)/1e3);this.lastTickAt=s;let o={presence:0,single:1,centering:0,size:0,pose:0,sharpness:N(r.sharpness),exposure:N(r.exposure),motion:1};if(t!==null){o.presence=1,o.single=(t.extraFaces??0)>0?0:1;let d=this.geometryOf(t,e);o.centering=d.centering,o.size=d.size,o.pose=d.pose,o.motion=this.motionOf(d.center,d.iod,s)}else this.lastCenter=null,this.velocityEma=0;let l=Math.min(o.presence,o.single,o.centering,o.size,o.pose,o.sharpness,o.exposure,o.motion);this.p=N(this.p+(l>=this.t.Q_GOOD?this.t.RISE_PER_S*l:-this.t.FALL_PER_S*(1-l))*a),this.qWindow.push({at:s,q:l}),this.qWindow=this.qWindow.filter(d=>d.at>=s-this.t.READY_WINDOW_MS);let c=this.qWindow.map(d=>d.q);if(c.length>=3){let d=Math.min(...c),u=c.indexOf(d);c=c.filter((v,w)=>w!==u)}let h=this.p>=1&&c.every(d=>d>=this.t.Q_GOOD);return{at:s,q:l,p:this.p,factors:o,guidanceKey:this.guidanceOf(o,r,l),ready:h,accepted:l>=this.t.Q_GOOD}}geometryOf(e,t){let{box:r,eyes:s}=e,a={x:t.frameWidth/2,y:t.frameHeight/2},o=Math.min(t.frameWidth,t.frameHeight),l=s!==void 0?{x:(s.left.x+s.right.x)/2,y:(s.left.y+s.right.y)/2}:{x:r.x+r.width/2,y:r.y+r.height/2-this.t.BOX_EYE_OFFSET_FACTOR*r.height},c=s!==void 0?Math.hypot(s.right.x-s.left.x,s.right.y-s.left.y):this.t.IOD_BOX_PROXY_FACTOR*r.width,h=Math.hypot(l.x-a.x,l.y-a.y),d=c<=0?0:1-N(h/(this.t.CENTER_FALLOFF_IOD_MULTIPLE*c)),u=o>0?c/o:0;this.lastSizeDirection=u<this.t.SIZE_IDEAL_MIN?"far":u>this.t.SIZE_IDEAL_MAX?"close":"ideal";let v;u<this.t.SIZE_HARD_MIN||u>this.t.SIZE_HARD_MAX?v=0:u<this.t.SIZE_IDEAL_MIN?v=(u-this.t.SIZE_HARD_MIN)/(this.t.SIZE_IDEAL_MIN-this.t.SIZE_HARD_MIN):u>this.t.SIZE_IDEAL_MAX?v=(this.t.SIZE_HARD_MAX-u)/(this.t.SIZE_HARD_MAX-this.t.SIZE_IDEAL_MAX):v=1;let w=1;if(s!==void 0){let m=Math.abs(Math.atan2(s.right.y-s.left.y,s.right.x-s.left.x))*180/Math.PI;w=1-N(m/this.t.ROLL_MAX_DEG)}return{center:l,iod:c,centering:d,size:v,pose:w}}motionOf(e,t,r){let s=this.lastCenter;if(this.lastCenter={...e,at:r},s===null||t<=0)return 1;let a=(r-s.at)/1e3;if(a<=0)return 1;let o=Math.hypot(e.x-s.x,e.y-s.y)/t/a;o<=this.t.MOTION_DEADBAND_IOD_PER_S&&(o=0);let l=1-Math.exp(-a/this.t.MOTION_TAU_S);return this.velocityEma=l*o+(1-l)*this.velocityEma,1-N(this.velocityEma/this.t.MOTION_VELOCITY_IOD_PER_S)}guidanceOf(e,t,r){if(e.presence<=0)return"fcv3.no_face";if(e.single<=0)return"fcv3.one_face";if(e.size<this.t.GUIDE_SIZE)return this.sizeGuidance();if(e.centering<this.t.GUIDE_CENTERING)return"fcv3.center_face";if(e.pose<this.t.GUIDE_POSE)return"fcv3.straighten";if(e.exposure<this.t.GUIDE_EXPOSURE)return this.exposureGuidance(t);if(e.sharpness<this.t.GUIDE_SHARPNESS)return"fcv3.steady_camera";if(e.motion<this.t.GUIDE_MOTION)return"fcv3.hold_still";if(r<this.t.Q_GOOD){let s=[["size",this.sizeGuidance()],["centering","fcv3.center_face"],["pose","fcv3.straighten"],["exposure",this.exposureGuidance(t)],["sharpness","fcv3.steady_camera"],["motion","fcv3.hold_still"]],a=s[0];for(let o of s)e[o[0]]<e[a[0]]&&(a=o);return a[1]}return"fcv3.hold_still"}sizeGuidance(){return this.lastSizeDirection==="far"?"fcv3.come_closer":"fcv3.move_back"}exposureGuidance(e){let t=(ne[0]+ne[1])/2;return e.meanLuma<t?"fcv3.more_light":"fcv3.too_bright"}},n(W,"k"),W),si=["single","size","centering","pose","exposure","sharpness","motion"];function ai(i){if(i.accepted)return null;if(i.factors.presence<=0)return"no_face";let e="single";for(let t of si)i.factors[t]<i.factors[e]&&(e=t);return e}n(ai,"Ze");var z,st=(z=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=ai(e);if(r===null){this.acceptedMs+=t;return}let s=this.blocked[r]??{count:0,ms:0};s.count+=1,s.ms+=t,this.blocked[r]=s}summary(){let e={};for(let[t,r]of Object.entries(this.blocked))e[t]={count:r.count,ms:Math.round(r.ms)};return{blocked:e,acceptedMs:Math.round(this.acceptedMs),ticks:this.ticks}}},n(z,"w"),z),ni=["obs","manycam","virtual","snap camera","xsplit","droidcam","iriun","camo"],oi=[/^(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 li(i){let e=(i??"").trim().toLowerCase();return e.length===0?"unknown":ni.some(t=>e.includes(t))?"known_virtual":oi.some(t=>t.test(e))?"platform":"unknown"}n(li,"je");function at(i){if(typeof i!="function")return!1;try{return/\{\s*\[native code\]\s*\}\s*$/.test(Function.prototype.toString.call(i))}catch{return!1}}n(at,"Te");function ci(i=globalThis){return at(i.navigator?.mediaDevices?.getUserMedia)&&at(i.MediaStreamTrack?.prototype?.getSettings)}n(ci,"$e");async function hi(i,e=globalThis){let t=e.crypto?.subtle?.digest;if(typeof t=="function")try{let r=new Uint8Array(await t.call(e.crypto?.subtle,"SHA-256",new TextEncoder().encode(i)));return Array.from(r.subarray(0,8),s=>s.toString(16).padStart(2,"0")).join("")}catch{return}}n(hi,"Je");async function ui(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 hi(t.deviceId,e);a!==void 0&&(r.deviceIdHash=a)}let s;try{s=i.label}catch{s=void 0}return{trackSettings:r,capabilitiesPresent:typeof i.getCapabilities=="function",labelClass:li(s),prototypesIntact:ci(e)}}n(ui,"Ce");var ue=n(i=>Math.round(i*100)/100,"K");function di(i){let e=i,t=typeof e?.requestVideoFrameCallback=="function",r=null,s=null,a=0,o=0,l=0,c=0,h=0,d=0,u=n(()=>{!t||e?.requestVideoFrameCallback===void 0||(r=e.requestVideoFrameCallback((v,w)=>{if(r=null,!t)return;let m=w.presentationTime;if(s!==null){let g=m-s.presentationTimeMs;o+=1;let y=g-l;l+=y/o,c+=y*(g-l)}typeof w.captureTime=="number"&&Number.isFinite(w.captureTime)&&(h+=m-w.captureTime,d+=1),a+=1,s={mediaTimeMs:w.mediaTime*1e3,presentationTimeMs:m},u()}))},"u");return u(),{latest:n(()=>s,"latest"),stats:n(()=>({n:a,meanGapMs:o===0?0:ue(l),stdGapMs:o<2?0:ue(Math.sqrt(c/(o-1))),captureLatencyMs:d===0?null:ue(h/d)}),"stats"),stop:n(()=>{t&&(t=!1,r!==null&&e?.cancelVideoFrameCallback?.(r),r=null)},"stop")}}n(di,"Ee");function fi(i,e,t){return{...i,rvfc:e,rampPainter:t}}n(fi,"_e");var mi=1e3,de="fcv3.hold_upright",pi=200,fe=4,gi=600,vi=1e3,nt={sharpness:1,exposure:1,meanLuma:128};function yi(i,e){return e.width=i.videoWidth,e.height=i.videoHeight,e.getContext("2d").drawImage(i,0,0),new Promise((t,r)=>e.toBlob(s=>s?t(s):r(new Error("empty-keyframe")),"image/jpeg",.92))}n(yi,"it");function wi(){return Y()==="phone"}n(wi,"at");var H,ut=(H=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??wi)(),this.setState("preflight");let r=Ue();if(r!=="OK"){this.fail(r==="INSECURE_CONTEXT"?"insecure":"unsupported",{phase:"preflight"});return}this.setState("acquiring");let s=t.getUserMedia??(h=>navigator.mediaDevices.getUserMedia(h)),a;this.cameraRequestedAt=this.now();try{let{facingMode:h,...d}=Se(Ie(),this.facing).video;a=await ze(this.facing,d,{getUserMedia:s,enumerateDevices:ki(t)})}catch(h){if(e!==this.attempt)return;if(h instanceof We){this.fail("backcamera",{phase:"acquiring",name:j(h)});return}this.fail(Le(h),{phase:"acquiring",name:j(h)});return}if(xe(a),qe(a),e!==this.attempt){for(let h of a.getTracks())h.stop();return}this.stream=a;let o=a.getVideoTracks?.()[0];if(this.trackProvenance=o===void 0?null:ui(o).catch(()=>null),this.facing=Ae(a)??this.facing,t.video.srcObject=a,await t.video.play().catch(()=>{}),e!==this.attempt)return;if(this.cameraReadyAt=this.now(),this.detector===null){let h={v3AssetBaseUrl:t.v3AssetBaseUrl},d=t.createDetector??(t.createWorker!==void 0&&Qe()?async()=>{try{return await Je.create(t.createWorker(),h)}catch{return x(h)}}:()=>x(h)),u;try{u=await d()}catch(v){e===this.attempt&&this.fail("models",{phase:"models",name:j(v)},v instanceof he?v.fallbackReason:Mi(v));return}if(e!==this.attempt){u.destroy();return}this.detector=u,this.options.telemetry?.({type:"detector",tier:u.tier,fallbackReason:u.fallbackReason})}let l=He(),c=t.deviceClass??Ke(l);this.profiler=new Xe(c),this.options.telemetry?.({type:"profile",staticClass:c,activeClass:this.profiler.deviceClass,simd:l.simd}),this.gate=new rt(t.thresholds??{}),this.blockStats=new st,this.lastGateSnapshotAt=this.now(),t.rankKeyframes?.()&&import("./keyframe-rank-YAJLYJYF-WCA6RPMD.js").then(h=>me=h,()=>{}),this.setState("positioning"),this.positioningStartedAt=this.now(),this.startScheduler(e)}get animations(){return this.profiler?.profile.animations??"full"}startScheduler(e){let t=this.profiler;if(t===null)return;if(this.scheduler!==null){let s=this.scheduler.stats();this.carriedDegrade+=s.degradeCount,s.meanDetectMs>0&&this.carriedMeans.push(s.meanDetectMs),this.scheduler.stop()}let r=new ii({cadenceHz:t.profile.cadenceHz,video:this.options.video,now:this.options.now,run:n(()=>this.detectTick(e),"run")});this.scheduler=r,r.start()}async detectTick(e){let{detector:t,gate:r,profiler:s}=this,a=this.options.video;if(e!==this.attempt||t===null||r===null||s===null||this.fired||a.videoWidth===0)return;if(this.isLandscape()){this.holdUpright(e);return}let o=s.deviceClass,l=this.now(),c=this.options.makeSnapshot?.(a,s.profile.inputWidth)??this.defaultSnapshot(a,s.profile.inputWidth),h=null;try{h=await t.detect(c,a.videoWidth,a.videoHeight)}catch{h=null}if(e!==this.attempt||this.fired)return;s.record(this.now()-l),s.deviceClass!==o&&this.startScheduler(e);let d=h===null?nt:this.options.measureQuality?.(a,h.box)??this.defaultQuality(a,h.box),u=r.tick({timestampMs:this.now(),observation:h,quality:d,frameWidth:a.videoWidth,frameHeight:a.videoHeight});u.accepted&&this.faceAcquiredAt===null&&(this.faceAcquiredAt=u.at),this.blockStats?.record(u),!u.ready&&u.at-this.lastGateSnapshotAt>=mi&&(this.lastGateSnapshotAt=u.at,this.reportGate(!1)),this.emit("checks",{engine:"v3",progress:u.p,q:u.q,factors:u.factors,attempt:e}),u.guidanceKey!==this.lastGuidanceKey&&(this.lastGuidanceKey=u.guidanceKey,this.emit("guidance",{key:u.guidanceKey})),u.ready&&this.stateValue==="positioning"&&(this.fired=!0,this.captureCompleteAt=u.at,this.fire(e))}async fire(e){let{options:t}=this,r=this.scheduler;r?.stop(),this.reportGate(!0);let s=r?.stats()??{degradeCount:0,meanDetectMs:0},a=[...this.carriedMeans,...s.meanDetectMs>0?[s.meanDetectMs]:[]];t.telemetry?.({type:"fired",timeToGateMs:this.now()-this.positioningStartedAt,degradeCount:this.carriedDegrade+s.degradeCount,meanDetectMs:a.length===0?0:a.reduce((T,b)=>T+b,0)/a.length});let o=t.mode??"clip",l=t.rankKeyframes?.()&&me?me.default(this,e).catch(()=>this.collectKeyframes(e)):this.collectKeyframes(e);if(o==="photo"){let T=this.watchRotation(e,null),b=await l;if(T(),e!==this.attempt)return;if(b===null){this.fail("generic",{phase:"keyframes"});return}let A=await this.provenance({n:0,meanGapMs:0,stdGapMs:0,captureLatencyMs:null},!1);if(e!==this.attempt)return;this.finishCapture({keyframe:b.blob,previewDataUrl:b.previewDataUrl,...A});return}this.setState("recording");let c=this.stream;if(c===null){this.fail("generic",{phase:"recording"});return}let h=t.screenRamp?.(),d=pe(h),u=null;l.then(T=>{u=T},()=>{});let v=n(()=>{e===this.attempt&&u!==null&&this.emit("frozen",{previewDataUrl:u.previewDataUrl})},"f"),w=Jt(h,ht),m=null,g,y=0;try{let T=this.recordTake(e,c,h,w,void 0).then(S=>S,S=>({failed:S})),[b,A]=await Promise.all([T,l]);if(g=A,e!==this.attempt)return;if("failed"in b){if(b.failed.kind==="cliptoolarge")throw b.failed;et(b.failed.requestedMimeType??"")}else m=b,it(b.clip,w)?b.clip.stats===null&&et(b.clip.requestedMimeType??""):v();if(m===null||it(m.clip,w)){y=1,t.telemetry?.({type:"clip_retake",reason:m===null?"error":m.clip.stats===null?"unreadable":"short"});let S=null;try{S=await this.recordTake(e,c,h,w,v)}catch(K){if(m===null)throw K}if(e!==this.attempt)return;S!==null&&(m===null||Xt(S.clip,m.clip))&&(m=S),S===null&&v()}}catch(T){if(e!==this.attempt)return;let b=T.kind;this.fail(b==="cliptoolarge"?"cliptoolarge":"recorder",{phase:"recording",name:j(T)});return}if(m===null){this.fail("recorder",{phase:"recording"});return}let{clip:p,rvfc:M,report:E}=m;if(ae(p.blob)){this.fail("cliptoolarge",{phase:"recording"});return}if(g===null){this.fail("generic",{phase:"keyframes"});return}let I=await this.provenance(M,d);e===this.attempt&&this.finishCapture({clip:p.blob,clipMimeType:p.mimeType,...p.stats?{clipStats:p.stats}:{},clipRetakes:y,keyframe:g.blob,previewDataUrl:g.previewDataUrl,...E!==void 0&&E.rendered.length>0?{screenRamp:E}:{},...I})}async recordTake(e,t,r,s,a){let o=this.options.createRecorder?.()??new Zt({now:n(()=>this.now(),"now")}),l=di(this.options.video),c=ei(r,{paint:n(u=>{(u===null||e===this.attempt)&&this.emit("ramp",{colour:u})},"paint"),now:n(()=>this.now(),"now"),frames:l.latest});this.ramp=c;let h=n(()=>{l.stop(),c.stop(),this.ramp===c&&(this.ramp=null)},"l"),d=this.watchRotation(e,o);try{return{clip:await o.record(t,a,()=>c.started(this.now()),s,l),rvfc:l.stats(),report:c.report()}}finally{d(),h()}}async provenance(e,t){let r=this.trackProvenance;if(r===null)return{};let s,a=new Promise(l=>{s=setTimeout(()=>l(null),vi)}),o=await Promise.race([r,a]);return clearTimeout(s),o===null?{}:{provenance:fi(o,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!==de&&(this.lastGuidanceKey=de,this.emit("guidance",{key:de}))}watchRotation(e,t){if(!this.uprightGuard)return()=>{};let r=this.options.video,s=n(()=>{if(e!==this.attempt||t!==null&&this.stateValue!=="recording"){l();return}r.videoWidth>0&&this.isLandscape()&&(l(),this.abortRecording(e,t))},"n"),a=setInterval(s,pi);r.addEventListener?.("resize",s);let o=!1;function l(){o||(o=!0,clearInterval(a),r.removeEventListener?.("resize",s))}return n(l,"o"),l}abortRecording(e,t){if(e!==this.attempt)return;this.attempt+=1;let r=this.attempt;try{t?.stop()}catch{}this.ramp?.stop(),this.ramp=null,this.fired=!1,this.captureCompleteAt=null,this.gate=new rt(this.options.thresholds??{}),this.blockStats=new st,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=gi/(fe-1),s=null;for(let a=0;a<fe;a+=1){if(e!==this.attempt)return s;try{let o=await t(this.options.video);(s===null||o.sharpness>s.sharpness)&&(s=o)}catch{}a<fe-1&&await bi(r)}return s}finishCapture(e){this.stopTracks(),this.setState("captured");let t=this.captureTiming();this.emit("artifacts",t===void 0?e:{...e,timing:t})}captureTiming(){let e={},t=n((r,s,a)=>{s!==null&&a!==null&&(e[r]=Math.max(0,Math.round(a-s)))},"t");return t("cameraReadyMs",this.cameraRequestedAt,this.cameraReadyAt),t("faceAcquireMs",this.cameraReadyAt,this.faceAcquiredAt),t("captureMs",this.faceAcquiredAt,this.captureCompleteAt),Object.keys(e).length>0?e:void 0}async defaultKeyframe(e){let t=document.createElement("canvas"),r=await(this.facing==="user"?ti:yi)(e,t),s=t.toDataURL("image/jpeg",.92);return{blob:r,previewDataUrl:s,sharpness:this.centerSharpness(e)}}defaultSnapshot(e,t){try{let r=this.snapshotCanvas??document.createElement("canvas"),s=t/Math.max(1,e.videoWidth),a=Math.max(1,Math.round(e.videoWidth*s)),o=Math.max(1,Math.round(e.videoHeight*s)),l=r.getContext("2d");return l===null?e:(r.width!==a&&(r.width=a),r.height!==o&&(r.height=o),l.drawImage(e,0,0,a,o),this.snapshotCanvas=r,r)}catch{return e}}defaultQuality(e,t){let r=ot(e,t,96);return r===null?nt:{sharpness:oe(r),exposure:Ve(r),meanLuma:Ze(r)}}centerSharpness(e){let t=Q(e),r=ot(e,{x:t.width*.25,y:t.height*.25,width:t.width*.5,height:t.height*.5},96);return r===null?0:oe(r)}teardownAttempt(){this.scheduler?.stop(),this.scheduler=null,this.reportGate(!0),this.gate=null,this.ramp?.stop(),this.ramp=null,this.stopTracks()}reportGate(e){let t=this.blockStats,r=this.profiler;if(t===null||r===null)return;let s=t.summary();e&&(this.blockStats=null),s.ticks!==0&&this.options.telemetry?.({type:"gate",final:e,activeClass:r.deviceClass,cadenceHz:r.profile.cadenceHz,...s})}stopTracks(){if(this.stream!==null){for(let e of this.stream.getTracks())e.stop();this.stream=null}}fail(e,t,r){this.scheduler?.stop(),this.reportGate(!0),this.stopTracks(),this.setState("error"),this.options.telemetry?.({type:"error",kind:e,fallbackReason:r});let{phase:s,name:a}=t;this.emit("error",{kind:e,retryable:e!=="insecure"&&e!=="unsupported",detail:a===void 0?{phase:s}:{phase:s,name:a}})}setState(e){this.stateValue=e,this.emit("statechange",{state:e})}now(){return this.options.now?.()??performance.now()}},n(H,"ke"),H),me;function bi(i){return new Promise(e=>setTimeout(e,i))}n(bi,"st");function Mi(i){return i instanceof Error?i.message:String(i)}n(Mi,"ot");function ot(i,e,t){try{let r=document.createElement("canvas"),s=t/Math.max(1,e.width);r.width=Math.max(1,Math.round(e.width*s)),r.height=Math.max(1,Math.round(e.height*s));let a=r.getContext("2d");return a===null?null:(a.drawImage(i,e.x,e.y,e.width,e.height,0,0,r.width,r.height),a.getImageData(0,0,r.width,r.height))}catch{return null}}n(ot,"we");function ki(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()}n(ki,"lt");var Ti=12e4,dt=13e4,_i=3e3,Ei=1200,ge=Symbol.for("@sekyro/web.preload.v1");function ye(){let i=globalThis;return i[ge]??(i[ge]=new Map),i[ge]}n(ye,"h");function te(i){let e=(i??ce).replace(/\/+$/,"");return e===""?"/":e}n(te,"b");function mt(i){let e=ye(),t=e.get(i);return t===void 0&&(t={status:"idle",promise:null,scheduled:null,detectorPromise:null,detector:null,listeners:new Set},e.set(i,t)),t}n(mt,"ae");function ve(i,e){if(i.status!==e){i.status=e;for(let t of[...i.listeners])t(e)}}n(ve,"k");var Si=n(i=>x({preferred:["blaze"],v3AssetBaseUrl:i,blazeInitTimeoutMs:Ti}),"K"),Ii=Si;function Ai(){return typeof window<"u"&&typeof navigator<"u"&&typeof navigator.mediaDevices?.getUserMedia=="function"}n(Ai,"Ce");function xi(){return navigator.connection?.saveData===!0}n(xi,"Se");function Di(i){let e=window;if(typeof e.requestIdleCallback=="function"){let r=e.requestIdleCallback(i,{timeout:_i});return()=>e.cancelIdleCallback?.(r)}let t=setTimeout(i,Ei);return()=>clearTimeout(t)}n(Di,"Ee");function Ri(i,e){let t,r=new Promise(l=>{t=l}),s=!1,a=n(()=>{},"u"),o={promise:r,settle:n(l=>{s||(s=!0,a(),i.scheduled===o&&(i.scheduled=null),t(l))},"settle")};return i.scheduled=o,a=Di(()=>{s||o.settle(we(i,e))}),r}n(Ri,"ye");function we(i,e){if((i.status==="loading"||i.status==="ready")&&i.promise!==null)return i.promise;ve(i,"loading");let t=new Promise(o=>o(Ii(e)));i.detectorPromise=t;let r,s=new Promise((o,l)=>{r=setTimeout(()=>{t.then(c=>c.destroy(),()=>{}),l(new Error(`detector preload exceeded ${dt} ms`))},dt)}),a=Promise.race([t,s]).then(o=>i.detectorPromise!==t?(o.destroy(),i.status):(i.detector=o,ve(i,"ready"),"ready"),o=>(i.detectorPromise===t&&(i.detectorPromise=null,i.detector=null,ve(i,"failed"),console.warn("[@sekyro/web] face-detector preload failed:",o)),i.status)).finally(()=>clearTimeout(r));return i.promise=a,i.scheduled?.settle(a),a}n(we,"U");function sr(i={}){if(!Ai())return Promise.resolve("idle");let e=te(i.assetBaseUrl),t=mt(e);return i.respectSaveData===!0&&xi()?Promise.resolve(t.status):(t.status==="loading"||t.status==="ready")&&t.promise!==null?t.promise:i.idle===!0?t.scheduled?.promise??Ri(t,e):we(t,e)}n(sr,"xe");function ar(i){return ye().get(te(i))?.status??"idle"}n(ar,"Fe");function nr(i,e){let t=mt(te(e));return t.listeners.add(i),()=>{t.listeners.delete(i)}}n(nr,"Ie");function Ci(i){return{get tier(){return i.tier},get fallbackReason(){return i.fallbackReason},detect:n((...e)=>i.detect(...e),"detect"),destroy:n(()=>{},"destroy")}}n(Ci,"Le");function Oi(i){let e=te(i),t=ye().get(e);if(!(t===void 0||t.detector===null&&t.detectorPromise===null&&t.scheduled===null))return async()=>{t.scheduled!==null&&we(t,e);let r=t.promise;for(;t.detector===null&&r!==null&&(await r,t.promise!==r);)r=t.promise;return t.detector!==null?Ci(t.detector):x({v3AssetBaseUrl:e})}}n(Oi,"de");var Gi=new Set(["inuse","overconstrained","notfound"]),Pi=[500,1500];function Ui(i){switch(i){case"fcv3.no_face":case"fcv3.center_face":case"fcv3.straighten":return"center";case"fcv3.come_closer":return"closer";case"fcv3.move_back":return"farther";case"fcv3.more_light":case"fcv3.too_bright":return"light";case"fcv3.hold_still":case"fcv3.steady_camera":return"still";case"fcv3.hold_upright":return"upright";case"fcv3.one_face":return"one_face";default:return null}}n(Ui,"Ae");function Fi(i){switch(i){case"preflight":case"acquiring":return"starting";case"positioning":return"gating";default:return i}}n(Fi,"Pe");function ft(i){switch(i){case"permission":case"notfound":case"inuse":case"insecure":case"unsupported":return i;case"backcamera":return"notfound";default:{let e=i;return"generic"}}}n(ft,"ue");function Ni(i,e,t){if(t===void 0)return{kind:ft(i),retryable:e};let r=Be(t.name);return{kind:ft(i),retryable:e,detail:{...r!==void 0?{name:r}:{},phase:t.phase,engineKind:i}}}n(Ni,"we");var Bi=new Set(["captured","uploading","checking"]);function Li(i,e={},t,r=()=>"self",s=()=>{},a){let o=e.now??(()=>performance.now()),l=e.canChooseFacing??Re,c="user",h=Ce(),d=r(),u=De(),v=!Fe(),w=e.engineOptions,m=w?.createDetector===void 0&&w?.createWorker===void 0?{createDetector:n(()=>{let f=Oi(i.assetBaseUrl);return f!==void 0?f():x({v3AssetBaseUrl:i.assetBaseUrl})},"createDetector")}:{},g={video:i.video,mode:v?"photo":"clip",rankKeyframes:t,facingMode:void 0,v3AssetBaseUrl:i.assetBaseUrl,screenRamp:n(()=>d==="self"&&u.count("ramp")>0?s():void 0,"screenRamp"),...e.engineOptions??{},...m},y=e.createEngine?.(g)??new ut(g),p="idle",M=null,E=0,I=!1,T="full",b=null,A=null,S=0,K=0,be=n(()=>{i.video.videoWidth>0&&i.video.videoHeight>0&&(S=i.video.videoWidth,K=i.video.videoHeight)},"W"),Me=Oe({enabled:i.keepScreenAwake!==!1}),X=n(f=>{p=f,Me.setActive(f==="starting"||f==="gating"||f==="recording"),u.emit("state",f)},"S"),ie=n(()=>u.emit("gate",{progress:E,hint:M,faceDetected:I}),"F"),re=n(()=>{let f=y.animations??"full";f!==T&&(T=f,u.emit("profile",{animations:T}))},"I"),G=0,$=null,pt=e.schedule??((f,k)=>{let _=setTimeout(f,k);return()=>clearTimeout(_)}),Z=n(()=>{$?.(),$=null},"E"),gt=n((f,k)=>{if(V||!Gi.has(f)||k?.phase!=="acquiring")return!1;let _=Pi[G];return _===void 0?!1:(G+=1,Z(),$=pt(()=>{$=null,V||y.retry()},_),!0)},"fe"),vt=[y.on("statechange",({state:f})=>{if(f==="error")return;let k=Fi(f);k==="gating"&&(G=0),k==="starting"&&p!=="starting"&&(M=null,E=0,I=!1,b=null,A=null,S=0,K=0),X(k),re(),k==="recording"&&(be(),b=o(),M="hold",E=1,ie())}),y.on("checks",f=>{be(),E=f.progress,I=f.factors.presence>0,ie(),re()}),y.on("guidance",({key:f})=>{M=Ui(f),ie()}),y.on("frozen",({previewDataUrl:f})=>{A=o(),u.emit("frozen",{previewDataUrl:f})}),y.on("ramp",f=>u.emit("ramp",f)),y.on("artifacts",f=>{if(p!=="captured")return;let k=Y(),_=f.clipStats,_e=_!==void 0?Math.round(_.durationMs):b!==null&&A!==null?Math.max(0,Math.round(A-b)):void 0,Ee=_!==void 0&&_.frames>1&&_.durationMs>0?Math.round(_.frames*1e4/_.durationMs)/10:void 0;u.emit("captured",{keyframe:f.keyframe,...f.clip!==void 0?{clip:f.clip}:{},...f.clipMimeType!==void 0?{clipMime:f.clipMimeType}:{},width:i.video.videoWidth||S,height:i.video.videoHeight||K,..._e!==void 0?{clipMs:_e}:{},..._!==void 0?{clipFrames:_.frames}:{},...Ee!==void 0?{fps:Ee}:{},...f.clipRetakes!==void 0?{clipRetakes:f.clipRetakes}:{},...f.clipMimeType!==void 0?{codec:ct(f.clipMimeType)}:{},captureChannel:k==="desktop"?"desktop":"mobile",formFactor:k,...v?{degraded:"NO_RECORDER"}:{},engine:"v3",facingMode:y.facingMode,mode:d,...f.timing,...f.screenRamp!==void 0?{screenRamp:f.screenRamp}:{},...f.provenance!==void 0?{provenance:f.provenance}:{}})}),y.on("error",({kind:f,retryable:k,detail:_})=>{f==="backcamera"&&yt()||gt(f,_)||(X("error"),re(),u.emit("error",Ni(f,k,_)))})],ke=!1;function yt(){return V||ke||d!=="assisted"||a===void 0||a.session()!=="choice"?!1:(ke=!0,a.onModeChange("self"),d="self",c=se("self"),X("mode_switch"),y.restart(c),!0)}n(yt,"me");let Te=n(async()=>a!==void 0&&a.session()==="choice"&&await l().catch(()=>!1),"$"),V=!1;return{handle:{get state(){return p},get captureMode(){return r()},get facingMode(){return y.facingMode??c},on:n((f,k)=>u.on(f,k),"on"),start:n(f=>(d=r(),h.facing(d,i.facing),c=h.facing(d,f?.facing),Z(),G=0,y.start({facingMode:c})),"start"),retry:n(()=>{Z(),G=0,y.retry()},"retry"),switchCamera:n(()=>h.refuseSwitch(r()),"switchCamera"),canSwitchCaptureMode:Te,setCaptureMode:n(async f=>{if(f===r()||!await Te()||V||Bi.has(p)||a===void 0)return!1;a.onModeChange(f),d=f;let k=se(f);return c=k,p==="idle"||(X("mode_switch"),Z(),G=0,y.restart(k)),!0},"setCaptureMode"),destroy:n(()=>{V=!0,Z();for(let f of vt)f();Me.setActive(!1),y.destroy(),u.clear()},"destroy")},setFlowState:n(f=>{p!==f&&X(f)},"setFlowState")}}n(Li,"De");function or(i){return Li(i).handle}n(or,"Ze");export{$i as a,sr as b,ar as c,nr as d,Ni as e,Li as f,or as g};
|
|
1
|
+
import{d as xe,e as He,f as Ke,g as Xe}from"./chunk-HOSTJBJM.js";import{a as ne,b as Ze,c as oe,d as Ve}from"./chunk-P7K7ELYZ.js";import{a as Se,b as Y,c as Ie,d as Ae,e as De,h as Re,i as se,j as Ce,k as Oe,l as We,m as ze}from"./chunk-6MYG4HWP.js";import{a as Ge,b as Pe,c as Ue,d as Fe,e as Ne,f as ae,g as j,h as Be,i as Le,j as qe}from"./chunk-JS2IXPNL.js";import{a as n}from"./chunk-4FHWXBOB.js";var wt=1e4,C,bt=(C=class{constructor(e,t){this.tier="blaze",this.inner=e,t!==void 0&&(this.fallbackReason=t)}static async create(e,t){let r=await import("./vision_bundle-WBHR7TEE.js"),s=await r.FilesetResolver.forVisionTasks(e),a=await r.FaceDetector.createFromOptions(s,{baseOptions:{modelAssetPath:`${e}/blaze_face_short_range.tflite`,delegate:"CPU"},runningMode:"IMAGE"});return new C(a,t)}async detect(e,t,r){let s;try{s=this.inner.detect(e).detections}catch{return null}let a=Mt(s);if(a?.boundingBox===void 0)return null;let o=Q(e),l=kt(a.keypoints,o),c=a.keypoints?.[2],h={box:{x:a.boundingBox.originX,y:a.boundingBox.originY,width:a.boundingBox.width,height:a.boundingBox.height},...l!==void 0?{eyes:l}:{},...c!==void 0?{nose:{x:c.x*o.width,y:c.y*o.height}}:{},score:a.categories[0]?.score??0,extraFaces:je(s.map(d=>d.boundingBox??{width:0,height:0}),s.indexOf(a))};return $e(h,e,t,r)}destroy(){try{this.inner.close()}catch{}}},n(C,"t"),C);function Mt(i){let e,t=-1;for(let r of i){let s=r.categories[0]?.score??0;s>t&&(e=r,t=s)}return e}n(Mt,"R");function kt(i,e){let t=i?.[0],r=i?.[1];if(t===void 0||r===void 0)return;let s=n(l=>({x:l.x*e.width,y:l.y*e.height}),"n"),[a,o]=[s(t),s(r)];return a.x<=o.x?{left:a,right:o}:{left:o,right:a}}n(kt,"T");function Tt(){if(typeof OffscreenCanvas=="function")return new OffscreenCanvas(2,2);let i=document.createElement("canvas");return i.width=2,i.height=2,i}n(Tt,"E");var _t=4;async function Et(){let i=globalThis.FaceDetector;if(typeof i!="function")return{ok:!1,reason:"unsupported"};try{let e=new i({fastMode:!0,maxDetectedFaces:_t});return await e.detect(Tt()),{ok:!0,instance:e}}catch(e){return{ok:!1,reason:`smoke_failed:${e instanceof Error?e.message:String(e)}`}}}n(Et,"w");var P,St=(P=class{constructor(e,t){this.tier="native",this.inner=e,t!==void 0&&(this.fallbackReason=t)}async detect(e,t,r){let s;try{s=await this.inner.detect(e)}catch{return null}let a=s.map(d=>d.boundingBox),o=-1;a.forEach((d,u)=>{let v=a[o];(v===void 0||d.width*d.height>v.width*v.height)&&(o=u)});let l=s[o];if(l===void 0)return null;let c=It(l.landmarks),h={box:{x:l.boundingBox.x,y:l.boundingBox.y,width:l.boundingBox.width,height:l.boundingBox.height},...c!==void 0?{eyes:c}:{},score:1,extraFaces:je(a,o)};return $e(h,e,t,r)}destroy(){}},n(P,"b"),P);function It(i){if(i===void 0)return;let e=i.filter(s=>s.type==="eye").map(s=>s.locations[0]).filter(s=>s!==void 0),[t,r]=e;if(!(t===void 0||r===void 0))return t.x<=r.x?{left:t,right:r}:{left:r,right:t}}n(It,"S");var At=.25;function je(i,e){let t=i[e],r=t===void 0?0:t.width*t.height;if(!(r>0))return 0;let s=0;return i.forEach((a,o)=>{o!==e&&a.width*a.height>=At*r&&(s+=1)}),s}n(je,"f");var ce="/models-v3",xt=["native","blaze"],U,he=(U=class extends Error{constructor(e){super(`no detector tier available (${e})`),this.name="DetectorLadderError",this.fallbackReason=e}},n(U,"x"),U);function Q(i){let e=i;if(typeof e.videoWidth=="number"&&e.videoWidth>0)return{width:e.videoWidth,height:e.videoHeight??0};if(typeof e.naturalWidth=="number"&&e.naturalWidth>0)return{width:e.naturalWidth,height:e.naturalHeight??0};let t=typeof e.width=="number"?e.width:0,r=typeof e.height=="number"?e.height:0;return{width:t,height:r}}n(Q,"y");function $e(i,e,t,r){let s=Q(e),a=s.width>0?t/s.width:1,o=s.height>0?r/s.height:1,l=n(c=>({x:c.x*a,y:c.y*o}),"s");return{box:{x:i.box.x*a,y:i.box.y*o,width:i.box.width*a,height:i.box.height*o},...i.eyes!==void 0?{eyes:{left:l(i.eyes.left),right:l(i.eyes.right)}}:{},...i.nose!==void 0?{nose:l(i.nose)}:{},score:i.score,...i.extraFaces!==void 0?{extraFaces:i.extraFaces}:{}}}n($e,"h");function Dt(i){return i instanceof Error?i.message:String(i)}n(Dt,"C");async function x(i){let e=i.preferred??xt,t=[];for(let r of e){if(r==="native"){let s=await Et();if(s.ok)return new St(s.instance,le(t));t.push(`native:${s.reason}`);continue}try{return await Rt(bt.create(i.v3AssetBaseUrl??ce,le(t)),i.blazeInitTimeoutMs??wt)}catch(s){t.push(s instanceof Ye?"blaze:blaze_init_timeout":`blaze:${Dt(s)}`)}}throw new he(le(t)??"no_tier_available")}n(x,"O");function le(i){return i.length>0?i.join("; "):void 0}n(le,"v");var F,Ye=(F=class extends Error{},n(F,"g"),F);function Rt(i,e){return new Promise((t,r)=>{let s=setTimeout(()=>{r(new Ye(`init exceeded ${e}ms`)),i.then(a=>a.destroy(),()=>{})},e);i.then(a=>{clearTimeout(s),t(a)},a=>{clearTimeout(s),r(a)})})}n(Rt,"W");var R=1;function Qe(){return typeof OffscreenCanvas=="function"&&typeof createImageBitmap=="function"&&typeof Worker=="function"}n(Qe,"K");function Ct(i,e={}){let t=e.createDetector??x,r=null;i.onmessage=s=>{let a=s.data;if(a.v!==R){a.bitmap?.close?.();return}if(a.type==="init"){t(a.options).then(o=>{r=o;let l={v:R,type:"ready",tier:o.tier,...o.fallbackReason!==void 0?{fallbackReason:o.fallbackReason}:{}};i.postMessage(l)});return}if(a.type==="detect"){let o=n(l=>{let c={v:R,type:"result",id:a.id,observation:l};i.postMessage(c),a.bitmap.close?.()},"a");if(r===null){o(null);return}r.detect(a.bitmap,a.streamWidth,a.streamHeight).then(o,()=>o(null))}}}n(Ct,"B");typeof self<"u"&&typeof self.importScripts=="function"&&Ct(self);var O,Je=(O=class{constructor(e,t){this.pending=new Map,this.nextId=1,this.worker=e,this.tier=t.tier,t.fallbackReason!==void 0&&(this.fallbackReason=t.fallbackReason),e.addEventListener("message",r=>{let s=r.data;if(s.v!==R||s.type!=="result")return;let a=this.pending.get(s.id);this.pending.delete(s.id),a?.(s.observation)})}static create(e,t,r=1e4){return new Promise((s,a)=>{let o=setTimeout(()=>{e.removeEventListener("message",l),e.terminate(),a(new Error(`worker detector not ready within ${r}ms`))},r),l=n(h=>{let d=h.data;d.v!==R||d.type!=="ready"||(clearTimeout(o),e.removeEventListener("message",l),s(new O(e,d)))},"s");e.addEventListener("message",l);let c={v:R,type:"init",options:t};e.postMessage(c)})}async detect(e,t,r){let s;try{typeof ImageBitmap<"u"&&e instanceof ImageBitmap?s=e:typeof createImageBitmap=="function"?s=await createImageBitmap(e):s=e}catch{return null}let a=this.nextId;return this.nextId+=1,new Promise(o=>{this.pending.set(a,o);let l={v:R,type:"detect",id:a,bitmap:s,streamWidth:t,streamHeight:r};this.worker.postMessage(l,[s])})}destroy(){for(let e of this.pending.values())e(null);this.pending.clear(),this.worker.terminate()}},n(O,"t"),O);var Ot=[...Ge.filter(i=>i.startsWith("video/mp4")),"video/webm;codecs=h264","video/webm;codecs=avc1","video/webm;codecs=vp8","video/webm;codecs=vp9","video/webm"],lt=new Set;function Gt(i){let e=/(?:Chrome|Chromium)\/(\d+)\./.exec(i??"");return e?Number(e[1]):null}n(Gt,"De");function Pt(i=Ft(),e=globalThis.navigator?.userAgent){if(i===void 0)return"";let t=Gt(e)===126;for(let r of Ot)if(!(lt.has(r)||t&&r.startsWith("video/mp4")))try{if(i(r))return r}catch{}return""}n(Pt,"fe");function et(i){i!==""&<.add(i)}n(et,"V");function Ut(i){return i.replace(/^video\/x-matroska/i,"video/webm")}n(Ut,"ge");function ct(i){let e=/codecs=["']?([^,;"']+)/i.exec(i);return e?e[1].trim():i.split(";")[0].trim()}n(ct,"ut");function Ft(){let i=globalThis.MediaRecorder;return i&&typeof i.isTypeSupported=="function"?e=>i.isTypeSupported(e):void 0}n(Ft,"Oe");var ht=2500,Nt=1e3,Bt=1500,tt=25e5,Lt=100,qt=700,Wt=20,zt=1500,J=null;function Ht(){return J??(J=import("./clip-inspect-DLJXVKV6-TNHTD4LV.js").catch(i=>{throw J=null,i})),J.catch(()=>null)}n(Ht,"Ne");var B,D=(B=class extends Error{constructor(e,t){super(t??e),this.kind=e}},n(B,"S"),B),Kt=100;function it(i,e){return i.stats===void 0?!1:i.stats===null?!0:i.stats.durationMs<e-Kt}n(it,"H");function Xt(i,e){return i.stats?e.stats?i.stats.durationMs>e.stats.durationMs:!0:!1}n(Xt,"be");var L,Zt=(L=class{constructor(e={}){this.recorder=null,this.stream=null,this.chunks=[],this.bytes=0,this.hardStopTimer=null,this.graceTimer=null,this.pollTimer=null,this.settled=!1,this.now=e.now??(()=>globalThis.performance?.now?.()??Date.now())}clearTimers(){this.hardStopTimer&&clearTimeout(this.hardStopTimer),this.graceTimer&&clearTimeout(this.graceTimer),this.pollTimer&&clearInterval(this.pollTimer),this.hardStopTimer=null,this.graceTimer=null,this.pollTimer=null}record(e,t,r,s=ht,a){let o=Pt(),l=Ht();return this.recordRaw(e,t,r,s,a,o).then(c=>Vt(c,l),c=>{throw c instanceof D&&(c.requestedMimeType=o),c})}recordRaw(e,t,r,s,a,o){return this.recorder&&!this.settled?Promise.reject(new D("generic","record() called while a recording is in flight — ClipRecorder handles one recording at a time")):(this.recorder=null,this.clearTimers(),this.chunks=[],this.bytes=0,this.settled=!1,this.stream=e,new Promise((l,c)=>{let h;try{h=new MediaRecorder(e,o?{mimeType:o,videoBitsPerSecond:tt}:{videoBitsPerSecond:tt})}catch{try{h=new MediaRecorder(e)}catch{c(new D("unsupported"));return}}this.recorder=h;let d=n(p=>{this.settled||(this.settled=!0,this.clearTimers(),p())},"d"),u=n(()=>d(()=>{let p=Ut(h.mimeType||o||Pe),M=new Blob(this.chunks,{type:p});if(M.size===0){c(new D("generic","empty clip"));return}if(ae(M)){c(new D("cliptoolarge"));return}l({blob:M,mimeType:p,requestedMimeType:o})}),"u");h.ondataavailable=p=>{p.data&&p.data.size&&(this.chunks.push(p.data),this.bytes+=p.data.size,this.bytes>Ne&&d(()=>{try{h.state!=="inactive"&&h.stop()}catch{}c(new D("cliptoolarge"))}))},h.onstop=u,h.onerror=()=>d(()=>c(new D("generic")));let v=this.now();if(r!==void 0||a!==void 0){let p=!1;h.onstart=()=>{if(!(p||this.settled)&&(p=!0,v=this.now(),r!==void 0))try{r()}catch{}}}try{h.start(Nt)}catch{d(()=>c(new D("generic")));return}let w=n(()=>{if(this.pollTimer&&clearInterval(this.pollTimer),this.pollTimer=null,this.hardStopTimer&&clearTimeout(this.hardStopTimer),this.hardStopTimer=null,this.settled||t?.(),h.state!=="inactive"){try{h.stop()}catch{u()}this.graceTimer=setTimeout(u,Bt)}else u()},"g"),m=this.now();if(a===void 0){this.hardStopTimer=setTimeout(w,s);return}let g=null,y=!1;this.hardStopTimer=setTimeout(w,s+qt),this.pollTimer=setInterval(()=>{if(this.settled||y)return;let p=null;try{p=a.latest()}catch{p=null}let M=p?.presentationTimeMs;M!==void 0&&Number.isFinite(M)&&M>=v&&g===null&&(g=M);let E=g!==null&&M!==void 0&&M-g>=s,I=g===null&&this.now()-m>=s;if(!(!E&&!I)){if(y=!0,this.pollTimer&&clearInterval(this.pollTimer),this.pollTimer=null,I){w();return}this.hardStopTimer&&clearTimeout(this.hardStopTimer),this.hardStopTimer=setTimeout(w,Lt)}},Wt)}))}stop(e){this.clearTimers();let t=this.recorder;if(t&&t.state!=="inactive")try{t.stop()}catch{}this.recorder=null,(e??this.stream)?.getTracks().forEach(r=>r.stop()),this.stream=null}},n(L,"I"),L);async function Vt(i,e){let t,r=new Promise(h=>{t=setTimeout(()=>h(null),zt)}),s=await Promise.race([e,r]);if(clearTimeout(t),s===null)return i;let a;try{a=await s.blobBytes(i.blob)}catch{return{...i,stats:null}}let o=s.inspectClipBytes(a);if(o?.container!=="webm")return{...i,stats:o};let l=s.withWebmDuration(a,o.durationMs);if(l===null)return{...i,stats:o};let c=s.inspectClipBytes(l);return c===null||c.frames!==o.frames||c.durationMs!==o.durationMs?{...i,stats:o}:{...i,blob:new Blob([l],{type:i.blob.type}),stats:o}}n(Vt,"He");var jt=["magenta","yellow","green","blue"],$t={magenta:"rgb(255, 72, 150)",yellow:"rgb(255, 190, 0)",green:"rgb(0, 238, 175)",blue:"rgb(25, 150, 255)",dark:"rgb(0, 0, 0)"};function $i(i){return $t[i]}n($i,"ft");var Yt=4,Qt=4,ee=n(i=>typeof i=="number"&&Number.isFinite(i),"D");function pe(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=>jt.includes(r))||!Array.isArray(e.onsetsMs)||e.onsetsMs.length!==e.colours.length)return!1;let t=-1;for(let r of e.onsetsMs){if(!ee(r)||r<0||r<=t)return!1;t=r}return!(!ee(e.holdMs)||e.holdMs<=0||!ee(e.endMs)||e.endMs<=t||!ee(e.clipMs)||e.clipMs<e.endMs||e.clipMs>8e3)}n(pe,"O");function Jt(i,e){return pe(i)?Math.max(e,Math.ceil(i.clipMs)):e}n(Jt,"ye");function ei(i,e){let t=e.now??(()=>performance.now()),r=pe(i)?i:void 0,s=[],a=null,o=null,l=null,c=!1,h=null,d=n(m=>{h=m;try{e.paint(m)}catch{}},"d"),u=n(m=>{let g=e.frames?.()??null;return g!==null&&l!==null?g.mediaTimeMs+(m-g.presentationTimeMs)-l:m-(o??m)},"u"),v=n((m,g,y=0)=>{if(c)return;let p=Math.max(0,m-u(t()));a=setTimeout(()=>{if(a=null,!c){if(y<Yt&&u(t())<m-Qt){v(m,g,y+1);return}g()}},p)},"f"),w=n(m=>{if(r===void 0)return;let g=r.endMs;if(m>=r.colours.length){v(g,()=>d(null));return}let y=r.onsetsMs[m],p=m+1<r.onsetsMs.length?r.onsetsMs[m+1]:g;v(y,()=>{let M=u(t());if(M>g){h!==null&&d(null);return}let E=r.colours[m];d(E);let I=s.length===0?0:s[s.length-1].tMs;s.push({tMs:Math.max(I,Math.round(M)),colour:E});let T=y+r.holdMs;if(T<p){v(T,()=>{if(u(t())>g){h!==null&&d(null);return}d("dark"),w(m+1)});return}w(m+1)})},"g");return{started(m){if(r===void 0||c||o!==null)return;o=m;let g=e.frames?.()??null;l=g===null?null:g.mediaTimeMs+(m-g.presentationTimeMs),w(0)},stop(){c||(c=!0,a!==null&&clearTimeout(a),a=null,h!==null&&d(null))},report(){return r===void 0?void 0:{nonce:r.nonce,rendered:[...s]}}}}n(ei,"Me");function ti(i,e,t=.92){return new Promise((r,s)=>{let a=i.videoWidth,o=i.videoHeight;if(!a||!o){s(new Error("video-not-ready"));return}let l=e.getContext("2d");if(!l){s(new Error("no-2d-context"));return}e.width=a,e.height=o,l.scale(-1,1),l.drawImage(i,-a,0),e.toBlob(c=>c?r(c):s(new Error("empty-keyframe")),"image/jpeg",t)})}n(ti,"Se");var q,ii=(q=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=n(()=>{this.running&&(this.frameCallbackId=e.requestVideoFrameCallback?.(()=>{this.frameCallbackId=null,this.now()-this.lastRunAt>=this.periodMs&&this.tick(),t()}))},"t");t();return}this.timer=setInterval(()=>this.tick(),this.periodMs)}stop(){this.running=!1,this.timer!==null&&(clearInterval(this.timer),this.timer=null),this.frameCallbackId!==null&&(this.options.video?.cancelVideoFrameCallback?.(this.frameCallbackId),this.frameCallbackId=null)}stats(){let e=this.durations.length===0?0:this.durations.reduce((t,r)=>t+r,0)/this.durations.length;return{degradeCount:this.degradeCount,meanDetectMs:e}}now(){return this.options.now?.()??performance.now()}tick(){if(!this.running)return;if(this.busy){this.degradeCount+=1;return}this.busy=!0,this.lastRunAt=this.now();let e=this.now();this.options.run().catch(()=>{}).finally(()=>{this.busy=!1,this.durations.push(this.now()-e),this.durations.length>20&&this.durations.shift()})}},n(q,"P"),q),ri=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}),N=n(i=>Math.min(1,Math.max(0,i)),"_"),W,rt=(W=class{constructor(e={}){this.p=0,this.lastTickAt=null,this.lastCenter=null,this.velocityEma=0,this.qWindow=[],this.lastSizeDirection="ideal",this.t={...ri,...e}}reset(){this.p=0,this.lastTickAt=null,this.lastCenter=null,this.velocityEma=0,this.qWindow=[],this.lastSizeDirection="ideal"}tick(e){let{observation:t,quality:r,timestampMs:s}=e,a=this.lastTickAt===null?0:Math.max(0,(s-this.lastTickAt)/1e3);this.lastTickAt=s;let o={presence:0,single:1,centering:0,size:0,pose:0,sharpness:N(r.sharpness),exposure:N(r.exposure),motion:1};if(t!==null){o.presence=1,o.single=(t.extraFaces??0)>0?0:1;let d=this.geometryOf(t,e);o.centering=d.centering,o.size=d.size,o.pose=d.pose,o.motion=this.motionOf(d.center,d.iod,s)}else this.lastCenter=null,this.velocityEma=0;let l=Math.min(o.presence,o.single,o.centering,o.size,o.pose,o.sharpness,o.exposure,o.motion);this.p=N(this.p+(l>=this.t.Q_GOOD?this.t.RISE_PER_S*l:-this.t.FALL_PER_S*(1-l))*a),this.qWindow.push({at:s,q:l}),this.qWindow=this.qWindow.filter(d=>d.at>=s-this.t.READY_WINDOW_MS);let c=this.qWindow.map(d=>d.q);if(c.length>=3){let d=Math.min(...c),u=c.indexOf(d);c=c.filter((v,w)=>w!==u)}let h=this.p>=1&&c.every(d=>d>=this.t.Q_GOOD);return{at:s,q:l,p:this.p,factors:o,guidanceKey:this.guidanceOf(o,r,l),ready:h,accepted:l>=this.t.Q_GOOD}}geometryOf(e,t){let{box:r,eyes:s}=e,a={x:t.frameWidth/2,y:t.frameHeight/2},o=Math.min(t.frameWidth,t.frameHeight),l=s!==void 0?{x:(s.left.x+s.right.x)/2,y:(s.left.y+s.right.y)/2}:{x:r.x+r.width/2,y:r.y+r.height/2-this.t.BOX_EYE_OFFSET_FACTOR*r.height},c=s!==void 0?Math.hypot(s.right.x-s.left.x,s.right.y-s.left.y):this.t.IOD_BOX_PROXY_FACTOR*r.width,h=Math.hypot(l.x-a.x,l.y-a.y),d=c<=0?0:1-N(h/(this.t.CENTER_FALLOFF_IOD_MULTIPLE*c)),u=o>0?c/o:0;this.lastSizeDirection=u<this.t.SIZE_IDEAL_MIN?"far":u>this.t.SIZE_IDEAL_MAX?"close":"ideal";let v;u<this.t.SIZE_HARD_MIN||u>this.t.SIZE_HARD_MAX?v=0:u<this.t.SIZE_IDEAL_MIN?v=(u-this.t.SIZE_HARD_MIN)/(this.t.SIZE_IDEAL_MIN-this.t.SIZE_HARD_MIN):u>this.t.SIZE_IDEAL_MAX?v=(this.t.SIZE_HARD_MAX-u)/(this.t.SIZE_HARD_MAX-this.t.SIZE_IDEAL_MAX):v=1;let w=1;if(s!==void 0){let m=Math.abs(Math.atan2(s.right.y-s.left.y,s.right.x-s.left.x))*180/Math.PI;w=1-N(m/this.t.ROLL_MAX_DEG)}return{center:l,iod:c,centering:d,size:v,pose:w}}motionOf(e,t,r){let s=this.lastCenter;if(this.lastCenter={...e,at:r},s===null||t<=0)return 1;let a=(r-s.at)/1e3;if(a<=0)return 1;let o=Math.hypot(e.x-s.x,e.y-s.y)/t/a;o<=this.t.MOTION_DEADBAND_IOD_PER_S&&(o=0);let l=1-Math.exp(-a/this.t.MOTION_TAU_S);return this.velocityEma=l*o+(1-l)*this.velocityEma,1-N(this.velocityEma/this.t.MOTION_VELOCITY_IOD_PER_S)}guidanceOf(e,t,r){if(e.presence<=0)return"fcv3.no_face";if(e.single<=0)return"fcv3.one_face";if(e.size<this.t.GUIDE_SIZE)return this.sizeGuidance();if(e.centering<this.t.GUIDE_CENTERING)return"fcv3.center_face";if(e.pose<this.t.GUIDE_POSE)return"fcv3.straighten";if(e.exposure<this.t.GUIDE_EXPOSURE)return this.exposureGuidance(t);if(e.sharpness<this.t.GUIDE_SHARPNESS)return"fcv3.steady_camera";if(e.motion<this.t.GUIDE_MOTION)return"fcv3.hold_still";if(r<this.t.Q_GOOD){let s=[["size",this.sizeGuidance()],["centering","fcv3.center_face"],["pose","fcv3.straighten"],["exposure",this.exposureGuidance(t)],["sharpness","fcv3.steady_camera"],["motion","fcv3.hold_still"]],a=s[0];for(let o of s)e[o[0]]<e[a[0]]&&(a=o);return a[1]}return"fcv3.hold_still"}sizeGuidance(){return this.lastSizeDirection==="far"?"fcv3.come_closer":"fcv3.move_back"}exposureGuidance(e){let t=(ne[0]+ne[1])/2;return e.meanLuma<t?"fcv3.more_light":"fcv3.too_bright"}},n(W,"k"),W),si=["single","size","centering","pose","exposure","sharpness","motion"];function ai(i){if(i.accepted)return null;if(i.factors.presence<=0)return"no_face";let e="single";for(let t of si)i.factors[t]<i.factors[e]&&(e=t);return e}n(ai,"Ze");var z,st=(z=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=ai(e);if(r===null){this.acceptedMs+=t;return}let s=this.blocked[r]??{count:0,ms:0};s.count+=1,s.ms+=t,this.blocked[r]=s}summary(){let e={};for(let[t,r]of Object.entries(this.blocked))e[t]={count:r.count,ms:Math.round(r.ms)};return{blocked:e,acceptedMs:Math.round(this.acceptedMs),ticks:this.ticks}}},n(z,"w"),z),ni=["obs","manycam","virtual","snap camera","xsplit","droidcam","iriun","camo"],oi=[/^(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 li(i){let e=(i??"").trim().toLowerCase();return e.length===0?"unknown":ni.some(t=>e.includes(t))?"known_virtual":oi.some(t=>t.test(e))?"platform":"unknown"}n(li,"je");function at(i){if(typeof i!="function")return!1;try{return/\{\s*\[native code\]\s*\}\s*$/.test(Function.prototype.toString.call(i))}catch{return!1}}n(at,"Te");function ci(i=globalThis){return at(i.navigator?.mediaDevices?.getUserMedia)&&at(i.MediaStreamTrack?.prototype?.getSettings)}n(ci,"$e");async function hi(i,e=globalThis){let t=e.crypto?.subtle?.digest;if(typeof t=="function")try{let r=new Uint8Array(await t.call(e.crypto?.subtle,"SHA-256",new TextEncoder().encode(i)));return Array.from(r.subarray(0,8),s=>s.toString(16).padStart(2,"0")).join("")}catch{return}}n(hi,"Je");async function ui(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 hi(t.deviceId,e);a!==void 0&&(r.deviceIdHash=a)}let s;try{s=i.label}catch{s=void 0}return{trackSettings:r,capabilitiesPresent:typeof i.getCapabilities=="function",labelClass:li(s),prototypesIntact:ci(e)}}n(ui,"Ce");var ue=n(i=>Math.round(i*100)/100,"K");function di(i){let e=i,t=typeof e?.requestVideoFrameCallback=="function",r=null,s=null,a=0,o=0,l=0,c=0,h=0,d=0,u=n(()=>{!t||e?.requestVideoFrameCallback===void 0||(r=e.requestVideoFrameCallback((v,w)=>{if(r=null,!t)return;let m=w.presentationTime;if(s!==null){let g=m-s.presentationTimeMs;o+=1;let y=g-l;l+=y/o,c+=y*(g-l)}typeof w.captureTime=="number"&&Number.isFinite(w.captureTime)&&(h+=m-w.captureTime,d+=1),a+=1,s={mediaTimeMs:w.mediaTime*1e3,presentationTimeMs:m},u()}))},"u");return u(),{latest:n(()=>s,"latest"),stats:n(()=>({n:a,meanGapMs:o===0?0:ue(l),stdGapMs:o<2?0:ue(Math.sqrt(c/(o-1))),captureLatencyMs:d===0?null:ue(h/d)}),"stats"),stop:n(()=>{t&&(t=!1,r!==null&&e?.cancelVideoFrameCallback?.(r),r=null)},"stop")}}n(di,"Ee");function fi(i,e,t){return{...i,rvfc:e,rampPainter:t}}n(fi,"_e");var mi=1e3,de="fcv3.hold_upright",pi=200,fe=4,gi=600,vi=1e3,nt={sharpness:1,exposure:1,meanLuma:128};function yi(i,e){return e.width=i.videoWidth,e.height=i.videoHeight,e.getContext("2d").drawImage(i,0,0),new Promise((t,r)=>e.toBlob(s=>s?t(s):r(new Error("empty-keyframe")),"image/jpeg",.92))}n(yi,"it");function wi(){return Y()==="phone"}n(wi,"at");var H,ut=(H=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??wi)(),this.setState("preflight");let r=Ue();if(r!=="OK"){this.fail(r==="INSECURE_CONTEXT"?"insecure":"unsupported",{phase:"preflight"});return}this.setState("acquiring");let s=t.getUserMedia??(h=>navigator.mediaDevices.getUserMedia(h)),a;this.cameraRequestedAt=this.now();try{let{facingMode:h,...d}=Se(Ie(),this.facing).video;a=await ze(this.facing,d,{getUserMedia:s,enumerateDevices:ki(t)})}catch(h){if(e!==this.attempt)return;if(h instanceof We){this.fail("backcamera",{phase:"acquiring",name:j(h)});return}this.fail(Le(h),{phase:"acquiring",name:j(h)});return}if(xe(a),qe(a),e!==this.attempt){for(let h of a.getTracks())h.stop();return}this.stream=a;let o=a.getVideoTracks?.()[0];if(this.trackProvenance=o===void 0?null:ui(o).catch(()=>null),this.facing=Ae(a)??this.facing,t.video.srcObject=a,await t.video.play().catch(()=>{}),e!==this.attempt)return;if(this.cameraReadyAt=this.now(),this.detector===null){let h={v3AssetBaseUrl:t.v3AssetBaseUrl},d=t.createDetector??(t.createWorker!==void 0&&Qe()?async()=>{try{return await Je.create(t.createWorker(),h)}catch{return x(h)}}:()=>x(h)),u;try{u=await d()}catch(v){e===this.attempt&&this.fail("models",{phase:"models",name:j(v)},v instanceof he?v.fallbackReason:Mi(v));return}if(e!==this.attempt){u.destroy();return}this.detector=u,this.options.telemetry?.({type:"detector",tier:u.tier,fallbackReason:u.fallbackReason})}let l=He(),c=t.deviceClass??Ke(l);this.profiler=new Xe(c),this.options.telemetry?.({type:"profile",staticClass:c,activeClass:this.profiler.deviceClass,simd:l.simd}),this.gate=new rt(t.thresholds??{}),this.blockStats=new st,this.lastGateSnapshotAt=this.now(),t.rankKeyframes?.()&&import("./keyframe-rank-YAJLYJYF-WCA6RPMD.js").then(h=>me=h,()=>{}),this.setState("positioning"),this.positioningStartedAt=this.now(),this.startScheduler(e)}get animations(){return this.profiler?.profile.animations??"full"}startScheduler(e){let t=this.profiler;if(t===null)return;if(this.scheduler!==null){let s=this.scheduler.stats();this.carriedDegrade+=s.degradeCount,s.meanDetectMs>0&&this.carriedMeans.push(s.meanDetectMs),this.scheduler.stop()}let r=new ii({cadenceHz:t.profile.cadenceHz,video:this.options.video,now:this.options.now,run:n(()=>this.detectTick(e),"run")});this.scheduler=r,r.start()}async detectTick(e){let{detector:t,gate:r,profiler:s}=this,a=this.options.video;if(e!==this.attempt||t===null||r===null||s===null||this.fired||a.videoWidth===0)return;if(this.isLandscape()){this.holdUpright(e);return}let o=s.deviceClass,l=this.now(),c=this.options.makeSnapshot?.(a,s.profile.inputWidth)??this.defaultSnapshot(a,s.profile.inputWidth),h=null;try{h=await t.detect(c,a.videoWidth,a.videoHeight)}catch{h=null}if(e!==this.attempt||this.fired)return;s.record(this.now()-l),s.deviceClass!==o&&this.startScheduler(e);let d=h===null?nt:this.options.measureQuality?.(a,h.box)??this.defaultQuality(a,h.box),u=r.tick({timestampMs:this.now(),observation:h,quality:d,frameWidth:a.videoWidth,frameHeight:a.videoHeight});u.accepted&&this.faceAcquiredAt===null&&(this.faceAcquiredAt=u.at),this.blockStats?.record(u),!u.ready&&u.at-this.lastGateSnapshotAt>=mi&&(this.lastGateSnapshotAt=u.at,this.reportGate(!1)),this.emit("checks",{engine:"v3",progress:u.p,q:u.q,factors:u.factors,attempt:e}),u.guidanceKey!==this.lastGuidanceKey&&(this.lastGuidanceKey=u.guidanceKey,this.emit("guidance",{key:u.guidanceKey})),u.ready&&this.stateValue==="positioning"&&(this.fired=!0,this.captureCompleteAt=u.at,this.fire(e))}async fire(e){let{options:t}=this,r=this.scheduler;r?.stop(),this.reportGate(!0);let s=r?.stats()??{degradeCount:0,meanDetectMs:0},a=[...this.carriedMeans,...s.meanDetectMs>0?[s.meanDetectMs]:[]];t.telemetry?.({type:"fired",timeToGateMs:this.now()-this.positioningStartedAt,degradeCount:this.carriedDegrade+s.degradeCount,meanDetectMs:a.length===0?0:a.reduce((T,b)=>T+b,0)/a.length});let o=t.mode??"clip",l=t.rankKeyframes?.()&&me?me.default(this,e).catch(()=>this.collectKeyframes(e)):this.collectKeyframes(e);if(o==="photo"){let T=this.watchRotation(e,null),b=await l;if(T(),e!==this.attempt)return;if(b===null){this.fail("generic",{phase:"keyframes"});return}let A=await this.provenance({n:0,meanGapMs:0,stdGapMs:0,captureLatencyMs:null},!1);if(e!==this.attempt)return;this.finishCapture({keyframe:b.blob,previewDataUrl:b.previewDataUrl,...A});return}this.setState("recording");let c=this.stream;if(c===null){this.fail("generic",{phase:"recording"});return}let h=t.screenRamp?.(),d=pe(h),u=null;l.then(T=>{u=T},()=>{});let v=n(()=>{e===this.attempt&&u!==null&&this.emit("frozen",{previewDataUrl:u.previewDataUrl})},"f"),w=Jt(h,ht),m=null,g,y=0;try{let T=this.recordTake(e,c,h,w,void 0).then(S=>S,S=>({failed:S})),[b,A]=await Promise.all([T,l]);if(g=A,e!==this.attempt)return;if("failed"in b){if(b.failed.kind==="cliptoolarge")throw b.failed;et(b.failed.requestedMimeType??"")}else m=b,it(b.clip,w)?b.clip.stats===null&&et(b.clip.requestedMimeType??""):v();if(m===null||it(m.clip,w)){y=1,t.telemetry?.({type:"clip_retake",reason:m===null?"error":m.clip.stats===null?"unreadable":"short"});let S=null;try{S=await this.recordTake(e,c,h,w,v)}catch(K){if(m===null)throw K}if(e!==this.attempt)return;S!==null&&(m===null||Xt(S.clip,m.clip))&&(m=S),S===null&&v()}}catch(T){if(e!==this.attempt)return;let b=T.kind;this.fail(b==="cliptoolarge"?"cliptoolarge":"recorder",{phase:"recording",name:j(T)});return}if(m===null){this.fail("recorder",{phase:"recording"});return}let{clip:p,rvfc:M,report:E}=m;if(ae(p.blob)){this.fail("cliptoolarge",{phase:"recording"});return}if(g===null){this.fail("generic",{phase:"keyframes"});return}let I=await this.provenance(M,d);e===this.attempt&&this.finishCapture({clip:p.blob,clipMimeType:p.mimeType,...p.stats?{clipStats:p.stats}:{},clipRetakes:y,keyframe:g.blob,previewDataUrl:g.previewDataUrl,...E!==void 0&&E.rendered.length>0?{screenRamp:E}:{},...I})}async recordTake(e,t,r,s,a){let o=this.options.createRecorder?.()??new Zt({now:n(()=>this.now(),"now")}),l=di(this.options.video),c=ei(r,{paint:n(u=>{(u===null||e===this.attempt)&&this.emit("ramp",{colour:u})},"paint"),now:n(()=>this.now(),"now"),frames:l.latest});this.ramp=c;let h=n(()=>{l.stop(),c.stop(),this.ramp===c&&(this.ramp=null)},"l"),d=this.watchRotation(e,o);try{return{clip:await o.record(t,a,()=>c.started(this.now()),s,l),rvfc:l.stats(),report:c.report()}}finally{d(),h()}}async provenance(e,t){let r=this.trackProvenance;if(r===null)return{};let s,a=new Promise(l=>{s=setTimeout(()=>l(null),vi)}),o=await Promise.race([r,a]);return clearTimeout(s),o===null?{}:{provenance:fi(o,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!==de&&(this.lastGuidanceKey=de,this.emit("guidance",{key:de}))}watchRotation(e,t){if(!this.uprightGuard)return()=>{};let r=this.options.video,s=n(()=>{if(e!==this.attempt||t!==null&&this.stateValue!=="recording"){l();return}r.videoWidth>0&&this.isLandscape()&&(l(),this.abortRecording(e,t))},"n"),a=setInterval(s,pi);r.addEventListener?.("resize",s);let o=!1;function l(){o||(o=!0,clearInterval(a),r.removeEventListener?.("resize",s))}return n(l,"o"),l}abortRecording(e,t){if(e!==this.attempt)return;this.attempt+=1;let r=this.attempt;try{t?.stop()}catch{}this.ramp?.stop(),this.ramp=null,this.fired=!1,this.captureCompleteAt=null,this.gate=new rt(this.options.thresholds??{}),this.blockStats=new st,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=gi/(fe-1),s=null;for(let a=0;a<fe;a+=1){if(e!==this.attempt)return s;try{let o=await t(this.options.video);(s===null||o.sharpness>s.sharpness)&&(s=o)}catch{}a<fe-1&&await bi(r)}return s}finishCapture(e){this.stopTracks(),this.setState("captured");let t=this.captureTiming();this.emit("artifacts",t===void 0?e:{...e,timing:t})}captureTiming(){let e={},t=n((r,s,a)=>{s!==null&&a!==null&&(e[r]=Math.max(0,Math.round(a-s)))},"t");return t("cameraReadyMs",this.cameraRequestedAt,this.cameraReadyAt),t("faceAcquireMs",this.cameraReadyAt,this.faceAcquiredAt),t("captureMs",this.faceAcquiredAt,this.captureCompleteAt),Object.keys(e).length>0?e:void 0}async defaultKeyframe(e){let t=document.createElement("canvas"),r=await(this.facing==="user"?ti:yi)(e,t),s=t.toDataURL("image/jpeg",.92);return{blob:r,previewDataUrl:s,sharpness:this.centerSharpness(e)}}defaultSnapshot(e,t){try{let r=this.snapshotCanvas??document.createElement("canvas"),s=t/Math.max(1,e.videoWidth),a=Math.max(1,Math.round(e.videoWidth*s)),o=Math.max(1,Math.round(e.videoHeight*s)),l=r.getContext("2d");return l===null?e:(r.width!==a&&(r.width=a),r.height!==o&&(r.height=o),l.drawImage(e,0,0,a,o),this.snapshotCanvas=r,r)}catch{return e}}defaultQuality(e,t){let r=ot(e,t,96);return r===null?nt:{sharpness:oe(r),exposure:Ve(r),meanLuma:Ze(r)}}centerSharpness(e){let t=Q(e),r=ot(e,{x:t.width*.25,y:t.height*.25,width:t.width*.5,height:t.height*.5},96);return r===null?0:oe(r)}teardownAttempt(){this.scheduler?.stop(),this.scheduler=null,this.reportGate(!0),this.gate=null,this.ramp?.stop(),this.ramp=null,this.stopTracks()}reportGate(e){let t=this.blockStats,r=this.profiler;if(t===null||r===null)return;let s=t.summary();e&&(this.blockStats=null),s.ticks!==0&&this.options.telemetry?.({type:"gate",final:e,activeClass:r.deviceClass,cadenceHz:r.profile.cadenceHz,...s})}stopTracks(){if(this.stream!==null){for(let e of this.stream.getTracks())e.stop();this.stream=null}}fail(e,t,r){this.scheduler?.stop(),this.reportGate(!0),this.stopTracks(),this.setState("error"),this.options.telemetry?.({type:"error",kind:e,fallbackReason:r});let{phase:s,name:a}=t;this.emit("error",{kind:e,retryable:e!=="insecure"&&e!=="unsupported",detail:a===void 0?{phase:s}:{phase:s,name:a}})}setState(e){this.stateValue=e,this.emit("statechange",{state:e})}now(){return this.options.now?.()??performance.now()}},n(H,"ke"),H),me;function bi(i){return new Promise(e=>setTimeout(e,i))}n(bi,"st");function Mi(i){return i instanceof Error?i.message:String(i)}n(Mi,"ot");function ot(i,e,t){try{let r=document.createElement("canvas"),s=t/Math.max(1,e.width);r.width=Math.max(1,Math.round(e.width*s)),r.height=Math.max(1,Math.round(e.height*s));let a=r.getContext("2d");return a===null?null:(a.drawImage(i,e.x,e.y,e.width,e.height,0,0,r.width,r.height),a.getImageData(0,0,r.width,r.height))}catch{return null}}n(ot,"we");function ki(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()}n(ki,"lt");var Ti=12e4,dt=13e4,_i=3e3,Ei=1200,ge=Symbol.for("@sekyro/web.preload.v1");function ye(){let i=globalThis;return i[ge]??(i[ge]=new Map),i[ge]}n(ye,"h");function te(i){let e=(i??ce).replace(/\/+$/,"");return e===""?"/":e}n(te,"b");function mt(i){let e=ye(),t=e.get(i);return t===void 0&&(t={status:"idle",promise:null,scheduled:null,detectorPromise:null,detector:null,listeners:new Set},e.set(i,t)),t}n(mt,"ae");function ve(i,e){if(i.status!==e){i.status=e;for(let t of[...i.listeners])t(e)}}n(ve,"k");var Si=n(i=>x({preferred:["blaze"],v3AssetBaseUrl:i,blazeInitTimeoutMs:Ti}),"K"),Ii=Si;function Ai(){return typeof window<"u"&&typeof navigator<"u"&&typeof navigator.mediaDevices?.getUserMedia=="function"}n(Ai,"Ce");function xi(){return navigator.connection?.saveData===!0}n(xi,"Se");function Di(i){let e=window;if(typeof e.requestIdleCallback=="function"){let r=e.requestIdleCallback(i,{timeout:_i});return()=>e.cancelIdleCallback?.(r)}let t=setTimeout(i,Ei);return()=>clearTimeout(t)}n(Di,"Ee");function Ri(i,e){let t,r=new Promise(l=>{t=l}),s=!1,a=n(()=>{},"u"),o={promise:r,settle:n(l=>{s||(s=!0,a(),i.scheduled===o&&(i.scheduled=null),t(l))},"settle")};return i.scheduled=o,a=Di(()=>{s||o.settle(we(i,e))}),r}n(Ri,"ye");function we(i,e){if((i.status==="loading"||i.status==="ready")&&i.promise!==null)return i.promise;ve(i,"loading");let t=new Promise(o=>o(Ii(e)));i.detectorPromise=t;let r,s=new Promise((o,l)=>{r=setTimeout(()=>{t.then(c=>c.destroy(),()=>{}),l(new Error(`detector preload exceeded ${dt} ms`))},dt)}),a=Promise.race([t,s]).then(o=>i.detectorPromise!==t?(o.destroy(),i.status):(i.detector=o,ve(i,"ready"),"ready"),o=>(i.detectorPromise===t&&(i.detectorPromise=null,i.detector=null,ve(i,"failed"),console.warn("[@sekyro/web] face-detector preload failed:",o)),i.status)).finally(()=>clearTimeout(r));return i.promise=a,i.scheduled?.settle(a),a}n(we,"U");function sr(i={}){if(!Ai())return Promise.resolve("idle");let e=te(i.assetBaseUrl),t=mt(e);return i.respectSaveData===!0&&xi()?Promise.resolve(t.status):(t.status==="loading"||t.status==="ready")&&t.promise!==null?t.promise:i.idle===!0?t.scheduled?.promise??Ri(t,e):we(t,e)}n(sr,"xe");function ar(i){return ye().get(te(i))?.status??"idle"}n(ar,"Fe");function nr(i,e){let t=mt(te(e));return t.listeners.add(i),()=>{t.listeners.delete(i)}}n(nr,"Ie");function Ci(i){return{get tier(){return i.tier},get fallbackReason(){return i.fallbackReason},detect:n((...e)=>i.detect(...e),"detect"),destroy:n(()=>{},"destroy")}}n(Ci,"Le");function Oi(i){let e=te(i),t=ye().get(e);if(!(t===void 0||t.detector===null&&t.detectorPromise===null&&t.scheduled===null))return async()=>{t.scheduled!==null&&we(t,e);let r=t.promise;for(;t.detector===null&&r!==null&&(await r,t.promise!==r);)r=t.promise;return t.detector!==null?Ci(t.detector):x({v3AssetBaseUrl:e})}}n(Oi,"de");var Gi=new Set(["inuse","overconstrained","notfound"]),Pi=[500,1500];function Ui(i){switch(i){case"fcv3.no_face":case"fcv3.center_face":case"fcv3.straighten":return"center";case"fcv3.come_closer":return"closer";case"fcv3.move_back":return"farther";case"fcv3.more_light":case"fcv3.too_bright":return"light";case"fcv3.hold_still":case"fcv3.steady_camera":return"still";case"fcv3.hold_upright":return"upright";case"fcv3.one_face":return"one_face";default:return null}}n(Ui,"Ae");function Fi(i){switch(i){case"preflight":case"acquiring":return"starting";case"positioning":return"gating";default:return i}}n(Fi,"Pe");function ft(i){switch(i){case"permission":case"notfound":case"inuse":case"insecure":case"unsupported":return i;case"backcamera":return"notfound";default:{let e=i;return"generic"}}}n(ft,"ue");function Ni(i,e,t){if(t===void 0)return{kind:ft(i),retryable:e};let r=Be(t.name);return{kind:ft(i),retryable:e,detail:{...r!==void 0?{name:r}:{},phase:t.phase,engineKind:i}}}n(Ni,"we");var Bi=new Set(["captured","uploading","checking"]);function Li(i,e={},t,r=()=>"self",s=()=>{},a){let o=e.now??(()=>performance.now()),l=e.canChooseFacing??Re,c="user",h=Ce(),d=r(),u=De(),v=!Fe(),w=e.engineOptions,m=w?.createDetector===void 0&&w?.createWorker===void 0?{createDetector:n(()=>{let f=Oi(i.assetBaseUrl);return f!==void 0?f():x({v3AssetBaseUrl:i.assetBaseUrl})},"createDetector")}:{},g={video:i.video,mode:v?"photo":"clip",rankKeyframes:t,facingMode:void 0,v3AssetBaseUrl:i.assetBaseUrl,screenRamp:n(()=>d==="self"&&u.count("ramp")>0?s():void 0,"screenRamp"),...e.engineOptions??{},...m},y=e.createEngine?.(g)??new ut(g),p="idle",M=null,E=0,I=!1,T="full",b=null,A=null,S=0,K=0,be=n(()=>{i.video.videoWidth>0&&i.video.videoHeight>0&&(S=i.video.videoWidth,K=i.video.videoHeight)},"W"),Me=Oe({enabled:i.keepScreenAwake!==!1}),X=n(f=>{p=f,Me.setActive(f==="starting"||f==="gating"||f==="recording"),u.emit("state",f)},"S"),ie=n(()=>u.emit("gate",{progress:E,hint:M,faceDetected:I}),"F"),re=n(()=>{let f=y.animations??"full";f!==T&&(T=f,u.emit("profile",{animations:T}))},"I"),G=0,$=null,pt=e.schedule??((f,k)=>{let _=setTimeout(f,k);return()=>clearTimeout(_)}),Z=n(()=>{$?.(),$=null},"E"),gt=n((f,k)=>{if(V||!Gi.has(f)||k?.phase!=="acquiring")return!1;let _=Pi[G];return _===void 0?!1:(G+=1,Z(),$=pt(()=>{$=null,V||y.retry()},_),!0)},"fe"),vt=[y.on("statechange",({state:f})=>{if(f==="error")return;let k=Fi(f);k==="gating"&&(G=0),k==="starting"&&p!=="starting"&&(M=null,E=0,I=!1,b=null,A=null,S=0,K=0),X(k),re(),k==="recording"&&(be(),b=o(),M="hold",E=1,ie())}),y.on("checks",f=>{be(),E=f.progress,I=f.factors.presence>0,ie(),re()}),y.on("guidance",({key:f})=>{M=Ui(f),ie()}),y.on("frozen",({previewDataUrl:f})=>{A=o(),u.emit("frozen",{previewDataUrl:f})}),y.on("ramp",f=>u.emit("ramp",f)),y.on("artifacts",f=>{if(p!=="captured")return;let k=Y(),_=f.clipStats,_e=_!==void 0?Math.round(_.durationMs):b!==null&&A!==null?Math.max(0,Math.round(A-b)):void 0,Ee=_!==void 0&&_.frames>1&&_.durationMs>0?Math.round(_.frames*1e4/_.durationMs)/10:void 0;u.emit("captured",{keyframe:f.keyframe,...f.clip!==void 0?{clip:f.clip}:{},...f.clipMimeType!==void 0?{clipMime:f.clipMimeType}:{},width:i.video.videoWidth||S,height:i.video.videoHeight||K,..._e!==void 0?{clipMs:_e}:{},..._!==void 0?{clipFrames:_.frames}:{},...Ee!==void 0?{fps:Ee}:{},...f.clipRetakes!==void 0?{clipRetakes:f.clipRetakes}:{},...f.clipMimeType!==void 0?{codec:ct(f.clipMimeType)}:{},captureChannel:k==="desktop"?"desktop":"mobile",formFactor:k,...v?{degraded:"NO_RECORDER"}:{},engine:"v3",facingMode:y.facingMode,mode:d,...f.timing,...f.screenRamp!==void 0?{screenRamp:f.screenRamp}:{},...f.provenance!==void 0?{provenance:f.provenance}:{}})}),y.on("error",({kind:f,retryable:k,detail:_})=>{f==="backcamera"&&yt()||gt(f,_)||(X("error"),re(),u.emit("error",Ni(f,k,_)))})],ke=!1;function yt(){return V||ke||d!=="assisted"||a===void 0||a.session()!=="choice"?!1:(ke=!0,a.onModeChange("self"),d="self",c=se("self"),X("mode_switch"),y.restart(c),!0)}n(yt,"me");let Te=n(async()=>a!==void 0&&a.session()==="choice"&&await l().catch(()=>!1),"$"),V=!1;return{handle:{get state(){return p},get captureMode(){return r()},get facingMode(){return y.facingMode??c},on:n((f,k)=>u.on(f,k),"on"),start:n(f=>(d=r(),h.facing(d,i.facing),c=h.facing(d,f?.facing),Z(),G=0,y.start({facingMode:c})),"start"),retry:n(()=>{Z(),G=0,y.retry()},"retry"),switchCamera:n(()=>h.refuseSwitch(r()),"switchCamera"),canSwitchCaptureMode:Te,setCaptureMode:n(async f=>{if(f===r()||!await Te()||V||Bi.has(p)||a===void 0)return!1;a.onModeChange(f),d=f;let k=se(f);return c=k,p==="idle"||(X("mode_switch"),Z(),G=0,y.restart(k)),!0},"setCaptureMode"),destroy:n(()=>{V=!0,Z();for(let f of vt)f();Me.setActive(!1),y.destroy(),u.clear()},"destroy")},setFlowState:n(f=>{p!==f&&X(f)},"setFlowState")}}n(Li,"De");function or(i){return Li(i).handle}n(or,"Ze");export{$i as a,sr as b,ar as c,nr as d,Ni as e,Li as f,or as g};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as n}from"./chunk-4FHWXBOB.js";var S="0.1.0-rc.
|
|
1
|
+
import{a as n}from"./chunk-4FHWXBOB.js";var S="0.1.0-rc.36",k=/FBAN|FBAV|FB_IAB|FBIOS|MessengerForiOS|Instagram|WhatsApp|musical_ly|BytedanceWebview|TikTok|Snapchat|\bLine\/|LinkedInApp|Pinterest|MicroMessenger|; wv\)/i;function O(t){let e=t??(typeof navigator>"u"?"":String(navigator.userAgent??""));return k.test(e)}n(O,"p");var f="sekyro.did",C=1e4,w=n(()=>globalThis.process?.versions?.node,"v"),l;function y(){let t=globalThis.crypto;try{if(typeof t?.randomUUID=="function")return t.randomUUID()}catch{}try{if(typeof t?.getRandomValues=="function"){let e=t.getRandomValues(new Uint8Array(16));return Array.from(e,a=>a.toString(16).padStart(2,"0")).join("")}}catch{}}n(y,"b");function H(){try{let t=localStorage.getItem(f);if(t)return t;let e=y();return e!==void 0&&localStorage.setItem(f,e),e}catch{return l??(l=y()),l}}n(H,"I");async function M(){let t=globalThis.crypto?.subtle;if(!t)return"";let e=navigator,a=JSON.stringify([e.userAgent,e.platform,e.hardwareConcurrency??null,e.deviceMemory??null,e.maxTouchPoints??0,screen.width,screen.height,screen.colorDepth,globalThis.devicePixelRatio??1,Intl.DateTimeFormat().resolvedOptions().timeZone,e.languages?.join(",")??e.language]),i=await t.digest("SHA-256",new TextEncoder().encode(a));return Array.from(new Uint8Array(i),s=>s.toString(16).padStart(2,"0")).join("").slice(0,32)}n(M,"w");function x(){try{let t=Number(navigator.maxTouchPoints);return Number.isFinite(t)&&t>=0?{touch:Math.min(64,Math.trunc(t))}:{}}catch{return{}}}n(x,"k");function W(t){let e=new TextEncoder().encode(t),a="";for(let i of e)a+=String.fromCharCode(i);return btoa(a).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}n(W,"x");function j(t){let e,a,i,s,c,d,m=n(()=>d?.readyState==="live","u"),T=n(()=>{c!==void 0||!globalThis.crypto?.subtle||w()||m()||(c=Promise.race([import("./print-SEWS3VHQ-HWJTHADG.js"),new Promise(r=>setTimeout(r,C))]).then(r=>r?.computePrint(m)).then(r=>{r==="busy"?c=void 0:s=r}).catch(()=>{}))},"_");return{timezone(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone?.slice(0,64)||void 0}catch{return}},noteCameraLabel(r){r&&(e=r.slice(0,128))},noteCamera(r){a=r},noteCameraTrack(r){d=r},async deviceHeader(){try{i??(i=M().catch(()=>""));let r=[];navigator.webdriver&&r.push("webdriver"),/HeadlessChrome/.test(navigator.userAgent)&&r.push("headless");let g=await i,p=H(),A={v:1,platform:"web",sdk:t.sdk.slice(0,64),caps:["session_proof"],ids:[...p?[{kind:"web_local",value:p.slice(0,128)}]:[],...g?[{kind:"web_fp",value:g}]:[]],screen:{w:screen.width,h:screen.height,dpr:globalThis.devicePixelRatio??1},...x(),...e?{cameraLabel:e}:{},...r.length?{signals:r}:{},...s?{print:{v:2,...s,...a?{camera:a}:{}}}:{},...O()?{inApp:!0}:{}},I=W(JSON.stringify(A));return T(),I}catch{return}},printReady(){return c??Promise.resolve()}}}n(j,"A");var v=Symbol.for("sekyro.web.clientContext"),b=globalThis,u=b[v]??(b[v]=j({sdk:`@sekyro/web@${S}`}));function z(t){try{let e=t.getVideoTracks?.()[0];if(e){if(u.noteCameraLabel(e.label),u.noteCameraTrack(e),w())return;import("./camera-trait-V4UAOPIQ-TFCPOCSU.js").then(a=>a.noteCameraTrait(e,u)).catch(()=>{})}}catch{}}n(z,"M");var P=Object.freeze({LOW:Object.freeze({cadenceHz:5,inputWidth:128,animations:"reduced"}),MID:Object.freeze({cadenceHz:8,inputWidth:160,animations:"full"}),HIGH:Object.freeze({cadenceHz:10,inputWidth:192,animations:"full"})}),L=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]);function F(){let t=typeof navigator>"u"?void 0:navigator,e=!1;try{e=typeof WebAssembly<"u"&&WebAssembly.validate(L)}catch{e=!1}return{cores:t?.hardwareConcurrency??2,memGB:t?.deviceMemory??null,simd:e}}n(F,"o");function U(t){let e=t.memGB??4;return t.cores<4||e<3?"LOW":t.cores>=8&&e>=6?"HIGH":"MID"}n(U,"l");var h=["LOW","MID","HIGH"],o,_=(o=class{constructor(e){this.samples=[],this.adjusted=!1,this.current=e}get deviceClass(){return this.current}get profile(){return P[this.current]}record(e){if(this.adjusted||this.samples.length>=10)return this.current;if(this.samples.push(e),this.samples.length<10)return this.current;this.adjusted=!0;let a=this.samples.reduce((i,s)=>i+s,0)/this.samples.length;if(a>70)this.current="LOW";else if(a<25){let i=h.indexOf(this.current);this.current=h[Math.min(h.length-1,i+1)]??this.current}return this.current}},n(o,"i"),o);export{S as a,O as b,u as c,z as d,F as e,U as f,_ as g};
|