Liferay.Loader.define("portal-workflow-kaleo-designer-web@5.0.92/designer/js/definition-builder/diagram-builder/components/sidebar/sections/shared-components/BaseRole",["module","exports","require","@frontend-taglib-clay$clayui/autocomplete","@frontend-taglib-clay$clayui/data-provider","@frontend-taglib-clay$clayui/drop-down","@frontend-taglib-clay$clayui/form","liferay!frontend-js-react-web$prop-types","liferay!frontend-js-react-web$react","../../../../../constants","../../../../../util/fetchUtil"],(function(e,t,r){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function BaseRole({defaultFieldValue:e={id:"",name:""},inputLabel:t,selectLabel:r,updateSelectedItem:d}){const[f,s]=(0,i.useState)(!1),[p,m]=(0,i.useState)(!0),[y,b]=(0,i.useState)(e),[g,w]=(0,i.useState)(4),{resource:j}=(0,n.useResource)({fetchOptions:{headers:_objectSpread(_objectSpread({},u.headers),{},{accept:"application/json","x-csrf-token":Liferay.authToken})},fetchPolicy:"cache-first",link:"".concat(window.location.origin).concat(c.contextUrl).concat(u.userBaseURL,"/roles"),onNetworkStatusChange:w,variables:{pageSize:-1}});(0,i.useEffect)((()=>{""!==e.name&&b((t=>{const r=_objectSpread({},t);return r.name=e.name,r}))}),[e]);const O=5===g;return i.default.createElement(i.default.Fragment,null,i.default.createElement(o.default.Group,null,i.default.createElement(a.default,null,i.default.createElement("label",{htmlFor:"role-name"},r),i.default.createElement(a.default.Input,{autoComplete:"off",id:"role-name",onChange:e=>(e=>{e.persist(),m(!0),b((t=>_objectSpread(_objectSpread({},t),{},{name:e.target.value})))})(e),onFocus:()=>(m(""===y.name),void s(!0)),placeholder:"Search",value:y.name}),i.default.createElement(a.default.DropDown,{active:!!j&&f,closeOnClickOutside:!0,onSetActive:s},i.default.createElement(l.default.ItemList,null,(O||j&&j.error)&&i.default.createElement(l.default.Item,{className:"disabled"},Liferay.Language.get("no-results-found")),!O&&(null==j?void 0:j.items)&&j.items.filter((e=>p?e.name.toLowerCase().match(y.name.toLowerCase()):e)).map((e=>i.default.createElement(a.default.Item,{key:e.id,onClickCapture:()=>{(e=>{b({id:e.id,name:e.name}),s(!1),d(e)})(e)},value:e.name}))))),g<4&&i.default.createElement(a.default.LoadingIndicator,null))),i.default.createElement(o.default.Group,null,i.default.createElement("label",{htmlFor:"role-id"},t,i.default.createElement("span",{className:"ml-1 mr-1 text-warning"},"*")),i.default.createElement(o.ClayInput,{component:"input",disabled:!0,id:"role-id",type:"text",value:y.id})))};var a=_interopRequireDefault(r("@frontend-taglib-clay$clayui/autocomplete")),n=r("@frontend-taglib-clay$clayui/data-provider"),l=_interopRequireDefault(r("@frontend-taglib-clay$clayui/drop-down")),o=_interopRequireWildcard(r("@frontend-taglib-clay$clayui/form")),i=(_interopRequireDefault(r("liferay!frontend-js-react-web$prop-types")),_interopRequireWildcard(r("liferay!frontend-js-react-web$react"))),c=r("../../../../../constants"),u=r("../../../../../util/fetchUtil");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={},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){var l=a?Object.getOwnPropertyDescriptor(e,n):null;l&&(l.get||l.set)?Object.defineProperty(r,n,l):r[n]=e[n]}return r.default=e,t&&t.set(e,r),r}function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function ownKeys(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,a)}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}}}));
//# sourceMappingURL=BaseRole.js.map