PageSourceSearch

https://petstory.ru/product-finder/_nuxt/DdZp0NGf.js

js petstory.ru collected 2026-10-01 10:39:48 UTC 8,307 bytes, 1 lines download raw bytes

1import{a8 as _}from"./Cxdmyf11.js";import{N,q as b,a as F,t as T,x as M}from"./BRJV5OZO.js";const k="pslib:notification-mock-state";function A(t,n,i){return{id:t,userId:1,author:"petstory",title:i,content:`${i}. Тестовое содержимое уведомления.`,status:n,sendAt:new Date(Date.now()-t*6e4).toISOString(),action:{type:"notification.open_page"}}}function C(){return[A(3,"sent","Новое уведомление №3"),A(2,"sent","Новое уведомление №2"),A(1,"read","Прочитанное уведомление")]}function y(){const t=localStorage.getItem(k);if(!t){const n=C();return E(n),n}try{return JSON.parse(t)}catch{const n=C();return E(n),n}}function E(t){localStorage.setItem(k,JSON.stringify(t))}function v(){return!1}function O(){const t=y();return{success:!0,data:{count:t.length,unreadCount:t.filter(n=>n.status==="sent").length}}}function q(t){const n=t.offset??0,i=t.limit??10,e=y().filter(u=>!t.status||u.status===t.status);return{success:!0,data:e.slice(n,n+i),pagination:{count:e.length,limit:i,offset:n}}}function B(t){return{success:!0,data:y().find(n=>n.id===t)??null}}function U(t){const n=y().map(i=>i.id===t?{...i,status:"read"}:i);return E(n),{success:!0,data:{success:!0}}}let l=null;const $=_("notificationsStore",{state:()=>({unreadCount:null,currentNotification:{},totalCount:0,count:null,fakeNotification:{id:0,userId:0,author:"petstory",title:"Войдите, чтобы следить за состоянием питомца по основным параметрам здоровья",content:"",status:"sent",sendAt:new Date().toISOString()},forumOpenNotification:null,isLoading:!1,notifications:[],offset:0,hasMore:!0,isUnreadTest:!1,unreadRequestSequence:0}),getters:{getUnreadCount:t=>t.unreadCount,getTotalCount:t=>t.totalCount,getCount:t=>t.count,getFakeNotification:t=>t.fakeNotification,getForumOpenNotification:t=>t.forumOpenNotification,getNotifications:t=>t.notifications,getHasMore:t=>t.hasMore,getLoading:t=>t.isLoading,getIsUnreadTest:t=>t.isUnreadTest},actions:{setUnreadCount(t){this.unreadCount=t},setCount(t){if(t==null){this.count=null;return}Number.isFinite(t)&&(this.count=Math.max(0,t))},invalidateUnreadCountRequests(){this.unreadRequestSequence+=1,l=null},async ensureCount(){return typeof this.count=="number"?this.count:(await(l??this.fetchUnreadCount()),typeof this.count=="number"?this.count:(await this.fetchUnreadCount(),this.count))},setNotification(t){this.currentNotification=t},setTotalCount(t){this.totalCount=t},setFakeNotificationStatus(t){this.fakeNotification={...this.fakeNotification,status:t?"read":"sent"}},setForumOpenNotification(t){this.forumOpenNotification=t},setLoading(t){this.isLoading=t},setNotifications(t,n){this.notifications=n?t:[...this.notifications,...t]},setOffset(t){this.offset=t},setHasMore(t){this.hasMore=t},setIsUnreadTest(t){this.isUnreadTest=t},async fetchUnreadCount(){if(l)return l;const t=(async()=>{const n="/proxy/api/gateway/notification/profile/unread-count",i=++this.unreadRequestSequence;try{const e=v()?O():await N(n,{method:"GET"}).then(u=>u).catch(u=>u);if(i!==this.unreadRequestSequence)return!1;if(e&&e.success&&e.data){const u=e.data;return this.setUnreadCount(u.unreadCount),this.setCount(u.count),u}return!1}catch(e){return i===this.unreadRequestSequence&&console.error(e),!1}})();l=t;try{return await t}finally{l===t&&(l=null)}},async fetchNotifications(t,n){const i="/proxy/api/gateway/notification/profile";n&&this.setLoading(!0);try{const e=v()?q(t):await N(i,{method:"GET",params:t}).then(u=>u).catch(u=>u);return e&&e.success&&e.data?(this.setTotalCount(e.pagination?.count||0),this.setLoading(!1),e):(this.setLoading(!1),!1)}catch(e){return console.error(e),e}},async loadNotifications(t){const n=b(),i=()=>v()||!!(n.getAuthToken||T("X-Auth-Token").value),{clear:e,...u}=t;if(e&&(this.setOffset(0),this.setHasMore(!0)),!(this.isLoading||!this.hasMore||!i())){this.setLoading(!0);try{const r=await this.fetchNotifications({offset:this.offset,limit:u.limit??10,status:u.status});if(!r?.data)return;const f=this.offset+(u.limit??10);this.setOffset(f),this.setHasMore(f<this.totalCount);let s=e?[...r.data]:[...this.notifications,...r.data];const{$pslibNotificationsUpdateList:d}=F();if(typeof d=="function")try{s=await d({list:s,clear:e,clearList:e,activeTab:u.status??""})??s}catch(m){console.error(m)}this.setNotifications(s,!0)}finally{this.setLoading(!1)}}},async fetchNotification(t){const n=`/proxy/api/gateway/notification/profile/${t}`;try{const i=v()?B(t):await N(n,{method:"GET"}).then(e=>e).catch(e=>e);if(i&&i.success&&i.data){const e=i.data||[];return this.setNotification(e),e}else return!1}catch(i){return console.error(i),i}},async readNotification(t){const n=`/proxy/api/gateway/notification/${t}/read`;try{const i=v()?U(t):await N(n,{method:"POST"}).then(e=>e).catch(e=>e);return i&&i.success&&i.data?(i.data||[]).success:!1}catch(i){return console.error(i),i}}}}),x=t=>{if(t==null||t==="")return"—";const n=["янв.","февр.","марта","апр.","мая","июня","июля","авг.","сент.","окт.","ноя.","дек."],i=new Date,e=new Date(t);if(Number.isNaN(e.getTime()))return"—";const u=new Date(i.getFullYear(),i.getMonth(),i.getDate()),r=new Date(e.getFullYear(),e.getMonth(),e.getDate()),f=Math.floor((u.getTime()-r.getTime())/(1e3*60*60*24)),s=`${e.getHours().toString().padStart(2,"0")}:${e.getMinutes().toString().padStart(2,"0")}`;return f===0?`Сегодня, ${s}`:f===1?`Вчера, ${s}`:`${e.getDate()} ${n[e.getMonth()]}, ${s}`},R=()=>{const{push:t,way:n}=M();function i(o){const a={event:"AnalyticsEvent",eventName:"header_notification_click",eventSection:"notification",eventBlock:"header",eventAction:"click",eventLabel:o,eventLocation:n};return t(a),a}function e(o){const a={event:"AnalyticsEvent",eventName:"notification_list_open",eventSection:"notification",eventBlock:"list",eventAction:"open",eventLabel:o,eventLocation:n};return t(a),a}function u(o,a){const c={event:"AnalyticsEvent",eventName:"notification_list_view",eventSection:"notification",eventBlock:"list",eventAction:"view",eventElement:o,eventLabel:a,eventLocation:n};return t(c),c}function r(o,a,c,g,p){const h={event:"AnalyticsEvent",eventName:"notification_inList_view",eventSection:"notification",eventBlock:"inList",eventAction:"view",eventElement:o,eventLabel:a,notificationName:g,notificationDateSend:p,type:{read:"Прочитанное",sent:"Новое"}[c],eventLocation:n};return t(h),h}function f(o,a,c,g,p){const h={event:"AnalyticsEvent",eventName:"notification_list_click",eventSection:"notification",eventBlock:"list",eventAction:"click",eventElement:o,eventLabel:a,notificationName:g,notificationDateSend:p,type:{read:"Прочитанное",sent:"Новое"}[c],eventLocation:n};return t(h),h}function s(o){const a={event:"AnalyticsEvent",eventName:"notification_item_view",eventSection:"notification",eventBlock:"item",eventAction:"view",eventLabel:o,eventLocation:n};return t(a),a}function d(o,a){const c={event:"AnalyticsEvent",eventName:"notification_item_click",eventSection:"notification",eventBlock:"item",eventAction:"click",eventElement:a,eventLabel:o,eventLocation:n};return t(c),c}function m(){const o={event:"AnalyticsEvent",eventName:"header_notificNotAutoriz_show",eventSection:"notificNotAutoriz",eventBlock:"header",eventAction:"show",eventLocation:n};return t(o),o}function L(){const o={event:"AnalyticsEvent",eventName:"header_notificNotAutoriz_click",eventSection:"notificNotAutoriz",eventBlock:"header",eventAction:"click",eventLocation:n};return t(o),o}function S(){const o={event:"AnalyticsEvent",eventName:"notificNotAutoriz_list_open",eventSection:"notificNotAutoriz",eventBlock:"list",eventAction:"open",eventLocation:n};return t(o),o}function w(o){const a={event:"AnalyticsEvent",eventName:`notificNotAutoriz_list_${o}_click`,eventSection:"notificNotAutoriz",eventBlock:"list",eventElement:o,eventAction:"click",eventLocation:n};return t(a),a}return{headerNotificationClick:i,notificationListOpen:e,notificationListView:u,notificationListClick:f,notificationItemView:s,notificationItemClick:d,notificNotAutorizShow:m,notificNotAutorizClick:L,notificNotAutorizListOpen:S,notificNotAutorizListClick:w,notificationInListView:r}};
1export{$ as a,x as f,v as i,R as u};

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.