Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@onefootprint/footprint-js

Package Overview
Dependencies
Maintainers
0
Versions
75
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@onefootprint/footprint-js - npm Package Compare versions

Comparing version 3.14.0 to 3.14.1

4

dist/footprint-js.d.ts

@@ -261,2 +261,3 @@ import * as CSS from 'csstype';

readonly sandboxOutcome?: SandboxOutcome;
readonly sandboxId?: string;
/** @deprecated use bootstrapData instead */

@@ -273,5 +274,6 @@ readonly userData?: FootprintUserData;

documentFixtureResult?: IdDocOutcome;
readonly sandboxId?: string;
};
/** Components SDK. Just a subset of Verify */
type ComponentsSdkProps = VerifyPropsBase<VerifyPublicKey> & {
type ComponentsSdkProps = VerifyPropsBase<VerifyPublicKey | VerifyAuthToken> & {
readonly onRelayToComponents?: (authToken: string) => void;

@@ -278,0 +280,0 @@ readonly kind: `${ComponentKind.Components}`;

@@ -1,5 +0,6 @@

import yt from '@onefootprint/postmate';
import lt from 'crypto';
import Mt from '@onefootprint/postmate';
var He=Object.defineProperty,qe=Object.defineProperties;var ze=Object.getOwnPropertyDescriptors;var L=Object.getOwnPropertySymbols;var se=Object.prototype.hasOwnProperty,de=Object.prototype.propertyIsEnumerable;var ie=(e,t,o)=>t in e?He(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,g=(e,t)=>{for(var o in t||(t={}))se.call(t,o)&&ie(e,o,t[o]);if(L)for(var o of L(t))de.call(t,o)&&ie(e,o,t[o]);return e},C=(e,t)=>qe(e,ze(t));var pe=(e,t)=>{var o={};for(var n in e)se.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&L)for(var n of L(e))t.indexOf(n)<0&&de.call(e,n)&&(o[n]=e[n]);return o};var u=(e,t,o)=>new Promise((n,r)=>{var a=p=>{try{s(o.next(p));}catch(d){r(d);}},i=p=>{try{s(o.throw(p));}catch(d){r(d);}},s=p=>p.done?n(p.value):Promise.resolve(p.value).then(a,i);s((o=o.apply(e,t)).next());});var E="3.14.0";var R=(s=>(s.Auth="auth",s.Components="components",s.Form="form",s.Render="render",s.UpdateLoginMethods="update_login_methods",s.Verify="verify",s.VerifyButton="verify-button",s))(R||{});var O=(i=>(i.auth="auth",i.canceled="canceled",i.clicked="clicked",i.closed="closed",i.completed="completed",i.relayToComponents="relayToComponents",i))(O||{}),I=(i=>(i.formSaveComplete="formSaveComplete",i.formSaveFailed="formSaveFailed",i.formSaved="formSaved",i.propsReceived="propsReceived",i.started="started",i.relayFromComponents="relayFromComponents",i))(I||{});var le="footprint-inline-container",ce="footprint-body-locked",me="footprint-overlay",We="footprint-overlay-container",ue=le,fe=me,ye="footprint-loading-indicator",D=e=>`${We}-${e}`,V=(e,t)=>`${e}-${t}`,ge=e=>u(void 0,null,function*(){H(e),Ye(e),yield Xe(e);}),he=e=>{let t=D(e),o=document.getElementById(t);if(o)return o;let n=document.createElement("div");return n.setAttribute("id",t),document.body.appendChild(n),n},Xe=e=>u(void 0,null,function*(){let t=D(e),o=document.getElementById(t);if(!o)return;let n=o.querySelector("iframe.footprint-drawer");n&&(n==null||n.classList.add("footprint-drawer-closing"),yield new Promise(s=>{setTimeout(s,300);}));let r=o.querySelector("iframe.footprint-modal");r&&(r==null||r.classList.add("footprint-modal-closing"),yield new Promise(s=>{setTimeout(s,100);}));let a=V(fe,e),i=document.getElementById(a);i&&(i.classList.add("footprint-overlay-fading"),yield new Promise(s=>{setTimeout(s,200);}),o.remove(),i.remove(),document.body.classList.remove(ce));}),Ce=(e,t)=>{let o=V(ue,e),n=document.createElement("div");return n.classList.add(le),n.setAttribute("id",o),t.appendChild(n),n},Ye=e=>{let t=V(ue,e),o=document.getElementById(t);o&&o.remove();},H=e=>{let t=V(ye,e),o=document.getElementById(t);o&&o.remove();},q=(e,t)=>{let o=V(ye,t),n=Ze(o);e.appendChild(n);},ke=(e,t)=>{document.body.classList.add(ce);let o=document.createElement("div"),n=V(fe,t);return o.setAttribute("id",n),o.classList.add(me),e.appendChild(o),o},Ze=e=>{let t=document.createElement("div");t.setAttribute("id",e),t.classList.add("footprint-loading-indicator");let o=document.createElement("div");o.classList.add("footprint-loading-spin");let n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.setAttribute("width","24px"),n.setAttribute("height","24px"),n.setAttribute("fill","none"),n.setAttribute("aria-hidden","true");let r=document.createElementNS("http://www.w3.org/2000/svg","path");return r.setAttribute("d","M12 2a10 10 0 0 1 10 10h-2a7.999 7.999 0 0 0-8-8V2Z"),n.appendChild(r),o.appendChild(n),t.appendChild(o),t},Pe=e=>{let t=document.getElementById(D(e));t&&(t.style.opacity="1",t.style.display="block");},be=e=>{let t=document.getElementById(D(e));t&&(t.style.opacity="0",t.style.display="none");},ve=e=>{let t=document.createElement("div");t.classList.add("modal-error-container"),t.setAttribute("role","dialog"),t.setAttribute("aria-modal","true"),t.setAttribute("aria-label","Oops! Something\u2019s not quite right.");let o=document.createElement("div");o.classList.add("modal-error");let n=document.createElement("button");n.setAttribute("aria-label","Close"),n.classList.add("modal-error-close-button"),n.addEventListener("click",()=>{e.remove();});let r=document.createElementNS("http://www.w3.org/2000/svg","svg");r.setAttribute("xmlns","http://www.w3.org/2000/svg"),r.setAttribute("width","20"),r.setAttribute("height","20"),r.setAttribute("viewBox","0 0 20 20"),r.setAttribute("fill","none");let a=document.createElementNS("http://www.w3.org/2000/svg","path");a.setAttribute("d","M5 5L15 15M15 5L5 15"),a.setAttribute("stroke","black"),a.setAttribute("stroke-width","1.5"),a.setAttribute("stroke-linecap","round"),r.appendChild(a),n.appendChild(r);let i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.setAttribute("xmlns","http://www.w3.org/2000/svg"),i.setAttribute("width","40"),i.setAttribute("height","40"),i.setAttribute("viewBox","0 0 40 40"),i.setAttribute("fill","none"),i.setAttribute("class","error-icon");let s=document.createElementNS("http://www.w3.org/2000/svg","path");s.setAttribute("d","M25 15L15 25M25 25L15 15M35 20C35 28.2843 28.2843 35 20 35C11.7157 35 5 28.2843 5 20C5 11.7157 11.7157 5 20 5C28.2843 5 35 11.7157 35 20Z"),s.setAttribute("stroke","black"),s.setAttribute("stroke-width","3.33333"),s.setAttribute("stroke-linecap","round"),s.setAttribute("stroke-linejoin","round"),i.appendChild(s);let p=document.createElement("h2");p.textContent="Oops! Something\u2019s not quite right.";let d=document.createElement("p");d.textContent="It looks like there was an issue loading the page. Try reloading and we\u2019ll get things back on track.",o.appendChild(n),o.appendChild(i),o.appendChild(p),o.appendChild(d),t.appendChild(o),e.appendChild(t);};var Ge=()=>Math.random().toString(36).substring(2),K=Ge;var T="https://api.onefootprint.com",B=E,_="footprint-js";var A={["auth"]:"auth_v1",["form"]:"form_v1",["render"]:"render_v1",["update_login_methods"]:"update_auth_methods_v1",["verify"]:"verify_v1",["verify-button"]:"verify_button_v1",["components"]:"verify_v1"};var Qe=e=>e.replace(/[A-Z]/g,t=>`_${t.toLowerCase()}`),z=e=>t=>{if(!t||typeof t!="object")return t;let o=Object.entries(t).map(([n,r])=>{let a;return Array.isArray(r)?a=r.map(z(e)):Object(r)===r?a=z(e)(r):a=r,[e(n),a]});return Object.fromEntries(o)},et=z(Qe),U=et;var tt=(e,t,o,n)=>{let r={tenantDomain:n,sdkKind:e,sdkName:_,sdkVersion:B,logLevel:o,logMessage:t};try{fetch(`${T}/org/sdk_telemetry`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(U(r))});}catch(a){}},J=tt;var W=(e,t)=>{let o=`@onefootprint/footprint-js: ${t}`;{let n;try{n=window.location.href;}catch(r){}J(e,t,"warn",n);}return o},Ve=(e,t)=>{let o=`@onefootprint/footprint-js: ${t}`;{let n;try{n=window.location.href;}catch(r){}J(e,t,"error",n);}return o};var Ae={["auth"]:{["canceled"]:"onCancel",["closed"]:"onClose",["completed"]:"onComplete"},["update_login_methods"]:{["canceled"]:"onCancel",["closed"]:"onClose",["completed"]:"onComplete"},["form"]:{["canceled"]:"onCancel",["closed"]:"onClose",["completed"]:"onComplete"},["verify"]:{["auth"]:"onAuth",["canceled"]:"onCancel",["closed"]:"onClose",["completed"]:"onComplete"},["components"]:{["auth"]:"onAuth",["canceled"]:"onCancel",["closed"]:"onClose",["completed"]:"onComplete",["relayToComponents"]:"onRelayToComponents"},["verify-button"]:{["auth"]:"onAuth",["canceled"]:"onCancel",["clicked"]:"onClick",["closed"]:"onClose",["completed"]:"onComplete"},["render"]:{}},Se={["auth"]:[],["form"]:[],["render"]:[],["update_login_methods"]:[],["verify"]:[],["components"]:[],["verify-button"]:[]};var xe={["auth"]:["modal","drawer"],["components"]:["modal"],["form"]:["inline","modal","drawer"],["render"]:["inline"],["update_login_methods"]:["modal","drawer"],["verify"]:["modal","drawer"],["verify-button"]:["inline"]},ot=Object.values(O),nt=(...e)=>{},P=e=>e!=null&&typeof e=="object"&&!Array.isArray(e),X=e=>P(e)&&Object.keys(e).length>0,rt=(e,t)=>{if(e==="inline"&&!t)throw new Error(`Inline component requires a containerId. Received ${t}`)},M=(e,t)=>{var r;if(!t)return;let o=(r=xe[e])!=null?r:[];if(!o.includes(t))throw new Error(`Invalid variant: ${JSON.stringify(t)}. Valid variants for ${e} are ${o.join(", ")}`)},S=e=>{var o;let t=(o=xe[e])!=null?o:[];if(!t.length)throw new Error(`Invalid kind: ${e}`);return t[0]},$=e=>{if(!e)throw new Error("Kind is required");let t=Object.values(R);if(!t.includes(e))throw new Error(`Invalid kind: ${e}. Valid kinds are: ${t.join(", ")}`)},Oe=e=>{if(e.kind==="verify-button"){let t=e,{kind:o,appearance:n,variant:r,dialogVariant:a,onClick:i,label:s,containerId:p}=t,d=pe(t,["kind","appearance","variant","dialogVariant","onClick","label","containerId"]);return C(g({},d),{variant:a,kind:"verify"})}};var Fe=(e,t)=>(Object.prototype.hasOwnProperty.call(e,t)&&typeof e[t]=="function"?e[t]:void 0)||nt,Y=(e,t,o)=>{var s;let{kind:n}=e,r=(s=Ae[n])!=null?s:{},a={},i=Oe(e);return Object.entries(r).forEach(([p,d])=>{let c=p;if(!ot.includes(c))return;let k=Fe(e,d),x=c==="closed"||c==="canceled",m=n==="verify-button"&&c==="clicked";a[c]=h=>{k(h),x&&(t==null||t()),m&&i&&(o==null||o(i));};}),a},F=e=>{let{kind:t,variant:o,containerId:n}=e,r=o||S(t);return $(t),M(t,o),rt(r,n),X(e==null?void 0:e.userData)&&console.warn("userData is deprecated and will be removed in the next major version. Please use bootstrapData instead."),C(g({},e),{variant:r})},b=e=>X(e==null?void 0:e.bootstrapData)?{userData:e.bootstrapData}:X(e==null?void 0:e.userData)?{userData:e.userData}:void 0;var at=e=>e==="auth";var it=e=>e==="update_login_methods";var Z=e=>e.kind==="components";var G=e=>typeof e=="string"&&e.length>0,N=e=>at(e.kind)&&!!("updateLoginMethods"in e&&e.updateLoginMethods)&&!!e.authToken&&/tok_/.test(e.authToken),st=e=>it(e.kind)&&!!e.authToken&&/tok_/.test(e.authToken),Q=e=>[N,st].some(t=>t(e));var dt=3,pt=!1,lt=e=>Q(e)?"update_auth_methods_v1":A[e.kind],ct=e=>{var o,n;let{kind:t}=e;if(t==="verify"||t==="components")return C(g({},b(e)),{publicKey:e.publicKey,authToken:e.authToken,options:e.options,l10n:e.l10n,fixtureResult:(o=e.sandboxOutcome)==null?void 0:o.overallOutcome,documentFixtureResult:(n=e.sandboxOutcome)==null?void 0:n.documentOutcome,isComponentsSdk:t==="components"});if(t==="update_login_methods")return C(g({},b(e)),{authToken:e.authToken,options:e.options,l10n:e.l10n});if(t==="auth")return N(e)?C(g({},b(e)),{authToken:e.authToken,updateLoginMethods:e.updateLoginMethods,options:e.options,l10n:e.l10n}):e.authToken&&pt?C(g({},b(e)),{authToken:e.authToken,options:e.options,l10n:e.l10n}):C(g({},b(e)),{publicKey:e.publicKey,options:e.options,l10n:e.l10n});if(t==="form")return {authToken:e.authToken,options:e.options,title:e.title,l10n:e.l10n};if(t==="render")return {authToken:e.authToken,canCopy:e.canCopy,defaultHidden:e.defaultHidden,id:e.id,label:e.label,showHiddenToggle:e.showHiddenToggle,l10n:e.l10n};if(t==="verify-button")return C(g({},b(e)),{publicKey:e.publicKey,options:e.options,authToken:e.authToken,label:e.label,l10n:e.l10n})},Le=(e,t)=>u(void 0,null,function*(){return fetch(`${T}/org/sdk_args`,{method:"POST",headers:{"x-fp-client-version":`${_} ${B} ${e.kind}`.trim(),"Content-Type":"application/json"},body:JSON.stringify(e)}).then(o=>{if(o.ok)return o.json();if(t>0)return Le(e,t-1)})}),mt=e=>u(void 0,null,function*(){let t=ct(e);if(!t)return;let o=yield Le({data:U(t),kind:lt(e)},dt);return o?o.token:void 0}),Ee=mt;var Re=({fontSrc:e,variables:t={},rules:o={},variant:n}={})=>{let r=()=>Object.keys(t).length?encodeURIComponent(JSON.stringify(t)):void 0,a=()=>Object.keys(o).length?encodeURIComponent(JSON.stringify(o)):void 0;return {fontSrc:e,variables:r(),rules:a(),variant:n}},Ie=()=>{let e=window.footprintAppearance;return !e||!P(e)?{}:{fontSrc:e.fontSrc,rules:e.rules,variables:e.variables}};var De=()=>{var e;return typeof window!="undefined"?((e=window.location)==null?void 0:e.href)||window.location.toString():""},ut=(e,t)=>{let{appearance:o,kind:n,l10n:r,variant:a}=e,{fontSrc:i,rules:s,variables:p}=Re(o),d=new URLSearchParams;return p&&d.append("variables",p),s&&d.append("rules",s),i&&d.append("font_src",i),r!=null&&r.language&&d.append("lng",r.language),d.append("variant",a||S(n)),`${d.toString()}#${t}`},ft=(e,t)=>{let{kind:o}=e,n=ut(e,t),r=`https://components.onefootprint.com/${o}`,a=`https://components2.onefootprint.com/${o}`;if(o==="update_login_methods"&&(r="https://auth.onefootprint.com/user",a="https://auth2.onefootprint.com/user"),o==="auth"&&(r="https://auth.onefootprint.com",a="https://auth2.onefootprint.com"),(o==="verify"||o==="verify-button"||o==="components")&&(r="https://id.onefootprint.com",a="https://id2.onefootprint.com"),!G(r))throw new Error(`${o}_URL environment variable is not defined.`);return r+=`?${n}`.trim(),a+=`?${n}`.trim(),{url:r,fallbackUrl:a}},Ke=ft;var gt=e=>{let t=null,o=!1,n,r,{formSaveComplete:a,formSaved:i,formSaveFailed:s,started:p}=I,d=F(e),{variant:c,containerId:k}=d,x=c==="modal"||c==="drawer",m=K(),h=(l,f)=>{var w;let y=Ve(A[d.kind],l);(w=d.onError)==null||w.call(d,y),o&&f&&(n(),o=!1);},Me=()=>{if(!t){h("Footprint should be initialized in order to register callback props");return}let l=Y(d,n,r);Object.entries(l).forEach(([f,y])=>{t==null||t.on(f,y),t==null||t.on(`${m}:${f}`,y);});},$e=()=>{if(x)return he(m);if(!k){h("containerId is required when rendering inline");return}let l=document.getElementById(k);if(!l){h(`Could not find container with id ${k} while rendering footprint`);return}return Ce(m,l)},j=(l,f)=>{if(!f){H(m),t==null||t.frame.classList.remove("fp-hide"),t==null||t.frame.classList.remove(`footprint-${c}-loading`),t==null||t.frame.classList.add(`footprint-${c}-loaded`);return}if(x){let y=ke(l,m);q(y,m);}else q(l,m);},oe=()=>{var f;if(!t){h("Footprint should be initialized in order to set up refs");return}if(d.kind!=="form"||!d.getRef)return;let l={save:()=>(t||h("Footprint should be initialized to call ref methods"),new Promise((y,w)=>{t==null||t.on(a,()=>{y();}),t==null||t.on(s,je=>{w(je);}),t==null||t.on(`${m}:${a}`,y),t==null||t.on(`${m}:${s}`,w),t==null||t.call(i);}))};(f=d.getRef)==null||f.call(d,l);},ne=(l,f)=>u(void 0,null,function*(){try{return t=yield new yt({classListArray:[`footprint-${c}`,`footprint-${c}-loading`,"fp-hide"],container:l,name:`footprint-iframe-${m}`,url:f,allow:"otp-credentials; publickey-credentials-get *; camera *; clipboard-write;",model:{authToken:d.authToken,initId:m,sdkUrl:De(),sdkVersion:E||""}}),{success:!0,parentApi:t}}catch(y){return h(`Initializing ${f} iframe failed with error ${y}`),{success:!1}}}),Ne=(w,je)=>u(void 0,[w,je],function*(l,{url:f,fallbackUrl:y}){let re=yield ne(l,f);if(re.success)return re.parentApi;let ae=yield ne(l,y);if(!ae.success)throw new Error("Failed to initialize iframe");return ae.parentApi});return {relayFromComponents:()=>{t&&(t.call("relayFromComponents"),Pe(m));},props:d,isRendered:o,render:()=>u(void 0,null,function*(){if(o){W(A[d.kind],"Footprint component is already rendered");return}o=!0;let l=$e();if(!l){W(A[d.kind],"Unable to create container for Footprint component");return}l.hasChildNodes()&&(l.innerHTML=""),j(l,!0);let f=yield Ee(d);if(!f){h("Unable to get SDK args token.",!0),j(l,!1);return}let y=Ke(d,f||"");try{yield Ne(l,y),Me();}catch(w){ve(l),o=!1;}j(l,!1),t==null||t.on(p,()=>oe()),t==null||t.on(`${m}:${p}`,oe),d.kind==="components"&&(t==null||t.on(`${m}:${"relayToComponents"}`,()=>{be(m);}));}),destroy:()=>u(void 0,null,function*(){o&&(o=!1,yield ge(m),t&&(t.destroy(),t=null));}),registerOnDestroy:l=>{!l||typeof l!="function"||(n=l);},registerOnRenderSecondary:l=>{!l||typeof l!="function"||(r=l);}}},ee=gt;var v=e=>{let t=F(e);return JSON.stringify(t)},ht=()=>{let e=Object.create(null);return {getOrCreate:a=>{let i=v(a.props),s=Object.values(e).find(p=>v(p.iframe.props)===i);return s?s.iframe:(e[i]={iframe:a,secondaryIframes:{}},a)},getOrCreateSecondary:(a,i)=>{let s=v(a.props),p=v(i.props);if(!e[s])throw new Error("iframe manager: primary iframe does not exist while adding secondary");let{secondaryIframes:d}=e[s],c=Object.values(d).find(k=>v(k.props)===p);return c||(d[p]=i,i)},remove:a=>{let i=v(a.props),s=e[i];s&&(Object.keys(s.secondaryIframes).forEach(p=>{s.secondaryIframes[p].destroy();}),delete e[i]);},removeSecondary:(a,i)=>{let s=v(a.props),p=v(i.props);if(!e[s])throw new Error("iframe manager: primary iframe does not exist while removing secondary");let{secondaryIframes:d}=e[s],c=d[p];c&&(c.destroy(),delete d[p]);}}},Te=ht;var Ct=()=>{let e=Te();return {init:o=>{let n=ee(o),r=()=>u(void 0,null,function*(){e.remove(n),yield n.destroy();}),a=d=>u(void 0,null,function*(){e.removeSecondary(n,d),yield d.destroy();}),i=d=>u(void 0,null,function*(){let c=ee(d);c=e.getOrCreateSecondary(n,c),c.registerOnDestroy(()=>{a(c);}),c.render();}),s=()=>u(void 0,null,function*(){n=e.getOrCreate(n),n.registerOnDestroy(r),n.registerOnRenderSecondary(i),yield n.render();}),p={};return Z(o)&&(p={relayFromComponents:()=>{n.relayFromComponents();}}),g({render:s,destroy:r},p)}}},kt=Ct(),te=kt;var Pt=e=>{window.setTimeout(e,0);},bt=e=>{if(typeof window=="undefined")return;let t=r=>{var s;let a=(s=window.footprintCallbacks)!=null?s:{};if(!P(a))throw Error("`window.footprintCallbacks` must be a valid mapping from callback names to functions.");return Se[r].forEach(p=>{if(!a[p])throw Error(`Callback '${p}' must be defined in window.footprintCallbacks`)}),a},o=r=>{var m;let a=r.getAttribute("data-kind");$(a);let i=(m=r.getAttribute("data-variant"))!=null?m:S(a);M(a,i);let s=Ie(),p=t(a),d=r.getAttribute("data-props")||"",c;try{c=JSON.parse(d);}catch(h){throw Error("Could not parse `data-props` for footprint.")}if(!P(c))throw Error("`data-props` on the footprint element has to be a valid JSON object stringified.");let k=K();r.setAttribute("id",k),e.init(g(g({kind:a,variant:i,appearance:s,containerId:r.id},p),c)).render();},n=()=>{let r=document.querySelectorAll("[data-footprint]");r.length&&r.forEach(a=>{o(a);});};document.addEventListener("DOMContentLoaded",()=>Pt(n));},Be=bt;var vt="http://test",_e=e=>u(void 0,null,function*(){let t=yield fetch(`${vt}/hosted/identify/lite`,{method:"POST",body:JSON.stringify(e)});if(!t.ok)throw Error(t.statusText);return (yield t.json()).user_found}),wt=e=>u(void 0,null,function*(){if(!P(e))throw new Error("User data must be passed in order to identify an user");let t=e["id.email"],o=e["id.phone_number"];return t&&(yield _e({email:t}))?!0:o?yield _e({phone_number:o}):!1}),Ue=wt;var en=te;Be(te);
var st=Object.defineProperty,dt=Object.defineProperties;var pt=Object.getOwnPropertyDescriptors;var R=Object.getOwnPropertySymbols;var Ce=Object.prototype.hasOwnProperty,be=Object.prototype.propertyIsEnumerable;var Pe=(e,t,o)=>t in e?st(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,h=(e,t)=>{for(var o in t||(t={}))Ce.call(t,o)&&Pe(e,o,t[o]);if(R)for(var o of R(t))be.call(t,o)&&Pe(e,o,t[o]);return e},P=(e,t)=>dt(e,pt(t));var ve=(e,t)=>{var o={};for(var n in e)Ce.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&R)for(var n of R(e))t.indexOf(n)<0&&be.call(e,n)&&(o[n]=e[n]);return o};var u=(e,t,o)=>new Promise((n,r)=>{var a=p=>{try{s(o.next(p));}catch(d){r(d);}},i=p=>{try{s(o.throw(p));}catch(d){r(d);}},s=p=>p.done?n(p.value):Promise.resolve(p.value).then(a,i);s((o=o.apply(e,t)).next());});var K=new Uint8Array(256),D=K.length;function Z(){return D>K.length-16&&(lt.randomFillSync(K),D=0),K.slice(D,D+=16)}var y=[];for(let e=0;e<256;++e)y.push((e+256).toString(16).slice(1));function we(e,t=0){return (y[e[t+0]]+y[e[t+1]]+y[e[t+2]]+y[e[t+3]]+"-"+y[e[t+4]]+y[e[t+5]]+"-"+y[e[t+6]]+y[e[t+7]]+"-"+y[e[t+8]]+y[e[t+9]]+"-"+y[e[t+10]]+y[e[t+11]]+y[e[t+12]]+y[e[t+13]]+y[e[t+14]]+y[e[t+15]]).toLowerCase()}var G={randomUUID:lt.randomUUID};function mt(e,t,o){if(G.randomUUID&&!t&&!e)return G.randomUUID();e=e||{};let n=e.random||(e.rng||Z)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,t){o=o||0;for(let r=0;r<16;++r)t[o+r]=n[r];return t}return we(n)}var ee=mt;var Se="fp-session-id",xe=typeof window!="undefined",te="xfpsessionid",Ve=(e,t)=>new URL(t).searchParams.get(e),ft=e=>{var t,o;try{let n=(o=(t=window==null?void 0:window.top)==null?void 0:t.location)==null?void 0:o.href;return n?Ve(e,n):null}catch(n){return null}},Ie=e=>xe?Ve(e,window.location.href)||ft(e):null,Ae=()=>{if((!xe||!window.sessionStorage))return !1;try{let e="test";return sessionStorage.setItem(e,e),sessionStorage.removeItem(e),!0}catch(e){return !1}},yt=()=>{let e=Ie(te)||ee();if(Ae())try{sessionStorage.setItem(Se,e);}catch(t){console.error("Failed to create session id",t);}return e},gt=()=>{let e=Ie(te);return e||(Ae()?sessionStorage.getItem(Se):null)},Oe=()=>gt()||yt(),O=(e,t=Oe())=>{let o=new URL(e);return o.searchParams.set(te,t),o.toString()};var T=Oe;var U="3.14.1";var B=(s=>(s.Auth="auth",s.Components="components",s.Form="form",s.Render="render",s.UpdateLoginMethods="update_login_methods",s.Verify="verify",s.VerifyButton="verify-button",s))(B||{});var F=(i=>(i.auth="auth",i.canceled="canceled",i.clicked="clicked",i.closed="closed",i.completed="completed",i.relayToComponents="relayToComponents",i))(F||{}),_=(i=>(i.formSaveComplete="formSaveComplete",i.formSaveFailed="formSaveFailed",i.formSaved="formSaved",i.propsReceived="propsReceived",i.started="started",i.relayFromComponents="relayFromComponents",i))(_||{});var Fe="footprint-inline-container",Le="footprint-body-locked",Ee="footprint-overlay",Pt="footprint-overlay-container",Re=Fe,De=Ee,Ke="footprint-loading-indicator",M=e=>`${Pt}-${e}`,V=(e,t)=>`${e}-${t}`,Te=e=>u(void 0,null,function*(){oe(e),bt(e),yield Ct(e);}),Ue=e=>{let t=M(e),o=document.getElementById(t);if(o)return o;let n=document.createElement("div");return n.setAttribute("id",t),document.body.appendChild(n),n},Ct=e=>u(void 0,null,function*(){let t=M(e),o=document.getElementById(t);if(!o)return;let n=o.querySelector("iframe.footprint-drawer");n&&(n==null||n.classList.add("footprint-drawer-closing"),yield new Promise(s=>{setTimeout(s,300);}));let r=o.querySelector("iframe.footprint-modal");r&&(r==null||r.classList.add("footprint-modal-closing"),yield new Promise(s=>{setTimeout(s,100);}));let a=V(De,e),i=document.getElementById(a);i&&(i.classList.add("footprint-overlay-fading"),yield new Promise(s=>{setTimeout(s,200);}),o.remove(),i.remove(),document.body.classList.remove(Le));}),Be=(e,t)=>{let o=V(Re,e),n=document.createElement("div");return n.classList.add(Fe),n.setAttribute("id",o),t.appendChild(n),n},bt=e=>{let t=V(Re,e),o=document.getElementById(t);o&&o.remove();},oe=e=>{let t=V(Ke,e),o=document.getElementById(t);o&&o.remove();},ne=(e,t)=>{let o=V(Ke,t),n=vt(o);e.appendChild(n);},_e=(e,t)=>{document.body.classList.add(Le);let o=document.createElement("div"),n=V(De,t);return o.setAttribute("id",n),o.classList.add(Ee),e.appendChild(o),o},vt=e=>{let t=document.createElement("div");t.setAttribute("id",e),t.classList.add("footprint-loading-indicator");let o=document.createElement("div");o.classList.add("footprint-loading-spin");let n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.setAttribute("width","24px"),n.setAttribute("height","24px"),n.setAttribute("fill","none"),n.setAttribute("aria-hidden","true");let r=document.createElementNS("http://www.w3.org/2000/svg","path");return r.setAttribute("d","M12 2a10 10 0 0 1 10 10h-2a7.999 7.999 0 0 0-8-8V2Z"),n.appendChild(r),o.appendChild(n),t.appendChild(o),t},Me=e=>{let t=document.getElementById(M(e));t&&(t.style.opacity="1",t.style.display="block");},$e=e=>{let t=document.getElementById(M(e));t&&(t.style.opacity="0",t.style.display="none");},Ne=e=>{let t=document.createElement("div");t.classList.add("modal-error-container"),t.setAttribute("role","dialog"),t.setAttribute("aria-modal","true"),t.setAttribute("aria-label","Oops! Something\u2019s not quite right.");let o=document.createElement("div");o.classList.add("modal-error");let n=document.createElement("button");n.setAttribute("aria-label","Close"),n.classList.add("modal-error-close-button"),n.addEventListener("click",()=>{e.remove();});let r=document.createElementNS("http://www.w3.org/2000/svg","svg");r.setAttribute("xmlns","http://www.w3.org/2000/svg"),r.setAttribute("width","20"),r.setAttribute("height","20"),r.setAttribute("viewBox","0 0 20 20"),r.setAttribute("fill","none");let a=document.createElementNS("http://www.w3.org/2000/svg","path");a.setAttribute("d","M5 5L15 15M15 5L5 15"),a.setAttribute("stroke","black"),a.setAttribute("stroke-width","1.5"),a.setAttribute("stroke-linecap","round"),r.appendChild(a),n.appendChild(r);let i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.setAttribute("xmlns","http://www.w3.org/2000/svg"),i.setAttribute("width","40"),i.setAttribute("height","40"),i.setAttribute("viewBox","0 0 40 40"),i.setAttribute("fill","none"),i.setAttribute("class","error-icon");let s=document.createElementNS("http://www.w3.org/2000/svg","path");s.setAttribute("d","M25 15L15 25M25 25L15 15M35 20C35 28.2843 28.2843 35 20 35C11.7157 35 5 28.2843 5 20C5 11.7157 11.7157 5 20 5C28.2843 5 35 11.7157 35 20Z"),s.setAttribute("stroke","black"),s.setAttribute("stroke-width","3.33333"),s.setAttribute("stroke-linecap","round"),s.setAttribute("stroke-linejoin","round"),i.appendChild(s);let p=document.createElement("h2");p.textContent="Oops! Something\u2019s not quite right.";let d=document.createElement("p");d.textContent="It looks like there was an issue loading the page. Try reloading and we\u2019ll get things back on track.",o.appendChild(n),o.appendChild(i),o.appendChild(p),o.appendChild(d),t.appendChild(o),e.appendChild(t);};var wt=()=>Math.random().toString(36).substring(2),$=wt;var N="https://api.onefootprint.com",j=U,H="footprint-js";var b={["auth"]:"auth_v1",["form"]:"form_v1",["render"]:"render_v1",["update_login_methods"]:"update_auth_methods_v1",["verify"]:"verify_v1",["verify-button"]:"verify_button_v1",["components"]:"verify_v1"};var St=e=>e.replace(/[A-Z]/g,t=>`_${t.toLowerCase()}`),re=e=>t=>{if(!t||typeof t!="object")return t;let o=Object.entries(t).map(([n,r])=>{let a;return Array.isArray(r)?a=r.map(re(e)):Object(r)===r?a=re(e)(r):a=r,[e(n),a]});return Object.fromEntries(o)},xt=re(St),q=xt;var Vt=(e,t,o,n)=>{let r={tenantDomain:n,sdkKind:e,sdkName:H,sdkVersion:j,logLevel:o,logMessage:t,sessionId:T()};try{fetch(`${N}/org/sdk_telemetry`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(q(r))});}catch(a){}},z=Vt;var L=(e,t)=>{let o=`@onefootprint/footprint-js: ${t}`;{let n;try{n=window.location.href;}catch(r){}z(e,t,"info",n);}return o},ie=(e,t)=>{let o=`@onefootprint/footprint-js: ${t}`;{let n;try{n=window.location.href;}catch(r){}z(e,t,"warn",n);}return o},J=(e,t)=>{let o=`@onefootprint/footprint-js: ${t}`;{let n;try{n=window.location.href;}catch(r){}z(e,t,"error",n);}return o};var je={["auth"]:{["canceled"]:"onCancel",["closed"]:"onClose",["completed"]:"onComplete"},["update_login_methods"]:{["canceled"]:"onCancel",["closed"]:"onClose",["completed"]:"onComplete"},["form"]:{["canceled"]:"onCancel",["closed"]:"onClose",["completed"]:"onComplete"},["verify"]:{["auth"]:"onAuth",["canceled"]:"onCancel",["closed"]:"onClose",["completed"]:"onComplete"},["components"]:{["auth"]:"onAuth",["canceled"]:"onCancel",["closed"]:"onClose",["completed"]:"onComplete",["relayToComponents"]:"onRelayToComponents"},["verify-button"]:{["auth"]:"onAuth",["canceled"]:"onCancel",["clicked"]:"onClick",["closed"]:"onClose",["completed"]:"onComplete"},["render"]:{}},He={["auth"]:[],["form"]:[],["render"]:[],["update_login_methods"]:[],["verify"]:[],["components"]:[],["verify-button"]:[]};var qe={["auth"]:["modal","drawer"],["components"]:["modal"],["form"]:["inline","modal","drawer"],["render"]:["inline"],["update_login_methods"]:["modal","drawer"],["verify"]:["modal","drawer"],["verify-button"]:["inline"]},It=Object.values(F),At=(...e)=>{},v=e=>e!=null&&typeof e=="object"&&!Array.isArray(e),se=e=>v(e)&&Object.keys(e).length>0,Ot=(e,t)=>{if(e==="inline"&&!t)throw new Error(`Inline component requires a containerId. Received ${t}`)},W=(e,t)=>{var r;if(!t)return;let o=(r=qe[e])!=null?r:[];if(!o.includes(t))throw new Error(`Invalid variant: ${JSON.stringify(t)}. Valid variants for ${e} are ${o.join(", ")}`)},I=e=>{var o;let t=(o=qe[e])!=null?o:[];if(!t.length)throw new Error(`Invalid kind: ${e}`);return t[0]},Q=e=>{if(!e)throw new Error("Kind is required");let t=Object.values(B);if(!t.includes(e))throw new Error(`Invalid kind: ${e}. Valid kinds are: ${t.join(", ")}`)},ze=e=>{if(e.kind==="verify-button"){let t=e,{kind:o,appearance:n,variant:r,dialogVariant:a,onClick:i,label:s,containerId:p}=t,d=ve(t,["kind","appearance","variant","dialogVariant","onClick","label","containerId"]);return P(h({},d),{variant:a,kind:"verify"})}};var Je=(e,t)=>(Object.prototype.hasOwnProperty.call(e,t)&&typeof e[t]=="function"?e[t]:void 0)||At,de=(e,t,o)=>{var s;let{kind:n}=e,r=(s=je[n])!=null?s:{},a={},i=ze(e);return Object.entries(r).forEach(([p,d])=>{let c=p;if(!It.includes(c))return;let C=Je(e,d),A=c==="closed"||c==="canceled",m=n==="verify-button"&&c==="clicked";a[c]=k=>{C(k),A&&(t==null||t()),m&&i&&(o==null||o(i));};}),a},E=e=>{let{kind:t,variant:o,containerId:n}=e,r=o||I(t);return Q(t),W(t,o),Ot(r,n),se(e==null?void 0:e.userData)&&console.warn("userData is deprecated and will be removed in the next major version. Please use bootstrapData instead."),P(h({},e),{variant:r})},w=e=>se(e==null?void 0:e.bootstrapData)?{userData:e.bootstrapData}:se(e==null?void 0:e.userData)?{userData:e.userData}:void 0;var Ft=e=>e==="auth";var Lt=e=>e==="update_login_methods";var pe=e=>e.kind==="components";var le=e=>typeof e=="string"&&e.length>0,X=e=>Ft(e.kind)&&!!("updateLoginMethods"in e&&e.updateLoginMethods)&&!!e.authToken&&/tok_/.test(e.authToken),Et=e=>Lt(e.kind)&&!!e.authToken&&/tok_/.test(e.authToken),ce=e=>[X,Et].some(t=>t(e));var Rt=3,Dt=!1,Kt=e=>ce(e)?"update_auth_methods_v1":b[e.kind],Tt=e=>{var o,n;let{kind:t}=e;if(t==="verify"||t==="components")return P(h({},w(e)),{publicKey:e.publicKey,authToken:e.authToken,options:e.options,l10n:e.l10n,fixtureResult:(o=e.sandboxOutcome)==null?void 0:o.overallOutcome,documentFixtureResult:(n=e.sandboxOutcome)==null?void 0:n.documentOutcome,sandboxId:e.sandboxId,isComponentsSdk:t==="components"});if(t==="update_login_methods")return P(h({},w(e)),{authToken:e.authToken,options:e.options,l10n:e.l10n});if(t==="auth")return X(e)?P(h({},w(e)),{authToken:e.authToken,updateLoginMethods:e.updateLoginMethods,options:e.options,l10n:e.l10n}):e.authToken&&Dt?P(h({},w(e)),{authToken:e.authToken,options:e.options,l10n:e.l10n}):P(h({},w(e)),{publicKey:e.publicKey,options:e.options,l10n:e.l10n});if(t==="form")return {authToken:e.authToken,options:e.options,title:e.title,l10n:e.l10n};if(t==="render")return {authToken:e.authToken,canCopy:e.canCopy,defaultHidden:e.defaultHidden,id:e.id,label:e.label,showHiddenToggle:e.showHiddenToggle,l10n:e.l10n};if(t==="verify-button")return P(h({},w(e)),{publicKey:e.publicKey,options:e.options,authToken:e.authToken,label:e.label,l10n:e.l10n});J(t,"Invalid kind provided");},We=(e,t)=>u(void 0,null,function*(){return fetch(`${N}/org/sdk_args`,{method:"POST",headers:{"x-fp-client-version":`${H} ${j} ${e.kind}`.trim(),"Content-Type":"application/json"},body:JSON.stringify(e)}).then(o=>{if(o.ok)return o.json();if(t>0)return We(e,t-1)})}),Ut=e=>u(void 0,null,function*(){L(b[e.kind],"Sending SDK args");let t=Tt(e);if(!t)return;let o=yield We({data:q(t),kind:Kt(e)},Rt);return o?o.token:void 0}),Qe=Ut;var Xe=({fontSrc:e,variables:t={},rules:o={},variant:n}={})=>{let r=()=>Object.keys(t).length?encodeURIComponent(JSON.stringify(t)):void 0,a=()=>Object.keys(o).length?encodeURIComponent(JSON.stringify(o)):void 0;return {fontSrc:e,variables:r(),rules:a(),variant:n}},Ye=()=>{let e=window.footprintAppearance;return !e||!v(e)?{}:{fontSrc:e.fontSrc,rules:e.rules,variables:e.variables}};var Ze=()=>{var e;return typeof window!="undefined"?((e=window.location)==null?void 0:e.href)||window.location.toString():""},Bt=(e,t)=>{let{appearance:o,kind:n,l10n:r,variant:a}=e,{fontSrc:i,rules:s,variables:p}=Xe(o),d=new URLSearchParams;return p&&d.append("variables",p),s&&d.append("rules",s),i&&d.append("font_src",i),r!=null&&r.language&&d.append("lng",r.language),d.append("variant",a||I(n)),`${d.toString()}#${t}`},_t=(e,t)=>{let{kind:o}=e,n=Bt(e,t),r=`https://components.onefootprint.com/${o}`,a=`https://components2.onefootprint.com/${o}`;if(o==="update_login_methods"&&(r="https://auth.onefootprint.com/user",a="https://auth2.onefootprint.com/user"),o==="auth"&&(r="https://auth.onefootprint.com",a="https://auth2.onefootprint.com"),(o==="verify"||o==="verify-button"||o==="components")&&(r="https://id.onefootprint.com",a="https://id2.onefootprint.com"),!le(r))throw new Error(`${o}_URL environment variable is not defined.`);return r+=`?${n}`.trim(),a+=`?${n}`.trim(),{url:r,fallbackUrl:a}},Ge=_t;var $t=e=>{let t=null,o=!1,n,r,{formSaveComplete:a,formSaved:i,formSaveFailed:s,started:p}=_,d=E(e),{variant:c,containerId:C}=d,A=c==="modal"||c==="drawer",m=$(),k=(l,f)=>{var x;let g=J(b[d.kind],l);(x=d.onError)==null||x.call(d,g),o&&f&&(n(),o=!1);},rt=()=>{if(!t){k("Footprint should be initialized in order to register callback props");return}let l=de(d,n,r);Object.entries(l).forEach(([f,g])=>{t==null||t.on(f,g),t==null||t.on(`${m}:${f}`,g);});},at=()=>{if(A)return Ue(m);if(!C){k("containerId is required when rendering inline");return}let l=document.getElementById(C);if(!l){k(`Could not find container with id ${C} while rendering footprint`);return}return Be(m,l)},Y=(l,f)=>{if(!f){oe(m),t==null||t.frame.classList.remove("fp-hide"),t==null||t.frame.classList.remove(`footprint-${c}-loading`),t==null||t.frame.classList.add(`footprint-${c}-loaded`);return}if(A){let g=_e(l,m);ne(g,m);}else ne(l,m);},fe=()=>{var f;if(!t){k("Footprint should be initialized in order to set up refs");return}if(d.kind!=="form"||!d.getRef)return;let l={save:()=>(t||k("Footprint should be initialized to call ref methods"),new Promise((g,x)=>{t==null||t.on(a,()=>{g();}),t==null||t.on(s,ge=>{x(ge);}),t==null||t.on(`${m}:${a}`,g),t==null||t.on(`${m}:${s}`,x),t==null||t.call(i);}))};(f=d.getRef)==null||f.call(d,l);},ye=(l,f)=>u(void 0,null,function*(){try{return t=yield new Mt({classListArray:[`footprint-${c}`,`footprint-${c}-loading`,"fp-hide"],container:l,name:`footprint-iframe-${m}`,url:f,allow:"otp-credentials; publickey-credentials-get *; camera *; clipboard-write;",model:{authToken:d.authToken,initId:m,sdkUrl:Ze(),sdkVersion:U||""}}),{success:!0,parentApi:t}}catch(g){return k(`Initializing iframe with ${new URL(f).host} failed with error ${g}`),{success:!1}}}),it=(x,ge)=>u(void 0,[x,ge],function*(l,{url:f,fallbackUrl:g}){L(b[d.kind],`Initializing iframe with ${new URL(f).host}`);let he=yield ye(l,f);if(he.success)return he.parentApi;L(b[d.kind],`Initializing iframe with ${new URL(g).host} as fallback`);let ke=yield ye(l,g);if(!ke.success)throw new Error("Failed to initialize iframe");return ke.parentApi});return {relayFromComponents:()=>{t&&(t.call("relayFromComponents"),Me(m));},props:d,isRendered:o,render:()=>u(void 0,null,function*(){if(o){ie(b[d.kind],"Footprint component is already rendered");return}o=!0;let l=at();if(!l){ie(b[d.kind],"Unable to create container for Footprint component");return}l.hasChildNodes()&&(l.innerHTML=""),Y(l,!0);let f=yield Qe(d);if(!f){k("Unable to get SDK args token.",!0),Y(l,!1);return}let{url:g,fallbackUrl:x}=Ge(d,f||"");try{yield it(l,{url:O(g),fallbackUrl:O(x)}),rt();}catch(ge){Ne(l),o=!1;}Y(l,!1),t==null||t.on(p,()=>fe()),t==null||t.on(`${m}:${p}`,fe),d.kind==="components"&&(t==null||t.on(`${m}:${"relayToComponents"}`,()=>{$e(m);}));}),destroy:()=>u(void 0,null,function*(){o&&(o=!1,yield Te(m),t&&(t.destroy(),t=null));}),registerOnDestroy:l=>{!l||typeof l!="function"||(n=l);},registerOnRenderSecondary:l=>{!l||typeof l!="function"||(r=l);}}},me=$t;var S=e=>{let t=E(e);return JSON.stringify(t)},Nt=()=>{let e=Object.create(null);return {getOrCreate:a=>{let i=S(a.props),s=Object.values(e).find(p=>S(p.iframe.props)===i);return s?s.iframe:(e[i]={iframe:a,secondaryIframes:{}},a)},getOrCreateSecondary:(a,i)=>{let s=S(a.props),p=S(i.props);if(!e[s])throw new Error("iframe manager: primary iframe does not exist while adding secondary");let{secondaryIframes:d}=e[s],c=Object.values(d).find(C=>S(C.props)===p);return c||(d[p]=i,i)},remove:a=>{let i=S(a.props),s=e[i];s&&(Object.keys(s.secondaryIframes).forEach(p=>{s.secondaryIframes[p].destroy();}),delete e[i]);},removeSecondary:(a,i)=>{let s=S(a.props),p=S(i.props);if(!e[s])throw new Error("iframe manager: primary iframe does not exist while removing secondary");let{secondaryIframes:d}=e[s],c=d[p];c&&(c.destroy(),delete d[p]);}}},et=Nt;var jt=()=>{let e=et();return {init:o=>{let n=me(o),r=()=>u(void 0,null,function*(){e.remove(n),yield n.destroy();}),a=d=>u(void 0,null,function*(){e.removeSecondary(n,d),yield d.destroy();}),i=d=>u(void 0,null,function*(){let c=me(d);c=e.getOrCreateSecondary(n,c),c.registerOnDestroy(()=>{a(c);}),c.render();}),s=()=>u(void 0,null,function*(){n=e.getOrCreate(n),n.registerOnDestroy(r),n.registerOnRenderSecondary(i),yield n.render();}),p={};return pe(o)&&(p={relayFromComponents:()=>{n.relayFromComponents();}}),h({render:s,destroy:r},p)}}},Ht=jt(),ue=Ht;var qt=e=>{window.setTimeout(e,0);},zt=e=>{if(typeof window=="undefined")return;let t=r=>{var s;let a=(s=window.footprintCallbacks)!=null?s:{};if(!v(a))throw Error("`window.footprintCallbacks` must be a valid mapping from callback names to functions.");return He[r].forEach(p=>{if(!a[p])throw Error(`Callback '${p}' must be defined in window.footprintCallbacks`)}),a},o=r=>{var m;let a=r.getAttribute("data-kind");Q(a);let i=(m=r.getAttribute("data-variant"))!=null?m:I(a);W(a,i);let s=Ye(),p=t(a),d=r.getAttribute("data-props")||"",c;try{c=JSON.parse(d);}catch(k){throw Error("Could not parse `data-props` for footprint.")}if(!v(c))throw Error("`data-props` on the footprint element has to be a valid JSON object stringified.");let C=$();r.setAttribute("id",C),e.init(h(h({kind:a,variant:i,appearance:s,containerId:r.id},p),c)).render();},n=()=>{let r=document.querySelectorAll("[data-footprint]");r.length&&r.forEach(a=>{o(a);});};document.addEventListener("DOMContentLoaded",()=>qt(n));},tt=zt;var Jt="http://test",ot=e=>u(void 0,null,function*(){let t=yield fetch(`${Jt}/hosted/identify/lite`,{method:"POST",body:JSON.stringify(e)});if(!t.ok)throw Error(t.statusText);return (yield t.json()).user_found}),Wt=e=>u(void 0,null,function*(){if(!v(e))throw new Error("User data must be passed in order to identify an user");let t=e["id.email"],o=e["id.phone_number"];return t&&(yield ot({email:t}))?!0:o?yield ot({phone_number:o}):!1}),nt=Wt;var zn=ue;tt(ue);
export { R as FootprintComponentKind, I as FootprintPrivateEvent, O as FootprintPublicEvent, en as default, Ue as identifyFootprintUser };
export { B as FootprintComponentKind, _ as FootprintPrivateEvent, F as FootprintPublicEvent, zn as default, nt as identifyFootprintUser };

