Liferay.Loader.define("asset-list-web@3.0.88/js/components/VariationsNav/SortableListItem",["module","exports","require","@frontend-taglib-clay$clayui/icon","@frontend-taglib-clay$clayui/link","@frontend-taglib-clay$clayui/list","liferay!frontend-js-react-web$prop-types","liferay!frontend-js-react-web$react","liferay!frontend-js-react-web$react-dnd","./SortableListItemMoreActions","./utils/index"],(function(e,t,a){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r=_interopRequireDefault(a("@frontend-taglib-clay$clayui/icon")),i=_interopRequireDefault(a("@frontend-taglib-clay$clayui/link")),n=_interopRequireDefault(a("@frontend-taglib-clay$clayui/list")),l=(_interopRequireDefault(a("liferay!frontend-js-react-web$prop-types")),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 i in e)if(Object.prototype.hasOwnProperty.call(e,i)){var n=r?Object.getOwnPropertyDescriptor(e,i):null;n&&(n.get||n.set)?Object.defineProperty(a,i,n):a[i]=e[i]}a.default=e,t&&t.set(e,a);return a}(a("liferay!frontend-js-react-web$react"))),o=a("liferay!frontend-js-react-web$react-dnd"),d=_interopRequireDefault(a("./SortableListItemMoreActions")),s=a("./utils/index");function _getRequireWildcardCache(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return _getRequireWildcardCache=function _getRequireWildcardCache(){return e},e}function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}const e={SORTABLE_LIST_ITEM:"sortableListItem"};var _default=({handleItemDelete:t,handleItemMove:a,handleSavePriority:c,id:u,index:f,sortableListItem:m,totalItems:g})=>{const[y,b]=(0,l.useState)(!1),p=(0,l.useRef)(null),[,I]=(0,o.useDrop)({accept:e.SORTABLE_LIST_ITEM,drop:e=>{c({itemIndex:e.index,itemName:m.name})},hover:(e,t)=>{const r=e.index,i=f;p.current&&r!==i&&!(0,s.dragIsOutOfBounds)({dragIndex:r,hoverIndex:i,monitor:t,ref:p})&&(e.index=i,a({hoverIndex:i,index:r}))}}),[{isDragging:_,itemBeingDragged:L},D]=(0,o.useDrag)({collect:e=>({isDragging:e.isDragging(),itemBeingDragged:e.getItem()||{id:0}}),item:{id:u,index:f,type:e.SORTABLE_LIST_ITEM}}),E=L.id===u;return D(I(p)),l.default.createElement(n.default.Item,{active:m.active,className:"align-items-center justify-content-start mb-1 sortable-list-item",flex:!0,id:"sortableListItem-id-".concat(m.assetListEntrySegmentsEntryRelId),onMouseEnter:()=>{b(!0)},onMouseLeave:()=>{b(!1)},ref:p,style:(0,s.getDndStyles)({isDragging:_,isItemBeingDragged:E})},l.default.createElement(n.default.ItemField,{className:"pl-0 sortable-list-item__drag-icon"},y&&l.default.createElement(r.default,{symbol:"drag"})),l.default.createElement(n.default.ItemField,{className:"sortable-list-item__label"},l.default.createElement(n.default.ItemTitle,{className:"align-items-stretch"},l.default.createElement(i.default,{className:"align-items-center d-flex w-100",href:m.editAssetListEntryURL},l.default.createElement("span",{className:"c-inner flex-grow-1",tabIndex:"-1"},m.name)))),l.default.createElement(n.default.ItemField,{className:"sortable-list-item__more-icon"},l.default.createElement(d.default,{index:f,itemIsDeleteable:!!m.deleteAssetListEntryVariationURL,onDeleteVariation:()=>t({deleteURL:m.deleteAssetListEntryVariationURL}),onReorder:({direction:e,index:t})=>{a({direction:e,index:t,saveAfterMove:!0})},sortableListItemName:m.name,totalItems:g})))};t.default=_default}}));
//# sourceMappingURL=SortableListItem.js.map