Liferay.Loader.define("commerce-organization-web@5.0.46/js/OrganizationChart",["module","exports","require","@frontend-taglib-clay$clayui/button","liferay!frontend-js-react-web$classnames","liferay!frontend-js-react-web$prop-types","liferay!frontend-js-react-web$react","./ChartContext","./D3OrganizationChart","./ManagementBar/ManagementBar","./data/organizations","./menu/MenuProvider","./modals/ModalProvider","./utils/constants","../style/main.scss"],(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=_interopRequireDefault(a("liferay!frontend-js-react-web$classnames")),l=(_interopRequireDefault(a("liferay!frontend-js-react-web$prop-types")),_interopRequireWildcard(a("liferay!frontend-js-react-web$react"))),u=_interopRequireDefault(a("./ChartContext")),i=_interopRequireDefault(a("./D3OrganizationChart")),o=_interopRequireDefault(a("./ManagementBar/ManagementBar")),c=a("./data/organizations"),s=_interopRequireDefault(a("./menu/MenuProvider")),d=_interopRequireDefault(a("./modals/ModalProvider")),f=a("./utils/constants");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}function OrganizationChart({pageSize:e,rootOrganizationId:t,spritemap:a}){const[p,m]=(0,l.useState)(!1),[y,g]=(0,l.useState)(null),[v,h]=(0,l.useState)(f.VIEWS[0]),[b,R]=(0,l.useState)(!1),[_,O]=(0,l.useState)(null),[C,z]=(0,l.useState)(null),[q,w]=(0,l.useState)(null),D=(0,l.useRef)(null),E=(0,l.useRef)(null),j=(0,l.useRef)(null),M=(0,l.useRef)(null),W=(0,l.useRef)(null);return(0,l.useEffect)((()=>{Number(t)?(0,c.getOrganization)(t).then(w):(0,c.getOrganizations)(e).then((e=>w(e.items)))}),[t,e]),(0,l.useLayoutEffect)((()=>(q&&E.current&&(j.current=new i.default(q,{svg:E.current,zoomIn:W.current,zoomOut:M.current},a,{open:(e,t)=>{g({parentData:e,type:t}),m(!0)}},{close:()=>{D.current=null,O(null),z(null)},open:(e,t,a)=>{D.current=e,O(t),z(a)}})),()=>{var e;return null===(e=j.current)||void 0===e?void 0:e.cleanUp()})),[e,q,a]),l.default.createElement(u.default.Provider,{value:{chartInstanceRef:j,currentView:v,setCurrentView:h}},l.default.createElement(o.default,null),l.default.createElement("div",{className:(0,n.default)("org-chart-container",{expanded:b})},l.default.createElement("svg",{className:"svg-chart",ref:E}),l.default.createElement("div",{className:"zoom-controls"},l.default.createElement(r.ClayButtonWithIcon,{displayType:"secondary",onClick:()=>R(!b),small:!0,symbol:"expand"}),l.default.createElement(r.default.Group,{className:"ml-3"},l.default.createElement(r.ClayButtonWithIcon,{displayType:"secondary",ref:M,small:!0,symbol:"hr"}),l.default.createElement(r.ClayButtonWithIcon,{displayType:"secondary",ref:W,small:!0,symbol:"plus"})))),l.default.createElement(s.default,{alignElementRef:D,data:_,parentData:C}),l.default.createElement(d.default,{active:p,closeModal:()=>m(!1),parentData:null==y?void 0:y.parentData,type:null==y?void 0:y.type}))}a("../style/main.scss"),OrganizationChart.defaultProps={pageSize:10,rootOrganizationId:0};var p=OrganizationChart;t.default=p}}));
//# sourceMappingURL=OrganizationChart.js.map