1import{eO as g,dn as o,fm as m}from"./index-DfEzlclk.js";import{p as u,f as d,F as w,a as S,c as k}from"./csfApply-p28rz2fU.js";function p(e){return String(e??"").normalize("NFD").replace(/[Ì-ͯ]/g,"").toLowerCase().replace(/[^a-z0-9 ]+/g," ").replace(/\s+/g," ").trim()}const y=e=>{const t=new Map,n=` ${e} `;for(let s=0;s<n.length-1;s++){const i=n.slice(s,s+2);t.set(i,(t.get(i)||0)+1)}return t};function f(e,t){if(!e||!t)return 0;if(e===t)return 1;const n=y(e),s=y(t);let i=0,r=0;for(const[c,a]of n)r+=a,i+=Math.min(a,s.get(c)||0);for(const c of s.values())r+=c;return 2*i/r}const O=.7;function A(e,t){const n=p(t);if(n.length<2)return[];const s=n.split(" ").sort().join(" ");return(e||[]).filter(i=>p(i.name).length>=2).map(i=>{const r=p(i.name),c=r.split(" ").sort().join(" "),a=Math.max(f(n,r),f(s,c),r.includes(n)||n.includes(r)?.9:0,r===n?1:0);return{...i,score:a}}).filter(i=>i.score>=O).sort((i,r)=>r.score-i.score)}async function h(e,t,n){try{return(await fetch(`https://saasbackend.yacamba.com/api/client/get/?page=${e}&per_page=${n}&search=${t}`,{headers:{Authorization:"Bearer "+o.get("token")}})).json()}catch{return new Response("Something went wrong...",{status:500})}}async function z(){try{return(await fetch("https://saasbackend.yacamba.com/api/client/get-code",{headers:{Authorization:"Bearer "+o.get("token")}})).json()}catch{return new Response("Something went wrong...",{status:500})}}async function _(){try{return(await fetch("https://saasbackend.yacamba.com/api/supplier/get",{headers:{Authorization:"Bearer "+o.get("token")}})).json()}catch{return new Response("Something went wrong...",{status:500})}}async function T(){const[e,t,n]=await Promise.all([z(),l(),_()]);return g({code:e,categories:t,suppliers:n})}async function J({params:e}){const[t,n,s]=await Promise.all([$(e.id),_(),l()]);return g({customer:t,suppliers:n,categories:s})}async function l(){try{return(await fetch(`https://saasbackend.yacamba.com/api/client/get-categories 2`,{headers:{Authorization:"Bearer "+o.get("token")}})).json()}catch{return new Response("Something went wrong...",{status:500})}}async function j(){const[e,t,n]=await Promise.all([h(1,null,30),l(),b()]);return g({customers:e,categories:t,rewards:n})}async function v(){const[e,t,n]=await Promise.all([h(1,null,20),l(),b()]);return g({customers:e,categories:t,rewards:n})}async function b(){try{return(await fetch("https://saasbackend.yacamba.com/api/client/get-rewards",{headers:{Authorization:"Bearer "+o.get("token")}})).json()}catch{return new Response("Something went wrong...",{status:500})}}async function x(e){if(!String(e||"").trim())return[];try{const t=await fetch("https://saasbackend.yacamba.com/api/client/get-select",{headers:{Authorization:"Bearer "+o.get("token")}}),{data:n}=await t.json(),s=(n||[]).map(i=>({id:i.value,name:i.label,code:i.code,email:i.email}));return A(s,e)}catch{return[]}}async function D(e){const t={client_type:Number(e.get("client_type")),currency:e.get("currency"),category_id:e.get("client_category_id"),supplier_id:e.get("supplier_id"),name:e.get("fiscal_name"),discount:e.get("discount")||0};return(await fetch("https://saasbackend.yacamba.com/api/client/create",{method:"POST",body:JSON.stringify(t),headers:{Authorization:"Bearer "+o.get("token")}})).json()}async function $(e){try{return(await fetch(`https://saasbackend.yacamba.com/api/client/get/${e}`,{headers:{Authorization:"Bearer "+o.get("token")}})).json()}catch{return new Response("Something went wrong...",{status:500})}}async function R(e){const t={client_code:Number(e.get("client_code")),client_type:Number(e.get("client_type")),category_id:e.get("client_category_id"),supplier_id:e.get("supplier_id"),rfc:e.get("rfc"),client_group:Number(e.get("client_group")),currency:e.get("currency"),name:e.get("fiscal_name"),discount:e.get("discount")||0,client_transactional_id:e.get("client_transactional_id")};return await fetch("https://saasbackend.yacamba.com/api/client/edit",{method:"POST",body:JSON.stringify(t),headers:{Authorization:"Bearer "+o.get("token")}})}
2async function L(e){const t={client_transactional_id:e.get("customer_id")};return await fetch("https://saasbackend.yacamba.com/api/client/destroy",{method:"POST",body:JSON.stringify(t),headers:{Authorization:"Bearer "+o.get("token")}})}async function B(e){const t=e.get("start")?m(e.get("start"),"yyyy-MM-dd"):"",n=e.get("end")?m(e.get("end"),"yyyy-MM-dd"):"",s={client_transactional_id:e.get("client_transactional_id"),street:e.get("street"),ext:e.get("ext"),int:e.get("int"),cp:e.get("cp"),city:e.get("city"),cologne:e.get("cologne"),state:e.get("state"),country:e.get("country"),shopping_person:e.get("shopping_person"),comment:e.get("comment"),start:t,end:n,active:e.get("status")?"1":"0"};return await fetch("https://saasbackend.yacamba.com/api/client/create-address-info",{method:"POST",body:JSON.stringify(s),headers:{Authorization:"Bearer "+o.get("token")}})}async function M(e){const t={client_transactional_id:e.get("client_transactional_id"),street:e.get("street"),ext:e.get("ext"),int:e.get("int"),cp:e.get("cp"),city:e.get("
2city"),cologne:e.get("cologne"),state:e.get("state"),country:e.get("country"),shopping_person:0,comment:e.get("comment"),start:e.get("start"),end:e.get("end"),info_id:e.get("info_id"),active:e.get("status")=="true"};return await fetch("https://saasbackend.yacamba.com/api/client/edit-address-info",{method:"POST",body:JSON.stringify(t),headers:{Authorization:"Bearer "+o.get("token")}})}async function I(e){const t={client_transactional_id:e.get("client_transactional_id"),alias:e.get("alias"),street:e.get("street"),ext:e.get("ext"),int:e.get("int"),cologne:e.get("cologne"),city:e.get("city"),state:e.get("state"),cp:e.get("cp"),country:e.get("country"),reference:e.get("reference"),contact_name:e.get("contact_name"),contact_phone:e.get("contact_phone"),is_default:e.get("is_default")==="1"?1:0};return await fetch("https://saasbackend.yacamba.com/api/client/create-delivery-address",{method:"POST",body:JSON.stringify(t),headers:{Authorization:"Bearer "+o.get("token"),"Content-Type":"application/json",Accept:"application/json"}})}async function F(e){const t={address_id:e.get("address_id"),client_transactional_id:e.get("client_transactional_id"),alias:e.get("alias"),street:e.get("street"),ext:e.get("ext"),int:e.get("int"),cologne:e.get("cologne"),city:e.get("
2city"),state:e.get("state"),cp:e.get("cp"),country:e.get("country"),reference:e.get("reference"),contact_name:e.get("contact_name"),contact_phone:e.get("contact_phone"),is_default:e.get("is_default")==="1"?1:0};return await fetch("https://saasbackend.yacamba.com/api/client/edit-delivery-address",{method:"POST",body:JSON.stringify(t),headers:{Authorization:"Bearer "+o.get("token"),"Content-Type":"application/json",Accept:"application/json"}})}async function G(e){const t={address_id:e.get("address_id")};return await fetch("https://saasbackend.yacamba.com/api/client/destroy-delivery-address",{method:"POST",body:JSON.stringify(t),headers:{Authorization:"Bearer "+o.get("token"),"Content-Type":"application/json",Accept:"application/json"}})}async function E(e){const t={client_transactional_id:e.get("client_transactional_id"),name:e.get("name"),middle_name:e.get("middle_name"),last_name:e.get("last_name"),email:e.get("email"),phone:e.get("phone"),position:e.get("position")};return await fetch("https://saasbackend.yacamba.com/api/client/create-contact",{method:"POST",body:JSON.stringify(t),headers:{Authorization:"Bearer "+o.get("token")}})}async function q(e){const t={name:e.get("name"),middle_name:e.get("middle_name"),last_name:e.get("last_name"),email:e.get("email"),phone:e.get("phone"),position:e.get("position"),contact_id:e.get("contact_id")};return await fetch("https://saasbackend.yacamba.com/api/client/edit-contact",{method:"POST",body:JSON.stringify(t),headers:{Authorization:"Bearer "+o.get("token")}})}async function H(e){const t={contact_id:e.get("contact_id")};return await fetch("https://saasbackend.yacamba.com/api/client/destroy-contact",{method:"POST",body:JSON.stringify(t),headers:{Authorization:"Bearer "+o.get("token")}})}async function C(e){const t={client_transactional_id:e.get("client_transactional_id"),regimen_fiscal:e.get("regimen_fiscal"),razon_social:e.get("razon_social"),rfc:e.get("rfc"),uso_cfdi:e.get("uso_cfdi"),metodo_pago:e.get("metodo_pago"),email:e.get("email"),forma_pago:e.get("forma_pago"),principal_record:!!e.get("principal_record")};return await fetch("https://saasbackend.yacamba.com/api/client/create-billing-info",{method:"POST",body:JSON.stringify(t),headers:{Authorization:"Bearer "+o.get("token")}})}async function U(e){const t={billing_id:e.get("billing_id"),regimen_fiscal:e.get("regimen_fiscal"),razon_social:e.get("razon_social"),rfc:e.get("rfc"),uso_cfdi:e.get("uso_cfdi"),metodo_pago:e.get("metodo_pago"),email:e.get("email"),forma_pago:e.get("forma_pago"),principal_record:!!e.get("principal_record")};return await fetch("https://saasbackend.yacamba.com/api/client/edit-billing-info",{method:"POST",body:JSON.stringify(t),headers:{Authorization:"Bearer "+o.get("token")}})}async function W(e){const t={billing_id:e.get("billing_id")};return await fetch("https://saasbackend.yacamba.com/api/client/destroy-billing-info",{method:"POST",body:JSON.stringify(t),headers:{Authorization:"Bearer "+o.get("token")}})}async function Y(e){const t={client_transactional_id:e.get("client_transactional_id"),conditions:e.get("conditions"),interest:e.get("interest"),days_of_credit:e.get("days_of_credit"),credit_limit:e.get("credit_limit")};return await fetch("https://saasbackend.yacamba.com/api/client/create-payment-conditions",{method:"POST",body:JSON.stringify(t),headers:{Authorization:"Bearer "+o.get("token")}})}async function K(e){const t={payment_id:e.get("payment_id"),conditions:e.get("conditions"),interest:e.get("interest"),days_of_credit:e.get("days_of_credit"),credit_limit:e.get("credit_limit")};return await fetch("https://saasbackend.yacamba.com/api/client/edit-payment-conditions",{method:"POST",body:JSON.stringify(t),headers:{Authorization:"Bearer "+o.get("token")}})}async function Q(e){const t={client_id:e.get("client_id"),email:e.get("email"),password:e.get("password")};return await fetch("https://saasbackend.yacamba.com/api/client/create-login-info",{method:"POST",body:JSON.stringify(t),headers:{Authorization:"Bearer "+o.get("token")}})}async function V(e){const t={client_id:e.get("client_id"),email:e.get("email"),password:e.get("password")};return await fetch("https://saasbackend.yacamba.com/api/client/edit-login-info",{method:"POST",body:JSON.stringify(t),headers:{Authorization:"Bearer "+o.get("token")}})}
2async function X(e){const t={client_id:e.get("client_id"),email:e.get("email"),password:e.get("password")};return await fetch("https://saasbackend.yacamba.com/api/shopping-catalog/save-reward-whitdraw",{method:"POST",body:JSON.stringify(t),headers:{Authorization:"Bearer "+o.get("token")}})}async function Z(e,t){if(!e||!t)return;const n=[];(t.cp||t.street)&&n.push(u("client/create-address-info",B(d({client_transactional_id:e,street:t.street,ext:t.ext,int:t.int,cp:t.cp,city:t.city,cologne:t.cologne,state:t.state,country:t.country,shopping_person:"",comment:"",status:"1"})))),(t.rfc||t.regimen_fiscal)&&n.push(u("client/create-billing-info",C(d({client_transactional_id:e,regimen_fiscal:k(t.regimen_fiscal),razon_social:t.fiscal_name,rfc:t.rfc,uso_cfdi:"",metodo_pago:"",email:t.email||await S(),forma_pago:w,principal_record:"true"})))),await Promise.all(n)}export{b as GetRewards,Z as applyCsfToCustomer,X as confirmWithdraw,C as createBillingInfo,E as createContact,I as createDeliveryAddress,B as createGeneralInfo,Q as createLoginInfo,Y as createPaymentConditions,W as destroyBillingInfo,H as destroyContact,L as destroyCustomer,G as destroyDeliveryAddress,U as editBillingInfo,q as editContact,R as editCustomer,F as editDeliveryAddress,M as editGeneralInfo,V as editLoginInfo,K as editPaymentConditions,x as findDuplicateCustomers,l as getCategories,z as getCode,$ as getCustomer,h as getCustomers,_ as getSuppliers,T as multiLoaderCreateCustomer,v as multiLoaderSalesCustomer,j as multiLoaderSalesCustomerMobile,J as multiloaderEditCustomer,D as saveNewCustomer};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.