upconta.frontend-utils 1.0.4 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.dist/esm/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import e,{useState as t,useEffect as r,createContext as n,useContext as o,useLayoutEffect as
|
|
1
|
+
import e,{useState as t,useEffect as r,createContext as n,useContext as o,useLayoutEffect as a,useRef as i,useMemo as s,useCallback as c,useDebugValue as u}from"react";import l from"next/link";import{useRouter as f,Router as d}from"next/router";import{ReloadOutlined as p,QuestionCircleOutlined as m,MenuUnfoldOutlined as v,MenuFoldOutlined as h}from"@ant-design/icons";import{Input as y,Button as g,Typography as b,Breadcrumb as w,App as S,Form as _,Space as O,Skeleton as x,ConfigProvider as E,Layout as j,AutoComplete as k}from"antd";import R from"axios";import{getCookie as T,setCookie as L,deleteCookie as P}from"cookies-next";import D from"dayjs";import{debounce as I}from"ts-debounce";import F,{useSWRConfig as N}from"swr";import C from"antd/locale/es_ES";var A=function(){return A=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},A.apply(this,arguments)};function $(e,t,r,n){return new(r||(r=Promise))((function(o,a){function i(e){try{c(n.next(e))}catch(e){a(e)}}function s(e){try{c(n.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,s)}c((n=n.apply(e,t||[])).next())}))}function V(e,t){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(c){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(i=0)),i;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,n=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){i.label=s[1];break}if(6===s[0]&&i.label<o[1]){i.label=o[1],o=s;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(s);break}o[2]&&i.ops.pop(),i.trys.pop();continue}s=t.call(e,i)}catch(e){s=[6,e],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}}function U(e,t,r){if(r||2===arguments.length)for(var n,o=0,a=t.length;o<a;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))}"function"==typeof SuppressedError&&SuppressedError;var q,M={exports:{}},W={};var B,Y={};
|
|
2
2
|
/**
|
|
3
3
|
* @license React
|
|
4
4
|
* react-jsx-runtime.development.js
|
|
@@ -7,7 +7,7 @@ import e,{useState as t,useEffect as r,createContext as n,useContext as o,useLay
|
|
|
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?M.exports=function(){if(q)return W;q=1;var t=e,r=Symbol.for("react.element"),n=Symbol.for("react.fragment"),o=Object.prototype.hasOwnProperty,i=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,a={key:!0,ref:!0,__self:!0,__source:!0};function s(e,t,n){var s,c={},u=null,l=null;for(s in void 0!==n&&(u=""+n),void 0!==t.key&&(u=""+t.key),void 0!==t.ref&&(l=t.ref),t)o.call(t,s)&&!a.hasOwnProperty(s)&&(c[s]=t[s]);if(e&&e.defaultProps)for(s in t=e.defaultProps)void 0===c[s]&&(c[s]=t[s]);return{$$typeof:r,type:e,key:u,ref:l,props:c,_owner:i.current}}return W.Fragment=n,W.jsx=s,W.jsxs=s,W}():M.exports=(B||(B=1,"production"!==process.env.NODE_ENV&&function(){var t=e,r=Symbol.for("react.element"),n=Symbol.for("react.portal"),o=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),s=Symbol.for("react.provider"),c=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),l=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),f=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),m=Symbol.for("react.offscreen"),v=Symbol.iterator,h="@@iterator",y=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function g(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];!function(e,t,r){var n=y.ReactDebugCurrentFrame.getStackAddendum();""!==n&&(t+="%s",r=r.concat([n]));var o=r.map((function(e){return String(e)}));o.unshift("Warning: "+t),Function.prototype.apply.call(console[e],console,o)}("error",e,r)}var b,w=!1,x=!1,S=!1,_=!1,O=!1;function j(e){return e.displayName||"Context"}function E(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 o:return"Fragment";case n:return"Portal";case a:return"Profiler";case i:return"StrictMode";case l:return"Suspense";case d:return"SuspenseList"}if("object"==typeof e)switch(e.$$typeof){case c:return j(e)+".Consumer";case s:return j(e._context)+".Provider";case u:return function(e,t,r){var n=e.displayName;if(n)return n;var o=t.displayName||t.name||"";return""!==o?r+"("+o+")":r}(e,e.render,"ForwardRef");case f:var t=e.displayName||null;return null!==t?t:E(e.type)||"Memo";case p:var r=e,m=r._payload,v=r._init;try{return E(v(m))}catch(e){return null}}return null}b=Symbol.for("react.module.reference");var k,R,T,L,P,D,I,C=Object.assign,N=0;function F(){}F.__reactDisabledLog=!0;var A,$=y.ReactCurrentDispatcher;function V(e,t,r){if(void 0===A)try{throw Error()}catch(e){var n=e.stack.trim().match(/\n( *(at )?)/);A=n&&n[1]||""}return"\n"+A+e}var U,q=!1,M="function"==typeof WeakMap?WeakMap:Map;function W(e,t){if(!e||q)return"";var r,n=U.get(e);if(void 0!==n)return n;q=!0;var o,i=Error.prepareStackTrace;Error.prepareStackTrace=void 0,o=$.current,$.current=null,function(){if(0===N){k=console.log,R=console.info,T=console.warn,L=console.error,P=console.group,D=console.groupCollapsed,I=console.groupEnd;var e={configurable:!0,enumerable:!0,value:F,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}N++}();try{if(t){var a=function(){throw Error()};if(Object.defineProperty(a.prototype,"props",{set:function(){throw Error()}}),"object"==typeof Reflect&&Reflect.construct){try{Reflect.construct(a,[])}catch(e){r=e}Reflect.construct(e,[],a)}else{try{a.call()}catch(e){r=e}e.call(a.prototype)}}else{try{throw Error()}catch(e){r=e}e()}}catch(t){if(t&&r&&"string"==typeof t.stack){for(var s=t.stack.split("\n"),c=r.stack.split("\n"),u=s.length-1,l=c.length-1;u>=1&&l>=0&&s[u]!==c[l];)l--;for(;u>=1&&l>=0;u--,l--)if(s[u]!==c[l]){if(1!==u||1!==l)do{if(u--,--l<0||s[u]!==c[l]){var d="\n"+s[u].replace(" at new "," at ");return e.displayName&&d.includes("<anonymous>")&&(d=d.replace("<anonymous>",e.displayName)),"function"==typeof e&&U.set(e,d),d}}while(u>=1&&l>=0);break}}}finally{q=!1,$.current=o,function(){if(0==--N){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:C({},e,{value:k}),info:C({},e,{value:R}),warn:C({},e,{value:T}),error:C({},e,{value:L}),group:C({},e,{value:P}),groupCollapsed:C({},e,{value:D}),groupEnd:C({},e,{value:I})})}N<0&&g("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}(),Error.prepareStackTrace=i}var f=e?e.displayName||e.name:"",p=f?V(f):"";return"function"==typeof e&&U.set(e,p),p}function B(e,t,r){if(null==e)return"";if("function"==typeof e)return W(e,!(!(n=e.prototype)||!n.isReactComponent));var n;if("string"==typeof e)return V(e);switch(e){case l:return V("Suspense");case d:return V("SuspenseList")}if("object"==typeof e)switch(e.$$typeof){case u:return W(e.render,!1);case f:return B(e.type,t,r);case p:var o=e,i=o._payload,a=o._init;try{return B(a(i),t,r)}catch(e){}}return""}U=new M;var z=Object.prototype.hasOwnProperty,H={},K=y.ReactDebugCurrentFrame;function G(e){if(e){var t=e._owner,r=B(e.type,e._source,t?t.type:null);K.setExtraStackFrame(r)}else K.setExtraStackFrame(null)}var J=Array.isArray;function X(e){return J(e)}function Q(e){return""+e}function Z(e){if(function(e){try{return Q(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)),Q(e)}var ee,te,re,ne=y.ReactCurrentOwner,oe={key:!0,ref:!0,__self:!0,__source:!0};re={};var ie=function(e,t,n,o,i,a,s){var c={$$typeof:r,type:e,key:t,ref:n,props:s,_owner:a,_store:{}};return Object.defineProperty(c._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(c,"_self",{configurable:!1,enumerable:!1,writable:!1,value:o}),Object.defineProperty(c,"_source",{configurable:!1,enumerable:!1,writable:!1,value:i}),Object.freeze&&(Object.freeze(c.props),Object.freeze(c)),c};function ae(e,t,r,n,o){var i,a={},s=null,c=null;for(i in void 0!==r&&(Z(r),s=""+r),function(e){if(z.call(e,"key")){var t=Object.getOwnPropertyDescriptor(e,"key").get;if(t&&t.isReactWarning)return!1}return void 0!==e.key}(t)&&(Z(t.key),s=""+t.key),function(e){if(z.call(e,"ref")){var t=Object.getOwnPropertyDescriptor(e,"ref").get;if(t&&t.isReactWarning)return!1}return void 0!==e.ref}(t)&&(c=t.ref,function(e,t){if("string"==typeof e.ref&&ne.current&&t&&ne.current.stateNode!==t){var r=E(ne.current.type);re[r]||(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',E(ne.current.type),e.ref),re[r]=!0)}}(t,o)),t)z.call(t,i)&&!oe.hasOwnProperty(i)&&(a[i]=t[i]);if(e&&e.defaultProps){var u=e.defaultProps;for(i in u)void 0===a[i]&&(a[i]=u[i])}if(s||c){var l="function"==typeof e?e.displayName||e.name||"Unknown":e;s&&function(e,t){var r=function(){ee||(ee=!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)",t))};r.isReactWarning=!0,Object.defineProperty(e,"key",{get:r,configurable:!0})}(a,l),c&&function(e,t){var r=function(){te||(te=!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)",t))};r.isReactWarning=!0,Object.defineProperty(e,"ref",{get:r,configurable:!0})}(a,l)}return ie(e,s,c,o,n,ne.current,a)}var se,ce=y.ReactCurrentOwner,ue=y.ReactDebugCurrentFrame;function le(e){if(e){var t=e._owner,r=B(e.type,e._source,t?t.type:null);ue.setExtraStackFrame(r)}else ue.setExtraStackFrame(null)}function de(e){return"object"==typeof e&&null!==e&&e.$$typeof===r}function fe(){if(ce.current){var e=E(ce.current.type);if(e)return"\n\nCheck the render method of `"+e+"`."}return""}se=!1;var pe={};function me(e,t){if(e._store&&!e._store.validated&&null==e.key){e._store.validated=!0;var r=function(e){var t=fe();if(!t){var r="string"==typeof e?e:e.displayName||e.name;r&&(t="\n\nCheck the top-level render call using <"+r+">.")}return t}(t);if(!pe[r]){pe[r]=!0;var n="";e&&e._owner&&e._owner!==ce.current&&(n=" It was passed a child from "+E(e._owner.type)+"."),le(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.',r,n),le(null)}}}function ve(e,t){if("object"==typeof e)if(X(e))for(var r=0;r<e.length;r++){var n=e[r];de(n)&&me(n,t)}else if(de(e))e._store&&(e._store.validated=!0);else if(e){var o=function(e){if(null===e||"object"!=typeof e)return null;var t=v&&e[v]||e[h];return"function"==typeof t?t:null}(e);if("function"==typeof o&&o!==e.entries)for(var i,a=o.call(e);!(i=a.next()).done;)de(i.value)&&me(i.value,t)}}function he(e){var t,r=e.type;if(null!=r&&"string"!=typeof r){if("function"==typeof r)t=r.propTypes;else{if("object"!=typeof r||r.$$typeof!==u&&r.$$typeof!==f)return;t=r.propTypes}if(t){var n=E(r);!function(e,t,r,n,o){var i=Function.call.bind(z);for(var a in e)if(i(e,a)){var s=void 0;try{if("function"!=typeof e[a]){var c=Error((n||"React class")+": "+r+" type `"+a+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[a]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw c.name="Invariant Violation",c}s=e[a](t,a,n,r,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(e){s=e}!s||s instanceof Error||(G(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).",n||"React class",r,a,typeof s),G(null)),s instanceof Error&&!(s.message in H)&&(H[s.message]=!0,G(o),g("Failed %s type: %s",r,s.message),G(null))}}(t,e.props,"prop",n,e)}else void 0===r.PropTypes||se||(se=!0,g("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",E(r)||"Unknown"));"function"!=typeof r.getDefaultProps||r.getDefaultProps.isReactClassApproved||g("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}var ye={};function ge(e,t,n,v,h,y){var j=function(e){return"string"==typeof e||"function"==typeof e||!!(e===o||e===a||O||e===i||e===l||e===d||_||e===m||w||x||S)||"object"==typeof e&&null!==e&&(e.$$typeof===p||e.$$typeof===f||e.$$typeof===s||e.$$typeof===c||e.$$typeof===u||e.$$typeof===b||void 0!==e.getModuleId)}(e);if(!j){var k,R="";(void 0===e||"object"==typeof e&&null!==e&&0===Object.keys(e).length)&&(R+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports."),R+=fe(),null===e?k="null":X(e)?k="array":void 0!==e&&e.$$typeof===r?(k="<"+(E(e.type)||"Unknown")+" />",R=" Did you accidentally export a JSX literal instead of a component?"):k=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",k,R)}var T=ae(e,t,n,h,y);if(null==T)return T;if(j){var L=t.children;if(void 0!==L)if(v)if(X(L)){for(var P=0;P<L.length;P++)ve(L[P],e);Object.freeze&&Object.freeze(L)}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 ve(L,e)}if(z.call(t,"key")){var D=E(e),I=Object.keys(t).filter((function(e){return"key"!==e})),C=I.length>0?"{key: someKey, "+I.join(": ..., ")+": ...}":"{key: someKey}";ye[D+C]||(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} />',C,D,I.length>0?"{"+I.join(": ..., ")+": ...}":"{}",D),ye[D+C]=!0)}return e===o?function(e){for(var t=Object.keys(e.props),r=0;r<t.length;r++){var n=t[r];if("children"!==n&&"key"!==n){le(e),g("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",n),le(null);break}}null!==e.ref&&(le(e),g("Invalid attribute `ref` supplied to `React.Fragment`."),le(null))}(T):he(T),T}var be=function(e,t,r){return ge(e,t,r,!1)},we=function(e,t,r){return ge(e,t,r,!0)};Y.Fragment=o,Y.jsx=be,Y.jsxs=we}()),Y);var z=M.exports,H=function(e){return e.paths?z.jsx(w,{items:e.paths.map((function(e){var t=e.to,r=e.label;return{title:t?z.jsx(l,{href:t,children:r}):r}}))}):null},K=function(e){var n,o=e.defaultInsert,i=void 0!==o&&o,a=e.loading,s=void 0!==a&&a,c=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r}(e,["defaultInsert","loading"]),u=d(),f=u.pathname,m=t(""),v=m[0],h=m[1],w=new URLSearchParams(u.query),x=function(){var e=new URLSearchParams(w.toString());(e.get("q")||"")!==v&&(v?e.set("q",v):e.delete("q"),e.delete("page"),u.push({query:Object.fromEntries(e)}))},S=z.jsxs("div",{className:"flex w-full md:w-auto flex-wrap md:flex-nowrap gap-2 justify-end",children:[!0!==c.ocultarBuscador?z.jsx(y.Search,{value:v,placeholder:"Ingresar búsqueda",onChange:function(e){return h(e.target.value||"")},onSearch:x,onPressEnter:x}):null,null!==i?i||z.jsx(l,{href:(n=f,n.endsWith("/")&&(n=n.slice(0,-1)),n+"/insert"),children:z.jsx(g,{type:"primary",children:"Insertar"})}):null,c.onRefrescar?z.jsx("div",{children:z.jsx(g,{loading:s,title:"Refrescar datos",icon:z.jsx(p,{}),onClick:c.onRefrescar})}):null,c.children]});return r((function(){u.isReady&&h(w.get("q")||"")}),[u.isReady]),z.jsxs("div",{className:"flex md:flex-row flex-col md:items-end items-start justify-between gap-6 mb-6",children:[z.jsxs("div",{children:[z.jsx(H,{paths:c.paths}),z.jsx(b.Title,{className:"!mb-0 mt-4",children:c.title}),c.subtitle&&z.jsx(b.Title,{level:3,type:"secondary",className:"!font-normal !m-0",children:c.subtitle})]}),null!==c.column?c.column||S:null]})},G={hostUtils:"https://utils.upconta.com",hostFastify:"",hostRestify:"",userTokenName:"",adminTokenName:"",cookieDominio:"",cookiePath:void 0},J=function(e){G=A(A({},G),e)},X=function(e){return $(void 0,void 0,void 0,(function(){var t,r,n,o,i,a;return V(this,(function(s){switch(s.label){case 0:if(!((t=(null===(i=e.response)||void 0===i?void 0:i.data)?(null===(a=e.response.data)||void 0===a?void 0:a.message)||e.response.data:e.message)instanceof Blob))return[3,5];s.label=1;case 1:return s.trys.push([1,3,,5]),n=(r=JSON).parse,[4,t.text()];case 2:return[2,n.apply(r,[s.sent()]).message];case 3:return s.sent(),o={},[4,t.text()];case 4:return[2,(o.message=s.sent(),o.tipo="error",o)];case 5:return[2,{message:t,tipo:"error"}]}}))}))},Q=function(){var e=x.useApp(),t=e.modal,r=e.message,n=e.notification;return{showError:function(e,r){return $(void 0,void 0,void 0,(function(){var n;return V(this,(function(o){switch(o.label){case 0:return[4,X(e)];case 1:return n=o.sent(),t[n.tipo]({title:(null==r?void 0:r.title)||"Proceso fallido",width:450,content:z.jsxs(z.Fragment,{children:[n.message,null==r?void 0:r.cuerpoAdicional]}),okType:"danger"}),[2]}}))}))},modal:t,message:r,notification:n}},Z=function(e){return"administrador"===e?G.adminTokenName:G.userTokenName},ee=function(e,t){var r="";r=!e||"fastify"===e||e.includes("/v4")?G.hostFastify:"utils"===e?G.hostUtils:G.hostRestify;var n=R.create({baseURL:r});return"utils"!==e&&(n.defaults.headers.common.Authorization=T(Z(null==t?void 0:t.tipo),{domain:G.cookieDominio,path:G.cookiePath})),n},te=function(e,t){L(Z(t.usuario),e,{domain:G.cookieDominio,maxAge:604800,path:G.cookiePath})},re=function(e){P(Z(e),{domain:G.cookieDominio,path:G.cookiePath})},ne=function(e,t){var r=new URL(e,e.includes("v4")?G.hostFastify:G.hostRestify),n="";return t&&(n=new URLSearchParams(t).toString()),r.href+(n?"?"+n:"")},oe=function(e){var t,r=0;if(0===e.length)return r;for(t=0;t<e.length;t++)r=(r<<5)-r+e.charCodeAt(t),r|=0;return r},ie=function(e,t){void 0===t&&(t="/login");var r=t.includes("://"),n=new URL(r?t:window.location.origin+t);("/"!==e.asPath||r)&&n.searchParams.append("redirect",r?window.location.href:e.asPath),r?window.location.href=n.href:e.push(n.pathname+n.search)},ae={empresa:function(e,t){return $(void 0,void 0,void 0,(function(){return V(this,(function(e){switch(e.label){case 0:return t?[4,ee("restify").get("/v3/auth/business/"+t)]:[2];case 1:if(e.sent().data)throw new Error("La empresa ya se encuentra registrada");return[2]}}))}))}},se={required:function(e){return void 0===e&&(e="El campo es requerido"),{required:!0,message:e}},min:function(e,t){return void 0===t&&(t="Debe tener mínimo ".concat(e.toString()," caracteres")),{min:e,message:t}},max:function(e,t){return void 0===t&&(t="Debe tener máximo ".concat(e.toString()," caracteres")),{max:e,message:t}},email:function(e){return void 0===e&&(e="El correo electrónico no es válido"),{type:"email",message:e}},pattern:function(e,t){return void 0===t&&(t="No cumple el formato requerido"),{pattern:e,message:t}},unico:function(e){return{validator:I(ae[e],300)}},correos:function(){return{validator:function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return $(void 0,U([e],t,!0),void 0,(function(e,t){return void 0===t&&(t=[]),V(this,(function(e){if(t.some((function(e){return!e.includes("@")})))throw new Error("Alguno de los correos no es válido");return[2]}))}))}}},diasDiferencia:function(e,t){return void 0===t&&(t="La fecha ingresada no es válido"),{validator:function(r,n){return $(void 0,void 0,void 0,(function(){var r;return V(this,(function(o){if(r=D(n).startOf("day").diff(D().startOf("day"),"day"),e<0?r<e:r>e)throw new Error(t);return[2]}))}))}}}},ce="es-EC",ue={currency:function(e,t){return void 0===t&&(t=2),e||(e=0),new Intl.NumberFormat(ce,{style:"currency",currency:"USD",minimumFractionDigits:t}).format("number"==typeof e?e:parseFloat(e))},date:function(e,t){return void 0===t&&(t="DD/MM/YYYY"),D(e).format(t)},completeDate:function(e){return D(e).format("DD/MM/YYYY HH:mm:ss")},month:function(e){return D(e).format("MM/YYYY")},percent:function(e,t){return void 0===t&&(t=2),e||(e=0),new Intl.NumberFormat(ce,{style:"percent",minimumFractionDigits:t}).format("number"==typeof e?e:parseFloat(e))}},le=n(null);function de(){return o(le)}var fe,pe=function(e){var n=d(),o=t(!1),i=o[0],a=o[1],s=t(),c=s[0],u=s[1];return r((function(){$(void 0,void 0,void 0,(function(){var e,t,r,n;return V(this,(function(o){switch(o.label){case 0:e=ee("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 t=o.sent(),r=t[0].data,n=t[1].data,r.configuraciones=n,[2,r];case 3:return o.sent(),[2,null];case 4:return[2]}}))})).then((function(t){t?(a(!0),u(t)):ie(n,e.pathLogin)}))}),[]),i?z.jsx(le.Provider,{value:{business:c,nombreEmpresa:c.business,nombreUsuario:c.user,testEnviroment:c.configs.useTestEnviroment,usuarioEsAdmin:"admin"===c.userType},children:e.children}):z.jsx("div",{className:"w-full h-screen flex items-center justify-center",children:"Cargando..."})},me={exports:{}},ve={};var he,ye={};
|
|
10
|
+
*/"production"===process.env.NODE_ENV?M.exports=function(){if(q)return W;q=1;var t=e,r=Symbol.for("react.element"),n=Symbol.for("react.fragment"),o=Object.prototype.hasOwnProperty,a=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function s(e,t,n){var s,c={},u=null,l=null;for(s in void 0!==n&&(u=""+n),void 0!==t.key&&(u=""+t.key),void 0!==t.ref&&(l=t.ref),t)o.call(t,s)&&!i.hasOwnProperty(s)&&(c[s]=t[s]);if(e&&e.defaultProps)for(s in t=e.defaultProps)void 0===c[s]&&(c[s]=t[s]);return{$$typeof:r,type:e,key:u,ref:l,props:c,_owner:a.current}}return W.Fragment=n,W.jsx=s,W.jsxs=s,W}():M.exports=(B||(B=1,"production"!==process.env.NODE_ENV&&function(){var t=e,r=Symbol.for("react.element"),n=Symbol.for("react.portal"),o=Symbol.for("react.fragment"),a=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),s=Symbol.for("react.provider"),c=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),l=Symbol.for("react.suspense"),f=Symbol.for("react.suspense_list"),d=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),m=Symbol.for("react.offscreen"),v=Symbol.iterator,h="@@iterator",y=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function g(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];!function(e,t,r){var n=y.ReactDebugCurrentFrame.getStackAddendum();""!==n&&(t+="%s",r=r.concat([n]));var o=r.map((function(e){return String(e)}));o.unshift("Warning: "+t),Function.prototype.apply.call(console[e],console,o)}("error",e,r)}var b,w=!1,S=!1,_=!1,O=!1,x=!1;function E(e){return e.displayName||"Context"}function j(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 o:return"Fragment";case n:return"Portal";case i:return"Profiler";case a:return"StrictMode";case l:return"Suspense";case f:return"SuspenseList"}if("object"==typeof e)switch(e.$$typeof){case c:return E(e)+".Consumer";case s:return E(e._context)+".Provider";case u:return function(e,t,r){var n=e.displayName;if(n)return n;var o=t.displayName||t.name||"";return""!==o?r+"("+o+")":r}(e,e.render,"ForwardRef");case d:var t=e.displayName||null;return null!==t?t:j(e.type)||"Memo";case p:var r=e,m=r._payload,v=r._init;try{return j(v(m))}catch(e){return null}}return null}b=Symbol.for("react.module.reference");var k,R,T,L,P,D,I,F=Object.assign,N=0;function C(){}C.__reactDisabledLog=!0;var A,$=y.ReactCurrentDispatcher;function V(e,t,r){if(void 0===A)try{throw Error()}catch(e){var n=e.stack.trim().match(/\n( *(at )?)/);A=n&&n[1]||""}return"\n"+A+e}var U,q=!1,M="function"==typeof WeakMap?WeakMap:Map;function W(e,t){if(!e||q)return"";var r,n=U.get(e);if(void 0!==n)return n;q=!0;var o,a=Error.prepareStackTrace;Error.prepareStackTrace=void 0,o=$.current,$.current=null,function(){if(0===N){k=console.log,R=console.info,T=console.warn,L=console.error,P=console.group,D=console.groupCollapsed,I=console.groupEnd;var e={configurable:!0,enumerable:!0,value:C,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}N++}();try{if(t){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){r=e}Reflect.construct(e,[],i)}else{try{i.call()}catch(e){r=e}e.call(i.prototype)}}else{try{throw Error()}catch(e){r=e}e()}}catch(t){if(t&&r&&"string"==typeof t.stack){for(var s=t.stack.split("\n"),c=r.stack.split("\n"),u=s.length-1,l=c.length-1;u>=1&&l>=0&&s[u]!==c[l];)l--;for(;u>=1&&l>=0;u--,l--)if(s[u]!==c[l]){if(1!==u||1!==l)do{if(u--,--l<0||s[u]!==c[l]){var f="\n"+s[u].replace(" at new "," at ");return e.displayName&&f.includes("<anonymous>")&&(f=f.replace("<anonymous>",e.displayName)),"function"==typeof e&&U.set(e,f),f}}while(u>=1&&l>=0);break}}}finally{q=!1,$.current=o,function(){if(0==--N){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:F({},e,{value:k}),info:F({},e,{value:R}),warn:F({},e,{value:T}),error:F({},e,{value:L}),group:F({},e,{value:P}),groupCollapsed:F({},e,{value:D}),groupEnd:F({},e,{value:I})})}N<0&&g("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}(),Error.prepareStackTrace=a}var d=e?e.displayName||e.name:"",p=d?V(d):"";return"function"==typeof e&&U.set(e,p),p}function B(e,t,r){if(null==e)return"";if("function"==typeof e)return W(e,!(!(n=e.prototype)||!n.isReactComponent));var n;if("string"==typeof e)return V(e);switch(e){case l:return V("Suspense");case f:return V("SuspenseList")}if("object"==typeof e)switch(e.$$typeof){case u:return W(e.render,!1);case d:return B(e.type,t,r);case p:var o=e,a=o._payload,i=o._init;try{return B(i(a),t,r)}catch(e){}}return""}U=new M;var H=Object.prototype.hasOwnProperty,z={},K=y.ReactDebugCurrentFrame;function G(e){if(e){var t=e._owner,r=B(e.type,e._source,t?t.type:null);K.setExtraStackFrame(r)}else K.setExtraStackFrame(null)}var J=Array.isArray;function X(e){return J(e)}function Q(e){return""+e}function Z(e){if(function(e){try{return Q(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)),Q(e)}var ee,te,re,ne=y.ReactCurrentOwner,oe={key:!0,ref:!0,__self:!0,__source:!0};re={};var ae=function(e,t,n,o,a,i,s){var c={$$typeof:r,type:e,key:t,ref:n,props:s,_owner:i,_store:{}};return Object.defineProperty(c._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(c,"_self",{configurable:!1,enumerable:!1,writable:!1,value:o}),Object.defineProperty(c,"_source",{configurable:!1,enumerable:!1,writable:!1,value:a}),Object.freeze&&(Object.freeze(c.props),Object.freeze(c)),c};function ie(e,t,r,n,o){var a,i={},s=null,c=null;for(a in void 0!==r&&(Z(r),s=""+r),function(e){if(H.call(e,"key")){var t=Object.getOwnPropertyDescriptor(e,"key").get;if(t&&t.isReactWarning)return!1}return void 0!==e.key}(t)&&(Z(t.key),s=""+t.key),function(e){if(H.call(e,"ref")){var t=Object.getOwnPropertyDescriptor(e,"ref").get;if(t&&t.isReactWarning)return!1}return void 0!==e.ref}(t)&&(c=t.ref,function(e,t){if("string"==typeof e.ref&&ne.current&&t&&ne.current.stateNode!==t){var r=j(ne.current.type);re[r]||(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',j(ne.current.type),e.ref),re[r]=!0)}}(t,o)),t)H.call(t,a)&&!oe.hasOwnProperty(a)&&(i[a]=t[a]);if(e&&e.defaultProps){var u=e.defaultProps;for(a in u)void 0===i[a]&&(i[a]=u[a])}if(s||c){var l="function"==typeof e?e.displayName||e.name||"Unknown":e;s&&function(e,t){var r=function(){ee||(ee=!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)",t))};r.isReactWarning=!0,Object.defineProperty(e,"key",{get:r,configurable:!0})}(i,l),c&&function(e,t){var r=function(){te||(te=!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)",t))};r.isReactWarning=!0,Object.defineProperty(e,"ref",{get:r,configurable:!0})}(i,l)}return ae(e,s,c,o,n,ne.current,i)}var se,ce=y.ReactCurrentOwner,ue=y.ReactDebugCurrentFrame;function le(e){if(e){var t=e._owner,r=B(e.type,e._source,t?t.type:null);ue.setExtraStackFrame(r)}else ue.setExtraStackFrame(null)}function fe(e){return"object"==typeof e&&null!==e&&e.$$typeof===r}function de(){if(ce.current){var e=j(ce.current.type);if(e)return"\n\nCheck the render method of `"+e+"`."}return""}se=!1;var pe={};function me(e,t){if(e._store&&!e._store.validated&&null==e.key){e._store.validated=!0;var r=function(e){var t=de();if(!t){var r="string"==typeof e?e:e.displayName||e.name;r&&(t="\n\nCheck the top-level render call using <"+r+">.")}return t}(t);if(!pe[r]){pe[r]=!0;var n="";e&&e._owner&&e._owner!==ce.current&&(n=" It was passed a child from "+j(e._owner.type)+"."),le(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.',r,n),le(null)}}}function ve(e,t){if("object"==typeof e)if(X(e))for(var r=0;r<e.length;r++){var n=e[r];fe(n)&&me(n,t)}else if(fe(e))e._store&&(e._store.validated=!0);else if(e){var o=function(e){if(null===e||"object"!=typeof e)return null;var t=v&&e[v]||e[h];return"function"==typeof t?t:null}(e);if("function"==typeof o&&o!==e.entries)for(var a,i=o.call(e);!(a=i.next()).done;)fe(a.value)&&me(a.value,t)}}function he(e){var t,r=e.type;if(null!=r&&"string"!=typeof r){if("function"==typeof r)t=r.propTypes;else{if("object"!=typeof r||r.$$typeof!==u&&r.$$typeof!==d)return;t=r.propTypes}if(t){var n=j(r);!function(e,t,r,n,o){var a=Function.call.bind(H);for(var i in e)if(a(e,i)){var s=void 0;try{if("function"!=typeof e[i]){var c=Error((n||"React class")+": "+r+" type `"+i+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[i]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw c.name="Invariant Violation",c}s=e[i](t,i,n,r,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(e){s=e}!s||s instanceof Error||(G(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).",n||"React class",r,i,typeof s),G(null)),s instanceof Error&&!(s.message in z)&&(z[s.message]=!0,G(o),g("Failed %s type: %s",r,s.message),G(null))}}(t,e.props,"prop",n,e)}else void 0===r.PropTypes||se||(se=!0,g("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",j(r)||"Unknown"));"function"!=typeof r.getDefaultProps||r.getDefaultProps.isReactClassApproved||g("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}var ye={};function ge(e,t,n,v,h,y){var E=function(e){return"string"==typeof e||"function"==typeof e||!!(e===o||e===i||x||e===a||e===l||e===f||O||e===m||w||S||_)||"object"==typeof e&&null!==e&&(e.$$typeof===p||e.$$typeof===d||e.$$typeof===s||e.$$typeof===c||e.$$typeof===u||e.$$typeof===b||void 0!==e.getModuleId)}(e);if(!E){var k,R="";(void 0===e||"object"==typeof e&&null!==e&&0===Object.keys(e).length)&&(R+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports."),R+=de(),null===e?k="null":X(e)?k="array":void 0!==e&&e.$$typeof===r?(k="<"+(j(e.type)||"Unknown")+" />",R=" Did you accidentally export a JSX literal instead of a component?"):k=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",k,R)}var T=ie(e,t,n,h,y);if(null==T)return T;if(E){var L=t.children;if(void 0!==L)if(v)if(X(L)){for(var P=0;P<L.length;P++)ve(L[P],e);Object.freeze&&Object.freeze(L)}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 ve(L,e)}if(H.call(t,"key")){var D=j(e),I=Object.keys(t).filter((function(e){return"key"!==e})),F=I.length>0?"{key: someKey, "+I.join(": ..., ")+": ...}":"{key: someKey}";ye[D+F]||(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} />',F,D,I.length>0?"{"+I.join(": ..., ")+": ...}":"{}",D),ye[D+F]=!0)}return e===o?function(e){for(var t=Object.keys(e.props),r=0;r<t.length;r++){var n=t[r];if("children"!==n&&"key"!==n){le(e),g("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",n),le(null);break}}null!==e.ref&&(le(e),g("Invalid attribute `ref` supplied to `React.Fragment`."),le(null))}(T):he(T),T}var be=function(e,t,r){return ge(e,t,r,!1)},we=function(e,t,r){return ge(e,t,r,!0)};Y.Fragment=o,Y.jsx=be,Y.jsxs=we}()),Y);var H=M.exports,z=function(e){return e.paths?H.jsx(w,{items:e.paths.map((function(e){var t=e.to,r=e.label;return{title:t?H.jsx(l,{href:t,children:r}):r}}))}):null},K=function(e){var n,o=e.defaultInsert,a=void 0!==o&&o,i=e.loading,s=void 0!==i&&i,c=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r}(e,["defaultInsert","loading"]),u=f(),d=u.pathname,m=t(""),v=m[0],h=m[1],w=new URLSearchParams(u.query),S=function(){var e=new URLSearchParams(w.toString());(e.get("q")||"")!==v&&(v?e.set("q",v):e.delete("q"),e.delete("page"),u.push({query:Object.fromEntries(e)}))},_=H.jsxs("div",{className:"flex w-full md:w-auto flex-wrap md:flex-nowrap gap-2 justify-end",children:[!0!==c.ocultarBuscador?H.jsx(y.Search,{value:v,placeholder:"Ingresar búsqueda",onChange:function(e){return h(e.target.value||"")},onSearch:S,onPressEnter:S}):null,null!==a?a||H.jsx(l,{href:(n=d,n.endsWith("/")&&(n=n.slice(0,-1)),n+"/insert"),children:H.jsx(g,{type:"primary",children:"Insertar"})}):null,c.onRefrescar?H.jsx("div",{children:H.jsx(g,{loading:s,title:"Refrescar datos",icon:H.jsx(p,{}),onClick:c.onRefrescar})}):null,c.children]});return r((function(){u.isReady&&h(w.get("q")||"")}),[u.isReady]),H.jsxs("div",{className:"flex md:flex-row flex-col md:items-end items-start justify-between gap-6 mb-6",children:[H.jsxs("div",{children:[H.jsx(z,{paths:c.paths}),H.jsx(b.Title,{className:"!mb-0 mt-4",children:c.title}),c.subtitle&&H.jsx(b.Title,{level:3,type:"secondary",className:"!font-normal !m-0",children:c.subtitle})]}),null!==c.column?c.column||_:null]})},G={hostUtils:"https://utils.upconta.com",hostFastify:"",hostRestify:"",userTokenName:"",adminTokenName:"",cookieDominio:"",cookiePath:void 0},J=function(e){G=A(A({},G),e)},X=function(e){return $(void 0,void 0,void 0,(function(){var t,r,n,o,a,i;return V(this,(function(s){switch(s.label){case 0:if(!((t=(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]),n=(r=JSON).parse,[4,t.text()];case 2:return[2,n.apply(r,[s.sent()]).message];case 3:return s.sent(),o={},[4,t.text()];case 4:return[2,(o.message=s.sent(),o.tipo="error",o)];case 5:return[2,{message:t,tipo:"error"}]}}))}))},Q=function(){var e=S.useApp(),t=e.modal,r=e.message,n=e.notification;return{showError:function(e,r){return $(void 0,void 0,void 0,(function(){var n;return V(this,(function(o){switch(o.label){case 0:return[4,X(e)];case 1:return n=o.sent(),t[n.tipo]({title:(null==r?void 0:r.title)||"Proceso fallido",width:450,content:H.jsxs(H.Fragment,{children:[n.message,null==r?void 0:r.cuerpoAdicional]}),okType:"danger"}),[2]}}))}))},modal:t,message:r,notification:n}},Z=function(e){return"administrador"===e?G.adminTokenName:G.userTokenName},ee=function(e,t){var r="";r=!e||"fastify"===e||e.includes("/v4")?G.hostFastify:"utils"===e?G.hostUtils:G.hostRestify;var n=R.create({baseURL:r});return"utils"!==e&&(n.defaults.headers.common.Authorization=T(Z(null==t?void 0:t.tipo),{domain:G.cookieDominio,path:G.cookiePath})),n},te=function(e,t){L(Z(t.usuario),e,{domain:G.cookieDominio,maxAge:604800,path:G.cookiePath})},re=function(e){P(Z(e),{domain:G.cookieDominio,path:G.cookiePath})},ne=function(e,t){var r=new URL(e,e.includes("v4")?G.hostFastify:G.hostRestify),n="";return t&&(n=new URLSearchParams(t).toString()),r.href+(n?"?"+n:"")},oe=function(e){var t,r=0;if(0===e.length)return r;for(t=0;t<e.length;t++)r=(r<<5)-r+e.charCodeAt(t),r|=0;return r},ae=function(e,t){void 0===t&&(t="/login");var r=t.includes("://"),n=new URL(r?t:window.location.origin+t);("/"!==e.asPath||r)&&n.searchParams.append("redirect",r?window.location.href:e.asPath),r?window.location.href=n.href:e.push(n.pathname+n.search)},ie={empresa:function(e,t){return $(void 0,void 0,void 0,(function(){return V(this,(function(e){switch(e.label){case 0:return t?[4,ee("restify").get("/v3/auth/business/"+t)]:[2];case 1:if(e.sent().data)throw new Error("La empresa ya se encuentra registrada");return[2]}}))}))}},se={required:function(e){return void 0===e&&(e="El campo es requerido"),{required:!0,message:e}},min:function(e,t){return void 0===t&&(t="Debe tener mínimo ".concat(e.toString()," caracteres")),{min:e,message:t}},max:function(e,t){return void 0===t&&(t="Debe tener máximo ".concat(e.toString()," caracteres")),{max:e,message:t}},email:function(e){return void 0===e&&(e="El correo electrónico no es válido"),{type:"email",message:e}},pattern:function(e,t){return void 0===t&&(t="No cumple el formato requerido"),{pattern:e,message:t}},unico:function(e){return{validator:I(ie[e],300)}},correos:function(){return{validator:function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return $(void 0,U([e],t,!0),void 0,(function(e,t){return void 0===t&&(t=[]),V(this,(function(e){if(t.some((function(e){return!e.includes("@")})))throw new Error("Alguno de los correos no es válido");return[2]}))}))}}},diasDiferencia:function(e,t){return void 0===t&&(t="La fecha ingresada no es válido"),{validator:function(r,n){return $(void 0,void 0,void 0,(function(){var r;return V(this,(function(o){if(r=D(n).startOf("day").diff(D().startOf("day"),"day"),e<0?r<e:r>e)throw new Error(t);return[2]}))}))}}}},ce="es-EC",ue={currency:function(e,t){return void 0===t&&(t=2),e||(e=0),new Intl.NumberFormat(ce,{style:"currency",currency:"USD",minimumFractionDigits:t}).format("number"==typeof e?e:parseFloat(e))},date:function(e,t){return void 0===t&&(t="DD/MM/YYYY"),D(e).format(t)},completeDate:function(e){return D(e).format("DD/MM/YYYY HH:mm:ss")},month:function(e){return D(e).format("MM/YYYY")},percent:function(e,t){return void 0===t&&(t=2),e||(e=0),new Intl.NumberFormat(ce,{style:"percent",minimumFractionDigits:t}).format("number"==typeof e?e:parseFloat(e))}},le=n(null);function fe(){return o(le)}var de,pe=function(e){var n=f(),o=t(!1),a=o[0],i=o[1],s=t(),c=s[0],u=s[1];return r((function(){$(void 0,void 0,void 0,(function(){var e,t,r,n;return V(this,(function(o){switch(o.label){case 0:e=ee("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 t=o.sent(),r=t[0].data,n=t[1].data,r.configuraciones=n,[2,r];case 3:return o.sent(),[2,null];case 4:return[2]}}))})).then((function(t){t?(i(!0),u(t)):ae(n,e.pathLogin)}))}),[]),a?H.jsx(le.Provider,{value:{business:c,nombreEmpresa:c.business,nombreUsuario:c.user,testEnviroment:c.configs.useTestEnviroment,usuarioEsAdmin:"admin"===c.userType},children:e.children}):H.jsx("div",{className:"w-full h-screen flex items-center justify-center",children:"Cargando..."})},me={exports:{}},ve={};var he,ye={};
|
|
11
11
|
/**
|
|
12
12
|
* @license React
|
|
13
13
|
* use-sync-external-store-shim.development.js
|
|
@@ -16,5 +16,5 @@ import e,{useState as t,useEffect as r,createContext as n,useContext as o,useLay
|
|
|
16
16
|
*
|
|
17
17
|
* This source code is licensed under the MIT license found in the
|
|
18
18
|
* LICENSE file in the root directory of this source tree.
|
|
19
|
-
*/"production"===process.env.NODE_ENV?me.exports=function(){if(fe)return ve;fe=1;var t=e,r="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},n=t.useState,o=t.useEffect,i=t.useLayoutEffect,a=t.useDebugValue;function s(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!r(e,n)}catch(e){return!0}}var c="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?function(e,t){return t()}:function(e,t){var r=t(),c=n({inst:{value:r,getSnapshot:t}}),u=c[0].inst,l=c[1];return i((function(){u.value=r,u.getSnapshot=t,s(u)&&l({inst:u})}),[e,r,t]),o((function(){return s(u)&&l({inst:u}),e((function(){s(u)&&l({inst:u})}))}),[e]),a(r),r};return ve.useSyncExternalStore=void 0!==t.useSyncExternalStore?t.useSyncExternalStore:c,ve}():me.exports=(he||(he=1,"production"!==process.env.NODE_ENV&&function(){"undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error);var t=e,r=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function n(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),o=1;o<t;o++)n[o-1]=arguments[o];!function(e,t,n){var o=r.ReactDebugCurrentFrame.getStackAddendum();""!==o&&(t+="%s",n=n.concat([o]));var i=n.map((function(e){return String(e)}));i.unshift("Warning: "+t),Function.prototype.apply.call(console[e],console,i)}("error",e,n)}var o="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},i=t.useState,a=t.useEffect,s=t.useLayoutEffect,c=t.useDebugValue,u=!1,l=!1;function d(e){var t=e.getSnapshot,r=e.value;try{var n=t();return!o(r,n)}catch(e){return!0}}var f="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?function(e,t,r){return t()}:function(e,r,f){u||void 0!==t.startTransition&&(u=!0,n("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var p=r();if(!l){var m=r();o(p,m)||(n("The result of getSnapshot should be cached to avoid an infinite loop"),l=!0)}var v=i({inst:{value:p,getSnapshot:r}}),h=v[0].inst,y=v[1];return s((function(){h.value=p,h.getSnapshot=r,d(h)&&y({inst:h})}),[e,p,r]),a((function(){return d(h)&&y({inst:h}),e((function(){d(h)&&y({inst:h})}))}),[e]),c(p),p},p=void 0!==t.useSyncExternalStore?t.useSyncExternalStore:f;ye.useSyncExternalStore=p,"undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}()),ye);var ge=me.exports;const be=()=>{},we=be(),xe=Object,Se=e=>e===we,_e=e=>"function"==typeof e,Oe=(e,t)=>({...e,...t}),je=new WeakMap;let Ee=0;const ke=e=>{const t=typeof e,r=e&&e.constructor,n=r==Date;let o,i;if(xe(e)!==e||n||r==RegExp)o=n?e.toJSON():"symbol"==t?e.toString():"string"==t?JSON.stringify(e):""+e;else{if(o=je.get(e),o)return o;if(o=++Ee+"~",je.set(e,o),r==Array){for(o="@",i=0;i<e.length;i++)o+=ke(e[i])+",";je.set(e,o)}if(r==xe){o="#";const t=xe.keys(e).sort();for(;!Se(i=t.pop());)Se(e[i])||(o+=i+":"+ke(e[i])+",");je.set(e,o)}}return o},Re=new WeakMap,Te={},Le={},Pe="undefined",De=typeof window!=Pe,Ie=typeof document!=Pe,Ce=(e,t)=>{const r=Re.get(e);return[()=>!Se(t)&&e.get(t)||Te,n=>{if(!Se(t)){const o=e.get(t);t in Le||(Le[t]=o),r[5](t,Oe(o,n),o||Te)}},r[6],()=>!Se(t)&&t in Le?Le[t]:!Se(t)&&e.get(t)||Te]};let Ne=!0;const[Fe,Ae]=De&&window.addEventListener?[window.addEventListener.bind(window),window.removeEventListener.bind(window)]:[be,be],$e={isOnline:()=>Ne,isVisible:()=>{const e=Ie&&document.visibilityState;return Se(e)||"hidden"!==e}},Ve={initFocus:e=>(Ie&&document.addEventListener("visibilitychange",e),Fe("focus",e),()=>{Ie&&document.removeEventListener("visibilitychange",e),Ae("focus",e)}),initReconnect:e=>{const t=()=>{Ne=!0,e()},r=()=>{Ne=!1};return Fe("online",t),Fe("offline",r),()=>{Ae("online",t),Ae("offline",r)}}},Ue=!e.useId,qe=!De||"Deno"in window,Me=e=>De&&typeof window.requestAnimationFrame!=Pe?window.requestAnimationFrame(e):setTimeout(e,1),We=qe?r:i,Be="undefined"!=typeof navigator&&navigator.connection,Ye=!qe&&Be&&(["slow-2g","2g"].includes(Be.effectiveType)||Be.saveData),ze=e=>{if(_e(e))try{e=e()}catch(t){e=""}const t=e;return[e="string"==typeof e?e:(Array.isArray(e)?e.length:e)?ke(e):"",t]};let He=0;const Ke=()=>++He;var Ge=3,Je=0,Xe=2,Qe=1;async function Ze(...e){const[t,r,n,o]=e,i=Oe({populateCache:!0,throwOnError:!0},"boolean"==typeof o?{revalidate:o}:o||{});let a=i.populateCache;const s=i.rollbackOnError;let c=i.optimisticData;const u=i.throwOnError;if(_e(r)){const e=r,n=[],o=t.keys();for(const r of o)!/^\$(inf|sub)\$/.test(r)&&e(t.get(r)._k)&&n.push(r);return Promise.all(n.map(l))}return l(r);async function l(r){const[o]=ze(r);if(!o)return;const[l,d]=Ce(t,o),[f,p,m,v]=Re.get(t),h=()=>{const e=f[o];return(_e(i.revalidate)?i.revalidate(l().data,r):!1!==i.revalidate)&&(delete m[o],delete v[o],e&&e[0])?e[0](2).then((()=>l().data)):l().data};if(e.length<3)return h();let y,g=n;const b=Ke();p[o]=[b,0];const w=!Se(c),x=l(),S=x.data,_=x._c,O=Se(_)?S:_;if(w&&(c=_e(c)?c(O,S):c,d({data:c,_c:O})),_e(g))try{g=g(O)}catch(e){y=e}if(g&&_e(g.then)){if(g=await g.catch((e=>{y=e})),b!==p[o][0]){if(y)throw y;return g}y&&w&&(e=>"function"==typeof s?s(e):!1!==s)(y)&&(a=!0,d({data:O,_c:we}))}if(a&&!y)if(_e(a)){const e=a(g,O);d({data:e,error:we,_c:we})}else d({data:g,error:we,_c:we});if(p[o][1]=Ke(),Promise.resolve(h()).then((()=>{d({_c:we})})),!y)return g;if(u)throw y}}const et=(e,t)=>{for(const r in e)e[r][0]&&e[r][0](t)},[tt,rt]=((e,t)=>{if(!Re.has(e)){const r=Oe(Ve,t),n={},o=Ze.bind(we,e);let i=be;const a={},s=(e,t)=>{const r=a[e]||[];return a[e]=r,r.push(t),()=>r.splice(r.indexOf(t),1)},c=(t,r,n)=>{e.set(t,r);const o=a[t];if(o)for(const e of o)e(r,n)},u=()=>{if(!Re.has(e)&&(Re.set(e,[n,{},{},{},o,c,s]),!qe)){const t=r.initFocus(setTimeout.bind(we,et.bind(we,n,0))),o=r.initReconnect(setTimeout.bind(we,et.bind(we,n,1)));i=()=>{t&&t(),o&&o(),Re.delete(e)}}};return u(),[e,o,u,i]}return[e,Re.get(e)[4]]})(new Map),nt=Oe({onLoadingSlow:be,onSuccess:be,onError:be,onErrorRetry:(e,t,r,n,o)=>{const i=r.errorRetryCount,a=o.retryCount,s=~~((Math.random()+.5)*(1<<(a<8?a:8)))*r.errorRetryInterval;!Se(i)&&a>i||setTimeout(n,s,o)},onDiscarded:be,revalidateOnFocus:!0,revalidateOnReconnect:!0,revalidateIfStale:!0,shouldRetryOnError:!0,errorRetryInterval:Ye?1e4:5e3,focusThrottleInterval:5e3,dedupingInterval:2e3,loadingTimeout:Ye?5e3:3e3,compare:(e,t)=>ke(e)==ke(t),isPaused:()=>!1,cache:tt,mutate:rt,fallback:{}},$e),ot=n({}),it=De&&window.__SWR_DEVTOOLS_USE__,at=it?window.__SWR_DEVTOOLS_USE__:[],st=e=>_e(e[1])?[e[0],e[1],e[2]||{}]:[e[0],null,(null===e[1]?e[2]:e[1])||{}],ct=at.concat((e=>(t,r,n)=>e(t,r&&((...e)=>{const[n]=ze(t),[,,,o]=Re.get(tt);if(n.startsWith("$inf$"))return r(...e);const i=o[n];return Se(i)?r(...e):(delete o[n],i)}),n)));it&&(window.__SWR_DEVTOOLS_REACT__=e);const ut=e.use||(e=>{if("pending"===e.status)throw e;if("fulfilled"===e.status)return e.value;throw"rejected"===e.status?e.reason:(e.status="pending",e.then((t=>{e.status="fulfilled",e.value=t}),(t=>{e.status="rejected",e.reason=t})),e)}),lt={dedupe:!0},dt=(ft=(e,t,r)=>{const{cache:n,compare:o,suspense:i,fallbackData:l,revalidateOnMount:d,revalidateIfStale:f,refreshInterval:p,refreshWhenHidden:m,refreshWhenOffline:v,keepPreviousData:h}=r,[y,g,b,w]=Re.get(n),[x,S]=ze(e),_=a(!1),O=a(!1),j=a(x),E=a(t),k=a(r),R=()=>k.current,T=()=>R().isVisible()&&R().isOnline(),[L,P,D,I]=Ce(n,x),C=a({}).current,N=Se(l)?r.fallback[x]:l,F=(e,t)=>{for(const r in C){const n=r;if("data"===n){if(!o(e[n],t[n])){if(!Se(e[n]))return!1;if(!o(Y,t[n]))return!1}}else if(t[n]!==e[n])return!1}return!0},A=s((()=>{const e=!!x&&!!t&&(Se(d)?!R().isPaused()&&!i&&(!!Se(f)||f):d),r=t=>{const r=Oe(t);return delete r._k,e?{isValidating:!0,isLoading:!0,...r}:r},n=L(),o=I(),a=r(n),s=n===o?a:r(o);let c=a;return[()=>{const e=r(L());return F(e,c)?(c.data=e.data,c.isLoading=e.isLoading,c.isValidating=e.isValidating,c.error=e.error,c):(c=e,e)},()=>s]}),[n,x]),$=ge.useSyncExternalStore(c((e=>D(x,((t,r)=>{F(r,t)||e()}))),[n,x]),A[0],A[1]),V=!_.current,U=y[x]&&y[x].length>0,q=$.data,M=Se(q)?N:q,W=$.error,B=a(M),Y=h?Se(q)?B.current:q:M,z=!(U&&!Se(W))&&(V&&!Se(d)?d:!R().isPaused()&&(i?!Se(M)&&f:Se(M)||f)),H=!!(x&&t&&V&&z),K=Se($.isValidating)?H:$.isValidating,G=Se($.isLoading)?H:$.isLoading,J=c((async e=>{const t=E.current;if(!x||!t||O.current||R().isPaused())return!1;let n,i,a=!0;const s=e||{},c=!b[x]||!s.dedupe,u=()=>Ue?!O.current&&x===j.current&&_.current:x===j.current,l={isValidating:!1,isLoading:!1},d=()=>{P(l)},f=()=>{const e=b[x];e&&e[1]===i&&delete b[x]},p={isValidating:!0};Se(L().data)&&(p.isLoading=!0);try{if(c&&(P(p),r.loadingTimeout&&Se(L().data)&&setTimeout((()=>{a&&u()&&R().onLoadingSlow(x,r)}),r.loadingTimeout),b[x]=[t(S),Ke()]),[n,i]=b[x],n=await n,c&&setTimeout(f,r.dedupingInterval),!b[x]||b[x][1]!==i)return c&&u()&&R().onDiscarded(x),!1;l.error=we;const e=g[x];if(!Se(e)&&(i<=e[0]||i<=e[1]||0===e[1]))return d(),c&&u()&&R().onDiscarded(x),!1;const s=L().data;l.data=o(s,n)?s:n,c&&u()&&R().onSuccess(n,x,r)}catch(e){f();const t=R(),{shouldRetryOnError:r}=t;t.isPaused()||(l.error=e,c&&u()&&(t.onError(e,x,t),(!0===r||_e(r)&&r(e))&&(R().revalidateOnFocus&&R().revalidateOnReconnect&&!T()||t.onErrorRetry(e,x,t,(e=>{const t=y[x];t&&t[0]&&t[0](Ge,e)}),{retryCount:(s.retryCount||0)+1,dedupe:!0}))))}return a=!1,d(),!0}),[x,n]),X=c(((...e)=>Ze(n,j.current,...e)),[]);if(We((()=>{E.current=t,k.current=r,Se(q)||(B.current=q)})),We((()=>{if(!x)return;const e=J.bind(we,lt);let t=0;const r=((e,t,r)=>{const n=t[e]||(t[e]=[]);return n.push(r),()=>{const e=n.indexOf(r);e>=0&&(n[e]=n[n.length-1],n.pop())}})(x,y,((r,n={})=>{if(r==Je){const r=Date.now();R().revalidateOnFocus&&r>t&&T()&&(t=r+R().focusThrottleInterval,e())}else if(r==Qe)R().revalidateOnReconnect&&T()&&e();else{if(r==Xe)return J();if(r==Ge)return J(n)}}));return O.current=!1,j.current=x,_.current=!0,P({_k:S}),z&&(Se(M)||qe?e():Me(e)),()=>{O.current=!0,r()}}),[x]),We((()=>{let e;function t(){const t=_e(p)?p(L().data):p;t&&-1!==e&&(e=setTimeout(r,t))}function r(){L().error||!m&&!R().isVisible()||!v&&!R().isOnline()?t():J(lt).then(t)}return t(),()=>{e&&(clearTimeout(e),e=-1)}}),[p,m,v,x]),u(Y),i&&Se(M)&&x){if(!Ue&&qe)throw new Error("Fallback data is required when using suspense in SSR.");E.current=t,k.current=r,O.current=!1;const e=w[x];if(!Se(e)){const t=X(e);ut(t)}if(!Se(W))throw W;{const e=J(lt);Se(Y)||(e.status="fulfilled",e.value=!0),ut(e)}}return{mutate:X,get data(){return C.data=!0,Y},get error(){return C.error=!0,W},get isValidating(){return C.isValidating=!0,K},get isLoading(){return C.isLoading=!0,G}}},function(...e){const t=Oe(nt,o(ot)),[r,n,i]=st(e),a=((e,t)=>{const r=Oe(e,t);if(t){const{use:n,fallback:o}=e,{use:i,fallback:a}=t;n&&i&&(r.use=n.concat(i)),o&&a&&(r.fallback=Oe(o,a))}return r})(t,i);let s=ft;const{use:c}=a,u=(c||[]).concat(ct);for(let e=u.length;e--;)s=u[e](s);return s(r,n||a.fetcher||null,a)});var ft;const pt=((e,t)=>(...r)=>{const[n,o,i]=st(r),a=(i.use||[]).concat(t);return e(n,o,{...i,use:a})})(dt,(e=>(t,r,n)=>(n.revalidateOnFocus=!1,n.revalidateIfStale=!1,n.revalidateOnReconnect=!1,e(t,r,n))));var mt=function(e){var t=ee(e.endpoint),r=d(),n=Q().showError,o=N().mutate,i=pt(e.sinOptions?null:(e.optionsPath||e.endpoint)+"/get-options",(function(e){return $(void 0,void 0,void 0,(function(){return V(this,(function(r){switch(r.label){case 0:return[4,t.get(e)];case 1:return[2,r.sent().data]}}))}))})).data,a=void 0===i?{}:i,s=new URLSearchParams(A(A({},e.params),r.query)).toString(),c=e.endpoint+(s?"?"+s:""),u=C(r.isReady?c:null,(function(e){return $(void 0,void 0,void 0,(function(){return V(this,(function(r){switch(r.label){case 0:return[4,t.get(e)];case 1:return[2,r.sent().data]}}))}))})),l=u.data,f=u.error,p=u.isLoading,m=(null==l?void 0:l.data)||[],v=(null==l?void 0:l.total)||0,h=new URLSearchParams(r.query),y=h.get("page"),g=y?parseInt(y):1,b=h.get("limit"),w=b?parseInt(b):20,x={loading:p,dataSource:m,rowKey:"_id",bordered:!0,pagination:{current:g,defaultPageSize:w,total:v},onChange:function(e,t,n){return $(void 0,void 0,void 0,(function(){var t,o,i,a;return V(this,(function(s){return t=h.toString(),o=new URLSearchParams(t),e.current!==g&&("1"===(i=e.current.toString())?o.delete("page"):o.set("page",i)),e.pageSize!==w&&("20"===(a=e.pageSize.toString())?o.delete("limit"):o.set("limit",a)),Array.isArray(n)||("ascend"===n.order?o.set("sort",n.field):"descend"===n.order?o.set("sort","-"+n.field):o.delete("sort")),t!==o.toString()&&r.push({query:Object.fromEntries(o)}),[2]}))}))}},S=function(){o(c)};return{data:m,isLoading:p,error:f,options:a,endpoint:e.endpoint,endpointWithHost:ne(e.endpoint),mainroute:r.route,tableProps:x,init:S,getOpt:function(e,t){var r,n=null===(r=a[e])||void 0===r?void 0:r.find((function(e){return e.id===t}));return n?n.description:""},remove:function(r){return $(void 0,void 0,void 0,(function(){var o;return V(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,t.delete("string"==typeof r?e.endpoint+"/"+r:r.endpoint)];case 1:return i.sent(),S(),[3,3];case 2:return o=i.sent(),n(o),[3,3];case 3:return[2]}}))}))},cancel:function(r){return $(void 0,void 0,void 0,(function(){var o;return V(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,t.delete("string"==typeof r?e.endpoint+"/"+r+"/cancel":r.endpoint)];case 1:return i.sent(),S(),[3,3];case 2:return o=i.sent(),n(o),[3,3];case 3:return[2]}}))}))}}},vt=function(e){var n=ee(e.endpoint),o=S.useForm()[0],i=t(!1),s=i[0],c=i[1],u=t(!1),p=u[0],v=u[1],h=d(),y=Q(),b=y.showError,w=y.message,x=function(e){var n=a(!1),o=Q().modal,i=a(0),s=t(0),c=s[0],u=s[1],l=function(){if(!window.confirm("¿Estás seguro que quieres salir?"))throw"Route Canceled";p(),localStorage.removeItem(e)},d=function(e){e.preventDefault()},p=function(){n.current=!1,window.removeEventListener("beforeunload",d),f.events.off("routeChangeStart",l),localStorage.removeItem(e),u(0)};return r((function(){if(n.current)return i.current!==c&&(window.addEventListener("beforeunload",d),f.events.on("routeChangeStart",l)),function(){window.removeEventListener("beforeunload",d),f.events.off("routeChangeStart",l)}}),[i.current,c]),{cambiarHashInicial:function(e){var t=oe(JSON.stringify(e));u(t),i.current=t},cambiarDatosFormulario:function(t){if(n.current&&0!==i.current){var r=JSON.stringify(t),o=oe(r);u(o),o===i.current?localStorage.removeItem(e):localStorage.setItem(e,r)}},limpiar:p,reanudar:function(){n.current=!0},obtenerDataEmergencia:function(){return $(void 0,void 0,void 0,(function(){var t,r;return V(this,(function(i){switch(i.label){case 0:return t=localStorage.getItem(e),[4,new Promise((function(e){if(!t)return e(void 0);o.confirm({title:"Existen datos guardados",icon:z.jsx(m,{}),content:"Hubo un cierre inesperado pero los datos fueron guardados temporalmente ¿Deseas recuperarlos?",onOk:function(){return e(JSON.parse(t))},onCancel:function(){return e(void 0)}})}))];case 1:return r=i.sent(),n.current=!0,[2,r]}}))}))}}}(h.asPath),j=a("emitir"),E=a(h.query.id),k=pt(e.sinOptions?null:e.endpoint+"/get-options",(function(e){return $(void 0,void 0,void 0,(function(){return V(this,(function(t){switch(t.label){case 0:return[4,n.get(e)];case 1:return[2,t.sent().data]}}))}))}),{revalidateOnFocus:!1}).data,R=void 0===k?{}:k;r((function(){E.current=e.registroId,E.current||(E.current=e.soloParaInsertar?void 0:h.query.id)}),[null==e?void 0:e.registroId,e.soloParaInsertar]);var T=h.asPath.replace(/\/(insert|[\w]*\/edit$)/g,"")||"/",L=function(t){for(var r=[],o=1;o<arguments.length;o++)r[o-1]=arguments[o];return $(void 0,U([t],r,!0),void 0,(function(t,r){var o,i,a,u,l,d,f,p;return void 0===r&&(r={}),V(this,(function(m){switch(m.label){case 0:if(!0===s)return[2];c(!0),x.limpiar(),o=r.endpoint||e.endpoint,i=r.params||void 0,m.label=1;case 1:return m.trys.push([1,6,,7]),a=void 0,E.current?[4,n.put(o+"/"+E.current,t,{params:i})]:[3,3];case 2:return a=m.sent().data,[3,5];case 3:return[4,n.post(o,t,{params:i})];case 4:a=m.sent().data,m.label=5;case 5:return!0!==r.noRedirect?(w.success("Guardado correctamente"),h.push(T)):c(!1),[2,a];case 6:if(u=m.sent(),c(!1),r.noShowError)throw u;return b(u),l=null===(p=null===(f=null==u?void 0:u.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(T):!r.noRedirect&&l&&l!==E.current?(E.current=l,h.push(T+"/"+l+"/edit")):x.reanudar(),[3,7];case 7:return[2]}}))}))},P=z.jsxs(_,{children:[z.jsx(g,{type:"primary",loading:s,onClick:function(){return o.submit()},children:"Guardar"}),z.jsx(l,{href:T,children:z.jsx(g,{children:"Cancelar"})})]}),D=z.jsxs(z.Fragment,{children:[z.jsx(O,{paragraph:{rows:3,width:"100%"},className:"mb-4"}),z.jsx(O,{paragraph:{rows:4,width:"100%"},className:"mb-4"}),z.jsxs("div",{className:"grid grid-cols-2 gap-4 mb-4",children:[z.jsx(O,{paragraph:{rows:4,width:"100%"}}),z.jsx(O,{paragraph:{rows:4,width:"100%"}})]}),z.jsxs(_,{children:[z.jsx(O.Button,{}),z.jsx(O.Button,{})]})]}),I=function(){return w.warning("Revisa los errores del formulario")},C={form:o,autoComplete:"off",initialValues:e.data,onFinish:L,layout:"vertical",onFinishFailed:I};return r((function(){if(e.recuperacionEmergencia){var t=setInterval((function(){if(p){var e=o.getFieldsValue();x.cambiarDatosFormulario(e)}}),1e3);return function(){return clearInterval(t)}}}),[p]),r((function(){var t=setTimeout((function(){e.soloParaInsertar||$(void 0,void 0,void 0,(function(){var t,r,i;return V(this,(function(a){switch(a.label){case 0:return t=!1,[4,x.obtenerDataEmergencia()];case 1:return(r=a.sent())?(E.current=r._id,t=!0,[3,4]):[3,2];case 2:return E.current?[4,n.get("".concat(e.endpoint,"/").concat(E.current),{params:e.params})]:[3,4];case 3:r=a.sent().data,a.label=4;case 4:return r?[4,null===(i=e.formatearDataInicial)||void 0===i?void 0:i.call(e,r)]:[3,6];case 5:a.sent(),o.setFieldsValue(r),a.label=6;case 6:return[2,t?e.data:r||e.data]}}))})).then((function(t){var r;return Promise.all([x.cambiarHashInicial(t),null===(r=e.onMounted)||void 0===r?void 0:r.call(e)])})).then((function(){return v(!0)}))}),200);return function(){return clearTimeout(t)}}),[h.query.id]),{form:o,router:h,options:R,tipoEmision:j,objectId:E.current,mainroute:T,isLoading:s,isReady:p,data:e.data,endpoint:e.endpoint,onSubmit:L,onMainRouter:function(){return h.push(T)},setIsLoading:c,preventor:x,ModoCarga:D,BotonesPorDefecto:P,onMensajeValidacion:I,getOption:function(e,t){var r,n;return(null===(n=null===(r=R[e])||void 0===r?void 0:r.find((function(e){return e.id===t})))||void 0===n?void 0:n.description)||""},formProps:C}};var ht=function(e){var r=t(""),n=r[0];r[1];var o=function(e){var t=this,r=a(e.defaultOptions),n=(e.type,{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}});if(!n)return null;var o=ee(n.endpoint),i=C(n.withOptions&&!e.defaultOptions?n.endpoint+"/get-options":null,(function(e){return $(t,void 0,void 0,(function(){return V(this,(function(t){switch(t.label){case 0:return[4,o.get(e)];case 1:return[2,t.sent().data]}}))}))}),{revalidateOnFocus:!1}).data;return i&&(r.current=i),n}({type:e.type,defaultOptions:void 0});return o?z.jsx(S.Item,{name:e.name,label:e.hideLabel?void 0:e.label||o.label,extra:e.hideMessage?void 0:n,rules:e.required?[se.required()]:[{}],className:e.classNameFormItem}):null},yt="#F34D24",gt="#FFFFFF",bt=function(e){var n=t(!1),o=n[0],i=n[1];return r((function(){i(!0)}),[]),o?z.jsx(j,{locale:F,theme:{token:{colorPrimary:yt,colorLink:yt,colorTextDisabled:"#00000080"},components:{Layout:{bodyBg:gt,headerBg:gt}}},children:z.jsx(x,{children:z.jsx(E,{className:e.className+" min-h-screen",style:e.style,hasSider:!0,children:e.children})})}):null},wt=function(e){var r=S.useFormInstance(),n=t([]),o=n[0],i=n[1],a=s((function(){var t=e.rules||[];switch(e.type){case"ruc":return{label:"RUC",placeholder:"Ingresar el RUC",max:13,rules:U(U([],t,!0),[se.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:U(U([],t,!0),[se.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:t}}}),[e.type]),c=I((function(t){return $(void 0,void 0,void 0,(function(){var r,n,a;return V(this,(function(s){switch(s.label){case 0:if(r=ee("utils"),!e.campoNombre||t.length<6||!["ci","ruc"].includes(e.type))return 0!==o.length&&i([]),[2];s.label=1;case 1:return s.trys.push([1,3,,4]),[4,r.get("/clientes/buscar",{params:{identificador:t,tipo:"ci"===e.type?"cedula":"ruc"}})];case 2:return n=s.sent().data,i(n.map((function(e){return{value:e.identificador,nombre:e.nombre,label:z.jsxs(z.Fragment,{children:[z.jsx("b",{children:e.identificador}),z.jsx("br",{}),e.nombre]})}}))),[3,4];case 3:return a=s.sent(),console.error(a),[3,4];case 4:return[2]}}))}))}),500);return z.jsx(S.Item,A({name:e.name,rules:a.rules,normalize:function(e){return e.trim().toUpperCase()},className:e.className,dependencies:e.dependencies},e.hiddenLabel?{}:{label:e.label||a.label},{children:z.jsx(k,{options:o,onSelect:function(t,n){r.setFieldValue(e.campoNombre,n.nombre)},onSearch:c,placeholder:e.placeholder||a.placeholder,maxLength:a.max,disabled:e.disabled,onChange:function(t){var r;return null===(r=e.onChange)||void 0===r?void 0:r.call(e,t)}})}))},xt=function(e){var r=t(!0),n=r[0],o=r[1],i=t(!1),a=i[0],s=i[1];return z.jsxs(z.Fragment,{children:[e.sidebar?z.jsxs(E.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:n,collapsible:!0,width:"230px",onBreakpoint:function(e){o(e),s(e)},children:[z.jsx(l,{href:e.sidebar.title.href,children:z.jsx("div",{className:"flex justify-center items-center h-16 text-lg text-white font-bold",children:z.jsx("div",{children:e.sidebar.title.label})})}),e.sidebar.menu]}):null,z.jsxs(E,{className:a||n?"ml-0":"ml-[230px]",onClick:!n&&a?function(e){e.stopPropagation(),e.preventDefault(),o(!0)}:void 0,children:[e.navbar?z.jsx(E.Header,{className:"border-b top-0 !z-[2] sticky !px-4",children:z.jsxs("div",{className:"flex justify-between items-center h-full",children:[e.navbar.title?z.jsx("div",{children:z.jsx(g,{type:"text",icon:n?z.jsx(v,{}):z.jsx(h,{}),onClick:function(){return o(!n)},children:e.navbar.title})}):z.jsx("div",{}),e.navbar.options?z.jsx("div",{children:e.navbar.options}):z.jsx("div",{})]})}):null,z.jsx(E.Content,{className:"m-4 md:m-8 xl:m-16",children:e.children}),e.footer?z.jsx(E.Footer,{className:"!text-gray-500",children:e.footer}):null]})]})};export{ue as $filtros,se as $reglas,pe as ContextoEmpresa,K as Header,wt as IdentificadorPersona,xt as LayoutBase,ht as Seeker,bt as TemaPrincipal,J as configurarUtils,te as crearToken,re as destruirToken,ne as getApiEndpoint,ee as getAxios,oe as hashear,ie as redireccionarLogin,de as useContextoEmpresa,Q as useUtils,vt as useVistaInsertar,mt as useVistaPrincipal};
|
|
19
|
+
*/"production"===process.env.NODE_ENV?me.exports=function(){if(de)return ve;de=1;var t=e,r="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},n=t.useState,o=t.useEffect,a=t.useLayoutEffect,i=t.useDebugValue;function s(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!r(e,n)}catch(e){return!0}}var c="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?function(e,t){return t()}:function(e,t){var r=t(),c=n({inst:{value:r,getSnapshot:t}}),u=c[0].inst,l=c[1];return a((function(){u.value=r,u.getSnapshot=t,s(u)&&l({inst:u})}),[e,r,t]),o((function(){return s(u)&&l({inst:u}),e((function(){s(u)&&l({inst:u})}))}),[e]),i(r),r};return ve.useSyncExternalStore=void 0!==t.useSyncExternalStore?t.useSyncExternalStore:c,ve}():me.exports=(he||(he=1,"production"!==process.env.NODE_ENV&&function(){"undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error);var t=e,r=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function n(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),o=1;o<t;o++)n[o-1]=arguments[o];!function(e,t,n){var o=r.ReactDebugCurrentFrame.getStackAddendum();""!==o&&(t+="%s",n=n.concat([o]));var a=n.map((function(e){return String(e)}));a.unshift("Warning: "+t),Function.prototype.apply.call(console[e],console,a)}("error",e,n)}var o="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},a=t.useState,i=t.useEffect,s=t.useLayoutEffect,c=t.useDebugValue,u=!1,l=!1;function f(e){var t=e.getSnapshot,r=e.value;try{var n=t();return!o(r,n)}catch(e){return!0}}var d="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?function(e,t,r){return t()}:function(e,r,d){u||void 0!==t.startTransition&&(u=!0,n("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var p=r();if(!l){var m=r();o(p,m)||(n("The result of getSnapshot should be cached to avoid an infinite loop"),l=!0)}var v=a({inst:{value:p,getSnapshot:r}}),h=v[0].inst,y=v[1];return s((function(){h.value=p,h.getSnapshot=r,f(h)&&y({inst:h})}),[e,p,r]),i((function(){return f(h)&&y({inst:h}),e((function(){f(h)&&y({inst:h})}))}),[e]),c(p),p},p=void 0!==t.useSyncExternalStore?t.useSyncExternalStore:d;ye.useSyncExternalStore=p,"undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}()),ye);var ge=me.exports;const be=()=>{},we=be(),Se=Object,_e=e=>e===we,Oe=e=>"function"==typeof e,xe=(e,t)=>({...e,...t}),Ee=new WeakMap;let je=0;const ke=e=>{const t=typeof e,r=e&&e.constructor,n=r==Date;let o,a;if(Se(e)!==e||n||r==RegExp)o=n?e.toJSON():"symbol"==t?e.toString():"string"==t?JSON.stringify(e):""+e;else{if(o=Ee.get(e),o)return o;if(o=++je+"~",Ee.set(e,o),r==Array){for(o="@",a=0;a<e.length;a++)o+=ke(e[a])+",";Ee.set(e,o)}if(r==Se){o="#";const t=Se.keys(e).sort();for(;!_e(a=t.pop());)_e(e[a])||(o+=a+":"+ke(e[a])+",");Ee.set(e,o)}}return o},Re=new WeakMap,Te={},Le={},Pe="undefined",De=typeof window!=Pe,Ie=typeof document!=Pe,Fe=(e,t)=>{const r=Re.get(e);return[()=>!_e(t)&&e.get(t)||Te,n=>{if(!_e(t)){const o=e.get(t);t in Le||(Le[t]=o),r[5](t,xe(o,n),o||Te)}},r[6],()=>!_e(t)&&t in Le?Le[t]:!_e(t)&&e.get(t)||Te]};let Ne=!0;const[Ce,Ae]=De&&window.addEventListener?[window.addEventListener.bind(window),window.removeEventListener.bind(window)]:[be,be],$e={isOnline:()=>Ne,isVisible:()=>{const e=Ie&&document.visibilityState;return _e(e)||"hidden"!==e}},Ve={initFocus:e=>(Ie&&document.addEventListener("visibilitychange",e),Ce("focus",e),()=>{Ie&&document.removeEventListener("visibilitychange",e),Ae("focus",e)}),initReconnect:e=>{const t=()=>{Ne=!0,e()},r=()=>{Ne=!1};return Ce("online",t),Ce("offline",r),()=>{Ae("online",t),Ae("offline",r)}}},Ue=!e.useId,qe=!De||"Deno"in window,Me=e=>De&&typeof window.requestAnimationFrame!=Pe?window.requestAnimationFrame(e):setTimeout(e,1),We=qe?r:a,Be="undefined"!=typeof navigator&&navigator.connection,Ye=!qe&&Be&&(["slow-2g","2g"].includes(Be.effectiveType)||Be.saveData),He=e=>{if(Oe(e))try{e=e()}catch(t){e=""}const t=e;return[e="string"==typeof e?e:(Array.isArray(e)?e.length:e)?ke(e):"",t]};let ze=0;const Ke=()=>++ze;var Ge=3,Je=0,Xe=2,Qe=1;async function Ze(...e){const[t,r,n,o]=e,a=xe({populateCache:!0,throwOnError:!0},"boolean"==typeof o?{revalidate:o}:o||{});let i=a.populateCache;const s=a.rollbackOnError;let c=a.optimisticData;const u=a.throwOnError;if(Oe(r)){const e=r,n=[],o=t.keys();for(const r of o)!/^\$(inf|sub)\$/.test(r)&&e(t.get(r)._k)&&n.push(r);return Promise.all(n.map(l))}return l(r);async function l(r){const[o]=He(r);if(!o)return;const[l,f]=Fe(t,o),[d,p,m,v]=Re.get(t),h=()=>{const e=d[o];return(Oe(a.revalidate)?a.revalidate(l().data,r):!1!==a.revalidate)&&(delete m[o],delete v[o],e&&e[0])?e[0](2).then((()=>l().data)):l().data};if(e.length<3)return h();let y,g=n;const b=Ke();p[o]=[b,0];const w=!_e(c),S=l(),_=S.data,O=S._c,x=_e(O)?_:O;if(w&&(c=Oe(c)?c(x,_):c,f({data:c,_c:x})),Oe(g))try{g=g(x)}catch(e){y=e}if(g&&Oe(g.then)){if(g=await g.catch((e=>{y=e})),b!==p[o][0]){if(y)throw y;return g}y&&w&&(e=>"function"==typeof s?s(e):!1!==s)(y)&&(i=!0,f({data:x,_c:we}))}if(i&&!y)if(Oe(i)){const e=i(g,x);f({data:e,error:we,_c:we})}else f({data:g,error:we,_c:we});if(p[o][1]=Ke(),Promise.resolve(h()).then((()=>{f({_c:we})})),!y)return g;if(u)throw y}}const et=(e,t)=>{for(const r in e)e[r][0]&&e[r][0](t)},[tt,rt]=((e,t)=>{if(!Re.has(e)){const r=xe(Ve,t),n={},o=Ze.bind(we,e);let a=be;const i={},s=(e,t)=>{const r=i[e]||[];return i[e]=r,r.push(t),()=>r.splice(r.indexOf(t),1)},c=(t,r,n)=>{e.set(t,r);const o=i[t];if(o)for(const e of o)e(r,n)},u=()=>{if(!Re.has(e)&&(Re.set(e,[n,{},{},{},o,c,s]),!qe)){const t=r.initFocus(setTimeout.bind(we,et.bind(we,n,0))),o=r.initReconnect(setTimeout.bind(we,et.bind(we,n,1)));a=()=>{t&&t(),o&&o(),Re.delete(e)}}};return u(),[e,o,u,a]}return[e,Re.get(e)[4]]})(new Map),nt=xe({onLoadingSlow:be,onSuccess:be,onError:be,onErrorRetry:(e,t,r,n,o)=>{const a=r.errorRetryCount,i=o.retryCount,s=~~((Math.random()+.5)*(1<<(i<8?i:8)))*r.errorRetryInterval;!_e(a)&&i>a||setTimeout(n,s,o)},onDiscarded:be,revalidateOnFocus:!0,revalidateOnReconnect:!0,revalidateIfStale:!0,shouldRetryOnError:!0,errorRetryInterval:Ye?1e4:5e3,focusThrottleInterval:5e3,dedupingInterval:2e3,loadingTimeout:Ye?5e3:3e3,compare:(e,t)=>ke(e)==ke(t),isPaused:()=>!1,cache:tt,mutate:rt,fallback:{}},$e),ot=n({}),at=De&&window.__SWR_DEVTOOLS_USE__,it=at?window.__SWR_DEVTOOLS_USE__:[],st=e=>Oe(e[1])?[e[0],e[1],e[2]||{}]:[e[0],null,(null===e[1]?e[2]:e[1])||{}],ct=it.concat((e=>(t,r,n)=>e(t,r&&((...e)=>{const[n]=He(t),[,,,o]=Re.get(tt);if(n.startsWith("$inf$"))return r(...e);const a=o[n];return _e(a)?r(...e):(delete o[n],a)}),n)));at&&(window.__SWR_DEVTOOLS_REACT__=e);const ut=e.use||(e=>{if("pending"===e.status)throw e;if("fulfilled"===e.status)return e.value;throw"rejected"===e.status?e.reason:(e.status="pending",e.then((t=>{e.status="fulfilled",e.value=t}),(t=>{e.status="rejected",e.reason=t})),e)}),lt={dedupe:!0},ft=(dt=(e,t,r)=>{const{cache:n,compare:o,suspense:a,fallbackData:l,revalidateOnMount:f,revalidateIfStale:d,refreshInterval:p,refreshWhenHidden:m,refreshWhenOffline:v,keepPreviousData:h}=r,[y,g,b,w]=Re.get(n),[S,_]=He(e),O=i(!1),x=i(!1),E=i(S),j=i(t),k=i(r),R=()=>k.current,T=()=>R().isVisible()&&R().isOnline(),[L,P,D,I]=Fe(n,S),F=i({}).current,N=_e(l)?r.fallback[S]:l,C=(e,t)=>{for(const r in F){const n=r;if("data"===n){if(!o(e[n],t[n])){if(!_e(e[n]))return!1;if(!o(Y,t[n]))return!1}}else if(t[n]!==e[n])return!1}return!0},A=s((()=>{const e=!!S&&!!t&&(_e(f)?!R().isPaused()&&!a&&(!!_e(d)||d):f),r=t=>{const r=xe(t);return delete r._k,e?{isValidating:!0,isLoading:!0,...r}:r},n=L(),o=I(),i=r(n),s=n===o?i:r(o);let c=i;return[()=>{const e=r(L());return C(e,c)?(c.data=e.data,c.isLoading=e.isLoading,c.isValidating=e.isValidating,c.error=e.error,c):(c=e,e)},()=>s]}),[n,S]),$=ge.useSyncExternalStore(c((e=>D(S,((t,r)=>{C(r,t)||e()}))),[n,S]),A[0],A[1]),V=!O.current,U=y[S]&&y[S].length>0,q=$.data,M=_e(q)?N:q,W=$.error,B=i(M),Y=h?_e(q)?B.current:q:M,H=!(U&&!_e(W))&&(V&&!_e(f)?f:!R().isPaused()&&(a?!_e(M)&&d:_e(M)||d)),z=!!(S&&t&&V&&H),K=_e($.isValidating)?z:$.isValidating,G=_e($.isLoading)?z:$.isLoading,J=c((async e=>{const t=j.current;if(!S||!t||x.current||R().isPaused())return!1;let n,a,i=!0;const s=e||{},c=!b[S]||!s.dedupe,u=()=>Ue?!x.current&&S===E.current&&O.current:S===E.current,l={isValidating:!1,isLoading:!1},f=()=>{P(l)},d=()=>{const e=b[S];e&&e[1]===a&&delete b[S]},p={isValidating:!0};_e(L().data)&&(p.isLoading=!0);try{if(c&&(P(p),r.loadingTimeout&&_e(L().data)&&setTimeout((()=>{i&&u()&&R().onLoadingSlow(S,r)}),r.loadingTimeout),b[S]=[t(_),Ke()]),[n,a]=b[S],n=await n,c&&setTimeout(d,r.dedupingInterval),!b[S]||b[S][1]!==a)return c&&u()&&R().onDiscarded(S),!1;l.error=we;const e=g[S];if(!_e(e)&&(a<=e[0]||a<=e[1]||0===e[1]))return f(),c&&u()&&R().onDiscarded(S),!1;const s=L().data;l.data=o(s,n)?s:n,c&&u()&&R().onSuccess(n,S,r)}catch(e){d();const t=R(),{shouldRetryOnError:r}=t;t.isPaused()||(l.error=e,c&&u()&&(t.onError(e,S,t),(!0===r||Oe(r)&&r(e))&&(R().revalidateOnFocus&&R().revalidateOnReconnect&&!T()||t.onErrorRetry(e,S,t,(e=>{const t=y[S];t&&t[0]&&t[0](Ge,e)}),{retryCount:(s.retryCount||0)+1,dedupe:!0}))))}return i=!1,f(),!0}),[S,n]),X=c(((...e)=>Ze(n,E.current,...e)),[]);if(We((()=>{j.current=t,k.current=r,_e(q)||(B.current=q)})),We((()=>{if(!S)return;const e=J.bind(we,lt);let t=0;const r=((e,t,r)=>{const n=t[e]||(t[e]=[]);return n.push(r),()=>{const e=n.indexOf(r);e>=0&&(n[e]=n[n.length-1],n.pop())}})(S,y,((r,n={})=>{if(r==Je){const r=Date.now();R().revalidateOnFocus&&r>t&&T()&&(t=r+R().focusThrottleInterval,e())}else if(r==Qe)R().revalidateOnReconnect&&T()&&e();else{if(r==Xe)return J();if(r==Ge)return J(n)}}));return x.current=!1,E.current=S,O.current=!0,P({_k:_}),H&&(_e(M)||qe?e():Me(e)),()=>{x.current=!0,r()}}),[S]),We((()=>{let e;function t(){const t=Oe(p)?p(L().data):p;t&&-1!==e&&(e=setTimeout(r,t))}function r(){L().error||!m&&!R().isVisible()||!v&&!R().isOnline()?t():J(lt).then(t)}return t(),()=>{e&&(clearTimeout(e),e=-1)}}),[p,m,v,S]),u(Y),a&&_e(M)&&S){if(!Ue&&qe)throw new Error("Fallback data is required when using suspense in SSR.");j.current=t,k.current=r,x.current=!1;const e=w[S];if(!_e(e)){const t=X(e);ut(t)}if(!_e(W))throw W;{const e=J(lt);_e(Y)||(e.status="fulfilled",e.value=!0),ut(e)}}return{mutate:X,get data(){return F.data=!0,Y},get error(){return F.error=!0,W},get isValidating(){return F.isValidating=!0,K},get isLoading(){return F.isLoading=!0,G}}},function(...e){const t=xe(nt,o(ot)),[r,n,a]=st(e),i=((e,t)=>{const r=xe(e,t);if(t){const{use:n,fallback:o}=e,{use:a,fallback:i}=t;n&&a&&(r.use=n.concat(a)),o&&i&&(r.fallback=xe(o,i))}return r})(t,a);let s=dt;const{use:c}=i,u=(c||[]).concat(ct);for(let e=u.length;e--;)s=u[e](s);return s(r,n||i.fetcher||null,i)});var dt;const pt=((e,t)=>(...r)=>{const[n,o,a]=st(r),i=(a.use||[]).concat(t);return e(n,o,{...a,use:i})})(ft,(e=>(t,r,n)=>(n.revalidateOnFocus=!1,n.revalidateIfStale=!1,n.revalidateOnReconnect=!1,e(t,r,n))));var mt=function(e){var t=ee(e.endpoint),r=f(),n=Q().showError,o=N().mutate,a=pt(e.sinOptions?null:(e.optionsPath||e.endpoint)+"/get-options",(function(e){return $(void 0,void 0,void 0,(function(){return V(this,(function(r){switch(r.label){case 0:return[4,t.get(e)];case 1:return[2,r.sent().data]}}))}))})).data,i=void 0===a?{}:a,s=new URLSearchParams(A(A({},e.params),r.query)).toString(),c=e.endpoint+(s?"?"+s:""),u=F(r.isReady?c:null,(function(e){return $(void 0,void 0,void 0,(function(){return V(this,(function(r){switch(r.label){case 0:return[4,t.get(e)];case 1:return[2,r.sent().data]}}))}))})),l=u.data,d=u.error,p=u.isLoading,m=(null==l?void 0:l.data)||[],v=(null==l?void 0:l.total)||0,h=new URLSearchParams(r.query),y=h.get("page"),g=y?parseInt(y):1,b=h.get("limit"),w=b?parseInt(b):20,S={loading:p,dataSource:m,rowKey:"_id",bordered:!0,pagination:{current:g,defaultPageSize:w,total:v},onChange:function(e,t,n){return $(void 0,void 0,void 0,(function(){var t,o,a,i;return V(this,(function(s){return t=h.toString(),o=new URLSearchParams(t),e.current!==g&&("1"===(a=e.current.toString())?o.delete("page"):o.set("page",a)),e.pageSize!==w&&("20"===(i=e.pageSize.toString())?o.delete("limit"):o.set("limit",i)),Array.isArray(n)||("ascend"===n.order?o.set("sort",n.field):"descend"===n.order?o.set("sort","-"+n.field):o.delete("sort")),t!==o.toString()&&r.push({query:Object.fromEntries(o)}),[2]}))}))}},_=function(){o(c)};return{data:m,isLoading:p,error:d,options:i,endpoint:e.endpoint,endpointWithHost:ne(e.endpoint),mainroute:r.route,tableProps:S,init:_,getOpt:function(e,t){var r,n=null===(r=i[e])||void 0===r?void 0:r.find((function(e){return e.id===t}));return n?n.description:""},remove:function(r){return $(void 0,void 0,void 0,(function(){var o;return V(this,(function(a){switch(a.label){case 0:return a.trys.push([0,2,,3]),[4,t.delete("string"==typeof r?e.endpoint+"/"+r:r.endpoint)];case 1:return a.sent(),_(),[3,3];case 2:return o=a.sent(),n(o),[3,3];case 3:return[2]}}))}))},cancel:function(r){return $(void 0,void 0,void 0,(function(){var o;return V(this,(function(a){switch(a.label){case 0:return a.trys.push([0,2,,3]),[4,t.delete("string"==typeof r?e.endpoint+"/"+r+"/cancel":r.endpoint)];case 1:return a.sent(),_(),[3,3];case 2:return o=a.sent(),n(o),[3,3];case 3:return[2]}}))}))}}},vt=function(e){var n=ee(e.endpoint),o=_.useForm()[0],a=t(!1),s=a[0],c=a[1],u=t(!1),p=u[0],v=u[1],h=f(),y=Q(),b=y.showError,w=y.message,S=function(e){var n=i(!1),o=Q().modal,a=i(0),s=t(0),c=s[0],u=s[1],l=function(){if(!window.confirm("¿Estás seguro que quieres salir?"))throw"Route Canceled";p(),localStorage.removeItem(e)},f=function(e){e.preventDefault()},p=function(){n.current=!1,window.removeEventListener("beforeunload",f),d.events.off("routeChangeStart",l),localStorage.removeItem(e),u(0)};return r((function(){if(n.current)return a.current!==c&&(window.addEventListener("beforeunload",f),d.events.on("routeChangeStart",l)),function(){window.removeEventListener("beforeunload",f),d.events.off("routeChangeStart",l)}}),[a.current,c]),{cambiarHashInicial:function(e){var t=oe(JSON.stringify(e));u(t),a.current=t},cambiarDatosFormulario:function(t){if(n.current&&0!==a.current){var r=JSON.stringify(t),o=oe(r);u(o),o===a.current?localStorage.removeItem(e):localStorage.setItem(e,r)}},limpiar:p,reanudar:function(){n.current=!0},obtenerDataEmergencia:function(){return $(void 0,void 0,void 0,(function(){var t,r;return V(this,(function(a){switch(a.label){case 0:return t=localStorage.getItem(e),[4,new Promise((function(e){if(!t)return e(void 0);o.confirm({title:"Existen datos guardados",icon:H.jsx(m,{}),content:"Hubo un cierre inesperado pero los datos fueron guardados temporalmente ¿Deseas recuperarlos?",onOk:function(){return e(JSON.parse(t))},onCancel:function(){return e(void 0)}})}))];case 1:return r=a.sent(),n.current=!0,[2,r]}}))}))}}}(h.asPath),E=i("emitir"),j=i(h.query.id),k=pt(e.sinOptions?null:e.endpoint+"/get-options",(function(e){return $(void 0,void 0,void 0,(function(){return V(this,(function(t){switch(t.label){case 0:return[4,n.get(e)];case 1:return[2,t.sent().data]}}))}))}),{revalidateOnFocus:!1}).data,R=void 0===k?{}:k;r((function(){j.current=e.registroId,j.current||(j.current=e.soloParaInsertar?void 0:h.query.id)}),[null==e?void 0:e.registroId,e.soloParaInsertar]);var T=h.asPath.replace(/\/(insert|[\w]*\/edit$)/g,"")||"/",L=function(t){for(var r=[],o=1;o<arguments.length;o++)r[o-1]=arguments[o];return $(void 0,U([t],r,!0),void 0,(function(t,r){var o,a,i,u,l,f,d,p;return void 0===r&&(r={}),V(this,(function(m){switch(m.label){case 0:if(!0===s)return[2];c(!0),S.limpiar(),o=r.endpoint||e.endpoint,a=r.params||void 0,m.label=1;case 1:return m.trys.push([1,6,,7]),i=void 0,j.current?[4,n.put(o+"/"+j.current,t,{params:a})]:[3,3];case 2:return i=m.sent().data,[3,5];case 3:return[4,n.post(o,t,{params:a})];case 4:i=m.sent().data,m.label=5;case 5:return!0!==r.noRedirect?(w.success("Guardado correctamente"),h.push(T)):c(!1),[2,i];case 6:if(u=m.sent(),c(!1),r.noShowError)throw u;return b(u),l=null===(p=null===(d=null==u?void 0:u.response)||void 0===d?void 0:d.data)||void 0===p?void 0:p.comprobante,f="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 f.includes(e)}))?h.push(T):!r.noRedirect&&l&&l!==j.current?(j.current=l,h.push(T+"/"+l+"/edit")):S.reanudar(),[3,7];case 7:return[2]}}))}))},P=H.jsxs(O,{children:[H.jsx(g,{type:"primary",loading:s,onClick:function(){return o.submit()},children:"Guardar"}),H.jsx(l,{href:T,children:H.jsx(g,{children:"Cancelar"})})]}),D=H.jsxs(H.Fragment,{children:[H.jsx(x,{paragraph:{rows:3,width:"100%"},className:"mb-4"}),H.jsx(x,{paragraph:{rows:4,width:"100%"},className:"mb-4"}),H.jsxs("div",{className:"grid grid-cols-2 gap-4 mb-4",children:[H.jsx(x,{paragraph:{rows:4,width:"100%"}}),H.jsx(x,{paragraph:{rows:4,width:"100%"}})]}),H.jsxs(O,{children:[H.jsx(x.Button,{}),H.jsx(x.Button,{})]})]}),I=function(){return w.warning("Revisa los errores del formulario")},F={form:o,autoComplete:"off",initialValues:e.data,onFinish:L,layout:"vertical",onFinishFailed:I};return r((function(){if(e.recuperacionEmergencia){var t=setInterval((function(){if(p){var e=o.getFieldsValue();S.cambiarDatosFormulario(e)}}),1e3);return function(){return clearInterval(t)}}}),[p]),r((function(){var t=setTimeout((function(){e.soloParaInsertar||$(void 0,void 0,void 0,(function(){var t,r,a;return V(this,(function(i){switch(i.label){case 0:return t=!1,[4,S.obtenerDataEmergencia()];case 1:return(r=i.sent())?(j.current=r._id,t=!0,[3,4]):[3,2];case 2:return j.current?[4,n.get("".concat(e.endpoint,"/").concat(j.current),{params:e.params})]:[3,4];case 3:r=i.sent().data,i.label=4;case 4:return r?[4,null===(a=e.formatearDataInicial)||void 0===a?void 0:a.call(e,r)]:[3,6];case 5:i.sent(),o.setFieldsValue(r),i.label=6;case 6:return[2,t?e.data:r||e.data]}}))})).then((function(t){var r;return Promise.all([S.cambiarHashInicial(t),null===(r=e.onMounted)||void 0===r?void 0:r.call(e)])})).then((function(){return v(!0)}))}),200);return function(){return clearTimeout(t)}}),[h.query.id]),{form:o,router:h,options:R,tipoEmision:E,objectId:j.current,mainroute:T,isLoading:s,isReady:p,data:e.data,endpoint:e.endpoint,onSubmit:L,onMainRouter:function(){return h.push(T)},setIsLoading:c,preventor:S,ModoCarga:D,BotonesPorDefecto:P,onMensajeValidacion:I,getOption:function(e,t){var r,n;return(null===(n=null===(r=R[e])||void 0===r?void 0:r.find((function(e){return e.id===t})))||void 0===n?void 0:n.description)||""},formProps:F}};var ht=function(e){var r=t(""),n=r[0];r[1];var o=function(e){var t=this,r=i(e.defaultOptions),n=(e.type,{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}});if(!n)return null;var o=ee(n.endpoint),a=F(n.withOptions&&!e.defaultOptions?n.endpoint+"/get-options":null,(function(e){return $(t,void 0,void 0,(function(){return V(this,(function(t){switch(t.label){case 0:return[4,o.get(e)];case 1:return[2,t.sent().data]}}))}))}),{revalidateOnFocus:!1}).data;return a&&(r.current=a),n}({type:e.type,defaultOptions:void 0});return o?H.jsx(_.Item,{name:e.name,label:e.hideLabel?void 0:e.label||o.label,extra:e.hideMessage?void 0:n,rules:e.required?[se.required()]:[{}],className:e.classNameFormItem}):null},yt="#F34D24",gt="#FFFFFF",bt=function(e){var n=t(!1),o=n[0],a=n[1];return r((function(){a(!0)}),[]),o?H.jsx(E,{locale:C,theme:{token:{colorPrimary:yt,colorLink:yt,colorTextDisabled:"#00000080"},components:{Layout:{bodyBg:gt,headerBg:gt}}},children:H.jsx(S,{children:H.jsx(j,{className:(e.className||"")+" min-h-screen w-full",style:e.style,children:e.children})})}):null},wt=function(e){var r=_.useFormInstance(),n=t([]),o=n[0],a=n[1],i=s((function(){var t=e.rules||[];switch(e.type){case"ruc":return{label:"RUC",placeholder:"Ingresar el RUC",max:13,rules:U(U([],t,!0),[se.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:U(U([],t,!0),[se.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:t}}}),[e.type]),c=I((function(t){return $(void 0,void 0,void 0,(function(){var r,n,i;return V(this,(function(s){switch(s.label){case 0:if(r=ee("utils"),!e.campoNombre||t.length<6||!["ci","ruc"].includes(e.type))return 0!==o.length&&a([]),[2];s.label=1;case 1:return s.trys.push([1,3,,4]),[4,r.get("/clientes/buscar",{params:{identificador:t,tipo:"ci"===e.type?"cedula":"ruc"}})];case 2:return n=s.sent().data,a(n.map((function(e){return{value:e.identificador,nombre:e.nombre,label:H.jsxs(H.Fragment,{children:[H.jsx("b",{children:e.identificador}),H.jsx("br",{}),e.nombre]})}}))),[3,4];case 3:return i=s.sent(),console.error(i),[3,4];case 4:return[2]}}))}))}),500);return H.jsx(_.Item,A({name:e.name,rules:i.rules,normalize:function(e){return e.trim().toUpperCase()},className:e.className,dependencies:e.dependencies},e.hiddenLabel?{}:{label:e.label||i.label},{children:H.jsx(k,{options:o,onSelect:function(t,n){r.setFieldValue(e.campoNombre,n.nombre)},onSearch:c,placeholder:e.placeholder||i.placeholder,maxLength:i.max,disabled:e.disabled,onChange:function(t){var r;return null===(r=e.onChange)||void 0===r?void 0:r.call(e,t)}})}))},St=function(e){var r=t(!0),n=r[0],o=r[1],a=t(!1),i=a[0],s=a[1];return H.jsxs(H.Fragment,{children:[e.sidebar?H.jsxs(j.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:n,collapsible:!0,width:"230px",onBreakpoint:function(e){o(e),s(e)},children:[H.jsx(l,{href:e.sidebar.title.href,children:H.jsx("div",{className:"flex justify-center items-center h-16 text-lg text-white font-bold",children:H.jsx("div",{children:e.sidebar.title.label})})}),e.sidebar.menu]}):null,H.jsxs(j,{className:i||n?"ml-0":"ml-[230px]",onClick:!n&&i?function(e){e.stopPropagation(),e.preventDefault(),o(!0)}:void 0,children:[e.navbar?H.jsx(j.Header,{className:"border-b top-0 !z-[2] sticky !px-4",children:H.jsxs("div",{className:"flex justify-between items-center h-full",children:[e.navbar.title?H.jsx("div",{children:H.jsx(g,{type:"text",icon:n?H.jsx(v,{}):H.jsx(h,{}),onClick:function(){return o(!n)},children:e.navbar.title})}):H.jsx("div",{}),e.navbar.options?H.jsx("div",{children:e.navbar.options}):H.jsx("div",{})]})}):null,H.jsx(j.Content,{className:"m-4 md:m-8 xl:m-16",children:e.children}),e.footer?H.jsx(j.Footer,{className:"!text-gray-500",children:e.footer}):null]})]})};export{ue as $filtros,se as $reglas,pe as ContextoEmpresa,K as Header,wt as IdentificadorPersona,St as LayoutBase,ht as Seeker,bt as TemaPrincipal,J as configurarUtils,te as crearToken,re as destruirToken,ne as getApiEndpoint,ee as getAxios,oe as hashear,ae as redireccionarLogin,fe as useContextoEmpresa,Q as useUtils,vt as useVistaInsertar,mt as useVistaPrincipal};
|
|
20
20
|
//# sourceMappingURL=index.js.map
|