1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5593],{18373:(t,e,a)=>{function r(t){switch(t.kind){case"product":return"product:".concat(t.productId,":").concat(t.storeId);case"inventory":return"inventory:".concat(t.productId,":").concat(t.storeId);case"series":return"series:".concat(t.seriesCode);case"author":return"author:".concat(t.authorSlug)}}a.d(e,{JE:()=>s,Vb:()=>n,jU:()=>c,mh:()=>i,nz:()=>l,qD:()=>o,vi:()=>r});let o=0,n=1,s=0,i=1,c=2,l=3},35593:(t,e,a)=>{a.d(e,{dx:()=>g,lx:()=>v,pC:()=>b,q7:()=>y});var r=a(12115),o=a(72944),n=a(86393),s=a(95604),i=a(75537),c=a(59559),l=a(58839),u=a(18373);let d=new Set,h=new Set,f=new Set;function p(){h.forEach(t=>t())}function x(t){return h.add(t),()=>{h.delete(t)}}function m(){return d}function w(){return d}function g(t){d.delete(t)&&p()}function v(t){let e=!1;for(let r of t){var a;let t;if(r.status!==u.qD)continue;let o=null!=(a=r.storeId)?a:"";r.watchType===u.JE?t="product:".concat(r.targetId,":").concat(o):r.watchType===u.mh?t="inventory:".concat(r.targetId,":").concat(o):r.watchType===u.jU?t="series:".concat(r.targetId):r.watchType===u.nz&&(t="author:".concat(r.targetId)),t&&!d.has(t)&&(d.add(t),e=!0)}e&&p()}function y(){0!==d.size&&(d.clear(),p())}function b(t){var e;let[a,h]=(0,r.useState)(!1),[g,v]=(0,r.useState)(null),[y,b]=(0,r.useState)(!1),[k,T]=(0,r.useState)(void 0),C=(0,r.useSyncExternalStore)(x,m,w),I=(0,u.vi)(t),P=C.has(I),{authState:S}=(0,r.useContext)(o.A),j=!!(null==S||null==(e=S.tokens)?void 0:e.access_token),{addNotification:A}=(0,r.useContext)(n.A),W=(0,c.o)(),H=(0,s.useTranslations)("common"),E=(0,r.useMemo)(()=>{switch(t.kind){case"product":return t.productName;case"inventory":return"".concat(t.productName," â ").concat(t.storeName);case"series":return t.seriesName;case"author":return t.authorName}},[t]),N=(0,r.useCallback)(()=>{y||(h(!1),v(null),T(void 0))},[y]),_=(0,r.useCallback)(()=>{d.add(I),p(),W({contextLabel:E,contextKind:t.kind,targetHref:"/mypage/watchlists"})},[E,t.kind,W,I]),z=(0,r.useCallback)(()=>{if(!f.has(I)){if("series"===t.kind)(0,i.Fg)({event:"follow_series",params:{series_slug:t.seriesSlug,series_name:t.seriesName}});else{if("author"!==t.kind)return;(0,i.Fg)({event:"follow_author",params:{author_slug:t.authorSlug,author_name:t.authorName}})}f.add(I)}},[t,I]),F=(0,r.useCallback)(async(e,a)=>{switch(t.kind){case"product":return(0,l.bM)({productId:t.productId,storeId:t.storeId,email:e,sourcePath:t.sourcePath,formContext:a});case"inventory":return(0,l.Uj)({productId:t.productId,storeId:t.storeId,email:e,sourcePath:t.sourcePath,formContext:a});case"series":return(0,l.nB)({seriesCode:t.seriesCode,email:e,sourcePath:t.sourcePath,formContext:a});case"author":return(0,l.FR)({slug:t.authorSlug,email:e,sourcePath:t.sourcePath,formContext:a})}}
1,[t]),O=(0,r.useCallback)(async t=>{if(!P&&!y){if(!j){v(t.currentTarget),h(!0),T(void 0);return}b(!0),T(void 0);try{let t=await F(void 0);z(),(null==t?void 0:t.status)===u.Vb?A(H("Watchlist.Popover.PendingVerification"),void 0,"info",!0):_()}catch(t){A(H("Watchlist.Popover.ErrorGeneric"),void 0,"error",!0)}finally{b(!1)}}},[A,_,z,j,y,P,F,H]),V=(0,r.useCallback)(async(t,e)=>{if(!y){b(!0),T(void 0);try{let a=await F(t,e);z(),(null==a?void 0:a.status)===u.Vb?A(H("Watchlist.Popover.PendingVerification"),void 0,"info",!0):_(),h(!1),v(null)}catch(t){T(H("Watchlist.Popover.ErrorGeneric"))}finally{b(!1)}}},[A,_,z,y,F,H]),D=(0,r.useCallback)(t=>{v(t.currentTarget),h(!0),T(void 0)},[]);return{isOpen:a,anchorEl:g,isSubmitting:y,errorMessage:k,isWatchedThisSession:P,isLoggedIn:j,contextLabel:E,contextKind:t.kind,openPopover:D,closePopover:N,triggerWatch:O,submitFromPopover:V}}},58839:(t,e,a)=>{a.d(e,{AV:()=>l,FR:()=>c,Uj:()=>s,bM:()=>n,hs:()=>u,nB:()=>i});var r=a(18373);async function o(t){var e;let{watchType:a,targetId:r,storeId:o,email:n,sourcePath:s,formContext:i}=t,c=window.location.pathname.includes("/b2b")?"SHOP2":"SHOP1",l=window.location.pathname.split("/"),u=l.length>1&&["sv","en"].includes(l[1])?l[1]:"sv",d=await fetch("/api/backend/watchlistCreate",{method:"POST",headers:{"Content-Type":"application/json","x-domain":c,"x-locale":u},body:JSON.stringify({request:{watchType:a,targetId:r,storeId:o,email:n,sourcePath:s,formContext:i}})});if(!d.ok)throw Error((await d.json().catch(()=>({error:"HTTP ".concat(d.status)}))).error||"Failed to create watch (HTTP ".concat(d.status,")"));let h=await d.json().catch(()=>({}));
1return{watchId:null!=(e=null==h?void 0:h.watchId)?e:"",status:+((null==h?void 0:h.status)===1)}}function n(t){return o({watchType:r.JE,targetId:t.productId,storeId:t.storeId,email:t.email,sourcePath:t.sourcePath,formContext:t.formContext})}function s(t){return o({watchType:r.mh,targetId:t.productId,storeId:t.storeId,email:t.email,sourcePath:t.sourcePath,formContext:t.formContext})}function i(t){return o({watchType:r.jU,targetId:t.seriesCode,storeId:"1",email:t.email,sourcePath:t.sourcePath,formContext:t.formContext})}function c(t){return o({watchType:r.nz,targetId:t.slug,storeId:"1",email:t.email,sourcePath:t.sourcePath,formContext:t.formContext})}async function l(){let t=await fetch("/api/backend/watchlistGetMine",{method:"POST",headers:{"Content-Type":"application/json"},body:"{}"});if(!t.ok)throw Error("Failed to load watchlist (HTTP ".concat(t.status,")"));let e=await t.json().catch(()=>({}));return{watches:Array.isArray(null==e?void 0:e.watches)?e.watches:[]}}async function u(t){let e=await fetch("/api/backend/watchlistDelete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({watchId:t})});if(!e.ok)throw Error("Failed to remove watch (HTTP ".concat(e.status,")"))}},59559:(t,e,a)=>{a.d(e,{e:()=>m,o:()=>w});var r=a(95155),o=a(84057),n=a(33567),s=a(52853),i=a(25635),c=a(97992),l=a(41983),u=a(71991),d=a(52619),h=a.n(d),f=a(12115),p=a(95604),x=a(31129);let m=(0,f.forwardRef)(function(t,e){let{id:a,heading:d,subline:m,linkText:w,linkHref:g}=t,{closeSnackbar:v}=(0,u.dh)(),y=(0,p.useTranslations)("common"),{vars:{palette:b}}=(0,n.A)(),k=(0,f.useCallback)(()=>v(a),[v,a]);return(0,r.jsx)(u.Zv,{ref:e,role:"status",children:(0,r.jsxs)(s.A,{sx:{display:"flex",alignItems:"flex-start",gap:"12px",bgcolor:b.background.paper,color:b.text.primary,borderRadius:"14px",boxShadow:"0 12px 24px rgba(0, 0, 0, 0.20)",padding:"12px 16px",minWidth:"320px",maxWidth:"420px"},children:[(0,r.jsx)(s.A,{sx:{flexShrink:0,width:32,height:32,borderRadius:"9999px",bgcolor:b.primary.main,display:"flex",alignItems:"center",justifyContent:"center",color:"#1A1A1A"},children:(0,r.jsx)(o.A,{sx:{fontSize:18}})}),(0,r.jsxs)(s.A,{sx:{flex:1,minWidth:0},children:[(0,r.jsx)(i.A,{component:"div",sx:{fontSize:14,fontWeight:600,lineHeight:1.3,mb:"2px"},children:d}),(0,r.jsxs)(i.A,{component:"div",sx:{fontSize:13,fontWeight:400,lineHeight:1.4,color:b.text.secondary},children:[m," ",(0,r.jsx)(c.A,{component:h(),href:g,underline:"always",sx:{color:b.text.primary,fontWeight:600},children:w})]})]}),(0,r.jsx)(l.A,{"aria-label":y("Watchlist.Toast.Close"),size:"small",onClick:k,sx:{flexShrink:0,p:"4px",color:b.text.primary},children:(0,r.jsx)(x.gz,{sx:{fontSize:16}})})]})})});function w(){let{enqueueSnackbar:t}=(0,u.dh)(),e=(0,p.useTranslations)("common");return(0,f.useCallback)(a=>{t(e("Watchlist.Toast.Heading",{name:a.contextLabel}),{variant:"watch",autoHideDuration:6e3,preventDuplicate:!0,heading:e("Watchlist.Toast.Heading",{name:a.contextLabel}),subline:e(function(t){switch(t){case"series":return"Watchlist.Toast.SublineSeries";case"author":return"Watchlist.Toast.SublineAuthor";default:return"Watchlist.Toast.Subline"}}(a.contextKind)),linkText:e("Watchlist.Toast.LinkText"),linkHref:a.targetHref})},[t,e])}}}]);
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.