PageSourceSearch

https://mevcut.co/_nuxt/C1QjcpQp.js

js mevcut.co collected 2026-10-01 16:34:50 UTC 11,313 bytes, 2 lines download raw bytes

1import{c as J,p as K,B as y,A as v,x as f,v as P,af as L,W as H,ak as x,Z as Q,s as X,ae as Y,aC as N}from"./CtLYAXk2.js";let E;const p=new Uint8Array(16);function G(){if(!E&&(E=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!E))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return E(p)}const m=[];for(let c=0;c<256;++c)m.push((c+256).toString(16).slice(1));function k(c,h=0){return m[c[h+0]]+m[c[h+1]]+m[c[h+2]]+m[c[h+3]]+"-"+m[c[h+4]]+m[c[h+5]]+"-"+m[c[h+6]]+m[c[h+7]]+"-"+m[c[h+8]]+m[c[h+9]]+"-"+m[c[h+10]]+m[c[h+11]]+m[c[h+12]]+m[c[h+13]]+m[c[h+14]]+m[c[h+15]]}const V=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),j={randomUUID:V};function tt(c,h,R){if(j.randomUUID&&!h&&!c)return j.randomUUID();c=c||{};const I=c.random||(c.rng||G)();return I[6]=I[6]&15|64,I[8]=I[8]&63|128,k(I)}const et=()=>{const c=J(),h=K();async function R(){var s;const a=S(),{data:o}=await y(v(f().isAuthLoggedIn()).cartRoutes.getMaterialsCountWithToggle,{query:{client_uuid:a.getUuid()}});a.setMaterialsCount((s=o.value)==null?void 0:s.data)}async function I(){const a=S();return await y(v(f().isAuthLoggedIn()).cartRoutes.getCartWithToggle,{query:{client_uuid:a.getUuid()},transform:o=>i(o)})}async function T(){const a=S();return await y(v(f().isAuthLoggedIn()).cartRoutes.clearCartWithToggle,{method:"DELETE",query:{client_uuid:a.getUuid()}})}function b(){const a=H(),{t:o}=x().$i18n,s=Q(),l=X(),{isAuthLoggedIn:w}=f();return!s&&!w()?(a.info(o("login_required"),{timeout:1e3}),h.push(l({path:"/auth/login",query:{callbackUrl:c.path}})),!1):!0}function M(a){const o=a==null?void 0:a.reduce((s,l)=>[...s,{property_definition_id:l.property_id||l.property_definition_id,value_id:l.value_id}],[]);return o!=null&&o.length?o:[]}async function W(a,o,s,l){const w=S(),g=M(s);if(b())return await y(v(f().isAuthLoggedIn()).cartRoutes.addMaterialWithToggle,{method:"POST",body:{client_uuid:w.getUuid(),material_id:a,branch_id:l,properties_lookup_values:s!=null&&s.length?s:void 0,propertiesLookupValues:g!=null&&g.length?g:void 0,count:o||1},transform:_=>i(_)})}async function A(a,o,s){const l=s||P(),w=S();return await y(v(f().isAuthLoggedIn()).cartRoutes.setTableToStoreWithToggle(a),{method:"POST",body:{client_uuid:w.getUuid(),table_id:o,store_id:a,branch_id:l},transform:g=>i(g)})}async function O(a){const o=S();return await y(v(f().isAuthLoggedIn()).cartRoutes.removeMaterialsStoreCartWithToggle(a),{method:"DELETE",body:{client_uuid:o.getUuid(),store_id:a},transform:s=>i(s)})}async function B(a){const o=S();if(b())return await y(v(f().isAuthLoggedIn()).cartRoutes.editMaterialFromCartWithToggle,{method:"POST",body:{client_uuid:o.getUuid(),...a},transform:s=>i(s)})}async function t(a,o){const s=S();return await y(v(f().isAuthLoggedIn()).cartRoutes.editAddonsCartWithToggle(o),{method:"POST",body:{client_uuid:s.getUuid(),...a},transform:l=>i(l)})}async function n(a){const o=S();if(b())return await y(v(f().isAuthLoggedIn()).cartRoutes.addMaterialWithAddonWithToggle,{method:"POST",body:{client_uuid:o.getUuid(),...a},transform:s=>i(s)})}async function r(a){const o=S(),s=f().isAuthLoggedIn();return await y(v(s).cartRoutes.removeFromCartWithToggle,{method:"DELETE",body:{client_uuid:s?void 0:o.getUuid(),...a},transform:l=>i(l)})}async function e(a){const o=S();if(!b())return;const s=f().isAuthLoggedIn();return await y(v(s).cartRoutes.editCartOfferWithToggle,{method:"POST",body:{client_uuid:s?void 0:o.getUuid(),...a},transform:l=>i(l)})}function i(a){var l;const{cartModel:o}=f(),s=a.data||{};return s.cart_items=((l=s==null?void 0:s.cart_items)==null?void 0:l.map(o))||[],s}function d(a){switch(a){case L.Delivery:return 1;case L.Shipping:return 3;default:return}}function u(a,o,s,l){const w={...o};return a==null?void 0:a.reduce((g,_,C)=>{var U,q,D;if(_.material.id!==w.id||((U=_.material_group_offer_id)!=null?U:null)!==(l!=null?l:null)||(((q=_.addons)==null?void 0:q.length)||0)!==((s==null?void 0:s.length)||0))return g;if((D=_.addons)!=null&&D.length&&(s!=null&&s.length)){let $=0;return _.addons.forEach(Z=>{const F=s.findIndex(z=>Z.id===z.id);Number.isSafeInteger(F)&&F>=0&&$++}),$===_.addons.length&&g.push({item:_,index:C}),g}else return g.push({item:_,index:C}),g},[])}return{matchItems:u,editMaterial:B,editOffer:e,deleteMaterial:r,syncMaterials:I,setTableToStore:A,editAddonsInCart:t,clearMaterials:T,getDeliveryMethodByPattern:d,getMaterialsCount:R,addMaterial:W,reducePropertiesLookupValues:M,addMaterialWithAddons:n,removeMaterialsStore:O}},S=()=>{const{editMaterial:c,addMaterial:h,editOffer:R,reducePropertiesLookupValues:I,matchItems:T,deleteMaterial:b,editAddonsInCart:M,syncMaterials:W,removeMaterialsStore:A,addMaterialWithAddons:O,clearMaterials:B}=et();return Y("cart",{state:()=>({items:[],loading:!1,stores_tables:[],validatedItems:[],materialsCount:0,uuid:null,errors:{}}),getters:{getItem:t=>(n,r,e)=>{var d;const i=T(t.items,n,r,e);return i.length?(d=i[0])==null?void 0:d.item:null},isAuthLoggedIn:()=>f().isAuthLoggedIn(),quantity:t=>(n,r,e)=>{var d,u;const i=T(t.items,n,r,e);return i.length?(u=(d=i[0])==null?void 0:d.item)==null?void 0:u.quantity:0},itemsWithOutOffer:t=>()=>t.items.filter(n=>n.material_group_offer_id===void 0||n.material_group_offer_id===null),count:()=>t=>t.length,getTableByID:t=>n=>t.stores_tables.find(r=>parseFloat(r.store_id||"")===n),badgeCount(){return this.getCount()>9?"+9":this.getCount()},itemsByStore:t=>{const n=[...t.items];return n==null?void 0:n.reduce((e,i)=>{var d;return i.material.store&&(e["".concat(i.material.store.id,"-").concat(i.branch_id)]={id:i.material.store.id,branchId:i.branch_id,branch:i.branch,store:i.material.store,cartItems:[...((d=e["".concat(i.material.store.id,"-").concat(i.branch_id)])==null?void 0:d.cartItems)||[],i]}),e},{})},itemsByStoreSortedByOffer(){const t=this.itemsByStore,n=[];return Object.values(t).forEach(r=>{var i,d;const e={...r};e.items={withOffers:(i=e.cartItems)==null?void 0:i.reduce((u,a)=>(a.group_offer_uuid&&(u[a.group_offer_uuid]=[...u[a.group_offer_uuid]||[],a]),u),{}),withOutOffers:(d=e.cartItems)==null?void 0:d.filter(u=>u.material_group_offer_id===void 0||u.material_group_offer_id===null)},e==null||delete e.cartItems,n.push(e)}),n},quantityItemsPerStore:t=>(n,r)=>[...t.items].reduce((i,d)=>{var u,a;return((a=(u=d.material)==null?void 0:u.store)==null?void 0:a.id)===n&&(d.branch_id||void 0)===(r||void 0)&&(i=i+1),i},0)},actions:{getItemsFilter(t,n){var r;return(r=this.items)==null?void 0:r.filter(e=>{var i,d;return((d=(i=e.material)==null?void 0:i.store)==null?void 0:d.id)===t&&e.branch_id===n})},setValidationItems(t){this.validatedItems=t},setNewUuid(){return this.uuid=this.uuid||tt(),this.uuid},getUuid(){return this.uuid||this.setNewUuid()},setMaterialsCount(t){this.materialsCount=t||0},setErrors(t,n){t&&(this.errors[t]=n)},isHasItemsByPerviousCityId(t){return t===null?!1:this.items.some(n=>{var r,e;return((e=(r=n.material)==null?void 0:r.store)==null?void 0:e.city_id)===t})},setItems(t){if(this.items=[],this.setMaterialsCount(0),t!=null&&t.cart_items){const n=t==null?void 0:t.cart_items.filter(r=>{var e,i;return((i=(e=r.material)==null?void 0:e.store)==null?void 0:i.cart_visible)===1});this.setMaterialsCount(this.count(n)),this.items=n}t!=null&&t.stores_tables?this.stores_tables=t==null?void 0:t.stores_tables:this.stores_tables=[]},async addItem(t,n,r,e){var d;const i=(d=t.store)!=null&&d.id?t.store.id.toString():void 0;return this.handleReponseApi(await h(t.id,n,r,e),i)}
1,async removeMaterialsStoreCart(t){this.setErrors(t.toString(),void 0),this.handleReponseApi(await A(t),t.toString())},async addItemWithAddonAttributes(t,n=1,r,e,i,d){var s;const u=I(i),a={material_id:t.id,count:n,operation:"+",properties_lookup_values:i!=null&&i.length?i:void 0,propertiesLookupValues:u!=null&&u.length?u:void 0,material_group_offer_id:e==null?void 0:e.id,branch_id:d,addons:r},o=(s=t.store)!=null&&s.id?t.store.id.toString():void 0;return this.setErrors(o,void 0),this.handleReponseApi(await O(a),o)},async addOffer(t,n){const r=n?n.toString():void 0;return await this.handleReponseApi(await R({material_group_offer_id:t}),r)},async deleteOffer(t){var r,e;const n=(r=t.material.store)!=null&&r.id?t.material.store.id.toString():void 0;return await this.handleReponseApi(await this.deleteServerItem({store_id:(e=t.material.store)==null?void 0:e.id,material_group_offer_id:t.material_group_offer_id,group_offer_uuid:t.group_offer_uuid}),n)},async deleteOrAddOffer(t,n){var e;const r=this.getItem(t,void 0,n);r?await this.deleteOffer(r):await this.addOffer(n,(e=t.store)==null?void 0:e.id)},async deleteItem(t,n){return await this.deleteServerItem(n||{cart_item_id:t})},async toggleAddwithAddonsAttribute(t,n=1,r,e,i,d){return r!=null&&r.length?await this.addItemWithAddonAttributes(t,n,r,e,i,d):await this.addItem(t,n,i,d)},async editItem(t,n,r,e,i){var u;const d=(u=t.store)!=null&&u.id?t.store.id.toString():void 0;return this.setErrors(d,void 0),this.handleReponseApi(await c({material_id:t.id,cart_item_id:n,branch_id:r,count:i||1,operation:e}),d)},clear(){this.items=[],this.materialsCount=0,this.errors={}},catchError(t,n,r){var u,a,o,s,l,w,g;const e=t!=null&&t.data&&((u=t==null?void 0:t.data)!=null&&u.statusCode)?t==null?void 0:t.data:t,i=H(),{t:d}=x().$i18n;if((e==null?void 0:e.statusCode)===422)if((o=(a=e==null?void 0:e.data)==null?void 0:a.errors)!=null&&o.bill_detail_errors)this.setErrors(n==null?void 0:n.toString(),(s=e==null?void 0:e.data)==null?void 0:s.errors.bill_detail_errors),this.setValidationItems(e==null?void 0:e.data.errors.new_bill_details);else{const _=[];if((l=e==null?void 0:e.data)!=null&&l.errors){for(const C in e==null?void 0:e.data.errors)if(Object.hasOwnProperty.call(e==null?void 0:e.data.errors,C)){const U=e==null?void 0:e.data.errors[C];_.push(...U)}}else(w=e==null?void 0:e.data)!=null&&w.message&&_.push(e==null?void 0:e.data.message);i.error(_.length?_[0]:r||d("error_500"),{timeout:3e3}),this.setErrors(n==null?void 0:n.toString(),_)}else i.error(r||((g=e==null?void 0:e.data)==null?void 0:g.message)||d("error_500"),{timeout:3e3})},async editAddonAttribute(t,n,r,e,i=1){var u;const d=(u=t.store)!=null&&u.id?t.store.id.toString():void 0;return this.setErrors(d,void 0),this.handleReponseApi(await M({material_id:t.id,addon_id:n,cart_id:r,attribute_quantity:i,operation:e},r),d)},async deleteServerItem(t={}){var r;const{t:n}=x().$i18n;return this.setErrors(t.store_id,void 0),this.handleReponseApi(await b(t),(r=t.store_id)==null?void 0:r.toString(),n("delete_failed"))},async serverLoad(t){if(!this.loading||t){this.loading=!0,this.errors={};const n=await W();this.loading=!1,this.handleReponseApi(n,void 0,void 0,!1)}},async serverClear(){this.errors={},this.handleReponseApi(await B())},getCount(){return this.materialsCount},handleReponseApi(t,n,r,e){var o,s;const{data:i,error:d}=t||{},u=e?(o=i==null?void 0:i.value)==null?void 0:o.data:i==null?void 0:i.value,a=e?(s=d==null?void 0:d.value)==null?void 0:s.data:d==null?void 0:d.value;if(u)return this.setItems(u),!0;if(a)return this.catchError(a,n,r),!1}},persist:[{pick:["uuid"],storage:N.cookies},{pick:["items","stores_tables","hasToken","loading"],storage:N.localStorage}]})()};export{et as a,S as u};
2//# sourceMappingURL=C1QjcpQp.js.map

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.