"use strict";(globalThis.webpackChunk_openmrs_esm_service_queues_app=globalThis.webpackChunk_openmrs_esm_service_queues_app||[]).push([["8358"],{99210:function(e,t,r){r.r(t),r.d(t,{default:()=>E});var n=r(27350),u=r.n(n),i=r(68892),l=r(89194),o=r(93798),a=r(40259),s=r(64247),c=r(16916),d=r(18400),y=r(4598),m=r(20158);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.y)().queues,b=(0,d.m)(t.uuid),g=b.queueEntry,h=b.error,q=b.isLoading,v=(0,c.Qd)().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.xBx,{closeModal:r,title:E("editQueueEntryForPatient","Edit queue entry for {{patient}}",{patient:t.display})}),u().createElement(l.fef,null,u().createElement(l.iTo,{"data-testid":"edit-queue-entry-loading-skeleton"}))):h?u().createElement(u().Fragment,null,u().createElement(l.xBx,{closeModal:r,title:E("editQueueEntryForPatient","Edit queue entry for {{patient}}",{patient:t.display})}),u().createElement(l.fef,null,u().createElement(l.K0D,{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.mzw,null,u().createElement(l.zxk,{kind:"secondary",onClick:r},(0,o.getCoreTranslation)("close")))):w?u().createElement(u().Fragment,null,u().createElement(l.xBx,{closeModal:r,title:E("editQueueEntryForPatient","Edit queue entry for {{patient}}",{patient:t.display})}),u().createElement(l.fef,null,u().createElement(l.K0D,{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.mzw,null,u().createElement(l.zxk,{kind:"secondary",onClick:r},(0,o.getCoreTranslation)("close")))):u().createElement(m.Z,{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),o=(r=(0,a.A)(t.transitionTime,t.transitionTimeFormat),function(e){if(Array.isArray(e))return e}(r)||function(e,t){var r,n,u=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=u){var i=[],l=!0,o=!1;try{for(u=u.call(e);!(l=(r=u.next()).done)&&(i.push(r.value),i.length!==t);l=!0);}catch(e){o=!0,n=e}finally{try{l||null==u.return||u.return()}finally{if(o)throw n}}return i}}(r,2)||function(e,t){if(e){if("string"==typeof e)return f(e,2);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return f(e,t)}}(r,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.")}()),c=o[0],d=o[1];return l.setHours(c,d,0,0),(0,s.zI)(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}})}}}]);