"use strict";(globalThis.webpackChunk_openmrs_esm_bed_management_app=globalThis.webpackChunk_openmrs_esm_bed_management_app||[]).push([["2841"],{79030:function(e,t,r){r.r(t),r.d(t,{default:()=>m});var n=r(27350),a=r.n(n),o=r(98900),l=r(20366),c=r(54675),i=r(94180),u=r(68892),s=r(93798);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}function b(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r,n,a=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=a){var o=[],l=!0,c=!1;try{for(a=a.call(e);!(l=(r=a.next()).done)&&(o.push(r.value),!t||o.length!==t);l=!0);}catch(e){c=!0,n=e}finally{try{l||null==a.return||a.return()}finally{if(c)throw n}}return o}}(e,t)||function(e,t){if(e){if("string"==typeof e)return f(e,t);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)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var d=o.Ry({reason:o.Z_().min(1).max(255)});let m=function(e){var t=e.bedTagData,r=e.handleDeleteBedTag,o=e.closeModal,f=(0,u.useTranslation)().t,m=b((0,n.useState)(!1),2),y=m[0],p=m[1],g=b((0,n.useState)(""),2),O=g[0],h=g[1],v=(0,l.cI)({mode:"all",resolver:(0,c.F)(d)}),j=v.handleSubmit,w=v.control,T=v.formState.isDirty;return a().createElement(a().Fragment,null,a().createElement(i.xBx,{closeModal:o,title:f("deleteTagConfirmation","Are you sure you want to delete this bed tag?")}),a().createElement(i.fef,null,a().createElement(i.l09,null,a().createElement(i.cwH,{legendText:""},a().createElement(l.Qr,{control:w,name:"reason",render:function(e){var t,r,n=e.field;return a().createElement(i.oil,(t=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}({},n),r=r={id:"bedTag",invalidText:y&&O,labelText:f("reasonForDeletingBedTag","Reason for deletion"),placeholder:f("reasonForDeletingBedTagPlaceholder","Enter a reason for deletion")},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):(function(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r.push.apply(r,n)}return r})(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}),t))},rules:{required:!0}})))),a().createElement(i.mzw,null,a().createElement(i.zxk,{onClick:o,kind:"secondary"},(0,s.getCoreTranslation)("cancel","Cancel")),a().createElement(i.zxk,{disabled:!T,onClick:j(function(e){d.safeParse(e).success&&(p(!1),r(t.uuid,e.reason,t,o))},function(e){h(Object.entries(e)[0][1].message),p(!0)})},(0,s.getCoreTranslation)("delete","Delete"))))}}}]);