import{c as e,d as t}from"./objectSpread2-DtFdQpqy.js";import{a as n,n as r}from"./preload-helper-EQ20WQt-.js";import{F as i,c as a,l as o}from"./prop-types-DdDwMzX7.js";import{Do as s,Dt as c,Eo as l,Qi as u,ra as d}from"./time-BE5vfriQ.js";import{E as f}from"./compose_form_container-fJeJ5S-L.js";var p=e({RevokeCollectionInclusionModal:()=>v,useConfirmRevoke:()=>_}),m=t(n()),h=r(),g=a({revokeCollectionInclusionTitle:{id:`confirmations.revoke_collection_inclusion.title`,defaultMessage:`Remove yourself from this collection?`},revokeCollectionInclusionMessage:{id:`confirmations.revoke_collection_inclusion.message`,defaultMessage:`This action is permanent, and the curator won't be able to re-add you to the collection later on.`},revokeCollectionInclusionConfirm:{id:`confirmations.revoke_collection_inclusion.confirm`,defaultMessage:`Remove me`}});function _(e){var t;let n=l(),{id:r,items:a=[]}=e==null?{}:e,o=(t=a.find(e=>e.account_id===i))==null?void 0:t.id;return(0,m.useCallback)(()=>{n(u({modalType:`REVOKE_COLLECTION_INCLUSION`,modalProps:{collectionId:r,collectionItemId:o}}))},[n,r,o])}var v=({collectionId:e,collectionItemId:t,onClose:n})=>{let r=o(),i=l(),a=s(t=>{var n;return(n=t.collections.collections[e])==null?void 0:n.name}),u=(0,m.useCallback)(async()=>{try{await i(c({collectionId:e,itemId:t})).unwrap(),i(d({message:r.formatMessage({id:`collections.revoke_inclusion.confirmation`,defaultMessage:`You've been removed from "{collection}"`},{collection:a})}))}catch(e){i(d({message:r.formatMessage({id:`collections.revoke_inclusion.error`,defaultMessage:`There was an error, please try again later.`})}))}},[i,e,a,t,r]);return(0,h.jsx)(f,{title:r.formatMessage(g.revokeCollectionInclusionTitle),message:r.formatMessage(g.revokeCollectionInclusionMessage),confirm:r.formatMessage(g.revokeCollectionInclusionConfirm),onConfirm:u,onClose:n})};export{_ as n,p as t};
//# sourceMappingURL=revoke_collection_inclusion_modal-3P6rYFFn.js.map