"use strict";(globalThis.webpackChunk_openmrs_esm_service_queues_app=globalThis.webpackChunk_openmrs_esm_service_queues_app||[]).push([["7296"],{46195(e,t,r){r.r(t),r.d(t,{default:()=>E});var n=r(97125),u=r.n(n),i=r(75921),l=r(86835),a=r(82895),o=r(51812),s=r(73275),c=r(41751),d=r(36831),y=r(47406),m=r(70160);function f(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 E=function(e){var t=e.queueEntry,r=e.closeModal,E=(0,i.useTranslation)().t,p=(0,y.A)().queues,b=(0,d.v)(t.uuid),g=b.queueEntry,h=b.error,q=b.isLoading,v=(0,c.fe)().mutateQueueEntries,w=!q&&!h&&(!g||!!g.endedAt);return((0,n.useEffect)(function(){w&&v()},[w,v]),q)?u().createElement(u().Fragment,null,u().createElement(l.rQ0,{closeModal:r,title:E("editQueueEntryForPatient","Edit queue entry for {{patient}}",{patient:t.display})}),u().createElement(l.cwr,null,u().createElement(l.dF7,{"data-testid":"edit-queue-entry-loading-skeleton"}))):h?u().createElement(u().Fragment,null,u().createElement(l.rQ0,{closeModal:r,title:E("editQueueEntryForPatient","Edit queue entry for {{patient}}",{patient:t.display})}),u().createElement(l.cwr,null,u().createElement(l.jeF,{hideCloseButton:!0,kind:"error",lowContrast:!0,title:E("errorLoadingQueueEntry","Error loading queue entry"),subtitle:(null==h?void 0:h.message)||E("unexpectedError","An unexpected error occurred")})),u().createElement(l.jlY,null,u().createElement(l.$nd,{kind:"secondary",onClick:r},(0,a.getCoreTranslation)("close")))):w?u().createElement(u().Fragment,null,u().createElement(l.rQ0,{closeModal:r,title:E("editQueueEntryForPatient","Edit queue entry for {{patient}}",{patient:t.display})}),u().createElement(l.cwr,null,u().createElement(l.jeF,{hideCloseButton:!0,kind:"warning",lowContrast:!0,title:E("queueEntryAlreadyEnded","Queue entry is no longer active"),subtitle:E("queueEntryAlreadyEndedMessage","This queue entry has already been completed by another user. The queue has been refreshed.")})),u().createElement(l.jlY,null,u().createElement(l.$nd,{kind:"secondary",onClick:r},(0,a.getCoreTranslation)("close")))):u().createElement(m.A,{queueEntry:g,closeModal:r,modalParams:{modalTitle:E("editQueueEntryForPatient","Edit queue entry for {{patient}}",{patient:g.display}),submitButtonText:E("editQueueEntry","Edit queue entry"),submitSuccessTitle:E("queueEntryEdited","Queue entry edited"),submitSuccessText:E("queueEntryEditedSuccessfully","Queue entry edited successfully"),submitFailureTitle:E("queueEntryEditingFailed","Error editing queue entry"),submitAction:function(e,t){var r,n=p.find(function(e){return e.uuid===t.selectedQueue}),u=null==n?void 0:n.allowedStatuses,i=null==n?void 0:n.allowedPriorities,l=new Date(t.transitionDate),a=function(e){if(Array.isArray(e))return e}(r=(0,o.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 u=[],i=!0,l=!1;try{for(n=n.call(e);!(i=(t=n.next()).done)&&(u.push(t.value),2!==u.length);i=!0);}catch(e){l=!0,r=e}finally{try{i||null==n.return||n.return()}finally{if(l)throw r}}return u}}(r)||function(e){if(e){if("string"==typeof e)return f(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 f(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.")}(),c=a[0],d=a[1];return l.setHours(c,d,0,0),(0,s.hC)(e.uuid,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}({status:u.find(function(e){return e.uuid===t.selectedStatus}),priority:i.find(function(e){return e.uuid===t.selectedPriority}),priorityComment:t.priorityComment},t.modifyDefaultTransitionDateTime?{startedAt:l.toISOString()}:{}))},disableSubmit:function(){return!1},isEdit:!0,showQueuePicker:!0,showStatusPicker:!0}})}}}]);