upconta.frontend-utils 1.0.15 → 1.0.17

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.
@@ -7,5 +7,5 @@ import e,{useState as r,useEffect as n,useRef as t,useMemo as o,createContext as
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?fe.exports=function(){if(de)return pe;de=1;var r=e,n=Symbol.for("react.element"),t=Symbol.for("react.fragment"),o=Object.prototype.hasOwnProperty,a=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function s(e,r,t){var s,l={},c=null,u=null;for(s in void 0!==t&&(c=""+t),void 0!==r.key&&(c=""+r.key),void 0!==r.ref&&(u=r.ref),r)o.call(r,s)&&!i.hasOwnProperty(s)&&(l[s]=r[s]);if(e&&e.defaultProps)for(s in r=e.defaultProps)void 0===l[s]&&(l[s]=r[s]);return{$$typeof:n,type:e,key:c,ref:u,props:l,_owner:a.current}}return pe.Fragment=t,pe.jsx=s,pe.jsxs=s,pe}():fe.exports=(me||(me=1,"production"!==process.env.NODE_ENV&&function(){var r,n=e,t=Symbol.for("react.element"),o=Symbol.for("react.portal"),a=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),l=Symbol.for("react.provider"),c=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),d=Symbol.for("react.suspense"),f=Symbol.for("react.suspense_list"),p=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),v=Symbol.for("react.offscreen"),h=Symbol.iterator,y=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function g(e){for(var r=arguments.length,n=new Array(r>1?r-1:0),t=1;t<r;t++)n[t-1]=arguments[t];!function(e,r,n){var t=y.ReactDebugCurrentFrame.getStackAddendum();""!==t&&(r+="%s",n=n.concat([t]));var o=n.map((function(e){return String(e)}));o.unshift("Warning: "+r),Function.prototype.apply.call(console[e],console,o)}("error",e,n)}function b(e){return e.displayName||"Context"}function x(e){if(null==e)return null;if("number"==typeof e.tag&&g("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 o:return"Portal";case s:return"Profiler";case i:return"StrictMode";case d:return"Suspense";case f:return"SuspenseList"}if("object"==typeof e)switch(e.$$typeof){case c:return b(e)+".Consumer";case l:return b(e._context)+".Provider";case u:return function(e,r,n){var t=e.displayName;if(t)return t;var o=r.displayName||r.name||"";return""!==o?n+"("+o+")":n}(e,e.render,"ForwardRef");case p:var r=e.displayName||null;return null!==r?r:x(e.type)||"Memo";case m:var n=e,t=n._payload,v=n._init;try{return x(v(t))}catch(e){return null}}return null}r=Symbol.for("react.module.reference");var j,w,S,k,I,C,N,P=Object.assign,O=0;function E(){}E.__reactDisabledLog=!0;var T,F=y.ReactCurrentDispatcher;function R(e,r,n){if(void 0===T)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);T=t&&t[1]||""}return"\n"+T+e}var _,D=!1,L="function"==typeof WeakMap?WeakMap:Map;function q(e,r){if(!e||D)return"";var n,t=_.get(e);if(void 0!==t)return t;D=!0;var o,a=Error.prepareStackTrace;Error.prepareStackTrace=void 0,o=F.current,F.current=null,function(){if(0===O){j=console.log,w=console.info,S=console.warn,k=console.error,I=console.group,C=console.groupCollapsed,N=console.groupEnd;var e={configurable:!0,enumerable:!0,value:E,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}O++}();try{if(r){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(e){n=e}Reflect.construct(e,[],i)}else{try{i.call()}catch(e){n=e}e.call(i.prototype)}}else{try{throw Error()}catch(e){n=e}e()}}catch(r){if(r&&n&&"string"==typeof r.stack){for(var s=r.stack.split("\n"),l=n.stack.split("\n"),c=s.length-1,u=l.length-1;c>=1&&u>=0&&s[c]!==l[u];)u--;for(;c>=1&&u>=0;c--,u--)if(s[c]!==l[u]){if(1!==c||1!==u)do{if(c--,--u<0||s[c]!==l[u]){var d="\n"+s[c].replace(" at new "," at ");return e.displayName&&d.includes("<anonymous>")&&(d=d.replace("<anonymous>",e.displayName)),"function"==typeof e&&_.set(e,d),d}}while(c>=1&&u>=0);break}}}finally{D=!1,F.current=o,function(){if(0==--O){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:P({},e,{value:j}),info:P({},e,{value:w}),warn:P({},e,{value:S}),error:P({},e,{value:k}),group:P({},e,{value:I}),groupCollapsed:P({},e,{value:C}),groupEnd:P({},e,{value:N})})}O<0&&g("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}(),Error.prepareStackTrace=a}var f=e?e.displayName||e.name:"",p=f?R(f):"";return"function"==typeof e&&_.set(e,p),p}function $(e,r,n){if(null==e)return"";if("function"==typeof e)return q(e,!(!(t=e.prototype)||!t.isReactComponent));var t;if("string"==typeof e)return R(e);switch(e){case d:return R("Suspense");case f:return R("SuspenseList")}if("object"==typeof e)switch(e.$$typeof){case u:return q(e.render,!1);case p:return $(e.type,r,n);case m:var o=e,a=o._payload,i=o._init;try{return $(i(a),r,n)}catch(e){}}return""}_=new L;var A=Object.prototype.hasOwnProperty,U={},M=y.ReactDebugCurrentFrame;function B(e){if(e){var r=e._owner,n=$(e.type,e._source,r?r.type:null);M.setExtraStackFrame(n)}else M.setExtraStackFrame(null)}var z=Array.isArray;function W(e){return z(e)}function Y(e){return""+e}function V(e){if(function(e){try{return Y(e),!1}catch(e){return!0}}(e))return g("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)),Y(e)}var H,J,K,Q=y.ReactCurrentOwner,X={key:!0,ref:!0,__self:!0,__source:!0};function G(e,r,n,o,a){var i,s={},l=null,c=null;for(i in void 0!==n&&(V(n),l=""+n),function(e){if(A.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return void 0!==e.key}(r)&&(V(r.key),l=""+r.key),function(e){if(A.call(e,"ref")){var r=Object.getOwnPropertyDescriptor(e,"ref").get;if(r&&r.isReactWarning)return!1}return void 0!==e.ref}(r)&&(c=r.ref,function(e,r){if("string"==typeof e.ref&&Q.current&&r&&Q.current.stateNode!==r){var n=x(Q.current.type);K[n]||(g('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(Q.current.type),e.ref),K[n]=!0)}}(r,a)),r)A.call(r,i)&&!X.hasOwnProperty(i)&&(s[i]=r[i]);if(e&&e.defaultProps){var u=e.defaultProps;for(i in u)void 0===s[i]&&(s[i]=u[i])}if(l||c){var d="function"==typeof e?e.displayName||e.name||"Unknown":e;l&&function(e,r){var n=function(){H||(H=!0,g("%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)",r))};n.isReactWarning=!0,Object.defineProperty(e,"key",{get:n,configurable:!0})}(s,d),c&&function(e,r){var n=function(){J||(J=!0,g("%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)",r))};n.isReactWarning=!0,Object.defineProperty(e,"ref",{get:n,configurable:!0})}(s,d)}return function(e,r,n,o,a,i,s){var l={$$typeof:t,type:e,key:r,ref:n,props:s,_owner:i,_store:{}};return Object.defineProperty(l._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(l,"_self",{configurable:!1,enumerable:!1,writable:!1,value:o}),Object.defineProperty(l,"_source",{configurable:!1,enumerable:!1,writable:!1,value:a}),Object.freeze&&(Object.freeze(l.props),Object.freeze(l)),l}(e,l,c,a,o,Q.current,s)}K={};var Z,ee=y.ReactCurrentOwner,re=y.ReactDebugCurrentFrame;function ne(e){if(e){var r=e._owner,n=$(e.type,e._source,r?r.type:null);re.setExtraStackFrame(n)}else re.setExtraStackFrame(null)}function te(e){return"object"==typeof e&&null!==e&&e.$$typeof===t}function oe(){if(ee.current){var e=x(ee.current.type);if(e)return"\n\nCheck the render method of `"+e+"`."}return""}Z=!1;var ae={};function ie(e,r){if(e._store&&!e._store.validated&&null==e.key){e._store.validated=!0;var n=function(e){var r=oe();if(!r){var n="string"==typeof e?e:e.displayName||e.name;n&&(r="\n\nCheck the top-level render call using <"+n+">.")}return r}(r);if(!ae[n]){ae[n]=!0;var t="";e&&e._owner&&e._owner!==ee.current&&(t=" It was passed a child from "+x(e._owner.type)+"."),ne(e),g('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',n,t),ne(null)}}}function se(e,r){if("object"==typeof e)if(W(e))for(var n=0;n<e.length;n++){var t=e[n];te(t)&&ie(t,r)}else if(te(e))e._store&&(e._store.validated=!0);else if(e){var o=function(e){if(null===e||"object"!=typeof e)return null;var r=h&&e[h]||e["@@iterator"];return"function"==typeof r?r:null}(e);if("function"==typeof o&&o!==e.entries)for(var a,i=o.call(e);!(a=i.next()).done;)te(a.value)&&ie(a.value,r)}}function le(e){var r,n=e.type;if(null!=n&&"string"!=typeof n){if("function"==typeof n)r=n.propTypes;else{if("object"!=typeof n||n.$$typeof!==u&&n.$$typeof!==p)return;r=n.propTypes}if(r){var t=x(n);!function(e,r,n,t,o){var a=Function.call.bind(A);for(var i in e)if(a(e,i)){var s=void 0;try{if("function"!=typeof e[i]){var l=Error((t||"React class")+": "+n+" 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 l.name="Invariant Violation",l}s=e[i](r,i,t,n,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(e){s=e}!s||s instanceof Error||(B(o),g("%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).",t||"React class",n,i,typeof s),B(null)),s instanceof Error&&!(s.message in U)&&(U[s.message]=!0,B(o),g("Failed %s type: %s",n,s.message),B(null))}}(r,e.props,"prop",t,e)}else void 0===n.PropTypes||Z||(Z=!0,g("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",x(n)||"Unknown"));"function"!=typeof n.getDefaultProps||n.getDefaultProps.isReactClassApproved||g("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}var ce={};function ue(e,n,o,h,y,b){var j=function(e){return"string"==typeof e||"function"==typeof e||e===a||e===s||e===i||e===d||e===f||e===v||"object"==typeof e&&null!==e&&(e.$$typeof===m||e.$$typeof===p||e.$$typeof===l||e.$$typeof===c||e.$$typeof===u||e.$$typeof===r||void 0!==e.getModuleId)}(e);if(!j){var w,S="";(void 0===e||"object"==typeof e&&null!==e&&0===Object.keys(e).length)&&(S+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports."),S+=oe(),null===e?w="null":W(e)?w="array":void 0!==e&&e.$$typeof===t?(w="<"+(x(e.type)||"Unknown")+" />",S=" Did you accidentally export a JSX literal instead of a component?"):w=typeof e,g("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",w,S)}var k=G(e,n,o,y,b);if(null==k)return k;if(j){var I=n.children;if(void 0!==I)if(h)if(W(I)){for(var C=0;C<I.length;C++)se(I[C],e);Object.freeze&&Object.freeze(I)}else g("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 se(I,e)}if(A.call(n,"key")){var N=x(e),P=Object.keys(n).filter((function(e){return"key"!==e})),O=P.length>0?"{key: someKey, "+P.join(": ..., ")+": ...}":"{key: someKey}";ce[N+O]||(g('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} />',O,N,P.length>0?"{"+P.join(": ..., ")+": ...}":"{}",N),ce[N+O]=!0)}return e===a?function(e){for(var r=Object.keys(e.props),n=0;n<r.length;n++){var t=r[n];if("children"!==t&&"key"!==t){ne(e),g("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",t),ne(null);break}}null!==e.ref&&(ne(e),g("Invalid attribute `ref` supplied to `React.Fragment`."),ne(null))}(k):le(k),k}var de=function(e,r,n){return ue(e,r,n,!1)},fe=function(e,r,n){return ue(e,r,n,!0)};ve.Fragment=a,ve.jsx=de,ve.jsxs=fe}()),ve);var he=fe.exports,ye=function(e){return e.paths?he.jsx(_,{items:e.paths.map((function(e){var r=e.to,n=e.label;return{title:r?he.jsx(c,{href:r,children:n}):n}}))}):null},ge=function(e){var t,o=e.defaultInsert,a=void 0!==o&&o,i=e.loading,s=void 0!==i&&i,l=function(e,r){var n={};for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&r.indexOf(t)<0&&(n[t]=e[t]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(t=Object.getOwnPropertySymbols(e);o<t.length;o++)r.indexOf(t[o])<0&&Object.prototype.propertyIsEnumerable.call(e,t[o])&&(n[t[o]]=e[t[o]])}return n}(e,["defaultInsert","loading"]),d=u(),p=d.pathname,m=r(""),v=m[0],h=m[1],y=new URLSearchParams(d.query),g=function(){var e=new URLSearchParams(y.toString());(e.get("q")||"")!==v&&(v?e.set("q",v):e.delete("q"),e.delete("page"),d.push({query:Object.fromEntries(e)}))},b=he.jsxs("div",{className:"flex w-full md:w-auto flex-wrap md:flex-nowrap gap-2 justify-end",children:[!0!==l.ocultarBuscador?he.jsx(T.Search,{value:v,placeholder:"Ingresar búsqueda",onChange:function(e){return h(e.target.value||"")},onSearch:g,onPressEnter:g}):null,null!==a?a||he.jsx(c,{href:(t=p,t.endsWith("/")&&(t=t.slice(0,-1)),t+"/insert"),children:he.jsx(F,{type:"primary",children:"Insertar"})}):null,l.onRefrescar?he.jsx("div",{children:he.jsx(F,{loading:s,title:"Refrescar datos",icon:he.jsx(f,{}),onClick:l.onRefrescar})}):null,l.children]});return n((function(){d.isReady&&h(y.get("q")||"")}),[d.isReady]),he.jsxs("div",{className:"flex md:flex-row flex-col md:items-end items-start justify-between gap-6 mb-6",children:[he.jsxs("div",{children:[he.jsx(ye,{paths:l.paths}),he.jsx(R.Title,{className:"!mb-0 mt-4",children:l.title}),l.subtitle&&he.jsx(R.Title,{level:3,type:"secondary",className:"!font-normal !m-0",children:l.subtitle})]}),null!==l.column?l.column||b:null]})},be={hostUtils:"https://utils.upconta.com",hostFastify:"",hostRestify:"",userTokenName:"",adminTokenName:"",cookieDominio:"",cookiePath:void 0},xe=function(e){be=se(se({},be),e)},je=function(e){return le(void 0,void 0,void 0,(function(){var r,n,t,o,a,i;return ce(this,(function(s){switch(s.label){case 0:if(!((r=(null===(a=e.response)||void 0===a?void 0:a.data)?(null===(i=e.response.data)||void 0===i?void 0:i.message)||e.response.data:e.message)instanceof Blob))return[3,5];s.label=1;case 1:return s.trys.push([1,3,,5]),t=(n=JSON).parse,[4,r.text()];case 2:return[2,t.apply(n,[s.sent()]).message];case 3:return s.sent(),o={},[4,r.text()];case 4:return[2,(o.message=s.sent(),o.tipo="error",o)];case 5:return[2,{message:r,tipo:"error"}]}}))}))},we=function(){var e=D.useApp(),r=e.modal,n=e.message,t=e.notification;return{showError:function(e,n){return le(void 0,void 0,void 0,(function(){var t;return ce(this,(function(o){switch(o.label){case 0:return[4,je(e)];case 1:return t=o.sent(),r[t.tipo]({title:(null==n?void 0:n.title)||"Proceso fallido",width:450,content:he.jsxs(he.Fragment,{children:[t.message,null==n?void 0:n.cuerpoAdicional]}),okType:"danger"}),[2]}}))}))},modal:r,message:n,notification:t}},Se=function(e){return"administrador"===e?be.adminTokenName:be.userTokenName},ke=function(e,r){var n="";n=!e||"fastify"===e||e.includes("/v4")?be.hostFastify:"utils"===e?be.hostUtils:be.hostRestify;var t=G.create({baseURL:n});return"utils"!==e&&(t.defaults.headers.common.Authorization=Z(Se(null==r?void 0:r.tipo),{domain:be.cookieDominio,path:be.cookiePath})),t},Ie=function(e,r){ee(Se(r.usuario),e,{domain:be.cookieDominio,maxAge:604800,path:be.cookiePath})},Ce=function(e){re(Se(e),{domain:be.cookieDominio,path:be.cookiePath})},Ne=function(e,r){var n=new URL(e,e.includes("/v4")?be.hostFastify:be.hostRestify),t="";return r&&(t=new URLSearchParams(r).toString()),n.href+(t?"?"+t:"")},Pe=function(e,r){for(var n=(r=(r=r.replace(/\[(\w+)\]/g,".$1")).replace(/^\./,"")).split("."),t=0,o=n.length;t<o;++t){var a=n[t];if(!e||!(a in e))return;e=e[a]}return e},Oe=function(e){var r,n=0;if(0===e.length)return n;for(r=0;r<e.length;r++)n=(n<<5)-n+e.charCodeAt(r),n|=0;return n},Ee=function(e,r){void 0===r&&(r="/login");var n=r.includes("://"),t=new URL(n?r:window.location.origin+r);("/"!==e.asPath||n)&&t.searchParams.append("redirect",n?window.location.href:e.asPath),n?window.location.href=t.href:e.push(t.pathname+t.search)};function Te(e,r){void 0===r&&(r=2);var n=Math.pow(10,r);return Math.round(+(e*n).toFixed(2))/n}var Fe={empresa:function(e,r){return le(void 0,void 0,void 0,(function(){return ce(this,(function(e){switch(e.label){case 0:return r?[4,ke("restify").get("/v3/auth/business/"+r)]:[2];case 1:if(e.sent().data)throw new Error("La empresa ya se encuentra registrada");return[2]}}))}))}},Re={required:function(e){return void 0===e&&(e="El campo es requerido"),{required:!0,message:e}},min:function(e,r){return void 0===r&&(r="Debe tener mínimo ".concat(e.toString()," caracteres")),{min:e,message:r}},max:function(e,r){return void 0===r&&(r="Debe tener máximo ".concat(e.toString()," caracteres")),{max:e,message:r}},email:function(e){return void 0===e&&(e="El correo electrónico no es válido"),{type:"email",message:e}},pattern:function(e,r){return void 0===r&&(r="No cumple el formato requerido"),{pattern:e,message:r}},unico:function(e){return{validator:te(Fe[e],300)}},correos:function(){return{validator:function(e){for(var r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];return le(void 0,ue([e],r,!0),void 0,(function(e,r){return void 0===r&&(r=[]),ce(this,(function(e){if(r.some((function(e){return!e.includes("@")})))throw new Error("Alguno de los correos no es válido");return[2]}))}))}}},diasDiferencia:function(e,r){return void 0===r&&(r="La fecha ingresada no es válido"),{validator:function(n,t){return le(void 0,void 0,void 0,(function(){var n;return ce(this,(function(o){if(n=ne(t).startOf("day").diff(ne().startOf("day"),"day"),e<0?n<e:n>e)throw new Error(r);return[2]}))}))}}}},_e="es-EC",De={currency:function(e,r){return void 0===r&&(r=2),e||(e=0),new Intl.NumberFormat(_e,{style:"currency",currency:"USD",minimumFractionDigits:r}).format("number"==typeof e?e:parseFloat(e))},date:function(e,r){return void 0===r&&(r="DD/MM/YYYY"),ne(e).format(r)},completeDate:function(e){return ne(e).format("DD/MM/YYYY HH:mm:ss")},month:function(e){return ne(e).format("MM/YYYY")},percent:function(e,r){return void 0===r&&(r=2),e||(e=0),new Intl.NumberFormat(_e,{style:"percent",minimumFractionDigits:r}).format("number"==typeof e?e:parseFloat(e))}},Le=function(e){var r=ke(e.endpoint,{tipo:e.tipoUsuario||"usuario"}),n=u(),t=we().showError,o=ae().mutate,a=X(e.sinOptions?null:(e.optionsPath||e.endpoint)+"/get-options",(function(e){return le(void 0,void 0,void 0,(function(){return ce(this,(function(n){switch(n.label){case 0:return[4,r.get(e)];case 1:return[2,n.sent().data]}}))}))})).data,i=void 0===a?{}:a,s=new URLSearchParams(se(se({},e.params),n.query)).toString(),l=e.endpoint+(s?"?"+s:""),c=oe(n.isReady?l:null,(function(e){return le(void 0,void 0,void 0,(function(){return ce(this,(function(n){switch(n.label){case 0:return[4,r.get(e)];case 1:return[2,n.sent().data]}}))}))}),{keepPreviousData:!0}),d=c.data,f=c.error,p=c.isLoading,m=(null==d?void 0:d.data)||[],v=(null==d?void 0:d.total)||0,h=new URLSearchParams(n.query),y=h.get("page"),g=y?parseInt(y):1,b=h.get("limit"),x=b?parseInt(b):20,j={loading:p,dataSource:m,rowKey:"_id",bordered:!0,pagination:{current:g,defaultPageSize:x,total:v},onChange:function(e,r,t){return le(void 0,void 0,void 0,(function(){var r,o,a,i;return ce(this,(function(s){return r=h.toString(),o=new URLSearchParams(r),e.current!==g&&("1"===(a=e.current.toString())?o.delete("page"):o.set("page",a)),e.pageSize!==x&&("20"===(i=e.pageSize.toString())?o.delete("limit"):o.set("limit",i)),Array.isArray(t)||("ascend"===t.order?o.set("sort",t.field):"descend"===t.order?o.set("sort","-"+t.field):o.delete("sort")),r!==o.toString()&&n.push({query:Object.fromEntries(o)}),[2]}))}))}},w=function(){o(l)};return{data:m,isLoading:p,error:f,options:i,endpoint:e.endpoint,endpointWithHost:Ne(e.endpoint),mainroute:n.route,tableProps:j,axios:r,init:w,getOpt:function(e,r){var n,t=null===(n=i[e])||void 0===n?void 0:n.find((function(e){return e.id===r}));return t?t.description:""},remove:function(n){return le(void 0,void 0,void 0,(function(){var o;return ce(this,(function(a){switch(a.label){case 0:return a.trys.push([0,2,,3]),[4,r.delete("string"==typeof n?e.endpoint+"/"+n:n.endpoint)];case 1:return a.sent(),w(),[3,3];case 2:return o=a.sent(),t(o),[3,3];case 3:return[2]}}))}))},cancel:function(n){return le(void 0,void 0,void 0,(function(){var o;return ce(this,(function(a){switch(a.label){case 0:return a.trys.push([0,2,,3]),[4,r.delete("string"==typeof n?e.endpoint+"/"+n+"/cancel":n.endpoint)];case 1:return a.sent(),w(),[3,3];case 2:return o=a.sent(),t(o),[3,3];case 3:return[2]}}))}))}}},qe=function(e){var o=ke(e.endpoint,{tipo:e.tipoUsuario||"usuario"}),a=L.useForm()[0],i=r(!1),s=i[0],l=i[1],f=r(!1),m=f[0],v=f[1],h=u(),y=we(),g=y.showError,b=y.message,x=function(e){var o=t(!1),a=we().modal,i=t(0),s=r(0),l=s[0],c=s[1],u=function(){if(!window.confirm("¿Estás seguro que quieres salir?"))throw"Route Canceled";m(),localStorage.removeItem(e)},f=function(e){e.preventDefault()},m=function(){o.current=!1,window.removeEventListener("beforeunload",f),d.events.off("routeChangeStart",u),localStorage.removeItem(e),c(0)};return n((function(){if(o.current)return i.current!==l&&(window.addEventListener("beforeunload",f),d.events.on("routeChangeStart",u)),function(){window.removeEventListener("beforeunload",f),d.events.off("routeChangeStart",u)}}),[i.current,l]),{cambiarHashInicial:function(e){var r=Oe(JSON.stringify(e));c(r),i.current=r},cambiarDatosFormulario:function(r){if(o.current&&0!==i.current){var n=JSON.stringify(r),t=Oe(n);c(t),t===i.current?localStorage.removeItem(e):localStorage.setItem(e,n)}},limpiar:m,reanudar:function(){o.current=!0},obtenerDataEmergencia:function(){return le(void 0,void 0,void 0,(function(){var r,n;return ce(this,(function(t){switch(t.label){case 0:return r=localStorage.getItem(e),[4,new Promise((function(e){if(!r)return e(void 0);a.confirm({title:"Existen datos guardados",icon:he.jsx(p,{}),content:"Hubo un cierre inesperado pero los datos fueron guardados temporalmente ¿Deseas recuperarlos?",onOk:function(){return e(JSON.parse(r))},onCancel:function(){return e(void 0)}})}))];case 1:return n=t.sent(),o.current=!0,[2,n]}}))}))}}}(h.asPath),j=t("emitir"),w=t(h.query.id),S=X(e.sinOptions?null:e.endpoint+"/get-options",(function(e){return le(void 0,void 0,void 0,(function(){return ce(this,(function(r){switch(r.label){case 0:return[4,o.get(e)];case 1:return[2,r.sent().data]}}))}))}),{revalidateOnFocus:!1}).data,k=void 0===S?{}:S;n((function(){w.current=e.registroId,w.current||(w.current=e.soloParaInsertar?void 0:h.query.id)}),[null==e?void 0:e.registroId,e.soloParaInsertar]);var I=h.asPath.replace(/\/(insert|[\w]*\/edit$)/g,"")||"/",C=function(r){for(var n=[],t=1;t<arguments.length;t++)n[t-1]=arguments[t];return le(void 0,ue([r],n,!0),void 0,(function(r,n){var t,a,i,c,u,d,f,p;return void 0===n&&(n={}),ce(this,(function(m){switch(m.label){case 0:if(!0===s)return[2];l(!0),x.limpiar(),t=n.endpoint||e.endpoint,a=n.params||void 0,m.label=1;case 1:return m.trys.push([1,6,,7]),i=void 0,w.current?[4,o.put(t+"/"+w.current,r,{params:a})]:[3,3];case 2:return i=m.sent().data,[3,5];case 3:return[4,o.post(t,r,{params:a})];case 4:i=m.sent().data,m.label=5;case 5:return!0!==n.noRedirect?(b.success("Guardado correctamente"),h.push(I)):l(!1),[2,i];case 6:if(c=m.sent(),l(!1),n.noShowError)throw c;return g(c),u=null===(p=null===(f=null==c?void 0:c.response)||void 0===f?void 0:f.data)||void 0===p?void 0:p.comprobante,d="pruebas",["Hostname/IP does not match certificate's altnames:","El servidor del SRI no ha respondido en un largo tiempo por lo que se ha cerrado la conexión."].some((function(e){return d.includes(e)}))?h.push(I):!n.noRedirect&&u&&u!==w.current?(w.current=u,h.push(I+"/"+u+"/edit")):x.reanudar(),[3,7];case 7:return[2]}}))}))},N=he.jsxs(q,{children:[he.jsx(F,{type:"primary",loading:s,onClick:function(){return a.submit()},children:"Guardar"}),he.jsx(c,{href:I,children:he.jsx(F,{children:"Cancelar"})})]}),P=he.jsxs(he.Fragment,{children:[he.jsx($,{paragraph:{rows:3,width:"100%"},className:"mb-4"}),he.jsx($,{paragraph:{rows:4,width:"100%"},className:"mb-4"}),he.jsxs("div",{className:"grid grid-cols-2 gap-4 mb-4",children:[he.jsx($,{paragraph:{rows:4,width:"100%"}}),he.jsx($,{paragraph:{rows:4,width:"100%"}})]}),he.jsxs(q,{children:[he.jsx($.Button,{}),he.jsx($.Button,{})]})]}),O=function(){return b.warning("Revisa los errores del formulario")},E={form:a,autoComplete:"off",initialValues:e.data,onFinish:C,layout:"vertical",onFinishFailed:O};return n((function(){if(e.recuperacionEmergencia){var r=setInterval((function(){if(m){var e=a.getFieldsValue();x.cambiarDatosFormulario(e)}}),1e3);return function(){return clearInterval(r)}}}),[m]),n((function(){var r=setTimeout((function(){e.soloParaInsertar||le(void 0,void 0,void 0,(function(){var r,n,t;return ce(this,(function(i){switch(i.label){case 0:return r=!1,[4,x.obtenerDataEmergencia()];case 1:return(n=i.sent())?(w.current=n._id,r=!0,[3,4]):[3,2];case 2:return w.current?[4,o.get("".concat(e.endpoint,"/").concat(w.current),{params:e.params})]:[3,4];case 3:n=i.sent().data,i.label=4;case 4:return n?[4,null===(t=e.formatearDataInicial)||void 0===t?void 0:t.call(e,n)]:[3,6];case 5:i.sent(),a.setFieldsValue(n),i.label=6;case 6:return[2,r?e.data:n||e.data]}}))})).then((function(r){var n;return Promise.all([x.cambiarHashInicial(r),null===(n=e.onMounted)||void 0===n?void 0:n.call(e)])})).then((function(){return v(!0)}))}),200);return function(){return clearTimeout(r)}}),[h.query.id]),{form:a,router:h,options:k,tipoEmision:j,objectId:w.current,mainroute:I,isLoading:s,isReady:m,data:e.data,endpoint:e.endpoint,axios:o,onSubmit:C,onMainRouter:function(){return h.push(I)},setIsLoading:l,preventor:x,ModoCarga:P,BotonesPorDefecto:N,onMensajeValidacion:O,getOption:function(e,r){var n,t;return(null===(t=null===(n=k[e])||void 0===n?void 0:n.find((function(e){return e.id===r})))||void 0===t?void 0:t.description)||""},formProps:E}},$e=function(e){var a=e.values.customDocumentId||"_id",i=ke(e.values.endpoint),s=r(!1),l=s[0],c=s[1],u=r(),d=u[0],f=u[1],p=t(!1),h=r(""),y=h[0],g=h[1],b=o((function(){var r=new URLSearchParams(se(se(se({limit:"50"},e.values.params),e.params),e.value?{_id:e.value}:y?{q:y}:{})).toString();return r?"?"+r:""}),[e.value,y,e.params]),x=X(l?e.values.endpoint+b:null,(function(e){return le(void 0,void 0,void 0,(function(){return ce(this,(function(r){switch(r.label){case 0:return[4,i.get(e)];case 1:return[2,r.sent().data]}}))}))}),{keepPreviousData:!0}),j=x.data,w=x.isLoading;n((function(){if(!k&&void 0!==d){var e=setTimeout((function(){g(d),c(!0)}),500);return function(){return clearTimeout(e)}}}),[d]);var S=o((function(){return(null==j?void 0:j.data.map((function(r){var n,t,o=Pe(r,a),i=e.values.title(r),s=null===(t=(n=e.values).subtitle)||void 0===t?void 0:t.call(n,r);return{key:o,value:o,texto:s,item:r,label:he.jsxs("div",{children:[he.jsxs("div",{children:[he.jsx("b",{className:"mr-1",children:i}),e.value===o?he.jsx(m,{twoToneColor:"#52c41a"}):void 0]}),s?he.jsx("div",{className:"text-wrap",children:s}):null]})}})))||[]}),[e.value,j]),k=o((function(){if(e.value)return null==j?void 0:j.data.find((function(r){return Pe(r,a)===e.value}))}),[e.value,j]),I=o((function(){return!0===w?he.jsx(v,{}):k&&!e.llenarCuandoTipea?he.jsx(m,{twoToneColor:"#52c41a"}):he.jsx("span",{})}),[w,k]);return n((function(){e.value&&c(!0)}),[e.value]),n((function(){var r,n;if(k){var t=Pe(k,e.values.field),o=null===(r=e.values.formItemTexto||e.values.subtitle)||void 0===r?void 0:r(k);e.onSetTextoExtra(o||""),f(t),c(!1)}else e.onSetTextoExtra("");!0===p.current&&(null===(n=e.onSelect)||void 0===n||n.call(e,k||null))}),[k]),n((function(){var e=setTimeout((function(){p.current=!0}),1e3);return function(){return clearTimeout(e)}}),[]),he.jsx(A,{options:S,value:d,notFoundContent:"Sin resultados",disabled:e.disabled,onFocus:function(){e.value||c(!0)},onSelect:function(r){var n;c(!1),null===(n=e.onChange)||void 0===n||n.call(e,r)},onSearch:function(r){var n,t;e.llenarCuandoTipea?null===(n=e.onChange)||void 0===n||n.call(e,r):e.value&&(null===(t=e.onChange)||void 0===t||t.call(e,null)),f(r)},children:he.jsx(T,{placeholder:e.values.placeholder,suffix:I})})};$e.displayName="BuscadorSeeker";var Ae=function(e){var n,a,i,s,l=r(""),c=l[0],u=l[1],d=(n={tipo:e.type,options:void 0},a=t(n.options),i=o((function(){return function(e){switch(e.tipo){case"mesas":return{label:"Mesa",endpoint:"/v3/restaurantes/mesas",params:{fields:"codigo estado descripcion ordenActual lugar"},field:"codigo",placeholder:"Ingresa el código de mesas",title:function(e){return e.codigo},subtitle:function(e){return e.lugar}};case"meseros":return{label:"Mesero",endpoint:"/v3/restaurantes/meseros",params:{fields:"name codigo"},field:"name",placeholder:"Ingresa un mesero",title:function(e){return e.name},subtitle:function(e){return e.codigo}};case"cuentas-contables":return{label:"Cuenta contable",endpoint:"/v3/contability/chart-of-accounts",params:{fields:"codigo descripcion tipoDeCuenta auxiliar signo",tipoDeCuenta:"D"},field:"codigo",placeholder:"Ingrese el código de la cuenta",title:function(e){return e.codigo},subtitle:function(e){return e.descripcion},preBusquedaQ:function(e){return/^\d+\./.test(e)?"^"+e:e}};default:return{withOptions:!0,label:"Cliente",endpoint:"/v3/administrative/clients",params:{fields:"idType id name phone email address",estado:"activo"},field:"id",placeholder:"Ingresar la identificación del cliente",title:function(e){return"".concat(e.id)},subtitle:function(e){return e.name},preBusquedaQ:function(e){return void 0===e&&(e=""),e=e.trim(),/^\d+/.test(e)?"^"+e:e}}}}({opciones:a,tipo:n.tipo})}),[n.tipo]),s=X(i.withOptions&&!n.options?i.endpoint+"/get-options":null,(function(e){return le(void 0,void 0,void 0,(function(){return ce(this,(function(r){switch(r.label){case 0:return[4,ke(i.endpoint).get(e)];case 1:return[2,r.sent().data]}}))}))}),{revalidateOnFocus:!1}).data,s&&(a.current=s),i);return d?he.jsx(L.Item,{name:e.name,label:null===e.label?void 0:e.label||d.label,extra:e.hideMessage?void 0:c,rules:e.required?[Re.required()]:[{}],className:e.classNameFormItem,children:he.jsx($e,{type:e.type,canCreate:e.canCreate,values:d,params:e.params,onSetTextoExtra:function(r){e.hideMessage||u(r)},onSelect:e.onSelect,llenarCuandoTipea:e.llenarCuandoTipea,disabled:e.disabled,cuerpoCrear:e.cuerpoCrear,initialValue:e.initialValue})}):null};Ae.displayName="Seeker";var Ue=a(null);function Me(){return i(Ue)}var Be=function(e){var n=r([]),t=n[0],o=n[1];return he.jsxs(Ue.Provider,{value:{setBitacora:o},children:[he.jsx(ze,{bitacora:t,setBitacora:o}),e.children]})},ze=function(e){return he.jsx(U,{title:"Bitácora",placement:"right",closable:!1,open:0!==e.bitacora.length,onClose:function(){return e.setBitacora([])},children:he.jsx(M,{items:e.bitacora.map((function(e,r){var n=function(e){switch(e){case"created":case"creacion-masiva":return{color:"green"};case"draft":return{color:"orange",icon:he.jsx(C,{})};case"failed":return{color:"red",icon:he.jsx(I,{})};case"issued":case"used":return{color:"green",icon:he.jsx(k,{})};case"sent":return{color:"#1890FF",icon:he.jsx(S,{})};case"pre-canceled":return{color:"#FFA500",icon:he.jsx(p,{})};case"canceled":case"reversado":return{color:"red",icon:he.jsx(w,{})};case"edit":return{color:"#1890FF",icon:he.jsx(j,{})};case"email":return{color:"#00CCFF",icon:he.jsx(x,{})};case"deleted":return{color:"red",icon:he.jsx(b,{})};case"intermitencia":return{color:"red",icon:he.jsx(g,{})};case"exit-notice":return{color:"red",icon:he.jsx(y,{})};case"exit-notice-deleted":return{color:"green",icon:he.jsx(h,{})}}}(e.type);return{color:null==n?void 0:n.color,key:"movimiento"+r,dot:null==n?void 0:n.icon,children:he.jsxs(he.Fragment,{children:[e.nota," ",he.jsx("br",{}),De.completeDate(e.date)]})}}))})})},We="#F34D24",Ye="#FFFFFF",Ve=function(e){var t=r(!1),o=t[0],a=t[1];return n((function(){a(!0)}),[]),o?he.jsx(Be,{children:he.jsx(B,{locale:ie,theme:{token:{colorPrimary:We,colorLink:We,colorTextDisabled:"#00000080"},components:{Layout:{bodyBg:Ye,headerBg:Ye},Tag:{marginXS:0}}},children:he.jsx(D,{children:he.jsx(z,{className:(e.className||"")+" min-h-screen w-full",style:e.style,children:e.children})})})}):null},He=function(e){var t=Me().setBitacora,a=r(!1),i=a[0],s=a[1],l=o((function(){return Array.isArray(e.movimientos)&&0!==e.movimientos.length}),[e.movimientos]),c=function(){l&&t(e.movimientos)};return n((function(){var r;s(null===(r=e.movimientos)||void 0===r?void 0:r.some((function(e){return!!e.mostrarBadge})))}),[e.movimientos]),he.jsx(W,{dot:i,children:e.usarIcono?he.jsx(N,{title:"Ver historial",className:l?"":"text-gray-300 cursor-not-allowed",onClick:c}):he.jsx(F,{icon:he.jsx(N,{}),title:"Ver historial",disabled:!l,onClick:c})})},Je=function(e){var n=L.useFormInstance(),t=r([]),a=t[0],i=t[1],s=o((function(){var r=e.rules||[];switch(e.type){case"ruc":return{label:"RUC",placeholder:"Ingresar el RUC",max:13,rules:ue(ue([],r,!0),[Re.pattern(/^[0-9]{13}$/,"El ruc debe tener 13 caracteres numéricos")],!1)};case"ci":return{label:"Cédula",placeholder:"Ingresar la cédula",max:10,rules:ue(ue([],r,!0),[Re.pattern(/^[0-9]{10}$/,"La cédula debe tener 10 caracteres numéricos")],!1)};default:return{label:"Nº identificación",placeholder:"Ingresar el número de identificación",rules:r}}}),[e.type]),l=te((function(r){return le(void 0,void 0,void 0,(function(){var n,t,o;return ce(this,(function(s){switch(s.label){case 0:if(n=ke("utils"),!e.campoNombre||r.length<6||!["ci","ruc"].includes(e.type))return 0!==a.length&&i([]),[2];s.label=1;case 1:return s.trys.push([1,3,,4]),[4,n.get("/clientes/buscar",{params:{identificador:r,tipo:"ci"===e.type?"cedula":"ruc"}})];case 2:return t=s.sent().data,i(t.map((function(e){return{value:e.identificador,nombre:e.nombre,label:he.jsxs(he.Fragment,{children:[he.jsx("b",{children:e.identificador}),he.jsx("br",{}),e.nombre]})}}))),[3,4];case 3:return o=s.sent(),console.error(o),[3,4];case 4:return[2]}}))}))}),500);return he.jsx(L.Item,se({name:e.name,rules:s.rules,normalize:function(e){return e.trim().toUpperCase()},className:e.className,dependencies:e.dependencies},e.hiddenLabel?{}:{label:e.label||s.label},{children:he.jsx(A,{options:a,onSelect:function(r,t){n.setFieldValue(e.campoNombre,t.nombre)},onSearch:l,placeholder:e.placeholder||s.placeholder,maxLength:s.max,disabled:e.disabled,onChange:function(r){var n;return null===(n=e.onChange)||void 0===n?void 0:n.call(e,r)}})}))},Ke=function(e){var n=r(),t=n[0],o=n[1];return he.jsx(Y,{title:"Click para confirmar",open:!!t,children:he.jsx(F,{title:e.title,disabled:e.disabled,danger:!!t,icon:t?he.jsx(P,{}):he.jsx(b,{}),onClick:function(){if(t)e.onConfirm(),o(void 0),clearTimeout(t);else{var r=setTimeout((function(){return o(void 0)}),1500);o(r)}}})})},Qe=function(e){var n=r(!0),t=n[0],o=n[1],a=r(!1),i=a[0],s=a[1];return he.jsxs(he.Fragment,{children:[e.sidebar?he.jsxs(z.Sider,{style:{overflow:"auto",height:"100vh",position:"fixed",insetInlineStart:0,top:0,bottom:0,scrollbarWidth:"thin",scrollbarColor:"unset",zIndex:10},breakpoint:"md",collapsedWidth:0,trigger:null,collapsed:t,collapsible:!0,width:"230px",onBreakpoint:function(e){o(e),s(e)},children:[he.jsx(c,{href:e.sidebar.title.href,children:he.jsx("div",{className:"flex justify-center items-center h-16 text-lg text-white font-bold",children:he.jsx("div",{children:e.sidebar.title.label})})}),e.sidebar.menu]}):null,he.jsxs(z,{className:i||t?"ml-0":"ml-[230px]",onClick:!t&&i?function(e){e.stopPropagation(),e.preventDefault(),o(!0)}:void 0,children:[e.navbar?he.jsx(z.Header,{className:"border-b top-0 !z-[2] sticky !px-4",children:he.jsxs("div",{className:"flex justify-between items-center h-full",children:[he.jsx("div",{children:he.jsx(F,{type:"text",icon:t?he.jsx(O,{}):he.jsx(E,{}),onClick:function(){return o(!t)},children:e.navbar.title})}),e.navbar.options?he.jsx("div",{children:e.navbar.options}):he.jsx("div",{})]})}):null,he.jsx(z.Content,{className:"m-4 md:m-8 xl:mx-16 xl:my-8",children:e.children}),e.footer?he.jsx(z.Footer,{className:"!text-gray-500",children:e.footer}):null]})]})},Xe=a(null);function Ge(){return i(Xe)}var Ze=function(e){var t=u(),o=r(!1),a=o[0],i=o[1],s=r(),l=s[0],c=s[1];n((function(){le(void 0,void 0,void 0,(function(){var e,r,n,t;return ce(this,(function(o){switch(o.label){case 0:e=ke("restify"),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,Promise.all([e.get("/v3/auth/user"),e.get("/v3/businesses/me/configurations",{params:{fields:"comprobantes nDecimals invoice"}})])];case 2:return r=o.sent(),n=r[0].data,t=r[1].data,n.configuraciones=t,[2,n];case 3:return o.sent(),[2,null];case 4:return[2]}}))})).then((function(r){r?(i(!0),c(r)):Ee(t,e.pathLogin)}))}),[]);return a?he.jsx(Xe.Provider,{value:{business:l,nombreEmpresa:l.business,nombreUsuario:l.user,testEnviroment:l.configs.useTestEnviroment,usuarioEsAdmin:"admin"===l.userType,hasModule:function(e,r){var n=null==l?void 0:l.modules.find((function(r){return r.key===e}));return!!n&&ne(r).isAfter(n.operationDate)}},children:e.children}):he.jsx("div",{className:"w-full h-screen flex items-center justify-center",children:"Cargando..."})},er=function(e){var n=r(!1),t=n[0],o=n[1],a=X(t&&e.autocompletar?"/v4/administrative/clients/nombres-info-adicional":null,(function(e){return le(void 0,void 0,void 0,(function(){return ce(this,(function(r){switch(r.label){case 0:return[4,ke(e).get(e)];case 1:return[2,r.sent().data.map((function(e){return{label:e,value:e}}))]}}))}))})).data,i=void 0===a?[]:a;return he.jsx(L.List,{name:e.name,children:function(r,n){return he.jsxs("div",{children:[he.jsxs("div",{className:"flex items-center justify-between mb-4",children:[he.jsx("div",{className:"text-base font-bold",children:"Información adicional"}),he.jsx(F,{type:"dashed",onClick:function(){return n.add({})},children:"Agregar"})]}),he.jsxs(V,{dataSource:r,rowClassName:"align-top",bordered:!0,children:[he.jsx(V.Column,{title:"Nombre",render:function(r){var n=r.name;return he.jsx(L.Item,{className:"m-0 p-0",name:[n,"nombre"],rules:[Re.required()],children:e.autocompletar?he.jsx(A,{options:i,maxLength:300,placeholder:"Ingresar el nombre",onFocus:function(){return o(!0)}}):he.jsx(T,{maxLength:300,placeholder:"Ingresar el nombre"})})}},"name"),he.jsx(V.Column,{title:"Descripción",render:function(e){var r=e.name;return he.jsx(L.Item,{className:"m-0 p-0",name:[r,"valor"],rules:[Re.required()],children:he.jsx(T,{placeholder:"Ingresar la descripción"})})}},"description"),he.jsx(V.Column,{align:"center",width:1,render:function(e){var r=e.name;return he.jsx(Ke,{title:"¿Eliminar información adicional?",onConfirm:function(){return n.remove(r)}})}},"opciones")]})]})}})},rr=function(e){var r=e.form,t=L.useWatch("address",r),o=L.useWatch("direcciones",r);return n((function(){var e=setTimeout((function(){1===o.length&&r.setFieldValue("address",o[0])}),500);return function(){return clearTimeout(e)}}),[o]),he.jsx(L.List,{name:"direcciones",children:function(e,n){var a,i=n.add,s=n.remove;return he.jsxs(he.Fragment,{children:[he.jsxs("div",{className:"flex items-center justify-between mb-6",children:[he.jsx(R.Title,{level:3,className:"!m-0",children:"Direcciones"}),he.jsx(F,{type:"dashed",onClick:function(){return i(null)},children:"Agregar"})]}),0===(null===(a=o||[])||void 0===a?void 0:a.length)?he.jsx(K,{className:"my-8",description:"No hay direcciones"}):e.map((function(e){return he.jsxs("div",{className:"flex flex-wrap md:flex-nowrap items-center gap-y-2 gap-x-6 mb-6 last:mb-0",children:[he.jsx(L.Item,{name:e.name,rules:[Re.required()],className:"mb-0 w-full",children:he.jsx(T,{placeholder:"Ingresar la dirección"})}),o&&he.jsx(Q,{checked:t===o[e.name],className:"whitespace-nowrap",onChange:function(n){return t=n.target.checked,a=e.name,void(t&&r.setFieldValue("address",o[a]));var t,a},children:"Por defecto"}),he.jsx(R.Link,{className:"whitespace-nowrap",onClick:function(){o[e.name]===t&&r.setFieldValue("address",""),s(e.name)},children:"Eliminar"})]},"direcciones"+e.key)}))]})}})},nr=function(){var e=r(!1),n=e[0],t=e[1],o=X(n?"/v4/administrative/clients/etiquetas":null,(function(e){return le(void 0,void 0,void 0,(function(){return ce(this,(function(r){switch(r.label){case 0:return[4,ke(e).get(e)];case 1:return[2,r.sent().data.etiquetas]}}))}))})).data,a=void 0===o?[]:o;return he.jsx(L.Item,{name:"etiquetas",label:"Etiqueta",children:he.jsx(A,{options:a.map((function(e){return{label:e,value:e}})),placeholder:"Ingresar o seleccionar una etiqueta",onFocus:function(){return t(!0)}})})},tr=s((function(e,r){var t,a,i=u(),s=Ge().hasModule,c=qe({endpoint:"/v3/administrative/"+e.type+"s",soloParaInsertar:!0===e.ocultarBotones,params:{$getAllFields:"true"},data:{id:"",idType:"04",subjectType:"01",direcciones:[],address:"",name:void 0}}),d=L.useWatch("idType",c.form),f="client"===e.type,p="provider"===e.type,m="transporter"===e.type,v=X("08"===d?"/v3/administrative/retenciones-v2/get-options":null,(function(e){return le(void 0,void 0,void 0,(function(){return ce(this,(function(r){switch(r.label){case 0:return[4,ke(e).get(e)];case 1:return[2,r.sent().data.PaisesParaisosFiscales.map((function(e){return{label:e.description,value:parseInt(e.id)}}))]}}))}))})).data,h=o((function(){switch(d){case"04":return"ruc";case"05":return"ci";default:return"other"}}),[d]);l(r,(function(){return{insertar:c}}));var y="grid grid-cols-1 md:grid-cols-2 gap-x-6";return n((function(){var r=JSON.parse(JSON.stringify(i.query)),n=r.name,t=r.idType,o=r.identificador;t&&o&&n&&e.type}),[i.query]),c.isReady?he.jsxs(L,se({},c.formProps,{layout:"vertical",children:[he.jsxs("div",{className:y,children:[he.jsx(L.Item,{name:"idType",label:"Tipo de identificación",rules:[Re.required()],children:he.jsx(H,{options:null===(t=c.options.TiposDeIdentificacion)||void 0===t?void 0:t.map((function(e){return{label:e.description,value:e.id}}))})}),he.jsx(Je,{name:"id",campoNombre:"name",type:h,rules:[Re.required()]}),he.jsx(L.Item,{name:"name",label:"Nombres / Razón social",rules:[Re.required()],children:he.jsx(T,{placeholder:"Ingresar la razón social"})}),he.jsx(L.Item,{name:"subjectType",label:"Tipo de sujeto",rules:[Re.required()],children:he.jsx(H,{options:null===(a=c.options.TiposDePersona)||void 0===a?void 0:a.map((function(e){return{label:e.description,value:e.id}}))})})]}),he.jsx(R.Title,{level:3,children:"Información de contacto"}),he.jsxs("div",{className:y,children:[he.jsx(L.Item,{name:"phone",label:"Télefono 1",children:he.jsx(T,{type:"phone",placeholder:"Ingresar el teléfono 1"})}),f?he.jsx(L.Item,{name:"cellphone",label:"Télefono 2",children:he.jsx(T,{type:"phone",placeholder:"Ingresar el teléfono 2"})}):null,he.jsx(L.Item,{name:"email",label:"Correo electrónico",rules:[Re.email()],normalize:function(e){return e.trim()},children:he.jsx(T,{placeholder:"Ingresar el correo electrónico"})}),!m&&he.jsx(L.Item,{name:"optionalEmail",label:"Correos electrónicos alternativos",rules:[Re.correos()],children:he.jsx(H,{mode:"tags",placeholder:"Ingresar uno o varios correos alternativos",open:!1,suffixIcon:null})})]}),he.jsx(L.Item,{name:"address",noStyle:!0,children:he.jsx(T,{type:"hidden"})}),!m&&he.jsx(rr,{form:c.form}),he.jsx(R.Title,{level:3,children:"Otra información"}),he.jsxs("div",{className:y,children:[f&&s("treasury")&&he.jsx(L.Item,{name:"creditQuotaDollars",label:"Cupo de crédito en dólares",children:he.jsx(J,{className:"w-full",precision:2,min:0,placeholder:"Ingresar el cupo de crédito en dólares"})}),f&&s("treasury")&&he.jsx(L.Item,{name:"creditQuotaDays",label:"Cupo de crédito en días",children:he.jsx(J,{className:"w-full",precision:0,min:0,placeholder:"Ingresar el cupo de crédito en días"})}),p&&s("contability")&&he.jsx(Ae,{name:"accountingAccount",type:"cuentas-contables"}),p&&s("treasury")&&he.jsx(L.Item,{name:"diasPlazo",label:"Días plazo",children:he.jsx(J,{className:"w-full",precision:0,min:0,placeholder:"Ingresar los días plazo"})}),m?he.jsx(L.Item,{name:"licensePlate",label:"Placa",rules:[Re.required()],children:he.jsx(H,{mode:"tags",placeholder:"Ingresar una o varias placas",open:!1,suffixIcon:null})}):null,f&&he.jsx(L.Item,{name:"descuento",label:"Descuento adicional para facturas (%)",children:he.jsx(J,{className:"w-full",precision:2,max:100,suffix:"%",placeholder:"Ingresar el descuento"})}),f&&"08"===d&&he.jsx(L.Item,{name:"paisExportacion",label:"País de exportación",children:he.jsx(H,{allowClear:!0,showSearch:!0,placeholder:"Seleccionar el país de exportación",optionFilterProp:"children",filterOption:function(e,r){var n;return(null!==(n=null==r?void 0:r.label)&&void 0!==n?n:"").toLowerCase().includes(e.toLowerCase())},options:v})}),f&&he.jsx(nr,{})]}),he.jsx("div",{className:"mb-5",children:he.jsx(er,{name:"informacionAdicional",autocompletar:!0})}),e.ocultarBotones?null:c.BotonesPorDefecto]})):c.ModoCarga}));export{De as $filtros,Re as $reglas,Ke as BotonConfirmacion,He as BotonMovimientos,Ze as ContextoEmpresa,tr as FormularioPersonas,ge as Header,Je as IdentificadorPersona,Qe as LayoutBase,Ae as Seeker,Ve as TemaPrincipal,xe as configurarUtils,Ie as crearToken,Ce as destruirToken,Ne as getApiEndpoint,ke as getAxios,Pe as getNestedPath,Oe as hashear,Te as nDecimals,Ee as redireccionarLogin,Ge as useContextoEmpresa,Me as useFrontendUtils,we as useUtils,qe as useVistaInsertar,Le as useVistaPrincipal};
10
+ */"production"===process.env.NODE_ENV?fe.exports=function(){if(de)return pe;de=1;var r=e,n=Symbol.for("react.element"),t=Symbol.for("react.fragment"),o=Object.prototype.hasOwnProperty,a=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function s(e,r,t){var s,l={},c=null,u=null;for(s in void 0!==t&&(c=""+t),void 0!==r.key&&(c=""+r.key),void 0!==r.ref&&(u=r.ref),r)o.call(r,s)&&!i.hasOwnProperty(s)&&(l[s]=r[s]);if(e&&e.defaultProps)for(s in r=e.defaultProps)void 0===l[s]&&(l[s]=r[s]);return{$$typeof:n,type:e,key:c,ref:u,props:l,_owner:a.current}}return pe.Fragment=t,pe.jsx=s,pe.jsxs=s,pe}():fe.exports=(me||(me=1,"production"!==process.env.NODE_ENV&&function(){var r,n=e,t=Symbol.for("react.element"),o=Symbol.for("react.portal"),a=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),l=Symbol.for("react.provider"),c=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),d=Symbol.for("react.suspense"),f=Symbol.for("react.suspense_list"),p=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),v=Symbol.for("react.offscreen"),h=Symbol.iterator,y=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function g(e){for(var r=arguments.length,n=new Array(r>1?r-1:0),t=1;t<r;t++)n[t-1]=arguments[t];!function(e,r,n){var t=y.ReactDebugCurrentFrame.getStackAddendum();""!==t&&(r+="%s",n=n.concat([t]));var o=n.map((function(e){return String(e)}));o.unshift("Warning: "+r),Function.prototype.apply.call(console[e],console,o)}("error",e,n)}function b(e){return e.displayName||"Context"}function x(e){if(null==e)return null;if("number"==typeof e.tag&&g("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 o:return"Portal";case s:return"Profiler";case i:return"StrictMode";case d:return"Suspense";case f:return"SuspenseList"}if("object"==typeof e)switch(e.$$typeof){case c:return b(e)+".Consumer";case l:return b(e._context)+".Provider";case u:return function(e,r,n){var t=e.displayName;if(t)return t;var o=r.displayName||r.name||"";return""!==o?n+"("+o+")":n}(e,e.render,"ForwardRef");case p:var r=e.displayName||null;return null!==r?r:x(e.type)||"Memo";case m:var n=e,t=n._payload,v=n._init;try{return x(v(t))}catch(e){return null}}return null}r=Symbol.for("react.module.reference");var j,w,S,k,I,C,N,P=Object.assign,O=0;function E(){}E.__reactDisabledLog=!0;var T,F=y.ReactCurrentDispatcher;function R(e,r,n){if(void 0===T)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);T=t&&t[1]||""}return"\n"+T+e}var _,D=!1,L="function"==typeof WeakMap?WeakMap:Map;function q(e,r){if(!e||D)return"";var n,t=_.get(e);if(void 0!==t)return t;D=!0;var o,a=Error.prepareStackTrace;Error.prepareStackTrace=void 0,o=F.current,F.current=null,function(){if(0===O){j=console.log,w=console.info,S=console.warn,k=console.error,I=console.group,C=console.groupCollapsed,N=console.groupEnd;var e={configurable:!0,enumerable:!0,value:E,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}O++}();try{if(r){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(e){n=e}Reflect.construct(e,[],i)}else{try{i.call()}catch(e){n=e}e.call(i.prototype)}}else{try{throw Error()}catch(e){n=e}e()}}catch(r){if(r&&n&&"string"==typeof r.stack){for(var s=r.stack.split("\n"),l=n.stack.split("\n"),c=s.length-1,u=l.length-1;c>=1&&u>=0&&s[c]!==l[u];)u--;for(;c>=1&&u>=0;c--,u--)if(s[c]!==l[u]){if(1!==c||1!==u)do{if(c--,--u<0||s[c]!==l[u]){var d="\n"+s[c].replace(" at new "," at ");return e.displayName&&d.includes("<anonymous>")&&(d=d.replace("<anonymous>",e.displayName)),"function"==typeof e&&_.set(e,d),d}}while(c>=1&&u>=0);break}}}finally{D=!1,F.current=o,function(){if(0==--O){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:P({},e,{value:j}),info:P({},e,{value:w}),warn:P({},e,{value:S}),error:P({},e,{value:k}),group:P({},e,{value:I}),groupCollapsed:P({},e,{value:C}),groupEnd:P({},e,{value:N})})}O<0&&g("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}(),Error.prepareStackTrace=a}var f=e?e.displayName||e.name:"",p=f?R(f):"";return"function"==typeof e&&_.set(e,p),p}function $(e,r,n){if(null==e)return"";if("function"==typeof e)return q(e,!(!(t=e.prototype)||!t.isReactComponent));var t;if("string"==typeof e)return R(e);switch(e){case d:return R("Suspense");case f:return R("SuspenseList")}if("object"==typeof e)switch(e.$$typeof){case u:return q(e.render,!1);case p:return $(e.type,r,n);case m:var o=e,a=o._payload,i=o._init;try{return $(i(a),r,n)}catch(e){}}return""}_=new L;var A=Object.prototype.hasOwnProperty,U={},M=y.ReactDebugCurrentFrame;function B(e){if(e){var r=e._owner,n=$(e.type,e._source,r?r.type:null);M.setExtraStackFrame(n)}else M.setExtraStackFrame(null)}var z=Array.isArray;function W(e){return z(e)}function Y(e){return""+e}function V(e){if(function(e){try{return Y(e),!1}catch(e){return!0}}(e))return g("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)),Y(e)}var H,J,K,Q=y.ReactCurrentOwner,X={key:!0,ref:!0,__self:!0,__source:!0};function G(e,r,n,o,a){var i,s={},l=null,c=null;for(i in void 0!==n&&(V(n),l=""+n),function(e){if(A.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return void 0!==e.key}(r)&&(V(r.key),l=""+r.key),function(e){if(A.call(e,"ref")){var r=Object.getOwnPropertyDescriptor(e,"ref").get;if(r&&r.isReactWarning)return!1}return void 0!==e.ref}(r)&&(c=r.ref,function(e,r){if("string"==typeof e.ref&&Q.current&&r&&Q.current.stateNode!==r){var n=x(Q.current.type);K[n]||(g('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(Q.current.type),e.ref),K[n]=!0)}}(r,a)),r)A.call(r,i)&&!X.hasOwnProperty(i)&&(s[i]=r[i]);if(e&&e.defaultProps){var u=e.defaultProps;for(i in u)void 0===s[i]&&(s[i]=u[i])}if(l||c){var d="function"==typeof e?e.displayName||e.name||"Unknown":e;l&&function(e,r){var n=function(){H||(H=!0,g("%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)",r))};n.isReactWarning=!0,Object.defineProperty(e,"key",{get:n,configurable:!0})}(s,d),c&&function(e,r){var n=function(){J||(J=!0,g("%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)",r))};n.isReactWarning=!0,Object.defineProperty(e,"ref",{get:n,configurable:!0})}(s,d)}return function(e,r,n,o,a,i,s){var l={$$typeof:t,type:e,key:r,ref:n,props:s,_owner:i,_store:{}};return Object.defineProperty(l._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(l,"_self",{configurable:!1,enumerable:!1,writable:!1,value:o}),Object.defineProperty(l,"_source",{configurable:!1,enumerable:!1,writable:!1,value:a}),Object.freeze&&(Object.freeze(l.props),Object.freeze(l)),l}(e,l,c,a,o,Q.current,s)}K={};var Z,ee=y.ReactCurrentOwner,re=y.ReactDebugCurrentFrame;function ne(e){if(e){var r=e._owner,n=$(e.type,e._source,r?r.type:null);re.setExtraStackFrame(n)}else re.setExtraStackFrame(null)}function te(e){return"object"==typeof e&&null!==e&&e.$$typeof===t}function oe(){if(ee.current){var e=x(ee.current.type);if(e)return"\n\nCheck the render method of `"+e+"`."}return""}Z=!1;var ae={};function ie(e,r){if(e._store&&!e._store.validated&&null==e.key){e._store.validated=!0;var n=function(e){var r=oe();if(!r){var n="string"==typeof e?e:e.displayName||e.name;n&&(r="\n\nCheck the top-level render call using <"+n+">.")}return r}(r);if(!ae[n]){ae[n]=!0;var t="";e&&e._owner&&e._owner!==ee.current&&(t=" It was passed a child from "+x(e._owner.type)+"."),ne(e),g('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',n,t),ne(null)}}}function se(e,r){if("object"==typeof e)if(W(e))for(var n=0;n<e.length;n++){var t=e[n];te(t)&&ie(t,r)}else if(te(e))e._store&&(e._store.validated=!0);else if(e){var o=function(e){if(null===e||"object"!=typeof e)return null;var r=h&&e[h]||e["@@iterator"];return"function"==typeof r?r:null}(e);if("function"==typeof o&&o!==e.entries)for(var a,i=o.call(e);!(a=i.next()).done;)te(a.value)&&ie(a.value,r)}}function le(e){var r,n=e.type;if(null!=n&&"string"!=typeof n){if("function"==typeof n)r=n.propTypes;else{if("object"!=typeof n||n.$$typeof!==u&&n.$$typeof!==p)return;r=n.propTypes}if(r){var t=x(n);!function(e,r,n,t,o){var a=Function.call.bind(A);for(var i in e)if(a(e,i)){var s=void 0;try{if("function"!=typeof e[i]){var l=Error((t||"React class")+": "+n+" 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 l.name="Invariant Violation",l}s=e[i](r,i,t,n,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(e){s=e}!s||s instanceof Error||(B(o),g("%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).",t||"React class",n,i,typeof s),B(null)),s instanceof Error&&!(s.message in U)&&(U[s.message]=!0,B(o),g("Failed %s type: %s",n,s.message),B(null))}}(r,e.props,"prop",t,e)}else void 0===n.PropTypes||Z||(Z=!0,g("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",x(n)||"Unknown"));"function"!=typeof n.getDefaultProps||n.getDefaultProps.isReactClassApproved||g("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}var ce={};function ue(e,n,o,h,y,b){var j=function(e){return"string"==typeof e||"function"==typeof e||e===a||e===s||e===i||e===d||e===f||e===v||"object"==typeof e&&null!==e&&(e.$$typeof===m||e.$$typeof===p||e.$$typeof===l||e.$$typeof===c||e.$$typeof===u||e.$$typeof===r||void 0!==e.getModuleId)}(e);if(!j){var w,S="";(void 0===e||"object"==typeof e&&null!==e&&0===Object.keys(e).length)&&(S+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports."),S+=oe(),null===e?w="null":W(e)?w="array":void 0!==e&&e.$$typeof===t?(w="<"+(x(e.type)||"Unknown")+" />",S=" Did you accidentally export a JSX literal instead of a component?"):w=typeof e,g("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",w,S)}var k=G(e,n,o,y,b);if(null==k)return k;if(j){var I=n.children;if(void 0!==I)if(h)if(W(I)){for(var C=0;C<I.length;C++)se(I[C],e);Object.freeze&&Object.freeze(I)}else g("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 se(I,e)}if(A.call(n,"key")){var N=x(e),P=Object.keys(n).filter((function(e){return"key"!==e})),O=P.length>0?"{key: someKey, "+P.join(": ..., ")+": ...}":"{key: someKey}";ce[N+O]||(g('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} />',O,N,P.length>0?"{"+P.join(": ..., ")+": ...}":"{}",N),ce[N+O]=!0)}return e===a?function(e){for(var r=Object.keys(e.props),n=0;n<r.length;n++){var t=r[n];if("children"!==t&&"key"!==t){ne(e),g("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",t),ne(null);break}}null!==e.ref&&(ne(e),g("Invalid attribute `ref` supplied to `React.Fragment`."),ne(null))}(k):le(k),k}var de=function(e,r,n){return ue(e,r,n,!1)},fe=function(e,r,n){return ue(e,r,n,!0)};ve.Fragment=a,ve.jsx=de,ve.jsxs=fe}()),ve);var he=fe.exports,ye=function(e){return e.paths?he.jsx(_,{items:e.paths.map((function(e){var r=e.to,n=e.label;return{title:r?he.jsx(c,{href:r,children:n}):n}}))}):null},ge=function(e){var t,o=e.defaultInsert,a=void 0!==o&&o,i=e.loading,s=void 0!==i&&i,l=function(e,r){var n={};for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&r.indexOf(t)<0&&(n[t]=e[t]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(t=Object.getOwnPropertySymbols(e);o<t.length;o++)r.indexOf(t[o])<0&&Object.prototype.propertyIsEnumerable.call(e,t[o])&&(n[t[o]]=e[t[o]])}return n}(e,["defaultInsert","loading"]),d=u(),p=d.pathname,m=r(""),v=m[0],h=m[1],y=new URLSearchParams(d.query),g=function(){var e=new URLSearchParams(y.toString());(e.get("q")||"")!==v&&(v?e.set("q",v):e.delete("q"),e.delete("page"),d.push({query:Object.fromEntries(e)}))},b=he.jsxs("div",{className:"flex w-full md:w-auto flex-wrap md:flex-nowrap gap-2 justify-end",children:[!0!==l.ocultarBuscador?he.jsx(T.Search,{value:v,placeholder:"Ingresar búsqueda",onChange:function(e){return h(e.target.value||"")},onSearch:g,onPressEnter:g}):null,null!==a?a||he.jsx(c,{href:(t=p,t.endsWith("/")&&(t=t.slice(0,-1)),t+"/insert"),children:he.jsx(F,{type:"primary",children:"Insertar"})}):null,l.onRefrescar?he.jsx("div",{children:he.jsx(F,{loading:s,title:"Refrescar datos",icon:he.jsx(f,{}),onClick:l.onRefrescar})}):null,l.children]});return n((function(){d.isReady&&h(y.get("q")||"")}),[d.isReady]),he.jsxs("div",{className:"flex md:flex-row flex-col md:items-end items-start justify-between gap-6 mb-6",children:[he.jsxs("div",{children:[he.jsx(ye,{paths:l.paths}),he.jsx(R.Title,{className:"!mb-0 mt-4",children:l.title}),l.subtitle&&he.jsx(R.Title,{level:3,type:"secondary",className:"!font-normal !m-0",children:l.subtitle})]}),null!==l.column?l.column||b:null]})},be={hostUtils:"https://utils.upconta.com",hostFastify:"",hostRestify:"",userTokenName:"",adminTokenName:"",cookieDominio:"",cookiePath:void 0},xe=function(e){be=se(se({},be),e)},je=function(e){return le(void 0,void 0,void 0,(function(){var r,n,t,o,a,i;return ce(this,(function(s){switch(s.label){case 0:if(!((r=(null===(a=e.response)||void 0===a?void 0:a.data)?(null===(i=e.response.data)||void 0===i?void 0:i.message)||e.response.data:e.message)instanceof Blob))return[3,5];s.label=1;case 1:return s.trys.push([1,3,,5]),t=(n=JSON).parse,[4,r.text()];case 2:return[2,t.apply(n,[s.sent()]).message];case 3:return s.sent(),o={},[4,r.text()];case 4:return[2,(o.message=s.sent(),o.tipo="error",o)];case 5:return[2,{message:r,tipo:"error"}]}}))}))},we=function(){var e=D.useApp(),r=e.modal,n=e.message,t=e.notification;return{showError:function(e,n){return le(void 0,void 0,void 0,(function(){var t;return ce(this,(function(o){switch(o.label){case 0:return[4,je(e)];case 1:return t=o.sent(),r[t.tipo]({title:(null==n?void 0:n.title)||"Proceso fallido",width:450,content:he.jsxs(he.Fragment,{children:[t.message,null==n?void 0:n.cuerpoAdicional]}),okType:"danger"}),[2]}}))}))},modal:r,message:n,notification:t}},Se=function(e){return"administrador"===e?be.adminTokenName:be.userTokenName},ke=function(e,r){var n="";n=!e||"fastify"===e||e.includes("/v4")?be.hostFastify:"utils"===e?be.hostUtils:be.hostRestify;var t=G.create({baseURL:n});return"utils"!==e&&(t.defaults.headers.common.Authorization=Z(Se(null==r?void 0:r.tipo),{domain:be.cookieDominio,path:be.cookiePath})),t},Ie=function(e,r){ee(Se(r.usuario),e,{domain:be.cookieDominio,maxAge:604800,path:be.cookiePath})},Ce=function(e){re(Se(e),{domain:be.cookieDominio,path:be.cookiePath})},Ne=function(e,r){var n=new URL(e,e.includes("/v4")?be.hostFastify:be.hostRestify),t="";return r&&(t=new URLSearchParams(r).toString()),n.href+(t?"?"+t:"")},Pe=function(e,r){for(var n=(r=(r=r.replace(/\[(\w+)\]/g,".$1")).replace(/^\./,"")).split("."),t=0,o=n.length;t<o;++t){var a=n[t];if(!e||!(a in e))return;e=e[a]}return e},Oe=function(e){var r,n=0;if(0===e.length)return n;for(r=0;r<e.length;r++)n=(n<<5)-n+e.charCodeAt(r),n|=0;return n},Ee=function(e,r){void 0===r&&(r="/login");var n=r.includes("://"),t=new URL(n?r:window.location.origin+r);("/"!==e.asPath||n)&&t.searchParams.append("redirect",n?window.location.href:e.asPath),n?window.location.href=t.href:e.push(t.pathname+t.search)};function Te(e,r){void 0===r&&(r=2);var n=Math.pow(10,r);return Math.round(+(e*n).toFixed(2))/n}var Fe={empresa:function(e,r){return le(void 0,void 0,void 0,(function(){return ce(this,(function(e){switch(e.label){case 0:return r?[4,ke("restify").get("/v3/auth/business/"+r)]:[2];case 1:if(e.sent().data)throw new Error("La empresa ya se encuentra registrada");return[2]}}))}))}},Re={required:function(e){return void 0===e&&(e="El campo es requerido"),{required:!0,message:e}},min:function(e,r){return void 0===r&&(r="Debe tener mínimo ".concat(e.toString()," caracteres")),{min:e,message:r}},max:function(e,r){return void 0===r&&(r="Debe tener máximo ".concat(e.toString()," caracteres")),{max:e,message:r}},email:function(e){return void 0===e&&(e="El correo electrónico no es válido"),{type:"email",message:e}},pattern:function(e,r){return void 0===r&&(r="No cumple el formato requerido"),{pattern:e,message:r}},unico:function(e){return{validator:te(Fe[e],300)}},correos:function(){return{validator:function(e){for(var r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];return le(void 0,ue([e],r,!0),void 0,(function(e,r){return void 0===r&&(r=[]),ce(this,(function(e){if(r.some((function(e){return!e.includes("@")})))throw new Error("Alguno de los correos no es válido");return[2]}))}))}}},diasDiferencia:function(e,r){return void 0===r&&(r="La fecha ingresada no es válido"),{validator:function(n,t){return le(void 0,void 0,void 0,(function(){var n;return ce(this,(function(o){if(n=ne(t).startOf("day").diff(ne().startOf("day"),"day"),e<0?n<e:n>e)throw new Error(r);return[2]}))}))}}}},_e="es-EC",De={currency:function(e,r){return void 0===r&&(r=2),e||(e=0),new Intl.NumberFormat(_e,{style:"currency",currency:"USD",minimumFractionDigits:r}).format("number"==typeof e?e:parseFloat(e))},date:function(e,r){return void 0===r&&(r="DD/MM/YYYY"),ne(e).format(r)},completeDate:function(e){return ne(e).format("DD/MM/YYYY HH:mm:ss")},month:function(e){return ne(e).format("MM/YYYY")},percent:function(e,r){return void 0===r&&(r=2),e||(e=0),new Intl.NumberFormat(_e,{style:"percent",minimumFractionDigits:r}).format("number"==typeof e?e:parseFloat(e))}},Le=function(e){var r=ke(e.endpoint,{tipo:e.tipoUsuario||"usuario"}),n=u(),t=we().showError,o=ae().mutate,a=X(e.sinOptions?null:(e.optionsPath||e.endpoint)+"/get-options",(function(e){return le(void 0,void 0,void 0,(function(){return ce(this,(function(n){switch(n.label){case 0:return[4,r.get(e)];case 1:return[2,n.sent().data]}}))}))})).data,i=void 0===a?{}:a,s=new URLSearchParams(se(se({},e.params),n.query)).toString(),l=e.endpoint+(s?"?"+s:""),c=oe(n.isReady?l:null,(function(e){return le(void 0,void 0,void 0,(function(){return ce(this,(function(n){switch(n.label){case 0:return[4,r.get(e)];case 1:return[2,n.sent().data]}}))}))}),{keepPreviousData:!0}),d=c.data,f=c.error,p=c.isLoading,m=(null==d?void 0:d.data)||[],v=(null==d?void 0:d.total)||0,h=new URLSearchParams(n.query),y=h.get("page"),g=y?parseInt(y):1,b=h.get("limit"),x=b?parseInt(b):20,j={loading:p,dataSource:m,rowKey:"_id",bordered:!0,pagination:{current:g,defaultPageSize:x,total:v},onChange:function(e,r,t){return le(void 0,void 0,void 0,(function(){var r,o,a,i;return ce(this,(function(s){return r=h.toString(),o=new URLSearchParams(r),e.current!==g&&("1"===(a=e.current.toString())?o.delete("page"):o.set("page",a)),e.pageSize!==x&&("20"===(i=e.pageSize.toString())?o.delete("limit"):o.set("limit",i)),Array.isArray(t)||("ascend"===t.order?o.set("sort",t.field):"descend"===t.order?o.set("sort","-"+t.field):o.delete("sort")),r!==o.toString()&&n.push({query:Object.fromEntries(o)}),[2]}))}))}},w=function(){o(l)};return{data:m,isLoading:p,error:f,options:i,endpoint:e.endpoint,endpointWithHost:Ne(e.endpoint),mainroute:n.route,tableProps:j,axios:r,init:w,getOpt:function(e,r){var n,t=null===(n=i[e])||void 0===n?void 0:n.find((function(e){return e.id===r}));return t?t.description:""},remove:function(n){return le(void 0,void 0,void 0,(function(){var o;return ce(this,(function(a){switch(a.label){case 0:return a.trys.push([0,2,,3]),[4,r.delete("string"==typeof n?e.endpoint+"/"+n:n.endpoint)];case 1:return a.sent(),w(),[3,3];case 2:return o=a.sent(),t(o),[3,3];case 3:return[2]}}))}))},cancel:function(n){return le(void 0,void 0,void 0,(function(){var o;return ce(this,(function(a){switch(a.label){case 0:return a.trys.push([0,2,,3]),[4,r.delete("string"==typeof n?e.endpoint+"/"+n+"/cancel":n.endpoint)];case 1:return a.sent(),w(),[3,3];case 2:return o=a.sent(),t(o),[3,3];case 3:return[2]}}))}))}}},qe=function(e){var o=ke(e.endpoint,{tipo:e.tipoUsuario||"usuario"}),a=L.useForm()[0],i=r(!1),s=i[0],l=i[1],f=r(!1),m=f[0],v=f[1],h=u(),y=we(),g=y.showError,b=y.message,x=function(e){var o=t(!1),a=we().modal,i=t(0),s=r(0),l=s[0],c=s[1],u=function(){if(!window.confirm("¿Estás seguro que quieres salir?"))throw"Route Canceled";m(),localStorage.removeItem(e)},f=function(e){e.preventDefault()},m=function(){o.current=!1,window.removeEventListener("beforeunload",f),d.events.off("routeChangeStart",u),localStorage.removeItem(e),c(0)};return n((function(){if(o.current)return i.current!==l&&(window.addEventListener("beforeunload",f),d.events.on("routeChangeStart",u)),function(){window.removeEventListener("beforeunload",f),d.events.off("routeChangeStart",u)}}),[i.current,l]),{cambiarHashInicial:function(e){var r=Oe(JSON.stringify(e));c(r),i.current=r},cambiarDatosFormulario:function(r){if(o.current&&0!==i.current){var n=JSON.stringify(r),t=Oe(n);c(t),t===i.current?localStorage.removeItem(e):localStorage.setItem(e,n)}},limpiar:m,reanudar:function(){o.current=!0},obtenerDataEmergencia:function(){return le(void 0,void 0,void 0,(function(){var r,n;return ce(this,(function(t){switch(t.label){case 0:return r=localStorage.getItem(e),[4,new Promise((function(e){if(!r)return e(void 0);a.confirm({title:"Existen datos guardados",icon:he.jsx(p,{}),content:"Hubo un cierre inesperado pero los datos fueron guardados temporalmente ¿Deseas recuperarlos?",onOk:function(){return e(JSON.parse(r))},onCancel:function(){return e(void 0)}})}))];case 1:return n=t.sent(),o.current=!0,[2,n]}}))}))}}}(h.asPath),j=t("emitir"),w=t(e.data),S=t(),k=X(e.sinOptions?null:e.endpoint+"/get-options",(function(e){return le(void 0,void 0,void 0,(function(){return ce(this,(function(r){switch(r.label){case 0:return[4,o.get(e)];case 1:return[2,r.sent().data]}}))}))}),{revalidateOnFocus:!1}).data,I=void 0===k?{}:k;n((function(){S.current=e.registroId,S.current||(S.current=e.soloParaInsertar?void 0:h.query.id)}),[null==e?void 0:e.registroId,e.soloParaInsertar]);var C=h.asPath.replace(/\/(insert|[\w]*\/edit$)/g,"")||"/",N=function(r){for(var n=[],t=1;t<arguments.length;t++)n[t-1]=arguments[t];return le(void 0,ue([r],n,!0),void 0,(function(r,n){var t,a,i,c,u,d,f,p;return void 0===n&&(n={}),ce(this,(function(m){switch(m.label){case 0:if(!0===s)return[2];l(!0),x.limpiar(),t=n.endpoint||e.endpoint,a=n.params||void 0,m.label=1;case 1:return m.trys.push([1,6,,7]),i=void 0,S.current?[4,o.put(t+"/"+S.current,r,{params:a})]:[3,3];case 2:return i=m.sent().data,[3,5];case 3:return[4,o.post(t,r,{params:a})];case 4:i=m.sent().data,m.label=5;case 5:return!0!==n.noRedirect?(b.success("Guardado correctamente"),h.push(C)):l(!1),[2,i];case 6:if(c=m.sent(),l(!1),n.noShowError)throw c;return g(c),u=null===(p=null===(f=null==c?void 0:c.response)||void 0===f?void 0:f.data)||void 0===p?void 0:p.comprobante,d="pruebas",["Hostname/IP does not match certificate's altnames:","El servidor del SRI no ha respondido en un largo tiempo por lo que se ha cerrado la conexión."].some((function(e){return d.includes(e)}))?h.push(C):!n.noRedirect&&u&&u!==S.current?(S.current=u,h.push(C+"/"+u+"/edit")):x.reanudar(),[3,7];case 7:return[2]}}))}))},P=he.jsxs(q,{children:[he.jsx(F,{type:"primary",loading:s,onClick:function(){return a.submit()},children:"Guardar"}),he.jsx(c,{href:C,children:he.jsx(F,{children:"Cancelar"})})]}),O=he.jsxs(he.Fragment,{children:[he.jsx($,{paragraph:{rows:3,width:"100%"},className:"mb-4"}),he.jsx($,{paragraph:{rows:4,width:"100%"},className:"mb-4"}),he.jsxs("div",{className:"grid grid-cols-2 gap-4 mb-4",children:[he.jsx($,{paragraph:{rows:4,width:"100%"}}),he.jsx($,{paragraph:{rows:4,width:"100%"}})]}),he.jsxs(q,{children:[he.jsx($.Button,{}),he.jsx($.Button,{})]})]}),E=function(){return b.warning("Revisa los errores del formulario")},T={form:a,autoComplete:"off",initialValues:e.data,onFinish:N,layout:"vertical",onFinishFailed:E};return n((function(){if(e.recuperacionEmergencia){var r=setInterval((function(){if(m){var e=a.getFieldsValue();x.cambiarDatosFormulario(e)}}),1e3);return function(){return clearInterval(r)}}}),[m]),n((function(){if(h.isReady){S.current=h.query.id;var r=setTimeout((function(){e.soloParaInsertar||le(void 0,void 0,void 0,(function(){var r,n,t;return ce(this,(function(i){switch(i.label){case 0:return r=!1,[4,x.obtenerDataEmergencia()];case 1:return(n=i.sent())?(S.current=n._id,r=!0,[3,4]):[3,2];case 2:return S.current?[4,o.get("".concat(e.endpoint,"/").concat(S.current),{params:e.params})]:[3,4];case 3:n=i.sent().data,i.label=4;case 4:return n?[4,null===(t=e.formatearDataInicial)||void 0===t?void 0:t.call(e,n)]:[3,6];case 5:i.sent(),a.setFieldsValue(n),w.current=n,i.label=6;case 6:return[2,r?e.data:n||e.data]}}))})).then((function(r){var n;return Promise.all([x.cambiarHashInicial(r),null===(n=e.onMounted)||void 0===n?void 0:n.call(e)])})).then((function(){return v(!0)}))}),200);return function(){return clearTimeout(r)}}}),[h.query.id,h.isReady]),{form:a,router:h,options:I,tipoEmision:j,objectId:S.current,mainroute:C,isLoading:s,isReady:m,data:w.current,endpoint:e.endpoint,axios:o,onSubmit:N,onMainRouter:function(){return h.push(C)},setIsLoading:l,preventor:x,ModoCarga:O,BotonesPorDefecto:P,onMensajeValidacion:E,getOption:function(e,r){var n,t;return(null===(t=null===(n=I[e])||void 0===n?void 0:n.find((function(e){return e.id===r})))||void 0===t?void 0:t.description)||""},formProps:T}},$e=function(e){var a=e.values.customDocumentId||"_id",i=ke(e.values.endpoint),s=r(!1),l=s[0],c=s[1],u=r(),d=u[0],f=u[1],p=t(!1),h=r(""),y=h[0],g=h[1],b=o((function(){var r=new URLSearchParams(se(se(se({limit:"50"},e.values.params),e.params),e.value?{_id:e.value}:y?{q:y}:{})).toString();return r?"?"+r:""}),[e.value,y,e.params]),x=X(l?e.values.endpoint+b:null,(function(e){return le(void 0,void 0,void 0,(function(){return ce(this,(function(r){switch(r.label){case 0:return[4,i.get(e)];case 1:return[2,r.sent().data]}}))}))}),{keepPreviousData:!0}),j=x.data,w=x.isLoading;n((function(){if(!k&&void 0!==d){var e=setTimeout((function(){g(d),c(!0)}),500);return function(){return clearTimeout(e)}}}),[d]);var S=o((function(){return(null==j?void 0:j.data.map((function(r){var n,t,o=Pe(r,a),i=e.values.title(r),s=null===(t=(n=e.values).subtitle)||void 0===t?void 0:t.call(n,r);return{key:o,value:o,texto:s,item:r,label:he.jsxs("div",{children:[he.jsxs("div",{children:[he.jsx("b",{className:"mr-1",children:i}),e.value===o?he.jsx(m,{twoToneColor:"#52c41a"}):void 0]}),s?he.jsx("div",{className:"text-wrap",children:s}):null]})}})))||[]}),[e.value,j]),k=o((function(){if(e.value)return null==j?void 0:j.data.find((function(r){return Pe(r,a)===e.value}))}),[e.value,j]),I=o((function(){return!0===w?he.jsx(v,{}):k&&!e.llenarCuandoTipea?he.jsx(m,{twoToneColor:"#52c41a"}):he.jsx("span",{})}),[w,k]);return n((function(){e.value&&c(!0)}),[e.value]),n((function(){var r,n;if(k){var t=Pe(k,e.values.field),o=null===(r=e.values.formItemTexto||e.values.subtitle)||void 0===r?void 0:r(k);e.onSetTextoExtra(o||""),f(t),c(!1)}else e.onSetTextoExtra("");!0===p.current&&(null===(n=e.onSelect)||void 0===n||n.call(e,k||null))}),[k]),n((function(){var e=setTimeout((function(){p.current=!0}),1e3);return function(){return clearTimeout(e)}}),[]),he.jsx(A,{options:S,value:d,notFoundContent:"Sin resultados",disabled:e.disabled,onFocus:function(){e.value||c(!0)},onSelect:function(r){var n;c(!1),null===(n=e.onChange)||void 0===n||n.call(e,r)},onSearch:function(r){var n,t;e.llenarCuandoTipea?null===(n=e.onChange)||void 0===n||n.call(e,r):e.value&&(null===(t=e.onChange)||void 0===t||t.call(e,null)),f(r)},children:he.jsx(T,{placeholder:e.values.placeholder,suffix:I})})};$e.displayName="BuscadorSeeker";var Ae=function(e){var n,a,i,s,l=r(""),c=l[0],u=l[1],d=(n={tipo:e.type,options:void 0},a=t(n.options),i=o((function(){return function(e){switch(e.tipo){case"mesas":return{label:"Mesa",endpoint:"/v3/restaurantes/mesas",params:{fields:"codigo estado descripcion ordenActual lugar"},field:"codigo",placeholder:"Ingresa el código de mesas",title:function(e){return e.codigo},subtitle:function(e){return e.lugar}};case"meseros":return{label:"Mesero",endpoint:"/v3/restaurantes/meseros",params:{fields:"name codigo"},field:"name",placeholder:"Ingresa un mesero",title:function(e){return e.name},subtitle:function(e){return e.codigo}};case"cuentas-contables":return{label:"Cuenta contable",endpoint:"/v3/contability/chart-of-accounts",params:{fields:"codigo descripcion tipoDeCuenta auxiliar signo",tipoDeCuenta:"D"},field:"codigo",placeholder:"Ingrese el código de la cuenta",title:function(e){return e.codigo},subtitle:function(e){return e.descripcion},preBusquedaQ:function(e){return/^\d+\./.test(e)?"^"+e:e}};default:return{withOptions:!0,label:"Cliente",endpoint:"/v3/administrative/clients",params:{fields:"idType id name phone email address",estado:"activo"},field:"id",placeholder:"Ingresar la identificación del cliente",title:function(e){return"".concat(e.id)},subtitle:function(e){return e.name},preBusquedaQ:function(e){return void 0===e&&(e=""),e=e.trim(),/^\d+/.test(e)?"^"+e:e}}}}({opciones:a,tipo:n.tipo})}),[n.tipo]),s=X(i.withOptions&&!n.options?i.endpoint+"/get-options":null,(function(e){return le(void 0,void 0,void 0,(function(){return ce(this,(function(r){switch(r.label){case 0:return[4,ke(i.endpoint).get(e)];case 1:return[2,r.sent().data]}}))}))}),{revalidateOnFocus:!1}).data,s&&(a.current=s),i);return d?he.jsx(L.Item,{name:e.name,label:null===e.label?void 0:e.label||d.label,extra:e.hideMessage?void 0:c,rules:e.required?[Re.required()]:[{}],className:e.classNameFormItem,children:he.jsx($e,{type:e.type,canCreate:e.canCreate,values:d,params:e.params,onSetTextoExtra:function(r){e.hideMessage||u(r)},onSelect:e.onSelect,llenarCuandoTipea:e.llenarCuandoTipea,disabled:e.disabled,cuerpoCrear:e.cuerpoCrear,initialValue:e.initialValue})}):null};Ae.displayName="Seeker";var Ue=a(null);function Me(){return i(Ue)}var Be=function(e){var n=r([]),t=n[0],o=n[1];return he.jsxs(Ue.Provider,{value:{setBitacora:o},children:[he.jsx(ze,{bitacora:t,setBitacora:o}),e.children]})},ze=function(e){return he.jsx(U,{title:"Bitácora",placement:"right",closable:!1,open:0!==e.bitacora.length,onClose:function(){return e.setBitacora([])},children:he.jsx(M,{items:e.bitacora.map((function(e,r){var n=function(e){switch(e){case"created":case"creacion-masiva":return{color:"green"};case"draft":return{color:"orange",icon:he.jsx(C,{})};case"failed":return{color:"red",icon:he.jsx(I,{})};case"issued":case"used":return{color:"green",icon:he.jsx(k,{})};case"sent":return{color:"#1890FF",icon:he.jsx(S,{})};case"pre-canceled":return{color:"#FFA500",icon:he.jsx(p,{})};case"canceled":case"reversado":return{color:"red",icon:he.jsx(w,{})};case"edit":return{color:"#1890FF",icon:he.jsx(j,{})};case"email":return{color:"#00CCFF",icon:he.jsx(x,{})};case"deleted":return{color:"red",icon:he.jsx(b,{})};case"intermitencia":return{color:"red",icon:he.jsx(g,{})};case"exit-notice":return{color:"red",icon:he.jsx(y,{})};case"exit-notice-deleted":return{color:"green",icon:he.jsx(h,{})}}}(e.type);return{color:null==n?void 0:n.color,key:"movimiento"+r,dot:null==n?void 0:n.icon,children:he.jsxs(he.Fragment,{children:[e.nota," ",he.jsx("br",{}),De.completeDate(e.date)]})}}))})})},We="#F34D24",Ye="#FFFFFF",Ve=function(e){var t=r(!1),o=t[0],a=t[1];return n((function(){a(!0)}),[]),o?he.jsx(Be,{children:he.jsx(B,{locale:ie,theme:{token:{colorPrimary:We,colorLink:We,colorTextDisabled:"#00000080"},components:{Layout:{bodyBg:Ye,headerBg:Ye},Tag:{marginXS:0}}},children:he.jsx(D,{children:he.jsx(z,{className:(e.className||"")+" min-h-screen w-full",style:e.style,children:e.children})})})}):null},He=function(e){var t=Me().setBitacora,a=r(!1),i=a[0],s=a[1],l=o((function(){return Array.isArray(e.movimientos)&&0!==e.movimientos.length}),[e.movimientos]),c=function(){l&&t(e.movimientos)};return n((function(){var r;s(null===(r=e.movimientos)||void 0===r?void 0:r.some((function(e){return!!e.mostrarBadge})))}),[e.movimientos]),he.jsx(W,{dot:i,children:e.usarIcono?he.jsx(N,{title:"Ver historial",className:l?"":"text-gray-300 cursor-not-allowed",onClick:c}):he.jsx(F,{icon:he.jsx(N,{}),title:"Ver historial",disabled:!l,onClick:c})})},Je=function(e){var n=L.useFormInstance(),t=r([]),a=t[0],i=t[1],s=o((function(){var r=e.rules||[];switch(e.type){case"ruc":return{label:"RUC",placeholder:"Ingresar el RUC",max:13,rules:ue(ue([],r,!0),[Re.pattern(/^[0-9]{13}$/,"El ruc debe tener 13 caracteres numéricos")],!1)};case"ci":return{label:"Cédula",placeholder:"Ingresar la cédula",max:10,rules:ue(ue([],r,!0),[Re.pattern(/^[0-9]{10}$/,"La cédula debe tener 10 caracteres numéricos")],!1)};default:return{label:"Nº identificación",placeholder:"Ingresar el número de identificación",rules:r}}}),[e.type]),l=te((function(r){return le(void 0,void 0,void 0,(function(){var n,t,o;return ce(this,(function(s){switch(s.label){case 0:if(n=ke("utils"),!e.campoNombre||r.length<6||!["ci","ruc"].includes(e.type))return 0!==a.length&&i([]),[2];s.label=1;case 1:return s.trys.push([1,3,,4]),[4,n.get("/clientes/buscar",{params:{identificador:r,tipo:"ci"===e.type?"cedula":"ruc"}})];case 2:return t=s.sent().data,i(t.map((function(e){return{value:e.identificador,nombre:e.nombre,label:he.jsxs(he.Fragment,{children:[he.jsx("b",{children:e.identificador}),he.jsx("br",{}),e.nombre]})}}))),[3,4];case 3:return o=s.sent(),console.error(o),[3,4];case 4:return[2]}}))}))}),500);return he.jsx(L.Item,se({name:e.name,rules:s.rules,normalize:function(e){return e.trim().toUpperCase()},className:e.className,dependencies:e.dependencies},e.hiddenLabel?{}:{label:e.label||s.label},{children:he.jsx(A,{options:a,onSelect:function(r,t){n.setFieldValue(e.campoNombre,t.nombre)},onSearch:l,placeholder:e.placeholder||s.placeholder,maxLength:s.max,disabled:e.disabled,onChange:function(r){var n;return null===(n=e.onChange)||void 0===n?void 0:n.call(e,r)}})}))},Ke=function(e){var n=r(),t=n[0],o=n[1];return he.jsx(Y,{title:"Click para confirmar",open:!!t,children:he.jsx(F,{title:e.title,disabled:e.disabled,danger:!!t,icon:t?he.jsx(P,{}):he.jsx(b,{}),onClick:function(){if(t)e.onConfirm(),o(void 0),clearTimeout(t);else{var r=setTimeout((function(){return o(void 0)}),1500);o(r)}}})})},Qe=function(){return{hora:(new Date).toLocaleTimeString(),fecha:(new Date).toLocaleDateString(void 0,{weekday:"long",year:"numeric",month:"long",day:"numeric"})}},Xe=function(){var e=r(Qe()),t=e[0],o=e[1];return n((function(){var e=setInterval((function(){return o(Qe())}),1e3);return function(){return clearInterval(e)}}),[]),he.jsxs("div",{className:"text-right",children:[he.jsx("div",{className:"text-4xl font-bold",children:t.hora}),he.jsx("div",{className:"text-2xl text-gray-500",children:t.fecha})]})},Ge=function(e){var n=r(!0),t=n[0],o=n[1],a=r(!1),i=a[0],s=a[1];return he.jsxs(he.Fragment,{children:[e.sidebar?he.jsxs(z.Sider,{style:{overflow:"auto",height:"100vh",position:"fixed",insetInlineStart:0,top:0,bottom:0,scrollbarWidth:"thin",scrollbarColor:"unset",zIndex:10},breakpoint:"md",collapsedWidth:0,trigger:null,collapsed:t,collapsible:!0,width:"230px",onBreakpoint:function(e){o(e),s(e)},children:[he.jsx(c,{href:e.sidebar.title.href,children:he.jsx("div",{className:"flex justify-center items-center h-16 text-lg text-white font-bold",children:he.jsx("div",{children:e.sidebar.title.label})})}),e.sidebar.menu]}):null,he.jsxs(z,{className:i||t?"ml-0":"ml-[230px]",onClick:!t&&i?function(e){e.stopPropagation(),e.preventDefault(),o(!0)}:void 0,children:[e.navbar?he.jsx(z.Header,{className:"border-b top-0 !z-[2] sticky !px-4",children:he.jsxs("div",{className:"flex justify-between items-center h-full",children:[he.jsx("div",{children:he.jsx(F,{type:"text",icon:t?he.jsx(O,{}):he.jsx(E,{}),onClick:function(){return o(!t)},children:e.navbar.title})}),e.navbar.options?he.jsx("div",{children:e.navbar.options}):he.jsx("div",{})]})}):null,he.jsx(z.Content,{className:"m-4 md:m-8 xl:mx-16 xl:my-8",children:e.children}),e.footer?he.jsx(z.Footer,{className:"!text-gray-500",children:e.footer}):null]})]})},Ze=a(null);function er(){return i(Ze)}var rr=function(e){var t=u(),o=r(!1),a=o[0],i=o[1],s=r(),l=s[0],c=s[1];n((function(){le(void 0,void 0,void 0,(function(){var e,r,n,t;return ce(this,(function(o){switch(o.label){case 0:e=ke("restify"),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,Promise.all([e.get("/v3/auth/user"),e.get("/v3/businesses/me/configurations",{params:{fields:"comprobantes nDecimals invoice"}})])];case 2:return r=o.sent(),n=r[0].data,t=r[1].data,n.configuraciones=t,[2,n];case 3:return o.sent(),[2,null];case 4:return[2]}}))})).then((function(r){r?(i(!0),c(r)):Ee(t,e.pathLogin)}))}),[]);return a?he.jsx(Ze.Provider,{value:{business:l,nombreEmpresa:l.business,nombreUsuario:l.user,testEnviroment:l.configs.useTestEnviroment,usuarioEsAdmin:"admin"===l.userType,hasModule:function(e,r){var n=null==l?void 0:l.modules.find((function(r){return r.key===e}));return!!n&&ne(r).isAfter(n.operationDate)}},children:e.children}):he.jsx("div",{className:"w-full h-screen flex items-center justify-center",children:"Cargando..."})},nr=function(e){var n=r(!1),t=n[0],o=n[1],a=X(t&&e.autocompletar?"/v4/administrative/clients/nombres-info-adicional":null,(function(e){return le(void 0,void 0,void 0,(function(){return ce(this,(function(r){switch(r.label){case 0:return[4,ke(e).get(e)];case 1:return[2,r.sent().data.map((function(e){return{label:e,value:e}}))]}}))}))})).data,i=void 0===a?[]:a;return he.jsx(L.List,{name:e.name,children:function(r,n){return he.jsxs("div",{children:[he.jsxs("div",{className:"flex items-center justify-between mb-4",children:[he.jsx("div",{className:"text-base font-bold",children:"Información adicional"}),he.jsx(F,{type:"dashed",onClick:function(){return n.add({})},children:"Agregar"})]}),he.jsxs(V,{dataSource:r,rowClassName:"align-top",bordered:!0,children:[he.jsx(V.Column,{title:"Nombre",render:function(r){var n=r.name;return he.jsx(L.Item,{className:"m-0 p-0",name:[n,"nombre"],rules:[Re.required()],children:e.autocompletar?he.jsx(A,{options:i,maxLength:300,placeholder:"Ingresar el nombre",onFocus:function(){return o(!0)}}):he.jsx(T,{maxLength:300,placeholder:"Ingresar el nombre"})})}},"name"),he.jsx(V.Column,{title:"Descripción",render:function(e){var r=e.name;return he.jsx(L.Item,{className:"m-0 p-0",name:[r,"valor"],rules:[Re.required()],children:he.jsx(T,{placeholder:"Ingresar la descripción"})})}},"description"),he.jsx(V.Column,{align:"center",width:1,render:function(e){var r=e.name;return he.jsx(Ke,{title:"¿Eliminar información adicional?",onConfirm:function(){return n.remove(r)}})}},"opciones")]})]})}})},tr=function(e){var r=e.form,t=L.useWatch("address",r),o=L.useWatch("direcciones",r);return n((function(){var e=setTimeout((function(){1===o.length&&r.setFieldValue("address",o[0])}),500);return function(){return clearTimeout(e)}}),[o]),he.jsx(L.List,{name:"direcciones",children:function(e,n){var a,i=n.add,s=n.remove;return he.jsxs(he.Fragment,{children:[he.jsxs("div",{className:"flex items-center justify-between mb-6",children:[he.jsx(R.Title,{level:3,className:"!m-0",children:"Direcciones"}),he.jsx(F,{type:"dashed",onClick:function(){return i(null)},children:"Agregar"})]}),0===(null===(a=o||[])||void 0===a?void 0:a.length)?he.jsx(K,{className:"my-8",description:"No hay direcciones"}):e.map((function(e){return he.jsxs("div",{className:"flex flex-wrap md:flex-nowrap items-center gap-y-2 gap-x-6 mb-6 last:mb-0",children:[he.jsx(L.Item,{name:e.name,rules:[Re.required()],className:"mb-0 w-full",children:he.jsx(T,{placeholder:"Ingresar la dirección"})}),o&&he.jsx(Q,{checked:t===o[e.name],className:"whitespace-nowrap",onChange:function(n){return t=n.target.checked,a=e.name,void(t&&r.setFieldValue("address",o[a]));var t,a},children:"Por defecto"}),he.jsx(R.Link,{className:"whitespace-nowrap",onClick:function(){o[e.name]===t&&r.setFieldValue("address",""),s(e.name)},children:"Eliminar"})]},"direcciones"+e.key)}))]})}})},or=function(){var e=r(!1),n=e[0],t=e[1],o=X(n?"/v4/administrative/clients/etiquetas":null,(function(e){return le(void 0,void 0,void 0,(function(){return ce(this,(function(r){switch(r.label){case 0:return[4,ke(e).get(e)];case 1:return[2,r.sent().data.etiquetas]}}))}))})).data,a=void 0===o?[]:o;return he.jsx(L.Item,{name:"etiquetas",label:"Etiqueta",children:he.jsx(A,{options:a.map((function(e){return{label:e,value:e}})),placeholder:"Ingresar o seleccionar una etiqueta",onFocus:function(){return t(!0)}})})},ar=s((function(e,r){var t,a,i=u(),s=er().hasModule,c=qe({endpoint:"/v3/administrative/"+e.type+"s",soloParaInsertar:!0===e.ocultarBotones,params:{$getAllFields:"true"},data:{id:"",idType:"04",subjectType:"01",direcciones:[],address:"",name:void 0}}),d=L.useWatch("idType",c.form),f="client"===e.type,p="provider"===e.type,m="transporter"===e.type,v=X("08"===d?"/v3/administrative/retenciones-v2/get-options":null,(function(e){return le(void 0,void 0,void 0,(function(){return ce(this,(function(r){switch(r.label){case 0:return[4,ke(e).get(e)];case 1:return[2,r.sent().data.PaisesParaisosFiscales.map((function(e){return{label:e.description,value:parseInt(e.id)}}))]}}))}))})).data,h=o((function(){switch(d){case"04":return"ruc";case"05":return"ci";default:return"other"}}),[d]);l(r,(function(){return{insertar:c}}));var y="grid grid-cols-1 md:grid-cols-2 gap-x-6";return n((function(){var r=JSON.parse(JSON.stringify(i.query)),n=r.name,t=r.idType,o=r.identificador;t&&o&&n&&e.type}),[i.query]),c.isReady?he.jsxs(L,se({},c.formProps,{layout:"vertical",children:[he.jsxs("div",{className:y,children:[he.jsx(L.Item,{name:"idType",label:"Tipo de identificación",rules:[Re.required()],children:he.jsx(H,{options:null===(t=c.options.TiposDeIdentificacion)||void 0===t?void 0:t.map((function(e){return{label:e.description,value:e.id}}))})}),he.jsx(Je,{name:"id",campoNombre:"name",type:h,rules:[Re.required()]}),he.jsx(L.Item,{name:"name",label:"Nombres / Razón social",rules:[Re.required()],children:he.jsx(T,{placeholder:"Ingresar la razón social"})}),he.jsx(L.Item,{name:"subjectType",label:"Tipo de sujeto",rules:[Re.required()],children:he.jsx(H,{options:null===(a=c.options.TiposDePersona)||void 0===a?void 0:a.map((function(e){return{label:e.description,value:e.id}}))})})]}),he.jsx(R.Title,{level:3,children:"Información de contacto"}),he.jsxs("div",{className:y,children:[he.jsx(L.Item,{name:"phone",label:"Télefono 1",children:he.jsx(T,{type:"phone",placeholder:"Ingresar el teléfono 1"})}),f?he.jsx(L.Item,{name:"cellphone",label:"Télefono 2",children:he.jsx(T,{type:"phone",placeholder:"Ingresar el teléfono 2"})}):null,he.jsx(L.Item,{name:"email",label:"Correo electrónico",rules:[Re.email()],normalize:function(e){return e.trim()},children:he.jsx(T,{placeholder:"Ingresar el correo electrónico"})}),!m&&he.jsx(L.Item,{name:"optionalEmail",label:"Correos electrónicos alternativos",rules:[Re.correos()],children:he.jsx(H,{mode:"tags",placeholder:"Ingresar uno o varios correos alternativos",open:!1,suffixIcon:null})})]}),he.jsx(L.Item,{name:"address",noStyle:!0,children:he.jsx(T,{type:"hidden"})}),!m&&he.jsx(tr,{form:c.form}),he.jsx(R.Title,{level:3,children:"Otra información"}),he.jsxs("div",{className:y,children:[f&&s("treasury")&&he.jsx(L.Item,{name:"creditQuotaDollars",label:"Cupo de crédito en dólares",children:he.jsx(J,{className:"w-full",precision:2,min:0,placeholder:"Ingresar el cupo de crédito en dólares"})}),f&&s("treasury")&&he.jsx(L.Item,{name:"creditQuotaDays",label:"Cupo de crédito en días",children:he.jsx(J,{className:"w-full",precision:0,min:0,placeholder:"Ingresar el cupo de crédito en días"})}),p&&s("contability")&&he.jsx(Ae,{name:"accountingAccount",type:"cuentas-contables"}),p&&s("treasury")&&he.jsx(L.Item,{name:"diasPlazo",label:"Días plazo",children:he.jsx(J,{className:"w-full",precision:0,min:0,placeholder:"Ingresar los días plazo"})}),m?he.jsx(L.Item,{name:"licensePlate",label:"Placa",rules:[Re.required()],children:he.jsx(H,{mode:"tags",placeholder:"Ingresar una o varias placas",open:!1,suffixIcon:null})}):null,f&&he.jsx(L.Item,{name:"descuento",label:"Descuento adicional para facturas (%)",children:he.jsx(J,{className:"w-full",precision:2,max:100,suffix:"%",placeholder:"Ingresar el descuento"})}),f&&"08"===d&&he.jsx(L.Item,{name:"paisExportacion",label:"País de exportación",children:he.jsx(H,{allowClear:!0,showSearch:!0,placeholder:"Seleccionar el país de exportación",optionFilterProp:"children",filterOption:function(e,r){var n;return(null!==(n=null==r?void 0:r.label)&&void 0!==n?n:"").toLowerCase().includes(e.toLowerCase())},options:v})}),f&&he.jsx(or,{})]}),he.jsx("div",{className:"mb-5",children:he.jsx(nr,{name:"informacionAdicional",autocompletar:!0})}),e.ocultarBotones?null:c.BotonesPorDefecto]})):c.ModoCarga}));export{De as $filtros,Re as $reglas,Ke as BotonConfirmacion,He as BotonMovimientos,rr as ContextoEmpresa,ar as FormularioPersonas,ge as Header,Je as IdentificadorPersona,Ge as LayoutBase,Xe as Reloj,Ae as Seeker,Ve as TemaPrincipal,xe as configurarUtils,Ie as crearToken,Ce as destruirToken,Ne as getApiEndpoint,ke as getAxios,Pe as getNestedPath,Oe as hashear,Te as nDecimals,Ee as redireccionarLogin,er as useContextoEmpresa,Me as useFrontendUtils,we as useUtils,qe as useVistaInsertar,Le as useVistaPrincipal};
11
11
  //# sourceMappingURL=index.js.map