Liferay.Loader.define("portal-workflow-kaleo-designer-web@5.0.83/designer/js/definition-builder/diagram-builder/components/sidebar/DefnitionInfo",["module","exports","require","@frontend-taglib-clay$clayui/button","@frontend-taglib-clay$clayui/tabs","portal-workflow-kaleo-designer-web$moment/min/moment-with-locales","liferay!frontend-js-react-web$react","../../../DefinitionBuilderContext","../../../util/fetchUtil","../../../util/lang"],(function(e,t,a){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(){const[e,t]=(0,i.useState)(0),{definitionInfo:a,version:n}=(0,i.useContext)(o.DefinitionBuilderContext);return i.default.createElement(i.default.Fragment,null,i.default.createElement(l.default,null,m.map((({label:a},n)=>i.default.createElement(l.default.Item,{active:e===n,key:n,onClick:()=>t(n)},a)))),i.default.createElement(l.default.Content,{activeIndex:e,fade:!0},m.map((({Component:e},t)=>i.default.createElement(l.default.TabPane,{key:t},i.default.createElement(e,{definitionInfo:a,version:n}))))))};var n=a("@frontend-taglib-clay$clayui/button"),l=d(a("@frontend-taglib-clay$clayui/tabs")),r=d(a("portal-workflow-kaleo-designer-web$moment/min/moment-with-locales")),i=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=f();if(t&&t.has(e))return t.get(e);var a={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var l in e)if(Object.prototype.hasOwnProperty.call(e,l)){var r=n?Object.getOwnPropertyDescriptor(e,l):null;r&&(r.get||r.set)?Object.defineProperty(a,l,r):a[l]=e[l]}a.default=e,t&&t.set(e,a);return a}(a("liferay!frontend-js-react-web$react")),o=a("../../../DefinitionBuilderContext"),u=a("../../../util/fetchUtil"),s=d(a("../../../util/lang"));function f(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return f=function(){return e},e}function d(e){return e&&e.__esModule?e:{default:e}}r.default.locale(Liferay.ThemeDisplay.getBCP47LanguageId());const e=({versionNumber:e})=>{const{definitionId:t,setAlertMessage:a,setAlertType:l,setDefinitionId:r,setShowAlert:f,setVersion:d}=(0,i.useContext)(o.DefinitionBuilderContext),c=t=>{const n=s.default.sub(Liferay.Language.get("restored-to-revision-x"),[e]);a(n),l("success"),f(!0),t.json().then((({name:e,version:t})=>{r(e),d(parseInt(t,10))}))},m=()=>{const e=Liferay.Language.get("unable-to-restore-this-item");a(e),l("danger"),f(!0)};return i.default.createElement("div",{className:"info-group"},i.default.createElement("div",{className:"version-row"},i.default.createElement("label",{className:"text-secondary"},Liferay.Language.get("version")," ",e),i.default.createElement(n.ClayButtonWithIcon,{className:"text-secondary",displayType:"unstyled",onClick:()=>{(0,u.retrieveDefinitionRequest)(t,e).then((e=>e.json())).then((({active:e,content:a,title:n,title_i18n:l,version:r})=>{e?(0,u.publishDefinitionRequest)({active:e,content:a,name:t,title:n,title_i18n:l,version:r}).then((e=>{e.ok?c(e):m()})):(0,u.saveDefinitionRequest)({active:e,content:a,name:t,title:n,version:r}).then((e=>{e.ok?c(e):m()}))}))},symbol:"restore",title:Liferay.Language.get("restore")})),i.default.createElement("div",{className:"sheet-subtitle"}))},c=({version:t})=>{const a=[];for(let e=t-1;e>0;e--)a.push({versionNumber:e});return i.default.createElement(i.default.Fragment,null,i.default.createElement("div",{className:"info-group"},i.default.createElement("label",null,Liferay.Language.get("current-version"),": ",t),i.default.createElement("div",{className:"sheet-subtitle"})),a.map((({versionNumber:t},a)=>i.default.createElement(e,{key:a,versionNumber:t}))))},m=[{Component:({definitionInfo:e})=>{const t=Liferay.Language.get("created"),a=Liferay.Language.get("last-modified"),n=Liferay.Language.get("total-modifications"),l=r.default.utc(e.dateCreated).format(Liferay.Language.get("mmm-dd-yyyy-lt")),o=r.default.utc(e.dateModified).format(Liferay.Language.get("mmm-dd-yyyy-lt")),u=e.totalModifications,f=u>1?s.default.sub(Liferay.Language.get("x-revisions"),[u]):"".concat(u," ").concat(Liferay.Language.get("revision"));return i.default.createElement(i.default.Fragment,null,i.default.createElement("div",{className:"info-group"},i.default.createElement("label",{className:"text-secondary"},t.toUpperCase()),i.default.createElement("span",null,l)),i.default.createElement("div",{className:"info-group"},i.default.createElement("label",{className:"text-secondary"},a.toUpperCase()),i.default.createElement("span",null,o)),i.default.createElement("div",{className:"info-group"},i.default.createElement("label",{className:"text-secondary"},n.toUpperCase()),i.default.createElement("span",null,f)))},label:Liferay.Language.get("details")},{Component:c,label:Liferay.Language.get("revision-history")}]}}));
//# sourceMappingURL=DefnitionInfo.js.map