@neofaceid/web-sdk 1.4.0 → 1.6.0

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.
@@ -1,4 +1,4 @@
1
- !function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("react"),require("react-dom"),require("face-api.js")):"function"==typeof define&&define.amd?define(["exports","react","react-dom","face-api.js"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).NeoFaceIdSdk={},e.React,e.ReactDOM,e.faceapi)}(this,(function(e,n,t,o){"use strict";var r=Object.defineProperty,a=(e,n,t)=>(((e,n,t)=>{n in e?r(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t})(e,"symbol"!=typeof n?n+"":n,t),t);function i(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e)for(const t in e)if("default"!==t){const o=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,o.get?o:{enumerable:!0,get:()=>e[t]})}return n.default=e,Object.freeze(n)}const s=i(o);var c,l=t;if("production"===process.env.NODE_ENV)c=l.createRoot,l.hydrateRoot;else{var d=l.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;c=function(e,n){d.usingClientEntryPoint=!0;try{return l.createRoot(e,n)}finally{d.usingClientEntryPoint=!1}}}var u,p={exports:{}},f={};var h,m={};
1
+ var __defProp=Object.defineProperty,__defNormalProp=(e,n,t)=>n in e?__defProp(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,__publicField=(e,n,t)=>(__defNormalProp(e,"symbol"!=typeof n?n+"":n,t),t);!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("react"),require("react-dom"),require("face-api.js")):"function"==typeof define&&define.amd?define(["exports","react","react-dom","face-api.js"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).NeoFaceIdSdk={},e.React,e.ReactDOM,e.faceapi)}(this,(function(e,n,t,o){var a;function r(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e)for(const t in e)if("default"!==t){const o=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,o.get?o:{enumerable:!0,get:()=>e[t]})}return n.default=e,Object.freeze(n)}const i=r(o);var s,c=t;if("production"===process.env.NODE_ENV)s=c.createRoot,c.hydrateRoot;else{var l=c.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;s=function(e,n){l.usingClientEntryPoint=!0;try{return c.createRoot(e,n)}finally{l.usingClientEntryPoint=!1}}}var d,u={exports:{}},p={};var f,h={};
2
2
  /**
3
3
  * @license React
4
4
  * react-jsx-runtime.development.js
@@ -7,5 +7,5 @@
7
7
  *
8
8
  * This source code is licensed under the MIT license found in the
9
9
  * LICENSE file in the root directory of this source tree.
10
- */"production"===process.env.NODE_ENV?p.exports=function(){if(u)return f;u=1;var e=n,t=Symbol.for("react.element"),o=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,a=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function s(e,n,o){var s,c={},l=null,d=null;for(s in void 0!==o&&(l=""+o),void 0!==n.key&&(l=""+n.key),void 0!==n.ref&&(d=n.ref),n)r.call(n,s)&&!i.hasOwnProperty(s)&&(c[s]=n[s]);if(e&&e.defaultProps)for(s in n=e.defaultProps)void 0===c[s]&&(c[s]=n[s]);return{$$typeof:t,type:e,key:l,ref:d,props:c,_owner:a.current}}return f.Fragment=o,f.jsx=s,f.jsxs=s,f}():p.exports=(h||(h=1,"production"!==process.env.NODE_ENV&&function(){var e,t=n,o=Symbol.for("react.element"),r=Symbol.for("react.portal"),a=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),c=Symbol.for("react.provider"),l=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),p=Symbol.for("react.suspense_list"),f=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),g=Symbol.for("react.offscreen"),b=Symbol.iterator,w=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function y(e){for(var n=arguments.length,t=new Array(n>1?n-1:0),o=1;o<n;o++)t[o-1]=arguments[o];!function(e,n,t){var o=w.ReactDebugCurrentFrame.getStackAddendum();""!==o&&(n+="%s",t=t.concat([o]));var r=t.map((function(e){return String(e)}));r.unshift("Warning: "+n),Function.prototype.apply.call(console[e],console,r)}("error",e,t)}function x(e){return e.displayName||"Context"}function v(e){if(null==e)return null;if("number"==typeof e.tag&&y("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),"function"==typeof e)return e.displayName||e.name||null;if("string"==typeof e)return e;switch(e){case a:return"Fragment";case r:return"Portal";case s:return"Profiler";case i:return"StrictMode";case u:return"Suspense";case p:return"SuspenseList"}if("object"==typeof e)switch(e.$$typeof){case l:return x(e)+".Consumer";case c:return x(e._context)+".Provider";case d:return function(e,n,t){var o=e.displayName;if(o)return o;var r=n.displayName||n.name||"";return""!==r?t+"("+r+")":t}(e,e.render,"ForwardRef");case f:var n=e.displayName||null;return null!==n?n:v(e.type)||"Memo";case h:var t=e,o=t._payload,m=t._init;try{return v(m(o))}catch(g){return null}}return null}e=Symbol.for("react.module.reference");var E,k,R,T,O,_,N,S=Object.assign,I=0;function j(){}j.__reactDisabledLog=!0;var C,A=w.ReactCurrentDispatcher;function P(e,n,t){if(void 0===C)try{throw Error()}catch(r){var o=r.stack.trim().match(/\n( *(at )?)/);C=o&&o[1]||""}return"\n"+C+e}var D,F=!1,L="function"==typeof WeakMap?WeakMap:Map;function W(e,n){if(!e||F)return"";var t,o=D.get(e);if(void 0!==o)return o;F=!0;var r,a=Error.prepareStackTrace;Error.prepareStackTrace=void 0,r=A.current,A.current=null,function(){if(0===I){E=console.log,k=console.info,R=console.warn,T=console.error,O=console.group,_=console.groupCollapsed,N=console.groupEnd;var e={configurable:!0,enumerable:!0,value:j,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}I++}();try{if(n){var i=function(){throw Error()};if(Object.defineProperty(i.prototype,"props",{set:function(){throw Error()}}),"object"==typeof Reflect&&Reflect.construct){try{Reflect.construct(i,[])}catch(h){t=h}Reflect.construct(e,[],i)}else{try{i.call()}catch(h){t=h}e.call(i.prototype)}}else{try{throw Error()}catch(h){t=h}e()}}catch(m){if(m&&t&&"string"==typeof m.stack){for(var s=m.stack.split("\n"),c=t.stack.split("\n"),l=s.length-1,d=c.length-1;l>=1&&d>=0&&s[l]!==c[d];)d--;for(;l>=1&&d>=0;l--,d--)if(s[l]!==c[d]){if(1!==l||1!==d)do{if(l--,--d<0||s[l]!==c[d]){var u="\n"+s[l].replace(" at new "," at ");return e.displayName&&u.includes("<anonymous>")&&(u=u.replace("<anonymous>",e.displayName)),"function"==typeof e&&D.set(e,u),u}}while(l>=1&&d>=0);break}}}finally{F=!1,A.current=r,function(){if(0==--I){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:S({},e,{value:E}),info:S({},e,{value:k}),warn:S({},e,{value:R}),error:S({},e,{value:T}),group:S({},e,{value:O}),groupCollapsed:S({},e,{value:_}),groupEnd:S({},e,{value:N})})}I<0&&y("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}(),Error.prepareStackTrace=a}var p=e?e.displayName||e.name:"",f=p?P(p):"";return"function"==typeof e&&D.set(e,f),f}function U(e,n,t){if(null==e)return"";if("function"==typeof e)return W(e,!(!(o=e.prototype)||!o.isReactComponent));var o;if("string"==typeof e)return P(e);switch(e){case u:return P("Suspense");case p:return P("SuspenseList")}if("object"==typeof e)switch(e.$$typeof){case d:return W(e.render,!1);case f:return U(e.type,n,t);case h:var r=e,a=r._payload,i=r._init;try{return U(i(a),n,t)}catch(s){}}return""}D=new L;var z=Object.prototype.hasOwnProperty,K={},q=w.ReactDebugCurrentFrame;function M(e){if(e){var n=e._owner,t=U(e.type,e._source,n?n.type:null);q.setExtraStackFrame(t)}else q.setExtraStackFrame(null)}var $=Array.isArray;function B(e){return $(e)}function V(e){return""+e}function X(e){if(function(e){try{return V(e),!1}catch(n){return!0}}(e))return y("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",function(e){return"function"==typeof Symbol&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object"}(e)),V(e)}var Y,G,H,J=w.ReactCurrentOwner,Z={key:!0,ref:!0,__self:!0,__source:!0};function Q(e,n,t,r,a){var i,s={},c=null,l=null;for(i in void 0!==t&&(X(t),c=""+t),function(e){if(z.call(e,"key")){var n=Object.getOwnPropertyDescriptor(e,"key").get;if(n&&n.isReactWarning)return!1}return void 0!==e.key}(n)&&(X(n.key),c=""+n.key),function(e){if(z.call(e,"ref")){var n=Object.getOwnPropertyDescriptor(e,"ref").get;if(n&&n.isReactWarning)return!1}return void 0!==e.ref}(n)&&(l=n.ref,function(e,n){if("string"==typeof e.ref&&J.current&&n&&J.current.stateNode!==n){var t=v(J.current.type);H[t]||(y('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',v(J.current.type),e.ref),H[t]=!0)}}(n,a)),n)z.call(n,i)&&!Z.hasOwnProperty(i)&&(s[i]=n[i]);if(e&&e.defaultProps){var d=e.defaultProps;for(i in d)void 0===s[i]&&(s[i]=d[i])}if(c||l){var u="function"==typeof e?e.displayName||e.name||"Unknown":e;c&&function(e,n){var t=function(){Y||(Y=!0,y("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",n))};t.isReactWarning=!0,Object.defineProperty(e,"key",{get:t,configurable:!0})}(s,u),l&&function(e,n){var t=function(){G||(G=!0,y("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",n))};t.isReactWarning=!0,Object.defineProperty(e,"ref",{get:t,configurable:!0})}(s,u)}return function(e,n,t,r,a,i,s){var c={$$typeof:o,type:e,key:n,ref:t,props:s,_owner:i,_store:{}};return Object.defineProperty(c._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(c,"_self",{configurable:!1,enumerable:!1,writable:!1,value:r}),Object.defineProperty(c,"_source",{configurable:!1,enumerable:!1,writable:!1,value:a}),Object.freeze&&(Object.freeze(c.props),Object.freeze(c)),c}(e,c,l,a,r,J.current,s)}H={};var ee,ne=w.ReactCurrentOwner,te=w.ReactDebugCurrentFrame;function oe(e){if(e){var n=e._owner,t=U(e.type,e._source,n?n.type:null);te.setExtraStackFrame(t)}else te.setExtraStackFrame(null)}function re(e){return"object"==typeof e&&null!==e&&e.$$typeof===o}function ae(){if(ne.current){var e=v(ne.current.type);if(e)return"\n\nCheck the render method of `"+e+"`."}return""}ee=!1;var ie={};function se(e,n){if(e._store&&!e._store.validated&&null==e.key){e._store.validated=!0;var t=function(e){var n=ae();if(!n){var t="string"==typeof e?e:e.displayName||e.name;t&&(n="\n\nCheck the top-level render call using <"+t+">.")}return n}(n);if(!ie[t]){ie[t]=!0;var o="";e&&e._owner&&e._owner!==ne.current&&(o=" It was passed a child from "+v(e._owner.type)+"."),oe(e),y('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',t,o),oe(null)}}}function ce(e,n){if("object"==typeof e)if(B(e))for(var t=0;t<e.length;t++){var o=e[t];re(o)&&se(o,n)}else if(re(e))e._store&&(e._store.validated=!0);else if(e){var r=function(e){if(null===e||"object"!=typeof e)return null;var n=b&&e[b]||e["@@iterator"];return"function"==typeof n?n:null}(e);if("function"==typeof r&&r!==e.entries)for(var a,i=r.call(e);!(a=i.next()).done;)re(a.value)&&se(a.value,n)}}function le(e){var n,t=e.type;if(null!=t&&"string"!=typeof t){if("function"==typeof t)n=t.propTypes;else{if("object"!=typeof t||t.$$typeof!==d&&t.$$typeof!==f)return;n=t.propTypes}if(n){var o=v(t);!function(e,n,t,o,r){var a=Function.call.bind(z);for(var i in e)if(a(e,i)){var s=void 0;try{if("function"!=typeof e[i]){var c=Error((o||"React class")+": "+t+" type `"+i+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[i]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw c.name="Invariant Violation",c}s=e[i](n,i,o,t,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(l){s=l}!s||s instanceof Error||(M(r),y("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",o||"React class",t,i,typeof s),M(null)),s instanceof Error&&!(s.message in K)&&(K[s.message]=!0,M(r),y("Failed %s type: %s",t,s.message),M(null))}}(n,e.props,"prop",o,e)}else void 0===t.PropTypes||ee||(ee=!0,y("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",v(t)||"Unknown"));"function"!=typeof t.getDefaultProps||t.getDefaultProps.isReactClassApproved||y("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}var de={};function ue(n,t,r,m,b,w){var x=function(n){return"string"==typeof n||"function"==typeof n||n===a||n===s||n===i||n===u||n===p||n===g||"object"==typeof n&&null!==n&&(n.$$typeof===h||n.$$typeof===f||n.$$typeof===c||n.$$typeof===l||n.$$typeof===d||n.$$typeof===e||void 0!==n.getModuleId)}(n);if(!x){var E="";(void 0===n||"object"==typeof n&&null!==n&&0===Object.keys(n).length)&&(E+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var k,R=function(e){return void 0!==e?"\n\nCheck your code at "+e.fileName.replace(/^.*[\\\/]/,"")+":"+e.lineNumber+".":""}(b);E+=R||ae(),null===n?k="null":B(n)?k="array":void 0!==n&&n.$$typeof===o?(k="<"+(v(n.type)||"Unknown")+" />",E=" Did you accidentally export a JSX literal instead of a component?"):k=typeof n,y("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",k,E)}var T=Q(n,t,r,b,w);if(null==T)return T;if(x){var O=t.children;if(void 0!==O)if(m)if(B(O)){for(var _=0;_<O.length;_++)ce(O[_],n);Object.freeze&&Object.freeze(O)}else y("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else ce(O,n)}if(z.call(t,"key")){var N=v(n),S=Object.keys(t).filter((function(e){return"key"!==e})),I=S.length>0?"{key: someKey, "+S.join(": ..., ")+": ...}":"{key: someKey}";de[N+I]||(y('A props object containing a "key" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />',I,N,S.length>0?"{"+S.join(": ..., ")+": ...}":"{}",N),de[N+I]=!0)}return n===a?function(e){for(var n=Object.keys(e.props),t=0;t<n.length;t++){var o=n[t];if("children"!==o&&"key"!==o){oe(e),y("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",o),oe(null);break}}null!==e.ref&&(oe(e),y("Invalid attribute `ref` supplied to `React.Fragment`."),oe(null))}(T):le(T),T}var pe=function(e,n,t){return ue(e,n,t,!1)},fe=function(e,n,t){return ue(e,n,t,!0)};m.Fragment=a,m.jsx=pe,m.jsxs=fe}()),m);var g=p.exports;class b extends Error{constructor(e){super(e),this.name="CameraPermissionDenied"}}class w{constructor(e){a(this,"stream"),this.stream=e}getStream(){return this.stream}stop(){this.stream.getTracks().forEach((e=>e.stop()))}}const y=()=>{const e=n.useRef(null),[t,o]=n.useState(!1),r=n.useRef(!1);return{startCamera:n.useCallback((async n=>{const t=e.current;if(t)return t.getStream();if(r.current){await new Promise((e=>setTimeout(e,100)));const n=e.current;if(n)return n.getStream()}r.current=!0;try{const t=n||(()=>{const e=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);return{video:{facingMode:"user",width:{ideal:e?640:1280},height:{ideal:e?480:720},aspectRatio:{ideal:1.777777778}},audio:!1}})(),a=await navigator.mediaDevices.getUserMedia(t),i=new w(a);return e.current=i,o(!0),r.current=!1,a}catch(a){if(r.current=!1,a instanceof Error){if("NotAllowedError"===a.name||"PermissionDeniedError"===a.name)throw new b("Permissão para acessar a câmera foi negada pelo usuário");if("NotFoundError"===a.name||"DevicesNotFoundError"===a.name)throw new Error("Nenhuma câmera foi encontrada no dispositivo");if("NotReadableError"===a.name||"TrackStartError"===a.name)throw new Error("A câmera já está sendo usada por outro aplicativo");if("OverconstrainedError"===a.name||"ConstraintNotSatisfiedError"===a.name)throw new Error("As configurações solicitadas não são suportadas pela câmera")}throw new Error(`Erro ao inicializar câmera: ${a instanceof Error?a.message:String(a)}`)}}),[]),stopCamera:n.useCallback((n=>{const t=e.current;t&&t.getStream()===n&&(t.stop(),e.current=null,o(!1),r.current=!1)}),[]),cleanup:n.useCallback((()=>{e.current&&(e.current.stop(),e.current=null,o(!1),r.current=!1)}),[]),isActive:t}};var x=(e=>(e.NETWORK="NetworkError",e.NETWORK_ERROR="NetworkError",e.INVALID_TOKEN="InvalidTokenError",e.RECOGNITION_FAILED="RecognitionFailedError",e.LOGIN_FAILED="LoginFailedError",e.VALIDATION_ERROR="ValidationError",e.API_ERROR="ApiError",e.PERSON_NOT_FOUND="PersonNotFoundError",e.INITIALIZATION_ERROR="InitializationError",e.CAMERA_ERROR="CameraError",e.CAPTURE_ERROR="CaptureError",e.NOT_FOUND="NotFoundError",e.UNKNOWN="UnknownError",e))(x||{});class v extends Error{constructor(e,n){super(e),a(this,"type"),this.name=n,this.type=n}}const E="https://core.neofaceid.com.br",k=()=>{if(!window.isSecureContext)throw new v("Secure context (HTTPS) is required for this operation",x.NETWORK)},R=()=>{const e=new AbortController,n=setTimeout((()=>e.abort()),1e4);return e.signal.addEventListener("abort",(()=>clearTimeout(n))),e},T=async e=>new Promise(((n,t)=>{const o=new Image;o.onload=()=>{const e=document.createElement("canvas");e.width=o.width,e.height=o.height;const r=e.getContext("2d");r?(r.drawImage(o,0,0),e.toBlob((e=>{e?n(e):t(new Error("Failed to compress image"))}),"image/jpeg",.7)):t(new Error("Failed to get canvas context"))},o.onerror=()=>{t(new Error("Failed to load image"))},o.src=URL.createObjectURL(e)})),O=async e=>{k();const n=R();try{return(await fetch(`${E}/api/v1/external/auth/validate-token/`,{method:"POST",headers:{"Content-Type":"application/json","X-App-Token":e},body:JSON.stringify({}),signal:n.signal})).ok}catch(t){if(t instanceof Error){if("AbortError"===t.name)throw new v("Request timed out",x.NETWORK_ERROR);throw new v(t.message,x.NETWORK_ERROR)}throw new v("Unknown error occurred",x.NETWORK_ERROR)}},_=async(e,n,t,o)=>{k();const r=R(),a=await T(t),i=await T(o);try{const t=new FormData;t.append("face_image",a,"face.jpg"),t.append("document_image",i,"document.jpg");const o=await fetch(`${E}/api/v1/onboardings/${encodeURIComponent(n)}/complete`,{method:"POST",headers:{"X-App-Token":e},body:t,signal:r.signal}),s=await o.json();if(!o.ok){if(401===o.status||403===o.status)throw new v("Token de aplicação inválido ou expirado",x.INVALID_TOKEN);if(404===o.status)throw new v("Link de onboarding não encontrado",x.NOT_FOUND);throw new v((null==s?void 0:s.error)||(null==s?void 0:s.message)||"Falha ao concluir onboarding",x.NETWORK)}return{success:!!s.success,message:s.message||"Onboarding concluído",person_id:s.person_id,identity_data_id:s.identity_data_id,confidence_score:s.confidence_score,processing_time:s.processing_time}}catch(s){if(s instanceof Error){if("AbortError"===s.name)throw new v("Tempo de requisição excedido",x.NETWORK);if(s instanceof v)throw s;throw new v(s.message,x.NETWORK)}throw new v("Erro desconhecido",x.NETWORK_ERROR)}},N=async(e,n)=>{k();const t=R(),o=await T(e);try{const e=new FormData;e.append("face_frames",o);const r=await fetch(`${E}/api/v1/external/recognition/face/`,{method:"POST",headers:{"X-App-Token":n},body:e,signal:t.signal});if(!r.ok){if(401===r.status||403===r.status)throw new v("Invalid or expired application token",x.INVALID_TOKEN);throw new v(`Server returned status ${r.status}`,x.NETWORK)}const a=await r.json();if(!a.success)throw new v(a.message||"Recognition failed",x.RECOGNITION_FAILED);return{accessToken:a.accessToken,payload:a.payload}}catch(r){if(r instanceof Error){if("AbortError"===r.name)throw new v("Request timed out",x.NETWORK);if(r instanceof v)throw r;throw new v(r.message,x.NETWORK)}throw new v("Unknown error occurred",x.NETWORK_ERROR)}},S=async(e,n)=>{var t,o,r,a,i;k();const s=R(),c=await T(e);try{const e=new FormData;e.append("face_frames",c);const l=await fetch(`${E}/api/v1/external/auth/login/`,{method:"POST",headers:{"X-App-Token":n},body:e,signal:s.signal});if(!l.ok){if(401===l.status||403===l.status)throw new v("Invalid or expired application token",x.INVALID_TOKEN);throw new v(`Server returned status ${l.status}`,x.NETWORK)}const d=await l.json();if(!d.success)throw new v(d.message||"Login failed",x.LOGIN_FAILED);return{success:!0,accessToken:d.accessToken,alias:d.alias,user:{id:(null==(t=d.user)?void 0:t.id)||"",email:(null==(o=d.user)?void 0:o.email)||"",role:(null==(r=d.user)?void 0:r.role)||"",validated:(null==(a=d.user)?void 0:a.validated)||!1,active:(null==(i=d.user)?void 0:i.active)||!1},person:d.person?{name:d.person.name||"",birth_date:d.person.birth_date||""}:void 0,confidence_score:d.confidence_score,recognition_id:d.recognition_id}}catch(l){if(l instanceof Error){if("AbortError"===l.name)throw new v("Request timed out",x.NETWORK);if(l instanceof v)throw l;throw new v(l.message,x.NETWORK)}throw new v("Unknown error occurred",x.NETWORK_ERROR)}},I=async(e,n,t)=>{if(k(),!n||0===n.length)throw new v("At least one face photo is required for biometric registration",x.VALIDATION_ERROR);if(n.length>5)throw new v("Maximum of 5 face photos allowed",x.VALIDATION_ERROR);const o=R();try{const a=await Promise.all(n.map((async e=>{const n=await T(e);return new Promise(((e,t)=>{const o=new FileReader;o.onload=()=>{const n=o.result;e(n)},o.onerror=t,o.readAsDataURL(n)}))}))),i=await fetch(`${E}/api/v1/signup/donor/`,{method:"POST",headers:{"Content-Type":"application/json","X-App-Token":t},body:JSON.stringify({name:e.name,birth_date:e.birth_date,cpf:e.cpf,email:e.email,password:e.password,password_confirm:e.password,face_photos:a}),signal:o.signal});if(!i.ok){if(401===i.status||403===i.status)throw new v("Invalid or expired application token",x.INVALID_TOKEN);try{const e=await i.json();if("fraud_detected"===e.error)throw new v("Fraud detected in biometric images. Registration blocked.",x.VALIDATION_ERROR);if("user_exists"===e.error)throw new v("User with this email already exists",x.VALIDATION_ERROR);if("person_exists"===e.error)throw new v("Person with this CPF already exists",x.VALIDATION_ERROR);throw new v(e.message||`Server returned status ${i.status}`,x.NETWORK)}catch(r){throw new v(`Server returned status ${i.status}`,x.NETWORK)}}const s=await i.json();return{success:s.success,message:s.message,person_id:s.person_id,user_id:s.user_id,person_validated:s.person_validated,face_processing:s.face_processing,onboarding_link:s.onboarding_link}}catch(a){if(a instanceof Error){if("AbortError"===a.name)throw new v("Request timed out",x.NETWORK);if(a instanceof v)throw a;throw new v(a.message,x.NETWORK)}throw new v("Unknown error occurred",x.NETWORK_ERROR)}},j=(e,n)=>{switch(n.type){case"PERMISSION_GRANTED":case"RESET":return{status:"ready"};case"PERMISSION_DENIED":return{status:"error",message:"Permissão para acessar a câmera foi negada"};case"START_CAPTURE":return{status:"capturing"};case"UPLOAD_START":return{status:"uploading"};case"UPLOAD_SUCCESS":return{status:"success"};case"UPLOAD_ERROR":case"SET_ERROR":return{status:"error",message:n.message};default:return e}},C={overlay:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.8)",display:"flex",justifyContent:"center",alignItems:"center",zIndex:1e3},modal:{backgroundColor:"#000",borderRadius:"12px",overflow:"hidden",position:"relative",width:"60%",maxWidth:"600px",maxHeight:"80vh"},video:{width:"100%",height:"auto",display:"block"},canvas:{display:"none"},guide:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:"200px",height:"200px",border:"2px solid rgba(255, 255, 255, 0.5)",borderRadius:"50%",pointerEvents:"none"},controls:{position:"absolute",bottom:"20px",left:0,right:0,display:"flex",justifyContent:"center",gap:"10px"},button:{padding:"12px 24px",borderRadius:"24px",border:"none",backgroundColor:"#007AFF",color:"white",fontSize:"16px",fontWeight:"bold",cursor:"pointer"},message:{position:"absolute",top:"20px",left:0,right:0,textAlign:"center",color:"white",fontSize:"18px",fontWeight:"bold"},spinner:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:"40px",height:"40px",border:"4px solid rgba(255, 255, 255, 0.3)",borderRadius:"50%",borderTopColor:"white",animation:"spin 1s linear infinite"},closeButton:{position:"absolute",top:"20px",right:"20px",backgroundColor:"transparent",border:"none",color:"white",fontSize:"24px",cursor:"pointer"}};function A({accessToken:e,onClose:t,onSuccess:o}){const r=n.useRef(null),a=n.useRef(null),i=n.useRef(null),c=n.useRef(null),l=n.useRef(null),[d,u]=n.useReducer(j,{status:"requestingPermission"}),[p,f]=n.useState(!1),[h,m]=n.useState(0),{startCamera:b,stopCamera:w}=y(),x=()=>{if(!r.current)return;const e=async()=>{if(r.current&&"ready"===d.status){try{const e=await s.detectAllFaces(r.current,new s.TinyFaceDetectorOptions),n=1===e.length,t=n&&(e=>{if(!r.current)return!1;const{box:n}=e,{videoWidth:t,videoHeight:o}=r.current,a=t/2,i=o/2,s=.4*t,c=.4*o;return n.x+n.width/2>a-s/2&&n.x+n.width/2<a+s/2&&n.y+n.height/2>i-c/2&&n.y+n.height/2<i+c/2})(e[0]);f(n&&t),n&&t&&0===h&&(l.current=window.setTimeout((()=>{"ready"===d.status&&(m((e=>e+1)),u({type:"START_CAPTURE"}))}),3e3))}catch(n){}c.current=window.setTimeout(e,100)}};e()};n.useEffect((()=>((async()=>{try{await Promise.all([s.nets.tinyFaceDetector.loadFromUri("./models"),s.nets.faceLandmark68Net.loadFromUri("./models")])}catch(e){}})(),()=>{c.current&&window.clearTimeout(c.current),l.current&&window.clearInterval(l.current)})),[]),n.useEffect((()=>((async()=>{try{const e=await b();i.current=e,r.current&&(r.current.srcObject=e),u({type:"PERMISSION_GRANTED"}),x()}catch(e){u({type:"PERMISSION_DENIED"})}})(),()=>{i.current&&w(i.current)})),[b,w]);const v=async()=>{if(a.current&&r.current)try{u({type:"START_CAPTURE"});const i=a.current.getContext("2d");if(!i)return void u({type:"SET_ERROR",message:"Failed to get canvas context"});a.current.width=r.current.videoWidth,a.current.height=r.current.videoHeight,i.drawImage(r.current,0,0,a.current.width,a.current.height);const s=await new Promise(((e,n)=>{var t;null==(t=a.current)||t.toBlob((t=>{t?e(t):n(new Error("Failed to convert canvas to blob"))}),"image/jpeg",.95)}));try{const n=await N(s,e);o({success:!0,data:{faceId:n.payload.documentId,confidence:1}}),u({type:"UPLOAD_SUCCESS"}),setTimeout(t,1500)}catch(n){u({type:"SET_ERROR",message:"Face recognition failed"})}}catch(n){u({type:"SET_ERROR",message:"Failed to capture image"})}};return g.jsxs("div",{style:C.overlay,children:[g.jsx("style",{children:"\n @keyframes spin {\n 0% { transform: translate(-50%, -50%) rotate(0deg); }\n 100% { transform: translate(-50%, -50%) rotate(360deg); }\n }\n"}),g.jsx("style",{children:"\n @media (max-width: 768px) {\n .modal {\n width: 100%;\n height: 100%;\n max-height: 100vh;\n border-radius: 0;\n }\n .button {\n padding: 16px 32px;\n font-size: 18px;\n }\n }\n"}),g.jsxs("div",{style:C.modal,className:"modal",children:[g.jsx("button",{type:"button",style:C.closeButton,onClick:t,children:"×"}),g.jsx("video",{ref:r,style:C.video,autoPlay:!0,playsInline:!0,muted:!0}),g.jsx("canvas",{ref:a,style:C.canvas}),g.jsx("div",{style:C.guide}),"ready"===d.status&&!p&&g.jsx("div",{style:C.message,children:"Centralize seu rosto no círculo"}),"capturing"===d.status&&g.jsx("div",{style:C.message,children:"Por favor, pisque os olhos"}),"uploading"===d.status&&g.jsx("div",{style:C.spinner}),"success"===d.status&&g.jsx("div",{style:C.message,children:"Autenticado!"}),"error"===d.status&&g.jsx("div",{style:C.message,children:d.message}),g.jsxs("div",{style:C.controls,children:["ready"===d.status&&p&&g.jsx("button",{type:"button",style:C.button,onClick:v,children:"Capturar"}),"capturing"===d.status&&g.jsx("button",{type:"button",style:C.button,onClick:v,children:"Capturar"}),"error"===d.status&&g.jsx("button",{type:"button",style:C.button,onClick:()=>{u({type:"RESET"}),m(0)},children:"Tentar Novamente"})]})]})]})}const P=(e,n)=>{switch(n.type){case"START_LIVENESS":return{status:"liveness",step:n.stepSequence[0],capturedPhotos:[],stepSequence:n.stepSequence,currentStepIndex:0,stepProgress:0};case"NEXT_STEP":if("liveness"===e.status){const t=n.photo?[...e.capturedPhotos,n.photo]:e.capturedPhotos;return{status:"liveness",step:n.step,capturedPhotos:t,stepSequence:e.stepSequence,currentStepIndex:e.currentStepIndex+1,stepProgress:0}}return e;case"UPDATE_PROGRESS":return"liveness"===e.status?{...e,stepProgress:n.progress}:e;case"START_PROCESSING":return{status:"processing"};case"SUCCESS":return{status:"success"};case"ERROR":return{status:"error",message:n.message};case"RESET":return F;default:return e}},D={center:"Posicione seu rosto no centro",up:"Incline a cabeça para cima",down:"Incline a cabeça para baixo",left:"Vire o rosto para a esquerda",right:"Vire o rosto para a direita",complete:"Processando..."},F=(()=>{const e=["center","up","down","left","right","complete"];return{status:"liveness",step:e[0],capturedPhotos:[],stepSequence:e,currentStepIndex:0,stepProgress:0}})(),L=8,W=10,U=26,z=8,K=-8,q=15,M=-15,$=1500,B=200;function V({personData:e,applicationToken:t,onClose:o,onSuccess:r,onError:a,useRealApi:i=!1}){const c=n.useRef(null),l=n.useRef(null),d=n.useRef(null),u=n.useRef(null),p=n.useRef(null),f=n.useRef(!1),h=n.useRef("center"),m=n.useRef(null),[b,w]=n.useReducer(P,F),[y,x]=n.useState(!1),[v,E]=n.useState("ok");n.useEffect((()=>{if("liveness"===b.status){const e=b.step;h.current!==e&&(h.current=e,f.current||(u.current&&(u.current=null),p.current&&(clearInterval(p.current),p.current=null),w({type:"UPDATE_PROGRESS",progress:0}))),m.current={stepSequence:b.stepSequence,currentStepIndex:b.currentStepIndex,capturedPhotos:b.capturedPhotos}}}),[b.status,"liveness"===b.status&&b.step,"liveness"===b.status&&b.currentStepIndex]);n.useEffect((()=>{(async()=>{try{const e="https://cdn.jsdelivr.net/npm/@vladmandic/face-api/model";await Promise.all([s.nets.tinyFaceDetector.loadFromUri(e),s.nets.faceLandmark68Net.loadFromUri(e)])}catch(e){w({type:"ERROR",message:"Erro ao carregar modelos de IA"})}})()}),[]),n.useEffect((()=>{let e=!0;return(async()=>{if("liveness"===b.status&&!d.current)try{const n=await navigator.mediaDevices.getUserMedia({video:{width:{ideal:640},height:{ideal:480},facingMode:"user"}});if(!e)return void n.getTracks().forEach((e=>e.stop()));const t=async()=>{let e=0;for(;!c.current&&e<50;)await new Promise((e=>setTimeout(e,100))),e++;return c.current},o=await t();if(!o)throw new Error("Elemento de vídeo não encontrado");o.srcObject=n,d.current=n,await o.play()}catch(n){if(!e)return;const t=n instanceof Error?n.message:"Erro ao acessar câmera";w({type:"ERROR",message:t})}})(),()=>{e=!1,d.current&&(d.current.getTracks().forEach((e=>e.stop())),d.current=null),p.current&&(clearInterval(p.current),p.current=null),u.current=null}}),[b.status]),n.useEffect((()=>{if("liveness"!==b.status||!c.current)return;let e=!0,n=0;const t=async()=>{if(!e||"liveness"!==b.status)return;if(f.current||"complete"===h.current)return void requestAnimationFrame(t);const o=Date.now();if(o-n<B)requestAnimationFrame(t);else{n=o;try{const n=await s.detectSingleFace(c.current,new s.TinyFaceDetectorOptions({inputSize:160,scoreThreshold:.4})).withFaceLandmarks();if(!e)return;const t=!!n;if(x(t),t&&n.detection){const e=n.detection.box.width;E(e>250?"too-close":e<120?"too-far":"ok")}if(t&&n.landmarks){const e=(e=>{try{const n=e.positions||e._positions;if(!Array.isArray(n)||n.length<68)return null;const t=e=>{const t=n[e];return{x:void 0!==t._x?t._x:t.x,y:void 0!==t._y?t._y:t.y}},o=t(30),r=t(8),a=t(36),i=t(45),s=(a.x+i.x)/2,c=(o.x-s)/Math.abs(i.x-a.x)*90,l=(a.y+i.y)/2,d=o.y-l,u=-d/Math.abs(r.y-l)*90+U;return{pitch:Math.round(u),yaw:Math.round(c)}}catch(n){return null}})(n.landmarks);if(e){(e=>{if(f.current||"complete"===h.current)return;const n=Date.now();e?u.current||(u.current=n,p.current&&clearInterval(p.current),p.current=window.setInterval((()=>{if(!u.current)return;const e=Date.now()-u.current,n=Math.min(e/$*100,100);w({type:"UPDATE_PROGRESS",progress:n}),n>=100&&(clearInterval(p.current),p.current=null,k())}),50)):u.current&&(u.current=null,p.current&&(clearInterval(p.current),p.current=null),w({type:"UPDATE_PROGRESS",progress:0}))})(((e,n,t)=>{switch(t){case"center":return Math.abs(e)<L&&Math.abs(n)<W;case"up":return e>z;case"down":return e<K;case"left":return n>q;case"right":return n<M;default:return!1}})(e.pitch,e.yaw,h.current))}}else u.current&&(u.current=null,p.current&&(clearInterval(p.current),p.current=null),w({type:"UPDATE_PROGRESS",progress:0}))}catch(r){}e&&"liveness"===b.status&&requestAnimationFrame(t)}},o=setTimeout((()=>{var n;e&&4===(null==(n=c.current)?void 0:n.readyState)&&t()}),1e3);return()=>{e=!1,clearTimeout(o),p.current&&(clearInterval(p.current),p.current=null),u.current=null}}),[b.status]);const k=async()=>{if(!c.current||!l.current||f.current)return;f.current=!0,u.current=null;const e=m.current;if(!e)return void(f.current=!1);const n=l.current,t=c.current,o=n.getContext("2d");o?(n.width=t.videoWidth,n.height=t.videoHeight,o.scale(-1,1),o.drawImage(t,-n.width,0,n.width,n.height),n.toBlob((n=>{if(!n)return void(f.current=!1);const t=e.currentStepIndex+1,o=e.stepSequence[t];if("complete"===o){const t=[...e.capturedPhotos,n];w({type:"START_PROCESSING"}),R(t)}else setTimeout((()=>{f.current=!1,w({type:"NEXT_STEP",step:o,photo:n})}),100)}),"image/jpeg",.85)):f.current=!1},R=async n=>{try{if(i){const o=await I(e,n,t),a={success:o.success,message:o.message,person_id:o.person_id,user_id:o.user_id,person_validated:o.person_validated,face_processing:o.face_processing,onboarding_link:o.onboarding_link};return w({type:"SUCCESS"}),void r(a)}const o=await Promise.all(n.map((async e=>new Promise(((n,t)=>{const o=new FileReader;o.onload=()=>{const e=o.result;n(e)},o.onerror=t,o.readAsDataURL(e)})))));await new Promise((e=>setTimeout(e,2e3)));const a={success:!0,message:"Registro biométrico realizado com sucesso",person_id:"test-person-123",user_id:"test-user-456",person_validated:!0,face_processing:{total_photos_captured:n.length,photo_sizes:n.map(((e,n)=>({photo_index:n+1,size_kb:Math.round(e.size/1024)}))),photos_preview:o.map(((e,n)=>({photo_index:n+1,format:"data:image/jpeg;base64,...",preview:e.substring(0,50)+"...",full_length:e.length})))}};w({type:"SUCCESS"}),r(a)}catch(o){const e=o instanceof Error?o.message:"Erro desconhecido";w({type:"ERROR",message:e}),a(e)}};return g.jsxs(g.Fragment,{children:[g.jsx("style",{children:"\n @keyframes fadeIn {\n from { opacity: 0; transform: scale(0.95); }\n to { opacity: 1; transform: scale(1); }\n }\n\n @keyframes slideUp {\n from { opacity: 0; transform: translateY(20px); }\n to { opacity: 1; transform: translateY(0); }\n }\n\n @keyframes slideDown {\n from { opacity: 0; transform: translateY(-10px); }\n to { opacity: 1; transform: translateY(0); }\n }\n\n @keyframes spin {\n from { transform: rotate(0deg); }\n to { transform: rotate(360deg); }\n }\n\n @keyframes pulseRing {\n 0%, 100% { \n box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.8), 0 0 40px rgba(16, 185, 129, 0.4);\n }\n 50% { \n box-shadow: 0 0 0 6px rgba(16, 185, 129, 0.9), 0 0 50px rgba(16, 185, 129, 0.5);\n }\n }\n\n @keyframes checkmark {\n 0% {\n stroke-dashoffset: 100;\n }\n 100% {\n stroke-dashoffset: 0;\n }\n }\n\n @keyframes scaleIn {\n 0% {\n transform: scale(0);\n opacity: 0;\n }\n 50% {\n transform: scale(1.1);\n }\n 100% {\n transform: scale(1);\n opacity: 1;\n }\n }\n\n @keyframes scanRing {\n 0%, 100% { transform: scale(1); opacity: 0.3; }\n 50% { transform: scale(1.1); opacity: 0.6; }\n }\n\n @keyframes cornerBlink {\n 0%, 100% { opacity: 0.3; }\n 50% { opacity: 1; }\n }\n\n .modal-overlay {\n position: fixed;\n inset: 0;\n background: rgba(0, 0, 0, 0.92);\n backdrop-filter: blur(8px);\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 9999;\n padding: 20px;\n }\n\n .modal-content {\n background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);\n border-radius: 24px;\n width: 100%;\n max-width: 420px;\n max-height: 90vh;\n overflow: hidden;\n box-shadow: 0 24px 48px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.1);\n animation: fadeIn 0.3s ease-out;\n position: relative;\n }\n\n .close-button {\n position: absolute;\n top: 20px;\n right: 20px;\n width: 32px;\n height: 32px;\n background: transparent;\n border: none;\n color: rgba(255, 255, 255, 0.6);\n font-size: 28px;\n font-weight: 300;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: all 0.2s;\n z-index: 10;\n line-height: 1;\n }\n\n .close-button:hover {\n color: rgba(255, 255, 255, 0.9);\n transform: rotate(90deg);\n }\n\n /* Instructions Screen */\n .instructions-container {\n padding: 60px 40px 40px;\n color: white;\n text-align: center;\n animation: slideUp 0.4s ease-out;\n }\n\n .instructions-header {\n margin-bottom: 40px;\n }\n\n .icon-wrapper {\n display: inline-block;\n color: #7c3aed;\n margin-bottom: 24px;\n }\n\n .icon-wrapper .scan-ring {\n animation: scanRing 2s ease-in-out infinite;\n }\n\n .icon-wrapper .corner {\n animation: cornerBlink 2s ease-in-out infinite;\n }\n\n .icon-wrapper .corner.tl { animation-delay: 0s; }\n .icon-wrapper .corner.tr { animation-delay: 0.5s; }\n .icon-wrapper .corner.bl { animation-delay: 1s; }\n .icon-wrapper .corner.br { animation-delay: 1.5s; }\n\n .instructions-header h2 {\n font-size: 28px;\n font-weight: 700;\n margin: 0 0 12px 0;\n background: linear-gradient(135deg, #7c3aed 0%, #a78bfa 100%);\n -webkit-background-clip: text;\n -webkit-text-fill-color: transparent;\n background-clip: text;\n }\n\n .subtitle {\n font-size: 15px;\n color: rgba(255, 255, 255, 0.7);\n margin: 0;\n line-height: 1.5;\n }\n\n .requirements-list {\n text-align: left;\n margin: 0 auto 40px;\n max-width: 360px;\n }\n\n .requirement-item {\n display: flex;\n align-items: center;\n gap: 16px;\n padding: 14px 0;\n font-size: 15px;\n color: rgba(255, 255, 255, 0.9);\n border-bottom: 1px solid rgba(255, 255, 255, 0.05);\n }\n\n .requirement-item:last-child {\n border-bottom: none;\n }\n\n .req-icon {\n width: 32px;\n height: 32px;\n border-radius: 50%;\n display: flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n }\n\n .req-icon.success {\n background: rgba(16, 185, 129, 0.15);\n color: #10b981;\n border: 1.5px solid rgba(16, 185, 129, 0.3);\n }\n\n .primary-button {\n width: 100%;\n padding: 16px 32px;\n border-radius: 12px;\n border: none;\n background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);\n color: white;\n font-size: 16px;\n font-weight: 600;\n cursor: pointer;\n transition: all 0.3s;\n box-shadow: 0 4px 16px rgba(124, 58, 237, 0.3);\n }\n\n .primary-button:hover {\n transform: translateY(-2px);\n box-shadow: 0 8px 24px rgba(124, 58, 237, 0.4);\n }\n\n .primary-button:active {\n transform: translateY(0);\n }\n\n .branding {\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 8px;\n margin-top: 32px;\n padding-top: 24px;\n border-top: 1px solid rgba(255, 255, 255, 0.1);\n font-size: 13px;\n color: rgba(255, 255, 255, 0.5);\n }\n\n .brand-logo {\n height: 20px;\n width: auto;\n }\n\n .brand-name {\n font-weight: 600;\n font-family: 'SF Pro Display', -apple-system, system-ui, sans-serif;\n color: #ffffff;\n letter-spacing: 0.3px;\n }\n\n /* Liveness Detection */\n .liveness-container {\n height: 100%;\n min-height: 520px;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n padding: 70px 20px 80px;\n position: relative;\n animation: fadeIn 0.3s ease-out;\n }\n\n .progress-indicator {\n position: absolute;\n top: 20px;\n left: 50%;\n transform: translateX(-50%);\n background: rgba(255, 255, 255, 0.08);\n backdrop-filter: blur(12px);\n border-radius: 20px;\n padding: 8px 20px;\n border: 1px solid rgba(255, 255, 255, 0.12);\n z-index: 5;\n }\n\n .progress-text {\n font-size: 14px;\n font-weight: 600;\n color: white;\n }\n\n .video-wrapper {\n position: relative;\n margin: 20px 0;\n }\n\n .video-circle {\n width: 320px;\n height: 400px;\n border-radius: 50%;\n overflow: hidden;\n position: relative;\n transition: all 0.3s ease;\n box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.3);\n }\n\n .video-circle.face-detected {\n box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.5), 0 0 40px rgba(16, 185, 129, 0.3);\n }\n\n .video-circle.capturing {\n box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.9), 0 0 40px rgba(16, 185, 129, 0.5);\n transition: box-shadow 0.3s ease;\n }\n\n .video-feed {\n width: 100%;\n height: 100%;\n object-fit: cover;\n transform: scaleX(-1);\n }\n\n .face-badge {\n position: absolute;\n top: 20px;\n left: 50%;\n transform: translateX(-50%);\n background: rgba(16, 185, 129, 0.95);\n backdrop-filter: blur(10px);\n border-radius: 20px;\n padding: 8px 16px;\n display: flex;\n align-items: center;\n gap: 8px;\n color: white;\n font-size: 13px;\n font-weight: 600;\n border: 1px solid rgba(255, 255, 255, 0.3);\n box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);\n animation: slideDown 0.3s ease-out;\n }\n\n .face-badge.warning {\n background: rgba(251, 191, 36, 0.95);\n border: 1px solid rgba(255, 255, 255, 0.3);\n box-shadow: 0 4px 12px rgba(251, 191, 36, 0.3);\n color: #78350f;\n }\n\n .face-badge.error {\n background: rgba(239, 68, 68, 0.95);\n border: 1px solid rgba(255, 255, 255, 0.3);\n box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);\n color: white;\n }\n\n .instruction-box {\n background: rgba(255, 255, 255, 0.08);\n backdrop-filter: blur(12px);\n border-radius: 16px;\n padding: 16px 24px;\n margin-top: 20px;\n border: 1px solid rgba(255, 255, 255, 0.12);\n max-width: 320px;\n animation: slideUp 0.3s ease-out;\n }\n\n .instruction-text {\n font-size: 18px;\n font-weight: 600;\n color: white;\n margin: 0 0 12px 0;\n text-align: center;\n }\n\n .progress-bar {\n height: 4px;\n background: rgba(255, 255, 255, 0.2);\n border-radius: 2px;\n overflow: hidden;\n }\n\n .progress-fill {\n height: 100%;\n background: linear-gradient(90deg, #7c3aed 0%, #10b981 100%);\n border-radius: 2px;\n transition: width 0.05s linear;\n }\n\n .branding-small {\n position: absolute;\n bottom: 24px;\n left: 50%;\n transform: translateX(-50%);\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 5px;\n font-size: 12px;\n color: rgba(255, 255, 255, 0.5);\n }\n\n .brand-logo-small {\n height: 18px;\n width: 18px;\n }\n\n /* Processing */\n .processing-container {\n padding: 80px 40px;\n text-align: center;\n color: white;\n animation: fadeIn 0.3s ease-out;\n }\n\n .spinner-wrapper {\n position: relative;\n width: 80px;\n height: 80px;\n margin: 0 auto 32px;\n }\n\n .spinner {\n position: absolute;\n inset: 0;\n border: 4px solid rgba(124, 58, 237, 0.2);\n border-top-color: #7c3aed;\n border-radius: 50%;\n animation: spin 1s linear infinite;\n }\n\n .spinner-ring {\n position: absolute;\n inset: -10px;\n border: 2px solid rgba(124, 58, 237, 0.1);\n border-radius: 50%;\n animation: pulseSpinner 2s ease-in-out infinite;\n }\n\n @keyframes pulseSpinner {\n 0%, 100% { transform: scale(1); opacity: 1; }\n 50% { transform: scale(1.1); opacity: 0.5; }\n }\n\n .processing-container h3 {\n font-size: 24px;\n font-weight: 700;\n margin: 0 0 12px 0;\n }\n\n .processing-container p {\n font-size: 15px;\n color: rgba(255, 255, 255, 0.7);\n margin: 0;\n }\n\n /* Result Screens */\n .result-container {\n padding: 80px 40px 40px;\n text-align: center;\n color: white;\n animation: slideUp 0.4s ease-out;\n }\n\n .result-icon {\n display: inline-flex;\n margin-bottom: 24px;\n }\n\n .success-icon {\n color: #10b981;\n animation: scaleIn 0.6s ease-out;\n }\n\n .success-icon svg circle {\n animation: scaleIn 0.5s ease-out;\n }\n\n .success-icon svg path {\n stroke-dasharray: 100;\n stroke-dashoffset: 100;\n animation: checkmark 0.6s ease-out 0.3s forwards;\n }\n\n .error-icon {\n color: #ef4444;\n animation: fadeIn 0.5s ease-out;\n }\n\n .result-container h3 {\n font-size: 26px;\n font-weight: 700;\n margin: 0 0 12px 0;\n }\n\n .result-container p {\n font-size: 15px;\n color: rgba(255, 255, 255, 0.7);\n margin: 0 0 32px 0;\n line-height: 1.5;\n }\n\n .button-group {\n display: flex;\n gap: 12px;\n margin-top: 32px;\n }\n\n .secondary-button {\n flex: 1;\n padding: 14px 24px;\n border-radius: 12px;\n border: 1px solid rgba(255, 255, 255, 0.2);\n background: rgba(255, 255, 255, 0.1);\n color: white;\n font-size: 15px;\n font-weight: 600;\n cursor: pointer;\n transition: all 0.2s;\n }\n\n .secondary-button:hover {\n background: rgba(255, 255, 255, 0.15);\n border-color: rgba(255, 255, 255, 0.3);\n }\n\n .ghost-button {\n flex: 1;\n padding: 14px 24px;\n border-radius: 12px;\n border: none;\n background: transparent;\n color: rgba(255, 255, 255, 0.7);\n font-size: 15px;\n font-weight: 600;\n cursor: pointer;\n transition: all 0.2s;\n }\n\n .ghost-button:hover {\n color: white;\n background: rgba(255, 255, 255, 0.05);\n }\n\n /* Canvas */\n canvas {\n display: none;\n }\n\n /* Responsive */\n @media (max-width: 640px) {\n .modal-content {\n max-width: 100%;\n border-radius: 0;\n max-height: 100vh;\n }\n\n .instructions-container {\n padding: 50px 24px 24px;\n }\n\n .instructions-header h2 {\n font-size: 24px;\n }\n\n .video-circle {\n width: 280px;\n height: 350px;\n }\n\n .liveness-container {\n min-height: 100vh;\n }\n }\n "}),g.jsx("div",{className:"modal-overlay",children:g.jsxs("div",{className:"modal-content",children:[g.jsx("button",{className:"close-button",onClick:o,children:"×"}),"liveness"===b.status&&(()=>{if("liveness"!==b.status)return null;const e=`${b.currentStepIndex+1}/${b.stepSequence.length-1}`,n=b.stepProgress;return g.jsxs("div",{className:"liveness-container",children:[g.jsx("div",{className:"progress-indicator",children:g.jsx("span",{className:"progress-text",children:e})}),g.jsx("div",{className:"video-wrapper",children:g.jsxs("div",{className:`video-circle ${y?"face-detected":""} ${n>0?"capturing":""}`,children:[g.jsx("video",{ref:c,className:"video-feed",autoPlay:!0,muted:!0,playsInline:!0}),y&&g.jsxs("div",{className:"face-badge",children:[g.jsx("svg",{width:"16",height:"16",viewBox:"0 0 20 20",fill:"none",children:g.jsx("path",{d:"M5 10 L8 13 L15 6",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"})}),g.jsx("span",{children:"Rosto detectado"})]})]})}),g.jsxs("div",{className:"instruction-box",children:[g.jsx("p",{className:"instruction-text",children:D[b.step]}),n>0&&g.jsx("div",{className:"progress-bar",children:g.jsx("div",{className:"progress-fill",style:{width:`${n}%`}})})]}),g.jsxs("div",{className:"branding-small",children:[g.jsx("img",{src:"/public/logo-icone.png",alt:"NeoFaceId",className:"brand-logo-small"}),g.jsx("span",{children:"NeoFaceId by"}),g.jsx("span",{className:"brand-name",children:"OCTA"})]})]})})(),"processing"===b.status&&g.jsxs("div",{className:"processing-container",children:[g.jsxs("div",{className:"spinner-wrapper",children:[g.jsx("div",{className:"spinner"}),g.jsx("div",{className:"spinner-ring"})]}),g.jsx("h3",{children:"Processando biometria"}),g.jsx("p",{children:"Analisando suas capturas faciais..."}),g.jsxs("div",{className:"branding",style:{marginTop:"40px",paddingTop:"24px",borderTop:"1px solid rgba(255, 255, 255, 0.1)"},children:[g.jsx("span",{children:"NeoFaceId by"}),g.jsx("span",{className:"brand-name",children:"OCTA"})]})]}),"error"===b.status&&("error"!==b.status?null:g.jsxs("div",{className:"result-container error",children:[g.jsx("div",{className:"result-icon error-icon",children:g.jsxs("svg",{width:"60",height:"60",viewBox:"0 0 60 60",fill:"none",children:[g.jsx("circle",{cx:"30",cy:"30",r:"28",stroke:"currentColor",strokeWidth:"3"}),g.jsx("path",{d:"M20 20 L40 40 M40 20 L20 40",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round"})]})}),g.jsx("h3",{children:"Não foi possível concluir"}),g.jsx("p",{children:b.message}),g.jsxs("div",{className:"button-group",children:[g.jsx("button",{className:"secondary-button",onClick:()=>w({type:"RESET"}),children:"Tentar Novamente"}),g.jsx("button",{className:"ghost-button",onClick:o,children:"Cancelar"})]})]})),"success"===b.status&&g.jsxs("div",{className:"result-container success",children:[g.jsx("div",{className:"result-icon success-icon",children:g.jsxs("svg",{width:"60",height:"60",viewBox:"0 0 60 60",fill:"none",children:[g.jsx("circle",{cx:"30",cy:"30",r:"28",stroke:"currentColor",strokeWidth:"3"}),g.jsx("path",{d:"M15 30 L25 40 L45 20",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round"})]})}),g.jsx("h3",{children:"Verificação concluída!"}),g.jsx("p",{children:"Sua biometria foi registrada com sucesso"}),g.jsx("button",{className:"primary-button",onClick:o,children:"Continuar"})]})]})}),g.jsx("canvas",{ref:l})]})}function X({status:e,onClose:t}){const[o,r]=n.useState(!0);return n.useEffect((()=>{if("success"===e){const e=setTimeout((()=>{r(!1),setTimeout((()=>{null==t||t()}),300)}),800);return()=>clearTimeout(e)}}),[e,t]),o?g.jsxs(g.Fragment,{children:[g.jsx("style",{children:"\n @keyframes fadeIn {\n from { opacity: 0; transform: scale(0.9); }\n to { opacity: 1; transform: scale(1); }\n }\n\n @keyframes fadeOut {\n from { opacity: 1; transform: scale(1); }\n to { opacity: 0; transform: scale(0.9); }\n }\n\n @keyframes pulse {\n 0%, 100% { \n transform: scale(1);\n opacity: 1;\n }\n 50% { \n transform: scale(1.1);\n opacity: 0.9;\n }\n }\n\n @keyframes spin {\n from { transform: rotate(0deg); }\n to { transform: rotate(360deg); }\n }\n\n @keyframes checkmark {\n 0% {\n stroke-dashoffset: 100;\n opacity: 0;\n }\n 50% {\n opacity: 1;\n }\n 100% {\n stroke-dashoffset: 0;\n opacity: 1;\n }\n }\n\n @keyframes errorShake {\n 0%, 100% { transform: translateX(0) scale(1); }\n 10%, 30%, 50%, 70%, 90% { transform: translateX(-4px) scale(1); }\n 20%, 40%, 60%, 80% { transform: translateX(4px) scale(1); }\n }\n\n @keyframes scaleIn {\n 0% {\n transform: scale(0);\n opacity: 0;\n }\n 50% {\n transform: scale(1.1);\n }\n 100% {\n transform: scale(1);\n opacity: 1;\n }\n }\n\n .neofaceid-overlay-container {\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 10000;\n pointer-events: none;\n animation: fadeIn 0.3s ease-out;\n }\n\n .neofaceid-overlay-container.fade-out {\n animation: fadeOut 0.3s ease-out;\n }\n\n .neofaceid-overlay-content {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n gap: 24px;\n pointer-events: auto;\n }\n\n .neofaceid-logo-wrapper {\n position: relative;\n width: 120px;\n height: 120px;\n display: flex;\n align-items: center;\n justify-content: center;\n }\n\n .neofaceid-logo {\n width: 80px;\n height: 80px;\n object-fit: contain;\n filter: drop-shadow(0 4px 12px rgba(124, 58, 237, 0.3));\n }\n\n .neofaceid-logo.pulsing {\n animation: pulse 2s ease-in-out infinite;\n }\n\n .neofaceid-status-icon {\n position: absolute;\n inset: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n }\n\n .neofaceid-success-icon {\n width: 60px;\n height: 60px;\n color: #10b981;\n animation: scaleIn 0.6s ease-out;\n }\n\n .neofaceid-success-icon svg circle {\n stroke-dasharray: 100;\n stroke-dashoffset: 100;\n animation: checkmark 0.6s ease-out 0.2s forwards;\n }\n\n .neofaceid-error-icon {\n width: 60px;\n height: 60px;\n color: #ef4444;\n animation: errorShake 0.5s ease-out, scaleIn 0.4s ease-out;\n }\n\n /* Responsive */\n @media (max-width: 640px) {\n .neofaceid-logo-wrapper {\n width: 100px;\n height: 100px;\n }\n\n .neofaceid-logo {\n width: 70px;\n height: 70px;\n }\n }\n "}),g.jsx("div",{className:"neofaceid-overlay-container "+(o?"":"fade-out"),children:g.jsx("div",{className:"neofaceid-overlay-content",children:g.jsxs("div",{className:"neofaceid-logo-wrapper",children:[("preparing"===e||"verifying"===e)&&g.jsx(g.Fragment,{children:g.jsx("img",{src:"/public/logo-icone-no-backgorund.png",alt:"NeoFaceId",className:"neofaceid-logo "+("verifying"===e?"pulsing":""),onError:e=>{var n;const t=e.target;t.style.display="none";const o=document.createElement("div");o.innerHTML='\n <svg width="80" height="80" viewBox="0 0 80 80" fill="none" xmlns="http://www.w3.org/2000/svg">\n <circle cx="40" cy="40" r="35" fill="#7c3aed" opacity="0.2"/>\n <path d="M40 20 L40 60 M20 40 L60 40" stroke="#7c3aed" stroke-width="4" stroke-linecap="round"/>\n </svg>\n ',o.style.cssText="width: 80px; height: 80px; display: flex; align-items: center; justify-content: center;",null==(n=t.parentElement)||n.appendChild(o)}})}),"success"===e&&g.jsx("div",{className:"neofaceid-status-icon",children:g.jsxs("svg",{className:"neofaceid-success-icon",viewBox:"0 0 60 60",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[g.jsx("circle",{cx:"30",cy:"30",r:"28",stroke:"currentColor",strokeWidth:"3",fill:"none"}),g.jsx("path",{d:"M15 30 L25 40 L45 20",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})]})}),"error"===e&&g.jsx("div",{className:"neofaceid-status-icon",children:g.jsxs("svg",{className:"neofaceid-error-icon",viewBox:"0 0 60 60",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[g.jsx("circle",{cx:"30",cy:"30",r:"28",stroke:"currentColor",strokeWidth:"3",fill:"none"}),g.jsx("path",{d:"M20 20 L40 40 M40 20 L20 40",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round"})]})})]})})})]}):null}class Y{constructor(){a(this,"container",null),a(this,"root",null),a(this,"currentStatus","preparing")}show(e="preparing"){this.container?this.updateStatus(e):(this.container=document.createElement("div"),this.container.id="neofaceid-status-overlay",document.body.appendChild(this.container),this.root=c(this.container),this.currentStatus=e,this.render())}updateStatus(e){this.currentStatus=e,this.root&&this.render()}close(){this.container&&(this.root&&this.root.render(g.jsx(X,{status:this.currentStatus,onClose:()=>{this.container&&document.body.contains(this.container)&&document.body.removeChild(this.container),this.container=null,this.root=null}})),setTimeout((()=>{this.container&&document.body.contains(this.container)&&document.body.removeChild(this.container),this.container=null,this.root=null}),300))}render(){this.root&&this.container&&this.root.render(g.jsx(X,{status:this.currentStatus,onClose:()=>this.close()}))}}function G({error:e,onRetry:n,onCredentials:t,onCancel:o}){return g.jsxs(g.Fragment,{children:[g.jsx("style",{children:"\n @keyframes slideUp {\n from {\n opacity: 0;\n transform: translateY(20px);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n }\n\n @keyframes fadeIn {\n from { opacity: 0; }\n to { opacity: 1; }\n }\n\n .neofaceid-fallback-overlay {\n position: fixed;\n inset: 0;\n background: rgba(0, 0, 0, 0.6);\n backdrop-filter: blur(8px);\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 10001;\n padding: 20px;\n animation: fadeIn 0.3s ease-out;\n }\n\n .neofaceid-fallback-prompt {\n background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);\n border-radius: 20px;\n padding: 32px;\n max-width: 400px;\n width: 100%;\n box-shadow: 0 24px 48px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.1);\n animation: slideUp 0.4s ease-out;\n text-align: center;\n }\n\n .neofaceid-fallback-icon {\n width: 64px;\n height: 64px;\n margin: 0 auto 20px;\n color: #ef4444;\n animation: scaleIn 0.4s ease-out;\n }\n\n @keyframes scaleIn {\n 0% {\n transform: scale(0);\n opacity: 0;\n }\n 50% {\n transform: scale(1.1);\n }\n 100% {\n transform: scale(1);\n opacity: 1;\n }\n }\n\n .neofaceid-fallback-title {\n font-size: 22px;\n font-weight: 700;\n color: white;\n margin: 0 0 12px 0;\n }\n\n .neofaceid-fallback-message {\n font-size: 15px;\n color: rgba(255, 255, 255, 0.7);\n margin: 0 0 28px 0;\n line-height: 1.5;\n }\n\n .neofaceid-fallback-actions {\n display: flex;\n flex-direction: column;\n gap: 12px;\n }\n\n .neofaceid-fallback-button {\n padding: 14px 24px;\n border-radius: 12px;\n border: none;\n font-size: 16px;\n font-weight: 600;\n cursor: pointer;\n transition: all 0.2s;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n }\n\n .neofaceid-fallback-button-primary {\n background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);\n color: white;\n box-shadow: 0 4px 16px rgba(124, 58, 237, 0.3);\n }\n\n .neofaceid-fallback-button-primary:hover {\n transform: translateY(-2px);\n box-shadow: 0 8px 24px rgba(124, 58, 237, 0.4);\n }\n\n .neofaceid-fallback-button-primary:active {\n transform: translateY(0);\n }\n\n .neofaceid-fallback-button-secondary {\n background: rgba(255, 255, 255, 0.1);\n color: white;\n border: 1px solid rgba(255, 255, 255, 0.2);\n }\n\n .neofaceid-fallback-button-secondary:hover {\n background: rgba(255, 255, 255, 0.15);\n border-color: rgba(255, 255, 255, 0.3);\n }\n\n .neofaceid-fallback-button-ghost {\n background: transparent;\n color: rgba(255, 255, 255, 0.7);\n padding: 10px;\n }\n\n .neofaceid-fallback-button-ghost:hover {\n color: white;\n background: rgba(255, 255, 255, 0.05);\n }\n\n @media (max-width: 640px) {\n .neofaceid-fallback-prompt {\n padding: 24px;\n border-radius: 16px;\n }\n\n .neofaceid-fallback-title {\n font-size: 20px;\n }\n }\n "}),g.jsx("div",{className:"neofaceid-fallback-overlay",children:g.jsxs("div",{className:"neofaceid-fallback-prompt",children:[g.jsx("div",{className:"neofaceid-fallback-icon",children:g.jsxs("svg",{viewBox:"0 0 64 64",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[g.jsx("circle",{cx:"32",cy:"32",r:"30",stroke:"currentColor",strokeWidth:"3",fill:"none"}),g.jsx("path",{d:"M20 20 L44 44 M44 20 L20 44",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round"})]})}),g.jsx("h3",{className:"neofaceid-fallback-title",children:"Não foi possível reconhecer"}),g.jsx("p",{className:"neofaceid-fallback-message",children:(null==e?void 0:e.message)||"Não conseguimos reconhecer sua face. Tente novamente ou use email e senha."}),g.jsxs("div",{className:"neofaceid-fallback-actions",children:[g.jsx("button",{type:"button",className:"neofaceid-fallback-button neofaceid-fallback-button-primary",onClick:n,children:"Tentar Novamente"}),g.jsx("button",{type:"button",className:"neofaceid-fallback-button neofaceid-fallback-button-secondary",onClick:t,children:"Entrar com Email e Senha"}),o&&g.jsx("button",{type:"button",className:"neofaceid-fallback-button neofaceid-fallback-button-ghost",onClick:o,children:"Cancelar"})]})]})})]})}class H{constructor(){a(this,"container",null),a(this,"root",null)}show(e,n,t,o){this.container||(this.container=document.createElement("div"),this.container.id="neofaceid-fallback-prompt",document.body.appendChild(this.container),this.root=c(this.container),this.render(e,n,t,o))}close(){this.container&&document.body.contains(this.container)&&(this.root&&this.root.unmount(),document.body.removeChild(this.container),this.container=null,this.root=null)}render(e,n,t,o){this.root&&this.container&&this.root.render(g.jsx(G,{error:e,onRetry:()=>{this.close(),n()},onCredentials:()=>{this.close(),t()},onCancel:()=>{this.close(),null==o||o()}}))}}class J{constructor(e){a(this,"options"),a(this,"modalElement",null),this.options=e}async open(){this.createModal(),document.body.appendChild(this.modalElement)}close(){this.modalElement&&(document.body.removeChild(this.modalElement),this.modalElement=null),this.options.onCancel&&this.options.onCancel()}createModal(){this.addStyles(),this.modalElement=document.createElement("div"),this.modalElement.className="neoface-email-password-modal",this.modalElement.innerHTML=`\n <div class="neoface-email-modal-overlay">\n <div class="neoface-email-modal-content">\n <h2>${this.options.title||"Login com Email e Senha"}</h2>\n <p>${this.options.subtitle||"Informe seus dados para login."}</p>\n <form id="email-password-form">\n <input type="email" id="email" placeholder="Email" required />\n <input type="password" id="password" placeholder="Senha" required />\n <button type="submit" class="neoface-email-submit-btn">Entrar</button>\n </form>\n <button class="neoface-email-cancel-btn">Cancelar</button>\n \n \x3c!-- Branding --\x3e\n <div class="neoface-email-branding">\n <img src="/public/logo-icone-no-backgorund.png" alt="NeoFaceId" class="neoface-email-brand-logo" onerror="this.style.display='none'" />\n <span>NeoFaceId by</span>\n <span class="neoface-email-brand-name">OCTA</span>\n </div>\n </div>\n </div>\n `;this.modalElement.querySelector("#email-password-form").addEventListener("submit",this.handleSubmit.bind(this));this.modalElement.querySelector(".neoface-email-cancel-btn").addEventListener("click",this.close.bind(this))}addStyles(){const e="neoface-email-password-modal-styles";if(document.getElementById(e))return;const n=document.createElement("style");n.id=e,n.textContent="\n .neoface-email-password-modal {\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n z-index: 10002;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n }\n\n .neoface-email-modal-overlay {\n position: absolute;\n inset: 0;\n background: rgba(0, 0, 0, 0.6);\n backdrop-filter: blur(8px);\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 20px;\n animation: fadeIn 0.3s ease-out;\n }\n\n @keyframes fadeIn {\n from { opacity: 0; }\n to { opacity: 1; }\n }\n\n @keyframes slideUp {\n from {\n opacity: 0;\n transform: translateY(20px);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n }\n\n .neoface-email-modal-content {\n background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);\n border-radius: 20px;\n padding: 32px;\n max-width: 400px;\n width: 100%;\n box-shadow: 0 24px 48px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.1);\n animation: slideUp 0.4s ease-out;\n }\n\n .neoface-email-modal-content h2 {\n font-size: 24px;\n font-weight: 700;\n color: white;\n margin: 0 0 12px 0;\n text-align: center;\n }\n\n .neoface-email-modal-content p {\n font-size: 15px;\n color: rgba(255, 255, 255, 0.7);\n margin: 0 0 24px 0;\n text-align: center;\n line-height: 1.5;\n }\n\n .neoface-email-modal-content form {\n display: flex;\n flex-direction: column;\n gap: 16px;\n margin-bottom: 16px;\n }\n\n .neoface-email-modal-content input {\n width: 100%;\n padding: 14px 16px;\n border: 2px solid rgba(255, 255, 255, 0.2);\n border-radius: 12px;\n font-size: 15px;\n background: rgba(255, 255, 255, 0.1);\n color: white;\n font-family: inherit;\n transition: all 0.2s;\n box-sizing: border-box;\n }\n\n .neoface-email-modal-content input::placeholder {\n color: rgba(255, 255, 255, 0.5);\n }\n\n .neoface-email-modal-content input:focus {\n outline: none;\n border-color: #7c3aed;\n box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.2);\n background: rgba(255, 255, 255, 0.15);\n }\n\n .neoface-email-submit-btn {\n width: 100%;\n padding: 14px 24px;\n border-radius: 12px;\n border: none;\n background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);\n color: white;\n font-size: 16px;\n font-weight: 600;\n cursor: pointer;\n transition: all 0.2s;\n box-shadow: 0 4px 16px rgba(124, 58, 237, 0.3);\n font-family: inherit;\n }\n\n .neoface-email-submit-btn:hover {\n transform: translateY(-2px);\n box-shadow: 0 8px 24px rgba(124, 58, 237, 0.4);\n }\n\n .neoface-email-submit-btn:active {\n transform: translateY(0);\n }\n\n .neoface-email-submit-btn:disabled {\n opacity: 0.6;\n cursor: not-allowed;\n transform: none;\n }\n\n .neoface-email-cancel-btn {\n width: 100%;\n padding: 12px 24px;\n border-radius: 12px;\n border: 1px solid rgba(255, 255, 255, 0.2);\n background: transparent;\n color: rgba(255, 255, 255, 0.7);\n font-size: 15px;\n font-weight: 600;\n cursor: pointer;\n transition: all 0.2s;\n font-family: inherit;\n }\n\n .neoface-email-cancel-btn:hover {\n background: rgba(255, 255, 255, 0.1);\n color: white;\n border-color: rgba(255, 255, 255, 0.3);\n }\n\n .neoface-email-branding {\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 8px;\n margin-top: 32px;\n padding-top: 24px;\n border-top: 1px solid rgba(255, 255, 255, 0.1);\n font-size: 13px;\n color: rgba(255, 255, 255, 0.5);\n }\n\n .neoface-email-brand-logo {\n height: 20px;\n width: auto;\n }\n\n .neoface-email-brand-name {\n font-weight: 600;\n font-family: 'SF Pro Display', -apple-system, system-ui, sans-serif;\n color: #ffffff;\n letter-spacing: 0.3px;\n }\n\n @media (max-width: 640px) {\n .neoface-email-modal-content {\n padding: 24px;\n border-radius: 16px;\n }\n\n .neoface-email-modal-content h2 {\n font-size: 20px;\n }\n }\n ",document.head.appendChild(n)}async handleSubmit(e){e.preventDefault();const n=this.modalElement.querySelector("#email"),t=this.modalElement.querySelector("#password"),o=n.value.trim(),r=t.value.trim();if(o&&r)try{const e=await(async(e,n,t)=>{k();const o=R();try{const r=await fetch(`${E}/api/v1/auth/login/`,{method:"POST",headers:{"Content-Type":"application/json","X-App-Token":t},body:JSON.stringify({email:e,password:n}),signal:o.signal});if(!r.ok){if(401===r.status||403===r.status)throw new v("Invalid credentials or application token",x.INVALID_TOKEN);throw new v(`Server returned status ${r.status}`,x.NETWORK)}const a=await r.json();return{success:!0,accessToken:a.access_token||a.access,alias:a.user&&a.user.alias||a.alias,user:{id:a.user&&a.user.id||"",email:a.user&&a.user.email||"",role:a.user&&a.user.role||"",validated:a.user&&a.user.validated||!1,active:a.user&&a.user.active||!1}}}catch(r){if(r instanceof Error){if("AbortError"===r.name)throw new v("Request timed out",x.NETWORK);if(r instanceof v)throw r;throw new v(r.message,x.NETWORK)}throw new v("Unknown error occurred",x.NETWORK_ERROR)}})(o,r,this.options.applicationToken);this.options.onSuccess(e),this.close()}catch(a){this.options.onError(a)}else this.options.onError(new v("Email e senha são obrigatórios",x.VALIDATION_ERROR))}}async function Z(e,n){n.updateStatus("verifying");const t=document.createElement("video");t.style.position="fixed",t.style.top="-9999px",t.style.left="-9999px",t.style.width="1px",t.style.height="1px",t.style.opacity="0",t.setAttribute("autoplay",""),t.setAttribute("muted",""),t.setAttribute("playsinline",""),document.body.appendChild(t);let o=null;try{o=await navigator.mediaDevices.getUserMedia({video:{width:{ideal:640},height:{ideal:480},facingMode:"user"},audio:!1}),t.srcObject=o,await t.play(),await new Promise((e=>{t.readyState>=2?e(void 0):t.onloadedmetadata=()=>e(void 0)})),await new Promise((e=>setTimeout(e,500)));const n=await async function(e,n=3e3,t=200){return new Promise((o=>{let r=0,a=0;const i=Math.ceil(n/t);let c=null,l=!1;const d=e=>{l||(l=!0,c&&clearTimeout(c),o(e))},u=async()=>{if(!l)try{const n=await s.detectSingleFace(e,new s.TinyFaceDetectorOptions({inputSize:160,scoreThreshold:.4}));if(a++,n&&r++,a>=i)return void d(r/a>=.6);c=window.setTimeout(u,t)}catch(n){a++,a>=i?d(r/a>=.6):c=window.setTimeout(u,t)}},p=window.setTimeout((()=>{l||d((a>0?r/a:0)>=.6)}),n+1e3);c=window.setTimeout((()=>{u(),clearTimeout(p)}),t)}))}(t,3e3);if(!n)throw o&&o.getTracks().forEach((e=>e.stop())),t.parentElement&&t.parentElement.removeChild(t),new v("Rosto não detectado. Posicione seu rosto na frente da câmera.",x.VALIDATION_ERROR);const r=document.createElement("canvas");r.width=t.videoWidth,r.height=t.videoHeight;const a=r.getContext("2d");if(!a)throw o&&o.getTracks().forEach((e=>e.stop())),t.parentElement&&t.parentElement.removeChild(t),new v("Erro ao capturar imagem",x.CAPTURE_ERROR);a.drawImage(t,0,0,r.width,r.height),o&&o.getTracks().forEach((e=>e.stop())),t.parentElement&&t.parentElement.removeChild(t);const i=await new Promise(((e,n)=>{r.toBlob((t=>{r.remove(),t?e(t):n(new Error("Failed to capture image"))}),"image/jpeg",.85)})),c=await S(i,e);if(!c.success)throw new v("Login falhou",x.LOGIN_FAILED);return c}catch(r){if(o&&o.getTracks().forEach((e=>e.stop())),t.parentElement&&t.parentElement.removeChild(t),r instanceof v)throw r;throw new v(r instanceof Error?r.message:"Erro desconhecido",x.UNKNOWN)}}async function Q(e){try{if(!(await O(e.applicationToken)))return void e.onError(new v("Token de aplicação inválido",x.INVALID_TOKEN));await async function(e){const{applicationToken:n,onSuccess:t,onError:o,onFallbackRequest:r,onCancel:a}=e,i=new Y,c=new H;let l,d=0;try{const e="https://cdn.jsdelivr.net/npm/@vladmandic/face-api/model";await Promise.all([s.nets.tinyFaceDetector.loadFromUri(e),s.nets.faceLandmark68Net.loadFromUri(e)])}catch(p){}i.show("preparing");const u=async()=>{try{d++;const e=await Z(n,i);i.updateStatus("success"),setTimeout((()=>{i.close(),t(e)}),800)}catch(p){l=p instanceof v?p:new v(p instanceof Error?p.message:"Erro desconhecido",x.UNKNOWN),i.updateStatus("error"),d<3?setTimeout((()=>{u()}),500):setTimeout((()=>{i.close(),c.show(l,(()=>{d=0,i.show("preparing"),setTimeout((()=>u()),500)}),(()=>{r?r():o(new v("Por favor, use email e senha para fazer login",x.LOGIN_FAILED))}),a)}),1e3)}};setTimeout((()=>{u()}),300)}({applicationToken:e.applicationToken,onSuccess:e.onSuccess,onError:e.onError,onFallbackRequest:e.onFallbackRequest||(()=>{const n={applicationToken:e.applicationToken,onSuccess:e.onSuccess,onError:e.onError,title:"Login Alternativo",subtitle:"Biometria não reconhecida. Por favor, informe email e senha."};new J(n).open()}),onCancel:e.onCancel})}catch(n){e.onError(new v("Erro ao inicializar login facial: "+n.message,x.INITIALIZATION_ERROR))}}async function ee(e){try{if(!(await O(e.applicationToken)))return void e.onError(new v("Token de aplicação inválido",x.INVALID_TOKEN));const n={mode:"hand",onSuccess:async(n,t)=>{try{const t=await fetch(n).then((e=>e.blob())),o=await loginWithBiometric(t,e.applicationToken);e.onSuccess(o)}catch(o){e.onError(o)}},onError:e.onError,onCancel:e.onCancel,countdown:e.countdown,title:e.title||"Login por Mão",subtitle:e.subtitle||"Posicione sua mão dentro do quadro para fazer login."},t=new BiometricCaptureModal(n);await t.open()}catch(n){e.onError(new v("Erro ao inicializar login por mão: "+n.message,x.INITIALIZATION_ERROR))}}async function ne(e){try{if(!(await O(e.applicationToken)))return void e.onError(new v("Token de aplicação inválido",x.INVALID_TOKEN));const n={mode:"auto",onSuccess:async(n,t)=>{try{const t=await fetch(n).then((e=>e.blob())),o=await loginWithBiometric(t,e.applicationToken);e.onSuccess(o)}catch(o){e.onError(o)}},onError:e.onError,onCancel:e.onCancel,countdown:e.countdown,title:e.title||"Login Biométrico",subtitle:e.subtitle||"Posicione seu rosto ou mão dentro do quadro para login automático."},t=new BiometricCaptureModal(n);await t.open()}catch(n){e.onError(new v("Erro ao inicializar login automático: "+n.message,x.INITIALIZATION_ERROR))}}async function te(e){try{const t=await(n=e,new Promise(((e,t)=>{const o=new Image;o.onload=()=>e(o),o.onerror=()=>t(new Error("Erro ao carregar imagem"));const r=n.startsWith("data:")?n:`data:image/jpeg;base64,${n}`;o.src=r}))),o=await async function(e){try{if("undefined"!=typeof window&&window.faceapi){const n=window.faceapi;await re();const t=new n.TinyFaceDetectorOptions({inputSize:320,scoreThreshold:.5}),o=await n.detectAllFaces(e,t).withFaceLandmarks();if(o&&o.length>0){const e=o.reduce(((e,n)=>n.detection.score>e.detection.score?n:e));return{confidence:e.detection.score,details:{faces:o.length,landmarks:e.landmarks,box:e.detection.box}}}}return{confidence:0}}catch(n){return{confidence:0}}}(t);if(o.confidence>.7)return{type:"face",confidence:o.confidence,details:o.details};const r=await async function(e){try{const n=document.createElement("canvas"),t=n.getContext("2d");if(!t)return{confidence:0};n.width=e.width,n.height=e.height,t.drawImage(e,0,0);const o=function(e){const{data:n,width:t,height:o}=e;let r=0,a=0;for(let d=0;d<n.length;d+=4){oe(n[d],n[d+1],n[d+2])&&r++,a++}const i=r/a,s=t/o;let c=0;i>.15&&i<.7&&(c+=i/.7*.4);s>.6&&s<1.8&&(c+=.3);const l=t*o;l>1e4&&l<5e5&&(c+=.3);return{confidence:Math.min(c,.8),skinRatio:i,aspectRatio:s,imageSize:l,skinPixels:r,totalPixels:a}}(t.getImageData(0,0,n.width,n.height));return{confidence:o.confidence,details:o}}catch(n){return{confidence:0}}}(t);return r.confidence>.6?{type:"hand",confidence:r.confidence,details:r.details}:{type:"unknown",confidence:Math.max(o.confidence,r.confidence)}}catch(t){return{type:"face",confidence:.5}}var n}function oe(e,n,t){const o=.299*e+.587*n+.114*t,r=-.169*e-.331*n+.5*t+128,a=.5*e-.419*n-.081*t+128;return o>80&&o<255&&r>85&&r<135&&a>135&&a<180}async function re(){if("undefined"==typeof window||!window.faceapi)return;const e=window.faceapi;if(!e.nets.tinyFaceDetector.isLoaded)try{await Promise.all([e.nets.tinyFaceDetector.loadFromUri("./models"),e.nets.faceLandmark68Net.loadFromUri("./models")])}catch(n){}}async function ae(){try{"undefined"!=typeof window&&await re()}catch(e){}}function ie(){return"undefined"!=typeof window&&window.faceapi&&window.faceapi.nets.tinyFaceDetector.isLoaded}const se=Object.freeze(Object.defineProperty({__proto__:null,detectBiometricType:te,initializeBiometricDetection:ae,isAdvancedDetectionAvailable:ie},Symbol.toStringTag,{value:"Module"}));class ce{constructor(e){a(this,"overlay",null),a(this,"video",null),a(this,"canvas",null),a(this,"stream",null),a(this,"step","face"),a(this,"countdownSeconds"),a(this,"title"),a(this,"subtitle"),a(this,"faceBlob",null),a(this,"documentBlob",null),this.countdownSeconds=(null==e?void 0:e.countdown)??3,this.title=null==e?void 0:e.title,this.subtitle=null==e?void 0:e.subtitle}async open(){if(await this.createDom(),await this.startCamera(),await this.runFaceCaptureCountdown(),this.faceBlob=await this.captureFrame(),this.step="document",this.updateTexts("Captura do Documento",'Posicione seu documento visível e clique em "Capturar"'),await this.waitForUserCaptureClick(),this.documentBlob=await this.captureFrame(),await this.close(),!this.faceBlob||!this.documentBlob)throw new Error("Falha na captura das imagens de onboarding");return{face:this.faceBlob,document:this.documentBlob}}async createDom(){const e=document.createElement("div");e.className="neofaceid-modal-overlay",e.innerHTML=`\n <div class="neofaceid-modal">\n <div class="neofaceid-modal-header">\n <h2 class="neofaceid-title">${this.title??"Onboarding NeoFaceID"}</h2>\n <button class="neofaceid-close-btn" aria-label="Fechar">×</button>\n </div>\n <div class="neofaceid-modal-body">\n <p class="neofaceid-subtitle">${this.subtitle??"Vamos capturar sua face e documento"}</p>\n <div class="neofaceid-camera-container">\n <video class="neofaceid-video" autoplay playsinline></video>\n <canvas class="neofaceid-canvas"></canvas>\n <div class="neofaceid-overlay">\n <div class="neofaceid-frame"></div>\n <div class="neofaceid-countdown" style="display:none"><span class="neofaceid-countdown-number">${this.countdownSeconds}</span></div>\n </div>\n </div>\n <div class="neofaceid-status"><p class="neofaceid-status-text">Posicione seu rosto no quadro</p></div>\n </div>\n <div class="neofaceid-modal-footer">\n <button class="neofaceid-cancel-btn">Cancelar</button>\n <button class="neofaceid-capture-btn" disabled>Capturar</button>\n </div>\n </div>\n `;const n=document.createElement("style");n.textContent="\n .neofaceid-modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); display:flex; align-items:center; justify-content:center; z-index: 9999; }\n .neofaceid-modal { background:#fff; border-radius:12px; width: 92%; max-width: 640px; box-shadow: 0 20px 60px rgba(0,0,0,0.3); overflow:hidden; }\n .neofaceid-modal-header { padding: 16px 20px; border-bottom: 1px solid #eee; display:flex; align-items:center; justify-content:space-between; }\n .neofaceid-title { margin:0; font-size: 20px; color:#333; }\n .neofaceid-close-btn { background:none; border:none; font-size:24px; cursor:pointer; color:#666; }\n .neofaceid-modal-body { padding: 16px 20px; }\n .neofaceid-subtitle { margin: 0 0 12px 0; color:#666; }\n .neofaceid-camera-container { position: relative; background:#000; border-radius:8px; overflow:hidden; aspect-ratio: 4/3; margin-bottom: 12px; }\n .neofaceid-video { width:100%; height:100%; object-fit: cover; }\n .neofaceid-canvas { position:absolute; top:0; left:0; }\n .neofaceid-overlay { position:absolute; inset:0; display:flex; align-items:center; justify-content:center; }\n .neofaceid-frame { width: 200px; height: 200px; border: 3px solid #4CAF50; border-radius: 50%; box-shadow: 0 0 0 2px rgba(76,175,80,0.3); }\n .neofaceid-countdown { position:absolute; top:16px; right:16px; background: rgba(0,0,0,0.7); color:#fff; width: 48px; height:48px; display:flex; align-items:center; justify-content:center; border-radius:50%; }\n .neofaceid-modal-footer { padding: 16px 20px; border-top: 1px solid #eee; display:flex; gap: 8px; justify-content:flex-end; }\n .neofaceid-cancel-btn { background:#f5f5f5; color:#666; border:none; border-radius:6px; padding:10px 18px; cursor:pointer; }\n .neofaceid-capture-btn { background:#4CAF50; color:#fff; border:none; border-radius:6px; padding:10px 18px; cursor:pointer; }\n .neofaceid-capture-btn:disabled { background:#ccc; cursor:not-allowed; }\n ",document.head.appendChild(n),document.body.appendChild(e),this.overlay=e,this.video=this.overlay.querySelector(".neofaceid-video"),this.canvas=this.overlay.querySelector(".neofaceid-canvas");const t=this.overlay.querySelector(".neofaceid-close-btn"),o=this.overlay.querySelector(".neofaceid-cancel-btn");t.onclick=()=>this.close(),o.onclick=()=>this.close();this.overlay.querySelector(".neofaceid-capture-btn").disabled=!0}async startCamera(){if(this.stream=await navigator.mediaDevices.getUserMedia({video:{facingMode:"user",width:{ideal:1280},height:{ideal:720}},audio:!1}),!this.video)throw new Error("Elemento de vídeo não encontrado");this.video.srcObject=this.stream,await this.video.play()}async runFaceCaptureCountdown(){if(!this.overlay)return;const e=this.overlay.querySelector(".neofaceid-countdown"),n=this.overlay.querySelector(".neofaceid-countdown-number"),t=this.overlay.querySelector(".neofaceid-status-text");e.style.display="flex",t.textContent="Prepare-se! Capturando seu rosto...";let o=this.countdownSeconds;n.textContent=String(o),await new Promise((t=>{const r=setInterval((()=>{o-=1,n.textContent=String(o),o<=0&&(clearInterval(r),e.style.display="none",t())}),1e3)}))}async waitForUserCaptureClick(){if(!this.overlay)return;const e=this.overlay.querySelector(".neofaceid-capture-btn"),n=this.overlay.querySelector(".neofaceid-status-text");e.disabled=!1,n.textContent='Clique em "Capturar" quando o documento estiver visível',await new Promise((n=>{const t=()=>{e.removeEventListener("click",t),n()};e.addEventListener("click",t)})),e.disabled=!0}async captureFrame(){if(!this.video||!this.canvas)throw new Error("Elementos de captura não encontrados");const e=this.canvas.getContext("2d");if(!e)throw new Error("Falha ao obter contexto do canvas");this.canvas.width=this.video.videoWidth,this.canvas.height=this.video.videoHeight,e.drawImage(this.video,0,0,this.canvas.width,this.canvas.height);return await new Promise(((e,n)=>{this.canvas.toBlob((t=>t?e(t):n(new Error("Falha ao gerar imagem"))),"image/jpeg",.92)}))}updateTexts(e,n){if(!this.overlay)return;const t=this.overlay.querySelector(".neofaceid-title"),o=this.overlay.querySelector(".neofaceid-subtitle"),r=this.overlay.querySelector(".neofaceid-frame");t.textContent=e,o.textContent=n,"document"===this.step&&(r.style.borderRadius="8px",r.style.width="280px",r.style.height="180px")}async close(){this.stream&&(this.stream.getTracks().forEach((e=>e.stop())),this.stream=null),this.overlay&&(this.overlay.remove(),this.overlay=null)}}e.BiometricCaptureModal=class{constructor(e){a(this,"modal",null),a(this,"video",null),a(this,"canvas",null),a(this,"stream",null),a(this,"options"),a(this,"countdownInterval",null),a(this,"isCapturing",!1),this.options=e}async open(){try{await this.createModal(),await this.initializeCamera(),this.startCountdown()}catch(e){this.options.onError(new v("Erro ao inicializar câmera: "+e.message,x.CAMERA_ERROR))}}close(){this.cleanup(),this.modal&&(document.body.removeChild(this.modal),this.modal=null)}async createModal(){this.modal=document.createElement("div"),this.modal.className="neofaceid-biometric-modal";const e=this.options.title||this.getDefaultTitle(),n=this.options.subtitle||this.getDefaultSubtitle();this.modal.innerHTML=`\n <div class="neofaceid-modal-overlay">\n <div class="neofaceid-modal-content">\n <div class="neofaceid-modal-header">\n <h2>${e}</h2>\n <button class="neofaceid-close-btn" type="button">&times;</button>\n </div>\n <div class="neofaceid-modal-body">\n <p class="neofaceid-subtitle">${n}</p>\n <div class="neofaceid-camera-container">\n <video class="neofaceid-video" autoplay muted playsinline></video>\n <canvas class="neofaceid-canvas" style="display: none;"></canvas>\n <div class="neofaceid-overlay">\n <div class="neofaceid-frame"></div>\n <div class="neofaceid-countdown">\n <span class="neofaceid-countdown-number">${this.options.countdown||3}</span>\n </div>\n </div>\n </div>\n <div class="neofaceid-status">\n <p class="neofaceid-status-text">Posicione-se na frente da câmera</p>\n </div>\n </div>\n <div class="neofaceid-modal-footer">\n <button class="neofaceid-cancel-btn" type="button">Cancelar</button>\n <button class="neofaceid-capture-btn" type="button" disabled>Capturar</button>\n </div>\n </div>\n </div>\n `,this.addStyles(),this.addEventListeners(),document.body.appendChild(this.modal)}async initializeCamera(){if(!this.modal)throw new Error("Modal não inicializado");if(this.video=this.modal.querySelector(".neofaceid-video"),this.canvas=this.modal.querySelector(".neofaceid-canvas"),!this.video||!this.canvas)throw new Error("Elementos de vídeo ou canvas não encontrados");try{this.stream=await navigator.mediaDevices.getUserMedia({video:{width:{ideal:640},height:{ideal:480},facingMode:"user"},audio:!1}),this.video.srcObject=this.stream,await this.video.play(),this.canvas.width=this.video.videoWidth,this.canvas.height=this.video.videoHeight}catch(e){throw new Error("Não foi possível acessar a câmera: "+e.message)}}startCountdown(){if(!this.modal)return;const e=this.modal.querySelector(".neofaceid-countdown-number"),n=this.modal.querySelector(".neofaceid-capture-btn"),t=this.modal.querySelector(".neofaceid-status-text");let o=this.options.countdown||3;e&&(e.textContent=o.toString()),this.countdownInterval=window.setInterval((()=>{o--,e&&(e.textContent=o.toString()),o<=0&&(this.countdownInterval&&(clearInterval(this.countdownInterval),this.countdownInterval=null),e&&(e.style.display="none"),n&&(n.disabled=!1,n.textContent="Capturar Agora"),t&&(t.textContent="Pronto para capturar!"),"auto"===this.options.mode&&setTimeout((()=>this.captureImage()),500))}),1e3)}async captureImage(){if(!this.isCapturing&&this.video&&this.canvas){this.isCapturing=!0;try{const e=this.canvas.getContext("2d");if(!e)throw new Error("Não foi possível obter contexto do canvas");e.drawImage(this.video,0,0,this.canvas.width,this.canvas.height);const n=this.canvas.toDataURL("image/jpeg",.8).split(",")[1],t=`data:image/jpeg;base64,${n}`;let o="auto"===this.options.mode?await this.detectBiometricType(n):this.options.mode;this.close(),this.options.onSuccess(t,o)}catch(e){this.options.onError(new v("Erro ao capturar imagem: "+e.message,x.CAPTURE_ERROR))}finally{this.isCapturing=!1}}}async detectBiometricType(e){try{const{detectBiometricType:n}=await Promise.resolve().then((()=>se)),t=await n(e);return"unknown"!==t.type&&t.confidence>.6?t.type:"face"}catch(n){return"face"}}addEventListeners(){if(!this.modal)return;const e=this.modal.querySelector(".neofaceid-close-btn"),n=this.modal.querySelector(".neofaceid-cancel-btn"),t=this.modal.querySelector(".neofaceid-capture-btn");null==e||e.addEventListener("click",(()=>{var e,n;this.close(),null==(n=(e=this.options).onCancel)||n.call(e)})),null==n||n.addEventListener("click",(()=>{var e,n;this.close(),null==(n=(e=this.options).onCancel)||n.call(e)})),null==t||t.addEventListener("click",(()=>{this.captureImage()})),this.modal.addEventListener("click",(e=>{var n,t,o;e.target===(null==(n=this.modal)?void 0:n.querySelector(".neofaceid-modal-overlay"))&&(this.close(),null==(o=(t=this.options).onCancel)||o.call(t))}))}cleanup(){this.stream&&(this.stream.getTracks().forEach((e=>e.stop())),this.stream=null),this.countdownInterval&&(clearInterval(this.countdownInterval),this.countdownInterval=null),this.video=null,this.canvas=null,this.isCapturing=!1}getDefaultTitle(){switch(this.options.mode){case"face":return"Autenticação Facial";case"hand":return"Autenticação por Mão";case"auto":return"Autenticação Biométrica";default:return"Captura Biométrica"}}getDefaultSubtitle(){switch(this.options.mode){case"face":return"Posicione seu rosto dentro do quadro e aguarde a captura automática.";case"hand":return"Posicione sua mão dentro do quadro e aguarde a captura automática.";case"auto":return"Posicione seu rosto ou mão dentro do quadro para autenticação automática.";default:return"Posicione-se dentro do quadro para captura."}}addStyles(){const e="neofaceid-biometric-modal-styles",n=document.getElementById(e);n&&n.remove();const t=document.createElement("style");t.id=e,t.textContent="\n .neofaceid-biometric-modal {\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n z-index: 10000;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n }\n\n .neofaceid-modal-overlay {\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background: rgba(0, 0, 0, 0.8);\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 20px;\n box-sizing: border-box;\n }\n\n .neofaceid-modal-content {\n background: white;\n border-radius: 12px;\n max-width: 600px;\n width: 100%;\n max-height: 90vh;\n overflow: hidden;\n box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);\n }\n\n .neofaceid-modal-header {\n padding: 20px;\n border-bottom: 1px solid #e0e0e0;\n display: flex;\n justify-content: space-between;\n align-items: center;\n }\n\n .neofaceid-modal-header h2 {\n margin: 0;\n font-size: 24px;\n font-weight: 600;\n color: #333;\n }\n\n .neofaceid-close-btn {\n background: none;\n border: none;\n font-size: 28px;\n cursor: pointer;\n color: #666;\n padding: 0;\n width: 32px;\n height: 32px;\n display: flex;\n align-items: center;\n justify-content: center;\n border-radius: 50%;\n transition: background-color 0.2s;\n }\n\n .neofaceid-close-btn:hover {\n background-color: #f0f0f0;\n }\n\n .neofaceid-modal-body {\n padding: 20px;\n }\n\n .neofaceid-subtitle {\n margin: 0 0 20px 0;\n color: #666;\n font-size: 16px;\n line-height: 1.4;\n }\n\n .neofaceid-camera-container {\n position: relative;\n background: #000;\n border-radius: 8px;\n overflow: hidden;\n aspect-ratio: 4/3;\n margin-bottom: 20px;\n }\n\n .neofaceid-video {\n width: 100%;\n height: 100%;\n object-fit: cover;\n }\n\n .neofaceid-canvas {\n position: absolute;\n top: 0;\n left: 0;\n }\n\n .neofaceid-overlay {\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n display: flex;\n align-items: center;\n justify-content: center;\n }\n\n .neofaceid-frame {\n width: 200px;\n height: 200px;\n border: 3px solid #4CAF50;\n border-radius: 50%;\n box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.3);\n animation: pulse 2s infinite;\n }\n\n .neofaceid-countdown {\n position: absolute;\n top: 20px;\n right: 20px;\n background: rgba(0, 0, 0, 0.7);\n color: white;\n padding: 10px;\n border-radius: 50%;\n width: 50px;\n height: 50px;\n display: flex;\n align-items: center;\n justify-content: center;\n }\n\n .neofaceid-countdown-number {\n font-size: 24px;\n font-weight: bold;\n }\n\n .neofaceid-status {\n text-align: center;\n margin-bottom: 20px;\n }\n\n .neofaceid-status-text {\n margin: 0;\n color: #666;\n font-size: 16px;\n }\n\n .neofaceid-modal-footer {\n padding: 20px;\n border-top: 1px solid #e0e0e0;\n display: flex;\n gap: 12px;\n justify-content: flex-end;\n }\n\n .neofaceid-cancel-btn,\n .neofaceid-capture-btn {\n padding: 12px 24px;\n border: none;\n border-radius: 6px;\n font-size: 16px;\n font-weight: 500;\n cursor: pointer;\n transition: all 0.2s;\n }\n\n .neofaceid-cancel-btn {\n background: #f5f5f5;\n color: #666;\n }\n\n .neofaceid-cancel-btn:hover {\n background: #e0e0e0;\n }\n\n .neofaceid-capture-btn {\n background: #4CAF50;\n color: white;\n }\n\n .neofaceid-capture-btn:hover:not(:disabled) {\n background: #45a049;\n }\n\n .neofaceid-capture-btn:disabled {\n background: #ccc;\n cursor: not-allowed;\n }\n\n @keyframes pulse {\n 0% { box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.3); }\n 50% { box-shadow: 0 0 0 10px rgba(76, 175, 80, 0.1); }\n 100% { box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.3); }\n }\n\n @media (max-width: 640px) {\n .neofaceid-modal-overlay {\n padding: 10px;\n }\n \n .neofaceid-modal-header,\n .neofaceid-modal-body,\n .neofaceid-modal-footer {\n padding: 15px;\n }\n \n .neofaceid-frame {\n width: 150px;\n height: 150px;\n }\n }\n ",document.head.appendChild(t)}},e.BiometricRegistrationModal=V,e.BiometricStatusOverlay=Y,e.EmailPasswordModal=J,e.ErrorType=x,e.FaceCaptureModal=A,e.FallbackPrompt=H,e.NeoFaceError=v,e.RELEASE_DATE="2025-11-23",e.VERSION="1.4.0",e.biometricLogin=function(e,n="auto"){return new Promise(((t,o)=>{const r={applicationToken:e,onSuccess:t,onError:o};switch(n){case"face":Q(r);break;case"hand":ee(r);break;case"auto":ne(r);break;default:o(new v("Modo de login inválido",x.VALIDATION_ERROR))}}))},e.biometricLoginWithFallback=function(e,n="auto"){return new Promise(((t,o)=>{const r={applicationToken:e,onSuccess:t,onError:n=>{if(n.type===x.LOGIN_FAILED){new J({applicationToken:e,onSuccess:t,onError:o,title:"Login Alternativo",subtitle:"Biometria não reconhecida. Por favor, informe email e senha."}).open()}else o(n)}};switch(n){case"face":Q(r);break;case"hand":ee(r);break;case"auto":ne(r);break;default:o(new v("Modo de login inválido",x.VALIDATION_ERROR))}}))},e.completeOnboarding=_,e.completeOnboardingWithData=async(e,n,t,o,r)=>{if(k(),!o||0===o.length)throw new v("Pelo menos uma imagem da pessoa é obrigatória",x.VALIDATION_ERROR);const a=R();try{const i=await Promise.all(o.map((e=>T(e)))),s=await T(r),c=new FormData;i.forEach(((e,n)=>{c.append("person_images",e,`person_${n+1}.jpg`)})),c.append("document_image",s,"document.jpg"),t.name&&c.append("name",t.name),t.birth_date&&c.append("birth_date",t.birth_date),t.cpf&&c.append("cpf",t.cpf),t.cnpj&&c.append("cnpj",t.cnpj),t.email&&c.append("email",t.email);const l=await fetch(`${E}/api/v1/onboardings/${encodeURIComponent(n)}/complete`,{method:"POST",headers:{"X-App-Token":e},body:c,signal:a.signal}),d=await l.json();if(!l.ok){if(401===l.status||403===l.status)throw new v("Token de aplicação inválido ou expirado",x.INVALID_TOKEN);if(404===l.status)throw new v("Link de onboarding não encontrado",x.NOT_FOUND);throw new v((null==d?void 0:d.error)||(null==d?void 0:d.message)||"Falha ao concluir onboarding",x.NETWORK)}return{success:!!d.success,message:d.message||"Onboarding concluído com sucesso",person_id:d.person_id,identity_data_id:d.identity_data_id,confidence_score:d.confidence_score,processing_time:d.processing_time,liveness_passed:d.liveness_passed,document_verified:d.document_verified,person_created:d.person_created}}catch(i){if(i instanceof Error){if("AbortError"===i.name)throw new v("Tempo de requisição excedido",x.NETWORK);if(i instanceof v)throw i;throw new v(i.message,x.NETWORK)}throw new v("Erro desconhecido",x.NETWORK_ERROR)}},e.detectBiometricType=te,e.identifyPerson=async(e,n)=>{var t,o;k();const r=R(),a=await T(e),i=await new Promise(((e,n)=>{const t=new FileReader;t.onload=()=>{const n=t.result;e(n.split(",")[1])},t.onerror=n,t.readAsDataURL(a)}));try{const e=await fetch(`${E}/api/v1/external/recognition/face/`,{method:"POST",headers:{"Content-Type":"application/json","X-App-Token":n},body:JSON.stringify({image:i,purpose:"SIMPLE_IDENTIFICATION_F"}),signal:r.signal});if(!e.ok){if(401===e.status||403===e.status)throw new v("Invalid or expired application token",x.INVALID_TOKEN);throw new v(`Server returned status ${e.status}`,x.NETWORK)}const a=await e.json();if(!a.success)throw new v(a.message||"Person identification failed",x.RECOGNITION_FAILED);const s=(null==(t=a.person)?void 0:t.name)||"",c=null==(o=a.person)?void 0:o.birth_date;if(!s)throw new v("Person name not found in response",x.PERSON_NOT_FOUND);if(!c)throw new v("Birth date not found in response",x.PERSON_NOT_FOUND);const l=new Date(c),d=new Date;let u=d.getFullYear()-l.getFullYear();const p=d.getMonth()-l.getMonth();return(p<0||0===p&&d.getDate()<l.getDate())&&u--,{name:s,age:u}}catch(s){if(s instanceof Error){if("AbortError"===s.name)throw new v("Request timed out",x.NETWORK);if(s instanceof v)throw s;throw new v(s.message,x.NETWORK)}throw new v("Unknown error occurred",x.NETWORK_ERROR)}},e.initializeBiometricDetection=ae,e.isAdvancedDetectionAvailable=ie,e.loginWithBiometric=S,e.recognize=N,e.recognizeBiometric=async(e,n,t=!0,o=.8)=>{k();const r=R(),a=await T(e);try{const e=new FormData;e.append("face_frames",a),e.append("liveness_check",t.toString()),e.append("confidence_threshold",o.toString());const i=await fetch(`${E}/api/v1/external/recognition/biometric/`,{method:"POST",headers:{"X-App-Token":n},body:e,signal:r.signal});if(!i.ok){if(401===i.status||403===i.status)throw new v("Invalid or expired application token",x.INVALID_TOKEN);throw new v(`Server returned status ${i.status}`,x.NETWORK)}const s=await i.json();return{success:s.success,personId:s.person_id,confidenceScore:s.confidence_score,accessToken:s.access_token,payload:s.payload}}catch(i){if(i instanceof Error){if("AbortError"===i.name)throw new v("Request timed out",x.NETWORK);if(i instanceof v)throw i;throw new v(i.message,x.NETWORK)}throw new v("Unknown error occurred",x.NETWORK_ERROR)}},e.recognizeByPurpose=async(e,n,t,o=.8)=>{k();const r=R(),a=await T(e),i=await new Promise(((e,n)=>{const t=new FileReader;t.onload=()=>{const n=t.result;e(n.split(",")[1])},t.onerror=n,t.readAsDataURL(a)}));try{const e=await fetch(`${E}/api/v1/external/recognition/purpose/`,{method:"POST",headers:{"Content-Type":"application/json","X-App-Token":n},body:JSON.stringify({biometric_data:i,type_of_identification:"FACE",purpose:t,confidence_threshold:o}),signal:r.signal});if(!e.ok){if(401===e.status||403===e.status)throw new v("Invalid or expired application token",x.INVALID_TOKEN);throw new v(`Server returned status ${e.status}`,x.NETWORK)}const a=await e.json();return{success:a.success,personId:a.person_id,confidenceScore:a.confidence_score,accessToken:a.access_token,payload:a.payload}}catch(s){if(s instanceof Error){if("AbortError"===s.name)throw new v("Request timed out",x.NETWORK);if(s instanceof v)throw s;throw new v(s.message,x.NETWORK)}throw new v("Unknown error occurred",x.NETWORK_ERROR)}},e.registerPersonWithBiometric=I,e.registerPersonWithoutFace=async(e,n)=>{k();const t=R();try{const o=await fetch(`${E}/api/v1/signup/donor/`,{method:"POST",headers:{"Content-Type":"application/json","X-App-Token":n},body:JSON.stringify({name:e.name,birth_date:e.birth_date,cpf:e.cpf,email:e.email,password:e.password,password_confirm:e.password}),signal:t.signal});if(!o.ok){if(401===o.status||403===o.status)throw new v("Invalid or expired application token",x.INVALID_TOKEN);throw new v(`Server returned status ${o.status}`,x.NETWORK)}return await o.json()}catch(o){if(o instanceof Error){if("AbortError"===o.name)throw new v("Request timed out",x.NETWORK);if(o instanceof v)throw o;throw new v(o.message,x.NETWORK)}throw new v("Unknown error occurred",x.NETWORK)}},e.simpleIdentification=async(e,n,t,o="LOGIN")=>{k();const r=R();try{const a=await fetch(`${E}/api/v1/external/recognition/simple/`,{method:"POST",headers:{"Content-Type":"application/json","X-App-Token":t},body:JSON.stringify({document_type:e,document_number:n,purpose:o}),signal:r.signal});if(!a.ok){if(401===a.status||403===a.status)throw new v("Invalid or expired application token",x.INVALID_TOKEN);throw new v(`Server returned status ${a.status}`,x.NETWORK)}const i=await a.json();if(!i.success)throw new v(i.message||"Identification failed",x.RECOGNITION_FAILED);return{success:i.success,personId:i.person_id,accessToken:i.access_token,payload:i.payload}}catch(a){if(a instanceof Error){if("AbortError"===a.name)throw new v("Request timed out",x.NETWORK);if(a instanceof v)throw a;throw new v(a.message,x.NETWORK)}throw new v("Unknown error occurred",x.NETWORK_ERROR)}},e.start=function(e,t){const o=document.createElement("div");o.id="neoface-modal-container",document.body.appendChild(o);const r=()=>{document.body.contains(o)&&document.body.removeChild(o)};O(e).then((()=>{const a=n.createElement(A,{accessToken:e,onClose:r,onSuccess:e=>{r(),t.onSuccess({name:e.data.faceId,email:e.data.faceId,documentId:e.data.faceId})}});c(o).render(a)})).catch((e=>{r(),t.onError("TOKEN_VALIDATION_ERROR",e.message||"Failed to validate token")}))},e.startAutoLogin=ne,e.startBiometricRegistration=function(e,t,o,r){const a=document.createElement("div");a.id="neoface-biometric-registration-container",document.body.appendChild(a);const i=()=>{document.body.contains(a)&&document.body.removeChild(a)};O(t).then((()=>{const s=n.createElement(V,{personData:e,applicationToken:t,useRealApi:(null==r?void 0:r.useRealApi)||!1,onClose:i,onSuccess:e=>{i(),o.onSuccess(e)},onError:e=>{i(),o.onError("BIOMETRIC_REGISTRATION_ERROR",e)}});c(a).render(s)})).catch((e=>{i(),o.onError("TOKEN_VALIDATION_ERROR",e.message||"Failed to validate token")}))},e.startFaceLogin=Q,e.startHandLogin=ee,e.startOnboarding=async e=>{const{applicationToken:n,onboardingToken:t,countdown:o,title:r,subtitle:a,onSuccess:i,onError:s}=e;try{const e=await(async(e,n)=>{k();const t=R();try{const o=await fetch(`${E}/api/v1/onboardings/${encodeURIComponent(n)}/`,{method:"GET",headers:{"X-App-Token":e},signal:t.signal});if(!o.ok){if(401===o.status||403===o.status)throw new v("Token de aplicação inválido ou expirado",x.INVALID_TOKEN);if(404===o.status)throw new v("Link de onboarding não encontrado",x.NOT_FOUND);throw new v(`Falha ao obter detalhes (${o.status})`,x.NETWORK)}return await o.json()}catch(o){if(o instanceof Error){if("AbortError"===o.name)throw new v("Tempo de requisição excedido",x.NETWORK);if(o instanceof v)throw o;throw new v(o.message,x.NETWORK)}throw new v("Erro desconhecido",x.NETWORK_ERROR)}})(n,t);if(!(null==e?void 0:e.is_valid))throw new v("Link de onboarding inválido ou expirado",x.VALIDATION_ERROR);const s=new ce({countdown:o,title:r,subtitle:a}),{face:c,document:l}=await s.open();i({...await _(n,t,c,l),details:e})}catch(c){if(c instanceof v)return void s(c);const e=(null==c?void 0:c.message)||"Erro desconhecido no onboarding";s(new v(e,x.UNKNOWN))}},e.validateOnboardingToken=async(e,n)=>{k();const t=R();try{const o=await fetch(`${E}/api/v1/onboardings/${encodeURIComponent(n)}/`,{method:"GET",headers:{"X-App-Token":e},signal:t.signal});if(!o.ok){if(401===o.status||403===o.status)throw new v("Token de aplicação inválido ou expirado",x.INVALID_TOKEN);if(404===o.status)return!1;throw new v(`Falha ao validar token (${o.status})`,x.NETWORK)}const r=await o.json();return!0===(null==r?void 0:r.is_valid)}catch(o){if(o instanceof Error){if("AbortError"===o.name)throw new v("Tempo de requisição excedido",x.NETWORK);if(o instanceof v)throw o;throw new v(o.message,x.NETWORK)}throw new v("Erro desconhecido",x.NETWORK_ERROR)}},e.validateToken=O,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}));
10
+ */"production"===process.env.NODE_ENV?u.exports=function(){if(d)return p;d=1;var e=n,t=Symbol.for("react.element"),o=Symbol.for("react.fragment"),a=Object.prototype.hasOwnProperty,r=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function s(e,n,o){var s,c={},l=null,d=null;for(s in void 0!==o&&(l=""+o),void 0!==n.key&&(l=""+n.key),void 0!==n.ref&&(d=n.ref),n)a.call(n,s)&&!i.hasOwnProperty(s)&&(c[s]=n[s]);if(e&&e.defaultProps)for(s in n=e.defaultProps)void 0===c[s]&&(c[s]=n[s]);return{$$typeof:t,type:e,key:l,ref:d,props:c,_owner:r.current}}return p.Fragment=o,p.jsx=s,p.jsxs=s,p}():u.exports=(f||(f=1,"production"!==process.env.NODE_ENV&&function(){var e,t=n,o=Symbol.for("react.element"),a=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),c=Symbol.for("react.provider"),l=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),p=Symbol.for("react.suspense_list"),f=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),g=Symbol.for("react.offscreen"),w=Symbol.iterator,b=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function y(e){for(var n=arguments.length,t=new Array(n>1?n-1:0),o=1;o<n;o++)t[o-1]=arguments[o];!function(e,n,t){var o=b.ReactDebugCurrentFrame.getStackAddendum();""!==o&&(n+="%s",t=t.concat([o]));var a=t.map((function(e){return String(e)}));a.unshift("Warning: "+n),Function.prototype.apply.call(console[e],console,a)}("error",e,t)}function v(e){return e.displayName||"Context"}function x(e){if(null==e)return null;if("number"==typeof e.tag&&y("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),"function"==typeof e)return e.displayName||e.name||null;if("string"==typeof e)return e;switch(e){case r:return"Fragment";case a:return"Portal";case s:return"Profiler";case i:return"StrictMode";case u:return"Suspense";case p:return"SuspenseList"}if("object"==typeof e)switch(e.$$typeof){case l:return v(e)+".Consumer";case c:return v(e._context)+".Provider";case d:return function(e,n,t){var o=e.displayName;if(o)return o;var a=n.displayName||n.name||"";return""!==a?t+"("+a+")":t}(e,e.render,"ForwardRef");case f:var n=e.displayName||null;return null!==n?n:x(e.type)||"Memo";case m:var t=e,o=t._payload,h=t._init;try{return x(h(o))}catch(g){return null}}return null}e=Symbol.for("react.module.reference");var E,R,k,_,T,O,N,I=Object.assign,S=0;function A(){}A.__reactDisabledLog=!0;var j,C=b.ReactCurrentDispatcher;function F(e,n,t){if(void 0===j)try{throw Error()}catch(a){var o=a.stack.trim().match(/\n( *(at )?)/);j=o&&o[1]||""}return"\n"+j+e}var P,D=!1,L="function"==typeof WeakMap?WeakMap:Map;function U(e,n){if(!e||D)return"";var t,o=P.get(e);if(void 0!==o)return o;D=!0;var a,r=Error.prepareStackTrace;Error.prepareStackTrace=void 0,a=C.current,C.current=null,function(){if(0===S){E=console.log,R=console.info,k=console.warn,_=console.error,T=console.group,O=console.groupCollapsed,N=console.groupEnd;var e={configurable:!0,enumerable:!0,value:A,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}S++}();try{if(n){var i=function(){throw Error()};if(Object.defineProperty(i.prototype,"props",{set:function(){throw Error()}}),"object"==typeof Reflect&&Reflect.construct){try{Reflect.construct(i,[])}catch(h){t=h}Reflect.construct(e,[],i)}else{try{i.call()}catch(h){t=h}e.call(i.prototype)}}else{try{throw Error()}catch(h){t=h}e()}}catch(m){if(m&&t&&"string"==typeof m.stack){for(var s=m.stack.split("\n"),c=t.stack.split("\n"),l=s.length-1,d=c.length-1;l>=1&&d>=0&&s[l]!==c[d];)d--;for(;l>=1&&d>=0;l--,d--)if(s[l]!==c[d]){if(1!==l||1!==d)do{if(l--,--d<0||s[l]!==c[d]){var u="\n"+s[l].replace(" at new "," at ");return e.displayName&&u.includes("<anonymous>")&&(u=u.replace("<anonymous>",e.displayName)),"function"==typeof e&&P.set(e,u),u}}while(l>=1&&d>=0);break}}}finally{D=!1,C.current=a,function(){if(0==--S){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:I({},e,{value:E}),info:I({},e,{value:R}),warn:I({},e,{value:k}),error:I({},e,{value:_}),group:I({},e,{value:T}),groupCollapsed:I({},e,{value:O}),groupEnd:I({},e,{value:N})})}S<0&&y("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}(),Error.prepareStackTrace=r}var p=e?e.displayName||e.name:"",f=p?F(p):"";return"function"==typeof e&&P.set(e,f),f}function W(e,n,t){if(null==e)return"";if("function"==typeof e)return U(e,!(!(o=e.prototype)||!o.isReactComponent));var o;if("string"==typeof e)return F(e);switch(e){case u:return F("Suspense");case p:return F("SuspenseList")}if("object"==typeof e)switch(e.$$typeof){case d:return U(e.render,!1);case f:return W(e.type,n,t);case m:var a=e,r=a._payload,i=a._init;try{return W(i(r),n,t)}catch(s){}}return""}P=new L;var M=Object.prototype.hasOwnProperty,q={},K=b.ReactDebugCurrentFrame;function z(e){if(e){var n=e._owner,t=W(e.type,e._source,n?n.type:null);K.setExtraStackFrame(t)}else K.setExtraStackFrame(null)}var $=Array.isArray;function B(e){return $(e)}function V(e){return""+e}function X(e){if(function(e){try{return V(e),!1}catch(n){return!0}}(e))return y("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",function(e){return"function"==typeof Symbol&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object"}(e)),V(e)}var G,Y,H,J=b.ReactCurrentOwner,Z={key:!0,ref:!0,__self:!0,__source:!0};function Q(e,n,t,a,r){var i,s={},c=null,l=null;for(i in void 0!==t&&(X(t),c=""+t),function(e){if(M.call(e,"key")){var n=Object.getOwnPropertyDescriptor(e,"key").get;if(n&&n.isReactWarning)return!1}return void 0!==e.key}(n)&&(X(n.key),c=""+n.key),function(e){if(M.call(e,"ref")){var n=Object.getOwnPropertyDescriptor(e,"ref").get;if(n&&n.isReactWarning)return!1}return void 0!==e.ref}(n)&&(l=n.ref,function(e,n){if("string"==typeof e.ref&&J.current&&n&&J.current.stateNode!==n){var t=x(J.current.type);H[t]||(y('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',x(J.current.type),e.ref),H[t]=!0)}}(n,r)),n)M.call(n,i)&&!Z.hasOwnProperty(i)&&(s[i]=n[i]);if(e&&e.defaultProps){var d=e.defaultProps;for(i in d)void 0===s[i]&&(s[i]=d[i])}if(c||l){var u="function"==typeof e?e.displayName||e.name||"Unknown":e;c&&function(e,n){var t=function(){G||(G=!0,y("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",n))};t.isReactWarning=!0,Object.defineProperty(e,"key",{get:t,configurable:!0})}(s,u),l&&function(e,n){var t=function(){Y||(Y=!0,y("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",n))};t.isReactWarning=!0,Object.defineProperty(e,"ref",{get:t,configurable:!0})}(s,u)}return function(e,n,t,a,r,i,s){var c={$$typeof:o,type:e,key:n,ref:t,props:s,_owner:i,_store:{}};return Object.defineProperty(c._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(c,"_self",{configurable:!1,enumerable:!1,writable:!1,value:a}),Object.defineProperty(c,"_source",{configurable:!1,enumerable:!1,writable:!1,value:r}),Object.freeze&&(Object.freeze(c.props),Object.freeze(c)),c}(e,c,l,r,a,J.current,s)}H={};var ee,ne=b.ReactCurrentOwner,te=b.ReactDebugCurrentFrame;function oe(e){if(e){var n=e._owner,t=W(e.type,e._source,n?n.type:null);te.setExtraStackFrame(t)}else te.setExtraStackFrame(null)}function ae(e){return"object"==typeof e&&null!==e&&e.$$typeof===o}function re(){if(ne.current){var e=x(ne.current.type);if(e)return"\n\nCheck the render method of `"+e+"`."}return""}ee=!1;var ie={};function se(e,n){if(e._store&&!e._store.validated&&null==e.key){e._store.validated=!0;var t=function(e){var n=re();if(!n){var t="string"==typeof e?e:e.displayName||e.name;t&&(n="\n\nCheck the top-level render call using <"+t+">.")}return n}(n);if(!ie[t]){ie[t]=!0;var o="";e&&e._owner&&e._owner!==ne.current&&(o=" It was passed a child from "+x(e._owner.type)+"."),oe(e),y('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',t,o),oe(null)}}}function ce(e,n){if("object"==typeof e)if(B(e))for(var t=0;t<e.length;t++){var o=e[t];ae(o)&&se(o,n)}else if(ae(e))e._store&&(e._store.validated=!0);else if(e){var a=function(e){if(null===e||"object"!=typeof e)return null;var n=w&&e[w]||e["@@iterator"];return"function"==typeof n?n:null}(e);if("function"==typeof a&&a!==e.entries)for(var r,i=a.call(e);!(r=i.next()).done;)ae(r.value)&&se(r.value,n)}}function le(e){var n,t=e.type;if(null!=t&&"string"!=typeof t){if("function"==typeof t)n=t.propTypes;else{if("object"!=typeof t||t.$$typeof!==d&&t.$$typeof!==f)return;n=t.propTypes}if(n){var o=x(t);!function(e,n,t,o,a){var r=Function.call.bind(M);for(var i in e)if(r(e,i)){var s=void 0;try{if("function"!=typeof e[i]){var c=Error((o||"React class")+": "+t+" type `"+i+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[i]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw c.name="Invariant Violation",c}s=e[i](n,i,o,t,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(l){s=l}!s||s instanceof Error||(z(a),y("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",o||"React class",t,i,typeof s),z(null)),s instanceof Error&&!(s.message in q)&&(q[s.message]=!0,z(a),y("Failed %s type: %s",t,s.message),z(null))}}(n,e.props,"prop",o,e)}else void 0===t.PropTypes||ee||(ee=!0,y("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",x(t)||"Unknown"));"function"!=typeof t.getDefaultProps||t.getDefaultProps.isReactClassApproved||y("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}var de={};function ue(n,t,a,h,w,b){var v=function(n){return"string"==typeof n||"function"==typeof n||n===r||n===s||n===i||n===u||n===p||n===g||"object"==typeof n&&null!==n&&(n.$$typeof===m||n.$$typeof===f||n.$$typeof===c||n.$$typeof===l||n.$$typeof===d||n.$$typeof===e||void 0!==n.getModuleId)}(n);if(!v){var E="";(void 0===n||"object"==typeof n&&null!==n&&0===Object.keys(n).length)&&(E+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var R,k=function(e){return void 0!==e?"\n\nCheck your code at "+e.fileName.replace(/^.*[\\\/]/,"")+":"+e.lineNumber+".":""}(w);E+=k||re(),null===n?R="null":B(n)?R="array":void 0!==n&&n.$$typeof===o?(R="<"+(x(n.type)||"Unknown")+" />",E=" Did you accidentally export a JSX literal instead of a component?"):R=typeof n,y("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",R,E)}var _=Q(n,t,a,w,b);if(null==_)return _;if(v){var T=t.children;if(void 0!==T)if(h)if(B(T)){for(var O=0;O<T.length;O++)ce(T[O],n);Object.freeze&&Object.freeze(T)}else y("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else ce(T,n)}if(M.call(t,"key")){var N=x(n),I=Object.keys(t).filter((function(e){return"key"!==e})),S=I.length>0?"{key: someKey, "+I.join(": ..., ")+": ...}":"{key: someKey}";de[N+S]||(y('A props object containing a "key" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />',S,N,I.length>0?"{"+I.join(": ..., ")+": ...}":"{}",N),de[N+S]=!0)}return n===r?function(e){for(var n=Object.keys(e.props),t=0;t<n.length;t++){var o=n[t];if("children"!==o&&"key"!==o){oe(e),y("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",o),oe(null);break}}null!==e.ref&&(oe(e),y("Invalid attribute `ref` supplied to `React.Fragment`."),oe(null))}(_):le(_),_}var pe=function(e,n,t){return ue(e,n,t,!1)},fe=function(e,n,t){return ue(e,n,t,!0)};h.Fragment=r,h.jsx=pe,h.jsxs=fe}()),h);var m=u.exports;class g extends Error{constructor(e){super(e),this.name="CameraPermissionDenied"}}class w{constructor(e){__publicField(this,"stream"),this.stream=e}getStream(){return this.stream}stop(){this.stream.getTracks().forEach((e=>e.stop()))}}const b=()=>{const e=n.useRef(null),[t,o]=n.useState(!1),a=n.useRef(!1);return{startCamera:n.useCallback((async n=>{const t=e.current;if(t)return t.getStream();if(a.current){await new Promise((e=>setTimeout(e,100)));const n=e.current;if(n)return n.getStream()}a.current=!0;try{const t=n||(()=>{const e=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);return{video:{facingMode:"user",width:{ideal:e?640:1280},height:{ideal:e?480:720},aspectRatio:{ideal:1.777777778}},audio:!1}})(),r=await navigator.mediaDevices.getUserMedia(t),i=new w(r);return e.current=i,o(!0),a.current=!1,r}catch(r){if(a.current=!1,r instanceof Error){if("NotAllowedError"===r.name||"PermissionDeniedError"===r.name)throw new g("Permissão para acessar a câmera foi negada pelo usuário");if("NotFoundError"===r.name||"DevicesNotFoundError"===r.name)throw new Error("Nenhuma câmera foi encontrada no dispositivo");if("NotReadableError"===r.name||"TrackStartError"===r.name)throw new Error("A câmera já está sendo usada por outro aplicativo");if("OverconstrainedError"===r.name||"ConstraintNotSatisfiedError"===r.name)throw new Error("As configurações solicitadas não são suportadas pela câmera")}throw new Error(`Erro ao inicializar câmera: ${r instanceof Error?r.message:String(r)}`)}}),[]),stopCamera:n.useCallback((n=>{const t=e.current;t&&t.getStream()===n&&(t.stop(),e.current=null,o(!1),a.current=!1)}),[]),cleanup:n.useCallback((()=>{e.current&&(e.current.stop(),e.current=null,o(!1),a.current=!1)}),[]),isActive:t}};var y=(e=>(e.NETWORK="NetworkError",e.NETWORK_ERROR="NetworkError",e.INVALID_TOKEN="InvalidTokenError",e.RECOGNITION_FAILED="RecognitionFailedError",e.LOGIN_FAILED="LoginFailedError",e.VALIDATION_ERROR="ValidationError",e.API_ERROR="ApiError",e.PERSON_NOT_FOUND="PersonNotFoundError",e.INITIALIZATION_ERROR="InitializationError",e.CAMERA_ERROR="CameraError",e.NO_CAMERA="NoCameraError",e.CAPTURE_ERROR="CaptureError",e.NOT_FOUND="NotFoundError",e.UNKNOWN="UnknownError",e))(y||{});class v extends Error{constructor(e,n){super(e),__publicField(this,"type"),this.name=n,this.type=n}}const x=(null==(a={BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1})?void 0:a.VITE_API_BASE_URL)||"http://localhost:8000",E=()=>{const e="localhost"===window.location.hostname||"127.0.0.1"===window.location.hostname||""===window.location.hostname;if(!window.isSecureContext&&!e)throw new v("Secure context (HTTPS) is required for this operation",y.NETWORK)},R=()=>{const e=new AbortController,n=setTimeout((()=>e.abort()),1e4);return e.signal.addEventListener("abort",(()=>clearTimeout(n))),e},k=async e=>new Promise(((n,t)=>{const o=new Image;o.onload=()=>{const e=document.createElement("canvas");e.width=o.width,e.height=o.height;const a=e.getContext("2d");a?(a.drawImage(o,0,0),e.toBlob((e=>{e?n(e):t(new Error("Failed to compress image"))}),"image/jpeg",.7)):t(new Error("Failed to get canvas context"))},o.onerror=()=>{t(new Error("Failed to load image"))},o.src=URL.createObjectURL(e)})),_=async e=>{E();const n=R();try{return(await fetch(`${x}/api/v1/auth/application/validate_token/`,{method:"POST",headers:{"Content-Type":"application/json","X-App-Token":e},body:JSON.stringify({}),signal:n.signal})).ok}catch(t){if(t instanceof Error){if("AbortError"===t.name)throw new v("Request timed out",y.NETWORK_ERROR);throw new v(t.message,y.NETWORK_ERROR)}throw new v("Unknown error occurred",y.NETWORK_ERROR)}},T=async(e,n,t,o)=>{E();const a=R(),r=await k(t),i=await k(o);try{const t=new FormData;t.append("face_image",r,"face.jpg"),t.append("document_image",i,"document.jpg");const o=await fetch(`${x}/api/v1/onboardings/${encodeURIComponent(n)}/complete`,{method:"POST",headers:{"X-App-Token":e},body:t,signal:a.signal}),s=await o.json();if(!o.ok){if(401===o.status||403===o.status)throw new v("Token de aplicação inválido ou expirado",y.INVALID_TOKEN);if(404===o.status)throw new v("Link de onboarding não encontrado",y.NOT_FOUND);throw new v((null==s?void 0:s.error)||(null==s?void 0:s.message)||"Falha ao concluir onboarding",y.NETWORK)}return{success:!!s.success,message:s.message||"Onboarding concluído",person_id:s.person_id,identity_data_id:s.identity_data_id,confidence_score:s.confidence_score,processing_time:s.processing_time}}catch(s){if(s instanceof Error){if("AbortError"===s.name)throw new v("Tempo de requisição excedido",y.NETWORK);if(s instanceof v)throw s;throw new v(s.message,y.NETWORK)}throw new v("Erro desconhecido",y.NETWORK_ERROR)}},O=async(e,n)=>{E();const t=R(),o=await k(e);try{const e=new FormData;e.append("face_frames",o);const a=await fetch(`${x}/api/v1/external/recognition/face/`,{method:"POST",headers:{"X-App-Token":n},body:e,signal:t.signal});if(!a.ok){if(401===a.status||403===a.status)throw new v("Invalid or expired application token",y.INVALID_TOKEN);throw new v(`Server returned status ${a.status}`,y.NETWORK)}const r=await a.json();if(!r.success)throw new v(r.message||"Recognition failed",y.RECOGNITION_FAILED);return{accessToken:r.accessToken,payload:r.payload}}catch(a){if(a instanceof Error){if("AbortError"===a.name)throw new v("Request timed out",y.NETWORK);if(a instanceof v)throw a;throw new v(a.message,y.NETWORK)}throw new v("Unknown error occurred",y.NETWORK_ERROR)}},N=async(e,n)=>{var t,o,a,r,i;E();const s=R(),c=await k(e);try{const e=new FormData;e.append("face_frames",c);const l=await fetch(`${x}/api/v1/external/auth/login/`,{method:"POST",headers:{"X-App-Token":n},body:e,signal:s.signal});if(!l.ok){if(401===l.status||403===l.status)throw new v("Invalid or expired application token",y.INVALID_TOKEN);throw new v(`Server returned status ${l.status}`,y.NETWORK)}const d=await l.json();if(!d.success)throw new v(d.message||"Login failed",y.LOGIN_FAILED);return{success:!0,accessToken:d.accessToken,alias:d.alias,user:{id:(null==(t=d.user)?void 0:t.id)||"",email:(null==(o=d.user)?void 0:o.email)||"",role:(null==(a=d.user)?void 0:a.role)||"",validated:(null==(r=d.user)?void 0:r.validated)||!1,active:(null==(i=d.user)?void 0:i.active)||!1},person:d.person?{name:d.person.name||"",birth_date:d.person.birth_date||""}:void 0,confidence_score:d.confidence_score,recognition_id:d.recognition_id}}catch(l){if(l instanceof Error){if("AbortError"===l.name)throw new v("Request timed out",y.NETWORK);if(l instanceof v)throw l;throw new v(l.message,y.NETWORK)}throw new v("Unknown error occurred",y.NETWORK_ERROR)}},I=async(e,n,t,o=.8,a,r)=>{var i;E();const s=R(),c=await k(e),l=await new Promise(((e,n)=>{const t=new FileReader;t.onload=()=>{const n=t.result;e(n.split(",")[1])},t.onerror=n,t.readAsDataURL(c)}));try{const e={biometric_data:l,type_of_identification:"FACE",purpose:t,confidence_threshold:o};a&&(e.signature=a);const c=await fetch(`${x}/api/v1/external/recognition/purpose/`,{method:"POST",headers:{"Content-Type":"application/json","X-App-Token":n},body:JSON.stringify(e),signal:s.signal});if(!c.ok){if(401===c.status||403===c.status)throw new v("Invalid or expired application token",y.INVALID_TOKEN);throw new v(`Server returned status ${c.status}`,y.NETWORK)}const d=await c.json();return{success:d.success,personName:d.person_name||(null==(i=d.person)?void 0:i.name),email:d.email||(null==r?void 0:r.email),cpf:d.cpf||(null==r?void 0:r.cpf),confidenceScore:d.confidence_score,accessToken:d.access_token,payload:d.payload,signature:a,sessionId:null==r?void 0:r.sessionId}}catch(d){if(d instanceof Error){if("AbortError"===d.name)throw new v("Request timed out",y.NETWORK);if(d instanceof v)throw d;throw new v(d.message,y.NETWORK)}throw new v("Unknown error occurred",y.NETWORK_ERROR)}},S=async(e,n,t)=>{var o,a,r,i,s,c,l,d;if(E(),!n||0===n.length)throw new v("At least one face photo is required for biometric registration",y.VALIDATION_ERROR);if(n.length>5)throw new v("Maximum of 5 face photos allowed",y.VALIDATION_ERROR);const u=R();try{const f=await Promise.all(n.map((async e=>{const n=await k(e);return new Promise(((e,t)=>{const o=new FileReader;o.onload=()=>{const n=o.result;e(n)},o.onerror=t,o.readAsDataURL(n)}))}))),h=await fetch(`${x}/api/v1/signup/donor/`,{method:"POST",headers:{"Content-Type":"application/json","X-App-Token":t},body:JSON.stringify({name:e.name,birth_date:e.birth_date,cpf:e.cpf,email:e.email,password:e.password,password_confirm:e.password,face_photos:f}),signal:u.signal});if(!h.ok){if(401===h.status||403===h.status)throw new v("Invalid or expired application token",y.INVALID_TOKEN);try{const e=await h.json();if(e.errors){const n=Object.entries(e.errors).map((([e,n])=>`${"password"===e?"senha":"password_confirm"===e?"confirmação de senha":e}: ${Array.isArray(n)?n.join(", "):String(n)}`)).join("; ");throw new v(`Erro de validação: ${n}`,y.VALIDATION_ERROR)}if("fraud_detected"===e.error)throw new v("Fraud detected in biometric images. Registration blocked.",y.VALIDATION_ERROR);if("user_exists"===e.error||"ALREADY_EXISTS"===e.error_code)throw new v("User with this email already exists",y.VALIDATION_ERROR);if("person_exists"===e.error)throw new v("Person with this CPF already exists",y.VALIDATION_ERROR);const n=e.message||e.error||`Server returned status ${h.status}`;throw new v(n,y.VALIDATION_ERROR)}catch(p){if(p instanceof v)throw p;throw new v(`Server returned status ${h.status}`,y.NETWORK)}}const m=await h.json();return 202===h.status&&(null==(o=m.data)?void 0:o.task_id)?{success:m.success,message:m.message||"Registration is being processed. You will receive an email when completed.",task_id:m.data.task_id,status:m.data.status||"processing",person_id:void 0,user_id:void 0,person_validated:void 0,face_processing:void 0,onboarding_link:void 0}:{success:m.success,message:m.message,person_id:(null==(a=m.data)?void 0:a.person_id)||m.person_id,user_id:(null==(r=m.data)?void 0:r.user_id)||m.user_id,person_validated:(null==(i=m.data)?void 0:i.person_validated)||m.person_validated,face_processing:(null==(s=m.data)?void 0:s.face_processing)||m.face_processing,onboarding_link:(null==(c=m.data)?void 0:c.onboarding_link)||m.onboarding_link,task_id:null==(l=m.data)?void 0:l.task_id,status:null==(d=m.data)?void 0:d.status}}catch(f){if(f instanceof Error){if("AbortError"===f.name)throw new v("Request timed out",y.NETWORK);if(f instanceof v)throw f;throw new v(f.message,y.NETWORK)}throw new v("Unknown error occurred",y.NETWORK_ERROR)}},A=(e,n)=>{switch(n.type){case"PERMISSION_GRANTED":case"RESET":return{status:"ready"};case"PERMISSION_DENIED":return{status:"error",message:"Permissão para acessar a câmera foi negada"};case"START_CAPTURE":return{status:"capturing"};case"UPLOAD_START":return{status:"uploading"};case"UPLOAD_SUCCESS":return{status:"success"};case"UPLOAD_ERROR":case"SET_ERROR":return{status:"error",message:n.message};default:return e}},j={overlay:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.8)",display:"flex",justifyContent:"center",alignItems:"center",zIndex:1e3},modal:{backgroundColor:"#000",borderRadius:"12px",overflow:"hidden",position:"relative",width:"60%",maxWidth:"600px",maxHeight:"80vh"},video:{width:"100%",height:"auto",display:"block"},canvas:{display:"none"},guide:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:"200px",height:"200px",border:"2px solid rgba(255, 255, 255, 0.5)",borderRadius:"50%",pointerEvents:"none"},controls:{position:"absolute",bottom:"20px",left:0,right:0,display:"flex",justifyContent:"center",gap:"10px"},button:{padding:"12px 24px",borderRadius:"24px",border:"none",backgroundColor:"#007AFF",color:"white",fontSize:"16px",fontWeight:"bold",cursor:"pointer"},message:{position:"absolute",top:"20px",left:0,right:0,textAlign:"center",color:"white",fontSize:"18px",fontWeight:"bold"},spinner:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:"40px",height:"40px",border:"4px solid rgba(255, 255, 255, 0.3)",borderRadius:"50%",borderTopColor:"white",animation:"spin 1s linear infinite"},closeButton:{position:"absolute",top:"20px",right:"20px",backgroundColor:"transparent",border:"none",color:"white",fontSize:"24px",cursor:"pointer"}};function C({accessToken:e,onClose:t,onSuccess:o}){const a=n.useRef(null),r=n.useRef(null),s=n.useRef(null),c=n.useRef(null),l=n.useRef(null),[d,u]=n.useReducer(A,{status:"requestingPermission"}),[p,f]=n.useState(!1),[h,g]=n.useState(0),{startCamera:w,stopCamera:y}=b(),v=()=>{if(!a.current)return;const e=async()=>{if(a.current&&"ready"===d.status){try{const e=await i.detectAllFaces(a.current,new i.TinyFaceDetectorOptions),n=1===e.length,t=n&&(e=>{if(!a.current)return!1;const{box:n}=e,{videoWidth:t,videoHeight:o}=a.current,r=t/2,i=o/2,s=.4*t,c=.4*o;return n.x+n.width/2>r-s/2&&n.x+n.width/2<r+s/2&&n.y+n.height/2>i-c/2&&n.y+n.height/2<i+c/2})(e[0]);f(n&&t),n&&t&&0===h&&(l.current=window.setTimeout((()=>{"ready"===d.status&&(g((e=>e+1)),u({type:"START_CAPTURE"}))}),3e3))}catch(n){}c.current=window.setTimeout(e,100)}};e()};n.useEffect((()=>((async()=>{try{await Promise.all([i.nets.tinyFaceDetector.loadFromUri("./models"),i.nets.faceLandmark68Net.loadFromUri("./models")])}catch(e){}})(),()=>{c.current&&window.clearTimeout(c.current),l.current&&window.clearInterval(l.current)})),[]),n.useEffect((()=>((async()=>{try{const e=await w();s.current=e,a.current&&(a.current.srcObject=e),u({type:"PERMISSION_GRANTED"}),v()}catch(e){u({type:"PERMISSION_DENIED"})}})(),()=>{s.current&&y(s.current)})),[w,y]);const x=async()=>{if(r.current&&a.current)try{u({type:"START_CAPTURE"});const i=r.current.getContext("2d");if(!i)return void u({type:"SET_ERROR",message:"Failed to get canvas context"});r.current.width=a.current.videoWidth,r.current.height=a.current.videoHeight,i.drawImage(a.current,0,0,r.current.width,r.current.height);const s=await new Promise(((e,n)=>{var t;null==(t=r.current)||t.toBlob((t=>{t?e(t):n(new Error("Failed to convert canvas to blob"))}),"image/jpeg",.95)}));try{const n=await O(s,e);o({success:!0,data:{faceId:n.payload.documentId,confidence:1}}),u({type:"UPLOAD_SUCCESS"}),setTimeout(t,1500)}catch(n){u({type:"SET_ERROR",message:"Face recognition failed"})}}catch(n){u({type:"SET_ERROR",message:"Failed to capture image"})}};return m.jsxs("div",{style:j.overlay,children:[m.jsx("style",{children:"\n @keyframes spin {\n 0% { transform: translate(-50%, -50%) rotate(0deg); }\n 100% { transform: translate(-50%, -50%) rotate(360deg); }\n }\n"}),m.jsx("style",{children:"\n @media (max-width: 768px) {\n .modal {\n width: 100%;\n height: 100%;\n max-height: 100vh;\n border-radius: 0;\n }\n .button {\n padding: 16px 32px;\n font-size: 18px;\n }\n }\n"}),m.jsxs("div",{style:j.modal,className:"modal",children:[m.jsx("button",{type:"button",style:j.closeButton,onClick:t,children:"×"}),m.jsx("video",{ref:a,style:j.video,autoPlay:!0,playsInline:!0,muted:!0}),m.jsx("canvas",{ref:r,style:j.canvas}),m.jsx("div",{style:j.guide}),"ready"===d.status&&!p&&m.jsx("div",{style:j.message,children:"Centralize seu rosto no círculo"}),"capturing"===d.status&&m.jsx("div",{style:j.message,children:"Por favor, pisque os olhos"}),"uploading"===d.status&&m.jsx("div",{style:j.spinner}),"success"===d.status&&m.jsx("div",{style:j.message,children:"Autenticado!"}),"error"===d.status&&m.jsx("div",{style:j.message,children:d.message}),m.jsxs("div",{style:j.controls,children:["ready"===d.status&&p&&m.jsx("button",{type:"button",style:j.button,onClick:x,children:"Capturar"}),"capturing"===d.status&&m.jsx("button",{type:"button",style:j.button,onClick:x,children:"Capturar"}),"error"===d.status&&m.jsx("button",{type:"button",style:j.button,onClick:()=>{u({type:"RESET"}),g(0)},children:"Tentar Novamente"})]})]})]})}const F=(e,n)=>{switch(n.type){case"START_LIVENESS":return{status:"liveness",step:n.stepSequence[0],capturedPhotos:[],stepSequence:n.stepSequence,currentStepIndex:0,stepProgress:0};case"NEXT_STEP":if("liveness"===e.status){const t=n.photo?[...e.capturedPhotos,n.photo]:e.capturedPhotos;return{status:"liveness",step:n.step,capturedPhotos:t,stepSequence:e.stepSequence,currentStepIndex:e.currentStepIndex+1,stepProgress:0}}return e;case"UPDATE_PROGRESS":return"liveness"===e.status?{...e,stepProgress:n.progress}:e;case"START_PROCESSING":return{status:"processing"};case"SUCCESS":return{status:"success"};case"ERROR":return{status:"error",message:n.message};case"RESET":return D;default:return e}},P={center:"Posicione seu rosto no centro",up:"Incline a cabeça para cima",down:"Incline a cabeça para baixo",left:"Vire o rosto para a esquerda",right:"Vire o rosto para a direita",complete:"Processando..."},D=(()=>{const e=["center","up","down","left","right","complete"];return{status:"liveness",step:e[0],capturedPhotos:[],stepSequence:e,currentStepIndex:0,stepProgress:0}})(),L=8,U=10,W=26,M=8,q=-8,K=15,z=-15,$=1500,B=200;function V({personData:e,applicationToken:t,onClose:o,onSuccess:a,onError:r,useRealApi:s=!0}){const c=n.useRef(null),l=n.useRef(null),d=n.useRef(null),u=n.useRef(null),p=n.useRef(null),f=n.useRef(!1),h=n.useRef("center"),g=n.useRef(null),[w,b]=n.useReducer(F,D),[y,v]=n.useState(!1),[x,E]=n.useState("ok");n.useEffect((()=>{if("liveness"===w.status){const e=w.step;h.current!==e&&(h.current=e,f.current||(u.current&&(u.current=null),p.current&&(clearInterval(p.current),p.current=null),b({type:"UPDATE_PROGRESS",progress:0}))),g.current={stepSequence:w.stepSequence,currentStepIndex:w.currentStepIndex,capturedPhotos:w.capturedPhotos}}}),[w.status,"liveness"===w.status&&w.step,"liveness"===w.status&&w.currentStepIndex]);n.useEffect((()=>{(async()=>{try{const e="https://cdn.jsdelivr.net/npm/@vladmandic/face-api/model";await Promise.all([i.nets.tinyFaceDetector.loadFromUri(e),i.nets.faceLandmark68Net.loadFromUri(e)])}catch(e){b({type:"ERROR",message:"Erro ao carregar modelos de IA"})}})()}),[]),n.useEffect((()=>{let e=!0;return(async()=>{if("liveness"===w.status&&!d.current)try{const n=await navigator.mediaDevices.getUserMedia({video:{width:{ideal:640},height:{ideal:480},facingMode:"user"}});if(!e)return void n.getTracks().forEach((e=>e.stop()));const t=async()=>{let e=0;for(;!c.current&&e<50;)await new Promise((e=>setTimeout(e,100))),e++;return c.current},o=await t();if(!o)throw new Error("Elemento de vídeo não encontrado");o.srcObject=n,d.current=n,await o.play()}catch(n){if(!e)return;const t=n instanceof Error?n.message:"Erro ao acessar câmera";b({type:"ERROR",message:t})}})(),()=>{e=!1,d.current&&(d.current.getTracks().forEach((e=>e.stop())),d.current=null),p.current&&(clearInterval(p.current),p.current=null),u.current=null}}),[w.status]),n.useEffect((()=>{if("liveness"!==w.status||!c.current)return;let e=!0,n=0;const t=async()=>{if(!e||"liveness"!==w.status)return;if(f.current||"complete"===h.current)return void requestAnimationFrame(t);const o=Date.now();if(o-n<B)requestAnimationFrame(t);else{n=o;try{const n=await i.detectSingleFace(c.current,new i.TinyFaceDetectorOptions({inputSize:160,scoreThreshold:.4})).withFaceLandmarks();if(!e)return;const t=!!n;if(v(t),t&&n.detection){const e=n.detection.box.width;E(e>250?"too-close":e<120?"too-far":"ok")}if(t&&n.landmarks){const e=(e=>{try{const n=e.positions||e._positions;if(!Array.isArray(n)||n.length<68)return null;const t=e=>{const t=n[e];return{x:void 0!==t._x?t._x:t.x,y:void 0!==t._y?t._y:t.y}},o=t(30),a=t(8),r=t(36),i=t(45),s=(r.x+i.x)/2,c=(o.x-s)/Math.abs(i.x-r.x)*90,l=(r.y+i.y)/2,d=o.y-l,u=-d/Math.abs(a.y-l)*90+W;return{pitch:Math.round(u),yaw:Math.round(c)}}catch(n){return null}})(n.landmarks);if(e){(e=>{if(f.current||"complete"===h.current)return;const n=Date.now();e?u.current||(u.current=n,p.current&&clearInterval(p.current),p.current=window.setInterval((()=>{if(!u.current)return;const e=Date.now()-u.current,n=Math.min(e/$*100,100);b({type:"UPDATE_PROGRESS",progress:n}),n>=100&&(clearInterval(p.current),p.current=null,R())}),50)):u.current&&(u.current=null,p.current&&(clearInterval(p.current),p.current=null),b({type:"UPDATE_PROGRESS",progress:0}))})(((e,n,t)=>{switch(t){case"center":return Math.abs(e)<L&&Math.abs(n)<U;case"up":return e>M;case"down":return e<q;case"left":return n>K;case"right":return n<z;default:return!1}})(e.pitch,e.yaw,h.current))}}else u.current&&(u.current=null,p.current&&(clearInterval(p.current),p.current=null),b({type:"UPDATE_PROGRESS",progress:0}))}catch(a){}e&&"liveness"===w.status&&requestAnimationFrame(t)}},o=setTimeout((()=>{var n;e&&4===(null==(n=c.current)?void 0:n.readyState)&&t()}),1e3);return()=>{e=!1,clearTimeout(o),p.current&&(clearInterval(p.current),p.current=null),u.current=null}}),[w.status]);const R=async()=>{if(!c.current||!l.current||f.current)return;f.current=!0,u.current=null;const e=g.current;if(!e)return void(f.current=!1);const n=l.current,t=c.current,o=n.getContext("2d");o?(n.width=t.videoWidth,n.height=t.videoHeight,o.scale(-1,1),o.drawImage(t,-n.width,0,n.width,n.height),n.toBlob((n=>{if(!n)return void(f.current=!1);const t=e.currentStepIndex+1,o=e.stepSequence[t];if("complete"===o){const t=[...e.capturedPhotos,n];b({type:"START_PROCESSING"}),k(t)}else setTimeout((()=>{f.current=!1,b({type:"NEXT_STEP",step:o,photo:n})}),100)}),"image/jpeg",.85)):f.current=!1},k=async n=>{try{const o=await S(e,n,t),r={success:o.success,message:o.message,person_id:o.person_id,user_id:o.user_id,person_validated:o.person_validated,face_processing:o.face_processing,onboarding_link:o.onboarding_link};b({type:"SUCCESS"}),a(r)}catch(o){const e=o instanceof Error?o.message:"Erro desconhecido";b({type:"ERROR",message:e}),r(e)}};return m.jsxs(m.Fragment,{children:[m.jsx("style",{children:"\n @keyframes fadeIn {\n from { opacity: 0; transform: scale(0.95); }\n to { opacity: 1; transform: scale(1); }\n }\n\n @keyframes slideUp {\n from { opacity: 0; transform: translateY(20px); }\n to { opacity: 1; transform: translateY(0); }\n }\n\n @keyframes slideDown {\n from { opacity: 0; transform: translateY(-10px); }\n to { opacity: 1; transform: translateY(0); }\n }\n\n @keyframes spin {\n from { transform: rotate(0deg); }\n to { transform: rotate(360deg); }\n }\n\n @keyframes pulseRing {\n 0%, 100% { \n box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.8), 0 0 40px rgba(16, 185, 129, 0.4);\n }\n 50% { \n box-shadow: 0 0 0 6px rgba(16, 185, 129, 0.9), 0 0 50px rgba(16, 185, 129, 0.5);\n }\n }\n\n @keyframes checkmark {\n 0% {\n stroke-dashoffset: 100;\n }\n 100% {\n stroke-dashoffset: 0;\n }\n }\n\n @keyframes scaleIn {\n 0% {\n transform: scale(0);\n opacity: 0;\n }\n 50% {\n transform: scale(1.1);\n }\n 100% {\n transform: scale(1);\n opacity: 1;\n }\n }\n\n @keyframes scanRing {\n 0%, 100% { transform: scale(1); opacity: 0.3; }\n 50% { transform: scale(1.1); opacity: 0.6; }\n }\n\n @keyframes cornerBlink {\n 0%, 100% { opacity: 0.3; }\n 50% { opacity: 1; }\n }\n\n .modal-overlay {\n position: fixed;\n inset: 0;\n background: rgba(0, 0, 0, 0.92);\n backdrop-filter: blur(8px);\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 9999;\n padding: 20px;\n }\n\n .modal-content {\n background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);\n border-radius: 24px;\n width: 100%;\n max-width: 420px;\n max-height: 90vh;\n overflow: hidden;\n box-shadow: 0 24px 48px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.1);\n animation: fadeIn 0.3s ease-out;\n position: relative;\n }\n\n .close-button {\n position: absolute;\n top: 20px;\n right: 20px;\n width: 32px;\n height: 32px;\n background: transparent;\n border: none;\n color: rgba(255, 255, 255, 0.6);\n font-size: 28px;\n font-weight: 300;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: all 0.2s;\n z-index: 10;\n line-height: 1;\n }\n\n .close-button:hover {\n color: rgba(255, 255, 255, 0.9);\n transform: rotate(90deg);\n }\n\n /* Instructions Screen */\n .instructions-container {\n padding: 60px 40px 40px;\n color: white;\n text-align: center;\n animation: slideUp 0.4s ease-out;\n }\n\n .instructions-header {\n margin-bottom: 40px;\n }\n\n .icon-wrapper {\n display: inline-block;\n color: #7c3aed;\n margin-bottom: 24px;\n }\n\n .icon-wrapper .scan-ring {\n animation: scanRing 2s ease-in-out infinite;\n }\n\n .icon-wrapper .corner {\n animation: cornerBlink 2s ease-in-out infinite;\n }\n\n .icon-wrapper .corner.tl { animation-delay: 0s; }\n .icon-wrapper .corner.tr { animation-delay: 0.5s; }\n .icon-wrapper .corner.bl { animation-delay: 1s; }\n .icon-wrapper .corner.br { animation-delay: 1.5s; }\n\n .instructions-header h2 {\n font-size: 28px;\n font-weight: 700;\n margin: 0 0 12px 0;\n background: linear-gradient(135deg, #7c3aed 0%, #a78bfa 100%);\n -webkit-background-clip: text;\n -webkit-text-fill-color: transparent;\n background-clip: text;\n }\n\n .subtitle {\n font-size: 15px;\n color: rgba(255, 255, 255, 0.7);\n margin: 0;\n line-height: 1.5;\n }\n\n .requirements-list {\n text-align: left;\n margin: 0 auto 40px;\n max-width: 360px;\n }\n\n .requirement-item {\n display: flex;\n align-items: center;\n gap: 16px;\n padding: 14px 0;\n font-size: 15px;\n color: rgba(255, 255, 255, 0.9);\n border-bottom: 1px solid rgba(255, 255, 255, 0.05);\n }\n\n .requirement-item:last-child {\n border-bottom: none;\n }\n\n .req-icon {\n width: 32px;\n height: 32px;\n border-radius: 50%;\n display: flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n }\n\n .req-icon.success {\n background: rgba(16, 185, 129, 0.15);\n color: #10b981;\n border: 1.5px solid rgba(16, 185, 129, 0.3);\n }\n\n .primary-button {\n width: 100%;\n padding: 16px 32px;\n border-radius: 12px;\n border: none;\n background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);\n color: white;\n font-size: 16px;\n font-weight: 600;\n cursor: pointer;\n transition: all 0.3s;\n box-shadow: 0 4px 16px rgba(124, 58, 237, 0.3);\n }\n\n .primary-button:hover {\n transform: translateY(-2px);\n box-shadow: 0 8px 24px rgba(124, 58, 237, 0.4);\n }\n\n .primary-button:active {\n transform: translateY(0);\n }\n\n .branding {\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 8px;\n margin-top: 32px;\n padding-top: 24px;\n border-top: 1px solid rgba(255, 255, 255, 0.1);\n font-size: 13px;\n color: rgba(255, 255, 255, 0.5);\n }\n\n .brand-logo {\n height: 20px;\n width: auto;\n }\n\n .brand-name {\n font-weight: 600;\n font-family: 'SF Pro Display', -apple-system, system-ui, sans-serif;\n color: #ffffff;\n letter-spacing: 0.3px;\n }\n\n /* Liveness Detection */\n .liveness-container {\n height: 100%;\n min-height: 520px;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n padding: 70px 20px 80px;\n position: relative;\n animation: fadeIn 0.3s ease-out;\n }\n\n .progress-indicator {\n position: absolute;\n top: 20px;\n left: 50%;\n transform: translateX(-50%);\n background: rgba(255, 255, 255, 0.08);\n backdrop-filter: blur(12px);\n border-radius: 20px;\n padding: 8px 20px;\n border: 1px solid rgba(255, 255, 255, 0.12);\n z-index: 5;\n }\n\n .progress-text {\n font-size: 14px;\n font-weight: 600;\n color: white;\n }\n\n .video-wrapper {\n position: relative;\n margin: 20px 0;\n }\n\n .video-circle {\n width: 320px;\n height: 400px;\n border-radius: 50%;\n overflow: hidden;\n position: relative;\n transition: all 0.3s ease;\n box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.3);\n }\n\n .video-circle.face-detected {\n box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.5), 0 0 40px rgba(16, 185, 129, 0.3);\n }\n\n .video-circle.capturing {\n box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.9), 0 0 40px rgba(16, 185, 129, 0.5);\n transition: box-shadow 0.3s ease;\n }\n\n .video-feed {\n width: 100%;\n height: 100%;\n object-fit: cover;\n transform: scaleX(-1);\n }\n\n .face-badge {\n position: absolute;\n top: 20px;\n left: 50%;\n transform: translateX(-50%);\n background: rgba(16, 185, 129, 0.95);\n backdrop-filter: blur(10px);\n border-radius: 20px;\n padding: 8px 16px;\n display: flex;\n align-items: center;\n gap: 8px;\n color: white;\n font-size: 13px;\n font-weight: 600;\n border: 1px solid rgba(255, 255, 255, 0.3);\n box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);\n animation: slideDown 0.3s ease-out;\n }\n\n .face-badge.warning {\n background: rgba(251, 191, 36, 0.95);\n border: 1px solid rgba(255, 255, 255, 0.3);\n box-shadow: 0 4px 12px rgba(251, 191, 36, 0.3);\n color: #78350f;\n }\n\n .face-badge.error {\n background: rgba(239, 68, 68, 0.95);\n border: 1px solid rgba(255, 255, 255, 0.3);\n box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);\n color: white;\n }\n\n .instruction-box {\n background: rgba(255, 255, 255, 0.08);\n backdrop-filter: blur(12px);\n border-radius: 16px;\n padding: 16px 24px;\n margin-top: 20px;\n border: 1px solid rgba(255, 255, 255, 0.12);\n max-width: 320px;\n animation: slideUp 0.3s ease-out;\n }\n\n .instruction-text {\n font-size: 18px;\n font-weight: 600;\n color: white;\n margin: 0 0 12px 0;\n text-align: center;\n }\n\n .progress-bar {\n height: 4px;\n background: rgba(255, 255, 255, 0.2);\n border-radius: 2px;\n overflow: hidden;\n }\n\n .progress-fill {\n height: 100%;\n background: linear-gradient(90deg, #7c3aed 0%, #10b981 100%);\n border-radius: 2px;\n transition: width 0.05s linear;\n }\n\n .branding-small {\n position: absolute;\n bottom: 24px;\n left: 50%;\n transform: translateX(-50%);\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 5px;\n font-size: 12px;\n color: rgba(255, 255, 255, 0.5);\n }\n\n .brand-logo-small {\n height: 18px;\n width: 18px;\n }\n\n /* Processing */\n .processing-container {\n padding: 80px 40px;\n text-align: center;\n color: white;\n animation: fadeIn 0.3s ease-out;\n }\n\n .spinner-wrapper {\n position: relative;\n width: 80px;\n height: 80px;\n margin: 0 auto 32px;\n }\n\n .spinner {\n position: absolute;\n inset: 0;\n border: 4px solid rgba(124, 58, 237, 0.2);\n border-top-color: #7c3aed;\n border-radius: 50%;\n animation: spin 1s linear infinite;\n }\n\n .spinner-ring {\n position: absolute;\n inset: -10px;\n border: 2px solid rgba(124, 58, 237, 0.1);\n border-radius: 50%;\n animation: pulseSpinner 2s ease-in-out infinite;\n }\n\n @keyframes pulseSpinner {\n 0%, 100% { transform: scale(1); opacity: 1; }\n 50% { transform: scale(1.1); opacity: 0.5; }\n }\n\n .processing-container h3 {\n font-size: 24px;\n font-weight: 700;\n margin: 0 0 12px 0;\n }\n\n .processing-container p {\n font-size: 15px;\n color: rgba(255, 255, 255, 0.7);\n margin: 0;\n }\n\n /* Result Screens */\n .result-container {\n padding: 80px 40px 40px;\n text-align: center;\n color: white;\n animation: slideUp 0.4s ease-out;\n }\n\n .result-icon {\n display: inline-flex;\n margin-bottom: 24px;\n }\n\n .success-icon {\n color: #10b981;\n animation: scaleIn 0.6s ease-out;\n }\n\n .success-icon svg circle {\n animation: scaleIn 0.5s ease-out;\n }\n\n .success-icon svg path {\n stroke-dasharray: 100;\n stroke-dashoffset: 100;\n animation: checkmark 0.6s ease-out 0.3s forwards;\n }\n\n .error-icon {\n color: #ef4444;\n animation: fadeIn 0.5s ease-out;\n }\n\n .result-container h3 {\n font-size: 26px;\n font-weight: 700;\n margin: 0 0 12px 0;\n }\n\n .result-container p {\n font-size: 15px;\n color: rgba(255, 255, 255, 0.7);\n margin: 0 0 32px 0;\n line-height: 1.5;\n }\n\n .button-group {\n display: flex;\n gap: 12px;\n margin-top: 32px;\n }\n\n .secondary-button {\n flex: 1;\n padding: 14px 24px;\n border-radius: 12px;\n border: 1px solid rgba(255, 255, 255, 0.2);\n background: rgba(255, 255, 255, 0.1);\n color: white;\n font-size: 15px;\n font-weight: 600;\n cursor: pointer;\n transition: all 0.2s;\n }\n\n .secondary-button:hover {\n background: rgba(255, 255, 255, 0.15);\n border-color: rgba(255, 255, 255, 0.3);\n }\n\n .ghost-button {\n flex: 1;\n padding: 14px 24px;\n border-radius: 12px;\n border: none;\n background: transparent;\n color: rgba(255, 255, 255, 0.7);\n font-size: 15px;\n font-weight: 600;\n cursor: pointer;\n transition: all 0.2s;\n }\n\n .ghost-button:hover {\n color: white;\n background: rgba(255, 255, 255, 0.05);\n }\n\n /* Canvas */\n canvas {\n display: none;\n }\n\n /* Responsive */\n @media (max-width: 640px) {\n .modal-content {\n max-width: 100%;\n border-radius: 0;\n max-height: 100vh;\n }\n\n .instructions-container {\n padding: 50px 24px 24px;\n }\n\n .instructions-header h2 {\n font-size: 24px;\n }\n\n .video-circle {\n width: 280px;\n height: 350px;\n }\n\n .liveness-container {\n min-height: 100vh;\n }\n }\n "}),m.jsx("div",{className:"modal-overlay",children:m.jsxs("div",{className:"modal-content",children:[m.jsx("button",{className:"close-button",onClick:o,children:"×"}),"liveness"===w.status&&(()=>{if("liveness"!==w.status)return null;const e=`${w.currentStepIndex+1}/${w.stepSequence.length-1}`,n=w.stepProgress;return m.jsxs("div",{className:"liveness-container",children:[m.jsx("div",{className:"progress-indicator",children:m.jsx("span",{className:"progress-text",children:e})}),m.jsx("div",{className:"video-wrapper",children:m.jsxs("div",{className:`video-circle ${y?"face-detected":""} ${n>0?"capturing":""}`,children:[m.jsx("video",{ref:c,className:"video-feed",autoPlay:!0,muted:!0,playsInline:!0}),y&&m.jsxs("div",{className:"face-badge",children:[m.jsx("svg",{width:"16",height:"16",viewBox:"0 0 20 20",fill:"none",children:m.jsx("path",{d:"M5 10 L8 13 L15 6",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"})}),m.jsx("span",{children:"Rosto detectado"})]})]})}),m.jsxs("div",{className:"instruction-box",children:[m.jsx("p",{className:"instruction-text",children:P[w.step]}),n>0&&m.jsx("div",{className:"progress-bar",children:m.jsx("div",{className:"progress-fill",style:{width:`${n}%`}})})]}),m.jsxs("div",{className:"branding-small",children:[m.jsx("img",{src:"/public/logo-icone.png",alt:"NeoFaceId",className:"brand-logo-small"}),m.jsx("span",{children:"NeoFaceId by"}),m.jsx("span",{className:"brand-name",children:"OCTA"})]})]})})(),"processing"===w.status&&m.jsxs("div",{className:"processing-container",children:[m.jsxs("div",{className:"spinner-wrapper",children:[m.jsx("div",{className:"spinner"}),m.jsx("div",{className:"spinner-ring"})]}),m.jsx("h3",{children:"Processando biometria"}),m.jsx("p",{children:"Analisando suas capturas faciais..."}),m.jsxs("div",{className:"branding",style:{marginTop:"40px",paddingTop:"24px",borderTop:"1px solid rgba(255, 255, 255, 0.1)"},children:[m.jsx("span",{children:"NeoFaceId by"}),m.jsx("span",{className:"brand-name",children:"OCTA"})]})]}),"error"===w.status&&("error"!==w.status?null:m.jsxs("div",{className:"result-container error",children:[m.jsx("div",{className:"result-icon error-icon",children:m.jsxs("svg",{width:"60",height:"60",viewBox:"0 0 60 60",fill:"none",children:[m.jsx("circle",{cx:"30",cy:"30",r:"28",stroke:"currentColor",strokeWidth:"3"}),m.jsx("path",{d:"M20 20 L40 40 M40 20 L20 40",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round"})]})}),m.jsx("h3",{children:"Não foi possível concluir"}),m.jsx("p",{children:w.message}),m.jsxs("div",{className:"button-group",children:[m.jsx("button",{className:"secondary-button",onClick:()=>b({type:"RESET"}),children:"Tentar Novamente"}),m.jsx("button",{className:"ghost-button",onClick:o,children:"Cancelar"})]})]})),"success"===w.status&&m.jsxs("div",{className:"result-container success",children:[m.jsx("div",{className:"result-icon success-icon",children:m.jsxs("svg",{width:"60",height:"60",viewBox:"0 0 60 60",fill:"none",children:[m.jsx("circle",{cx:"30",cy:"30",r:"28",stroke:"currentColor",strokeWidth:"3"}),m.jsx("path",{d:"M15 30 L25 40 L45 20",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round"})]})}),m.jsx("h3",{children:"Verificação concluída!"}),m.jsx("p",{children:"Sua biometria foi registrada com sucesso"}),m.jsx("button",{className:"primary-button",onClick:o,children:"Continuar"})]})]})}),m.jsx("canvas",{ref:l})]})}function X({status:e,onClose:t}){const[o,a]=n.useState(!0);return n.useEffect((()=>{if("success"===e){const e=setTimeout((()=>{a(!1),setTimeout((()=>{null==t||t()}),300)}),800);return()=>clearTimeout(e)}}),[e,t]),o?m.jsxs(m.Fragment,{children:[m.jsx("style",{children:"\n @keyframes fadeIn {\n from { opacity: 0; transform: scale(0.9); }\n to { opacity: 1; transform: scale(1); }\n }\n\n @keyframes fadeOut {\n from { opacity: 1; transform: scale(1); }\n to { opacity: 0; transform: scale(0.9); }\n }\n\n @keyframes pulse {\n 0%, 100% { \n transform: scale(1);\n opacity: 1;\n }\n 50% { \n transform: scale(1.1);\n opacity: 0.9;\n }\n }\n\n @keyframes spin {\n from { transform: rotate(0deg); }\n to { transform: rotate(360deg); }\n }\n\n @keyframes checkmark {\n 0% {\n stroke-dashoffset: 100;\n opacity: 0;\n }\n 50% {\n opacity: 1;\n }\n 100% {\n stroke-dashoffset: 0;\n opacity: 1;\n }\n }\n\n @keyframes errorShake {\n 0%, 100% { transform: translateX(0) scale(1); }\n 10%, 30%, 50%, 70%, 90% { transform: translateX(-4px) scale(1); }\n 20%, 40%, 60%, 80% { transform: translateX(4px) scale(1); }\n }\n\n @keyframes scaleIn {\n 0% {\n transform: scale(0);\n opacity: 0;\n }\n 50% {\n transform: scale(1.1);\n }\n 100% {\n transform: scale(1);\n opacity: 1;\n }\n }\n\n .neofaceid-overlay-container {\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 10000;\n pointer-events: none;\n animation: fadeIn 0.3s ease-out;\n }\n\n .neofaceid-overlay-container.fade-out {\n animation: fadeOut 0.3s ease-out;\n }\n\n .neofaceid-overlay-content {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n gap: 24px;\n pointer-events: auto;\n }\n\n .neofaceid-logo-wrapper {\n position: relative;\n width: 120px;\n height: 120px;\n display: flex;\n align-items: center;\n justify-content: center;\n }\n\n .neofaceid-logo {\n width: 80px;\n height: 80px;\n object-fit: contain;\n filter: drop-shadow(0 4px 12px rgba(124, 58, 237, 0.3));\n }\n\n .neofaceid-logo.pulsing {\n animation: pulse 2s ease-in-out infinite;\n }\n\n .neofaceid-status-icon {\n position: absolute;\n inset: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n }\n\n .neofaceid-success-icon {\n width: 60px;\n height: 60px;\n color: #10b981;\n animation: scaleIn 0.6s ease-out;\n }\n\n .neofaceid-success-icon svg circle {\n stroke-dasharray: 100;\n stroke-dashoffset: 100;\n animation: checkmark 0.6s ease-out 0.2s forwards;\n }\n\n .neofaceid-error-icon {\n width: 60px;\n height: 60px;\n color: #ef4444;\n animation: errorShake 0.5s ease-out, scaleIn 0.4s ease-out;\n }\n\n /* Responsive */\n @media (max-width: 640px) {\n .neofaceid-logo-wrapper {\n width: 100px;\n height: 100px;\n }\n\n .neofaceid-logo {\n width: 70px;\n height: 70px;\n }\n }\n "}),m.jsx("div",{className:"neofaceid-overlay-container "+(o?"":"fade-out"),children:m.jsx("div",{className:"neofaceid-overlay-content",children:m.jsxs("div",{className:"neofaceid-logo-wrapper",children:[("preparing"===e||"verifying"===e)&&m.jsx(m.Fragment,{children:m.jsx("img",{src:"/public/logo-icone-no-backgorund.png",alt:"NeoFaceId",className:"neofaceid-logo "+("verifying"===e?"pulsing":""),onError:e=>{var n;const t=e.target;t.style.display="none";const o=document.createElement("div");o.innerHTML='\n <svg width="80" height="80" viewBox="0 0 80 80" fill="none" xmlns="http://www.w3.org/2000/svg">\n <circle cx="40" cy="40" r="35" fill="#7c3aed" opacity="0.2"/>\n <path d="M40 20 L40 60 M20 40 L60 40" stroke="#7c3aed" stroke-width="4" stroke-linecap="round"/>\n </svg>\n ',o.style.cssText="width: 80px; height: 80px; display: flex; align-items: center; justify-content: center;",null==(n=t.parentElement)||n.appendChild(o)}})}),"success"===e&&m.jsx("div",{className:"neofaceid-status-icon",children:m.jsxs("svg",{className:"neofaceid-success-icon",viewBox:"0 0 60 60",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[m.jsx("circle",{cx:"30",cy:"30",r:"28",stroke:"currentColor",strokeWidth:"3",fill:"none"}),m.jsx("path",{d:"M15 30 L25 40 L45 20",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})]})}),"error"===e&&m.jsx("div",{className:"neofaceid-status-icon",children:m.jsxs("svg",{className:"neofaceid-error-icon",viewBox:"0 0 60 60",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[m.jsx("circle",{cx:"30",cy:"30",r:"28",stroke:"currentColor",strokeWidth:"3",fill:"none"}),m.jsx("path",{d:"M20 20 L40 40 M40 20 L20 40",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round"})]})})]})})})]}):null}class G{constructor(){__publicField(this,"container",null),__publicField(this,"root",null),__publicField(this,"currentStatus","preparing")}show(e="preparing"){this.container?this.updateStatus(e):(this.container=document.createElement("div"),this.container.id="neofaceid-status-overlay",document.body.appendChild(this.container),this.root=s(this.container),this.currentStatus=e,this.render())}updateStatus(e){this.currentStatus=e,this.root&&this.render()}close(){this.container&&(this.root&&this.root.render(m.jsx(X,{status:this.currentStatus,onClose:()=>{this.container&&document.body.contains(this.container)&&document.body.removeChild(this.container),this.container=null,this.root=null}})),setTimeout((()=>{this.container&&document.body.contains(this.container)&&document.body.removeChild(this.container),this.container=null,this.root=null}),300))}render(){this.root&&this.container&&this.root.render(m.jsx(X,{status:this.currentStatus,onClose:()=>this.close()}))}}function Y({error:e,onRetry:n,onCredentials:t,onCancel:o}){return m.jsxs(m.Fragment,{children:[m.jsx("style",{children:"\n @keyframes slideUp {\n from {\n opacity: 0;\n transform: translateY(20px);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n }\n\n @keyframes fadeIn {\n from { opacity: 0; }\n to { opacity: 1; }\n }\n\n .neofaceid-fallback-overlay {\n position: fixed;\n inset: 0;\n background: rgba(0, 0, 0, 0.6);\n backdrop-filter: blur(8px);\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 10001;\n padding: 20px;\n animation: fadeIn 0.3s ease-out;\n }\n\n .neofaceid-fallback-prompt {\n background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);\n border-radius: 20px;\n padding: 32px;\n max-width: 400px;\n width: 100%;\n box-shadow: 0 24px 48px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.1);\n animation: slideUp 0.4s ease-out;\n text-align: center;\n }\n\n .neofaceid-fallback-icon {\n width: 64px;\n height: 64px;\n margin: 0 auto 20px;\n color: #ef4444;\n animation: scaleIn 0.4s ease-out;\n }\n\n @keyframes scaleIn {\n 0% {\n transform: scale(0);\n opacity: 0;\n }\n 50% {\n transform: scale(1.1);\n }\n 100% {\n transform: scale(1);\n opacity: 1;\n }\n }\n\n .neofaceid-fallback-title {\n font-size: 22px;\n font-weight: 700;\n color: white;\n margin: 0 0 12px 0;\n }\n\n .neofaceid-fallback-message {\n font-size: 15px;\n color: rgba(255, 255, 255, 0.7);\n margin: 0 0 28px 0;\n line-height: 1.5;\n }\n\n .neofaceid-fallback-actions {\n display: flex;\n flex-direction: column;\n gap: 12px;\n }\n\n .neofaceid-fallback-button {\n padding: 14px 24px;\n border-radius: 12px;\n border: none;\n font-size: 16px;\n font-weight: 600;\n cursor: pointer;\n transition: all 0.2s;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n }\n\n .neofaceid-fallback-button-primary {\n background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);\n color: white;\n box-shadow: 0 4px 16px rgba(124, 58, 237, 0.3);\n }\n\n .neofaceid-fallback-button-primary:hover {\n transform: translateY(-2px);\n box-shadow: 0 8px 24px rgba(124, 58, 237, 0.4);\n }\n\n .neofaceid-fallback-button-primary:active {\n transform: translateY(0);\n }\n\n .neofaceid-fallback-button-secondary {\n background: rgba(255, 255, 255, 0.1);\n color: white;\n border: 1px solid rgba(255, 255, 255, 0.2);\n }\n\n .neofaceid-fallback-button-secondary:hover {\n background: rgba(255, 255, 255, 0.15);\n border-color: rgba(255, 255, 255, 0.3);\n }\n\n .neofaceid-fallback-button-ghost {\n background: transparent;\n color: rgba(255, 255, 255, 0.7);\n padding: 10px;\n }\n\n .neofaceid-fallback-button-ghost:hover {\n color: white;\n background: rgba(255, 255, 255, 0.05);\n }\n\n @media (max-width: 640px) {\n .neofaceid-fallback-prompt {\n padding: 24px;\n border-radius: 16px;\n }\n\n .neofaceid-fallback-title {\n font-size: 20px;\n }\n }\n "}),m.jsx("div",{className:"neofaceid-fallback-overlay",children:m.jsxs("div",{className:"neofaceid-fallback-prompt",children:[m.jsx("div",{className:"neofaceid-fallback-icon",children:m.jsxs("svg",{viewBox:"0 0 64 64",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[m.jsx("circle",{cx:"32",cy:"32",r:"30",stroke:"currentColor",strokeWidth:"3",fill:"none"}),m.jsx("path",{d:"M20 20 L44 44 M44 20 L20 44",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round"})]})}),m.jsx("h3",{className:"neofaceid-fallback-title",children:"Não foi possível reconhecer"}),m.jsx("p",{className:"neofaceid-fallback-message",children:(null==e?void 0:e.message)||"Não conseguimos reconhecer sua face. Tente novamente ou use email e senha."}),m.jsxs("div",{className:"neofaceid-fallback-actions",children:[m.jsx("button",{type:"button",className:"neofaceid-fallback-button neofaceid-fallback-button-primary",onClick:n,children:"Tentar Novamente"}),m.jsx("button",{type:"button",className:"neofaceid-fallback-button neofaceid-fallback-button-secondary",onClick:t,children:"Entrar com Email e Senha"}),o&&m.jsx("button",{type:"button",className:"neofaceid-fallback-button neofaceid-fallback-button-ghost",onClick:o,children:"Cancelar"})]})]})})]})}class H{constructor(){__publicField(this,"container",null),__publicField(this,"root",null)}show(e,n,t,o){this.container||(this.container=document.createElement("div"),this.container.id="neofaceid-fallback-prompt",document.body.appendChild(this.container),this.root=s(this.container),this.render(e,n,t,o))}close(){this.container&&document.body.contains(this.container)&&(this.root&&this.root.unmount(),document.body.removeChild(this.container),this.container=null,this.root=null)}render(e,n,t,o){this.root&&this.container&&this.root.render(m.jsx(Y,{error:e,onRetry:()=>{this.close(),n()},onCredentials:()=>{this.close(),t()},onCancel:()=>{this.close(),null==o||o()}}))}}class J{constructor(e){__publicField(this,"options"),__publicField(this,"modalElement",null),this.options=e}async open(){this.createModal(),document.body.appendChild(this.modalElement)}close(){this.modalElement&&(document.body.removeChild(this.modalElement),this.modalElement=null),this.options.onCancel&&this.options.onCancel()}createModal(){this.addStyles(),this.modalElement=document.createElement("div"),this.modalElement.className="neoface-email-password-modal",this.modalElement.innerHTML=`\n <div class="neoface-email-modal-overlay">\n <div class="neoface-email-modal-content">\n <h2>${this.options.title||"Login com Email e Senha"}</h2>\n <p>${this.options.subtitle||"Informe seus dados para login."}</p>\n <form id="email-password-form">\n <input type="email" id="email" placeholder="Email" required />\n <input type="password" id="password" placeholder="Senha" required />\n <button type="submit" class="neoface-email-submit-btn">Entrar</button>\n </form>\n <button class="neoface-email-cancel-btn">Cancelar</button>\n \n \x3c!-- Branding --\x3e\n <div class="neoface-email-branding">\n <img src="/public/logo-icone-no-backgorund.png" alt="NeoFaceId" class="neoface-email-brand-logo" onerror="this.style.display='none'" />\n <span>NeoFaceId by</span>\n <span class="neoface-email-brand-name">OCTA</span>\n </div>\n </div>\n </div>\n `;this.modalElement.querySelector("#email-password-form").addEventListener("submit",this.handleSubmit.bind(this));this.modalElement.querySelector(".neoface-email-cancel-btn").addEventListener("click",this.close.bind(this))}addStyles(){const e="neoface-email-password-modal-styles";if(document.getElementById(e))return;const n=document.createElement("style");n.id=e,n.textContent="\n .neoface-email-password-modal {\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n z-index: 10002;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n }\n\n .neoface-email-modal-overlay {\n position: absolute;\n inset: 0;\n background: rgba(0, 0, 0, 0.6);\n backdrop-filter: blur(8px);\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 20px;\n animation: fadeIn 0.3s ease-out;\n }\n\n @keyframes fadeIn {\n from { opacity: 0; }\n to { opacity: 1; }\n }\n\n @keyframes slideUp {\n from {\n opacity: 0;\n transform: translateY(20px);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n }\n\n .neoface-email-modal-content {\n background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);\n border-radius: 20px;\n padding: 32px;\n max-width: 400px;\n width: 100%;\n box-shadow: 0 24px 48px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.1);\n animation: slideUp 0.4s ease-out;\n }\n\n .neoface-email-modal-content h2 {\n font-size: 24px;\n font-weight: 700;\n color: white;\n margin: 0 0 12px 0;\n text-align: center;\n }\n\n .neoface-email-modal-content p {\n font-size: 15px;\n color: rgba(255, 255, 255, 0.7);\n margin: 0 0 24px 0;\n text-align: center;\n line-height: 1.5;\n }\n\n .neoface-email-modal-content form {\n display: flex;\n flex-direction: column;\n gap: 16px;\n margin-bottom: 16px;\n }\n\n .neoface-email-modal-content input {\n width: 100%;\n padding: 14px 16px;\n border: 2px solid rgba(255, 255, 255, 0.2);\n border-radius: 12px;\n font-size: 15px;\n background: rgba(255, 255, 255, 0.1);\n color: white;\n font-family: inherit;\n transition: all 0.2s;\n box-sizing: border-box;\n }\n\n .neoface-email-modal-content input::placeholder {\n color: rgba(255, 255, 255, 0.5);\n }\n\n .neoface-email-modal-content input:focus {\n outline: none;\n border-color: #7c3aed;\n box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.2);\n background: rgba(255, 255, 255, 0.15);\n }\n\n .neoface-email-submit-btn {\n width: 100%;\n padding: 14px 24px;\n border-radius: 12px;\n border: none;\n background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);\n color: white;\n font-size: 16px;\n font-weight: 600;\n cursor: pointer;\n transition: all 0.2s;\n box-shadow: 0 4px 16px rgba(124, 58, 237, 0.3);\n font-family: inherit;\n }\n\n .neoface-email-submit-btn:hover {\n transform: translateY(-2px);\n box-shadow: 0 8px 24px rgba(124, 58, 237, 0.4);\n }\n\n .neoface-email-submit-btn:active {\n transform: translateY(0);\n }\n\n .neoface-email-submit-btn:disabled {\n opacity: 0.6;\n cursor: not-allowed;\n transform: none;\n }\n\n .neoface-email-cancel-btn {\n width: 100%;\n padding: 12px 24px;\n border-radius: 12px;\n border: 1px solid rgba(255, 255, 255, 0.2);\n background: transparent;\n color: rgba(255, 255, 255, 0.7);\n font-size: 15px;\n font-weight: 600;\n cursor: pointer;\n transition: all 0.2s;\n font-family: inherit;\n }\n\n .neoface-email-cancel-btn:hover {\n background: rgba(255, 255, 255, 0.1);\n color: white;\n border-color: rgba(255, 255, 255, 0.3);\n }\n\n .neoface-email-branding {\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 8px;\n margin-top: 32px;\n padding-top: 24px;\n border-top: 1px solid rgba(255, 255, 255, 0.1);\n font-size: 13px;\n color: rgba(255, 255, 255, 0.5);\n }\n\n .neoface-email-brand-logo {\n height: 20px;\n width: auto;\n }\n\n .neoface-email-brand-name {\n font-weight: 600;\n font-family: 'SF Pro Display', -apple-system, system-ui, sans-serif;\n color: #ffffff;\n letter-spacing: 0.3px;\n }\n\n @media (max-width: 640px) {\n .neoface-email-modal-content {\n padding: 24px;\n border-radius: 16px;\n }\n\n .neoface-email-modal-content h2 {\n font-size: 20px;\n }\n }\n ",document.head.appendChild(n)}async handleSubmit(e){e.preventDefault();const n=this.modalElement.querySelector("#email"),t=this.modalElement.querySelector("#password"),o=n.value.trim(),a=t.value.trim();if(o&&a)try{const e=await(async(e,n,t)=>{E();const o=R();try{const a=await fetch(`${x}/api/v1/auth/login/`,{method:"POST",headers:{"Content-Type":"application/json","X-App-Token":t},body:JSON.stringify({email:e,password:n}),signal:o.signal});if(!a.ok){if(401===a.status||403===a.status)throw new v("Invalid credentials or application token",y.INVALID_TOKEN);throw new v(`Server returned status ${a.status}`,y.NETWORK)}const r=await a.json();return{success:!0,accessToken:r.access_token||r.access,alias:r.user&&r.user.alias||r.alias,user:{id:r.user&&r.user.id||"",email:r.user&&r.user.email||"",role:r.user&&r.user.role||"",validated:r.user&&r.user.validated||!1,active:r.user&&r.user.active||!1}}}catch(a){if(a instanceof Error){if("AbortError"===a.name)throw new v("Request timed out",y.NETWORK);if(a instanceof v)throw a;throw new v(a.message,y.NETWORK)}throw new v("Unknown error occurred",y.NETWORK_ERROR)}})(o,a,this.options.applicationToken);this.options.onSuccess(e),this.close()}catch(r){this.options.onError(r)}else this.options.onError(new v("Email e senha são obrigatórios",y.VALIDATION_ERROR))}}async function Z(e,n){n.updateStatus("verifying");const t=document.createElement("video");t.style.position="fixed",t.style.top="-9999px",t.style.left="-9999px",t.style.width="1px",t.style.height="1px",t.style.opacity="0",t.setAttribute("autoplay",""),t.setAttribute("muted",""),t.setAttribute("playsinline",""),document.body.appendChild(t);let o=null;try{o=await navigator.mediaDevices.getUserMedia({video:{width:{ideal:640},height:{ideal:480},facingMode:"user"},audio:!1}),t.srcObject=o,await t.play(),await new Promise((e=>{t.readyState>=2?e(void 0):t.onloadedmetadata=()=>e(void 0)})),await new Promise((e=>setTimeout(e,500)));const n=await async function(e,n=3e3,t=200){return new Promise((o=>{let a=0,r=0;const s=Math.ceil(n/t);let c=null,l=!1;const d=e=>{l||(l=!0,c&&clearTimeout(c),o(e))},u=async()=>{if(!l)try{const n=await i.detectSingleFace(e,new i.TinyFaceDetectorOptions({inputSize:160,scoreThreshold:.4}));if(r++,n&&a++,r>=s)return void d(a/r>=.6);c=window.setTimeout(u,t)}catch(n){r++,r>=s?d(a/r>=.6):c=window.setTimeout(u,t)}},p=window.setTimeout((()=>{l||d((r>0?a/r:0)>=.6)}),n+1e3);c=window.setTimeout((()=>{u(),clearTimeout(p)}),t)}))}(t,3e3);if(!n)throw o&&o.getTracks().forEach((e=>e.stop())),t.parentElement&&t.parentElement.removeChild(t),new v("Rosto não detectado. Posicione seu rosto na frente da câmera.",y.VALIDATION_ERROR);const a=document.createElement("canvas");a.width=t.videoWidth,a.height=t.videoHeight;const r=a.getContext("2d");if(!r)throw o&&o.getTracks().forEach((e=>e.stop())),t.parentElement&&t.parentElement.removeChild(t),new v("Erro ao capturar imagem",y.CAPTURE_ERROR);r.drawImage(t,0,0,a.width,a.height),o&&o.getTracks().forEach((e=>e.stop())),t.parentElement&&t.parentElement.removeChild(t);const s=await new Promise(((e,n)=>{a.toBlob((t=>{a.remove(),t?e(t):n(new Error("Failed to capture image"))}),"image/jpeg",.85)})),c=await N(s,e);if(!c.success)throw new v("Login falhou",y.LOGIN_FAILED);return c}catch(a){if(o&&o.getTracks().forEach((e=>e.stop())),t.parentElement&&t.parentElement.removeChild(t),a instanceof v)throw a;throw new v(a instanceof Error?a.message:"Erro desconhecido",y.UNKNOWN)}}async function Q(e){const{applicationToken:n,onSuccess:t,onError:o,onFallbackRequest:a,onCancel:r}=e,s=new G,c=new H;let l,d=0;try{const e="https://cdn.jsdelivr.net/npm/@vladmandic/face-api/model";await Promise.all([i.nets.tinyFaceDetector.loadFromUri(e),i.nets.faceLandmark68Net.loadFromUri(e)])}catch(p){}s.show("preparing");const u=async()=>{try{d++;const e=await Z(n,s);s.updateStatus("success"),setTimeout((()=>{s.close(),t(e)}),800)}catch(p){l=p instanceof v?p:new v(p instanceof Error?p.message:"Erro desconhecido",y.UNKNOWN),s.updateStatus("error"),d<3?setTimeout((()=>{u()}),500):setTimeout((()=>{s.close(),c.show(l,(()=>{d=0,s.show("preparing"),setTimeout((()=>u()),500)}),(()=>{a?a():o(new v("Por favor, use email e senha para fazer login",y.LOGIN_FAILED))}),r)}),1e3)}};setTimeout((()=>{u()}),300)}const ee=Object.freeze(Object.defineProperty({__proto__:null,captureFaceSilently:async function(){return new Promise(((e,n)=>{const t=document.createElement("video");t.style.position="fixed",t.style.top="-9999px",t.style.left="-9999px",t.style.width="1px",t.style.height="1px",t.style.opacity="0",t.setAttribute("autoplay",""),t.setAttribute("muted",""),t.setAttribute("playsinline","");const o=document.createElement("canvas");o.style.display="none";let a=null,r=0;const s=()=>{a&&a.getTracks().forEach((e=>e.stop())),t.parentElement&&t.parentElement.removeChild(t),o.parentElement&&o.parentElement.removeChild(o)};document.body.appendChild(t),document.body.appendChild(o),navigator.mediaDevices.getUserMedia({video:{width:{ideal:640},height:{ideal:480},facingMode:"user"},audio:!1}).then((c=>{a=c,t.srcObject=a,t.play();const l=()=>{if(!t.videoWidth||!t.videoHeight)return r<10?(r++,void setTimeout(l,100)):(s(),void n(new v("Câmera não está pronta",y.CAMERA_ERROR)));o.width=t.videoWidth,o.height=t.videoHeight;const a=o.getContext("2d");if(!a)return s(),void n(new Error("Failed to get canvas context"));(async()=>{try{return!!(await i.detectSingleFace(t,new i.TinyFaceDetectorOptions({inputSize:160,scoreThreshold:.4})))}catch{return!1}})().then((i=>{if(!i&&r<10)return r++,void setTimeout(l,200);a.drawImage(t,0,0,o.width,o.height),o.toBlob((t=>{s(),t?e(t):n(new Error("Failed to capture image"))}),"image/jpeg",.85)}))};t.onloadedmetadata=()=>{setTimeout(l,800)},t.onerror=()=>{s(),n(new v("Erro ao acessar câmera",y.CAMERA_ERROR))}})).catch((e=>{s(),n(new v("Não foi possível acessar a câmera: "+e.message,y.CAMERA_ERROR))}))}))},executeBiometricLoginFlow:Q},Symbol.toStringTag,{value:"Module"}));async function ne(e){try{if(!(await _(e.applicationToken)))return void e.onError(new v("Token de aplicação inválido",y.INVALID_TOKEN));await Q({applicationToken:e.applicationToken,onSuccess:e.onSuccess,onError:e.onError,onFallbackRequest:e.onFallbackRequest||(()=>{const n={applicationToken:e.applicationToken,onSuccess:e.onSuccess,onError:e.onError,title:"Login Alternativo",subtitle:"Biometria não reconhecida. Por favor, informe email e senha."};new J(n).open()}),onCancel:e.onCancel})}catch(n){e.onError(new v("Erro ao inicializar login facial: "+n.message,y.INITIALIZATION_ERROR))}}async function te(e){try{if(!(await _(e.applicationToken)))return void e.onError(new v("Token de aplicação inválido",y.INVALID_TOKEN));const n={mode:"hand",onSuccess:async(n,t)=>{try{const t=await fetch(n).then((e=>e.blob())),o=await loginWithBiometric(t,e.applicationToken);e.onSuccess(o)}catch(o){e.onError(o)}},onError:e.onError,onCancel:e.onCancel,countdown:e.countdown,title:e.title||"Login por Mão",subtitle:e.subtitle||"Posicione sua mão dentro do quadro para fazer login."},t=new BiometricCaptureModal(n);await t.open()}catch(n){e.onError(new v("Erro ao inicializar login por mão: "+n.message,y.INITIALIZATION_ERROR))}}async function oe(e){try{if(!(await _(e.applicationToken)))return void e.onError(new v("Token de aplicação inválido",y.INVALID_TOKEN));const n={mode:"auto",onSuccess:async(n,t)=>{try{const t=await fetch(n).then((e=>e.blob())),o=await loginWithBiometric(t,e.applicationToken);e.onSuccess(o)}catch(o){e.onError(o)}},onError:e.onError,onCancel:e.onCancel,countdown:e.countdown,title:e.title||"Login Biométrico",subtitle:e.subtitle||"Posicione seu rosto ou mão dentro do quadro para login automático."},t=new BiometricCaptureModal(n);await t.open()}catch(n){e.onError(new v("Erro ao inicializar login automático: "+n.message,y.INITIALIZATION_ERROR))}}async function ae(e){try{const t=await(n=e,new Promise(((e,t)=>{const o=new Image;o.onload=()=>e(o),o.onerror=()=>t(new Error("Erro ao carregar imagem"));const a=n.startsWith("data:")?n:`data:image/jpeg;base64,${n}`;o.src=a}))),o=await async function(e){try{if("undefined"!=typeof window&&window.faceapi){const n=window.faceapi;await ie();const t=new n.TinyFaceDetectorOptions({inputSize:320,scoreThreshold:.5}),o=await n.detectAllFaces(e,t).withFaceLandmarks();if(o&&o.length>0){const e=o.reduce(((e,n)=>n.detection.score>e.detection.score?n:e));return{confidence:e.detection.score,details:{faces:o.length,landmarks:e.landmarks,box:e.detection.box}}}}return{confidence:0}}catch(n){return{confidence:0}}}(t);if(o.confidence>.7)return{type:"face",confidence:o.confidence,details:o.details};const a=await async function(e){try{const n=document.createElement("canvas"),t=n.getContext("2d");if(!t)return{confidence:0};n.width=e.width,n.height=e.height,t.drawImage(e,0,0);const o=function(e){const{data:n,width:t,height:o}=e;let a=0,r=0;for(let d=0;d<n.length;d+=4){re(n[d],n[d+1],n[d+2])&&a++,r++}const i=a/r,s=t/o;let c=0;i>.15&&i<.7&&(c+=i/.7*.4);s>.6&&s<1.8&&(c+=.3);const l=t*o;l>1e4&&l<5e5&&(c+=.3);return{confidence:Math.min(c,.8),skinRatio:i,aspectRatio:s,imageSize:l,skinPixels:a,totalPixels:r}}(t.getImageData(0,0,n.width,n.height));return{confidence:o.confidence,details:o}}catch(n){return{confidence:0}}}(t);return a.confidence>.6?{type:"hand",confidence:a.confidence,details:a.details}:{type:"unknown",confidence:Math.max(o.confidence,a.confidence)}}catch(t){return{type:"face",confidence:.5}}var n}function re(e,n,t){const o=.299*e+.587*n+.114*t,a=-.169*e-.331*n+.5*t+128,r=.5*e-.419*n-.081*t+128;return o>80&&o<255&&a>85&&a<135&&r>135&&r<180}async function ie(){if("undefined"==typeof window||!window.faceapi)return;const e=window.faceapi;if(!e.nets.tinyFaceDetector.isLoaded)try{await Promise.all([e.nets.tinyFaceDetector.loadFromUri("./models"),e.nets.faceLandmark68Net.loadFromUri("./models")])}catch(n){}}async function se(){try{"undefined"!=typeof window&&await ie()}catch(e){}}function ce(){return"undefined"!=typeof window&&window.faceapi&&window.faceapi.nets.tinyFaceDetector.isLoaded}const le=Object.freeze(Object.defineProperty({__proto__:null,detectBiometricType:ae,initializeBiometricDetection:se,isAdvancedDetectionAvailable:ce},Symbol.toStringTag,{value:"Module"}));class de{constructor(e){__publicField(this,"overlay",null),__publicField(this,"video",null),__publicField(this,"canvas",null),__publicField(this,"stream",null),__publicField(this,"step","face"),__publicField(this,"countdownSeconds"),__publicField(this,"title"),__publicField(this,"subtitle"),__publicField(this,"faceBlob",null),__publicField(this,"documentBlob",null),this.countdownSeconds=(null==e?void 0:e.countdown)??3,this.title=null==e?void 0:e.title,this.subtitle=null==e?void 0:e.subtitle}async open(){if(await this.createDom(),await this.startCamera(),await this.runFaceCaptureCountdown(),this.faceBlob=await this.captureFrame(),this.step="document",this.updateTexts("Captura do Documento",'Posicione seu documento visível e clique em "Capturar"'),await this.waitForUserCaptureClick(),this.documentBlob=await this.captureFrame(),await this.close(),!this.faceBlob||!this.documentBlob)throw new Error("Falha na captura das imagens de onboarding");return{face:this.faceBlob,document:this.documentBlob}}async createDom(){const e=document.createElement("div");e.className="neofaceid-modal-overlay",e.innerHTML=`\n <div class="neofaceid-modal">\n <div class="neofaceid-modal-header">\n <h2 class="neofaceid-title">${this.title??"Onboarding NeoFaceID"}</h2>\n <button class="neofaceid-close-btn" aria-label="Fechar">×</button>\n </div>\n <div class="neofaceid-modal-body">\n <p class="neofaceid-subtitle">${this.subtitle??"Vamos capturar sua face e documento"}</p>\n <div class="neofaceid-camera-container">\n <video class="neofaceid-video" autoplay playsinline></video>\n <canvas class="neofaceid-canvas"></canvas>\n <div class="neofaceid-overlay">\n <div class="neofaceid-frame"></div>\n <div class="neofaceid-countdown" style="display:none"><span class="neofaceid-countdown-number">${this.countdownSeconds}</span></div>\n </div>\n </div>\n <div class="neofaceid-status"><p class="neofaceid-status-text">Posicione seu rosto no quadro</p></div>\n </div>\n <div class="neofaceid-modal-footer">\n <button class="neofaceid-cancel-btn">Cancelar</button>\n <button class="neofaceid-capture-btn" disabled>Capturar</button>\n </div>\n </div>\n `;const n=document.createElement("style");n.textContent="\n .neofaceid-modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); display:flex; align-items:center; justify-content:center; z-index: 9999; }\n .neofaceid-modal { background:#fff; border-radius:12px; width: 92%; max-width: 640px; box-shadow: 0 20px 60px rgba(0,0,0,0.3); overflow:hidden; }\n .neofaceid-modal-header { padding: 16px 20px; border-bottom: 1px solid #eee; display:flex; align-items:center; justify-content:space-between; }\n .neofaceid-title { margin:0; font-size: 20px; color:#333; }\n .neofaceid-close-btn { background:none; border:none; font-size:24px; cursor:pointer; color:#666; }\n .neofaceid-modal-body { padding: 16px 20px; }\n .neofaceid-subtitle { margin: 0 0 12px 0; color:#666; }\n .neofaceid-camera-container { position: relative; background:#000; border-radius:8px; overflow:hidden; aspect-ratio: 4/3; margin-bottom: 12px; }\n .neofaceid-video { width:100%; height:100%; object-fit: cover; }\n .neofaceid-canvas { position:absolute; top:0; left:0; }\n .neofaceid-overlay { position:absolute; inset:0; display:flex; align-items:center; justify-content:center; }\n .neofaceid-frame { width: 200px; height: 200px; border: 3px solid #4CAF50; border-radius: 50%; box-shadow: 0 0 0 2px rgba(76,175,80,0.3); }\n .neofaceid-countdown { position:absolute; top:16px; right:16px; background: rgba(0,0,0,0.7); color:#fff; width: 48px; height:48px; display:flex; align-items:center; justify-content:center; border-radius:50%; }\n .neofaceid-modal-footer { padding: 16px 20px; border-top: 1px solid #eee; display:flex; gap: 8px; justify-content:flex-end; }\n .neofaceid-cancel-btn { background:#f5f5f5; color:#666; border:none; border-radius:6px; padding:10px 18px; cursor:pointer; }\n .neofaceid-capture-btn { background:#4CAF50; color:#fff; border:none; border-radius:6px; padding:10px 18px; cursor:pointer; }\n .neofaceid-capture-btn:disabled { background:#ccc; cursor:not-allowed; }\n ",document.head.appendChild(n),document.body.appendChild(e),this.overlay=e,this.video=this.overlay.querySelector(".neofaceid-video"),this.canvas=this.overlay.querySelector(".neofaceid-canvas");const t=this.overlay.querySelector(".neofaceid-close-btn"),o=this.overlay.querySelector(".neofaceid-cancel-btn");t.onclick=()=>this.close(),o.onclick=()=>this.close();this.overlay.querySelector(".neofaceid-capture-btn").disabled=!0}async startCamera(){if(this.stream=await navigator.mediaDevices.getUserMedia({video:{facingMode:"user",width:{ideal:1280},height:{ideal:720}},audio:!1}),!this.video)throw new Error("Elemento de vídeo não encontrado");this.video.srcObject=this.stream,await this.video.play()}async runFaceCaptureCountdown(){if(!this.overlay)return;const e=this.overlay.querySelector(".neofaceid-countdown"),n=this.overlay.querySelector(".neofaceid-countdown-number"),t=this.overlay.querySelector(".neofaceid-status-text");e.style.display="flex",t.textContent="Prepare-se! Capturando seu rosto...";let o=this.countdownSeconds;n.textContent=String(o),await new Promise((t=>{const a=setInterval((()=>{o-=1,n.textContent=String(o),o<=0&&(clearInterval(a),e.style.display="none",t())}),1e3)}))}async waitForUserCaptureClick(){if(!this.overlay)return;const e=this.overlay.querySelector(".neofaceid-capture-btn"),n=this.overlay.querySelector(".neofaceid-status-text");e.disabled=!1,n.textContent='Clique em "Capturar" quando o documento estiver visível',await new Promise((n=>{const t=()=>{e.removeEventListener("click",t),n()};e.addEventListener("click",t)})),e.disabled=!0}async captureFrame(){if(!this.video||!this.canvas)throw new Error("Elementos de captura não encontrados");const e=this.canvas.getContext("2d");if(!e)throw new Error("Falha ao obter contexto do canvas");this.canvas.width=this.video.videoWidth,this.canvas.height=this.video.videoHeight,e.drawImage(this.video,0,0,this.canvas.width,this.canvas.height);return await new Promise(((e,n)=>{this.canvas.toBlob((t=>t?e(t):n(new Error("Falha ao gerar imagem"))),"image/jpeg",.92)}))}updateTexts(e,n){if(!this.overlay)return;const t=this.overlay.querySelector(".neofaceid-title"),o=this.overlay.querySelector(".neofaceid-subtitle"),a=this.overlay.querySelector(".neofaceid-frame");t.textContent=e,o.textContent=n,"document"===this.step&&(a.style.borderRadius="8px",a.style.width="280px",a.style.height="180px")}async close(){this.stream&&(this.stream.getTracks().forEach((e=>e.stop())),this.stream=null),this.overlay&&(this.overlay.remove(),this.overlay=null)}}const ue=["Olhe diretamente para a câmera","Vire levemente a cabeça para a esquerda","Vire levemente a cabeça para a direita","Mostre o polegar para cima (👍) e olhe para a câmera"];e.BiometricCaptureModal=class{constructor(e){__publicField(this,"modal",null),__publicField(this,"video",null),__publicField(this,"canvas",null),__publicField(this,"stream",null),__publicField(this,"options"),__publicField(this,"countdownInterval",null),__publicField(this,"isCapturing",!1),this.options=e}async open(){try{await this.createModal(),await this.initializeCamera(),this.startCountdown()}catch(e){this.options.onError(new v("Erro ao inicializar câmera: "+e.message,y.CAMERA_ERROR))}}close(){this.cleanup(),this.modal&&(document.body.removeChild(this.modal),this.modal=null)}async createModal(){this.modal=document.createElement("div"),this.modal.className="neofaceid-biometric-modal";const e=this.options.title||this.getDefaultTitle(),n=this.options.subtitle||this.getDefaultSubtitle();this.modal.innerHTML=`\n <div class="neofaceid-modal-overlay">\n <div class="neofaceid-modal-content">\n <div class="neofaceid-modal-header">\n <h2>${e}</h2>\n <button class="neofaceid-close-btn" type="button">&times;</button>\n </div>\n <div class="neofaceid-modal-body">\n <p class="neofaceid-subtitle">${n}</p>\n <div class="neofaceid-camera-container">\n <video class="neofaceid-video" autoplay muted playsinline></video>\n <canvas class="neofaceid-canvas" style="display: none;"></canvas>\n <div class="neofaceid-overlay">\n <div class="neofaceid-frame"></div>\n <div class="neofaceid-countdown">\n <span class="neofaceid-countdown-number">${this.options.countdown||3}</span>\n </div>\n </div>\n </div>\n <div class="neofaceid-status">\n <p class="neofaceid-status-text">Posicione-se na frente da câmera</p>\n </div>\n </div>\n <div class="neofaceid-modal-footer">\n <button class="neofaceid-cancel-btn" type="button">Cancelar</button>\n <button class="neofaceid-capture-btn" type="button" disabled>Capturar</button>\n </div>\n </div>\n </div>\n `,this.addStyles(),this.addEventListeners(),document.body.appendChild(this.modal)}async initializeCamera(){if(!this.modal)throw new Error("Modal não inicializado");if(this.video=this.modal.querySelector(".neofaceid-video"),this.canvas=this.modal.querySelector(".neofaceid-canvas"),!this.video||!this.canvas)throw new Error("Elementos de vídeo ou canvas não encontrados");try{this.stream=await navigator.mediaDevices.getUserMedia({video:{width:{ideal:640},height:{ideal:480},facingMode:"user"},audio:!1}),this.video.srcObject=this.stream,await this.video.play(),this.canvas.width=this.video.videoWidth,this.canvas.height=this.video.videoHeight}catch(e){throw new Error("Não foi possível acessar a câmera: "+e.message)}}startCountdown(){if(!this.modal)return;const e=this.modal.querySelector(".neofaceid-countdown-number"),n=this.modal.querySelector(".neofaceid-capture-btn"),t=this.modal.querySelector(".neofaceid-status-text");let o=this.options.countdown||3;e&&(e.textContent=o.toString()),this.countdownInterval=window.setInterval((()=>{o--,e&&(e.textContent=o.toString()),o<=0&&(this.countdownInterval&&(clearInterval(this.countdownInterval),this.countdownInterval=null),e&&(e.style.display="none"),n&&(n.disabled=!1,n.textContent="Capturar Agora"),t&&(t.textContent="Pronto para capturar!"),"auto"===this.options.mode&&setTimeout((()=>this.captureImage()),500))}),1e3)}async captureImage(){if(!this.isCapturing&&this.video&&this.canvas){this.isCapturing=!0;try{const e=this.canvas.getContext("2d");if(!e)throw new Error("Não foi possível obter contexto do canvas");e.drawImage(this.video,0,0,this.canvas.width,this.canvas.height);const n=this.canvas.toDataURL("image/jpeg",.8).split(",")[1],t=`data:image/jpeg;base64,${n}`;let o="auto"===this.options.mode?await this.detectBiometricType(n):this.options.mode;this.close(),this.options.onSuccess(t,o)}catch(e){this.options.onError(new v("Erro ao capturar imagem: "+e.message,y.CAPTURE_ERROR))}finally{this.isCapturing=!1}}}async detectBiometricType(e){try{const{detectBiometricType:n}=await Promise.resolve().then((()=>le)),t=await n(e);return"unknown"!==t.type&&t.confidence>.6?t.type:"face"}catch(n){return"face"}}addEventListeners(){if(!this.modal)return;const e=this.modal.querySelector(".neofaceid-close-btn"),n=this.modal.querySelector(".neofaceid-cancel-btn"),t=this.modal.querySelector(".neofaceid-capture-btn");null==e||e.addEventListener("click",(()=>{var e,n;this.close(),null==(n=(e=this.options).onCancel)||n.call(e)})),null==n||n.addEventListener("click",(()=>{var e,n;this.close(),null==(n=(e=this.options).onCancel)||n.call(e)})),null==t||t.addEventListener("click",(()=>{this.captureImage()})),this.modal.addEventListener("click",(e=>{var n,t,o;e.target===(null==(n=this.modal)?void 0:n.querySelector(".neofaceid-modal-overlay"))&&(this.close(),null==(o=(t=this.options).onCancel)||o.call(t))}))}cleanup(){this.stream&&(this.stream.getTracks().forEach((e=>e.stop())),this.stream=null),this.countdownInterval&&(clearInterval(this.countdownInterval),this.countdownInterval=null),this.video=null,this.canvas=null,this.isCapturing=!1}getDefaultTitle(){switch(this.options.mode){case"face":return"Autenticação Facial";case"hand":return"Autenticação por Mão";case"auto":return"Autenticação Biométrica";default:return"Captura Biométrica"}}getDefaultSubtitle(){switch(this.options.mode){case"face":return"Posicione seu rosto dentro do quadro e aguarde a captura automática.";case"hand":return"Posicione sua mão dentro do quadro e aguarde a captura automática.";case"auto":return"Posicione seu rosto ou mão dentro do quadro para autenticação automática.";default:return"Posicione-se dentro do quadro para captura."}}addStyles(){const e="neofaceid-biometric-modal-styles",n=document.getElementById(e);n&&n.remove();const t=document.createElement("style");t.id=e,t.textContent="\n .neofaceid-biometric-modal {\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n z-index: 10000;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n }\n\n .neofaceid-modal-overlay {\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background: rgba(0, 0, 0, 0.8);\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 20px;\n box-sizing: border-box;\n }\n\n .neofaceid-modal-content {\n background: white;\n border-radius: 12px;\n max-width: 600px;\n width: 100%;\n max-height: 90vh;\n overflow: hidden;\n box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);\n }\n\n .neofaceid-modal-header {\n padding: 20px;\n border-bottom: 1px solid #e0e0e0;\n display: flex;\n justify-content: space-between;\n align-items: center;\n }\n\n .neofaceid-modal-header h2 {\n margin: 0;\n font-size: 24px;\n font-weight: 600;\n color: #333;\n }\n\n .neofaceid-close-btn {\n background: none;\n border: none;\n font-size: 28px;\n cursor: pointer;\n color: #666;\n padding: 0;\n width: 32px;\n height: 32px;\n display: flex;\n align-items: center;\n justify-content: center;\n border-radius: 50%;\n transition: background-color 0.2s;\n }\n\n .neofaceid-close-btn:hover {\n background-color: #f0f0f0;\n }\n\n .neofaceid-modal-body {\n padding: 20px;\n }\n\n .neofaceid-subtitle {\n margin: 0 0 20px 0;\n color: #666;\n font-size: 16px;\n line-height: 1.4;\n }\n\n .neofaceid-camera-container {\n position: relative;\n background: #000;\n border-radius: 8px;\n overflow: hidden;\n aspect-ratio: 4/3;\n margin-bottom: 20px;\n }\n\n .neofaceid-video {\n width: 100%;\n height: 100%;\n object-fit: cover;\n }\n\n .neofaceid-canvas {\n position: absolute;\n top: 0;\n left: 0;\n }\n\n .neofaceid-overlay {\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n display: flex;\n align-items: center;\n justify-content: center;\n }\n\n .neofaceid-frame {\n width: 200px;\n height: 200px;\n border: 3px solid #4CAF50;\n border-radius: 50%;\n box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.3);\n animation: pulse 2s infinite;\n }\n\n .neofaceid-countdown {\n position: absolute;\n top: 20px;\n right: 20px;\n background: rgba(0, 0, 0, 0.7);\n color: white;\n padding: 10px;\n border-radius: 50%;\n width: 50px;\n height: 50px;\n display: flex;\n align-items: center;\n justify-content: center;\n }\n\n .neofaceid-countdown-number {\n font-size: 24px;\n font-weight: bold;\n }\n\n .neofaceid-status {\n text-align: center;\n margin-bottom: 20px;\n }\n\n .neofaceid-status-text {\n margin: 0;\n color: #666;\n font-size: 16px;\n }\n\n .neofaceid-modal-footer {\n padding: 20px;\n border-top: 1px solid #e0e0e0;\n display: flex;\n gap: 12px;\n justify-content: flex-end;\n }\n\n .neofaceid-cancel-btn,\n .neofaceid-capture-btn {\n padding: 12px 24px;\n border: none;\n border-radius: 6px;\n font-size: 16px;\n font-weight: 500;\n cursor: pointer;\n transition: all 0.2s;\n }\n\n .neofaceid-cancel-btn {\n background: #f5f5f5;\n color: #666;\n }\n\n .neofaceid-cancel-btn:hover {\n background: #e0e0e0;\n }\n\n .neofaceid-capture-btn {\n background: #4CAF50;\n color: white;\n }\n\n .neofaceid-capture-btn:hover:not(:disabled) {\n background: #45a049;\n }\n\n .neofaceid-capture-btn:disabled {\n background: #ccc;\n cursor: not-allowed;\n }\n\n @keyframes pulse {\n 0% { box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.3); }\n 50% { box-shadow: 0 0 0 10px rgba(76, 175, 80, 0.1); }\n 100% { box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.3); }\n }\n\n @media (max-width: 640px) {\n .neofaceid-modal-overlay {\n padding: 10px;\n }\n \n .neofaceid-modal-header,\n .neofaceid-modal-body,\n .neofaceid-modal-footer {\n padding: 15px;\n }\n \n .neofaceid-frame {\n width: 150px;\n height: 150px;\n }\n }\n ",document.head.appendChild(t)}},e.BiometricRegistrationModal=V,e.BiometricStatusOverlay=G,e.EmailPasswordModal=J,e.ErrorType=y,e.FaceCaptureModal=C,e.FallbackPrompt=H,e.NeoFaceError=v,e.NeoFaceID=class{constructor(e){var n;if(__publicField(this,"appToken"),__publicField(this,"baseUrl"),__publicField(this,"signature"),__publicField(this,"sessionData"),this.appToken=e.appToken,this.baseUrl=e.baseUrl||(null==(n={BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1})?void 0:n.VITE_API_BASE_URL)||"http://localhost:8000",this.signature=e.signature,this.sessionData=e.sessionData,this.signature&&!this.validateSignatureFormat(this.signature))throw new v("Invalid signature format. Expected HMAC-SHA256 hex string (minimum 64 characters)",y.VALIDATION_ERROR);if(this.sessionData&&(!this.sessionData.email||!this.sessionData.cpf||!this.sessionData.sessionId))throw new v("Session data must include email, cpf, and sessionId",y.VALIDATION_ERROR)}validateSignatureFormat(e){return/^[a-f0-9]{64,}$/i.test(e)}async captureFaceFrames(e){const{numFrames:n,livenessCheck:t}=e;if(n<1||n>10)throw new v("Number of frames must be between 1 and 10",y.VALIDATION_ERROR);const o=[];try{const{captureFaceSilently:e}=await Promise.resolve().then((()=>ee));for(let a=0;a<n;a++){const r=await e();o.push(r),t&&a<n-1&&await new Promise((e=>setTimeout(e,300)))}return o}catch(a){if(a instanceof v)throw a;throw new v(`Failed to capture face frames: ${a instanceof Error?a.message:"Unknown error"}`,y.CAPTURE_ERROR)}}async loginRecognition(e){const{biometricData:n,typeOfIdentification:t,purpose:o,confidenceThreshold:a=.8}=e,r=Array.isArray(n)?n:[n];if(0===r.length)throw new v("At least one biometric data frame is required",y.VALIDATION_ERROR);const i=r[0];try{const e=await I(i,this.appToken,o,a,this.signature,this.sessionData);if(!e.success)throw new v("Recognition failed",y.RECOGNITION_FAILED);if(!e.personName||!e.email||!e.cpf)throw new v("Incomplete recognition result: missing personName, email, or cpf",y.RECOGNITION_FAILED);return{success:!0,personName:e.personName,email:e.email,cpf:e.cpf,signature:e.signature,sessionId:e.sessionId,confidenceScore:e.confidenceScore,accessToken:e.accessToken}}catch(s){if(s instanceof v)throw s;throw new v(`Login recognition failed: ${s instanceof Error?s.message:"Unknown error"}`,y.RECOGNITION_FAILED)}}},e.RELEASE_DATE="2025-12-01",e.VERSION="1.6.0",e.authorizeOperation=async(e,n,t)=>{if(!e)throw new v("Application token is required",y.VALIDATION_ERROR);if(!n)throw new v("CPF is required",y.VALIDATION_ERROR);const o=n.replace(/\D/g,"");if(11!==o.length)throw new v("Invalid CPF format",y.VALIDATION_ERROR);const a=[],r=(null==t?void 0:t.captureDelay)||2e3;try{if(!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia)throw new v("Camera not available",y.NO_CAMERA);const n=await navigator.mediaDevices.getUserMedia({video:{facingMode:"user",width:{ideal:1280},height:{ideal:720}}}),i=document.createElement("video");i.srcObject=n,i.autoplay=!0,i.playsInline=!0,await new Promise((e=>{i.onloadedmetadata=()=>{i.play(),e()}}));const s=document.createElement("canvas");s.width=i.videoWidth,s.height=i.videoHeight;const c=s.getContext("2d");if(!c)throw new v("Failed to get canvas context",y.CAPTURE_ERROR);for(let e=0;e<4;e++){const n=ue[e];(null==t?void 0:t.onProgress)&&t.onProgress(e+1,4,n),e>0&&await new Promise((e=>setTimeout(e,r))),c.drawImage(i,0,0,s.width,s.height);const o=await new Promise(((e,n)=>{s.toBlob((t=>{t?e(t):n(new Error("Failed to capture photo"))}),"image/jpeg",.9)}));a.push(o),(null==t?void 0:t.onPhotoTaken)&&t.onPhotoTaken(e+1,o)}n.getTracks().forEach((e=>e.stop()));const l=a[3],d={cpf:o,email:"",sessionId:`auth_${Date.now()}_${Math.random().toString(36).substring(7)}`},u=await I(l,e,"AUTHORIZATION",.8,void 0,d);if(!u.success)throw new v("Authorization failed: Person not recognized",y.RECOGNITION_FAILED);return{success:!0,authorizationHash:d.sessionId,name:u.personName,birthDate:void 0,cpf:u.cpf||o,confidenceScore:u.confidenceScore,message:"Authorization successful"}}catch(i){if(i instanceof v)throw i;if(i instanceof Error)throw new v(i.message,y.CAPTURE_ERROR);throw new v("Unknown error during authorization",y.UNKNOWN)}},e.biometricLogin=function(e,n="auto"){return new Promise(((t,o)=>{const a={applicationToken:e,onSuccess:t,onError:o};switch(n){case"face":ne(a);break;case"hand":te(a);break;case"auto":oe(a);break;default:o(new v("Modo de login inválido",y.VALIDATION_ERROR))}}))},e.biometricLoginWithFallback=function(e,n="auto"){return new Promise(((t,o)=>{const a={applicationToken:e,onSuccess:t,onError:n=>{if(n.type===y.LOGIN_FAILED){new J({applicationToken:e,onSuccess:t,onError:o,title:"Login Alternativo",subtitle:"Biometria não reconhecida. Por favor, informe email e senha."}).open()}else o(n)}};switch(n){case"face":ne(a);break;case"hand":te(a);break;case"auto":oe(a);break;default:o(new v("Modo de login inválido",y.VALIDATION_ERROR))}}))},e.completeOnboarding=T,e.completeOnboardingWithData=async(e,n,t,o,a)=>{if(E(),!o||0===o.length)throw new v("Pelo menos uma imagem da pessoa é obrigatória",y.VALIDATION_ERROR);const r=R();try{const i=await Promise.all(o.map((e=>k(e)))),s=await k(a),c=new FormData;i.forEach(((e,n)=>{c.append("person_images",e,`person_${n+1}.jpg`)})),c.append("document_image",s,"document.jpg"),t.name&&c.append("name",t.name),t.birth_date&&c.append("birth_date",t.birth_date),t.cpf&&c.append("cpf",t.cpf),t.cnpj&&c.append("cnpj",t.cnpj),t.email&&c.append("email",t.email);const l=await fetch(`${x}/api/v1/onboardings/${encodeURIComponent(n)}/complete`,{method:"POST",headers:{"X-App-Token":e},body:c,signal:r.signal}),d=await l.json();if(!l.ok){if(401===l.status||403===l.status)throw new v("Token de aplicação inválido ou expirado",y.INVALID_TOKEN);if(404===l.status)throw new v("Link de onboarding não encontrado",y.NOT_FOUND);throw new v((null==d?void 0:d.error)||(null==d?void 0:d.message)||"Falha ao concluir onboarding",y.NETWORK)}return{success:!!d.success,message:d.message||"Onboarding concluído com sucesso",person_id:d.person_id,identity_data_id:d.identity_data_id,confidence_score:d.confidence_score,processing_time:d.processing_time,liveness_passed:d.liveness_passed,document_verified:d.document_verified,person_created:d.person_created}}catch(i){if(i instanceof Error){if("AbortError"===i.name)throw new v("Tempo de requisição excedido",y.NETWORK);if(i instanceof v)throw i;throw new v(i.message,y.NETWORK)}throw new v("Erro desconhecido",y.NETWORK_ERROR)}},e.detectBiometricType=ae,e.identifyPerson=async(e,n)=>{var t,o;E();const a=R(),r=await k(e),i=await new Promise(((e,n)=>{const t=new FileReader;t.onload=()=>{const n=t.result;e(n.split(",")[1])},t.onerror=n,t.readAsDataURL(r)}));try{const e=await fetch(`${x}/api/v1/external/recognition/face/`,{method:"POST",headers:{"Content-Type":"application/json","X-App-Token":n},body:JSON.stringify({image:i,purpose:"SIMPLE_IDENTIFICATION_F"}),signal:a.signal});if(!e.ok){if(401===e.status||403===e.status)throw new v("Invalid or expired application token",y.INVALID_TOKEN);throw new v(`Server returned status ${e.status}`,y.NETWORK)}const r=await e.json();if(!r.success)throw new v(r.message||"Person identification failed",y.RECOGNITION_FAILED);const s=(null==(t=r.person)?void 0:t.name)||"",c=null==(o=r.person)?void 0:o.birth_date;if(!s)throw new v("Person name not found in response",y.PERSON_NOT_FOUND);if(!c)throw new v("Birth date not found in response",y.PERSON_NOT_FOUND);const l=new Date(c),d=new Date;let u=d.getFullYear()-l.getFullYear();const p=d.getMonth()-l.getMonth();return(p<0||0===p&&d.getDate()<l.getDate())&&u--,{name:s,age:u}}catch(s){if(s instanceof Error){if("AbortError"===s.name)throw new v("Request timed out",y.NETWORK);if(s instanceof v)throw s;throw new v(s.message,y.NETWORK)}throw new v("Unknown error occurred",y.NETWORK_ERROR)}},e.initializeBiometricDetection=se,e.isAdvancedDetectionAvailable=ce,e.loginWithBiometric=N,e.recognize=O,e.recognizeBiometric=async(e,n,t=!0,o=.8)=>{E();const a=R(),r=await k(e);try{const e=new FormData;e.append("face_frames",r),e.append("liveness_check",t.toString()),e.append("confidence_threshold",o.toString());const i=await fetch(`${x}/api/v1/external/recognition/biometric/`,{method:"POST",headers:{"X-App-Token":n},body:e,signal:a.signal});if(!i.ok){if(401===i.status||403===i.status)throw new v("Invalid or expired application token",y.INVALID_TOKEN);throw new v(`Server returned status ${i.status}`,y.NETWORK)}const s=await i.json();return{success:s.success,confidenceScore:s.confidence_score,accessToken:s.access_token,payload:s.payload}}catch(i){if(i instanceof Error){if("AbortError"===i.name)throw new v("Request timed out",y.NETWORK);if(i instanceof v)throw i;throw new v(i.message,y.NETWORK)}throw new v("Unknown error occurred",y.NETWORK_ERROR)}},e.recognizeByPurpose=I,e.registerBiometric=async(e,n,t)=>{if(E(),!e)throw new v("Person ID is required",y.VALIDATION_ERROR);if(!n)throw new v("Face image is required",y.VALIDATION_ERROR);const o=R(),a=await k(n),r=await new Promise(((e,n)=>{const t=new FileReader;t.onload=()=>{const n=t.result;e(n.split(",")[1])},t.onerror=n,t.readAsDataURL(a)}));try{const n=await fetch(`${x}/api/v1/identity-data/`,{method:"POST",headers:{"Content-Type":"application/json","X-App-Token":t},body:JSON.stringify({person:e,type_of_identification:"FACE",biometric_data:r}),signal:o.signal});if(!n.ok){if(401===n.status||403===n.status)throw new v("Invalid or expired application token, or insufficient permissions",y.INVALID_TOKEN);if(400===n.status)try{const e=await n.json(),t=e.message||e.error||"Invalid biometric data";throw new v(t,y.VALIDATION_ERROR)}catch(i){if(i instanceof v)throw i;throw new v("Invalid biometric data",y.VALIDATION_ERROR)}throw new v(`Server returned status ${n.status}`,y.NETWORK)}const a=await n.json();return{success:!0,message:"Biometric data registered successfully",identity_data_id:a.id,type_of_identification:a.type_of_identification,have_biometric_data:a.have_biometric_data,created_at:a.created_at}}catch(s){if(s instanceof Error){if("AbortError"===s.name)throw new v("Request timed out",y.NETWORK);if(s instanceof v)throw s;throw new v(s.message,y.NETWORK)}throw new v("Unknown error occurred",y.NETWORK_ERROR)}},e.registerPersonWithBiometric=S,e.registerPersonWithoutFace=async(e,n)=>{E();const t=R();try{const o=await fetch(`${x}/api/v1/signup/donor/`,{method:"POST",headers:{"Content-Type":"application/json","X-App-Token":n},body:JSON.stringify({name:e.name,birth_date:e.birth_date,cpf:e.cpf,email:e.email,password:e.password,password_confirm:e.password}),signal:t.signal});if(!o.ok){if(401===o.status||403===o.status)throw new v("Invalid or expired application token",y.INVALID_TOKEN);throw new v(`Server returned status ${o.status}`,y.NETWORK)}return await o.json()}catch(o){if(o instanceof Error){if("AbortError"===o.name)throw new v("Request timed out",y.NETWORK);if(o instanceof v)throw o;throw new v(o.message,y.NETWORK)}throw new v("Unknown error occurred",y.NETWORK)}},e.simpleIdentification=async(e,n,t,o="LOGIN")=>{E();const a=R();try{const r=await fetch(`${x}/api/v1/external/recognition/simple/`,{method:"POST",headers:{"Content-Type":"application/json","X-App-Token":t},body:JSON.stringify({document_type:e,document_number:n,purpose:o}),signal:a.signal});if(!r.ok){if(401===r.status||403===r.status)throw new v("Invalid or expired application token",y.INVALID_TOKEN);throw new v(`Server returned status ${r.status}`,y.NETWORK)}const i=await r.json();if(!i.success)throw new v(i.message||"Identification failed",y.RECOGNITION_FAILED);return{success:i.success,personId:i.person_id,accessToken:i.access_token,payload:i.payload}}catch(r){if(r instanceof Error){if("AbortError"===r.name)throw new v("Request timed out",y.NETWORK);if(r instanceof v)throw r;throw new v(r.message,y.NETWORK)}throw new v("Unknown error occurred",y.NETWORK_ERROR)}},e.start=function(e,t){const o=document.createElement("div");o.id="neoface-modal-container",document.body.appendChild(o);const a=()=>{document.body.contains(o)&&document.body.removeChild(o)};_(e).then((()=>{const r=n.createElement(C,{accessToken:e,onClose:a,onSuccess:e=>{a(),t.onSuccess({name:e.data.faceId,email:e.data.faceId,documentId:e.data.faceId})}});s(o).render(r)})).catch((e=>{a(),t.onError("TOKEN_VALIDATION_ERROR",e.message||"Failed to validate token")}))},e.startAutoLogin=oe,e.startBiometricRegistration=function(e,t,o,a){const r=document.createElement("div");r.id="neoface-biometric-registration-container",document.body.appendChild(r);const i=()=>{document.body.contains(r)&&document.body.removeChild(r)};_(t).then((()=>{const c=n.createElement(V,{personData:e,applicationToken:t,useRealApi:(null==a?void 0:a.useRealApi)??!0,onClose:i,onSuccess:e=>{i(),o.onSuccess(e)},onError:e=>{i(),o.onError("BIOMETRIC_REGISTRATION_ERROR",e)}});s(r).render(c)})).catch((e=>{i(),o.onError("TOKEN_VALIDATION_ERROR",e.message||"Failed to validate token")}))},e.startFaceLogin=ne,e.startHandLogin=te,e.startOnboarding=async e=>{const{applicationToken:n,onboardingToken:t,countdown:o,title:a,subtitle:r,onSuccess:i,onError:s}=e;try{const e=await(async(e,n)=>{E();const t=R();try{const o=await fetch(`${x}/api/v1/onboardings/${encodeURIComponent(n)}/`,{method:"GET",headers:{"X-App-Token":e},signal:t.signal});if(!o.ok){if(401===o.status||403===o.status)throw new v("Token de aplicação inválido ou expirado",y.INVALID_TOKEN);if(404===o.status)throw new v("Link de onboarding não encontrado",y.NOT_FOUND);throw new v(`Falha ao obter detalhes (${o.status})`,y.NETWORK)}return await o.json()}catch(o){if(o instanceof Error){if("AbortError"===o.name)throw new v("Tempo de requisição excedido",y.NETWORK);if(o instanceof v)throw o;throw new v(o.message,y.NETWORK)}throw new v("Erro desconhecido",y.NETWORK_ERROR)}})(n,t);if(!(null==e?void 0:e.is_valid))throw new v("Link de onboarding inválido ou expirado",y.VALIDATION_ERROR);const s=new de({countdown:o,title:a,subtitle:r}),{face:c,document:l}=await s.open();i({...await T(n,t,c,l),details:e})}catch(c){if(c instanceof v)return void s(c);const e=(null==c?void 0:c.message)||"Erro desconhecido no onboarding";s(new v(e,y.UNKNOWN))}},e.validateOnboardingToken=async(e,n)=>{E();const t=R();try{const o=await fetch(`${x}/api/v1/onboardings/${encodeURIComponent(n)}/`,{method:"GET",headers:{"X-App-Token":e},signal:t.signal});if(!o.ok){if(401===o.status||403===o.status)throw new v("Token de aplicação inválido ou expirado",y.INVALID_TOKEN);if(404===o.status)return!1;throw new v(`Falha ao validar token (${o.status})`,y.NETWORK)}const a=await o.json();return!0===(null==a?void 0:a.is_valid)}catch(o){if(o instanceof Error){if("AbortError"===o.name)throw new v("Tempo de requisição excedido",y.NETWORK);if(o instanceof v)throw o;throw new v(o.message,y.NETWORK)}throw new v("Erro desconhecido",y.NETWORK_ERROR)}},e.validateToken=_,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}));
11
11
  //# sourceMappingURL=neoface-id-sdk.umd.js.map