1"use strict";(self.webpackChunkweb_alquiler_impresoras=self.webpackChunkweb_alquiler_impresoras||[]).push([[9276],{34427(e,t,r){r.d(t,{u:()=>N});var a=r(65043),n=r(16550),o=r(84583),s=r(26464),l=r(56478),i=r(85994),c=r(7669),d=r(35349),u=r(11798),m=r(70579);const v=e=>{let{cameraCount:t,error:r,hintText:a,loading:n,stream:s,torchOn:l,videoRef:i,onClose:v,onSwitchCamera:p,onToggleTorch:h}=e;return(0,m.jsxs)("div",{className:"w-full",children:[(0,m.jsxs)("div",{className:"relative bg-black rounded-lg overflow-hidden aspect-[1/1]",children:[(0,m.jsx)("video",{ref:i,autoPlay:!0,playsInline:!0,muted:!0,className:"w-full h-full object-cover"}),(0,m.jsxs)("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:[(0,m.jsx)("div",{className:"w-48 h-48 border-2 border-white/70 rounded-lg"}),(0,m.jsx)("div",{className:"absolute bottom-3 left-1/2 -translate-x-1/2 text-white text-xs bg-black/50 px-3 py-1 rounded",children:a})]}),(0,m.jsx)("div",{className:"absolute top-2 right-2 flex gap-2",children:(0,m.jsx)("button",{type:"button","aria-label":"Cerrar camara",onClick:v,className:"p-2 bg-white/85 hover:bg-white rounded-full",title:"Cerrar",children:(0,m.jsx)(c.A,{className:"w-5 h-5 text-gray-800"})})}),(0,m.jsxs)("div",{className:"absolute top-2 left-2 flex gap-2",children:[(0,m.jsx)("button",{type:"button","aria-label":"Cambiar camara",onClick:p,className:"p-2 rounded-full ".concat(t>1?"bg-white/85 hover:bg-white text-gray-800":"bg-white/60 text-gray-400 cursor-not-allowed"),title:t>1?"Cambiar c\xe1mara":"No hay otra c\xe1mara disponible",disabled:t<=1||n,children:(0,m.jsx)(d.A,{className:"w-5 h-5"})}),(0,m.jsx)("button",{type:"button","aria-label":l?"Apagar linterna":"Encender linterna",onClick:h,className:"p-2 bg-white/85 hover:bg-white rounded-full text-gray-800",title:"Linterna",disabled:!s||n,children:(0,m.jsx)(u.A,{className:"w-5 h-5 ".concat(l?"text-yellow-500":"")})})]}),n&&(0,m.jsx)("div",{className:"absolute inset-0 flex items-center justify-center bg-black/30",children:(0,m.jsxs)("div",{className:"flex items-center gap-2 text-white text-sm",children:[(0,m.jsx)(o.A,{className:"w-5 h-5 animate-spin"}),(0,m.jsx)("span",{children:"Abriendo c\xe1mara\u2026"})]})})]}),r&&(0,m.jsx)("div",{className:"mt-2 rounded-md border border-red-200 bg-red-50 text-red-700 text-sm px-3 py-2",children:r})]})};let p=null;const h=e=>{const t=(0,a.useRef)(e);return(0,a.useEffect)(()=>{t.current=e},[e]),t},g=e=>{let{open:t,onClose:n,idealWidth:o=1280,idealHeight:s=720,preferRearCamera:l=!0,onReady:c,hintText:d="Apunta al c\xf3digo QR",onDetected:u,autoCloseOnDetect:g=!0}=e;const f=(0,a.useRef)(null),x=(0,a.useRef)(null),y=h(c),b=(0,a.useRef)(!1),{stream:w,setStream:D,loading:C,setLoading:j,error:N,setError:R,deviceIds:S,setDeviceIds:I,torchOn:k,setTorchOn:E}=(()=>{const[e,t]=a.useState(null),[r,n]=a.useState(!1),[o,s]=a.useState(null),[l,i]=a.useState([]),[c,d]=a.useState(!1);return{stream:e,setStream:t,loading:r,setLoading:n,error:o,setError:s,deviceIds:l,setDeviceIds:i,torchOn:c,setTorchOn:d}})(),M=(0,a.useRef)(0),T=(0,a.useRef)(!1),A=(0,a.useRef)(null),q=(0,a.useRef)(null),Q=h(u),O=(0,a.useRef)(null),P=(0,a.useCallback)(()=>{var e;null!=q.current&&(null===(e=(0,i.R2)())||void 0===e||e.cancelAnimationFrame(q.current),q.current=null)},[]),U=(0,a.useCallback)(()=>{var e,t;P();const r=(0,i.R2)();if(null===r||void 0===r||!r.BarcodeDetector)return;try{A.current=new r.BarcodeDetector({formats:["qr_code"]})}catch(o){return void(A.current=null)}const a=async()=>{var e,t;const r=f.current;if(!r||r.readyState<2||!A.current){var o,s;q.current=null!==(o=null===(s=(0,i.R2)())||void 0===s?void 0:s.requestAnimationFrame(a))&&void 0!==o?o:null}else{try{const e=await A.current.detect(r);if(e&&e.length>0){var l,c;const t=null!==(l=null===(c=e[0])||void 0===c?void 0:c.rawValue)&&void 0!==l?l:"";var d;if(t)if(R(null),null===(d=Q.current)||void 0===d||d.call(Q,t),g)return void n()}}catch(u){}q.current=null!==(e=null===(t=(0,i.R2)())||void 0===t?void 0:t.requestAnimationFrame(a))&&void 0!==e?e:null}};q.current=null!==(e=null===(t=(0,i.R2)())||void 0===t?void 0:t.requestAnimationFrame(a))&&void 0!==e?e:null},[g,P,n,Q,R]),B=(0,a.useCallback)(()=>{const e=x.current;
1e&&e.getTracks().forEach(e=>e.stop()),x.current=null,D(null),E(!1),P();try{var t,r;null===(t=O.current)||void 0===t||null===(r=t.stop)||void 0===r||r.call(t)}catch(o){}try{var a,n;null===(a=O.current)||void 0===a||null===(n=a.destroy)||void 0===n||n.call(a)}catch(s){}O.current=null},[P,D,E]),L=(0,a.useCallback)(async e=>{const t=(0,i.OV)();if(null!==t&&void 0!==t&&t.mediaDevices&&"function"===typeof t.mediaDevices.getUserMedia){if(!b.current){b.current=!0,j(!0),R(null);try{const n=e?{deviceId:{exact:e},width:{ideal:o},height:{ideal:s}}:{facingMode:l?{ideal:"environment"}:{ideal:"user"},width:{ideal:o},height:{ideal:s}},i=await t.mediaDevices.getUserMedia({video:n,audio:!1});var r;if(f.current&&(f.current.srcObject=i,await f.current.play().catch(()=>{})),x.current=i,D(i),f.current)null===(r=y.current)||void 0===r||r.call(y,f.current,i);try{const e=(await t.mediaDevices.enumerateDevices()).filter(e=>"videoinput"===e.kind);I(e.flatMap(e=>e.deviceId?[e.deviceId]:[]))}catch(a){}U()}catch(n){const e=(null===n||void 0===n?void 0:n.name)||"";let t="No se pudo abrir la c\xe1mara.";"NotAllowedError"===e?t="Permiso de c\xe1mara denegado o prompt cancelado.":"NotFoundError"===e?t="No se encontr\xf3 una c\xe1mara disponible.":"NotReadableError"===e?t="La c\xe1mara est\xe1 en uso por otra aplicaci\xf3n.":"OverconstrainedError"===e&&(t="Las restricciones de video no se pueden cumplir."),R(t)}finally{j(!1),b.current=!1}}}else R("Este navegador no soporta acceso a c\xe1mara.")},[o,s,y,l,I,R,j,D,U]),F=(0,a.useCallback)(async()=>{try{var e,t,r,a,n;const o=null===w||void 0===w||null===(e=w.getVideoTracks)||void 0===e?void 0:e.call(w)[0];if(!o)return;const s=null===(t=(r=o).getCapabilities)||void 0===t?void 0:t.call(r);if(!s||!("torch"in s))return R("Este dispositivo no soporta linterna/torch."),void setTimeout(()=>R(null),2e3);const l=!k;await(null===(a=(n=o).applyConstraints)||void 0===a?void 0:a.call(n,{advanced:[{torch:l}]})),E(l)}catch(o){R("No se pudo cambiar el estado de la linterna."),setTimeout(()=>R(null),2e3)}},[R,E,w,k]),_=(0,a.useCallback)(async()=>{if(!S.length)return;const e=(M.current+1)%S.length;if(M.current=e,T.current)try{var t,r,a;await(null===(t=O.current)||void 0===t||null===(r=t.setCamera)||void 0===r?void 0:r.call(t,null!==(a=S[e])&&void 0!==a?a:""))}catch(n){R("No se pudo cambiar de c\xe1mara en modo compatible."),setTimeout(()=>R(null),2e3)}else B(),await L(S[e])},[S,R,L,B]);return(0,a.useEffect)(()=>{let e=!1;if(!t)return B(),void R(null);return(async()=>{const t=(0,i.R2)();let a=!1;if(null!==t&&void 0!==t&&t.BarcodeDetector)try{var o,s;const r=await(null===(o=(s=t.BarcodeDetector).getSupportedFormats)||void 0===o?void 0:o.call(s))||[];if(e)return;a=null===r||void 0===r?void 0:r.includes("qr_code")}catch(h){a=!1}if(a)T.current=!1,await L();else{T.current=!0,j(!0),R(null);const t=await(async()=>{if(p)return p;const{default:e}=await r.e(5544).then(r.bind(r,25544));try{e.WORKER_PATH=new URL(r(89104),r.b).toString()}catch(t){e.WORKER_PATH="/qr-scanner-worker.min.js"}return p=e,e})();if(e)return;try{var c,d;const r=await(null===(c=(d=t).listCameras)||void 0===c?void 0:c.call(d,!0));if(e)return;if(Array.isArray(r)&&r.length){const e=r.flatMap(e=>{const t="string"===typeof e?e:e.id;return t?[t]:[]});I(e)}}catch(x){}let a=!1;try{if(f.current){if(O.current=new t(f.current,t=>{var r,a;const o="string"===typeof t?t:null!==(r=null!==(a=null===t||void 0===t?void 0:t.data)&&void 0!==a?a:null===t||void 0===t?void 0:t.rawValue)&&void 0!==r?r:"";var s;o&&!e&&(R(null),null===(s=Q.current)||void 0===s||s.call(Q,o),g&&n())},{highlightScanRegion:!0,highlightCodeOutline:!0,maxScansPerSecond:15}),await O.current.start(),e)return;if(a=!0,R(null),l)try{var u,m;await(null===(u=(m=O.current).setCamera)||void 0===u?void 0:u.call(m,"environment"))}catch(b){}try{var v;null===(v=y.current)||void 0===v||v.call(y,f.current,f.current.srcObject)}catch(w){}}}catch(D){if(!a){if(e)return;const t=(null===D||void 0===D?void 0:D.name)||"";let r="No se pudo iniciar el esc\xe1ner en modo compatible.";"NotAllowedError"===t?r="Permiso de c\xe1mara denegado o prompt c
1ancelado.":"NotFoundError"===t?r="No se encontr\xf3 una c\xe1mara disponible.":"NotReadableError"===t&&(r="La c\xe1mara est\xe1 en uso por otra aplicaci\xf3n."),R(r)}}finally{e||j(!1)}}})(),()=>{e=!0,B()}},[g,n,Q,y,t,l,I,R,j,L,B]),t?(0,m.jsx)(v,{cameraCount:S.length,error:N,hintText:d,loading:C,stream:w,torchOn:k,videoRef:f,onClose:n,onSwitchCamera:_,onToggleTorch:F}):null};async function f(e){try{var t;const r=(0,i.OV)();if(null===r||void 0===r||null===(t=r.permissions)||void 0===t||!t.query)return;const a=await r.permissions.query({name:e});return null===a||void 0===a?void 0:a.state}catch(r){return}}async function x(e){const{preferRearCamera:t=!0,includeMicrophone:r=!1,keepStream:a=!1}=e||{},n=(0,i.OV)();if(!function(){const e=(0,i.R2)();return!!e&&!(!e.isSecureContext&&"https:"!==e.location.protocol&&!["localhost","127.0.0.1","[::1]"].includes(e.location.hostname))}())return{ok:!1,reason:"Requiere HTTPS o localhost para solicitar permisos."};if(null===n||void 0===n||!n.mediaDevices||"function"!==typeof n.mediaDevices.getUserMedia)return{ok:!1,reason:"API mediaDevices.getUserMedia no est\xe1 disponible."};const[o,s]=await Promise.all([f("camera"),r?f("microphone"):Promise.resolve(void 0)]),l={video:t?{facingMode:{ideal:"environment"}}:{facingMode:{ideal:"user"}},audio:r||!1};let c;try{return c=await n.mediaDevices.getUserMedia(l),!a&&c&&(c.getTracks().forEach(e=>e.stop()),c=void 0),{ok:!0,stream:c,stateHints:{camera:o,microphone:s}}}catch(d){const e=d instanceof Error?d.name:"",t=d instanceof Error?d.message:"",r="denied"===o||/denied/i.test(t)||/Permission denied/i.test(t);let a="No se pudo obtener permiso de c\xe1mara.";return"NotAllowedError"===e?a=r?"Permiso de c\xe1mara bloqueado en el navegador. Debes habilitarlo en los ajustes del sitio.":"Permiso de c\xe1mara rechazado o prompt cerrado.":"NotFoundError"===e||"DevicesNotFoundError"===e?a="No se encontr\xf3 una c\xe1mara disponible en este dispositivo.":"NotReadableError"===e||"TrackStartError"===e?a="La c\xe1mara est\xe1 en uso por otra aplicaci\xf3n.":"OverconstrainedError"!==e&&"ConstraintNotSatisfiedError"!==e||(a="Las restricciones de video no se pueden cumplir (prueba sin resoluci\xf3n/facingMode)."),{ok:!1,deniedPermanently:r,stateHints:{camera:o,microphone:s},reason:a,error:d instanceof Error?d:new Error(String(d))}}}var y=r(88169);const b={checked:!1,secureContext:!1,hasMediaDevices:!1,hasGetUserMedia:!1,canEnumerate:!1,hasCameraDevice:null,barcodeDetectorAvailable:!1,barcodeSupportsQR:null};const w=()=>{const[e,t]=(0,a.useState)(b);(0,a.useEffect)(()=>{let e=!0;return(async()=>{var r,a;const n=(0,i.OV)(),o=function(){const e=(0,i.R2)();if(!e)return!1;const{location:t,isSecureContext:r}=e,a="https:"===(null===t||void 0===t?void 0:t.protocol),n=!(null===t||void 0===t||!t.hostname)&&["localhost","127.0.0.1","[::1]"].includes(t.hostname);return Boolean(r||a||n)}(),s=Boolean(null===n||void 0===n?void 0:n.mediaDevices),l=s&&"function"===typeof(null===n||void 0===n||null===(r=n.mediaDevices)||void 0===r?void 0:r.getUserMedia),c=s&&"function"===typeof(null===n||void 0===n||null===(a=n.mediaDevices)||void 0===a?void 0:a.enumerateDevices);let d=null;if(c)try{var u;const e=await(null===n||void 0===n?void 0:n.mediaDevices.enumerateDevices());d=null!==(u=null===e||void 0===e?void 0:e.some(e=>"videoinput"===e.kind))&&void 0!==u?u:null}catch(p){d=null}const{available:m,supportsQR:v}=await async function(){const e=(0,i.R2)();if(!e||!("BarcodeDetector"in e))return{available:!1,supportsQR:null};try{var t;const r=await((null===(t=e.BarcodeDetector)||void 0===t?void 0:t.getSupportedFormats())||Promise.resolve([]));return{available:!0,supportsQR:(null===r||void 0===r?void 0:r.includes("qr_code"))||!1}}catch(r){return{available:!0,supportsQR:null}}}();e&&t({checked:!0,secureContext:o,hasMediaDevices:s,hasGetUserMedia:l,canEnumerate:c,hasCameraDevice:d,barcodeDetectorAvailable:m,barcodeSupportsQR:v})})(),()=>{e=!1}},[]);const r=(0,a.useMemo)(()=>e.secureContext&&e.hasMediaDevices&&e.hasGetUserMedia&&!1!==e.hasCameraDevice,[e]),n=(0,a.useMemo)(()=>{if(!e.checked)return[];const t=[];return e.secureContext||t.push("Requiere HTTPS o localhost."),e.hasMediaDevices||t.pu
1sh("API de mediaDevices no disponible."),e.hasGetUserMedia||t.push("getUserMedia no disponible."),!1===e.hasCameraDevice&&t.push("No se detecta c\xe1mara en el dispositivo."),e.barcodeDetectorAvailable||t.push("BarcodeDetector no disponible en este navegador."),!1===e.barcodeSupportsQR&&t.push("BarcodeDetector no soporta formato QR."),t},[e]);return{support:e,isSupported:r,reasons:n}};var D=r(22651);const C=e=>{let{errorMessage:t,selectedImage:r,state:a,onRetry:n}=e;return"processing"===a?(0,m.jsxs)("div",{className:"flex flex-col items-center gap-2 p-2 lg:gap-4 lg:p-4",children:[r&&(0,m.jsxs)("div",{className:"relative",children:[(0,m.jsx)("img",{src:r,alt:"Imagen seleccionada",className:"max-w-32 max-h-32 lg:max-w-64 lg:max-h-64 rounded-lg border border-gray-200"}),(0,m.jsx)("div",{className:"absolute inset-0 bg-black bg-opacity-50 rounded-lg flex items-center justify-center",children:(0,m.jsx)(o.A,{className:"w-8 h-8 text-white animate-spin"})})]}),(0,m.jsxs)("div",{className:"flex flex-col items-center gap-2 text-gray-600",children:[(0,m.jsx)(o.A,{className:"w-4 h-4 animate-spin"}),(0,m.jsx)("span",{children:"Analizando imagen en m\xfaltiples escalas..."}),(0,m.jsx)("span",{className:"text-xs text-gray-500",children:"Esto puede tomar unos segundos"})]})]}):"success"===a?(0,m.jsxs)("div",{className:"flex flex-row lg:flex-col items-center gap-2 p-2 lg:gap-4 lg:p-4",children:[r&&(0,m.jsx)("img",{src:r,alt:"Imagen procesada",className:"max-w-24 max-h-24 lg:max-w-48 lg:max-h-48 rounded-lg border border-green-200"}),(0,m.jsxs)("div",{className:"flex items-center gap-2 text-green-600 text-sm lg:text-base",children:[(0,m.jsx)(D.A,{className:"w-3 lg:w-5 h-3 lg:h-5"}),(0,m.jsx)("span",{children:"\xa1QR detectado exitosamente!"})]})]}):"error"!==a?null:(0,m.jsxs)("div",{className:"flex flex-col items-center gap-2 p-2 lg:gap-4 lg:p-4",children:[r&&(0,m.jsx)("img",{src:r,alt:"Imagen con error",className:"max-w-32 max-h-32 lg:max-w-64 lg:max-h-64 rounded-lg border border-red-200 opacity-50"}),(0,m.jsxs)("div",{className:"flex items-center gap-2 text-red-600",children:[(0,m.jsx)(l.A,{className:"w-5 h-5"}),(0,m.jsx)("span",{children:"Error"})]}),(0,m.jsx)("p",{className:"text-sm text-gray-600 text-center max-w-xs",children:t}),(0,m.jsx)("button",{type:"button",onClick:n,className:"px-4 py-2 text-sm bg-gray-100 hover:bg-gray-200 rounded-lg transition-colors",children:"Intentar de nuevo"})]})},j=e=>{let{onDetected:t,autoStart:i=!1,autoCloseOnDetect:c=!0,className:d="",showImageButton:u=!0}=e;const{userRoles:v}=(0,a.useContext)(y.Tz)||{userRoles:[]},{support:p,isSupported:h,reasons:f}=w(),{processImageForQR:b}=(()=>{const e=(0,a.useCallback)(e=>{const t=e.data,r=e.width,a=e.height,n=new Uint8ClampedArray(t);for(let c=0;c<t.length;c+=4){var o,s,l,i;const e=Math.round(.299*(null!==(o=t[c])&&void 0!==o?o:0)+.587*(null!==(s=t[c+1])&&void 0!==s?s:0)+.114*(null!==(l=t[c+2])&&void 0!==l?l:0))>128?255:0;n[c]=e,n[c+1]=e,n[c+2]=e,n[c+3]=null!==(i=t[c+3])&&void 0!==i?i:255}return new ImageData(n,r,a)},[]),t=(0,a.useCallback)(e=>{const t=e.data,r=e.width,a=e.height,n=new Uint8ClampedArray(t);let o=255,s=0;for(let h=0;h<t.length;h+=4){var l,i,c;const e=Math.round(.299*(null!==(l=t[h])&&void 0!==l?l:0)+.587*(null!==(i=t[h+1])&&void 0!==i?i:0)+.114*(null!==(c=t[h+2])&&void 0!==c?c:0));o=Math.min(o,e),s=Math.max(s,e)}const d=s-o;if(d>0)for(let h=0;h<t.length;h+=4){var u;for(let e=0;e<3;e++){var m,v,p;const r=Math.round(.299*(null!==(m=t[h])&&void 0!==m?m:0)+.587*(null!==(v=t[h+1])&&void 0!==v?v:0)+.114*(null!==(p=t[h+2])&&void 0!==p?p:0)),a=Math.round((r-o)/d*255);n[h+e]=a}n[h+3]=null!==(u=t[h+3])&&void 0!==u?u:255}return new ImageData(n,r,a)},[]);return{processImageForQR:(0,a.useCallback)(async a=>{try{const{default:n}=await r.e(7361).then(r.t.bind(r,67361,23)),o=new Image;await new Promise((e,t)=>{o.onload=e,o.onerror=t,o.src=a});const s=document.createElement("canvas"),l=s.getContext("2d");if(!l)return{success:!1,error:"No se pudo acceder al contexto del canvas."};const i=o.width,c=o.height,d=800;let u=i,m=c;if(i>d||c>d){const e=i/c;i>c?(u=d,m=Math.floor(d/e)):(m=d,u=Math.floor(d*e))}let v=o;if(u!==i||m!==c){const e=document.createElement("canvas"),t=e.getContext("2d");if(t){e.width=u,e.height=m,t.drawImage(o,0,0,u,m);const r=new Image;r.src=e.toDataURL(),await new Promise(e=>{r.onload=e}),v=r}}const p=[1,1.5,.8,2,.6],h=150;let g=null,f=1;for(const r of p){const a=Math.max(h,Math.floor(u*r)),o=Math.max(h,Math.floor(m*r));
1if(a<h||o<h)continue;s.width=a,s.height=o,l.drawImage(v,0,0,a,o);const i=l.getImageData(0,0,a,o),c=[t(i),e(i)];for(const e of c){const t=n(e.data,e.width,e.height);if(t){g=t,f=r;break}}if(g)break}return g?{success:!0,data:g.data,scale:f}:{success:!1,error:"No se detect\xf3 ning\xfan c\xf3digo QR en la imagen. Prueba con una foto m\xe1s clara, m\xe1s cercana y con mejor iluminaci\xf3n."}}catch(n){return console.error("Error procesando la imagen:",n),{success:!1,error:"Error procesando la imagen. Int\xe9ntalo con otra imagen."}}},[e,t]),applyThreshold:e,enhanceImageForQR:t}})(),[D,j]=(0,a.useState)(null),[N,R]=(0,a.useState)(!1),[S,I]=(0,a.useState)(!1),k=(0,a.useRef)(null),E=(0,a.useRef)(null),[M,T]=(0,a.useState)("idle"),[A,q]=(0,a.useState)(null),[Q,O]=(0,a.useState)(""),[P,U]=(0,a.useState)(""),[B,L]=(0,a.useState)(null);a.useEffect(()=>{if(!i)return;const e=setTimeout(()=>{var e;null===(e=k.current)||void 0===e||e.click()},100);return()=>clearTimeout(e)},[i]);const F=(0,a.useCallback)(()=>{T("idle"),q(null),O(""),U(""),L(null),E.current&&(E.current.value="")},[]),_=(0,a.useCallback)(()=>{I(!1),R(!1),F(),j(null)},[F]),G=(0,a.useCallback)((e,r)=>{t(e,r),c&&_()},[t,c,_]),H=(0,a.useCallback)((e,t)=>{},[]),z=async e=>{const t=await b(e);t.success&&t.data?(U(t.data),T("success"),L(t.scale||null),setTimeout(()=>{t.data&&G(t.data,"image")},1500)):(T("error"),O(t.error||"Error desconocido procesando la imagen."))};return(0,m.jsxs)("div",{className:"space-y-4 ".concat(d),children:[(0,m.jsxs)("div",{className:"grid gap-3 ".concat(u?"grid-cols-2":"grid-cols-1"),children:[(0,m.jsx)("div",{className:"flex flex-col space-y-2",children:(0,m.jsxs)("button",{type:"button",onClick:async()=>{if(!h)return"image"===D&&F(),j("camera"),void R(!0);"image"===D&&F();(await x({preferRearCamera:!0,includeMicrophone:!1,keepStream:!1})).ok?(j("camera"),I(!0),R(!1)):(j("camera"),R(!0))},ref:k,className:"flex items-center justify-center gap-1.5 lg:gap-3 px-3 py-1.5 lg:px-6 lg:py-3 rounded-lg text-xs lg:text-base font-medium\n ".concat(h?"bg-blue-100 text-blue-700 hover:bg-blue-200":"bg-gray-100 text-gray-500 hover:bg-gray-200"),title:h?"Escanear con c\xe1mara":"C\xe1mara no disponible",children:[(0,m.jsx)(n.A,{className:"w-3 h-3 lg:w-5 lg:h-5"}),(0,m.jsx)("span",{children:"C\xe1mara"})]})}),u&&(0,m.jsxs)("div",{className:"flex flex-col space-y-2",children:[(0,m.jsx)("button",{type:"button",onClick:()=>{var e;"camera"===D&&(I(!1),R(!1)),j("image"),null===(e=E.current)||void 0===e||e.click()},disabled:"processing"===M,className:"flex items-center justify-center gap-1.5 lg:gap-3 px-3 py-1.5 lg:px-6 lg:py-3 rounded-lg text-xs lg:text-base font-medium text-white bg-gradient-to-r from-sky-500 to-blue-600 hover:opacity-90 disabled:opacity-50 disabled:cursor-not-allowed transition-opacity",children:"processing"===M?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(o.A,{className:"w-3 h-3 lg:w-4 lg:h-4 animate-spin"}),(0,m.jsx)("span",{children:"Procesando..."})]}):(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(s.A,{className:"w-3 h-3 lg:w-4 lg:h-4"}),(0,m.jsx)("span",{children:"Imagen"})]})}),(0,m.jsx)("input",{ref:E,type:"file",accept:"image/*",onChange:async e=>{var t;const r=null===(t=e.target.files)||void 0===t?void 0:t[0];if(!r)return;if(T("idle"),q(null),O(""),U(""),L(null),!r.type.startsWith("image/"))return T("error"),void O("Por favor selecciona un archivo de imagen v\xe1lido.");const a=new FileReader;a.onload=e=>{var t,r;q(null===(t=e.target)||void 0===t?void 0:t.result),T("processing"),z(null===(r=e.target)||void 0===r?void 0:r.result)},a.onerror=()=>{T("error"),O("Error al leer el archivo.")},a.readAsDataURL(r)},className:"hidden"})]})]}),"camera"===D&&(0,m.jsxs)("div",{className:"w-full",children:[N&&!h&&(0,m.jsxs)("div",{className:"flex items-start gap-1.5 lg:gap-3 rounded-lg border border-red-200 bg-red-50 p-2 lg:p-4 text-xs lg:text-base text-red-700 mb-4",children:[(0,m.jsx)(l.A,{className:"w-3 h-3 lg:w-5 lg:h-5 mt-0.5 flex-shrink-0"}),(0,m.jsxs)("div",{children:[(0,m.jsx)("div",{className:"font-semibold",children:"C\xe1mara no disponible"}),(0,m.jsx)("ul",{className:"mt-1 list-disc pl-5",children:f.map(e=>(0,m.jsx)("li",{children:e},e))}),(0,m.jsx)("button",{type:"button",onClick:()=>{R(!1),j(null)},className:"mt-2 px-3 py-1 text-sm bg-red-100 hover:bg-red-200 rounded transition-colors",children:"Cerrar"})]})]}),S&&(0,m.jsx)(g,{open:S,onClose:()=>{I(!1),j(null)},preferRearCamera:!0,hintText:"Alinea el QR dentro del marco",onReady:H,onDetected:e=>G(e,"camera"),autoCloseOnDetect:c})]}),"image"===D&&(0,m.jsx)(C,{errorMessage:Q,selectedImage:A,state:M,onRetry:()=>{F(),j(null)}})]})},N=e=>{let{onDetected:t,autoStart:r=!1,autoCloseOnDetect:a=!0,showImageButton:n=!0}=e;return(0,m.jsx)("div",{className:"space-y-3",children:(0,m.jsx)(j,{onDetected:t,autoStart:r,autoCloseOnDetect:a,showImageButton:n})})}},65066(e,t,r){r.d(t,{EZ:()=>p,YU:()=>o,cb:()=>v,g:()=>i,m7:()=>d,y9:()=>h});var a=r(89379);const n=r(42202).qK.injectEndpoints({endpoints:e=>({getDeviceById:e.query({query:e=>({url:"device/detail",params:{deviceId:e}}),transformResponse:e=>e.data,providesTags:(e,t,r)=>[{type:"Device",id:r}]}),getDeviceByQr:e.query({query:e=>({url:"device/qr",params:{qrCode:e}}),transformResponse:e=>e.data,providesTags:(e,t,r)=>[{type:"Device",id:r}]}),getDevicesByCustomer:e.query({query:e=>{let{customerId:t,page:r=1,limit:n=200,owner:o}=e;return{url:"device/customer",params:(0,a.A)({customerId:t,page:r,limit:n},o?{owner:o}:{})}},transformResponse:e=>e.data,providesTags:e=>{if(null===e||void 0===e||!e.rows)return[{type:"Device",id:"CUSTOMER_LIST"}];return[{type:"Device",id:"CUSTOMER_LIST"},...e.rows.flatMap(e=>null!==e&&void 0!==e&&e.id?[{type:"Device",id:e.id}]:[])]}}),getCustomerDeviceInventory:e.query({query:e=>{let{customerId:t,page:r=1,limit:a=20,ownership:n="all"}=e;return{url:"device/customer-inventory",params:{customerId:t,page:r,limit:a,ownership:n}}},transformResponse:e=>e.data,providesTags:e=>{var t;return[{type:"Device",id:"CUSTOMER_LIST"},{type:"DeviceRent",id:"LIST"},...null!==(t=null===e||void 0===e?void 0:e.rows.flatMap(e=>{var t,r;return[...null!==(t=e.device)&&void 0!==t&&t.id?[{type:"Device",id:e.device.id}]:[],...null!==(r=e.rental)&&void 0!==r&&r.id?[{type:"DeviceRent",id:e.rental.id}]:[]]}))&&void 0!==t?t:[]]}}),getDeviceHistory:e.query({query:e=>({url:"device/history",params:{deviceId:e}}),transformResponse:e=>Array.isArray(e.data)?e.data:[],providesTags:(e,t,r)=>[{type:"Device",id:r}]}),updateDevice:e.mutation({query:e=>{let{deviceId:t,body:r}=e;return{url:"device",method:"PUT",params:{deviceId:t},body:r}},invalidatesTags:(e,t,r)=>{let{deviceId:a}=r;return[{type:"Device",id:a},{type:"Device",id:"CUSTOMER_LIST"}]}}),replaceDeviceQr:e.mutation({query:e=>({url:"device/replace-qr",method:"POST",body:e}),transformResponse:e=>e,invalidatesTags:(e,t,r)=>{let{deviceId:a}=r;return[{type:"Device",id:a},{type:"Device",id:"CUSTOMER_LIST"}]}})})}),{useGetDeviceByIdQuery:o,useLazyGetDeviceByIdQuery:s,useGetDeviceByQrQuery:l,useLazyGetDeviceByQrQuery:i,useGetDevicesByCustomerQuery:c,useGetCustomerDeviceInventoryQuery:d,useLazyGetDevicesByCustomerQuery:u,useGetDeviceHistoryQuery:m,useLazyGetDeviceHistoryQuery:v,useUpdateDeviceMutation:p,useReplaceDeviceQrMutation:h}=n}}]); 2//# sourceMappingURL=9276.ab87a4f6.chunk.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.