1(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,358221,e=>{"use strict";e.i(441143);var t,i=((t={}).DayOff="day_off",t.Sick="sick",t.NoShow="no_show",t.Activated="activated",t);let a=["day_off","sick","no_show"];e.s(["DayExceptionStatus",()=>i,"isAbsenceDayExceptionStatus",0,e=>void 0!==e&&a.includes(e)])},840105,e=>{"use strict";var t=e.i(799523),i=e.i(683138),a=e.i(358221),s=e.i(441143);class r{id;userId;role;startDate;endDate;experience;pocByActivity;activityTypes;dayExceptions;weeklyDaysOff;isBackup;constructor(e,{userId:t,role:i,startDate:a,endDate:s,experience:r,pocByActivity:n,activityTypes:o,dayExceptions:l,weeklyDaysOff:c,isBackup:d}){this.id=e,this.userId=t,this.role=i,this.startDate=a,this.endDate=s,this.experience=r,this.pocByActivity=n,this.activityTypes=o,this.dayExceptions=l,this.weeklyDaysOff=c,this.isBackup=d}toString(){return`Presence ${this.id} | UserId ${this.userId}`}toFirestore(){let e={userId:this.userId,role:this.role,startDate:this.startDate,endDate:this.endDate,experience:this.experience,months:this.getMonths()};return void 0!==this.pocByActivity&&(e.pocByActivity=this.pocByActivity),void 0!==this.activityTypes&&this.activityTypes.length>0&&(e.activityTypes=this.activityTypes),void 0!==this.dayExceptions&&this.dayExceptions.length>0&&(e.dayExceptions=this.dayExceptions),void 0!==this.weeklyDaysOff&&this.weeklyDaysOff.length>0&&(e.weeklyDaysOff=this.weeklyDaysOff),void 0!==this.isBackup&&(e.isBackup=this.isBackup),e}static fromFirestore(e,t){let i=e.data(t);return i?new r(e.id,i):null}getMonths(){let e=[],i=new Date(this.startDate);i.setDate(1);let a=new Date(this.endDate);for(a.setDate(28);(0,t.default)(i).isSameOrBefore(a);)e.push((0,t.default)(i).format("YYYY-MM")),i.setMonth(i.getMonth()+1);return e}getDates(){let e=[],a=new Date(this.startDate),s=new Date(this.endDate);for(;(0,t.default)(a).isSameOrBefore(s);)e.push((0,t.default)(a).format(i.DATE_FORMAT_DASH)),a.setDate(a.getDate()+1);return e}static empty(){return new r("",{userId:"",role:s.Role.Trainee,startDate:"",endDate:"",experience:s.TrainerExperience.Junior,pocByActivity:{},activityTypes:[],dayExceptions:[],weeklyDaysOff:[],isBackup:!1})}getDayException(e){return this.dayExceptions?.find(t=>t.date===e)}hasExceptionOnDate(e){return this.dayExceptions?.some(t=>t.date===e)??!1}isDayOff(e){let t=this.getDayException(e);return!!t&&t.status===a.DayExceptionStatus.DayOff}isSick(e){let t=this.getDayException(e);return!!t&&t.status===a.DayExceptionStatus.Sick}isNoShow(e){let t=this.getDayException(e);
1return!!t&&t.status===a.DayExceptionStatus.NoShow}isActivated(e){let t=this.getDayException(e);return!!t&&t.status===a.DayExceptionStatus.Activated}isWeeklyDayOff(e){if(!this.weeklyDaysOff||0===this.weeklyDaysOff.length)return!1;let i=(0,t.default)(e).day();return this.weeklyDaysOff.includes(i)}isEffectiveWorkingDay(e){if(!(0,t.default)(e).isBetween(this.startDate,this.endDate,"day","[]"))return!1;let i=this.getDayException(e);if(i){if((0,a.isAbsenceDayExceptionStatus)(i.status))return!1;if(i.status===a.DayExceptionStatus.Activated)return!0}return!this.isWeeklyDayOff(e)&&!this.isBackup}getEffectiveDates(){return this.getDates().filter(e=>this.isEffectiveWorkingDay(e))}getPocForActivity(e){return(0,s.getPocForActivity)(this.pocByActivity,e)}hasActivityType(e){return!this.activityTypes||0===this.activityTypes.length||this.activityTypes.includes(e)}overlapsWithDates(e,i){return(0,t.default)(this.startDate).isSameOrBefore(i)&&(0,t.default)(this.endDate).isSameOrAfter(e)}overlapsWithPresence(e){return this.userId===e.userId&&!!this.overlapsWithDates(e.startDate,e.endDate)&&(!(this.activityTypes?.length&&e.activityTypes?.length)||this.activityTypes.some(t=>e.activityTypes?.includes(t)))}}e.s(["Presence",0,r])},255704,e=>{"use strict";var t=e.i(391398),i=e.i(143308),a=e.i(239773),s=e.i(537857),r=e.i(844764),n=e.i(353835),o=e.i(377094);e.i(581516);var l=e.i(207742),c=e.i(799523),d=e.i(191788),h=e.i(169520),u=e.i(642994),m=e.i(139706),f=e.i(742397),g=e.i(13400),p=e.i(606957),y=e.i(657312),v=e.i(353533),w=e.i(840105),x=e.i(947148),b=e.i(441143);let _=new Map,S=new Map,E=async(e,t)=>{let i=`${e}|${t}`;if(_.has(i))return _.get(i)??null;let a=S.get(i);if(a)return a;let s=(async()=>{let a=await (0,v.getCollection)(f.COLLECTIONS.PRESENCES),s=(0,l.query)(a,(0,l.where)("userId","==",e),(0,l.where)("startDate","<=",t),(0,l.where)("endDate",">=",t)),r=await (0,l.getDocs)(s);if(r.empty)return _.set(i,null),null;let n=r.docs[0],o=n.data(),c=new w.Presence(n.id,o);return _.set(i,c),c})();S.set(i,s);try{return await s}finally{S.delete(i)}},j=[x.ActivityType.Kite,x.ActivityType.Surf,x.ActivityType.Wingfoil,x.ActivityType.SUP,x.ActivityType.Windsurf,x.ActivityType.Yoga],C=({className:e=""})=>{let[i,a]=(0,d.useState)(0);return(0,d.useEffect)(()=>{let e=setInterval(()=>{a(e=>(e+1)%j.length)},1200);return()=>clearInterval(e)},[]),(0,t.jsx)("div",{className:`relative w-5 h-5 ${e}`,children:j.map((e,a)=>(0,t.jsx)("div",{className:`absolute inset-0 transition-opacity duration-500 ease-out ${a===i?"opacity-100":"opacity-0"}`,children:(0,t.jsx)(u.default,{activityType:e,className:"w-5 h-5",showTooltip:!1})},e))})},O=(0,d.memo)(function({instructorId:e,presence:l,date:f,onDelete:v,onSettingsClick:w,onInstructorColorChange:x,className:_="",showSettings:S=!1,showActivities:j=!0,skipPresence:O=!1,isLoading:D=!1,disableTooltips:T=!1,isHeadcoach:N=!1}){let[k,A]=(0,d.useState)(!0),[L,$]=(0,d.useState)(!0),{openUserProfileModal:M}=(0,i.useUserProfileModal)(),W=(0,s.default)(),I=(0,p.useAuth)(e=>e.accessLevel??0)>=(0,b.getAccessLevelForRole)(b.Role.Trainer),[R,P]=(0,d.useState)(null),[V,F]=(0,d.useState)(""),[B,z]=(0,d.useState)(null),H="skeleton"===e,q=l??B;(0,d.useEffect)(()=>{if(!e||H||D)return;let t=!1;return A(!0),(0,y.fetchUserById)(e,!0,!0,!0).then(e=>{t||(P(e),A(!1))}),()=>{t=!0}},[e,H,D]),(0,d.useEffect)(()=>{if(D||H)return void $(!0);if(l)return void $(!1);if(O){$(!1),z(null);return}if(!e)return;if(!I){$(!1),z(null);return}let t=!1,i=f??(0,c.default)().format("YYYY-MM-DD");return $(!0),E(e,i).then(e=>{t||z(e)}).catch(e=>{t||(console.error("Error fetching presence for instructor:",e),z(null))}).finally(()=>{t||$(!1)}),()=>{t=!0}},[e,f,l,O,I,D,H]),(0,d.useEffect)(()=>{R?.color&&x&&x(R.color)},[R]),(0,d.useEffect)(()=>{R?F(R.getPhoto()):F("")},[R?.id,R?.photoUrl]);let U=k||D||H;return(R||k||D||H)&&e?(0,t.jsxs)("div",{className:`flex min-h-10 w-full flex-row items-center justify-between gap-2 rounded-full border border-neutralsWaterloo-200 bg-white pl-1 pr-2 py-1 text-xs shadow-sm shadow-neutralsWaterloo-200/40 transition-colors ${_}`,children:[(0,t.jsxs)("div",{className:"flex min-w-0 flex-1 flex-row items-center gap-1.5",children:[(0,t.jsx)(o.Skeleton,{disableAnimation:!0,isLoaded:!U,className:"rounded-full min-w-8",children:(0,t.jsx)(r.Avatar,{src:(0,a.getOptimizedImageUrl)(V,"thumbnail"),size:"sm",ignoreFallback:!0,"aria-label":"instructor picture",className:"cursor-pointer bg-white",imgProps:{loading:"lazy",referrerPolicy:"no-referrer",onError:()=>{if(!R?.id)return;let e=(0,g.getDefaultImageForId)(R.id);F(t=>t===e?t:e)}},onClick:e=>{e.stopPropagation(),R?.id&&M(R.id)}},V)}),(0,t.jsx)(o.Skeleton,{disableAnimation:!0,isLoaded:!U,className:"rounded-full truncate",children:R?.color?(0,t.jsx)("div",{className:`w-1 h-5 rounded-full bg-${R.color}-500`}):(0,t.jsx)("div",{className:"w-1 h-5 rounded-full bg-white"})}),(0,t.jsx)(o.Skeleton,{disableAnimation:!0,isLoaded:!U,className:"rounded-full truncate",children:(0,t.jsx)("span",{className:"block truncate",children:`${R?.firstName} ${R?.lastName?.slice(0,2)}.`})}),N&&!U&&(0,t.jsx)(m.Tooltip,{content:W("whiteboard.headcoach"),isDisabled:T,children:(0,t.jsx)("span",{"aria-label":W("whiteboard.headcoach"),className:"flex h-5 w-5 flex-none items-center justify-center rounded-full bg-golde
1nBell-50",children:(0,t.jsx)(h.default,{name:"stars",size:"14px",color:"goldenBell-700",filled:!0})})})]}),(0,t.jsx)(o.Skeleton,{disableAnimation:!0,isLoaded:!U,className:"flex flex-row items-center gap-1.5 rounded-full",children:(0,t.jsxs)("div",{className:"flex flex-row items-center gap-1.5 ",children:[j&&(L||U)?(0,t.jsx)(C,{}):j&&q?.activityTypes&&q.activityTypes.length>0?(0,t.jsx)("div",{className:"flex items-center gap-1",children:q.activityTypes.map(e=>(0,t.jsx)(u.default,{activityType:e,className:"w-5 h-5",showTooltip:!T},e))}):j&&R?.pocByActivity&&Object.keys(R.pocByActivity).length>0?(0,t.jsx)("div",{className:"flex items-center gap-1",children:Object.keys(R.pocByActivity).map(e=>(0,t.jsx)(u.default,{activityType:e,className:"w-5 h-5",showTooltip:!T},e))}):null,S?(0,t.jsx)(n.Button,{size:"sm",isIconOnly:!0,variant:"light",onPress:()=>{w&&w()},children:(0,t.jsx)(h.default,{name:"more_vert",size:"18px"})}):v&&q&&(0,t.jsx)(n.Button,{size:"sm",isIconOnly:!0,variant:"light",onPress:()=>{v&&v(q)},children:(0,t.jsx)(h.default,{name:"more_vert",size:"18px"})})]})})]}):(0,t.jsxs)("div",{className:`flex flex-row justify-center gap-2 items-center whitespace-nowrap truncate text-md p-2 w-full text-carnation-500 rounded-full font-bold ${_}`,children:[(0,t.jsx)(h.default,{name:"warning",color:"carnation-500"}),W("common.invalidQrCode")+" / "+W("common.instructor")]})});e.s(["InstructorCard",0,O])},346171,e=>{"use strict";var t=e.i(507820);e.i(581516);var i=e.i(615351),a=e.i(207742),s=e.i(336770),r=e.i(158652),n=e.i(742397),o=e.i(337153),l=e.i(606957),c=e.i(353533),d=e.i(219073);let h={columnOrder:["image","brand","model","type","materialType","size","year","color","teamColor","lines","serialNr","condition","currentLocation","salesPrice","listPrice","basePurchasePrice","purchasePrice","discount","supplier","articleNr","deliveryDate","invoiceProducer","invoiceNr","soldBy","soledTo","soldAt","soldPrice","usedHours","orderStatus","archived","owner","createdAt","modified","modifiedBy","actions"],visibleColumns:new Set(["all"]),columnSorting:{column:"model",direction:"ascending"},savedViews:[],activeViewId:null},u=(0,s.create)()((0,r.persist)((e,s)=>({columnOrder:h.columnOrder,visibleColumns:h.visibleColumns,columnSorting:h.columnSorting,savedViews:[],activeViewId:null,setColumnOrder:t=>e({columnOrder:t}),setVisibleColumns:t=>e({visibleColumns:t}),setColumnSorting:t=>e({columnSorting:t}),material:[],setMaterial:t=>e({material:t}),favorites:[],setFavorites:t=>e({favorites:t}),locations:null,locationsLoadedFor:null,locationsLoading:!1,locationsError:null,setLocations:t=>e({locations:t}),loadLocations:async i=>{let a=i??await (0,c.getLocation)();if(!s().locationsLoading||s().locationsLoadedFor!==a){s().locationsLoadedFor&&s().locationsLoadedFor!==a&&e({locations:null,locationsLoadedFor:null}),e({locationsLoading:!0,locationsError:null});try{let i=await t.default.listAsLegacyMaterialLocations(a);e({locations:new d.Locations({locations:i}),locationsLoadedFor:a,locationsLoading:!1,locationsError:null})}catch(t){console.error("[MaterialStore] loadLocations: Error loading locations:",t),e({locations:null,locationsLoadedFor:null,locationsLoading:!1,locationsError:t instanceof Error?t.message:"Failed to load locations"})}}},saveView:async t=>{let{columnOrder:i,visibleColumns:a,columnSorting:r,savedViews:n}=s();e({savedViews:[...n,{id:Date.now().toString(),name:t,columnOrder:i,visibleColumns:a,columnSorting:r}]});let o=l.useAuth.getState().user?.fbUser.uid;o&&await s().saveViewConfig(o)},loadView:t=>{let{savedViews:i}=s(),a=i.find(e=>e.id===t);a&&e({columnOrder:a.columnOrder,visibleColumns:a.visibleColumns,columnSorting:a.columnSorting,activeViewId:a.id})},deleteView:t=>{let{savedViews:i}=s();e({savedViews:i.filter(e=>e.id!==t)})},setActiveViewId:t=>e({activeViewId:t}),isCurrentSettingsMatchingView:()=>{let{columnOrder:e,visibleColumns:t,columnSorting:i,savedViews:a}=s();return a.find(a=>{let s=JSON.stringify(a.columnOrder)===JSON.stringify(e),r=!1;if("all"===a.visibleColumns&&"all"===t)r=!0;else if("all"!==a.visibleColumns&&"all"!==t){let e=Array.from(a.visibleColumns).sort(),i=Array.from(t).sort();r=JSON.stringify(e)===JSON.stringify(i)}let n=JSON.stringify(a.columnSorting)===JSON.stringify(i);return s&&r&&n})||null},loadViewConfig:async t=>{let s=(0,i.doc)(o.db,n.COLLECTIONS.USER_METADATA.PUBLIC,t,"config","view_config_inventory"),r=await (0,a.getDoc)(s);if(r.exists()){let t=r.data();e({columnOrder:t.columnOrder||h.columnOrder,visibleColumns:t.visibleColumns||h.visibleColumns,columnSorting:t.columnSorting||h.columnSorting,savedViews:(t.savedViews||[]).map(e=>({...e,visibleColumns:new Set("all"===e.visibleColumns?["all"]:e.visibleColumns)})),activeViewId:t.activeViewId||null})}else e({columnOrder:h.columnOrder,visibleColumns:h.visibleColumns,columnSorting:h.columnSorting,savedViews:[],activeViewId:null})},saveViewConfig:async e=>{let{columnOrder:t,visibleColumns:r,columnSorting:l,savedViews:c,activeViewId:d}=s(),h=c.map(e=>({...e,visibleColumns:"all"===e.visibleColumns?"all":Array.from(e.visibleColumns)})),u=(0,i.doc)(o.db,n.COLLECTIONS.USER_METADATA.PUBLIC,e,"config","view_config_inventory");await (0,a.setDoc)(u,{columnOrder:t,visibleColumns:"all"===r?"all":Array.from(r),columnSorting:l,savedViews:h,activeViewId:d})}}),{name:"material-store",version:2,migrate:(e,t)=>
1(e&&"object"==typeof e&&(delete e.locations,delete e.locationsLoadedFor,delete e.locationsLoading,delete e.locationsError),e),partialize:e=>({columnOrder:e.columnOrder||h.columnOrder,visibleColumns:e.visibleColumns||h.visibleColumns,columnSorting:e.columnSorting||h.columnSorting,savedViews:e.savedViews||[],activeViewId:e.activeViewId||null})}));e.s(["useMaterialStore",0,u])},96863,e=>{"use strict";var t=e.i(184532);e.s(["TactileSwitch",()=>t.default])},806500,e=>{"use strict";var t=e.i(391398),i=e.i(239773),a=e.i(233588),s=e.i(537857),r=e.i(418103),n=e.i(380300),o=e.i(959751),l=e.i(599367),c=e.i(700730),d=e.i(770694),h=e.i(298909),u=e.i(824004),m=e.i(191788),f=e.i(828150);e.i(963793);var g=e.i(96863),p=e.i(169520),y=e.i(642994),v=e.i(164052),w=e.i(337153),x=e.i(381232),b=e.i(346171),_=e.i(353533),S=e.i(430110);function E({sportTypeLocked:e,materialTypeLocked:i,selectedActivityType:s,selectedMaterialType:r,availableActivityTypes:n,materialTypes:o,isLoadingTypes:l,onActivityTypeChange:u,onMaterialTypeChange:m,t:f}){return(0,t.jsxs)(t.Fragment,{children:[!e&&(0,t.jsxs)(c.ScrollShadow,{orientation:"horizontal",className:"flex gap-1 pb-1 items-end",hideScrollBar:!0,children:[l&&(0,t.jsx)("div",{className:"flex items-center justify-center min-w-[56px] px-2 py-1",children:(0,t.jsx)(d.Spinner,{size:"sm",color:"default"})}),!l&&(0,t.jsxs)("button",{onClick:()=>u(void 0),className:(0,h.cn)("group flex flex-col items-center justify-center flex-shrink-0 transition-all duration-200","min-w-[56px] px-2 py-1 rounded-xl",void 0===s?"text-neutralsWaterloo-900":"text-neutralsWaterloo-500 hover:text-neutralsWaterloo-700"),children:[(0,t.jsx)("div",{className:(0,h.cn)("flex items-center justify-center rounded-full transition-all duration-200","group-hover:scale-110 group-hover:shadow-md","w-10 h-10 mb-0.5",void 0===s?"bg-neutralsWaterloo-900":"bg-neutralsWaterloo-100 group-hover:bg-neutralsWaterloo-200"),children:(0,t.jsx)(p.default,{name:"apps",size:"20px",color:void 0===s?"white":"neutralsWaterloo-500"})}),(0,t.jsx)("span",{className:(0,h.cn)("font-medium whitespace-nowrap text-[10px]",void 0===s&&"font-semibold"),children:f("bookingEngine.catalog.all")}),(0,t.jsx)("div",{className:(0,h.cn)("h-0.5 w-6 rounded-full transition-all mt-0.5",void 0===s?"bg-neutralsWaterloo-900":"bg-transparent")})]}),!l&&n.map(e=>{let i=s===e;return(0,t.jsxs)("button",{onClick:()=>u(e),className:(0,h.cn)("group flex flex-col items-center justify-center flex-shrink-0 transition-all duration-200","min-w-[56px] px-2 py-1 rounded-xl",i?"text-neutralsWaterloo-900":"text-neutralsWaterloo-500 hover:text-neutralsWaterloo-700"),children:[(0,t.jsx)("div",{className:(0,h.cn)("flex items-center justify-center rounded-full transition-all duration-200","group-hover:scale-110 group-hover:shadow-md","w-10 h-10 mb-0.5",i?"bg-neutralsWaterloo-900":"bg-neutralsWaterloo-100 group-hover:bg-neutralsWaterloo-200"),children:(0,t.jsx)(y.default,{activityType:e,showTooltip:!1,className:(0,h.cn)("w-5 h-5",i?"[&_path]:fill-white":"[&_path]:fill-neutralsWaterloo-500")})}),(0,t.jsx)("span",{className:(0,h.cn)("font-medium whitespace-nowrap text-[10px]",i&&"font-semibold"),children:(0,a.getActivityTypeLabel)(f,e)}),(0,t.jsx)("div",{className:(0,h.cn)("h-0.5 w-6 rounded-full transition-all mt-0.5",i?"bg-neutralsWaterloo-900":"bg-transparent")})]},e)})]}),!i&&s&&o.length>0&&(0,t.jsxs)(c.ScrollShadow,{orientation:"horizontal",className:"flex gap-1 pb-1",hideScrollBar:!0,children:[(0,t.jsxs)("button",{onClick:()=>m(void 0),className:(0,h.cn)("group flex items-center gap-1.5 flex-shrink-0 transition-all duration-200","px-3 py-1.5 rounded-full border",void 0===r?"bg-secondaryAquamarine-500 text-white border-secondaryAquamarine-500":"bg-white text-neutralsWaterloo-600 border-neutralsWaterloo-200 hover:border-neutralsWaterloo-300 hover:bg-neutralsWaterloo-50"),children:[(0,t.jsx)(p.default,{name:"category",size:"14px",color:void 0===r?"white":"neutralsWaterloo-500"}),(0,t.jsx)("span",{className:"text-xs font-medium whitespace-nowrap",children:f("bookingEngine.catalog.all")})]}),o.map(e=>{let i=r===e,n=S.MATERIAL_TYPE_ICONS[e]||"category";return(0,t.jsxs)("button",{onClick:()=>m(e),className:(0,h.cn)("group flex items-center gap-1.5 flex-shrink-0 transition-all duration-200","px-3 py-1.5 rounded-full border",i?"bg-secondaryAquamarine-500 text-white border-secondaryAquamarine-500":"bg-white text-neutralsWaterloo-600 border-neutralsWaterloo-200 hover:border-neutralsWaterloo-300 hover:bg-neutralsWaterloo-50"),children:[(0,t.jsx)(p.default,{name:n,size:"14px",color:i?"white":"neutralsWaterloo-500"}),(0,t.jsx)("span",{className:"text-xs font-medium whitespace-nowrap",children:(0,a.getMaterialTypeLabel)(f,e,s)})]},e)})]})]})}function j({image:e,alt:a}){let[s,r]=(0,m.useState)(!1);(0,m.useEffect)(()=>{r(!1)},[e]);let n=e?s?e:(0,i.buildResizedImageUrl)(e,"thumbnail")??e:"/images/materialPlaceholder.png";
1return(0,t.jsx)(f.Avatar,{src:n,alt:a,size:"sm",radius:"md",className:"bg-neutralsWaterloo-100 shrink-0",onError:()=>{e&&!s&&r(!0)}},n)}function C({onMaterialSelect:e,sportType:i,materialType:a,condition:s,availableForRental:o,usageStatus:l,locationId:c,limit:d,autoClear:h,placeholder:u,size:f,isDisabled:g,isRequired:v,excludeNonOperationalLocations:b,t:S}){let[E,O]=(0,m.useState)({selectedKey:null,inputValue:"",items:[]}),[D,T]=(0,m.useState)(!1),N=(0,m.useRef)(null),k=(0,m.useCallback)(async e=>{if(e.length<1)return void O(e=>({...e,items:[]}));T(!0);try{let t=c??await (0,_.getLocation)(),r={db:w.db,locationId:t,searchTerm:e,sportType:i,materialType:a,condition:s,availableForRental:o,usageStatus:l,excludeNonOperationalLocations:b,limit:d},n=await (0,x.searchMaterialsByText)(r);O(e=>({...e,items:n}))}catch(e){console.error("[MaterialSearchV2] search failed:",e),O(e=>({...e,items:[]}))}finally{T(!1)}},[i,a,s,o,l,b,c,d]);return(0,m.useEffect)(()=>(N.current&&clearTimeout(N.current),N.current=setTimeout(()=>k(E.inputValue),300),()=>{N.current&&clearTimeout(N.current)}),[E.inputValue,k]),(0,t.jsx)("div",{className:"relative w-full",children:(0,t.jsx)(r.Autocomplete,{isDisabled:g,isRequired:v,size:f,isLoading:D,placeholder:u||S("material.search.placeholder"),inputValue:E.inputValue,items:E.items,selectedKey:E.selectedKey,onInputChange:e=>{O(t=>({...t,inputValue:e,selectedKey:null}))},onSelectionChange:t=>{let i=E.items.find(e=>e.id===t);if(i){if(e(i.id,i.serialNr,i.condition),h)return void O({inputValue:"",selectedKey:null,items:[]});O({inputValue:`${i.brand} ${i.model} ${i.size} ${i.serialNr}`,selectedKey:t,items:[i]})}},allowsCustomValue:!0,"aria-labelledby":S("material.search.label"),listboxProps:{emptyContent:S(E.inputValue.length>0?"material.search.noResults":"material.search.placeholder")},children:e=>(0,t.jsx)(n.AutocompleteItem,{textValue:`${e.brand} ${e.model} ${e.size} ${e.serialNr}`,children:(0,t.jsxs)("div",{className:"flex items-center gap-2 py-0.5",children:[(0,t.jsx)(j,{image:e.images?.[0],alt:e.model}),(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsxs)("p",{className:"text-sm font-medium truncate leading-tight",children:[e.brand," ",e.model]}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5 text-[11px] text-neutralsWaterloo-500 leading-tight",children:[(0,t.jsx)("span",{children:e.serialNr}),e.size&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"text-neutralsWaterloo-300",children:"·"}),(0,t.jsx)("span",{children:e.size})]}),e.currentLocation&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"text-neutralsWaterloo-300",children:"·"}),(0,t.jsxs)("span",{className:"flex items-center gap-0.5",children:[(0,t.jsx)(p.default,{name:"location_on",size:"12px",color:"neutralsWaterloo-400"}),e.currentLocation]})]})]})]}),e.type&&(0,t.jsx)(y.default,{activityType:e.type,className:"w-4 h-4 shrink-0"})]})},e.id)})})}function O({onMaterialSelect:e,sportType:i,materialType:a,condition:s,availableForRental:r,usageStatus:n,locationId:o,limit:c,placeholder:h,selectedMaterialId:u,renderCatalogItem:f,excludeNonOperationalLocations:g,t:y}){let[v,b]=(0,m.useState)([]),[S,E]=(0,m.useState)(!1),[j,C]=(0,m.useState)(""),T=(0,m.useRef)(null),N=(0,m.useCallback)(async e=>{E(!0);try{let t=o??await (0,_.getLocation)(),l={db:w.db,locationId:t,searchTerm:e,sportType:i,materialType:a,condition:s,availableForRental:r,usageStatus:n,excludeNonOperationalLocations:g,limit:c},d=await (0,x.searchMaterialsByText)(l);b(d)}catch(e){console.error("[MaterialSearchV2:catalog] fetch failed:",e),b([])}finally{E(!1)}},[i,a,s,r,n,g,o,c]);return(0,m.useEffect)(()=>{N(j)},[i,a,s,r,n]),(0,m.useEffect)(()=>(T.current&&clearTimeout(T.current),T.current=setTimeout(()=>N(j),300),()=>{T.current&&clearTimeout(T.current)}),[j]),(0,t.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,t.jsx)(l.Input,{placeholder:h||y("bookingEngine.rental.searchItems"),value:j,onValueChange:C,size:"sm",variant:"bordered",startContent:(0,t.jsx)(p.default,{name:"search",size:"18px",color:"neutralsWaterloo-400"}),isClearable:!0,onClear:()=>C(""),classNames:{inputWrapper:"border-neutralsWaterloo-200"}}),S&&(0,t.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,t.jsx)(d.Spinner,{size:"lg"})}),!S&&0===v.length&&(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 gap-2",children:[(0,t.jsx)(p.default,{name:"inventory_2",size:"40px",color:"neutralsWaterloo-300"}),(0,t.jsx)("span",{className:"text-sm text-neutralsWaterloo-500",children:j.trim()?y("material.search.noResults"):y("bookingEngine.rental.noSpecificItemsAvailable")})]}),!S&&v.length>0&&(0,t.jsx)("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-3",children:v.map(i=>{let a=u===i.id;return f?(0,t.jsx)(m.default.Fragment,{children:f(i,a)},i.id):(0,t.jsx)(D,{material:i,isSelected:a,onSelect:()=>{e(i.id,i.serialNr,i.condition)},t:y},i.id)})})]})}function D({material:e,isSelected:i,onSelect:a,t:s}){let r=e.images?.[0],n=e.condition?S.MaterialConditionMetadata[e.condition]:void 0;return(0,t.jsxs)("button",{type:"button",onClick:a,className:(0,h.cn)("flex flex-col rounded-xl border overflow-hidden transition-all duration-150 text-left",i?"border-heroLavander-400 bg-heroLavander-50 shadow-md ring-2 ring-heroLavander-300":"border-neutralsWaterloo-200 bg-white hover:border-heroLavander-300 hover:shadow-sm"),children:[(0,t.jsxs)("div",{className:"relative w-full aspect-square bg-neutralsWaterloo-100",children:[r?(0,t.jsx)(v.default,{src:r,resizeTo:"thumbnail",alt:`${e.brand} ${e.model}`,className:"w-full h-full object-cover"}):(0,t.jsx)("div",{className:"w-full h-full flex items-center justify-center",children:(0,t.jsx)(p.default,{name:"image",size:"32px",color:"neutralsWaterloo-300"})}),i&&(0,t.jsx)("div",{className:"absolute top-2 right-2 w-6 h-6 rounded-full bg-heroLavander-500 flex items-center justify-center shadow-sm",children:(0,t.jsx)(p.default,{name:"check",size:"16px",color:"white"})}),n&&(0,t.jsx)("div",{className:"absolute bottom-2 left-2",children:(0,t.jsx)(o.Chip,{size:"sm",variant:"flat",classNames:{base:`bg-${n.bg} text-${n.text} backdrop-blur-sm`,content:"text-[10px] px-1 font-medium"},children:s(`material.conditions.${e.condition}`)}
1)})]}),(0,t.jsxs)("div",{className:"p-2 flex flex-col gap-0.5",children:[(0,t.jsxs)("span",{className:"text-sm font-medium text-neutralsWaterloo-800 truncate",children:[e.brand," ",e.model]}),(0,t.jsx)("span",{className:"text-xs text-neutralsWaterloo-500 truncate",children:[e.size,e.year].filter(Boolean).join(" · ")})]})]})}e.s(["default",0,function({onMaterialSelect:e,mode:i="search",showFilters:a=!1,sportType:r,materialType:n,initialSportType:o,initialMaterialType:l,initialFiltersEnabled:c=!1,condition:d,availableForRental:h,usageStatus:f,locationId:p,limit:y=50,autoClear:v=!1,placeholder:w,size:x="md",isDisabled:_=!1,isRequired:j=!1,excludeNonOperational:D=!1,showNonOperationalToggle:T=!1,selectedMaterialId:N,renderCatalogItem:k}){let A=(0,s.default)(),[L,$]=(0,m.useState)(!0),M=T?L:D,W=(0,b.useMaterialStore)(e=>e.locations),I=(0,b.useMaterialStore)(e=>e.loadLocations);(0,m.useEffect)(()=>{M&&!W&&I()},[M,W,I]);let R=(0,m.useMemo)(()=>{if(M&&W)return W.locations.filter(e=>(0,S.isNonOperationalLocation)(e)).map(e=>e.name)},[M,W]),P=r??o,V=n??l,[F,B]=(0,m.useState)(c),[z,H]=(0,m.useState)(P),[q,U]=(0,m.useState)(V),[Q,Y]=(0,m.useState)([]),[K,J]=(0,m.useState)(!1);(0,m.useEffect)(()=>{H(r)},[r]),(0,m.useEffect)(()=>{U(n)},[n]),(0,m.useEffect)(()=>{F||(H(r),U(n))},[F,r,n]),(0,m.useEffect)(()=>{a&&F&&!r&&(J(!0),u.default.getExistingActivityTypes().then(e=>{Y(Object.keys(S.MATERIAL_TYPE_MAP).filter(t=>e.includes(t)))}).catch(()=>Y([])).finally(()=>J(!1)))},[a,F,r]);let G=z?S.MATERIAL_TYPE_MAP[z]:[],X=r??z,Z=n??q;return(0,t.jsxs)("div",{className:"flex flex-col gap-3",children:[(a||T)&&(0,t.jsxs)("div",{className:"flex justify-end gap-4",children:[a&&(0,t.jsx)(g.TactileSwitch,{size:"sm",isSelected:F,onChange:B,label:A("material.search.showFilters"),color:"secondary"}),T&&(0,t.jsx)(g.TactileSwitch,{size:"sm",isSelected:L,onChange:$,label:A("material.search.activeOnly"),color:"warning"})]}),a&&F&&(0,t.jsx)(E,{sportTypeLocked:!!r,materialTypeLocked:!!n,selectedActivityType:z,selectedMaterialType:q,availableActivityTypes:Q,materialTypes:G,isLoadingTypes:K,onActivityTypeChange:e=>{H(e),U(void 0)},onMaterialTypeChange:e=>{U(e)},t:A}),"search"===i?(0,t.jsx)(C,{onMaterialSelect:e,sportType:X,materialType:Z,condition:d,availableForRental:h,usageStatus:f,locationId:p,limit:y,autoClear:v,placeholder:w,size:x,isDisabled:_,isRequired:j,excludeNonOperationalLocations:R,t:A}):(0,t.jsx)(O,{onMaterialSelect:e,sportType:X,materialType:Z,condition:d,availableForRental:h,usageStatus:f,locationId:p,limit:y,placeholder:w,selectedMaterialId:N,renderCatalogItem:k,excludeNonOperationalLocations:R,t:A})]})}])},325353,e=>{"use strict";class t{constructor(e,i,a,s,r){this._legacyCanvasSize=t.DEFAULT_CANVAS_SIZE,this._preferredCamera="environment",this._maxScansPerSecond=25,this._lastScanTimestamp=-1,this._destroyed=this._flashOn=this._paused=this._active=!1,this.$video=e,this.$canvas=document.createElement("canvas"),a&&"object"==typeof a?this._onDecode=i:(a||s||r?console.warn("You're using a deprecated version of the QrScanner constructor which will be removed in the future"):console.warn("Note that the type of the scan result passed to onDecode will change in the future. To already switch to the new api today, you can pass returnDetailedScanResult: true."),this._legacyOnDecode=i),i="object"==typeof a?a:{},this._onDecodeError=i.onDecodeError||("function"==typeof a?a:this._onDecodeError),this._calculateScanRegion=i.calculateScanRegion||("function"==typeof s?s:this._calculateScanRegion),this._preferredCamera=i.preferredCamera||r||this._preferredCamera,this._legacyCanvasSize="number"==typeof a?a:"number"==typeof s?s:this._legacyCanvasSize,this._maxScansPerSecond=i.maxScansPerSecond||this._maxScansPerSecond,this._onPlay=this._onPlay.bind(this),this._onLoadedMetaData=this._onLoadedMetaData.bind(this),this._onVisibilityChange=this._onVisibilityChange.bind(this),this._updateOverlay=this._updateOverlay.bind(this),e.disablePictureInPicture=!0,e.playsInline=!0,e.muted=!0;let n=!1;if(e.hidden&&(e.hidden=!1,n=!0),document.body.contains(e)||(document.body.appendChild(e),n=!0),a=e.parentElement,i.highlightScanRegion||i.highlightCodeOutline){if(s=!!i.overlay,this.$overlay=i.overlay||document.createElement("div"),(r=this.$overlay.style).position="absolute",r.display="none",r.pointerEvents="none",this.$overlay.classList.add("scan-region-
1highlight"),!s&&i.highlightScanRegion){this.$overlay.innerHTML='<svg class="scan-region-highlight-svg" viewBox="0 0 238 238" preserveAspectRatio="none" style="position:absolute;width:100%;height:100%;left:0;top:0;fill:none;stroke:#e9b213;stroke-width:4;stroke-linecap:round;stroke-linejoin:round"><path d="M31 2H10a8 8 0 0 0-8 8v21M207 2h21a8 8 0 0 1 8 8v21m0 176v21a8 8 0 0 1-8 8h-21m-176 0H10a8 8 0 0 1-8-8v-21"/></svg>';try{this.$overlay.firstElementChild.animate({transform:["scale(.98)","scale(1.01)"]},{duration:400,iterations:1/0,direction:"alternate",easing:"ease-in-out"})}catch(e){}a.insertBefore(this.$overlay,this.$video.nextSibling)}i.highlightCodeOutline&&(this.$overlay.insertAdjacentHTML("beforeend",'<svg class="code-outline-highlight" preserveAspectRatio="none" style="display:none;width:100%;height:100%;fill:none;stroke:#e9b213;stroke-width:5;stroke-dasharray:25;stroke-linecap:round;stroke-linejoin:round"><polygon/></svg>'),this.$codeOutlineHighlight=this.$overlay.lastElementChild)}this._scanRegion=this._calculateScanRegion(e),requestAnimationFrame(()=>{let t=window.getComputedStyle(e);"none"===t.display&&(e.style.setProperty("display","block","important"),n=!0),"visible"!==t.visibility&&(e.style.setProperty("visibility","visible","important"),n=!0),n&&(console.warn("QrScanner has overwritten the video hiding style to avoid Safari stopping the playback."),e.style.opacity="0",e.style.width="0",e.style.height="0",this.$overlay&&this.$overlay.parentElement&&this.$overlay.parentElement.removeChild(this.$overlay),delete this.$overlay,delete this.$codeOutlineHighlight),this.$overlay&&this._updateOverlay()}),e.addEventListener("play",this._onPlay),e.addEventListener("loadedmetadata",this._onLoadedMetaData),document.addEventListener("visibilitychange",this._onVisibilityChange),window.addEventListener("resize",this._updateOverlay),this._qrEnginePromise=t.createQrEngine()}static set WORKER_PATH(e){console.warn("Setting QrScanner.WORKER_PATH is not required and not supported anymore. Have a look at the README for new setup instructions.")}static async hasCamera(){try{return!!(await t.listCameras(!1)).length}catch(e){return!1}}static async listCameras(e=!1){if(!navigator.mediaDevices)return[];let i=async()=>(await navigator.mediaDevices.enumerateDevices()).filter(e=>"videoinput"===e.kind),a;try{e&&(await i()).every(e=>!e.label)&&(a=await navigator.mediaDevices.getUserMedia({audio:!1,video:!0}))}catch(e){}try{return(await i()).map((e,t)=>({id:e.deviceId,label:e.label||(0===t?"Default Camera":`Camera ${t+1}`)}))}finally{a&&(console.warn("Call listCameras after successfully starting a QR scanner to avoid creating a temporary video stream"),t._stopVideoStream(a))}}async hasFlash(){let e;try{if(this.$video.srcObject){if(!(this.$video.srcObject instanceof MediaStream))return!1;e=this.$video.srcObject}else e=(await this._getCameraStream()).stream;return"torch"in e.getVideoTracks()[0].getSettings()}catch(e){return!1}finally{e&&e!==this.$video.srcObject&&(console.warn("Call hasFlash after successfully starting the scanner to avoid creating a temporary video stream"),t._stopVideoStream(e))}}isFlashOn(){return this._flashOn}async toggleFlash(){this._flashOn?await this.turnFlashOff():await this.turnFlashOn()}async turnFlashOn(){if(!this._flashOn&&!this._destroyed&&(this._flashOn=!0,this._active&&!this._paused))try{if(!await this.hasFlash())throw"No flash available";await this.$video.srcObject.getVideoTracks()[0].applyConstraints({advanced:[{torch:!0}]})}catch(e){throw this._flashOn=!1,e}}async turnFlashOff(){this._flashOn&&(this._flashOn=!1,await this._restartVideoStream())}destroy(){this.$video.removeEventListener("loadedmetadata",this._onLoadedMetaData),this.$video.removeEventListener("play",this._onPlay),document.removeEventListener("visibilitychange",this._onVisibilityChange),window.removeEventListener("resize",this._updateOverlay),this._destroyed=!0,this._flashOn=!1,this.stop(),t._postWorkerMessage(this._qrEnginePromise,"close")}async start(){if(this._destroyed)throw Error("The QR scanner can not be started as it had been destroyed.");if((!this._active||this._paused)&&("https:"!==window.location.protocol&&console.warn("The camera stream is only accessible if the page is transferred via https."),this._active=!0,!document.hidden))if(this._paused=!1,this.$video.srcObject)await this.$video.play();else try{let{stream:e,facingMode:i}=await this._getCameraStream();!this._active||this._paused?t._stopVideoStream(e):(this._setVideoMirror(i),this.$video.srcObject=e,await this.$video.play(),this._flashOn&&(this._flashOn=!1,this.turnFlashOn().catch(()=>{})))}catch(e){if(!this._paused)throw this._active=!1,e}}stop(){this.pause(),this._active=!1}async pause(e=!1){if(this._paused=!0,!this._active)return!0;this.$video.pause(),this.$overlay&&(this.$overlay.style.display="none");let i=()=>{this.$video.srcObject instanceof MediaStream&&(t._stopVideoStream(this.$video.srcObject),this.$video.srcObject=null)};return e?(i(),!0):(await new Promise(e=>
1setTimeout(e,300)),!!this._paused&&(i(),!0))}async setCamera(e){e!==this._preferredCamera&&(this._preferredCamera=e,await this._restartVideoStream())}static async scanImage(e,i,a,s,r=!1,n=!1){let o,l=!1;i&&("scanRegion"in i||"qrEngine"in i||"canvas"in i||"disallowCanvasResizing"in i||"alsoTryWithoutScanRegion"in i||"returnDetailedScanResult"in i)?(o=i.scanRegion,a=i.qrEngine,s=i.canvas,r=i.disallowCanvasResizing||!1,n=i.alsoTryWithoutScanRegion||!1,l=!0):i||a||s||r||n?console.warn("You're using a deprecated api for scanImage which will be removed in the future."):console.warn("Note that the return type of scanImage will change in the future. To already switch to the new api today, you can pass returnDetailedScanResult: true."),i=!!a;try{let c,d,h;if([a,c]=await Promise.all([a||t.createQrEngine(),t._loadImage(e)]),[s,d]=t._drawToCanvas(c,o,s,r),a instanceof Worker){let e=a;i||t._postWorkerMessageSync(e,"inversionMode","both"),h=await new Promise((i,a)=>{let r,n,l,c=-1;n=s=>{s.data.id===c&&(e.removeEventListener("message",n),e.removeEventListener("error",l),clearTimeout(r),null!==s.data.data?i({data:s.data.data,cornerPoints:t._convertPoints(s.data.cornerPoints,o)}):a(t.NO_QR_CODE_FOUND))},l=t=>{e.removeEventListener("message",n),e.removeEventListener("error",l),clearTimeout(r),a("Scanner error: "+(t?t.message||t:"Unknown Error"))},e.addEventListener("message",n),e.addEventListener("error",l),r=setTimeout(()=>l("timeout"),1e4);let h=d.getImageData(0,0,s.width,s.height);c=t._postWorkerMessageSync(e,"decode",h,[h.data.buffer])})}else h=await Promise.race([new Promise((e,t)=>window.setTimeout(()=>t("Scanner error: timeout"),1e4)),(async()=>{try{var[i]=await a.detect(s);if(!i)throw t.NO_QR_CODE_FOUND;return{data:i.rawValue,cornerPoints:t._convertPoints(i.cornerPoints,o)}}catch(a){if(i=a.message||a,/not implemented|service unavailable/.test(i))return t._disableBarcodeDetector=!0,t.scanImage(e,{scanRegion:o,canvas:s,disallowCanvasResizing:r,alsoTryWithoutScanRegion:n});throw`Scanner error: ${i}`}})()]);return l?h:h.data}catch(c){if(!o||!n)throw c;let i=await t.scanImage(e,{qrEngine:a,canvas:s,disallowCanvasResizing:r});return l?i:i.data}finally{i||t._postWorkerMessage(a,"close")}}setGrayscaleWeights(e,i,a,s=!0){t._postWorkerMessage(this._qrEnginePromise,"grayscaleWeights",{red:e,green:i,blue:a,useIntegerApproximation:s})}setInversionMode(e){t._postWorkerMessage(this._qrEnginePromise,"inversionMode",e)}static async createQrEngine(i){if(i&&console.warn("Specifying a worker path is not required and not supported anymore."),i=()=>e.A(305630).then(e=>e.createWorker()),!(!t._disableBarcodeDetector&&"BarcodeDetector"in window&&BarcodeDetector.getSupportedFormats&&(await BarcodeDetector.getSupportedFormats()).includes("qr_code")))return i();let a=navigator.userAgentData;return a&&a.brands.some(({brand:e})=>/Chromium/i.test(e))&&/mac ?OS/i.test(a.platform)&&await a.getHighEntropyValues(["architecture","platformVersion"]).then(({architecture:e,platformVersion:t})=>/arm/i.test(e||"arm")&&13<=parseInt(t||"13")).catch(()=>!0)?i():new BarcodeDetector({formats:["qr_code"]})}_onPlay(){this._scanRegion=this._calculateScanRegion(this.$video),this._updateOverlay(),this.$overlay&&(this.$overlay.style.display=""),this._scanFrame()}_onLoadedMetaData(){this._scanRegion=this._calculateScanRegion(this.$video),this._updateOverlay()}_onVisibilityChange(){document.hidden?this.pause():this._active&&this.start()}_calculateScanRegion(e){let t=Math.round(2/3*Math.min(e.videoWidth,e.videoHeight));return{x:Math.round((e.videoWidth-t)/2),y:Math.round((e.videoHeight-t)/2),width:t,height:t,downScaledWidth:this._legacyCanvasSize,downScaledHeight:this._legacyCanvasSize}}_updateOverlay(){requestAnimationFrame(()=>{if(this.$overlay){var e=this.$video,t=e.videoWidth,i=e.videoHeight,a=e.offsetWidth,s=e.offsetHeight,r=e.offsetLeft,n=e.offsetTop,o=window.getComputedStyle(e),l=o.objectFit,c=t/i,d=a/s;switch(l){case"none":var h=t,u=i;break;case"fill":h=a,u=s;break;default:("cover"===l?c>d:c<d)?h=(u=s)*c:u=(h=a)/c,"scale-down"===l&&(h=Math.min(h,t),u=Math.min(u,i))}var[m,f]=o.objectPosition.split(" ").map((e,t)=>{let i=parseFloat(e);return e.endsWith("%")?(t?s-u:a-h)*i/100:i});o=this._scanRegion.width||t,d=this._scanRegion.height||i,l=this._scanRegion.x||0;var g=this._scanRegion.y||0;(c=this.$overlay.style).width=`${o/t*h}px`,c.height=`${d/i*u}
1px`,c.top=`${n+f+g/i*u}px`,i=/scaleX\(-1\)/.test(e.style.transform),c.left=`${r+(i?a-m-h:m)+(i?t-l-o:l)/t*h}px`,c.transform=e.style.transform}})}static _convertPoints(e,t){if(!t)return e;let i=t.x||0,a=t.y||0,s=t.width&&t.downScaledWidth?t.width/t.downScaledWidth:1;for(let r of(t=t.height&&t.downScaledHeight?t.height/t.downScaledHeight:1,e))r.x=r.x*s+i,r.y=r.y*t+a;return e}_scanFrame(){!this._active||this.$video.paused||this.$video.ended||("requestVideoFrameCallback"in this.$video?this.$video.requestVideoFrameCallback.bind(this.$video):requestAnimationFrame)(async()=>{if(!(1>=this.$video.readyState)){var e=Date.now()-this._lastScanTimestamp,i=1e3/this._maxScansPerSecond;e<i&&await new Promise(t=>setTimeout(t,i-e)),this._lastScanTimestamp=Date.now();try{var a=await t.scanImage(this.$video,{scanRegion:this._scanRegion,qrEngine:this._qrEnginePromise,canvas:this.$canvas})}catch(e){if(!this._active)return;this._onDecodeError(e)}!t._disableBarcodeDetector||await this._qrEnginePromise instanceof Worker||(this._qrEnginePromise=t.createQrEngine()),a?(this._onDecode?this._onDecode(a):this._legacyOnDecode&&this._legacyOnDecode(a.data),this.$codeOutlineHighlight&&(clearTimeout(this._codeOutlineHighlightRemovalTimeout),this._codeOutlineHighlightRemovalTimeout=void 0,this.$codeOutlineHighlight.setAttribute("viewBox",`${this._scanRegion.x||0} ${this._scanRegion.y||0} ${this._scanRegion.width||this.$video.videoWidth} ${this._scanRegion.height||this.$video.videoHeight}`),this.$codeOutlineHighlight.firstElementChild.setAttribute("points",a.cornerPoints.map(({x:e,y:t})=>`${e},${t}`).join(" ")),this.$codeOutlineHighlight.style.display="")):this.$codeOutlineHighlight&&!this._codeOutlineHighlightRemovalTimeout&&(this._codeOutlineHighlightRemovalTimeout=setTimeout(()=>this.$codeOutlineHighlight.style.display="none",100))}this._scanFrame()})}_onDecodeError(e){e!==t.NO_QR_CODE_FOUND&&console.log(e)}async _getCameraStream(){if(!navigator.mediaDevices)throw"Camera not found.";let e=/^(environment|user)$/.test(this._preferredCamera)?"facingMode":"deviceId",t=[{width:{min:1024}},{width:{min:768}},{}];for(let i of[...t.map(t=>Object.assign({},t,{[e]:{exact:this._preferredCamera}})),...t])try{let e=await navigator.mediaDevices.getUserMedia({video:i,audio:!1}),t=this._getFacingMode(e)||(i.facingMode?this._preferredCamera:"environment"===this._preferredCamera?"user":"environment");return{stream:e,facingMode:t}}catch(e){}throw"Camera not found."}async _restartVideoStream(){let e=this._paused;await this.pause(!0)&&!e&&this._active&&await this.start()}static _stopVideoStream(e){for(let t of e.getTracks())t.stop(),e.removeTrack(t)}_setVideoMirror(e){this.$video.style.transform="scaleX("+("user"===e?-1:1)+")"}_getFacingMode(e){return(e=e.getVideoTracks()[0])?/rear|back|environment/i.test(e.label)?"environment":/front|user|face/i.test(e.label)?"user":null:null}static _drawToCanvas(e,t,i,a=!1){i=i||document.createElement("canvas");let s=t&&t.x?t.x:0,r=t&&t.y?t.y:0,n=t&&t.width?t.width:e.videoWidth||e.width,o=t&&t.height?t.height:e.videoHeight||e.height;return a||(a=t&&t.downScaledWidth?t.downScaledWidth:n,t=t&&t.downScaledHeight?t.downScaledHeight:o,i.width!==a&&(i.width=a),i.height!==t&&(i.height=t)),(t=i.getContext("2d",{alpha:!1})).imageSmoothingEnabled=!1,t.drawImage(e,s,r,n,o,0,0,i.width,i.height),[i,t]}static async _loadImage(e){if(e instanceof Image)return await t._awaitImageLoad(e),e;if(e instanceof HTMLVideoElement||e instanceof HTMLCanvasElement||e instanceof SVGImageElement||"OffscreenCanvas"in window&&e instanceof OffscreenCanvas||"ImageBitmap"in window&&e instanceof ImageBitmap)return e;if(e instanceof File||e instanceof Blob||e instanceof URL||"string"==typeof e){let i=new Image;i.src=e instanceof File||e instanceof Blob?URL.createObjectURL(e):e.toString();try{return await t._awaitImageLoad(i),i}finally{(e instanceof File||e instanceof Blob)&&URL.revokeObjectURL(i.src)}}throw"Unsupported image type."}static async _awaitImageLoad(e){e.complete&&0!==e.naturalWidth||await new Promise((t,i)=>{let a=s=>{e.removeEventListener("load",a),e.removeEventListener("error",a),s instanceof ErrorEvent?i("Image load error"):t()};e.addEventListener("load",a),e.addEventListener("error",a)})}static async _postWorkerMessage(e,i,a,s){return t._postWorkerMessageSync(await e,i,a,s)}
1static _postWorkerMessageSync(e,i,a,s){if(!(e instanceof Worker))return -1;let r=t._workerMessageId++;return e.postMessage({id:r,type:i,data:a},s),r}}t.DEFAULT_CANVAS_SIZE=400,t.NO_QR_CODE_FOUND="No QR code found",t._disableBarcodeDetector=!1,t._workerMessageId=0,e.s(["default",0,t])},76272,e=>{"use strict";let t=null,i=(e,t,i)=>{let a=e.createOscillator(),s=e.createGain();a.type="sine",a.frequency.value=t,s.gain.setValueAtTime(.18,i),s.gain.exponentialRampToValueAtTime(.001,i+.2),a.connect(s).connect(e.destination),a.start(i),a.stop(i+.2)},a=async()=>{if(!t)return;let e=t;if(t=null,"closed"!==e.state)try{await e.close()}catch{}};e.s(["closeSuccessChimeAudio",0,a,"playSuccessChime",0,()=>{try{let e="function"!=typeof window.AudioContext?null:(t&&"closed"!==t.state||(t=new window.AudioContext),t);if(!e)return;"suspended"===e.state&&e.resume().catch(()=>{});let a=e.currentTime;i(e,520,a),i(e,780,a+.1)}catch{}}])}]);
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.