Liferay.Loader.define("@liferay/search-experiences-web@3.0.30/sxp_blueprint_admin/js/edit_sxp_blueprint/preview_sidebar/PreviewAttributesModal",["module","exports","require","@frontend-taglib-clay$clayui/button","@frontend-taglib-clay$clayui/form","@frontend-taglib-clay$clayui/icon","@frontend-taglib-clay$clayui/modal","liferay!frontend-js-react-web$prop-types","liferay!frontend-js-react-web$react"],(function(e,t,a){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var l=_interopRequireDefault(a("@frontend-taglib-clay$clayui/button")),r=_interopRequireWildcard(a("@frontend-taglib-clay$clayui/form")),n=_interopRequireDefault(a("@frontend-taglib-clay$clayui/icon")),u=_interopRequireWildcard(a("@frontend-taglib-clay$clayui/modal")),i=(_interopRequireDefault(a("liferay!frontend-js-react-web$prop-types")),_interopRequireWildcard(a("liferay!frontend-js-react-web$react")));function _getRequireWildcardCache(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return _getRequireWildcardCache=function _getRequireWildcardCache(){return e},e}function _interopRequireWildcard(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=_getRequireWildcardCache();if(t&&t.has(e))return t.get(e);var a={},l=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){var n=l?Object.getOwnPropertyDescriptor(e,r):null;n&&(n.get||n.set)?Object.defineProperty(a,r,n):a[r]=e[r]}return a.default=e,t&&t.set(e,a),a}function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}const KeyValueRow=({id:e,onChange:t=(()=>{}),onDelete:a=(()=>{}),showLabels:u=!1,valueObject:d={key:"",value:""}})=>{const{key:o,value:c}=d;return i.default.createElement(r.default.Group,{className:"key-value-row"},i.default.createElement(r.ClayInput.Group,null,i.default.createElement(r.ClayInput.GroupItem,null,u&&i.default.createElement("label",{htmlFor:"key-".concat(e)},Liferay.Language.get("key")),i.default.createElement(r.ClayInput,{id:"key-".concat(e),onChange:({target:{value:e}})=>t({key:e,value:c}),type:"text",value:o})),i.default.createElement(r.ClayInput.GroupItem,null,u&&i.default.createElement("label",{htmlFor:"value-".concat(e)},Liferay.Language.get("value")),i.default.createElement(r.ClayInput,{id:"value-".concat(e),onChange:({target:{value:e}})=>t({key:o,value:e}),type:"text",value:c})),i.default.createElement(r.ClayInput.GroupItem,{className:"delete-button-input-group-item",shrink:!0},i.default.createElement(l.default,{"aria-label":Liferay.Language.get("delete"),borderless:!0,displayType:"secondary",monospaced:!0,onClick:a},i.default.createElement(n.default,{symbol:"times-circle"})))))};var _default=({children:e,title:t=Liferay.Language.get("attributes"),description:a,onSubmit:d=(()=>{})})=>{const[o,c]=(0,i.useState)([{key:"",value:""}]),[f,y]=(0,i.useState)(!1),{observer:p,onClose:s}=(0,u.useModal)({onClose:()=>y(!1)});return i.default.createElement(i.default.Fragment,null,f&&i.default.createElement(u.default,{className:"preview-attributes-modal",observer:p,size:"md"},i.default.createElement(u.default.Header,null,t),i.default.createElement(u.default.Body,null,a&&i.default.createElement("p",{className:"text-secondary"},a),o.map(((e,t)=>i.default.createElement(KeyValueRow,{id:t,key:t,onChange:e=>((e,t)=>{c(o.map(((a,l)=>e===l?t:a)))})(t,e),onDelete:()=>c(o.filter(((e,a)=>t!==a))),showLabels:0===t,valueObject:e}))),i.default.createElement(r.default.Group,null,i.default.createElement(l.default.Group,{spaced:!0},i.default.createElement(l.default,{"aria-label":Liferay.Language.get("add-field"),displayType:"secondary",monospaced:!0,onClick:()=>{c([...o,{key:"",value:""}])}},i.default.createElement(n.default,{symbol:"plus"}))))),i.default.createElement(u.default.Footer,{last:i.default.createElement(l.default.Group,{spaced:!0},i.default.createElement(l.default,{displayType:"secondary",onClick:s},Liferay.Language.get("cancel")),i.default.createElement(l.default,{displayType:"primary",onClick:()=>{d(o),s()}},Liferay.Language.get("done")))})),i.default.createElement("span",{onClick:()=>y(!f)},e))};t.default=_default}}));
//# sourceMappingURL=PreviewAttributesModal.js.map