Liferay.Loader.define("journal-web@5.0.114/js/article/PreviewButton",["module","exports","require","@frontend-taglib-clay$clayui/button","frontend-js-web","liferay!frontend-js-react-web$react"],(function(e,a,t){window;{Object.defineProperty(a,"__esModule",{value:!0}),a.default=function PreviewButton({disabled:e,getPreviewURL:a,namespace:t,newArticle:u,saveAsDraftURL:i}){return o.default.createElement(n.default,{"aria-label":Liferay.Language.get("a-draft-will-be-saved-before-displaying-the-preview"),disabled:e,displayType:"secondary",onClick:()=>{updateJournalInput({name:"formDate",namespace:t,value:Date.now().toString()});const e=document.getElementById("".concat(t,"fm1")),n=new FormData(e),o=document.getElementById("".concat(t,"articleId"));return n.append("".concat(t,"cmd"),u&&!o.value?"add":"update"),Liferay.Util.fetch(i,{body:n,method:e.method}).then((e=>e.json())).then((e=>{const{articleId:n,error:o,friendlyUrlMap:u,version:i}=e;o?(0,r.openToast)({message:Liferay.Language.get("web-content-could-not-be-previewed-due-to-an-unexpected-error-while-generating-the-draft"),title:Liferay.Language.get("error"),type:"danger"}):(updateJournalInput({name:"formDate",namespace:t,value:Date.now().toString()}),updateJournalInput({name:"articleId",namespace:t,value:n}),updateJournalInput({name:"version",namespace:t,value:i}),Object.entries(u).forEach((([e,a])=>{updateJournalInput({name:"friendlyURL_".concat(e),namespace:t,value:a})})),(0,r.openModal)({title:Liferay.Language.get("preview"),url:a(e)}))})).catch((()=>{(0,r.openToast)({message:Liferay.Language.get("web-content-could-not-be-previewed-due-to-an-unexpected-error-while-generating-the-draft"),title:Liferay.Language.get("error"),type:"danger"})}))},title:!e&&Liferay.Language.get("a-draft-will-be-saved-before-displaying-the-preview")},Liferay.Language.get("preview"))};var n=_interopRequireDefault(t("@frontend-taglib-clay$clayui/button")),r=t("frontend-js-web"),o=_interopRequireDefault(t("liferay!frontend-js-react-web$react"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function updateJournalInput({name:e,namespace:a,value:t}){const n=document.getElementById("".concat(a).concat(e));n&&(n.value=t)}}}));
//# sourceMappingURL=PreviewButton.js.map