"use strict";(globalThis.webpackChunk_openmrs_esm_service_queues_app=globalThis.webpackChunk_openmrs_esm_service_queues_app||[]).push([["8585"],{59136(e,t,r){r.r(t),r.d(t,{default:()=>f});var n=r(97125),i=r.n(n),u=r(75921),a=r(86835),o=r(82895),l=r(51812),s=r(73275),c=r(41751),d=r(36831),m=r(70160);function y(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}let f=function(e){var t=e.queueEntry,r=e.closeModal,f=(0,u.useTranslation)().t,p=(0,d.v)(t.uuid),E=p.queueEntry,b=p.error,v=p.isLoading,g=(0,c.fe)().mutateQueueEntries,h=!v&&!b&&(!E||!!E.endedAt);return((0,n.useEffect)(function(){h&&g()},[h,g]),v)?i().createElement(i().Fragment,null,i().createElement(a.rQ0,{closeModal:r,title:f("movePatient","Move {{patient}}",{patient:t.display})}),i().createElement(a.cwr,null,i().createElement(a.dF7,{"data-testid":"move-queue-entry-loading-skeleton"}))):b?i().createElement(i().Fragment,null,i().createElement(a.rQ0,{closeModal:r,title:f("movePatient","Move {{patient}}",{patient:t.display})}),i().createElement(a.cwr,null,i().createElement(a.jeF,{hideCloseButton:!0,kind:"error",lowContrast:!0,title:f("errorLoadingQueueEntry","Error loading queue entry"),subtitle:(null==b?void 0:b.message)||f("unexpectedError","An unexpected error occurred")})),i().createElement(a.jlY,null,i().createElement(a.$nd,{kind:"secondary",onClick:r},(0,o.getCoreTranslation)("close")))):h?i().createElement(i().Fragment,null,i().createElement(a.rQ0,{closeModal:r,title:f("movePatient","Move {{patient}}",{patient:t.display})}),i().createElement(a.cwr,null,i().createElement(a.jeF,{hideCloseButton:!0,kind:"warning",lowContrast:!0,title:f("queueEntryAlreadyEnded","Queue entry is no longer active"),subtitle:f("queueEntryAlreadyEndedMessage","This queue entry has already been completed by another user. The queue has been refreshed.")})),i().createElement(a.jlY,null,i().createElement(a.$nd,{kind:"secondary",onClick:r},(0,o.getCoreTranslation)("close")))):i().createElement(m.A,{queueEntry:E,closeModal:r,modalParams:{modalTitle:f("movePatient","Move {{patient}}",{patient:E.display}),submitButtonText:f("move","Move"),submitSuccessTitle:f("queueEntryTransitioned","Queue entry transitioned"),submitSuccessText:f("queueEntryTransitionedSuccessfully","Queue entry transitioned successfully"),submitFailureTitle:f("queueEntryTransitionFailed","Error transitioning queue entry"),submitAction:function(e,t){var r,n=new Date(t.transitionDate),i=function(e){if(Array.isArray(e))return e}(r=(0,l.R)(t.transitionTime,t.transitionTimeFormat))||function(e){var t,r,n=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var i=[],u=!0,a=!1;try{for(n=n.call(e);!(u=(t=n.next()).done)&&(i.push(t.value),2!==i.length);u=!0);}catch(e){a=!0,r=e}finally{try{u||null==n.return||n.return()}finally{if(a)throw r}}return i}}(r)||function(e){if(e){if("string"==typeof e)return y(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return y(e,2)}}(r)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),u=i[0],a=i[1];return n.setHours(u,a,0,0),(0,s.TI)(function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){var n;n=r[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}({queueEntryToTransition:e.uuid,newQueue:t.selectedQueue,newStatus:t.selectedStatus,newPriority:t.selectedPriority,newPriorityComment:t.priorityComment},t.modifyDefaultTransitionDateTime?{transitionDate:n.toISOString()}:{}))},disableSubmit:function(e,t){return t.selectedQueue===e.queue.uuid&&t.selectedStatus===e.status.uuid&&t.selectedPriority===e.priority.uuid},isEdit:!1,showQueuePicker:!0,showStatusPicker:!1}})}}}]);