PageSourceSearch

https://lk.resosearch.ru/build/assets/SharedSessionView-B6-IsD8k.js

js resosearch.ru collected 2026-09-25 05:47:07 UTC 6,886 bytes, 3 lines download raw bytes

1import{cw as u,cQ as P,a6 as R,dA as V,bJ as U,ce as t,b8 as x,D as c,at as M,t as d,p as F,aU as f,H as W,bM as B}from"./PopupSearchContainer-B4jkP1YD.js";import{c5 as D,H as G,G as C}from"./ErrorBoundary-BTAzdVZB.js";import{a as H,s as a,I as L,C as Q}from"./AssistantProductCard.module-CPnXsOOp.js";import"./Grow-C3M5W-Rf.js";import"./TextField-rFgLEG3v.js";import"./LightTooltip-CW_0fb6M.js";import"./ExpandMore-fIg9bOu6.js";import"./Search-Bpi7jej7.js";function $({product:e,searchSettings:s}){const[r,n]=u.useState(()=>new Set),b=P(s[R.PriceGroupingMode]?.value),p=u.useMemo(()=>H(e),[e]),{attributes:S,selectedValues:N,selectedVariant:A,selectAttribute:j}=V(p,e.id,s),h=p.length>0?A??null:null,g=h?e.variants.find(_=>_.id===h.id)??null:null,i=g?g.price:e.price,o=g?.url??e.url,l=g?.imageUrl??e.imageUrl,v=l&&!r.has(l),E=[e.category,e.vendor].filter(Boolean).join(" · "),T=i!=null?U(i,b):"",O=t.jsxs(t.Fragment,{children:[t.jsx("div",{className:a.thumb,children:v?t.jsx("img",{src:l,alt:e.name,draggable:!1,className:x(a.img,c.product.image),onError:()=>{n(_=>new Set(_).add(l))}}):t.jsx(L,{className:x(a.placeholder,c.product.image,c.product.imageFallback)})}),t.jsxs("div",{className:a.body,children:[t.jsx("span",{className:x(a.name,c.product.name),children:e.name}),h&&t.jsx(M,{attributes:S,selectedValues:N,selectedVariant:h,onSelect:j}),t.jsx("div",{className:a.footer,children:t.jsxs("div",{className:a.info,children:[T!==""&&t.jsxs("span",{className:x(a.price,c.product.price),children:[T," ₽"]}),E&&t.jsx("div",{className:x(a.meta,c.product.meta),children:E})]})})]})]});return o?t.jsx("a",{className:x(a.card,a.clickable,c.product.root,c.product.clickable),href:o,target:"_blank",rel:"noopener noreferrer",children:O}):t.jsx("div",{className:x(a.card,c.product.root),children:O})}const y=e=>typeof e=="string"?e:"",m=e=>typeof e=="string"?e:null,k=e=>typeof e=="number"?e:null,I=e=>typeof e=="boolean"?e:null,z=e=>{if(typeof e!="object"||e===null||Array.isArray(e))return{};const s={};for(const[r,n]of Object.entries(e))typeof n=="string"&&(s[r]=n);return s},q=e=>({id:y(e.id),name:y(e.name),price:k(e.price),attributes:z(e.attributes),availabilityType:m(e.availabilityType??e.availability_type),availableQuantity:I(e.availableQuantity??e.has_available_quantity),url:m(e.url),imageUrl:m(e.imageUrl??e.image_url)}),J=e=>Array.isArray(e)?e.filter(s=>typeof s=="object"&&s!==null).map(q):[],X=e=>({id:y(e.id),name:y(e.name),price:k(e.price),category:m(e.category),vendor:m(e.vendor),imageUrl:m(e.imageUrl??e.image_url),vendorCode:y(e.vendorCode??e.vendor_code),availabilityType:m(e.availabilityType??e.availability_type),availableQuantity:I(e.availableQuantity??e.has_available_quantity),url:m(e.url),isRelevant:I(e.isRelevant??e.is_relevant)??!0,variants:J(e.variants)}),K="⚠️ Ответ не получен: во время обработки запроса произошла ошибка",Y="⚠️ Ответ не получен полностью: во время обработки запроса произошла ошибка",Z=e=>e.trim()===""?K:`${e}
2
3${Y}`,w=(e,s)=>{const r=e.role==="assistant",n=r?(e.products??[]).map(X):void 0;return{id:`shared-${s}`,role:r?"incoming":"outgoing",content:e.failed?Z(e.content):e.content,products:n&&n.length>0?n:void 0}},ee="ROLE_ADMIN",te=e=>e.axiosError?.response?.status===401,se=e=>{try{const s=e.split(".")[1];if(!s)return!1;const r=s.replace(/-/g,"+").replace(/_/g,"/"),n=r.padEnd(r.length+(4-r.length%4)%4,"="),p=JSON.parse(window.atob(n)).roles;return Array.isArray(p)&&p.includes(ee)}catch{return!1}},re=e=>{const s=B();return!s||!se(s)?C.getSharedSession({token:e}):C.getSharedSession({token:e},{headers:{Authorization:`Bearer ${s}`}}).catch(r=>{if(te(r))return C.getSharedSession({token:e});throw r})},ne={notFound:"Ссылка недействительна или диалог не найден.",revoked:"Доступ к этому диалогу был отозван.",expired:"Ссылка больше не действует.",error:"Не удалось загрузить диалог. Попробуйте позже."};function pe(){const{token:e}=D(),[s,r]=u.useState("loading"),[n,b]=u.useState(""),[p,S]=u.useState({}),[N,A]=u.useState([]),[j,h]=u.useState(0);u.useEffect(()=>{if(!e){r("notFound");return}let i=!1;return re(e).then(({data:o})=>{i||(b(o.shopName),S(o.searchSettings),A(o.messages.map(w)),h(o.messages.filter(l=>l.adminOnly).length),r("ready"))}).catch(o=>{if(i)return;const l=o?.axiosError?.response,v=l?.status;if(v===410){r(l?.data?.message==="Shared session link has expired"?"expired":"revoked");return}r(v===404?"notFound":"error")}),()=>{i=!0}},[e]);const g=n?`Чат с ассистентом · ${n}`:"Чат с ассистентом";return t.jsxs(t.Fragment,{children:[t.jsxs(G,{children:[t.jsx("title",{children:g}),t.jsx("meta",{name:"robots",content:"noindex, nofollow"})]}),t.jsxs(d,{sx:{display:"flex",flexDirection:"column",height:"100dvh",overflow:"hidden",bgcolor:"background.default","--widget-color":"#1161FB"},children:[t.jsxs(d,{component:"header",sx:{flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",gap:1.5,px:2,py:1.5,borderBottom:1,borderColor:"divider"},children:[t.jsx(d,{sx:{display:"flex",alignItems:"center",justifyContent:"center",width:36,height:36,borderRadius:"50%",bgcolor:"primary.main",color:"primary.contrastText"},"aria-hidden":"true",children:t.jsx(F,{sx:{fontSize:20}})}),t.jsxs(d,{children:[t.jsx(f,{variant:"subtitle1",noWrap:!0,sx:{fontWeight:600,lineHeight:1.2,maxWidth:{xs:"60vw",sm:360}}
3,children:n||"Магазин"}),t.jsx(f,{variant:"caption",color:"text.secondary",children:"Сохранённая копия диалога"})]})]}),t.jsxs(d,{sx:{flex:1,width:"100%",maxWidth:984,mx:"auto",display:"flex",flexDirection:"column",minHeight:0},children:[s==="loading"&&t.jsx(d,{sx:{flex:1,display:"flex",alignItems:"center",justifyContent:"center"},children:t.jsx(W,{})}),s==="ready"&&j>0&&t.jsx(d,{role:"status",sx:{flexShrink:0,mx:2,mt:2,px:2,py:1.25,borderRadius:1,bgcolor:"action.hover"},children:t.jsxs(f,{variant:"caption",color:"text.secondary",children:["Скрытых от покупателя сообщений: ",j,". Их видно только администраторам"]})}),s==="ready"&&t.jsx(Q,{isLoading:!1,messages:N,renderProduct:i=>t.jsx($,{product:i,searchSettings:p},i.id)}),s!=="loading"&&s!=="ready"&&t.jsx(d,{sx:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",px:3,textAlign:"center"},children:t.jsx(f,{color:"text.secondary",children:ne[s]})})]}),t.jsx(d,{component:"footer",sx:{flexShrink:0,py:1.5,textAlign:"center",borderTop:1,borderColor:"divider"},children:t.jsx(f,{variant:"caption",color:"text.secondary",children:"Это сохранённая копия диалога (только для чтения)"})})]})]})}export{pe as default};

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.