@@ -1,6 +0,10 @@

(function (exports) {
(function (exports, ft) {
'use strict';
var Je=Object.defineProperty,Xe=Object.defineProperties;var Ye=Object.getOwnPropertyDescriptors;var I=Object.getOwnPropertySymbols;var le=Object.prototype.hasOwnProperty,ce=Object.prototype.propertyIsEnumerable;var pe=(e,t,o)=>t in e?Je(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,g=(e,t)=>{for(var o in t||(t={}))le.call(t,o)&&pe(e,o,t[o]);if(I)for(var o of I(t))ce.call(t,o)&&pe(e,o,t[o]);return e},P=(e,t)=>Xe(e,Ye(t));var me=(e,t)=>{var o={};for(var n in e)le.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&I)for(var n of I(e))t.indexOf(n)<0&&ce.call(e,n)&&(o[n]=e[n]);return o};var u=(e,t,o)=>new Promise((n,r)=>{var i=p=>{try{s(o.next(p));}catch(d){r(d);}},a=p=>{try{s(o.throw(p));}catch(d){r(d);}},s=p=>p.done?n(p.value):Promise.resolve(p.value).then(i,a);s((o=o.apply(e,t)).next());});var V="application/x-postmate-v1+json",Ze=5,Ge=0,Qe=function(){return ++Ge};var et=function(t){var o=document.createElement("a");o.href=t;var n=o.protocol.length>4?o.protocol:window.location.protocol,r=o.host.length?o.port==="80"||o.port==="443"?o.hostname:o.host:window.location.host;return o.origin||n+"//"+r},tt={handshake:1,"handshake-reply":1,call:1,emit:1,reply:1,request:1},z=function(t,o){return !(typeof o=="string"&&t.origin!==o||!t.data||typeof t.data=="object"&&!("postmate"in t.data)||t.data.type!==V||!tt[t.data.postmate])},ot=function(t,o){var n=typeof t[o]=="function"?t[o]():t[o];return E.Promise.resolve(n)},nt=function(){function e(o){var n=this;this.parent=o.parent,this.frame=o.frame,this.child=o.child,this.childOrigin=o.childOrigin,this.events={},this.listener=function(r){if(!z(r,n.childOrigin))return !1;var i=((r||{}).data||{}).value||{},a=i.data,s=i.name;r.data.postmate==="emit"&&s in n.events&&n.events[s].forEach(function(p){p.call(n,a);});},this.parent.addEventListener("message",this.listener,!1);}var t=e.prototype;return t.get=function(n){var r=this;return new E.Promise(function(i){var a=Qe(),s=function p(d){d.data.uid===a&&d.data.postmate==="reply"&&(r.parent.removeEventListener("message",p,!1),i(d.data.value));};r.parent.addEventListener("message",s,!1),r.child.postMessage({postmate:"request",type:V,property:n,uid:a},r.childOrigin);})},t.call=function(n,r){this.child.postMessage({postmate:"call",type:V,property:n,data:r},this.childOrigin);},t.on=function(n,r){this.events[n]||(this.events[n]=[]),this.events[n].push(r);},t.destroy=function(){window.removeEventListener("message",this.listener,!1),this.frame.parentNode.removeChild(this.frame);},e}(),rt=function(){function e(o){var n=this;this.model=o.model,this.parent=o.parent,this.parentOrigin=o.parentOrigin,this.child=o.child,this.child.addEventListener("message",function(r){if(z(r,n.parentOrigin)){var i=r.data,a=i.property,s=i.uid,p=i.data;if(r.data.postmate==="call"){a in n.model&&typeof n.model[a]=="function"&&n.model[a](p);return}ot(n.model,a).then(function(d){return r.source.postMessage({property:a,postmate:"reply",type:V,uid:s,value:d},r.origin)});}});}var t=e.prototype;return t.emit=function(n,r){this.parent.postMessage({postmate:"emit",type:V,value:{name:n,data:r}},this.parentOrigin);},e}(),E=function(){function e(o){var n=o.container,r=n===void 0?typeof r!="undefined"?r:document.body:n,i=o.model,a=o.url,s=o.name,p=s===void 0?"":s,d=o.allow,l=o.id,y=o.classListArray,k=y===void 0?[]:y;return this.parent=window,this.frame=document.createElement("iframe"),this.frame.name=p||"",this.frame.classList.add.apply(this.frame.classList,k),d&&(this.frame.allow=d),l&&(this.frame.id=l),r.appendChild(this.frame),this.child=this.frame.contentWindow||this.frame.contentDocument.parentWindow,this.model=i||{},this.sendHandshake(a)}var t=e.prototype;return t.sendHandshake=function(n){var r=this,i=et(n),a=0,s;return new e.Promise(function(p,d){var l=function m(v){return z(v,i)?v.data.postmate==="handshake-reply"?(clearInterval(s),r.parent.removeEventListener("message",m,!1),r.childOrigin=v.origin,p(new nt(r))):d("Failed handshake"):!1};r.parent.addEventListener("message",l,!1);var y=function(){if(a++,r.child.postMessage({postmate:"handshake",type:V,model:r.model},i),a===Ze)return clearInterval(s),d("Failed to handshake")},k=function(){y(),s=setInterval(y,500);};r.frame.attachEvent?r.frame.attachEvent("onload",k):r.frame.addEventListener("load",k),r.frame.src=n;})},e}();E.debug=!1;E.Promise=function(){try{return window?window.Promise:Promise}catch(e){return null}}();E.Model=function(){function e(o){return this.child=window,this.model=o,this.parent=this.child.parent,this.sendHandshakeReply()}var t=e.prototype;return t.sendHandshakeReply=function(){var n=this;return new E.Promise(function(r,i){var a=function s(p){if(p.data.postmate){if(p.data.postmate==="handshake"){n.child.removeEventListener("message",s,!1),p.source.postMessage({postmate:"handshake-reply",type:V},p.origin),n.parentOrigin=p.origin;var d=p.data.model;return d&&Object.keys(d).forEach(function(l){n.model[l]=d[l];}),r(new rt(n))}return i("Handshake Reply Failed")}};n.child.addEventListener("message",a,!1);})},e}();var ue=E;var F="3.14.0";var R=(s=>(s.Auth="auth",s.Components="components",s.Form="form",s.Render="render",s.UpdateLoginMethods="update_login_methods",s.Verify="verify",s.VerifyButton="verify-button",s))(R||{});var x=(a=>(a.auth="auth",a.canceled="canceled",a.clicked="clicked",a.closed="closed",a.completed="completed",a.relayToComponents="relayToComponents",a))(x||{}),K=(a=>(a.formSaveComplete="formSaveComplete",a.formSaveFailed="formSaveFailed",a.formSaved="formSaved",a.propsReceived="propsReceived",a.started="started",a.relayFromComponents="relayFromComponents",a))(K||{});var fe="footprint-inline-container",ye="footprint-body-locked",he="footprint-overlay",it="footprint-overlay-container",ge=fe,ve=he,ke="footprint-loading-indicator",_=e=>`${it}-${e}`,A=(e,t)=>`${e}-${t}`,Pe=e=>u(void 0,null,function*(){W(e),dt(e),yield st(e);}),Ce=e=>{let t=_(e),o=document.getElementById(t);if(o)return o;let n=document.createElement("div");return n.setAttribute("id",t),document.body.appendChild(n),n},st=e=>u(void 0,null,function*(){let t=_(e),o=document.getElementById(t);if(!o)return;let n=o.querySelector("iframe.footprint-drawer");n&&(n==null||n.classList.add("footprint-drawer-closing"),yield new Promise(s=>{setTimeout(s,300);}));let r=o.querySelector("iframe.footprint-modal");r&&(r==null||r.classList.add("footprint-modal-closing"),yield new Promise(s=>{setTimeout(s,100);}));let i=A(ve,e),a=document.getElementById(i);a&&(a.classList.add("footprint-overlay-fading"),yield new Promise(s=>{setTimeout(s,200);}),o.remove(),a.remove(),document.body.classList.remove(ye));}),be=(e,t)=>{let o=A(ge,e),n=document.createElement("div");return n.classList.add(fe),n.setAttribute("id",o),t.appendChild(n),n},dt=e=>{let t=A(ge,e),o=document.getElementById(t);o&&o.remove();},W=e=>{let t=A(ke,e),o=document.getElementById(t);o&&o.remove();},J=(e,t)=>{let o=A(ke,t),n=pt(o);e.appendChild(n);},we=(e,t)=>{document.body.classList.add(ye);let o=document.createElement("div"),n=A(ve,t);return o.setAttribute("id",n),o.classList.add(he),e.appendChild(o),o},pt=e=>{let t=document.createElement("div");t.setAttribute("id",e),t.classList.add("footprint-loading-indicator");let o=document.createElement("div");o.classList.add("footprint-loading-spin");let n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.setAttribute("width","24px"),n.setAttribute("height","24px"),n.setAttribute("fill","none"),n.setAttribute("aria-hidden","true");let r=document.createElementNS("http://www.w3.org/2000/svg","path");return r.setAttribute("d","M12 2a10 10 0 0 1 10 10h-2a7.999 7.999 0 0 0-8-8V2Z"),n.appendChild(r),o.appendChild(n),t.appendChild(o),t},Ve=e=>{let t=document.getElementById(_(e));t&&(t.style.opacity="1",t.style.display="block");},Ee=e=>{let t=document.getElementById(_(e));t&&(t.style.opacity="0",t.style.display="none");},Oe=e=>{let t=document.createElement("div");t.classList.add("modal-error-container"),t.setAttribute("role","dialog"),t.setAttribute("aria-modal","true"),t.setAttribute("aria-label","Oops! Something\u2019s not quite right.");let o=document.createElement("div");o.classList.add("modal-error");let n=document.createElement("button");n.setAttribute("aria-label","Close"),n.classList.add("modal-error-close-button"),n.addEventListener("click",()=>{e.remove();});let r=document.createElementNS("http://www.w3.org/2000/svg","svg");r.setAttribute("xmlns","http://www.w3.org/2000/svg"),r.setAttribute("width","20"),r.setAttribute("height","20"),r.setAttribute("viewBox","0 0 20 20"),r.setAttribute("fill","none");let i=document.createElementNS("http://www.w3.org/2000/svg","path");i.setAttribute("d","M5 5L15 15M15 5L5 15"),i.setAttribute("stroke","black"),i.setAttribute("stroke-width","1.5"),i.setAttribute("stroke-linecap","round"),r.appendChild(i),n.appendChild(r);let a=document.createElementNS("http://www.w3.org/2000/svg","svg");a.setAttribute("xmlns","http://www.w3.org/2000/svg"),a.setAttribute("width","40"),a.setAttribute("height","40"),a.setAttribute("viewBox","0 0 40 40"),a.setAttribute("fill","none"),a.setAttribute("class","error-icon");let s=document.createElementNS("http://www.w3.org/2000/svg","path");s.setAttribute("d","M25 15L15 25M25 25L15 15M35 20C35 28.2843 28.2843 35 20 35C11.7157 35 5 28.2843 5 20C5 11.7157 11.7157 5 20 5C28.2843 5 35 11.7157 35 20Z"),s.setAttribute("stroke","black"),s.setAttribute("stroke-width","3.33333"),s.setAttribute("stroke-linecap","round"),s.setAttribute("stroke-linejoin","round"),a.appendChild(s);let p=document.createElement("h2");p.textContent="Oops! Something\u2019s not quite right.";let d=document.createElement("p");d.textContent="It looks like there was an issue loading the page. Try reloading and we\u2019ll get things back on track.",o.appendChild(n),o.appendChild(a),o.appendChild(p),o.appendChild(d),t.appendChild(o),e.appendChild(t);};var lt=()=>Math.random().toString(36).substring(2),T=lt;var B="https://api.onefootprint.com",M=F,U="footprint-js";var S={["auth"]:"auth_v1",["form"]:"form_v1",["render"]:"render_v1",["update_login_methods"]:"update_auth_methods_v1",["verify"]:"verify_v1",["verify-button"]:"verify_button_v1",["components"]:"verify_v1"};var ct=e=>e.replace(/[A-Z]/g,t=>`_${t.toLowerCase()}`),X=e=>t=>{if(!t||typeof t!="object")return t;let o=Object.entries(t).map(([n,r])=>{let i;return Array.isArray(r)?i=r.map(X(e)):Object(r)===r?i=X(e)(r):i=r,[e(n),i]});return Object.fromEntries(o)},mt=X(ct),N=mt;var ut=(e,t,o,n)=>{let r={tenantDomain:n,sdkKind:e,sdkName:U,sdkVersion:M,logLevel:o,logMessage:t};try{fetch(`${B}/org/sdk_telemetry`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(N(r))});}catch(i){}},Y=ut;var Z=(e,t)=>{let o=`@onefootprint/footprint-js: ${t}`;{let n;try{n=window.location.href;}catch(r){}Y(e,t,"warn",n);}return o},Se=(e,t)=>{let o=`@onefootprint/footprint-js: ${t}`;{let n;try{n=window.location.href;}catch(r){}Y(e,t,"error",n);}return o};var Le={["auth"]:{["canceled"]:"onCancel",["closed"]:"onClose",["completed"]:"onComplete"},["update_login_methods"]:{["canceled"]:"onCancel",["closed"]:"onClose",["completed"]:"onComplete"},["form"]:{["canceled"]:"onCancel",["closed"]:"onClose",["completed"]:"onComplete"},["verify"]:{["auth"]:"onAuth",["canceled"]:"onCancel",["closed"]:"onClose",["completed"]:"onComplete"},["components"]:{["auth"]:"onAuth",["canceled"]:"onCancel",["closed"]:"onClose",["completed"]:"onComplete",["relayToComponents"]:"onRelayToComponents"},["verify-button"]:{["auth"]:"onAuth",["canceled"]:"onCancel",["clicked"]:"onClick",["closed"]:"onClose",["completed"]:"onComplete"},["render"]:{}},xe={["auth"]:[],["form"]:[],["render"]:[],["update_login_methods"]:[],["verify"]:[],["components"]:[],["verify-button"]:[]};var De={["auth"]:["modal","drawer"],["components"]:["modal"],["form"]:["inline","modal","drawer"],["render"]:["inline"],["update_login_methods"]:["modal","drawer"],["verify"]:["modal","drawer"],["verify-button"]:["inline"]},ft=Object.values(x),yt=(...e)=>{},C=e=>e!=null&&typeof e=="object"&&!Array.isArray(e),G=e=>C(e)&&Object.keys(e).length>0,ht=(e,t)=>{if(e==="inline"&&!t)throw new Error(`Inline component requires a containerId. Received ${t}`)},$=(e,t)=>{var r;if(!t)return;let o=(r=De[e])!=null?r:[];if(!o.includes(t))throw new Error(`Invalid variant: ${JSON.stringify(t)}. Valid variants for ${e} are ${o.join(", ")}`)},L=e=>{var o;let t=(o=De[e])!=null?o:[];if(!t.length)throw new Error(`Invalid kind: ${e}`);return t[0]},H=e=>{if(!e)throw new Error("Kind is required");let t=Object.values(R);if(!t.includes(e))throw new Error(`Invalid kind: ${e}. Valid kinds are: ${t.join(", ")}`)},Ie=e=>{if(e.kind==="verify-button"){let t=e,{kind:o,appearance:n,variant:r,dialogVariant:i,onClick:a,label:s,containerId:p}=t,d=me(t,["kind","appearance","variant","dialogVariant","onClick","label","containerId"]);return P(g({},d),{variant:i,kind:"verify"})}};var Fe=(e,t)=>(Object.prototype.hasOwnProperty.call(e,t)&&typeof e[t]=="function"?e[t]:void 0)||yt,Q=(e,t,o)=>{var s;let{kind:n}=e,r=(s=Le[n])!=null?s:{},i={},a=Ie(e);return Object.entries(r).forEach(([p,d])=>{let l=p;if(!ft.includes(l))return;let y=Fe(e,d),k=l==="closed"||l==="canceled",m=n==="verify-button"&&l==="clicked";i[l]=v=>{y(v),k&&(t==null||t()),m&&a&&(o==null||o(a));};}),i},D=e=>{let{kind:t,variant:o,containerId:n}=e,r=o||L(t);return H(t),$(t,o),ht(r,n),G(e==null?void 0:e.userData)&&console.warn("userData is deprecated and will be removed in the next major version. Please use bootstrapData instead."),P(g({},e),{variant:r})},b=e=>G(e==null?void 0:e.bootstrapData)?{userData:e.bootstrapData}:G(e==null?void 0:e.userData)?{userData:e.userData}:void 0;var gt=e=>e==="auth";var vt=e=>e==="update_login_methods";var ee=e=>e.kind==="components";var te=e=>typeof e=="string"&&e.length>0,j=e=>gt(e.kind)&&!!("updateLoginMethods"in e&&e.updateLoginMethods)&&!!e.authToken&&/tok_/.test(e.authToken),kt=e=>vt(e.kind)&&!!e.authToken&&/tok_/.test(e.authToken),oe=e=>[j,kt].some(t=>t(e));var Pt=3,Ct=!1,bt=e=>oe(e)?"update_auth_methods_v1":S[e.kind],wt=e=>{var o,n;let{kind:t}=e;if(t==="verify"||t==="components")return P(g({},b(e)),{publicKey:e.publicKey,authToken:e.authToken,options:e.options,l10n:e.l10n,fixtureResult:(o=e.sandboxOutcome)==null?void 0:o.overallOutcome,documentFixtureResult:(n=e.sandboxOutcome)==null?void 0:n.documentOutcome,isComponentsSdk:t==="components"});if(t==="update_login_methods")return P(g({},b(e)),{authToken:e.authToken,options:e.options,l10n:e.l10n});if(t==="auth")return j(e)?P(g({},b(e)),{authToken:e.authToken,updateLoginMethods:e.updateLoginMethods,options:e.options,l10n:e.l10n}):e.authToken&&Ct?P(g({},b(e)),{authToken:e.authToken,options:e.options,l10n:e.l10n}):P(g({},b(e)),{publicKey:e.publicKey,options:e.options,l10n:e.l10n});if(t==="form")return {authToken:e.authToken,options:e.options,title:e.title,l10n:e.l10n};if(t==="render")return {authToken:e.authToken,canCopy:e.canCopy,defaultHidden:e.defaultHidden,id:e.id,label:e.label,showHiddenToggle:e.showHiddenToggle,l10n:e.l10n};if(t==="verify-button")return P(g({},b(e)),{publicKey:e.publicKey,options:e.options,authToken:e.authToken,label:e.label,l10n:e.l10n})},Re=(e,t)=>u(void 0,null,function*(){return fetch(`${B}/org/sdk_args`,{method:"POST",headers:{"x-fp-client-version":`${U} ${M} ${e.kind}`.trim(),"Content-Type":"application/json"},body:JSON.stringify(e)}).then(o=>{if(o.ok)return o.json();if(t>0)return Re(e,t-1)})}),Vt=e=>u(void 0,null,function*(){let t=wt(e);if(!t)return;let o=yield Re({data:N(t),kind:bt(e)},Pt);return o?o.token:void 0}),Ke=Vt;var _e=({fontSrc:e,variables:t={},rules:o={},variant:n}={})=>{let r=()=>Object.keys(t).length?encodeURIComponent(JSON.stringify(t)):void 0,i=()=>Object.keys(o).length?encodeURIComponent(JSON.stringify(o)):void 0;return {fontSrc:e,variables:r(),rules:i(),variant:n}},Te=()=>{let e=window.footprintAppearance;return !e||!C(e)?{}:{fontSrc:e.fontSrc,rules:e.rules,variables:e.variables}};var Be=()=>{var e;return typeof window!="undefined"?((e=window.location)==null?void 0:e.href)||window.location.toString():""},Et=(e,t)=>{let{appearance:o,kind:n,l10n:r,variant:i}=e,{fontSrc:a,rules:s,variables:p}=_e(o),d=new URLSearchParams;return p&&d.append("variables",p),s&&d.append("rules",s),a&&d.append("font_src",a),r!=null&&r.language&&d.append("lng",r.language),d.append("variant",i||L(n)),`${d.toString()}#${t}`},Ot=(e,t)=>{let{kind:o}=e,n=Et(e,t),r=`https://components.onefootprint.com/${o}`,i=`https://components2.onefootprint.com/${o}`;if(o==="update_login_methods"&&(r="https://auth.onefootprint.com/user",i="https://auth2.onefootprint.com/user"),o==="auth"&&(r="https://auth.onefootprint.com",i="https://auth2.onefootprint.com"),(o==="verify"||o==="verify-button"||o==="components")&&(r="https://id.onefootprint.com",i="https://id2.onefootprint.com"),!te(r))throw new Error(`${o}_URL environment variable is not defined.`);return r+=`?${n}`.trim(),i+=`?${n}`.trim(),{url:r,fallbackUrl:i}},Me=Ot;var At=e=>{let t=null,o=!1,n,r,{formSaveComplete:i,formSaved:a,formSaveFailed:s,started:p}=K,d=D(e),{variant:l,containerId:y}=d,k=l==="modal"||l==="drawer",m=T(),v=(c,f)=>{var O;let h=Se(S[d.kind],c);(O=d.onError)==null||O.call(d,h),o&&f&&(n(),o=!1);},je=()=>{if(!t){v("Footprint should be initialized in order to register callback props");return}let c=Q(d,n,r);Object.entries(c).forEach(([f,h])=>{t==null||t.on(f,h),t==null||t.on(`${m}:${f}`,h);});},qe=()=>{if(k)return Ce(m);if(!y){v("containerId is required when rendering inline");return}let c=document.getElementById(y);if(!c){v(`Could not find container with id ${y} while rendering footprint`);return}return be(m,c)},q=(c,f)=>{if(!f){W(m),t==null||t.frame.classList.remove("fp-hide"),t==null||t.frame.classList.remove(`footprint-${l}-loading`),t==null||t.frame.classList.add(`footprint-${l}-loaded`);return}if(k){let h=we(c,m);J(h,m);}else J(c,m);},ae=()=>{var f;if(!t){v("Footprint should be initialized in order to set up refs");return}if(d.kind!=="form"||!d.getRef)return;let c={save:()=>(t||v("Footprint should be initialized to call ref methods"),new Promise((h,O)=>{t==null||t.on(i,()=>{h();}),t==null||t.on(s,We=>{O(We);}),t==null||t.on(`${m}:${i}`,h),t==null||t.on(`${m}:${s}`,O),t==null||t.call(a);}))};(f=d.getRef)==null||f.call(d,c);},ie=(c,f)=>u(void 0,null,function*(){try{return t=yield new ue({classListArray:[`footprint-${l}`,`footprint-${l}-loading`,"fp-hide"],container:c,name:`footprint-iframe-${m}`,url:f,allow:"otp-credentials; publickey-credentials-get *; camera *; clipboard-write;",model:{authToken:d.authToken,initId:m,sdkUrl:Be(),sdkVersion:F||""}}),{success:!0,parentApi:t}}catch(h){return v(`Initializing ${f} iframe failed with error ${h}`),{success:!1}}}),ze=(O,We)=>u(void 0,[O,We],function*(c,{url:f,fallbackUrl:h}){let se=yield ie(c,f);if(se.success)return se.parentApi;let de=yield ie(c,h);if(!de.success)throw new Error("Failed to initialize iframe");return de.parentApi});return {relayFromComponents:()=>{t&&(t.call("relayFromComponents"),Ve(m));},props:d,isRendered:o,render:()=>u(void 0,null,function*(){if(o){Z(S[d.kind],"Footprint component is already rendered");return}o=!0;let c=qe();if(!c){Z(S[d.kind],"Unable to create container for Footprint component");return}c.hasChildNodes()&&(c.innerHTML=""),q(c,!0);let f=yield Ke(d);if(!f){v("Unable to get SDK args token.",!0),q(c,!1);return}let h=Me(d,f||"");try{yield ze(c,h),je();}catch(O){Oe(c),o=!1;}q(c,!1),t==null||t.on(p,()=>ae()),t==null||t.on(`${m}:${p}`,ae),d.kind==="components"&&(t==null||t.on(`${m}:${"relayToComponents"}`,()=>{Ee(m);}));}),destroy:()=>u(void 0,null,function*(){o&&(o=!1,yield Pe(m),t&&(t.destroy(),t=null));}),registerOnDestroy:c=>{!c||typeof c!="function"||(n=c);},registerOnRenderSecondary:c=>{!c||typeof c!="function"||(r=c);}}},ne=At;var w=e=>{let t=D(e);return JSON.stringify(t)},St=()=>{let e=Object.create(null);return {getOrCreate:i=>{let a=w(i.props),s=Object.values(e).find(p=>w(p.iframe.props)===a);return s?s.iframe:(e[a]={iframe:i,secondaryIframes:{}},i)},getOrCreateSecondary:(i,a)=>{let s=w(i.props),p=w(a.props);if(!e[s])throw new Error("iframe manager: primary iframe does not exist while adding secondary");let{secondaryIframes:d}=e[s],l=Object.values(d).find(y=>w(y.props)===p);return l||(d[p]=a,a)},remove:i=>{let a=w(i.props),s=e[a];s&&(Object.keys(s.secondaryIframes).forEach(p=>{s.secondaryIframes[p].destroy();}),delete e[a]);},removeSecondary:(i,a)=>{let s=w(i.props),p=w(a.props);if(!e[s])throw new Error("iframe manager: primary iframe does not exist while removing secondary");let{secondaryIframes:d}=e[s],l=d[p];l&&(l.destroy(),delete d[p]);}}},Ue=St;var Lt=()=>{let e=Ue();return {init:o=>{let n=ne(o),r=()=>u(void 0,null,function*(){e.remove(n),yield n.destroy();}),i=d=>u(void 0,null,function*(){e.removeSecondary(n,d),yield d.destroy();}),a=d=>u(void 0,null,function*(){let l=ne(d);l=e.getOrCreateSecondary(n,l),l.registerOnDestroy(()=>{i(l);}),l.render();}),s=()=>u(void 0,null,function*(){n=e.getOrCreate(n),n.registerOnDestroy(r),n.registerOnRenderSecondary(a),yield n.render();}),p={};return ee(o)&&(p={relayFromComponents:()=>{n.relayFromComponents();}}),g({render:s,destroy:r},p)}}},xt=Lt(),re=xt;var Dt=e=>{window.setTimeout(e,0);},It=e=>{if(typeof window=="undefined")return;let t=r=>{var s;let i=(s=window.footprintCallbacks)!=null?s:{};if(!C(i))throw Error("`window.footprintCallbacks` must be a valid mapping from callback names to functions.");return xe[r].forEach(p=>{if(!i[p])throw Error(`Callback '${p}' must be defined in window.footprintCallbacks`)}),i},o=r=>{var m;let i=r.getAttribute("data-kind");H(i);let a=(m=r.getAttribute("data-variant"))!=null?m:L(i);$(i,a);let s=Te(),p=t(i),d=r.getAttribute("data-props")||"",l;try{l=JSON.parse(d);}catch(v){throw Error("Could not parse `data-props` for footprint.")}if(!C(l))throw Error("`data-props` on the footprint element has to be a valid JSON object stringified.");let y=T();r.setAttribute("id",y),e.init(g(g({kind:i,variant:a,appearance:s,containerId:r.id},p),l)).render();},n=()=>{let r=document.querySelectorAll("[data-footprint]");r.length&&r.forEach(i=>{o(i);});};document.addEventListener("DOMContentLoaded",()=>Dt(n));},Ne=It;var Ft="http://test",$e=e=>u(void 0,null,function*(){let t=yield fetch(`${Ft}/hosted/identify/lite`,{method:"POST",body:JSON.stringify(e)});if(!t.ok)throw Error(t.statusText);return (yield t.json()).user_found}),Rt=e=>u(void 0,null,function*(){if(!C(e))throw new Error("User data must be passed in order to identify an user");let t=e["id.email"],o=e["id.phone_number"];return t&&(yield $e({email:t}))?!0:o?yield $e({phone_number:o}):!1}),He=Rt;var un=re;Ne(re);/*! Bundled license information:
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
var ft__default = /*#__PURE__*/_interopDefault(ft);
var ct=Object.defineProperty,mt=Object.defineProperties;var ut=Object.getOwnPropertyDescriptors;var K=Object.getOwnPropertySymbols;var be=Object.prototype.hasOwnProperty,Se=Object.prototype.propertyIsEnumerable;var we=(e,t,o)=>t in e?ct(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,v=(e,t)=>{for(var o in t||(t={}))be.call(t,o)&&we(e,o,t[o]);if(K)for(var o of K(t))Se.call(t,o)&&we(e,o,t[o]);return e},C=(e,t)=>mt(e,ut(t));var Ve=(e,t)=>{var o={};for(var n in e)be.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&K)for(var n of K(e))t.indexOf(n)<0&&Se.call(e,n)&&(o[n]=e[n]);return o};var u=(e,t,o)=>new Promise((n,r)=>{var i=p=>{try{s(o.next(p));}catch(d){r(d);}},a=p=>{try{s(o.throw(p));}catch(d){r(d);}},s=p=>p.done?n(p.value):Promise.resolve(p.value).then(i,a);s((o=o.apply(e,t)).next());});var T=new Uint8Array(256),_=T.length;function ee(){return _>T.length-16&&(ft__default.default.randomFillSync(T),_=0),T.slice(_,_+=16)}var y=[];for(let e=0;e<256;++e)y.push((e+256).toString(16).slice(1));function Ee(e,t=0){return (y[e[t+0]]+y[e[t+1]]+y[e[t+2]]+y[e[t+3]]+"-"+y[e[t+4]]+y[e[t+5]]+"-"+y[e[t+6]]+y[e[t+7]]+"-"+y[e[t+8]]+y[e[t+9]]+"-"+y[e[t+10]]+y[e[t+11]]+y[e[t+12]]+y[e[t+13]]+y[e[t+14]]+y[e[t+15]]).toLowerCase()}var te={randomUUID:ft__default.default.randomUUID};function gt(e,t,o){if(te.randomUUID&&!t&&!e)return te.randomUUID();e=e||{};let n=e.random||(e.rng||ee)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,t){o=o||0;for(let r=0;r<16;++r)t[o+r]=n[r];return t}return Ee(n)}var oe=gt;var Oe="fp-session-id",xe=typeof window!="undefined",ne="xfpsessionid",Ie=(e,t)=>new URL(t).searchParams.get(e),vt=e=>{var t,o;try{let n=(o=(t=window==null?void 0:window.top)==null?void 0:t.location)==null?void 0:o.href;return n?Ie(e,n):null}catch(n){return null}},Ae=e=>xe?Ie(e,window.location.href)||vt(e):null,Le=()=>{if((!xe||!window.sessionStorage))return !1;try{let e="test";return sessionStorage.setItem(e,e),sessionStorage.removeItem(e),!0}catch(e){return !1}},Pt=()=>{let e=Ae(ne)||oe();if(Le())try{sessionStorage.setItem(Oe,e);}catch(t){console.error("Failed to create session id",t);}return e},kt=()=>{let e=Ae(ne);return e||(Le()?sessionStorage.getItem(Oe):null)},De=()=>kt()||Pt(),L=(e,t=De())=>{let o=new URL(e);return o.searchParams.set(ne,t),o.toString()};var U=De;var O="application/x-postmate-v1+json",wt=5,bt=0,St=function(){return ++bt};var Vt=function(t){var o=document.createElement("a");o.href=t;var n=o.protocol.length>4?o.protocol:window.location.protocol,r=o.host.length?o.port==="80"||o.port==="443"?o.hostname:o.host:window.location.host;return o.origin||n+"//"+r},Et={handshake:1,"handshake-reply":1,call:1,emit:1,reply:1,request:1},re=function(t,o){return !(typeof o=="string"&&t.origin!==o||!t.data||typeof t.data=="object"&&!("postmate"in t.data)||t.data.type!==O||!Et[t.data.postmate])},Ot=function(t,o){var n=typeof t[o]=="function"?t[o]():t[o];return x.Promise.resolve(n)},xt=function(){function e(o){var n=this;this.parent=o.parent,this.frame=o.frame,this.child=o.child,this.childOrigin=o.childOrigin,this.events={},this.listener=function(r){if(!re(r,n.childOrigin))return !1;var i=((r||{}).data||{}).value||{},a=i.data,s=i.name;r.data.postmate==="emit"&&s in n.events&&n.events[s].forEach(function(p){p.call(n,a);});},this.parent.addEventListener("message",this.listener,!1);}var t=e.prototype;return t.get=function(n){var r=this;return new x.Promise(function(i){var a=St(),s=function p(d){d.data.uid===a&&d.data.postmate==="reply"&&(r.parent.removeEventListener("message",p,!1),i(d.data.value));};r.parent.addEventListener("message",s,!1),r.child.postMessage({postmate:"request",type:O,property:n,uid:a},r.childOrigin);})},t.call=function(n,r){this.child.postMessage({postmate:"call",type:O,property:n,data:r},this.childOrigin);},t.on=function(n,r){this.events[n]||(this.events[n]=[]),this.events[n].push(r);},t.destroy=function(){window.removeEventListener("message",this.listener,!1),this.frame.parentNode.removeChild(this.frame);},e}(),It=function(){function e(o){var n=this;this.model=o.model,this.parent=o.parent,this.parentOrigin=o.parentOrigin,this.child=o.child,this.child.addEventListener("message",function(r){if(re(r,n.parentOrigin)){var i=r.data,a=i.property,s=i.uid,p=i.data;if(r.data.postmate==="call"){a in n.model&&typeof n.model[a]=="function"&&n.model[a](p);return}Ot(n.model,a).then(function(d){return r.source.postMessage({property:a,postmate:"reply",type:O,uid:s,value:d},r.origin)});}});}var t=e.prototype;return t.emit=function(n,r){this.parent.postMessage({postmate:"emit",type:O,value:{name:n,data:r}},this.parentOrigin);},e}(),x=function(){function e(o){var n=o.container,r=n===void 0?typeof r!="undefined"?r:document.body:n,i=o.model,a=o.url,s=o.name,p=s===void 0?"":s,d=o.allow,l=o.id,h=o.classListArray,k=h===void 0?[]:h;return this.parent=window,this.frame=document.createElement("iframe"),this.frame.name=p||"",this.frame.classList.add.apply(this.frame.classList,k),d&&(this.frame.allow=d),l&&(this.frame.id=l),r.appendChild(this.frame),this.child=this.frame.contentWindow||this.frame.contentDocument.parentWindow,this.model=i||{},this.sendHandshake(a)}var t=e.prototype;return t.sendHandshake=function(n){var r=this,i=Vt(n),a=0,s;return new e.Promise(function(p,d){var l=function m(P){return re(P,i)?P.data.postmate==="handshake-reply"?(clearInterval(s),r.parent.removeEventListener("message",m,!1),r.childOrigin=P.origin,p(new xt(r))):d("Failed handshake"):!1};r.parent.addEventListener("message",l,!1);var h=function(){if(a++,r.child.postMessage({postmate:"handshake",type:O,model:r.model},i),a===wt)return clearInterval(s),d("Failed to handshake")},k=function(){h(),s=setInterval(h,500);};r.frame.attachEvent?r.frame.attachEvent("onload",k):r.frame.addEventListener("load",k),r.frame.src=n;})},e}();x.debug=!1;x.Promise=function(){try{return window?window.Promise:Promise}catch(e){return null}}();x.Model=function(){function e(o){return this.child=window,this.model=o,this.parent=this.child.parent,this.sendHandshakeReply()}var t=e.prototype;return t.sendHandshakeReply=function(){var n=this;return new x.Promise(function(r,i){var a=function s(p){if(p.data.postmate){if(p.data.postmate==="handshake"){n.child.removeEventListener("message",s,!1),p.source.postMessage({postmate:"handshake-reply",type:O},p.origin),n.parentOrigin=p.origin;var d=p.data.model;return d&&Object.keys(d).forEach(function(l){n.model[l]=d[l];}),r(new It(n))}return i("Handshake Reply Failed")}};n.child.addEventListener("message",a,!1);})},e}();var Fe=x;var B="3.14.1";var M=(s=>(s.Auth="auth",s.Components="components",s.Form="form",s.Render="render",s.UpdateLoginMethods="update_login_methods",s.Verify="verify",s.VerifyButton="verify-button",s))(M||{});var D=(a=>(a.auth="auth",a.canceled="canceled",a.clicked="clicked",a.closed="closed",a.completed="completed",a.relayToComponents="relayToComponents",a))(D||{}),N=(a=>(a.formSaveComplete="formSaveComplete",a.formSaveFailed="formSaveFailed",a.formSaved="formSaved",a.propsReceived="propsReceived",a.started="started",a.relayFromComponents="relayFromComponents",a))(N||{});var Re="footprint-inline-container",Ke="footprint-body-locked",_e="footprint-overlay",Lt="footprint-overlay-container",Te=Re,Ue=_e,Be="footprint-loading-indicator",$=e=>`${Lt}-${e}`,I=(e,t)=>`${e}-${t}`,Me=e=>u(void 0,null,function*(){ae(e),Ft(e),yield Dt(e);}),Ne=e=>{let t=$(e),o=document.getElementById(t);if(o)return o;let n=document.createElement("div");return n.setAttribute("id",t),document.body.appendChild(n),n},Dt=e=>u(void 0,null,function*(){let t=$(e),o=document.getElementById(t);if(!o)return;let n=o.querySelector("iframe.footprint-drawer");n&&(n==null||n.classList.add("footprint-drawer-closing"),yield new Promise(s=>{setTimeout(s,300);}));let r=o.querySelector("iframe.footprint-modal");r&&(r==null||r.classList.add("footprint-modal-closing"),yield new Promise(s=>{setTimeout(s,100);}));let i=I(Ue,e),a=document.getElementById(i);a&&(a.classList.add("footprint-overlay-fading"),yield new Promise(s=>{setTimeout(s,200);}),o.remove(),a.remove(),document.body.classList.remove(Ke));}),$e=(e,t)=>{let o=I(Te,e),n=document.createElement("div");return n.classList.add(Re),n.setAttribute("id",o),t.appendChild(n),n},Ft=e=>{let t=I(Te,e),o=document.getElementById(t);o&&o.remove();},ae=e=>{let t=I(Be,e),o=document.getElementById(t);o&&o.remove();},ie=(e,t)=>{let o=I(Be,t),n=Rt(o);e.appendChild(n);},He=(e,t)=>{document.body.classList.add(Ke);let o=document.createElement("div"),n=I(Ue,t);return o.setAttribute("id",n),o.classList.add(_e),e.appendChild(o),o},Rt=e=>{let t=document.createElement("div");t.setAttribute("id",e),t.classList.add("footprint-loading-indicator");let o=document.createElement("div");o.classList.add("footprint-loading-spin");let n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.setAttribute("width","24px"),n.setAttribute("height","24px"),n.setAttribute("fill","none"),n.setAttribute("aria-hidden","true");let r=document.createElementNS("http://www.w3.org/2000/svg","path");return r.setAttribute("d","M12 2a10 10 0 0 1 10 10h-2a7.999 7.999 0 0 0-8-8V2Z"),n.appendChild(r),o.appendChild(n),t.appendChild(o),t},je=e=>{let t=document.getElementById($(e));t&&(t.style.opacity="1",t.style.display="block");},qe=e=>{let t=document.getElementById($(e));t&&(t.style.opacity="0",t.style.display="none");},ze=e=>{let t=document.createElement("div");t.classList.add("modal-error-container"),t.setAttribute("role","dialog"),t.setAttribute("aria-modal","true"),t.setAttribute("aria-label","Oops! Something\u2019s not quite right.");let o=document.createElement("div");o.classList.add("modal-error");let n=document.createElement("button");n.setAttribute("aria-label","Close"),n.classList.add("modal-error-close-button"),n.addEventListener("click",()=>{e.remove();});let r=document.createElementNS("http://www.w3.org/2000/svg","svg");r.setAttribute("xmlns","http://www.w3.org/2000/svg"),r.setAttribute("width","20"),r.setAttribute("height","20"),r.setAttribute("viewBox","0 0 20 20"),r.setAttribute("fill","none");let i=document.createElementNS("http://www.w3.org/2000/svg","path");i.setAttribute("d","M5 5L15 15M15 5L5 15"),i.setAttribute("stroke","black"),i.setAttribute("stroke-width","1.5"),i.setAttribute("stroke-linecap","round"),r.appendChild(i),n.appendChild(r);let a=document.createElementNS("http://www.w3.org/2000/svg","svg");a.setAttribute("xmlns","http://www.w3.org/2000/svg"),a.setAttribute("width","40"),a.setAttribute("height","40"),a.setAttribute("viewBox","0 0 40 40"),a.setAttribute("fill","none"),a.setAttribute("class","error-icon");let s=document.createElementNS("http://www.w3.org/2000/svg","path");s.setAttribute("d","M25 15L15 25M25 25L15 15M35 20C35 28.2843 28.2843 35 20 35C11.7157 35 5 28.2843 5 20C5 11.7157 11.7157 5 20 5C28.2843 5 35 11.7157 35 20Z"),s.setAttribute("stroke","black"),s.setAttribute("stroke-width","3.33333"),s.setAttribute("stroke-linecap","round"),s.setAttribute("stroke-linejoin","round"),a.appendChild(s);let p=document.createElement("h2");p.textContent="Oops! Something\u2019s not quite right.";let d=document.createElement("p");d.textContent="It looks like there was an issue loading the page. Try reloading and we\u2019ll get things back on track.",o.appendChild(n),o.appendChild(a),o.appendChild(p),o.appendChild(d),t.appendChild(o),e.appendChild(t);};var Kt=()=>Math.random().toString(36).substring(2),H=Kt;var j="https://api.onefootprint.com",q=B,z="footprint-js";var w={["auth"]:"auth_v1",["form"]:"form_v1",["render"]:"render_v1",["update_login_methods"]:"update_auth_methods_v1",["verify"]:"verify_v1",["verify-button"]:"verify_button_v1",["components"]:"verify_v1"};var _t=e=>e.replace(/[A-Z]/g,t=>`_${t.toLowerCase()}`),se=e=>t=>{if(!t||typeof t!="object")return t;let o=Object.entries(t).map(([n,r])=>{let i;return Array.isArray(r)?i=r.map(se(e)):Object(r)===r?i=se(e)(r):i=r,[e(n),i]});return Object.fromEntries(o)},Tt=se(_t),W=Tt;var Ut=(e,t,o,n)=>{let r={tenantDomain:n,sdkKind:e,sdkName:z,sdkVersion:q,logLevel:o,logMessage:t,sessionId:U()};try{fetch(`${j}/org/sdk_telemetry`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(W(r))});}catch(i){}},J=Ut;var F=(e,t)=>{let o=`@onefootprint/footprint-js: ${t}`;{let n;try{n=window.location.href;}catch(r){}J(e,t,"info",n);}return o},pe=(e,t)=>{let o=`@onefootprint/footprint-js: ${t}`;{let n;try{n=window.location.href;}catch(r){}J(e,t,"warn",n);}return o},Q=(e,t)=>{let o=`@onefootprint/footprint-js: ${t}`;{let n;try{n=window.location.href;}catch(r){}J(e,t,"error",n);}return o};var We={["auth"]:{["canceled"]:"onCancel",["closed"]:"onClose",["completed"]:"onComplete"},["update_login_methods"]:{["canceled"]:"onCancel",["closed"]:"onClose",["completed"]:"onComplete"},["form"]:{["canceled"]:"onCancel",["closed"]:"onClose",["completed"]:"onComplete"},["verify"]:{["auth"]:"onAuth",["canceled"]:"onCancel",["closed"]:"onClose",["completed"]:"onComplete"},["components"]:{["auth"]:"onAuth",["canceled"]:"onCancel",["closed"]:"onClose",["completed"]:"onComplete",["relayToComponents"]:"onRelayToComponents"},["verify-button"]:{["auth"]:"onAuth",["canceled"]:"onCancel",["clicked"]:"onClick",["closed"]:"onClose",["completed"]:"onComplete"},["render"]:{}},Je={["auth"]:[],["form"]:[],["render"]:[],["update_login_methods"]:[],["verify"]:[],["components"]:[],["verify-button"]:[]};var Qe={["auth"]:["modal","drawer"],["components"]:["modal"],["form"]:["inline","modal","drawer"],["render"]:["inline"],["update_login_methods"]:["modal","drawer"],["verify"]:["modal","drawer"],["verify-button"]:["inline"]},Bt=Object.values(D),Mt=(...e)=>{},b=e=>e!=null&&typeof e=="object"&&!Array.isArray(e),le=e=>b(e)&&Object.keys(e).length>0,Nt=(e,t)=>{if(e==="inline"&&!t)throw new Error(`Inline component requires a containerId. Received ${t}`)},X=(e,t)=>{var r;if(!t)return;let o=(r=Qe[e])!=null?r:[];if(!o.includes(t))throw new Error(`Invalid variant: ${JSON.stringify(t)}. Valid variants for ${e} are ${o.join(", ")}`)},A=e=>{var o;let t=(o=Qe[e])!=null?o:[];if(!t.length)throw new Error(`Invalid kind: ${e}`);return t[0]},Y=e=>{if(!e)throw new Error("Kind is required");let t=Object.values(M);if(!t.includes(e))throw new Error(`Invalid kind: ${e}. Valid kinds are: ${t.join(", ")}`)},Xe=e=>{if(e.kind==="verify-button"){let t=e,{kind:o,appearance:n,variant:r,dialogVariant:i,onClick:a,label:s,containerId:p}=t,d=Ve(t,["kind","appearance","variant","dialogVariant","onClick","label","containerId"]);return C(v({},d),{variant:i,kind:"verify"})}};var Ye=(e,t)=>(Object.prototype.hasOwnProperty.call(e,t)&&typeof e[t]=="function"?e[t]:void 0)||Mt,ce=(e,t,o)=>{var s;let{kind:n}=e,r=(s=We[n])!=null?s:{},i={},a=Xe(e);return Object.entries(r).forEach(([p,d])=>{let l=p;if(!Bt.includes(l))return;let h=Ye(e,d),k=l==="closed"||l==="canceled",m=n==="verify-button"&&l==="clicked";i[l]=P=>{h(P),k&&(t==null||t()),m&&a&&(o==null||o(a));};}),i},R=e=>{let{kind:t,variant:o,containerId:n}=e,r=o||A(t);return Y(t),X(t,o),Nt(r,n),le(e==null?void 0:e.userData)&&console.warn("userData is deprecated and will be removed in the next major version. Please use bootstrapData instead."),C(v({},e),{variant:r})},S=e=>le(e==null?void 0:e.bootstrapData)?{userData:e.bootstrapData}:le(e==null?void 0:e.userData)?{userData:e.userData}:void 0;var $t=e=>e==="auth";var Ht=e=>e==="update_login_methods";var me=e=>e.kind==="components";var ue=e=>typeof e=="string"&&e.length>0,Z=e=>$t(e.kind)&&!!("updateLoginMethods"in e&&e.updateLoginMethods)&&!!e.authToken&&/tok_/.test(e.authToken),jt=e=>Ht(e.kind)&&!!e.authToken&&/tok_/.test(e.authToken),fe=e=>[Z,jt].some(t=>t(e));var qt=3,zt=!1,Wt=e=>fe(e)?"update_auth_methods_v1":w[e.kind],Jt=e=>{var o,n;let{kind:t}=e;if(t==="verify"||t==="components")return C(v({},S(e)),{publicKey:e.publicKey,authToken:e.authToken,options:e.options,l10n:e.l10n,fixtureResult:(o=e.sandboxOutcome)==null?void 0:o.overallOutcome,documentFixtureResult:(n=e.sandboxOutcome)==null?void 0:n.documentOutcome,sandboxId:e.sandboxId,isComponentsSdk:t==="components"});if(t==="update_login_methods")return C(v({},S(e)),{authToken:e.authToken,options:e.options,l10n:e.l10n});if(t==="auth")return Z(e)?C(v({},S(e)),{authToken:e.authToken,updateLoginMethods:e.updateLoginMethods,options:e.options,l10n:e.l10n}):e.authToken&&zt?C(v({},S(e)),{authToken:e.authToken,options:e.options,l10n:e.l10n}):C(v({},S(e)),{publicKey:e.publicKey,options:e.options,l10n:e.l10n});if(t==="form")return {authToken:e.authToken,options:e.options,title:e.title,l10n:e.l10n};if(t==="render")return {authToken:e.authToken,canCopy:e.canCopy,defaultHidden:e.defaultHidden,id:e.id,label:e.label,showHiddenToggle:e.showHiddenToggle,l10n:e.l10n};if(t==="verify-button")return C(v({},S(e)),{publicKey:e.publicKey,options:e.options,authToken:e.authToken,label:e.label,l10n:e.l10n});Q(t,"Invalid kind provided");},Ze=(e,t)=>u(void 0,null,function*(){return fetch(`${j}/org/sdk_args`,{method:"POST",headers:{"x-fp-client-version":`${z} ${q} ${e.kind}`.trim(),"Content-Type":"application/json"},body:JSON.stringify(e)}).then(o=>{if(o.ok)return o.json();if(t>0)return Ze(e,t-1)})}),Qt=e=>u(void 0,null,function*(){F(w[e.kind],"Sending SDK args");let t=Jt(e);if(!t)return;let o=yield Ze({data:W(t),kind:Wt(e)},qt);return o?o.token:void 0}),Ge=Qt;var et=({fontSrc:e,variables:t={},rules:o={},variant:n}={})=>{let r=()=>Object.keys(t).length?encodeURIComponent(JSON.stringify(t)):void 0,i=()=>Object.keys(o).length?encodeURIComponent(JSON.stringify(o)):void 0;return {fontSrc:e,variables:r(),rules:i(),variant:n}},tt=()=>{let e=window.footprintAppearance;return !e||!b(e)?{}:{fontSrc:e.fontSrc,rules:e.rules,variables:e.variables}};var ot=()=>{var e;return typeof window!="undefined"?((e=window.location)==null?void 0:e.href)||window.location.toString():""},Xt=(e,t)=>{let{appearance:o,kind:n,l10n:r,variant:i}=e,{fontSrc:a,rules:s,variables:p}=et(o),d=new URLSearchParams;return p&&d.append("variables",p),s&&d.append("rules",s),a&&d.append("font_src",a),r!=null&&r.language&&d.append("lng",r.language),d.append("variant",i||A(n)),`${d.toString()}#${t}`},Yt=(e,t)=>{let{kind:o}=e,n=Xt(e,t),r=`https://components.onefootprint.com/${o}`,i=`https://components2.onefootprint.com/${o}`;if(o==="update_login_methods"&&(r="https://auth.onefootprint.com/user",i="https://auth2.onefootprint.com/user"),o==="auth"&&(r="https://auth.onefootprint.com",i="https://auth2.onefootprint.com"),(o==="verify"||o==="verify-button"||o==="components")&&(r="https://id.onefootprint.com",i="https://id2.onefootprint.com"),!ue(r))throw new Error(`${o}_URL environment variable is not defined.`);return r+=`?${n}`.trim(),i+=`?${n}`.trim(),{url:r,fallbackUrl:i}},nt=Yt;var Zt=e=>{let t=null,o=!1,n,r,{formSaveComplete:i,formSaved:a,formSaveFailed:s,started:p}=N,d=R(e),{variant:l,containerId:h}=d,k=l==="modal"||l==="drawer",m=H(),P=(c,f)=>{var E;let g=Q(w[d.kind],c);(E=d.onError)==null||E.call(d,g),o&&f&&(n(),o=!1);},dt=()=>{if(!t){P("Footprint should be initialized in order to register callback props");return}let c=ce(d,n,r);Object.entries(c).forEach(([f,g])=>{t==null||t.on(f,g),t==null||t.on(`${m}:${f}`,g);});},pt=()=>{if(k)return Ne(m);if(!h){P("containerId is required when rendering inline");return}let c=document.getElementById(h);if(!c){P(`Could not find container with id ${h} while rendering footprint`);return}return $e(m,c)},G=(c,f)=>{if(!f){ae(m),t==null||t.frame.classList.remove("fp-hide"),t==null||t.frame.classList.remove(`footprint-${l}-loading`),t==null||t.frame.classList.add(`footprint-${l}-loaded`);return}if(k){let g=He(c,m);ie(g,m);}else ie(c,m);},he=()=>{var f;if(!t){P("Footprint should be initialized in order to set up refs");return}if(d.kind!=="form"||!d.getRef)return;let c={save:()=>(t||P("Footprint should be initialized to call ref methods"),new Promise((g,E)=>{t==null||t.on(i,()=>{g();}),t==null||t.on(s,Pe=>{E(Pe);}),t==null||t.on(`${m}:${i}`,g),t==null||t.on(`${m}:${s}`,E),t==null||t.call(a);}))};(f=d.getRef)==null||f.call(d,c);},ve=(c,f)=>u(void 0,null,function*(){try{return t=yield new Fe({classListArray:[`footprint-${l}`,`footprint-${l}-loading`,"fp-hide"],container:c,name:`footprint-iframe-${m}`,url:f,allow:"otp-credentials; publickey-credentials-get *; camera *; clipboard-write;",model:{authToken:d.authToken,initId:m,sdkUrl:ot(),sdkVersion:B||""}}),{success:!0,parentApi:t}}catch(g){return P(`Initializing iframe with ${new URL(f).host} failed with error ${g}`),{success:!1}}}),lt=(E,Pe)=>u(void 0,[E,Pe],function*(c,{url:f,fallbackUrl:g}){F(w[d.kind],`Initializing iframe with ${new URL(f).host}`);let ke=yield ve(c,f);if(ke.success)return ke.parentApi;F(w[d.kind],`Initializing iframe with ${new URL(g).host} as fallback`);let Ce=yield ve(c,g);if(!Ce.success)throw new Error("Failed to initialize iframe");return Ce.parentApi});return {relayFromComponents:()=>{t&&(t.call("relayFromComponents"),je(m));},props:d,isRendered:o,render:()=>u(void 0,null,function*(){if(o){pe(w[d.kind],"Footprint component is already rendered");return}o=!0;let c=pt();if(!c){pe(w[d.kind],"Unable to create container for Footprint component");return}c.hasChildNodes()&&(c.innerHTML=""),G(c,!0);let f=yield Ge(d);if(!f){P("Unable to get SDK args token.",!0),G(c,!1);return}let{url:g,fallbackUrl:E}=nt(d,f||"");try{yield lt(c,{url:L(g),fallbackUrl:L(E)}),dt();}catch(Pe){ze(c),o=!1;}G(c,!1),t==null||t.on(p,()=>he()),t==null||t.on(`${m}:${p}`,he),d.kind==="components"&&(t==null||t.on(`${m}:${"relayToComponents"}`,()=>{qe(m);}));}),destroy:()=>u(void 0,null,function*(){o&&(o=!1,yield Me(m),t&&(t.destroy(),t=null));}),registerOnDestroy:c=>{!c||typeof c!="function"||(n=c);},registerOnRenderSecondary:c=>{!c||typeof c!="function"||(r=c);}}},ye=Zt;var V=e=>{let t=R(e);return JSON.stringify(t)},Gt=()=>{let e=Object.create(null);return {getOrCreate:i=>{let a=V(i.props),s=Object.values(e).find(p=>V(p.iframe.props)===a);return s?s.iframe:(e[a]={iframe:i,secondaryIframes:{}},i)},getOrCreateSecondary:(i,a)=>{let s=V(i.props),p=V(a.props);if(!e[s])throw new Error("iframe manager: primary iframe does not exist while adding secondary");let{secondaryIframes:d}=e[s],l=Object.values(d).find(h=>V(h.props)===p);return l||(d[p]=a,a)},remove:i=>{let a=V(i.props),s=e[a];s&&(Object.keys(s.secondaryIframes).forEach(p=>{s.secondaryIframes[p].destroy();}),delete e[a]);},removeSecondary:(i,a)=>{let s=V(i.props),p=V(a.props);if(!e[s])throw new Error("iframe manager: primary iframe does not exist while removing secondary");let{secondaryIframes:d}=e[s],l=d[p];l&&(l.destroy(),delete d[p]);}}},rt=Gt;var eo=()=>{let e=rt();return {init:o=>{let n=ye(o),r=()=>u(void 0,null,function*(){e.remove(n),yield n.destroy();}),i=d=>u(void 0,null,function*(){e.removeSecondary(n,d),yield d.destroy();}),a=d=>u(void 0,null,function*(){let l=ye(d);l=e.getOrCreateSecondary(n,l),l.registerOnDestroy(()=>{i(l);}),l.render();}),s=()=>u(void 0,null,function*(){n=e.getOrCreate(n),n.registerOnDestroy(r),n.registerOnRenderSecondary(a),yield n.render();}),p={};return me(o)&&(p={relayFromComponents:()=>{n.relayFromComponents();}}),v({render:s,destroy:r},p)}}},to=eo(),ge=to;var oo=e=>{window.setTimeout(e,0);},no=e=>{if(typeof window=="undefined")return;let t=r=>{var s;let i=(s=window.footprintCallbacks)!=null?s:{};if(!b(i))throw Error("`window.footprintCallbacks` must be a valid mapping from callback names to functions.");return Je[r].forEach(p=>{if(!i[p])throw Error(`Callback '${p}' must be defined in window.footprintCallbacks`)}),i},o=r=>{var m;let i=r.getAttribute("data-kind");Y(i);let a=(m=r.getAttribute("data-variant"))!=null?m:A(i);X(i,a);let s=tt(),p=t(i),d=r.getAttribute("data-props")||"",l;try{l=JSON.parse(d);}catch(P){throw Error("Could not parse `data-props` for footprint.")}if(!b(l))throw Error("`data-props` on the footprint element has to be a valid JSON object stringified.");let h=H();r.setAttribute("id",h),e.init(v(v({kind:i,variant:a,appearance:s,containerId:r.id},p),l)).render();},n=()=>{let r=document.querySelectorAll("[data-footprint]");r.length&&r.forEach(i=>{o(i);});};document.addEventListener("DOMContentLoaded",()=>oo(n));},at=no;var ro="http://test",it=e=>u(void 0,null,function*(){let t=yield fetch(`${ro}/hosted/identify/lite`,{method:"POST",body:JSON.stringify(e)});if(!t.ok)throw Error(t.statusText);return (yield t.json()).user_found}),ao=e=>u(void 0,null,function*(){if(!b(e))throw new Error("User data must be passed in order to identify an user");let t=e["id.email"],o=e["id.phone_number"];return t&&(yield it({email:t}))?!0:o?yield it({phone_number:o}):!1}),st=ao;var rr=ge;at(ge);/*! Bundled license information:
@onefootprint/postmate/build/postmate.es.js:

@@ -16,7 +20,7 @@ (**

exports.FootprintComponentKind = R;
exports.FootprintPrivateEvent = K;
exports.FootprintPublicEvent = x;
exports.default = un;
exports.identifyFootprintUser = He;
exports.FootprintComponentKind = M;
exports.FootprintPrivateEvent = N;
exports.FootprintPublicEvent = D;
exports.default = rr;
exports.identifyFootprintUser = st;

@@ -27,2 +31,2 @@ Object.defineProperty(exports, '__esModule', { value: true });

})({});
})({}, ft);

@@ -5,3 +5,3 @@ {

"type": "module",
"version": "3.14.0",
"version": "3.14.1",
"main": "./dist/footprint-js.cjs",

@@ -8,0 +8,0 @@ "module": "./dist/footprint-js.js",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc