Liferay.Loader.define("portal-search-web@6.0.114/js/components/search_bar_configuration_suggestions/contributor_input_set_item/inputs/SXPBlueprintSelectorInput",["module","exports","require","@frontend-taglib-clay$clayui/button","@frontend-taglib-clay$clayui/form","@frontend-taglib-clay$clayui/icon","@frontend-taglib-clay$clayui/loading-indicator","@frontend-taglib-clay$clayui/modal","liferay!frontend-js-react-web$classnames","frontend-js-web","liferay!frontend-js-react-web$react","../../../select_sxp_blueprint_modal/SelectSXPBlueprintModal"],(function(e,t,a){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r=_interopRequireWildcard(a("@frontend-taglib-clay$clayui/button")),n=_interopRequireWildcard(a("@frontend-taglib-clay$clayui/form")),l=_interopRequireDefault(a("@frontend-taglib-clay$clayui/icon")),i=_interopRequireDefault(a("@frontend-taglib-clay$clayui/loading-indicator")),o=a("@frontend-taglib-clay$clayui/modal"),u=_interopRequireDefault(a("liferay!frontend-js-react-web$classnames")),c=a("frontend-js-web"),d=_interopRequireWildcard(a("liferay!frontend-js-react-web$react")),f=_interopRequireDefault(a("../../../select_sxp_blueprint_modal/SelectSXPBlueprintModal"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}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={},r=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){var l=r?Object.getOwnPropertyDescriptor(e,n):null;l&&(l.get||l.set)?Object.defineProperty(a,n,l):a[n]=e[n]}return a.default=e,t&&t.set(e,a),a}var s=function SXPBlueprintSelectorInput({onBlur:e,onSubmit:t,sxpBlueprintExternalReferenceCode:a,touched:s}){const[p,y]=(0,d.useState)(!1),[m,g]=(0,d.useState)({loading:!1,title:""}),{observer:b,onClose:_}=(0,o.useModal)({onClose:()=>y(!1)}),_handleSubmit=(e,a)=>{t(e),g({loading:!1,title:a})};return(0,d.useEffect)((()=>{a&&(g({loading:!0,title:""}),(0,c.fetch)("/o/search-experiences-rest/v1.0/sxp-blueprints/by-external-reference-code/".concat(a),{headers:new Headers({Accept:"application/json","Accept-Language":Liferay.ThemeDisplay.getBCP47LanguageId(),"Content-Type":"application/json"}),method:"GET"}).then((e=>e.json().then((t=>({data:t,ok:e.ok}))))).then((({data:e,ok:t})=>{g({loading:!1,title:t&&"NOT_FOUND"!==e.status?e.title:a})})).catch((()=>{g({loading:!1,title:a})})))}),[]),d.default.createElement(d.default.Fragment,null,p&&d.default.createElement(f.default,{observer:b,onClose:_,onSubmit:_handleSubmit,selectedExternalReferenceCode:a||""}),d.default.createElement(n.ClayInput.GroupItem,{className:(0,u.default)({"has-error":!a&&s})},d.default.createElement(n.default.Group,{className:"c-mb-0 w-100"},d.default.createElement("label",null,Liferay.Language.get("blueprint"),d.default.createElement("span",{className:"reference-mark"},d.default.createElement(l.default,{symbol:"asterisk"}))),d.default.createElement(n.ClayInput.Group,null,d.default.createElement(n.ClayInput.GroupItem,{prepend:!0},d.default.createElement(n.ClayInput,{className:"bg-transparent form-control input-group-inset input-group-inset-after",onBlur:e,onChange:e=>{e.preventDefault()},required:!0,style:{caretColor:"transparent"},type:"text",value:m.title}),d.default.createElement(n.ClayInput.GroupInsetItem,{after:!0,className:"bg-transparent rounded-0"},m.loading&&d.default.createElement(i.default,{small:!0}),m.title&&d.default.createElement(r.ClayButtonWithIcon,{displayType:"unstyled",onClick:()=>{_handleSubmit("",""),e()},symbol:"times-circle"}))),d.default.createElement(n.ClayInput.GroupItem,{append:!0,shrink:!0},d.default.createElement(r.default,{displayType:"secondary",onClick:()=>{y(!0)}},Liferay.Language.get("select")))))))};t.default=s}}));
//# sourceMappingURL=SXPBlueprintSelectorInput.js.map