Liferay.Loader.define("layout-seo-web@2.0.66/js/seo/display_page_templates/components/MappingInput",["module","exports","require","@frontend-taglib-clay$clayui/form","@liferay/frontend-js-react-web","liferay!frontend-js-react-web$prop-types","liferay!frontend-js-react-web$react","./MappingPanel"],(function(e,t,r){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=_interopRequireWildcard(r("@frontend-taglib-clay$clayui/form")),a=r("@liferay/frontend-js-react-web"),l=(r("liferay!frontend-js-react-web$prop-types"),_interopRequireWildcard(r("liferay!frontend-js-react-web$react"))),c=function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}(r("./MappingPanel"));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 r={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in e)if(Object.prototype.hasOwnProperty.call(e,a)){var l=n?Object.getOwnPropertyDescriptor(e,a):null;l&&(l.get||l.set)?Object.defineProperty(r,a,l):r[a]=e[a]}return r.default=e,t&&t.set(e,r),r}function ownKeys(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(r),!0).forEach((function(t){_defineProperty(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function _defineProperty(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const sanitizeLabel=e=>e.replace(/}|[\r\n]+/gm,""),fieldTemplate=(e,t)=>" ${".concat(e,":").concat(sanitizeLabel(t),"} ");var o=function MappingInput({component:e,fieldTypes:t,fields:r,helpMessage:o,label:u,name:i,selectedSource:f,value:p}){const[s,d]=(0,l.useState)(f),[y,b]=(0,l.useState)(p||""),m=(0,l.useRef)(null),j=(0,a.useIsMounted)(),g=!!y.trim(),O=f?f.classTypeLabel||f.classNameLabel:"";return l.default.createElement(n.default.Group,null,l.default.createElement("label",{className:"control-label",htmlFor:i},u),l.default.createElement(n.ClayInput.Group,null,l.default.createElement(n.ClayInput.GroupItem,null,l.default.createElement(n.ClayInput,{component:e,id:i,name:i,onChange:e=>{b(e.target.value)},ref:m,value:y})),l.default.createElement(n.ClayInput.GroupItem,{shrink:!0},l.default.createElement(c.default,{clearSelectionOnClose:!0,fieldTypes:t,fields:r,isActive:g,name:i,onSelect:({field:e,source:t})=>{d(t),(({key:e,label:t})=>{const r=m.current.selectionStart,n=m.current.selectionEnd,a=fieldTemplate(e,t);b((e=>"".concat(e.slice(0,r)).concat(a).concat(e.slice(n)).trim())),setTimeout((()=>{j()&&(m.current.selectionStart=m.current.selectionEnd=r+a.length,m.current.focus())}),100)})(e)},source:_objectSpread(_objectSpread({},s),{},{initialValue:O})}))),o&&l.default.createElement(n.default.Text,null,o))};t.default=o}}));
//# sourceMappingURL=MappingInput.js.map