upconta.frontend-utils 2.3.2 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.dist/cjs/components/Seeker.d.ts +10 -58
- package/.dist/cjs/components/Seeker.utils.d.ts +14 -38
- package/.dist/cjs/components/Seeker.utils.ec.d.ts +4 -0
- package/.dist/cjs/components/Seeker.utils.mx.d.ts +4 -66
- package/.dist/cjs/components/SeekerMx.d.ts +3 -2
- package/.dist/cjs/components/administrative/FormularioPersonas.d.ts +1 -1
- package/.dist/cjs/components/index.d.ts +4 -3
- package/.dist/cjs/components/mx/administrative/FormularioPersonasMx.d.ts +1 -1
- package/.dist/cjs/components/mx/administrative/FormularioProductoServicioMx.d.ts +1 -1
- package/.dist/cjs/components/mx/contability/FormularioCuentas.d.ts +1 -1
- package/.dist/cjs/components/production/ProductsServicesForm.d.ts +13 -0
- package/.dist/cjs/index.js +2 -2
- package/.dist/cjs/index.js.map +1 -1
- package/.dist/cjs/types/production.d.ts +78 -0
- package/.dist/cjs/types.d.ts +11 -0
- package/.dist/esm/index.js +2 -2
- package/.dist/esm/index.js.map +1 -1
- package/package.json +18 -18
package/.dist/esm/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import e,{useState as n,useEffect as r,
|
|
1
|
+
import e,{useState as n,useEffect as r,useRef as t,createContext as o,useContext as i,useMemo as a,forwardRef as l,useImperativeHandle as s}from"react";import c from"next/link";import u from"axios";import d from"swr/immutable";import{QuestionOutlined as p,ReloadOutlined as m,QuestionCircleOutlined as f,LoginOutlined as v,LogoutOutlined as h,HourglassOutlined as g,DeleteOutlined as b,MailOutlined as x,EditOutlined as j,StopOutlined as y,CloudUploadOutlined as I,CheckCircleOutlined as C,CloseCircleOutlined as P,SaveOutlined as w,HistoryOutlined as S,ExclamationCircleOutlined as N,CheckCircleTwoTone as F,LoadingOutlined as k,MenuUnfoldOutlined as E,MenuFoldOutlined as D}from"@ant-design/icons";import{Button as R,Modal as T,Form as O,Select as _,Typography as A,Input as V,Breadcrumb as L,App as q,Space as U,Skeleton as B,Drawer as M,Timeline as $,ConfigProvider as W,Layout as z,Badge as X,AutoComplete as Y,Tooltip as H,DatePicker as G,Divider as J,Table as Q,Tabs as K,InputNumber as Z,Checkbox as ee,Popover as ne,Popconfirm as re,message as te,Card as oe,Empty as ie,Collapse as ae,Tag as le,Alert as se}from"antd";import{useRouter as ce,Router as ue}from"next/router";import de from"antd/locale/es_ES";import{setCookie as pe,deleteCookie as me}from"cookies-next";import{useDebouncedCallback as fe,useDebounce as ve}from"use-debounce";import he from"dayjs";import ge,{useSWRConfig as be}from"swr";var xe=function(){return xe=Object.assign||function(e){for(var n,r=1,t=arguments.length;r<t;r++)for(var o in n=arguments[r])Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o]);return e},xe.apply(this,arguments)};function je(e,n,r,t){return new(r||(r=Promise))(function(o,i){function a(e){try{s(t.next(e))}catch(e){i(e)}}function l(e){try{s(t.throw(e))}catch(e){i(e)}}function s(e){var n;e.done?o(e.value):(n=e.value,n instanceof r?n:new r(function(e){e(n)})).then(a,l)}s((t=t.apply(e,n||[])).next())})}function ye(e,n){var r,t,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=l(0),a.throw=l(1),a.return=l(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function l(l){return function(s){return function(l){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(i=0)),i;)try{if(r=1,t&&(o=2&l[0]?t.return:l[0]?t.throw||((o=t.return)&&o.call(t),0):t.next)&&!(o=o.call(t,l[1])).done)return o;switch(t=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return i.label++,{value:l[1],done:!1};case 5:i.label++,t=l[1],l=[0];continue;case 7:l=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==l[0]&&2!==l[0])){i=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){i.label=l[1];break}if(6===l[0]&&i.label<o[1]){i.label=o[1],o=l;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(l);break}o[2]&&i.ops.pop(),i.trys.pop();continue}l=n.call(e,i)}catch(e){l=[6,e],t=0}finally{r=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}([l,s])}}}function Ie(e,n,r){if(r||2===arguments.length)for(var t,o=0,i=n.length;o<i;o++)!t&&o in n||(t||(t=Array.prototype.slice.call(n,0,o)),t[o]=n[o]);return e.concat(t||Array.prototype.slice.call(n))}"function"==typeof SuppressedError&&SuppressedError;var Ce,Pe={exports:{}},we={};var Se,Ne={};
|
|
2
2
|
/**
|
|
3
3
|
* @license React
|
|
4
4
|
* react-jsx-runtime.development.js
|
|
@@ -7,5 +7,5 @@ import e,{useState as n,useEffect as r,createContext as t,useContext as o,useRef
|
|
|
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?we.exports=function(){if(Ce)return Pe;Ce=1;var n=e,r=Symbol.for("react.element"),t=Symbol.for("react.fragment"),o=Object.prototype.hasOwnProperty,i=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,a={key:!0,ref:!0,__self:!0,__source:!0};function l(e,n,t){var l,s={},c=null,u=null;for(l in void 0!==t&&(c=""+t),void 0!==n.key&&(c=""+n.key),void 0!==n.ref&&(u=n.ref),n)o.call(n,l)&&!a.hasOwnProperty(l)&&(s[l]=n[l]);if(e&&e.defaultProps)for(l in n=e.defaultProps)void 0===s[l]&&(s[l]=n[l]);return{$$typeof:r,type:e,key:c,ref:u,props:s,_owner:i.current}}return Pe.Fragment=t,Pe.jsx=l,Pe.jsxs=l,Pe}():we.exports=(Se||(Se=1,"production"!==process.env.NODE_ENV&&function(){var n,r=e,t=Symbol.for("react.element"),o=Symbol.for("react.portal"),i=Symbol.for("react.fragment"),a=Symbol.for("react.strict_mode"),l=Symbol.for("react.profiler"),s=Symbol.for("react.provider"),c=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),d=Symbol.for("react.suspense"),p=Symbol.for("react.suspense_list"),m=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),v=Symbol.for("react.offscreen"),h=Symbol.iterator,g=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function b(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),t=1;t<n;t++)r[t-1]=arguments[t];!function(e,n,r){var t=g.ReactDebugCurrentFrame.getStackAddendum();""!==t&&(n+="%s",r=r.concat([t]));var o=r.map(function(e){return String(e)});o.unshift("Warning: "+n),Function.prototype.apply.call(console[e],console,o)}("error",e,r)}function x(e){return e.displayName||"Context"}function j(e){if(null==e)return null;if("number"==typeof e.tag&&b("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 i:return"Fragment";case o:return"Portal";case l:return"Profiler";case a:return"StrictMode";case d:return"Suspense";case p:return"SuspenseList"}if("object"==typeof e)switch(e.$$typeof){case c:return x(e)+".Consumer";case s:return x(e._context)+".Provider";case u:return function(e,n,r){var t=e.displayName;if(t)return t;var o=n.displayName||n.name||"";return""!==o?r+"("+o+")":r}(e,e.render,"ForwardRef");case m:var n=e.displayName||null;return null!==n?n:j(e.type)||"Memo";case f:var r=e,t=r._payload,v=r._init;try{return j(v(t))}catch(e){return null}}return null}n=Symbol.for("react.module.reference");var y,I,C,w,P,S,F,N=Object.assign,k=0;function E(){}E.__reactDisabledLog=!0;var T,R=g.ReactCurrentDispatcher;function D(e,n,r){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 O,_=!1,A="function"==typeof WeakMap?WeakMap:Map;function L(e,n){if(!e||_)return"";var r,t=O.get(e);if(void 0!==t)return t;_=!0;var o,i=Error.prepareStackTrace;Error.prepareStackTrace=void 0,o=R.current,R.current=null,function(){if(0===k){y=console.log,I=console.info,C=console.warn,w=console.error,P=console.group,S=console.groupCollapsed,F=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})}k++}();try{if(n){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(n){if(n&&r&&"string"==typeof n.stack){for(var l=n.stack.split("\n"),s=r.stack.split("\n"),c=l.length-1,u=s.length-1;c>=1&&u>=0&&l[c]!==s[u];)u--;for(;c>=1&&u>=0;c--,u--)if(l[c]!==s[u]){if(1!==c||1!==u)do{if(c--,--u<0||l[c]!==s[u]){var d="\n"+l[c].replace(" at new "," at ");return e.displayName&&d.includes("<anonymous>")&&(d=d.replace("<anonymous>",e.displayName)),"function"==typeof e&&O.set(e,d),d}}while(c>=1&&u>=0);break}}}finally{_=!1,R.current=o,function(){if(0===--k){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:N({},e,{value:y}),info:N({},e,{value:I}),warn:N({},e,{value:C}),error:N({},e,{value:w}),group:N({},e,{value:P}),groupCollapsed:N({},e,{value:S}),groupEnd:N({},e,{value:F})})}k<0&&b("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}(),Error.prepareStackTrace=i}var p=e?e.displayName||e.name:"",m=p?D(p):"";return"function"==typeof e&&O.set(e,m),m}function q(e,n,r){if(null==e)return"";if("function"==typeof e)return L(e,!(!(t=e.prototype)||!t.isReactComponent));var t;if("string"==typeof e)return D(e);switch(e){case d:return D("Suspense");case p:return D("SuspenseList")}if("object"==typeof e)switch(e.$$typeof){case u:return L(e.render,!1);case m:return q(e.type,n,r);case f:var o=e,i=o._payload,a=o._init;try{return q(a(i),n,r)}catch(e){}}return""}O=new A;var V=Object.prototype.hasOwnProperty,U={},M=g.ReactDebugCurrentFrame;function B(e){if(e){var n=e._owner,r=q(e.type,e._source,n?n.type:null);M.setExtraStackFrame(r)}else M.setExtraStackFrame(null)}var $=Array.isArray;function W(e){return $(e)}function z(e){return""+e}function X(e){if(function(e){try{return z(e),!1}catch(e){return!0}}(e))return b("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)),z(e)}var Y,H,J=g.ReactCurrentOwner,G={key:!0,ref:!0,__self:!0,__source:!0};function Q(e,n,r,o,i){var a,l={},s=null,c=null;for(a in void 0!==r&&(X(r),s=""+r),function(e){if(V.call(e,"key")){var n=Object.getOwnPropertyDescriptor(e,"key").get;if(n&&n.isReactWarning)return!1}return void 0!==e.key}(n)&&(X(n.key),s=""+n.key),function(e){if(V.call(e,"ref")){var n=Object.getOwnPropertyDescriptor(e,"ref").get;if(n&&n.isReactWarning)return!1}return void 0!==e.ref}(n)&&(c=n.ref,function(e){"string"==typeof e.ref&&J.current}(n)),n)V.call(n,a)&&!G.hasOwnProperty(a)&&(l[a]=n[a]);if(e&&e.defaultProps){var u=e.defaultProps;for(a in u)void 0===l[a]&&(l[a]=u[a])}if(s||c){var d="function"==typeof e?e.displayName||e.name||"Unknown":e;s&&function(e,n){var r=function(){Y||(Y=!0,b("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",n))};r.isReactWarning=!0,Object.defineProperty(e,"key",{get:r,configurable:!0})}(l,d),c&&function(e,n){var r=function(){H||(H=!0,b("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",n))};r.isReactWarning=!0,Object.defineProperty(e,"ref",{get:r,configurable:!0})}(l,d)}return function(e,n,r,o,i,a,l){var s={$$typeof:t,type:e,key:n,ref:r,props:l,_owner:a,_store:{}};return Object.defineProperty(s._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(s,"_self",{configurable:!1,enumerable:!1,writable:!1,value:o}),Object.defineProperty(s,"_source",{configurable:!1,enumerable:!1,writable:!1,value:i}),Object.freeze&&(Object.freeze(s.props),Object.freeze(s)),s}(e,s,c,i,o,J.current,l)}var K,Z=g.ReactCurrentOwner,ee=g.ReactDebugCurrentFrame;function ne(e){if(e){var n=e._owner,r=q(e.type,e._source,n?n.type:null);ee.setExtraStackFrame(r)}else ee.setExtraStackFrame(null)}function re(e){return"object"==typeof e&&null!==e&&e.$$typeof===t}function te(){if(Z.current){var e=j(Z.current.type);if(e)return"\n\nCheck the render method of `"+e+"`."}return""}K=!1;var oe={};function ie(e,n){if(e._store&&!e._store.validated&&null==e.key){e._store.validated=!0;var r=function(e){var n=te();if(!n){var r="string"==typeof e?e:e.displayName||e.name;r&&(n="\n\nCheck the top-level render call using <"+r+">.")}return n}(n);if(!oe[r]){oe[r]=!0;var t="";e&&e._owner&&e._owner!==Z.current&&(t=" It was passed a child from "+j(e._owner.type)+"."),ne(e),b('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',r,t),ne(null)}}}function ae(e,n){if("object"==typeof e)if(W(e))for(var r=0;r<e.length;r++){var t=e[r];re(t)&&ie(t,n)}else if(re(e))e._store&&(e._store.validated=!0);else if(e){var o=function(e){if(null===e||"object"!=typeof e)return null;var n=h&&e[h]||e["@@iterator"];return"function"==typeof n?n:null}(e);if("function"==typeof o&&o!==e.entries)for(var i,a=o.call(e);!(i=a.next()).done;)re(i.value)&&ie(i.value,n)}}function le(e){var n,r=e.type;if(null!=r&&"string"!=typeof r){if("function"==typeof r)n=r.propTypes;else{if("object"!=typeof r||r.$$typeof!==u&&r.$$typeof!==m)return;n=r.propTypes}if(n){var t=j(r);!function(e,n,r,t,o){var i=Function.call.bind(V);for(var a in e)if(i(e,a)){var l=void 0;try{if("function"!=typeof e[a]){var s=Error((t||"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 s.name="Invariant Violation",s}l=e[a](n,a,t,r,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(e){l=e}!l||l instanceof Error||(B(o),b("%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",r,a,typeof l),B(null)),l instanceof Error&&!(l.message in U)&&(U[l.message]=!0,B(o),b("Failed %s type: %s",r,l.message),B(null))}}(n,e.props,"prop",t,e)}else void 0===r.PropTypes||K||(K=!0,b("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",j(r)||"Unknown"));"function"!=typeof r.getDefaultProps||r.getDefaultProps.isReactClassApproved||b("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}var se={};function ce(e,r,o,h,g,x){var y=function(e){return"string"==typeof e||"function"==typeof e||e===i||e===l||e===a||e===d||e===p||e===v||"object"==typeof e&&null!==e&&(e.$$typeof===f||e.$$typeof===m||e.$$typeof===s||e.$$typeof===c||e.$$typeof===u||e.$$typeof===n||void 0!==e.getModuleId)}(e);if(!y){var I,C="";(void 0===e||"object"==typeof e&&null!==e&&0===Object.keys(e).length)&&(C+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports."),C+=te(),null===e?I="null":W(e)?I="array":void 0!==e&&e.$$typeof===t?(I="<"+(j(e.type)||"Unknown")+" />",C=" Did you accidentally export a JSX literal instead of a component?"):I=typeof e,b("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",I,C)}var w=Q(e,r,o,g,x);if(null==w)return w;if(y){var P=r.children;if(void 0!==P)if(h)if(W(P)){for(var S=0;S<P.length;S++)ae(P[S],e);Object.freeze&&Object.freeze(P)}else b("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 ae(P,e)}if(V.call(r,"key")){var F=j(e),N=Object.keys(r).filter(function(e){return"key"!==e}),k=N.length>0?"{key: someKey, "+N.join(": ..., ")+": ...}":"{key: someKey}";se[F+k]||(b('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} />',k,F,N.length>0?"{"+N.join(": ..., ")+": ...}":"{}",F),se[F+k]=!0)}return e===i?function(e){for(var n=Object.keys(e.props),r=0;r<n.length;r++){var t=n[r];if("children"!==t&&"key"!==t){ne(e),b("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),b("Invalid attribute `ref` supplied to `React.Fragment`."),ne(null))}(w):le(w),w}var ue=function(e,n,r){return ce(e,n,r,!1)},de=function(e,n,r){return ce(e,n,r,!0)};Fe.Fragment=i,Fe.jsx=ue,Fe.jsxs=de}()),Fe);var Ne=we.exports,ke=function(e){var t=n(!1),o=t[0],i=t[1],a=n(""),l=a[0],s=a[1],c=d(["/api/v3/videos/public",e.pathname],function(e){return je(void 0,[e],void 0,function(e){var n,r,t,o=e[0],i=e[1];return ye(this,function(e){switch(e.label){case 0:return n=i.split("/"),r=n[1],t=n[2],[4,u.get(o,{params:{module:r,submodule:t,showIn:"page"}})];case 1:return[2,e.sent().data]}})})}),m=c.data,f=c.isLoading;return r(function(){m&&m.length>0&&s(m[0].videoId)},[m]),m&&0!==m.length?Ne.jsxs("div",{children:[Ne.jsx(R,xe({loading:f,title:"Videos de ayuda",icon:Ne.jsx(p,{}),onClick:function(){return i(!0)}},e.buttonProps)),Ne.jsxs(D,{title:"Videos de ayuda",footer:null,open:o,maskClosable:!1,width:640,onCancel:function(){return i(!1)},children:[Ne.jsx(O.Item,{children:Ne.jsx(_,{className:"w-full",value:l,onChange:function(e){return s(e)},children:m.map(function(e){return Ne.jsx(_.Option,{value:e.videoId,children:e.title},e.videoId)})})}),Ne.jsx("iframe",{title:"YouTube video player",className:"aspect-video w-full rounded-sm mb-4",src:"https://www.youtube.com/embed/".concat(l),allowFullScreen:!0}),Ne.jsxs(A.Text,{type:"secondary",children:["Suscríbete a nuestro"," ",Ne.jsx(A.Link,{href:"https://www.youtube.com/channel/UCPo_ZWhAfRtbIzMwAJe7iVA",target:"_blank",children:"canal de YouTube"}),". Mantente informado de nuestras últimas actualizaciones, novedades y tutoriales."]})]})]}):null},Ee=function(e){return e.paths?Ne.jsx(q,{items:e.paths.map(function(e){var n=e.to,r=e.label;return{title:n?Ne.jsx(c,{href:n,children:r}):r}})}):null},Te=function(e){var t,o=e.defaultInsert,i=void 0!==o&&o,a=e.loading,l=void 0!==a&&a,s=function(e,n){var r={};for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&n.indexOf(t)<0&&(r[t]=e[t]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(t=Object.getOwnPropertySymbols(e);o<t.length;o++)n.indexOf(t[o])<0&&Object.prototype.propertyIsEnumerable.call(e,t[o])&&(r[t[o]]=e[t[o]])}return r}(e,["defaultInsert","loading"]),u=ce(),d=u.pathname,p=n(""),f=p[0],v=p[1],h=new URLSearchParams(u.query),g=function(){var e=new URLSearchParams(h.toString());(e.get("q")||"")!==f&&(f?e.set("q",f):e.delete("q"),e.delete("page"),u.push({query:Object.fromEntries(e)}))},b=Ne.jsxs("div",{className:"flex w-full md:w-auto flex-wrap md:flex-nowrap gap-2 justify-end",children:[!0!==s.ocultarBuscador?Ne.jsx(L.Search,{value:f,placeholder:"Ingresar búsqueda",onChange:function(e){return v(e.target.value||"")},onSearch:g,onPressEnter:g}):null,null!==i?i||Ne.jsx(c,{href:(t=d,t.endsWith("/")&&(t=t.slice(0,-1)),t+"/insert"),children:Ne.jsx(R,{type:"primary",children:"Insertar"})}):null,s.onRefrescar?Ne.jsx("div",{children:Ne.jsx(R,{loading:l,title:"Refrescar datos",icon:Ne.jsx(m,{}),onClick:s.onRefrescar})}):null,s.children,s.tutorialPathname&&Ne.jsx(ke,{pathname:s.tutorialPathname})]});return r(function(){u.isReady&&v(h.get("q")||"")},[u.isReady]),Ne.jsxs("div",{className:"flex md:flex-row flex-col md:items-end items-start justify-between gap-6 mb-8",children:[Ne.jsxs("div",{children:[Ne.jsx(Ee,{paths:s.paths}),Ne.jsx(A.Title,{className:"mb-0! mt-4",children:s.title}),s.subtitle&&Ne.jsx(A.Title,{level:3,type:"secondary",className:"font-normal! m-0!",children:s.subtitle})]}),null!==s.column?s.column||b:null]})},Re={host:{api:process.env.NEXT_PUBLIC_API,apiOpen:process.env.NEXT_PUBLIC_API_OPEN,restify:process.env.NEXT_PUBLIC_RESTIFY,restifyOpen:process.env.NEXT_PUBLIC_RESTIFY_OPEN,utils:process.env.NEXT_PUBLIC_UTILS,utilsOpen:process.env.NEXT_PUBLIC_UTILS_OPEN},userTokenName:"",adminTokenName:"",cookieDominio:"",cookiePath:void 0},De=function(e){return je(void 0,void 0,void 0,function(){var n,r,t,o,i,a;return ye(this,function(l){switch(l.label){case 0:if(!((n=(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];l.label=1;case 1:return l.trys.push([1,3,,5]),t=(r=JSON).parse,[4,n.text()];case 2:return[2,{message:t.apply(r,[l.sent()]).message,tipo:"error"}];case 3:return l.sent(),o={},[4,n.text()];case 4:return[2,(o.message=l.sent(),o.tipo="error",o)];case 5:return[2,{message:n,tipo:"error"}]}})})},Oe=function(){var e=V.useApp(),n=e.modal,r=e.message,t=e.notification;return{showError:function(e,r){return je(void 0,void 0,void 0,function(){var t;return ye(this,function(o){switch(o.label){case 0:return[4,De(e)];case 1:return t=o.sent(),n[t.tipo]({title:(null==r?void 0:r.title)||"Proceso fallido",width:450,content:Ne.jsxs(Ne.Fragment,{children:[t.message,null==r?void 0:r.cuerpoAdicional]}),okType:"danger"}),[2]}})})},modal:n,message:r,notification:t}},_e=function(e){return"administrador"===e?Re.adminTokenName:Re.userTokenName},Ae=function(e,n){pe(_e(n.usuario),e,{domain:Re.cookieDominio,maxAge:604800,path:Re.cookiePath})},Le=function(e){me(_e(e),{domain:Re.cookieDominio,path:Re.cookiePath})},qe=function(e,n){var r=e.includes("/v4")?Re.host.apiOpen:Re.host.restifyOpen;if(r){var t=new URL(e.replace(/^\/api/,""),r),o="";return n&&(o=new URLSearchParams(n).toString()),t.href+(o?"?"+o:"")}},Ve=function(e,n){for(var r=(n=(n=n.replace(/\[(\w+)\]/g,".$1")).replace(/^\./,"")).split("."),t=0,o=r.length;t<o;++t){var i=r[t];if(!e||!(i in e))return;e=e[i]}return e},Ue=function(e){var n,r=0;if(0===e.length)return r;for(n=0;n<e.length;n++)r=(r<<5)-r+e.charCodeAt(n),r|=0;return r},Me=function(e,n){void 0===n&&(n="/login");var r=n.includes("://"),t=new URL(r?n:window.location.origin+n);("/"!==e.asPath||r)&&t.searchParams.append("redirect",r?window.location.href:e.asPath),r?window.location.href=t.href:e.push(t.pathname+t.search)};function Be(e,n){void 0===n&&(n=2);var r=Math.pow(10,n);return Math.round(+(e*r).toFixed(2))/r}var $e=[{source:"/api/v4/:path*",destination:"".concat(process.env.NEXT_PUBLIC_API,"/v4/:path*")},{source:"/api/:path*",destination:"".concat(process.env.NEXT_PUBLIC_RESTIFY,"/:path*")},{source:"/utils/:path*",destination:"".concat(process.env.NEXT_PUBLIC_UTILS,"/:path*")}],We=function(){return((new Date).getTime()/1e3|0).toString(16)+"xxxxxxxxxxxxxxxx".replace(/[x]/g,function(){return(16*Math.random()|0).toString(16)}).toLowerCase()},ze=t(null);function Xe(){var e=o(ze);if(null===e)throw new Error("useContextoEmpresa debe usarse dentro de EmpresaContext.Provider");return e}var Ye=function(e){var t=ce(),o=n(!1),i=o[0],a=o[1],l=n(),s=l[0],c=l[1];return r(function(){je(void 0,void 0,void 0,function(){var e,n,r;return ye(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,Promise.all([u.get("/api/v3/auth/user"),u.get("/api/v3/businesses/me/configurations",{params:{fields:"comprobantes nDecimals invoice"}})])];case 1:return e=t.sent(),n=e[0].data,r=e[1].data,n.configuraciones=r,[2,n];case 2:return t.sent(),[2,null];case 3:return[2]}})}).then(function(n){n?(a(!0),c(n)):Me(t,e.pathLogin)})},[]),i?Ne.jsx(ze.Provider,{value:{business:s,nombreEmpresa:s.business,nombreUsuario:s.user,testEnviroment:s.configs.useTestEnviroment,usuarioEsAdmin:"admin"===s.userType,getPermisos:function(e){var n,r,o,i,a,l,c,u,d,p={leer:!1,escribir:!1,eliminar:!1,anular:!1},m=e||t.route;if("admin"===(null==s?void 0:s.userType))return{leer:!0,escribir:!0,eliminar:!0,anular:!0};var f=m.split("/"),v=f[1],h=f[2],g=null==s?void 0:s.modules.find(function(e){return e.key===v});if(!g)return p;for(var b=0,x=g.submodules;b<x.length;b++){var j=x[b];if(j.key&&j.key===h){p={leer:!!(null===(n=j.permisos)||void 0===n?void 0:n.includes("leer")),escribir:!!(null===(r=j.permisos)||void 0===r?void 0:r.includes("escribir")),eliminar:!!(null===(o=j.permisos)||void 0===o?void 0:o.includes("eliminar")),anular:!!(null===(i=j.permisos)||void 0===i?void 0:i.includes("anular"))};break}var y=null===(a=j.items)||void 0===a?void 0:a.find(function(e){return e.key===h});if(y){p={leer:!!(null===(l=y.permisos)||void 0===l?void 0:l.includes("leer")),escribir:!!(null===(c=y.permisos)||void 0===c?void 0:c.includes("escribir")),eliminar:!!(null===(u=y.permisos)||void 0===u?void 0:u.includes("eliminar")),anular:!!(null===(d=y.permisos)||void 0===d?void 0:d.includes("anular"))};break}}return p},hasModule:function(e,n){var r=null==s?void 0:s.modules.find(function(n){return n.key===e});return!!r&&de(n).isAfter(r.operationDate)}},children:e.children}):Ne.jsx("div",{className:"w-full h-screen flex items-center justify-center",children:"Cargando..."})},He={empresa:function(e,n){return je(void 0,void 0,void 0,function(){return ye(this,function(e){switch(e.label){case 0:return n?[4,u.get("/api/v3/auth/business/"+n)]:[2];case 1:if(e.sent().data)throw new Error("La empresa ya se encuentra registrada");return[2]}})})}},Je={required:function(e){return void 0===e&&(e="El campo es requerido"),{required:!0,message:e}},min:function(e,n){return void 0===n&&(n="Debe tener mínimo ".concat(e.toString()," caracteres")),{min:e,message:n}},max:function(e,n){return void 0===n&&(n="Debe tener máximo ".concat(e.toString()," caracteres")),{max:e,message:n}},email:function(e){return void 0===e&&(e="El correo electrónico no es válido"),{type:"email",message:e}},pattern:function(e,n){return void 0===n&&(n="No cumple el formato requerido"),{pattern:e,message:n}},unico:function(e){return{validator:fe(He[e],300)}},correos:function(){return{validator:function(e){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];return je(void 0,Ie([e],n,!0),void 0,function(e,n){return void 0===n&&(n=[]),ye(this,function(e){if(n.some(function(e){return!e.includes("@")}))throw new Error("Alguno de los correos no es válido");return[2]})})}}},emissionDeadline:function(e){return void 0===e&&(e="La fecha está fuera de los 4 días hábiles permitidos para la emisión."),{validator:function(n,r){return je(void 0,void 0,void 0,function(){return ye(this,function(n){switch(n.label){case 0:if(!r)return[2];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,u.head("/v4/utils/is-within-transmission-deadline",{params:{date:r.toISOString()}})];case 2:return n.sent(),[3,4];case 3:throw n.sent(),new Error(e);case 4:return[2]}})})}}}},Ge="es-EC",Qe={currency:function(e,n){return void 0===n&&(n=2),e||(e=0),new Intl.NumberFormat(Ge,{style:"currency",currency:"USD",minimumFractionDigits:"object"==typeof n?n.min:2,maximumFractionDigits:"object"==typeof n?n.max:n}).format("number"==typeof e?e:parseFloat(e))},date:function(e,n){return void 0===n&&(n="DD/MM/YYYY"),de(e).format(n)},dateLiteral:function(e){return new Date(e).toLocaleDateString("es-EC",{weekday:"long",month:"numeric",year:"numeric",day:"numeric"})},completeDate:function(e){return de(e).format("DD/MM/YYYY HH:mm:ss")},month:function(e){return de(e).format("MM/YYYY")},percent:function(e,n){return void 0===n&&(n=2),e||(e=0),new Intl.NumberFormat(Ge,{style:"percent",minimumFractionDigits:n}).format("number"==typeof e?e:parseFloat(e))}},Ke=function(e){var n=ce(),r=Oe().showError,t=ge().mutate,o=d(e.sinOptions?null:(e.optionsPath||e.endpoint)+"/get-options",function(e){return je(void 0,void 0,void 0,function(){return ye(this,function(n){switch(n.label){case 0:return[4,u.get(e)];case 1:return[2,n.sent().data]}})})}).data,i=void 0===o?{}:o,a=new URLSearchParams(xe(xe({},e.params),n.query)).toString(),l=e.endpoint+(a?"?"+a:""),s=he(n.isReady?l:null,function(e){return je(void 0,void 0,void 0,function(){return ye(this,function(n){switch(n.label){case 0:return[4,u.get(e)];case 1:return[2,n.sent().data]}})})},{keepPreviousData:!0}),c=s.data,p=s.error,m=s.isLoading,f=(null==c?void 0:c.data)||[],v=(null==c?void 0:c.total)||0,h=new URLSearchParams(n.query),g=h.get("page"),b=g?parseInt(g):1,x=h.get("limit"),j=x?parseInt(x):20,y={loading:m,dataSource:f,rowKey:"_id",bordered:!0,pagination:{current:b,defaultPageSize:j,total:v},onChange:function(r,t,o){return je(void 0,void 0,void 0,function(){var i,a,l,s,c;return ye(this,function(u){return i=h.toString(),a=new URLSearchParams(i),r.current!==b&&("1"===(l=r.current.toString())?a.delete("page"):a.set("page",l)),r.pageSize!==j&&("20"===(s=r.pageSize.toString())?a.delete("limit"):a.set("limit",s)),Array.isArray(o)||("ascend"===o.order?a.set("sort",o.field):"descend"===o.order?a.set("sort","-"+o.field):a.delete("sort")),c=[],Object.entries(t).forEach(function(n){var r=n[0],t=n[1];t&&0!==t.length?t.some(function(n){return Object.values(e.filtros||{}).some(function(e){return e.value===n})})?(c.push(r),t.forEach(function(e){new URLSearchParams(e).forEach(function(e,n){a.set(n,e)})})):1===t.length&&/\{\$(gte?|lte?)\}/.test(t[0])?a.set(r,t[0]):a.set(r,"{$in}"+t.join(",")):a.delete(r)}),e.filtros&&Object.entries(e.filtros).forEach(function(e){var n=e[0],r=e[1];c.includes(n)||new URLSearchParams(r.value).forEach(function(e,n){a.get(n)===e&&a.delete(n)})}),i!==a.toString()&&n.push({query:Object.fromEntries(a)}),[2]})})}},I=function(){return t(l)};return{data:f,isLoading:m,error:p,options:i,endpoint:e.endpoint,endpointWithHost:qe(e.endpoint),mainroute:n.route,tableProps:y,axios:u,init:I,getOpt:function(e,n,r){var t;void 0===r&&(r=!1);var o=null===(t=i[e])||void 0===t?void 0:t.find(function(e){return e.id===n});return o?r?o.id+" - "+o.description:o.description:""},setData:function(e){return t(l,e,{revalidate:!1})},remove:function(n){return je(void 0,void 0,void 0,function(){var t;return ye(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,u.delete("string"==typeof n?e.endpoint+"/"+n:n.endpoint)];case 1:return o.sent(),I(),[3,3];case 2:return t=o.sent(),r(t),[3,3];case 3:return[2]}})})},cancel:function(n){return je(void 0,void 0,void 0,function(){var t;return ye(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,u.delete("string"==typeof n?e.endpoint+"/"+n+"/cancel":n.endpoint)];case 1:return o.sent(),I(),[3,3];case 2:return t=o.sent(),r(t),[3,3];case 3:return[2]}})})}}},Ze=function(e){var t=O.useForm()[0],o=n(!1),a=o[0],l=o[1],s=n(!1),p=s[0],m=s[1],v=ce(),h=Oe(),g=h.showError,b=h.message,x=function(e){var t=i(!1),o=Oe().modal,a=i(0),l=n(0),s=l[0],c=l[1],u=function(){if(!window.confirm("¿Estás seguro que quieres salir?"))throw"Route Canceled";p(),localStorage.removeItem(e)},d=function(e){e.preventDefault()},p=function(){t.current=!1,window.removeEventListener("beforeunload",d),ue.events.off("routeChangeStart",u),localStorage.removeItem(e),c(0)};return r(function(){if(t.current)return a.current!==s&&(window.addEventListener("beforeunload",d),ue.events.on("routeChangeStart",u)),function(){window.removeEventListener("beforeunload",d),ue.events.off("routeChangeStart",u)}},[a.current,s]),{cambiarHashInicial:function(e){var n=Ue(JSON.stringify(e));c(n),a.current=n},cambiarDatosFormulario:function(n){if(t.current&&0!==a.current){var r=JSON.stringify(n),o=Ue(r);c(o),o===a.current?localStorage.removeItem(e):localStorage.setItem(e,r)}},limpiar:p,reanudar:function(){t.current=!0},obtenerDataEmergencia:function(){return je(void 0,void 0,void 0,function(){var n,r;return ye(this,function(i){switch(i.label){case 0:return n=localStorage.getItem(e),[4,new Promise(function(e){if(!n)return e(void 0);o.confirm({title:"Existen datos guardados",icon:Ne.jsx(f,{}),content:"Hubo un cierre inesperado pero los datos fueron guardados temporalmente ¿Deseas recuperarlos?",onOk:function(){return e(JSON.parse(n))},onCancel:function(){return e(void 0)}})})];case 1:return r=i.sent(),t.current=!0,[2,r]}})})}}}(v.asPath),j=i("emitir"),y=i(e.data),I=i(),C=d(e.sinOptions?null:e.endpoint+"/get-options",function(e){return je(void 0,void 0,void 0,function(){return ye(this,function(n){switch(n.label){case 0:return[4,u.get(e)];case 1:return[2,n.sent().data]}})})},{revalidateOnFocus:!1}).data,w=void 0===C?{}:C;r(function(){I.current=e.registroId,I.current||(I.current=e.soloParaInsertar?void 0:v.query.id)},[null==e?void 0:e.registroId,e.soloParaInsertar]);var P=v.asPath.replace(/\/(insert|[\w]*\/edit$)/g,"")||"/",S=function(n){for(var r=[],t=1;t<arguments.length;t++)r[t-1]=arguments[t];return je(void 0,Ie([n],r,!0),void 0,function(n,r){var t,o,i,s,c,d,p,m;return void 0===r&&(r={}),ye(this,function(f){switch(f.label){case 0:if(!0===a)return[2];l(!0),x.limpiar(),t=r.endpoint||e.endpoint,o=r.params||void 0,f.label=1;case 1:return f.trys.push([1,6,,7]),i=void 0,I.current?[4,u.put(t+"/"+I.current,n,{params:o})]:[3,3];case 2:return i=f.sent().data,[3,5];case 3:return[4,u.post(t,n,{params:o})];case 4:i=f.sent().data,f.label=5;case 5:return!0!==r.noRedirect?(b.success("Guardado correctamente"),v.push(P)):l(!1),[2,i];case 6:if(s=f.sent(),l(!1),r.noShowError)throw s;return g(s),c=null===(m=null===(p=null==s?void 0:s.response)||void 0===p?void 0:p.data)||void 0===m?void 0:m.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)})?v.push(P):!r.noRedirect&&c&&c!==I.current?(I.current=c,v.push(P+"/"+c+"/edit")):x.reanudar(),[3,7];case 7:return[2]}})})},F=Ne.jsxs(U,{children:[Ne.jsx(R,{type:"primary",loading:a,onClick:function(){return t.submit()},children:"Guardar"}),Ne.jsx(c,{href:P,children:Ne.jsx(R,{children:"Cancelar"})})]}),N=Ne.jsxs(Ne.Fragment,{children:[Ne.jsx(M,{paragraph:{rows:3,width:"100%"},className:"mb-4"}),Ne.jsx(M,{paragraph:{rows:4,width:"100%"},className:"mb-4"}),Ne.jsxs("div",{className:"grid grid-cols-2 gap-4 mb-4",children:[Ne.jsx(M,{paragraph:{rows:4,width:"100%"}}),Ne.jsx(M,{paragraph:{rows:4,width:"100%"}})]}),Ne.jsxs(U,{children:[Ne.jsx(M.Button,{}),Ne.jsx(M.Button,{})]})]}),k=function(){return b.warning("Revisa los errores del formulario")},E={form:t,autoComplete:"off",initialValues:e.data,onFinish:S,layout:"vertical",onFinishFailed:k};return r(function(){if(e.recuperacionEmergencia){var n=setInterval(function(){if(p){var e=t.getFieldsValue();x.cambiarDatosFormulario(e)}},1e3);return function(){return clearInterval(n)}}},[p]),r(function(){if(v.isReady){I.current=v.query.id;var n=setTimeout(function(){e.soloParaInsertar?m(!0):je(void 0,void 0,void 0,function(){var n,r,o;return ye(this,function(i){switch(i.label){case 0:return n=!1,[4,x.obtenerDataEmergencia()];case 1:return(r=i.sent())?(I.current=r._id,n=!0,[3,4]):[3,2];case 2:return I.current?[4,u.get("".concat(e.endpoint,"/").concat(I.current),{params:e.params})]:[3,4];case 3:r=i.sent().data,i.label=4;case 4:return r?[4,null===(o=e.formatearDataInicial)||void 0===o?void 0:o.call(e,r)]:[3,6];case 5:i.sent(),t.setFieldsValue(r),y.current=r,i.label=6;case 6:return[2,n?e.data:r||e.data]}})}).then(function(n){var r;return Promise.all([x.cambiarHashInicial(n),null===(r=e.onMounted)||void 0===r?void 0:r.call(e)])}).then(function(){return m(!0)})},200);return function(){return clearTimeout(n)}}},[v.query.id,v.isReady]),{form:t,router:v,options:w,tipoEmision:j,objectId:I.current,mainroute:P,isLoading:a,isReady:p,data:y.current,endpoint:e.endpoint,axios:u,onSubmit:S,onMainRouter:function(){return v.push(P)},setIsLoading:l,preventor:x,ModoCarga:N,BotonesPorDefecto:F,onMensajeValidacion:k,getOption:function(e,n){var r,t;return(null===(t=null===(r=w[e])||void 0===r?void 0:r.find(function(e){return e.id===n}))||void 0===t?void 0:t.description)||""},formProps:E}},en=function(e){var r=n(),t=r[0],o=r[1],i=n(!1),a=i[0],l=i[1];return Ne.jsx(B,{title:"Click para confirmar",open:!!t,children:Ne.jsx(R,{loading:a,title:e.title,disabled:e.disabled,danger:!!t,icon:t?Ne.jsx(v,{}):Ne.jsx(h,{}),onClick:function(){return je(void 0,void 0,void 0,function(){var n;return ye(this,function(r){switch(r.label){case 0:return t?[3,1]:(n=setTimeout(function(){return o(void 0)},1500),o(n),[3,3]);case 1:return l(!0),[4,e.onConfirm()];case 2:r.sent(),o(void 0),clearTimeout(t),l(!1),r.label=3;case 3:return[2]}})})}})})},nn=function(e){var r=n(!1),t=r[0],o=r[1],i=d(t&&e.autocompletar?"/api/v4/administrative/clients/nombres-info-adicional":null,function(e){return je(void 0,void 0,void 0,function(){return ye(this,function(n){switch(n.label){case 0:return[4,u.get(e)];case 1:return[2,n.sent().data.map(function(e){return{label:e,value:e}})]}})})}).data,a=void 0===i?[]:i;return Ne.jsx(O.List,{name:e.name,children:function(n,r){return Ne.jsxs("div",{children:[Ne.jsxs("div",{className:"flex items-center justify-between mb-4",children:[Ne.jsx(A.Title,{level:3,className:"mb-0",children:"Información adicional"}),Ne.jsx(R,{type:"dashed",onClick:function(){return r.add({})},children:"Agregar"})]}),Ne.jsxs($,{dataSource:n,rowClassName:"align-top",bordered:!0,pagination:!1,children:[Ne.jsx($.Column,{title:"Nombre",render:function(n){var r=n.name;return Ne.jsx(O.Item,{className:"mb-0",name:[r,"nombre"],rules:[Je.required()],children:e.autocompletar?Ne.jsx(W,{options:a,maxLength:300,placeholder:"Ingresar el nombre",onFocus:function(){return o(!0)}}):Ne.jsx(L,{maxLength:300,placeholder:"Ingresar el nombre"})})}},"name"),Ne.jsx($.Column,{title:"Descripción",render:function(e){var n=e.name;return Ne.jsx(O.Item,{className:"mb-0",name:[n,"valor"],rules:[Je.required()],children:Ne.jsx(L,{placeholder:"Ingresar la descripción"})})}},"description"),Ne.jsx($.Column,{width:1,render:function(e){var n=e.name;return Ne.jsx(en,{title:"¿Eliminar información adicional?",onConfirm:function(){return r.remove(n)}})}},"opciones")]})]})}})},rn=function(e){var r=O.useFormInstance(),t=n([]),o=t[0],i=t[1],l=a(function(){var n=e.rules||[];switch(e.type){case"ruc":return{label:"RUC",placeholder:"Ingresar el RUC",max:13,rules:Ie(Ie([],n,!0),[Je.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:Ie(Ie([],n,!0),[Je.pattern(/^[0-9]{10}$/,"La cédula debe tener 10 caracteres numéricos")],!1)};case"rfc":var r=/^[A-Z&Ñ]{4}[0-9]{2}(0[1-9]|1[012])(0[1-9]|[12][0-9]|3[01])[A-Z0-9]{2}[0-9A]$/,t=void 0,o=13;return"01"===e.subjectType?t="Persona física debe tener 13 caracteres":(e.foreing||(o=12,r=/^[A-Z&Ñ]{3}[0-9]{2}(0[1-9]|1[012])(0[1-9]|[12][0-9]|3[01])[A-Z0-9]{2}[0-9A]$/),t="Persona moral debe tener 12 caracteres"),{label:"RFC",placeholder:"Ingresar el RFC",max:o,rules:Ie(Ie([],n,!0),[Je.pattern(r,t)],!1)};default:return{label:"Nº identificación",placeholder:"Ingresar el número de identificación",rules:n}}},[e.type,e.subjectType,e.foreing]),s=fe(function(n){return je(void 0,void 0,void 0,function(){var r,t;return ye(this,function(a){switch(a.label){case 0:if(!e.campoNombre||n.length<6||!["ci","ruc"].includes(e.type))return 0!==o.length&&i([]),[2];a.label=1;case 1:return a.trys.push([1,3,,4]),[4,u.get("/utils/clientes/buscar",{params:{identificador:n,tipo:"ci"===e.type?"cedula":"ruc"}})];case 2:return r=a.sent().data,i(r.map(function(e){return{value:e.identificador,nombre:e.nombre,label:Ne.jsxs(Ne.Fragment,{children:[Ne.jsx("b",{children:e.identificador}),Ne.jsx("br",{}),e.nombre]})}})),[3,4];case 3:return t=a.sent(),console.error(t),[3,4];case 4:return[2]}})})},500);return Ne.jsx(O.Item,xe({name:e.name,rules:l.rules,normalize:function(e){return e.trim().toUpperCase()},className:e.className,dependencies:e.dependencies},e.hiddenLabel?{}:{label:e.label||l.label},{children:Ne.jsx(W,{options:o,onSelect:function(n,t){r.setFieldValue(e.campoNombre,t.nombre)},onSearch:s,placeholder:e.placeholder||l.placeholder,maxLength:l.max,disabled:e.disabled,onChange:function(n){var r;return null===(r=e.onChange)||void 0===r?void 0:r.call(e,n)}})}))},tn=function(e){var n=e.form,r=O.useWatch("address",n),t=O.useWatch("direcciones",n);return Ne.jsx(O.List,{name:"direcciones",children:function(e,o){return Ne.jsxs("div",{className:"mb-6",children:[Ne.jsxs("div",{className:"flex items-center justify-between",children:[Ne.jsx(A.Title,{level:3,className:"m-0!",children:"Direcciones"}),Ne.jsx(R,{type:"dashed",onClick:function(){return o.add("")},children:"Agregar"})]}),Ne.jsx(X,{itemLayout:"horizontal",dataSource:e,renderItem:function(i){return Ne.jsx(X.Item,{actions:[Ne.jsx(O.Item,{shouldUpdate:function(e,n){return JSON.stringify(e.direcciones)!==JSON.stringify(n.direcciones)},noStyle:!0,children:function(e){var n=e.setFieldValue,o=t[i.name];return Ne.jsx(Y,{checked:o===r,onClick:function(){return n("address",o)},children:"Por defecto"})}},"unico"),Ne.jsx(en,{onConfirm:function(){t[i.name]===r&&n.setFieldValue("address",""),o.remove(i.name)}},"eliminar")],children:Ne.jsx(X.Item.Meta,{description:Ne.jsx(O.Item,{name:i.name,rules:[Je.required()],className:"mb-0",children:Ne.jsx(L,{placeholder:"Ingresar la dirección",onChange:function(r){1===e.length&&n.setFieldValue("address",r.target.value)}})})})})}})]})}})},on=function(){var e=n(!1),r=e[0],t=e[1],o=d(r?"/api/v4/administrative/clients/etiquetas":null,function(e){return je(void 0,void 0,void 0,function(){return ye(this,function(n){switch(n.label){case 0:return[4,u.get(e)];case 1:return[2,n.sent().data.etiquetas]}})})}).data,i=void 0===o?[]:o;return Ne.jsx(O.Item,{name:"etiquetas",label:"Etiqueta",children:Ne.jsx(W,{options:i.map(function(e){return{label:e,value:e}}),placeholder:"Ingresar o seleccionar una etiqueta",onFocus:function(){return t(!0)}})})},an=l(function(e,n){var t,o,i=ce(),l=Xe().hasModule,c=Ze({endpoint:"/api/v3/administrative/"+e.type+"s",soloParaInsertar:!0===e.ocultarBotones,params:{$getAllFields:"true"},data:{id:"",idType:"04",subjectType:"01",direcciones:[],address:"",name:""}}),p=O.useWatch("idType",c.form),m="client"===e.type,f="provider"===e.type,v="transporter"===e.type,h=d("08"===p?"/api/v3/administrative/retenciones-v2/get-options":null,function(e){return je(void 0,void 0,void 0,function(){return ye(this,function(n){switch(n.label){case 0:return[4,u.get(e)];case 1:return[2,n.sent().data.PaisesParaisosFiscales.map(function(e){return{label:e.description,value:parseInt(e.id)}})]}})})}).data,g=a(function(){switch(p){case"04":return"ruc";case"05":return"ci";default:return"other"}},[p]);s(n,function(){return{form:c.form,onSubmit:c.onSubmit}});var b="grid grid-cols-1 md:grid-cols-2 gap-x-6";return r(function(){var n=JSON.parse(JSON.stringify(i.query)),r=n.name,t=n.idType,o=n.identificador;t&&o&&r&&e.type},[i.query]),c.isReady?Ne.jsxs(O,xe({},c.formProps,{layout:"vertical",children:[Ne.jsxs("div",{className:b,children:[Ne.jsx(O.Item,{name:"idType",label:"Tipo de identificación",rules:[Je.required()],children:Ne.jsx(_,{options:null===(t=c.options.TiposDeIdentificacion)||void 0===t?void 0:t.map(function(e){return{label:e.description,value:e.id}})})}),Ne.jsx(rn,{name:"id",campoNombre:"name",type:g,rules:[Je.required()]}),Ne.jsx(O.Item,{name:"name",label:"Nombres / Razón social",rules:[Je.required()],children:Ne.jsx(L,{placeholder:"Ingresar la razón social"})}),Ne.jsx(O.Item,{name:"subjectType",label:"Tipo de sujeto",rules:[Je.required()],children:Ne.jsx(_,{options:null===(o=c.options.TiposDePersona)||void 0===o?void 0:o.map(function(e){return{label:e.description,value:e.id}})})}),Ne.jsx(O.Item,{name:"phone",label:"Télefono 1",children:Ne.jsx(L,{type:"phone",placeholder:"Ingresar el teléfono 1"})}),m?Ne.jsx(O.Item,{name:"cellphone",label:"Télefono 2",children:Ne.jsx(L,{type:"phone",placeholder:"Ingresar el teléfono 2"})}):null,Ne.jsx(O.Item,{name:"email",label:"Correo electrónico",rules:[Je.email()],normalize:function(e){return e.trim()},children:Ne.jsx(L,{placeholder:"Ingresar el correo electrónico"})}),!v&&Ne.jsx(O.Item,{name:"optionalEmail",label:"Correos electrónicos alternativos",rules:[Je.correos()],children:Ne.jsx(_,{mode:"tags",placeholder:"Ingresar uno o varios correos alternativos",open:!1,suffixIcon:null})})]}),Ne.jsx(O.Item,{name:"address",className:"hidden",children:Ne.jsx(L,{})}),!v&&Ne.jsx(tn,{form:c.form}),Ne.jsx(A.Title,{level:3,children:"Otra información"}),Ne.jsxs("div",{className:b,children:[m&&l("treasury")?Ne.jsxs(Ne.Fragment,{children:[Ne.jsx(O.Item,{name:"creditQuotaDollars",label:"Cupo de crédito en dólares",children:Ne.jsx(z,{className:"w-full",precision:2,min:0,placeholder:"Ingresar el cupo de crédito en dólares"})}),Ne.jsx(O.Item,{name:"creditQuotaDays",label:"Cupo de crédito en días",children:Ne.jsx(z,{className:"w-full",precision:0,min:0,placeholder:"Ingresar el cupo de crédito en días"})})]}):null,f&&l("contability")&&Ne.jsx(cn,{name:"accountingAccount",type:"cuentas-contables"}),f&&l("treasury")&&Ne.jsx(O.Item,{name:"diasPlazo",label:"Días plazo",children:Ne.jsx(z,{className:"w-full",precision:0,min:0,placeholder:"Ingresar los días plazo"})}),v?Ne.jsx(O.Item,{name:"licensePlate",label:"Placa",rules:[Je.required()],children:Ne.jsx(_,{mode:"tags",placeholder:"Ingresar una o varias placas",open:!1,suffixIcon:null})}):null,m?Ne.jsxs(Ne.Fragment,{children:[Ne.jsx(cn,{name:"vendedor",type:"sellers"}),Ne.jsx(O.Item,{name:"descuento",label:"Descuento adicional para facturas (%)",children:Ne.jsx(z,{className:"w-full",precision:2,max:100,suffix:"%",placeholder:"Ingresar el descuento"})}),"08"===p?Ne.jsx(O.Item,{name:"paisExportacion",label:"País de exportación",children:Ne.jsx(_,{allowClear:!0,showSearch:!0,placeholder:"Seleccionar el país de exportación",optionFilterProp:"children",filterOption:function(e,n){var r;return(null!==(r=null==n?void 0:n.label)&&void 0!==r?r:"").toLowerCase().includes(e.toLowerCase())},options:h})}):null,Ne.jsx(on,{})]}):null]}),Ne.jsx("div",{className:"mb-5",children:Ne.jsx(nn,{name:"informacionAdicional",autocompletar:!0})}),e.ocultarBotones?null:c.BotonesPorDefecto]})):c.ModoCarga}),ln=function(e){var n=i(e.options),r=a(function(){return function(e){switch(e.tipo){case"mesas":return{label:"Mesa",endpoint:"/api/v4/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:"/api/v4/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:"/api/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:"/api/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},modal:{title:"Clientes",getTexto:function(e){return e.name},componente:function(e){return Ne.jsx(an,{ref:e.ref,type:"client",ocultarBotones:!0})}}}}}({tipo:e.tipo})},[e.tipo]),t=d(r.withOptions&&!e.options?r.endpoint+"/get-options":null,function(e){return je(void 0,void 0,void 0,function(){return ye(this,function(n){switch(n.label){case 0:return[4,u.get(e)];case 1:return[2,n.sent().data]}})})},{revalidateOnFocus:!1}).data;return t&&(n.current=t),r},sn=function(e){var t=Oe().message,o=Xe().getPermisos,l=e.fieldValue||e.values.customDocumentId||"_id",s=n(!1),c=s[0],p=s[1],m=n(),f=m[0],v=m[1],h=n(!1),x=h[0],j=h[1],y=n(!1),I=y[0],C=y[1],w=i(!1),P=n(""),S=P[0],F=P[1],N=i(null),k=!0===e.canCreate&&!!e.values.modal;r(function(){var n,r;if(e.documentoPorDefecto){var t=Ve(e.documentoPorDefecto,l);null===(n=e.onChange)||void 0===n||n.call(e,t),null===(r=e.onChangeDocumentoPorDefecto)||void 0===r||r.call(e,void 0)}},[e.documentoPorDefecto]);var E=a(function(){var n,r=new URLSearchParams(xe(xe(xe({limit:"50"},e.values.params),e.params),e.value?(n={},n[l]=e.value,n):S?{q:S}:{})).toString();return r?"?"+r:""},[e.value,S,e.params]),T=d(c?e.values.endpoint+E:null,function(e){return je(void 0,void 0,void 0,function(){return ye(this,function(n){switch(n.label){case 0:return[4,u.get(e)];case 1:return[2,n.sent().data.data]}})})},{keepPreviousData:!0}),R=T.data,O=void 0===R?[]:R,_=T.isLoading;T.mutate;var q=a(function(){switch(e.type){case"clients":case"clients-mx":case"products-services":case"products":case"providers":case"cuentas-contables-mx":case"transporters":return o("/administrative/".concat(e.type))}},[e.type]);r(function(){if(!U&&void 0!==f){var e=setTimeout(function(){F(f),p(!0)},500);return function(){return clearTimeout(e)}}},[f]);var V=a(function(){return O.map(function(n){var r,t,o=Ve(n,l),i=e.values.title(n),a=null===(t=(r=e.values).subtitle)||void 0===t?void 0:t.call(r,n);return{key:o,value:o,texto:a,item:n,label:Ne.jsxs("div",{children:[Ne.jsxs("div",{children:[Ne.jsx("b",{className:"mr-1",children:i}),e.value===o?Ne.jsx(g,{twoToneColor:"#52c41a"}):void 0]}),a?Ne.jsx("div",{className:"text-wrap",children:a}):null]})}})||[]},[e.value,O]),U=a(function(){if(e.value)return O.find(function(n){return Ve(n,l)===e.value})},[e.value,O]),M=a(function(){return!0===_?Ne.jsx(b,{}):U&&!e.llenarCuandoTipea?Ne.jsx(g,{twoToneColor:"#52c41a"}):Ne.jsx("span",{})},[_,U,e.llenarCuandoTipea]);return r(function(){e.value&&p(!0)},[e.value]),r(function(){var n;if(U){var r=Ve(U,e.values.field),t=null===(n=e.values.formItemTexto||e.values.subtitle)||void 0===n?void 0:n(U);e.onSetTextoExtra(t||""),v(r),p(!1)}else e.onSetTextoExtra("");var o=function(){var n,r;null===(n=e.onSelect)||void 0===n||n.call(e,U||null),null===(r=e.onChangeDocumentoPorDefecto)||void 0===r||r.call(e,U||null)};(w.current||e.ejecutarSelect)&&o()},[U]),Ne.jsxs(Ne.Fragment,{children:[k?Ne.jsx(D,{title:e.values.modal.title,open:x,width:720,zIndex:1100,maskClosable:!1,styles:{body:{padding:0}},confirmLoading:I,onOk:function(){return je(void 0,void 0,void 0,function(){var n,r,o,i,a,l;return ye(this,function(s){switch(s.label){case 0:n=N.current,r=n.form,o=n.onSubmit,s.label=1;case 1:return s.trys.push([1,3,,4]),[4,r.validateFields()];case 2:return s.sent(),[3,4];case 3:return s.sent(),[2,t.warning("Revisa los errores del formulario")];case 4:return C(!0),i=r.getFieldsValue(),[4,o(i,{noRedirect:!0})];case 5:return a=s.sent(),C(!1),a?(r.resetFields(),null===(l=e.onChange)||void 0===l||l.call(e,a._id),j(!1),[2]):[2]}})})},onCancel:function(){return j(!1)},children:e.values.modal.componente({ref:N})}):null,Ne.jsx(W,{options:V,allowClear:e.allowClear,value:f,popupRender:function(e){return Ne.jsxs(Ne.Fragment,{children:[k&&(null==q?void 0:q.escribir)?Ne.jsxs(Ne.Fragment,{children:[Ne.jsx(A.Link,{className:"block px-3 py-1",onClick:function(){j(!0)},children:"Añadir nuevo"}),Ne.jsx(H,{className:"m-0!"})]}):null,e]})},notFoundContent:"Sin resultados",disabled:e.disabled,onFocus:function(){e.value||p(!0)},onSelect:function(n){var r;w.current=!0,p(!1),null===(r=e.onChange)||void 0===r||r.call(e,n)},onSearch:function(n){var r,t;e.llenarCuandoTipea?null===(r=e.onChange)||void 0===r||r.call(e,n):e.value&&(null===(t=e.onChange)||void 0===t||t.call(e,null)),v(n)},children:Ne.jsx(L,{placeholder:e.values.placeholder,suffix:M})})]})};sn.displayName="BuscadorSeeker";var cn=function(e){var r=n(""),t=r[0],o=r[1],i=(e._useSeekerHook||ln)({tipo:e.type,options:void 0,configs:e.configs,params:e.params});return i?Ne.jsx(O.Item,{name:e.name,label:null===e.label?void 0:e.label||i.label,extra:e.hideMessage?void 0:t,rules:e.required?[Je.required()]:[{}],className:e.classNameFormItem,children:Ne.jsx(sn,{type:e.type,canCreate:e.canCreate,values:i,params:e.params,onSetTextoExtra:function(n){e.hideMessage||o(n)},onSelect:e.onSelect,llenarCuandoTipea:e.llenarCuandoTipea,disabled:e.disabled,cuerpoCrear:e.cuerpoCrear,initialValue:e.initialValue,allowClear:e.allowClear})}):null};cn.displayName="Seeker";var un=function(e){var r=e.options,t=n([]),o=t[0],i=t[1],a=[Je.required()],l=O.useFormInstance(),s=O.useWatch("banks",l),c=function(e){var n,t=null===(n=r.Bancos)||void 0===n?void 0:n.filter(function(n){var r=n.id.toLowerCase().includes(e.toLowerCase()),t=n.description.toLowerCase().includes(e.toLowerCase());return r||t});i(t)};return Ne.jsx(O.List,{name:"banks",children:function(e,n){return Ne.jsxs(Ne.Fragment,{children:[Ne.jsx("div",{className:"flex items-center justify-end mb-6",children:Ne.jsx(R,{type:"dashed",onClick:function(){return n.add({tipoCuenta:"nacional"})},children:"Agregar"})}),Ne.jsxs($,{pagination:!1,className:"mb-6",dataSource:e,bordered:!0,rowClassName:"align-top",children:[Ne.jsx($.Column,{title:"Tipo de cuenta",render:function(e,n){var r=n.name;return Ne.jsx(O.Item,{name:[r,"tipoCuenta"],rules:a,children:Ne.jsxs(_,{onSelect:function(e){"nacional"===e&&l.setFieldValue(["banks",r,"nombreBancoExt"],void 0)},children:[Ne.jsx(_.Option,{value:"extranjera",children:"Cuenta extranjera"}),Ne.jsx(_.Option,{value:"nacional",children:"Cuenta nacional"})]})})}},"tipoCuenta"),Ne.jsx($.Column,{title:"RFC banco",render:function(e,n){var r=n.name;return Ne.jsx(O.Item,{name:[r,"rfcBanco"],rules:a,children:Ne.jsx(W,{onSearch:c,style:{width:200},onSelect:function(e){if(e){var n=o.find(function(n){return n.id===e});n&&l.setFieldValue(["banks",r,"nombreCuenta"],n.description)}},placeholder:"Ingrese el rfc del banco",children:o.map(function(e,n){return Ne.jsx(_.Option,{value:e.id,children:e.description},n)})})})}},"rfcBanco"),Ne.jsx($.Column,{title:"Nombre cuenta",render:function(e,n){var r=n.name;return Ne.jsx(O.Item,{name:[r,"nombreCuenta"],rules:a,children:Ne.jsx(L,{placeholder:"Ingrese el nombre de la cuenta bancaria"})})}},"nombreCuenta"),Ne.jsx($.Column,{title:"N° de cuenta",render:function(e,n){var r=n.name;return Ne.jsx(O.Item,{name:[r,"cuentaBancaria"],rules:a,children:Ne.jsx(L,{placeholder:"Ingrese el número de cuenta bancaria"})})}},"cuentaBancaria"),Ne.jsx($.Column,{title:"Nombre banco ext.",render:function(e,n){var r=n.name;return s&&"extranjera"===s[r].tipoCuenta?Ne.jsx(O.Item,{name:[r,"nombreBancoExt"],rules:a,children:Ne.jsx(L,{placeholder:"Ingrese cuenta bancaria"})}):"No aplica"}},"nombreBancoExt"),Ne.jsx($.Column,{align:"center",render:function(e,r){var t=r.name;return Ne.jsx(J,{title:"¿Eliminar cuenta?",onConfirm:function(){return n.remove(t)},children:Ne.jsx(h,{title:"Eliminar cuenta"})})}},"opciones")]})]})}})},dn=function(e){var n=O.useWatch(e.nameComplete,e.form),r=a(function(){return e.form.getFieldValue(e.nameComplete)},[n]),t=a(function(){var n=e.form.getFieldValue(e.nameComplete);return!["MEX","USA","CAN"].includes(null==n?void 0:n.Pais)},[r]);return Ne.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-x-6",children:[Ne.jsx(O.Item,{name:Ie(Ie([],e.name,!0),["Calle"],!1),label:"Calle",rules:e.street?[Je.required()]:[],children:Ne.jsx(L,{placeholder:"Ingrese la calle"})}),Ne.jsx(O.Item,{name:Ie(Ie([],e.name,!0),["NumExterior"],!1),label:"Num. Exterior",children:Ne.jsx(L,{placeholder:"Ingrese el número"})}),Ne.jsx(O.Item,{name:Ie(Ie([],e.name,!0),["NumInterior"],!1),label:"Num. Interior",children:Ne.jsx(L,{placeholder:"Ingrese el número"})}),Ne.jsx(Cn,{name:Ie(Ie([],e.name,!0),["Pais"],!1),onSelect:function(){return n=e.form.getFieldValue(e.nameComplete),void e.form.setFieldValue(e.nameComplete,xe(xe({},n),{CodigoPostal:void 0,Estado:void 0,Municipio:void 0,Localidad:void 0,Colonia:void 0}));var n},llenarCuandoTipea:!0,type:"paises",required:!0}),"MEX"===(null==r?void 0:r.Pais)?Ne.jsx(Cn,{name:Ie(Ie([],e.name,!0),["CodigoPostal"],!1),type:"codigo-postal",required:!0,onSelect:function(n){return r=n,void((t=e.form.getFieldValue(e.nameComplete)||{})&&e.form.setFieldValue(e.nameComplete,xe(xe({},t),{Estado:null==r?void 0:r.cEstado,Municipio:null==r?void 0:r.cMunicipio,Localidad:null==r?void 0:r.cLocalidad})));var r,t}}):Ne.jsx(O.Item,{name:Ie(Ie([],e.name,!0),["CodigoPostal"],!1),label:"Código postal",rules:[Je.required()],children:Ne.jsx(L,{placeholder:"Ingrese el código postal"})}),"MEX"===(null==r?void 0:r.Pais)?Ne.jsx(Cn,{name:Ie(Ie([],e.name,!0),["Colonia"],!1),type:"colonias",params:{cCodigoPostal:(null==r?void 0:r.CodigoPostal)||"inexistente"},llenarCuandoTipea:!0,required:!1}):Ne.jsx(O.Item,{name:Ie(Ie([],e.name,!0),["Colonia"],!1),label:"Colonia",children:Ne.jsx(L,{placeholder:"Ingrese el código de la colonia"})}),"MEX"===(null==r?void 0:r.Pais)?Ne.jsx(Cn,{name:Ie(Ie([],e.name,!0),["Localidad"],!1),type:"localidades",params:{cEstado:(null==r?void 0:r.Estado)||"sin-estado"},llenarCuandoTipea:!0,required:!1}):Ne.jsx(O.Item,{name:Ie(Ie([],e.name,!0),["Localidad"],!1),label:"Localidad",children:Ne.jsx(L,{placeholder:"Ingrese el código de la localidad"})}),"MEX"===(null==r?void 0:r.Pais)?Ne.jsx(Cn,{name:Ie(Ie([],e.name,!0),["Municipio"],!1),type:"municipios",params:{cEstado:(null==r?void 0:r.Estado)||"sin-estado"},required:!1}):Ne.jsx(O.Item,{name:Ie(Ie([],e.name,!0),["Municipio"],!1),label:"Municipio",children:Ne.jsx(L,{placeholder:"Ingrese el código del municipio"})}),t?Ne.jsx(O.Item,{name:Ie(Ie([],e.name,!0),["Estado"],!1),rules:[Je.required()],label:"Estado",children:Ne.jsx(L,{placeholder:"Ingrese el código del estado"})}):Ne.jsx(Cn,{name:Ie(Ie([],e.name,!0),["Estado"],!1),params:{cPais:(null==r?void 0:r.Pais)||"sin-pais"},required:!0,type:"estados"}),Ne.jsx(O.Item,{name:Ie(Ie([],e.name,!0),["Referencia"],!1),label:"Referencia",children:Ne.jsx(L,{placeholder:"Referencia geográfica adicional"})})]})},pn=function(e){return{isActual:e,IDUbicacion:void 0,Calle:void 0,NumExterior:void 0,NumInterior:void 0,Pais:"MEX",Estado:void 0,Municipio:void 0,Localidad:void 0,Colonia:void 0,CodigoPostal:void 0,Referencia:void 0}},mn=function(e){var t=e.form,o=e.name,i=e.cartaPorte,a=void 0!==i&&i,l=e.newClient,s=e.onSelectDomicilio,c=n([]),u=c[0],d=c[1],p=O.useWatch(o,t)||[];r(function(){a||0!==(p||[]).length||(t.setFieldValue(o,[pn(!0)]),d(["direcciones0"]));var e=p.findIndex(function(e){return!!e.isActual});-1!==e&&d(["direcciones"+e])},[]);return Ne.jsx(Ne.Fragment,{children:Ne.jsx(O.List,{name:o,children:function(e,n){var r,i;return Ne.jsxs(Ne.Fragment,{children:[Ne.jsx("div",{className:"flex justify-end mb-5",children:l&&0===(null===(r=p||[])||void 0===r?void 0:r.length)||!l&&Ne.jsx(R,{type:"link",onClick:function(){if(n.add(pn()),1===t.getFieldValue(o).length){var e=t.getFieldValue(o);e[0].isActual=!0,t.setFieldValue(o,e)}d(["direcciones"+p.length])},children:"Agregar"})}),0===(null===(i=p||[])||void 0===i?void 0:i.length)?Ne.jsx(Z,{description:"No hay ubicaciones"}):Ne.jsx(ee,{activeKey:u,onChange:function(e){return d(e)},items:e.map(function(e){var r,i;return{key:"direcciones"+e.key,label:Ne.jsx("div",{className:"flex justify-between",children:Ne.jsx(A.Text,{children:"Ubicación "+((null===(r=p[e.name])||void 0===r?void 0:r.IDUbicacion)||l?null===(i=p[e.name])||void 0===i?void 0:i.IDUbicacion:"sin nombre")})}),extra:Ne.jsx(Ne.Fragment,{children:l?void 0:Ne.jsxs(Ne.Fragment,{children:[e.name!==t.getFieldValue(o).findIndex(function(e){return!0===e.isActual})?Ne.jsx(ne,{color:"default",onClick:function(n){var r;n.stopPropagation(),r=e.name,p.forEach(function(e){e.isActual=!1}),p[r].isActual=!0,t.setFieldValue(o,p)},children:"Usar por defecto"}):Ne.jsx(ne,{color:"success",children:"Por defecto"}),a?Ne.jsx(R,{type:"link",onClick:function(n){n.stopPropagation(),s&&s(e.name)},children:"Seleccionar"}):Ne.jsx(J,{title:"¿Eliminar registro?",onConfirm:function(){return n.remove(e.name)},children:Ne.jsx(h,{onClick:function(e){e.stopPropagation()}})})]})}),children:Ne.jsx(dn,{name:[e.name],form:t,nameComplete:[o,e.name]})}})})]})}})})},fn=function(e){var t=n(!1),o=t[0],i=t[1],a=n(""),l=a[0],s=a[1];return r(function(){i(e.visible),s("601"===e.codigo?"General de ley personas morales":"Personas físicas con actividades empresariales y profesionales")},[e.visible]),Ne.jsx(Ne.Fragment,{children:Ne.jsxs(D,{title:"Campos establecidos por defecto",centered:!0,closable:!1,width:600,open:o,onOk:function(){e.respuesta(!1),i(!1)},footer:[Ne.jsx(R,{type:"primary",onClick:function(){e.respuesta(!1)},children:"Aceptar"},"submit")],children:[Ne.jsxs("p",{children:["Régimen Fiscal:"," ",Ne.jsxs("span",{className:"font-bold",children:[e.codigo," - ",l]})]}),Ne.jsxs("p",{children:["USO DE CFDI: ",Ne.jsx("span",{className:"font-bold",children:"G03 - Gastos generales"})]})]})})},vn=l(function(e,t){var o,i=Ze({endpoint:"/api/v3/administrative/clients-mx",params:{estado:"activo",fields:"rfc name tipo phone RegimenFiscalReceptor emails address usoCFDI subjectType estado banks accountingAccount accountingAccountGastos seller"},data:{usoCFDI:void 0,RegimenFiscalReceptor:"612",subjectType:"01",address:[],banks:[],tipo:["cliente"],rfc:void 0},soloParaInsertar:!0===e.ocultarBotones}),l=Xe().hasModule,c=n(void 0),u=c[0];c[1];var d=n("direcciones"),p=d[0],m=d[1],f=O.useWatch("tipo",i.form),v=O.useWatch("subjectType",i.form),h=O.useWatch("esExtranjero",i.form),g=O.useWatch("RegimenFiscalReceptor",i.form),b=null!=g?g:i.data.RegimenFiscalReceptor,x=a(function(){var e,n,r=null===(e=i.options.RegimenFiscales)||void 0===e?void 0:e.filter(function(e){return e.id===b}),t=null===(n=i.options.UsosDeCFDI)||void 0===n?void 0:n.filter(function(e){var n;return null===(n=null==r?void 0:r[0].usosCfdis)||void 0===n?void 0:n.includes(e.id)});return t},[b,i.options.RegimenFiscales,i.options.UsosDeCFDI]),j=a(function(){var e;return null===(e=i.options.RegimenFiscales)||void 0===e?void 0:e.filter(function(e){var n="01"===v?"fisica":"moral";return"ambos"===e.stringValue||e.stringValue===n})},[v,i]);r(function(){var n,r;if("client"===e.type?i.form.setFieldValue("tipo",["cliente"]):"provider"===e.type&&i.form.setFieldValue("tipo",["proveedor"]),setTimeout(function(){var e=i.form.getFieldsValue();"XEXX010101000"===(null==e?void 0:e.rfc)&&i.form.setFieldValue("esExtranjero",!0)},300),u){var t=u,o=t.rfc,a=i.form.getFieldValue("rfc"),l=window.location.pathname.split("/")[3];if(o!==a&&"insert"!==l)return void G.error("La constancia que desea cargar, no corresponde al RFC actual");t.address&&null!==t.address[0]&&i.form.setFieldValue(["address",0,"CodigoPostal"],t.address[0].CodigoPostal),t.emails=null===(n=t.emails)||void 0===n?void 0:n.filter(function(e){return e}),F("01"===t.subjectType?"612":"601");var s=i.form.getFieldsValue();Object.assign(s,u),s.address&&(s.address[0].Pais=(null===(r=null==s?void 0:s.address[0])||void 0===r?void 0:r.CodigoPostal)?"MEX":void 0),i.form.setFieldsValue(s),i.form.setFieldValue("RegimenFiscalReceptor","01"===t.subjectType?"612":"601"),w(!0)}},[u]),s(t,function(){return{form:i.form,onSubmit:i.onSubmit}});var y={className:!1!==e.bordered?"mb-6":"",variant:!1!==e.bordered?"outlined":"borderless"},I=n(!1),C=I[0],w=I[1],P=n(""),S=P[0],F=P[1],N="grid grid-cols-2 md:grid-cols-3 gap-x-6";return Ne.jsxs(Ne.Fragment,{children:[Ne.jsxs(O,{form:i.form,layout:"vertical",initialValues:i.data,onFinish:i.onSubmit,children:[Ne.jsxs(Q,xe({},y,{children:[Ne.jsxs("div",{className:N,children:[Ne.jsx(O.Item,{name:"subjectType",label:"Tipo de persona",rules:[Je.required()],children:Ne.jsx(_,{placeholder:"Escoja una de las opciones",options:null===(o=i.options.TiposDePersona)||void 0===o?void 0:o.map(function(e){return{label:e.description,value:e.id}}),onChange:function(){i.form.setFieldValue("RegimenFiscalReceptor",void 0),i.form.setFieldValue("usoCFDI",void 0)}})}),Ne.jsx(rn,{name:"rfc",type:"rfc",subjectType:v,foreing:h,rules:[Je.required()]}),Ne.jsx(O.Item,{name:"name",label:"Nombres / Razón social",rules:[Je.required()],normalize:function(e){return e.toUpperCase()},children:Ne.jsx(L,{placeholder:"Ingrese la razón social"})}),h?Ne.jsx(O.Item,{name:"numRegIdTrib",label:"Número registro tributario",children:Ne.jsx(L,{placeholder:"Ingrese el número de registro tributario"})}):null,Ne.jsx(O.Item,{name:"RegimenFiscalReceptor",label:"Régimen fiscal",rules:[Je.required()],children:Ne.jsx(_,{placeholder:"Escoja una de las opciones",allowClear:!0,options:null==j?void 0:j.map(function(e){return{label:"".concat(e.id," - ").concat(e.description),value:e.id}}),onChange:function(){i.form.setFieldValue("usoCFDI",void 0)}})}),Ne.jsx(O.Item,{name:"usoCFDI",label:"Uso CFDI",rules:[Je.required()],children:Ne.jsx(_,{placeholder:"Escoja una de las opciones",options:null==x?void 0:x.map(function(e){return{label:"".concat(e.id," - ").concat(e.description),value:e.id}})})}),Ne.jsx(O.Item,{name:"phone",label:"Teléfono",children:Ne.jsx(L,{placeholder:"Ingrese el teléfono"})}),Ne.jsx(Cn,{name:"seller",type:"sellers"})]}),Ne.jsxs("div",{className:"flex",children:[Ne.jsx(O.Item,{name:"tipo",children:Ne.jsxs(K.Group,{children:[Ne.jsx(K,{value:"cliente",style:{lineHeight:"32px"},onChange:function(e){(null==e?void 0:e.target.checked)||i.form.setFieldValue("accountingAccount",null)},children:"Es cliente"}),Ne.jsx(K,{value:"proveedor",style:{lineHeight:"32px"},onChange:function(e){(null==e?void 0:e.target.checked)||i.form.setFieldValue("accountingAccountGastos",null)},children:"Es proveedor"})]})}),Ne.jsx(O.Item,{name:"esExtranjero",valuePropName:"checked",children:Ne.jsx(K,{style:{lineHeight:"32px"},onChange:function(e){return function(e){i.form.setFieldValue("rfc",e?"XEXX010101000":""),i.form.setFieldValue("RegimenFiscalReceptor",e?"616":"601"),i.form.setFieldValue("usoCFDI",e?"S01":"G03"),setTimeout(function(){i.form.validateFields(["rfc"])},500)}(e.target.checked)},children:"Es extranjero"})})]}),Ne.jsx(O.Item,{name:"emails",label:"Correos electrónicos",children:Ne.jsx(_,{mode:"tags",placeholder:"Ingrese un correo electrónico"})})]})),Ne.jsxs(Q,xe({tabList:Ie([{key:"direcciones",tab:"Ubicaciones"},{key:"cuentas",tab:"Cuentas bancarias"}],l("contabilidad-mx")?[{key:"other",tab:"Info. Contable"}]:[],!0)},y,{activeTabKey:p,onTabChange:function(e){return m(e)},children:[Ne.jsx("div",{className:"direcciones"===p?"":"hidden",children:Ne.jsx(mn,{form:i.form,name:"address"})}),Ne.jsx("div",{className:"cuentas"===p?"":"hidden",children:Ne.jsx(un,{options:i.options})}),Ne.jsx("div",{className:"other"===p&&l("contabilidad-mx")?"":"hidden",children:Ne.jsxs("div",{className:N,children:[(null==f?void 0:f.includes("cliente"))&&Ne.jsx(Cn,{name:"accountingAccount",type:"cuentas-contables-mx",label:"Cuenta contable de ingresos"}),(null==f?void 0:f.includes("proveedor"))&&Ne.jsx(Cn,{name:"accountingAccountGastos",type:"cuentas-contables-mx",label:"Cuenta contable de gastos"})]})})]})),e.ocultarBotones?null:i.BotonesPorDefecto]}),Ne.jsx(fn,{visible:C,respuesta:function(e){w(e)},codigo:S})]})}),hn=function(e){var n,r,t,o,i,a,l,s,c,u,d=O.useWatch("cuentaMayor",e.form);return Ne.jsxs(Ne.Fragment,{children:[Ne.jsx(O.Item,{name:"codigo",label:"Código",rules:[Je.required(),Je.pattern(/[^.|_|-]$/,"El código no puede terminar en punto o guión")],children:Ne.jsx(L,{placeholder:"Ingrese el código de la cuenta"})}),Ne.jsx(O.Item,{name:"nombre",label:"Nombre",rules:[Je.required()],children:Ne.jsx(L,{placeholder:"Ingrese el nombre de la cuenta"})}),Ne.jsx(O.Item,{name:"codigoAgrupador",label:"Código agrupador (SAT)",children:Ne.jsx(_,{showSearch:!0,options:null===(r=null===(n=e.options)||void 0===n?void 0:n.CodigosSAT)||void 0===r?void 0:r.map(function(e){return{label:"".concat(e.id," - ").concat(e.description),value:e.id}}),placeholder:"Seleccione el código agrupador",optionFilterProp:"description",filterOption:function(e,n){return n.value.includes(e)}})}),Ne.jsx(O.Item,{name:"naturaleza",label:"Tipo de cuenta",rules:[Je.required()],children:Ne.jsx(_,{options:null===(o=null===(t=e.options)||void 0===t?void 0:t.Naturaleza)||void 0===o?void 0:o.map(function(e){return{label:e.description,value:e.id}}),placeholder:"Seleccione el tipo de cuenta"})}),Ne.jsx(O.Item,{name:"cuentaMayor",label:"Cuenta de mayor",rules:[Je.required()],children:Ne.jsx(_,{options:null===(a=null===(i=e.options)||void 0===i?void 0:i.CuentaMayor)||void 0===a?void 0:a.map(function(e){return{label:e.description,value:e.id}}),placeholder:"Seleccione una de las opciones"})}),Ne.jsx(O.Item,{name:"moneda",label:"Moneda",rules:[Je.required()],children:Ne.jsx(_,{options:null===(s=null===(l=e.options)||void 0===l?void 0:l.Monedas)||void 0===s?void 0:s.map(function(e){return{label:e.description,value:e.id}}),placeholder:"Seleccione la moneda"})}),Ne.jsx(O.Item,{name:"estado",label:"Estado",rules:[Je.required()],children:Ne.jsxs(_,{children:[Ne.jsx(_.Option,{value:"activo",children:"Activo"}),Ne.jsx(_.Option,{value:"inactivo",children:"Inactivo"})]})}),"2"===d?Ne.jsx(O.Item,{name:"auxiliar",label:"Auxiliar",tooltip:"Asegurese de alimentar la base de datos clientes, productos y proveedores.",children:Ne.jsx(_,{options:null===(u=null===(c=e.options)||void 0===c?void 0:c.Auxiliares)||void 0===u?void 0:u.map(function(e){return{label:e.description,value:e.id}}),placeholder:"Seleccione un auxiliar"})}):null]})},gn=l(function(e,n){var r=Ze({endpoint:"/api/v3/contability/cuentas-contables",params:{$getAllFields:"true"},data:{codigo:"",moneda:"MXN",estado:"activo"},soloParaInsertar:!0===e.ocultarBotones});return s(n,function(){return{form:r.form,onSubmit:r.onSubmit}}),Ne.jsxs(O,{form:r.form,layout:"vertical",autoComplete:"off",initialValues:r.data,onFinish:r.onSubmit,onValuesChange:function(e,n){return r.preventor.cambiarDatosFormulario(n)},children:[Ne.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-x-6",children:Ne.jsx(hn,{options:r.options,form:r.form})}),e.ocultarBotones?null:r.BotonesPorDefecto]})}),bn=function(e){var n,r,t=e.form,o=null!==(n=O.useWatch(e.name,t))&&void 0!==n?n:null;return Ne.jsxs("div",{className:"flex items-center mb-3",children:[Ne.jsx(K,{checked:null!==o,className:"basis-36",onChange:function(n){return t.setFieldValue(e.name,n.target.checked?"":null)},children:e.label}),Ne.jsx(O.Item,{className:"m-0 p-0 basis-full",name:e.name,children:Ne.jsx(_,{placeholder:"Seleccione un valor",disabled:null===o,options:null===(r=e.options)||void 0===r?void 0:r.map(function(e){return{label:"".concat(e.description," - ").concat(e.value),value:e.value}})})})]})},xn=function(e){var n=Xe().business;return Ne.jsx(O.List,{name:"relaciones",children:function(r,t){return Ne.jsxs(Ne.Fragment,{children:[Ne.jsx("div",{className:"flex items-center justify-end mb-6",children:Ne.jsx(R,{type:"dashed",onClick:function(){return t.add({cantidad:1,precio:0})},children:"Agregar relación"})}),Ne.jsxs($,{dataSource:r,rowClassName:"align-top",children:[Ne.jsx($.Column,{title:"Nombre",render:function(n){var r=n.name;return Ne.jsx(Cn,{classNameFormItem:"m-0 p-0",name:[r,"producto"],label:null,params:{tipoProducto:"producto"},type:"products-services",onSelect:function(n){return function(n,r){var t,o;void 0===n&&(n={});var i=e.form.getFieldValue("relaciones");i[r].producto&&n&&(i[r].nota=n.description,null!==(t=(o=i[r]).cantidad)&&void 0!==t||(o.cantidad=1),i[r].precio=n.price,i[r].type=n.type,e.form.setFieldValue("relaciones",i))}(n,r)}})}},"name"),Ne.jsx($.Column,{title:"Nota",render:function(e){var n=e.name;return Ne.jsx(O.Item,{className:"m-0 p-0",name:[n,"nota"],rules:[Je.required()],children:Ne.jsx(L,{placeholder:"Ingresar una nota"})})}},"nota"),Ne.jsx($.Column,{title:"Cantidad",render:function(e){var r,t=e.name;return Ne.jsx(O.Item,{className:"m-0 p-0",name:[t,"cantidad"],rules:[Je.required()],children:Ne.jsx(z,{placeholder:"Ingresar la cantidad",min:1e-6,precision:(null===(r=null==n?void 0:n.configs)||void 0===r?void 0:r.nDecimals)||2})})}},"cantidad"),Ne.jsx($.Column,{title:"Costo",render:function(e){var n=e.name;return Ne.jsx(O.Item,{className:"m-0 p-0",name:[n,"precio"],rules:[Je.required()],children:Ne.jsx(z,{className:"w-full",disabled:!0,placeholder:"precio",formatter:function(e){return"$ ".concat(e)}})})}},"precio"),Ne.jsx($.Column,{align:"center",render:function(e){var n=e.name;return Ne.jsx(R,{title:"¿Eliminar relación?",icon:Ne.jsx(h,{}),onClick:function(){return t.remove(n)}})}},"opciones")]})]})}})},jn=function(e){var n=Xe().business,r=e.form,t=O.useWatch("price",r),o=O.useWatch("iva",r),i=O.useWatch("ieps",r);O.useWatch("ice",r),O.useWatch("icePercentage",r),O.useWatch("irbpnr",r);var a,l=O.useWatch("descuento",r),s=function(r,t,a){var s;void 0===a&&(a=!0);var c=1;i&&(c+=i);var u=null===(s=e.options.PorcentajesDeIVA)||void 0===s?void 0:s.find(function(e){return e.id===o});return c*=1+((null==u?void 0:u.value)||0),a&&(c*=1-(l||0)/100),Be("final"===t?r*c:r/c,null==n?void 0:n.configs.nDecimals)},c=s(t||0,"final",!1),u=s(t||0,"final"),d=fe(function(e,n){void 0===n&&(n=!0),r.setFieldValue("price",s(e||0,"base",n))},1e3),p=function(e){if(!e)return"";var n=String(e),r=(n=n.replace(/,/g,"")).split("."),t=r[0],o=r[1],i=t.replace(/\B(?=(\d{3})+(?!\d))/g,",");return o?"$ ".concat(i,".").concat(o):"$ ".concat(i)};return Ne.jsxs(Ne.Fragment,{children:[Ne.jsxs("div",{className:"grid md:grid-cols-2 lg:grid-cols-4 gap-x-6 mb-3",children:[Ne.jsx(O.Item,{label:"Precio sin impuestos",name:"price",children:Ne.jsx(z,{min:0,precision:(null==n?void 0:n.configs.nDecimals)||2,className:"w-full",formatter:p,placeholder:"Ingresar el precio unitario"})}),Ne.jsx(O.Item,{label:"Precio con impuestos",children:Ne.jsx(z,{placeholder:"Ingresar el precio unitario",min:0,precision:(null==n?void 0:n.configs.nDecimals)||2,className:"!w-full",value:c,formatter:p,onChange:function(e){return d(e,!1)}})}),Ne.jsx(O.Item,{label:"% de descuento",name:"descuento",children:Ne.jsx(z,{placeholder:"Ingresar el porcentaje del descuento",min:0,max:100,precision:(null==n?void 0:n.configs.nDecimals)||2,className:"!w-full"})}),Ne.jsx(O.Item,{label:"Precio final",children:Ne.jsx(z,{value:u,placeholder:"Ingresar el precio unitario",min:0,formatter:p,precision:(null==n?void 0:n.configs.nDecimals)||2,className:"!w-full",onChange:d})})]}),Ne.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[Ne.jsxs("div",{children:[Ne.jsx("p",{className:"text-lg font-bold",children:"Traslados"}),Ne.jsxs("div",{className:"flex items-center mb-3",children:[Ne.jsx(K,{checked:!0,disabled:!0,className:"basis-36",children:"IVA"}),Ne.jsx(O.Item,{name:"iva",className:"m-0 basis-full",rules:[Je.required()],children:Ne.jsx(_,{options:null===(a=e.options.PorcentajesDeIVA)||void 0===a?void 0:a.map(function(e){return{label:e.id+" - "+e.description,value:e.id}})})})]}),Ne.jsx(bn,{form:r,options:e.options.PorcentajesDeIEPS,label:"IEPS",name:"ieps"})]}),Ne.jsx("div",{children:Ne.jsxs("div",{children:[Ne.jsx("p",{className:"text-lg font-bold",children:"Retenciones"}),Ne.jsx(bn,{form:r,options:e.options.PorcentajesIVARET,label:"IVA",name:"ivaRet"}),Ne.jsx(bn,{form:r,options:e.options.PorcentajesIEPSRET,label:"IEPS",name:"iepsRet"}),Ne.jsx(bn,{form:r,options:e.options.PorcentajesISRRET,label:"ISR",name:"isrRet"})]})})]})]})},yn=l(function(e,t){var o,i=n(e.tipoPorDefecto&&"producto"!==e.tipoPorDefecto?"/api/v3/production/services":"/api/v3/production/products"),l=i[0],c=i[1],d=Ze({endpoint:l,params:{$getAllFields:"true"},data:{type:"servicio"===e.tipoPorDefecto?"service":"product",code:"",accountingAccount:void 0,iva:"3",aditionalInformation:[],bodegas:[],tipoProducto:"producto",relaciones:[],ObjetoImp:"02"},soloParaInsertar:!0===e.ocultarBotones}),p=n("precios"),m=p[0],f=p[1],v=n(0),h=v[0],g=v[1],b=Xe().hasModule,x=n(""),j=x[0],y=x[1],I=n([]);I[0];var C=I[1],w=O.useWatch("price",d.form)||0,P=O.useWatch("type",d.form);r(function(){c("service"===P?"/api/v3/production/services":"/api/v3/production/products")},[P]);var S=O.useWatch("relaciones",d.form),F=O.useWatch("tipoProducto",d.form),N="product"===P?"producto":"servicio",k="Clave de ".concat(N),E="Código SAT del ".concat(N),T=Oe(),R=T.message,D=T.showError;s(t,function(){return{form:d.form,onSubmit:d.onSubmit}}),r(function(){u.get("/api/v3/businesses/me/configurations",{params:{fields:"restaurantes production"}}).then(function(e){var n,r,t=e.data;if(b("restaurantes")){var o=(null===(n=null==t?void 0:t.restaurantes)||void 0===n?void 0:n.categorias.filter(function(e){return"activo"===e.estado}))||[];C(o)}y(null===(r=null==t?void 0:t.production)||void 0===r?void 0:r.metodoInventario)})},[]),a(function(){if(S){var e=d.form.getFieldValue("relaciones"),n=null==e?void 0:e.reduce(function(e,n){return e+(n.precio*n.cantidad||0)},0);g(w-n)}},[S,w]);return Ne.jsxs(O,{form:d.form,layout:"vertical",autoComplete:"off",initialValues:d.data,onFinish:function(e){return je(void 0,void 0,void 0,function(){var n,r,t,o,i,a,l;return ye(this,function(s){switch(s.label){case 0:if(s.trys.push([0,6,,7]),"kit"===e.tipoProducto){if(0===(null===(o=null==e?void 0:e.relaciones)||void 0===o?void 0:o.length))return[2,R.warning("El kit debe tener ingresado al menos una relación.")];if(!(null===(i=null==e?void 0:e.relaciones)||void 0===i?void 0:i.some(function(e){return"product"===e.type})))return[2,R.warning("En las relaciones del kit debe tener ingresado al menos un producto.")]}s.label=1;case 1:return s.trys.push([1,4,,5]),[4,d.form.validateFields()];case 2:return s.sent(),[4,d.onSubmit(e)];case 3:return s.sent(),[3,5];case 4:return n=s.sent(),null!==(l=null===(a=null==(r=n)?void 0:r.errorFields)||void 0===a?void 0:a.length)&&void 0!==l&&l?[2,R.warning("Completa los campos del formulario")]:[3,5];case 5:return[3,7];case 6:return t=s.sent(),D(t),[3,7];case 7:return[2]}})})},onValuesChange:function(e,n){return d.preventor.cambiarDatosFormulario(n)},children:[Ne.jsx(Q,{className:"mb-4",variant:e.bordered?"outlined":"borderless",children:Ne.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-x-6",children:[Ne.jsx(O.Item,{name:"type",label:"Tipo",rules:[Je.required()],className:e.tipoPorDefecto?"hidden":"",children:Ne.jsx(_,{options:[{label:"Producto",value:"product"},{label:"Servicio",value:"service"}]})}),"product"===P&&Ne.jsx(O.Item,{name:"tipoProducto",label:"Tipo producto",rules:[Je.required()],children:Ne.jsx(_,{options:[{label:"Producto",value:"producto"},{label:"Kit",value:"kit"}],onChange:function(e){"producto"===e&&d.form.setFieldValue("relaciones",[])}})}),Ne.jsx(O.Item,{name:"code",label:k,rules:[Je.required(),Je.max(300)],children:Ne.jsx(L,{placeholder:"Ingresar el código principal"})}),Ne.jsx(O.Item,{label:"Clave alterna",name:"auxiliarCode",children:Ne.jsx(L,{placeholder:"Ingresar la clave alterna"})}),Ne.jsx(Cn,{label:E,name:"claveProdServ",type:"products-and-services-catalog",required:!0}),Ne.jsx(O.Item,{label:"Descripción",name:"description",rules:[Je.required(),Je.max(1e3)],children:Ne.jsx(L,{placeholder:"Ingresar una descripción"})}),Ne.jsx(Cn,{label:"Clave de unidad SAT",name:"claveUnidad",type:"claves-de-unidad",required:!0}),Ne.jsx(O.Item,{name:"ObjetoImp",rules:[Je.required()],label:"Operación comercial",children:Ne.jsx(_,{placeholder:"Seleccionar la operación comercial",options:null===(o=d.options.ObjetoImp)||void 0===o?void 0:o.map(function(e){return{label:e.id+" - "+e.description,value:e.id}})})}),Ne.jsx(O.Item,{label:"No. identificación",name:"noDeIdentificacion",children:Ne.jsx(L,{placeholder:"Ingresar el número de identificación"})})]})}),Ne.jsxs(Q,{tabList:Ie(Ie(Ie([{key:"precios",tab:"Precios"}],"receta"===F||"kit"===F?[{key:"relaciones",tab:"Relaciones"}]:[],!0),b("contabilidad-mx")?[{key:"contabilidad",tab:"Contabilidad"}]:[],!0),b("restaurantes")?[{key:"restaurantes",tab:"Restaurantes"}]:[],!0),className:"mb-6",variant:e.bordered?"outlined":"borderless",activeTabKey:m,onTabChange:function(e){return f(e)},children:["kit"===F&&(null==S?void 0:S.length)>0&&"peps"!==j&&Ne.jsxs("div",{className:"mb-5",children:[1===Math.sign(h)&&Ne.jsx(re,{message:"Utilidad: ".concat(Qe.currency(h)),type:"success",showIcon:!0}),-1===Math.sign(h)&&Ne.jsx(re,{message:"Utilidad: ".concat(Qe.currency(h)),type:"warning",showIcon:!0})]}),Ne.jsx("div",{className:"precios"===m?"":"hidden",children:Ne.jsx(jn,{form:d.form,hasModule:b,options:d.options})}),"kit"===F&&Ne.jsx("div",{className:"relaciones"===m?"":"hidden",children:Ne.jsx(xn,{form:d.form})}),b("contabilidad-mx")&&Ne.jsx("div",{className:"contabilidad"===m?"":"hidden",children:Ne.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-x-6",children:[Ne.jsx(Cn,{label:"Cuenta contable de venta",name:"accountingAccount",type:"cuentas-contables-mx"}),"product"===P&&Ne.jsxs(Ne.Fragment,{children:[Ne.jsx(Cn,{label:"Cuenta contable de costo",name:"accountingAccountCost",type:"cuentas-contables-mx"}),Ne.jsx(Cn,{label:"Cuenta contable de inventario",name:"cuentaContableInventario",type:"cuentas-contables-mx"})]})]})})]}),e.ocultarBotones?null:d.BotonesPorDefecto]})}),In=function(e){var n=i(e.options),r=a(function(){var r;return null!==(r=e.configs)&&void 0!==r?r:function(e){var n=function(n){var r,t,o,i,a;return o=null===(t=null===(r=e.opciones)||void 0===r?void 0:r.current)||void 0===t?void 0:t.Banks,i=n,(a=null==o?void 0:o.find(function(e){return e.id===i}))?a.description:"No encontrado"};switch(e.tipo){case"cuentas-contables-mx":return{label:"Cuenta contable",endpoint:"/api/v3/contability/cuentas-contables",params:{fields:"codigo nombre codigoAgrupador cuentaMayor auxiliar estado cuentaSuperior",cuentaMayor:"2"},field:"codigo",placeholder:"Ingrese el código de la cuenta",title:function(e){return"".concat(null==e?void 0:e.codigo)},subtitle:function(e){return null==e?void 0:e.nombre},modal:{title:"Cuenta contable",getTexto:function(e){return e.description},componente:function(e){return Ne.jsx(gn,{ref:e.ref,ocultarBotones:!0})}}};case"clients-mx":default:return{withOptions:!0,label:"Cliente",endpoint:"/api/v3/administrative/clients-mx",params:{fields:"rfc name usoCFDI banks address numRegIdTrib RegimenFiscalReceptor",tipo:"cliente",estado:"activo"},field:"rfc",placeholder:"Ingrese el RFC del cliente",title:function(e){return"".concat(e.rfc," · ").concat(e.name)},subtitle:function(e){return e.name},preBusquedaQ:function(e){return void 0===e&&(e=""),e=e.trim(),/^\d+/.test(e)?"^"+e:e},modal:{title:"Clientes",getTexto:function(e){return e.name},componente:function(e){return Ne.jsx(vn,{ref:e.ref,type:"client",ocultarBotones:!0})}}};case"clients-rfc":return{label:"Cliente",endpoint:"/api/v3/administrative/clients-mx",params:{fields:"rfc name usoCFDI banks address numRegIdTrib RegimenFiscalReceptor",tipo:"cliente",estado:"activo"},field:"rfc",placeholder:"Ingrese el RFC del cliente",title:function(e){return"".concat(e.rfc," · ").concat(e.name)},subtitle:function(e){return e.name},customDocumentId:"rfc",buscarPorQueryString:!0};case"codigo-postal":return{label:"Código postal",endpoint:"/api/v3/utils/enums/codigo-postal",field:"id",placeholder:"Ingrese el código postal",title:function(e){return e.id},customDocumentId:"id",preBusquedaQ:function(e){return/^\d+\./.test(e)?"^"+e:e}};case"sellers":return{withOptions:!0,label:"Vendedor",endpoint:"/api/v3/administrative/sellers",params:{fields:"rfc name codigo",estado:"activo"},field:"name",placeholder:"Ingrese el nombre del vendedor",title:function(e){return e.name},subtitle:function(e){return"".concat(e.codigo)}};case"paises":return{label:"Pais",endpoint:"/api/v3/utils/enums/Paises",field:"id",placeholder:"Ingrese el país. Ej. MEX",title:function(e){var n;return null!==(n=null==e?void 0:e.id)&&void 0!==n?n:e},subtitle:function(e){return null==e?void 0:e.description},customDocumentId:"id"};case"bankaccounts":return{withOptions:!0,label:"Cuenta bancaria",endpoint:"/api/v3/treasury/bank-accounts",params:{fields:"number bank total",status:"activo"},field:"number",placeholder:"Ingrese la cuenta de banco",title:function(e){return e.number},subtitle:function(e){return"".concat(n(e.bank)," - Saldo: ").concat(Qe.currency(e.total))}};case"colonias":return{label:"Colonia",endpoint:"/api/v3/utils/enums/cartaPorte--Colonia",field:"id",placeholder:"Ingrese la colonia",title:function(e){var n;return null!==(n=null==e?void 0:e.id)&&void 0!==n?n:e},subtitle:function(e){return null==e?void 0:e.description},customDocumentId:"id"};case"localidades":return{label:"Localidad",endpoint:"/api/v3/utils/enums/cartaPorte--Localidad",field:"id",placeholder:"Ingrese la localidad",title:function(e){var n;return null!==(n=null==e?void 0:e.id)&&void 0!==n?n:e},subtitle:function(e){return null==e?void 0:e.description},customDocumentId:"id"};case"municipios":return{label:"Municipio",endpoint:"/api/v3/utils/enums/cartaPorte--Municipio",field:"id",placeholder:"Ingrese el municipio",title:function(e){var n;return null!==(n=null==e?void 0:e.id)&&void 0!==n?n:e},subtitle:function(e){return null==e?void 0:e.description},customDocumentId:"id"};case"estados":return{label:"Estado",endpoint:"/api/v3/utils/enums/cartaPorte--Estados",field:"id",placeholder:"Ingrese el estado",title:function(e){var n;return null!==(n=null==e?void 0:e.id)&&void 0!==n?n:e},subtitle:function(e){return null==e?void 0:e.description},customDocumentId:"id"};case"ingresos-uuid":return{label:"UUID",endpoint:"/api/v3/administrative/ingresos",field:"uuid",placeholder:"Ingrese el UUID",title:function(e){return e.uuid},subtitle:function(e){return"".concat(e.comprobante.serie," -").concat(e.comprobante.folio)},customDocumentId:"uuid",buscarPorQueryString:!0};case"products-services":return{label:"Producto",endpoint:"/api/v3/production/products-services",params:{fields:"code description auxiliarCode type price iva ieps ivaRet iepsRet isrRet total claveProdServ claveUnidad ObjetoImp bodegas tipoProducto",sort:"code",status:"active"},field:"code",placeholder:"Ingrese el código del producto",title:function(e){return null==e?void 0:e.code},subtitle:function(n){var r,t,o,i,a=null==n?void 0:n.description;if("product"===(null==n?void 0:n.type)){var l=null==n?void 0:n.total,s=null===(r=e.params)||void 0===r?void 0:r._bodega;if(s){var c=n.bodegas.find(function(e){return e.bodega===s});l="number"==typeof(null==c?void 0:c.amount)?c.amount:0}a="".concat((null===(o=null===(t=null==n?void 0:n.tipoProducto)||void 0===t?void 0:t[0])||void 0===o?void 0:o.toUpperCase())+(null===(i=null==n?void 0:n.tipoProducto)||void 0===i?void 0:i.substr(1)),": ").concat(a," (").concat(l,")")}else a="Servicio: ".concat(a);return a},modal:{itemNoEncontrado:"El producto o servicio no se encuentra registrado ¿Desea registrarlo?",title:"Productos y servicios",getTexto:function(e){return e.description},componente:function(e){return Ne.jsx(yn,{ref:e.ref,ocultarBotones:!0,bordered:!1})}}};case"products-and-services-catalog":return{label:"Código SAT de producto/servicio",endpoint:"/api/v3/utils/enums/ClaveProdServ",field:"id",placeholder:"Ingrese la clave de producto SAT",title:function(e){return e.id},subtitle:function(e){return e.description},customDocumentId:"id"};case"claves-de-unidad":return{label:"Clave de Unidad SAT",endpoint:"/api/v3/utils/enums/claves-de-unidad",field:"id",placeholder:"Ingrese la clave de unidad",title:function(e){return e.id},subtitle:function(e){return e.description},customDocumentId:"id"};case"alumnos":return{label:"Alumno",endpoint:"/api/api/v3/administrative/alumnos",params:{fields:"_id idAlumno nombreAlumno CURP nivelEducativo autRVOE rfcPago"},field:"nombreAlumno",placeholder:"Ingrese el nombre del alumno",title:function(e){return"".concat(e.idAlumno)},subtitle:function(e){return e.nombreAlumno}};case"providers-mx":return{withOptions:!0,label:"Proveedor",endpoint:"/api/v3/administrative/clients-mx",params:{fields:"_id name rfc",tipo:"proveedor",estado:"activo"},field:"rfc",placeholder:"Ingrese el rfc",title:function(e){return"".concat(e.rfc)},subtitle:function(e){return e.name},modal:{itemNoEncontrado:"Este proveedor no se encuentra registrado ¿Desea registrarlo?",title:"Proveedores",getTexto:function(e){return e.name},componente:function(e){return Ne.jsx(vn,{ref:e.ref,type:"provider",ocultarBotones:!0,bordered:!1})}}};case"pettycash":return{label:"Caja chica",endpoint:"/api/v3/treasury/pretty-cash",params:{fields:"name bank total",status:"activo"},field:"name",placeholder:"Ingrese el nombre de caja chica",title:function(e){return e.name},subtitle:function(e){return"Saldo: ".concat(null==Qe?void 0:Qe.currency(e.total))}};case"creditcards":return{withOptions:!0,label:"Tarjeta de crédito",endpoint:"/api/v3/treasury/credit-cards",params:{fields:"number cardholder bank total",status:"activo"},field:"number",placeholder:"Ingrese el número de tarjeta de crédito",title:function(e){return e.number},subtitle:function(e){return"".concat(e.cardholder," · ").concat(n(e.bank)," · Saldo: ").concat(Qe.currency(e.total))}};case"boxes":return{label:"Caja",endpoint:"/api/v3/treasury/boxes",params:{fields:"name total",status:"activo"},field:"name",placeholder:"Ingrese el nombre de la caja",title:function(e){return e.name},subtitle:function(e){return"Saldo: ".concat(Qe.currency(e.total))}};case"faltas":return{withOptions:!0,label:"Tipo de falta",endpoint:"/api/v3/payroll/faltas",params:{fields:"clave descripcion"},field:"descripcion",placeholder:"Ingresar la clave",title:function(e){return"".concat(e.clave," - ").concat(e.descripcion)}};case"percepciones":return{withOptions:!0,label:"Percepciones",endpoint:"/api/v3/payroll/percepciones",params:{fields:"clave descripcion formula montoPeriodo montoAnual estado claveSat basesFiscales"},field:"clave",placeholder:"Ingresar la percepción",title:function(e){return"".concat(e.clave)},subtitle:function(e){return"".concat(e.descripcion)}};case"deducciones":return{withOptions:!0,label:"Deducciones",endpoint:"/api/v3/payroll/deducciones",params:{fields:"clave descripcion formula montoPeriodo montoAnual estado claveSat basesFiscales"},field:"clave",placeholder:"Ingresar la deducción",title:function(e){return"".concat(e.clave)},subtitle:function(e){return"".concat(e.descripcion)}};case"departamentos":return{label:"Departamento",endpoint:"/api/v3/payroll/departamentos",params:{fields:"clave descripcion"},field:"descripcion",placeholder:"Ingrese la clave del departamento",title:function(e){return e.clave},subtitle:function(e){return e.descripcion}};case"empleados":return{withOptions:!0,label:"Empleado",endpoint:"/api/v3/payroll/employees",params:{fields:"names apellidoPaterno apellidoMaterno documentNumber ingressDate periodicidadPago salaries",status:"activo"},field:"documentNumber",placeholder:"Ingresar el empleado",title:function(e){return"".concat(e.documentNumber)},subtitle:function(e){return"".concat(e.names," ").concat(e.apellidoPaterno," ").concat(e.apellidoMaterno)}};case"bodegas":return{label:"Bodegas",endpoint:"/api/v3/production/bodegas",params:{fields:"code name description color"},field:"code",placeholder:"Ingrese la bodega",title:function(e){return e.code},subtitle:function(e){return e.name}};case"puestos":return{label:"Puesto",endpoint:"/api/v3/payroll/puestos",params:{fields:"clave descripcion"},field:"descripcion",placeholder:"Ingrese la clave del puesto",title:function(e){return e.clave},subtitle:function(e){return e.descripcion}};case"products":return{label:"Producto",endpoint:"/api/v3/production/products",params:{fields:"code description price total claveUnidad tipoProducto",sort:"code",status:"active"},field:"code",placeholder:"Ingrese el código del producto",title:function(e){return e.code},subtitle:function(e){return e.description},modal:{itemNoEncontrado:"El producto no se encuentra registrado ¿Desea registrarlo?",title:"Productos y servicios",getTexto:function(e){return e.description},componente:function(e){return Ne.jsx(yn,{ref:e.ref,tipoPorDefecto:"producto",ocultarBotones:!0,bordered:!1})}}};case"cost-centers":return{label:"Centro de costos",endpoint:"/api/v3/contability/cost-centers",params:{fields:"code description"},field:"code",placeholder:"Ingrese el código del centro de costos",title:function(e){return e.code},subtitle:function(e){return e.description}};case"categorias":return{label:"Categoria",endpoint:"/api/v3/production/categorias",params:{fields:"nombre descripcion"},field:"nombre",placeholder:"Ingrese el nombre",title:function(e){var n;return 1===(null===(n=e.data)||void 0===n?void 0:n.length)?decodeURIComponent(e.data[0].nombre):decodeURIComponent(e.nombre)},customDocumentId:"nombre",buscarPorQueryString:!0};case"figuras-transportes":return{label:"Figura de transporte",endpoint:"/api/v3/administrative/figuras-transportes",params:{fields:"RFCFigura TipoFigura NumLicencia NombreFigura NumRegIdTribFigura ResidenciaFiscalFigura PartesTransporte"},field:"RFCFigura",placeholder:"Ingrese el RFC de la figura de transporte",title:function(e){return e.RFCFigura},subtitle:function(e){return e.NombreFigura},customDocumentId:"RFCFigura",buscarPorQueryString:!0};case"autotransportes":return{label:"Placa vehícular",endpoint:"/api/v3/administrative/autotransportes",params:{fields:"PermSCT NumPermisoSCT IdentificacionVehicular Seguros Remolques"},field:"IdentificacionVehicular.PlacaVM",placeholder:"Ingrese la placa vehícular",title:function(e){return e.IdentificacionVehicular.PlacaVM},customDocumentId:"IdentificacionVehicular.PlacaVM",buscarPorQueryString:!0}}}({opciones:n,tipo:e.tipo,params:e.params||{}})},[e.tipo,e.params,e.configs]),t=d(r.withOptions&&!e.options?r.endpoint+"/get-options":null,function(e){return je(void 0,void 0,void 0,function(){return ye(this,function(n){switch(n.label){case 0:return[4,u.get(e)];case 1:return[2,n.sent().data]}})})},{revalidateOnFocus:!1}).data;return t&&(n.current=t),r},Cn=function(e){return Ne.jsx(cn,xe({},e,{_useSeekerHook:In}))},wn=t(null);function Pn(){return o(wn)}var Sn=function(e){var r=n([]),t=r[0],o=r[1];return Ne.jsxs(wn.Provider,{value:{setBitacora:o},children:[Ne.jsx(Fn,{bitacora:t,setBitacora:o}),e.children]})},Fn=function(e){return Ne.jsx(te,{title:"Bitácora",placement:"right",closable:!1,open:0!==e.bitacora.length,onClose:function(){return e.setBitacora([])},children:Ne.jsx(oe,{items:e.bitacora.map(function(e,n){var r=function(e){switch(e){case"created":case"creacion-masiva":return{color:"green"};case"draft":return{color:"orange",icon:Ne.jsx(N,{})};case"failed":return{color:"red",icon:Ne.jsx(F,{})};case"issued":case"used":return{color:"green",icon:Ne.jsx(S,{})};case"sent":return{color:"#1890FF",icon:Ne.jsx(P,{})};case"pre-canceled":return{color:"#FFA500",icon:Ne.jsx(f,{})};case"canceled":case"reversado":return{color:"red",icon:Ne.jsx(w,{})};case"edit":return{color:"#1890FF",icon:Ne.jsx(C,{})};case"email":return{color:"#00CCFF",icon:Ne.jsx(I,{})};case"deleted":return{color:"red",icon:Ne.jsx(h,{})};case"intermitencia":return{color:"red",icon:Ne.jsx(y,{})};case"exit-notice":return{color:"red",icon:Ne.jsx(j,{})};case"exit-notice-deleted":return{color:"green",icon:Ne.jsx(x,{})}}}(e.type);return{color:null==r?void 0:r.color,key:"movimiento"+n,dot:null==r?void 0:r.icon,children:Ne.jsxs(Ne.Fragment,{children:[e.nota," ",Ne.jsx("br",{}),Qe.completeDate(e.date)]})}})})})},Nn="#F34D24",kn=function(e){var t=n(!1),o=t[0],i=t[1];return r(function(){i(!0)},[]),o?Ne.jsx(Sn,{children:Ne.jsx(ie,{locale:be,theme:{token:{colorPrimary:Nn,colorLink:Nn,fontFamily:e.fontFamily||'"Inter", "SF Pro", "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", "Helvetica", "Arial", sans-serif',colorTextDisabled:"#00000080"},components:{Layout:{headerBg:"rgba(245,245,245,0.5)",siderBg:"#0F141E"},Menu:{darkItemBg:"#0F141E",darkSubMenuItemBg:"#0A0E15"},Tag:{marginXS:0}}},children:Ne.jsx(V,{children:Ne.jsx(ae,{className:(e.className||"")+" !min-h-screen w-full",style:e.style,children:e.children})})})}):null},En=function(e){var t=Pn().setBitacora,o=n(!1),i=o[0],l=o[1],s=a(function(){return Array.isArray(e.movimientos)&&0!==e.movimientos.length},[e.movimientos]),c=function(){s&&t(e.movimientos)};return r(function(){var n;l(null===(n=e.movimientos)||void 0===n?void 0:n.some(function(e){return!!e.mostrarBadge}))},[e.movimientos]),Ne.jsx(le,{dot:i,children:e.usarIcono?Ne.jsx(k,{title:"Ver historial",className:s?"":"text-gray-300 cursor-not-allowed",onClick:c}):Ne.jsx(R,{icon:Ne.jsx(k,{}),title:"Ver historial",disabled:!s,onClick:c})})},Tn=function(){return{hora:(new Date).toLocaleTimeString(),fecha:(new Date).toLocaleDateString(void 0,{weekday:"long",year:"numeric",month:"long",day:"numeric"})}},Rn=function(e){var t=n(Tn()),o=t[0],i=t[1];return r(function(){var e=setInterval(function(){return i(Tn())},1e3);return function(){return clearInterval(e)}},[]),Ne.jsxs("div",{className:e.className,children:[Ne.jsx("div",{className:"text-3xl font-bold",children:o.hora}),Ne.jsx("div",{className:"text-xl text-gray-500",children:o.fecha})]})},Dn=function(e){var r=n([null,null]),t=r[0],o=r[1];return Ne.jsxs("div",{className:"w-64",children:[Ne.jsx("div",{className:"p-2",children:Ne.jsx(se.RangePicker,{value:t,onCalendarChange:function(n){o(n);var r=n[0],t=n[1];if(r&&t){var i=r.startOf("day").toISOString(),a=t.endOf("day").toISOString();e.setSelectedKeys(["{$gte}".concat(i,"{$lte}").concat(a)])}}})}),Ne.jsx(H,{className:"m-0"}),Ne.jsxs("div",{className:"flex p-2 justify-between",children:[Ne.jsx(R,{size:"small",type:"text",onClick:function(){var n;o([null,null]),null===(n=e.clearFilters)||void 0===n||n.call(e),e.confirm()},children:"Reiniciar"}),Ne.jsx(R,{disabled:!t[0]||!t[1],type:"primary",onClick:function(){return e.confirm()},size:"small",children:"Aceptar"})]})]})},On=function(e){var r=n(null),t=r[0],o=r[1],i=ve(t,400)[0],a=d(null===i?null:[e.endpoint,i],function(n){return je(void 0,[n],void 0,function(n){var r,t=n[0],o=n[1];return ye(this,function(n){switch(n.label){case 0:return r=Array.isArray(e.name)?e.name.filter(function(e){return"string"==typeof e}).join("."):e.name,[4,u.get("".concat(t,"/_autocompletado/").concat(r),{params:{q:o}})];case 1:return[2,n.sent().data]}})})}).data,l=void 0===a?[]:a;return Ne.jsx(O.Item,{name:e.name,label:e.label,children:Ne.jsx(W,{onChange:function(e){return o(e||void 0)},onFocus:function(){return null===t?o(void 0):null},options:l.map(function(e){return{label:e,value:e}}),maxLength:300,placeholder:e.placeholder||"Tipear para buscar"})})},_n=function(e){var r=n(!0),t=r[0],o=r[1],i=n(!1),a=i[0],l=i[1];return Ne.jsxs(Ne.Fragment,{children:[e.sidebar?Ne.jsxs(ae.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),l(e)},children:[Ne.jsx(c,{href:e.sidebar.title.href,children:Ne.jsx("div",{className:"flex justify-center items-center h-16 text-lg text-white font-bold",children:Ne.jsx("div",{children:e.sidebar.title.label})})}),e.sidebar.menu]}):null,Ne.jsxs(ae,{className:a||t?"ml-0":"ml-[230px]",onClick:!t&&a?function(e){e.stopPropagation(),e.preventDefault(),o(!0)}:void 0,children:[e.navbar?Ne.jsx(ae.Header,{className:"border-b top-0 z-2! sticky px-4! backdrop-blur-xs",children:Ne.jsxs("div",{className:"flex justify-between items-center h-full",children:[Ne.jsx("div",{children:e.sidebar?Ne.jsx(R,{type:"text",icon:t?Ne.jsx(E,{}):Ne.jsx(T,{}),onClick:function(){return o(!t)},children:e.navbar.title}):e.navbar.title}),e.navbar.options?Ne.jsx("div",{children:e.navbar.options}):Ne.jsx("div",{})]})}):null,Ne.jsx(ae.Content,{className:"m-4 md:m-8 xl:mx-16 xl:my-8",children:e.children}),e.footer?Ne.jsx(ae.Footer,{className:"text-gray-500!",children:e.footer}):null]})]})};export{Qe as $filtros,Je as $reglas,On as Autocompletado,en as BotonConfirmacion,En as BotonMovimientos,Ye as ContextoEmpresa,Dn as FiltroFechas,dn as FormDirecciones,an as FormularioPersonas,Te as Header,rn as IdentificadorPersona,_n as LayoutBase,Rn as Reloj,cn as Seeker,Cn as SeekerMx,kn as TemaPrincipal,ke as Tutoriales,Ae as crearToken,Le as destruirToken,We as generarObjectId,qe as getApiEndpoint,Ve as getNestedPath,Ue as hashear,Be as nDecimals,Me as redireccionarLogin,$e as rewrites,Xe as useContextoEmpresa,Pn as useFrontendUtils,Oe as useUtils,Ze as useVistaInsertar,Ke as useVistaPrincipal};
|
|
10
|
+
*/"production"===process.env.NODE_ENV?Pe.exports=function(){if(Ce)return we;Ce=1;var n=e,r=Symbol.for("react.element"),t=Symbol.for("react.fragment"),o=Object.prototype.hasOwnProperty,i=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,a={key:!0,ref:!0,__self:!0,__source:!0};function l(e,n,t){var l,s={},c=null,u=null;for(l in void 0!==t&&(c=""+t),void 0!==n.key&&(c=""+n.key),void 0!==n.ref&&(u=n.ref),n)o.call(n,l)&&!a.hasOwnProperty(l)&&(s[l]=n[l]);if(e&&e.defaultProps)for(l in n=e.defaultProps)void 0===s[l]&&(s[l]=n[l]);return{$$typeof:r,type:e,key:c,ref:u,props:s,_owner:i.current}}return we.Fragment=t,we.jsx=l,we.jsxs=l,we}():Pe.exports=(Se||(Se=1,"production"!==process.env.NODE_ENV&&function(){var n,r=e,t=Symbol.for("react.element"),o=Symbol.for("react.portal"),i=Symbol.for("react.fragment"),a=Symbol.for("react.strict_mode"),l=Symbol.for("react.profiler"),s=Symbol.for("react.provider"),c=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),d=Symbol.for("react.suspense"),p=Symbol.for("react.suspense_list"),m=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),v=Symbol.for("react.offscreen"),h=Symbol.iterator,g=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function b(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),t=1;t<n;t++)r[t-1]=arguments[t];!function(e,n,r){var t=g.ReactDebugCurrentFrame.getStackAddendum();""!==t&&(n+="%s",r=r.concat([t]));var o=r.map(function(e){return String(e)});o.unshift("Warning: "+n),Function.prototype.apply.call(console[e],console,o)}("error",e,r)}function x(e){return e.displayName||"Context"}function j(e){if(null==e)return null;if("number"==typeof e.tag&&b("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 i:return"Fragment";case o:return"Portal";case l:return"Profiler";case a:return"StrictMode";case d:return"Suspense";case p:return"SuspenseList"}if("object"==typeof e)switch(e.$$typeof){case c:return x(e)+".Consumer";case s:return x(e._context)+".Provider";case u:return function(e,n,r){var t=e.displayName;if(t)return t;var o=n.displayName||n.name||"";return""!==o?r+"("+o+")":r}(e,e.render,"ForwardRef");case m:var n=e.displayName||null;return null!==n?n:j(e.type)||"Memo";case f:var r=e,t=r._payload,v=r._init;try{return j(v(t))}catch(e){return null}}return null}n=Symbol.for("react.module.reference");var y,I,C,P,w,S,N,F=Object.assign,k=0;function E(){}E.__reactDisabledLog=!0;var D,R=g.ReactCurrentDispatcher;function T(e,n,r){if(void 0===D)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);D=t&&t[1]||""}return"\n"+D+e}var O,_=!1,A="function"==typeof WeakMap?WeakMap:Map;function V(e,n){if(!e||_)return"";var r,t=O.get(e);if(void 0!==t)return t;_=!0;var o,i=Error.prepareStackTrace;Error.prepareStackTrace=void 0,o=R.current,R.current=null,function(){if(0===k){y=console.log,I=console.info,C=console.warn,P=console.error,w=console.group,S=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})}k++}();try{if(n){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(n){if(n&&r&&"string"==typeof n.stack){for(var l=n.stack.split("\n"),s=r.stack.split("\n"),c=l.length-1,u=s.length-1;c>=1&&u>=0&&l[c]!==s[u];)u--;for(;c>=1&&u>=0;c--,u--)if(l[c]!==s[u]){if(1!==c||1!==u)do{if(c--,--u<0||l[c]!==s[u]){var d="\n"+l[c].replace(" at new "," at ");return e.displayName&&d.includes("<anonymous>")&&(d=d.replace("<anonymous>",e.displayName)),"function"==typeof e&&O.set(e,d),d}}while(c>=1&&u>=0);break}}}finally{_=!1,R.current=o,function(){if(0===--k){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:F({},e,{value:y}),info:F({},e,{value:I}),warn:F({},e,{value:C}),error:F({},e,{value:P}),group:F({},e,{value:w}),groupCollapsed:F({},e,{value:S}),groupEnd:F({},e,{value:N})})}k<0&&b("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}(),Error.prepareStackTrace=i}var p=e?e.displayName||e.name:"",m=p?T(p):"";return"function"==typeof e&&O.set(e,m),m}function L(e,n,r){if(null==e)return"";if("function"==typeof e)return V(e,!(!(t=e.prototype)||!t.isReactComponent));var t;if("string"==typeof e)return T(e);switch(e){case d:return T("Suspense");case p:return T("SuspenseList")}if("object"==typeof e)switch(e.$$typeof){case u:return V(e.render,!1);case m:return L(e.type,n,r);case f:var o=e,i=o._payload,a=o._init;try{return L(a(i),n,r)}catch(e){}}return""}O=new A;var q=Object.prototype.hasOwnProperty,U={},B=g.ReactDebugCurrentFrame;function M(e){if(e){var n=e._owner,r=L(e.type,e._source,n?n.type:null);B.setExtraStackFrame(r)}else B.setExtraStackFrame(null)}var $=Array.isArray;function W(e){return $(e)}function z(e){return""+e}function X(e){if(function(e){try{return z(e),!1}catch(e){return!0}}(e))return b("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)),z(e)}var Y,H,G=g.ReactCurrentOwner,J={key:!0,ref:!0,__self:!0,__source:!0};function Q(e,n,r,o,i){var a,l={},s=null,c=null;for(a in void 0!==r&&(X(r),s=""+r),function(e){if(q.call(e,"key")){var n=Object.getOwnPropertyDescriptor(e,"key").get;if(n&&n.isReactWarning)return!1}return void 0!==e.key}(n)&&(X(n.key),s=""+n.key),function(e){if(q.call(e,"ref")){var n=Object.getOwnPropertyDescriptor(e,"ref").get;if(n&&n.isReactWarning)return!1}return void 0!==e.ref}(n)&&(c=n.ref,function(e){"string"==typeof e.ref&&G.current}(n)),n)q.call(n,a)&&!J.hasOwnProperty(a)&&(l[a]=n[a]);if(e&&e.defaultProps){var u=e.defaultProps;for(a in u)void 0===l[a]&&(l[a]=u[a])}if(s||c){var d="function"==typeof e?e.displayName||e.name||"Unknown":e;s&&function(e,n){var r=function(){Y||(Y=!0,b("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",n))};r.isReactWarning=!0,Object.defineProperty(e,"key",{get:r,configurable:!0})}(l,d),c&&function(e,n){var r=function(){H||(H=!0,b("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",n))};r.isReactWarning=!0,Object.defineProperty(e,"ref",{get:r,configurable:!0})}(l,d)}return function(e,n,r,o,i,a,l){var s={$$typeof:t,type:e,key:n,ref:r,props:l,_owner:a,_store:{}};return Object.defineProperty(s._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(s,"_self",{configurable:!1,enumerable:!1,writable:!1,value:o}),Object.defineProperty(s,"_source",{configurable:!1,enumerable:!1,writable:!1,value:i}),Object.freeze&&(Object.freeze(s.props),Object.freeze(s)),s}(e,s,c,i,o,G.current,l)}var K,Z=g.ReactCurrentOwner,ee=g.ReactDebugCurrentFrame;function ne(e){if(e){var n=e._owner,r=L(e.type,e._source,n?n.type:null);ee.setExtraStackFrame(r)}else ee.setExtraStackFrame(null)}function re(e){return"object"==typeof e&&null!==e&&e.$$typeof===t}function te(){if(Z.current){var e=j(Z.current.type);if(e)return"\n\nCheck the render method of `"+e+"`."}return""}K=!1;var oe={};function ie(e,n){if(e._store&&!e._store.validated&&null==e.key){e._store.validated=!0;var r=function(e){var n=te();if(!n){var r="string"==typeof e?e:e.displayName||e.name;r&&(n="\n\nCheck the top-level render call using <"+r+">.")}return n}(n);if(!oe[r]){oe[r]=!0;var t="";e&&e._owner&&e._owner!==Z.current&&(t=" It was passed a child from "+j(e._owner.type)+"."),ne(e),b('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',r,t),ne(null)}}}function ae(e,n){if("object"==typeof e)if(W(e))for(var r=0;r<e.length;r++){var t=e[r];re(t)&&ie(t,n)}else if(re(e))e._store&&(e._store.validated=!0);else if(e){var o=function(e){if(null===e||"object"!=typeof e)return null;var n=h&&e[h]||e["@@iterator"];return"function"==typeof n?n:null}(e);if("function"==typeof o&&o!==e.entries)for(var i,a=o.call(e);!(i=a.next()).done;)re(i.value)&&ie(i.value,n)}}function le(e){var n,r=e.type;if(null!=r&&"string"!=typeof r){if("function"==typeof r)n=r.propTypes;else{if("object"!=typeof r||r.$$typeof!==u&&r.$$typeof!==m)return;n=r.propTypes}if(n){var t=j(r);!function(e,n,r,t,o){var i=Function.call.bind(q);for(var a in e)if(i(e,a)){var l=void 0;try{if("function"!=typeof e[a]){var s=Error((t||"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 s.name="Invariant Violation",s}l=e[a](n,a,t,r,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(e){l=e}!l||l instanceof Error||(M(o),b("%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",r,a,typeof l),M(null)),l instanceof Error&&!(l.message in U)&&(U[l.message]=!0,M(o),b("Failed %s type: %s",r,l.message),M(null))}}(n,e.props,"prop",t,e)}else void 0===r.PropTypes||K||(K=!0,b("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",j(r)||"Unknown"));"function"!=typeof r.getDefaultProps||r.getDefaultProps.isReactClassApproved||b("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}var se={};function ce(e,r,o,h,g,x){var y=function(e){return"string"==typeof e||"function"==typeof e||e===i||e===l||e===a||e===d||e===p||e===v||"object"==typeof e&&null!==e&&(e.$$typeof===f||e.$$typeof===m||e.$$typeof===s||e.$$typeof===c||e.$$typeof===u||e.$$typeof===n||void 0!==e.getModuleId)}(e);if(!y){var I,C="";(void 0===e||"object"==typeof e&&null!==e&&0===Object.keys(e).length)&&(C+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports."),C+=te(),null===e?I="null":W(e)?I="array":void 0!==e&&e.$$typeof===t?(I="<"+(j(e.type)||"Unknown")+" />",C=" Did you accidentally export a JSX literal instead of a component?"):I=typeof e,b("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",I,C)}var P=Q(e,r,o,g,x);if(null==P)return P;if(y){var w=r.children;if(void 0!==w)if(h)if(W(w)){for(var S=0;S<w.length;S++)ae(w[S],e);Object.freeze&&Object.freeze(w)}else b("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 ae(w,e)}if(q.call(r,"key")){var N=j(e),F=Object.keys(r).filter(function(e){return"key"!==e}),k=F.length>0?"{key: someKey, "+F.join(": ..., ")+": ...}":"{key: someKey}";se[N+k]||(b('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} />',k,N,F.length>0?"{"+F.join(": ..., ")+": ...}":"{}",N),se[N+k]=!0)}return e===i?function(e){for(var n=Object.keys(e.props),r=0;r<n.length;r++){var t=n[r];if("children"!==t&&"key"!==t){ne(e),b("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),b("Invalid attribute `ref` supplied to `React.Fragment`."),ne(null))}(P):le(P),P}var ue=function(e,n,r){return ce(e,n,r,!1)},de=function(e,n,r){return ce(e,n,r,!0)};Ne.Fragment=i,Ne.jsx=ue,Ne.jsxs=de}()),Ne);var Fe=Pe.exports,ke=function(e){var t=n(!1),o=t[0],i=t[1],a=n(""),l=a[0],s=a[1],c=d(["/api/v3/videos/public",e.pathname],function(e){return je(void 0,[e],void 0,function(e){var n,r,t,o=e[0],i=e[1];return ye(this,function(e){switch(e.label){case 0:return n=i.split("/"),r=n[1],t=n[2],[4,u.get(o,{params:{module:r,submodule:t,showIn:"page"}})];case 1:return[2,e.sent().data]}})})}),m=c.data,f=c.isLoading;return r(function(){m&&m.length>0&&s(m[0].videoId)},[m]),m&&0!==m.length?Fe.jsxs("div",{children:[Fe.jsx(R,xe({loading:f,title:"Videos de ayuda",icon:Fe.jsx(p,{}),onClick:function(){return i(!0)}},e.buttonProps)),Fe.jsxs(T,{title:"Videos de ayuda",footer:null,open:o,maskClosable:!1,width:640,onCancel:function(){return i(!1)},children:[Fe.jsx(O.Item,{children:Fe.jsx(_,{className:"w-full",value:l,onChange:function(e){return s(e)},children:m.map(function(e){return Fe.jsx(_.Option,{value:e.videoId,children:e.title},e.videoId)})})}),Fe.jsx("iframe",{title:"YouTube video player",className:"aspect-video w-full rounded-sm mb-4",src:"https://www.youtube.com/embed/".concat(l),allowFullScreen:!0}),Fe.jsxs(A.Text,{type:"secondary",children:["Suscríbete a nuestro"," ",Fe.jsx(A.Link,{href:"https://www.youtube.com/channel/UCPo_ZWhAfRtbIzMwAJe7iVA",target:"_blank",children:"canal de YouTube"}),". Mantente informado de nuestras últimas actualizaciones, novedades y tutoriales."]})]})]}):null},Ee=function(e){return e.paths?Fe.jsx(L,{items:e.paths.map(function(e){var n=e.to,r=e.label;return{title:n?Fe.jsx(c,{href:n,children:r}):r}})}):null},De=function(e){var t,o=e.defaultInsert,i=void 0!==o&&o,a=e.loading,l=void 0!==a&&a,s=function(e,n){var r={};for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&n.indexOf(t)<0&&(r[t]=e[t]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(t=Object.getOwnPropertySymbols(e);o<t.length;o++)n.indexOf(t[o])<0&&Object.prototype.propertyIsEnumerable.call(e,t[o])&&(r[t[o]]=e[t[o]])}return r}(e,["defaultInsert","loading"]),u=ce(),d=u.pathname,p=n(""),f=p[0],v=p[1],h=new URLSearchParams(u.query),g=function(){var e=new URLSearchParams(h.toString());(e.get("q")||"")!==f&&(f?e.set("q",f):e.delete("q"),e.delete("page"),u.push({query:Object.fromEntries(e)}))},b=Fe.jsxs("div",{className:"flex w-full md:w-auto flex-wrap md:flex-nowrap gap-2 justify-end",children:[!0!==s.ocultarBuscador?Fe.jsx(V.Search,{value:f,placeholder:"Ingresar búsqueda",onChange:function(e){return v(e.target.value||"")},onSearch:g,onPressEnter:g}):null,null!==i?i||Fe.jsx(c,{href:(t=d,t.endsWith("/")&&(t=t.slice(0,-1)),t+"/insert"),children:Fe.jsx(R,{type:"primary",children:"Insertar"})}):null,s.onRefrescar?Fe.jsx("div",{children:Fe.jsx(R,{loading:l,title:"Refrescar datos",icon:Fe.jsx(m,{}),onClick:s.onRefrescar})}):null,s.children,s.tutorialPathname&&Fe.jsx(ke,{pathname:s.tutorialPathname})]});return r(function(){u.isReady&&v(h.get("q")||"")},[u.isReady]),Fe.jsxs("div",{className:"flex md:flex-row flex-col md:items-end items-start justify-between gap-6 mb-8",children:[Fe.jsxs("div",{children:[Fe.jsx(Ee,{paths:s.paths}),Fe.jsx(A.Title,{className:"mb-0! mt-4",children:s.title}),s.subtitle&&Fe.jsx(A.Title,{level:3,type:"secondary",className:"font-normal! m-0!",children:s.subtitle})]}),null!==s.column?s.column||b:null]})},Re={host:{api:process.env.NEXT_PUBLIC_API,apiOpen:process.env.NEXT_PUBLIC_API_OPEN,restify:process.env.NEXT_PUBLIC_RESTIFY,restifyOpen:process.env.NEXT_PUBLIC_RESTIFY_OPEN,utils:process.env.NEXT_PUBLIC_UTILS,utilsOpen:process.env.NEXT_PUBLIC_UTILS_OPEN},userTokenName:"",adminTokenName:"",cookieDominio:"",cookiePath:void 0},Te=function(e){return je(void 0,void 0,void 0,function(){var n,r,t,o,i,a;return ye(this,function(l){switch(l.label){case 0:if(!((n=(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];l.label=1;case 1:return l.trys.push([1,3,,5]),t=(r=JSON).parse,[4,n.text()];case 2:return[2,{message:t.apply(r,[l.sent()]).message,tipo:"error"}];case 3:return l.sent(),o={},[4,n.text()];case 4:return[2,(o.message=l.sent(),o.tipo="error",o)];case 5:return[2,{message:n,tipo:"error"}]}})})},Oe=function(){var e=q.useApp(),n=e.modal,r=e.message,t=e.notification;return{showError:function(e,r){return je(void 0,void 0,void 0,function(){var t;return ye(this,function(o){switch(o.label){case 0:return[4,Te(e)];case 1:return t=o.sent(),n[t.tipo]({title:(null==r?void 0:r.title)||"Proceso fallido",width:450,content:Fe.jsxs(Fe.Fragment,{children:[t.message,null==r?void 0:r.cuerpoAdicional]}),okType:"danger"}),[2]}})})},modal:n,message:r,notification:t}},_e=function(e){return"administrador"===e?Re.adminTokenName:Re.userTokenName},Ae=function(e,n){pe(_e(n.usuario),e,{domain:Re.cookieDominio,maxAge:604800,path:Re.cookiePath})},Ve=function(e){me(_e(e),{domain:Re.cookieDominio,path:Re.cookiePath})},Le=function(e,n){var r=e.includes("/v4")?Re.host.apiOpen:Re.host.restifyOpen;if(r){var t=new URL(e.replace(/^\/api/,""),r),o="";return n&&(o=new URLSearchParams(n).toString()),t.href+(o?"?"+o:"")}},qe=function(e,n){for(var r=(n=(n=n.replace(/\[(\w+)\]/g,".$1")).replace(/^\./,"")).split("."),t=0,o=r.length;t<o;++t){var i=r[t];if(!e||!(i in e))return;e=e[i]}return e},Ue=function(e){var n,r=0;if(0===e.length)return r;for(n=0;n<e.length;n++)r=(r<<5)-r+e.charCodeAt(n),r|=0;return r},Be=function(e,n){void 0===n&&(n="/login");var r=n.includes("://"),t=new URL(r?n:window.location.origin+n);("/"!==e.asPath||r)&&t.searchParams.append("redirect",r?window.location.href:e.asPath),r?window.location.href=t.href:e.push(t.pathname+t.search)};function Me(e,n){void 0===n&&(n=2);var r=Math.pow(10,n);return Math.round(+(e*r).toFixed(2))/r}var $e=[{source:"/api/v4/:path*",destination:"".concat(process.env.NEXT_PUBLIC_API,"/v4/:path*")},{source:"/api/:path*",destination:"".concat(process.env.NEXT_PUBLIC_RESTIFY,"/:path*")},{source:"/utils/:path*",destination:"".concat(process.env.NEXT_PUBLIC_UTILS,"/:path*")}],We=function(){return((new Date).getTime()/1e3|0).toString(16)+"xxxxxxxxxxxxxxxx".replace(/[x]/g,function(){return(16*Math.random()|0).toString(16)}).toLowerCase()},ze={empresa:function(e,n){return je(void 0,void 0,void 0,function(){return ye(this,function(e){switch(e.label){case 0:return n?[4,u.get("/api/v3/auth/business/"+n)]:[2];case 1:if(e.sent().data)throw new Error("La empresa ya se encuentra registrada");return[2]}})})}},Xe={required:function(e){return void 0===e&&(e="El campo es requerido"),{required:!0,message:e}},min:function(e,n){return void 0===n&&(n="Debe tener mínimo ".concat(e.toString()," caracteres")),{min:e,message:n}},max:function(e,n){return void 0===n&&(n="Debe tener máximo ".concat(e.toString()," caracteres")),{max:e,message:n}},email:function(e){return void 0===e&&(e="El correo electrónico no es válido"),{type:"email",message:e}},pattern:function(e,n){return void 0===n&&(n="No cumple el formato requerido"),{pattern:e,message:n}},unico:function(e){return{validator:fe(ze[e],300)}},correos:function(){return{validator:function(e){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];return je(void 0,Ie([e],n,!0),void 0,function(e,n){return void 0===n&&(n=[]),ye(this,function(e){if(n.some(function(e){return!e.includes("@")}))throw new Error("Alguno de los correos no es válido");return[2]})})}}},emissionDeadline:function(e){return void 0===e&&(e="La fecha está fuera de los 4 días hábiles permitidos para la emisión."),{validator:function(n,r){return je(void 0,void 0,void 0,function(){return ye(this,function(n){switch(n.label){case 0:if(!r)return[2];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,u.head("/v4/utils/is-within-transmission-deadline",{params:{date:r.toISOString()}})];case 2:return n.sent(),[3,4];case 3:throw n.sent(),new Error(e);case 4:return[2]}})})}}}},Ye="es-EC",He={currency:function(e,n){return void 0===n&&(n=2),e||(e=0),new Intl.NumberFormat(Ye,{style:"currency",currency:"USD",minimumFractionDigits:"object"==typeof n?n.min:2,maximumFractionDigits:"object"==typeof n?n.max:n}).format("number"==typeof e?e:parseFloat(e))},date:function(e,n){return void 0===n&&(n="DD/MM/YYYY"),he(e).format(n)},dateLiteral:function(e){return new Date(e).toLocaleDateString("es-EC",{weekday:"long",month:"numeric",year:"numeric",day:"numeric"})},completeDate:function(e){return he(e).format("DD/MM/YYYY HH:mm:ss")},month:function(e){return he(e).format("MM/YYYY")},percent:function(e,n){return void 0===n&&(n=2),e||(e=0),new Intl.NumberFormat(Ye,{style:"percent",minimumFractionDigits:n}).format("number"==typeof e?e:parseFloat(e))}},Ge=function(e){var n=ce(),r=Oe().showError,t=be().mutate,o=d(e.sinOptions?null:(e.optionsPath||e.endpoint)+"/get-options",function(e){return je(void 0,void 0,void 0,function(){return ye(this,function(n){switch(n.label){case 0:return[4,u.get(e)];case 1:return[2,n.sent().data]}})})}).data,i=void 0===o?{}:o,a=new URLSearchParams(xe(xe({},e.params),n.query)).toString(),l=e.endpoint+(a?"?"+a:""),s=ge(n.isReady?l:null,function(e){return je(void 0,void 0,void 0,function(){return ye(this,function(n){switch(n.label){case 0:return[4,u.get(e)];case 1:return[2,n.sent().data]}})})},{keepPreviousData:!0}),c=s.data,p=s.error,m=s.isLoading,f=(null==c?void 0:c.data)||[],v=(null==c?void 0:c.total)||0,h=new URLSearchParams(n.query),g=h.get("page"),b=g?parseInt(g):1,x=h.get("limit"),j=x?parseInt(x):20,y={loading:m,dataSource:f,rowKey:"_id",bordered:!0,pagination:{current:b,defaultPageSize:j,total:v},onChange:function(r,t,o){return je(void 0,void 0,void 0,function(){var i,a,l,s,c;return ye(this,function(u){return i=h.toString(),a=new URLSearchParams(i),r.current!==b&&("1"===(l=r.current.toString())?a.delete("page"):a.set("page",l)),r.pageSize!==j&&("20"===(s=r.pageSize.toString())?a.delete("limit"):a.set("limit",s)),Array.isArray(o)||("ascend"===o.order?a.set("sort",o.field):"descend"===o.order?a.set("sort","-"+o.field):a.delete("sort")),c=[],Object.entries(t).forEach(function(n){var r=n[0],t=n[1];t&&0!==t.length?t.some(function(n){return Object.values(e.filtros||{}).some(function(e){return e.value===n})})?(c.push(r),t.forEach(function(e){new URLSearchParams(e).forEach(function(e,n){a.set(n,e)})})):1===t.length&&/\{\$(gte?|lte?)\}/.test(t[0])?a.set(r,t[0]):a.set(r,"{$in}"+t.join(",")):a.delete(r)}),e.filtros&&Object.entries(e.filtros).forEach(function(e){var n=e[0],r=e[1];c.includes(n)||new URLSearchParams(r.value).forEach(function(e,n){a.get(n)===e&&a.delete(n)})}),i!==a.toString()&&n.push({query:Object.fromEntries(a)}),[2]})})}},I=function(){return t(l)};return{data:f,isLoading:m,error:p,options:i,endpoint:e.endpoint,endpointWithHost:Le(e.endpoint),mainroute:n.route,tableProps:y,axios:u,init:I,getOpt:function(e,n,r){var t;void 0===r&&(r=!1);var o=null===(t=i[e])||void 0===t?void 0:t.find(function(e){return e.id===n});return o?r?o.id+" - "+o.description:o.description:""},setData:function(e){return t(l,e,{revalidate:!1})},remove:function(n){return je(void 0,void 0,void 0,function(){var t;return ye(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,u.delete("string"==typeof n?e.endpoint+"/"+n:n.endpoint)];case 1:return o.sent(),I(),[3,3];case 2:return t=o.sent(),r(t),[3,3];case 3:return[2]}})})},cancel:function(n){return je(void 0,void 0,void 0,function(){var t;return ye(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,u.delete("string"==typeof n?e.endpoint+"/"+n+"/cancel":n.endpoint)];case 1:return o.sent(),I(),[3,3];case 2:return t=o.sent(),r(t),[3,3];case 3:return[2]}})})}}},Je=function(e){var o=O.useForm()[0],i=n(!1),a=i[0],l=i[1],s=n(!1),p=s[0],m=s[1],v=ce(),h=Oe(),g=h.showError,b=h.message,x=function(e){var o=t(!1),i=Oe().modal,a=t(0),l=n(0),s=l[0],c=l[1],u=function(){if(!window.confirm("¿Estás seguro que quieres salir?"))throw"Route Canceled";p(),localStorage.removeItem(e)},d=function(e){e.preventDefault()},p=function(){o.current=!1,window.removeEventListener("beforeunload",d),ue.events.off("routeChangeStart",u),localStorage.removeItem(e),c(0)};return r(function(){if(o.current)return a.current!==s&&(window.addEventListener("beforeunload",d),ue.events.on("routeChangeStart",u)),function(){window.removeEventListener("beforeunload",d),ue.events.off("routeChangeStart",u)}},[a.current,s]),{cambiarHashInicial:function(e){var n=Ue(JSON.stringify(e));c(n),a.current=n},cambiarDatosFormulario:function(n){if(o.current&&0!==a.current){var r=JSON.stringify(n),t=Ue(r);c(t),t===a.current?localStorage.removeItem(e):localStorage.setItem(e,r)}},limpiar:p,reanudar:function(){o.current=!0},obtenerDataEmergencia:function(){return je(void 0,void 0,void 0,function(){var n,r;return ye(this,function(t){switch(t.label){case 0:return n=localStorage.getItem(e),[4,new Promise(function(e){if(!n)return e(void 0);i.confirm({title:"Existen datos guardados",icon:Fe.jsx(f,{}),content:"Hubo un cierre inesperado pero los datos fueron guardados temporalmente ¿Deseas recuperarlos?",onOk:function(){return e(JSON.parse(n))},onCancel:function(){return e(void 0)}})})];case 1:return r=t.sent(),o.current=!0,[2,r]}})})}}}(v.asPath),j=t("emitir"),y=t(e.data),I=t(),C=d(e.sinOptions?null:e.endpoint+"/get-options",function(e){return je(void 0,void 0,void 0,function(){return ye(this,function(n){switch(n.label){case 0:return[4,u.get(e)];case 1:return[2,n.sent().data]}})})},{revalidateOnFocus:!1}).data,P=void 0===C?{}:C;r(function(){I.current=e.registroId,I.current||(I.current=e.soloParaInsertar?void 0:v.query.id)},[null==e?void 0:e.registroId,e.soloParaInsertar]);var w=v.asPath.replace(/\/(insert|[\w]*\/edit$)/g,"")||"/",S=function(n){for(var r=[],t=1;t<arguments.length;t++)r[t-1]=arguments[t];return je(void 0,Ie([n],r,!0),void 0,function(n,r){var t,o,i,s,c,d,p,m;return void 0===r&&(r={}),ye(this,function(f){switch(f.label){case 0:if(!0===a)return[2];l(!0),x.limpiar(),t=r.endpoint||e.endpoint,o=r.params||void 0,f.label=1;case 1:return f.trys.push([1,6,,7]),i=void 0,I.current?[4,u.put(t+"/"+I.current,n,{params:o})]:[3,3];case 2:return i=f.sent().data,[3,5];case 3:return[4,u.post(t,n,{params:o})];case 4:i=f.sent().data,f.label=5;case 5:return!0!==r.noRedirect?(b.success("Guardado correctamente"),v.push(w)):l(!1),[2,i];case 6:if(s=f.sent(),l(!1),r.noShowError)throw s;return g(s),c=null===(m=null===(p=null==s?void 0:s.response)||void 0===p?void 0:p.data)||void 0===m?void 0:m.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)})?v.push(w):!r.noRedirect&&c&&c!==I.current?(I.current=c,v.push(w+"/"+c+"/edit")):x.reanudar(),[3,7];case 7:return[2]}})})},N=Fe.jsxs(U,{children:[Fe.jsx(R,{type:"primary",loading:a,onClick:function(){return o.submit()},children:"Guardar"}),Fe.jsx(c,{href:w,children:Fe.jsx(R,{children:"Cancelar"})})]}),F=Fe.jsxs(Fe.Fragment,{children:[Fe.jsx(B,{paragraph:{rows:3,width:"100%"},className:"mb-4"}),Fe.jsx(B,{paragraph:{rows:4,width:"100%"},className:"mb-4"}),Fe.jsxs("div",{className:"grid grid-cols-2 gap-4 mb-4",children:[Fe.jsx(B,{paragraph:{rows:4,width:"100%"}}),Fe.jsx(B,{paragraph:{rows:4,width:"100%"}})]}),Fe.jsxs(U,{children:[Fe.jsx(B.Button,{}),Fe.jsx(B.Button,{})]})]}),k=function(){return b.warning("Revisa los errores del formulario")},E={form:o,autoComplete:"off",initialValues:e.data,onFinish:S,layout:"vertical",onFinishFailed:k};return r(function(){if(e.recuperacionEmergencia){var n=setInterval(function(){if(p){var e=o.getFieldsValue();x.cambiarDatosFormulario(e)}},1e3);return function(){return clearInterval(n)}}},[p]),r(function(){if(v.isReady){I.current=e.soloParaInsertar?void 0:v.query.id;var n=setTimeout(function(){e.soloParaInsertar?m(!0):je(void 0,void 0,void 0,function(){var n,r,t;return ye(this,function(i){switch(i.label){case 0:return n=!1,[4,x.obtenerDataEmergencia()];case 1:return(r=i.sent())?(I.current=r._id,n=!0,[3,4]):[3,2];case 2:return I.current?[4,u.get("".concat(e.endpoint,"/").concat(I.current),{params:e.params})]:[3,4];case 3:r=i.sent().data,i.label=4;case 4:return r?[4,null===(t=e.formatearDataInicial)||void 0===t?void 0:t.call(e,r)]:[3,6];case 5:i.sent(),o.setFieldsValue(r),y.current=r,i.label=6;case 6:return[2,n?e.data:r||e.data]}})}).then(function(n){var r;return Promise.all([x.cambiarHashInicial(n),null===(r=e.onMounted)||void 0===r?void 0:r.call(e)])}).then(function(){return m(!0)})},200);return function(){return clearTimeout(n)}}},[v.query.id,v.isReady,e.soloParaInsertar]),{form:o,router:v,options:P,tipoEmision:j,objectId:I.current,mainroute:w,isLoading:a,isReady:p,data:y.current,endpoint:e.endpoint,axios:u,onSubmit:S,onMainRouter:function(){return v.push(w)},setIsLoading:l,preventor:x,ModoCarga:F,BotonesPorDefecto:N,onMensajeValidacion:k,getOption:function(e,n){var r,t;return(null===(t=null===(r=P[e])||void 0===r?void 0:r.find(function(e){return e.id===n}))||void 0===t?void 0:t.description)||""},formProps:E}},Qe=o(null);function Ke(){return i(Qe)}var Ze=function(e){var r=n([]),t=r[0],o=r[1];return Fe.jsxs(Qe.Provider,{value:{setBitacora:o},children:[Fe.jsx(en,{bitacora:t,setBitacora:o}),e.children]})},en=function(e){return Fe.jsx(M,{title:"Bitácora",placement:"right",closable:!1,open:0!==e.bitacora.length,onClose:function(){return e.setBitacora([])},children:Fe.jsx($,{items:e.bitacora.map(function(e,n){var r=function(e){switch(e){case"created":case"creacion-masiva":return{color:"green"};case"draft":return{color:"orange",icon:Fe.jsx(w,{})};case"failed":return{color:"red",icon:Fe.jsx(P,{})};case"issued":case"used":return{color:"green",icon:Fe.jsx(C,{})};case"sent":return{color:"#1890FF",icon:Fe.jsx(I,{})};case"pre-canceled":return{color:"#FFA500",icon:Fe.jsx(f,{})};case"canceled":case"reversado":return{color:"red",icon:Fe.jsx(y,{})};case"edit":return{color:"#1890FF",icon:Fe.jsx(j,{})};case"email":return{color:"#00CCFF",icon:Fe.jsx(x,{})};case"deleted":return{color:"red",icon:Fe.jsx(b,{})};case"intermitencia":return{color:"red",icon:Fe.jsx(g,{})};case"exit-notice":return{color:"red",icon:Fe.jsx(h,{})};case"exit-notice-deleted":return{color:"green",icon:Fe.jsx(v,{})}}}(e.type);return{color:null==r?void 0:r.color,key:"movimiento"+n,dot:null==r?void 0:r.icon,children:Fe.jsxs(Fe.Fragment,{children:[e.nota," ",Fe.jsx("br",{}),He.completeDate(e.date)]})}})})})},nn="#F34D24",rn=function(e){var t=n(!1),o=t[0],i=t[1];return r(function(){i(!0)},[]),o?Fe.jsx(Ze,{children:Fe.jsx(W,{locale:de,theme:{token:{colorPrimary:nn,colorLink:nn,fontFamily:e.fontFamily||'"Inter", "SF Pro", "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", "Helvetica", "Arial", sans-serif',colorTextDisabled:"#00000080"},components:{Layout:{headerBg:"rgba(245,245,245,0.5)",siderBg:"#0F141E"},Menu:{darkItemBg:"#0F141E",darkSubMenuItemBg:"#0A0E15"},Tag:{marginXS:0}}},children:Fe.jsx(q,{children:Fe.jsx(z,{className:(e.className||"")+" !min-h-screen w-full",style:e.style,children:e.children})})})}):null},tn=function(e){var t=Ke().setBitacora,o=n(!1),i=o[0],l=o[1],s=a(function(){return Array.isArray(e.movimientos)&&0!==e.movimientos.length},[e.movimientos]),c=function(){s&&t(e.movimientos)};return r(function(){var n;l(null===(n=e.movimientos)||void 0===n?void 0:n.some(function(e){return!!e.mostrarBadge}))},[e.movimientos]),Fe.jsx(X,{dot:i,children:e.usarIcono?Fe.jsx(S,{title:"Ver historial",className:s?"":"text-gray-300 cursor-not-allowed",onClick:c}):Fe.jsx(R,{icon:Fe.jsx(S,{}),title:"Ver historial",disabled:!s,onClick:c})})},on=function(e){var r=O.useFormInstance(),t=n([]),o=t[0],i=t[1],l=a(function(){var n=e.rules||[];switch(e.type){case"ruc":return{label:"RUC",placeholder:"Ingresar el RUC",max:13,rules:Ie(Ie([],n,!0),[Xe.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:Ie(Ie([],n,!0),[Xe.pattern(/^[0-9]{10}$/,"La cédula debe tener 10 caracteres numéricos")],!1)};case"rfc":var r=/^[A-Z&Ñ]{4}[0-9]{2}(0[1-9]|1[012])(0[1-9]|[12][0-9]|3[01])[A-Z0-9]{2}[0-9A]$/,t=void 0,o=13;return"01"===e.subjectType?t="Persona física debe tener 13 caracteres":(e.foreing||(o=12,r=/^[A-Z&Ñ]{3}[0-9]{2}(0[1-9]|1[012])(0[1-9]|[12][0-9]|3[01])[A-Z0-9]{2}[0-9A]$/),t="Persona moral debe tener 12 caracteres"),{label:"RFC",placeholder:"Ingresar el RFC",max:o,rules:Ie(Ie([],n,!0),[Xe.pattern(r,t)],!1)};default:return{label:"Nº identificación",placeholder:"Ingresar el número de identificación",rules:n}}},[e.type,e.subjectType,e.foreing]),s=fe(function(n){return je(void 0,void 0,void 0,function(){var r,t;return ye(this,function(a){switch(a.label){case 0:if(!e.campoNombre||n.length<6||!["ci","ruc"].includes(e.type))return 0!==o.length&&i([]),[2];a.label=1;case 1:return a.trys.push([1,3,,4]),[4,u.get("/utils/clientes/buscar",{params:{identificador:n,tipo:"ci"===e.type?"cedula":"ruc"}})];case 2:return r=a.sent().data,i(r.map(function(e){return{value:e.identificador,nombre:e.nombre,label:Fe.jsxs(Fe.Fragment,{children:[Fe.jsx("b",{children:e.identificador}),Fe.jsx("br",{}),e.nombre]})}})),[3,4];case 3:return t=a.sent(),console.error(t),[3,4];case 4:return[2]}})})},500);return Fe.jsx(O.Item,xe({name:e.name,rules:l.rules,normalize:function(e){return e.trim().toUpperCase()},className:e.className,dependencies:e.dependencies},e.hiddenLabel?{}:{label:e.label||l.label},{children:Fe.jsx(Y,{options:o,onSelect:function(n,t){r.setFieldValue(e.campoNombre,t.nombre)},onSearch:s,placeholder:e.placeholder||l.placeholder,maxLength:l.max,disabled:e.disabled,onChange:function(n){var r;return null===(r=e.onChange)||void 0===r?void 0:r.call(e,n)}})}))},an=function(e){var r=n(),t=r[0],o=r[1],i=n(!1),a=i[0],l=i[1];return Fe.jsx(H,{title:"Click para confirmar",open:!!t,children:Fe.jsx(R,{loading:a,title:e.title,disabled:e.disabled,danger:!!t,icon:t?Fe.jsx(N,{}):Fe.jsx(b,{}),onClick:function(){return je(void 0,void 0,void 0,function(){var n;return ye(this,function(r){switch(r.label){case 0:return t?[3,1]:(n=setTimeout(function(){return o(void 0)},1500),o(n),[3,3]);case 1:return l(!0),[4,e.onConfirm()];case 2:r.sent(),o(void 0),clearTimeout(t),l(!1),r.label=3;case 3:return[2]}})})}})})},ln=function(){return{hora:(new Date).toLocaleTimeString(),fecha:(new Date).toLocaleDateString(void 0,{weekday:"long",year:"numeric",month:"long",day:"numeric"})}},sn=function(e){var t=n(ln()),o=t[0],i=t[1];return r(function(){var e=setInterval(function(){return i(ln())},1e3);return function(){return clearInterval(e)}},[]),Fe.jsxs("div",{className:e.className,children:[Fe.jsx("div",{className:"text-3xl font-bold",children:o.hora}),Fe.jsx("div",{className:"text-xl text-gray-500",children:o.fecha})]})},cn=function(e){var r=n([null,null]),t=r[0],o=r[1];return Fe.jsxs("div",{className:"w-64",children:[Fe.jsx("div",{className:"p-2",children:Fe.jsx(G.RangePicker,{value:t,onCalendarChange:function(n){o(n);var r=n[0],t=n[1];if(r&&t){var i=r.startOf("day").toISOString(),a=t.endOf("day").toISOString();e.setSelectedKeys(["{$gte}".concat(i,"{$lte}").concat(a)])}}})}),Fe.jsx(J,{className:"m-0"}),Fe.jsxs("div",{className:"flex p-2 justify-between",children:[Fe.jsx(R,{size:"small",type:"text",onClick:function(){var n;o([null,null]),null===(n=e.clearFilters)||void 0===n||n.call(e),e.confirm()},children:"Reiniciar"}),Fe.jsx(R,{disabled:!t[0]||!t[1],type:"primary",onClick:function(){return e.confirm()},size:"small",children:"Aceptar"})]})]})},un=function(e){var r=n(null),t=r[0],o=r[1],i=ve(t,400)[0],a=d(null===i?null:[e.endpoint,i],function(n){return je(void 0,[n],void 0,function(n){var r,t=n[0],o=n[1];return ye(this,function(n){switch(n.label){case 0:return r=Array.isArray(e.name)?e.name.filter(function(e){return"string"==typeof e}).join("."):e.name,[4,u.get("".concat(t,"/_autocompletado/").concat(r),{params:{q:o}})];case 1:return[2,n.sent().data]}})})}).data,l=void 0===a?[]:a;return Fe.jsx(O.Item,{name:e.name,label:e.label,children:Fe.jsx(Y,{onChange:function(e){return o(e||void 0)},onFocus:function(){return null===t?o(void 0):null},options:l.map(function(e){return{label:e,value:e}}),maxLength:300,placeholder:e.placeholder||"Tipear para buscar"})})},dn=o(null);function pn(){var e=i(dn);if(null===e)throw new Error("useContextoEmpresa debe usarse dentro de EmpresaContext.Provider");return e}var mn=function(e){var t=ce(),o=n(!1),i=o[0],a=o[1],l=n(),s=l[0],c=l[1];return r(function(){je(void 0,void 0,void 0,function(){var e,n,r;return ye(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,Promise.all([u.get("/api/v3/auth/user"),u.get("/api/v3/businesses/me/configurations",{params:{fields:"comprobantes nDecimals invoice"}})])];case 1:return e=t.sent(),n=e[0].data,r=e[1].data,n.configuraciones=r,[2,n];case 2:return t.sent(),[2,null];case 3:return[2]}})}).then(function(n){n?(a(!0),c(n)):Be(t,e.pathLogin)})},[]),i?Fe.jsx(dn.Provider,{value:{business:s,nombreEmpresa:s.business,nombreUsuario:s.user,testEnviroment:s.configs.useTestEnviroment,usuarioEsAdmin:"admin"===s.userType,getPermisos:function(e){var n,r,o,i,a,l,c,u,d,p={leer:!1,escribir:!1,eliminar:!1,anular:!1},m=e||t.route;if("admin"===(null==s?void 0:s.userType))return{leer:!0,escribir:!0,eliminar:!0,anular:!0};var f=m.split("/"),v=f[1],h=f[2],g=null==s?void 0:s.modules.find(function(e){return e.key===v});if(!g)return p;for(var b=0,x=g.submodules;b<x.length;b++){var j=x[b];if(j.key&&j.key===h){p={leer:!!(null===(n=j.permisos)||void 0===n?void 0:n.includes("leer")),escribir:!!(null===(r=j.permisos)||void 0===r?void 0:r.includes("escribir")),eliminar:!!(null===(o=j.permisos)||void 0===o?void 0:o.includes("eliminar")),anular:!!(null===(i=j.permisos)||void 0===i?void 0:i.includes("anular"))};break}var y=null===(a=j.items)||void 0===a?void 0:a.find(function(e){return e.key===h});if(y){p={leer:!!(null===(l=y.permisos)||void 0===l?void 0:l.includes("leer")),escribir:!!(null===(c=y.permisos)||void 0===c?void 0:c.includes("escribir")),eliminar:!!(null===(u=y.permisos)||void 0===u?void 0:u.includes("eliminar")),anular:!!(null===(d=y.permisos)||void 0===d?void 0:d.includes("anular"))};break}}return p},hasModule:function(e,n){var r=null==s?void 0:s.modules.find(function(n){return n.key===e});return!!r&&he(n).isAfter(r.operationDate)}},children:e.children}):Fe.jsx("div",{className:"w-full h-screen flex items-center justify-center",children:"Cargando..."})},fn=function(e){var r=n(!1),t=r[0],o=r[1],i=d(t&&e.autocompletar?"/api/v4/administrative/clients/nombres-info-adicional":null,function(e){return je(void 0,void 0,void 0,function(){return ye(this,function(n){switch(n.label){case 0:return[4,u.get(e)];case 1:return[2,n.sent().data.map(function(e){return{label:e,value:e}})]}})})}).data,a=void 0===i?[]:i;return Fe.jsx(O.List,{name:e.name,children:function(n,r){return Fe.jsxs("div",{children:[Fe.jsxs("div",{className:"flex items-center justify-between mb-4",children:[Fe.jsx(A.Title,{level:4,className:"mb-0",children:"Información adicional"}),Fe.jsx(R,{type:"dashed",onClick:function(){return r.add({})},children:"Agregar"})]}),Fe.jsxs(Q,{dataSource:n,rowClassName:"align-top",bordered:!0,pagination:!1,children:[Fe.jsx(Q.Column,{title:"Nombre",render:function(n){var r=n.name;return Fe.jsx(O.Item,{className:"mb-0",name:[r,"nombre"],rules:[Xe.required()],children:e.autocompletar?Fe.jsx(Y,{options:a,maxLength:300,placeholder:"Ingresar el nombre",onFocus:function(){return o(!0)}}):Fe.jsx(V,{maxLength:300,placeholder:"Ingresar el nombre"})})}},"name"),Fe.jsx(Q.Column,{title:"Descripción",render:function(e){var n=e.name;return Fe.jsx(O.Item,{className:"mb-0",name:[n,"valor"],rules:[Xe.required()],children:Fe.jsx(V,{placeholder:"Ingresar la descripción"})})}},"description"),Fe.jsx(Q.Column,{width:1,render:function(e){var n=e.name;return Fe.jsx(an,{title:"¿Eliminar información adicional?",onConfirm:function(){return r.remove(n)}})}},"opciones")]})]})}})},vn=function(){var e=n(""),r=e[0],t=e[1],o=d("/api/v4/administrative/clients/etiquetas",function(e){return je(void 0,void 0,void 0,function(){return ye(this,function(n){switch(n.label){case 0:return[4,u.get(e)];case 1:return[2,n.sent().data.etiquetas]}})})}).data,i=a(function(){return r?null==o?void 0:o.filter(function(e){var n;return null===(n=e.toLowerCase())||void 0===n?void 0:n.includes(r)}):o},[r,o]);return Fe.jsx(O.Item,{name:"etiquetas",label:"Etiquetas",children:Fe.jsx(Y,{onSearch:function(e){return t(e||"")},options:null==i?void 0:i.map(function(e){return{label:e,value:e}}),placeholder:"Ingresar o seleccionar una etiqueta"})})},hn=l(function(e,n){var r,t,o=pn().hasModule,i=Je({endpoint:"/api/v3/administrative/"+e.type+"s",params:{$getAllFields:"true"},data:{id:void 0,idType:"04",subjectType:"01",direcciones:[],address:"",name:void 0},soloParaInsertar:!0===e.ocultarBotones}),l="client"===e.type,c="provider"===e.type,p="transporter"===e.type,m="grid grid-cols-1 md:grid-cols-2 gap-x-4",f=d(c?["/api/v3/administrative/compras/get-options","SustentosDeComprobantes"]:null,function(e){return je(void 0,[e],void 0,function(e){var n=e[0];return ye(this,function(e){switch(e.label){case 0:return[4,u.get(n)];case 1:return[2,e.sent().data.SustentosDeComprobantes.filter(function(e){return e.tiposDeComprobantes.includes("1")}).map(function(e){return{label:"".concat(e.id,": ").concat(e.description),value:e.id}})]}})})}).data,v=void 0===f?[]:f,h=O.useWatch("idType",i.form),g=a(function(){switch(h){case"04":return"ruc";case"05":return"ci";default:return"other"}},[h]),b=d(l&&"08"===h?"/api/v3/administrative/retenciones-v2/get-options":null,function(e){return je(void 0,void 0,void 0,function(){var n,r;return ye(this,function(t){switch(t.label){case 0:return[4,u.get(e)];case 1:return n=t.sent().data,[2,null===(r=n.PaisesParaisosFiscales)||void 0===r?void 0:r.map(function(e){return{label:e.description,value:parseInt(e.id)}})]}})})}).data;return s(n,function(){return{form:i.form,onSubmit:i.onSubmit}}),Fe.jsxs(O,xe({},i.formProps,{layout:"vertical",children:[Fe.jsx(K,{items:[{key:"general",label:"General",children:Fe.jsxs("div",{className:m,children:[Fe.jsx(O.Item,{name:"idType",label:"Tipo de identificación",rules:[Xe.required()],children:Fe.jsx(_,{options:null===(r=i.options.TiposDeIdentificacion)||void 0===r?void 0:r.map(function(e){return{label:e.description,value:e.id}})})}),Fe.jsx(on,{name:"id",campoNombre:"name",type:g,rules:[Xe.required()]}),Fe.jsx(O.Item,{name:"name",label:"Nombres / Razón social",rules:[Xe.required()],children:Fe.jsx(V,{placeholder:"Ingresar la razón social"})}),Fe.jsx(O.Item,{name:"subjectType",label:"Tipo de sujeto",rules:[Xe.required()],children:Fe.jsx(_,{options:null===(t=i.options.TiposDePersona)||void 0===t?void 0:t.map(function(e){return{label:e.description,value:e.id}})})}),Fe.jsx(O.Item,{name:"phone",label:"Télefono",children:Fe.jsx(V,{type:"phone",placeholder:"Ingresar el teléfono"})}),Fe.jsx(O.Item,{name:"email",label:"Correo electrónico",rules:[Xe.email()],normalize:function(e){return null==e?void 0:e.trim()},children:Fe.jsx(V,{placeholder:"Ingresar el correo electrónico"})}),Fe.jsx(O.Item,{name:"address",label:"Dirección",children:Fe.jsx(V,{placeholder:"Ingresar la dirección"})}),l&&Fe.jsx(Nn,{name:"vendedor",type:"sellers"})]})},{key:"other-information",label:"Otra información",children:Fe.jsxs("div",{children:[Fe.jsxs("div",{className:m,children:[l&&o("treasury")?Fe.jsxs(Fe.Fragment,{children:[Fe.jsx(O.Item,{name:"creditQuotaDollars",label:"Cupo de crédito en dólares",children:Fe.jsx(Z,{className:"!w-full",precision:2,min:0,prefix:"$",placeholder:"Ingresar el cupo de crédito en dólares"})}),Fe.jsx(O.Item,{name:"creditQuotaDays",label:"Cupo de crédito en días",children:Fe.jsx(Z,{className:"!w-full",precision:0,min:0,placeholder:"Ingresar el cupo de crédito en días"})})]}):null,l&&Fe.jsx(O.Item,{name:"descuento",label:"Descuento adicional para facturas",children:Fe.jsx(Z,{className:"!w-full",precision:2,max:100,suffix:"%",placeholder:"Ingresar el descuento"})}),c&&o("contability")&&Fe.jsx(Nn,{name:"accountingAccount",type:"cuentas-contables"}),(c||l)&&o("contability")&&Fe.jsx(Nn,{type:"cost-centers",name:"costCenter"}),c&&o("treasury")&&Fe.jsx(O.Item,{name:"diasPlazo",label:"Días plazo",children:Fe.jsx(Z,{className:"!w-full",precision:0,min:0,placeholder:"Ingresar los días plazo"})}),c&&Fe.jsx(O.Item,{label:"Sustento de factura",name:"sustentoFactura",tooltip:"Es el sustento de comprobante por defecto para las facturas emitidas por este proveedor (compras).",children:Fe.jsx(_,{options:v,placeholder:"Seleccionar el sustento para factura",showSearch:!0,allowClear:!0,onClear:function(){return setTimeout(function(){return i.form.setFieldValue("sustentoFactura",null)},100)}})}),p?Fe.jsx(O.Item,{name:"licensePlate",label:"Placa",rules:[Xe.required()],children:Fe.jsx(_,{mode:"tags",placeholder:"Ingresar una o varias placas",open:!1,suffixIcon:null})}):null,l&&"08"===h&&Fe.jsx(O.Item,{name:"paisExportacion",label:"País de exportación",children:Fe.jsx(_,{allowClear:!0,showSearch:!0,placeholder:"Seleccionar el país de exportación",optionFilterProp:"children",filterOption:function(e,n){var r;return(null!==(r=null==n?void 0:n.label)&&void 0!==r?r:"").toLowerCase().includes(e.toLowerCase())},options:b})}),l&&Fe.jsx(vn,{})]}),Fe.jsx("div",{className:"mb-5",children:Fe.jsx(fn,{name:"informacionAdicional",autocompletar:!0})})]})}]}),e.ocultarBotones?null:i.BotonesPorDefecto]}))}),gn=function(e){return Fe.jsx(O.List,{name:"relaciones",children:function(n,r){return Fe.jsxs(Fe.Fragment,{children:[Fe.jsx("div",{className:"flex items-center justify-end mb-6",children:Fe.jsx(R,{type:"dashed",onClick:function(){return r.add({cantidad:0,precio:0})},children:"Agregar relación"})}),Fe.jsxs(Q,{dataSource:n,rowClassName:"align-top",children:[Fe.jsx(Q.Column,{title:"Nombre",render:function(n){var r=n.name;return Fe.jsx(Nn,{className:"m-0 p-0",name:[r,"producto"],label:null,params:{tipoProducto:["receta","fabricado"].includes(e.tipoProduct)?"insumo":"{$in}producto,receta"},type:"products",onSelect:function(n){return function(n,r){var t,o;void 0===n&&(n={});var i=e.form.getFieldValue("relaciones");i[r].producto&&(null!==(t=(o=i[r]).cantidad)&&void 0!==t||(o.cantidad=1),i[r].precio=n.price,e.form.setFieldValue("relaciones",i))}(n,r)}})}},"name"),Fe.jsx(Q.Column,{title:"Nota",render:function(e){var n=e.name;return Fe.jsx(O.Item,{className:"m-0 p-0",name:[n,"nota"],children:Fe.jsx(V,{placeholder:"Ingresar una nota"})})}},"nota"),Fe.jsx(Q.Column,{title:"Cantidad",render:function(e){var n=e.name;return Fe.jsx(O.Item,{className:"m-0 p-0",name:[n,"cantidad"],rules:[Xe.required(),{validator:function(e,n){return n>0?Promise.resolve():Promise.reject(new Error("La cantidad debe ser mayor que 0"))}}],children:Fe.jsx(Z,{className:"!w-full",min:0,placeholder:"Ingresar la cantidad"})})}},"cantidad"),Fe.jsx(Q.Column,{align:"center",render:function(e){var n=e.name;return Fe.jsx(an,{title:"¿Eliminar relación?",onConfirm:function(){return r.remove(n)}})}},"opciones")]})]})}})},bn=function(e){var o=n(!0),i=o[0],a=o[1],l=n([]),s=l[0],c=l[1],d=t(""),p=Oe().showError;r(function(){e.url?(d.current=e.url,m()):u.get("/api/v3/businesses/me/configurations",{params:{fields:"impresoras"}}).then(function(e){var n,r=e.data;return d.current=null===(n=null==r?void 0:r.impresoras)||void 0===n?void 0:n.servidor,m()}).catch(function(e){return p(e)})},[]);var m=function(){return je(void 0,void 0,void 0,function(){var e,n;return ye(this,function(r){switch(r.label){case 0:if(!d.current)return[2];r.label=1;case 1:return r.trys.push([1,3,4,5]),a(!0),[4,u.get("".concat(d.current,"/get-printers"))];case 2:return(e=r.sent().data)&&c(null==e?void 0:e.map(function(e){return{id:e.deviceId,descripcion:e.name}})),[3,5];case 3:return n=r.sent(),console.error(n),[3,5];case 4:return a(!1),[7];case 5:return[2]}})})};return Fe.jsx(O.Item,{label:"Impresora",name:"impresora",children:Fe.jsx(_,{placeholder:"Seleccione una impresora",loading:i,allowClear:!0,options:null==s?void 0:s.map(function(e){return{label:"".concat(e.descripcion),value:e.id}}),onClear:function(){setTimeout(function(){e.form.setFieldValue("impresora",null)},300)}})})},xn=function(e){var t=O.useFormInstance(),o=O.useForm()[0],i=n(!1),a=i[0],l=i[1];return r(function(){if(a){var e=localStorage.getItem("porcentaje-ganancia");o.setFieldValue("porcentaje",null!==e?parseInt(e):0)}},[a]),Fe.jsx(ne,{open:a,onOpenChange:function(e){return l(e)},content:Fe.jsxs(O,{form:o,layout:"vertical",autoComplete:"off",initialValues:{valorInicial:0,porcentaje:0},onFinish:function(n){var r=Me(n.valorInicial*(1+n.porcentaje/100)),o=t.getFieldValue(e.name),i=e.getPrecio(o,"final"),a=Me(100*(1-(r||0)/i));0!==i&&a>0?t.setFieldValue("descuento",a):(t.setFieldValue("descuento",0),t.setFieldValue(e.name,e.getPrecio(r||0,"base")))},children:[Fe.jsxs("div",{className:"grid grid-cols-1 gap-x-2",children:[Fe.jsx(O.Item,{label:"Costo o precio de compra",name:"valorInicial",rules:[Xe.required()],children:Fe.jsx(Z,{placeholder:"Ingresar valor inicial",min:0,precision:2,className:"!w-full"})}),Fe.jsx(O.Item,{label:"Porcentaje de ganancia",name:"porcentaje",children:Fe.jsx(Z,{placeholder:"Ingresar el porcentaje de ganacia esperado",min:0,max:100,prefix:"%",precision:2,className:"!w-full",onChange:function(e){"number"==typeof e&&localStorage.setItem("porcentaje-ganancia",JSON.stringify(e))}})}),Fe.jsx(O.Item,{noStyle:!0,shouldUpdate:function(e,n){return JSON.stringify(e)!==JSON.stringify(n)},children:function(e){var n=e.getFieldValue,r=n("valorInicial"),t=n("porcentaje");return Fe.jsxs("div",{className:"mb-3",children:[Fe.jsx(A.Text,{strong:!0,className:"mr-2",children:"Precio referencial de venta:"}),He.currency(r*(1+t/100))]})}})]}),Fe.jsx("div",{children:Fe.jsx(R,{htmlType:"submit",type:"primary",block:!0,children:"Cambiar precio"})})]}),trigger:"click",children:Fe.jsx(R,{title:"Calcular precio final",icon:Fe.jsx(f,{}),className:"flex-shrink-0"})})},jn=function(e){var n=e.name||"price";return Fe.jsxs(Fe.Fragment,{children:[Fe.jsx(O.Item,{label:"Sin impuestos",name:n,children:Fe.jsx(Z,{min:0,precision:6,className:"!w-full",prefix:"$",placeholder:"Ingresar el precio unitario"})}),Fe.jsx(O.Item,{label:"Con impuestos",tooltip:"Modificar este campo cambia el precio sin impuestos",shouldUpdate:function(e,r){return e[n]!==r[n]},children:function(r){var t=r.getFieldValue,o=r.setFieldValue;return Fe.jsx(Z,{placeholder:"Ingresar el precio unitario",min:0,precision:2,className:"!w-full",prefix:"$",value:e.getPrecio(t(n),"final"),onChange:function(r){return o(n,e.getPrecio(r||0,"base"))}})}}),Fe.jsx(O.Item,{label:"Descuento",name:"descuento",children:Fe.jsx(Z,{placeholder:"Ingresar el porcentaje del descuento",min:0,max:100,suffix:"%",precision:2,className:"!w-full"})}),Fe.jsx(O.Item,{label:"Precio final",tooltip:"Modificar este campo cambia el descuento, si el valor es superior al precio con impuestos se cambia el precio sin impuestos y el descuento a 0",children:Fe.jsxs("div",{className:"w-full flex gap-x-2",children:[Fe.jsx(O.Item,{noStyle:!0,shouldUpdate:function(e,r){return e[n]!==r[n]||e.descuento!==r.descuento},children:function(r){var t=r.getFieldValue,o=r.setFieldValue,i=t(n),a=t("descuento");return Fe.jsx(Z,{value:e.getPrecio(i,"final",a),placeholder:"Ingresar el precio final",min:0,precision:2,prefix:"$",className:"!w-full",onChange:function(r){var t=e.getPrecio(i,"final"),a=Me(100*(1-(r||0)/t));0!==t&&a>0?o("descuento",a):(o("descuento",0),o(n,e.getPrecio(r||0,"base")))}})}}),Fe.jsx(xn,{name:n,getPrecio:e.getPrecio})]})})]})},yn=function(e){var n,r,t,o=e.form,i=O.useWatch("iva",o),a=O.useWatch("ice",o),l=O.useWatch("icePercentage",o),s=O.useWatch("irbpnr",o),c=!!a,u=!!s;return Fe.jsxs(Fe.Fragment,{children:[Fe.jsx("div",{className:"grid md:grid-cols-2 gap-x-4",children:Fe.jsx(jn,{getPrecio:function(n,r,t){var o,c,u;void 0===n&&(n=0);var d=1;if(a)if("number"==typeof l)d+=l/100;else{var p=null===(o=e.options.PorcentajesDeICE)||void 0===o?void 0:o.find(function(e){return e.id===a});d+=(null==p?void 0:p.value)||0}if(s){var m=null===(c=e.options.PorcentajesDeIRBPNR)||void 0===c?void 0:c.find(function(e){return e.id===s});d+=(null==m?void 0:m.value)||0}var f=null===(u=e.options.PorcentajesDeIVA)||void 0===u?void 0:u.find(function(e){return e.id===i});return d*=1+((null==f?void 0:f.value)||0),"number"==typeof t&&(d*=1-(t||0)/100),Me("final"===r?n*d:n/d,"final"===r?2:6)}})}),Fe.jsx(A.Title,{level:4,children:"Impuestos aplicables"}),Fe.jsxs("div",{className:"grid grid-cols-6",children:[Fe.jsx("div",{className:"col-span-2 pt-2",children:Fe.jsx(ee,{checked:!0,disabled:!0,children:"IVA"})}),Fe.jsx("div",{className:"col-span-4",children:Fe.jsx(O.Item,{name:"iva",rules:[Xe.required()],children:Fe.jsx(_,{options:null===(n=e.options.PorcentajesDeIVA)||void 0===n?void 0:n.map(function(e){return{label:e.id+" - "+e.description,value:e.id}})})})}),Fe.jsx("div",{className:"col-span-2 pt-2",children:Fe.jsx(ee,{checked:c,onChange:function(e){c||(o.setFieldValue("ice","3023"),o.setFieldValue("icePercentage",150)),c&&!e.target.checked&&(o.setFieldValue("ice",null),o.setFieldValue("icePercentage",null))},children:"ICE"})}),Fe.jsx("div",{className:"col-span-4",children:Fe.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-3 gap-4 w-full",children:[Fe.jsx(O.Item,{className:"lg:col-span-2 m-0",name:"ice",children:Fe.jsx(_,{placeholder:"Seleccione el impuesto del ICE",disabled:!c,options:null===(r=e.options.PorcentajesDeICE)||void 0===r?void 0:r.map(function(e){var n="number"==typeof e.value?He.percent(e.value):"N/A";return{value:e.id,label:"".concat(e.id," - ").concat(n," - ").concat(e.description)}}),onChange:function(n){var r=e.options.PorcentajesDeICE.find(function(e){return e.id===n});o.setFieldValue("icePercentage","number"==typeof(null==r?void 0:r.value)?100*r.value:0)}})}),Fe.jsx(O.Item,{className:"m-0",name:"icePercentage",rules:c?[Xe.required()]:[],children:Fe.jsx(Z,{disabled:!c,placeholder:"Porcentaje de ICE",precision:2,className:"!w-full"})})]})}),Fe.jsx("div",{className:"col-span-2 pt-2",children:Fe.jsx(ee,{checked:u,onChange:function(e){u||o.setFieldValue("irbpnr","5001"),u&&!e.target.checked&&o.setFieldValue("irbpnr",null)},children:"IRBPNR"})}),Fe.jsx("div",{className:"col-span-4",children:Fe.jsx(O.Item,{name:"irbpnr",children:Fe.jsx(_,{placeholder:"Seleccione el IRBPNR",disabled:!u,options:null===(t=e.options.PorcentajesDeIRBPNR)||void 0===t?void 0:t.map(function(e){return{label:"".concat(e.id," - ").concat(100*((null==e?void 0:e.value)||0),"% - ").concat(e.description),value:e.id}})})})})]})]})},In=function(e){var r,t,o,i=n(""),a=i[0],l=i[1],s=ve(a,500)[0],c=n(!1),d=c[0],p=c[1],m=ge((null===(r=e.value)||void 0===r?void 0:r.length)||d&&"string"==typeof s?["/api/v3/production/categorias",d||null===(t=e.value)||void 0===t?void 0:t[0],s]:null,function(e){return je(void 0,[e],void 0,function(e){var n,r=e[0],t=e[1],o=e[2];return ye(this,function(e){switch(e.label){case 0:return(n=new URLSearchParams).set("fields","nombre color"),t&&n.set("_id",t),o&&n.set("q",o),[4,u.get(r,{params:n})];case 1:return[2,e.sent().data.data]}})})}),f=m.data,v=m.isLoading;return Fe.jsx(_,{value:null===(o=e.value)||void 0===o?void 0:o[0],allowClear:!0,onClear:function(){return l("")},showSearch:!0,loading:v,filterOption:!1,onSearch:function(e){return l(e)},placeholder:"Seleccionar las categorias",onChange:function(n){var r;p(!0),null===(r=e.onChange)||void 0===r||r.call(e,[n])},onFocus:function(){(null==f?void 0:f.length)||p(!0)},options:null==f?void 0:f.map(function(e){return{label:decodeURIComponent(e.nombre),value:e._id}})})},Cn=l(function(e,t){var o=Je({endpoint:e.tipoPorDefecto&&"producto"!==e.tipoPorDefecto?"/api/v3/production/services":"/api/v3/production/products",params:{$getAllFields:"true"},data:{type:"servicio"===e.tipoPorDefecto?"service":"product",code:"",accountingAccount:void 0,iva:"4",aditionalInformation:[],bodegas:[],descripciones:[],precios:[],tipoProducto:"producto",relaciones:[],ObjetoImp:"02"},soloParaInsertar:!0===e.ocultarBotones,formatearDataInicial:function(e){return je(void 0,void 0,void 0,function(){var n,r,t,o,i,a;return ye(this,function(l){switch(l.label){case 0:return e.precios?0===e.precios.length?[2]:(n=e.precios.filter(function(e){return e.cliente}),0===n.length?[2]:[4,u.get("/api/v3/administrative/clients",{params:{_id:"{$in}".concat(n.map(function(e){return e.cliente}).join(","))}})]):[2];case 1:for(r=l.sent().data,t=function(e){if(!e.cliente)return"continue";var n=r.data.find(function(n){return n._id===e.cliente});e.cliente={_id:n._id,nombre:n.name}},o=0,i=e.precios;o<i.length;o++)a=i[o],t(a);return[2]}})})}}),i=pn().hasModule,a=n([]),l=a[0],c=a[1],d=O.useWatch("type",o.form),p=O.useWatch("tipoProducto",o.form);s(t,function(){return{form:o.form,onSubmit:o.onSubmit}}),r(function(){i("restaurantes")&&u.get("/api/v3/businesses/me/configurations",{params:{fields:"restaurantes"}}).then(function(e){var n,r=e.data,t=(null===(n=null==r?void 0:r.restaurantes)||void 0===n?void 0:n.categorias.filter(function(e){return"activo"===e.estado}))||[];c(t)})},[]);var m=[{key:"precios",label:"Precios",children:Fe.jsx(yn,{form:o.form,options:o.options})}];return["receta","combo","fabricado"].includes(p)&&m.push({key:"relaciones",label:"Relaciones",children:Fe.jsx(gn,{form:o.form,tipoProduct:p})}),i("contability")&&m.push({key:"contabilidad",label:"Contabilidad",children:Fe.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-x-6",children:[Fe.jsx(Nn,{label:"Cuenta contable de venta",name:"accountingAccount",type:"cuentas-contables"}),"product"===d&&Fe.jsxs(Fe.Fragment,{children:[Fe.jsx(Nn,{label:"Cuenta contable de costo",name:"accountingAccountCost",type:"cuentas-contables"}),Fe.jsx(Nn,{label:"Cuenta contable de inventario",name:"cuentaContableInventario",type:"cuentas-contables"})]})]})}),i("restaurantes")&&m.push({key:"restaurantes",label:"Restaurantes",children:Fe.jsxs("div",{children:[Fe.jsx(O.Item,{name:"paraRestaurantes",valuePropName:"checked",noStyle:"producto"===e.tipoPorDefecto,children:Fe.jsxs(ee,{children:["Usar el ","product"===d?"producto":"servicio"," en módulo de restaurantes"]})}),"producto"===e.tipoPorDefecto?Fe.jsx(O.Item,{name:"NoAplicaServicio",valuePropName:"checked",children:Fe.jsx(ee,{children:"No aplicar servicio"})}):null,Fe.jsxs("div",{className:"grid sm:grid-cols-2 gap-x-6",children:[Fe.jsx(bn,{form:o.form}),Fe.jsx(O.Item,{label:"Categoría",name:"categoriasRestaurantes",children:Fe.jsx(_,{mode:"multiple",placeholder:"Seleccione las categorias",options:null==l?void 0:l.map(function(e){return{label:e.nombre,value:e._id}})})})]})]})}),Fe.jsxs(O,{form:o.form,layout:"vertical",autoComplete:"off",initialValues:o.data,onFinish:function(){var e=o.form.getFieldsValue();e.precios=e.precios.map(function(e){var n;return xe(xe({},e),{cliente:null===(n=e.cliente)||void 0===n?void 0:n._id})}),o.onSubmit(e)},children:[Fe.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-x-4",children:[Fe.jsx(O.Item,{name:"type",label:"Tipo",rules:[Xe.required()],className:e.tipoPorDefecto?"hidden":"",children:Fe.jsx(_,{options:[{label:"Producto",value:"product"},{label:"Servicio",value:"service"}]})}),"product"===d&&Fe.jsx(O.Item,{name:"tipoProducto",label:"Tipo producto",rules:[Xe.required()],children:Fe.jsx(_,{options:[{label:"Producto",value:"producto"},{label:"Combo",value:"combo"},{label:"Insumo",value:"insumo"},{label:"Producto con receta",value:"receta"},{label:"Producto fabricado",value:"fabricado"}],onChange:function(e){"producto"!==e&&"insumo"!==e||o.form.setFieldValue("relaciones",[])}})}),Fe.jsx(O.Item,{name:"code",label:"Código principal",rules:[Xe.required(),Xe.max(300)],children:Fe.jsx(V,{placeholder:"Ingresar el código principal"})}),Fe.jsx(O.Item,{label:"Código auxiliar",name:"auxiliarCode",children:Fe.jsx(V,{placeholder:"Ingresar el código auxiliar",maxLength:25})}),Fe.jsx(O.Item,{label:"Descripción",name:"description",rules:[Xe.required(),Xe.max(300)],children:Fe.jsx(V,{placeholder:"Ingresar una descripción",maxLength:300})}),"product"===d&&Fe.jsxs(Fe.Fragment,{children:[Fe.jsx(un,{name:"claveUnidad",label:"Unidad",endpoint:"/api/v4/production/products"}),Fe.jsx(O.Item,{name:"categorias",label:"Categoría",children:Fe.jsx(In,{})})]})]}),Fe.jsx(K,{className:"mb-6",items:m}),e.ocultarBotones?null:o.BotonesPorDefecto]})}),Pn=function(e){var n=e.type;switch(e.options,n){case"mesas":return{label:"Mesa",endpoint:"/api/v4/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:"/api/v4/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:"/api/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}};case"cost-centers":return{label:"Centro de costos",endpoint:"/api/v3/contability/cost-centers",params:{fields:"code description"},field:"code",placeholder:"Ingrese el código del centro de costos",title:function(e){return e.code},subtitle:function(e){return e.description}};case"sellers":return{label:"Vendedor",endpoint:"/api/v3/administrative/sellers",params:{fields:"name",estado:"activo"},field:"name",placeholder:"Ingrese el nombre del vendedor",title:function(e){return e.name}};case"clients":return{withOptions:!0,label:"Cliente",endpoint:"/api/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},modal:{title:"Insertar cliente",getTexto:function(e){return e.name},componente:function(e){return Fe.jsx(hn,{ref:e.ref,type:"client",ocultarBotones:!0})}}};case"providers":return{withOptions:!0,label:"Proveedor",endpoint:"/api/v3/administrative/providers",params:{fields:"idType id name diasPlazo phone email",estado:"activo"},field:"id",placeholder:"Ingrese la identificación del proveedor",title:function(e){return"".concat(e.id)},subtitle:function(e){return e.name},modal:{title:"Insertar proveedor",getTexto:function(e){return e.name},componente:function(e){return Fe.jsx(hn,{ref:e.ref,type:"provider",ocultarBotones:!0})}}};case"products":return{label:"Producto",endpoint:"/api/v3/production/products",params:{fields:"code description price total claveUnidad precioFinal descuento auxiliarCode",sort:"code",status:"active"},field:"code",placeholder:"Ingrese el código del producto",title:function(e){return e.code},subtitle:function(e){return e.description},modal:{itemNoEncontrado:"Producto no existe en tu inventario ¿Deseas registrarlo?",title:"Productos",getTexto:function(e){return e.description},componente:function(e){return Fe.jsx(Cn,{ref:e.ref,tipoPorDefecto:"producto",ocultarBotones:!0,bordered:!1})}}};case"products-services":return{label:"Producto",endpoint:"/api/v4/production/products-services",params:{fields:"code description price total iva claveUnidad",sort:"code",status:"active"},field:"code",placeholder:"Ingrese el código del producto",title:function(e){return e.code},subtitle:function(e){var n=e.description;return n="product"===e.type?Fe.jsxs(Fe.Fragment,{children:["Producto: ",n,!["combo","receta"].includes(e.tipoProducto)&&Fe.jsxs("div",{className:"text-sm",children:["En stock: ",e.total]})]}):"Servicio: ".concat(n)},formItemTexto:function(e){return e.description},modal:{itemNoEncontrado:"El producto o servicio no se encuentra registrado ¿Desea registrarlo?",title:"Productos y servicios",getTexto:function(e){return e.description},componente:function(e){return Fe.jsx(Cn,{ref:e.ref,ocultarBotones:!0,bordered:!1})}}};case"services":return{label:"Servicio",endpoint:"/api/v3/production/services",params:{fields:"code description price total iva",sort:"code",status:"active"},field:"code",placeholder:"Ingresar el código del servicio",title:function(e){return e.code},subtitle:function(e){return e.description},modal:{itemNoEncontrado:"Servicio no existe en el inventario ¿Desea registrarlo?",title:"Servicios",getTexto:function(e){return e.description},componente:function(e){return Fe.jsx(Cn,{ref:e.ref,tipoPorDefecto:"servicio",ocultarBotones:!0,bordered:!1})}}};default:return}},wn=function(e){return Pn=e},Sn=function(e){var o=Oe().message,i=pn().getPermisos,l=e.fieldValue||e.config.customDocumentId||"_id",s=n(!1),c=s[0],p=s[1],m=n(),f=m[0],v=m[1],h=n(!1),g=h[0],b=h[1],x=n(!1),j=x[0],y=x[1],I=t(!1),C=n(""),P=C[0],w=C[1],S=t(null),N=a(function(){var n,r=new URLSearchParams(xe(xe(xe({limit:"50"},e.config.params),e.params),e.value?(n={},n[l]=e.value,n):P?{q:P}:{})).toString();return r?"?"+r:""},[e.value,P,e.params]),E=d(c?e.config.endpoint+N:null,function(e){return je(void 0,void 0,void 0,function(){return ye(this,function(n){switch(n.label){case 0:return[4,u.get(e)];case 1:return[2,n.sent().data.data]}})})},{keepPreviousData:!0}),D=E.data,R=E.isLoading,O=a(function(){var n;if(!e.canCreate||!e.config.modal)return!1;switch(e.type){case"clients":case"clients-mx":case"products-services":case"products":case"providers":case"cuentas-contables-mx":case"transporters":return!!(null===(n=i("/administrative/"+e.type))||void 0===n?void 0:n.escribir);default:return!1}},[e.type,e.canCreate,e.config.modal]);r(function(){if(!L&&void 0!==f){var e=setTimeout(function(){w(f),p(!0)},500);return function(){return clearTimeout(e)}}},[f]);var _=a(function(){return(null==D?void 0:D.map(function(n){var r,t,o=qe(n,l),i=e.config.title(n),a=null===(t=(r=e.config).subtitle)||void 0===t?void 0:t.call(r,n);return{key:o,value:o,texto:a,item:n,label:Fe.jsxs("div",{children:[Fe.jsxs("div",{children:[Fe.jsx("b",{className:"mr-2",children:i}),e.value===o?Fe.jsx(F,{twoToneColor:"#52c41a"}):void 0]}),a?Fe.jsx("div",{className:"text-wrap",children:a}):null]})}}))||[]},[e.value,D]),L=a(function(){if(e.value)return null==D?void 0:D.find(function(n){return qe(n,l)===e.value})},[e.value,D]),q=a(function(){return!0===R?Fe.jsx(k,{}):L&&!e.fillWhileTyping?Fe.jsx(F,{twoToneColor:"#52c41a"}):Fe.jsx("span",{})},[R,L,e.fillWhileTyping]);return r(function(){e.value&&p(!0)},[e.value]),r(function(){var n,r;if(L){var t=qe(L,e.config.field),o=(null===(n=e.config.getFormItemExtra||e.config.subtitle)||void 0===n?void 0:n(L))||"";e.setExtra(o),v(t),p(!1)}else e.setExtra("");(I.current||e.ejecutarSelect)&&(null===(r=e.onSelect)||void 0===r||r.call(e,L||null))},[L]),Fe.jsxs(Fe.Fragment,{children:[O?Fe.jsx(T,{title:e.config.modal.title,open:g,width:640,zIndex:1100,maskClosable:!1,confirmLoading:j,onOk:function(){return je(void 0,void 0,void 0,function(){var n,r,t,i,a,s;return ye(this,function(c){switch(c.label){case 0:n=S.current,r=n.form,t=n.onSubmit,c.label=1;case 1:return c.trys.push([1,3,,4]),[4,r.validateFields()];case 2:return c.sent(),[3,4];case 3:return c.sent(),[2,o.warning("Revisa los errores del formulario")];case 4:return y(!0),i=r.getFieldsValue(),[4,t(i,{noRedirect:!0})];case 5:return a=c.sent(),y(!1),a?(r.resetFields(),null===(s=e.onChange)||void 0===s||s.call(e,a[l]),b(!1),[2]):[2]}})})},onCancel:function(){return b(!1)},children:e.config.modal.componente({ref:S})}):null,Fe.jsx(Y,{options:_,allowClear:e.allowClear,value:f,popupRender:function(e){return Fe.jsxs(Fe.Fragment,{children:[O?Fe.jsxs(Fe.Fragment,{children:[Fe.jsx(A.Link,{className:"block !px-3 !pt-1",onClick:function(){return b(!0)},children:"Añadir nuevo"}),Fe.jsx(J,{className:"!m-1"})]}):null,e]})},notFoundContent:"Sin resultados",disabled:e.disabled,onFocus:function(){e.value||p(!0)},onSelect:function(n){var r;I.current=!0,p(!1),null===(r=e.onChange)||void 0===r||r.call(e,n)},onSearch:function(n){var r,t;e.fillWhileTyping?null===(r=e.onChange)||void 0===r||r.call(e,n):e.value&&(null===(t=e.onChange)||void 0===t||t.call(e,null)),v(n)},children:Fe.jsx(V,{placeholder:e.placeholder||e.config.placeholder,suffix:q})})]})};Sn.displayName="SeekerAutoComplete";var Nn=function(e){var r,o,i,l,s=n(""),c=s[0],p=s[1],m=(r={type:e.type,params:e.params},o=t({}),i=a(function(){return Pn({type:r.type,options:o.current,params:r.params})},[r.type]),l=d((null==i?void 0:i.withOptions)?i.endpoint+"/get-options":null,function(e){return je(void 0,void 0,void 0,function(){return ye(this,function(n){switch(n.label){case 0:return[4,u.get(e)];case 1:return[2,n.sent().data]}})})},{revalidateOnFocus:!1}).data,l&&(o.current=l),i);return m?Fe.jsx(O.Item,{name:e.name,label:null===e.label?void 0:e.label||m.label,extra:e.hideMessage?void 0:c,rules:e.required?[Xe.required()]:[{}],className:e.className,children:Fe.jsx(Sn,{type:e.type,canCreate:e.canCreate,config:m,params:e.params,setExtra:function(n){e.hideMessage||p(n)},onSelect:e.onSelect,fillWhileTyping:e.fillWhileTyping,disabled:e.disabled,cuerpoCrear:e.cuerpoCrear,initialValue:e.initialValue,allowClear:e.allowClear,placeholder:e.placeholder})}):(console.error("No se encontro el tipo",e.type),null)};Nn.displayName="Seeker";var Fn=function(e){return Fe.jsx(Nn,xe({},e))},kn=function(e){var n=O.useWatch(e.nameComplete,e.form),r=a(function(){return e.form.getFieldValue(e.nameComplete)},[n]),t=a(function(){var n=e.form.getFieldValue(e.nameComplete);return!["MEX","USA","CAN"].includes(null==n?void 0:n.Pais)},[r]);return Fe.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-x-6",children:[Fe.jsx(O.Item,{name:Ie(Ie([],e.name,!0),["Calle"],!1),label:"Calle",rules:e.street?[Xe.required()]:[],children:Fe.jsx(V,{placeholder:"Ingrese la calle"})}),Fe.jsx(O.Item,{name:Ie(Ie([],e.name,!0),["NumExterior"],!1),label:"Num. Exterior",children:Fe.jsx(V,{placeholder:"Ingrese el número"})}),Fe.jsx(O.Item,{name:Ie(Ie([],e.name,!0),["NumInterior"],!1),label:"Num. Interior",children:Fe.jsx(V,{placeholder:"Ingrese el número"})}),Fe.jsx(Fn,{name:Ie(Ie([],e.name,!0),["Pais"],!1),onSelect:function(){return n=e.form.getFieldValue(e.nameComplete),void e.form.setFieldValue(e.nameComplete,xe(xe({},n),{CodigoPostal:void 0,Estado:void 0,Municipio:void 0,Localidad:void 0,Colonia:void 0}));var n},fillWhileTyping:!0,type:"paises",required:!0}),"MEX"===(null==r?void 0:r.Pais)?Fe.jsx(Fn,{name:Ie(Ie([],e.name,!0),["CodigoPostal"],!1),type:"codigo-postal",required:!0,onSelect:function(n){return r=n,void((t=e.form.getFieldValue(e.nameComplete)||{})&&e.form.setFieldValue(e.nameComplete,xe(xe({},t),{Estado:null==r?void 0:r.cEstado,Municipio:null==r?void 0:r.cMunicipio,Localidad:null==r?void 0:r.cLocalidad})));var r,t}}):Fe.jsx(O.Item,{name:Ie(Ie([],e.name,!0),["CodigoPostal"],!1),label:"Código postal",rules:[Xe.required()],children:Fe.jsx(V,{placeholder:"Ingrese el código postal"})}),"MEX"===(null==r?void 0:r.Pais)?Fe.jsx(Fn,{name:Ie(Ie([],e.name,!0),["Colonia"],!1),type:"colonias",params:{cCodigoPostal:(null==r?void 0:r.CodigoPostal)||"inexistente"},fillWhileTyping:!0,required:!1}):Fe.jsx(O.Item,{name:Ie(Ie([],e.name,!0),["Colonia"],!1),label:"Colonia",children:Fe.jsx(V,{placeholder:"Ingrese el código de la colonia"})}),"MEX"===(null==r?void 0:r.Pais)?Fe.jsx(Fn,{name:Ie(Ie([],e.name,!0),["Localidad"],!1),type:"localidades",params:{cEstado:(null==r?void 0:r.Estado)||"sin-estado"},fillWhileTyping:!0,required:!1}):Fe.jsx(O.Item,{name:Ie(Ie([],e.name,!0),["Localidad"],!1),label:"Localidad",children:Fe.jsx(V,{placeholder:"Ingrese el código de la localidad"})}),"MEX"===(null==r?void 0:r.Pais)?Fe.jsx(Fn,{name:Ie(Ie([],e.name,!0),["Municipio"],!1),type:"municipios",params:{cEstado:(null==r?void 0:r.Estado)||"sin-estado"},required:!1}):Fe.jsx(O.Item,{name:Ie(Ie([],e.name,!0),["Municipio"],!1),label:"Municipio",children:Fe.jsx(V,{placeholder:"Ingrese el código del municipio"})}),t?Fe.jsx(O.Item,{name:Ie(Ie([],e.name,!0),["Estado"],!1),rules:[Xe.required()],label:"Estado",children:Fe.jsx(V,{placeholder:"Ingrese el código del estado"})}):Fe.jsx(Fn,{name:Ie(Ie([],e.name,!0),["Estado"],!1),params:{cPais:(null==r?void 0:r.Pais)||"sin-pais"},required:!0,type:"estados"}),Fe.jsx(O.Item,{name:Ie(Ie([],e.name,!0),["Referencia"],!1),label:"Referencia",children:Fe.jsx(V,{placeholder:"Referencia geográfica adicional"})})]})},En=function(e){var n,r,t,o,i,a,l,s,c,u,d=O.useWatch("cuentaMayor",e.form);return Fe.jsxs(Fe.Fragment,{children:[Fe.jsx(O.Item,{name:"codigo",label:"Código",rules:[Xe.required(),Xe.pattern(/[^.|_|-]$/,"El código no puede terminar en punto o guión")],children:Fe.jsx(V,{placeholder:"Ingrese el código de la cuenta"})}),Fe.jsx(O.Item,{name:"nombre",label:"Nombre",rules:[Xe.required()],children:Fe.jsx(V,{placeholder:"Ingrese el nombre de la cuenta"})}),Fe.jsx(O.Item,{name:"codigoAgrupador",label:"Código agrupador (SAT)",children:Fe.jsx(_,{showSearch:!0,options:null===(r=null===(n=e.options)||void 0===n?void 0:n.CodigosSAT)||void 0===r?void 0:r.map(function(e){return{label:"".concat(e.id," - ").concat(e.description),value:e.id}}),placeholder:"Seleccione el código agrupador",optionFilterProp:"description",filterOption:function(e,n){return n.value.includes(e)}})}),Fe.jsx(O.Item,{name:"naturaleza",label:"Tipo de cuenta",rules:[Xe.required()],children:Fe.jsx(_,{options:null===(o=null===(t=e.options)||void 0===t?void 0:t.Naturaleza)||void 0===o?void 0:o.map(function(e){return{label:e.description,value:e.id}}),placeholder:"Seleccione el tipo de cuenta"})}),Fe.jsx(O.Item,{name:"cuentaMayor",label:"Cuenta de mayor",rules:[Xe.required()],children:Fe.jsx(_,{options:null===(a=null===(i=e.options)||void 0===i?void 0:i.CuentaMayor)||void 0===a?void 0:a.map(function(e){return{label:e.description,value:e.id}}),placeholder:"Seleccione una de las opciones"})}),Fe.jsx(O.Item,{name:"moneda",label:"Moneda",rules:[Xe.required()],children:Fe.jsx(_,{options:null===(s=null===(l=e.options)||void 0===l?void 0:l.Monedas)||void 0===s?void 0:s.map(function(e){return{label:e.description,value:e.id}}),placeholder:"Seleccione la moneda"})}),Fe.jsx(O.Item,{name:"estado",label:"Estado",rules:[Xe.required()],children:Fe.jsxs(_,{children:[Fe.jsx(_.Option,{value:"activo",children:"Activo"}),Fe.jsx(_.Option,{value:"inactivo",children:"Inactivo"})]})}),"2"===d?Fe.jsx(O.Item,{name:"auxiliar",label:"Auxiliar",tooltip:"Asegurese de alimentar la base de datos clientes, productos y proveedores.",children:Fe.jsx(_,{options:null===(u=null===(c=e.options)||void 0===c?void 0:c.Auxiliares)||void 0===u?void 0:u.map(function(e){return{label:e.description,value:e.id}}),placeholder:"Seleccione un auxiliar"})}):null]})},Dn=l(function(e,n){var r=Je({endpoint:"/api/v3/contability/cuentas-contables",params:{$getAllFields:"true"},data:{codigo:"",moneda:"MXN",estado:"activo"},soloParaInsertar:!0===e.ocultarBotones});return s(n,function(){return{form:r.form,onSubmit:r.onSubmit}}),Fe.jsxs(O,{form:r.form,layout:"vertical",autoComplete:"off",initialValues:r.data,onFinish:r.onSubmit,onValuesChange:function(e,n){return r.preventor.cambiarDatosFormulario(n)},children:[Fe.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-x-6",children:Fe.jsx(En,{options:r.options,form:r.form})}),e.ocultarBotones?null:r.BotonesPorDefecto]})}),Rn=function(e){var r=e.options,t=n([]),o=t[0],i=t[1],a=[Xe.required()],l=O.useFormInstance(),s=O.useWatch("banks",l),c=function(e){var n,t=null===(n=r.Bancos)||void 0===n?void 0:n.filter(function(n){var r=n.id.toLowerCase().includes(e.toLowerCase()),t=n.description.toLowerCase().includes(e.toLowerCase());return r||t});i(t)};return Fe.jsx(O.List,{name:"banks",children:function(e,n){return Fe.jsxs(Fe.Fragment,{children:[Fe.jsx("div",{className:"flex items-center justify-end mb-6",children:Fe.jsx(R,{type:"dashed",onClick:function(){return n.add({tipoCuenta:"nacional"})},children:"Agregar"})}),Fe.jsxs(Q,{pagination:!1,className:"mb-6",dataSource:e,bordered:!0,rowClassName:"align-top",children:[Fe.jsx(Q.Column,{title:"Tipo de cuenta",render:function(e,n){var r=n.name;return Fe.jsx(O.Item,{name:[r,"tipoCuenta"],rules:a,children:Fe.jsxs(_,{onSelect:function(e){"nacional"===e&&l.setFieldValue(["banks",r,"nombreBancoExt"],void 0)},children:[Fe.jsx(_.Option,{value:"extranjera",children:"Cuenta extranjera"}),Fe.jsx(_.Option,{value:"nacional",children:"Cuenta nacional"})]})})}},"tipoCuenta"),Fe.jsx(Q.Column,{title:"RFC banco",render:function(e,n){var r=n.name;return Fe.jsx(O.Item,{name:[r,"rfcBanco"],rules:a,children:Fe.jsx(Y,{onSearch:c,style:{width:200},onSelect:function(e){if(e){var n=o.find(function(n){return n.id===e});n&&l.setFieldValue(["banks",r,"nombreCuenta"],n.description)}},placeholder:"Ingrese el rfc del banco",children:o.map(function(e,n){return Fe.jsx(_.Option,{value:e.id,children:e.description},n)})})})}},"rfcBanco"),Fe.jsx(Q.Column,{title:"Nombre cuenta",render:function(e,n){var r=n.name;return Fe.jsx(O.Item,{name:[r,"nombreCuenta"],rules:a,children:Fe.jsx(V,{placeholder:"Ingrese el nombre de la cuenta bancaria"})})}},"nombreCuenta"),Fe.jsx(Q.Column,{title:"N° de cuenta",render:function(e,n){var r=n.name;return Fe.jsx(O.Item,{name:[r,"cuentaBancaria"],rules:a,children:Fe.jsx(V,{placeholder:"Ingrese el número de cuenta bancaria"})})}},"cuentaBancaria"),Fe.jsx(Q.Column,{title:"Nombre banco ext.",render:function(e,n){var r=n.name;return s&&"extranjera"===s[r].tipoCuenta?Fe.jsx(O.Item,{name:[r,"nombreBancoExt"],rules:a,children:Fe.jsx(V,{placeholder:"Ingrese cuenta bancaria"})}):"No aplica"}},"nombreBancoExt"),Fe.jsx(Q.Column,{align:"center",render:function(e,r){var t=r.name;return Fe.jsx(re,{title:"¿Eliminar cuenta?",onConfirm:function(){return n.remove(t)},children:Fe.jsx(b,{title:"Eliminar cuenta"})})}},"opciones")]})]})}})},Tn=function(e){return{isActual:e,IDUbicacion:void 0,Calle:void 0,NumExterior:void 0,NumInterior:void 0,Pais:"MEX",Estado:void 0,Municipio:void 0,Localidad:void 0,Colonia:void 0,CodigoPostal:void 0,Referencia:void 0}},On=function(e){var t=e.form,o=e.name,i=e.cartaPorte,a=void 0!==i&&i,l=e.newClient,s=e.onSelectDomicilio,c=n([]),u=c[0],d=c[1],p=O.useWatch(o,t)||[];r(function(){a||0!==(p||[]).length||(t.setFieldValue(o,[Tn(!0)]),d(["direcciones0"]));var e=p.findIndex(function(e){return!!e.isActual});-1!==e&&d(["direcciones"+e])},[]);return Fe.jsx(Fe.Fragment,{children:Fe.jsx(O.List,{name:o,children:function(e,n){var r,i;return Fe.jsxs(Fe.Fragment,{children:[Fe.jsx("div",{className:"flex justify-end mb-5",children:l&&0===(null===(r=p||[])||void 0===r?void 0:r.length)||!l&&Fe.jsx(R,{type:"link",onClick:function(){if(n.add(Tn()),1===t.getFieldValue(o).length){var e=t.getFieldValue(o);e[0].isActual=!0,t.setFieldValue(o,e)}d(["direcciones"+p.length])},children:"Agregar"})}),0===(null===(i=p||[])||void 0===i?void 0:i.length)?Fe.jsx(ie,{description:"No hay ubicaciones"}):Fe.jsx(ae,{activeKey:u,onChange:function(e){return d(e)},items:e.map(function(e){var r,i;return{key:"direcciones"+e.key,label:Fe.jsx("div",{className:"flex justify-between",children:Fe.jsx(A.Text,{children:"Ubicación "+((null===(r=p[e.name])||void 0===r?void 0:r.IDUbicacion)||l?null===(i=p[e.name])||void 0===i?void 0:i.IDUbicacion:"sin nombre")})}),extra:Fe.jsx(Fe.Fragment,{children:l?void 0:Fe.jsxs(Fe.Fragment,{children:[e.name!==t.getFieldValue(o).findIndex(function(e){return!0===e.isActual})?Fe.jsx(le,{color:"default",onClick:function(n){var r;n.stopPropagation(),r=e.name,p.forEach(function(e){e.isActual=!1}),p[r].isActual=!0,t.setFieldValue(o,p)},children:"Usar por defecto"}):Fe.jsx(le,{color:"success",children:"Por defecto"}),a?Fe.jsx(R,{type:"link",onClick:function(n){n.stopPropagation(),s&&s(e.name)},children:"Seleccionar"}):Fe.jsx(re,{title:"¿Eliminar registro?",onConfirm:function(){return n.remove(e.name)},children:Fe.jsx(b,{onClick:function(e){e.stopPropagation()}})})]})}),children:Fe.jsx(kn,{name:[e.name],form:t,nameComplete:[o,e.name]})}})})]})}})})},_n=function(e){var t=n(!1),o=t[0],i=t[1],a=n(""),l=a[0],s=a[1];return r(function(){i(e.visible),s("601"===e.codigo?"General de ley personas morales":"Personas físicas con actividades empresariales y profesionales")},[e.visible]),Fe.jsx(Fe.Fragment,{children:Fe.jsxs(T,{title:"Campos establecidos por defecto",centered:!0,closable:!1,width:600,open:o,onOk:function(){e.respuesta(!1),i(!1)},footer:[Fe.jsx(R,{type:"primary",onClick:function(){e.respuesta(!1)},children:"Aceptar"},"submit")],children:[Fe.jsxs("p",{children:["Régimen Fiscal:"," ",Fe.jsxs("span",{className:"font-bold",children:[e.codigo," - ",l]})]}),Fe.jsxs("p",{children:["USO DE CFDI: ",Fe.jsx("span",{className:"font-bold",children:"G03 - Gastos generales"})]})]})})},An=l(function(e,t){var o,i=Je({endpoint:"/api/v3/administrative/clients-mx",params:{estado:"activo",fields:"rfc name tipo phone RegimenFiscalReceptor emails address usoCFDI subjectType estado banks accountingAccount accountingAccountGastos seller"},data:{usoCFDI:void 0,RegimenFiscalReceptor:"612",subjectType:"01",address:[],banks:[],tipo:["cliente"],rfc:void 0},soloParaInsertar:!0===e.ocultarBotones}),l=pn().hasModule,c=n(void 0),u=c[0];c[1];var d=n("direcciones"),p=d[0],m=d[1],f=O.useWatch("tipo",i.form),v=O.useWatch("subjectType",i.form),h=O.useWatch("esExtranjero",i.form),g=O.useWatch("RegimenFiscalReceptor",i.form),b=null!=g?g:i.data.RegimenFiscalReceptor,x=a(function(){var e,n,r=null===(e=i.options.RegimenFiscales)||void 0===e?void 0:e.filter(function(e){return e.id===b}),t=null===(n=i.options.UsosDeCFDI)||void 0===n?void 0:n.filter(function(e){var n;return null===(n=null==r?void 0:r[0].usosCfdis)||void 0===n?void 0:n.includes(e.id)});return t},[b,i.options.RegimenFiscales,i.options.UsosDeCFDI]),j=a(function(){var e;return null===(e=i.options.RegimenFiscales)||void 0===e?void 0:e.filter(function(e){var n="01"===v?"fisica":"moral";return"ambos"===e.stringValue||e.stringValue===n})},[v,i]);r(function(){var n,r;if("client"===e.type?i.form.setFieldValue("tipo",["cliente"]):"provider"===e.type&&i.form.setFieldValue("tipo",["proveedor"]),setTimeout(function(){var e=i.form.getFieldsValue();"XEXX010101000"===(null==e?void 0:e.rfc)&&i.form.setFieldValue("esExtranjero",!0)},300),u){var t=u,o=t.rfc,a=i.form.getFieldValue("rfc"),l=window.location.pathname.split("/")[3];if(o!==a&&"insert"!==l)return void te.error("La constancia que desea cargar, no corresponde al RFC actual");t.address&&null!==t.address[0]&&i.form.setFieldValue(["address",0,"CodigoPostal"],t.address[0].CodigoPostal),t.emails=null===(n=t.emails)||void 0===n?void 0:n.filter(function(e){return e}),N("01"===t.subjectType?"612":"601");var s=i.form.getFieldsValue();Object.assign(s,u),s.address&&(s.address[0].Pais=(null===(r=null==s?void 0:s.address[0])||void 0===r?void 0:r.CodigoPostal)?"MEX":void 0),i.form.setFieldsValue(s),i.form.setFieldValue("RegimenFiscalReceptor","01"===t.subjectType?"612":"601"),P(!0)}},[u]),s(t,function(){return{form:i.form,onSubmit:i.onSubmit}});var y={className:!1!==e.bordered?"mb-6":"",variant:!1!==e.bordered?"outlined":"borderless"},I=n(!1),C=I[0],P=I[1],w=n(""),S=w[0],N=w[1],F="grid grid-cols-2 md:grid-cols-3 gap-x-6";return Fe.jsxs(Fe.Fragment,{children:[Fe.jsxs(O,{form:i.form,layout:"vertical",initialValues:i.data,onFinish:i.onSubmit,children:[Fe.jsxs(oe,xe({},y,{children:[Fe.jsxs("div",{className:F,children:[Fe.jsx(O.Item,{name:"subjectType",label:"Tipo de persona",rules:[Xe.required()],children:Fe.jsx(_,{placeholder:"Escoja una de las opciones",options:null===(o=i.options.TiposDePersona)||void 0===o?void 0:o.map(function(e){return{label:e.description,value:e.id}}),onChange:function(){i.form.setFieldValue("RegimenFiscalReceptor",void 0),i.form.setFieldValue("usoCFDI",void 0)}})}),Fe.jsx(on,{name:"rfc",type:"rfc",subjectType:v,foreing:h,rules:[Xe.required()]}),Fe.jsx(O.Item,{name:"name",label:"Nombres / Razón social",rules:[Xe.required()],normalize:function(e){return e.toUpperCase()},children:Fe.jsx(V,{placeholder:"Ingrese la razón social"})}),h?Fe.jsx(O.Item,{name:"numRegIdTrib",label:"Número registro tributario",children:Fe.jsx(V,{placeholder:"Ingrese el número de registro tributario"})}):null,Fe.jsx(O.Item,{name:"RegimenFiscalReceptor",label:"Régimen fiscal",rules:[Xe.required()],children:Fe.jsx(_,{placeholder:"Escoja una de las opciones",allowClear:!0,options:null==j?void 0:j.map(function(e){return{label:"".concat(e.id," - ").concat(e.description),value:e.id}}),onChange:function(){i.form.setFieldValue("usoCFDI",void 0)}})}),Fe.jsx(O.Item,{name:"usoCFDI",label:"Uso CFDI",rules:[Xe.required()],children:Fe.jsx(_,{placeholder:"Escoja una de las opciones",options:null==x?void 0:x.map(function(e){return{label:"".concat(e.id," - ").concat(e.description),value:e.id}})})}),Fe.jsx(O.Item,{name:"phone",label:"Teléfono",children:Fe.jsx(V,{placeholder:"Ingrese el teléfono"})}),Fe.jsx(Fn,{name:"seller",type:"sellers"})]}),Fe.jsxs("div",{className:"flex",children:[Fe.jsx(O.Item,{name:"tipo",children:Fe.jsxs(ee.Group,{children:[Fe.jsx(ee,{value:"cliente",style:{lineHeight:"32px"},onChange:function(e){(null==e?void 0:e.target.checked)||i.form.setFieldValue("accountingAccount",null)},children:"Es cliente"}),Fe.jsx(ee,{value:"proveedor",style:{lineHeight:"32px"},onChange:function(e){(null==e?void 0:e.target.checked)||i.form.setFieldValue("accountingAccountGastos",null)},children:"Es proveedor"})]})}),Fe.jsx(O.Item,{name:"esExtranjero",valuePropName:"checked",children:Fe.jsx(ee,{style:{lineHeight:"32px"},onChange:function(e){return function(e){i.form.setFieldValue("rfc",e?"XEXX010101000":""),i.form.setFieldValue("RegimenFiscalReceptor",e?"616":"601"),i.form.setFieldValue("usoCFDI",e?"S01":"G03"),setTimeout(function(){i.form.validateFields(["rfc"])},500)}(e.target.checked)},children:"Es extranjero"})})]}),Fe.jsx(O.Item,{name:"emails",label:"Correos electrónicos",children:Fe.jsx(_,{mode:"tags",placeholder:"Ingrese un correo electrónico"})})]})),Fe.jsxs(oe,xe({tabList:Ie([{key:"direcciones",tab:"Ubicaciones"},{key:"cuentas",tab:"Cuentas bancarias"}],l("contabilidad-mx")?[{key:"other",tab:"Info. Contable"}]:[],!0)},y,{activeTabKey:p,onTabChange:function(e){return m(e)},children:[Fe.jsx("div",{className:"direcciones"===p?"":"hidden",children:Fe.jsx(On,{form:i.form,name:"address"})}),Fe.jsx("div",{className:"cuentas"===p?"":"hidden",children:Fe.jsx(Rn,{options:i.options})}),Fe.jsx("div",{className:"other"===p&&l("contabilidad-mx")?"":"hidden",children:Fe.jsxs("div",{className:F,children:[(null==f?void 0:f.includes("cliente"))&&Fe.jsx(Fn,{name:"accountingAccount",type:"cuentas-contables-mx",label:"Cuenta contable de ingresos"}),(null==f?void 0:f.includes("proveedor"))&&Fe.jsx(Fn,{name:"accountingAccountGastos",type:"cuentas-contables-mx",label:"Cuenta contable de gastos"})]})})]})),e.ocultarBotones?null:i.BotonesPorDefecto]}),Fe.jsx(_n,{visible:C,respuesta:function(e){P(e)},codigo:S})]})}),Vn=function(e){var n,r,t=e.form,o=null!==(n=O.useWatch(e.name,t))&&void 0!==n?n:null;return Fe.jsxs("div",{className:"flex items-center mb-3",children:[Fe.jsx(ee,{checked:null!==o,className:"basis-36",onChange:function(n){return t.setFieldValue(e.name,n.target.checked?"":null)},children:e.label}),Fe.jsx(O.Item,{className:"m-0 p-0 basis-full",name:e.name,children:Fe.jsx(_,{placeholder:"Seleccione un valor",disabled:null===o,options:null===(r=e.options)||void 0===r?void 0:r.map(function(e){return{label:"".concat(e.description," - ").concat(e.value),value:e.value}})})})]})},Ln=function(e){var n=pn().business;return Fe.jsx(O.List,{name:"relaciones",children:function(r,t){return Fe.jsxs(Fe.Fragment,{children:[Fe.jsx("div",{className:"flex items-center justify-end mb-6",children:Fe.jsx(R,{type:"dashed",onClick:function(){return t.add({cantidad:1,precio:0})},children:"Agregar relación"})}),Fe.jsxs(Q,{dataSource:r,rowClassName:"align-top",children:[Fe.jsx(Q.Column,{title:"Nombre",render:function(n){var r=n.name;return Fe.jsx(Fn,{className:"m-0 p-0",name:[r,"producto"],label:null,params:{tipoProducto:"producto"},type:"products-services",onSelect:function(n){return function(n,r){var t,o;void 0===n&&(n={});var i=e.form.getFieldValue("relaciones");i[r].producto&&n&&(i[r].nota=n.description,null!==(t=(o=i[r]).cantidad)&&void 0!==t||(o.cantidad=1),i[r].precio=n.price,i[r].type=n.type,e.form.setFieldValue("relaciones",i))}(n,r)}})}},"name"),Fe.jsx(Q.Column,{title:"Nota",render:function(e){var n=e.name;return Fe.jsx(O.Item,{className:"m-0 p-0",name:[n,"nota"],rules:[Xe.required()],children:Fe.jsx(V,{placeholder:"Ingresar una nota"})})}},"nota"),Fe.jsx(Q.Column,{title:"Cantidad",render:function(e){var r,t=e.name;return Fe.jsx(O.Item,{className:"m-0 p-0",name:[t,"cantidad"],rules:[Xe.required()],children:Fe.jsx(Z,{placeholder:"Ingresar la cantidad",min:1e-6,precision:(null===(r=null==n?void 0:n.configs)||void 0===r?void 0:r.nDecimals)||2})})}},"cantidad"),Fe.jsx(Q.Column,{title:"Costo",render:function(e){var n=e.name;return Fe.jsx(O.Item,{className:"m-0 p-0",name:[n,"precio"],rules:[Xe.required()],children:Fe.jsx(Z,{className:"w-full",disabled:!0,placeholder:"precio",formatter:function(e){return"$ ".concat(e)}})})}},"precio"),Fe.jsx(Q.Column,{align:"center",render:function(e){var n=e.name;return Fe.jsx(R,{title:"¿Eliminar relación?",icon:Fe.jsx(b,{}),onClick:function(){return t.remove(n)}})}},"opciones")]})]})}})},qn=function(e){var n=pn().business,r=e.form,t=O.useWatch("price",r),o=O.useWatch("iva",r),i=O.useWatch("ieps",r);O.useWatch("ice",r),O.useWatch("icePercentage",r),O.useWatch("irbpnr",r);var a,l=O.useWatch("descuento",r),s=function(r,t,a){var s;void 0===a&&(a=!0);var c=1;i&&(c+=i);var u=null===(s=e.options.PorcentajesDeIVA)||void 0===s?void 0:s.find(function(e){return e.id===o});return c*=1+((null==u?void 0:u.value)||0),a&&(c*=1-(l||0)/100),Me("final"===t?r*c:r/c,null==n?void 0:n.configs.nDecimals)},c=s(t||0,"final",!1),u=s(t||0,"final"),d=fe(function(e,n){void 0===n&&(n=!0),r.setFieldValue("price",s(e||0,"base",n))},1e3),p=function(e){if(!e)return"";var n=String(e),r=(n=n.replace(/,/g,"")).split("."),t=r[0],o=r[1],i=t.replace(/\B(?=(\d{3})+(?!\d))/g,",");return o?"$ ".concat(i,".").concat(o):"$ ".concat(i)};return Fe.jsxs(Fe.Fragment,{children:[Fe.jsxs("div",{className:"grid md:grid-cols-2 lg:grid-cols-4 gap-x-6 mb-3",children:[Fe.jsx(O.Item,{label:"Precio sin impuestos",name:"price",children:Fe.jsx(Z,{min:0,precision:(null==n?void 0:n.configs.nDecimals)||2,className:"w-full",formatter:p,placeholder:"Ingresar el precio unitario"})}),Fe.jsx(O.Item,{label:"Precio con impuestos",children:Fe.jsx(Z,{placeholder:"Ingresar el precio unitario",min:0,precision:(null==n?void 0:n.configs.nDecimals)||2,className:"!w-full",value:c,formatter:p,onChange:function(e){return d(e,!1)}})}),Fe.jsx(O.Item,{label:"% de descuento",name:"descuento",children:Fe.jsx(Z,{placeholder:"Ingresar el porcentaje del descuento",min:0,max:100,precision:(null==n?void 0:n.configs.nDecimals)||2,className:"!w-full"})}),Fe.jsx(O.Item,{label:"Precio final",children:Fe.jsx(Z,{value:u,placeholder:"Ingresar el precio unitario",min:0,formatter:p,precision:(null==n?void 0:n.configs.nDecimals)||2,className:"!w-full",onChange:d})})]}),Fe.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[Fe.jsxs("div",{children:[Fe.jsx("p",{className:"text-lg font-bold",children:"Traslados"}),Fe.jsxs("div",{className:"flex items-center mb-3",children:[Fe.jsx(ee,{checked:!0,disabled:!0,className:"basis-36",children:"IVA"}),Fe.jsx(O.Item,{name:"iva",className:"m-0 basis-full",rules:[Xe.required()],children:Fe.jsx(_,{options:null===(a=e.options.PorcentajesDeIVA)||void 0===a?void 0:a.map(function(e){return{label:e.id+" - "+e.description,value:e.id}})})})]}),Fe.jsx(Vn,{form:r,options:e.options.PorcentajesDeIEPS,label:"IEPS",name:"ieps"})]}),Fe.jsx("div",{children:Fe.jsxs("div",{children:[Fe.jsx("p",{className:"text-lg font-bold",children:"Retenciones"}),Fe.jsx(Vn,{form:r,options:e.options.PorcentajesIVARET,label:"IVA",name:"ivaRet"}),Fe.jsx(Vn,{form:r,options:e.options.PorcentajesIEPSRET,label:"IEPS",name:"iepsRet"}),Fe.jsx(Vn,{form:r,options:e.options.PorcentajesISRRET,label:"ISR",name:"isrRet"})]})})]})]})},Un=l(function(e,t){var o,i=n(e.tipoPorDefecto&&"producto"!==e.tipoPorDefecto?"/api/v3/production/services":"/api/v3/production/products"),l=i[0],c=i[1],d=Je({endpoint:l,params:{$getAllFields:"true"},data:{type:"servicio"===e.tipoPorDefecto?"service":"product",code:"",accountingAccount:void 0,iva:"3",aditionalInformation:[],bodegas:[],tipoProducto:"producto",relaciones:[],ObjetoImp:"02"},soloParaInsertar:!0===e.ocultarBotones}),p=n("precios"),m=p[0],f=p[1],v=n(0),h=v[0],g=v[1],b=pn().hasModule,x=n(""),j=x[0],y=x[1],I=n([]);I[0];var C=I[1],P=O.useWatch("price",d.form)||0,w=O.useWatch("type",d.form);r(function(){c("service"===w?"/api/v3/production/services":"/api/v3/production/products")},[w]);var S=O.useWatch("relaciones",d.form),N=O.useWatch("tipoProducto",d.form),F="product"===w?"producto":"servicio",k="Clave de ".concat(F),E="Código SAT del ".concat(F),D=Oe(),R=D.message,T=D.showError;s(t,function(){return{form:d.form,onSubmit:d.onSubmit}}),r(function(){u.get("/api/v3/businesses/me/configurations",{params:{fields:"restaurantes production"}}).then(function(e){var n,r,t=e.data;if(b("restaurantes")){var o=(null===(n=null==t?void 0:t.restaurantes)||void 0===n?void 0:n.categorias.filter(function(e){return"activo"===e.estado}))||[];C(o)}y(null===(r=null==t?void 0:t.production)||void 0===r?void 0:r.metodoInventario)})},[]),a(function(){if(S){var e=d.form.getFieldValue("relaciones"),n=null==e?void 0:e.reduce(function(e,n){return e+(n.precio*n.cantidad||0)},0);g(P-n)}},[S,P]);return Fe.jsxs(O,{form:d.form,layout:"vertical",autoComplete:"off",initialValues:d.data,onFinish:function(e){return je(void 0,void 0,void 0,function(){var n,r,t,o,i,a,l;return ye(this,function(s){switch(s.label){case 0:if(s.trys.push([0,6,,7]),"kit"===e.tipoProducto){if(0===(null===(o=null==e?void 0:e.relaciones)||void 0===o?void 0:o.length))return[2,R.warning("El kit debe tener ingresado al menos una relación.")];if(!(null===(i=null==e?void 0:e.relaciones)||void 0===i?void 0:i.some(function(e){return"product"===e.type})))return[2,R.warning("En las relaciones del kit debe tener ingresado al menos un producto.")]}s.label=1;case 1:return s.trys.push([1,4,,5]),[4,d.form.validateFields()];case 2:return s.sent(),[4,d.onSubmit(e)];case 3:return s.sent(),[3,5];case 4:return n=s.sent(),null!==(l=null===(a=null==(r=n)?void 0:r.errorFields)||void 0===a?void 0:a.length)&&void 0!==l&&l?[2,R.warning("Completa los campos del formulario")]:[3,5];case 5:return[3,7];case 6:return t=s.sent(),T(t),[3,7];case 7:return[2]}})})},onValuesChange:function(e,n){return d.preventor.cambiarDatosFormulario(n)},children:[Fe.jsx(oe,{className:"mb-4",variant:e.bordered?"outlined":"borderless",children:Fe.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-x-6",children:[Fe.jsx(O.Item,{name:"type",label:"Tipo",rules:[Xe.required()],className:e.tipoPorDefecto?"hidden":"",children:Fe.jsx(_,{options:[{label:"Producto",value:"product"},{label:"Servicio",value:"service"}]})}),"product"===w&&Fe.jsx(O.Item,{name:"tipoProducto",label:"Tipo producto",rules:[Xe.required()],children:Fe.jsx(_,{options:[{label:"Producto",value:"producto"},{label:"Kit",value:"kit"}],onChange:function(e){"producto"===e&&d.form.setFieldValue("relaciones",[])}})}),Fe.jsx(O.Item,{name:"code",label:k,rules:[Xe.required(),Xe.max(300)],children:Fe.jsx(V,{placeholder:"Ingresar el código principal"})}),Fe.jsx(O.Item,{label:"Clave alterna",name:"auxiliarCode",children:Fe.jsx(V,{placeholder:"Ingresar la clave alterna"})}),Fe.jsx(Fn,{label:E,name:"claveProdServ",type:"products-and-services-catalog",required:!0}),Fe.jsx(O.Item,{label:"Descripción",name:"description",rules:[Xe.required(),Xe.max(1e3)],children:Fe.jsx(V,{placeholder:"Ingresar una descripción"})}),Fe.jsx(Fn,{label:"Clave de unidad SAT",name:"claveUnidad",type:"claves-de-unidad",required:!0}),Fe.jsx(O.Item,{name:"ObjetoImp",rules:[Xe.required()],label:"Operación comercial",children:Fe.jsx(_,{placeholder:"Seleccionar la operación comercial",options:null===(o=d.options.ObjetoImp)||void 0===o?void 0:o.map(function(e){return{label:e.id+" - "+e.description,value:e.id}})})}),Fe.jsx(O.Item,{label:"No. identificación",name:"noDeIdentificacion",children:Fe.jsx(V,{placeholder:"Ingresar el número de identificación"})})]})}),Fe.jsxs(oe,{tabList:Ie(Ie(Ie([{key:"precios",tab:"Precios"}],"receta"===N||"kit"===N?[{key:"relaciones",tab:"Relaciones"}]:[],!0),b("contabilidad-mx")?[{key:"contabilidad",tab:"Contabilidad"}]:[],!0),b("restaurantes")?[{key:"restaurantes",tab:"Restaurantes"}]:[],!0),className:"mb-6",variant:e.bordered?"outlined":"borderless",activeTabKey:m,onTabChange:function(e){return f(e)},children:["kit"===N&&(null==S?void 0:S.length)>0&&"peps"!==j&&Fe.jsxs("div",{className:"mb-5",children:[1===Math.sign(h)&&Fe.jsx(se,{message:"Utilidad: ".concat(He.currency(h)),type:"success",showIcon:!0}),-1===Math.sign(h)&&Fe.jsx(se,{message:"Utilidad: ".concat(He.currency(h)),type:"warning",showIcon:!0})]}),Fe.jsx("div",{className:"precios"===m?"":"hidden",children:Fe.jsx(qn,{form:d.form,hasModule:b,options:d.options})}),"kit"===N&&Fe.jsx("div",{className:"relaciones"===m?"":"hidden",children:Fe.jsx(Ln,{form:d.form})}),b("contabilidad-mx")&&Fe.jsx("div",{className:"contabilidad"===m?"":"hidden",children:Fe.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-x-6",children:[Fe.jsx(Fn,{label:"Cuenta contable de venta",name:"accountingAccount",type:"cuentas-contables-mx"}),"product"===w&&Fe.jsxs(Fe.Fragment,{children:[Fe.jsx(Fn,{label:"Cuenta contable de costo",name:"accountingAccountCost",type:"cuentas-contables-mx"}),Fe.jsx(Fn,{label:"Cuenta contable de inventario",name:"cuentaContableInventario",type:"cuentas-contables-mx"})]})]})})]}),e.ocultarBotones?null:d.BotonesPorDefecto]})}),Bn=function(e){var n=function(n){var r,t,o,i;return t=null===(r=e.options)||void 0===r?void 0:r.Banks,o=n,(i=null==t?void 0:t.find(function(e){return e.id===o}))?i.description:"No encontrado"};switch(e.type){case"cuentas-contables-mx":return{label:"Cuenta contable",endpoint:"/api/v3/contability/cuentas-contables",params:{fields:"codigo nombre codigoAgrupador cuentaMayor auxiliar estado cuentaSuperior",cuentaMayor:"2"},field:"codigo",placeholder:"Ingrese el código de la cuenta",title:function(e){return"".concat(null==e?void 0:e.codigo)},subtitle:function(e){return null==e?void 0:e.nombre},modal:{title:"Cuenta contable",getTexto:function(e){return e.description},componente:function(e){return Fe.jsx(Dn,{ref:e.ref,ocultarBotones:!0})}}};case"clients-mx":default:return{withOptions:!0,label:"Cliente",endpoint:"/api/v3/administrative/clients-mx",params:{fields:"rfc name usoCFDI banks address numRegIdTrib RegimenFiscalReceptor",tipo:"cliente",estado:"activo"},field:"rfc",placeholder:"Ingrese el RFC del cliente",title:function(e){return"".concat(e.rfc," · ").concat(e.name)},subtitle:function(e){return e.name},preBusquedaQ:function(e){return void 0===e&&(e=""),e=e.trim(),/^\d+/.test(e)?"^"+e:e},modal:{title:"Clientes",getTexto:function(e){return e.name},componente:function(e){return Fe.jsx(An,{ref:e.ref,type:"client",ocultarBotones:!0})}}};case"clients-rfc":return{label:"Cliente",endpoint:"/api/v3/administrative/clients-mx",params:{fields:"rfc name usoCFDI banks address numRegIdTrib RegimenFiscalReceptor",tipo:"cliente",estado:"activo"},field:"rfc",placeholder:"Ingrese el RFC del cliente",title:function(e){return"".concat(e.rfc," · ").concat(e.name)},subtitle:function(e){return e.name},customDocumentId:"rfc",buscarPorQueryString:!0};case"codigo-postal":return{label:"Código postal",endpoint:"/api/v3/utils/enums/codigo-postal",field:"id",placeholder:"Ingrese el código postal",title:function(e){return e.id},customDocumentId:"id",preBusquedaQ:function(e){return/^\d+\./.test(e)?"^"+e:e}};case"sellers":return{withOptions:!0,label:"Vendedor",endpoint:"/api/v3/administrative/sellers",params:{fields:"rfc name codigo",estado:"activo"},field:"name",placeholder:"Ingrese el nombre del vendedor",title:function(e){return e.name},subtitle:function(e){return"".concat(e.codigo)}};case"paises":return{label:"Pais",endpoint:"/api/v3/utils/enums/Paises",field:"id",placeholder:"Ingrese el país. Ej. MEX",title:function(e){var n;return null!==(n=null==e?void 0:e.id)&&void 0!==n?n:e},subtitle:function(e){return null==e?void 0:e.description},customDocumentId:"id"};case"bankaccounts":return{withOptions:!0,label:"Cuenta bancaria",endpoint:"/api/v3/treasury/bank-accounts",params:{fields:"number bank total",status:"activo"},field:"number",placeholder:"Ingrese la cuenta de banco",title:function(e){return e.number},subtitle:function(e){return"".concat(n(e.bank)," - Saldo: ").concat(He.currency(e.total))}};case"colonias":return{label:"Colonia",endpoint:"/api/v3/utils/enums/cartaPorte--Colonia",field:"id",placeholder:"Ingrese la colonia",title:function(e){var n;return null!==(n=null==e?void 0:e.id)&&void 0!==n?n:e},subtitle:function(e){return null==e?void 0:e.description},customDocumentId:"id"};case"localidades":return{label:"Localidad",endpoint:"/api/v3/utils/enums/cartaPorte--Localidad",field:"id",placeholder:"Ingrese la localidad",title:function(e){var n;return null!==(n=null==e?void 0:e.id)&&void 0!==n?n:e},subtitle:function(e){return null==e?void 0:e.description},customDocumentId:"id"};case"municipios":return{label:"Municipio",endpoint:"/api/v3/utils/enums/cartaPorte--Municipio",field:"id",placeholder:"Ingrese el municipio",title:function(e){var n;return null!==(n=null==e?void 0:e.id)&&void 0!==n?n:e},subtitle:function(e){return null==e?void 0:e.description},customDocumentId:"id"};case"estados":return{label:"Estado",endpoint:"/api/v3/utils/enums/cartaPorte--Estados",field:"id",placeholder:"Ingrese el estado",title:function(e){var n;return null!==(n=null==e?void 0:e.id)&&void 0!==n?n:e},subtitle:function(e){return null==e?void 0:e.description},customDocumentId:"id"};case"ingresos-uuid":return{label:"UUID",endpoint:"/api/v3/administrative/ingresos",field:"uuid",placeholder:"Ingrese el UUID",title:function(e){return e.uuid},subtitle:function(e){return"".concat(e.comprobante.serie," -").concat(e.comprobante.folio)},customDocumentId:"uuid",buscarPorQueryString:!0};case"products-services":return{label:"Producto",endpoint:"/api/v3/production/products-services",params:{fields:"code description auxiliarCode type price iva ieps ivaRet iepsRet isrRet total claveProdServ claveUnidad ObjetoImp bodegas tipoProducto",sort:"code",status:"active"},field:"code",placeholder:"Ingrese el código del producto",title:function(e){return null==e?void 0:e.code},subtitle:function(n){var r,t,o,i,a=null==n?void 0:n.description;if("product"===(null==n?void 0:n.type)){var l=null==n?void 0:n.total,s=null===(r=e.params)||void 0===r?void 0:r._bodega;if(s){var c=n.bodegas.find(function(e){return e.bodega===s});l="number"==typeof(null==c?void 0:c.amount)?c.amount:0}a="".concat((null===(o=null===(t=null==n?void 0:n.tipoProducto)||void 0===t?void 0:t[0])||void 0===o?void 0:o.toUpperCase())+(null===(i=null==n?void 0:n.tipoProducto)||void 0===i?void 0:i.substr(1)),": ").concat(a," (").concat(l,")")}else a="Servicio: ".concat(a);return a},modal:{itemNoEncontrado:"El producto o servicio no se encuentra registrado ¿Desea registrarlo?",title:"Productos y servicios",getTexto:function(e){return e.description},componente:function(e){return Fe.jsx(Un,{ref:e.ref,ocultarBotones:!0,bordered:!1})}}};case"products-and-services-catalog":return{label:"Código SAT de producto/servicio",endpoint:"/api/v3/utils/enums/ClaveProdServ",field:"id",placeholder:"Ingrese la clave de producto SAT",title:function(e){return e.id},subtitle:function(e){return e.description},customDocumentId:"id"};case"claves-de-unidad":return{label:"Clave de Unidad SAT",endpoint:"/api/v3/utils/enums/claves-de-unidad",field:"id",placeholder:"Ingrese la clave de unidad",title:function(e){return e.id},subtitle:function(e){return e.description},customDocumentId:"id"};case"alumnos":return{label:"Alumno",endpoint:"/api/api/v3/administrative/alumnos",params:{fields:"_id idAlumno nombreAlumno CURP nivelEducativo autRVOE rfcPago"},field:"nombreAlumno",placeholder:"Ingrese el nombre del alumno",title:function(e){return"".concat(e.idAlumno)},subtitle:function(e){return e.nombreAlumno}};case"providers-mx":return{withOptions:!0,label:"Proveedor",endpoint:"/api/v3/administrative/clients-mx",params:{fields:"_id name rfc",tipo:"proveedor",estado:"activo"},field:"rfc",placeholder:"Ingrese el rfc",title:function(e){return"".concat(e.rfc)},subtitle:function(e){return e.name},modal:{itemNoEncontrado:"Este proveedor no se encuentra registrado ¿Desea registrarlo?",title:"Proveedores",getTexto:function(e){return e.name},componente:function(e){return Fe.jsx(An,{ref:e.ref,type:"provider",ocultarBotones:!0,bordered:!1})}}};case"pettycash":return{label:"Caja chica",endpoint:"/api/v3/treasury/pretty-cash",params:{fields:"name bank total",status:"activo"},field:"name",placeholder:"Ingrese el nombre de caja chica",title:function(e){return e.name},subtitle:function(e){return"Saldo: ".concat(null==He?void 0:He.currency(e.total))}};case"creditcards":return{withOptions:!0,label:"Tarjeta de crédito",endpoint:"/api/v3/treasury/credit-cards",params:{fields:"number cardholder bank total",status:"activo"},field:"number",placeholder:"Ingrese el número de tarjeta de crédito",title:function(e){return e.number},subtitle:function(e){return"".concat(e.cardholder," · ").concat(n(e.bank)," · Saldo: ").concat(He.currency(e.total))}};case"boxes":return{label:"Caja",endpoint:"/api/v3/treasury/boxes",params:{fields:"name total",status:"activo"},field:"name",placeholder:"Ingrese el nombre de la caja",title:function(e){return e.name},subtitle:function(e){return"Saldo: ".concat(He.currency(e.total))}};case"faltas":return{withOptions:!0,label:"Tipo de falta",endpoint:"/api/v3/payroll/faltas",params:{fields:"clave descripcion"},field:"descripcion",placeholder:"Ingresar la clave",title:function(e){return"".concat(e.clave," - ").concat(e.descripcion)}};case"percepciones":return{withOptions:!0,label:"Percepciones",endpoint:"/api/v3/payroll/percepciones",params:{fields:"clave descripcion formula montoPeriodo montoAnual estado claveSat basesFiscales"},field:"clave",placeholder:"Ingresar la percepción",title:function(e){return"".concat(e.clave)},subtitle:function(e){return"".concat(e.descripcion)}};case"deducciones":return{withOptions:!0,label:"Deducciones",endpoint:"/api/v3/payroll/deducciones",params:{fields:"clave descripcion formula montoPeriodo montoAnual estado claveSat basesFiscales"},field:"clave",placeholder:"Ingresar la deducción",title:function(e){return"".concat(e.clave)},subtitle:function(e){return"".concat(e.descripcion)}};case"departamentos":return{label:"Departamento",endpoint:"/api/v3/payroll/departamentos",params:{fields:"clave descripcion"},field:"descripcion",placeholder:"Ingrese la clave del departamento",title:function(e){return e.clave},subtitle:function(e){return e.descripcion}};case"empleados":return{withOptions:!0,label:"Empleado",endpoint:"/api/v3/payroll/employees",params:{fields:"names apellidoPaterno apellidoMaterno documentNumber ingressDate periodicidadPago salaries",status:"activo"},field:"documentNumber",placeholder:"Ingresar el empleado",title:function(e){return"".concat(e.documentNumber)},subtitle:function(e){return"".concat(e.names," ").concat(e.apellidoPaterno," ").concat(e.apellidoMaterno)}};case"bodegas":return{label:"Bodegas",endpoint:"/api/v3/production/bodegas",params:{fields:"code name description color"},field:"code",placeholder:"Ingrese la bodega",title:function(e){return e.code},subtitle:function(e){return e.name}};case"puestos":return{label:"Puesto",endpoint:"/api/v3/payroll/puestos",params:{fields:"clave descripcion"},field:"descripcion",placeholder:"Ingrese la clave del puesto",title:function(e){return e.clave},subtitle:function(e){return e.descripcion}};case"products":return{label:"Producto",endpoint:"/api/v3/production/products",params:{fields:"code description price total claveUnidad tipoProducto",sort:"code",status:"active"},field:"code",placeholder:"Ingrese el código del producto",title:function(e){return e.code},subtitle:function(e){return e.description},modal:{itemNoEncontrado:"El producto no se encuentra registrado ¿Desea registrarlo?",title:"Productos y servicios",getTexto:function(e){return e.description},componente:function(e){return Fe.jsx(Un,{ref:e.ref,tipoPorDefecto:"producto",ocultarBotones:!0,bordered:!1})}}};case"cost-centers":return{label:"Centro de costos",endpoint:"/api/v3/contability/cost-centers",params:{fields:"code description"},field:"code",placeholder:"Ingrese el código del centro de costos",title:function(e){return e.code},subtitle:function(e){return e.description}};case"categorias":return{label:"Categoria",endpoint:"/api/v3/production/categorias",params:{fields:"nombre descripcion"},field:"nombre",placeholder:"Ingrese el nombre",title:function(e){var n;return 1===(null===(n=e.data)||void 0===n?void 0:n.length)?decodeURIComponent(e.data[0].nombre):decodeURIComponent(e.nombre)},customDocumentId:"nombre",buscarPorQueryString:!0};case"figuras-transportes":return{label:"Figura de transporte",endpoint:"/api/v3/administrative/figuras-transportes",params:{fields:"RFCFigura TipoFigura NumLicencia NombreFigura NumRegIdTribFigura ResidenciaFiscalFigura PartesTransporte"},field:"RFCFigura",placeholder:"Ingrese el RFC de la figura de transporte",title:function(e){return e.RFCFigura},subtitle:function(e){return e.NombreFigura},customDocumentId:"RFCFigura",buscarPorQueryString:!0};case"autotransportes":return{label:"Placa vehícular",endpoint:"/api/v3/administrative/autotransportes",params:{fields:"PermSCT NumPermisoSCT IdentificacionVehicular Seguros Remolques"},field:"IdentificacionVehicular.PlacaVM",placeholder:"Ingrese la placa vehícular",title:function(e){return e.IdentificacionVehicular.PlacaVM},customDocumentId:"IdentificacionVehicular.PlacaVM",buscarPorQueryString:!0}}},Mn=function(e){var r=n(!0),t=r[0],o=r[1],i=n(!1),a=i[0],l=i[1];return Fe.jsxs(Fe.Fragment,{children:[e.sidebar?Fe.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),l(e)},children:[Fe.jsx(c,{href:e.sidebar.title.href,children:Fe.jsx("div",{className:"flex justify-center items-center h-16 text-lg text-white font-bold",children:Fe.jsx("div",{children:e.sidebar.title.label})})}),e.sidebar.menu]}):null,Fe.jsxs(z,{className:a||t?"ml-0":"ml-[230px]",onClick:!t&&a?function(e){e.stopPropagation(),e.preventDefault(),o(!0)}:void 0,children:[e.navbar?Fe.jsx(z.Header,{className:"border-b top-0 z-2! sticky px-4! backdrop-blur-xs",children:Fe.jsxs("div",{className:"flex justify-between items-center h-full",children:[Fe.jsx("div",{children:e.sidebar?Fe.jsx(R,{type:"text",icon:t?Fe.jsx(E,{}):Fe.jsx(D,{}),onClick:function(){return o(!t)},children:e.navbar.title}):e.navbar.title}),e.navbar.options?Fe.jsx("div",{children:e.navbar.options}):Fe.jsx("div",{})]})}):null,Fe.jsx(z.Content,{className:"m-4 md:m-8 xl:mx-16 xl:my-8",children:e.children}),e.footer?Fe.jsx(z.Footer,{className:"text-gray-500!",children:e.footer}):null]})]})};export{He as $filtros,Xe as $reglas,un as Autocompletado,an as BotonConfirmacion,tn as BotonMovimientos,mn as ContextoEmpresa,cn as FiltroFechas,kn as FormDirecciones,hn as FormularioPersonas,De as Header,on as IdentificadorPersona,Mn as LayoutBase,sn as Reloj,Nn as Seeker,Fn as SeekerMx,rn as TemaPrincipal,ke as Tutoriales,Ae as crearToken,Ve as destruirToken,We as generarObjectId,Le as getApiEndpoint,qe as getNestedPath,Ue as hashear,wn as initSeeker,Me as nDecimals,Be as redireccionarLogin,$e as rewrites,Bn as seekerPackMx,pn as useContextoEmpresa,Ke as useFrontendUtils,Oe as useUtils,Je as useVistaInsertar,Ge as useVistaPrincipal};
|
|
11
11
|
//# sourceMappingURL=index.js.map
|