1import{r as e,j as o}from"./react-vendor.B75MsAI9.js";import{u as l,cp as t,M as a,T as s,cr as i,g as r,a as d,dB as n,dC as f,dD as h,dE as b}from"./AuthModalContainer.CwDh3qj_.js";const c=({isVisible:c,isRtl:g,bookShelfArr:m,isFetchingBookShelves:k,userBookshelves:u,loading:p,getBookshelfAutocompletefWorkflow:_,getBookshelfListWorkflow:v,addBookshelfWorkflow:x,onCloseClicked:y,addSlimNotification:w,slug:j,fetchUserListsWorkflow:B,validateSearchWordWorkFlow:C,addNewBookToBookshelfWorkflow:S,onTriggerEvents:N,book:$,userId:I,userType:W,eventCategory:E})=>{const L=l(),M="pb-select-bookshelf",[T,A]=e.useState(""),[F,R]=e.useState(""),[U,D]=e.useState(""),[H,V]=e.useState(!1),[q,z]=e.useState("");if(e.useEffect(()=>{c&&v()},[c]),!c)return null;const G=o.jsx("h2",{dir:t(L("global.bookshelf-add-header"))?"rtl":"ltr",className:`${M}__modal-title`,children:L("global.bookshelf-add-header")}),J=o.jsx("div",{className:`${M}__loader-el`,children:o.jsx(i,{})}),K=o.jsx("div",{className:`${M}__bookshelf-el`,children:H?o.jsx("div",{dir:t(q)?"rtl":"ltr",className:`${M}__create-message--danger`,children:q}):p?J:u.length>0?m.map((e,l)=>o.jsx("p",{dir:t(e.title)?"rtl":"ltr",className:`${M}__bookshelf-item`,onClick:()=>((e,o)=>{let l=u.find(e=>e.title===o);l&&l.books&&l.books.length>=24?(V(!0),z(L("global.bookshelf-max-limit-notification")),R(o)):S({bookshelfId:e,storyId:j}).then(e=>{e.ok||e.data?(window.dataLayer.push({event:d.existingBookshelf,category:E,label:r.confirmModal,item_type:null,item_id:null,item_value:null,user_id:I||"00000",user_profile:W}),w({type:"success",id:"Book.book-added-notification",content:L("global.bookshelf-book-aaded-success-msg")}),localStorage.setItem("sw-bookshelf","bookshelf"+Math.random()),y(),B()):(V(!0),z(L("global.bookshelf-max-limit-notification")),R(o))})})(e.slug,e.title),children:e.title},l)):o.jsxs("div",{className:`${M}__create-message`,children:[o.jsx("span",{dir:t(L("global.bookshelf-empty-message1"))?"rtl":"ltr",className:`${M}__create-message-bold-text`,children:L("global.bookshelf-empty-message1")})," ",L("global.bookshelf-empty-message2").trim()]})});return o.jsxs(a,{parentClassName:g?`${M} ${M}__modal-wrapper`:`${M}`,header:G,footer:null,onClose:()=>{R(""),V(!1),z(""),y(),N&&N({gtmEvent:d.closedBookshelf,gtmLabel:r.confirmModal,d3:$.language})},isRtl:g,reducedLineHeight:!0,children:[o.jsx(s,{label:L("global.bookshelf-textfield"),value:F,fontFamily:"monospace",onChange:async e=>{const o=e.target.value;if(R(o),V(!1),b(o))D(L("global.url-not-allowed"));else{const e=n(L("global.bookshelf-textfield"),o);D(e[0]||"")}o?_(o):v()},isRtl:t(L("global.bookshelf-textfield")),buttonWithText:!0,buttonText:L("global.bookshelf-add"),onClick:async()=>{const e=n(L("global.bookshelf-textfield"),F);if(e.length)return void D(e[0]);const o=await f(F,C,L);if(!o.valid)return void D(o.message||L("global.url-not-allowed"));let l=!1;u.forEach(e=>{e.title.toUpperCase()===F.toUpperCase()&&(l=!0)}),u.length>=h||0===F.trim().length||l?(V(!0),z(L("global.bookshelf-limit")),0===F.trim().length&&z(L("global.bookshelf-title-blank")),l&&z(L("global.bookshelf-title-duplicate"))):(window.dataLayer.push({event:d.bookshelfAdded,category:E,label:d.bookShelf,item_type:null,item_id:null,item_value:null,user_id:I||"00000",user_profile:W}),x({title:F,storyId:j}).then(e=>{e.ok&&e.data?(w({type:"info",id:"Book.book-removed-notification",content:L("global.bookshelf-added-new")}),localStorage.setItem("sw-bookshelf","bookshelf"+Math.random()),R(""),V(!1),z(""),N&&N({gtmEvent:d.bookshelfAdded,gtmLabel:r.confirmModal,d3:$.language}),y(),B()):w({type:"danger",content:(null==e?void 0:e.error)||"Invalid list data"})},e=>{w({type:"danger",content:(null==e?void 0:e.message)||"Invalid list data"})}))},buttonDisabled:Boolean(U),error:"string"==typeof U?U:"",customError:Boolean(U),autoFocus:!0}),o.jsx("div",{className:`${M}__loader-bookshelf-wrapper`,children:k?J:U?"":K})]})};export{c as default}; 2//# sourceMappingURL=SelectBookShelf.C4MP3sdZ.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.