Liferay.Loader.define("@liferay/layout-content-page-editor-web@3.0.130/page_editor/app/components/fragment-configuration-fields/ItemSelectorField",["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","../../../common/components/ItemSelector","../../../core/hooks/useId","../../../prop-types/index","../../contexts/CollectionItemContext","../../contexts/StoreContext","../../services/InfoItemService","../../utils/item-selector-value/itemSelectorValueToInfoItem"],(function(e,t,r){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.ItemSelectorField=function({field:t,onValueSelect:r,value:n}){const c=(0,a.useContext)(i.CollectionItemContext),{typeOptions:s={}}=t,f=c.collectionItem,m=null!==f,p=m?f.className:n.className,d=m?f.classPK:n.classPK;return a.default.createElement(a.default.Fragment,null,a.default.createElement(o.default,{helpText:t.description,itemSelectorURL:s.infoItemSelectorURL,label:t.label,onItemSelect:e=>{r(t.name,e)},selectedItem:m?f||{title:Liferay.Language.get("collection-item")}:n,showEditControls:!m,transformValueCallback:u.default}),s.enableSelectTemplate&&p&&a.default.createElement(l.default.Group,{small:!0},a.default.createElement(e,{className:p,classPK:d,onTemplateSelect:e=>{r(t.name,y(y({},n),{},{template:e}))},selectedTemplate:n.template})))};var l=p(r("@frontend-taglib-clay$clayui/form")),n=r("@liferay/frontend-js-react-web"),a=(p(r("liferay!frontend-js-react-web$prop-types")),function(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=m();if(t&&t.has(e))return t.get(e);var r={},l=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){var a=l?Object.getOwnPropertyDescriptor(e,n):null;a&&(a.get||a.set)?Object.defineProperty(r,n,a):r[n]=e[n]}r.default=e,t&&t.set(e,r);return r}(r("liferay!frontend-js-react-web$react"))),o=p(r("../../../common/components/ItemSelector")),c=r("../../../core/hooks/useId"),i=(r("../../../prop-types/index"),r("../../contexts/CollectionItemContext")),s=r("../../contexts/StoreContext"),f=p(r("../../services/InfoItemService")),u=p(r("../../utils/item-selector-value/itemSelectorValueToInfoItem"));function m(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return m=function(){return e},e}function p(e){return e&&e.__esModule?e:{default:e}}function d(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);t&&(l=l.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,l)}return r}function y(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?d(Object(r),!0).forEach((function(t){b(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):d(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function b(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const e=({className:e,classPK:t,onTemplateSelect:r,selectedTemplate:o})=>{const i=(0,s.useDispatch)(),[u,m]=(0,a.useState)([]),p=(0,n.useIsMounted)(),d=(0,c.useId)();return(0,a.useEffect)((()=>{p()&&f.default.getAvailableTemplates({className:e,classPK:t,onNetworkStatus:i}).then((e=>{m(e)}))}),[e,t,i,p]),a.default.createElement(a.default.Fragment,null,a.default.createElement(l.default.Group,{small:!0},a.default.createElement("label",{htmlFor:d},Liferay.Language.get("template")),a.default.createElement("select",{className:"form-control",id:d,onChange:e=>{r(e.target.options[e.target.selectedIndex].dataset)}},u.map((e=>e.templates?a.default.createElement("optgroup",{key:e.label,label:e.label},e.templates.map((e=>a.default.createElement("option",{"data-info-item-renderer-key":e.infoItemRendererKey,"data-template-key":e.templateKey,key:e.label,selected:o&&o.infoItemRendererKey===e.infoItemRendererKey&&(!o.templateKey||o.templateKey&&o.templateKey===e.templateKey)},e.label)))):a.default.createElement("option",{"data-info-item-renderer-key":e.infoItemRendererKey,key:e.label,selected:o&&o.infoItemRendererKey===e.infoItemRendererKey},e.label))))))}}}));
//# sourceMappingURL=ItemSelectorField.js.map