"use strict";(globalThis.webpackChunk_openmrs_esm_service_queues_app=globalThis.webpackChunk_openmrs_esm_service_queues_app||[]).push([["6738"],{49937:function(e,t,n){n.r(t),n.d(t,{default:()=>f});var r=n(27350),i=n.n(r),u=n(68892),a=n(89194),o=n(93798),l=n(40259),s=n(64247),c=n(16916),d=n(18400),m=n(20158);function y(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}let f=function(e){var t=e.queueEntry,n=e.closeModal,f=(0,u.useTranslation)().t,p=(0,d.m)(t.uuid),E=p.queueEntry,b=p.error,v=p.isLoading,g=(0,c.Qd)().mutateQueueEntries,h=!v&&!b&&(!E||!!E.endedAt);return((0,r.useEffect)(function(){h&&g()},[h,g]),v)?i().createElement(i().Fragment,null,i().createElement(a.xBx,{closeModal:n,title:f("movePatient","Move {{patient}}",{patient:t.display})}),i().createElement(a.fef,null,i().createElement(a.iTo,{"data-testid":"move-queue-entry-loading-skeleton"}))):b?i().createElement(i().Fragment,null,i().createElement(a.xBx,{closeModal:n,title:f("movePatient","Move {{patient}}",{patient:t.display})}),i().createElement(a.fef,null,i().createElement(a.K0D,{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.mzw,null,i().createElement(a.zxk,{kind:"secondary",onClick:n},(0,o.getCoreTranslation)("close")))):h?i().createElement(i().Fragment,null,i().createElement(a.xBx,{closeModal:n,title:f("movePatient","Move {{patient}}",{patient:t.display})}),i().createElement(a.fef,null,i().createElement(a.K0D,{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.mzw,null,i().createElement(a.zxk,{kind:"secondary",onClick:n},(0,o.getCoreTranslation)("close")))):i().createElement(m.Z,{queueEntry:E,closeModal:n,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 n,r=new Date(t.transitionDate),i=(n=(0,l.A)(t.transitionTime,t.transitionTimeFormat),function(e){if(Array.isArray(e))return e}(n)||function(e,t){var n,r,i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var u=[],a=!0,o=!1;try{for(i=i.call(e);!(a=(n=i.next()).done)&&(u.push(n.value),u.length!==t);a=!0);}catch(e){o=!0,r=e}finally{try{a||null==i.return||i.return()}finally{if(o)throw r}}return u}}(n,2)||function(e,t){if(e){if("string"==typeof e)return y(e,2);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return y(e,t)}}(n,2)||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 r.setHours(u,a,0,0),(0,s.rf)(function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({queueEntryToTransition:e.uuid,newQueue:t.selectedQueue,newStatus:t.selectedStatus,newPriority:t.selectedPriority,newPriorityComment:t.priorityComment},t.modifyDefaultTransitionDateTime?{transitionDate:r.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}})}}}]);