Enhance SvelteKit project by adding new API routes for dark mode toggling, updating existing route parameters, and improving type definitions. Refactor component imports and optimize asset handling for better performance and maintainability.
This commit is contained in:
@@ -0,0 +1 @@
|
||||
import{c as g,_ as ve}from"./B5gxx3nr.js";import"./Bzak7iHL.js";import{p as he,a as C,q as n,g as e,h as J,i as S,w as B,x as T,t as Q,j as l,s as x,o as E,v as P,k as _e,m as pe,y as b,l as y}from"./DScGFiBY.js";import{s as W}from"./B7h8GtFa.js";import{i as ge}from"./BlbL38UD.js";import{b as xe}from"./DkOFPg3x.js";import{p as X}from"./DoRZqEmo.js";import{B as Y}from"./CcEFwafz.js";import{I as be}from"./CB0VnWqK.js";import{D as ye,a as we,b as De,c as ke,d as Se}from"./Do7CCxfs.js";var Be=y("<!> <!>",1),Te=y('<p class="text-destructive text-sm"> </p>'),Ee=y('<video class="border-input max-h-[50vh] w-full flex-1 rounded-lg border object-cover sm:max-h-none" playsinline=""></video>',2),Pe=y('<p class="text-muted-foreground text-sm">Starting camera…</p>'),Ae=y('<!> <div class="flex min-h-0 flex-1 flex-col gap-4"><div class="flex shrink-0 gap-2"><!> <!></div> <p class="text-muted-foreground shrink-0 text-center text-xs">or use camera below</p> <!> <div class="flex shrink-0 gap-2"><!></div></div>',1);function Ue(Z,i){he(i,!0);let c=X(i,"open",15,!1),ee=X(i,"title",3,"Scan barcode"),v=b(null),h=b(""),a=b(void 0),d=b(null),f=b(0);function q(){var s;const r=e(h).trim();r&&(_(),c(!1),n(h,""),(s=i.onResult)==null||s.call(i,r))}async function te(){if(typeof globalThis>"u"||"BarcodeDetector"in globalThis)return!0;try{const r=await ve(()=>import("./Bd99md_0.js"),[],import.meta.url);return globalThis.BarcodeDetector=r.BarcodeDetector,!0}catch{return!1}}async function re(){if(n(v,null),!await te()){n(v,"Failed to load barcode scanner. Try again or use Chrome/Edge.");return}try{n(d,await navigator.mediaDevices.getUserMedia({video:{facingMode:"environment",width:{ideal:1280},height:{ideal:720}}}),!0)}catch(s){n(v,s instanceof Error?s.message:"Could not access camera.",!0)}}function _(){var r;e(f)&&(cancelAnimationFrame(e(f)),n(f,0)),e(d)&&(e(d).getTracks().forEach(s=>s.stop()),n(d,null)),(r=e(a))!=null&&r.srcObject&&(e(a).srcObject=null),n(v,null)}C(()=>{if(!c()){_(),n(h,"");return}return re(),()=>_()}),C(()=>{if(!(!c()||!e(d)||!e(a)))return e(a).srcObject=e(d),e(a).play().catch(()=>{}),()=>{var r;(r=e(a))!=null&&r.srcObject&&(e(a).srcObject=null)}});const ae=300;function oe(){if(!e(a)||!("BarcodeDetector"in globalThis))return;const r=new globalThis.BarcodeDetector;let s=0;async function m(){var p,w;if(!c()||!e(a))return;if(e(a).readyState<2){n(f,requestAnimationFrame(m),!0);return}const A=Date.now();if(A-s>=ae){s=A;try{const D=await r.detect(e(a));if(D.length>0){const j=((p=D[0].rawValue)==null?void 0:p.trim())??"";_(),c(!1),(w=i.onResult)==null||w.call(i,j);return}}catch{}}n(f,requestAnimationFrame(m),!0)}m()}C(()=>{if(!(!c()||!e(d)||!e(a)))return oe(),()=>{e(f)&&cancelAnimationFrame(e(f))}});var L=J(),ne=S(L);g(ne,()=>Se,(r,s)=>{s(r,{get open(){return c()},set open(m){c(m)},children:(m,A)=>{var p=J(),w=S(p);g(w,()=>ye,(D,j)=>{j(D,{class:"flex max-h-[100dvh] w-[100vw] max-w-none flex-col gap-4 rounded-none border-0 p-4 sm:max-h-[90dvh] sm:w-auto sm:max-w-md sm:rounded-lg sm:border",onclose:()=>_(),children:(se,je)=>{var M=Ae(),V=S(M);g(V,()=>we,(t,o)=>{o(t,{class:"shrink-0",children:(u,z)=>{var G=Be(),H=S(G);g(H,()=>De,(O,I)=>{I(O,{children:(R,me)=>{B();var k=T();Q(()=>W(k,ee())),l(R,k)},$$slots:{default:!0}})});var fe=x(H,2);g(fe,()=>ke,(O,I)=>{I(O,{children:(R,me)=>{B();var k=T("Scan a barcode or type a code to look up an item.");l(R,k)},$$slots:{default:!0}})}),l(u,G)},$$slots:{default:!0}})});var N=x(V,2),F=E(N),U=E(F);be(U,{type:"text",placeholder:"Type barcode or SKU to search…",onkeydown:t=>t.key==="Enter"&&q(),class:"min-h-11 flex-1",get value(){return e(h)},set value(t){n(h,t,!0)}});var le=x(U,2);{let t=_e(()=>!e(h).trim());Y(le,{type:"button",class:"min-h-11 shrink-0",onclick:q,get disabled(){return e(t)},children:(o,u)=>{B();var z=T("Search");l(o,z)},$$slots:{default:!0}})}P(F);var $=x(F,4);{var ie=t=>{var o=Te(),u=E(o,!0);P(o),Q(()=>W(u,e(v))),l(t,o)},ce=t=>{var o=Ee();o.muted=!0,xe(o,u=>n(a,u),()=>e(a)),l(t,o)},de=t=>{var o=Pe();l(t,o)};ge($,t=>{e(v)?t(ie):e(d)?t(ce,1):t(de,!1)})}var K=x($,2),ue=E(K);Y(ue,{type:"button",variant:"outline",class:"min-h-12 flex-1",onclick:()=>{_(),c(!1)},children:(t,o)=>{B();var u=T("Cancel");l(t,u)},$$slots:{default:!0}}),P(K),P(N),l(se,M)},$$slots:{default:!0}})}),l(m,p)},$$slots:{default:!0}})}),l(Z,L),pe()}export{Ue as B};
|
||||
Reference in New Issue
Block a user