const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/BoostCompanion-BzaH1vXM.js","assets/BoostPanel-BOwmJdiG.js","assets/useAssistantChat-Dj_g_jDW.js","assets/useSmartQueue-DNbJof9F.js","assets/useBoostGift-_O1eN1OG.js","assets/sun-DMydLVYy.js","assets/announcements-CHWMrHjI.js","assets/chatWidget-B9XylLn5.js","assets/use-reduced-motion-CF5clF_K.js","assets/pause-CNkKdAXQ.js","assets/bell-off-VEjhhJlZ.js","assets/LeadSiteHome-vtgAM0pw.js","assets/ExchangeListingsSection-CE_saqt4.js","assets/useLeadSiteSearchSuggestions-ByctBUEO.js","assets/hash-BsP_EYow.js","assets/map-BFv_R5u2.js","assets/AgentReviewsSection-4KxavIT8.js","assets/credits-PIR_bev7.js","assets/leadSiteAgent--GbV6IdE.js","assets/ScrollLivingHero-2IVgsm2h.js","assets/StudioSite-SBSNKjZp.js","assets/StudioCanvas-DNzEHWt5.js","assets/waves-zxob1HHg.js","assets/mountain-DgDBLIkt.js","assets/trees-DmraWjiz.js","assets/arrow-down-Cvv6Mp9y.js","assets/StudioCanvas-Bjx_P9aK.css","assets/ThSignatureSite-CO0kky0l.js","assets/thSignatureHomepage-Ce4ghQRE.js","assets/ThSignatureSite-C-UjGvUT.css","assets/LeadSiteLuxuryHome-BDfvD2dR.js","assets/RecentSalesSnapshot-OnPRmWJM.js","assets/LeadSiteExchangeListings-DzkjV0MK.js","assets/crown-DYj5rznI.js","assets/chart-line-bfWH1_6p.js","assets/truck-CRtp0t0M.js","assets/LeadSiteLuxuryHome-DKt_VWIz.css","assets/LeadSiteLandRanchHome-CvTZ-8ub.js","assets/use-in-view-BJN_bADp.js","assets/tree-pine-DGSX7rNQ.js","assets/LeadSiteSearch-DwfD56Ee.js","assets/ListingCardExtras-BV-e0wtR.js","assets/bell-ring-TX7qlLem.js","assets/useInfiniteQuery-tryRR5hS.js","assets/LeadSiteMap-DdMRRhZh.js","assets/LeadSiteLuxurySearch-pPakYl83.js","assets/LeadSiteListingDetail-DYYNI31E.js","assets/ListingVideoTour-CaqAVR5R.js","assets/expand-Cw7nV7e4.js","assets/car-l0q1e05I.js","assets/thermometer-DdQtODFY.js","assets/snowflake-aPoUO2Cn.js","assets/useListingVideos-DB7v9JE1.js","assets/LeadSiteLuxuryListingDetail-CUbD1QZm.js","assets/LeadSiteAbout-CkGpEsCK.js","assets/LeadSiteLuxuryAbout-D8IAKdP-.js","assets/ExpReadySpotlight-DWRcjMW9.js","assets/LeadSiteBlog-CHEU4QgC.js","assets/BlogBody-Dp4szi2O.js","assets/rss-C8cLo2Ij.js","assets/LeadSiteCommunity-Co4rvs9P.js","assets/wine-BBFWHEi8.js","assets/plane-BslKInej.js","assets/music-DFqIIHlr.js","assets/LeadSiteSellers-uYsIiLJB.js","assets/LeadSiteCityPage-bDEM6cvj.js","assets/CityFaqSection-BKFf5O4k.js","assets/LeadSiteFocusPage-Zt2VeRgO.js","assets/LeadSiteExpReady-lRlWXhdP.js","assets/paintbrush-CGWbnNyQ.js","assets/VacationRentals-BZ2Mh8ek.js","assets/paw-print-Bp30VUzW.js","assets/OrgSiteLayout-9kJCtiyr.js","assets/orgSiteBrand-DKMUe12O.js","assets/OrgSiteHome-CYQrmRvQ.js","assets/OrgSiteAgents-tJYbMd15.js","assets/OrgSitePages-BGsBOoQn.js","assets/OrgSiteListings-Bd7apWgF.js","assets/CanvaSupport-fSiaOhng.js","assets/unplug-pj195nvc.js","assets/SmsOptIn-K805vX-P.js","assets/signpost-DcKGu3zU.js","assets/ConnectChatGPT-DgG_BrrO.js","assets/circle-check-big-BZ4VWBMQ.js","assets/LevelUpMCP-q2sUbmbG.js","assets/terminal-CIVjbemr.js","assets/SubscriptionSuccess-CUJ6IYfp.js","assets/index-D321xUZe.js","assets/SetupBrokerage-F_ttltqz.js","assets/LeadEngine-0c_T7vqN.js","assets/brokerageLeads-DvPZSd42.js","assets/pricing-Dng7hbfz.js","assets/inbox-DjURnG-H.js","assets/shuffle-DbQDcqMj.js","assets/list-filter-C6Q5bPvl.js","assets/circle-user-round-hfEJujLY.js","assets/InviteSignup-DggWEpGq.js","assets/eye-off-MgBEfZn0.js","assets/CoachingHub-BPJMTsWK.js","assets/useCoaching-BUPDIowh.js","assets/CoachAgentWorkspace-CoXZcOo1.js","assets/CoachingFiles-0YyvB8dK.js","assets/folder-open-BE9TImOO.js","assets/save-C3hIRWw9.js","assets/MyCoach-C_cOzpbn.js","assets/CoachReviews-CMEODed2.js","assets/circle-x-D8_18LM7.js","assets/AdminCoaching-wT156B6G.js","assets/arrow-left-right-BGdWXVq3.js","assets/user-minus-DxkGYYNf.js","assets/CoachBilling-DqgRolso.js","assets/credit-card-CVV5zaN1.js","assets/CoachSettings-FIfa4pOl.js","assets/GoogleCalendarCard-CA9j19zi.js","assets/calendar-off-CtANaTFw.js","assets/useCoachGoogleCalendar-BtDi70v3.js","assets/link-_duok5qJ.js","assets/Microsoft365Return-C5d0PeR2.js","assets/useMicrosoft365-C0Q3BbW-.js","assets/freshAccessToken-oplt78C-.js","assets/CoachWaitlist-CCxPriQF.js","assets/mail-check-CVct8iK7.js","assets/CoachProfile-BpMiOqCb.js","assets/Trial-vRxd_5cc.js","assets/testimonial-avatar-5-DBoTqx4u.js","assets/TrialSuccess-C0FNk0K8.js","assets/party-popper-emDlkm1c.js","assets/LaborDaySale-265DfpLM.js","assets/OpenHouseInviteModal-Crb8rsx1.js","assets/infinity-BgJzpAPw.js","assets/workflow-B5aEmY8M.js","assets/EndOfYearSale-CHMkL0DW.js","assets/social-studio.png.asset-VjxYcX-_.js","assets/BlackFridaySale-DJFXxqZS.js","assets/bfSale-BqD9_8Gc.js","assets/timer-CBfBrEcO.js","assets/badge-check-DelqiJaA.js","assets/BlackFridayBrokerage-C6h8vqyS.js","assets/IdxStart-0DfDbJkP.js","assets/IdxOnboarding-BVAbVQ1P.js","assets/BrokerageImports-BcnRmUx9.js","assets/papaparse.min-C9swL3BP.js","assets/BrokerageLaborDaySale-1X1Vb-h2.js","assets/BrokerageSolutions-CV_sAjWD.js","assets/receipt-DYwNmD9m.js","assets/banknote-XXP-IhQQ.js","assets/pencil-line-BBJ7ICLM.js","assets/Upgrade-0-bQA7jT.js","assets/log-in-CKye2ziT.js","assets/InstagramGift-CvU1jjwB.js","assets/VideoShare-DN76HNuW.js","assets/VideoPageTemplates-CGSvXjGK.js","assets/message-circle-heart-DkQIJbpH.js","assets/door-open-pi8WtcgI.js","assets/brain-D12bx7l1.js","assets/coffee-BAIHzA8U.js","assets/CommercialWizard-jh6IEJia.js","assets/useListingExchange-d3UtUyjH.js","assets/useTeamListingAccess-D24CcxXJ.js","assets/CommercialWorkspace-DrwnipdQ.js","assets/useListingDocuments-BWZfZTfN.js","assets/ListingPhotoGrid-BixDJ46o.js","assets/sortable.esm-opBnwJCZ.js","assets/grip-vertical-D5hPalQn.js","assets/ShareListingDialog-JfjYG9Ag.js","assets/EmailListingToSphereDialog-BDtLRIDt.js","assets/index-BTVksG5R.js","assets/separator-S1Z4_kvp.js","assets/GmailComposeDialog-CY8zDL6D.js","assets/edgeError-BL0CI4kJ.js","assets/useMassEmailReady-Os7d5zi0.js","assets/useSenderIdentity-C_dSDfF3.js","assets/useVerifiedSenderCheck-BZkAI3Tm.js","assets/VerifySenderRequiredDialog-qXG4Ig_Q.js","assets/useContactIntakePage-CBvGftum.js","assets/ToContactAutocomplete-DiD7dIex.js","assets/outlookSend-Zk2o0sqR.js","assets/paperclip-C-4Xn0VX.js","assets/ListingSocialDialog-BaiA-pmH.js","assets/useAgentBrand-BUNQgebC.js","assets/listingGraphic-Dz02nV1B.js","assets/file-search-BZvidZZE.js","assets/qr-code-DIlUG_nr.js","assets/CommercialPitchPreview-BV1Hcduv.js","assets/PublicLiveEvent-DxTZZJrw.js","assets/pin-D9QlWmSA.js","assets/arrow-up-W5Gx6TL-.js","assets/useLiveEngagement-_o0cCvpi.js","assets/sparkle-CgEUd8ud.js","assets/LiveEvents-CNpkFb5p.js","assets/AdminPageHeader-BRHVTmf6.js","assets/useLiveEvents-B07shwLc.js","assets/image-plus-D2IHl6pD.js","assets/LiveEventConsole-fpnH1PB-.js","assets/mouse-pointer-click-DCsyRaHA.js","assets/ban-DzgJFGKk.js","assets/Dashboard-iAUwr13z.js","assets/useContentEngagement-D_Y13ESK.js","assets/timezone-ChZRLJbV.js","assets/addMilliseconds-Cw5hhvmq.js","assets/isWithinInterval-JezIGd7Q.js","assets/useGmailIntegration-CKClf97D.js","assets/GoalTargetsDialog-CeJCjny6.js","assets/useBrokerageContent-zsASQKKC.js","assets/beta-badge-BSuzxHMw.js","assets/useEventGamification-Bn0oS4qz.js","assets/RelationshipHealthWidget-CEpqKofH.js","assets/useRelationshipScore-ZtvS0pJQ.js","assets/file-image-CVi1S5pe.js","assets/Profile-DWNcEJ7N.js","assets/RichTextEditor-DapAdhYv.js","assets/index-Dqhm8IyX.js","assets/index-CpcakAUL.js","assets/index-b1f3Zwqj.js","assets/heading-1-CpFFVKvC.js","assets/heading-2-eN_jNBWO.js","assets/undo-Cotug5Fb.js","assets/list-ordered-DrgdbKps.js","assets/align-left-CllKdQHH.js","assets/align-right-D143sfvh.js","assets/ImageCropper-CBCJ-2Q8.js","assets/zoom-out-zyG9BHUf.js","assets/rotate-cw-Cw2thaCR.js","assets/ImageCropper-D8Md-CES.css","assets/SmsOptInCard-DqRA5IAh.js","assets/mail-x-Bu5AnZpE.js","assets/useBrandKit-Cc_IO9XO.js","assets/useStagingStudio-zb8uX281.js","assets/checkoutTab-Dttsj7oL.js","assets/BrokerageLogoUpload-Coi0M4jg.js","assets/user-round-CpC_xxbO.js","assets/Events-vv9nsoa_.js","assets/EventLeaderboard-Clc1n-I3.js","assets/medal-BceiUynv.js","assets/MainStageSchedule-BMNdNeXB.js","assets/history-BOrbz8R3.js","assets/EventDetail-B2CM9euh.js","assets/ShareButton-CpYsHBbT.js","assets/user-cog-DCy9FYqg.js","assets/Apps-D3wHN2gm.js","assets/monitor-play-ByECYX1v.js","assets/skip-forward-BhoxdNsH.js","assets/Templates-CVJ0DeKs.js","assets/TemplateDetail-CL7L6SH1.js","assets/Programs-sGHWZ4So.js","assets/usePrograms-CF0sdLFC.js","assets/ProgramDetail-DVD7TwSC.js","assets/accordion-WNje8XOd.js","assets/index-BT5Y9-Cy.js","assets/ProgramEnroll-ClAU4AzP.js","assets/tag-uvbT7lyb.js","assets/ProgramWorkspace-DFMJOTGw.js","assets/file-spreadsheet-D0xyepZY.js","assets/layout-template-DyfJLzKO.js","assets/Programs-Cm_stlwY.js","assets/route-ChMhAUcb.js","assets/collapsible-B1-lcN8D.js","assets/AcademyVideoDetail-CAjBJrKN.js","assets/LinkedTemplatePills-B3BL6g8g.js","assets/ToolboxDetail-CAY731_e.js","assets/SocialSwag-DhG18oyl.js","assets/SocialStudio-nofHaHIU.js","assets/CanvaImportDialog-B7LHClmo.js","assets/useCanvaMailStudio-CIyktiZx.js","assets/unlink-BonQBMJK.js","assets/platforms-a4RflsaF.js","assets/music-2-2Te_BoVC.js","assets/jpegConvert-QFrA2yJr.js","assets/repeat-2-BRqIR1MA.js","assets/useCalendarTimezone-C51Ef0oG.js","assets/calendarTz-JHe45SGp.js","assets/type-BX5y536z.js","assets/settings-2-g9t_K3AO.js","assets/scheduleTz-y76AAiW0.js","assets/YouTubePublishing-CXOyyQKK.js","assets/CalendarSettingsDialog-Ch4-xD2L.js","assets/earth-7ZlzETCG.js","assets/tiktokCallbackError-HhZqZSBp.js","assets/lock-keyhole-CiXEUCYR.js","assets/clock-3-4Nb3j2DY.js","assets/jszip.min-DPw09LKr.js","assets/flask-conical-BO0WIJ68.js","assets/SocialStudio-Bwx1jhq8.css","assets/MarketingStudio-CTHfwC6_.js","assets/message-square-quote-CQry_QFD.js","assets/BrandKit-4EL5ot9w.js","assets/useBrandPresets-DvvjIyrs.js","assets/BrandingBarEditor-zexBh-fy.js","assets/ReactKonvaCore-C2uLXV71.js","assets/index-B-u0k2-X.js","assets/ListingTemplates-DVNQKkbu.js","assets/index-xVp0PEHv.js","assets/EditorialTemplate-CO88j6wt.js","assets/PersonalBranding-COR1cTin.js","assets/toggle-group-C9YKSVPk.js","assets/SocialSwagDetail-mqPXwLOM.js","assets/Community-C4fxs0wt.js","assets/MentionTextarea-CvUFrGwk.js","assets/reply-uioplJNb.js","assets/pin-off-B3eO7O2C.js","assets/Support-BrEmuPd_.js","assets/SupportAttachmentList-x1cZ_Sha.js","assets/file-video-ifiSwsuQ.js","assets/BrokerageResources-B2LMBvWJ.js","assets/AdminDashboard-D0xwk3nH.js","assets/coins-CMdz4Amx.js","assets/shopping-bag-B3tsnRKT.js","assets/database-SB12n1uv.js","assets/AdminAdEngine-mZQ1xBr2.js","assets/AdEngineOrders-8j_FZ_eh.js","assets/jspdf.es.min-DUqKe8CT.js","assets/AdEngineCheckout-DtG6Pqp1.js","assets/MemberManagement-D5hBZfo8.js","assets/SendCelebrationDialog-CFHQEoLU.js","assets/sortable-table-head-VU_X5U_2.js","assets/useTeams-RW3KxTyo.js","assets/CreateTeamDialog-Bz9yQcw-.js","assets/TeamSharedAssetsView-B0Pto3LU.js","assets/LeadPondView-BoK3SZ7N.js","assets/arrow-right-left-B9UYVuYt.js","assets/sticky-note-Ch8II8by.js","assets/droplets-BUDFYp9z.js","assets/hand-BsY7byHs.js","assets/contact-Dnejs8Lt.js","assets/calendar-heart-XYBphLAl.js","assets/UnassignedMembers-DMoNxcny.js","assets/InviteCodes-UGhRf5SE.js","assets/Events-d56nq9Z9.js","assets/useNotifications-BDftUp7d.js","assets/repeat-B_HLI2UJ.js","assets/MCPAuditLog-C99UZ1cT.js","assets/shield-alert-BhQeJRQD.js","assets/Templates-BQqtn442.js","assets/Academy-BIxaIo9t.js","assets/LinkedTemplatePicker-CeH5Wtg4.js","assets/VideoLibraryPicker-NyowpU8-.js","assets/Toolbox-B8bZGq97.js","assets/SocialSwag-DIwyXBcO.js","assets/SocialSwag2-V2kIdISU.js","assets/Community-BvHNV8x0.js","assets/Analytics-DHnC1FIq.js","assets/ShareAnalytics-HXy_MlOD.js","assets/mouse-pointer-DcmlTbmz.js","assets/panels-top-left-b6LOmpbu.js","assets/LineChart-BB5c8sgQ.js","assets/chrome-DBIZS1qQ.js","assets/BrokerageResources-Bf5jbgaZ.js","assets/DashboardManagement-5i4pyk0u.js","assets/SupportTickets-5z5A963j.js","assets/EmailTemplates-CRo9ocmL.js","assets/index-BRxKfDFq.js","assets/code-IOzXa940.js","assets/variable-Dbw2be1k.js","assets/monitor-BCj1r_Zm.js","assets/AgentEmailTemplates-VGDK73ke.js","assets/BrokerageDashboard-D-FxGQY5.js","assets/BrokerageLenderReport-C_s15PKF.js","assets/MyBrokerage-B5Gt3aMH.js","assets/useBrokerageOnboarding-BdH2fQaF.js","assets/OnboardingChecklist-BATPGRlX.js","assets/BrokerageContent-D2pFExjh.js","assets/BrokerageHelpBoard-DzSyOrCb.js","assets/useBrokerageHelpBoard-ZTM9T4jI.js","assets/BrokerageHelpBoardNew-DcQyjNQE.js","assets/BrokerageHelpBoardDetail-B7fj9bxt.js","assets/Newsletters-CC5kZ0Bz.js","assets/VisualHtmlEditor-6WJ0Vtve.js","assets/NewsletterGraphicsPicker-DuktrGyK.js","assets/underline-BZgoZUOb.js","assets/uploadBase64Images-DgL0UIpb.js","assets/SendNewsletterDialog-LMkrrDvA.js","assets/undo-2-ChS_mQVJ.js","assets/useContactCustomTags-DtSZL0Yn.js","assets/useSmartLists-BqWSYWRw.js","assets/useMailingAddressGate--nNDpOa4.js","assets/SenderAddressDialog-g7lBVpOv.js","assets/code-xml-BzqTxdU0.js","assets/NewsletterDetail-Dj_1Ptxw.js","assets/Newsletters-D41vs-Ew.js","assets/library-Cq8qXpaF.js","assets/MemberBroadcasts-Cu5dLj_N.js","assets/bookmark-plus-Dl8b91ss.js","assets/BoostAnnouncements-B88a74Yd.js","assets/NewsletterGraphics-jXnvwkp3.js","assets/Wishlist-Bufadeen.js","assets/WishlistDetail-ln43pdF0.js","assets/LevelUpBrief-C_-flNUC.js","assets/AdditionalServices-DPx-5QtW.js","assets/Discounts-SIhqIpuL.js","assets/Subscriptions-Dx4ubYgU.js","assets/instagramEmailReview-DK4Cq88H.js","assets/InstagramGiftEmails-kb6M3XmG.js","assets/InstagramCommentPilot-CnCfFvi2.js","assets/Referrals-jxC19mAt.js","assets/AgentOSControlCenter-Cp2bdb_H.js","assets/AskAI-BBiZUbBL.js","assets/InnerCircleHome-BrMc9v-t.js","assets/SnoozeContactDialog-BgLjJHvh.js","assets/pen-tool-D-onD4vr.js","assets/milestoneMail-Cs6qfJaR.js","assets/handoff-B7AOa2Ye.js","assets/milestones-De303X1G.js","assets/stamp-BC4FxcCa.js","assets/mail-open-C6BJPdFj.js","assets/InnerCircleContacts-CIMUaX4G.js","assets/mailingAddress-BJ5Zh-Ye.js","assets/SyncDirectionSelector-C8Q-hf6S.js","assets/refresh-ccw-BnDogNXw.js","assets/merge-r1lnDB08.js","assets/ContactCriteriaForm-C0_saMfl.js","assets/usePopbys-CIjSXiCA.js","assets/ContactTagChip-Bb7Jc7Ly.js","assets/info-BituTFdh.js","assets/RelationshipScoreBadge-BHI8_HUp.js","assets/MailStudioHandoffButton-B1tqQZYC.js","assets/useVideoShareTracking-U2R_MeFJ.js","assets/EnrollContactsDialog-Bxzj5Gvz.js","assets/useDripCampaigns-CO7TcF2V.js","assets/CampaignBuilderDialog-CeWlJzze.js","assets/quill.snow-DalZijOK.js","assets/quill-BzY4kI8E.css","assets/braces-TKJO_5dq.js","assets/holidayCalendar-BWDbed4A.js","assets/VideoUploadDialog-DUE8NI9D.js","assets/useVideoTouch-DvV39kDq.js","assets/CardVideoRecorderDialog-D4DgeIvu.js","assets/VideoRecorder-kpiVkoBz.js","assets/flip-horizontal-Bqo7SM0i.js","assets/videoSegmentation-23AN6N06.js","assets/monitor-up-iR000Lqu.js","assets/mic-CzAEDo7I.js","assets/folder-CiYPnfx3.js","assets/NeighborhoodFilter-DerXbohv.js","assets/useNeighborhoods-sgQ_dcI5.js","assets/useSphereMap-CqJASdTA.js","assets/sphereMap-YB1M3Tvq.js","assets/sprout-xZGKyYx3.js","assets/ContactAvatar-CBkD885L.js","assets/user-x-IH7FPmVG.js","assets/map-pinned-C100Wnsm.js","assets/InnerCircleContactDetail-CUyjfrxJ.js","assets/useLenders-CiXIbNRj.js","assets/SendToLenderDialog-dJAhGdm7.js","assets/HomeownerHubManager-BPmdMLct.js","assets/EditHomeDetailsDialog-BKBU39uL.js","assets/moon-BCV9udeI.js","assets/useSentEmails-Fe9IGPqG.js","assets/DeleteActivityDialog-C6mmABTQ.js","assets/useCMA-sX6suzAf.js","assets/useClientPortal-BT0y7sKz.js","assets/AiCmaDialog-CjDWotP-.js","assets/futureSeller-3LZHQ-5i.js","assets/PropertyLookupPanel-C-X2OA_X.js","assets/useContactFinder-ueVo66iZ.js","assets/SentEmails-DAUlqV4W.js","assets/InnerCirclePlans-BFeO1tnU.js","assets/pen-C2xGKUhr.js","assets/CMAList-BpCijee8.js","assets/SendCMADialog-CByKFw8F.js","assets/UpgradeLockedCard-33nFUTl4.js","assets/CMABuilder-Cs0EWdMD.js","assets/ListingPresentations-B3_xxTbC.js","assets/session-BgSZUuDV.js","assets/SendPresentationDialog-DMVpvB6z.js","assets/ListingPresentationBuilder-CUEk5iES.js","assets/PdfCanvasPreview-w_qY7Fuj.js","assets/pdf.worker.min-DD9c4Ig4.js","assets/ImageUploadField-DVHSGZCT.js","assets/move--cVErFku.js","assets/InnerCirclePopbys-DqVQMQ00.js","assets/locate-CXRgnrH_.js","assets/navigation-DwKzvY1A.js","assets/AdEngine-BJqZ-W33.js","assets/launchRunbook-Bp4m7sw7.js","assets/promotion-BIjG_EU8.js","assets/SmartSigns-Cdqs72Rd.js","assets/message-square-text-BZ3x4o98.js","assets/ListingExchange-DSynPs2_.js","assets/ListingLaunchKitModal-C9SbS-4J.js","assets/ListingSelectionBar-cmbZImN_.js","assets/musicVideoHandoff-Bs6IOG8F.js","assets/building-BRNZdO3z.js","assets/ListingDetail-C96X6mvn.js","assets/ListingForm-ZOv8tyo2.js","assets/CustomizeListingPage-DYvAmsod.js","assets/box-yQoiLSbZ.js","assets/VideoStudio-fGPyuTeZ.js","assets/wifi-B4tdTs8V.js","assets/VideoShareWithTemplate-CoHsvN2Y.js","assets/useStageChat-DfKDZRUJ.js","assets/chatHistory-9WGlXRX2.js","assets/browser-CjSdxGTc.js","assets/tv-Cn_o7YH1.js","assets/video-off-B-NyN1Z-.js","assets/guestRoom-iFDRpZV4.js","assets/kits-DACmZcCF.js","assets/BackdropPanel-DXbc4jmF.js","assets/ListingPhotoImport-CzfslIK8.js","assets/images-DWN5oMKW.js","assets/panel-right-close-C1FYW5uq.js","assets/clapperboard-BqQyoq-9.js","assets/scissors-CO3_AU1G.js","assets/switch-camera-G8kXZVsQ.js","assets/MainStageGate--0dXEWxR.js","assets/arena-DfiWkKIx.js","assets/phone-off-Dsp_GAli.js","assets/eraser-PeGlXLtB.js","assets/theater-DRiecA4z.js","assets/MainStageAdmin-DHtAsvxY.js","assets/StudioKitsAdmin-cnuUIZ_R.js","assets/StudioGuestJoin-CcMQxwbw.js","assets/VideoLibrary-qQ8YRCM1.js","assets/tags-BbMFYX7d.js","assets/hard-drive-CGhV67Pg.js","assets/DealPipeline-DfgtZ73-.js","assets/lucide-react-DiMp9xrg.js","assets/archive-restore-DKzdDDwR.js","assets/archive-B39Yh1cT.js","assets/arrow-down-left-r8GV9jXy.js","assets/arrow-down-right-CWYCuB6I.js","assets/circle-user-Cggrt4EY.js","assets/beaker-Ca-CMWsl.js","assets/brain-circuit-DZ3sQHJS.js","assets/calendar-x-Lh1Y1_dt.js","assets/file-code-CkWp31js.js","assets/table-DTi6HNtI.js","assets/circle-dollar-sign-BgvEHi0e.js","assets/sunset-DQOvx400.js","assets/cloud-upload-BFLq8wby.js","assets/corner-down-right-64EsyYQi.js","assets/file-check-2-DHvEdZ45.js","assets/file-check-A5WX_wn3.js","assets/file-down-CVQucXiV.js","assets/file-plus-2-BOcuGl5P.js","assets/piggy-bank-oW7Km5u5.js","assets/folder-plus-CZH9Ird4.js","assets/footprints-qD5c3V1e.js","assets/gem-DfvRkg8s.js","assets/hand-heart-odNGBfXD.js","assets/heading-3-DOf9dWym.js","assets/heart-handshake-CJ3ICg2l.js","assets/id-card-CBiVYcVh.js","assets/locate-fixed-BpH6nY8r.js","assets/list-plus-C4_XIm9m.js","assets/mail-plus-BTi3MPha.js","assets/mail-warning-Bma9yRr-.js","assets/message-square-more-piHh62Zh.js","assets/message-square-plus-CakGutYJ.js","assets/message-square-reply-CRufCDLk.js","assets/messages-square-Dpwq5deB.js","assets/mouse-pointer-2-UyDtiIdq.js","assets/skip-back-CH1nDQqy.js","assets/octagon-alert-2a74myJ8.js","assets/power-off-CnDqEGCt.js","assets/power-D3Y-6aim.js","assets/rectangle-vertical-_U-2cW1G.js","assets/scroll-text-CYs27ELC.js","assets/shield-off-CxFFXFd5.js","assets/shield-question-CMiCDo1A.js","assets/table-2-FZbbUU6a.js","assets/text-cursor-input-GynnjVvD.js","assets/thumbs-down-D25vToiu.js","assets/twitter-CbGWpZn6.js","assets/user-round-check-nFO-nclO.js","assets/user-round-plus-chGhm3n0.js","assets/user-round-search-D7EV3kYo.js","assets/users-round-Df5pcq8p.js","assets/useCommissionPlans-DhO8sb_l.js","assets/ComplianceMessageThread-oxLuiSDD.js","assets/SendForSignatureDialog-BcZu-3HL.js","assets/useFormEnvelopes-C4xHXBcX.js","assets/PortalInviteDialog-BwwkonCg.js","assets/PlaybookLibraryDialog-g_t3cMV-.js","assets/LenderPartnerDialog-Dfw5crGX.js","assets/PhotoUploadField-C59Z0d9L.js","assets/PortalListView-Ds8H7L4h.js","assets/complianceMetrics-Ce83UgLe.js","assets/FormsLibrary-BNIJ2aG2.js","assets/FormPlacementEditor-Bayd2OC1.js","assets/TransactionCoordinator-Ckage62J.js","assets/PortalReferrals-CTYoOxSH.js","assets/usePortalReferrals-BZc7FLAq.js","assets/AgentVendors-BUrf85WR.js","assets/VendorFormDialog-Caqmxn_n.js","assets/BrokerageForms-Bqf3OwjN.js","assets/BrokerageVendors-BU2zrJtu.js","assets/ClientPortalsHub-DgAVX8aO.js","assets/PortalMessagesPanel-DQFFK8ze.js","assets/ClientPortalDetail-B86EvJC6.js","assets/MyCardEditor-Butsjdpb.js","assets/CardBlocksEditor-VTdXTyQi.js","assets/Integrations-Deg4wIkp.js","assets/SesIntegrationCard-BjVKWToh.js","assets/RecruitVerifiedSenders-8CRZOwDI.js","assets/Microsoft365Card-CBAK7PNU.js","assets/BrowserExtension-eNQIv4Jx.js","assets/IntegrationsGmailCallback-CJLOG5li.js","assets/IntegrationsMetaCallback-CcXcrEko.js","assets/AgentActivation-HhbSavlg.js","assets/MembershipReviews-kMlSgTwv.js","assets/LeadNotifications-BKxz4Aif.js","assets/WeeklyDigest-zTy1tB5w.js","assets/AgentPoints-BpcgWDpO.js","assets/AgentCards-3Qf4U7vs.js","assets/Marketplace-Df1tDdoq.js","assets/RewardStore-Dd5Q3bFV.js","assets/usePointRewardSettings-D3mLnFQN.js","assets/Integrations-B4Gahdnu.js","assets/SocialConnections-CcfxOguT.js","assets/SocialAutopilot-C9xyW-6G.js","assets/McpUpdates-DrtpfAzN.js","assets/NotificationSettings-Cw8ONKsU.js","assets/PresentationAnalytics-BFNu1ctK.js","assets/ListingPresentationStudioAdmin-DCsJKxc5.js","assets/ListingRevivalAdmin-BsfjERgS.js","assets/useListingRevivalAccess-6u1shkwo.js","assets/GuestBookAnalytics-CvegAMB4.js","assets/IntegrationsCallback-LkO-GEX6.js","assets/AdminRecruiting-C-grfgMs.js","assets/RecruitPipelineStageEditor-C7nyd7Sp.js","assets/videoThumb-B7-rh5G3.js","assets/index-XUiaAs3m.js","assets/BrokerageRecruiting-CrY-8di-.js","assets/600-BSKZD_mM.css","assets/BrokerageOnboarding-CNP7OlZ8.js","assets/BrokerageTransactions-CntvaJ7I.js","assets/AddDealDialog-D6NLKdQn.js","assets/useDealEscrow-CX8wRY_q.js","assets/BrokerageDeals-D4fxI9p7.js","assets/BrokerageOperations-Bh74zfRa.js","assets/renewals-kN25gEnX.js","assets/WebsitesHub-4abe3Vdt.js","assets/useMyWebsites-DtIB5CB7.js","assets/SiteGrade-CoqrwCLx.js","assets/TeamWebsite-0nF4fjS5.js","assets/OrgSiteBuilder-Dw9GDEms.js","assets/SiteSwitcher-tUOcXXYV.js","assets/BrokerageWebsite-BcHdnuJ_.js","assets/BrokerageAgentWebsites-CPfLtNEe.js","assets/BrokerageCommissionPlans-BO35m4yO.js","assets/BrokerageContentActivity-3pX3mmWI.js","assets/BetaSocialPostGenerator-C6lnS7ZD.js","assets/AdminLMS-C-EfrlRg.js","assets/useLMS-BKLNgoI3.js","assets/AdminCourseDetail-F26HUt6O.js","assets/LevelUpU-BPFskb6X.js","assets/LevelUpUCourse-CTmMi8xm.js","assets/MobileAgentApp-CV2ei4T0.js","assets/StagingStudio-CV3ve39v.js","assets/presets-C74ROnAM.js","assets/download-BqCckdNk.js","assets/BeforeAfterSlider-B9TceAs8.js","assets/BuyCreditsDialog-C9eWGnzv.js","assets/StagingLibrary-DRSTLFfh.js","assets/StagingCredits-_84kHm1e.js","assets/AgentWallet-ZimQn_Ol.js","assets/useHomeReel-Cc7MapD4.js","assets/Prospecting-CujaRYrd.js","assets/ProspectHousePanel-D0Sqyg6G.js","assets/types-kW6jHCE4.js","assets/recipients-DwRJtOvs.js","assets/aerial-CfLIM_YZ.js","assets/StagingSharePage-sfhWuPtV.js","assets/StagingStudioAdmin-BPEPdpSK.js","assets/ContactFinderAdmin-DYhphu6T.js","assets/PostcardManager-DajZv7R5.js","assets/PostcardZoneEditor-pvhYLw34.js","assets/usePostcardZones-DdZ6JqVL.js","assets/MailStudioTemplates-BunFvmH0.js","assets/HomeReelManager-ME6Plbss.js","assets/videoRenderSink-KDd1M0JO.js","assets/AdminMusicVideos-DNpk8cm1.js","assets/AdminVideoLab-B7NsdzyA.js","assets/BoostPreview-oIArAqR8.js","assets/AdminCredits-Cosuj3sB.js","assets/MailStudio-vc5hU33W.js","assets/farmToCrm-BXB42VAu.js","assets/campaignMail-De5lo4aW.js","assets/FsboLetter-DmgYXTNo.js","assets/RevivalLetter-Cd-kMR61.js","assets/types-CK1tolb7.js","assets/prepareCampaignLetter-Dd2QzIaC.js","assets/addressNormalization-R8Z0mzYu.js","assets/MailStudio-D-BotKHo.css","assets/InnerCirclePopbyMap-eqARYlEl.js","assets/SphereMap-COj98qKf.js","assets/PropertyIntelligenceDashboard-D42_fp5S.js","assets/LiveVisitorFeed-L8dsc5JD.js","assets/LeadSites-Em7Ok5w5.js","assets/LeadSiteEditor-CGtsUzAI.js","assets/ModuleConfigPanel-BEL3FpmJ.js","assets/ImageUrlField-osLKL9RK.js","assets/VideoUrlField-D-3QAswv.js","assets/LeadSiteEditor-MoQpsqOR.css","assets/AdminLeadSiteThemes-C8FQkt7w.js","assets/AdminFreeWebsiteOfferStudio-YfhowkFk.js","assets/AdminMlsFeeds-CiuVq-97.js","assets/AdminWebsiteRequests-Dfe65SxC.js","assets/WebsitePackages-CSO4ApaI.js","assets/NeedAWebsite-tGWW447e.js","assets/CreateWebsite-D0DlaJeA.js","assets/MLSListings-DaS4thHE.js","assets/MLSListingDetail-DeRQmhuZ.js","assets/WebsiteActivityPage-BEFtlWvK.js","assets/PublicRecruitForm-BhjdMzZ6.js","assets/PublicEventInviteUnsubscribe-0EFcgboA.js","assets/SocialConnections-CNQGoeCv.js","assets/SocialConnectionsCallback-Bmys1jO5.js","assets/LinkedInCallback-BOjDm5l7.js","assets/TikTokCallback-C2s7vleb.js","assets/MarketplaceCart-T4w2tAGO.js","assets/MarketplaceOrderDetail-RnFxDSLb.js","assets/RewardStore-CYO4K5hP.js","assets/ReferFriends-DBXwiJu4.js","assets/SmartPresentations-B8aNVXXp.js","assets/useSmartPresentations-CKWfW8oA.js","assets/SmartPresentationCreate-Cw82Y4Wb.js","assets/TeleprompterOverlay-DDCHo8nd.js","assets/GuestBook-CsZItNVp.js","assets/SignDocument-C0U6obph.js","assets/Blog-DJF4w0OG.js","assets/TrialCTA-BiRYkvc6.js","assets/BlogPost-BcEkWjB1.js","assets/AdminBlog-B3tSvDnM.js","assets/ReviewLanding-1sCryaZA.js","assets/ReviewIntake-qgFClzWF.js","assets/PublicReviewsPage-C20dK_U6.js","assets/PublicReviewSubmit-BrErdwUc.js","assets/Reviews-f2ymLybE.js","assets/NetSheets-CZ8icpQ6.js","assets/LenderHub-B870jRAL.js","assets/states-BVqvKcH4.js","assets/AdEngineSponsor-kz-gAyDD.js","assets/LendersLanding-BgMMhAbx.js","assets/LendingPartners-BTte9N4W.js","assets/AdminLenders-C9-4Vhw1.js","assets/CardStudio-Von4ijey.js","assets/ListingStudio-erYNFvVe.js","assets/SmartDrips-BxOvg4wr.js","assets/WeeklyReels-DesmnX8y.js","assets/ReelCard-BLLtXZIi.js","assets/useWeeklyReels-C_a8ONE3.js","assets/WeeklyReelsOnboarding-CGNH2CC9.js","assets/WeeklyReelsAdmin-DA368_Hz.js","assets/AttractLayout-CaM7C488.js","assets/useAttractSettings-CDr6ZNWJ.js","assets/useAttractIntelligence-BZjCc8gp.js","assets/HealthScoreBadge-Dn0uk4id.js","assets/AttractToday-99cYfCAU.js","assets/useAttractIntelSync-DUc5D0M-.js","assets/useAttractAgents-tPMNRYQY.js","assets/useAttractFollowUps-BqnUbvAI.js","assets/useAttractActivities-BUYiiCfi.js","assets/RecommendationCard-sZpUhRGw.js","assets/QuickAddRelationship-Dpi9Oth3.js","assets/relationshipStages-Buh5_cBI.js","assets/useAttractEvents-BpOMG5pO.js","assets/AttractRelationships-DRFHsRrN.js","assets/AgentEditSheet-4YiOU1NR.js","assets/AttractFollowUp-BcjQ9dPo.js","assets/AttractPageHeader-W8xjEXjN.js","assets/AttractTemplates-ClaJ1oUd.js","assets/AttractReports-PInmKEKT.js","assets/AttractSettings-BkKOLlsY.js","assets/AttractToolkit-Bm9QLshu.js","assets/Objections-CSuZlNH6.js","assets/AttractCalculator-CEgWkr49.js","assets/attractionPageTemplate-C9AaZMgq.js","assets/AttractEventList-DhS_xZMw.js","assets/AttractEventBuilder-CLe-qoCR.js","assets/useAttractKits-lMl2Mh_T.js","assets/AttractEventDetail-C5qNYS21.js","assets/AttractEventCheckIn-CqRFvpzz.js","assets/AttractOnboarding-C2BLwmKP.js","assets/ContentStudio-CYKOOt_Z.js","assets/KitList-DGxIZUrm.js","assets/KitBuilder-DSTrE8rI.js","assets/KitPreview-jY3XQoiA.js","assets/KitAnalytics-BndrWLoy.js","assets/KitTemplates-DY1AG-MH.js","assets/AttractAgentDetail-DS0TlnJD.js","assets/AttractOpportunities-DZh-avoJ.js","assets/AttractIntelligenceDebug-CifQjjCJ.js","assets/PublicAttractKit-nYTvFFEL.js","assets/PublicAttractEvent-D2WsDVRS.js","assets/PublicAttractionPage-CfmfJw1w.js","assets/AttractionPageView-DyQT3XAZ.js","assets/RevivalLanding-B864A4Ly.js","assets/RevivalPlan-VBIeXtu9.js","assets/revivalPdf-eCON2uCE.js","assets/ListingRevival-XDE68Tb4.js","assets/useListingRevival-Cgw08Alm.js","assets/AreaChart-Bf6lPQaR.js","assets/RevivalCampaignWizard-BFYN5fU5.js","assets/RevivalCampaignDetail-5w513gfY.js","assets/LetterEditor-B-tlVz1d.js","assets/FsboBreakthrough-D492dQaS.js","assets/useFsboBreakthrough-Yefmhi3D.js","assets/FsboPropertyDialog-DiHqabFQ.js","assets/FsboCampaignWizard-DEQorBuI.js","assets/FsboCampaignDetail-DcLt5KQX.js","assets/FsboLanding-czzsELEa.js","assets/publicApi-BEaFpcRg.js","assets/FsboGuide-D5vl352u.js","assets/FsboBreakthroughAdmin-C6_--7zf.js","assets/AttractLandingPageBuilder-CE1t4csj.js","assets/AttractAccess-Dfqx8vk4.js","assets/Teams-C19D-jEe.js","assets/MyTeam-7PxxGrSI.js","assets/TeamLeaderSettings-8deAxmQp.js","assets/TeamHub-ITFpVPoL.js","assets/SchedulerSettings-BOrvSE0N.js","assets/MyCalendar-Dv8TVPRg.js","assets/BookingManagePage-BzuMJgmt.js","assets/LandingPages-bRzks_ln.js","assets/BuyerMatch-EZlKwo6B.js","assets/SendBuyerMatchEmailDialog-ugyCjTX9.js","assets/BuyerMatchEditor-C4oSxTWS.js","assets/matching-BdEgbJjD.js","assets/PublicBuyerMatch-Bl3Z676o.js","assets/LandingPageEditor-DKWyll5y.js","assets/LandingPageDefaults-Cj5zWA1Q.js","assets/WebsiteAppsHub-DSwmzt1m.js","assets/ClaimFreeLeadSiteCard-CkWpWKgi.js","assets/useWebsiteApps-D33xoREq.js","assets/ClaimWebsite-Co4MvxyD.js","assets/VideoGreeterEditor-N-510jjk.js","assets/ExitIntentEditor-CzAe9OBa.js","assets/widgetTemplates-keLygp7O.js","assets/LeadMagnetEditor-DRdNWpFQ.js","assets/RelationshipScorecard-5Yv_cJmx.js","assets/SphereGaps-DOrasUf3.js","assets/ConnectPageSettings-BO3b1PvK.js","assets/BehaviorAlerts-DQKI5OeA.js","assets/HomeownerHubs-CIQu5mJ1.js","assets/EmailCampaigns-Cx8BvTYu.js","assets/sesRequest-BJwyD-V9.js","assets/EmailCompliance-CgJrlK3z.js","assets/EmailCampaignComposer-Ck9xqmGH.js","assets/EditorModeSelector-BHdP-hYg.js","assets/EmailCampaignDetail-Dz8Dp1IU.js","assets/SharedCampaignTemplates-B1KNJGBn.js","assets/TemplateEditorDialog-C7wcFpoe.js","assets/AgentTemplates-CBfBVEaO.js","assets/TheLocalMoveHome-DLJh4tUe.js","assets/tlm-hero-bg-BbD3acLf.js","assets/TheLocalMoveGetStarted-2K_90THZ.js","assets/TheLocalMoveCheckout-mZVjye7x.js","assets/AdminWebsiteOrders-BuyAZ0FA.js"])))=>i.map(i=>d[i]); var bMe=Object.defineProperty;var Ete=t=>{throw TypeError(t)};var wMe=(t,e,r)=>e in t?bMe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var Vr=(t,e,r)=>wMe(t,typeof e!="symbol"?e+"":e,r),ez=(t,e,r)=>e.has(t)||Ete("Cannot "+r);var Ct=(t,e,r)=>(ez(t,e,"read from private field"),r?r.call(t):e.get(t)),os=(t,e,r)=>e.has(t)?Ete("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),Sn=(t,e,r,n)=>(ez(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),Zs=(t,e,r)=>(ez(t,e,"access private method"),r);var PR=(t,e,r,n)=>({set _(s){Sn(t,e,s,r)},get _(){return Ct(t,e,n)}});function SMe(t,e){for(var r=0;rn[s]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))n(s);new MutationObserver(s=>{for(const o of s)if(o.type==="childList")for(const c of o.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&n(c)}).observe(document,{childList:!0,subtree:!0});function r(s){const o={};return s.integrity&&(o.integrity=s.integrity),s.referrerPolicy&&(o.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?o.credentials="include":s.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function n(s){if(s.ep)return;s.ep=!0;const o=r(s);fetch(s.href,o)}})();var uc=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function bi(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function TMe(t){if(t.__esModule)return t;var e=t.default;if(typeof e=="function"){var r=function n(){return this instanceof n?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};r.prototype=e.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(t).forEach(function(n){var s=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(r,n,s.get?s:{enumerable:!0,get:function(){return t[n]}})}),r}var ome={exports:{}},B3={},lme={exports:{}},si={};/** * @license React * react.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var cC=Symbol.for("react.element"),EMe=Symbol.for("react.portal"),jMe=Symbol.for("react.fragment"),kMe=Symbol.for("react.strict_mode"),AMe=Symbol.for("react.profiler"),NMe=Symbol.for("react.provider"),CMe=Symbol.for("react.context"),IMe=Symbol.for("react.forward_ref"),PMe=Symbol.for("react.suspense"),RMe=Symbol.for("react.memo"),LMe=Symbol.for("react.lazy"),jte=Symbol.iterator;function MMe(t){return t===null||typeof t!="object"?null:(t=jte&&t[jte]||t["@@iterator"],typeof t=="function"?t:null)}var cme={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},ume=Object.assign,dme={};function OT(t,e,r){this.props=t,this.context=e,this.refs=dme,this.updater=r||cme}OT.prototype.isReactComponent={};OT.prototype.setState=function(t,e){if(typeof t!="object"&&typeof t!="function"&&t!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,t,e,"setState")};OT.prototype.forceUpdate=function(t){this.updater.enqueueForceUpdate(this,t,"forceUpdate")};function hme(){}hme.prototype=OT.prototype;function h7(t,e,r){this.props=t,this.context=e,this.refs=dme,this.updater=r||cme}var f7=h7.prototype=new hme;f7.constructor=h7;ume(f7,OT.prototype);f7.isPureReactComponent=!0;var kte=Array.isArray,fme=Object.prototype.hasOwnProperty,m7={current:null},mme={key:!0,ref:!0,__self:!0,__source:!0};function pme(t,e,r){var n,s={},o=null,c=null;if(e!=null)for(n in e.ref!==void 0&&(c=e.ref),e.key!==void 0&&(o=""+e.key),e)fme.call(e,n)&&!mme.hasOwnProperty(n)&&(s[n]=e[n]);var a=arguments.length-2;if(a===1)s.children=r;else if(1>>1,xe=me[je];if(0>>1;jes(lt,Pe))wts(yt,lt)?(me[je]=yt,me[wt]=Pe,je=wt):(me[je]=lt,me[Ze]=Pe,je=Ze);else if(wts(yt,Pe))me[je]=yt,me[wt]=Pe,je=wt;else break e}}return ke}function s(me,ke){var Pe=me.sortIndex-ke.sortIndex;return Pe!==0?Pe:me.id-ke.id}if(typeof performance=="object"&&typeof performance.now=="function"){var o=performance;t.unstable_now=function(){return o.now()}}else{var c=Date,a=c.now();t.unstable_now=function(){return c.now()-a}}var f=[],m=[],y=1,_=null,w=3,E=!1,A=!1,C=!1,I=typeof setTimeout=="function"?setTimeout:null,M=typeof clearTimeout=="function"?clearTimeout:null,D=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function B(me){for(var ke=r(m);ke!==null;){if(ke.callback===null)n(m);else if(ke.startTime<=me)n(m),ke.sortIndex=ke.expirationTime,e(f,ke);else break;ke=r(m)}}function U(me){if(C=!1,B(me),!A)if(r(f)!==null)A=!0,Se(q);else{var ke=r(m);ke!==null&&be(U,ke.startTime-me)}}function q(me,ke){A=!1,C&&(C=!1,M(Q),Q=-1),E=!0;var Pe=w;try{for(B(ke),_=r(f);_!==null&&(!(_.expirationTime>ke)||me&&!oe());){var je=_.callback;if(typeof je=="function"){_.callback=null,w=_.priorityLevel;var xe=je(_.expirationTime<=ke);ke=t.unstable_now(),typeof xe=="function"?_.callback=xe:_===r(f)&&n(f),B(ke)}else n(f);_=r(f)}if(_!==null)var Ue=!0;else{var Ze=r(m);Ze!==null&&be(U,Ze.startTime-ke),Ue=!1}return Ue}finally{_=null,w=Pe,E=!1}}var H=!1,K=null,Q=-1,J=5,ee=-1;function oe(){return!(t.unstable_now()-eeme||125je?(me.sortIndex=Pe,e(m,me),r(f)===null&&me===r(m)&&(C?(M(Q),Q=-1):C=!0,be(U,Pe-je))):(me.sortIndex=xe,e(f,me),A||E||(A=!0,Se(q))),me},t.unstable_shouldYield=oe,t.unstable_wrapCallback=function(me){var ke=w;return function(){var Pe=w;w=ke;try{return me.apply(this,arguments)}finally{w=Pe}}}})(vme);_me.exports=vme;var HMe=_me.exports;/** * @license React * react-dom.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var WMe=N,Md=HMe;function Yr(t){for(var e="https://reactjs.org/docs/error-decoder.html?invariant="+t,r=1;r"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),pV=Object.prototype.hasOwnProperty,KMe=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,Nte={},Cte={};function YMe(t){return pV.call(Cte,t)?!0:pV.call(Nte,t)?!1:KMe.test(t)?Cte[t]=!0:(Nte[t]=!0,!1)}function ZMe(t,e,r,n){if(r!==null&&r.type===0)return!1;switch(typeof e){case"function":case"symbol":return!0;case"boolean":return n?!1:r!==null?!r.acceptsBooleans:(t=t.toLowerCase().slice(0,5),t!=="data-"&&t!=="aria-");default:return!1}}function XMe(t,e,r,n){if(e===null||typeof e>"u"||ZMe(t,e,r,n))return!0;if(n)return!1;if(r!==null)switch(r.type){case 3:return!e;case 4:return e===!1;case 5:return isNaN(e);case 6:return isNaN(e)||1>e}return!1}function Eu(t,e,r,n,s,o,c){this.acceptsBooleans=e===2||e===3||e===4,this.attributeName=n,this.attributeNamespace=s,this.mustUseProperty=r,this.propertyName=t,this.type=e,this.sanitizeURL=o,this.removeEmptyString=c}var pc={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){pc[t]=new Eu(t,0,!1,t,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var e=t[0];pc[e]=new Eu(e,1,!1,t[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(t){pc[t]=new Eu(t,2,!1,t.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){pc[t]=new Eu(t,2,!1,t,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(t){pc[t]=new Eu(t,3,!1,t.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(t){pc[t]=new Eu(t,3,!0,t,null,!1,!1)});["capture","download"].forEach(function(t){pc[t]=new Eu(t,4,!1,t,null,!1,!1)});["cols","rows","size","span"].forEach(function(t){pc[t]=new Eu(t,6,!1,t,null,!1,!1)});["rowSpan","start"].forEach(function(t){pc[t]=new Eu(t,5,!1,t.toLowerCase(),null,!1,!1)});var y7=/[\-:]([a-z])/g;function x7(t){return t[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(t){var e=t.replace(y7,x7);pc[e]=new Eu(e,1,!1,t,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(t){var e=t.replace(y7,x7);pc[e]=new Eu(e,1,!1,t,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(t){var e=t.replace(y7,x7);pc[e]=new Eu(e,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(t){pc[t]=new Eu(t,1,!1,t.toLowerCase(),null,!1,!1)});pc.xlinkHref=new Eu("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(t){pc[t]=new Eu(t,1,!1,t.toLowerCase(),null,!0,!0)});function _7(t,e,r,n){var s=pc.hasOwnProperty(e)?pc[e]:null;(s!==null?s.type!==0:n||!(2a||s[c]!==o[a]){var f=` `+s[c].replace(" at new "," at ");return t.displayName&&f.includes("")&&(f=f.replace("",t.displayName)),f}while(1<=c&&0<=a);break}}}finally{nz=!1,Error.prepareStackTrace=r}return(t=t?t.displayName||t.name:"")?Ak(t):""}function QMe(t){switch(t.tag){case 5:return Ak(t.type);case 16:return Ak("Lazy");case 13:return Ak("Suspense");case 19:return Ak("SuspenseList");case 0:case 2:case 15:return t=sz(t.type,!1),t;case 11:return t=sz(t.type.render,!1),t;case 1:return t=sz(t.type,!0),t;default:return""}}function _V(t){if(t==null)return null;if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case P1:return"Fragment";case I1:return"Portal";case gV:return"Profiler";case v7:return"StrictMode";case yV:return"Suspense";case xV:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case Sme:return(t.displayName||"Context")+".Consumer";case wme:return(t._context.displayName||"Context")+".Provider";case b7:var e=t.render;return t=t.displayName,t||(t=e.displayName||e.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case w7:return e=t.displayName||null,e!==null?e:_V(t.type)||"Memo";case Yy:e=t._payload,t=t._init;try{return _V(t(e))}catch{}}return null}function JMe(t){var e=t.type;switch(t.tag){case 24:return"Cache";case 9:return(e.displayName||"Context")+".Consumer";case 10:return(e._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return t=e.render,t=t.displayName||t.name||"",e.displayName||(t!==""?"ForwardRef("+t+")":"ForwardRef");case 7:return"Fragment";case 5:return e;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return _V(e);case 8:return e===v7?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e}return null}function Ox(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function Eme(t){var e=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(e==="checkbox"||e==="radio")}function eDe(t){var e=Eme(t)?"checked":"value",r=Object.getOwnPropertyDescriptor(t.constructor.prototype,e),n=""+t[e];if(!t.hasOwnProperty(e)&&typeof r<"u"&&typeof r.get=="function"&&typeof r.set=="function"){var s=r.get,o=r.set;return Object.defineProperty(t,e,{configurable:!0,get:function(){return s.call(this)},set:function(c){n=""+c,o.call(this,c)}}),Object.defineProperty(t,e,{enumerable:r.enumerable}),{getValue:function(){return n},setValue:function(c){n=""+c},stopTracking:function(){t._valueTracker=null,delete t[e]}}}}function MR(t){t._valueTracker||(t._valueTracker=eDe(t))}function jme(t){if(!t)return!1;var e=t._valueTracker;if(!e)return!0;var r=e.getValue(),n="";return t&&(n=Eme(t)?t.checked?"true":"false":t.value),t=n,t!==r?(e.setValue(t),!0):!1}function aD(t){if(t=t||(typeof document<"u"?document:void 0),typeof t>"u")return null;try{return t.activeElement||t.body}catch{return t.body}}function vV(t,e){var r=e.checked;return yo({},e,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:r??t._wrapperState.initialChecked})}function Pte(t,e){var r=e.defaultValue==null?"":e.defaultValue,n=e.checked!=null?e.checked:e.defaultChecked;r=Ox(e.value!=null?e.value:r),t._wrapperState={initialChecked:n,initialValue:r,controlled:e.type==="checkbox"||e.type==="radio"?e.checked!=null:e.value!=null}}function kme(t,e){e=e.checked,e!=null&&_7(t,"checked",e,!1)}function bV(t,e){kme(t,e);var r=Ox(e.value),n=e.type;if(r!=null)n==="number"?(r===0&&t.value===""||t.value!=r)&&(t.value=""+r):t.value!==""+r&&(t.value=""+r);else if(n==="submit"||n==="reset"){t.removeAttribute("value");return}e.hasOwnProperty("value")?wV(t,e.type,r):e.hasOwnProperty("defaultValue")&&wV(t,e.type,Ox(e.defaultValue)),e.checked==null&&e.defaultChecked!=null&&(t.defaultChecked=!!e.defaultChecked)}function Rte(t,e,r){if(e.hasOwnProperty("value")||e.hasOwnProperty("defaultValue")){var n=e.type;if(!(n!=="submit"&&n!=="reset"||e.value!==void 0&&e.value!==null))return;e=""+t._wrapperState.initialValue,r||e===t.value||(t.value=e),t.defaultValue=e}r=t.name,r!==""&&(t.name=""),t.defaultChecked=!!t._wrapperState.initialChecked,r!==""&&(t.name=r)}function wV(t,e,r){(e!=="number"||aD(t.ownerDocument)!==t)&&(r==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+r&&(t.defaultValue=""+r))}var Nk=Array.isArray;function eS(t,e,r,n){if(t=t.options,e){e={};for(var s=0;s"+e.valueOf().toString()+"",e=DR.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;e.firstChild;)t.appendChild(e.firstChild)}});function EA(t,e){if(e){var r=t.firstChild;if(r&&r===t.lastChild&&r.nodeType===3){r.nodeValue=e;return}}t.textContent=e}var Gk={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},tDe=["Webkit","ms","Moz","O"];Object.keys(Gk).forEach(function(t){tDe.forEach(function(e){e=e+t.charAt(0).toUpperCase()+t.substring(1),Gk[e]=Gk[t]})});function Ime(t,e,r){return e==null||typeof e=="boolean"||e===""?"":r||typeof e!="number"||e===0||Gk.hasOwnProperty(t)&&Gk[t]?(""+e).trim():e+"px"}function Pme(t,e){t=t.style;for(var r in e)if(e.hasOwnProperty(r)){var n=r.indexOf("--")===0,s=Ime(r,e[r],n);r==="float"&&(r="cssFloat"),n?t.setProperty(r,s):t[r]=s}}var rDe=yo({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function EV(t,e){if(e){if(rDe[t]&&(e.children!=null||e.dangerouslySetInnerHTML!=null))throw Error(Yr(137,t));if(e.dangerouslySetInnerHTML!=null){if(e.children!=null)throw Error(Yr(60));if(typeof e.dangerouslySetInnerHTML!="object"||!("__html"in e.dangerouslySetInnerHTML))throw Error(Yr(61))}if(e.style!=null&&typeof e.style!="object")throw Error(Yr(62))}}function jV(t,e){if(t.indexOf("-")===-1)return typeof e.is=="string";switch(t){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var kV=null;function S7(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var AV=null,tS=null,rS=null;function Dte(t){if(t=hC(t)){if(typeof AV!="function")throw Error(Yr(280));var e=t.stateNode;e&&(e=q3(e),AV(t.stateNode,t.type,e))}}function Rme(t){tS?rS?rS.push(t):rS=[t]:tS=t}function Lme(){if(tS){var t=tS,e=rS;if(rS=tS=null,Dte(t),e)for(t=0;t>>=0,t===0?32:31-(fDe(t)/mDe|0)|0}var OR=64,FR=4194304;function Ck(t){switch(t&-t){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return t&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return t}}function uD(t,e){var r=t.pendingLanes;if(r===0)return 0;var n=0,s=t.suspendedLanes,o=t.pingedLanes,c=r&268435455;if(c!==0){var a=c&~s;a!==0?n=Ck(a):(o&=c,o!==0&&(n=Ck(o)))}else c=r&~s,c!==0?n=Ck(c):o!==0&&(n=Ck(o));if(n===0)return 0;if(e!==0&&e!==n&&!(e&s)&&(s=n&-n,o=e&-e,s>=o||s===16&&(o&4194240)!==0))return e;if(n&4&&(n|=r&16),e=t.entangledLanes,e!==0)for(t=t.entanglements,e&=n;0r;r++)e.push(t);return e}function uC(t,e,r){t.pendingLanes|=e,e!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,e=31-If(e),t[e]=r}function xDe(t,e){var r=t.pendingLanes&~e;t.pendingLanes=e,t.suspendedLanes=0,t.pingedLanes=0,t.expiredLanes&=e,t.mutableReadLanes&=e,t.entangledLanes&=e,e=t.entanglements;var n=t.eventTimes;for(t=t.expirationTimes;0=Wk),Gte=" ",Hte=!1;function epe(t,e){switch(t){case"keyup":return HDe.indexOf(e.keyCode)!==-1;case"keydown":return e.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function tpe(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var R1=!1;function KDe(t,e){switch(t){case"compositionend":return tpe(e);case"keypress":return e.which!==32?null:(Hte=!0,Gte);case"textInput":return t=e.data,t===Gte&&Hte?null:t;default:return null}}function YDe(t,e){if(R1)return t==="compositionend"||!I7&&epe(t,e)?(t=Qme(),gM=A7=gx=null,R1=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(e.ctrlKey||e.altKey||e.metaKey)||e.ctrlKey&&e.altKey){if(e.char&&1=e)return{node:r,offset:e-t};t=n}e:{for(;r;){if(r.nextSibling){r=r.nextSibling;break e}r=r.parentNode}r=void 0}r=Zte(r)}}function ipe(t,e){return t&&e?t===e?!0:t&&t.nodeType===3?!1:e&&e.nodeType===3?ipe(t,e.parentNode):"contains"in t?t.contains(e):t.compareDocumentPosition?!!(t.compareDocumentPosition(e)&16):!1:!1}function ape(){for(var t=window,e=aD();e instanceof t.HTMLIFrameElement;){try{var r=typeof e.contentWindow.location.href=="string"}catch{r=!1}if(r)t=e.contentWindow;else break;e=aD(t.document)}return e}function P7(t){var e=t&&t.nodeName&&t.nodeName.toLowerCase();return e&&(e==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||e==="textarea"||t.contentEditable==="true")}function sOe(t){var e=ape(),r=t.focusedElem,n=t.selectionRange;if(e!==r&&r&&r.ownerDocument&&ipe(r.ownerDocument.documentElement,r)){if(n!==null&&P7(r)){if(e=n.start,t=n.end,t===void 0&&(t=e),"selectionStart"in r)r.selectionStart=e,r.selectionEnd=Math.min(t,r.value.length);else if(t=(e=r.ownerDocument||document)&&e.defaultView||window,t.getSelection){t=t.getSelection();var s=r.textContent.length,o=Math.min(n.start,s);n=n.end===void 0?o:Math.min(n.end,s),!t.extend&&o>n&&(s=n,n=o,o=s),s=Xte(r,o);var c=Xte(r,n);s&&c&&(t.rangeCount!==1||t.anchorNode!==s.node||t.anchorOffset!==s.offset||t.focusNode!==c.node||t.focusOffset!==c.offset)&&(e=e.createRange(),e.setStart(s.node,s.offset),t.removeAllRanges(),o>n?(t.addRange(e),t.extend(c.node,c.offset)):(e.setEnd(c.node,c.offset),t.addRange(e)))}}for(e=[],t=r;t=t.parentNode;)t.nodeType===1&&e.push({element:t,left:t.scrollLeft,top:t.scrollTop});for(typeof r.focus=="function"&&r.focus(),r=0;r=document.documentMode,L1=null,LV=null,Yk=null,MV=!1;function Qte(t,e,r){var n=r.window===r?r.document:r.nodeType===9?r:r.ownerDocument;MV||L1==null||L1!==aD(n)||(n=L1,"selectionStart"in n&&P7(n)?n={start:n.selectionStart,end:n.selectionEnd}:(n=(n.ownerDocument&&n.ownerDocument.defaultView||window).getSelection(),n={anchorNode:n.anchorNode,anchorOffset:n.anchorOffset,focusNode:n.focusNode,focusOffset:n.focusOffset}),Yk&&IA(Yk,n)||(Yk=n,n=fD(LV,"onSelect"),0O1||(t.current=zV[O1],zV[O1]=null,O1--)}function Na(t,e){O1++,zV[O1]=t.current,t.current=e}var Fx={},Oc=i0(Fx),Yu=i0(!1),Pv=Fx;function FS(t,e){var r=t.type.contextTypes;if(!r)return Fx;var n=t.stateNode;if(n&&n.__reactInternalMemoizedUnmaskedChildContext===e)return n.__reactInternalMemoizedMaskedChildContext;var s={},o;for(o in r)s[o]=e[o];return n&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=e,t.__reactInternalMemoizedMaskedChildContext=s),s}function Zu(t){return t=t.childContextTypes,t!=null}function pD(){Ga(Yu),Ga(Oc)}function ire(t,e,r){if(Oc.current!==Fx)throw Error(Yr(168));Na(Oc,e),Na(Yu,r)}function ppe(t,e,r){var n=t.stateNode;if(e=e.childContextTypes,typeof n.getChildContext!="function")return r;n=n.getChildContext();for(var s in n)if(!(s in e))throw Error(Yr(108,JMe(t)||"Unknown",s));return yo({},r,n)}function gD(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||Fx,Pv=Oc.current,Na(Oc,t),Na(Yu,Yu.current),!0}function are(t,e,r){var n=t.stateNode;if(!n)throw Error(Yr(169));r?(t=ppe(t,e,Pv),n.__reactInternalMemoizedMergedChildContext=t,Ga(Yu),Ga(Oc),Na(Oc,t)):Ga(Yu),Na(Yu,r)}var ig=null,G3=!1,xz=!1;function gpe(t){ig===null?ig=[t]:ig.push(t)}function gOe(t){G3=!0,gpe(t)}function a0(){if(!xz&&ig!==null){xz=!0;var t=0,e=ta;try{var r=ig;for(ta=1;t>=c,s-=c,dg=1<<32-If(e)+s|r<Q?(J=K,K=null):J=K.sibling;var ee=w(M,K,B[Q],U);if(ee===null){K===null&&(K=J);break}t&&K&&ee.alternate===null&&e(M,K),D=o(ee,D,Q),H===null?q=ee:H.sibling=ee,H=ee,K=J}if(Q===B.length)return r(M,K),Qa&&V_(M,Q),q;if(K===null){for(;QQ?(J=K,K=null):J=K.sibling;var oe=w(M,K,ee.value,U);if(oe===null){K===null&&(K=J);break}t&&K&&oe.alternate===null&&e(M,K),D=o(oe,D,Q),H===null?q=oe:H.sibling=oe,H=oe,K=J}if(ee.done)return r(M,K),Qa&&V_(M,Q),q;if(K===null){for(;!ee.done;Q++,ee=B.next())ee=_(M,ee.value,U),ee!==null&&(D=o(ee,D,Q),H===null?q=ee:H.sibling=ee,H=ee);return Qa&&V_(M,Q),q}for(K=n(M,K);!ee.done;Q++,ee=B.next())ee=E(K,M,Q,ee.value,U),ee!==null&&(t&&ee.alternate!==null&&K.delete(ee.key===null?Q:ee.key),D=o(ee,D,Q),H===null?q=ee:H.sibling=ee,H=ee);return t&&K.forEach(function(de){return e(M,de)}),Qa&&V_(M,Q),q}function I(M,D,B,U){if(typeof B=="object"&&B!==null&&B.type===P1&&B.key===null&&(B=B.props.children),typeof B=="object"&&B!==null){switch(B.$$typeof){case LR:e:{for(var q=B.key,H=D;H!==null;){if(H.key===q){if(q=B.type,q===P1){if(H.tag===7){r(M,H.sibling),D=s(H,B.props.children),D.return=M,M=D;break e}}else if(H.elementType===q||typeof q=="object"&&q!==null&&q.$$typeof===Yy&&cre(q)===H.type){r(M,H.sibling),D=s(H,B.props),D.ref=G2(M,H,B),D.return=M,M=D;break e}r(M,H);break}else e(M,H);H=H.sibling}B.type===P1?(D=wv(B.props.children,M.mode,U,B.key),D.return=M,M=D):(U=TM(B.type,B.key,B.props,null,M.mode,U),U.ref=G2(M,D,B),U.return=M,M=U)}return c(M);case I1:e:{for(H=B.key;D!==null;){if(D.key===H)if(D.tag===4&&D.stateNode.containerInfo===B.containerInfo&&D.stateNode.implementation===B.implementation){r(M,D.sibling),D=s(D,B.children||[]),D.return=M,M=D;break e}else{r(M,D);break}else e(M,D);D=D.sibling}D=jz(B,M.mode,U),D.return=M,M=D}return c(M);case Yy:return H=B._init,I(M,D,H(B._payload),U)}if(Nk(B))return A(M,D,B,U);if($2(B))return C(M,D,B,U);GR(M,B)}return typeof B=="string"&&B!==""||typeof B=="number"?(B=""+B,D!==null&&D.tag===6?(r(M,D.sibling),D=s(D,B),D.return=M,M=D):(r(M,D),D=Ez(B,M.mode,U),D.return=M,M=D),c(M)):r(M,D)}return I}var $S=vpe(!0),bpe=vpe(!1),_D=i0(null),vD=null,$1=null,D7=null;function O7(){D7=$1=vD=null}function F7(t){var e=_D.current;Ga(_D),t._currentValue=e}function qV(t,e,r){for(;t!==null;){var n=t.alternate;if((t.childLanes&e)!==e?(t.childLanes|=e,n!==null&&(n.childLanes|=e)):n!==null&&(n.childLanes&e)!==e&&(n.childLanes|=e),t===r)break;t=t.return}}function sS(t,e){vD=t,D7=$1=null,t=t.dependencies,t!==null&&t.firstContext!==null&&(t.lanes&e&&(Hu=!0),t.firstContext=null)}function kh(t){var e=t._currentValue;if(D7!==t)if(t={context:t,memoizedValue:e,next:null},$1===null){if(vD===null)throw Error(Yr(308));$1=t,vD.dependencies={lanes:0,firstContext:t}}else $1=$1.next=t;return e}var rv=null;function B7(t){rv===null?rv=[t]:rv.push(t)}function wpe(t,e,r,n){var s=e.interleaved;return s===null?(r.next=r,B7(e)):(r.next=s.next,s.next=r),e.interleaved=r,Eg(t,n)}function Eg(t,e){t.lanes|=e;var r=t.alternate;for(r!==null&&(r.lanes|=e),r=t,t=t.return;t!==null;)t.childLanes|=e,r=t.alternate,r!==null&&(r.childLanes|=e),r=t,t=t.return;return r.tag===3?r.stateNode:null}var Zy=!1;function $7(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Spe(t,e){t=t.updateQueue,e.updateQueue===t&&(e.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,effects:t.effects})}function gg(t,e){return{eventTime:t,lane:e,tag:0,payload:null,callback:null,next:null}}function jx(t,e,r){var n=t.updateQueue;if(n===null)return null;if(n=n.shared,Ni&2){var s=n.pending;return s===null?e.next=e:(e.next=s.next,s.next=e),n.pending=e,Eg(t,r)}return s=n.interleaved,s===null?(e.next=e,B7(n)):(e.next=s.next,s.next=e),n.interleaved=e,Eg(t,r)}function xM(t,e,r){if(e=e.updateQueue,e!==null&&(e=e.shared,(r&4194240)!==0)){var n=e.lanes;n&=t.pendingLanes,r|=n,e.lanes=r,E7(t,r)}}function ure(t,e){var r=t.updateQueue,n=t.alternate;if(n!==null&&(n=n.updateQueue,r===n)){var s=null,o=null;if(r=r.firstBaseUpdate,r!==null){do{var c={eventTime:r.eventTime,lane:r.lane,tag:r.tag,payload:r.payload,callback:r.callback,next:null};o===null?s=o=c:o=o.next=c,r=r.next}while(r!==null);o===null?s=o=e:o=o.next=e}else s=o=e;r={baseState:n.baseState,firstBaseUpdate:s,lastBaseUpdate:o,shared:n.shared,effects:n.effects},t.updateQueue=r;return}t=r.lastBaseUpdate,t===null?r.firstBaseUpdate=e:t.next=e,r.lastBaseUpdate=e}function bD(t,e,r,n){var s=t.updateQueue;Zy=!1;var o=s.firstBaseUpdate,c=s.lastBaseUpdate,a=s.shared.pending;if(a!==null){s.shared.pending=null;var f=a,m=f.next;f.next=null,c===null?o=m:c.next=m,c=f;var y=t.alternate;y!==null&&(y=y.updateQueue,a=y.lastBaseUpdate,a!==c&&(a===null?y.firstBaseUpdate=m:a.next=m,y.lastBaseUpdate=f))}if(o!==null){var _=s.baseState;c=0,y=m=f=null,a=o;do{var w=a.lane,E=a.eventTime;if((n&w)===w){y!==null&&(y=y.next={eventTime:E,lane:0,tag:a.tag,payload:a.payload,callback:a.callback,next:null});e:{var A=t,C=a;switch(w=e,E=r,C.tag){case 1:if(A=C.payload,typeof A=="function"){_=A.call(E,_,w);break e}_=A;break e;case 3:A.flags=A.flags&-65537|128;case 0:if(A=C.payload,w=typeof A=="function"?A.call(E,_,w):A,w==null)break e;_=yo({},_,w);break e;case 2:Zy=!0}}a.callback!==null&&a.lane!==0&&(t.flags|=64,w=s.effects,w===null?s.effects=[a]:w.push(a))}else E={eventTime:E,lane:w,tag:a.tag,payload:a.payload,callback:a.callback,next:null},y===null?(m=y=E,f=_):y=y.next=E,c|=w;if(a=a.next,a===null){if(a=s.shared.pending,a===null)break;w=a,a=w.next,w.next=null,s.lastBaseUpdate=w,s.shared.pending=null}}while(!0);if(y===null&&(f=_),s.baseState=f,s.firstBaseUpdate=m,s.lastBaseUpdate=y,e=s.shared.interleaved,e!==null){s=e;do c|=s.lane,s=s.next;while(s!==e)}else o===null&&(s.shared.lanes=0);Mv|=c,t.lanes=c,t.memoizedState=_}}function dre(t,e,r){if(t=e.effects,e.effects=null,t!==null)for(e=0;er?r:4,t(!0);var n=vz.transition;vz.transition={};try{t(!1),e()}finally{ta=r,vz.transition=n}}function $pe(){return Ah().memoizedState}function vOe(t,e,r){var n=Ax(t);if(r={lane:n,action:r,hasEagerState:!1,eagerState:null,next:null},zpe(t))Upe(e,r);else if(r=wpe(t,e,r,n),r!==null){var s=bu();Pf(r,t,n,s),Vpe(r,e,n)}}function bOe(t,e,r){var n=Ax(t),s={lane:n,action:r,hasEagerState:!1,eagerState:null,next:null};if(zpe(t))Upe(e,s);else{var o=t.alternate;if(t.lanes===0&&(o===null||o.lanes===0)&&(o=e.lastRenderedReducer,o!==null))try{var c=e.lastRenderedState,a=o(c,r);if(s.hasEagerState=!0,s.eagerState=a,Ff(a,c)){var f=e.interleaved;f===null?(s.next=s,B7(e)):(s.next=f.next,f.next=s),e.interleaved=s;return}}catch{}finally{}r=wpe(t,e,s,n),r!==null&&(s=bu(),Pf(r,t,n,s),Vpe(r,e,n))}}function zpe(t){var e=t.alternate;return t===po||e!==null&&e===po}function Upe(t,e){Zk=SD=!0;var r=t.pending;r===null?e.next=e:(e.next=r.next,r.next=e),t.pending=e}function Vpe(t,e,r){if(r&4194240){var n=e.lanes;n&=t.pendingLanes,r|=n,e.lanes=r,E7(t,r)}}var TD={readContext:kh,useCallback:kc,useContext:kc,useEffect:kc,useImperativeHandle:kc,useInsertionEffect:kc,useLayoutEffect:kc,useMemo:kc,useReducer:kc,useRef:kc,useState:kc,useDebugValue:kc,useDeferredValue:kc,useTransition:kc,useMutableSource:kc,useSyncExternalStore:kc,useId:kc,unstable_isNewReconciler:!1},wOe={readContext:kh,useCallback:function(t,e){return Tm().memoizedState=[t,e===void 0?null:e],t},useContext:kh,useEffect:fre,useImperativeHandle:function(t,e,r){return r=r!=null?r.concat([t]):null,vM(4194308,4,Mpe.bind(null,e,t),r)},useLayoutEffect:function(t,e){return vM(4194308,4,t,e)},useInsertionEffect:function(t,e){return vM(4,2,t,e)},useMemo:function(t,e){var r=Tm();return e=e===void 0?null:e,t=t(),r.memoizedState=[t,e],t},useReducer:function(t,e,r){var n=Tm();return e=r!==void 0?r(e):e,n.memoizedState=n.baseState=e,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:e},n.queue=t,t=t.dispatch=vOe.bind(null,po,t),[n.memoizedState,t]},useRef:function(t){var e=Tm();return t={current:t},e.memoizedState=t},useState:hre,useDebugValue:K7,useDeferredValue:function(t){return Tm().memoizedState=t},useTransition:function(){var t=hre(!1),e=t[0];return t=_Oe.bind(null,t[1]),Tm().memoizedState=t,[e,t]},useMutableSource:function(){},useSyncExternalStore:function(t,e,r){var n=po,s=Tm();if(Qa){if(r===void 0)throw Error(Yr(407));r=r()}else{if(r=e(),Hl===null)throw Error(Yr(349));Lv&30||kpe(n,e,r)}s.memoizedState=r;var o={value:r,getSnapshot:e};return s.queue=o,fre(Npe.bind(null,n,o,t),[t]),n.flags|=2048,BA(9,Ape.bind(null,n,o,r,e),void 0,null),r},useId:function(){var t=Tm(),e=Hl.identifierPrefix;if(Qa){var r=hg,n=dg;r=(n&~(1<<32-If(n)-1)).toString(32)+r,e=":"+e+"R"+r,r=OA++,0<\/script>",t=t.removeChild(t.firstChild)):typeof n.is=="string"?t=c.createElement(r,{is:n.is}):(t=c.createElement(r),r==="select"&&(c=t,n.multiple?c.multiple=!0:n.size&&(c.size=n.size))):t=c.createElementNS(t,r),t[Pm]=e,t[LA]=n,Jpe(t,e,!1,!1),e.stateNode=t;e:{switch(c=jV(r,n),r){case"dialog":za("cancel",t),za("close",t),s=n;break;case"iframe":case"object":case"embed":za("load",t),s=n;break;case"video":case"audio":for(s=0;sVS&&(e.flags|=128,n=!0,H2(o,!1),e.lanes=4194304)}else{if(!n)if(t=wD(c),t!==null){if(e.flags|=128,n=!0,r=t.updateQueue,r!==null&&(e.updateQueue=r,e.flags|=4),H2(o,!0),o.tail===null&&o.tailMode==="hidden"&&!c.alternate&&!Qa)return Ac(e),null}else 2*Fo()-o.renderingStartTime>VS&&r!==1073741824&&(e.flags|=128,n=!0,H2(o,!1),e.lanes=4194304);o.isBackwards?(c.sibling=e.child,e.child=c):(r=o.last,r!==null?r.sibling=c:e.child=c,o.last=c)}return o.tail!==null?(e=o.tail,o.rendering=e,o.tail=e.sibling,o.renderingStartTime=Fo(),e.sibling=null,r=uo.current,Na(uo,n?r&1|2:r&1),e):(Ac(e),null);case 22:case 23:return eH(),n=e.memoizedState!==null,t!==null&&t.memoizedState!==null!==n&&(e.flags|=8192),n&&e.mode&1?wd&1073741824&&(Ac(e),e.subtreeFlags&6&&(e.flags|=8192)):Ac(e),null;case 24:return null;case 25:return null}throw Error(Yr(156,e.tag))}function COe(t,e){switch(L7(e),e.tag){case 1:return Zu(e.type)&&pD(),t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 3:return zS(),Ga(Yu),Ga(Oc),V7(),t=e.flags,t&65536&&!(t&128)?(e.flags=t&-65537|128,e):null;case 5:return U7(e),null;case 13:if(Ga(uo),t=e.memoizedState,t!==null&&t.dehydrated!==null){if(e.alternate===null)throw Error(Yr(340));BS()}return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 19:return Ga(uo),null;case 4:return zS(),null;case 10:return F7(e.type._context),null;case 22:case 23:return eH(),null;case 24:return null;default:return null}}var WR=!1,Rc=!1,IOe=typeof WeakSet=="function"?WeakSet:Set,In=null;function z1(t,e){var r=t.ref;if(r!==null)if(typeof r=="function")try{r(null)}catch(n){Ao(t,e,n)}else r.current=null}function JV(t,e,r){try{r()}catch(n){Ao(t,e,n)}}var Tre=!1;function POe(t,e){if(DV=dD,t=ape(),P7(t)){if("selectionStart"in t)var r={start:t.selectionStart,end:t.selectionEnd};else e:{r=(r=t.ownerDocument)&&r.defaultView||window;var n=r.getSelection&&r.getSelection();if(n&&n.rangeCount!==0){r=n.anchorNode;var s=n.anchorOffset,o=n.focusNode;n=n.focusOffset;try{r.nodeType,o.nodeType}catch{r=null;break e}var c=0,a=-1,f=-1,m=0,y=0,_=t,w=null;t:for(;;){for(var E;_!==r||s!==0&&_.nodeType!==3||(a=c+s),_!==o||n!==0&&_.nodeType!==3||(f=c+n),_.nodeType===3&&(c+=_.nodeValue.length),(E=_.firstChild)!==null;)w=_,_=E;for(;;){if(_===t)break t;if(w===r&&++m===s&&(a=c),w===o&&++y===n&&(f=c),(E=_.nextSibling)!==null)break;_=w,w=_.parentNode}_=E}r=a===-1||f===-1?null:{start:a,end:f}}else r=null}r=r||{start:0,end:0}}else r=null;for(OV={focusedElem:t,selectionRange:r},dD=!1,In=e;In!==null;)if(e=In,t=e.child,(e.subtreeFlags&1028)!==0&&t!==null)t.return=e,In=t;else for(;In!==null;){e=In;try{var A=e.alternate;if(e.flags&1024)switch(e.tag){case 0:case 11:case 15:break;case 1:if(A!==null){var C=A.memoizedProps,I=A.memoizedState,M=e.stateNode,D=M.getSnapshotBeforeUpdate(e.elementType===e.type?C:hf(e.type,C),I);M.__reactInternalSnapshotBeforeUpdate=D}break;case 3:var B=e.stateNode.containerInfo;B.nodeType===1?B.textContent="":B.nodeType===9&&B.documentElement&&B.removeChild(B.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(Yr(163))}}catch(U){Ao(e,e.return,U)}if(t=e.sibling,t!==null){t.return=e.return,In=t;break}In=e.return}return A=Tre,Tre=!1,A}function Xk(t,e,r){var n=e.updateQueue;if(n=n!==null?n.lastEffect:null,n!==null){var s=n=n.next;do{if((s.tag&t)===t){var o=s.destroy;s.destroy=void 0,o!==void 0&&JV(e,r,o)}s=s.next}while(s!==n)}}function K3(t,e){if(e=e.updateQueue,e=e!==null?e.lastEffect:null,e!==null){var r=e=e.next;do{if((r.tag&t)===t){var n=r.create;r.destroy=n()}r=r.next}while(r!==e)}}function e8(t){var e=t.ref;if(e!==null){var r=t.stateNode;switch(t.tag){case 5:t=r;break;default:t=r}typeof e=="function"?e(t):e.current=t}}function rge(t){var e=t.alternate;e!==null&&(t.alternate=null,rge(e)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(e=t.stateNode,e!==null&&(delete e[Pm],delete e[LA],delete e[$V],delete e[mOe],delete e[pOe])),t.stateNode=null,t.return=null,t.dependencies=null,t.memoizedProps=null,t.memoizedState=null,t.pendingProps=null,t.stateNode=null,t.updateQueue=null}function nge(t){return t.tag===5||t.tag===3||t.tag===4}function Ere(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||nge(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function t8(t,e,r){var n=t.tag;if(n===5||n===6)t=t.stateNode,e?r.nodeType===8?r.parentNode.insertBefore(t,e):r.insertBefore(t,e):(r.nodeType===8?(e=r.parentNode,e.insertBefore(t,r)):(e=r,e.appendChild(t)),r=r._reactRootContainer,r!=null||e.onclick!==null||(e.onclick=mD));else if(n!==4&&(t=t.child,t!==null))for(t8(t,e,r),t=t.sibling;t!==null;)t8(t,e,r),t=t.sibling}function r8(t,e,r){var n=t.tag;if(n===5||n===6)t=t.stateNode,e?r.insertBefore(t,e):r.appendChild(t);else if(n!==4&&(t=t.child,t!==null))for(r8(t,e,r),t=t.sibling;t!==null;)r8(t,e,r),t=t.sibling}var tc=null,pf=!1;function Py(t,e,r){for(r=r.child;r!==null;)sge(t,e,r),r=r.sibling}function sge(t,e,r){if(zm&&typeof zm.onCommitFiberUnmount=="function")try{zm.onCommitFiberUnmount($3,r)}catch{}switch(r.tag){case 5:Rc||z1(r,e);case 6:var n=tc,s=pf;tc=null,Py(t,e,r),tc=n,pf=s,tc!==null&&(pf?(t=tc,r=r.stateNode,t.nodeType===8?t.parentNode.removeChild(r):t.removeChild(r)):tc.removeChild(r.stateNode));break;case 18:tc!==null&&(pf?(t=tc,r=r.stateNode,t.nodeType===8?yz(t.parentNode,r):t.nodeType===1&&yz(t,r),NA(t)):yz(tc,r.stateNode));break;case 4:n=tc,s=pf,tc=r.stateNode.containerInfo,pf=!0,Py(t,e,r),tc=n,pf=s;break;case 0:case 11:case 14:case 15:if(!Rc&&(n=r.updateQueue,n!==null&&(n=n.lastEffect,n!==null))){s=n=n.next;do{var o=s,c=o.destroy;o=o.tag,c!==void 0&&(o&2||o&4)&&JV(r,e,c),s=s.next}while(s!==n)}Py(t,e,r);break;case 1:if(!Rc&&(z1(r,e),n=r.stateNode,typeof n.componentWillUnmount=="function"))try{n.props=r.memoizedProps,n.state=r.memoizedState,n.componentWillUnmount()}catch(a){Ao(r,e,a)}Py(t,e,r);break;case 21:Py(t,e,r);break;case 22:r.mode&1?(Rc=(n=Rc)||r.memoizedState!==null,Py(t,e,r),Rc=n):Py(t,e,r);break;default:Py(t,e,r)}}function jre(t){var e=t.updateQueue;if(e!==null){t.updateQueue=null;var r=t.stateNode;r===null&&(r=t.stateNode=new IOe),e.forEach(function(n){var s=zOe.bind(null,t,n);r.has(n)||(r.add(n),n.then(s,s))})}}function rf(t,e){var r=e.deletions;if(r!==null)for(var n=0;ns&&(s=c),n&=~o}if(n=s,n=Fo()-n,n=(120>n?120:480>n?480:1080>n?1080:1920>n?1920:3e3>n?3e3:4320>n?4320:1960*LOe(n/1960))-n,10t?16:t,yx===null)var n=!1;else{if(t=yx,yx=null,kD=0,Ni&6)throw Error(Yr(331));var s=Ni;for(Ni|=4,In=t.current;In!==null;){var o=In,c=o.child;if(In.flags&16){var a=o.deletions;if(a!==null){for(var f=0;fFo()-Q7?bv(t,0):X7|=r),Xu(t,e)}function hge(t,e){e===0&&(t.mode&1?(e=FR,FR<<=1,!(FR&130023424)&&(FR=4194304)):e=1);var r=bu();t=Eg(t,e),t!==null&&(uC(t,e,r),Xu(t,r))}function $Oe(t){var e=t.memoizedState,r=0;e!==null&&(r=e.retryLane),hge(t,r)}function zOe(t,e){var r=0;switch(t.tag){case 13:var n=t.stateNode,s=t.memoizedState;s!==null&&(r=s.retryLane);break;case 19:n=t.stateNode;break;default:throw Error(Yr(314))}n!==null&&n.delete(e),hge(t,r)}var fge;fge=function(t,e,r){if(t!==null)if(t.memoizedProps!==e.pendingProps||Yu.current)Hu=!0;else{if(!(t.lanes&r)&&!(e.flags&128))return Hu=!1,AOe(t,e,r);Hu=!!(t.flags&131072)}else Hu=!1,Qa&&e.flags&1048576&&ype(e,xD,e.index);switch(e.lanes=0,e.tag){case 2:var n=e.type;bM(t,e),t=e.pendingProps;var s=FS(e,Oc.current);sS(e,r),s=G7(null,e,n,t,s,r);var o=H7();return e.flags|=1,typeof s=="object"&&s!==null&&typeof s.render=="function"&&s.$$typeof===void 0?(e.tag=1,e.memoizedState=null,e.updateQueue=null,Zu(n)?(o=!0,gD(e)):o=!1,e.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,$7(e),s.updater=W3,e.stateNode=s,s._reactInternals=e,HV(e,n,t,r),e=YV(null,e,n,!0,o,r)):(e.tag=0,Qa&&o&&R7(e),uu(null,e,s,r),e=e.child),e;case 16:n=e.elementType;e:{switch(bM(t,e),t=e.pendingProps,s=n._init,n=s(n._payload),e.type=n,s=e.tag=VOe(n),t=hf(n,t),s){case 0:e=KV(null,e,n,t,r);break e;case 1:e=bre(null,e,n,t,r);break e;case 11:e=_re(null,e,n,t,r);break e;case 14:e=vre(null,e,n,hf(n.type,t),r);break e}throw Error(Yr(306,n,""))}return e;case 0:return n=e.type,s=e.pendingProps,s=e.elementType===n?s:hf(n,s),KV(t,e,n,s,r);case 1:return n=e.type,s=e.pendingProps,s=e.elementType===n?s:hf(n,s),bre(t,e,n,s,r);case 3:e:{if(Zpe(e),t===null)throw Error(Yr(387));n=e.pendingProps,o=e.memoizedState,s=o.element,Spe(t,e),bD(e,n,null,r);var c=e.memoizedState;if(n=c.element,o.isDehydrated)if(o={element:n,isDehydrated:!1,cache:c.cache,pendingSuspenseBoundaries:c.pendingSuspenseBoundaries,transitions:c.transitions},e.updateQueue.baseState=o,e.memoizedState=o,e.flags&256){s=US(Error(Yr(423)),e),e=wre(t,e,n,r,s);break e}else if(n!==s){s=US(Error(Yr(424)),e),e=wre(t,e,n,r,s);break e}else for(Ad=Ex(e.stateNode.containerInfo.firstChild),Id=e,Qa=!0,_f=null,r=bpe(e,null,n,r),e.child=r;r;)r.flags=r.flags&-3|4096,r=r.sibling;else{if(BS(),n===s){e=jg(t,e,r);break e}uu(t,e,n,r)}e=e.child}return e;case 5:return Tpe(e),t===null&&VV(e),n=e.type,s=e.pendingProps,o=t!==null?t.memoizedProps:null,c=s.children,FV(n,s)?c=null:o!==null&&FV(n,o)&&(e.flags|=32),Ype(t,e),uu(t,e,c,r),e.child;case 6:return t===null&&VV(e),null;case 13:return Xpe(t,e,r);case 4:return z7(e,e.stateNode.containerInfo),n=e.pendingProps,t===null?e.child=$S(e,null,n,r):uu(t,e,n,r),e.child;case 11:return n=e.type,s=e.pendingProps,s=e.elementType===n?s:hf(n,s),_re(t,e,n,s,r);case 7:return uu(t,e,e.pendingProps,r),e.child;case 8:return uu(t,e,e.pendingProps.children,r),e.child;case 12:return uu(t,e,e.pendingProps.children,r),e.child;case 10:e:{if(n=e.type._context,s=e.pendingProps,o=e.memoizedProps,c=s.value,Na(_D,n._currentValue),n._currentValue=c,o!==null)if(Ff(o.value,c)){if(o.children===s.children&&!Yu.current){e=jg(t,e,r);break e}}else for(o=e.child,o!==null&&(o.return=e);o!==null;){var a=o.dependencies;if(a!==null){c=o.child;for(var f=a.firstContext;f!==null;){if(f.context===n){if(o.tag===1){f=gg(-1,r&-r),f.tag=2;var m=o.updateQueue;if(m!==null){m=m.shared;var y=m.pending;y===null?f.next=f:(f.next=y.next,y.next=f),m.pending=f}}o.lanes|=r,f=o.alternate,f!==null&&(f.lanes|=r),qV(o.return,r,e),a.lanes|=r;break}f=f.next}}else if(o.tag===10)c=o.type===e.type?null:o.child;else if(o.tag===18){if(c=o.return,c===null)throw Error(Yr(341));c.lanes|=r,a=c.alternate,a!==null&&(a.lanes|=r),qV(c,r,e),c=o.sibling}else c=o.child;if(c!==null)c.return=o;else for(c=o;c!==null;){if(c===e){c=null;break}if(o=c.sibling,o!==null){o.return=c.return,c=o;break}c=c.return}o=c}uu(t,e,s.children,r),e=e.child}return e;case 9:return s=e.type,n=e.pendingProps.children,sS(e,r),s=kh(s),n=n(s),e.flags|=1,uu(t,e,n,r),e.child;case 14:return n=e.type,s=hf(n,e.pendingProps),s=hf(n.type,s),vre(t,e,n,s,r);case 15:return Wpe(t,e,e.type,e.pendingProps,r);case 17:return n=e.type,s=e.pendingProps,s=e.elementType===n?s:hf(n,s),bM(t,e),e.tag=1,Zu(n)?(t=!0,gD(e)):t=!1,sS(e,r),qpe(e,n,s),HV(e,n,s,r),YV(null,e,n,!0,t,r);case 19:return Qpe(t,e,r);case 22:return Kpe(t,e,r)}throw Error(Yr(156,e.tag))};function mge(t,e){return zme(t,e)}function UOe(t,e,r,n){this.tag=t,this.key=r,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=e,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=n,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function _h(t,e,r,n){return new UOe(t,e,r,n)}function rH(t){return t=t.prototype,!(!t||!t.isReactComponent)}function VOe(t){if(typeof t=="function")return rH(t)?1:0;if(t!=null){if(t=t.$$typeof,t===b7)return 11;if(t===w7)return 14}return 2}function Nx(t,e){var r=t.alternate;return r===null?(r=_h(t.tag,e,t.key,t.mode),r.elementType=t.elementType,r.type=t.type,r.stateNode=t.stateNode,r.alternate=t,t.alternate=r):(r.pendingProps=e,r.type=t.type,r.flags=0,r.subtreeFlags=0,r.deletions=null),r.flags=t.flags&14680064,r.childLanes=t.childLanes,r.lanes=t.lanes,r.child=t.child,r.memoizedProps=t.memoizedProps,r.memoizedState=t.memoizedState,r.updateQueue=t.updateQueue,e=t.dependencies,r.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext},r.sibling=t.sibling,r.index=t.index,r.ref=t.ref,r}function TM(t,e,r,n,s,o){var c=2;if(n=t,typeof t=="function")rH(t)&&(c=1);else if(typeof t=="string")c=5;else e:switch(t){case P1:return wv(r.children,s,o,e);case v7:c=8,s|=8;break;case gV:return t=_h(12,r,e,s|2),t.elementType=gV,t.lanes=o,t;case yV:return t=_h(13,r,e,s),t.elementType=yV,t.lanes=o,t;case xV:return t=_h(19,r,e,s),t.elementType=xV,t.lanes=o,t;case Tme:return Z3(r,s,o,e);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case wme:c=10;break e;case Sme:c=9;break e;case b7:c=11;break e;case w7:c=14;break e;case Yy:c=16,n=null;break e}throw Error(Yr(130,t==null?t:typeof t,""))}return e=_h(c,r,e,s),e.elementType=t,e.type=n,e.lanes=o,e}function wv(t,e,r,n){return t=_h(7,t,n,e),t.lanes=r,t}function Z3(t,e,r,n){return t=_h(22,t,n,e),t.elementType=Tme,t.lanes=r,t.stateNode={isHidden:!1},t}function Ez(t,e,r){return t=_h(6,t,null,e),t.lanes=r,t}function jz(t,e,r){return e=_h(4,t.children!==null?t.children:[],t.key,e),e.lanes=r,e.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},e}function qOe(t,e,r,n,s){this.tag=e,this.containerInfo=t,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=az(0),this.expirationTimes=az(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=az(0),this.identifierPrefix=n,this.onRecoverableError=s,this.mutableSourceEagerHydrationData=null}function nH(t,e,r,n,s,o,c,a,f){return t=new qOe(t,e,r,a,f),e===1?(e=1,o===!0&&(e|=8)):e=0,o=_h(3,null,null,e),t.current=o,o.stateNode=t,o.memoizedState={element:n,isDehydrated:r,cache:null,transitions:null,pendingSuspenseBoundaries:null},$7(o),t}function GOe(t,e,r){var n=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(xge)}catch(t){console.error(t)}}xge(),xme.exports=zd;var sp=xme.exports;const _ge=bi(sp);var vge,Lre=sp;vge=Lre.createRoot,Lre.hydrateRoot;const Mre="levelup:chunk-reload";function ZOe(t){return!!(t&&/Failed to fetch dynamically imported module|Importing a module script failed|error loading dynamically imported module|Unable to preload CSS/i.test(t))}function XOe(t,e,r){if(!ZOe(t))return!1;try{if(e.getItem(Mre))return!1;e.setItem(Mre,"1")}catch{return!1}return r(),!0}function QOe(t,e){const r=t.payload,n=r instanceof Error?r.message:typeof r=="string"?r:void 0;e(n)}const JOe="modulepreload",e3e=function(t){return"/"+t},Dre={},Oe=function(e,r,n){let s=Promise.resolve();if(r&&r.length>0){document.getElementsByTagName("link");const c=document.querySelector("meta[property=csp-nonce]"),a=(c==null?void 0:c.nonce)||(c==null?void 0:c.getAttribute("nonce"));s=Promise.allSettled(r.map(f=>{if(f=e3e(f),f in Dre)return;Dre[f]=!0;const m=f.endsWith(".css"),y=m?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${y}`))return;const _=document.createElement("link");if(_.rel=m?"stylesheet":JOe,m||(_.as="script"),_.crossOrigin="",_.href=f,a&&_.setAttribute("nonce",a),document.head.appendChild(_),m)return new Promise((w,E)=>{_.addEventListener("load",w),_.addEventListener("error",()=>E(new Error(`Unable to preload CSS for ${f}`)))})}))}function o(c){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=c,window.dispatchEvent(a),!a.defaultPrevented)throw c}return s.then(c=>{for(const a of c||[])a.status==="rejected"&&o(a.reason);return e().catch(o)})},t3e=new Set(["localhost","relevelup.com","thelocalmove.com","www.thelocalmove.com"]),r3e=t=>t.toLowerCase().replace(/:\d+$/,"").replace(/^www\./,"");function n3e(t){return!!(t==="localhost"||t.endsWith(".localhost")||/^\d{1,3}(\.\d{1,3}){3}$/.test(t)||t.endsWith(".lovable.app")||t.endsWith(".lovableproject.com")||t.endsWith(".lovable.dev")||t.endsWith(".vercel.app")||t==="relevelup.com"||t.endsWith(".relevelup.com")||t==="thelocalmove.com"||t.endsWith(".thelocalmove.com")||t3e.has(t))}function bge(t){return wge(t)!==null}function wge(t){const e=r3e(t);return n3e(e)?null:e}const s3e=1,i3e=1e6;let kz=0;function a3e(){return kz=(kz+1)%Number.MAX_SAFE_INTEGER,kz.toString()}const Az=new Map,Ore=t=>{if(Az.has(t))return;const e=setTimeout(()=>{Az.delete(t),eA({type:"REMOVE_TOAST",toastId:t})},i3e);Az.set(t,e)},o3e=(t,e)=>{switch(e.type){case"ADD_TOAST":return{...t,toasts:[e.toast,...t.toasts].slice(0,s3e)};case"UPDATE_TOAST":return{...t,toasts:t.toasts.map(r=>r.id===e.toast.id?{...r,...e.toast}:r)};case"DISMISS_TOAST":{const{toastId:r}=e;return r?Ore(r):t.toasts.forEach(n=>{Ore(n.id)}),{...t,toasts:t.toasts.map(n=>n.id===r||r===void 0?{...n,open:!1}:n)}}case"REMOVE_TOAST":return e.toastId===void 0?{...t,toasts:[]}:{...t,toasts:t.toasts.filter(r=>r.id!==e.toastId)}}},EM=[];let jM={toasts:[]};function eA(t){jM=o3e(jM,t),EM.forEach(e=>{e(jM)})}function Fi({...t}){const e=a3e(),r=s=>eA({type:"UPDATE_TOAST",toast:{...s,id:e}}),n=()=>eA({type:"DISMISS_TOAST",toastId:e});return eA({type:"ADD_TOAST",toast:{...t,id:e,open:!0,onOpenChange:s=>{s||n()}}}),{id:e,dismiss:n,update:r}}function Sge(){const[t,e]=N.useState(jM);return N.useEffect(()=>(EM.push(e),()=>{const r=EM.indexOf(e);r>-1&&EM.splice(r,1)}),[t]),{...t,toast:Fi,dismiss:r=>eA({type:"DISMISS_TOAST",toastId:r})}}function Gr(t,e,{checkForDefaultPrevented:r=!0}={}){return function(s){if(t==null||t(s),r===!1||!s.defaultPrevented)return e==null?void 0:e(s)}}function Fre(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function kg(...t){return e=>{let r=!1;const n=t.map(s=>{const o=Fre(s,e);return!r&&typeof o=="function"&&(r=!0),o});if(r)return()=>{for(let s=0;s{const{children:c,...a}=o,f=N.useMemo(()=>a,Object.values(a));return i.jsx(r.Provider,{value:f,children:c})};n.displayName=t+"Provider";function s(o){const c=N.useContext(r);if(c)return c;if(e!==void 0)return e;throw new Error(`\`${o}\` must be used within \`${t}\``)}return[n,s]}function cl(t,e=[]){let r=[];function n(o,c){const a=N.createContext(c),f=r.length;r=[...r,c];const m=_=>{var M;const{scope:w,children:E,...A}=_,C=((M=w==null?void 0:w[t])==null?void 0:M[f])||a,I=N.useMemo(()=>A,Object.values(A));return i.jsx(C.Provider,{value:I,children:E})};m.displayName=o+"Provider";function y(_,w){var C;const E=((C=w==null?void 0:w[t])==null?void 0:C[f])||a,A=N.useContext(E);if(A)return A;if(c!==void 0)return c;throw new Error(`\`${_}\` must be used within \`${o}\``)}return[m,y]}const s=()=>{const o=r.map(c=>N.createContext(c));return function(a){const f=(a==null?void 0:a[t])||o;return N.useMemo(()=>({[`__scope${t}`]:{...a,[t]:f}}),[a,f])}};return s.scopeName=t,[n,c3e(s,...e)]}function c3e(...t){const e=t[0];if(t.length===1)return e;const r=()=>{const n=t.map(s=>({useScope:s(),scopeName:s.scopeName}));return function(o){const c=n.reduce((a,{useScope:f,scopeName:m})=>{const _=f(o)[`__scope${m}`];return{...a,..._}},{});return N.useMemo(()=>({[`__scope${e.scopeName}`]:c}),[c])}};return r.scopeName=e.scopeName,r}function Bx(t){const e=u3e(t),r=N.forwardRef((n,s)=>{const{children:o,...c}=n,a=N.Children.toArray(o),f=a.find(d3e);if(f){const m=f.props.children,y=a.map(_=>_===f?N.Children.count(m)>1?N.Children.only(null):N.isValidElement(m)?m.props.children:null:_);return i.jsx(e,{...c,ref:s,children:N.isValidElement(m)?N.cloneElement(m,void 0,y):null})}return i.jsx(e,{...c,ref:s,children:o})});return r.displayName=`${t}.Slot`,r}var Tge=Bx("Slot");function u3e(t){const e=N.forwardRef((r,n)=>{const{children:s,...o}=r;if(N.isValidElement(s)){const c=f3e(s),a=h3e(o,s.props);return s.type!==N.Fragment&&(a.ref=n?kg(n,c):c),N.cloneElement(s,a)}return N.Children.count(s)>1?N.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var Ege=Symbol("radix.slottable");function jge(t){const e=({children:r})=>i.jsx(i.Fragment,{children:r});return e.displayName=`${t}.Slottable`,e.__radixId=Ege,e}function d3e(t){return N.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===Ege}function h3e(t,e){const r={...e};for(const n in e){const s=t[n],o=e[n];/^on[A-Z]/.test(n)?s&&o?r[n]=(...a)=>{const f=o(...a);return s(...a),f}:s&&(r[n]=s):n==="style"?r[n]={...s,...o}:n==="className"&&(r[n]=[s,o].filter(Boolean).join(" "))}return{...t,...r}}function f3e(t){var n,s;let e=(n=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:n.get,r=e&&"isReactWarning"in e&&e.isReactWarning;return r?t.ref:(e=(s=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:s.get,r=e&&"isReactWarning"in e&&e.isReactWarning,r?t.props.ref:t.props.ref||t.ref)}function mC(t){const e=t+"CollectionProvider",[r,n]=cl(e),[s,o]=r(e,{collectionRef:{current:null},itemMap:new Map}),c=C=>{const{scope:I,children:M}=C,D=Qe.useRef(null),B=Qe.useRef(new Map).current;return i.jsx(s,{scope:I,itemMap:B,collectionRef:D,children:M})};c.displayName=e;const a=t+"CollectionSlot",f=Bx(a),m=Qe.forwardRef((C,I)=>{const{scope:M,children:D}=C,B=o(a,M),U=is(I,B.collectionRef);return i.jsx(f,{ref:U,children:D})});m.displayName=a;const y=t+"CollectionItemSlot",_="data-radix-collection-item",w=Bx(y),E=Qe.forwardRef((C,I)=>{const{scope:M,children:D,...B}=C,U=Qe.useRef(null),q=is(I,U),H=o(y,M);return Qe.useEffect(()=>(H.itemMap.set(U,{ref:U,...B}),()=>void H.itemMap.delete(U))),i.jsx(w,{[_]:"",ref:q,children:D})});E.displayName=y;function A(C){const I=o(t+"CollectionConsumer",C);return Qe.useCallback(()=>{const D=I.collectionRef.current;if(!D)return[];const B=Array.from(D.querySelectorAll(`[${_}]`));return Array.from(I.itemMap.values()).sort((H,K)=>B.indexOf(H.ref.current)-B.indexOf(K.ref.current))},[I.collectionRef,I.itemMap])}return[{Provider:c,Slot:m,ItemSlot:E},A,n]}var m3e=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],cn=m3e.reduce((t,e)=>{const r=Bx(`Primitive.${e}`),n=N.forwardRef((s,o)=>{const{asChild:c,...a}=s,f=c?r:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),i.jsx(f,{...a,ref:o})});return n.displayName=`Primitive.${e}`,{...t,[e]:n}},{});function oH(t,e){t&&sp.flushSync(()=>t.dispatchEvent(e))}function fo(t){const e=N.useRef(t);return N.useEffect(()=>{e.current=t}),N.useMemo(()=>(...r)=>{var n;return(n=e.current)==null?void 0:n.call(e,...r)},[])}function p3e(t,e=globalThis==null?void 0:globalThis.document){const r=fo(t);N.useEffect(()=>{const n=s=>{s.key==="Escape"&&r(s)};return e.addEventListener("keydown",n,{capture:!0}),()=>e.removeEventListener("keydown",n,{capture:!0})},[r,e])}var g3e="DismissableLayer",o8="dismissableLayer.update",y3e="dismissableLayer.pointerDownOutside",x3e="dismissableLayer.focusOutside",Bre,kge=N.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),nb=N.forwardRef((t,e)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:n,onPointerDownOutside:s,onFocusOutside:o,onInteractOutside:c,onDismiss:a,...f}=t,m=N.useContext(kge),[y,_]=N.useState(null),w=(y==null?void 0:y.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,E]=N.useState({}),A=is(e,K=>_(K)),C=Array.from(m.layers),[I]=[...m.layersWithOutsidePointerEventsDisabled].slice(-1),M=C.indexOf(I),D=y?C.indexOf(y):-1,B=m.layersWithOutsidePointerEventsDisabled.size>0,U=D>=M,q=v3e(K=>{const Q=K.target,J=[...m.branches].some(ee=>ee.contains(Q));!U||J||(s==null||s(K),c==null||c(K),K.defaultPrevented||a==null||a())},w),H=b3e(K=>{const Q=K.target;[...m.branches].some(ee=>ee.contains(Q))||(o==null||o(K),c==null||c(K),K.defaultPrevented||a==null||a())},w);return p3e(K=>{D===m.layers.size-1&&(n==null||n(K),!K.defaultPrevented&&a&&(K.preventDefault(),a()))},w),N.useEffect(()=>{if(y)return r&&(m.layersWithOutsidePointerEventsDisabled.size===0&&(Bre=w.body.style.pointerEvents,w.body.style.pointerEvents="none"),m.layersWithOutsidePointerEventsDisabled.add(y)),m.layers.add(y),$re(),()=>{r&&m.layersWithOutsidePointerEventsDisabled.size===1&&(w.body.style.pointerEvents=Bre)}},[y,w,r,m]),N.useEffect(()=>()=>{y&&(m.layers.delete(y),m.layersWithOutsidePointerEventsDisabled.delete(y),$re())},[y,m]),N.useEffect(()=>{const K=()=>E({});return document.addEventListener(o8,K),()=>document.removeEventListener(o8,K)},[]),i.jsx(cn.div,{...f,ref:A,style:{pointerEvents:B?U?"auto":"none":void 0,...t.style},onFocusCapture:Gr(t.onFocusCapture,H.onFocusCapture),onBlurCapture:Gr(t.onBlurCapture,H.onBlurCapture),onPointerDownCapture:Gr(t.onPointerDownCapture,q.onPointerDownCapture)})});nb.displayName=g3e;var _3e="DismissableLayerBranch",Age=N.forwardRef((t,e)=>{const r=N.useContext(kge),n=N.useRef(null),s=is(e,n);return N.useEffect(()=>{const o=n.current;if(o)return r.branches.add(o),()=>{r.branches.delete(o)}},[r.branches]),i.jsx(cn.div,{...t,ref:s})});Age.displayName=_3e;function v3e(t,e=globalThis==null?void 0:globalThis.document){const r=fo(t),n=N.useRef(!1),s=N.useRef(()=>{});return N.useEffect(()=>{const o=a=>{if(a.target&&!n.current){let f=function(){Nge(y3e,r,m,{discrete:!0})};const m={originalEvent:a};a.pointerType==="touch"?(e.removeEventListener("click",s.current),s.current=f,e.addEventListener("click",s.current,{once:!0})):f()}else e.removeEventListener("click",s.current);n.current=!1},c=window.setTimeout(()=>{e.addEventListener("pointerdown",o)},0);return()=>{window.clearTimeout(c),e.removeEventListener("pointerdown",o),e.removeEventListener("click",s.current)}},[e,r]),{onPointerDownCapture:()=>n.current=!0}}function b3e(t,e=globalThis==null?void 0:globalThis.document){const r=fo(t),n=N.useRef(!1);return N.useEffect(()=>{const s=o=>{o.target&&!n.current&&Nge(x3e,r,{originalEvent:o},{discrete:!1})};return e.addEventListener("focusin",s),()=>e.removeEventListener("focusin",s)},[e,r]),{onFocusCapture:()=>n.current=!0,onBlurCapture:()=>n.current=!1}}function $re(){const t=new CustomEvent(o8);document.dispatchEvent(t)}function Nge(t,e,r,{discrete:n}){const s=r.originalEvent.target,o=new CustomEvent(t,{bubbles:!1,cancelable:!0,detail:r});e&&s.addEventListener(t,e,{once:!0}),n?oH(s,o):s.dispatchEvent(o)}var w3e=nb,S3e=Age,qo=globalThis!=null&&globalThis.document?N.useLayoutEffect:()=>{},T3e="Portal",$T=N.forwardRef((t,e)=>{var a;const{container:r,...n}=t,[s,o]=N.useState(!1);qo(()=>o(!0),[]);const c=r||s&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return c?_ge.createPortal(i.jsx(cn.div,{...n,ref:e}),c):null});$T.displayName=T3e;function E3e(t,e){return N.useReducer((r,n)=>e[r][n]??r,t)}var Cl=t=>{const{present:e,children:r}=t,n=j3e(e),s=typeof r=="function"?r({present:n.isPresent}):N.Children.only(r),o=is(n.ref,k3e(s));return typeof r=="function"||n.isPresent?N.cloneElement(s,{ref:o}):null};Cl.displayName="Presence";function j3e(t){const[e,r]=N.useState(),n=N.useRef(null),s=N.useRef(t),o=N.useRef("none"),c=t?"mounted":"unmounted",[a,f]=E3e(c,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return N.useEffect(()=>{const m=ZR(n.current);o.current=a==="mounted"?m:"none"},[a]),qo(()=>{const m=n.current,y=s.current;if(y!==t){const w=o.current,E=ZR(m);t?f("MOUNT"):E==="none"||(m==null?void 0:m.display)==="none"?f("UNMOUNT"):f(y&&w!==E?"ANIMATION_OUT":"UNMOUNT"),s.current=t}},[t,f]),qo(()=>{if(e){let m;const y=e.ownerDocument.defaultView??window,_=E=>{const C=ZR(n.current).includes(E.animationName);if(E.target===e&&C&&(f("ANIMATION_END"),!s.current)){const I=e.style.animationFillMode;e.style.animationFillMode="forwards",m=y.setTimeout(()=>{e.style.animationFillMode==="forwards"&&(e.style.animationFillMode=I)})}},w=E=>{E.target===e&&(o.current=ZR(n.current))};return e.addEventListener("animationstart",w),e.addEventListener("animationcancel",_),e.addEventListener("animationend",_),()=>{y.clearTimeout(m),e.removeEventListener("animationstart",w),e.removeEventListener("animationcancel",_),e.removeEventListener("animationend",_)}}else f("ANIMATION_END")},[e,f]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:N.useCallback(m=>{n.current=m?getComputedStyle(m):null,r(m)},[])}}function ZR(t){return(t==null?void 0:t.animationName)||"none"}function k3e(t){var n,s;let e=(n=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:n.get,r=e&&"isReactWarning"in e&&e.isReactWarning;return r?t.ref:(e=(s=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:s.get,r=e&&"isReactWarning"in e&&e.isReactWarning,r?t.props.ref:t.props.ref||t.ref)}var A3e=g7[" useInsertionEffect ".trim().toString()]||qo;function ed({prop:t,defaultProp:e,onChange:r=()=>{},caller:n}){const[s,o,c]=N3e({defaultProp:e,onChange:r}),a=t!==void 0,f=a?t:s;{const y=N.useRef(t!==void 0);N.useEffect(()=>{const _=y.current;_!==a&&console.warn(`${n} is changing from ${_?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),y.current=a},[a,n])}const m=N.useCallback(y=>{var _;if(a){const w=C3e(y)?y(t):y;w!==t&&((_=c.current)==null||_.call(c,w))}else o(y)},[a,t,o,c]);return[f,m]}function N3e({defaultProp:t,onChange:e}){const[r,n]=N.useState(t),s=N.useRef(r),o=N.useRef(e);return A3e(()=>{o.current=e},[e]),N.useEffect(()=>{var c;s.current!==r&&((c=o.current)==null||c.call(o,r),s.current=r)},[r,s]),[r,n,o]}function C3e(t){return typeof t=="function"}var Cge=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),I3e="VisuallyHidden",t4=N.forwardRef((t,e)=>i.jsx(cn.span,{...t,ref:e,style:{...Cge,...t.style}}));t4.displayName=I3e;var P3e=t4,lH="ToastProvider",[cH,R3e,L3e]=mC("Toast"),[Ige,uQt]=cl("Toast",[L3e]),[M3e,r4]=Ige(lH),Pge=t=>{const{__scopeToast:e,label:r="Notification",duration:n=5e3,swipeDirection:s="right",swipeThreshold:o=50,children:c}=t,[a,f]=N.useState(null),[m,y]=N.useState(0),_=N.useRef(!1),w=N.useRef(!1);return r.trim()||console.error(`Invalid prop \`label\` supplied to \`${lH}\`. Expected non-empty \`string\`.`),i.jsx(cH.Provider,{scope:e,children:i.jsx(M3e,{scope:e,label:r,duration:n,swipeDirection:s,swipeThreshold:o,toastCount:m,viewport:a,onViewportChange:f,onToastAdd:N.useCallback(()=>y(E=>E+1),[]),onToastRemove:N.useCallback(()=>y(E=>E-1),[]),isFocusedToastEscapeKeyDownRef:_,isClosePausedRef:w,children:c})})};Pge.displayName=lH;var Rge="ToastViewport",D3e=["F8"],l8="toast.viewportPause",c8="toast.viewportResume",Lge=N.forwardRef((t,e)=>{const{__scopeToast:r,hotkey:n=D3e,label:s="Notifications ({hotkey})",...o}=t,c=r4(Rge,r),a=R3e(r),f=N.useRef(null),m=N.useRef(null),y=N.useRef(null),_=N.useRef(null),w=is(e,_,c.onViewportChange),E=n.join("+").replace(/Key/g,"").replace(/Digit/g,""),A=c.toastCount>0;N.useEffect(()=>{const I=M=>{var B;n.length!==0&&n.every(U=>M[U]||M.code===U)&&((B=_.current)==null||B.focus())};return document.addEventListener("keydown",I),()=>document.removeEventListener("keydown",I)},[n]),N.useEffect(()=>{const I=f.current,M=_.current;if(A&&I&&M){const D=()=>{if(!c.isClosePausedRef.current){const H=new CustomEvent(l8);M.dispatchEvent(H),c.isClosePausedRef.current=!0}},B=()=>{if(c.isClosePausedRef.current){const H=new CustomEvent(c8);M.dispatchEvent(H),c.isClosePausedRef.current=!1}},U=H=>{!I.contains(H.relatedTarget)&&B()},q=()=>{I.contains(document.activeElement)||B()};return I.addEventListener("focusin",D),I.addEventListener("focusout",U),I.addEventListener("pointermove",D),I.addEventListener("pointerleave",q),window.addEventListener("blur",D),window.addEventListener("focus",B),()=>{I.removeEventListener("focusin",D),I.removeEventListener("focusout",U),I.removeEventListener("pointermove",D),I.removeEventListener("pointerleave",q),window.removeEventListener("blur",D),window.removeEventListener("focus",B)}}},[A,c.isClosePausedRef]);const C=N.useCallback(({tabbingDirection:I})=>{const D=a().map(B=>{const U=B.ref.current,q=[U,...Y3e(U)];return I==="forwards"?q:q.reverse()});return(I==="forwards"?D.reverse():D).flat()},[a]);return N.useEffect(()=>{const I=_.current;if(I){const M=D=>{var q,H,K;const B=D.altKey||D.ctrlKey||D.metaKey;if(D.key==="Tab"&&!B){const Q=document.activeElement,J=D.shiftKey;if(D.target===I&&J){(q=m.current)==null||q.focus();return}const de=C({tabbingDirection:J?"backwards":"forwards"}),ye=de.findIndex(Ee=>Ee===Q);Nz(de.slice(ye+1))?D.preventDefault():J?(H=m.current)==null||H.focus():(K=y.current)==null||K.focus()}};return I.addEventListener("keydown",M),()=>I.removeEventListener("keydown",M)}},[a,C]),i.jsxs(S3e,{ref:f,role:"region","aria-label":s.replace("{hotkey}",E),tabIndex:-1,style:{pointerEvents:A?void 0:"none"},children:[A&&i.jsx(u8,{ref:m,onFocusFromOutsideViewport:()=>{const I=C({tabbingDirection:"forwards"});Nz(I)}}),i.jsx(cH.Slot,{scope:r,children:i.jsx(cn.ol,{tabIndex:-1,...o,ref:w})}),A&&i.jsx(u8,{ref:y,onFocusFromOutsideViewport:()=>{const I=C({tabbingDirection:"backwards"});Nz(I)}})]})});Lge.displayName=Rge;var Mge="ToastFocusProxy",u8=N.forwardRef((t,e)=>{const{__scopeToast:r,onFocusFromOutsideViewport:n,...s}=t,o=r4(Mge,r);return i.jsx(t4,{"aria-hidden":!0,tabIndex:0,...s,ref:e,style:{position:"fixed"},onFocus:c=>{var m;const a=c.relatedTarget;!((m=o.viewport)!=null&&m.contains(a))&&n()}})});u8.displayName=Mge;var pC="Toast",O3e="toast.swipeStart",F3e="toast.swipeMove",B3e="toast.swipeCancel",$3e="toast.swipeEnd",Dge=N.forwardRef((t,e)=>{const{forceMount:r,open:n,defaultOpen:s,onOpenChange:o,...c}=t,[a,f]=ed({prop:n,defaultProp:s??!0,onChange:o,caller:pC});return i.jsx(Cl,{present:r||a,children:i.jsx(V3e,{open:a,...c,ref:e,onClose:()=>f(!1),onPause:fo(t.onPause),onResume:fo(t.onResume),onSwipeStart:Gr(t.onSwipeStart,m=>{m.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:Gr(t.onSwipeMove,m=>{const{x:y,y:_}=m.detail.delta;m.currentTarget.setAttribute("data-swipe","move"),m.currentTarget.style.setProperty("--radix-toast-swipe-move-x",`${y}px`),m.currentTarget.style.setProperty("--radix-toast-swipe-move-y",`${_}px`)}),onSwipeCancel:Gr(t.onSwipeCancel,m=>{m.currentTarget.setAttribute("data-swipe","cancel"),m.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),m.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),m.currentTarget.style.removeProperty("--radix-toast-swipe-end-x"),m.currentTarget.style.removeProperty("--radix-toast-swipe-end-y")}),onSwipeEnd:Gr(t.onSwipeEnd,m=>{const{x:y,y:_}=m.detail.delta;m.currentTarget.setAttribute("data-swipe","end"),m.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),m.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),m.currentTarget.style.setProperty("--radix-toast-swipe-end-x",`${y}px`),m.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${_}px`),f(!1)})})})});Dge.displayName=pC;var[z3e,U3e]=Ige(pC,{onClose(){}}),V3e=N.forwardRef((t,e)=>{const{__scopeToast:r,type:n="foreground",duration:s,open:o,onClose:c,onEscapeKeyDown:a,onPause:f,onResume:m,onSwipeStart:y,onSwipeMove:_,onSwipeCancel:w,onSwipeEnd:E,...A}=t,C=r4(pC,r),[I,M]=N.useState(null),D=is(e,Ee=>M(Ee)),B=N.useRef(null),U=N.useRef(null),q=s||C.duration,H=N.useRef(0),K=N.useRef(q),Q=N.useRef(0),{onToastAdd:J,onToastRemove:ee}=C,oe=fo(()=>{var Le;(I==null?void 0:I.contains(document.activeElement))&&((Le=C.viewport)==null||Le.focus()),c()}),de=N.useCallback(Ee=>{!Ee||Ee===1/0||(window.clearTimeout(Q.current),H.current=new Date().getTime(),Q.current=window.setTimeout(oe,Ee))},[oe]);N.useEffect(()=>{const Ee=C.viewport;if(Ee){const Le=()=>{de(K.current),m==null||m()},Se=()=>{const be=new Date().getTime()-H.current;K.current=K.current-be,window.clearTimeout(Q.current),f==null||f()};return Ee.addEventListener(l8,Se),Ee.addEventListener(c8,Le),()=>{Ee.removeEventListener(l8,Se),Ee.removeEventListener(c8,Le)}}},[C.viewport,q,f,m,de]),N.useEffect(()=>{o&&!C.isClosePausedRef.current&&de(q)},[o,q,C.isClosePausedRef,de]),N.useEffect(()=>(J(),()=>ee()),[J,ee]);const ye=N.useMemo(()=>I?Vge(I):null,[I]);return C.viewport?i.jsxs(i.Fragment,{children:[ye&&i.jsx(q3e,{__scopeToast:r,role:"status","aria-live":n==="foreground"?"assertive":"polite","aria-atomic":!0,children:ye}),i.jsx(z3e,{scope:r,onClose:oe,children:sp.createPortal(i.jsx(cH.ItemSlot,{scope:r,children:i.jsx(w3e,{asChild:!0,onEscapeKeyDown:Gr(a,()=>{C.isFocusedToastEscapeKeyDownRef.current||oe(),C.isFocusedToastEscapeKeyDownRef.current=!1}),children:i.jsx(cn.li,{role:"status","aria-live":"off","aria-atomic":!0,tabIndex:0,"data-state":o?"open":"closed","data-swipe-direction":C.swipeDirection,...A,ref:D,style:{userSelect:"none",touchAction:"none",...t.style},onKeyDown:Gr(t.onKeyDown,Ee=>{Ee.key==="Escape"&&(a==null||a(Ee.nativeEvent),Ee.nativeEvent.defaultPrevented||(C.isFocusedToastEscapeKeyDownRef.current=!0,oe()))}),onPointerDown:Gr(t.onPointerDown,Ee=>{Ee.button===0&&(B.current={x:Ee.clientX,y:Ee.clientY})}),onPointerMove:Gr(t.onPointerMove,Ee=>{if(!B.current)return;const Le=Ee.clientX-B.current.x,Se=Ee.clientY-B.current.y,be=!!U.current,me=["left","right"].includes(C.swipeDirection),ke=["left","up"].includes(C.swipeDirection)?Math.min:Math.max,Pe=me?ke(0,Le):0,je=me?0:ke(0,Se),xe=Ee.pointerType==="touch"?10:2,Ue={x:Pe,y:je},Ze={originalEvent:Ee,delta:Ue};be?(U.current=Ue,XR(F3e,_,Ze,{discrete:!1})):zre(Ue,C.swipeDirection,xe)?(U.current=Ue,XR(O3e,y,Ze,{discrete:!1}),Ee.target.setPointerCapture(Ee.pointerId)):(Math.abs(Le)>xe||Math.abs(Se)>xe)&&(B.current=null)}),onPointerUp:Gr(t.onPointerUp,Ee=>{const Le=U.current,Se=Ee.target;if(Se.hasPointerCapture(Ee.pointerId)&&Se.releasePointerCapture(Ee.pointerId),U.current=null,B.current=null,Le){const be=Ee.currentTarget,me={originalEvent:Ee,delta:Le};zre(Le,C.swipeDirection,C.swipeThreshold)?XR($3e,E,me,{discrete:!0}):XR(B3e,w,me,{discrete:!0}),be.addEventListener("click",ke=>ke.preventDefault(),{once:!0})}})})})}),C.viewport)})]}):null}),q3e=t=>{const{__scopeToast:e,children:r,...n}=t,s=r4(pC,e),[o,c]=N.useState(!1),[a,f]=N.useState(!1);return W3e(()=>c(!0)),N.useEffect(()=>{const m=window.setTimeout(()=>f(!0),1e3);return()=>window.clearTimeout(m)},[]),a?null:i.jsx($T,{asChild:!0,children:i.jsx(t4,{...n,children:o&&i.jsxs(i.Fragment,{children:[s.label," ",r]})})})},G3e="ToastTitle",Oge=N.forwardRef((t,e)=>{const{__scopeToast:r,...n}=t;return i.jsx(cn.div,{...n,ref:e})});Oge.displayName=G3e;var H3e="ToastDescription",Fge=N.forwardRef((t,e)=>{const{__scopeToast:r,...n}=t;return i.jsx(cn.div,{...n,ref:e})});Fge.displayName=H3e;var Bge="ToastAction",$ge=N.forwardRef((t,e)=>{const{altText:r,...n}=t;return r.trim()?i.jsx(Uge,{altText:r,asChild:!0,children:i.jsx(uH,{...n,ref:e})}):(console.error(`Invalid prop \`altText\` supplied to \`${Bge}\`. Expected non-empty \`string\`.`),null)});$ge.displayName=Bge;var zge="ToastClose",uH=N.forwardRef((t,e)=>{const{__scopeToast:r,...n}=t,s=U3e(zge,r);return i.jsx(Uge,{asChild:!0,children:i.jsx(cn.button,{type:"button",...n,ref:e,onClick:Gr(t.onClick,s.onClose)})})});uH.displayName=zge;var Uge=N.forwardRef((t,e)=>{const{__scopeToast:r,altText:n,...s}=t;return i.jsx(cn.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":n||void 0,...s,ref:e})});function Vge(t){const e=[];return Array.from(t.childNodes).forEach(n=>{if(n.nodeType===n.TEXT_NODE&&n.textContent&&e.push(n.textContent),K3e(n)){const s=n.ariaHidden||n.hidden||n.style.display==="none",o=n.dataset.radixToastAnnounceExclude==="";if(!s)if(o){const c=n.dataset.radixToastAnnounceAlt;c&&e.push(c)}else e.push(...Vge(n))}}),e}function XR(t,e,r,{discrete:n}){const s=r.originalEvent.currentTarget,o=new CustomEvent(t,{bubbles:!0,cancelable:!0,detail:r});e&&s.addEventListener(t,e,{once:!0}),n?oH(s,o):s.dispatchEvent(o)}var zre=(t,e,r=0)=>{const n=Math.abs(t.x),s=Math.abs(t.y),o=n>s;return e==="left"||e==="right"?o&&n>r:!o&&s>r};function W3e(t=()=>{}){const e=fo(t);qo(()=>{let r=0,n=0;return r=window.requestAnimationFrame(()=>n=window.requestAnimationFrame(e)),()=>{window.cancelAnimationFrame(r),window.cancelAnimationFrame(n)}},[e])}function K3e(t){return t.nodeType===t.ELEMENT_NODE}function Y3e(t){const e=[],r=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:n=>{const s=n.tagName==="INPUT"&&n.type==="hidden";return n.disabled||n.hidden||s?NodeFilter.FILTER_SKIP:n.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;r.nextNode();)e.push(r.currentNode);return e}function Nz(t){const e=document.activeElement;return t.some(r=>r===e?!0:(r.focus(),document.activeElement!==e))}var Z3e=Pge,qge=Lge,Gge=Dge,Hge=Oge,Wge=Fge,Kge=$ge,Yge=uH;function Zge(t){var e,r,n="";if(typeof t=="string"||typeof t=="number")n+=t;else if(typeof t=="object")if(Array.isArray(t)){var s=t.length;for(e=0;etypeof t=="boolean"?`${t}`:t===0?"0":t,Vre=Ws,zT=(t,e)=>r=>{var n;if((e==null?void 0:e.variants)==null)return Vre(t,r==null?void 0:r.class,r==null?void 0:r.className);const{variants:s,defaultVariants:o}=e,c=Object.keys(s).map(m=>{const y=r==null?void 0:r[m],_=o==null?void 0:o[m];if(y===null)return null;const w=Ure(y)||Ure(_);return s[m][w]}),a=r&&Object.entries(r).reduce((m,y)=>{let[_,w]=y;return w===void 0||(m[_]=w),m},{}),f=e==null||(n=e.compoundVariants)===null||n===void 0?void 0:n.reduce((m,y)=>{let{class:_,className:w,...E}=y;return Object.entries(E).every(A=>{let[C,I]=A;return Array.isArray(I)?I.includes({...o,...a}[C]):{...o,...a}[C]===I})?[...m,_,w]:m},[]);return Vre(t,c,f,r==null?void 0:r.class,r==null?void 0:r.className)};/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const X3e=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Xge=(...t)=>t.filter((e,r,n)=>!!e&&e.trim()!==""&&n.indexOf(e)===r).join(" ").trim();/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */var Q3e={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const J3e=N.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:r=2,absoluteStrokeWidth:n,className:s="",children:o,iconNode:c,...a},f)=>N.createElement("svg",{ref:f,...Q3e,width:e,height:e,stroke:t,strokeWidth:n?Number(r)*24/Number(e):r,className:Xge("lucide",s),...a},[...c.map(([m,y])=>N.createElement(m,y)),...Array.isArray(o)?o:[o]]));/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dr=(t,e)=>{const r=N.forwardRef(({className:n,...s},o)=>N.createElement(J3e,{ref:o,iconNode:e,className:Xge(`lucide-${X3e(t)}`,n),...s}));return r.displayName=`${t}`,r};/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qre=dr("Activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $x=dr("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ji=dr("ArrowRight",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const e4e=dr("ArrowUpDown",[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Qu=dr("ArrowUpRight",[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aS=dr("Award",[["path",{d:"m15.477 12.89 1.515 8.526a.5.5 0 0 1-.81.47l-3.58-2.687a1 1 0 0 0-1.197 0l-3.586 2.686a.5.5 0 0 1-.81-.469l1.514-8.526",key:"1yiouv"}],["circle",{cx:"12",cy:"8",r:"6",key:"1vp47v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const o0=dr("Bath",[["path",{d:"M10 4 8 6",key:"1rru8s"}],["path",{d:"M17 19v2",key:"ts1sot"}],["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"M7 19v2",key:"12npes"}],["path",{d:"M9 5 7.621 3.621A2.121 2.121 0 0 0 4 5v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-5",key:"14ym8i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Qge=dr("BedDouble",[["path",{d:"M2 20v-8a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v8",key:"1k78r4"}],["path",{d:"M4 10V6a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v4",key:"fb3tl2"}],["path",{d:"M12 4v6",key:"1dcgq2"}],["path",{d:"M2 18h20",key:"ajqnye"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UT=dr("Bed",[["path",{d:"M2 4v16",key:"vw9hq8"}],["path",{d:"M2 8h18a2 2 0 0 1 2 2v10",key:"1dgv2r"}],["path",{d:"M2 17h20",key:"18nfp3"}],["path",{d:"M6 8v9",key:"1yriud"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gC=dr("Bell",[["path",{d:"M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9",key:"1qo2s2"}],["path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0",key:"qgo35s"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qS=dr("BookOpen",[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CD=dr("Bookmark",[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z",key:"1fy3hk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const t4e=dr("Bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const d8=dr("Briefcase",[["path",{d:"M16 20V4a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v16",key:"jecpp"}],["rect",{width:"20",height:"14",x:"2",y:"6",rx:"2",key:"i6l2r4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ja=dr("Building2",[["path",{d:"M6 22V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v18Z",key:"1b4qmf"}],["path",{d:"M6 12H4a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h2",key:"i71pzd"}],["path",{d:"M18 9h2a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2h-2",key:"10jefs"}],["path",{d:"M10 6h4",key:"1itunk"}],["path",{d:"M10 10h4",key:"tcdvrf"}],["path",{d:"M10 14h4",key:"kelpxr"}],["path",{d:"M10 18h4",key:"1ulq68"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const r4e=dr("Cake",[["path",{d:"M20 21v-8a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v8",key:"1w3rig"}],["path",{d:"M4 16s.5-1 2-1 2.5 2 4 2 2.5-2 4-2 2.5 2 4 2 2-1 2-1",key:"n2jgmb"}],["path",{d:"M2 21h20",key:"1nyx9w"}],["path",{d:"M7 8v3",key:"1qtyvj"}],["path",{d:"M12 8v3",key:"hwp4zt"}],["path",{d:"M17 8v3",key:"1i6e5u"}],["path",{d:"M7 4h.01",key:"1bh4kh"}],["path",{d:"M12 4h.01",key:"1ujb9j"}],["path",{d:"M17 4h.01",key:"1upcoc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const h8=dr("Calculator",[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["line",{x1:"8",x2:"16",y1:"6",y2:"6",key:"x4nwl0"}],["line",{x1:"16",x2:"16",y1:"14",y2:"18",key:"wjye3r"}],["path",{d:"M16 10h.01",key:"1m94wz"}],["path",{d:"M12 10h.01",key:"1nrarc"}],["path",{d:"M8 10h.01",key:"19clt8"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M8 14h.01",key:"6423bh"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M8 18h.01",key:"lrp35t"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dH=dr("CalendarCheck",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"m9 16 2 2 4-4",key:"19s6y9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hH=dr("CalendarClock",[["path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5",key:"1osxxc"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M3 10h5",key:"r794hk"}],["path",{d:"M17.5 17.5 16 16.3V14",key:"akvzfd"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vm=dr("CalendarDays",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 14h.01",key:"6423bh"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M16 14h.01",key:"1gbofw"}],["path",{d:"M8 18h.01",key:"lrp35t"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M16 18h.01",key:"kzsmim"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Jge=dr("CalendarPlus",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 13V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h8",key:"3spt84"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M16 19h6",key:"xwg31i"}],["path",{d:"M19 16v6",key:"tddt3s"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xo=dr("Calendar",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gre=dr("Camera",[["path",{d:"M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3l-2.5-3z",key:"1tc9qg"}],["circle",{cx:"12",cy:"13",r:"3",key:"1vg3eu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zA=dr("ChartColumn",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pa=dr("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Go=dr("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ip=dr("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vd=dr("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eye=dr("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const f8=dr("ChevronsUpDown",[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tye=dr("CircleAlert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Nl=dr("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const n4e=dr("CircleHelp",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fH=dr("CirclePlay",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polygon",{points:"10 8 16 12 10 16 10 8",key:"1cimsy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ov=dr("Circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const m8=dr("ClipboardCheck",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"m9 14 2 2 4-4",key:"df797q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Cz=dr("ClipboardList",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"M12 11h4",key:"1jrz19"}],["path",{d:"M12 16h4",key:"n85exb"}],["path",{d:"M8 11h.01",key:"1dfujw"}],["path",{d:"M8 16h.01",key:"18s6g9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ql=dr("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Hre=dr("Compass",[["path",{d:"m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z",key:"9ktpf1"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ID=dr("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yg=dr("DollarSign",[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mc=dr("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const s4e=dr("EllipsisVertical",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const i4e=dr("Ellipsis",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sb=dr("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const n4=dr("Eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mH=dr("Facebook",[["path",{d:"M18 2h-3a5 5 0 0 0-5 5v3H7v4h3v8h4v-8h3l1-4h-4V7a1 1 0 0 1 1-1h3z",key:"1jg4f8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const a4e=dr("FilePenLine",[["path",{d:"m18 5-2.414-2.414A2 2 0 0 0 14.172 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2",key:"142zxg"}],["path",{d:"M21.378 12.626a1 1 0 0 0-3.004-3.004l-4.01 4.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"2t3380"}],["path",{d:"M8 18h1",key:"13wk12"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const o4e=dr("FileStack",[["path",{d:"M21 7h-3a2 2 0 0 1-2-2V2",key:"9rb54x"}],["path",{d:"M21 6v6.5c0 .8-.7 1.5-1.5 1.5h-7c-.8 0-1.5-.7-1.5-1.5v-9c0-.8.7-1.5 1.5-1.5H17Z",key:"1059l0"}],["path",{d:"M7 8v8.8c0 .3.2.6.4.8.2.2.5.4.8.4H15",key:"16874u"}],["path",{d:"M3 12v8.8c0 .3.2.6.4.8.2.2.5.4.8.4H11",key:"k2ox98"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ym=dr("FileText",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wre=dr("Film",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7 3v18",key:"bbkbws"}],["path",{d:"M3 7.5h4",key:"zfgn84"}],["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 16.5h4",key:"1230mu"}],["path",{d:"M17 3v18",key:"in4fa5"}],["path",{d:"M17 7.5h4",key:"myr1c1"}],["path",{d:"M17 16.5h4",key:"go4c1d"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const l4e=dr("Filter",[["polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3",key:"1yg77f"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const c4e=dr("Flag",[["path",{d:"M4 15s1-1 4-1 5 2 8 2 4-1 4-1V3s-1 1-4 1-5-2-8-2-4 1-4 1z",key:"i9b6wo"}],["line",{x1:"4",x2:"4",y1:"22",y2:"15",key:"1cm3nv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rye=dr("Flame",[["path",{d:"M8.5 14.5A2.5 2.5 0 0 0 11 12c0-1.38-.5-2-1-3-1.072-2.143-.224-4.054 2-6 .5 2.5 2 4.9 4 6.5 2 1.6 3 3.5 3 5.5a7 7 0 1 1-14 0c0-1.153.433-2.294 1-3a2.5 2.5 0 0 0 2.5 2.5z",key:"96xj49"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const u4e=dr("Gauge",[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Rf=dr("Gift",[["rect",{x:"3",y:"8",width:"18",height:"4",rx:"1",key:"bkv52"}],["path",{d:"M12 8v13",key:"1c76mn"}],["path",{d:"M19 12v7a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2v-7",key:"6wjy6b"}],["path",{d:"M7.5 8a2.5 2.5 0 0 1 0-5A4.8 8 0 0 1 12 8a4.8 8 0 0 1 4.5-5 2.5 2.5 0 0 1 0 5",key:"1ihvrl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Sv=dr("Globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UA=dr("GraduationCap",[["path",{d:"M21.42 10.922a1 1 0 0 0-.019-1.838L12.83 5.18a2 2 0 0 0-1.66 0L2.6 9.08a1 1 0 0 0 0 1.832l8.57 3.908a2 2 0 0 0 1.66 0z",key:"j76jl0"}],["path",{d:"M22 10v6",key:"1lu8f3"}],["path",{d:"M6 12.5V16a6 3 0 0 0 12 0v-3.5",key:"1r8lef"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const d4e=dr("Grid3x3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const h4e=dr("Hammer",[["path",{d:"m15 12-8.373 8.373a1 1 0 1 1-3-3L12 9",key:"eefl8a"}],["path",{d:"m18 15 4-4",key:"16gjal"}],["path",{d:"m21.5 11.5-1.914-1.914A2 2 0 0 1 19 8.172V7l-2.26-2.26a6 6 0 0 0-4.202-1.756L9 2.96l.92.82A6.18 6.18 0 0 1 12 8.4V10l2 2h1.172a2 2 0 0 1 1.414.586L18.5 14.5",key:"b7pghm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const f4e=dr("HandHelping",[["path",{d:"M11 12h2a2 2 0 1 0 0-4h-3c-.6 0-1.1.2-1.4.6L3 14",key:"1j4xps"}],["path",{d:"m7 18 1.6-1.4c.3-.4.8-.6 1.4-.6h4c1.1 0 2.1-.4 2.8-1.2l4.6-4.4a2 2 0 0 0-2.75-2.91l-4.2 3.9",key:"uospg8"}],["path",{d:"m2 13 6 6",key:"16e5sb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const p8=dr("Handshake",[["path",{d:"m11 17 2 2a1 1 0 1 0 3-3",key:"efffak"}],["path",{d:"m14 14 2.5 2.5a1 1 0 1 0 3-3l-3.88-3.88a3 3 0 0 0-4.24 0l-.88.88a1 1 0 1 1-3-3l2.81-2.81a5.79 5.79 0 0 1 7.06-.87l.47.28a2 2 0 0 0 1.42.25L21 4",key:"9pr0kb"}],["path",{d:"m21 3 1 11h-2",key:"1tisrp"}],["path",{d:"M3 3 2 14l6.5 6.5a1 1 0 1 0 3-3",key:"1uvwmv"}],["path",{d:"M3 4h8",key:"1ep09j"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Zm=dr("Heart",[["path",{d:"M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z",key:"c3ymky"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ea=dr("House",[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"1d0kgt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Kre=dr("Image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pH=dr("Instagram",[["rect",{width:"20",height:"20",x:"2",y:"2",rx:"5",ry:"5",key:"2e1cvw"}],["path",{d:"M16 11.37A4 4 0 1 1 12.63 8 4 4 0 0 1 16 11.37z",key:"9exkf1"}],["line",{x1:"17.5",x2:"17.51",y1:"6.5",y2:"6.5",key:"r4j83e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gH=dr("Kanban",[["path",{d:"M6 5v11",key:"mdvv1e"}],["path",{d:"M12 5v6",key:"14ar3b"}],["path",{d:"M18 5v14",key:"7ji314"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yH=dr("KeyRound",[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nye=dr("Key",[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const s4=dr("Landmark",[["line",{x1:"3",x2:"21",y1:"22",y2:"22",key:"j8o0r"}],["line",{x1:"6",x2:"6",y1:"18",y2:"11",key:"10tf0k"}],["line",{x1:"10",x2:"10",y1:"18",y2:"11",key:"54lgf6"}],["line",{x1:"14",x2:"14",y1:"18",y2:"11",key:"380y"}],["line",{x1:"18",x2:"18",y1:"18",y2:"11",key:"1kevvc"}],["polygon",{points:"12 2 20 7 4 7",key:"jkujk7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const m4e=dr("Layers",[["path",{d:"m12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83Z",key:"8b97xw"}],["path",{d:"m22 17.65-9.17 4.16a2 2 0 0 1-1.66 0L2 17.65",key:"dd6zsq"}],["path",{d:"m22 12.65-9.17 4.16a2 2 0 0 1-1.66 0L2 12.65",key:"ep9fru"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sye=dr("LayoutDashboard",[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const p4e=dr("LayoutGrid",[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const g4e=dr("LifeBuoy",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m4.93 4.93 4.24 4.24",key:"1ymg45"}],["path",{d:"m14.83 9.17 4.24-4.24",key:"1cb5xl"}],["path",{d:"m14.83 14.83 4.24 4.24",key:"q42g0n"}],["path",{d:"m9.17 14.83-4.24 4.24",key:"bqpfvv"}],["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const y4e=dr("Lightbulb",[["path",{d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5",key:"1gvzjb"}],["path",{d:"M9 18h6",key:"x1upvd"}],["path",{d:"M10 22h4",key:"ceow96"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Yre=dr("Link2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xH=dr("Linkedin",[["path",{d:"M16 8a6 6 0 0 1 6 6v7h-4v-7a2 2 0 0 0-2-2 2 2 0 0 0-2 2v7h-4v-7a6 6 0 0 1 6-6z",key:"c2jq9f"}],["rect",{width:"4",height:"12",x:"2",y:"9",key:"mk3on5"}],["circle",{cx:"4",cy:"4",r:"2",key:"bt5ra8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const x4e=dr("ListChecks",[["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"m3 7 2 2 4-4",key:"1obspn"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const g8=dr("List",[["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 18h.01",key:"1tta3j"}],["path",{d:"M3 6h.01",key:"1rqtza"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 18h13",key:"1lx6n3"}],["path",{d:"M8 6h13",key:"ik3vkj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Fc=dr("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zx=dr("Lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const i4=dr("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rs=dr("Mail",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ui=dr("MapPin",[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _4e=dr("Maximize2",[["polyline",{points:"15 3 21 3 21 9",key:"mznyad"}],["polyline",{points:"9 21 3 21 3 15",key:"1avn1i"}],["line",{x1:"21",x2:"14",y1:"3",y2:"10",key:"ota7mn"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const v4e=dr("Maximize",[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Tv=dr("Megaphone",[["path",{d:"m3 11 18-5v12L3 14v-3z",key:"n962bs"}],["path",{d:"M11.6 16.8a3 3 0 1 1-5.8-1.6",key:"1yl0tm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ib=dr("Menu",[["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}],["line",{x1:"4",x2:"20",y1:"6",y2:"6",key:"1owob3"}],["line",{x1:"4",x2:"20",y1:"18",y2:"18",key:"yk5zj1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const b4e=dr("MessageCircleQuestion",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Fv=dr("MessageCircle",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Nh=dr("MessageSquare",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const w4e=dr("Minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iye=dr("Newspaper",[["path",{d:"M4 22h16a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v16a2 2 0 0 1-2 2Zm0 0a2 2 0 0 1-2-2v-9c0-1.1.9-2 2-2h2",key:"7pis2x"}],["path",{d:"M18 14h-8",key:"sponae"}],["path",{d:"M15 18h-5",key:"95g1m2"}],["path",{d:"M10 6h8v4h-8V6Z",key:"smlsk5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const S4e=dr("NotebookPen",[["path",{d:"M13.4 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-7.4",key:"re6nr2"}],["path",{d:"M2 6h4",key:"aawbzj"}],["path",{d:"M2 10h4",key:"l0bgd4"}],["path",{d:"M2 14h4",key:"1gsvsf"}],["path",{d:"M2 18h4",key:"1bu2t1"}],["path",{d:"M21.378 5.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"pqwjuv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Zre=dr("Package",[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["path",{d:"m3.3 7 7.703 4.734a2 2 0 0 0 1.994 0L20.7 7",key:"yx3hmr"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const a4=dr("Palette",[["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["path",{d:"M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.926 0 1.648-.746 1.648-1.688 0-.437-.18-.835-.437-1.125-.29-.289-.438-.652-.438-1.125a1.64 1.64 0 0 1 1.668-1.668h1.996c3.051 0 5.555-2.503 5.555-5.554C21.965 6.012 17.461 2 12 2z",key:"12rzf8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const T4e=dr("PenLine",[["path",{d:"M12 20h9",key:"t2du7b"}],["path",{d:"M16.376 3.622a1 1 0 0 1 3.002 3.002L7.368 18.635a2 2 0 0 1-.855.506l-2.872.838a.5.5 0 0 1-.62-.62l.838-2.872a2 2 0 0 1 .506-.854z",key:"1ykcvy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aye=dr("Pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const E4e=dr("Percent",[["line",{x1:"19",x2:"5",y1:"5",y2:"19",key:"1x9vlm"}],["circle",{cx:"6.5",cy:"6.5",r:"2.5",key:"4mh3h7"}],["circle",{cx:"17.5",cy:"17.5",r:"2.5",key:"1mdrzq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const j4e=dr("PhoneCall",[["path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z",key:"foiqr5"}],["path",{d:"M14.05 2a9 9 0 0 1 8 7.94",key:"vmijpz"}],["path",{d:"M14.05 6A5 5 0 0 1 18 10",key:"13nbpp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Un=dr("Phone",[["path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z",key:"foiqr5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const k4e=dr("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PD=dr("Plug",[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M9 8V2",key:"14iosj"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z",key:"osxo6l"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qm=dr("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const A4e=dr("Presentation",[["path",{d:"M2 3h20",key:"91anmk"}],["path",{d:"M21 3v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V3",key:"2k9sn8"}],["path",{d:"m7 21 5-5 5 5",key:"bip4we"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const N4e=dr("Printer",[["path",{d:"M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2",key:"143wyd"}],["path",{d:"M6 9V3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v6",key:"1itne7"}],["rect",{x:"6",y:"14",width:"12",height:"8",rx:"1",key:"1ue0tg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const C4e=dr("Quote",[["path",{d:"M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"rib7q0"}],["path",{d:"M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"1ymkrd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const y8=dr("Radar",[["path",{d:"M19.07 4.93A10 10 0 0 0 6.99 3.34",key:"z3du51"}],["path",{d:"M4 6h.01",key:"oypzma"}],["path",{d:"M2.29 9.62A10 10 0 1 0 21.31 8.35",key:"qzzz0"}],["path",{d:"M16.24 7.76A6 6 0 1 0 8.23 16.67",key:"1yjesh"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M17.99 11.66A6 6 0 0 1 15.77 16.67",key:"1u2y91"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"m13.41 10.59 5.66-5.66",key:"mhq4k0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RD=dr("Radio",[["path",{d:"M4.9 19.1C1 15.2 1 8.8 4.9 4.9",key:"1vaf9d"}],["path",{d:"M7.8 16.2c-2.3-2.3-2.3-6.1 0-8.5",key:"u1ii0m"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"M16.2 7.8c2.3 2.3 2.3 6.1 0 8.5",key:"1j5fej"}],["path",{d:"M19.1 4.9C23 8.8 23 15.1 19.1 19",key:"10b0cb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oye=dr("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Iz=dr("Rocket",[["path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z",key:"m3kijz"}],["path",{d:"m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z",key:"1fmvmk"}],["path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0",key:"1f8sc4"}],["path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5",key:"qeys4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const I4e=dr("RotateCcw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yC=dr("Ruler",[["path",{d:"M21.3 15.3a2.4 2.4 0 0 1 0 3.4l-2.6 2.6a2.4 2.4 0 0 1-3.4 0L2.7 8.7a2.41 2.41 0 0 1 0-3.4l2.6-2.6a2.41 2.41 0 0 1 3.4 0Z",key:"icamh8"}],["path",{d:"m14.5 12.5 2-2",key:"inckbg"}],["path",{d:"m11.5 9.5 2-2",key:"fmmyf7"}],["path",{d:"m8.5 6.5 2-2",key:"vc6u1g"}],["path",{d:"m17.5 15.5 2-2",key:"wo5hmg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const P4e=dr("Scale",[["path",{d:"m16 16 3-8 3 8c-.87.65-1.92 1-3 1s-2.13-.35-3-1Z",key:"7g6ntu"}],["path",{d:"m2 16 3-8 3 8c-.87.65-1.92 1-3 1s-2.13-.35-3-1Z",key:"ijws7r"}],["path",{d:"M7 21h10",key:"1b0cd5"}],["path",{d:"M12 3v18",key:"108xh3"}],["path",{d:"M3 7h2c2 0 5-1 7-2 2 1 5 2 7 2h2",key:"3gwbw2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const R4e=dr("SearchX",[["path",{d:"m13.5 8.5-5 5",key:"1cs55j"}],["path",{d:"m8.5 8.5 5 5",key:"a8mexj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Dd=dr("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VA=dr("Send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _H=dr("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xC=dr("Share2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const L4e=dr("Share",[["path",{d:"M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8",key:"1b2hhj"}],["polyline",{points:"16 6 12 2 8 6",key:"m901s6"}],["line",{x1:"12",x2:"12",y1:"2",y2:"15",key:"1p0rca"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const o4=dr("ShieldCheck",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qA=dr("Shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lye=dr("ShoppingCart",[["circle",{cx:"8",cy:"21",r:"1",key:"jimo8o"}],["circle",{cx:"19",cy:"21",r:"1",key:"13723u"}],["path",{d:"M2.05 2.05h2l2.66 12.42a2 2 0 0 0 2 1.58h9.78a2 2 0 0 0 1.95-1.57l1.65-7.43H5.12",key:"9zh506"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const M4e=dr("SlidersHorizontal",[["line",{x1:"21",x2:"14",y1:"4",y2:"4",key:"obuewd"}],["line",{x1:"10",x2:"3",y1:"4",y2:"4",key:"1q6298"}],["line",{x1:"21",x2:"12",y1:"12",y2:"12",key:"1iu8h1"}],["line",{x1:"8",x2:"3",y1:"12",y2:"12",key:"ntss68"}],["line",{x1:"21",x2:"16",y1:"20",y2:"20",key:"14d8ph"}],["line",{x1:"12",x2:"3",y1:"20",y2:"20",key:"m0wm8r"}],["line",{x1:"14",x2:"14",y1:"2",y2:"6",key:"14e1ph"}],["line",{x1:"8",x2:"8",y1:"10",y2:"14",key:"1i6ji0"}],["line",{x1:"16",x2:"16",y1:"18",y2:"22",key:"1lctlv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Pz=dr("Smartphone",[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const D4e=dr("Sofa",[["path",{d:"M20 9V6a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v3",key:"1dgpiv"}],["path",{d:"M2 16a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-5a2 2 0 0 0-4 0v1.5a.5.5 0 0 1-.5.5h-11a.5.5 0 0 1-.5-.5V11a2 2 0 0 0-4 0z",key:"xacw8m"}],["path",{d:"M4 18v2",key:"jwo5n2"}],["path",{d:"M20 18v2",key:"1ar1qi"}],["path",{d:"M12 4v9",key:"oqhhn3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ki=dr("Sparkles",[["path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z",key:"4pj2yx"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M22 5h-4",key:"1gvqau"}],["path",{d:"M4 17v2",key:"vumght"}],["path",{d:"M5 18H3",key:"zchphs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const O4e=dr("SquareCheckBig",[["path",{d:"M21 10.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.5",key:"1uzm8b"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const x8=dr("SquarePen",[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vH=dr("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gc=dr("Star",[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bH=dr("Store",[["path",{d:"m2 7 4.41-4.41A2 2 0 0 1 7.83 2h8.34a2 2 0 0 1 1.42.59L22 7",key:"ztvudi"}],["path",{d:"M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8",key:"1b2hhj"}],["path",{d:"M15 22v-4a2 2 0 0 0-2-2h-2a2 2 0 0 0-2 2v4",key:"2ebpfo"}],["path",{d:"M2 7h20",key:"1fcdvo"}],["path",{d:"M22 7v3a2 2 0 0 1-2 2a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 16 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 12 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 8 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 4 12a2 2 0 0 1-2-2V7",key:"6c3vgh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const F4e=dr("Tablet",[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",ry:"2",key:"76otgf"}],["line",{x1:"12",x2:"12.01",y1:"18",y2:"18",key:"1dp563"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _C=dr("Target",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"6",key:"1vlfrh"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const B4e=dr("ThumbsUp",[["path",{d:"M7 10v12",key:"1qc93n"}],["path",{d:"M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z",key:"emmmcr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cye=dr("Ticket",[["path",{d:"M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z",key:"qn84l0"}],["path",{d:"M13 5v2",key:"dyzc3o"}],["path",{d:"M13 17v2",key:"1ont0d"}],["path",{d:"M13 11v2",key:"1wjjxi"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LD=dr("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uye=dr("TrendingDown",[["polyline",{points:"22 17 13.5 8.5 8.5 13.5 2 7",key:"1r2t7k"}],["polyline",{points:"16 17 22 17 22 11",key:"11uiuu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Lf=dr("TrendingUp",[["polyline",{points:"22 7 13.5 15.5 8.5 10.5 2 17",key:"126l90"}],["polyline",{points:"16 7 22 7 22 13",key:"kwv8wd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VT=dr("TriangleAlert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MD=dr("Trophy",[["path",{d:"M6 9H4.5a2.5 2.5 0 0 1 0-5H6",key:"17hqa7"}],["path",{d:"M18 9h1.5a2.5 2.5 0 0 0 0-5H18",key:"lmptdp"}],["path",{d:"M4 22h16",key:"57wxv0"}],["path",{d:"M10 14.66V17c0 .55-.47.98-.97 1.21C7.85 18.75 7 20.24 7 22",key:"1nw9bq"}],["path",{d:"M14 14.66V17c0 .55.47.98.97 1.21C16.15 18.75 17 20.24 17 22",key:"1np0yb"}],["path",{d:"M18 2H6v7a6 6 0 0 0 12 0V2Z",key:"u46fv3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _8=dr("Upload",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"17 8 12 3 7 8",key:"t8dd8p"}],["line",{x1:"12",x2:"12",y1:"3",y2:"15",key:"widbto"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const v8=dr("UserCheck",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["polyline",{points:"16 11 18 13 22 9",key:"1pwet4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const l4=dr("UserPlus",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gl=dr("User",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const El=dr("Users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tA=dr("Video",[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dye=dr("Volume2",[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728",key:"ijwkga"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hye=dr("VolumeX",[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["line",{x1:"22",x2:"16",y1:"9",y2:"15",key:"1ewh16"}],["line",{x1:"16",x2:"22",y1:"9",y2:"15",key:"5ykzw1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const c4=dr("Wallet",[["path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1",key:"18etb6"}],["path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4",key:"xoc0q4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $4e=dr("WandSparkles",[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wH=dr("Wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",key:"cbrjhi"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ci=dr("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fye=dr("Youtube",[["path",{d:"M2.5 17a24.12 24.12 0 0 1 0-10 2 2 0 0 1 1.4-1.4 49.56 49.56 0 0 1 16.2 0A2 2 0 0 1 21.5 7a24.12 24.12 0 0 1 0 10 2 2 0 0 1-1.4 1.4 49.55 49.55 0 0 1-16.2 0A2 2 0 0 1 2.5 17",key:"1q2vi4"}],["path",{d:"m10 15 5-3-5-3z",key:"1jp15x"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GS=dr("Zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Xre=dr("ZoomIn",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]),SH="-",z4e=t=>{const e=V4e(t),{conflictingClassGroups:r,conflictingClassGroupModifiers:n}=t;return{getClassGroupId:c=>{const a=c.split(SH);return a[0]===""&&a.length!==1&&a.shift(),mye(a,e)||U4e(c)},getConflictingClassGroupIds:(c,a)=>{const f=r[c]||[];return a&&n[c]?[...f,...n[c]]:f}}},mye=(t,e)=>{var c;if(t.length===0)return e.classGroupId;const r=t[0],n=e.nextPart.get(r),s=n?mye(t.slice(1),n):void 0;if(s)return s;if(e.validators.length===0)return;const o=t.join(SH);return(c=e.validators.find(({validator:a})=>a(o)))==null?void 0:c.classGroupId},Qre=/^\[(.+)\]$/,U4e=t=>{if(Qre.test(t)){const e=Qre.exec(t)[1],r=e==null?void 0:e.substring(0,e.indexOf(":"));if(r)return"arbitrary.."+r}},V4e=t=>{const{theme:e,prefix:r}=t,n={nextPart:new Map,validators:[]};return G4e(Object.entries(t.classGroups),r).forEach(([o,c])=>{b8(c,n,o,e)}),n},b8=(t,e,r,n)=>{t.forEach(s=>{if(typeof s=="string"){const o=s===""?e:Jre(e,s);o.classGroupId=r;return}if(typeof s=="function"){if(q4e(s)){b8(s(n),e,r,n);return}e.validators.push({validator:s,classGroupId:r});return}Object.entries(s).forEach(([o,c])=>{b8(c,Jre(e,o),r,n)})})},Jre=(t,e)=>{let r=t;return e.split(SH).forEach(n=>{r.nextPart.has(n)||r.nextPart.set(n,{nextPart:new Map,validators:[]}),r=r.nextPart.get(n)}),r},q4e=t=>t.isThemeGetter,G4e=(t,e)=>e?t.map(([r,n])=>{const s=n.map(o=>typeof o=="string"?e+o:typeof o=="object"?Object.fromEntries(Object.entries(o).map(([c,a])=>[e+c,a])):o);return[r,s]}):t,H4e=t=>{if(t<1)return{get:()=>{},set:()=>{}};let e=0,r=new Map,n=new Map;const s=(o,c)=>{r.set(o,c),e++,e>t&&(e=0,n=r,r=new Map)};return{get(o){let c=r.get(o);if(c!==void 0)return c;if((c=n.get(o))!==void 0)return s(o,c),c},set(o,c){r.has(o)?r.set(o,c):s(o,c)}}},pye="!",W4e=t=>{const{separator:e,experimentalParseClassName:r}=t,n=e.length===1,s=e[0],o=e.length,c=a=>{const f=[];let m=0,y=0,_;for(let I=0;Iy?_-y:void 0;return{modifiers:f,hasImportantModifier:E,baseClassName:A,maybePostfixModifierPosition:C}};return r?a=>r({className:a,parseClassName:c}):c},K4e=t=>{if(t.length<=1)return t;const e=[];let r=[];return t.forEach(n=>{n[0]==="["?(e.push(...r.sort(),n),r=[]):r.push(n)}),e.push(...r.sort()),e},Y4e=t=>({cache:H4e(t.cacheSize),parseClassName:W4e(t),...z4e(t)}),Z4e=/\s+/,X4e=(t,e)=>{const{parseClassName:r,getClassGroupId:n,getConflictingClassGroupIds:s}=e,o=[],c=t.trim().split(Z4e);let a="";for(let f=c.length-1;f>=0;f-=1){const m=c[f],{modifiers:y,hasImportantModifier:_,baseClassName:w,maybePostfixModifierPosition:E}=r(m);let A=!!E,C=n(A?w.substring(0,E):w);if(!C){if(!A){a=m+(a.length>0?" "+a:a);continue}if(C=n(w),!C){a=m+(a.length>0?" "+a:a);continue}A=!1}const I=K4e(y).join(":"),M=_?I+pye:I,D=M+C;if(o.includes(D))continue;o.push(D);const B=s(C,A);for(let U=0;U0?" "+a:a)}return a};function Q4e(){let t=0,e,r,n="";for(;t{if(typeof t=="string")return t;let e,r="";for(let n=0;n_(y),t());return r=Y4e(m),n=r.cache.get,s=r.cache.set,o=a,a(f)}function a(f){const m=n(f);if(m)return m;const y=X4e(f,r);return s(f,y),y}return function(){return o(Q4e.apply(null,arguments))}}const $a=t=>{const e=r=>r[t]||[];return e.isThemeGetter=!0,e},yye=/^\[(?:([a-z-]+):)?(.+)\]$/i,eFe=/^\d+\/\d+$/,tFe=new Set(["px","full","screen"]),rFe=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,nFe=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,sFe=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,iFe=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,aFe=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,qp=t=>oS(t)||tFe.has(t)||eFe.test(t),Ry=t=>qT(t,"length",mFe),oS=t=>!!t&&!Number.isNaN(Number(t)),Rz=t=>qT(t,"number",oS),K2=t=>!!t&&Number.isInteger(Number(t)),oFe=t=>t.endsWith("%")&&oS(t.slice(0,-1)),qs=t=>yye.test(t),Ly=t=>rFe.test(t),lFe=new Set(["length","size","percentage"]),cFe=t=>qT(t,lFe,xye),uFe=t=>qT(t,"position",xye),dFe=new Set(["image","url"]),hFe=t=>qT(t,dFe,gFe),fFe=t=>qT(t,"",pFe),Y2=()=>!0,qT=(t,e,r)=>{const n=yye.exec(t);return n?n[1]?typeof e=="string"?n[1]===e:e.has(n[1]):r(n[2]):!1},mFe=t=>nFe.test(t)&&!sFe.test(t),xye=()=>!1,pFe=t=>iFe.test(t),gFe=t=>aFe.test(t),yFe=()=>{const t=$a("colors"),e=$a("spacing"),r=$a("blur"),n=$a("brightness"),s=$a("borderColor"),o=$a("borderRadius"),c=$a("borderSpacing"),a=$a("borderWidth"),f=$a("contrast"),m=$a("grayscale"),y=$a("hueRotate"),_=$a("invert"),w=$a("gap"),E=$a("gradientColorStops"),A=$a("gradientColorStopPositions"),C=$a("inset"),I=$a("margin"),M=$a("opacity"),D=$a("padding"),B=$a("saturate"),U=$a("scale"),q=$a("sepia"),H=$a("skew"),K=$a("space"),Q=$a("translate"),J=()=>["auto","contain","none"],ee=()=>["auto","hidden","clip","visible","scroll"],oe=()=>["auto",qs,e],de=()=>[qs,e],ye=()=>["",qp,Ry],Ee=()=>["auto",oS,qs],Le=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],Se=()=>["solid","dashed","dotted","double","none"],be=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],me=()=>["start","end","center","between","around","evenly","stretch"],ke=()=>["","0",qs],Pe=()=>["auto","avoid","all","avoid-page","page","left","right","column"],je=()=>[oS,qs];return{cacheSize:500,separator:":",theme:{colors:[Y2],spacing:[qp,Ry],blur:["none","",Ly,qs],brightness:je(),borderColor:[t],borderRadius:["none","","full",Ly,qs],borderSpacing:de(),borderWidth:ye(),contrast:je(),grayscale:ke(),hueRotate:je(),invert:ke(),gap:de(),gradientColorStops:[t],gradientColorStopPositions:[oFe,Ry],inset:oe(),margin:oe(),opacity:je(),padding:de(),saturate:je(),scale:je(),sepia:ke(),skew:je(),space:de(),translate:de()},classGroups:{aspect:[{aspect:["auto","square","video",qs]}],container:["container"],columns:[{columns:[Ly]}],"break-after":[{"break-after":Pe()}],"break-before":[{"break-before":Pe()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...Le(),qs]}],overflow:[{overflow:ee()}],"overflow-x":[{"overflow-x":ee()}],"overflow-y":[{"overflow-y":ee()}],overscroll:[{overscroll:J()}],"overscroll-x":[{"overscroll-x":J()}],"overscroll-y":[{"overscroll-y":J()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[C]}],"inset-x":[{"inset-x":[C]}],"inset-y":[{"inset-y":[C]}],start:[{start:[C]}],end:[{end:[C]}],top:[{top:[C]}],right:[{right:[C]}],bottom:[{bottom:[C]}],left:[{left:[C]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",K2,qs]}],basis:[{basis:oe()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",qs]}],grow:[{grow:ke()}],shrink:[{shrink:ke()}],order:[{order:["first","last","none",K2,qs]}],"grid-cols":[{"grid-cols":[Y2]}],"col-start-end":[{col:["auto",{span:["full",K2,qs]},qs]}],"col-start":[{"col-start":Ee()}],"col-end":[{"col-end":Ee()}],"grid-rows":[{"grid-rows":[Y2]}],"row-start-end":[{row:["auto",{span:[K2,qs]},qs]}],"row-start":[{"row-start":Ee()}],"row-end":[{"row-end":Ee()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",qs]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",qs]}],gap:[{gap:[w]}],"gap-x":[{"gap-x":[w]}],"gap-y":[{"gap-y":[w]}],"justify-content":[{justify:["normal",...me()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...me(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...me(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[D]}],px:[{px:[D]}],py:[{py:[D]}],ps:[{ps:[D]}],pe:[{pe:[D]}],pt:[{pt:[D]}],pr:[{pr:[D]}],pb:[{pb:[D]}],pl:[{pl:[D]}],m:[{m:[I]}],mx:[{mx:[I]}],my:[{my:[I]}],ms:[{ms:[I]}],me:[{me:[I]}],mt:[{mt:[I]}],mr:[{mr:[I]}],mb:[{mb:[I]}],ml:[{ml:[I]}],"space-x":[{"space-x":[K]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[K]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",qs,e]}],"min-w":[{"min-w":[qs,e,"min","max","fit"]}],"max-w":[{"max-w":[qs,e,"none","full","min","max","fit","prose",{screen:[Ly]},Ly]}],h:[{h:[qs,e,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[qs,e,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[qs,e,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[qs,e,"auto","min","max","fit"]}],"font-size":[{text:["base",Ly,Ry]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",Rz]}],"font-family":[{font:[Y2]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",qs]}],"line-clamp":[{"line-clamp":["none",oS,Rz]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",qp,qs]}],"list-image":[{"list-image":["none",qs]}],"list-style-type":[{list:["none","disc","decimal",qs]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[t]}],"placeholder-opacity":[{"placeholder-opacity":[M]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[t]}],"text-opacity":[{"text-opacity":[M]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...Se(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",qp,Ry]}],"underline-offset":[{"underline-offset":["auto",qp,qs]}],"text-decoration-color":[{decoration:[t]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:de()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",qs]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",qs]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[M]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...Le(),uFe]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",cFe]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},hFe]}],"bg-color":[{bg:[t]}],"gradient-from-pos":[{from:[A]}],"gradient-via-pos":[{via:[A]}],"gradient-to-pos":[{to:[A]}],"gradient-from":[{from:[E]}],"gradient-via":[{via:[E]}],"gradient-to":[{to:[E]}],rounded:[{rounded:[o]}],"rounded-s":[{"rounded-s":[o]}],"rounded-e":[{"rounded-e":[o]}],"rounded-t":[{"rounded-t":[o]}],"rounded-r":[{"rounded-r":[o]}],"rounded-b":[{"rounded-b":[o]}],"rounded-l":[{"rounded-l":[o]}],"rounded-ss":[{"rounded-ss":[o]}],"rounded-se":[{"rounded-se":[o]}],"rounded-ee":[{"rounded-ee":[o]}],"rounded-es":[{"rounded-es":[o]}],"rounded-tl":[{"rounded-tl":[o]}],"rounded-tr":[{"rounded-tr":[o]}],"rounded-br":[{"rounded-br":[o]}],"rounded-bl":[{"rounded-bl":[o]}],"border-w":[{border:[a]}],"border-w-x":[{"border-x":[a]}],"border-w-y":[{"border-y":[a]}],"border-w-s":[{"border-s":[a]}],"border-w-e":[{"border-e":[a]}],"border-w-t":[{"border-t":[a]}],"border-w-r":[{"border-r":[a]}],"border-w-b":[{"border-b":[a]}],"border-w-l":[{"border-l":[a]}],"border-opacity":[{"border-opacity":[M]}],"border-style":[{border:[...Se(),"hidden"]}],"divide-x":[{"divide-x":[a]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[a]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[M]}],"divide-style":[{divide:Se()}],"border-color":[{border:[s]}],"border-color-x":[{"border-x":[s]}],"border-color-y":[{"border-y":[s]}],"border-color-s":[{"border-s":[s]}],"border-color-e":[{"border-e":[s]}],"border-color-t":[{"border-t":[s]}],"border-color-r":[{"border-r":[s]}],"border-color-b":[{"border-b":[s]}],"border-color-l":[{"border-l":[s]}],"divide-color":[{divide:[s]}],"outline-style":[{outline:["",...Se()]}],"outline-offset":[{"outline-offset":[qp,qs]}],"outline-w":[{outline:[qp,Ry]}],"outline-color":[{outline:[t]}],"ring-w":[{ring:ye()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[t]}],"ring-opacity":[{"ring-opacity":[M]}],"ring-offset-w":[{"ring-offset":[qp,Ry]}],"ring-offset-color":[{"ring-offset":[t]}],shadow:[{shadow:["","inner","none",Ly,fFe]}],"shadow-color":[{shadow:[Y2]}],opacity:[{opacity:[M]}],"mix-blend":[{"mix-blend":[...be(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":be()}],filter:[{filter:["","none"]}],blur:[{blur:[r]}],brightness:[{brightness:[n]}],contrast:[{contrast:[f]}],"drop-shadow":[{"drop-shadow":["","none",Ly,qs]}],grayscale:[{grayscale:[m]}],"hue-rotate":[{"hue-rotate":[y]}],invert:[{invert:[_]}],saturate:[{saturate:[B]}],sepia:[{sepia:[q]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[r]}],"backdrop-brightness":[{"backdrop-brightness":[n]}],"backdrop-contrast":[{"backdrop-contrast":[f]}],"backdrop-grayscale":[{"backdrop-grayscale":[m]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[y]}],"backdrop-invert":[{"backdrop-invert":[_]}],"backdrop-opacity":[{"backdrop-opacity":[M]}],"backdrop-saturate":[{"backdrop-saturate":[B]}],"backdrop-sepia":[{"backdrop-sepia":[q]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[c]}],"border-spacing-x":[{"border-spacing-x":[c]}],"border-spacing-y":[{"border-spacing-y":[c]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",qs]}],duration:[{duration:je()}],ease:[{ease:["linear","in","out","in-out",qs]}],delay:[{delay:je()}],animate:[{animate:["none","spin","ping","pulse","bounce",qs]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[U]}],"scale-x":[{"scale-x":[U]}],"scale-y":[{"scale-y":[U]}],rotate:[{rotate:[K2,qs]}],"translate-x":[{"translate-x":[Q]}],"translate-y":[{"translate-y":[Q]}],"skew-x":[{"skew-x":[H]}],"skew-y":[{"skew-y":[H]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",qs]}],accent:[{accent:["auto",t]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",qs]}],"caret-color":[{caret:[t]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":de()}],"scroll-mx":[{"scroll-mx":de()}],"scroll-my":[{"scroll-my":de()}],"scroll-ms":[{"scroll-ms":de()}],"scroll-me":[{"scroll-me":de()}],"scroll-mt":[{"scroll-mt":de()}],"scroll-mr":[{"scroll-mr":de()}],"scroll-mb":[{"scroll-mb":de()}],"scroll-ml":[{"scroll-ml":de()}],"scroll-p":[{"scroll-p":de()}],"scroll-px":[{"scroll-px":de()}],"scroll-py":[{"scroll-py":de()}],"scroll-ps":[{"scroll-ps":de()}],"scroll-pe":[{"scroll-pe":de()}],"scroll-pt":[{"scroll-pt":de()}],"scroll-pr":[{"scroll-pr":de()}],"scroll-pb":[{"scroll-pb":de()}],"scroll-pl":[{"scroll-pl":de()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",qs]}],fill:[{fill:[t,"none"]}],"stroke-w":[{stroke:[qp,Ry,Rz]}],stroke:[{stroke:[t,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}},xFe=J4e(yFe);function Xt(...t){return xFe(Ws(t))}function Xa(t,e=!1){return e&&t>=1e6?`$${(t/1e6).toFixed(1)}M`:e&&t>=1e3?`$${(t/1e3).toFixed(0)}K`:new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:0,maximumFractionDigits:0}).format(t)}function ene(t){const e=new Date(t);return new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",year:"numeric"}).format(e)}function dQt(t){return t?t.replace(/<[^>]*>/g,""):""}const _Fe=Z3e,_ye=N.forwardRef(({className:t,...e},r)=>i.jsx(qge,{ref:r,className:Xt("fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]",t),...e}));_ye.displayName=qge.displayName;const vFe=zT("group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-8 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",{variants:{variant:{default:"border bg-background text-foreground",destructive:"destructive group border-destructive bg-destructive text-destructive-foreground"}},defaultVariants:{variant:"default"}}),vye=N.forwardRef(({className:t,variant:e,...r},n)=>i.jsx(Gge,{ref:n,className:Xt(vFe({variant:e}),t),...r}));vye.displayName=Gge.displayName;const bFe=N.forwardRef(({className:t,...e},r)=>i.jsx(Kge,{ref:r,className:Xt("inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors group-[.destructive]:border-muted/40 hover:bg-secondary group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 group-[.destructive]:focus:ring-destructive disabled:pointer-events-none disabled:opacity-50",t),...e}));bFe.displayName=Kge.displayName;const bye=N.forwardRef(({className:t,...e},r)=>i.jsx(Yge,{ref:r,className:Xt("absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity group-hover:opacity-100 group-[.destructive]:text-red-300 hover:text-foreground group-[.destructive]:hover:text-red-50 focus:opacity-100 focus:outline-none focus:ring-2 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",t),"toast-close":"",...e,children:i.jsx(Ci,{className:"h-4 w-4"})}));bye.displayName=Yge.displayName;const wye=N.forwardRef(({className:t,...e},r)=>i.jsx(Hge,{ref:r,className:Xt("text-sm font-semibold",t),...e}));wye.displayName=Hge.displayName;const Sye=N.forwardRef(({className:t,...e},r)=>i.jsx(Wge,{ref:r,className:Xt("text-sm opacity-90",t),...e}));Sye.displayName=Wge.displayName;function wFe(){const{toasts:t}=Sge();return i.jsxs(_Fe,{children:[t.map(function({id:e,title:r,description:n,action:s,...o}){return i.jsxs(vye,{...o,children:[i.jsxs("div",{className:"grid gap-1",children:[r&&i.jsx(wye,{children:r}),n&&i.jsx(Sye,{children:n})]}),s,i.jsx(bye,{})]},e)}),i.jsx(_ye,{})]})}var tne=["light","dark"],SFe="(prefers-color-scheme: dark)",TFe=N.createContext(void 0),EFe={setTheme:t=>{},themes:[]},jFe=()=>{var t;return(t=N.useContext(TFe))!=null?t:EFe};N.memo(({forcedTheme:t,storageKey:e,attribute:r,enableSystem:n,enableColorScheme:s,defaultTheme:o,value:c,attrs:a,nonce:f})=>{let m=o==="system",y=r==="class"?`var d=document.documentElement,c=d.classList;${`c.remove(${a.map(A=>`'${A}'`).join(",")})`};`:`var d=document.documentElement,n='${r}',s='setAttribute';`,_=s?tne.includes(o)&&o?`if(e==='light'||e==='dark'||!e)d.style.colorScheme=e||'${o}'`:"if(e==='light'||e==='dark')d.style.colorScheme=e":"",w=(A,C=!1,I=!0)=>{let M=c?c[A]:A,D=C?A+"|| ''":`'${M}'`,B="";return s&&I&&!C&&tne.includes(A)&&(B+=`d.style.colorScheme = '${A}';`),r==="class"?C||M?B+=`c.add(${D})`:B+="null":M&&(B+=`d[s](n,${D})`),B},E=t?`!function(){${y}${w(t)}}()`:n?`!function(){try{${y}var e=localStorage.getItem('${e}');if('system'===e||(!e&&${m})){var t='${SFe}',m=window.matchMedia(t);if(m.media!==t||m.matches){${w("dark")}}else{${w("light")}}}else if(e){${c?`var x=${JSON.stringify(c)};`:""}${w(c?"x[e]":"e",!0)}}${m?"":"else{"+w(o,!1,!1)+"}"}${_}}catch(e){}}()`:`!function(){try{${y}var e=localStorage.getItem('${e}');if(e){${c?`var x=${JSON.stringify(c)};`:""}${w(c?"x[e]":"e",!0)}}else{${w(o,!1,!1)};}${_}}catch(t){}}();`;return N.createElement("script",{nonce:f,dangerouslySetInnerHTML:{__html:E}})});var kFe=t=>{switch(t){case"success":return CFe;case"info":return PFe;case"warning":return IFe;case"error":return RFe;default:return null}},AFe=Array(12).fill(0),NFe=({visible:t,className:e})=>Qe.createElement("div",{className:["sonner-loading-wrapper",e].filter(Boolean).join(" "),"data-visible":t},Qe.createElement("div",{className:"sonner-spinner"},AFe.map((r,n)=>Qe.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${n}`})))),CFe=Qe.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},Qe.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),IFe=Qe.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},Qe.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),PFe=Qe.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},Qe.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),RFe=Qe.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},Qe.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),LFe=Qe.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},Qe.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),Qe.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),MFe=()=>{let[t,e]=Qe.useState(document.hidden);return Qe.useEffect(()=>{let r=()=>{e(document.hidden)};return document.addEventListener("visibilitychange",r),()=>window.removeEventListener("visibilitychange",r)},[]),t},w8=1,DFe=class{constructor(){this.subscribe=t=>(this.subscribers.push(t),()=>{let e=this.subscribers.indexOf(t);this.subscribers.splice(e,1)}),this.publish=t=>{this.subscribers.forEach(e=>e(t))},this.addToast=t=>{this.publish(t),this.toasts=[...this.toasts,t]},this.create=t=>{var e;let{message:r,...n}=t,s=typeof(t==null?void 0:t.id)=="number"||((e=t.id)==null?void 0:e.length)>0?t.id:w8++,o=this.toasts.find(a=>a.id===s),c=t.dismissible===void 0?!0:t.dismissible;return this.dismissedToasts.has(s)&&this.dismissedToasts.delete(s),o?this.toasts=this.toasts.map(a=>a.id===s?(this.publish({...a,...t,id:s,title:r}),{...a,...t,id:s,dismissible:c,title:r}):a):this.addToast({title:r,...n,dismissible:c,id:s}),s},this.dismiss=t=>(this.dismissedToasts.add(t),t||this.toasts.forEach(e=>{this.subscribers.forEach(r=>r({id:e.id,dismiss:!0}))}),this.subscribers.forEach(e=>e({id:t,dismiss:!0})),t),this.message=(t,e)=>this.create({...e,message:t}),this.error=(t,e)=>this.create({...e,message:t,type:"error"}),this.success=(t,e)=>this.create({...e,type:"success",message:t}),this.info=(t,e)=>this.create({...e,type:"info",message:t}),this.warning=(t,e)=>this.create({...e,type:"warning",message:t}),this.loading=(t,e)=>this.create({...e,type:"loading",message:t}),this.promise=(t,e)=>{if(!e)return;let r;e.loading!==void 0&&(r=this.create({...e,promise:t,type:"loading",message:e.loading,description:typeof e.description!="function"?e.description:void 0}));let n=t instanceof Promise?t:t(),s=r!==void 0,o,c=n.then(async f=>{if(o=["resolve",f],Qe.isValidElement(f))s=!1,this.create({id:r,type:"default",message:f});else if(FFe(f)&&!f.ok){s=!1;let m=typeof e.error=="function"?await e.error(`HTTP error! status: ${f.status}`):e.error,y=typeof e.description=="function"?await e.description(`HTTP error! status: ${f.status}`):e.description;this.create({id:r,type:"error",message:m,description:y})}else if(e.success!==void 0){s=!1;let m=typeof e.success=="function"?await e.success(f):e.success,y=typeof e.description=="function"?await e.description(f):e.description;this.create({id:r,type:"success",message:m,description:y})}}).catch(async f=>{if(o=["reject",f],e.error!==void 0){s=!1;let m=typeof e.error=="function"?await e.error(f):e.error,y=typeof e.description=="function"?await e.description(f):e.description;this.create({id:r,type:"error",message:m,description:y})}}).finally(()=>{var f;s&&(this.dismiss(r),r=void 0),(f=e.finally)==null||f.call(e)}),a=()=>new Promise((f,m)=>c.then(()=>o[0]==="reject"?m(o[1]):f(o[1])).catch(m));return typeof r!="string"&&typeof r!="number"?{unwrap:a}:Object.assign(r,{unwrap:a})},this.custom=(t,e)=>{let r=(e==null?void 0:e.id)||w8++;return this.create({jsx:t(r),id:r,...e}),r},this.getActiveToasts=()=>this.toasts.filter(t=>!this.dismissedToasts.has(t.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},Vu=new DFe,OFe=(t,e)=>{let r=(e==null?void 0:e.id)||w8++;return Vu.addToast({title:t,...e,id:r}),r},FFe=t=>t&&typeof t=="object"&&"ok"in t&&typeof t.ok=="boolean"&&"status"in t&&typeof t.status=="number",BFe=OFe,$Fe=()=>Vu.toasts,zFe=()=>Vu.getActiveToasts(),$t=Object.assign(BFe,{success:Vu.success,info:Vu.info,warning:Vu.warning,error:Vu.error,custom:Vu.custom,message:Vu.message,promise:Vu.promise,dismiss:Vu.dismiss,loading:Vu.loading},{getHistory:$Fe,getToasts:zFe});function UFe(t,{insertAt:e}={}){if(typeof document>"u")return;let r=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css",e==="top"&&r.firstChild?r.insertBefore(n,r.firstChild):r.appendChild(n),n.styleSheet?n.styleSheet.cssText=t:n.appendChild(document.createTextNode(t))}UFe(`:where(html[dir="ltr"]),:where([data-sonner-toaster][dir="ltr"]){--toast-icon-margin-start: -3px;--toast-icon-margin-end: 4px;--toast-svg-margin-start: -1px;--toast-svg-margin-end: 0px;--toast-button-margin-start: auto;--toast-button-margin-end: 0;--toast-close-button-start: 0;--toast-close-button-end: unset;--toast-close-button-transform: translate(-35%, -35%)}:where(html[dir="rtl"]),:where([data-sonner-toaster][dir="rtl"]){--toast-icon-margin-start: 4px;--toast-icon-margin-end: -3px;--toast-svg-margin-start: 0px;--toast-svg-margin-end: -1px;--toast-button-margin-start: 0;--toast-button-margin-end: auto;--toast-close-button-start: unset;--toast-close-button-end: 0;--toast-close-button-transform: translate(35%, -35%)}:where([data-sonner-toaster]){position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1: hsl(0, 0%, 99%);--gray2: hsl(0, 0%, 97.3%);--gray3: hsl(0, 0%, 95.1%);--gray4: hsl(0, 0%, 93%);--gray5: hsl(0, 0%, 90.9%);--gray6: hsl(0, 0%, 88.7%);--gray7: hsl(0, 0%, 85.8%);--gray8: hsl(0, 0%, 78%);--gray9: hsl(0, 0%, 56.1%);--gray10: hsl(0, 0%, 52.3%);--gray11: hsl(0, 0%, 43.5%);--gray12: hsl(0, 0%, 9%);--border-radius: 8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:none;z-index:999999999;transition:transform .4s ease}:where([data-sonner-toaster][data-lifted="true"]){transform:translateY(-10px)}@media (hover: none) and (pointer: coarse){:where([data-sonner-toaster][data-lifted="true"]){transform:none}}:where([data-sonner-toaster][data-x-position="right"]){right:var(--offset-right)}:where([data-sonner-toaster][data-x-position="left"]){left:var(--offset-left)}:where([data-sonner-toaster][data-x-position="center"]){left:50%;transform:translate(-50%)}:where([data-sonner-toaster][data-y-position="top"]){top:var(--offset-top)}:where([data-sonner-toaster][data-y-position="bottom"]){bottom:var(--offset-bottom)}:where([data-sonner-toast]){--y: translateY(100%);--lift-amount: calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);filter:blur(0);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:none;overflow-wrap:anywhere}:where([data-sonner-toast][data-styled="true"]){padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px #0000001a;width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}:where([data-sonner-toast]:focus-visible){box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast][data-y-position="top"]){top:0;--y: translateY(-100%);--lift: 1;--lift-amount: calc(1 * var(--gap))}:where([data-sonner-toast][data-y-position="bottom"]){bottom:0;--y: translateY(100%);--lift: -1;--lift-amount: calc(var(--lift) * var(--gap))}:where([data-sonner-toast]) :where([data-description]){font-weight:400;line-height:1.4;color:inherit}:where([data-sonner-toast]) :where([data-title]){font-weight:500;line-height:1.5;color:inherit}:where([data-sonner-toast]) :where([data-icon]){display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}:where([data-sonner-toast][data-promise="true"]) :where([data-icon])>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}:where([data-sonner-toast]) :where([data-icon])>*{flex-shrink:0}:where([data-sonner-toast]) :where([data-icon]) svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}:where([data-sonner-toast]) :where([data-content]){display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;cursor:pointer;outline:none;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}:where([data-sonner-toast]) :where([data-button]):focus-visible{box-shadow:0 0 0 2px #0006}:where([data-sonner-toast]) :where([data-button]):first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}:where([data-sonner-toast]) :where([data-cancel]){color:var(--normal-text);background:rgba(0,0,0,.08)}:where([data-sonner-toast][data-theme="dark"]) :where([data-cancel]){background:rgba(255,255,255,.3)}:where([data-sonner-toast]) :where([data-close-button]){position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast] [data-close-button]{background:var(--gray1)}:where([data-sonner-toast]) :where([data-close-button]):focus-visible{box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast]) :where([data-disabled="true"]){cursor:not-allowed}:where([data-sonner-toast]):hover :where([data-close-button]):hover{background:var(--gray2);border-color:var(--gray5)}:where([data-sonner-toast][data-swiping="true"]):before{content:"";position:absolute;left:-50%;right:-50%;height:100%;z-index:-1}:where([data-sonner-toast][data-y-position="top"][data-swiping="true"]):before{bottom:50%;transform:scaleY(3) translateY(50%)}:where([data-sonner-toast][data-y-position="bottom"][data-swiping="true"]):before{top:50%;transform:scaleY(3) translateY(-50%)}:where([data-sonner-toast][data-swiping="false"][data-removed="true"]):before{content:"";position:absolute;inset:0;transform:scaleY(2)}:where([data-sonner-toast]):after{content:"";position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}:where([data-sonner-toast][data-mounted="true"]){--y: translateY(0);opacity:1}:where([data-sonner-toast][data-expanded="false"][data-front="false"]){--scale: var(--toasts-before) * .05 + 1;--y: translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}:where([data-sonner-toast])>*{transition:opacity .4s}:where([data-sonner-toast][data-expanded="false"][data-front="false"][data-styled="true"])>*{opacity:0}:where([data-sonner-toast][data-visible="false"]){opacity:0;pointer-events:none}:where([data-sonner-toast][data-mounted="true"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}:where([data-sonner-toast][data-removed="true"][data-front="true"][data-swipe-out="false"]){--y: translateY(calc(var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="false"]){--y: translateY(40%);opacity:0;transition:transform .5s,opacity .2s}:where([data-sonner-toast][data-removed="true"][data-front="false"]):before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y, 0px)) translate(var(--swipe-amount-x, 0px));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width: 600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-theme=light]{--normal-bg: #fff;--normal-border: var(--gray4);--normal-text: var(--gray12);--success-bg: hsl(143, 85%, 96%);--success-border: hsl(145, 92%, 91%);--success-text: hsl(140, 100%, 27%);--info-bg: hsl(208, 100%, 97%);--info-border: hsl(221, 91%, 91%);--info-text: hsl(210, 92%, 45%);--warning-bg: hsl(49, 100%, 97%);--warning-border: hsl(49, 91%, 91%);--warning-text: hsl(31, 92%, 45%);--error-bg: hsl(359, 100%, 97%);--error-border: hsl(359, 100%, 94%);--error-text: hsl(360, 100%, 45%)}[data-sonner-toaster][data-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg: #000;--normal-border: hsl(0, 0%, 20%);--normal-text: var(--gray1)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg: #fff;--normal-border: var(--gray3);--normal-text: var(--gray12)}[data-sonner-toaster][data-theme=dark]{--normal-bg: #000;--normal-bg-hover: hsl(0, 0%, 12%);--normal-border: hsl(0, 0%, 20%);--normal-border-hover: hsl(0, 0%, 25%);--normal-text: var(--gray1);--success-bg: hsl(150, 100%, 6%);--success-border: hsl(147, 100%, 12%);--success-text: hsl(150, 86%, 65%);--info-bg: hsl(215, 100%, 6%);--info-border: hsl(223, 100%, 12%);--info-text: hsl(216, 87%, 65%);--warning-bg: hsl(64, 100%, 6%);--warning-border: hsl(60, 100%, 12%);--warning-text: hsl(46, 87%, 65%);--error-bg: hsl(358, 76%, 10%);--error-border: hsl(357, 89%, 16%);--error-text: hsl(358, 100%, 81%)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success],[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info],[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning],[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error],[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size: 16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:nth-child(1){animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}to{opacity:.15}}@media (prefers-reduced-motion){[data-sonner-toast],[data-sonner-toast]>*,.sonner-loading-bar{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)} `);function QR(t){return t.label!==void 0}var VFe=3,qFe="32px",GFe="16px",rne=4e3,HFe=356,WFe=14,KFe=20,YFe=200;function nf(...t){return t.filter(Boolean).join(" ")}function ZFe(t){let[e,r]=t.split("-"),n=[];return e&&n.push(e),r&&n.push(r),n}var XFe=t=>{var e,r,n,s,o,c,a,f,m,y,_;let{invert:w,toast:E,unstyled:A,interacting:C,setHeights:I,visibleToasts:M,heights:D,index:B,toasts:U,expanded:q,removeToast:H,defaultRichColors:K,closeButton:Q,style:J,cancelButtonStyle:ee,actionButtonStyle:oe,className:de="",descriptionClassName:ye="",duration:Ee,position:Le,gap:Se,loadingIcon:be,expandByDefault:me,classNames:ke,icons:Pe,closeButtonAriaLabel:je="Close toast",pauseWhenPageIsHidden:xe}=t,[Ue,Ze]=Qe.useState(null),[lt,wt]=Qe.useState(null),[yt,gt]=Qe.useState(!1),[ft,kt]=Qe.useState(!1),[Vt,xt]=Qe.useState(!1),[or,Sr]=Qe.useState(!1),[rn,Rr]=Qe.useState(!1),[$r,qr]=Qe.useState(0),[Nn,tt]=Qe.useState(0),Tt=Qe.useRef(E.duration||Ee||rne),Zt=Qe.useRef(null),ar=Qe.useRef(null),Wt=B===0,Kt=B+1<=M,At=E.type,pr=E.dismissible!==!1,yn=E.className||"",Gn=E.descriptionClassName||"",Fn=Qe.useMemo(()=>D.findIndex(nn=>nn.toastId===E.id)||0,[D,E.id]),Rs=Qe.useMemo(()=>{var nn;return(nn=E.closeButton)!=null?nn:Q},[E.closeButton,Q]),sa=Qe.useMemo(()=>E.duration||Ee||rne,[E.duration,Ee]),gs=Qe.useRef(0),$i=Qe.useRef(0),Cr=Qe.useRef(0),Bn=Qe.useRef(null),[wi,ii]=Le.split("-"),ia=Qe.useMemo(()=>D.reduce((nn,Ln,ti)=>ti>=Fn?nn:nn+Ln.height,0),[D,Fn]),Xr=MFe(),un=E.invert||w,xn=At==="loading";$i.current=Qe.useMemo(()=>Fn*Se+ia,[Fn,ia]),Qe.useEffect(()=>{Tt.current=sa},[sa]),Qe.useEffect(()=>{gt(!0)},[]),Qe.useEffect(()=>{let nn=ar.current;if(nn){let Ln=nn.getBoundingClientRect().height;return tt(Ln),I(ti=>[{toastId:E.id,height:Ln,position:E.position},...ti]),()=>I(ti=>ti.filter(Wo=>Wo.toastId!==E.id))}},[I,E.id]),Qe.useLayoutEffect(()=>{if(!yt)return;let nn=ar.current,Ln=nn.style.height;nn.style.height="auto";let ti=nn.getBoundingClientRect().height;nn.style.height=Ln,tt(ti),I(Wo=>Wo.find(Us=>Us.toastId===E.id)?Wo.map(Us=>Us.toastId===E.id?{...Us,height:ti}:Us):[{toastId:E.id,height:ti,position:E.position},...Wo])},[yt,E.title,E.description,I,E.id]);let Qr=Qe.useCallback(()=>{kt(!0),qr($i.current),I(nn=>nn.filter(Ln=>Ln.toastId!==E.id)),setTimeout(()=>{H(E)},YFe)},[E,H,I,$i]);Qe.useEffect(()=>{if(E.promise&&At==="loading"||E.duration===1/0||E.type==="loading")return;let nn;return q||C||xe&&Xr?(()=>{if(Cr.current{var Ln;(Ln=E.onAutoClose)==null||Ln.call(E,E),Qr()},Tt.current)),()=>clearTimeout(nn)},[q,C,E,At,xe,Xr,Qr]),Qe.useEffect(()=>{E.delete&&Qr()},[Qr,E.delete]);function ls(){var nn,Ln,ti;return Pe!=null&&Pe.loading?Qe.createElement("div",{className:nf(ke==null?void 0:ke.loader,(nn=E==null?void 0:E.classNames)==null?void 0:nn.loader,"sonner-loader"),"data-visible":At==="loading"},Pe.loading):be?Qe.createElement("div",{className:nf(ke==null?void 0:ke.loader,(Ln=E==null?void 0:E.classNames)==null?void 0:Ln.loader,"sonner-loader"),"data-visible":At==="loading"},be):Qe.createElement(NFe,{className:nf(ke==null?void 0:ke.loader,(ti=E==null?void 0:E.classNames)==null?void 0:ti.loader),visible:At==="loading"})}return Qe.createElement("li",{tabIndex:0,ref:ar,className:nf(de,yn,ke==null?void 0:ke.toast,(e=E==null?void 0:E.classNames)==null?void 0:e.toast,ke==null?void 0:ke.default,ke==null?void 0:ke[At],(r=E==null?void 0:E.classNames)==null?void 0:r[At]),"data-sonner-toast":"","data-rich-colors":(n=E.richColors)!=null?n:K,"data-styled":!(E.jsx||E.unstyled||A),"data-mounted":yt,"data-promise":!!E.promise,"data-swiped":rn,"data-removed":ft,"data-visible":Kt,"data-y-position":wi,"data-x-position":ii,"data-index":B,"data-front":Wt,"data-swiping":Vt,"data-dismissible":pr,"data-type":At,"data-invert":un,"data-swipe-out":or,"data-swipe-direction":lt,"data-expanded":!!(q||me&&yt),style:{"--index":B,"--toasts-before":B,"--z-index":U.length-B,"--offset":`${ft?$r:$i.current}px`,"--initial-height":me?"auto":`${Nn}px`,...J,...E.style},onDragEnd:()=>{xt(!1),Ze(null),Bn.current=null},onPointerDown:nn=>{xn||!pr||(Zt.current=new Date,qr($i.current),nn.target.setPointerCapture(nn.pointerId),nn.target.tagName!=="BUTTON"&&(xt(!0),Bn.current={x:nn.clientX,y:nn.clientY}))},onPointerUp:()=>{var nn,Ln,ti,Wo;if(or||!pr)return;Bn.current=null;let Us=Number(((nn=ar.current)==null?void 0:nn.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),Ft=Number(((Ln=ar.current)==null?void 0:Ln.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),So=new Date().getTime()-((ti=Zt.current)==null?void 0:ti.getTime()),bs=Ue==="x"?Us:Ft,gi=Math.abs(bs)/So;if(Math.abs(bs)>=KFe||gi>.11){qr($i.current),(Wo=E.onDismiss)==null||Wo.call(E,E),wt(Ue==="x"?Us>0?"right":"left":Ft>0?"down":"up"),Qr(),Sr(!0),Rr(!1);return}xt(!1),Ze(null)},onPointerMove:nn=>{var Ln,ti,Wo,Us;if(!Bn.current||!pr||((Ln=window.getSelection())==null?void 0:Ln.toString().length)>0)return;let Ft=nn.clientY-Bn.current.y,So=nn.clientX-Bn.current.x,bs=(ti=t.swipeDirections)!=null?ti:ZFe(Le);!Ue&&(Math.abs(So)>1||Math.abs(Ft)>1)&&Ze(Math.abs(So)>Math.abs(Ft)?"x":"y");let gi={x:0,y:0};Ue==="y"?(bs.includes("top")||bs.includes("bottom"))&&(bs.includes("top")&&Ft<0||bs.includes("bottom")&&Ft>0)&&(gi.y=Ft):Ue==="x"&&(bs.includes("left")||bs.includes("right"))&&(bs.includes("left")&&So<0||bs.includes("right")&&So>0)&&(gi.x=So),(Math.abs(gi.x)>0||Math.abs(gi.y)>0)&&Rr(!0),(Wo=ar.current)==null||Wo.style.setProperty("--swipe-amount-x",`${gi.x}px`),(Us=ar.current)==null||Us.style.setProperty("--swipe-amount-y",`${gi.y}px`)}},Rs&&!E.jsx?Qe.createElement("button",{"aria-label":je,"data-disabled":xn,"data-close-button":!0,onClick:xn||!pr?()=>{}:()=>{var nn;Qr(),(nn=E.onDismiss)==null||nn.call(E,E)},className:nf(ke==null?void 0:ke.closeButton,(s=E==null?void 0:E.classNames)==null?void 0:s.closeButton)},(o=Pe==null?void 0:Pe.close)!=null?o:LFe):null,E.jsx||N.isValidElement(E.title)?E.jsx?E.jsx:typeof E.title=="function"?E.title():E.title:Qe.createElement(Qe.Fragment,null,At||E.icon||E.promise?Qe.createElement("div",{"data-icon":"",className:nf(ke==null?void 0:ke.icon,(c=E==null?void 0:E.classNames)==null?void 0:c.icon)},E.promise||E.type==="loading"&&!E.icon?E.icon||ls():null,E.type!=="loading"?E.icon||(Pe==null?void 0:Pe[At])||kFe(At):null):null,Qe.createElement("div",{"data-content":"",className:nf(ke==null?void 0:ke.content,(a=E==null?void 0:E.classNames)==null?void 0:a.content)},Qe.createElement("div",{"data-title":"",className:nf(ke==null?void 0:ke.title,(f=E==null?void 0:E.classNames)==null?void 0:f.title)},typeof E.title=="function"?E.title():E.title),E.description?Qe.createElement("div",{"data-description":"",className:nf(ye,Gn,ke==null?void 0:ke.description,(m=E==null?void 0:E.classNames)==null?void 0:m.description)},typeof E.description=="function"?E.description():E.description):null),N.isValidElement(E.cancel)?E.cancel:E.cancel&&QR(E.cancel)?Qe.createElement("button",{"data-button":!0,"data-cancel":!0,style:E.cancelButtonStyle||ee,onClick:nn=>{var Ln,ti;QR(E.cancel)&&pr&&((ti=(Ln=E.cancel).onClick)==null||ti.call(Ln,nn),Qr())},className:nf(ke==null?void 0:ke.cancelButton,(y=E==null?void 0:E.classNames)==null?void 0:y.cancelButton)},E.cancel.label):null,N.isValidElement(E.action)?E.action:E.action&&QR(E.action)?Qe.createElement("button",{"data-button":!0,"data-action":!0,style:E.actionButtonStyle||oe,onClick:nn=>{var Ln,ti;QR(E.action)&&((ti=(Ln=E.action).onClick)==null||ti.call(Ln,nn),!nn.defaultPrevented&&Qr())},className:nf(ke==null?void 0:ke.actionButton,(_=E==null?void 0:E.classNames)==null?void 0:_.actionButton)},E.action.label):null))};function nne(){if(typeof window>"u"||typeof document>"u")return"ltr";let t=document.documentElement.getAttribute("dir");return t==="auto"||!t?window.getComputedStyle(document.documentElement).direction:t}function QFe(t,e){let r={};return[t,e].forEach((n,s)=>{let o=s===1,c=o?"--mobile-offset":"--offset",a=o?GFe:qFe;function f(m){["top","right","bottom","left"].forEach(y=>{r[`${c}-${y}`]=typeof m=="number"?`${m}px`:m})}typeof n=="number"||typeof n=="string"?f(n):typeof n=="object"?["top","right","bottom","left"].forEach(m=>{n[m]===void 0?r[`${c}-${m}`]=a:r[`${c}-${m}`]=typeof n[m]=="number"?`${n[m]}px`:n[m]}):f(a)}),r}var JFe=N.forwardRef(function(t,e){let{invert:r,position:n="bottom-right",hotkey:s=["altKey","KeyT"],expand:o,closeButton:c,className:a,offset:f,mobileOffset:m,theme:y="light",richColors:_,duration:w,style:E,visibleToasts:A=VFe,toastOptions:C,dir:I=nne(),gap:M=WFe,loadingIcon:D,icons:B,containerAriaLabel:U="Notifications",pauseWhenPageIsHidden:q}=t,[H,K]=Qe.useState([]),Q=Qe.useMemo(()=>Array.from(new Set([n].concat(H.filter(xe=>xe.position).map(xe=>xe.position)))),[H,n]),[J,ee]=Qe.useState([]),[oe,de]=Qe.useState(!1),[ye,Ee]=Qe.useState(!1),[Le,Se]=Qe.useState(y!=="system"?y:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),be=Qe.useRef(null),me=s.join("+").replace(/Key/g,"").replace(/Digit/g,""),ke=Qe.useRef(null),Pe=Qe.useRef(!1),je=Qe.useCallback(xe=>{K(Ue=>{var Ze;return(Ze=Ue.find(lt=>lt.id===xe.id))!=null&&Ze.delete||Vu.dismiss(xe.id),Ue.filter(({id:lt})=>lt!==xe.id)})},[]);return Qe.useEffect(()=>Vu.subscribe(xe=>{if(xe.dismiss){K(Ue=>Ue.map(Ze=>Ze.id===xe.id?{...Ze,delete:!0}:Ze));return}setTimeout(()=>{_ge.flushSync(()=>{K(Ue=>{let Ze=Ue.findIndex(lt=>lt.id===xe.id);return Ze!==-1?[...Ue.slice(0,Ze),{...Ue[Ze],...xe},...Ue.slice(Ze+1)]:[xe,...Ue]})})})}),[]),Qe.useEffect(()=>{if(y!=="system"){Se(y);return}if(y==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?Se("dark"):Se("light")),typeof window>"u")return;let xe=window.matchMedia("(prefers-color-scheme: dark)");try{xe.addEventListener("change",({matches:Ue})=>{Se(Ue?"dark":"light")})}catch{xe.addListener(({matches:Ze})=>{try{Se(Ze?"dark":"light")}catch(lt){console.error(lt)}})}},[y]),Qe.useEffect(()=>{H.length<=1&&de(!1)},[H]),Qe.useEffect(()=>{let xe=Ue=>{var Ze,lt;s.every(wt=>Ue[wt]||Ue.code===wt)&&(de(!0),(Ze=be.current)==null||Ze.focus()),Ue.code==="Escape"&&(document.activeElement===be.current||(lt=be.current)!=null&<.contains(document.activeElement))&&de(!1)};return document.addEventListener("keydown",xe),()=>document.removeEventListener("keydown",xe)},[s]),Qe.useEffect(()=>{if(be.current)return()=>{ke.current&&(ke.current.focus({preventScroll:!0}),ke.current=null,Pe.current=!1)}},[be.current]),Qe.createElement("section",{ref:e,"aria-label":`${U} ${me}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},Q.map((xe,Ue)=>{var Ze;let[lt,wt]=xe.split("-");return H.length?Qe.createElement("ol",{key:xe,dir:I==="auto"?nne():I,tabIndex:-1,ref:be,className:a,"data-sonner-toaster":!0,"data-theme":Le,"data-y-position":lt,"data-lifted":oe&&H.length>1&&!o,"data-x-position":wt,style:{"--front-toast-height":`${((Ze=J[0])==null?void 0:Ze.height)||0}px`,"--width":`${HFe}px`,"--gap":`${M}px`,...E,...QFe(f,m)},onBlur:yt=>{Pe.current&&!yt.currentTarget.contains(yt.relatedTarget)&&(Pe.current=!1,ke.current&&(ke.current.focus({preventScroll:!0}),ke.current=null))},onFocus:yt=>{yt.target instanceof HTMLElement&&yt.target.dataset.dismissible==="false"||Pe.current||(Pe.current=!0,ke.current=yt.relatedTarget)},onMouseEnter:()=>de(!0),onMouseMove:()=>de(!0),onMouseLeave:()=>{ye||de(!1)},onDragEnd:()=>de(!1),onPointerDown:yt=>{yt.target instanceof HTMLElement&&yt.target.dataset.dismissible==="false"||Ee(!0)},onPointerUp:()=>Ee(!1)},H.filter(yt=>!yt.position&&Ue===0||yt.position===xe).map((yt,gt)=>{var ft,kt;return Qe.createElement(XFe,{key:yt.id,icons:B,index:gt,toast:yt,defaultRichColors:_,duration:(ft=C==null?void 0:C.duration)!=null?ft:w,className:C==null?void 0:C.className,descriptionClassName:C==null?void 0:C.descriptionClassName,invert:r,visibleToasts:A,closeButton:(kt=C==null?void 0:C.closeButton)!=null?kt:c,interacting:ye,position:xe,style:C==null?void 0:C.style,unstyled:C==null?void 0:C.unstyled,classNames:C==null?void 0:C.classNames,cancelButtonStyle:C==null?void 0:C.cancelButtonStyle,actionButtonStyle:C==null?void 0:C.actionButtonStyle,removeToast:je,toasts:H.filter(Vt=>Vt.position==yt.position),heights:J.filter(Vt=>Vt.position==yt.position),setHeights:ee,expandByDefault:o,gap:M,loadingIcon:D,expanded:oe,pauseWhenPageIsHidden:q,swipeDirections:t.swipeDirections})})):null}))});const e5e=({...t})=>{const{theme:e="system"}=jFe();return i.jsx(JFe,{theme:e,position:"top-center",className:"toaster group",toastOptions:{classNames:{toast:"group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",description:"group-[.toast]:text-muted-foreground",actionButton:"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",cancelButton:"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground"}},...t})};var t5e=g7[" useId ".trim().toString()]||(()=>{}),r5e=0;function il(t){const[e,r]=N.useState(t5e());return qo(()=>{r(n=>n??String(r5e++))},[t]),e?`radix-${e}`:""}var Lz="focusScope.autoFocusOnMount",Mz="focusScope.autoFocusOnUnmount",sne={bubbles:!1,cancelable:!0},n5e="FocusScope",vC=N.forwardRef((t,e)=>{const{loop:r=!1,trapped:n=!1,onMountAutoFocus:s,onUnmountAutoFocus:o,...c}=t,[a,f]=N.useState(null),m=fo(s),y=fo(o),_=N.useRef(null),w=is(e,C=>f(C)),E=N.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;N.useEffect(()=>{if(n){let C=function(B){if(E.paused||!a)return;const U=B.target;a.contains(U)?_.current=U:Vy(_.current,{select:!0})},I=function(B){if(E.paused||!a)return;const U=B.relatedTarget;U!==null&&(a.contains(U)||Vy(_.current,{select:!0}))},M=function(B){if(document.activeElement===document.body)for(const q of B)q.removedNodes.length>0&&Vy(a)};document.addEventListener("focusin",C),document.addEventListener("focusout",I);const D=new MutationObserver(M);return a&&D.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",C),document.removeEventListener("focusout",I),D.disconnect()}}},[n,a,E.paused]),N.useEffect(()=>{if(a){ane.add(E);const C=document.activeElement;if(!a.contains(C)){const M=new CustomEvent(Lz,sne);a.addEventListener(Lz,m),a.dispatchEvent(M),M.defaultPrevented||(s5e(c5e(Tye(a)),{select:!0}),document.activeElement===C&&Vy(a))}return()=>{a.removeEventListener(Lz,m),setTimeout(()=>{const M=new CustomEvent(Mz,sne);a.addEventListener(Mz,y),a.dispatchEvent(M),M.defaultPrevented||Vy(C??document.body,{select:!0}),a.removeEventListener(Mz,y),ane.remove(E)},0)}}},[a,m,y,E]);const A=N.useCallback(C=>{if(!r&&!n||E.paused)return;const I=C.key==="Tab"&&!C.altKey&&!C.ctrlKey&&!C.metaKey,M=document.activeElement;if(I&&M){const D=C.currentTarget,[B,U]=i5e(D);B&&U?!C.shiftKey&&M===U?(C.preventDefault(),r&&Vy(B,{select:!0})):C.shiftKey&&M===B&&(C.preventDefault(),r&&Vy(U,{select:!0})):M===D&&C.preventDefault()}},[r,n,E.paused]);return i.jsx(cn.div,{tabIndex:-1,...c,ref:w,onKeyDown:A})});vC.displayName=n5e;function s5e(t,{select:e=!1}={}){const r=document.activeElement;for(const n of t)if(Vy(n,{select:e}),document.activeElement!==r)return}function i5e(t){const e=Tye(t),r=ine(e,t),n=ine(e.reverse(),t);return[r,n]}function Tye(t){const e=[],r=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:n=>{const s=n.tagName==="INPUT"&&n.type==="hidden";return n.disabled||n.hidden||s?NodeFilter.FILTER_SKIP:n.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;r.nextNode();)e.push(r.currentNode);return e}function ine(t,e){for(const r of t)if(!a5e(r,{upTo:e}))return r}function a5e(t,{upTo:e}){if(getComputedStyle(t).visibility==="hidden")return!0;for(;t;){if(e!==void 0&&t===e)return!1;if(getComputedStyle(t).display==="none")return!0;t=t.parentElement}return!1}function o5e(t){return t instanceof HTMLInputElement&&"select"in t}function Vy(t,{select:e=!1}={}){if(t&&t.focus){const r=document.activeElement;t.focus({preventScroll:!0}),t!==r&&o5e(t)&&e&&t.select()}}var ane=l5e();function l5e(){let t=[];return{add(e){const r=t[0];e!==r&&(r==null||r.pause()),t=one(t,e),t.unshift(e)},remove(e){var r;t=one(t,e),(r=t[0])==null||r.resume()}}}function one(t,e){const r=[...t],n=r.indexOf(e);return n!==-1&&r.splice(n,1),r}function c5e(t){return t.filter(e=>e.tagName!=="A")}var Dz=0;function u4(){N.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??lne()),document.body.insertAdjacentElement("beforeend",t[1]??lne()),Dz++,()=>{Dz===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),Dz--}},[])}function lne(){const t=document.createElement("span");return t.setAttribute("data-radix-focus-guard",""),t.tabIndex=0,t.style.outline="none",t.style.opacity="0",t.style.position="fixed",t.style.pointerEvents="none",t}var Rm=function(){return Rm=Object.assign||function(e){for(var r,n=1,s=arguments.length;n"u")return j5e;var e=k5e(t),r=document.documentElement.clientWidth,n=window.innerWidth;return{left:e[0],top:e[1],right:e[2],gap:Math.max(0,n-r+e[2]-e[0])}},N5e=Aye(),lS="data-scroll-locked",C5e=function(t,e,r,n){var s=t.left,o=t.top,c=t.right,a=t.gap;return r===void 0&&(r="margin"),` .`.concat(d5e,` { overflow: hidden `).concat(n,`; padding-right: `).concat(a,"px ").concat(n,`; } body[`).concat(lS,`] { overflow: hidden `).concat(n,`; overscroll-behavior: contain; `).concat([e&&"position: relative ".concat(n,";"),r==="margin"&&` padding-left: `.concat(s,`px; padding-top: `).concat(o,`px; padding-right: `).concat(c,`px; margin-left:0; margin-top:0; margin-right: `).concat(a,"px ").concat(n,`; `),r==="padding"&&"padding-right: ".concat(a,"px ").concat(n,";")].filter(Boolean).join(""),` } .`).concat(kM,` { right: `).concat(a,"px ").concat(n,`; } .`).concat(AM,` { margin-right: `).concat(a,"px ").concat(n,`; } .`).concat(kM," .").concat(kM,` { right: 0 `).concat(n,`; } .`).concat(AM," .").concat(AM,` { margin-right: 0 `).concat(n,`; } body[`).concat(lS,`] { `).concat(h5e,": ").concat(a,`px; } `)},une=function(){var t=parseInt(document.body.getAttribute(lS)||"0",10);return isFinite(t)?t:0},I5e=function(){N.useEffect(function(){return document.body.setAttribute(lS,(une()+1).toString()),function(){var t=une()-1;t<=0?document.body.removeAttribute(lS):document.body.setAttribute(lS,t.toString())}},[])},P5e=function(t){var e=t.noRelative,r=t.noImportant,n=t.gapMode,s=n===void 0?"margin":n;I5e();var o=N.useMemo(function(){return A5e(s)},[s]);return N.createElement(N5e,{styles:C5e(o,!e,s,r?"":"!important")})},S8=!1;if(typeof window<"u")try{var JR=Object.defineProperty({},"passive",{get:function(){return S8=!0,!0}});window.addEventListener("test",JR,JR),window.removeEventListener("test",JR,JR)}catch{S8=!1}var Ww=S8?{passive:!1}:!1,R5e=function(t){return t.tagName==="TEXTAREA"},Nye=function(t,e){if(!(t instanceof Element))return!1;var r=window.getComputedStyle(t);return r[e]!=="hidden"&&!(r.overflowY===r.overflowX&&!R5e(t)&&r[e]==="visible")},L5e=function(t){return Nye(t,"overflowY")},M5e=function(t){return Nye(t,"overflowX")},dne=function(t,e){var r=e.ownerDocument,n=e;do{typeof ShadowRoot<"u"&&n instanceof ShadowRoot&&(n=n.host);var s=Cye(t,n);if(s){var o=Iye(t,n),c=o[1],a=o[2];if(c>a)return!0}n=n.parentNode}while(n&&n!==r.body);return!1},D5e=function(t){var e=t.scrollTop,r=t.scrollHeight,n=t.clientHeight;return[e,r,n]},O5e=function(t){var e=t.scrollLeft,r=t.scrollWidth,n=t.clientWidth;return[e,r,n]},Cye=function(t,e){return t==="v"?L5e(e):M5e(e)},Iye=function(t,e){return t==="v"?D5e(e):O5e(e)},F5e=function(t,e){return t==="h"&&e==="rtl"?-1:1},B5e=function(t,e,r,n,s){var o=F5e(t,window.getComputedStyle(e).direction),c=o*n,a=r.target,f=e.contains(a),m=!1,y=c>0,_=0,w=0;do{if(!a)break;var E=Iye(t,a),A=E[0],C=E[1],I=E[2],M=C-I-o*A;(A||M)&&Cye(t,a)&&(_+=M,w+=A);var D=a.parentNode;a=D&&D.nodeType===Node.DOCUMENT_FRAGMENT_NODE?D.host:D}while(!f&&a!==document.body||f&&(e.contains(a)||e===a));return(y&&(Math.abs(_)<1||!s)||!y&&(Math.abs(w)<1||!s))&&(m=!0),m},eL=function(t){return"changedTouches"in t?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0]},hne=function(t){return[t.deltaX,t.deltaY]},fne=function(t){return t&&"current"in t?t.current:t},$5e=function(t,e){return t[0]===e[0]&&t[1]===e[1]},z5e=function(t){return` .block-interactivity-`.concat(t,` {pointer-events: none;} .allow-interactivity-`).concat(t,` {pointer-events: all;} `)},U5e=0,Kw=[];function V5e(t){var e=N.useRef([]),r=N.useRef([0,0]),n=N.useRef(),s=N.useState(U5e++)[0],o=N.useState(Aye)[0],c=N.useRef(t);N.useEffect(function(){c.current=t},[t]),N.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(s));var C=u5e([t.lockRef.current],(t.shards||[]).map(fne),!0).filter(Boolean);return C.forEach(function(I){return I.classList.add("allow-interactivity-".concat(s))}),function(){document.body.classList.remove("block-interactivity-".concat(s)),C.forEach(function(I){return I.classList.remove("allow-interactivity-".concat(s))})}}},[t.inert,t.lockRef.current,t.shards]);var a=N.useCallback(function(C,I){if("touches"in C&&C.touches.length===2||C.type==="wheel"&&C.ctrlKey)return!c.current.allowPinchZoom;var M=eL(C),D=r.current,B="deltaX"in C?C.deltaX:D[0]-M[0],U="deltaY"in C?C.deltaY:D[1]-M[1],q,H=C.target,K=Math.abs(B)>Math.abs(U)?"h":"v";if("touches"in C&&K==="h"&&H.type==="range")return!1;var Q=dne(K,H);if(!Q)return!0;if(Q?q=K:(q=K==="v"?"h":"v",Q=dne(K,H)),!Q)return!1;if(!n.current&&"changedTouches"in C&&(B||U)&&(n.current=q),!q)return!0;var J=n.current||q;return B5e(J,I,C,J==="h"?B:U,!0)},[]),f=N.useCallback(function(C){var I=C;if(!(!Kw.length||Kw[Kw.length-1]!==o)){var M="deltaY"in I?hne(I):eL(I),D=e.current.filter(function(q){return q.name===I.type&&(q.target===I.target||I.target===q.shadowParent)&&$5e(q.delta,M)})[0];if(D&&D.should){I.cancelable&&I.preventDefault();return}if(!D){var B=(c.current.shards||[]).map(fne).filter(Boolean).filter(function(q){return q.contains(I.target)}),U=B.length>0?a(I,B[0]):!c.current.noIsolation;U&&I.cancelable&&I.preventDefault()}}},[]),m=N.useCallback(function(C,I,M,D){var B={name:C,delta:I,target:M,should:D,shadowParent:q5e(M)};e.current.push(B),setTimeout(function(){e.current=e.current.filter(function(U){return U!==B})},1)},[]),y=N.useCallback(function(C){r.current=eL(C),n.current=void 0},[]),_=N.useCallback(function(C){m(C.type,hne(C),C.target,a(C,t.lockRef.current))},[]),w=N.useCallback(function(C){m(C.type,eL(C),C.target,a(C,t.lockRef.current))},[]);N.useEffect(function(){return Kw.push(o),t.setCallbacks({onScrollCapture:_,onWheelCapture:_,onTouchMoveCapture:w}),document.addEventListener("wheel",f,Ww),document.addEventListener("touchmove",f,Ww),document.addEventListener("touchstart",y,Ww),function(){Kw=Kw.filter(function(C){return C!==o}),document.removeEventListener("wheel",f,Ww),document.removeEventListener("touchmove",f,Ww),document.removeEventListener("touchstart",y,Ww)}},[]);var E=t.removeScrollBar,A=t.inert;return N.createElement(N.Fragment,null,A?N.createElement(o,{styles:z5e(s)}):null,E?N.createElement(P5e,{noRelative:t.noRelative,gapMode:t.gapMode}):null)}function q5e(t){for(var e=null;t!==null;)t instanceof ShadowRoot&&(e=t.host,t=t.host),t=t.parentNode;return e}const G5e=_5e(kye,V5e);var bC=N.forwardRef(function(t,e){return N.createElement(d4,Rm({},t,{ref:e,sideCar:G5e}))});bC.classNames=d4.classNames;var H5e=function(t){if(typeof document>"u")return null;var e=Array.isArray(t)?t[0]:t;return e.ownerDocument.body},Yw=new WeakMap,tL=new WeakMap,rL={},$z=0,Pye=function(t){return t&&(t.host||Pye(t.parentNode))},W5e=function(t,e){return e.map(function(r){if(t.contains(r))return r;var n=Pye(r);return n&&t.contains(n)?n:(console.error("aria-hidden",r,"in not contained inside",t,". Doing nothing"),null)}).filter(function(r){return!!r})},K5e=function(t,e,r,n){var s=W5e(e,Array.isArray(t)?t:[t]);rL[r]||(rL[r]=new WeakMap);var o=rL[r],c=[],a=new Set,f=new Set(s),m=function(_){!_||a.has(_)||(a.add(_),m(_.parentNode))};s.forEach(m);var y=function(_){!_||f.has(_)||Array.prototype.forEach.call(_.children,function(w){if(a.has(w))y(w);else try{var E=w.getAttribute(n),A=E!==null&&E!=="false",C=(Yw.get(w)||0)+1,I=(o.get(w)||0)+1;Yw.set(w,C),o.set(w,I),c.push(w),C===1&&A&&tL.set(w,!0),I===1&&w.setAttribute(r,"true"),A||w.setAttribute(n,"true")}catch(M){console.error("aria-hidden: cannot operate on ",w,M)}})};return y(e),a.clear(),$z++,function(){c.forEach(function(_){var w=Yw.get(_)-1,E=o.get(_)-1;Yw.set(_,w),o.set(_,E),w||(tL.has(_)||_.removeAttribute(n),tL.delete(_)),E||_.removeAttribute(r)}),$z--,$z||(Yw=new WeakMap,Yw=new WeakMap,tL=new WeakMap,rL={})}},h4=function(t,e,r){r===void 0&&(r="data-aria-hidden");var n=Array.from(Array.isArray(t)?t:[t]),s=H5e(t);return s?(n.push.apply(n,Array.from(s.querySelectorAll("[aria-live]"))),K5e(n,s,r,"aria-hidden")):function(){return null}},f4="Dialog",[Rye,Lye]=cl(f4),[Y5e,Uf]=Rye(f4),Mye=t=>{const{__scopeDialog:e,children:r,open:n,defaultOpen:s,onOpenChange:o,modal:c=!0}=t,a=N.useRef(null),f=N.useRef(null),[m,y]=ed({prop:n,defaultProp:s??!1,onChange:o,caller:f4});return i.jsx(Y5e,{scope:e,triggerRef:a,contentRef:f,contentId:il(),titleId:il(),descriptionId:il(),open:m,onOpenChange:y,onOpenToggle:N.useCallback(()=>y(_=>!_),[y]),modal:c,children:r})};Mye.displayName=f4;var Dye="DialogTrigger",Oye=N.forwardRef((t,e)=>{const{__scopeDialog:r,...n}=t,s=Uf(Dye,r),o=is(e,s.triggerRef);return i.jsx(cn.button,{type:"button","aria-haspopup":"dialog","aria-expanded":s.open,"aria-controls":s.contentId,"data-state":jH(s.open),...n,ref:o,onClick:Gr(t.onClick,s.onOpenToggle)})});Oye.displayName=Dye;var TH="DialogPortal",[Z5e,Fye]=Rye(TH,{forceMount:void 0}),Bye=t=>{const{__scopeDialog:e,forceMount:r,children:n,container:s}=t,o=Uf(TH,e);return i.jsx(Z5e,{scope:e,forceMount:r,children:N.Children.map(n,c=>i.jsx(Cl,{present:r||o.open,children:i.jsx($T,{asChild:!0,container:s,children:c})}))})};Bye.displayName=TH;var DD="DialogOverlay",$ye=N.forwardRef((t,e)=>{const r=Fye(DD,t.__scopeDialog),{forceMount:n=r.forceMount,...s}=t,o=Uf(DD,t.__scopeDialog);return o.modal?i.jsx(Cl,{present:n||o.open,children:i.jsx(Q5e,{...s,ref:e})}):null});$ye.displayName=DD;var X5e=Bx("DialogOverlay.RemoveScroll"),Q5e=N.forwardRef((t,e)=>{const{__scopeDialog:r,...n}=t,s=Uf(DD,r);return i.jsx(bC,{as:X5e,allowPinchZoom:!0,shards:[s.contentRef],children:i.jsx(cn.div,{"data-state":jH(s.open),...n,ref:e,style:{pointerEvents:"auto",...n.style}})})}),Bv="DialogContent",zye=N.forwardRef((t,e)=>{const r=Fye(Bv,t.__scopeDialog),{forceMount:n=r.forceMount,...s}=t,o=Uf(Bv,t.__scopeDialog);return i.jsx(Cl,{present:n||o.open,children:o.modal?i.jsx(J5e,{...s,ref:e}):i.jsx(eBe,{...s,ref:e})})});zye.displayName=Bv;var J5e=N.forwardRef((t,e)=>{const r=Uf(Bv,t.__scopeDialog),n=N.useRef(null),s=is(e,r.contentRef,n);return N.useEffect(()=>{const o=n.current;if(o)return h4(o)},[]),i.jsx(Uye,{...t,ref:s,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Gr(t.onCloseAutoFocus,o=>{var c;o.preventDefault(),(c=r.triggerRef.current)==null||c.focus()}),onPointerDownOutside:Gr(t.onPointerDownOutside,o=>{const c=o.detail.originalEvent,a=c.button===0&&c.ctrlKey===!0;(c.button===2||a)&&o.preventDefault()}),onFocusOutside:Gr(t.onFocusOutside,o=>o.preventDefault())})}),eBe=N.forwardRef((t,e)=>{const r=Uf(Bv,t.__scopeDialog),n=N.useRef(!1),s=N.useRef(!1);return i.jsx(Uye,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{var c,a;(c=t.onCloseAutoFocus)==null||c.call(t,o),o.defaultPrevented||(n.current||(a=r.triggerRef.current)==null||a.focus(),o.preventDefault()),n.current=!1,s.current=!1},onInteractOutside:o=>{var f,m;(f=t.onInteractOutside)==null||f.call(t,o),o.defaultPrevented||(n.current=!0,o.detail.originalEvent.type==="pointerdown"&&(s.current=!0));const c=o.target;((m=r.triggerRef.current)==null?void 0:m.contains(c))&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&s.current&&o.preventDefault()}})}),Uye=N.forwardRef((t,e)=>{const{__scopeDialog:r,trapFocus:n,onOpenAutoFocus:s,onCloseAutoFocus:o,...c}=t,a=Uf(Bv,r),f=N.useRef(null),m=is(e,f);return u4(),i.jsxs(i.Fragment,{children:[i.jsx(vC,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:s,onUnmountAutoFocus:o,children:i.jsx(nb,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":jH(a.open),...c,ref:m,onDismiss:()=>a.onOpenChange(!1)})}),i.jsxs(i.Fragment,{children:[i.jsx(rBe,{titleId:a.titleId}),i.jsx(sBe,{contentRef:f,descriptionId:a.descriptionId})]})]})}),EH="DialogTitle",Vye=N.forwardRef((t,e)=>{const{__scopeDialog:r,...n}=t,s=Uf(EH,r);return i.jsx(cn.h2,{id:s.titleId,...n,ref:e})});Vye.displayName=EH;var qye="DialogDescription",Gye=N.forwardRef((t,e)=>{const{__scopeDialog:r,...n}=t,s=Uf(qye,r);return i.jsx(cn.p,{id:s.descriptionId,...n,ref:e})});Gye.displayName=qye;var Hye="DialogClose",Wye=N.forwardRef((t,e)=>{const{__scopeDialog:r,...n}=t,s=Uf(Hye,r);return i.jsx(cn.button,{type:"button",...n,ref:e,onClick:Gr(t.onClick,()=>s.onOpenChange(!1))})});Wye.displayName=Hye;function jH(t){return t?"open":"closed"}var Kye="DialogTitleWarning",[tBe,Yye]=l3e(Kye,{contentName:Bv,titleName:EH,docsSlug:"dialog"}),rBe=({titleId:t})=>{const e=Yye(Kye),r=`\`${e.contentName}\` requires a \`${e.titleName}\` for the component to be accessible for screen reader users. If you want to hide the \`${e.titleName}\`, you can wrap it with our VisuallyHidden component. For more information, see https://radix-ui.com/primitives/docs/components/${e.docsSlug}`;return N.useEffect(()=>{t&&(document.getElementById(t)||console.error(r))},[r,t]),null},nBe="DialogDescriptionWarning",sBe=({contentRef:t,descriptionId:e})=>{const n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Yye(nBe).contentName}}.`;return N.useEffect(()=>{var o;const s=(o=t.current)==null?void 0:o.getAttribute("aria-describedby");e&&s&&(document.getElementById(e)||console.warn(n))},[n,t,e]),null},m4=Mye,kH=Oye,p4=Bye,GT=$ye,HT=zye,wC=Vye,SC=Gye,TC=Wye,Zye="AlertDialog",[iBe,hQt]=cl(Zye,[Lye]),Bg=Lye(),Xye=t=>{const{__scopeAlertDialog:e,...r}=t,n=Bg(e);return i.jsx(m4,{...n,...r,modal:!0})};Xye.displayName=Zye;var aBe="AlertDialogTrigger",Qye=N.forwardRef((t,e)=>{const{__scopeAlertDialog:r,...n}=t,s=Bg(r);return i.jsx(kH,{...s,...n,ref:e})});Qye.displayName=aBe;var oBe="AlertDialogPortal",Jye=t=>{const{__scopeAlertDialog:e,...r}=t,n=Bg(e);return i.jsx(p4,{...n,...r})};Jye.displayName=oBe;var lBe="AlertDialogOverlay",exe=N.forwardRef((t,e)=>{const{__scopeAlertDialog:r,...n}=t,s=Bg(r);return i.jsx(GT,{...s,...n,ref:e})});exe.displayName=lBe;var cS="AlertDialogContent",[cBe,uBe]=iBe(cS),dBe=jge("AlertDialogContent"),txe=N.forwardRef((t,e)=>{const{__scopeAlertDialog:r,children:n,...s}=t,o=Bg(r),c=N.useRef(null),a=is(e,c),f=N.useRef(null);return i.jsx(tBe,{contentName:cS,titleName:rxe,docsSlug:"alert-dialog",children:i.jsx(cBe,{scope:r,cancelRef:f,children:i.jsxs(HT,{role:"alertdialog",...o,...s,ref:a,onOpenAutoFocus:Gr(s.onOpenAutoFocus,m=>{var y;m.preventDefault(),(y=f.current)==null||y.focus({preventScroll:!0})}),onPointerDownOutside:m=>m.preventDefault(),onInteractOutside:m=>m.preventDefault(),children:[i.jsx(dBe,{children:n}),i.jsx(fBe,{contentRef:c})]})})})});txe.displayName=cS;var rxe="AlertDialogTitle",nxe=N.forwardRef((t,e)=>{const{__scopeAlertDialog:r,...n}=t,s=Bg(r);return i.jsx(wC,{...s,...n,ref:e})});nxe.displayName=rxe;var sxe="AlertDialogDescription",ixe=N.forwardRef((t,e)=>{const{__scopeAlertDialog:r,...n}=t,s=Bg(r);return i.jsx(SC,{...s,...n,ref:e})});ixe.displayName=sxe;var hBe="AlertDialogAction",axe=N.forwardRef((t,e)=>{const{__scopeAlertDialog:r,...n}=t,s=Bg(r);return i.jsx(TC,{...s,...n,ref:e})});axe.displayName=hBe;var oxe="AlertDialogCancel",lxe=N.forwardRef((t,e)=>{const{__scopeAlertDialog:r,...n}=t,{cancelRef:s}=uBe(oxe,r),o=Bg(r),c=is(e,s);return i.jsx(TC,{...o,...n,ref:c})});lxe.displayName=oxe;var fBe=({contentRef:t})=>{const e=`\`${cS}\` requires a description for the component to be accessible for screen reader users. You can add a description to the \`${cS}\` by passing a \`${sxe}\` component as a child, which also benefits sighted users by adding visible context to the dialog. Alternatively, you can use your own component as a description by assigning it an \`id\` and passing the same value to the \`aria-describedby\` prop in \`${cS}\`. If the description is confusing or duplicative for sighted users, you can use the \`@radix-ui/react-visually-hidden\` primitive as a wrapper around your description component. For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return N.useEffect(()=>{var n;document.getElementById((n=t.current)==null?void 0:n.getAttribute("aria-describedby"))||console.warn(e)},[e,t]),null},mBe=Xye,pBe=Qye,gBe=Jye,cxe=exe,uxe=txe,dxe=axe,hxe=lxe,fxe=nxe,mxe=ixe;const GA=zT("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-full text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-full px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),Lt=N.forwardRef(({className:t,variant:e,size:r,asChild:n=!1,...s},o)=>{const c=n?Tge:"button";return i.jsx(c,{className:Xt(GA({variant:e,size:r,className:t})),ref:o,...s})});Lt.displayName="Button";const pxe=mBe,fQt=pBe,yBe=gBe,gxe=N.forwardRef(({className:t,...e},r)=>i.jsx(cxe,{className:Xt("fixed inset-0 z-50 bg-foreground/45 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...e,ref:r}));gxe.displayName=cxe.displayName;const AH=N.forwardRef(({className:t,...e},r)=>i.jsxs(yBe,{children:[i.jsx(gxe,{}),i.jsx(uxe,{ref:r,className:Xt("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",t),...e})]}));AH.displayName=uxe.displayName;const NH=({className:t,...e})=>i.jsx("div",{className:Xt("flex flex-col space-y-2 text-center sm:text-left",t),...e});NH.displayName="AlertDialogHeader";const CH=({className:t,...e})=>i.jsx("div",{className:Xt("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...e});CH.displayName="AlertDialogFooter";const IH=N.forwardRef(({className:t,...e},r)=>i.jsx(fxe,{ref:r,className:Xt("text-lg font-semibold",t),...e}));IH.displayName=fxe.displayName;const PH=N.forwardRef(({className:t,...e},r)=>i.jsx(mxe,{ref:r,className:Xt("text-sm text-muted-foreground",t),...e}));PH.displayName=mxe.displayName;const RH=N.forwardRef(({className:t,...e},r)=>i.jsx(dxe,{ref:r,className:Xt(GA(),t),...e}));RH.displayName=dxe.displayName;const LH=N.forwardRef(({className:t,...e},r)=>i.jsx(hxe,{ref:r,className:Xt(GA({variant:"outline"}),"mt-2 sm:mt-0",t),...e}));LH.displayName=hxe.displayName;let OD=null;const xBe=["delete","remove","revoke","cannot be undone","permanently"];function mQt(t,e={}){const r=typeof t=="string"?{description:t,...e}:t,n=`${r.title??""} ${r.description??""}`.toLowerCase(),s=r.destructive??xBe.some(o=>n.includes(o));return new Promise(o=>{if(!OD){o(window.confirm(r.description??r.title??"Are you sure?"));return}OD({...r,destructive:s,resolve:o})})}function _Be(){const[t,e]=N.useState(null);N.useEffect(()=>(OD=s=>e(s),()=>{OD=null}),[]);const r=s=>{t==null||t.resolve(s),e(null)},n=!!(t!=null&&t.destructive);return i.jsx(pxe,{open:!!t,onOpenChange:s=>!s&&r(!1),children:i.jsxs(AH,{className:"sm:max-w-md",children:[i.jsx(NH,{children:i.jsxs("div",{className:"flex items-start gap-3",children:[i.jsx("div",{className:Xt("mt-0.5 flex h-10 w-10 shrink-0 items-center justify-center rounded-full",n?"bg-destructive/10 text-destructive":"bg-primary/10 text-primary"),children:i.jsx(VT,{className:"h-5 w-5"})}),i.jsxs("div",{className:"space-y-1.5 text-left",children:[i.jsx(IH,{children:(t==null?void 0:t.title)??(n?"Are you sure?":"Please confirm")}),(t==null?void 0:t.description)&&i.jsx(PH,{className:"leading-relaxed",children:t.description})]})]})}),i.jsxs(CH,{className:"gap-2 sm:gap-2",children:[i.jsx(LH,{onClick:()=>r(!1),children:(t==null?void 0:t.cancelText)??"Cancel"}),i.jsx(RH,{onClick:()=>r(!0),className:Xt(n&&"bg-destructive text-destructive-foreground hover:bg-destructive/90"),children:(t==null?void 0:t.confirmText)??(n?"Delete":"Continue")})]})]})})}const vBe=["top","right","bottom","left"],Ux=Math.min,Ed=Math.max,FD=Math.round,nL=Math.floor,Vx=t=>({x:t,y:t}),bBe={left:"right",right:"left",bottom:"top",top:"bottom"},wBe={start:"end",end:"start"};function T8(t,e,r){return Ed(t,Ux(e,r))}function Ag(t,e){return typeof t=="function"?t(e):t}function Ng(t){return t.split("-")[0]}function WT(t){return t.split("-")[1]}function MH(t){return t==="x"?"y":"x"}function DH(t){return t==="y"?"height":"width"}function qx(t){return["top","bottom"].includes(Ng(t))?"y":"x"}function OH(t){return MH(qx(t))}function SBe(t,e,r){r===void 0&&(r=!1);const n=WT(t),s=OH(t),o=DH(s);let c=s==="x"?n===(r?"end":"start")?"right":"left":n==="start"?"bottom":"top";return e.reference[o]>e.floating[o]&&(c=BD(c)),[c,BD(c)]}function TBe(t){const e=BD(t);return[E8(t),e,E8(e)]}function E8(t){return t.replace(/start|end/g,e=>wBe[e])}function EBe(t,e,r){const n=["left","right"],s=["right","left"],o=["top","bottom"],c=["bottom","top"];switch(t){case"top":case"bottom":return r?e?s:n:e?n:s;case"left":case"right":return e?o:c;default:return[]}}function jBe(t,e,r,n){const s=WT(t);let o=EBe(Ng(t),r==="start",n);return s&&(o=o.map(c=>c+"-"+s),e&&(o=o.concat(o.map(E8)))),o}function BD(t){return t.replace(/left|right|bottom|top/g,e=>bBe[e])}function kBe(t){return{top:0,right:0,bottom:0,left:0,...t}}function yxe(t){return typeof t!="number"?kBe(t):{top:t,right:t,bottom:t,left:t}}function $D(t){const{x:e,y:r,width:n,height:s}=t;return{width:n,height:s,top:r,left:e,right:e+n,bottom:r+s,x:e,y:r}}function mne(t,e,r){let{reference:n,floating:s}=t;const o=qx(e),c=OH(e),a=DH(c),f=Ng(e),m=o==="y",y=n.x+n.width/2-s.width/2,_=n.y+n.height/2-s.height/2,w=n[a]/2-s[a]/2;let E;switch(f){case"top":E={x:y,y:n.y-s.height};break;case"bottom":E={x:y,y:n.y+n.height};break;case"right":E={x:n.x+n.width,y:_};break;case"left":E={x:n.x-s.width,y:_};break;default:E={x:n.x,y:n.y}}switch(WT(e)){case"start":E[c]-=w*(r&&m?-1:1);break;case"end":E[c]+=w*(r&&m?-1:1);break}return E}const ABe=async(t,e,r)=>{const{placement:n="bottom",strategy:s="absolute",middleware:o=[],platform:c}=r,a=o.filter(Boolean),f=await(c.isRTL==null?void 0:c.isRTL(e));let m=await c.getElementRects({reference:t,floating:e,strategy:s}),{x:y,y:_}=mne(m,n,f),w=n,E={},A=0;for(let C=0;C({name:"arrow",options:t,async fn(e){const{x:r,y:n,placement:s,rects:o,platform:c,elements:a,middlewareData:f}=e,{element:m,padding:y=0}=Ag(t,e)||{};if(m==null)return{};const _=yxe(y),w={x:r,y:n},E=OH(s),A=DH(E),C=await c.getDimensions(m),I=E==="y",M=I?"top":"left",D=I?"bottom":"right",B=I?"clientHeight":"clientWidth",U=o.reference[A]+o.reference[E]-w[E]-o.floating[A],q=w[E]-o.reference[E],H=await(c.getOffsetParent==null?void 0:c.getOffsetParent(m));let K=H?H[B]:0;(!K||!await(c.isElement==null?void 0:c.isElement(H)))&&(K=a.floating[B]||o.floating[A]);const Q=U/2-q/2,J=K/2-C[A]/2-1,ee=Ux(_[M],J),oe=Ux(_[D],J),de=ee,ye=K-C[A]-oe,Ee=K/2-C[A]/2+Q,Le=T8(de,Ee,ye),Se=!f.arrow&&WT(s)!=null&&Ee!==Le&&o.reference[A]/2-(EeEe<=0)){var oe,de;const Ee=(((oe=o.flip)==null?void 0:oe.index)||0)+1,Le=K[Ee];if(Le)return{data:{index:Ee,overflows:ee},reset:{placement:Le}};let Se=(de=ee.filter(be=>be.overflows[0]<=0).sort((be,me)=>be.overflows[1]-me.overflows[1])[0])==null?void 0:de.placement;if(!Se)switch(E){case"bestFit":{var ye;const be=(ye=ee.filter(me=>{if(H){const ke=qx(me.placement);return ke===D||ke==="y"}return!0}).map(me=>[me.placement,me.overflows.filter(ke=>ke>0).reduce((ke,Pe)=>ke+Pe,0)]).sort((me,ke)=>me[1]-ke[1])[0])==null?void 0:ye[0];be&&(Se=be);break}case"initialPlacement":Se=a;break}if(s!==Se)return{reset:{placement:Se}}}return{}}}};function pne(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function gne(t){return vBe.some(e=>t[e]>=0)}const IBe=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(e){const{rects:r}=e,{strategy:n="referenceHidden",...s}=Ag(t,e);switch(n){case"referenceHidden":{const o=await HA(e,{...s,elementContext:"reference"}),c=pne(o,r.reference);return{data:{referenceHiddenOffsets:c,referenceHidden:gne(c)}}}case"escaped":{const o=await HA(e,{...s,altBoundary:!0}),c=pne(o,r.floating);return{data:{escapedOffsets:c,escaped:gne(c)}}}default:return{}}}}};async function PBe(t,e){const{placement:r,platform:n,elements:s}=t,o=await(n.isRTL==null?void 0:n.isRTL(s.floating)),c=Ng(r),a=WT(r),f=qx(r)==="y",m=["left","top"].includes(c)?-1:1,y=o&&f?-1:1,_=Ag(e,t);let{mainAxis:w,crossAxis:E,alignmentAxis:A}=typeof _=="number"?{mainAxis:_,crossAxis:0,alignmentAxis:null}:{mainAxis:_.mainAxis||0,crossAxis:_.crossAxis||0,alignmentAxis:_.alignmentAxis};return a&&typeof A=="number"&&(E=a==="end"?A*-1:A),f?{x:E*y,y:w*m}:{x:w*m,y:E*y}}const RBe=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var r,n;const{x:s,y:o,placement:c,middlewareData:a}=e,f=await PBe(e,t);return c===((r=a.offset)==null?void 0:r.placement)&&(n=a.arrow)!=null&&n.alignmentOffset?{}:{x:s+f.x,y:o+f.y,data:{...f,placement:c}}}}},LBe=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:r,y:n,placement:s}=e,{mainAxis:o=!0,crossAxis:c=!1,limiter:a={fn:I=>{let{x:M,y:D}=I;return{x:M,y:D}}},...f}=Ag(t,e),m={x:r,y:n},y=await HA(e,f),_=qx(Ng(s)),w=MH(_);let E=m[w],A=m[_];if(o){const I=w==="y"?"top":"left",M=w==="y"?"bottom":"right",D=E+y[I],B=E-y[M];E=T8(D,E,B)}if(c){const I=_==="y"?"top":"left",M=_==="y"?"bottom":"right",D=A+y[I],B=A-y[M];A=T8(D,A,B)}const C=a.fn({...e,[w]:E,[_]:A});return{...C,data:{x:C.x-r,y:C.y-n,enabled:{[w]:o,[_]:c}}}}}},MBe=function(t){return t===void 0&&(t={}),{options:t,fn(e){const{x:r,y:n,placement:s,rects:o,middlewareData:c}=e,{offset:a=0,mainAxis:f=!0,crossAxis:m=!0}=Ag(t,e),y={x:r,y:n},_=qx(s),w=MH(_);let E=y[w],A=y[_];const C=Ag(a,e),I=typeof C=="number"?{mainAxis:C,crossAxis:0}:{mainAxis:0,crossAxis:0,...C};if(f){const B=w==="y"?"height":"width",U=o.reference[w]-o.floating[B]+I.mainAxis,q=o.reference[w]+o.reference[B]-I.mainAxis;Eq&&(E=q)}if(m){var M,D;const B=w==="y"?"width":"height",U=["top","left"].includes(Ng(s)),q=o.reference[_]-o.floating[B]+(U&&((M=c.offset)==null?void 0:M[_])||0)+(U?0:I.crossAxis),H=o.reference[_]+o.reference[B]+(U?0:((D=c.offset)==null?void 0:D[_])||0)-(U?I.crossAxis:0);AH&&(A=H)}return{[w]:E,[_]:A}}}},DBe=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(e){var r,n;const{placement:s,rects:o,platform:c,elements:a}=e,{apply:f=()=>{},...m}=Ag(t,e),y=await HA(e,m),_=Ng(s),w=WT(s),E=qx(s)==="y",{width:A,height:C}=o.floating;let I,M;_==="top"||_==="bottom"?(I=_,M=w===(await(c.isRTL==null?void 0:c.isRTL(a.floating))?"start":"end")?"left":"right"):(M=_,I=w==="end"?"top":"bottom");const D=C-y.top-y.bottom,B=A-y.left-y.right,U=Ux(C-y[I],D),q=Ux(A-y[M],B),H=!e.middlewareData.shift;let K=U,Q=q;if((r=e.middlewareData.shift)!=null&&r.enabled.x&&(Q=B),(n=e.middlewareData.shift)!=null&&n.enabled.y&&(K=D),H&&!w){const ee=Ed(y.left,0),oe=Ed(y.right,0),de=Ed(y.top,0),ye=Ed(y.bottom,0);E?Q=A-2*(ee!==0||oe!==0?ee+oe:Ed(y.left,y.right)):K=C-2*(de!==0||ye!==0?de+ye:Ed(y.top,y.bottom))}await f({...e,availableWidth:Q,availableHeight:K});const J=await c.getDimensions(a.floating);return A!==J.width||C!==J.height?{reset:{rects:!0}}:{}}}};function g4(){return typeof window<"u"}function KT(t){return xxe(t)?(t.nodeName||"").toLowerCase():"#document"}function Pd(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function ap(t){var e;return(e=(xxe(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function xxe(t){return g4()?t instanceof Node||t instanceof Pd(t).Node:!1}function Bf(t){return g4()?t instanceof Element||t instanceof Pd(t).Element:!1}function Xm(t){return g4()?t instanceof HTMLElement||t instanceof Pd(t).HTMLElement:!1}function yne(t){return!g4()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof Pd(t).ShadowRoot}function EC(t){const{overflow:e,overflowX:r,overflowY:n,display:s}=$f(t);return/auto|scroll|overlay|hidden|clip/.test(e+n+r)&&!["inline","contents"].includes(s)}function OBe(t){return["table","td","th"].includes(KT(t))}function y4(t){return[":popover-open",":modal"].some(e=>{try{return t.matches(e)}catch{return!1}})}function FH(t){const e=BH(),r=Bf(t)?$f(t):t;return r.transform!=="none"||r.perspective!=="none"||(r.containerType?r.containerType!=="normal":!1)||!e&&(r.backdropFilter?r.backdropFilter!=="none":!1)||!e&&(r.filter?r.filter!=="none":!1)||["transform","perspective","filter"].some(n=>(r.willChange||"").includes(n))||["paint","layout","strict","content"].some(n=>(r.contain||"").includes(n))}function FBe(t){let e=Gx(t);for(;Xm(e)&&!HS(e);){if(FH(e))return e;if(y4(e))return null;e=Gx(e)}return null}function BH(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function HS(t){return["html","body","#document"].includes(KT(t))}function $f(t){return Pd(t).getComputedStyle(t)}function x4(t){return Bf(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function Gx(t){if(KT(t)==="html")return t;const e=t.assignedSlot||t.parentNode||yne(t)&&t.host||ap(t);return yne(e)?e.host:e}function _xe(t){const e=Gx(t);return HS(e)?t.ownerDocument?t.ownerDocument.body:t.body:Xm(e)&&EC(e)?e:_xe(e)}function WA(t,e,r){var n;e===void 0&&(e=[]),r===void 0&&(r=!0);const s=_xe(t),o=s===((n=t.ownerDocument)==null?void 0:n.body),c=Pd(s);if(o){const a=j8(c);return e.concat(c,c.visualViewport||[],EC(s)?s:[],a&&r?WA(a):[])}return e.concat(s,WA(s,[],r))}function j8(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function vxe(t){const e=$f(t);let r=parseFloat(e.width)||0,n=parseFloat(e.height)||0;const s=Xm(t),o=s?t.offsetWidth:r,c=s?t.offsetHeight:n,a=FD(r)!==o||FD(n)!==c;return a&&(r=o,n=c),{width:r,height:n,$:a}}function $H(t){return Bf(t)?t:t.contextElement}function uS(t){const e=$H(t);if(!Xm(e))return Vx(1);const r=e.getBoundingClientRect(),{width:n,height:s,$:o}=vxe(e);let c=(o?FD(r.width):r.width)/n,a=(o?FD(r.height):r.height)/s;return(!c||!Number.isFinite(c))&&(c=1),(!a||!Number.isFinite(a))&&(a=1),{x:c,y:a}}const BBe=Vx(0);function bxe(t){const e=Pd(t);return!BH()||!e.visualViewport?BBe:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function $Be(t,e,r){return e===void 0&&(e=!1),!r||e&&r!==Pd(t)?!1:e}function $v(t,e,r,n){e===void 0&&(e=!1),r===void 0&&(r=!1);const s=t.getBoundingClientRect(),o=$H(t);let c=Vx(1);e&&(n?Bf(n)&&(c=uS(n)):c=uS(t));const a=$Be(o,r,n)?bxe(o):Vx(0);let f=(s.left+a.x)/c.x,m=(s.top+a.y)/c.y,y=s.width/c.x,_=s.height/c.y;if(o){const w=Pd(o),E=n&&Bf(n)?Pd(n):n;let A=w,C=j8(A);for(;C&&n&&E!==A;){const I=uS(C),M=C.getBoundingClientRect(),D=$f(C),B=M.left+(C.clientLeft+parseFloat(D.paddingLeft))*I.x,U=M.top+(C.clientTop+parseFloat(D.paddingTop))*I.y;f*=I.x,m*=I.y,y*=I.x,_*=I.y,f+=B,m+=U,A=Pd(C),C=j8(A)}}return $D({width:y,height:_,x:f,y:m})}function zBe(t){let{elements:e,rect:r,offsetParent:n,strategy:s}=t;const o=s==="fixed",c=ap(n),a=e?y4(e.floating):!1;if(n===c||a&&o)return r;let f={scrollLeft:0,scrollTop:0},m=Vx(1);const y=Vx(0),_=Xm(n);if((_||!_&&!o)&&((KT(n)!=="body"||EC(c))&&(f=x4(n)),Xm(n))){const w=$v(n);m=uS(n),y.x=w.x+n.clientLeft,y.y=w.y+n.clientTop}return{width:r.width*m.x,height:r.height*m.y,x:r.x*m.x-f.scrollLeft*m.x+y.x,y:r.y*m.y-f.scrollTop*m.y+y.y}}function UBe(t){return Array.from(t.getClientRects())}function k8(t,e){const r=x4(t).scrollLeft;return e?e.left+r:$v(ap(t)).left+r}function VBe(t){const e=ap(t),r=x4(t),n=t.ownerDocument.body,s=Ed(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),o=Ed(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight);let c=-r.scrollLeft+k8(t);const a=-r.scrollTop;return $f(n).direction==="rtl"&&(c+=Ed(e.clientWidth,n.clientWidth)-s),{width:s,height:o,x:c,y:a}}function qBe(t,e){const r=Pd(t),n=ap(t),s=r.visualViewport;let o=n.clientWidth,c=n.clientHeight,a=0,f=0;if(s){o=s.width,c=s.height;const m=BH();(!m||m&&e==="fixed")&&(a=s.offsetLeft,f=s.offsetTop)}return{width:o,height:c,x:a,y:f}}function GBe(t,e){const r=$v(t,!0,e==="fixed"),n=r.top+t.clientTop,s=r.left+t.clientLeft,o=Xm(t)?uS(t):Vx(1),c=t.clientWidth*o.x,a=t.clientHeight*o.y,f=s*o.x,m=n*o.y;return{width:c,height:a,x:f,y:m}}function xne(t,e,r){let n;if(e==="viewport")n=qBe(t,r);else if(e==="document")n=VBe(ap(t));else if(Bf(e))n=GBe(e,r);else{const s=bxe(t);n={...e,x:e.x-s.x,y:e.y-s.y}}return $D(n)}function wxe(t,e){const r=Gx(t);return r===e||!Bf(r)||HS(r)?!1:$f(r).position==="fixed"||wxe(r,e)}function HBe(t,e){const r=e.get(t);if(r)return r;let n=WA(t,[],!1).filter(a=>Bf(a)&&KT(a)!=="body"),s=null;const o=$f(t).position==="fixed";let c=o?Gx(t):t;for(;Bf(c)&&!HS(c);){const a=$f(c),f=FH(c);!f&&a.position==="fixed"&&(s=null),(o?!f&&!s:!f&&a.position==="static"&&!!s&&["absolute","fixed"].includes(s.position)||EC(c)&&!f&&wxe(t,c))?n=n.filter(y=>y!==c):s=a,c=Gx(c)}return e.set(t,n),n}function WBe(t){let{element:e,boundary:r,rootBoundary:n,strategy:s}=t;const c=[...r==="clippingAncestors"?y4(e)?[]:HBe(e,this._c):[].concat(r),n],a=c[0],f=c.reduce((m,y)=>{const _=xne(e,y,s);return m.top=Ed(_.top,m.top),m.right=Ux(_.right,m.right),m.bottom=Ux(_.bottom,m.bottom),m.left=Ed(_.left,m.left),m},xne(e,a,s));return{width:f.right-f.left,height:f.bottom-f.top,x:f.left,y:f.top}}function KBe(t){const{width:e,height:r}=vxe(t);return{width:e,height:r}}function YBe(t,e,r){const n=Xm(e),s=ap(e),o=r==="fixed",c=$v(t,!0,o,e);let a={scrollLeft:0,scrollTop:0};const f=Vx(0);if(n||!n&&!o)if((KT(e)!=="body"||EC(s))&&(a=x4(e)),n){const E=$v(e,!0,o,e);f.x=E.x+e.clientLeft,f.y=E.y+e.clientTop}else s&&(f.x=k8(s));let m=0,y=0;if(s&&!n&&!o){const E=s.getBoundingClientRect();y=E.top+a.scrollTop,m=E.left+a.scrollLeft-k8(s,E)}const _=c.left+a.scrollLeft-f.x-m,w=c.top+a.scrollTop-f.y-y;return{x:_,y:w,width:c.width,height:c.height}}function zz(t){return $f(t).position==="static"}function _ne(t,e){if(!Xm(t)||$f(t).position==="fixed")return null;if(e)return e(t);let r=t.offsetParent;return ap(t)===r&&(r=r.ownerDocument.body),r}function Sxe(t,e){const r=Pd(t);if(y4(t))return r;if(!Xm(t)){let s=Gx(t);for(;s&&!HS(s);){if(Bf(s)&&!zz(s))return s;s=Gx(s)}return r}let n=_ne(t,e);for(;n&&OBe(n)&&zz(n);)n=_ne(n,e);return n&&HS(n)&&zz(n)&&!FH(n)?r:n||FBe(t)||r}const ZBe=async function(t){const e=this.getOffsetParent||Sxe,r=this.getDimensions,n=await r(t.floating);return{reference:YBe(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}};function XBe(t){return $f(t).direction==="rtl"}const QBe={convertOffsetParentRelativeRectToViewportRelativeRect:zBe,getDocumentElement:ap,getClippingRect:WBe,getOffsetParent:Sxe,getElementRects:ZBe,getClientRects:UBe,getDimensions:KBe,getScale:uS,isElement:Bf,isRTL:XBe};function JBe(t,e){let r=null,n;const s=ap(t);function o(){var a;clearTimeout(n),(a=r)==null||a.disconnect(),r=null}function c(a,f){a===void 0&&(a=!1),f===void 0&&(f=1),o();const{left:m,top:y,width:_,height:w}=t.getBoundingClientRect();if(a||e(),!_||!w)return;const E=nL(y),A=nL(s.clientWidth-(m+_)),C=nL(s.clientHeight-(y+w)),I=nL(m),D={rootMargin:-E+"px "+-A+"px "+-C+"px "+-I+"px",threshold:Ed(0,Ux(1,f))||1};let B=!0;function U(q){const H=q[0].intersectionRatio;if(H!==f){if(!B)return c();H?c(!1,H):n=setTimeout(()=>{c(!1,1e-7)},1e3)}B=!1}try{r=new IntersectionObserver(U,{...D,root:s.ownerDocument})}catch{r=new IntersectionObserver(U,D)}r.observe(t)}return c(!0),o}function e$e(t,e,r,n){n===void 0&&(n={});const{ancestorScroll:s=!0,ancestorResize:o=!0,elementResize:c=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:f=!1}=n,m=$H(t),y=s||o?[...m?WA(m):[],...WA(e)]:[];y.forEach(M=>{s&&M.addEventListener("scroll",r,{passive:!0}),o&&M.addEventListener("resize",r)});const _=m&&a?JBe(m,r):null;let w=-1,E=null;c&&(E=new ResizeObserver(M=>{let[D]=M;D&&D.target===m&&E&&(E.unobserve(e),cancelAnimationFrame(w),w=requestAnimationFrame(()=>{var B;(B=E)==null||B.observe(e)})),r()}),m&&!f&&E.observe(m),E.observe(e));let A,C=f?$v(t):null;f&&I();function I(){const M=$v(t);C&&(M.x!==C.x||M.y!==C.y||M.width!==C.width||M.height!==C.height)&&r(),C=M,A=requestAnimationFrame(I)}return r(),()=>{var M;y.forEach(D=>{s&&D.removeEventListener("scroll",r),o&&D.removeEventListener("resize",r)}),_==null||_(),(M=E)==null||M.disconnect(),E=null,f&&cancelAnimationFrame(A)}}const t$e=RBe,r$e=LBe,n$e=CBe,s$e=DBe,i$e=IBe,vne=NBe,a$e=MBe,o$e=(t,e,r)=>{const n=new Map,s={platform:QBe,...r},o={...s.platform,_c:n};return ABe(t,e,{...s,platform:o})};var NM=typeof document<"u"?N.useLayoutEffect:N.useEffect;function zD(t,e){if(t===e)return!0;if(typeof t!=typeof e)return!1;if(typeof t=="function"&&t.toString()===e.toString())return!0;let r,n,s;if(t&&e&&typeof t=="object"){if(Array.isArray(t)){if(r=t.length,r!==e.length)return!1;for(n=r;n--!==0;)if(!zD(t[n],e[n]))return!1;return!0}if(s=Object.keys(t),r=s.length,r!==Object.keys(e).length)return!1;for(n=r;n--!==0;)if(!{}.hasOwnProperty.call(e,s[n]))return!1;for(n=r;n--!==0;){const o=s[n];if(!(o==="_owner"&&t.$$typeof)&&!zD(t[o],e[o]))return!1}return!0}return t!==t&&e!==e}function Txe(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function bne(t,e){const r=Txe(t);return Math.round(e*r)/r}function Uz(t){const e=N.useRef(t);return NM(()=>{e.current=t}),e}function l$e(t){t===void 0&&(t={});const{placement:e="bottom",strategy:r="absolute",middleware:n=[],platform:s,elements:{reference:o,floating:c}={},transform:a=!0,whileElementsMounted:f,open:m}=t,[y,_]=N.useState({x:0,y:0,strategy:r,placement:e,middlewareData:{},isPositioned:!1}),[w,E]=N.useState(n);zD(w,n)||E(n);const[A,C]=N.useState(null),[I,M]=N.useState(null),D=N.useCallback(me=>{me!==H.current&&(H.current=me,C(me))},[]),B=N.useCallback(me=>{me!==K.current&&(K.current=me,M(me))},[]),U=o||A,q=c||I,H=N.useRef(null),K=N.useRef(null),Q=N.useRef(y),J=f!=null,ee=Uz(f),oe=Uz(s),de=Uz(m),ye=N.useCallback(()=>{if(!H.current||!K.current)return;const me={placement:e,strategy:r,middleware:w};oe.current&&(me.platform=oe.current),o$e(H.current,K.current,me).then(ke=>{const Pe={...ke,isPositioned:de.current!==!1};Ee.current&&!zD(Q.current,Pe)&&(Q.current=Pe,sp.flushSync(()=>{_(Pe)}))})},[w,e,r,oe,de]);NM(()=>{m===!1&&Q.current.isPositioned&&(Q.current.isPositioned=!1,_(me=>({...me,isPositioned:!1})))},[m]);const Ee=N.useRef(!1);NM(()=>(Ee.current=!0,()=>{Ee.current=!1}),[]),NM(()=>{if(U&&(H.current=U),q&&(K.current=q),U&&q){if(ee.current)return ee.current(U,q,ye);ye()}},[U,q,ye,ee,J]);const Le=N.useMemo(()=>({reference:H,floating:K,setReference:D,setFloating:B}),[D,B]),Se=N.useMemo(()=>({reference:U,floating:q}),[U,q]),be=N.useMemo(()=>{const me={position:r,left:0,top:0};if(!Se.floating)return me;const ke=bne(Se.floating,y.x),Pe=bne(Se.floating,y.y);return a?{...me,transform:"translate("+ke+"px, "+Pe+"px)",...Txe(Se.floating)>=1.5&&{willChange:"transform"}}:{position:r,left:ke,top:Pe}},[r,a,Se.floating,y.x,y.y]);return N.useMemo(()=>({...y,update:ye,refs:Le,elements:Se,floatingStyles:be}),[y,ye,Le,Se,be])}const c$e=t=>{function e(r){return{}.hasOwnProperty.call(r,"current")}return{name:"arrow",options:t,fn(r){const{element:n,padding:s}=typeof t=="function"?t(r):t;return n&&e(n)?n.current!=null?vne({element:n.current,padding:s}).fn(r):{}:n?vne({element:n,padding:s}).fn(r):{}}}},u$e=(t,e)=>({...t$e(t),options:[t,e]}),d$e=(t,e)=>({...r$e(t),options:[t,e]}),h$e=(t,e)=>({...a$e(t),options:[t,e]}),f$e=(t,e)=>({...n$e(t),options:[t,e]}),m$e=(t,e)=>({...s$e(t),options:[t,e]}),p$e=(t,e)=>({...i$e(t),options:[t,e]}),g$e=(t,e)=>({...c$e(t),options:[t,e]});var y$e="Arrow",Exe=N.forwardRef((t,e)=>{const{children:r,width:n=10,height:s=5,...o}=t;return i.jsx(cn.svg,{...o,ref:e,width:n,height:s,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:t.asChild?r:i.jsx("polygon",{points:"0,0 30,0 15,10"})})});Exe.displayName=y$e;var x$e=Exe;function jC(t){const[e,r]=N.useState(void 0);return qo(()=>{if(t){r({width:t.offsetWidth,height:t.offsetHeight});const n=new ResizeObserver(s=>{if(!Array.isArray(s)||!s.length)return;const o=s[0];let c,a;if("borderBoxSize"in o){const f=o.borderBoxSize,m=Array.isArray(f)?f[0]:f;c=m.inlineSize,a=m.blockSize}else c=t.offsetWidth,a=t.offsetHeight;r({width:c,height:a})});return n.observe(t,{box:"border-box"}),()=>n.unobserve(t)}else r(void 0)},[t]),e}var zH="Popper",[jxe,l0]=cl(zH),[_$e,kxe]=jxe(zH),Axe=t=>{const{__scopePopper:e,children:r}=t,[n,s]=N.useState(null);return i.jsx(_$e,{scope:e,anchor:n,onAnchorChange:s,children:r})};Axe.displayName=zH;var Nxe="PopperAnchor",Cxe=N.forwardRef((t,e)=>{const{__scopePopper:r,virtualRef:n,...s}=t,o=kxe(Nxe,r),c=N.useRef(null),a=is(e,c);return N.useEffect(()=>{o.onAnchorChange((n==null?void 0:n.current)||c.current)}),n?null:i.jsx(cn.div,{...s,ref:a})});Cxe.displayName=Nxe;var UH="PopperContent",[v$e,b$e]=jxe(UH),Ixe=N.forwardRef((t,e)=>{var yt,gt,ft,kt,Vt,xt;const{__scopePopper:r,side:n="bottom",sideOffset:s=0,align:o="center",alignOffset:c=0,arrowPadding:a=0,avoidCollisions:f=!0,collisionBoundary:m=[],collisionPadding:y=0,sticky:_="partial",hideWhenDetached:w=!1,updatePositionStrategy:E="optimized",onPlaced:A,...C}=t,I=kxe(UH,r),[M,D]=N.useState(null),B=is(e,or=>D(or)),[U,q]=N.useState(null),H=jC(U),K=(H==null?void 0:H.width)??0,Q=(H==null?void 0:H.height)??0,J=n+(o!=="center"?"-"+o:""),ee=typeof y=="number"?y:{top:0,right:0,bottom:0,left:0,...y},oe=Array.isArray(m)?m:[m],de=oe.length>0,ye={padding:ee,boundary:oe.filter(S$e),altBoundary:de},{refs:Ee,floatingStyles:Le,placement:Se,isPositioned:be,middlewareData:me}=l$e({strategy:"fixed",placement:J,whileElementsMounted:(...or)=>e$e(...or,{animationFrame:E==="always"}),elements:{reference:I.anchor},middleware:[u$e({mainAxis:s+Q,alignmentAxis:c}),f&&d$e({mainAxis:!0,crossAxis:!1,limiter:_==="partial"?h$e():void 0,...ye}),f&&f$e({...ye}),m$e({...ye,apply:({elements:or,rects:Sr,availableWidth:rn,availableHeight:Rr})=>{const{width:$r,height:qr}=Sr.reference,Nn=or.floating.style;Nn.setProperty("--radix-popper-available-width",`${rn}px`),Nn.setProperty("--radix-popper-available-height",`${Rr}px`),Nn.setProperty("--radix-popper-anchor-width",`${$r}px`),Nn.setProperty("--radix-popper-anchor-height",`${qr}px`)}}),U&&g$e({element:U,padding:a}),T$e({arrowWidth:K,arrowHeight:Q}),w&&p$e({strategy:"referenceHidden",...ye})]}),[ke,Pe]=Lxe(Se),je=fo(A);qo(()=>{be&&(je==null||je())},[be,je]);const xe=(yt=me.arrow)==null?void 0:yt.x,Ue=(gt=me.arrow)==null?void 0:gt.y,Ze=((ft=me.arrow)==null?void 0:ft.centerOffset)!==0,[lt,wt]=N.useState();return qo(()=>{M&&wt(window.getComputedStyle(M).zIndex)},[M]),i.jsx("div",{ref:Ee.setFloating,"data-radix-popper-content-wrapper":"",style:{...Le,transform:be?Le.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:lt,"--radix-popper-transform-origin":[(kt=me.transformOrigin)==null?void 0:kt.x,(Vt=me.transformOrigin)==null?void 0:Vt.y].join(" "),...((xt=me.hide)==null?void 0:xt.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:i.jsx(v$e,{scope:r,placedSide:ke,onArrowChange:q,arrowX:xe,arrowY:Ue,shouldHideArrow:Ze,children:i.jsx(cn.div,{"data-side":ke,"data-align":Pe,...C,ref:B,style:{...C.style,animation:be?void 0:"none"}})})})});Ixe.displayName=UH;var Pxe="PopperArrow",w$e={top:"bottom",right:"left",bottom:"top",left:"right"},Rxe=N.forwardRef(function(e,r){const{__scopePopper:n,...s}=e,o=b$e(Pxe,n),c=w$e[o.placedSide];return i.jsx("span",{ref:o.onArrowChange,style:{position:"absolute",left:o.arrowX,top:o.arrowY,[c]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[o.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[o.placedSide],visibility:o.shouldHideArrow?"hidden":void 0},children:i.jsx(x$e,{...s,ref:r,style:{...s.style,display:"block"}})})});Rxe.displayName=Pxe;function S$e(t){return t!==null}var T$e=t=>({name:"transformOrigin",options:t,fn(e){var I,M,D;const{placement:r,rects:n,middlewareData:s}=e,c=((I=s.arrow)==null?void 0:I.centerOffset)!==0,a=c?0:t.arrowWidth,f=c?0:t.arrowHeight,[m,y]=Lxe(r),_={start:"0%",center:"50%",end:"100%"}[y],w=(((M=s.arrow)==null?void 0:M.x)??0)+a/2,E=(((D=s.arrow)==null?void 0:D.y)??0)+f/2;let A="",C="";return m==="bottom"?(A=c?_:`${w}px`,C=`${-f}px`):m==="top"?(A=c?_:`${w}px`,C=`${n.floating.height+f}px`):m==="right"?(A=`${-f}px`,C=c?_:`${E}px`):m==="left"&&(A=`${n.floating.width+f}px`,C=c?_:`${E}px`),{data:{x:A,y:C}}}});function Lxe(t){const[e,r="center"]=t.split("-");return[e,r]}var kC=Axe,AC=Cxe,_4=Ixe,v4=Rxe,[b4,pQt]=cl("Tooltip",[l0]),w4=l0(),Mxe="TooltipProvider",E$e=700,A8="tooltip.open",[j$e,VH]=b4(Mxe),Dxe=t=>{const{__scopeTooltip:e,delayDuration:r=E$e,skipDelayDuration:n=300,disableHoverableContent:s=!1,children:o}=t,c=N.useRef(!0),a=N.useRef(!1),f=N.useRef(0);return N.useEffect(()=>{const m=f.current;return()=>window.clearTimeout(m)},[]),i.jsx(j$e,{scope:e,isOpenDelayedRef:c,delayDuration:r,onOpen:N.useCallback(()=>{window.clearTimeout(f.current),c.current=!1},[]),onClose:N.useCallback(()=>{window.clearTimeout(f.current),f.current=window.setTimeout(()=>c.current=!0,n)},[n]),isPointerInTransitRef:a,onPointerInTransitChange:N.useCallback(m=>{a.current=m},[]),disableHoverableContent:s,children:o})};Dxe.displayName=Mxe;var KA="Tooltip",[k$e,S4]=b4(KA),Oxe=t=>{const{__scopeTooltip:e,children:r,open:n,defaultOpen:s,onOpenChange:o,disableHoverableContent:c,delayDuration:a}=t,f=VH(KA,t.__scopeTooltip),m=w4(e),[y,_]=N.useState(null),w=il(),E=N.useRef(0),A=c??f.disableHoverableContent,C=a??f.delayDuration,I=N.useRef(!1),[M,D]=ed({prop:n,defaultProp:s??!1,onChange:K=>{K?(f.onOpen(),document.dispatchEvent(new CustomEvent(A8))):f.onClose(),o==null||o(K)},caller:KA}),B=N.useMemo(()=>M?I.current?"delayed-open":"instant-open":"closed",[M]),U=N.useCallback(()=>{window.clearTimeout(E.current),E.current=0,I.current=!1,D(!0)},[D]),q=N.useCallback(()=>{window.clearTimeout(E.current),E.current=0,D(!1)},[D]),H=N.useCallback(()=>{window.clearTimeout(E.current),E.current=window.setTimeout(()=>{I.current=!0,D(!0),E.current=0},C)},[C,D]);return N.useEffect(()=>()=>{E.current&&(window.clearTimeout(E.current),E.current=0)},[]),i.jsx(kC,{...m,children:i.jsx(k$e,{scope:e,contentId:w,open:M,stateAttribute:B,trigger:y,onTriggerChange:_,onTriggerEnter:N.useCallback(()=>{f.isOpenDelayedRef.current?H():U()},[f.isOpenDelayedRef,H,U]),onTriggerLeave:N.useCallback(()=>{A?q():(window.clearTimeout(E.current),E.current=0)},[q,A]),onOpen:U,onClose:q,disableHoverableContent:A,children:r})})};Oxe.displayName=KA;var N8="TooltipTrigger",Fxe=N.forwardRef((t,e)=>{const{__scopeTooltip:r,...n}=t,s=S4(N8,r),o=VH(N8,r),c=w4(r),a=N.useRef(null),f=is(e,a,s.onTriggerChange),m=N.useRef(!1),y=N.useRef(!1),_=N.useCallback(()=>m.current=!1,[]);return N.useEffect(()=>()=>document.removeEventListener("pointerup",_),[_]),i.jsx(AC,{asChild:!0,...c,children:i.jsx(cn.button,{"aria-describedby":s.open?s.contentId:void 0,"data-state":s.stateAttribute,...n,ref:f,onPointerMove:Gr(t.onPointerMove,w=>{w.pointerType!=="touch"&&!y.current&&!o.isPointerInTransitRef.current&&(s.onTriggerEnter(),y.current=!0)}),onPointerLeave:Gr(t.onPointerLeave,()=>{s.onTriggerLeave(),y.current=!1}),onPointerDown:Gr(t.onPointerDown,()=>{s.open&&s.onClose(),m.current=!0,document.addEventListener("pointerup",_,{once:!0})}),onFocus:Gr(t.onFocus,()=>{m.current||s.onOpen()}),onBlur:Gr(t.onBlur,s.onClose),onClick:Gr(t.onClick,s.onClose)})})});Fxe.displayName=N8;var A$e="TooltipPortal",[gQt,N$e]=b4(A$e,{forceMount:void 0}),WS="TooltipContent",Bxe=N.forwardRef((t,e)=>{const r=N$e(WS,t.__scopeTooltip),{forceMount:n=r.forceMount,side:s="top",...o}=t,c=S4(WS,t.__scopeTooltip);return i.jsx(Cl,{present:n||c.open,children:c.disableHoverableContent?i.jsx($xe,{side:s,...o,ref:e}):i.jsx(C$e,{side:s,...o,ref:e})})}),C$e=N.forwardRef((t,e)=>{const r=S4(WS,t.__scopeTooltip),n=VH(WS,t.__scopeTooltip),s=N.useRef(null),o=is(e,s),[c,a]=N.useState(null),{trigger:f,onClose:m}=r,y=s.current,{onPointerInTransitChange:_}=n,w=N.useCallback(()=>{a(null),_(!1)},[_]),E=N.useCallback((A,C)=>{const I=A.currentTarget,M={x:A.clientX,y:A.clientY},D=M$e(M,I.getBoundingClientRect()),B=D$e(M,D),U=O$e(C.getBoundingClientRect()),q=B$e([...B,...U]);a(q),_(!0)},[_]);return N.useEffect(()=>()=>w(),[w]),N.useEffect(()=>{if(f&&y){const A=I=>E(I,y),C=I=>E(I,f);return f.addEventListener("pointerleave",A),y.addEventListener("pointerleave",C),()=>{f.removeEventListener("pointerleave",A),y.removeEventListener("pointerleave",C)}}},[f,y,E,w]),N.useEffect(()=>{if(c){const A=C=>{const I=C.target,M={x:C.clientX,y:C.clientY},D=(f==null?void 0:f.contains(I))||(y==null?void 0:y.contains(I)),B=!F$e(M,c);D?w():B&&(w(),m())};return document.addEventListener("pointermove",A),()=>document.removeEventListener("pointermove",A)}},[f,y,c,m,w]),i.jsx($xe,{...t,ref:o})}),[I$e,P$e]=b4(KA,{isInside:!1}),R$e=jge("TooltipContent"),$xe=N.forwardRef((t,e)=>{const{__scopeTooltip:r,children:n,"aria-label":s,onEscapeKeyDown:o,onPointerDownOutside:c,...a}=t,f=S4(WS,r),m=w4(r),{onClose:y}=f;return N.useEffect(()=>(document.addEventListener(A8,y),()=>document.removeEventListener(A8,y)),[y]),N.useEffect(()=>{if(f.trigger){const _=w=>{const E=w.target;E!=null&&E.contains(f.trigger)&&y()};return window.addEventListener("scroll",_,{capture:!0}),()=>window.removeEventListener("scroll",_,{capture:!0})}},[f.trigger,y]),i.jsx(nb,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:o,onPointerDownOutside:c,onFocusOutside:_=>_.preventDefault(),onDismiss:y,children:i.jsxs(_4,{"data-state":f.stateAttribute,...m,...a,ref:e,style:{...a.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[i.jsx(R$e,{children:n}),i.jsx(I$e,{scope:r,isInside:!0,children:i.jsx(P3e,{id:f.contentId,role:"tooltip",children:s||n})})]})})});Bxe.displayName=WS;var zxe="TooltipArrow",L$e=N.forwardRef((t,e)=>{const{__scopeTooltip:r,...n}=t,s=w4(r);return P$e(zxe,r).isInside?null:i.jsx(v4,{...s,...n,ref:e})});L$e.displayName=zxe;function M$e(t,e){const r=Math.abs(e.top-t.y),n=Math.abs(e.bottom-t.y),s=Math.abs(e.right-t.x),o=Math.abs(e.left-t.x);switch(Math.min(r,n,s,o)){case o:return"left";case s:return"right";case r:return"top";case n:return"bottom";default:throw new Error("unreachable")}}function D$e(t,e,r=5){const n=[];switch(e){case"top":n.push({x:t.x-r,y:t.y+r},{x:t.x+r,y:t.y+r});break;case"bottom":n.push({x:t.x-r,y:t.y-r},{x:t.x+r,y:t.y-r});break;case"left":n.push({x:t.x+r,y:t.y-r},{x:t.x+r,y:t.y+r});break;case"right":n.push({x:t.x-r,y:t.y-r},{x:t.x-r,y:t.y+r});break}return n}function O$e(t){const{top:e,right:r,bottom:n,left:s}=t;return[{x:s,y:e},{x:r,y:e},{x:r,y:n},{x:s,y:n}]}function F$e(t,e){const{x:r,y:n}=t;let s=!1;for(let o=0,c=e.length-1;on!=w>n&&r<(_-m)*(n-y)/(w-y)+m&&(s=!s)}return s}function B$e(t){const e=t.slice();return e.sort((r,n)=>r.xn.x?1:r.yn.y?1:0),$$e(e)}function $$e(t){if(t.length<=1)return t.slice();const e=[];for(let n=0;n=2;){const o=e[e.length-1],c=e[e.length-2];if((o.x-c.x)*(s.y-c.y)>=(o.y-c.y)*(s.x-c.x))e.pop();else break}e.push(s)}e.pop();const r=[];for(let n=t.length-1;n>=0;n--){const s=t[n];for(;r.length>=2;){const o=r[r.length-1],c=r[r.length-2];if((o.x-c.x)*(s.y-c.y)>=(o.y-c.y)*(s.x-c.x))r.pop();else break}r.push(s)}return r.pop(),e.length===1&&r.length===1&&e[0].x===r[0].x&&e[0].y===r[0].y?e:e.concat(r)}var z$e=Dxe,U$e=Oxe,V$e=Fxe,Uxe=Bxe;const Vxe=z$e,q$e=U$e,G$e=V$e,qxe=N.forwardRef(({className:t,sideOffset:e=4,...r},n)=>i.jsx(Uxe,{ref:n,sideOffset:e,className:Xt("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...r}));qxe.displayName=Uxe.displayName;var YT=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(t){return this.listeners.add(t),this.onSubscribe(),()=>{this.listeners.delete(t),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},zv=typeof window>"u"||"Deno"in globalThis;function du(){}function H$e(t,e){return typeof t=="function"?t(e):t}function C8(t){return typeof t=="number"&&t>=0&&t!==1/0}function Gxe(t,e){return Math.max(t+(e||0)-Date.now(),0)}function Cx(t,e){return typeof t=="function"?t(e):t}function mh(t,e){return typeof t=="function"?t(e):t}function wne(t,e){const{type:r="all",exact:n,fetchStatus:s,predicate:o,queryKey:c,stale:a}=t;if(c){if(n){if(e.queryHash!==qH(c,e.options))return!1}else if(!YA(e.queryKey,c))return!1}if(r!=="all"){const f=e.isActive();if(r==="active"&&!f||r==="inactive"&&f)return!1}return!(typeof a=="boolean"&&e.isStale()!==a||s&&s!==e.state.fetchStatus||o&&!o(e))}function Sne(t,e){const{exact:r,status:n,predicate:s,mutationKey:o}=t;if(o){if(!e.options.mutationKey)return!1;if(r){if(Uv(e.options.mutationKey)!==Uv(o))return!1}else if(!YA(e.options.mutationKey,o))return!1}return!(n&&e.state.status!==n||s&&!s(e))}function qH(t,e){return((e==null?void 0:e.queryKeyHashFn)||Uv)(t)}function Uv(t){return JSON.stringify(t,(e,r)=>I8(r)?Object.keys(r).sort().reduce((n,s)=>(n[s]=r[s],n),{}):r)}function YA(t,e){return t===e?!0:typeof t!=typeof e?!1:t&&e&&typeof t=="object"&&typeof e=="object"?Object.keys(e).every(r=>YA(t[r],e[r])):!1}function Hxe(t,e){if(t===e)return t;const r=Tne(t)&&Tne(e);if(r||I8(t)&&I8(e)){const n=r?t:Object.keys(t),s=n.length,o=r?e:Object.keys(e),c=o.length,a=r?[]:{},f=new Set(n);let m=0;for(let y=0;y{setTimeout(e,t)})}function P8(t,e,r){return typeof r.structuralSharing=="function"?r.structuralSharing(t,e):r.structuralSharing!==!1?Hxe(t,e):e}function K$e(t,e,r=0){const n=[...t,e];return r&&n.length>r?n.slice(1):n}function Y$e(t,e,r=0){const n=[e,...t];return r&&n.length>r?n.slice(0,-1):n}var GH=Symbol();function Wxe(t,e){return!t.queryFn&&(e!=null&&e.initialPromise)?()=>e.initialPromise:!t.queryFn||t.queryFn===GH?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function Kxe(t,e){return typeof t=="function"?t(...e):!!t}var dv,ax,ES,Xfe,Z$e=(Xfe=class extends YT{constructor(){super();os(this,dv);os(this,ax);os(this,ES);Sn(this,ES,e=>{if(!zv&&window.addEventListener){const r=()=>e();return window.addEventListener("visibilitychange",r,!1),()=>{window.removeEventListener("visibilitychange",r)}}})}onSubscribe(){Ct(this,ax)||this.setEventListener(Ct(this,ES))}onUnsubscribe(){var e;this.hasListeners()||((e=Ct(this,ax))==null||e.call(this),Sn(this,ax,void 0))}setEventListener(e){var r;Sn(this,ES,e),(r=Ct(this,ax))==null||r.call(this),Sn(this,ax,e(n=>{typeof n=="boolean"?this.setFocused(n):this.onFocus()}))}setFocused(e){Ct(this,dv)!==e&&(Sn(this,dv,e),this.onFocus())}onFocus(){const e=this.isFocused();this.listeners.forEach(r=>{r(e)})}isFocused(){var e;return typeof Ct(this,dv)=="boolean"?Ct(this,dv):((e=globalThis.document)==null?void 0:e.visibilityState)!=="hidden"}},dv=new WeakMap,ax=new WeakMap,ES=new WeakMap,Xfe),HH=new Z$e,jS,ox,kS,Qfe,X$e=(Qfe=class extends YT{constructor(){super();os(this,jS,!0);os(this,ox);os(this,kS);Sn(this,kS,e=>{if(!zv&&window.addEventListener){const r=()=>e(!0),n=()=>e(!1);return window.addEventListener("online",r,!1),window.addEventListener("offline",n,!1),()=>{window.removeEventListener("online",r),window.removeEventListener("offline",n)}}})}onSubscribe(){Ct(this,ox)||this.setEventListener(Ct(this,kS))}onUnsubscribe(){var e;this.hasListeners()||((e=Ct(this,ox))==null||e.call(this),Sn(this,ox,void 0))}setEventListener(e){var r;Sn(this,kS,e),(r=Ct(this,ox))==null||r.call(this),Sn(this,ox,e(this.setOnline.bind(this)))}setOnline(e){Ct(this,jS)!==e&&(Sn(this,jS,e),this.listeners.forEach(n=>{n(e)}))}isOnline(){return Ct(this,jS)}},jS=new WeakMap,ox=new WeakMap,kS=new WeakMap,Qfe),VD=new X$e;function R8(){let t,e;const r=new Promise((s,o)=>{t=s,e=o});r.status="pending",r.catch(()=>{});function n(s){Object.assign(r,s),delete r.resolve,delete r.reject}return r.resolve=s=>{n({status:"fulfilled",value:s}),t(s)},r.reject=s=>{n({status:"rejected",reason:s}),e(s)},r}function Q$e(t){return Math.min(1e3*2**t,3e4)}function Yxe(t){return(t??"online")==="online"?VD.isOnline():!0}var Zxe=class extends Error{constructor(t){super("CancelledError"),this.revert=t==null?void 0:t.revert,this.silent=t==null?void 0:t.silent}};function Vz(t){return t instanceof Zxe}function Xxe(t){let e=!1,r=0,n=!1,s;const o=R8(),c=C=>{var I;n||(w(new Zxe(C)),(I=t.abort)==null||I.call(t))},a=()=>{e=!0},f=()=>{e=!1},m=()=>HH.isFocused()&&(t.networkMode==="always"||VD.isOnline())&&t.canRun(),y=()=>Yxe(t.networkMode)&&t.canRun(),_=C=>{var I;n||(n=!0,(I=t.onSuccess)==null||I.call(t,C),s==null||s(),o.resolve(C))},w=C=>{var I;n||(n=!0,(I=t.onError)==null||I.call(t,C),s==null||s(),o.reject(C))},E=()=>new Promise(C=>{var I;s=M=>{(n||m())&&C(M)},(I=t.onPause)==null||I.call(t)}).then(()=>{var C;s=void 0,n||(C=t.onContinue)==null||C.call(t)}),A=()=>{if(n)return;let C;const I=r===0?t.initialPromise:void 0;try{C=I??t.fn()}catch(M){C=Promise.reject(M)}Promise.resolve(C).then(_).catch(M=>{var H;if(n)return;const D=t.retry??(zv?0:3),B=t.retryDelay??Q$e,U=typeof B=="function"?B(r,M):B,q=D===!0||typeof D=="number"&&rm()?void 0:E()).then(()=>{e?w(M):A()})})};return{promise:o,cancel:c,continue:()=>(s==null||s(),o),cancelRetry:a,continueRetry:f,canStart:y,start:()=>(y()?A():E().then(A),o)}}var J$e=t=>setTimeout(t,0);function eze(){let t=[],e=0,r=a=>{a()},n=a=>{a()},s=J$e;const o=a=>{e?t.push(a):s(()=>{r(a)})},c=()=>{const a=t;t=[],a.length&&s(()=>{n(()=>{a.forEach(f=>{r(f)})})})};return{batch:a=>{let f;e++;try{f=a()}finally{e--,e||c()}return f},batchCalls:a=>(...f)=>{o(()=>{a(...f)})},schedule:o,setNotifyFunction:a=>{r=a},setBatchNotifyFunction:a=>{n=a},setScheduler:a=>{s=a}}}var Tl=eze(),hv,Jfe,Qxe=(Jfe=class{constructor(){os(this,hv)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),C8(this.gcTime)&&Sn(this,hv,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(zv?1/0:5*60*1e3))}clearGcTimeout(){Ct(this,hv)&&(clearTimeout(Ct(this,hv)),Sn(this,hv,void 0))}},hv=new WeakMap,Jfe),AS,fv,fh,mv,Cc,iC,pv,ff,Xp,eme,tze=(eme=class extends Qxe{constructor(e){super();os(this,ff);os(this,AS);os(this,fv);os(this,fh);os(this,mv);os(this,Cc);os(this,iC);os(this,pv);Sn(this,pv,!1),Sn(this,iC,e.defaultOptions),this.setOptions(e.options),this.observers=[],Sn(this,mv,e.client),Sn(this,fh,Ct(this,mv).getQueryCache()),this.queryKey=e.queryKey,this.queryHash=e.queryHash,Sn(this,AS,rze(this.options)),this.state=e.state??Ct(this,AS),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var e;return(e=Ct(this,Cc))==null?void 0:e.promise}setOptions(e){this.options={...Ct(this,iC),...e},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&Ct(this,fh).remove(this)}setData(e,r){const n=P8(this.state.data,e,this.options);return Zs(this,ff,Xp).call(this,{data:n,type:"success",dataUpdatedAt:r==null?void 0:r.updatedAt,manual:r==null?void 0:r.manual}),n}setState(e,r){Zs(this,ff,Xp).call(this,{type:"setState",state:e,setStateOptions:r})}cancel(e){var n,s;const r=(n=Ct(this,Cc))==null?void 0:n.promise;return(s=Ct(this,Cc))==null||s.cancel(e),r?r.then(du).catch(du):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(Ct(this,AS))}isActive(){return this.observers.some(e=>mh(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===GH||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(e=>Cx(e.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e==="static"?!1:this.state.isInvalidated?!0:!Gxe(this.state.dataUpdatedAt,e)}onFocus(){var r;const e=this.observers.find(n=>n.shouldFetchOnWindowFocus());e==null||e.refetch({cancelRefetch:!1}),(r=Ct(this,Cc))==null||r.continue()}onOnline(){var r;const e=this.observers.find(n=>n.shouldFetchOnReconnect());e==null||e.refetch({cancelRefetch:!1}),(r=Ct(this,Cc))==null||r.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),Ct(this,fh).notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(r=>r!==e),this.observers.length||(Ct(this,Cc)&&(Ct(this,pv)?Ct(this,Cc).cancel({revert:!0}):Ct(this,Cc).cancelRetry()),this.scheduleGc()),Ct(this,fh).notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||Zs(this,ff,Xp).call(this,{type:"invalidate"})}fetch(e,r){var m,y,_;if(this.state.fetchStatus!=="idle"){if(this.state.data!==void 0&&(r!=null&&r.cancelRefetch))this.cancel({silent:!0});else if(Ct(this,Cc))return Ct(this,Cc).continueRetry(),Ct(this,Cc).promise}if(e&&this.setOptions(e),!this.options.queryFn){const w=this.observers.find(E=>E.options.queryFn);w&&this.setOptions(w.options)}const n=new AbortController,s=w=>{Object.defineProperty(w,"signal",{enumerable:!0,get:()=>(Sn(this,pv,!0),n.signal)})},o=()=>{const w=Wxe(this.options,r),A=(()=>{const C={client:Ct(this,mv),queryKey:this.queryKey,meta:this.meta};return s(C),C})();return Sn(this,pv,!1),this.options.persister?this.options.persister(w,A,this):w(A)},a=(()=>{const w={fetchOptions:r,options:this.options,queryKey:this.queryKey,client:Ct(this,mv),state:this.state,fetchFn:o};return s(w),w})();(m=this.options.behavior)==null||m.onFetch(a,this),Sn(this,fv,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((y=a.fetchOptions)==null?void 0:y.meta))&&Zs(this,ff,Xp).call(this,{type:"fetch",meta:(_=a.fetchOptions)==null?void 0:_.meta});const f=w=>{var E,A,C,I;Vz(w)&&w.silent||Zs(this,ff,Xp).call(this,{type:"error",error:w}),Vz(w)||((A=(E=Ct(this,fh).config).onError)==null||A.call(E,w,this),(I=(C=Ct(this,fh).config).onSettled)==null||I.call(C,this.state.data,w,this)),this.scheduleGc()};return Sn(this,Cc,Xxe({initialPromise:r==null?void 0:r.initialPromise,fn:a.fetchFn,abort:n.abort.bind(n),onSuccess:w=>{var E,A,C,I;if(w===void 0){f(new Error(`${this.queryHash} data is undefined`));return}try{this.setData(w)}catch(M){f(M);return}(A=(E=Ct(this,fh).config).onSuccess)==null||A.call(E,w,this),(I=(C=Ct(this,fh).config).onSettled)==null||I.call(C,w,this.state.error,this),this.scheduleGc()},onError:f,onFail:(w,E)=>{Zs(this,ff,Xp).call(this,{type:"failed",failureCount:w,error:E})},onPause:()=>{Zs(this,ff,Xp).call(this,{type:"pause"})},onContinue:()=>{Zs(this,ff,Xp).call(this,{type:"continue"})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0})),Ct(this,Cc).start()}},AS=new WeakMap,fv=new WeakMap,fh=new WeakMap,mv=new WeakMap,Cc=new WeakMap,iC=new WeakMap,pv=new WeakMap,ff=new WeakSet,Xp=function(e){const r=n=>{switch(e.type){case"failed":return{...n,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...n,fetchStatus:"paused"};case"continue":return{...n,fetchStatus:"fetching"};case"fetch":return{...n,...Jxe(n.data,this.options),fetchMeta:e.meta??null};case"success":return Sn(this,fv,void 0),{...n,data:e.data,dataUpdateCount:n.dataUpdateCount+1,dataUpdatedAt:e.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":const s=e.error;return Vz(s)&&s.revert&&Ct(this,fv)?{...Ct(this,fv),fetchStatus:"idle"}:{...n,error:s,errorUpdateCount:n.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:n.fetchFailureCount+1,fetchFailureReason:s,fetchStatus:"idle",status:"error"};case"invalidate":return{...n,isInvalidated:!0};case"setState":return{...n,...e.state}}};this.state=r(this.state),Tl.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),Ct(this,fh).notify({query:this,type:"updated",action:e})})},eme);function Jxe(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Yxe(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function rze(t){const e=typeof t.initialData=="function"?t.initialData():t.initialData,r=e!==void 0,n=r?typeof t.initialDataUpdatedAt=="function"?t.initialDataUpdatedAt():t.initialDataUpdatedAt:0;return{data:e,dataUpdateCount:0,dataUpdatedAt:r?n??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}var km,tme,nze=(tme=class extends YT{constructor(e={}){super();os(this,km);this.config=e,Sn(this,km,new Map)}build(e,r,n){const s=r.queryKey,o=r.queryHash??qH(s,r);let c=this.get(o);return c||(c=new tze({client:e,queryKey:s,queryHash:o,options:e.defaultQueryOptions(r),state:n,defaultOptions:e.getQueryDefaults(s)}),this.add(c)),c}add(e){Ct(this,km).has(e.queryHash)||(Ct(this,km).set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){const r=Ct(this,km).get(e.queryHash);r&&(e.destroy(),r===e&&Ct(this,km).delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){Tl.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return Ct(this,km).get(e)}getAll(){return[...Ct(this,km).values()]}find(e){const r={exact:!0,...e};return this.getAll().find(n=>wne(r,n))}findAll(e={}){const r=this.getAll();return Object.keys(e).length>0?r.filter(n=>wne(e,n)):r}notify(e){Tl.batch(()=>{this.listeners.forEach(r=>{r(e)})})}onFocus(){Tl.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){Tl.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},km=new WeakMap,tme),Am,lu,gv,Nm,qy,rme,sze=(rme=class extends Qxe{constructor(e){super();os(this,Nm);os(this,Am);os(this,lu);os(this,gv);this.mutationId=e.mutationId,Sn(this,lu,e.mutationCache),Sn(this,Am,[]),this.state=e.state||e0e(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){Ct(this,Am).includes(e)||(Ct(this,Am).push(e),this.clearGcTimeout(),Ct(this,lu).notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){Sn(this,Am,Ct(this,Am).filter(r=>r!==e)),this.scheduleGc(),Ct(this,lu).notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){Ct(this,Am).length||(this.state.status==="pending"?this.scheduleGc():Ct(this,lu).remove(this))}continue(){var e;return((e=Ct(this,gv))==null?void 0:e.continue())??this.execute(this.state.variables)}async execute(e){var o,c,a,f,m,y,_,w,E,A,C,I,M,D,B,U,q,H,K,Q;const r=()=>{Zs(this,Nm,qy).call(this,{type:"continue"})};Sn(this,gv,Xxe({fn:()=>this.options.mutationFn?this.options.mutationFn(e):Promise.reject(new Error("No mutationFn found")),onFail:(J,ee)=>{Zs(this,Nm,qy).call(this,{type:"failed",failureCount:J,error:ee})},onPause:()=>{Zs(this,Nm,qy).call(this,{type:"pause"})},onContinue:r,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>Ct(this,lu).canRun(this)}));const n=this.state.status==="pending",s=!Ct(this,gv).canStart();try{if(n)r();else{Zs(this,Nm,qy).call(this,{type:"pending",variables:e,isPaused:s}),await((c=(o=Ct(this,lu).config).onMutate)==null?void 0:c.call(o,e,this));const ee=await((f=(a=this.options).onMutate)==null?void 0:f.call(a,e));ee!==this.state.context&&Zs(this,Nm,qy).call(this,{type:"pending",context:ee,variables:e,isPaused:s})}const J=await Ct(this,gv).start();return await((y=(m=Ct(this,lu).config).onSuccess)==null?void 0:y.call(m,J,e,this.state.context,this)),await((w=(_=this.options).onSuccess)==null?void 0:w.call(_,J,e,this.state.context)),await((A=(E=Ct(this,lu).config).onSettled)==null?void 0:A.call(E,J,null,this.state.variables,this.state.context,this)),await((I=(C=this.options).onSettled)==null?void 0:I.call(C,J,null,e,this.state.context)),Zs(this,Nm,qy).call(this,{type:"success",data:J}),J}catch(J){try{throw await((D=(M=Ct(this,lu).config).onError)==null?void 0:D.call(M,J,e,this.state.context,this)),await((U=(B=this.options).onError)==null?void 0:U.call(B,J,e,this.state.context)),await((H=(q=Ct(this,lu).config).onSettled)==null?void 0:H.call(q,void 0,J,this.state.variables,this.state.context,this)),await((Q=(K=this.options).onSettled)==null?void 0:Q.call(K,void 0,J,e,this.state.context)),J}finally{Zs(this,Nm,qy).call(this,{type:"error",error:J})}}finally{Ct(this,lu).runNext(this)}}},Am=new WeakMap,lu=new WeakMap,gv=new WeakMap,Nm=new WeakSet,qy=function(e){const r=n=>{switch(e.type){case"failed":return{...n,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...n,isPaused:!0};case"continue":return{...n,isPaused:!1};case"pending":return{...n,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...n,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...n,data:void 0,error:e.error,failureCount:n.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}};this.state=r(this.state),Tl.batch(()=>{Ct(this,Am).forEach(n=>{n.onMutationUpdate(e)}),Ct(this,lu).notify({mutation:this,type:"updated",action:e})})},rme);function e0e(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var og,mf,aC,nme,ize=(nme=class extends YT{constructor(e={}){super();os(this,og);os(this,mf);os(this,aC);this.config=e,Sn(this,og,new Set),Sn(this,mf,new Map),Sn(this,aC,0)}build(e,r,n){const s=new sze({mutationCache:this,mutationId:++PR(this,aC)._,options:e.defaultMutationOptions(r),state:n});return this.add(s),s}add(e){Ct(this,og).add(e);const r=sL(e);if(typeof r=="string"){const n=Ct(this,mf).get(r);n?n.push(e):Ct(this,mf).set(r,[e])}this.notify({type:"added",mutation:e})}remove(e){if(Ct(this,og).delete(e)){const r=sL(e);if(typeof r=="string"){const n=Ct(this,mf).get(r);if(n)if(n.length>1){const s=n.indexOf(e);s!==-1&&n.splice(s,1)}else n[0]===e&&Ct(this,mf).delete(r)}}this.notify({type:"removed",mutation:e})}canRun(e){const r=sL(e);if(typeof r=="string"){const n=Ct(this,mf).get(r),s=n==null?void 0:n.find(o=>o.state.status==="pending");return!s||s===e}else return!0}runNext(e){var n;const r=sL(e);if(typeof r=="string"){const s=(n=Ct(this,mf).get(r))==null?void 0:n.find(o=>o!==e&&o.state.isPaused);return(s==null?void 0:s.continue())??Promise.resolve()}else return Promise.resolve()}clear(){Tl.batch(()=>{Ct(this,og).forEach(e=>{this.notify({type:"removed",mutation:e})}),Ct(this,og).clear(),Ct(this,mf).clear()})}getAll(){return Array.from(Ct(this,og))}find(e){const r={exact:!0,...e};return this.getAll().find(n=>Sne(r,n))}findAll(e={}){return this.getAll().filter(r=>Sne(e,r))}notify(e){Tl.batch(()=>{this.listeners.forEach(r=>{r(e)})})}resumePausedMutations(){const e=this.getAll().filter(r=>r.state.isPaused);return Tl.batch(()=>Promise.all(e.map(r=>r.continue().catch(du))))}},og=new WeakMap,mf=new WeakMap,aC=new WeakMap,nme);function sL(t){var e;return(e=t.options.scope)==null?void 0:e.id}function jne(t){return{onFetch:(e,r)=>{var y,_,w,E,A;const n=e.options,s=(w=(_=(y=e.fetchOptions)==null?void 0:y.meta)==null?void 0:_.fetchMore)==null?void 0:w.direction,o=((E=e.state.data)==null?void 0:E.pages)||[],c=((A=e.state.data)==null?void 0:A.pageParams)||[];let a={pages:[],pageParams:[]},f=0;const m=async()=>{let C=!1;const I=B=>{Object.defineProperty(B,"signal",{enumerable:!0,get:()=>(e.signal.aborted?C=!0:e.signal.addEventListener("abort",()=>{C=!0}),e.signal)})},M=Wxe(e.options,e.fetchOptions),D=async(B,U,q)=>{if(C)return Promise.reject();if(U==null&&B.pages.length)return Promise.resolve(B);const K=(()=>{const oe={client:e.client,queryKey:e.queryKey,pageParam:U,direction:q?"backward":"forward",meta:e.options.meta};return I(oe),oe})(),Q=await M(K),{maxPages:J}=e.options,ee=q?Y$e:K$e;return{pages:ee(B.pages,Q,J),pageParams:ee(B.pageParams,U,J)}};if(s&&o.length){const B=s==="backward",U=B?t0e:L8,q={pages:o,pageParams:c},H=U(n,q);a=await D(q,H,B)}else{const B=t??o.length;do{const U=f===0?c[0]??n.initialPageParam:L8(n,a);if(f>0&&U==null)break;a=await D(a,U),f++}while(f{var C,I;return(I=(C=e.options).persister)==null?void 0:I.call(C,m,{client:e.client,queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},r)}:e.fetchFn=m}}}function L8(t,{pages:e,pageParams:r}){const n=e.length-1;return e.length>0?t.getNextPageParam(e[n],e,r[n],r):void 0}function t0e(t,{pages:e,pageParams:r}){var n;return e.length>0?(n=t.getPreviousPageParam)==null?void 0:n.call(t,e[0],e,r[0],r):void 0}function yQt(t,e){return e?L8(t,e)!=null:!1}function xQt(t,e){return!e||!t.getPreviousPageParam?!1:t0e(t,e)!=null}var ko,lx,cx,NS,CS,ux,IS,PS,sme,aze=(sme=class{constructor(t={}){os(this,ko);os(this,lx);os(this,cx);os(this,NS);os(this,CS);os(this,ux);os(this,IS);os(this,PS);Sn(this,ko,t.queryCache||new nze),Sn(this,lx,t.mutationCache||new ize),Sn(this,cx,t.defaultOptions||{}),Sn(this,NS,new Map),Sn(this,CS,new Map),Sn(this,ux,0)}mount(){PR(this,ux)._++,Ct(this,ux)===1&&(Sn(this,IS,HH.subscribe(async t=>{t&&(await this.resumePausedMutations(),Ct(this,ko).onFocus())})),Sn(this,PS,VD.subscribe(async t=>{t&&(await this.resumePausedMutations(),Ct(this,ko).onOnline())})))}unmount(){var t,e;PR(this,ux)._--,Ct(this,ux)===0&&((t=Ct(this,IS))==null||t.call(this),Sn(this,IS,void 0),(e=Ct(this,PS))==null||e.call(this),Sn(this,PS,void 0))}isFetching(t){return Ct(this,ko).findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return Ct(this,lx).findAll({...t,status:"pending"}).length}getQueryData(t){var r;const e=this.defaultQueryOptions({queryKey:t});return(r=Ct(this,ko).get(e.queryHash))==null?void 0:r.state.data}ensureQueryData(t){const e=this.defaultQueryOptions(t),r=Ct(this,ko).build(this,e),n=r.state.data;return n===void 0?this.fetchQuery(t):(t.revalidateIfStale&&r.isStaleByTime(Cx(e.staleTime,r))&&this.prefetchQuery(e),Promise.resolve(n))}getQueriesData(t){return Ct(this,ko).findAll(t).map(({queryKey:e,state:r})=>{const n=r.data;return[e,n]})}setQueryData(t,e,r){const n=this.defaultQueryOptions({queryKey:t}),s=Ct(this,ko).get(n.queryHash),o=s==null?void 0:s.state.data,c=H$e(e,o);if(c!==void 0)return Ct(this,ko).build(this,n).setData(c,{...r,manual:!0})}setQueriesData(t,e,r){return Tl.batch(()=>Ct(this,ko).findAll(t).map(({queryKey:n})=>[n,this.setQueryData(n,e,r)]))}getQueryState(t){var r;const e=this.defaultQueryOptions({queryKey:t});return(r=Ct(this,ko).get(e.queryHash))==null?void 0:r.state}removeQueries(t){const e=Ct(this,ko);Tl.batch(()=>{e.findAll(t).forEach(r=>{e.remove(r)})})}resetQueries(t,e){const r=Ct(this,ko);return Tl.batch(()=>(r.findAll(t).forEach(n=>{n.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){const r={revert:!0,...e},n=Tl.batch(()=>Ct(this,ko).findAll(t).map(s=>s.cancel(r)));return Promise.all(n).then(du).catch(du)}invalidateQueries(t,e={}){return Tl.batch(()=>(Ct(this,ko).findAll(t).forEach(r=>{r.invalidate()}),(t==null?void 0:t.refetchType)==="none"?Promise.resolve():this.refetchQueries({...t,type:(t==null?void 0:t.refetchType)??(t==null?void 0:t.type)??"active"},e)))}refetchQueries(t,e={}){const r={...e,cancelRefetch:e.cancelRefetch??!0},n=Tl.batch(()=>Ct(this,ko).findAll(t).filter(s=>!s.isDisabled()&&!s.isStatic()).map(s=>{let o=s.fetch(void 0,r);return r.throwOnError||(o=o.catch(du)),s.state.fetchStatus==="paused"?Promise.resolve():o}));return Promise.all(n).then(du)}fetchQuery(t){const e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);const r=Ct(this,ko).build(this,e);return r.isStaleByTime(Cx(e.staleTime,r))?r.fetch(e):Promise.resolve(r.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(du).catch(du)}fetchInfiniteQuery(t){return t.behavior=jne(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(du).catch(du)}ensureInfiniteQueryData(t){return t.behavior=jne(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return VD.isOnline()?Ct(this,lx).resumePausedMutations():Promise.resolve()}getQueryCache(){return Ct(this,ko)}getMutationCache(){return Ct(this,lx)}getDefaultOptions(){return Ct(this,cx)}setDefaultOptions(t){Sn(this,cx,t)}setQueryDefaults(t,e){Ct(this,NS).set(Uv(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){const e=[...Ct(this,NS).values()],r={};return e.forEach(n=>{YA(t,n.queryKey)&&Object.assign(r,n.defaultOptions)}),r}setMutationDefaults(t,e){Ct(this,CS).set(Uv(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){const e=[...Ct(this,CS).values()],r={};return e.forEach(n=>{YA(t,n.mutationKey)&&Object.assign(r,n.defaultOptions)}),r}defaultQueryOptions(t){if(t._defaulted)return t;const e={...Ct(this,cx).queries,...this.getQueryDefaults(t.queryKey),...t,_defaulted:!0};return e.queryHash||(e.queryHash=qH(e.queryKey,e)),e.refetchOnReconnect===void 0&&(e.refetchOnReconnect=e.networkMode!=="always"),e.throwOnError===void 0&&(e.throwOnError=!!e.suspense),!e.networkMode&&e.persister&&(e.networkMode="offlineFirst"),e.queryFn===GH&&(e.enabled=!1),e}defaultMutationOptions(t){return t!=null&&t._defaulted?t:{...Ct(this,cx).mutations,...(t==null?void 0:t.mutationKey)&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){Ct(this,ko).clear(),Ct(this,lx).clear()}},ko=new WeakMap,lx=new WeakMap,cx=new WeakMap,NS=new WeakMap,CS=new WeakMap,ux=new WeakMap,IS=new WeakMap,PS=new WeakMap,sme),$u,mi,oC,cu,yv,RS,dx,hx,lC,LS,MS,xv,_v,fx,DS,Wi,Pk,M8,D8,O8,F8,B8,$8,z8,r0e,ime,oze=(ime=class extends YT{constructor(e,r){super();os(this,Wi);os(this,$u);os(this,mi);os(this,oC);os(this,cu);os(this,yv);os(this,RS);os(this,dx);os(this,hx);os(this,lC);os(this,LS);os(this,MS);os(this,xv);os(this,_v);os(this,fx);os(this,DS,new Set);this.options=r,Sn(this,$u,e),Sn(this,hx,null),Sn(this,dx,R8()),this.options.experimental_prefetchInRender||Ct(this,dx).reject(new Error("experimental_prefetchInRender feature flag is not enabled")),this.bindMethods(),this.setOptions(r)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(Ct(this,mi).addObserver(this),kne(Ct(this,mi),this.options)?Zs(this,Wi,Pk).call(this):this.updateResult(),Zs(this,Wi,F8).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return U8(Ct(this,mi),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return U8(Ct(this,mi),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,Zs(this,Wi,B8).call(this),Zs(this,Wi,$8).call(this),Ct(this,mi).removeObserver(this)}setOptions(e){const r=this.options,n=Ct(this,mi);if(this.options=Ct(this,$u).defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof mh(this.options.enabled,Ct(this,mi))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");Zs(this,Wi,z8).call(this),Ct(this,mi).setOptions(this.options),r._defaulted&&!UD(this.options,r)&&Ct(this,$u).getQueryCache().notify({type:"observerOptionsUpdated",query:Ct(this,mi),observer:this});const s=this.hasListeners();s&&Ane(Ct(this,mi),n,this.options,r)&&Zs(this,Wi,Pk).call(this),this.updateResult(),s&&(Ct(this,mi)!==n||mh(this.options.enabled,Ct(this,mi))!==mh(r.enabled,Ct(this,mi))||Cx(this.options.staleTime,Ct(this,mi))!==Cx(r.staleTime,Ct(this,mi)))&&Zs(this,Wi,M8).call(this);const o=Zs(this,Wi,D8).call(this);s&&(Ct(this,mi)!==n||mh(this.options.enabled,Ct(this,mi))!==mh(r.enabled,Ct(this,mi))||o!==Ct(this,fx))&&Zs(this,Wi,O8).call(this,o)}getOptimisticResult(e){const r=Ct(this,$u).getQueryCache().build(Ct(this,$u),e),n=this.createResult(r,e);return cze(this,n)&&(Sn(this,cu,n),Sn(this,RS,this.options),Sn(this,yv,Ct(this,mi).state)),n}getCurrentResult(){return Ct(this,cu)}trackResult(e,r){return new Proxy(e,{get:(n,s)=>(this.trackProp(s),r==null||r(s),Reflect.get(n,s))})}trackProp(e){Ct(this,DS).add(e)}getCurrentQuery(){return Ct(this,mi)}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){const r=Ct(this,$u).defaultQueryOptions(e),n=Ct(this,$u).getQueryCache().build(Ct(this,$u),r);return n.fetch().then(()=>this.createResult(n,r))}fetch(e){return Zs(this,Wi,Pk).call(this,{...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),Ct(this,cu)))}createResult(e,r){var J;const n=Ct(this,mi),s=this.options,o=Ct(this,cu),c=Ct(this,yv),a=Ct(this,RS),m=e!==n?e.state:Ct(this,oC),{state:y}=e;let _={...y},w=!1,E;if(r._optimisticResults){const ee=this.hasListeners(),oe=!ee&&kne(e,r),de=ee&&Ane(e,n,r,s);(oe||de)&&(_={..._,...Jxe(y.data,e.options)}),r._optimisticResults==="isRestoring"&&(_.fetchStatus="idle")}let{error:A,errorUpdatedAt:C,status:I}=_;E=_.data;let M=!1;if(r.placeholderData!==void 0&&E===void 0&&I==="pending"){let ee;o!=null&&o.isPlaceholderData&&r.placeholderData===(a==null?void 0:a.placeholderData)?(ee=o.data,M=!0):ee=typeof r.placeholderData=="function"?r.placeholderData((J=Ct(this,MS))==null?void 0:J.state.data,Ct(this,MS)):r.placeholderData,ee!==void 0&&(I="success",E=P8(o==null?void 0:o.data,ee,r),w=!0)}if(r.select&&E!==void 0&&!M)if(o&&E===(c==null?void 0:c.data)&&r.select===Ct(this,lC))E=Ct(this,LS);else try{Sn(this,lC,r.select),E=r.select(E),E=P8(o==null?void 0:o.data,E,r),Sn(this,LS,E),Sn(this,hx,null)}catch(ee){Sn(this,hx,ee)}Ct(this,hx)&&(A=Ct(this,hx),E=Ct(this,LS),C=Date.now(),I="error");const D=_.fetchStatus==="fetching",B=I==="pending",U=I==="error",q=B&&D,H=E!==void 0,Q={status:I,fetchStatus:_.fetchStatus,isPending:B,isSuccess:I==="success",isError:U,isInitialLoading:q,isLoading:q,data:E,dataUpdatedAt:_.dataUpdatedAt,error:A,errorUpdatedAt:C,failureCount:_.fetchFailureCount,failureReason:_.fetchFailureReason,errorUpdateCount:_.errorUpdateCount,isFetched:_.dataUpdateCount>0||_.errorUpdateCount>0,isFetchedAfterMount:_.dataUpdateCount>m.dataUpdateCount||_.errorUpdateCount>m.errorUpdateCount,isFetching:D,isRefetching:D&&!B,isLoadingError:U&&!H,isPaused:_.fetchStatus==="paused",isPlaceholderData:w,isRefetchError:U&&H,isStale:WH(e,r),refetch:this.refetch,promise:Ct(this,dx),isEnabled:mh(r.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){const ee=ye=>{Q.status==="error"?ye.reject(Q.error):Q.data!==void 0&&ye.resolve(Q.data)},oe=()=>{const ye=Sn(this,dx,Q.promise=R8());ee(ye)},de=Ct(this,dx);switch(de.status){case"pending":e.queryHash===n.queryHash&&ee(de);break;case"fulfilled":(Q.status==="error"||Q.data!==de.value)&&oe();break;case"rejected":(Q.status!=="error"||Q.error!==de.reason)&&oe();break}}return Q}updateResult(){const e=Ct(this,cu),r=this.createResult(Ct(this,mi),this.options);if(Sn(this,yv,Ct(this,mi).state),Sn(this,RS,this.options),Ct(this,yv).data!==void 0&&Sn(this,MS,Ct(this,mi)),UD(r,e))return;Sn(this,cu,r);const n=()=>{if(!e)return!0;const{notifyOnChangeProps:s}=this.options,o=typeof s=="function"?s():s;if(o==="all"||!o&&!Ct(this,DS).size)return!0;const c=new Set(o??Ct(this,DS));return this.options.throwOnError&&c.add("error"),Object.keys(Ct(this,cu)).some(a=>{const f=a;return Ct(this,cu)[f]!==e[f]&&c.has(f)})};Zs(this,Wi,r0e).call(this,{listeners:n()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&Zs(this,Wi,F8).call(this)}},$u=new WeakMap,mi=new WeakMap,oC=new WeakMap,cu=new WeakMap,yv=new WeakMap,RS=new WeakMap,dx=new WeakMap,hx=new WeakMap,lC=new WeakMap,LS=new WeakMap,MS=new WeakMap,xv=new WeakMap,_v=new WeakMap,fx=new WeakMap,DS=new WeakMap,Wi=new WeakSet,Pk=function(e){Zs(this,Wi,z8).call(this);let r=Ct(this,mi).fetch(this.options,e);return e!=null&&e.throwOnError||(r=r.catch(du)),r},M8=function(){Zs(this,Wi,B8).call(this);const e=Cx(this.options.staleTime,Ct(this,mi));if(zv||Ct(this,cu).isStale||!C8(e))return;const n=Gxe(Ct(this,cu).dataUpdatedAt,e)+1;Sn(this,xv,setTimeout(()=>{Ct(this,cu).isStale||this.updateResult()},n))},D8=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(Ct(this,mi)):this.options.refetchInterval)??!1},O8=function(e){Zs(this,Wi,$8).call(this),Sn(this,fx,e),!(zv||mh(this.options.enabled,Ct(this,mi))===!1||!C8(Ct(this,fx))||Ct(this,fx)===0)&&Sn(this,_v,setInterval(()=>{(this.options.refetchIntervalInBackground||HH.isFocused())&&Zs(this,Wi,Pk).call(this)},Ct(this,fx)))},F8=function(){Zs(this,Wi,M8).call(this),Zs(this,Wi,O8).call(this,Zs(this,Wi,D8).call(this))},B8=function(){Ct(this,xv)&&(clearTimeout(Ct(this,xv)),Sn(this,xv,void 0))},$8=function(){Ct(this,_v)&&(clearInterval(Ct(this,_v)),Sn(this,_v,void 0))},z8=function(){const e=Ct(this,$u).getQueryCache().build(Ct(this,$u),this.options);if(e===Ct(this,mi))return;const r=Ct(this,mi);Sn(this,mi,e),Sn(this,oC,e.state),this.hasListeners()&&(r==null||r.removeObserver(this),e.addObserver(this))},r0e=function(e){Tl.batch(()=>{e.listeners&&this.listeners.forEach(r=>{r(Ct(this,cu))}),Ct(this,$u).getQueryCache().notify({query:Ct(this,mi),type:"observerResultsUpdated"})})},ime);function lze(t,e){return mh(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&e.retryOnMount===!1)}function kne(t,e){return lze(t,e)||t.state.data!==void 0&&U8(t,e,e.refetchOnMount)}function U8(t,e,r){if(mh(e.enabled,t)!==!1&&Cx(e.staleTime,t)!=="static"){const n=typeof r=="function"?r(t):r;return n==="always"||n!==!1&&WH(t,e)}return!1}function Ane(t,e,r,n){return(t!==e||mh(n.enabled,t)===!1)&&(!r.suspense||t.state.status!=="error")&&WH(t,r)}function WH(t,e){return mh(e.enabled,t)!==!1&&t.isStaleByTime(Cx(e.staleTime,t))}function cze(t,e){return!UD(t.getCurrentResult(),e)}var mx,px,zu,lg,wg,CM,V8,ame,uze=(ame=class extends YT{constructor(r,n){super();os(this,wg);os(this,mx);os(this,px);os(this,zu);os(this,lg);Sn(this,mx,r),this.setOptions(n),this.bindMethods(),Zs(this,wg,CM).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(r){var s;const n=this.options;this.options=Ct(this,mx).defaultMutationOptions(r),UD(this.options,n)||Ct(this,mx).getMutationCache().notify({type:"observerOptionsUpdated",mutation:Ct(this,zu),observer:this}),n!=null&&n.mutationKey&&this.options.mutationKey&&Uv(n.mutationKey)!==Uv(this.options.mutationKey)?this.reset():((s=Ct(this,zu))==null?void 0:s.state.status)==="pending"&&Ct(this,zu).setOptions(this.options)}onUnsubscribe(){var r;this.hasListeners()||(r=Ct(this,zu))==null||r.removeObserver(this)}onMutationUpdate(r){Zs(this,wg,CM).call(this),Zs(this,wg,V8).call(this,r)}getCurrentResult(){return Ct(this,px)}reset(){var r;(r=Ct(this,zu))==null||r.removeObserver(this),Sn(this,zu,void 0),Zs(this,wg,CM).call(this),Zs(this,wg,V8).call(this)}mutate(r,n){var s;return Sn(this,lg,n),(s=Ct(this,zu))==null||s.removeObserver(this),Sn(this,zu,Ct(this,mx).getMutationCache().build(Ct(this,mx),this.options)),Ct(this,zu).addObserver(this),Ct(this,zu).execute(r)}},mx=new WeakMap,px=new WeakMap,zu=new WeakMap,lg=new WeakMap,wg=new WeakSet,CM=function(){var n;const r=((n=Ct(this,zu))==null?void 0:n.state)??e0e();Sn(this,px,{...r,isPending:r.status==="pending",isSuccess:r.status==="success",isError:r.status==="error",isIdle:r.status==="idle",mutate:this.mutate,reset:this.reset})},V8=function(r){Tl.batch(()=>{var n,s,o,c,a,f,m,y;if(Ct(this,lg)&&this.hasListeners()){const _=Ct(this,px).variables,w=Ct(this,px).context;(r==null?void 0:r.type)==="success"?((s=(n=Ct(this,lg)).onSuccess)==null||s.call(n,r.data,_,w),(c=(o=Ct(this,lg)).onSettled)==null||c.call(o,r.data,null,_,w)):(r==null?void 0:r.type)==="error"&&((f=(a=Ct(this,lg)).onError)==null||f.call(a,r.error,_,w),(y=(m=Ct(this,lg)).onSettled)==null||y.call(m,void 0,r.error,_,w))}this.listeners.forEach(_=>{_(Ct(this,px))})})},ame),n0e=N.createContext(void 0),jr=t=>{const e=N.useContext(n0e);if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},dze=({client:t,children:e})=>(N.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),i.jsx(n0e.Provider,{value:t,children:e})),s0e=N.createContext(!1),hze=()=>N.useContext(s0e);s0e.Provider;function fze(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var mze=N.createContext(fze()),pze=()=>N.useContext(mze),gze=(t,e)=>{(t.suspense||t.throwOnError||t.experimental_prefetchInRender)&&(e.isReset()||(t.retryOnMount=!1))},yze=t=>{N.useEffect(()=>{t.clearReset()},[t])},xze=({result:t,errorResetBoundary:e,throwOnError:r,query:n,suspense:s})=>t.isError&&!e.isReset()&&!t.isFetching&&n&&(s&&t.data===void 0||Kxe(r,[t.error,n])),_ze=t=>{if(t.suspense){const e=n=>n==="static"?n:Math.max(n??1e3,1e3),r=t.staleTime;t.staleTime=typeof r=="function"?(...n)=>e(r(...n)):e(r),typeof t.gcTime=="number"&&(t.gcTime=Math.max(t.gcTime,1e3))}},vze=(t,e)=>t.isLoading&&t.isFetching&&!e,bze=(t,e)=>(t==null?void 0:t.suspense)&&e.isPending,Nne=(t,e,r)=>e.fetchOptimistic(t).catch(()=>{r.clearReset()});function wze(t,e,r){var _,w,E,A,C;const n=hze(),s=pze(),o=jr(),c=o.defaultQueryOptions(t);(w=(_=o.getDefaultOptions().queries)==null?void 0:_._experimental_beforeQuery)==null||w.call(_,c),c._optimisticResults=n?"isRestoring":"optimistic",_ze(c),gze(c,s),yze(s);const a=!o.getQueryCache().get(c.queryHash),[f]=N.useState(()=>new e(o,c)),m=f.getOptimisticResult(c),y=!n&&t.subscribed!==!1;if(N.useSyncExternalStore(N.useCallback(I=>{const M=y?f.subscribe(Tl.batchCalls(I)):du;return f.updateResult(),M},[f,y]),()=>f.getCurrentResult(),()=>f.getCurrentResult()),N.useEffect(()=>{f.setOptions(c)},[c,f]),bze(c,m))throw Nne(c,f,s);if(xze({result:m,errorResetBoundary:s,throwOnError:c.throwOnError,query:o.getQueryCache().get(c.queryHash),suspense:c.suspense}))throw m.error;if((A=(E=o.getDefaultOptions().queries)==null?void 0:E._experimental_afterQuery)==null||A.call(E,c,m),c.experimental_prefetchInRender&&!zv&&vze(m,n)){const I=a?Nne(c,f,s):(C=o.getQueryCache().get(c.queryHash))==null?void 0:C.promise;I==null||I.catch(du).finally(()=>{f.updateResult()})}return c.notifyOnChangeProps?m:f.trackResult(m)}function mr(t,e){return wze(t,oze)}function kr(t,e){const r=jr(),[n]=N.useState(()=>new uze(r,t));N.useEffect(()=>{n.setOptions(t)},[n,t]);const s=N.useSyncExternalStore(N.useCallback(c=>n.subscribe(Tl.batchCalls(c)),[n]),()=>n.getCurrentResult(),()=>n.getCurrentResult()),o=N.useCallback((c,a)=>{n.mutate(c,a).catch(du)},[n]);if(s.error&&Kxe(n.options.throwOnError,[s.error]))throw s.error;return{...s,mutate:o,mutateAsync:s.mutate}}/** * @remix-run/router v1.23.0 * * Copyright (c) Remix Software Inc. * * This source code is licensed under the MIT license found in the * LICENSE.md file in the root directory of this source tree. * * @license MIT */function ZA(){return ZA=Object.assign?Object.assign.bind():function(t){for(var e=1;e"u")throw new Error(e)}function i0e(t,e){if(!t){typeof console<"u"&&console.warn(e);try{throw new Error(e)}catch{}}}function Tze(){return Math.random().toString(36).substr(2,8)}function Ine(t,e){return{usr:t.state,key:t.key,idx:e}}function q8(t,e,r,n){return r===void 0&&(r=null),ZA({pathname:typeof t=="string"?t:t.pathname,search:"",hash:""},typeof e=="string"?ZT(e):e,{state:r,key:e&&e.key||n||Tze()})}function qD(t){let{pathname:e="/",search:r="",hash:n=""}=t;return r&&r!=="?"&&(e+=r.charAt(0)==="?"?r:"?"+r),n&&n!=="#"&&(e+=n.charAt(0)==="#"?n:"#"+n),e}function ZT(t){let e={};if(t){let r=t.indexOf("#");r>=0&&(e.hash=t.substr(r),t=t.substr(0,r));let n=t.indexOf("?");n>=0&&(e.search=t.substr(n),t=t.substr(0,n)),t&&(e.pathname=t)}return e}function Eze(t,e,r,n){n===void 0&&(n={});let{window:s=document.defaultView,v5Compat:o=!1}=n,c=s.history,a=xx.Pop,f=null,m=y();m==null&&(m=0,c.replaceState(ZA({},c.state,{idx:m}),""));function y(){return(c.state||{idx:null}).idx}function _(){a=xx.Pop;let I=y(),M=I==null?null:I-m;m=I,f&&f({action:a,location:C.location,delta:M})}function w(I,M){a=xx.Push;let D=q8(C.location,I,M);m=y()+1;let B=Ine(D,m),U=C.createHref(D);try{c.pushState(B,"",U)}catch(q){if(q instanceof DOMException&&q.name==="DataCloneError")throw q;s.location.assign(U)}o&&f&&f({action:a,location:C.location,delta:1})}function E(I,M){a=xx.Replace;let D=q8(C.location,I,M);m=y();let B=Ine(D,m),U=C.createHref(D);c.replaceState(B,"",U),o&&f&&f({action:a,location:C.location,delta:0})}function A(I){let M=s.location.origin!=="null"?s.location.origin:s.location.href,D=typeof I=="string"?I:qD(I);return D=D.replace(/ $/,"%20"),go(M,"No window.location.(origin|href) available to create URL for href: "+D),new URL(D,M)}let C={get action(){return a},get location(){return t(s,c)},listen(I){if(f)throw new Error("A history only accepts one active listener");return s.addEventListener(Cne,_),f=I,()=>{s.removeEventListener(Cne,_),f=null}},createHref(I){return e(s,I)},createURL:A,encodeLocation(I){let M=A(I);return{pathname:M.pathname,search:M.search,hash:M.hash}},push:w,replace:E,go(I){return c.go(I)}};return C}var Pne;(function(t){t.data="data",t.deferred="deferred",t.redirect="redirect",t.error="error"})(Pne||(Pne={}));function jze(t,e,r){return r===void 0&&(r="/"),kze(t,e,r,!1)}function kze(t,e,r,n){let s=typeof e=="string"?ZT(e):e,o=KS(s.pathname||"/",r);if(o==null)return null;let c=a0e(t);Aze(c);let a=null;for(let f=0;a==null&&f{let f={relativePath:a===void 0?o.path||"":a,caseSensitive:o.caseSensitive===!0,childrenIndex:c,route:o};f.relativePath.startsWith("/")&&(go(f.relativePath.startsWith(n),'Absolute route path "'+f.relativePath+'" nested under path '+('"'+n+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),f.relativePath=f.relativePath.slice(n.length));let m=Ix([n,f.relativePath]),y=r.concat(f);o.children&&o.children.length>0&&(go(o.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+m+'".')),a0e(o.children,e,y,m)),!(o.path==null&&!o.index)&&e.push({path:m,score:Mze(m,o.index),routesMeta:y})};return t.forEach((o,c)=>{var a;if(o.path===""||!((a=o.path)!=null&&a.includes("?")))s(o,c);else for(let f of o0e(o.path))s(o,c,f)}),e}function o0e(t){let e=t.split("/");if(e.length===0)return[];let[r,...n]=e,s=r.endsWith("?"),o=r.replace(/\?$/,"");if(n.length===0)return s?[o,""]:[o];let c=o0e(n.join("/")),a=[];return a.push(...c.map(f=>f===""?o:[o,f].join("/"))),s&&a.push(...c),a.map(f=>t.startsWith("/")&&f===""?"/":f)}function Aze(t){t.sort((e,r)=>e.score!==r.score?r.score-e.score:Dze(e.routesMeta.map(n=>n.childrenIndex),r.routesMeta.map(n=>n.childrenIndex)))}const Nze=/^:[\w-]+$/,Cze=3,Ize=2,Pze=1,Rze=10,Lze=-2,Rne=t=>t==="*";function Mze(t,e){let r=t.split("/"),n=r.length;return r.some(Rne)&&(n+=Lze),e&&(n+=Ize),r.filter(s=>!Rne(s)).reduce((s,o)=>s+(Nze.test(o)?Cze:o===""?Pze:Rze),n)}function Dze(t,e){return t.length===e.length&&t.slice(0,-1).every((n,s)=>n===e[s])?t[t.length-1]-e[e.length-1]:0}function Oze(t,e,r){let{routesMeta:n}=t,s={},o="/",c=[];for(let a=0;a{let{paramName:w,isOptional:E}=y;if(w==="*"){let C=a[_]||"";c=o.slice(0,o.length-C.length).replace(/(.)\/+$/,"$1")}const A=a[_];return E&&!A?m[w]=void 0:m[w]=(A||"").replace(/%2F/g,"/"),m},{}),pathname:o,pathnameBase:c,pattern:t}}function Fze(t,e,r){e===void 0&&(e=!1),r===void 0&&(r=!0),i0e(t==="*"||!t.endsWith("*")||t.endsWith("/*"),'Route path "'+t+'" will be treated as if it were '+('"'+t.replace(/\*$/,"/*")+'" because the `*` character must ')+"always follow a `/` in the pattern. To get rid of this warning, "+('please change the route path to "'+t.replace(/\*$/,"/*")+'".'));let n=[],s="^"+t.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(c,a,f)=>(n.push({paramName:a,isOptional:f!=null}),f?"/?([^\\/]+)?":"/([^\\/]+)"));return t.endsWith("*")?(n.push({paramName:"*"}),s+=t==="*"||t==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):r?s+="\\/*$":t!==""&&t!=="/"&&(s+="(?:(?=\\/|$))"),[new RegExp(s,e?void 0:"i"),n]}function Bze(t){try{return t.split("/").map(e=>decodeURIComponent(e).replace(/\//g,"%2F")).join("/")}catch(e){return i0e(!1,'The URL path "'+t+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent '+("encoding ("+e+").")),t}}function KS(t,e){if(e==="/")return t;if(!t.toLowerCase().startsWith(e.toLowerCase()))return null;let r=e.endsWith("/")?e.length-1:e.length,n=t.charAt(r);return n&&n!=="/"?null:t.slice(r)||"/"}function $ze(t,e){e===void 0&&(e="/");let{pathname:r,search:n="",hash:s=""}=typeof t=="string"?ZT(t):t;return{pathname:r?r.startsWith("/")?r:zze(r,e):e,search:qze(n),hash:Gze(s)}}function zze(t,e){let r=e.replace(/\/+$/,"").split("/");return t.split("/").forEach(s=>{s===".."?r.length>1&&r.pop():s!=="."&&r.push(s)}),r.length>1?r.join("/"):"/"}function qz(t,e,r,n){return"Cannot include a '"+t+"' character in a manually specified "+("`to."+e+"` field ["+JSON.stringify(n)+"]. Please separate it out to the ")+("`to."+r+"` field. Alternatively you may provide the full path as ")+'a string in and the router will parse it for you.'}function Uze(t){return t.filter((e,r)=>r===0||e.route.path&&e.route.path.length>0)}function KH(t,e){let r=Uze(t);return e?r.map((n,s)=>s===r.length-1?n.pathname:n.pathnameBase):r.map(n=>n.pathnameBase)}function YH(t,e,r,n){n===void 0&&(n=!1);let s;typeof t=="string"?s=ZT(t):(s=ZA({},t),go(!s.pathname||!s.pathname.includes("?"),qz("?","pathname","search",s)),go(!s.pathname||!s.pathname.includes("#"),qz("#","pathname","hash",s)),go(!s.search||!s.search.includes("#"),qz("#","search","hash",s)));let o=t===""||s.pathname==="",c=o?"/":s.pathname,a;if(c==null)a=r;else{let _=e.length-1;if(!n&&c.startsWith("..")){let w=c.split("/");for(;w[0]==="..";)w.shift(),_-=1;s.pathname=w.join("/")}a=_>=0?e[_]:"/"}let f=$ze(s,a),m=c&&c!=="/"&&c.endsWith("/"),y=(o||c===".")&&r.endsWith("/");return!f.pathname.endsWith("/")&&(m||y)&&(f.pathname+="/"),f}const Ix=t=>t.join("/").replace(/\/\/+/g,"/"),Vze=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),qze=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,Gze=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t;function Hze(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}const l0e=["post","put","patch","delete"];new Set(l0e);const Wze=["get",...l0e];new Set(Wze);/** * React Router v6.30.1 * * Copyright (c) Remix Software Inc. * * This source code is licensed under the MIT license found in the * LICENSE.md file in the root directory of this source tree. * * @license MIT */function XA(){return XA=Object.assign?Object.assign.bind():function(t){for(var e=1;e{a.current=!0}),N.useCallback(function(m,y){if(y===void 0&&(y={}),!a.current)return;if(typeof m=="number"){n.go(m);return}let _=YH(m,JSON.parse(c),o,y.relative==="path");t==null&&e!=="/"&&(_.pathname=_.pathname==="/"?e:Ix([e,_.pathname])),(y.replace?n.replace:n.push)(_,y.state,y)},[e,n,c,o,t])}const Zze=N.createContext(null);function Xze(t){let e=N.useContext(op).outlet;return e&&N.createElement(Zze.Provider,{value:t},e)}function Vf(){let{matches:t}=N.useContext(op),e=t[t.length-1];return e?e.params:{}}function j4(t,e){let{relative:r}=e===void 0?{}:e,{future:n}=N.useContext($g),{matches:s}=N.useContext(op),{pathname:o}=js(),c=JSON.stringify(KH(s,n.v7_relativeSplatPath));return N.useMemo(()=>YH(t,JSON.parse(c),o,r==="path"),[t,c,o,r])}function Qze(t,e){return Jze(t,e)}function Jze(t,e,r,n){XT()||go(!1);let{navigator:s}=N.useContext($g),{matches:o}=N.useContext(op),c=o[o.length-1],a=c?c.params:{};c&&c.pathname;let f=c?c.pathnameBase:"/";c&&c.route;let m=js(),y;if(e){var _;let I=typeof e=="string"?ZT(e):e;f==="/"||(_=I.pathname)!=null&&_.startsWith(f)||go(!1),y=I}else y=m;let w=y.pathname||"/",E=w;if(f!=="/"){let I=f.replace(/^\//,"").split("/");E="/"+w.replace(/^\//,"").split("/").slice(I.length).join("/")}let A=jze(t,{pathname:E}),C=s6e(A&&A.map(I=>Object.assign({},I,{params:Object.assign({},a,I.params),pathname:Ix([f,s.encodeLocation?s.encodeLocation(I.pathname).pathname:I.pathname]),pathnameBase:I.pathnameBase==="/"?f:Ix([f,s.encodeLocation?s.encodeLocation(I.pathnameBase).pathname:I.pathnameBase])})),o,r,n);return e&&C?N.createElement(E4.Provider,{value:{location:XA({pathname:"/",search:"",hash:"",state:null,key:"default"},y),navigationType:xx.Pop}},C):C}function e6e(){let t=l6e(),e=Hze(t)?t.status+" "+t.statusText:t instanceof Error?t.message:JSON.stringify(t),r=t instanceof Error?t.stack:null,s={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return N.createElement(N.Fragment,null,N.createElement("h2",null,"Unexpected Application Error!"),N.createElement("h3",{style:{fontStyle:"italic"}},e),r?N.createElement("pre",{style:s},r):null,null)}const t6e=N.createElement(e6e,null);class r6e extends N.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,r){return r.location!==e.location||r.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?e.error:r.error,location:r.location,revalidation:e.revalidation||r.revalidation}}componentDidCatch(e,r){console.error("React Router caught the following error during render",e,r)}render(){return this.state.error!==void 0?N.createElement(op.Provider,{value:this.props.routeContext},N.createElement(u0e.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function n6e(t){let{routeContext:e,match:r,children:n}=t,s=N.useContext(T4);return s&&s.static&&s.staticContext&&(r.route.errorElement||r.route.ErrorBoundary)&&(s.staticContext._deepestRenderedBoundaryId=r.route.id),N.createElement(op.Provider,{value:e},n)}function s6e(t,e,r,n){var s;if(e===void 0&&(e=[]),r===void 0&&(r=null),n===void 0&&(n=null),t==null){var o;if(!r)return null;if(r.errors)t=r.matches;else if((o=n)!=null&&o.v7_partialHydration&&e.length===0&&!r.initialized&&r.matches.length>0)t=r.matches;else return null}let c=t,a=(s=r)==null?void 0:s.errors;if(a!=null){let y=c.findIndex(_=>_.route.id&&(a==null?void 0:a[_.route.id])!==void 0);y>=0||go(!1),c=c.slice(0,Math.min(c.length,y+1))}let f=!1,m=-1;if(r&&n&&n.v7_partialHydration)for(let y=0;y=0?c=c.slice(0,m+1):c=[c[0]];break}}}return c.reduceRight((y,_,w)=>{let E,A=!1,C=null,I=null;r&&(E=a&&_.route.id?a[_.route.id]:void 0,C=_.route.errorElement||t6e,f&&(m<0&&w===0?(A=!0,I=null):m===w&&(A=!0,I=_.route.hydrateFallbackElement||null)));let M=e.concat(c.slice(0,w+1)),D=()=>{let B;return E?B=C:A?B=I:_.route.Component?B=N.createElement(_.route.Component,null):_.route.element?B=_.route.element:B=y,N.createElement(n6e,{match:_,routeContext:{outlet:y,matches:M,isDataRoute:r!=null},children:B})};return r&&(_.route.ErrorBoundary||_.route.errorElement||w===0)?N.createElement(r6e,{location:r.location,revalidation:r.revalidation,component:C,error:E,children:D(),routeContext:{outlet:null,matches:M,isDataRoute:!0}}):D()},null)}var h0e=function(t){return t.UseBlocker="useBlocker",t.UseRevalidator="useRevalidator",t.UseNavigateStable="useNavigate",t}(h0e||{}),HD=function(t){return t.UseBlocker="useBlocker",t.UseLoaderData="useLoaderData",t.UseActionData="useActionData",t.UseRouteError="useRouteError",t.UseNavigation="useNavigation",t.UseRouteLoaderData="useRouteLoaderData",t.UseMatches="useMatches",t.UseRevalidator="useRevalidator",t.UseNavigateStable="useNavigate",t.UseRouteId="useRouteId",t}(HD||{});function i6e(t){let e=N.useContext(T4);return e||go(!1),e}function a6e(t){let e=N.useContext(c0e);return e||go(!1),e}function o6e(t){let e=N.useContext(op);return e||go(!1),e}function f0e(t){let e=o6e(),r=e.matches[e.matches.length-1];return r.route.id||go(!1),r.route.id}function l6e(){var t;let e=N.useContext(u0e),r=a6e(HD.UseRouteError),n=f0e(HD.UseRouteError);return e!==void 0?e:(t=r.errors)==null?void 0:t[n]}function c6e(){let{router:t}=i6e(h0e.UseNavigateStable),e=f0e(HD.UseNavigateStable),r=N.useRef(!1);return d0e(()=>{r.current=!0}),N.useCallback(function(s,o){o===void 0&&(o={}),r.current&&(typeof s=="number"?t.navigate(s):t.navigate(s,XA({fromRouteId:e},o)))},[t,e])}function u6e(t,e){t==null||t.v7_startTransition,t==null||t.v7_relativeSplatPath}function hs(t){let{to:e,replace:r,state:n,relative:s}=t;XT()||go(!1);let{future:o,static:c}=N.useContext($g),{matches:a}=N.useContext(op),{pathname:f}=js(),m=ra(),y=YH(e,KH(a,o.v7_relativeSplatPath),f,s==="path"),_=JSON.stringify(y);return N.useEffect(()=>m(JSON.parse(_),{replace:r,state:n,relative:s}),[m,_,s,r,n]),null}function vQt(t){return Xze(t.context)}function ge(t){go(!1)}function d6e(t){let{basename:e="/",children:r=null,location:n,navigationType:s=xx.Pop,navigator:o,static:c=!1,future:a}=t;XT()&&go(!1);let f=e.replace(/^\/*/,"/"),m=N.useMemo(()=>({basename:f,navigator:o,static:c,future:XA({v7_relativeSplatPath:!1},a)}),[f,a,o,c]);typeof n=="string"&&(n=ZT(n));let{pathname:y="/",search:_="",hash:w="",state:E=null,key:A="default"}=n,C=N.useMemo(()=>{let I=KS(y,f);return I==null?null:{location:{pathname:I,search:_,hash:w,state:E,key:A},navigationType:s}},[f,y,_,w,E,A,s]);return C==null?null:N.createElement($g.Provider,{value:m},N.createElement(E4.Provider,{children:r,value:C}))}function ag(t){let{children:e,location:r}=t;return Qze(G8(e),r)}new Promise(()=>{});function G8(t,e){e===void 0&&(e=[]);let r=[];return N.Children.forEach(t,(n,s)=>{if(!N.isValidElement(n))return;let o=[...e,s];if(n.type===N.Fragment){r.push.apply(r,G8(n.props.children,o));return}n.type!==ge&&go(!1),!n.props.index||!n.props.children||go(!1);let c={id:n.props.id||o.join("-"),caseSensitive:n.props.caseSensitive,element:n.props.element,Component:n.props.Component,index:n.props.index,path:n.props.path,loader:n.props.loader,action:n.props.action,errorElement:n.props.errorElement,ErrorBoundary:n.props.ErrorBoundary,hasErrorBoundary:n.props.ErrorBoundary!=null||n.props.errorElement!=null,shouldRevalidate:n.props.shouldRevalidate,handle:n.props.handle,lazy:n.props.lazy};n.props.children&&(c.children=G8(n.props.children,o)),r.push(c)}),r}/** * React Router DOM v6.30.1 * * Copyright (c) Remix Software Inc. * * This source code is licensed under the MIT license found in the * LICENSE.md file in the root directory of this source tree. * * @license MIT */function WD(){return WD=Object.assign?Object.assign.bind():function(t){for(var e=1;e=0)&&(r[s]=t[s]);return r}function h6e(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function f6e(t,e){return t.button===0&&(!e||e==="_self")&&!h6e(t)}function H8(t){return t===void 0&&(t=""),new URLSearchParams(typeof t=="string"||Array.isArray(t)||t instanceof URLSearchParams?t:Object.keys(t).reduce((e,r)=>{let n=t[r];return e.concat(Array.isArray(n)?n.map(s=>[r,s]):[[r,n]])},[]))}function m6e(t,e){let r=H8(t);return e&&e.forEach((n,s)=>{r.has(s)||e.getAll(s).forEach(o=>{r.append(s,o)})}),r}const p6e=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],g6e=["aria-current","caseSensitive","className","end","style","to","viewTransition","children"],y6e="6";try{window.__reactRouterVersion=y6e}catch{}const x6e=N.createContext({isTransitioning:!1}),_6e="startTransition",Lne=g7[_6e];function v6e(t){let{basename:e,children:r,future:n,window:s}=t,o=N.useRef();o.current==null&&(o.current=Sze({window:s,v5Compat:!0}));let c=o.current,[a,f]=N.useState({action:c.action,location:c.location}),{v7_startTransition:m}=n||{},y=N.useCallback(_=>{m&&Lne?Lne(()=>f(_)):f(_)},[f,m]);return N.useLayoutEffect(()=>c.listen(y),[c,y]),N.useEffect(()=>u6e(n),[n]),N.createElement(d6e,{basename:e,children:r,location:a.location,navigationType:a.action,navigator:c,future:n})}const b6e=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",w6e=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Br=N.forwardRef(function(e,r){let{onClick:n,relative:s,reloadDocument:o,replace:c,state:a,target:f,to:m,preventScrollReset:y,viewTransition:_}=e,w=m0e(e,p6e),{basename:E}=N.useContext($g),A,C=!1;if(typeof m=="string"&&w6e.test(m)&&(A=m,b6e))try{let B=new URL(window.location.href),U=m.startsWith("//")?new URL(B.protocol+m):new URL(m),q=KS(U.pathname,E);U.origin===B.origin&&q!=null?m=q+U.search+U.hash:C=!0}catch{}let I=Kze(m,{relative:s}),M=T6e(m,{replace:c,state:a,target:f,preventScrollReset:y,relative:s,viewTransition:_});function D(B){n&&n(B),B.defaultPrevented||M(B)}return N.createElement("a",WD({},w,{href:A||I,onClick:C||o?n:D,ref:r,target:f}))}),bQt=N.forwardRef(function(e,r){let{"aria-current":n="page",caseSensitive:s=!1,className:o="",end:c=!1,style:a,to:f,viewTransition:m,children:y}=e,_=m0e(e,g6e),w=j4(f,{relative:_.relative}),E=js(),A=N.useContext(c0e),{navigator:C,basename:I}=N.useContext($g),M=A!=null&&E6e(w)&&m===!0,D=C.encodeLocation?C.encodeLocation(w).pathname:w.pathname,B=E.pathname,U=A&&A.navigation&&A.navigation.location?A.navigation.location.pathname:null;s||(B=B.toLowerCase(),U=U?U.toLowerCase():null,D=D.toLowerCase()),U&&I&&(U=KS(U,I)||U);const q=D!=="/"&&D.endsWith("/")?D.length-1:D.length;let H=B===D||!c&&B.startsWith(D)&&B.charAt(q)==="/",K=U!=null&&(U===D||!c&&U.startsWith(D)&&U.charAt(D.length)==="/"),Q={isActive:H,isPending:K,isTransitioning:M},J=H?n:void 0,ee;typeof o=="function"?ee=o(Q):ee=[o,H?"active":null,K?"pending":null,M?"transitioning":null].filter(Boolean).join(" ");let oe=typeof a=="function"?a(Q):a;return N.createElement(Br,WD({},_,{"aria-current":J,className:ee,ref:r,style:oe,to:f,viewTransition:m}),typeof y=="function"?y(Q):y)});var W8;(function(t){t.UseScrollRestoration="useScrollRestoration",t.UseSubmit="useSubmit",t.UseSubmitFetcher="useSubmitFetcher",t.UseFetcher="useFetcher",t.useViewTransitionState="useViewTransitionState"})(W8||(W8={}));var Mne;(function(t){t.UseFetcher="useFetcher",t.UseFetchers="useFetchers",t.UseScrollRestoration="useScrollRestoration"})(Mne||(Mne={}));function S6e(t){let e=N.useContext(T4);return e||go(!1),e}function T6e(t,e){let{target:r,replace:n,state:s,preventScrollReset:o,relative:c,viewTransition:a}=e===void 0?{}:e,f=ra(),m=js(),y=j4(t,{relative:c});return N.useCallback(_=>{if(f6e(_,r)){_.preventDefault();let w=n!==void 0?n:qD(m)===qD(y);f(t,{replace:w,state:s,preventScrollReset:o,relative:c,viewTransition:a})}},[m,f,y,n,s,r,t,o,c,a])}function c0(t){let e=N.useRef(H8(t)),r=N.useRef(!1),n=js(),s=N.useMemo(()=>m6e(n.search,r.current?null:e.current),[n.search]),o=ra(),c=N.useCallback((a,f)=>{const m=H8(typeof a=="function"?a(s):a);r.current=!0,o("?"+m,f)},[o,s]);return[s,c]}function E6e(t,e){e===void 0&&(e={});let r=N.useContext(x6e);r==null&&go(!1);let{basename:n}=S6e(W8.useViewTransitionState),s=j4(t,{relative:e.relative});if(!r.isTransitioning)return!1;let o=KS(r.currentLocation.pathname,n)||r.currentLocation.pathname,c=KS(r.nextLocation.pathname,n)||r.nextLocation.pathname;return GD(s.pathname,c)!=null||GD(s.pathname,o)!=null}var j6e=typeof Element<"u",k6e=typeof Map=="function",A6e=typeof Set=="function",N6e=typeof ArrayBuffer=="function"&&!!ArrayBuffer.isView;function IM(t,e){if(t===e)return!0;if(t&&e&&typeof t=="object"&&typeof e=="object"){if(t.constructor!==e.constructor)return!1;var r,n,s;if(Array.isArray(t)){if(r=t.length,r!=e.length)return!1;for(n=r;n--!==0;)if(!IM(t[n],e[n]))return!1;return!0}var o;if(k6e&&t instanceof Map&&e instanceof Map){if(t.size!==e.size)return!1;for(o=t.entries();!(n=o.next()).done;)if(!e.has(n.value[0]))return!1;for(o=t.entries();!(n=o.next()).done;)if(!IM(n.value[1],e.get(n.value[0])))return!1;return!0}if(A6e&&t instanceof Set&&e instanceof Set){if(t.size!==e.size)return!1;for(o=t.entries();!(n=o.next()).done;)if(!e.has(n.value[0]))return!1;return!0}if(N6e&&ArrayBuffer.isView(t)&&ArrayBuffer.isView(e)){if(r=t.length,r!=e.length)return!1;for(n=r;n--!==0;)if(t[n]!==e[n])return!1;return!0}if(t.constructor===RegExp)return t.source===e.source&&t.flags===e.flags;if(t.valueOf!==Object.prototype.valueOf&&typeof t.valueOf=="function"&&typeof e.valueOf=="function")return t.valueOf()===e.valueOf();if(t.toString!==Object.prototype.toString&&typeof t.toString=="function"&&typeof e.toString=="function")return t.toString()===e.toString();if(s=Object.keys(t),r=s.length,r!==Object.keys(e).length)return!1;for(n=r;n--!==0;)if(!Object.prototype.hasOwnProperty.call(e,s[n]))return!1;if(j6e&&t instanceof Element)return!1;for(n=r;n--!==0;)if(!((s[n]==="_owner"||s[n]==="__v"||s[n]==="__o")&&t.$$typeof)&&!IM(t[s[n]],e[s[n]]))return!1;return!0}return t!==t&&e!==e}var C6e=function(e,r){try{return IM(e,r)}catch(n){if((n.message||"").match(/stack|recursion/i))return console.warn("react-fast-compare cannot handle circular refs"),!1;throw n}};const I6e=bi(C6e);var P6e=function(t,e,r,n,s,o,c,a){if(!t){var f;if(e===void 0)f=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var m=[r,n,s,o,c,a],y=0;f=new Error(e.replace(/%s/g,function(){return m[y++]})),f.name="Invariant Violation"}throw f.framesToPop=1,f}},R6e=P6e;const Dne=bi(R6e);var L6e=function(e,r,n,s){var o=n?n.call(s,e,r):void 0;if(o!==void 0)return!!o;if(e===r)return!0;if(typeof e!="object"||!e||typeof r!="object"||!r)return!1;var c=Object.keys(e),a=Object.keys(r);if(c.length!==a.length)return!1;for(var f=Object.prototype.hasOwnProperty.bind(r),m=0;m(t.BASE="base",t.BODY="body",t.HEAD="head",t.HTML="html",t.LINK="link",t.META="meta",t.NOSCRIPT="noscript",t.SCRIPT="script",t.STYLE="style",t.TITLE="title",t.FRAGMENT="Symbol(react.fragment)",t))(p0e||{}),Gz={link:{rel:["amphtml","canonical","alternate"]},script:{type:["application/ld+json"]},meta:{charset:"",name:["generator","robots","description"],property:["og:type","og:title","og:url","og:image","og:image:alt","og:description","twitter:url","twitter:title","twitter:description","twitter:image","twitter:image:alt","twitter:card","twitter:site"]}},One=Object.values(p0e),ZH={accesskey:"accessKey",charset:"charSet",class:"className",contenteditable:"contentEditable",contextmenu:"contextMenu","http-equiv":"httpEquiv",itemprop:"itemProp",tabindex:"tabIndex"},D6e=Object.entries(ZH).reduce((t,[e,r])=>(t[r]=e,t),{}),kf="data-rh",dS={DEFAULT_TITLE:"defaultTitle",DEFER:"defer",ENCODE_SPECIAL_CHARACTERS:"encodeSpecialCharacters",ON_CHANGE_CLIENT_STATE:"onChangeClientState",TITLE_TEMPLATE:"titleTemplate",PRIORITIZE_SEO_TAGS:"prioritizeSeoTags"},hS=(t,e)=>{for(let r=t.length-1;r>=0;r-=1){const n=t[r];if(Object.prototype.hasOwnProperty.call(n,e))return n[e]}return null},O6e=t=>{let e=hS(t,"title");const r=hS(t,dS.TITLE_TEMPLATE);if(Array.isArray(e)&&(e=e.join("")),r&&e)return r.replace(/%s/g,()=>e);const n=hS(t,dS.DEFAULT_TITLE);return e||n||void 0},F6e=t=>hS(t,dS.ON_CHANGE_CLIENT_STATE)||(()=>{}),Hz=(t,e)=>e.filter(r=>typeof r[t]<"u").map(r=>r[t]).reduce((r,n)=>({...r,...n}),{}),B6e=(t,e)=>e.filter(r=>typeof r.base<"u").map(r=>r.base).reverse().reduce((r,n)=>{if(!r.length){const s=Object.keys(n);for(let o=0;oconsole&&typeof console.warn=="function"&&console.warn(t),Z2=(t,e,r)=>{const n={};return r.filter(s=>Array.isArray(s[t])?!0:(typeof s[t]<"u"&&$6e(`Helmet: ${t} should be of type "Array". Instead found type "${typeof s[t]}"`),!1)).map(s=>s[t]).reverse().reduce((s,o)=>{const c={};o.filter(f=>{let m;const y=Object.keys(f);for(let w=0;ws.push(f));const a=Object.keys(c);for(let f=0;f{if(Array.isArray(t)&&t.length){for(let r=0;r({baseTag:B6e(["href"],t),bodyAttributes:Hz("bodyAttributes",t),defer:hS(t,dS.DEFER),encode:hS(t,dS.ENCODE_SPECIAL_CHARACTERS),htmlAttributes:Hz("htmlAttributes",t),linkTags:Z2("link",["rel","href"],t),metaTags:Z2("meta",["name","charset","http-equiv","property","itemprop"],t),noscriptTags:Z2("noscript",["innerHTML"],t),onChangeClientState:F6e(t),scriptTags:Z2("script",["src","innerHTML"],t),styleTags:Z2("style",["cssText"],t),title:O6e(t),titleAttributes:Hz("titleAttributes",t),prioritizeSeoTags:z6e(t,dS.PRIORITIZE_SEO_TAGS)}),g0e=t=>Array.isArray(t)?t.join(""):t,V6e=(t,e)=>{const r=Object.keys(t);for(let n=0;nArray.isArray(t)?t.reduce((r,n)=>(V6e(n,e)?r.priority.push(n):r.default.push(n),r),{priority:[],default:[]}):{default:t,priority:[]},Fne=(t,e)=>({...t,[e]:void 0}),q6e=["noscript","script","style"],K8=(t,e=!0)=>e===!1?String(t):String(t).replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'"),y0e=t=>Object.keys(t).reduce((e,r)=>{const n=typeof t[r]<"u"?`${r}="${t[r]}"`:`${r}`;return e?`${e} ${n}`:n},""),G6e=(t,e,r,n)=>{const s=y0e(r),o=g0e(e);return s?`<${t} ${kf}="true" ${s}>${K8(o,n)}`:`<${t} ${kf}="true">${K8(o,n)}`},H6e=(t,e,r=!0)=>e.reduce((n,s)=>{const o=s,c=Object.keys(o).filter(m=>!(m==="innerHTML"||m==="cssText")).reduce((m,y)=>{const _=typeof o[y]>"u"?y:`${y}="${K8(o[y],r)}"`;return m?`${m} ${_}`:_},""),a=o.innerHTML||o.cssText||"",f=q6e.indexOf(t)===-1;return`${n}<${t} ${kf}="true" ${c}${f?"/>":`>${a}`}`},""),x0e=(t,e={})=>Object.keys(t).reduce((r,n)=>{const s=ZH[n];return r[s||n]=t[n],r},e),W6e=(t,e,r)=>{const n={key:e,[kf]:!0},s=x0e(r,n);return[Qe.createElement("title",s,e)]},PM=(t,e)=>e.map((r,n)=>{const s={key:n,[kf]:!0};return Object.keys(r).forEach(o=>{const a=ZH[o]||o;if(a==="innerHTML"||a==="cssText"){const f=r.innerHTML||r.cssText;s.dangerouslySetInnerHTML={__html:f}}else s[a]=r[o]}),Qe.createElement(t,s)}),hh=(t,e,r=!0)=>{switch(t){case"title":return{toComponent:()=>W6e(t,e.title,e.titleAttributes),toString:()=>G6e(t,e.title,e.titleAttributes,r)};case"bodyAttributes":case"htmlAttributes":return{toComponent:()=>x0e(e),toString:()=>y0e(e)};default:return{toComponent:()=>PM(t,e),toString:()=>H6e(t,e,r)}}},K6e=({metaTags:t,linkTags:e,scriptTags:r,encode:n})=>{const s=Wz(t,Gz.meta),o=Wz(e,Gz.link),c=Wz(r,Gz.script);return{priorityMethods:{toComponent:()=>[...PM("meta",s.priority),...PM("link",o.priority),...PM("script",c.priority)],toString:()=>`${hh("meta",s.priority,n)} ${hh("link",o.priority,n)} ${hh("script",c.priority,n)}`},metaTags:s.default,linkTags:o.default,scriptTags:c.default}},Y6e=t=>{const{baseTag:e,bodyAttributes:r,encode:n=!0,htmlAttributes:s,noscriptTags:o,styleTags:c,title:a="",titleAttributes:f,prioritizeSeoTags:m}=t;let{linkTags:y,metaTags:_,scriptTags:w}=t,E={toComponent:()=>{},toString:()=>""};return m&&({priorityMethods:E,linkTags:y,metaTags:_,scriptTags:w}=K6e(t)),{priority:E,base:hh("base",e,n),bodyAttributes:hh("bodyAttributes",r,n),htmlAttributes:hh("htmlAttributes",s,n),link:hh("link",y,n),meta:hh("meta",_,n),noscript:hh("noscript",o,n),script:hh("script",w,n),style:hh("style",c,n),title:hh("title",{title:a,titleAttributes:f},n)}},Y8=Y6e,iL=[],_0e=!!(typeof window<"u"&&window.document&&window.document.createElement),Z8=class{constructor(t,e){Vr(this,"instances",[]);Vr(this,"canUseDOM",_0e);Vr(this,"context");Vr(this,"value",{setHelmet:t=>{this.context.helmet=t},helmetInstances:{get:()=>this.canUseDOM?iL:this.instances,add:t=>{(this.canUseDOM?iL:this.instances).push(t)},remove:t=>{const e=(this.canUseDOM?iL:this.instances).indexOf(t);(this.canUseDOM?iL:this.instances).splice(e,1)}}});this.context=t,this.canUseDOM=e||!1,e||(t.helmet=Y8({baseTag:[],bodyAttributes:{},encodeSpecialCharacters:!0,htmlAttributes:{},linkTags:[],metaTags:[],noscriptTags:[],scriptTags:[],styleTags:[],title:"",titleAttributes:{}}))}},Z6e={},v0e=Qe.createContext(Z6e),vv,b0e=(vv=class extends N.Component{constructor(r){super(r);Vr(this,"helmetData");this.helmetData=new Z8(this.props.context||{},vv.canUseDOM)}render(){return Qe.createElement(v0e.Provider,{value:this.helmetData.value},this.props.children)}},Vr(vv,"canUseDOM",_0e),vv),Zw=(t,e)=>{const r=document.head||document.querySelector("head"),n=r.querySelectorAll(`${t}[${kf}]`),s=[].slice.call(n),o=[];let c;return e&&e.length&&e.forEach(a=>{const f=document.createElement(t);for(const m in a)if(Object.prototype.hasOwnProperty.call(a,m))if(m==="innerHTML")f.innerHTML=a.innerHTML;else if(m==="cssText")f.styleSheet?f.styleSheet.cssText=a.cssText:f.appendChild(document.createTextNode(a.cssText));else{const y=m,_=typeof a[y]>"u"?"":a[y];f.setAttribute(m,_)}f.setAttribute(kf,"true"),s.some((m,y)=>(c=y,f.isEqualNode(m)))?s.splice(c,1):o.push(f)}),s.forEach(a=>{var f;return(f=a.parentNode)==null?void 0:f.removeChild(a)}),o.forEach(a=>r.appendChild(a)),{oldTags:s,newTags:o}},X8=(t,e)=>{const r=document.getElementsByTagName(t)[0];if(!r)return;const n=r.getAttribute(kf),s=n?n.split(","):[],o=[...s],c=Object.keys(e);for(const a of c){const f=e[a]||"";r.getAttribute(a)!==f&&r.setAttribute(a,f),s.indexOf(a)===-1&&s.push(a);const m=o.indexOf(a);m!==-1&&o.splice(m,1)}for(let a=o.length-1;a>=0;a-=1)r.removeAttribute(o[a]);s.length===o.length?r.removeAttribute(kf):r.getAttribute(kf)!==c.join(",")&&r.setAttribute(kf,c.join(","))},X6e=(t,e)=>{typeof t<"u"&&document.title!==t&&(document.title=g0e(t)),X8("title",e)},Bne=(t,e)=>{const{baseTag:r,bodyAttributes:n,htmlAttributes:s,linkTags:o,metaTags:c,noscriptTags:a,onChangeClientState:f,scriptTags:m,styleTags:y,title:_,titleAttributes:w}=t;X8("body",n),X8("html",s),X6e(_,w);const E={baseTag:Zw("base",r),linkTags:Zw("link",o),metaTags:Zw("meta",c),noscriptTags:Zw("noscript",a),scriptTags:Zw("script",m),styleTags:Zw("style",y)},A={},C={};Object.keys(E).forEach(I=>{const{newTags:M,oldTags:D}=E[I];M.length&&(A[I]=M),D.length&&(C[I]=E[I].oldTags)}),e&&e(),f(t,A,C)},X2=null,Q6e=t=>{X2&&cancelAnimationFrame(X2),t.defer?X2=requestAnimationFrame(()=>{Bne(t,()=>{X2=null})}):(Bne(t),X2=null)},J6e=Q6e,$ne=class extends N.Component{constructor(){super(...arguments);Vr(this,"rendered",!1)}shouldComponentUpdate(e){return!M6e(e,this.props)}componentDidUpdate(){this.emitChange()}componentWillUnmount(){const{helmetInstances:e}=this.props.context;e.remove(this),this.emitChange()}emitChange(){const{helmetInstances:e,setHelmet:r}=this.props.context;let n=null;const s=U6e(e.get().map(o=>{const c={...o.props};return delete c.context,c}));b0e.canUseDOM?J6e(s):Y8&&(n=Y8(s)),r(n)}init(){if(this.rendered)return;this.rendered=!0;const{helmetInstances:e}=this.props.context;e.add(this),this.emitChange()}render(){return this.init(),null}},mV,_o=(mV=class extends N.Component{shouldComponentUpdate(t){return!I6e(Fne(this.props,"helmetData"),Fne(t,"helmetData"))}mapNestedChildrenToProps(t,e){if(!e)return null;switch(t.type){case"script":case"noscript":return{innerHTML:e};case"style":return{cssText:e};default:throw new Error(`<${t.type} /> elements are self-closing and can not contain children. Refer to our API for more information.`)}}flattenArrayTypeChildren(t,e,r,n){return{...e,[t.type]:[...e[t.type]||[],{...r,...this.mapNestedChildrenToProps(t,n)}]}}mapObjectTypeChildren(t,e,r,n){switch(t.type){case"title":return{...e,[t.type]:n,titleAttributes:{...r}};case"body":return{...e,bodyAttributes:{...r}};case"html":return{...e,htmlAttributes:{...r}};default:return{...e,[t.type]:{...r}}}}mapArrayTypeChildrenToProps(t,e){let r={...e};return Object.keys(t).forEach(n=>{r={...r,[n]:t[n]}}),r}warnOnInvalidChildren(t,e){return Dne(One.some(r=>t.type===r),typeof t.type=="function"?"You may be attempting to nest components within each other, which is not allowed. Refer to our API for more information.":`Only elements types ${One.join(", ")} are allowed. Helmet does not support rendering <${t.type}> elements. Refer to our API for more information.`),Dne(!e||typeof e=="string"||Array.isArray(e)&&!e.some(r=>typeof r!="string"),`Helmet expects a string as a child of <${t.type}>. Did you forget to wrap your children in braces? ( <${t.type}>{\`\`} ) Refer to our API for more information.`),!0}mapChildrenToProps(t,e){let r={};return Qe.Children.forEach(t,n=>{if(!n||!n.props)return;const{children:s,...o}=n.props,c=Object.keys(o).reduce((f,m)=>(f[D6e[m]||m]=o[m],f),{});let{type:a}=n;switch(typeof a=="symbol"?a=a.toString():this.warnOnInvalidChildren(n,s),a){case"Symbol(react.fragment)":e=this.mapChildrenToProps(s,e);break;case"link":case"meta":case"noscript":case"script":case"style":r=this.flattenArrayTypeChildren(n,r,c,s);break;default:e=this.mapObjectTypeChildren(n,e,c,s);break}}),this.mapArrayTypeChildrenToProps(r,e)}render(){const{children:t,...e}=this.props;let r={...e},{helmetData:n}=e;if(t&&(r=this.mapChildrenToProps(t,r)),n&&!(n instanceof Z8)){const s=n;n=new Z8(s.context,!0),delete r.helmetData}return n?Qe.createElement($ne,{...r,context:n.value}):Qe.createElement(v0e.Consumer,null,s=>Qe.createElement($ne,{...r,context:s}))}},Vr(mV,"defaultProps",{defer:!0,encodeSpecialCharacters:!0,prioritizeSeoTags:!1}),mV);const eUe=t=>{let e;return t?e=t:typeof fetch>"u"?e=(...r)=>Oe(async()=>{const{default:n}=await Promise.resolve().then(()=>QT);return{default:n}},void 0).then(({default:n})=>n(...r)):e=fetch,(...r)=>e(...r)};class XH extends Error{constructor(e,r="FunctionsError",n){super(e),this.name=r,this.context=n}}class tUe extends XH{constructor(e){super("Failed to send a request to the Edge Function","FunctionsFetchError",e)}}class rUe extends XH{constructor(e){super("Relay Error invoking the Edge Function","FunctionsRelayError",e)}}class nUe extends XH{constructor(e){super("Edge Function returned a non-2xx status code","FunctionsHttpError",e)}}var Q8;(function(t){t.Any="any",t.ApNortheast1="ap-northeast-1",t.ApNortheast2="ap-northeast-2",t.ApSouth1="ap-south-1",t.ApSoutheast1="ap-southeast-1",t.ApSoutheast2="ap-southeast-2",t.CaCentral1="ca-central-1",t.EuCentral1="eu-central-1",t.EuWest1="eu-west-1",t.EuWest2="eu-west-2",t.EuWest3="eu-west-3",t.SaEast1="sa-east-1",t.UsEast1="us-east-1",t.UsWest1="us-west-1",t.UsWest2="us-west-2"})(Q8||(Q8={}));var sUe=function(t,e,r,n){function s(o){return o instanceof r?o:new r(function(c){c(o)})}return new(r||(r=Promise))(function(o,c){function a(y){try{m(n.next(y))}catch(_){c(_)}}function f(y){try{m(n.throw(y))}catch(_){c(_)}}function m(y){y.done?o(y.value):s(y.value).then(a,f)}m((n=n.apply(t,e||[])).next())})};class iUe{constructor(e,{headers:r={},customFetch:n,region:s=Q8.Any}={}){this.url=e,this.headers=r,this.region=s,this.fetch=eUe(n)}setAuth(e){this.headers.Authorization=`Bearer ${e}`}invoke(e,r={}){var n;return sUe(this,void 0,void 0,function*(){try{const{headers:s,method:o,body:c}=r;let a={},{region:f}=r;f||(f=this.region),f&&f!=="any"&&(a["x-region"]=f);let m;c&&(s&&!Object.prototype.hasOwnProperty.call(s,"Content-Type")||!s)&&(typeof Blob<"u"&&c instanceof Blob||c instanceof ArrayBuffer?(a["Content-Type"]="application/octet-stream",m=c):typeof c=="string"?(a["Content-Type"]="text/plain",m=c):typeof FormData<"u"&&c instanceof FormData?m=c:(a["Content-Type"]="application/json",m=JSON.stringify(c)));const y=yield this.fetch(`${this.url}/${e}`,{method:o||"POST",headers:Object.assign(Object.assign(Object.assign({},a),this.headers),s),body:m}).catch(A=>{throw new tUe(A)}),_=y.headers.get("x-relay-error");if(_&&_==="true")throw new rUe(y);if(!y.ok)throw new nUe(y);let w=((n=y.headers.get("Content-Type"))!==null&&n!==void 0?n:"text/plain").split(";")[0].trim(),E;return w==="application/json"?E=yield y.json():w==="application/octet-stream"?E=yield y.blob():w==="text/event-stream"?E=y:w==="multipart/form-data"?E=yield y.formData():E=yield y.text(),{data:E,error:null}}catch(s){return{data:null,error:s}}})}}var Gu={},QH={},k4={},NC={},A4={},N4={},aUe=function(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global;throw new Error("unable to locate global object")},YS=aUe();const oUe=YS.fetch,w0e=YS.fetch.bind(YS),S0e=YS.Headers,lUe=YS.Request,cUe=YS.Response,QT=Object.freeze(Object.defineProperty({__proto__:null,Headers:S0e,Request:lUe,Response:cUe,default:w0e,fetch:oUe},Symbol.toStringTag,{value:"Module"})),uUe=TMe(QT);var C4={};Object.defineProperty(C4,"__esModule",{value:!0});let dUe=class extends Error{constructor(e){super(e.message),this.name="PostgrestError",this.details=e.details,this.hint=e.hint,this.code=e.code}};C4.default=dUe;var T0e=uc&&uc.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(N4,"__esModule",{value:!0});const hUe=T0e(uUe),fUe=T0e(C4);let mUe=class{constructor(e){this.shouldThrowOnError=!1,this.method=e.method,this.url=e.url,this.headers=e.headers,this.schema=e.schema,this.body=e.body,this.shouldThrowOnError=e.shouldThrowOnError,this.signal=e.signal,this.isMaybeSingle=e.isMaybeSingle,e.fetch?this.fetch=e.fetch:typeof fetch>"u"?this.fetch=hUe.default:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(e,r){return this.headers=Object.assign({},this.headers),this.headers[e]=r,this}then(e,r){this.schema===void 0||(["GET","HEAD"].includes(this.method)?this.headers["Accept-Profile"]=this.schema:this.headers["Content-Profile"]=this.schema),this.method!=="GET"&&this.method!=="HEAD"&&(this.headers["Content-Type"]="application/json");const n=this.fetch;let s=n(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async o=>{var c,a,f;let m=null,y=null,_=null,w=o.status,E=o.statusText;if(o.ok){if(this.method!=="HEAD"){const M=await o.text();M===""||(this.headers.Accept==="text/csv"||this.headers.Accept&&this.headers.Accept.includes("application/vnd.pgrst.plan+text")?y=M:y=JSON.parse(M))}const C=(c=this.headers.Prefer)===null||c===void 0?void 0:c.match(/count=(exact|planned|estimated)/),I=(a=o.headers.get("content-range"))===null||a===void 0?void 0:a.split("/");C&&I&&I.length>1&&(_=parseInt(I[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(y)&&(y.length>1?(m={code:"PGRST116",details:`Results contain ${y.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},y=null,_=null,w=406,E="Not Acceptable"):y.length===1?y=y[0]:y=null)}else{const C=await o.text();try{m=JSON.parse(C),Array.isArray(m)&&o.status===404&&(y=[],m=null,w=200,E="OK")}catch{o.status===404&&C===""?(w=204,E="No Content"):m={message:C}}if(m&&this.isMaybeSingle&&(!((f=m==null?void 0:m.details)===null||f===void 0)&&f.includes("0 rows"))&&(m=null,w=200,E="OK"),m&&this.shouldThrowOnError)throw new fUe.default(m)}return{error:m,data:y,count:_,status:w,statusText:E}});return this.shouldThrowOnError||(s=s.catch(o=>{var c,a,f;return{error:{message:`${(c=o==null?void 0:o.name)!==null&&c!==void 0?c:"FetchError"}: ${o==null?void 0:o.message}`,details:`${(a=o==null?void 0:o.stack)!==null&&a!==void 0?a:""}`,hint:"",code:`${(f=o==null?void 0:o.code)!==null&&f!==void 0?f:""}`},data:null,count:null,status:0,statusText:""}})),s.then(e,r)}returns(){return this}overrideTypes(){return this}};N4.default=mUe;var pUe=uc&&uc.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(A4,"__esModule",{value:!0});const gUe=pUe(N4);let yUe=class extends gUe.default{select(e){let r=!1;const n=(e??"*").split("").map(s=>/\s/.test(s)&&!r?"":(s==='"'&&(r=!r),s)).join("");return this.url.searchParams.set("select",n),this.headers.Prefer&&(this.headers.Prefer+=","),this.headers.Prefer+="return=representation",this}order(e,{ascending:r=!0,nullsFirst:n,foreignTable:s,referencedTable:o=s}={}){const c=o?`${o}.order`:"order",a=this.url.searchParams.get(c);return this.url.searchParams.set(c,`${a?`${a},`:""}${e}.${r?"asc":"desc"}${n===void 0?"":n?".nullsfirst":".nullslast"}`),this}limit(e,{foreignTable:r,referencedTable:n=r}={}){const s=typeof n>"u"?"limit":`${n}.limit`;return this.url.searchParams.set(s,`${e}`),this}range(e,r,{foreignTable:n,referencedTable:s=n}={}){const o=typeof s>"u"?"offset":`${s}.offset`,c=typeof s>"u"?"limit":`${s}.limit`;return this.url.searchParams.set(o,`${e}`),this.url.searchParams.set(c,`${r-e+1}`),this}abortSignal(e){return this.signal=e,this}single(){return this.headers.Accept="application/vnd.pgrst.object+json",this}maybeSingle(){return this.method==="GET"?this.headers.Accept="application/json":this.headers.Accept="application/vnd.pgrst.object+json",this.isMaybeSingle=!0,this}csv(){return this.headers.Accept="text/csv",this}geojson(){return this.headers.Accept="application/geo+json",this}explain({analyze:e=!1,verbose:r=!1,settings:n=!1,buffers:s=!1,wal:o=!1,format:c="text"}={}){var a;const f=[e?"analyze":null,r?"verbose":null,n?"settings":null,s?"buffers":null,o?"wal":null].filter(Boolean).join("|"),m=(a=this.headers.Accept)!==null&&a!==void 0?a:"application/json";return this.headers.Accept=`application/vnd.pgrst.plan+${c}; for="${m}"; options=${f};`,c==="json"?this:this}rollback(){var e;return((e=this.headers.Prefer)!==null&&e!==void 0?e:"").trim().length>0?this.headers.Prefer+=",tx=rollback":this.headers.Prefer="tx=rollback",this}returns(){return this}};A4.default=yUe;var xUe=uc&&uc.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(NC,"__esModule",{value:!0});const _Ue=xUe(A4);let vUe=class extends _Ue.default{eq(e,r){return this.url.searchParams.append(e,`eq.${r}`),this}neq(e,r){return this.url.searchParams.append(e,`neq.${r}`),this}gt(e,r){return this.url.searchParams.append(e,`gt.${r}`),this}gte(e,r){return this.url.searchParams.append(e,`gte.${r}`),this}lt(e,r){return this.url.searchParams.append(e,`lt.${r}`),this}lte(e,r){return this.url.searchParams.append(e,`lte.${r}`),this}like(e,r){return this.url.searchParams.append(e,`like.${r}`),this}likeAllOf(e,r){return this.url.searchParams.append(e,`like(all).{${r.join(",")}}`),this}likeAnyOf(e,r){return this.url.searchParams.append(e,`like(any).{${r.join(",")}}`),this}ilike(e,r){return this.url.searchParams.append(e,`ilike.${r}`),this}ilikeAllOf(e,r){return this.url.searchParams.append(e,`ilike(all).{${r.join(",")}}`),this}ilikeAnyOf(e,r){return this.url.searchParams.append(e,`ilike(any).{${r.join(",")}}`),this}is(e,r){return this.url.searchParams.append(e,`is.${r}`),this}in(e,r){const n=Array.from(new Set(r)).map(s=>typeof s=="string"&&new RegExp("[,()]").test(s)?`"${s}"`:`${s}`).join(",");return this.url.searchParams.append(e,`in.(${n})`),this}contains(e,r){return typeof r=="string"?this.url.searchParams.append(e,`cs.${r}`):Array.isArray(r)?this.url.searchParams.append(e,`cs.{${r.join(",")}}`):this.url.searchParams.append(e,`cs.${JSON.stringify(r)}`),this}containedBy(e,r){return typeof r=="string"?this.url.searchParams.append(e,`cd.${r}`):Array.isArray(r)?this.url.searchParams.append(e,`cd.{${r.join(",")}}`):this.url.searchParams.append(e,`cd.${JSON.stringify(r)}`),this}rangeGt(e,r){return this.url.searchParams.append(e,`sr.${r}`),this}rangeGte(e,r){return this.url.searchParams.append(e,`nxl.${r}`),this}rangeLt(e,r){return this.url.searchParams.append(e,`sl.${r}`),this}rangeLte(e,r){return this.url.searchParams.append(e,`nxr.${r}`),this}rangeAdjacent(e,r){return this.url.searchParams.append(e,`adj.${r}`),this}overlaps(e,r){return typeof r=="string"?this.url.searchParams.append(e,`ov.${r}`):this.url.searchParams.append(e,`ov.{${r.join(",")}}`),this}textSearch(e,r,{config:n,type:s}={}){let o="";s==="plain"?o="pl":s==="phrase"?o="ph":s==="websearch"&&(o="w");const c=n===void 0?"":`(${n})`;return this.url.searchParams.append(e,`${o}fts${c}.${r}`),this}match(e){return Object.entries(e).forEach(([r,n])=>{this.url.searchParams.append(r,`eq.${n}`)}),this}not(e,r,n){return this.url.searchParams.append(e,`not.${r}.${n}`),this}or(e,{foreignTable:r,referencedTable:n=r}={}){const s=n?`${n}.or`:"or";return this.url.searchParams.append(s,`(${e})`),this}filter(e,r,n){return this.url.searchParams.append(e,`${r}.${n}`),this}};NC.default=vUe;var bUe=uc&&uc.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(k4,"__esModule",{value:!0});const Q2=bUe(NC);let wUe=class{constructor(e,{headers:r={},schema:n,fetch:s}){this.url=e,this.headers=r,this.schema=n,this.fetch=s}select(e,{head:r=!1,count:n}={}){const s=r?"HEAD":"GET";let o=!1;const c=(e??"*").split("").map(a=>/\s/.test(a)&&!o?"":(a==='"'&&(o=!o),a)).join("");return this.url.searchParams.set("select",c),n&&(this.headers.Prefer=`count=${n}`),new Q2.default({method:s,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch,allowEmpty:!1})}insert(e,{count:r,defaultToNull:n=!0}={}){const s="POST",o=[];if(this.headers.Prefer&&o.push(this.headers.Prefer),r&&o.push(`count=${r}`),n||o.push("missing=default"),this.headers.Prefer=o.join(","),Array.isArray(e)){const c=e.reduce((a,f)=>a.concat(Object.keys(f)),[]);if(c.length>0){const a=[...new Set(c)].map(f=>`"${f}"`);this.url.searchParams.set("columns",a.join(","))}}return new Q2.default({method:s,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:this.fetch,allowEmpty:!1})}upsert(e,{onConflict:r,ignoreDuplicates:n=!1,count:s,defaultToNull:o=!0}={}){const c="POST",a=[`resolution=${n?"ignore":"merge"}-duplicates`];if(r!==void 0&&this.url.searchParams.set("on_conflict",r),this.headers.Prefer&&a.push(this.headers.Prefer),s&&a.push(`count=${s}`),o||a.push("missing=default"),this.headers.Prefer=a.join(","),Array.isArray(e)){const f=e.reduce((m,y)=>m.concat(Object.keys(y)),[]);if(f.length>0){const m=[...new Set(f)].map(y=>`"${y}"`);this.url.searchParams.set("columns",m.join(","))}}return new Q2.default({method:c,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:this.fetch,allowEmpty:!1})}update(e,{count:r}={}){const n="PATCH",s=[];return this.headers.Prefer&&s.push(this.headers.Prefer),r&&s.push(`count=${r}`),this.headers.Prefer=s.join(","),new Q2.default({method:n,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:this.fetch,allowEmpty:!1})}delete({count:e}={}){const r="DELETE",n=[];return e&&n.push(`count=${e}`),this.headers.Prefer&&n.unshift(this.headers.Prefer),this.headers.Prefer=n.join(","),new Q2.default({method:r,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch,allowEmpty:!1})}};k4.default=wUe;var I4={},P4={};Object.defineProperty(P4,"__esModule",{value:!0});P4.version=void 0;P4.version="0.0.0-automated";Object.defineProperty(I4,"__esModule",{value:!0});I4.DEFAULT_HEADERS=void 0;const SUe=P4;I4.DEFAULT_HEADERS={"X-Client-Info":`postgrest-js/${SUe.version}`};var E0e=uc&&uc.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(QH,"__esModule",{value:!0});const TUe=E0e(k4),EUe=E0e(NC),jUe=I4;let kUe=class j0e{constructor(e,{headers:r={},schema:n,fetch:s}={}){this.url=e,this.headers=Object.assign(Object.assign({},jUe.DEFAULT_HEADERS),r),this.schemaName=n,this.fetch=s}from(e){const r=new URL(`${this.url}/${e}`);return new TUe.default(r,{headers:Object.assign({},this.headers),schema:this.schemaName,fetch:this.fetch})}schema(e){return new j0e(this.url,{headers:this.headers,schema:e,fetch:this.fetch})}rpc(e,r={},{head:n=!1,get:s=!1,count:o}={}){let c;const a=new URL(`${this.url}/rpc/${e}`);let f;n||s?(c=n?"HEAD":"GET",Object.entries(r).filter(([y,_])=>_!==void 0).map(([y,_])=>[y,Array.isArray(_)?`{${_.join(",")}}`:`${_}`]).forEach(([y,_])=>{a.searchParams.append(y,_)})):(c="POST",f=r);const m=Object.assign({},this.headers);return o&&(m.Prefer=`count=${o}`),new EUe.default({method:c,url:a,headers:m,schema:this.schemaName,body:f,fetch:this.fetch,allowEmpty:!1})}};QH.default=kUe;var JT=uc&&uc.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Gu,"__esModule",{value:!0});Gu.PostgrestError=Gu.PostgrestBuilder=Gu.PostgrestTransformBuilder=Gu.PostgrestFilterBuilder=Gu.PostgrestQueryBuilder=Gu.PostgrestClient=void 0;const k0e=JT(QH);Gu.PostgrestClient=k0e.default;const A0e=JT(k4);Gu.PostgrestQueryBuilder=A0e.default;const N0e=JT(NC);Gu.PostgrestFilterBuilder=N0e.default;const C0e=JT(A4);Gu.PostgrestTransformBuilder=C0e.default;const I0e=JT(N4);Gu.PostgrestBuilder=I0e.default;const P0e=JT(C4);Gu.PostgrestError=P0e.default;var AUe=Gu.default={PostgrestClient:k0e.default,PostgrestQueryBuilder:A0e.default,PostgrestFilterBuilder:N0e.default,PostgrestTransformBuilder:C0e.default,PostgrestBuilder:I0e.default,PostgrestError:P0e.default};const{PostgrestClient:NUe,PostgrestQueryBuilder:kQt,PostgrestFilterBuilder:AQt,PostgrestTransformBuilder:NQt,PostgrestBuilder:CQt,PostgrestError:IQt}=AUe;let J8;typeof window>"u"?J8=require("ws"):J8=window.WebSocket;const CUe=J8,IUe="2.11.10",PUe={"X-Client-Info":`realtime-js/${IUe}`},RUe="1.0.0",R0e=1e4,LUe=1e3;var fS;(function(t){t[t.connecting=0]="connecting",t[t.open=1]="open",t[t.closing=2]="closing",t[t.closed=3]="closed"})(fS||(fS={}));var au;(function(t){t.closed="closed",t.errored="errored",t.joined="joined",t.joining="joining",t.leaving="leaving"})(au||(au={}));var gf;(function(t){t.close="phx_close",t.error="phx_error",t.join="phx_join",t.reply="phx_reply",t.leave="phx_leave",t.access_token="access_token"})(gf||(gf={}));var eq;(function(t){t.websocket="websocket"})(eq||(eq={}));var Q_;(function(t){t.Connecting="connecting",t.Open="open",t.Closing="closing",t.Closed="closed"})(Q_||(Q_={}));class MUe{constructor(){this.HEADER_LENGTH=1}decode(e,r){return e.constructor===ArrayBuffer?r(this._binaryDecode(e)):r(typeof e=="string"?JSON.parse(e):{})}_binaryDecode(e){const r=new DataView(e),n=new TextDecoder;return this._decodeBroadcast(e,r,n)}_decodeBroadcast(e,r,n){const s=r.getUint8(1),o=r.getUint8(2);let c=this.HEADER_LENGTH+2;const a=n.decode(e.slice(c,c+s));c=c+s;const f=n.decode(e.slice(c,c+o));c=c+o;const m=JSON.parse(n.decode(e.slice(c,e.byteLength)));return{ref:null,topic:a,event:f,payload:m}}}class L0e{constructor(e,r){this.callback=e,this.timerCalc=r,this.timer=void 0,this.tries=0,this.callback=e,this.timerCalc=r}reset(){this.tries=0,clearTimeout(this.timer)}scheduleTimeout(){clearTimeout(this.timer),this.timer=setTimeout(()=>{this.tries=this.tries+1,this.callback()},this.timerCalc(this.tries+1))}}var Ea;(function(t){t.abstime="abstime",t.bool="bool",t.date="date",t.daterange="daterange",t.float4="float4",t.float8="float8",t.int2="int2",t.int4="int4",t.int4range="int4range",t.int8="int8",t.int8range="int8range",t.json="json",t.jsonb="jsonb",t.money="money",t.numeric="numeric",t.oid="oid",t.reltime="reltime",t.text="text",t.time="time",t.timestamp="timestamp",t.timestamptz="timestamptz",t.timetz="timetz",t.tsrange="tsrange",t.tstzrange="tstzrange"})(Ea||(Ea={}));const zne=(t,e,r={})=>{var n;const s=(n=r.skipTypes)!==null&&n!==void 0?n:[];return Object.keys(e).reduce((o,c)=>(o[c]=DUe(c,t,e,s),o),{})},DUe=(t,e,r,n)=>{const s=e.find(a=>a.name===t),o=s==null?void 0:s.type,c=r[t];return o&&!n.includes(o)?M0e(o,c):tq(c)},M0e=(t,e)=>{if(t.charAt(0)==="_"){const r=t.slice(1,t.length);return $Ue(e,r)}switch(t){case Ea.bool:return OUe(e);case Ea.float4:case Ea.float8:case Ea.int2:case Ea.int4:case Ea.int8:case Ea.numeric:case Ea.oid:return FUe(e);case Ea.json:case Ea.jsonb:return BUe(e);case Ea.timestamp:return zUe(e);case Ea.abstime:case Ea.date:case Ea.daterange:case Ea.int4range:case Ea.int8range:case Ea.money:case Ea.reltime:case Ea.text:case Ea.time:case Ea.timestamptz:case Ea.timetz:case Ea.tsrange:case Ea.tstzrange:return tq(e);default:return tq(e)}},tq=t=>t,OUe=t=>{switch(t){case"t":return!0;case"f":return!1;default:return t}},FUe=t=>{if(typeof t=="string"){const e=parseFloat(t);if(!Number.isNaN(e))return e}return t},BUe=t=>{if(typeof t=="string")try{return JSON.parse(t)}catch(e){return console.log(`JSON parse error: ${e}`),t}return t},$Ue=(t,e)=>{if(typeof t!="string")return t;const r=t.length-1,n=t[r];if(t[0]==="{"&&n==="}"){let o;const c=t.slice(1,r);try{o=JSON.parse("["+c+"]")}catch{o=c?c.split(","):[]}return o.map(a=>M0e(e,a))}return t},zUe=t=>typeof t=="string"?t.replace(" ","T"):t,D0e=t=>{let e=t;return e=e.replace(/^ws/i,"http"),e=e.replace(/(\/socket\/websocket|\/socket|\/websocket)\/?$/i,""),e.replace(/\/+$/,"")};class Kz{constructor(e,r,n={},s=R0e){this.channel=e,this.event=r,this.payload=n,this.timeout=s,this.sent=!1,this.timeoutTimer=void 0,this.ref="",this.receivedResp=null,this.recHooks=[],this.refEvent=null}resend(e){this.timeout=e,this._cancelRefEvent(),this.ref="",this.refEvent=null,this.receivedResp=null,this.sent=!1,this.send()}send(){this._hasReceived("timeout")||(this.startTimeout(),this.sent=!0,this.channel.socket.push({topic:this.channel.topic,event:this.event,payload:this.payload,ref:this.ref,join_ref:this.channel._joinRef()}))}updatePayload(e){this.payload=Object.assign(Object.assign({},this.payload),e)}receive(e,r){var n;return this._hasReceived(e)&&r((n=this.receivedResp)===null||n===void 0?void 0:n.response),this.recHooks.push({status:e,callback:r}),this}startTimeout(){if(this.timeoutTimer)return;this.ref=this.channel.socket._makeRef(),this.refEvent=this.channel._replyEventName(this.ref);const e=r=>{this._cancelRefEvent(),this._cancelTimeout(),this.receivedResp=r,this._matchReceive(r)};this.channel._on(this.refEvent,{},e),this.timeoutTimer=setTimeout(()=>{this.trigger("timeout",{})},this.timeout)}trigger(e,r){this.refEvent&&this.channel._trigger(this.refEvent,{status:e,response:r})}destroy(){this._cancelRefEvent(),this._cancelTimeout()}_cancelRefEvent(){this.refEvent&&this.channel._off(this.refEvent,{})}_cancelTimeout(){clearTimeout(this.timeoutTimer),this.timeoutTimer=void 0}_matchReceive({status:e,response:r}){this.recHooks.filter(n=>n.status===e).forEach(n=>n.callback(r))}_hasReceived(e){return this.receivedResp&&this.receivedResp.status===e}}var Une;(function(t){t.SYNC="sync",t.JOIN="join",t.LEAVE="leave"})(Une||(Une={}));class rA{constructor(e,r){this.channel=e,this.state={},this.pendingDiffs=[],this.joinRef=null,this.caller={onJoin:()=>{},onLeave:()=>{},onSync:()=>{}};const n=(r==null?void 0:r.events)||{state:"presence_state",diff:"presence_diff"};this.channel._on(n.state,{},s=>{const{onJoin:o,onLeave:c,onSync:a}=this.caller;this.joinRef=this.channel._joinRef(),this.state=rA.syncState(this.state,s,o,c),this.pendingDiffs.forEach(f=>{this.state=rA.syncDiff(this.state,f,o,c)}),this.pendingDiffs=[],a()}),this.channel._on(n.diff,{},s=>{const{onJoin:o,onLeave:c,onSync:a}=this.caller;this.inPendingSyncState()?this.pendingDiffs.push(s):(this.state=rA.syncDiff(this.state,s,o,c),a())}),this.onJoin((s,o,c)=>{this.channel._trigger("presence",{event:"join",key:s,currentPresences:o,newPresences:c})}),this.onLeave((s,o,c)=>{this.channel._trigger("presence",{event:"leave",key:s,currentPresences:o,leftPresences:c})}),this.onSync(()=>{this.channel._trigger("presence",{event:"sync"})})}static syncState(e,r,n,s){const o=this.cloneDeep(e),c=this.transformState(r),a={},f={};return this.map(o,(m,y)=>{c[m]||(f[m]=y)}),this.map(c,(m,y)=>{const _=o[m];if(_){const w=y.map(I=>I.presence_ref),E=_.map(I=>I.presence_ref),A=y.filter(I=>E.indexOf(I.presence_ref)<0),C=_.filter(I=>w.indexOf(I.presence_ref)<0);A.length>0&&(a[m]=A),C.length>0&&(f[m]=C)}else a[m]=y}),this.syncDiff(o,{joins:a,leaves:f},n,s)}static syncDiff(e,r,n,s){const{joins:o,leaves:c}={joins:this.transformState(r.joins),leaves:this.transformState(r.leaves)};return n||(n=()=>{}),s||(s=()=>{}),this.map(o,(a,f)=>{var m;const y=(m=e[a])!==null&&m!==void 0?m:[];if(e[a]=this.cloneDeep(f),y.length>0){const _=e[a].map(E=>E.presence_ref),w=y.filter(E=>_.indexOf(E.presence_ref)<0);e[a].unshift(...w)}n(a,y,f)}),this.map(c,(a,f)=>{let m=e[a];if(!m)return;const y=f.map(_=>_.presence_ref);m=m.filter(_=>y.indexOf(_.presence_ref)<0),e[a]=m,s(a,m,f),m.length===0&&delete e[a]}),e}static map(e,r){return Object.getOwnPropertyNames(e).map(n=>r(n,e[n]))}static transformState(e){return e=this.cloneDeep(e),Object.getOwnPropertyNames(e).reduce((r,n)=>{const s=e[n];return"metas"in s?r[n]=s.metas.map(o=>(o.presence_ref=o.phx_ref,delete o.phx_ref,delete o.phx_ref_prev,o)):r[n]=s,r},{})}static cloneDeep(e){return JSON.parse(JSON.stringify(e))}onJoin(e){this.caller.onJoin=e}onLeave(e){this.caller.onLeave=e}onSync(e){this.caller.onSync=e}inPendingSyncState(){return!this.joinRef||this.joinRef!==this.channel._joinRef()}}var Vne;(function(t){t.ALL="*",t.INSERT="INSERT",t.UPDATE="UPDATE",t.DELETE="DELETE"})(Vne||(Vne={}));var qne;(function(t){t.BROADCAST="broadcast",t.PRESENCE="presence",t.POSTGRES_CHANGES="postgres_changes",t.SYSTEM="system"})(qne||(qne={}));var tg;(function(t){t.SUBSCRIBED="SUBSCRIBED",t.TIMED_OUT="TIMED_OUT",t.CLOSED="CLOSED",t.CHANNEL_ERROR="CHANNEL_ERROR"})(tg||(tg={}));class JH{constructor(e,r={config:{}},n){this.topic=e,this.params=r,this.socket=n,this.bindings={},this.state=au.closed,this.joinedOnce=!1,this.pushBuffer=[],this.subTopic=e.replace(/^realtime:/i,""),this.params.config=Object.assign({broadcast:{ack:!1,self:!1},presence:{key:""},private:!1},r.config),this.timeout=this.socket.timeout,this.joinPush=new Kz(this,gf.join,this.params,this.timeout),this.rejoinTimer=new L0e(()=>this._rejoinUntilConnected(),this.socket.reconnectAfterMs),this.joinPush.receive("ok",()=>{this.state=au.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach(s=>s.send()),this.pushBuffer=[]}),this._onClose(()=>{this.rejoinTimer.reset(),this.socket.log("channel",`close ${this.topic} ${this._joinRef()}`),this.state=au.closed,this.socket._remove(this)}),this._onError(s=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,s),this.state=au.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("timeout",()=>{this._isJoining()&&(this.socket.log("channel",`timeout ${this.topic}`,this.joinPush.timeout),this.state=au.errored,this.rejoinTimer.scheduleTimeout())}),this._on(gf.reply,{},(s,o)=>{this._trigger(this._replyEventName(o),s)}),this.presence=new rA(this),this.broadcastEndpointURL=D0e(this.socket.endPoint)+"/api/broadcast",this.private=this.params.config.private||!1}subscribe(e,r=this.timeout){var n,s;if(this.socket.isConnected()||this.socket.connect(),this.joinedOnce)throw"tried to subscribe multiple times. 'subscribe' can only be called a single time per channel instance";{const{config:{broadcast:o,presence:c,private:a}}=this.params;this._onError(y=>e==null?void 0:e(tg.CHANNEL_ERROR,y)),this._onClose(()=>e==null?void 0:e(tg.CLOSED));const f={},m={broadcast:o,presence:c,postgres_changes:(s=(n=this.bindings.postgres_changes)===null||n===void 0?void 0:n.map(y=>y.filter))!==null&&s!==void 0?s:[],private:a};this.socket.accessTokenValue&&(f.access_token=this.socket.accessTokenValue),this.updateJoinPayload(Object.assign({config:m},f)),this.joinedOnce=!0,this._rejoin(r),this.joinPush.receive("ok",async({postgres_changes:y})=>{var _;if(this.socket.setAuth(),y===void 0){e==null||e(tg.SUBSCRIBED);return}else{const w=this.bindings.postgres_changes,E=(_=w==null?void 0:w.length)!==null&&_!==void 0?_:0,A=[];for(let C=0;C{this.state=au.errored,e==null||e(tg.CHANNEL_ERROR,new Error(JSON.stringify(Object.values(y).join(", ")||"error")))}).receive("timeout",()=>{e==null||e(tg.TIMED_OUT)})}return this}presenceState(){return this.presence.state}async track(e,r={}){return await this.send({type:"presence",event:"track",payload:e},r.timeout||this.timeout)}async untrack(e={}){return await this.send({type:"presence",event:"untrack"},e)}on(e,r,n){return this._on(e,r,n)}async send(e,r={}){var n,s;if(!this._canPush()&&e.type==="broadcast"){const{event:o,payload:c}=e,f={method:"POST",headers:{Authorization:this.socket.accessTokenValue?`Bearer ${this.socket.accessTokenValue}`:"",apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"},body:JSON.stringify({messages:[{topic:this.subTopic,event:o,payload:c,private:this.private}]})};try{const m=await this._fetchWithTimeout(this.broadcastEndpointURL,f,(n=r.timeout)!==null&&n!==void 0?n:this.timeout);return await((s=m.body)===null||s===void 0?void 0:s.cancel()),m.ok?"ok":"error"}catch(m){return m.name==="AbortError"?"timed out":"error"}}else return new Promise(o=>{var c,a,f;const m=this._push(e.type,e,r.timeout||this.timeout);e.type==="broadcast"&&!(!((f=(a=(c=this.params)===null||c===void 0?void 0:c.config)===null||a===void 0?void 0:a.broadcast)===null||f===void 0)&&f.ack)&&o("ok"),m.receive("ok",()=>o("ok")),m.receive("error",()=>o("error")),m.receive("timeout",()=>o("timed out"))})}updateJoinPayload(e){this.joinPush.updatePayload(e)}unsubscribe(e=this.timeout){this.state=au.leaving;const r=()=>{this.socket.log("channel",`leave ${this.topic}`),this._trigger(gf.close,"leave",this._joinRef())};return this.joinPush.destroy(),new Promise(n=>{const s=new Kz(this,gf.leave,{},e);s.receive("ok",()=>{r(),n("ok")}).receive("timeout",()=>{r(),n("timed out")}).receive("error",()=>{n("error")}),s.send(),this._canPush()||s.trigger("ok",{})})}teardown(){this.pushBuffer.forEach(e=>e.destroy()),this.rejoinTimer&&clearTimeout(this.rejoinTimer.timer),this.joinPush.destroy()}async _fetchWithTimeout(e,r,n){const s=new AbortController,o=setTimeout(()=>s.abort(),n),c=await this.socket.fetch(e,Object.assign(Object.assign({},r),{signal:s.signal}));return clearTimeout(o),c}_push(e,r,n=this.timeout){if(!this.joinedOnce)throw`tried to push '${e}' to '${this.topic}' before joining. Use channel.subscribe() before pushing events`;let s=new Kz(this,e,r,n);return this._canPush()?s.send():(s.startTimeout(),this.pushBuffer.push(s)),s}_onMessage(e,r,n){return r}_isMember(e){return this.topic===e}_joinRef(){return this.joinPush.ref}_trigger(e,r,n){var s,o;const c=e.toLocaleLowerCase(),{close:a,error:f,leave:m,join:y}=gf;if(n&&[a,f,m,y].indexOf(c)>=0&&n!==this._joinRef())return;let w=this._onMessage(c,r,n);if(r&&!w)throw"channel onMessage callbacks must return the payload, modified or unmodified";["insert","update","delete"].includes(c)?(s=this.bindings.postgres_changes)===null||s===void 0||s.filter(E=>{var A,C,I;return((A=E.filter)===null||A===void 0?void 0:A.event)==="*"||((I=(C=E.filter)===null||C===void 0?void 0:C.event)===null||I===void 0?void 0:I.toLocaleLowerCase())===c}).map(E=>E.callback(w,n)):(o=this.bindings[c])===null||o===void 0||o.filter(E=>{var A,C,I,M,D,B;if(["broadcast","presence","postgres_changes"].includes(c))if("id"in E){const U=E.id,q=(A=E.filter)===null||A===void 0?void 0:A.event;return U&&((C=r.ids)===null||C===void 0?void 0:C.includes(U))&&(q==="*"||(q==null?void 0:q.toLocaleLowerCase())===((I=r.data)===null||I===void 0?void 0:I.type.toLocaleLowerCase()))}else{const U=(D=(M=E==null?void 0:E.filter)===null||M===void 0?void 0:M.event)===null||D===void 0?void 0:D.toLocaleLowerCase();return U==="*"||U===((B=r==null?void 0:r.event)===null||B===void 0?void 0:B.toLocaleLowerCase())}else return E.type.toLocaleLowerCase()===c}).map(E=>{if(typeof w=="object"&&"ids"in w){const A=w.data,{schema:C,table:I,commit_timestamp:M,type:D,errors:B}=A;w=Object.assign(Object.assign({},{schema:C,table:I,commit_timestamp:M,eventType:D,new:{},old:{},errors:B}),this._getPayloadRecords(A))}E.callback(w,n)})}_isClosed(){return this.state===au.closed}_isJoined(){return this.state===au.joined}_isJoining(){return this.state===au.joining}_isLeaving(){return this.state===au.leaving}_replyEventName(e){return`chan_reply_${e}`}_on(e,r,n){const s=e.toLocaleLowerCase(),o={type:s,filter:r,callback:n};return this.bindings[s]?this.bindings[s].push(o):this.bindings[s]=[o],this}_off(e,r){const n=e.toLocaleLowerCase();return this.bindings[n]=this.bindings[n].filter(s=>{var o;return!(((o=s.type)===null||o===void 0?void 0:o.toLocaleLowerCase())===n&&JH.isEqual(s.filter,r))}),this}static isEqual(e,r){if(Object.keys(e).length!==Object.keys(r).length)return!1;for(const n in e)if(e[n]!==r[n])return!1;return!0}_rejoinUntilConnected(){this.rejoinTimer.scheduleTimeout(),this.socket.isConnected()&&this._rejoin()}_onClose(e){this._on(gf.close,{},e)}_onError(e){this._on(gf.error,{},r=>e(r))}_canPush(){return this.socket.isConnected()&&this._isJoined()}_rejoin(e=this.timeout){this._isLeaving()||(this.socket._leaveOpenTopic(this.topic),this.state=au.joining,this.joinPush.resend(e))}_getPayloadRecords(e){const r={new:{},old:{}};return(e.type==="INSERT"||e.type==="UPDATE")&&(r.new=zne(e.columns,e.record)),(e.type==="UPDATE"||e.type==="DELETE")&&(r.old=zne(e.columns,e.old_record)),r}}const Gne=()=>{},UUe=` addEventListener("message", (e) => { if (e.data.event === "start") { setInterval(() => postMessage({ event: "keepAlive" }), e.data.interval); } });`;class VUe{constructor(e,r){var n;this.accessTokenValue=null,this.apiKey=null,this.channels=new Array,this.endPoint="",this.httpEndpoint="",this.headers=PUe,this.params={},this.timeout=R0e,this.heartbeatIntervalMs=25e3,this.heartbeatTimer=void 0,this.pendingHeartbeatRef=null,this.heartbeatCallback=Gne,this.ref=0,this.logger=Gne,this.conn=null,this.sendBuffer=[],this.serializer=new MUe,this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.accessToken=null,this._resolveFetch=o=>{let c;return o?c=o:typeof fetch>"u"?c=(...a)=>Oe(async()=>{const{default:f}=await Promise.resolve().then(()=>QT);return{default:f}},void 0).then(({default:f})=>f(...a)):c=fetch,(...a)=>c(...a)},this.endPoint=`${e}/${eq.websocket}`,this.httpEndpoint=D0e(e),r!=null&&r.transport?this.transport=r.transport:this.transport=null,r!=null&&r.params&&(this.params=r.params),r!=null&&r.headers&&(this.headers=Object.assign(Object.assign({},this.headers),r.headers)),r!=null&&r.timeout&&(this.timeout=r.timeout),r!=null&&r.logger&&(this.logger=r.logger),(r!=null&&r.logLevel||r!=null&&r.log_level)&&(this.logLevel=r.logLevel||r.log_level,this.params=Object.assign(Object.assign({},this.params),{log_level:this.logLevel})),r!=null&&r.heartbeatIntervalMs&&(this.heartbeatIntervalMs=r.heartbeatIntervalMs);const s=(n=r==null?void 0:r.params)===null||n===void 0?void 0:n.apikey;if(s&&(this.accessTokenValue=s,this.apiKey=s),this.reconnectAfterMs=r!=null&&r.reconnectAfterMs?r.reconnectAfterMs:o=>[1e3,2e3,5e3,1e4][o-1]||1e4,this.encode=r!=null&&r.encode?r.encode:(o,c)=>c(JSON.stringify(o)),this.decode=r!=null&&r.decode?r.decode:this.serializer.decode.bind(this.serializer),this.reconnectTimer=new L0e(async()=>{this.disconnect(),this.connect()},this.reconnectAfterMs),this.fetch=this._resolveFetch(r==null?void 0:r.fetch),r!=null&&r.worker){if(typeof window<"u"&&!window.Worker)throw new Error("Web Worker is not supported");this.worker=(r==null?void 0:r.worker)||!1,this.workerUrl=r==null?void 0:r.workerUrl}this.accessToken=(r==null?void 0:r.accessToken)||null}connect(){if(!this.conn){if(this.transport||(this.transport=CUe),this.transport){typeof window<"u"&&this.transport===window.WebSocket?this.conn=new this.transport(this.endpointURL()):this.conn=new this.transport(this.endpointURL(),void 0,{headers:this.headers}),this.setupConnection();return}this.conn=new qUe(this.endpointURL(),void 0,{close:()=>{this.conn=null}})}}endpointURL(){return this._appendParams(this.endPoint,Object.assign({},this.params,{vsn:RUe}))}disconnect(e,r){this.conn&&(this.conn.onclose=function(){},e?this.conn.close(e,r??""):this.conn.close(),this.conn=null,this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.reconnectTimer.reset(),this.channels.forEach(n=>n.teardown()))}getChannels(){return this.channels}async removeChannel(e){const r=await e.unsubscribe();return this.channels=this.channels.filter(n=>n._joinRef!==e._joinRef),this.channels.length===0&&this.disconnect(),r}async removeAllChannels(){const e=await Promise.all(this.channels.map(r=>r.unsubscribe()));return this.channels=[],this.disconnect(),e}log(e,r,n){this.logger(e,r,n)}connectionState(){switch(this.conn&&this.conn.readyState){case fS.connecting:return Q_.Connecting;case fS.open:return Q_.Open;case fS.closing:return Q_.Closing;default:return Q_.Closed}}isConnected(){return this.connectionState()===Q_.Open}channel(e,r={config:{}}){const n=`realtime:${e}`,s=this.getChannels().find(o=>o.topic===n);if(s)return s;{const o=new JH(`realtime:${e}`,r,this);return this.channels.push(o),o}}push(e){const{topic:r,event:n,payload:s,ref:o}=e,c=()=>{this.encode(e,a=>{var f;(f=this.conn)===null||f===void 0||f.send(a)})};this.log("push",`${r} ${n} (${o})`,s),this.isConnected()?c():this.sendBuffer.push(c)}async setAuth(e=null){let r=e||this.accessToken&&await this.accessToken()||this.accessTokenValue;this.accessTokenValue!=r&&(this.accessTokenValue=r,this.channels.forEach(n=>{r&&n.updateJoinPayload({access_token:r,version:this.headers&&this.headers["X-Client-Info"]}),n.joinedOnce&&n._isJoined()&&n._push(gf.access_token,{access_token:r})}))}async sendHeartbeat(){var e;if(!this.isConnected()){this.heartbeatCallback("disconnected");return}if(this.pendingHeartbeatRef){this.pendingHeartbeatRef=null,this.log("transport","heartbeat timeout. Attempting to re-establish connection"),this.heartbeatCallback("timeout"),(e=this.conn)===null||e===void 0||e.close(LUe,"hearbeat timeout");return}this.pendingHeartbeatRef=this._makeRef(),this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:this.pendingHeartbeatRef}),this.heartbeatCallback("sent"),await this.setAuth()}onHeartbeat(e){this.heartbeatCallback=e}flushSendBuffer(){this.isConnected()&&this.sendBuffer.length>0&&(this.sendBuffer.forEach(e=>e()),this.sendBuffer=[])}_makeRef(){let e=this.ref+1;return e===this.ref?this.ref=0:this.ref=e,this.ref.toString()}_leaveOpenTopic(e){let r=this.channels.find(n=>n.topic===e&&(n._isJoined()||n._isJoining()));r&&(this.log("transport",`leaving duplicate topic "${e}"`),r.unsubscribe())}_remove(e){this.channels=this.channels.filter(r=>r.topic!==e.topic)}setupConnection(){this.conn&&(this.conn.binaryType="arraybuffer",this.conn.onopen=()=>this._onConnOpen(),this.conn.onerror=e=>this._onConnError(e),this.conn.onmessage=e=>this._onConnMessage(e),this.conn.onclose=e=>this._onConnClose(e))}_onConnMessage(e){this.decode(e.data,r=>{let{topic:n,event:s,payload:o,ref:c}=r;n==="phoenix"&&s==="phx_reply"&&this.heartbeatCallback(r.payload.status=="ok"?"ok":"error"),c&&c===this.pendingHeartbeatRef&&(this.pendingHeartbeatRef=null),this.log("receive",`${o.status||""} ${n} ${s} ${c&&"("+c+")"||""}`,o),Array.from(this.channels).filter(a=>a._isMember(n)).forEach(a=>a._trigger(s,o,c)),this.stateChangeCallbacks.message.forEach(a=>a(r))})}_onConnOpen(){if(this.log("transport",`connected to ${this.endpointURL()}`),this.flushSendBuffer(),this.reconnectTimer.reset(),!this.worker)this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.heartbeatTimer=setInterval(()=>this.sendHeartbeat(),this.heartbeatIntervalMs);else{this.workerUrl?this.log("worker",`starting worker for from ${this.workerUrl}`):this.log("worker","starting default worker");const e=this._workerObjectUrl(this.workerUrl);this.workerRef=new Worker(e),this.workerRef.onerror=r=>{this.log("worker","worker error",r.message),this.workerRef.terminate()},this.workerRef.onmessage=r=>{r.data.event==="keepAlive"&&this.sendHeartbeat()},this.workerRef.postMessage({event:"start",interval:this.heartbeatIntervalMs})}this.stateChangeCallbacks.open.forEach(e=>e())}_onConnClose(e){this.log("transport","close",e),this._triggerChanError(),this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.reconnectTimer.scheduleTimeout(),this.stateChangeCallbacks.close.forEach(r=>r(e))}_onConnError(e){this.log("transport",e.message),this._triggerChanError(),this.stateChangeCallbacks.error.forEach(r=>r(e))}_triggerChanError(){this.channels.forEach(e=>e._trigger(gf.error))}_appendParams(e,r){if(Object.keys(r).length===0)return e;const n=e.match(/\?/)?"&":"?",s=new URLSearchParams(r);return`${e}${n}${s}`}_workerObjectUrl(e){let r;if(e)r=e;else{const n=new Blob([UUe],{type:"application/javascript"});r=URL.createObjectURL(n)}return r}}class qUe{constructor(e,r,n){this.binaryType="arraybuffer",this.onclose=()=>{},this.onerror=()=>{},this.onmessage=()=>{},this.onopen=()=>{},this.readyState=fS.connecting,this.send=()=>{},this.url=null,this.url=e,this.close=n.close}}class eW extends Error{constructor(e){super(e),this.__isStorageError=!0,this.name="StorageError"}}function Bl(t){return typeof t=="object"&&t!==null&&"__isStorageError"in t}class GUe extends eW{constructor(e,r){super(e),this.name="StorageApiError",this.status=r}toJSON(){return{name:this.name,message:this.message,status:this.status}}}class rq extends eW{constructor(e,r){super(e),this.name="StorageUnknownError",this.originalError=r}}var HUe=function(t,e,r,n){function s(o){return o instanceof r?o:new r(function(c){c(o)})}return new(r||(r=Promise))(function(o,c){function a(y){try{m(n.next(y))}catch(_){c(_)}}function f(y){try{m(n.throw(y))}catch(_){c(_)}}function m(y){y.done?o(y.value):s(y.value).then(a,f)}m((n=n.apply(t,e||[])).next())})};const O0e=t=>{let e;return t?e=t:typeof fetch>"u"?e=(...r)=>Oe(async()=>{const{default:n}=await Promise.resolve().then(()=>QT);return{default:n}},void 0).then(({default:n})=>n(...r)):e=fetch,(...r)=>e(...r)},WUe=()=>HUe(void 0,void 0,void 0,function*(){return typeof Response>"u"?(yield Oe(()=>Promise.resolve().then(()=>QT),void 0)).Response:Response}),nq=t=>{if(Array.isArray(t))return t.map(r=>nq(r));if(typeof t=="function"||t!==Object(t))return t;const e={};return Object.entries(t).forEach(([r,n])=>{const s=r.replace(/([-_][a-z])/gi,o=>o.toUpperCase().replace(/[-_]/g,""));e[s]=nq(n)}),e};var ab=function(t,e,r,n){function s(o){return o instanceof r?o:new r(function(c){c(o)})}return new(r||(r=Promise))(function(o,c){function a(y){try{m(n.next(y))}catch(_){c(_)}}function f(y){try{m(n.throw(y))}catch(_){c(_)}}function m(y){y.done?o(y.value):s(y.value).then(a,f)}m((n=n.apply(t,e||[])).next())})};const Yz=t=>t.msg||t.message||t.error_description||t.error||JSON.stringify(t),KUe=(t,e,r)=>ab(void 0,void 0,void 0,function*(){const n=yield WUe();t instanceof n&&!(r!=null&&r.noResolveJson)?t.json().then(s=>{e(new GUe(Yz(s),t.status||500))}).catch(s=>{e(new rq(Yz(s),s))}):e(new rq(Yz(t),t))}),YUe=(t,e,r,n)=>{const s={method:t,headers:(e==null?void 0:e.headers)||{}};return t==="GET"?s:(s.headers=Object.assign({"Content-Type":"application/json"},e==null?void 0:e.headers),n&&(s.body=JSON.stringify(n)),Object.assign(Object.assign({},s),r))};function CC(t,e,r,n,s,o){return ab(this,void 0,void 0,function*(){return new Promise((c,a)=>{t(r,YUe(e,n,s,o)).then(f=>{if(!f.ok)throw f;return n!=null&&n.noResolveJson?f:f.json()}).then(f=>c(f)).catch(f=>KUe(f,a,n))})})}function KD(t,e,r,n){return ab(this,void 0,void 0,function*(){return CC(t,"GET",e,r,n)})}function Xy(t,e,r,n,s){return ab(this,void 0,void 0,function*(){return CC(t,"POST",e,n,s,r)})}function ZUe(t,e,r,n,s){return ab(this,void 0,void 0,function*(){return CC(t,"PUT",e,n,s,r)})}function XUe(t,e,r,n){return ab(this,void 0,void 0,function*(){return CC(t,"HEAD",e,Object.assign(Object.assign({},r),{noResolveJson:!0}),n)})}function F0e(t,e,r,n,s){return ab(this,void 0,void 0,function*(){return CC(t,"DELETE",e,n,s,r)})}var Fu=function(t,e,r,n){function s(o){return o instanceof r?o:new r(function(c){c(o)})}return new(r||(r=Promise))(function(o,c){function a(y){try{m(n.next(y))}catch(_){c(_)}}function f(y){try{m(n.throw(y))}catch(_){c(_)}}function m(y){y.done?o(y.value):s(y.value).then(a,f)}m((n=n.apply(t,e||[])).next())})};const QUe={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},Hne={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1};class JUe{constructor(e,r={},n,s){this.url=e,this.headers=r,this.bucketId=n,this.fetch=O0e(s)}uploadOrUpdate(e,r,n,s){return Fu(this,void 0,void 0,function*(){try{let o;const c=Object.assign(Object.assign({},Hne),s);let a=Object.assign(Object.assign({},this.headers),e==="POST"&&{"x-upsert":String(c.upsert)});const f=c.metadata;typeof Blob<"u"&&n instanceof Blob?(o=new FormData,o.append("cacheControl",c.cacheControl),f&&o.append("metadata",this.encodeMetadata(f)),o.append("",n)):typeof FormData<"u"&&n instanceof FormData?(o=n,o.append("cacheControl",c.cacheControl),f&&o.append("metadata",this.encodeMetadata(f))):(o=n,a["cache-control"]=`max-age=${c.cacheControl}`,a["content-type"]=c.contentType,f&&(a["x-metadata"]=this.toBase64(this.encodeMetadata(f)))),s!=null&&s.headers&&(a=Object.assign(Object.assign({},a),s.headers));const m=this._removeEmptyFolders(r),y=this._getFinalPath(m),_=yield this.fetch(`${this.url}/object/${y}`,Object.assign({method:e,body:o,headers:a},c!=null&&c.duplex?{duplex:c.duplex}:{})),w=yield _.json();return _.ok?{data:{path:m,id:w.Id,fullPath:w.Key},error:null}:{data:null,error:w}}catch(o){if(Bl(o))return{data:null,error:o};throw o}})}upload(e,r,n){return Fu(this,void 0,void 0,function*(){return this.uploadOrUpdate("POST",e,r,n)})}uploadToSignedUrl(e,r,n,s){return Fu(this,void 0,void 0,function*(){const o=this._removeEmptyFolders(e),c=this._getFinalPath(o),a=new URL(this.url+`/object/upload/sign/${c}`);a.searchParams.set("token",r);try{let f;const m=Object.assign({upsert:Hne.upsert},s),y=Object.assign(Object.assign({},this.headers),{"x-upsert":String(m.upsert)});typeof Blob<"u"&&n instanceof Blob?(f=new FormData,f.append("cacheControl",m.cacheControl),f.append("",n)):typeof FormData<"u"&&n instanceof FormData?(f=n,f.append("cacheControl",m.cacheControl)):(f=n,y["cache-control"]=`max-age=${m.cacheControl}`,y["content-type"]=m.contentType);const _=yield this.fetch(a.toString(),{method:"PUT",body:f,headers:y}),w=yield _.json();return _.ok?{data:{path:o,fullPath:w.Key},error:null}:{data:null,error:w}}catch(f){if(Bl(f))return{data:null,error:f};throw f}})}createSignedUploadUrl(e,r){return Fu(this,void 0,void 0,function*(){try{let n=this._getFinalPath(e);const s=Object.assign({},this.headers);r!=null&&r.upsert&&(s["x-upsert"]="true");const o=yield Xy(this.fetch,`${this.url}/object/upload/sign/${n}`,{},{headers:s}),c=new URL(this.url+o.url),a=c.searchParams.get("token");if(!a)throw new eW("No token returned by API");return{data:{signedUrl:c.toString(),path:e,token:a},error:null}}catch(n){if(Bl(n))return{data:null,error:n};throw n}})}update(e,r,n){return Fu(this,void 0,void 0,function*(){return this.uploadOrUpdate("PUT",e,r,n)})}move(e,r,n){return Fu(this,void 0,void 0,function*(){try{return{data:yield Xy(this.fetch,`${this.url}/object/move`,{bucketId:this.bucketId,sourceKey:e,destinationKey:r,destinationBucket:n==null?void 0:n.destinationBucket},{headers:this.headers}),error:null}}catch(s){if(Bl(s))return{data:null,error:s};throw s}})}copy(e,r,n){return Fu(this,void 0,void 0,function*(){try{return{data:{path:(yield Xy(this.fetch,`${this.url}/object/copy`,{bucketId:this.bucketId,sourceKey:e,destinationKey:r,destinationBucket:n==null?void 0:n.destinationBucket},{headers:this.headers})).Key},error:null}}catch(s){if(Bl(s))return{data:null,error:s};throw s}})}createSignedUrl(e,r,n){return Fu(this,void 0,void 0,function*(){try{let s=this._getFinalPath(e),o=yield Xy(this.fetch,`${this.url}/object/sign/${s}`,Object.assign({expiresIn:r},n!=null&&n.transform?{transform:n.transform}:{}),{headers:this.headers});const c=n!=null&&n.download?`&download=${n.download===!0?"":n.download}`:"";return o={signedUrl:encodeURI(`${this.url}${o.signedURL}${c}`)},{data:o,error:null}}catch(s){if(Bl(s))return{data:null,error:s};throw s}})}createSignedUrls(e,r,n){return Fu(this,void 0,void 0,function*(){try{const s=yield Xy(this.fetch,`${this.url}/object/sign/${this.bucketId}`,{expiresIn:r,paths:e},{headers:this.headers}),o=n!=null&&n.download?`&download=${n.download===!0?"":n.download}`:"";return{data:s.map(c=>Object.assign(Object.assign({},c),{signedUrl:c.signedURL?encodeURI(`${this.url}${c.signedURL}${o}`):null})),error:null}}catch(s){if(Bl(s))return{data:null,error:s};throw s}})}download(e,r){return Fu(this,void 0,void 0,function*(){const s=typeof(r==null?void 0:r.transform)<"u"?"render/image/authenticated":"object",o=this.transformOptsToQueryString((r==null?void 0:r.transform)||{}),c=o?`?${o}`:"";try{const a=this._getFinalPath(e);return{data:yield(yield KD(this.fetch,`${this.url}/${s}/${a}${c}`,{headers:this.headers,noResolveJson:!0})).blob(),error:null}}catch(a){if(Bl(a))return{data:null,error:a};throw a}})}info(e){return Fu(this,void 0,void 0,function*(){const r=this._getFinalPath(e);try{const n=yield KD(this.fetch,`${this.url}/object/info/${r}`,{headers:this.headers});return{data:nq(n),error:null}}catch(n){if(Bl(n))return{data:null,error:n};throw n}})}exists(e){return Fu(this,void 0,void 0,function*(){const r=this._getFinalPath(e);try{return yield XUe(this.fetch,`${this.url}/object/${r}`,{headers:this.headers}),{data:!0,error:null}}catch(n){if(Bl(n)&&n instanceof rq){const s=n.originalError;if([400,404].includes(s==null?void 0:s.status))return{data:!1,error:n}}throw n}})}getPublicUrl(e,r){const n=this._getFinalPath(e),s=[],o=r!=null&&r.download?`download=${r.download===!0?"":r.download}`:"";o!==""&&s.push(o);const a=typeof(r==null?void 0:r.transform)<"u"?"render/image":"object",f=this.transformOptsToQueryString((r==null?void 0:r.transform)||{});f!==""&&s.push(f);let m=s.join("&");return m!==""&&(m=`?${m}`),{data:{publicUrl:encodeURI(`${this.url}/${a}/public/${n}${m}`)}}}remove(e){return Fu(this,void 0,void 0,function*(){try{return{data:yield F0e(this.fetch,`${this.url}/object/${this.bucketId}`,{prefixes:e},{headers:this.headers}),error:null}}catch(r){if(Bl(r))return{data:null,error:r};throw r}})}list(e,r,n){return Fu(this,void 0,void 0,function*(){try{const s=Object.assign(Object.assign(Object.assign({},QUe),r),{prefix:e||""});return{data:yield Xy(this.fetch,`${this.url}/object/list/${this.bucketId}`,s,{headers:this.headers},n),error:null}}catch(s){if(Bl(s))return{data:null,error:s};throw s}})}encodeMetadata(e){return JSON.stringify(e)}toBase64(e){return typeof Buffer<"u"?Buffer.from(e).toString("base64"):btoa(e)}_getFinalPath(e){return`${this.bucketId}/${e}`}_removeEmptyFolders(e){return e.replace(/^\/|\/$/g,"").replace(/\/+/g,"/")}transformOptsToQueryString(e){const r=[];return e.width&&r.push(`width=${e.width}`),e.height&&r.push(`height=${e.height}`),e.resize&&r.push(`resize=${e.resize}`),e.format&&r.push(`format=${e.format}`),e.quality&&r.push(`quality=${e.quality}`),r.join("&")}}const eVe="2.7.1",tVe={"X-Client-Info":`storage-js/${eVe}`};var Xw=function(t,e,r,n){function s(o){return o instanceof r?o:new r(function(c){c(o)})}return new(r||(r=Promise))(function(o,c){function a(y){try{m(n.next(y))}catch(_){c(_)}}function f(y){try{m(n.throw(y))}catch(_){c(_)}}function m(y){y.done?o(y.value):s(y.value).then(a,f)}m((n=n.apply(t,e||[])).next())})};class rVe{constructor(e,r={},n){this.url=e,this.headers=Object.assign(Object.assign({},tVe),r),this.fetch=O0e(n)}listBuckets(){return Xw(this,void 0,void 0,function*(){try{return{data:yield KD(this.fetch,`${this.url}/bucket`,{headers:this.headers}),error:null}}catch(e){if(Bl(e))return{data:null,error:e};throw e}})}getBucket(e){return Xw(this,void 0,void 0,function*(){try{return{data:yield KD(this.fetch,`${this.url}/bucket/${e}`,{headers:this.headers}),error:null}}catch(r){if(Bl(r))return{data:null,error:r};throw r}})}createBucket(e,r={public:!1}){return Xw(this,void 0,void 0,function*(){try{return{data:yield Xy(this.fetch,`${this.url}/bucket`,{id:e,name:e,public:r.public,file_size_limit:r.fileSizeLimit,allowed_mime_types:r.allowedMimeTypes},{headers:this.headers}),error:null}}catch(n){if(Bl(n))return{data:null,error:n};throw n}})}updateBucket(e,r){return Xw(this,void 0,void 0,function*(){try{return{data:yield ZUe(this.fetch,`${this.url}/bucket/${e}`,{id:e,name:e,public:r.public,file_size_limit:r.fileSizeLimit,allowed_mime_types:r.allowedMimeTypes},{headers:this.headers}),error:null}}catch(n){if(Bl(n))return{data:null,error:n};throw n}})}emptyBucket(e){return Xw(this,void 0,void 0,function*(){try{return{data:yield Xy(this.fetch,`${this.url}/bucket/${e}/empty`,{},{headers:this.headers}),error:null}}catch(r){if(Bl(r))return{data:null,error:r};throw r}})}deleteBucket(e){return Xw(this,void 0,void 0,function*(){try{return{data:yield F0e(this.fetch,`${this.url}/bucket/${e}`,{},{headers:this.headers}),error:null}}catch(r){if(Bl(r))return{data:null,error:r};throw r}})}}class nVe extends rVe{constructor(e,r={},n){super(e,r,n)}from(e){return new JUe(this.url,this.headers,e,this.fetch)}}const sVe="2.49.10";let Rk="";typeof Deno<"u"?Rk="deno":typeof document<"u"?Rk="web":typeof navigator<"u"&&navigator.product==="ReactNative"?Rk="react-native":Rk="node";const iVe={"X-Client-Info":`supabase-js-${Rk}/${sVe}`},aVe={headers:iVe},oVe={schema:"public"},lVe={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},cVe={};var uVe=function(t,e,r,n){function s(o){return o instanceof r?o:new r(function(c){c(o)})}return new(r||(r=Promise))(function(o,c){function a(y){try{m(n.next(y))}catch(_){c(_)}}function f(y){try{m(n.throw(y))}catch(_){c(_)}}function m(y){y.done?o(y.value):s(y.value).then(a,f)}m((n=n.apply(t,e||[])).next())})};const dVe=t=>{let e;return t?e=t:typeof fetch>"u"?e=w0e:e=fetch,(...r)=>e(...r)},hVe=()=>typeof Headers>"u"?S0e:Headers,fVe=(t,e,r)=>{const n=dVe(r),s=hVe();return(o,c)=>uVe(void 0,void 0,void 0,function*(){var a;const f=(a=yield e())!==null&&a!==void 0?a:t;let m=new s(c==null?void 0:c.headers);return m.has("apikey")||m.set("apikey",t),m.has("Authorization")||m.set("Authorization",`Bearer ${f}`),n(o,Object.assign(Object.assign({},c),{headers:m}))})};var mVe=function(t,e,r,n){function s(o){return o instanceof r?o:new r(function(c){c(o)})}return new(r||(r=Promise))(function(o,c){function a(y){try{m(n.next(y))}catch(_){c(_)}}function f(y){try{m(n.throw(y))}catch(_){c(_)}}function m(y){y.done?o(y.value):s(y.value).then(a,f)}m((n=n.apply(t,e||[])).next())})};function pVe(t){return t.endsWith("/")?t:t+"/"}function gVe(t,e){var r,n;const{db:s,auth:o,realtime:c,global:a}=t,{db:f,auth:m,realtime:y,global:_}=e,w={db:Object.assign(Object.assign({},f),s),auth:Object.assign(Object.assign({},m),o),realtime:Object.assign(Object.assign({},y),c),global:Object.assign(Object.assign(Object.assign({},_),a),{headers:Object.assign(Object.assign({},(r=_==null?void 0:_.headers)!==null&&r!==void 0?r:{}),(n=a==null?void 0:a.headers)!==null&&n!==void 0?n:{})}),accessToken:()=>mVe(this,void 0,void 0,function*(){return""})};return t.accessToken?w.accessToken=t.accessToken:delete w.accessToken,w}const B0e="2.69.1",E1=30*1e3,sq=3,Zz=sq*E1,yVe="http://localhost:9999",xVe="supabase.auth.token",_Ve={"X-Client-Info":`gotrue-js/${B0e}`},iq="X-Supabase-Api-Version",$0e={"2024-01-01":{timestamp:Date.parse("2024-01-01T00:00:00.0Z"),name:"2024-01-01"}},vVe=/^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}$|[a-z0-9_-]{2}$)$/i,bVe=6e5;class tW extends Error{constructor(e,r,n){super(e),this.__isAuthError=!0,this.name="AuthError",this.status=r,this.code=n}}function Hs(t){return typeof t=="object"&&t!==null&&"__isAuthError"in t}class wVe extends tW{constructor(e,r,n){super(e,r,n),this.name="AuthApiError",this.status=r,this.code=n}}function SVe(t){return Hs(t)&&t.name==="AuthApiError"}class z0e extends tW{constructor(e,r){super(e),this.name="AuthUnknownError",this.originalError=r}}class u0 extends tW{constructor(e,r,n,s){super(e,n,s),this.name=r,this.status=n}}class Gy extends u0{constructor(){super("Auth session missing!","AuthSessionMissingError",400,void 0)}}function TVe(t){return Hs(t)&&t.name==="AuthSessionMissingError"}class Xz extends u0{constructor(){super("Auth session or user missing","AuthInvalidTokenResponseError",500,void 0)}}class aL extends u0{constructor(e){super(e,"AuthInvalidCredentialsError",400,void 0)}}class oL extends u0{constructor(e,r=null){super(e,"AuthImplicitGrantRedirectError",500,void 0),this.details=null,this.details=r}toJSON(){return{name:this.name,message:this.message,status:this.status,details:this.details}}}function EVe(t){return Hs(t)&&t.name==="AuthImplicitGrantRedirectError"}class Wne extends u0{constructor(e,r=null){super(e,"AuthPKCEGrantCodeExchangeError",500,void 0),this.details=null,this.details=r}toJSON(){return{name:this.name,message:this.message,status:this.status,details:this.details}}}class aq extends u0{constructor(e,r){super(e,"AuthRetryableFetchError",r,void 0)}}function Qz(t){return Hs(t)&&t.name==="AuthRetryableFetchError"}class Kne extends u0{constructor(e,r,n){super(e,"AuthWeakPasswordError",r,"weak_password"),this.reasons=n}}class nA extends u0{constructor(e){super(e,"AuthInvalidJwtError",400,"invalid_jwt")}}const Yne="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".split(""),Zne=` \r=`.split(""),jVe=(()=>{const t=new Array(128);for(let e=0;e-1)for(e.queue=e.queue<<6|n,e.queuedBits+=6;e.queuedBits>=8;)r(e.queue>>e.queuedBits-8&255),e.queuedBits-=8;else{if(n===-2)return;throw new Error(`Invalid Base64-URL character "${String.fromCharCode(t)}"`)}}function Xne(t){const e=[],r=c=>{e.push(String.fromCodePoint(c))},n={utf8seq:0,codepoint:0},s={queue:0,queuedBits:0},o=c=>{NVe(c,n,r)};for(let c=0;c>6),e(128|t&63);return}else if(t<=65535){e(224|t>>12),e(128|t>>6&63),e(128|t&63);return}else if(t<=1114111){e(240|t>>18),e(128|t>>12&63),e(128|t>>6&63),e(128|t&63);return}throw new Error(`Unrecognized Unicode codepoint: ${t.toString(16)}`)}function AVe(t,e){for(let r=0;r55295&&n<=56319){const s=(n-55296)*1024&65535;n=(t.charCodeAt(r+1)-56320&65535|s)+65536,r+=1}kVe(n,e)}}function NVe(t,e,r){if(e.utf8seq===0){if(t<=127){r(t);return}for(let n=1;n<6;n+=1)if(!(t>>7-n&1)){e.utf8seq=n;break}if(e.utf8seq===2)e.codepoint=t&31;else if(e.utf8seq===3)e.codepoint=t&15;else if(e.utf8seq===4)e.codepoint=t&7;else throw new Error("Invalid UTF-8 sequence");e.utf8seq-=1}else if(e.utf8seq>0){if(t<=127)throw new Error("Invalid UTF-8 sequence");e.codepoint=e.codepoint<<6|t&63,e.utf8seq-=1,e.utf8seq===0&&r(e.codepoint)}}function CVe(t){const e=[],r={queue:0,queuedBits:0},n=s=>{e.push(s)};for(let s=0;se.push(r)),new Uint8Array(e)}function PVe(t){return Math.round(Date.now()/1e3)+t}function RVe(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){const e=Math.random()*16|0;return(t=="x"?e:e&3|8).toString(16)})}const _m=()=>typeof window<"u"&&typeof document<"u",P_={tested:!1,writable:!1},sA=()=>{if(!_m())return!1;try{if(typeof globalThis.localStorage!="object")return!1}catch{return!1}if(P_.tested)return P_.writable;const t=`lswt-${Math.random()}${Math.random()}`;try{globalThis.localStorage.setItem(t,t),globalThis.localStorage.removeItem(t),P_.tested=!0,P_.writable=!0}catch{P_.tested=!0,P_.writable=!1}return P_.writable};function LVe(t){const e={},r=new URL(t);if(r.hash&&r.hash[0]==="#")try{new URLSearchParams(r.hash.substring(1)).forEach((s,o)=>{e[o]=s})}catch{}return r.searchParams.forEach((n,s)=>{e[s]=n}),e}const V0e=t=>{let e;return t?e=t:typeof fetch>"u"?e=(...r)=>Oe(async()=>{const{default:n}=await Promise.resolve().then(()=>QT);return{default:n}},void 0).then(({default:n})=>n(...r)):e=fetch,(...r)=>e(...r)},MVe=t=>typeof t=="object"&&t!==null&&"status"in t&&"ok"in t&&"json"in t&&typeof t.json=="function",q0e=async(t,e,r)=>{await t.setItem(e,JSON.stringify(r))},lL=async(t,e)=>{const r=await t.getItem(e);if(!r)return null;try{return JSON.parse(r)}catch{return r}},cL=async(t,e)=>{await t.removeItem(e)};class R4{constructor(){this.promise=new R4.promiseConstructor((e,r)=>{this.resolve=e,this.reject=r})}}R4.promiseConstructor=Promise;function Jz(t){const e=t.split(".");if(e.length!==3)throw new nA("Invalid JWT structure");for(let n=0;n{setTimeout(()=>e(null),t)})}function OVe(t,e){return new Promise((n,s)=>{(async()=>{for(let o=0;o<1/0;o++)try{const c=await t(o);if(!e(o,null,c)){n(c);return}}catch(c){if(!e(o,c)){s(c);return}}})()})}function FVe(t){return("0"+t.toString(16)).substr(-2)}function BVe(){const e=new Uint32Array(56);if(typeof crypto>"u"){const r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",n=r.length;let s="";for(let o=0;o<56;o++)s+=r.charAt(Math.floor(Math.random()*n));return s}return crypto.getRandomValues(e),Array.from(e,FVe).join("")}async function $Ve(t){const r=new TextEncoder().encode(t),n=await crypto.subtle.digest("SHA-256",r),s=new Uint8Array(n);return Array.from(s).map(o=>String.fromCharCode(o)).join("")}async function zVe(t){if(!(typeof crypto<"u"&&typeof crypto.subtle<"u"&&typeof TextEncoder<"u"))return console.warn("WebCrypto API is not supported. Code challenge method will default to use plain instead of sha256."),t;const r=await $Ve(t);return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function Qw(t,e,r=!1){const n=BVe();let s=n;r&&(s+="/PASSWORD_RECOVERY"),await q0e(t,`${e}-code-verifier`,s);const o=await zVe(n);return[o,n===o?"plain":"s256"]}const UVe=/^2[0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1])$/i;function VVe(t){const e=t.headers.get(iq);if(!e||!e.match(UVe))return null;try{return new Date(`${e}T00:00:00.0Z`)}catch{return null}}function qVe(t){if(!t)throw new Error("Missing exp claim");const e=Math.floor(Date.now()/1e3);if(t<=e)throw new Error("JWT has expired")}function GVe(t){switch(t){case"RS256":return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}};case"ES256":return{name:"ECDSA",namedCurve:"P-256",hash:{name:"SHA-256"}};default:throw new Error("Invalid alg claim")}}var HVe=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(t);st.msg||t.message||t.error_description||t.error||JSON.stringify(t),WVe=[502,503,504];async function Qne(t){var e;if(!MVe(t))throw new aq(G_(t),0);if(WVe.includes(t.status))throw new aq(G_(t),t.status);let r;try{r=await t.json()}catch(o){throw new z0e(G_(o),o)}let n;const s=VVe(t);if(s&&s.getTime()>=$0e["2024-01-01"].timestamp&&typeof r=="object"&&r&&typeof r.code=="string"?n=r.code:typeof r=="object"&&r&&typeof r.error_code=="string"&&(n=r.error_code),n){if(n==="weak_password")throw new Kne(G_(r),t.status,((e=r.weak_password)===null||e===void 0?void 0:e.reasons)||[]);if(n==="session_not_found")throw new Gy}else if(typeof r=="object"&&r&&typeof r.weak_password=="object"&&r.weak_password&&Array.isArray(r.weak_password.reasons)&&r.weak_password.reasons.length&&r.weak_password.reasons.reduce((o,c)=>o&&typeof c=="string",!0))throw new Kne(G_(r),t.status,r.weak_password.reasons);throw new wVe(G_(r),t.status||500,n)}const KVe=(t,e,r,n)=>{const s={method:t,headers:(e==null?void 0:e.headers)||{}};return t==="GET"?s:(s.headers=Object.assign({"Content-Type":"application/json;charset=UTF-8"},e==null?void 0:e.headers),s.body=JSON.stringify(n),Object.assign(Object.assign({},s),r))};async function li(t,e,r,n){var s;const o=Object.assign({},n==null?void 0:n.headers);o[iq]||(o[iq]=$0e["2024-01-01"].name),n!=null&&n.jwt&&(o.Authorization=`Bearer ${n.jwt}`);const c=(s=n==null?void 0:n.query)!==null&&s!==void 0?s:{};n!=null&&n.redirectTo&&(c.redirect_to=n.redirectTo);const a=Object.keys(c).length?"?"+new URLSearchParams(c).toString():"",f=await YVe(t,e,r+a,{headers:o,noResolveJson:n==null?void 0:n.noResolveJson},{},n==null?void 0:n.body);return n!=null&&n.xform?n==null?void 0:n.xform(f):{data:Object.assign({},f),error:null}}async function YVe(t,e,r,n,s,o){const c=KVe(e,n,s,o);let a;try{a=await t(r,Object.assign({},c))}catch(f){throw console.error(f),new aq(G_(f),0)}if(a.ok||await Qne(a),n!=null&&n.noResolveJson)return a;try{return await a.json()}catch(f){await Qne(f)}}function Hy(t){var e;let r=null;JVe(t)&&(r=Object.assign({},t),t.expires_at||(r.expires_at=PVe(t.expires_in)));const n=(e=t.user)!==null&&e!==void 0?e:t;return{data:{session:r,user:n},error:null}}function Jne(t){const e=Hy(t);return!e.error&&t.weak_password&&typeof t.weak_password=="object"&&Array.isArray(t.weak_password.reasons)&&t.weak_password.reasons.length&&t.weak_password.message&&typeof t.weak_password.message=="string"&&t.weak_password.reasons.reduce((r,n)=>r&&typeof n=="string",!0)&&(e.data.weak_password=t.weak_password),e}function sx(t){var e;return{data:{user:(e=t.user)!==null&&e!==void 0?e:t},error:null}}function ZVe(t){return{data:t,error:null}}function XVe(t){const{action_link:e,email_otp:r,hashed_token:n,redirect_to:s,verification_type:o}=t,c=HVe(t,["action_link","email_otp","hashed_token","redirect_to","verification_type"]),a={action_link:e,email_otp:r,hashed_token:n,redirect_to:s,verification_type:o},f=Object.assign({},c);return{data:{properties:a,user:f},error:null}}function QVe(t){return t}function JVe(t){return t.access_token&&t.refresh_token&&t.expires_in}var e8e=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(t);s0&&(E.forEach(A=>{const C=parseInt(A.split(";")[0].split("=")[1].substring(0,1)),I=JSON.parse(A.split(";")[1].split("=")[1]);m[`${I}Page`]=C}),m.total=parseInt(w)),{data:Object.assign(Object.assign({},_),m),error:null}}catch(m){if(Hs(m))return{data:{users:[]},error:m};throw m}}async getUserById(e){try{return await li(this.fetch,"GET",`${this.url}/admin/users/${e}`,{headers:this.headers,xform:sx})}catch(r){if(Hs(r))return{data:{user:null},error:r};throw r}}async updateUserById(e,r){try{return await li(this.fetch,"PUT",`${this.url}/admin/users/${e}`,{body:r,headers:this.headers,xform:sx})}catch(n){if(Hs(n))return{data:{user:null},error:n};throw n}}async deleteUser(e,r=!1){try{return await li(this.fetch,"DELETE",`${this.url}/admin/users/${e}`,{headers:this.headers,body:{should_soft_delete:r},xform:sx})}catch(n){if(Hs(n))return{data:{user:null},error:n};throw n}}async _listFactors(e){try{const{data:r,error:n}=await li(this.fetch,"GET",`${this.url}/admin/users/${e.userId}/factors`,{headers:this.headers,xform:s=>({data:{factors:s},error:null})});return{data:r,error:n}}catch(r){if(Hs(r))return{data:null,error:r};throw r}}async _deleteFactor(e){try{return{data:await li(this.fetch,"DELETE",`${this.url}/admin/users/${e.userId}/factors/${e.id}`,{headers:this.headers}),error:null}}catch(r){if(Hs(r))return{data:null,error:r};throw r}}}const r8e={getItem:t=>sA()?globalThis.localStorage.getItem(t):null,setItem:(t,e)=>{sA()&&globalThis.localStorage.setItem(t,e)},removeItem:t=>{sA()&&globalThis.localStorage.removeItem(t)}};function ese(t={}){return{getItem:e=>t[e]||null,setItem:(e,r)=>{t[e]=r},removeItem:e=>{delete t[e]}}}function n8e(){if(typeof globalThis!="object")try{Object.defineProperty(Object.prototype,"__magic__",{get:function(){return this},configurable:!0}),__magic__.globalThis=__magic__,delete Object.prototype.__magic__}catch{typeof self<"u"&&(self.globalThis=self)}}const Jw={debug:!!(globalThis&&sA()&&globalThis.localStorage&&globalThis.localStorage.getItem("supabase.gotrue-js.locks.debug")==="true")};class G0e extends Error{constructor(e){super(e),this.isAcquireTimeout=!0}}class s8e extends G0e{}async function i8e(t,e,r){Jw.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquire lock",t,e);const n=new globalThis.AbortController;return e>0&&setTimeout(()=>{n.abort(),Jw.debug&&console.log("@supabase/gotrue-js: navigatorLock acquire timed out",t)},e),await Promise.resolve().then(()=>globalThis.navigator.locks.request(t,e===0?{mode:"exclusive",ifAvailable:!0}:{mode:"exclusive",signal:n.signal},async s=>{if(s){Jw.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquired",t,s.name);try{return await r()}finally{Jw.debug&&console.log("@supabase/gotrue-js: navigatorLock: released",t,s.name)}}else{if(e===0)throw Jw.debug&&console.log("@supabase/gotrue-js: navigatorLock: not immediately available",t),new s8e(`Acquiring an exclusive Navigator LockManager lock "${t}" immediately failed`);if(Jw.debug)try{const o=await globalThis.navigator.locks.query();console.log("@supabase/gotrue-js: Navigator LockManager state",JSON.stringify(o,null," "))}catch(o){console.warn("@supabase/gotrue-js: Error when querying Navigator LockManager state",o)}return console.warn("@supabase/gotrue-js: Navigator LockManager returned a null lock when using #request without ifAvailable set to true, it appears this browser is not following the LockManager spec https://developer.mozilla.org/en-US/docs/Web/API/LockManager/request"),await r()}}))}n8e();const a8e={url:yVe,storageKey:xVe,autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:_Ve,flowType:"implicit",debug:!1,hasCustomAuthorizationHeader:!1};async function tse(t,e,r){return await r()}class QA{constructor(e){var r,n;this.memoryStorage=null,this.stateChangeEmitters=new Map,this.autoRefreshTicker=null,this.visibilityChangedCallback=null,this.refreshingDeferred=null,this.initializePromise=null,this.detectSessionInUrl=!0,this.hasCustomAuthorizationHeader=!1,this.suppressGetSessionWarning=!1,this.lockAcquired=!1,this.pendingInLock=[],this.broadcastChannel=null,this.logger=console.log,this.instanceID=QA.nextInstanceID,QA.nextInstanceID+=1,this.instanceID>0&&_m()&&console.warn("Multiple GoTrueClient instances detected in the same browser context. It is not an error, but this should be avoided as it may produce undefined behavior when used concurrently under the same storage key.");const s=Object.assign(Object.assign({},a8e),e);if(this.logDebugMessages=!!s.debug,typeof s.debug=="function"&&(this.logger=s.debug),this.persistSession=s.persistSession,this.storageKey=s.storageKey,this.autoRefreshToken=s.autoRefreshToken,this.admin=new t8e({url:s.url,headers:s.headers,fetch:s.fetch}),this.url=s.url,this.headers=s.headers,this.fetch=V0e(s.fetch),this.lock=s.lock||tse,this.detectSessionInUrl=s.detectSessionInUrl,this.flowType=s.flowType,this.hasCustomAuthorizationHeader=s.hasCustomAuthorizationHeader,s.lock?this.lock=s.lock:_m()&&(!((r=globalThis==null?void 0:globalThis.navigator)===null||r===void 0)&&r.locks)?this.lock=i8e:this.lock=tse,this.jwks={keys:[]},this.jwks_cached_at=Number.MIN_SAFE_INTEGER,this.mfa={verify:this._verify.bind(this),enroll:this._enroll.bind(this),unenroll:this._unenroll.bind(this),challenge:this._challenge.bind(this),listFactors:this._listFactors.bind(this),challengeAndVerify:this._challengeAndVerify.bind(this),getAuthenticatorAssuranceLevel:this._getAuthenticatorAssuranceLevel.bind(this)},this.persistSession?s.storage?this.storage=s.storage:sA()?this.storage=r8e:(this.memoryStorage={},this.storage=ese(this.memoryStorage)):(this.memoryStorage={},this.storage=ese(this.memoryStorage)),_m()&&globalThis.BroadcastChannel&&this.persistSession&&this.storageKey){try{this.broadcastChannel=new globalThis.BroadcastChannel(this.storageKey)}catch(o){console.error("Failed to create a new BroadcastChannel, multi-tab state changes will not be available",o)}(n=this.broadcastChannel)===null||n===void 0||n.addEventListener("message",async o=>{this._debug("received broadcast notification from other tab or client",o),await this._notifyAllSubscribers(o.data.event,o.data.session,!1)})}this.initialize()}_debug(...e){return this.logDebugMessages&&this.logger(`GoTrueClient@${this.instanceID} (${B0e}) ${new Date().toISOString()}`,...e),this}async initialize(){return this.initializePromise?await this.initializePromise:(this.initializePromise=(async()=>await this._acquireLock(-1,async()=>await this._initialize()))(),await this.initializePromise)}async _initialize(){var e;try{const r=LVe(window.location.href);let n="none";if(this._isImplicitGrantCallback(r)?n="implicit":await this._isPKCECallback(r)&&(n="pkce"),_m()&&this.detectSessionInUrl&&n!=="none"){const{data:s,error:o}=await this._getSessionFromURL(r,n);if(o){if(this._debug("#_initialize()","error detecting session from URL",o),EVe(o)){const f=(e=o.details)===null||e===void 0?void 0:e.code;if(f==="identity_already_exists"||f==="identity_not_found"||f==="single_identity_not_deletable")return{error:o}}return await this._removeSession(),{error:o}}const{session:c,redirectType:a}=s;return this._debug("#_initialize()","detected session in URL",c,"redirect type",a),await this._saveSession(c),setTimeout(async()=>{a==="recovery"?await this._notifyAllSubscribers("PASSWORD_RECOVERY",c):await this._notifyAllSubscribers("SIGNED_IN",c)},0),{error:null}}return await this._recoverAndRefresh(),{error:null}}catch(r){return Hs(r)?{error:r}:{error:new z0e("Unexpected error during initialization",r)}}finally{await this._handleVisibilityChange(),this._debug("#_initialize()","end")}}async signInAnonymously(e){var r,n,s;try{const o=await li(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{data:(n=(r=e==null?void 0:e.options)===null||r===void 0?void 0:r.data)!==null&&n!==void 0?n:{},gotrue_meta_security:{captcha_token:(s=e==null?void 0:e.options)===null||s===void 0?void 0:s.captchaToken}},xform:Hy}),{data:c,error:a}=o;if(a||!c)return{data:{user:null,session:null},error:a};const f=c.session,m=c.user;return c.session&&(await this._saveSession(c.session),await this._notifyAllSubscribers("SIGNED_IN",f)),{data:{user:m,session:f},error:null}}catch(o){if(Hs(o))return{data:{user:null,session:null},error:o};throw o}}async signUp(e){var r,n,s;try{let o;if("email"in e){const{email:y,password:_,options:w}=e;let E=null,A=null;this.flowType==="pkce"&&([E,A]=await Qw(this.storage,this.storageKey)),o=await li(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,redirectTo:w==null?void 0:w.emailRedirectTo,body:{email:y,password:_,data:(r=w==null?void 0:w.data)!==null&&r!==void 0?r:{},gotrue_meta_security:{captcha_token:w==null?void 0:w.captchaToken},code_challenge:E,code_challenge_method:A},xform:Hy})}else if("phone"in e){const{phone:y,password:_,options:w}=e;o=await li(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{phone:y,password:_,data:(n=w==null?void 0:w.data)!==null&&n!==void 0?n:{},channel:(s=w==null?void 0:w.channel)!==null&&s!==void 0?s:"sms",gotrue_meta_security:{captcha_token:w==null?void 0:w.captchaToken}},xform:Hy})}else throw new aL("You must provide either an email or phone number and a password");const{data:c,error:a}=o;if(a||!c)return{data:{user:null,session:null},error:a};const f=c.session,m=c.user;return c.session&&(await this._saveSession(c.session),await this._notifyAllSubscribers("SIGNED_IN",f)),{data:{user:m,session:f},error:null}}catch(o){if(Hs(o))return{data:{user:null,session:null},error:o};throw o}}async signInWithPassword(e){try{let r;if("email"in e){const{email:o,password:c,options:a}=e;r=await li(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{email:o,password:c,gotrue_meta_security:{captcha_token:a==null?void 0:a.captchaToken}},xform:Jne})}else if("phone"in e){const{phone:o,password:c,options:a}=e;r=await li(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{phone:o,password:c,gotrue_meta_security:{captcha_token:a==null?void 0:a.captchaToken}},xform:Jne})}else throw new aL("You must provide either an email or phone number and a password");const{data:n,error:s}=r;return s?{data:{user:null,session:null},error:s}:!n||!n.session||!n.user?{data:{user:null,session:null},error:new Xz}:(n.session&&(await this._saveSession(n.session),await this._notifyAllSubscribers("SIGNED_IN",n.session)),{data:Object.assign({user:n.user,session:n.session},n.weak_password?{weakPassword:n.weak_password}:null),error:s})}catch(r){if(Hs(r))return{data:{user:null,session:null},error:r};throw r}}async signInWithOAuth(e){var r,n,s,o;return await this._handleProviderSignIn(e.provider,{redirectTo:(r=e.options)===null||r===void 0?void 0:r.redirectTo,scopes:(n=e.options)===null||n===void 0?void 0:n.scopes,queryParams:(s=e.options)===null||s===void 0?void 0:s.queryParams,skipBrowserRedirect:(o=e.options)===null||o===void 0?void 0:o.skipBrowserRedirect})}async exchangeCodeForSession(e){return await this.initializePromise,this._acquireLock(-1,async()=>this._exchangeCodeForSession(e))}async _exchangeCodeForSession(e){const r=await lL(this.storage,`${this.storageKey}-code-verifier`),[n,s]=(r??"").split("/");try{const{data:o,error:c}=await li(this.fetch,"POST",`${this.url}/token?grant_type=pkce`,{headers:this.headers,body:{auth_code:e,code_verifier:n},xform:Hy});if(await cL(this.storage,`${this.storageKey}-code-verifier`),c)throw c;return!o||!o.session||!o.user?{data:{user:null,session:null,redirectType:null},error:new Xz}:(o.session&&(await this._saveSession(o.session),await this._notifyAllSubscribers("SIGNED_IN",o.session)),{data:Object.assign(Object.assign({},o),{redirectType:s??null}),error:c})}catch(o){if(Hs(o))return{data:{user:null,session:null,redirectType:null},error:o};throw o}}async signInWithIdToken(e){try{const{options:r,provider:n,token:s,access_token:o,nonce:c}=e,a=await li(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,body:{provider:n,id_token:s,access_token:o,nonce:c,gotrue_meta_security:{captcha_token:r==null?void 0:r.captchaToken}},xform:Hy}),{data:f,error:m}=a;return m?{data:{user:null,session:null},error:m}:!f||!f.session||!f.user?{data:{user:null,session:null},error:new Xz}:(f.session&&(await this._saveSession(f.session),await this._notifyAllSubscribers("SIGNED_IN",f.session)),{data:f,error:m})}catch(r){if(Hs(r))return{data:{user:null,session:null},error:r};throw r}}async signInWithOtp(e){var r,n,s,o,c;try{if("email"in e){const{email:a,options:f}=e;let m=null,y=null;this.flowType==="pkce"&&([m,y]=await Qw(this.storage,this.storageKey));const{error:_}=await li(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{email:a,data:(r=f==null?void 0:f.data)!==null&&r!==void 0?r:{},create_user:(n=f==null?void 0:f.shouldCreateUser)!==null&&n!==void 0?n:!0,gotrue_meta_security:{captcha_token:f==null?void 0:f.captchaToken},code_challenge:m,code_challenge_method:y},redirectTo:f==null?void 0:f.emailRedirectTo});return{data:{user:null,session:null},error:_}}if("phone"in e){const{phone:a,options:f}=e,{data:m,error:y}=await li(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{phone:a,data:(s=f==null?void 0:f.data)!==null&&s!==void 0?s:{},create_user:(o=f==null?void 0:f.shouldCreateUser)!==null&&o!==void 0?o:!0,gotrue_meta_security:{captcha_token:f==null?void 0:f.captchaToken},channel:(c=f==null?void 0:f.channel)!==null&&c!==void 0?c:"sms"}});return{data:{user:null,session:null,messageId:m==null?void 0:m.message_id},error:y}}throw new aL("You must provide either an email or phone number.")}catch(a){if(Hs(a))return{data:{user:null,session:null},error:a};throw a}}async verifyOtp(e){var r,n;try{let s,o;"options"in e&&(s=(r=e.options)===null||r===void 0?void 0:r.redirectTo,o=(n=e.options)===null||n===void 0?void 0:n.captchaToken);const{data:c,error:a}=await li(this.fetch,"POST",`${this.url}/verify`,{headers:this.headers,body:Object.assign(Object.assign({},e),{gotrue_meta_security:{captcha_token:o}}),redirectTo:s,xform:Hy});if(a)throw a;if(!c)throw new Error("An error occurred on token verification.");const f=c.session,m=c.user;return f!=null&&f.access_token&&(await this._saveSession(f),await this._notifyAllSubscribers(e.type=="recovery"?"PASSWORD_RECOVERY":"SIGNED_IN",f)),{data:{user:m,session:f},error:null}}catch(s){if(Hs(s))return{data:{user:null,session:null},error:s};throw s}}async signInWithSSO(e){var r,n,s;try{let o=null,c=null;return this.flowType==="pkce"&&([o,c]=await Qw(this.storage,this.storageKey)),await li(this.fetch,"POST",`${this.url}/sso`,{body:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},"providerId"in e?{provider_id:e.providerId}:null),"domain"in e?{domain:e.domain}:null),{redirect_to:(n=(r=e.options)===null||r===void 0?void 0:r.redirectTo)!==null&&n!==void 0?n:void 0}),!((s=e==null?void 0:e.options)===null||s===void 0)&&s.captchaToken?{gotrue_meta_security:{captcha_token:e.options.captchaToken}}:null),{skip_http_redirect:!0,code_challenge:o,code_challenge_method:c}),headers:this.headers,xform:ZVe})}catch(o){if(Hs(o))return{data:null,error:o};throw o}}async reauthenticate(){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._reauthenticate())}async _reauthenticate(){try{return await this._useSession(async e=>{const{data:{session:r},error:n}=e;if(n)throw n;if(!r)throw new Gy;const{error:s}=await li(this.fetch,"GET",`${this.url}/reauthenticate`,{headers:this.headers,jwt:r.access_token});return{data:{user:null,session:null},error:s}})}catch(e){if(Hs(e))return{data:{user:null,session:null},error:e};throw e}}async resend(e){try{const r=`${this.url}/resend`;if("email"in e){const{email:n,type:s,options:o}=e,{error:c}=await li(this.fetch,"POST",r,{headers:this.headers,body:{email:n,type:s,gotrue_meta_security:{captcha_token:o==null?void 0:o.captchaToken}},redirectTo:o==null?void 0:o.emailRedirectTo});return{data:{user:null,session:null},error:c}}else if("phone"in e){const{phone:n,type:s,options:o}=e,{data:c,error:a}=await li(this.fetch,"POST",r,{headers:this.headers,body:{phone:n,type:s,gotrue_meta_security:{captcha_token:o==null?void 0:o.captchaToken}}});return{data:{user:null,session:null,messageId:c==null?void 0:c.message_id},error:a}}throw new aL("You must provide either an email or phone number and a type")}catch(r){if(Hs(r))return{data:{user:null,session:null},error:r};throw r}}async getSession(){return await this.initializePromise,await this._acquireLock(-1,async()=>this._useSession(async r=>r))}async _acquireLock(e,r){this._debug("#_acquireLock","begin",e);try{if(this.lockAcquired){const n=this.pendingInLock.length?this.pendingInLock[this.pendingInLock.length-1]:Promise.resolve(),s=(async()=>(await n,await r()))();return this.pendingInLock.push((async()=>{try{await s}catch{}})()),s}return await this.lock(`lock:${this.storageKey}`,e,async()=>{this._debug("#_acquireLock","lock acquired for storage key",this.storageKey);try{this.lockAcquired=!0;const n=r();for(this.pendingInLock.push((async()=>{try{await n}catch{}})()),await n;this.pendingInLock.length;){const s=[...this.pendingInLock];await Promise.all(s),this.pendingInLock.splice(0,s.length)}return await n}finally{this._debug("#_acquireLock","lock released for storage key",this.storageKey),this.lockAcquired=!1}})}finally{this._debug("#_acquireLock","end")}}async _useSession(e){this._debug("#_useSession","begin");try{const r=await this.__loadSession();return await e(r)}finally{this._debug("#_useSession","end")}}async __loadSession(){this._debug("#__loadSession()","begin"),this.lockAcquired||this._debug("#__loadSession()","used outside of an acquired lock!",new Error().stack);try{let e=null;const r=await lL(this.storage,this.storageKey);if(this._debug("#getSession()","session from storage",r),r!==null&&(this._isValidSession(r)?e=r:(this._debug("#getSession()","session from storage is not valid"),await this._removeSession())),!e)return{data:{session:null},error:null};const n=e.expires_at?e.expires_at*1e3-Date.now()(!c&&m==="user"&&(console.warn("Using the user object as returned from supabase.auth.getSession() or from some supabase.auth.onAuthStateChange() events could be insecure! This value comes directly from the storage medium (usually cookies on the server) and may not be authentic. Use supabase.auth.getUser() instead which authenticates the data by contacting the Supabase Auth server."),c=!0,this.suppressGetSessionWarning=!0),Reflect.get(f,m,y))})}return{data:{session:e},error:null}}const{session:s,error:o}=await this._callRefreshToken(e.refresh_token);return o?{data:{session:null},error:o}:{data:{session:s},error:null}}finally{this._debug("#__loadSession()","end")}}async getUser(e){return e?await this._getUser(e):(await this.initializePromise,await this._acquireLock(-1,async()=>await this._getUser()))}async _getUser(e){try{return e?await li(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:e,xform:sx}):await this._useSession(async r=>{var n,s,o;const{data:c,error:a}=r;if(a)throw a;return!(!((n=c.session)===null||n===void 0)&&n.access_token)&&!this.hasCustomAuthorizationHeader?{data:{user:null},error:new Gy}:await li(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:(o=(s=c.session)===null||s===void 0?void 0:s.access_token)!==null&&o!==void 0?o:void 0,xform:sx})})}catch(r){if(Hs(r))return TVe(r)&&(await this._removeSession(),await cL(this.storage,`${this.storageKey}-code-verifier`)),{data:{user:null},error:r};throw r}}async updateUser(e,r={}){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._updateUser(e,r))}async _updateUser(e,r={}){try{return await this._useSession(async n=>{const{data:s,error:o}=n;if(o)throw o;if(!s.session)throw new Gy;const c=s.session;let a=null,f=null;this.flowType==="pkce"&&e.email!=null&&([a,f]=await Qw(this.storage,this.storageKey));const{data:m,error:y}=await li(this.fetch,"PUT",`${this.url}/user`,{headers:this.headers,redirectTo:r==null?void 0:r.emailRedirectTo,body:Object.assign(Object.assign({},e),{code_challenge:a,code_challenge_method:f}),jwt:c.access_token,xform:sx});if(y)throw y;return c.user=m.user,await this._saveSession(c),await this._notifyAllSubscribers("USER_UPDATED",c),{data:{user:c.user},error:null}})}catch(n){if(Hs(n))return{data:{user:null},error:n};throw n}}async setSession(e){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._setSession(e))}async _setSession(e){try{if(!e.access_token||!e.refresh_token)throw new Gy;const r=Date.now()/1e3;let n=r,s=!0,o=null;const{payload:c}=Jz(e.access_token);if(c.exp&&(n=c.exp,s=n<=r),s){const{session:a,error:f}=await this._callRefreshToken(e.refresh_token);if(f)return{data:{user:null,session:null},error:f};if(!a)return{data:{user:null,session:null},error:null};o=a}else{const{data:a,error:f}=await this._getUser(e.access_token);if(f)throw f;o={access_token:e.access_token,refresh_token:e.refresh_token,user:a.user,token_type:"bearer",expires_in:n-r,expires_at:n},await this._saveSession(o),await this._notifyAllSubscribers("SIGNED_IN",o)}return{data:{user:o.user,session:o},error:null}}catch(r){if(Hs(r))return{data:{session:null,user:null},error:r};throw r}}async refreshSession(e){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._refreshSession(e))}async _refreshSession(e){try{return await this._useSession(async r=>{var n;if(!e){const{data:c,error:a}=r;if(a)throw a;e=(n=c.session)!==null&&n!==void 0?n:void 0}if(!(e!=null&&e.refresh_token))throw new Gy;const{session:s,error:o}=await this._callRefreshToken(e.refresh_token);return o?{data:{user:null,session:null},error:o}:s?{data:{user:s.user,session:s},error:null}:{data:{user:null,session:null},error:null}})}catch(r){if(Hs(r))return{data:{user:null,session:null},error:r};throw r}}async _getSessionFromURL(e,r){try{if(!_m())throw new oL("No browser detected.");if(e.error||e.error_description||e.error_code)throw new oL(e.error_description||"Error in URL with unspecified error_description",{error:e.error||"unspecified_error",code:e.error_code||"unspecified_code"});switch(r){case"implicit":if(this.flowType==="pkce")throw new Wne("Not a valid PKCE flow url.");break;case"pkce":if(this.flowType==="implicit")throw new oL("Not a valid implicit grant flow url.");break;default:}if(r==="pkce"){if(this._debug("#_initialize()","begin","is PKCE flow",!0),!e.code)throw new Wne("No code detected.");const{data:D,error:B}=await this._exchangeCodeForSession(e.code);if(B)throw B;const U=new URL(window.location.href);return U.searchParams.delete("code"),window.history.replaceState(window.history.state,"",U.toString()),{data:{session:D.session,redirectType:null},error:null}}const{provider_token:n,provider_refresh_token:s,access_token:o,refresh_token:c,expires_in:a,expires_at:f,token_type:m}=e;if(!o||!a||!c||!m)throw new oL("No session defined in URL");const y=Math.round(Date.now()/1e3),_=parseInt(a);let w=y+_;f&&(w=parseInt(f));const E=w-y;E*1e3<=E1&&console.warn(`@supabase/gotrue-js: Session as retrieved from URL expires in ${E}s, should have been closer to ${_}s`);const A=w-_;y-A>=120?console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued over 120s ago, URL could be stale",A,w,y):y-A<0&&console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued in the future? Check the device clock for skew",A,w,y);const{data:C,error:I}=await this._getUser(o);if(I)throw I;const M={provider_token:n,provider_refresh_token:s,access_token:o,expires_in:_,expires_at:w,refresh_token:c,token_type:m,user:C.user};return window.location.hash="",this._debug("#_getSessionFromURL()","clearing window.location.hash"),{data:{session:M,redirectType:e.type},error:null}}catch(n){if(Hs(n))return{data:{session:null,redirectType:null},error:n};throw n}}_isImplicitGrantCallback(e){return!!(e.access_token||e.error_description)}async _isPKCECallback(e){const r=await lL(this.storage,`${this.storageKey}-code-verifier`);return!!(e.code&&r)}async signOut(e={scope:"global"}){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._signOut(e))}async _signOut({scope:e}={scope:"global"}){return await this._useSession(async r=>{var n;const{data:s,error:o}=r;if(o)return{error:o};const c=(n=s.session)===null||n===void 0?void 0:n.access_token;if(c){const{error:a}=await this.admin.signOut(c,e);if(a&&!(SVe(a)&&(a.status===404||a.status===401||a.status===403)))return{error:a}}return e!=="others"&&(await this._removeSession(),await cL(this.storage,`${this.storageKey}-code-verifier`)),{error:null}})}onAuthStateChange(e){const r=RVe(),n={id:r,callback:e,unsubscribe:()=>{this._debug("#unsubscribe()","state change callback with id removed",r),this.stateChangeEmitters.delete(r)}};return this._debug("#onAuthStateChange()","registered callback with id",r),this.stateChangeEmitters.set(r,n),(async()=>(await this.initializePromise,await this._acquireLock(-1,async()=>{this._emitInitialSession(r)})))(),{data:{subscription:n}}}async _emitInitialSession(e){return await this._useSession(async r=>{var n,s;try{const{data:{session:o},error:c}=r;if(c)throw c;await((n=this.stateChangeEmitters.get(e))===null||n===void 0?void 0:n.callback("INITIAL_SESSION",o)),this._debug("INITIAL_SESSION","callback id",e,"session",o)}catch(o){await((s=this.stateChangeEmitters.get(e))===null||s===void 0?void 0:s.callback("INITIAL_SESSION",null)),this._debug("INITIAL_SESSION","callback id",e,"error",o),console.error(o)}})}async resetPasswordForEmail(e,r={}){let n=null,s=null;this.flowType==="pkce"&&([n,s]=await Qw(this.storage,this.storageKey,!0));try{return await li(this.fetch,"POST",`${this.url}/recover`,{body:{email:e,code_challenge:n,code_challenge_method:s,gotrue_meta_security:{captcha_token:r.captchaToken}},headers:this.headers,redirectTo:r.redirectTo})}catch(o){if(Hs(o))return{data:null,error:o};throw o}}async getUserIdentities(){var e;try{const{data:r,error:n}=await this.getUser();if(n)throw n;return{data:{identities:(e=r.user.identities)!==null&&e!==void 0?e:[]},error:null}}catch(r){if(Hs(r))return{data:null,error:r};throw r}}async linkIdentity(e){var r;try{const{data:n,error:s}=await this._useSession(async o=>{var c,a,f,m,y;const{data:_,error:w}=o;if(w)throw w;const E=await this._getUrlForProvider(`${this.url}/user/identities/authorize`,e.provider,{redirectTo:(c=e.options)===null||c===void 0?void 0:c.redirectTo,scopes:(a=e.options)===null||a===void 0?void 0:a.scopes,queryParams:(f=e.options)===null||f===void 0?void 0:f.queryParams,skipBrowserRedirect:!0});return await li(this.fetch,"GET",E,{headers:this.headers,jwt:(y=(m=_.session)===null||m===void 0?void 0:m.access_token)!==null&&y!==void 0?y:void 0})});if(s)throw s;return _m()&&!(!((r=e.options)===null||r===void 0)&&r.skipBrowserRedirect)&&window.location.assign(n==null?void 0:n.url),{data:{provider:e.provider,url:n==null?void 0:n.url},error:null}}catch(n){if(Hs(n))return{data:{provider:e.provider,url:null},error:n};throw n}}async unlinkIdentity(e){try{return await this._useSession(async r=>{var n,s;const{data:o,error:c}=r;if(c)throw c;return await li(this.fetch,"DELETE",`${this.url}/user/identities/${e.identity_id}`,{headers:this.headers,jwt:(s=(n=o.session)===null||n===void 0?void 0:n.access_token)!==null&&s!==void 0?s:void 0})})}catch(r){if(Hs(r))return{data:null,error:r};throw r}}async _refreshAccessToken(e){const r=`#_refreshAccessToken(${e.substring(0,5)}...)`;this._debug(r,"begin");try{const n=Date.now();return await OVe(async s=>(s>0&&await DVe(200*Math.pow(2,s-1)),this._debug(r,"refreshing attempt",s),await li(this.fetch,"POST",`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:e},headers:this.headers,xform:Hy})),(s,o)=>{const c=200*Math.pow(2,s);return o&&Qz(o)&&Date.now()+c-n{try{await a.callback(e,r)}catch(f){o.push(f)}});if(await Promise.all(c),o.length>0){for(let a=0;athis._autoRefreshTokenTick(),E1);this.autoRefreshTicker=e,e&&typeof e=="object"&&typeof e.unref=="function"?e.unref():typeof Deno<"u"&&typeof Deno.unrefTimer=="function"&&Deno.unrefTimer(e),setTimeout(async()=>{await this.initializePromise,await this._autoRefreshTokenTick()},0)}async _stopAutoRefresh(){this._debug("#_stopAutoRefresh()");const e=this.autoRefreshTicker;this.autoRefreshTicker=null,e&&clearInterval(e)}async startAutoRefresh(){this._removeVisibilityChangedCallback(),await this._startAutoRefresh()}async stopAutoRefresh(){this._removeVisibilityChangedCallback(),await this._stopAutoRefresh()}async _autoRefreshTokenTick(){this._debug("#_autoRefreshTokenTick()","begin");try{await this._acquireLock(0,async()=>{try{const e=Date.now();try{return await this._useSession(async r=>{const{data:{session:n}}=r;if(!n||!n.refresh_token||!n.expires_at){this._debug("#_autoRefreshTokenTick()","no session");return}const s=Math.floor((n.expires_at*1e3-e)/E1);this._debug("#_autoRefreshTokenTick()",`access token expires in ${s} ticks, a tick lasts ${E1}ms, refresh threshold is ${sq} ticks`),s<=sq&&await this._callRefreshToken(n.refresh_token)})}catch(r){console.error("Auto refresh tick failed with error. This is likely a transient error.",r)}}finally{this._debug("#_autoRefreshTokenTick()","end")}})}catch(e){if(e.isAcquireTimeout||e instanceof G0e)this._debug("auto refresh token tick lock not available");else throw e}}async _handleVisibilityChange(){if(this._debug("#_handleVisibilityChange()"),!_m()||!(window!=null&&window.addEventListener))return this.autoRefreshToken&&this.startAutoRefresh(),!1;try{this.visibilityChangedCallback=async()=>await this._onVisibilityChanged(!1),window==null||window.addEventListener("visibilitychange",this.visibilityChangedCallback),await this._onVisibilityChanged(!0)}catch(e){console.error("_handleVisibilityChange",e)}}async _onVisibilityChanged(e){const r=`#_onVisibilityChanged(${e})`;this._debug(r,"visibilityState",document.visibilityState),document.visibilityState==="visible"?(this.autoRefreshToken&&this._startAutoRefresh(),e||(await this.initializePromise,await this._acquireLock(-1,async()=>{if(document.visibilityState!=="visible"){this._debug(r,"acquired the lock to recover the session, but the browser visibilityState is no longer visible, aborting");return}await this._recoverAndRefresh()}))):document.visibilityState==="hidden"&&this.autoRefreshToken&&this._stopAutoRefresh()}async _getUrlForProvider(e,r,n){const s=[`provider=${encodeURIComponent(r)}`];if(n!=null&&n.redirectTo&&s.push(`redirect_to=${encodeURIComponent(n.redirectTo)}`),n!=null&&n.scopes&&s.push(`scopes=${encodeURIComponent(n.scopes)}`),this.flowType==="pkce"){const[o,c]=await Qw(this.storage,this.storageKey),a=new URLSearchParams({code_challenge:`${encodeURIComponent(o)}`,code_challenge_method:`${encodeURIComponent(c)}`});s.push(a.toString())}if(n!=null&&n.queryParams){const o=new URLSearchParams(n.queryParams);s.push(o.toString())}return n!=null&&n.skipBrowserRedirect&&s.push(`skip_http_redirect=${n.skipBrowserRedirect}`),`${e}?${s.join("&")}`}async _unenroll(e){try{return await this._useSession(async r=>{var n;const{data:s,error:o}=r;return o?{data:null,error:o}:await li(this.fetch,"DELETE",`${this.url}/factors/${e.factorId}`,{headers:this.headers,jwt:(n=s==null?void 0:s.session)===null||n===void 0?void 0:n.access_token})})}catch(r){if(Hs(r))return{data:null,error:r};throw r}}async _enroll(e){try{return await this._useSession(async r=>{var n,s;const{data:o,error:c}=r;if(c)return{data:null,error:c};const a=Object.assign({friendly_name:e.friendlyName,factor_type:e.factorType},e.factorType==="phone"?{phone:e.phone}:{issuer:e.issuer}),{data:f,error:m}=await li(this.fetch,"POST",`${this.url}/factors`,{body:a,headers:this.headers,jwt:(n=o==null?void 0:o.session)===null||n===void 0?void 0:n.access_token});return m?{data:null,error:m}:(e.factorType==="totp"&&(!((s=f==null?void 0:f.totp)===null||s===void 0)&&s.qr_code)&&(f.totp.qr_code=`data:image/svg+xml;utf-8,${f.totp.qr_code}`),{data:f,error:null})})}catch(r){if(Hs(r))return{data:null,error:r};throw r}}async _verify(e){return this._acquireLock(-1,async()=>{try{return await this._useSession(async r=>{var n;const{data:s,error:o}=r;if(o)return{data:null,error:o};const{data:c,error:a}=await li(this.fetch,"POST",`${this.url}/factors/${e.factorId}/verify`,{body:{code:e.code,challenge_id:e.challengeId},headers:this.headers,jwt:(n=s==null?void 0:s.session)===null||n===void 0?void 0:n.access_token});return a?{data:null,error:a}:(await this._saveSession(Object.assign({expires_at:Math.round(Date.now()/1e3)+c.expires_in},c)),await this._notifyAllSubscribers("MFA_CHALLENGE_VERIFIED",c),{data:c,error:a})})}catch(r){if(Hs(r))return{data:null,error:r};throw r}})}async _challenge(e){return this._acquireLock(-1,async()=>{try{return await this._useSession(async r=>{var n;const{data:s,error:o}=r;return o?{data:null,error:o}:await li(this.fetch,"POST",`${this.url}/factors/${e.factorId}/challenge`,{body:{channel:e.channel},headers:this.headers,jwt:(n=s==null?void 0:s.session)===null||n===void 0?void 0:n.access_token})})}catch(r){if(Hs(r))return{data:null,error:r};throw r}})}async _challengeAndVerify(e){const{data:r,error:n}=await this._challenge({factorId:e.factorId});return n?{data:null,error:n}:await this._verify({factorId:e.factorId,challengeId:r.id,code:e.code})}async _listFactors(){const{data:{user:e},error:r}=await this.getUser();if(r)return{data:null,error:r};const n=(e==null?void 0:e.factors)||[],s=n.filter(c=>c.factor_type==="totp"&&c.status==="verified"),o=n.filter(c=>c.factor_type==="phone"&&c.status==="verified");return{data:{all:n,totp:s,phone:o},error:null}}async _getAuthenticatorAssuranceLevel(){return this._acquireLock(-1,async()=>await this._useSession(async e=>{var r,n;const{data:{session:s},error:o}=e;if(o)return{data:null,error:o};if(!s)return{data:{currentLevel:null,nextLevel:null,currentAuthenticationMethods:[]},error:null};const{payload:c}=Jz(s.access_token);let a=null;c.aal&&(a=c.aal);let f=a;((n=(r=s.user.factors)===null||r===void 0?void 0:r.filter(_=>_.status==="verified"))!==null&&n!==void 0?n:[]).length>0&&(f="aal2");const y=c.amr||[];return{data:{currentLevel:a,nextLevel:f,currentAuthenticationMethods:y},error:null}}))}async fetchJwk(e,r={keys:[]}){let n=r.keys.find(c=>c.kid===e);if(n||(n=this.jwks.keys.find(c=>c.kid===e),n&&this.jwks_cached_at+bVe>Date.now()))return n;const{data:s,error:o}=await li(this.fetch,"GET",`${this.url}/.well-known/jwks.json`,{headers:this.headers});if(o)throw o;if(!s.keys||s.keys.length===0)throw new nA("JWKS is empty");if(this.jwks=s,this.jwks_cached_at=Date.now(),n=s.keys.find(c=>c.kid===e),!n)throw new nA("No matching signing key found in JWKS");return n}async getClaims(e,r={keys:[]}){try{let n=e;if(!n){const{data:E,error:A}=await this.getSession();if(A||!E.session)return{data:null,error:A};n=E.session.access_token}const{header:s,payload:o,signature:c,raw:{header:a,payload:f}}=Jz(n);if(qVe(o.exp),!s.kid||s.alg==="HS256"||!("crypto"in globalThis&&"subtle"in globalThis.crypto)){const{error:E}=await this.getUser(n);if(E)throw E;return{data:{claims:o,header:s,signature:c},error:null}}const m=GVe(s.alg),y=await this.fetchJwk(s.kid,r),_=await crypto.subtle.importKey("jwk",y,m,!0,["verify"]);if(!await crypto.subtle.verify(m,_,c,IVe(`${a}.${f}`)))throw new nA("Invalid JWT signature");return{data:{claims:o,header:s,signature:c},error:null}}catch(n){if(Hs(n))return{data:null,error:n};throw n}}}QA.nextInstanceID=0;const o8e=QA;class l8e extends o8e{constructor(e){super(e)}}var c8e=function(t,e,r,n){function s(o){return o instanceof r?o:new r(function(c){c(o)})}return new(r||(r=Promise))(function(o,c){function a(y){try{m(n.next(y))}catch(_){c(_)}}function f(y){try{m(n.throw(y))}catch(_){c(_)}}function m(y){y.done?o(y.value):s(y.value).then(a,f)}m((n=n.apply(t,e||[])).next())})};class u8e{constructor(e,r,n){var s,o,c;if(this.supabaseUrl=e,this.supabaseKey=r,!e)throw new Error("supabaseUrl is required.");if(!r)throw new Error("supabaseKey is required.");const a=pVe(e),f=new URL(a);this.realtimeUrl=new URL("realtime/v1",f),this.realtimeUrl.protocol=this.realtimeUrl.protocol.replace("http","ws"),this.authUrl=new URL("auth/v1",f),this.storageUrl=new URL("storage/v1",f),this.functionsUrl=new URL("functions/v1",f);const m=`sb-${f.hostname.split(".")[0]}-auth-token`,y={db:oVe,realtime:cVe,auth:Object.assign(Object.assign({},lVe),{storageKey:m}),global:aVe},_=gVe(n??{},y);this.storageKey=(s=_.auth.storageKey)!==null&&s!==void 0?s:"",this.headers=(o=_.global.headers)!==null&&o!==void 0?o:{},_.accessToken?(this.accessToken=_.accessToken,this.auth=new Proxy({},{get:(w,E)=>{throw new Error(`@supabase/supabase-js: Supabase Client is configured with the accessToken option, accessing supabase.auth.${String(E)} is not possible`)}})):this.auth=this._initSupabaseAuthClient((c=_.auth)!==null&&c!==void 0?c:{},this.headers,_.global.fetch),this.fetch=fVe(r,this._getAccessToken.bind(this),_.global.fetch),this.realtime=this._initRealtimeClient(Object.assign({headers:this.headers,accessToken:this._getAccessToken.bind(this)},_.realtime)),this.rest=new NUe(new URL("rest/v1",f).href,{headers:this.headers,schema:_.db.schema,fetch:this.fetch}),_.accessToken||this._listenForAuthEvents()}get functions(){return new iUe(this.functionsUrl.href,{headers:this.headers,customFetch:this.fetch})}get storage(){return new nVe(this.storageUrl.href,this.headers,this.fetch)}from(e){return this.rest.from(e)}schema(e){return this.rest.schema(e)}rpc(e,r={},n={}){return this.rest.rpc(e,r,n)}channel(e,r={config:{}}){return this.realtime.channel(e,r)}getChannels(){return this.realtime.getChannels()}removeChannel(e){return this.realtime.removeChannel(e)}removeAllChannels(){return this.realtime.removeAllChannels()}_getAccessToken(){var e,r;return c8e(this,void 0,void 0,function*(){if(this.accessToken)return yield this.accessToken();const{data:n}=yield this.auth.getSession();return(r=(e=n.session)===null||e===void 0?void 0:e.access_token)!==null&&r!==void 0?r:null})}_initSupabaseAuthClient({autoRefreshToken:e,persistSession:r,detectSessionInUrl:n,storage:s,storageKey:o,flowType:c,lock:a,debug:f},m,y){const _={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new l8e({url:this.authUrl.href,headers:Object.assign(Object.assign({},_),m),storageKey:o,autoRefreshToken:e,persistSession:r,detectSessionInUrl:n,storage:s,flowType:c,lock:a,debug:f,fetch:y,hasCustomAuthorizationHeader:"Authorization"in this.headers})}_initRealtimeClient(e){return new VUe(this.realtimeUrl.href,Object.assign(Object.assign({},e),{params:Object.assign({apikey:this.supabaseKey},e==null?void 0:e.params)}))}_listenForAuthEvents(){return this.auth.onAuthStateChange((r,n)=>{this._handleTokenChanged(r,"CLIENT",n==null?void 0:n.access_token)})}_handleTokenChanged(e,r,n){(e==="TOKEN_REFRESHED"||e==="SIGNED_IN")&&this.changedAccessToken!==n?this.changedAccessToken=n:e==="SIGNED_OUT"&&(this.realtime.setAuth(),r=="STORAGE"&&this.auth.signOut(),this.changedAccessToken=void 0)}}const d8e=(t,e,r)=>new u8e(t,e,r),h8e="lovable-preview-auth:result";function f8e(t,e){return typeof t!="object"||t===null||!("type"in t)||t.type!==h8e||!("requestId"in t)||t.requestId!==e?null:{ok:"ok"in t&&!!t.ok,value:"value"in t&&typeof t.value=="string"?t.value:null}}function m8e(){try{const t=localStorage;return t.getItem("__lovable_storage_probe__"),t}catch{return}}function p8e(){var D,B,U;if(typeof window>"u")return;const t=location.hostname,r=["lovableproject.com","lovableproject-dev.com","lovable.app","gpt-eng.com","gptengineer.run"].some(q=>t===q||t.endsWith("."+q)),n="[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}",s=r?((D=new RegExp("^(?:id-preview(?:-[a-z0-9]+)?|project)--("+n+")(?:-dev)?(?=\\.|$)","i").exec(t))==null?void 0:D[1])??((B=new RegExp("^live--("+n+")(?:-thr_[a-z0-9]+)?(?=\\.|$)","i").exec(t))==null?void 0:B[1])??((U=new RegExp("^("+n+")(?=[.-])","i").exec(t))==null?void 0:U[1]):void 0,o=window.parent;if(!s||!(o!==null&&o!==window))return m8e();const a=t.endsWith(".lovableproject-dev.com")||t.endsWith(".gpt-eng.com"),f=a?/^https:\/\/([a-z0-9-]+\.)*(lovable\.dev|gptengineer\.app)$|^http:\/\/localhost:3000$/:/^https:\/\/([a-z0-9-]+\.)*(lovable\.dev|gptengineer\.app)$/,m=location.ancestorOrigins,y=(m==null?void 0:m[0])??(document.referrer?new URL(document.referrer).origin:""),_=y&&f.test(y)?[y]:a?["https://lovable.dev","http://localhost:3000"]:["https://lovable.dev"],w=2e3,E=()=>Math.random().toString(36).slice(2)+Date.now().toString(36),A=(q,H,K)=>new Promise(Q=>{const J=E();let ee=!1;const oe=Le=>{ee||(ee=!0,clearTimeout(ye),window.removeEventListener("message",de),Q(Le))},de=Le=>{if(!_.includes(Le.origin))return;const Se=f8e(Le.data,J);Se&&oe(Se)};window.addEventListener("message",de);const ye=setTimeout(()=>{oe(null)},w),Ee={type:q,requestId:J,projectId:s,key:H};K!==void 0&&(Ee.value=K);for(const Le of _)window.parent.postMessage(Ee,Le)});let C=!0;const I=250,M=q=>{try{return localStorage.getItem(q)}catch{return}};return{getItem:async q=>{const H=M(q);let K=await A("lovable-preview-auth:get",q,H??void 0);if(!K&&C&&(await new Promise(Q=>setTimeout(Q,I)),K=await A("lovable-preview-auth:get",q,H??void 0)),C=!1,K!=null&&K.ok&&K.value!==null){if(K.value===""){if(H!==void 0&&M(q)===H)try{localStorage.removeItem(q)}catch{}return null}if(H===null&&M(q)===null)try{localStorage.setItem(q,K.value)}catch{}return K.value}return M(q)??null},setItem:(q,H)=>{try{localStorage.setItem(q,H)}catch{}return A("lovable-preview-auth:set",q,H).then(K=>{if(K!=null&&K.ok&&K.value!==null&&M(q)===H)try{K.value===""?localStorage.removeItem(q):localStorage.setItem(q,K.value)}catch{}})},removeItem:q=>{const H=M(q);try{localStorage.removeItem(q)}catch{}return A("lovable-preview-auth:remove",q,H??void 0).then(()=>{})}}}const g8e="https://relzejiswnotikjgvjhz.supabase.co",y8e="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InJlbHplamlzd25vdGlramd2amh6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjE5NTAzNDQsImV4cCI6MjA3NzUyNjM0NH0.dzIkIr_oFSbFE3oWS0ktIr83iKHHkZxt40Gc7SpC_mM",Ce=d8e(g8e,y8e,{auth:{storage:p8e(),persistSession:!0,autoRefreshToken:!0}}),PQt=Object.freeze(Object.defineProperty({__proto__:null,supabase:Ce},Symbol.toStringTag,{value:"Module"})),H0e=N.createContext(void 0),x8e=({children:t})=>{const[e,r]=N.useState(null),[n,s]=N.useState(null),[o,c]=N.useState(!0),[a,f]=N.useState(!0),[m,y]=N.useState(!1),[_,w]=N.useState(!1),[E,A]=N.useState(!1),[C,I]=N.useState(null),[M,D]=N.useState([]),[B,U]=N.useState(null),q=N.useRef(null),H=N.useRef(!1),K=N.useRef(!1),Q=ra(),J=N.useRef(null),ee=Se=>{U(be=>{const me=typeof Se=="function"?Se(be):Se,ke=J.current;if(ke&&me)try{localStorage.setItem(`levelup:selectedBrokerage:${ke}`,me)}catch{}return me})},oe=()=>{y(!1),w(!1),A(!1),I(null),D([]),ee(null),q.current=null,H.current=!1},de=async Se=>{if(J.current=Se,H.current&&q.current===Se||K.current)return;K.current=!0,f(!0);const be=window.setTimeout(()=>{console.warn("Role check timeout reached — unblocking UI."),K.current=!1,f(!1)},8e3);try{console.log("Checking roles via RPC for user:",Se);const[{data:me,error:ke},{data:Pe,error:je},{data:xe,error:Ue}]=await Promise.all([Ce.rpc("has_role",{_user_id:Se,_role:"admin"}),Ce.rpc("has_role",{_user_id:Se,_role:"brokerage_manager"}),Ce.rpc("has_role",{_user_id:Se,_role:"coach"})]);if(ke||je)console.error("Role RPC errors:",{isAdminError:ke,isBrokerError:je,isCoachError:Ue}),y(!1),w(!1),A(!1);else{const wt=!!me,yt=!!Pe,gt=!!xe;console.log("RPC roles result:",{adminValue:wt,brokerValue:yt,coachValue:gt}),y(wt),w(yt),A(gt)}q.current=Se,H.current=!0,window.clearTimeout(be),f(!1);const{data:Ze,error:lt}=await Ce.from("profiles").select("brokerage_id, is_paused, paused_reason").eq("id",Se).single();if(!lt&&(Ze!=null&&Ze.is_paused)){const wt=Ze.paused_reason;try{sessionStorage.setItem("accountPausedReason",wt||"")}catch{}await Ce.auth.signOut(),oe(),Q("/auth?paused=1",{replace:!0});return}if(I(!lt&&Ze?Ze.brokerage_id:null),Pe){console.log("Fetching managed brokerages for user:",Se);const{data:wt,error:yt}=await Ce.from("brokerage_manager_assignments").select("brokerage_id").eq("user_id",Se);if(console.log("Managed brokerage assignments result:",{assignments:wt,assignmentsError:yt}),yt||!wt){console.error("Error fetching managed brokerage assignments:",yt),D([]);return}const gt=Array.from(new Set(wt.map(xt=>xt.brokerage_id).filter(Boolean)));if(gt.length===0){D([]);return}const{data:ft,error:kt}=await Ce.from("brokerages").select("id, name").in("id",gt);if(console.log("Managed brokerages details result:",{brokeragesData:ft,brokeragesError:kt}),kt||!ft){console.error("Error fetching managed brokerages details:",kt),D([]);return}const Vt=ft.map(xt=>({id:xt.id,name:xt.name})).sort((xt,or)=>gt.indexOf(xt.id)-gt.indexOf(or.id));if(console.log("Parsed managed brokerages:",Vt),D(Vt),Vt.length>0){let xt=null;try{xt=localStorage.getItem(`levelup:selectedBrokerage:${Se}`)}catch{}ee(or=>{const Sr=rn=>!!rn&&Vt.some(Rr=>Rr.id===rn);return Sr(or)?or:Sr(xt)?xt:Vt[0].id})}}else console.log("User is not a brokerage manager, skipping managed brokerages fetch"),D([]);q.current=Se,H.current=!0}catch(me){console.error("Unexpected error in checkRoles:",me),oe()}finally{window.clearTimeout(be),K.current=!1,f(!1)}};N.useEffect(()=>{let Se=!0,be=!1;const me=()=>{!Se||be||(be=!0,c(!1))},{data:{subscription:ke}}=Ce.auth.onAuthStateChange((je,xe)=>{console.log("Auth event:",je),Se&&(s(xe),r(Ue=>{const Ze=(xe==null?void 0:xe.user)??null;return Ue&&Ze&&Ue.id===Ze.id?Ue:Ze}),me(),je==="PASSWORD_RECOVERY"&&(console.log("Password recovery detected, redirecting to profile"),setTimeout(()=>{Q("/profile?reset=true")},100)),xe!=null&&xe.user?(!H.current||q.current!==xe.user.id)&&setTimeout(()=>{de(xe.user.id)},0):(oe(),f(!1)))}),Pe=window.setTimeout(()=>{console.warn("Auth initialization timeout reached. Continuing without blocking UI."),me()},8e3);return()=>{Se=!1,window.clearTimeout(Pe),ke.unsubscribe()}},[]);const ye=async(Se,be)=>{var je;const me=(Se||"").trim().toLowerCase(),{data:ke,error:Pe}=await Ce.auth.signInWithPassword({email:me,password:be});if(Pe)throw $t.error(/invalid login credentials/i.test(Pe.message)?`That email and password don't match an account. Check the email address, or use "Forgot password" to set a new password.`:Pe.message),Pe;if((je=ke.user)!=null&&je.id){const{data:xe}=await Ce.from("profiles").select("is_paused, paused_reason").eq("id",ke.user.id).maybeSingle();if(xe!=null&&xe.is_paused){const Ue=xe.paused_reason||"";try{sessionStorage.setItem("accountPausedReason",Ue)}catch{}await Ce.auth.signOut(),oe(),r(null),s(null);const Ze=new Error(Ue?`Your account is paused. ${Ue}`:"Your account is paused. Please contact LevelUp support to reactivate it.");throw Ze.name="AccountPaused",$t.error(Ze.message),Ze}}$t.success("Welcome back!")},Ee=async(Se,be,me)=>{var Ue;const ke="https://dashboard.relevelup.com/dashboard",Pe=localStorage.getItem("levelup_referral_code")||null,{data:je,error:xe}=await Ce.auth.signUp({email:Se,password:be,options:{emailRedirectTo:ke,data:{name:me,referred_by_code:Pe}}});if(xe)throw $t.error(xe.message),xe;if(Pe&&((Ue=je.user)!=null&&Ue.id))try{await Ce.from("profiles").update({referred_by_code:Pe}).eq("id",je.user.id),localStorage.removeItem("levelup_referral_code")}catch(Ze){console.warn("Failed to attach referral code to profile",Ze)}$t.success("Account created! Welcome to LevelUp."),Q("/dashboard")},Le=async()=>{try{const{data:{session:Se}}=await Ce.auth.getSession();if(Se){const{error:be}=await Ce.auth.signOut();be?be.message==="Auth session missing!"?console.warn("Sign out warning (ignored):",be.message):(console.error("Sign out error:",be),$t.error(be.message)):$t.success("Signed out successfully")}else console.log("No active session found, redirecting to auth");r(null),s(null),y(!1),w(!1),I(null),D([]),ee(null),Q("/auth")}catch(Se){console.error("Unexpected sign out error:",Se),Q("/auth")}};return i.jsx(H0e.Provider,{value:{user:e,session:n,loading:o,rolesLoading:a,signIn:ye,signUp:Ee,signOut:Le,isAdmin:m,isBrokerageManager:_,isCoach:E,brokerageId:C,managedBrokerages:M,selectedBrokerageId:B,setSelectedBrokerageId:ee},children:t})},Zn=()=>{const t=N.useContext(H0e);if(t===void 0)throw new Error("useAuth must be used within an AuthProvider");return t},W0e=N.createContext({onlineUsers:[],totalOnline:0}),_8e=3*60*1e3,v8e=45*1e3,b8e=30*1e3,w8e=({children:t})=>{const{user:e,brokerageId:r,isAdmin:n}=Zn(),[s,o]=N.useState([]),c=N.useRef(new Date().toISOString()),a=N.useCallback(async()=>{e&&await Ce.from("user_presence").upsert({user_id:e.id,last_seen_at:new Date().toISOString(),online_since:c.current,current_path:window.location.pathname},{onConflict:"user_id"})},[e==null?void 0:e.id]),f=N.useCallback(async()=>{if(!e)return;const y=new Date(Date.now()-_8e).toISOString(),{data:_}=await Ce.from("user_presence").select("user_id, last_seen_at, online_since").gte("last_seen_at",y).order("last_seen_at",{ascending:!1}).limit(200);if(!(_!=null&&_.length)){o([]);return}const w=_.map(C=>C.user_id),{data:E}=await Ce.from("profiles").select("id, name, email, avatar_url, brokerage_id").in("id",w),A=new Map((E||[]).map(C=>[C.id,C]));o(_.map(C=>{var M;const I=A.get(C.user_id);return{id:C.user_id,name:(I==null?void 0:I.name)||((M=I==null?void 0:I.email)==null?void 0:M.split("@")[0])||"Member",avatarUrl:(I==null?void 0:I.avatar_url)||void 0,brokerageId:(I==null?void 0:I.brokerage_id)||void 0,onlineSince:C.online_since||C.last_seen_at}}))},[e==null?void 0:e.id]);N.useEffect(()=>{if(!e){o([]);return}c.current=new Date().toISOString();let y=!1;const _=async()=>{y||(await a(),await f())};_();const w=window.setInterval(()=>{a()},v8e),E=window.setInterval(()=>{f()},b8e),A=()=>{document.visibilityState==="visible"&&_()};return document.addEventListener("visibilitychange",A),()=>{y=!0,window.clearInterval(w),window.clearInterval(E),document.removeEventListener("visibilitychange",A)}},[e==null?void 0:e.id,a,f]);const m=s.filter(y=>!!(y.id===(e==null?void 0:e.id)||n||r&&y.brokerageId===r||!r&&!y.brokerageId));return i.jsx(W0e.Provider,{value:{onlineUsers:m,totalOnline:m.length},children:t})},RQt=()=>N.useContext(W0e),K0e=N.createContext(void 0),R_="levelup_admin_session",My="levelup_impersonation",e6="levelup_impersonation_return",S8e=({children:t})=>{const[e,r]=N.useState(!1),[n,s]=N.useState(null),[o,c]=N.useState(!1);N.useEffect(()=>{const m=sessionStorage.getItem(My);if(m)try{const y=JSON.parse(m);r(!0),s(y)}catch{sessionStorage.removeItem(My)}},[]);const a=async(m,y)=>{c(!0);try{const{data:{session:_}}=await Ce.auth.getSession();if(!_)return $t.error("No active session found"),!1;const w={access_token:_.access_token,refresh_token:_.refresh_token};sessionStorage.setItem(R_,JSON.stringify(w)),y&&sessionStorage.setItem(e6,y);const E=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/impersonate-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${_.access_token}`},body:JSON.stringify({targetUserId:m})}),A=await E.json();if(!E.ok)throw new Error(A.error||"Failed to impersonate user");const C={id:A.targetUser.id,name:A.targetUser.name,email:A.targetUser.email};if(sessionStorage.setItem(My,JSON.stringify(C)),A.method==="session"){const{error:I}=await Ce.auth.setSession({access_token:A.access_token,refresh_token:A.refresh_token});if(I)throw console.error("Set session error:",I),sessionStorage.removeItem(R_),sessionStorage.removeItem(My),new Error("Failed to establish impersonation session")}else{const I=A.type||"recovery",{error:M}=await Ce.auth.verifyOtp({token_hash:A.token_hash,type:I});if(M)throw console.error("Verify OTP error:",M),sessionStorage.removeItem(R_),sessionStorage.removeItem(My),new Error("Failed to establish impersonation session")}return r(!0),s(C),$t.success(`Now viewing as ${C.name}`),window.location.href="/dashboard",!0}catch(_){return console.error("Impersonation error:",_),$t.error(_.message||"Failed to impersonate user"),sessionStorage.removeItem(R_),sessionStorage.removeItem(My),!1}finally{c(!1)}},f=async()=>{c(!0);try{const m=sessionStorage.getItem(R_);if(!m){await Ce.auth.signOut(),window.location.href="/auth";return}const y=JSON.parse(m);await Ce.auth.signOut();const{error:_}=await Ce.auth.setSession({access_token:y.access_token,refresh_token:y.refresh_token});if(sessionStorage.removeItem(R_),sessionStorage.removeItem(My),_){console.error("Failed to restore admin session:",_),$t.error("Admin session expired, please sign in again"),window.location.href="/auth";return}r(!1),s(null),$t.success("Returned to your account");const w=sessionStorage.getItem(e6)||"/admin/members";sessionStorage.removeItem(e6),window.location.href=w}catch(m){console.error("Stop impersonation error:",m),$t.error("Failed to restore admin session"),sessionStorage.removeItem(R_),sessionStorage.removeItem(My),window.location.href="/auth"}finally{c(!1)}};return i.jsx(K0e.Provider,{value:{isImpersonating:e,impersonatedUser:n,startImpersonation:a,stopImpersonation:f,isLoading:o},children:t})},Y0e=()=>{const t=N.useContext(K0e);if(t===void 0)throw new Error("useImpersonation must be used within an ImpersonationProvider");return t},T8e=()=>{const{isImpersonating:t,impersonatedUser:e,stopImpersonation:r,isLoading:n}=Y0e();return!t||!e?null:i.jsx("div",{className:"fixed top-0 left-0 right-0 z-[100] bg-amber-500 text-amber-950 px-4 py-2 shadow-lg",children:i.jsxs("div",{className:"container mx-auto flex items-center justify-between gap-4",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(VT,{className:"h-5 w-5 flex-shrink-0"}),i.jsxs("span",{className:"font-medium text-sm md:text-base",children:[i.jsx("span",{className:"hidden sm:inline",children:"You are viewing as "}),i.jsx("strong",{children:e.name}),i.jsxs("span",{className:"hidden md:inline text-amber-800",children:[" (",e.email,")"]})]})]}),i.jsx(Lt,{size:"sm",variant:"secondary",onClick:r,disabled:n,className:"bg-amber-100 hover:bg-amber-200 text-amber-950 border-0",children:n?i.jsx(Fc,{className:"h-4 w-4 animate-spin"}):i.jsxs(i.Fragment,{children:[i.jsx(Ci,{className:"h-4 w-4 mr-1"}),i.jsx("span",{className:"hidden sm:inline",children:"Exit Impersonation"}),i.jsx("span",{className:"sm:hidden",children:"Exit"})]})})]})})},Z0e=N.createContext(void 0),e1="levelup_acting_as",uL="levelup_acting_as_self",E8e=({children:t})=>{const{user:e}=Zn(),[r,n]=N.useState(!1),[s,o]=N.useState([]),[c,a]=N.useState(null),[f,m]=N.useState({}),[y,_]=N.useState(!0),[w,E]=N.useState(()=>sessionStorage.getItem(uL)==="true");N.useEffect(()=>{if(!(e!=null&&e.id)){n(!1),o([]),a(null),m({}),_(!1);return}(async()=>{_(!0);try{const{data:B}=await Ce.rpc("has_role",{_user_id:e.id,_role:"assistant"});if(!B){n(!1),o([]),a(null),m({}),_(!1);return}n(!0);const{data:U,error:q}=await Ce.from("agent_assistant_assignments").select("agent_id, permissions").eq("assistant_id",e.id);if(q||!U||U.length===0){o([]),_(!1);return}const H=U.map(J=>J.agent_id),{data:K}=await Ce.from("profiles").select("id, name, email, avatar_url").in("id",H),Q=(K||[]).map(J=>({id:J.id,name:J.name||J.email||"Unknown",email:J.email||"",avatar_url:J.avatar_url}));if(o(Q),sessionStorage.getItem(uL)==="true")E(!0),a(null),m({});else{const J=sessionStorage.getItem(e1);if(J){const ee=Q.find(oe=>oe.id===J);if(ee){a(ee);const oe=U.find(de=>de.agent_id===J);m((oe==null?void 0:oe.permissions)||{})}else if(Q.length>0){a(Q[0]);const oe=U.find(de=>de.agent_id===Q[0].id);m((oe==null?void 0:oe.permissions)||{}),sessionStorage.setItem(e1,Q[0].id)}}else if(Q.length>0){a(Q[0]);const ee=U.find(oe=>oe.agent_id===Q[0].id);m((ee==null?void 0:ee.permissions)||{}),sessionStorage.setItem(e1,Q[0].id)}}}catch(B){console.error("Error loading assistant data:",B)}finally{_(!1)}})()},[e==null?void 0:e.id]);const A=D=>{a(D),E(!1),sessionStorage.removeItem(uL),D?(sessionStorage.setItem(e1,D.id),Ce.from("agent_assistant_assignments").select("permissions").eq("assistant_id",(e==null?void 0:e.id)||"").eq("agent_id",D.id).single().then(({data:B})=>{m((B==null?void 0:B.permissions)||{})})):(sessionStorage.removeItem(e1),m({}))},C=()=>{E(!0),a(null),m({}),sessionStorage.setItem(uL,"true"),sessionStorage.removeItem(e1)},I=D=>!r||w?!0:f[D]===!0,M=r&&c&&!w?c.id:(e==null?void 0:e.id)||null;return i.jsx(Z0e.Provider,{value:{isAssistant:r,assignedAgents:s,actingAsAgent:c,setActingAsAgent:A,effectiveUserId:M,permissions:f,hasPermission:I,isLoading:y,isActingAsSelf:w,setActingAsSelf:C},children:t})},L4=()=>{const t=N.useContext(Z0e);if(t===void 0)throw new Error("useActingAs must be used within an ActingAsProvider");return t},zs=()=>{const{effectiveUserId:t}=L4();return t};var X0e={exports:{}},Q0e={};/** * @license React * use-sync-external-store-shim.production.js * * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var ZS=N;function j8e(t,e){return t===e&&(t!==0||1/t===1/e)||t!==t&&e!==e}var k8e=typeof Object.is=="function"?Object.is:j8e,A8e=ZS.useState,N8e=ZS.useEffect,C8e=ZS.useLayoutEffect,I8e=ZS.useDebugValue;function P8e(t,e){var r=e(),n=A8e({inst:{value:r,getSnapshot:e}}),s=n[0].inst,o=n[1];return C8e(function(){s.value=r,s.getSnapshot=e,t6(s)&&o({inst:s})},[t,r,e]),N8e(function(){return t6(s)&&o({inst:s}),t(function(){t6(s)&&o({inst:s})})},[t]),I8e(r),r}function t6(t){var e=t.getSnapshot;t=t.value;try{var r=e();return!k8e(t,r)}catch{return!0}}function R8e(t,e){return e()}var L8e=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?R8e:P8e;Q0e.useSyncExternalStore=ZS.useSyncExternalStore!==void 0?ZS.useSyncExternalStore:L8e;X0e.exports=Q0e;var M8e=X0e.exports;function D8e(){return M8e.useSyncExternalStore(O8e,()=>!0,()=>!1)}function O8e(){return()=>{}}var rW="Avatar",[F8e,LQt]=cl(rW),[B8e,J0e]=F8e(rW),e_e=N.forwardRef((t,e)=>{const{__scopeAvatar:r,...n}=t,[s,o]=N.useState("idle");return i.jsx(B8e,{scope:r,imageLoadingStatus:s,onImageLoadingStatusChange:o,children:i.jsx(cn.span,{...n,ref:e})})});e_e.displayName=rW;var t_e="AvatarImage",r_e=N.forwardRef((t,e)=>{const{__scopeAvatar:r,src:n,onLoadingStatusChange:s=()=>{},...o}=t,c=J0e(t_e,r),a=$8e(n,o),f=fo(m=>{s(m),c.onImageLoadingStatusChange(m)});return qo(()=>{a!=="idle"&&f(a)},[a,f]),a==="loaded"?i.jsx(cn.img,{...o,ref:e,src:n}):null});r_e.displayName=t_e;var n_e="AvatarFallback",s_e=N.forwardRef((t,e)=>{const{__scopeAvatar:r,delayMs:n,...s}=t,o=J0e(n_e,r),[c,a]=N.useState(n===void 0);return N.useEffect(()=>{if(n!==void 0){const f=window.setTimeout(()=>a(!0),n);return()=>window.clearTimeout(f)}},[n]),c&&o.imageLoadingStatus!=="loaded"?i.jsx(cn.span,{...s,ref:e}):null});s_e.displayName=n_e;function rse(t,e){return t?e?(t.src!==e&&(t.src=e),t.complete&&t.naturalWidth>0?"loaded":"loading"):"error":"idle"}function $8e(t,{referrerPolicy:e,crossOrigin:r}){const n=D8e(),s=N.useRef(null),o=n?(s.current||(s.current=new window.Image),s.current):null,[c,a]=N.useState(()=>rse(o,t));return qo(()=>{a(rse(o,t))},[o,t]),qo(()=>{const f=_=>()=>{a(_)};if(!o)return;const m=f("loaded"),y=f("error");return o.addEventListener("load",m),o.addEventListener("error",y),e&&(o.referrerPolicy=e),typeof r=="string"&&(o.crossOrigin=r),()=>{o.removeEventListener("load",m),o.removeEventListener("error",y)}},[o,r,e]),c}var i_e=e_e,a_e=r_e,o_e=s_e;const Od=N.forwardRef(({className:t,...e},r)=>i.jsx(i_e,{ref:r,className:Xt("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",t),...e}));Od.displayName=i_e.displayName;const Fd=N.forwardRef(({className:t,...e},r)=>i.jsx(a_e,{ref:r,className:Xt("aspect-square h-full w-full",t),...e}));Fd.displayName=a_e.displayName;const Bd=N.forwardRef(({className:t,...e},r)=>i.jsx(o_e,{ref:r,className:Xt("flex h-full w-full items-center justify-center rounded-full bg-muted",t),...e}));Bd.displayName=o_e.displayName;const z8e=zT("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function pi({className:t,variant:e,...r}){return i.jsx("div",{className:Xt(z8e({variant:e}),t),...r})}var U8e=N.createContext(void 0);function ob(t){const e=N.useContext(U8e);return t||e||"ltr"}var r6="rovingFocusGroup.onEntryFocus",V8e={bubbles:!1,cancelable:!0},IC="RovingFocusGroup",[oq,l_e,q8e]=mC(IC),[G8e,eE]=cl(IC,[q8e]),[H8e,W8e]=G8e(IC),c_e=N.forwardRef((t,e)=>i.jsx(oq.Provider,{scope:t.__scopeRovingFocusGroup,children:i.jsx(oq.Slot,{scope:t.__scopeRovingFocusGroup,children:i.jsx(K8e,{...t,ref:e})})}));c_e.displayName=IC;var K8e=N.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:r,orientation:n,loop:s=!1,dir:o,currentTabStopId:c,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:f,onEntryFocus:m,preventScrollOnEntryFocus:y=!1,..._}=t,w=N.useRef(null),E=is(e,w),A=ob(o),[C,I]=ed({prop:c,defaultProp:a??null,onChange:f,caller:IC}),[M,D]=N.useState(!1),B=fo(m),U=l_e(r),q=N.useRef(!1),[H,K]=N.useState(0);return N.useEffect(()=>{const Q=w.current;if(Q)return Q.addEventListener(r6,B),()=>Q.removeEventListener(r6,B)},[B]),i.jsx(H8e,{scope:r,orientation:n,dir:A,loop:s,currentTabStopId:C,onItemFocus:N.useCallback(Q=>I(Q),[I]),onItemShiftTab:N.useCallback(()=>D(!0),[]),onFocusableItemAdd:N.useCallback(()=>K(Q=>Q+1),[]),onFocusableItemRemove:N.useCallback(()=>K(Q=>Q-1),[]),children:i.jsx(cn.div,{tabIndex:M||H===0?-1:0,"data-orientation":n,..._,ref:E,style:{outline:"none",...t.style},onMouseDown:Gr(t.onMouseDown,()=>{q.current=!0}),onFocus:Gr(t.onFocus,Q=>{const J=!q.current;if(Q.target===Q.currentTarget&&J&&!M){const ee=new CustomEvent(r6,V8e);if(Q.currentTarget.dispatchEvent(ee),!ee.defaultPrevented){const oe=U().filter(Se=>Se.focusable),de=oe.find(Se=>Se.active),ye=oe.find(Se=>Se.id===C),Le=[de,ye,...oe].filter(Boolean).map(Se=>Se.ref.current);h_e(Le,y)}}q.current=!1}),onBlur:Gr(t.onBlur,()=>D(!1))})})}),u_e="RovingFocusGroupItem",d_e=N.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:r,focusable:n=!0,active:s=!1,tabStopId:o,children:c,...a}=t,f=il(),m=o||f,y=W8e(u_e,r),_=y.currentTabStopId===m,w=l_e(r),{onFocusableItemAdd:E,onFocusableItemRemove:A,currentTabStopId:C}=y;return N.useEffect(()=>{if(n)return E(),()=>A()},[n,E,A]),i.jsx(oq.ItemSlot,{scope:r,id:m,focusable:n,active:s,children:i.jsx(cn.span,{tabIndex:_?0:-1,"data-orientation":y.orientation,...a,ref:e,onMouseDown:Gr(t.onMouseDown,I=>{n?y.onItemFocus(m):I.preventDefault()}),onFocus:Gr(t.onFocus,()=>y.onItemFocus(m)),onKeyDown:Gr(t.onKeyDown,I=>{if(I.key==="Tab"&&I.shiftKey){y.onItemShiftTab();return}if(I.target!==I.currentTarget)return;const M=X8e(I,y.orientation,y.dir);if(M!==void 0){if(I.metaKey||I.ctrlKey||I.altKey||I.shiftKey)return;I.preventDefault();let B=w().filter(U=>U.focusable).map(U=>U.ref.current);if(M==="last")B.reverse();else if(M==="prev"||M==="next"){M==="prev"&&B.reverse();const U=B.indexOf(I.currentTarget);B=y.loop?Q8e(B,U+1):B.slice(U+1)}setTimeout(()=>h_e(B))}}),children:typeof c=="function"?c({isCurrentTabStop:_,hasTabStop:C!=null}):c})})});d_e.displayName=u_e;var Y8e={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Z8e(t,e){return e!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function X8e(t,e,r){const n=Z8e(t.key,r);if(!(e==="vertical"&&["ArrowLeft","ArrowRight"].includes(n))&&!(e==="horizontal"&&["ArrowUp","ArrowDown"].includes(n)))return Y8e[n]}function h_e(t,e=!1){const r=document.activeElement;for(const n of t)if(n===r||(n.focus({preventScroll:e}),document.activeElement!==r))return}function Q8e(t,e){return t.map((r,n)=>t[(e+n)%t.length])}var nW=c_e,sW=d_e,lq=["Enter"," "],J8e=["ArrowDown","PageUp","Home"],f_e=["ArrowUp","PageDown","End"],eqe=[...J8e,...f_e],tqe={ltr:[...lq,"ArrowRight"],rtl:[...lq,"ArrowLeft"]},rqe={ltr:["ArrowLeft"],rtl:["ArrowRight"]},PC="Menu",[JA,nqe,sqe]=mC(PC),[lb,m_e]=cl(PC,[sqe,l0,eE]),RC=l0(),p_e=eE(),[g_e,d0]=lb(PC),[iqe,LC]=lb(PC),y_e=t=>{const{__scopeMenu:e,open:r=!1,children:n,dir:s,onOpenChange:o,modal:c=!0}=t,a=RC(e),[f,m]=N.useState(null),y=N.useRef(!1),_=fo(o),w=ob(s);return N.useEffect(()=>{const E=()=>{y.current=!0,document.addEventListener("pointerdown",A,{capture:!0,once:!0}),document.addEventListener("pointermove",A,{capture:!0,once:!0})},A=()=>y.current=!1;return document.addEventListener("keydown",E,{capture:!0}),()=>{document.removeEventListener("keydown",E,{capture:!0}),document.removeEventListener("pointerdown",A,{capture:!0}),document.removeEventListener("pointermove",A,{capture:!0})}},[]),i.jsx(kC,{...a,children:i.jsx(g_e,{scope:e,open:r,onOpenChange:_,content:f,onContentChange:m,children:i.jsx(iqe,{scope:e,onClose:N.useCallback(()=>_(!1),[_]),isUsingKeyboardRef:y,dir:w,modal:c,children:n})})})};y_e.displayName=PC;var aqe="MenuAnchor",iW=N.forwardRef((t,e)=>{const{__scopeMenu:r,...n}=t,s=RC(r);return i.jsx(AC,{...s,...n,ref:e})});iW.displayName=aqe;var aW="MenuPortal",[oqe,x_e]=lb(aW,{forceMount:void 0}),__e=t=>{const{__scopeMenu:e,forceMount:r,children:n,container:s}=t,o=d0(aW,e);return i.jsx(oqe,{scope:e,forceMount:r,children:i.jsx(Cl,{present:r||o.open,children:i.jsx($T,{asChild:!0,container:s,children:n})})})};__e.displayName=aW;var Sh="MenuContent",[lqe,oW]=lb(Sh),v_e=N.forwardRef((t,e)=>{const r=x_e(Sh,t.__scopeMenu),{forceMount:n=r.forceMount,...s}=t,o=d0(Sh,t.__scopeMenu),c=LC(Sh,t.__scopeMenu);return i.jsx(JA.Provider,{scope:t.__scopeMenu,children:i.jsx(Cl,{present:n||o.open,children:i.jsx(JA.Slot,{scope:t.__scopeMenu,children:c.modal?i.jsx(cqe,{...s,ref:e}):i.jsx(uqe,{...s,ref:e})})})})}),cqe=N.forwardRef((t,e)=>{const r=d0(Sh,t.__scopeMenu),n=N.useRef(null),s=is(e,n);return N.useEffect(()=>{const o=n.current;if(o)return h4(o)},[]),i.jsx(lW,{...t,ref:s,trapFocus:r.open,disableOutsidePointerEvents:r.open,disableOutsideScroll:!0,onFocusOutside:Gr(t.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>r.onOpenChange(!1)})}),uqe=N.forwardRef((t,e)=>{const r=d0(Sh,t.__scopeMenu);return i.jsx(lW,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>r.onOpenChange(!1)})}),dqe=Bx("MenuContent.ScrollLock"),lW=N.forwardRef((t,e)=>{const{__scopeMenu:r,loop:n=!1,trapFocus:s,onOpenAutoFocus:o,onCloseAutoFocus:c,disableOutsidePointerEvents:a,onEntryFocus:f,onEscapeKeyDown:m,onPointerDownOutside:y,onFocusOutside:_,onInteractOutside:w,onDismiss:E,disableOutsideScroll:A,...C}=t,I=d0(Sh,r),M=LC(Sh,r),D=RC(r),B=p_e(r),U=nqe(r),[q,H]=N.useState(null),K=N.useRef(null),Q=is(e,K,I.onContentChange),J=N.useRef(0),ee=N.useRef(""),oe=N.useRef(0),de=N.useRef(null),ye=N.useRef("right"),Ee=N.useRef(0),Le=A?bC:N.Fragment,Se=A?{as:dqe,allowPinchZoom:!0}:void 0,be=ke=>{var yt,gt;const Pe=ee.current+ke,je=U().filter(ft=>!ft.disabled),xe=document.activeElement,Ue=(yt=je.find(ft=>ft.ref.current===xe))==null?void 0:yt.textValue,Ze=je.map(ft=>ft.textValue),lt=Sqe(Ze,Pe,Ue),wt=(gt=je.find(ft=>ft.textValue===lt))==null?void 0:gt.ref.current;(function ft(kt){ee.current=kt,window.clearTimeout(J.current),kt!==""&&(J.current=window.setTimeout(()=>ft(""),1e3))})(Pe),wt&&setTimeout(()=>wt.focus())};N.useEffect(()=>()=>window.clearTimeout(J.current),[]),u4();const me=N.useCallback(ke=>{var je,xe;return ye.current===((je=de.current)==null?void 0:je.side)&&Eqe(ke,(xe=de.current)==null?void 0:xe.area)},[]);return i.jsx(lqe,{scope:r,searchRef:ee,onItemEnter:N.useCallback(ke=>{me(ke)&&ke.preventDefault()},[me]),onItemLeave:N.useCallback(ke=>{var Pe;me(ke)||((Pe=K.current)==null||Pe.focus(),H(null))},[me]),onTriggerLeave:N.useCallback(ke=>{me(ke)&&ke.preventDefault()},[me]),pointerGraceTimerRef:oe,onPointerGraceIntentChange:N.useCallback(ke=>{de.current=ke},[]),children:i.jsx(Le,{...Se,children:i.jsx(vC,{asChild:!0,trapped:s,onMountAutoFocus:Gr(o,ke=>{var Pe;ke.preventDefault(),(Pe=K.current)==null||Pe.focus({preventScroll:!0})}),onUnmountAutoFocus:c,children:i.jsx(nb,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:m,onPointerDownOutside:y,onFocusOutside:_,onInteractOutside:w,onDismiss:E,children:i.jsx(nW,{asChild:!0,...B,dir:M.dir,orientation:"vertical",loop:n,currentTabStopId:q,onCurrentTabStopIdChange:H,onEntryFocus:Gr(f,ke=>{M.isUsingKeyboardRef.current||ke.preventDefault()}),preventScrollOnEntryFocus:!0,children:i.jsx(_4,{role:"menu","aria-orientation":"vertical","data-state":O_e(I.open),"data-radix-menu-content":"",dir:M.dir,...D,...C,ref:Q,style:{outline:"none",...C.style},onKeyDown:Gr(C.onKeyDown,ke=>{const je=ke.target.closest("[data-radix-menu-content]")===ke.currentTarget,xe=ke.ctrlKey||ke.altKey||ke.metaKey,Ue=ke.key.length===1;je&&(ke.key==="Tab"&&ke.preventDefault(),!xe&&Ue&&be(ke.key));const Ze=K.current;if(ke.target!==Ze||!eqe.includes(ke.key))return;ke.preventDefault();const wt=U().filter(yt=>!yt.disabled).map(yt=>yt.ref.current);f_e.includes(ke.key)&&wt.reverse(),bqe(wt)}),onBlur:Gr(t.onBlur,ke=>{ke.currentTarget.contains(ke.target)||(window.clearTimeout(J.current),ee.current="")}),onPointerMove:Gr(t.onPointerMove,eN(ke=>{const Pe=ke.target,je=Ee.current!==ke.clientX;if(ke.currentTarget.contains(Pe)&&je){const xe=ke.clientX>Ee.current?"right":"left";ye.current=xe,Ee.current=ke.clientX}}))})})})})})})});v_e.displayName=Sh;var hqe="MenuGroup",cW=N.forwardRef((t,e)=>{const{__scopeMenu:r,...n}=t;return i.jsx(cn.div,{role:"group",...n,ref:e})});cW.displayName=hqe;var fqe="MenuLabel",b_e=N.forwardRef((t,e)=>{const{__scopeMenu:r,...n}=t;return i.jsx(cn.div,{...n,ref:e})});b_e.displayName=fqe;var YD="MenuItem",nse="menu.itemSelect",M4=N.forwardRef((t,e)=>{const{disabled:r=!1,onSelect:n,...s}=t,o=N.useRef(null),c=LC(YD,t.__scopeMenu),a=oW(YD,t.__scopeMenu),f=is(e,o),m=N.useRef(!1),y=()=>{const _=o.current;if(!r&&_){const w=new CustomEvent(nse,{bubbles:!0,cancelable:!0});_.addEventListener(nse,E=>n==null?void 0:n(E),{once:!0}),oH(_,w),w.defaultPrevented?m.current=!1:c.onClose()}};return i.jsx(w_e,{...s,ref:f,disabled:r,onClick:Gr(t.onClick,y),onPointerDown:_=>{var w;(w=t.onPointerDown)==null||w.call(t,_),m.current=!0},onPointerUp:Gr(t.onPointerUp,_=>{var w;m.current||(w=_.currentTarget)==null||w.click()}),onKeyDown:Gr(t.onKeyDown,_=>{const w=a.searchRef.current!=="";r||w&&_.key===" "||lq.includes(_.key)&&(_.currentTarget.click(),_.preventDefault())})})});M4.displayName=YD;var w_e=N.forwardRef((t,e)=>{const{__scopeMenu:r,disabled:n=!1,textValue:s,...o}=t,c=oW(YD,r),a=p_e(r),f=N.useRef(null),m=is(e,f),[y,_]=N.useState(!1),[w,E]=N.useState("");return N.useEffect(()=>{const A=f.current;A&&E((A.textContent??"").trim())},[o.children]),i.jsx(JA.ItemSlot,{scope:r,disabled:n,textValue:s??w,children:i.jsx(sW,{asChild:!0,...a,focusable:!n,children:i.jsx(cn.div,{role:"menuitem","data-highlighted":y?"":void 0,"aria-disabled":n||void 0,"data-disabled":n?"":void 0,...o,ref:m,onPointerMove:Gr(t.onPointerMove,eN(A=>{n?c.onItemLeave(A):(c.onItemEnter(A),A.defaultPrevented||A.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Gr(t.onPointerLeave,eN(A=>c.onItemLeave(A))),onFocus:Gr(t.onFocus,()=>_(!0)),onBlur:Gr(t.onBlur,()=>_(!1))})})})}),mqe="MenuCheckboxItem",S_e=N.forwardRef((t,e)=>{const{checked:r=!1,onCheckedChange:n,...s}=t;return i.jsx(A_e,{scope:t.__scopeMenu,checked:r,children:i.jsx(M4,{role:"menuitemcheckbox","aria-checked":ZD(r)?"mixed":r,...s,ref:e,"data-state":hW(r),onSelect:Gr(s.onSelect,()=>n==null?void 0:n(ZD(r)?!0:!r),{checkForDefaultPrevented:!1})})})});S_e.displayName=mqe;var T_e="MenuRadioGroup",[pqe,gqe]=lb(T_e,{value:void 0,onValueChange:()=>{}}),E_e=N.forwardRef((t,e)=>{const{value:r,onValueChange:n,...s}=t,o=fo(n);return i.jsx(pqe,{scope:t.__scopeMenu,value:r,onValueChange:o,children:i.jsx(cW,{...s,ref:e})})});E_e.displayName=T_e;var j_e="MenuRadioItem",k_e=N.forwardRef((t,e)=>{const{value:r,...n}=t,s=gqe(j_e,t.__scopeMenu),o=r===s.value;return i.jsx(A_e,{scope:t.__scopeMenu,checked:o,children:i.jsx(M4,{role:"menuitemradio","aria-checked":o,...n,ref:e,"data-state":hW(o),onSelect:Gr(n.onSelect,()=>{var c;return(c=s.onValueChange)==null?void 0:c.call(s,r)},{checkForDefaultPrevented:!1})})})});k_e.displayName=j_e;var uW="MenuItemIndicator",[A_e,yqe]=lb(uW,{checked:!1}),N_e=N.forwardRef((t,e)=>{const{__scopeMenu:r,forceMount:n,...s}=t,o=yqe(uW,r);return i.jsx(Cl,{present:n||ZD(o.checked)||o.checked===!0,children:i.jsx(cn.span,{...s,ref:e,"data-state":hW(o.checked)})})});N_e.displayName=uW;var xqe="MenuSeparator",C_e=N.forwardRef((t,e)=>{const{__scopeMenu:r,...n}=t;return i.jsx(cn.div,{role:"separator","aria-orientation":"horizontal",...n,ref:e})});C_e.displayName=xqe;var _qe="MenuArrow",I_e=N.forwardRef((t,e)=>{const{__scopeMenu:r,...n}=t,s=RC(r);return i.jsx(v4,{...s,...n,ref:e})});I_e.displayName=_qe;var dW="MenuSub",[vqe,P_e]=lb(dW),R_e=t=>{const{__scopeMenu:e,children:r,open:n=!1,onOpenChange:s}=t,o=d0(dW,e),c=RC(e),[a,f]=N.useState(null),[m,y]=N.useState(null),_=fo(s);return N.useEffect(()=>(o.open===!1&&_(!1),()=>_(!1)),[o.open,_]),i.jsx(kC,{...c,children:i.jsx(g_e,{scope:e,open:n,onOpenChange:_,content:m,onContentChange:y,children:i.jsx(vqe,{scope:e,contentId:il(),triggerId:il(),trigger:a,onTriggerChange:f,children:r})})})};R_e.displayName=dW;var Lk="MenuSubTrigger",L_e=N.forwardRef((t,e)=>{const r=d0(Lk,t.__scopeMenu),n=LC(Lk,t.__scopeMenu),s=P_e(Lk,t.__scopeMenu),o=oW(Lk,t.__scopeMenu),c=N.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:f}=o,m={__scopeMenu:t.__scopeMenu},y=N.useCallback(()=>{c.current&&window.clearTimeout(c.current),c.current=null},[]);return N.useEffect(()=>y,[y]),N.useEffect(()=>{const _=a.current;return()=>{window.clearTimeout(_),f(null)}},[a,f]),i.jsx(iW,{asChild:!0,...m,children:i.jsx(w_e,{id:s.triggerId,"aria-haspopup":"menu","aria-expanded":r.open,"aria-controls":s.contentId,"data-state":O_e(r.open),...t,ref:kg(e,s.onTriggerChange),onClick:_=>{var w;(w=t.onClick)==null||w.call(t,_),!(t.disabled||_.defaultPrevented)&&(_.currentTarget.focus(),r.open||r.onOpenChange(!0))},onPointerMove:Gr(t.onPointerMove,eN(_=>{o.onItemEnter(_),!_.defaultPrevented&&!t.disabled&&!r.open&&!c.current&&(o.onPointerGraceIntentChange(null),c.current=window.setTimeout(()=>{r.onOpenChange(!0),y()},100))})),onPointerLeave:Gr(t.onPointerLeave,eN(_=>{var E,A;y();const w=(E=r.content)==null?void 0:E.getBoundingClientRect();if(w){const C=(A=r.content)==null?void 0:A.dataset.side,I=C==="right",M=I?-5:5,D=w[I?"left":"right"],B=w[I?"right":"left"];o.onPointerGraceIntentChange({area:[{x:_.clientX+M,y:_.clientY},{x:D,y:w.top},{x:B,y:w.top},{x:B,y:w.bottom},{x:D,y:w.bottom}],side:C}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>o.onPointerGraceIntentChange(null),300)}else{if(o.onTriggerLeave(_),_.defaultPrevented)return;o.onPointerGraceIntentChange(null)}})),onKeyDown:Gr(t.onKeyDown,_=>{var E;const w=o.searchRef.current!=="";t.disabled||w&&_.key===" "||tqe[n.dir].includes(_.key)&&(r.onOpenChange(!0),(E=r.content)==null||E.focus(),_.preventDefault())})})})});L_e.displayName=Lk;var M_e="MenuSubContent",D_e=N.forwardRef((t,e)=>{const r=x_e(Sh,t.__scopeMenu),{forceMount:n=r.forceMount,...s}=t,o=d0(Sh,t.__scopeMenu),c=LC(Sh,t.__scopeMenu),a=P_e(M_e,t.__scopeMenu),f=N.useRef(null),m=is(e,f);return i.jsx(JA.Provider,{scope:t.__scopeMenu,children:i.jsx(Cl,{present:n||o.open,children:i.jsx(JA.Slot,{scope:t.__scopeMenu,children:i.jsx(lW,{id:a.contentId,"aria-labelledby":a.triggerId,...s,ref:m,align:"start",side:c.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:y=>{var _;c.isUsingKeyboardRef.current&&((_=f.current)==null||_.focus()),y.preventDefault()},onCloseAutoFocus:y=>y.preventDefault(),onFocusOutside:Gr(t.onFocusOutside,y=>{y.target!==a.trigger&&o.onOpenChange(!1)}),onEscapeKeyDown:Gr(t.onEscapeKeyDown,y=>{c.onClose(),y.preventDefault()}),onKeyDown:Gr(t.onKeyDown,y=>{var E;const _=y.currentTarget.contains(y.target),w=rqe[c.dir].includes(y.key);_&&w&&(o.onOpenChange(!1),(E=a.trigger)==null||E.focus(),y.preventDefault())})})})})})});D_e.displayName=M_e;function O_e(t){return t?"open":"closed"}function ZD(t){return t==="indeterminate"}function hW(t){return ZD(t)?"indeterminate":t?"checked":"unchecked"}function bqe(t){const e=document.activeElement;for(const r of t)if(r===e||(r.focus(),document.activeElement!==e))return}function wqe(t,e){return t.map((r,n)=>t[(e+n)%t.length])}function Sqe(t,e,r){const s=e.length>1&&Array.from(e).every(m=>m===e[0])?e[0]:e,o=r?t.indexOf(r):-1;let c=wqe(t,Math.max(o,0));s.length===1&&(c=c.filter(m=>m!==r));const f=c.find(m=>m.toLowerCase().startsWith(s.toLowerCase()));return f!==r?f:void 0}function Tqe(t,e){const{x:r,y:n}=t;let s=!1;for(let o=0,c=e.length-1;on!=w>n&&r<(_-m)*(n-y)/(w-y)+m&&(s=!s)}return s}function Eqe(t,e){if(!e)return!1;const r={x:t.clientX,y:t.clientY};return Tqe(r,e)}function eN(t){return e=>e.pointerType==="mouse"?t(e):void 0}var jqe=y_e,kqe=iW,Aqe=__e,Nqe=v_e,Cqe=cW,Iqe=b_e,Pqe=M4,Rqe=S_e,Lqe=E_e,Mqe=k_e,Dqe=N_e,Oqe=C_e,Fqe=I_e,Bqe=R_e,$qe=L_e,zqe=D_e,D4="DropdownMenu",[Uqe,MQt]=cl(D4,[m_e]),$c=m_e(),[Vqe,F_e]=Uqe(D4),B_e=t=>{const{__scopeDropdownMenu:e,children:r,dir:n,open:s,defaultOpen:o,onOpenChange:c,modal:a=!0}=t,f=$c(e),m=N.useRef(null),[y,_]=ed({prop:s,defaultProp:o??!1,onChange:c,caller:D4});return i.jsx(Vqe,{scope:e,triggerId:il(),triggerRef:m,contentId:il(),open:y,onOpenChange:_,onOpenToggle:N.useCallback(()=>_(w=>!w),[_]),modal:a,children:i.jsx(jqe,{...f,open:y,onOpenChange:_,dir:n,modal:a,children:r})})};B_e.displayName=D4;var $_e="DropdownMenuTrigger",z_e=N.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,disabled:n=!1,...s}=t,o=F_e($_e,r),c=$c(r);return i.jsx(kqe,{asChild:!0,...c,children:i.jsx(cn.button,{type:"button",id:o.triggerId,"aria-haspopup":"menu","aria-expanded":o.open,"aria-controls":o.open?o.contentId:void 0,"data-state":o.open?"open":"closed","data-disabled":n?"":void 0,disabled:n,...s,ref:kg(e,o.triggerRef),onPointerDown:Gr(t.onPointerDown,a=>{!n&&a.button===0&&a.ctrlKey===!1&&(o.onOpenToggle(),o.open||a.preventDefault())}),onKeyDown:Gr(t.onKeyDown,a=>{n||(["Enter"," "].includes(a.key)&&o.onOpenToggle(),a.key==="ArrowDown"&&o.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});z_e.displayName=$_e;var qqe="DropdownMenuPortal",U_e=t=>{const{__scopeDropdownMenu:e,...r}=t,n=$c(e);return i.jsx(Aqe,{...n,...r})};U_e.displayName=qqe;var V_e="DropdownMenuContent",q_e=N.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,s=F_e(V_e,r),o=$c(r),c=N.useRef(!1);return i.jsx(Nqe,{id:s.contentId,"aria-labelledby":s.triggerId,...o,...n,ref:e,onCloseAutoFocus:Gr(t.onCloseAutoFocus,a=>{var f;c.current||(f=s.triggerRef.current)==null||f.focus(),c.current=!1,a.preventDefault()}),onInteractOutside:Gr(t.onInteractOutside,a=>{const f=a.detail.originalEvent,m=f.button===0&&f.ctrlKey===!0,y=f.button===2||m;(!s.modal||y)&&(c.current=!0)}),style:{...t.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});q_e.displayName=V_e;var Gqe="DropdownMenuGroup",Hqe=N.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,s=$c(r);return i.jsx(Cqe,{...s,...n,ref:e})});Hqe.displayName=Gqe;var Wqe="DropdownMenuLabel",G_e=N.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,s=$c(r);return i.jsx(Iqe,{...s,...n,ref:e})});G_e.displayName=Wqe;var Kqe="DropdownMenuItem",H_e=N.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,s=$c(r);return i.jsx(Pqe,{...s,...n,ref:e})});H_e.displayName=Kqe;var Yqe="DropdownMenuCheckboxItem",W_e=N.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,s=$c(r);return i.jsx(Rqe,{...s,...n,ref:e})});W_e.displayName=Yqe;var Zqe="DropdownMenuRadioGroup",Xqe=N.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,s=$c(r);return i.jsx(Lqe,{...s,...n,ref:e})});Xqe.displayName=Zqe;var Qqe="DropdownMenuRadioItem",K_e=N.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,s=$c(r);return i.jsx(Mqe,{...s,...n,ref:e})});K_e.displayName=Qqe;var Jqe="DropdownMenuItemIndicator",Y_e=N.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,s=$c(r);return i.jsx(Dqe,{...s,...n,ref:e})});Y_e.displayName=Jqe;var e9e="DropdownMenuSeparator",Z_e=N.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,s=$c(r);return i.jsx(Oqe,{...s,...n,ref:e})});Z_e.displayName=e9e;var t9e="DropdownMenuArrow",r9e=N.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,s=$c(r);return i.jsx(Fqe,{...s,...n,ref:e})});r9e.displayName=t9e;var n9e=t=>{const{__scopeDropdownMenu:e,children:r,open:n,onOpenChange:s,defaultOpen:o}=t,c=$c(e),[a,f]=ed({prop:n,defaultProp:o??!1,onChange:s,caller:"DropdownMenuSub"});return i.jsx(Bqe,{...c,open:a,onOpenChange:f,children:r})},s9e="DropdownMenuSubTrigger",X_e=N.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,s=$c(r);return i.jsx($qe,{...s,...n,ref:e})});X_e.displayName=s9e;var i9e="DropdownMenuSubContent",Q_e=N.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,s=$c(r);return i.jsx(zqe,{...s,...n,ref:e,style:{...t.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Q_e.displayName=i9e;var a9e=B_e,o9e=z_e,l9e=U_e,J_e=q_e,eve=G_e,tve=H_e,rve=W_e,nve=K_e,sve=Y_e,ive=Z_e,c9e=n9e,ave=X_e,ove=Q_e;const tE=a9e,rE=o9e,DQt=c9e,u9e=N.forwardRef(({className:t,inset:e,children:r,...n},s)=>i.jsxs(ave,{ref:s,className:Xt("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[state=open]:bg-accent focus:bg-accent",e&&"pl-8",t),...n,children:[r,i.jsx(Vd,{className:"ml-auto h-4 w-4"})]}));u9e.displayName=ave.displayName;const d9e=N.forwardRef(({className:t,...e},r)=>i.jsx(ove,{ref:r,className:Xt("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...e}));d9e.displayName=ove.displayName;const cb=N.forwardRef(({className:t,sideOffset:e=4,...r},n)=>i.jsx(l9e,{children:i.jsx(J_e,{ref:n,sideOffset:e,className:Xt("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...r})}));cb.displayName=J_e.displayName;const mu=N.forwardRef(({className:t,inset:e,...r},n)=>i.jsx(tve,{ref:n,className:Xt("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",e&&"pl-8",t),...r}));mu.displayName=tve.displayName;const h9e=N.forwardRef(({className:t,children:e,checked:r,...n},s)=>i.jsxs(rve,{ref:s,className:Xt("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",t),checked:r,...n,children:[i.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:i.jsx(sve,{children:i.jsx(pa,{className:"h-4 w-4"})})}),e]}));h9e.displayName=rve.displayName;const f9e=N.forwardRef(({className:t,children:e,...r},n)=>i.jsxs(nve,{ref:n,className:Xt("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",t),...r,children:[i.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:i.jsx(sve,{children:i.jsx(Ov,{className:"h-2 w-2 fill-current"})})}),e]}));f9e.displayName=nve.displayName;const fW=N.forwardRef(({className:t,inset:e,...r},n)=>i.jsx(eve,{ref:n,className:Xt("px-2 py-1.5 text-sm font-semibold",e&&"pl-8",t),...r}));fW.displayName=eve.displayName;const XS=N.forwardRef(({className:t,...e},r)=>i.jsx(ive,{ref:r,className:Xt("-mx-1 my-1 h-px bg-muted",t),...e}));XS.displayName=ive.displayName;const m9e=()=>{const{isAssistant:t,actingAsAgent:e,assignedAgents:r,setActingAsAgent:n,isActingAsSelf:s,setActingAsSelf:o}=L4();if(!t)return null;const c=a=>a.split(" ").map(f=>f[0]).join("").toUpperCase().slice(0,2);return i.jsx("div",{className:"fixed top-0 left-0 right-0 z-[2147483647] bg-primary text-primary-foreground px-4 py-1.5 shadow-lg",style:{height:"40px"},children:i.jsxs("div",{className:"container mx-auto flex items-center justify-between gap-4 h-full",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[s?i.jsxs(i.Fragment,{children:[i.jsx(Gl,{className:"h-4 w-4 flex-shrink-0"}),i.jsx("span",{className:"font-medium text-sm",children:"My Account"})]}):i.jsxs(i.Fragment,{children:[i.jsx(El,{className:"h-4 w-4 flex-shrink-0"}),i.jsx("span",{className:"font-medium text-sm",children:"Acting as"})]}),i.jsxs(tE,{children:[i.jsx(rE,{asChild:!0,children:i.jsxs(Lt,{variant:"secondary",size:"sm",className:"gap-2 bg-primary-foreground/20 hover:bg-primary-foreground/30 text-primary-foreground border-0",children:[s?i.jsxs(i.Fragment,{children:[i.jsx(Gl,{className:"h-4 w-4"}),i.jsx("strong",{children:"My Account"})]}):e?i.jsxs(i.Fragment,{children:[i.jsxs(Od,{className:"h-5 w-5",children:[i.jsx(Fd,{src:e.avatar_url||void 0}),i.jsx(Bd,{className:"text-[10px] bg-primary-foreground/30",children:c(e.name)})]}),i.jsx("strong",{children:e.name})]}):i.jsx("strong",{children:"Select..."}),i.jsx(Go,{className:"h-3 w-3"})]})}),i.jsxs(cb,{align:"start",className:"z-[2147483647]",children:[i.jsxs(mu,{onClick:o,className:"gap-2",children:[i.jsx(Gl,{className:"h-4 w-4"}),i.jsx("span",{children:"My Account"}),s&&i.jsx(pi,{variant:"secondary",className:"ml-auto text-[10px]",children:"Current"})]}),i.jsx(XS,{}),r.map(a=>i.jsxs(mu,{onClick:()=>n(a),className:"gap-2",children:[i.jsxs(Od,{className:"h-6 w-6",children:[i.jsx(Fd,{src:a.avatar_url||void 0}),i.jsx(Bd,{className:"text-[10px]",children:c(a.name)})]}),i.jsx("span",{children:a.name}),!s&&a.id===(e==null?void 0:e.id)&&i.jsx(pi,{variant:"secondary",className:"ml-auto text-[10px]",children:"Current"})]},a.id))]})]})]}),i.jsx(pi,{variant:"secondary",className:"bg-primary-foreground/20 text-primary-foreground border-0 text-xs",children:s?"Personal Mode":"Assistant Mode"})]})})};function lve(){var f,m;const{user:t,isAdmin:e}=Zn(),{data:r,isLoading:n}=mr({queryKey:["partnership-membership",t==null?void 0:t.id],enabled:!!(t!=null&&t.id),staleTime:5*60*1e3,queryFn:async()=>{const{data:y}=await Ce.from("partnership_memberships").select("id, status, package_id, program_id").eq("user_id",t.id).eq("status","active").maybeSingle();if(!y)return null;const[{data:_},{data:w}]=await Promise.all([Ce.from("partnership_packages").select("*").eq("id",y.package_id).maybeSingle(),Ce.from("partnership_programs").select("id, name, enabled, brokerage_id").eq("id",y.program_id).maybeSingle()]);return!_||!(w!=null&&w.enabled)?null:{membership:y,pkg:_,program:w}}}),s=N.useMemo(()=>{var y;return new Set(((y=r==null?void 0:r.pkg)==null?void 0:y.included_features)||[])},[r]),o=!!r,c=y=>e||!o?!0:s.has(y),a=y=>{var E,A;const _=((E=r==null?void 0:r.pkg)==null?void 0:E.feature_limits)||{},w=(A=_==null?void 0:_[y])==null?void 0:A.monthly_limit;return typeof w=="number"?w:null};return{isLoading:n,isMember:o,membership:(r==null?void 0:r.membership)??null,pkg:(r==null?void 0:r.pkg)??null,program:(r==null?void 0:r.program)??null,packageKey:((f=r==null?void 0:r.pkg)==null?void 0:f.key)??null,packageName:((m=r==null?void 0:r.pkg)==null?void 0:m.name)??null,features:s,hasFeature:c,limitFor:a,isRestricted:o&&!e}}const mW={crm:"Contacts & CRM",mass_email:"Mass Email",website:"Agent Website",deals:"Deal Pipeline",listing_exchange:"Listing Exchange",smart_card:"Smart Card",guest_book:"Guest Book",landing_pages:"Landing Pages",learn:"Learn & Academy",community:"Community",quickvid:"QuickVid",reelflow:"ReelFlow",direct_mail:"Direct Mail",levelup_attract:"LevelUp Attract",listing_revival:"Listing Revival",fsbo_breakthrough:"By-Owner Breakthrough",weekly_reels:"Weekly Reels",coaching_access:"Coaching",marketing_studio:"Marketing Studio",video_library:"Video Library",presentations:"Presentations",card_studio:"Card Studio",newsletter:"Newsletters",scheduler:"Scheduler",client_portals:"Client Portals",social:"Social Swag"},OQt=Object.keys(mW),p9e={home:null,crm:"crm",deals:"deals",listings:"listing_exchange",marketing:"marketing_studio",websites:"website",academy:"learn",events:"learn",apps:null,brokerage:"community",more:null},sse={"mission-control":"crm",contacts:"crm","sphere-gaps":"crm","mass-emails":"mass_email","bulk-email":"mass_email",newsletters:"newsletter","my-card":"smart_card","guest-book":"guest_book","landing-pages":"landing_pages","card-studio":"card_studio","direct-mail":"direct_mail",quickvid:"quickvid","video-library":"video_library",reelflow:"reelflow",scheduler:"scheduler",community:"community",coaching:"coaching_access","my-coach":"coaching_access","client-portals":"client_portals",presentations:"presentations","social-swag":"social",attract:"levelup_attract","listing-revival":"listing_revival",fsbo:"fsbo_breakthrough","weekly-reels":"weekly_reels"},g9e={quickvid:"quickvid","smart-card":"smart_card","smart-presentations":"presentations","listing-presentation-studio":"presentations","landing-pages":"landing_pages","guest-book":"guest_book","card-studio":"card_studio","direct-mail":"direct_mail",reelflow:"reelflow","mass-emails":"mass_email","newsletter-pro":"newsletter","listing-studio":"listing_exchange","listing-revival":"listing_revival","fsbo-breakthrough":"fsbo_breakthrough",attract:"levelup_attract",scheduler:"scheduler","client-portals":"client_portals","social-swag":"social","social-studio":"social","weekly-reels":"weekly_reels"};function y9e(t){return t.id in sse?sse[t.id]:p9e[t.primaryCategory]??null}function FQt(t){return g9e[t]??null}const x9e=[["/mission-control/pipeline","deals"],["/mission-control/transactions","deals"],["/mission-control/tasks","deals"],["/mission-control/client-portals","client_portals"],["/mission-control/scheduler","scheduler"],["/mission-control/guest-book","guest_book"],["/mission-control/landing-pages","landing_pages"],["/mission-control/card-studio","card_studio"],["/mission-control/direct-mail","direct_mail"],["/mission-control/video-library","video_library"],["/mission-control/video","quickvid"],["/mission-control/my-card","smart_card"],["/mission-control/listing-presentations","presentations"],["/mission-control/sent-emails","mass_email"],["/mission-control/listings","listing_exchange"],["/mission-control/listing-studio","listing_exchange"],["/mission-control/cma","listing_exchange"],["/apps/listing-presentation-studio","presentations"],["/apps/listing-revival","listing_revival"],["/apps/fsbo-breakthrough","fsbo_breakthrough"],["/marketing-studio","marketing_studio"],["/social-swag","social"],["/weekly-reels","weekly_reels"],["/newsletters","newsletter"],["/email-campaigns","mass_email"],["/templates","marketing_studio"],["/reelflow","reelflow"],["/attract","levelup_attract"],["/community","community"],["/coaching","coaching_access"],["/my-coach","coaching_access"],["/events","learn"],["/academy","learn"],["/levelup-u","learn"],["/toolbox","learn"],["/programs","learn"]];function _9e(t){let e=null;for(const r of x9e){const[n]=r;(t===n||t.startsWith(n+"/")||t.startsWith(n+"?"))&&(!e||n.length>e[0].length)&&(e=r)}return e?e[1]:null}const Kn=N.forwardRef(({className:t,...e},r)=>i.jsx("div",{ref:r,className:Xt("rounded-lg border bg-card text-card-foreground shadow-sm",t),...e}));Kn.displayName="Card";const Nd=N.forwardRef(({className:t,...e},r)=>i.jsx("div",{ref:r,className:Xt("flex flex-col space-y-1.5 p-6",t),...e}));Nd.displayName="CardHeader";const Cd=N.forwardRef(({className:t,...e},r)=>i.jsx("h3",{ref:r,className:Xt("text-2xl font-semibold leading-none tracking-tight",t),...e}));Cd.displayName="CardTitle";const tN=N.forwardRef(({className:t,...e},r)=>i.jsx("p",{ref:r,className:Xt("text-sm text-muted-foreground",t),...e}));tN.displayName="CardDescription";const ss=N.forwardRef(({className:t,...e},r)=>i.jsx("div",{ref:r,className:Xt("p-6 pt-0",t),...e}));ss.displayName="CardContent";const cq=N.forwardRef(({className:t,...e},r)=>i.jsx("div",{ref:r,className:Xt("flex items-center p-6 pt-0",t),...e}));cq.displayName="CardFooter";const zc=N.forwardRef(({className:t,...e},r)=>i.jsx("textarea",{className:Xt("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t),ref:r,...e}));zc.displayName="Textarea";const Ha=m4,cve=kH,v9e=p4,BQt=TC,uve=N.forwardRef(({className:t,...e},r)=>i.jsx(GT,{ref:r,className:Xt("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...e}));uve.displayName=GT.displayName;const Ra=N.forwardRef(({className:t,children:e,overlayClassName:r,...n},s)=>i.jsxs(v9e,{children:[i.jsx(uve,{className:r}),i.jsxs(HT,{ref:s,className:Xt("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",t),...n,children:[e,i.jsxs(TC,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity data-[state=open]:bg-accent data-[state=open]:text-muted-foreground hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none",children:[i.jsx(Ci,{className:"h-4 w-4"}),i.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Ra.displayName=HT.displayName;const Ho=({className:t,...e})=>i.jsx("div",{className:Xt("flex flex-col space-y-1.5 text-center sm:text-left",t),...e});Ho.displayName="DialogHeader";const dve=({className:t,...e})=>i.jsx("div",{className:Xt("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...e});dve.displayName="DialogFooter";const Co=N.forwardRef(({className:t,...e},r)=>i.jsx(wC,{ref:r,className:Xt("text-lg font-semibold leading-none tracking-tight",t),...e}));Co.displayName=wC.displayName;const td=N.forwardRef(({className:t,...e},r)=>i.jsx(SC,{ref:r,className:Xt("text-sm text-muted-foreground",t),...e}));td.displayName=SC.displayName;function b9e({featureKey:t,open:e,onOpenChange:r}){const{user:n}=Zn(),s=jr(),[o,c]=N.useState(""),{data:a}=mr({queryKey:["partnership-upgrade-requests",n==null?void 0:n.id],enabled:!!(n!=null&&n.id)&&e,queryFn:async()=>{const{data:_}=await Ce.from("lead_site_upgrade_requests").select("id, feature_key, status").eq("user_id",n.id);return _||[]}}),f=!!(a!=null&&a.some(_=>_.feature_key===t&&_.status!=="declined")),m=kr({mutationFn:async()=>{const{error:_}=await Ce.from("lead_site_upgrade_requests").insert({user_id:n.id,feature_key:t,notes:o||null});if(_)throw _},onSuccess:()=>{s.invalidateQueries({queryKey:["partnership-upgrade-requests"]}),$t.success("Request sent — we'll be in touch shortly."),c(""),r(!1)},onError:_=>$t.error((_==null?void 0:_.message)||"Could not send your request")}),y=mW[t]||t;return i.jsx(Ha,{open:e,onOpenChange:r,children:i.jsxs(Ra,{className:"sm:max-w-md",children:[i.jsxs(Ho,{children:[i.jsxs(Co,{className:"flex items-center gap-2",children:[i.jsx(ki,{className:"h-5 w-5 text-primary"}),"Request ",y]}),i.jsxs(td,{children:[y," is included with the Signature package. Send a request and we'll get you set up."]})]}),f?i.jsxs("div",{className:"rounded-lg border border-border bg-muted/40 p-4 text-sm flex items-start gap-2",children:[i.jsx(pa,{className:"h-4 w-4 mt-0.5 text-primary"}),i.jsx("span",{children:"You've already requested this. We'll follow up soon."})]}):i.jsx(zc,{placeholder:"Anything we should know? (optional)",value:o,onChange:_=>c(_.target.value),rows:4}),i.jsxs(dve,{children:[i.jsx(Lt,{variant:"outline",onClick:()=>r(!1),children:"Close"}),!f&&i.jsx(Lt,{onClick:()=>m.mutate(),disabled:m.isPending,children:m.isPending?"Sending…":"Send request"})]})]})})}function w9e({featureKey:t}){const[e,r]=N.useState(!1),n=mW[t]||t;return i.jsxs("div",{className:"flex items-center justify-center py-16 px-4",children:[i.jsx(Kn,{className:"max-w-lg w-full border-border/60",children:i.jsxs(ss,{className:"p-8 text-center space-y-4",children:[i.jsx("div",{className:"mx-auto h-12 w-12 rounded-full bg-primary/10 flex items-center justify-center",children:i.jsx(zx,{className:"h-6 w-6 text-primary"})}),i.jsxs("h2",{className:"text-2xl font-semibold",children:[n," is a Signature feature"]}),i.jsxs("p",{className:"text-muted-foreground",children:["Your current package doesn't include ",n,". Request access and our team will upgrade your account."]}),i.jsxs(Lt,{onClick:()=>r(!0),className:"gap-2",children:[i.jsx(ki,{className:"h-4 w-4"})," Request access"]})]})}),i.jsx(b9e,{featureKey:t,open:e,onOpenChange:r})]})}const S9e=t=>{const[e,r]=N.useState(null),[n,s]=N.useState(!0);return N.useEffect(()=>{if(!t){s(!1);return}(async()=>{try{const{data:a}=await Ce.storage.from("avatars").list(`${t}`);if(a&&a.length>0){const{data:f}=Ce.storage.from("avatars").getPublicUrl(`${t}/${a[0].name}`);r(`${f.publicUrl}?t=${Date.now()}`)}else r(null)}catch(a){console.error("Error fetching avatar:",a),r(null)}finally{s(!1)}})()},[t]),{avatarUrl:e,loading:n,refreshAvatar:async()=>{if(t)try{const{data:c}=await Ce.storage.from("avatars").list(`${t}`);if(c&&c.length>0){const{data:a}=Ce.storage.from("avatars").getPublicUrl(`${t}/${c[0].name}`);r(`${a.publicUrl}?t=${Date.now()}`)}}catch(c){console.error("Error refreshing avatar:",c)}}}},$Qt=async t=>{const e=new Map;return await Promise.all(t.map(async r=>{try{const{data:n}=await Ce.storage.from("avatars").list(`${r}`);if(n&&n.length>0){const{data:s}=Ce.storage.from("avatars").getPublicUrl(`${r}/${n[0].name}`);e.set(r,s.publicUrl)}}catch{}})),e},T9e=t=>{const[e,r]=N.useState({isTrial:!1,isExpired:!1,expiresAt:null,daysLeft:null,loading:!0});return N.useEffect(()=>{if(!t){r(s=>({...s,loading:!1}));return}(async()=>{try{const{data:s,error:o}=await Ce.from("profiles").select("is_trial, trial_expires_at, subscription_status, subscription_end_date").eq("id",t).single();if(o){console.error("Error fetching trial status:",o),r(_=>({..._,loading:!1}));return}const c=(s==null?void 0:s.subscription_status)==="trialing",a=!!(s!=null&&s.is_trial),f=!!(s!=null&&s.trial_expires_at)&&new Date(s.trial_expires_at).getTime()>Date.now()&&(s==null?void 0:s.subscription_status)!=="active",m=c&&(s==null?void 0:s.subscription_end_date)||(s==null?void 0:s.trial_expires_at)||(s==null?void 0:s.subscription_end_date)||null;if((c||a||f)&&!!m&&m){const _=new Date().getTime(),w=new Date(m).getTime(),E=Math.ceil((w-_)/(1e3*60*60*24)),A=E<=0;r({isTrial:!0,isExpired:A,expiresAt:m,daysLeft:A?0:E,loading:!1})}else r({isTrial:!1,isExpired:!1,expiresAt:null,daysLeft:null,loading:!1})}catch(s){console.error("Error in useTrialStatus:",s),r(o=>({...o,loading:!1}))}})()},[t]),e},O4=()=>{const{data:t,isLoading:e}=mr({queryKey:["feature-flags"],queryFn:async()=>{const{data:n,error:s}=await Ce.from("feature_flags").select("*");if(s)throw s;return n}}),r=n=>{if(!t)return!1;const s=t.find(o=>o.key===n);return(s==null?void 0:s.enabled)??!1};return{flags:t,isLoading:e,isFeatureEnabled:r,isAgentOSEnabled:r("agent_os_enabled"),isInnerCircleEnabled:r("innercircle_enabled"),isMarketplaceEnabled:r("marketplace")}},ise="community_last_seen_post_at";function E9e(){const{user:t}=Zn(),e=js(),[r,n]=N.useState(0),[s,o]=N.useState(null);N.useEffect(()=>{if(!t)return;const a=localStorage.getItem(`${ise}_${t.id}`);o(a)},[t]),N.useEffect(()=>{if(!t)return;const a=`community_unread_count_${t.id}`,f=2*60*1e3;(async()=>{try{const E=sessionStorage.getItem(a);if(E){const A=JSON.parse(E);if(A.ts&&Date.now()-A.ts{if(!t)return;const a=Ce.channel("community-new-posts").on("postgres_changes",{event:"INSERT",schema:"public",table:"community_posts"},async f=>{const m=f.new;if(m.user_id===t.id)return;const y=e.pathname==="/community";y||n(C=>C+1);const{data:_}=await Ce.from("profiles").select("name").eq("id",m.user_id).single(),w=(_==null?void 0:_.name)||"Someone",E=m.content.replace(/@\[([^\]]+)\]\([^)]+\)/g,"@$1"),A=E.length>50?E.substring(0,50)+"...":E;y||$t("New Community Post",{description:`${w}: ${A}`,action:{label:"View",onClick:()=>{window.location.href="/community"}}})}).subscribe();return()=>{Ce.removeChannel(a)}},[t,e.pathname]);const c=N.useCallback(()=>{if(!t)return;const a=new Date().toISOString();localStorage.setItem(`${ise}_${t.id}`,a),o(a),n(0)},[t]);return N.useEffect(()=>{e.pathname==="/community"&&r>0&&c()},[e.pathname,r,c]),{unreadCount:r,markAsRead:c}}function j9e(){const{isAdmin:t}=Zn(),{data:e=0}=mr({queryKey:["wishlist-open-count"],queryFn:async()=>{const{count:r,error:n}=await Ce.from("wishlist_items").select("*",{count:"exact",head:!0}).eq("status","open");if(n)throw n;return r||0},enabled:t,staleTime:6e4});return{openCount:t?e:0}}const n6=t=>`levelup:activeTeam:${t}`,k9e=()=>{const t=zs();return mr({queryKey:["user-teams",t],queryFn:async()=>{const{data:e,error:r}=await Ce.from("team_members").select("id, team_id, role").eq("user_id",t);if(r)throw r;if(!(e!=null&&e.length))return[];const{data:n,error:s}=await Ce.from("teams").select("*").in("id",e.map(c=>c.team_id));if(s)throw s;const o=new Map((n||[]).map(c=>[c.id,c]));return e.filter(c=>o.has(c.team_id)).map(c=>({membershipId:c.id,teamId:c.team_id,role:c.role,team:o.get(c.team_id)})).sort((c,a)=>{var f,m;return c.role!==a.role?c.role==="team_leader"?-1:1:(((f=c.team)==null?void 0:f.name)||"").localeCompare(((m=a.team)==null?void 0:m.name)||"")})},enabled:!!t,staleTime:5*60*1e3})},nE=()=>{const t=zs(),e=k9e(),r=N.useMemo(()=>e.data||[],[e.data]),[n,s]=N.useState(()=>!t||typeof window>"u"?null:window.localStorage.getItem(n6(t)));N.useEffect(()=>{!t||typeof window>"u"||s(window.localStorage.getItem(n6(t)))},[t]);const o=N.useCallback(a=>{s(a),t&&typeof window<"u"&&window.localStorage.setItem(n6(t),a)},[t]),c=N.useMemo(()=>r.length?r.find(a=>a.teamId===n)||r[0]:null,[r,n]);return{...e,data:c,teams:r,activeTeamId:(c==null?void 0:c.teamId)??null,setActiveTeamId:o}},ase="weekly_reels";function pW(){const{user:t,loading:e,isAdmin:r}=Zn(),{data:n,isLoading:s}=mr({queryKey:["feature-entitlement",ase,t==null?void 0:t.id],enabled:!!t&&!r,staleTime:5*60*1e3,queryFn:async()=>{const{data:o,error:c}=await Ce.from("feature_entitlements").select("enabled, expires_at, tier").eq("user_id",t.id).eq("feature_key",ase).maybeSingle();if(c)throw c;return o?{hasAccess:o.enabled&&(!o.expires_at||new Date(o.expires_at).getTime()>Date.now()),tier:o.tier??null}:{hasAccess:!1,tier:null}}});return{hasAccess:r||!!(n!=null&&n.hasAccess),tier:r?"admin":(n==null?void 0:n.tier)??null,isLoading:e||!r&&!!t&&s}}const hve=m4,A9e=kH,N9e=p4,fve=N.forwardRef(({className:t,...e},r)=>i.jsx(GT,{className:Xt("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...e,ref:r}));fve.displayName=GT.displayName;const C9e=zT("fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),gW=N.forwardRef(({side:t="right",className:e,children:r,...n},s)=>i.jsxs(N9e,{children:[i.jsx(fve,{}),i.jsxs(HT,{ref:s,className:Xt(C9e({side:t}),e),...n,children:[r,i.jsxs(TC,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity data-[state=open]:bg-secondary hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none",children:[i.jsx(Ci,{className:"h-4 w-4"}),i.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));gW.displayName=HT.displayName;const mve=({className:t,...e})=>i.jsx("div",{className:Xt("flex flex-col space-y-2 text-center sm:text-left",t),...e});mve.displayName="SheetHeader";const I9e=({className:t,...e})=>i.jsx("div",{className:Xt("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...e});I9e.displayName="SheetFooter";const pve=N.forwardRef(({className:t,...e},r)=>i.jsx(wC,{ref:r,className:Xt("text-lg font-semibold text-foreground",t),...e}));pve.displayName=wC.displayName;const gve=N.forwardRef(({className:t,...e},r)=>i.jsx(SC,{ref:r,className:Xt("text-sm text-muted-foreground",t),...e}));gve.displayName=SC.displayName;function rN(t,[e,r]){return Math.min(r,Math.max(e,t))}function P9e(t,e){return N.useReducer((r,n)=>e[r][n]??r,t)}var yW="ScrollArea",[yve,zQt]=cl(yW),[R9e,Lh]=yve(yW),xve=N.forwardRef((t,e)=>{const{__scopeScrollArea:r,type:n="hover",dir:s,scrollHideDelay:o=600,...c}=t,[a,f]=N.useState(null),[m,y]=N.useState(null),[_,w]=N.useState(null),[E,A]=N.useState(null),[C,I]=N.useState(null),[M,D]=N.useState(0),[B,U]=N.useState(0),[q,H]=N.useState(!1),[K,Q]=N.useState(!1),J=is(e,oe=>f(oe)),ee=ob(s);return i.jsx(R9e,{scope:r,type:n,dir:ee,scrollHideDelay:o,scrollArea:a,viewport:m,onViewportChange:y,content:_,onContentChange:w,scrollbarX:E,onScrollbarXChange:A,scrollbarXEnabled:q,onScrollbarXEnabledChange:H,scrollbarY:C,onScrollbarYChange:I,scrollbarYEnabled:K,onScrollbarYEnabledChange:Q,onCornerWidthChange:D,onCornerHeightChange:U,children:i.jsx(cn.div,{dir:ee,...c,ref:J,style:{position:"relative","--radix-scroll-area-corner-width":M+"px","--radix-scroll-area-corner-height":B+"px",...t.style}})})});xve.displayName=yW;var _ve="ScrollAreaViewport",vve=N.forwardRef((t,e)=>{const{__scopeScrollArea:r,children:n,nonce:s,...o}=t,c=Lh(_ve,r),a=N.useRef(null),f=is(e,a,c.onViewportChange);return i.jsxs(i.Fragment,{children:[i.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:s}),i.jsx(cn.div,{"data-radix-scroll-area-viewport":"",...o,ref:f,style:{overflowX:c.scrollbarXEnabled?"scroll":"hidden",overflowY:c.scrollbarYEnabled?"scroll":"hidden",...t.style},children:i.jsx("div",{ref:c.onContentChange,style:{minWidth:"100%",display:"table"},children:n})})]})});vve.displayName=_ve;var lp="ScrollAreaScrollbar",xW=N.forwardRef((t,e)=>{const{forceMount:r,...n}=t,s=Lh(lp,t.__scopeScrollArea),{onScrollbarXEnabledChange:o,onScrollbarYEnabledChange:c}=s,a=t.orientation==="horizontal";return N.useEffect(()=>(a?o(!0):c(!0),()=>{a?o(!1):c(!1)}),[a,o,c]),s.type==="hover"?i.jsx(L9e,{...n,ref:e,forceMount:r}):s.type==="scroll"?i.jsx(M9e,{...n,ref:e,forceMount:r}):s.type==="auto"?i.jsx(bve,{...n,ref:e,forceMount:r}):s.type==="always"?i.jsx(_W,{...n,ref:e}):null});xW.displayName=lp;var L9e=N.forwardRef((t,e)=>{const{forceMount:r,...n}=t,s=Lh(lp,t.__scopeScrollArea),[o,c]=N.useState(!1);return N.useEffect(()=>{const a=s.scrollArea;let f=0;if(a){const m=()=>{window.clearTimeout(f),c(!0)},y=()=>{f=window.setTimeout(()=>c(!1),s.scrollHideDelay)};return a.addEventListener("pointerenter",m),a.addEventListener("pointerleave",y),()=>{window.clearTimeout(f),a.removeEventListener("pointerenter",m),a.removeEventListener("pointerleave",y)}}},[s.scrollArea,s.scrollHideDelay]),i.jsx(Cl,{present:r||o,children:i.jsx(bve,{"data-state":o?"visible":"hidden",...n,ref:e})})}),M9e=N.forwardRef((t,e)=>{const{forceMount:r,...n}=t,s=Lh(lp,t.__scopeScrollArea),o=t.orientation==="horizontal",c=B4(()=>f("SCROLL_END"),100),[a,f]=P9e("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return N.useEffect(()=>{if(a==="idle"){const m=window.setTimeout(()=>f("HIDE"),s.scrollHideDelay);return()=>window.clearTimeout(m)}},[a,s.scrollHideDelay,f]),N.useEffect(()=>{const m=s.viewport,y=o?"scrollLeft":"scrollTop";if(m){let _=m[y];const w=()=>{const E=m[y];_!==E&&(f("SCROLL"),c()),_=E};return m.addEventListener("scroll",w),()=>m.removeEventListener("scroll",w)}},[s.viewport,o,f,c]),i.jsx(Cl,{present:r||a!=="hidden",children:i.jsx(_W,{"data-state":a==="hidden"?"hidden":"visible",...n,ref:e,onPointerEnter:Gr(t.onPointerEnter,()=>f("POINTER_ENTER")),onPointerLeave:Gr(t.onPointerLeave,()=>f("POINTER_LEAVE"))})})}),bve=N.forwardRef((t,e)=>{const r=Lh(lp,t.__scopeScrollArea),{forceMount:n,...s}=t,[o,c]=N.useState(!1),a=t.orientation==="horizontal",f=B4(()=>{if(r.viewport){const m=r.viewport.offsetWidth{const{orientation:r="vertical",...n}=t,s=Lh(lp,t.__scopeScrollArea),o=N.useRef(null),c=N.useRef(0),[a,f]=N.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),m=jve(a.viewport,a.content),y={...n,sizes:a,onSizesChange:f,hasThumb:m>0&&m<1,onThumbChange:w=>o.current=w,onThumbPointerUp:()=>c.current=0,onThumbPointerDown:w=>c.current=w};function _(w,E){return z9e(w,c.current,a,E)}return r==="horizontal"?i.jsx(D9e,{...y,ref:e,onThumbPositionChange:()=>{if(s.viewport&&o.current){const w=s.viewport.scrollLeft,E=ose(w,a,s.dir);o.current.style.transform=`translate3d(${E}px, 0, 0)`}},onWheelScroll:w=>{s.viewport&&(s.viewport.scrollLeft=w)},onDragScroll:w=>{s.viewport&&(s.viewport.scrollLeft=_(w,s.dir))}}):r==="vertical"?i.jsx(O9e,{...y,ref:e,onThumbPositionChange:()=>{if(s.viewport&&o.current){const w=s.viewport.scrollTop,E=ose(w,a);o.current.style.transform=`translate3d(0, ${E}px, 0)`}},onWheelScroll:w=>{s.viewport&&(s.viewport.scrollTop=w)},onDragScroll:w=>{s.viewport&&(s.viewport.scrollTop=_(w))}}):null}),D9e=N.forwardRef((t,e)=>{const{sizes:r,onSizesChange:n,...s}=t,o=Lh(lp,t.__scopeScrollArea),[c,a]=N.useState(),f=N.useRef(null),m=is(e,f,o.onScrollbarXChange);return N.useEffect(()=>{f.current&&a(getComputedStyle(f.current))},[f]),i.jsx(Sve,{"data-orientation":"horizontal",...s,ref:m,sizes:r,style:{bottom:0,left:o.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:o.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":F4(r)+"px",...t.style},onThumbPointerDown:y=>t.onThumbPointerDown(y.x),onDragScroll:y=>t.onDragScroll(y.x),onWheelScroll:(y,_)=>{if(o.viewport){const w=o.viewport.scrollLeft+y.deltaX;t.onWheelScroll(w),Ave(w,_)&&y.preventDefault()}},onResize:()=>{f.current&&o.viewport&&c&&n({content:o.viewport.scrollWidth,viewport:o.viewport.offsetWidth,scrollbar:{size:f.current.clientWidth,paddingStart:QD(c.paddingLeft),paddingEnd:QD(c.paddingRight)}})}})}),O9e=N.forwardRef((t,e)=>{const{sizes:r,onSizesChange:n,...s}=t,o=Lh(lp,t.__scopeScrollArea),[c,a]=N.useState(),f=N.useRef(null),m=is(e,f,o.onScrollbarYChange);return N.useEffect(()=>{f.current&&a(getComputedStyle(f.current))},[f]),i.jsx(Sve,{"data-orientation":"vertical",...s,ref:m,sizes:r,style:{top:0,right:o.dir==="ltr"?0:void 0,left:o.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":F4(r)+"px",...t.style},onThumbPointerDown:y=>t.onThumbPointerDown(y.y),onDragScroll:y=>t.onDragScroll(y.y),onWheelScroll:(y,_)=>{if(o.viewport){const w=o.viewport.scrollTop+y.deltaY;t.onWheelScroll(w),Ave(w,_)&&y.preventDefault()}},onResize:()=>{f.current&&o.viewport&&c&&n({content:o.viewport.scrollHeight,viewport:o.viewport.offsetHeight,scrollbar:{size:f.current.clientHeight,paddingStart:QD(c.paddingTop),paddingEnd:QD(c.paddingBottom)}})}})}),[F9e,wve]=yve(lp),Sve=N.forwardRef((t,e)=>{const{__scopeScrollArea:r,sizes:n,hasThumb:s,onThumbChange:o,onThumbPointerUp:c,onThumbPointerDown:a,onThumbPositionChange:f,onDragScroll:m,onWheelScroll:y,onResize:_,...w}=t,E=Lh(lp,r),[A,C]=N.useState(null),I=is(e,J=>C(J)),M=N.useRef(null),D=N.useRef(""),B=E.viewport,U=n.content-n.viewport,q=fo(y),H=fo(f),K=B4(_,10);function Q(J){if(M.current){const ee=J.clientX-M.current.left,oe=J.clientY-M.current.top;m({x:ee,y:oe})}}return N.useEffect(()=>{const J=ee=>{const oe=ee.target;(A==null?void 0:A.contains(oe))&&q(ee,U)};return document.addEventListener("wheel",J,{passive:!1}),()=>document.removeEventListener("wheel",J,{passive:!1})},[B,A,U,q]),N.useEffect(H,[n,H]),QS(A,K),QS(E.content,K),i.jsx(F9e,{scope:r,scrollbar:A,hasThumb:s,onThumbChange:fo(o),onThumbPointerUp:fo(c),onThumbPositionChange:H,onThumbPointerDown:fo(a),children:i.jsx(cn.div,{...w,ref:I,style:{position:"absolute",...w.style},onPointerDown:Gr(t.onPointerDown,J=>{J.button===0&&(J.target.setPointerCapture(J.pointerId),M.current=A.getBoundingClientRect(),D.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",E.viewport&&(E.viewport.style.scrollBehavior="auto"),Q(J))}),onPointerMove:Gr(t.onPointerMove,Q),onPointerUp:Gr(t.onPointerUp,J=>{const ee=J.target;ee.hasPointerCapture(J.pointerId)&&ee.releasePointerCapture(J.pointerId),document.body.style.webkitUserSelect=D.current,E.viewport&&(E.viewport.style.scrollBehavior=""),M.current=null})})})}),XD="ScrollAreaThumb",Tve=N.forwardRef((t,e)=>{const{forceMount:r,...n}=t,s=wve(XD,t.__scopeScrollArea);return i.jsx(Cl,{present:r||s.hasThumb,children:i.jsx(B9e,{ref:e,...n})})}),B9e=N.forwardRef((t,e)=>{const{__scopeScrollArea:r,style:n,...s}=t,o=Lh(XD,r),c=wve(XD,r),{onThumbPositionChange:a}=c,f=is(e,_=>c.onThumbChange(_)),m=N.useRef(void 0),y=B4(()=>{m.current&&(m.current(),m.current=void 0)},100);return N.useEffect(()=>{const _=o.viewport;if(_){const w=()=>{if(y(),!m.current){const E=U9e(_,a);m.current=E,a()}};return a(),_.addEventListener("scroll",w),()=>_.removeEventListener("scroll",w)}},[o.viewport,y,a]),i.jsx(cn.div,{"data-state":c.hasThumb?"visible":"hidden",...s,ref:f,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...n},onPointerDownCapture:Gr(t.onPointerDownCapture,_=>{const E=_.target.getBoundingClientRect(),A=_.clientX-E.left,C=_.clientY-E.top;c.onThumbPointerDown({x:A,y:C})}),onPointerUp:Gr(t.onPointerUp,c.onThumbPointerUp)})});Tve.displayName=XD;var vW="ScrollAreaCorner",Eve=N.forwardRef((t,e)=>{const r=Lh(vW,t.__scopeScrollArea),n=!!(r.scrollbarX&&r.scrollbarY);return r.type!=="scroll"&&n?i.jsx($9e,{...t,ref:e}):null});Eve.displayName=vW;var $9e=N.forwardRef((t,e)=>{const{__scopeScrollArea:r,...n}=t,s=Lh(vW,r),[o,c]=N.useState(0),[a,f]=N.useState(0),m=!!(o&&a);return QS(s.scrollbarX,()=>{var _;const y=((_=s.scrollbarX)==null?void 0:_.offsetHeight)||0;s.onCornerHeightChange(y),f(y)}),QS(s.scrollbarY,()=>{var _;const y=((_=s.scrollbarY)==null?void 0:_.offsetWidth)||0;s.onCornerWidthChange(y),c(y)}),m?i.jsx(cn.div,{...n,ref:e,style:{width:o,height:a,position:"absolute",right:s.dir==="ltr"?0:void 0,left:s.dir==="rtl"?0:void 0,bottom:0,...t.style}}):null});function QD(t){return t?parseInt(t,10):0}function jve(t,e){const r=t/e;return isNaN(r)?0:r}function F4(t){const e=jve(t.viewport,t.content),r=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,n=(t.scrollbar.size-r)*e;return Math.max(n,18)}function z9e(t,e,r,n="ltr"){const s=F4(r),o=s/2,c=e||o,a=s-c,f=r.scrollbar.paddingStart+c,m=r.scrollbar.size-r.scrollbar.paddingEnd-a,y=r.content-r.viewport,_=n==="ltr"?[0,y]:[y*-1,0];return kve([f,m],_)(t)}function ose(t,e,r="ltr"){const n=F4(e),s=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,o=e.scrollbar.size-s,c=e.content-e.viewport,a=o-n,f=r==="ltr"?[0,c]:[c*-1,0],m=rN(t,f);return kve([0,c],[0,a])(m)}function kve(t,e){return r=>{if(t[0]===t[1]||e[0]===e[1])return e[0];const n=(e[1]-e[0])/(t[1]-t[0]);return e[0]+n*(r-t[0])}}function Ave(t,e){return t>0&&t{})=>{let r={left:t.scrollLeft,top:t.scrollTop},n=0;return function s(){const o={left:t.scrollLeft,top:t.scrollTop},c=r.left!==o.left,a=r.top!==o.top;(c||a)&&e(),r=o,n=window.requestAnimationFrame(s)}(),()=>window.cancelAnimationFrame(n)};function B4(t,e){const r=fo(t),n=N.useRef(0);return N.useEffect(()=>()=>window.clearTimeout(n.current),[]),N.useCallback(()=>{window.clearTimeout(n.current),n.current=window.setTimeout(r,e)},[r,e])}function QS(t,e){const r=fo(e);qo(()=>{let n=0;if(t){const s=new ResizeObserver(()=>{cancelAnimationFrame(n),n=window.requestAnimationFrame(r)});return s.observe(t),()=>{window.cancelAnimationFrame(n),s.unobserve(t)}}},[t,r])}var Nve=xve,V9e=vve,q9e=Eve;const cp=N.forwardRef(({className:t,children:e,...r},n)=>i.jsxs(Nve,{ref:n,className:Xt("relative overflow-hidden",t),...r,children:[i.jsx(V9e,{className:"h-full w-full rounded-[inherit]",children:e}),i.jsx(Cve,{}),i.jsx(q9e,{})]}));cp.displayName=Nve.displayName;const Cve=N.forwardRef(({className:t,orientation:e="vertical",...r},n)=>i.jsx(xW,{ref:n,orientation:e,className:Xt("flex touch-none select-none transition-colors",e==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",e==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",t),...r,children:i.jsx(Tve,{className:"relative flex-1 rounded-full bg-border"})}));Cve.displayName=xW.displayName;const G9e="/assets/levelup-logo-Eif24dqY.png",H9e="/assets/levelup-logo-icon-C-7iromj.png",W9e="/assets/levelup-logo-mobile-B9skSjUG.png";var MC=t=>t.type==="checkbox",sv=t=>t instanceof Date,hu=t=>t==null;const Ive=t=>typeof t=="object";var Vo=t=>!hu(t)&&!Array.isArray(t)&&Ive(t)&&!sv(t),Pve=t=>Vo(t)&&t.target?MC(t.target)?t.target.checked:t.target.value:t,K9e=t=>t.substring(0,t.search(/\.\d+(\.|$)/))||t,Rve=(t,e)=>t.has(K9e(e)),Y9e=t=>{const e=t.constructor&&t.constructor.prototype;return Vo(e)&&e.hasOwnProperty("isPrototypeOf")},bW=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function xl(t){let e;const r=Array.isArray(t),n=typeof FileList<"u"?t instanceof FileList:!1;if(t instanceof Date)e=new Date(t);else if(!(bW&&(t instanceof Blob||n))&&(r||Vo(t)))if(e=r?[]:{},!r&&!Y9e(t))e=t;else for(const s in t)t.hasOwnProperty(s)&&(e[s]=xl(t[s]));else return t;return e}var $4=t=>/^\w*$/.test(t),Oo=t=>t===void 0,wW=t=>Array.isArray(t)?t.filter(Boolean):[],SW=t=>wW(t.replace(/["|']|\]/g,"").split(/\.|\[/)),pn=(t,e,r)=>{if(!e||!Vo(t))return r;const n=($4(e)?[e]:SW(e)).reduce((s,o)=>hu(s)?s:s[o],t);return Oo(n)||n===t?Oo(t[e])?r:t[e]:n},Td=t=>typeof t=="boolean",Yi=(t,e,r)=>{let n=-1;const s=$4(e)?[e]:SW(e),o=s.length,c=o-1;for(;++nQe.useContext(TW),Z9e=t=>{const{children:e,...r}=t;return Qe.createElement(TW.Provider,{value:r},e)};var Lve=(t,e,r,n=!0)=>{const s={defaultValues:e._defaultValues};for(const o in t)Object.defineProperty(s,o,{get:()=>{const c=o;return e._proxyFormState[c]!==wf.all&&(e._proxyFormState[c]=!n||wf.all),r&&(r[c]=!0),t[c]}});return s};const EW=typeof window<"u"?Qe.useLayoutEffect:Qe.useEffect;function X9e(t){const e=z4(),{control:r=e.control,disabled:n,name:s,exact:o}=t||{},[c,a]=Qe.useState(r._formState),f=Qe.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return EW(()=>r._subscribe({name:s,formState:f.current,exact:o,callback:m=>{!n&&a({...r._formState,...m})}}),[s,n,o]),Qe.useEffect(()=>{f.current.isValid&&r._setValid(!0)},[r]),Qe.useMemo(()=>Lve(c,r,f.current,!1),[c,r])}var Om=t=>typeof t=="string",Mve=(t,e,r,n,s)=>Om(t)?(n&&e.watch.add(t),pn(r,t,s)):Array.isArray(t)?t.map(o=>(n&&e.watch.add(o),pn(r,o))):(n&&(e.watchAll=!0),r),uq=t=>hu(t)||!Ive(t);function cg(t,e,r=new WeakSet){if(uq(t)||uq(e))return t===e;if(sv(t)&&sv(e))return t.getTime()===e.getTime();const n=Object.keys(t),s=Object.keys(e);if(n.length!==s.length)return!1;if(r.has(t)||r.has(e))return!0;r.add(t),r.add(e);for(const o of n){const c=t[o];if(!s.includes(o))return!1;if(o!=="ref"){const a=e[o];if(sv(c)&&sv(a)||Vo(c)&&Vo(a)||Array.isArray(c)&&Array.isArray(a)?!cg(c,a,r):c!==a)return!1}}return!0}function Q9e(t){const e=z4(),{control:r=e.control,name:n,defaultValue:s,disabled:o,exact:c,compute:a}=t||{},f=Qe.useRef(s),m=Qe.useRef(a),y=Qe.useRef(void 0);m.current=a;const _=Qe.useMemo(()=>r._getWatch(n,f.current),[r,n]),[w,E]=Qe.useState(m.current?m.current(_):_);return EW(()=>r._subscribe({name:n,formState:{values:!0},exact:c,callback:A=>{if(!o){const C=Mve(n,r._names,A.values||r._formValues,!1,f.current);if(m.current){const I=m.current(C);cg(I,y.current)||(E(I),y.current=I)}else E(C)}}}),[r,o,n,c]),Qe.useEffect(()=>r._removeUnmounted()),w}function J9e(t){const e=z4(),{name:r,disabled:n,control:s=e.control,shouldUnregister:o,defaultValue:c}=t,a=Rve(s._names.array,r),f=Qe.useMemo(()=>pn(s._formValues,r,pn(s._defaultValues,r,c)),[s,r,c]),m=Q9e({control:s,name:r,defaultValue:f,exact:!0}),y=X9e({control:s,name:r,exact:!0}),_=Qe.useRef(t),w=Qe.useRef(s.register(r,{...t.rules,value:m,...Td(t.disabled)?{disabled:t.disabled}:{}}));_.current=t;const E=Qe.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!pn(y.errors,r)},isDirty:{enumerable:!0,get:()=>!!pn(y.dirtyFields,r)},isTouched:{enumerable:!0,get:()=>!!pn(y.touchedFields,r)},isValidating:{enumerable:!0,get:()=>!!pn(y.validatingFields,r)},error:{enumerable:!0,get:()=>pn(y.errors,r)}}),[y,r]),A=Qe.useCallback(D=>w.current.onChange({target:{value:Pve(D),name:r},type:JD.CHANGE}),[r]),C=Qe.useCallback(()=>w.current.onBlur({target:{value:pn(s._formValues,r),name:r},type:JD.BLUR}),[r,s._formValues]),I=Qe.useCallback(D=>{const B=pn(s._fields,r);B&&D&&(B._f.ref={focus:()=>D.focus&&D.focus(),select:()=>D.select&&D.select(),setCustomValidity:U=>D.setCustomValidity(U),reportValidity:()=>D.reportValidity()})},[s._fields,r]),M=Qe.useMemo(()=>({name:r,value:m,...Td(n)||y.disabled?{disabled:y.disabled||n}:{},onChange:A,onBlur:C,ref:I}),[r,n,y.disabled,A,C,I,m]);return Qe.useEffect(()=>{const D=s._options.shouldUnregister||o;s.register(r,{..._.current.rules,...Td(_.current.disabled)?{disabled:_.current.disabled}:{}});const B=(U,q)=>{const H=pn(s._fields,U);H&&H._f&&(H._f.mount=q)};if(B(r,!0),D){const U=xl(pn(s._options.defaultValues,r));Yi(s._defaultValues,r,U),Oo(pn(s._formValues,r))&&Yi(s._formValues,r,U)}return!a&&s.register(r),()=>{(a?D&&!s._state.action:D)?s.unregister(r):B(r,!1)}},[r,s,a,o]),Qe.useEffect(()=>{s._setDisabledField({disabled:n,name:r})},[n,r,s]),Qe.useMemo(()=>({field:M,formState:y,fieldState:E}),[M,y,E])}const eGe=t=>t.render(J9e(t));var Dve=(t,e,r,n,s)=>e?{...r[t],types:{...r[t]&&r[t].types?r[t].types:{},[n]:s||!0}}:{},iA=t=>Array.isArray(t)?t:[t],lse=()=>{let t=[];return{get observers(){return t},next:s=>{for(const o of t)o.next&&o.next(s)},subscribe:s=>(t.push(s),{unsubscribe:()=>{t=t.filter(o=>o!==s)}}),unsubscribe:()=>{t=[]}}},Uu=t=>Vo(t)&&!Object.keys(t).length,jW=t=>t.type==="file",Sf=t=>typeof t=="function",eO=t=>{if(!bW)return!1;const e=t?t.ownerDocument:0;return t instanceof(e&&e.defaultView?e.defaultView.HTMLElement:HTMLElement)},Ove=t=>t.type==="select-multiple",kW=t=>t.type==="radio",tGe=t=>kW(t)||MC(t),s6=t=>eO(t)&&t.isConnected;function rGe(t,e){const r=e.slice(0,-1).length;let n=0;for(;n{for(const e in t)if(Sf(t[e]))return!0;return!1};function tO(t,e={}){const r=Array.isArray(t);if(Vo(t)||r)for(const n in t)Array.isArray(t[n])||Vo(t[n])&&!Fve(t[n])?(e[n]=Array.isArray(t[n])?[]:{},tO(t[n],e[n])):hu(t[n])||(e[n]=!0);return e}function Bve(t,e,r){const n=Array.isArray(t);if(Vo(t)||n)for(const s in t)Array.isArray(t[s])||Vo(t[s])&&!Fve(t[s])?Oo(e)||uq(r[s])?r[s]=Array.isArray(t[s])?tO(t[s],[]):{...tO(t[s])}:Bve(t[s],hu(e)?{}:e[s],r[s]):r[s]=!cg(t[s],e[s]);return r}var J2=(t,e)=>Bve(t,e,tO(e));const cse={value:!1,isValid:!1},use={value:!0,isValid:!0};var $ve=t=>{if(Array.isArray(t)){if(t.length>1){const e=t.filter(r=>r&&r.checked&&!r.disabled).map(r=>r.value);return{value:e,isValid:!!e.length}}return t[0].checked&&!t[0].disabled?t[0].attributes&&!Oo(t[0].attributes.value)?Oo(t[0].value)||t[0].value===""?use:{value:t[0].value,isValid:!0}:use:cse}return cse},zve=(t,{valueAsNumber:e,valueAsDate:r,setValueAs:n})=>Oo(t)?t:e?t===""?NaN:t&&+t:r&&Om(t)?new Date(t):n?n(t):t;const dse={isValid:!1,value:null};var Uve=t=>Array.isArray(t)?t.reduce((e,r)=>r&&r.checked&&!r.disabled?{isValid:!0,value:r.value}:e,dse):dse;function hse(t){const e=t.ref;return jW(e)?e.files:kW(e)?Uve(t.refs).value:Ove(e)?[...e.selectedOptions].map(({value:r})=>r):MC(e)?$ve(t.refs).value:zve(Oo(e.value)?t.ref.value:e.value,t)}var sGe=(t,e,r,n)=>{const s={};for(const o of t){const c=pn(e,o);c&&Yi(s,o,c._f)}return{criteriaMode:r,names:[...t],fields:s,shouldUseNativeValidation:n}},rO=t=>t instanceof RegExp,ek=t=>Oo(t)?t:rO(t)?t.source:Vo(t)?rO(t.value)?t.value.source:t.value:t,fse=t=>({isOnSubmit:!t||t===wf.onSubmit,isOnBlur:t===wf.onBlur,isOnChange:t===wf.onChange,isOnAll:t===wf.all,isOnTouch:t===wf.onTouched});const mse="AsyncFunction";var iGe=t=>!!t&&!!t.validate&&!!(Sf(t.validate)&&t.validate.constructor.name===mse||Vo(t.validate)&&Object.values(t.validate).find(e=>e.constructor.name===mse)),aGe=t=>t.mount&&(t.required||t.min||t.max||t.maxLength||t.minLength||t.pattern||t.validate),pse=(t,e,r)=>!r&&(e.watchAll||e.watch.has(t)||[...e.watch].some(n=>t.startsWith(n)&&/^\.\w+/.test(t.slice(n.length))));const aA=(t,e,r,n)=>{for(const s of r||Object.keys(t)){const o=pn(t,s);if(o){const{_f:c,...a}=o;if(c){if(c.refs&&c.refs[0]&&e(c.refs[0],s)&&!n)return!0;if(c.ref&&e(c.ref,c.name)&&!n)return!0;if(aA(a,e))break}else if(Vo(a)&&aA(a,e))break}}};function gse(t,e,r){const n=pn(t,r);if(n||$4(r))return{error:n,name:r};const s=r.split(".");for(;s.length;){const o=s.join("."),c=pn(e,o),a=pn(t,o);if(c&&!Array.isArray(c)&&r!==o)return{name:r};if(a&&a.type)return{name:o,error:a};if(a&&a.root&&a.root.type)return{name:`${o}.root`,error:a.root};s.pop()}return{name:r}}var oGe=(t,e,r,n)=>{r(t);const{name:s,...o}=t;return Uu(o)||Object.keys(o).length>=Object.keys(e).length||Object.keys(o).find(c=>e[c]===(!n||wf.all))},lGe=(t,e,r)=>!t||!e||t===e||iA(t).some(n=>n&&(r?n===e:n.startsWith(e)||e.startsWith(n))),cGe=(t,e,r,n,s)=>s.isOnAll?!1:!r&&s.isOnTouch?!(e||t):(r?n.isOnBlur:s.isOnBlur)?!t:(r?n.isOnChange:s.isOnChange)?t:!0,uGe=(t,e)=>!wW(pn(t,e)).length&&Qo(t,e),dGe=(t,e,r)=>{const n=iA(pn(t,r));return Yi(n,"root",e[r]),Yi(t,r,n),t},RM=t=>Om(t);function yse(t,e,r="validate"){if(RM(t)||Array.isArray(t)&&t.every(RM)||Td(t)&&!t)return{type:r,message:RM(t)?t:"",ref:e}}var t1=t=>Vo(t)&&!rO(t)?t:{value:t,message:""},xse=async(t,e,r,n,s,o)=>{const{ref:c,refs:a,required:f,maxLength:m,minLength:y,min:_,max:w,pattern:E,validate:A,name:C,valueAsNumber:I,mount:M}=t._f,D=pn(r,C);if(!M||e.has(C))return{};const B=a?a[0]:c,U=de=>{s&&B.reportValidity&&(B.setCustomValidity(Td(de)?"":de||""),B.reportValidity())},q={},H=kW(c),K=MC(c),Q=H||K,J=(I||jW(c))&&Oo(c.value)&&Oo(D)||eO(c)&&c.value===""||D===""||Array.isArray(D)&&!D.length,ee=Dve.bind(null,C,n,q),oe=(de,ye,Ee,Le=Gp.maxLength,Se=Gp.minLength)=>{const be=de?ye:Ee;q[C]={type:de?Le:Se,message:be,ref:c,...ee(de?Le:Se,be)}};if(o?!Array.isArray(D)||!D.length:f&&(!Q&&(J||hu(D))||Td(D)&&!D||K&&!$ve(a).isValid||H&&!Uve(a).isValid)){const{value:de,message:ye}=RM(f)?{value:!!f,message:f}:t1(f);if(de&&(q[C]={type:Gp.required,message:ye,ref:B,...ee(Gp.required,ye)},!n))return U(ye),q}if(!J&&(!hu(_)||!hu(w))){let de,ye;const Ee=t1(w),Le=t1(_);if(!hu(D)&&!isNaN(D)){const Se=c.valueAsNumber||D&&+D;hu(Ee.value)||(de=Se>Ee.value),hu(Le.value)||(ye=Senew Date(new Date().toDateString()+" "+Pe),me=c.type=="time",ke=c.type=="week";Om(Ee.value)&&D&&(de=me?be(D)>be(Ee.value):ke?D>Ee.value:Se>new Date(Ee.value)),Om(Le.value)&&D&&(ye=me?be(D)+de.value,Le=!hu(ye.value)&&D.length<+ye.value;if((Ee||Le)&&(oe(Ee,de.message,ye.message),!n))return U(q[C].message),q}if(E&&!J&&Om(D)){const{value:de,message:ye}=t1(E);if(rO(de)&&!D.match(de)&&(q[C]={type:Gp.pattern,message:ye,ref:c,...ee(Gp.pattern,ye)},!n))return U(ye),q}if(A){if(Sf(A)){const de=await A(D,r),ye=yse(de,B);if(ye&&(q[C]={...ye,...ee(Gp.validate,ye.message)},!n))return U(ye.message),q}else if(Vo(A)){let de={};for(const ye in A){if(!Uu(de)&&!n)break;const Ee=yse(await A[ye](D,r),B,ye);Ee&&(de={...Ee,...ee(ye,Ee.message)},U(Ee.message),n&&(q[C]=de))}if(!Uu(de)&&(q[C]={ref:B,...de},!n))return q}}return U(!0),q};const hGe={mode:wf.onSubmit,reValidateMode:wf.onChange,shouldFocusError:!0};function fGe(t={}){let e={...hGe,...t},r={submitCount:0,isDirty:!1,isReady:!1,isLoading:Sf(e.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1},n={},s=Vo(e.defaultValues)||Vo(e.values)?xl(e.defaultValues||e.values)||{}:{},o=e.shouldUnregister?{}:xl(s),c={action:!1,mount:!1,watch:!1},a={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},f,m=0;const y={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1};let _={...y};const w={array:lse(),state:lse()},E=e.criteriaMode===wf.all,A=tt=>Tt=>{clearTimeout(m),m=setTimeout(tt,Tt)},C=async tt=>{if(!e.disabled&&(y.isValid||_.isValid||tt)){const Tt=e.resolver?Uu((await K()).errors):await J(n,!0);Tt!==r.isValid&&w.state.next({isValid:Tt})}},I=(tt,Tt)=>{!e.disabled&&(y.isValidating||y.validatingFields||_.isValidating||_.validatingFields)&&((tt||Array.from(a.mount)).forEach(Zt=>{Zt&&(Tt?Yi(r.validatingFields,Zt,Tt):Qo(r.validatingFields,Zt))}),w.state.next({validatingFields:r.validatingFields,isValidating:!Uu(r.validatingFields)}))},M=(tt,Tt=[],Zt,ar,Wt=!0,Kt=!0)=>{if(ar&&Zt&&!e.disabled){if(c.action=!0,Kt&&Array.isArray(pn(n,tt))){const At=Zt(pn(n,tt),ar.argA,ar.argB);Wt&&Yi(n,tt,At)}if(Kt&&Array.isArray(pn(r.errors,tt))){const At=Zt(pn(r.errors,tt),ar.argA,ar.argB);Wt&&Yi(r.errors,tt,At),uGe(r.errors,tt)}if((y.touchedFields||_.touchedFields)&&Kt&&Array.isArray(pn(r.touchedFields,tt))){const At=Zt(pn(r.touchedFields,tt),ar.argA,ar.argB);Wt&&Yi(r.touchedFields,tt,At)}(y.dirtyFields||_.dirtyFields)&&(r.dirtyFields=J2(s,o)),w.state.next({name:tt,isDirty:oe(tt,Tt),dirtyFields:r.dirtyFields,errors:r.errors,isValid:r.isValid})}else Yi(o,tt,Tt)},D=(tt,Tt)=>{Yi(r.errors,tt,Tt),w.state.next({errors:r.errors})},B=tt=>{r.errors=tt,w.state.next({errors:r.errors,isValid:!1})},U=(tt,Tt,Zt,ar)=>{const Wt=pn(n,tt);if(Wt){const Kt=pn(o,tt,Oo(Zt)?pn(s,tt):Zt);Oo(Kt)||ar&&ar.defaultChecked||Tt?Yi(o,tt,Tt?Kt:hse(Wt._f)):Ee(tt,Kt),c.mount&&C()}},q=(tt,Tt,Zt,ar,Wt)=>{let Kt=!1,At=!1;const pr={name:tt};if(!e.disabled){if(!Zt||ar){(y.isDirty||_.isDirty)&&(At=r.isDirty,r.isDirty=pr.isDirty=oe(),Kt=At!==pr.isDirty);const yn=cg(pn(s,tt),Tt);At=!!pn(r.dirtyFields,tt),yn?Qo(r.dirtyFields,tt):Yi(r.dirtyFields,tt,!0),pr.dirtyFields=r.dirtyFields,Kt=Kt||(y.dirtyFields||_.dirtyFields)&&At!==!yn}if(Zt){const yn=pn(r.touchedFields,tt);yn||(Yi(r.touchedFields,tt,Zt),pr.touchedFields=r.touchedFields,Kt=Kt||(y.touchedFields||_.touchedFields)&&yn!==Zt)}Kt&&Wt&&w.state.next(pr)}return Kt?pr:{}},H=(tt,Tt,Zt,ar)=>{const Wt=pn(r.errors,tt),Kt=(y.isValid||_.isValid)&&Td(Tt)&&r.isValid!==Tt;if(e.delayError&&Zt?(f=A(()=>D(tt,Zt)),f(e.delayError)):(clearTimeout(m),f=null,Zt?Yi(r.errors,tt,Zt):Qo(r.errors,tt)),(Zt?!cg(Wt,Zt):Wt)||!Uu(ar)||Kt){const At={...ar,...Kt&&Td(Tt)?{isValid:Tt}:{},errors:r.errors,name:tt};r={...r,...At},w.state.next(At)}},K=async tt=>{I(tt,!0);const Tt=await e.resolver(o,e.context,sGe(tt||a.mount,n,e.criteriaMode,e.shouldUseNativeValidation));return I(tt),Tt},Q=async tt=>{const{errors:Tt}=await K(tt);if(tt)for(const Zt of tt){const ar=pn(Tt,Zt);ar?Yi(r.errors,Zt,ar):Qo(r.errors,Zt)}else r.errors=Tt;return Tt},J=async(tt,Tt,Zt={valid:!0})=>{for(const ar in tt){const Wt=tt[ar];if(Wt){const{_f:Kt,...At}=Wt;if(Kt){const pr=a.array.has(Kt.name),yn=Wt._f&&iGe(Wt._f);yn&&y.validatingFields&&I([ar],!0);const Gn=await xse(Wt,a.disabled,o,E,e.shouldUseNativeValidation&&!Tt,pr);if(yn&&y.validatingFields&&I([ar]),Gn[Kt.name]&&(Zt.valid=!1,Tt))break;!Tt&&(pn(Gn,Kt.name)?pr?dGe(r.errors,Gn,Kt.name):Yi(r.errors,Kt.name,Gn[Kt.name]):Qo(r.errors,Kt.name))}!Uu(At)&&await J(At,Tt,Zt)}}return Zt.valid},ee=()=>{for(const tt of a.unMount){const Tt=pn(n,tt);Tt&&(Tt._f.refs?Tt._f.refs.every(Zt=>!s6(Zt)):!s6(Tt._f.ref))&&yt(tt)}a.unMount=new Set},oe=(tt,Tt)=>!e.disabled&&(tt&&Tt&&Yi(o,tt,Tt),!cg(Pe(),s)),de=(tt,Tt,Zt)=>Mve(tt,a,{...c.mount?o:Oo(Tt)?s:Om(tt)?{[tt]:Tt}:Tt},Zt,Tt),ye=tt=>wW(pn(c.mount?o:s,tt,e.shouldUnregister?pn(s,tt,[]):[])),Ee=(tt,Tt,Zt={})=>{const ar=pn(n,tt);let Wt=Tt;if(ar){const Kt=ar._f;Kt&&(!Kt.disabled&&Yi(o,tt,zve(Tt,Kt)),Wt=eO(Kt.ref)&&hu(Tt)?"":Tt,Ove(Kt.ref)?[...Kt.ref.options].forEach(At=>At.selected=Wt.includes(At.value)):Kt.refs?MC(Kt.ref)?Kt.refs.forEach(At=>{(!At.defaultChecked||!At.disabled)&&(Array.isArray(Wt)?At.checked=!!Wt.find(pr=>pr===At.value):At.checked=Wt===At.value||!!Wt)}):Kt.refs.forEach(At=>At.checked=At.value===Wt):jW(Kt.ref)?Kt.ref.value="":(Kt.ref.value=Wt,Kt.ref.type||w.state.next({name:tt,values:xl(o)})))}(Zt.shouldDirty||Zt.shouldTouch)&&q(tt,Wt,Zt.shouldTouch,Zt.shouldDirty,!0),Zt.shouldValidate&&ke(tt)},Le=(tt,Tt,Zt)=>{for(const ar in Tt){if(!Tt.hasOwnProperty(ar))return;const Wt=Tt[ar],Kt=tt+"."+ar,At=pn(n,Kt);(a.array.has(tt)||Vo(Wt)||At&&!At._f)&&!sv(Wt)?Le(Kt,Wt,Zt):Ee(Kt,Wt,Zt)}},Se=(tt,Tt,Zt={})=>{const ar=pn(n,tt),Wt=a.array.has(tt),Kt=xl(Tt);Yi(o,tt,Kt),Wt?(w.array.next({name:tt,values:xl(o)}),(y.isDirty||y.dirtyFields||_.isDirty||_.dirtyFields)&&Zt.shouldDirty&&w.state.next({name:tt,dirtyFields:J2(s,o),isDirty:oe(tt,Kt)})):ar&&!ar._f&&!hu(Kt)?Le(tt,Kt,Zt):Ee(tt,Kt,Zt),pse(tt,a)&&w.state.next({...r,name:tt}),w.state.next({name:c.mount?tt:void 0,values:xl(o)})},be=async tt=>{c.mount=!0;const Tt=tt.target;let Zt=Tt.name,ar=!0;const Wt=pn(n,Zt),Kt=yn=>{ar=Number.isNaN(yn)||sv(yn)&&isNaN(yn.getTime())||cg(yn,pn(o,Zt,yn))},At=fse(e.mode),pr=fse(e.reValidateMode);if(Wt){let yn,Gn;const Fn=Tt.type?hse(Wt._f):Pve(tt),Rs=tt.type===JD.BLUR||tt.type===JD.FOCUS_OUT,sa=!aGe(Wt._f)&&!e.resolver&&!pn(r.errors,Zt)&&!Wt._f.deps||cGe(Rs,pn(r.touchedFields,Zt),r.isSubmitted,pr,At),gs=pse(Zt,a,Rs);Yi(o,Zt,Fn),Rs?(Wt._f.onBlur&&Wt._f.onBlur(tt),f&&f(0)):Wt._f.onChange&&Wt._f.onChange(tt);const $i=q(Zt,Fn,Rs),Cr=!Uu($i)||gs;if(!Rs&&w.state.next({name:Zt,type:tt.type,values:xl(o)}),sa)return(y.isValid||_.isValid)&&(e.mode==="onBlur"?Rs&&C():Rs||C()),Cr&&w.state.next({name:Zt,...gs?{}:$i});if(!Rs&&gs&&w.state.next({...r}),e.resolver){const{errors:Bn}=await K([Zt]);if(Kt(Fn),ar){const wi=gse(r.errors,n,Zt),ii=gse(Bn,n,wi.name||Zt);yn=ii.error,Zt=ii.name,Gn=Uu(Bn)}}else I([Zt],!0),yn=(await xse(Wt,a.disabled,o,E,e.shouldUseNativeValidation))[Zt],I([Zt]),Kt(Fn),ar&&(yn?Gn=!1:(y.isValid||_.isValid)&&(Gn=await J(n,!0)));ar&&(Wt._f.deps&&ke(Wt._f.deps),H(Zt,Gn,yn,$i))}},me=(tt,Tt)=>{if(pn(r.errors,Tt)&&tt.focus)return tt.focus(),1},ke=async(tt,Tt={})=>{let Zt,ar;const Wt=iA(tt);if(e.resolver){const Kt=await Q(Oo(tt)?tt:Wt);Zt=Uu(Kt),ar=tt?!Wt.some(At=>pn(Kt,At)):Zt}else tt?(ar=(await Promise.all(Wt.map(async Kt=>{const At=pn(n,Kt);return await J(At&&At._f?{[Kt]:At}:At)}))).every(Boolean),!(!ar&&!r.isValid)&&C()):ar=Zt=await J(n);return w.state.next({...!Om(tt)||(y.isValid||_.isValid)&&Zt!==r.isValid?{}:{name:tt},...e.resolver||!tt?{isValid:Zt}:{},errors:r.errors}),Tt.shouldFocus&&!ar&&aA(n,me,tt?Wt:a.mount),ar},Pe=tt=>{const Tt={...c.mount?o:s};return Oo(tt)?Tt:Om(tt)?pn(Tt,tt):tt.map(Zt=>pn(Tt,Zt))},je=(tt,Tt)=>({invalid:!!pn((Tt||r).errors,tt),isDirty:!!pn((Tt||r).dirtyFields,tt),error:pn((Tt||r).errors,tt),isValidating:!!pn(r.validatingFields,tt),isTouched:!!pn((Tt||r).touchedFields,tt)}),xe=tt=>{tt&&iA(tt).forEach(Tt=>Qo(r.errors,Tt)),w.state.next({errors:tt?r.errors:{}})},Ue=(tt,Tt,Zt)=>{const ar=(pn(n,tt,{_f:{}})._f||{}).ref,Wt=pn(r.errors,tt)||{},{ref:Kt,message:At,type:pr,...yn}=Wt;Yi(r.errors,tt,{...yn,...Tt,ref:ar}),w.state.next({name:tt,errors:r.errors,isValid:!1}),Zt&&Zt.shouldFocus&&ar&&ar.focus&&ar.focus()},Ze=(tt,Tt)=>Sf(tt)?w.state.subscribe({next:Zt=>"values"in Zt&&tt(de(void 0,Tt),Zt)}):de(tt,Tt,!0),lt=tt=>w.state.subscribe({next:Tt=>{lGe(tt.name,Tt.name,tt.exact)&&oGe(Tt,tt.formState||y,$r,tt.reRenderRoot)&&tt.callback({values:{...o},...r,...Tt,defaultValues:s})}}).unsubscribe,wt=tt=>(c.mount=!0,_={..._,...tt.formState},lt({...tt,formState:_})),yt=(tt,Tt={})=>{for(const Zt of tt?iA(tt):a.mount)a.mount.delete(Zt),a.array.delete(Zt),Tt.keepValue||(Qo(n,Zt),Qo(o,Zt)),!Tt.keepError&&Qo(r.errors,Zt),!Tt.keepDirty&&Qo(r.dirtyFields,Zt),!Tt.keepTouched&&Qo(r.touchedFields,Zt),!Tt.keepIsValidating&&Qo(r.validatingFields,Zt),!e.shouldUnregister&&!Tt.keepDefaultValue&&Qo(s,Zt);w.state.next({values:xl(o)}),w.state.next({...r,...Tt.keepDirty?{isDirty:oe()}:{}}),!Tt.keepIsValid&&C()},gt=({disabled:tt,name:Tt})=>{(Td(tt)&&c.mount||tt||a.disabled.has(Tt))&&(tt?a.disabled.add(Tt):a.disabled.delete(Tt))},ft=(tt,Tt={})=>{let Zt=pn(n,tt);const ar=Td(Tt.disabled)||Td(e.disabled);return Yi(n,tt,{...Zt||{},_f:{...Zt&&Zt._f?Zt._f:{ref:{name:tt}},name:tt,mount:!0,...Tt}}),a.mount.add(tt),Zt?gt({disabled:Td(Tt.disabled)?Tt.disabled:e.disabled,name:tt}):U(tt,!0,Tt.value),{...ar?{disabled:Tt.disabled||e.disabled}:{},...e.progressive?{required:!!Tt.required,min:ek(Tt.min),max:ek(Tt.max),minLength:ek(Tt.minLength),maxLength:ek(Tt.maxLength),pattern:ek(Tt.pattern)}:{},name:tt,onChange:be,onBlur:be,ref:Wt=>{if(Wt){ft(tt,Tt),Zt=pn(n,tt);const Kt=Oo(Wt.value)&&Wt.querySelectorAll&&Wt.querySelectorAll("input,select,textarea")[0]||Wt,At=tGe(Kt),pr=Zt._f.refs||[];if(At?pr.find(yn=>yn===Kt):Kt===Zt._f.ref)return;Yi(n,tt,{_f:{...Zt._f,...At?{refs:[...pr.filter(s6),Kt,...Array.isArray(pn(s,tt))?[{}]:[]],ref:{type:Kt.type,name:tt}}:{ref:Kt}}}),U(tt,!1,void 0,Kt)}else Zt=pn(n,tt,{}),Zt._f&&(Zt._f.mount=!1),(e.shouldUnregister||Tt.shouldUnregister)&&!(Rve(a.array,tt)&&c.action)&&a.unMount.add(tt)}}},kt=()=>e.shouldFocusError&&aA(n,me,a.mount),Vt=tt=>{Td(tt)&&(w.state.next({disabled:tt}),aA(n,(Tt,Zt)=>{const ar=pn(n,Zt);ar&&(Tt.disabled=ar._f.disabled||tt,Array.isArray(ar._f.refs)&&ar._f.refs.forEach(Wt=>{Wt.disabled=ar._f.disabled||tt}))},0,!1))},xt=(tt,Tt)=>async Zt=>{let ar;Zt&&(Zt.preventDefault&&Zt.preventDefault(),Zt.persist&&Zt.persist());let Wt=xl(o);if(w.state.next({isSubmitting:!0}),e.resolver){const{errors:Kt,values:At}=await K();r.errors=Kt,Wt=xl(At)}else await J(n);if(a.disabled.size)for(const Kt of a.disabled)Qo(Wt,Kt);if(Qo(r.errors,"root"),Uu(r.errors)){w.state.next({errors:{}});try{await tt(Wt,Zt)}catch(Kt){ar=Kt}}else Tt&&await Tt({...r.errors},Zt),kt(),setTimeout(kt);if(w.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:Uu(r.errors)&&!ar,submitCount:r.submitCount+1,errors:r.errors}),ar)throw ar},or=(tt,Tt={})=>{pn(n,tt)&&(Oo(Tt.defaultValue)?Se(tt,xl(pn(s,tt))):(Se(tt,Tt.defaultValue),Yi(s,tt,xl(Tt.defaultValue))),Tt.keepTouched||Qo(r.touchedFields,tt),Tt.keepDirty||(Qo(r.dirtyFields,tt),r.isDirty=Tt.defaultValue?oe(tt,xl(pn(s,tt))):oe()),Tt.keepError||(Qo(r.errors,tt),y.isValid&&C()),w.state.next({...r}))},Sr=(tt,Tt={})=>{const Zt=tt?xl(tt):s,ar=xl(Zt),Wt=Uu(tt),Kt=Wt?s:ar;if(Tt.keepDefaultValues||(s=Zt),!Tt.keepValues){if(Tt.keepDirtyValues){const At=new Set([...a.mount,...Object.keys(J2(s,o))]);for(const pr of Array.from(At))pn(r.dirtyFields,pr)?Yi(Kt,pr,pn(o,pr)):Se(pr,pn(Kt,pr))}else{if(bW&&Oo(tt))for(const At of a.mount){const pr=pn(n,At);if(pr&&pr._f){const yn=Array.isArray(pr._f.refs)?pr._f.refs[0]:pr._f.ref;if(eO(yn)){const Gn=yn.closest("form");if(Gn){Gn.reset();break}}}}if(Tt.keepFieldsRef)for(const At of a.mount)Se(At,pn(Kt,At));else n={}}o=e.shouldUnregister?Tt.keepDefaultValues?xl(s):{}:xl(Kt),w.array.next({values:{...Kt}}),w.state.next({values:{...Kt}})}a={mount:Tt.keepDirtyValues?a.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},c.mount=!y.isValid||!!Tt.keepIsValid||!!Tt.keepDirtyValues,c.watch=!!e.shouldUnregister,w.state.next({submitCount:Tt.keepSubmitCount?r.submitCount:0,isDirty:Wt?!1:Tt.keepDirty?r.isDirty:!!(Tt.keepDefaultValues&&!cg(tt,s)),isSubmitted:Tt.keepIsSubmitted?r.isSubmitted:!1,dirtyFields:Wt?{}:Tt.keepDirtyValues?Tt.keepDefaultValues&&o?J2(s,o):r.dirtyFields:Tt.keepDefaultValues&&tt?J2(s,tt):Tt.keepDirty?r.dirtyFields:{},touchedFields:Tt.keepTouched?r.touchedFields:{},errors:Tt.keepErrors?r.errors:{},isSubmitSuccessful:Tt.keepIsSubmitSuccessful?r.isSubmitSuccessful:!1,isSubmitting:!1})},rn=(tt,Tt)=>Sr(Sf(tt)?tt(o):tt,Tt),Rr=(tt,Tt={})=>{const Zt=pn(n,tt),ar=Zt&&Zt._f;if(ar){const Wt=ar.refs?ar.refs[0]:ar.ref;Wt.focus&&(Wt.focus(),Tt.shouldSelect&&Sf(Wt.select)&&Wt.select())}},$r=tt=>{r={...r,...tt}},Nn={control:{register:ft,unregister:yt,getFieldState:je,handleSubmit:xt,setError:Ue,_subscribe:lt,_runSchema:K,_focusError:kt,_getWatch:de,_getDirty:oe,_setValid:C,_setFieldArray:M,_setDisabledField:gt,_setErrors:B,_getFieldArray:ye,_reset:Sr,_resetDefaultValues:()=>Sf(e.defaultValues)&&e.defaultValues().then(tt=>{rn(tt,e.resetOptions),w.state.next({isLoading:!1})}),_removeUnmounted:ee,_disableForm:Vt,_subjects:w,_proxyFormState:y,get _fields(){return n},get _formValues(){return o},get _state(){return c},set _state(tt){c=tt},get _defaultValues(){return s},get _names(){return a},set _names(tt){a=tt},get _formState(){return r},get _options(){return e},set _options(tt){e={...e,...tt}}},subscribe:wt,trigger:ke,register:ft,handleSubmit:xt,watch:Ze,setValue:Se,getValues:Pe,reset:rn,resetField:or,clearErrors:xe,unregister:yt,setError:Ue,setFocus:Rr,getFieldState:je};return{...Nn,formControl:Nn}}function AW(t={}){const e=Qe.useRef(void 0),r=Qe.useRef(void 0),[n,s]=Qe.useState({isDirty:!1,isValidating:!1,isLoading:Sf(t.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:t.errors||{},disabled:t.disabled||!1,isReady:!1,defaultValues:Sf(t.defaultValues)?void 0:t.defaultValues});if(!e.current)if(t.formControl)e.current={...t.formControl,formState:n},t.defaultValues&&!Sf(t.defaultValues)&&t.formControl.reset(t.defaultValues,t.resetOptions);else{const{formControl:c,...a}=fGe(t);e.current={...a,formState:n}}const o=e.current.control;return o._options=t,EW(()=>{const c=o._subscribe({formState:o._proxyFormState,callback:()=>s({...o._formState}),reRenderRoot:!0});return s(a=>({...a,isReady:!0})),o._formState.isReady=!0,c},[o]),Qe.useEffect(()=>o._disableForm(t.disabled),[o,t.disabled]),Qe.useEffect(()=>{t.mode&&(o._options.mode=t.mode),t.reValidateMode&&(o._options.reValidateMode=t.reValidateMode)},[o,t.mode,t.reValidateMode]),Qe.useEffect(()=>{t.errors&&(o._setErrors(t.errors),o._focusError())},[o,t.errors]),Qe.useEffect(()=>{t.shouldUnregister&&o._subjects.state.next({values:o._getWatch()})},[o,t.shouldUnregister]),Qe.useEffect(()=>{if(o._proxyFormState.isDirty){const c=o._getDirty();c!==n.isDirty&&o._subjects.state.next({isDirty:c})}},[o,n.isDirty]),Qe.useEffect(()=>{t.values&&!cg(t.values,r.current)?(o._reset(t.values,{keepFieldsRef:!0,...o._options.resetOptions}),r.current=t.values,s(c=>({...c}))):o._resetDefaultValues()},[o,t.values]),Qe.useEffect(()=>{o._state.mount||(o._setValid(),o._state.mount=!0),o._state.watch&&(o._state.watch=!1,o._subjects.state.next({...o._formState})),o._removeUnmounted()}),e.current.formState=Lve(n,o),e.current}const _se=(t,e,r)=>{if(t&&"reportValidity"in t){const n=pn(r,e);t.setCustomValidity(n&&n.message||""),t.reportValidity()}},Vve=(t,e)=>{for(const r in e.fields){const n=e.fields[r];n&&n.ref&&"reportValidity"in n.ref?_se(n.ref,r,t):n.refs&&n.refs.forEach(s=>_se(s,r,t))}},mGe=(t,e)=>{e.shouldUseNativeValidation&&Vve(t,e);const r={};for(const n in t){const s=pn(e.fields,n),o=Object.assign(t[n]||{},{ref:s&&s.ref});if(pGe(e.names||Object.keys(t),n)){const c=Object.assign({},pn(r,n));Yi(c,"root",o),Yi(r,n,c)}else Yi(r,n,o)}return r},pGe=(t,e)=>t.some(r=>r.startsWith(e+"."));var gGe=function(t,e){for(var r={};t.length;){var n=t[0],s=n.code,o=n.message,c=n.path.join(".");if(!r[c])if("unionErrors"in n){var a=n.unionErrors[0].errors[0];r[c]={message:a.message,type:a.code}}else r[c]={message:o,type:s};if("unionErrors"in n&&n.unionErrors.forEach(function(y){return y.errors.forEach(function(_){return t.push(_)})}),e){var f=r[c].types,m=f&&f[n.code];r[c]=Dve(c,e,r,s,m?[].concat(m,n.message):n.message)}t.shift()}return r},NW=function(t,e,r){return r===void 0&&(r={}),function(n,s,o){try{return Promise.resolve(function(c,a){try{var f=Promise.resolve(t[r.mode==="sync"?"parse":"parseAsync"](n,e)).then(function(m){return o.shouldUseNativeValidation&&Vve({},o),{errors:{},values:r.raw?n:m}})}catch(m){return a(m)}return f&&f.then?f.then(void 0,a):f}(0,function(c){if(function(a){return Array.isArray(a==null?void 0:a.errors)}(c))return{values:{},errors:mGe(gGe(c.errors,!o.shouldUseNativeValidation&&o.criteriaMode==="all"),o)};throw c}))}catch(c){return Promise.reject(c)}}},vse;function Nr(t,e,r){function n(a,f){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:f,constr:c,traits:new Set},enumerable:!1}),a._zod.traits.has(t))return;a._zod.traits.add(t),e(a,f);const m=c.prototype,y=Object.keys(m);for(let _=0;_{var f,m;return r!=null&&r.Parent&&a instanceof r.Parent?!0:(m=(f=a==null?void 0:a._zod)==null?void 0:f.traits)==null?void 0:m.has(t)}}),Object.defineProperty(c,"name",{value:t}),c}class mS extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class qve extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}(vse=globalThis).__zod_globalConfig??(vse.__zod_globalConfig={});const CW=globalThis.__zod_globalConfig;function Cg(t){return CW}function Gve(t){const e=Object.values(t).filter(n=>typeof n=="number");return Object.entries(t).filter(([n,s])=>e.indexOf(+n)===-1).map(([n,s])=>s)}function dq(t,e){return typeof e=="bigint"?e.toString():e}function IW(t){return{get value(){{const e=t();return Object.defineProperty(this,"value",{value:e}),e}}}}function PW(t){return t==null}function RW(t){const e=t.startsWith("^")?1:0,r=t.endsWith("$")?t.length-1:t.length;return t.slice(e,r)}function yGe(t,e){const r=t/e,n=Math.round(r),s=Number.EPSILON*Math.max(Math.abs(r),1);return Math.abs(r-n){};function nO(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}const _Ge=IW(()=>{var t;if(CW.jitless||typeof navigator<"u"&&((t=navigator==null?void 0:navigator.userAgent)!=null&&t.includes("Cloudflare")))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function JS(t){if(nO(t)===!1)return!1;const e=t.constructor;if(e===void 0||typeof e!="function")return!0;const r=e.prototype;return!(nO(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function Wve(t){return JS(t)?{...t}:Array.isArray(t)?[...t]:t instanceof Map?new Map(t):t instanceof Set?new Set(t):t}const vGe=new Set(["string","number","symbol"]);function eT(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function f0(t,e,r){const n=new t._zod.constr(e??t._zod.def);return(!e||r!=null&&r.parent)&&(n._zod.parent=t),n}function Yn(t){const e=t;if(!e)return{};if(typeof e=="string")return{error:()=>e};if((e==null?void 0:e.message)!==void 0){if((e==null?void 0:e.error)!==void 0)throw new Error("Cannot specify both `message` and `error` params");e.error=e.message}return delete e.message,typeof e.error=="string"?{...e,error:()=>e.error}:e}function bGe(t){return Object.keys(t).filter(e=>t[e]._zod.optin==="optional"&&t[e]._zod.optout==="optional")}const wGe={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function SGe(t,e){const r=t._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const o=h0(t._zod.def,{get shape(){const c={};for(const a in e){if(!(a in r.shape))throw new Error(`Unrecognized key: "${a}"`);e[a]&&(c[a]=r.shape[a])}return ub(this,"shape",c),c},checks:[]});return f0(t,o)}function TGe(t,e){const r=t._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const o=h0(t._zod.def,{get shape(){const c={...t._zod.def.shape};for(const a in e){if(!(a in r.shape))throw new Error(`Unrecognized key: "${a}"`);e[a]&&delete c[a]}return ub(this,"shape",c),c},checks:[]});return f0(t,o)}function EGe(t,e){if(!JS(e))throw new Error("Invalid input to extend: expected a plain object");const r=t._zod.def.checks;if(r&&r.length>0){const o=t._zod.def.shape;for(const c in e)if(Object.getOwnPropertyDescriptor(o,c)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const s=h0(t._zod.def,{get shape(){const o={...t._zod.def.shape,...e};return ub(this,"shape",o),o}});return f0(t,s)}function jGe(t,e){if(!JS(e))throw new Error("Invalid input to safeExtend: expected a plain object");const r=h0(t._zod.def,{get shape(){const n={...t._zod.def.shape,...e};return ub(this,"shape",n),n}});return f0(t,r)}function kGe(t,e){var n;if((n=t._zod.def.checks)!=null&&n.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");const r=h0(t._zod.def,{get shape(){const s={...t._zod.def.shape,...e._zod.def.shape};return ub(this,"shape",s),s},get catchall(){return e._zod.def.catchall},checks:e._zod.def.checks??[]});return f0(t,r)}function AGe(t,e,r){const s=e._zod.def.checks;if(s&&s.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const c=h0(e._zod.def,{get shape(){const a=e._zod.def.shape,f={...a};if(r)for(const m in r){if(!(m in a))throw new Error(`Unrecognized key: "${m}"`);r[m]&&(f[m]=t?new t({type:"optional",innerType:a[m]}):a[m])}else for(const m in a)f[m]=t?new t({type:"optional",innerType:a[m]}):a[m];return ub(this,"shape",f),f},checks:[]});return f0(e,c)}function NGe(t,e,r){const n=h0(e._zod.def,{get shape(){const s=e._zod.def.shape,o={...s};if(r)for(const c in r){if(!(c in o))throw new Error(`Unrecognized key: "${c}"`);r[c]&&(o[c]=new t({type:"nonoptional",innerType:s[c]}))}else for(const c in s)o[c]=new t({type:"nonoptional",innerType:s[c]});return ub(this,"shape",o),o}});return f0(e,n)}function V1(t,e=0){var r;if(t.aborted===!0)return!0;for(let n=e;n{var n;return(n=r).path??(n.path=[]),r.path.unshift(t),r})}function dL(t){return typeof t=="string"?t:t==null?void 0:t.message}function Ig(t,e,r){var f,m,y,_,w,E;const n=t.message?t.message:dL((y=(m=(f=t.inst)==null?void 0:f._zod.def)==null?void 0:m.error)==null?void 0:y.call(m,t))??dL((_=e==null?void 0:e.error)==null?void 0:_.call(e,t))??dL((w=r.customError)==null?void 0:w.call(r,t))??dL((E=r.localeError)==null?void 0:E.call(r,t))??"Invalid input",{inst:s,continue:o,input:c,...a}=t;return a.path??(a.path=[]),a.message=n,e!=null&&e.reportInput&&(a.input=c),a}function LW(t){return Array.isArray(t)?"array":typeof t=="string"?"string":"unknown"}function nN(...t){const[e,r,n]=t;return typeof e=="string"?{message:e,code:"custom",input:r,inst:n}:{...e}}const Kve=(t,e)=>{t.name="$ZodError",Object.defineProperty(t,"_zod",{value:t._zod,enumerable:!1}),Object.defineProperty(t,"issues",{value:e,enumerable:!1}),t.message=JSON.stringify(e,dq,2),Object.defineProperty(t,"toString",{value:()=>t.message,enumerable:!1})},Yve=Nr("$ZodError",Kve),Zve=Nr("$ZodError",Kve,{Parent:Error});function IGe(t,e=r=>r.message){const r={},n=[];for(const s of t.issues)s.path.length>0?(r[s.path[0]]=r[s.path[0]]||[],r[s.path[0]].push(e(s))):n.push(e(s));return{formErrors:n,fieldErrors:r}}function PGe(t,e=r=>r.message){const r={_errors:[]},n=(s,o=[])=>{for(const c of s.issues)if(c.code==="invalid_union"&&c.errors.length)c.errors.map(a=>n({issues:a},[...o,...c.path]));else if(c.code==="invalid_key")n({issues:c.issues},[...o,...c.path]);else if(c.code==="invalid_element")n({issues:c.issues},[...o,...c.path]);else{const a=[...o,...c.path];if(a.length===0)r._errors.push(e(c));else{let f=r,m=0;for(;m(e,r,n,s)=>{const o=n?{...n,async:!1}:{async:!1},c=e._zod.run({value:r,issues:[]},o);if(c instanceof Promise)throw new mS;if(c.issues.length){const a=new((s==null?void 0:s.Err)??t)(c.issues.map(f=>Ig(f,o,Cg())));throw Hve(a,s==null?void 0:s.callee),a}return c.value},DW=t=>async(e,r,n,s)=>{const o=n?{...n,async:!0}:{async:!0};let c=e._zod.run({value:r,issues:[]},o);if(c instanceof Promise&&(c=await c),c.issues.length){const a=new((s==null?void 0:s.Err)??t)(c.issues.map(f=>Ig(f,o,Cg())));throw Hve(a,s==null?void 0:s.callee),a}return c.value},U4=t=>(e,r,n)=>{const s=n?{...n,async:!1}:{async:!1},o=e._zod.run({value:r,issues:[]},s);if(o instanceof Promise)throw new mS;return o.issues.length?{success:!1,error:new(t??Yve)(o.issues.map(c=>Ig(c,s,Cg())))}:{success:!0,data:o.value}},RGe=U4(Zve),V4=t=>async(e,r,n)=>{const s=n?{...n,async:!0}:{async:!0};let o=e._zod.run({value:r,issues:[]},s);return o instanceof Promise&&(o=await o),o.issues.length?{success:!1,error:new t(o.issues.map(c=>Ig(c,s,Cg())))}:{success:!0,data:o.value}},LGe=V4(Zve),MGe=t=>(e,r,n)=>{const s=n?{...n,direction:"backward"}:{direction:"backward"};return MW(t)(e,r,s)},DGe=t=>(e,r,n)=>MW(t)(e,r,n),OGe=t=>async(e,r,n)=>{const s=n?{...n,direction:"backward"}:{direction:"backward"};return DW(t)(e,r,s)},FGe=t=>async(e,r,n)=>DW(t)(e,r,n),BGe=t=>(e,r,n)=>{const s=n?{...n,direction:"backward"}:{direction:"backward"};return U4(t)(e,r,s)},$Ge=t=>(e,r,n)=>U4(t)(e,r,n),zGe=t=>async(e,r,n)=>{const s=n?{...n,direction:"backward"}:{direction:"backward"};return V4(t)(e,r,s)},UGe=t=>async(e,r,n)=>V4(t)(e,r,n),VGe=/^[cC][0-9a-z]{6,}$/,qGe=/^[0-9a-z]+$/,GGe=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,HGe=/^[0-9a-vA-V]{20}$/,WGe=/^[A-Za-z0-9]{27}$/,KGe=/^[a-zA-Z0-9_-]{21}$/,YGe=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,ZGe=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Sse=t=>t?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${t}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,XGe=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,QGe="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function JGe(){return new RegExp(QGe,"u")}const e7e=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,t7e=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,r7e=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,n7e=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,s7e=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Xve=/^[A-Za-z0-9_-]*$/,i7e=/^https?$/,a7e=/^\+[1-9]\d{6,14}$/,Qve="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",o7e=new RegExp(`^${Qve}$`);function Jve(t){const e="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof t.precision=="number"?t.precision===-1?`${e}`:t.precision===0?`${e}:[0-5]\\d`:`${e}:[0-5]\\d\\.\\d{${t.precision}}`:`${e}(?::[0-5]\\d(?:\\.\\d+)?)?`}function l7e(t){return new RegExp(`^${Jve(t)}$`)}function c7e(t){const e=Jve({precision:t.precision}),r=["Z"];t.local&&r.push(""),t.offset&&r.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const n=`${e}(?:${r.join("|")})`;return new RegExp(`^${Qve}T(?:${n})$`)}const u7e=t=>{const e=t?`[\\s\\S]{${(t==null?void 0:t.minimum)??0},${(t==null?void 0:t.maximum)??""}}`:"[\\s\\S]*";return new RegExp(`^${e}$`)},d7e=/^-?\d+$/,ebe=/^-?\d+(?:\.\d+)?$/,h7e=/^(?:true|false)$/i,f7e=/^[^A-Z]*$/,m7e=/^[^a-z]*$/,rd=Nr("$ZodCheck",(t,e)=>{var r;t._zod??(t._zod={}),t._zod.def=e,(r=t._zod).onattach??(r.onattach=[])}),tbe={number:"number",bigint:"bigint",object:"date"},rbe=Nr("$ZodCheckLessThan",(t,e)=>{rd.init(t,e);const r=tbe[typeof e.value];t._zod.onattach.push(n=>{const s=n._zod.bag,o=(e.inclusive?s.maximum:s.exclusiveMaximum)??Number.POSITIVE_INFINITY;e.value{(e.inclusive?n.value<=e.value:n.value{rd.init(t,e);const r=tbe[typeof e.value];t._zod.onattach.push(n=>{const s=n._zod.bag,o=(e.inclusive?s.minimum:s.exclusiveMinimum)??Number.NEGATIVE_INFINITY;e.value>o&&(e.inclusive?s.minimum=e.value:s.exclusiveMinimum=e.value)}),t._zod.check=n=>{(e.inclusive?n.value>=e.value:n.value>e.value)||n.issues.push({origin:r,code:"too_small",minimum:typeof e.value=="object"?e.value.getTime():e.value,input:n.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}}),p7e=Nr("$ZodCheckMultipleOf",(t,e)=>{rd.init(t,e),t._zod.onattach.push(r=>{var n;(n=r._zod.bag).multipleOf??(n.multipleOf=e.value)}),t._zod.check=r=>{if(typeof r.value!=typeof e.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?r.value%e.value===BigInt(0):yGe(r.value,e.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:e.value,input:r.value,inst:t,continue:!e.abort})}}),g7e=Nr("$ZodCheckNumberFormat",(t,e)=>{var c;rd.init(t,e),e.format=e.format||"float64";const r=(c=e.format)==null?void 0:c.includes("int"),n=r?"int":"number",[s,o]=wGe[e.format];t._zod.onattach.push(a=>{const f=a._zod.bag;f.format=e.format,f.minimum=s,f.maximum=o,r&&(f.pattern=d7e)}),t._zod.check=a=>{const f=a.value;if(r){if(!Number.isInteger(f)){a.issues.push({expected:n,format:e.format,code:"invalid_type",continue:!1,input:f,inst:t});return}if(!Number.isSafeInteger(f)){f>0?a.issues.push({input:f,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:n,inclusive:!0,continue:!e.abort}):a.issues.push({input:f,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:n,inclusive:!0,continue:!e.abort});return}}fo&&a.issues.push({origin:"number",input:f,code:"too_big",maximum:o,inclusive:!0,inst:t,continue:!e.abort})}}),y7e=Nr("$ZodCheckMaxLength",(t,e)=>{var r;rd.init(t,e),(r=t._zod.def).when??(r.when=n=>{const s=n.value;return!PW(s)&&s.length!==void 0}),t._zod.onattach.push(n=>{const s=n._zod.bag.maximum??Number.POSITIVE_INFINITY;e.maximum{const s=n.value;if(s.length<=e.maximum)return;const c=LW(s);n.issues.push({origin:c,code:"too_big",maximum:e.maximum,inclusive:!0,input:s,inst:t,continue:!e.abort})}}),x7e=Nr("$ZodCheckMinLength",(t,e)=>{var r;rd.init(t,e),(r=t._zod.def).when??(r.when=n=>{const s=n.value;return!PW(s)&&s.length!==void 0}),t._zod.onattach.push(n=>{const s=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;e.minimum>s&&(n._zod.bag.minimum=e.minimum)}),t._zod.check=n=>{const s=n.value;if(s.length>=e.minimum)return;const c=LW(s);n.issues.push({origin:c,code:"too_small",minimum:e.minimum,inclusive:!0,input:s,inst:t,continue:!e.abort})}}),_7e=Nr("$ZodCheckLengthEquals",(t,e)=>{var r;rd.init(t,e),(r=t._zod.def).when??(r.when=n=>{const s=n.value;return!PW(s)&&s.length!==void 0}),t._zod.onattach.push(n=>{const s=n._zod.bag;s.minimum=e.length,s.maximum=e.length,s.length=e.length}),t._zod.check=n=>{const s=n.value,o=s.length;if(o===e.length)return;const c=LW(s),a=o>e.length;n.issues.push({origin:c,...a?{code:"too_big",maximum:e.length}:{code:"too_small",minimum:e.length},inclusive:!0,exact:!0,input:n.value,inst:t,continue:!e.abort})}}),q4=Nr("$ZodCheckStringFormat",(t,e)=>{var r,n;rd.init(t,e),t._zod.onattach.push(s=>{const o=s._zod.bag;o.format=e.format,e.pattern&&(o.patterns??(o.patterns=new Set),o.patterns.add(e.pattern))}),e.pattern?(r=t._zod).check??(r.check=s=>{e.pattern.lastIndex=0,!e.pattern.test(s.value)&&s.issues.push({origin:"string",code:"invalid_format",format:e.format,input:s.value,...e.pattern?{pattern:e.pattern.toString()}:{},inst:t,continue:!e.abort})}):(n=t._zod).check??(n.check=()=>{})}),v7e=Nr("$ZodCheckRegex",(t,e)=>{q4.init(t,e),t._zod.check=r=>{e.pattern.lastIndex=0,!e.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:e.pattern.toString(),inst:t,continue:!e.abort})}}),b7e=Nr("$ZodCheckLowerCase",(t,e)=>{e.pattern??(e.pattern=f7e),q4.init(t,e)}),w7e=Nr("$ZodCheckUpperCase",(t,e)=>{e.pattern??(e.pattern=m7e),q4.init(t,e)}),S7e=Nr("$ZodCheckIncludes",(t,e)=>{rd.init(t,e);const r=eT(e.includes),n=new RegExp(typeof e.position=="number"?`^.{${e.position}}${r}`:r);e.pattern=n,t._zod.onattach.push(s=>{const o=s._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),t._zod.check=s=>{s.value.includes(e.includes,e.position)||s.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:e.includes,input:s.value,inst:t,continue:!e.abort})}}),T7e=Nr("$ZodCheckStartsWith",(t,e)=>{rd.init(t,e);const r=new RegExp(`^${eT(e.prefix)}.*`);e.pattern??(e.pattern=r),t._zod.onattach.push(n=>{const s=n._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(r)}),t._zod.check=n=>{n.value.startsWith(e.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:e.prefix,input:n.value,inst:t,continue:!e.abort})}}),E7e=Nr("$ZodCheckEndsWith",(t,e)=>{rd.init(t,e);const r=new RegExp(`.*${eT(e.suffix)}$`);e.pattern??(e.pattern=r),t._zod.onattach.push(n=>{const s=n._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(r)}),t._zod.check=n=>{n.value.endsWith(e.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:e.suffix,input:n.value,inst:t,continue:!e.abort})}}),j7e=Nr("$ZodCheckOverwrite",(t,e)=>{rd.init(t,e),t._zod.check=r=>{r.value=e.tx(r.value)}});class k7e{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if(typeof e=="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}const n=e.split(` `).filter(c=>c),s=Math.min(...n.map(c=>c.length-c.trimStart().length)),o=n.map(c=>c.slice(s)).map(c=>" ".repeat(this.indent*2)+c);for(const c of o)this.content.push(c)}compile(){const e=Function,r=this==null?void 0:this.args,s=[...((this==null?void 0:this.content)??[""]).map(o=>` ${o}`)];return new e(...r,s.join(` `))}}const A7e={major:4,minor:4,patch:3},vo=Nr("$ZodType",(t,e)=>{var s;var r;t??(t={}),t._zod.def=e,t._zod.bag=t._zod.bag||{},t._zod.version=A7e;const n=[...t._zod.def.checks??[]];t._zod.traits.has("$ZodCheck")&&n.unshift(t);for(const o of n)for(const c of o._zod.onattach)c(t);if(n.length===0)(r=t._zod).deferred??(r.deferred=[]),(s=t._zod.deferred)==null||s.push(()=>{t._zod.run=t._zod.parse});else{const o=(a,f,m)=>{let y=V1(a),_;for(const w of f){if(w._zod.def.when){if(CGe(a)||!w._zod.def.when(a))continue}else if(y)continue;const E=a.issues.length,A=w._zod.check(a);if(A instanceof Promise&&(m==null?void 0:m.async)===!1)throw new mS;if(_||A instanceof Promise)_=(_??Promise.resolve()).then(async()=>{await A,a.issues.length!==E&&(y||(y=V1(a,E)))});else{if(a.issues.length===E)continue;y||(y=V1(a,E))}}return _?_.then(()=>a):a},c=(a,f,m)=>{if(V1(a))return a.aborted=!0,a;const y=o(f,n,m);if(y instanceof Promise){if(m.async===!1)throw new mS;return y.then(_=>t._zod.parse(_,m))}return t._zod.parse(y,m)};t._zod.run=(a,f)=>{if(f.skipChecks)return t._zod.parse(a,f);if(f.direction==="backward"){const y=t._zod.parse({value:a.value,issues:[]},{...f,skipChecks:!0});return y instanceof Promise?y.then(_=>c(_,a,f)):c(y,a,f)}const m=t._zod.parse(a,f);if(m instanceof Promise){if(f.async===!1)throw new mS;return m.then(y=>o(y,n,f))}return o(m,n,f)}}ca(t,"~standard",()=>({validate:o=>{var c;try{const a=RGe(t,o);return a.success?{value:a.data}:{issues:(c=a.error)==null?void 0:c.issues}}catch{return LGe(t,o).then(f=>{var m;return f.success?{value:f.data}:{issues:(m=f.error)==null?void 0:m.issues}})}},vendor:"zod",version:1}))}),OW=Nr("$ZodString",(t,e)=>{var r;vo.init(t,e),t._zod.pattern=[...((r=t==null?void 0:t._zod.bag)==null?void 0:r.patterns)??[]].pop()??u7e(t._zod.bag),t._zod.parse=(n,s)=>{if(e.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:t}),n}}),to=Nr("$ZodStringFormat",(t,e)=>{q4.init(t,e),OW.init(t,e)}),N7e=Nr("$ZodGUID",(t,e)=>{e.pattern??(e.pattern=ZGe),to.init(t,e)}),C7e=Nr("$ZodUUID",(t,e)=>{if(e.version){const n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[e.version];if(n===void 0)throw new Error(`Invalid UUID version: "${e.version}"`);e.pattern??(e.pattern=Sse(n))}else e.pattern??(e.pattern=Sse());to.init(t,e)}),I7e=Nr("$ZodEmail",(t,e)=>{e.pattern??(e.pattern=XGe),to.init(t,e)}),P7e=Nr("$ZodURL",(t,e)=>{to.init(t,e),t._zod.check=r=>{var n;try{const s=r.value.trim();if(!e.normalize&&((n=e.protocol)==null?void 0:n.source)===i7e.source&&!/^https?:\/\//i.test(s)){r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:t,continue:!e.abort});return}const o=new URL(s);e.hostname&&(e.hostname.lastIndex=0,e.hostname.test(o.hostname)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:e.hostname.source,input:r.value,inst:t,continue:!e.abort})),e.protocol&&(e.protocol.lastIndex=0,e.protocol.test(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.protocol)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:e.protocol.source,input:r.value,inst:t,continue:!e.abort})),e.normalize?r.value=o.href:r.value=s;return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:t,continue:!e.abort})}}}),R7e=Nr("$ZodEmoji",(t,e)=>{e.pattern??(e.pattern=JGe()),to.init(t,e)}),L7e=Nr("$ZodNanoID",(t,e)=>{e.pattern??(e.pattern=KGe),to.init(t,e)}),M7e=Nr("$ZodCUID",(t,e)=>{e.pattern??(e.pattern=VGe),to.init(t,e)}),D7e=Nr("$ZodCUID2",(t,e)=>{e.pattern??(e.pattern=qGe),to.init(t,e)}),O7e=Nr("$ZodULID",(t,e)=>{e.pattern??(e.pattern=GGe),to.init(t,e)}),F7e=Nr("$ZodXID",(t,e)=>{e.pattern??(e.pattern=HGe),to.init(t,e)}),B7e=Nr("$ZodKSUID",(t,e)=>{e.pattern??(e.pattern=WGe),to.init(t,e)}),$7e=Nr("$ZodISODateTime",(t,e)=>{e.pattern??(e.pattern=c7e(e)),to.init(t,e)}),z7e=Nr("$ZodISODate",(t,e)=>{e.pattern??(e.pattern=o7e),to.init(t,e)}),U7e=Nr("$ZodISOTime",(t,e)=>{e.pattern??(e.pattern=l7e(e)),to.init(t,e)}),V7e=Nr("$ZodISODuration",(t,e)=>{e.pattern??(e.pattern=YGe),to.init(t,e)}),q7e=Nr("$ZodIPv4",(t,e)=>{e.pattern??(e.pattern=e7e),to.init(t,e),t._zod.bag.format="ipv4"}),G7e=Nr("$ZodIPv6",(t,e)=>{e.pattern??(e.pattern=t7e),to.init(t,e),t._zod.bag.format="ipv6",t._zod.check=r=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:t,continue:!e.abort})}}}),H7e=Nr("$ZodCIDRv4",(t,e)=>{e.pattern??(e.pattern=r7e),to.init(t,e)}),W7e=Nr("$ZodCIDRv6",(t,e)=>{e.pattern??(e.pattern=n7e),to.init(t,e),t._zod.check=r=>{const n=r.value.split("/");try{if(n.length!==2)throw new Error;const[s,o]=n;if(!o)throw new Error;const c=Number(o);if(`${c}`!==o)throw new Error;if(c<0||c>128)throw new Error;new URL(`http://[${s}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:t,continue:!e.abort})}}});function sbe(t){if(t==="")return!0;if(/\s/.test(t)||t.length%4!==0)return!1;try{return atob(t),!0}catch{return!1}}const K7e=Nr("$ZodBase64",(t,e)=>{e.pattern??(e.pattern=s7e),to.init(t,e),t._zod.bag.contentEncoding="base64",t._zod.check=r=>{sbe(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:t,continue:!e.abort})}});function Y7e(t){if(!Xve.test(t))return!1;const e=t.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=e.padEnd(Math.ceil(e.length/4)*4,"=");return sbe(r)}const Z7e=Nr("$ZodBase64URL",(t,e)=>{e.pattern??(e.pattern=Xve),to.init(t,e),t._zod.bag.contentEncoding="base64url",t._zod.check=r=>{Y7e(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:t,continue:!e.abort})}}),X7e=Nr("$ZodE164",(t,e)=>{e.pattern??(e.pattern=a7e),to.init(t,e)});function Q7e(t,e=null){try{const r=t.split(".");if(r.length!==3)return!1;const[n]=r;if(!n)return!1;const s=JSON.parse(atob(n));return!("typ"in s&&(s==null?void 0:s.typ)!=="JWT"||!s.alg||e&&(!("alg"in s)||s.alg!==e))}catch{return!1}}const J7e=Nr("$ZodJWT",(t,e)=>{to.init(t,e),t._zod.check=r=>{Q7e(r.value,e.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:t,continue:!e.abort})}}),ibe=Nr("$ZodNumber",(t,e)=>{vo.init(t,e),t._zod.pattern=t._zod.bag.pattern??ebe,t._zod.parse=(r,n)=>{if(e.coerce)try{r.value=Number(r.value)}catch{}const s=r.value;if(typeof s=="number"&&!Number.isNaN(s)&&Number.isFinite(s))return r;const o=typeof s=="number"?Number.isNaN(s)?"NaN":Number.isFinite(s)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:s,inst:t,...o?{received:o}:{}}),r}}),eHe=Nr("$ZodNumberFormat",(t,e)=>{g7e.init(t,e),ibe.init(t,e)}),tHe=Nr("$ZodBoolean",(t,e)=>{vo.init(t,e),t._zod.pattern=h7e,t._zod.parse=(r,n)=>{if(e.coerce)try{r.value=!!r.value}catch{}const s=r.value;return typeof s=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:s,inst:t}),r}}),rHe=Nr("$ZodUnknown",(t,e)=>{vo.init(t,e),t._zod.parse=r=>r}),nHe=Nr("$ZodNever",(t,e)=>{vo.init(t,e),t._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:t}),r)});function Tse(t,e,r){t.issues.length&&e.issues.push(...q1(r,t.issues)),e.value[r]=t.value}const sHe=Nr("$ZodArray",(t,e)=>{vo.init(t,e),t._zod.parse=(r,n)=>{const s=r.value;if(!Array.isArray(s))return r.issues.push({expected:"array",code:"invalid_type",input:s,inst:t}),r;r.value=Array(s.length);const o=[];for(let c=0;cTse(m,r,c))):Tse(f,r,c)}return o.length?Promise.all(o).then(()=>r):r}});function sO(t,e,r,n,s,o){const c=r in n;if(t.issues.length){if(s&&o&&!c)return;e.issues.push(...q1(r,t.issues))}if(!c&&!s){t.issues.length||e.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}t.value===void 0?c&&(e.value[r]=void 0):e.value[r]=t.value}function abe(t){var n,s,o,c;const e=Object.keys(t.shape);for(const a of e)if(!((c=(o=(s=(n=t.shape)==null?void 0:n[a])==null?void 0:s._zod)==null?void 0:o.traits)!=null&&c.has("$ZodType")))throw new Error(`Invalid element at key "${a}": expected a Zod schema`);const r=bGe(t.shape);return{...t,keys:e,keySet:new Set(e),numKeys:e.length,optionalKeys:new Set(r)}}function obe(t,e,r,n,s,o){const c=[],a=s.keySet,f=s.catchall._zod,m=f.def.type,y=f.optin==="optional",_=f.optout==="optional";for(const w in e){if(w==="__proto__"||a.has(w))continue;if(m==="never"){c.push(w);continue}const E=f.run({value:e[w],issues:[]},n);E instanceof Promise?t.push(E.then(A=>sO(A,r,w,e,y,_))):sO(E,r,w,e,y,_)}return c.length&&r.issues.push({code:"unrecognized_keys",keys:c,input:e,inst:o}),t.length?Promise.all(t).then(()=>r):r}const iHe=Nr("$ZodObject",(t,e)=>{vo.init(t,e);const r=Object.getOwnPropertyDescriptor(e,"shape");if(!(r!=null&&r.get)){const a=e.shape;Object.defineProperty(e,"shape",{get:()=>{const f={...a};return Object.defineProperty(e,"shape",{value:f}),f}})}const n=IW(()=>abe(e));ca(t._zod,"propValues",()=>{const a=e.shape,f={};for(const m in a){const y=a[m]._zod;if(y.values){f[m]??(f[m]=new Set);for(const _ of y.values)f[m].add(_)}}return f});const s=nO,o=e.catchall;let c;t._zod.parse=(a,f)=>{c??(c=n.value);const m=a.value;if(!s(m))return a.issues.push({expected:"object",code:"invalid_type",input:m,inst:t}),a;a.value={};const y=[],_=c.shape;for(const w of c.keys){const E=_[w],A=E._zod.optin==="optional",C=E._zod.optout==="optional",I=E._zod.run({value:m[w],issues:[]},f);I instanceof Promise?y.push(I.then(M=>sO(M,a,w,m,A,C))):sO(I,a,w,m,A,C)}return o?obe(y,m,a,f,n.value,t):y.length?Promise.all(y).then(()=>a):a}}),aHe=Nr("$ZodObjectJIT",(t,e)=>{iHe.init(t,e);const r=t._zod.parse,n=IW(()=>abe(e)),s=w=>{var B,U;const E=new k7e(["shape","payload","ctx"]),A=n.value,C=q=>{const H=wse(q);return`shape[${H}]._zod.run({ value: input[${H}], issues: [] }, ctx)`};E.write("const input = payload.value;");const I=Object.create(null);let M=0;for(const q of A.keys)I[q]=`key_${M++}`;E.write("const newResult = {};");for(const q of A.keys){const H=I[q],K=wse(q),Q=w[q],J=((B=Q==null?void 0:Q._zod)==null?void 0:B.optin)==="optional",ee=((U=Q==null?void 0:Q._zod)==null?void 0:U.optout)==="optional";E.write(`const ${H} = ${C(q)};`),J&&ee?E.write(` if (${H}.issues.length) { if (${K} in input) { payload.issues = payload.issues.concat(${H}.issues.map(iss => ({ ...iss, path: iss.path ? [${K}, ...iss.path] : [${K}] }))); } } if (${H}.value === undefined) { if (${K} in input) { newResult[${K}] = undefined; } } else { newResult[${K}] = ${H}.value; } `):J?E.write(` if (${H}.issues.length) { payload.issues = payload.issues.concat(${H}.issues.map(iss => ({ ...iss, path: iss.path ? [${K}, ...iss.path] : [${K}] }))); } if (${H}.value === undefined) { if (${K} in input) { newResult[${K}] = undefined; } } else { newResult[${K}] = ${H}.value; } `):E.write(` const ${H}_present = ${K} in input; if (${H}.issues.length) { payload.issues = payload.issues.concat(${H}.issues.map(iss => ({ ...iss, path: iss.path ? [${K}, ...iss.path] : [${K}] }))); } if (!${H}_present && !${H}.issues.length) { payload.issues.push({ code: "invalid_type", expected: "nonoptional", input: undefined, path: [${K}] }); } if (${H}_present) { if (${H}.value === undefined) { newResult[${K}] = undefined; } else { newResult[${K}] = ${H}.value; } } `)}E.write("payload.value = newResult;"),E.write("return payload;");const D=E.compile();return(q,H)=>D(w,q,H)};let o;const c=nO,a=!CW.jitless,m=a&&_Ge.value,y=e.catchall;let _;t._zod.parse=(w,E)=>{_??(_=n.value);const A=w.value;return c(A)?a&&m&&(E==null?void 0:E.async)===!1&&E.jitless!==!0?(o||(o=s(e.shape)),w=o(w,E),y?obe([],A,w,E,_,t):w):r(w,E):(w.issues.push({expected:"object",code:"invalid_type",input:A,inst:t}),w)}});function Ese(t,e,r,n){for(const o of t)if(o.issues.length===0)return e.value=o.value,e;const s=t.filter(o=>!V1(o));return s.length===1?(e.value=s[0].value,s[0]):(e.issues.push({code:"invalid_union",input:e.value,inst:r,errors:t.map(o=>o.issues.map(c=>Ig(c,n,Cg())))}),e)}const oHe=Nr("$ZodUnion",(t,e)=>{vo.init(t,e),ca(t._zod,"optin",()=>e.options.some(n=>n._zod.optin==="optional")?"optional":void 0),ca(t._zod,"optout",()=>e.options.some(n=>n._zod.optout==="optional")?"optional":void 0),ca(t._zod,"values",()=>{if(e.options.every(n=>n._zod.values))return new Set(e.options.flatMap(n=>Array.from(n._zod.values)))}),ca(t._zod,"pattern",()=>{if(e.options.every(n=>n._zod.pattern)){const n=e.options.map(s=>s._zod.pattern);return new RegExp(`^(${n.map(s=>RW(s.source)).join("|")})$`)}});const r=e.options.length===1?e.options[0]._zod.run:null;t._zod.parse=(n,s)=>{if(r)return r(n,s);let o=!1;const c=[];for(const a of e.options){const f=a._zod.run({value:n.value,issues:[]},s);if(f instanceof Promise)c.push(f),o=!0;else{if(f.issues.length===0)return f;c.push(f)}}return o?Promise.all(c).then(a=>Ese(a,n,t,s)):Ese(c,n,t,s)}}),lHe=Nr("$ZodIntersection",(t,e)=>{vo.init(t,e),t._zod.parse=(r,n)=>{const s=r.value,o=e.left._zod.run({value:s,issues:[]},n),c=e.right._zod.run({value:s,issues:[]},n);return o instanceof Promise||c instanceof Promise?Promise.all([o,c]).then(([f,m])=>jse(r,f,m)):jse(r,o,c)}});function hq(t,e){if(t===e)return{valid:!0,data:t};if(t instanceof Date&&e instanceof Date&&+t==+e)return{valid:!0,data:t};if(JS(t)&&JS(e)){const r=Object.keys(e),n=Object.keys(t).filter(o=>r.indexOf(o)!==-1),s={...t,...e};for(const o of n){const c=hq(t[o],e[o]);if(!c.valid)return{valid:!1,mergeErrorPath:[o,...c.mergeErrorPath]};s[o]=c.data}return{valid:!0,data:s}}if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return{valid:!1,mergeErrorPath:[]};const r=[];for(let n=0;na.l&&a.r).map(([a])=>a);if(o.length&&s&&t.issues.push({...s,keys:o}),V1(t))return t;const c=hq(e.value,r.value);if(!c.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`);return t.value=c.data,t}const cHe=Nr("$ZodRecord",(t,e)=>{vo.init(t,e),t._zod.parse=(r,n)=>{const s=r.value;if(!JS(s))return r.issues.push({expected:"record",code:"invalid_type",input:s,inst:t}),r;const o=[],c=e.keyType._zod.values;if(c){r.value={};const a=new Set;for(const m of c)if(typeof m=="string"||typeof m=="number"||typeof m=="symbol"){a.add(typeof m=="number"?m.toString():m);const y=e.keyType._zod.run({value:m,issues:[]},n);if(y instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(y.issues.length){r.issues.push({code:"invalid_key",origin:"record",issues:y.issues.map(E=>Ig(E,n,Cg())),input:m,path:[m],inst:t});continue}const _=y.value,w=e.valueType._zod.run({value:s[m],issues:[]},n);w instanceof Promise?o.push(w.then(E=>{E.issues.length&&r.issues.push(...q1(m,E.issues)),r.value[_]=E.value})):(w.issues.length&&r.issues.push(...q1(m,w.issues)),r.value[_]=w.value)}let f;for(const m in s)a.has(m)||(f=f??[],f.push(m));f&&f.length>0&&r.issues.push({code:"unrecognized_keys",input:s,inst:t,keys:f})}else{r.value={};for(const a of Reflect.ownKeys(s)){if(a==="__proto__"||!Object.prototype.propertyIsEnumerable.call(s,a))continue;let f=e.keyType._zod.run({value:a,issues:[]},n);if(f instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof a=="string"&&ebe.test(a)&&f.issues.length){const _=e.keyType._zod.run({value:Number(a),issues:[]},n);if(_ instanceof Promise)throw new Error("Async schemas not supported in object keys currently");_.issues.length===0&&(f=_)}if(f.issues.length){e.mode==="loose"?r.value[a]=s[a]:r.issues.push({code:"invalid_key",origin:"record",issues:f.issues.map(_=>Ig(_,n,Cg())),input:a,path:[a],inst:t});continue}const y=e.valueType._zod.run({value:s[a],issues:[]},n);y instanceof Promise?o.push(y.then(_=>{_.issues.length&&r.issues.push(...q1(a,_.issues)),r.value[f.value]=_.value})):(y.issues.length&&r.issues.push(...q1(a,y.issues)),r.value[f.value]=y.value)}}return o.length?Promise.all(o).then(()=>r):r}}),uHe=Nr("$ZodEnum",(t,e)=>{vo.init(t,e);const r=Gve(e.entries),n=new Set(r);t._zod.values=n,t._zod.pattern=new RegExp(`^(${r.filter(s=>vGe.has(typeof s)).map(s=>typeof s=="string"?eT(s):s.toString()).join("|")})$`),t._zod.parse=(s,o)=>{const c=s.value;return n.has(c)||s.issues.push({code:"invalid_value",values:r,input:c,inst:t}),s}}),dHe=Nr("$ZodLiteral",(t,e)=>{if(vo.init(t,e),e.values.length===0)throw new Error("Cannot create literal schema with no valid values");const r=new Set(e.values);t._zod.values=r,t._zod.pattern=new RegExp(`^(${e.values.map(n=>typeof n=="string"?eT(n):n?eT(n.toString()):String(n)).join("|")})$`),t._zod.parse=(n,s)=>{const o=n.value;return r.has(o)||n.issues.push({code:"invalid_value",values:e.values,input:o,inst:t}),n}}),hHe=Nr("$ZodTransform",(t,e)=>{vo.init(t,e),t._zod.optin="optional",t._zod.parse=(r,n)=>{if(n.direction==="backward")throw new qve(t.constructor.name);const s=e.transform(r.value,r);if(n.async)return(s instanceof Promise?s:Promise.resolve(s)).then(c=>(r.value=c,r.fallback=!0,r));if(s instanceof Promise)throw new mS;return r.value=s,r.fallback=!0,r}});function kse(t,e){return e===void 0&&(t.issues.length||t.fallback)?{issues:[],value:void 0}:t}const lbe=Nr("$ZodOptional",(t,e)=>{vo.init(t,e),t._zod.optin="optional",t._zod.optout="optional",ca(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,void 0]):void 0),ca(t._zod,"pattern",()=>{const r=e.innerType._zod.pattern;return r?new RegExp(`^(${RW(r.source)})?$`):void 0}),t._zod.parse=(r,n)=>{if(e.innerType._zod.optin==="optional"){const s=r.value,o=e.innerType._zod.run(r,n);return o instanceof Promise?o.then(c=>kse(c,s)):kse(o,s)}return r.value===void 0?r:e.innerType._zod.run(r,n)}}),fHe=Nr("$ZodExactOptional",(t,e)=>{lbe.init(t,e),ca(t._zod,"values",()=>e.innerType._zod.values),ca(t._zod,"pattern",()=>e.innerType._zod.pattern),t._zod.parse=(r,n)=>e.innerType._zod.run(r,n)}),mHe=Nr("$ZodNullable",(t,e)=>{vo.init(t,e),ca(t._zod,"optin",()=>e.innerType._zod.optin),ca(t._zod,"optout",()=>e.innerType._zod.optout),ca(t._zod,"pattern",()=>{const r=e.innerType._zod.pattern;return r?new RegExp(`^(${RW(r.source)}|null)$`):void 0}),ca(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,null]):void 0),t._zod.parse=(r,n)=>r.value===null?r:e.innerType._zod.run(r,n)}),pHe=Nr("$ZodDefault",(t,e)=>{vo.init(t,e),t._zod.optin="optional",ca(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(r,n)=>{if(n.direction==="backward")return e.innerType._zod.run(r,n);if(r.value===void 0)return r.value=e.defaultValue,r;const s=e.innerType._zod.run(r,n);return s instanceof Promise?s.then(o=>Ase(o,e)):Ase(s,e)}});function Ase(t,e){return t.value===void 0&&(t.value=e.defaultValue),t}const gHe=Nr("$ZodPrefault",(t,e)=>{vo.init(t,e),t._zod.optin="optional",ca(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(r,n)=>(n.direction==="backward"||r.value===void 0&&(r.value=e.defaultValue),e.innerType._zod.run(r,n))}),yHe=Nr("$ZodNonOptional",(t,e)=>{vo.init(t,e),ca(t._zod,"values",()=>{const r=e.innerType._zod.values;return r?new Set([...r].filter(n=>n!==void 0)):void 0}),t._zod.parse=(r,n)=>{const s=e.innerType._zod.run(r,n);return s instanceof Promise?s.then(o=>Nse(o,t)):Nse(s,t)}});function Nse(t,e){return!t.issues.length&&t.value===void 0&&t.issues.push({code:"invalid_type",expected:"nonoptional",input:t.value,inst:e}),t}const xHe=Nr("$ZodCatch",(t,e)=>{vo.init(t,e),t._zod.optin="optional",ca(t._zod,"optout",()=>e.innerType._zod.optout),ca(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(r,n)=>{if(n.direction==="backward")return e.innerType._zod.run(r,n);const s=e.innerType._zod.run(r,n);return s instanceof Promise?s.then(o=>(r.value=o.value,o.issues.length&&(r.value=e.catchValue({...r,error:{issues:o.issues.map(c=>Ig(c,n,Cg()))},input:r.value}),r.issues=[],r.fallback=!0),r)):(r.value=s.value,s.issues.length&&(r.value=e.catchValue({...r,error:{issues:s.issues.map(o=>Ig(o,n,Cg()))},input:r.value}),r.issues=[],r.fallback=!0),r)}}),_He=Nr("$ZodPipe",(t,e)=>{vo.init(t,e),ca(t._zod,"values",()=>e.in._zod.values),ca(t._zod,"optin",()=>e.in._zod.optin),ca(t._zod,"optout",()=>e.out._zod.optout),ca(t._zod,"propValues",()=>e.in._zod.propValues),t._zod.parse=(r,n)=>{if(n.direction==="backward"){const o=e.out._zod.run(r,n);return o instanceof Promise?o.then(c=>hL(c,e.in,n)):hL(o,e.in,n)}const s=e.in._zod.run(r,n);return s instanceof Promise?s.then(o=>hL(o,e.out,n)):hL(s,e.out,n)}});function hL(t,e,r){return t.issues.length?(t.aborted=!0,t):e._zod.run({value:t.value,issues:t.issues,fallback:t.fallback},r)}const vHe=Nr("$ZodReadonly",(t,e)=>{vo.init(t,e),ca(t._zod,"propValues",()=>e.innerType._zod.propValues),ca(t._zod,"values",()=>e.innerType._zod.values),ca(t._zod,"optin",()=>{var r,n;return(n=(r=e.innerType)==null?void 0:r._zod)==null?void 0:n.optin}),ca(t._zod,"optout",()=>{var r,n;return(n=(r=e.innerType)==null?void 0:r._zod)==null?void 0:n.optout}),t._zod.parse=(r,n)=>{if(n.direction==="backward")return e.innerType._zod.run(r,n);const s=e.innerType._zod.run(r,n);return s instanceof Promise?s.then(Cse):Cse(s)}});function Cse(t){return t.value=Object.freeze(t.value),t}const bHe=Nr("$ZodCustom",(t,e)=>{rd.init(t,e),vo.init(t,e),t._zod.parse=(r,n)=>r,t._zod.check=r=>{const n=r.value,s=e.fn(n);if(s instanceof Promise)return s.then(o=>Ise(o,r,n,t));Ise(s,r,n,t)}});function Ise(t,e,r,n){if(!t){const s={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(s.params=n._zod.def.params),e.issues.push(nN(s))}}var Pse;class wHe{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...r){const n=r[0];return this._map.set(e,n),n&&typeof n=="object"&&"id"in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){const r=this._map.get(e);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(e),this}get(e){const r=e._zod.parent;if(r){const n={...this.get(r)??{}};delete n.id;const s={...n,...this._map.get(e)};return Object.keys(s).length?s:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function SHe(){return new wHe}(Pse=globalThis).__zod_globalRegistry??(Pse.__zod_globalRegistry=SHe());const Mk=globalThis.__zod_globalRegistry;function THe(t,e){return new t({type:"string",...Yn(e)})}function EHe(t,e){return new t({type:"string",format:"email",check:"string_format",abort:!1,...Yn(e)})}function Rse(t,e){return new t({type:"string",format:"guid",check:"string_format",abort:!1,...Yn(e)})}function jHe(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,...Yn(e)})}function kHe(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...Yn(e)})}function AHe(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...Yn(e)})}function NHe(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...Yn(e)})}function CHe(t,e){return new t({type:"string",format:"url",check:"string_format",abort:!1,...Yn(e)})}function IHe(t,e){return new t({type:"string",format:"emoji",check:"string_format",abort:!1,...Yn(e)})}function PHe(t,e){return new t({type:"string",format:"nanoid",check:"string_format",abort:!1,...Yn(e)})}function RHe(t,e){return new t({type:"string",format:"cuid",check:"string_format",abort:!1,...Yn(e)})}function LHe(t,e){return new t({type:"string",format:"cuid2",check:"string_format",abort:!1,...Yn(e)})}function MHe(t,e){return new t({type:"string",format:"ulid",check:"string_format",abort:!1,...Yn(e)})}function DHe(t,e){return new t({type:"string",format:"xid",check:"string_format",abort:!1,...Yn(e)})}function OHe(t,e){return new t({type:"string",format:"ksuid",check:"string_format",abort:!1,...Yn(e)})}function FHe(t,e){return new t({type:"string",format:"ipv4",check:"string_format",abort:!1,...Yn(e)})}function BHe(t,e){return new t({type:"string",format:"ipv6",check:"string_format",abort:!1,...Yn(e)})}function $He(t,e){return new t({type:"string",format:"cidrv4",check:"string_format",abort:!1,...Yn(e)})}function zHe(t,e){return new t({type:"string",format:"cidrv6",check:"string_format",abort:!1,...Yn(e)})}function UHe(t,e){return new t({type:"string",format:"base64",check:"string_format",abort:!1,...Yn(e)})}function VHe(t,e){return new t({type:"string",format:"base64url",check:"string_format",abort:!1,...Yn(e)})}function qHe(t,e){return new t({type:"string",format:"e164",check:"string_format",abort:!1,...Yn(e)})}function GHe(t,e){return new t({type:"string",format:"jwt",check:"string_format",abort:!1,...Yn(e)})}function HHe(t,e){return new t({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...Yn(e)})}function WHe(t,e){return new t({type:"string",format:"date",check:"string_format",...Yn(e)})}function KHe(t,e){return new t({type:"string",format:"time",check:"string_format",precision:null,...Yn(e)})}function YHe(t,e){return new t({type:"string",format:"duration",check:"string_format",...Yn(e)})}function ZHe(t,e){return new t({type:"number",checks:[],...Yn(e)})}function XHe(t,e){return new t({type:"number",check:"number_format",abort:!1,format:"safeint",...Yn(e)})}function QHe(t,e){return new t({type:"boolean",...Yn(e)})}function JHe(t){return new t({type:"unknown"})}function eWe(t,e){return new t({type:"never",...Yn(e)})}function Lse(t,e){return new rbe({check:"less_than",...Yn(e),value:t,inclusive:!1})}function i6(t,e){return new rbe({check:"less_than",...Yn(e),value:t,inclusive:!0})}function Mse(t,e){return new nbe({check:"greater_than",...Yn(e),value:t,inclusive:!1})}function a6(t,e){return new nbe({check:"greater_than",...Yn(e),value:t,inclusive:!0})}function Dse(t,e){return new p7e({check:"multiple_of",...Yn(e),value:t})}function cbe(t,e){return new y7e({check:"max_length",...Yn(e),maximum:t})}function iO(t,e){return new x7e({check:"min_length",...Yn(e),minimum:t})}function ube(t,e){return new _7e({check:"length_equals",...Yn(e),length:t})}function tWe(t,e){return new v7e({check:"string_format",format:"regex",...Yn(e),pattern:t})}function rWe(t){return new b7e({check:"string_format",format:"lowercase",...Yn(t)})}function nWe(t){return new w7e({check:"string_format",format:"uppercase",...Yn(t)})}function sWe(t,e){return new S7e({check:"string_format",format:"includes",...Yn(e),includes:t})}function iWe(t,e){return new T7e({check:"string_format",format:"starts_with",...Yn(e),prefix:t})}function aWe(t,e){return new E7e({check:"string_format",format:"ends_with",...Yn(e),suffix:t})}function sE(t){return new j7e({check:"overwrite",tx:t})}function oWe(t){return sE(e=>e.normalize(t))}function lWe(){return sE(t=>t.trim())}function cWe(){return sE(t=>t.toLowerCase())}function uWe(){return sE(t=>t.toUpperCase())}function dWe(){return sE(t=>xGe(t))}function hWe(t,e,r){return new t({type:"array",element:e,...Yn(r)})}function fWe(t,e,r){return new t({type:"custom",check:"custom",fn:e,...Yn(r)})}function mWe(t,e){const r=pWe(n=>(n.addIssue=s=>{if(typeof s=="string")n.issues.push(nN(s,n.value,r._zod.def));else{const o=s;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=n.value),o.inst??(o.inst=r),o.continue??(o.continue=!r._zod.def.abort),n.issues.push(nN(o))}},t(n.value,n)),e);return r}function pWe(t,e){const r=new rd({check:"custom",...Yn(e)});return r._zod.check=t,r}function dbe(t){let e=(t==null?void 0:t.target)??"draft-2020-12";return e==="draft-4"&&(e="draft-04"),e==="draft-7"&&(e="draft-07"),{processors:t.processors??{},metadataRegistry:(t==null?void 0:t.metadata)??Mk,target:e,unrepresentable:(t==null?void 0:t.unrepresentable)??"throw",override:(t==null?void 0:t.override)??(()=>{}),io:(t==null?void 0:t.io)??"output",counter:0,seen:new Map,cycles:(t==null?void 0:t.cycles)??"ref",reused:(t==null?void 0:t.reused)??"inline",external:(t==null?void 0:t.external)??void 0}}function al(t,e,r={path:[],schemaPath:[]}){var y,_;var n;const s=t._zod.def,o=e.seen.get(t);if(o)return o.count++,r.schemaPath.includes(t)&&(o.cycle=r.path),o.schema;const c={schema:{},count:1,cycle:void 0,path:r.path};e.seen.set(t,c);const a=(_=(y=t._zod).toJSONSchema)==null?void 0:_.call(y);if(a)c.schema=a;else{const w={...r,schemaPath:[...r.schemaPath,t],path:r.path};if(t._zod.processJSONSchema)t._zod.processJSONSchema(e,c.schema,w);else{const A=c.schema,C=e.processors[s.type];if(!C)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${s.type}`);C(t,e,A,w)}const E=t._zod.parent;E&&(c.ref||(c.ref=E),al(E,e,w),e.seen.get(E).isParent=!0)}const f=e.metadataRegistry.get(t);return f&&Object.assign(c.schema,f),e.io==="input"&&iu(t)&&(delete c.schema.examples,delete c.schema.default),e.io==="input"&&"_prefault"in c.schema&&((n=c.schema).default??(n.default=c.schema._prefault)),delete c.schema._prefault,e.seen.get(t).schema}function hbe(t,e){var c,a,f,m;const r=t.seen.get(e);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");const n=new Map;for(const y of t.seen.entries()){const _=(c=t.metadataRegistry.get(y[0]))==null?void 0:c.id;if(_){const w=n.get(_);if(w&&w!==y[0])throw new Error(`Duplicate schema id "${_}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);n.set(_,y[0])}}const s=y=>{var C;const _=t.target==="draft-2020-12"?"$defs":"definitions";if(t.external){const I=(C=t.external.registry.get(y[0]))==null?void 0:C.id,M=t.external.uri??(B=>B);if(I)return{ref:M(I)};const D=y[1].defId??y[1].schema.id??`schema${t.counter++}`;return y[1].defId=D,{defId:D,ref:`${M("__shared")}#/${_}/${D}`}}if(y[1]===r)return{ref:"#"};const E=`#/${_}/`,A=y[1].schema.id??`__schema${t.counter++}`;return{defId:A,ref:E+A}},o=y=>{if(y[1].schema.$ref)return;const _=y[1],{ref:w,defId:E}=s(y);_.def={..._.schema},E&&(_.defId=E);const A=_.schema;for(const C in A)delete A[C];A.$ref=w};if(t.cycles==="throw")for(const y of t.seen.entries()){const _=y[1];if(_.cycle)throw new Error(`Cycle detected: #/${(a=_.cycle)==null?void 0:a.join("/")}/ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const y of t.seen.entries()){const _=y[1];if(e===y[0]){o(y);continue}if(t.external){const E=(f=t.external.registry.get(y[0]))==null?void 0:f.id;if(e!==y[0]&&E){o(y);continue}}if((m=t.metadataRegistry.get(y[0]))==null?void 0:m.id){o(y);continue}if(_.cycle){o(y);continue}if(_.count>1&&t.reused==="ref"){o(y);continue}}}function fbe(t,e){var a,f,m,y;const r=t.seen.get(e);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");const n=_=>{const w=t.seen.get(_);if(w.ref===null)return;const E=w.def??w.schema,A={...E},C=w.ref;if(w.ref=null,C){n(C);const M=t.seen.get(C),D=M.schema;if(D.$ref&&(t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0")?(E.allOf=E.allOf??[],E.allOf.push(D)):Object.assign(E,D),Object.assign(E,A),_._zod.parent===C)for(const U in E)U==="$ref"||U==="allOf"||U in A||delete E[U];if(D.$ref&&M.def)for(const U in E)U==="$ref"||U==="allOf"||U in M.def&&JSON.stringify(E[U])===JSON.stringify(M.def[U])&&delete E[U]}const I=_._zod.parent;if(I&&I!==C){n(I);const M=t.seen.get(I);if(M!=null&&M.schema.$ref&&(E.$ref=M.schema.$ref,M.def))for(const D in E)D==="$ref"||D==="allOf"||D in M.def&&JSON.stringify(E[D])===JSON.stringify(M.def[D])&&delete E[D]}t.override({zodSchema:_,jsonSchema:E,path:w.path??[]})};for(const _ of[...t.seen.entries()].reverse())n(_[0]);const s={};if(t.target==="draft-2020-12"?s.$schema="https://json-schema.org/draft/2020-12/schema":t.target==="draft-07"?s.$schema="http://json-schema.org/draft-07/schema#":t.target==="draft-04"?s.$schema="http://json-schema.org/draft-04/schema#":t.target,(a=t.external)!=null&&a.uri){const _=(f=t.external.registry.get(e))==null?void 0:f.id;if(!_)throw new Error("Schema is missing an `id` property");s.$id=t.external.uri(_)}Object.assign(s,r.def??r.schema);const o=(m=t.metadataRegistry.get(e))==null?void 0:m.id;o!==void 0&&s.id===o&&delete s.id;const c=((y=t.external)==null?void 0:y.defs)??{};for(const _ of t.seen.entries()){const w=_[1];w.def&&w.defId&&(w.def.id===w.defId&&delete w.def.id,c[w.defId]=w.def)}t.external||Object.keys(c).length>0&&(t.target==="draft-2020-12"?s.$defs=c:s.definitions=c);try{const _=JSON.parse(JSON.stringify(s));return Object.defineProperty(_,"~standard",{value:{...e["~standard"],jsonSchema:{input:aO(e,"input",t.processors),output:aO(e,"output",t.processors)}},enumerable:!1,writable:!1}),_}catch{throw new Error("Error converting schema to JSON.")}}function iu(t,e){const r=e??{seen:new Set};if(r.seen.has(t))return!1;r.seen.add(t);const n=t._zod.def;if(n.type==="transform")return!0;if(n.type==="array")return iu(n.element,r);if(n.type==="set")return iu(n.valueType,r);if(n.type==="lazy")return iu(n.getter(),r);if(n.type==="promise"||n.type==="optional"||n.type==="nonoptional"||n.type==="nullable"||n.type==="readonly"||n.type==="default"||n.type==="prefault")return iu(n.innerType,r);if(n.type==="intersection")return iu(n.left,r)||iu(n.right,r);if(n.type==="record"||n.type==="map")return iu(n.keyType,r)||iu(n.valueType,r);if(n.type==="pipe")return t._zod.traits.has("$ZodCodec")?!0:iu(n.in,r)||iu(n.out,r);if(n.type==="object"){for(const s in n.shape)if(iu(n.shape[s],r))return!0;return!1}if(n.type==="union"){for(const s of n.options)if(iu(s,r))return!0;return!1}if(n.type==="tuple"){for(const s of n.items)if(iu(s,r))return!0;return!!(n.rest&&iu(n.rest,r))}return!1}const gWe=(t,e={})=>r=>{const n=dbe({...r,processors:e});return al(t,n),hbe(n,t),fbe(n,t)},aO=(t,e,r={})=>n=>{const{libraryOptions:s,target:o}=n??{},c=dbe({...s??{},target:o,io:e,processors:r});return al(t,c),hbe(c,t),fbe(c,t)},yWe={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},xWe=(t,e,r,n)=>{const s=r;s.type="string";const{minimum:o,maximum:c,format:a,patterns:f,contentEncoding:m}=t._zod.bag;if(typeof o=="number"&&(s.minLength=o),typeof c=="number"&&(s.maxLength=c),a&&(s.format=yWe[a]??a,s.format===""&&delete s.format,a==="time"&&delete s.format),m&&(s.contentEncoding=m),f&&f.size>0){const y=[...f];y.length===1?s.pattern=y[0].source:y.length>1&&(s.allOf=[...y.map(_=>({...e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"?{type:"string"}:{},pattern:_.source}))])}},_We=(t,e,r,n)=>{const s=r,{minimum:o,maximum:c,format:a,multipleOf:f,exclusiveMaximum:m,exclusiveMinimum:y}=t._zod.bag;typeof a=="string"&&a.includes("int")?s.type="integer":s.type="number";const _=typeof y=="number"&&y>=(o??Number.NEGATIVE_INFINITY),w=typeof m=="number"&&m<=(c??Number.POSITIVE_INFINITY),E=e.target==="draft-04"||e.target==="openapi-3.0";_?E?(s.minimum=y,s.exclusiveMinimum=!0):s.exclusiveMinimum=y:typeof o=="number"&&(s.minimum=o),w?E?(s.maximum=m,s.exclusiveMaximum=!0):s.exclusiveMaximum=m:typeof c=="number"&&(s.maximum=c),typeof f=="number"&&(s.multipleOf=f)},vWe=(t,e,r,n)=>{r.type="boolean"},bWe=(t,e,r,n)=>{r.not={}},wWe=(t,e,r,n)=>{},SWe=(t,e,r,n)=>{const s=t._zod.def,o=Gve(s.entries);o.every(c=>typeof c=="number")&&(r.type="number"),o.every(c=>typeof c=="string")&&(r.type="string"),r.enum=o},TWe=(t,e,r,n)=>{const s=t._zod.def,o=[];for(const c of s.values)if(c===void 0){if(e.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof c=="bigint"){if(e.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");o.push(Number(c))}else o.push(c);if(o.length!==0)if(o.length===1){const c=o[0];r.type=c===null?"null":typeof c,e.target==="draft-04"||e.target==="openapi-3.0"?r.enum=[c]:r.const=c}else o.every(c=>typeof c=="number")&&(r.type="number"),o.every(c=>typeof c=="string")&&(r.type="string"),o.every(c=>typeof c=="boolean")&&(r.type="boolean"),o.every(c=>c===null)&&(r.type="null"),r.enum=o},EWe=(t,e,r,n)=>{if(e.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},jWe=(t,e,r,n)=>{if(e.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},kWe=(t,e,r,n)=>{const s=r,o=t._zod.def,{minimum:c,maximum:a}=t._zod.bag;typeof c=="number"&&(s.minItems=c),typeof a=="number"&&(s.maxItems=a),s.type="array",s.items=al(o.element,e,{...n,path:[...n.path,"items"]})},AWe=(t,e,r,n)=>{var m;const s=r,o=t._zod.def;s.type="object",s.properties={};const c=o.shape;for(const y in c)s.properties[y]=al(c[y],e,{...n,path:[...n.path,"properties",y]});const a=new Set(Object.keys(c)),f=new Set([...a].filter(y=>{const _=o.shape[y]._zod;return e.io==="input"?_.optin===void 0:_.optout===void 0}));f.size>0&&(s.required=Array.from(f)),((m=o.catchall)==null?void 0:m._zod.def.type)==="never"?s.additionalProperties=!1:o.catchall?o.catchall&&(s.additionalProperties=al(o.catchall,e,{...n,path:[...n.path,"additionalProperties"]})):e.io==="output"&&(s.additionalProperties=!1)},NWe=(t,e,r,n)=>{const s=t._zod.def,o=s.inclusive===!1,c=s.options.map((a,f)=>al(a,e,{...n,path:[...n.path,o?"oneOf":"anyOf",f]}));o?r.oneOf=c:r.anyOf=c},CWe=(t,e,r,n)=>{const s=t._zod.def,o=al(s.left,e,{...n,path:[...n.path,"allOf",0]}),c=al(s.right,e,{...n,path:[...n.path,"allOf",1]}),a=m=>"allOf"in m&&Object.keys(m).length===1,f=[...a(o)?o.allOf:[o],...a(c)?c.allOf:[c]];r.allOf=f},IWe=(t,e,r,n)=>{const s=r,o=t._zod.def;s.type="object";const c=o.keyType,a=c._zod.bag,f=a==null?void 0:a.patterns;if(o.mode==="loose"&&f&&f.size>0){const y=al(o.valueType,e,{...n,path:[...n.path,"patternProperties","*"]});s.patternProperties={};for(const _ of f)s.patternProperties[_.source]=y}else(e.target==="draft-07"||e.target==="draft-2020-12")&&(s.propertyNames=al(o.keyType,e,{...n,path:[...n.path,"propertyNames"]})),s.additionalProperties=al(o.valueType,e,{...n,path:[...n.path,"additionalProperties"]});const m=c._zod.values;if(m){const y=[...m].filter(_=>typeof _=="string"||typeof _=="number");y.length>0&&(s.required=y)}},PWe=(t,e,r,n)=>{const s=t._zod.def,o=al(s.innerType,e,n),c=e.seen.get(t);e.target==="openapi-3.0"?(c.ref=s.innerType,r.nullable=!0):r.anyOf=[o,{type:"null"}]},RWe=(t,e,r,n)=>{const s=t._zod.def;al(s.innerType,e,n);const o=e.seen.get(t);o.ref=s.innerType},LWe=(t,e,r,n)=>{const s=t._zod.def;al(s.innerType,e,n);const o=e.seen.get(t);o.ref=s.innerType,r.default=JSON.parse(JSON.stringify(s.defaultValue))},MWe=(t,e,r,n)=>{const s=t._zod.def;al(s.innerType,e,n);const o=e.seen.get(t);o.ref=s.innerType,e.io==="input"&&(r._prefault=JSON.parse(JSON.stringify(s.defaultValue)))},DWe=(t,e,r,n)=>{const s=t._zod.def;al(s.innerType,e,n);const o=e.seen.get(t);o.ref=s.innerType;let c;try{c=s.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}r.default=c},OWe=(t,e,r,n)=>{const s=t._zod.def,o=s.in._zod.traits.has("$ZodTransform"),c=e.io==="input"?o?s.out:s.in:s.out;al(c,e,n);const a=e.seen.get(t);a.ref=c},FWe=(t,e,r,n)=>{const s=t._zod.def;al(s.innerType,e,n);const o=e.seen.get(t);o.ref=s.innerType,r.readOnly=!0},mbe=(t,e,r,n)=>{const s=t._zod.def;al(s.innerType,e,n);const o=e.seen.get(t);o.ref=s.innerType},BWe=Nr("ZodISODateTime",(t,e)=>{$7e.init(t,e),wo.init(t,e)});function $We(t){return HHe(BWe,t)}const zWe=Nr("ZodISODate",(t,e)=>{z7e.init(t,e),wo.init(t,e)});function UWe(t){return WHe(zWe,t)}const VWe=Nr("ZodISOTime",(t,e)=>{U7e.init(t,e),wo.init(t,e)});function qWe(t){return KHe(VWe,t)}const GWe=Nr("ZodISODuration",(t,e)=>{V7e.init(t,e),wo.init(t,e)});function HWe(t){return YHe(GWe,t)}const pbe=(t,e)=>{Yve.init(t,e),t.name="ZodError",Object.defineProperties(t,{format:{value:r=>PGe(t,r)},flatten:{value:r=>IGe(t,r)},addIssue:{value:r=>{t.issues.push(r),t.message=JSON.stringify(t.issues,dq,2)}},addIssues:{value:r=>{t.issues.push(...r),t.message=JSON.stringify(t.issues,dq,2)}},isEmpty:{get(){return t.issues.length===0}}})},WWe=Nr("ZodError",pbe),Mh=Nr("ZodError",pbe,{Parent:Error}),KWe=MW(Mh),YWe=DW(Mh),ZWe=U4(Mh),XWe=V4(Mh),QWe=MGe(Mh),JWe=DGe(Mh),eKe=OGe(Mh),tKe=FGe(Mh),rKe=BGe(Mh),nKe=$Ge(Mh),sKe=zGe(Mh),iKe=UGe(Mh),Ose=new WeakMap;function DC(t,e,r){const n=Object.getPrototypeOf(t);let s=Ose.get(n);if(s||(s=new Set,Ose.set(n,s)),!s.has(e)){s.add(e);for(const o in r){const c=r[o];Object.defineProperty(n,o,{configurable:!0,enumerable:!1,get(){const a=c.bind(this);return Object.defineProperty(this,o,{configurable:!0,writable:!0,enumerable:!0,value:a}),a},set(a){Object.defineProperty(this,o,{configurable:!0,writable:!0,enumerable:!0,value:a})}})}}}const bo=Nr("ZodType",(t,e)=>(vo.init(t,e),Object.assign(t["~standard"],{jsonSchema:{input:aO(t,"input"),output:aO(t,"output")}}),t.toJSONSchema=gWe(t,{}),t.def=e,t.type=e.type,Object.defineProperty(t,"_def",{value:e}),t.parse=(r,n)=>KWe(t,r,n,{callee:t.parse}),t.safeParse=(r,n)=>ZWe(t,r,n),t.parseAsync=async(r,n)=>YWe(t,r,n,{callee:t.parseAsync}),t.safeParseAsync=async(r,n)=>XWe(t,r,n),t.spa=t.safeParseAsync,t.encode=(r,n)=>QWe(t,r,n),t.decode=(r,n)=>JWe(t,r,n),t.encodeAsync=async(r,n)=>eKe(t,r,n),t.decodeAsync=async(r,n)=>tKe(t,r,n),t.safeEncode=(r,n)=>rKe(t,r,n),t.safeDecode=(r,n)=>nKe(t,r,n),t.safeEncodeAsync=async(r,n)=>sKe(t,r,n),t.safeDecodeAsync=async(r,n)=>iKe(t,r,n),DC(t,"ZodType",{check(...r){const n=this.def;return this.clone(h0(n,{checks:[...n.checks??[],...r.map(s=>typeof s=="function"?{_zod:{check:s,def:{check:"custom"},onattach:[]}}:s)]}),{parent:!0})},with(...r){return this.check(...r)},clone(r,n){return f0(this,r,n)},brand(){return this},register(r,n){return r.add(this,n),this},refine(r,n){return this.check(tYe(r,n))},superRefine(r,n){return this.check(rYe(r,n))},overwrite(r){return this.check(sE(r))},optional(){return zse(this)},exactOptional(){return UKe(this)},nullable(){return Use(this)},nullish(){return zse(Use(this))},nonoptional(r){return KKe(this,r)},array(){return IKe(this)},or(r){return LKe([this,r])},and(r){return DKe(this,r)},transform(r){return Vse(this,$Ke(r))},default(r){return GKe(this,r)},prefault(r){return WKe(this,r)},catch(r){return ZKe(this,r)},pipe(r){return Vse(this,r)},readonly(){return JKe(this)},describe(r){const n=this.clone();return Mk.add(n,{description:r}),n},meta(...r){if(r.length===0)return Mk.get(this);const n=this.clone();return Mk.add(n,r[0]),n},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(r){return r(this)}}),Object.defineProperty(t,"description",{get(){var r;return(r=Mk.get(t))==null?void 0:r.description},configurable:!0}),t)),gbe=Nr("_ZodString",(t,e)=>{OW.init(t,e),bo.init(t,e),t._zod.processJSONSchema=(n,s,o)=>xWe(t,n,s);const r=t._zod.bag;t.format=r.format??null,t.minLength=r.minimum??null,t.maxLength=r.maximum??null,DC(t,"_ZodString",{regex(...n){return this.check(tWe(...n))},includes(...n){return this.check(sWe(...n))},startsWith(...n){return this.check(iWe(...n))},endsWith(...n){return this.check(aWe(...n))},min(...n){return this.check(iO(...n))},max(...n){return this.check(cbe(...n))},length(...n){return this.check(ube(...n))},nonempty(...n){return this.check(iO(1,...n))},lowercase(n){return this.check(rWe(n))},uppercase(n){return this.check(nWe(n))},trim(){return this.check(lWe())},normalize(...n){return this.check(oWe(...n))},toLowerCase(){return this.check(cWe())},toUpperCase(){return this.check(uWe())},slugify(){return this.check(dWe())}})}),aKe=Nr("ZodString",(t,e)=>{OW.init(t,e),gbe.init(t,e),t.email=r=>t.check(EHe(oKe,r)),t.url=r=>t.check(CHe(lKe,r)),t.jwt=r=>t.check(GHe(SKe,r)),t.emoji=r=>t.check(IHe(cKe,r)),t.guid=r=>t.check(Rse(Fse,r)),t.uuid=r=>t.check(jHe(fL,r)),t.uuidv4=r=>t.check(kHe(fL,r)),t.uuidv6=r=>t.check(AHe(fL,r)),t.uuidv7=r=>t.check(NHe(fL,r)),t.nanoid=r=>t.check(PHe(uKe,r)),t.guid=r=>t.check(Rse(Fse,r)),t.cuid=r=>t.check(RHe(dKe,r)),t.cuid2=r=>t.check(LHe(hKe,r)),t.ulid=r=>t.check(MHe(fKe,r)),t.base64=r=>t.check(UHe(vKe,r)),t.base64url=r=>t.check(VHe(bKe,r)),t.xid=r=>t.check(DHe(mKe,r)),t.ksuid=r=>t.check(OHe(pKe,r)),t.ipv4=r=>t.check(FHe(gKe,r)),t.ipv6=r=>t.check(BHe(yKe,r)),t.cidrv4=r=>t.check($He(xKe,r)),t.cidrv6=r=>t.check(zHe(_Ke,r)),t.e164=r=>t.check(qHe(wKe,r)),t.datetime=r=>t.check($We(r)),t.date=r=>t.check(UWe(r)),t.time=r=>t.check(qWe(r)),t.duration=r=>t.check(HWe(r))});function Ds(t){return THe(aKe,t)}const wo=Nr("ZodStringFormat",(t,e)=>{to.init(t,e),gbe.init(t,e)}),oKe=Nr("ZodEmail",(t,e)=>{I7e.init(t,e),wo.init(t,e)}),Fse=Nr("ZodGUID",(t,e)=>{N7e.init(t,e),wo.init(t,e)}),fL=Nr("ZodUUID",(t,e)=>{C7e.init(t,e),wo.init(t,e)}),lKe=Nr("ZodURL",(t,e)=>{P7e.init(t,e),wo.init(t,e)}),cKe=Nr("ZodEmoji",(t,e)=>{R7e.init(t,e),wo.init(t,e)}),uKe=Nr("ZodNanoID",(t,e)=>{L7e.init(t,e),wo.init(t,e)}),dKe=Nr("ZodCUID",(t,e)=>{M7e.init(t,e),wo.init(t,e)}),hKe=Nr("ZodCUID2",(t,e)=>{D7e.init(t,e),wo.init(t,e)}),fKe=Nr("ZodULID",(t,e)=>{O7e.init(t,e),wo.init(t,e)}),mKe=Nr("ZodXID",(t,e)=>{F7e.init(t,e),wo.init(t,e)}),pKe=Nr("ZodKSUID",(t,e)=>{B7e.init(t,e),wo.init(t,e)}),gKe=Nr("ZodIPv4",(t,e)=>{q7e.init(t,e),wo.init(t,e)}),yKe=Nr("ZodIPv6",(t,e)=>{G7e.init(t,e),wo.init(t,e)}),xKe=Nr("ZodCIDRv4",(t,e)=>{H7e.init(t,e),wo.init(t,e)}),_Ke=Nr("ZodCIDRv6",(t,e)=>{W7e.init(t,e),wo.init(t,e)}),vKe=Nr("ZodBase64",(t,e)=>{K7e.init(t,e),wo.init(t,e)}),bKe=Nr("ZodBase64URL",(t,e)=>{Z7e.init(t,e),wo.init(t,e)}),wKe=Nr("ZodE164",(t,e)=>{X7e.init(t,e),wo.init(t,e)}),SKe=Nr("ZodJWT",(t,e)=>{J7e.init(t,e),wo.init(t,e)}),ybe=Nr("ZodNumber",(t,e)=>{ibe.init(t,e),bo.init(t,e),t._zod.processJSONSchema=(n,s,o)=>_We(t,n,s),DC(t,"ZodNumber",{gt(n,s){return this.check(Mse(n,s))},gte(n,s){return this.check(a6(n,s))},min(n,s){return this.check(a6(n,s))},lt(n,s){return this.check(Lse(n,s))},lte(n,s){return this.check(i6(n,s))},max(n,s){return this.check(i6(n,s))},int(n){return this.check(Bse(n))},safe(n){return this.check(Bse(n))},positive(n){return this.check(Mse(0,n))},nonnegative(n){return this.check(a6(0,n))},negative(n){return this.check(Lse(0,n))},nonpositive(n){return this.check(i6(0,n))},multipleOf(n,s){return this.check(Dse(n,s))},step(n,s){return this.check(Dse(n,s))},finite(){return this}});const r=t._zod.bag;t.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,t.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,t.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),t.isFinite=!0,t.format=r.format??null});function oA(t){return ZHe(ybe,t)}const TKe=Nr("ZodNumberFormat",(t,e)=>{eHe.init(t,e),ybe.init(t,e)});function Bse(t){return XHe(TKe,t)}const EKe=Nr("ZodBoolean",(t,e)=>{tHe.init(t,e),bo.init(t,e),t._zod.processJSONSchema=(r,n,s)=>vWe(t,r,n)});function jKe(t){return QHe(EKe,t)}const kKe=Nr("ZodUnknown",(t,e)=>{rHe.init(t,e),bo.init(t,e),t._zod.processJSONSchema=(r,n,s)=>wWe()});function fq(){return JHe(kKe)}const AKe=Nr("ZodNever",(t,e)=>{nHe.init(t,e),bo.init(t,e),t._zod.processJSONSchema=(r,n,s)=>bWe(t,r,n)});function NKe(t){return eWe(AKe,t)}const CKe=Nr("ZodArray",(t,e)=>{sHe.init(t,e),bo.init(t,e),t._zod.processJSONSchema=(r,n,s)=>kWe(t,r,n,s),t.element=e.element,DC(t,"ZodArray",{min(r,n){return this.check(iO(r,n))},nonempty(r){return this.check(iO(1,r))},max(r,n){return this.check(cbe(r,n))},length(r,n){return this.check(ube(r,n))},unwrap(){return this.element}})});function IKe(t,e){return hWe(CKe,t,e)}const PKe=Nr("ZodObject",(t,e)=>{aHe.init(t,e),bo.init(t,e),t._zod.processJSONSchema=(r,n,s)=>AWe(t,r,n,s),ca(t,"shape",()=>e.shape),DC(t,"ZodObject",{keyof(){return tT(Object.keys(this._zod.def.shape))},catchall(r){return this.clone({...this._zod.def,catchall:r})},passthrough(){return this.clone({...this._zod.def,catchall:fq()})},loose(){return this.clone({...this._zod.def,catchall:fq()})},strict(){return this.clone({...this._zod.def,catchall:NKe()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(r){return EGe(this,r)},safeExtend(r){return jGe(this,r)},merge(r){return kGe(this,r)},pick(r){return SGe(this,r)},omit(r){return TGe(this,r)},partial(...r){return AGe(xbe,this,r[0])},required(...r){return NGe(_be,this,r[0])}})});function zg(t,e){const r={type:"object",shape:t??{},...Yn(e)};return new PKe(r)}const RKe=Nr("ZodUnion",(t,e)=>{oHe.init(t,e),bo.init(t,e),t._zod.processJSONSchema=(r,n,s)=>NWe(t,r,n,s),t.options=e.options});function LKe(t,e){return new RKe({type:"union",options:t,...Yn(e)})}const MKe=Nr("ZodIntersection",(t,e)=>{lHe.init(t,e),bo.init(t,e),t._zod.processJSONSchema=(r,n,s)=>CWe(t,r,n,s)});function DKe(t,e){return new MKe({type:"intersection",left:t,right:e})}const $se=Nr("ZodRecord",(t,e)=>{cHe.init(t,e),bo.init(t,e),t._zod.processJSONSchema=(r,n,s)=>IWe(t,r,n,s),t.keyType=e.keyType,t.valueType=e.valueType});function OKe(t,e,r){return!e||!e._zod?new $se({type:"record",keyType:Ds(),valueType:t,...Yn(e)}):new $se({type:"record",keyType:t,valueType:e,...Yn(r)})}const mq=Nr("ZodEnum",(t,e)=>{uHe.init(t,e),bo.init(t,e),t._zod.processJSONSchema=(n,s,o)=>SWe(t,n,s),t.enum=e.entries,t.options=Object.values(e.entries);const r=new Set(Object.keys(e.entries));t.extract=(n,s)=>{const o={};for(const c of n)if(r.has(c))o[c]=e.entries[c];else throw new Error(`Key ${c} not found in enum`);return new mq({...e,checks:[],...Yn(s),entries:o})},t.exclude=(n,s)=>{const o={...e.entries};for(const c of n)if(r.has(c))delete o[c];else throw new Error(`Key ${c} not found in enum`);return new mq({...e,checks:[],...Yn(s),entries:o})}});function tT(t,e){const r=Array.isArray(t)?Object.fromEntries(t.map(n=>[n,n])):t;return new mq({type:"enum",entries:r,...Yn(e)})}const FKe=Nr("ZodLiteral",(t,e)=>{dHe.init(t,e),bo.init(t,e),t._zod.processJSONSchema=(r,n,s)=>TWe(t,r,n),t.values=new Set(e.values),Object.defineProperty(t,"value",{get(){if(e.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return e.values[0]}})});function oO(t,e){return new FKe({type:"literal",values:Array.isArray(t)?t:[t],...Yn(e)})}const BKe=Nr("ZodTransform",(t,e)=>{hHe.init(t,e),bo.init(t,e),t._zod.processJSONSchema=(r,n,s)=>jWe(t,r),t._zod.parse=(r,n)=>{if(n.direction==="backward")throw new qve(t.constructor.name);r.addIssue=o=>{if(typeof o=="string")r.issues.push(nN(o,r.value,e));else{const c=o;c.fatal&&(c.continue=!1),c.code??(c.code="custom"),c.input??(c.input=r.value),c.inst??(c.inst=t),r.issues.push(nN(c))}};const s=e.transform(r.value,r);return s instanceof Promise?s.then(o=>(r.value=o,r.fallback=!0,r)):(r.value=s,r.fallback=!0,r)}});function $Ke(t){return new BKe({type:"transform",transform:t})}const xbe=Nr("ZodOptional",(t,e)=>{lbe.init(t,e),bo.init(t,e),t._zod.processJSONSchema=(r,n,s)=>mbe(t,r,n,s),t.unwrap=()=>t._zod.def.innerType});function zse(t){return new xbe({type:"optional",innerType:t})}const zKe=Nr("ZodExactOptional",(t,e)=>{fHe.init(t,e),bo.init(t,e),t._zod.processJSONSchema=(r,n,s)=>mbe(t,r,n,s),t.unwrap=()=>t._zod.def.innerType});function UKe(t){return new zKe({type:"optional",innerType:t})}const VKe=Nr("ZodNullable",(t,e)=>{mHe.init(t,e),bo.init(t,e),t._zod.processJSONSchema=(r,n,s)=>PWe(t,r,n,s),t.unwrap=()=>t._zod.def.innerType});function Use(t){return new VKe({type:"nullable",innerType:t})}const qKe=Nr("ZodDefault",(t,e)=>{pHe.init(t,e),bo.init(t,e),t._zod.processJSONSchema=(r,n,s)=>LWe(t,r,n,s),t.unwrap=()=>t._zod.def.innerType,t.removeDefault=t.unwrap});function GKe(t,e){return new qKe({type:"default",innerType:t,get defaultValue(){return typeof e=="function"?e():Wve(e)}})}const HKe=Nr("ZodPrefault",(t,e)=>{gHe.init(t,e),bo.init(t,e),t._zod.processJSONSchema=(r,n,s)=>MWe(t,r,n,s),t.unwrap=()=>t._zod.def.innerType});function WKe(t,e){return new HKe({type:"prefault",innerType:t,get defaultValue(){return typeof e=="function"?e():Wve(e)}})}const _be=Nr("ZodNonOptional",(t,e)=>{yHe.init(t,e),bo.init(t,e),t._zod.processJSONSchema=(r,n,s)=>RWe(t,r,n,s),t.unwrap=()=>t._zod.def.innerType});function KKe(t,e){return new _be({type:"nonoptional",innerType:t,...Yn(e)})}const YKe=Nr("ZodCatch",(t,e)=>{xHe.init(t,e),bo.init(t,e),t._zod.processJSONSchema=(r,n,s)=>DWe(t,r,n,s),t.unwrap=()=>t._zod.def.innerType,t.removeCatch=t.unwrap});function ZKe(t,e){return new YKe({type:"catch",innerType:t,catchValue:typeof e=="function"?e:()=>e})}const XKe=Nr("ZodPipe",(t,e)=>{_He.init(t,e),bo.init(t,e),t._zod.processJSONSchema=(r,n,s)=>OWe(t,r,n,s),t.in=e.in,t.out=e.out});function Vse(t,e){return new XKe({type:"pipe",in:t,out:e})}const QKe=Nr("ZodReadonly",(t,e)=>{vHe.init(t,e),bo.init(t,e),t._zod.processJSONSchema=(r,n,s)=>FWe(t,r,n,s),t.unwrap=()=>t._zod.def.innerType});function JKe(t){return new QKe({type:"readonly",innerType:t})}const eYe=Nr("ZodCustom",(t,e)=>{bHe.init(t,e),bo.init(t,e),t._zod.processJSONSchema=(r,n,s)=>EWe(t,r)});function tYe(t,e={}){return fWe(eYe,t,e)}function rYe(t,e){return mWe(t,e)}var nYe="Label",vbe=N.forwardRef((t,e)=>i.jsx(cn.label,{...t,ref:e,onMouseDown:r=>{var s;r.target.closest("button, input, select, textarea")||((s=t.onMouseDown)==null||s.call(t,r),!r.defaultPrevented&&r.detail>1&&r.preventDefault())}}));vbe.displayName=nYe;var bbe=vbe;const sYe=zT("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Fr=N.forwardRef(({className:t,...e},r)=>i.jsx(bbe,{ref:r,className:Xt(sYe(),t),...e}));Fr.displayName=bbe.displayName;const FW=Z9e,wbe=N.createContext({}),vl=({...t})=>i.jsx(wbe.Provider,{value:{name:t.name},children:i.jsx(eGe,{...t})}),G4=()=>{const t=N.useContext(wbe),e=N.useContext(Sbe),{getFieldState:r,formState:n}=z4(),s=r(t.name,n);if(!t)throw new Error("useFormField should be used within ");const{id:o}=e;return{id:o,name:t.name,formItemId:`${o}-form-item`,formDescriptionId:`${o}-form-item-description`,formMessageId:`${o}-form-item-message`,...s}},Sbe=N.createContext({}),el=N.forwardRef(({className:t,...e},r)=>{const n=N.useId();return i.jsx(Sbe.Provider,{value:{id:n},children:i.jsx("div",{ref:r,className:Xt("space-y-2",t),...e})})});el.displayName="FormItem";const tl=N.forwardRef(({className:t,...e},r)=>{const{error:n,formItemId:s}=G4();return i.jsx(Fr,{ref:r,className:Xt(n&&"text-destructive",t),htmlFor:s,...e})});tl.displayName="FormLabel";const rl=N.forwardRef(({...t},e)=>{const{error:r,formItemId:n,formDescriptionId:s,formMessageId:o}=G4();return i.jsx(Tge,{ref:e,id:n,"aria-describedby":r?`${s} ${o}`:`${s}`,"aria-invalid":!!r,...t})});rl.displayName="FormControl";const LM=N.forwardRef(({className:t,...e},r)=>{const{formDescriptionId:n}=G4();return i.jsx("p",{ref:r,id:n,className:Xt("text-sm text-muted-foreground",t),...e})});LM.displayName="FormDescription";const Af=N.forwardRef(({className:t,children:e,...r},n)=>{const{error:s,formMessageId:o}=G4(),c=s?String(s==null?void 0:s.message):e;return c?i.jsx("p",{ref:n,id:o,className:Xt("text-sm font-medium text-destructive",t),...r,children:c}):null});Af.displayName="FormMessage";const Dr=N.forwardRef(({className:t,type:e,...r},n)=>i.jsx("input",{type:e,className:Xt("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",t),ref:n,...r}));Dr.displayName="Input";function OC(t){const e=N.useRef({value:t,previous:t});return N.useMemo(()=>(e.current.value!==t&&(e.current.previous=e.current.value,e.current.value=t),e.current.previous),[t])}var iYe=[" ","Enter","ArrowUp","ArrowDown"],aYe=[" ","Enter"],Vv="Select",[H4,W4,oYe]=mC(Vv),[iE,UQt]=cl(Vv,[oYe,l0]),K4=l0(),[lYe,m0]=iE(Vv),[cYe,uYe]=iE(Vv),Tbe=t=>{const{__scopeSelect:e,children:r,open:n,defaultOpen:s,onOpenChange:o,value:c,defaultValue:a,onValueChange:f,dir:m,name:y,autoComplete:_,disabled:w,required:E,form:A}=t,C=K4(e),[I,M]=N.useState(null),[D,B]=N.useState(null),[U,q]=N.useState(!1),H=ob(m),[K,Q]=ed({prop:n,defaultProp:s??!1,onChange:o,caller:Vv}),[J,ee]=ed({prop:c,defaultProp:a,onChange:f,caller:Vv}),oe=N.useRef(null),de=I?A||!!I.closest("form"):!0,[ye,Ee]=N.useState(new Set),Le=Array.from(ye).map(Se=>Se.props.value).join(";");return i.jsx(kC,{...C,children:i.jsxs(lYe,{required:E,scope:e,trigger:I,onTriggerChange:M,valueNode:D,onValueNodeChange:B,valueNodeHasChildren:U,onValueNodeHasChildrenChange:q,contentId:il(),value:J,onValueChange:ee,open:K,onOpenChange:Q,dir:H,triggerPointerDownPosRef:oe,disabled:w,children:[i.jsx(H4.Provider,{scope:e,children:i.jsx(cYe,{scope:t.__scopeSelect,onNativeOptionAdd:N.useCallback(Se=>{Ee(be=>new Set(be).add(Se))},[]),onNativeOptionRemove:N.useCallback(Se=>{Ee(be=>{const me=new Set(be);return me.delete(Se),me})},[]),children:r})}),de?i.jsxs(Ybe,{"aria-hidden":!0,required:E,tabIndex:-1,name:y,autoComplete:_,value:J,onChange:Se=>ee(Se.target.value),disabled:w,form:A,children:[J===void 0?i.jsx("option",{value:""}):null,Array.from(ye)]},Le):null]})})};Tbe.displayName=Vv;var Ebe="SelectTrigger",jbe=N.forwardRef((t,e)=>{const{__scopeSelect:r,disabled:n=!1,...s}=t,o=K4(r),c=m0(Ebe,r),a=c.disabled||n,f=is(e,c.onTriggerChange),m=W4(r),y=N.useRef("touch"),[_,w,E]=Xbe(C=>{const I=m().filter(B=>!B.disabled),M=I.find(B=>B.value===c.value),D=Qbe(I,C,M);D!==void 0&&c.onValueChange(D.value)}),A=C=>{a||(c.onOpenChange(!0),E()),C&&(c.triggerPointerDownPosRef.current={x:Math.round(C.pageX),y:Math.round(C.pageY)})};return i.jsx(AC,{asChild:!0,...o,children:i.jsx(cn.button,{type:"button",role:"combobox","aria-controls":c.contentId,"aria-expanded":c.open,"aria-required":c.required,"aria-autocomplete":"none",dir:c.dir,"data-state":c.open?"open":"closed",disabled:a,"data-disabled":a?"":void 0,"data-placeholder":Zbe(c.value)?"":void 0,...s,ref:f,onClick:Gr(s.onClick,C=>{C.currentTarget.focus(),y.current!=="mouse"&&A(C)}),onPointerDown:Gr(s.onPointerDown,C=>{y.current=C.pointerType;const I=C.target;I.hasPointerCapture(C.pointerId)&&I.releasePointerCapture(C.pointerId),C.button===0&&C.ctrlKey===!1&&C.pointerType==="mouse"&&(A(C),C.preventDefault())}),onKeyDown:Gr(s.onKeyDown,C=>{const I=_.current!=="";!(C.ctrlKey||C.altKey||C.metaKey)&&C.key.length===1&&w(C.key),!(I&&C.key===" ")&&iYe.includes(C.key)&&(A(),C.preventDefault())})})})});jbe.displayName=Ebe;var kbe="SelectValue",Abe=N.forwardRef((t,e)=>{const{__scopeSelect:r,className:n,style:s,children:o,placeholder:c="",...a}=t,f=m0(kbe,r),{onValueNodeHasChildrenChange:m}=f,y=o!==void 0,_=is(e,f.onValueNodeChange);return qo(()=>{m(y)},[m,y]),i.jsx(cn.span,{...a,ref:_,style:{pointerEvents:"none"},children:Zbe(f.value)?i.jsx(i.Fragment,{children:c}):o})});Abe.displayName=kbe;var dYe="SelectIcon",Nbe=N.forwardRef((t,e)=>{const{__scopeSelect:r,children:n,...s}=t;return i.jsx(cn.span,{"aria-hidden":!0,...s,ref:e,children:n||"▼"})});Nbe.displayName=dYe;var hYe="SelectPortal",Cbe=t=>i.jsx($T,{asChild:!0,...t});Cbe.displayName=hYe;var qv="SelectContent",Ibe=N.forwardRef((t,e)=>{const r=m0(qv,t.__scopeSelect),[n,s]=N.useState();if(qo(()=>{s(new DocumentFragment)},[]),!r.open){const o=n;return o?sp.createPortal(i.jsx(Pbe,{scope:t.__scopeSelect,children:i.jsx(H4.Slot,{scope:t.__scopeSelect,children:i.jsx("div",{children:t.children})})}),o):null}return i.jsx(Rbe,{...t,ref:e})});Ibe.displayName=qv;var cf=10,[Pbe,p0]=iE(qv),fYe="SelectContentImpl",mYe=Bx("SelectContent.RemoveScroll"),Rbe=N.forwardRef((t,e)=>{const{__scopeSelect:r,position:n="item-aligned",onCloseAutoFocus:s,onEscapeKeyDown:o,onPointerDownOutside:c,side:a,sideOffset:f,align:m,alignOffset:y,arrowPadding:_,collisionBoundary:w,collisionPadding:E,sticky:A,hideWhenDetached:C,avoidCollisions:I,...M}=t,D=m0(qv,r),[B,U]=N.useState(null),[q,H]=N.useState(null),K=is(e,yt=>U(yt)),[Q,J]=N.useState(null),[ee,oe]=N.useState(null),de=W4(r),[ye,Ee]=N.useState(!1),Le=N.useRef(!1);N.useEffect(()=>{if(B)return h4(B)},[B]),u4();const Se=N.useCallback(yt=>{const[gt,...ft]=de().map(xt=>xt.ref.current),[kt]=ft.slice(-1),Vt=document.activeElement;for(const xt of yt)if(xt===Vt||(xt==null||xt.scrollIntoView({block:"nearest"}),xt===gt&&q&&(q.scrollTop=0),xt===kt&&q&&(q.scrollTop=q.scrollHeight),xt==null||xt.focus(),document.activeElement!==Vt))return},[de,q]),be=N.useCallback(()=>Se([Q,B]),[Se,Q,B]);N.useEffect(()=>{ye&&be()},[ye,be]);const{onOpenChange:me,triggerPointerDownPosRef:ke}=D;N.useEffect(()=>{if(B){let yt={x:0,y:0};const gt=kt=>{var Vt,xt;yt={x:Math.abs(Math.round(kt.pageX)-(((Vt=ke.current)==null?void 0:Vt.x)??0)),y:Math.abs(Math.round(kt.pageY)-(((xt=ke.current)==null?void 0:xt.y)??0))}},ft=kt=>{yt.x<=10&&yt.y<=10?kt.preventDefault():B.contains(kt.target)||me(!1),document.removeEventListener("pointermove",gt),ke.current=null};return ke.current!==null&&(document.addEventListener("pointermove",gt),document.addEventListener("pointerup",ft,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",gt),document.removeEventListener("pointerup",ft,{capture:!0})}}},[B,me,ke]),N.useEffect(()=>{const yt=()=>me(!1);return window.addEventListener("blur",yt),window.addEventListener("resize",yt),()=>{window.removeEventListener("blur",yt),window.removeEventListener("resize",yt)}},[me]);const[Pe,je]=Xbe(yt=>{const gt=de().filter(Vt=>!Vt.disabled),ft=gt.find(Vt=>Vt.ref.current===document.activeElement),kt=Qbe(gt,yt,ft);kt&&setTimeout(()=>kt.ref.current.focus())}),xe=N.useCallback((yt,gt,ft)=>{const kt=!Le.current&&!ft;(D.value!==void 0&&D.value===gt||kt)&&(J(yt),kt&&(Le.current=!0))},[D.value]),Ue=N.useCallback(()=>B==null?void 0:B.focus(),[B]),Ze=N.useCallback((yt,gt,ft)=>{const kt=!Le.current&&!ft;(D.value!==void 0&&D.value===gt||kt)&&oe(yt)},[D.value]),lt=n==="popper"?pq:Lbe,wt=lt===pq?{side:a,sideOffset:f,align:m,alignOffset:y,arrowPadding:_,collisionBoundary:w,collisionPadding:E,sticky:A,hideWhenDetached:C,avoidCollisions:I}:{};return i.jsx(Pbe,{scope:r,content:B,viewport:q,onViewportChange:H,itemRefCallback:xe,selectedItem:Q,onItemLeave:Ue,itemTextRefCallback:Ze,focusSelectedItem:be,selectedItemText:ee,position:n,isPositioned:ye,searchRef:Pe,children:i.jsx(bC,{as:mYe,allowPinchZoom:!0,children:i.jsx(vC,{asChild:!0,trapped:D.open,onMountAutoFocus:yt=>{yt.preventDefault()},onUnmountAutoFocus:Gr(s,yt=>{var gt;(gt=D.trigger)==null||gt.focus({preventScroll:!0}),yt.preventDefault()}),children:i.jsx(nb,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:o,onPointerDownOutside:c,onFocusOutside:yt=>yt.preventDefault(),onDismiss:()=>D.onOpenChange(!1),children:i.jsx(lt,{role:"listbox",id:D.contentId,"data-state":D.open?"open":"closed",dir:D.dir,onContextMenu:yt=>yt.preventDefault(),...M,...wt,onPlaced:()=>Ee(!0),ref:K,style:{display:"flex",flexDirection:"column",outline:"none",...M.style},onKeyDown:Gr(M.onKeyDown,yt=>{const gt=yt.ctrlKey||yt.altKey||yt.metaKey;if(yt.key==="Tab"&&yt.preventDefault(),!gt&&yt.key.length===1&&je(yt.key),["ArrowUp","ArrowDown","Home","End"].includes(yt.key)){let kt=de().filter(Vt=>!Vt.disabled).map(Vt=>Vt.ref.current);if(["ArrowUp","End"].includes(yt.key)&&(kt=kt.slice().reverse()),["ArrowUp","ArrowDown"].includes(yt.key)){const Vt=yt.target,xt=kt.indexOf(Vt);kt=kt.slice(xt+1)}setTimeout(()=>Se(kt)),yt.preventDefault()}})})})})})})});Rbe.displayName=fYe;var pYe="SelectItemAlignedPosition",Lbe=N.forwardRef((t,e)=>{const{__scopeSelect:r,onPlaced:n,...s}=t,o=m0(qv,r),c=p0(qv,r),[a,f]=N.useState(null),[m,y]=N.useState(null),_=is(e,K=>y(K)),w=W4(r),E=N.useRef(!1),A=N.useRef(!0),{viewport:C,selectedItem:I,selectedItemText:M,focusSelectedItem:D}=c,B=N.useCallback(()=>{if(o.trigger&&o.valueNode&&a&&m&&C&&I&&M){const K=o.trigger.getBoundingClientRect(),Q=m.getBoundingClientRect(),J=o.valueNode.getBoundingClientRect(),ee=M.getBoundingClientRect();if(o.dir!=="rtl"){const Vt=ee.left-Q.left,xt=J.left-Vt,or=K.left-xt,Sr=K.width+or,rn=Math.max(Sr,Q.width),Rr=window.innerWidth-cf,$r=rN(xt,[cf,Math.max(cf,Rr-rn)]);a.style.minWidth=Sr+"px",a.style.left=$r+"px"}else{const Vt=Q.right-ee.right,xt=window.innerWidth-J.right-Vt,or=window.innerWidth-K.right-xt,Sr=K.width+or,rn=Math.max(Sr,Q.width),Rr=window.innerWidth-cf,$r=rN(xt,[cf,Math.max(cf,Rr-rn)]);a.style.minWidth=Sr+"px",a.style.right=$r+"px"}const oe=w(),de=window.innerHeight-cf*2,ye=C.scrollHeight,Ee=window.getComputedStyle(m),Le=parseInt(Ee.borderTopWidth,10),Se=parseInt(Ee.paddingTop,10),be=parseInt(Ee.borderBottomWidth,10),me=parseInt(Ee.paddingBottom,10),ke=Le+Se+ye+me+be,Pe=Math.min(I.offsetHeight*5,ke),je=window.getComputedStyle(C),xe=parseInt(je.paddingTop,10),Ue=parseInt(je.paddingBottom,10),Ze=K.top+K.height/2-cf,lt=de-Ze,wt=I.offsetHeight/2,yt=I.offsetTop+wt,gt=Le+Se+yt,ft=ke-gt;if(gt<=Ze){const Vt=oe.length>0&&I===oe[oe.length-1].ref.current;a.style.bottom="0px";const xt=m.clientHeight-C.offsetTop-C.offsetHeight,or=Math.max(lt,wt+(Vt?Ue:0)+xt+be),Sr=gt+or;a.style.height=Sr+"px"}else{const Vt=oe.length>0&&I===oe[0].ref.current;a.style.top="0px";const or=Math.max(Ze,Le+C.offsetTop+(Vt?xe:0)+wt)+ft;a.style.height=or+"px",C.scrollTop=gt-Ze+C.offsetTop}a.style.margin=`${cf}px 0`,a.style.minHeight=Pe+"px",a.style.maxHeight=de+"px",n==null||n(),requestAnimationFrame(()=>E.current=!0)}},[w,o.trigger,o.valueNode,a,m,C,I,M,o.dir,n]);qo(()=>B(),[B]);const[U,q]=N.useState();qo(()=>{m&&q(window.getComputedStyle(m).zIndex)},[m]);const H=N.useCallback(K=>{K&&A.current===!0&&(B(),D==null||D(),A.current=!1)},[B,D]);return i.jsx(yYe,{scope:r,contentWrapper:a,shouldExpandOnScrollRef:E,onScrollButtonChange:H,children:i.jsx("div",{ref:f,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:U},children:i.jsx(cn.div,{...s,ref:_,style:{boxSizing:"border-box",maxHeight:"100%",...s.style}})})})});Lbe.displayName=pYe;var gYe="SelectPopperPosition",pq=N.forwardRef((t,e)=>{const{__scopeSelect:r,align:n="start",collisionPadding:s=cf,...o}=t,c=K4(r);return i.jsx(_4,{...c,...o,ref:e,align:n,collisionPadding:s,style:{boxSizing:"border-box",...o.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});pq.displayName=gYe;var[yYe,BW]=iE(qv,{}),gq="SelectViewport",Mbe=N.forwardRef((t,e)=>{const{__scopeSelect:r,nonce:n,...s}=t,o=p0(gq,r),c=BW(gq,r),a=is(e,o.onViewportChange),f=N.useRef(0);return i.jsxs(i.Fragment,{children:[i.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:n}),i.jsx(H4.Slot,{scope:r,children:i.jsx(cn.div,{"data-radix-select-viewport":"",role:"presentation",...s,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...s.style},onScroll:Gr(s.onScroll,m=>{const y=m.currentTarget,{contentWrapper:_,shouldExpandOnScrollRef:w}=c;if(w!=null&&w.current&&_){const E=Math.abs(f.current-y.scrollTop);if(E>0){const A=window.innerHeight-cf*2,C=parseFloat(_.style.minHeight),I=parseFloat(_.style.height),M=Math.max(C,I);if(M0?U:0,_.style.justifyContent="flex-end")}}}f.current=y.scrollTop})})})]})});Mbe.displayName=gq;var Dbe="SelectGroup",[xYe,_Ye]=iE(Dbe),Obe=N.forwardRef((t,e)=>{const{__scopeSelect:r,...n}=t,s=il();return i.jsx(xYe,{scope:r,id:s,children:i.jsx(cn.div,{role:"group","aria-labelledby":s,...n,ref:e})})});Obe.displayName=Dbe;var Fbe="SelectLabel",Bbe=N.forwardRef((t,e)=>{const{__scopeSelect:r,...n}=t,s=_Ye(Fbe,r);return i.jsx(cn.div,{id:s.id,...n,ref:e})});Bbe.displayName=Fbe;var lO="SelectItem",[vYe,$be]=iE(lO),zbe=N.forwardRef((t,e)=>{const{__scopeSelect:r,value:n,disabled:s=!1,textValue:o,...c}=t,a=m0(lO,r),f=p0(lO,r),m=a.value===n,[y,_]=N.useState(o??""),[w,E]=N.useState(!1),A=is(e,D=>{var B;return(B=f.itemRefCallback)==null?void 0:B.call(f,D,n,s)}),C=il(),I=N.useRef("touch"),M=()=>{s||(a.onValueChange(n),a.onOpenChange(!1))};if(n==="")throw new Error("A must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return i.jsx(vYe,{scope:r,value:n,disabled:s,textId:C,isSelected:m,onItemTextChange:N.useCallback(D=>{_(B=>B||((D==null?void 0:D.textContent)??"").trim())},[]),children:i.jsx(H4.ItemSlot,{scope:r,value:n,disabled:s,textValue:y,children:i.jsx(cn.div,{role:"option","aria-labelledby":C,"data-highlighted":w?"":void 0,"aria-selected":m&&w,"data-state":m?"checked":"unchecked","aria-disabled":s||void 0,"data-disabled":s?"":void 0,tabIndex:s?void 0:-1,...c,ref:A,onFocus:Gr(c.onFocus,()=>E(!0)),onBlur:Gr(c.onBlur,()=>E(!1)),onClick:Gr(c.onClick,()=>{I.current!=="mouse"&&M()}),onPointerUp:Gr(c.onPointerUp,()=>{I.current==="mouse"&&M()}),onPointerDown:Gr(c.onPointerDown,D=>{I.current=D.pointerType}),onPointerMove:Gr(c.onPointerMove,D=>{var B;I.current=D.pointerType,s?(B=f.onItemLeave)==null||B.call(f):I.current==="mouse"&&D.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Gr(c.onPointerLeave,D=>{var B;D.currentTarget===document.activeElement&&((B=f.onItemLeave)==null||B.call(f))}),onKeyDown:Gr(c.onKeyDown,D=>{var U;((U=f.searchRef)==null?void 0:U.current)!==""&&D.key===" "||(aYe.includes(D.key)&&M(),D.key===" "&&D.preventDefault())})})})})});zbe.displayName=lO;var Dk="SelectItemText",Ube=N.forwardRef((t,e)=>{const{__scopeSelect:r,className:n,style:s,...o}=t,c=m0(Dk,r),a=p0(Dk,r),f=$be(Dk,r),m=uYe(Dk,r),[y,_]=N.useState(null),w=is(e,M=>_(M),f.onItemTextChange,M=>{var D;return(D=a.itemTextRefCallback)==null?void 0:D.call(a,M,f.value,f.disabled)}),E=y==null?void 0:y.textContent,A=N.useMemo(()=>i.jsx("option",{value:f.value,disabled:f.disabled,children:E},f.value),[f.disabled,f.value,E]),{onNativeOptionAdd:C,onNativeOptionRemove:I}=m;return qo(()=>(C(A),()=>I(A)),[C,I,A]),i.jsxs(i.Fragment,{children:[i.jsx(cn.span,{id:f.textId,...o,ref:w}),f.isSelected&&c.valueNode&&!c.valueNodeHasChildren?sp.createPortal(o.children,c.valueNode):null]})});Ube.displayName=Dk;var Vbe="SelectItemIndicator",qbe=N.forwardRef((t,e)=>{const{__scopeSelect:r,...n}=t;return $be(Vbe,r).isSelected?i.jsx(cn.span,{"aria-hidden":!0,...n,ref:e}):null});qbe.displayName=Vbe;var yq="SelectScrollUpButton",Gbe=N.forwardRef((t,e)=>{const r=p0(yq,t.__scopeSelect),n=BW(yq,t.__scopeSelect),[s,o]=N.useState(!1),c=is(e,n.onScrollButtonChange);return qo(()=>{if(r.viewport&&r.isPositioned){let a=function(){const m=f.scrollTop>0;o(m)};const f=r.viewport;return a(),f.addEventListener("scroll",a),()=>f.removeEventListener("scroll",a)}},[r.viewport,r.isPositioned]),s?i.jsx(Wbe,{...t,ref:c,onAutoScroll:()=>{const{viewport:a,selectedItem:f}=r;a&&f&&(a.scrollTop=a.scrollTop-f.offsetHeight)}}):null});Gbe.displayName=yq;var xq="SelectScrollDownButton",Hbe=N.forwardRef((t,e)=>{const r=p0(xq,t.__scopeSelect),n=BW(xq,t.__scopeSelect),[s,o]=N.useState(!1),c=is(e,n.onScrollButtonChange);return qo(()=>{if(r.viewport&&r.isPositioned){let a=function(){const m=f.scrollHeight-f.clientHeight,y=Math.ceil(f.scrollTop)f.removeEventListener("scroll",a)}},[r.viewport,r.isPositioned]),s?i.jsx(Wbe,{...t,ref:c,onAutoScroll:()=>{const{viewport:a,selectedItem:f}=r;a&&f&&(a.scrollTop=a.scrollTop+f.offsetHeight)}}):null});Hbe.displayName=xq;var Wbe=N.forwardRef((t,e)=>{const{__scopeSelect:r,onAutoScroll:n,...s}=t,o=p0("SelectScrollButton",r),c=N.useRef(null),a=W4(r),f=N.useCallback(()=>{c.current!==null&&(window.clearInterval(c.current),c.current=null)},[]);return N.useEffect(()=>()=>f(),[f]),qo(()=>{var y;const m=a().find(_=>_.ref.current===document.activeElement);(y=m==null?void 0:m.ref.current)==null||y.scrollIntoView({block:"nearest"})},[a]),i.jsx(cn.div,{"aria-hidden":!0,...s,ref:e,style:{flexShrink:0,...s.style},onPointerDown:Gr(s.onPointerDown,()=>{c.current===null&&(c.current=window.setInterval(n,50))}),onPointerMove:Gr(s.onPointerMove,()=>{var m;(m=o.onItemLeave)==null||m.call(o),c.current===null&&(c.current=window.setInterval(n,50))}),onPointerLeave:Gr(s.onPointerLeave,()=>{f()})})}),bYe="SelectSeparator",Kbe=N.forwardRef((t,e)=>{const{__scopeSelect:r,...n}=t;return i.jsx(cn.div,{"aria-hidden":!0,...n,ref:e})});Kbe.displayName=bYe;var _q="SelectArrow",wYe=N.forwardRef((t,e)=>{const{__scopeSelect:r,...n}=t,s=K4(r),o=m0(_q,r),c=p0(_q,r);return o.open&&c.position==="popper"?i.jsx(v4,{...s,...n,ref:e}):null});wYe.displayName=_q;var SYe="SelectBubbleInput",Ybe=N.forwardRef(({__scopeSelect:t,value:e,...r},n)=>{const s=N.useRef(null),o=is(n,s),c=OC(e);return N.useEffect(()=>{const a=s.current;if(!a)return;const f=window.HTMLSelectElement.prototype,y=Object.getOwnPropertyDescriptor(f,"value").set;if(c!==e&&y){const _=new Event("change",{bubbles:!0});y.call(a,e),a.dispatchEvent(_)}},[c,e]),i.jsx(cn.select,{...r,style:{...Cge,...r.style},ref:o,defaultValue:e})});Ybe.displayName=SYe;function Zbe(t){return t===""||t===void 0}function Xbe(t){const e=fo(t),r=N.useRef(""),n=N.useRef(0),s=N.useCallback(c=>{const a=r.current+c;e(a),function f(m){r.current=m,window.clearTimeout(n.current),m!==""&&(n.current=window.setTimeout(()=>f(""),1e3))}(a)},[e]),o=N.useCallback(()=>{r.current="",window.clearTimeout(n.current)},[]);return N.useEffect(()=>()=>window.clearTimeout(n.current),[]),[r,s,o]}function Qbe(t,e,r){const s=e.length>1&&Array.from(e).every(m=>m===e[0])?e[0]:e,o=r?t.indexOf(r):-1;let c=TYe(t,Math.max(o,0));s.length===1&&(c=c.filter(m=>m!==r));const f=c.find(m=>m.textValue.toLowerCase().startsWith(s.toLowerCase()));return f!==r?f:void 0}function TYe(t,e){return t.map((r,n)=>t[(e+n)%t.length])}var EYe=Tbe,Jbe=jbe,jYe=Abe,kYe=Nbe,AYe=Cbe,ewe=Ibe,NYe=Mbe,CYe=Obe,twe=Bbe,rwe=zbe,IYe=Ube,PYe=qbe,nwe=Gbe,swe=Hbe,iwe=Kbe;const Ia=EYe,VQt=CYe,Pa=jYe,_a=N.forwardRef(({className:t,children:e,...r},n)=>i.jsxs(Jbe,{ref:n,className:Xt("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",t),...r,children:[e,i.jsx(kYe,{asChild:!0,children:i.jsx(Go,{className:"h-4 w-4 opacity-50"})})]}));_a.displayName=Jbe.displayName;const awe=N.forwardRef(({className:t,...e},r)=>i.jsx(nwe,{ref:r,className:Xt("flex cursor-default items-center justify-center py-1",t),...e,children:i.jsx(eye,{className:"h-4 w-4"})}));awe.displayName=nwe.displayName;const owe=N.forwardRef(({className:t,...e},r)=>i.jsx(swe,{ref:r,className:Xt("flex cursor-default items-center justify-center py-1",t),...e,children:i.jsx(Go,{className:"h-4 w-4"})}));owe.displayName=swe.displayName;const va=N.forwardRef(({className:t,children:e,position:r="popper",...n},s)=>i.jsx(AYe,{children:i.jsxs(ewe,{ref:s,className:Xt("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",r==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",t),position:r,...n,children:[i.jsx(awe,{}),i.jsx(NYe,{className:Xt("p-1",r==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:e}),i.jsx(owe,{})]})}));va.displayName=ewe.displayName;const RYe=N.forwardRef(({className:t,...e},r)=>i.jsx(twe,{ref:r,className:Xt("py-1.5 pl-8 pr-2 text-sm font-semibold",t),...e}));RYe.displayName=twe.displayName;const gn=N.forwardRef(({className:t,children:e,...r},n)=>i.jsxs(rwe,{ref:n,className:Xt("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",t),...r,children:[i.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:i.jsx(PYe,{children:i.jsx(pa,{className:"h-4 w-4"})})}),i.jsx(IYe,{children:e})]}));gn.displayName=rwe.displayName;const LYe=N.forwardRef(({className:t,...e},r)=>i.jsx(iwe,{ref:r,className:Xt("-mx-1 my-1 h-px bg-muted",t),...e}));LYe.displayName=iwe.displayName;const MYe=zg({category:tT(["general","technology","crm","marketing"]),subject:Ds().min(5,"Subject must be at least 5 characters").max(200),description:Ds().min(20,"Please provide more details (at least 20 characters)").max(1e4,"Please keep the description under 10,000 characters")}),DYe={general:"General Support",technology:"Technology Support",crm:"CRM Support",marketing:"Marketing Support"};function OYe({trigger:t}){const[e,r]=N.useState(!1),[n,s]=N.useState(!1),{user:o}=Zn(),c=AW({resolver:NW(MYe),defaultValues:{category:"general",subject:"",description:""}}),a=async f=>{if(!o){$t.error("You must be logged in to submit a ticket");return}s(!0);try{const{error:m}=await Ce.from("support_tickets").insert({user_id:o.id,category:f.category,subject:f.subject,description:f.description});if(m)throw m;try{await Ce.functions.invoke("support-ticket-notify",{body:{category:DYe[f.category],subject:f.subject}})}catch(y){console.log("Notification send attempted:",y)}$t.success("Support ticket submitted successfully!"),c.reset(),r(!1)}catch(m){console.error("Error submitting ticket:",m),$t.error("Failed to submit ticket. Please try again.")}finally{s(!1)}};return i.jsxs(Ha,{open:e,onOpenChange:r,children:[i.jsx(cve,{asChild:!0,children:t||i.jsxs(Lt,{variant:"ghost",size:"icon",className:"relative",children:[i.jsx(b4e,{className:"h-5 w-5"}),i.jsx("span",{className:"sr-only",children:"Support"})]})}),i.jsxs(Ra,{className:"sm:max-w-[500px]",children:[i.jsxs(Ho,{children:[i.jsx(Co,{children:"Need Help?"}),i.jsx(td,{children:"Submit a support ticket and we'll get back to you as soon as possible."})]}),i.jsxs("div",{className:"flex items-center gap-2 p-3 bg-muted rounded-lg mb-4",children:[i.jsx(Un,{className:"h-4 w-4 text-muted-foreground"}),i.jsxs("span",{className:"text-sm text-muted-foreground",children:["You can also text us at: ",i.jsx("span",{className:"font-medium text-foreground",children:"1-866-527-8668"})]})]}),i.jsx(FW,{...c,children:i.jsxs("form",{onSubmit:c.handleSubmit(a),className:"space-y-4",children:[i.jsx(vl,{control:c.control,name:"category",render:({field:f})=>i.jsxs(el,{children:[i.jsx(tl,{children:"Category"}),i.jsxs(Ia,{onValueChange:f.onChange,defaultValue:f.value,children:[i.jsx(rl,{children:i.jsx(_a,{children:i.jsx(Pa,{placeholder:"Select a category"})})}),i.jsxs(va,{children:[i.jsx(gn,{value:"general",children:"General Support"}),i.jsx(gn,{value:"technology",children:"Technology Support"}),i.jsx(gn,{value:"crm",children:"CRM Support"}),i.jsx(gn,{value:"marketing",children:"Marketing Support"})]})]}),i.jsx(Af,{})]})}),i.jsx(vl,{control:c.control,name:"subject",render:({field:f})=>i.jsxs(el,{children:[i.jsx(tl,{children:"Subject"}),i.jsx(rl,{children:i.jsx(Dr,{placeholder:"Brief description of your issue",...f})}),i.jsx(Af,{})]})}),i.jsx(vl,{control:c.control,name:"description",render:({field:f})=>{var m;return i.jsxs(el,{children:[i.jsx(tl,{children:"Description"}),i.jsx(rl,{children:i.jsx(zc,{placeholder:"Please describe your issue in detail...",className:"min-h-[120px]",...f})}),i.jsxs("p",{className:"text-right text-xs text-muted-foreground",children:[(((m=f.value)==null?void 0:m.length)??0).toLocaleString()," / 10,000"]}),i.jsx(Af,{})]})}}),i.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[i.jsx(Lt,{type:"button",variant:"outline",onClick:()=>r(!1),children:"Cancel"}),i.jsx(Lt,{type:"submit",disabled:n,children:n?"Submitting...":"Submit Ticket"})]})]})})]})]})}function qn(t){const e=Object.prototype.toString.call(t);return t instanceof Date||typeof t=="object"&&e==="[object Date]"?new t.constructor(+t):typeof t=="number"||e==="[object Number]"||typeof t=="string"||e==="[object String]"?new Date(t):new Date(NaN)}function la(t,e){return t instanceof Date?new t.constructor(e):new Date(e)}function Ul(t,e){const r=qn(t);return isNaN(e)?la(t,NaN):(e&&r.setDate(r.getDate()+e),r)}function $d(t,e){const r=qn(t);if(isNaN(e))return la(t,NaN);if(!e)return r;const n=r.getDate(),s=la(t,r.getTime());s.setMonth(r.getMonth()+e+1,0);const o=s.getDate();return n>=o?s:(r.setFullYear(s.getFullYear(),s.getMonth(),n),r)}const $W=6048e5,FYe=864e5,zW=6e4,UW=36e5,BYe=1e3,mL=43200,qse=1440;let $Ye={};function g0(){return $Ye}function Bc(t,e){var a,f,m,y;const r=g0(),n=(e==null?void 0:e.weekStartsOn)??((f=(a=e==null?void 0:e.locale)==null?void 0:a.options)==null?void 0:f.weekStartsOn)??r.weekStartsOn??((y=(m=r.locale)==null?void 0:m.options)==null?void 0:y.weekStartsOn)??0,s=qn(t),o=s.getDay(),c=(o=s.getTime()?r+1:e.getTime()>=c.getTime()?r:r-1}function Hx(t){const e=qn(t);return e.setHours(0,0,0,0),e}function Wx(t){const e=qn(t),r=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return r.setUTCFullYear(e.getFullYear()),+t-+r}function Nf(t,e){const r=Hx(t),n=Hx(e),s=+r-Wx(r),o=+n-Wx(n);return Math.round((s-o)/FYe)}function zYe(t){const e=lwe(t),r=la(t,0);return r.setFullYear(e,0,4),r.setHours(0,0,0,0),Pg(r)}function vq(t,e){const r=e*7;return Ul(t,r)}function UYe(t,e){return $d(t,e*12)}function VYe(t){let e;return t.forEach(function(r){const n=qn(r);(e===void 0||e{const n=qn(r);(!e||e>n||isNaN(+n))&&(e=n)}),e||new Date(NaN)}function MM(t,e){const r=qn(t),n=qn(e),s=r.getTime()-n.getTime();return s<0?-1:s>0?1:s}function VW(t){return la(t,Date.now())}function dc(t,e){const r=Hx(t),n=Hx(e);return+r==+n}function qW(t){return t instanceof Date||typeof t=="object"&&Object.prototype.toString.call(t)==="[object Date]"}function bq(t){if(!qW(t)&&typeof t!="number")return!1;const e=qn(t);return!isNaN(Number(e))}function rT(t,e){const r=qn(t),n=qn(e),s=r.getFullYear()-n.getFullYear(),o=r.getMonth()-n.getMonth();return s*12+o}function GYe(t,e,r){const n=Bc(t,r),s=Bc(e,r),o=+n-Wx(n),c=+s-Wx(s);return Math.round((o-c)/$W)}function HYe(t,e){const r=qn(t),n=qn(e),s=Gse(r,n),o=Math.abs(Nf(r,n));r.setDate(r.getDate()-s*o);const c=+(Gse(r,n)===-s),a=s*(o-c);return a===0?0:a}function Gse(t,e){const r=t.getFullYear()-e.getFullYear()||t.getMonth()-e.getMonth()||t.getDate()-e.getDate()||t.getHours()-e.getHours()||t.getMinutes()-e.getMinutes()||t.getSeconds()-e.getSeconds()||t.getMilliseconds()-e.getMilliseconds();return r<0?-1:r>0?1:r}function WYe(t){return e=>{const n=(t?Math[t]:Math.trunc)(e);return n===0?0:n}}function KYe(t,e){return+qn(t)-+qn(e)}function YYe(t){const e=qn(t);return e.setHours(23,59,59,999),e}function FC(t){const e=qn(t),r=e.getMonth();return e.setFullYear(e.getFullYear(),r+1,0),e.setHours(23,59,59,999),e}function ZYe(t){const e=qn(t);return+YYe(e)==+FC(e)}function XYe(t,e){const r=qn(t),n=qn(e),s=MM(r,n),o=Math.abs(rT(r,n));let c;if(o<1)c=0;else{r.getMonth()===1&&r.getDate()>27&&r.setDate(30),r.setMonth(r.getMonth()-s*o);let a=MM(r,n)===-s;ZYe(qn(t))&&o===1&&MM(t,n)===1&&(a=!1),c=s*(o-Number(a))}return c===0?0:c}function QYe(t,e,r){const n=KYe(t,e)/1e3;return WYe(r==null?void 0:r.roundingMethod)(n)}function JYe(t,e){const r=qn(t.start),n=qn(t.end);let s=+r>+n;const o=s?+r:+n,c=s?n:r;c.setHours(0,0,0,0);let a=1;const f=[];for(;+c<=o;)f.push(qn(c)),c.setDate(c.getDate()+a),c.setHours(0,0,0,0);return s?f.reverse():f}function wu(t){const e=qn(t);return e.setDate(1),e.setHours(0,0,0,0),e}function cwe(t){const e=qn(t),r=la(t,0);return r.setFullYear(e.getFullYear(),0,1),r.setHours(0,0,0,0),r}function Y4(t,e){var a,f,m,y;const r=g0(),n=(e==null?void 0:e.weekStartsOn)??((f=(a=e==null?void 0:e.locale)==null?void 0:a.options)==null?void 0:f.weekStartsOn)??r.weekStartsOn??((y=(m=r.locale)==null?void 0:m.options)==null?void 0:y.weekStartsOn)??0,s=qn(t),o=s.getDay(),c=(o{let n;const s=eZe[t];return typeof s=="string"?n=s:e===1?n=s.one:n=s.other.replace("{{count}}",e.toString()),r!=null&&r.addSuffix?r.comparison&&r.comparison>0?"in "+n:n+" ago":n};function o6(t){return(e={})=>{const r=e.width?String(e.width):t.defaultWidth;return t.formats[r]||t.formats[t.defaultWidth]}}const rZe={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},nZe={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},sZe={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},iZe={date:o6({formats:rZe,defaultWidth:"full"}),time:o6({formats:nZe,defaultWidth:"full"}),dateTime:o6({formats:sZe,defaultWidth:"full"})},aZe={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},oZe=(t,e,r,n)=>aZe[t];function tk(t){return(e,r)=>{const n=r!=null&&r.context?String(r.context):"standalone";let s;if(n==="formatting"&&t.formattingValues){const c=t.defaultFormattingWidth||t.defaultWidth,a=r!=null&&r.width?String(r.width):c;s=t.formattingValues[a]||t.formattingValues[c]}else{const c=t.defaultWidth,a=r!=null&&r.width?String(r.width):t.defaultWidth;s=t.values[a]||t.values[c]}const o=t.argumentCallback?t.argumentCallback(e):e;return s[o]}}const lZe={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},cZe={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},uZe={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},dZe={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},hZe={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},fZe={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},mZe=(t,e)=>{const r=Number(t),n=r%100;if(n>20||n<10)switch(n%10){case 1:return r+"st";case 2:return r+"nd";case 3:return r+"rd"}return r+"th"},pZe={ordinalNumber:mZe,era:tk({values:lZe,defaultWidth:"wide"}),quarter:tk({values:cZe,defaultWidth:"wide",argumentCallback:t=>t-1}),month:tk({values:uZe,defaultWidth:"wide"}),day:tk({values:dZe,defaultWidth:"wide"}),dayPeriod:tk({values:hZe,defaultWidth:"wide",formattingValues:fZe,defaultFormattingWidth:"wide"})};function rk(t){return(e,r={})=>{const n=r.width,s=n&&t.matchPatterns[n]||t.matchPatterns[t.defaultMatchWidth],o=e.match(s);if(!o)return null;const c=o[0],a=n&&t.parsePatterns[n]||t.parsePatterns[t.defaultParseWidth],f=Array.isArray(a)?yZe(a,_=>_.test(c)):gZe(a,_=>_.test(c));let m;m=t.valueCallback?t.valueCallback(f):f,m=r.valueCallback?r.valueCallback(m):m;const y=e.slice(c.length);return{value:m,rest:y}}}function gZe(t,e){for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&e(t[r]))return r}function yZe(t,e){for(let r=0;r{const n=e.match(t.matchPattern);if(!n)return null;const s=n[0],o=e.match(t.parsePattern);if(!o)return null;let c=t.valueCallback?t.valueCallback(o[0]):o[0];c=r.valueCallback?r.valueCallback(c):c;const a=e.slice(s.length);return{value:c,rest:a}}}const _Ze=/^(\d+)(th|st|nd|rd)?/i,vZe=/\d+/i,bZe={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},wZe={any:[/^b/i,/^(a|c)/i]},SZe={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},TZe={any:[/1/i,/2/i,/3/i,/4/i]},EZe={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},jZe={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},kZe={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},AZe={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},NZe={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},CZe={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},IZe={ordinalNumber:xZe({matchPattern:_Ze,parsePattern:vZe,valueCallback:t=>parseInt(t,10)}),era:rk({matchPatterns:bZe,defaultMatchWidth:"wide",parsePatterns:wZe,defaultParseWidth:"any"}),quarter:rk({matchPatterns:SZe,defaultMatchWidth:"wide",parsePatterns:TZe,defaultParseWidth:"any",valueCallback:t=>t+1}),month:rk({matchPatterns:EZe,defaultMatchWidth:"wide",parsePatterns:jZe,defaultParseWidth:"any"}),day:rk({matchPatterns:kZe,defaultMatchWidth:"wide",parsePatterns:AZe,defaultParseWidth:"any"}),dayPeriod:rk({matchPatterns:NZe,defaultMatchWidth:"any",parsePatterns:CZe,defaultParseWidth:"any"})},Z4={code:"en-US",formatDistance:tZe,formatLong:iZe,formatRelative:oZe,localize:pZe,match:IZe,options:{weekStartsOn:0,firstWeekContainsDate:1}};function PZe(t){const e=qn(t);return Nf(e,cwe(e))+1}function GW(t){const e=qn(t),r=+Pg(e)-+zYe(e);return Math.round(r/$W)+1}function HW(t,e){var y,_,w,E;const r=qn(t),n=r.getFullYear(),s=g0(),o=(e==null?void 0:e.firstWeekContainsDate)??((_=(y=e==null?void 0:e.locale)==null?void 0:y.options)==null?void 0:_.firstWeekContainsDate)??s.firstWeekContainsDate??((E=(w=s.locale)==null?void 0:w.options)==null?void 0:E.firstWeekContainsDate)??1,c=la(t,0);c.setFullYear(n+1,0,o),c.setHours(0,0,0,0);const a=Bc(c,e),f=la(t,0);f.setFullYear(n,0,o),f.setHours(0,0,0,0);const m=Bc(f,e);return r.getTime()>=a.getTime()?n+1:r.getTime()>=m.getTime()?n:n-1}function RZe(t,e){var a,f,m,y;const r=g0(),n=(e==null?void 0:e.firstWeekContainsDate)??((f=(a=e==null?void 0:e.locale)==null?void 0:a.options)==null?void 0:f.firstWeekContainsDate)??r.firstWeekContainsDate??((y=(m=r.locale)==null?void 0:m.options)==null?void 0:y.firstWeekContainsDate)??1,s=HW(t,e),o=la(t,0);return o.setFullYear(s,0,n),o.setHours(0,0,0,0),Bc(o,e)}function WW(t,e){const r=qn(t),n=+Bc(r,e)-+RZe(r,e);return Math.round(n/$W)+1}function Zi(t,e){const r=t<0?"-":"",n=Math.abs(t).toString().padStart(e,"0");return r+n}const Dy={y(t,e){const r=t.getFullYear(),n=r>0?r:1-r;return Zi(e==="yy"?n%100:n,e.length)},M(t,e){const r=t.getMonth();return e==="M"?String(r+1):Zi(r+1,2)},d(t,e){return Zi(t.getDate(),e.length)},a(t,e){const r=t.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return r.toUpperCase();case"aaa":return r;case"aaaaa":return r[0];case"aaaa":default:return r==="am"?"a.m.":"p.m."}},h(t,e){return Zi(t.getHours()%12||12,e.length)},H(t,e){return Zi(t.getHours(),e.length)},m(t,e){return Zi(t.getMinutes(),e.length)},s(t,e){return Zi(t.getSeconds(),e.length)},S(t,e){const r=e.length,n=t.getMilliseconds(),s=Math.trunc(n*Math.pow(10,r-3));return Zi(s,e.length)}},r1={am:"am",pm:"pm",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},Hse={G:function(t,e,r){const n=t.getFullYear()>0?1:0;switch(e){case"G":case"GG":case"GGG":return r.era(n,{width:"abbreviated"});case"GGGGG":return r.era(n,{width:"narrow"});case"GGGG":default:return r.era(n,{width:"wide"})}},y:function(t,e,r){if(e==="yo"){const n=t.getFullYear(),s=n>0?n:1-n;return r.ordinalNumber(s,{unit:"year"})}return Dy.y(t,e)},Y:function(t,e,r,n){const s=HW(t,n),o=s>0?s:1-s;if(e==="YY"){const c=o%100;return Zi(c,2)}return e==="Yo"?r.ordinalNumber(o,{unit:"year"}):Zi(o,e.length)},R:function(t,e){const r=lwe(t);return Zi(r,e.length)},u:function(t,e){const r=t.getFullYear();return Zi(r,e.length)},Q:function(t,e,r){const n=Math.ceil((t.getMonth()+1)/3);switch(e){case"Q":return String(n);case"QQ":return Zi(n,2);case"Qo":return r.ordinalNumber(n,{unit:"quarter"});case"QQQ":return r.quarter(n,{width:"abbreviated",context:"formatting"});case"QQQQQ":return r.quarter(n,{width:"narrow",context:"formatting"});case"QQQQ":default:return r.quarter(n,{width:"wide",context:"formatting"})}},q:function(t,e,r){const n=Math.ceil((t.getMonth()+1)/3);switch(e){case"q":return String(n);case"qq":return Zi(n,2);case"qo":return r.ordinalNumber(n,{unit:"quarter"});case"qqq":return r.quarter(n,{width:"abbreviated",context:"standalone"});case"qqqqq":return r.quarter(n,{width:"narrow",context:"standalone"});case"qqqq":default:return r.quarter(n,{width:"wide",context:"standalone"})}},M:function(t,e,r){const n=t.getMonth();switch(e){case"M":case"MM":return Dy.M(t,e);case"Mo":return r.ordinalNumber(n+1,{unit:"month"});case"MMM":return r.month(n,{width:"abbreviated",context:"formatting"});case"MMMMM":return r.month(n,{width:"narrow",context:"formatting"});case"MMMM":default:return r.month(n,{width:"wide",context:"formatting"})}},L:function(t,e,r){const n=t.getMonth();switch(e){case"L":return String(n+1);case"LL":return Zi(n+1,2);case"Lo":return r.ordinalNumber(n+1,{unit:"month"});case"LLL":return r.month(n,{width:"abbreviated",context:"standalone"});case"LLLLL":return r.month(n,{width:"narrow",context:"standalone"});case"LLLL":default:return r.month(n,{width:"wide",context:"standalone"})}},w:function(t,e,r,n){const s=WW(t,n);return e==="wo"?r.ordinalNumber(s,{unit:"week"}):Zi(s,e.length)},I:function(t,e,r){const n=GW(t);return e==="Io"?r.ordinalNumber(n,{unit:"week"}):Zi(n,e.length)},d:function(t,e,r){return e==="do"?r.ordinalNumber(t.getDate(),{unit:"date"}):Dy.d(t,e)},D:function(t,e,r){const n=PZe(t);return e==="Do"?r.ordinalNumber(n,{unit:"dayOfYear"}):Zi(n,e.length)},E:function(t,e,r){const n=t.getDay();switch(e){case"E":case"EE":case"EEE":return r.day(n,{width:"abbreviated",context:"formatting"});case"EEEEE":return r.day(n,{width:"narrow",context:"formatting"});case"EEEEEE":return r.day(n,{width:"short",context:"formatting"});case"EEEE":default:return r.day(n,{width:"wide",context:"formatting"})}},e:function(t,e,r,n){const s=t.getDay(),o=(s-n.weekStartsOn+8)%7||7;switch(e){case"e":return String(o);case"ee":return Zi(o,2);case"eo":return r.ordinalNumber(o,{unit:"day"});case"eee":return r.day(s,{width:"abbreviated",context:"formatting"});case"eeeee":return r.day(s,{width:"narrow",context:"formatting"});case"eeeeee":return r.day(s,{width:"short",context:"formatting"});case"eeee":default:return r.day(s,{width:"wide",context:"formatting"})}},c:function(t,e,r,n){const s=t.getDay(),o=(s-n.weekStartsOn+8)%7||7;switch(e){case"c":return String(o);case"cc":return Zi(o,e.length);case"co":return r.ordinalNumber(o,{unit:"day"});case"ccc":return r.day(s,{width:"abbreviated",context:"standalone"});case"ccccc":return r.day(s,{width:"narrow",context:"standalone"});case"cccccc":return r.day(s,{width:"short",context:"standalone"});case"cccc":default:return r.day(s,{width:"wide",context:"standalone"})}},i:function(t,e,r){const n=t.getDay(),s=n===0?7:n;switch(e){case"i":return String(s);case"ii":return Zi(s,e.length);case"io":return r.ordinalNumber(s,{unit:"day"});case"iii":return r.day(n,{width:"abbreviated",context:"formatting"});case"iiiii":return r.day(n,{width:"narrow",context:"formatting"});case"iiiiii":return r.day(n,{width:"short",context:"formatting"});case"iiii":default:return r.day(n,{width:"wide",context:"formatting"})}},a:function(t,e,r){const s=t.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return r.dayPeriod(s,{width:"abbreviated",context:"formatting"});case"aaa":return r.dayPeriod(s,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return r.dayPeriod(s,{width:"narrow",context:"formatting"});case"aaaa":default:return r.dayPeriod(s,{width:"wide",context:"formatting"})}},b:function(t,e,r){const n=t.getHours();let s;switch(n===12?s=r1.noon:n===0?s=r1.midnight:s=n/12>=1?"pm":"am",e){case"b":case"bb":return r.dayPeriod(s,{width:"abbreviated",context:"formatting"});case"bbb":return r.dayPeriod(s,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return r.dayPeriod(s,{width:"narrow",context:"formatting"});case"bbbb":default:return r.dayPeriod(s,{width:"wide",context:"formatting"})}},B:function(t,e,r){const n=t.getHours();let s;switch(n>=17?s=r1.evening:n>=12?s=r1.afternoon:n>=4?s=r1.morning:s=r1.night,e){case"B":case"BB":case"BBB":return r.dayPeriod(s,{width:"abbreviated",context:"formatting"});case"BBBBB":return r.dayPeriod(s,{width:"narrow",context:"formatting"});case"BBBB":default:return r.dayPeriod(s,{width:"wide",context:"formatting"})}},h:function(t,e,r){if(e==="ho"){let n=t.getHours()%12;return n===0&&(n=12),r.ordinalNumber(n,{unit:"hour"})}return Dy.h(t,e)},H:function(t,e,r){return e==="Ho"?r.ordinalNumber(t.getHours(),{unit:"hour"}):Dy.H(t,e)},K:function(t,e,r){const n=t.getHours()%12;return e==="Ko"?r.ordinalNumber(n,{unit:"hour"}):Zi(n,e.length)},k:function(t,e,r){let n=t.getHours();return n===0&&(n=24),e==="ko"?r.ordinalNumber(n,{unit:"hour"}):Zi(n,e.length)},m:function(t,e,r){return e==="mo"?r.ordinalNumber(t.getMinutes(),{unit:"minute"}):Dy.m(t,e)},s:function(t,e,r){return e==="so"?r.ordinalNumber(t.getSeconds(),{unit:"second"}):Dy.s(t,e)},S:function(t,e){return Dy.S(t,e)},X:function(t,e,r){const n=t.getTimezoneOffset();if(n===0)return"Z";switch(e){case"X":return Kse(n);case"XXXX":case"XX":return H_(n);case"XXXXX":case"XXX":default:return H_(n,":")}},x:function(t,e,r){const n=t.getTimezoneOffset();switch(e){case"x":return Kse(n);case"xxxx":case"xx":return H_(n);case"xxxxx":case"xxx":default:return H_(n,":")}},O:function(t,e,r){const n=t.getTimezoneOffset();switch(e){case"O":case"OO":case"OOO":return"GMT"+Wse(n,":");case"OOOO":default:return"GMT"+H_(n,":")}},z:function(t,e,r){const n=t.getTimezoneOffset();switch(e){case"z":case"zz":case"zzz":return"GMT"+Wse(n,":");case"zzzz":default:return"GMT"+H_(n,":")}},t:function(t,e,r){const n=Math.trunc(t.getTime()/1e3);return Zi(n,e.length)},T:function(t,e,r){const n=t.getTime();return Zi(n,e.length)}};function Wse(t,e=""){const r=t>0?"-":"+",n=Math.abs(t),s=Math.trunc(n/60),o=n%60;return o===0?r+String(s):r+String(s)+e+Zi(o,2)}function Kse(t,e){return t%60===0?(t>0?"-":"+")+Zi(Math.abs(t)/60,2):H_(t,e)}function H_(t,e=""){const r=t>0?"-":"+",n=Math.abs(t),s=Zi(Math.trunc(n/60),2),o=Zi(n%60,2);return r+s+e+o}const Yse=(t,e)=>{switch(t){case"P":return e.date({width:"short"});case"PP":return e.date({width:"medium"});case"PPP":return e.date({width:"long"});case"PPPP":default:return e.date({width:"full"})}},dwe=(t,e)=>{switch(t){case"p":return e.time({width:"short"});case"pp":return e.time({width:"medium"});case"ppp":return e.time({width:"long"});case"pppp":default:return e.time({width:"full"})}},LZe=(t,e)=>{const r=t.match(/(P+)(p+)?/)||[],n=r[1],s=r[2];if(!s)return Yse(t,e);let o;switch(n){case"P":o=e.dateTime({width:"short"});break;case"PP":o=e.dateTime({width:"medium"});break;case"PPP":o=e.dateTime({width:"long"});break;case"PPPP":default:o=e.dateTime({width:"full"});break}return o.replace("{{date}}",Yse(n,e)).replace("{{time}}",dwe(s,e))},wq={p:dwe,P:LZe},MZe=/^D+$/,DZe=/^Y+$/,OZe=["D","DD","YY","YYYY"];function hwe(t){return MZe.test(t)}function fwe(t){return DZe.test(t)}function Sq(t,e,r){const n=FZe(t,e,r);if(console.warn(n),OZe.includes(t))throw new RangeError(n)}function FZe(t,e,r){const n=t[0]==="Y"?"years":"days of the month";return`Use \`${t.toLowerCase()}\` instead of \`${t}\` (in \`${e}\`) for formatting ${n} to the input \`${r}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const BZe=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,$Ze=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,zZe=/^'([^]*?)'?$/,UZe=/''/g,VZe=/[a-zA-Z]/;function Ls(t,e,r){var y,_,w,E,A,C,I,M;const n=g0(),s=(r==null?void 0:r.locale)??n.locale??Z4,o=(r==null?void 0:r.firstWeekContainsDate)??((_=(y=r==null?void 0:r.locale)==null?void 0:y.options)==null?void 0:_.firstWeekContainsDate)??n.firstWeekContainsDate??((E=(w=n.locale)==null?void 0:w.options)==null?void 0:E.firstWeekContainsDate)??1,c=(r==null?void 0:r.weekStartsOn)??((C=(A=r==null?void 0:r.locale)==null?void 0:A.options)==null?void 0:C.weekStartsOn)??n.weekStartsOn??((M=(I=n.locale)==null?void 0:I.options)==null?void 0:M.weekStartsOn)??0,a=qn(t);if(!bq(a))throw new RangeError("Invalid time value");let f=e.match($Ze).map(D=>{const B=D[0];if(B==="p"||B==="P"){const U=wq[B];return U(D,s.formatLong)}return D}).join("").match(BZe).map(D=>{if(D==="''")return{isToken:!1,value:"'"};const B=D[0];if(B==="'")return{isToken:!1,value:qZe(D)};if(Hse[B])return{isToken:!0,value:D};if(B.match(VZe))throw new RangeError("Format string contains an unescaped latin alphabet character `"+B+"`");return{isToken:!1,value:D}});s.localize.preprocessor&&(f=s.localize.preprocessor(a,f));const m={firstWeekContainsDate:o,weekStartsOn:c,locale:s};return f.map(D=>{if(!D.isToken)return D.value;const B=D.value;(!(r!=null&&r.useAdditionalWeekYearTokens)&&fwe(B)||!(r!=null&&r.useAdditionalDayOfYearTokens)&&hwe(B))&&Sq(B,e,String(t));const U=Hse[B[0]];return U(a,B,s.localize,m)}).join("")}function qZe(t){const e=t.match(zZe);return e?e[1].replace(UZe,"'"):t}function GZe(t,e,r){const n=g0(),s=(r==null?void 0:r.locale)??n.locale??Z4,o=2520,c=MM(t,e);if(isNaN(c))throw new RangeError("Invalid time value");const a=Object.assign({},r,{addSuffix:r==null?void 0:r.addSuffix,comparison:c});let f,m;c>0?(f=qn(e),m=qn(t)):(f=qn(t),m=qn(e));const y=QYe(m,f),_=(Wx(m)-Wx(f))/1e3,w=Math.round((y-_)/60);let E;if(w<2)return r!=null&&r.includeSeconds?y<5?s.formatDistance("lessThanXSeconds",5,a):y<10?s.formatDistance("lessThanXSeconds",10,a):y<20?s.formatDistance("lessThanXSeconds",20,a):y<40?s.formatDistance("halfAMinute",0,a):y<60?s.formatDistance("lessThanXMinutes",1,a):s.formatDistance("xMinutes",1,a):w===0?s.formatDistance("lessThanXMinutes",1,a):s.formatDistance("xMinutes",w,a);if(w<45)return s.formatDistance("xMinutes",w,a);if(w<90)return s.formatDistance("aboutXHours",1,a);if(wn.getTime()}function KW(t,e){const r=qn(t),n=qn(e);return+r<+n}function QZe(t,e){const r=e instanceof Date?la(e,0):new e(0);return r.setFullYear(t.getFullYear(),t.getMonth(),t.getDate()),r.setHours(t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()),r}const JZe=10;class pwe{constructor(){Vr(this,"subPriority",0)}validate(e,r){return!0}}class eXe extends pwe{constructor(e,r,n,s,o){super(),this.value=e,this.validateValue=r,this.setValue=n,this.priority=s,o&&(this.subPriority=o)}validate(e,r){return this.validateValue(e,this.value,r)}set(e,r,n){return this.setValue(e,r,this.value,n)}}class tXe extends pwe{constructor(){super(...arguments);Vr(this,"priority",JZe);Vr(this,"subPriority",-1)}set(r,n){return n.timestampIsSet?r:la(r,QZe(r,Date))}}class Bi{run(e,r,n,s){const o=this.parse(e,r,n,s);return o?{setter:new eXe(o.value,this.validate,this.set,this.priority,this.subPriority),rest:o.rest}:null}validate(e,r,n){return!0}}class rXe extends Bi{constructor(){super(...arguments);Vr(this,"priority",140);Vr(this,"incompatibleTokens",["R","u","t","T"])}parse(r,n,s){switch(n){case"G":case"GG":case"GGG":return s.era(r,{width:"abbreviated"})||s.era(r,{width:"narrow"});case"GGGGG":return s.era(r,{width:"narrow"});case"GGGG":default:return s.era(r,{width:"wide"})||s.era(r,{width:"abbreviated"})||s.era(r,{width:"narrow"})}}set(r,n,s){return n.era=s,r.setFullYear(s,0,1),r.setHours(0,0,0,0),r}}const zo={month:/^(1[0-2]|0?\d)/,date:/^(3[0-1]|[0-2]?\d)/,dayOfYear:/^(36[0-6]|3[0-5]\d|[0-2]?\d?\d)/,week:/^(5[0-3]|[0-4]?\d)/,hour23h:/^(2[0-3]|[0-1]?\d)/,hour24h:/^(2[0-4]|[0-1]?\d)/,hour11h:/^(1[0-1]|0?\d)/,hour12h:/^(1[0-2]|0?\d)/,minute:/^[0-5]?\d/,second:/^[0-5]?\d/,singleDigit:/^\d/,twoDigits:/^\d{1,2}/,threeDigits:/^\d{1,3}/,fourDigits:/^\d{1,4}/,anyDigitsSigned:/^-?\d+/,singleDigitSigned:/^-?\d/,twoDigitsSigned:/^-?\d{1,2}/,threeDigitsSigned:/^-?\d{1,3}/,fourDigitsSigned:/^-?\d{1,4}/},Lm={basicOptionalMinutes:/^([+-])(\d{2})(\d{2})?|Z/,basic:/^([+-])(\d{2})(\d{2})|Z/,basicOptionalSeconds:/^([+-])(\d{2})(\d{2})((\d{2}))?|Z/,extended:/^([+-])(\d{2}):(\d{2})|Z/,extendedOptionalSeconds:/^([+-])(\d{2}):(\d{2})(:(\d{2}))?|Z/};function Uo(t,e){return t&&{value:e(t.value),rest:t.rest}}function mo(t,e){const r=e.match(t);return r?{value:parseInt(r[0],10),rest:e.slice(r[0].length)}:null}function Mm(t,e){const r=e.match(t);if(!r)return null;if(r[0]==="Z")return{value:0,rest:e.slice(1)};const n=r[1]==="+"?1:-1,s=r[2]?parseInt(r[2],10):0,o=r[3]?parseInt(r[3],10):0,c=r[5]?parseInt(r[5],10):0;return{value:n*(s*UW+o*zW+c*BYe),rest:e.slice(r[0].length)}}function gwe(t){return mo(zo.anyDigitsSigned,t)}function Io(t,e){switch(t){case 1:return mo(zo.singleDigit,e);case 2:return mo(zo.twoDigits,e);case 3:return mo(zo.threeDigits,e);case 4:return mo(zo.fourDigits,e);default:return mo(new RegExp("^\\d{1,"+t+"}"),e)}}function cO(t,e){switch(t){case 1:return mo(zo.singleDigitSigned,e);case 2:return mo(zo.twoDigitsSigned,e);case 3:return mo(zo.threeDigitsSigned,e);case 4:return mo(zo.fourDigitsSigned,e);default:return mo(new RegExp("^-?\\d{1,"+t+"}"),e)}}function YW(t){switch(t){case"morning":return 4;case"evening":return 17;case"pm":case"noon":case"afternoon":return 12;case"am":case"midnight":case"night":default:return 0}}function ywe(t,e){const r=e>0,n=r?e:1-e;let s;if(n<=50)s=t||100;else{const o=n+50,c=Math.trunc(o/100)*100,a=t>=o%100;s=t+c-(a?100:0)}return r?s:1-s}function xwe(t){return t%400===0||t%4===0&&t%100!==0}class nXe extends Bi{constructor(){super(...arguments);Vr(this,"priority",130);Vr(this,"incompatibleTokens",["Y","R","u","w","I","i","e","c","t","T"])}parse(r,n,s){const o=c=>({year:c,isTwoDigitYear:n==="yy"});switch(n){case"y":return Uo(Io(4,r),o);case"yo":return Uo(s.ordinalNumber(r,{unit:"year"}),o);default:return Uo(Io(n.length,r),o)}}validate(r,n){return n.isTwoDigitYear||n.year>0}set(r,n,s){const o=r.getFullYear();if(s.isTwoDigitYear){const a=ywe(s.year,o);return r.setFullYear(a,0,1),r.setHours(0,0,0,0),r}const c=!("era"in n)||n.era===1?s.year:1-s.year;return r.setFullYear(c,0,1),r.setHours(0,0,0,0),r}}class sXe extends Bi{constructor(){super(...arguments);Vr(this,"priority",130);Vr(this,"incompatibleTokens",["y","R","u","Q","q","M","L","I","d","D","i","t","T"])}parse(r,n,s){const o=c=>({year:c,isTwoDigitYear:n==="YY"});switch(n){case"Y":return Uo(Io(4,r),o);case"Yo":return Uo(s.ordinalNumber(r,{unit:"year"}),o);default:return Uo(Io(n.length,r),o)}}validate(r,n){return n.isTwoDigitYear||n.year>0}set(r,n,s,o){const c=HW(r,o);if(s.isTwoDigitYear){const f=ywe(s.year,c);return r.setFullYear(f,0,o.firstWeekContainsDate),r.setHours(0,0,0,0),Bc(r,o)}const a=!("era"in n)||n.era===1?s.year:1-s.year;return r.setFullYear(a,0,o.firstWeekContainsDate),r.setHours(0,0,0,0),Bc(r,o)}}class iXe extends Bi{constructor(){super(...arguments);Vr(this,"priority",130);Vr(this,"incompatibleTokens",["G","y","Y","u","Q","q","M","L","w","d","D","e","c","t","T"])}parse(r,n){return cO(n==="R"?4:n.length,r)}set(r,n,s){const o=la(r,0);return o.setFullYear(s,0,4),o.setHours(0,0,0,0),Pg(o)}}class aXe extends Bi{constructor(){super(...arguments);Vr(this,"priority",130);Vr(this,"incompatibleTokens",["G","y","Y","R","w","I","i","e","c","t","T"])}parse(r,n){return cO(n==="u"?4:n.length,r)}set(r,n,s){return r.setFullYear(s,0,1),r.setHours(0,0,0,0),r}}class oXe extends Bi{constructor(){super(...arguments);Vr(this,"priority",120);Vr(this,"incompatibleTokens",["Y","R","q","M","L","w","I","d","D","i","e","c","t","T"])}parse(r,n,s){switch(n){case"Q":case"QQ":return Io(n.length,r);case"Qo":return s.ordinalNumber(r,{unit:"quarter"});case"QQQ":return s.quarter(r,{width:"abbreviated",context:"formatting"})||s.quarter(r,{width:"narrow",context:"formatting"});case"QQQQQ":return s.quarter(r,{width:"narrow",context:"formatting"});case"QQQQ":default:return s.quarter(r,{width:"wide",context:"formatting"})||s.quarter(r,{width:"abbreviated",context:"formatting"})||s.quarter(r,{width:"narrow",context:"formatting"})}}validate(r,n){return n>=1&&n<=4}set(r,n,s){return r.setMonth((s-1)*3,1),r.setHours(0,0,0,0),r}}class lXe extends Bi{constructor(){super(...arguments);Vr(this,"priority",120);Vr(this,"incompatibleTokens",["Y","R","Q","M","L","w","I","d","D","i","e","c","t","T"])}parse(r,n,s){switch(n){case"q":case"qq":return Io(n.length,r);case"qo":return s.ordinalNumber(r,{unit:"quarter"});case"qqq":return s.quarter(r,{width:"abbreviated",context:"standalone"})||s.quarter(r,{width:"narrow",context:"standalone"});case"qqqqq":return s.quarter(r,{width:"narrow",context:"standalone"});case"qqqq":default:return s.quarter(r,{width:"wide",context:"standalone"})||s.quarter(r,{width:"abbreviated",context:"standalone"})||s.quarter(r,{width:"narrow",context:"standalone"})}}validate(r,n){return n>=1&&n<=4}set(r,n,s){return r.setMonth((s-1)*3,1),r.setHours(0,0,0,0),r}}class cXe extends Bi{constructor(){super(...arguments);Vr(this,"incompatibleTokens",["Y","R","q","Q","L","w","I","D","i","e","c","t","T"]);Vr(this,"priority",110)}parse(r,n,s){const o=c=>c-1;switch(n){case"M":return Uo(mo(zo.month,r),o);case"MM":return Uo(Io(2,r),o);case"Mo":return Uo(s.ordinalNumber(r,{unit:"month"}),o);case"MMM":return s.month(r,{width:"abbreviated",context:"formatting"})||s.month(r,{width:"narrow",context:"formatting"});case"MMMMM":return s.month(r,{width:"narrow",context:"formatting"});case"MMMM":default:return s.month(r,{width:"wide",context:"formatting"})||s.month(r,{width:"abbreviated",context:"formatting"})||s.month(r,{width:"narrow",context:"formatting"})}}validate(r,n){return n>=0&&n<=11}set(r,n,s){return r.setMonth(s,1),r.setHours(0,0,0,0),r}}class uXe extends Bi{constructor(){super(...arguments);Vr(this,"priority",110);Vr(this,"incompatibleTokens",["Y","R","q","Q","M","w","I","D","i","e","c","t","T"])}parse(r,n,s){const o=c=>c-1;switch(n){case"L":return Uo(mo(zo.month,r),o);case"LL":return Uo(Io(2,r),o);case"Lo":return Uo(s.ordinalNumber(r,{unit:"month"}),o);case"LLL":return s.month(r,{width:"abbreviated",context:"standalone"})||s.month(r,{width:"narrow",context:"standalone"});case"LLLLL":return s.month(r,{width:"narrow",context:"standalone"});case"LLLL":default:return s.month(r,{width:"wide",context:"standalone"})||s.month(r,{width:"abbreviated",context:"standalone"})||s.month(r,{width:"narrow",context:"standalone"})}}validate(r,n){return n>=0&&n<=11}set(r,n,s){return r.setMonth(s,1),r.setHours(0,0,0,0),r}}function dXe(t,e,r){const n=qn(t),s=WW(n,r)-e;return n.setDate(n.getDate()-s*7),n}class hXe extends Bi{constructor(){super(...arguments);Vr(this,"priority",100);Vr(this,"incompatibleTokens",["y","R","u","q","Q","M","L","I","d","D","i","t","T"])}parse(r,n,s){switch(n){case"w":return mo(zo.week,r);case"wo":return s.ordinalNumber(r,{unit:"week"});default:return Io(n.length,r)}}validate(r,n){return n>=1&&n<=53}set(r,n,s,o){return Bc(dXe(r,s,o),o)}}function fXe(t,e){const r=qn(t),n=GW(r)-e;return r.setDate(r.getDate()-n*7),r}class mXe extends Bi{constructor(){super(...arguments);Vr(this,"priority",100);Vr(this,"incompatibleTokens",["y","Y","u","q","Q","M","L","w","d","D","e","c","t","T"])}parse(r,n,s){switch(n){case"I":return mo(zo.week,r);case"Io":return s.ordinalNumber(r,{unit:"week"});default:return Io(n.length,r)}}validate(r,n){return n>=1&&n<=53}set(r,n,s){return Pg(fXe(r,s))}}const pXe=[31,28,31,30,31,30,31,31,30,31,30,31],gXe=[31,29,31,30,31,30,31,31,30,31,30,31];class yXe extends Bi{constructor(){super(...arguments);Vr(this,"priority",90);Vr(this,"subPriority",1);Vr(this,"incompatibleTokens",["Y","R","q","Q","w","I","D","i","e","c","t","T"])}parse(r,n,s){switch(n){case"d":return mo(zo.date,r);case"do":return s.ordinalNumber(r,{unit:"date"});default:return Io(n.length,r)}}validate(r,n){const s=r.getFullYear(),o=xwe(s),c=r.getMonth();return o?n>=1&&n<=gXe[c]:n>=1&&n<=pXe[c]}set(r,n,s){return r.setDate(s),r.setHours(0,0,0,0),r}}class xXe extends Bi{constructor(){super(...arguments);Vr(this,"priority",90);Vr(this,"subpriority",1);Vr(this,"incompatibleTokens",["Y","R","q","Q","M","L","w","I","d","E","i","e","c","t","T"])}parse(r,n,s){switch(n){case"D":case"DD":return mo(zo.dayOfYear,r);case"Do":return s.ordinalNumber(r,{unit:"date"});default:return Io(n.length,r)}}validate(r,n){const s=r.getFullYear();return xwe(s)?n>=1&&n<=366:n>=1&&n<=365}set(r,n,s){return r.setMonth(0,s),r.setHours(0,0,0,0),r}}function ZW(t,e,r){var _,w,E,A;const n=g0(),s=(r==null?void 0:r.weekStartsOn)??((w=(_=r==null?void 0:r.locale)==null?void 0:_.options)==null?void 0:w.weekStartsOn)??n.weekStartsOn??((A=(E=n.locale)==null?void 0:E.options)==null?void 0:A.weekStartsOn)??0,o=qn(t),c=o.getDay(),f=(e%7+7)%7,m=7-s,y=e<0||e>6?e-(c+m)%7:(f+m)%7-(c+m)%7;return Ul(o,y)}class _Xe extends Bi{constructor(){super(...arguments);Vr(this,"priority",90);Vr(this,"incompatibleTokens",["D","i","e","c","t","T"])}parse(r,n,s){switch(n){case"E":case"EE":case"EEE":return s.day(r,{width:"abbreviated",context:"formatting"})||s.day(r,{width:"short",context:"formatting"})||s.day(r,{width:"narrow",context:"formatting"});case"EEEEE":return s.day(r,{width:"narrow",context:"formatting"});case"EEEEEE":return s.day(r,{width:"short",context:"formatting"})||s.day(r,{width:"narrow",context:"formatting"});case"EEEE":default:return s.day(r,{width:"wide",context:"formatting"})||s.day(r,{width:"abbreviated",context:"formatting"})||s.day(r,{width:"short",context:"formatting"})||s.day(r,{width:"narrow",context:"formatting"})}}validate(r,n){return n>=0&&n<=6}set(r,n,s,o){return r=ZW(r,s,o),r.setHours(0,0,0,0),r}}class vXe extends Bi{constructor(){super(...arguments);Vr(this,"priority",90);Vr(this,"incompatibleTokens",["y","R","u","q","Q","M","L","I","d","D","E","i","c","t","T"])}parse(r,n,s,o){const c=a=>{const f=Math.floor((a-1)/7)*7;return(a+o.weekStartsOn+6)%7+f};switch(n){case"e":case"ee":return Uo(Io(n.length,r),c);case"eo":return Uo(s.ordinalNumber(r,{unit:"day"}),c);case"eee":return s.day(r,{width:"abbreviated",context:"formatting"})||s.day(r,{width:"short",context:"formatting"})||s.day(r,{width:"narrow",context:"formatting"});case"eeeee":return s.day(r,{width:"narrow",context:"formatting"});case"eeeeee":return s.day(r,{width:"short",context:"formatting"})||s.day(r,{width:"narrow",context:"formatting"});case"eeee":default:return s.day(r,{width:"wide",context:"formatting"})||s.day(r,{width:"abbreviated",context:"formatting"})||s.day(r,{width:"short",context:"formatting"})||s.day(r,{width:"narrow",context:"formatting"})}}validate(r,n){return n>=0&&n<=6}set(r,n,s,o){return r=ZW(r,s,o),r.setHours(0,0,0,0),r}}class bXe extends Bi{constructor(){super(...arguments);Vr(this,"priority",90);Vr(this,"incompatibleTokens",["y","R","u","q","Q","M","L","I","d","D","E","i","e","t","T"])}parse(r,n,s,o){const c=a=>{const f=Math.floor((a-1)/7)*7;return(a+o.weekStartsOn+6)%7+f};switch(n){case"c":case"cc":return Uo(Io(n.length,r),c);case"co":return Uo(s.ordinalNumber(r,{unit:"day"}),c);case"ccc":return s.day(r,{width:"abbreviated",context:"standalone"})||s.day(r,{width:"short",context:"standalone"})||s.day(r,{width:"narrow",context:"standalone"});case"ccccc":return s.day(r,{width:"narrow",context:"standalone"});case"cccccc":return s.day(r,{width:"short",context:"standalone"})||s.day(r,{width:"narrow",context:"standalone"});case"cccc":default:return s.day(r,{width:"wide",context:"standalone"})||s.day(r,{width:"abbreviated",context:"standalone"})||s.day(r,{width:"short",context:"standalone"})||s.day(r,{width:"narrow",context:"standalone"})}}validate(r,n){return n>=0&&n<=6}set(r,n,s,o){return r=ZW(r,s,o),r.setHours(0,0,0,0),r}}function wXe(t,e){const r=qn(t),n=KZe(r),s=e-n;return Ul(r,s)}class SXe extends Bi{constructor(){super(...arguments);Vr(this,"priority",90);Vr(this,"incompatibleTokens",["y","Y","u","q","Q","M","L","w","d","D","E","e","c","t","T"])}parse(r,n,s){const o=c=>c===0?7:c;switch(n){case"i":case"ii":return Io(n.length,r);case"io":return s.ordinalNumber(r,{unit:"day"});case"iii":return Uo(s.day(r,{width:"abbreviated",context:"formatting"})||s.day(r,{width:"short",context:"formatting"})||s.day(r,{width:"narrow",context:"formatting"}),o);case"iiiii":return Uo(s.day(r,{width:"narrow",context:"formatting"}),o);case"iiiiii":return Uo(s.day(r,{width:"short",context:"formatting"})||s.day(r,{width:"narrow",context:"formatting"}),o);case"iiii":default:return Uo(s.day(r,{width:"wide",context:"formatting"})||s.day(r,{width:"abbreviated",context:"formatting"})||s.day(r,{width:"short",context:"formatting"})||s.day(r,{width:"narrow",context:"formatting"}),o)}}validate(r,n){return n>=1&&n<=7}set(r,n,s){return r=wXe(r,s),r.setHours(0,0,0,0),r}}class TXe extends Bi{constructor(){super(...arguments);Vr(this,"priority",80);Vr(this,"incompatibleTokens",["b","B","H","k","t","T"])}parse(r,n,s){switch(n){case"a":case"aa":case"aaa":return s.dayPeriod(r,{width:"abbreviated",context:"formatting"})||s.dayPeriod(r,{width:"narrow",context:"formatting"});case"aaaaa":return s.dayPeriod(r,{width:"narrow",context:"formatting"});case"aaaa":default:return s.dayPeriod(r,{width:"wide",context:"formatting"})||s.dayPeriod(r,{width:"abbreviated",context:"formatting"})||s.dayPeriod(r,{width:"narrow",context:"formatting"})}}set(r,n,s){return r.setHours(YW(s),0,0,0),r}}class EXe extends Bi{constructor(){super(...arguments);Vr(this,"priority",80);Vr(this,"incompatibleTokens",["a","B","H","k","t","T"])}parse(r,n,s){switch(n){case"b":case"bb":case"bbb":return s.dayPeriod(r,{width:"abbreviated",context:"formatting"})||s.dayPeriod(r,{width:"narrow",context:"formatting"});case"bbbbb":return s.dayPeriod(r,{width:"narrow",context:"formatting"});case"bbbb":default:return s.dayPeriod(r,{width:"wide",context:"formatting"})||s.dayPeriod(r,{width:"abbreviated",context:"formatting"})||s.dayPeriod(r,{width:"narrow",context:"formatting"})}}set(r,n,s){return r.setHours(YW(s),0,0,0),r}}class jXe extends Bi{constructor(){super(...arguments);Vr(this,"priority",80);Vr(this,"incompatibleTokens",["a","b","t","T"])}parse(r,n,s){switch(n){case"B":case"BB":case"BBB":return s.dayPeriod(r,{width:"abbreviated",context:"formatting"})||s.dayPeriod(r,{width:"narrow",context:"formatting"});case"BBBBB":return s.dayPeriod(r,{width:"narrow",context:"formatting"});case"BBBB":default:return s.dayPeriod(r,{width:"wide",context:"formatting"})||s.dayPeriod(r,{width:"abbreviated",context:"formatting"})||s.dayPeriod(r,{width:"narrow",context:"formatting"})}}set(r,n,s){return r.setHours(YW(s),0,0,0),r}}class kXe extends Bi{constructor(){super(...arguments);Vr(this,"priority",70);Vr(this,"incompatibleTokens",["H","K","k","t","T"])}parse(r,n,s){switch(n){case"h":return mo(zo.hour12h,r);case"ho":return s.ordinalNumber(r,{unit:"hour"});default:return Io(n.length,r)}}validate(r,n){return n>=1&&n<=12}set(r,n,s){const o=r.getHours()>=12;return o&&s<12?r.setHours(s+12,0,0,0):!o&&s===12?r.setHours(0,0,0,0):r.setHours(s,0,0,0),r}}class AXe extends Bi{constructor(){super(...arguments);Vr(this,"priority",70);Vr(this,"incompatibleTokens",["a","b","h","K","k","t","T"])}parse(r,n,s){switch(n){case"H":return mo(zo.hour23h,r);case"Ho":return s.ordinalNumber(r,{unit:"hour"});default:return Io(n.length,r)}}validate(r,n){return n>=0&&n<=23}set(r,n,s){return r.setHours(s,0,0,0),r}}class NXe extends Bi{constructor(){super(...arguments);Vr(this,"priority",70);Vr(this,"incompatibleTokens",["h","H","k","t","T"])}parse(r,n,s){switch(n){case"K":return mo(zo.hour11h,r);case"Ko":return s.ordinalNumber(r,{unit:"hour"});default:return Io(n.length,r)}}validate(r,n){return n>=0&&n<=11}set(r,n,s){return r.getHours()>=12&&s<12?r.setHours(s+12,0,0,0):r.setHours(s,0,0,0),r}}class CXe extends Bi{constructor(){super(...arguments);Vr(this,"priority",70);Vr(this,"incompatibleTokens",["a","b","h","H","K","t","T"])}parse(r,n,s){switch(n){case"k":return mo(zo.hour24h,r);case"ko":return s.ordinalNumber(r,{unit:"hour"});default:return Io(n.length,r)}}validate(r,n){return n>=1&&n<=24}set(r,n,s){const o=s<=24?s%24:s;return r.setHours(o,0,0,0),r}}class IXe extends Bi{constructor(){super(...arguments);Vr(this,"priority",60);Vr(this,"incompatibleTokens",["t","T"])}parse(r,n,s){switch(n){case"m":return mo(zo.minute,r);case"mo":return s.ordinalNumber(r,{unit:"minute"});default:return Io(n.length,r)}}validate(r,n){return n>=0&&n<=59}set(r,n,s){return r.setMinutes(s,0,0),r}}class PXe extends Bi{constructor(){super(...arguments);Vr(this,"priority",50);Vr(this,"incompatibleTokens",["t","T"])}parse(r,n,s){switch(n){case"s":return mo(zo.second,r);case"so":return s.ordinalNumber(r,{unit:"second"});default:return Io(n.length,r)}}validate(r,n){return n>=0&&n<=59}set(r,n,s){return r.setSeconds(s,0),r}}class RXe extends Bi{constructor(){super(...arguments);Vr(this,"priority",30);Vr(this,"incompatibleTokens",["t","T"])}parse(r,n){const s=o=>Math.trunc(o*Math.pow(10,-n.length+3));return Uo(Io(n.length,r),s)}set(r,n,s){return r.setMilliseconds(s),r}}class LXe extends Bi{constructor(){super(...arguments);Vr(this,"priority",10);Vr(this,"incompatibleTokens",["t","T","x"])}parse(r,n){switch(n){case"X":return Mm(Lm.basicOptionalMinutes,r);case"XX":return Mm(Lm.basic,r);case"XXXX":return Mm(Lm.basicOptionalSeconds,r);case"XXXXX":return Mm(Lm.extendedOptionalSeconds,r);case"XXX":default:return Mm(Lm.extended,r)}}set(r,n,s){return n.timestampIsSet?r:la(r,r.getTime()-Wx(r)-s)}}class MXe extends Bi{constructor(){super(...arguments);Vr(this,"priority",10);Vr(this,"incompatibleTokens",["t","T","X"])}parse(r,n){switch(n){case"x":return Mm(Lm.basicOptionalMinutes,r);case"xx":return Mm(Lm.basic,r);case"xxxx":return Mm(Lm.basicOptionalSeconds,r);case"xxxxx":return Mm(Lm.extendedOptionalSeconds,r);case"xxx":default:return Mm(Lm.extended,r)}}set(r,n,s){return n.timestampIsSet?r:la(r,r.getTime()-Wx(r)-s)}}class DXe extends Bi{constructor(){super(...arguments);Vr(this,"priority",40);Vr(this,"incompatibleTokens","*")}parse(r){return gwe(r)}set(r,n,s){return[la(r,s*1e3),{timestampIsSet:!0}]}}class OXe extends Bi{constructor(){super(...arguments);Vr(this,"priority",20);Vr(this,"incompatibleTokens","*")}parse(r){return gwe(r)}set(r,n,s){return[la(r,s),{timestampIsSet:!0}]}}const FXe={G:new rXe,y:new nXe,Y:new sXe,R:new iXe,u:new aXe,Q:new oXe,q:new lXe,M:new cXe,L:new uXe,w:new hXe,I:new mXe,d:new yXe,D:new xXe,E:new _Xe,e:new vXe,c:new bXe,i:new SXe,a:new TXe,b:new EXe,B:new jXe,h:new kXe,H:new AXe,K:new NXe,k:new CXe,m:new IXe,s:new PXe,S:new RXe,X:new LXe,x:new MXe,t:new DXe,T:new OXe},BXe=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,$Xe=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,zXe=/^'([^]*?)'?$/,UXe=/''/g,VXe=/\S/,qXe=/[a-zA-Z]/;function GXe(t,e,r,n){var C,I,M,D;const s=WZe(),o=s.locale??Z4,c=s.firstWeekContainsDate??((I=(C=s.locale)==null?void 0:C.options)==null?void 0:I.firstWeekContainsDate)??1,a=s.weekStartsOn??((D=(M=s.locale)==null?void 0:M.options)==null?void 0:D.weekStartsOn)??0;if(e==="")return t===""?qn(r):la(r,NaN);const f={firstWeekContainsDate:c,weekStartsOn:a,locale:o},m=[new tXe],y=e.match($Xe).map(B=>{const U=B[0];if(U in wq){const q=wq[U];return q(B,o.formatLong)}return B}).join("").match(BXe),_=[];for(let B of y){fwe(B)&&Sq(B,e,t),hwe(B)&&Sq(B,e,t);const U=B[0],q=FXe[U];if(q){const{incompatibleTokens:H}=q;if(Array.isArray(H)){const Q=_.find(J=>H.includes(J.token)||J.token===U);if(Q)throw new RangeError(`The format string mustn't contain \`${Q.fullToken}\` and \`${B}\` at the same time`)}else if(q.incompatibleTokens==="*"&&_.length>0)throw new RangeError(`The format string mustn't contain \`${B}\` and any other token at the same time`);_.push({token:U,fullToken:B});const K=q.run(t,B,o.match,f);if(!K)return la(r,NaN);m.push(K.setter),t=K.rest}else{if(U.match(qXe))throw new RangeError("Format string contains an unescaped latin alphabet character `"+U+"`");if(B==="''"?B="'":U==="'"&&(B=HXe(B)),t.indexOf(B)===0)t=t.slice(B.length);else return la(r,NaN)}}if(t.length>0&&VXe.test(t))return la(r,NaN);const w=m.map(B=>B.priority).sort((B,U)=>U-B).filter((B,U,q)=>q.indexOf(B)===U).map(B=>m.filter(U=>U.priority===B).sort((U,q)=>q.subPriority-U.subPriority)).map(B=>B[0]);let E=qn(r);if(isNaN(E.getTime()))return la(r,NaN);const A={};for(const B of w){if(!B.validate(E,f))return la(r,NaN);const U=B.set(E,A,f);Array.isArray(U)?(E=U[0],Object.assign(A,U[1])):E=U}return la(r,E)}function HXe(t){return t.match(zXe)[1].replace(UXe,"'")}function nT(t){return+qn(t)2)return e;if(/:/.test(r[0])?n=r[0]:(e.date=r[0],n=r[1],pL.timeZoneDelimiter.test(e.date)&&(e.date=t.split(pL.timeZoneDelimiter)[0],n=t.substr(e.date.length,t.length))),n){const s=pL.timezone.exec(n);s?(e.time=n.replace(s[1],""),e.timezone=s[1]):e.time=n}return e}function eQe(t,e){const r=new RegExp("^(?:(\\d{4}|[+-]\\d{"+(4+e)+"})|(\\d{2}|[+-]\\d{"+(2+e)+"})$)"),n=t.match(r);if(!n)return{year:NaN,restDateString:""};const s=n[1]?parseInt(n[1]):null,o=n[2]?parseInt(n[2]):null;return{year:o===null?s:o*100,restDateString:t.slice((n[1]||n[2]).length)}}function tQe(t,e){if(e===null)return new Date(NaN);const r=t.match(ZXe);if(!r)return new Date(NaN);const n=!!r[4],s=nk(r[1]),o=nk(r[2])-1,c=nk(r[3]),a=nk(r[4]),f=nk(r[5])-1;if(n)return lQe(e,a,f)?sQe(e,a,f):new Date(NaN);{const m=new Date(0);return!aQe(e,o,c)||!oQe(e,s)?new Date(NaN):(m.setUTCFullYear(e,o,Math.max(s,c)),m)}}function nk(t){return t?parseInt(t):1}function rQe(t){const e=t.match(XXe);if(!e)return NaN;const r=c6(e[1]),n=c6(e[2]),s=c6(e[3]);return cQe(r,n,s)?r*UW+n*zW+s*1e3:NaN}function c6(t){return t&&parseFloat(t.replace(",","."))||0}function nQe(t){if(t==="Z")return 0;const e=t.match(QXe);if(!e)return 0;const r=e[1]==="+"?-1:1,n=parseInt(e[2]),s=e[3]&&parseInt(e[3])||0;return uQe(n,s)?r*(n*UW+s*zW):NaN}function sQe(t,e,r){const n=new Date(0);n.setUTCFullYear(t,0,4);const s=n.getUTCDay()||7,o=(e-1)*7+r+1-s;return n.setUTCDate(n.getUTCDate()+o),n}const iQe=[31,null,31,30,31,30,31,31,30,31,30,31];function _we(t){return t%400===0||t%4===0&&t%100!==0}function aQe(t,e,r){return e>=0&&e<=11&&r>=1&&r<=(iQe[e]||(_we(t)?29:28))}function oQe(t,e){return e>=1&&e<=(_we(t)?366:365)}function lQe(t,e,r){return e>=1&&e<=53&&r>=0&&r<=6}function cQe(t,e,r){return t===24?e===0&&r===0:r>=0&&r<60&&e>=0&&e<60&&t>=0&&t<25}function uQe(t,e){return e>=0&&e<=59}function u6(t,e){const r=qn(t),n=r.getFullYear(),s=r.getDate(),o=la(t,0);o.setFullYear(n,e,15),o.setHours(0,0,0,0);const c=HZe(o);return r.setMonth(e,Math.min(s,c)),r}function Zse(t,e){const r=qn(t);return isNaN(+r)?la(t,NaN):(r.setFullYear(e),r)}function dQe(t,e){return $d(t,-e)}const hQe=()=>{const{user:t}=Zn(),e=ra(),[r,n]=N.useState([]),[s,o]=N.useState(0),[c,a]=N.useState(!1),[f,m]=N.useState(null),y=N.useRef(null);N.useEffect(()=>{y.current=f},[f]),N.useEffect(()=>{if(!t)return;const C=`notification_last_read_${t.id}`,I=localStorage.getItem(C);I&&!y.current&&(y.current=I,m(I));const M=`nb_cache_${t.id}`,D=60*1e3,B=async()=>{try{const Q=sessionStorage.getItem(M);if(Q){const J=JSON.parse(Q);if(J.ts&&Date.now()-J.ts{n(H);const K=y.current?new Date(y.current):null,Q=H.filter(J=>K?new Date(J.created_at)>K:!0);o(Q.length)};B();const q=Ce.channel("push-notifications").on("postgres_changes",{event:"INSERT",schema:"public",table:"push_notifications"},H=>{const K=H.new;n(J=>{const ee=[K,...J].slice(0,20);try{sessionStorage.setItem(M,JSON.stringify({ts:Date.now(),data:ee}))}catch{}return ee});const Q=y.current?new Date(y.current):null;(!Q||new Date(K.created_at)>Q)&&o(J=>J+1),Notification.permission==="granted"&&new Notification(K.title,{body:K.body,icon:"/favicon.ico"})}).subscribe();return()=>{Ce.removeChannel(q)}},[t]);const _=C=>{const I=C.toLowerCase();return I.includes("community")||I.includes("post")?Nh:I.includes("academy")||I.includes("video")?tA:I.includes("template")?a4:I.includes("event")?xo:I.includes("newsletter")?iye:I.includes("brokerage")?d8:I.includes("swag")||I.includes("social")?Rf:I.includes("toolbox")||I.includes("tool")?wH:I.includes("brief")?ki:Nh},w=C=>{a(!1),C.url&&C.url!=="/"&&e(C.url)},E=()=>{if(!t)return;const C=new Date().toISOString(),I=`notification_last_read_${t.id}`;localStorage.setItem(I,C),m(C),o(0)},A=C=>{a(C),C&&s>0&&E()};return i.jsxs(tE,{open:c,onOpenChange:A,children:[i.jsx(rE,{asChild:!0,children:i.jsxs(Lt,{variant:"ghost",size:"icon",className:"relative",children:[i.jsx(gC,{className:"h-5 w-5"}),s>0&&i.jsx(pi,{variant:"destructive",className:"absolute -top-1 -right-1 h-5 w-5 flex items-center justify-center p-0 text-xs",children:s>9?"9+":s})]})}),i.jsxs(cb,{align:"end",className:"w-80",children:[i.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b",children:[i.jsx("span",{className:"font-semibold",children:"Notifications"}),r.length>0&&i.jsx(Lt,{variant:"ghost",size:"sm",className:"text-xs h-6",onClick:E,children:"Mark all read"})]}),i.jsx(cp,{className:"h-[300px]",children:r.length===0?i.jsx("div",{className:"p-4 text-center text-muted-foreground text-sm",children:"No notifications yet"}):r.map(C=>{const I=_(C.title);return i.jsxs(mu,{className:"group flex items-start gap-3 p-3 cursor-pointer data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground",onClick:()=>w(C),children:[i.jsx("div",{className:"flex-shrink-0 mt-0.5",children:i.jsx(I,{className:"h-4 w-4 text-primary"})}),i.jsxs("div",{className:"flex flex-col gap-1 min-w-0",children:[i.jsx("span",{className:"font-medium text-sm",children:C.title}),i.jsx("span",{className:"text-xs text-muted-foreground line-clamp-2 group-data-[highlighted]:text-accent-foreground/80",children:C.body}),i.jsx("span",{className:"text-xs text-muted-foreground group-data-[highlighted]:text-accent-foreground/80",children:mwe(new Date(C.created_at),{addSuffix:!0})})]})]},C.id)})})]})]})};function fQe(t){if(!(t!=null&&t.length))return null;const e=n=>n.is_active&&!!n.mls_provider_id&&!n.no_mls_mode,r=n=>(n.owner_type||"agent")==="agent";return t.find(n=>e(n)&&r(n)&&!!(n.mls_agent_id||n.mls_agent_key))||t.find(n=>e(n)&&r(n))||t.find(e)||t.find(r)||t[0]}function XW(){const{user:t}=Zn(),{data:e,isLoading:r}=mr({queryKey:["agent-lead-site",t==null?void 0:t.id],queryFn:async()=>{const{data:n,error:s}=await Ce.from("lead_sites").select("id, subdomain_slug, custom_domain, site_title, is_active, plan_tier, mls_provider_id, no_mls_mode, mls_agent_id, mls_agent_key, mls_office_id, mls_service_cities, mls_disclaimer_text, brokerage_legal_name, owner_type").eq("agent_id",t.id).eq("is_active",!0).order("created_at",{ascending:!0}).limit(10);if(s)throw s;return fQe(n)},enabled:!!t,staleTime:5*60*1e3});return{leadSite:e??null,hasLeadSite:!!e,isFreePlan:(e==null?void 0:e.plan_tier)==="free_luxury",hasIdx:!!(e!=null&&e.mls_provider_id)&&!(e!=null&&e.no_mls_mode),isLoading:r,siteUrl:e?e.custom_domain?`https://${e.custom_domain}`:`https://${e.subdomain_slug}.thelocalmove.com`:null}}function mQe(t){const[e,r]=N.useState([]),[n,s]=N.useState(!1),[o,c]=N.useState(()=>Date.now());N.useEffect(()=>{const _=setInterval(()=>c(Date.now()),15e3);return()=>clearInterval(_)},[]);const{data:a,isLoading:f}=mr({queryKey:["active-visitors",t],queryFn:async()=>{if(!t)return[];try{await Ce.rpc("cleanup_stale_visitors")}catch{}const{data:_}=await Ce.from("lead_site_active_visitors").select("*").eq("lead_site_id",t).gte("last_seen_at",new Date(Date.now()-2*60*1e3).toISOString()).order("last_seen_at",{ascending:!1});if(!_)return[];const w=_.map(C=>C.contact_id).filter(Boolean);let E={};if(w.length>0){const{data:C}=await Ce.from("innercircle_contacts").select("id, first_name, last_name, email, phone").in("id",w);(C||[]).forEach(I=>{E[I.id]=I})}const A=_.map(C=>C.auth_user_id).filter(Boolean);if(A.length>0){const{data:C}=await Ce.from("lead_site_consumer_profiles").select("user_id, name, phone, contact_id").eq("lead_site_id",t).in("user_id",A);(C||[]).forEach(I=>{const M=_.find(D=>D.auth_user_id===I.user_id);M&&!M.contact_id&&I.contact_id&&(M.contact_id=I.contact_id),M&&!E[M.contact_id||""]&&I.name&&(E[M.contact_id||M.auth_user_id||""]={first_name:I.name.split(" ")[0],last_name:I.name.split(" ").slice(1).join(" ")||null,email:null,phone:I.phone})})}return _.map(C=>{var I,M;return{...C,contact_name:E[C.contact_id||C.auth_user_id||""]?`${E[C.contact_id||C.auth_user_id||""].first_name} ${E[C.contact_id||C.auth_user_id||""].last_name||""}`.trim():null,contact_email:((I=E[C.contact_id||C.auth_user_id||""])==null?void 0:I.email)||null,contact_phone:((M=E[C.contact_id||C.auth_user_id||""])==null?void 0:M.phone)||null}})},enabled:!!t,refetchInterval:6e4});N.useEffect(()=>{if(!t)return;const _=Ce.channel(`active-visitors-${t}`).on("postgres_changes",{event:"*",schema:"public",table:"lead_site_active_visitors",filter:`lead_site_id=eq.${t}`},w=>{w.eventType==="INSERT"?r(E=>E.find(C=>C.id===w.new.id)?E:[w.new,...E]):w.eventType==="UPDATE"?r(E=>E.map(A=>A.id===w.new.id?{...A,...w.new}:A)):w.eventType==="DELETE"&&r(E=>E.filter(A=>A.id!==w.old.id))}).subscribe(w=>{w==="SUBSCRIBED"&&s(!0)});return()=>{Ce.removeChannel(_)}},[t]);const y=(n&&e.length>0?gQe([...e,...a||[]]):a||[]).filter(_=>o-new Date(_.last_seen_at).getTime()new Date(n.last_seen_at).getTime())&&e.set(r.id,r)}return[...e.values()]}let Oy=null;function d6(){try{const t=window.AudioContext||window.webkitAudioContext;if(!t)return;Oy=Oy||new t,Oy.state==="suspended"&&Oy.resume();const e=Oy.currentTime;[880,1318.5].forEach((r,n)=>{const s=Oy.createOscillator(),o=Oy.createGain();s.type="sine",s.frequency.value=r;const c=e+n*.14;o.gain.setValueAtTime(1e-4,c),o.gain.exponentialRampToValueAtTime(.25,c+.02),o.gain.exponentialRampToValueAtTime(1e-4,c+.6),s.connect(o).connect(Oy.destination),s.start(c),s.stop(c+.65)})}catch{}}function yQe(t,e=sessionStorage){const r=`lu_ding_${t}`;return e.getItem(r)?!1:(e.setItem(r,"1"),!0)}function xQe(t,e){return[`Hi there! I'm online right now — happy to answer any questions${t&&e?` about ${t}`:""}.`,e?"Would you like a private showing or a video walkthrough of this home?":"Looking for something specific? I can send you homes that match.","Hi! Want me to send you a list of similar homes, including ones not online yet?"]}const Xse="lu_live_ding";function _Qe(){const{user:t}=Zn(),{leadSite:e}=XW(),r=e==null?void 0:e.id,{activeVisitors:n}=mQe(r),[s,o]=N.useState(!1),[c,a]=N.useState(null),[f,m]=N.useState([]),[y,_]=N.useState(""),[w,E]=N.useState(()=>localStorage.getItem(Xse)!=="off"),A=N.useRef(w);A.current=w,N.useEffect(()=>{for(const H of n){const K=H.visitor_fingerprint||H.id;yQe(`${r}_${K}`)&&(A.current&&d6(),$t(`${H.contact_name||"Someone"} is on your website`,{description:H.current_page_title||H.current_page_path,action:{label:"Say hi",onClick:()=>{o(!0),a(K)}}}))}},[n,r]),N.useEffect(()=>{if(!r)return;const H=new Date(Date.now()-24*3600*1e3).toISOString();Ce.from("lead_site_live_chat_messages").select("id, visitor_token, sender, body, created_at").eq("lead_site_id",r).gte("created_at",H).order("created_at").limit(500).then(({data:Q})=>m(Q||[]));const K=Ce.channel(`live-chat-${r}-${Math.random().toString(36).slice(2)}`).on("postgres_changes",{event:"INSERT",schema:"public",table:"lead_site_live_chat_messages",filter:`lead_site_id=eq.${r}`},Q=>{const J=Q.new;m(ee=>ee.some(oe=>oe.id===J.id)?ee:[...ee,J]),J.sender==="visitor"&&(A.current&&d6(),$t("New chat reply from your website",{description:J.body.slice(0,120),action:{label:"Open",onClick:()=>{o(!0),a(J.visitor_token)}}}))}).subscribe();return()=>{Ce.removeChannel(K)}},[r]);const C=N.useMemo(()=>f.filter(H=>H.visitor_token===c),[f,c]),I=n.find(H=>(H.visitor_fingerprint||H.id)===c),M=xQe(I==null?void 0:I.current_page_title,!!(I!=null&&I.current_mls_number)),D=async H=>{if(!r||!c||!t||!H.trim())return;const{error:K}=await Ce.from("lead_site_live_chat_messages").insert({lead_site_id:r,visitor_token:c,sender:"agent",body:H.trim(),agent_user_id:t.id});if(K){$t.error("Message could not be sent");return}_("")};if(!r)return null;const B=n.length,U=Array.from(new Set(f.map(H=>H.visitor_token))),q=[...n.map(H=>({key:H.visitor_fingerprint||H.id,v:H})),...U.filter(H=>!n.some(K=>(K.visitor_fingerprint||K.id)===H)).map(H=>({key:H}))];return i.jsxs(i.Fragment,{children:[i.jsxs(Lt,{variant:"ghost",size:"icon",className:"relative","aria-label":"Live website visitors",title:"Live website visitors",onClick:()=>o(H=>!H),children:[i.jsx(RD,{className:`h-5 w-5 ${B?"text-primary":""}`}),B>0&&i.jsx("span",{className:"absolute -top-0.5 -right-0.5 min-w-[18px] h-[18px] rounded-full bg-primary text-primary-foreground text-[10px] font-bold flex items-center justify-center px-1",children:B})]}),s&&sp.createPortal(i.jsxs("div",{className:"fixed top-16 right-4 z-[70] w-[min(94vw,420px)] max-h-[80vh] rounded-2xl border bg-card text-card-foreground shadow-2xl flex flex-col overflow-hidden",children:[i.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 border-b",children:[i.jsx(RD,{className:"h-4 w-4 text-primary"}),i.jsx("p",{className:"font-semibold text-sm flex-1",children:c?"Live chat":`Live on your website (${B})`}),i.jsx("button",{"aria-label":w?"Mute ding":"Turn on ding",onClick:()=>{const H=!w;E(H),localStorage.setItem(Xse,H?"on":"off"),H&&d6()},children:w?i.jsx(dye,{className:"h-4 w-4"}):i.jsx(hye,{className:"h-4 w-4 text-muted-foreground"})}),c&&i.jsx("button",{className:"text-xs text-primary",onClick:()=>a(null),children:"All visitors"}),i.jsx("button",{"aria-label":"Close",onClick:()=>o(!1),children:i.jsx(Ci,{className:"h-4 w-4"})})]}),c?i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"px-4 py-2 text-xs text-muted-foreground border-b",children:I?`${I.contact_name||"Anonymous visitor"} · viewing ${I.current_page_title||I.current_page_path}`:"Visitor may have left the site"}),i.jsxs("div",{className:"flex-1 overflow-y-auto p-3 space-y-2 bg-muted/40 min-h-[160px]",children:[C.map(H=>i.jsx("div",{className:`max-w-[85%] rounded-2xl px-3 py-2 text-sm whitespace-pre-wrap ${H.sender==="agent"?"ml-auto bg-primary text-primary-foreground":"bg-background border"}`,children:H.body},H.id)),C.length===0&&M.map(H=>i.jsx("button",{className:"block w-full text-left text-sm rounded-xl border bg-background px-3 py-2 hover:border-primary",onClick:()=>D(H),children:H},H))]}),i.jsxs("form",{className:"flex gap-2 p-2 border-t",onSubmit:H=>{H.preventDefault(),D(y)},children:[i.jsx(zc,{rows:2,value:y,maxLength:2e3,placeholder:"Write a message…",onChange:H=>_(H.target.value),onKeyDown:H=>{H.key==="Enter"&&!H.shiftKey&&(H.preventDefault(),D(y))}}),i.jsx(Lt,{type:"submit",size:"icon","aria-label":"Send",children:i.jsx(VA,{className:"h-4 w-4"})})]})]}):i.jsxs("div",{className:"overflow-y-auto divide-y",children:[q.length===0&&i.jsx("p",{className:"p-6 text-sm text-muted-foreground text-center",children:"No one is on your website right now. You'll hear a ding when someone arrives."}),q.map(({key:H,v:K})=>i.jsxs("div",{className:"flex items-center gap-3 px-4 py-3",children:[i.jsx("span",{className:`h-2.5 w-2.5 rounded-full ${K?"bg-primary animate-pulse":"bg-muted-foreground/40"}`}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("p",{className:"text-sm font-medium truncate",children:(K==null?void 0:K.contact_name)||"Anonymous visitor"}),i.jsx("p",{className:"text-xs text-muted-foreground truncate",children:K?K.current_page_title||K.current_page_path:"Left the site"})]}),i.jsxs(Lt,{size:"sm",variant:f.some(Q=>Q.visitor_token===H)?"outline":"default",onClick:()=>a(H),children:[i.jsx(Fv,{className:"h-4 w-4 mr-1"}),f.some(Q=>Q.visitor_token===H)?"Open":"Say hi"]})]},H))]})]}),document.body)]})}function vQe(){const{managedBrokerages:t,selectedBrokerageId:e,setSelectedBrokerageId:r}=Zn(),n=jr();if(t.length<2)return null;const s=t.find(o=>o.id===e)??t[0];return i.jsxs(tE,{children:[i.jsx(rE,{asChild:!0,children:i.jsxs(Lt,{variant:"outline",size:"sm",className:"gap-2 max-w-[220px]",title:"Switch brokerage",children:[i.jsx(Ja,{className:"h-4 w-4 shrink-0 text-primary"}),i.jsx("span",{className:"truncate hidden md:inline",children:s.name}),i.jsx(Go,{className:"h-3.5 w-3.5 shrink-0 opacity-60"})]})}),i.jsxs(cb,{align:"end",className:"w-64",children:[i.jsx(fW,{className:"text-xs text-muted-foreground",children:"Managing brokerage"}),i.jsx(XS,{}),t.map(o=>i.jsxs(mu,{onSelect:()=>{o.id!==s.id&&(r(o.id),n.invalidateQueries(),$t.success(`Now managing ${o.name}`))},children:[i.jsx(pa,{className:`mr-2 h-4 w-4 ${o.id===s.id?"opacity-100":"opacity-0"}`}),i.jsx("span",{className:"truncate",children:o.name})]},o.id))]})]})}function bQe(t){return!!t&&t.plan_tier==="free_beta"&&!!t.no_mls_mode&&!t.mls_provider_id}function vwe(t=!0){const{user:e}=Zn(),{data:r,isLoading:n}=mr({queryKey:["free-lead-site-offer",e==null?void 0:e.id],enabled:!!e&&t,staleTime:5*60*1e3,queryFn:async()=>{const{data:s}=await Ce.from("profiles").select("brokerage_id").eq("id",e.id).maybeSingle();if(!(s!=null&&s.brokerage_id))return null;const{data:o}=await Ce.from("lead_site_brokerage_offers").select("*").eq("brokerage_id",s.brokerage_id).eq("enabled",!0).maybeSingle();return o??null}});return{offer:r??null,hasOffer:!!r,isLoading:n}}const wQe="coaching_access";function SQe(){const{user:t,loading:e,isAdmin:r,isCoach:n}=Zn(),{data:s,isLoading:o}=mr({queryKey:["coaching-access",t==null?void 0:t.id],enabled:!!t,staleTime:5*60*1e3,queryFn:async()=>{const[c,a]=await Promise.all([Ce.from("coaching_assignments").select("id").eq("agent_id",t.id).eq("status","active").limit(1),Ce.from("feature_entitlements").select("enabled, expires_at").eq("user_id",t.id).eq("feature_key",wQe).maybeSingle()]),f=(c.data||[]).length>0,m=a.data,y=!!(m!=null&&m.enabled)&&(!m.expires_at||new Date(m.expires_at).getTime()>Date.now());return{hasAssignment:f,entitled:y}}});return{hasAccess:!!(r||n||s!=null&&s.hasAssignment||s!=null&&s.entitled),hasAssignment:!!(s!=null&&s.hasAssignment),isLoading:e||o}}const ei=Ce,qQt=[{value:"contract",label:"Under contract"},{value:"inspection",label:"Inspection / due diligence"},{value:"closing",label:"Closing"},{value:"closed",label:"Closed"}];function GQt(t){return t.total_items===0?"not_started":t.rejected_items>0?"changes_requested":t.approved_items>=t.total_items?"compliant":"in_review"}const HQt={not_started:"Not started",in_review:"In review",changes_requested:"Changes requested",compliant:"Compliant"};function TQe(){return mr({queryKey:["transaction-admin-seats"],queryFn:async()=>{const{data:t}=await Ce.auth.getUser();if(!t.user)return[];const{data:e,error:r}=await ei.from("brokerage_transaction_admins").select("brokerage_id").eq("user_id",t.user.id);if(r)throw r;return e||[]}})}function WQt(t){return mr({queryKey:["transaction-admins",t],enabled:!!t,queryFn:async()=>{const{data:e,error:r}=await ei.from("brokerage_transaction_admins").select("id, user_id, created_at").eq("brokerage_id",t);if(r)throw r;const n=e||[];if(n.length===0)return[];const{data:s}=await ei.from("profiles").select("id, name, email").in("id",n.map(c=>c.user_id)),o=new Map((s||[]).map(c=>[c.id,{name:c.name??null,email:c.email??null}]));return n.map(c=>{var a,f;return{...c,name:((a=o.get(c.user_id))==null?void 0:a.name)??null,email:((f=o.get(c.user_id))==null?void 0:f.email)??null}})}})}function KQt(){const t=jr();return kr({mutationFn:async({brokerageId:e,userId:r})=>{const{error:n}=await ei.from("brokerage_transaction_admins").insert({brokerage_id:e,user_id:r});if(n)throw n},onSuccess:(e,r)=>t.invalidateQueries({queryKey:["transaction-admins",r.brokerageId]})})}function YQt(){const t=jr();return kr({mutationFn:async({id:e})=>{const{error:r}=await ei.from("brokerage_transaction_admins").delete().eq("id",e);if(r)throw r},onSuccess:(e,r)=>t.invalidateQueries({queryKey:["transaction-admins",r.brokerageId]})})}function ZQt(t){return mr({queryKey:["compliance-settings",t],enabled:!!t,queryFn:async()=>{const{data:e,error:r}=await ei.from("brokerage_compliance_settings").select("*").eq("brokerage_id",t).maybeSingle();if(r)throw r;return e}})}function XQt(){const t=jr();return kr({mutationFn:async e=>{const{error:r}=await ei.from("brokerage_compliance_settings").upsert(e,{onConflict:"brokerage_id"});if(r)throw r},onSuccess:(e,r)=>{t.invalidateQueries({queryKey:["compliance-settings",r.brokerage_id]}),t.invalidateQueries({queryKey:["compliance-deals"]})}})}function QQt(t){return mr({queryKey:["compliance-templates",t],enabled:!!t,queryFn:async()=>{const{data:e,error:r}=await ei.from("brokerage_checklist_templates").select("*").eq("brokerage_id",t).order("created_at",{ascending:!0});if(r)throw r;return e||[]}})}function JQt(t){return mr({queryKey:["compliance-template-items",t],enabled:!!t,queryFn:async()=>{const{data:e,error:r}=await ei.from("brokerage_checklist_template_items").select("*").eq("template_id",t).order("sort_order",{ascending:!0});if(r)throw r;return e||[]}})}function eJt(){const t=jr();return kr({mutationFn:async e=>{if(e.id){const{error:s}=await ei.from("brokerage_checklist_templates").update(e).eq("id",e.id);if(s)throw s;return e.id}const{data:r,error:n}=await ei.from("brokerage_checklist_templates").insert(e).select("id").single();if(n)throw n;return r.id},onSuccess:(e,r)=>t.invalidateQueries({queryKey:["compliance-templates",r.brokerage_id]})})}function tJt(){const t=jr();return kr({mutationFn:async({id:e})=>{const{error:r}=await ei.from("brokerage_checklist_templates").delete().eq("id",e);if(r)throw r},onSuccess:(e,r)=>t.invalidateQueries({queryKey:["compliance-templates",r.brokerageId]})})}function rJt(){const t=jr();return kr({mutationFn:async e=>{if(e.id){const{error:n}=await ei.from("brokerage_checklist_template_items").update(e).eq("id",e.id);if(n)throw n;return}const{error:r}=await ei.from("brokerage_checklist_template_items").insert(e);if(r)throw r},onSuccess:(e,r)=>t.invalidateQueries({queryKey:["compliance-template-items",r.template_id]})})}function nJt(){const t=jr();return kr({mutationFn:async({id:e})=>{const{error:r}=await ei.from("brokerage_checklist_template_items").delete().eq("id",e);if(r)throw r},onSuccess:(e,r)=>t.invalidateQueries({queryKey:["compliance-template-items",r.templateId]})})}function sJt(t){return mr({queryKey:["compliance-deals",t],enabled:!!t,queryFn:async()=>{const{data:e,error:r}=await ei.rpc("get_brokerage_compliance_deals",{_brokerage_id:t});if(r)throw r;return e||[]}})}function iJt(t){return mr({queryKey:["deal-compliance-items",t],enabled:!!t,queryFn:async()=>{const{data:e,error:r}=await ei.from("deal_compliance_items").select("*").eq("deal_id",t).order("sort_order",{ascending:!0});if(r)throw r;return e||[]}})}function aJt(t){return mr({queryKey:["deal-compliance-events",t],enabled:!!t,queryFn:async()=>{const{data:e,error:r}=await ei.from("deal_compliance_events").select("*").eq("deal_id",t).order("created_at",{ascending:!1}).limit(200);if(r)throw r;return e||[]}})}async function BC(t){var r;const{data:e}=await Ce.auth.getUser();await ei.from("deal_compliance_events").insert({deal_id:t.dealId,brokerage_id:t.brokerageId??null,item_id:t.itemId??null,actor_user_id:((r=e.user)==null?void 0:r.id)??null,event_type:t.eventType,detail:t.detail??null})}function oJt(){const t=jr();return kr({mutationFn:async({item:e,status:r,note:n})=>{var c;const{data:s}=await Ce.auth.getUser(),{error:o}=await ei.from("deal_compliance_items").update({status:r,review_note:n??null,reviewed_by:((c=s.user)==null?void 0:c.id)??null,reviewed_at:new Date().toISOString()}).eq("id",e.id);if(o)throw o;await BC({dealId:e.deal_id,brokerageId:e.brokerage_id,itemId:e.id,eventType:r==="approved"?"item_approved":r==="rejected"?"item_rejected":"item_updated",detail:n?`${e.title}: ${n}`:e.title})},onSuccess:(e,r)=>{t.invalidateQueries({queryKey:["deal-compliance-items",r.item.deal_id]}),t.invalidateQueries({queryKey:["deal-compliance-events",r.item.deal_id]}),t.invalidateQueries({queryKey:["compliance-deals"]})}})}function lJt(){const t=jr();return kr({mutationFn:async({dealId:e,brokerageId:r,templateId:n,deal:s})=>{const{data:o,error:c}=await ei.from("brokerage_checklist_template_items").select("*").eq("template_id",n).order("sort_order",{ascending:!0});if(c)throw c;const a=(y,_)=>{if(!y)return null;const[w,E,A]=y.split(/[-/T]/).map(Number);return new Date(Date.UTC(w,E-1,A+(_||0))).toISOString().slice(0,10)},f=(o||[]).map(y=>({deal_id:e,brokerage_id:r,template_item_id:y.id,title:y.title,description:y.description,phase:y.phase,requires_document:y.requires_document,required_for_closing:y.required_for_closing,due_date:y.due_anchor==="contract_date"?a(s==null?void 0:s.contract_date,y.due_offset_days):y.due_anchor==="target_close_date"?a(s==null?void 0:s.target_close_date,y.due_offset_days):null,sort_order:y.sort_order}));if(f.length===0)return;const{error:m}=await ei.from("deal_compliance_items").insert(f);if(m)throw m;await BC({dealId:e,brokerageId:r,eventType:"checklist_applied",detail:`${f.length} items added`})},onSuccess:(e,r)=>{t.invalidateQueries({queryKey:["deal-compliance-items",r.dealId]}),t.invalidateQueries({queryKey:["deal-compliance-events",r.dealId]}),t.invalidateQueries({queryKey:["compliance-deals"]})}})}function cJt(t){return mr({queryKey:["deal-compliance-files",t],enabled:!!t,queryFn:async()=>{const{data:e,error:r}=await ei.from("deal_files").select("id, deal_id, compliance_item_id, file_name, file_size, storage_path, version_no, is_current, created_at, owner_user_id").eq("deal_id",t).not("compliance_item_id","is",null).order("version_no",{ascending:!1});if(r)throw r;return e||[]}})}function uJt(){const t=jr();return kr({mutationFn:async({item:e,file:r})=>{var _,w;const{data:n}=await Ce.auth.getUser(),s=(_=n.user)==null?void 0:_.id;if(!s)throw new Error("Not signed in");const{data:o}=await ei.from("deal_files").select("id, version_no").eq("compliance_item_id",e.id).order("version_no",{ascending:!1}).limit(1),c=(((w=o==null?void 0:o[0])==null?void 0:w.version_no)||0)+1,a=r.name.split(".").pop(),f=`${s}/${e.deal_id}/${crypto.randomUUID()}.${a}`,{error:m}=await Ce.storage.from("deal-files").upload(f,r);if(m)throw m;o!=null&&o.length&&await ei.from("deal_files").update({is_current:!1}).eq("compliance_item_id",e.id);const{error:y}=await ei.from("deal_files").insert({deal_id:e.deal_id,owner_user_id:s,file_name:r.name,file_size:r.size,file_type:r.type||null,storage_path:f,compliance_item_id:e.id,version_no:c,is_current:!0});if(y)throw y;await ei.from("deal_compliance_items").update({status:"submitted",review_note:null,reviewed_at:null,reviewed_by:null}).eq("id",e.id),await BC({dealId:e.deal_id,brokerageId:e.brokerage_id,itemId:e.id,eventType:"document_uploaded",detail:`${e.title} — ${r.name} (v${c})`})},onSuccess:(e,r)=>{t.invalidateQueries({queryKey:["deal-compliance-files",r.item.deal_id]}),t.invalidateQueries({queryKey:["deal-compliance-items",r.item.deal_id]}),t.invalidateQueries({queryKey:["deal-compliance-events",r.item.deal_id]}),t.invalidateQueries({queryKey:["deal-files",r.item.deal_id]}),t.invalidateQueries({queryKey:["compliance-deals"]})}})}async function dJt(t){const{data:e,error:r}=await Ce.storage.from("deal-files").createSignedUrl(t,3600);if(r)throw r;window.open(e.signedUrl,"_blank","noopener,noreferrer")}function hJt(t){return mr({queryKey:["deal-compliance-messages",t],enabled:!!t,refetchInterval:3e4,queryFn:async()=>{const{data:e,error:r}=await ei.from("deal_compliance_messages").select("*").eq("deal_id",t).order("created_at",{ascending:!0});if(r)throw r;const n=e||[],s=Array.from(new Set(n.map(a=>a.sender_user_id)));if(s.length===0)return n;const{data:o}=await ei.from("profiles").select("id, name").in("id",s),c=new Map((o||[]).map(a=>[a.id,a.name??null]));return n.map(a=>({...a,sender_name:c.get(a.sender_user_id)??null}))}})}function fJt(){const t=jr();return kr({mutationFn:async({dealId:e,brokerageId:r,body:n,senderRole:s,itemId:o})=>{var y;const{data:c}=await Ce.auth.getUser(),a=(y=c.user)==null?void 0:y.id;if(!a)throw new Error("Not signed in");const{data:f,error:m}=await ei.from("deal_compliance_messages").insert({deal_id:e,brokerage_id:r,sender_user_id:a,sender_role:s,item_id:o??null,body:n.trim()}).select("id").single();if(m)throw m;try{await Ce.functions.invoke("compliance-message-notify",{body:{messageId:f.id}})}catch(_){console.error("compliance message notify failed",_)}return f.id},onSuccess:(e,r)=>t.invalidateQueries({queryKey:["deal-compliance-messages",r.dealId]})})}function mJt(){const t=jr();return kr({mutationFn:async({dealId:e,senderRole:r})=>{const{error:n}=await ei.from("deal_compliance_messages").update({read_at:new Date().toISOString()}).eq("deal_id",e).neq("sender_role",r).is("read_at",null);if(n)throw n},onSuccess:(e,r)=>t.invalidateQueries({queryKey:["deal-compliance-messages",r.dealId]})})}function pJt(t){return mr({queryKey:["brokerage-agent-roster",t],enabled:!!t,queryFn:async()=>{const{data:e,error:r}=await ei.from("profiles").select("id, name, email, avatar_url").eq("brokerage_id",t).order("name",{ascending:!0});if(r)throw r;return e||[]}})}function gJt(t){return mr({queryKey:["agent-pipeline-stages",t],enabled:!!t,queryFn:async()=>{const e=async()=>{const{data:n,error:s}=await ei.from("deal_pipeline_stages").select("id, name, sort_order, default_probability").eq("owner_user_id",t).order("sort_order",{ascending:!0});if(s)throw s;return n||[]};let r=await e();if(r.length===0){const{error:n}=await ei.rpc("initialize_deal_pipeline_stages",{p_user_id:t});n||(r=await e())}return r}})}function yJt(){const t=jr();return kr({mutationFn:async e=>{const r=e.price!=null&&e.commissionPercentage!=null?Math.round(e.price*(e.commissionPercentage/100)*100)/100:null,{data:n,error:s}=await ei.from("deal_pipeline").insert({owner_user_id:e.ownerUserId,deal_name:e.dealName.trim(),deal_type:e.dealType,stage_id:e.stageId,property_address:e.propertyAddress||null,city:e.city||null,state:e.state||null,zip_code:e.zipCode||null,contract_date:e.contractDate||null,target_close_date:e.targetCloseDate||null,actual_close_date:e.actualCloseDate||null,expected_price:e.price??null,sale_price:e.actualCloseDate?e.price??null:null,commission_percentage:e.commissionPercentage??null,expected_commission:r,notes:e.notes||null}).select("id").single();if(s)throw s;const o=n.id;try{await ei.rpc("ensure_deal_compliance",{_deal_id:o})}catch(c){console.error("ensure_deal_compliance failed",c)}return await BC({dealId:o,brokerageId:e.brokerageId,eventType:"deal_added_by_staff",detail:"Deal added by brokerage staff for the agent's pipeline"}),o},onSuccess:(e,r)=>{t.invalidateQueries({queryKey:["compliance-deals",r.brokerageId]}),t.invalidateQueries({queryKey:["deal-pipeline"]})}})}function xJt(t){return mr({queryKey:["staff-deal-detail",t],enabled:!!t,queryFn:async()=>{const{data:e,error:r}=await ei.from("deal_pipeline").select("id, owner_user_id, deal_name, deal_type, stage_id, property_address, city, state, zip_code, contract_date, target_close_date, actual_close_date, expected_price, sale_price, commission_percentage, notes").eq("id",t).maybeSingle();if(r)throw r;return e||null}})}function _Jt(){const t=jr();return kr({mutationFn:async e=>{const r=e.price!=null&&e.commissionPercentage!=null?Math.round(e.price*(e.commissionPercentage/100)*100)/100:null,{error:n}=await ei.from("deal_pipeline").update({deal_name:e.dealName.trim(),deal_type:e.dealType,stage_id:e.stageId,property_address:e.propertyAddress||null,city:e.city||null,state:e.state||null,zip_code:e.zipCode||null,contract_date:e.contractDate||null,target_close_date:e.targetCloseDate||null,actual_close_date:e.actualCloseDate||null,expected_price:e.price??null,sale_price:e.actualCloseDate?e.price??null:null,commission_percentage:e.commissionPercentage??null,expected_commission:r,notes:e.notes||null}).eq("id",e.dealId);if(n)throw n;return await BC({dealId:e.dealId,brokerageId:e.brokerageId,eventType:"deal_updated_by_staff",detail:"Deal details updated by brokerage staff"}),e.dealId},onSuccess:(e,r)=>{t.invalidateQueries({queryKey:["compliance-deals",r.brokerageId]}),t.invalidateQueries({queryKey:["staff-deal-detail",r.dealId]}),t.invalidateQueries({queryKey:["deal-pipeline"]}),t.invalidateQueries({queryKey:["deal-pipeline-deals"]}),t.invalidateQueries({queryKey:["deal-compliance-events",r.dealId]})}})}const Q4=[{id:"home",label:"Home",icon:sye,route:"/dashboard",accent:"nav-home"},{id:"crm",label:"CRM",icon:Zm,description:"Contacts and follow-up",accent:"nav-crm"},{id:"prospecting",label:"Prospecting",icon:y8,route:"/prospecting",accent:"nav-prospecting",visible:t=>t.hasPermission("contacts")},{id:"deals",label:"Deals",icon:gH,description:"Pipeline, transactions and tasks",accent:"nav-deals"},{id:"listings",label:"Listings",icon:Ja,description:"Win and market listings",accent:"nav-listings"},{id:"marketing",label:"Marketing",icon:Tv,description:"Content, email and video",accent:"nav-marketing"},{id:"websites",label:"Websites",icon:Sv,description:"Your site and add-ons",accent:"nav-websites"},{id:"academy",label:"Learn",icon:UA,description:"Training, programs and coaching",accent:"nav-academy"},{id:"mainstage",label:"Main Stage",icon:RD,route:"/main-stage",accent:"nav-mainstage"},{id:"events",label:"Events",icon:cye,route:"/events",accent:"nav-events"},{id:"apps",label:"Apps",icon:d4e,route:"/apps",accent:"nav-apps"},{id:"team",label:"Team",icon:El,route:"/team",description:"Your team hub — production, pond and resources",accent:"nav-team",visible:t=>t.isOnTeam&&!t.isAdmin&&!t.isBrokerageManager},{id:"brokerage",label:"Brokerage",icon:s4,description:"Your brokerage, teams and recruiting",accent:"nav-brokerage",visible:t=>!t.isAdmin&&(!!t.brokerageId||t.isBrokerageManager||t.isOnTeam)},{id:"more",label:"More",icon:i4e,description:"Community, marketplace and help",accent:"nav-more"}],pl=t=>e=>e.hasPermission(t),EQe=[{id:"prospecting",label:"Prospecting",route:"/prospecting",icon:y8,description:"Property searches, owner contacts and saved intelligence",primaryCategory:"prospecting",section:"Prospecting",visible:pl("contacts"),displayOrder:1,searchKeywords:["prospect","contact finder","homeowner","property search","prospecting credits","dossier"]},{id:"mission-control",label:"Mission Control",route:"/mission-control",icon:t4e,description:"Your daily relationship command center",primaryCategory:"crm",section:"Overview",visible:pl("contacts"),searchKeywords:["agent os","mission control","dashboard"],displayOrder:10},{id:"client-portals",label:"Client Portals",route:"/mission-control/client-portals",icon:ki,description:"Private portals for buyers and sellers",primaryCategory:"crm",section:"Overview",searchKeywords:["portal","client portal"],displayOrder:20},{id:"net-sheets",label:"Seller Net Sheets",route:"/mission-control/net-sheets",icon:h8,description:"Interactive walk-away estimates for sellers",primaryCategory:"crm",section:"Overview",searchKeywords:["net sheet","seller net","proceeds","offer comparison"],displayOrder:21},{id:"contacts",label:"All Contacts",route:"/mission-control/contacts",icon:El,description:"Every contact in your database",primaryCategory:"crm",section:"Contacts",visible:pl("contacts"),searchKeywords:["contacts","database","sphere","people"],displayOrder:30},{id:"contact-map",label:"Contact Map",route:"/mission-control/sphere-map",icon:ui,iconTone:"red",description:"See your sphere on a map — boundaries, farms and prospects",primaryCategory:"crm",section:"Contacts",visible:pl("contacts"),searchKeywords:["contact map","sphere map","map","boundaries","property lines","farm","neighborhood","prospects"],displayOrder:35},{id:"relationship-report",label:"Relationship Report",route:"/mission-control/relationship-scorecard",icon:qre,description:"See who needs attention next",primaryCategory:"crm",section:"Contacts",visible:pl("contacts"),searchKeywords:["relationship","scorecard","report"],displayOrder:40},{id:"sphere-gaps",label:"Sphere Gaps",route:"/mission-control/sphere-gaps",icon:R4e,description:"Find missing info across your sphere",primaryCategory:"crm",section:"Contacts",visible:pl("contacts"),searchKeywords:["gaps","missing data"],displayOrder:50},{id:"sent-emails",label:"Sent Emails",route:"/mission-control/sent-emails",icon:VA,description:"History of everything you have sent",primaryCategory:"crm",section:"Contacts",visible:pl("contacts"),searchKeywords:["sent","email history"],displayOrder:60},{id:"connect-page",label:"Connect Page",route:"/mission-control/connect-page",icon:Yre,description:"Your shareable intake and link page",primaryCategory:"crm",section:"Contacts",visible:pl("contacts"),searchKeywords:["connect","link in bio","intake"],displayOrder:70},{id:"property-intelligence",label:"Property Intelligence",route:"/mission-control/property-intelligence",icon:Ja,description:"Enrich property data for your contacts",primaryCategory:"crm",section:"Contacts",visible:t=>t.isAdmin,searchKeywords:["property","zillow","enrichment","intelligence","home value"],displayOrder:75},{id:"touchplans",label:"TouchPlans",route:"/mission-control/plans",icon:Vm,description:"Structured touch plans for your people",primaryCategory:"crm",section:"Follow-Up",visible:pl("contacts"),searchKeywords:["touch plan","follow up plan"],displayOrder:80},{id:"smart-drips",label:"Smart Drips",route:"/mission-control/smart-drips",icon:GS,description:"Automated drip campaigns that pause when they reply",primaryCategory:"crm",section:"Follow-Up",badge:"beta",searchKeywords:["drip","automation","campaign"],displayOrder:90},{id:"email-templates",label:"Email Templates",route:"/email-campaigns/templates",icon:rs,description:"Reusable email templates",primaryCategory:"crm",section:"Follow-Up",searchKeywords:["email template"],displayOrder:100},{id:"signals",label:"Signals",route:"/mission-control/signals",icon:y8,description:"Buying and selling signals from your database",primaryCategory:"crm",section:"Follow-Up",searchKeywords:["signals","intent","hot leads"],displayOrder:110},{id:"popbys",label:"Popbys",route:"/mission-control/popbys",icon:Rf,description:"Plan and log in-person pop-bys",primaryCategory:"crm",section:"Follow-Up",visible:pl("popbys"),searchKeywords:["pop by","gifts","drop off"],displayOrder:120},{id:"pipeline",label:"Deal Pipeline",route:"/mission-control/pipeline",icon:gH,description:"Track every deal from lead to close",primaryCategory:"deals",section:"Pipeline",visible:pl("pipeline"),searchKeywords:["pipeline","deals","kanban"],displayOrder:130},{id:"lending-partners",label:"Lending Partners",route:"/mission-control/lenders",icon:s4,description:"Loan officers, loan milestones and lead exchange",primaryCategory:"deals",section:"Pipeline",visible:pl("pipeline"),searchKeywords:["lender","loan officer","mortgage","pre-approval","referral"],displayOrder:135},{id:"transactions",label:"Transactions",route:"/mission-control/transactions",icon:m8,description:"Closed and in-progress transactions",primaryCategory:"deals",section:"Pipeline",visible:pl("pipeline"),searchKeywords:["transactions","closings"],displayOrder:140},{id:"forms",label:"Forms Library",route:"/mission-control/forms",icon:a4e,description:"Your PDF form templates, filled from any deal",primaryCategory:"deals",section:"Pipeline",visible:pl("pipeline"),searchKeywords:["forms","pdf","templates","contracts","documents"],displayOrder:145},{id:"tasks",label:"Tasks",route:"/mission-control/tasks",icon:O4e,description:"Everything on your plate today",primaryCategory:"deals",section:"Pipeline",visible:pl("pipeline"),searchKeywords:["tasks","to do"],displayOrder:150},{id:"scorecard",label:"Scorecard",route:"/mission-control/scorecard",icon:zA,description:"Your production numbers at a glance",primaryCategory:"deals",section:"Pipeline",visible:pl("scorecard"),searchKeywords:["scorecard","production","goals"],displayOrder:160},{id:"my-calendar",label:"My Calendar",route:"/mission-control/calendar",icon:Vm,description:"Every appointment, deadline and task in one view",primaryCategory:"crm",section:"Overview",visible:()=>!0,searchKeywords:["calendar","schedule","agenda","google calendar","my calendar"],displayOrder:24},{id:"scheduler",label:"LevelUp Scheduler",route:"/mission-control/scheduler",icon:Vm,description:"Share your booking link and sync your calendar",primaryCategory:"crm",section:"Overview",toolId:"scheduler",visible:()=>!0,searchKeywords:["scheduler","booking","calendar","appointments"],displayOrder:25},{id:"my-listings",label:"My Listings",route:t=>t.hasLeadSiteMLS?"/my-website/mls-listings?scope=mine":"/mission-control/listings?tab=my-listings",icon:ea,description:"Your own active listings",primaryCategory:"listings",section:"Manage Listings",visible:t=>t.hasLeadSiteMLS||t.hasPermission("listings"),searchKeywords:["my listings","my properties"],displayOrder:5},{id:"mls-listings-search",label:"MLS Listings",route:"/my-website/mls-listings",icon:Ja,description:"Search every listing in your MLS",primaryCategory:"listings",section:"Manage Listings",visible:t=>t.hasLeadSiteMLS,searchKeywords:["mls","idx","search homes","all listings"],displayOrder:6},{id:"ad-engine",label:"AdEngine",route:"/listings/ad-engine",icon:Iz,description:"Run Facebook & Instagram ads for your listings",primaryCategory:"listings",section:"Manage Listings",secondaryPlacements:[{category:"marketing",section:"Paid Ads",displayOrder:25}],visible:()=>!0,searchKeywords:["ads","facebook ads","instagram ads","boost","adengine","paid ads","advertising"],displayOrder:7},{id:"listing-exchange",label:"Listing Exchange",route:"/mission-control/listings",icon:Ja,description:"Publish and browse member listings",primaryCategory:"listings",section:"Manage Listings",visible:pl("listings"),searchKeywords:["listings","exchange","my listings"],displayOrder:10},{id:"listing-presentation-studio",label:"Listing Presentation Studio",route:"/apps/listing-presentation-studio",icon:A4e,description:"Build a polished listing presentation PDF",primaryCategory:"listings",section:"Win the Listing",toolId:"listing-presentation-studio",searchKeywords:["listing presentation","pdf","pitch"],displayOrder:20},{id:"listing-revival",label:"Listing Revival",route:"/apps/listing-revival",icon:rye,description:"Win expired and withdrawn listings",primaryCategory:"listings",section:"Win the Listing",toolId:"listing-revival",searchKeywords:["expired","revival","withdrawn"],displayOrder:30},{id:"fsbo-breakthrough",label:"By-Owner Breakthrough",route:"/apps/fsbo-breakthrough",icon:ea,description:"Convert for-sale-by-owner sellers",primaryCategory:"listings",section:"Win the Listing",toolId:"fsbo-breakthrough",searchKeywords:["fsbo","by owner"],displayOrder:40},{id:"cma",label:"CMA Reports",route:"/mission-control/cma",icon:h8,description:"Comparative market analysis for sellers",primaryCategory:"listings",section:"Win the Listing",toolId:"cma",visible:t=>t.hasLeadSiteMLS,searchKeywords:["cma","market analysis","pricing"],displayOrder:50},{id:"guest-book",label:"Guest Book",route:"/mission-control/guest-book",icon:m8,description:"Digital open house sign-in",primaryCategory:"listings",section:"Open Houses",toolId:"guest-book",searchKeywords:["open house","sign in","guest book"],displayOrder:60},{id:"listing-studio",label:"Listing Studio",route:"/mission-control/listing-studio",icon:Kre,description:"Marketing assets for a listing",primaryCategory:"listings",section:"Market the Listing",toolId:"listing-studio",searchKeywords:["listing marketing","flyer","just listed"],displayOrder:70},{id:"templates",label:"Templates",route:"/templates",icon:a4,description:"Ready-to-edit Canva templates",primaryCategory:"marketing",section:"Create",searchKeywords:["templates","canva","graphics"],displayOrder:10},{id:"staging-studio",label:"Staging Studio",route:"/apps/staging-studio",icon:D4e,description:"Virtually stage, declutter and brighten listing photos",primaryCategory:"marketing",section:"Create",toolId:"staging-studio",visible:t=>t.isAdmin||t.stagingStudioEnabled,searchKeywords:["staging","virtual staging","twilight","declutter","sky replacement","photo"],displayOrder:11},{id:"reviews",label:"Reviews",route:"/apps/reviews",icon:gc,description:"Collect, showcase and reply to client reviews",primaryCategory:"marketing",section:"Create",searchKeywords:["reviews","agent reviews","google reviews","testimonials","reputation","review link","review page","ratings","video review"],displayOrder:12},{id:"marketing-studio",label:"Marketing Studio",route:"/marketing-studio",icon:Kre,description:"Create branded marketing assets",primaryCategory:"marketing",section:"Create",searchKeywords:["marketing studio","design","brand kit"],displayOrder:20},{id:"social-studio",label:"Social Studio",route:"/social-studio",icon:Pz,description:"Post to all your social accounts from one composer",primaryCategory:"marketing",section:"Social & Content",searchKeywords:["social","posts","instagram","facebook","linkedin","google business","schedule","swag"],displayOrder:29},{id:"social-swag",label:"Social Swag",route:"/social-studio?tab=gallery",icon:Pz,description:"Daily social posts you can publish in a tap",primaryCategory:"marketing",section:"Social & Content",searchKeywords:["social","posts","instagram","facebook"],displayOrder:30},{id:"weekly-reels",label:"Weekly Reels",route:"/weekly-reels",icon:Wre,description:"A fresh reel script every Monday",primaryCategory:"marketing",section:"Social & Content",toolId:"weekly-reels",visible:t=>t.hasWeeklyReels,searchKeywords:["reels","video script","instagram"],displayOrder:40},{id:"newsletter-pro",label:"Newsletter Pro",route:"/newsletters",icon:iye,description:"Send a branded monthly newsletter",primaryCategory:"marketing",section:"Email & Mail",badge:"new",toolId:"newsletter-pro",searchKeywords:["newsletter","email marketing"],displayOrder:50},{id:"mass-emails",label:"Mass Emails",route:"/admin/email-campaigns",icon:rs,description:"Email your whole database at once",primaryCategory:"marketing",section:"Email & Mail",toolId:"mass-emails",searchKeywords:["mass email","campaign","blast"],displayOrder:60},{id:"direct-mail",label:"Mail Studio",route:"/mission-control/direct-mail",icon:VA,description:"Postcards & letters via your thanks.io account",primaryCategory:"marketing",section:"Email & Mail",toolId:"direct-mail",searchKeywords:["postcard","direct mail","farming","letter","thanks.io","mail studio"],displayOrder:70},{id:"card-studio",label:"Card Studio",route:"/mission-control/card-studio",icon:Rf,description:"Send digital celebration cards",primaryCategory:"marketing",section:"Email & Mail",toolId:"card-studio",searchKeywords:["cards","birthday","anniversary"],displayOrder:80},{id:"video-library",label:"Video Library",route:"/mission-control/video-library",icon:tA,description:"All of your recorded videos",primaryCategory:"marketing",section:"Video",visible:pl("videos"),searchKeywords:["videos","library"],displayOrder:90},{id:"video-studio",label:"Video Studio",route:"/video-studio",icon:tA,description:"Record vertical or horizontal videos with a scrolling teleprompter",primaryCategory:"marketing",section:"Video",visible:pl("videos"),searchKeywords:["teleprompter","studio","reels","record video","social video"],displayOrder:95},{id:"quickvid",label:"Video Messages",route:"/video-studio",icon:tA,description:"Record a personal video and email or text it with a template",primaryCategory:"marketing",section:"Video",toolId:"quickvid",searchKeywords:["record video","video email","screen record"],displayOrder:100},{id:"reelflow",label:"ReelFlow",route:"/admin/beta/homereel",icon:Wre,description:"AI-assisted short-form video creation",primaryCategory:"marketing",section:"Video",toolId:"reelflow",searchKeywords:["reelflow","ai video","reels"],displayOrder:110},{id:"landing-pages",label:"Landing Pages",route:"/mission-control/landing-pages",icon:Iz,description:"Capture leads with focused landing pages",primaryCategory:"marketing",section:"Lead Capture",toolId:"landing-pages",searchKeywords:["landing page","lead capture","funnel"],displayOrder:120},{id:"buyer-match",label:"Buyer Match",route:"/mission-control/buyer-match",icon:p8,description:"Turn a buyer's wish list into seller conversations",primaryCategory:"marketing",section:"Lead Capture",searchKeywords:["buyer match","buyer needs","seller leads","wish list"],displayOrder:125},{id:"smart-card",label:"Smart Card",route:"/mission-control/my-card",icon:Yre,description:"Your digital business card",primaryCategory:"marketing",section:"Lead Capture",toolId:"smart-card",searchKeywords:["digital card","business card","qr"],displayOrder:130},{id:"my-websites",label:"My Websites",route:"/websites",icon:p4e,description:"Every site you can edit: yours, your company and your team",primaryCategory:"websites",section:"My Website",visible:t=>t.hasLeadSite||t.isBrokerageManager||t.isTeamLeader||t.isAdmin,searchKeywords:["websites","my sites","edit website","company site","team site"],displayOrder:1},{id:"site-grade",label:"Site Grade",route:"/websites/grade",icon:u4e,description:"How Google, AI search and your clients see your website",primaryCategory:"websites",section:"My Website",badge:"new",visible:t=>t.hasLeadSite||t.isBrokerageManager||t.isTeamLeader||t.isAdmin,searchKeywords:["seo","aeo","site grade","audit","google","ai search","score"],displayOrder:2},{id:"get-my-website",label:"Create Website",route:"/create-website",icon:Sv,description:"Choose a design and create your included agent website",primaryCategory:"websites",section:"My Website",visible:t=>!t.hasLeadSite,searchKeywords:["website","claim site","free site"],displayOrder:5},{id:"upgrade-website-idx",label:"Upgrade to IDX",route:"/create-website?upgrade=1",icon:ki,description:"Add MLS search and listings to your free website",primaryCategory:"websites",section:"My Website",badge:"new",visible:t=>!!t.hasFreeNonIdxSite,searchKeywords:["idx","upgrade","mls","website"],displayOrder:3},{id:"need-a-website",label:"Need a Website",route:"/need-a-website",icon:Sv,description:"Request your free beta agent website",primaryCategory:"websites",section:"My Website",badge:"beta",visible:()=>!1,searchKeywords:["website","need a website","beta site","free website"],displayOrder:6},{id:"view-site",label:"View Site",route:t=>t.siteUrl||"#",icon:n4,description:"Open your live website",primaryCategory:"websites",section:"My Website",external:!0,openInNewTab:!0,visible:t=>t.hasLeadSite&&!!t.siteUrl,searchKeywords:["view site","live site"],displayOrder:10},{id:"edit-website",label:"Edit My Site",route:t=>`/my-website/${t.leadSiteId}/edit`,icon:aye,description:"Site builder for pages, branding and content",primaryCategory:"websites",section:"My Website",visible:t=>t.hasLeadSite&&!!t.leadSiteId,searchKeywords:["edit website","site builder","pages"],displayOrder:20},{id:"brokerage-website",label:"Edit Company Site",route:"/brokerage/website",icon:Ja,description:"Your company site: agents, listings, recruiting and leads",primaryCategory:"websites",section:"My Website",badge:"new",visible:t=>t.isBrokerageManager||t.isAdmin,searchKeywords:["website","company site","brokerage site","agents","roster"],displayOrder:24},{id:"team-website",label:"Edit Team Site",route:"/team/website",icon:El,description:"Your team site: members, listings and leads",primaryCategory:"websites",section:"My Website",badge:"new",visible:t=>t.isTeamLeader||t.isAdmin,searchKeywords:["team website","team site","team page"],displayOrder:26},{id:"mls-listings",label:"MLS Listings",route:"/my-website/mls-listings",icon:ea,description:"Control which listings appear on your site",primaryCategory:"websites",section:"My Website",visible:t=>t.hasLeadSite,searchKeywords:["mls","idx","listings on site"],displayOrder:30},{id:"market-reports",label:"Market Reports",route:"/my-website/market-report",icon:zA,description:"Monthly market reports for your areas",primaryCategory:"websites",section:"My Website",visible:t=>t.hasLeadSite&&t.hasLeadSiteMLS,searchKeywords:["market report","stats"],displayOrder:40},{id:"website-activity",label:"Website Activity",route:"/mission-control/website-activity",icon:qre,description:"See who is browsing your site",primaryCategory:"websites",section:"My Website",visible:t=>t.hasLeadSite,searchKeywords:["website activity","visitors","analytics"],displayOrder:50},{id:"behavior-alerts",label:"Behavior Alerts",route:"/my-website/behavior-alerts",icon:rs,description:"Your branded website follow-up emails",primaryCategory:"websites",section:"My Website",visible:t=>t.hasLeadSite&&t.hasLeadSiteMLS,searchKeywords:["behavior","alerts","email","automation","follow up"],displayOrder:55},{id:"homeowner-hubs",label:"Homeowner Hubs",route:"/my-website/homeowner-hubs",icon:ea,description:"Monthly home value emails and equity dashboards for past clients",primaryCategory:"websites",section:"My Website",visible:t=>t.hasLeadSite&&t.hasLeadSiteMLS,searchKeywords:["homebot","homeowner","equity","home value","past clients","digest"],displayOrder:56},{id:"mobile-command",label:"Mobile Command",route:"/m",icon:Pz,description:"The mobile-first agent console",primaryCategory:"websites",section:"My Website",visible:t=>t.hasLeadSite,searchKeywords:["mobile","command"],displayOrder:60},{id:"website-apps",label:"Website Apps",route:"/website-apps",icon:ki,description:"Lead magnets, video greeter and more",primaryCategory:"websites",section:"Website Add-Ons",toolId:"website-apps",searchKeywords:["widgets","lead magnet","video greeter"],displayOrder:70},{id:"levelup-u",label:"LevelUp U",route:"/levelup-u",icon:UA,description:"Structured courses and certifications",primaryCategory:"academy",section:"Learn",badge:"new",searchKeywords:["levelup u","courses","training"],displayOrder:10},{id:"academy",label:"Academy",route:"/academy",icon:qS,description:"On-demand training videos",primaryCategory:"academy",section:"Learn",searchKeywords:["academy","videos","training"],displayOrder:20},{id:"toolbox",label:"Toolbox",route:"/toolbox",icon:wH,description:"Scripts, checklists and downloads",primaryCategory:"academy",section:"Learn",searchKeywords:["toolbox","scripts","downloads"],displayOrder:30},{id:"events",label:"Events",route:"/events",icon:cye,description:"Live trainings and member events",primaryCategory:"events",section:"Events",searchKeywords:["events","live","webinar"],displayOrder:10},{id:"programs",label:"Programs",route:"/programs",icon:Iz,description:"Cohort programs like Reel Estate 90",primaryCategory:"academy",section:"Programs & Coaching",searchKeywords:["programs","reel estate 90","cohort"],displayOrder:50},{id:"coaching",label:"Coaching",route:"/coaching",icon:UA,description:"Your coaching hub and calendar",primaryCategory:"academy",section:"Programs & Coaching",visible:t=>t.isCoach,searchKeywords:["coaching","coach hub"],displayOrder:60},{id:"my-coach",label:"Coaching",route:"/my-coach",icon:Zm,description:"Sessions, goals and notes with your coach",primaryCategory:"academy",section:"Programs & Coaching",visible:t=>!t.isCoach&&(t.hasCoach||t.hasCoachingAccess),searchKeywords:["my coach","coaching","sessions","book session"],displayOrder:70},{id:"community",label:"Community",route:"/community",icon:Nh,description:"Talk shop with other LevelUp members",primaryCategory:"more",section:"Community",badgeKey:"community",searchKeywords:["community","forum","posts"],displayOrder:10},{id:"wishlist",label:"Wishlist",route:"/wishlist",icon:y4e,description:"Request and vote on new features",primaryCategory:"more",section:"Community",badgeKey:"wishlist",searchKeywords:["wishlist","feature request"],displayOrder:20},{id:"facebook-group",label:"Facebook Group",route:"https://www.facebook.com/share/g/1CC6thti2V/",icon:sb,description:"Our private Facebook community",primaryCategory:"more",section:"Community",external:!0,openInNewTab:!0,searchKeywords:["facebook group"],displayOrder:30},{id:"marketplace",label:"Marketplace",route:"/marketplace",icon:bH,description:"Print and promo products",primaryCategory:"more",section:"The Goods",badge:"new",visible:t=>t.isMarketplaceEnabled,searchKeywords:["marketplace","shop","print"],displayOrder:40},{id:"reward-store",label:"Reward Store",route:"/reward-store",icon:MD,description:"Spend the points you have earned",primaryCategory:"more",section:"The Goods",searchKeywords:["rewards","points","store"],displayOrder:50},{id:"refer-friends",label:"Refer & Earn",route:"/refer-friends",icon:Rf,description:"Invite agents and earn rewards",primaryCategory:"more",section:"The Goods",searchKeywords:["referral","refer a friend"],displayOrder:60},{id:"support",label:"Support",route:"/support",icon:g4e,description:"Get help from the LevelUp team",primaryCategory:"more",section:"Help & Services",searchKeywords:["support","help","ticket"],displayOrder:70},{id:"additional-services",label:"Additional Services",route:"/additional-services",icon:ki,description:"Done-for-you services from LevelUp",primaryCategory:"more",section:"Help & Services",searchKeywords:["services","done for you"],displayOrder:80},{id:"integrations",label:"Integrations",route:"/mission-control/integrations",icon:PD,description:"Connect your CRM, calendar and socials",primaryCategory:"more",section:"Help & Services",searchKeywords:["integrations","connect","crm sync"],displayOrder:90},{id:"browser-extension",label:"Browser Extension",route:"/mission-control/browser-extension",icon:PD,description:"Install the LevelUp Chrome extension",primaryCategory:"more",section:"Help & Services",searchKeywords:["extension","chrome"],displayOrder:100},{id:"attract",label:"LevelUp Attract",route:"/attract",icon:ki,description:"Relationship-first attraction coach",primaryCategory:"more",section:"Help & Services",badge:"beta",visible:t=>t.email==="jeremy@relevelup.com",searchKeywords:["attract","recruiting"],displayOrder:110},{id:"admin-dashboard",label:"Admin Dashboard",route:"/admin",icon:zx,description:"Manage members, content and settings",primaryCategory:"more",section:"Admin",visible:t=>t.isAdmin,searchKeywords:["admin"],displayOrder:120},{id:"agent-activation",label:"Agent Activation",route:"/admin/agent-activation",icon:GS,description:"Wake up dormant agents with branded email sequences",primaryCategory:"more",section:"Admin",visible:t=>t.isAdmin,searchKeywords:["activation","dormant","adoption","agents"],displayOrder:121},{id:"my-brokerage",label:"My Brokerage",route:"/my-brokerage",icon:Ja,description:"Your brokerage hub",primaryCategory:"brokerage",section:"My Brokerage",visible:t=>!!t.brokerageId&&!t.isAdmin,searchKeywords:["brokerage"],displayOrder:130},{id:"brokerage-lead-engine",label:"Office Lead Engine",route:"/brokerage/lead-engine",icon:Tv,description:"Office campaigns, lead team and inquiry assignments",primaryCategory:"brokerage",section:"My Brokerage",visible:t=>!t.isAdmin&&(!!t.brokerageId||t.isBrokerageManager),searchKeywords:["office leads","lead engine","ads","pond","round robin"],displayOrder:135},{id:"admin-office-lead-engine",label:"Office Lead Engine",route:"/brokerage/lead-engine",icon:Tv,description:"Office lead programs and campaign assignments",primaryCategory:"more",section:"Admin",visible:t=>t.isAdmin,searchKeywords:["office leads","brokerage ads","lead engine"],displayOrder:125},{id:"help-board",label:"Help Board",route:"/brokerage/help-board",icon:f4e,description:"Ask for showing and open house coverage",primaryCategory:"brokerage",section:"My Brokerage",visible:t=>!!t.brokerageId&&!t.isAdmin,searchKeywords:["help board","coverage"],displayOrder:140},{id:"brokerage-content",label:"Brokerage Content",route:"/brokerage-content",icon:qS,description:"Content shared by your brokerage",primaryCategory:"brokerage",section:"My Brokerage",visible:t=>!!t.brokerageId&&!t.isAdmin,searchKeywords:["brokerage content"],displayOrder:150},{id:"team-hub",label:"Team Hub",route:"/team",icon:El,description:"Production, leaderboard, pond and resources for your team",primaryCategory:"team",section:"My Team",searchKeywords:["team","leaderboard","production","team hub","standing"],displayOrder:155},{id:"my-team",label:"My Team",route:"/my-team",icon:El,description:"Your team roster and lead pond",primaryCategory:"brokerage",section:"My Team",visible:t=>t.isOnTeam&&!t.isBrokerageManager&&!t.isAdmin,searchKeywords:["team","lead pond"],displayOrder:160},{id:"manage-brokerages",label:"Manage Brokerages",route:"/brokerage/dashboard",icon:_H,description:"Brokerage manager dashboard",primaryCategory:"brokerage",section:"Manage Brokerage",visible:t=>t.isBrokerageManager&&!t.isAdmin,searchKeywords:["manage brokerage"],displayOrder:170},{id:"brokerage-teams",label:"Teams",route:"/brokerage/teams",icon:El,description:"Teams, rosters and lead ponds",primaryCategory:"brokerage",section:"Manage Brokerage",badge:"new",visible:t=>t.isBrokerageManager&&!t.isAdmin,searchKeywords:["teams","pond"],displayOrder:180},{id:"brokerage-recruiting",label:"Recruiting",route:"/brokerage/recruiting",icon:Tv,description:"Recruit and nurture agents",primaryCategory:"brokerage",section:"Manage Brokerage",visible:t=>t.isBrokerageManager&&!t.isAdmin,searchKeywords:["recruiting"],displayOrder:190},{id:"brokerage-onboarding",label:"Agent Onboarding",route:"/brokerage/onboarding",icon:Cz,description:"Onboarding checklists, documents and agent notes",primaryCategory:"brokerage",section:"Manage Brokerage",badge:"new",visible:t=>t.isBrokerageManager&&!t.isAdmin,searchKeywords:["onboarding","checklist","documents","new agent"],displayOrder:195},{id:"brokerage-agent-websites",label:"Agent Websites",route:"/brokerage/agent-websites",icon:Sv,description:"Every agent's website, status and leads",primaryCategory:"brokerage",section:"Manage Brokerage",badge:"new",visible:t=>t.isBrokerageManager||t.isAdmin,searchKeywords:["agent websites","agent sites","domains","idx"],displayOrder:197},{id:"brokerage-operations",label:"Operations",route:"/brokerage/operations",icon:sye,description:"Daily action feed, office task board and brokerage calendar",primaryCategory:"brokerage",section:"Manage Brokerage",badge:"new",visible:t=>(t.isBrokerageManager||t.isTransactionAdmin)&&!t.isAdmin,searchKeywords:["operations","tasks","today","calendar","action items"],displayOrder:188},{id:"brokerage-commission-plans",label:"Financials",route:"/brokerage/commission-plans",icon:E4e,description:"Commission plans, company dollar and fee statements",primaryCategory:"brokerage",section:"Manage Brokerage",badge:"new",visible:t=>(t.isBrokerageManager||t.isTransactionAdmin)&&!t.isAdmin,searchKeywords:["commission","split","cap","fees","agent plans"],displayOrder:195},{id:"brokerage-deals",label:"Agent Deals",route:"/brokerage/deals",icon:d8,description:"Every agent's listings, pending deals and production",primaryCategory:"brokerage",section:"Manage Brokerage",badge:"new",visible:t=>(t.isBrokerageManager||t.isTransactionAdmin)&&!t.isAdmin,searchKeywords:["deals","pipeline","import","production","agent deals"],displayOrder:195.5},{id:"brokerage-transactions",label:"Transactions & Compliance",route:"/brokerage/transactions",icon:Cz,description:"Review agent files, required documents and closing compliance",primaryCategory:"brokerage",section:"Manage Brokerage",badge:"new",visible:t=>(t.isBrokerageManager||t.isTransactionAdmin)&&!t.isAdmin,searchKeywords:["compliance","transactions","documents","closing","paperless"],displayOrder:196},{id:"brokerage-vendors",label:"Vendors",route:"/brokerage/vendors",icon:p8,description:"Preferred vendor directory",primaryCategory:"brokerage",section:"Manage Brokerage",visible:t=>t.isBrokerageManager&&!t.isAdmin,searchKeywords:["vendors"],displayOrder:200},{id:"brokerage-forms",label:"Brokerage Forms",route:"/brokerage/forms",icon:Ym,description:"Official forms your agents can use",primaryCategory:"brokerage",section:"Manage Brokerage",badge:"new",visible:t=>t.isBrokerageManager&&!t.isAdmin,searchKeywords:["forms","pdf","documents"],displayOrder:205},{id:"brokerage-resources",label:"Brokerage Resources",route:"/brokerage-resources",icon:d8,description:"Documents and links for your agents",primaryCategory:"brokerage",section:"Manage Brokerage",visible:t=>t.isBrokerageManager&&!t.isAdmin,searchKeywords:["resources"],displayOrder:210},{id:"my-partnership",label:"My Package",route:"/my-partnership",icon:ki,description:"What is included in your partnership package",primaryCategory:"more",section:"Account",visible:t=>t.isPartnershipMember,searchKeywords:["partnership","package","upgrade","exp luxury"],displayOrder:5},{id:"coaching-onboarding",label:"Coaching Onboarding",route:"/coaching/onboarding",icon:Cz,description:"Tell your coach about your business before session one",primaryCategory:"academy",section:"Coaching",visible:t=>t.hasCoachingOnboarding,searchKeywords:["coaching","onboarding","intake"],displayOrder:45}];function bwe(t,e){return typeof t.route=="function"?t.route(e):t.route}function wwe(t,e){var r;return t.primaryCategory===e?{category:e,section:t.section,displayOrder:t.displayOrder}:((r=t.secondaryPlacements)==null?void 0:r.find(n=>n.category===e))??null}function jQe(t,e){return t.map(r=>({dest:r,placement:wwe(r,e)})).filter(r=>r.placement!==null).sort((r,n)=>(r.placement.displayOrder??r.dest.displayOrder)-(n.placement.displayOrder??n.dest.displayOrder)).map(r=>({dest:r.dest,section:r.placement.section}))}function Swe(){const{user:t,isAdmin:e,isBrokerageManager:r,isCoach:n,brokerageId:s}=Zn(),{hasPermission:o}=L4(),{isInnerCircleEnabled:c,isMarketplaceEnabled:a,isFeatureEnabled:f}=O4(),{hasAccess:m}=pW(),{data:y,teams:_}=nE(),{leadSite:w,hasLeadSite:E,siteUrl:A}=XW(),{hasOffer:C}=vwe(!E),I=lve(),{hasAccess:M}=SQe(),{data:D}=TQe(),B=jr(),{data:U}=mr({queryKey:["my-coach-nav",t==null?void 0:t.id],enabled:!!(t!=null&&t.id),staleTime:5*60*1e3,queryFn:async()=>{const{data:be}=await Ce.from("coaching_assignments").select("id").eq("agent_id",t.id).eq("status","active").limit(1);return(be||[]).length>0}}),{data:q}=mr({queryKey:["user-tool-favorites",t==null?void 0:t.id],enabled:!!(t!=null&&t.id),staleTime:60*1e3,queryFn:async()=>{const{data:be}=await Ce.from("user_tool_favorites").select("tool_id").eq("user_id",t.id);return(be||[]).map(me=>me.tool_id)}}),H=N.useMemo(()=>new Set(q||[]),[q]),K=kr({mutationFn:async be=>{t!=null&&t.id&&(H.has(be)?await Ce.from("user_tool_favorites").delete().eq("user_id",t.id).eq("tool_id",be):await Ce.from("user_tool_favorites").insert({user_id:t.id,tool_id:be}))},onSuccess:()=>{B.invalidateQueries({queryKey:["user-tool-favorites"]}),B.invalidateQueries({queryKey:["app-catalog"]})}}),Q=N.useMemo(()=>{var be,me;return{isAdmin:!!e,isBrokerageManager:!!r,isTransactionAdmin:((D==null?void 0:D.length)||0)>0,isCoach:!!n,isOnTeam:!!y,isTeamLeader:(_||[]).some(ke=>ke.role==="team_leader"),hasCoach:!!U,brokerageId:s??null,hasPermission:o,isInnerCircleEnabled:!!c,stagingStudioEnabled:f("staging_studio_enabled"),isMarketplaceEnabled:!!a,hasWeeklyReels:!!m,hasLeadSite:!!E,hasLeadSiteMLS:!!(w!=null&&w.mls_provider_id),hasFreeNonIdxSite:bQe(w),hasFreeSiteOffer:!!C,leadSiteId:(w==null?void 0:w.id)??null,siteUrl:A??null,email:(t==null?void 0:t.email)??null,isPartnershipMember:I.isMember,hasCoachingOnboarding:I.isMember&&!!((be=I.pkg)!=null&&be.includes_coaching),hasCoachingAccess:!!M||I.isMember&&!!((me=I.pkg)!=null&&me.includes_coaching)}},[e,r,D,n,y,_,U,s,o,c,a,f,m,E,w,C,A,t==null?void 0:t.email,I.isMember,I.pkg,M]),J=N.useMemo(()=>EQe.filter(be=>be.visible?be.visible(Q):!0).map(be=>{if(!I.isRestricted)return be;const me=y9e(be);return!me||I.hasFeature(me)?be:{...be,locked:!0,route:`/upgrade/${me}`}}).sort((be,me)=>be.displayOrder-me.displayOrder),[Q,I.isRestricted,I.features]),ee=N.useMemo(()=>Q4.filter(be=>be.visible?be.visible(Q):!0),[Q]),oe=N.useMemo(()=>ee.filter(be=>!be.route).map(be=>{const me=[],ke=new Map;for(const{dest:Pe,section:je}of jQe(J,be.id))ke.has(je)||(ke.set(je,[]),me.push(je)),ke.get(je).push(Pe);return{id:be.id,label:be.label,sections:me.map(Pe=>({title:Pe,items:ke.get(Pe)}))}}),[J,ee]),de=N.useMemo(()=>new Map(oe.map(be=>[be.id,be])),[oe]),ye=be=>be.toolId||`nav:${be.id}`,Ee=be=>H.has(ye(be));return{ctx:Q,categories:oe,railCategories:ee,categoryMap:de,destinations:J,favorites:H,isFavorite:Ee,favoritesFor:be=>J.filter(me=>wwe(me,be)!==null&&Ee(me)),favoriteKey:ye,toggleFavorite:be=>K.mutate(be),searchDestinations:be=>{const me=be.trim().toLowerCase();return me?J.map(Pe=>{const je=Pe.label.toLowerCase(),xe=(Pe.description||"").toLowerCase(),Ue=(Pe.searchKeywords||[]).join(" ").toLowerCase();let Ze=0;return je===me?Ze=100:je.startsWith(me)?Ze=80:je.includes(me)?Ze=60:Ue.includes(me)?Ze=40:xe.includes(me)?Ze=20:Pe.section.toLowerCase().includes(me)&&(Ze=10),Ze&&Ee(Pe)&&(Ze+=5),{d:Pe,score:Ze}}).filter(Pe=>Pe.score>0).sort((Pe,je)=>je.score-Pe.score).map(Pe=>Pe.d):[]},routeFor:be=>bwe(be,Q)}}var Qse=1,kQe=.9,AQe=.8,NQe=.17,h6=.1,f6=.999,CQe=.9999,IQe=.99,PQe=/[\\\/_+.#"@\[\(\{&]/,RQe=/[\\\/_+.#"@\[\(\{&]/g,LQe=/[\s-]/,Twe=/[\s-]/g;function Tq(t,e,r,n,s,o,c){if(o===e.length)return s===t.length?Qse:IQe;var a=`${s},${o}`;if(c[a]!==void 0)return c[a];for(var f=n.charAt(o),m=r.indexOf(f,s),y=0,_,w,E,A;m>=0;)_=Tq(t,e,r,n,m+1,o+1,c),_>y&&(m===s?_*=Qse:PQe.test(t.charAt(m-1))?(_*=AQe,E=t.slice(s,m-1).match(RQe),E&&s>0&&(_*=Math.pow(f6,E.length))):LQe.test(t.charAt(m-1))?(_*=kQe,A=t.slice(s,m-1).match(Twe),A&&s>0&&(_*=Math.pow(f6,A.length))):(_*=NQe,s>0&&(_*=Math.pow(f6,m-s))),t.charAt(m)!==e.charAt(o)&&(_*=CQe)),(__&&(_=w*h6)),_>y&&(y=_),m=r.indexOf(f,m+1);return c[a]=y,y}function Jse(t){return t.toLowerCase().replace(Twe," ")}function MQe(t,e,r){return t=r&&r.length>0?`${t+" "+r.join(" ")}`:t,Tq(t,e,Jse(t),Jse(e),0,0,{})}var sk='[cmdk-group=""]',m6='[cmdk-group-items=""]',DQe='[cmdk-group-heading=""]',Ewe='[cmdk-item=""]',eie=`${Ewe}:not([aria-disabled="true"])`,Eq="cmdk-item-select",j1="data-value",OQe=(t,e,r)=>MQe(t,e,r),jwe=N.createContext(void 0),$C=()=>N.useContext(jwe),kwe=N.createContext(void 0),QW=()=>N.useContext(kwe),Awe=N.createContext(void 0),Nwe=N.forwardRef((t,e)=>{let r=k1(()=>{var xe,Ue;return{search:"",value:(Ue=(xe=t.value)!=null?xe:t.defaultValue)!=null?Ue:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),n=k1(()=>new Set),s=k1(()=>new Map),o=k1(()=>new Map),c=k1(()=>new Set),a=Cwe(t),{label:f,children:m,value:y,onValueChange:_,filter:w,shouldFilter:E,loop:A,disablePointerSelection:C=!1,vimBindings:I=!0,...M}=t,D=il(),B=il(),U=il(),q=N.useRef(null),H=KQe();Gv(()=>{if(y!==void 0){let xe=y.trim();r.current.value=xe,K.emit()}},[y]),Gv(()=>{H(6,ye)},[]);let K=N.useMemo(()=>({subscribe:xe=>(c.current.add(xe),()=>c.current.delete(xe)),snapshot:()=>r.current,setState:(xe,Ue,Ze)=>{var lt,wt,yt,gt;if(!Object.is(r.current[xe],Ue)){if(r.current[xe]=Ue,xe==="search")de(),ee(),H(1,oe);else if(xe==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let ft=document.getElementById(U);ft?ft.focus():(lt=document.getElementById(D))==null||lt.focus()}if(H(7,()=>{var ft;r.current.selectedItemId=(ft=Ee())==null?void 0:ft.id,K.emit()}),Ze||H(5,ye),((wt=a.current)==null?void 0:wt.value)!==void 0){let ft=Ue??"";(gt=(yt=a.current).onValueChange)==null||gt.call(yt,ft);return}}K.emit()}},emit:()=>{c.current.forEach(xe=>xe())}}),[]),Q=N.useMemo(()=>({value:(xe,Ue,Ze)=>{var lt;Ue!==((lt=o.current.get(xe))==null?void 0:lt.value)&&(o.current.set(xe,{value:Ue,keywords:Ze}),r.current.filtered.items.set(xe,J(Ue,Ze)),H(2,()=>{ee(),K.emit()}))},item:(xe,Ue)=>(n.current.add(xe),Ue&&(s.current.has(Ue)?s.current.get(Ue).add(xe):s.current.set(Ue,new Set([xe]))),H(3,()=>{de(),ee(),r.current.value||oe(),K.emit()}),()=>{o.current.delete(xe),n.current.delete(xe),r.current.filtered.items.delete(xe);let Ze=Ee();H(4,()=>{de(),(Ze==null?void 0:Ze.getAttribute("id"))===xe&&oe(),K.emit()})}),group:xe=>(s.current.has(xe)||s.current.set(xe,new Set),()=>{o.current.delete(xe),s.current.delete(xe)}),filter:()=>a.current.shouldFilter,label:f||t["aria-label"],getDisablePointerSelection:()=>a.current.disablePointerSelection,listId:D,inputId:U,labelId:B,listInnerRef:q}),[]);function J(xe,Ue){var Ze,lt;let wt=(lt=(Ze=a.current)==null?void 0:Ze.filter)!=null?lt:OQe;return xe?wt(xe,r.current.search,Ue):0}function ee(){if(!r.current.search||a.current.shouldFilter===!1)return;let xe=r.current.filtered.items,Ue=[];r.current.filtered.groups.forEach(lt=>{let wt=s.current.get(lt),yt=0;wt.forEach(gt=>{let ft=xe.get(gt);yt=Math.max(ft,yt)}),Ue.push([lt,yt])});let Ze=q.current;Le().sort((lt,wt)=>{var yt,gt;let ft=lt.getAttribute("id"),kt=wt.getAttribute("id");return((yt=xe.get(kt))!=null?yt:0)-((gt=xe.get(ft))!=null?gt:0)}).forEach(lt=>{let wt=lt.closest(m6);wt?wt.appendChild(lt.parentElement===wt?lt:lt.closest(`${m6} > *`)):Ze.appendChild(lt.parentElement===Ze?lt:lt.closest(`${m6} > *`))}),Ue.sort((lt,wt)=>wt[1]-lt[1]).forEach(lt=>{var wt;let yt=(wt=q.current)==null?void 0:wt.querySelector(`${sk}[${j1}="${encodeURIComponent(lt[0])}"]`);yt==null||yt.parentElement.appendChild(yt)})}function oe(){let xe=Le().find(Ze=>Ze.getAttribute("aria-disabled")!=="true"),Ue=xe==null?void 0:xe.getAttribute(j1);K.setState("value",Ue||void 0)}function de(){var xe,Ue,Ze,lt;if(!r.current.search||a.current.shouldFilter===!1){r.current.filtered.count=n.current.size;return}r.current.filtered.groups=new Set;let wt=0;for(let yt of n.current){let gt=(Ue=(xe=o.current.get(yt))==null?void 0:xe.value)!=null?Ue:"",ft=(lt=(Ze=o.current.get(yt))==null?void 0:Ze.keywords)!=null?lt:[],kt=J(gt,ft);r.current.filtered.items.set(yt,kt),kt>0&&wt++}for(let[yt,gt]of s.current)for(let ft of gt)if(r.current.filtered.items.get(ft)>0){r.current.filtered.groups.add(yt);break}r.current.filtered.count=wt}function ye(){var xe,Ue,Ze;let lt=Ee();lt&&(((xe=lt.parentElement)==null?void 0:xe.firstChild)===lt&&((Ze=(Ue=lt.closest(sk))==null?void 0:Ue.querySelector(DQe))==null||Ze.scrollIntoView({block:"nearest"})),lt.scrollIntoView({block:"nearest"}))}function Ee(){var xe;return(xe=q.current)==null?void 0:xe.querySelector(`${Ewe}[aria-selected="true"]`)}function Le(){var xe;return Array.from(((xe=q.current)==null?void 0:xe.querySelectorAll(eie))||[])}function Se(xe){let Ue=Le()[xe];Ue&&K.setState("value",Ue.getAttribute(j1))}function be(xe){var Ue;let Ze=Ee(),lt=Le(),wt=lt.findIndex(gt=>gt===Ze),yt=lt[wt+xe];(Ue=a.current)!=null&&Ue.loop&&(yt=wt+xe<0?lt[lt.length-1]:wt+xe===lt.length?lt[0]:lt[wt+xe]),yt&&K.setState("value",yt.getAttribute(j1))}function me(xe){let Ue=Ee(),Ze=Ue==null?void 0:Ue.closest(sk),lt;for(;Ze&&!lt;)Ze=xe>0?HQe(Ze,sk):WQe(Ze,sk),lt=Ze==null?void 0:Ze.querySelector(eie);lt?K.setState("value",lt.getAttribute(j1)):be(xe)}let ke=()=>Se(Le().length-1),Pe=xe=>{xe.preventDefault(),xe.metaKey?ke():xe.altKey?me(1):be(1)},je=xe=>{xe.preventDefault(),xe.metaKey?Se(0):xe.altKey?me(-1):be(-1)};return N.createElement(cn.div,{ref:e,tabIndex:-1,...M,"cmdk-root":"",onKeyDown:xe=>{var Ue;(Ue=M.onKeyDown)==null||Ue.call(M,xe);let Ze=xe.nativeEvent.isComposing||xe.keyCode===229;if(!(xe.defaultPrevented||Ze))switch(xe.key){case"n":case"j":{I&&xe.ctrlKey&&Pe(xe);break}case"ArrowDown":{Pe(xe);break}case"p":case"k":{I&&xe.ctrlKey&&je(xe);break}case"ArrowUp":{je(xe);break}case"Home":{xe.preventDefault(),Se(0);break}case"End":{xe.preventDefault(),ke();break}case"Enter":{xe.preventDefault();let lt=Ee();if(lt){let wt=new Event(Eq);lt.dispatchEvent(wt)}}}}},N.createElement("label",{"cmdk-label":"",htmlFor:Q.inputId,id:Q.labelId,style:ZQe},f),J4(t,xe=>N.createElement(kwe.Provider,{value:K},N.createElement(jwe.Provider,{value:Q},xe))))}),FQe=N.forwardRef((t,e)=>{var r,n;let s=il(),o=N.useRef(null),c=N.useContext(Awe),a=$C(),f=Cwe(t),m=(n=(r=f.current)==null?void 0:r.forceMount)!=null?n:c==null?void 0:c.forceMount;Gv(()=>{if(!m)return a.item(s,c==null?void 0:c.id)},[m]);let y=Iwe(s,o,[t.value,t.children,o],t.keywords),_=QW(),w=Kx(H=>H.value&&H.value===y.current),E=Kx(H=>m||a.filter()===!1?!0:H.search?H.filtered.items.get(s)>0:!0);N.useEffect(()=>{let H=o.current;if(!(!H||t.disabled))return H.addEventListener(Eq,A),()=>H.removeEventListener(Eq,A)},[E,t.onSelect,t.disabled]);function A(){var H,K;C(),(K=(H=f.current).onSelect)==null||K.call(H,y.current)}function C(){_.setState("value",y.current,!0)}if(!E)return null;let{disabled:I,value:M,onSelect:D,forceMount:B,keywords:U,...q}=t;return N.createElement(cn.div,{ref:kg(o,e),...q,id:s,"cmdk-item":"",role:"option","aria-disabled":!!I,"aria-selected":!!w,"data-disabled":!!I,"data-selected":!!w,onPointerMove:I||a.getDisablePointerSelection()?void 0:C,onClick:I?void 0:A},t.children)}),BQe=N.forwardRef((t,e)=>{let{heading:r,children:n,forceMount:s,...o}=t,c=il(),a=N.useRef(null),f=N.useRef(null),m=il(),y=$C(),_=Kx(E=>s||y.filter()===!1?!0:E.search?E.filtered.groups.has(c):!0);Gv(()=>y.group(c),[]),Iwe(c,a,[t.value,t.heading,f]);let w=N.useMemo(()=>({id:c,forceMount:s}),[s]);return N.createElement(cn.div,{ref:kg(a,e),...o,"cmdk-group":"",role:"presentation",hidden:_?void 0:!0},r&&N.createElement("div",{ref:f,"cmdk-group-heading":"","aria-hidden":!0,id:m},r),J4(t,E=>N.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":r?m:void 0},N.createElement(Awe.Provider,{value:w},E))))}),$Qe=N.forwardRef((t,e)=>{let{alwaysRender:r,...n}=t,s=N.useRef(null),o=Kx(c=>!c.search);return!r&&!o?null:N.createElement(cn.div,{ref:kg(s,e),...n,"cmdk-separator":"",role:"separator"})}),zQe=N.forwardRef((t,e)=>{let{onValueChange:r,...n}=t,s=t.value!=null,o=QW(),c=Kx(m=>m.search),a=Kx(m=>m.selectedItemId),f=$C();return N.useEffect(()=>{t.value!=null&&o.setState("search",t.value)},[t.value]),N.createElement(cn.input,{ref:e,...n,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":f.listId,"aria-labelledby":f.labelId,"aria-activedescendant":a,id:f.inputId,type:"text",value:s?t.value:c,onChange:m=>{s||o.setState("search",m.target.value),r==null||r(m.target.value)}})}),UQe=N.forwardRef((t,e)=>{let{children:r,label:n="Suggestions",...s}=t,o=N.useRef(null),c=N.useRef(null),a=Kx(m=>m.selectedItemId),f=$C();return N.useEffect(()=>{if(c.current&&o.current){let m=c.current,y=o.current,_,w=new ResizeObserver(()=>{_=requestAnimationFrame(()=>{let E=m.offsetHeight;y.style.setProperty("--cmdk-list-height",E.toFixed(1)+"px")})});return w.observe(m),()=>{cancelAnimationFrame(_),w.unobserve(m)}}},[]),N.createElement(cn.div,{ref:kg(o,e),...s,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":a,"aria-label":n,id:f.listId},J4(t,m=>N.createElement("div",{ref:kg(c,f.listInnerRef),"cmdk-list-sizer":""},m)))}),VQe=N.forwardRef((t,e)=>{let{open:r,onOpenChange:n,overlayClassName:s,contentClassName:o,container:c,...a}=t;return N.createElement(m4,{open:r,onOpenChange:n},N.createElement(p4,{container:c},N.createElement(GT,{"cmdk-overlay":"",className:s}),N.createElement(HT,{"aria-label":t.label,"cmdk-dialog":"",className:o},N.createElement(Nwe,{ref:e,...a}))))}),qQe=N.forwardRef((t,e)=>Kx(r=>r.filtered.count===0)?N.createElement(cn.div,{ref:e,...t,"cmdk-empty":"",role:"presentation"}):null),GQe=N.forwardRef((t,e)=>{let{progress:r,children:n,label:s="Loading...",...o}=t;return N.createElement(cn.div,{ref:e,...o,"cmdk-loading":"",role:"progressbar","aria-valuenow":r,"aria-valuemin":0,"aria-valuemax":100,"aria-label":s},J4(t,c=>N.createElement("div",{"aria-hidden":!0},c)))}),nd=Object.assign(Nwe,{List:UQe,Item:FQe,Input:zQe,Group:BQe,Separator:$Qe,Dialog:VQe,Empty:qQe,Loading:GQe});function HQe(t,e){let r=t.nextElementSibling;for(;r;){if(r.matches(e))return r;r=r.nextElementSibling}}function WQe(t,e){let r=t.previousElementSibling;for(;r;){if(r.matches(e))return r;r=r.previousElementSibling}}function Cwe(t){let e=N.useRef(t);return Gv(()=>{e.current=t}),e}var Gv=typeof window>"u"?N.useEffect:N.useLayoutEffect;function k1(t){let e=N.useRef();return e.current===void 0&&(e.current=t()),e}function Kx(t){let e=QW(),r=()=>t(e.snapshot());return N.useSyncExternalStore(e.subscribe,r,r)}function Iwe(t,e,r,n=[]){let s=N.useRef(),o=$C();return Gv(()=>{var c;let a=(()=>{var m;for(let y of r){if(typeof y=="string")return y.trim();if(typeof y=="object"&&"current"in y)return y.current?(m=y.current.textContent)==null?void 0:m.trim():s.current}})(),f=n.map(m=>m.trim());o.value(t,a,f),(c=e.current)==null||c.setAttribute(j1,a),s.current=a}),s}var KQe=()=>{let[t,e]=N.useState(),r=k1(()=>new Map);return Gv(()=>{r.current.forEach(n=>n()),r.current=new Map},[t]),(n,s)=>{r.current.set(n,s),e({})}};function YQe(t){let e=t.type;return typeof e=="function"?e(t.props):"render"in e?e.render(t.props):t}function J4({asChild:t,children:e},r){return t&&N.isValidElement(e)?N.cloneElement(YQe(e),{ref:e.ref},r(e.props.children)):r(e)}var ZQe={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const iN=N.forwardRef(({className:t,...e},r)=>i.jsx(nd,{ref:r,className:Xt("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",t),...e}));iN.displayName=nd.displayName;const XQe=({children:t,...e})=>i.jsx(Ha,{...e,children:i.jsx(Ra,{className:"overflow-hidden p-0 shadow-lg",children:i.jsx(iN,{className:"[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5",children:t})})}),aN=N.forwardRef(({className:t,...e},r)=>i.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[i.jsx(Dd,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),i.jsx(nd.Input,{ref:r,className:Xt("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",t),...e})]}));aN.displayName=nd.Input.displayName;const oN=N.forwardRef(({className:t,...e},r)=>i.jsx(nd.List,{ref:r,className:Xt("max-h-[300px] overflow-y-auto overflow-x-hidden",t),...e}));oN.displayName=nd.List.displayName;const lN=N.forwardRef((t,e)=>i.jsx(nd.Empty,{ref:e,className:"py-6 text-center text-sm",...t}));lN.displayName=nd.Empty.displayName;const ug=N.forwardRef(({className:t,...e},r)=>i.jsx(nd.Group,{ref:r,className:Xt("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",t),...e}));ug.displayName=nd.Group.displayName;const QQe=N.forwardRef(({className:t,...e},r)=>i.jsx(nd.Separator,{ref:r,className:Xt("-mx-1 h-px bg-border",t),...e}));QQe.displayName=nd.Separator.displayName;const Tf=N.forwardRef(({className:t,...e},r)=>i.jsx(nd.Item,{ref:r,className:Xt("group relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected='true']:bg-primary/80 data-[selected=true]:text-primary-foreground data-[disabled=true]:opacity-50",t),...e}));Tf.displayName=nd.Item.displayName;const xd=t=>Number.isFinite(Number(t))?Number(t):0,Qp=t=>Math.round(t*100)/100,JQe=[{id:"closing",label:"Closing / settlement fee",amount:200},{id:"owners",label:"Owner's title insurance",amount:711.7},{id:"search",label:"Search & exam fee",amount:250},{id:"tief",label:"TIEF fee",amount:5},{id:"deed",label:"Deed preparation",amount:75},{id:"cpl",label:"Closing protection letter",amount:25}];function eJe(){return{listingCommissionPct:3,buyerCommissionPct:3,brokerageFee:0,titleFees:JQe.map(t=>({...t})),firstPayoff:0,secondPayoff:0,annualTaxes:0,taxesInArrears:!0,otherCosts:[]}}function tJe(t,e=5){const r=Math.max(0,xd(t)),n=Math.round(r*e/100/1e3)*1e3;return[{id:"low",label:"Quick sale",price:Math.max(0,r-n),concessions:0,repairs:0},{id:"target",label:"Target price",price:r,concessions:0,repairs:0},{id:"high",label:"Top of market",price:r+n,concessions:0,repairs:0}]}function vJt(t){const e=Math.max(0,xd(t));return["A","B","C"].map(r=>({id:`offer-${r}`,label:`Offer ${r}`,price:e,concessions:0,repairs:0}))}function rJe(t){if(!t)return null;const[e,r,n]=t.split(/[-/T]/).map(Number);if(!e||!r||!n)return null;const s=e%4===0&&e%100!==0||e%400===0,o=[31,s?29:28,31,30,31,30,31,31,30,31,30,31];let c=n;for(let a=0;aI+xd(M.amount),0)),m=Qp(xd(t.firstPayoff)+xd(t.secondPayoff)),y=nJe(t.annualTaxes,r,t.taxesInArrears),_=Qp((t.otherCosts||[]).reduce((I,M)=>I+xd(M.amount),0)),w=xd(e.concessions),E=xd(e.repairs),A=Qp(c+a+f+m+y+_+w+E),C=Qp(n-A);return{price:n,commission:c,listingCommission:s,buyerCommission:o,brokerageFee:a,titleTotal:f,payoffs:m,taxProration:y,concessions:w,repairs:E,otherTotal:_,totalCosts:A,net:C,netPct:n>0?C/n:0}}const vm=(t,e=!1)=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:e?2:0,maximumFractionDigits:e?2:0}).format(t||0),zC=()=>Ce.from("seller_net_sheets"),bJt=t=>`${window.location.origin}/net-sheet/${t}`;function wJt(t){const e=zs();return mr({queryKey:["net-sheets",e,t??"all"],enabled:!!e,queryFn:async()=>{let r=zC().select("*").eq("owner_user_id",e).order("updated_at",{ascending:!1});t&&(r=r.eq("deal_id",t));const{data:n,error:s}=await r.range(0,999);if(s)throw s;return n??[]}})}function SJt(t){return mr({queryKey:["net-sheet",t],enabled:!!t,queryFn:async()=>{const{data:e,error:r}=await zC().select("*").eq("id",t).single();if(r)throw r;return e}})}function iJe(){const t=zs(),e=jr();return kr({mutationFn:async r=>{const{price:n,...s}=r,{data:o,error:c}=await zC().insert({...s,owner_user_id:t,title:r.title??"Seller net sheet",mode:"price",inputs:eJe(),scenarios:tJe(n||3e5)}).select().single();if(c)throw c;return o},onSuccess:()=>e.invalidateQueries({queryKey:["net-sheets"]})})}function TJt(){const t=jr();return kr({mutationFn:async({id:e,...r})=>{const{error:n}=await zC().update(r).eq("id",e);if(n)throw n},onSuccess:(e,r)=>{t.invalidateQueries({queryKey:["net-sheets"]}),t.invalidateQueries({queryKey:["net-sheet",r.id]})}})}function EJt(){const t=jr();return kr({mutationFn:async e=>{const{error:r}=await zC().delete().eq("id",e);if(r)throw r},onSuccess:()=>t.invalidateQueries({queryKey:["net-sheets"]})})}function aJe(t){return mr({queryKey:["public-net-sheet",t],enabled:!!t,queryFn:async()=>{const{data:e,error:r}=await Ce.rpc("get_public_net_sheet",{_slug:t});if(r)throw r;return e}})}const oJe=[{id:"new-net-sheet",label:"New Net Sheet",hint:"Show a seller what they walk away with",keywords:["net","sheet","seller","proceeds"],path:"/mission-control/net-sheets"},{id:"drop-contract",label:"Drop Contract",hint:"Upload a purchase agreement to a deal",keywords:["contract","pdf","purchase","agreement","upload","dates"],path:"/mission-control/pipeline"},{id:"record-video",label:"Record Video",hint:"Open Video Studio",keywords:["video","record","studio","camera"],path:"/video-studio"},{id:"new-contact",label:"New Contact",hint:"Add someone to your CRM",keywords:["contact","add","lead","person"],path:"/mission-control/contacts?new=true"},{id:"new-deal",label:"Open Pipeline",hint:"See and add deals",keywords:["deal","pipeline","transaction","new"],path:"/mission-control/pipeline"},{id:"new-task",label:"My Tasks",hint:"See and add tasks",keywords:["task","todo","follow"],path:"/mission-control/tasks"},{id:"new-cma",label:"New CMA",hint:"Build a market analysis",keywords:["cma","market","analysis","comps","value"],path:"/mission-control/cma"},{id:"my-calendar",label:"My Calendar",hint:"Appointments and showings",keywords:["calendar","appointment","schedule"],path:"/mission-control/calendar"}];function lJe(t,e=oJe){const r=t.trim().toLowerCase();if(!r)return e.slice(0,4);const n=r.split(/\s+/);return e.filter(s=>{const o=`${s.label} ${s.keywords.join(" ")}`.toLowerCase();return n.every(c=>o.includes(c))})}function cJe(t){return/mac|iphone|ipad|ipod/i.test(t)?"⌘K":"Ctrl K"}function uJe(t){return t.replace(/[,()*%\\]/g," ").trim()}const dJe={event:{label:"Events",icon:Vm,color:"bg-blue-500/10 text-blue-600"},template:{label:"Templates",icon:a4,color:"bg-purple-500/10 text-purple-600"},academy:{label:"Academy",icon:UA,color:"bg-amber-500/10 text-amber-600"},toolbox:{label:"Toolbox",icon:wH,color:"bg-green-500/10 text-green-600"},"social-swag":{label:"Social Swag",icon:ki,color:"bg-fuchsia-500/10 text-fuchsia-600"}},tie=({hotkey:t=!0}={})=>{const[e,r]=N.useState(!1),[n,s]=N.useState(""),[o,c]=N.useState([]),[a,f]=N.useState(!1),m=ra(),{searchDestinations:y,isFavorite:_,routeFor:w}=Swe(),E=n.trim()?y(n).slice(0,4):[],A=zs(),[C,I]=N.useState([]),[M,D]=N.useState([]),B=lJe(n),U=iJe(),q=typeof navigator<"u"?cJe(navigator.platform||navigator.userAgent):"Ctrl K",H=async ee=>{if(ee.id==="new-net-sheet"){r(!1),s("");try{const oe=await U.mutateAsync({});m(`/mission-control/net-sheets/${oe.id}`)}catch{m(ee.path)}return}Q(ee.path)};N.useEffect(()=>{if(!t)return;const ee=oe=>{oe.key==="k"&&(oe.metaKey||oe.ctrlKey)&&(oe.preventDefault(),r(de=>!de))};return document.addEventListener("keydown",ee),()=>document.removeEventListener("keydown",ee)},[t]);const K=N.useCallback(async ee=>{if(!ee.trim()){c([]),I([]),D([]);return}f(!0);const oe=`%${ee}%`;try{const[de,ye,Ee,Le,Se]=await Promise.all([Ce.from("events").select("id, title, description, event_date").eq("is_published",!0).or(`title.ilike.${oe},description.ilike.${oe}`).limit(5),Ce.from("canva_templates").select("id, name, description, publish_date").or(`name.ilike.${oe},description.ilike.${oe}`).limit(5),Ce.from("academy_videos").select("id, title, description, publish_date").eq("is_published",!0).or(`title.ilike.${oe},description.ilike.${oe}`).limit(5),Ce.from("resource_kits").select("id, name, description, publish_date").eq("is_published",!0).or(`name.ilike.${oe},description.ilike.${oe}`).limit(5),Ce.from("social_swag").select("id, title, description, publish_date").eq("is_published",!0).or(`title.ilike.${oe},description.ilike.${oe}`).limit(5)]),be=[],me=uJe(ee);if(me&&A){const ke=`%${me}%`,Pe=me.split(/\s+/),je=Pe.length>1?`and(first_name.ilike.%${Pe[0]}%,last_name.ilike.%${Pe.slice(1).join(" ")}%)`:null,[xe,Ue]=await Promise.all([Ce.from("innercircle_contacts").select("id, first_name, last_name, email, phone, address, city").eq("owner_user_id",A).or([`first_name.ilike.${ke}`,`last_name.ilike.${ke}`,`email.ilike.${ke}`,`phone.ilike.${ke}`,`address.ilike.${ke}`,je].filter(Boolean).join(",")).limit(6),Ce.from("deal_pipeline").select("id, deal_name, property_address, city, deal_type").eq("owner_user_id",A).or(`deal_name.ilike.${ke},property_address.ilike.${ke},city.ilike.${ke}`).limit(6)]);I((xe.data??[]).map(Ze=>({id:Ze.id,title:[Ze.first_name,Ze.last_name].filter(Boolean).join(" ")||Ze.email||"Contact",sub:[Ze.phone,Ze.email,Ze.address].filter(Boolean).join(" · ")}))),D((Ue.data??[]).map(Ze=>({id:Ze.id,title:Ze.property_address||Ze.deal_name||"Deal",sub:[Ze.deal_name!==Ze.property_address?Ze.deal_name:null,Ze.city,Ze.deal_type].filter(Boolean).join(" · ")})))}de.data&&de.data.forEach(ke=>{be.push({id:ke.id,title:ke.title,description:ke.description,type:"event",date:ke.event_date,path:`/event/${ke.id}`})}),ye.data&&ye.data.forEach(ke=>{be.push({id:ke.id,title:ke.name,description:ke.description,type:"template",date:ke.publish_date,path:`/templates/${ke.id}`})}),Ee.data&&Ee.data.forEach(ke=>{be.push({id:ke.id,title:ke.title,description:ke.description,type:"academy",date:ke.publish_date,path:`/academy/${ke.id}`})}),Le.data&&Le.data.forEach(ke=>{be.push({id:ke.id,title:ke.name,description:ke.description,type:"toolbox",date:ke.publish_date,path:`/toolbox/${ke.id}`})}),Se.data&&Se.data.forEach(ke=>{be.push({id:ke.id,title:ke.title,description:ke.description,type:"social-swag",date:ke.publish_date,path:`/social-swag/${ke.id}`})}),c(be)}catch(de){console.error("Search error:",de)}finally{f(!1)}},[A]);N.useEffect(()=>{const ee=setTimeout(()=>{K(n)},200);return()=>clearTimeout(ee)},[n,K]);const Q=ee=>{r(!1),s(""),m(ee)},J=o.reduce((ee,oe)=>(ee[oe.type]||(ee[oe.type]=[]),ee[oe.type].push(oe),ee),{});return i.jsxs(i.Fragment,{children:[i.jsxs(Lt,{variant:"outline","aria-label":"Search contacts, deals and actions",className:"relative h-9 w-9 p-0 md:h-10 md:w-full md:max-w-xl md:justify-start md:rounded-full md:bg-muted/40 md:px-4 md:pr-16 hover:bg-muted",onClick:()=>r(!0),children:[i.jsx(Dd,{className:"h-4 w-4 md:mr-2 text-muted-foreground"}),i.jsx("span",{className:"hidden md:inline-flex truncate text-muted-foreground text-sm",children:"Search contacts, addresses, or type an action…"}),i.jsx("kbd",{className:"pointer-events-none absolute right-3 top-1/2 -translate-y-1/2 hidden h-6 select-none items-center rounded border bg-background px-1.5 font-mono text-[11px] font-medium text-muted-foreground md:flex",children:q})]}),i.jsxs(XQe,{open:e,onOpenChange:r,children:[i.jsx(aN,{placeholder:"Name, address, or an action like “New Net Sheet”…",value:n,onValueChange:s}),i.jsxs(oN,{className:"max-h-[70vh]",children:[C.length>0&&i.jsx(ug,{heading:"Contacts",children:C.map(ee=>i.jsxs(Tf,{value:`contact-${ee.id}-${ee.title}-${ee.sub}-${n}`,onSelect:()=>Q(`/mission-control/contacts/${ee.id}`),className:"flex items-center gap-3 cursor-pointer",children:[i.jsx("div",{className:"p-2 rounded-full bg-primary/10 text-primary",children:i.jsx(Gl,{className:"h-4 w-4"})}),i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsx("div",{className:"font-medium truncate",children:ee.title}),ee.sub&&i.jsx("div",{className:"text-sm text-muted-foreground truncate",children:ee.sub})]})]},`c-${ee.id}`))}),M.length>0&&i.jsx(ug,{heading:"Deals",children:M.map(ee=>i.jsxs(Tf,{value:`deal-${ee.id}-${ee.title}-${ee.sub}-${n}`,onSelect:()=>Q(`/mission-control/pipeline?deal=${ee.id}`),className:"flex items-center gap-3 cursor-pointer",children:[i.jsx("div",{className:"p-2 rounded-md bg-secondary text-secondary-foreground",children:i.jsx(ea,{className:"h-4 w-4"})}),i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsx("div",{className:"font-medium truncate",children:ee.title}),ee.sub&&i.jsx("div",{className:"text-sm text-muted-foreground truncate",children:ee.sub})]})]},`d-${ee.id}`))}),B.length>0&&i.jsx(ug,{heading:n?"Actions":"Quick actions",children:B.map(ee=>i.jsxs(Tf,{value:`action-${ee.id}-${ee.label}-${ee.keywords.join(" ")}`,onSelect:()=>H(ee),className:"flex items-center gap-3 cursor-pointer",children:[i.jsx("div",{className:"p-2 rounded-md bg-accent text-accent-foreground",children:i.jsx(GS,{className:"h-4 w-4"})}),i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsx("div",{className:"font-medium truncate",children:ee.label}),i.jsx("div",{className:"text-sm text-muted-foreground truncate",children:ee.hint})]})]},`a-${ee.id}`))}),E.length>0&&i.jsx(ug,{heading:"Go to",children:E.map(ee=>{const oe=ee.icon;return i.jsxs(Tf,{value:`nav-${ee.id}-${ee.label}`,onSelect:()=>{const de=w(ee);ee.external||ee.openInNewTab?(r(!1),s(""),window.open(de,"_blank","noopener,noreferrer")):Q(de)},className:"flex items-start gap-3 py-3 cursor-pointer",children:[i.jsx("div",{className:"p-2 rounded-md bg-primary/10 text-primary",children:i.jsx(oe,{className:"h-4 w-4"})}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"font-medium truncate flex items-center gap-1.5",children:[ee.label,_(ee)&&i.jsx(CD,{className:"h-3 w-3 fill-current text-primary"})]}),ee.description&&i.jsx("div",{className:"text-sm text-muted-foreground truncate",children:ee.description})]}),i.jsx(pi,{variant:"secondary",className:"text-xs shrink-0",children:ee.section})]},`nav-${ee.id}`)})}),a&&i.jsx("div",{className:"py-6 text-center text-sm text-muted-foreground",children:"Searching..."}),!a&&n&&o.length===0&&E.length===0&&C.length===0&&M.length===0&&B.length===0&&i.jsxs(lN,{children:['No results found for "',n,'"']}),!a&&!n&&i.jsx("div",{className:"py-3 text-center text-xs text-muted-foreground",children:"Type a name, address or phone — or an action"}),Object.entries(J).map(([ee,oe])=>{const de=dJe[ee],ye=de.icon;return i.jsx(ug,{heading:de.label,children:oe.map(Ee=>i.jsxs(Tf,{value:`${Ee.type}-${Ee.id}-${Ee.title}`,onSelect:()=>Q(Ee.path),className:"flex items-start gap-3 py-3 cursor-pointer",children:[i.jsx("div",{className:`p-2 rounded-md ${de.color}`,children:i.jsx(ye,{className:"h-4 w-4"})}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("div",{className:"font-medium truncate",children:Ee.title}),Ee.description&&i.jsx("div",{className:"text-sm text-muted-foreground truncate group-data-[selected=true]:text-primary-foreground/80",children:Ee.description})]}),i.jsxs("div",{className:"flex flex-col items-end gap-1 shrink-0",children:[i.jsx(pi,{variant:"secondary",className:"text-xs",children:de.label}),i.jsx("span",{className:"text-xs text-muted-foreground",children:mwe(new Date(Ee.date),{addSuffix:!0})})]})]},`${Ee.type}-${Ee.id}`))},ee)})]})]})]})},hJe=({expiresAt:t,className:e,showUpgradeButton:r=!0})=>{const[n,s]=N.useState(null),o=ra();if(N.useEffect(()=>{const m=()=>{const _=new Date().getTime(),E=new Date(t).getTime()-_;if(E<=0){s({days:0,hours:0,minutes:0});return}const A=Math.floor(E/(1e3*60*60*24)),C=Math.floor(E%(1e3*60*60*24)/(1e3*60*60)),I=Math.floor(E%(1e3*60*60)/(1e3*60));s({days:A,hours:C,minutes:I})};m();const y=setInterval(m,6e4);return()=>clearInterval(y)},[t]),!n)return null;const c=n.days===0&&n.hours===0&&n.minutes===0,a=n.days<=1,f=n.days<=3&&!a;return c?i.jsxs("div",{className:Xt("flex items-center justify-between gap-3 px-4 py-2 rounded-lg bg-destructive/10 border border-destructive/20",e),children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(VT,{className:"h-4 w-4 text-destructive"}),i.jsx("span",{className:"text-sm font-medium text-destructive",children:"Your free trial has expired"})]}),r&&i.jsxs(Lt,{size:"sm",onClick:()=>o("/subscription"),className:"bg-primary hover:bg-primary/90 text-xs h-7 px-3",children:[i.jsx(ki,{className:"h-3 w-3 mr-1"}),"Upgrade Now"]})]}):i.jsxs("div",{className:Xt("flex items-center justify-between gap-3 px-4 py-2 rounded-lg border transition-colors",a?"bg-destructive/10 border-destructive/20":f?"bg-amber-500/10 border-amber-500/20":"bg-primary/10 border-primary/20",e),children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(ql,{className:Xt("h-4 w-4",a?"text-destructive":f?"text-amber-500":"text-primary")}),i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsx("span",{className:Xt("text-sm font-medium",a?"text-destructive":f?"text-amber-600":"text-primary"),children:"Free Trial:"}),i.jsxs("div",{className:"flex items-center gap-1",children:[n.days>0&&i.jsxs("span",{className:Xt("text-sm font-bold",a?"text-destructive":f?"text-amber-600":"text-primary"),children:[n.days,"d"]}),i.jsxs("span",{className:Xt("text-sm font-bold",a?"text-destructive":f?"text-amber-600":"text-primary"),children:[n.hours,"h"]}),i.jsxs("span",{className:Xt("text-sm font-bold",a?"text-destructive":f?"text-amber-600":"text-primary"),children:[n.minutes,"m"]}),i.jsx("span",{className:Xt("text-xs",a?"text-destructive/70":f?"text-amber-600/70":"text-primary/70"),children:"remaining"})]})]})]}),r&&i.jsxs(Lt,{size:"sm",onClick:()=>o("/subscription"),variant:a?"destructive":f?"default":"outline",className:Xt("text-xs h-7 px-3",f&&"bg-amber-500 hover:bg-amber-600 text-white"),children:[i.jsx(ki,{className:"h-3 w-3 mr-1"}),"Upgrade"]})]})},fJe=()=>{const t=ra();return i.jsx("div",{className:"fixed inset-0 bg-background/95 backdrop-blur-sm z-50 flex items-center justify-center p-4 overflow-y-auto",children:i.jsxs(Kn,{className:"w-full max-w-2xl shadow-2xl border-destructive/20 my-8",children:[i.jsxs(Nd,{className:"text-center pb-2",children:[i.jsx("div",{className:"mx-auto mb-4 h-16 w-16 rounded-full bg-destructive/10 flex items-center justify-center",children:i.jsx(VT,{className:"h-8 w-8 text-destructive"})}),i.jsx(Cd,{className:"text-2xl",children:"Your Free Trial Has Ended"}),i.jsx(tN,{className:"text-base",children:"Your 7-day free trial has expired. Upgrade now to continue accessing all the powerful tools and resources LevelUp has to offer!"})]}),i.jsxs(ss,{className:"space-y-6",children:[i.jsxs("div",{className:"grid sm:grid-cols-2 gap-4",children:[i.jsx(Kn,{className:"border-2 border-primary/20 hover:border-primary/50 transition-colors cursor-pointer",onClick:()=>t("/subscription"),children:i.jsxs(ss,{className:"p-5 text-center",children:[i.jsx("div",{className:"mx-auto mb-3 h-12 w-12 rounded-full bg-primary/10 flex items-center justify-center",children:i.jsx(El,{className:"h-6 w-6 text-primary"})}),i.jsx("h3",{className:"font-semibold text-lg mb-1",children:"Individual Agent"}),i.jsxs("p",{className:"text-2xl font-bold text-primary mb-2",children:["$39",i.jsx("span",{className:"text-sm font-normal text-muted-foreground",children:"/mo"})]}),i.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Perfect for solo agents ready to level up"}),i.jsxs(Lt,{className:"w-full",onClick:e=>{e.stopPropagation(),t("/subscription")},children:[i.jsx(ki,{className:"h-4 w-4 mr-2"}),"Choose Individual"]})]})}),i.jsx(Kn,{className:"border-2 border-amber-500/20 hover:border-amber-500/50 transition-colors cursor-pointer",onClick:()=>t("/subscription"),children:i.jsxs(ss,{className:"p-5 text-center",children:[i.jsx("div",{className:"mx-auto mb-3 h-12 w-12 rounded-full bg-amber-500/10 flex items-center justify-center",children:i.jsx(Ja,{className:"h-6 w-6 text-amber-600"})}),i.jsx("h3",{className:"font-semibold text-lg mb-1",children:"Brokerage"}),i.jsxs("p",{className:"text-2xl font-bold text-amber-600 mb-2",children:["$299",i.jsx("span",{className:"text-sm font-normal text-muted-foreground",children:"/mo"})]}),i.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"For teams and brokerages"}),i.jsxs(Lt,{variant:"outline",className:"w-full border-amber-500 text-amber-600 hover:bg-amber-50",onClick:e=>{e.stopPropagation(),t("/subscription")},children:[i.jsx(Ja,{className:"h-4 w-4 mr-2"}),"Choose Brokerage"]})]})})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx("p",{className:"text-sm text-muted-foreground text-center",children:"With a full membership, you'll get:"}),i.jsxs("ul",{className:"text-sm space-y-1 text-muted-foreground grid sm:grid-cols-2 gap-x-4",children:[i.jsxs("li",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-primary",children:"✓"})," Unlimited access to all marketing templates"]}),i.jsxs("li",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-primary",children:"✓"})," Complete Academy training library"]}),i.jsxs("li",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-primary",children:"✓"})," AI-powered tools and resources"]}),i.jsxs("li",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-primary",children:"✓"})," Community forums and support"]}),i.jsxs("li",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-primary",children:"✓"})," Exclusive member events and workshops"]}),i.jsxs("li",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-primary",children:"✓"})," Deal pipeline & scorecard tracking"]})]})]}),i.jsxs("div",{className:"bg-muted/50 rounded-lg p-4 space-y-3",children:[i.jsx("p",{className:"text-sm font-medium text-center",children:"Questions? Contact us:"}),i.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 justify-center",children:[i.jsxs("a",{href:"tel:1-866-527-8668",className:"flex items-center justify-center gap-2 text-primary hover:underline",children:[i.jsx(Un,{className:"h-4 w-4"}),i.jsx("span",{children:"1-866-527-8668"})]}),i.jsxs("a",{href:"mailto:support@relevelup.com",className:"flex items-center justify-center gap-2 text-primary hover:underline",children:[i.jsx(rs,{className:"h-4 w-4"}),i.jsx("span",{children:"support@relevelup.com"})]})]})]})]})]})})},mJe=({hasUnseenBrief:t,onClick:e,className:r})=>i.jsxs(q$e,{children:[i.jsx(G$e,{asChild:!0,children:i.jsxs(Lt,{variant:"ghost",size:"icon",onClick:e,className:Xt("relative transition-colors",t&&"text-primary hover:text-primary",r),children:[i.jsx(Tv,{className:"h-5 w-5"}),t&&i.jsx("span",{className:"absolute top-1 right-1 h-2 w-2 rounded-full bg-primary animate-pulse"})]})}),i.jsx(qxe,{children:i.jsx("p",{children:"The LevelUp Brief"})})]});var eF="Checkbox",[pJe,jJt]=cl(eF),[gJe,JW]=pJe(eF);function yJe(t){const{__scopeCheckbox:e,checked:r,children:n,defaultChecked:s,disabled:o,form:c,name:a,onCheckedChange:f,required:m,value:y="on",internal_do_not_use_render:_}=t,[w,E]=ed({prop:r,defaultProp:s??!1,onChange:f,caller:eF}),[A,C]=N.useState(null),[I,M]=N.useState(null),D=N.useRef(!1),B=A?!!c||!!A.closest("form"):!0,U={checked:w,disabled:o,setChecked:E,control:A,setControl:C,name:a,form:c,value:y,hasConsumerStoppedPropagationRef:D,required:m,defaultChecked:Px(s)?!1:s,isFormControl:B,bubbleInput:I,setBubbleInput:M};return i.jsx(gJe,{scope:e,...U,children:xJe(_)?_(U):n})}var Pwe="CheckboxTrigger",Rwe=N.forwardRef(({__scopeCheckbox:t,onKeyDown:e,onClick:r,...n},s)=>{const{control:o,value:c,disabled:a,checked:f,required:m,setControl:y,setChecked:_,hasConsumerStoppedPropagationRef:w,isFormControl:E,bubbleInput:A}=JW(Pwe,t),C=is(s,y),I=N.useRef(f);return N.useEffect(()=>{const M=o==null?void 0:o.form;if(M){const D=()=>_(I.current);return M.addEventListener("reset",D),()=>M.removeEventListener("reset",D)}},[o,_]),i.jsx(cn.button,{type:"button",role:"checkbox","aria-checked":Px(f)?"mixed":f,"aria-required":m,"data-state":Fwe(f),"data-disabled":a?"":void 0,disabled:a,value:c,...n,ref:C,onKeyDown:Gr(e,M=>{M.key==="Enter"&&M.preventDefault()}),onClick:Gr(r,M=>{_(D=>Px(D)?!0:!D),A&&E&&(w.current=M.isPropagationStopped(),w.current||M.stopPropagation())})})});Rwe.displayName=Pwe;var eK=N.forwardRef((t,e)=>{const{__scopeCheckbox:r,name:n,checked:s,defaultChecked:o,required:c,disabled:a,value:f,onCheckedChange:m,form:y,..._}=t;return i.jsx(yJe,{__scopeCheckbox:r,checked:s,defaultChecked:o,disabled:a,required:c,onCheckedChange:m,name:n,form:y,value:f,internal_do_not_use_render:({isFormControl:w})=>i.jsxs(i.Fragment,{children:[i.jsx(Rwe,{..._,ref:e,__scopeCheckbox:r}),w&&i.jsx(Owe,{__scopeCheckbox:r})]})})});eK.displayName=eF;var Lwe="CheckboxIndicator",Mwe=N.forwardRef((t,e)=>{const{__scopeCheckbox:r,forceMount:n,...s}=t,o=JW(Lwe,r);return i.jsx(Cl,{present:n||Px(o.checked)||o.checked===!0,children:i.jsx(cn.span,{"data-state":Fwe(o.checked),"data-disabled":o.disabled?"":void 0,...s,ref:e,style:{pointerEvents:"none",...t.style}})})});Mwe.displayName=Lwe;var Dwe="CheckboxBubbleInput",Owe=N.forwardRef(({__scopeCheckbox:t,...e},r)=>{const{control:n,hasConsumerStoppedPropagationRef:s,checked:o,defaultChecked:c,required:a,disabled:f,name:m,value:y,form:_,bubbleInput:w,setBubbleInput:E}=JW(Dwe,t),A=is(r,E),C=OC(o),I=jC(n);N.useEffect(()=>{const D=w;if(!D)return;const B=window.HTMLInputElement.prototype,q=Object.getOwnPropertyDescriptor(B,"checked").set,H=!s.current;if(C!==o&&q){const K=new Event("click",{bubbles:H});D.indeterminate=Px(o),q.call(D,Px(o)?!1:o),D.dispatchEvent(K)}},[w,C,o,s]);const M=N.useRef(Px(o)?!1:o);return i.jsx(cn.input,{type:"checkbox","aria-hidden":!0,defaultChecked:c??M.current,required:a,disabled:f,name:m,value:y,form:_,...e,tabIndex:-1,ref:A,style:{...e.style,...I,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});Owe.displayName=Dwe;function xJe(t){return typeof t=="function"}function Px(t){return t==="indeterminate"}function Fwe(t){return Px(t)?"indeterminate":t?"checked":"unchecked"}const aE=N.forwardRef(({className:t,...e},r)=>i.jsx(eK,{ref:r,className:Xt("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t),...e,children:i.jsx(Mwe,{className:Xt("flex items-center justify-center text-current"),children:i.jsx(pa,{className:"h-4 w-4"})})}));aE.displayName=eK.displayName;var tK="Radio",[_Je,Bwe]=cl(tK),[vJe,bJe]=_Je(tK),$we=N.forwardRef((t,e)=>{const{__scopeRadio:r,name:n,checked:s=!1,required:o,disabled:c,value:a="on",onCheck:f,form:m,...y}=t,[_,w]=N.useState(null),E=is(e,I=>w(I)),A=N.useRef(!1),C=_?m||!!_.closest("form"):!0;return i.jsxs(vJe,{scope:r,checked:s,disabled:c,children:[i.jsx(cn.button,{type:"button",role:"radio","aria-checked":s,"data-state":qwe(s),"data-disabled":c?"":void 0,disabled:c,value:a,...y,ref:E,onClick:Gr(t.onClick,I=>{s||f==null||f(),C&&(A.current=I.isPropagationStopped(),A.current||I.stopPropagation())})}),C&&i.jsx(Vwe,{control:_,bubbles:!A.current,name:n,value:a,checked:s,required:o,disabled:c,form:m,style:{transform:"translateX(-100%)"}})]})});$we.displayName=tK;var zwe="RadioIndicator",Uwe=N.forwardRef((t,e)=>{const{__scopeRadio:r,forceMount:n,...s}=t,o=bJe(zwe,r);return i.jsx(Cl,{present:n||o.checked,children:i.jsx(cn.span,{"data-state":qwe(o.checked),"data-disabled":o.disabled?"":void 0,...s,ref:e})})});Uwe.displayName=zwe;var wJe="RadioBubbleInput",Vwe=N.forwardRef(({__scopeRadio:t,control:e,checked:r,bubbles:n=!0,...s},o)=>{const c=N.useRef(null),a=is(c,o),f=OC(r),m=jC(e);return N.useEffect(()=>{const y=c.current;if(!y)return;const _=window.HTMLInputElement.prototype,E=Object.getOwnPropertyDescriptor(_,"checked").set;if(f!==r&&E){const A=new Event("click",{bubbles:n});E.call(y,r),y.dispatchEvent(A)}},[f,r,n]),i.jsx(cn.input,{type:"radio","aria-hidden":!0,defaultChecked:r,...s,tabIndex:-1,ref:a,style:{...s.style,...m,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});Vwe.displayName=wJe;function qwe(t){return t?"checked":"unchecked"}var SJe=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],tF="RadioGroup",[TJe,kJt]=cl(tF,[eE,Bwe]),Gwe=eE(),Hwe=Bwe(),[EJe,jJe]=TJe(tF),Wwe=N.forwardRef((t,e)=>{const{__scopeRadioGroup:r,name:n,defaultValue:s,value:o,required:c=!1,disabled:a=!1,orientation:f,dir:m,loop:y=!0,onValueChange:_,...w}=t,E=Gwe(r),A=ob(m),[C,I]=ed({prop:o,defaultProp:s??null,onChange:_,caller:tF});return i.jsx(EJe,{scope:r,name:n,required:c,disabled:a,value:C,onValueChange:I,children:i.jsx(nW,{asChild:!0,...E,orientation:f,dir:A,loop:y,children:i.jsx(cn.div,{role:"radiogroup","aria-required":c,"aria-orientation":f,"data-disabled":a?"":void 0,dir:A,...w,ref:e})})})});Wwe.displayName=tF;var Kwe="RadioGroupItem",Ywe=N.forwardRef((t,e)=>{const{__scopeRadioGroup:r,disabled:n,...s}=t,o=jJe(Kwe,r),c=o.disabled||n,a=Gwe(r),f=Hwe(r),m=N.useRef(null),y=is(e,m),_=o.value===s.value,w=N.useRef(!1);return N.useEffect(()=>{const E=C=>{SJe.includes(C.key)&&(w.current=!0)},A=()=>w.current=!1;return document.addEventListener("keydown",E),document.addEventListener("keyup",A),()=>{document.removeEventListener("keydown",E),document.removeEventListener("keyup",A)}},[]),i.jsx(sW,{asChild:!0,...a,focusable:!c,active:_,children:i.jsx($we,{disabled:c,required:o.required,checked:_,...f,...s,name:o.name,ref:y,onCheck:()=>o.onValueChange(s.value),onKeyDown:Gr(E=>{E.key==="Enter"&&E.preventDefault()}),onFocus:Gr(s.onFocus,()=>{var E;w.current&&((E=m.current)==null||E.click())})})})});Ywe.displayName=Kwe;var kJe="RadioGroupIndicator",Zwe=N.forwardRef((t,e)=>{const{__scopeRadioGroup:r,...n}=t,s=Hwe(r);return i.jsx(Uwe,{...s,...n,ref:e})});Zwe.displayName=kJe;var Xwe=Wwe,Qwe=Ywe,AJe=Zwe;const Jwe=N.forwardRef(({className:t,...e},r)=>i.jsx(Xwe,{className:Xt("grid gap-2",t),...e,ref:r}));Jwe.displayName=Xwe.displayName;const e1e=N.forwardRef(({className:t,...e},r)=>i.jsx(Qwe,{ref:r,className:Xt("aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t),...e,children:i.jsx(AJe,{className:"flex items-center justify-center",children:i.jsx(Ov,{className:"h-2.5 w-2.5 fill-current text-current"})})}));e1e.displayName=Qwe.displayName;const NJe=({brief:t,open:e,onClose:r,onDismiss:n})=>{const{user:s}=Zn(),[o,c]=N.useState({}),[a,f]=N.useState({}),[m,y]=N.useState([]);N.useEffect(()=>{e&&s&&t.polls.length>0&&_()},[e,s,t.polls]);const _=async()=>{if(!s)return;const I=t.polls.map(D=>D.id),{data:M}=await Ce.from("levelup_brief_poll_responses").select("poll_id, option_id").eq("user_id",s.id).in("poll_id",I);if(M){const D={};M.forEach(B=>{D[B.poll_id]||(D[B.poll_id]=[]),D[B.poll_id].push(B.option_id)}),f(D)}},w=(I,M)=>{c(D=>({...D,[I]:M}))},E=(I,M,D)=>{c(B=>{const U=B[I]||[];return D?{...B,[I]:[...U,M]}:{...B,[I]:U.filter(q=>q!==M)}})},A=async I=>{if(!s)return;const M=o[I];if(!M||Array.isArray(M)&&M.length===0){$t.error("Please select an option");return}y(D=>[...D,I]);try{await Ce.from("levelup_brief_poll_responses").delete().eq("poll_id",I).eq("user_id",s.id);const D=Array.isArray(M)?M:[M],B=D.map(q=>({poll_id:I,option_id:q,user_id:s.id})),{error:U}=await Ce.from("levelup_brief_poll_responses").insert(B);if(U)throw U;f(q=>({...q,[I]:D})),$t.success("Response submitted!")}catch(D){console.error("Error submitting poll response:",D),$t.error("Failed to submit response")}finally{y(D=>D.filter(B=>B!==I))}},C=I=>(I.includes("mediadelivery.net")||I.includes("bunny"),I);return i.jsx(Ha,{open:e,onOpenChange:I=>!I&&r(),children:i.jsxs(Ra,{className:"max-w-2xl max-h-[90vh] p-0 overflow-hidden [&>button]:hidden",children:[i.jsxs("div",{className:"bg-gradient-to-r from-primary to-primary/80 p-4 pr-12 text-primary-foreground relative",children:[i.jsx("button",{onClick:r,className:"absolute top-3 right-3 p-1.5 rounded-full bg-white/30 hover:bg-white/50 transition-colors","aria-label":"Close",children:i.jsx(Ci,{className:"h-5 w-5 text-white"})}),i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"p-2 bg-white/20 rounded-lg",children:i.jsx(Tv,{className:"h-6 w-6"})}),i.jsxs("div",{children:[i.jsx(pi,{variant:"secondary",className:"mb-1 bg-white/20 text-white border-0",children:"The LevelUp Brief"}),i.jsx(Co,{className:"text-xl font-bold text-white",children:t.brief.title})]})]})]}),i.jsx(cp,{className:"max-h-[calc(90vh-240px)]",children:i.jsxs("div",{className:"p-6 space-y-6",children:[t.brief.description&&i.jsx("div",{className:"text-muted-foreground prose prose-sm max-w-none",dangerouslySetInnerHTML:{__html:t.brief.description}}),t.brief.video_url&&i.jsx("div",{className:"relative w-full aspect-video rounded-lg overflow-hidden bg-muted",children:i.jsx("iframe",{src:C(t.brief.video_url),className:"absolute inset-0 w-full h-full",allow:"autoplay; fullscreen; picture-in-picture",allowFullScreen:!0})}),t.brief.graphic_url&&!t.brief.video_url&&i.jsx("div",{className:"rounded-lg overflow-hidden bg-muted",children:t.brief.graphic_link_url?i.jsx("a",{href:t.brief.graphic_link_url,target:"_blank",rel:"noopener noreferrer",className:"block",children:i.jsx("img",{src:t.brief.graphic_url,alt:"Brief graphic",className:"w-full object-contain cursor-pointer hover:opacity-90 transition-opacity"})}):i.jsx("img",{src:t.brief.graphic_url,alt:"Brief graphic",className:"w-full object-contain"})}),t.links.length>0&&i.jsxs("div",{className:"space-y-3",children:[i.jsx("h4",{className:"font-semibold text-foreground",children:"Quick Links"}),i.jsx("div",{className:"flex flex-wrap gap-2",children:t.links.map(I=>i.jsxs(Lt,{variant:"outline",size:"sm",onClick:()=>window.open(I.url,"_blank"),className:"gap-2",children:[i.jsx(sb,{className:"h-4 w-4"}),I.title]},I.id))})]}),t.polls.map(I=>{var B,U;const M=((B=a[I.id])==null?void 0:B.length)>0,D=m.includes(I.id);return i.jsxs("div",{className:"space-y-3 p-4 bg-muted/50 rounded-lg border",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("h4",{className:"font-semibold text-foreground",children:I.question}),M&&i.jsxs(pi,{variant:"secondary",className:"gap-1",children:[i.jsx(Nl,{className:"h-3 w-3"}),"Responded"]})]}),I.poll_type==="single"?i.jsx(Jwe,{value:o[I.id]||((U=a[I.id])==null?void 0:U[0])||"",onValueChange:q=>w(I.id,q),className:"space-y-2",children:I.options.map(q=>i.jsxs("div",{className:"flex items-center space-x-2",children:[i.jsx(e1e,{value:q.id,id:q.id}),i.jsx(Fr,{htmlFor:q.id,className:"cursor-pointer",children:q.option_text})]},q.id))}):i.jsx("div",{className:"space-y-2",children:I.options.map(q=>{const K=(o[I.id]||a[I.id]||[]).includes(q.id);return i.jsxs("div",{className:"flex items-center space-x-2",children:[i.jsx(aE,{id:q.id,checked:K,onCheckedChange:Q=>E(I.id,q.id,Q)}),i.jsx(Fr,{htmlFor:q.id,className:"cursor-pointer",children:q.option_text})]},q.id)})}),i.jsx(Lt,{size:"sm",onClick:()=>A(I.id),disabled:D,children:D?"Submitting...":M?"Update Response":"Submit"})]},I.id)})]})}),i.jsxs("div",{className:"p-4 pb-[calc(1rem+env(safe-area-inset-bottom))] border-t bg-muted/30 flex flex-col items-center gap-2 sticky bottom-0 z-10",children:[i.jsx(Lt,{onClick:r,className:"w-full max-w-xs",children:"Got it!"}),i.jsx(Lt,{variant:"ghost",size:"sm",onClick:n,children:"Don't show again"})]})]})})},CJe=()=>{const{user:t}=Zn(),[e,r]=N.useState(null),[n,s]=N.useState(!1),[o,c]=N.useState(!0),[a,f]=N.useState(!1),m=N.useCallback(async()=>{if(!t){c(!1);return}try{const{data:A,error:C}=await Ce.from("levelup_briefs").select("*").eq("is_published",!0).lte("publish_date",new Date().toISOString()).order("publish_date",{ascending:!1}).limit(1).single();if(C||!A){c(!1);return}const{data:I}=await Ce.from("levelup_brief_views").select("*").eq("brief_id",A.id).eq("user_id",t.id).maybeSingle(),[M,D]=await Promise.all([Ce.from("levelup_brief_links").select("*").eq("brief_id",A.id).order("sort_order"),Ce.from("levelup_brief_polls").select("*").eq("brief_id",A.id).order("sort_order")]),B=[];if(D.data)for(const Q of D.data){const{data:J}=await Ce.from("levelup_brief_poll_options").select("*").eq("poll_id",Q.id).order("sort_order");B.push({...Q,options:J||[]})}const U={brief:A,links:M.data||[],polls:B};r(U);const q=!!I,H=(I==null?void 0:I.dismissed_at)!=null,K=localStorage.getItem(`brief-dismissed-${A.id}`)==="true";if(H||K)f(!1),s(!1);else if(!q)s(!0),f(!0);else if(A.show_frequency==="every_login")s(!0),f(!0);else if(A.show_frequency==="daily"){const Q=new Date(I.viewed_at);(new Date().getTime()-Q.getTime())/(1e3*60*60)>=24&&(s(!0),f(!0))}else f(!1)}catch(A){console.error("Error fetching brief:",A)}finally{c(!1)}},[t]);N.useEffect(()=>{m()},[m]);const y=async()=>{if(!(!t||!e))try{const{data:A}=await Ce.from("levelup_brief_views").select("id").eq("brief_id",e.brief.id).eq("user_id",t.id).maybeSingle();A?await Ce.from("levelup_brief_views").update({viewed_at:new Date().toISOString()}).eq("id",A.id):await Ce.from("levelup_brief_views").insert({brief_id:e.brief.id,user_id:t.id})}catch(A){console.error("Error marking brief as viewed:",A)}};return{currentBrief:e,shouldShowPopup:n,hasUnseenBrief:a,loading:o,openBrief:()=>{s(!0)},closeBrief:()=>{s(!1),y()},dismissBrief:async()=>{if(!(!t||!e)){s(!1),f(!1);try{const{data:A,error:C}=await Ce.from("levelup_brief_views").select("id").eq("brief_id",e.brief.id).eq("user_id",t.id).maybeSingle();if(C&&console.error("Error checking existing brief view:",C),A){const{error:I}=await Ce.from("levelup_brief_views").update({dismissed_at:new Date().toISOString()}).eq("id",A.id).eq("user_id",t.id);I&&console.error("Error updating brief dismiss:",I)}else{const{error:I}=await Ce.from("levelup_brief_views").insert({brief_id:e.brief.id,user_id:t.id,dismissed_at:new Date().toISOString()});I&&console.error("Error inserting brief dismiss:",I)}localStorage.setItem(`brief-dismissed-${e.brief.id}`,"true")}catch(A){console.error("Error dismissing brief:",A),e&&localStorage.setItem(`brief-dismissed-${e.brief.id}`,"true")}}},refetch:m}};function IJe(){const[t,e]=N.useState(!1),[r,n]=N.useState(!1),[s,o]=N.useState(null);N.useEffect(()=>{const f=localStorage.getItem("install-banner-dismissed"),m=localStorage.getItem("install-banner-shown");if(f||m)return;if(window.matchMedia("(display-mode: standalone)").matches||window.matchMedia("(display-mode: fullscreen)").matches||window.matchMedia("(display-mode: minimal-ui)").matches||window.navigator.standalone===!0||document.referrer.startsWith("android-app://")){localStorage.setItem("install-banner-dismissed","true");return}if(!/iPhone|iPad|iPod|Android/i.test(navigator.userAgent))return;const w=/iPhone|iPad|iPod/i.test(navigator.userAgent);n(w),e(!0),localStorage.setItem("install-banner-shown","true");const E=A=>{A.preventDefault(),o(A)};return window.addEventListener("beforeinstallprompt",E),()=>{window.removeEventListener("beforeinstallprompt",E)}},[]);const c=()=>{localStorage.setItem("install-banner-dismissed","true"),localStorage.setItem("install-banner-shown","true"),e(!1)},a=async()=>{if(s){await s.prompt();const{outcome:f}=await s.userChoice;f==="accepted"&&c(),o(null)}};return t?i.jsx("div",{className:"fixed bottom-0 left-0 right-0 z-50 p-4 bg-primary text-primary-foreground shadow-lg animate-in slide-in-from-bottom duration-300",children:i.jsxs("div",{className:"flex items-center justify-between gap-3",children:[i.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[i.jsx("div",{className:"flex-shrink-0 p-2 bg-primary-foreground/10 rounded-full",children:i.jsx(mc,{className:"h-5 w-5"})}),i.jsxs("div",{className:"min-w-0",children:[i.jsx("p",{className:"font-medium text-sm",children:"Add LevelUp to your home screen"}),r?i.jsxs("p",{className:"text-xs opacity-80 flex items-center gap-1",children:["Tap ",i.jsx(L4e,{className:"h-3 w-3 inline"}),' then "Add to Home Screen"']}):i.jsx("p",{className:"text-xs opacity-80",children:"Quick access anytime"})]})]}),i.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[!r&&s&&i.jsx(Lt,{size:"sm",variant:"secondary",onClick:a,className:"text-xs",children:"Install"}),i.jsx(Lt,{size:"sm",variant:"secondary",onClick:c,className:"text-xs",children:"Got it"}),i.jsx("button",{onClick:c,className:"p-1.5 hover:bg-primary-foreground/10 rounded-full transition-colors","aria-label":"Dismiss",children:i.jsx(Ci,{className:"h-4 w-4"})})]})]})}):null}const PJe=({children:t,onRefresh:e})=>{const[r,n]=N.useState(!1),[s,o]=N.useState(0),[c,a]=N.useState(!1),f=N.useRef(null),m=N.useRef(0),y=jr(),_=80,w=120,E=N.useCallback(D=>{const B=f.current;B&&B.scrollTop<=0&&(m.current=D.touches[0].clientY,n(!0))},[]),A=N.useCallback(D=>{if(!r||c)return;const B=f.current;if(!B||B.scrollTop>0){n(!1),o(0);return}const q=D.touches[0].clientY-m.current;if(q>0){const K=Math.min(q*.5,w);o(K),K>10&&D.preventDefault()}},[r,c]),C=N.useCallback(async()=>{if(r)if(n(!1),s>=_&&!c){a(!0),o(_);try{e?await e():await y.invalidateQueries()}catch(D){console.error("Refresh failed:",D)}finally{a(!1),o(0)}}else o(0)},[r,s,c,e,y]),I=Math.min(s/_,1),M=I*180;return i.jsxs("div",{ref:f,className:"h-full overflow-auto",onTouchStart:E,onTouchMove:A,onTouchEnd:C,children:[i.jsx("div",{className:"flex justify-center items-center overflow-hidden transition-all duration-200 ease-out",style:{height:s>0?s:0,opacity:I},children:i.jsx("div",{className:`p-2 rounded-full bg-primary/10 ${c?"animate-spin":""}`,style:{transform:c?void 0:`rotate(${M}deg)`,transition:c?void 0:"transform 0.1s ease-out"},children:i.jsx(oye,{className:"h-5 w-5 text-primary"})})}),i.jsx("div",{style:{transform:s>0?`translateY(${Math.max(0,s-60)}px)`:void 0,transition:r?void 0:"transform 0.2s ease-out"},children:t})]})},RJe=()=>{const{user:t}=Zn(),[e,r]=N.useState(!1),[n,s]=N.useState(!1),[o,c]=N.useState(0),[a,f]=N.useState(!0);N.useEffect(()=>{(async()=>{if(!t){f(!1);return}try{const{data:E}=await Ce.from("membership_reviews").select("id").eq("user_id",t.id).maybeSingle();if(E){s(!0),r(!1),f(!1);return}const{data:A}=await Ce.from("profiles").select("login_count").eq("id",t.id).single(),C=(A==null?void 0:A.login_count)||0;c(C);const I=sessionStorage.getItem("review-prompt-dismissed");r(C>=4&&!I)}catch(E){console.error("Error checking review eligibility:",E)}finally{f(!1)}})()},[t]);const m=N.useCallback(()=>{sessionStorage.setItem("review-prompt-dismissed","true"),r(!1)},[]),y=N.useCallback(async(w,E)=>{if(!t)return{success:!1,error:"Not authenticated"};try{const{error:A}=await Ce.from("membership_reviews").insert({user_id:t.id,rating:w,review_text:E});if(A)throw A;return s(!0),r(!1),{success:!0,pointsAwarded:25}}catch(A){return console.error("Error submitting review:",A),{success:!1,error:A.message}}},[t]),_=N.useCallback(async()=>{if(t)try{await Ce.from("membership_reviews").update({posted_to_google:!0}).eq("user_id",t.id)}catch(w){console.error("Error updating Google review status:",w)}},[t]);return{shouldShowPrompt:e,hasSubmittedReview:n,loginCount:o,isLoading:a,dismissPrompt:m,submitReview:y,markPostedToGoogle:_}},LJe="https://search.google.com/local/writereview?placeid=ChIJM73ERQD1QogRPxupMFObuck&source=g.page.m.ia._&laa=nmx-review-solicitation-ia2",MJe=()=>{const{shouldShowPrompt:t,isLoading:e,dismissPrompt:r,submitReview:n,markPostedToGoogle:s}=RJe(),[o,c]=N.useState(!1),[a,f]=N.useState("review"),[m,y]=N.useState(0),[_,w]=N.useState(0),[E,A]=N.useState(""),[C,I]=N.useState(!1),[M,D]=N.useState(!1);if(e||!t&&!M)return null;const B=async()=>{if(m===0){Fi({title:"Please select a rating",variant:"destructive"});return}I(!0);const H=await n(m,E);I(!1),H.success?(D(!0),Fi({title:"Thank you for your feedback!",description:"Your review helps us improve."}),f("google")):Fi({title:"Error submitting review",description:H.error,variant:"destructive"})},U=async H=>{H&&(await navigator.clipboard.writeText(E||`${m} star rating for LevelUp!`),Fi({title:"Review copied!",description:"Paste it on Google Reviews."}),await s(),window.open(LJe,"_blank")),c(!1),r()},q=()=>{c(!1),r()};return i.jsxs(i.Fragment,{children:[i.jsxs("button",{onClick:()=>c(!0),className:"fixed bottom-20 left-1/2 -translate-x-1/2 z-40 flex items-center gap-2 rounded-full bg-primary/90 px-3 py-2 text-xs text-primary-foreground shadow-lg backdrop-blur-sm transition-all hover:bg-primary hover:scale-105 md:bottom-6",children:[i.jsx(gc,{className:"h-3.5 w-3.5 fill-current"}),i.jsx("span",{className:"hidden sm:inline",children:"Leave a Review"})]}),i.jsx(Ha,{open:o,onOpenChange:q,children:i.jsx(Ra,{className:"sm:max-w-md",children:a==="review"?i.jsxs(i.Fragment,{children:[i.jsxs(Ho,{children:[i.jsx(Co,{className:"text-center",children:"How are you enjoying LevelUp?"}),i.jsx(td,{className:"text-center",children:"Your feedback helps us improve the experience for all members."})]}),i.jsxs("div",{className:"space-y-6 py-4",children:[i.jsx("div",{className:"flex justify-center gap-1",children:[1,2,3,4,5].map(H=>i.jsx("button",{type:"button",onClick:()=>y(H),onMouseEnter:()=>w(H),onMouseLeave:()=>w(0),className:"p-1 transition-transform hover:scale-110",children:i.jsx(gc,{className:Xt("h-8 w-8 transition-colors",(_||m)>=H?"fill-yellow-400 text-yellow-400":"text-muted-foreground")})},H))}),i.jsx(zc,{placeholder:"Tell us about your experience (optional)",value:E,onChange:H=>A(H.target.value),rows:4,className:"resize-none"}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(Lt,{variant:"outline",onClick:q,className:"flex-1",children:"Maybe Later"}),i.jsx(Lt,{onClick:B,disabled:C||m===0,className:"flex-1",children:C?"Submitting...":"Submit Review"})]})]})]}):i.jsxs(i.Fragment,{children:[i.jsxs(Ho,{children:[i.jsx(Co,{className:"text-center",children:"🎉 Thank you!"}),i.jsx(td,{className:"text-center",children:"Would you mind sharing your review on Google? It really helps other agents discover LevelUp!"})]}),i.jsxs("div",{className:"space-y-4 py-4",children:[i.jsx("p",{className:"text-center text-sm text-muted-foreground",children:"We'll copy your review so you can easily paste it."}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(Lt,{variant:"outline",onClick:()=>U(!1),className:"flex-1",children:"No Thanks"}),i.jsx(Lt,{onClick:()=>U(!0),className:"flex-1",children:"Yes, Open Google"})]})]})]})})})]})};function DJe(t){const e="=".repeat((4-t.length%4)%4),r=(t+e).replace(/-/g,"+").replace(/_/g,"/"),n=window.atob(r),s=new Uint8Array(n.length);for(let o=0;o{if(!_){c(!1);return}(async()=>{try{const C="vapid_public_key";let I=localStorage.getItem(C);if(!I){const{data:B,error:U}=await Ce.functions.invoke("get-vapid-public-key",{body:{}});if(U)throw U;if(I=(B==null?void 0:B.vapidPublicKey)??null,!I)throw new Error("Missing VAPID public key");localStorage.setItem(C,I)}y(I);const M=await navigator.serviceWorker.register("/push-sw.js",{scope:"/push-notifications/"});f(M),r(Notification.permission);const D=await M.pushManager.getSubscription();s(!!D)}catch(C){console.error("Error initializing push notifications:",C)}finally{c(!1)}})()},[_]);const w=N.useCallback(async()=>{if(!_||!a||!t)return console.error("Push notifications not supported or user not logged in"),!1;if(!m)return $t.error("Push notifications are not ready yet. Please try again in a moment."),!1;try{c(!0);const A=await a.pushManager.getSubscription();if(A){try{await A.unsubscribe()}catch(U){console.warn("Failed to unsubscribe existing push subscription:",U)}const{error:B}=await Ce.from("push_subscriptions").delete().eq("user_id",t.id);B&&console.warn("Failed to cleanup push_subscriptions rows:",B)}if(Notification.permission!=="granted"){const B=await Notification.requestPermission();if(r(B),B!=="granted")return B==="denied"?$t.error("Notifications blocked. Please enable them in your browser settings (click the lock icon in the address bar)."):$t.error("Notification permission was dismissed. Please try again."),!1}const C=DJe(m);let I;try{I=await a.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:C})}catch(B){console.error("PushManager.subscribe() failed:",B);const U=(B==null?void 0:B.message)||String(B);return U.includes("permission")?$t.error("Push permission denied. Check your browser notification settings."):U.includes("key")||U.includes("VAPID")?$t.error("Push configuration error. Please contact support."):U.includes("AbortError")?$t.error("Push subscription was cancelled. Please try again."):$t.error(`Failed to subscribe: ${U}`),!1}const M=I.toJSON(),{error:D}=await Ce.from("push_subscriptions").upsert({user_id:t.id,endpoint:M.endpoint,p256dh_key:M.keys.p256dh,auth_key:M.keys.auth},{onConflict:"user_id,endpoint"});if(D)throw console.error("Error saving subscription:",D),$t.error("Failed to save notification preferences. Please try again."),D;return s(!0),$t.success("Push notifications enabled!"),!0}catch(A){if(console.error("Error subscribing to push notifications:",A),!(A instanceof Error&&A.message.includes("toast"))){const C=A instanceof Error?A.message:"Unknown error";$t.error("Failed to enable push notifications: "+C)}return!1}finally{c(!1)}},[_,a,t,m]),E=N.useCallback(async()=>{if(!a||!t)return!1;try{c(!0);const A=await a.pushManager.getSubscription();return A&&await A.unsubscribe(),await Ce.from("push_subscriptions").delete().eq("user_id",t.id),s(!1),$t.success("Push notifications disabled"),!0}catch(A){console.error("Error unsubscribing:",A);const C=A instanceof Error?A.message:"Unknown error";return $t.error("Failed to disable push notifications: "+C),!1}finally{c(!1)}},[a,t]);return{isSupported:_,permission:e,isSubscribed:n,isLoading:o,vapidPublicKey:m,subscribe:w,unsubscribe:E}}const p6="push_notification_prompt_dismissed",FJe=["/dashboard","/admin","/listings"],BJe=()=>{const{user:t}=Zn(),{isSupported:e,isSubscribed:r,isLoading:n,subscribe:s}=OJe(),o=js(),[c,a]=N.useState(!1),[f,m]=N.useState(!1),y=FJe.some(E=>o.pathname===E||o.pathname.startsWith(`${E}/`));N.useEffect(()=>{if(y){a(!1);return}if(!t||!e||r||n||localStorage.getItem(`${p6}_${t.id}`))return;const A=setTimeout(()=>{a(!0)},2e3);return()=>clearTimeout(A)},[t,e,r,n,y]);const _=async()=>{m(!0);const E=await s();m(!1),E&&(t&&localStorage.setItem(`${p6}_${t.id}`,"true"),a(!1))},w=()=>{t&&localStorage.setItem(`${p6}_${t.id}`,"true"),a(!1)};return!e||r||y?null:i.jsx(Ha,{open:c,onOpenChange:E=>!E&&w(),children:i.jsxs(Ra,{className:"sm:max-w-md",children:[i.jsxs(Ho,{children:[i.jsx("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-primary/10",children:i.jsx(gC,{className:"h-6 w-6 text-primary"})}),i.jsx(Co,{className:"text-center",children:"Stay in the Loop!"}),i.jsx(td,{className:"text-center",children:"Enable push notifications to get alerted when:"})]}),i.jsxs("ul",{className:"my-4 space-y-2 text-sm text-muted-foreground",children:[i.jsxs("li",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-primary",children:"•"})," New events go live"]}),i.jsxs("li",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-primary",children:"•"})," Fresh templates are added"]}),i.jsxs("li",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-primary",children:"•"})," New toolbox resources drop"]}),i.jsxs("li",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-primary",children:"•"})," Social swag updates"]}),i.jsxs("li",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-primary",children:"•"})," New newsletters arrive"]}),i.jsxs("li",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-primary",children:"•"})," Posts in your community groups"]})]}),i.jsxs("div",{className:"flex flex-col gap-2",children:[i.jsx(Lt,{onClick:_,disabled:f,className:"w-full",children:f?"Enabling...":"Enable Notifications"}),i.jsx(Lt,{variant:"ghost",onClick:w,className:"w-full",children:"Not Now"})]}),i.jsx("p",{className:"text-center text-xs text-muted-foreground",children:"You can always change this in your Profile settings."})]})})},rie=t=>{let e;const r=new Set,n=(m,y)=>{const _=typeof m=="function"?m(e):m;if(!Object.is(_,e)){const w=e;e=y??(typeof _!="object"||_===null)?_:Object.assign({},e,_),r.forEach(E=>E(e,w))}},s=()=>e,a={setState:n,getState:s,getInitialState:()=>f,subscribe:m=>(r.add(m),()=>r.delete(m))},f=e=t(n,s,a);return a},$Je=t=>t?rie(t):rie,zJe=t=>t;function UJe(t,e=zJe){const r=Qe.useSyncExternalStore(t.subscribe,Qe.useCallback(()=>e(t.getState()),[t,e]),Qe.useCallback(()=>e(t.getInitialState()),[t,e]));return Qe.useDebugValue(r),r}const nie=t=>{const e=$Je(t),r=n=>UJe(e,n);return Object.assign(r,e),r},VJe=t=>t?nie(t):nie;function qJe(t,e){let r;try{r=t()}catch{return}return{getItem:s=>{var o;const c=f=>f===null?null:JSON.parse(f,void 0),a=(o=r.getItem(s))!=null?o:null;return a instanceof Promise?a.then(c):c(a)},setItem:(s,o)=>r.setItem(s,JSON.stringify(o,void 0)),removeItem:s=>r.removeItem(s)}}const jq=t=>e=>{try{const r=t(e);return r instanceof Promise?r:{then(n){return jq(n)(r)},catch(n){return this}}}catch(r){return{then(n){return this},catch(n){return jq(n)(r)}}}},GJe=(t,e)=>(r,n,s)=>{let o={storage:qJe(()=>window.localStorage),partialize:I=>I,version:0,merge:(I,M)=>({...M,...I}),...e},c=!1,a=0;const f=new Set,m=new Set;let y=o.storage;if(!y)return t((...I)=>{console.warn(`[zustand persist middleware] Unable to update item '${o.name}', the given storage is currently unavailable.`),r(...I)},n,s);const _=()=>{const I=o.partialize({...n()});return y.setItem(o.name,{state:I,version:o.version})},w=s.setState;s.setState=(I,M)=>(w(I,M),_());const E=t((...I)=>(r(...I),_()),n,s);s.getInitialState=()=>E;let A;const C=()=>{var I,M;if(!y)return;const D=++a;c=!1,f.forEach(U=>{var q;return U((q=n())!=null?q:E)});const B=((M=o.onRehydrateStorage)==null?void 0:M.call(o,(I=n())!=null?I:E))||void 0;return jq(y.getItem.bind(y))(o.name).then(U=>{if(U)if(typeof U.version=="number"&&U.version!==o.version){if(o.migrate){const q=o.migrate(U.state,U.version);return q instanceof Promise?q.then(H=>[!0,H]):[!0,q]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,U.state];return[!1,void 0]}).then(U=>{var q;if(D!==a)return;const[H,K]=U;if(A=o.merge(K,(q=n())!=null?q:E),r(A,!0),H)return _()}).then(()=>{D===a&&(B==null||B(n(),void 0),A=n(),c=!0,m.forEach(U=>U(A)))}).catch(U=>{D===a&&(B==null||B(void 0,U))})};return s.persist={setOptions:I=>{o={...o,...I},I.storage&&(y=I.storage)},clearStorage:()=>{y==null||y.removeItem(o.name)},getOptions:()=>o,rehydrate:()=>C(),hasHydrated:()=>c,onHydrate:I=>(f.add(I),()=>{f.delete(I)}),onFinishHydration:I=>(m.add(I),()=>{m.delete(I)})},o.skipHydration||C(),A||E},HJe=GJe,t1e=VJe()(HJe((t,e)=>({cartItems:[],addToCart:(r,n,s=1,o)=>{t(c=>{const a=c.cartItems.findIndex(f=>{var m;return f.product.id===r.id&&((m=f.variant)==null?void 0:m.id)===(n==null?void 0:n.id)});if(a>=0){const f=[...c.cartItems];return f[a].quantity+=s,o&&(f[a].artworkUrl=o),{cartItems:f}}return{cartItems:[...c.cartItems,{product:r,variant:n,quantity:s,artworkUrl:o}]}})},removeFromCart:(r,n)=>{t(s=>({cartItems:s.cartItems.filter(o=>{var c;return!(o.product.id===r&&((c=o.variant)==null?void 0:c.id)===n)})}))},updateQuantity:(r,n,s)=>{t(o=>({cartItems:o.cartItems.map(c=>{var a;return c.product.id===r&&((a=c.variant)==null?void 0:a.id)===n?{...c,quantity:Math.max(1,s)}:c})}))},updateArtwork:(r,n,s)=>{t(o=>({cartItems:o.cartItems.map(c=>{var a;return c.product.id===r&&((a=c.variant)==null?void 0:a.id)===n?{...c,artworkUrl:s}:c})}))},clearCart:()=>t({cartItems:[]}),getItemPrice:r=>{const n=Number(r.product.base_price),s=r.variant?Number(r.variant.price_adjustment):0;return n+s},getSubtotal:()=>{const{cartItems:r,getItemPrice:n}=e();return r.reduce((s,o)=>s+n(o)*o.quantity,0)},getShippingTotal:()=>{const{cartItems:r}=e();return r.reduce((n,s)=>n+Number(s.product.shipping_fee)*s.quantity,0)},getTotal:()=>{const{getSubtotal:r,getShippingTotal:n}=e();return r()+n()}}),{name:"marketplace-cart",partialize:t=>({cartItems:t.cartItems})})),WJe="/admin/beta/boost",KJe=N.lazy(()=>Oe(()=>import("./BoostCompanion-BzaH1vXM.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10])));function YJe(){const{user:t,isAdmin:e}=Zn(),{isFeatureEnabled:r}=O4(),{pathname:n}=js(),s=n==="/main-stage"||n.startsWith("/main-stage/");return!(!!t&&(e||r("boost_mascot"))&&n!==WJe&&!s)||!t?null:i.jsx(N.Suspense,{fallback:null,children:i.jsx(KJe,{userId:t.id})})}async function ZJe(t){const{data:e,error:r}=await Ce.rpc("main_stage_list_events",t?{_event_id:t}:{});if(r)throw r;return(e||[]).map(n=>({...n,speakers:Array.isArray(n.speakers)?n.speakers:[],registered_count:Number(n.registered_count)}))}async function AJt(t){const{data:e,error:r}=await Ce.functions.invoke("main-stage-events",{body:t});if(e!=null&&e.error)throw new Error(e.error);if(r)throw new Error(r.message);return e}const r1e="America/New_York",NJt=t=>new Intl.DateTimeFormat("en-US",{timeZone:r1e,weekday:"short",month:"short",day:"numeric"}).format(new Date(t)),CJt=t=>new Intl.DateTimeFormat("en-US",{timeZone:r1e,hour:"numeric",minute:"2-digit",timeZoneName:"short"}).format(new Date(t)),IJt=t=>t.trim().toUpperCase().replace(/\s+/g,"");function PJt(t,e="https://dashboard.relevelup.com"){const r=a=>a.toISOString().replace(/[-:]/g,"").replace(/\.\d{3}/,""),n=new Date(t.starts_at),s=new Date(n.getTime()+t.duration_min*6e4),o=`${e}/main-stage?event=${t.id}`;return`https://calendar.google.com/calendar/render?${new URLSearchParams({action:"TEMPLATE",text:`The Main Stage: ${t.title}`,dates:`${r(n)}/${r(s)}`,details:`Join here: ${o}`,location:o})}`}function RJt(t,e="https://dashboard.relevelup.com"){const r=a=>a.toISOString().replace(/[-:]/g,"").replace(/\.\d{3}/,""),n=new Date(t.starts_at),s=new Date(n.getTime()+t.duration_min*6e4),o=`${e}/main-stage?event=${t.id}`,c=["BEGIN:VCALENDAR","VERSION:2.0","PRODID:-//LevelUp//Main Stage//EN","BEGIN:VEVENT",`UID:main-stage-${t.id}@relevelup.com`,`DTSTAMP:${r(new Date)}`,`DTSTART:${r(n)}`,`DTEND:${r(s)}`,`SUMMARY:The Main Stage: ${t.title.replace(/[,;]/g," ")}`,`URL:${o}`,`LOCATION:${o}`,"END:VEVENT","END:VCALENDAR"].join(`\r `);return URL.createObjectURL(new Blob([c],{type:"text/calendar"}))}const LJt=t=>{const e=Math.floor(t/1e3);return{d:Math.floor(e/86400),h:Math.floor(e%86400/3600),m:Math.floor(e%3600/60),s:e%60}};function n1e(){const{data:t}=mr({queryKey:["main-stage-live-nav"],queryFn:async()=>(await ZJe()).some(e=>e.status==="live"),refetchInterval:6e4,staleTime:3e4});return!!t}function XJe({activeCategory:t,currentCategory:e,onSelect:r,onHover:n,badgeCounts:s,categories:o=Q4}){const c=n1e();return i.jsx("nav",{"aria-label":"Primary",className:"flex flex-col gap-1 p-2",children:o.map(a=>{const f=a.icon,m=t===a.id,y=e===a.id,_=(s==null?void 0:s[a.id])??0,w=`hsl(var(--${a.accent}))`,E=m||y;return i.jsxs("button",{type:"button",onClick:()=>r(a.id),onMouseEnter:()=>n==null?void 0:n(a.id),"aria-expanded":a.route?void 0:m,"aria-controls":a.route?void 0:"primary-nav-flyout","aria-current":y?"page":void 0,style:{color:E?w:void 0,backgroundColor:E?`hsl(var(--${a.accent}) / 0.12)`:void 0},className:Xt("group relative flex flex-col items-center gap-1 rounded-xl px-1 py-2.5 text-[11px] font-medium transition-colors","text-sidebar-foreground/70 hover:bg-sidebar-accent/10","focus:outline-none focus-visible:ring-2 focus-visible:ring-primary"),children:[y&&i.jsx("span",{className:"absolute left-0 top-1/2 h-6 w-1 -translate-y-1/2 rounded-r",style:{backgroundColor:w}}),i.jsxs("span",{className:"relative",children:[i.jsx(f,{className:"h-5 w-5 transition-colors",style:{color:w}}),a.id==="mainstage"&&c&&i.jsxs("span",{className:"absolute -right-1 -top-1 flex h-3 w-3",children:[i.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-destructive opacity-75"}),i.jsx("span",{className:"relative inline-flex h-3 w-3 rounded-full bg-destructive"})]}),_>0&&i.jsx("span",{className:"absolute -right-1.5 -top-1 flex h-4 min-w-4 items-center justify-center rounded-full px-1 text-[9px] font-bold text-primary-foreground",style:{backgroundColor:w},children:_>9?"9+":_})]}),a.id==="mainstage"&&c?i.jsx("span",{className:"rounded bg-destructive px-1 text-[9px] font-bold uppercase tracking-wider leading-tight text-destructive-foreground",children:"Live"}):i.jsx("span",{className:"leading-tight",children:a.label})]},a.id)})})}function QJe({category:t,top:e,left:r,onClose:n,onNavigate:s,isFavorite:o,favorites:c,onToggleFavorite:a,isCurrent:f,badgeCounts:m}){const y=N.useRef(null);N.useEffect(()=>{const w=A=>{A.key==="Escape"&&n()},E=A=>{var I;if(!y.current)return;const C=A.target;!y.current.contains(C)&&!((I=C==null?void 0:C.closest)!=null&&I.call(C,"[data-nav-rail]"))&&n()};return document.addEventListener("keydown",w),document.addEventListener("mousedown",E),()=>{document.removeEventListener("keydown",w),document.removeEventListener("mousedown",E)}},[n]);const _=w=>{const E=w.icon,A=w.badgeKey?(m==null?void 0:m[w.badgeKey])??0:0;return i.jsxs("div",{className:Xt("group flex items-start gap-3 rounded-lg border border-transparent p-2 transition-colors hover:bg-muted/60",f(w)&&"border-primary/30 bg-primary/5"),children:[i.jsxs("button",{type:"button",onClick:()=>s(w),className:"flex flex-1 items-start gap-3 text-left focus:outline-none focus-visible:ring-2 focus-visible:ring-primary rounded-md",children:[i.jsx("span",{className:Xt("mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-lg",w.iconTone==="red"?"bg-destructive/10 text-destructive":"bg-primary/10 text-primary"),children:i.jsx(E,{className:Xt("h-4 w-4",w.iconTone==="red"&&"fill-destructive/20")})}),i.jsxs("span",{className:"min-w-0",children:[i.jsxs("span",{className:"flex items-center gap-1.5",children:[i.jsx("span",{className:"text-sm font-medium text-foreground",children:w.label}),w.badge==="new"&&i.jsx("span",{className:"rounded bg-primary px-1 py-px text-[9px] font-bold uppercase tracking-wide text-primary-foreground",children:"New"}),w.badge==="beta"&&i.jsx("span",{className:"rounded border border-amber-500 bg-amber-500/10 px-1 py-px text-[9px] font-bold uppercase tracking-wide text-amber-600 dark:text-amber-400",children:"Beta"}),w.locked&&i.jsx(zx,{className:"h-3 w-3 text-muted-foreground","aria-label":"Upgrade required"}),A>0&&i.jsx("span",{className:"flex h-4 min-w-4 items-center justify-center rounded-full bg-muted-foreground/15 px-1 text-[10px] font-medium text-muted-foreground",children:A>9?"9+":A})]}),w.description&&i.jsx("span",{className:"mt-0.5 block text-xs leading-snug text-muted-foreground line-clamp-2",children:w.description})]})]}),i.jsx("button",{type:"button","aria-label":o(w)?`Remove ${w.label} from favorites`:`Add ${w.label} to favorites`,onClick:C=>{C.stopPropagation(),a(w)},className:Xt("mt-1 rounded p-1 opacity-0 transition-opacity focus:outline-none focus-visible:ring-2 focus-visible:ring-primary group-hover:opacity-100",o(w)&&"opacity-100 text-primary",!o(w)&&"text-muted-foreground/60 hover:text-primary"),children:i.jsx(CD,{className:Xt("h-4 w-4",o(w)&&"fill-current")})})]},w.id)};return i.jsxs("div",{id:"primary-nav-flyout",ref:y,role:"dialog","aria-label":`${t.label} navigation`,style:{top:e,left:r,maxHeight:`calc(100vh - ${e+16}px)`},className:"fixed z-40 hidden w-[min(720px,calc(100vw-8rem))] animate-in fade-in-0 slide-in-from-left-2 duration-200 motion-reduce:animate-none overflow-hidden rounded-2xl border border-border bg-card shadow-2xl md:block",children:[i.jsx("div",{className:"flex items-center justify-between border-b border-border px-5 py-3",children:i.jsx("h2",{className:"text-sm font-semibold text-foreground",children:t.label})}),i.jsxs("div",{className:"max-h-[70vh] overflow-y-auto p-4",children:[c.length>0&&i.jsxs("section",{className:"mb-4",children:[i.jsxs("h3",{className:"mb-2 flex items-center gap-1.5 px-2 text-[11px] font-semibold uppercase tracking-wider text-muted-foreground",children:[i.jsx(CD,{className:"h-3 w-3 fill-current text-primary"})," My Favorites"]}),i.jsx("div",{className:"grid grid-cols-1 gap-1 sm:grid-cols-2",children:c.map(_)})]}),t.sections.map(w=>i.jsxs("section",{className:"mb-4 last:mb-0",children:[i.jsx("h3",{className:"mb-2 px-2 text-[11px] font-semibold uppercase tracking-wider text-muted-foreground",children:w.title}),i.jsx("div",{className:"grid grid-cols-1 gap-1 sm:grid-cols-2",children:w.items.map(_)})]},w.title)),t.sections.length===0&&i.jsx("p",{className:"px-2 py-6 text-sm text-muted-foreground",children:"Nothing here yet."})]})]})}function JJe({categories:t,railCategories:e=Q4,currentCategory:r,onNavigate:n,onNavigateRoute:s,isCurrent:o,badgeCounts:c,isFavorite:a,onToggleFavorite:f}){const[m,y]=N.useState(r),_=n1e();return i.jsx("nav",{"aria-label":"Primary",className:"p-2",children:e.map(w=>{const E=w.icon;if(w.route)return i.jsxs("button",{type:"button",onClick:()=>s(w.route),className:Xt("flex w-full items-center gap-3 rounded-lg px-3 py-3 text-sm font-medium text-sidebar-foreground hover:bg-sidebar-accent",r===w.id&&"bg-sidebar-accent"),children:[i.jsx(E,{className:"h-4 w-4",style:{color:`hsl(var(--${w.accent}))`}}),w.label,w.id==="mainstage"&&_&&i.jsxs("span",{className:"ml-auto flex items-center gap-1 rounded-full bg-destructive px-2 py-0.5 text-[10px] font-bold uppercase text-destructive-foreground",children:[i.jsx("span",{className:"h-1.5 w-1.5 animate-pulse rounded-full bg-destructive-foreground"}),"Live"]})]},w.id);const A=t.find(I=>I.id===w.id),C=m===w.id;return i.jsxs("div",{children:[i.jsxs("button",{type:"button","aria-expanded":C,onClick:()=>y(C?null:w.id),className:Xt("flex w-full items-center gap-3 rounded-lg px-3 py-3 text-sm font-medium text-sidebar-foreground hover:bg-sidebar-accent",r===w.id&&"text-primary"),children:[i.jsx(E,{className:"h-4 w-4",style:{color:`hsl(var(--${w.accent}))`}}),w.label,i.jsx(Go,{className:Xt("ml-auto h-4 w-4 transition-transform",C&&"rotate-180")})]}),C&&A&&i.jsx("div",{className:"space-y-3 pb-3 pl-4 pr-1",children:A.sections.map(I=>i.jsxs("div",{children:[i.jsx("p",{className:"px-2 py-1 text-[11px] font-semibold uppercase tracking-wider text-muted-foreground",children:I.title}),I.items.map(M=>{const D=M.icon,B=M.badgeKey?(c==null?void 0:c[M.badgeKey])??0:0,U=(a==null?void 0:a(M))??!1;return i.jsxs("div",{className:Xt("flex w-full items-center gap-2 rounded-md pr-1 hover:bg-sidebar-accent",o(M)&&"bg-sidebar-accent"),children:[i.jsxs("button",{type:"button",onClick:()=>n(M),className:"flex flex-1 items-center gap-2 px-2 py-2 text-left text-sm text-sidebar-foreground",children:[i.jsx(D,{className:Xt("h-4 w-4 shrink-0",M.iconTone==="red"&&"text-destructive")}),i.jsx("span",{className:"truncate",children:M.label}),B>0&&i.jsx("span",{className:"ml-auto flex h-5 w-5 items-center justify-center rounded-full bg-muted text-xs text-muted-foreground",children:B>9?"9+":B})]}),f&&i.jsx("button",{type:"button","aria-label":U?`Remove ${M.label} from favorites`:`Add ${M.label} to favorites`,onClick:()=>f(M),className:Xt("rounded p-2",U?"text-primary":"text-muted-foreground/60"),children:i.jsx(CD,{className:Xt("h-4 w-4",U&&"fill-current")})})]},M.id)})]},I.title))})]},w.id)})})}function s1e(){const t=ra(),e=js(),r=Swe(),n=N.useCallback(a=>bwe(a,r.ctx),[r.ctx]),s=N.useMemo(()=>{if(e.pathname.startsWith("/apps"))return"apps";if(e.pathname==="/dashboard")return"home";let a=null;for(const f of r.destinations){if(f.external)continue;const m=n(f);m!=="/"&&e.pathname.startsWith(m)&&(!a||m.length>a.len)&&(a={id:f.primaryCategory,len:m.length})}return(a==null?void 0:a.id)??null},[e.pathname,r.destinations,n]),o=N.useCallback(a=>!a.external&&e.pathname===n(a),[e.pathname,n]),c=N.useCallback(a=>{const f=n(a);if(a.external||a.openInNewTab){window.open(f,"_blank","noopener,noreferrer");return}t(f)},[t,n]);return{nav:r,navigate:t,currentCategory:s,isCurrent:o,go:c}}function eet({communityUnreadCount:t=0,wishlistOpenCount:e=0,flyoutTop:r=64,flyoutLeft:n=80}){const{nav:s,navigate:o,currentCategory:c,isCurrent:a,go:f}=s1e(),[m,y]=N.useState(null),_=N.useRef(null),w=C=>{const I=Q4.find(M=>M.id===C);if(I!=null&&I.route){y(null),o(I.route);return}y(M=>M===C?null:C)},E=m?s.categoryMap.get(m):void 0,A={more:t+e};return i.jsxs("div",{"data-nav-rail":!0,className:"flex h-full flex-col",onMouseLeave:()=>{_.current&&window.clearTimeout(_.current),_.current=window.setTimeout(()=>y(null),250)},onMouseEnter:()=>{_.current&&window.clearTimeout(_.current)},children:[i.jsx(XJe,{activeCategory:m,currentCategory:c,onSelect:w,categories:s.railCategories,badgeCounts:A}),E&&i.jsx(QJe,{category:E,top:r,left:n,onClose:()=>y(null),onNavigate:C=>{y(null),f(C)},isFavorite:s.isFavorite,favorites:s.favoritesFor(E.id),onToggleFavorite:C=>s.toggleFavorite(s.favoriteKey(C)),isCurrent:a,badgeCounts:{community:t,wishlist:e}})]})}function tet({communityUnreadCount:t=0,wishlistOpenCount:e=0,onNavigated:r}){const{nav:n,navigate:s,currentCategory:o,isCurrent:c,go:a}=s1e();return i.jsx(JJe,{categories:n.categories,railCategories:n.railCategories,currentCategory:o,isCurrent:c,isFavorite:n.isFavorite,onToggleFavorite:f=>n.toggleFavorite(n.favoriteKey(f)),badgeCounts:{community:t,wishlist:e},onNavigate:f=>{a(f),r==null||r()},onNavigateRoute:f=>{s(f),r==null||r()}})}const ret=({bannerHeight:t,communityUnreadCount:e,wishlistOpenCount:r,isTrial:n,isExpired:s})=>{const o=ra();return i.jsxs("div",{className:"flex h-full flex-col",children:[i.jsx("div",{className:"flex h-16 shrink-0 items-center justify-center border-b border-sidebar-border",children:i.jsx("button",{type:"button",onClick:()=>o("/dashboard"),"aria-label":"LevelUp home",children:i.jsx("img",{src:H9e,alt:"LevelUp",className:"h-8 w-auto"})})}),i.jsxs(cp,{className:"flex-1 [&_[data-radix-scroll-area-scrollbar]]:w-1.5",children:[i.jsx(eet,{communityUnreadCount:e,wishlistOpenCount:r,flyoutTop:t+64,flyoutLeft:80}),n&&!s&&i.jsx("div",{className:"p-2",children:i.jsxs("button",{type:"button",onClick:()=>o("/subscription"),className:"flex w-full flex-col items-center gap-1 rounded-xl border border-amber-500/30 bg-amber-500/10 px-1 py-2 text-[10px] font-semibold text-amber-600 dark:text-amber-400",children:[i.jsx(ki,{className:"h-4 w-4"}),"Upgrade"]})})]})]})},net=({isTrial:t,isExpired:e,expiresAt:r,communityUnreadCount:n,wishlistOpenCount:s,pathname:o,onSignOut:c,onNavigated:a})=>{const f=ra();return i.jsxs("div",{className:"flex h-full flex-col",children:[i.jsx("div",{className:"flex items-center gap-2 border-b border-sidebar-border p-3",children:i.jsx("img",{src:G9e,alt:"LevelUp",className:"h-8 w-auto"})}),i.jsxs(cp,{className:"flex-1",children:[t&&!e&&i.jsx("div",{className:"p-2",children:i.jsx("button",{type:"button",onClick:()=>{f("/subscription"),a==null||a()},className:Xt("relative mb-1 w-full overflow-hidden rounded-md p-[1.5px]","bg-[linear-gradient(120deg,#f59e0b,#ef4444,#a855f7,#f59e0b)] bg-[length:200%_200%]","animate-gradient-x shadow-lg shadow-amber-500/20"),children:i.jsxs("span",{className:"flex items-center gap-2 rounded-[5px] bg-sidebar px-3 py-2 text-sm font-semibold text-sidebar-foreground",children:[i.jsx(ki,{className:"h-4 w-4 text-amber-500"}),i.jsx("span",{className:"flex-1 text-left",children:"Ready to Upgrade?"}),r&&i.jsxs("span",{className:"rounded border border-amber-500/30 bg-amber-500/15 px-1.5 py-0.5 text-[10px] font-bold uppercase tracking-wide text-amber-600 dark:text-amber-400",children:[Math.max(0,Math.ceil((Date.parse(r)-Date.now())/864e5)),"d left"]})]})})}),i.jsx(tet,{communityUnreadCount:n,wishlistOpenCount:s,onNavigated:a})]}),i.jsxs("div",{className:"border-t border-sidebar-border p-3",children:[i.jsxs(Lt,{variant:"ghost",size:"sm",className:Xt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",o==="/profile"&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>{f("/profile"),a==null||a()},children:[i.jsx(Gl,{className:"h-4 w-4"}),"Profile"]}),i.jsxs(Lt,{variant:"ghost",size:"sm",className:Xt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",o==="/credits"&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>{f("/credits"),a==null||a()},children:[i.jsx(c4,{className:"h-4 w-4"}),"Credits & Wallet"]}),i.jsxs(Lt,{variant:"ghost",size:"sm",className:"w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",onClick:c,children:[i.jsx(i4,{className:"h-4 w-4"}),"Sign Out"]})]})]})},sT=({children:t,title:e})=>{var lt;const{user:r,signOut:n,isAdmin:s,isBrokerageManager:o,isCoach:c,brokerageId:a}=Zn(),{isAssistant:f,actingAsAgent:m,hasPermission:y}=L4();pW();const{isImpersonating:_}=Y0e(),E=(f&&!!m?40:0)+(_?40:0),{avatarUrl:A}=S9e(r==null?void 0:r.id),{isTrial:C,isExpired:I,expiresAt:M}=T9e(r==null?void 0:r.id),{isInnerCircleEnabled:D,isMarketplaceEnabled:B}=O4(),{currentBrief:U,shouldShowPopup:q,hasUnseenBrief:H,openBrief:K,closeBrief:Q,dismissBrief:J}=CJe(),{unreadCount:ee}=E9e(),{openCount:oe}=j9e();nE();const ye=t1e(wt=>wt.cartItems).reduce((wt,yt)=>wt+yt.quantity,0),{leadSite:Ee,hasLeadSite:Le,siteUrl:Se}=XW();vwe(!Le);const be=ra(),me=js(),[ke,Pe]=N.useState(null);N.useEffect(()=>{r!=null&&r.id&&Ce.from("profiles").select("name").eq("id",r.id).single().then(({data:wt})=>{wt!=null&&wt.name&&Pe(wt.name)})},[r==null?void 0:r.id]);const je=ke||((lt=r==null?void 0:r.user_metadata)==null?void 0:lt.name)||(r==null?void 0:r.email)||"User",[xe,Ue]=N.useState(!1),Ze=wt=>wt.split(" ").map(yt=>yt[0]).join("").toUpperCase().slice(0,2);return i.jsx(Vxe,{children:i.jsxs("div",{className:"min-h-screen bg-background flex",children:[C&&I&&me.pathname!=="/subscription"&&i.jsx(fJe,{}),typeof document<"u"&&sp.createPortal(i.jsx("aside",{className:"hidden md:flex flex-col bg-card border-r border-border fixed left-0 z-30 !pointer-events-auto w-20",style:{top:`${E}px`,height:`calc(100vh - ${E}px)`},children:i.jsx(ret,{bannerHeight:E,communityUnreadCount:ee,wishlistOpenCount:oe,isTrial:C,isExpired:I})}),document.body),i.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden md:ml-20",style:{height:`calc(100vh - ${E}px)`,marginTop:`${E}px`},children:[i.jsx("header",{className:"sticky top-0 z-40 bg-card border-b border-border flex-shrink-0",children:i.jsxs("div",{className:"flex items-center justify-between px-6 py-3",children:[i.jsxs(hve,{open:xe,onOpenChange:Ue,children:[i.jsx(A9e,{asChild:!0,children:i.jsx(Lt,{variant:"ghost",size:"icon",className:"md:hidden",children:i.jsx(ib,{className:"h-5 w-5"})})}),i.jsx(gW,{side:"left",className:"w-72 p-0 bg-card",children:i.jsx(net,{isTrial:C,isExpired:I,expiresAt:M,communityUnreadCount:ee,wishlistOpenCount:oe,pathname:me.pathname,onSignOut:n,onNavigated:()=>Ue(!1)})})]}),i.jsx("div",{className:"flex-1 md:hidden",children:i.jsx("img",{src:W9e,alt:"LevelUp",className:"h-8 w-auto"})}),i.jsx("div",{className:"hidden md:flex flex-1 justify-center px-4 min-w-0",children:i.jsx(tie,{})}),i.jsxs("div",{className:"flex items-center gap-3 ml-auto",children:[C&&!I&&M&&i.jsx(hJe,{expiresAt:M,className:"hidden lg:flex"}),i.jsx("div",{className:"md:hidden",children:i.jsx(tie,{hotkey:!1})}),U&&i.jsx(mJe,{hasUnseenBrief:H,onClick:K}),B&&i.jsxs(Lt,{variant:"ghost",size:"icon",className:"relative",onClick:()=>be("/marketplace/cart"),children:[i.jsx(lye,{className:"h-5 w-5"}),ye>0&&i.jsx("span",{className:"absolute -top-1 -right-1 h-5 w-5 rounded-full bg-primary text-primary-foreground text-xs font-medium flex items-center justify-center",children:ye>99?"99+":ye})]}),i.jsx(Lt,{variant:"ghost",size:"icon","aria-label":"My Calendar",title:"My Calendar",onClick:()=>be("/mission-control/calendar"),children:i.jsx(Vm,{className:"h-5 w-5"})}),i.jsx(vQe,{}),i.jsx(_Qe,{}),i.jsx(hQe,{}),i.jsx(OYe,{}),i.jsxs("span",{className:"hidden sm:block text-sm font-medium text-foreground",children:["Hello, ",je.split(" ")[0],"!"]}),i.jsxs(tE,{children:[i.jsx(rE,{asChild:!0,children:i.jsx("button",{className:"focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 rounded-full",children:i.jsxs(Od,{className:"h-9 w-9 cursor-pointer hover:opacity-80 transition-opacity",children:[i.jsx(Fd,{src:A||void 0}),i.jsx(Bd,{className:"bg-primary text-primary-foreground font-medium text-sm",children:Ze(je)})]})})}),i.jsxs(cb,{align:"end",className:"w-48",children:[i.jsxs(mu,{onClick:()=>be("/profile"),className:"cursor-pointer",children:[i.jsx(Gl,{className:"h-4 w-4 mr-2"}),"Profile"]}),i.jsxs(mu,{onClick:()=>be("/credits"),className:"cursor-pointer",children:[i.jsx(c4,{className:"h-4 w-4 mr-2"}),"Credits & Wallet"]}),i.jsxs(mu,{onClick:()=>be("/mission-control/integrations"),className:"cursor-pointer",children:[i.jsx(PD,{className:"h-4 w-4 mr-2"}),"Integrations"]}),i.jsxs(mu,{onClick:()=>be("/mission-control/browser-extension"),className:"cursor-pointer",children:[i.jsx(PD,{className:"h-4 w-4 mr-2"}),"Browser Extension"]}),i.jsx(XS,{}),i.jsxs(mu,{onClick:n,className:"cursor-pointer text-destructive focus:text-destructive",children:[i.jsx(i4,{className:"h-4 w-4 mr-2"}),"Sign Out"]})]})]})]})]})}),i.jsx(PJe,{children:i.jsx("main",{className:"p-4 sm:p-6 lg:p-8 overflow-x-hidden",children:t})}),U&&i.jsx(NJe,{brief:U,open:q,onClose:Q,onDismiss:J}),i.jsx(IJe,{}),i.jsx(MJe,{}),i.jsx(BJe,{}),i.jsx(YJe,{})]})]})})},ct=({children:t,requireAdmin:e=!1,requireBrokerageManager:r=!1})=>{const{user:n,loading:s,rolesLoading:o,isAdmin:c,isBrokerageManager:a}=Zn(),f=js(),m=lve();if(s||(e||r)&&o)return i.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background",children:i.jsxs("div",{className:"text-center",children:[i.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent mx-auto mb-4"}),i.jsx("p",{className:"text-muted-foreground",children:"Loading..."})]})});if(!n){const y=f.pathname+f.search+f.hash;return y&&y!=="/auth"&&sessionStorage.setItem("redirectAfterLogin",y),i.jsx(hs,{to:"/auth",replace:!0})}if(e&&!c)return i.jsx(hs,{to:"/dashboard",replace:!0});if(r&&!a&&!c)return i.jsx(hs,{to:"/dashboard",replace:!0});if(m.isRestricted&&!m.isLoading){const y=_9e(f.pathname);if(y&&!m.hasFeature(y))return i.jsx(sT,{title:"Upgrade required",children:i.jsx(w9e,{featureKey:y})})}return i.jsx(i.Fragment,{children:t})};function g6({children:t}){const{isAdmin:e,loading:r,rolesLoading:n}=Zn(),{isFeatureEnabled:s,isLoading:o}=O4();return r||n||o?i.jsx("div",{className:"flex min-h-[50vh] items-center justify-center",children:i.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):!e&&!s("staging_studio_enabled")?i.jsx(hs,{to:"/apps",replace:!0}):i.jsx(sT,{title:"Staging Studio",children:i.jsx(N.Suspense,{fallback:i.jsx("div",{className:"flex min-h-[50vh] items-center justify-center",children:i.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}),children:t})})}var rK={};(function t(e,r,n,s){var o=!!(e.Worker&&e.Blob&&e.Promise&&e.OffscreenCanvas&&e.OffscreenCanvasRenderingContext2D&&e.HTMLCanvasElement&&e.HTMLCanvasElement.prototype.transferControlToOffscreen&&e.URL&&e.URL.createObjectURL),c=typeof Path2D=="function"&&typeof DOMMatrix=="function",a=function(){if(!e.OffscreenCanvas)return!1;try{var Pe=new OffscreenCanvas(1,1),je=Pe.getContext("2d");je.fillRect(0,0,1,1);var xe=Pe.transferToImageBitmap();je.createPattern(xe,"no-repeat")}catch{return!1}return!0}();function f(){}function m(Pe){var je=r.exports.Promise,xe=je!==void 0?je:e.Promise;return typeof xe=="function"?new xe(Pe):(Pe(f,f),null)}var y=function(Pe,je){return{transform:function(xe){if(Pe)return xe;if(je.has(xe))return je.get(xe);var Ue=new OffscreenCanvas(xe.width,xe.height),Ze=Ue.getContext("2d");return Ze.drawImage(xe,0,0),je.set(xe,Ue),Ue},clear:function(){je.clear()}}}(a,new Map),_=function(){var Pe=Math.floor(16.666666666666668),je,xe,Ue={},Ze=0;return typeof requestAnimationFrame=="function"&&typeof cancelAnimationFrame=="function"?(je=function(lt){var wt=Math.random();return Ue[wt]=requestAnimationFrame(function yt(gt){Ze===gt||Ze+Pe-1{const{data:e,error:r}=await Ce.from("celebration_queue").select("*").eq("user_id",t.id).is("seen_at",null).order("created_at",{ascending:!0});if(r)throw r;return e},enabled:!!(t!=null&&t.id),refetchOnWindowFocus:!0,staleTime:0})}function iet(){const t=jr();return kr({mutationFn:async e=>{const{error:r}=await Ce.from("celebration_queue").update({seen_at:new Date().toISOString()}).eq("id",e);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["celebrations"]})}})}function MJt(){const t=jr(),{user:e}=Zn();return kr({mutationFn:async r=>{const{error:n}=await Ce.from("celebration_queue").insert({user_id:r.user_id,celebration_type:r.celebration_type,title:r.title,message:r.message||null,points_amount:r.points_amount||null,created_by:e==null?void 0:e.id});if(n)throw n},onSuccess:()=>{t.invalidateQueries({queryKey:["celebrations"]})}})}const aet={points_earned:MD,listing_created:ea,deal_closed:yg,custom:gc},iie={points_earned:"from-amber-500 to-orange-500",listing_created:"from-emerald-500 to-teal-500",deal_closed:"from-green-500 to-emerald-500",custom:"from-purple-500 to-pink-500"},aie=()=>{const t=window.location.hostname;return t.startsWith("cards.")||t.startsWith("cardstudio.")||t.startsWith("listings.")||t.startsWith("presentations.")||t.startsWith("guestbook.")||t.startsWith("clients.")||t.startsWith("booking.")||t.startsWith("contacts.")};function oet(){const{user:t}=Zn(),e=jr(),{data:r}=set(),n=iet(),[s,o]=N.useState(null),[c,a]=N.useState(!1),f=N.useCallback(()=>{const E=Date.now()+3e3,A={startVelocity:30,spread:360,ticks:60,zIndex:9999},C=(M,D)=>Math.random()*(D-M)+M,I=setInterval(()=>{const M=E-Date.now();if(M<=0){clearInterval(I);return}const D=50*(M/3e3);sie({...A,particleCount:D,origin:{x:C(.1,.3),y:Math.random()-.2},colors:["#ff6b6b","#feca57","#48dbfb","#ff9ff3","#54a0ff","#5f27cd"]}),sie({...A,particleCount:D,origin:{x:C(.7,.9),y:Math.random()-.2},colors:["#ff6b6b","#feca57","#48dbfb","#ff9ff3","#54a0ff","#5f27cd"]})},250)},[]);N.useEffect(()=>{aie()||r&&r.length>0&&!s&&(o(r[0]),a(!0),setTimeout(f,100))},[r,s,f]);const m=async()=>{if(s){const w=s.id;a(!1),o(null),e.setQueryData(["celebrations","pending",t==null?void 0:t.id],E=>(E==null?void 0:E.filter(A=>A.id!==w))??[]),await n.mutateAsync(w)}};if(aie()||!s)return null;const y=aet[s.celebration_type]||gc,_=iie[s.celebration_type]||iie.custom;return i.jsx(Ha,{open:c,onOpenChange:w=>!w&&m(),children:i.jsxs(Ra,{className:"sm:max-w-md text-center border-0 overflow-hidden",children:[i.jsx("div",{className:`absolute inset-0 bg-gradient-to-br ${_} opacity-10`}),i.jsxs("div",{className:"relative z-10 py-6",children:[i.jsx("div",{className:"flex justify-center mb-4",children:i.jsx("div",{className:`w-20 h-20 rounded-full bg-gradient-to-br ${_} flex items-center justify-center animate-bounce`,children:i.jsx(y,{className:"w-10 h-10 text-white"})})}),i.jsxs("div",{className:"flex justify-center gap-1 mb-4",children:[i.jsx(ki,{className:"w-5 h-5 text-yellow-500 animate-pulse"}),i.jsx(ki,{className:"w-5 h-5 text-yellow-500 animate-pulse delay-75"}),i.jsx(ki,{className:"w-5 h-5 text-yellow-500 animate-pulse delay-150"})]}),i.jsxs("h2",{className:"text-2xl font-bold mb-2 bg-gradient-to-r from-primary to-secondary bg-clip-text text-transparent",children:["🎉 ",s.title]}),s.points_amount&&s.points_amount>0&&i.jsxs("div",{className:"text-4xl font-bold text-primary mb-2",children:["+",s.points_amount," points!"]}),s.message&&i.jsx("p",{className:"text-muted-foreground mb-6",children:s.message}),i.jsx(Lt,{onClick:m,className:"w-full",size:"lg",children:"Awesome! 🙌"}),r&&r.length>1&&i.jsxs("p",{className:"text-sm text-muted-foreground mt-3",children:["+",r.length-1," more celebration",r.length>2?"s":""," waiting"]})]})]})})}function jl({className:t,...e}){return i.jsx("div",{className:Xt("animate-pulse rounded-md bg-muted",t),...e})}var rF="Tabs",[cet,DJt]=cl(rF,[eE]),i1e=eE(),[uet,nK]=cet(rF),a1e=N.forwardRef((t,e)=>{const{__scopeTabs:r,value:n,onValueChange:s,defaultValue:o,orientation:c="horizontal",dir:a,activationMode:f="automatic",...m}=t,y=ob(a),[_,w]=ed({prop:n,onChange:s,defaultProp:o??"",caller:rF});return i.jsx(uet,{scope:r,baseId:il(),value:_,onValueChange:w,orientation:c,dir:y,activationMode:f,children:i.jsx(cn.div,{dir:y,"data-orientation":c,...m,ref:e})})});a1e.displayName=rF;var o1e="TabsList",l1e=N.forwardRef((t,e)=>{const{__scopeTabs:r,loop:n=!0,...s}=t,o=nK(o1e,r),c=i1e(r);return i.jsx(nW,{asChild:!0,...c,orientation:o.orientation,dir:o.dir,loop:n,children:i.jsx(cn.div,{role:"tablist","aria-orientation":o.orientation,...s,ref:e})})});l1e.displayName=o1e;var c1e="TabsTrigger",u1e=N.forwardRef((t,e)=>{const{__scopeTabs:r,value:n,disabled:s=!1,...o}=t,c=nK(c1e,r),a=i1e(r),f=f1e(c.baseId,n),m=m1e(c.baseId,n),y=n===c.value;return i.jsx(sW,{asChild:!0,...a,focusable:!s,active:y,children:i.jsx(cn.button,{type:"button",role:"tab","aria-selected":y,"aria-controls":m,"data-state":y?"active":"inactive","data-disabled":s?"":void 0,disabled:s,id:f,...o,ref:e,onMouseDown:Gr(t.onMouseDown,_=>{!s&&_.button===0&&_.ctrlKey===!1?c.onValueChange(n):_.preventDefault()}),onKeyDown:Gr(t.onKeyDown,_=>{[" ","Enter"].includes(_.key)&&c.onValueChange(n)}),onFocus:Gr(t.onFocus,()=>{const _=c.activationMode!=="manual";!y&&!s&&_&&c.onValueChange(n)})})})});u1e.displayName=c1e;var d1e="TabsContent",h1e=N.forwardRef((t,e)=>{const{__scopeTabs:r,value:n,forceMount:s,children:o,...c}=t,a=nK(d1e,r),f=f1e(a.baseId,n),m=m1e(a.baseId,n),y=n===a.value,_=N.useRef(y);return N.useEffect(()=>{const w=requestAnimationFrame(()=>_.current=!1);return()=>cancelAnimationFrame(w)},[]),i.jsx(Cl,{present:s||y,children:({present:w})=>i.jsx(cn.div,{"data-state":y?"active":"inactive","data-orientation":a.orientation,role:"tabpanel","aria-labelledby":f,hidden:!w,id:m,tabIndex:0,...c,ref:e,style:{...t.style,animationDuration:_.current?"0s":void 0},children:w&&o})})});h1e.displayName=d1e;function f1e(t,e){return`${t}-trigger-${e}`}function m1e(t,e){return`${t}-content-${e}`}var det=a1e,p1e=l1e,g1e=u1e,y1e=h1e;const nF=det,UC=N.forwardRef(({className:t,...e},r)=>i.jsx(p1e,{ref:r,className:Xt("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",t),...e}));UC.displayName=p1e.displayName;const Mf=N.forwardRef(({className:t,...e},r)=>i.jsx(g1e,{ref:r,className:Xt("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",t),...e}));Mf.displayName=g1e.displayName;const Rx=N.forwardRef(({className:t,...e},r)=>i.jsx(y1e,{ref:r,className:Xt("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",t),...e}));Rx.displayName=y1e.displayName;const cN="#0d0d0d",uO="#1a1a1a",lc="#c9a84c",VC="#f0d78c",Qm={captured:"lup_lead_captured_v1",stickyDismissed:"lup_sticky_dismissed_v1",exitShown:"lup_exit_shown_v1",savedListings:"lup_saved_listings_v1"};async function sF(t){const e={...t,source_page:typeof window<"u"?window.location.pathname:null,user_agent:typeof navigator<"u"?navigator.userAgent:null,referrer:typeof document<"u"?document.referrer:null},{data:r,error:n}=await Ce.functions.invoke("public-site-lead",{body:e});if(n)throw n;try{localStorage.setItem(Qm.captured,JSON.stringify({email:t.email,ts:Date.now()}))}catch{}return r}function sK(){try{return!!localStorage.getItem(Qm.captured)}catch{return!1}}function het(){try{const t=localStorage.getItem(Qm.captured);return t?JSON.parse(t).email??null:null}catch{return null}}function iK({open:t,onClose:e,children:r}){return N.useEffect(()=>{if(!t)return;const n=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=n}},[t]),t?sp.createPortal(i.jsx("div",{className:"fixed inset-0 z-[100] flex items-center justify-center p-4 animate-in fade-in",style:{background:"rgba(0,0,0,0.82)",backdropFilter:"blur(6px)"},onClick:e,children:i.jsxs("div",{onClick:n=>n.stopPropagation(),className:"relative w-full max-w-md rounded-2xl overflow-hidden animate-in zoom-in-95",style:{background:`linear-gradient(180deg, ${uO} 0%, ${cN} 100%)`,border:`1px solid ${lc}33`,boxShadow:`0 30px 80px rgba(0,0,0,0.6), 0 0 0 1px ${lc}22 inset`},children:[i.jsx("button",{onClick:e,className:"absolute right-4 top-4 z-10 rounded-full p-2 text-white/60 hover:text-white hover:bg-white/10 transition","aria-label":"Close",children:i.jsx(Ci,{className:"h-4 w-4"})}),r]})}),document.body):null}function aK(){const[t,e]=N.useState({first_name:"",email:"",phone:"",area:""}),[r,n]=N.useState(!1),[s,o]=N.useState("");return{values:t,setValues:e,loading:r,setLoading:n,honeypot:s,setHoneypot:o}}function oK({values:t,setValues:e,honeypot:r,setHoneypot:n,showPhone:s=!0,showArea:o=!0,areaPlaceholder:c="City, ZIP, or neighborhood"}){const a="w-full rounded-lg px-11 py-3 text-sm text-white placeholder:text-white/40 border transition focus:outline-none",f={background:"rgba(255,255,255,0.04)",borderColor:"rgba(255,255,255,0.12)"};return i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{className:"relative",children:[i.jsx(Gl,{className:"absolute left-3.5 top-1/2 -translate-y-1/2 h-4 w-4 text-white/40"}),i.jsx("input",{type:"text",placeholder:"First name",value:t.first_name,onChange:m=>e({...t,first_name:m.target.value}),className:a,style:f})]}),i.jsxs("div",{className:"relative",children:[i.jsx(rs,{className:"absolute left-3.5 top-1/2 -translate-y-1/2 h-4 w-4 text-white/40"}),i.jsx("input",{type:"email",required:!0,placeholder:"Email address",value:t.email,onChange:m=>e({...t,email:m.target.value}),className:a,style:f})]}),s&&i.jsxs("div",{className:"relative",children:[i.jsx(Un,{className:"absolute left-3.5 top-1/2 -translate-y-1/2 h-4 w-4 text-white/40"}),i.jsx("input",{type:"tel",placeholder:"Phone (optional)",value:t.phone,onChange:m=>e({...t,phone:m.target.value}),className:a,style:f})]}),o&&i.jsxs("div",{className:"relative",children:[i.jsx(ui,{className:"absolute left-3.5 top-1/2 -translate-y-1/2 h-4 w-4 text-white/40"}),i.jsx("input",{type:"text",placeholder:c,value:t.area,onChange:m=>e({...t,area:m.target.value}),className:a,style:f})]}),i.jsx("input",{type:"text",value:r,onChange:m=>n(m.target.value),tabIndex:-1,autoComplete:"off",className:"absolute -left-[9999px] w-0 h-0 opacity-0","aria-hidden":"true"})]})}function lK({children:t,disabled:e,onClick:r,type:n="button"}){return i.jsx("button",{type:n,disabled:e,onClick:r,className:"w-full rounded-lg py-3 text-sm font-semibold uppercase tracking-widest transition disabled:opacity-60 disabled:cursor-not-allowed",style:{background:`linear-gradient(180deg, ${VC} 0%, ${lc} 100%)`,color:cN,boxShadow:`0 8px 24px ${lc}55`},children:t})}function oie({open:t,onClose:e,initialCriteria:r}){const{values:n,setValues:s,loading:o,setLoading:c,honeypot:a,setHoneypot:f}=aK(),[m,y]=N.useState(!1),_=async w=>{if(w.preventDefault(),!!n.email){c(!0);try{await sF({lead_type:"new_listing_alerts",email:n.email.trim().toLowerCase(),first_name:n.first_name.trim()||void 0,phone:n.phone.trim()||void 0,criteria:{...r||{},...n.area.trim()?{area:n.area.trim()}:{}}}),y(!0);try{localStorage.setItem(Qm.stickyDismissed,"1")}catch{}setTimeout(e,2200)}catch{$t.error("Something went wrong. Please try again.")}finally{c(!1)}}};return i.jsx(iK,{open:t,onClose:e,children:i.jsxs("div",{className:"p-8",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[i.jsx(gC,{className:"h-4 w-4",style:{color:lc}}),i.jsx("span",{className:"text-xs uppercase tracking-[0.2em]",style:{color:VC},children:"New Listing Alerts"})]}),i.jsx("h2",{className:"text-2xl font-serif text-white leading-tight mb-2",children:"Be the first to know."}),i.jsx("p",{className:"text-sm text-white/60 mb-6 leading-relaxed",children:"The best homes go before they hit the market. Get instant alerts the moment new listings match your search."}),m?i.jsxs("div",{className:"py-6 text-center",children:[i.jsx("div",{className:"mx-auto mb-3 h-12 w-12 rounded-full flex items-center justify-center",style:{background:`${lc}22`,border:`1px solid ${lc}55`},children:i.jsx(ki,{className:"h-5 w-5",style:{color:lc}})}),i.jsx("div",{className:"text-white font-medium",children:"You're on the list."}),i.jsx("div",{className:"text-white/50 text-xs mt-1",children:"Check your inbox for confirmation."})]}):i.jsxs("form",{onSubmit:_,className:"space-y-4",children:[i.jsx(oK,{values:n,setValues:s,honeypot:a,setHoneypot:f}),i.jsx(lK,{type:"submit",disabled:o||!n.email,children:o?"Activating…":"Activate Alerts"}),i.jsx("p",{className:"text-[10px] text-white/40 text-center leading-relaxed",children:"We respect your inbox. Unsubscribe any time."})]})]})})}function fet(){const[t,e]=N.useState(!0),[r,n]=N.useState(!1);N.useEffect(()=>{try{const o=!!localStorage.getItem(Qm.stickyDismissed)||sK();e(o)}catch{e(!1)}},[]);const s=()=>{e(!0);try{localStorage.setItem(Qm.stickyDismissed,"1")}catch{}};return t?i.jsx(oie,{open:r,onClose:()=>n(!1)}):i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"fixed bottom-0 left-0 right-0 z-40 animate-in slide-in-from-bottom",style:{background:`linear-gradient(180deg, ${uO} 0%, ${cN} 100%)`,borderTop:`1px solid ${lc}44`,boxShadow:"0 -8px 30px rgba(0,0,0,0.5)"},children:i.jsxs("div",{className:"max-w-6xl mx-auto px-4 sm:px-6 py-3 flex items-center gap-3",children:[i.jsx("div",{className:"hidden sm:flex h-9 w-9 rounded-full items-center justify-center flex-shrink-0",style:{background:`${lc}22`,border:`1px solid ${lc}55`},children:i.jsx(gC,{className:"h-4 w-4",style:{color:lc}})}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("div",{className:"text-white text-sm font-medium truncate",children:"Be the first to know when new homes hit the market"}),i.jsx("div",{className:"text-white/50 text-xs hidden sm:block",children:"Instant alerts. No spam. Unsubscribe anytime."})]}),i.jsx("button",{onClick:()=>n(!0),className:"rounded-lg px-4 py-2 text-xs font-semibold uppercase tracking-wider whitespace-nowrap transition hover:brightness-110",style:{background:`linear-gradient(180deg, ${VC} 0%, ${lc} 100%)`,color:cN},children:"Get Alerts"}),i.jsx("button",{onClick:s,className:"p-2 text-white/50 hover:text-white transition","aria-label":"Dismiss",children:i.jsx(Ci,{className:"h-4 w-4"})})]})}),i.jsx(oie,{open:r,onClose:()=>n(!1)})]})}function met(){const[t,e]=N.useState(!1),r=N.useRef(!1);N.useEffect(()=>{try{if(sessionStorage.getItem(Qm.exitShown)||sK())return}catch{}const w=setTimeout(()=>{r.current=!0},8e3),E=A=>{if(r.current&&!(A.clientY>0)){e(!0);try{sessionStorage.setItem(Qm.exitShown,"1")}catch{}window.removeEventListener("mouseleave",E),document.removeEventListener("mouseleave",E)}};return document.addEventListener("mouseleave",E),()=>{clearTimeout(w),document.removeEventListener("mouseleave",E)}},[]);const{values:n,setValues:s,loading:o,setLoading:c,honeypot:a,setHoneypot:f}=aK(),[m,y]=N.useState(!1),_=async w=>{if(w.preventDefault(),!!n.email){c(!0);try{await sF({lead_type:"exit_intent",email:n.email.trim().toLowerCase(),first_name:n.first_name.trim()||void 0,phone:n.phone.trim()||void 0,criteria:n.area.trim()?{area:n.area.trim()}:void 0}),y(!0),setTimeout(()=>e(!1),2200)}catch{$t.error("Something went wrong. Please try again.")}finally{c(!1)}}};return i.jsx(iK,{open:t,onClose:()=>e(!1),children:i.jsxs("div",{className:"relative",children:[i.jsx("div",{className:"h-32 w-full",style:{background:`linear-gradient(135deg, ${cN} 0%, ${uO} 60%, ${lc} 130%)`},children:i.jsx("div",{className:"absolute top-4 left-6",children:i.jsx("span",{className:"text-[10px] uppercase tracking-[0.25em]",style:{color:VC},children:"Before You Go"})})}),i.jsxs("div",{className:"p-8 -mt-10",children:[i.jsx("div",{className:"mx-auto mb-5 h-16 w-16 rounded-full flex items-center justify-center",style:{background:uO,border:`1px solid ${lc}55`,boxShadow:"0 8px 24px rgba(0,0,0,0.5)"},children:i.jsx(ki,{className:"h-6 w-6",style:{color:lc}})}),i.jsx("h2",{className:"text-2xl font-serif text-white text-center leading-tight mb-2",children:"Wait — get a fresh list of homes."}),i.jsx("p",{className:"text-sm text-white/60 text-center mb-6 leading-relaxed",children:"Drop your email and we'll send you a curated list of homes matching your area, updated weekly."}),m?i.jsxs("div",{className:"py-4 text-center",children:[i.jsx("div",{className:"text-white font-medium",children:"Sent — check your inbox."}),i.jsx("div",{className:"text-white/50 text-xs mt-1",children:"Your list is on its way."})]}):i.jsxs("form",{onSubmit:_,className:"space-y-4",children:[i.jsx(oK,{values:n,setValues:s,honeypot:a,setHoneypot:f,showPhone:!1}),i.jsx(lK,{type:"submit",disabled:o||!n.email,children:o?"Sending…":"Send My List"})]})]})]})})}function pet(){const[t,e]=N.useState([]);N.useEffect(()=>{try{const a=localStorage.getItem(Qm.savedListings);a&&e(JSON.parse(a))}catch{}},[]);const r=a=>{e(a);try{localStorage.setItem(Qm.savedListings,JSON.stringify(a))}catch{}},n=N.useCallback(a=>t.includes(a),[t]),s=a=>{t.includes(a)||r([...t,a])},o=a=>r(t.filter(f=>f!==a));return{ids:t,has:n,add:s,remove:o,toggle:a=>t.includes(a)?o(a):s(a)}}function get({listingId:t,listingAddress:e,className:r}){const{has:n,add:s,remove:o}=pet(),c=n(t),[a,f]=N.useState(!1),m=()=>{if(c){o(t);return}if(sK()){s(t),$t.success("Saved to your favorites"),sF({lead_type:"saved_listing",email:het()||"unknown@local",listing_id:t,listing_address:e}).catch(()=>{});return}f(!0)};return i.jsxs(i.Fragment,{children:[i.jsx("button",{onClick:m,className:r,"aria-label":c?"Remove from favorites":"Save to favorites",children:i.jsx(Zm,{className:`h-5 w-5 ${c?"fill-current":""}`})}),i.jsx(yet,{open:a,onClose:()=>f(!1),listingId:t,listingAddress:e,onSaved:()=>s(t)})]})}function yet({open:t,onClose:e,listingId:r,listingAddress:n,onSaved:s}){const{values:o,setValues:c,loading:a,setLoading:f,honeypot:m,setHoneypot:y}=aK(),_=async w=>{if(w.preventDefault(),!!o.email){f(!0);try{await sF({lead_type:"saved_listing",email:o.email.trim().toLowerCase(),first_name:o.first_name.trim()||void 0,phone:o.phone.trim()||void 0,listing_id:r,listing_address:n}),s(),$t.success("Saved to your favorites"),e()}catch{$t.error("Something went wrong. Please try again.")}finally{f(!1)}}};return i.jsx(iK,{open:t,onClose:e,children:i.jsxs("div",{className:"p-8",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[i.jsx(Zm,{className:"h-4 w-4",style:{color:lc}}),i.jsx("span",{className:"text-xs uppercase tracking-[0.2em]",style:{color:VC},children:"Save This Home"})]}),i.jsx("h2",{className:"text-2xl font-serif text-white leading-tight mb-2",children:"One click to save."}),i.jsx("p",{className:"text-sm text-white/60 mb-6 leading-relaxed",children:"Get an alert if the price drops or the status changes. No spam — just the updates that matter."}),i.jsxs("form",{onSubmit:_,className:"space-y-4",children:[i.jsx(oK,{values:o,setValues:c,honeypot:m,setHoneypot:y}),i.jsx(lK,{type:"submit",disabled:a||!o.email,children:a?"Saving…":"Save Home"})]})]})})}var x1e=["PageUp","PageDown"],_1e=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],v1e={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},oE="Slider",[kq,xet,_et]=mC(oE),[b1e,OJt]=cl(oE,[_et]),[vet,iF]=b1e(oE),w1e=N.forwardRef((t,e)=>{const{name:r,min:n=0,max:s=100,step:o=1,orientation:c="horizontal",disabled:a=!1,minStepsBetweenThumbs:f=0,defaultValue:m=[n],value:y,onValueChange:_=()=>{},onValueCommit:w=()=>{},inverted:E=!1,form:A,...C}=t,I=N.useRef(new Set),M=N.useRef(0),B=c==="horizontal"?bet:wet,[U=[],q]=ed({prop:y,defaultProp:m,onChange:oe=>{var ye;(ye=[...I.current][M.current])==null||ye.focus(),_(oe)}}),H=N.useRef(U);function K(oe){const de=Aet(U,oe);ee(oe,de)}function Q(oe){ee(oe,M.current)}function J(){const oe=H.current[M.current];U[M.current]!==oe&&w(U)}function ee(oe,de,{commit:ye}={commit:!1}){const Ee=Pet(o),Le=Ret(Math.round((oe-n)/o)*o+n,Ee),Se=rN(Le,[n,s]);q((be=[])=>{const me=jet(be,Se,de);if(Iet(me,f*o)){M.current=me.indexOf(Se);const ke=String(me)!==String(be);return ke&&ye&&w(me),ke?me:be}else return be})}return i.jsx(vet,{scope:t.__scopeSlider,name:r,disabled:a,min:n,max:s,valueIndexToChangeRef:M,thumbs:I.current,values:U,orientation:c,form:A,children:i.jsx(kq.Provider,{scope:t.__scopeSlider,children:i.jsx(kq.Slot,{scope:t.__scopeSlider,children:i.jsx(B,{"aria-disabled":a,"data-disabled":a?"":void 0,...C,ref:e,onPointerDown:Gr(C.onPointerDown,()=>{a||(H.current=U)}),min:n,max:s,inverted:E,onSlideStart:a?void 0:K,onSlideMove:a?void 0:Q,onSlideEnd:a?void 0:J,onHomeKeyDown:()=>!a&&ee(n,0,{commit:!0}),onEndKeyDown:()=>!a&&ee(s,U.length-1,{commit:!0}),onStepKeyDown:({event:oe,direction:de})=>{if(!a){const Le=x1e.includes(oe.key)||oe.shiftKey&&_1e.includes(oe.key)?10:1,Se=M.current,be=U[Se],me=o*Le*de;ee(be+me,Se,{commit:!0})}}})})})})});w1e.displayName=oE;var[S1e,T1e]=b1e(oE,{startEdge:"left",endEdge:"right",size:"width",direction:1}),bet=N.forwardRef((t,e)=>{const{min:r,max:n,dir:s,inverted:o,onSlideStart:c,onSlideMove:a,onSlideEnd:f,onStepKeyDown:m,...y}=t,[_,w]=N.useState(null),E=is(e,B=>w(B)),A=N.useRef(void 0),C=ob(s),I=C==="ltr",M=I&&!o||!I&&o;function D(B){const U=A.current||_.getBoundingClientRect(),q=[0,U.width],K=cK(q,M?[r,n]:[n,r]);return A.current=U,K(B-U.left)}return i.jsx(S1e,{scope:t.__scopeSlider,startEdge:M?"left":"right",endEdge:M?"right":"left",direction:M?1:-1,size:"width",children:i.jsx(E1e,{dir:C,"data-orientation":"horizontal",...y,ref:E,style:{...y.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:B=>{const U=D(B.clientX);c==null||c(U)},onSlideMove:B=>{const U=D(B.clientX);a==null||a(U)},onSlideEnd:()=>{A.current=void 0,f==null||f()},onStepKeyDown:B=>{const q=v1e[M?"from-left":"from-right"].includes(B.key);m==null||m({event:B,direction:q?-1:1})}})})}),wet=N.forwardRef((t,e)=>{const{min:r,max:n,inverted:s,onSlideStart:o,onSlideMove:c,onSlideEnd:a,onStepKeyDown:f,...m}=t,y=N.useRef(null),_=is(e,y),w=N.useRef(void 0),E=!s;function A(C){const I=w.current||y.current.getBoundingClientRect(),M=[0,I.height],B=cK(M,E?[n,r]:[r,n]);return w.current=I,B(C-I.top)}return i.jsx(S1e,{scope:t.__scopeSlider,startEdge:E?"bottom":"top",endEdge:E?"top":"bottom",size:"height",direction:E?1:-1,children:i.jsx(E1e,{"data-orientation":"vertical",...m,ref:_,style:{...m.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:C=>{const I=A(C.clientY);o==null||o(I)},onSlideMove:C=>{const I=A(C.clientY);c==null||c(I)},onSlideEnd:()=>{w.current=void 0,a==null||a()},onStepKeyDown:C=>{const M=v1e[E?"from-bottom":"from-top"].includes(C.key);f==null||f({event:C,direction:M?-1:1})}})})}),E1e=N.forwardRef((t,e)=>{const{__scopeSlider:r,onSlideStart:n,onSlideMove:s,onSlideEnd:o,onHomeKeyDown:c,onEndKeyDown:a,onStepKeyDown:f,...m}=t,y=iF(oE,r);return i.jsx(cn.span,{...m,ref:e,onKeyDown:Gr(t.onKeyDown,_=>{_.key==="Home"?(c(_),_.preventDefault()):_.key==="End"?(a(_),_.preventDefault()):x1e.concat(_1e).includes(_.key)&&(f(_),_.preventDefault())}),onPointerDown:Gr(t.onPointerDown,_=>{const w=_.target;w.setPointerCapture(_.pointerId),_.preventDefault(),y.thumbs.has(w)?w.focus():n(_)}),onPointerMove:Gr(t.onPointerMove,_=>{_.target.hasPointerCapture(_.pointerId)&&s(_)}),onPointerUp:Gr(t.onPointerUp,_=>{const w=_.target;w.hasPointerCapture(_.pointerId)&&(w.releasePointerCapture(_.pointerId),o(_))})})}),j1e="SliderTrack",k1e=N.forwardRef((t,e)=>{const{__scopeSlider:r,...n}=t,s=iF(j1e,r);return i.jsx(cn.span,{"data-disabled":s.disabled?"":void 0,"data-orientation":s.orientation,...n,ref:e})});k1e.displayName=j1e;var Aq="SliderRange",A1e=N.forwardRef((t,e)=>{const{__scopeSlider:r,...n}=t,s=iF(Aq,r),o=T1e(Aq,r),c=N.useRef(null),a=is(e,c),f=s.values.length,m=s.values.map(w=>I1e(w,s.min,s.max)),y=f>1?Math.min(...m):0,_=100-Math.max(...m);return i.jsx(cn.span,{"data-orientation":s.orientation,"data-disabled":s.disabled?"":void 0,...n,ref:a,style:{...t.style,[o.startEdge]:y+"%",[o.endEdge]:_+"%"}})});A1e.displayName=Aq;var Nq="SliderThumb",N1e=N.forwardRef((t,e)=>{const r=xet(t.__scopeSlider),[n,s]=N.useState(null),o=is(e,a=>s(a)),c=N.useMemo(()=>n?r().findIndex(a=>a.ref.current===n):-1,[r,n]);return i.jsx(Tet,{...t,ref:o,index:c})}),Tet=N.forwardRef((t,e)=>{const{__scopeSlider:r,index:n,name:s,...o}=t,c=iF(Nq,r),a=T1e(Nq,r),[f,m]=N.useState(null),y=is(e,D=>m(D)),_=f?c.form||!!f.closest("form"):!0,w=jC(f),E=c.values[n],A=E===void 0?0:I1e(E,c.min,c.max),C=ket(n,c.values.length),I=w==null?void 0:w[a.size],M=I?Net(I,A,a.direction):0;return N.useEffect(()=>{if(f)return c.thumbs.add(f),()=>{c.thumbs.delete(f)}},[f,c.thumbs]),i.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[a.startEdge]:`calc(${A}% + ${M}px)`},children:[i.jsx(kq.ItemSlot,{scope:t.__scopeSlider,children:i.jsx(cn.span,{role:"slider","aria-label":t["aria-label"]||C,"aria-valuemin":c.min,"aria-valuenow":E,"aria-valuemax":c.max,"aria-orientation":c.orientation,"data-orientation":c.orientation,"data-disabled":c.disabled?"":void 0,tabIndex:c.disabled?void 0:0,...o,ref:y,style:E===void 0?{display:"none"}:t.style,onFocus:Gr(t.onFocus,()=>{c.valueIndexToChangeRef.current=n})})}),_&&i.jsx(C1e,{name:s??(c.name?c.name+(c.values.length>1?"[]":""):void 0),form:c.form,value:E},n)]})});N1e.displayName=Nq;var Eet="RadioBubbleInput",C1e=N.forwardRef(({__scopeSlider:t,value:e,...r},n)=>{const s=N.useRef(null),o=is(s,n),c=OC(e);return N.useEffect(()=>{const a=s.current;if(!a)return;const f=window.HTMLInputElement.prototype,y=Object.getOwnPropertyDescriptor(f,"value").set;if(c!==e&&y){const _=new Event("input",{bubbles:!0});y.call(a,e),a.dispatchEvent(_)}},[c,e]),i.jsx(cn.input,{style:{display:"none"},...r,ref:o,defaultValue:e})});C1e.displayName=Eet;function jet(t=[],e,r){const n=[...t];return n[r]=e,n.sort((s,o)=>s-o)}function I1e(t,e,r){const o=100/(r-e)*(t-e);return rN(o,[0,100])}function ket(t,e){return e>2?`Value ${t+1} of ${e}`:e===2?["Minimum","Maximum"][t]:void 0}function Aet(t,e){if(t.length===1)return 0;const r=t.map(s=>Math.abs(s-e)),n=Math.min(...r);return r.indexOf(n)}function Net(t,e,r){const n=t/2,o=cK([0,50],[0,n]);return(n-o(e)*r)*r}function Cet(t){return t.slice(0,-1).map((e,r)=>t[r+1]-e)}function Iet(t,e){if(e>0){const r=Cet(t);return Math.min(...r)>=e}return!0}function cK(t,e){return r=>{if(t[0]===t[1]||e[0]===e[1])return e[0];const n=(e[1]-e[0])/(t[1]-t[0]);return e[0]+n*(r-t[0])}}function Pet(t){return(String(t).split(".")[1]||"").length}function Ret(t,e){const r=Math.pow(10,e);return Math.round(t*r)/r}var P1e=w1e,Let=k1e,Met=A1e,Det=N1e;const Gm=N.forwardRef(({className:t,...e},r)=>i.jsxs(P1e,{ref:r,className:Xt("relative flex w-full touch-none select-none items-center",t),...e,children:[i.jsx(Let,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:i.jsx(Met,{className:"absolute h-full bg-primary"})}),i.jsx(Det,{className:"block h-5 w-5 rounded-full border-2 border-primary bg-background ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50"})]}));Gm.displayName=P1e.displayName;const Oet=t=>mr({queryKey:["public-listings",t],queryFn:async()=>{let e=Ce.from("listings").select(` id, slug, agent_id, property_address, city, state, neighborhood, price, property_type, listing_class, status, bedrooms, bathrooms, square_footage, lot_size, year_built, has_hoa, description, latitude, longitude, created_at, updated_at, photos:listing_photos(id, photo_url, is_primary), agent:profiles!listings_agent_id_fkey(id, name, email, phone, avatar_url, brokerage_name, brokerage:brokerages!profiles_brokerage_id_fkey(name)) `).eq("is_approved",!0).eq("is_public",!0).or("lifecycle_stage.is.null,lifecycle_stage.neq.pitch").or("listing_class.is.null,listing_class.neq.commercial").order("created_at",{ascending:!1});if(t!=null&&t.status?e=e.eq("status",t.status):e=e.not("status","in","(sold,temp_off_market,withdrawn)"),t!=null&&t.propertyType&&(e=e.eq("property_type",t.propertyType)),t!=null&&t.city){const s=t.city.replace(/[%,()]/g," ").trim();if(s){const o=`%${s}%`;e=e.or(`city.ilike.${o},neighborhood.ilike.${o},property_address.ilike.${o}`)}}t!=null&&t.minPrice&&(e=e.gte("price",t.minPrice)),t!=null&&t.maxPrice&&(e=e.lte("price",t.maxPrice));const{data:r,error:n}=await e;if(n)throw n;return r}}),Fet=()=>mr({queryKey:["public-listings-search-index"],staleTime:5*60*1e3,queryFn:async()=>{const{data:t,error:e}=await Ce.from("listings").select("city, state, neighborhood, property_address").eq("is_approved",!0).eq("is_public",!0);if(e)throw e;const r=new Map,n=new Map,s=new Map;return(t||[]).forEach(o=>{if(o.city){const c=`${o.city}|${o.state||""}`.toLowerCase(),a=o.state?`${o.city}, ${o.state}`:o.city,f=r.get(c);f?f.count++:r.set(c,{label:a,city:o.city,state:o.state,count:1})}if(o.neighborhood){const c=`${o.neighborhood}|${o.city||""}`.toLowerCase(),a=o.city?`${o.neighborhood} — ${o.city}`:o.neighborhood,f=n.get(c);f?f.count++:n.set(c,{label:a,city:o.city||"",neighborhood:o.neighborhood,count:1})}if(o.property_address){const c=String(o.property_address).match(/\b(\d{5})(?:-\d{4})?\b/);if(c){const a=c[1],f=s.get(a);f?f.count++:s.set(a,{label:a,zip:a,count:1})}}}),{cities:Array.from(r.values()).sort((o,c)=>c.count-o.count),neighborhoods:Array.from(n.values()).sort((o,c)=>c.count-o.count),zips:Array.from(s.values()).sort((o,c)=>c.count-o.count)}}}),Bet=t=>mr({queryKey:["public-listing",t],queryFn:async()=>{const e=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(t);let r=Ce.from("listings").select(` id, slug, agent_id, property_address, city, state, neighborhood, price, property_type, listing_class, status, bedrooms, bathrooms, square_footage, lot_size, year_built, has_hoa, description, agent_notes, agent_notes_public, mls_link, video_link, video_id, latitude, longitude, page_config, page_theme, created_at, updated_at, co_agent_name, co_agent_email, co_agent_phone, co_agent_brokerage, co_agent_photo_url, photos:listing_photos(id, photo_url, is_primary, sort_order), agent:profiles!listings_agent_id_fkey(id, name, email, phone, avatar_url, brokerage_name, brokerage:brokerages!profiles_brokerage_id_fkey(name)), video:agent_videos!listings_video_id_fkey(id, playback_url, thumbnail_url, title, duration_seconds, bunny_video_id) `).eq("is_approved",!0).eq("is_public",!0).not("status","in","(temp_off_market,withdrawn)");e?r=r.eq("id",t):r=r.eq("slug",t);const{data:n,error:s}=await r.single();if(s)throw s;const o=n;return Array.isArray(o==null?void 0:o.photos)&&(o.photos=[...o.photos].sort((c,a)=>(c.sort_order??0)-(a.sort_order??0)||(a.is_primary?1:0)-(c.is_primary?1:0))),o},enabled:!!t}),$et=()=>kr({mutationFn:async({listingId:t,agentId:e,firstName:r,lastName:n,email:s,phone:o,shareToken:c,leadType:a="info_request",preferredDate:f,preferredTime:m,showingMode:y,message:_})=>{let w=null,E=null;if(c){const{data:D}=await Ce.from("listing_shares").select("id, sharing_agent_id").eq("share_token",c).eq("listing_id",t).maybeSingle();D&&(w=D.id,E=D.sharing_agent_id)}const A=crypto.randomUUID(),C={id:A},{error:I}=await Ce.from("listing_leads").insert({id:A,listing_id:t,agent_id:E||e,first_name:r,last_name:n,email:s,phone:o,share_id:w,referred_by_agent_id:E,lead_type:a,preferred_date:f||null,preferred_time:m||null,showing_mode:y||null,message:_||null});if(I)throw I;const{error:M}=await Ce.functions.invoke("process-listing-lead",{body:{leadId:C.id}});return M&&console.error("Error processing lead:",M),C}}),zet=()=>kr({mutationFn:async t=>{const{error:e}=await Ce.rpc("increment_listing_share_click",{p_share_token:t});if(e)throw e}});function Uet({title:t,subtitle:e,areaLabel:r,sections:n,agent:s,tone:o="light"}){const c=o==="dark",a=c?"text-white/65":"text-muted-foreground",f=c?"border-white/10":"border-border";return i.jsxs("div",{className:c?"text-white":"text-foreground",id:"community-guide-print",children:[i.jsxs("header",{className:`border-b ${f} pb-6 mb-8`,children:[i.jsxs("div",{className:`flex items-center gap-2 text-[11px] uppercase tracking-[0.22em] ${a} mb-3`,children:[i.jsx(qS,{className:"h-3.5 w-3.5"}),"Insider's Community Guide"]}),i.jsx("h1",{className:"font-display text-3xl sm:text-4xl font-semibold leading-tight",children:t}),e&&i.jsx("p",{className:`mt-3 text-base leading-relaxed ${a}`,children:e}),r&&i.jsxs("p",{className:`mt-3 flex items-center gap-1.5 text-sm ${a}`,children:[i.jsx(ui,{className:"h-3.5 w-3.5"}),r]})]}),i.jsx("div",{className:"space-y-10",children:n.map((m,y)=>i.jsxs("section",{children:[i.jsxs("div",{className:"flex items-baseline gap-3 mb-2",children:[i.jsx("span",{className:"font-display text-2xl text-primary font-semibold",children:String(y+1).padStart(2,"0")}),i.jsx("h2",{className:"font-display text-xl sm:text-2xl font-semibold",children:m.heading})]}),m.intro&&i.jsx("p",{className:`text-sm sm:text-base leading-relaxed ${a} mb-4`,children:m.intro}),i.jsx("ul",{className:"space-y-3",children:(m.items??[]).map((_,w)=>i.jsxs("li",{className:`rounded-xl border ${f} ${c?"bg-white/[0.03]":"bg-muted/40"} px-4 py-3`,children:[i.jsx("p",{className:"font-medium text-sm sm:text-base",children:_.name}),_.note&&i.jsx("p",{className:`text-sm mt-1 leading-relaxed ${a}`,children:_.note})]},w))})]},y))}),(s==null?void 0:s.name)&&i.jsxs("footer",{className:`mt-10 pt-6 border-t ${f}`,children:[i.jsxs("div",{className:"flex items-center gap-4",children:[s.avatar_url?i.jsx("img",{src:s.avatar_url,alt:s.name,className:"h-14 w-14 rounded-full object-cover border border-primary/30"}):null,i.jsxs("div",{className:"min-w-0",children:[i.jsx("p",{className:`text-[11px] uppercase tracking-[0.2em] ${a}`,children:"Prepared for you by"}),i.jsx("p",{className:"font-display text-lg font-semibold leading-tight",children:s.name}),s.brokerage&&i.jsx("p",{className:`text-sm ${a}`,children:s.brokerage}),i.jsxs("div",{className:`flex flex-wrap gap-4 mt-1.5 text-sm ${a}`,children:[s.phone&&i.jsxs("a",{href:`tel:${s.phone}`,className:"flex items-center gap-1.5 hover:text-primary",children:[i.jsx(Un,{className:"h-3.5 w-3.5"}),s.phone]}),s.email&&i.jsxs("a",{href:`mailto:${s.email}`,className:"flex items-center gap-1.5 hover:text-primary",children:[i.jsx(rs,{className:"h-3.5 w-3.5"}),s.email]})]})]})]}),i.jsxs("p",{className:`mt-4 text-sm ${a}`,children:["Thinking about a move in ",r||"the area","? Reach out any time — happy to share what never makes it online."]})]})]})}const gL="border-white/15 bg-white/5 text-white placeholder:text-white/40";function Vet({listingId:t}){const[e,r]=N.useState(null),[n,s]=N.useState({firstName:"",lastName:"",email:"",phone:""}),[o,c]=N.useState(!1),[a,f]=N.useState(null),[m,y]=N.useState(!1);if(N.useEffect(()=>{let w=!1;return Ce.functions.invoke("community-guide-public",{body:{action:"teaser",listingId:t}}).then(({data:E})=>{!w&&E&&r(E)}).catch(()=>{}),()=>{w=!0}},[t]),!(e!=null&&e.available))return null;const _=async w=>{if(w.preventDefault(),!n.firstName.trim()||!n.email.trim()){$t.error("Please add your name and email.");return}c(!0);try{const{data:E,error:A}=await Ce.functions.invoke("community-guide-public",{body:{action:"unlock",listingId:t,...n}});if(A||E!=null&&E.error)throw new Error((E==null?void 0:E.error)||"Something went wrong.");f(E),y(!0),$t.success("Your guide is ready!")}catch(E){$t.error((E==null?void 0:E.message)||"We could not send your guide. Please try again.")}finally{c(!1)}};return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"rounded-2xl border border-white/10 bg-white/[0.03] p-6 backdrop-blur",children:[i.jsxs("div",{className:"flex items-center gap-2 text-[11px] uppercase tracking-[0.2em] text-white/60 mb-3",children:[i.jsx(qS,{className:"h-3.5 w-3.5"}),"Free Community Guide"]}),i.jsx("h3",{className:"font-display text-xl text-white font-medium leading-snug",children:e.title}),e.subtitle&&i.jsx("p",{className:"text-sm text-white/60 mt-2 leading-relaxed",children:e.subtitle}),(e.teaser??[]).length>0&&i.jsx("ul",{className:"mt-4 space-y-2",children:e.teaser.map((w,E)=>i.jsxs("li",{className:"flex gap-2 text-sm text-white/70",children:[i.jsx(pa,{className:"h-4 w-4 text-primary shrink-0 mt-0.5"}),w]},E))}),a?i.jsxs(Lt,{className:"w-full mt-5",onClick:()=>y(!0),children:[i.jsx(qS,{className:"h-4 w-4 mr-2"}),"Read your guide"]}):i.jsxs("form",{onSubmit:_,className:"mt-5 space-y-3",children:[i.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[i.jsxs("div",{className:"space-y-1.5",children:[i.jsx(Fr,{htmlFor:"cg-first",className:"text-xs text-white/60",children:"First name"}),i.jsx(Dr,{id:"cg-first",value:n.firstName,onChange:w=>s({...n,firstName:w.target.value}),className:gL,required:!0})]}),i.jsxs("div",{className:"space-y-1.5",children:[i.jsx(Fr,{htmlFor:"cg-last",className:"text-xs text-white/60",children:"Last name"}),i.jsx(Dr,{id:"cg-last",value:n.lastName,onChange:w=>s({...n,lastName:w.target.value}),className:gL})]})]}),i.jsxs("div",{className:"space-y-1.5",children:[i.jsx(Fr,{htmlFor:"cg-email",className:"text-xs text-white/60",children:"Email"}),i.jsx(Dr,{id:"cg-email",type:"email",value:n.email,onChange:w=>s({...n,email:w.target.value}),className:gL,required:!0})]}),i.jsxs("div",{className:"space-y-1.5",children:[i.jsx(Fr,{htmlFor:"cg-phone",className:"text-xs text-white/60",children:"Cell phone"}),i.jsx(Dr,{id:"cg-phone",type:"tel",value:n.phone,onChange:w=>s({...n,phone:w.target.value}),className:gL})]}),i.jsxs(Lt,{type:"submit",className:"w-full",disabled:o,children:[o?i.jsx(Fc,{className:"h-4 w-4 mr-2 animate-spin"}):i.jsx(mc,{className:"h-4 w-4 mr-2"}),o?"Preparing your guide…":"Get the free guide"]}),i.jsxs("p",{className:"text-[11px] text-white/50 flex items-center gap-1.5 justify-center",children:[i.jsx(zx,{className:"h-3 w-3"}),"Instant access. We never share your details."]})]})]}),i.jsx(Ha,{open:m,onOpenChange:y,children:i.jsx(Ra,{className:"max-w-2xl p-0 gap-0",children:i.jsx(cp,{className:"max-h-[82vh]",children:i.jsxs("div",{className:"p-6 sm:p-8",children:[i.jsx("div",{id:"community-guide-print",children:a&&i.jsx(Uet,{title:a.title,subtitle:a.subtitle,areaLabel:a.area_label,sections:a.sections??[],agent:a.agent})}),i.jsx("div",{className:"mt-8 flex justify-end print:hidden",children:i.jsxs(Lt,{variant:"outline",onClick:()=>qet(a==null?void 0:a.title),children:[i.jsx(mc,{className:"h-4 w-4 mr-2"}),"Save as PDF"]})})]})})})})]})}function qet(t){const e=document.getElementById("community-guide-print");if(!e)return window.print();const r=e.cloneNode(!0);r.removeAttribute("id"),r.setAttribute("data-print-root",""),document.body.appendChild(r),document.body.classList.add("printing-doc");const n=document.title;t&&(document.title=t);let s=!1;const o=()=>{s||(s=!0,r.remove(),document.body.classList.remove("printing-doc"),document.title=n,window.removeEventListener("afterprint",o))};window.addEventListener("afterprint",o);try{window.print()}finally{setTimeout(o,1e3)}}const lie={sale:"For Sale",lease:"For Lease",sale_or_lease:"For Sale or Lease",investment:"Investment Offering"},R1e={office:"Office",retail:"Retail",industrial:"Industrial",flex:"Flex / R&D",multifamily:"Multifamily",land:"Land",medical:"Medical",hospitality:"Hospitality",self_storage:"Self Storage",mixed_use:"Mixed Use",special_purpose:"Special Purpose"},FJt=["NNN","Modified Gross","Full Service","Gross","Absolute Net","Ground Lease"],Get={sf_year:"/SF/YR",sf_month:"/SF/MO",month:"/MO"},Het={om:"Offering Memorandum",flyer:"Flyer",rent_roll:"Rent Roll",financials:"Financials",survey:"Survey",site_plan:"Site Plan",lease:"Lease Documents",other:"Other"},BJt={public:"Open download",email:"Email required",nda:"NDA required"},Wet={principal:"Principal / Investor",broker:"Broker",tenant:"Tenant / User",lender:"Lender",other:"Other"},$Jt=[{key:"pitch",label:"Pitch",blurb:"Competing for the assignment"},{key:"won",label:"Won",blurb:"Assignment secured"},{key:"launched",label:"Launch",blurb:"Microsite & materials live"},{key:"marketing",label:"Market",blurb:"Campaign in market"},{key:"under_contract",label:"Under Contract",blurb:"Deal in escrow"},{key:"closed",label:"Closed",blurb:"Transaction complete"}],y6=[{key:"photos",label:"Professional photography uploaded",detail:"At least 6 images for the microsite hero and gallery"},{key:"financials",label:"Financial snapshot completed",detail:"NOI, cap rate, occupancy or lease rate entered"},{key:"highlights",label:"Investment highlights written",detail:"3–6 reasons this opportunity matters"},{key:"om",label:"Offering Memorandum uploaded",detail:"Gated OM available for qualified prospects"},{key:"microsite",label:"Microsite published",detail:"Public commercial microsite is live"},{key:"email",label:"Broker & investor email sent",detail:"First distribution to your database"},{key:"social",label:"Social / LinkedIn announcement",detail:"Launch post published"},{key:"signage",label:"Signage & QR deployed",detail:"On-site QR code linking to the microsite"}],zJt=[{label:"Day 1 — Positioning & pricing",detail:"Finalize the pricing strategy, opportunity narrative and target buyer/tenant profile."},{label:"Day 2–4 — Institutional-grade materials",detail:"Photography, Offering Memorandum, investor teaser and branded flyer produced."},{label:"Day 5 — Property microsite goes live",detail:"Dedicated commercial microsite with gated OM, tour requests and full analytics."},{label:"Week 1 — Targeted broker & investor outreach",detail:"Direct email to qualified buyers, brokers and 1031 investors in the LevelUp database."},{label:"Week 2 — Digital & social distribution",detail:"LinkedIn campaign, syndication and QR-coded on-site signage."},{label:"Weekly — Owner activity reporting",detail:"Every week you receive views, OM requests, downloads, tours and prospect-level interest."}];function Ef(t,e=0){return t==null||Number.isNaN(Number(t))?null:new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:e}).format(Number(t))}function cie(t){if(t==null)return null;const e=Number(t);return Number.isNaN(e)?null:e>=1e6?`$${(e/1e6).toFixed(e>=1e7?1:2).replace(/\.0+$/,"")}M`:e>=1e3?`$${Math.round(e/1e3)}K`:Ef(e)}function Cq(t){return t==null?null:`${new Intl.NumberFormat("en-US").format(Number(t))} SF`}function L1e(t,e=2){return t==null?null:`${Number(t).toFixed(e).replace(/\.?0+$/,"")}%`}function Iq(t){if(!(t!=null&&t.lease_rate))return null;const e=Get[t.lease_rate_unit||"sf_year"]??"";return`${t.lease_rate_unit==="month"?Ef(t.lease_rate):`$${Number(t.lease_rate).toFixed(2).replace(/\.00$/,"")}`}${e}${t.lease_type?` ${t.lease_type}`:""}`}function uie(t,e){if(!t)return Ef(e)??"Price on request";if(t.deal_type==="lease")return Iq(t)??"Rate on request";const r=t.asking_price??e;if(t.deal_type==="sale_or_lease"){const n=[Ef(r),Iq(t)].filter(Boolean);return n.length?n.join(" · "):"Price on request"}return Ef(r)??"Price on request"}function Ket(t,e){return e!=null&&e.opportunity_title?e.opportunity_title:e!=null&&e.hide_address||e!=null&&e.is_confidential?`Confidential ${e!=null&&e.commercial_type?R1e[e.commercial_type]:"Commercial"} Opportunity`:t.property_address||`${t.city??""}, ${t.state??""}`}function Yet(t,e){const r=(e==null?void 0:e.submarket)||t.neighborhood,n=[t.city,t.state].filter(Boolean).join(", ");return r?`${r} · ${n}`:n}function UJt(t,e){var o;const r=(t==null?void 0:t.launch_checklist)??{},n=[],s={photos:e.photoCount>=6,financials:!!(t!=null&&t.noi||t!=null&&t.cap_rate||t!=null&&t.lease_rate||t!=null&&t.occupancy_pct),highlights:(((o=t==null?void 0:t.investment_highlights)==null?void 0:o.length)??0)>=3,om:e.hasOm,microsite:e.isPublic};for(const c of y6)(s[c.key]||r[c.key])&&n.push(c.key);return{done:n,total:y6.length,score:Math.round(n.length/y6.length*100)}}const VJt={om_download:10,om_request:9,tour_request:15,inquiry:12,doc_download:8,om_view:5,gallery_view:2,page_view:1,contact_click:4,share_click:2,email_click:3,email_open:1,map_view:1};function qJt(t){return t>=30?{label:"Hot",tone:"bg-amber-500/15 text-amber-600 border-amber-500/30"}:t>=12?{label:"Warm",tone:"bg-orange-500/10 text-orange-600 border-orange-500/20"}:{label:"Tracking",tone:"bg-muted text-muted-foreground border-border"}}const GJt="https://commercial.relevelup.com",Jm=Ce;function HJt(t){return mr({queryKey:["commercial-details",t],queryFn:async()=>{const{data:e,error:r}=await Jm.from("commercial_listing_details").select("*").eq("listing_id",t).maybeSingle();if(r)throw r;return e??null},enabled:!!t})}function WJt(){const t=jr(),{user:e}=Zn();return kr({mutationFn:async({listingId:r,values:n})=>{const{data:s,error:o}=await Jm.from("commercial_listing_details").upsert({listing_id:r,agent_id:e==null?void 0:e.id,...n},{onConflict:"listing_id"}).select().single();if(o)throw o;return s},onSuccess:(r,n)=>{t.invalidateQueries({queryKey:["commercial-details",n.listingId]}),t.invalidateQueries({queryKey:["listing",n.listingId]})}})}function KJt(t){return mr({queryKey:["commercial-pitch",t],queryFn:async()=>{const{data:e,error:r}=await Jm.from("commercial_pitch_details").select("*").eq("listing_id",t).maybeSingle();if(r)throw r;return e??null},enabled:!!t})}function YJt(){const t=jr(),{user:e}=Zn();return kr({mutationFn:async({listingId:r,values:n})=>{const{data:s,error:o}=await Jm.from("commercial_pitch_details").upsert({listing_id:r,agent_id:e==null?void 0:e.id,...n},{onConflict:"listing_id"}).select().single();if(o)throw o;return s},onSuccess:(r,n)=>t.invalidateQueries({queryKey:["commercial-pitch",n.listingId]})})}function ZJt(){const t=jr();return kr({mutationFn:async({listingId:e,stage:r,lostReason:n})=>{const s=r==="won",o=r==="lost",c={lifecycle_stage:r};s&&(c.status="coming_soon"),o&&(c.is_public=!1,c.allow_sharing=!1);const{error:a}=await Jm.from("listings").update(c).eq("id",e);if(a)throw a;return(s||o)&&await Jm.from("commercial_pitch_details").update({outcome:s?"won":"lost",won_at:s?new Date().toISOString():null,lost_at:o?new Date().toISOString():null,lost_reason:o?n??null:null}).eq("listing_id",e),r},onSuccess:(e,r)=>{t.invalidateQueries({queryKey:["listing",r.listingId]}),t.invalidateQueries({queryKey:["commercial-pitch",r.listingId]}),t.invalidateQueries({queryKey:["my-listings"]}),t.invalidateQueries({queryKey:["listings"]})}})}function XJt(){const t=jr();return kr({mutationFn:async({listingId:e,values:r})=>{const{error:n}=await Jm.from("listings").update(r).eq("id",e);if(n)throw n},onSuccess:(e,r)=>{t.invalidateQueries({queryKey:["listing",r.listingId]}),t.invalidateQueries({queryKey:["my-listings"]})}})}function QJt(t,e=90){return mr({queryKey:["commercial-engagement",t,e],queryFn:async()=>{const r=new Date(Date.now()-e*864e5).toISOString(),{data:n,error:s}=await Jm.from("commercial_engagement_events").select("*").eq("listing_id",t).gte("created_at",r).order("created_at",{ascending:!1}).limit(1e3);if(s)throw s;return n??[]},enabled:!!t})}function JJt(t){return mr({queryKey:["commercial-leads",t],queryFn:async()=>{const{data:e,error:r}=await Jm.from("listing_leads").select("*").eq("listing_id",t).order("created_at",{ascending:!1});if(r)throw r;return e??[]},enabled:!!t})}const die="lu_commercial_session";function M1e(){try{let t=localStorage.getItem(die);return t||(t=crypto.randomUUID(),localStorage.setItem(die,t)),t}catch{return"anonymous"}}async function n1(t,e,r={}){try{await Jm.from("commercial_engagement_events").insert({listing_id:t,event_type:e,session_id:M1e(),source:typeof document<"u"&&document.referrer||null,metadata:r})}catch{}}const Zet={om_request:{eyebrow:"Confidential materials",title:"Request the Offering Memorandum",blurb:"Complete the form below and the offering package will be released to you immediately.",cta:"Request access"},tour_request:{eyebrow:"Property tour",title:"Schedule a tour",blurb:"Tell us who you represent and preferred timing — the listing broker will confirm directly.",cta:"Request tour"},investor_inquiry:{eyebrow:"Investment inquiry",title:"Request information",blurb:"Send a note to the listing broker about this opportunity.",cta:"Send inquiry"}};function Xet({open:t,onOpenChange:e,listingId:r,kind:n,documentId:s,requiresNda:o,brokerName:c}){const a=Zet[n],[f,m]=N.useState({firstName:"",lastName:"",email:"",phone:"",company:"",role:"principal",message:""}),[y,_]=N.useState(!1),[w,E]=N.useState(!1),[A,C]=N.useState(null),I=async()=>{if(!f.firstName.trim()||!f.email.trim()){$t.error("Name and email are required");return}if(o&&n==="om_request"&&!y){$t.error("Please acknowledge the confidentiality terms");return}E(!0);try{const{data:M,error:D}=await Ce.functions.invoke("commercial-lead",{body:{listingId:r,documentId:s??null,leadType:n,firstName:f.firstName,lastName:f.lastName,email:f.email,phone:f.phone||null,company:f.company||null,role:f.role,message:f.message||null,ndaAccepted:y,sessionId:M1e()}});if(D)throw D;if(M!=null&&M.error)throw new Error(M.error);C({signedUrl:(M==null?void 0:M.signedUrl)??null,fileName:(M==null?void 0:M.fileName)??null}),M!=null&&M.signedUrl&&window.open(M.signedUrl,"_blank")}catch(M){$t.error(M.message||"Something went wrong. Please try again.")}finally{E(!1)}};return i.jsx(Ha,{open:t,onOpenChange:M=>{e(M),M||C(null)},children:i.jsxs(Ra,{className:"max-w-lg overflow-hidden border-white/10 bg-[#0b0f14] p-0 text-white",children:[i.jsxs("div",{className:"border-b border-white/10 bg-gradient-to-b from-white/[0.06] to-transparent px-7 py-6",children:[i.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-[0.24em] text-white/45",children:a.eyebrow}),i.jsx("h2",{className:"mt-2 font-serif text-2xl",children:A?"Access granted":a.title}),i.jsx("p",{className:"mt-1.5 text-sm text-white/60",children:A?A.signedUrl?"Your download has opened in a new tab. The secure link expires in 30 minutes.":`Your request has been sent${c?` to ${c}`:""}. You'll hear back shortly.`:a.blurb})]}),A?i.jsxs("div",{className:"space-y-4 px-7 py-7",children:[i.jsxs("div",{className:"flex items-center gap-3 rounded-xl border border-emerald-400/20 bg-emerald-400/10 px-4 py-3",children:[i.jsx(Nl,{className:"h-5 w-5 text-emerald-400"}),i.jsx("p",{className:"text-sm text-white/80",children:A.fileName??"Request received"})]}),A.signedUrl&&i.jsx(Lt,{className:"w-full",onClick:()=>window.open(A.signedUrl,"_blank"),children:"Download again"}),i.jsx(Lt,{variant:"ghost",className:"w-full text-white/60 hover:text-white",onClick:()=>e(!1),children:"Close"})]}):i.jsxs("div",{className:"space-y-4 px-7 py-6",children:[i.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[i.jsx(L_,{label:"First name *",children:i.jsx(Dr,{value:f.firstName,onChange:M=>m({...f,firstName:M.target.value}),className:"border-white/15 bg-white/5 text-white"})}),i.jsx(L_,{label:"Last name",children:i.jsx(Dr,{value:f.lastName,onChange:M=>m({...f,lastName:M.target.value}),className:"border-white/15 bg-white/5 text-white"})})]}),i.jsx(L_,{label:"Email *",children:i.jsx(Dr,{type:"email",value:f.email,onChange:M=>m({...f,email:M.target.value}),className:"border-white/15 bg-white/5 text-white"})}),i.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[i.jsx(L_,{label:"Company",children:i.jsx(Dr,{value:f.company,onChange:M=>m({...f,company:M.target.value}),className:"border-white/15 bg-white/5 text-white"})}),i.jsx(L_,{label:"Phone",children:i.jsx(Dr,{value:f.phone,onChange:M=>m({...f,phone:M.target.value}),className:"border-white/15 bg-white/5 text-white"})})]}),i.jsx(L_,{label:"I am a *",children:i.jsxs(Ia,{value:f.role,onValueChange:M=>m({...f,role:M}),children:[i.jsx(_a,{className:"border-white/15 bg-white/5 text-white",children:i.jsx(Pa,{})}),i.jsx(va,{children:Object.entries(Wet).map(([M,D])=>i.jsx(gn,{value:M,children:D},M))})]})}),n!=="om_request"&&i.jsx(L_,{label:"Message",children:i.jsx(zc,{rows:3,value:f.message,onChange:M=>m({...f,message:M.target.value}),className:"border-white/15 bg-white/5 text-white",placeholder:n==="tour_request"?"Preferred dates and times…":"Your question…"})}),o&&n==="om_request"&&i.jsxs("label",{className:"flex cursor-pointer items-start gap-3 rounded-xl border border-white/10 bg-white/[0.04] p-3",children:[i.jsx(aE,{checked:y,onCheckedChange:M=>_(!!M),className:"mt-0.5 border-white/30"}),i.jsxs("span",{className:"text-xs leading-relaxed text-white/65",children:[i.jsx(o4,{className:"mr-1 inline h-3.5 w-3.5"}),"I acknowledge these materials are confidential and agree not to distribute them without the listing broker's written consent."]})]}),i.jsxs(Lt,{className:"w-full",size:"lg",onClick:I,disabled:w,children:[w?i.jsx(Fc,{className:"mr-2 h-4 w-4 animate-spin"}):i.jsx(zx,{className:"mr-2 h-4 w-4"}),a.cta]}),i.jsx("p",{className:"text-center text-[11px] text-white/40",children:"Your information is shared only with the listing broker."})]})]})})}function L_({label:t,children:e}){return i.jsxs("div",{className:"space-y-1.5",children:[i.jsx(Fr,{className:"text-[11px] font-medium uppercase tracking-wider text-white/50",children:t}),e]})}function D1e(t){if(!t)return[];const e=[],r=(n,s)=>{s&&e.push({label:n,value:s})};return r("Cap Rate",L1e(t.cap_rate)),r("NOI",cie(t.noi)),r("Occupancy",t.occupancy_pct!=null?`${Math.round(Number(t.occupancy_pct))}%`:null),r("Building SF",Cq(t.building_sf)),r("Available SF",Cq(t.available_sf)),r("Lot Size",t.lot_acres!=null?`${Number(t.lot_acres)} AC`:null),r("Units",t.units!=null?String(t.units):null),r("Price / SF",t.price_per_sf!=null?Ef(t.price_per_sf,2):null),r("Price / Unit",cie(t.price_per_unit)),r("Lease Rate",t.deal_type!=="sale"?Iq(t):null),r("Year Built",null),r("Zoning",t.zoning??null),e}function eer({details:t,className:e="",tone:r="light"}){const n=D1e(t).slice(0,8);if(!n.length)return null;const s=r==="dark";return i.jsx("div",{className:`grid gap-px overflow-hidden rounded-xl border ${s?"border-white/10 bg-white/10":"bg-border"} sm:grid-cols-2 lg:grid-cols-4 ${e}`,children:n.map(o=>i.jsxs("div",{className:`${s?"bg-[#0b0f14]":"bg-card"} px-5 py-4`,children:[i.jsx("p",{className:`text-[10px] font-semibold uppercase tracking-[0.18em] ${s?"text-white/45":"text-muted-foreground"}`,children:o.label}),i.jsx("p",{className:`mt-1.5 text-xl font-semibold tabular-nums ${s?"text-white":""}`,children:o.value})]},o.label))})}function Qet(t){return mr({queryKey:["commercial-microsite",t],queryFn:async()=>{const{data:e,error:r}=await Ce.functions.invoke("commercial-public",{body:{slug:t}});if(r)throw r;if(e!=null&&e.error)throw new Error(e.error);return e},enabled:!!t})}function Jet({slug:t}){var oe,de;const{data:e,isLoading:r,error:n}=Qet(t),[s,o]=N.useState(null),[c,a]=N.useState(null),f=e==null?void 0:e.listing,m=(e==null?void 0:e.details)??void 0,y=(e==null?void 0:e.documents)??[],_=(f==null?void 0:f.photos)??[],w=f==null?void 0:f.agent,E=!!(m!=null&&m.is_confidential||m!=null&&m.hide_address),A=N.useMemo(()=>D1e(m).slice(0,8),[m]);if(N.useEffect(()=>{f!=null&&f.id&&n1(f.id,"page_view",{slug:t})},[f==null?void 0:f.id,t]),N.useEffect(()=>{if(s===null)return;const ye=Ee=>{Ee.key==="Escape"&&o(null),Ee.key==="ArrowRight"&&o(Le=>Le===null?Le:(Le+1)%_.length),Ee.key==="ArrowLeft"&&o(Le=>Le===null?Le:(Le-1+_.length)%_.length)};return window.addEventListener("keydown",ye),()=>window.removeEventListener("keydown",ye)},[s,_.length]),r)return i.jsx("div",{className:"flex min-h-screen items-center justify-center bg-[#0b0f14]",children:i.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-2 border-white/20 border-t-white/70"})});if(n||!f)return i.jsx("div",{className:"flex min-h-screen items-center justify-center bg-[#0b0f14] px-6 text-center text-white/60",children:"This offering is no longer available."});const C=Ket(f,m),I=Yet(f,m),M=f.latitude&&f.longitude?`${f.latitude},${f.longitude}`:E?[m==null?void 0:m.submarket,f.city,f.state].filter(Boolean).join(", ")||null:[f.property_address,f.city,f.state].filter(Boolean).join(", ")||null,D=(oe=_[0])==null?void 0:oe.photo_url,B=(m==null?void 0:m.tenants)??[],U=(m==null?void 0:m.spaces)??[],q=(m==null?void 0:m.demographics)??{},H=(m==null?void 0:m.traffic_counts)??[],K=(m==null?void 0:m.investment_highlights)??[],Q=(m==null?void 0:m.property_highlights)??[],J=["radius_1","radius_3","radius_5"].some(ye=>(q==null?void 0:q[ye])&&Object.values(q[ye]).some(Boolean)),ee=(ye,Ee)=>{a({kind:ye,documentId:Ee}),n1(f.id,ye==="om_request"?"om_request":ye,{})};return i.jsxs("div",{className:"min-h-screen bg-[#0b0f14] text-white antialiased",children:[i.jsxs(_o,{children:[i.jsx("title",{children:`${C} | ${I}`}),i.jsx("meta",{name:"description",content:(f.description??"").slice(0,155)||`${lie[(m==null?void 0:m.deal_type)??"sale"]} — ${I}`}),E&&i.jsx("meta",{name:"robots",content:"noindex,nofollow"}),i.jsx("meta",{property:"og:title",content:C}),i.jsx("meta",{property:"og:type",content:"website"})]}),i.jsx("header",{className:"fixed inset-x-0 top-0 z-40 border-b border-white/10 bg-[#0b0f14]/80 backdrop-blur",children:i.jsxs("div",{className:"mx-auto flex max-w-7xl items-center justify-between px-6 py-3.5 md:px-10",children:[i.jsxs("a",{href:typeof window<"u"&&window.location.hostname.startsWith("commercial.")?"/":"/public/commercial",className:"flex items-center gap-2 text-[11px] font-semibold uppercase tracking-[0.22em] text-white/70 transition-colors hover:text-white",children:[i.jsx("span",{"aria-hidden":!0,children:"←"})," All opportunities"]}),i.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-[0.22em] text-white/45",children:"LevelUp Commercial"})]})}),i.jsxs("section",{className:"relative min-h-[86vh] w-full overflow-hidden",children:[D?i.jsx("img",{src:D,alt:C,className:"absolute inset-0 h-full w-full object-cover"}):i.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-[#12202b] to-[#0b0f14]"}),i.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-[#0b0f14] via-[#0b0f14]/60 to-[#0b0f14]/30"}),i.jsxs("div",{className:"relative mx-auto flex min-h-[86vh] max-w-7xl flex-col justify-end px-6 pb-16 pt-24 md:px-10",children:[i.jsxs("div",{className:"mb-5 flex flex-wrap items-center gap-2.5",children:[i.jsx("span",{className:"rounded-full border border-white/25 px-3.5 py-1 text-[10px] font-semibold uppercase tracking-[0.22em]",children:lie[(m==null?void 0:m.deal_type)??"sale"]}),(m==null?void 0:m.commercial_type)&&i.jsx("span",{className:"rounded-full border border-white/15 bg-white/5 px-3.5 py-1 text-[10px] font-semibold uppercase tracking-[0.22em] text-white/70",children:R1e[m.commercial_type]}),E&&i.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full border border-amber-300/30 bg-amber-300/10 px-3.5 py-1 text-[10px] font-semibold uppercase tracking-[0.22em] text-amber-200",children:[i.jsx(zx,{className:"h-3 w-3"})," Confidential offering"]})]}),i.jsx("h1",{className:"max-w-4xl font-serif text-4xl leading-[1.05] tracking-tight md:text-6xl lg:text-7xl",children:C}),i.jsxs("p",{className:"mt-4 flex items-center gap-2 text-sm uppercase tracking-[0.2em] text-white/60",children:[i.jsx(ui,{className:"h-4 w-4"})," ",I]}),i.jsxs("div",{className:"mt-8 flex flex-wrap items-end gap-x-10 gap-y-5",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-[0.24em] text-white/45",children:(m==null?void 0:m.deal_type)==="lease"?"Lease rate":"Asking price"}),i.jsx("p",{className:"mt-1 text-3xl font-semibold tabular-nums md:text-4xl",children:uie(m,f.price)})]}),(m==null?void 0:m.cap_rate)!=null&&i.jsxs("div",{children:[i.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-[0.24em] text-white/45",children:"Cap rate"}),i.jsx("p",{className:"mt-1 text-3xl font-semibold tabular-nums md:text-4xl",children:L1e(m.cap_rate)})]})]}),i.jsxs("div",{className:"mt-9 flex flex-wrap gap-3",children:[i.jsxs(Lt,{size:"lg",className:"rounded-full px-7",onClick:()=>{var ye;return ee("om_request",((ye=y.find(Ee=>Ee.doc_kind==="om"))==null?void 0:ye.id)??null)},children:["Request Offering Memorandum ",i.jsx(ji,{className:"ml-2 h-4 w-4"})]}),i.jsx(Lt,{size:"lg",variant:"outline",className:"rounded-full border-white/25 bg-white/5 px-7 text-white hover:bg-white/10 hover:text-white",onClick:()=>ee("tour_request"),children:"Schedule a tour"})]})]})]}),A.length>0&&i.jsx("section",{className:"border-y border-white/10 bg-white/[0.02]",children:i.jsx("div",{className:"mx-auto grid max-w-7xl gap-px bg-white/10",style:{gridTemplateColumns:`repeat(${Math.min(A.length,4)}, minmax(0, 1fr))`},children:A.map(ye=>i.jsxs("div",{className:"bg-[#0b0f14] px-6 py-8",children:[i.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-[0.2em] text-white/40",children:ye.label}),i.jsx("p",{className:"mt-2 text-2xl font-semibold tabular-nums md:text-3xl",children:ye.value})]},ye.label))})}),K.length>0&&i.jsx(Fy,{eyebrow:"The opportunity",title:"Investment highlights",children:i.jsx("div",{className:"grid gap-x-12 gap-y-8 md:grid-cols-2",children:K.map((ye,Ee)=>i.jsxs("div",{className:"flex gap-5 border-t border-white/10 pt-6",children:[i.jsx("span",{className:"font-serif text-2xl text-white/25 tabular-nums",children:String(Ee+1).padStart(2,"0")}),i.jsx("p",{className:"text-lg leading-relaxed text-white/85",children:ye})]},Ee))})}),(f.description||Q.length>0)&&i.jsx(Fy,{eyebrow:"Property",title:"The asset",children:i.jsxs("div",{className:"grid gap-12 lg:grid-cols-[1.4fr_1fr]",children:[f.description&&i.jsx("div",{className:"space-y-5 text-lg leading-relaxed text-white/70",children:String(f.description).split(/\n{2,}/).map((ye,Ee)=>i.jsx("p",{children:ye},Ee))}),Q.length>0&&i.jsx("ul",{className:"space-y-3 self-start rounded-2xl border border-white/10 bg-white/[0.03] p-7",children:Q.map((ye,Ee)=>i.jsxs("li",{className:"flex gap-3 text-sm text-white/75",children:[i.jsx("span",{className:"mt-2 h-1 w-1 shrink-0 rounded-full bg-white/50"})," ",ye]},Ee))})]})}),_.length>1&&i.jsx(Fy,{eyebrow:"Gallery",title:"Property imagery",children:i.jsx("div",{className:"grid gap-3 md:grid-cols-3",children:_.slice(1,10).map((ye,Ee)=>i.jsx("button",{onClick:()=>{o(Ee+1),n1(f.id,"gallery_view",{})},className:`group relative overflow-hidden rounded-xl ${Ee===0?"md:col-span-2 md:row-span-2":""}`,children:i.jsx("img",{src:ye.photo_url,alt:`${C} — image ${Ee+2}`,loading:"lazy",className:`w-full object-cover transition-transform duration-700 group-hover:scale-[1.04] ${Ee===0?"h-full min-h-[280px] md:min-h-[560px]":"h-[180px] md:h-[275px]"}`})},ye.id))})}),((m==null?void 0:m.noi)||(m==null?void 0:m.gross_income)||(m==null?void 0:m.operating_expenses)||(m==null?void 0:m.occupancy_pct)!=null)&&i.jsxs(Fy,{eyebrow:"Financials",title:"Offering snapshot",children:[i.jsx("div",{className:"grid gap-px overflow-hidden rounded-2xl border border-white/10 bg-white/10 sm:grid-cols-2 lg:grid-cols-4",children:[{l:"Net operating income",v:Ef(m==null?void 0:m.noi)},{l:"Gross income",v:Ef(m==null?void 0:m.gross_income)},{l:"Operating expenses",v:Ef(m==null?void 0:m.operating_expenses)},{l:"Occupancy",v:(m==null?void 0:m.occupancy_pct)!=null?`${Math.round(Number(m.occupancy_pct))}%`:null},{l:"Price per SF",v:(m==null?void 0:m.price_per_sf)!=null?Ef(m.price_per_sf,2):null},{l:"Price per unit",v:Ef(m==null?void 0:m.price_per_unit)},{l:"Tenancy",v:m!=null&&m.tenancy?`${m.tenancy[0].toUpperCase()}${m.tenancy.slice(1)} tenant`:null},{l:"Broker co-op",v:(m==null?void 0:m.broker_coop_pct)!=null?`${m.broker_coop_pct}%`:null}].filter(ye=>ye.v).map(ye=>i.jsxs("div",{className:"bg-[#0b0f14] px-6 py-7",children:[i.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-[0.2em] text-white/40",children:ye.l}),i.jsx("p",{className:"mt-2 text-xl font-semibold tabular-nums",children:ye.v})]},ye.l))}),(m==null?void 0:m.call_for_offers_at)&&i.jsxs("p",{className:"mt-6 inline-flex items-center gap-2 rounded-full border border-amber-300/25 bg-amber-300/10 px-5 py-2 text-sm text-amber-100",children:["Call for offers · ",new Date(m.call_for_offers_at).toLocaleDateString(void 0,{month:"long",day:"numeric",year:"numeric"})]})]}),(B.length>0||U.length>0)&&i.jsx(Fy,{eyebrow:"Occupancy",title:U.length?"Space availability":"Tenant roster",children:i.jsx("div",{className:"overflow-hidden rounded-2xl border border-white/10",children:i.jsxs("table",{className:"w-full text-left text-sm",children:[i.jsx("thead",{className:"bg-white/[0.04] text-[10px] uppercase tracking-[0.18em] text-white/45",children:i.jsxs("tr",{children:[i.jsx("th",{className:"px-6 py-4",children:U.length?"Suite":"Tenant"}),i.jsx("th",{className:"px-6 py-4",children:"SF"}),i.jsx("th",{className:"px-6 py-4",children:U.length?"Rate":"Rent"}),i.jsx("th",{className:"px-6 py-4",children:U.length?"Availability":"Lease expiry"})]})}),i.jsx("tbody",{className:"divide-y divide-white/5",children:(U.length?U:B).map((ye,Ee)=>i.jsxs("tr",{className:"text-white/80",children:[i.jsx("td",{className:"px-6 py-4 font-medium text-white",children:ye.suite??ye.name??"—"}),i.jsx("td",{className:"px-6 py-4 tabular-nums",children:ye.sf?Cq(Number(ye.sf)):"—"}),i.jsx("td",{className:"px-6 py-4",children:ye.rate??ye.rent??"—"}),i.jsx("td",{className:"px-6 py-4",children:ye.availability??ye.lease_expiry??"—"})]},Ee))})]})})}),i.jsx(Fy,{eyebrow:"Location",title:m!=null&&m.submarket?`${m.submarket} submarket`:I,children:i.jsxs("div",{className:"grid gap-8 lg:grid-cols-[1.2fr_1fr]",children:[M?i.jsx("div",{className:"overflow-hidden rounded-2xl border border-white/10",children:i.jsx("iframe",{title:"Property location",className:"h-[420px] w-full",loading:"lazy",src:`https://www.google.com/maps?q=${encodeURIComponent(M)}&z=${f.latitude&&f.longitude?15:12}&output=embed`,onLoad:()=>n1(f.id,"map_view",{})})}):i.jsx("div",{className:"flex h-[420px] items-center justify-center rounded-2xl border border-white/10 bg-white/[0.03] text-center text-sm text-white/50",children:E?"Exact location released with the Offering Memorandum.":I}),i.jsxs("div",{className:"space-y-5",children:[(m==null?void 0:m.zoning)&&i.jsx(s1,{label:"Zoning",value:m.zoning}),(m==null?void 0:m.lot_acres)!=null&&i.jsx(s1,{label:"Site size",value:`${m.lot_acres} acres`}),(m==null?void 0:m.parking_spaces)!=null&&i.jsx(s1,{label:"Parking",value:`${m.parking_spaces} spaces`}),(m==null?void 0:m.opportunity_zone)&&i.jsx(s1,{label:"Opportunity Zone",value:"Qualified"}),H.filter(ye=>ye.road||ye.count).map((ye,Ee)=>i.jsx(s1,{label:`Traffic count — ${ye.road??"Adjacent road"}`,value:`${ye.count??"—"} VPD`},Ee)),!(m!=null&&m.zoning)&&(m==null?void 0:m.lot_acres)==null&&(m==null?void 0:m.parking_spaces)==null&&!(m!=null&&m.opportunity_zone)&&i.jsx(s1,{label:"Submarket",value:(m==null?void 0:m.submarket)||I})]})]})}),J&&i.jsx(Fy,{eyebrow:"Market",title:"Demographics",children:i.jsx("div",{className:"grid gap-4 md:grid-cols-3",children:[["radius_1","1 mile"],["radius_3","3 miles"],["radius_5","5 miles"]].map(([ye,Ee])=>{const Le=q==null?void 0:q[ye];return!Le||!Object.values(Le).some(Boolean)?null:i.jsxs("div",{className:"rounded-2xl border border-white/10 bg-white/[0.03] p-7",children:[i.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-[0.2em] text-white/40",children:Ee}),i.jsx("dl",{className:"mt-5 space-y-3 text-sm",children:[["Population",Le.population],["Households",Le.households],["Avg. income",Le.avg_income],["Daytime pop.",Le.daytime_pop]].filter(([,Se])=>Se).map(([Se,be])=>i.jsxs("div",{className:"flex justify-between gap-4",children:[i.jsx("dt",{className:"text-white/50",children:Se}),i.jsx("dd",{className:"font-medium tabular-nums",children:be})]},Se))})]},ye)})})}),y.length>0&&i.jsx(Fy,{eyebrow:"Deal room",title:"Offering documents",children:i.jsx("div",{className:"grid gap-4 md:grid-cols-2",children:y.map(ye=>{const Ee=ye.gate_level==="public";return i.jsxs("div",{className:"flex items-center gap-4 rounded-2xl border border-white/10 bg-white/[0.03] p-5 transition-colors hover:border-white/20",children:[i.jsx("div",{className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-xl border border-white/10 bg-white/5",children:Ee?i.jsx(mc,{className:"h-5 w-5"}):ye.gate_level==="nda"?i.jsx(o4,{className:"h-5 w-5"}):i.jsx(zx,{className:"h-5 w-5"})}),i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsx("p",{className:"truncate font-medium",children:ye.title||Het[ye.doc_kind||"other"]}),i.jsx("p",{className:"text-xs text-white/45",children:Ee?"Available to download":ye.gate_level==="nda"?"Confidentiality acknowledgement required":"Registration required"})]}),i.jsx(Lt,{size:"sm",variant:"outline",className:"border-white/20 bg-transparent text-white hover:bg-white/10 hover:text-white",onClick:()=>ee("om_request",ye.id),children:Ee?"Download":"Request"})]},ye.id)})})}),w&&i.jsx("section",{className:"border-t border-white/10 bg-white/[0.02]",children:i.jsx("div",{className:"mx-auto max-w-7xl px-6 py-20 md:px-10",children:i.jsxs("div",{className:"flex flex-col items-start gap-8 md:flex-row md:items-center md:justify-between",children:[i.jsxs("div",{className:"flex items-center gap-6",children:[w.avatar_url&&i.jsx("img",{src:w.avatar_url,alt:w.name,className:"h-24 w-24 rounded-full object-cover ring-1 ring-white/15"}),i.jsxs("div",{children:[i.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-[0.22em] text-white/40",children:"Exclusively listed by"}),i.jsx("p",{className:"mt-2 font-serif text-2xl",children:w.name}),i.jsx("p",{className:"text-sm text-white/55",children:((de=w.brokerage)==null?void 0:de.name)||w.brokerage_name})]})]}),i.jsxs("div",{className:"flex flex-wrap gap-3",children:[w.email&&i.jsxs(Lt,{variant:"outline",className:"rounded-full border-white/20 bg-transparent text-white hover:bg-white/10 hover:text-white",onClick:()=>{n1(f.id,"contact_click",{}),window.location.href=`mailto:${w.email}`},children:[i.jsx(rs,{className:"mr-2 h-4 w-4"})," Email"]}),w.phone&&i.jsxs(Lt,{variant:"outline",className:"rounded-full border-white/20 bg-transparent text-white hover:bg-white/10 hover:text-white",onClick:()=>{n1(f.id,"contact_click",{}),window.location.href=`tel:${w.phone}`},children:[i.jsx(Un,{className:"mr-2 h-4 w-4"})," Call"]}),i.jsx(Lt,{className:"rounded-full",onClick:()=>ee("investor_inquiry"),children:"Request information"})]})]})})}),i.jsx("footer",{className:"border-t border-white/10 py-10 text-center text-xs text-white/35",children:i.jsx("p",{children:"The information contained herein has been obtained from sources believed reliable but is not guaranteed. Prospective purchasers and tenants should conduct their own independent investigation."})}),i.jsx("div",{className:"sticky bottom-0 z-30 border-t border-white/10 bg-[#0b0f14]/90 backdrop-blur-xl",children:i.jsxs("div",{className:"mx-auto flex max-w-7xl flex-wrap items-center justify-between gap-3 px-6 py-3.5 md:px-10",children:[i.jsxs("div",{className:"min-w-0",children:[i.jsx("p",{className:"truncate text-sm font-medium",children:C}),i.jsxs("p",{className:"truncate text-xs text-white/50",children:[uie(m,f.price)," · ",I]})]}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(Lt,{size:"sm",variant:"outline",className:"rounded-full border-white/20 bg-transparent text-white hover:bg-white/10 hover:text-white",onClick:()=>ee("tour_request"),children:"Tour"}),i.jsx(Lt,{size:"sm",className:"rounded-full",onClick:()=>{var ye;return ee("om_request",((ye=y.find(Ee=>Ee.doc_kind==="om"))==null?void 0:ye.id)??null)},children:"Request OM"})]})]})}),i.jsx(Ha,{open:s!==null,onOpenChange:ye=>!ye&&o(null),children:i.jsx(Ra,{className:"max-w-[96vw] border-none bg-transparent p-0 shadow-none",children:s!==null&&_[s]&&i.jsxs("div",{className:"relative",children:[i.jsx("img",{src:_[s].photo_url,alt:"",className:"max-h-[88vh] w-full rounded-xl object-contain"}),i.jsx("button",{className:"absolute right-3 top-3 rounded-full bg-black/60 p-2",onClick:()=>o(null),children:i.jsx(Ci,{className:"h-5 w-5"})}),i.jsx("button",{className:"absolute left-3 top-1/2 -translate-y-1/2 rounded-full bg-black/60 p-2",onClick:()=>o(ye=>(ye-1+_.length)%_.length),children:i.jsx(ip,{className:"h-6 w-6"})}),i.jsx("button",{className:"absolute right-3 top-1/2 -translate-y-1/2 rounded-full bg-black/60 p-2",onClick:()=>o(ye=>(ye+1)%_.length),children:i.jsx(Vd,{className:"h-6 w-6"})})]})})}),c&&i.jsx(Xet,{open:!0,onOpenChange:ye=>!ye&&a(null),listingId:f.id,kind:c.kind,documentId:c.documentId,requiresNda:!!(m!=null&&m.requires_nda)||(m==null?void 0:m.om_gate_mode)==="nda",brokerName:w==null?void 0:w.name})]})}function Fy({eyebrow:t,title:e,children:r}){return i.jsx("section",{className:"border-t border-white/10",children:i.jsxs("div",{className:"mx-auto max-w-7xl px-6 py-20 md:px-10 md:py-24",children:[i.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-[0.24em] text-white/40",children:t}),i.jsx("h2",{className:"mt-3 font-serif text-3xl tracking-tight md:text-4xl",children:e}),i.jsx("div",{className:"mt-12",children:r})]})})}function s1({label:t,value:e}){return i.jsxs("div",{className:"border-t border-white/10 pt-4",children:[i.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-[0.2em] text-white/40",children:t}),i.jsx("p",{className:"mt-1 text-lg",children:e})]})}const hie="/assets/levelup-logo-color-BeKd2k_g.png",ett={active:"bg-emerald-500",coming_soon:"bg-sky-500",office_exclusive:"bg-indigo-500",temp_off_market:"bg-amber-600",withdrawn:"bg-slate-500",pre_market:"bg-cyan-500",price_improvement:"bg-orange-500",under_contract:"bg-purple-500",sold:"bg-gray-600"},x6={active:"For Sale",coming_soon:"Coming Soon",office_exclusive:"Office Exclusive",temp_off_market:"Temporarily Off Market",withdrawn:"Withdrawn",pre_market:"Pre-Market",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"},fie={single_family:"Single Family",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury",commercial:"Commercial",other:"Other"},_6=t=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(t),ik=t=>new Intl.NumberFormat("en-US").format(t);function O1e(t){var e,r;if(!t)return null;try{const n=new URL(t.trim()),s=n.hostname.replace(/^www\.|^m\./,"");let o=null;if(s==="youtu.be"?o=n.pathname.slice(1).split("/")[0]:(s==="youtube.com"||s==="youtube-nocookie.com")&&(o=n.searchParams.get("v")||((e=n.pathname.match(/\/(?:embed|shorts|live)\/([^/?]+)/))==null?void 0:e[1])||null),o&&/^[\w-]{6,20}$/.test(o))return`https://www.youtube.com/embed/${o}`;if(s==="vimeo.com"||s==="player.vimeo.com"){const c=(r=n.pathname.match(/(\d{5,})/))==null?void 0:r[1];if(c)return`https://player.vimeo.com/video/${c}`}return null}catch{return null}}function uK({slugOverride:t}={}){var $i,Cr,Bn,wi,ii,ia,Xr;const e=Vf(),r=t||e.slugOrId,[n]=c0(),{data:s,isLoading:o}=Bet(r||""),c=$et(),a=zet(),f=n.get("ref"),[m,y]=N.useState(""),[_,w]=N.useState(""),[E,A]=N.useState(""),[C,I]=N.useState(""),[M,D]=N.useState(""),[B,U]=N.useState(""),[q,H]=N.useState(""),[K,Q]=N.useState("in_person"),[J,ee]=N.useState("info"),[oe,de]=N.useState(!1),[ye,Ee]=N.useState(!1),[Le,Se]=N.useState(null),[be,me]=N.useState(!1);N.useState(!1);const[ke,Pe]=N.useState(!1),[je,xe]=N.useState(20),[Ue,Ze]=N.useState(6.5),[lt,wt]=N.useState(30),yt=N.useRef(null),[gt,ft]=N.useState(!1);N.useEffect(()=>{const un=()=>ft(window.scrollY>300);return window.addEventListener("scroll",un,{passive:!0}),()=>window.removeEventListener("scroll",un)},[]),N.useEffect(()=>{f&&a.mutate(f)},[f]),N.useEffect(()=>{window.scrollTo({top:0,left:0,behavior:"auto"})},[r]);const kt=(s==null?void 0:s.photos)||[],Vt=kt.find(un=>un.is_primary)||kt[0],xt=N.useMemo(()=>{if(!(s!=null&&s.price))return 0;const un=s.price*(1-je/100),xn=Ue/100/12,Qr=lt*12;return xn===0?un/Qr:un*xn/(1-Math.pow(1+xn,-Qr))},[s==null?void 0:s.price,je,Ue,lt]),or=async()=>{const un=window.location.href;if(navigator.share)try{await navigator.share({title:document.title,url:un})}catch{}else await navigator.clipboard.writeText(un),$t.success("Link copied to clipboard")},Sr=async un=>{if(un.preventDefault(),!m.trim()||!E.trim()||!s)return;const xn=J==="showing";if(xn&&!B){$t.error("Please pick a preferred date for your showing");return}de(!0);try{await c.mutateAsync({listingId:s.id,agentId:s.agent_id,firstName:m.trim(),lastName:_.trim(),email:E.trim(),phone:C.trim(),shareToken:f,leadType:xn?"showing_request":"info_request",preferredDate:xn?B:null,preferredTime:xn&&q||null,showingMode:xn?K:null,message:M.trim()||null}),Ee(!0),$t.success(xn?"Showing request sent! The agent will confirm details shortly.":"Thanks! The agent will be in touch soon.")}catch(Qr){console.error("Lead submission error:",Qr),$t.error(`Failed to submit: ${Qr.message||"Please try again"}`)}finally{de(!1)}},rn=()=>{Le!==null&&Se(Le===0?kt.length-1:Le-1)},Rr=()=>{Le!==null&&Se(Le===kt.length-1?0:Le+1)};if((s==null?void 0:s.listing_class)==="commercial")return i.jsx(Jet,{slug:r});if(o)return i.jsx("div",{className:"min-h-screen bg-neutral-950",children:i.jsx(jl,{className:"h-[100svh] w-full rounded-none bg-neutral-900"})});if(!s)return i.jsxs("div",{className:"min-h-screen bg-background",children:[i.jsx("header",{className:"border-b bg-card",children:i.jsx("div",{className:"container mx-auto px-4 py-4",children:i.jsx(Br,{to:"/public/listings",className:"flex items-center gap-2",children:i.jsx("img",{src:hie,alt:"LevelUp",className:"h-8"})})})}),i.jsxs("div",{className:"container mx-auto px-4 py-24 text-center",children:[i.jsx(ea,{className:"h-16 w-16 mx-auto text-muted-foreground mb-4"}),i.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Listing Not Found"}),i.jsx("p",{className:"text-muted-foreground mb-6",children:"This listing may no longer be available."}),i.jsx(Lt,{asChild:!0,children:i.jsx(Br,{to:typeof window<"u"&&window.location.host==="listings.relevelup.com"?"/":"/public/listings",children:"Browse All Listings"})})]})]});const $r=s.property_address?`${s.property_address} — ${s.city}, ${s.state}`:`${s.city}, ${s.state} Home for Sale`,qr=((Cr=($i=s.agent)==null?void 0:$i.brokerage)==null?void 0:Cr.name)||((Bn=s.agent)==null?void 0:Bn.brokerage_name),Nn=((wi=s.agent)==null?void 0:wi.name)||"",tt=O1e(s.video_link),Tt=qr||Nn||"",Zt=x6[s.status]==="Sold"?"Just Sold":x6[s.status],ar=Zt?`${Zt}: ${$r}`:$r,Wt=[`${_6(s.price)} · ${s.city}, ${s.state}`,Nn?`Presented by ${Nn}${qr?`, ${qr}`:""}.`:""].filter(Boolean).join(" · "),Kt=s.latitude&&s.longitude?`https://maps.google.com/maps?q=${s.latitude},${s.longitude}&z=15&output=embed`:s.property_address?`https://maps.google.com/maps?q=${encodeURIComponent(`${s.property_address}, ${s.city}, ${s.state}`)}&z=15&output=embed`:null,At=s.description||"",pr=At.length>420,yn=ke||!pr?At:At.slice(0,420).trimEnd()+"…",Gn=s.page_config||{},Fn=un=>{var xn;return(((xn=Gn.sections)==null?void 0:xn[un])??!0)!==!1},Rs=Array.isArray(Gn.addons)?Gn.addons:[],sa=Gn.custom_note||"",gs=Gn.accent_color||null;return i.jsxs(i.Fragment,{children:[i.jsxs(_o,{children:[i.jsx("title",{children:Tt?`${$r} | ${Tt}`:$r}),i.jsx("meta",{name:"description",content:`${_6(s.price)} · ${s.bedrooms||""}BD ${s.bathrooms||""}BA ${s.square_footage?s.square_footage.toLocaleString()+" sqft · ":""}${fie[s.property_type]} in ${s.city}, ${s.state}. ${At.slice(0,140)}`}),i.jsx("link",{rel:"canonical",href:`https://listings.relevelup.com/${s.slug||s.id}`}),i.jsx("link",{rel:"preconnect",href:"https://fonts.googleapis.com"}),i.jsx("link",{rel:"preconnect",href:"https://fonts.gstatic.com",crossOrigin:""}),i.jsx("link",{href:"https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,300;9..144,400;9..144,500;9..144,600&display=swap",rel:"stylesheet"}),i.jsx("meta",{property:"og:title",content:ar}),i.jsx("meta",{property:"og:description",content:Wt}),i.jsx("meta",{property:"og:type",content:"website"}),i.jsx("meta",{property:"og:url",content:`https://listings.relevelup.com/${s.slug||s.id}`}),Vt&&i.jsx("meta",{property:"og:image",content:Vt.photo_url}),Tt&&i.jsx("meta",{property:"og:site_name",content:Tt}),i.jsx("meta",{name:"twitter:card",content:"summary_large_image"}),i.jsx("meta",{name:"twitter:title",content:ar}),i.jsx("meta",{name:"twitter:description",content:Wt}),Vt&&i.jsx("meta",{name:"twitter:image",content:Vt.photo_url}),i.jsx("meta",{name:"robots",content:"index, follow"}),i.jsx("script",{type:"application/ld+json",children:JSON.stringify({"@context":"https://schema.org","@type":"RealEstateListing",name:s.property_address||`${s.city}, ${s.state} Home`,description:At,url:`https://listings.relevelup.com/${s.slug||s.id}`,datePosted:s.created_at,image:kt.map(un=>un.photo_url),address:{"@type":"PostalAddress",streetAddress:s.property_address||void 0,addressLocality:s.city,addressRegion:s.state,addressCountry:"US"},offers:{"@type":"Offer",price:s.price,priceCurrency:"USD",availability:s.status==="sold"?"https://schema.org/SoldOut":s.status==="under_contract"?"https://schema.org/LimitedAvailability":"https://schema.org/InStock"},numberOfRooms:s.bedrooms||void 0,numberOfBathroomsTotal:s.bathrooms||void 0,floorSize:s.square_footage?{"@type":"QuantitativeValue",value:s.square_footage,unitCode:"FTK"}:void 0,yearBuilt:s.year_built||void 0})}),i.jsx("style",{children:` .font-display { font-family: 'Fraunces', ui-serif, Georgia, serif; font-optical-sizing: auto; letter-spacing: -0.02em; } @keyframes kb-zoom { from { transform: scale(1.08); } to { transform: scale(1); } } .kb-zoom { animation: kb-zoom 12s ease-out forwards; } .noscroll::-webkit-scrollbar { display: none; } `})]}),i.jsxs("div",{className:"bg-neutral-950 text-neutral-100 min-h-screen",children:[i.jsx("header",{className:`fixed inset-x-0 top-0 z-40 transition-all duration-300 ${gt?"bg-neutral-950/85 backdrop-blur-xl border-b border-white/10 py-3":"bg-gradient-to-b from-black/60 to-transparent py-4"}`,children:i.jsxs("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 flex items-center justify-between gap-3",children:[i.jsxs(Br,{to:typeof window<"u"&&window.location.host==="listings.relevelup.com"?"/":"/public/listings",className:"flex items-center gap-2 text-white/90 hover:text-white",children:[i.jsx($x,{className:"h-4 w-4"}),i.jsx("span",{className:"text-sm font-medium hidden sm:inline",children:"All Listings"})]}),gt&&i.jsx("div",{className:"hidden md:flex items-center gap-1 text-sm",children:[["overview","Overview"],["gallery","Gallery"],["story","The Story"],["video","Video"],["map","Location"],["payment","Payment"],["agent","Agent"]].map(([un,xn])=>i.jsx("a",{href:`#${un}`,className:"px-3 py-1.5 rounded-full text-white/70 hover:text-white hover:bg-white/10 transition",children:xn},un))}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(get,{listingId:s.id,listingAddress:s.property_address?`${s.property_address}, ${s.city}, ${s.state}`:`${s.city}, ${s.state}`,className:"h-9 w-9 rounded-full border border-white/20 bg-white/5 backdrop-blur hover:bg-white/15 flex items-center justify-center transition text-white"}),i.jsx("button",{onClick:or,className:"h-9 w-9 rounded-full border border-white/20 bg-white/5 backdrop-blur hover:bg-white/15 flex items-center justify-center transition","aria-label":"Share",children:i.jsx(xC,{className:"h-4 w-4 text-white"})}),i.jsx(Lt,{size:"sm",onClick:()=>me(!0),className:"hidden sm:inline-flex bg-white text-neutral-900 hover:bg-white/90 rounded-full h-9 px-4 font-medium",children:"Request Tour"})]})]})}),i.jsxs("section",{ref:yt,id:"overview",className:"relative h-[100svh] min-h-[620px] w-full overflow-hidden",children:[Vt?i.jsx("img",{src:Vt.photo_url,alt:s.property_address||`${s.city}, ${s.state}`,className:"absolute inset-0 h-full w-full object-cover kb-zoom"}):i.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-neutral-800 to-neutral-950"}),i.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black via-black/50 to-black/20"}),i.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-black/40 via-transparent to-transparent"}),i.jsxs("div",{className:"absolute top-24 right-4 sm:right-8 z-10 flex flex-col items-end gap-2",children:[i.jsx(pi,{className:`${ett[s.status]} text-white border-0 uppercase tracking-widest text-[10px] px-3 py-1 rounded-full shadow-lg`,children:x6[s.status]}),kt.length>0&&i.jsxs("button",{onClick:()=>Se(0),className:"flex items-center gap-1.5 text-xs text-white/90 bg-black/40 backdrop-blur border border-white/20 rounded-full px-3 py-1.5 hover:bg-black/60 transition",children:[i.jsx(Gre,{className:"h-3.5 w-3.5"}),kt.length," photos"]})]}),i.jsx("div",{className:"absolute inset-x-0 bottom-0 z-10 px-4 sm:px-8 pb-10 sm:pb-14",children:i.jsxs("div",{className:"max-w-7xl mx-auto",children:[i.jsxs("div",{className:"flex items-end justify-between gap-6 flex-wrap",children:[i.jsxs("div",{className:"max-w-3xl",children:[s.neighborhood&&i.jsxs("p",{className:"text-white/70 uppercase tracking-[0.25em] text-xs mb-3 font-medium",children:[s.neighborhood," · ",s.city,", ",s.state]}),s.property_address&&i.jsx("h1",{className:"font-display text-white text-4xl sm:text-6xl md:text-7xl leading-[0.95] mb-4 font-light",children:s.property_address}),!s.property_address&&i.jsxs("h1",{className:"font-display text-white text-4xl sm:text-6xl md:text-7xl leading-[0.95] mb-4 font-light",children:[s.city,", ",s.state]}),i.jsxs("div",{className:"flex items-center gap-4 flex-wrap",children:[i.jsx("p",{className:"font-display text-white text-3xl sm:text-4xl md:text-5xl font-medium",children:_6(s.price)}),i.jsx("div",{className:"h-8 w-px bg-white/30 hidden sm:block"}),i.jsxs("div",{className:"flex items-center gap-4 text-white/80 text-sm sm:text-base",children:[s.bedrooms&&i.jsxs("span",{children:[i.jsx("span",{className:"font-semibold text-white",children:s.bedrooms})," bd"]}),s.bathrooms&&i.jsxs("span",{children:[i.jsx("span",{className:"font-semibold text-white",children:s.bathrooms})," ba"]}),s.square_footage&&i.jsxs("span",{children:[i.jsx("span",{className:"font-semibold text-white",children:ik(s.square_footage)})," sqft"]})]})]})]}),i.jsxs("div",{className:"hidden md:flex flex-col gap-2",children:[s.agent&&i.jsxs("div",{className:"flex items-center gap-3 bg-white/10 backdrop-blur-xl border border-white/20 rounded-2xl px-4 py-3 shadow-2xl",children:[s.agent.avatar_url?i.jsx("img",{src:s.agent.avatar_url,alt:s.agent.name,className:"h-12 w-12 rounded-full object-cover"}):i.jsx("div",{className:"h-12 w-12 rounded-full bg-white/20 flex items-center justify-center",children:i.jsx(Gl,{className:"h-6 w-6 text-white"})}),i.jsxs("div",{className:"pr-2 flex-1",children:[i.jsx("p",{className:"text-[11px] uppercase tracking-widest text-white/60",children:"Listing Agent"}),i.jsx("p",{className:"text-white font-medium leading-tight",children:s.agent.name}),qr&&i.jsx("p",{className:"text-xs text-white/60",children:qr})]}),i.jsx(Lt,{size:"sm",onClick:()=>me(!0),className:"bg-white text-neutral-900 hover:bg-white/90 rounded-full h-9 px-4",children:"Contact"})]}),s.co_agent_name&&i.jsxs("div",{className:"flex items-center gap-3 bg-white/10 backdrop-blur-xl border border-white/20 rounded-2xl px-4 py-3 shadow-2xl",children:[s.co_agent_photo_url?i.jsx("img",{src:s.co_agent_photo_url,alt:s.co_agent_name,className:"h-12 w-12 rounded-full object-cover"}):i.jsx("div",{className:"h-12 w-12 rounded-full bg-white/20 flex items-center justify-center",children:i.jsx(Gl,{className:"h-6 w-6 text-white"})}),i.jsxs("div",{className:"pr-2 flex-1",children:[i.jsx("p",{className:"text-[11px] uppercase tracking-widest text-white/60",children:"Co-Listing Agent"}),i.jsx("p",{className:"text-white font-medium leading-tight",children:s.co_agent_name}),s.co_agent_brokerage&&i.jsx("p",{className:"text-xs text-white/60",children:s.co_agent_brokerage})]}),(s.co_agent_phone||s.co_agent_email)&&i.jsx(Lt,{asChild:!0,size:"sm",className:"bg-white text-neutral-900 hover:bg-white/90 rounded-full h-9 px-4",children:i.jsx("a",{href:s.co_agent_phone?`tel:${s.co_agent_phone}`:`mailto:${s.co_agent_email}`,children:"Contact"})})]})]})]}),i.jsxs("div",{className:"mt-10 flex items-center gap-2 text-white/50 text-xs uppercase tracking-widest",children:[i.jsx("span",{className:"h-px w-8 bg-white/30"}),"Scroll to explore"]})]})})]}),Fn("stats")&&i.jsx("section",{className:"border-b border-white/10 bg-neutral-950",children:i.jsx("div",{className:"max-w-7xl mx-auto px-4 sm:px-8 py-8 grid grid-cols-2 md:grid-cols-5 gap-6",children:[s.bedrooms&&{icon:UT,label:"Bedrooms",value:s.bedrooms},s.bathrooms&&{icon:o0,label:"Bathrooms",value:s.bathrooms},s.square_footage&&{icon:vH,label:"Interior",value:`${ik(s.square_footage)} sqft`},s.lot_size&&{icon:yC,label:"Lot Size",value:s.lot_size},s.year_built&&{icon:xo,label:"Year Built",value:s.year_built},!s.year_built&&s.square_footage&&{icon:h8,label:"Price / sqft",value:`$${ik(Math.round(s.price/s.square_footage))}`}].filter(Boolean).slice(0,5).map((un,xn)=>i.jsxs("div",{className:"flex items-start gap-3",children:[i.jsx("div",{className:"h-10 w-10 rounded-full bg-white/5 border border-white/10 flex items-center justify-center shrink-0",children:i.jsx(un.icon,{className:"h-4 w-4 text-white/70"})}),i.jsxs("div",{children:[i.jsx("p",{className:"text-[11px] uppercase tracking-widest text-white/50",children:un.label}),i.jsx("p",{className:"font-display text-2xl text-white font-light",children:un.value})]})]},xn))})}),i.jsxs("div",{className:"max-w-7xl mx-auto px-4 sm:px-8 py-16 grid lg:grid-cols-3 gap-12",children:[i.jsxs("div",{className:"lg:col-span-2 space-y-20",children:[Fn("story")&&At&&i.jsxs("section",{id:"story",children:[i.jsx("p",{className:"text-[11px] uppercase tracking-[0.3em] text-white/40 mb-3",children:"The Story"}),i.jsx("h2",{className:"font-display text-3xl sm:text-4xl font-light mb-6 text-white",children:"A closer look at this home"}),i.jsx("div",{className:"prose prose-invert prose-lg max-w-none",children:i.jsx("p",{className:"text-white/75 leading-relaxed whitespace-pre-wrap",children:yn})}),pr&&i.jsx("button",{onClick:()=>Pe(!ke),className:"mt-4 text-sm text-white/60 hover:text-white underline underline-offset-4",children:ke?"Show less":"Read more"}),i.jsxs("div",{className:"mt-8 flex flex-wrap gap-2",children:[i.jsxs(pi,{variant:"outline",className:"border-white/20 text-white/80 bg-white/5",children:[i.jsx(Ja,{className:"h-3 w-3 mr-1.5"}),fie[s.property_type]]}),s.has_hoa&&i.jsx(pi,{variant:"outline",className:"border-white/20 text-white/80 bg-white/5",children:"HOA"}),s.mls_link&&i.jsx(Lt,{variant:"outline",size:"sm",asChild:!0,className:"ml-2 border-white/20 bg-white/5 text-white hover:bg-white/15",children:i.jsxs("a",{href:s.mls_link,target:"_blank",rel:"noopener noreferrer",children:[i.jsx(sb,{className:"h-3.5 w-3.5 mr-1.5"})," MLS"]})})]}),(sa||s.agent_notes&&s.agent_notes_public)&&i.jsxs("div",{className:"mt-10 rounded-2xl border border-white/10 bg-white/5 p-6",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[i.jsx(ki,{className:"h-4 w-4 text-amber-300"}),i.jsx("p",{className:"text-[11px] uppercase tracking-[0.25em] text-white/60",children:"A note from the agent"})]}),i.jsxs("p",{className:"text-white/80 whitespace-pre-wrap leading-relaxed italic font-display",children:['"',sa||s.agent_notes,'"']})]})]}),Fn("gallery")&&kt.length>1&&i.jsxs("section",{id:"gallery",children:[i.jsxs("div",{className:"flex items-end justify-between mb-6",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-[11px] uppercase tracking-[0.3em] text-white/40 mb-2",children:"Gallery"}),i.jsx("h2",{className:"font-display text-3xl sm:text-4xl font-light text-white",children:"Every angle, every detail"})]}),i.jsxs("button",{onClick:()=>Se(0),className:"text-sm text-white/60 hover:text-white underline underline-offset-4 hidden sm:inline",children:["View all ",kt.length]})]}),i.jsx("div",{className:"grid grid-cols-4 gap-2 sm:gap-3",children:kt.slice(0,7).map((un,xn)=>{const Qr=["col-span-4 sm:col-span-2 sm:row-span-2 aspect-square sm:aspect-auto","col-span-2 sm:col-span-2 aspect-[4/3]","col-span-2 sm:col-span-2 aspect-[4/3]","col-span-2 sm:col-span-1 aspect-square","col-span-2 sm:col-span-1 aspect-square","col-span-2 sm:col-span-1 aspect-square","col-span-2 sm:col-span-1 aspect-square"],ls=xn===6&&kt.length>7;return i.jsxs("button",{onClick:()=>Se(xn),className:`${Qr[xn]} relative rounded-xl overflow-hidden group bg-neutral-900`,children:[i.jsx("img",{src:un.photo_url,alt:`Photo ${xn+1}`,className:"absolute inset-0 h-full w-full object-cover group-hover:scale-[1.04] transition-transform duration-500"}),ls&&i.jsxs("div",{className:"absolute inset-0 bg-black/60 flex flex-col items-center justify-center text-white",children:[i.jsx(Gre,{className:"h-6 w-6 mb-1"}),i.jsxs("span",{className:"font-medium",children:["+",kt.length-7," more"]})]})]},un.id)})})]}),Fn("video")&&!((ii=s.video)!=null&&ii.playback_url)&&tt&&i.jsxs("section",{id:"video",children:[i.jsx("p",{className:"text-[11px] uppercase tracking-[0.3em] text-white/40 mb-2",children:"Video Tour"}),i.jsx("h2",{className:"font-display text-3xl sm:text-4xl font-light text-white mb-6",children:"Walk through the home"}),i.jsx("div",{className:"relative rounded-2xl overflow-hidden bg-black shadow-2xl aspect-video",children:i.jsx("iframe",{src:tt,className:"absolute inset-0 h-full w-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,title:"Video Tour"})})]}),Fn("video")&&((ia=s.video)==null?void 0:ia.playback_url)&&i.jsxs("section",{id:"video",children:[i.jsx("p",{className:"text-[11px] uppercase tracking-[0.3em] text-white/40 mb-2",children:"Video Tour"}),i.jsx("h2",{className:"font-display text-3xl sm:text-4xl font-light text-white mb-6",children:"Walk through the home"}),i.jsx("div",{className:"relative rounded-2xl overflow-hidden bg-black shadow-2xl aspect-video",children:i.jsx("iframe",{src:s.video.playback_url,className:"absolute inset-0 h-full w-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,title:"Video Tour"})})]}),Fn("map")&&Kt&&i.jsxs("section",{id:"map",children:[i.jsx("p",{className:"text-[11px] uppercase tracking-[0.3em] text-white/40 mb-2",children:"Location"}),i.jsxs("h2",{className:"font-display text-3xl sm:text-4xl font-light text-white mb-6",children:[s.neighborhood?s.neighborhood:s.city,", ",s.state]}),i.jsx("div",{className:"rounded-2xl overflow-hidden border border-white/10 shadow-2xl aspect-[16/10]",children:i.jsx("iframe",{src:Kt,className:"w-full h-full grayscale-[.2] contrast-[1.05]",loading:"lazy",title:"Map"})}),i.jsxs("div",{className:"mt-4 flex items-center gap-2 text-white/60 text-sm",children:[i.jsx(ui,{className:"h-4 w-4"}),s.property_address?`${s.property_address}, `:"",s.city,", ",s.state]})]}),Fn("payment")&&i.jsxs("section",{id:"payment",children:[i.jsx("p",{className:"text-[11px] uppercase tracking-[0.3em] text-white/40 mb-2",children:"Payment"}),i.jsx("h2",{className:"font-display text-3xl sm:text-4xl font-light text-white mb-6",children:"Estimate your monthly"}),i.jsxs("div",{className:"rounded-2xl border border-white/10 bg-gradient-to-br from-white/5 to-transparent p-6 sm:p-8",children:[i.jsxs("div",{className:"flex items-baseline gap-3 mb-8",children:[i.jsxs("p",{className:"font-display text-5xl sm:text-6xl font-light text-white",children:["$",ik(Math.round(xt))]}),i.jsx("p",{className:"text-white/60",children:"/ month"})]}),i.jsxs("div",{className:"grid sm:grid-cols-3 gap-8",children:[i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center justify-between mb-2",children:[i.jsx(Fr,{className:"text-white/70 text-xs uppercase tracking-widest",children:"Down Payment"}),i.jsxs("span",{className:"text-white font-medium",children:[je,"%"]})]}),i.jsx(Gm,{value:[je],onValueChange:un=>xe(un[0]),min:0,max:50,step:1}),i.jsxs("p",{className:"text-xs text-white/50 mt-2",children:["$",ik(Math.round(s.price*je/100))," down"]})]}),i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center justify-between mb-2",children:[i.jsx(Fr,{className:"text-white/70 text-xs uppercase tracking-widest",children:"Interest Rate"}),i.jsxs("span",{className:"text-white font-medium",children:[Ue.toFixed(2),"%"]})]}),i.jsx(Gm,{value:[Ue],onValueChange:un=>Ze(un[0]),min:2,max:10,step:.125})]}),i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center justify-between mb-2",children:[i.jsx(Fr,{className:"text-white/70 text-xs uppercase tracking-widest",children:"Loan Term"}),i.jsxs("span",{className:"text-white font-medium",children:[lt," yr"]})]}),i.jsx(Gm,{value:[lt],onValueChange:un=>wt(un[0]),min:10,max:30,step:5})]})]}),i.jsx("p",{className:"text-xs text-white/40 mt-6",children:"Estimated principal & interest only. Taxes, insurance, and HOA not included."})]})]}),Rs.map(un=>{const xn=un.type,Qr=un.data||{};if(xn==="extra_video"&&Qr.url){const ls=String(Qr.url).includes("youtu")?`https://www.youtube.com/embed/${String(Qr.url).split(/[/=]/).pop()}`:Qr.url;return i.jsxs("section",{children:[i.jsx("p",{className:"text-[11px] uppercase tracking-[0.3em] text-white/40 mb-2",children:Qr.eyebrow||"Featured Video"}),i.jsx("h2",{className:"font-display text-3xl sm:text-4xl font-light text-white mb-6",children:Qr.title||"Watch"}),i.jsx("div",{className:"relative rounded-2xl overflow-hidden bg-black shadow-2xl aspect-video",children:i.jsx("iframe",{src:ls,className:"absolute inset-0 h-full w-full",allowFullScreen:!0,title:Qr.title||"Video"})})]},un.id)}return xn==="3d_tour"&&Qr.url?i.jsxs("section",{children:[i.jsx("p",{className:"text-[11px] uppercase tracking-[0.3em] text-white/40 mb-2",children:"3D Tour"}),i.jsx("h2",{className:"font-display text-3xl sm:text-4xl font-light text-white mb-6",children:Qr.title||"Step inside"}),i.jsx("div",{className:"relative rounded-2xl overflow-hidden bg-black shadow-2xl aspect-video",children:i.jsx("iframe",{src:Qr.url,className:"absolute inset-0 h-full w-full",allowFullScreen:!0,title:"3D Tour"})})]},un.id):xn==="floor_plan"&&Qr.image_url?i.jsxs("section",{children:[i.jsx("p",{className:"text-[11px] uppercase tracking-[0.3em] text-white/40 mb-2",children:"Floor Plan"}),i.jsx("h2",{className:"font-display text-3xl sm:text-4xl font-light text-white mb-6",children:Qr.title||"Layout"}),i.jsx("img",{src:Qr.image_url,alt:"Floor plan",className:"w-full rounded-2xl border border-white/10"})]},un.id):xn==="testimonial"&&Qr.quote?i.jsxs("section",{className:"rounded-2xl border border-white/10 bg-white/[0.03] p-8",children:[i.jsxs("p",{className:"font-display italic text-2xl text-white/90 leading-relaxed",children:['"',Qr.quote,'"']}),Qr.author&&i.jsxs("p",{className:"mt-4 text-sm text-white/60",children:["— ",Qr.author]})]},un.id):xn==="custom_cta"&&Qr.label?i.jsxs("section",{className:"rounded-2xl p-8 text-center",style:{background:gs?`${gs}22`:"rgba(255,255,255,0.05)",border:`1px solid ${gs||"rgba(255,255,255,0.1)"}`},children:[Qr.title&&i.jsx("h3",{className:"font-display text-3xl text-white mb-4",children:Qr.title}),i.jsx(Lt,{asChild:!0,size:"lg",style:gs?{background:gs}:void 0,children:i.jsx("a",{href:Qr.url||"#agent",children:Qr.label})})]},un.id):null})]}),i.jsxs("aside",{id:"agent",className:"lg:sticky lg:top-24 lg:self-start space-y-6",children:[i.jsx(Vet,{listingId:s.id}),s.agent&&i.jsxs("div",{className:"rounded-2xl border border-white/10 bg-white/[0.03] p-6 backdrop-blur",children:[i.jsxs("div",{className:"flex items-start gap-4",children:[s.agent.avatar_url?i.jsx("img",{src:s.agent.avatar_url,alt:s.agent.name,className:"h-16 w-16 rounded-full object-cover border-2 border-white/20"}):i.jsx("div",{className:"h-16 w-16 rounded-full bg-white/10 flex items-center justify-center border-2 border-white/20",children:i.jsx(Gl,{className:"h-7 w-7 text-white/70"})}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("p",{className:"text-[10px] uppercase tracking-widest text-white/50",children:"Listing Agent"}),i.jsx("p",{className:"font-display text-xl text-white font-medium leading-tight",children:s.agent.name}),qr&&i.jsx("p",{className:"text-sm text-white/60 mt-0.5",children:qr})]})]}),i.jsxs("div",{className:"mt-4 grid grid-cols-2 gap-2",children:[s.agent.phone&&i.jsx(Lt,{asChild:!0,variant:"outline",size:"sm",className:"border-white/20 bg-white/5 text-white hover:bg-white/15",children:i.jsxs("a",{href:`tel:${s.agent.phone}`,children:[i.jsx(Un,{className:"h-3.5 w-3.5 mr-1.5"}),"Call"]})}),s.agent.email&&i.jsx(Lt,{asChild:!0,variant:"outline",size:"sm",className:"border-white/20 bg-white/5 text-white hover:bg-white/15",children:i.jsxs("a",{href:`mailto:${s.agent.email}`,children:[i.jsx(rs,{className:"h-3.5 w-3.5 mr-1.5"}),"Email"]})})]})]}),s.co_agent_name&&i.jsxs("div",{className:"rounded-2xl border border-white/10 bg-white/[0.03] p-6 backdrop-blur",children:[i.jsxs("div",{className:"flex items-start gap-4",children:[s.co_agent_photo_url?i.jsx("img",{src:s.co_agent_photo_url,alt:s.co_agent_name,className:"h-16 w-16 rounded-full object-cover border-2 border-white/20"}):i.jsx("div",{className:"h-16 w-16 rounded-full bg-white/10 flex items-center justify-center border-2 border-white/20",children:i.jsx(Gl,{className:"h-7 w-7 text-white/70"})}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("p",{className:"text-[10px] uppercase tracking-widest text-white/50",children:"Co-Listing Agent"}),i.jsx("p",{className:"font-display text-xl text-white font-medium leading-tight",children:s.co_agent_name}),s.co_agent_brokerage&&i.jsx("p",{className:"text-sm text-white/60 mt-0.5",children:s.co_agent_brokerage})]})]}),(s.co_agent_phone||s.co_agent_email)&&i.jsxs("div",{className:"mt-4 grid grid-cols-2 gap-2",children:[s.co_agent_phone&&i.jsx(Lt,{asChild:!0,variant:"outline",size:"sm",className:"border-white/20 bg-white/5 text-white hover:bg-white/15",children:i.jsxs("a",{href:`tel:${s.co_agent_phone}`,children:[i.jsx(Un,{className:"h-3.5 w-3.5 mr-1.5"}),"Call"]})}),s.co_agent_email&&i.jsx(Lt,{asChild:!0,variant:"outline",size:"sm",className:"border-white/20 bg-white/5 text-white hover:bg-white/15",children:i.jsxs("a",{href:`mailto:${s.co_agent_email}`,children:[i.jsx(rs,{className:"h-3.5 w-3.5 mr-1.5"}),"Email"]})})]})]}),i.jsx("div",{id:"contact",className:"rounded-2xl border border-white/10 bg-white text-neutral-900 p-6 shadow-2xl",children:i.jsx(mie,{submitted:ye,activeTab:J,setActiveTab:ee,firstName:m,setFirstName:y,lastName:_,setLastName:w,email:E,setEmail:A,phone:C,setPhone:I,message:M,setMessage:D,preferredDate:B,setPreferredDate:U,preferredTime:q,setPreferredTime:H,showingMode:K,setShowingMode:Q,isSubmitting:oe,onSubmit:Sr})})]})]}),i.jsxs("div",{className:"lg:hidden fixed bottom-0 inset-x-0 z-40 bg-neutral-950/95 backdrop-blur-xl border-t border-white/10 px-4 py-3 flex items-center gap-2 safe-area-inset-bottom",children:[((Xr=s.agent)==null?void 0:Xr.phone)&&i.jsx(Lt,{asChild:!0,variant:"outline",size:"sm",className:"border-white/20 bg-white/5 text-white hover:bg-white/15 flex-1",children:i.jsxs("a",{href:`tel:${s.agent.phone}`,children:[i.jsx(Un,{className:"h-4 w-4 mr-1.5"}),"Call"]})}),i.jsxs(Lt,{onClick:()=>me(!0),className:"bg-white text-neutral-900 hover:bg-white/90 flex-[2] font-medium",children:[i.jsx(hH,{className:"h-4 w-4 mr-1.5"}),"Request Tour"]})]}),i.jsx("footer",{className:"border-t border-white/10 py-10 mt-24 mb-16 lg:mb-0",children:i.jsxs("div",{className:"max-w-7xl mx-auto px-4 sm:px-8 flex flex-col sm:flex-row items-center justify-between gap-4 text-sm text-white/50",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("img",{src:hie,alt:"LevelUp",className:"h-6 opacity-80"}),i.jsxs("span",{children:["© ",new Date().getFullYear()," LevelUp"]})]}),i.jsx("a",{href:"https://relevelup.com",target:"_blank",rel:"noopener noreferrer",className:"hover:text-white",children:"relevelup.com"})]})}),i.jsx(Ha,{open:Le!==null,onOpenChange:()=>Se(null),children:i.jsxs(Ra,{className:"max-w-6xl p-0 bg-black/95 border-0",children:[i.jsx(Ho,{className:"sr-only",children:i.jsx(Co,{children:"Photo Gallery"})}),i.jsx("button",{onClick:()=>Se(null),className:"absolute right-4 top-4 z-50 rounded-full bg-white/10 hover:bg-white/20 p-2 text-white",children:i.jsx(Ci,{className:"h-5 w-5"})}),Le!==null&&kt[Le]&&i.jsxs("div",{className:"relative",children:[i.jsx("img",{src:kt[Le].photo_url,alt:`Photo ${Le+1}`,className:"w-full max-h-[85vh] object-contain"}),kt.length>1&&i.jsxs(i.Fragment,{children:[i.jsx("button",{onClick:rn,className:"absolute left-4 top-1/2 -translate-y-1/2 rounded-full bg-white/10 hover:bg-white/20 p-3 text-white",children:i.jsx(ip,{className:"h-6 w-6"})}),i.jsx("button",{onClick:Rr,className:"absolute right-4 top-1/2 -translate-y-1/2 rounded-full bg-white/10 hover:bg-white/20 p-3 text-white",children:i.jsx(Vd,{className:"h-6 w-6"})}),i.jsxs("div",{className:"absolute bottom-4 left-1/2 -translate-x-1/2 text-white bg-black/60 px-3 py-1 rounded-full text-sm",children:[Le+1," / ",kt.length]})]})]})]})}),i.jsx(Ha,{open:be,onOpenChange:me,children:i.jsxs(Ra,{className:"max-w-md p-0 bg-white text-neutral-900",children:[i.jsx(Ho,{className:"sr-only",children:i.jsx(Co,{children:"Contact the agent"})}),i.jsx("div",{className:"p-6",children:i.jsx(mie,{submitted:ye,activeTab:J,setActiveTab:ee,firstName:m,setFirstName:y,lastName:_,setLastName:w,email:E,setEmail:A,phone:C,setPhone:I,message:M,setMessage:D,preferredDate:B,setPreferredDate:U,preferredTime:q,setPreferredTime:H,showingMode:K,setShowingMode:Q,isSubmitting:oe,onSubmit:Sr})})]})})]})]})}function mie(t){const{submitted:e,activeTab:r,setActiveTab:n,firstName:s,setFirstName:o,lastName:c,setLastName:a,email:f,setEmail:m,phone:y,setPhone:_,message:w,setMessage:E,preferredDate:A,setPreferredDate:C,preferredTime:I,setPreferredTime:M,showingMode:D,setShowingMode:B,isSubmitting:U,onSubmit:q}=t;return e?i.jsxs("div",{className:"text-center py-6",children:[i.jsx("div",{className:"h-14 w-14 rounded-full bg-emerald-100 flex items-center justify-center mx-auto mb-3",children:i.jsx(pa,{className:"h-7 w-7 text-emerald-600"})}),i.jsx("p",{className:"font-display text-2xl font-medium mb-1",children:r==="showing"?"Showing request sent!":"Thanks — you're all set!"}),i.jsx("p",{className:"text-sm text-neutral-600",children:r==="showing"?"The listing agent will reach out to confirm your showing time.":"The listing agent will contact you shortly with more details."})]}):i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"mb-4",children:[i.jsx("p",{className:"text-[10px] uppercase tracking-[0.25em] text-neutral-500 mb-1",children:"Interested?"}),i.jsx("h3",{className:"font-display text-2xl font-medium",children:"Talk to the listing agent"})]}),i.jsxs(nF,{value:r,onValueChange:H=>n(H),children:[i.jsxs(UC,{className:"grid w-full grid-cols-2 mb-4",children:[i.jsxs(Mf,{value:"info",className:"gap-1.5",children:[i.jsx(Nh,{className:"h-3.5 w-3.5"})," Get Info"]}),i.jsxs(Mf,{value:"showing",className:"gap-1.5",children:[i.jsx(hH,{className:"h-3.5 w-3.5"})," Request Tour"]})]}),i.jsxs("form",{onSubmit:q,className:"space-y-3",children:[i.jsxs(Rx,{value:"showing",className:"mt-0 space-y-3",children:[i.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[i.jsxs("div",{children:[i.jsx(Fr,{htmlFor:"preferredDate",children:"Preferred Date *"}),i.jsx(Dr,{id:"preferredDate",type:"date",value:A,onChange:H=>C(H.target.value),min:new Date().toISOString().split("T")[0],required:r==="showing"})]}),i.jsxs("div",{children:[i.jsx(Fr,{htmlFor:"preferredTime",children:"Preferred Time"}),i.jsxs(Ia,{value:I,onValueChange:M,children:[i.jsx(_a,{id:"preferredTime",children:i.jsx(Pa,{placeholder:"Any time"})}),i.jsxs(va,{children:[i.jsx(gn,{value:"morning",children:"Morning (9am–12pm)"}),i.jsx(gn,{value:"afternoon",children:"Afternoon (12pm–5pm)"}),i.jsx(gn,{value:"evening",children:"Evening (5pm–8pm)"})]})]})]})]}),i.jsxs("div",{children:[i.jsx(Fr,{htmlFor:"showingMode",children:"Tour Type"}),i.jsxs(Ia,{value:D,onValueChange:H=>B(H),children:[i.jsx(_a,{id:"showingMode",children:i.jsx(Pa,{})}),i.jsxs(va,{children:[i.jsx(gn,{value:"in_person",children:"🏡 In-person showing"}),i.jsx(gn,{value:"video",children:"📱 Video tour (FaceTime/Zoom)"}),i.jsx(gn,{value:"either",children:"Either works for me"})]})]})]})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[i.jsxs("div",{children:[i.jsx(Fr,{htmlFor:"firstName",children:"First Name *"}),i.jsx(Dr,{id:"firstName",value:s,onChange:H=>o(H.target.value),required:!0})]}),i.jsxs("div",{children:[i.jsx(Fr,{htmlFor:"lastName",children:"Last Name"}),i.jsx(Dr,{id:"lastName",value:c,onChange:H=>a(H.target.value)})]})]}),i.jsxs("div",{children:[i.jsx(Fr,{htmlFor:"email",children:"Email *"}),i.jsx(Dr,{id:"email",type:"email",value:f,onChange:H=>m(H.target.value),required:!0})]}),i.jsxs("div",{children:[i.jsxs(Fr,{htmlFor:"phone",children:["Phone ",r==="showing"&&"*"]}),i.jsx(Dr,{id:"phone",type:"tel",value:y,onChange:H=>_(H.target.value),required:r==="showing"})]}),i.jsxs("div",{children:[i.jsx(Fr,{htmlFor:"message",children:r==="showing"?"Anything else?":"Message (optional)"}),i.jsx(zc,{id:"message",value:w,onChange:H=>E(H.target.value),rows:2})]}),i.jsx(Lt,{type:"submit",disabled:U,className:"w-full bg-neutral-900 hover:bg-neutral-800 text-white h-11",children:U?"Sending…":r==="showing"?"Request Showing":"Get More Info"}),i.jsx("p",{className:"text-[11px] text-neutral-500 text-center",children:"The listing agent will contact you directly. No spam."})]})]})]})}const ttt=Object.freeze(Object.defineProperty({__proto__:null,default:uK,toVideoEmbedUrl:O1e},Symbol.toStringTag,{value:"Module"})),pie="/assets/levelup-logo-white-C2RAgAoG.png",rtt="/assets/listings-hero-noir-BHCJrhvU.jpg";var F1e={exports:{}};(function(t,e){(function(r,n){t.exports=n()})(uc,function(){let r,n,s;function o(a,f){if(!r)r=f;else if(!n)n=f;else{const m={};r(m),s=f(m);const y="self.onerror = function() { console.error('An error occurred while parsing the WebWorker bundle. This is most likely due to improper transpilation by Babel; please see https://docs.mapbox.com/mapbox-gl-js/guides/install/#transpiling'); }; var sharedChunk = {}; ("+r+")(sharedChunk); ("+n+")(undefined, sharedChunk); self.onerror = null;";typeof window<"u"&&window&&window.URL&&window.URL.createObjectURL&&(s.workerUrl=window.URL.createObjectURL(new Blob([y],{type:"text/javascript"})))}}o(["exports"],function(a){var f=1e-6,m=typeof Float32Array<"u"?Float32Array:Array;function y(h,l){var u=l[0],p=l[1],x=l[2],b=l[3],T=u*b-x*p;return T?(h[0]=b*(T=1/T),h[1]=-p*T,h[2]=-x*T,h[3]=u*T,h):null}function _(){var h=new m(9);return m!=Float32Array&&(h[1]=0,h[2]=0,h[3]=0,h[5]=0,h[6]=0,h[7]=0),h[0]=1,h[4]=1,h[8]=1,h}function w(h,l){var u=l[0],p=l[1],x=l[2],b=l[3],T=l[4],k=l[5],P=l[6],O=l[7],$=l[8];return h[0]=T*$-k*O,h[1]=x*O-p*$,h[2]=p*k-x*T,h[3]=k*P-b*$,h[4]=u*$-x*P,h[5]=x*b-u*k,h[6]=b*O-T*P,h[7]=p*P-u*O,h[8]=u*T-p*b,h}function E(h,l,u){var p=l[0],x=l[1],b=l[2],T=l[3],k=l[4],P=l[5],O=l[6],$=l[7],V=l[8],G=u[0],Y=u[1],X=u[2],te=u[3],se=u[4],ae=u[5],fe=u[6],ue=u[7],we=u[8];return h[0]=G*p+Y*T+X*O,h[1]=G*x+Y*k+X*$,h[2]=G*b+Y*P+X*V,h[3]=te*p+se*T+ae*O,h[4]=te*x+se*k+ae*$,h[5]=te*b+se*P+ae*V,h[6]=fe*p+ue*T+we*O,h[7]=fe*x+ue*k+we*$,h[8]=fe*b+ue*P+we*V,h}function A(){var h=new m(16);return m!=Float32Array&&(h[1]=0,h[2]=0,h[3]=0,h[4]=0,h[6]=0,h[7]=0,h[8]=0,h[9]=0,h[11]=0,h[12]=0,h[13]=0,h[14]=0),h[0]=1,h[5]=1,h[10]=1,h[15]=1,h}function C(h){var l=new m(16);return l[0]=h[0],l[1]=h[1],l[2]=h[2],l[3]=h[3],l[4]=h[4],l[5]=h[5],l[6]=h[6],l[7]=h[7],l[8]=h[8],l[9]=h[9],l[10]=h[10],l[11]=h[11],l[12]=h[12],l[13]=h[13],l[14]=h[14],l[15]=h[15],l}function I(h){return h[0]=1,h[1]=0,h[2]=0,h[3]=0,h[4]=0,h[5]=1,h[6]=0,h[7]=0,h[8]=0,h[9]=0,h[10]=1,h[11]=0,h[12]=0,h[13]=0,h[14]=0,h[15]=1,h}function M(h,l){var u=l[0],p=l[1],x=l[2],b=l[3],T=l[4],k=l[5],P=l[6],O=l[7],$=l[8],V=l[9],G=l[10],Y=l[11],X=l[12],te=l[13],se=l[14],ae=l[15],fe=u*k-p*T,ue=u*P-x*T,we=u*O-b*T,Ae=p*P-x*k,Ie=p*O-b*k,We=x*O-b*P,ze=$*te-V*X,He=$*se-G*X,Ve=$*ae-Y*X,qe=V*se-G*te,bt=V*ae-Y*te,jt=G*ae-Y*se,It=fe*jt-ue*bt+we*qe+Ae*Ve-Ie*He+We*ze;return It?(h[0]=(k*jt-P*bt+O*qe)*(It=1/It),h[1]=(x*bt-p*jt-b*qe)*It,h[2]=(te*We-se*Ie+ae*Ae)*It,h[3]=(G*Ie-V*We-Y*Ae)*It,h[4]=(P*Ve-T*jt-O*He)*It,h[5]=(u*jt-x*Ve+b*He)*It,h[6]=(se*we-X*We-ae*ue)*It,h[7]=($*We-G*we+Y*ue)*It,h[8]=(T*bt-k*Ve+O*ze)*It,h[9]=(p*Ve-u*bt-b*ze)*It,h[10]=(X*Ie-te*we+ae*fe)*It,h[11]=(V*we-$*Ie-Y*fe)*It,h[12]=(k*He-T*qe-P*ze)*It,h[13]=(u*qe-p*He+x*ze)*It,h[14]=(te*ue-X*Ae-se*fe)*It,h[15]=($*Ae-V*ue+G*fe)*It,h):null}function D(h,l,u){var p=l[0],x=l[1],b=l[2],T=l[3],k=l[4],P=l[5],O=l[6],$=l[7],V=l[8],G=l[9],Y=l[10],X=l[11],te=l[12],se=l[13],ae=l[14],fe=l[15],ue=u[0],we=u[1],Ae=u[2],Ie=u[3];return h[0]=ue*p+we*k+Ae*V+Ie*te,h[1]=ue*x+we*P+Ae*G+Ie*se,h[2]=ue*b+we*O+Ae*Y+Ie*ae,h[3]=ue*T+we*$+Ae*X+Ie*fe,h[4]=(ue=u[4])*p+(we=u[5])*k+(Ae=u[6])*V+(Ie=u[7])*te,h[5]=ue*x+we*P+Ae*G+Ie*se,h[6]=ue*b+we*O+Ae*Y+Ie*ae,h[7]=ue*T+we*$+Ae*X+Ie*fe,h[8]=(ue=u[8])*p+(we=u[9])*k+(Ae=u[10])*V+(Ie=u[11])*te,h[9]=ue*x+we*P+Ae*G+Ie*se,h[10]=ue*b+we*O+Ae*Y+Ie*ae,h[11]=ue*T+we*$+Ae*X+Ie*fe,h[12]=(ue=u[12])*p+(we=u[13])*k+(Ae=u[14])*V+(Ie=u[15])*te,h[13]=ue*x+we*P+Ae*G+Ie*se,h[14]=ue*b+we*O+Ae*Y+Ie*ae,h[15]=ue*T+we*$+Ae*X+Ie*fe,h}function B(h,l,u){var p,x,b,T,k,P,O,$,V,G,Y,X,te=u[0],se=u[1],ae=u[2];return l===h?(h[12]=l[0]*te+l[4]*se+l[8]*ae+l[12],h[13]=l[1]*te+l[5]*se+l[9]*ae+l[13],h[14]=l[2]*te+l[6]*se+l[10]*ae+l[14],h[15]=l[3]*te+l[7]*se+l[11]*ae+l[15]):(x=l[1],b=l[2],T=l[3],k=l[4],P=l[5],O=l[6],$=l[7],V=l[8],G=l[9],Y=l[10],X=l[11],h[0]=p=l[0],h[1]=x,h[2]=b,h[3]=T,h[4]=k,h[5]=P,h[6]=O,h[7]=$,h[8]=V,h[9]=G,h[10]=Y,h[11]=X,h[12]=p*te+k*se+V*ae+l[12],h[13]=x*te+P*se+G*ae+l[13],h[14]=b*te+O*se+Y*ae+l[14],h[15]=T*te+$*se+X*ae+l[15]),h}function U(h,l,u){var p=u[0],x=u[1],b=u[2];return h[0]=l[0]*p,h[1]=l[1]*p,h[2]=l[2]*p,h[3]=l[3]*p,h[4]=l[4]*x,h[5]=l[5]*x,h[6]=l[6]*x,h[7]=l[7]*x,h[8]=l[8]*b,h[9]=l[9]*b,h[10]=l[10]*b,h[11]=l[11]*b,h[12]=l[12],h[13]=l[13],h[14]=l[14],h[15]=l[15],h}function q(h,l,u){var p=Math.sin(u),x=Math.cos(u),b=l[4],T=l[5],k=l[6],P=l[7],O=l[8],$=l[9],V=l[10],G=l[11];return l!==h&&(h[0]=l[0],h[1]=l[1],h[2]=l[2],h[3]=l[3],h[12]=l[12],h[13]=l[13],h[14]=l[14],h[15]=l[15]),h[4]=b*x+O*p,h[5]=T*x+$*p,h[6]=k*x+V*p,h[7]=P*x+G*p,h[8]=O*x-b*p,h[9]=$*x-T*p,h[10]=V*x-k*p,h[11]=G*x-P*p,h}function H(h,l,u){var p=Math.sin(u),x=Math.cos(u),b=l[0],T=l[1],k=l[2],P=l[3],O=l[8],$=l[9],V=l[10],G=l[11];return l!==h&&(h[4]=l[4],h[5]=l[5],h[6]=l[6],h[7]=l[7],h[12]=l[12],h[13]=l[13],h[14]=l[14],h[15]=l[15]),h[0]=b*x-O*p,h[1]=T*x-$*p,h[2]=k*x-V*p,h[3]=P*x-G*p,h[8]=b*p+O*x,h[9]=T*p+$*x,h[10]=k*p+V*x,h[11]=P*p+G*x,h}function K(h,l,u){var p=Math.sin(u),x=Math.cos(u),b=l[0],T=l[1],k=l[2],P=l[3],O=l[4],$=l[5],V=l[6],G=l[7];return l!==h&&(h[8]=l[8],h[9]=l[9],h[10]=l[10],h[11]=l[11],h[12]=l[12],h[13]=l[13],h[14]=l[14],h[15]=l[15]),h[0]=b*x+O*p,h[1]=T*x+$*p,h[2]=k*x+V*p,h[3]=P*x+G*p,h[4]=O*x-b*p,h[5]=$*x-T*p,h[6]=V*x-k*p,h[7]=G*x-P*p,h}function Q(h,l){return h[0]=l[0],h[1]=0,h[2]=0,h[3]=0,h[4]=0,h[5]=l[1],h[6]=0,h[7]=0,h[8]=0,h[9]=0,h[10]=l[2],h[11]=0,h[12]=0,h[13]=0,h[14]=0,h[15]=1,h}function J(h,l,u){var p,x,b,T=u[0],k=u[1],P=u[2],O=Math.sqrt(T*T+k*k+P*P);return O0&&(b=1/Math.sqrt(b)),h[0]=l[0]*b,h[1]=l[1]*b,h[2]=l[2]*b,h}function kt(h,l){return h[0]*l[0]+h[1]*l[1]+h[2]*l[2]}function Vt(h,l,u){var p=l[0],x=l[1],b=l[2],T=u[0],k=u[1],P=u[2];return h[0]=x*P-b*k,h[1]=b*T-p*P,h[2]=p*k-x*T,h}function xt(h,l,u,p){var x=l[0],b=l[1],T=l[2];return h[0]=x+p*(u[0]-x),h[1]=b+p*(u[1]-b),h[2]=T+p*(u[2]-T),h}function or(h,l,u){var p=l[0],x=l[1],b=l[2],T=u[3]*p+u[7]*x+u[11]*b+u[15];return h[0]=(u[0]*p+u[4]*x+u[8]*b+u[12])/(T=T||1),h[1]=(u[1]*p+u[5]*x+u[9]*b+u[13])/T,h[2]=(u[2]*p+u[6]*x+u[10]*b+u[14])/T,h}function Sr(h,l,u){var p=l[0],x=l[1],b=l[2];return h[0]=p*u[0]+x*u[3]+b*u[6],h[1]=p*u[1]+x*u[4]+b*u[7],h[2]=p*u[2]+x*u[5]+b*u[8],h}function rn(h,l,u){var p=u[0],x=u[1],b=u[2],T=u[3],k=l[0],P=l[1],O=l[2],$=x*O-b*P,V=b*k-p*O,G=p*P-x*k;return h[0]=k+T*($+=$)+x*(G+=G)-b*(V+=V),h[1]=P+T*V+b*$-p*G,h[2]=O+T*G+p*V-x*$,h}function Rr(h){return h[0]=0,h[1]=0,h[2]=0,h}function $r(h,l){return h[0]===l[0]&&h[1]===l[1]&&h[2]===l[2]}var qr=ke,Nn=Pe,tt=Le;function Tt(){var h=new m(4);return m!=Float32Array&&(h[0]=0,h[1]=0,h[2]=0,h[3]=0),h}function Zt(h,l,u){return h[0]=l[0]*u,h[1]=l[1]*u,h[2]=l[2]*u,h[3]=l[3]*u,h}function ar(h,l){var u=l[0],p=l[1],x=l[2],b=l[3],T=u*u+p*p+x*x+b*b;return T>0&&(T=1/Math.sqrt(T)),h[0]=u*T,h[1]=p*T,h[2]=x*T,h[3]=b*T,h}function Wt(h,l){return h[0]*l[0]+h[1]*l[1]+h[2]*l[2]+h[3]*l[3]}function Kt(h,l,u){var p=l[0],x=l[1],b=l[2],T=l[3];return h[0]=u[0]*p+u[4]*x+u[8]*b+u[12]*T,h[1]=u[1]*p+u[5]*x+u[9]*b+u[13]*T,h[2]=u[2]*p+u[6]*x+u[10]*b+u[14]*T,h[3]=u[3]*p+u[7]*x+u[11]*b+u[15]*T,h}function At(){var h=new m(4);return m!=Float32Array&&(h[0]=0,h[1]=0,h[2]=0),h[3]=1,h}function pr(h){return h[0]=0,h[1]=0,h[2]=0,h[3]=1,h}function yn(h,l,u){u*=.5;var p=l[0],x=l[1],b=l[2],T=l[3],k=Math.sin(u),P=Math.cos(u);return h[0]=p*P+T*k,h[1]=x*P+b*k,h[2]=b*P-x*k,h[3]=T*P-p*k,h}function Gn(h,l,u){u*=.5;var p=l[0],x=l[1],b=l[2],T=l[3],k=Math.sin(u),P=Math.cos(u);return h[0]=p*P-b*k,h[1]=x*P+T*k,h[2]=b*P+p*k,h[3]=T*P-x*k,h}ye(),Tt();var Fn,Rs,sa,gs=ar,$i=(Fn=ye(),Rs=Se(1,0,0),sa=Se(0,1,0),function(h,l,u){var p=kt(l,u);return p<-.999999?(Vt(Fn,Rs,l),tt(Fn)<1e-6&&Vt(Fn,sa,l),ft(Fn,Fn),function(x,b,T){T*=.5;var k=Math.sin(T);x[0]=k*b[0],x[1]=k*b[1],x[2]=k*b[2],x[3]=Math.cos(T)}(h,Fn,Math.PI),h):p>.999999?(h[0]=0,h[1]=0,h[2]=0,h[3]=1,h):(Vt(Fn,l,u),h[0]=Fn[0],h[1]=Fn[1],h[2]=Fn[2],h[3]=1+p,gs(h,h))});function Cr(){var h=new m(2);return m!=Float32Array&&(h[0]=0,h[1]=0),h}function Bn(h,l){var u=new m(2);return u[0]=h,u[1]=l,u}function wi(h,l,u){return h[0]=l,h[1]=u,h}function ii(h,l,u){return h[0]=l[0]+u[0],h[1]=l[1]+u[1],h}function ia(h,l,u){return h[0]=l[0]-u[0],h[1]=l[1]-u[1],h}function Xr(h,l,u){return h[0]=l[0]*u,h[1]=l[1]*u,h}function un(h){var l=h[0],u=h[1];return Math.sqrt(l*l+u*u)}function xn(h,l){var u=l[0],p=l[1],x=u*u+p*p;return x>0&&(x=1/Math.sqrt(x)),h[0]=l[0]*x,h[1]=l[1]*x,h}function Qr(h,l){return h[0]*l[0]+h[1]*l[1]}At(),At(),_();var ls,nn,Ln=ia;function ti(h){return h&&h.__esModule&&Object.prototype.hasOwnProperty.call(h,"default")?h.default:h}Cr();var Wo=function(){if(nn)return ls;function h(l,u,p,x){this.cx=3*l,this.bx=3*(p-l)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*u,this.by=3*(x-u)-this.cy,this.ay=1-this.cy-this.by,this.p1x=l,this.p1y=u,this.p2x=p,this.p2y=x}return nn=1,ls=h,h.prototype={sampleCurveX:function(l){return((this.ax*l+this.bx)*l+this.cx)*l},sampleCurveY:function(l){return((this.ay*l+this.by)*l+this.cy)*l},sampleCurveDerivativeX:function(l){return(3*this.ax*l+2*this.bx)*l+this.cx},solveCurveX:function(l,u){if(u===void 0&&(u=1e-6),l<0)return 0;if(l>1)return 1;for(var p=l,x=0;x<8;x++){var b=this.sampleCurveX(p)-l;if(Math.abs(b)b?k=p:P=p,p=.5*(P-k)+k;return p},solve:function(l,u){return this.sampleCurveY(this.solveCurveX(l,u))}},ls}(),Us=ti(Wo);function Ft(h,l){this.x=h,this.y=l}function So(h,l){if(Array.isArray(h)){if(!Array.isArray(l)||h.length!==l.length)return!1;for(let u=0;u=1)return 1;const l=h*h,u=l*h;return 4*(h<.5?u:3*(h-l)+u-.75)}function dt(h,l,u,p){const x=new Us(h,l,u,p);return function(b){return x.solve(b)}}const he=dt(.25,.1,.25,1);function pe(h,l,u){return Math.min(u,Math.max(l,h))}function Fe(h,l,u){return(u=pe((u-h)/(l-h),0,1))*u*(3-2*u)}function Ye(h,l,u){const p=u-l,x=((h-l)%p+p)%p+l;return x===l?u:x}function et(h,l,u){if(!h.length)return u(null,[]);let p=h.length;const x=new Array(h.length);let b=null;h.forEach((T,k)=>{l(T,(P,O)=>{P&&(b=P),x[k]=O,--p===0&&u(b,x)})})}let nt=1;function ht(){return nt++}function it(h){return h<=1?1:Math.pow(2,Math.ceil(Math.log2(h)))}function mt(h,l){h.forEach(u=>{l[u]&&(l[u]=l[u].bind(l))})}function Gt(h,l,u){const p={};for(const x in h)p[x]=l.call(this,h[x],x,h);return p}function Mt(h,l,u){const p={};for(const x in h)l.call(this,h[x],x,h)&&(p[x]=h[x]);return p}function gr(h){return Array.isArray(h)?h.map(gr):typeof h=="object"&&h?Gt(h,gr):h}function zr(h,l){for(let u=0;u=0)return!0;return!1}const Hr={};function hr(h){Hr[h]||(typeof console<"u"&&console.warn(h),Hr[h]=!0)}function rt(h,l,u){return(u.y-h.y)*(l.x-h.x)>(l.y-h.y)*(u.x-h.x)}function qt(h){let l=0;for(let u,p,x=0,b=h.length,T=b-1;x@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(u,p,x,b)=>{const T=x||b;return l[p]=!T||T.toLowerCase(),""}),l["max-age"]){const u=parseInt(l["max-age"],10);isNaN(u)?delete l["max-age"]:l["max-age"]=u}return l}let Qn,Ns=null;function Jn(h,l){return[h[4*l],h[4*l+1],h[4*l+2],h[4*l+3]]}function ks(h,l,u,p){for(;l>1;h[x]>1;h[x]<=p?l=x+1:u=x}return l}function zn(h){return h>0?1/(1.001-h):1+h}function ri(h){return h>0?1-1/(1.001-h):-h}function di(h,l,u){return(h-l.min)*(u.max-u.min)/(l.max-l.min)+u.min}const Vn={API_URL:"https://api.mapbox.com",get API_URL_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/|\?|$)/i},get API_TILEJSON_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/v[0-9]*\/.*\.json.*$)/i},get API_SPRITE_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/styles\/v[0-9]*\/)(.*\/sprite.*\..*$)/i},get API_FONTS_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/fonts\/v[0-9]*\/)(.*\.pbf.*$)/i},get API_STYLE_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/styles\/v[0-9]*\/)(.*$)/i},get API_CDN_URL_REGEX(){return/^((https?:)?\/\/)?api\.mapbox\.c(n|om)(\/mapbox-gl-js\/)(.*$)/i},get EVENTS_URL(){if(!Vn.API_URL)return null;try{const h=new URL(Vn.API_URL);return h.hostname==="api.mapbox.cn"?"https://events.mapbox.cn/events/v2":h.hostname==="api.mapbox.com"?"https://events.mapbox.com/events/v2":null}catch{return null}},SESSION_PATH:"/map-sessions/v1",FEEDBACK_URL:"https://apps.mapbox.com/feedback",TILE_URL_VERSION:"v4",RASTER_URL_PREFIX:"raster/v1",RASTERARRAYS_URL_PREFIX:"rasterarrays/v1",REQUIRE_ACCESS_TOKEN:!0,ACCESS_TOKEN:null,DEFAULT_STYLE:"mapbox://styles/mapbox/standard",MAX_PARALLEL_IMAGE_REQUESTS:16,DRACO_URL:"/mapbox-gl-js/draco_decoder_gltf_v1.5.6.wasm",MESHOPT_URL:"/mapbox-gl-js/meshopt_base_v0.20.wasm",MESHOPT_SIMD_URL:"/mapbox-gl-js/meshopt_simd_v0.20.wasm",BUILDING_GEN_URL:"/mapbox-gl-js/building-gen/building_gen_v1.2.4.wasm",GLYPHS_URL:"mapbox://fonts/mapbox/{fontstack}/{range}.pbf",TILES3D_URL_PREFIX:"3dtiles/v1",TILE_PROVIDER_URLS:Object.assign(Object.create(null),{pmtiles:"/mapbox-gl-js/mapbox-gl-pmtiles-provider-v0.0.1.js"})};function Da(){return new URL(Vn.DRACO_URL,Vn.API_URL).href}function Po(){if(typeof WebAssembly!="object")throw new Error("WebAssembly not supported, cannot instantiate meshoptimizer");return new URL(function(){if(Qn===void 0){if(typeof WebAssembly!="object")return!1;const h=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]);Qn=WebAssembly.validate(h)}return Qn}()?Vn.MESHOPT_SIMD_URL:Vn.MESHOPT_URL,Vn.API_URL).href}function To(){return new URL(Vn.BUILDING_GEN_URL,Vn.API_URL).href}function xc(h){return Vn.API_URL_REGEX.test(h)}function _c(h){return Vn.API_SPRITE_REGEX.test(h)}let qd,Pl,vc,Gd,Vc,Hd;function Au(){return qd==null&&(qd=self.OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&typeof self.createImageBitmap=="function"),qd}const Kl={now:()=>Gd!==void 0?Gd:performance.now(),setNow(h){Gd=h},restoreNow(){Gd=void 0},frame(h){const l=requestAnimationFrame(h);return{cancel:()=>cancelAnimationFrame(l)}},getImageData(h,l=0){const{width:u,height:p}=h;Vc||(Vc=document.createElement("canvas"));const x=Vc.getContext("2d",{willReadFrequently:!0});if(!x)throw new Error("failed to create canvas 2d context");return(u>Vc.width||p>Vc.height)&&(Vc.width=u,Vc.height=p),x.clearRect(-l,-l,u+2*l,p+2*l),x.drawImage(h,0,0,u,p),x.getImageData(-l,-l,u+2*l,p+2*l)},resolveURL:h=>(Pl||(Pl=document.createElement("a")),Pl.href=h,Pl.href),get devicePixelRatio(){return window.devicePixelRatio},get prefersReducedMotion(){return!!window.matchMedia&&(vc==null&&(vc=window.matchMedia("(prefers-reduced-motion: reduce)")),vc.matches)},hasCanvasFingerprintNoise(){if(Hd!==void 0)return Hd;if(!Au())return Hd=!1,!1;const h=new OffscreenCanvas(85,1),l=h.getContext("2d",{willReadFrequently:!0});let u=0;for(let x=0;x0?`?${b}`:""}`}const fp="mapbox-tiles";let gb=500,yb=50;const CE=["language","worldview","jobid"];let Wd;function hI(){try{return caches}catch{}}function xb(){const h=hI();h&&Wd==null&&(Wd=h.open(fp))}let IE=1/0;const _b={supported:!1,testSupport:function(h){!PE&&Wg&&(Nu?Kg(h):mp=h)}};let mp,Wg,PE=!1,Nu=!1;const RE=typeof self<"u"?self:{};function Kg(h){const l=h.createTexture();h.bindTexture(h.TEXTURE_2D,l);try{if(h.texImage2D(h.TEXTURE_2D,0,h.RGBA,h.RGBA,h.UNSIGNED_BYTE,Wg),h.isContextLost())return;_b.supported=!0}catch{}h.deleteTexture(l),PE=!0}RE.document&&(Wg=RE.document.createElement("img"),Wg.onload=function(){mp&&Kg(mp),mp=null,Nu=!0},Wg.onerror=function(){PE=!0,mp=null},Wg.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const k0={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Iconset:"Iconset",Image:"Image",Model:"Model"};Object.freeze(k0);class LE extends Error{constructor(l,u,p){u===401&&xc(p)&&(l+=": you may have provided an invalid Mapbox access token. See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes"),super(l),this.status=u,this.url=p}toString(){return`${this.name}: ${this.message} (${this.status}): ${this.url}`}}function ME(h){return typeof h=="object"&&h!==null&&"status"in h&&h.status===404}const cs=wn()?()=>self.worker.referrer:()=>(location.protocol==="blob:"?parent:self).location.href,Yg=function(h,l){return/^file:/.test(u=h.url)||/^file:/.test(cs())&&!/^\w+:/.test(u)?function(p,x){const b=new XMLHttpRequest;b.open(p.method||"GET",p.url,!0),p.type==="arrayBuffer"&&(b.responseType="arraybuffer");for(const T in p.headers)b.setRequestHeader(T,p.headers[T]);return p.type==="json"&&(b.responseType="text",b.setRequestHeader("Accept","application/json")),b.withCredentials=p.credentials==="include",b.onerror=()=>{x(new Error(b.statusText))},b.onload=()=>{if((b.status>=200&&b.status<300||b.status===0)&&b.response!==null){let T=b.response;if(p.type==="json")try{T=JSON.parse(b.response)}catch(P){return x(P)}const k=new Headers;b.getAllResponseHeaders().trim().split(/[\r\n]+/).forEach(P=>{const O=P.split(": "),$=O.shift(),V=O.join(": ");k.append($,V)}),x(null,T,k)}else x(new LE(b.statusText,b.status,p.url))},b.send(p.body),{cancel:()=>b.abort()}}(h,l):function(p,x){const b=new AbortController,T=new Request(p.url,{method:p.method||"GET",body:p.body,credentials:p.credentials,headers:p.headers,referrer:cs(),referrerPolicy:p.referrerPolicy,signal:b.signal});let k=!1,P=!1;const O=($=T.url).indexOf("sku=")>0&&xc($);var $;p.type==="json"&&T.headers.set("Accept","application/json");const V=(Y,X,te)=>{if(P)return;if(Y&&Y.message!=="SecurityError"&&hr(Y.toString()),X&&te)return G(X);const se=Date.now();fetch(T).then(ae=>{if(ae.ok){const fe=O?ae.clone():null;return G(ae,fe,se)}return x(new LE(ae.statusText,ae.status,p.url))}).catch(ae=>{ae.name!=="AbortError"&&x(new Error(`${ae.message} ${p.url}`))})},G=(Y,X,te)=>{(p.type==="arrayBuffer"?Y.arrayBuffer():p.type==="json"?Y.json():Y.text()).then(se=>{P||(X&&te&&function(ae,fe,ue){if(xb(),Wd==null)return;const we=Cn(fe.headers.get("cache-control")||"");if(we["no-store"])return;const Ae={status:fe.status,statusText:fe.statusText,headers:new Headers};fe.headers.forEach((Ve,qe)=>Ae.headers.set(qe,Ve)),we["max-age"]&&Ae.headers.set("Expires",new Date(ue+1e3*we["max-age"]).toUTCString());const Ie=Ae.headers.get("expires");if(!Ie||new Date(Ie).getTime()-ue<42e4)return;let We=NE(ae.url,{persistentParams:CE});if(fe.status===206){const Ve=ae.headers.get("Range");if(!Ve)return;Ae.status=200,We=j0(We,{range:Ve})}const ze=new Response((He=fe.status)!==200&&He!==404&&[101,103,204,205,304].includes(He)?null:fe.body,Ae);var He;xb(),Wd!=null&&Wd.then(Ve=>Ve.put(We,ze)).catch(Ve=>hr(Ve.message))}(T,X,te),k=!0,x(null,se,Y.headers))}).catch(se=>{P||x(new Error(se.message))})};return O?function(Y,X){if(xb(),Wd==null)return X(null);Wd.then(te=>{let se=NE(Y.url,{persistentParams:CE});const ae=Y.headers.get("Range");ae&&(se=j0(se,{range:ae})),te.match(se).then(fe=>{const ue=function(we){if(!we)return!1;const Ae=new Date(we.headers.get("expires")||0),Ie=Cn(we.headers.get("cache-control")||"");return Number(Ae)>Date.now()&&!Ie["no-cache"]}(fe);te.delete(se).catch(X),ue&&te.put(se,fe.clone()).catch(X),X(null,fe,ue)}).catch(X)}).catch(X)}(T,V):V(null,null),{cancel:()=>{P=!0,k||b.abort()}}}(h,l);var u},Zg=function(h,l){return Yg(Object.assign(h,{type:"arrayBuffer"}),l)};function $5(h){const l=document.createElement("a");return l.href=h,l.protocol===location.protocol&&l.host===location.host}let vb,Gf;vb=[],Gf=0;const Xg=function(h,l){if(_b.supported&&(h.headers||(h.headers={}),h.headers.accept="image/webp,*/*"),Gf>=Vn.MAX_PARALLEL_IMAGE_REQUESTS){const b={requestParameters:h,callback:l,cancelled:!1,cancel(){this.cancelled=!0}};return vb.push(b),b}Gf++;let u=!1;const p=()=>{if(!u)for(u=!0,Gf--;vb.length&&Gf{p(),b?l(b):T&&function(P,O){const $=new Blob([new Uint8Array(P)],{type:"image/png"});createImageBitmap($).then(V=>{O(null,V)}).catch(V=>{O(new Error(`Could not load image because of ${V.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`))})}(T,(P,O)=>l(P,O,k))});return{cancel:()=>{x.cancel(),p()}}};var A0,bb,fI,pp={exports:{}},mI={exports:{}},DE={exports:{}},z5=function(){if(fI)return pp.exports;fI=1;var h=(A0||(A0=1,mI.exports=function(u,p){var x,b,T,k,P,O,$,V;for(b=u.length-(x=3&u.length),T=p,P=3432918353,O=461845907,V=0;V>>16)*P&65535)<<16)&4294967295)<<15|$>>>17))*O+((($>>>16)*O&65535)<<16)&4294967295)<<13|T>>>19))+((5*(T>>>16)&65535)<<16)&4294967295))+(((k>>>16)+58964&65535)<<16);switch($=0,x){case 3:$^=(255&u.charCodeAt(V+2))<<16;case 2:$^=(255&u.charCodeAt(V+1))<<8;case 1:T^=$=(65535&($=($=(65535&($^=255&u.charCodeAt(V)))*P+((($>>>16)*P&65535)<<16)&4294967295)<<15|$>>>17))*O+((($>>>16)*O&65535)<<16)&4294967295}return T^=u.length,T=2246822507*(65535&(T^=T>>>16))+((2246822507*(T>>>16)&65535)<<16)&4294967295,T=3266489909*(65535&(T^=T>>>13))+((3266489909*(T>>>16)&65535)<<16)&4294967295,(T^=T>>>16)>>>0}),mI.exports),l=(bb||(bb=1,DE.exports=function(u,p){for(var x,b=u.length,T=p^b,k=0;b>=4;)x=1540483477*(65535&(x=255&u.charCodeAt(k)|(255&u.charCodeAt(++k))<<8|(255&u.charCodeAt(++k))<<16|(255&u.charCodeAt(++k))<<24))+((1540483477*(x>>>16)&65535)<<16),T=1540483477*(65535&T)+((1540483477*(T>>>16)&65535)<<16)^(x=1540483477*(65535&(x^=x>>>24))+((1540483477*(x>>>16)&65535)<<16)),b-=4,++k;switch(b){case 3:T^=(255&u.charCodeAt(k+2))<<16;case 2:T^=(255&u.charCodeAt(k+1))<<8;case 1:T=1540483477*(65535&(T^=255&u.charCodeAt(k)))+((1540483477*(T>>>16)&65535)<<16)}return T=1540483477*(65535&(T^=T>>>13))+((1540483477*(T>>>16)&65535)<<16),(T^=T>>>15)>>>0}),DE.exports);return pp.exports=h,pp.exports.murmur3=h,pp.exports.murmur2=l,pp.exports}(),Hf=ti(z5);class ad{constructor(l,...u){Object.assign(this,u[0]||{}),this.type=l}}class Qg extends ad{constructor(l,u={}){super("error",Object.assign({error:l},u))}}function Cu(h,l,u){u[h]&&u[h].indexOf(l)!==-1||(u[h]=u[h]||[],u[h].push(l))}function wb(h,l,u){if(u&&u[h]){const p=u[h].indexOf(l);p!==-1&&u[h].splice(p,1)}}class N0{on(l,u){return this._listeners=this._listeners||{},Cu(l,u,this._listeners),this}off(l,u){return wb(l,u,this._listeners),wb(l,u,this._oneTimeListeners),this}once(l,u){return u?(this._oneTimeListeners=this._oneTimeListeners||{},Cu(l,u,this._oneTimeListeners),this):new Promise(p=>{this.once(l,p)})}fire(l,u){const p=typeof l=="string"?new ad(l,u):l,x=p.type;if(this.listens(x)){p.target=this;const b=this._listeners&&this._listeners[x]?this._listeners[x].slice():[];for(const P of b)P.call(this,p);const T=this._oneTimeListeners&&this._oneTimeListeners[x]?this._oneTimeListeners[x].slice():[];for(const P of T)wb(x,P,this._oneTimeListeners),P.call(this,p);const k=this._eventedParent;if(k){const P=typeof this._eventedParentData=="function"?this._eventedParentData():this._eventedParentData;Object.assign(p,P),k.fire(p)}}else p instanceof Qg&&console.error(p.error);return this}listens(l){return!!(this._listeners&&this._listeners[l]&&this._listeners[l].length>0||this._oneTimeListeners&&this._oneTimeListeners[l]&&this._oneTimeListeners[l].length>0||this._eventedParent&&this._eventedParent.listens(l))}setEventedParent(l,u){return this._eventedParent=l,this._eventedParentData=u,this}}class bc{constructor(l){typeof l=="string"?this.name=l:(this.name=l.name,this.iconsetId=l.iconsetId)}static from(l){return new bc(l)}static toString(l){return l.iconsetId?`${l.name}${l.iconsetId}`:l.name}static parse(l){const[u,p]=l.split("");return new bc({name:u,iconsetId:p})}static isEqual(l,u){return l.name===u.name&&l.iconsetId===u.iconsetId}toString(){return bc.toString(this)}serialize(){return{name:this.name,iconsetId:this.iconsetId}}}var OE,Sb={},FE=function(){if(OE)return Sb;OE=1;var h={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],rebeccapurple:[102,51,153,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};function l(b){return(b=Math.round(b))<0?0:b>255?255:b}function u(b){return l(b[b.length-1]==="%"?parseFloat(b)/100*255:parseInt(b))}function p(b){return(T=b[b.length-1]==="%"?parseFloat(b)/100:parseFloat(b))<0?0:T>1?1:T;var T}function x(b,T,k){return k<0?k+=1:k>1&&(k-=1),6*k<1?b+(T-b)*k*6:2*k<1?T:3*k<2?b+(T-b)*(2/3-k)*6:b}try{Sb.parseCSSColor=function(b){var T,k=b.replace(/ /g,"").toLowerCase();if(k in h)return h[k].slice();if(k[0]==="#")return k.length===4?(T=parseInt(k.substr(1),16))>=0&&T<=4095?[(3840&T)>>4|(3840&T)>>8,240&T|(240&T)>>4,15&T|(15&T)<<4,1]:null:k.length===7&&(T=parseInt(k.substr(1),16))>=0&&T<=16777215?[(16711680&T)>>16,(65280&T)>>8,255&T,1]:null;var P=k.indexOf("("),O=k.indexOf(")");if(P!==-1&&O+1===k.length){var $=k.substr(0,P),V=k.substr(P+1,O-(P+1)).split(","),G=1;switch($){case"rgba":if(V.length!==4)return null;G=p(V.pop());case"rgb":return V.length!==3?null:[u(V[0]),u(V[1]),u(V[2]),G];case"hsla":if(V.length!==4)return null;G=p(V.pop());case"hsl":if(V.length!==3)return null;var Y=(parseFloat(V[0])%360+360)%360/360,X=p(V[1]),te=p(V[2]),se=te<=.5?te*(X+1):te+X-te*X,ae=2*te-se;return[l(255*x(ae,se,Y+1/3)),l(255*x(ae,se,Y)),l(255*x(ae,se,Y-1/3)),G];default:return null}}return null}}catch{}return Sb}();class as{constructor(l,u,p,x=1){this.r=l,this.g=u,this.b=p,this.a=x}static parse(l){if(!l)return;if(l instanceof as)return l;if(typeof l!="string")return;const u=FE.parseCSSColor(l);return u?new as(u[0]/255,u[1]/255,u[2]/255,u[3]):void 0}toString(){const[l,u,p,x]=[this.r,this.g,this.b,this.a];return`rgba(${Math.round(255*l)},${Math.round(255*u)},${Math.round(255*p)},${x})`}toNonPremultipliedRenderColor(l){const{r:u,g:p,b:x,a:b}=this;return new Tb(l,u,p,x,b)}toPremultipliedRenderColor(l){const{r:u,g:p,b:x,a:b}=this;return new Jg(l,u*b,p*b,x*b,b)}clone(){return new as(this.r,this.g,this.b,this.a)}}class BE{constructor(l,u,p,x,b,T=!1){if(this.premultiplied=!1,this.premultiplied=T,l){const k=l.image.height,P=k*k;this.premultiplied?(u=b===0?0:u/b*(k-1),p=b===0?0:p/b*(k-1),x=b===0?0:x/b*(k-1)):(u*=k-1,p*=k-1,x*=k-1),u=Math.max(0,Math.min(k-1,u)),p=Math.max(0,Math.min(k-1,p)),x=Math.max(0,Math.min(k-1,x));const O=Math.floor(u),$=Math.floor(p),V=Math.floor(x),G=Math.ceil(u),Y=Math.ceil(p),X=Math.ceil(x),te=u-O,se=p-$,ae=x-V,fe=l.image.data,ue=4*(O+$*P+V*k),we=4*(O+$*P+X*k),Ae=4*(O+Y*P+V*k),Ie=4*(O+Y*P+X*k),We=4*(G+$*P+V*k),ze=4*(G+$*P+X*k),He=4*(G+Y*P+V*k),Ve=4*(G+Y*P+X*k);this.r=sn(sn(sn(fe[ue],fe[we],ae),sn(fe[Ae],fe[Ie],ae),se),sn(sn(fe[We],fe[ze],ae),sn(fe[He],fe[Ve],ae),se),te)/255*(this.premultiplied?b:1),this.g=sn(sn(sn(fe[ue+1],fe[we+1],ae),sn(fe[Ae+1],fe[Ie+1],ae),se),sn(sn(fe[We+1],fe[ze+1],ae),sn(fe[He+1],fe[Ve+1],ae),se),te)/255*(this.premultiplied?b:1),this.b=sn(sn(sn(fe[ue+2],fe[we+2],ae),sn(fe[Ae+2],fe[Ie+2],ae),se),sn(sn(fe[We+2],fe[ze+2],ae),sn(fe[He+2],fe[Ve+2],ae),se),te)/255*(this.premultiplied?b:1),this.a=b}else this.r=u,this.g=p,this.b=x,this.a=b}toArray(){const{r:l,g:u,b:p,a:x}=this;return[255*l,255*u,255*p,x]}toHslaArray(){let{r:l,g:u,b:p,a:x}=this;if(this.premultiplied){if(x===0)return[0,0,0,0];const X=1/x;l*=X,u*=X,p*=X}const b=Math.min(Math.max(l,0),1),T=Math.min(Math.max(u,0),1),k=Math.min(Math.max(p,0),1),P=Math.min(b,T,k),O=Math.max(b,T,k),$=O-P,V=.5*(P+O);if($===0)return[0,0,100*V,x];const G=V>.5?$/(2-O-P):$/(O+P);let Y;switch(O){case b:Y=60*((T-k)/$+(Tsn(p,l[x],u))}as.black=new as(0,0,0,1),as.white=new as(1,1,1,1),as.transparent=new as(0,0,0,0),as.red=new as(1,0,0,1),as.blue=new as(0,0,1,1);var Eb=Object.freeze({__proto__:null,array:od,color:function(h,l,u){return new as(sn(h.r,l.r,u),sn(h.g,l.g,u),sn(h.b,l.b,u),sn(h.a,l.a,u))},number:sn});class Iu extends Error{constructor(l,u){super(u),this.message=u,this.key=l}}class gp{constructor(l,u=[]){this.parent=l,this.bindings={};for(const[p,x]of u)this.bindings[p]=x}concat(l){return new gp(this,l)}get(l){if(this.bindings[l])return this.bindings[l];if(this.parent)return this.parent.get(l);throw new Error(`${l} not found in scope.`)}has(l){return!!this.bindings[l]||!!this.parent&&this.parent.has(l)}}const Bh={kind:"null"},Ur={kind:"number"},xs={kind:"string"},ws={kind:"boolean"},Rl={kind:"color"},Wf={kind:"object"},Ss={kind:"value"},yp={kind:"collator"},C0={kind:"formatted"},I0={kind:"resolvedImage"};function dl(h,l){return{kind:"array",itemType:h,N:l}}function ba(h){if(h.kind==="array"){const l=ba(h.itemType);return typeof h.N=="number"?`array<${l}, ${h.N}>`:h.itemType.kind==="value"?"array":`array<${l}>`}return h.kind}const U5=[Bh,Ur,xs,ws,Rl,C0,Wf,dl(Ss),I0];function P0(h,l){if(l.kind==="error")return null;if(h.kind==="array"){if(l.kind==="array"&&(l.N===0&&l.itemType.kind==="value"||!P0(h.itemType,l.itemType))&&(typeof h.N!="number"||h.N===l.N))return null}else{if(h.kind===l.kind)return null;if(h.kind==="value"){for(const u of U5)if(!P0(u,l))return null}}return`Expected ${ba(h)} but found ${ba(l)} instead.`}function $E(h,l){return l.some(u=>u.kind===h.kind)}function ey(h,l){return l.some(u=>u==="null"?h===null:u==="array"?Array.isArray(h):u==="object"?h&&!Array.isArray(h)&&typeof h=="object":u===typeof h)}function $h(h,l){return h.kind==="array"&&l.kind==="array"?h.N===l.N&&$h(h.itemType,l.itemType):h.kind===l.kind}class zE{constructor(l,u,p){this.sensitivity=l?u?"variant":"case":u?"accent":"base",this.locale=p,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(l,u){return this.collator.compare(l,u)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class R0{constructor(l,u,p,x,b){this.text=l.normalize?l.normalize():l,this.image=u,this.scale=p,this.fontStack=x,this.textColor=b}}class Ko{constructor(l){this.sections=l}static fromString(l){return new Ko([new R0(l,null,null,null,null)])}isEmpty(){return this.sections.length===0||!this.sections.some(l=>l.text.length!==0||!!l.image&&l.image.hasPrimary())}static factory(l){return l instanceof Ko?l:Ko.fromString(l)}toString(){return this.sections.length===0?"":this.sections.map(l=>l.text).join("")}serialize(){const l=["format"];for(const u of this.sections){if(u.image){const x=u.image.getPrimary().id.toString();l.push(["image",x]);continue}l.push(u.text);const p={};u.fontStack&&(p["text-font"]=["literal",u.fontStack.split(",")]),u.scale&&(p["font-scale"]=u.scale),u.textColor&&(p["text-color"]=["rgba"].concat(u.textColor.toNonPremultipliedRenderColor(null).toArray())),l.push(p)}return l}}class Pu{constructor(l,u={}){this.id=bc.from(l),this.params=u.params,this.sx=u.sx||1,this.sy=u.sy||1}toString(){return JSON.stringify(this)}static parse(l){let u,p,x,b;try{({id:u,params:p,sx:x,sy:b}=JSON.parse(l)||{})}catch{return null}return u?new Pu(u,{params:p,sx:x,sy:b}):null}scaleSelf(l,u=l){return this.sx*=l,this.sy*=u,this}}class Yl{constructor(l,u,p,x,b=!1){this.primaryId=bc.from(l),this.primaryOptions=u,p&&(this.secondaryId=bc.from(p)),this.secondaryOptions=x,this.available=b}toString(){return this.primaryId&&this.secondaryId?`[${this.primaryId.name},${this.secondaryId.name}]`:this.primaryId.name}hasPrimary(){return!!this.primaryId}getPrimary(){return new Pu(this.primaryId,this.primaryOptions)}hasSecondary(){return!!this.secondaryId}getSecondary(){return this.secondaryId?new Pu(this.secondaryId,this.secondaryOptions):null}static from(l){return typeof l=="string"?Yl.build({name:l}):l}static build(l,u,p,x){return!l||typeof l=="object"&&!("name"in l)?null:new Yl(l,p,u,x)}}function pI(h,l,u,p){return typeof h=="number"&&h>=0&&h<=255&&typeof l=="number"&&l>=0&&l<=255&&typeof u=="number"&&u>=0&&u<=255?p===void 0||typeof p=="number"&&p>=0&&p<=1?null:`Invalid rgba value [${[h,l,u,p].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${(typeof p=="number"?[h,l,u,p]:[h,l,u]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function ty(h){if(h===null||typeof h=="string"||typeof h=="boolean"||typeof h=="number"||h instanceof as||h instanceof zE||h instanceof Ko||h instanceof Yl)return!0;if(Array.isArray(h)){for(const l of h)if(!ty(l))return!1;return!0}if(typeof h=="object"){for(const l in h)if(!ty(h[l]))return!1;return!0}return!1}function Ui(h){if(h===null)return Bh;if(typeof h=="string")return xs;if(typeof h=="boolean")return ws;if(typeof h=="number")return Ur;if(h instanceof as)return Rl;if(h instanceof zE)return yp;if(h instanceof Ko)return C0;if(h instanceof Yl)return I0;if(Array.isArray(h)){const l=h.length;let u;for(const p of h){const x=Ui(p);if(u){if(u===x)continue;u=Ss;break}u=x}return dl(u||Ss,l)}return Wf}function tn(h){const l=typeof h;return h===null?"":l==="string"||l==="number"||l==="boolean"?String(h):h instanceof Ko||h instanceof Yl||h instanceof as?h.toString():JSON.stringify(h)}class Lr{constructor(l,u){this.type=l,this.value=u}static parse(l,u){if(l.length!==2)return u.error(`'literal' expression requires exactly one argument, but found ${l.length-1} instead.`);if(!ty(l[1]))return u.error("invalid value");const p=l[1];let x=Ui(p);const b=u.expectedType;return x.kind!=="array"||x.N!==0||!b||b.kind!=="array"||typeof b.N=="number"&&b.N!==0||(x=b),new Lr(x,p)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}serialize(){return this.type.kind==="array"||this.type.kind==="object"?["literal",this.value]:this.value instanceof as?["rgba"].concat(this.value.toNonPremultipliedRenderColor(null).toArray()):this.value instanceof Ko?this.value.serialize():this.value}}class da{constructor(l){this.name="ExpressionEvaluationError",this.message=l}toJSON(){return this.message}}const an={string:xs,number:Ur,boolean:ws,object:Wf};class qc{constructor(l,u){this.type=l,this.args=u}static parse(l,u){if(l.length<2)return u.error("Expected at least one argument.");let p,x=1;const b=l[0];if(b==="array"){let k,P;if(l.length>2){const O=l[1];if(typeof O!="string"||!(O in an)||O==="object")return u.error('The item type argument of "array" must be one of string, number, boolean',1);k=an[O],x++}else k=Ss;if(l.length>3){if(l[2]!==null&&(typeof l[2]!="number"||l[2]<0||l[2]!==Math.floor(l[2])))return u.error('The length argument to "array" must be a positive integer literal',2);P=l[2],x++}p=dl(k,P)}else p=an[b];const T=[];for(;xl.outputDefined())}serialize(){const l=this.type,u=[l.kind];if(l.kind==="array"){const p=l.itemType;if(p.kind==="string"||p.kind==="number"||p.kind==="boolean"){u.push(p.kind);const x=l.N;(typeof x=="number"||this.args.length>1)&&u.push(x)}}return u.concat(this.args.map(p=>p.serialize()))}}class xp{constructor(l){this.type=C0,this.sections=l}static parse(l,u){if(l.length<2)return u.error("Expected at least one argument.");const p=l[1];if(!Array.isArray(p)&&typeof p=="object")return u.error("First argument must be an image or text section.");const x=[];let b=!1;for(let T=1;T<=l.length-1;++T){const k=l[T];if(b&&typeof k=="object"&&!Array.isArray(k)){b=!1;let P=null;if(k["font-scale"]&&(P=u.parseObjectValue(k["font-scale"],T,"font-scale",Ur),!P))return null;let O=null;if(k["text-font"]&&(O=u.parseObjectValue(k["text-font"],T,"text-font",dl(xs)),!O))return null;let $=null;if(k["text-color"]&&($=u.parseObjectValue(k["text-color"],T,"text-color",Rl),!$))return null;const V=x[x.length-1];V.scale=P,V.font=O,V.textColor=$}else{const P=u.parse(l[T],T,Ss);if(!P)return null;const O=P.type.kind;if(O!=="string"&&O!=="value"&&O!=="null"&&O!=="resolvedImage")return u.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");b=!0,x.push({content:P,scale:null,font:null,textColor:null})}}return new xp(x)}evaluate(l){return new Ko(this.sections.map(u=>{const p=u.content.evaluate(l);return $h(Ui(p),I0)?new R0("",p,null,null,null):new R0(tn(p),null,u.scale?u.scale.evaluate(l):null,u.font?u.font.evaluate(l).join(","):null,u.textColor?u.textColor.evaluate(l):null)}))}eachChild(l){for(const u of this.sections)l(u.content),u.scale&&l(u.scale),u.font&&l(u.font),u.textColor&&l(u.textColor)}outputDefined(){return!1}serialize(){const l=["format"];for(const u of this.sections){l.push(u.content.serialize());const p={};u.scale&&(p["font-scale"]=u.scale.serialize()),u.font&&(p["text-font"]=u.font.serialize()),u.textColor&&(p["text-color"]=u.textColor.serialize()),l.push(p)}return l}}class Zr{constructor(l,u,p,x){this._imageWarnHistory={},this.type=I0,this.namePrimary=l,this.nameSecondary=u,p&&(this.paramsPrimary=p.params,this.iconsetIdPrimary=p.iconset?p.iconset.id:void 0),x&&(this.paramsSecondary=x.params,this.iconsetIdSecondary=x.iconset?x.iconset.id:void 0)}static parse(l,u){if(l.length<2)return u.error("Expected two or more arguments.");let p=1;const x=[];function b(){if(pbc.isEqual(T,b)),x.available){const T=x.getSecondary()?x.getSecondary().id:null;T&&(x.available=l.availableImages.some(k=>bc.isEqual(k,T)))}}return x}eachChild(l){if(l(this.namePrimary),this.paramsPrimary)for(const u in this.paramsPrimary)this.paramsPrimary[u]&&l(this.paramsPrimary[u]);if(this.nameSecondary&&(l(this.nameSecondary),this.paramsSecondary))for(const u in this.paramsSecondary)this.paramsSecondary[u]&&l(this.paramsSecondary[u])}outputDefined(){return!1}serializeOptions(l,u){const p={};if(u&&(p.iconset={id:u}),l){p.params={};for(const x in l)l[x]&&(p.params[x]=l[x].serialize())}return Object.keys(p).length>0?p:void 0}serialize(){const l=["image",this.namePrimary.serialize()];if(this.paramsPrimary||this.iconsetIdPrimary){const u=this.serializeOptions(this.paramsPrimary,this.iconsetIdPrimary);u&&l.push(u)}if(this.nameSecondary&&(l.push(this.nameSecondary.serialize()),this.paramsSecondary||this.iconsetIdSecondary)){const u=this.serializeOptions(this.paramsSecondary,this.iconsetIdSecondary);u&&l.push(u)}return l}}function L0(h){return kb(h)?"string":M0(h)?"number":D0(h)?"boolean":Array.isArray(h)?"array":h===null?"null":jb(h)?"object":typeof h}function jb(h){return h!=null&&!Array.isArray(h)&&typeof h!="function"&&!(h instanceof String||h instanceof Number||h instanceof Boolean)&&typeof h=="object"}function kb(h){return typeof h=="string"||h instanceof String}function M0(h){return typeof h=="number"||h instanceof Number}function D0(h){return typeof h=="boolean"||h instanceof Boolean}const V5={"to-boolean":ws,"to-color":Rl,"to-number":Ur,"to-string":xs};class ld{constructor(l,u){this.type=l,this.args=u}static parse(l,u){if(l.length<2)return u.error("Expected at least one argument.");const p=l[0],x=[];let b=Bh;if(p==="to-array"){if(!Array.isArray(l[1]))return null;const T=l[1].length;if(u.expectedType){if(u.expectedType.kind!=="array")return u.error(`Expected ${u.expectedType.kind} but found array.`);b=dl(u.expectedType.itemType,T)}else{if(!(T>0&&ty(l[1][0])))return null;b=dl(Ui(l[1][0]),T)}for(let k=0;k4?`Invalid rbga value ${JSON.stringify(u)}: expected an array containing either three or four numeric values.`:pI(u[0],u[1],u[2],u[3]),!p))return new as(u[0]/255,u[1]/255,u[2]/255,u[3])}throw new da(p||`Could not parse color from value '${typeof u=="string"?u:String(JSON.stringify(u))}'`)}if(this.type.kind==="number"){let u=null;for(const p of this.args){if(u=p.evaluate(l),u===null)return 0;const x=Number(u);if(!isNaN(x))return x}throw new da(`Could not convert ${JSON.stringify(u)} to number.`)}return this.type.kind==="formatted"?Ko.fromString(tn(this.args[0].evaluate(l))):this.type.kind==="resolvedImage"?Yl.build(tn(this.args[0].evaluate(l))):this.type.kind==="array"?this.args.map(u=>u.evaluate(l)):tn(this.args[0].evaluate(l))}eachChild(l){this.args.forEach(l)}outputDefined(){return this.args.every(l=>l.outputDefined())}serialize(){if(this.type.kind==="formatted")return new xp([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if(this.type.kind==="resolvedImage")return new Zr(this.args[0]).serialize();const l=this.type.kind==="array"?[]:[`to-${this.type.kind}`];return this.eachChild(u=>{l.push(u.serialize())}),l}}const _p=["Unknown","Point","LineString","Polygon"];class O0{constructor(l,u,p){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache={},this.availableImages=null,this.canonical=null,this.featureTileCoord=null,this.featureDistanceData=null,this.scope=l,this.options=u,this.iconImageUseTheme=p}id(){return this.feature&&this.feature.id!==void 0?this.feature.id:null}geometryType(){return this.feature?typeof this.feature.type=="number"?_p[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}measureLight(l){return this.globals.brightness||0}distanceFromCenter(){if(this.featureTileCoord&&this.featureDistanceData){const l=this.featureDistanceData.center,u=this.featureDistanceData.scale,{x:p,y:x}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(p*u-l[0])+this.featureDistanceData.bearing[1]*(x*u-l[1])}return 0}parseColor(l){let u=this._parseColorCache[l];return u||(u=this._parseColorCache[l]=as.parse(l)),u}getConfig(l){return this.options?this.options.get(l):null}}class Wa{constructor(l,u,p,x,b){this.name=l,this.type=u,this._evaluate=p,this.args=x,this._overloadIndex=b}evaluate(l){if(!this._evaluate){const u=Wa.definitions[this.name];this._evaluate=Array.isArray(u)?u[2]:u.overloads[this._overloadIndex][1]}return this._evaluate(l,this.args)}eachChild(l){this.args.forEach(l)}outputDefined(){return!1}serialize(){return[this.name].concat(this.args.map(l=>l.serialize()))}static parse(l,u){const p=l[0],x=Wa.definitions[p];if(!x)return u.error(`Unknown expression "${p}". If you wanted a literal array, use ["literal", [...]].`,0);const b=Array.isArray(x)?x[0]:x.type,T=Array.isArray(x)?[[x[1],x[2]]]:x.overloads,k=[];let P=null,O=-1;for(const[$,V]of T){if(Array.isArray($)&&$.length!==l.length-1)continue;k.push($),O++,P=new Mb(u.registry,u.path,null,u.scope,void 0,u._scope,u.options,u.iconImageUseTheme);const G=[];let Y=!1;for(let X=1;XG)).map(Kf).join(" | "),V=[];for(let G=1;Gu;){if(p-u>600){const P=p-u+1,O=l-u+1,$=Math.log(P),V=.5*Math.exp(2*$/3),G=.5*Math.sqrt($*V*(P-V)/P)*(O-P/2<0?-1:1);gI(h,l,Math.max(u,Math.floor(l-O*V/P+G)),Math.min(p,Math.floor(l+(P-O)*V/P+G)),x)}const b=h[l];let T=u,k=p;for(F0(h,u,l),x(h[p],b)>0&&F0(h,u,p);T0;)k--}x(h[u],b)===0?F0(h,u,k):(k++,F0(h,k,p)),k<=l&&(u=k+1),l<=k&&(p=k-1)}}function F0(h,l,u){const p=h[l];h[l]=h[u],h[u]=p}function Nb(h,l){return hl?1:0}function yI(h){let l=0;for(let u,p,x=0,b=h.length,T=b-1;x=l[2]||h[1]<=l[1]||h[3]>=l[3])}function q5(h,l,u){const p=h[0]-l[0],x=h[1]-l[1],b=h[0]-u[0],T=h[1]-u[1];return p*T-b*x===0&&p*b<=0&&x*T<=0}function UE(h,l,u){return l[1]>h[1]!=u[1]>h[1]&&h[0]<(u[0]-l[0])*(h[1]-l[1])/(u[1]-l[1])+l[0]}function ry(h,l,u=!1){let p=!1;for(let x=0,b=l.length;x0&&k<0||T<0&&k>0}function $0(h,l,u,p){return(x=[p[0]-u[0],p[1]-u[1]])[0]*(b=[l[0]-h[0],l[1]-h[1]])[1]-x[1]*b[0]!==0&&!(!xI(h,l,u,p)||!xI(u,p,h,l));var x,b}function VE(h){const l=new Ft(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),u=new Ft(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY);for(const p of h[0])l.x>p.x&&(l.x=p.x),l.y>p.y&&(l.y=p.y),u.xu[2]){const x=.5*p;let b=h[0]-u[0]>x?-p:u[0]-h[0]>x?p:0;b===0&&(b=h[0]-u[2]>x?-p:u[2]-h[0]>x?p:0),h[0]+=b}cd(l,h)}function HE(h,l,u,p){const x=Math.pow(2,p.z)*Yf,b=[p.x*Yf,p.y*Yf],T=[];if(!h)return T;for(const k of h)for(const P of k){const O=[P.x+b[0],P.y+b[1]];Ru(O,l,u,x),T.push(O)}return T}function WE(h,l,u,p){const x=Math.pow(2,p.z)*Yf,b=[p.x*Yf,p.y*Yf],T=[];if(!h)return T;for(const P of h){const O=[];for(const $ of P){const V=[$.x+b[0],$.y+b[1]];cd(l,V),O.push(V)}T.push(O)}if(l[2]-l[0]<=x/2){(k=l)[0]=k[1]=1/0,k[2]=k[3]=-1/0;for(const P of T)for(const O of P)Ru(O,l,u,x)}var k;return T}class Zf{constructor(l,u){this.type=ws,this.geojson=l,this.geometries=u}static parse(l,u){if(l.length!==2)return u.error(`'within' expression requires exactly one argument, but found ${l.length-1} instead.`);if(ty(l[1])){const p=l[1];if(p.type==="FeatureCollection")for(let x=0;xu)return Ib(b,T,(u-(p-k))/k)}return l[l.length-1]}pointToSegmentDistance(l,u,p){let[x,b]=u,T=Gc(p[0]-x)*this.kx,k=(p[1]-b)*this.ky;if(T!==0||k!==0){const P=(Gc(l[0]-x)*this.kx*T+(l[1]-b)*this.ky*k)/(T*T+k*k);P>1?(x=p[0],b=p[1]):P>0&&(x+=T/this.kx*P,b+=k/this.ky*P)}return T=Gc(l[0]-x)*this.kx,k=(l[1]-b)*this.ky,Math.sqrt(T*T+k*k)}pointOnLine(l,u){let p=1/0,x=l[0][0],b=l[0][1],T=0,k=0;for(let P=0;P1?(O=l[P+1][0],$=l[P+1][1]):Y>0&&(O+=V/this.kx*Y,$+=G/this.ky*Y)),V=Gc(u[0]-O)*this.kx,G=(u[1]-$)*this.ky;const X=V*V+G*G;Xb.index||x.index===b.index&&x.t>b.t){const O=x;x=b,b=O}const T=[x.point],k=x.index+1,P=b.index;!ZE(p[k],T[0])&&k<=P&&T.push(p[k]);for(let O=k+1;O<=P;O++)T.push(p[O]);return ZE(p[P],b.point)||T.push(b.point),T}lineSliceAlong(l,u,p){let x=0;const b=[];for(let T=0;Tl&&b.length===0&&b.push(Ib(k,P,(l-(x-O))/O)),x>=u)return b.push(Ib(k,P,(u-(x-O))/O)),b;x>l&&b.push(P)}return b}bufferPoint(l,u){const p=u/this.ky,x=u/this.kx;return[l[0]-x,l[1]-p,l[0]+x,l[1]+p]}bufferBBox(l,u){const p=u/this.ky,x=u/this.kx;return[l[0]-x,l[1]-p,l[2]+x,l[3]+p]}insideBBox(l,u){return Gc(l[0]-u[0])>=0&&Gc(l[0]-u[2])<=0&&l[1]>=u[1]&&l[1]<=u[3]}}function ZE(h,l){return h[0]===l[0]&&h[1]===l[1]}function Ib(h,l,u){const p=Gc(l[0]-h[0]);return[h[0]+p*u,h[1]+(l[1]-h[1])*u]}function Gc(h){for(;h<-180;)h+=360;for(;h>180;)h-=360;return h}class U0{constructor(l=[],u=(p,x)=>px?1:0){if(this.data=l,this.length=this.data.length,this.compare=u,this.length>0)for(let p=(this.length>>1)-1;p>=0;p--)this._down(p)}push(l){this.data.push(l),this._up(this.length++)}pop(){if(this.length===0)return;const l=this.data[0],u=this.data.pop();return--this.length>0&&(this.data[0]=u,this._down(0)),l}peek(){return this.data[0]}_up(l){const{data:u,compare:p}=this,x=u[l];for(;l>0;){const b=l-1>>1,T=u[b];if(p(x,T)>=0)break;u[l]=T,l=b}u[l]=x}_down(l){const{data:u,compare:p}=this,x=this.length>>1,b=u[l];for(;l=0)break;u[l]=u[T],l=T}u[l]=b}}var fr=8192;function vI(h,l){return l.dist-h.dist}function bI(h){const l=[1/0,1/0,-1/0,-1/0];if(l.length!==h.length)return!1;for(let u=0;u=h[0]&&h[1]h[1])return[null,null];const u=bp(h);if(l){if(u===2)return[h,null];const p=Math.floor(u/2);return[[h[0],h[0]+p],[h[0]+p,h[1]]]}{if(u===1)return[h,null];const p=Math.floor(u/2)-1;return[[h[0],h[0]+p],[h[0]+p+1,h[1]]]}}function Xf(h,l){const u=[1/0,1/0,-1/0,-1/0];if(!ud(l,h.length))return u;for(let p=l[0];p<=l[1];++p)cd(u,h[p]);return u}function V0(h){const l=[1/0,1/0,-1/0,-1/0];for(let u=0;ul[2]&&(p=h[0]-l[2]),h[1]>l[3]&&(x=h[1]-l[3]),h[3]=p)return p;if(B0(x,b)){if(jI(h,l))return 0}else if(jI(l,h))return 0;let T=p;for(const k of h)for(let P=0,O=k.length,$=O-1;P=b)continue;const $=O.range1;if(bp($)<=k){if(!ud($,h.length))return NaN;if(l){const V=yi(h,$,u,p);if((b=Math.min(b,V))===0)return b}else for(let V=$[0];V<=$[1];++V){const G=Y5(h[V],u,p);if((b=Math.min(b,G))===0)return b}}else{const V=iy($,l);if(V[0]!==null){const G=ay(Xf(h,V[0]),P,p);G=T)continue;const V=$.range1,G=$.range2;if(bp(V)<=P&&bp(G)<=O){if(!ud(V,h.length)||!ud(G,u.length))return NaN;if(l&&p?T=Math.min(T,K5(h,V,u,G,x)):l||p?l&&!p?T=Math.min(T,TI(u,G,h,V,x)):!l&&p&&(T=Math.min(T,TI(h,V,u,G,x))):T=Math.min(T,EI(h,V,u,G,x)),T===0)return T}else{const Y=iy(V,l),X=iy(G,p);Pb(k,T,x,h,u,Y[0],X[0]),Pb(k,T,x,h,u,Y[0],X[1]),Pb(k,T,x,h,u,Y[1],X[0]),Pb(k,T,x,h,u,Y[1],X[1])}}return T}function QE(h,l,u,p,x=1/0){let b=x;const T=Xf(h,[0,h.length-1]);for(const k of u)if(!(b!==1/0&&ay(T,Xf(k,[0,k.length-1]),p)>=b)&&(b=Math.min(b,kI(h,l,k,!0,p,b)),b===0))return b;return b}function Rb(h,l,u,p,x=1/0){let b=x;const T=Xf(h,[0,h.length-1]);for(const k of u){if(b!==1/0&&ay(T,V0(k),p)>=b)continue;const P=X5(h,l,k,p,b);if(isNaN(P))return P;if((b=Math.min(b,P))===0)return b}return b}function JE(h){return h==="Point"||h==="MultiPoint"||h==="LineString"||h==="MultiLineString"||h==="Polygon"||h==="MultiPolygon"}class wp{constructor(l,u){this.type=Ur,this.geojson=l,this.geometries=u}static parse(l,u){if(l.length!==2)return u.error(`'distance' expression requires either one argument, but found ' ${l.length-1} instead.`);if(ty(l[1])){const p=l[1];if(p.type==="FeatureCollection"){for(let x=0;x{l&&!Sp(u)&&(l=!1)}),l}function oy(h){if(h instanceof Wa&&h.name==="feature-state")return!1;let l=!0;return h.eachChild(u=>{l&&!oy(u)&&(l=!1)}),l}function Kd(h,l){if(h instanceof Wa&&l.indexOf(h.name)>=0)return!1;let u=!0;return h.eachChild(p=>{u&&!Kd(p,l)&&(u=!1)}),u}function AI(h,l,u){return[h,l,u].filter(Boolean).join("")}function ej(h,l){switch(h){case"string":return tn(l);case"number":return+l;case"boolean":return!!l;case"color":return as.parse(l);case"formatted":return Ko.fromString(tn(l));case"resolvedImage":return Yl.build(tn(l))}return l}function NI(h,l,u,p){return p!==void 0&&(h=p*Math.round(h/p)),l!==void 0&&hu&&(h=u),h}class ly{constructor(l,u,p,x=!1){this.type=l,this.key=u,this.scope=p,this.featureConstant=x}static parse(l,u){let p=u.expectedType;if(p==null&&(p=Ss),l.length<2||l.length>3)return u.error("Invalid number of arguments for 'config' expression.");const x=u.parse(l[1],1);if(!(x instanceof Lr))return u.error("Key name of 'config' expression must be a string literal.");let b,T=!0;const k=tn(x.value);if(l.length>=3){const P=u.parse(l[2],2);if(!(P instanceof Lr))return u.error("Scope of 'config' expression must be a string literal.");b=tn(P.value)}if(u.options){const P=AI(k,b,u._scope),O=u.options.get(P);O&&(T=Sp(O.value||O.default))}return new ly(p,k,b,T)}evaluate(l){const u=AI(this.key,this.scope,l.scope),p=l.getConfig(u);if(!p)return null;const{type:x,value:b,values:T,minValue:k,maxValue:P,stepValue:O}=p,$=p.default.evaluate(l);let V=$;if(b){const G=l.scope;l.scope=(G||"").split("").slice(1).join(""),V=b.evaluate(l),l.scope=G}return x&&(V=ej(x,V)),V===void 0||k===void 0&&P===void 0&&O===void 0||(typeof V=="number"?V=NI(V,k,P,O):Array.isArray(V)&&(V=V.map(G=>typeof G=="number"?NI(G,k,P,O):G))),b!==void 0&&V!==void 0&&T&&!T.includes(V)&&(V=$,x&&(V=ej(x,V))),(x&&x!==this.type||V!==void 0&&!$h(Ui(V),this.type))&&(V=ej(this.type.kind,V)),V}eachChild(){}outputDefined(){return!1}serialize(){const l=["config",this.key];return this.scope&&l.concat(this.scope),l}}class Lb{constructor(l,u){this.type=u.type,this.name=l,this.boundExpression=u}static parse(l,u){if(l.length!==2||typeof l[1]!="string")return u.error("'var' expression requires exactly one string literal argument.");const p=l[1];return u.scope.has(p)?new Lb(p,u.scope.get(p)):u.error(`Unknown variable "${p}". Make sure "${p}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(l){return this.boundExpression.evaluate(l)}eachChild(){}outputDefined(){return!1}serialize(){return["var",this.name]}}class Mb{constructor(l,u=[],p,x=new gp,b=[],T,k,P){this.registry=l,this.path=u,this.key=u.map(O=>typeof O=="string"?`['${O}']`:`[${O}]`).join(""),this.scope=x,this.errors=b,this.expectedType=p,this._scope=T,this.options=k,this.iconImageUseTheme=P}parse(l,u,p,x,b={}){return u||p?this.concat(u,null,p,x)._parse(l,b):this._parse(l,b)}parseObjectValue(l,u,p,x,b,T={}){return this.concat(u,p,x,b)._parse(l,T)}_parse(l,u){function p(x,b,T){return T==="assert"?new qc(b,[x]):T==="coerce"?new ld(b,[x]):x}if(l!==null&&typeof l!="string"&&typeof l!="boolean"&&typeof l!="number"||(l=["literal",l]),Array.isArray(l)){if(l.length===0)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const x=typeof l[0]=="string"?this.registry[l[0]]:void 0;if(x){let b=x.parse(l,this);if(!b)return null;if(this.expectedType){const T=this.expectedType,k=b.type;if(T.kind!=="string"&&T.kind!=="number"&&T.kind!=="boolean"&&T.kind!=="object"&&T.kind!=="array"||k.kind!=="value")if(T.kind!=="color"&&T.kind!=="formatted"&&T.kind!=="resolvedImage"||k.kind!=="value"&&k.kind!=="string"){if(this.checkSubtype(T,k))return null}else b=p(b,T,u.typeAnnotation||"coerce");else b=p(b,T,u.typeAnnotation||"assert")}if(!(b instanceof Lr)&&b.type.kind!=="resolvedImage"&&tj(b)){const T=new O0(this._scope,this.options,this.iconImageUseTheme);try{b=new Lr(b.type,b.evaluate(T))}catch(k){return this.error(k.message),null}}return b}return ld.parse(["to-array",l],this)}return this.error(l===void 0?"'undefined' value invalid. Use null instead.":typeof l=="object"?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof l} instead.`)}concat(l,u,p,x){let b=typeof l=="number"?this.path.concat(l):this.path;b=typeof u=="string"?b.concat(u):b;const T=x?this.scope.concat(x):this.scope;return new Mb(this.registry,b,p||null,T,this.errors,this._scope,this.options,this.iconImageUseTheme)}error(l,...u){const p=`${this.key}${u.map(x=>`[${x}]`).join("")}`;this.errors.push(new Iu(p,l))}checkSubtype(l,u){const p=P0(l,u);return p&&this.error(p),p}}function tj(h){if(h instanceof Lb)return tj(h.boundExpression);if(h instanceof Wa&&h.name==="error"||h instanceof Ab||h instanceof Zf||h instanceof wp||h instanceof ly)return!1;const l=h instanceof ld||h instanceof qc;let u=!0;return h.eachChild(p=>{u=l?u&&tj(p):u&&p instanceof Lr}),!!u&&Sp(h)&&Kd(h,["zoom","heatmap-density","worldview","line-progress","raster-value","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center","measure-light","raster-particle-speed","is-active-floor"])}function Db(h,l){const u=h.length-1;let p,x,b=0,T=u,k=0;for(;b<=T;)if(k=Math.floor((b+T)/2),p=h[k],x=h[k+1],p<=l){if(k===u||ll))throw new da("Input is not a number.");T=k-1}return 0}class q0{constructor(l,u,p){this.type=l,this.input=u,this.labels=[],this.outputs=[];for(const[x,b]of p)this.labels.push(x),this.outputs.push(b)}static parse(l,u){if(l.length-1<4)return u.error(`Expected at least 4 arguments, but found only ${l.length-1}.`);if((l.length-1)%2!=0)return u.error("Expected an even number of arguments.");const p=u.parse(l[1],1,Ur);if(!p)return null;const x=[];let b=null;u.expectedType&&u.expectedType.kind!=="value"&&(b=u.expectedType);for(let T=1;T=k)return u.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',O);const V=u.parse(P,$,b);if(!V)return null;b=b||V.type,x.push([k,V])}return new q0(b,p,x)}evaluate(l){const u=this.labels,p=this.outputs;if(u.length===1)return p[0].evaluate(l);const x=this.input.evaluate(l);if(x<=u[0])return p[0].evaluate(l);const b=u.length;return x>=u[b-1]?p[b-1].evaluate(l):p[Db(u,x)].evaluate(l)}eachChild(l){l(this.input);for(const u of this.outputs)l(u)}outputDefined(){return this.outputs.every(l=>l.outputDefined())}serialize(){const l=["step",this.input.serialize()];for(let u=0;u0&&l.push(this.labels[u]),l.push(this.outputs[u].serialize());return l}}const CI=.95047,II=1.08883,PI=4/29,cy=6/29,RI=3*cy*cy,Q5=cy*cy*cy,J5=Math.PI/180,eB=180/Math.PI;function rj(h){return h>Q5?Math.pow(h,1/3):h/RI+PI}function nj(h){return h>cy?h*h*h:RI*(h-PI)}function G0(h){return 255*(h<=.0031308?12.92*h:1.055*Math.pow(h,1/2.4)-.055)}function uy(h){return(h/=255)<=.04045?h/12.92:Math.pow((h+.055)/1.055,2.4)}function sj(h){const l=uy(h.r),u=uy(h.g),p=uy(h.b),x=rj((.4124564*l+.3575761*u+.1804375*p)/CI),b=rj((.2126729*l+.7151522*u+.072175*p)/1);return{l:116*b-16,a:500*(x-b),b:200*(b-rj((.0193339*l+.119192*u+.9503041*p)/II)),alpha:h.a}}function LI(h){let l=(h.l+16)/116,u=isNaN(h.a)?l:l+h.a/500,p=isNaN(h.b)?l:l-h.b/200;return l=1*nj(l),u=CI*nj(u),p=II*nj(p),new as(G0(3.2404542*u-1.5371385*l-.4985314*p),G0(-.969266*u+1.8760108*l+.041556*p),G0(.0556434*u-.2040259*l+1.0572252*p),h.alpha)}function tB(h,l,u){const p=l-h;return h+u*(p>180||p<-180?p-360*Math.round(p/360):p)}const H0={forward:sj,reverse:LI,interpolate:function(h,l,u){return{l:sn(h.l,l.l,u),a:sn(h.a,l.a,u),b:sn(h.b,l.b,u),alpha:sn(h.alpha,l.alpha,u)}}},dy={forward:function(h){const{l,a:u,b:p}=sj(h),x=Math.atan2(p,u)*eB;return{h:x<0?x+360:x,c:Math.sqrt(u*u+p*p),l,alpha:h.a}},reverse:function(h){const l=h.h*J5,u=h.c;return LI({l:h.l,a:Math.cos(l)*u,b:Math.sin(l)*u,alpha:h.alpha})},interpolate:function(h,l,u){return{h:tB(h.h,l.h,u),c:sn(h.c,l.c,u),l:sn(h.l,l.l,u),alpha:sn(h.alpha,l.alpha,u)}}};var ij=Object.freeze({__proto__:null,hcl:dy,lab:H0});class Yo{constructor(l,u,p,x,b){this.type=l,this.operator=u,this.interpolation=p,this.input=x,this.labels=[],this.outputs=[];for(const[T,k]of b)this.labels.push(T),this.outputs.push(k)}static interpolationFactor(l,u,p,x){let b=0;if(l.name==="exponential")b=Ob(u,l.base,p,x);else if(l.name==="linear")b=Ob(u,1,p,x);else if(l.name==="cubic-bezier"){const T=l.controlPoints;b=new Us(T[0],T[1],T[2],T[3]).solve(Ob(u,1,p,x))}return b}static parse(l,u){let[p,x,b,...T]=l;if(!Array.isArray(x)||x.length===0)return u.error("Expected an interpolation type expression.",1);if(x[0]==="linear")x={name:"linear"};else if(x[0]==="exponential"){const O=x[1];if(typeof O!="number")return u.error("Exponential interpolation requires a numeric base.",1,1);x={name:"exponential",base:O}}else{if(x[0]!=="cubic-bezier")return u.error(`Unknown interpolation type ${String(x[0])}`,1,0);{const O=x.slice(1);if(O.length!==4||O.some($=>typeof $!="number"||$<0||$>1))return u.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);x={name:"cubic-bezier",controlPoints:O}}}if(l.length-1<4)return u.error(`Expected at least 4 arguments, but found only ${l.length-1}.`);if(l.length-1>3&&(l.length-1)%2!=0)return u.error("Expected an even number of arguments.");if(b=u.parse(b,2,Ur),!b)return null;const k=[];let P=null;p==="interpolate-hcl"||p==="interpolate-lab"?P=Rl:u.expectedType&&u.expectedType.kind!=="value"&&(P=u.expectedType);for(let O=0;O=$)return u.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',G);const X=u.parse(V,Y,P);if(!X)return null;P=P||X.type,k.push([$,X])}return P.kind==="number"||P.kind==="color"||P.kind==="array"&&P.itemType.kind==="number"&&typeof P.N=="number"?new Yo(P,p,x,b,k):u.error(`Type ${ba(P)} is not interpolatable.`)}evaluate(l){const u=this.labels,p=this.outputs;if(u.length===1)return p[0].evaluate(l);const x=this.input.evaluate(l);if(x<=u[0])return p[0].evaluate(l);const b=u.length;if(x>=u[b-1])return p[b-1].evaluate(l);const T=Db(u,x),k=Yo.interpolationFactor(this.interpolation,x,u[T],u[T+1]),P=p[T].evaluate(l),O=p[T+1].evaluate(l);return this.operator==="interpolate"?Eb[this.type.kind.toLowerCase()](P,O,k):this.operator==="interpolate-hcl"?dy.reverse(dy.interpolate(dy.forward(P),dy.forward(O),k)):H0.reverse(H0.interpolate(H0.forward(P),H0.forward(O),k))}eachChild(l){l(this.input);for(const u of this.outputs)l(u)}outputDefined(){return this.outputs.every(l=>l.outputDefined())}serialize(){let l;l=this.interpolation.name==="linear"?["linear"]:this.interpolation.name==="exponential"?this.interpolation.base===1?["linear"]:["exponential",this.interpolation.base]:["cubic-bezier",...this.interpolation.controlPoints];const u=[this.operator,l,this.input.serialize()];for(let p=0;pP0(x,k.type));return new W0(T?Ss:p,b)}evaluate(l){let u,p=null,x=0;for(const b of this.args){if(x++,p=b.evaluate(l),p&&p instanceof Yl&&!p.available&&(u||(u=p),p=null,x===this.args.length))return u;if(p!==null)break}return p}eachChild(l){this.args.forEach(l)}outputDefined(){return this.args.every(l=>l.outputDefined())}serialize(){const l=["coalesce"];return this.eachChild(u=>{l.push(u.serialize())}),l}}class Fb{constructor(l,u){this.type=u.type,this.bindings=[].concat(l),this.result=u}evaluate(l){return this.result.evaluate(l)}eachChild(l){for(const u of this.bindings)l(u[1]);l(this.result)}static parse(l,u){if(l.length<4)return u.error(`Expected at least 3 arguments, but found ${l.length-1} instead.`);const p=[];for(let b=1;b=p.length)throw new da("Array index out of bounds: index exceeds array size");if(u!==Math.floor(u))throw new da("Array index must be an integer. Use at-interpolated for fractional indices");return p[u]}eachChild(l){l(this.index),l(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize()]}}class Y0{constructor(l,u,p){this.type=l,this.index=u,this.input=p}static parse(l,u){if(l.length!==3)return u.error(`Expected 2 arguments, but found ${l.length-1} instead.`);const p=u.parse(l[1],1,Ur),x=u.parse(l[2],2,dl(u.expectedType||Ss));return p&&x?new Y0(x.type.itemType,p,x):null}evaluate(l){const u=this.index.evaluate(l),p=this.input.evaluate(l);if(u<0)throw new da(`Array index out of bounds: ${u} < 0.`);if(u>p.length-1)throw new da(`Array index out of bounds: ${u} > ${p.length-1}.`);if(u===Math.floor(u))return p[u];const x=Math.floor(u),b=Math.ceil(u),T=p[x],k=p[b];if(typeof T!="number"||typeof k!="number")throw new da(`Cannot interpolate between non-number values at index ${u}.`);const P=u-x;return T*(1-P)+k*P}eachChild(l){l(this.index),l(this.input)}outputDefined(){return!1}serialize(){return["at-interpolated",this.index.serialize(),this.input.serialize()]}}class Z0{constructor(l,u){this.type=ws,this.needle=l,this.haystack=u}static parse(l,u){if(l.length!==3)return u.error(`Expected 2 arguments, but found ${l.length-1} instead.`),null;const p=u.parse(l[1],1,Ss),x=u.parse(l[2],2,Ss);return p&&x?$E(p.type,[ws,xs,Ur,Bh,Ss])?new Z0(p,x):(u.error(`Expected first argument to be of type boolean, string, number or null, but found ${ba(p.type)} instead`),null):null}evaluate(l){const u=this.needle.evaluate(l),p=this.haystack.evaluate(l);if(p==null)return!1;if(!ey(u,["boolean","string","number","null"]))throw new da(`Expected first argument to be of type boolean, string, number or null, but found ${ba(Ui(u))} instead.`);if(!ey(p,["string","array"]))throw new da(`Expected second argument to be of type array or string, but found ${ba(Ui(p))} instead.`);return p.indexOf(u)>=0}eachChild(l){l(this.needle),l(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}class Bb{constructor(l,u,p){this.type=Ur,this.needle=l,this.haystack=u,this.fromIndex=p}static parse(l,u){if(l.length<=2||l.length>=5)return u.error(`Expected 3 or 4 arguments, but found ${l.length-1} instead.`),null;const p=u.parse(l[1],1,Ss),x=u.parse(l[2],2,Ss);if(!p||!x)return null;if(!$E(p.type,[ws,xs,Ur,Bh,Ss]))return u.error(`Expected first argument to be of type boolean, string, number or null, but found ${ba(p.type)} instead`),null;if(l.length===4){const b=u.parse(l[3],3,Ur);return b?new Bb(p,x,b):null}return new Bb(p,x)}evaluate(l){const u=this.needle.evaluate(l),p=this.haystack.evaluate(l);if(!ey(u,["boolean","string","number","null"]))throw new da(`Expected first argument to be of type boolean, string, number or null, but found ${ba(Ui(u))} instead.`);if(!ey(p,["string","array"]))throw new da(`Expected second argument to be of type array or string, but found ${ba(Ui(p))} instead.`);if(this.fromIndex){const x=this.fromIndex.evaluate(l);return p.indexOf(u,x)}return p.indexOf(u)}eachChild(l){l(this.needle),l(this.haystack),this.fromIndex&&l(this.fromIndex)}outputDefined(){return!1}serialize(){if(this.fromIndex!=null&&this.fromIndex!==void 0){const l=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),l]}return["index-of",this.needle.serialize(),this.haystack.serialize()]}}class aj{constructor(l,u,p,x,b,T){this.inputType=l,this.type=u,this.input=p,this.cases=x,this.outputs=b,this.otherwise=T}static parse(l,u){if(l.length<5)return u.error(`Expected at least 4 arguments, but found only ${l.length-1}.`);if(l.length%2!=1)return u.error("Expected an even number of arguments.");let p,x;u.expectedType&&u.expectedType.kind!=="value"&&(x=u.expectedType);const b={},T=[];for(let O=2;ONumber.MAX_SAFE_INTEGER)return G.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if(typeof X=="number"&&Math.floor(X)!==X)return G.error("Numeric branch labels must be integer values.");if(p){if(G.checkSubtype(p,Ui(X)))return null}else p=Ui(X);if(b[String(X)]!==void 0)return G.error("Branch labels must be unique.");b[String(X)]=T.length}const Y=u.parse(V,O,x);if(!Y)return null;x=x||Y.type,T.push(Y)}const k=u.parse(l[1],1,Ss);if(!k)return null;const P=u.parse(l[l.length-1],l.length-1,x);return P?k.type.kind!=="value"&&u.concat(1).checkSubtype(p,k.type)?null:new aj(p,x,k,b,T,P):null}evaluate(l){const u=this.input.evaluate(l);return($h(Ui(u),this.inputType)&&this.outputs[this.cases[u]]||this.otherwise).evaluate(l)}eachChild(l){l(this.input),this.outputs.forEach(l),l(this.otherwise)}outputDefined(){return this.outputs.every(l=>l.outputDefined())&&this.otherwise.outputDefined()}serialize(){const l=["match",this.input.serialize()],u=Object.keys(this.cases).sort(),p=[],x={};for(const T of u){const k=x[this.cases[T]];k===void 0?(x[this.cases[T]]=p.length,p.push([this.cases[T],[T]])):p[k][1].push(T)}const b=T=>this.inputType.kind==="number"?Number(T):T;for(const[T,k]of p)l.push(k.length===1?b(k[0]):k.map(b)),l.push(this.outputs[T].serialize());return l.push(this.otherwise.serialize()),l}}class $b{constructor(l,u,p){this.type=l,this.branches=u,this.otherwise=p}static parse(l,u){if(l.length<4)return u.error(`Expected at least 3 arguments, but found only ${l.length-1}.`),null;if(l.length%2!=0)return u.error("Expected an odd number of arguments."),null;let p;u.expectedType&&u.expectedType.kind!=="value"&&(p=u.expectedType);const x=[];for(let T=1;Tu.outputDefined())&&this.otherwise.outputDefined()}serialize(){const l=["case"];return this.eachChild(u=>{l.push(u.serialize())}),l}}class X0{constructor(l,u,p,x){this.type=l,this.input=u,this.beginIndex=p,this.endIndex=x}static parse(l,u){if(l.length<=2||l.length>=5)return u.error(`Expected 3 or 4 arguments, but found ${l.length-1} instead.`),null;const p=u.parse(l[1],1,Ss),x=u.parse(l[2],2,Ur);if(!p||!x)return null;if(!$E(p.type,[dl(Ss),xs,Ss]))return u.error(`Expected first argument to be of type array or string, but found ${ba(p.type)} instead`),null;if(l.length===4){const b=u.parse(l[3],3,Ur);return b?new X0(p.type,p,x,b):null}return new X0(p.type,p,x)}evaluate(l){const u=this.input.evaluate(l),p=this.beginIndex.evaluate(l);if(!ey(u,["string","array"]))throw new da(`Expected first argument to be of type array or string, but found ${ba(Ui(u))} instead.`);if(this.endIndex){const x=this.endIndex.evaluate(l);return u.slice(p,x)}return u.slice(p)}eachChild(l){l(this.input),l(this.beginIndex),this.endIndex&&l(this.endIndex)}outputDefined(){return!1}serialize(){if(this.endIndex!=null&&this.endIndex!==void 0){const l=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),l]}return["slice",this.input.serialize(),this.beginIndex.serialize()]}}class oj{constructor(l,u){this.type=dl(xs),this.str=l,this.delimiter=u}static parse(l,u){if(l.length!==3)return u.error(`Expected 2 arguments, but found ${l.length-1} instead.`);const p=u.parse(l[1],1,xs),x=u.parse(l[2],2,xs);return p&&x?new oj(p,x):void 0}evaluate(l){const u=this.str.evaluate(l),p=this.delimiter.evaluate(l);return u.split(p)}eachChild(l){l(this.str),l(this.delimiter)}outputDefined(){return!1}serialize(){return["split",this.str.serialize(),this.delimiter.serialize()]}}function MI(h,l){return h==="=="||h==="!="?l.kind==="boolean"||l.kind==="string"||l.kind==="number"||l.kind==="null"||l.kind==="value":l.kind==="string"||l.kind==="number"||l.kind==="value"}function DI(h,l,u,p){return p.compare(l,u)===0}function Tp(h,l,u){const p=h!=="=="&&h!=="!=";return class B1e{constructor(b,T,k){this.type=ws,this.lhs=b,this.rhs=T,this.collator=k,this.hasUntypedArgument=b.type.kind==="value"||T.type.kind==="value"}static parse(b,T){if(b.length!==3&&b.length!==4)return T.error("Expected two or three arguments.");const k=b[0];let P=T.parse(b[1],1,Ss);if(!P)return null;if(!MI(k,P.type))return T.concat(1).error(`"${k}" comparisons are not supported for type '${ba(P.type)}'.`);let O=T.parse(b[2],2,Ss);if(!O)return null;if(!MI(k,O.type))return T.concat(2).error(`"${k}" comparisons are not supported for type '${ba(O.type)}'.`);if(P.type.kind!==O.type.kind&&P.type.kind!=="value"&&O.type.kind!=="value")return T.error(`Cannot compare types '${ba(P.type)}' and '${ba(O.type)}'.`);p&&(P.type.kind==="value"&&O.type.kind!=="value"?P=new qc(O.type,[P]):P.type.kind!=="value"&&O.type.kind==="value"&&(O=new qc(P.type,[O])));let $=null;if(b.length===4){if(P.type.kind!=="string"&&O.type.kind!=="string"&&P.type.kind!=="value"&&O.type.kind!=="value")return T.error("Cannot use collator to compare non-string types.");if($=T.parse(b[3],3,yp),!$)return null}return new B1e(P,O,$)}evaluate(b){const T=this.lhs.evaluate(b),k=this.rhs.evaluate(b);if(p&&this.hasUntypedArgument){const P=Ui(T),O=Ui(k);if(P.kind!==O.kind||P.kind!=="string"&&P.kind!=="number")throw new da(`Expected arguments for "${h}" to be (string, string) or (number, number), but found (${P.kind}, ${O.kind}) instead.`)}if(this.collator&&!p&&this.hasUntypedArgument){const P=Ui(T),O=Ui(k);if(P.kind!=="string"||O.kind!=="string")return l(b,T,k)}return this.collator?u(b,T,k,this.collator.evaluate(b)):l(b,T,k)}eachChild(b){b(this.lhs),b(this.rhs),this.collator&&b(this.collator)}outputDefined(){return!0}serialize(){const b=[h];return this.eachChild(T=>{b.push(T.serialize())}),b}}}const OI=Tp("==",function(h,l,u){return l===u},DI),zb=Tp("!=",function(h,l,u){return l!==u},function(h,l,u,p){return!DI(0,l,u,p)}),rB=Tp("<",function(h,l,u){return l",function(h,l,u){return l>u},function(h,l,u,p){return p.compare(l,u)>0}),nB=Tp("<=",function(h,l,u){return l<=u},function(h,l,u,p){return p.compare(l,u)<=0}),sB=Tp(">=",function(h,l,u){return l>=u},function(h,l,u,p){return p.compare(l,u)>=0});class Ub{constructor(l,u,p,x,b,T){this.type=xs,this.number=l,this.locale=u,this.currency=p,this.unit=x,this.minFractionDigits=b,this.maxFractionDigits=T}static parse(l,u){if(l.length!==3)return u.error("Expected two arguments.");const p=u.parse(l[1],1,Ur);if(!p)return null;const x=l[2];if(typeof x!="object"||Array.isArray(x))return u.error("NumberFormat options argument must be an object.");let b=null;if(x.locale&&(b=u.parseObjectValue(x.locale,2,"locale",xs),!b))return null;let T=null;if(x.currency&&(T=u.parseObjectValue(x.currency,2,"currency",xs),!T))return null;let k=null;if(x.unit&&(k=u.parseObjectValue(x.unit,2,"unit",xs),!k))return null;let P=null;if(x["min-fraction-digits"]&&(P=u.parseObjectValue(x["min-fraction-digits"],2,"min-fraction-digits",Ur),!P))return null;let O=null;return x["max-fraction-digits"]&&(O=u.parseObjectValue(x["max-fraction-digits"],2,"max-fraction-digits",Ur),!O)?null:new Ub(p,b,T,k,P,O)}evaluate(l){return new Intl.NumberFormat(this.locale?this.locale.evaluate(l):[],{style:(this.currency?"currency":this.unit&&"unit")||"decimal",currency:this.currency?this.currency.evaluate(l):void 0,unit:this.unit?this.unit.evaluate(l):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(l):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(l):void 0}).format(this.number.evaluate(l))}eachChild(l){l(this.number),this.locale&&l(this.locale),this.currency&&l(this.currency),this.unit&&l(this.unit),this.minFractionDigits&&l(this.minFractionDigits),this.maxFractionDigits&&l(this.maxFractionDigits)}outputDefined(){return!1}serialize(){const l={};return this.locale&&(l.locale=this.locale.serialize()),this.currency&&(l.currency=this.currency.serialize()),this.unit&&(l.unit=this.unit.serialize()),this.minFractionDigits&&(l["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(l["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),l]}}class Vb{constructor(l){this.type=Ur,this.input=l}static parse(l,u){if(l.length!==2)return u.error(`Expected 1 argument, but found ${l.length-1} instead.`),null;const p=u.parse(l[1],1);return p?p.type.kind!=="array"&&p.type.kind!=="string"&&p.type.kind!=="value"?(u.error(`Expected argument of type string or array, but found ${ba(p.type)} instead.`),null):new Vb(p):null}evaluate(l){const u=this.input.evaluate(l);if(typeof u=="string"||Array.isArray(u))return u.length;throw new da(`Expected value to be of type string or array, but found ${ba(Ui(u))} instead.`)}eachChild(l){l(this.input)}outputDefined(){return!1}serialize(){const l=["length"];return this.eachChild(u=>{l.push(u.serialize())}),l}}function BI(h){return function(){h=1831565813+(h|=0)|0;let l=Math.imul(h^h>>>15,1|h);return l=l+Math.imul(l^l>>>7,61|l)^l,((l^l>>>14)>>>0)/4294967296}}const hy={"==":OI,"!=":zb,">":FI,"<":rB,">=":sB,"<=":nB,array:qc,at:K0,"at-interpolated":Y0,boolean:qc,case:$b,coalesce:W0,collator:Ab,format:xp,image:Zr,in:Z0,"index-of":Bb,interpolate:Yo,"interpolate-hcl":Yo,"interpolate-lab":Yo,length:Vb,let:Fb,literal:Lr,match:aj,number:qc,"number-format":Ub,object:qc,slice:X0,step:q0,string:qc,"to-boolean":ld,"to-color":ld,"to-number":ld,"to-string":ld,var:Lb,within:Zf,distance:wp,config:ly,split:oj};function $I(h,[l,u,p,x]){l=l.evaluate(h),u=u.evaluate(h),p=p.evaluate(h);const b=x?x.evaluate(h):1,T=pI(l,u,p,b);if(T)throw new da(T);return new as(l/255,u/255,p/255,b)}function zI(h,[l,u,p,x]){l=l.evaluate(h),u=u.evaluate(h),p=p.evaluate(h);const b=x?x.evaluate(h):1,T=function(O,$,V,G){return typeof O=="number"&&O>=0&&O<=360?typeof $=="number"&&$>=0&&$<=100&&typeof V=="number"&&V>=0&&V<=100?G===void 0||typeof G=="number"&&G>=0&&G<=1?null:`Invalid hsla value [${[O,$,V,G].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid hsla value [${(typeof G=="number"?[O,$,V,G]:[O,$,V]).join(", ")}]: 's', and 'l' must be between 0 and 100.`:`Invalid hsla value [${(typeof G=="number"?[O,$,V,G]:[O,$,V]).join(", ")}]: 'h' must be between 0 and 360.`}(l,u,p,b);if(T)throw new da(T);const k=`hsla(${l}, ${u}%, ${p}%, ${b})`,P=as.parse(k);if(!P)throw new da(`Failed to parse HSLA color: ${k}`);return P}function Q0(h,l){return h in l}function qb(h,l){const u=l[h];return u===void 0?null:u}function Qf(h){return{type:h}}function Gb(h){if(h instanceof ly)return new Set([h.key]);let l=new Set;return h.eachChild(u=>{l=new Set([...l,...Gb(u)])}),l}function Hb(h){if(h instanceof Wa&&h.name==="is-active-floor")return!0;let l=!1;return h.eachChild(u=>{!l&&Hb(u)&&(l=!0)}),l}function UI(h){return{result:"success",value:h}}function Jf(h){return{result:"error",value:h}}function J0(h,l){return!!h&&!!h.parameters&&h.parameters.indexOf(l)>-1}function Wb(h){return h["property-type"]==="data-driven"}function VI(h){return J0(h.expression,"measure-light")}function lj(h){return J0(h.expression,"zoom")}function Kb(h){return!!h.expression&&h.expression.interpolated}function cj(h){return typeof h=="object"&&h!==null&&!Array.isArray(h)}function qI(h){return h}function GI(h,l){const u=l.type==="color",p=h.stops&&typeof h.stops[0][0]=="object",x=p||!(p||h.property!==void 0),b=h.type||(Kb(l)?"exponential":"interval");if(u&&((h=Object.assign({},h)).stops&&(h.stops=h.stops.map(O=>[O[0],as.parse(O[1])])),h.default=as.parse(h.default?h.default:l.default)),h.colorSpace&&h.colorSpace!=="rgb"&&!ij[h.colorSpace])throw new Error(`Unknown color space: ${h.colorSpace}`);let T,k,P;if(b==="exponential")T=HI;else if(b==="interval")T=aB;else if(b==="categorical"){T=iB,k=Object.create(null);for(const O of h.stops)k[O[0]]=O[1];P=typeof h.stops[0][0]}else{if(b!=="identity")throw new Error(`Unknown function type "${b}"`);T=WI}if(p){const O={},$=[];for(let Y=0;YY[0]),evaluate:({zoom:Y},X)=>HI({stops:V,base:h.base},l,Y).evaluate(Y,X)}}if(x){const O=b==="exponential"?{name:"exponential",base:h.base!==void 0?h.base:1}:null;return{kind:"camera",interpolationType:O,interpolationFactor:Yo.interpolationFactor.bind(void 0,O),zoomStops:h.stops.map($=>$[0]),evaluate:({zoom:$})=>T(h,l,$,k,P)}}return{kind:"source",evaluate(O,$){const V=$&&$.properties?$.properties[h.property]:void 0;return V===void 0?Yd(h.default,l.default):T(h,l,V,k,P)}}}function Yd(h,l,u){return h!==void 0?h:l!==void 0?l:u!==void 0?u:void 0}function iB(h,l,u,p,x){return Yd(typeof u===x?p[u]:void 0,h.default,l.default)}function aB(h,l,u){if(!M0(u))return Yd(h.default,l.default);const p=h.stops.length;if(p===1||u<=h.stops[0][0])return h.stops[0][1];if(u>=h.stops[p-1][0])return h.stops[p-1][1];const x=Db(h.stops.map(b=>b[0]),u);return h.stops[x][1]}function HI(h,l,u){const p=h.base!==void 0?h.base:1;if(!M0(u))return Yd(h.default,l.default);const x=h.stops.length;if(x===1||u<=h.stops[0][0])return h.stops[0][1];if(u>=h.stops[x-1][0])return h.stops[x-1][1];const b=Db(h.stops.map($=>$[0]),u),T=function($,V,G,Y){const X=Y-G,te=$-G;return X===0?0:V===1?te/X:(Math.pow(V,te)-1)/(Math.pow(V,X)-1)}(u,p,h.stops[b][0],h.stops[b+1][0]),k=h.stops[b][1],P=h.stops[b+1][1];let O=Eb[l.type]||qI;if(h.colorSpace&&h.colorSpace!=="rgb"){const $=ij[h.colorSpace];O=(V,G)=>$.reverse($.interpolate($.forward(V),$.forward(G),T))}return typeof k.evaluate=="function"?{evaluate(...$){const V=k.evaluate.apply(void 0,$),G=P.evaluate.apply(void 0,$);if(V!==void 0&&G!==void 0)return O(V,G,T)}}:O(k,P,T)}function WI(h,l,u){return l.type==="color"?u=as.parse(u):l.type==="formatted"?u=Ko.fromString(u.toString()):l.type==="resolvedImage"?u=Yl.build(u.toString()):L0(u)===l.type||l.type==="enum"&&l.values[u]||(u=void 0),Yd(u,h.default,l.default)}Wa.register(hy,{error:[{kind:"error"},[xs],(h,[l])=>{throw new da(l.evaluate(h))}],typeof:[xs,[Ss],(h,[l])=>ba(Ui(l.evaluate(h)))],"to-rgba":[dl(Ur,4),[Rl],(h,[l])=>l.evaluate(h).toNonPremultipliedRenderColor(null).toArray()],"to-hsla":[dl(Ur,4),[Rl],(h,[l])=>l.evaluate(h).toNonPremultipliedRenderColor(null).toHslaArray()],rgb:[Rl,[Ur,Ur,Ur],$I],rgba:[Rl,[Ur,Ur,Ur,Ur],$I],hsl:[Rl,[Ur,Ur,Ur],zI],hsla:[Rl,[Ur,Ur,Ur,Ur],zI],has:{type:ws,overloads:[[[xs],(h,[l])=>Q0(l.evaluate(h),h.properties())],[[xs,Wf],(h,[l,u])=>Q0(l.evaluate(h),u.evaluate(h))]]},get:{type:Ss,overloads:[[[xs],(h,[l])=>qb(l.evaluate(h),h.properties())],[[xs,Wf],(h,[l,u])=>qb(l.evaluate(h),u.evaluate(h))]]},"feature-state":[Ss,[xs],(h,[l])=>qb(l.evaluate(h),h.featureState||{})],properties:[Wf,[],h=>h.properties()],"geometry-type":[xs,[],h=>h.geometryType()],worldview:[xs,[],h=>h.globals.worldview||""],"is-active-floor":[ws,Qf(xs),(h,l)=>{if(!(h.globals&&h.globals.activeFloors&&h.globals.activeFloors.size>0))return!1;if(l.length===0)return!0;const u=h.globals.activeFloors;return l.some(p=>{const x=p.evaluate(h);return u.has(x)})}],id:[Ss,[],h=>h.id()],zoom:[Ur,[],h=>h.globals.zoom],pitch:[Ur,[],h=>h.globals.pitch||0],"distance-from-center":[Ur,[],h=>h.distanceFromCenter()],"measure-light":[Ur,[xs],(h,[l])=>h.measureLight(l.evaluate(h))],"heatmap-density":[Ur,[],h=>h.globals.heatmapDensity||0],"line-progress":[Ur,[],h=>h.globals.lineProgress||0],"raster-value":[Ur,[],h=>h.globals.rasterValue||0],"raster-particle-speed":[Ur,[],h=>h.globals.rasterParticleSpeed||0],"sky-radial-progress":[Ur,[],h=>h.globals.skyRadialProgress||0],accumulated:[Ss,[],h=>h.globals.accumulated===void 0?null:h.globals.accumulated],"+":[Ur,Qf(Ur),(h,l)=>{let u=0;for(const p of l)u+=p.evaluate(h);return u}],"*":[Ur,Qf(Ur),(h,l)=>{let u=1;for(const p of l)u*=p.evaluate(h);return u}],"-":{type:Ur,overloads:[[[Ur,Ur],(h,[l,u])=>l.evaluate(h)-u.evaluate(h)],[[Ur],(h,[l])=>-l.evaluate(h)]]},"/":[Ur,[Ur,Ur],(h,[l,u])=>l.evaluate(h)/u.evaluate(h)],"%":[Ur,[Ur,Ur],(h,[l,u])=>l.evaluate(h)%u.evaluate(h)],ln2:[Ur,[],()=>Math.LN2],pi:[Ur,[],()=>Math.PI],e:[Ur,[],()=>Math.E],"^":[Ur,[Ur,Ur],(h,[l,u])=>Math.pow(l.evaluate(h),u.evaluate(h))],sqrt:[Ur,[Ur],(h,[l])=>Math.sqrt(l.evaluate(h))],log10:[Ur,[Ur],(h,[l])=>Math.log(l.evaluate(h))/Math.LN10],ln:[Ur,[Ur],(h,[l])=>Math.log(l.evaluate(h))],log2:[Ur,[Ur],(h,[l])=>Math.log2(l.evaluate(h))],sin:[Ur,[Ur],(h,[l])=>Math.sin(l.evaluate(h))],cos:[Ur,[Ur],(h,[l])=>Math.cos(l.evaluate(h))],tan:[Ur,[Ur],(h,[l])=>Math.tan(l.evaluate(h))],asin:[Ur,[Ur],(h,[l])=>Math.asin(l.evaluate(h))],acos:[Ur,[Ur],(h,[l])=>Math.acos(l.evaluate(h))],atan:[Ur,[Ur],(h,[l])=>Math.atan(l.evaluate(h))],min:[Ur,Qf(Ur),(h,l)=>Math.min(...l.map(u=>u.evaluate(h)))],max:[Ur,Qf(Ur),(h,l)=>Math.max(...l.map(u=>u.evaluate(h)))],abs:[Ur,[Ur],(h,[l])=>Math.abs(l.evaluate(h))],round:[Ur,[Ur],(h,[l])=>{const u=l.evaluate(h);return u<0?-Math.round(-u):Math.round(u)}],floor:[Ur,[Ur],(h,[l])=>Math.floor(l.evaluate(h))],ceil:[Ur,[Ur],(h,[l])=>Math.ceil(l.evaluate(h))],"filter-==":[ws,[xs,Ss],(h,[l,u])=>h.properties()[l.value]===u.value],"filter-id-==":[ws,[Ss],(h,[l])=>h.id()===l.value],"filter-type-==":[ws,[xs],(h,[l])=>h.geometryType()===l.value],"filter-<":[ws,[xs,Ss],(h,[l,u])=>{const p=h.properties()[l.value],x=u.value;return typeof p==typeof x&&p{const u=h.id(),p=l.value;return typeof u==typeof p&&u":[ws,[xs,Ss],(h,[l,u])=>{const p=h.properties()[l.value],x=u.value;return typeof p==typeof x&&p>x}],"filter-id->":[ws,[Ss],(h,[l])=>{const u=h.id(),p=l.value;return typeof u==typeof p&&u>p}],"filter-<=":[ws,[xs,Ss],(h,[l,u])=>{const p=h.properties()[l.value],x=u.value;return typeof p==typeof x&&p<=x}],"filter-id-<=":[ws,[Ss],(h,[l])=>{const u=h.id(),p=l.value;return typeof u==typeof p&&u<=p}],"filter->=":[ws,[xs,Ss],(h,[l,u])=>{const p=h.properties()[l.value],x=u.value;return typeof p==typeof x&&p>=x}],"filter-id->=":[ws,[Ss],(h,[l])=>{const u=h.id(),p=l.value;return typeof u==typeof p&&u>=p}],"filter-has":[ws,[Ss],(h,[l])=>l.value in h.properties()],"filter-has-id":[ws,[],h=>h.id()!==null&&h.id()!==void 0],"filter-type-in":[ws,[dl(xs)],(h,[l])=>l.value.indexOf(h.geometryType())>=0],"filter-id-in":[ws,[dl(Ss)],(h,[l])=>l.value.indexOf(h.id())>=0],"filter-in-small":[ws,[xs,dl(Ss)],(h,[l,u])=>u.value.indexOf(h.properties()[l.value])>=0],"filter-in-large":[ws,[xs,dl(Ss)],(h,[l,u])=>function(p,x,b,T){for(;b<=T;){const k=b+T>>1;if(x[k]===p)return!0;x[k]>p?T=k-1:b=k+1}return!1}(h.properties()[l.value],u.value,0,u.value.length-1)],all:{type:ws,overloads:[[[ws,ws],(h,[l,u])=>l.evaluate(h)&&u.evaluate(h)],[Qf(ws),(h,l)=>{for(const u of l)if(!u.evaluate(h))return!1;return!0}]]},any:{type:ws,overloads:[[[ws,ws],(h,[l,u])=>l.evaluate(h)||u.evaluate(h)],[Qf(ws),(h,l)=>{for(const u of l)if(u.evaluate(h))return!0;return!1}]]},"!":[ws,[ws],(h,[l])=>!l.evaluate(h)],"is-supported-script":[ws,[xs],(h,[l])=>{const u=h.globals&&h.globals.isSupportedScript;return!u||u(l.evaluate(h))}],upcase:[xs,[xs],(h,[l])=>l.evaluate(h).toUpperCase()],downcase:[xs,[xs],(h,[l])=>l.evaluate(h).toLowerCase()],concat:[xs,Qf(Ss),(h,l)=>l.map(u=>tn(u.evaluate(h))).join("")],"resolved-locale":[xs,[yp],(h,[l])=>l.evaluate(h).resolvedLocale()],random:[Ur,[Ur,Ur,Ss],(h,l)=>{const[u,p,x]=l.map(T=>T.evaluate(h));if(u>p||u===p)return u;let b;if(typeof x=="string")b=function(T){let k=0;if(T.length===0)return k;for(let P=0;PJSON.stringify(V)).join(", ")}, but found ${JSON.stringify($)} instead.`);return $}catch($){const V=$;return this._warningHistory[V.message]||(this._warningHistory[V.message]=!0,typeof console<"u"&&console.warn(`Failed to evaluate expression "${JSON.stringify(this.expression.serialize())}". ${V.message}`)),this._defaultValue}}}function e_(h){return Array.isArray(h)&&h.length>0&&typeof h[0]=="string"&&h[0]in hy}function em(h,l,u,p,x){const b=new Mb(hy,[],l?function(k){const P={color:Rl,string:xs,number:Ur,enum:xs,boolean:ws,formatted:C0,resolvedImage:I0};return k.type==="array"?dl(P[k.value]||Ss,k.length):P[k.type]}(l):void 0,void 0,void 0,u,p,x),T=b.parse(h,void 0,void 0,void 0,l&&l.type==="string"?{typeAnnotation:"coerce"}:void 0);return T?UI(new Yb(T,l,u,p,x)):Jf(b.errors)}class fy{constructor(l,u,p,x){this.kind=l,this._styleExpression=u,this.isLightConstant=p,this.isLineProgressConstant=x,this.isStateDependent=l!=="constant"&&!oy(u.expression),this.configDependencies=Gb(u.expression),this.isIndoorDependent=Hb(u.expression)}evaluateWithoutErrorHandling(l,u,p,x,b,T){return this._styleExpression.evaluateWithoutErrorHandling(l,u,p,x,b,T)}evaluate(l,u,p,x,b,T,k){return this._styleExpression.evaluate(l,u,p,x,b,T,void 0,void 0,k)}}class Ep{constructor(l,u,p,x,b,T){this.kind=l,this.zoomStops=p,this._styleExpression=u,this.isStateDependent=l!=="camera"&&!oy(u.expression),this.isIndoorDependent=Hb(u.expression),this.isLightConstant=b,this.isLineProgressConstant=T,this.configDependencies=Gb(u.expression),this.interpolationType=x}evaluateWithoutErrorHandling(l,u,p,x,b,T){return this._styleExpression.evaluateWithoutErrorHandling(l,u,p,x,b,T)}evaluate(l,u,p,x,b,T){return this._styleExpression.evaluate(l,u,p,x,b,T)}interpolationFactor(l,u,p){return this.interpolationType?Yo.interpolationFactor(this.interpolationType,l,u,p):0}}function uj(h,l,u,p,x){if((h=em(h,l,u,p,x)).result==="error")return h;const b=h.value.expression,T=Sp(b);if(!T&&!Wb(l))return Jf([new Iu("","data expressions not supported")]);const k=Kd(b,["zoom","pitch","distance-from-center"]);if(!k&&!lj(l))return Jf([new Iu("","zoom expressions not supported")]);const P=Kd(b,["measure-light"]);if(!P&&!VI(l))return Jf([new Iu("","measure-light expression not supported")]);const O=Kd(b,["line-progress"]);if(!O&&!function(G){return J0(G.expression,"line-progress")}(l))return Jf([new Iu("","line-progress expression not supported")]);const $=l.expression&&l.expression.relaxZoomRestriction,V=dd(b);return V||k||$?V instanceof Iu?Jf([V]):V instanceof Yo&&!Kb(l)?Jf([new Iu("",'"interpolate" expressions cannot be used with this property')]):UI(V?new Ep(T&&O?"camera":"composite",h.value,V.labels,V instanceof Yo?V.interpolation:void 0,P,O):new fy(T&&O?"constant":"source",h.value,P,O)):Jf([new Iu("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression, or in the properties of atmosphere.')])}class Zb{constructor(l,u){this._parameters=l,this._specification=u,Object.assign(this,GI(this._parameters,this._specification))}static deserialize(l){return new Zb(l._parameters,l._specification)}static serialize(l){return{_parameters:l._parameters,_specification:l._specification}}}function dd(h){let l=null;if(h instanceof Fb)l=dd(h.result);else if(h instanceof W0){for(const u of h.args)if(l=dd(u),l)break}else(h instanceof q0||h instanceof Yo)&&h.input instanceof Wa&&h.input.name==="zoom"&&(l=h);return l instanceof Iu||h.eachChild(u=>{const p=dd(u);p instanceof Iu?l=p:l&&p&&l!==p&&(l=new Iu("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),l}var dj,KI,t_=function(){if(KI)return dj;KI=1,dj=l;var h=3;function l(u,p,x){var b=this.cells=[];if(u instanceof ArrayBuffer){this.arrayBuffer=u;var T=new Int32Array(this.arrayBuffer);u=T[0],this.d=(p=T[1])+2*(x=T[2]);for(var k=0;k=G[te+0]&&b>=G[te+1])?(P[X]=!0,k.push(V[X])):P[X]=!1}}},l.prototype._forEachCell=function(u,p,x,b,T,k,P,O){for(var $=this._convertToCellCoord(u),V=this._convertToCellCoord(p),G=this._convertToCellCoord(x),Y=this._convertToCellCoord(b),X=$;X<=G;X++)for(var te=V;te<=Y;te++){var se=this.d*te+X;if((!O||O(this._convertFromCellCoord(X),this._convertFromCellCoord(te),this._convertFromCellCoord(X+1),this._convertFromCellCoord(te+1)))&&T.call(this,u,p,x,b,se,k,P,O))return}},l.prototype._convertFromCellCoord=function(u){return(u-this.padding)/this.scale},l.prototype._convertToCellCoord=function(u){return Math.max(0,Math.min(this.d-1,Math.floor(u*this.scale)+this.padding))},l.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var u=this.cells,p=h+this.cells.length+1+1,x=0,b=0;b=0||(x[b]=Uh(h[b],l)));h instanceof Error&&(x.message=h.message)}if(x.$name)throw new Error("$name property is reserved for worker serialization logic.");return p!=="Object"&&(x.$name=p),x}throw new Error("can't serialize object of type "+typeof h)}function tm(h){if(h==null||typeof h=="boolean"||typeof h=="number"||typeof h=="string"||h instanceof Boolean||h instanceof Number||h instanceof String||h instanceof Date||h instanceof RegExp||r_(h)||h instanceof ImageBitmap||ArrayBuffer.isView(h)||h instanceof ImageData)return h;if(Array.isArray(h))return h.map(tm);if(typeof h=="object"){const l=h.$name||"Object";if(l==="Map"){const x=h.entries||[],b=new Map;for(let T=0;Th>=1536&&h<=1791,Xb=h=>h>=1872&&h<=1919,Qb=h=>h>=2208&&h<=2303,Jb=h=>h>=11904&&h<=12031,Vh=h=>h>=12032&&h<=12255,hj=h=>h>=12272&&h<=12287,n_=h=>h>=12288&&h<=12351,s_=h=>h>=12352&&h<=12447,kp=h=>h>=12448&&h<=12543,fj=h=>h>=12544&&h<=12591,ew=h=>h>=12704&&h<=12735,Zd=h=>h>=12736&&h<=12783,ZI=h=>h>=12784&&h<=12799,XI=h=>h>=12800&&h<=13055,QI=h=>h>=13056&&h<=13311,mj=h=>h>=13312&&h<=19903,tw=h=>h>=19968&&h<=40959,i_=h=>h>=40960&&h<=42127,pj=h=>h>=42128&&h<=42191,gj=h=>h>=44032&&h<=55215,rw=h=>h>=63744&&h<=64255,yj=h=>h>=64336&&h<=65023,JI=h=>h>=65040&&h<=65055,xj=h=>h>=65072&&h<=65103,eP=h=>h>=65104&&h<=65135,_j=h=>h>=65136&&h<=65279,vj=h=>h>=65280&&h<=65519;function bj(h){for(const l of h)if(wj(l.charCodeAt(0)))return!0;return!1}function oB(h){for(const l of h)if(!lB(l.charCodeAt(0)))return!1;return!0}function lB(h){return!(YI(h)||Xb(h)||Qb(h)||yj(h)||_j(h))}function cB(h){return!(h<11904||!(ew(h)||fj(h)||xj(h)||rw(h)||QI(h)||Jb(h)||Zd(h)||n_(h)||mj(h)||tw(h)||XI(h)||vj(h)||s_(h)||hj(h)||Vh(h)||ZI(h)||kp(h)||JI(h)||pj(h)||i_(h)))}function wj(h){return!(h!==746&&h!==747&&(h<4352||!(ew(h)||fj(h)||xj(h)&&!(h>=65097&&h<=65103)||rw(h)||QI(h)||Jb(h)||Zd(h)||!(!n_(h)||h>=12296&&h<=12305||h>=12308&&h<=12319||h===12336)||mj(h)||tw(h)||XI(h)||(l=>l>=12592&&l<=12687)(h)||(l=>l>=43360&&l<=43391)(h)||(l=>l>=55216&&l<=55295)(h)||(l=>l>=4352&&l<=4607)(h)||gj(h)||s_(h)||hj(h)||(l=>l>=12688&&l<=12703)(h)||Vh(h)||ZI(h)||kp(h)&&h!==12540||!(!vj(h)||h===65288||h===65289||h===65293||h>=65306&&h<=65310||h===65339||h===65341||h===65343||h>=65371&&h<=65503||h===65507||h>=65512&&h<=65519)||!(!eP(h)||h>=65112&&h<=65118||h>=65123&&h<=65126)||(l=>l>=5120&&l<=5759)(h)||(l=>l>=6320&&l<=6399)(h)||JI(h)||(l=>l>=19904&&l<=19967)(h)||i_(h)||pj(h))))}function tP(h){return h===12312||h===12313||h===12316||h===12540||h===12448}function Ap(h){return!(wj(h)||function(l){return!!((u=>u>=128&&u<=255)(l)&&(l===167||l===169||l===174||l===177||l===188||l===189||l===190||l===215||l===247)||(u=>u>=8192&&u<=8303)(l)&&(l===8214||l===8224||l===8225||l===8240||l===8241||l===8251||l===8252||l===8258||l===8263||l===8264||l===8265||l===8273)||(u=>u>=8448&&u<=8527)(l)||(u=>u>=8528&&u<=8591)(l)||(u=>u>=8960&&u<=9215)(l)&&(l>=8960&&l<=8967||l>=8972&&l<=8991||l>=8996&&l<=9e3||l===9003||l>=9085&&l<=9114||l>=9150&&l<=9165||l===9167||l>=9169&&l<=9179||l>=9186&&l<=9215)||(u=>u>=9216&&u<=9279)(l)&&l!==9251||(u=>u>=9280&&u<=9311)(l)||(u=>u>=9312&&u<=9471)(l)||(u=>u>=9632&&u<=9727)(l)||(u=>u>=9728&&u<=9983)(l)&&!(l>=9754&&l<=9759)||(u=>u>=11008&&u<=11263)(l)&&(l>=11026&&l<=11055||l>=11088&&l<=11097||l>=11192&&l<=11243)||n_(l)||kp(l)||(u=>u>=57344&&u<=63743)(l)||xj(l)||eP(l)||vj(l)||l===8734||l===8756||l===8757||l>=9984&&l<=10087||l>=10102&&l<=10131||l===65532||l===65533)}(h))}function rP(h){return YI(h)||Xb(h)||Qb(h)||yj(h)||_j(h)}function Sj(h){return h>=1424&&h<=2303||yj(h)||_j(h)}function nw(h,l){return!(!l&&Sj(h)||h>=2304&&h<=3583||h>=3840&&h<=4255||(u=>u>=6016&&u<=6143)(h))}function uB(h){for(const l of h)if(Sj(l.charCodeAt(0)))return!0;return!1}const wc={unavailable:"unavailable",deferred:"deferred",loading:"loading",parsing:"parsing",parsed:"parsed",loaded:"loaded",error:"error"};let Xd=null,hl=wc.unavailable,Hc=null;const nP=function(h){h&&typeof h=="string"&&h.indexOf("NetworkError")>-1&&(hl=wc.error),Xd&&Xd(h)};function Tj(){Ej.fire(new ad("pluginStateChange",{pluginStatus:hl,pluginURL:Hc}))}const Ej=new N0,jj=function(){return hl},sP=function(){if(hl!==wc.deferred||!Hc)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");hl=wc.loading,Tj(),Hc&&Zg({url:Hc},h=>{h?nP(h):(hl=wc.loaded,Tj())})},qh={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>hl===wc.loaded||qh.applyArabicShaping!=null,isLoading:()=>hl===wc.loading,setState(h){hl=h.pluginStatus,Hc=h.pluginURL},isParsing:()=>hl===wc.parsing,isParsed:()=>hl===wc.parsed,getPluginURL:()=>Hc},iP=function(){qh.isLoading()||qh.isLoaded()||jj()!=="deferred"||sP()};class fs{constructor(l,u){this.zoom=l,u?(this.now=u.now,this.fadeDuration=u.fadeDuration,this.transition=u.transition,this.pitch=u.pitch,this.brightness=u.brightness,this.worldview=u.worldview,this.activeFloors=u.activeFloors):(this.now=0,this.fadeDuration=0,this.transition={},this.pitch=0,this.brightness=0)}isSupportedScript(l){return function(u,p){for(const x of u)if(!nw(x.charCodeAt(0),p))return!1;return!0}(l,qh.isLoaded())}}class py{constructor(l,u,p,x,b){this.property=l,this.value=u,this.expression=function(T,k,P,O,$){if(cj(T))return new Zb(T,k);if(e_(T)||Array.isArray(T)&&T.length>0){const V=uj(T,k,P,O,$);if(V.result==="error")throw new Error(V.value.map(G=>`${G.key}: ${G.message}`).join(", "));return V.value}{let V=T;return typeof T=="string"&&k.type==="color"&&(V=as.parse(T)),{kind:"constant",configDependencies:new Set,isIndoorDependent:!1,evaluate:()=>V}}}(u===void 0?l.specification.default:u,l.specification,p,x,b)}isIndoorDependent(){return this.expression.isIndoorDependent}isDataDriven(){return this.expression.kind==="source"||this.expression.kind==="composite"}possiblyEvaluate(l,u,p,x){return this.property.possiblyEvaluate(this,l,u,p,x)}}class sw{constructor(l,u,p,x){this.property=l,this.value=new py(l,void 0,u,p,x)}transitioned(l,u){return new gy(this.property,this.value,u,Object.assign({},l.transition,this.transition),l.now)}untransitioned(){return new gy(this.property,this.value,null,{},0)}}class iw{constructor(l,u,p,x){this._properties=l,this._values=Object.create(l.defaultTransitionablePropertyValues),this._scope=u,this._options=p,this._iconImageUseTheme=x,this._isIndoorDependent=!1,this.configDependencies=new Set}getValue(l){return gr(this._values[l].value.value)}setValue(l,u){this._values.hasOwnProperty(l)||(this._values[l]=new sw(this._values[l].property,this._scope,this._options,this._iconImageUseTheme)),this._values[l].value=new py(this._values[l].property,u===null?void 0:gr(u),this._scope,this._options,this._iconImageUseTheme),this._values[l].value.expression.configDependencies&&(this.configDependencies=new Set([...this.configDependencies,...this._values[l].value.expression.configDependencies]),this._isIndoorDependent=this._isIndoorDependent||this._values[l].value.isIndoorDependent())}setTransitionOrValue(l,u){u&&(this._options=u);const p=this._properties.properties;if(l)for(const x in l){const b=l[x];if(x.endsWith("-transition")){const T=x.slice(0,-11);p[T]&&this.setTransition(T,b)}else p.hasOwnProperty(x)&&this.setValue(x,b)}}getTransition(l){return gr(this._values[l].transition)}setTransition(l,u){this._values.hasOwnProperty(l)||(this._values[l]=new sw(this._values[l].property)),this._values[l].transition=gr(u)||void 0}serialize(){const l={};for(const u of Object.keys(this._values)){const p=this.getValue(u);p!==void 0&&(l[u]=p);const x=this.getTransition(u);x!==void 0&&(l[`${u}-transition`]=x)}return l}transitioned(l,u){const p=new kj(this._properties);for(const x of Object.keys(this._values))p._values[x]=this._values[x].transitioned(l,u._values[x]);return p}untransitioned(){const l=new kj(this._properties);for(const u of Object.keys(this._values))l._values[u]=this._values[u].untransitioned();return l}isIndoorDependent(){return this._isIndoorDependent}}class gy{constructor(l,u,p,x,b){const T=x.delay||0,k=x.duration||0;b=b||0,this.property=l,this.value=u,this.begin=b+T,this.end=this.begin+k,l.specification.transition&&(x.delay||x.duration)&&(this.prior=p)}possiblyEvaluate(l,u,p){const x=l.now||0,b=this.value.possiblyEvaluate(l,u,p),T=this.prior;if(T){if(x>this.end)return this.prior=null,b;if(this.value.isDataDriven())return this.prior=null,b;if(x":1,">=":1,"<":1,"<=":1,"in":1,"!in":1,"all":1,"any":1,"none":1,"has":1,"!has":1}},"geometry_type":{"type":"enum","values":{"Point":1,"LineString":1,"Polygon":1}},"function":{"expression":{"type":"expression"},"stops":{"type":"array","value":"function_stop"},"base":{"type":"number","default":1,"minimum":0},"property":{"type":"string","default":"$zoom"},"type":{"type":"enum","values":{"identity":1,"exponential":1,"interval":1,"categorical":1},"default":"exponential"},"colorSpace":{"type":"enum","values":{"rgb":1,"lab":1,"hcl":1},"default":"rgb"},"default":{"type":"*"}},"function_stop":{"type":"array","minimum":0,"maximum":24,"value":["number","color"],"length":2},"expression":{"type":"array","value":"*","minimum":1},"fog":{"range":{"type":"array","default":[0.5,10],"minimum":-20,"maximum":20,"length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}},"color":{"type":"color","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"high-color":{"type":"color","default":"#245cdf","expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"space-color":{"type":"color","default":["interpolate",["linear"],["zoom"],4,"#010b19",7,"#367ab9"],"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"horizon-blend":{"type":"number","default":["interpolate",["linear"],["zoom"],4,0.2,7,0.1],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"star-intensity":{"type":"number","default":["interpolate",["linear"],["zoom"],5,0.35,6,0],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vertical-range":{"type":"array","default":[0,0],"minimum":0,"length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}}},"snow":{"density":{"type":"number","default":["interpolate",["linear"],["zoom"],11,0,13,0.85],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"intensity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"color":{"type":"color","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vignette":{"type":"number","default":["interpolate",["linear"],["zoom"],11,0,13,0.3],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vignette-color":{"type":"color","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"center-thinning":{"type":"number","default":0.4,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"direction":{"type":"array","default":[0,50],"minimum":0,"maximum":360,"length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}},"flake-size":{"type":"number","default":0.71,"minimum":0,"maximum":5,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true}},"rain":{"density":{"type":"number","default":["interpolate",["linear"],["zoom"],11,0,13,0.5],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"intensity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"color":{"type":"color","default":["interpolate",["linear"],["measure-light","brightness"],0,"#03113d",0.3,"#a8adbc"],"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"opacity":{"type":"number","default":["interpolate",["linear"],["measure-light","brightness"],0,0.88,1,0.7],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vignette":{"type":"number","default":["interpolate",["linear"],["zoom"],11,0,13,1],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vignette-color":{"type":"color","default":["interpolate",["linear"],["measure-light","brightness"],0,"#001736",0.3,"#464646"],"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"center-thinning":{"type":"number","default":0.57,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"direction":{"type":"array","default":[0,80],"minimum":0,"maximum":360,"length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}},"droplet-size":{"type":"array","default":[2.6,18.2],"minimum":0,"maximum":50,"length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}},"distortion-strength":{"type":"number","default":0.7,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true}},"camera":{"camera-projection":{"type":"enum","values":{"perspective":1,"orthographic":1},"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"default":"perspective"}},"colorTheme":{"data":{"type":"string","expression":{}}},"indoor_source":{"sourceId":{"type":"string"},"sourceLayers":{"type":"array","value":"string"}},"indoor":{"*":{"type":"indoor_source"}},"light":{"anchor":{"type":"enum","default":"viewport","values":{"map":1,"viewport":1},"expression":{"parameters":["zoom"]}},"position":{"type":"array","default":[1.15,210,30],"length":3,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"use-theme":true,"transition":true},"intensity":{"type":"number","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"projection":{"name":{"type":"enum","values":{"albers":1,"equalEarth":1,"equirectangular":1,"lambertConformalConic":1,"mercator":1,"naturalEarth":1,"winkelTripel":1,"globe":1},"default":"mercator"},"center":{"type":"array","length":2,"value":"number","minimum":[-180,-90],"maximum":[180,90]},"parallels":{"type":"array","length":2,"value":"number","minimum":[-90,-90],"maximum":[90,90]}},"terrain":{"source":{"type":"string"},"exaggeration":{"type":"number","default":1,"minimum":0,"maximum":1000,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"paint":["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_building","paint_symbol","paint_raster","paint_raster-particle","paint_hillshade","paint_background","paint_sky","paint_model"],"paint_fill":{"fill-antialias":{"type":"boolean","default":true,"expression":{"parameters":["zoom"]}},"fill-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-outline-color":{"type":"color","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"fill-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"fill-pattern-cross-fade":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-z-offset":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"fill-bridge-guard-rail-color":{"type":"color","default":"rgba(241, 236, 225, 255)","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature"]},"property-type":"data-driven"},"fill-tunnel-structure-color":{"type":"color","default":"rgba(241, 236, 225, 255)","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature"]},"property-type":"data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-extrusion-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"fill-extrusion-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"fill-extrusion-pattern-cross-fade":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-extrusion-height":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-height-alignment":{"type":"enum","values":{"terrain":1,"flat":1},"default":"flat"},"fill-extrusion-base-alignment":{"type":"enum","values":{"terrain":1,"flat":1},"default":"terrain"},"fill-extrusion-vertical-gradient":{"type":"boolean","default":true,"expression":{"parameters":["zoom"]}},"fill-extrusion-ambient-occlusion-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-radius":{"type":"number","default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-wall-radius":{"type":"number","default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-ground-radius":{"type":"number","default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-ground-attenuation":{"type":"number","default":0.69,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-flood-light-color":{"type":"color","default":"#ffffff","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-extrusion-flood-light-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-extrusion-flood-light-wall-radius":{"property-type":"data-driven","type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["feature","feature-state"]}},"fill-extrusion-flood-light-ground-radius":{"property-type":"data-driven","type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["feature","feature-state"]}},"fill-extrusion-flood-light-ground-attenuation":{"type":"number","default":0.69,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-vertical-scale":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-rounded-roof":{"type":"boolean","default":true,"expression":{"parameters":["zoom"]}},"fill-extrusion-cutoff-fade-range":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{}},"fill-extrusion-front-cutoff":{"type":"array","value":"number","expression":{"interpolated":true,"parameters":["zoom"]},"length":3,"default":[0,0,1],"minimum":[0,0,0],"maximum":[1,1,1]},"fill-extrusion-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature-state"]},"property-type":"data-driven"},"fill-extrusion-line-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-extrusion-cast-shadows":{"type":"boolean","default":true}},"paint_building":{"building-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"building-ambient-occlusion-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"parameters":[]},"transition":true},"building-ambient-occlusion-ground-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"building-ambient-occlusion-ground-radius":{"type":"number","default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"building-ambient-occlusion-ground-attenuation":{"type":"number","default":0.69,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"building-vertical-scale":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"building-cast-shadows":{"type":"boolean","default":true},"building-color":{"type":"color","default":"rgba(193, 154, 127, 1)","use-theme":true,"expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"property-type":"data-driven"},"building-emissive-strength":{"type":"number","default":0,"minimum":0,"maximum":5,"expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"property-type":"data-driven"},"building-facade-emissive-chance":{"type":"number","default":0.35,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["measure-light","zoom"]}},"building-cutoff-fade-range":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{}},"building-front-cutoff":{"type":"array","value":"number","expression":{"interpolated":true,"parameters":["zoom"]},"length":3,"default":[0,0,1],"minimum":[0,0,0],"maximum":[1,1,1]},"building-flood-light-color":{"type":"color","default":"#ffffff","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"building-flood-light-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"building-flood-light-ground-attenuation":{"type":"number","default":0.69,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}}},"paint_line":{"line-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"line-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"line-width":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light","line-progress"]},"property-type":"data-driven"},"line-gap-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-offset":{"type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-blur":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-dasharray":{"type":"array","value":"number","minimum":0,"expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-pattern-cross-fade":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"line-gradient":{"type":"color","use-theme":true,"expression":{"interpolated":true,"parameters":["line-progress"]}},"line-trim-offset":{"type":"array","value":"number","length":2,"default":[0,0],"minimum":[0,0],"maximum":[1,1]},"line-trim-fade-range":{"type":"array","value":"number","length":2,"default":[0,0],"minimum":[0,0],"maximum":[1,1],"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"line-trim-color":{"type":"color","default":"transparent","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"line-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-driven"},"line-border-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-border-color":{"type":"color","default":"rgba(0, 0, 0, 0)","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-occlusion-opacity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"line-blend-mode":{"type":"enum","values":{"default":1,"multiply":1,"additive":1},"default":"default","expression":{"parameters":["zoom"]}}},"paint_circle":{"circle-radius":{"type":"number","default":5,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-blur":{"type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"circle-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"circle-pitch-scale":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"circle-pitch-alignment":{"type":"enum","values":{"map":1,"viewport":1},"default":"viewport","expression":{"parameters":["zoom"]}},"circle-stroke-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-stroke-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-stroke-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}}},"paint_heatmap":{"heatmap-radius":{"type":"number","default":30,"minimum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"heatmap-weight":{"type":"number","default":1,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"heatmap-intensity":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"heatmap-color":{"type":"color","default":["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",0.1,"royalblue",0.3,"cyan",0.5,"lime",0.7,"yellow",1,"red"],"use-theme":true,"expression":{"interpolated":true,"parameters":["heatmap-density"]}},"heatmap-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}}},"paint_symbol":{"icon-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"appearance":true,"property-type":"data-driven"},"icon-occlusion-opacity":{"type":"number","minimum":0,"maximum":1,"default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"appearance":true,"property-type":"data-driven"},"icon-emissive-strength":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature-state"]},"appearance":true,"property-type":"data-driven"},"text-emissive-strength":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature-state"]},"appearance":true,"property-type":"data-driven"},"icon-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"appearance":true,"property-type":"data-driven"},"icon-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"appearance":true,"property-type":"data-driven"},"icon-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"appearance":true,"property-type":"data-driven"},"icon-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"appearance":true,"property-type":"data-driven"},"icon-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"appearance":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"icon-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"icon-image-cross-fade":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"text-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"appearance":true,"property-type":"data-driven"},"text-occlusion-opacity":{"type":"number","minimum":0,"maximum":1,"default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"appearance":true,"property-type":"data-driven"},"text-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"overridable":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"appearance":true,"property-type":"data-driven"},"text-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"appearance":true,"property-type":"data-driven"},"text-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"appearance":true,"property-type":"data-driven"},"text-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"appearance":true,"property-type":"data-driven"},"text-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"appearance":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"text-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"icon-color-saturation":{"type":"number","default":0,"minimum":-1,"maximum":1,"expression":{}},"icon-color-contrast":{"type":"number","default":0,"minimum":-1,"maximum":1,"expression":{}},"icon-color-brightness-min":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{}},"icon-color-brightness-max":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{}},"symbol-z-offset":{"type":"number","default":0,"minimum":0,"transition":true,"appearance":true,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"}},"paint_raster":{"raster-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-color":{"type":"color","use-theme":true,"expression":{"interpolated":true,"parameters":["raster-value"]}},"raster-color-mix":{"type":"array","default":[0.2126,0.7152,0.0722,0],"length":4,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-color-range":{"type":"array","length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-hue-rotate":{"type":"number","default":0,"period":360,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-brightness-min":{"type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-brightness-max":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-saturation":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-contrast":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-resampling":{"type":"enum","values":{"linear":1,"nearest":1},"default":"linear","expression":{"parameters":["zoom"]}},"raster-fade-duration":{"type":"number","default":300,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"raster-array-band":{"type":"string"},"raster-elevation":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-elevation-reference":{"type":"enum","values":{"sea":1,"ground":1},"default":"sea","expression":{}}},"paint_raster-particle":{"raster-particle-array-band":{"type":"string"},"raster-particle-count":{"type":"number","default":512,"minimum":1},"raster-particle-color":{"type":"color","use-theme":true,"expression":{"interpolated":true,"parameters":["raster-particle-speed"]}},"raster-particle-max-speed":{"type":"number","default":1,"minimum":1},"raster-particle-speed-factor":{"type":"number","default":0.2,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-particle-fade-opacity-factor":{"type":"number","default":0.98,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-particle-reset-rate-factor":{"type":"number","default":0.8,"minimum":0,"maximum":1},"raster-particle-elevation":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}}},"paint_hillshade":{"hillshade-illumination-direction":{"type":"number","default":335,"minimum":0,"maximum":359,"expression":{"interpolated":true,"parameters":["zoom"]}},"hillshade-illumination-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"viewport","expression":{"parameters":["zoom"]}},"hillshade-exaggeration":{"type":"number","default":0.5,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"hillshade-shadow-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"hillshade-highlight-color":{"type":"color","default":"#FFFFFF","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"hillshade-accent-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"hillshade-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}}},"paint_background":{"background-pitch-alignment":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":[]}},"background-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"background-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom"]}},"background-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"background-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}}},"paint_sky":{"sky-type":{"type":"enum","values":{"gradient":1,"atmosphere":1},"default":"atmosphere","expression":{"parameters":["zoom"]}},"sky-atmosphere-sun":{"type":"array","value":"number","length":2,"minimum":[0,0],"maximum":[360,180],"expression":{"parameters":["zoom"]}},"sky-atmosphere-sun-intensity":{"type":"number","default":10,"minimum":0,"maximum":100},"sky-gradient-center":{"type":"array","value":"number","default":[0,0],"length":2,"minimum":[0,0],"maximum":[360,180],"expression":{"parameters":["zoom"]}},"sky-gradient-radius":{"type":"number","default":90,"minimum":0,"maximum":180,"expression":{"parameters":["zoom"]}},"sky-gradient":{"type":"color","default":["interpolate",["linear"],["sky-radial-progress"],0.8,"#87ceeb",1,"white"],"use-theme":true,"expression":{"interpolated":true,"parameters":["sky-radial-progress"]}},"sky-atmosphere-halo-color":{"type":"color","default":"white","use-theme":true},"sky-atmosphere-color":{"type":"color","default":"white","use-theme":true},"sky-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}}},"paint_model":{"model-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"property-type":"data-driven"},"model-rotation":{"type":"array","value":"number","length":3,"default":[0,0,0],"period":360,"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"transition":true},"model-scale":{"type":"array","value":"number","length":3,"default":[1,1,1],"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"transition":true},"model-translation":{"type":"array","value":"number","length":3,"default":[0,0,0],"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"transition":true},"model-color":{"type":"color","default":"#ffffff","property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light","zoom"]},"use-theme":true,"transition":true},"model-color-mix-intensity":{"type":"number","property-type":"data-driven","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"transition":true},"model-type":{"type":"enum","values":{"common-3d":1,"location-indicator":1},"default":"common-3d"},"model-cast-shadows":{"type":"boolean","default":true},"model-receive-shadows":{"type":"boolean","default":true},"model-ambient-occlusion-intensity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"model-emissive-strength":{"type":"number","property-type":"data-driven","default":0,"minimum":0,"maximum":5,"expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"transition":true},"model-roughness":{"type":"number","default":1,"minimum":0,"maximum":1,"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state"]},"transition":true},"model-height-based-emissive-strength-multiplier":{"type":"array","default":[1,1,1,1,0],"length":5,"value":"number","property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"transition":true},"model-cutoff-fade-range":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{}},"model-front-cutoff":{"type":"array","value":"number","expression":{"interpolated":true,"parameters":["zoom"]},"length":3,"default":[0,0,1],"minimum":[0,0,0],"maximum":[1,1,1]},"model-elevation-reference":{"type":"enum","values":{"sea":1,"ground":1,"hd-road-markup":1},"default":"ground","expression":{}},"model-ignore-line-cutout":{"type":"boolean","default":false,"expression":{}}},"transition":{"duration":{"type":"number","default":300,"minimum":0},"delay":{"type":"number","default":0,"minimum":0}},"promoteId":{"*":{"type":"*"}}}');function aP(h){return h instanceof Number||h instanceof String||h instanceof Boolean?h.valueOf():h}function aw(h){if(Array.isArray(h))return h.map(aw);if(h instanceof Object&&!(h instanceof Number||h instanceof String||h instanceof Boolean)){const l={};for(const u in h)l[u]=aw(h[u]);return l}return aP(h)}function Nj(h){if(h===!0||h===!1)return!0;if(!Array.isArray(h)||h.length===0)return!1;switch(h[0]){case"has":return h.length>=2&&h[1]!=="$id"&&h[1]!=="$type";case"in":return h.length>=3&&(typeof h[1]!="string"||Array.isArray(h[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return h.length!==3||Array.isArray(h[1])||Array.isArray(h[2]);case"any":case"all":for(const l of h.slice(1))if(!Nj(l)&&typeof l!="boolean")return!1;return!0;default:return!0}}function ow(h,l="",u=null,p="fill"){if(h==null)return{filter:()=>!0,needGeometry:!1,needFeature:!1};Nj(h)||(h=lw(h));const x=h;let b=!0;try{b=function($){if(!xy($))return $;let V=aw($);return lP(V),V=oP(V),V}(x)}catch{console.warn(`Failed to extract static filter. Filter will continue working, but at higher memory usage and slower framerate. This is most likely a bug, please report this via https://github.com/mapbox/mapbox-gl-js/issues/new?assignees=&labels=&template=Bug_report.md and paste the contents of this message in the report. Thank you! Filter Expression: ${JSON.stringify(x,null,2)} `)}let T=null,k=null;if(p!=="background"&&p!=="sky"&&p!=="slot"){k=at[`filter_${p}`];const $=em(b,k,l,u);if($.result==="error")throw new Error($.value.map(V=>`${V.key}: ${V.message}`).join(", "));T=(V,G,Y)=>$.value.evaluate(V,G,{},Y)}let P=null,O=null;if(b!==x){const $=em(x,k,l,u);if($.result==="error")throw new Error($.value.map(V=>`${V.key}: ${V.message}`).join(", "));P=(V,G,Y,X,te)=>$.value.evaluate(V,G,{},Y,void 0,void 0,X,te),O=!Sp($.value.expression)}return{filter:T,dynamicFilter:P||void 0,needGeometry:uP(b),needFeature:!!O}}function oP(h){if(!Array.isArray(h))return h;const l=function(u){if(cP.has(u[0])){for(let p=1;poP(u))}function lP(h){let l=!1;const u=[];if(h[0]==="case"){for(let p=1;p",">=","<","<=","to-boolean"]);function dB(h,l){return hl?1:0}function uP(h){if(!Array.isArray(h))return!1;if(h[0]==="within"||h[0]==="distance")return!0;for(let l=1;l"||l==="<="||l===">="?cw(h[1],h[2],l):l==="any"?(u=h.slice(1),["any"].concat(u.map(lw))):l==="all"?["all"].concat(h.slice(1).map(lw)):l==="none"?["all"].concat(h.slice(1).map(lw).map(a_)):l==="in"?Cj(h[1],h.slice(2)):l==="!in"?a_(Cj(h[1],h.slice(2))):l==="has"?Hh(h[1]):l!=="!has"||a_(Hh(h[1]));var u}function cw(h,l,u){switch(h){case"$type":return[`filter-type-${u}`,l];case"$id":return[`filter-id-${u}`,l];default:return[`filter-${u}`,h,l]}}function Cj(h,l){if(l.length===0)return!1;switch(h){case"$type":return["filter-type-in",["literal",l]];case"$id":return["filter-id-in",["literal",l]];default:return l.length>200&&!l.some(u=>typeof u!=typeof l[0])?["filter-in-large",h,["literal",l.sort(dB)]]:["filter-in-small",h,["literal",l]]}}function Hh(h){switch(h){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",h]}}function a_(h){return["!",h]}const o_="";function Cp(h,l){return l?`${h}${o_}${l}`:h}function dP(h){const l=h.indexOf(o_);return l>=0?h.slice(l+1):""}let hP;const Ij=()=>hP||(hP=new hi({"icon-size":new Qt(at.layout_symbol["icon-size"]),"icon-image":new Qt(at.layout_symbol["icon-image"]),"icon-rotate":new Qt(at.layout_symbol["icon-rotate"]),"icon-offset":new Qt(at.layout_symbol["icon-offset"]),"text-size":new Qt(at.layout_symbol["text-size"]),"text-rotate":new Qt(at.layout_symbol["text-rotate"]),"text-offset":new Qt(at.layout_symbol["text-offset"])}));let Pj;const Rj=()=>Pj||(Pj=new hi({"icon-opacity":new Qt(at.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new Qt(at.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new Qt(at.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new Qt(at.paint_symbol["text-emissive-strength"]),"icon-color":new Qt(at.paint_symbol["icon-color"]),"icon-halo-color":new Qt(at.paint_symbol["icon-halo-color"]),"icon-halo-width":new Qt(at.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Qt(at.paint_symbol["icon-halo-blur"]),"icon-translate":new Qt(at.paint_symbol["icon-translate"]),"text-opacity":new Qt(at.paint_symbol["text-opacity"]),"text-occlusion-opacity":new Qt(at.paint_symbol["text-occlusion-opacity"]),"text-color":new Qt(at.paint_symbol["text-color"],{runtimeType:Rl,getOverride:h=>h.textColor,hasOverride:h=>!!h.textColor}),"text-halo-color":new Qt(at.paint_symbol["text-halo-color"]),"text-halo-width":new Qt(at.paint_symbol["text-halo-width"]),"text-halo-blur":new Qt(at.paint_symbol["text-halo-blur"]),"text-translate":new Qt(at.paint_symbol["text-translate"]),"symbol-z-offset":new Qt(at.paint_symbol["symbol-z-offset"]),"icon-color-use-theme":new Qt({type:"string",default:"default","property-type":"data-driven"}),"icon-halo-color-use-theme":new Qt({type:"string",default:"default","property-type":"data-driven"}),"text-color-use-theme":new Qt({type:"string",default:"default","property-type":"data-driven"}),"text-halo-color-use-theme":new Qt({type:"string",default:"default","property-type":"data-driven"})}));class hB{constructor(l,u,p,x,b,T){this._conditionSpec=l,this._propertiesSpec=p;const k=em(l,at.appearance.condition);if(k.result==="success"&&(this.condition=k.value),this.name=u,p){this.layoutProperties=new Gh(Ij()),this.unevaluatedLayout=new Aj(Ij(),x,b,T),this.paintProperties=new Gh(Rj()),this.unevaluatedPaint=new Aj(Rj(),x,b,"");for(const P in p)P in this.unevaluatedLayout._values?this.unevaluatedLayout.setValue(P,p[P]):P in this.unevaluatedPaint._values&&this.unevaluatedPaint.setValue(P,p[P])}}isActive(l){return!(this.condition||!l.isHidden||this.name!=="hidden")||this.condition.evaluate(l.globals,l.feature,l.featureState,l.canonical)}getCondition(){return this.condition}getName(){return this.name}getLayoutProperty(l){return this.layoutProperties.get(l)}getPaintProperty(l){return this.paintProperties.get(l)}getUnevaluatedLayoutProperties(){return this.unevaluatedLayout}getUnevaluatedLayoutProperty(l){return this.unevaluatedLayout._values[l]}getUnevaluatedPaintProperty(l){return this.unevaluatedPaint._values[l]}recalculate(l,u,p){this.unevaluatedLayout&&(this.layoutProperties=this.unevaluatedLayout.possiblyEvaluate(l,void 0,u,p)),this.unevaluatedPaint&&(this.paintProperties=this.unevaluatedPaint.possiblyEvaluate(l,void 0,u,""))}serialize(){const l={};l.condition=this.condition.expression.serialize(),this.name&&(l.name=this.name);const u=this.unevaluatedLayout?this.unevaluatedLayout.serialize():{},p=this.unevaluatedPaint?this.unevaluatedPaint.serialize():{},x=Object.assign({},u,p);return Object.keys(x).length>0&&(l.properties=x),l}hasIconLayoutProperties(){const l=this.hasLayoutProperty("icon-image"),u=this.hasLayoutProperty("icon-size"),p=this.hasLayoutProperty("icon-offset"),x=this.hasLayoutProperty("icon-rotate");return l||u||p||x}hasTextLayoutProperties(){const l=this.hasLayoutProperty("text-size"),u=this.hasLayoutProperty("text-offset"),p=this.hasLayoutProperty("text-rotate");return l||u||p}hasIconPaintProperties(){return!!this.unevaluatedPaint&&Object.keys(this.unevaluatedPaint._values).filter(l=>!l.endsWith("-use-theme")).some(l=>(l.startsWith("icon-")||l==="symbol-z-offset")&&this.hasPaintProperty(l))}hasTextPaintProperties(){return!!this.unevaluatedPaint&&Object.keys(this.unevaluatedPaint._values).filter(l=>!l.endsWith("-use-theme")).some(l=>(l.startsWith("text-")||l==="symbol-z-offset")&&this.hasPaintProperty(l))}hasLayoutProperty(l){return this.unevaluatedLayout&&this.unevaluatedLayout._values[l].value!==void 0}hasPaintProperty(l){return this.unevaluatedPaint&&this.unevaluatedPaint._values[l].value!==void 0}}const Lj="-transition",fB=new Set(["fill","line","background","hillshade","raster"]);class fl extends N0{constructor(l,u,p,x,b,T){if(super(),this.id=l.id,this.fqid=Cp(this.id,p),this.type=l.type,this.scope=p,this.lut=x,this.options=b,this.iconImageUseTheme=T,this.appearances=new Array,this.appearancesVersion=0,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,this.expressionDependencies={isIndoorDependent:!1,configDependencies:new Set},l.type!=="custom"){if(this.metadata=l.metadata,this.minzoom=l.minzoom,this.maxzoom=l.maxzoom,l.type&&l.type!=="background"&&l.type!=="sky"&&l.type!=="slot"){this.source=l.source,this.sourceLayer=l["source-layer"],this.filter=l.filter;const k=em(this.filter,at[`filter_${l.type}`]);k.result!=="error"&&(this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...k.value.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||k.value.isIndoorDependent)}if(l.slot&&(this.slot=l.slot),l.appearances&&this.setAppearances(l.appearances),u.layout&&(this._unevaluatedLayout=new Aj(u.layout,this.scope,b,this.iconImageUseTheme),this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...this._unevaluatedLayout.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||this._unevaluatedLayout.isIndoorDependent()),u.paint){this._transitionablePaint=new iw(u.paint,this.scope,b);for(const k in l.paint)this.setPaintProperty(k,l.paint[k]);for(const k in l.layout)this.setLayoutProperty(k,l.layout[k]);this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...this._transitionablePaint.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||this._transitionablePaint.isIndoorDependent(),this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new Gh(u.paint)}}}onAdd(l){}onRemove(l){}isDraped(l){return!this.is3D(!0)&&fB.has(this.type)}getLayoutProperty(l){return l==="visibility"?this.visibility:this._unevaluatedLayout.getValue(l)}setLayoutProperty(l,u){if(this.type==="custom"&&l==="visibility")return void(this.visibility=u);const p=this._unevaluatedLayout;p._properties.properties[l]&&(p.setValue(l,u),this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...p.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||p.isIndoorDependent(),l==="visibility"&&this.possiblyEvaluateVisibility())}setAppearances(l){this.appearances=[],l.forEach(u=>{this.appearances.push(new hB(u.condition,u.name,u.properties,this.scope,this.options,this.iconImageUseTheme))}),this.appearancesVersion++}possiblyEvaluateVisibility(){this._unevaluatedLayout._values.visibility&&(this.visibility=this._unevaluatedLayout._values.visibility.possiblyEvaluate({zoom:0}))}getPaintProperty(l){return l.endsWith(Lj)?this._transitionablePaint.getTransition(l.slice(0,-11)):this._transitionablePaint.getValue(l)}isPaintProperty(l){return!!this._transitionablePaint._properties.properties[l]}setPaintProperty(l,u){const p=this._transitionablePaint,x=p._properties.properties;if(l.endsWith(Lj)){const V=l.slice(0,-11);return x[V]&&p.setTransition(V,u||void 0),!1}if(!x[l])return!1;const b=p._values[l],T=b.value.isDataDriven(),k=b.value;p.setValue(l,u),this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...p.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||p.isIndoorDependent(),this._handleSpecialPaintPropertyUpdate(l);const P=p._values[l].value,O=P.isDataDriven(),$=l.endsWith("pattern")||l==="line-dasharray";return O||T||$||this._handleOverridablePaintPropertyUpdate(l,k,P)}_handleSpecialPaintPropertyUpdate(l){}getProgramIds(){return null}getDefaultProgramParams(l,u,p){return null}_handleOverridablePaintPropertyUpdate(l,u,p){return!1}isHidden(l){return!!(this.minzoom&&l=this.maxzoom)||this.visibility==="none"}updateTransitions(l){this._transitioningPaint=this._transitionablePaint.transitioned(l,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(l,u){this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(l,void 0,u,this.iconImageUseTheme)),this.paint=this._transitioningPaint.possiblyEvaluate(l,void 0,u)}serialize(){const l={id:this.id,type:this.type,slot:this.slot,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()};return this.appearances.length!==0&&(l.appearances=this.appearances.map(u=>u.serialize())),Mt(l,(u,p)=>!(u===void 0||p==="layout"&&!Object.keys(u).length||p==="paint"&&!Object.keys(u).length))}is3D(l){return!1}hasElevation(){return!1}isSky(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}hasShadowPass(){return!1}canCastShadows(){return!1}hasLightBeamPass(){return!1}cutoffRange(){return 0}tileCoverLift(){return 0}resize(){}_clear(){}isStateDependent(){for(const l in this.paint._values){const u=this.paint.get(l);if(u instanceof Np&&Wb(u.property.specification)&&(u.value.kind==="source"||u.value.kind==="composite")&&u.value.isStateDependent)return!0}for(const l of this.appearances)if(!oy(l.condition.expression))return!0;return!1}compileFilter(l){this._filterCompiled||(this._featureFilter=ow(this.filter,this.scope,l),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}dynamicFilterNeedsGeometry(){return this._featureFilter.needGeometry}getLayerRenderingStats(){return this._stats}resetLayerRenderingStats(l){this._stats&&(l.renderPass==="shadow"?this._stats.numRenderedVerticesInShadowPass=0:this._stats.numRenderedVerticesInTransparentPass=0)}getAppearances(){return this.appearances}queryRenderedFeatures(l,u,p){return{}}queryRadius(l){}queryIntersectsFeature(l,u,p,x,b,T,k,P,O,$){}}const uw={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class l_{constructor(l,u){this._structArray=l,this._pos1=u*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}const mB=new ArrayBuffer(0);class Xs{constructor(){this._reallocCount=0,this.capacity=0,this.length=0}static serialize(l,u){return l._trim(),u&&l.arrayBuffer&&u.add(l.arrayBuffer),{length:l.length,arrayBuffer:l.arrayBuffer}}static deserialize(l){const u=Object.create(this.prototype);return u.arrayBuffer=l.arrayBuffer,u.length=l.length,l.arrayBuffer?u.capacity=l.arrayBuffer.byteLength/u.bytesPerElement:(u.capacity=0,u.arrayBuffer=mB),u._refreshViews(),u}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(l){this.reserve(l),this.length=l}reserve(l){if(l>this.capacity){this._reallocCount++,this.capacity=Math.max(l,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const u=this.uint8;this._refreshViews(),u&&this.uint8.set(u)}}reserveForAdditional(l){this.reserve(this.length+l)}_refreshViews(){throw new Error("StructArray#_refreshViews() must be implemented by each concrete StructArray layout")}emplace(...l){throw new Error("StructArray#emplace() must be implemented by each concrete StructArray layout")}emplaceBack(...l){throw new Error("StructArray#emplaceBack() must be implemented by each concrete StructArray layout")}destroy(){this.int8=this.uint8=this.int16=this.uint16=this.int32=this.uint32=this.float32=null,this.arrayBuffer=null}}function On(h,l=1){let u=0,p=0;return{members:h.map(x=>{const b=uw[x.type].BYTES_PER_ELEMENT,T=u=fP(u,Math.max(l,b)),k=x.components||1;return p=Math.max(p,b),u+=b*k,{name:x.name,type:x.type,components:k,offset:T}}),size:fP(u,Math.max(p,l)),alignment:l}}function fP(h,l){return Math.ceil(h/l)*l}class Sc extends Xs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(l,u){const p=this.length;return this.resize(p+1),this.emplace(p,l,u)}emplace(l,u,p){const x=2*l;return this.int16[x+0]=u,this.int16[x+1]=p,l}}Sc.prototype.bytesPerElement=4,Tr(Sc,"StructArrayLayout2i4");class Qd extends Xs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(l,u,p){const x=this.length;return this.resize(x+1),this.emplace(x,l,u,p)}emplace(l,u,p,x){const b=3*l;return this.int16[b+0]=u,this.int16[b+1]=p,this.int16[b+2]=x,l}}Qd.prototype.bytesPerElement=6,Tr(Qd,"StructArrayLayout3i6");class Ro extends Xs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(l,u,p,x){const b=this.length;return this.resize(b+1),this.emplace(b,l,u,p,x)}emplace(l,u,p,x,b){const T=4*l;return this.int16[T+0]=u,this.int16[T+1]=p,this.uint16[T+2]=x,this.uint16[T+3]=b,l}}Ro.prototype.bytesPerElement=8,Tr(Ro,"StructArrayLayout2i2ui8");class Wc extends Xs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(l){const u=this.length;return this.resize(u+1),this.emplace(u,l)}emplace(l,u){return this.float32[1*l+0]=u,l}}Wc.prototype.bytesPerElement=4,Tr(Wc,"StructArrayLayout1f4");class Mj extends Xs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(l,u,p){const x=this.length;return this.resize(x+1),this.emplace(x,l,u,p)}emplace(l,u,p,x){const b=4*l,T=2*l;return this.int16[b+0]=u,this.int16[b+1]=p,this.float32[T+1]=x,l}}Mj.prototype.bytesPerElement=8,Tr(Mj,"StructArrayLayout2i1f8");class Dj extends Xs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(l,u,p){const x=this.length;return this.resize(x+1),this.emplace(x,l,u,p)}emplace(l,u,p,x){const b=4*l;return this.int16[b+0]=u,this.int16[b+1]=p,this.int16[b+2]=x,l}}Dj.prototype.bytesPerElement=8,Tr(Dj,"StructArrayLayout3i8");class Oj extends Xs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(l,u,p,x){const b=this.length;return this.resize(b+1),this.emplace(b,l,u,p,x)}emplace(l,u,p,x,b){const T=4*l;return this.int16[T+0]=u,this.int16[T+1]=p,this.int16[T+2]=x,this.int16[T+3]=b,l}}Oj.prototype.bytesPerElement=8,Tr(Oj,"StructArrayLayout4i8");class Fj extends Xs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(l,u,p,x,b){const T=this.length;return this.resize(T+1),this.emplace(T,l,u,p,x,b)}emplace(l,u,p,x,b,T){const k=5*l;return this.int16[k+0]=u,this.int16[k+1]=p,this.int16[k+2]=x,this.int16[k+3]=b,this.int16[k+4]=T,l}}Fj.prototype.bytesPerElement=10,Tr(Fj,"StructArrayLayout5i10");class c_ extends Xs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(l,u,p,x,b,T,k){const P=this.length;return this.resize(P+1),this.emplace(P,l,u,p,x,b,T,k)}emplace(l,u,p,x,b,T,k,P){const O=6*l,$=12*l,V=3*l;return this.int16[O+0]=u,this.int16[O+1]=p,this.uint8[$+4]=x,this.uint8[$+5]=b,this.uint8[$+6]=T,this.uint8[$+7]=k,this.float32[V+2]=P,l}}c_.prototype.bytesPerElement=12,Tr(c_,"StructArrayLayout2i4ub1f12");class Lu extends Xs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(l,u,p){const x=this.length;return this.resize(x+1),this.emplace(x,l,u,p)}emplace(l,u,p,x){const b=3*l;return this.float32[b+0]=u,this.float32[b+1]=p,this.float32[b+2]=x,l}}Lu.prototype.bytesPerElement=12,Tr(Lu,"StructArrayLayout3f12");class Jd extends Xs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(l,u,p,x,b){const T=this.length;return this.resize(T+1),this.emplace(T,l,u,p,x,b)}emplace(l,u,p,x,b,T){const k=6*l,P=3*l;return this.uint16[k+0]=u,this.uint16[k+1]=p,this.uint16[k+2]=x,this.uint16[k+3]=b,this.float32[P+2]=T,l}}Jd.prototype.bytesPerElement=12,Tr(Jd,"StructArrayLayout4ui1f12");class _y extends Xs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(l,u,p,x){const b=this.length;return this.resize(b+1),this.emplace(b,l,u,p,x)}emplace(l,u,p,x,b){const T=4*l;return this.uint16[T+0]=u,this.uint16[T+1]=p,this.uint16[T+2]=x,this.uint16[T+3]=b,l}}_y.prototype.bytesPerElement=8,Tr(_y,"StructArrayLayout4ui8");class dw extends Xs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(l,u,p,x,b,T){const k=this.length;return this.resize(k+1),this.emplace(k,l,u,p,x,b,T)}emplace(l,u,p,x,b,T,k){const P=6*l;return this.int16[P+0]=u,this.int16[P+1]=p,this.int16[P+2]=x,this.int16[P+3]=b,this.int16[P+4]=T,this.int16[P+5]=k,l}}dw.prototype.bytesPerElement=12,Tr(dw,"StructArrayLayout6i12");class Bj extends Xs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(l,u,p,x,b,T,k,P,O,$,V,G){const Y=this.length;return this.resize(Y+1),this.emplace(Y,l,u,p,x,b,T,k,P,O,$,V,G)}emplace(l,u,p,x,b,T,k,P,O,$,V,G,Y){const X=12*l;return this.int16[X+0]=u,this.int16[X+1]=p,this.int16[X+2]=x,this.int16[X+3]=b,this.uint16[X+4]=T,this.uint16[X+5]=k,this.uint16[X+6]=P,this.uint16[X+7]=O,this.int16[X+8]=$,this.int16[X+9]=V,this.int16[X+10]=G,this.int16[X+11]=Y,l}}Bj.prototype.bytesPerElement=24,Tr(Bj,"StructArrayLayout4i4ui4i24");class $j extends Xs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(l,u,p,x,b,T){const k=this.length;return this.resize(k+1),this.emplace(k,l,u,p,x,b,T)}emplace(l,u,p,x,b,T,k){const P=10*l,O=5*l;return this.int16[P+0]=u,this.int16[P+1]=p,this.int16[P+2]=x,this.float32[O+2]=b,this.float32[O+3]=T,this.float32[O+4]=k,l}}$j.prototype.bytesPerElement=20,Tr($j,"StructArrayLayout3i3f20");class Wh extends Xs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(l,u,p,x){const b=this.length;return this.resize(b+1),this.emplace(b,l,u,p,x)}emplace(l,u,p,x,b){const T=4*l;return this.float32[T+0]=u,this.float32[T+1]=p,this.float32[T+2]=x,this.float32[T+3]=b,l}}Wh.prototype.bytesPerElement=16,Tr(Wh,"StructArrayLayout4f16");class u_ extends Xs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(l){const u=this.length;return this.resize(u+1),this.emplace(u,l)}emplace(l,u){return this.uint32[1*l+0]=u,l}}u_.prototype.bytesPerElement=4,Tr(u_,"StructArrayLayout1ul4");class Mu extends Xs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(l,u){const p=this.length;return this.resize(p+1),this.emplace(p,l,u)}emplace(l,u,p){const x=2*l;return this.uint16[x+0]=u,this.uint16[x+1]=p,l}}Mu.prototype.bytesPerElement=4,Tr(Mu,"StructArrayLayout2ui4");class hw extends Xs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(l,u,p,x,b,T,k,P,O,$,V,G,Y){const X=this.length;return this.resize(X+1),this.emplace(X,l,u,p,x,b,T,k,P,O,$,V,G,Y)}emplace(l,u,p,x,b,T,k,P,O,$,V,G,Y,X){const te=20*l,se=10*l;return this.int16[te+0]=u,this.int16[te+1]=p,this.int16[te+2]=x,this.int16[te+3]=b,this.int16[te+4]=T,this.float32[se+3]=k,this.float32[se+4]=P,this.float32[se+5]=O,this.float32[se+6]=$,this.int16[te+14]=V,this.uint32[se+8]=G,this.uint16[te+18]=Y,this.uint16[te+19]=X,l}}hw.prototype.bytesPerElement=40,Tr(hw,"StructArrayLayout5i4f1i1ul2ui40");class d_ extends Xs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(l,u,p,x,b,T,k){const P=this.length;return this.resize(P+1),this.emplace(P,l,u,p,x,b,T,k)}emplace(l,u,p,x,b,T,k,P){const O=8*l;return this.int16[O+0]=u,this.int16[O+1]=p,this.int16[O+2]=x,this.int16[O+4]=b,this.int16[O+5]=T,this.int16[O+6]=k,this.int16[O+7]=P,l}}d_.prototype.bytesPerElement=16,Tr(d_,"StructArrayLayout3i2i2i16");class zj extends Xs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(l,u,p,x,b){const T=this.length;return this.resize(T+1),this.emplace(T,l,u,p,x,b)}emplace(l,u,p,x,b,T){const k=4*l,P=8*l;return this.float32[k+0]=u,this.float32[k+1]=p,this.float32[k+2]=x,this.int16[P+6]=b,this.int16[P+7]=T,l}}zj.prototype.bytesPerElement=16,Tr(zj,"StructArrayLayout2f1f2i16");class h_ extends Xs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(l,u,p,x,b,T){const k=this.length;return this.resize(k+1),this.emplace(k,l,u,p,x,b,T)}emplace(l,u,p,x,b,T,k){const P=20*l,O=5*l;return this.uint8[P+0]=u,this.uint8[P+1]=p,this.float32[O+1]=x,this.float32[O+2]=b,this.float32[O+3]=T,this.float32[O+4]=k,l}}h_.prototype.bytesPerElement=20,Tr(h_,"StructArrayLayout2ub4f20");class Pi extends Xs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(l,u,p){const x=this.length;return this.resize(x+1),this.emplace(x,l,u,p)}emplace(l,u,p,x){const b=3*l;return this.uint16[b+0]=u,this.uint16[b+1]=p,this.uint16[b+2]=x,l}}Pi.prototype.bytesPerElement=6,Tr(Pi,"StructArrayLayout3ui6");class fw extends Xs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(l,u,p,x,b,T,k,P,O,$,V,G,Y,X,te,se,ae,fe,ue,we,Ae){const Ie=this.length;return this.resize(Ie+1),this.emplace(Ie,l,u,p,x,b,T,k,P,O,$,V,G,Y,X,te,se,ae,fe,ue,we,Ae)}emplace(l,u,p,x,b,T,k,P,O,$,V,G,Y,X,te,se,ae,fe,ue,we,Ae,Ie){const We=30*l,ze=15*l,He=60*l;return this.int16[We+0]=u,this.int16[We+1]=p,this.int16[We+2]=x,this.float32[ze+2]=b,this.float32[ze+3]=T,this.uint16[We+8]=k,this.uint16[We+9]=P,this.uint32[ze+5]=O,this.uint32[ze+6]=$,this.uint32[ze+7]=V,this.uint16[We+16]=G,this.uint16[We+17]=Y,this.uint16[We+18]=X,this.float32[ze+10]=te,this.float32[ze+11]=se,this.uint8[He+48]=ae,this.uint8[He+49]=fe,this.uint8[He+50]=ue,this.uint32[ze+13]=we,this.int16[We+28]=Ae,this.uint8[He+58]=Ie,l}}fw.prototype.bytesPerElement=60,Tr(fw,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class Uj extends Xs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(l,u,p,x,b,T,k,P,O,$,V,G,Y,X,te,se,ae,fe,ue,we,Ae,Ie,We,ze,He,Ve,qe,bt,jt,It,Dt,Pt,Ht){const _t=this.length;return this.resize(_t+1),this.emplace(_t,l,u,p,x,b,T,k,P,O,$,V,G,Y,X,te,se,ae,fe,ue,we,Ae,Ie,We,ze,He,Ve,qe,bt,jt,It,Dt,Pt,Ht)}emplace(l,u,p,x,b,T,k,P,O,$,V,G,Y,X,te,se,ae,fe,ue,we,Ae,Ie,We,ze,He,Ve,qe,bt,jt,It,Dt,Pt,Ht,_t){const Rt=20*l,Bt=40*l,Yt=80*l;return this.float32[Rt+0]=u,this.float32[Rt+1]=p,this.int16[Bt+4]=x,this.int16[Bt+5]=b,this.int16[Bt+6]=T,this.int16[Bt+7]=k,this.int16[Bt+8]=P,this.int16[Bt+9]=O,this.int16[Bt+10]=$,this.int16[Bt+11]=V,this.int16[Bt+12]=G,this.uint16[Bt+13]=Y,this.uint16[Bt+14]=X,this.uint16[Bt+15]=te,this.uint16[Bt+16]=se,this.uint16[Bt+17]=ae,this.uint16[Bt+18]=fe,this.uint16[Bt+19]=ue,this.uint16[Bt+20]=we,this.uint16[Bt+21]=Ae,this.uint16[Bt+22]=Ie,this.uint16[Bt+23]=We,this.uint16[Bt+24]=ze,this.uint16[Bt+25]=He,this.uint16[Bt+26]=Ve,this.uint16[Bt+27]=qe,this.uint32[Rt+14]=bt,this.float32[Rt+15]=jt,this.float32[Rt+16]=It,this.float32[Rt+17]=Dt,this.float32[Rt+18]=Pt,this.uint8[Yt+76]=Ht,this.uint16[Bt+39]=_t,l}}Uj.prototype.bytesPerElement=80,Tr(Uj,"StructArrayLayout2f9i15ui1ul4f1ub1ui80");class mw extends Xs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(l,u,p,x,b,T){const k=this.length;return this.resize(k+1),this.emplace(k,l,u,p,x,b,T)}emplace(l,u,p,x,b,T,k){const P=6*l;return this.float32[P+0]=u,this.float32[P+1]=p,this.float32[P+2]=x,this.float32[P+3]=b,this.float32[P+4]=T,this.float32[P+5]=k,l}}mw.prototype.bytesPerElement=24,Tr(mw,"StructArrayLayout6f24");class Ip extends Xs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(l,u,p,x,b){const T=this.length;return this.resize(T+1),this.emplace(T,l,u,p,x,b)}emplace(l,u,p,x,b,T){const k=5*l;return this.float32[k+0]=u,this.float32[k+1]=p,this.float32[k+2]=x,this.float32[k+3]=b,this.float32[k+4]=T,l}}Ip.prototype.bytesPerElement=20,Tr(Ip,"StructArrayLayout5f20");class f_ extends Xs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(l,u,p,x,b,T,k){const P=this.length;return this.resize(P+1),this.emplace(P,l,u,p,x,b,T,k)}emplace(l,u,p,x,b,T,k,P){const O=7*l;return this.float32[O+0]=u,this.float32[O+1]=p,this.float32[O+2]=x,this.float32[O+3]=b,this.float32[O+4]=T,this.float32[O+5]=k,this.float32[O+6]=P,l}}f_.prototype.bytesPerElement=28,Tr(f_,"StructArrayLayout7f28");class Vj extends Xs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(l,u,p,x,b,T,k,P,O,$,V){const G=this.length;return this.resize(G+1),this.emplace(G,l,u,p,x,b,T,k,P,O,$,V)}emplace(l,u,p,x,b,T,k,P,O,$,V,G){const Y=11*l;return this.float32[Y+0]=u,this.float32[Y+1]=p,this.float32[Y+2]=x,this.float32[Y+3]=b,this.float32[Y+4]=T,this.float32[Y+5]=k,this.float32[Y+6]=P,this.float32[Y+7]=O,this.float32[Y+8]=$,this.float32[Y+9]=V,this.float32[Y+10]=G,l}}Vj.prototype.bytesPerElement=44,Tr(Vj,"StructArrayLayout11f44");class qj extends Xs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(l,u,p,x,b,T,k,P,O){const $=this.length;return this.resize($+1),this.emplace($,l,u,p,x,b,T,k,P,O)}emplace(l,u,p,x,b,T,k,P,O,$){const V=9*l;return this.float32[V+0]=u,this.float32[V+1]=p,this.float32[V+2]=x,this.float32[V+3]=b,this.float32[V+4]=T,this.float32[V+5]=k,this.float32[V+6]=P,this.float32[V+7]=O,this.float32[V+8]=$,l}}qj.prototype.bytesPerElement=36,Tr(qj,"StructArrayLayout9f36");class Pp extends Xs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(l,u){const p=this.length;return this.resize(p+1),this.emplace(p,l,u)}emplace(l,u,p){const x=2*l;return this.float32[x+0]=u,this.float32[x+1]=p,l}}Pp.prototype.bytesPerElement=8,Tr(Pp,"StructArrayLayout2f8");class Gj extends Xs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(l,u,p,x){const b=this.length;return this.resize(b+1),this.emplace(b,l,u,p,x)}emplace(l,u,p,x,b){const T=6*l;return this.uint32[3*l+0]=u,this.uint16[T+2]=p,this.uint16[T+3]=x,this.uint16[T+4]=b,l}}Gj.prototype.bytesPerElement=12,Tr(Gj,"StructArrayLayout1ul3ui12");class Rp extends Xs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(l){const u=this.length;return this.resize(u+1),this.emplace(u,l)}emplace(l,u){return this.uint16[1*l+0]=u,l}}Rp.prototype.bytesPerElement=2,Tr(Rp,"StructArrayLayout1ui2");class Hj extends Xs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(l,u,p,x,b,T,k,P,O,$,V,G,Y,X,te,se){const ae=this.length;return this.resize(ae+1),this.emplace(ae,l,u,p,x,b,T,k,P,O,$,V,G,Y,X,te,se)}emplace(l,u,p,x,b,T,k,P,O,$,V,G,Y,X,te,se,ae){const fe=16*l;return this.float32[fe+0]=u,this.float32[fe+1]=p,this.float32[fe+2]=x,this.float32[fe+3]=b,this.float32[fe+4]=T,this.float32[fe+5]=k,this.float32[fe+6]=P,this.float32[fe+7]=O,this.float32[fe+8]=$,this.float32[fe+9]=V,this.float32[fe+10]=G,this.float32[fe+11]=Y,this.float32[fe+12]=X,this.float32[fe+13]=te,this.float32[fe+14]=se,this.float32[fe+15]=ae,l}}Hj.prototype.bytesPerElement=64,Tr(Hj,"StructArrayLayout16f64");class pw extends Xs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(l,u,p,x,b,T,k){const P=this.length;return this.resize(P+1),this.emplace(P,l,u,p,x,b,T,k)}emplace(l,u,p,x,b,T,k,P){const O=10*l,$=5*l;return this.uint16[O+0]=u,this.uint16[O+1]=p,this.uint16[O+2]=x,this.uint16[O+3]=b,this.float32[$+2]=T,this.float32[$+3]=k,this.float32[$+4]=P,l}}pw.prototype.bytesPerElement=20,Tr(pw,"StructArrayLayout4ui3f20");class gw extends Xs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(l){const u=this.length;return this.resize(u+1),this.emplace(u,l)}emplace(l,u){return this.int16[1*l+0]=u,l}}gw.prototype.bytesPerElement=2,Tr(gw,"StructArrayLayout1i2");class yw extends Xs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer)}emplaceBack(l){const u=this.length;return this.resize(u+1),this.emplace(u,l)}emplace(l,u){return this.uint8[1*l+0]=u,l}}yw.prototype.bytesPerElement=1,Tr(yw,"StructArrayLayout1ub1");class mP extends l_{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.int16[this._pos2+3]}get tileAnchorY(){return this._structArray.int16[this._pos2+4]}get x1(){return this._structArray.float32[this._pos4+3]}get y1(){return this._structArray.float32[this._pos4+4]}get x2(){return this._structArray.float32[this._pos4+5]}get y2(){return this._structArray.float32[this._pos4+6]}get padding(){return this._structArray.int16[this._pos2+14]}get featureIndex(){return this._structArray.uint32[this._pos4+8]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+18]}get bucketIndex(){return this._structArray.uint16[this._pos2+19]}}mP.prototype.size=40;class Wj extends hw{get(l){return new mP(this,l)}}Tr(Wj,"CollisionBoxArray");class pP extends l_{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.float32[this._pos4+2]}get tileAnchorY(){return this._structArray.float32[this._pos4+3]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+8]}get numGlyphs(){return this._structArray.uint16[this._pos2+9]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+5]}get lineStartIndex(){return this._structArray.uint32[this._pos4+6]}get lineLength(){return this._structArray.uint32[this._pos4+7]}get segment(){return this._structArray.uint16[this._pos2+16]}get lowerSize(){return this._structArray.uint16[this._pos2+17]}get upperSize(){return this._structArray.uint16[this._pos2+18]}get lineOffsetX(){return this._structArray.float32[this._pos4+10]}get lineOffsetY(){return this._structArray.float32[this._pos4+11]}get writingMode(){return this._structArray.uint8[this._pos1+48]}get placedOrientation(){return this._structArray.uint8[this._pos1+49]}set placedOrientation(l){this._structArray.uint8[this._pos1+49]=l}get hidden(){return this._structArray.uint8[this._pos1+50]}set hidden(l){this._structArray.uint8[this._pos1+50]=l}get crossTileID(){return this._structArray.uint32[this._pos4+13]}set crossTileID(l){this._structArray.uint32[this._pos4+13]=l}get associatedIconIndex(){return this._structArray.int16[this._pos2+28]}get flipState(){return this._structArray.uint8[this._pos1+58]}set flipState(l){this._structArray.uint8[this._pos1+58]=l}}pP.prototype.size=60;class gP extends fw{get(l){return new pP(this,l)}}Tr(gP,"PlacedSymbolArray");class m_ extends l_{get tileAnchorX(){return this._structArray.float32[this._pos4+0]}get tileAnchorY(){return this._structArray.float32[this._pos4+1]}get projectedAnchorX(){return this._structArray.int16[this._pos2+4]}get projectedAnchorY(){return this._structArray.int16[this._pos2+5]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+6]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+7]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+8]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+9]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+10]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+11]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+12]}get key(){return this._structArray.uint16[this._pos2+13]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+14]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+15]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+16]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+17]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+18]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+19]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+20]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+21]}get featureIndex(){return this._structArray.uint16[this._pos2+22]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+23]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+24]}get numIconVertices(){return this._structArray.uint16[this._pos2+25]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+26]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+27]}get crossTileID(){return this._structArray.uint32[this._pos4+14]}set crossTileID(l){this._structArray.uint32[this._pos4+14]=l}get textOffset0(){return this._structArray.float32[this._pos4+15]}get textOffset1(){return this._structArray.float32[this._pos4+16]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+17]}get zOffset(){return this._structArray.float32[this._pos4+18]}set zOffset(l){this._structArray.float32[this._pos4+18]=l}get hasIconTextFit(){return this._structArray.uint8[this._pos1+76]}get elevationFeatureIndex(){return this._structArray.uint16[this._pos2+39]}}m_.prototype.size=80;class yP extends Uj{get(l){return new m_(this,l)}}Tr(yP,"SymbolInstanceArray");class xP extends Wc{getoffsetX(l){return this.float32[1*l+0]}}Tr(xP,"GlyphOffsetArray");class p_ extends Sc{getx(l){return this.int16[2*l+0]}gety(l){return this.int16[2*l+1]}}Tr(p_,"SymbolLineVertexArray");class _P extends l_{get featureIndex(){return this._structArray.uint32[this._pos4+0]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+2]}get bucketIndex(){return this._structArray.uint16[this._pos2+3]}get layoutVertexArrayOffset(){return this._structArray.uint16[this._pos2+4]}}_P.prototype.size=12;class Kj extends Gj{get(l){return new _P(this,l)}}Tr(Kj,"FeatureIndexArray");class vP extends Mu{geta_centroid_pos0(l){return this.uint16[2*l+0]}geta_centroid_pos1(l){return this.uint16[2*l+1]}}Tr(vP,"FillExtrusionCentroidArray");class Yj extends l_{get a_join_normal_inside0(){return this._structArray.int16[this._pos2+0]}get a_join_normal_inside1(){return this._structArray.int16[this._pos2+1]}get a_join_normal_inside2(){return this._structArray.int16[this._pos2+2]}}Yj.prototype.size=6;class Zj extends Qd{get(l){return new Yj(this,l)}}Tr(Zj,"FillExtrusionWallArray");const bP=On([{name:"a_pos",components:2,type:"Int16"}],4),pB=On([{name:"a_circle_z_offset",components:1,type:"Float32"}],4),gB=On([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]);class Os{constructor(l=[]){this.segments=l}_prepareSegment(l,u,p,x,b){let T=this.segments[this.segments.length-1];return l>Os.MAX_VERTEX_ARRAY_LENGTH&&hr(`Max vertices per segment is ${Os.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${l}`),(!T||T.vertexLength+l>Os.MAX_VERTEX_ARRAY_LENGTH||T.sortKey!==x||b!==void 0&&T&&T.batchIndex!==void 0&&T.batchIndex!==b)&&(T={vertexOffset:u,primitiveOffset:p,vertexLength:0,primitiveLength:0},x!==void 0&&(T.sortKey=x),b!==void 0&&(T.batchIndex=b),this.segments.push(T)),T}prepareSegment(l,u,p,x,b){return this._prepareSegment(l,u.length,p.length,x,b)}get(){return this.segments}destroy(){for(const l of this.segments)for(const u in l.vaos)l.vaos[u].destroy()}static simpleSegment(l,u,p,x){return new Os([{vertexOffset:l,primitiveOffset:u,vertexLength:p,primitiveLength:x,vaos:{},sortKey:0}])}}function xw(h,l){return 256*(h=pe(Math.floor(h),0,255))+pe(Math.floor(l),0,255)}Os.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,Tr(Os,"SegmentVector");const yB=On([{name:"a_pattern",components:4,type:"Uint16"},{name:"a_pixel_ratio",components:1,type:"Float32"}]),xB=On([{name:"a_pattern_b",components:4,type:"Uint16"}]),_B=On([{name:"a_dash",components:4,type:"Uint16"}]);class g_{constructor(){this.ids=[],this.uniqueIds=[],this.positions=[],this.indexed=!1}add(l,u,p,x){this.ids.push(Xj(l)),this.positions.push(u,p,x)}eachPosition(l,u){const p=Xj(l);let x=0,b=this.ids.length-1;for(;x>1;this.ids[T]>=p?b=T:x=T+1}for(;this.ids[x]===p;)u(this.positions[3*x],this.positions[3*x+1],this.positions[3*x+2]),x++}static serialize(l,u){const p=new Float64Array(l.ids),x=new Uint32Array(l.positions);return y_(p,x,0,p.length-1),u&&(u.add(p.buffer),u.add(x.buffer)),{ids:p,positions:x}}static deserialize(l){const u=new g_;let p;u.ids=l.ids,u.positions=l.positions;for(const x of u.ids)x!==p&&u.uniqueIds.push(x),p=x;return u.indexed=!0,u}}function Xj(h){const l=+h;return Number.isSafeInteger(l)?l:Hf(String(h))}function y_(h,l,u,p){for(;u>1];let b=u-1,T=p+1;for(;;){do b++;while(h[b]x);if(b>=T)break;Kc(h,b,T),Kc(l,3*b,3*T),Kc(l,3*b+1,3*T+1),Kc(l,3*b+2,3*T+2)}T-u`u_${b}`),this.type=p,this.context=x}setUniform(l,u,p,x,b){const T=x.constantOr(this.value);u.set(l,b,T instanceof as?T.toPremultipliedRenderColor(this.lutExpression&&this.lutExpression.kind==="constant"&&this.lutExpression.value==="none"?null:this.context.lut):T)}getBinding(l,u){return this.type==="color"?new bB(l):new wa(l)}}class z{constructor(l,u){this.uniformNames=u.map(p=>`u_${p}`),this.pattern=null,this.patternTransition=null,this.pixelRatio=1}setConstantPatternPositions(l,u){this.pixelRatio=l.pixelRatio||1,this.pattern=l.tl.concat(l.br),this.patternTransition=u?u.tl.concat(u.br):this.pattern}setUniform(l,u,p,x,b){let T=null;b!=="u_pattern"&&b!=="u_dash"||(T=this.pattern),b==="u_pattern_b"&&(T=this.patternTransition),b==="u_pixel_ratio"&&(T=this.pixelRatio),T&&u.set(l,b,T)}getBinding(l,u){return u==="u_pattern"||u==="u_pattern_b"||u==="u_dash"?new vB(l):new wa(l)}}class W{constructor(l,u,p,x){this.expression=l,this.type=p,this.maxValue=0,this.paintVertexAttributes=u.map(b=>({name:`a_${b}`,type:"Float32",components:p==="color"?2:1,offset:0})),this.paintVertexArray=new x}populatePaintArray(l,u,p,x,b,T,k,P){const O=this.paintVertexArray.length,$=this.expression.kind==="composite"||this.expression.kind==="source"?this.expression.evaluate(new fs(0,{brightness:T,worldview:P}),u,{},b,x,k):this.expression.kind==="constant"&&this.expression.value,V=L(this.lutExpression,u,{},x,b,T,k,P);this.paintVertexArray.resize(l),this._setPaintValue(O,l,$,V?null:this.context.lut)}updatePaintArray(l,u,p,x,b,T,k,P){const O=this.expression.kind==="composite"||this.expression.kind==="source"?this.expression.evaluate({zoom:0,brightness:k,worldview:P},p,x,void 0,b):this.expression.kind==="constant"&&this.expression.value,$=L(this.lutExpression,p,x,b,void 0,k,void 0,P);this._setPaintValue(l,u,O,$?null:this.context.lut)}_setPaintValue(l,u,p,x){if(this.type==="color"){const b=R(p.toPremultipliedRenderColor(x));for(let T=l;T`u_${k}_t`),this.type=p,this.useIntegerZoom=x,this.context=b,this.maxValue=0,this.paintVertexAttributes=u.map(k=>({name:`a_${k}`,type:"Float32",components:p==="color"?4:2,offset:0})),this.paintVertexArray=new T}populatePaintArray(l,u,p,x,b,T,k,P){const O=this.expression.evaluate(new fs(this.context.zoom,{brightness:T,worldview:P}),u,{},b,x,k),$=this.expression.evaluate(new fs(this.context.zoom+1,{brightness:T,worldview:P}),u,{},b,x,k),V=L(this.lutExpression,u,{},x,b,T,k,P),G=this.paintVertexArray.length;this.paintVertexArray.resize(l),this._setPaintValue(G,l,O,$,V?null:this.context.lut)}updatePaintArray(l,u,p,x,b,T,k,P){const O=this.expression.evaluate({zoom:this.context.zoom,brightness:k,worldview:P},p,x,void 0,b),$=this.expression.evaluate({zoom:this.context.zoom+1,brightness:k,worldview:P},p,x,void 0,b),V=L(this.lutExpression,p,x,b,void 0,k,void 0,P);this._setPaintValue(l,u,O,$,V?null:this.context.lut)}_setPaintValue(l,u,p,x,b){if(this.type==="color"){const T=R(p.toPremultipliedRenderColor(b)),k=R(x.toPremultipliedRenderColor(b));for(let P=l;P!0){this.binders={},this._buffers=[],this.context=u;const x=[],b=l;for(const T in l.paint._values){const k=b.paint.get(T);if(T.endsWith("-use-theme")||!p(T)||!(k instanceof Np&&Wb(k.property.specification)))continue;const P=le(T,l.type),O=k.value,$=k.property.specification.type,V=!!k.property.useIntegerZoom,G=T==="line-dasharray"||T.endsWith("pattern"),Y=b.paint.get(`${T}-use-theme`),X=T==="line-dasharray"&&b.layout.get("line-cap").value.kind!=="constant"||Y&&Y.value.kind!=="constant";if(O.kind!=="constant"||X)if(O.kind==="source"||X||G){const te=Re(T,$,"source");this.binders[T]=G?new ne(O,P,$,te,l.id):new W(O,P,$,te),x.push(`/a_${T}`)}else{const te=Re(T,$,"composite");this.binders[T]=new Z(O,P,$,V,u,te),x.push(`/z_${T}`)}else this.binders[T]=G?new z(O.value,P):new F(O.value,P,$,u),x.push(`/u_${T}`);Y&&(this.binders[T].lutExpression=Y.value)}this.cacheKey=x.sort().join("")}getMaxValue(l){const u=this.binders[l];return u instanceof W||u instanceof Z?u.maxValue:0}populatePaintArrays(l,u,p,x,b,T,k,P){for(const O in this.binders){const $=this.binders[O];$.context=this.context,($ instanceof W||$ instanceof Z||$ instanceof ne)&&$.populatePaintArray(l,u,p,x,b,T,k,P)}}setConstantPatternPositions(l,u){for(const p in this.binders){const x=this.binders[p];x instanceof z&&x.setConstantPatternPositions(l,u)}}getPatternTransitionVertexBuffer(l){const u=this.binders[l];return u instanceof ne?u.paintTransitionVertexBuffer:null}updatePaintArrays(l,u,p,x,b,T,k,P,O,$){let V=!1;const G=Object.keys(l),Y=G.length!==0&&!P,X=Y?G:u.uniqueIds;this.context.lut=b.lut;for(const te in this.binders){const se=this.binders[te];if(se.context=this.context,(se instanceof W||se instanceof Z||se instanceof ne)&&se.expression&&se.expression.kind&&se.expression.kind!=="constant"&&(se.expression.isStateDependent===!0||se.expression.isLightConstant===!1)){const ae=b.paint.get(te);se.expression=ae.value;for(const fe of X){const ue=l[fe.toString()];u.eachPosition(fe,(we,Ae,Ie)=>{const We=x.feature(we);se.updatePaintArray(Ae,Ie,We,ue,T,k,O,$)})}if(!Y)for(const fe of p.uniqueIds){const ue=l[fe.toString()];p.eachPosition(fe,(we,Ae,Ie)=>{const We=x.feature(we);se.updatePaintArray(Ae,Ie,We,ue,T,k,O,$)})}V=!0}}return V}defines(){const l=[];for(const u in this.binders){const p=this.binders[u];(p instanceof F||p instanceof z)&&l.push(...p.uniformNames.map(x=>`#define HAS_UNIFORM_${x}`))}return l}getPaintVertexBuffers(){return this._buffers}getUniforms(l){const u=[];for(const p in this.binders){const x=this.binders[p];if(x instanceof F||x instanceof z||x instanceof Z)for(const b of x.uniformNames)u.push({name:b,property:p,binding:x.getBinding(l,b)})}return u}setUniforms(l,u,p,x,b){for(const{name:T,property:k,binding:P}of p)this.binders[k].setUniform(l,P,b,x.get(k),T)}updatePaintBuffers(){this._buffers=[];for(const l in this.binders){const u=this.binders[l];(u instanceof W||u instanceof Z||u instanceof ne)&&u.paintVertexBuffer&&this._buffers.push(u.paintVertexBuffer),u instanceof ne&&u.paintTransitionVertexBuffer&&this._buffers.push(u.paintTransitionVertexBuffer)}}upload(l){for(const u in this.binders){const p=this.binders[u];(p instanceof W||p instanceof Z||p instanceof ne)&&p.upload(l)}this.updatePaintBuffers()}destroy(){for(const l in this.binders){const u=this.binders[l];(u instanceof W||u instanceof Z||u instanceof ne)&&u.destroy()}}}class ie{constructor(l,u,p=()=>!0){this.programConfigurations={};for(const x of l)this.programConfigurations[x.id]=new re(x,u,p);this.needsUpload=!1,this._featureMap=new g_,this._featureMapWithoutIds=new g_,this._bufferOffset=0,this._idlessCounter=0}populatePaintArrays(l,u,p,x,b,T,k,P,O){for(const $ in this.programConfigurations)this.programConfigurations[$].populatePaintArrays(l,u,x,b,T,k,P,O);u.id!==void 0?this._featureMap.add(u.id,p,this._bufferOffset,l):(this._featureMapWithoutIds.add(this._idlessCounter,p,this._bufferOffset,l),this._idlessCounter+=1),this._bufferOffset=l,this.needsUpload=!0}updatePaintArrays(l,u,p,x,b,T,k,P){for(const O of p)this.needsUpload=this.programConfigurations[O.id].updatePaintArrays(l,this._featureMap,this._featureMapWithoutIds,u,O,x,b,T,k||0,P)||this.needsUpload}get(l){return this.programConfigurations[l]}upload(l){if(this.needsUpload){for(const u in this.programConfigurations)this.programConfigurations[u].upload(l);this.needsUpload=!1}}destroy(){for(const l in this.programConfigurations)this.programConfigurations[l].destroy()}}const ce={"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-occlusion-opacity":["occlusion_opacity"],"icon-occlusion-opacity":["occlusion_opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-emissive-strength":["emissive_strength"],"icon-emissive-strength":["emissive_strength"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"symbol-z-offset":["z_offset"],"line-gap-width":["gapwidth"],"line-pattern":["pattern","pixel_ratio","pattern_b"],"fill-pattern":["pattern","pixel_ratio","pattern_b"],"fill-extrusion-pattern":["pattern","pixel_ratio","pattern_b"],"line-dasharray":["dash"],"fill-bridge-guard-rail-color":["structure_color"],"fill-tunnel-structure-color":["structure_color"]};function le(h,l){return ce[h]||[h.replace(`${l}-`,"").replace(/-/g,"_")]}const ve={"line-pattern":{source:Jd,composite:Jd},"fill-pattern":{source:Jd,composite:Jd},"fill-extrusion-pattern":{source:Jd,composite:Jd},"line-dasharray":{source:_y,composite:_y}},_e={color:{source:Pp,composite:Wh},number:{source:Wc,composite:Pp}};function Re(h,l,u){const p=ve[h];return p&&p[u]||_e[l][u]}Tr(F,"ConstantBinder"),Tr(z,"PatternConstantBinder"),Tr(W,"SourceExpressionBinder"),Tr(ne,"PatternCompositeBinder"),Tr(Z,"CompositeExpressionBinder"),Tr(re,"ProgramConfiguration",{omit:["_buffers"]}),Tr(ie,"ProgramConfigurationSet");const Me=fr/Math.PI/2,Te=64,Xe=[Te,32,16],$e=-Me,Ke=Me;function De(h,l,u,p=Me){return u=Xn(u),[h*Math.sin(u)*p,-l*p,h*Math.cos(u)*p]}function Be(h,l,u){return De(Math.cos(Xn(h)),Math.sin(Xn(h)),l,u)}const Ge=63710088e-1,ot=2*Math.PI*Ge;class Je{constructor(l,u){if(isNaN(l)||isNaN(u))throw new Error(`Invalid LngLat object: (${l}, ${u})`);if(this.lng=+l,this.lat=+u,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new Je(Ye(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(l){const u=Math.PI/180,p=this.lat*u,x=l.lat*u,b=Math.sin(p)*Math.sin(x)+Math.cos(p)*Math.cos(x)*Math.cos((l.lng-this.lng)*u);return Ge*Math.acos(Math.min(b,1))}toBounds(l=0){const u=360*l/40075017,p=u/Math.cos(Math.PI/180*this.lat);return new St({lng:this.lng-p,lat:this.lat-u},{lng:this.lng+p,lat:this.lat+u})}toEcef(l){return Be(this.lat,this.lng,Me+l*Me/Ge)}static convert(l){if(l instanceof Je)return l;if(Array.isArray(l)&&(l.length===2||l.length===3))return new Je(Number(l[0]),Number(l[1]));if(!Array.isArray(l)&&typeof l=="object"&&l!==null)return new Je(Number("lng"in l?l.lng:l.lon),Number(l.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: , lat: }, an object {lon: , lat: }, or an array of [, ]")}}class St{constructor(l,u){l&&(u?this.setSouthWest(l).setNorthEast(u):Array.isArray(l)&&l.length===4?this.setSouthWest([l[0],l[1]]).setNorthEast([l[2],l[3]]):this.setSouthWest(l[0]).setNorthEast(l[1]))}setNorthEast(l){return this._ne=l instanceof Je?new Je(l.lng,l.lat):Je.convert(l),this}setSouthWest(l){return this._sw=l instanceof Je?new Je(l.lng,l.lat):Je.convert(l),this}extend(l){const u=this._sw,p=this._ne;let x,b;if(l instanceof Je)x=l,b=l;else{if(!(l instanceof St))return Array.isArray(l)?l.length===4||l.every(Array.isArray)?this.extend(St.convert(l)):this.extend(Je.convert(l)):typeof l=="object"&&l!==null&&l.hasOwnProperty("lat")&&(l.hasOwnProperty("lon")||l.hasOwnProperty("lng"))?this.extend(Je.convert(l)):this;if(x=l._sw,b=l._ne,!x||!b)return this}return u||p?(u.lng=Math.min(x.lng,u.lng),u.lat=Math.min(x.lat,u.lat),p.lng=Math.max(b.lng,p.lng),p.lat=Math.max(b.lat,p.lat)):(this._sw=new Je(x.lng,x.lat),this._ne=new Je(b.lng,b.lat)),this}getCenter(){return new Je((this._sw.lng+this._ne.lng)/2,(this._sw.lat+this._ne.lat)/2)}getSouthWest(){return this._sw}getNorthEast(){return this._ne}getNorthWest(){return new Je(this.getWest(),this.getNorth())}getSouthEast(){return new Je(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return!(this._sw&&this._ne)}contains(l){const{lng:u,lat:p}=Je.convert(l);let x=this._sw.lng<=u&&u<=this._ne.lng;return this._sw.lng>this._ne.lng&&(x=this._sw.lng>=u&&u>=this._ne.lng),this._sw.lat<=p&&p<=this._ne.lat&&x}static convert(l){if(l)return l instanceof St?l:new St(l)}}function pt(h){return ot*Math.cos(h*Math.PI/180)}function Ot(h){return(180+h)/360}function Ut(h){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+h*Math.PI/360)))/360}function ut(h,l){return h/pt(l)}function st(h){return 360*h-180}function vt(h){return 360/Math.PI*Math.atan(Math.exp((180-360*h)*Math.PI/180))-90}function Et(h,l){return h*pt(vt(l))}const Nt=85.051129;function lr(h){return Math.cos(Xn(pe(h,-85.051129,Nt)))}function Jt(h,l){const u=pe(l,0,25.5),p=Math.pow(2,u);return lr(h)*ot/(512*p)}function er(h){return 1/Math.cos(h*Math.PI/180)}function zt(h,l=0){const u=Math.exp(Math.PI*(1-(h.y+l/fr)/(1<=P?(Or(h,l,u,O,$,b,V,k,P),Or(h,O,$,p,x,V,T,k,P)):h.push(T)}function vr(h,l,u){let p=h[0],x=p.x,b=p.y;l(p);const T=[p];for(let k=1;kh.x+1||ph.y+1)&&hr("Geometry exceeds allowed extent, reduce your vector tile buffer size"),h}function Kr(h,l,u){const p=h.loadGeometry(),x=h.extent,b=fr/x;if(l&&u&&u.projection.isReprojectedInTileSpace){const T=1<{const Y=st((l.x+G.x/x)/T),X=vt((l.y+G.y/x)/T),te=$.project(Y,X);G.x=(te.x*k-P)*x,G.y=(te.y*k-O)*x};for(let G=0;G=x||X.y<0||X.y>=x||(V(X),Y.push(X));p[G]=Y}}for(const T of p)for(const k of T)Tn(k,b);return p}function En(h,l){return{type:h.type,id:h.id,properties:h.properties,geometry:l?Kr(h):[]}}class ln{constructor(l,u,p,x,b){this.properties={},this.extent=p,this.type=0,this.id=void 0,this._pbf=l,this._geometry=-1,this._keys=x,this._values=b,l.readFields(ts,this,u)}loadGeometry(){const l=this._pbf;l.pos=this._geometry;const u=l.readVarint()+l.pos,p=[];let x,b=1,T=0,k=0,P=0;for(;l.pos>3}if(T--,b===1||b===2)k+=l.readSVarint(),P+=l.readSVarint(),b===1&&(x&&p.push(x),x=[]),x&&x.push(new Ft(k,P));else{if(b!==7)throw new Error(`unknown command ${b}`);x&&x.push(x[0].clone())}}return x&&p.push(x),p}bbox(){const l=this._pbf;l.pos=this._geometry;const u=l.readVarint()+l.pos;let p=1,x=0,b=0,T=0,k=1/0,P=-1/0,O=1/0,$=-1/0;for(;l.pos>3}if(x--,p===1||p===2)b+=l.readSVarint(),T+=l.readSVarint(),bP&&(P=b),T$&&($=T);else if(p!==7)throw new Error(`unknown command ${p}`)}return[k,O,P,$]}toGeoJSON(l,u,p){const x=this.extent*Math.pow(2,p),b=this.extent*l,T=this.extent*u,k=this.loadGeometry();function P(G){return[360*(G.x+b)/x-180,360/Math.PI*Math.atan(Math.exp((1-2*(G.y+T)/x)*Math.PI))-90]}function O(G){return G.map(P)}let $;if(this.type===1){const G=[];for(const X of k)G.push(X[0]);const Y=O(G);$=G.length===1?{type:"Point",coordinates:Y[0]}:{type:"MultiPoint",coordinates:Y}}else if(this.type===2){const G=k.map(O);$=G.length===1?{type:"LineString",coordinates:G[0]}:{type:"MultiLineString",coordinates:G}}else{if(this.type!==3)throw new Error("unknown feature type");{const G=function(X){const te=X.length;if(te<=1)return[X];const se=[];let ae,fe;for(let ue=0;ue=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[l];const u=this._pbf.readVarint()+this._pbf.pos;return new ln(this._pbf,u,this.extent,this._keys,this._values)}}function Fs(h,l,u){h===15?l.version=u.readVarint():h===1?l.name=u.readString():h===5?l.extent=u.readVarint():h===2?l._features.push(u.pos):h===3?l._keys.push(u.readString()):h===4&&l._values.push(function(p){let x=null;const b=p.readVarint()+p.pos;for(;p.pos>3;x=T===1?p.readString():T===2?p.readFloat():T===3?p.readDouble():T===4?p.readVarint64():T===5?p.readVarint():T===6?p.readSVarint():T===7?p.readBoolean():null}if(x==null)throw new Error("unknown feature value");return x}(u))}class us{constructor(l,u){this.layers=l.readFields(vn,{},u)}}function vn(h,l,u){if(h===3){const p=new ai(u,u.readVarint()+u.pos);p.length&&(l[p.name]=p)}}const bn="3d_elevation_id",Bs="level";class fi{constructor(){this._valid=!1}reset(l){return this.feature=l,this._valid=!0,this._geometry=l.loadGeometry(),this._geometry.length!==0&&this._geometry[0].length!==0||(this._valid=!1),this}geometry(l,u){return this._valid&&l(u(this._geometry)),this}require(l,u,p){return this.get(l,!0,u,p)}optional(l,u,p){return this.get(l,!1,u,p)}success(){return this._valid}get(l,u,p,x){const b=this.feature.properties.hasOwnProperty(l)?+this.feature.properties[l]:void 0;return this._valid&&b!==void 0&&!Number.isNaN(b)?p(x?x(b):b):u&&(this._valid=!1),this}}class ds{constructor(l,u){this.featureFunc=l,this.vertexFunc=u}parseFeature(l,u,p){return this.featureFunc(l,u,p)}parseVertex(l,u,p){return this.vertexFunc(l,u,p)}}const hn=new ds((h,l,u)=>h.reset(l).require(bn,p=>{u.id=p}).optional("fixed_height_relative",p=>{u.constantHeight=p},Is.decodeRelativeHeight).geometry(p=>{u.bounds=p},VE).success(),(h,l,u)=>h.reset(l).require(bn,p=>{u.id=p}).require("elevation_idx",p=>{u.idx=p}).require("extent",p=>{u.extent=p}).require("height_relative",p=>{u.height=p},Is.decodeRelativeHeight).geometry(p=>{u.position=p},Is.getPoint).success()),ni=new ds((h,l,u)=>h.reset(l).require(bn,p=>{u.id=p}).optional("fixed_height",p=>{u.constantHeight=p},Is.decodeMetricHeight).geometry(p=>{u.bounds=p},VE).success(),(h,l,u)=>h.reset(l).require(bn,p=>{u.id=p}).require("elevation_idx",p=>{u.idx=p}).require("extent",p=>{u.extent=p}).require("height",p=>{u.height=p},Is.decodeMetricHeight).geometry(p=>{u.position=p},Is.getPoint).success());class Is{static getPoint(l){return Bn(l[0][0].x,l[0][0].y)}static decodeRelativeHeight(l){return 1e-4*l*5}static decodeMetricHeight(l){return 1e-4*l}static getVersionSchema(l){return l?l==="1.0.1"?ni:void 0:hn}static parse(l){const u=[],p=[],x=l.length,b=new fi;for(let T=0;T=0);if(b===0)return 0;b!==l.length&&(u=!1)}return u?2:1}function Sa(h,l){for(const u of h.projections){const p=ha(l,h.points[0],u.axis);if(u.projection[1]p[1])return 0}return 1}function ro(h,l){let u=0;const p=[0,0,0,0];for(let x=0;x=0&&u++;return u}class Tc{constructor(l,u){this.points=l||new Array(8).fill([0,0,0]),this.planes=u||new Array(6).fill([0,0,0,0]),this.bounds=ys.fromPoints(this.points),this.projections=[],this.frustumEdges=[qr([],this.points[2],this.points[3]),qr([],this.points[0],this.points[3]),qr([],this.points[4],this.points[0]),qr([],this.points[5],this.points[1]),qr([],this.points[6],this.points[2]),qr([],this.points[7],this.points[3])];for(const p of this.frustumEdges){const x=[0,-p[2],p[1]],b=[p[2],0,-p[0]];this.projections.push({axis:x,projection:ha(this.points,this.points[0],x)}),this.projections.push({axis:b,projection:ha(this.points,this.points[0],b)})}}static fromInvProjectionMatrix(l,u,p,x){const b=Math.pow(2,p),T=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]].map(O=>{const $=Kt([],O,l),V=1/$[3]/u*b;return(G=$)[0]=(Y=$)[0]*(X=[V,V,x?1/$[3]:V,V])[0],G[1]=Y[1]*X[1],G[2]=Y[2]*X[2],G[3]=Y[3]*X[3],G;var G,Y,X}),k=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(O=>{const $=ft([],Vt([],qr([],T[O[0]],T[O[1]]),qr([],T[O[2]],T[O[1]]))),V=-kt($,T[O[1]]);return $.concat(V)}),P=[];for(let O=0;OO[1]||O[0]>P[1])return 0}return 1}containsPoint(l){for(const u of this.planes){const p=u[3];if(kt([u[0],u[1],u[2]],l)+p<0)return!1}return!0}}class ys{static fromPoints(l){const u=[1/0,1/0,1/0],p=[-1/0,-1/0,-1/0];for(const x of l)je(u,u,x),xe(p,p,x);return new ys(u,p)}static fromTileIdAndHeight(l,u,p){const x=1<l.max[u]||l.min[u]>this.max[u])return!1;return!0}intersectsAabbXY(l){return!(this.min[0]>l.max[0]||l.min[0]>this.max[0]||this.min[1]>l.max[1]||l.min[1]>this.max[1])}encapsulate(l){for(let u=0;u<3;u++)this.min[u]=Math.min(this.min[u],l.min[u]),this.max[u]=Math.max(this.max[u],l.max[u])}encapsulatePoint(l){for(let u=0;u<3;u++)this.min[u]=Math.min(this.min[u],l[u]),this.max[u]=Math.max(this.max[u],l[u])}closestPoint(l){return[Math.max(Math.min(this.max[0],l[0]),this.min[0]),Math.max(Math.min(this.max[1],l[1]),this.min[1]),Math.max(Math.min(this.max[2],l[2]),this.min[2])]}}Tr(ys,"Aabb");class Yc{constructor(l,u){this.feature=l,this.metersToTile=u,this.index=0}get(){const l=this.feature.vertices[this.index],u=this.feature.vertexProps[this.index].dir,p=u[1],x=-u[0],b=(l.extent+1)*this.metersToTile;return[new Ft(Math.trunc(l.position[0]+p*b),Math.trunc(l.position[1]+x*b)),new Ft(Math.trunc(l.position[0]-p*b),Math.trunc(l.position[1]-x*b))]}next(){this.index++}valid(){return this.index{return k.a0?Ue(P,P,1/O):be(P,0,0,1)}getSafeArea(){return this.safeArea}isTunnel(){return this.heightRange.max<=-5}getClosestEdge(l){if(this.edges.length===0)return;let u=0,p=Number.POSITIVE_INFINITY,x=0;const[b,T,k,P,O,$,V]=this._tmpVec2;wi(V,l.x,l.y);const G=new Ki(V,null);for(let Y=0;Y0?Qr(P,k)/we:0,Ie=pe(Ae,0,1),We=Math.abs((Ae-Ie)*this.edgeProps[Y].len);ia(O,V,se),wi($,te[1],-te[0]);const ze=We+Math.abs(Qr(O,$));ze=0;--T){const k=this.edges[T].a,P=this.edges[T].b,{position:O,height:$,extent:V}=this.vertices[k],{position:G,height:Y,extent:X}=this.vertices[P],te=this.vertexProps[k].dir,se=this.vertexProps[P].dir;if(be(u,O[0]/l,O[1]/l,$),be(p,G[0]/l,G[1]/l,Y),be(x,te[1],-te[0],0),Ue(x,x,V),be(b,se[1],-se[0],0),Ue(b,b,X),this.distSqLines(Se(u[0]+.5*x[0],u[1]+.5*x[1],u[2]+.5*x[2]),Se(p[0]-.5*b[0],p[1]-.5*b[1],p[2]-.5*b[2]),Se(u[0]-.5*x[0],u[1]-.5*x[1],u[2]-.5*x[2]),Se(p[0]+.5*b[0],p[1]+.5*b[1],p[2]+.5*b[2]))<=.0025000000000000005)continue;const ae=this.vertices.length,fe=ii(Cr(),O,G);this.vertices.push({position:Xr(fe,fe,.5),height:.5*($+Y),extent:.5*(V+X)});const ue=ii(Cr(),te,se);this.vertexProps.push({dir:xn(ue,ue)}),this.edges.splice(T,1),this.edgeProps.splice(T,1),this.edges.push({a:k,b:ae}),this.edges.push({a:ae,b:P});const we=ia(Cr(),this.vertices[ae].position,O),Ae=un(we),Ie={vec:we,dir:Xr(Cr(),we,1/Ae),len:Ae};this.edgeProps.push(Ie),this.edgeProps.push(Ie)}}distSqLines(l,u,p,x){const b=ke(ye(),u,l),T=ke(ye(),x,p),k=ke(ye(),l,p),P=kt(b,b),O=kt(b,T),$=kt(b,k),V=kt(T,T),G=kt(T,k),Y=P*V-O*O;if(Y===0)return wt(xt(b,p,x,kt(k,T)/kt(T,T)),l);const X=(P*G-O*$)/Y;return wt(xt(b,l,u,(O*G-$*V)/Y),xt(T,p,x,X))}}class Vs{static parseFrom(l,u){const p=Is.parse(l);if(!p)return[];let{vertices:x,features:b}=p;const T=1/zt(u);b.sort(($,V)=>$.id-V.id),x.sort(($,V)=>$.id-V.id||$.idx-V.idx),x=x.filter(($,V,G)=>V===G.findIndex(Y=>Y.id===$.id&&Y.idx===$.idx));const k=new Array;let P=0;const O=x.length;for(const $ of b){if($.constantHeight){k.push(new Zc($.id,$.bounds,$.constantHeight));continue}for(;P!==O&&x[P].id<$.id;)P++;if(P===O||x[P].id!==$.id)continue;const V=new Array,G=new Array,Y=P;for(;P!==O&&x[P].id===$.id;){const X=x[P];if(V.push({position:X.position,height:X.height,extent:X.extent}),P!==Y&&x[P-1].idx===X.idx-1){const te=P-Y;G.push({a:te-1,b:te})}P++}k.push(new Zc($.id,$.bounds,void 0,V,G,T))}return k}static getElevationFeature(l,u){if(!u)return;const p=+l.properties[bn];return Number.isNaN(p)?void 0:u.find(x=>x.id===p)}}class Ys{constructor(l,u){this.zScale=1,this.xOffset=0,this.yOffset=0,l.equals(u)||(this.zScale=Math.pow(2,u.z-l.z),this.xOffset=(l.x*this.zScale-u.x)*fr,this.yOffset=(l.y*this.zScale-u.y)*fr)}constantElevation(l,u){if(l.constantHeight!=null)return this.computeBiasedHeight(l.constantHeight,u)}pointElevation(l,u,p){const x=this.constantElevation(u,p);return x??(l.x=l.x*this.zScale+this.xOffset,l.y=l.y*this.zScale+this.yOffset,this.computeBiasedHeight(u.pointElevation(l),p))}computeBiasedHeight(l,u){return u<=0?l:l+u*Fe(0,u,l>=0?l:Math.abs(.5*l))}}Tr(Zc,"ElevationFeature");class Ts{constructor(l){this.zoom=l.zoom,this.overscaling=l.overscaling,this.layers=l.layers,this.layerIds=this.layers.map(u=>u.fqid),this.index=l.index,this.hasPattern=!1,this.projection=l.projection,this.layoutVertexArray=new Sc,this.indexArray=new Pi,this.segments=new Os,this.programConfigurations=new ie(l.layers,{zoom:l.zoom,lut:l.lut}),this.stateDependentLayerIds=this.layers.filter(u=>u.isStateDependent()).map(u=>u.id),this.elevationMode=this.layers[0].layout.get("circle-elevation-reference"),this.hasElevation=!1,this.elevationMode!=="none"&&(this.elevatedLayoutVertexArray=new Wc),this.worldview=l.worldview,this.hasAppearances=null}updateFootprints(l,u){}updateAppearances(l,u,p,x){return{hasLayoutChanges:!1,hasUboChanges:!1}}populate(l,u,p,x){const b=this.layers[0],T=[];let k=null;b.type==="circle"&&(k=b.layout.get("circle-sort-key"));for(const{feature:O,id:$,index:V,sourceLayerIndex:G}of l){const Y=this.layers[0]._featureFilter.needGeometry,X=En(O,Y);if(!this.layers[0]._featureFilter.filter(new fs(this.zoom,{worldview:this.worldview,activeFloors:u.activeFloors}),X,p))continue;const te=k?k.evaluate(X,{},p):void 0,se={id:$,properties:O.properties,type:O.type,sourceLayerIndex:G,index:V,geometry:Y?X.geometry:Kr(O,p,x),patterns:{},sortKey:te};T.push(se)}k&&T.sort((O,$)=>O.sortKey-$.sortKey);let P=null;x.projection.name==="globe"&&(this.globeExtVertexArray=new dw,P=x.projection);for(const O of T){const{geometry:$,index:V,sourceLayerIndex:G}=O,Y=l[V].feature;this.addFeature(O,$,V,u.availableImages,p,P,u.brightness,u.elevationFeatures),u.featureIndex.insert(Y,$,V,G,this.index)}this.hasElevation||(this.elevatedLayoutVertexArray=void 0)}update(l,u,p,x,b,T,k){this.programConfigurations.updatePaintArrays(l,u,b,p,x,T,k,this.worldview)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(l){this.uploaded||(this.layoutVertexBuffer=l.createVertexBuffer(this.layoutVertexArray,bP.members),this.indexBuffer=l.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=l.createVertexBuffer(this.globeExtVertexArray,gB.members)),this.elevatedLayoutVertexArray&&(this.elevatedLayoutVertexBuffer=l.createVertexBuffer(this.elevatedLayoutVertexArray,pB.members))),this.programConfigurations.upload(l),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy(),this.elevatedLayoutVertexBuffer&&this.elevatedLayoutVertexBuffer.destroy())}addFeature(l,u,p,x,b,T,k,P){let O;this.elevationMode!=="none"&&(O=Vs.getElevationFeature(l,P));for(const $ of u)for(const V of $){const G=V.x,Y=V.y;if(G<0||G>=fr||Y<0||Y>=fr)continue;if(T){const se=T.projectTilePoint(G,Y,b),ae=T.upVector(b,G,Y);this.addGlobeExtVertex(se,ae),this.addGlobeExtVertex(se,ae),this.addGlobeExtVertex(se,ae),this.addGlobeExtVertex(se,ae)}const X=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,l.sortKey),te=X.vertexLength;if(this.addCircleVertex(G,Y,-1,-1),this.addCircleVertex(G,Y,1,-1),this.addCircleVertex(G,Y,1,1),this.addCircleVertex(G,Y,-1,1),this.elevationMode!=="none"){const se=O?O.pointElevation(new Ft(G,Y)):0;this.hasElevation=this.hasElevation||se!==0;for(let ae=0;ae<4;ae++)this.elevatedLayoutVertexArray.emplaceBack(se)}this.indexArray.emplaceBack(te,te+1,te+2),this.indexArray.emplaceBack(te,te+2,te+3),X.vertexLength+=4,X.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,l,p,{},x,b,k,void 0,this.worldview)}addCircleVertex(l,u,p,x){this.layoutVertexArray.emplaceBack(2*l+(p+1)/2,2*u+(x+1)/2)}addGlobeExtVertex(l,u){this.globeExtVertexArray.emplaceBack(l.x,l.y,l.z,u[0]*16384,u[1]*16384,u[2]*16384)}}function Vi(h,l){for(let u=0;u1){if(rm(h,l))return!0;for(let p=0;p1?u:u.sub(l)._mult(x)._add(l))}function by(h,l){let u,p,x,b=!1;for(let T=0;Tl.y!=x.y>l.y&&l.x<(x.x-p.x)*(l.y-p.y)/(x.y-p.y)+p.x&&(b=!b)}return b}function Zl(h,l){let u=!1;for(let p=0,x=h.length-1;pl.y!=T.y>l.y&&l.x<(T.x-b.x)*(l.y-b.y)/(T.y-b.y)+b.x&&(u=!u)}return u}function nm(h,l,u,p,x){for(const T of h)if(l<=T.x&&u<=T.y&&p>=T.x&&x>=T.y)return!0;const b=[new Ft(l,u),new Ft(l,x),new Ft(p,x),new Ft(p,u)];if(h.length>2){for(const T of b)if(Zl(h,T))return!0}for(let T=0;Tx.x&&l.x>x.x||h.yx.y&&l.y>x.y)return!1;const b=rt(h,l,u[0]);return b!==rt(h,l,u[1])||b!==rt(h,l,u[2])||b!==rt(h,l,u[3])}function im(h,l,u,p,x,b){let T=l.y-h.y,k=h.x-l.x;if(b=b||0){const P=T*T+k*k;if(P===0)return!0;const O=Math.sqrt(P);T/=O,k/=O}return!((u.x-h.x)*T+(u.y-h.y)*k-b<0||(p.x-h.x)*T+(p.y-h.y)*k-b<0||(x.x-h.x)*T+(x.y-h.y)*k-b<0)}function vw(h,l,u,p,x,b,T){return!(im(h,l,p,x,b,T)||im(l,u,p,x,b,T)||im(u,h,p,x,b,T)||im(p,x,h,l,u,T)||im(x,b,h,l,u,T)||im(b,p,h,l,u,T))}function wy(h,l,u){const p=l.paint.get(h).value;return p.kind==="constant"?p.value:u.programConfigurations.get(l.id).getMaxValue(h)}function wP(h){return Math.sqrt(h[0]*h[0]+h[1]*h[1])}function fX(h,l,u,p,x){if(!l[0]&&!l[1])return h;const b=Ft.convert(l)._mult(x);u==="viewport"&&b._rotate(-p);const T=[];for(let k=0;k>u&&l.y===this.y>>u}url(l,u){const p=function(b,T,k){const P=2**k,O=2*Math.PI*6378137,$=O*(b/P-.5),V=O*(.5-(T+1)/P);return`${$},${V},${$+O/P},${V+O/P}`}(this.x,this.y,this.z),x=function(b,T,k){let P,O="";for(let $=b;$>0;$--)P=1<<$-1,O+=(T&P?1:0)+(k&P?2:0);return O}(this.z,this.x,this.y);return l[(this.x+this.y)%l.length].replace("{prefix}",(this.x%16).toString(16)+(this.y%16).toString(16)).replace(/{z}/g,String(this.z)).replace(/{x}/g,String(this.x)).replace(/{y}/g,String(u==="tms"?Math.pow(2,this.z)-this.y-1:this.y)).replace("{quadkey}",x).replace("{bbox-epsg-3857}",p)}toString(){return`${this.z}/${this.x}/${this.y}`}}class yX{constructor(l,u){this.wrap=l,this.canonical=u,this.key=bw(l,u.z,u.z,u.x,u.y)}}class Ll{constructor(l,u,p,x,b){this.overscaledZ=l,this.wrap=u,this.canonical=new v_(p,+x,+b),this.key=u===0&&l===p?this.canonical.key:bw(u,l,p,x,b)}equals(l){return this.overscaledZ===l.overscaledZ&&this.wrap===l.wrap&&this.canonical.equals(l.canonical)}scaledTo(l){const u=this.canonical.z-l;return l>this.canonical.z?new Ll(l,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new Ll(l,this.wrap,l,this.canonical.x>>u,this.canonical.y>>u)}calculateScaledKey(l,u=!0){if(this.overscaledZ===l&&u)return this.key;if(l>this.canonical.z)return bw(this.wrap*+u,l,this.canonical.z,this.canonical.x,this.canonical.y);{const p=this.canonical.z-l;return bw(this.wrap*+u,l,l,this.canonical.x>>p,this.canonical.y>>p)}}isChildOf(l){if(l.wrap!==this.wrap)return!1;const u=this.canonical.z-l.canonical.z;return l.overscaledZ===0||l.overscaledZ>u&&l.canonical.y===this.canonical.y>>u}children(l){if(this.overscaledZ>=l)return[new Ll(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const u=this.canonical.z+1,p=2*this.canonical.x,x=2*this.canonical.y;return[new Ll(u,this.wrap,u,p,x),new Ll(u,this.wrap,u,p+1,x),new Ll(u,this.wrap,u,p,x+1),new Ll(u,this.wrap,u,p+1,x+1)]}isLessThan(l){return this.wrapl.wrap)&&(this.overscaledZl.overscaledZ)&&(this.canonical.xl.canonical.x)&&this.canonical.y{let l=h.canonical.x-1,u=h.wrap;return l<0&&(l=(1<{let l=h.canonical.x+1,u=h.wrap;return l===1<new Ll(h.overscaledZ,h.wrap,h.canonical.z,h.canonical.x,(h.canonical.y===0?1<new Ll(h.overscaledZ,h.wrap,h.canonical.z,h.canonical.x,h.canonical.y===(1<1?null:function(p,x,b,T){const k=Math.sin(b);return p*(Math.sin((1-T)*b)/k)+x*(Math.sin(T*b)/k)}(h.a[l],h.b[l],h.angle,pe(u,0,1))+h.center[l]}function am(h){if(h.z<=1)return TIe[h.z+2*h.y+h.x];const l=SB(EP(h));return ys.fromPoints(l)}function Dp(h,l,u){return Ue(h,h,1-u),Ze(h,h,l,u)}function vX(h,l){const u=Op(l.zoom);if(u===0)return am(h);const p=EP(h),x=SB(p),b=Ot(p.getWest())*l.worldSize,T=Ot(p.getEast())*l.worldSize,k=Ut(p.getNorth())*l.worldSize,P=Ut(p.getSouth())*l.worldSize,O=[b,k,0],$=[T,k,0],V=[b,P,0],G=[T,P,0],Y=M([],l.globeMatrix);return or(O,O,Y),or($,$,Y),or(V,V,Y),or(G,G,Y),x[0]=Dp(x[0],V,u),x[1]=Dp(x[1],G,u),x[2]=Dp(x[2],$,u),x[3]=Dp(x[3],O,u),ys.fromPoints(x)}function bX(h,l,u){for(const p of h)or(p,p,l),Ue(p,p,u)}function wX(h,l,u,p){const x=l/h.worldSize,b=h.globeMatrix;if(u.z<=1){const He=am(u).getCorners();return bX(He,b,x),ys.fromPoints(He)}const T=EP(u,p),k=SB(T,Me+TP(h._tileCoverLift));bX(k,b,x);const P=Number.MAX_VALUE,O=[-P,-P,-P],$=[P,P,P];if(T.contains(h.center)){for(const qe of k)je($,$,qe),xe(O,O,qe);O[2]=0;const He=h.point,Ve=[He.x*x,He.y*x,0];return je($,$,Ve),xe(O,O,Ve),new ys($,O)}if(h._tileCoverLift>0){for(const He of k)je($,$,He),xe(O,O,He);return new ys($,O)}const V=[b[12]*x,b[13]*x,b[14]*x],G=T.getCenter(),Y=pe(h.center.lat,-85.051129,Nt),X=pe(G.lat,-85.051129,Nt),te=Ot(h.center.lng),se=Ut(Y);let ae=te-Ot(G.lng);const fe=se-Ut(X);ae>.5?ae-=1:ae<-.5&&(ae+=1);let ue=0;Math.abs(ae)>Math.abs(fe)?ue=ae>=0?1:3:(ue=fe>=0?0:2,Ze(V,V,[b[4]*x,b[5]*x,b[6]*x],-Math.sin(Xn(fe>=0?T.getSouth():T.getNorth()))*Me));const we=k[ue],Ae=k[(ue+1)%4],Ie=new EIe(we,Ae,V),We=[wB(Ie,0)||we[0],wB(Ie,1)||we[1],wB(Ie,2)||we[2]],ze=Op(h.zoom);if(ze>0){const He=function({x:qe,y:bt,z:jt},It,Dt,Pt,Ht){const _t=1/(1<.5?br=-1:ur<-.5&&(br=1),Rt=((Rt+br)*It-(Pt*=It))*Dt+Pt,Bt=((Bt+br)*It-Pt)*Dt+Pt,Yt=(Yt*It-(Ht*=It))*Dt+Ht,tr=(tr*It-Ht)*Dt+Ht,[[Rt,tr,0],[Bt,tr,0],[Bt,Yt,0],[Rt,Yt,0]]}(u,l,h._pixelsPerMercatorPixel,te,se);for(let qe=0;qeMath.PI/2*1.01}const kX=Xn(85),jIe=Math.cos(kX),kIe=Math.sin(kX),AIe=A(),AX=h=>{const l=[];return h.paint.get("circle-pitch-alignment")==="map"&&l.push("PITCH_WITH_MAP"),h.paint.get("circle-pitch-scale")==="map"&&l.push("SCALE_WITH_MAP"),l};function NX(h,l,u,p,x,b,T,k,P){if(b&&h.queryGeometry.isAboveHorizon)return!1;b&&(P*=h.pixelToTileUnitsFactor);const O=h.tileID.canonical,$=u.projection.upVectorScale(O,u.center.lat,u.worldSize).metersToTile;for(const V of l)for(const G of V){const Y=G.add(k),X=x&&u.elevation?u.elevation.exaggeration()*x.getElevationAt(Y.x,Y.y,!0):0,te=u.projection.projectTilePoint(Y.x,Y.y,O);if(X>0){const ue=u.projection.upVector(O,Y.x,Y.y);te.x+=ue[0]*$*X,te.y+=ue[1]*$*X,te.z+=ue[2]*$*X}const se=b?Y:NIe(te.x,te.y,te.z,p),ae=b?h.tilespaceRays.map(ue=>IIe(ue,X)):h.queryGeometry.screenGeometry,fe=Kt([],[te.x,te.y,te.z,1],p);if(!T&&b?P*=fe[3]/u.cameraToCenterDistance:T&&!b&&(P*=u.cameraToCenterDistance/fe[3]),b){const ue=vt((G.y/fr+O.y)/(1<h.width||x.height>h.height||u.x>h.width-x.width||u.y>h.height-x.height)throw new RangeError("out of range source coordinates for image copy");if(x.width>l.width||x.height>l.height||p.x>l.width-x.width||p.y>l.height-x.height)throw new RangeError("out of range destination coordinates for image copy");const P=h.data,O=l.data,$=b===4&&k;for(let V=0;V{l[h.evaluationKey]=P;const O=h.expression.evaluate(l),$=O?O.toNonPremultipliedRenderColor(null):null;$&&(x.data[T+k+0]=Math.floor(255*$.r),x.data[T+k+1]=Math.floor(255*$.g),x.data[T+k+2]=Math.floor(255*$.b),x.data[T+k+3]=Math.floor(255*$.a))};if(h.clips)for(let T=0,k=0;T80*u){k=h[0],P=h[1];let $=k,V=P;for(let G=u;G$&&($=Y),X>V&&(V=X)}O=Math.max($-k,V-P),O=O!==0?32767/O:0}return r2(b,T,u,k,P,O,0),T}function BX(h,l,u,p,x){let b;if(x===function(T,k,P,O){let $=0;for(let V=k,G=P-O;V0)for(let T=l;T=l;T-=p)b=VX(T/p|0,h[T],h[T+1],b);return b&&Sw(b,b.next)&&(i2(b),b=b.next),b}function b_(h,l){if(!h)return h;l||(l=h);let u,p=h;do if(u=!1,p.steiner||!Sw(p,p.next)&&no(p.prev,p,p.next)!==0)p=p.next;else{if(i2(p),p=l=p.prev,p===p.next)break;u=!0}while(u||p!==l);return l}function r2(h,l,u,p,x,b,T){if(!h)return;!T&&b&&function(P,O,$,V){let G=P;do G.z===0&&(G.z=AB(G.x,G.y,O,$,V)),G.prevZ=G.prev,G.nextZ=G.next,G=G.next;while(G!==P);G.prevZ.nextZ=null,G.prevZ=null,function(Y){let X,te=1;do{let se,ae=Y;Y=null;let fe=null;for(X=0;ae;){X++;let ue=ae,we=0;for(let Ie=0;Ie0||Ae>0&&ue;)we!==0&&(Ae===0||!ue||ae.z<=ue.z)?(se=ae,ae=ae.nextZ,we--):(se=ue,ue=ue.nextZ,Ae--),fe?fe.nextZ=se:Y=se,se.prevZ=fe,fe=se;ae=ue}fe.nextZ=null,te*=2}while(X>1)}(G)}(h,p,x,b);let k=h;for(;h.prev!==h.next;){const P=h.prev,O=h.next;if(b?OIe(h,p,x,b):DIe(h))l.push(P.i,h.i,O.i),i2(h),h=O.next,k=O.next;else if((h=O)===k){T?T===1?r2(h=FIe(b_(h),l),l,u,p,x,b,2):T===2&&BIe(h,l,u,p,x,b):r2(b_(h),l,u,p,x,b,1);break}}}function DIe(h){const l=h.prev,u=h,p=h.next;if(no(l,u,p)>=0)return!1;const x=l.x,b=u.x,T=p.x,k=l.y,P=u.y,O=p.y,$=Math.min(x,b,T),V=Math.min(k,P,O),G=Math.max(x,b,T),Y=Math.max(k,P,O);let X=p.next;for(;X!==l;){if(X.x>=$&&X.x<=G&&X.y>=V&&X.y<=Y&&n2(x,k,b,P,T,O,X.x,X.y)&&no(X.prev,X,X.next)>=0)return!1;X=X.next}return!0}function OIe(h,l,u,p){const x=h.prev,b=h,T=h.next;if(no(x,b,T)>=0)return!1;const k=x.x,P=b.x,O=T.x,$=x.y,V=b.y,G=T.y,Y=Math.min(k,P,O),X=Math.min($,V,G),te=Math.max(k,P,O),se=Math.max($,V,G),ae=AB(Y,X,l,u,p),fe=AB(te,se,l,u,p);let ue=h.prevZ,we=h.nextZ;for(;ue&&ue.z>=ae&&we&&we.z<=fe;){if(ue.x>=Y&&ue.x<=te&&ue.y>=X&&ue.y<=se&&ue!==x&&ue!==T&&n2(k,$,P,V,O,G,ue.x,ue.y)&&no(ue.prev,ue,ue.next)>=0||(ue=ue.prevZ,we.x>=Y&&we.x<=te&&we.y>=X&&we.y<=se&&we!==x&&we!==T&&n2(k,$,P,V,O,G,we.x,we.y)&&no(we.prev,we,we.next)>=0))return!1;we=we.nextZ}for(;ue&&ue.z>=ae;){if(ue.x>=Y&&ue.x<=te&&ue.y>=X&&ue.y<=se&&ue!==x&&ue!==T&&n2(k,$,P,V,O,G,ue.x,ue.y)&&no(ue.prev,ue,ue.next)>=0)return!1;ue=ue.prevZ}for(;we&&we.z<=fe;){if(we.x>=Y&&we.x<=te&&we.y>=X&&we.y<=se&&we!==x&&we!==T&&n2(k,$,P,V,O,G,we.x,we.y)&&no(we.prev,we,we.next)>=0)return!1;we=we.nextZ}return!0}function FIe(h,l){let u=h;do{const p=u.prev,x=u.next.next;!Sw(p,x)&&zX(p,u,u.next,x)&&s2(p,x)&&s2(x,p)&&(l.push(p.i,u.i,x.i),i2(u),i2(u.next),u=h=x),u=u.next}while(u!==h);return b_(u)}function BIe(h,l,u,p,x,b){let T=h;do{let k=T.next.next;for(;k!==T.prev;){if(T.i!==k.i&&qIe(T,k)){let P=UX(T,k);return T=b_(T,T.next),P=b_(P,P.next),r2(T,l,u,p,x,b,0),void r2(P,l,u,p,x,b,0)}k=k.next}T=T.next}while(T!==h)}function $Ie(h,l){let u=h.x-l.x;return u===0&&(u=h.y-l.y,u===0)&&(u=(h.next.y-h.y)/(h.next.x-h.x)-(l.next.y-l.y)/(l.next.x-l.x)),u}function zIe(h,l){const u=function(x,b){let T=b;const k=x.x,P=x.y;let O,$=-1/0;if(Sw(x,T))return T;do{if(Sw(x,T.next))return T.next;if(P<=T.y&&P>=T.next.y&&T.next.y!==T.y){const te=T.x+(P-T.y)*(T.next.x-T.x)/(T.next.y-T.y);if(te<=k&&te>$&&($=te,O=T.x=T.x&&T.x>=G&&k!==T.x&&$X(PO.x||T.x===O.x&&UIe(O,T)))&&(O=T,X=te)}T=T.next}while(T!==V);return O}(h,l);if(!u)return l;const p=UX(u,h);return b_(p,p.next),b_(u,u.next)}function UIe(h,l){return no(h.prev,h,l.prev)<0&&no(l.next,h,h.next)<0}function AB(h,l,u,p,x){return(h=1431655765&((h=858993459&((h=252645135&((h=16711935&((h=(h-u)*x|0)|h<<8))|h<<4))|h<<2))|h<<1))|(l=1431655765&((l=858993459&((l=252645135&((l=16711935&((l=(l-p)*x|0)|l<<8))|l<<4))|l<<2))|l<<1))<<1}function VIe(h){let l=h,u=h;do(l.x=(h-T)*(b-k)&&(h-T)*(p-k)>=(u-T)*(l-k)&&(u-T)*(b-k)>=(x-T)*(p-k)}function n2(h,l,u,p,x,b,T,k){return!(h===T&&l===k)&&$X(h,l,u,p,x,b,T,k)}function qIe(h,l){return h.next.i!==l.i&&h.prev.i!==l.i&&!function(u,p){let x=u;do{if(x.i!==u.i&&x.next.i!==u.i&&x.i!==p.i&&x.next.i!==p.i&&zX(x,x.next,u,p))return!0;x=x.next}while(x!==u);return!1}(h,l)&&(s2(h,l)&&s2(l,h)&&function(u,p){let x=u,b=!1;const T=(u.x+p.x)/2,k=(u.y+p.y)/2;do x.y>k!=x.next.y>k&&x.next.y!==x.y&&T<(x.next.x-x.x)*(k-x.y)/(x.next.y-x.y)+x.x&&(b=!b),x=x.next;while(x!==u);return b}(h,l)&&(no(h.prev,h,l.prev)||no(h,l.prev,l))||Sw(h,l)&&no(h.prev,h,h.next)>0&&no(l.prev,l,l.next)>0)}function no(h,l,u){return(l.y-h.y)*(u.x-l.x)-(l.x-h.x)*(u.y-l.y)}function Sw(h,l){return h.x===l.x&&h.y===l.y}function zX(h,l,u,p){const x=AP(no(h,l,u)),b=AP(no(h,l,p)),T=AP(no(u,p,h)),k=AP(no(u,p,l));return x!==b&&T!==k||!(x!==0||!kP(h,u,l))||!(b!==0||!kP(h,p,l))||!(T!==0||!kP(u,h,p))||!(k!==0||!kP(u,l,p))}function kP(h,l,u){return l.x<=Math.max(h.x,u.x)&&l.x>=Math.min(h.x,u.x)&&l.y<=Math.max(h.y,u.y)&&l.y>=Math.min(h.y,u.y)}function AP(h){return h>0?1:h<0?-1:0}function s2(h,l){return no(h.prev,h,h.next)<0?no(h,l,h.next)>=0&&no(h,h.prev,l)>=0:no(h,l,h.prev)<0||no(h,h.next,l)<0}function UX(h,l){const u=NB(h.i,h.x,h.y),p=NB(l.i,l.x,l.y),x=h.next,b=l.prev;return h.next=l,l.prev=h,u.next=x,x.prev=u,p.next=u,u.prev=p,b.next=p,p.prev=b,p}function VX(h,l,u,p){const x=NB(h,l,u);return p?(x.next=p.next,x.prev=p,p.next.prev=x,p.next=x):(x.prev=x,x.next=x),x}function i2(h){h.next.prev=h.prev,h.prev.next=h.next,h.prevZ&&(h.prevZ.nextZ=h.nextZ),h.nextZ&&(h.nextZ.prevZ=h.prevZ)}function NB(h,l,u){return{i:h,x:l,y:u,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function a2(h,l){const u=h.length;if(u<=1)return[h];const p=[];let x,b;for(let T=0;T1)for(let T=0;T=fr&&u>=fr}static evaluate(l){if(l.length===0)return new Fp;let u=[];for(const P of l)u.push(...P.portals);if(u.length===0)return new Fp;for(const P of u){const O=P.va,$=P.vb;(Fp.isOnBorder(O.x,$.x)||Fp.isOnBorder(O.y,$.y))&&(P.type="border")}const p=u.filter(P=>P.type!=="unevaluated"),x=u.filter(P=>P.type==="unevaluated");if(x.length===0)return new Fp;x.sort((P,O)=>P.hash===O.hash?P.isTunnel===O.isTunnel?0:P.isTunnel?-1:1:P.hashP.hashb!=="fill-tunnel-structure-color"),this.tunnelProgramConfigurations=new ie(u,{zoom:p,lut:x},b=>b!=="fill-bridge-guard-rail-color")}addVertices(l,u){const p=this.unevalVertices.length;for(let x=0;x=b.min.x&&V.x<=b.max.x&&V.y>=b.min.y&&V.y<=b.max.y||G.x>=b.min.x&&G.x<=b.max.x&&G.y>=b.min.y&&G.y<=b.max.y||sm(V,G,k))||this.isOnBorder(V.x,G.x)||this.isOnBorder(V.y,G.y))continue;const Y=Xc.computeEdgeHash(this.unevalVertices[O],this.unevalVertices[$]);let X,te=this.vertexHashLookup.get(Xc.computePosHash(V));te!=null?X=te.next:(te=this.vertexHashLookup.get(Xc.computePosHash(G)),X=te!=null?te.prev:Y),this.unevalEdges.push({polygonIdx:l,a:O,b:$,hash:Y,portalHash:X,isTunnel:x,type:"unevaluated",featureInfo:T})}}addPortalCandidates(l,u,p,x,b){if(u.length!==0){this.vertexHashLookup.clear();for(const T of u){if(T.length===0)continue;const k=T[0];let P=Xc.computeEdgeHash(k[k.length-2],k[k.length-1]);for(let O=0;O({vertexOffset:0,primitiveOffset:this.indexArray.length}),p=G=>{G.primitiveLength=this.indexArray.length-G.primitiveOffset},x=new HIe(this.vertexPositions,this.vertexNormals,this.indexArray);this.prepareEdges(l.portals,this.unevalEdges);const b=u(),T=u(),k=u(),P=(G,Y)=>{G.sort((te,se)=>te.type===Y&&se.type!==Y?-1:te.type!==Y&&se.type===Y?1:0);const X=G.findIndex(te=>te.type!==Y);return X>=0?X:G.length};let O=0;this.unevalEdges.length>0&&(O=P(this.unevalEdges,"none"),this.constructBridgeStructures(x,this.unevalVertices,this.unevalHeights,this.unevalEdges,{min:0,max:O},this.tileToMeters)),p(k);const $=u(),V=u();if(this.unevalEdges.length>0){const G=this.unevalEdges.splice(O),Y=P(G,"tunnel")+O;this.unevalEdges.push(...G),this.constructTunnelStructures(x,this.unevalVertices,this.unevalHeights,this.unevalEdges,{min:0,max:O},{min:O,max:Y})}p($),x.addTriangles(this.unevalTriangles,this.unevalVertices,this.unevalHeights),p(V),x.addTriangles(this.unevalTunnelTriangles,this.unevalVertices,this.unevalHeights),p(T),x.addTriangles(this.unevalTunnelTriangles,this.unevalVertices,[-.1]),p(b),this.maskSegments=Os.simpleSegment(0,V.primitiveOffset,0,V.primitiveLength),this.depthSegments=Os.simpleSegment(0,T.primitiveOffset,0,T.primitiveLength),this.renderableBridgeSegments=Os.simpleSegment(0,k.primitiveOffset,0,k.primitiveLength),this.renderableTunnelSegments=Os.simpleSegment(0,$.primitiveOffset,0,$.primitiveLength),this.shadowCasterSegments=Os.simpleSegment(0,b.primitiveOffset,0,b.primitiveLength)}update(l,u,p,x,b,T,k,P){this.bridgeProgramConfigurations.updatePaintArrays(l,u,b,p,x,T,k,P),this.tunnelProgramConfigurations.updatePaintArrays(l,u,b,p,x,T,k,P)}upload(l){this.vertexBuffer||this.vertexPositions.length===0||this.vertexNormals.length===0||this.indexArray.length===0||(this.vertexBuffer=l.createVertexBuffer(this.vertexPositions,LIe.members),this.vertexBufferNormal=l.createVertexBuffer(this.vertexNormals,MIe.members),this.indexBuffer=l.createIndexBuffer(this.indexArray),this.bridgeProgramConfigurations.upload(l),this.tunnelProgramConfigurations.upload(l))}destroy(){this.vertexBuffer&&(this.vertexBuffer.destroy(),this.vertexBufferNormal.destroy(),this.indexBuffer.destroy()),this.maskSegments&&(this.maskSegments.destroy(),this.depthSegments.destroy(),this.renderableBridgeSegments.destroy(),this.renderableTunnelSegments.destroy(),this.shadowCasterSegments.destroy()),this.bridgeProgramConfigurations.destroy(),this.tunnelProgramConfigurations.destroy()}populatePaintArrays(l,u,p,x,b){const T=(k,P)=>{for(let O=0;Obe(Dt,u[Pt].x,u[Pt].y,p[Pt]*P),V=ye(),G=ye(),Y=ye(),X=ye(),te=ye(),se=(Dt,Pt)=>{const Ht=k.get(Xc.computePosHash(u[Pt])),_t=Ht.from,Rt=Ht.to;if(!_t||!Rt)return;$(V,_t),$(G,Pt),$(Y,Rt),Rr(X),$r(V,G)||(qr(te,G,V),ft(X,te)),$r(Y,G)||(qr(te,Y,G),me(X,X,ft(te,te)));const Bt=tt(X);return Bt>0?Ue(Dt,X,1/Bt):void 0};let ae=Number.POSITIVE_INFINITY;this.sortSubarray(x,b.min,b.max,(Dt,Pt)=>Dt.featureInfo.featureIndex-Pt.featureInfo.featureIndex);const fe=ye(),ue=ye(),we=ye(),Ae=ye(),Ie=ye(),We=ye(),ze=ye(),He=ye(),Ve=ye(),qe=[ye(),ye(),ye(),ye()],bt=[ye(),ye(),ye(),ye()],jt=[{coord:new Ft(0,0),height:0},{coord:new Ft(0,0),height:0}],It=(Dt,Pt)=>Dt>Pt;for(let Dt=b.min;Dtae.featureInfo.featureIndex-fe.featureInfo.featureIndex;this.sortSubarray(x,b.min,b.max,P),this.sortSubarray(x,T.min,T.max,P);const O=ae=>ft(ae,ae),$=[{coord:new Ft(0,0),height:0},{coord:new Ft(0,0),height:0}],V=(ae,fe)=>aek.hash===P.hash?P.polygonIdx-k.polygonIdx:P.hash>k.hash?1:-1);let p=0,x=0,b=0,T=u[p].polygonIdx;do x++,(x===u.length||u[p].hash!==u[x].hash)&&((x-p===1||u[x-1].polygonIdx!==T)&&(bO.portalHash<$.portalHash?1:-1);let k=0,P=0;for(;k!==u.length&&P!==l.length;){const O=u[k],$=l[P];O.portalHash>$.hash?k++:$.hash>O.portalHash?P++:(O.type=$.type,k++)}}}isOnBorder(l,u){return l<=0&&u<=0||l>=fr&&u>=fr}addFeatureSection(l,u,p,x){return l!==u&&(u=l,p.push({featureIndex:l,vertexStart:x.getVertexCount()}),x.clearVertexLookup()),u}sortSubarray(l,u,p,x){const b=l.slice(u,p);b.sort(x),l.splice(u,b.length,...b)}static computeEdgeHash(l,u){return(l.y===u.y&&l.x>u.x||l.y>u.y)&&([l,u]=[u,l]),BigInt(Xc.computePosHash(l))<<32n|BigInt(Xc.computePosHash(u))}static computePosHash(l){return((65535&l.x)<<16|65535&l.y)>>>0}}function WIe(h,l){return h>l?1:h0))return u;u=u.left}}return null}contains(l){for(var u=this._root,p=this._compare;u;){var x=p(l,u.key);if(x===0)return!0;u=x<0?u.left:u.right}return!1}remove(l){var u=this.find(l);if(!u)return!1;if(this.splay(u),u.left)if(u.right){var p=this.minNode(u.right);p.parent!==u&&(this.replace(p,p.right),p.right=u.right,p.right.parent=p),this.replace(u,p),p.left=u.left,p.left.parent=p}else this.replace(u,u.left);else this.replace(u,u.right);return this._size--,!0}removeNode(l){if(!l)return!1;if(this.splay(l),l.left)if(l.right){var u=this.minNode(l.right);u.parent!==l&&(this.replace(u,u.right),u.right=l.right,u.right.parent=u),this.replace(l,u),u.left=l.left,u.left.parent=u}else this.replace(l,l.left);else this.replace(l,l.right);return this._size--,!0}erase(l){var u=this.find(l);if(u){this.splay(u);var p=u.left,x=u.right,b=null;p&&(p.parent=null,b=this.maxNode(p),this.splay(b),this._root=b),x&&(p?b.right=x:this._root=x,x.parent=b),this._size--}}pop(){var l=this._root,u=null;if(l){for(;l.left;)l=l.left;u={key:l.key,data:l.data},this.remove(l.key)}return u}next(l){var u=l;if(u)if(u.right)for(u=u.right;u&&u.left;)u=u.left;else for(u=l.parent;u&&u.right===l;)l=u,u=u.parent;return u}prev(l){var u=l;if(u)if(u.left)for(u=u.left;u&&u.right;)u=u.right;else for(u=l.parent;u&&u.left===l;)l=u,u=u.parent;return u}forEach(l){for(var u=this._root,p=[],x=!1,b=0;!x;)u?(p.push(u),u=u.left):p.length>0?(l(u=p.pop(),b++),u=u.right):x=!0;return this}range(l,u,p,x){const b=[],T=this._compare;let k,P=this._root;for(;b.length!==0||P;)if(P)b.push(P),P=P.left;else{if(P=b.pop(),k=T(P.key,u),k>0)break;if(T(P.key,l)>=0&&p.call(x,P))return this;P=P.right}return this}keys(){for(var l=this._root,u=[],p=[],x=!1;!x;)l?(u.push(l),l=l.left):u.length>0?(l=u.pop(),p.push(l.key),l=l.right):x=!0;return p}values(){for(var l=this._root,u=[],p=[],x=!1;!x;)l?(u.push(l),l=l.left):u.length>0?(l=u.pop(),p.push(l.data),l=l.right):x=!0;return p}at(l){for(var u=this._root,p=[],x=!1,b=0;!x;)if(u)p.push(u),u=u.left;else if(p.length>0){if(u=p.pop(),b===l)return u;b++,u=u.right}else x=!0;return null}load(l=[],u=[],p=!1){if(this._size!==0)throw new Error("bulk-load: tree is not empty");const x=l.length;return p&&LB(l,u,0,x-1,this._compare),this._root=RB(null,l,u,0,x),this._size=x,this}min(){var l=this.minNode(this._root);return l?l.key:null}max(){var l=this.maxNode(this._root);return l?l.key:null}isEmpty(){return this._root===null}get size(){return this._size}static createTree(l,u,p,x,b){return new PB(p,b).load(l,u,x)}}function RB(h,l,u,p,x){const b=x-p;if(b>0){const T=p+Math.floor(b/2),k={key:l[T],data:u[T],parent:h};return k.left=RB(k,l,u,p,T),k.right=RB(k,l,u,T+1,x),k}return null}function LB(h,l,u,p,x){if(u>=p)return;const b=h[u+p>>1];let T=u-1,k=p+1;for(;;){do T++;while(x(h[T],b)<0);do k--;while(x(h[k],b)>0);if(T>=k)break;let P=h[T];h[T]=h[k],h[k]=P,P=l[T],l[T]=l[k],l[k]=P}LB(h,l,u,k,x),LB(h,l,k+1,p,x)}const GX=11102230246251565e-32,jc=134217729,KIe=(3+8*GX)*GX;function MB(h,l,u,p,x){let b,T,k,P,O=l[0],$=p[0],V=0,G=0;$>O==$>-O?(b=O,O=l[++V]):(b=$,$=p[++G]);let Y=0;if(VO==$>-O?(T=O+b,k=b-(T-O),O=l[++V]):(T=$+b,k=b-(T-$),$=p[++G]),b=T,k!==0&&(x[Y++]=k);VO==$>-O?(T=b+O,P=T-b,k=b-(T-P)+(O-P),O=l[++V]):(T=b+$,P=T-b,k=b-(T-P)+($-P),$=p[++G]),b=T,k!==0&&(x[Y++]=k);for(;V0:(p[0]-l[0])*(u[1]-l[1])-(u[0]-l[0])*(p[1]-l[1])>0}isAbove(l){return!this.isBelow(l)}isVertical(){return this.point[0]===this.otherEvent.point[0]}get inResult(){return this.resultTransition!==0}clone(){const l=new Ew(this.point,this.left,this.otherEvent,this.isSubject,this.type);return l.contourId=this.contourId,l.resultTransition=this.resultTransition,l.prevInResult=this.prevInResult,l.isExteriorRing=this.isExteriorRing,l.inOut=this.inOut,l.otherInOut=this.otherInOut,l}}function om(h,l){return h[0]===l[0]&&h[1]===l[1]}function DB(h,l,u){const p=function(x,b,T,k,P,O){const $=(b-O)*(T-P),V=(x-P)*(k-O),G=$-V;if($===0||V===0||$>0!=V>0)return G;const Y=Math.abs($+V);return Math.abs(G)>=33306690738754716e-32*Y?G:-function(X,te,se,ae,fe,ue,we){let Ae,Ie,We,ze,He,Ve,qe,bt,jt,It,Dt,Pt,Ht,_t,Rt,Bt,Yt,tr;const br=X-fe,ur=se-fe,cr=te-ue,rr=ae-ue;_t=br*rr,Ve=jc*br,qe=Ve-(Ve-br),bt=br-qe,Ve=jc*rr,jt=Ve-(Ve-rr),It=rr-jt,Rt=bt*It-(_t-qe*jt-bt*jt-qe*It),Bt=cr*ur,Ve=jc*cr,qe=Ve-(Ve-cr),bt=cr-qe,Ve=jc*ur,jt=Ve-(Ve-ur),It=ur-jt,Yt=bt*It-(Bt-qe*jt-bt*jt-qe*It),Dt=Rt-Yt,He=Rt-Dt,Tw[0]=Rt-(Dt+He)+(He-Yt),Pt=_t+Dt,He=Pt-_t,Ht=_t-(Pt-He)+(Dt-He),Dt=Ht-Bt,He=Ht-Dt,Tw[1]=Ht-(Dt+He)+(He-Bt),tr=Pt+Dt,He=tr-Pt,Tw[2]=Pt-(tr-He)+(Dt-He),Tw[3]=tr;let _r=function(Wn,mn){let es=mn[0];for(let jn=1;jn<4;jn++)es+=mn[jn];return es}(0,Tw),Pr=22204460492503146e-32*we;if(_r>=Pr||-_r>=Pr||(He=X-br,Ae=X-(br+He)+(He-fe),He=se-ur,We=se-(ur+He)+(He-fe),He=te-cr,Ie=te-(cr+He)+(He-ue),He=ae-rr,ze=ae-(rr+He)+(He-ue),Ae===0&&Ie===0&&We===0&&ze===0)||(Pr=11093356479670487e-47*we+KIe*Math.abs(_r),_r+=br*ze+rr*Ae-(cr*We+ur*Ie),_r>=Pr||-_r>=Pr))return _r;_t=Ae*rr,Ve=jc*Ae,qe=Ve-(Ve-Ae),bt=Ae-qe,Ve=jc*rr,jt=Ve-(Ve-rr),It=rr-jt,Rt=bt*It-(_t-qe*jt-bt*jt-qe*It),Bt=Ie*ur,Ve=jc*Ie,qe=Ve-(Ve-Ie),bt=Ie-qe,Ve=jc*ur,jt=Ve-(Ve-ur),It=ur-jt,Yt=bt*It-(Bt-qe*jt-bt*jt-qe*It),Dt=Rt-Yt,He=Rt-Dt,Qc[0]=Rt-(Dt+He)+(He-Yt),Pt=_t+Dt,He=Pt-_t,Ht=_t-(Pt-He)+(Dt-He),Dt=Ht-Bt,He=Ht-Dt,Qc[1]=Ht-(Dt+He)+(He-Bt),tr=Pt+Dt,He=tr-Pt,Qc[2]=Pt-(tr-He)+(Dt-He),Qc[3]=tr;const Wr=MB(4,Tw,4,Qc,HX);_t=br*ze,Ve=jc*br,qe=Ve-(Ve-br),bt=br-qe,Ve=jc*ze,jt=Ve-(Ve-ze),It=ze-jt,Rt=bt*It-(_t-qe*jt-bt*jt-qe*It),Bt=cr*We,Ve=jc*cr,qe=Ve-(Ve-cr),bt=cr-qe,Ve=jc*We,jt=Ve-(Ve-We),It=We-jt,Yt=bt*It-(Bt-qe*jt-bt*jt-qe*It),Dt=Rt-Yt,He=Rt-Dt,Qc[0]=Rt-(Dt+He)+(He-Yt),Pt=_t+Dt,He=Pt-_t,Ht=_t-(Pt-He)+(Dt-He),Dt=Ht-Bt,He=Ht-Dt,Qc[1]=Ht-(Dt+He)+(He-Bt),tr=Pt+Dt,He=tr-Pt,Qc[2]=Pt-(tr-He)+(Dt-He),Qc[3]=tr;const Mr=MB(Wr,HX,4,Qc,WX);_t=Ae*ze,Ve=jc*Ae,qe=Ve-(Ve-Ae),bt=Ae-qe,Ve=jc*ze,jt=Ve-(Ve-ze),It=ze-jt,Rt=bt*It-(_t-qe*jt-bt*jt-qe*It),Bt=Ie*We,Ve=jc*Ie,qe=Ve-(Ve-Ie),bt=Ie-qe,Ve=jc*We,jt=Ve-(Ve-We),It=We-jt,Yt=bt*It-(Bt-qe*jt-bt*jt-qe*It),Dt=Rt-Yt,He=Rt-Dt,Qc[0]=Rt-(Dt+He)+(He-Yt),Pt=_t+Dt,He=Pt-_t,Ht=_t-(Pt-He)+(Dt-He),Dt=Ht-Bt,He=Ht-Dt,Qc[1]=Ht-(Dt+He)+(He-Bt),tr=Pt+Dt,He=tr-Pt,Qc[2]=Pt-(tr-He)+(Dt-He),Qc[3]=tr;const fn=MB(Mr,WX,4,Qc,KX);return KX[fn-1]}(x,b,T,k,P,O,Y)}(h[0],h[1],l[0],l[1],u[0],u[1]);return p>0?-1:p<0?1:0}function Ty(h,l){const u=h.point,p=l.point;return u[0]>p[0]?1:u[0]p[1]?1:-1:function(x,b,T){return x.left!==b.left?x.left?1:-1:DB(T,x.otherEvent.point,b.otherEvent.point)!==0?x.isBelow(b.otherEvent.point)?-1:1:!x.isSubject&&b.isSubject?1:-1}(h,l,u)}function Ey(h,l,u){const p=new Ew(l,!1,h,h.isSubject),x=new Ew(l,!0,h.otherEvent,h.isSubject);return om(h.point,h.otherEvent.point)&&console.warn("what is that, a collapsed segment?",h),p.contourId=x.contourId=h.contourId,Ty(x,h.otherEvent)>0&&(h.otherEvent.left=!0,x.left=!1),h.otherEvent.otherEvent=x,h.otherEvent=p,u.push(x),u.push(p),u}function NP(h,l){return h[0]*l[1]-h[1]*l[0]}function OB(h,l){return h[0]*l[0]+h[1]*l[1]}function FB(h,l,u){const p=function(P,O,$,V){const G=[O[0]-P[0],O[1]-P[1]],Y=[V[0]-$[0],V[1]-$[1]];function X(We,ze,He){return[We[0]+ze*He[0],We[1]+ze*He[1]]}const te=[$[0]-P[0],$[1]-P[1]];let se=NP(G,Y),ae=se*se;const fe=OB(G,G);if(ae>0){const We=NP(te,Y)/se;if(We<0||We>1)return null;const ze=NP(te,G)/se;return ze<0||ze>1?null:We===0||We===1?[X(P,We,G)]:ze===0||ze===1?[X($,ze,Y)]:[X(P,We,G)]}if(se=NP(te,G),ae=se*se,ae>0)return null;const ue=OB(G,te)/fe,we=ue+OB(G,Y)/fe,Ae=Math.min(ue,we),Ie=Math.max(ue,we);return Ae<=1&&Ie>=0?Ae===1?[X(P,Ae>0?Ae:0,G)]:Ie===0?[X(P,Ie<1?Ie:1,G)]:[X(P,Ae>0?Ae:0,G),X(P,Ie<1?Ie:1,G)]:null}(h.point,h.otherEvent.point,l.point,l.otherEvent.point),x=p?p.length:0;if(x===0||x===1&&(om(h.point,l.point)||om(h.otherEvent.point,l.otherEvent.point))||x===2&&h.isSubject===l.isSubject)return 0;if(x===1)return!om(h.point,p[0])&&!om(h.otherEvent.point,p[0])&&Ey(h,p[0],u),!om(l.point,p[0])&&!om(l.otherEvent.point,p[0])&&Ey(l,p[0],u),1;const b=[];let T=!1,k=!1;return om(h.point,l.point)?T=!0:Ty(h,l)===1?b.push(l,h):b.push(h,l),om(h.otherEvent.point,l.otherEvent.point)?k=!0:Ty(h.otherEvent,l.otherEvent)===1?b.push(l.otherEvent,h.otherEvent):b.push(h.otherEvent,l.otherEvent),T&&k||T?(l.type=1,h.type=l.inOut===h.inOut?2:3,T&&!k&&Ey(b[1].otherEvent,b[0].point,u),2):k?(Ey(b[0],b[1].point,u),3):b[0]!==b[3].otherEvent?(Ey(b[0],b[1].point,u),Ey(b[1],b[2].point,u),3):(Ey(b[0],b[1].point,u),Ey(b[3].otherEvent,b[2].point,u),3)}function YIe(h,l){if(h===l)return 0;if(DB(h.point,h.otherEvent.point,l.point)!==0||DB(h.point,h.otherEvent.point,l.otherEvent.point)!==0)return om(h.point,l.point)?h.isBelow(l.otherEvent.point)?-1:1:h.point[0]===l.point[0]?h.point[1](l.contourId??0)?1:-1}return Ty(h,l)===1?1:-1}class ZIe{constructor(){this.points=[],this.holeIds=[],this.holeOf=null,this.depth=null}isExterior(){return this.holeOf==null}}function XIe(h,l,u,p){let x,b=h+1,T=l[h].point;const k=l.length;for(bp;)b--;return b}function QIe(h,l,u){const p=new ZIe;if(h.prevInResult!=null){const x=h.prevInResult,b=x.outputContourId;if(x.resultTransition>0){const T=l[b];if(T.holeOf!=null){const k=T.holeOf;l[k].holeIds.push(u),p.holeOf=k,p.depth=l[b].depth}else l[b].holeIds.push(u),p.holeOf=b,p.depth=l[b].depth+1}else p.holeOf=null,p.depth=l[b].depth}else p.holeOf=null,p.depth=0;return p}const ZX=Math.max,XX=Math.min;let CP=0;function QX(h,l,u,p,x,b){let T,k,P,O,$,V;for(T=0,k=h.length-1;T0?V.left=!0:$.left=!0;const G=P[0],Y=P[1];x[0]=XX(x[0],G),x[1]=XX(x[1],Y),x[2]=ZX(x[2],G),x[3]=ZX(x[3],Y),p.push($),p.push(V)}}const IP=[];function JX(h,l,u){let p=h,x=l;typeof h[0][0][0]=="number"&&(p=[h]),typeof l[0][0][0]=="number"&&(x=[l]);let b=function(G,Y,X){let te=null;return G.length*Y.length===0&&(X===0?te=IP:X===2?te=G:(X===1||X===3)&&(te=G.length===0?Y:G)),te}(p,x,u);if(b)return b===IP?null:b;const T=[1/0,1/0,-1/0,-1/0],k=[1/0,1/0,-1/0,-1/0],P=function(G,Y,X,te,se){const ae=new U0(void 0,Ty);let fe,ue,we,Ae,Ie,We;for(we=0,Ae=G.length;wete[2]||te[0]>X[2]||X[1]>te[3]||te[1]>X[3])&&(se===0?ae=IP:se===2?ae=G:(se===1||se===3)&&(ae=G.concat(Y))),ae}(p,x,T,k,u),b)return b===IP?null:b;const O=function(G,Y,X,te,se,ae){const fe=new PB(YIe),ue=[],we=Math.min(te[2],se[2]);let Ae,Ie,We;for(;G.length!==0;){let ze=G.pop();if(ue.push(ze),ae===0&&ze.point[0]>we||ae===2&&ze.point[0]>te[2])break;if(ze.left){Ie=Ae=fe.insert(ze),We=fe.minNode(),Ae=Ae!==We?fe.prev(Ae):null,Ie=fe.next(Ie);const He=Ae?Ae.key:null;let Ve;if(l2(ze,He,ae),Ie&&FB(ze,Ie.key,G)===2&&(l2(ze,He,ae),l2(Ie.key,ze,ae)),Ae&&FB(Ae.key,ze,G)===2){let qe=Ae;qe=qe!==We?fe.prev(qe):null,Ve=qe?qe.key:null,l2(He,Ve,ae),l2(ze,He,ae)}}else ze=ze.otherEvent,Ie=Ae=fe.find(ze),Ae&&Ie&&(Ae=Ae!==We?fe.prev(Ae):null,Ie=fe.next(Ie),fe.remove(ze),Ie&&Ae&&FB(Ae.key,Ie.key,G))}return ue}(P,0,0,T,k,u),$=function(G){let Y,X;const te=function(fe){let ue,we,Ae,Ie,We;const ze=[];for(we=0,Ae=fe.length;we{se[We]=!0,We=te.length)&&te[Ae];);ae.push(ue)}return ae}(O),V=[];for(let G=0;G<$.length;G++){let Y=$[G];if(Y.isExterior()){let X=[Y.points];for(let te=0;te{T.push(new Ft(V,P+(V-k)/(O-k)*($-P)))}:(T,k,P,O,$,V)=>{T.push(new Ft(k+(V-P)/($-P)*(O-k),V))};for(const T of h){const k=[];for(const P of T){if(P.length<=2)continue;const O=[];for(let G=0;Gl&&b(O,Y,X,te,se,l):ae>u?fe=l&&b(O,Y,X,te,se,l),fe>u&&ae<=u&&b(O,Y,X,te,se,u)}let $=P[P.length-1];const V=p===0?$.x:$.y;V>=l&&V<=u&&O.push($),O.length&&($=O[O.length-1],O[0].x===$.x&&O[0].y===$.y||O.push(O[0]),k.push(O))}k.length&&x.push(k)}return x}function JIe(h,l){const u=JX(BB(h),BB([l]),0);return u==null?[]:eQ(u)}function ePe(h,l,u=0){let x=BB(h,65536);const b=[];for(;l.valid();l.next()){const[T,k]=l.get();let P=T.x*65536,O=T.y*65536,$=k.x*65536,V=k.y*65536;const G=$-P,Y=V-O,X=Math.hypot(G,Y);if(X===0)continue;P-=G*u,O-=Y*u,$+=G*u,V+=Y*u;const te=Math.trunc(Y/X*3),se=-Math.trunc(G/X*3);b.push([[[P,O],[$,V],[$+te,V+se],[P+te,O+se],[P,O]]])}return b.length>0&&(x=JX(x,b,2)),eQ(x,1/65536,128)}function BB(h,l=1){return[h.map(u=>u.map(p=>[p.x*l,p.y*l]))]}function eQ(h,l=1,u){return h.map(p=>p.map((x,b)=>{const T=x.map(k=>{let P=k[0],O=k[1];return u&&(P=Math.round(P/u)*u,O=Math.round(O/u)*u),new Ft(P*l,O*l)._round()});return b>0&&T.reverse(),T}))}class $B{constructor(l,u){this.layoutVertexArray=new Sc,this.indexArray=new Pi,this.lineIndexArray=new Mu,this.triangleSegments=new Os,this.lineSegments=new Os,this.programConfigurations=new ie(l.layers,{zoom:l.zoom,lut:l.lut}),this.uploaded=!1,u&&(this.elevatedLayoutVertexArray=new Wc)}update(l,u,p,x,b,T,k,P){this.programConfigurations.updatePaintArrays(l,u,b,p,x,T,k,P)}isEmpty(){return this.layoutVertexArray.length===0}needsUpload(){return this.programConfigurations.needsUpload}upload(l){this.uploaded||(this.layoutVertexBuffer=l.createVertexBuffer(this.layoutVertexArray,PIe.members),this.indexBuffer=l.createIndexBuffer(this.indexArray),this.lineIndexBuffer=l.createIndexBuffer(this.lineIndexArray),this.elevatedLayoutVertexArray&&this.elevatedLayoutVertexArray.length>0&&(this.elevatedLayoutVertexBuffer=l.createVertexBuffer(this.elevatedLayoutVertexArray,RIe.members))),this.programConfigurations.upload(l),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.elevatedLayoutVertexBuffer&&this.elevatedLayoutVertexBuffer.destroy(),this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.lineIndexBuffer.destroy(),this.programConfigurations.destroy(),this.triangleSegments.destroy(),this.lineSegments.destroy())}populatePaintArrays(l,u,p,x,b,T,k){this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,l,u,p,x,b,T,void 0,k)}}class RP{constructor(l){this.zoom=l.zoom,this.pixelRatio=l.pixelRatio,this.overscaling=l.overscaling,this.layers=l.layers,this.layerIds=this.layers.map(u=>u.fqid),this.index=l.index,this.hasPattern=!1,this.patternFeatures=[],this.lut=l.lut,this.bufferData=new $B(l,!1),this.elevationBufferData=new $B(l,!0),this.stateDependentLayerIds=this.layers.filter(u=>u.isStateDependent()).map(u=>u.id),this.projection=l.projection,this.elevationMode=this.layers[0].layout.get("fill-elevation-reference"),this.sourceLayerIndex=l.sourceLayerIndex,this.worldview=l.worldview,this.hasAppearances=null}updateFootprints(l,u){}updateAppearances(l,u,p,x){return{hasLayoutChanges:!1,hasUboChanges:!1}}populate(l,u,p,x){this.hasPattern=CB("fill",this.layers,this.pixelRatio,u);const b=this.layers[0].layout.get("fill-sort-key"),T=[];for(const{feature:k,id:P,index:O,sourceLayerIndex:$}of l){const V=this.layers[0]._featureFilter.needGeometry,G=En(k,V);if(!this.layers[0]._featureFilter.filter(new fs(this.zoom,{worldview:this.worldview,activeFloors:u.activeFloors}),G,p))continue;const Y=b?b.evaluate(G,{},p,u.availableImages):void 0,X={id:P,properties:k.properties,type:k.type,sourceLayerIndex:$,index:O,geometry:V?G.geometry:Kr(k,p,x),patterns:{},sortKey:Y};T.push(X)}b&&T.sort((k,P)=>k.sortKey-P.sortKey);for(const k of T){const{geometry:P,index:O,sourceLayerIndex:$}=k;if(this.hasPattern){const V=IB("fill",this.layers,k,this.zoom,this.pixelRatio,u);this.patternFeatures.push(V)}else this.addFeature(k,P,O,p,{},u.availableImages,u.brightness,u.elevationFeatures);u.featureIndex.insert(l[O].feature,P,O,$,this.index)}}update(l,u,p,x,b,T,k){this.bufferData.update(l,u,p,x,b,T,k,this.worldview),this.elevationBufferData.update(l,u,p,x,b,T,k,this.worldview),this.elevatedStructures&&this.elevatedStructures.update(l,u,p,x,b,T,k,this.worldview)}addFeatures(l,u,p,x,b,T){for(const k of this.patternFeatures)this.addFeature(k,k.geometry,k.index,u,p,x,T,l.elevationFeatures)}isEmpty(){return this.bufferData.isEmpty()&&this.elevationBufferData.isEmpty()}uploadPending(){return!this.uploaded||this.bufferData.needsUpload()||this.elevationBufferData.needsUpload()}upload(l){this.bufferData.upload(l),this.elevationBufferData.upload(l),this.elevatedStructures&&this.elevatedStructures.upload(l)}destroy(){this.bufferData.destroy(),this.elevationBufferData.destroy(),this.elevatedStructures&&this.elevatedStructures.destroy()}addFeature(l,u,p,x,b,T=[],k,P){const O=a2(u,500);this.elevationMode!=="none"?this.addElevatedRoadFeature(l,O,x,p,P):this.addGeometry(O,this.bufferData),this.bufferData.populatePaintArrays(l,p,b,T,x,k,this.worldview),this.elevationBufferData.populatePaintArrays(l,p,b,T,x,k,this.worldview)}getUnevaluatedPortalGraph(){return this.elevatedStructures?this.elevatedStructures.unevaluatedPortals:void 0}setEvaluatedPortalGraph(l,u,p,x,b){this.elevatedStructures&&(this.elevatedStructures.construct(l),this.elevatedStructures.populatePaintArrays(u,p,x,b,this.worldview))}addElevatedRoadFeature(l,u,p,x,b){const T=new Array,k=Vs.getElevationFeature(l,b);if(!k)return void this.addGeometry(u,this.bufferData);{const O=this.clipPolygonsToTile(u,1);O.length>0&&T.push({polygons:O,elevationFeature:k,elevationTileID:p})}const P={guardRailEnabled:this.layers[0].layout.get("fill-construct-bridge-guard-rail").evaluate(l,{},p),featureIndex:x};for(const O of T)if(O.elevationFeature){if(this.elevationMode==="hd-road-base"){this.elevatedStructures||(this.elevatedStructures=new Xc(O.elevationTileID,this.layers,this.zoom,this.lut));const V=O.elevationFeature.isTunnel();let G=0;l.properties.hasOwnProperty(Bs)&&(G=+l.properties[Bs]),this.elevatedStructures.addPortalCandidates(O.elevationFeature.id,O.polygons,V,O.elevationFeature,G)}O.elevationFeature.constantHeight==null&&(O.polygons=this.prepareElevatedPolygons(O.polygons,O.elevationFeature,O.elevationTileID));const $=new Ys(p,O.elevationTileID);this.addElevatedGeometry(O.polygons,$,O.elevationFeature,this.elevationMode==="hd-road-base"?0:.05,x,P)}}addElevatedGeometry(l,u,p,x,b,T){const k={elevation:p,elevationSampler:u,bias:x,index:b,featureInfo:T},[P,O]=this.addGeometry(l,this.elevationBufferData,k);this.elevationBufferData.heightRange==null?this.elevationBufferData.heightRange={min:P,max:O}:(this.elevationBufferData.heightRange.min=Math.min(this.elevationBufferData.heightRange.min,P),this.elevationBufferData.heightRange.max=Math.max(this.elevationBufferData.heightRange.max,O))}addGeometry(l,u,p){let x=Number.POSITIVE_INFINITY,b=Number.NEGATIVE_INFINITY,T=null;p&&(T=p.elevationSampler.constantElevation(p.elevation,p.bias),T!=null&&(x=T,b=T));const k=(P,O,$)=>{if(p!=null)if(O.push(P),T!=null)u.elevatedLayoutVertexArray.emplaceBack(T),$.push(T);else{const V=p.elevationSampler.pointElevation(P,p.elevation,p.bias);u.elevatedLayoutVertexArray.emplaceBack(V),$.push(V),x=Math.min(x,V),b=Math.max(b,V)}};for(const P of l){let O=0;for(const ue of P)O+=ue.length;const $=u.triangleSegments.prepareSegment(O,u.layoutVertexArray,u.indexArray),V=$.vertexLength,G=[],Y=[],X=[],te=[],se=[],ae=u.layoutVertexArray.length;for(const ue of P){if(ue.length===0)continue;ue!==P[0]&&Y.push(G.length/2);const we=u.lineSegments.prepareSegment(ue.length,u.layoutVertexArray,u.lineIndexArray),Ae=we.vertexLength;p&&se.push(u.layoutVertexArray.length-ae),k(ue[0],X,te),u.layoutVertexArray.emplaceBack(ue[0].x,ue[0].y),u.lineIndexArray.emplaceBack(Ae+ue.length-1,Ae),G.push(ue[0].x),G.push(ue[0].y);for(let Ie=1;Ie0&&p&&this.elevationMode==="hd-road-base"){const ue=p.elevation.isTunnel(),we=p.elevation.safeArea,Ae=this.elevatedStructures.addVertices(X,te);this.elevatedStructures.addTriangles(fe,Ae,ue);const Ie=se.length;if(Ie>0){for(let We=0;We=p&&Y.max.x<=b&&Y.min.y>=x&&Y.max.y<=T?P:O).push(G)}if(P.length===l.length)return l;const $=[new Ft(p,x),new Ft(b,x),new Ft(b,T),new Ft(p,T),new Ft(p,x)],V=P;for(const G of O)V.push(...JIe(G,$));return V}}let tQ,rQ,nQ,sQ;Tr(RP,"FillBucket",{omit:["layers","patternFeatures"]}),Tr($B,"FillBufferData"),Tr(Xc,"ElevatedStructures");class LP{constructor(l,u,p,x){if(this.triangleCount=u.length/3,this.min=new Ft(0,0),this.max=new Ft(0,0),this.xScale=0,this.yScale=0,this.cellsX=0,this.cellsY=0,this.cells=[],this.payload=[],this.triangleCount===0||l.length===0)return;const[b,T]=[l[0].clone(),l[0].clone()];for(let V=1;VV.cellIdx-G.cellIdx||V.triIdx-G.triIdx);let $=0;for(;$this.max.x||this.min.x>l.x||l.y>this.max.y||this.min.y>l.y)return;const p=lm(l.x-this.min.x,this.xScale,this.cellsX),x=lm(l.y-this.min.y,this.yScale,this.cellsY),b=this.cells[x*this.cellsX+p];if(b){this._lazyInitLookup();for(let T=0;Tthis.max.x||this.min.x>u.x||l.y>this.max.y||this.min.y>u.y)return;this._lazyInitLookup();const x=lm(l.x-this.min.x,this.xScale,this.cellsX),b=lm(u.x-this.min.x,this.xScale,this.cellsX),T=lm(l.y-this.min.y,this.yScale,this.cellsY),k=lm(u.y-this.min.y,this.yScale,this.cellsY);for(let P=T;P<=k;P++)for(let O=x;O<=b;O++){const $=this.cells[P*this.cellsX+O];if($)for(let V=0;V<$.len;V++){const G=this.payload[$.start+V],Y=Math.floor(G/8),X=1<u.fqid),this.index=l.index,this.hasPattern=!1,this.stateDependentLayerIds=this.layers.filter(u=>u.isStateDependent()).map(u=>u.id),this.footprints=[],this.worldview=l.worldview,this.hasAppearances=null}updateFootprints(l,u){for(const p of this.footprints)u.push({footprint:p,id:l})}updateAppearances(l,u,p,x){return{hasLayoutChanges:!1,hasUboChanges:!1}}populate(l,u,p,x){const b=[];for(const{feature:T,id:k,index:P,sourceLayerIndex:O}of l){const $=this.layers[0]._featureFilter.needGeometry,V=En(T,$);if(!this.layers[0]._featureFilter.filter(new fs(this.zoom,{worldview:this.worldview,activeFloors:u.activeFloors}),V,p))continue;const G={id:k,properties:T.properties,type:T.type,sourceLayerIndex:O,index:P,geometry:$?V.geometry:Kr(T,p,x),patterns:{}};b.push(G)}for(const T of b){const{geometry:k,index:P,sourceLayerIndex:O}=T;this.addFeature(T,k,P,p,{},u.availableImages,u.brightness),u.featureIndex.insert(l[P].feature,k,P,O,this.index)}}isEmpty(){return this.footprints.length===0}uploadPending(){return!1}upload(l){}update(l,u,p,x,b,T,k){}destroy(){}addFeature(l,u,p,x,b,T=[],k){for(const P of a2(u,2)){const O=[],$=[],V=[],G=new Ft(1/0,1/0),Y=new Ft(-1/0,-1/0);for(const se of P)if(se.length!==0){se!==P[0]&&V.push($.length/2);for(let ae=0;ael.max.x||h.max.xl.max.y||h.max.ynew Ft((P.x+b.x*fr)*k-T.x*fr,(P.y+b.y*fr)*k-T.y*fr))}return UB(u,x,h.indices,0,h.indices.length,0,0)}function uQ(h,l,u,p){const x=Math.pow(2,p.z-u.z);return new Ft((h+u.x*fr)*x-p.x*fr,(l+u.y*fr)*x-p.y*fr)}function dQ(h,l){const u=[];l.grid.queryPoint(h,u);const p=l.indices,x=l.vertices;for(let b=0;b0&&(p.length>1&&u.push(p),p=[])}return p.length>1&&u.push(p),u}const qB=ln.types,dPe=["fill-extrusion-base","fill-extrusion-height","fill-extrusion-color","fill-extrusion-pattern","fill-extrusion-flood-light-wall-radius","fill-extrusion-line-width","fill-extrusion-emissive-strength"],hPe=["fill-extrusion-flood-light-ground-radius"],fPe=Math.pow(2,13),mPe=Math.pow(2,15)-1,FP=new Ft(0,1),Bp=2147483648,BP=1073741824;function u2(h,l,u,p,x,b,T,k){h.emplaceBack((l<<1)+T,(u<<1)+b,(Math.floor(p*fPe)<<1)+x,Math.round(k))}function d2(h,l,u){h.emplaceBack(l.x*fr,l.y*fr,u?1:0)}function $P(h,l,u,p,x,b){h.emplaceBack(l.x,l.y,(u.x<<1)+p,(u.y<<1)+x,b)}function h2(h,l,u){h.emplaceBack(l.x,l.y,l.z,u[0]*16384,u[1]*16384,u[2]*16384)}class fQ{constructor(){this.vertexOffset=0,this.vertexCount=0,this.indexOffset=0,this.indexCount=0}}class GB{constructor(){this.centroidXY=new Ft(0,0),this.vertexArrayOffset=0,this.vertexCount=0,this.groundVertexArrayOffset=0,this.groundVertexCount=0,this.flags=0,this.footprintSegIdx=-1,this.footprintSegLen=0,this.polygonSegIdx=-1,this.polygonSegLen=0,this.min=new Ft(Number.MAX_VALUE,Number.MAX_VALUE),this.max=new Ft(-Number.MAX_VALUE,-Number.MAX_VALUE),this.height=0,this.buildingId=0,this.groupCentroidPos=new Ft(0,0)}span(){return new Ft(this.max.x-this.min.x,this.max.y-this.min.y)}}class HB{constructor(){this.acc=new Ft(0,0),this.accCount=0,this.centroidDataIndex=0}startRing(l,u){l.min.x===Number.MAX_VALUE&&(l.min.x=l.max.x=u.x,l.min.y=l.max.y=u.y)}appendEdge(l,u,p){this.accCount++,this.acc._add(u);let x=!!this.borders;u.xl.max.x&&(l.max.x=u.x,x=!0),u.yl.max.y&&(l.max.y=u.y,x=!0),((u.x===0||u.x===fr)&&u.x===p.x)!=((u.y===0||u.y===fr)&&u.y===p.y)&&this.processBorderOverlap(u,p),x&&this.checkBorderIntersection(u,p)}checkBorderIntersection(l,u){u.x<0!=l.x<0&&this.addBorderIntersection(0,sn(u.y,l.y,(0-u.x)/(l.x-u.x))),u.x>fr!=l.x>fr&&this.addBorderIntersection(1,sn(u.y,l.y,(fr-u.x)/(l.x-u.x))),u.y<0!=l.y<0&&this.addBorderIntersection(2,sn(u.x,l.x,(0-u.y)/(l.y-u.y))),u.y>fr!=l.y>fr&&this.addBorderIntersection(3,sn(u.x,l.x,(fr-u.y)/(l.y-u.y)))}addBorderIntersection(l,u){this.borders||(this.borders=[[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE]]);const p=this.borders[l];up[1]&&(p[1]=u)}processBorderOverlap(l,u){if(l.x===u.x){if(l.y===u.y)return;const p=l.x===0?0:1;this.addBorderIntersection(p,u.y),this.addBorderIntersection(p,l.y)}else{const p=l.y===0?2:3;this.addBorderIntersection(p,u.x),this.addBorderIntersection(p,l.x)}}centroid(){return this.accCount===0?new Ft(0,0):new Ft(Math.floor(Math.max(0,this.acc.x)/this.accCount),Math.floor(Math.max(0,this.acc.y)/this.accCount))}intersectsCount(){return this.borders?this.borders.reduce((l,u)=>l+ +(u[0]!==Number.MAX_VALUE),0):0}}function mQ(h,l){const u=h.add(l)._unit(),p=pe(h.x*u.x+h.y*u.y,-1,1);var x,b,T;return T=Math.acos(p),Math.min(4,Math.max(-4,Math.tan(T)))/4*mPe*((x=h).x*(b=l).y-x.y*b.x<0?-1:1)}const pPe=[h=>h.x<0,h=>h.x>fr,h=>h.y<0,h=>h.y>fr];function gPe(h,l,u,p){const x=[4];if(p===0)return x;u._mult(p);const b=h.sub(u),T=l.sub(u),k=[h,l,b,T];for(let P=0;P<4;P++)for(const O of k)if(pPe[P](O)){x.push(P);break}return x}class WB{constructor(l){this.groundRadiusArray=null,this.groundRadiusBuffer=null,this.vertexArray=new Fj,this.indexArray=new Pi,this.programConfigurations=new ie(l.layers,{zoom:l.zoom,lut:l.lut},u=>hPe.includes(u)),this._segments=new Os,this.hiddenByLandmarkVertexArray=new yw,this._segmentToGroundQuads={},this._segmentToGroundQuads[0]=[],this._segmentToRegionTriCounts={},this._segmentToRegionTriCounts[0]=[0,0,0,0,0],this.regionSegments={},this.regionSegments[4]=new Os}getDefaultSegment(){return this.regionSegments[4]}hasData(){return this.vertexArray.length!==0}addData(l,u,p,x=!1){const b=l.length;if(b>2){let T=Math.max(0,this._segments.get().length-1);const k=this._segments._prepareSegment(4*b,this.vertexArray.length,2*this._segmentToGroundQuads[T].length);let P;T!==this._segments.get().length-1&&(T++,this._segmentToGroundQuads[T]=[],this._segmentToRegionTriCounts[T]=[0,0,0,0,0]);{const O=l[0],$=l[1];P=mQ(O.sub(l[b-1])._perp()._unit(),$.sub(O)._perp()._unit())}for(let O=0;Ox.region-b.region);for(let p=0;pP+O,0);let k=0;for(let P=0;P<=4;P++){const O=T[P];if(O!==0){let $=this.regionSegments[P];$||($=this.regionSegments[P]=new Os);const V={vertexOffset:b.vertexOffset,primitiveOffset:b.primitiveOffset+k,vertexLength:b.vertexLength,primitiveLength:O};$.get().push(V)}k+=O}for(let P=0;P0?this.hiddenByLandmarkVertexBuffer=l.createVertexBuffer(this.hiddenByLandmarkVertexArray,aPe.members,!0):this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.updateData(this.hiddenByLandmarkVertexArray),this._needsHiddenByLandmarkUpdate=!1)}destroy(){if(this.vertexBuffer){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.destroy(),this.groundRadiusBuffer&&this.groundRadiusBuffer.destroy(),this._segments&&this._segments.destroy(),this.programConfigurations.destroy();for(let l=0;l<=4;l++){const u=this.regionSegments[l];u&&u.destroy()}}}}class zP{constructor(l){this.zoom=l.zoom,this.canonical=l.canonical,this.overscaling=l.overscaling,this.layers=l.layers,this.pixelRatio=l.pixelRatio,this.layerIds=this.layers.map(u=>u.fqid),this.index=l.index,this.hasPattern=!1,this.edgeRadius=0,this.projection=l.projection,this.activeReplacements=[],this.replacementUpdateTime=0,this.centroidData=[],this.footprintIndices=new Pi,this.footprintVertices=new Sc,this.footprintSegments=[],this.layoutVertexArray=new Oj,this.centroidVertexArray=new vP,this.wallVertexArray=new Zj,this.indexArray=new Pi,this.programConfigurations=new ie(l.layers,{zoom:l.zoom,lut:l.lut},u=>dPe.includes(u)),this.segments=new Os,this.stateDependentLayerIds=this.layers.filter(u=>u.isStateDependent()).map(u=>u.id),this.groundEffect=new WB(l),this.maxHeight=0,this.partLookup={},this.triangleSubSegments=[],this.polygonSegments=[],this.buildingGroups=new Map,this.worldview=l.worldview,this.hasAppearances=null}updateFootprints(l,u){}updateAppearances(l,u,p,x){return{hasLayoutChanges:!1,hasUboChanges:!1}}populate(l,u,p,x){this.features=[],this.hasPattern=CB("fill-extrusion",this.layers,this.pixelRatio,u),this.featuresOnBorder=[],this.borderFeatureIndices=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.selfDEMTileTimestamp=Number.MAX_VALUE,this.borderDEMTileTimestamp=[Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE],this.tileToMeter=zt(p),this.edgeRadius=this.layers[0].layout.get("fill-extrusion-edge-radius")/this.tileToMeter,this.wallMode=this.layers[0].paint.get("fill-extrusion-line-width").constantOr(1)!==0;for(const{feature:b,id:T,index:k,sourceLayerIndex:P}of l){const O=this.layers[0]._featureFilter.needGeometry,$=En(b,O);if(!this.layers[0]._featureFilter.filter(new fs(this.zoom,{worldview:this.worldview,activeFloors:u.activeFloors}),$,p))continue;const V={id:T,sourceLayerIndex:P,index:k,geometry:O?$.geometry:Kr(b,p,x),properties:b.properties,type:b.type,patterns:{}},G=this.layoutVertexArray.length,Y=qB[V.type]==="Polygon";if(this.hasPattern)this.features.push({featureId:b.id,feature:IB("fill-extrusion",this.layers,V,this.zoom,this.pixelRatio,u)});else if(this.wallMode)for(const X of V.geometry)for(const te of hQ(X,Y))this.addFeature(b.id,V,[te],k,p,{},u.availableImages,x,u.brightness);else this.addFeature(b.id,V,V.geometry,k,p,{},u.availableImages,x,u.brightness);u.featureIndex.insert(b,V.geometry,k,P,this.index,G)}this._finalizeBuildingGroups(),this.sortBorders(),this.projection.name==="mercator"&&this.splitToSubtiles(),this.groundEffect.prepareBorderSegments(),this.polygonSegments.length=0}addFeatures(l,u,p,x,b,T){for(const{featureId:k,feature:P}of this.features){const O=qB[P.type]==="Polygon",{geometry:$}=P;if(this.wallMode)for(const V of $)for(const G of hQ(V,O))this.addFeature(k,P,[G],P.index,u,p,x,b,T);else this.addFeature(k,P,$,P.index,u,p,x,b,T)}this._finalizeBuildingGroups(),this.sortBorders(),this.projection.name==="mercator"&&this.splitToSubtiles()}update(l,u,p,x,b,T,k){this.programConfigurations.updatePaintArrays(l,u,b,p,x,T,k,this.worldview),this.groundEffect.update(l,u,b,p,x,T,k,this.worldview)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload||this.groundEffect.programConfigurations.needsUpload}upload(l){this.uploaded||(this.layoutVertexBuffer=l.createVertexBuffer(this.layoutVertexArray,lPe),this.indexBuffer=l.createIndexBuffer(this.indexArray),this.wallVertexBuffer=l.createVertexBuffer(this.wallVertexArray,iPe.members),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=l.createVertexBuffer(this.layoutVertexExtArray,oPe.members,!0)),this.groundEffect.upload(l)),this.groundEffect.uploadPaintProperties(l),this.programConfigurations.upload(l),this.uploaded=!0}uploadCentroid(l){this.groundEffect.uploadHiddenByLandmark(l),this.needsCentroidUpdate&&(!this.centroidVertexBuffer&&this.centroidVertexArray.length>0?this.centroidVertexBuffer=l.createVertexBuffer(this.centroidVertexArray,sPe.members,!0):this.centroidVertexBuffer&&this.centroidVertexBuffer.updateData(this.centroidVertexArray),this.needsCentroidUpdate=!1)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.centroidVertexBuffer&&this.centroidVertexBuffer.destroy(),this.layoutVertexExtBuffer&&this.layoutVertexExtBuffer.destroy(),this.groundEffect.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(l,u,p,x,b,T,k,P,O){const $=this.layers[0].paint.get("fill-extrusion-flood-light-ground-radius").evaluate(u,{})/this.tileToMeter,V=[new Ft(0,0),new Ft(fr,fr)],G=P.projection,Y=G.name==="globe",X=this.wallMode||qB[u.type]==="Polygon",te=new HB;te.centroidDataIndex=this.centroidData.length;const se=new GB;se.buildingId=l,u.properties&&u.properties.hasOwnProperty("building_id")&&(se.buildingId=Number(u.properties.building_id)),te.buildingId=se.buildingId;const ae=this.layers[0].paint.get("fill-extrusion-base").evaluate(u,{},b)<=0,fe=this.layers[0].paint.get("fill-extrusion-height").evaluate(u,{},b);let ue;if(se.height=fe,se.vertexArrayOffset=this.layoutVertexArray.length,se.groundVertexArrayOffset=this.groundEffect.vertexArray.length,Y&&!this.layoutVertexExtArray&&(this.layoutVertexExtArray=new dw),this.wallMode){if(Y)return void hr("Non zero fill-extrusion-line-width is not yet supported on globe.");if(p.length!==1)return;ue=function(Ve){const qe=Ve[0].x===Ve[Ve.length-1].x&&Ve[0].y===Ve[Ve.length-1].y;(function(cr){let rr=0;const _r=cr.length;for(let Pr=0;Pr<_r;Pr++)rr+=(cr[(Pr+1)%_r].x-cr[Pr].x)*(cr[(Pr+1)%_r].y+cr[Pr].y);return rr>=0})(Ve)||(Ve=Ve.reverse());const jt={geometry:[],joinNormals:[],indices:[]},It=[],Dt=[],Pt=[];let Ht=Ve.length;for(;Ht>=2&&Ve[Ht-1].equals(Ve[Ht-2]);)Ht--;if(Ht<(qe?3:2))return jt;let _t,Rt,Bt,Yt,tr,br=0;for(;br0;let Mr="miter";const fn=2;Mr==="miter"&&Pr>fn&&(Mr="bevel"),Mr==="bevel"&&(Pr>100&&(Mr="flipbevel"),Pr{const ms=new Ft(mn.x,mn.y),ns=new Ft(mn.x,mn.y);ms.x+=es.x*Ti,ms.y+=es.y*Ti,ns.x-=es.x*Math.max(jn,1),ns.y-=es.y*Math.max(jn,1),Pt.push(es),It.push(ms),Dt.push(ns)};if(Mr==="miter")rr._mult(Pr),Wn(_t,rr,0,0);else if(Mr==="flipbevel")rr=tr.mult(-1),Wn(_t,rr,0,0),Wn(_t,rr.mult(-1),0,0);else{const mn=-Math.sqrt(Pr*Pr-1),es=Wr?mn:0,jn=Wr?0:mn;Rt&&Wn(_t,Yt,es,jn),Bt&&Wn(_t,tr,es,jn)}}jt.geometry=[...It,...Dt.reverse(),It[0]],jt.joinNormals=[...Pt,...Pt.reverse(),Pt[Pt.length-1]];const ur=jt.geometry.length-1;for(let cr=0;crVe<(qe.length-1)/2||Ve===qe.length-1,Ae=this.wallMode?[p]:a2(p,500);for(let Ve=Ae.length-1;Ve>=0;Ve--){const qe=Ae[Ve];(qe.length===0||xPe(qe[0]))&&Ae.splice(Ve,1)}let Ie;if(Y)Ie=bQ(Ae,V,b);else{Ie=[];for(const Ve of Ae)Ie.push({polygon:Ve,bounds:V})}const We=X?this.edgeRadius:0,ze=We>0&&this.zoom<17,He=(Ve,qe)=>{if(Ve.length===0)return!1;const bt=Ve[Ve.length-1];return qe.x===bt.x&&qe.y===bt.y};for(const{polygon:Ve,bounds:qe}of Ie){let bt=0,jt=0;for(const Ht of Ve)X&&!Ht[0].equals(Ht[Ht.length-1])&&Ht.push(Ht[0]),jt+=X?Ht.length-1:Ht.length;const It=this.segments.prepareSegment((X?5:4)*jt,this.layoutVertexArray,this.indexArray);se.footprintSegIdx<0&&(se.footprintSegIdx=this.footprintSegments.length),se.polygonSegIdx<0&&(se.polygonSegIdx=this.polygonSegments.length);const Dt={triangleArrayOffset:this.indexArray.length,triangleCount:0,triangleSegIdx:this.segments.segments.length-1},Pt=new fQ;if(Pt.vertexOffset=this.footprintVertices.length,Pt.indexOffset=3*this.footprintIndices.length,Pt.ringIndices=[],X){const Ht=[],_t=[];bt=It.vertexLength;for(let Bt=0;Bt4&&xQ(_t[_t.length-2],_t[0],_t[1]),Bt=We?yPe(_t[_t.length-2],_t[0],_t[1],We):0;const Yt=[];let tr,br,ur;br=_t[1].sub(_t[0])._perp()._unit();let cr=!0;for(let rr=1,_r=0;rr<_t.length;rr++){let Pr=_t[rr-1],Wr=_t[rr];const Mr=_t[rr===_t.length-1?1:rr+1];if(te.appendEdge(se,Wr,Pr),KB(Wr,Pr,qe)){We&&(br=Mr.sub(Wr)._perp()._unit(),cr=!cr);continue}const fn=Wr.sub(Pr)._perp(),Wn=fn.x/(Math.abs(fn.x)+Math.abs(fn.y)),mn=fn.y>0?1:0,es=Pr.dist(Wr);if(_r+es>32768&&(_r=0),We){ur=Mr.sub(Wr)._perp()._unit();let ns=gQ(Pr,Wr,Mr,pQ(br,ur),We);isNaN(ns)&&(ns=0);const $s=Wr.sub(Pr)._unit();Pr=Pr.add($s.mult(Bt))._round(),Wr=Wr.add($s.mult(-ns))._round(),Bt=ns,br=ur,ae&&this.zoom>=17&&(He(Yt,Pr)||Yt.push(Pr),He(Yt,Wr)||Yt.push(Wr))}const jn=It.vertexLength,Ti=_t.length>4&&xQ(Pr,Wr,Mr);let ms=_Q(_r,Rt,cr);if(u2(this.layoutVertexArray,Pr.x,Pr.y,Wn,mn,0,0,ms),u2(this.layoutVertexArray,Pr.x,Pr.y,Wn,mn,0,1,ms),this.wallMode){const ns=we(rr-1,_t),$s=ue.joinNormals[rr-1];d2(this.wallVertexArray,$s,ns),d2(this.wallVertexArray,$s,ns)}if(_r+=es,ms=_Q(_r,Ti,!cr),Rt=Ti,u2(this.layoutVertexArray,Wr.x,Wr.y,Wn,mn,0,0,ms),u2(this.layoutVertexArray,Wr.x,Wr.y,Wn,mn,0,1,ms),this.wallMode){const ns=we(rr,_t),$s=ue.joinNormals[rr];d2(this.wallVertexArray,$s,ns),d2(this.wallVertexArray,$s,ns)}if(It.vertexLength+=4,this.indexArray.emplaceBack(jn+0,jn+1,jn+2),this.indexArray.emplaceBack(jn+1,jn+3,jn+2),It.primitiveLength+=2,We){const ns=bt+(rr===1?_t.length-2:rr-2),$s=rr===1?bt:ns+1;if(this.indexArray.emplaceBack(jn+1,ns,jn+3),this.indexArray.emplaceBack(ns,$s,jn+3),It.primitiveLength+=2,tr===void 0&&(tr=jn),!KB(Mr,_t[rr],qe)){const xi=rr===_t.length-1?tr:It.vertexLength;this.indexArray.emplaceBack(jn+2,jn+3,xi),this.indexArray.emplaceBack(jn+3,xi+1,xi),this.indexArray.emplaceBack(jn+3,$s,xi+1),It.primitiveLength+=3}cr=!cr}if(Y){const ns=this.layoutVertexExtArray,$s=G.projectTilePoint(Pr.x,Pr.y,b),xi=G.projectTilePoint(Wr.x,Wr.y,b),Ya=G.upVector(b,Pr.x,Pr.y),_i=G.upVector(b,Wr.x,Wr.y);h2(ns,$s,Ya),h2(ns,$s,Ya),h2(ns,xi,_i),h2(ns,xi,_i)}}X&&(bt+=_t.length-1),ae&&We&&this.zoom>=17&&(Yt.length!==0&&He(Yt,Yt[0])&&Yt.pop(),this.groundEffect.addData(Yt,qe,$,We>0))}this.footprintSegments.push(Pt),Dt.triangleCount=this.indexArray.length-Dt.triangleArrayOffset,this.polygonSegments.push(Dt),++se.footprintSegLen,++se.polygonSegLen}if(se.vertexCount=this.layoutVertexArray.length-se.vertexArrayOffset,se.groundVertexCount=this.groundEffect.vertexArray.length-se.groundVertexArrayOffset,se.vertexCount!==0){if(se.centroidXY=te.borders?FP:this.encodeCentroid(te,se),u.properties&&u.properties.hasOwnProperty("building_id")){const Ve=se.buildingId;let qe=this.buildingGroups.get(Ve);qe||(qe={accX:0,accY:0,accCount:0,mergedMin:new Ft(Number.MAX_VALUE,Number.MAX_VALUE),mergedMax:new Ft(-Number.MAX_VALUE,-Number.MAX_VALUE),partIndices:[]},this.buildingGroups.set(Ve,qe)),qe.accX+=te.acc.x,qe.accY+=te.acc.y,qe.accCount+=te.accCount,qe.mergedMin.x=Math.min(qe.mergedMin.x,se.min.x),qe.mergedMin.y=Math.min(qe.mergedMin.y,se.min.y),qe.mergedMax.x=Math.max(qe.mergedMax.x,se.max.x),qe.mergedMax.y=Math.max(qe.mergedMax.y,se.max.y),qe.partIndices.push(this.centroidData.length)}if(this.centroidData.push(se),te.borders){this.featuresOnBorder.push(te);const Ve=this.featuresOnBorder.length-1;for(let qe=0;qethis.featuresOnBorder[u].borders[l][0]-this.featuresOnBorder[p].borders[l][0])}splitToSubtiles(){const l=[];for(let k=0;kfr),$=2*O+(+(P.min.x+P.max.x>fr)^O);for(let V=0;Vk.triangleSegmentIdx===P.triangleSegmentIdx?k.subtile-P.subtile:k.triangleSegmentIdx-P.triangleSegmentIdx);let p=0,x=0,b=0;for(const k of l){if(k.triangleSegmentIdx!==p)break;b++}const T=l.length;for(;x!==l.length;){p=l[x].triangleSegmentIdx;let k=0,P=x,O=x;for(let $=P;$0&&this.triangleSubSegments.push({segment:Y,min:V,max:G}),P=O;for(let X=P;X[te[0]*(1-ae[0])+se[0]*ae[0],te[1]*(1-ae[1])+se[1]*ae[1]],Y=[],X=[];for(const te of this.triangleSubSegments){Y[0]=te.min.x/fr,Y[1]=te.min.y/fr,X[0]=te.max.x/fr,X[1]=te.max.y/fr;const se=G($,V,Y),ae=G($,V,X);if(new ys([se[0],se[1],b],[ae[0],ae[1],T]).intersectsPrecise(p)===0){O&&(x.segments.push(O),O=void 0);continue}const fe=te.segment;O&&O.vertexOffset!==fe.vertexOffset&&(x.segments.push(O),O=void 0),O?(O.vertexLength+=fe.vertexLength,O.primitiveLength+=fe.primitiveLength):O={vertexOffset:fe.vertexOffset,primitiveLength:fe.primitiveLength,vertexLength:fe.vertexLength,primitiveOffset:fe.primitiveOffset,sortKey:void 0,vaos:{}}}return O&&x.segments.push(O),x}encodeCentroid(l,u){const p=l.centroid(),x=u.span(),b=Math.min(7,Math.round(x.x*this.tileToMeter/10)),T=Math.min(6,Math.round(x.y*this.tileToMeter/10));return new Ft(pe(p.x,1,8191)<<3|b,pe(p.y,1,8191)<<3|T)}encodeBorderCentroid(l){if(!l.borders)return new Ft(0,0);const u=l.borders,p=Number.MAX_VALUE;if(u[0][0]!==p||u[1][0]!==p){const x=u[0][0]!==p?0:1;return new Ft(6|(u[0][0]!==p?0:65528),(u[x][0]+u[x][1])/2<<3|6)}{const x=u[2][0]!==p?2:3;return new Ft((u[x][0]+u[x][1])/2<<3|6,6|(u[2][0]!==p?0:65528))}}showCentroid(l){const u=this.centroidData[l.centroidDataIndex];if(u.flags&=Bp,u.groupCentroidPos.x!==0||u.groupCentroidPos.y!==0){const p=u.span(),x=Math.min(7,Math.round(p.x*this.tileToMeter/10)),b=Math.min(6,Math.round(p.y*this.tileToMeter/10));u.centroidXY=new Ft(pe(u.groupCentroidPos.x,1,8191)<<3|x,pe(u.groupCentroidPos.y,1,8191)<<3|b)}else u.centroidXY=new Ft(0,0);this.writeCentroidToBuffer(u)}writeCentroidToBuffer(l){this.groundEffect.updateHiddenByLandmark(l);const u=l.vertexArrayOffset,p=l.vertexCount+l.vertexArrayOffset,x=-1073741824&l.flags?FP:l.centroidXY,b=this.centroidVertexArray.geta_centroid_pos0(u);if(this.centroidVertexArray.geta_centroid_pos1(u)!==x.y||b!==x.x){for(let T=u;TP.max.x||P.min.x>T.max.x||T.min.y>P.max.y||P.min.y>T.max.y||T.footprint.buildingIds.has(P.buildingId)&&(P.flags|=T.clipMask!==OP.None?-1073741824:Bp);else for(const P of this.centroidData)if(!(P.flags&Bp||P.flags&BP||T.min.x>P.max.x||P.min.x>T.max.x||T.min.y>P.max.y||P.min.y>T.max.y))for(let O=0;Ou!=Y>u&&l<(this.footprintVertices.int16[2*($+T.vertexOffset)+0]-V)*(u-G)/(Y-G)+V&&(x=!x)}k=P}}return x}getHeightAtTileCoord(l,u){let p=Number.NEGATIVE_INFINITY,x=!0;const b=4*(l+fr)*fr+(u+fr);if(this.partLookup.hasOwnProperty(b)){const T=this.partLookup[b];return T?{height:T.height,hidden:!!(T.flags&Bp)}:void 0}for(const T of this.centroidData)l>T.max.x||T.min.x>l||u>T.max.y||T.min.y>u||T.height<=p||this.footprintContainsPoint(l,u,T)&&(p=T.height,this.partLookup[b]=T,x=!!(T.flags&Bp));if(p!==Number.NEGATIVE_INFINITY)return{height:p,hidden:x};this.partLookup[b]=void 0}}function pQ(h,l){const u=h.add(l)._unit();return h.x*u.x+h.y*u.y}function yPe(h,l,u,p){const x=l.sub(h)._perp()._unit(),b=u.sub(l)._perp()._unit();return gQ(h,l,u,pQ(x,b),p)}function gQ(h,l,u,p,x){const b=Math.sqrt(1-p*p);return Math.min(h.dist(l)/3,l.dist(u)/3,x*b/p)}function KB(h,l,u){return h.xu[1].x&&l.x>u[1].x||h.yu[1].y&&l.y>u[1].y}function yQ(h,l){return h.xl[1].x||h.yl[1].y}function xPe(h){return h.every(l=>l.x<=0)||h.every(l=>l.x>=fr)||h.every(l=>l.y<=0)||h.every(l=>l.y>=fr)}function xQ(h,l,u){if(h.x<0||h.x>=fr||l.x<0||l.x>=fr||u.x<0||u.x>=fr)return!1;const p=u.sub(l),x=p.perp(),b=h.sub(l);return(p.x*b.x+p.y*b.y)/Math.sqrt((p.x*p.x+p.y*p.y)*(b.x*b.x+b.y*b.y))>-.866&&x.x*b.x+x.y*b.y<0}function _Q(h,l,u){const p=l?2|h:-3&h;return u?1|p:-2&p}function vQ(){const h=Math.PI/32,l=Math.tan(h),u=Ge;return u*Math.sqrt(1+2*l*l)-u}function bQ(h,l,u){const p=1<{for(const ze of Ie)X.push({polygon:ze,bounds:We})},se=Math.ceil(Math.log2($)),ae=Math.ceil(Math.log2(V)),fe=se-ae,ue=[];for(let Ie=0;Ie0?0:1);for(let Ie=0;IeWe+1?Ae.push({polygons:It,bounds:Pt,depth:We+1}):te(It,Pt)}if(Dt.length){const Pt=[new Ft(ze===0?jt:He.x,ze===1?jt:He.y),Ve];ue.length>We+1?Ae.push({polygons:Dt,bounds:Pt,depth:We+1}):te(Dt,Pt)}}return X}(h,l,Math.ceil((b-x)/11.25),Math.ceil((T-k)/11.25),1,(P,O,$)=>{if(P===0)return .5*(O+$);{const V=vt((u.y+O/fr)/p);return(Ut(.5*(vt((u.y+$/fr)/p)+V))*p-u.y)*fr}})}function _Pe(h,l,u,p,x,b){const T=Math.pow(2,p.z-x.z);for(let k=0;k=P[T]&&(k=l,P=h),k[T]x&&EQ(k,P,T,x),k[T]b&&EQ(P,k,T,b)}}function UP(h,l,u,p,x,b){const T=[];for(let k=0;k=p&&X.x>=p||(Y.x>=p?Y=new Ft(p,Y.y+(p-Y.x)/(X.x-Y.x)*(X.y-Y.y))._round():X.x>=p&&(X=new Ft(p,Y.y+(p-Y.x)/(X.x-Y.x)*(X.y-Y.y))._round()),Y.y>=x&&X.y>=x||(Y.y>=x?Y=new Ft(Y.x+(x-Y.y)/(X.y-Y.y)*(X.x-Y.x),x)._round():X.y>=x&&(X=new Ft(Y.x+(x-Y.y)/(X.y-Y.y)*(X.x-Y.x),x)._round()),O&&Y.equals(O[O.length-1])||(O=[Y],T.push(O),b&&b.push({progress:{min:se+kQ(ae,fe,Y)*te,max:1},parentIndex:k,prevPoint:ae,nextPoint:fe})),O.push(X),b&&(b[b.length-1].progress.max=se+kQ(ae,fe,X)*te,b[b.length-1].nextPoint=fe)))))}if(b&&V>0)for(let G=$;GO.t-$.t);let T=0,k=0,P=[];for(p.push(P);T!==h.length;){if(k===b.length){for(;T!==h.length;)P.length!==0&&P[P.length-1].equals(h[T])||P.push(h[T]),T++;break}b[k].t<=T?(P.length!==0&&P[P.length-1].equals(b[k].point)||P.push(b[k].point),Math.trunc(b[k].t),k++):(P.length!==0&&P[P.length-1].equals(h[T])||P.push(h[T]),T++)}}function kQ(h,l,u){return h.x!==l.x?(u.x-h.x)/(l.x-h.x):h.y!==l.y?(u.y-h.y)/(l.y-h.y):0}function f2(h,l){return h.x*l.x+h.y*l.y}function AQ(h,l){if(h.length===1){let u=0;const p=l[u++];let x;for(;!x||p.equals(x);)if(x=l[u++],!x)return 1/0;for(;u{jt[0]=It,jt[1]=Dt,jt[2]=Pt,jt[3]=1},bt=vQ();Y>0&&(Y+=bt),X+=bt;for(const jt of G){const It=[],Dt=[];for(const Pt of jt){const Ht=Pt.x+te.x,_t=Pt.y+te.y,Rt=V.projection.projectTilePoint(Ht,_t,Ae),Bt=V.projection.upVector(Ae,Pt.x,Pt.y);let Yt=Y,tr=X;if(ae){const br=IQ(Ht,_t,Y,X,ae,fe,ue,we);Yt+=br.base,tr+=br.top}Y!==0?qe(He,Rt.x+Bt[0]*ze*Yt,Rt.y+Bt[1]*ze*Yt,Rt.z+Bt[2]*ze*Yt):qe(He,Rt.x,Rt.y,Rt.z),qe(Ve,Rt.x+Bt[0]*ze*tr,Rt.y+Bt[1]*ze*tr,Rt.z+Bt[2]*ze*tr),or(He,He,se),or(Ve,Ve,se),It.push(new w_(He[0],He[1],He[2])),Dt.push(new w_(Ve[0],Ve[1],Ve[2]))}Ie.push(It),We.push(Dt)}return[Ie,We]}(h,l,u,p,x,b,T,k,P,O,$):T?function(V,G,Y,X,te,se,ae,fe,ue){const we=[],Ae=[],Ie=[0,0,0,1];for(const We of V){const ze=[],He=[];for(const Ve of We){const qe=Ve.x+X.x,bt=Ve.y+X.y,jt=IQ(qe,bt,G,Y,se,ae,fe,ue);Ie[0]=qe,Ie[1]=bt,Ie[2]=jt.base,Ie[3]=1,Kt(Ie,Ie,te),Ie[3]=Math.max(Ie[3],1e-5);const It=new w_(Ie[0]/Ie[3],Ie[1]/Ie[3],Ie[2]/Ie[3]);Ie[0]=qe,Ie[1]=bt,Ie[2]=jt.top,Ie[3]=1,Kt(Ie,Ie,te),Ie[3]=Math.max(Ie[3],1e-5);const Dt=new w_(Ie[0]/Ie[3],Ie[1]/Ie[3],Ie[2]/Ie[3]);ze.push(It),He.push(Dt)}we.push(ze),Ae.push(He)}return[we,Ae]}(l,u,p,x,b,T,k,P,O):function(V,G,Y,X,te){const se=[],ae=[],fe=te[8]*G,ue=te[9]*G,we=te[10]*G,Ae=te[11]*G,Ie=te[8]*Y,We=te[9]*Y,ze=te[10]*Y,He=te[11]*Y;for(const Ve of V){const qe=[],bt=[];for(const jt of Ve){const It=jt.x+X.x,Dt=jt.y+X.y,Pt=te[0]*It+te[4]*Dt+te[12],Ht=te[1]*It+te[5]*Dt+te[13],_t=te[2]*It+te[6]*Dt+te[14],Rt=te[3]*It+te[7]*Dt+te[15],Bt=Pt+fe,Yt=Ht+ue,tr=_t+we,br=Math.max(Rt+Ae,1e-5),ur=Pt+Ie,cr=Ht+We,rr=_t+ze,_r=Math.max(Rt+He,1e-5);qe.push(new w_(Bt/br,Yt/br,tr/br)),bt.push(new w_(ur/_r,cr/_r,rr/_r))}se.push(qe),ae.push(bt)}return[se,ae]}(l,u,p,x,b)}function IQ(h,l,u,p,x,b,T,k){const P=T*x.getElevationAt(h,l,!0,!0),O=b[0]!==0,$=O?b[1]===0?T*(b[0]/7-450):T*function(V,G,Y){const X=Math.floor(G[0]/8),te=Math.floor(G[1]/8),se=10*(G[0]-8*X),ae=10*(G[1]-8*te),fe=V.getElevationAt(X,te,!0,!0),ue=V.getMeterToDEM(Y),we=Math.floor(.5*(se*ue-1)),Ae=Math.floor(.5*(ae*ue-1)),Ie=V.tileCoordToPixel(X,te),We=2*we+1,ze=2*Ae+1,He=function(Dt,Pt,Ht,_t,Rt){return[Dt.getElevationAtPixel(Pt,Ht,!0),Dt.getElevationAtPixel(Pt+Rt,Ht,!0),Dt.getElevationAtPixel(Pt,Ht+Rt,!0),Dt.getElevationAtPixel(Pt+_t,Ht+Rt,!0)]}(V,Ie.x-we,Ie.y-Ae,We,ze),Ve=Math.abs(He[0]-He[1]),qe=Math.abs(He[2]-He[3]),bt=Math.abs(He[0]-He[2])+Math.abs(He[1]-He[3]),jt=Math.min(.25,.5*ue*(Ve+qe)/We),It=Math.min(.25,.5*ue*bt/ze);return fe+Math.max(jt*se,It*ae)}(x,b,k):P;return{base:P+(u===0?-1:u),top:O?Math.max($+p,P+u+2):P+p}}const YB=4096;class bPe{constructor(l){this.module=l,this.memoryStack=this.module.malloc(YB),this.memoryStackNextFree=this.memoryStack}createIntArray(l){const u=this.memoryStackNextFree;return this.memoryStackNextFree+=l.length*Int32Array.BYTES_PER_ELEMENT,this.memoryStackNextFree-this.memoryStack>YB?-1:(new Int32Array(this.module.heap32.buffer,u,l.length).set(l),u)}createFloatArray(l){const u=this.memoryStackNextFree;return this.memoryStackNextFree+=l.length*Float32Array.BYTES_PER_ELEMENT,this.memoryStackNextFree-this.memoryStack>YB?-1:(new Float32Array(this.module.heapF32.buffer,u,l.length).set(l),u)}readStringBuffer(l){let u="";for(;this.module.heapU8[l]!==0;)u+=String.fromCharCode(this.module.heapU8[l]),++l;return u}setStyle(l){const u=l.normalScale;this.module.setStyle(u[0],u[1],u[2],l.tileToMeters)}setAOOptions(l,u){this.module.setAOOptions(l?1:0,u)}setMetricOptions(l,u){this.module.setMetricOptions(l?1:0,u)}setStructuralOptions(l){this.module.setStructuralOptions(l?1:0)}setFacadeOptions(l,u){this.module.setFacadeOptions(l,u?1:0)}setFauxFacadeOptions(l,u,p){this.module.setFauxFacadeOptions(l?1:0,u?1:0,p)}setFacadeClassifierOptions(l){this.module.setFacadeClassifierOptions(l)}generateMesh(l,u){this.memoryStackNextFree=this.memoryStack;for(const k of l){const P=this.createIntArray(k.ringIndices),O=this.createFloatArray(k.coordinates);if(P===-1||O===-1)return`building_gen: Out of stack memory: ${this.memoryStackNextFree-this.memoryStack}/4096`;this.module.addFeature(k.id,k.sourceId,k.minHeight,k.height,k.roofType,O,P,k.ringIndices.length-1)}for(const k of u){let P;P=k.entrances?JSON.parse(k.entrances):[];const O=this.createFloatArray(P),$=this.createFloatArray(k.coordinates);if(O===-1||$===-1)return`building_gen: Out of stack memory: ${this.memoryStackNextFree-this.memoryStack}/4096`;this.module.addFacade(k.sourceId,k.crossPerc,k.distanceToRoad,O,P.length,$,k.coordinates.length)}if(!this.module.generateMesh()){const k=this.module.getLastError();return this.readStringBuffer(k)}const p=this.module.getMeshCount(),x=new Array(p);for(let k=0;k>2)-3,se=Y[X++]>>2;if(X++,x.json=JSON.parse(zQ.decode(Y.subarray(X,X+se))),X+=se,X>>0,Math.ceil(1.2*we)),Ie=Math.ceil((Ae-we)/65536);try{return te.grow(Ie),se(),!0}catch{return!1}},b:ae}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(Y,fe):Y.then(ue=>ue.arrayBuffer()).then(ue=>WebAssembly.instantiate(ue,fe))).then(ue=>{const{Rb:we,Qb:Ae,P:Ie,T:We,X:ze,Ja:He,La:Ve,Qa:qe,Va:bt,Wa:jt,eb:It,jb:Dt,f:Pt,e:Ht,yb:_t,zb:Rt,Ab:Bt,Bb:Yt,Db:tr,Gb:br}=ue.instance.exports;te=Ht;const ur=(()=>{let cr=0,rr=0,_r=0,Pr=0;return Wr=>{_r&&(we(Pr),we(cr),rr+=_r,_r=cr=0),cr||(rr+=128,cr=Ae(rr));const Mr=Wr.length+7&-8;let fn=cr;Mr>=rr&&(_r=Mr,fn=Pr=Ae(Mr));for(let Wn=0;Wn{Yh=Y,m2=void 0}))}()),G&&$.push(function(){if(ZB)return;const Y=function(X){let te;const se=WebAssembly.instantiateStreaming(X,{}).then(ue=>{te=ue.instance,te.exports.__wasm_call_ctors()}),ae={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},fe={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return{ready:se,supported:!0,decodeGltfBuffer(ue,we,Ae,Ie,We,ze){(function(He,Ve,qe,bt,jt,It,Dt){const Pt=He.exports.sbrk,Ht=bt+3&-4,_t=Pt(Ht*jt),Rt=Pt(It.length),Bt=new Uint8Array(He.exports.memory.buffer);Bt.set(It,Rt);const Yt=Ve(_t,bt,jt,Rt,It.length);if(Yt===0&&Dt&&Dt(_t,Ht,jt),qe.set(Bt.subarray(_t,_t+bt*jt)),Pt(_t-Pt(0)),Yt!==0)throw new Error(`Malformed buffer data: ${Yt}`)})(te,te.exports[fe[We]],ue,we,Ae,Ie,te.exports[ae[ze]])}}}(fetch(Po()));return Y.ready.then(()=>{ZB=Y})}()),T)for(let Y=0;Y{const k=Yg(p,(P,O)=>{P?T(P):b(O)});x&&x.addEventListener("abort",()=>{k.cancel(),T(new DOMException("Aborted","AbortError"))},{once:!0})})}({url:h,type:"arrayBuffer"},l);return qQ(u,0,h,l)}function QB(h){switch(h){case WebGL2RenderingContext.RGBA8:case WebGL2RenderingContext.RGBA16F:return WebGL2RenderingContext.RGBA;case WebGL2RenderingContext.DEPTH_COMPONENT16:return WebGL2RenderingContext.DEPTH_COMPONENT;case WebGL2RenderingContext.DEPTH24_STENCIL8:return WebGL2RenderingContext.DEPTH_STENCIL;case WebGL2RenderingContext.R8:case WebGL2RenderingContext.R32F:return WebGL2RenderingContext.RED}}function JB(h){switch(h){case WebGL2RenderingContext.RGBA8:return WebGL2RenderingContext.UNSIGNED_BYTE;case WebGL2RenderingContext.RGBA16F:return WebGL2RenderingContext.HALF_FLOAT;case WebGL2RenderingContext.DEPTH_COMPONENT16:return WebGL2RenderingContext.UNSIGNED_SHORT;case WebGL2RenderingContext.DEPTH24_STENCIL8:return WebGL2RenderingContext.UNSIGNED_INT_24_8;case WebGL2RenderingContext.R8:return WebGL2RenderingContext.UNSIGNED_BYTE;case WebGL2RenderingContext.R32F:return WebGL2RenderingContext.FLOAT}}class cm{constructor(l,u,p,x){this.context=l,this.format=p,this.useMipmap=x&&x.useMipmap,this.texture=l.gl.createTexture(),this.update(u,{premultiply:x&&x.premultiply})}update(l,u){const p=l&&l instanceof HTMLVideoElement&&l.width===0?l.videoWidth:l.width,x=l&&l instanceof HTMLVideoElement&&l.height===0?l.videoHeight:l.height,{context:b}=this,{gl:T}=b,{x:k,y:P}=u&&u.position?u.position:{x:0,y:0},O=k+p,$=P+x;this.size&&(this.size[0]!==O||this.size[1]!==$)&&(!u||u.recreateWhenResize===void 0||u.recreateWhenResize)&&(T.bindTexture(T.TEXTURE_2D,null),T.deleteTexture(this.texture),this.texture=T.createTexture(),this.size=null),T.bindTexture(T.TEXTURE_2D,this.texture),b.pixelStoreUnpackFlipY.set(!1),b.pixelStoreUnpack.set(1),b.pixelStoreUnpackPremultiplyAlpha.set(this.format===T.RGBA8&&(!u||u.premultiply!==!1));const V=l instanceof HTMLImageElement||l instanceof HTMLCanvasElement||l instanceof HTMLVideoElement||l instanceof ImageData||ImageBitmap&&l instanceof ImageBitmap;if(!this.size&&O>0&&$>0){const G=this.useMipmap?Math.floor(Math.log2(Math.max(O,$)))+1:1;T.texStorage2D(T.TEXTURE_2D,G,this.format,O,$),this.size=[O,$]}this.size&&(V?T.texSubImage2D(T.TEXTURE_2D,0,k,P,QB(this.format),JB(this.format),l):"data"in l&&l.data&&T.texSubImage2D(T.TEXTURE_2D,0,k,P,p,x,QB(this.format),JB(this.format),l.data)),this.useMipmap&&T.generateMipmap(T.TEXTURE_2D)}bind(l,u,p=!1){const{context:x}=this,{gl:b}=x;b.bindTexture(b.TEXTURE_2D,this.texture),l!==this.minFilter&&(b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,l),b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,this.useMipmap&&!p?l===b.NEAREST?b.NEAREST_MIPMAP_NEAREST:b.LINEAR_MIPMAP_LINEAR:l),this.minFilter=l),u!==this.wrapS&&(b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,u),b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,u),this.wrapS=u)}bindExtraParam(l,u,p,x,b){const{context:T}=this,{gl:k}=T;k.bindTexture(k.TEXTURE_2D,this.texture),u!==this.magFilter&&(k.texParameteri(k.TEXTURE_2D,k.TEXTURE_MAG_FILTER,u),this.magFilter=u),l!==this.minFilter&&(k.texParameteri(k.TEXTURE_2D,k.TEXTURE_MIN_FILTER,this.useMipmap?l===k.NEAREST?k.NEAREST_MIPMAP_NEAREST:k.LINEAR_MIPMAP_LINEAR:l),this.minFilter=l),p!==this.wrapS&&(k.texParameteri(k.TEXTURE_2D,k.TEXTURE_WRAP_S,p),this.wrapS=p),x!==this.wrapT&&(k.texParameteri(k.TEXTURE_2D,k.TEXTURE_WRAP_T,x),this.wrapT=x),b!==this.compareMode&&(b?(k.texParameteri(k.TEXTURE_2D,k.TEXTURE_COMPARE_MODE,k.COMPARE_REF_TO_TEXTURE),k.texParameteri(k.TEXTURE_2D,k.TEXTURE_COMPARE_FUNC,b)):k.texParameteri(k.TEXTURE_2D,k.TEXTURE_COMPARE_MODE,k.NONE),this.compareMode=b)}destroy(){const{gl:l}=this.context;l.deleteTexture(this.texture),this.texture=null}}class g2{constructor(l,u){this.context=l,this.texture=u}bind(l,u){const{context:p}=this,{gl:x}=p;x.bindTexture(x.TEXTURE_2D,this.texture),l!==this.minFilter&&(x.texParameteri(x.TEXTURE_2D,x.TEXTURE_MAG_FILTER,l),x.texParameteri(x.TEXTURE_2D,x.TEXTURE_MIN_FILTER,l),this.minFilter=l),u!==this.wrapS&&(x.texParameteri(x.TEXTURE_2D,x.TEXTURE_WRAP_S,u),x.texParameteri(x.TEXTURE_2D,x.TEXTURE_WRAP_T,u),this.wrapS=u)}}const APe=On([{name:"a_pos_3f",components:3,type:"Float32"}]),NPe=On([{name:"a_color_3f",components:3,type:"Float32"}]),CPe=On([{name:"a_color_4f",components:4,type:"Float32"}]),IPe=On([{name:"a_uv_2f",components:2,type:"Float32"}]),PPe=On([{name:"a_normal_3f",components:3,type:"Float32"}]),RPe=On([{name:"a_normal_matrix0",components:4,type:"Float32"},{name:"a_normal_matrix1",components:4,type:"Float32"},{name:"a_normal_matrix2",components:4,type:"Float32"},{name:"a_normal_matrix3",components:4,type:"Float32"}]),LPe=On([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]);function HQ(h,l){const u=HP(h.projection,h.zoom,h.width,h.height),p=function(b,T,k,P,O){const $=new Je(k.lng-180*jy,k.lat),V=new Je(k.lng+180*jy,k.lat),G=b.project($.lng,$.lat),Y=b.project(V.lng,V.lat),X=-Math.atan2(Y.y-G.y,Y.x-G.x),te=Ir.fromLngLat(k);te.y=pe(te.y,-1+jy,1-jy);const se=te.toLngLat(),ae=b.project(se.lng,se.lat),fe=Ir.fromLngLat(se);fe.x+=jy;const ue=fe.toLngLat(),we=b.project(ue.lng,ue.lat),Ae=KQ(we.x-ae.x,we.y-ae.y,X),Ie=Ir.fromLngLat(se);Ie.y+=jy;const We=Ie.toLngLat(),ze=b.project(We.lng,We.lat),He=KQ(ze.x-ae.x,ze.y-ae.y,X),Ve=Math.abs(Ae.x)/Math.abs(He.y),qe=I([]);K(qe,qe,-X*(1-(O?0:P)));const bt=I([]);return U(bt,bt,[1,1-(1-Ve)*P,1]),bt[4]=-He.x/He.y*P,K(bt,bt,X),D(bt,qe,bt),bt}(h.projection,0,h.center,u,l),x=WQ(h);return U(p,p,[x,x,1]),p}function WQ(h){const l=h.projection,u=HP(h.projection,h.zoom,h.width,h.height),p=e$(l,h.center),x=e$(l,Je.convert(l.center));return Math.pow(2,p*u+(1-u)*x)}function HP(h,l,u,p,x=1/0){const b=h.range;if(!b)return 0;const T=Math.min(x,Math.max(u,p)),k=Math.log2(T/1024);return Fe(b[0]+k,b[1]+k,l)}const jy=1/4e4;function e$(h,l){const u=pe(l.lat,-85.051129,Nt),p=new Je(l.lng-180*jy,u),x=new Je(l.lng+180*jy,u),b=h.project(p.lng,u),T=h.project(x.lng,u),k=Ir.fromLngLat(p),P=Ir.fromLngLat(x),O=T.x-b.x,$=T.y-b.y,V=P.x-k.x,G=P.y-k.y,Y=Math.sqrt((V*V+G*G)/(O*O+$*$));return Math.log2(Y)}function KQ(h,l,u){const p=Math.cos(u),x=Math.sin(u);return{x:h*p-l*x,y:h*x+l*p}}function YQ(h,l,u){I(h),K(h,h,Xn(l[2])),q(h,h,Xn(l[0])),H(h,h,Xn(l[1])),U(h,h,u),D(h,h,[1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1])}function WP(h,l,u,p,x,b,T,k){const P=[u[0]-l[0],u[1]-l[1],0],O=[p[0]-l[0],p[1]-l[1],0];if(Le(P)<1e-12||Le(O)<1e-12)return pr(h);const $=Vt([],P,O);ft($,$),ke(O,p,l),P[2]=(b-x)*k,O[2]=(T-x)*k;const V=P;return Vt(V,P,O),ft(V,V),$i(h,$,V)}function KP(h,l,u=!1){const p=Op(l.zoom),x=function(b,T,k){const P=T.worldSize,O=[b[12],b[13],b[14]],$=vt(O[1]/P),V=st(O[0]/P),G=I([]),Y=ut(1,$)*P,X=ut(1,0)*P*Jt($,T.zoom),te=1/EB(P);let se=X*te;if(k){const we=HP(T.projection,T.zoom,T.width,T.height,1024);se=te*T.projection.pixelSpaceConversion(T.center.lat,P,we)}const ae=Be($,V);me(ae,ae,Ue([],ft([],ae),Y*se*O[2]));const fe=function(we){const Ae=[we[0],we[1],we[2]];let Ie=[0,1,0];const We=Vt([],Ie,Ae);return Vt(Ie,Ae,We),yt(Ie)===0&&(Ie=[0,1,0],Vt(We,Ae,Ie)),ft(We,We),ft(Ie,Ie),ft(Ae,Ae),[We[0],We[1],We[2],0,Ie[0],Ie[1],Ie[2],0,Ae[0],Ae[1],Ae[2],0,we[0],we[1],we[2],1]}(ae);U(G,G,[se,se,se*Y]),B(G,G,[-O[0],-O[1],-O[2]]);const ue=D([],T.globeMatrix,fe);return D(ue,ue,G),D(ue,ue,b),ue}(h,l,u);if(p>0){const b=function(T,k){const P=k.worldSize,O=ut(1,0)*P*Jt(k.center.lat,k.zoom)/EB(P),$=ut(1,k.center.lat)*P,V=I([]);H(V,V,Xn(k.center.lng)),q(V,V,Xn(k.center.lat)),B(V,V,[0,0,Me]),U(V,V,[O,O,O*$]);const G=k.point;return B(V,V,[-G.x,-G.y,0]),D(V,V,T),D(V,k.globeMatrix,V)}(h,l);return function(T,k,P){const O=(X,te,se)=>{const ae=Le(X),fe=Le(te),ue=Dp(X,te,se);return Ue(ue,ue,1/Le(ue)*sn(ae,fe,se))},$=O([T[0],T[1],T[2]],[k[0],k[1],k[2]],P),V=O([T[4],T[5],T[6]],[k[4],k[5],k[6]],P),G=O([T[8],T[9],T[10]],[k[8],k[9],k[10]],P),Y=Dp([T[12],T[13],T[14]],[k[12],k[13],k[14]],P);return[$[0],$[1],$[2],0,V[0],V[1],V[2],0,G[0],G[1],G[2],0,Y[0],Y[1],Y[2],1]}(x,b,p)}return x}function t$(h,l,u,p){const x=ys.projectAabbCorners(p,u);let b=Number.MAX_VALUE;for(let k=0;k0||se===0&&X[0]*te[0]+X[1]*te[1]>=0&&X[0]*X[0]+X[1]*X[1]>te[0]*te[0]+te[1]*te[1])&&($=Y)}V=$}while(V!==O);return P.length>0&&P.push(P[0]),P}(x);if(Vi(h,T))return b}const S_=64,kw={CoordinateSpaceTile:1,HasMapboxMeshFeatures:4,HasMeshoptCompression:8};function YP(h,l,u,p,x,b,T,k,P,O=!1){const $=u.zoom,V=u.project(p),G=Jt(p.lat,$),Y=1/G;I(h),B(h,h,[V.x+T[0]*Y,V.y+T[1]*Y,T[2]]);let X=1,te=1;const se=u.worldSize;if(O){if(u.projection.name==="mercator"){let we=0;u.elevation&&(we=u.elevation.getAtPointOrZero(new Ir(V.x/se,V.y/se),0));const Ae=Kt([],[V.x,V.y,we,1],u.projMatrix)[3]/u.cameraToCenterDistance;X=Ae,te=Ae*Jt(u.center.lat,$)}else if(u.projection.name==="globe"){const we=KP(h,u),Ae=[0,0,0,1];Kt(Ae,Ae,D([],u.projMatrix,we));const Ie=Ae[3]/u.cameraToCenterDistance,We=Op($),ze=u.projection.pixelsPerMeter(p.lat,se)*Jt(p.lat,$),He=u.projection.pixelsPerMeter(u.center.lat,se)*Jt(u.center.lat,$);X=Ie/sn(ze,lr(u.center.lat),We),te=Ie*G/ze,X*=He,te*=He}}else X=Y;U(h,h,[X,X,te]);const ae=[...h],fe=l.orientation,ue=[];if(YQ(ue,[fe[0]+(x?x[0]:0),fe[1]+(x?x[1]:0),fe[2]+(x?x[2]:0)],b),D(h,ae,ue),k&&u.elevation){let we=0;const Ae=[];if(P&&u.elevation){we=function(We,ze,He,Ve,qe){const bt=ze.elevation;if(!bt)return 0;const jt=ys.projectAabbCorners(He,Ve),It=ut(1,qe.lat)*ze.worldSize,Dt=function(rr,_r){const Pr=[0,0,1],Wr=[{corners:[0,1,3,2],dotProductWithUp:0},{corners:[1,5,2,6],dotProductWithUp:0},{corners:[0,4,1,5],dotProductWithUp:0},{corners:[2,6,3,7],dotProductWithUp:0},{corners:[4,7,5,6],dotProductWithUp:0},{corners:[0,3,4,7],dotProductWithUp:0}];for(const Mr of Wr){const fn=rr[Mr.corners[0]],Wn=rr[Mr.corners[1]],mn=rr[Mr.corners[2]],es=[Wn[0]-fn[0],Wn[1]-fn[1],_r*(Wn[2]-fn[2])],jn=Vt(es,es,[mn[0]-fn[0],mn[1]-fn[1],_r*(mn[2]-fn[2])]);ft(jn,jn),Mr.dotProductWithUp=kt(jn,Pr)}return Wr.sort((Mr,fn)=>Mr.dotProductWithUp-fn.dotProductWithUp),Wr[0].corners}(jt,It),Pt=jt[Dt[0]],Ht=jt[Dt[1]],_t=jt[Dt[2]],Rt=jt[Dt[3]],Bt=bt.getAtPointOrZero(new Ir(Pt[0]/ze.worldSize,Pt[1]/ze.worldSize),0),Yt=bt.getAtPointOrZero(new Ir(Ht[0]/ze.worldSize,Ht[1]/ze.worldSize),0),tr=bt.getAtPointOrZero(new Ir(_t[0]/ze.worldSize,_t[1]/ze.worldSize),0),br=bt.getAtPointOrZero(new Ir(Rt[0]/ze.worldSize,Rt[1]/ze.worldSize),0),ur=(Bt+br)/2,cr=(Yt+tr)/2;return ur>cr?Yt=l.gl.NEAREST_MIPMAP_NEAREST}),h.uploaded=!0,h.image=null)}function MPe(h,l,u){h.indexBuffer=l.createIndexBuffer(h.indexArray,!1,!0),h.vertexBuffer=l.createVertexBuffer(h.vertexArray,APe.members,!1,!0),h.normalArray&&(h.normalBuffer=l.createVertexBuffer(h.normalArray,PPe.members,!1,!0)),h.texcoordArray&&(h.texcoordBuffer=l.createVertexBuffer(h.texcoordArray,IPe.members,!1,!0)),h.colorArray&&(h.colorBuffer=l.createVertexBuffer(h.colorArray,(h.colorArray.bytesPerElement===12?NPe:CPe).members,!1,!0)),h.featureArray&&(h.pbrBuffer=l.createVertexBuffer(h.featureArray,LPe.members,!0)),h.segments=Os.simpleSegment(0,0,h.vertexArray.length,h.indexArray.length);const p=h.material;p.pbrMetallicRoughness.baseColorTexture&&y2(p.pbrMetallicRoughness.baseColorTexture,l),p.pbrMetallicRoughness.metallicRoughnessTexture&&y2(p.pbrMetallicRoughness.metallicRoughnessTexture,l),p.normalTexture&&y2(p.normalTexture,l),p.occlusionTexture&&y2(p.occlusionTexture,l,u),p.emissionTexture&&y2(p.emissionTexture,l)}function r$(h,l,u){if(h.meshes)for(const p of h.meshes)MPe(p,l,u);if(h.children)for(const p of h.children)r$(p,l,u)}function ZP(h){if(h.meshes)for(const l of h.meshes)l.indexArray.destroy(),l.vertexArray.destroy(),l.colorArray&&l.colorArray.destroy(),l.normalArray&&l.normalArray.destroy(),l.texcoordArray&&l.texcoordArray.destroy(),l.featureArray&&l.featureArray.destroy();if(h.children)for(const l of h.children)ZP(l)}function DPe(h){h.pbrMetallicRoughness.baseColorTexture&&h.pbrMetallicRoughness.baseColorTexture.gfxTexture&&h.pbrMetallicRoughness.baseColorTexture.gfxTexture.destroy(),h.pbrMetallicRoughness.metallicRoughnessTexture&&h.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture&&h.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture.destroy(),h.normalTexture&&h.normalTexture.gfxTexture&&h.normalTexture.gfxTexture.destroy(),h.emissionTexture&&h.emissionTexture.gfxTexture&&h.emissionTexture.gfxTexture.destroy(),h.occlusionTexture&&h.occlusionTexture.gfxTexture&&h.occlusionTexture.gfxTexture.destroy()}function n$(h){if(h.meshes)for(const l of h.meshes)l.vertexBuffer&&(l.vertexBuffer.destroy(),l.indexBuffer.destroy(),l.normalBuffer&&l.normalBuffer.destroy(),l.texcoordBuffer&&l.texcoordBuffer.destroy(),l.colorBuffer&&l.colorBuffer.destroy(),l.pbrBuffer&&l.pbrBuffer.destroy(),l.segments.destroy(),l.material&&DPe(l.material));if(h.footprintDebugMesh&&(h.footprintDebugMesh.vertexBuffer.destroy(),h.footprintDebugMesh.indexBuffer.destroy(),h.footprintDebugMesh.segments.destroy()),h.children)for(const l of h.children)n$(l)}function T_(h,l){const u=h.json.bufferViews[l.bufferView],p=qP[l.componentType];return new p(h.buffers[u.buffer],(l.byteOffset||0)+(u.byteOffset||0),l.count*(u.byteStride&&u.byteStride!==p2[l.type]*p.BYTES_PER_ELEMENT?u.byteStride/p.BYTES_PER_ELEMENT:p2[l.type]))}function s$(h,l,u,p){const x=qP[l.componentType],b=function($){switch($){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:return 1}}(x),T=h.json.bufferViews[l.bufferView],k=T.byteStride?T.byteStride/x.BYTES_PER_ELEMENT:p2[l.type],P=u.float32,O=P.length/u.capacity;for(let $=0,V=0;$0){for(let se=0;se0){b.texcoordArray=new Pp;const G=l.json.accessors[x.TEXCOORD_0];b.texcoordArray.resize(G.count);const Y=T_(l,G);s$(l,G,b.texcoordArray,Y)}if(x._FEATURE_ID_RGBA4444!==void 0){const G=l.json.accessors[x._FEATURE_ID_RGBA4444];l.json.extensionsUsed&&l.json.extensionsUsed.includes("EXT_meshopt_compression")&&(b.featureData=T_(l,G))}x._FEATURE_RGBA4444!==void 0&&(b.featureData=new Uint32Array(T_(l,l.json.accessors[x._FEATURE_RGBA4444]).buffer));const V=h.material;return b.material=function(G,Y){const{emissiveFactor:X=[0,0,0],alphaMode:te="OPAQUE",alphaCutoff:se=.5,normalTexture:ae,occlusionTexture:fe,emissiveTexture:ue,doubleSided:we,name:Ae}=G,{baseColorFactor:Ie=[1,1,1,1],metallicFactor:We=1,roughnessFactor:ze=1,baseColorTexture:He,metallicRoughnessTexture:Ve}=G.pbrMetallicRoughness||{},qe=fe?Y[fe.index]:void 0;if(fe&&fe.extensions&&fe.extensions.KHR_texture_transform&&qe){const bt=fe.extensions.KHR_texture_transform;qe.offsetScale=[bt.offset[0],bt.offset[1],bt.scale[0],bt.scale[1]]}return{name:Ae,pbrMetallicRoughness:{baseColorFactor:new as(...Ie),metallicFactor:We,roughnessFactor:ze,baseColorTexture:He?Y[He.index]:void 0,metallicRoughnessTexture:Ve?Y[Ve.index]:void 0},doubleSided:we,emissiveFactor:new as(...X),alphaMode:te,alphaCutoff:se,normalTexture:ae?Y[ae.index]:void 0,occlusionTexture:qe,emissionTexture:ue?Y[ue.index]:void 0,defined:G.defined===void 0}}(V!==void 0?l.json.materials[V]:{defined:!1},u),b}function XQ(h,l,u){const{matrix:p,rotation:x,translation:b,scale:T,mesh:k,extras:P,children:O,name:$}=h,V={};if(V.name=$,V.localMatrix=p||function(G,Y,X,te){var se=Y[0],ae=Y[1],fe=Y[2],ue=Y[3],we=se+se,Ae=ae+ae,Ie=fe+fe,We=se*we,ze=se*Ae,He=se*Ie,Ve=ae*Ae,qe=ae*Ie,bt=fe*Ie,jt=ue*we,It=ue*Ae,Dt=ue*Ie,Pt=te[0],Ht=te[1],_t=te[2];return G[0]=(1-(Ve+bt))*Pt,G[1]=(ze+Dt)*Pt,G[2]=(He-It)*Pt,G[3]=0,G[4]=(ze-Dt)*Ht,G[5]=(1-(We+bt))*Ht,G[6]=(qe+jt)*Ht,G[7]=0,G[8]=(He+It)*_t,G[9]=(qe-jt)*_t,G[10]=(1-(We+Ve))*_t,G[11]=0,G[12]=X[0],G[13]=X[1],G[14]=X[2],G[15]=1,G}([],x||[0,0,0,1],b||[0,0,0],T||[1,1,1]),V.globalMatrix=C(V.localMatrix),k!==void 0){V.meshes=u[k];const G=V.anchor=[0,0];for(const Y of V.meshes){const{min:X,max:te}=Y.aabb;G[0]+=X[0]+te[0],G[1]+=X[1]+te[1]}G[0]=Math.floor(G[0]/V.meshes.length/2),G[1]=Math.floor(G[1]/V.meshes.length/2)}if(P&&(P.id&&(V.id=P.id),P.lights&&(V.lights=function(G){if(!G.length)return[];const Y=function(fe){const ue=atob(fe),we=new Uint8Array(ue.length);for(let Ae=0;Ae1&&p[p.length-1].equals(p[0])&&p.pop();let x=0;for(let T=0;T0&&p.reverse();const b=ww(p.flatMap(T=>[T.x,T.y]),[]);return b.length===0?null:{vertices:p,indices:b}}function $Pe(h,l){const u=[],p=[];let x=0;const b=[];for(const T of h){x=u.length;const k=T.vertexArray.float32,P=T.indexArray.uint16;for(let O=0;O0&&([p[T+1],p[T+2]]=[p[T+2],p[T+1]])}return{vertices:u,indices:p}}function i$(h){const l=function(P,O){const $=[],V=WebGL2RenderingContext;if(P.json.textures)for(const G of P.json.textures){const Y={magFilter:V.LINEAR,minFilter:V.NEAREST,wrapS:V.REPEAT,wrapT:V.REPEAT};G.sampler!==void 0&&Object.assign(Y,P.json.samplers[G.sampler]),$.push({image:O[G.source],sampler:Y,uploaded:!1})}return $}(h,h.images),u=function(P,O){const $=[];for(const V of P.json.meshes){const G=[];for(const Y of V.primitives)G.push(OPe(Y,P,O));$.push(G)}return $}(h,l),{scenes:p,scene:x,nodes:b}=h.json,T=p?p[x||0].nodes:[...b.keys()],k=[];for(const P of T)k.push(XQ(b[P],h,u));return function(P,O,$){const V={},G=new Set;for(let Y=0;Y0){const Y=Array.from(G.values()).sort((X,te)=>X-te);for(let X=Y.length-1;X>=0;X--)P.splice(Y[X],1)}}(k,T,h.json.nodes),k}function zPe(h){h.heightmap=new Float32Array(4096),h.heightmap.fill(-1);const l=h.vertexArray.float32,u=h.aabb.min[0]-1,p=h.aabb.min[1]-1,x=S_/(h.aabb.max[0]-u+2),b=S_/(h.aabb.max[1]-p+2);for(let T=0;Th.heightmap[O*S_+P]&&(h.heightmap[O*S_+P]=k)}}function QQ(h,l,u,p,x){u.reserve(u.length+4*h.length),p.reserve(p.length+10*h.length),x.reserve(x.length+10*h.length);let b=p.length;for(const T of h){const k=Math.min(10,Math.max(4,1.3*T.height))*l,P=[-T.normal[1],T.normal[0],0],O=Math.min(.29,.1*T.width/T.depth),$=T.width-2*T.depth*l*(O+.01),V=Ze([],T.pos,P,$/2),G=Ze([],T.pos,P,-$/2),Y=[V[0],V[1],V[2]+T.height],X=[G[0],G[1],G[2]+T.height],te=Ze([],T.normal,P,O);Ue(te,te,k);const se=Ze([],T.normal,P,-O);Ue(se,se,k),me(te,V,te),me(se,G,se),V[2]+=.1,G[2]+=.1,p.emplaceBack(te[0],te[1],te[2]),p.emplaceBack(se[0],se[1],se[2]),p.emplaceBack(V[0],V[1],V[2]),p.emplaceBack(G[0],G[1],G[2]),p.emplaceBack(Y[0],Y[1],Y[2]),p.emplaceBack(X[0],X[1],X[2]),p.emplaceBack(V[0],V[1],V[2]),p.emplaceBack(G[0],G[1],G[2]),p.emplaceBack(te[0],te[1],te[2]),p.emplaceBack(se[0],se[1],se[2]);const ae=$/k/2;x.emplaceBack(-ae-O,-1,ae,.8),x.emplaceBack(ae+O,-1,ae,.8),x.emplaceBack(-ae,0,ae,1.3),x.emplaceBack(ae,0,ae,1.3),x.emplaceBack(ae+O,-.8,ae,.7),x.emplaceBack(ae+O,-.8,ae,.7),x.emplaceBack(0,0,ae,1.3),x.emplaceBack(0,0,ae,1.3),x.emplaceBack(ae+O,-1.2,ae,.8),x.emplaceBack(ae+O,-1.2,ae,.8),u.emplaceBack(6+b,4+b,8+b),u.emplaceBack(7+b,9+b,5+b),u.emplaceBack(0+b,1+b,2+b),u.emplaceBack(1+b,3+b,2+b),b+=10}}function UPe(h,l){const u={};u.indexArray=new Pi,u.vertexArray=new Lu,u.colorArray=new Wh,QQ(h,l,u.indexArray,u.vertexArray,u.colorArray);const p={defined:!0};p.emissiveFactor=as.black;const x={};return x.baseColorFactor=as.white,p.pbrMetallicRoughness=x,u.material=p,u.aabb=new ys([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),u}const JQ=On([{name:"a_pos_3f",components:3,type:"Float32"}]),VPe=On([{name:"a_normal_3",components:3,type:"Int16"}]),qPe=On([{name:"a_centroid_3",components:3,type:"Int16"}]),eJ=On([{name:"a_part_color_emissive",components:2,type:"Uint16"}]),GPe=On([{name:"a_faux_facade_color_emissive",components:2,type:"Uint16"}]),HPe=On([{name:"a_faux_facade_data",components:4,type:"Uint16"}]),WPe=On([{name:"a_faux_facade_vertical_range",components:2,type:"Uint16"}]),KPe=On([{name:"a_bloom_attenuation",components:4,type:"Float32"}]),YPe=On([{name:"a_flood_light_wall_radius_1i16",components:1,type:"Int16"}]),tJ=ln.types,XP=32767;function ZPe(h,l){const u=fr+l;for(const p of h)for(const x of p)if(x.x<-l||x.x>u||x.y<-l||x.y>u)return!1;return!0}function XPe(h){switch(h){case"flat":return 3;case"hipped":return 1;case"gabled":return 2;case"parapet":return 0;case"mansard":return 4;case"skillion":return 5;case"pyramidal":return 6;default:throw new Error(`Unknown roof shape: ${h}`)}}class a${constructor(){this.layoutVertexArray=new Lu,this.layoutAttenuationArray=new Wh,this.layoutColorArray=new Mu,this.indexArray=new Pi,this.indexArrayForConflation=new Pi,this.segmentsBucket=new Os}}class o${constructor(l){this.layoutFacadePaintArray=null,this.layoutFacadeDataArray=null,this.layoutFacadeVerticalRangeArray=null,this.segmentsBucket=new Os,this.entranceBloom=new a$;const u=66560;this.layoutVertexArray=new Lu,this.layoutVertexArray.reserve(u),this.layoutNormalArray=new Qd,this.layoutNormalArray.reserve(u),this.layoutCentroidArray=new Qd,this.layoutCentroidArray.reserve(u),this.layoutColorArray=new Mu,this.layoutColorArray.reserve(u),this.layoutFloodLightDataArray=new gw,this.layoutFloodLightDataArray.reserve(u),this.layoutAOArray=new yw,this.layoutAOArray.reserve(u),this.indexArray=new Pi,this.indexArray.reserve(66560),this.indexArrayForConflation=new Pi,this.segmentsBucket=new Os,this.entranceBloom=new a$,l&&(this.layoutFacadePaintArray=new Mu,this.layoutFacadeDataArray=new _y,this.layoutFacadeVerticalRangeArray=new Mu)}reserve(l,u,p){this.layoutVertexArray.reserveForAdditional(l),this.layoutCentroidArray.reserveForAdditional(l),this.layoutFloodLightDataArray.reserveForAdditional(l),this.layoutNormalArray.reserveForAdditional(l),this.layoutAOArray.reserveForAdditional(l),this.layoutColorArray.reserveForAdditional(l),this.indexArray.reserveForAdditional(u),p&&(this.layoutFacadePaintArray.reserveForAdditional(l),this.layoutFacadeDataArray.reserveForAdditional(l),this.layoutFacadeVerticalRangeArray.reserveForAdditional(l))}}class rJ{constructor(l){this.colorBufferUploaded=!1,this.maxHeight=0,this.replacementUpdateTime=0,this.activeReplacements=[],this.footprints=[],this.footprintsVertices=new Pp,this.footprintsIndices=new Rp,this.footprintsMin=new Ft(1/0,1/0),this.footprintsMax=new Ft(-1/0,-1/0),this.featuresOnBorder=[],this.buildingWithoutFacade=new o$(!1),this.buildingWithFacade=new o$(!0),this.indexArrayForConflationUploaded=!1,this.featureFootprintLookup=new Map,this.buildingIds=new Set,this.footprintLookup={},this.zoom=l.zoom,this.canonical=l.canonical,this.layers=l.layers,this.layerIds=this.layers.map(u=>u.fqid),this.index=l.index,this.hasPattern=!1,this.worldview=l.worldview,this.lut=l.lut,this.programConfigurations=new ie(l.layers,{zoom:l.zoom,lut:l.lut}),this.stateDependentLayerIds=this.layers.filter(u=>u.isStateDependent()).map(u=>u.id),this.projection=l.projection,this.groundEffect=new WB(l),this.groundEffect.groundRadiusArray=new Wc,this.hasAppearances=null}updateFootprints(l,u){const p=new LP([],[],1),x={vertices:[],indices:new Uint32Array(0),grid:p,min:this.footprintsMin,max:this.footprintsMax,buildingIds:this.buildingIds};u.push({footprint:x,id:l})}updateAppearances(l,u,p,x){return{hasLayoutChanges:!1,hasUboChanges:!1}}prepare(){return function(){if(VP!=null||PQ!=null)return null;if(jw!=null)return jw;const l=fetch(To());return jw=function(u){let p,x,b,T,k;function P(){p=new Uint8Array(k.buffer),x=new Int16Array(k.buffer),b=new Int32Array(k.buffer),T=new Float32Array(k.buffer)}function O(){throw new Error("Unexpected BuildingGen error.")}const $=()=>{},V={a:{a:O,f:function(G){const Y=p.length,X=Math.max(G>>>0,Math.ceil(1.2*Y)),te=Math.ceil((X-Y)/65536);try{return k.grow(te),P(),!0}catch{return!1}},g:O,b:$,c:$,d:$,e:$}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(u,V):u.then(G=>G.arrayBuffer()).then(G=>WebAssembly.instantiate(G,V))).then(G=>{const Y=G.instance.exports;return(0,Y.g)(),k=Y.f,P(),new bPe({setStyle:Y.h,setAOOptions:Y.i,setMetricOptions:Y.j,setStructuralOptions:Y.k,setFacadeOptions:Y.l,setFauxFacadeOptions:Y.m,setFacadeClassifierOptions:Y.n,addFeature:Y.o,addFacade:Y.p,generateMesh:Y.q,getLastError:Y.r,getOuterRingLength:Y.s,getMeshCount:Y.t,getPositionsPtr:Y.u,getPositionsLength:Y.v,getNormalsPtr:Y.w,getNormalsLength:Y.x,getAOPtr:Y.y,getAOLength:Y.z,getUVPtr:Y.A,getUVLength:Y.B,getFauxFacadePtr:Y.C,getFauxFacadeLength:Y.D,getIndicesPtr:Y.E,getIndicesLength:Y.F,getBuildingPart:Y.G,getRingCount:Y.H,getRingPtr:Y.I,getRingLength:Y.J,malloc:Y.K,free:Y.L,heapU8:p,heap16:x,heap32:b,heapF32:T})})}(l).then(u=>(jw=null,VP=u,VP)).catch(u=>{hr("Could not load building-gen"),jw=null,PQ=u instanceof Error?u:new Error("Unknown error")}),jw}()}populate(l,u,p,x){const b=wPe();if(!b)return;const T=zt(p);this.tileToMeter=T,this.brightness=u.brightness,b.setStyle({normalScale:[1,-1,T],tileToMeters:T}),b.setAOOptions(!1,.3),b.setMetricOptions(!1,16),b.setStructuralOptions(!0),b.setFacadeClassifierOptions(3);const k=new Map,P=new Map;let O=0;for(const{feature:ae}of l){if(tJ[ae.type]!=="LineString"){k.set(ae.id,ae.properties.source_id);continue}const fe=this.layers[0]._featureFilter.needGeometry;if(fe&&!this.layers[0]._featureFilter.filter(new fs(this.zoom),ae,p))continue;const ue=En(ae,fe);if(!fe&&!this.layers[0]._featureFilter.filter(new fs(this.zoom),ue,p))continue;const we=fe?ue.geometry:Kr(ae,p,x),Ae=[];for(const He of we)for(const Ve of He)Ae.push(Ve.x),Ae.push(Ve.y);const Ie={coordinates:Ae,crossPerc:ae.properties.cross_perc,distanceToRoad:ae.properties.distance_to_road,entrances:ae.properties.entrances,sourceId:0},We=ae.properties.source_id;let ze=P.get(We);ze||(ze=[],P.set(We,ze)),ze.push(Ie),++O}this.maxHeight=0;const $=new Array,V=new Set,G=ae=>{ae!=null&&V.add(ae)},Y=(ae,fe)=>{ae!=null&&$.push({buildingId:ae,footprintIndex:fe})},X=64*(l.length-O),te=X/2;this.buildingWithFacade.reserve(X,te,!0),this.buildingWithoutFacade.reserve(2*X,2*te,!1),this.footprintsIndices.reserve(16*(l.length-O)),this.footprintsVertices.reserve(8*(l.length-O));for(const{feature:ae,id:fe,index:ue,sourceLayerIndex:we}of l){if(tJ[ae.type]==="LineString")continue;const Ae=this.layers[0]._featureFilter.needGeometry;if(Ae&&!this.layers[0]._featureFilter.filter(new fs(this.zoom),ae,p))continue;let Ie=null;if(ae.properties&&ae.properties.hasOwnProperty("building_id")&&(Ie=Number(ae.properties.building_id),V.has(Ie)))continue;const We=En(ae,Ae);if(!Ae&&!this.layers[0]._featureFilter.filter(new fs(this.zoom),We,p))continue;const ze=Ae?We.geometry:Kr(ae,p,x),He=a2(ze,500);let Ve=!1;for(const Rn of He)if(Rn.length!==1){Ve=!0;break}if(Ve){G(Ie);continue}if(!ZPe(ze,163)){G(Ie);continue}const qe=this.layers[0],bt=XPe(qe.layout.get("building-roof-shape").evaluate(ae,{},p)),jt=qe.layout.get("building-base").evaluate(ae,{},p),It=qe.layout.get("building-height").evaluate(ae,{},p),Dt=qe.layout.get("building-flood-light-ground-radius").evaluate(ae,{},p),Pt=qe.paint.get("building-ambient-occlusion-intensity"),Ht=Dt/this.tileToMeter;ae.properties["building-part"]="roof";const _t=qe.paint.get("building-color").evaluate(ae,{},this.canonical).toPremultipliedRenderColor(this.lut),Rt=qe.paint.get("building-emissive-strength").evaluate(ae,{},this.canonical);ae.properties["building-part"]="wall";const Bt=qe.paint.get("building-color").evaluate(ae,{},this.canonical).toPremultipliedRenderColor(this.lut),Yt=qe.paint.get("building-emissive-strength").evaluate(ae,{},this.canonical);ae.properties["building-part"]="window";const tr=qe.paint.get("building-color").evaluate(ae,{},this.canonical).toPremultipliedRenderColor(this.lut),br=qe.paint.get("building-emissive-strength").evaluate(ae,{},this.canonical);ae.properties["building-part"]="door";const ur=qe.paint.get("building-color").evaluate(ae,{},this.canonical).toPremultipliedRenderColor(this.lut),cr=qe.paint.get("building-emissive-strength").evaluate(ae,{},this.canonical);let rr=qe.layout.get("building-flood-light-wall-radius").evaluate(ae,{},p);rr=pe(rr,0,2048);const _r=rr/2048*XP,Pr=k.get(fe),Wr=P.get(Pr)||[],Mr=Wr.length!==0&&qe.layout.get("building-facade").evaluate(ae,{},p);b.setFacadeOptions(4,!0),b.setFauxFacadeOptions(Mr,!1,1);let fn=0,Wn=0,mn=0,es=0,jn=0,Ti=0,ms=0,ns=0,$s=0,xi=0,Ya=0;if(Mr){let Rn=Math.round(qe.layout.get("building-facade-floors").evaluate(ae,{},p));if(jt===0){Rn=Math.max(1,Rn-(Wr.length>0?1:0));let Mi=4;if(It>100){const Fa=[10,13,15];Mi=Fa[ae.id?ae.id%Fa.length:0]}else It<=10&&(Mi=3);b.setFacadeOptions(Mi,!0),jn=(It<15?1.3:1.61803)*Mi/T}else jn=jt/T;Ti=It/T,jn=Math.min(jn,Ti),mn=qe.layout.get("building-facade-unit-width").evaluate(ae,{},p)/T,es=(Ti-jn)/Rn,b.setFauxFacadeOptions(!0,!0,mn);const ao=qe.layout.get("building-facade-window").evaluate(ae,{},p);fn=ao[0],Wn=ao[1],ms=Math.floor(65535*Math.min(1,jn/fr)),ns=Math.floor(65535*Math.min(1,Ti/fr)),$s=Math.floor(255*fn)<<8|Math.floor(255*Wn),xi=Math.floor(65535*Math.min(1,mn/fr)),Ya=Math.floor(65535*Math.min(1,es/fr))}const _i=Array(He.length),Ri={x:1/0,y:1/0},aa={x:-1/0,y:-1/0},Li={x:0,y:0};let Mo=0;for(let Rn=0;Rn0){const Mi=[],Fa=Array(ao.length+1);Fa[0]=0;for(let pd=0;pdfr||Ri.y<0||aa.y>fr)&&this.featuresOnBorder.push({featureId:ae.id,footprintIndex:this.footprints.length});{const Rn=ww(Vp,null,2);this.footprintsIndices.resize(this.footprintsIndices.length+Rn.length),this.footprintsIndices.uint16.set(Rn,$w),this.buildingIds.add(Ie??ae.id),this.footprintsMin.x=Math.min(this.footprintsMin.x,fd.x),this.footprintsMin.y=Math.min(this.footprintsMin.y,fd.y),this.footprintsMax.x=Math.max(this.footprintsMax.x,md.x),this.footprintsMax.y=Math.max(this.footprintsMax.y,md.y);const ao={footprintVertexOffset:Up,footprintVertexLength:this.footprintsVertices.length-Up,footprintIndexOffset:$w,footprintIndexLength:this.footprintsIndices.length-$w,min:fd,max:md,hiddenFlags:0,indicesOffset:jR,indicesLength:X$,bloomIndicesOffset:Do,bloomIndicesLength:Ei,groundEffectVertexOffset:I_,groundEffectVertexLength:zw,hasFauxFacade:Mr,height:Bw,promoteId:fe,feature:We,parts:so,buildingBloom:Dl},Mi=this.footprints.length;ae.id!==void 0&&this.featureFootprintLookup.set(ae.id,Mi),Y(Ie,Mi),this.footprints.push(ao)}this.programConfigurations.populatePaintArrays(An.layoutVertexArray.length,ae,ue,{},u.availableImages,p,u.brightness),this.groundEffect.addPaintPropertiesData(ae,ue,{},u.availableImages,p,u.brightness),u.featureIndex.insert(ae,ze,ue,we,this.index,ml)}$.forEach(({buildingId:ae,footprintIndex:fe})=>{V.has(ae)&&(this.footprints[fe].hiddenFlags|=4)});const se=new Set;this.buildingIds.forEach((ae,fe,ue)=>{V.has(ae)||se.add(ae)}),this.buildingIds=se,this.groundEffect.prepareBorderSegments()}update(l,u,p,x,b,T,k){this.programConfigurations.updatePaintArrays(l,u,b,p,x,T,k),this.groundEffect.update(l,u,b,p,x,T,k),this.evaluate(this.layers[0],l),this.colorBufferUploaded=!1}isEmpty(){return this.buildingWithoutFacade.layoutVertexArray.length===0&&this.buildingWithFacade.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload||this.groundEffect.programConfigurations.needsUpload}upload(l){const u=p=>{p.layoutVertexBuffer=l.createVertexBuffer(p.layoutVertexArray,JQ.members),p.layoutNormalBuffer=l.createVertexBuffer(p.layoutNormalArray,VPe.members),p.layoutCentroidBuffer=l.createVertexBuffer(p.layoutCentroidArray,qPe.members),p.layoutFloodLightDataBuffer=l.createVertexBuffer(p.layoutFloodLightDataArray,YPe.members),p.layoutFacadeDataArray&&p.layoutFacadeDataArray.length&&(p.layoutFacadeDataBuffer=l.createVertexBuffer(p.layoutFacadeDataArray,HPe.members)),p.layoutFacadeVerticalRangeArray&&p.layoutFacadeVerticalRangeArray.length&&(p.layoutFacadeVerticalRangeBuffer=l.createVertexBuffer(p.layoutFacadeVerticalRangeArray,WPe.members)),p.entranceBloom.layoutVertexArray.length&&(p.entranceBloom.layoutVertexBuffer=l.createVertexBuffer(p.entranceBloom.layoutVertexArray,JQ.members),p.entranceBloom.layoutAttenuationBuffer=l.createVertexBuffer(p.entranceBloom.layoutAttenuationArray,KPe.members)),this.uploadUpdatedColorBuffer(l),this.uploadUpdatedIndexBuffer(l)};this.uploaded||(u(this.buildingWithoutFacade),u(this.buildingWithFacade),this.groundEffect.upload(l)),this.groundEffect.uploadPaintProperties(l),this.programConfigurations.upload(l),this.uploaded=!0}destroy(){const l=u=>{u.layoutVertexBuffer&&(u.layoutVertexBuffer.destroy(),u.layoutNormalBuffer.destroy(),u.layoutColorBuffer.destroy(),u.segmentsBucket.destroy(),u.indexBuffer&&u.indexBuffer.destroy(),u.entranceBloom.layoutVertexBuffer&&(u.entranceBloom.layoutVertexBuffer.destroy(),u.entranceBloom.layoutColorBuffer.destroy(),u.entranceBloom.layoutAttenuationBuffer.destroy(),u.entranceBloom.indexBuffer.destroy(),u.entranceBloom.segmentsBucket.destroy()))};l(this.buildingWithoutFacade),l(this.buildingWithFacade),this.groundEffect.destroy(),this.programConfigurations.destroy()}updateFootprintHiddenFlags(l,u,p=!0){let x=!1;const b=p?u:0,T=0|(p?-1:~u);this.groundEffect.hiddenByLandmarkVertexArray.length===0&&this.groundEffect.hiddenByLandmarkVertexArray.resize(this.groundEffect.vertexArray.length);for(const k of l){const P=this.footprints[k],O=P.hiddenFlags&T|b;P.hiddenFlags!==O&&(P.hiddenFlags=O,x=!0,this.groundEffect.updateHiddenByLandmarkRange(P.groundEffectVertexOffset,P.groundEffectVertexLength,P.hiddenFlags!==0))}return x&&(this.indexArrayForConflationUploaded=!1),x}uploadUpdatedIndexBuffer(l){if(this.groundEffect.uploadHiddenByLandmark(l),this.indexArrayForConflationUploaded)return;const u=x=>{x.indexArray.length!==0&&(x.indexArrayForConflation.resize(x.indexArray.length),x.indexArrayForConflation.uint16.set(x.indexArray.uint16),x.entranceBloom.indexArrayForConflation.resize(x.entranceBloom.indexArray.length),x.entranceBloom.indexArrayForConflation.uint16.set(x.entranceBloom.indexArray.uint16))};u(this.buildingWithoutFacade),u(this.buildingWithFacade);for(const x of this.footprints){const b=x.hasFauxFacade?this.buildingWithFacade:this.buildingWithoutFacade,T=x.indicesOffset+x.indicesLength;if(x.hiddenFlags!==0){for(let P=x.indicesOffset;P{x.indexArray.length!==0&&(x.indexBuffer?x.indexBuffer.updateData(x.indexArrayForConflation):x.indexBuffer=l.createIndexBuffer(x.indexArrayForConflation,!0),x.entranceBloom.indexBuffer?x.entranceBloom.indexBuffer.updateData(x.entranceBloom.indexArrayForConflation):x.entranceBloom.indexBuffer=l.createIndexBuffer(x.entranceBloom.indexArrayForConflation,!0))};p(this.buildingWithoutFacade),p(this.buildingWithFacade),this.indexArrayForConflationUploaded=!0}uploadUpdatedColorBuffer(l){const u=p=>{p.layoutColorBuffer?p.layoutColorBuffer.updateData(p.layoutColorArray):p.layoutColorBuffer=l.createVertexBuffer(p.layoutColorArray,eJ.members,!0),p.layoutFacadePaintArray&&(p.layoutFacadePaintBuffer?p.layoutFacadePaintBuffer.updateData(p.layoutFacadePaintArray):p.layoutFacadePaintBuffer=l.createVertexBuffer(p.layoutFacadePaintArray,GPe.members,!0)),p.entranceBloom.layoutColorBuffer?p.entranceBloom.layoutColorBuffer.updateData(p.entranceBloom.layoutColorArray):p.entranceBloom.layoutColorBuffer=l.createVertexBuffer(p.entranceBloom.layoutColorArray,eJ.members,!0)};u(this.buildingWithoutFacade),u(this.buildingWithFacade),this.colorBufferUploaded=!0}evaluate(l,u){const p=l.paint.get("building-ambient-occlusion-intensity");for(const x of this.footprints){if(4&x.hiddenFlags)continue;const b=u[x.promoteId],T=x.feature;T.properties["building-part"]="roof";const k=l.paint.get("building-color").evaluate(T,b,this.canonical).toPremultipliedRenderColor(this.lut),P=l.paint.get("building-emissive-strength").evaluate(T,b,this.canonical);T.properties["building-part"]="wall";const O=l.paint.get("building-color").evaluate(T,b,this.canonical).toPremultipliedRenderColor(this.lut),$=l.paint.get("building-emissive-strength").evaluate(T,b,this.canonical);T.properties["building-part"]="window";const V=l.paint.get("building-color").evaluate(T,b,this.canonical).toPremultipliedRenderColor(this.lut),G=l.paint.get("building-emissive-strength").evaluate(T,b,this.canonical);T.properties["building-part"]="door";const Y=l.paint.get("building-color").evaluate(T,b,this.canonical).toPremultipliedRenderColor(this.lut),X=l.paint.get("building-emissive-strength").evaluate(T,b,this.canonical),te=x.hasFauxFacade?this.buildingWithFacade:this.buildingWithoutFacade;for(const ae of x.parts){let fe,ue=k;ae.part===1?(ue=k,fe=P):ae.part===0?(ue=O,fe=$):ae.part===2?(ue=V,fe=G):ae.part===3&&(ue=Y,fe=X),fe=pe(fe,0,1);for(let we=0;weT.max.x||P.max.xT.max.y||P.max.yk.max.x||k.min.x>l||u>k.max.y||k.min.y>u||k.height<=p||QPe(T,this.footprintsVertices.float32.subarray(2*k.footprintVertexOffset,2*(k.footprintVertexOffset+k.footprintVertexLength)),this.footprintsIndices.uint16.subarray(k.footprintIndexOffset,k.footprintIndexOffset+k.footprintIndexLength))&&(p=k.height,this.footprintLookup[b]=k,x=k.hiddenFlags!==0);if(p!==Number.NEGATIVE_INFINITY)return{height:p,hidden:x};this.footprintLookup[b]=void 0}}function QPe(h,l,u){for(let p=0;p1&&(P=l[++k]);const $=Math.abs(O-P.left),V=Math.abs(O-P.right),G=Math.min($,V);let Y;const X=b/p*(x+1);if(P.isDash){const te=x-Math.abs(X);Y=Math.sqrt(G*G+te*te)}else Y=x-Math.sqrt(G*G+X*X);this.image.data[T+O]=Math.max(0,Math.min(255,Y+128))}}}addRegularDash(l,u){for(let P=l.length-1;P>=0;--P){const O=l[P],$=l[P+1];O.zeroLength?l.splice(P,1):$&&$.isDash===O.isDash&&($.left=O.left,l.splice(P,1))}const p=l[0],x=l[l.length-1];p.isDash===x.isDash&&(p.left=x.left-this.width,x.right=p.right+this.width);const b=this.width*this.nextRow;let T=0,k=l[T];for(let P=0;P1&&(k=l[++T]);const O=Math.abs(P-k.left),$=Math.abs(P-k.right),V=Math.min(O,$);this.image.data[b+P]=Math.max(0,Math.min(255,(k.isDash?V:-V)+u+128))}}addDash(l,u){const p=this.getKey(l,u);if(this.positions[p])return this.positions[p];const x=u==="round",b=x?7:0,T=2*b+1;if(this.nextRow+T>this.height)return hr("LineAtlas out of space"),null;l.length===0&&l.push(1);let k=0;for(let V=0;Vu.fqid),this.index=l.index,this.projection=l.projection,this.hasPattern=!1,this.hasCrossSlope=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(u=>{this.gradients[u.id]={}}),this.layoutVertexArray=new c_,this.layoutVertexArray2=new Lu,this.patternVertexArray=new Lu,this.indexArray=new Pi,this.programConfigurations=new ie(l.layers,{zoom:l.zoom,lut:l.lut}),this.segments=new Os,this.maxLineLength=0,this.zOffsetVertexArray=new Lu,this.elevationGroundScaleVertexArray=new Wc,this.stateDependentLayerIds=this.layers.filter(u=>u.isStateDependent()).map(u=>u.id),this.tessellationStep=l.tessellationStep?l.tessellationStep:128,this.worldview=l.worldview,this.hasAppearances=null}updateFootprints(l,u){}updateAppearances(l,u,p,x){return{hasLayoutChanges:!1,hasUboChanges:!1}}populate(l,u,p,x){this.hasPattern=CB("line",this.layers,this.pixelRatio,u);const b=this.layers[0].layout.get("line-sort-key");this.tileToMeter=zt(p);const T=this.layers[0].layout.get("line-elevation-reference");if(T==="hd-road-markup")this.elevationType="road";else{const G=this.layers[0].layout.get("line-z-offset"),Y=G.isConstant()&&!G.constantOr(0);this.elevationType=T!=="sea"&&T!=="ground"&&Y?"none":"offset",this.elevationType==="offset"&&T==="none"&&hr(`line-elevation-reference: ground is used for the layer ${this.layerIds[0]} because non-zero line-z-offset value was found.`),this.isSeaLevelReference=T==="sea"}const k=this.layers[0].layout.get("line-cross-slope");this.hasCrossSlope=this.elevationType==="offset"&&k!==void 0;const P=[];for(const{feature:G,id:Y,index:X,sourceLayerIndex:te}of l){const se=this.layers[0]._featureFilter.needGeometry,ae=En(G,se);if(!this.layers[0]._featureFilter.filter(new fs(this.zoom,{worldview:this.worldview,activeFloors:u.activeFloors}),ae,p))continue;const fe=b?b.evaluate(ae,{},p):void 0,ue={id:Y,properties:G.properties,type:G.type,sourceLayerIndex:te,index:X,geometry:se?ae.geometry:Kr(G,p,x),patterns:{},sortKey:fe};P.push(ue)}b&&P.sort((G,Y)=>G.sortKey-Y.sortKey);const{lineAtlas:O,featureIndex:$}=u,V=this.addConstantDashes(O);for(const G of P){const{geometry:Y,index:X,sourceLayerIndex:te}=G;if(V&&this.addFeatureDashes(G,O),this.hasPattern){const se=IB("line",this.layers,G,this.zoom,this.pixelRatio,u);this.patternFeatures.push(se)}else this.addFeature(G,Y,X,p,O.positions,u.availableImages,u.brightness,u.elevationFeatures);$.insert(l[X].feature,Y,X,te,this.index)}}addConstantDashes(l){let u=!1;for(const p of this.layers){const x=p.paint.get("line-dasharray").value,b=p.layout.get("line-cap").value;if(x.kind!=="constant"||b.kind!=="constant")u=!0;else{const T=b.value,k=x.value;if(!k)continue;l.addDash(k,T)}}return u}addFeatureDashes(l,u){const p=this.zoom;for(const x of this.layers){const b=x.paint.get("line-dasharray").value,T=x.layout.get("line-cap").value;if(b.kind==="constant"&&T.kind==="constant")continue;let k,P;if(b.kind==="constant"){if(k=b.value,!k)continue}else k=b.evaluate({zoom:p},l);P=T.kind==="constant"?T.value:T.evaluate({zoom:p},l),u.addDash(k,P),l.patterns[x.id]=[u.getKey(k,P)]}}update(l,u,p,x,b,T,k,P,O){this.programConfigurations.updatePaintArrays(l,u,b,p,x,T,k,O)}addFeatures(l,u,p,x,b,T){for(const k of this.patternFeatures)this.addFeature(k,k.geometry,k.index,u,p,x,T,l.elevationFeatures)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(l){this.uploaded||(this.layoutVertexArray2.length!==0&&(this.layoutVertexBuffer2=l.createVertexBuffer(this.layoutVertexArray2,iRe)),this.patternVertexArray.length!==0&&(this.patternVertexBuffer=l.createVertexBuffer(this.patternVertexArray,oRe)),!this.zOffsetVertexBuffer&&this.zOffsetVertexArray.length>0&&(this.zOffsetVertexBuffer=l.createVertexBuffer(this.zOffsetVertexArray,tRe.members,!0)),!this.elevationGroundScaleVertexBuffer&&this.elevationGroundScaleVertexArray.length>0&&(this.elevationGroundScaleVertexBuffer=l.createVertexBuffer(this.elevationGroundScaleVertexArray,rRe.members,!0)),this.layoutVertexBuffer=l.createVertexBuffer(this.layoutVertexArray,nRe),this.indexBuffer=l.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(l),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy(),this.elevationGroundScaleVertexBuffer&&this.elevationGroundScaleVertexBuffer.destroy(),this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(l,u){let p,x;if(u&&u>0?(p=`mapbox_clip_start_${u}`,x=`mapbox_clip_end_${u}`):(p="mapbox_clip_start",x="mapbox_clip_end"),l.properties&&l.properties.hasOwnProperty(p)&&l.properties.hasOwnProperty(x))return{start:+l.properties[p],end:+l.properties[x]}}addFeature(l,u,p,x,b,T,k,P){const O=this.layers[0].layout,$=O.get("line-join").evaluate(l,{}),V=O.get("line-cap").evaluate(l,{}),G=O.get("line-miter-limit"),Y=O.get("line-round-limit");this.lineClips=this.lineFeatureClips(l),this.lineFeature=l;const X=!(!l.properties||!l.properties.hasOwnProperty("mapbox_line_metrics"))&&l.properties.mapbox_line_metrics;this.zOffsetValue=O.get("line-z-offset").value;const te=this.layers[0].paint.get("line-width").value;if(te.kind!=="constant"&&te.isLineProgressConstant===!1&&(this.variableWidthValue=te),this.isSeaLevelReference){const se=O.get("line-elevation-ground-scale").value;se.kind==="constant"&&se.value===0||(this.elevationGroundScaleValue=se)}if(this.elevationType==="road"){const se=this.layoutVertexArray.length;if(!this.addElevatedRoadFeature(l,u,x,P,$,V,G,Y)){const[ae,fe]=this.clipRuntimeLinesToTile(u,1);for(let ue=0;ue0?Ae.parentIndex:null)}this.fillNonElevatedRoadSegment(se)}}else for(let se=0;se0?se:null);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,l,p,b,T,x,k,void 0,this.worldview)}computeSegNextDir(l,u){return l.nextPoint.sub(u.at(-2)).unit()}computeSegPrevDir(l,u){return u[1].sub(l.prevPoint).unit()}clipLinesToTile(l,u){return UP(l,-u,-u,fr+u,fr+u)}clipRuntimeLinesToTile(l,u){const p=[];return[UP(l,-u,-u,fr+u,fr+u,p),p]}addElevatedRoadFeature(l,u,p,x,b,T,k,P){const O=[],$=Vs.getElevationFeature(l,x);if($){const V=this.clipLinesToTile(u,1),G=this.prepareElevatedLines(V,$,p);for(const Y of G)O.push({geometry:Y,elevation:$,elevationTileID:p,segment:{progress:{min:0,max:1},nextDir:void 0,prevDir:void 0}})}if(O.length===0)return!1;for(const V of O){const G=this.layoutVertexArray.length;this.addLine(V.geometry,l,p,b,T,k,P);const Y=new Ys(p,V.elevationTileID);if(V.elevation)for(let X=G;X>1,this.layoutVertexArray.int16[6*X+1]>>1),se=Y.pointElevation(te,V.elevation,.05);this.updateHeightRange(se),this.zOffsetVertexArray.emplaceBack(se,0,0)}else this.fillNonElevatedRoadSegment(G)}return!0}prepareElevatedLines(l,u,p){if(u.constantHeight!=null)return l;const x=[],b=1/zt(p);for(const T of l)vPe(T,new Yc(u,b),0,x);return x}fillNonElevatedRoadSegment(l){for(let u=l;u0,G=P&&P.progress.max<1;if(this.lineClips){let He={min:this.lineClips.start,max:this.lineClips.end},Ve=1;if(P){const jt=this.lineClips.end-this.lineClips.start;He=function(It,Dt,Pt){return{min:di(It.min,Dt,Pt),max:di(It.max,Dt,Pt)}}(P.progress,{min:0,max:1},He),jt>0&&(Ve=(He.max-He.min)/jt)}const qe=+u.properties.mapbox_clip_feature_len,bt=+u.properties.mapbox_clip_seg_len;if(Number.isNaN(qe)||Number.isNaN(bt)){for(let It=0;It=2&&l[X-1].equals(l[X-2]);)X--;let te=0;for(;te0,Rt=this.overscaling<=16?122880/(512*this.overscaling):0;if(Ve&&qe==="round"){if(DtT&&(qe="bevel"),qe==="bevel"&&(Dt>2&&(qe="flipbevel"),Dt2*Rt){const tr=ae.sub(ae.sub(fe)._mult(Rt/Bt)._round());this.updateDistance(fe,tr),this.addCurrentVertex(tr,we,0,0,se,ze),fe=tr}this.updateDistance(fe,ae),jt._mult(Dt),this.addCurrentVertex(ae,jt,0,0,se,ze);const Yt=ae.dist(ue);if(Yt>2*Rt){const tr=ae.add(ue.sub(ae)._mult(Rt/Yt)._round());this.updateDistance(ae,tr),this.addCurrentVertex(tr,Ae,0,0,se,ze),ae=tr}}else jt._mult(Dt),this.addCurrentVertex(ae,jt,0,0,se,ze);else if(qe==="flipbevel"){if(Dt>100)jt=Ae.mult(-1);else{const Bt=Dt*we.add(Ae).mag()/we.sub(Ae).mag();jt._perp()._mult(Bt*(_t?-1:1))}this.addCurrentVertex(ae,jt,0,0,se,ze),this.addCurrentVertex(ae,jt.mult(-1),0,0,se,ze)}else if(qe==="bevel"||qe==="fakeround"){const Bt=ae.dist(fe);let Yt=1;if(this.elevationType==="offset"&&qe==="bevel"&&this.currentLineJoinType!=="round"&&!this.patternJoinNone&&ze!=null&&fe&&ue){const _r=4*Rt;Bt<_r&&(Yt=Math.max(0,Bt/_r))}ze!=null&&fe&&this.addCurrentVertex(ae,We||we,-Yt,-Yt,se,ze);const tr=Bt<=2*Rt&&qe!=="bevel",br=jt.mult(_t?1:-1);br._mult(Dt);const ur=Ae.mult(_t?-1:1),cr=we.mult(_t?-1:1),rr=this.evaluateLineProgressFeatures(this.distance);if(ze==null&&(this.addHalfVertex(ae,br.x,br.y,!1,!_t,0,se,rr),tr||this.addHalfVertex(ae,br.x+2*cr.x,br.y+2*cr.y,!1,_t,0,se,rr)),qe==="fakeround"){const _r=Math.round(180*Pt/Math.PI/20);this.addHalfVertex(ae,cr.x,cr.y,!1,_t,0,se,rr);for(let Pr=0;Pr<_r;Pr++){let Wr=Pr/_r;if(Wr!==.5){const fn=Wr-.5;Wr+=Wr*fn*(Wr-1)*((1.0904+bt*(bt*(3.55645-1.43519*bt)-3.2452))*fn*fn+(.848013+bt*(.215638*bt-1.06021)))}const Mr=ur.sub(cr)._mult(Wr)._add(cr)._unit();this.addHalfVertex(ae,Mr.x,Mr.y,!1,_t,0,se,rr)}this.addHalfVertex(ae,ur.x,ur.y,!1,_t,0,se,rr)}tr||ze!=null||this.addHalfVertex(ae,br.x+2*ur.x,br.y+2*ur.y,!1,_t,0,se,rr),ze!=null&&ue&&this.addCurrentVertex(ae,Ie||Ae,Yt,Yt,se,ze)}else if(qe==="butt")this.addCurrentVertex(ae,jt,0,0,se,ze);else if(qe==="square"){if(!fe){const Bt=V?0:-1;this.addCurrentVertex(ae,jt,Bt,Bt,se,ze)}if(this.addCurrentVertex(ae,jt,0,0,se,ze),fe){const Bt=G?0:1;this.addCurrentVertex(ae,jt,Bt,Bt,se,ze)}}else if(qe==="round"){if(fe){const Bt=!Ve&&We?We:we;this.addCurrentVertex(ae,Bt,0,0,se,ze),!Ve&&G||this.addCurrentVertex(ae,Bt,1,1,se,ze,!0)}if(ue){const Bt=!Ve&&Ie?Ie:Ae;!Ve&&V||this.addCurrentVertex(ae,Bt,-1,-1,se,ze,!0),this.addCurrentVertex(ae,Bt,0,0,se,ze)}}}}addVerticesTo(l,u,p,x,b,T,k,P,O,$){const V=(u.w-l.w)/this.tessellationStep|0;let G=0;const Y=this.scaledDistance;if(V>1){this.lineSoFar=l.w;const te=(u.x-l.x)/V,se=(u.y-l.y)/V,ae=(u.z-l.z)/V,fe=(u.w-l.w)/V,ue=u.x-l.x,we=u.y-l.y,Ae=Math.sqrt(ue*ue+we*we);if(Ae===0)return;const Ie=-we/Ae,We=ue/Ae,ze=Ie,He=We,Ve=-Ie,qe=-We;for(let bt=1;bt=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,$),P.primitiveLength++),T?this.e2=$:this.e1=$,O!=null&&this.zOffsetVertexArray.emplaceBack(O.zOffset,O.variableWidth,O.variableWidth),this.elevationGroundScaleValue){const V=O?O.elevationGroundScale:this.evaluateElevationGroundScale();this.elevationGroundScaleVertexArray.emplaceBack(V)}}updateScaledDistance(){this.lineClips?(this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=this.totalFeatureLength*this.lineClips.start+this.distance):this.lineSoFar=this.distance}updateDistance(l,u){this.prevDistance=this.distance,this.distance+=l.dist(u),this.updateScaledDistance()}}function l$(h,l,u){return h.xu||h.yu}let aJ,oJ;function lJ(h,l,u){return l*(fr/(h.tileSize*Math.pow(2,u-h.tileID.overscaledZ)))}Tr(QP,"LineBucket",{omit:["layers","patternFeatures","currentVertex","currentVertexIsOutside"]});const cJ=(h,l,u)=>(1-u)*h+u*l;function uJ(h,l){return 1/lJ(h,1,l.tileZoom)}function dJ(h,l,u,p){return h.translatePosMatrix(p||l.tileID.projMatrix,l,u.paint.get("line-translate"),u.paint.get("line-translate-anchor"))}const hJ=h=>{const l=[];fJ(h)&&l.push("RENDER_LINE_DASH"),h.paint.get("line-gradient")&&l.push("RENDER_LINE_GRADIENT"),h.paint.get("line-blend-mode")==="multiply"&&l.push("LINE_BLEND_MULTIPLY");const u=h.paint.get("line-trim-offset");u[0]===0&&u[1]===0||l.push("RENDER_LINE_TRIM_OFFSET"),h.paint.get("line-border-width").constantOr(1)!==0&&l.push("RENDER_LINE_BORDER");const p=h.layout.get("line-join").constantOr("miter")==="none",x=!!h.paint.get("line-pattern").constantOr(1);return p&&x&&l.push("LINE_JOIN_NONE"),l};function fJ(h){const l=h.paint.get("line-dasharray").value;return l.kind!=="constant"||l.value}let c$;const mJ=()=>c$||(c$={layout:aJ||(aJ=new hi({"line-cap":new Qt(at.layout_line["line-cap"]),"line-join":new Qt(at.layout_line["line-join"]),"line-miter-limit":new sr(at.layout_line["line-miter-limit"]),"line-round-limit":new sr(at.layout_line["line-round-limit"]),"line-sort-key":new Qt(at.layout_line["line-sort-key"]),"line-z-offset":new Qt(at.layout_line["line-z-offset"]),"line-elevation-reference":new sr(at.layout_line["line-elevation-reference"]),"line-cross-slope":new sr(at.layout_line["line-cross-slope"]),visibility:new sr(at.layout_line.visibility),"line-width-unit":new sr(at.layout_line["line-width-unit"]),"line-elevation-ground-scale":new Qt(at.layout_line["line-elevation-ground-scale"])})),paint:oJ||(oJ=new hi({"line-opacity":new Qt(at.paint_line["line-opacity"]),"line-color":new Qt(at.paint_line["line-color"]),"line-translate":new sr(at.paint_line["line-translate"]),"line-translate-anchor":new sr(at.paint_line["line-translate-anchor"]),"line-width":new Qt(at.paint_line["line-width"]),"line-gap-width":new Qt(at.paint_line["line-gap-width"]),"line-offset":new Qt(at.paint_line["line-offset"]),"line-blur":new Qt(at.paint_line["line-blur"]),"line-dasharray":new Qt(at.paint_line["line-dasharray"]),"line-pattern":new Qt(at.paint_line["line-pattern"]),"line-pattern-cross-fade":new sr(at.paint_line["line-pattern-cross-fade"]),"line-gradient":new yy(at.paint_line["line-gradient"]),"line-trim-offset":new sr(at.paint_line["line-trim-offset"]),"line-trim-fade-range":new sr(at.paint_line["line-trim-fade-range"]),"line-trim-color":new sr(at.paint_line["line-trim-color"]),"line-emissive-strength":new Qt(at.paint_line["line-emissive-strength"]),"line-border-width":new Qt(at.paint_line["line-border-width"]),"line-border-color":new Qt(at.paint_line["line-border-color"]),"line-occlusion-opacity":new sr(at.paint_line["line-occlusion-opacity"]),"line-blend-mode":new sr(at.paint_line["line-blend-mode"]),"line-color-use-theme":new Qt({type:"string",default:"default","property-type":"data-driven"}),"line-gradient-use-theme":new Qt({type:"string",default:"default","property-type":"data-driven"}),"line-trim-color-use-theme":new Qt({type:"string",default:"default","property-type":"data-driven"}),"line-border-color-use-theme":new Qt({type:"string",default:"default","property-type":"data-driven"})}))},c$);class dRe extends Qt{possiblyEvaluate(l,u){return u=new fs(Math.floor(u.zoom),{now:u.now,fadeDuration:u.fadeDuration,transition:u.transition,worldview:u.worldview}),super.possiblyEvaluate(l,u)}evaluate(l,u,p,x){return u=Object.assign({},u,{zoom:Math.floor(u.zoom)}),super.evaluate(l,u,p,x)}}let x2;function pJ(h,l){return l>0?l+2*h:h}const hRe=On([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),fRe=On([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),mRe=On([{name:"a_projected_pos",components:4,type:"Float32"}],4);On([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const pRe=On([{name:"a_auto_z_offset",components:1,type:"Float32"}],4),gRe=On([{name:"a_feature_index",components:1,type:"Float32"}],4),yRe=On([{name:"a_x_axis",components:3,type:"Float32"},{name:"a_y_axis",components:3,type:"Float32"}]),xRe=On([{name:"a_texb",components:2,type:"Uint16"}]),_Re=On([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_elevation_from_sea",components:2,type:"Float32"}]),vRe=On([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"},{name:"a_auto_z_offset",components:1,type:"Float32"}]);On([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Int16",name:"tileAnchorX"},{type:"Int16",name:"tileAnchorY"},{type:"Float32",name:"x1"},{type:"Float32",name:"y1"},{type:"Float32",name:"x2"},{type:"Float32",name:"y2"},{type:"Int16",name:"padding"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const gJ=On([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),bRe=On([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);On([{name:"triangle",components:3,type:"Uint16"}]),On([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Uint16",name:"glyphStartIndex"},{type:"Uint16",name:"numGlyphs"},{type:"Uint32",name:"vertexStartIndex"},{type:"Uint32",name:"lineStartIndex"},{type:"Uint32",name:"lineLength"},{type:"Uint16",name:"segment"},{type:"Uint16",name:"lowerSize"},{type:"Uint16",name:"upperSize"},{type:"Float32",name:"lineOffsetX"},{type:"Float32",name:"lineOffsetY"},{type:"Uint8",name:"writingMode"},{type:"Uint8",name:"placedOrientation"},{type:"Uint8",name:"hidden"},{type:"Uint32",name:"crossTileID"},{type:"Int16",name:"associatedIconIndex"},{type:"Uint8",name:"flipState"}]),On([{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Int16",name:"rightJustifiedTextSymbolIndex"},{type:"Int16",name:"centerJustifiedTextSymbolIndex"},{type:"Int16",name:"leftJustifiedTextSymbolIndex"},{type:"Int16",name:"verticalPlacedTextSymbolIndex"},{type:"Int16",name:"placedIconSymbolIndex"},{type:"Int16",name:"verticalPlacedIconSymbolIndex"},{type:"Uint16",name:"key"},{type:"Uint16",name:"textBoxStartIndex"},{type:"Uint16",name:"textBoxEndIndex"},{type:"Uint16",name:"verticalTextBoxStartIndex"},{type:"Uint16",name:"verticalTextBoxEndIndex"},{type:"Uint16",name:"iconBoxStartIndex"},{type:"Uint16",name:"iconBoxEndIndex"},{type:"Uint16",name:"verticalIconBoxStartIndex"},{type:"Uint16",name:"verticalIconBoxEndIndex"},{type:"Uint16",name:"featureIndex"},{type:"Uint16",name:"numHorizontalGlyphVertices"},{type:"Uint16",name:"numVerticalGlyphVertices"},{type:"Uint16",name:"numIconVertices"},{type:"Uint16",name:"numVerticalIconVertices"},{type:"Uint16",name:"useRuntimeCollisionCircles"},{type:"Uint32",name:"crossTileID"},{type:"Float32",components:2,name:"textOffset"},{type:"Float32",name:"collisionCircleDiameter"},{type:"Float32",name:"zOffset"},{type:"Uint8",name:"hasIconTextFit"},{type:"Uint16",name:"elevationFeatureIndex"}]),On([{type:"Float32",name:"offsetX"}]),On([{type:"Int16",name:"x"},{type:"Int16",name:"y"}]);const u$=class DM{constructor(l=null,u=0,p=4096){this.batchIndex=u,this.headerBuffer=null,this.propertiesBuffer=null,this.blockIndicesBuffer=null,this.context=l||null,this.propsDwords=p,this.totalBytes=4*this.propsDwords,this.headerData=new Uint32Array(DM.HEADER_DWORDS),this.propertiesData=new Float32Array(this.propsDwords),this.blockIndicesData=new Uint32Array(this.propsDwords);for(let x=0;xl.maxUniformBlockSize)throw new Error(`UBO size ${this.totalBytes} exceeds device limit ${l.maxUniformBlockSize}`);if(this.headerBuffer=u.createBuffer(),!this.headerBuffer)throw new Error("Failed to create header UBO buffer");if(u.bindBuffer(u.UNIFORM_BUFFER,this.headerBuffer),u.bufferData(u.UNIFORM_BUFFER,DM.HEADER_BYTES,u.DYNAMIC_DRAW),this.propertiesBuffer=u.createBuffer(),!this.propertiesBuffer)throw new Error("Failed to create properties UBO buffer");if(u.bindBuffer(u.UNIFORM_BUFFER,this.propertiesBuffer),u.bufferData(u.UNIFORM_BUFFER,this.totalBytes,u.DYNAMIC_DRAW),this.blockIndicesBuffer=u.createBuffer(),!this.blockIndicesBuffer)throw new Error("Failed to create block-indices UBO buffer");u.bindBuffer(u.UNIFORM_BUFFER,this.blockIndicesBuffer),u.bufferData(u.UNIFORM_BUFFER,this.totalBytes,u.DYNAMIC_DRAW),u.bindBuffer(u.UNIFORM_BUFFER,null)}writeHeader(l){const u=this.headerData;u[0]=l.dataDrivenMask,u[1]=l.zoomDependentMask,u[2]=l.dataDrivenBlockSizeVec4,u[3]=l.offsets[0],u[4]=l.offsets[1],u[5]=l.offsets[2],u[6]=l.offsets[3],u[7]=l.offsets[4],u[8]=l.offsets[5],u[9]=l.offsets[6],u[10]=l.offsets[7],u[11]=l.offsets[8]}writeDataDrivenBlock(l,u,p){const x=4*p.dataDrivenBlockSizeVec4;if(x===0)return;const b=u*x;if(b+x>this.propertiesData.length)throw new Error(`UBO write out of bounds: feature index ${u} exceeds propertiesData capacity`);for(let T=0;T<9;T++)p.dataDrivenMask&1<{if(!k)return;const O=p.getUniformBlockIndex(u,T);O!==p.INVALID_INDEX&&(p.uniformBlockBinding(u,O,P),p.bindBufferBase(p.UNIFORM_BUFFER,P,k))},b=3*this.batchIndex;x("SymbolPaintPropertiesHeaderUniform",this.headerBuffer,b),x("SymbolPaintPropertiesUniform",this.propertiesBuffer,b+1),x("SymbolPaintPropertiesIndexUniform",this.blockIndicesBuffer,b+2)}destroy(){if(this.context){const l=this.context.gl;this.headerBuffer&&(l.deleteBuffer(this.headerBuffer),this.headerBuffer=null),this.propertiesBuffer&&(l.deleteBuffer(this.propertiesBuffer),this.propertiesBuffer=null),this.blockIndicesBuffer&&(l.deleteBuffer(this.blockIndicesBuffer),this.blockIndicesBuffer=null)}}};u$.HEADER_DWORDS=12,u$.HEADER_BYTES=48;let d$=u$;function h$(h,l,u,p){return[xw(255*h,255*l),xw(255*u,255*p)]}function yJ(h,l,u,p,x,b,T,k){return!!h&&(h.kind==="constant"?h.value==="none":h.kind==="composite"||h.kind==="source"?h.evaluate({zoom:0,brightness:b,worldview:k},l,u,x,p,T)==="none":typeof h=="string"&&h==="none")}Tr(d$,"SymbolPropertiesUBO",{omit:["headerBuffer","propertiesBuffer","blockIndicesBuffer"]});class f${constructor(l,u,p,x,b="",T,k){this.layer=l,this.zoom=u,this.lut=p,this.isText=x,this.propDefs=this._getPropDefs(),this.worldview=b,this.maxUniformBufferBindings=T||24,this.uboSizeDwords=k||4096,this.featureVertexRangesFromId=new Map,this.allFeatures=[],this.ubos=[],this.featureCount=0,this.cachedHeader=null,this.maxFeaturesPerBatch=0,this.propertyHashToUBOIndex=new Map,this.canDeduplicate=this._checkIfAllPropertiesAreConstant(l,x),this.cachedParams=null,this.cachedParamsNext=null,this.cachedBrightness=void 0,this.cachedConstantUniforms=null,this.cachedConstantRenderZoom=null,this.cachedConstantBrightness=void 0,this.activeAppearanceByVtIndex=new Map}_getPropDefs(){const l=this.isText?"text":"icon";return[{name:`${l}-color`,useThemeName:`${l}-color-use-theme`,isColor:!0},{name:`${l}-halo-color`,useThemeName:`${l}-halo-color-use-theme`,isColor:!0},{name:`${l}-opacity`,useThemeName:null,isColor:!1},{name:`${l}-halo-width`,useThemeName:null,isColor:!1},{name:`${l}-halo-blur`,useThemeName:null,isColor:!1},{name:`${l}-emissive-strength`,useThemeName:null,isColor:!1},{name:`${l}-occlusion-opacity`,useThemeName:null,isColor:!1},{name:"symbol-z-offset",useThemeName:null,isColor:!1},{name:`${l}-translate`,useThemeName:null,isColor:!1,isVec2:!0}]}buildHeader(){const l=this.layer.paint,u=this.propDefs;let p=0,x=0,b=0,T=0;const k=[0,0,0,0,0,0,0,0,0];for(let P=0;P<9;P++){const{name:O,isColor:$,isVec2:V}=u[P],G=l.get(O),Y=!(!G||typeof G.isConstant!="function"||G.isConstant()),X=this._appearancesHavePaintProperties(O),te=Y||X,se=!(!G||!G.value||G.value.kind!=="composite"),ae=this.layer._transitionablePaint._values[O],fe=!te&&(ae&&ae.value&&ae.value.expression&&ae.value.expression.kind)==="camera";te?(p|=1<u.hasPaintProperty(l):this.isText?u=>u.hasTextPaintProperties():u=>u.hasIconPaintProperties())}_checkIfAllPropertiesAreConstant(l,u){const p=l.paint,x=u?"text":"icon",b=[`${x}-color`,`${x}-halo-color`,`${x}-opacity`,`${x}-halo-width`,`${x}-halo-blur`,`${x}-emissive-strength`,`${x}-occlusion-opacity`,"symbol-z-offset",`${x}-translate`];for(const T of b){const k=p.get(T);if(k&&typeof k=="object"&&"isConstant"in k&&!k.isConstant())return!1}return!this._appearancesHavePaintProperties()}_hashDataDrivenValues(l,u){if(u.dataDrivenMask===0)return"";const p=[];for(let x=0;x<9;x++){if(!(u.dataDrivenMask&1<=X){hr(`Too many symbol features: batch ${G} requires binding points up to ${3*G+2}, device limit ${X}. Some features will render incorrectly.`);const se={batchIndex:0,localFeatureIndex:0,vtFeatureIndex:u,featureId:P};return this.allFeatures.push(se),P!=null&&(this.featureVertexRangesFromId.has(P)||this.featureVertexRangesFromId.set(P,[]),this.featureVertexRangesFromId.get(P).push(se)),0}this.ubos[G]||(this.ubos[G]=new d$(k,G,this.uboSizeDwords),this.ubos[G].writeHeader(O)),this.ubos[G].writeDataDrivenBlock($,Y,O);const te={batchIndex:G,localFeatureIndex:Y,vtFeatureIndex:u,featureId:P};return this.allFeatures.push(te),P!=null&&(this.featureVertexRangesFromId.has(P)||this.featureVertexRangesFromId.set(P,[]),this.featureVertexRangesFromId.get(P).push(te)),Y}updateFeatures(l,u,p,x,b,T,k){if(this.layer=u,this.cachedConstantUniforms=null,!this.cachedHeader)return;const P=this.cachedHeader;for(const O of l){const $=this.featureVertexRangesFromId.get(O);if(!$)continue;const V=T[O]||{};for(const G of $){if(!p)continue;const Y=p.feature(G.vtFeatureIndex);if(!Y)continue;const X={type:Y.type,id:O,properties:Y.properties||{},geometry:[]},te=this.activeAppearanceByVtIndex?this.activeAppearanceByVtIndex.get(G.vtFeatureIndex):void 0,se=this.evaluateAllProperties(X,V,x,b,k,void 0,te);this.ubos[G.batchIndex]&&this.ubos[G.batchIndex].writeDataDrivenBlock(se,G.localFeatureIndex,P)}}}updateDynamicExpressions(l,u,p,x,b,T){if(this.layer=l,this.cachedConstantUniforms=null,!this.cachedHeader)return;const k=this.cachedHeader;for(const P of this.allFeatures){if(!u)continue;const O=u.feature(P.vtFeatureIndex);if(!O)continue;const $=P.featureId!=null&&b[P.featureId]||{},V={type:O.type,id:P.featureId,properties:O.properties||{},geometry:[]},G=this.activeAppearanceByVtIndex?this.activeAppearanceByVtIndex.get(P.vtFeatureIndex):void 0,Y=this.evaluateAllProperties(V,$,p,x,T,void 0,G);this.ubos[P.batchIndex]&&this.ubos[P.batchIndex].writeDataDrivenBlock(Y,P.localFeatureIndex,k)}}updateFeaturePaintForAppearance(l,u,p,x,b,T,k){if(!this.layer||(this.activeAppearanceByVtIndex||(this.activeAppearanceByVtIndex=new Map),this.activeAppearanceByVtIndex.set(l,k||null),!this.cachedHeader))return!1;const P=this.cachedHeader;if(P.dataDrivenMask===0)return!1;let O=!1;for(const $ of this.allFeatures){if($.vtFeatureIndex!==l)continue;const V=this.evaluateAllProperties(u,p,x,b,T,void 0,k);this.ubos[$.batchIndex]&&(this.ubos[$.batchIndex].writeDataDrivenBlock(V,$.localFeatureIndex,P),O=!0)}return O}getConstantUniformValues(l,u){const p=this.cachedHeader,x=!(!p||!p.cameraMask);if(this.cachedConstantUniforms&&this.cachedConstantBrightness===u&&(!x||this.cachedConstantRenderZoom===l))return this.cachedConstantUniforms;const b=this.layer.paint,T=this.propDefs,k=x?new fs(l,{brightness:u,worldview:this.worldview}):null,P={type:1,id:void 0,properties:{},geometry:[]},O=G=>{const Y=T[G],X=b.get(Y.name);if(!X)return[0,0,0,1];const te=Y.useThemeName?b.get(Y.useThemeName):void 0,se=yJ(te&&typeof te!="string"?te.value:void 0,P,{},[],void 0,u,void 0,this.worldview)?null:this.lut;let ae;ae=p&&p.cameraMask&1<{const X=b.get(T[G].name);if(!X)return Y;if(p&&p.cameraMask&1<{p.text=function(x,b,T){const k=b.layout.get("text-transform").evaluate(T,{});return k==="uppercase"?x=x.toLocaleUpperCase():k==="lowercase"&&(x=x.toLocaleLowerCase()),qh.applyArabicShaping&&(x=qh.applyArabicShaping(x)),x}(p.text,l,u)}),h}const _2={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂","←":"↑","→":"↓"};function SRe(h){return h==="︶"||h==="﹈"||h==="︸"||h==="﹄"||h==="﹂"||h==="︾"||h==="︼"||h==="︺"||h==="︘"||h==="﹀"||h==="︐"||h==="︓"||h==="︔"||h==="`"||h===" ̄"||h==="︑"||h==="︒"}function TRe(h){return h==="︵"||h==="﹇"||h==="︷"||h==="﹃"||h==="﹁"||h==="︽"||h==="︻"||h==="︹"||h==="︗"||h==="︿"}const m$=4294967296,xJ=1/m$,_J=typeof TextDecoder>"u"?null:new TextDecoder("utf-8");let JP=class{constructor(h=new Uint8Array(16)){this.buf=ArrayBuffer.isView(h)?h:new Uint8Array(h),this.dataView=new DataView(this.buf.buffer),this.pos=0,this.type=0,this.length=this.buf.length}readFields(h,l,u=this.length){for(;this.pos>3,b=this.pos;this.type=7&p,h(x,l,this),this.pos===b&&this.skip(p)}return l}readMessage(h,l){return this.readFields(h,l,this.readVarint()+this.pos)}readFixed32(){const h=this.dataView.getUint32(this.pos,!0);return this.pos+=4,h}readSFixed32(){const h=this.dataView.getInt32(this.pos,!0);return this.pos+=4,h}readFixed64(){const h=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*m$;return this.pos+=8,h}readSFixed64(){const h=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*m$;return this.pos+=8,h}readFloat(){const h=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,h}readDouble(){const h=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,h}readVarint(h){const l=this.buf;let u,p;return p=l[this.pos++],u=127&p,p<128?u:(p=l[this.pos++],u|=(127&p)<<7,p<128?u:(p=l[this.pos++],u|=(127&p)<<14,p<128?u:(p=l[this.pos++],u|=(127&p)<<21,p<128?u:(p=l[this.pos],u|=(15&p)<<28,function(x,b,T){const k=T.buf;let P,O;if(O=k[T.pos++],P=(112&O)>>4,O<128||(O=k[T.pos++],P|=(127&O)<<3,O<128)||(O=k[T.pos++],P|=(127&O)<<10,O<128)||(O=k[T.pos++],P|=(127&O)<<17,O<128)||(O=k[T.pos++],P|=(127&O)<<24,O<128)||(O=k[T.pos++],P|=(1&O)<<31,O<128))return Aw(x,P,b);throw new Error("Expected varint not more than 10 bytes")}(u,h,this)))))}readVarint64(){return this.readVarint(!0)}readSVarint(){const h=this.readVarint();return h%2==1?(h+1)/-2:h/2}readBoolean(){return!!this.readVarint()}readString(){const h=this.readVarint()+this.pos,l=this.pos;return this.pos=h,h-l>=12&&_J?_J.decode(this.buf.subarray(l,h)):function(u,p,x){let b="",T=p;for(;T239?4:k>223?3:k>191?2:1;if(T+G>x)break;G===1?k<128&&(V=k):G===2?(P=u[T+1],(192&P)==128&&(V=(31&k)<<6|63&P,V<=127&&(V=null))):G===3?(P=u[T+1],O=u[T+2],(192&P)==128&&(192&O)==128&&(V=(15&k)<<12|(63&P)<<6|63&O,(V<=2047||V>=55296&&V<=57343)&&(V=null))):G===4&&(P=u[T+1],O=u[T+2],$=u[T+3],(192&P)==128&&(192&O)==128&&(192&$)==128&&(V=(15&k)<<18|(63&P)<<12|(63&O)<<6|63&$,(V<=65535||V>=1114112)&&(V=null))),V===null?(V=65533,G=1):V>65535&&(V-=65536,b+=String.fromCharCode(V>>>10&1023|55296),V=56320|1023&V),b+=String.fromCharCode(V),T+=G}return b}(this.buf,l,h)}readBytes(){const h=this.readVarint()+this.pos,l=this.buf.subarray(this.pos,h);return this.pos=h,l}readPackedVarint(h=[],l){const u=this.readPackedEnd();for(;this.pos127;);else if(l===2)this.pos=this.readVarint()+this.pos;else if(l===5)this.pos+=4;else{if(l!==1)throw new Error(`Unimplemented type: ${l}`);this.pos+=8}}writeTag(h,l){this.writeVarint(h<<3|l)}realloc(h){let l=this.length||16;for(;l268435455||h<0?function(l,u){let p,x;if(l>=0?(p=l%4294967296|0,x=l/4294967296|0):(p=~(-l%4294967296),x=~(-l/4294967296),4294967295^p?p=p+1|0:(p=0,x=x+1|0)),l>=18446744073709552e3||l<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");u.realloc(10),function(b,T,k){k.buf[k.pos++]=127&b|128,b>>>=7,k.buf[k.pos++]=127&b|128,b>>>=7,k.buf[k.pos++]=127&b|128,b>>>=7,k.buf[k.pos++]=127&b|128,k.buf[k.pos]=127&(b>>>=7)}(p,0,u),function(b,T){const k=(7&b)<<4;T.buf[T.pos++]|=k|((b>>>=3)?128:0),b&&(T.buf[T.pos++]=127&b|((b>>>=7)?128:0),b&&(T.buf[T.pos++]=127&b|((b>>>=7)?128:0),b&&(T.buf[T.pos++]=127&b|((b>>>=7)?128:0),b&&(T.buf[T.pos++]=127&b|((b>>>=7)?128:0),b&&(T.buf[T.pos++]=127&b)))))}(x,u)}(h,this):(this.realloc(4),this.buf[this.pos++]=127&h|(h>127?128:0),h<=127||(this.buf[this.pos++]=127&(h>>>=7)|(h>127?128:0),h<=127||(this.buf[this.pos++]=127&(h>>>=7)|(h>127?128:0),h<=127||(this.buf[this.pos++]=h>>>7&127))))}writeSVarint(h){this.writeVarint(h<0?2*-h-1:2*h)}writeBoolean(h){this.writeVarint(+h)}writeString(h){h=String(h),this.realloc(4*h.length),this.pos++;const l=this.pos;this.pos=function(p,x,b){for(let T,k,P=0;P55295&&T<57344){if(!k){T>56319||P+1===x.length?(p[b++]=239,p[b++]=191,p[b++]=189):k=T;continue}if(T<56320){p[b++]=239,p[b++]=191,p[b++]=189,k=T;continue}T=k-55296<<10|T-56320|65536,k=null}else k&&(p[b++]=239,p[b++]=191,p[b++]=189,k=null);T<128?p[b++]=T:(T<2048?p[b++]=T>>6|192:(T<65536?p[b++]=T>>12|224:(p[b++]=T>>18|240,p[b++]=T>>12&63|128),p[b++]=T>>6&63|128),p[b++]=63&T|128)}return b}(this.buf,h,this.pos);const u=this.pos-l;u>=128&&vJ(l,u,this),this.pos=l-1,this.writeVarint(u),this.pos+=u}writeFloat(h){this.realloc(4),this.dataView.setFloat32(this.pos,h,!0),this.pos+=4}writeDouble(h){this.realloc(8),this.dataView.setFloat64(this.pos,h,!0),this.pos+=8}writeBytes(h){const l=h.length;this.writeVarint(l),this.realloc(l);for(let u=0;u=128&&vJ(u,p,this),this.pos=u-1,this.writeVarint(p),this.pos+=p}writeMessage(h,l,u){this.writeTag(h,2),this.writeRawMessage(l,u)}writePackedVarint(h,l){l.length&&this.writeMessage(h,ERe,l)}writePackedSVarint(h,l){l.length&&this.writeMessage(h,jRe,l)}writePackedBoolean(h,l){l.length&&this.writeMessage(h,NRe,l)}writePackedFloat(h,l){l.length&&this.writeMessage(h,kRe,l)}writePackedDouble(h,l){l.length&&this.writeMessage(h,ARe,l)}writePackedFixed32(h,l){l.length&&this.writeMessage(h,CRe,l)}writePackedSFixed32(h,l){l.length&&this.writeMessage(h,IRe,l)}writePackedFixed64(h,l){l.length&&this.writeMessage(h,PRe,l)}writePackedSFixed64(h,l){l.length&&this.writeMessage(h,RRe,l)}writeBytesField(h,l){this.writeTag(h,2),this.writeBytes(l)}writeFixed32Field(h,l){this.writeTag(h,5),this.writeFixed32(l)}writeSFixed32Field(h,l){this.writeTag(h,5),this.writeSFixed32(l)}writeFixed64Field(h,l){this.writeTag(h,1),this.writeFixed64(l)}writeSFixed64Field(h,l){this.writeTag(h,1),this.writeSFixed64(l)}writeVarintField(h,l){this.writeTag(h,0),this.writeVarint(l)}writeSVarintField(h,l){this.writeTag(h,0),this.writeSVarint(l)}writeStringField(h,l){this.writeTag(h,2),this.writeString(l)}writeFloatField(h,l){this.writeTag(h,5),this.writeFloat(l)}writeDoubleField(h,l){this.writeTag(h,1),this.writeDouble(l)}writeBooleanField(h,l){this.writeVarintField(h,+l)}};function Aw(h,l,u){return u?4294967296*l+(h>>>0):4294967296*(l>>>0)+(h>>>0)}function vJ(h,l,u){const p=l<=16383?1:l<=2097151?2:l<=268435455?3:Math.floor(Math.log(l)/(7*Math.LN2));u.realloc(p);for(let x=u.pos-1;x>=h;x--)u.buf[x+p]=u.buf[x]}function ERe(h,l){for(let u=0;u=0&&p>=l&&eR[this.text.charCodeAt(p)];p--)u--;this.text=this.text.substring(l,u),this.sectionIndex=this.sectionIndex.slice(l,u)}substring(l,u){const p=new Nw;return p.text=this.text.substring(l,u),p.sectionIndex=this.sectionIndex.slice(l,u),p.sections=this.sections,p}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((l,u)=>Math.max(l,this.sections[u].scale),0)}addTextSection(l,u){this.text+=l.text,this.sections.push(v2.forText(l.scale,l.fontStack||u));const p=this.sections.length-1;for(let x=0;x=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function p$(h,l,u,p,x,b,T,k,P,O,$,V,G,Y,X,te=1,se=1){const ae=Nw.fromFeature(h,x,te,se);V===Jc.vertical&&ae.verticalizePunctuation(G);let fe=[];const ue=function(ze,He,Ve,qe,bt,jt,It=1){if(!ze)return[];const Dt=[],Pt=function(Rt,Bt,Yt,tr,br,ur,cr=1){let rr=0;for(let _r=0;_r=0;let _t=0;for(let Rt=0;Rt0&&ml>jn&&(jn=ml)}else{const so=Ve[xi.fontStack];if(!so)continue;so[_i]&&(Li=so[_i]);const Dl=He[xi.fontStack];if(!Dl)continue;const Do=Dl.glyphs[_i];if(!Do)continue;if(aa=Do.metrics,Za=_i!==8203?Ka:0,cr){const Ei=Dl.ascender!==void 0?Math.abs(Dl.ascender):0,ml=Dl.descender!==void 0?Math.abs(Dl.descender):0,io=(Ei+ml)*Ri;Ti-u/2;){if(T--,T<0)return!1;k-=h[T].dist(b),b=h[T]}k+=h[T].dist(h[T+1]),T++;const P=[];let O=0;for(;kp;)O-=P.shift().angleDelta;if(O>x)return!1;T++,k+=$.dist(V)}return!0}function CJ(h){let l=0;for(let u=0;uO){const X=(O-P)/Y,te=sn(V.x,G.x,X),se=sn(V.y,G.y,X),ae=new zp(te,se,0,G.angleTo(V),$);return!T||NJ(h,ae,k,T,l)?ae:void 0}P+=Y}}function $Re(h,l,u,p,x,b,T,k,P){const O=IJ(p,b,T),$=PJ(p,x),V=$*T,G=h[0].x===0||h[0].x===P||h[0].y===0||h[0].y===P;return l-V=0&&we=0&&Ae=0&&G+O<=$){const Ie=new zp(we,Ae,0,fe,X);p&&!NJ(h,Ie,b,p,x)||Y.push(Ie)}}V+=ae}return k||Y.length||T||(Y=RJ(h,V/2,u,p,x,b,T,!0,P)),Y}function LJ(h){let l=0,u=0;for(const T of h)l+=T.w*T.h,u=Math.max(u,T.w);h.sort((T,k)=>k.h-T.h);const p=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(l/.95)),u),h:1/0}];let x=0,b=0;for(const T of h)for(let k=p.length-1;k>=0;k--){const P=p[k];if(!(T.w>P.w||T.h>P.h)){if(T.x=P.x,T.y=P.y,b=Math.max(b,T.y+T.h),x=Math.max(x,T.x+T.w),T.w===P.w&&T.h===P.h){const O=p.pop();O&&kl.id?1:h.versionl.version?1:h.sxl.sx?1:h.syl.sy?1:0}function v$(h){let l=0;for(let u=0;u0,MJ(l,p,this.iconDescriptors,b),MJ(u,p,this.patternDescriptors,b),this.iconDescriptors.sort(rR),this.patternDescriptors.sort(rR);let T=0;const k=x?x.data:"";k&&(T=Zh(T,v$(k))),T=Zh(T,1);for(const P of this.iconDescriptors)T=Zh(T,v$(P.id)),T=Zh(T,P.version),T=Zh(T,P.sx),T=Zh(T,P.sy);T=Zh(T,1);for(const P of this.patternDescriptors)T=Zh(T,v$(P.id)),T=Zh(T,P.version),T=Zh(T,P.sx),T=Zh(T,P.sy);this.hash=T}subsetOf(l){return this.isSubsetArray(this.iconDescriptors,l.iconDescriptors,rR)&&this.isSubsetArray(this.patternDescriptors,l.patternDescriptors,rR)}isSubsetArray(l,u,p){let x=0,b=0;if(l.length>u.length)return!1;for(;x{const T=x.variant.id.toString().localeCompare(b.variant.id.toString());return T!==0?T:x.variant.sx!==b.variant.sx?x.variant.sx-b.variant.sx:x.variant.sy!==b.variant.sy?x.variant.sy-b.variant.sy:0});const p=new Map;for(const x of u)p.set(x.key,x.value);return p}class DJ{constructor(l){this.sourceAtlasHash=l}}class OJ{constructor(l,u,p,x){const b=new Map,T=new Map;this.haveRenderCallbacks=[];const k=[],P=x!==void 0,O=P?new Map:void 0,$=P?S$(l,O):l,V=P?S$(u,O):u;this.addImages($,b,1,k),this.addImages(V,T,2,k);const{w:G,h:Y}=LJ(k),X=new Xo({width:G||1,height:Y||1});for(const[te,se]of $.entries()){const ae=b.get(te).paddedRect;Xo.copy(se.data,X,{x:0,y:0},{x:ae.x+1,y:ae.y+1},se.data,null,se.sdf)}for(const[te,se]of V.entries()){const ae=T.get(te),fe=ae.paddedRect;let ue=ae.padding;const we=fe.x+ue,Ae=fe.y+ue,Ie=se.data.width,We=se.data.height;ue=ue>1?ue-1:ue,Xo.copy(se.data,X,{x:0,y:0},{x:we,y:Ae},se.data,p),Xo.copy(se.data,X,{x:0,y:We-ue},{x:we,y:Ae-ue},{width:Ie,height:ue},p),Xo.copy(se.data,X,{x:0,y:0},{x:we,y:Ae+We},{width:Ie,height:ue},p),Xo.copy(se.data,X,{x:Ie-ue,y:0},{x:we-ue,y:Ae},{width:ue,height:We},p),Xo.copy(se.data,X,{x:0,y:0},{x:we+Ie,y:Ae},{width:ue,height:We},p),Xo.copy(se.data,X,{x:Ie-ue,y:We-ue},{x:we-ue,y:Ae-ue},{width:ue,height:ue},p),Xo.copy(se.data,X,{x:0,y:We-ue},{x:we+Ie,y:Ae-ue},{width:ue,height:ue},p),Xo.copy(se.data,X,{x:0,y:0},{x:we+Ie,y:Ae+We},{width:ue,height:ue},p),Xo.copy(se.data,X,{x:Ie-ue,y:0},{x:we-ue,y:Ae+We},{width:ue,height:ue},p)}this.lut=p,this.image=X,this.iconPositions=b,this.patternPositions=T,P&&(this.contentDescriptor=new b$($,V,x,p,O))}addImages(l,u,p,x){for(const[b,T]of l.entries()){const{bin:k,imagePosition:P,imageVariant:O}=w$(b,T,p);u.set(b,P),x.push(k),T.hasRenderCallback&&this.haveRenderCallbacks.push(O.id)}}patchUpdatedImages(l,u,p,x){this.haveRenderCallbacks=this.haveRenderCallbacks.filter(b=>l.hasImage(b,p)),l.dispatchRenderCallbacks(this.haveRenderCallbacks,p);for(const b of l.getUpdatedImages(p)){for(const T of this.iconPositions.keys()){const k=Pu.parse(T);if(bc.isEqual(k.id,b)){const P=l.getImage(b,p);this.patchUpdatedImage(this.iconPositions.get(T),P,u,null)}}for(const T of this.patternPositions.keys()){const k=Pu.parse(T);if(bc.isEqual(k.id,b)){const P=l.getImage(b,p);this.patchUpdatedImage(this.patternPositions.get(T),P,u,x||this.lut)}}}}patchUpdatedImage(l,u,p,x=null){if(!l||!u||l.version===u.version)return;l.version=u.version;const[b,T]=l.tl,k=l.sdf;if(this.lut||k){const P={width:u.data.width,height:u.data.height},O=new Xo(P);Xo.copy(u.data,O,{x:0,y:0},{x:0,y:0},P,x,k),p.update(O,{position:{x:b,y:T},recreateWhenResize:!1})}else p.update(u.data,{position:{x:b,y:T},recreateWhenResize:!1})}}Tr(b2,"ImagePosition"),Tr(OJ,"ImageAtlas",{omit:["lut"]}),Tr(DJ,"ImageAtlasReference");class w2{constructor(l){this.pendingRequests=new Map,this.cachedRanges=new Map,this.useServerFontComposition=!l||l.useServerFontComposition===void 0||l.useServerFontComposition}loadGlyphRange(l,u,p,x,b){if(this.useServerFontComposition)return void w2.loadGlyphRange(l,u,p,x,b);const T=l.split(",").map(k=>k.trim()).filter(k=>k.length>0);T.length!==0?T.length!==1?this._loadMultipleFonts(T,u,p,x,b):this._loadFont(T[0],u,p,x,b):b(new Error("Empty fontstack"))}_loadMultipleFonts(l,u,p,x,b){const T=l.map(()=>null),k={completed:0,firstError:null,callbackCalled:!1},P=(O,$,V)=>{if(!k.callbackCalled&&($&&!k.firstError&&(k.firstError=$),V&&(T[O]=V),k.completed++,k.completed===l.length)){k.callbackCalled=!0;const G=T.filter(X=>X!==null);if(G.length===0)return void b(k.firstError||new Error("All fonts failed to load"));const Y=this._composeGlyphs(G);b(null,Y)}};for(let O=0;O{P(O,$,V)})}_loadFont(l,u,p,x,b){const T=`${l}:${u}`;if(this.cachedRanges.has(T)){const P=this.cachedRanges.get(T);return void Kl.frame(()=>b(null,P))}const k=this.pendingRequests.get(T);k?k.push(b):(this.pendingRequests.set(T,[b]),w2.loadGlyphRange(l,u,p,x,(P,O)=>{P||this.cachedRanges.set(T,O||null);const $=this.pendingRequests.get(T);if(this.pendingRequests.delete(T),$)for(const V of $)V(P,O)}))}_composeGlyphs(l){const u={};let p,x;for(const b of l)if(p===void 0&&b.ascender!==void 0&&(p=b.ascender),x===void 0&&b.descender!==void 0&&(x=b.descender),b.glyphs)for(const T in b.glyphs)u[T]===void 0&&(u[T]=b.glyphs[T]);return{glyphs:u,ascender:p,descender:x}}}w2.loadGlyphRange=function(h,l,u,p,x){const b=256*l,T=b+255,k=p.transformRequest(p.normalizeGlyphsURL(u).replace("{fontstack}",h).replace("{range}",`${b}-${T}`),k0.Glyphs);Zg(k,(P,O)=>{if(P)x(P);else if(O){const $={},V=function(G){return new JP(G).readFields(LRe,{})}(O);for(const G of V.glyphs)$[G.id]=G;x(null,{glyphs:$,ascender:V.ascender,descender:V.descender})}})};const S2=1e20;function FJ(h,l,u,p,x,b,T,k,P){for(let O=l;O-1);P++,b[P]=k,T[P]=O,T[P+1]=S2}for(let k=0,P=0;k{if(T){x.ascender=T.ascender,x.descender=T.descender;for(const k in T.glyphs)this._doesCharSupportLocalGlyph(+k)||(x.glyphs[+k]=T.glyphs[+k]);x.ranges[u]=!0}for(const k of x.requests[u]||[])k(b,T);delete x.requests[u]}))}getGlyphs(l,u){const p=[],x=this.url||Vn.GLYPHS_URL;for(const b in l)for(const T of l[b])p.push({stack:b,id:T});et(p,({stack:b,id:T},k)=>{let P=this.entries[b];P||(P=this.entries[b]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let O=P.glyphs[T];if(O!==void 0)return void k(null,{stack:b,id:T,glyph:O});if(O=this._tinySDF(P,b,T),O)return P.glyphs[T]=O,void k(null,{stack:b,id:T,glyph:O});const $=Math.floor(T/256);if(256*$>65535)return hr("glyphs > 65535 not supported"),void k(null,{stack:b,id:T,glyph:O});if(P.ranges[$])return void k(null,{stack:b,id:T,glyph:O});let V=P.requests[$];V||(V=P.requests[$]=[],this.glyphLoader.loadGlyphRange(b,$,x,this.requestManager,(G,Y)=>{if(Y){P.ascender=Y.ascender,P.descender=Y.descender;for(const X in Y.glyphs)this._doesCharSupportLocalGlyph(+X)||(P.glyphs[+X]=Y.glyphs[+X]);P.ranges[$]=!0}for(const X of V)X(G,Y);delete P.requests[$]})),V.push((G,Y)=>{G?k(G):Y&&k(null,{stack:b,id:T,glyph:Y.glyphs[T]||null})})},(b,T)=>{if(b)u(b);else if(T){const k={};for(const{stack:P,id:O,glyph:$}of T)k[P]===void 0&&(k[P]={}),k[P].glyphs===void 0&&(k[P].glyphs={}),k[P].glyphs[O]=$&&{id:$.id,bitmap:$.bitmap.clone(),metrics:$.metrics},k[P].ascender=this.entries[P].ascender,k[P].descender=this.entries[P].descender;u(null,k)}})}_doesCharSupportLocalGlyph(l){return this.localGlyphMode!==T$.none&&(this.localGlyphMode===T$.all?!!this.localFontFamily:!!this.localFontFamily&&(tw(l)||gj(l)||s_(l)||kp(l)||n_(l)||mj(l)||(u=l)>=131072&&u<=173791||(p=>p>=66736&&p<=66815)(l)));var u}_tinySDF(l,u,p){const x=this.localFontFamily;if(!x||!this._doesCharSupportLocalGlyph(p))return;let b=l.tinySDF;if(!b){let se="400";/bold/i.test(u)?se="900":/medium/i.test(u)?se="500":/light/i.test(u)&&(se="200"),b=l.tinySDF=new nR.TinySDF({fontFamily:x,fontWeight:se,fontSize:48,buffer:6,radius:16}),b.fontWeight=se}const T=b.fontWeight;if(this.localGlyphs[T][p])return this.localGlyphs[T][p];const k=String.fromCodePoint(p),{data:P,width:O,height:$,glyphWidth:V,glyphHeight:G,glyphLeft:Y,glyphTop:X,glyphAdvance:te}=b.draw(k);return this.localGlyphs[T][p]={id:p,bitmap:new Sy({width:O,height:$},P),metrics:{width:V/2,height:G/2,left:Y/2,top:X/2-27,advance:te/2,localGlyph:!0}}}}function $J(h,l){return h+l[1]-l[0]}function E$(h,l,u,p,x=1){const b=[],T=h.imagePrimary,k=T.pixelRatio,P=T.paddedRect.w-2,O=T.paddedRect.h-2,$=(h.right-h.left)*x,V=(h.bottom-h.top)*x,G=T.stretchX||[[0,P]],Y=T.stretchY||[[0,O]],X=G.reduce($J,0),te=Y.reduce($J,0),se=P-X,ae=O-te;let fe=0,ue=X,we=0,Ae=te,Ie=0,We=se,ze=0,He=ae;if(T.content&&p){const qe=T.content;fe=sR(G,0,qe[0]),we=sR(Y,0,qe[1]),ue=sR(G,qe[0],qe[2]),Ae=sR(Y,qe[1],qe[3]),Ie=qe[0]-fe,ze=qe[1]-we,We=qe[2]-qe[0]-ue,He=qe[3]-qe[1]-Ae}const Ve=(qe,bt,jt,It)=>{const Dt=iR(qe.stretch-fe,ue,$,h.left*x),Pt=aR(qe.fixed-Ie,We,qe.stretch,X),Ht=iR(bt.stretch-we,Ae,V,h.top*x),_t=aR(bt.fixed-ze,He,bt.stretch,te),Rt=iR(jt.stretch-fe,ue,$,h.left*x),Bt=aR(jt.fixed-Ie,We,jt.stretch,X),Yt=iR(It.stretch-we,Ae,V,h.top*x),tr=aR(It.fixed-ze,He,It.stretch,te),br=new Ft(Dt,Ht),ur=new Ft(Rt,Ht),cr=new Ft(Rt,Yt),rr=new Ft(Dt,Yt),_r=new Ft(Pt/k,_t/k),Pr=new Ft(Bt/k,tr/k),Wr=l*Math.PI/180;if(Wr){const jn=Math.sin(Wr),Ti=Math.cos(Wr),ms=[Ti,-jn,jn,Ti];br._matMult(ms),ur._matMult(ms),rr._matMult(ms),cr._matMult(ms)}const Mr=qe.stretch+qe.fixed,fn=jt.stretch+jt.fixed,Wn=bt.stretch+bt.fixed,mn=It.stretch+It.fixed,es=h.imageSecondary;return{tl:br,tr:ur,bl:rr,br:cr,texPrimary:{x:T.paddedRect.x+1+Mr,y:T.paddedRect.y+1+Wn,w:fn-Mr,h:mn-Wn},texSecondary:es?{x:es.paddedRect.x+1+Mr,y:es.paddedRect.y+1+Wn,w:fn-Mr,h:mn-Wn}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:_r,pixelOffsetBR:Pr,minFontScaleX:We/k/$,minFontScaleY:He/k/V,isSDF:u}};if(T.stretchX||T.stretchY){const qe=zJ(G,se,X),bt=zJ(Y,ae,te);for(let jt=0;jt0?[fe,-ue]:we<0?[-fe,ue]:fe===0?[ue,fe]:[ue,-fe]}(u);let Y=Math.abs(l.top-l.bottom);for(const ae of l.positionedLines)Y-=ae.lineOffset;const X=l.positionedLines.length,te=Y/X;let se=l.top-u[1];for(let ae=0;aeb)&&(b=X.x),(!Y||X.y>T)&&(T=X.y)}const P=Math.min(b-p,T-x);let O=P/2;const $=new U0([],qRe);if(P===0)return new Ft(p,x);for(let Y=p;YV.d||!V.d)&&(V=Y,u&&console.log("found best %d after %d probes",Math.round(1e4*Y.d)/1e4,G)),Y.max-V.d<=l||(O=Y.h/2,$.push(new Iw(Y.p.x-O,Y.p.y-O,O,h)),$.push(new Iw(Y.p.x+O,Y.p.y-O,O,h)),$.push(new Iw(Y.p.x-O,Y.p.y+O,O,h)),$.push(new Iw(Y.p.x+O,Y.p.y+O,O,h)),G+=4)}return u&&(console.log(`num probes: ${G}`),console.log(`best distance: ${V.d}`)),V.p}function qRe(h,l){return l.max-h.max}nR.TinySDF=class{constructor({fontSize:h=24,buffer:l=3,radius:u=8,cutoff:p=.25,fontFamily:x="sans-serif",fontWeight:b="normal",fontStyle:T="normal",lang:k=null}={}){this.buffer=l,this.cutoff=p,this.radius=u,this.lang=k;const P=this.size=h+4*l,O=this._createCanvas(P),$=this.ctx=O.getContext("2d",{willReadFrequently:!0});$.font=`${T} ${b} ${h}px ${x}`,$.textBaseline="alphabetic",$.textAlign="left",$.fillStyle="black",this.gridOuter=new Float64Array(P*P),this.gridInner=new Float64Array(P*P),this.f=new Float64Array(P),this.z=new Float64Array(P+1),this.v=new Uint16Array(P)}_createCanvas(h){const l=document.createElement("canvas");return l.width=l.height=h,l}draw(h){const{width:l,actualBoundingBoxAscent:u,actualBoundingBoxDescent:p,actualBoundingBoxLeft:x,actualBoundingBoxRight:b}=this.ctx.measureText(h),T=Math.ceil(u),k=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(b-x))),P=Math.min(this.size-this.buffer,T+Math.ceil(p)),O=k+2*this.buffer,$=P+2*this.buffer,V=Math.max(O*$,0),G=new Uint8ClampedArray(V),Y={data:G,width:O,height:$,glyphWidth:k,glyphHeight:P,glyphTop:T,glyphLeft:0,glyphAdvance:l};if(k===0||P===0)return Y;const{ctx:X,buffer:te,gridInner:se,gridOuter:ae}=this;this.lang&&(X.lang=this.lang),X.clearRect(te,te,k,P),X.fillText(h,te,te+T);const fe=X.getImageData(te,te,k,P);ae.fill(S2,0,V),se.fill(0,0,V);for(let ue=0;ue0?We*We:0,se[Ie]=We<0?We*We:0}}FJ(ae,0,0,O,$,O,this.f,this.v,this.z),FJ(se,te,te,k,P,O,this.f,this.v,this.z);for(let ue=0;ueb.y!=te.y>b.y&&b.x<(te.x-X.x)*(b.y-X.y)/(te.y-X.y)+X.x&&(k=!k),P=Math.min(P,eh(b,X,te))}}return(k?1:-1)*Math.sqrt(P)}(this.p,x),this.max=this.d+this.h*Math.SQRT2}}const GRe=Object.keys,j$=Number.POSITIVE_INFINITY,HRe=Math.sqrt(2);function ky(h,l,u,p,x,b){const T=y$(h)&&h.collisionPadding?h.collisionPadding:[0,0,0,0],k={top:h.top-T[1],bottom:h.bottom+T[3],left:h.left-T[0],right:h.right+T[2],scaled:!1};return p!==void 0&&function(P,O){P.top*=O,P.bottom*=O,P.left*=O,P.right*=O,P.scaled=!0}(k,p),b&&(k.left+=b[0],k.right+=b[0],k.top+=b[1],k.bottom+=b[1]),u&&function(P,O,$){if(!O)return;const V=Xn(O),G=new Ft($?$[0]:0,$?$[1]:0),Y=new Ft(P.left,P.top),X=new Ft(P.right,P.top),te=new Ft(P.left,P.bottom),se=new Ft(P.right,P.bottom);Y._rotateAround(V,G),X._rotateAround(V,G),te._rotateAround(V,G),se._rotateAround(V,G),P.left=Math.min(Y.x,X.x,te.x,se.x),P.right=Math.max(Y.x,X.x,te.x,se.x),P.top=Math.min(Y.y,X.y,te.y,se.y),P.bottom=Math.max(Y.y,X.y,te.y,se.y)}(k,u,x),l?{top:Math.min(l.top,k.top),bottom:Math.max(l.bottom,k.bottom),left:Math.min(l.left,k.left),right:Math.max(l.right,k.right),scaled:l.scaled||k.scaled}:k}function qJ(h,[l,u]){let p=0,x=0;if(u===j$){l<0&&(l=0);const b=l/HRe;switch(h){case"top-right":case"top-left":x=b-7;break;case"bottom-right":case"bottom-left":x=7-b;break;case"bottom":x=7-l;break;case"top":x=l-7}switch(h){case"top-right":case"bottom-right":p=-b;break;case"top-left":case"bottom-left":p=b;break;case"left":p=l;break;case"right":p=-l}}else{switch(l=Math.abs(l),u=Math.abs(u),h){case"top-right":case"top-left":case"top":x=u-7;break;case"bottom-right":case"bottom-left":case"bottom":x=7-u}switch(h){case"top-right":case"bottom-right":case"right":p=-l;break;case"top-left":case"bottom-left":case"left":p=l}}return[p,x]}function WRe(h,l,u,p,x,b,T,k,P,O,$,V,G,Y,X){const te=h.layers[0],se=te.appearances;if(se.length===0)return{iconBBox:null,iconVerticalBBox:null,textBBox:null,textVerticalBBox:null};const ae={iconBBox:null,iconVerticalBBox:null},fe={textBBox:null,textVerticalBBox:null},{baseIconRotate:ue,baseTextRotate:we,iconScaleFactor:Ae}=function(We,ze,He){const Ve=We.get("icon-rotate").evaluate(ze,{},He),qe=We.get("text-rotate").evaluate(ze,{},He),[bt,jt]=We.get("icon-size-scale-range");return{baseIconRotate:Ve,baseTextRotate:qe,iconScaleFactor:pe(1,bt,jt)}}(p,x,b);l&&(ae.iconBBox=ky(l,ae.iconBBox,ue),u)&&(ae.iconVerticalBBox=ky(u,ae.iconVerticalBBox,ue+90));const Ie=lR(V.horizontal);Ie&&(fe.textBBox=ky(Ie,fe.textBBox,we,1,Y)),V.vertical&&(fe.textVerticalBBox=ky(V.vertical,fe.textVerticalBBox,we+90,1,Y));for(const We of se)We.hasIconLayoutProperties()&&KRe(ae,h,te,We,x,b,k,ue,T,P,l,O,Ae,$,X),We.hasTextLayoutProperties()&&YRe(fe,te,We,x,b,Y,we,G,Ie,V.vertical);return{iconBBox:ae.iconBBox,iconVerticalBBox:ae.iconVerticalBBox,textBBox:fe.textBBox,textVerticalBBox:fe.textVerticalBBox}}function KRe(h,l,u,p,x,b,T,k,P,O,$,V,G,Y,X){const{appearanceIconOffset:te,appearanceIconRotate:se,appearanceIconSize:ae}=GJ(p,u,x,b,T,k,P,O.iconScaleFactor);let fe=null,ue=null,we=null;p.hasLayoutProperty("icon-image")?we=function(Ie,We,ze,He,Ve,qe,bt,jt){let It=null;const Dt=We.getAppearanceValueAndResolveTokens(ze,"icon-image",He,Ve,jt);if(Dt){const Pt=Ie.getResolvedImageFromTokens(Dt),Ht=ze.hasLayoutProperty("icon-size")?ze.getUnevaluatedLayoutProperty("icon-size"):We._unevaluatedLayout._values["icon-size"],_t=T2(Pt,E_(Ie.zoom,Ht,Ie.worldview,jt),Ht,Ve,Ie.zoom,He,Ie.pixelRatio,bt,Ie.worldview,jt);It=qe.get(_t.iconPrimary.toString())}return It}(l,u,p,x,b,V,G,X):$&&(we=$.imagePrimary),we&&(fe=tR(we,null,te,Y),l.allowVerticalPlacement&&(ue=tR(we,null,te,Y)));const Ae=P>0?ae/P:1;fe&&(h.iconBBox=ky(fe,h.iconBBox,se,Ae!==1?Ae:void 0)),ue&&(h.iconVerticalBBox=ky(ue,h.iconVerticalBBox,se+90,Ae!==1?Ae:void 0))}function GJ(h,l,u,p,x,b,T,k){const P=h.hasLayoutProperty("icon-offset")?l.getAppearanceValueAndResolveTokens(h,"icon-offset",u,p,[]):null,O=P&&Array.isArray(P)?P:x,$=h.hasLayoutProperty("icon-rotate")?l.getAppearanceValueAndResolveTokens(h,"icon-rotate",u,p,[]):null,V=typeof $=="number"?$:b,G=h.hasLayoutProperty("icon-size")?l.getAppearanceValueAndResolveTokens(h,"icon-size",u,p,[]):null;return{appearanceIconOffset:O,appearanceIconRotate:V,appearanceIconSize:typeof G=="number"?G*k:T}}function YRe(h,l,u,p,x,b,T,k,P,O){const{appearanceTextOffset:$,appearanceTextRotate:V,appearanceTextSize:G}=HJ(u,l,p,x,b,T,k),Y=G/k,X=[($[0]-b[0])*Y,($[1]-b[1])*Y],te=X[0]!==0||X[1]!==0;P&&(h.textBBox=ky(P,h.textBBox,V,Y,$,te?X:void 0)),O&&(h.textVerticalBBox=ky(O,h.textVerticalBBox,V+90,Y,$,te?X:void 0))}function HJ(h,l,u,p,x,b,T){const k=h.hasLayoutProperty("text-offset")?l.getAppearanceValueAndResolveTokens(h,"text-offset",u,p,[]):null,P=k&&Array.isArray(k)?[k[0]*Ka,k[1]*Ka]:x,O=h.hasLayoutProperty("text-rotate")?l.getAppearanceValueAndResolveTokens(h,"text-rotate",u,p,[]):null,$=typeof O=="number"?O:b,V=h.hasLayoutProperty("text-size")?l.getAppearanceValueAndResolveTokens(h,"text-size",u,p,[]):null;return{appearanceTextOffset:P,appearanceTextRotate:$,appearanceTextSize:typeof V=="number"?V:T}}function oR(h,l,u,p,x,b,T,k,P){if(!l||!l.usvg)return;const O=AJ(p),$=AJ(x),V=b!=="both"&&b!=="width"||!jJ(p)?1:$.width/O.width,G=b!=="both"&&b!=="height"||!kJ(p)?1:$.height/O.height;u.scaleSelf(V,G);const Y=u.toString();T.set(Y,u),k.set(Y,l);const{imagePosition:X}=w$(Y,l,1);P.set(Y,X)}function WJ(h,l,u,p,x,b,T,k,P,O){if(!h)return;const $=function(V,G,Y,X,te,se,ae){if(V.kind==="camera")return V.maxSize;if(V.kind==="composite"){const fe=G.possiblyEvaluate(new fs(V.maxZoom,{worldview:se}),Y,ae).evaluate(te,{},Y,ae),ue=G.possiblyEvaluate(new fs(V.minZoom,{worldview:se}),Y,ae).evaluate(te,{},Y,ae);return Math.max(fe,ue)}return G.possiblyEvaluate(new fs(X,{worldview:se}),Y,ae).evaluate(te,{},Y,ae)}(l,u,p,x,b,P,O);return h.scaleSelf($*k*T)}function T2(h,l,u,p,x,b,T,k,P,O){return{iconPrimary:WJ(h.getPrimary(),l,u,p,x,b,T,k,P,O),iconSecondary:WJ(h.getSecondary(),l,u,p,x,b,T,k,P,O)}}function ZRe(h,l,u){if(!l)return;const p=u.get(h.toString()),x=u.get(l.toString());p&&x&&(p.paddedRect.w===x.paddedRect.w&&p.paddedRect.h===x.paddedRect.h||hr(`Mismatch in icon variant sizes: ${h.toString()} and ${l.toString()}`),p.usvg!==x.usvg&&hr(`Mismatch in icon variant image types: ${h.id} and ${l.id}`))}function KJ(h,l,u,p){if(!h)return;const x=l.get(u.toString());if(x&&(h.imagePrimary=x),p){const b=l.get(p.toString());h.imageSecondary=b}}function XRe(h,l){for(const u in h.horizontal)YJ(h.horizontal[u],l);YJ(h.vertical,l)}function YJ(h,l){if(h){for(const u of h.positionedLines)for(const p of u.positionedGlyphs)if(p.image!==null){const x=p.image.toString();p.rect=l.get(x).paddedRect}}}function k$(h){switch(h){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function QRe(h,l,u,p,x,b,T,k,P){const O=lR(b.horizontal)||b.vertical,$=u.get("icon-text-fit-padding").evaluate(p,{},x);let V,G=l;return l&&P!=="none"&&(h.allowVerticalPlacement&&b.vertical&&(V=x$(l,b.vertical,P,$,k,T)),O&&(G=x$(l,O,P,$,k,T))),{defaultShapedIcon:G,verticallyShapedIcon:V}}function ZJ(h,l){return h*l/24}function JRe(h,l,u,p,x,b,T,k,P,O,$,V,G,Y,X,te,se,ae,fe,ue,we,Ae,Ie,We){let ze=T.textMaxSize.evaluate(l,{},G);ze===void 0?ze=k*T.textScaleFactor:ze*=T.textScaleFactor;const He=h.layers[0].layout,Ve=ZJ(k,T.textScaleFactor),qe=lR(u.horizontal)||u.vertical,bt=h.hasAnyAppearanceLayoutProperty(["text-size","text-offset","text-rotate"]),jt=h.getAppearanceFeatureData(l.index);(se!=="none"||bt)&&jt&&(jt.textShaping=qe,jt.iconTextFitPadding=He.get("icon-text-fit-padding").evaluate(l,{},G),jt.fontScale=Ve,jt.textScaleFactor=T.textScaleFactor);const It=Y.name==="globe",Dt=h.tilePixelRatio*ze/24,Pt=(tr=h.overscaling,h.zoom>18&&tr>2&&(tr>>=1),Math.max(fr/(512*tr),1)*He.get("symbol-spacing")),Ht=He.get("text-padding")*h.tilePixelRatio,_t=He.get("icon-padding")*h.tilePixelRatio,Rt=Xn(He.get("text-max-angle")),Bt=He.get("icon-rotation-alignment")==="map"&&ue!=="point",Yt=Pt/2;var tr;h.hasAnyIconTextFit===!1&&se!=="none"&&(h.hasAnyIconTextFit=!0);const br=l.properties?+l.properties[bn]:null,ur=br&&h.elevationFeatureIdToIndex?h.elevationFeatureIdToIndex.get(br):65535,cr=(rr,_r,Pr)=>{if(_r.x<0||_r.x>=fr||_r.y<0||_r.y>=fr)return;let Wr=null;if(It){const{x:Mr,y:fn,z:Wn}=Y.projectTilePoint(_r.x,_r.y,Pr);Wr={anchor:new zp(Mr,fn,Wn,0,void 0),up:Y.upVector(Pr,_r.x,_r.y)}}(function(Mr,fn,Wn,mn,es,jn,Ti,ms,ns,$s,xi,Ya,_i,Ri,aa,Li,Mo,Za,An,Ml,qi,so,Dl,Do,Ei,ml,io,jR,Bw,Xl,X$,$w){const Up=Mr.addToLineVertexArray(fn,mn);let Vp,fd,md,I_,zw,Rn,ao,Mi=0,Fa=0,pd=0,eu=0,tu=-1,ru=-1;const nh={};let kR=Hf("");const ef=Wn?Wn.anchor:fn,Uw=jR!=="none";let Vw=0,Ta=0;if(ns._unevaluatedLayout.getValue("text-radial-offset")===void 0){const Gi=ns.layout.get("text-offset").evaluate(qi,{},Ei);Vw=Gi[0]*Ka,Ta=Gi[1]*Ka}else Vw=ns.layout.get("text-radial-offset").evaluate(qi,{},Ei)*Ka,Ta=j$;if(Mr.allowVerticalPlacement&&es.vertical){const Gi=es.vertical;if(aa)Rn=C$(Gi),ms&&(ao=C$(ms));else{const Ol=ns.layout.get("text-rotate").evaluate(qi,{},Ei)+90;md=cR($s,ef,fn,xi,Ya,_i,Gi,Ri,Ol,Li,$w),ms&&(I_=cR($s,ef,fn,xi,Ya,_i,ms,Za,Ol,null,X$))}}if(jn){const Gi=ns.layout.get("icon-rotate").evaluate(qi,{},Ei),Ol=E$(jn,Gi,Dl,Uw,so.iconScaleFactor),Ql=ms?E$(ms,Gi,Dl,Uw,so.iconScaleFactor):void 0;fd=cR($s,ef,fn,xi,Ya,_i,jn,Za,Gi,null,Xl);const ih=function(tf,B2,qw,mMe,pMe,yte,xte,gMe,lQt,J$){const _te=tf.layers[0],vte=_te.appearances;let Gw=B2.length;if(qw&&(Gw=Math.max(Gw,qw.length)),vte.length===0)return Gw;const[yMe,xMe]=mMe.get("icon-size-scale-range"),_Me=pe(1,yMe,xMe);for(const IR of vte)if(IR.hasLayoutProperty("icon-image")){const bte=_te.getAppearanceValueAndResolveTokens(IR,"icon-image",yte,xte,J$);if(bte){const wte=tf.getResolvedImageFromTokens(bte);if(wte){const Ste=IR.hasLayoutProperty("icon-size")?IR.getUnevaluatedLayoutProperty("icon-size"):pMe._values["icon-size"],vMe=T2(wte,E_(tf.zoom,Ste,tf.worldview,J$),Ste,xte,tf.zoom,yte,tf.pixelRatio,_Me,tf.worldview,J$),Tte=gMe.get(vMe.iconPrimary.toString());Tte&&(Gw=Math.max(Gw,zRe(Tte)))}}}return Gw}(Mr,Ol,Ql,ns.layout,ns._unevaluatedLayout,qi,Ei,Mr.iconAtlasPositions,0,Do);Mi=4*ih;const AR=ns.layout.get("icon-size").evaluate(qi,{},Ei,Do),NR=so.compositeIconSizes?so.compositeIconSizes[0].evaluate(qi,{},Ei,Do):0,Q$=so.compositeIconSizes?so.compositeIconSizes[1].evaluate(qi,{},Ei,Do):0,CR=N$(Mr.layerIds[0],Mr.iconSizeData,AR,so.iconScaleFactor,NR,Q$);Mr.addSymbols(Mr.icon,Ol,CR,Ml,An,qi,void 0,Wn,fn,Up.lineStartIndex,Up.lineLength,-1,Do,Ei,ml,io,Mr.symbolInstances.length,ih),tu=Mr.icon.placedSymbolArray.length-1,Ql&&(Fa=4*ih,Mr.addSymbols(Mr.icon,Ql,CR,Ml,An,qi,Jc.vertical,Wn,fn,Up.lineStartIndex,Up.lineLength,-1,Do,Ei,ml,io,Mr.symbolInstances.length,ih),ru=Mr.icon.placedSymbolArray.length-1)}for(const Gi in es.horizontal){const Ol=Gi,Ql=es.horizontal[Ol];Vp||(kR=Hf(Ql.text),aa?zw=C$(Ql):Vp=cR($s,ef,fn,xi,Ya,_i,Ql,Ri,ns.layout.get("text-rotate").evaluate(qi,{},Ei),Li,$w));const ih=Ql.positionedLines.length===1;if(pd+=XJ(Mr,Wn,fn,Ql,Ti,ns,aa,qi,Li,Up,es.vertical?Jc.horizontal:Jc.horizontalOnly,ih?GRe(es.horizontal):[Ol],nh,tu,so,Do,Ei,Mr.symbolInstances.length,ml),ih)break}es.vertical&&(eu+=XJ(Mr,Wn,fn,es.vertical,Ti,ns,aa,qi,Li,Up,Jc.vertical,["vertical"],nh,ru,so,Do,Ei,Mr.symbolInstances.length,ml));let fa=-1;const Ba=(Gi,Ol)=>Gi?Math.max(Gi,Ol):Ol;fa=Ba(zw,fa),fa=Ba(Rn,fa),fa=Ba(ao,fa);const sh=fa>-1?1:0;Mr.glyphOffsetArray.length>=65535&&hr("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),qi.sortKey!==void 0&&Mr.addToSortKeyRanges(Mr.symbolInstances.length,qi.sortKey),Mr.symbolInstances.emplaceBack(fn.x,fn.y,ef.x,ef.y,ef.z,nh.right>=0?nh.right:-1,nh.center>=0?nh.center:-1,nh.left>=0?nh.left:-1,nh.vertical>=0?nh.vertical:-1,tu,ru,kR,Vp!==void 0?Vp:Mr.collisionBoxArray.length,Vp!==void 0?Vp+1:Mr.collisionBoxArray.length,md!==void 0?md:Mr.collisionBoxArray.length,md!==void 0?md+1:Mr.collisionBoxArray.length,fd!==void 0?fd:Mr.collisionBoxArray.length,fd!==void 0?fd+1:Mr.collisionBoxArray.length,I_||Mr.collisionBoxArray.length,I_?I_+1:Mr.collisionBoxArray.length,xi,pd,eu,Mi,Fa,sh,0,Vw,Ta,fa,0,Uw?1:0,Bw)})(h,_r,Wr,rr,u,p,b,x,h.layers[0],h.collisionBoxArray,l.index,l.sourceLayerIndex,h.index,Ht,fe,O,0,_t,Bt,ae,l,T,$,V,G,X,te,se,ur,we,Ae,Ie)};if(ue==="line")for(const rr of UP(l.geometry,0,0,fr,fr)){const _r=$Re(rr,Pt,Rt,u.vertical||qe,p,24,Dt,h.overscaling,fr);for(const Pr of _r)qe&&eLe(h,qe.text,Yt,Pr)||cr(rr,Pr,G)}else if(ue==="line-center"){for(const rr of l.geometry)if(rr.length>1){const _r=BRe(rr,Rt,u.vertical||qe,p,24,Dt);_r&&cr(rr,_r,G)}}else if(l.type==="Polygon")for(const rr of a2(l.geometry,0)){const _r=VRe(rr,16);cr(rr[0],new zp(_r.x,_r.y,0,0,void 0),G)}else if(l.type==="LineString")for(const rr of l.geometry)cr(rr,new zp(rr[0].x,rr[0].y,0,0,void 0),G);else if(l.type==="Point")for(const rr of l.geometry)for(const _r of rr)cr([_r],new zp(_r.x,_r.y,0,0,void 0),G)}const A$=255,j_=A$*$p;function XJ(h,l,u,p,x,b,T,k,P,O,$,V,G,Y,X,te,se,ae,fe){const ue=VJ(0,p,P,b,T,k,x,h.allowVerticalPlacement,void 0,X.textScaleFactor),we=b.layout.get("text-size").evaluate(k,{},se),Ae=X.compositeTextSizes?X.compositeTextSizes[0].evaluate(k,{},se):0,Ie=X.compositeTextSizes?X.compositeTextSizes[1].evaluate(k,{},se):0,We=N$(h.layerIds[0],h.textSizeData,we,X.textScaleFactor,Ae,Ie);h.addSymbols(h.text,ue,We,P,T,k,$,l,u,O.lineStartIndex,O.lineLength,Y,te,se,fe,!1,ae,ue.length);for(const ze of V)G[ze]=h.text.placedSymbolArray.length-1;return 4*ue.length}function N$(h,l,u,p,x,b){const T=l;let k=null;return T.kind==="source"?(k=[$p*u*p],k[0]>j_&&hr(`${h}: Value for "text-size" is >= ${A$}. Reduce your "text-size".`)):T.kind==="composite"&&(k=[$p*x*p,$p*b*p],(k[0]>j_||k[1]>j_)&&hr(`${h}: Value for "text-size" is >= ${A$}. Reduce your "text-size".`)),k}function lR(h){for(const l in h)return h[l];return null}function cR(h,l,u,p,x,b,T,k,P,O,$){let V,G,Y,X;if(V=$?$.top:T.top,G=$?$.bottom:T.bottom,Y=$?$.left:T.left,X=$?$.right:T.right,y$(T)&&T.collisionPadding){const te=T.collisionPadding;Y-=te[0],V-=te[1],X+=te[2],G+=te[3]}if(P){const te=new Ft(Y,V),se=new Ft(X,V),ae=new Ft(Y,G),fe=new Ft(X,G),ue=Xn(P);let we=new Ft(0,0);O&&(we=new Ft(O[0],O[1])),te._rotateAround(ue,we),se._rotateAround(ue,we),ae._rotateAround(ue,we),fe._rotateAround(ue,we),Y=Math.min(te.x,se.x,ae.x,fe.x),X=Math.max(te.x,se.x,ae.x,fe.x),V=Math.min(te.y,se.y,ae.y,fe.y),G=Math.max(te.y,se.y,ae.y,fe.y)}return h.emplaceBack(l.x,l.y,l.z,u.x,u.y,Y,V,X,G,k,p,x,b),h.length-1}function C$(h){y$(h)&&h.collisionPadding&&(h.top-=h.collisionPadding[1],h.bottom+=h.collisionPadding[3]);const l=h.bottom-h.top;return l>0?Math.max(10,l):null}function eLe(h,l,u,p){const x=h.compareText;if(l in x){const b=x[l];for(let T=b.length-1;T>=0;T--)if(p.dist(b[T])ue&&(we(Ie,It,ze,He,bt,jt),we(It,We,bt,jt,Ve,qe))}we(V,G,p,b,x,b),we(G,Y,x,b,x,T),we(Y,X,x,T,p,T),we(X,V,p,T,p,b),te-=ue,se-=ue,ae+=ue,fe+=ue;const Ae=1/Math.max(ae-te,fe-se);return{scale:Ae,x:te*Ae,y:se*Ae,x2:ae*Ae,y2:fe*Ae,projection:l}}function JJ(h,{x:l,y:u},p=0){return new Ft(((l-p)*h.scale-h.x)*fr,(u*h.scale-h.y)*fr)}const tLe=I(new Float32Array(16));class Ay{constructor(l){this.spec=l,this.name=l.name,this.wrap=!1,this.requiresDraping=!1,this.supportsWorldCopies=!1,this.supportsTerrain=!1,this.supportsFog=!1,this.supportsFreeCamera=!1,this.zAxisUnit="meters",this.isReprojectedInTileSpace=!0,this.unsupportedLayers=["custom"],this.center=[0,0],this.range=[3.5,7]}project(l,u){return{x:0,y:0,z:0}}unproject(l,u){return new Je(0,0)}projectTilePoint(l,u,p){return{x:l,y:u,z:0}}locationPoint(l,u,p,x=!0){return l._coordinatePoint(l.locationCoordinate(u,p),x)}pixelsPerMeter(l,u){return ut(1,l)*u}pixelSpaceConversion(l,u,p){return 1}farthestPixelDistance(l){return QJ(l,l.pixelsPerMeter)}pointCoordinate(l,u,p,x){const b=l.horizonLineFromTop(!1),T=new Ft(u,Math.max(b,p));return l.rayIntersectionCoordinate(l.pointRayIntersection(T,x))}pointCoordinate3D(l,u,p){const x=new Ft(u,p);if(l.elevation)return l.elevation.pointCoordinate(x);{const b=this.pointCoordinate(l,x.x,x.y,0);return[b.x,b.y,b.z]}}isPointAboveHorizon(l,u){if(l.elevation&&l.elevation.visibleDemTiles.length)return!this.pointCoordinate3D(l,u.x,u.y);const p=l.horizonLineFromTop();return u.y0?u<-Pw+p&&(u=-Pw+p):u>Pw-p&&(u=Pw-p);const T=b/Math.pow(dR(u),x);let k=T*Math.sin(x*l),P=b-T*Math.cos(x*l);return k=.5*(k/Math.PI+.5),P=.5*(P/Math.PI+.5),{x:k,y:this.southernCenter?P:1-P,z:0}}unproject(l,u){l=(2*l-.5)*Math.PI,this.southernCenter&&(u=1-u),u=(2*(1-u)-.5)*Math.PI;const{n:p,f:x}=this,b=x-u,T=Math.sign(b),k=Math.sign(p)*Math.sqrt(l*l+b*b);let P=Math.atan2(l,Math.abs(b))*T;b*p<0&&(P-=Math.PI*Math.sign(l)*T);const O=pe(Ma(P/p)+this.center[0],-180,180),$=pe(Ma(2*Math.atan(Math.pow(x/k,1/p))-Pw),-85.051129,Nt);return new Je(O,this.southernCenter?-$:$)}}class eee extends Ay{constructor(l){super(l),this.wrap=!0,this.supportsWorldCopies=!0,this.supportsTerrain=!0,this.supportsFog=!0,this.supportsFreeCamera=!0,this.isReprojectedInTileSpace=!1,this.unsupportedLayers=[],this.range=null}project(l,u){return{x:Ot(l),y:Ut(u),z:0}}unproject(l,u){const p=st(l),x=vt(u);return new Je(p,x)}}const tee=Xn(Nt);class aLe extends Ay{project(l,u){const p=(u=Xn(u))*u,x=p*p;return{x:.5*((l=Xn(l))*(.8707-.131979*p+x*(x*(.003971*p-.001529*x)-.013791))/Math.PI+.5),y:1-.5*(u*(1.007226+p*(.015085+x*(.028874*p-.044475-.005916*x)))/Math.PI+1),z:0}}unproject(l,u){l=(2*l-.5)*Math.PI;let p=u=(2*(1-u)-1)*Math.PI,x=25,b=0,T=p*p;do{T=p*p;const O=T*T;b=(p*(1.007226+T*(.015085+O*(.028874*T-.044475-.005916*O)))-u)/(1.007226+T*(.045255+O*(.259866*T-.311325-.005916*11*O))),p=pe(p-b,-tee,tee)}while(Math.abs(b)>1e-6&&--x>0);T=p*p;const k=pe(Ma(l/(.8707+T*(T*(T*T*T*(.003971-.001529*T)-.013791)-.131979))),-180,180),P=Ma(p);return new Je(k,P)}}const ree=Xn(Nt);class oLe extends Ay{project(l,u){u=Xn(u),l=Xn(l);const p=Math.cos(u),x=2/Math.PI,b=Math.acos(p*Math.cos(l/2)),T=Math.sin(b)/b,k=.5*(l*x+2*p*Math.sin(l/2)/T)||0,P=.5*(u+Math.sin(u)/T)||0;return{x:.5*(k/Math.PI+.5),y:1-.5*(P/Math.PI+1),z:0}}unproject(l,u){let p=l=(2*l-.5)*Math.PI,x=u=(2*(1-u)-1)*Math.PI,b=25;const T=1e-6;let k=0,P=0;do{const O=Math.cos(x),$=Math.sin(x),V=2*$*O,G=$*$,Y=O*O,X=Math.cos(p/2),te=Math.sin(p/2),se=2*X*te,ae=te*te,fe=1-Y*X*X,ue=fe?1/fe:0,we=fe?Math.acos(O*X)*Math.sqrt(1/fe):0,Ae=.5*(2*we*O*te+2*p/Math.PI)-l,Ie=.5*(we*$+x)-u,We=.5*ue*(Y*ae+we*O*X*G)+1/Math.PI,ze=ue*(se*V/4-we*$*te),He=.125*ue*(V*te-we*$*Y*se),Ve=.5*ue*(G*X+we*ae*O)+.5,qe=ze*He-Ve*We;k=(Ie*ze-Ae*Ve)/qe,P=(Ae*He-Ie*We)/qe,p=pe(p-k,-Math.PI,Math.PI),x=pe(x-P,-ree,ree)}while((Math.abs(k)>T||Math.abs(P)>T)&&--b>0);return new Je(Ma(p),Ma(x))}}class nee extends Ay{constructor(l){super(l),this.center=l.center||[0,0],this.parallels=l.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(Xn(this.parallels[0]))),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0}project(l,u){const{scale:p,cosPhi:x}=this;return{x:Xn(l)*x*p+.5,y:-Math.sin(Xn(u))/x*p+.5,z:0}}unproject(l,u){const{scale:p,cosPhi:x}=this,b=-(u-.5)/p,T=pe(Ma((l-.5)/p)/x,-180,180),k=Math.asin(pe(b*x,-1,1)),P=pe(Ma(k),-85.051129,Nt);return new Je(T,P)}}class lLe extends eee{constructor(l){super(l),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug"],this.range=[3,5]}projectTilePoint(l,u,p){const x=Jj(l,u,p);return or(x,x,e2(am(p))),{x:x[0],y:x[1],z:x[2]}}locationPoint(l,u,p){const x=Be(u.lat,u.lng),b=ft([],x),T=p?l._centerAltitude+p:l.elevation?l.elevation.getAtPointOrZero(l.locationCoordinate(u),l._centerAltitude):l._centerAltitude;Ze(x,x,b,ut(1,0)*fr*T);const k=I(new Float64Array(16));return D(k,l.pixelMatrix,l.globeMatrix),or(x,x,k),new Ft(x[0],x[1])}pixelsPerMeter(l,u){return ut(1,0)*u}pixelSpaceConversion(l,u,p){const x=ut(1,l)*u,b=sn(ut(1,45)*u,x,p);return this.pixelsPerMeter(l,u)/b}createTileMatrix(l,u,p){const x=TB(am(p.canonical));return D(new Float64Array(16),l.globeMatrix,x)}createInversionMatrix(l,u){const{center:p}=l,x=e2(am(u));return H(x,x,Xn(p.lng)),q(x,x,Xn(p.lat)),U(x,x,[l._pixelsPerMercatorPixel,l._pixelsPerMercatorPixel,1]),Float32Array.from(x)}pointCoordinate(l,u,p,x){return _X(l,u,p,!0)||new Ir(0,0)}pointCoordinate3D(l,u,p){const x=this.pointCoordinate(l,u,p,0);return[x.x,x.y,x.z]}isPointAboveHorizon(l,u){return!_X(l,u.x,u.y,!1)}farthestPixelDistance(l){const u=function(x,b){const T=x.cameraToCenterDistance,k=x._centerAltitude*b,P=x._camera,O=x._camera.forward(),$=me([],Ue([],O,-T),[0,0,k]),V=x.worldSize/(2*Math.PI),G=[0,0,-V],Y=x.width/x.height,X=Math.tan(x.fovAboveCenter),te=Ue([],P.up(),X),se=Ue([],P.right(),X*Y),ae=ft([],me([],me([],O,te),se)),fe=[];let ue;if(new Mn($,ae).closestPointOnSphere(G,V,fe)){const we=me([],fe,G),Ae=qr([],we,$);ue=Math.cos(x.fovAboveCenter)*Le(Ae)}else{const we=qr([],$,G),Ae=qr([],G,$);ft(Ae,Ae);const Ie=Le(we)-V;ue=Math.sqrt(Ie*(Ie+2*V));const We=Math.acos(ue/(V+Ie))-Math.acos(kt(O,Ae));ue*=Math.cos(We)}return 1.01*ue}(l,this.pixelsPerMeter(l.center.lat,l.worldSize)),p=Op(l.zoom);if(p>0){const x=QJ(l,ut(1,l.center.lat)*l.worldSize),b=l.worldSize/(2*Math.PI),T=Math.max(l.width,l.height)/l.worldSize*Math.PI;return sn(u,x+b*(1-Math.cos(T)),Math.pow(p,10))}return u}upVector(l,u,p){return Jj(u,p,l,1)}upVectorScale(l){return{metersToTile:TP(jP(am(l)))}}}function see(h){const l=h.parallels,u=!!l&&Math.abs(l[0]+l[1])<.01;switch(h.name){case"mercator":return new eee(h);case"equirectangular":return new sLe(h);case"naturalEarth":return new aLe(h);case"equalEarth":return new nLe(h);case"winkelTripel":return new oLe(h);case"albers":return u?new nee(h):new rLe(h);case"lambertConformalConic":return u?new nee(h):new iLe(h);case"globe":return new lLe(h)}throw new Error(`Invalid projection name: ${h.name}`)}class cLe{constructor(l,u){this.lastParams=null,this.lastAllFeaturesIndex=-2,this.appearancesVersion=u,this.appearances=l;const p=l.map(x=>function(b){if(!b.condition)return{featureDependent:!1,stateDependent:!1,zoomDependent:!1,pitchDependent:!1,brightnessDependent:!1,worldviewDependent:!1};const T=b.condition.expression;return{featureDependent:!Sp(T),stateDependent:!oy(T),zoomDependent:!Kd(T,["zoom"]),pitchDependent:!Kd(T,["pitch"]),brightnessDependent:!Kd(T,["brightness","measure-light"]),worldviewDependent:!Kd(T,["worldview"])}}(x));this.anyFeatureDependent=p.some(x=>x.featureDependent),this.anyStateDependent=p.some(x=>x.stateDependent)}update(l,u){const p=this.lastParams,x=!p||p.zoom!==l.zoom||p.pitch!==(l.pitch||0)||p.brightness!==(l.brightness||0)||p.worldview!==l.worldview;this.lastParams={zoom:l.zoom,pitch:l.pitch||0,brightness:l.brightness||0,worldview:l.worldview};const b=u&&this.anyStateDependent;if(!x&&!b&&this.lastAllFeaturesIndex!==-2)return{kind:"no-changes"};if(!this.anyFeatureDependent&&!b){const T=this.evaluateAllFeatures(l);return T===this.lastAllFeaturesIndex?{kind:"no-changes"}:(this.lastAllFeaturesIndex=T,{kind:"all-features",appearanceIndex:T})}return{kind:"per-feature"}}evaluateAllFeatures(l){for(let u=0;u{for(let x=0;xT-k),b=new Map;for(const T of x){const k=p.get(T);b.set(T,new Os(k))}return u&&(this.cachedBatchIndices=x,this.cachedBatchSegments=b),{batchIndices:x,batchSegments:b}}snapshotSymbolVertexData(l,u){const p=l*Lw;return this.layoutVertexArray.uint16.slice(p,p+u*Lw)}restoreSymbolVertexData(l,u){this.layoutVertexArray.uint16.set(u,l*Lw)}updateSymbolVertexData(l,u,p,x,b,T,k,P,O,$,V,G,Y){const X=this.layoutVertexArray.uint16,te=l*Lw;X[te]=u,X[te+1]=p,X[te+2]=x,X[te+3]=b,X[te+4]=T,X[te+5]=k,X[te+6]=P,X[te+7]=O,X[te+8]=$,X[te+9]=V,X[te+10]=G,X[te+11]=Y}upload(l,u,p,x,b,T){this.isEmpty()||(p&&(this.cachedBatchIndices=null,this.cachedBatchSegments=null,this.layoutVertexBuffer=l.createVertexBuffer(this.layoutVertexArray,hRe.members,!!T),this.indexBuffer=l.createIndexBuffer(this.indexArray,u),this.dynamicLayoutVertexBuffer=l.createVertexBuffer(this.dynamicLayoutVertexArray,mRe.members,!0),this.opacityVertexBuffer=l.createVertexBuffer(this.opacityVertexArray,dLe,!0),this.iconTransitioningVertexArray.length>0&&(this.iconTransitioningVertexBuffer=l.createVertexBuffer(this.iconTransitioningVertexArray,xRe.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=l.createVertexBuffer(this.globeExtVertexArray,fRe.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||b)&&(this.zOffsetVertexBuffer=l.createVertexBuffer(this.zOffsetVertexArray,pRe.members,!0)),!this.orientationVertexBuffer&&this.orientationVertexArray&&this.orientationVertexArray.length>0&&(this.orientationVertexBuffer=l.createVertexBuffer(this.orientationVertexArray,yRe.members,!0)),this.opacityVertexBuffer.itemSize=1,this.featureIdArray&&this.featureIdArray.length>0&&(this.featureIdBuffer=l.createVertexBuffer(this.featureIdArray,gRe.members,!1))),(p||x)&&(this.programConfigurations.upload(l),this.uboBinder&&this.uboBinder.upload(l)))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy(),this.iconTransitioningVertexBuffer&&this.iconTransitioningVertexBuffer.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy(),this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy(),this.orientationVertexBuffer&&this.orientationVertexBuffer.destroy(),this.featureIdBuffer&&this.featureIdBuffer.destroy(),this.uboBinder&&this.uboBinder.destroy())}}Tr(I$,"SymbolBuffers",{omit:["cachedBatchIndices","cachedBatchSegments"]});class P${constructor(l,u,p){this.layoutVertexArray=new l,this.layoutAttributes=u,this.indexArray=new p,this.segments=new Os,this.collisionVertexArray=new h_,this.collisionVertexArrayExt=new Wh}upload(l){this.layoutVertexBuffer=l.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=l.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=l.createVertexBuffer(this.collisionVertexArray,_Re.members,!0),this.collisionVertexBufferExt=l.createVertexBuffer(this.collisionVertexArrayExt,vRe.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}Tr(P$,"CollisionBuffers");class Xh{constructor(l){this.collisionBoxArray=l.collisionBoxArray,this.zoom=l.zoom,this.overscaling=l.overscaling,this.layers=l.layers,this.layerIds=this.layers.map(T=>T.fqid),this.index=l.index,this.pixelRatio=l.pixelRatio,this.sourceLayerIndex=l.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.hasAnyIconTextFit=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=I([]),this.placementViewportMatrix=I([]);const u=this.layers[0]._unevaluatedLayout._values;this.worldview=l.worldview,this.localizable=l.localizable,this.maxUniformBufferBindings=l.maxUniformBufferBindings,this.maxUniformBlockSizeDwords=l.maxUniformBlockSizeDwords,this.disableSymbolUBO=l.disableSymbolUBO,this.textSizeData=E_(this.zoom,u["text-size"],this.worldview,l.availableImages),this.iconSizeData=E_(this.zoom,u["icon-size"],this.worldview,l.availableImages);const p=this.layers[0].layout,x=p.get("symbol-sort-key"),b=p.get("symbol-z-order");this.lut=l.lut,this.canOverlap=p.get("text-allow-overlap")||p.get("icon-allow-overlap")||p.get("text-ignore-placement")||p.get("icon-ignore-placement"),this.sortFeaturesByKey=b!=="viewport-y"&&x.constantOr(1)!==void 0,this.sortFeaturesByY=(b==="viewport-y"||b==="auto"&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=p.get("text-writing-mode").map(T=>Jc[T]),this.stateDependentLayerIds=this.layers.filter(T=>T.isStateDependent()).map(T=>T.id),this.sourceID=l.sourceID,this.projection=l.projection,this.hasAnyZOffset=!1,this.zOffsetSortDirty=!1,this.zOffsetBuffersNeedUpload=!1,this.elevationType="none",this.elevationStateComplete=!1,this.activeReplacements=[],this.replacementUpdateTime=0,this.hasAnySecondaryIcon=!1,this.hasAppearances=null,this.featureAppearances=null,this.featureAppearanceData=new Map}hasAnyAppearanceLayoutProperty(l){const u=this.layers[0].getAppearances();if(!u||u.length===0)return!1;const p=Array.isArray(l)?l:[l];return u.some(x=>p.some(b=>x.hasLayoutProperty(b)))}getAppearanceFeatureData(l){return this.featureAppearanceData.get(l)}createArrays(){this.text=new I$(new ie(this.layers,{zoom:this.zoom,lut:this.lut},l=>l.startsWith("text")||l.startsWith("symbol"))),this.icon=new I$(new ie(this.layers,{zoom:this.zoom,lut:this.lut},l=>l.startsWith("icon")||l.startsWith("symbol"))),this.disableSymbolUBO||(this.text.uboBinder=new f$(this.layers[0],this.zoom,this.lut,!0,"",this.maxUniformBufferBindings,this.maxUniformBlockSizeDwords),this.icon.uboBinder=new f$(this.layers[0],this.zoom,this.lut,!1,"",this.maxUniformBufferBindings,this.maxUniformBlockSizeDwords)),this.glyphOffsetArray=new xP,this.lineVertexArray=new p_,this.symbolInstances=new yP}calculateGlyphDependencies(l,u,p,x,b){for(const T of l){const k=T.codePointAt(0);if(k===void 0)break;if(u[k]=!0,x&&b&&k<=65535){const P=_2[T];P&&(u[P.charCodeAt(0)]=!0)}}}calculateEffectiveAppearanceIconSize(l,u,p,x,b,T,k){if(!l.hasLayoutProperty("icon-size"))return k*T;let P=1;const O=l.getUnevaluatedLayoutProperty("icon-size"),$=E_(this.zoom,O,this.worldview,b),V=Cw($,u);if($.kind!=="constant"&&$.kind!=="camera"||(P=V.uSize),$.kind==="composite"){const{minZoom:G,maxZoom:Y}=$,X=O.possiblyEvaluate(new fs(G,{worldview:this.worldview}),x),te=O.possiblyEvaluate(new fs(Y,{worldview:this.worldview}),x),se=X.evaluate(p,{},x,b);P=se+(te.evaluate(p,{},x,b)-se)*V.uSizeT}return $.kind==="source"&&(P=O.possiblyEvaluate(new fs(this.zoom,{worldview:this.worldview}),x).evaluate(p,{},x,b)),P*T}updateFootprints(l,u){}updateReplacement(l,u){if(u.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=u.updateTime;const p=u.getReplacementRegionsForTile(l.toUnwrapped(),!0);return!DP(this.activeReplacements,p)&&(this.activeReplacements=p,!0)}getResolvedImageFromTokens(l){return typeof l=="string"?Yl.build(l):l}populate(l,u,p,x){const b=this.layers[0],T=b.layout,k=this.projection.name==="globe",P=T.get("text-font"),O=T.get("text-field"),$=T.get("icon-image"),[V,G]=T.get("icon-size-scale-range"),Y=pe(u.scaleFactor||1,V,G),[X,te]=T.get("text-size-scale-range"),se=pe(u.scaleFactor||1,X,te),ae=(O.value.kind!=="constant"||O.value.value instanceof Ko&&!O.value.value.isEmpty()||O.value.value.toString().length>0)&&(P.value.kind!=="constant"||P.value.value.length>0),fe=$.value.kind!=="constant"||!!$.value.value||Object.keys($.parameters).length>0,ue=this.hasAnyAppearanceLayoutProperty("icon-image"),we=T.get("symbol-sort-key");if(this.features=[],this.featureAppearanceData=new Map,!ae&&!fe&&!ue)return;const Ae=u.iconDependencies,Ie=u.glyphDependencies,We=u.availableImages,ze=new fs(this.zoom,{worldview:this.worldview,activeFloors:u.activeFloors}),He=Ve=>{const qe=Ve.id.toString();Ae.has(qe)?Ae.get(qe).push(Ve):Ae.set(qe,[Ve])};for(const Ve of l){const{feature:qe,id:bt,index:jt,sourceLayerIndex:It}=Ve,Dt=b._featureFilter.needGeometry,Pt=En(qe,Dt);if(!b._featureFilter.filter(ze,Pt,p))continue;if(Dt||(Pt.geometry=Kr(qe,p,x)),k&&qe.type!==1&&p.z<=5){const ur=Pt.geometry,cr=.98078528056,rr=(_r,Pr)=>kt(Jj(_r.x,_r.y,p,1),Jj(Pr.x,Pr.y,p,1)){if(!ur.getLayoutProperty("icon-image"))return;const cr=this.getCombinedIconPrimary(ur,Rt,Pt,p,We,tr,Y);cr&&He(cr)}),Ht){const ur=P.evaluate(Pt,{},p).join(","),cr=T.get("text-rotation-alignment")==="map"&&T.get("symbol-placement")!=="point";this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(Jc.vertical)>=0;for(const rr of Ht.sections)if(rr.image){const _r=rr.image.getPrimary().scaleSelf(this.pixelRatio*se),Pr=_r.id.toString(),Wr=Ae.get(Pr)||[];Wr.push(_r),Ae.set(Pr,Wr)}else{const _r=bj(Ht.toString()),Pr=rr.fontStack||ur,Wr=Ie[Pr]=Ie[Pr]||{};this.calculateGlyphDependencies(rr.text,Wr,cr,this.allowVerticalPlacement,_r)}}}if(T.get("symbol-placement")==="line"&&(this.features=function(Ve){const qe={},bt={},jt=[];let It=0;function Dt(Rt){jt.push(Ve[Rt]),It++}function Pt(Rt,Bt,Yt){const tr=bt[Rt];return delete bt[Rt],bt[Bt]=tr,jt[tr].geometry[0].pop(),jt[tr].geometry[0]=jt[tr].geometry[0].concat(Yt[0]),tr}function Ht(Rt,Bt,Yt){const tr=qe[Bt];return delete qe[Bt],qe[Rt]=tr,jt[tr].geometry[0].shift(),jt[tr].geometry[0]=Yt[0].concat(jt[tr].geometry[0]),tr}function _t(Rt,Bt,Yt){const tr=Yt?Bt[0][Bt[0].length-1]:Bt[0][0];return`${Rt}:${tr.x}:${tr.y}`}for(let Rt=0;RtRt.geometry)}(this.features)),T.get("symbol-elevation-reference")==="hd-road-markup"){if(this.elevationType="road",u.elevationFeatures){!this.elevationFeatures&&u.elevationFeatures.length>0&&(this.elevationFeatures=[],this.elevationFeatureIdToIndex=new Map);for(const Ve of u.elevationFeatures)this.elevationFeatureIdToIndex.set(Ve.id,this.elevationFeatures.length),this.elevationFeatures.push(Ve)}}else T.get("symbol-z-elevate")&&(this.elevationType="offset");this.elevationType!=="none"&&(this.zOffsetBuffersNeedUpload=!0),this.sortFeaturesByKey&&this.features.sort((Ve,qe)=>Ve.sortKey-qe.sortKey)}getCombinedIconPrimary(l,u,p,x,b,T,k){let P,O;if(l.hasLayoutProperty("icon-image")){const $=u.getAppearanceValueAndResolveTokens(l,"icon-image",p,x,b);P=this.getResolvedImageFromTokens($)}else{const $=u.getValueAndResolveTokens("icon-image",p,x,b);P=this.getResolvedImageFromTokens($)}if(P){const $=l.hasLayoutProperty("icon-size")?l.getUnevaluatedLayoutProperty("icon-size"):u._unevaluatedLayout._values["icon-size"];O=T2(P,E_(this.zoom,$,this.worldview,b),$,x,this.zoom,T,this.pixelRatio,k,this.worldview,b).iconPrimary}return O}updateSymbolInstanceIconVertices(l,u,p,x,b,T){const{canonical:k,availableImages:P,globalProperties:O,layer:$,iconScaleFactor:V,featureState:G,layoutIconOffset:Y,layoutIconSize:X,layoutIconRotate:te}=T;if(l.placedIconSymbolIndex<0)return{vertexOffsetDelta:0,hasChanges:!1};if(u.activeAppearanceIndex===p)return{vertexOffsetDelta:l.numIconVertices,hasChanges:!1};const se=p>=0?$.appearances[p]:null;if(se){const ae=this.getCombinedIconPrimary(se,$,x,k,P,{sortKey:void 0,text:void 0,icon:null,index:l.featureIndex,sourceLayerIndex:l.featureIndex,geometry:[],properties:u.properties,type:"Point",id:u.id},V);if(!ae)return{vertexOffsetDelta:0,hasChanges:!1};const fe=ae.toString(),ue=this.iconAtlasPositions&&this.iconAtlasPositions.get(fe);if(ue){const{appearanceIconOffset:we,appearanceIconRotate:Ae}=GJ(se,$,x,k,Y,te,X,V);let Ie=tR(ue,void 0,we,$.layout.get("icon-anchor").evaluate(x,G,k));const We=ue.sdf,ze=$.layout.get("icon-text-fit").constantOr("none");ze!=="none"&&u.textShaping&&u.iconTextFitPadding&&u.fontScale&&(Ie=x$(Ie,u.textShaping,ze,u.iconTextFitPadding,we,u.fontScale));const He=this.calculateEffectiveAppearanceIconSize(se,O.zoom,x,k,P,V,X),Ve=0,qe=1+(Math.min(j_,Math.round(He*$p))<<1),bt=E$(Ie,Ae,We,ze!=="none",V);u.isUsingAppearanceIconVertexData||(u.isUsingAppearanceIconVertexData=!0,u.layoutBasedIconVertexData=this.icon.snapshotSymbolVertexData(b,l.numIconVertices));const jt=Math.floor(l.numIconVertices/4),It=Math.min(bt.length,jt);let Dt=b;for(let Ht=0;Ht0||l.numVerticalGlyphVertices>0;if(!we)return{vertexOffsetDelta:we?l.numHorizontalGlyphVertices+l.numVerticalGlyphVertices:0,hasChanges:!1};if(u.activeAppearanceIndex===p)return{vertexOffsetDelta:l.numHorizontalGlyphVertices+l.numVerticalGlyphVertices,hasChanges:!1};const Ae=p>=0?P.appearances[p]:null;if(Ae&&u.textShaping){const{appearanceTextOffset:Ie,appearanceTextRotate:We,appearanceTextSize:ze}=HJ(Ae,P,x,k,G,X,Y);u.fontScale=ZJ(ze,u.textScaleFactor);const He=Ae.getUnevaluatedLayoutProperty("text-size");let Ve=this.textSizeData,qe=ae,bt=fe;Ae.hasLayoutProperty("text-size")&&(Ve=E_(this.zoom,He,this.worldview,ue),qe=this.textSizeData.kind==="composite"?this.textSizeData.minZoom:0,bt=this.textSizeData.kind==="composite"?this.textSizeData.maxZoom:0);const jt=u.textShaping.bottom-G[1],It=u.textShaping.left-G[0],Dt=u.textShaping.right-G[0];u.textShaping.top=Ie[1]+(u.textShaping.top-G[1]),u.textShaping.bottom=Ie[1]+jt,u.textShaping.left=Ie[0]+It,u.textShaping.right=Ie[0]+Dt;const Pt=VJ(0,u.textShaping,Ie,P,!1,x,$,this.allowVerticalPlacement,We),Ht=ze&&Ve.kind==="composite"?He.possiblyEvaluate(new fs(qe,{}),k).evaluate(x,V,k):te,_t=ze&&Ve.kind==="composite"?He.possiblyEvaluate(new fs(bt,{}),k).evaluate(x,V,k):se,Rt=N$(Ae.name,Ve,ze,O,Ht,_t),Bt=Array.isArray(Rt)?Rt[1]:ze,Yt=0,tr=1+(Math.min(j_,Math.round(Bt*$p))<<1);u.isUsingAppearanceTextVertexData||(u.isUsingAppearanceTextVertexData=!0,u.layoutBasedTextVertexData=this.text.snapshotSymbolVertexData(b,l.numHorizontalGlyphVertices+l.numVerticalGlyphVertices));for(let br=0;br0){const O=new Set(Object.keys(l).map($=>{const V=Number($);return!isNaN(V)&&Number.isSafeInteger(V)&&String(V)===$?V:$}));this.text.uboBinder&&this.text.uboBinder.updateFeatures(O,b[0],u,P,p,l,k),this.icon.uboBinder&&this.icon.uboBinder.updateFeatures(O,b[0],u,P,p,l,k)}}}updateRoadElevation(l){if(this.elevationType!=="road"||!this.elevationFeatures||this.elevationStateComplete)return;this.elevationStateComplete=!0,this.hasAnyZOffset=!1;let u=!1;const p=zt(l),x=1/p;let b=!1,T=!1;for(let k=0;k0||G>0,se=Y>0,ae=this.elevationFeatures[P.elevationFeatureIndex];if(ae){const fe=new Ft(P.tileAnchorX,P.tileAnchorY),ue=.075+ae.pointElevation(fe);P.zOffset!==ue&&(u=!0,P.zOffset=ue),ue!==0&&(this.hasAnyZOffset=!0);const we=ae.computeSlopeNormal(fe,x),Ae=$i(At(),Se(0,0,1),we);rn(O,O,Ae),rn($,$,Ae),O[2]*=p,$[2]*=p,O[0]===1&&O[1]===0&&O[2]===0&&$[0]===0&&$[1]===1&&$[2]===0||(b=b||te,T=T||se)}if(te&&(hR(this.text.orientationVertexArray,V,O,$),hR(this.text.orientationVertexArray,G,O,$)),se){const{placedIconSymbolIndex:fe,verticalPlacedIconSymbolIndex:ue}=P;fe>=0&&hR(this.icon.orientationVertexArray,Y,O,$),ue>=0&&hR(this.icon.orientationVertexArray,X,O,$)}}b||(this.text.orientationVertexArray=void 0),T||(this.icon.orientationVertexArray=void 0),u&&(this.zOffsetBuffersNeedUpload=!0,this.zOffsetSortDirty=!0)}updateZOffset(){const l=(b,T,k)=>{p+=T,p>b.length&&b.resize(p);for(let P=-T;P<0;P++)b.emplace(P+p,k)},u=(b,T,k)=>{x+=T,x>b.length&&b.resize(x);for(let P=-T;P<0;P++)b.emplace(P+x,k)};if(!this.zOffsetBuffersNeedUpload)return;this.zOffsetBuffersNeedUpload=!1;let p=0,x=0;for(let b=0;b0;if((k>0||P>0)&&(l(this.text.zOffsetVertexArray,k,$),l(this.text.zOffsetVertexArray,P,$)),V){const{placedIconSymbolIndex:G,verticalPlacedIconSymbolIndex:Y}=T;G>=0&&u(this.icon.zOffsetVertexArray,O,$),Y>=0&&u(this.icon.zOffsetVertexArray,T.numVerticalIconVertices,$)}}this.text.zOffsetVertexBuffer&&this.text.zOffsetVertexBuffer.updateData(this.text.zOffsetVertexArray),this.icon.zOffsetVertexBuffer&&this.icon.zOffsetVertexBuffer.updateData(this.icon.zOffsetVertexArray)}isEmpty(){return this.symbolInstances.length===0&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(l,u,p,x,b){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(l),this.iconCollisionBox.upload(l)),this.text.upload(l,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload,this.hasAppearances),this.hasAppearances===null&&(this.hasAppearances=this.layers.some(T=>T.appearances&&T.appearances.length>0)),this.icon.upload(l,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload,this.hasAppearances),this.uploaded=!0}updateAppearances(l,u,p,x,b,T=!1){const k={hasLayoutChanges:!1,hasUboChanges:!1};if(!l||!p||!this.featureAppearanceData)return k;const P=u||{},O=this.icon.layoutVertexArray&&this.icon.layoutVertexArray.length>0&&this.icon.layoutVertexArray.arrayBuffer,$=this.text.layoutVertexArray&&this.text.layoutVertexArray.length>0&&this.text.layoutVertexArray.arrayBuffer;if(!O&&!$)return k;const V=this.layers[0],G=V.layout;this.featureAppearances&&this.featureAppearances.appearancesVersion===V.appearancesVersion||(this.featureAppearances=new cLe(V.appearances,V.appearancesVersion));const Y=this.featureAppearances.update(x,T);if(Y.kind==="no-changes")return k;let X=1,te=0,se=!1,ae=!1;if(O){const[Ie,We]=G.get("icon-size-scale-range");X=pe(1,Ie,We)}let fe=1,ue=0,we=!1;if($){const[Ie,We]=G.get("text-size-scale-range");fe=pe(1,Ie,We)}const Ae=new Map;if(b&&p)for(const Ie of p){const We=b.getImage(Ie,V.scope);if(We){const ze=new Pu(Ie.toString());Ae.set(ze.toString(),We)}}for(let Ie=0;IeDt.isActive({globals:x,feature:qe,canonical:l,featureState:Ve})):-1;bt=It>=0?It:-1}const jt=ze.activeAppearanceIndex!==bt;if($){const It=G.get("text-size"),Dt=this.textSizeData.kind==="composite"?this.textSizeData.minZoom:0,Pt=this.textSizeData.kind==="composite"?this.textSizeData.maxZoom:0,Ht={canonical:l,layer:V,featureState:Ve,availableImages:p,textScaleFactor:fe,imageMap:Ae,layoutTextOffset:G.get("text-offset").evaluate(qe,Ve,l).map(Rt=>Rt*Ka),layoutTextSize:It.evaluate(qe,Ve,l),layoutTextRotate:G.get("text-rotate").evaluate(qe,Ve,l),layoutMinZoomSize:It.evaluate(qe,{zoom:Dt},l),layoutMaxZoomSize:It.evaluate(qe,{zoom:Pt},l),layoutTextSizeMinZoom:Dt,layoutTextSizeMaxZoom:Pt},_t=this.updateSymbolInstanceTextVertices(We,ze,bt,qe,ue,Ht);ue+=_t.vertexOffsetDelta,we=we||_t.hasChanges}if(O){const It={canonical:l,layer:V,featureState:Ve,availableImages:p,globalProperties:x,iconScaleFactor:X,layoutIconOffset:G.get("icon-offset").evaluate(qe,Ve,l),layoutIconSize:G.get("icon-size").evaluate(qe,Ve,l,p),layoutIconRotate:G.get("icon-rotate").evaluate(qe,Ve,l)},Dt=this.updateSymbolInstanceIconVertices(We,ze,bt,qe,te,It);te+=Dt.vertexOffsetDelta,se=se||Dt.hasChanges}if(jt){const It=We.featureIndex,Dt=x?x.brightness:null,Pt=Ve||{},Ht=bt>=0?V.appearances[bt]:null;this.text.uboBinder&&(this.text.uboBinder.layer=V,ae=this.text.uboBinder.updateFeaturePaintForAppearance(It,qe,Pt,l,p,Dt,Ht)||ae),this.icon.uboBinder&&(this.icon.uboBinder.layer=V,ae=this.icon.uboBinder.updateFeaturePaintForAppearance(It,qe,Pt,l,p,Dt,Ht)||ae)}ze.activeAppearanceIndex=bt}return se&&this.icon.layoutVertexBuffer&&this.icon.layoutVertexArray.arrayBuffer!==null&&this.icon.layoutVertexArray.length===this.icon.layoutVertexBuffer.length&&this.icon.layoutVertexBuffer.updateData(this.icon.layoutVertexArray),we&&this.text.layoutVertexBuffer&&this.text.layoutVertexArray.arrayBuffer!==null&&this.text.layoutVertexArray.length===this.text.layoutVertexBuffer.length&&this.text.layoutVertexBuffer.updateData(this.text.layoutVertexArray),{hasLayoutChanges:se||we,hasUboChanges:ae}}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}getProjection(){return this.projectionInstance||(this.projectionInstance=see(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(l,u){const p=this.lineVertexArray.length;if(l.segment!==void 0)for(const{x,y:b}of u)this.lineVertexArray.emplaceBack(x,b);return{lineStartIndex:p,lineLength:this.lineVertexArray.length-p}}addSymbols(l,u,p,x,b,T,k,P,O,$,V,G,Y,X,te,se,ae,fe){const ue=l.indexArray,we=l.layoutVertexArray,Ae=l.globeExtVertexArray,Ie=fe,We=l.uboBinder?l.uboBinder.getCurrentBatchIndex():void 0,ze=l.segments.prepareSegment(4*Ie,we,ue,this.canOverlap?T.sortKey:void 0,We),He=this.glyphOffsetArray.length,Ve=ze.vertexLength,qe=this.allowVerticalPlacement&&k===Jc.vertical?Math.PI/2:0,bt=T.text&&T.text.sections;let jt=we.length,It=-1;for(let Ht=0;Ht=0)){const Ht=4*Dt;for(let _t=0;_t=0?u.rightJustifiedTextSymbolIndex:u.centerJustifiedTextSymbolIndex>=0?u.centerJustifiedTextSymbolIndex:u.leftJustifiedTextSymbolIndex>=0?u.leftJustifiedTextSymbolIndex:u.verticalPlacedTextSymbolIndex>=0?u.verticalPlacedTextSymbolIndex:x),T=_$(this.textSizeData,l,b)/Ka;return this.tilePixelRatio*T}getSymbolInstanceIconSize(l,u,p){const x=this.icon.placedSymbolArray.get(p),b=_$(this.iconSizeData,l,x);return this.tilePixelRatio*b}_commitDebugCollisionVertexUpdate(l,u,p,x){l.emplaceBack(u,-p,-p,x),l.emplaceBack(u,p,-p,x),l.emplaceBack(u,p,p,x),l.emplaceBack(u,-p,p,x)}_updateTextDebugCollisionBoxes(l,u,p,x,b,T,k){for(let P=x;P0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}hasIconTextFit(){return this.hasAnyIconTextFit}addIndicesForPlacedSymbol(l,u){const p=l.placedSymbolArray.get(u),x=p.vertexStartIndex+4*p.numGlyphs;for(let b=p.vertexStartIndex;bx[k]-x[P]||b[P]-b[k]),T}getSortedIndexesByZOffset(){if(!this.zOffsetSortDirty)return this.symbolInstanceIndexesSortedZOffset;if(!this.symbolInstanceIndexesSortedZOffset){this.symbolInstanceIndexesSortedZOffset=[];for(let l=0;lthis.symbolInstances.get(u).zOffset-this.symbolInstances.get(l).zOffset)}addToSortKeyRanges(l,u){const p=this.sortKeyRanges[this.sortKeyRanges.length-1];p&&p.sortKey===u?p.symbolInstanceEnd=l+1:this.sortKeyRanges.push({sortKey:u,symbolInstanceStart:l,symbolInstanceEnd:l+1})}sortFeatures(l){if(this.sortFeaturesByY&&this.sortedAngle!==l)if(this.text.segments.get().length>1||this.icon.segments.get().length>1)this.sortFeaturesWithinSegments();else{this.symbolInstanceIndexes=this.getSortedSymbolIndexes(l),this.sortedAngle=l,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const u of this.symbolInstanceIndexes){const p=this.symbolInstances.get(u);this.featureSortOrder.push(p.featureIndex);const{rightJustifiedTextSymbolIndex:x,centerJustifiedTextSymbolIndex:b,leftJustifiedTextSymbolIndex:T,verticalPlacedTextSymbolIndex:k,placedIconSymbolIndex:P,verticalPlacedIconSymbolIndex:O}=p;x>=0&&this.addIndicesForPlacedSymbol(this.text,x),b>=0&&b!==x&&this.addIndicesForPlacedSymbol(this.text,b),T>=0&&T!==b&&T!==x&&this.addIndicesForPlacedSymbol(this.text,T),k>=0&&this.addIndicesForPlacedSymbol(this.text,k),P>=0&&this.addIndicesForPlacedSymbol(this.icon,P),O>=0&&this.addIndicesForPlacedSymbol(this.icon,O)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}getOrCreateSortedSymbolsByBatch(l,u){const p=(this.text.uboBinder&&this.text.uboBinder.maxFeaturesPerBatch>0?this.text.uboBinder:this.icon.uboBinder&&this.icon.uboBinder.maxFeaturesPerBatch>0?this.icon.uboBinder:null).maxFeaturesPerBatch;if(this.symbolsByBatch)for(const x of this.symbolsByBatch.values())for(const b of x){const T=this.symbolInstances.get(b.index);b.rotatedY=0|Math.round(l*T.tileAnchorX+u*T.tileAnchorY)}else{this.symbolsByBatch=new Map;for(let x=0;xb.rotatedY-T.rotatedY||T.featureIndex-b.featureIndex);return this.symbolsByBatch}rebuildTextSegmentIndices(l,u){for(const p of l){const x=p.batchIndex;if(x===void 0)continue;const b=u.get(x);if(!b){p.primitiveOffset=this.text.indexArray.length,p.primitiveLength=0;continue}p.primitiveOffset=this.text.indexArray.length;const T=this.text.indexArray.length;for(const{index:k}of b){const P=this.symbolInstances.get(k),{rightJustifiedTextSymbolIndex:O,centerJustifiedTextSymbolIndex:$,leftJustifiedTextSymbolIndex:V,verticalPlacedTextSymbolIndex:G}=P;O>=0&&this.addIndicesForPlacedSymbol(this.text,O),$>=0&&$!==O&&this.addIndicesForPlacedSymbol(this.text,$),V>=0&&V!==$&&V!==O&&this.addIndicesForPlacedSymbol(this.text,V),G>=0&&this.addIndicesForPlacedSymbol(this.text,G)}p.primitiveLength=this.text.indexArray.length-T}}rebuildIconSegmentIndices(l,u){for(const p of l){const x=p.batchIndex;if(x===void 0)continue;const b=u.get(x);if(!b){p.primitiveOffset=this.icon.indexArray.length,p.primitiveLength=0;continue}p.primitiveOffset=this.icon.indexArray.length;const T=this.icon.indexArray.length;for(const{index:k}of b){const P=this.symbolInstances.get(k),{placedIconSymbolIndex:O,verticalPlacedIconSymbolIndex:$}=P;O>=0&&this.addIndicesForPlacedSymbol(this.icon,O),$>=0&&this.addIndicesForPlacedSymbol(this.icon,$)}p.primitiveLength=this.icon.indexArray.length-T}}sortFeaturesWithinSegments(){this.featureSortOrder=[];const l=Math.sin(this.sortedAngle),u=Math.cos(this.sortedAngle),p=this.getOrCreateSortedSymbolsByBatch(l,u),x=Array.from(p.keys()).sort((b,T)=>b-T);for(const b of x){const T=p.get(b);for(const{index:k}of T){const P=this.symbolInstances.get(k);this.featureSortOrder.push(P.featureIndex)}}this.text.indexArray.clear(),this.icon.indexArray.clear(),this.rebuildTextSegmentIndices(this.text.segments.get(),p),this.rebuildIconSegmentIndices(this.icon.segments.get(),p),this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}getElevationFeatureForText(l){const u=this.symbolInstances.get(this.text.symbolInstanceIndices[l]).elevationFeatureIndex;let p;return this.elevationFeatures&&up in h?String(h[p]):"")}let aee,oee,R$;Tr(Xh,"SymbolBucket",{omit:["layers","collisionBoxArray","compareText","features"]}),Xh.addDynamicAttributes=Rw;class lee{constructor(l){this.type=l.property.overrides?l.property.overrides.runtimeType:Bh,this.defaultValue=l}evaluate(l){if(l.formattedSection){const u=this.defaultValue.property.overrides;if(u&&u.hasOverride(l.formattedSection))return u.getOverride(l.formattedSection)}return l.feature&&l.featureState?this.defaultValue.evaluate(l.feature,l.featureState):this.defaultValue.property.specification.default}eachChild(l){this.defaultValue.isConstant()||l(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}Tr(lee,"FormatSectionOverride",{omit:["defaultValue"]});const L$=()=>R$||(R$={layout:aee||(aee=new hi({"symbol-placement":new sr(at.layout_symbol["symbol-placement"]),"symbol-spacing":new sr(at.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new sr(at.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new Qt(at.layout_symbol["symbol-sort-key"]),"symbol-z-order":new sr(at.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new sr(at.layout_symbol["symbol-z-elevate"]),"symbol-elevation-reference":new sr(at.layout_symbol["symbol-elevation-reference"]),"icon-allow-overlap":new sr(at.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new sr(at.layout_symbol["icon-ignore-placement"]),"icon-optional":new sr(at.layout_symbol["icon-optional"]),"icon-rotation-alignment":new sr(at.layout_symbol["icon-rotation-alignment"]),"icon-size":new Qt(at.layout_symbol["icon-size"]),"icon-size-scale-range":new sr(at.layout_symbol["icon-size-scale-range"]),"icon-text-fit":new Qt(at.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new Qt(at.layout_symbol["icon-text-fit-padding"]),"icon-image":new Qt(at.layout_symbol["icon-image"]),"icon-image-use-theme":new sr({type:"string",default:"default","property-type":"data-constant"}),"icon-rotate":new Qt(at.layout_symbol["icon-rotate"]),"icon-padding":new sr(at.layout_symbol["icon-padding"]),"icon-keep-upright":new sr(at.layout_symbol["icon-keep-upright"]),"icon-offset":new Qt(at.layout_symbol["icon-offset"]),"icon-anchor":new Qt(at.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new sr(at.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new sr(at.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new sr(at.layout_symbol["text-rotation-alignment"]),"text-field":new Qt(at.layout_symbol["text-field"]),"text-font":new Qt(at.layout_symbol["text-font"]),"text-size":new Qt(at.layout_symbol["text-size"]),"text-size-scale-range":new sr(at.layout_symbol["text-size-scale-range"]),"text-max-width":new Qt(at.layout_symbol["text-max-width"]),"text-line-height":new Qt(at.layout_symbol["text-line-height"]),"text-letter-spacing":new Qt(at.layout_symbol["text-letter-spacing"]),"text-justify":new Qt(at.layout_symbol["text-justify"]),"text-radial-offset":new Qt(at.layout_symbol["text-radial-offset"]),"text-variable-anchor":new sr(at.layout_symbol["text-variable-anchor"]),"text-anchor":new Qt(at.layout_symbol["text-anchor"]),"text-max-angle":new sr(at.layout_symbol["text-max-angle"]),"text-writing-mode":new sr(at.layout_symbol["text-writing-mode"]),"text-rotate":new Qt(at.layout_symbol["text-rotate"]),"text-padding":new sr(at.layout_symbol["text-padding"]),"text-keep-upright":new sr(at.layout_symbol["text-keep-upright"]),"text-transform":new Qt(at.layout_symbol["text-transform"]),"text-offset":new Qt(at.layout_symbol["text-offset"]),"text-allow-overlap":new sr(at.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new sr(at.layout_symbol["text-ignore-placement"]),"text-optional":new sr(at.layout_symbol["text-optional"]),visibility:new sr(at.layout_symbol.visibility)})),paint:oee||(oee=new hi({"icon-opacity":new Qt(at.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new Qt(at.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new Qt(at.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new Qt(at.paint_symbol["text-emissive-strength"]),"icon-color":new Qt(at.paint_symbol["icon-color"]),"icon-halo-color":new Qt(at.paint_symbol["icon-halo-color"]),"icon-halo-width":new Qt(at.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Qt(at.paint_symbol["icon-halo-blur"]),"icon-translate":new sr(at.paint_symbol["icon-translate"]),"icon-translate-anchor":new sr(at.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new sr(at.paint_symbol["icon-image-cross-fade"]),"text-opacity":new Qt(at.paint_symbol["text-opacity"]),"text-occlusion-opacity":new Qt(at.paint_symbol["text-occlusion-opacity"]),"text-color":new Qt(at.paint_symbol["text-color"],{runtimeType:Rl,getOverride:h=>h.textColor,hasOverride:h=>!!h.textColor}),"text-halo-color":new Qt(at.paint_symbol["text-halo-color"]),"text-halo-width":new Qt(at.paint_symbol["text-halo-width"]),"text-halo-blur":new Qt(at.paint_symbol["text-halo-blur"]),"text-translate":new sr(at.paint_symbol["text-translate"]),"text-translate-anchor":new sr(at.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new sr(at.paint_symbol["icon-color-saturation"]),"icon-color-contrast":new sr(at.paint_symbol["icon-color-contrast"]),"icon-color-brightness-min":new sr(at.paint_symbol["icon-color-brightness-min"]),"icon-color-brightness-max":new sr(at.paint_symbol["icon-color-brightness-max"]),"symbol-z-offset":new Qt(at.paint_symbol["symbol-z-offset"]),"icon-color-use-theme":new Qt({type:"string",default:"default","property-type":"data-driven"}),"icon-halo-color-use-theme":new Qt({type:"string",default:"default","property-type":"data-driven"}),"text-color-use-theme":new Qt({type:"string",default:"default","property-type":"data-driven"}),"text-halo-color-use-theme":new Qt({type:"string",default:"default","property-type":"data-driven"})}))},R$);class fR extends fl{constructor(l,u,p,x){super(l,L$(),u,p,x,l.layout?l.layout["icon-image-use-theme"]:null),this._colorAdjustmentMatrix=I([]),this.hasOcclusionOpacityProperties=l.paint!==void 0&&("icon-occlusion-opacity"in l.paint||"text-occlusion-opacity"in l.paint)}_handleSpecialPaintPropertyUpdate(l){l!=="icon-occlusion-opacity"&&l!=="text-occlusion-opacity"||(this.hasOcclusionOpacityProperties=!0)}recalculate(l,u){super.recalculate(l,u),this.appearances&&this.appearances.forEach(x=>{x.recalculate(l,u,this.iconImageUseTheme)}),this.layout.get("icon-rotation-alignment")==="auto"&&(this.layout._values["icon-rotation-alignment"]=this.layout.get("symbol-placement")!=="point"?"map":"viewport"),this.layout.get("text-rotation-alignment")==="auto"&&(this.layout._values["text-rotation-alignment"]=this.layout.get("symbol-placement")!=="point"?"map":"viewport"),this.layout.get("text-pitch-alignment")==="auto"&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")),this.layout.get("icon-pitch-alignment")==="auto"&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment"));const p=this.layout.get("text-writing-mode");if(p){const x=[];for(const b of p)x.indexOf(b)<0&&x.push(b);this.layout._values["text-writing-mode"]=x}else this.layout._values["text-writing-mode"]=this.layout.get("symbol-placement")==="point"?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides()}getColorAdjustmentMatrix(l,u,p,x){return this._saturation===l&&this._contrast===u&&this._brightnessMin===p&&this._brightnessMax===x||(this._colorAdjustmentMatrix=function(b,T,k,P){b=ri(b),T=zn(T);const O=A(),$=b/3,V=1-2*$,G=[V,$,$,0,$,V,$,0,$,$,V,0,0,0,0,1],Y=.5-.5*T,X=P-k;return D(O,[X,0,0,0,0,X,0,0,0,0,X,0,k,k,k,1],[T,0,0,0,0,T,0,0,0,0,T,0,Y,Y,Y,1]),D(O,O,G),O}(l,u,p,x),this._saturation=l,this._contrast=u,this._brightnessMin=p,this._brightnessMax=x),this._colorAdjustmentMatrix}getValueAndResolveTokens(l,u,p,x){const b=this.layout.get(l).evaluate(u,{},p,x),T=this._unevaluatedLayout._values[l];return T.isDataDriven()||e_(T.value)||!b?b:iee(u.properties,b)}getAppearanceValueAndResolveTokens(l,u,p,x,b){const T=l.getLayoutProperty(u);if(!T)return;const k=T.evaluate(p,{},x,b),P=l.getUnevaluatedLayoutProperties()._values[u];return P.isDataDriven()||e_(P.value)||!k||typeof k!="string"?k:iee(p.properties,k)}createBucket(l){return new Xh(l)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const l of L$().paint.overridableProperties){if(!fR.hasPaintOverride(this.layout,l))continue;const u=this.paint.get(l),p=new lee(u),x=new Yb(p,u.property.specification,this.scope,this.options,this.layout.get("icon-image-use-theme"));let b=null;b=u.value.kind==="constant"||u.value.kind==="source"?new fy("source",x):new Ep("composite",x,u.value.zoomStops,u.value.interpolationType),this.paint._values[l]=new Np(u.property,b,u.parameters)}}_handleOverridablePaintPropertyUpdate(l,u,p){return!(!this.layout||u.isDataDriven()||p.isDataDriven())&&fR.hasPaintOverride(this.layout,l)}static hasPaintOverride(l,u){const p=l.get("text-field"),x=L$().paint.properties[u];let b=!1;const T=k=>{for(const P of k)if(x.overrides&&x.overrides.hasOverride(P))return void(b=!0)};if(p.value.kind==="constant"&&p.value.value instanceof Ko)T(p.value.value.sections);else if(p.value.kind==="source"){const k=O=>{b||(O instanceof Lr&&Ui(O.value)===C0?T(O.value.sections):O instanceof xp?T(O.sections):O.eachChild(k))},P=p.value;P._styleExpression&&k(P._styleExpression.expression)}return b}getProgramIds(){return["symbol"]}getDefaultProgramParams(l,u,p){return{config:new re(this,{zoom:u,lut:p}),overrideFog:!1}}hasElevation(){return this.layout&&this.layout.get("symbol-elevation-reference")==="hd-road-markup"}}let cee,uee,dee,hee;var mR=On([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Uint16",components:2}]);function pR(h,l,u,p,x,b,T,k){const P=[h,l,1,u,p,1,x,b,1],O=[T,k,1],$=w([],P),[V,G,Y]=Sr(O,O,$);return E(P,P,[V,0,0,0,G,0,0,0,Y])}function fee(h,l,u,p,x,b,T,k){const P=function(O,$,V,G,Y,X,te,se){const ae=pR(0,0,1,0,1,1,0,1),fe=pR(O,$,V,G,Y,X,te,se);return E(fe,fe,w([],ae))}(h,l,u,p,x,b,T,k);return[P[2]/P[8]/fr,P[5]/P[8]/fr]}function gR(h){return[h[0],Math.min(Math.max(h[1],-85.051129),Nt)]}class mee extends N0{constructor(l,u,p,x){super(),this.id=l,this.dispatcher=p,this.coordinates=u.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.onNorthPole=!1,this.onSouthPole=!1,this.setEventedParent(x),this.options=u,this._dirty=!1}load(l,u){if(this._loaded=u||!1,this.fire(new ad("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return l&&(this.coordinates=l),this._loaded=!0,void this._finishLoading();this._imageRequest=Xg(this.map._requestManager.transformRequest(this.url,k0.Image),(p,x)=>{this._imageRequest=null,this._loaded=!0,p?this.fire(new Qg(p)):x&&(this.image=x,this._dirty=!0,this.width=this.image.width,this.height=this.image.height,l&&(this.coordinates=l),this._finishLoading())})}loaded(){return this._loaded}updateImage(l){return l.url?(this._imageRequest&&l.url!==this.options.url&&(this._imageRequest.cancel(),this._imageRequest=null),this.options.url=l.url,this.load(l.coordinates,this._loaded),this):this}setTexture(l){if(!(l.handle instanceof WebGLTexture))throw new Error("The provided handle is not a WebGLTexture instance");return this.texture=new g2(this.map.painter.context,l.handle),this.width=l.dimensions[0],this.height=l.dimensions[1],this._dirty=!1,this._loaded=!0,this._finishLoading(),this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new ad("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(l){this.map=l,this.load()}onRemove(l){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),!this.texture||this.texture instanceof g2||this.texture.destroy(),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy())}setCoordinates(l){if(this.coordinates=l,this._boundsArray=void 0,this._unsupportedCoords=!1,!l.length)return this;this.onNorthPole=!1,this.onSouthPole=!1;let u=l[0][1],p=l[0][1];for(const b of l)b[1]>p&&(p=b[1]),b[1]Nt?this.onNorthPole=!0:x<-85.051129&&(this.onSouthPole=!0),!this.onNorthPole&&!this.onSouthPole){const b=l.map(Ir.fromLngLat);this.tileID=function(T){let k=1/0,P=1/0,O=-1/0,$=-1/0;for(const te of T)k=Math.min(k,te.x),P=Math.min(P,te.y),O=Math.max(O,te.x),$=Math.max($,te.y);const V=Math.max(O-k,$-P),G=Math.max(0,Math.floor(-Math.log2(V))),Y=Math.pow(2,G);let X=Math.floor((k+O)/2*Y);return X>1&&(X-=1),new v_(G,X,Math.floor((P+$)/2*Y))}(b),this.minzoom=this.maxzoom=this.tileID.z}return this.fire(new ad("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){!this.texture||this.texture instanceof g2||(this.texture.destroy(),this._dirty=!0),this.texture=null,this._boundsArray=void 0,this._unsupportedCoords=!1}_prepareData(l){for(const se in this.tiles){const ae=this.tiles[se];ae.state!=="loaded"&&(ae.state="loaded",ae.texture=this.texture)}if(this._boundsArray||this.onNorthPole||this.onSouthPole||this._unsupportedCoords)return;const u=k_(new v_(0,0,0),this.map.transform.projection),p=[u.projection.project(this.coordinates[0][0],this.coordinates[0][1]),u.projection.project(this.coordinates[1][0],this.coordinates[1][1]),u.projection.project(this.coordinates[2][0],this.coordinates[2][1]),u.projection.project(this.coordinates[3][0],this.coordinates[3][1])];if(!function(se){const ae=se[1].x-se[0].x,fe=se[1].y-se[0].y,ue=se[2].x-se[1].x,we=se[2].y-se[1].y,Ae=se[3].x-se[2].x,Ie=se[3].y-se[2].y,We=se[0].x-se[3].x,ze=se[0].y-se[3].y,He=ae*we-ue*fe,Ve=ue*Ie-Ae*we,qe=Ae*ze-We*Ie,bt=We*fe-ae*ze;return He>0&&Ve>0&&qe>0&&bt>0||He<0&&Ve<0&&qe<0&&bt<0}(p))return console.warn("Image source coordinates are defining non-convex area in the Mercator projection"),void(this._unsupportedCoords=!0);const x=k_(this.tileID,this.map.transform.projection),[b,T,k,P]=this.coordinates.map(se=>{const ae=x.projection.project(se[0],se[1]);return JJ(x,ae)._round()});this.perspectiveTransform=fee(b.x,b.y,T.x,T.y,k.x,k.y,P.x,P.y);const O=this._boundsArray=new Ro;O.emplaceBack(b.x,b.y,0,0),O.emplaceBack(T.x,T.y,fr,0),O.emplaceBack(P.x,P.y,0,fr),O.emplaceBack(k.x,k.y,fr,fr),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=l.createVertexBuffer(O,mR.members),this.boundsSegments=Os.simpleSegment(0,0,4,2);const $=[],V=function(se){return[gR(se[0]),gR(se[1]),gR(se[2]),gR(se[3])]}(this.coordinates),[G,Y,X,te]=function(se){let ae=se[0][0],fe=ae,ue=se[0][1],we=ue;for(let Ae=1;Aefe&&(fe=se[Ae][0]),se[Ae][1]we&&(we=se[Ae][1]);return[ae,ue,fe-ae,we-ue]}(V);{const se=new Ro,[ae,fe,ue,we]=function(Pt){let Ht=Pt[0].x,_t=Ht,Rt=Pt[0].y,Bt=Rt;for(let Yt=1;Yt_t&&(_t=Pt[Yt].x),Pt[Yt].yBt&&(Bt=Pt[Yt].y);return[Ht,Rt,_t-Ht,Bt-Rt]}(p),Ae=Pt=>[(Pt.x-ae)/ue,(Pt.y-fe)/we],[Ie,We,ze,He]=p.map(Ae),Ve=function(Pt,Ht,_t,Rt,Bt,Yt,tr,br){const ur=pR(0,0,1,0,1,1,0,1);return E(ur,ur,w([],pR(Pt,Ht,_t,Rt,Bt,Yt,tr,br)))}(Ie[0],Ie[1],We[0],We[1],ze[0],ze[1],He[0],He[1]);this.elevatedGlobePerspectiveTransform=fee(Ie[0],Ie[1],We[0],We[1],ze[0],ze[1],He[0],He[1]);const qe=(Pt,Ht)=>{$.push(Pt.lng);const _t=Math.round((Pt.lng-G)/X*fr),Rt=Math.round((Pt.lat-Y)/te*fr),Bt=Ae(Ht),Yt=Sr([],[Bt[0],Bt[1],1],Ve),tr=Math.round(Yt[0]/Yt[2]*fr),br=Math.round(Yt[1]/Yt[2]*fr);se.emplaceBack(_t,Rt,tr,br)},bt=p[3].x-p[0].x,jt=p[3].y-p[0].y,It=p[2].x-p[1].x,Dt=p[2].y-p[1].y;for(let Pt=0;Pt<65;Pt++){const Ht=Pt/64,_t=[p[0].x+Ht*bt,p[0].y+Ht*jt],Rt=[p[1].x+Ht*It,p[1].y+Ht*Dt],Bt=Rt[0]-_t[0],Yt=Rt[1]-_t[1];for(let tr=0;tr<65;tr++){const br=tr/64,ur={x:_t[0]+Bt*br,y:_t[1]+Yt*br};qe(u.projection.unproject(ur.x,ur.y),ur)}}this.elevatedGlobeVertexBuffer=l.createVertexBuffer(se,mR.members)}{this.maxLongitudeTriangleSize=0;let se=[],ae=new Pi;const fe=(ue,we,Ae)=>{ae.emplaceBack(ue,we,Ae);const Ie=$[ue],We=$[we],ze=$[Ae],He=Math.min(Math.min(Ie,We),ze),Ve=Math.max(Math.max(Ie,We),ze)-He;Ve>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=Ve),se.push(He+Ve/2)};for(let ue=0;ue<64;ue++)for(let we=0;we<64;we++){const Ae=65*ue+we,Ie=Ae+1,We=Ae+65,ze=We+1;fe(Ae,We,Ie),fe(Ie,We,ze)}[se,ae]=function(ue,we){const Ae=Array.from({length:ue.length},(ze,He)=>He);Ae.sort((ze,He)=>ue[ze]-ue[He]);const Ie=[],We=new Pi;for(let ze=0;ze{T.segments.push({vertexOffset:0,primitiveOffset:V,vertexLength:u.segments[0].vertexLength,primitiveLength:G,sortKey:void 0,vaos:{}})},P=.51*this.maxLongitudeTriangleSize;if(Math.abs(p[0]-x)<=P){const V=zi(p,0,p.length,x+P);return V===p.length||k(V,ks(p,V+1,p.length,x+360-P)-V),T}x0}}let gee,yee,xee,_ee,vee,bee,wee;class See extends fl{constructor(l,u,p,x){super(l,{layout:gee||(gee=new hi({visibility:new sr(at["layout_raster-particle"].visibility)})),paint:yee||(yee=new hi({"raster-particle-array-band":new sr(at["paint_raster-particle"]["raster-particle-array-band"]),"raster-particle-count":new sr(at["paint_raster-particle"]["raster-particle-count"]),"raster-particle-color":new yy(at["paint_raster-particle"]["raster-particle-color"]),"raster-particle-max-speed":new sr(at["paint_raster-particle"]["raster-particle-max-speed"]),"raster-particle-speed-factor":new sr(at["paint_raster-particle"]["raster-particle-speed-factor"]),"raster-particle-fade-opacity-factor":new sr(at["paint_raster-particle"]["raster-particle-fade-opacity-factor"]),"raster-particle-reset-rate-factor":new sr(at["paint_raster-particle"]["raster-particle-reset-rate-factor"]),"raster-particle-elevation":new sr(at["paint_raster-particle"]["raster-particle-elevation"]),"raster-particle-color-use-theme":new Qt({type:"string",default:"default","property-type":"data-driven"})}))},u,p,x),this._updateColorRamp(),this.lastInvalidatedAt=Kl.now()}_clear(){this.colorRampTexture&&(this.colorRampTexture.destroy(),this.colorRampTexture=null),this.tileFramebuffer&&(this.tileFramebuffer.destroy(),this.tileFramebuffer=null),this.particleFramebuffer&&(this.particleFramebuffer.destroy(),this.particleFramebuffer=null)}onRemove(l){this.colorRampTexture&&this.colorRampTexture.destroy(),this.tileFramebuffer&&this.tileFramebuffer.destroy(),this.particleFramebuffer&&this.particleFramebuffer.destroy()}hasColorMap(){return!!this._transitionablePaint._values["raster-particle-color"].value.value}getProgramIds(){return["rasterParticle"]}hasOffscreenPass(){return this.visibility!=="none"}isDraped(l){return!1}_handleSpecialPaintPropertyUpdate(l){l!=="raster-particle-color"&&l!=="raster-particle-max-speed"||(this._updateColorRamp(),this._invalidateAnimationState()),l==="raster-particle-count"&&this._invalidateAnimationState()}_updateColorRamp(){if(!this.hasColorMap())return;const l=this._transitionablePaint._values["raster-particle-color"].value.expression,u=this._transitionablePaint._values["raster-particle-max-speed"].value.expression.evaluate({zoom:0});this.colorRamp=t2({expression:l,evaluationKey:"rasterParticleSpeed",image:this.colorRamp,clips:[{start:0,end:u}],resolution:256}),this.colorRampTexture=null}_invalidateAnimationState(){this.lastInvalidatedAt=Kl.now()}tileCoverLift(){return this.paint.get("raster-particle-elevation")}}class mLe extends fl{constructor(l,u){super(l,{},u,null),this.implementation=l,l.slot&&(this.slot=l.slot)}is3D(l){return this.implementation.renderingMode==="3d"}hasOffscreenPass(){return this.implementation.prerender!==void 0}isDraped(l){return this.implementation.renderToTile!==void 0}shouldRedrape(){return!!this.implementation.shouldRerenderTiles&&this.implementation.shouldRerenderTiles()}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){}onAdd(l){this.implementation.onAdd&&this.implementation.onAdd(l,l.painter.context.gl)}onRemove(l){this.implementation.onRemove&&this.implementation.onRemove(l,l.painter.context.gl)}}function D$(h,l,u){const p=[0,0,1],x=pr([]);return Gn(x,x,u?-Xn(h)+Math.PI:Xn(h)),yn(x,x,-Xn(l)),rn(p,p,x),ft(p,p)}class yR{constructor(l,u,p,x){this.message=(l?`${l}: `:"")+p,x&&(this.identifier=x),u!=null&&u.__line__&&(this.line=u.__line__)}}function O$(h,l){const u=h.indexOf("://")===-1;try{return new URL(h,u&&l?"http://example.com":void 0),!0}catch{return!1}}class Tee{constructor(l,u){this.feature=l,this.instancedDataOffset=u,this.instancedDataCount=0,this.rotation=[0,0,0],this.scale=[1,1,1],this.translation=[0,0,0]}}class Eee{constructor(){this.maxScale=1,this.maxXYTranslationDistance=0,this.instancedDataArray=new Hj,this.instancesEvaluatedElevation=[],this.features=[],this.idToFeaturesIndex={}}colorForInstance(l){const u=16*l,p=this.instancedDataArray.float32;let x=Math.floor(p[u+2]);const b=1.05*(p[u+2]-x);return x/=100,[p[u]%1*1.05,p[u+1]%1*1.05,b,x]}tileCoordinatesForInstance(l){const u=16*l,p=this.instancedDataArray.float32;let x=p[u+0];return x=x>fr?x-fr:x,new Ft(Math.trunc(x),Math.trunc(p[u+1]))}translationForInstance(l){const u=16*l,p=this.instancedDataArray.float32;return[p[u+4],p[u+5],p[u+6]]}rotationScaleForInstance(l){const u=16*l,p=this.instancedDataArray.float32;return[p[u+7],p[u+8],p[u+9],p[u+10],p[u+11],p[u+12],p[u+13],p[u+14],p[u+15]]}transformForInstance(l){const u=16*l,p=this.instancedDataArray.float32;return[p[u+7],p[u+8],p[u+9],p[u+4],p[u+10],p[u+11],p[u+12],p[u+5],p[u+13],p[u+14],p[u+15],p[u+6],0,0,0,1]}}class F${constructor(l){this.zoom=l.zoom,this.canonical=l.canonical,this.overscaledZ=this.canonical.z+Math.log2(l.overscaling),this.layers=l.layers,this.layerIds=this.layers.map(u=>u.fqid),this.projection=l.projection,this.index=l.index,this.worldview=l.worldview,this.hasZoomDependentProperties=this.layers[0].isZoomDependent(),this.stateDependentLayerIds=this.layers.filter(u=>u.isStateDependent()).map(u=>u.id),this.hasPattern=!1,this.instancesPerModel={},this.validForExaggeration=0,this.maxVerticalOffset=0,this.maxScale=0,this.maxHeight=0,this.lookupDim=this.zoom>this.canonical.z+1?0:this.zoom>this.canonical.z?256:this.zoom>15?75:100,this.instanceCount=0,this.terrainElevationMin=0,this.terrainElevationMax=0,this.validForDEMTile={id:null,timestamp:0},this.modelUris=[],this.modelsRequested=!1,this.activeReplacements=[],this.replacementUpdateTime=0,this.styleDefinedModelURLs=l.styleDefinedModelURLs,this.hasAppearances=null}updateFootprints(l,u){}updateAppearances(l,u,p,x){return{hasLayoutChanges:!1,hasUboChanges:!1}}populate(l,u,p,x){this.tileToMeter=zt(p);const b=this.layers[0]._featureFilter.needGeometry;this.lookup=new Uint8Array(this.lookupDim*this.lookupDim);const T=this.layers[0].paint.get("model-elevation-reference")==="hd-road-markup"?u.elevationFeatures:void 0;for(const{feature:k,id:P,index:O,sourceLayerIndex:$}of l){const V=P??(k.properties&&k.properties.hasOwnProperty("id")?k.properties.id:void 0),G=En(k,b);if(!this.layers[0]._featureFilter.filter(new fs(this.zoom,{worldview:this.worldview,activeFloors:u.activeFloors}),G,p))continue;const Y={id:V,sourceLayerIndex:$,index:O,geometry:b?G.geometry:Kr(k,p,x),properties:k.properties,type:k.type,patterns:{}},X=this.addFeature(Y,Y.geometry,G,T,p);X&&u.featureIndex.insert(k,Y.geometry,O,$,this.index,this.instancesPerModel[X].instancedDataArray.length,256)}this.lookup=null}evaluateQueryRenderedFeaturePadding(){const l=this.layers[0].modelManager,u=this.layers[0].scope;let p=0;for(const x of this.modelUris){const b=l.getModel(x,u);if(!b)continue;const T=this.instancesPerModel[x];if(T){const k=.5*lt(b.aabb.max,b.aabb.min)*T.maxScale+T.maxXYTranslationDistance,P=Math.min(fr,Math.max(k/this.tileToMeter,256));p=Math.max(P,p)}}return p}update(l,u,p,x){for(const b in this.instancesPerModel){const T=this.instancesPerModel[b];for(const k in l)T.idToFeaturesIndex.hasOwnProperty(k)&&(this.evaluate(T.features[T.idToFeaturesIndex[k]],l[k],T,!0),this.uploaded=!1)}this.maxHeight=0}updateZoomBasedPaintProperties(){if(!this.hasZoomDependentProperties)return!1;let l=!1;for(const u in this.instancesPerModel){const p=this.instancesPerModel[u];for(const x of p.features){const b=this.layers[0],T=x.feature,k=this.canonical,P=b.paint.get("model-rotation").evaluate(T,{},k),O=b.paint.get("model-scale").evaluate(T,{},k),$=b.paint.get("model-translation").evaluate(T,{},k);$r(x.rotation,P)&&$r(x.scale,O)&&$r(x.translation,$)||(this.evaluate(x,x.featureStates,p,!0),l=!0)}}return l}updateReplacement(l,u,p,x){if(u.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=u.updateTime;const b=u.getReplacementRegionsForTile(l.toUnwrapped(),!0);if(DP(this.activeReplacements,b))return!1;this.activeReplacements=b;let T=!1;for(const k in this.instancesPerModel){const P=this.instancesPerModel[k],O=P.instancedDataArray;for(const $ of P.features){const V=$.instancedDataOffset,G=$.instancedDataCount;for(let Y=0;Yfr;te=se?te-fr:te;const ae=Math.floor(te),fe=Math.floor(O.float32[X+1]);let ue=!1;for(const we of this.activeReplacements)if(!aQ(we,p,OP.Model,x)&&!(we.min.x>ae||ae>we.max.x||we.min.y>fe||fe>we.max.y)&&(ue=dQ(uQ(ae,fe,l.canonical,we.footprintTileId.canonical),we.footprint),ue))break;O.float32[X]=ue?te+fr:te,T=T||ue!==se}}}return T}isEmpty(){for(const l in this.instancesPerModel)if(this.instancesPerModel[l].instancedDataArray.length!==0)return!1;return!0}uploadPending(){return!this.uploaded}upload(l){if(!this.uploaded)for(const u in this.instancesPerModel){const p=this.instancesPerModel[u];p.instancedDataArray.length<0||p.instancedDataArray.length===0||(p.instancedDataBuffer?p.instancedDataBuffer.updateData(p.instancedDataArray):p.instancedDataBuffer=l.createVertexBuffer(p.instancedDataArray,RPe.members,!0,void 0,this.instanceCount))}this.uploaded=!0}destroy(l){for(const p in this.instancesPerModel){const x=this.instancesPerModel[p];x.instancedDataArray.length!==0&&x.instancedDataBuffer&&x.instancedDataBuffer.destroy()}const u=this.layers[0].modelManager;if(l&&u&&this.modelUris&&this.modelsRequested)for(const p of this.modelUris)u.removeModel(p,"",!0)}addFeature(l,u,p,x,b){const T=this.layers[0],k=T.layout.get("model-id"),P=T.layout.get("model-allow-density-reduction"),O=k.evaluate(p,{},this.canonical);if(!O)return hr(`modelId is not evaluated for layer ${T.id} and it is not going to get rendered.`),O;(O$(O,!1)||this.styleDefinedModelURLs[O]!==void 0)&&(this.modelUris.includes(O)||this.modelUris.push(O)),this.instancesPerModel[O]||(this.instancesPerModel[O]=new Eee);const $=this.instancesPerModel[O],V=$.instancedDataArray,G=new Tee(p,V.length);let Y;x&&(Y=Vs.getElevationFeature(l,x));for(const X of u)for(const te of X){if(te.x<0||te.x>=fr||te.y<0||te.y>=fr)continue;if(this.lookupDim!==0&&P){const ae=(this.lookupDim-1)/fr,fe=this.lookupDim*(te.y*ae|0)+te.x*ae|0;if(this.lookup){if(this.lookup[fe]!==0)continue;this.lookup[fe]=1}}this.instanceCount++;const se=V.length;if(V.resize(se+1),x){$.instancesRoadElevation||($.instancesRoadElevation=[]);const ae=Y?Y.pointElevation(new Ft(te.x,te.y)):0;$.instancesRoadElevation.push(ae)}$.instancesEvaluatedElevation.push(0),V.float32[16*se]=te.x,V.float32[16*se+1]=te.y}return G.instancedDataCount=$.instancedDataArray.length-G.instancedDataOffset,G.instancedDataCount>0&&(l.id&&($.idToFeaturesIndex[l.id]=$.features.length),$.features.push(G),this.evaluate(G,{},$,!1)),O}getModelUris(){return this.modelUris}evaluate(l,u,p,x){const b=this.layers[0],T=l.feature,k=this.canonical,P=l.rotation=b.paint.get("model-rotation").evaluate(T,u,k),O=l.scale=b.paint.get("model-scale").evaluate(T,u,k),$=l.translation=b.paint.get("model-translation").evaluate(T,u,k),V=Object.assign({},b.paint.get("model-color").evaluate(T,u,k));V.a=b.paint.get("model-color-mix-intensity").evaluate(T,u,k);const G=[];this.maxVerticalOffset<$[2]&&(this.maxVerticalOffset=$[2]);const Y=$[0]*$[0]+$[1]*$[1],X=Y>0?Math.sqrt(Y):0;p.maxScale=Math.max(Math.max(p.maxScale,O[0]),Math.max(O[1],O[2])),p.maxXYTranslationDistance=Math.max(p.maxXYTranslationDistance,X),this.maxScale=Math.max(Math.max(this.maxScale,O[0]),Math.max(O[1],O[2])),YQ(G,P,O);const te=Math.round(100*V.a)+V.b/1.05;for(let se=0;se10?this.tileToMeter:zt(k,Ae)),ue[fe+4]=$[0],ue[fe+5]=$[1],ue[fe+6]=$[2]+(p.instancesRoadElevation?p.instancesRoadElevation[ae]:0)+we,ue[fe+7]=G[0],ue[fe+8]=G[1],ue[fe+9]=G[2],ue[fe+10]=G[4],ue[fe+11]=G[5],ue[fe+12]=G[6],ue[fe+13]=G[8],ue[fe+14]=G[9],ue[fe+15]=G[10],p.instancesEvaluatedElevation[ae]=$[2]}}}Tr(F$,"ModelBucket",{omit:["layers"]}),Tr(Eee,"PerModelAttributes"),Tr(Tee,"ModelFeature");class Mw{constructor(l,u,p){this._demTile=l,this._dem=this._demTile.dem,this._scale=u,this._offset=p}static create(l,u,p){const x=p||l.findDEMTileFor(u);if(!x||!x.dem)return;const b=x.dem,T=x.tileID,k=1<O.fqid),this.stateDependentLayerIds=this.layers.filter(O=>O.isStateDependent()).map(O=>O.id),this.modelTraits|=kw.CoordinateSpaceTile,this.uploaded=!1,this.hasPattern=!1,x&&(this.modelTraits|=kw.HasMapboxMeshFeatures),b&&(this.modelTraits|=kw.HasMeshoptCompression),this.zoom=-1,this.terrainExaggeration=1,this.projection={name:"mercator"},this.replacementUpdateTime=0,this.elevationReadFromZ=255,this.brightness=T,this.worldview=P,this.dirty=!0,this.needsUpload=!1,this.filter=null,this.nodesInfo=[];for(const O of u)this.nodesInfo.push(new Nee(O)),kee(O,k.featureIndexArray.length,k.grid),k.featureIndexArray.emplaceBack(this.nodesInfo.length-1,0,k.bucketLayerIDs.length-1,0);this.states={},this.hasAppearances=null}updateFootprints(l,u){for(const p of this.getNodesInfo()){const x=p.node;x.footprint&&u.push({footprint:x.footprint,id:l})}}updateAppearances(l,u,p,x){return{hasLayoutChanges:!1,hasUboChanges:!1}}update(l){const u=Object.keys(l).length!==0;if(u&&!this.stateDependentLayers.length)return;const p=u?this.stateDependentLayers:this.layers;if(!So(l,this.states))for(const x of p)this.evaluate(x,l);this.states=structuredClone(l)}populate(){console.log("populate 3D model bucket")}uploadPending(){return!this.uploaded||this.needsUpload}upload(l){if(!this.needsUpload)return;const u=this.getNodesInfo();for(const p of u){const x=p.node;this.uploaded?this.updatePbrBuffer(x):r$(x,l,!0)}for(const p of u)ZP(p.node);this.uploaded=!0,this.needsUpload=!1}updatePbrBuffer(l){let u=!1;if(!l.meshes)return u;for(const p of l.meshes)p.pbrBuffer&&(p.pbrBuffer.updateData(p.featureArray),u=!0);return u}needsReEvaluation(l,u,p){const x=l.transform.projectionOptions,b=l.style.getBrightness(),T=this.brightness!==b;if(!this.uploaded||this.dirty||x.name!==this.projection.name||P2(p.paint.get("model-color").value,T)||P2(p.paint.get("model-color-mix-intensity").value,T)||P2(p.paint.get("model-roughness").value,T)||P2(p.paint.get("model-emissive-strength").value,T)||P2(p.paint.get("model-height-based-emissive-strength-multiplier").value,T)){this.projection=x,this.brightness=b;const k=this.getNodesInfo();for(const P of k)P.state=null;return!0}return!1}evaluateTransform(l,u){if(l.transform.zoom===this.zoom)return;this.zoom=l.transform.zoom;const p=this.getNodesInfo(),x=this.id.canonical;for(const b of p){const T=b.feature;b.evaluatedTranslation=u.paint.get("model-translation").evaluate(T,{},x),b.evaluatedScale=u.paint.get("model-scale").evaluate(T,{},x)}}evaluate(l,u){const p=this.getNodesInfo();for(const x of p){if(!x.node.meshes)continue;const b=x.feature,T=u&&u[b.id];if(So(T,x.state))continue;x.state=structuredClone(T);const k=x.node.meshes&&x.node.meshes[0].featureData,P=x.evaluatedColor[2],O=x.evaluatedRMEA[2],$=this.id.canonical;if(x.hasTranslucentParts=!1,k){for(let V=0;V=Ie)continue;const Ht=B$[Pt],_t=Math.abs(Ht);_t>qe&&(Ve=Ht,qe=_t,bt=Dt,jt=It)}if(qe>.1){const It=1-(Ie+.5*Math.abs(bt*jt))/X;let Dt=u._dem.get(ze,We)+Ve*It;const Pt=u._dem.get(ze+bt,We+jt),Ht=u._dem.get(ze-bt,We-jt,!0);(Dt-Pt)*(Dt-Ht)>0&&(Dt=(Pt+Ht)/2),B$[He]=u._dem.set(ze,We,Dt),A_[He]=Ie}}}}}k&&(u._demTile.needsDEMTextureUpload=!0,u._dem._timestamp=Kl.now())}setFilter(l){this.filter=l?ow(l):null}getNodesInfo(){return this.filter?this.nodesInfo.filter(l=>this.filter.filter(new fs(this.id.overscaledZ,{worldview:this.worldview}),l.feature,this.id.canonical)):this.nodesInfo}destroy(){const l=this.getNodesInfo();for(const u of l)ZP(u.node),n$(u.node)}isEmpty(){return!this.nodesInfo.length}updateReplacement(l,u){if(u.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=u.updateTime;const p=u.getReplacementRegionsForTile(l.toUnwrapped());for(const x of this.getNodesInfo()){const b=x.node.footprint;x.hiddenByReplacement=!!b&&!p.find(T=>T.footprint===b)}}getHeightAtTileCoord(l,u){const p=[],x=[0,0,0],b=I([]);for(const T of this.getNodesInfo()){const k=T.node.meshes[0],P=k.transformedAabb;if(lP.max[0]||u>P.max[1])continue;if(T.node.hidden===!0)return{height:1/0,maxHeight:T.feature.properties.height,hidden:!1,verticalScale:T.evaluatedScale[2]};M(b,T.node.globalMatrix),x[0]=l,x[1]=u,or(x,x,b);const O=(x[0]-k.aabb.min[0])/(k.aabb.max[0]-k.aabb.min[0])*S_|0,$=Math.min(63,(x[1]-k.aabb.min[1])/(k.aabb.max[1]-k.aabb.min[1])*S_|0)*S_+Math.min(63,O),V=k.heightmap[$];if(!(V<0&&T.node.footprint))return T.hiddenByReplacement?void 0:{height:V,maxHeight:T.feature.properties.height,hidden:!1,verticalScale:T.evaluatedScale[2]};if(T.node.footprint.grid.query(new Ft(l,u),new Ft(l,u),p),p.length>0)return{height:void 0,maxHeight:T.feature.properties.height,hidden:T.hiddenByReplacement,verticalScale:T.evaluatedScale[2]}}}}function P2(h,l){return h instanceof fy&&!h.isLightConstant&&l}function pLe(h,l,u,p,x,b,T,k){let P=(61440&l|(61440&l)>>4)>>8,O=(3840&l|(3840&l)>>4)>>4,$=240&l|(240&l)>>4;u[3]>0&&(P=sn(P,255*u[0],u[3]),O=sn(O,255*u[1],u[3]),$=sn($,255*u[2],u[3]));const V=P<<8|O,G=$<<8|Math.floor(255*p[3]),Y=function(Ie){const We=pe(Ie,0,2);return Math.min(Math.round(.5*We*255),255)}(p[2])<<8|15*p[0]<<4|15*p[1],X=pe(x[0],0,1),te=pe(x[1],0,1),se=pe(x[2],0,1),ae=pe(x[3],0,1);let fe,ue,we,Ae;if(X!==te&&T!==b&&te!==X){const Ie=T-b;ue=1/(Ie*(te-X)),we=-(b+Ie*X)/(Ie*(te-X));const We=pe(x[4],-1,1);Ae=Math.pow(10,We),fe=255*se<<8|255*ae}else fe=65535,ue=0,we=1,Ae=1;if(h.emplaceBack(V,G,Y,fe,ue,we,Ae),k){const Ie=k.length;k.clear();for(let We=0;We>16&65535,$=b?P>>16&65535:65535&P,V=(15&$)<8?15&$:0,G=h.evaluatedRMEA[V],Y=h.evaluatedColor[V],X=h.emissionHeightBasedParams[V];let te;if(k&&V===2&&p.lights&&(te=new pw,te.resize(10*p.lights.length)),pLe(T.featureArray,O,Y,G,X,T.aabb.min[2],T.aabb.max[2],te),te&&k){k=!1;const se=p.meshes[p.lightMeshIndex];se.featureArray=te,se.featureArray._trim()}}T.featureArray._trim(),x++}}Tr(xR,"Tiled3dModelBucket",{omit:["layers"]}),Tr(Nee,"Tiled3dModelFeature");const yLe=["id","tile","layer","source","sourceLayer","state"];class N_{constructor(l,u,p,x,b){this.type="Feature",this._vectorTileFeature=l,this._z=u,this._x=p,this._y=x,this.properties=l?l.properties:{},this.id=b}clone(){const l=new N_(this._vectorTileFeature,this._z,this._x,this._y,this.id);return this.state&&(l.state=Object.assign({},this.state)),this.layer&&(l.layer=Object.assign({},this.layer)),this.source&&(l.source=this.source),this.sourceLayer&&(l.sourceLayer=this.sourceLayer),l}get geometry(){return this._geometry===void 0&&this._vectorTileFeature&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._x,this._y,this._z).geometry),this._geometry}set geometry(l){this._geometry=l}toJSON(){const l={type:"Feature",state:void 0,geometry:this.geometry,properties:this.properties};for(const u of yLe)this[u]!==void 0&&(l[u]=this[u]);return l}}class C_ extends N0{constructor(l,u,p,x){super(),this.id=l,this.type="model",this.models=[],this._options=u,this._modelsInfo=new Map,this._abortController=null}cancelModelRequests(){this._abortController&&(this._abortController.abort(),this._abortController=null)}loadGLTFFromURI(l,u){return GQ(this.map._requestManager.transformRequest(l,k0.Model).url,u)}async loadModel(l,u,p){try{const x=await this.loadGLTFFromURI(u.uri,p);if(p.aborted)return;const b=this._modelsInfo.get(l);if(!b)return;const T=i$(x),k=b.modelSpec,P=new ZQ(l,k.uri,k.position,k.orientation,T);C_.applyModelSpecification(P,k),P.computeBoundsAndApplyParent(),this.models.push(P),b.model=P}catch(x){if(x instanceof Error&&x.name==="AbortError")return;const b=x instanceof Error?x.message:"Unknown error";this.fire(new Qg(new Error(`Could not load model ${l} from ${u.uri}: ${b}`)))}}async load(){this._abortController||(this._abortController=new AbortController);const l=this._abortController.signal,u=[];for(const p in this._options.models){const x=this._options.models[p],b=this._modelsInfo.get(p);if(b&&b.model){b.modelSpec=x;const T=b.model;T.position=x.position!=null?new Je(x.position[0],x.position[1]):new Je(0,0),T.orientation=x.orientation!=null?x.orientation:[0,0,0],C_.applyModelSpecification(T,x),T.computeBoundsAndApplyParent(),this.models.push(T)}else b?b.modelSpec=x:(this._modelsInfo.set(p,{modelSpec:x,model:null}),u.push(this.loadModel(p,x,l)))}u.length!==0?(await Promise.allSettled(u),l.aborted||this.fire(new ad("data",{dataType:"source",sourceDataType:"metadata"}))):this.loaded()&&this.fire(new ad("data",{dataType:"source",sourceDataType:"metadata"}))}static applyModelSpecification(l,u){u.nodeOverrides&&C_.convertNodeOverrides(l,u.nodeOverrides),u.materialOverrides&&C_.convertMaterialOverrides(l,u.materialOverrides),u.nodeOverrideNames&&(l.nodeOverrideNames=[...u.nodeOverrideNames]),u.materialOverrideNames&&(l.materialOverrideNames=[...u.materialOverrideNames]),u.featureProperties&&(l.featureProperties=u.featureProperties)}static convertNodeOverrides(l,u){if(Array.isArray(u)&&u.every(p=>typeof p=="string")){l.nodeOverrideNames=[];for(const p of u)l.nodeOverrideNames.push(p)}else Object.entries(u).forEach(([p,x])=>{const b={orientation:[0,0,0]};if(x.hasOwnProperty("orientation")){const T=x.orientation;T&&(b.orientation=T)}l.nodeOverrides.set(p,b)})}static convertMaterialOverrides(l,u){if(Array.isArray(u)&&u.every(p=>typeof p=="string")){l.materialOverrideNames=[];for(const p of u)l.materialOverrideNames.push(p)}else Object.entries(u).forEach(([p,x])=>{const b={color:new as(1,1,1),colorMix:0,emissionStrength:0,opacity:1},T=x["model-color"];T!==void 0&&(b.color.r=T[0],b.color.g=T[1],b.color.b=T[2]);const k=x["model-color-mix-intensity"];k!==void 0&&(b.colorMix=k);const P=x["model-emissive-strength"];P!==void 0&&(b.emissionStrength=P);const O=x["model-opacity"];O!==void 0&&(b.opacity=O),l.materialOverrides.set(p,b)})}onAdd(l){this.map=l,this.load()}hasTransition(){return!1}loaded(){if(this._modelsInfo.size===0)return!0;for(const l of this._modelsInfo.values())if(l.model==null)return!1;return!0}getModels(){return this.models}loadTile(l,u){}serialize(){return this._options}setProperty(l,u){return!1}reload(){this.cancelModelRequests();const l=Cp(this.id,this.scope);this.map.style.clearSource(l),this.models=[],this._modelsInfo.clear(),this.load()}onRemove(l){this.cancelModelRequests()}setModels(l){this.models=[];const u=new Map;for(const p in l){const x=l[p],b=this._modelsInfo.get(p);b&&b.modelSpec.uri===x.uri&&u.set(p,b)}if(this._modelsInfo.size!==u.size){this.cancelModelRequests();for(const[p,x]of u)x.model||u.delete(p)}this._modelsInfo=u,this._options.models=l,this.load()}}function $$(h,l,u,p){const x=1<P>=Ae.vertexArrayOffset&&Pwe.polygon).flat());const se=Y?k:null,[ae,fe]=CQ(b,p,V,$,O,T,se,G,X,b.center.lat,h.tileID.canonical),ue=h.queryGeometry;return NQ(ae,fe,ue.isPointQuery()?ue.screenBounds:ue.screenGeometry)}},building:class extends fl{constructor(h,l,u,p){super(h,{layout:nJ||(nJ=new hi({visibility:new sr(at.layout_building.visibility),"building-facade":new Qt(at.layout_building["building-facade"]),"building-facade-floors":new Qt(at.layout_building["building-facade-floors"]),"building-facade-unit-width":new Qt(at.layout_building["building-facade-unit-width"]),"building-facade-window":new Qt(at.layout_building["building-facade-window"]),"building-roof-shape":new Qt(at.layout_building["building-roof-shape"]),"building-height":new Qt(at.layout_building["building-height"]),"building-base":new Qt(at.layout_building["building-base"]),"building-flood-light-wall-radius":new Qt(at.layout_building["building-flood-light-wall-radius"]),"building-flood-light-ground-radius":new Qt(at.layout_building["building-flood-light-ground-radius"]),"building-flip-roof-orientation":new Qt(at.layout_building["building-flip-roof-orientation"])})),paint:sJ||(sJ=new hi({"building-opacity":new sr(at.paint_building["building-opacity"]),"building-ambient-occlusion-intensity":new sr(at.paint_building["building-ambient-occlusion-intensity"]),"building-ambient-occlusion-ground-intensity":new sr(at.paint_building["building-ambient-occlusion-ground-intensity"]),"building-ambient-occlusion-ground-radius":new sr(at.paint_building["building-ambient-occlusion-ground-radius"]),"building-ambient-occlusion-ground-attenuation":new sr(at.paint_building["building-ambient-occlusion-ground-attenuation"]),"building-vertical-scale":new sr(at.paint_building["building-vertical-scale"]),"building-cast-shadows":new sr(at.paint_building["building-cast-shadows"]),"building-color":new Qt(at.paint_building["building-color"]),"building-emissive-strength":new Qt(at.paint_building["building-emissive-strength"]),"building-facade-emissive-chance":new sr(at.paint_building["building-facade-emissive-chance"]),"building-cutoff-fade-range":new sr(at.paint_building["building-cutoff-fade-range"]),"building-front-cutoff":new sr(at.paint_building["building-front-cutoff"]),"building-flood-light-color":new sr(at.paint_building["building-flood-light-color"]),"building-flood-light-intensity":new sr(at.paint_building["building-flood-light-intensity"]),"building-flood-light-ground-attenuation":new sr(at.paint_building["building-flood-light-ground-attenuation"]),"building-color-use-theme":new Qt({type:"string",default:"default","property-type":"data-driven"}),"building-flood-light-color-use-theme":new Qt({type:"string",default:"default","property-type":"data-driven"})}))},l,u,p),this._stats={numRenderedVerticesInShadowPass:0,numRenderedVerticesInTransparentPass:0}}createBucket(h){return new rJ(h)}cutoffRange(){return this.paint.get("building-cutoff-fade-range")}hasShadowPass(){return this.paint.get("building-cast-shadows")}hasLightBeamPass(){return!0}canCastShadows(){return!0}is3D(h){return!0}queryRadius(h){return 0}queryIntersectsFeature(h,l,u,p,x,b,T,k,P,O){let $=this.layout.get("building-height").evaluate(l,u);const V=this.layout.get("building-base").evaluate(l,u),G=h.tile.getBucket(this).getFootprint(l);if(G){if(G.hiddenFlags!==0)return!1;$=G.height}const[Y,X]=CQ(b,p,V,$,new Ft(0,0),T,null,[0,0],1,b.center.lat,h.tileID.canonical),te=h.queryGeometry;return NQ(Y,X,te.isPointQuery()?te.screenBounds:te.screenGeometry)}},line:class extends fl{constructor(h,l,u,p){const x=mJ();super(h,x,l,u,p),x.layout&&(this.layout=new Gh(x.layout)),this.gradientVersion=0,this.hasElevatedBuckets=!1,this.hasNonElevatedBuckets=!1}_handleSpecialPaintPropertyUpdate(h){if(h==="line-gradient"){const l=this._transitionablePaint._values["line-gradient"].value.expression;this.stepInterpolant=l._styleExpression&&l._styleExpression.expression instanceof q0,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}widthExpression(){return this._transitionablePaint._values["line-width"].value.expression}emissiveStrengthExpression(){return this._transitionablePaint._values["line-emissive-strength"].value.expression}recalculate(h,l){super.recalculate(h,l),this.paint._values["line-floorwidth"]=(()=>{if(x2)return x2;const u=mJ();return x2=new dRe(u.paint.properties["line-width"].specification),x2.useIntegerZoom=!0,x2})().possiblyEvaluate(this._transitioningPaint._values["line-width"].value,h)}createBucket(h){return new QP(h)}getProgramIds(){const h=[this.paint.get("line-pattern").constantOr(1)?"linePattern":"line"];return this.paint.get("line-blend-mode")!=="default"&&h.push("lineBlendComposite"),h}getDefaultProgramParams(h,l,u){if(h==="lineBlendComposite")return{};const p=hJ(this);return{config:new re(this,{zoom:l,lut:u}),defines:p,overrideFog:!1}}queryRadius(h){const l=h,u=pJ(wy("line-width",this,l),wy("line-gap-width",this,l)),p=wy("line-offset",this,l);return u/2+Math.abs(p)+wP(this.paint.get("line-translate"))}queryIntersectsFeature(h,l,u,p,x,b){if(h.queryGeometry.isAboveHorizon)return!1;const T=fX(h.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),b.angle,h.pixelToTileUnitsFactor),k=h.pixelToTileUnitsFactor/2*pJ(this.paint.get("line-width").evaluate(l,u),this.paint.get("line-gap-width").evaluate(l,u)),P=this.paint.get("line-offset").evaluate(l,u);return P&&(p=function(O,$){const V=[],G=new Ft(0,0);for(let Y=0;Y=3){for(let X=0;X{this._triggered=!1,this._callback()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout(()=>{this._triggered=!1,this._callback()},0))}remove(){this._channel=void 0,this._callback=()=>{}}}class Cee{constructor(l){this._stringToNumber={},this._numberToString=[];for(let u=0;u=0&&G[3]>=0&&O.insert(P,G[0],G[1],G[2],G[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new us(new JP(this.rawTileData)).layers,this.sourceLayerCoder=new Cee(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={};for(const l in this.vtLayers)this.vtFeatures[l]=[]}return this.vtLayers}query(l,u){const{tilespaceGeometry:p,transform:x,tileTransform:b,pixelPosMatrix:T,availableImages:k,worldview:P}=u;this.loadVTLayers(),this.serializedLayersCache.clear();const O=u.queryRadius?u.queryRadius:0,$=p.bufferedTilespaceBounds,V=this.grid.query($.min.x,$.min.y,$.max.x,$.max.y,(te,se,ae,fe)=>nm(p.bufferedTilespaceGeometry,te-O,se-O,ae+O,fe+O));V.sort(bLe);let G=null;x.elevation&&V.length>0&&(G=Mw.create(x.elevation,this.tileID));const Y={};let X;for(let te=0;te(fe||(fe=Kr(ue,this.tileID.canonical,b)),we.queryIntersectsFeature(p,ue,Ae,fe,this.z,x,T,G,Ie,u.scope)))}return Y}loadMatchingFeature(l,u,p,x,b,T){const{featureIndex:k,bucketIndex:P,sourceLayerIndex:O,layoutVertexArrayOffset:$}=u,V=this.bucketLayerIDs[P],G=p.layers,Y=Object.keys(G);if(Y.length&&!zr(Y,V))return;const X=p.sourceCache,te=this.sourceLayerCoder.decode(O),se=this.vtLayers[te].feature(k),ae=this.getId(se,te);for(let fe=0;fe`${k.key}: ${k.message}`).join(", ");return void hr(`Failed to create expression for promoteId: ${T}`)}this.promoteIdExpression=b.value}p=this.promoteIdExpression.evaluate({zoom:0},l)}else p=l.properties[x];typeof p=="boolean"&&(p=Number(p))}return p}}function Pee(h,l,u,p,x){return Gt(h,(b,T)=>{const k=l instanceof Gh?l.get(T):null;return k&&k.evaluate?k.evaluate(u,p,void 0,x):k})}function bLe(h,l){return l-h}function Ree(h,l){const u={};if(!l)return u;for(const p of h){const x=p.layerIds.map(b=>l.getLayer(b)).filter(Boolean);if(x.length!==0){p.layers=x,p.stateDependentLayerIds&&(p.stateDependentLayers=p.stateDependentLayerIds.map(b=>x.filter(T=>T.id===b)[0]));for(const b of x)u[b.fqid]=p}}return u}Tr(Iee,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});const th=32,um=33,Ny=new Uint16Array(8184);for(let h=0;h<2046;h++){let l=h+2,u=0,p=0,x=0,b=0,T=0,k=0;for(1&l?x=b=T=th:u=p=k=th;(l>>=1)>1;){const O=u+x>>1,$=p+b>>1;1&l?(x=u,b=p,u=T,p=k):(u=x,p=b,x=T,b=k),T=O,k=$}const P=4*h;Ny[P+0]=u,Ny[P+1]=p,Ny[P+2]=x,Ny[P+3]=b}const dm=new Uint16Array(2178),Cy=new Uint8Array(1089),_R=new Uint16Array(1089);function Lee(h){return h===0?-.03125:h===32?.03125:0}const Mee={Other:0,Symbol:1,FillExtrusion:2},Dee={type:2,extent:fr,loadGeometry:()=>[[new Ft(0,0),new Ft(8193,0),new Ft(8193,8193),new Ft(0,8193),new Ft(0,0)]]};class wLe{constructor(){this.tasks={},this.taskQueue=[],mt(["process"],this),this.invoker=new vLe(this.process),this.nextId=0}add(l,u){const p=this.nextId++,x=function({type:b,renderSourceType:T,zoom:k}){k=k||0;const P=T===Mee.Symbol;return b==="message"?0:b!=="maybePrepare"||P?b!=="parseTile"||P?b==="parseTile"&&P?300-k:b==="maybePrepare"&&P?400-k:500:200-k:100-k}(u);if(x===0){try{l()}finally{}return null}return this.tasks[p]={fn:l,metadata:u,priority:x,id:p},this.taskQueue.push(p),this.invoker.trigger(),{cancel:()=>{delete this.tasks[p]}}}process(){try{if(this.taskQueue=this.taskQueue.filter(p=>!!this.tasks[p]),!this.taskQueue.length)return;const l=this.pick();if(l===null)return;const u=this.tasks[l];if(delete this.tasks[l],this.taskQueue.length&&this.invoker.trigger(),!u)return;u.fn()}finally{}}pick(){let l=null,u=1/0;for(let x=0;x>16&255)/255,(h>>8&255)/255,(255&h)/255,1)}function LLe(h,l,u){h===1?(l.rgb_color=wR(u.readVarint()),l.paint="rgb_color"):h===2?(l.linear_gradient_idx=u.readVarint(),l.paint="linear_gradient_idx"):h===3?(l.radial_gradient_idx=u.readVarint(),l.paint="radial_gradient_idx"):h===5?u.readPackedFloat(l.dasharray):h===6?l.dashoffset=u.readFloat():h===7?l.miterlimit=u.readFloat():h===8?l.opacity=u.readVarint():h===9?l.width=u.readFloat():h===10?l.linecap=u.readVarint():h===11&&(l.linejoin=u.readVarint())}function MLe(h,l,u){h===1?l.transform=bR(u,u.readVarint()+u.pos):h===2?l.spread_method=u.readVarint():h===3?l.stops.push(Bee(u,u.readVarint()+u.pos)):h===4?l.x1=u.readFloat():h===5?l.y1=u.readFloat():h===6?l.x2=u.readFloat():h===7&&(l.y2=u.readFloat())}function Bee(h,l){return h.readFields(DLe,{offset:0,opacity:255,rgb_color:z$},l)}function DLe(h,l,u){h===1?l.offset=u.readFloat():h===2?l.opacity=u.readVarint():h===3&&(l.rgb_color=wR(u.readVarint()))}function OLe(h,l,u){h===1?l.transform=bR(u,u.readVarint()+u.pos):h===2?l.spread_method=u.readVarint():h===3?l.stops.push(Bee(u,u.readVarint()+u.pos)):h===4?l.cx=u.readFloat():h===5?l.cy=u.readFloat():h===6?l.r=u.readFloat():h===7?l.fx=u.readFloat():h===8?l.fy=u.readFloat():h===9&&(l.fr=u.readFloat())}function FLe(h,l,u){h===1?l.transform=bR(u,u.readVarint()+u.pos):h===2?l.clip_path_idx=u.readVarint():h===3&&l.children.push(vR(u,u.readVarint()+u.pos))}function BLe(h,l,u){h===1?l.left=l.top=u.readFloat():h===2?l.width=l.height=u.readFloat():h===3?l.top=u.readFloat():h===4?l.height=u.readFloat():h===5?l.mask_type=u.readVarint():h===6?l.mask_idx=u.readVarint():h===7&&l.children.push(vR(u,u.readVarint()+u.pos))}class $Le{static calculate(l={},u=[]){const p=new Map,x=new Map;if(Object.keys(l).length===0)return p;u.forEach(b=>{x.set(b.name,b.rgb_color||new as(0,0,0))});for(const[b,T]of Object.entries(l))x.has(b)?p.set(x.get(b).toString(),T):console.warn(`Ignoring unknown image variable "${b}"`);return p}}function Dw(h,l=255,u){const p=l/255,x=h.toString(),b=u.has(x)?u.get(x).clone():h.clone();return b.a*=p,b.toString()}function R2(h,l){if(!Au()){const u=document.createElement("canvas");return u.width=h,u.height=l,u}return new OffscreenCanvas(h,l)}let U$,L2=null;function V$(h,l,u,p,x){for(const b of p.children)$ee(h,l,u,b,x)}function $ee(h,l,u,p,x){p.group?(h.save(),function(b,T,k,P,O){const $=P.mask_idx!=null?k.masks[P.mask_idx]:null,V=P.clip_path_idx!=null?k.clip_paths[P.clip_path_idx]:null;if(P.transform&&(T=Ow(P.transform).preMultiplySelf(T)),!function(X,te,se){return X.opacity!==255||te||se}(P,V!=null,$!=null))return void V$(b,T,k,P,O);const G=R2(b.canvas.width,b.canvas.height),Y=G.getContext("2d");V$(Y,T,k,P,O),V&&Wee(Y,T,k,V),$&&Kee(Y,T,k,$,O),b.globalAlpha=P.opacity/255,b.drawImage(G,0,0)}(h,l,u,p.group,x),h.restore()):p.path&&(h.save(),function(b,T,k,P,O){b.setTransform(T),P.paint_order===1?(zee(b,k,P,O),Vee(b,k,P,O)):(Vee(b,k,P,O),zee(b,k,P,O))}(h,l,u,p.path,x),h.restore())}function zee(h,l,u,p){const x=u.fill;if(!x)return;const b=x.opacity/255;switch(h.save(),h.beginPath(),Yee(u,h),x.paint){case"rgb_color":h.fillStyle=Dw(x.rgb_color,x.opacity,p);break;case"linear_gradient_idx":{const T=l.linear_gradients[x.linear_gradient_idx];T.transform&&h.setTransform(Ow(T.transform).preMultiplySelf(h.getTransform())),h.fillStyle=qee(h,T,b,p);break}case"radial_gradient_idx":{const T=l.radial_gradients[x.radial_gradient_idx];T.transform&&h.setTransform(Ow(T.transform).preMultiplySelf(h.getTransform())),h.fillStyle=Gee(h,T,b,p)}}h.fill(Uee(u)),h.restore()}function Uee(h){return h.rule===1?"nonzero":h.rule===2?"evenodd":void 0}function Vee(h,l,u,p){const x=u.stroke;if(!x)return;const b=Zee(u);h.lineWidth=x.width,h.miterLimit=x.miterlimit,h.setLineDash(x.dasharray),h.lineDashOffset=x.dashoffset;const T=x.opacity/255;switch(x.paint){case"rgb_color":h.strokeStyle=Dw(x.rgb_color,x.opacity,p);break;case"linear_gradient_idx":h.strokeStyle=qee(h,l.linear_gradients[x.linear_gradient_idx],T,p,!0);break;case"radial_gradient_idx":h.strokeStyle=Gee(h,l.radial_gradients[x.radial_gradient_idx],T,p,!0)}switch(x.linejoin){case 2:case 1:h.lineJoin="miter";break;case 3:h.lineJoin="round";break;case 4:h.lineJoin="bevel"}switch(x.linecap){case 1:h.lineCap="butt";break;case 2:h.lineCap="round";break;case 3:h.lineCap="square"}h.stroke(b)}function qee(h,l,u,p,x=!1){if(l.stops.length===1){const G=l.stops[0];return Dw(G.rgb_color,G.opacity*u,p)}const{x1:b,y1:T,x2:k,y2:P}=l;let O=new DOMPoint(b,T),$=new DOMPoint(k,P);if(x){const G=Ow(l.transform);O=G.transformPoint(O),$=G.transformPoint($)}const V=h.createLinearGradient(O.x,O.y,$.x,$.y);for(const G of l.stops)V.addColorStop(G.offset,Dw(G.rgb_color,G.opacity*u,p));return V}function Gee(h,l,u,p,x=!1){if(l.stops.length===1){const ae=l.stops[0];return Dw(ae.rgb_color,ae.opacity*u,p)}const b=Ow(l.transform),{fx:T,fy:k,fr:P,cx:O,cy:$,r:V}=l;let G=new DOMPoint(T,k),Y=new DOMPoint(O,$),X=P,te=V;if(x){G=b.transformPoint(G),Y=b.transformPoint(Y);const ae=(b.a+b.d)/2;X=P*ae,te=l.r*ae}const se=h.createRadialGradient(G.x,G.y,X,Y.x,Y.y,te);for(const ae of l.stops)se.addColorStop(ae.offset,Dw(ae.rgb_color,ae.opacity*u,p));return se}function Hee(h,l,u,p){const x=p.transform?Ow(p.transform).preMultiplySelf(l):l,b=R2(h.canvas.width,h.canvas.height),T=b.getContext("2d");for(const P of p.children)if(P.group)Hee(T,x,u,P.group);else if(P.path){const O=P.path,$=new Path2D;$.addPath(Zee(O),x),T.fill($,Uee(O))}const k=p.clip_path_idx!=null?u.clip_paths[p.clip_path_idx]:null;k&&Wee(T,x,u,k),h.globalCompositeOperation="source-over",h.drawImage(b,0,0)}function Wee(h,l,u,p){const x=R2(h.canvas.width,h.canvas.height);Hee(x.getContext("2d"),l,u,p),h.globalCompositeOperation="destination-in",h.drawImage(x,0,0)}function Kee(h,l,u,p,x){if(p.children.length===0)return;const b=p.mask_idx!=null?u.masks[p.mask_idx]:null;b&&Kee(h,l,u,b,x);const T=h.canvas.width,k=h.canvas.height,P=R2(T,k),O=P.getContext("2d"),$=p.width,V=p.height,G=p.left,Y=p.top,X=new Path2D,te=new Path2D;te.rect(G,Y,$,V),X.addPath(te,l),O.clip(X);for(const fe of p.children)$ee(O,l,u,fe,x);const se=O.getImageData(0,0,T,k),ae=se.data;if(p.mask_type===1)for(let fe=0;fel[T])return null}else{const k=1/p[T];let P=(h[T]-u[T])*k,O=(l[T]-u[T])*k;if(P>O){const $=P;P=O,O=$}if(P>x&&(x=P),Ob)return null}return x}function Jee(h,l,u,p,x,b,T,k,P,O,$){const V=p-h,G=x-l,Y=b-u,X=T-h,te=k-l,se=P-u,ae=$[1]*se-$[2]*te,fe=$[2]*X-$[0]*se,ue=$[0]*te-$[1]*X,we=V*ae+G*fe+Y*ue;if(Math.abs(we)<1e-15)return null;const Ae=1/we,Ie=O[0]-h,We=O[1]-l,ze=O[2]-u,He=(Ie*ae+We*fe+ze*ue)*Ae;if(He<0||He>1)return null;const Ve=We*Y-ze*G,qe=ze*V-Ie*Y,bt=Ie*G-We*V,jt=($[0]*Ve+$[1]*qe+$[2]*bt)*Ae;return jt<0||He+jt>1?null:(X*Ve+te*qe+se*bt)*Ae}function ete(h,l,u){return(h-l)/(u-l)}function tte(h,l,u,p,x,b,T,k,P){const O=1<{const fe=se?1:0,ue=(Y+1)*te-fe,we=X*te,Ae=(X+1)*te-fe;ae[0]=Y*te,ae[1]=we,ae[2]=ue,ae[3]=Ae};let V=new Xee(P);const G=[];for(let Y=0;Y=1;P/=2){const Y=k[k.length-1];V=new Xee(P);for(let X=0;X0;){const{idx:X,t:te,nodex:se,nodey:ae,depth:fe}=Y.pop();if(this.leaves[X]){tte(se,ae,fe,l,u,p,x,V,G);const we=1<=Pt[2])return te}continue}let ue=0;for(let we=0;we=O[$[ze]]&&($.splice(ze,0,we),We=!0);We||($[ue]=we),ue++}}for(let we=0;we=this.dim+1||u<-1||u>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(u+1)*this.stride+(l+1)}static pack(l,u){const p=[0,0,0,0],x=TR.getUnpackVector(u);let b=Math.floor((l+x[3])/x[2]);return p[2]=b%256,b=Math.floor(b/256),p[1]=b%256,b=Math.floor(b/256),p[0]=b,p}getPixels(){return new FX({width:this.stride,height:this.stride},this.pixels)}backfillBorder(l,u,p){if(this.dim!==l.dim)throw new Error("dem dimension mismatch");let x=u*this.dim,b=u*this.dim+this.dim,T=p*this.dim,k=p*this.dim+this.dim;switch(u){case-1:x=b-1;break;case 1:b=x+1}switch(p){case-1:T=k-1;break;case 1:k=T+1}const P=-u*this.dim,O=-p*this.dim;for(let $=T;$=1;p--){const x=p===1?1:0,b=p===2?1:0;for(let T=0;T>>1^-(1&h[l]);return h}function eMe(h,l){switch(l){case"uint32":return h;case"uint16":for(let u=0;u>4|(61440&p)>>8|(240&x)<<4|61440&x,h[u+1]=15&p|(3840&p)>>4|(15&x)<<8|(3840&x)<<4}return h;case"uint8":for(let u=0;u>6|(192&x)>>4|(192&b)>>2|192&T,h[u+1]=(48&p)>>4|(48&x)>>2|48&b|(48&T)<<2,h[u+2]=(12&p)>>2|12&x|(12&b)<<2|(12&T)<<4,h[u+3]=3&p|(3&x)<<2|(3&b)<<4|(3&T)<<6}return h;default:throw new Error(`Invalid pixel format, "${l}"`)}}Tr(TR,"DEMData"),Tr(rte,"DemMinMaxQuadTree",{omit:["dem"]});var hd=Uint8Array,M2=Uint16Array,tMe=Int32Array,ste=new hd([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),ite=new hd([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),rMe=new hd([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ate=function(h,l){for(var u=new M2(31),p=0;p<31;++p)u[p]=l+=1<>1|(21845&Oa)<<1;cte[Oa]=((65280&(Fw=(61680&(Fw=(52428&Fw)>>2|(13107&Fw)<<2))>>4|(3855&Fw)<<4))>>8|(255&Fw)<<8)>>1}var D2=function(h,l,u){for(var p=h.length,x=0,b=new M2(l);x>P]=O;return T},O2=new hd(288);for(Oa=0;Oa<144;++Oa)O2[Oa]=8;for(Oa=144;Oa<256;++Oa)O2[Oa]=9;for(Oa=256;Oa<280;++Oa)O2[Oa]=7;for(Oa=280;Oa<288;++Oa)O2[Oa]=8;var ute=new hd(32);for(Oa=0;Oa<32;++Oa)ute[Oa]=5;var iMe=D2(O2,9),aMe=D2(ute,5),G$=function(h){for(var l=h[0],u=1;ul&&(l=h[u]);return l},Qh=function(h,l,u){var p=l/8|0;return(h[p]|h[p+1]<<8)>>(7&l)&u},H$=function(h,l){var u=l/8|0;return(h[u]|h[u+1]<<8|h[u+2]<<16)>>(7&l)},oMe=function(h){return(h+7)/8|0},lMe=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],Jh=function(h,l,u){var p=new Error(l||lMe[h]);if(p.code=h,Error.captureStackTrace&&Error.captureStackTrace(p,Jh),!u)throw p;return p},cMe=new hd(0),uMe=typeof TextDecoder<"u"&&new TextDecoder;try{uMe.decode(cMe,{stream:!0})}catch{}const dMe={gzip_data:"gzip"};class rh extends Error{constructor(l){super(l),this.name="MRTError"}}const hMe={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},dte={uint32:1,uint16:2,uint8:4},fMe={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};let W$;class ER{constructor(l=5){this.x=NaN,this.y=NaN,this.z=NaN,this.layers={},this._cacheSize=l}getLayer(l){const u=this.layers[l];if(!u)throw new rh(`Layer '${l}' not found`);return u}getHeaderLength(l){const u=new Uint8Array(l),p=new DataView(l);if(u[0]!==13)throw new rh("File is not a valid MRT.");return p.getUint32(1,!0)}parseHeader(l){const u=new Uint8Array(l),p=this.getHeaderLength(l);if(u.length= ${p} but got buffer of length ${u.length}`);const x=new W$(u.subarray(0,p)).readFields(qLe,{headerLength:0,x:0,y:0,z:0,layers:[]},void 0);if(!isNaN(this.x)&&(this.x!==x.x||this.y!==x.y||this.z!==x.z))throw new rh(`Invalid attempt to parse header ${x.z}/${x.x}/${x.y} for tile ${this.z}/${this.x}/${this.y}`);this.x=x.x,this.y=x.y,this.z=x.z;for(const b of x.layers)this.layers[b.name]=new hte(b,{cacheSize:this._cacheSize});return this}createDecodingTask(l){const u=[],p=this.getLayer(l.layerName);for(let x of l.blockIndices){const b=p.dataIndex[x],T=b.firstByte-l.firstByte,k=b.lastByte-l.firstByte;if(p._blocksInProgress.has(x))continue;const P={layerName:p.name,firstByte:T,lastByte:k,pixelFormat:p.pixelFormat,blockIndex:x,blockShape:[b.bands.length].concat(p.bandShape),buffer:p.buffer,codec:b.codec.codec,filters:b.filters.map(O=>O.filter)};p._blocksInProgress.add(x),u.push(P)}return new fte(u,()=>{u.forEach(x=>p._blocksInProgress.delete(x.blockIndex))},(x,b)=>{if(u.forEach(T=>p._blocksInProgress.delete(T.blockIndex)),x)throw x;b.forEach(T=>{this.getLayer(T.layerName).processDecodedData(T)})})}}class hte{constructor({version:l,name:u,units:p,tileSize:x,pixelFormat:b,buffer:T,dataIndex:k},P){if(this.version=l,this.version!==1)throw new rh(`Cannot parse raster layer encoded with MRT version ${l}`);this.name=u,this.units=p,this.tileSize=x,this.buffer=T,this.pixelFormat=hMe[b],this.dataIndex=k,this.bandShape=[x+2*T,x+2*T,dte[this.pixelFormat]],this._decodedBlocks=new SR(P?P.cacheSize:5),this._blocksInProgress=new Set}get dimension(){return dte[this.pixelFormat]}get cacheSize(){return this._decodedBlocks.capacity}getBandList(){return this.dataIndex.map(({bands:l})=>l).flat()}processDecodedData(l){const u=l.blockIndex.toString();this._decodedBlocks.get(u)||this._decodedBlocks.put(u,l.data)}getBlockForBand(l){let u=0;switch(typeof l){case"string":for(const[p,x]of this.dataIndex.entries()){for(const[b,T]of x.bands.entries())if(T===l)return{bandIndex:u+b,blockIndex:p,blockBandIndex:b};u+=x.bands.length}break;case"number":for(const[p,x]of this.dataIndex.entries()){if(l>=u&&lthis.cacheSize)throw new rh(`Number of blocks to decode (${b.size}) exceeds cache size (${this.cacheSize}).`);return{layerName:this.name,firstByte:u,lastByte:p,blockIndices:x}}hasBand(l){const{blockIndex:u}=this.getBlockForBand(l);return u>=0}hasDataForBand(l){const{blockIndex:u}=this.getBlockForBand(l);return u>=0&&!!this._decodedBlocks.get(u.toString())}getBandView(l){const{blockIndex:u,blockBandIndex:p}=this.getBlockForBand(l);if(u<0)throw new rh(`Band not found: ${JSON.stringify(l)}`);const x=this._decodedBlocks.get(u.toString());if(!x)throw new rh(`Data for band ${JSON.stringify(l)} of layer "${this.name}" not decoded.`);const b=this.dataIndex[u],T=this.bandShape.reduce((O,$)=>O*$,1),k=p*T,P=x.subarray(k,k+T);return{data:P,bytes:new Uint8Array(P.buffer).subarray(P.byteOffset,P.byteOffset+P.byteLength),tileSize:this.tileSize,buffer:this.buffer,pixelFormat:this.pixelFormat,dimension:this.dimension,offset:b.offset,scale:b.scale}}}ER.setPbf=function(h){W$=h};class fte{constructor(l,u,p){this.tasks=l,this._onCancel=u,this._onComplete=p,this._finalized=!1}cancel(){this._finalized||(this._onCancel(),this._finalized=!0)}complete(l,u){this._finalized||(this._onComplete(l,u),this._finalized=!0)}}ER.performDecoding=function(h,l){const u=new Uint8Array(h);return Promise.all(l.tasks.map(p=>{const{layerName:x,firstByte:b,lastByte:T,pixelFormat:k,blockShape:P,blockIndex:O,filters:$,codec:V}=p,G=u.subarray(b,T+1),Y=new Uint32Array(P[0]*P[1]*P[2]);let X;if(V!=="gzip_data")throw new rh(`Unhandled codec: ${V}`);return X=function(te,se){if(!globalThis.DecompressionStream&&se==="gzip_data")return Promise.resolve((Ae=function(ze){ze[0]==31&&ze[1]==139&&ze[2]==8||Jh(6,"invalid gzip data");var He=ze[3],Ve=10;4&He&&(Ve+=2+(ze[10]|ze[11]<<8));for(var qe=(He>>3&1)+(He>>4&1);qe>0;qe-=!ze[Ve++]);return Ve+(2&He)}(ae=te),Ae+8>ae.length&&Jh(6,"invalid gzip data"),function(ze,He,Ve,qe){var bt=ze.length;if(!bt||He.f&&!He.l)return Ve||new hd(0);var jt=!Ve,It=jt||He.i!=2,Dt=He.i;jt&&(Ve=new hd(3*bt));var Pt=function(Ei){var ml=Ve.length;if(Ei>ml){var io=new hd(Math.max(2*ml,Ei));io.set(Ve),Ve=io}},Ht=He.f||0,_t=He.p||0,Rt=He.b||0,Bt=He.l,Yt=He.d,tr=He.m,br=He.n,ur=8*bt;do{if(!Bt){Ht=Qh(ze,_t,1);var cr=Qh(ze,_t+1,3);if(_t+=3,!cr){var rr=ze[(ms=oMe(_t)+4)-4]|ze[ms-3]<<8,_r=ms+rr;if(_r>bt){Dt&&Jh(0);break}It&&Pt(Rt+rr),Ve.set(ze.subarray(ms,_r),Rt),He.b=Rt+=rr,He.p=_t=8*_r,He.f=Ht;continue}if(cr==1)Bt=iMe,Yt=aMe,tr=9,br=5;else if(cr==2){var Pr=Qh(ze,_t,31)+257,Wr=Qh(ze,_t+10,15)+4,Mr=Pr+Qh(ze,_t+5,31)+1;_t+=14;for(var fn=new hd(Mr),Wn=new hd(19),mn=0;mn>4)<16)fn[mn++]=ms;else{var $s=0,xi=0;for(ms==16?(xi=3+Qh(ze,_t,3),_t+=2,$s=fn[mn-1]):ms==17?(xi=3+Qh(ze,_t,7),_t+=3):ms==18&&(xi=11+Qh(ze,_t,127),_t+=7);xi--;)fn[mn++]=$s}}var Ya=fn.subarray(0,Pr),_i=fn.subarray(Pr);tr=G$(Ya),br=G$(_i),Bt=D2(Ya,tr),Yt=D2(_i,br)}else Jh(1);if(_t>ur){Dt&&Jh(0);break}}It&&Pt(Rt+131072);for(var Ri=(1<>4;if((_t+=15&$s)>ur){Dt&&Jh(0);break}if($s||Jh(2),Mo<256)Ve[Rt++]=Mo;else{if(Mo==256){Li=_t,Bt=null;break}var Za=Mo-254;Mo>264&&(Za=Qh(ze,_t,(1<<(qi=ste[mn=Mo-257]))-1)+lte[mn],_t+=qi);var An=Yt[H$(ze,_t)&aa],Ml=An>>4;if(An||Jh(3),_t+=15&An,_i=sMe[Ml],Ml>3){var qi=ite[Ml];_i+=H$(ze,_t)&(1<ur){Dt&&Jh(0);break}It&&Pt(Rt+131072);var so=Rt+Za;if(Rt<_i){var Dl=0-_i,Do=Math.min(_i,so);for(Dl+Rt<0&&Jh(3);RtEi.length)&&(io=Ei.length),new hd(Ei.subarray(0,io))}(Ve,0,Rt):Ve.subarray(0,Rt)}(ae.subarray(Ae,-8),{i:2},new hd(((ue=ae)[(we=ue.length)-4]|ue[we-3]<<8|ue[we-2]<<16|ue[we-1]<<24)>>>0),fe)));var ae,fe,ue,we,Ae;const Ie=dMe[se];if(!Ie)throw new Error(`Unhandled codec: ${se}`);const We=new globalThis.DecompressionStream(Ie);return new Response(new Blob([te]).stream().pipeThrough(We)).arrayBuffer().then(ze=>new Uint8Array(ze))}(G,V).then(te=>(function(se,ae){se.readFields(ZLe,ae)}(new W$(te),Y),new fMe[k](Y.buffer))),X.then(te=>{for(let se=$.length-1;se>=0;se--)switch($[se]){case"delta_filter":QLe(te,P);break;case"zigzag_filter":JLe(te);break;case"bitshuffle_filter":eMe(te,k);break;default:throw new rh(`Unhandled filter "${$[se]}"`)}return{layerName:x,blockIndex:O,data:te}}).catch(te=>{throw te})}))},Tr(fte,"MRTDecodingBatch",{omit:["_onCancel","_onComplete"]}),Tr(ER,"MapboxRasterTile"),Tr(hte,"MapboxRasterLayer",{omit:["_blocksInProgress"]});const mte=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class K${static from(l){if(!(l instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[u,p]=new Uint8Array(l,0,2);if(u!==219)throw new Error("Data does not appear to be in a KDBush format.");const x=p>>4;if(x!==1)throw new Error(`Got v${x} data when expected v1.`);const b=mte[15&p];if(!b)throw new Error("Unrecognized array type.");const[T]=new Uint16Array(l,2,1),[k]=new Uint32Array(l,4,1);return new K$(k,T,b,l)}constructor(l,u=64,p=Float64Array,x){if(isNaN(l)||l<0)throw new Error(`Unpexpected numItems value: ${l}.`);this.numItems=+l,this.nodeSize=Math.min(Math.max(+u,2),65535),this.ArrayType=p,this.IndexArrayType=l<65536?Uint16Array:Uint32Array;const b=mte.indexOf(this.ArrayType),T=2*l*this.ArrayType.BYTES_PER_ELEMENT,k=l*this.IndexArrayType.BYTES_PER_ELEMENT,P=(8-k%8)%8;if(b<0)throw new Error(`Unexpected typed array class: ${p}.`);x&&x instanceof ArrayBuffer?(this.data=x,this.ids=new this.IndexArrayType(this.data,8,l),this.coords=new this.ArrayType(this.data,8+k+P,2*l),this._pos=2*l,this._finished=!0):(this.data=new ArrayBuffer(8+T+k+P),this.ids=new this.IndexArrayType(this.data,8,l),this.coords=new this.ArrayType(this.data,8+k+P,2*l),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+b]),new Uint16Array(this.data,2,1)[0]=u,new Uint32Array(this.data,4,1)[0]=l)}add(l,u){const p=this._pos>>1;return this.ids[p]=p,this.coords[this._pos++]=l,this.coords[this._pos++]=u,p}finish(){const l=this._pos>>1;if(l!==this.numItems)throw new Error(`Added ${l} items when expected ${this.numItems}.`);return Y$(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(l,u,p,x){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:b,coords:T,nodeSize:k}=this,P=[0,b.length-1,0],O=[];for(;P.length;){const $=P.pop()||0,V=P.pop()||0,G=P.pop()||0;if(V-G<=k){for(let se=G;se<=V;se++){const ae=T[2*se],fe=T[2*se+1];ae>=l&&ae<=p&&fe>=u&&fe<=x&&O.push(b[se])}continue}const Y=G+V>>1,X=T[2*Y],te=T[2*Y+1];X>=l&&X<=p&&te>=u&&te<=x&&O.push(b[Y]),($===0?l<=X:u<=te)&&(P.push(G),P.push(Y-1),P.push(1-$)),($===0?p>=X:x>=te)&&(P.push(Y+1),P.push(V),P.push(1-$))}return O}within(l,u,p){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:x,coords:b,nodeSize:T}=this,k=[0,x.length-1,0],P=[],O=p*p;for(;k.length;){const $=k.pop()||0,V=k.pop()||0,G=k.pop()||0;if(V-G<=T){for(let se=G;se<=V;se++)gte(b[2*se],b[2*se+1],l,u)<=O&&P.push(x[se]);continue}const Y=G+V>>1,X=b[2*Y],te=b[2*Y+1];gte(X,te,l,u)<=O&&P.push(x[Y]),($===0?l-p<=X:u-p<=te)&&(k.push(G),k.push(Y-1),k.push(1-$)),($===0?l+p>=X:u+p>=te)&&(k.push(Y+1),k.push(V),k.push(1-$))}return P}}function Y$(h,l,u,p,x,b){if(x-p<=u)return;const T=p+x>>1;pte(h,l,T,p,x,b),Y$(h,l,u,p,T-1,1-b),Y$(h,l,u,T+1,x,1-b)}function pte(h,l,u,p,x,b){for(;x>p;){if(x-p>600){const O=x-p+1,$=u-p+1,V=Math.log(O),G=.5*Math.exp(2*V/3),Y=.5*Math.sqrt(V*G*(O-G)/O)*($-O/2<0?-1:1);pte(h,l,u,Math.max(p,Math.floor(u-$*G/O+Y)),Math.min(x,Math.floor(u+(O-$)*G/O+Y)),b)}const T=l[2*u+b];let k=p,P=x;for(F2(h,l,p,u),l[2*x+b]>T&&F2(h,l,p,x);kT;)P--}l[2*p+b]===T?F2(h,l,p,P):(P++,F2(h,l,P,x)),P<=u&&(p=P+1),u<=P&&(x=P-1)}}function F2(h,l,u,p){Z$(h,u,p),Z$(l,2*u,2*p),Z$(l,2*u+1,2*p+1)}function Z$(h,l,u){const p=h[l];h[l]=h[u],h[u]=p}function gte(h,l,u,p){const x=h-u,b=l-p;return x*x+b*b}a.$=oy,a.A=class{constructor(h,l,u){this.target=h,this.parent=l,this.mapId=u,this.callbacks={},this.cancelCallbacks={},mt(["receive"],this),this.target.addEventListener("message",this.receive,!1),this.scheduler=new wLe}send(h,l,u,p,x=!1,b){const T=Math.round(1e18*Math.random()).toString(36).substring(0,10);u&&(u.metadata=b,this.callbacks[T]=u);const k=new Set;return this.target.postMessage({id:T,type:h,hasCallback:!!u,targetMapId:p,mustQueue:x,sourceMapId:this.mapId,data:Uh(l,k)},k),{cancel:()=>{u&&delete this.callbacks[T],this.target.postMessage({id:T,type:"",targetMapId:p,sourceMapId:this.mapId})}}}receive(h){const l=h.data;if(!l)return;const u=l.id;if(u&&(!l.targetMapId||this.mapId===l.targetMapId))if(l.type===""){const p=this.cancelCallbacks[u];delete this.cancelCallbacks[u],p&&p.cancel()}else if(l.mustQueue||wn(self)){const p=this.callbacks[u],x=this.scheduler.add(()=>this.processTask(u,l),p&&p.metadata||{type:"message"});x&&(this.cancelCallbacks[u]=x)}else this.processTask(u,l)}processTask(h,l){if(delete this.cancelCallbacks[h],l.type===""){const u=this.callbacks[h];delete this.callbacks[h],u&&(l.error?u(tm(l.error)):u(null,tm(l.data)))}else{const u=new Set,p=l.hasCallback?(b,T)=>{this.target.postMessage({id:h,type:"",sourceMapId:this.mapId,error:b?Uh(b):null,data:Uh(T,u)},u)}:()=>{},x=tm(l.data);if(this.parent[l.type])this.parent[l.type](l.sourceMapId,x,p);else if(this.parent.getWorkerSource){const b=l.type.split("."),{source:T,scope:k}=x;this.parent.getWorkerSource(l.sourceMapId,{type:b[0],source:T,scope:k,uid:0})[b[1]](x,p)}else p(new Error(`Could not find function ${l.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}},a.B=Qg,a.C=ad,a.D=Pu,a.E=N0,a.F=Cp,a.G=2,a.H=b2,a.I=bc,a.J=LJ,a.K=jb,a.L=aP,a.M=L0,a.N=M0,a.O=Kb,a.P=Ft,a.Q=Wb,a.R=k0,a.S=lj,a.T=cm,a.U=e_,a.V=yR,a.W=aw,a.X=em,a.Y=uj,a.Z=Kd,a._=Sp,a.a=function(h){return Vn.API_CDN_URL_REGEX.test(h)},a.a$=JP,a.a0=Wa,a.a1=D0,a.a2=kb,a.a3=FE,a.a4=Nj,a.a5=class extends yR{},a.a6=cj,a.a7=VI,a.a8=at,a.a9=function(h){const l=h.value;return l?kb(l)?O$(l,!0)?[]:[new yR(h.key,l,`invalid url "${l}"`)]:[new yR(h.key,l,`string expected, "${L0(l)}" found`)]:[]},a.aA=lJ,a.aB=function(h){let l=1/0,u=1/0,p=-1/0,x=-1/0;for(const b of h)l=Math.min(l,b.x),u=Math.min(u,b.y),p=Math.max(p,b.x),x=Math.max(x,b.y);return{min:new Ft(l,u),max:new Ft(p,x)}},a.aC=pe,a.aD=D,a.aE=Kt,a.aF=Me,a.aG=Zl,a.aH=Ot,a.aI=vr,a.aJ=function(h,l){const u={};for(let p=0;p=0?l.slice(u+1):""}catch{return""}},a.aN=class{constructor(h){this.entries={},this.scheduler=h}request(h,l,u,p){const x=this.entries[h]=this.entries[h]||{callbacks:[]};if(x.result){const[b,T]=x.result;return this.scheduler?this.scheduler.add(()=>{p(b,T)},l):p(b,T),()=>{}}return x.callbacks.push(p),x.cancel||(x.cancel=u((b,T)=>{x.result=[b,T];for(const k of x.callbacks)this.scheduler?this.scheduler.add(()=>{k(b,T)},l):k(b,T);setTimeout(()=>delete this.entries[h],3e3)})),()=>{x.result||(x.callbacks=x.callbacks.filter(b=>b!==p),x.callbacks.length||(x.cancel(),delete this.entries[h]))}}},a.aO=function(h,l,u){const p=JSON.stringify(h.request);return h.data&&(this.deduped.entries[p]={result:[null,h.data]}),this.deduped.request(p,{type:"parseTile",renderSourceType:h.renderSourceType,zoom:h.tileZoom},x=>{const b=Zg(h.request,(T,k,P)=>{T?ME(T)?x(null,null):x(T):k&&x(null,{rawData:k,vectorTile:u?void 0:new us(new JP(k)),responseHeaders:new Map(P.entries())})});return()=>{b.cancel(),x(null,null)}},l)},a.aP=function(h){return h?{cacheControl:h.get("cache-control"),expires:h.get("expires")}:{cacheControl:void 0,expires:void 0}},a.aQ=function(h){IE++,IE>yb&&(h.getActor().send("enforceCacheSizeLimit",gb),IE=0)},a.aR=Ll,a.aS=pee,a.aT=See,a.aU=Je,a.aV=mee,a.aW=function(h,l){const u=document.createElement("video");u.muted=!0,u.onloadstart=function(){l(null,u)};for(let p=0;p{}}},a.aX=g2,a.aY=C_,a.aZ=mt,a.a_=ER,a.aa=iw,a.ab=hi,a.ac=sr,a.ad=class{constructor(h){this.specification=h}possiblyEvaluate(h,l){return xr(h.expression.evaluate(l))}interpolate(h,l,u){return{x:sn(h.x,l.x,u),y:sn(h.y,l.y,u),z:sn(h.z,l.z,u),azimuthal:sn(h.azimuthal,l.azimuthal,u),polar:sn(h.polar,l.polar,u)}}},a.ae=fs,a.af=Ep,a.ag=Ir,a.ah=or,a.ai=Le,a.aj=Fe,a.ak=Gh,a.al=Op,a.am=sn,a.an=fr,a.ao=od,a.ap=Xn,a.aq=as,a.ar=class{constructor(h){this.specification=h}possiblyEvaluate(h,l){return function([u,p]){const x=xr([1,u,p]);return{x:x.x,y:x.y,z:x.z}}(h.expression.evaluate(l))}interpolate(h,l,u){return{x:sn(h.x,l.x,u),y:sn(h.y,l.y,u),z:sn(h.z,l.z,u)}}},a.as=function(h,l,u=0,p=!0){const x=new Ft(u,u),b=h.sub(x),T=l.add(x),k=[b,new Ft(T.x,b.y),T,new Ft(b.x,T.y)];return p&&k.push(b.clone()),k},a.at=function(h,l){const u=[];for(let p=0;pthis.buckets[V].layers.some(G=>T.has(G.fqid))),P=Object.keys(this.buckets).some(V=>this.buckets[V].layers.some(G=>G.hasTransition&&G.hasTransition())),O=this._firstPrepareComplete&&b!==this._lastAvailableImagesCount;this._hasAppearances===null&&(this._hasAppearances=this.hasAppearances(l));const $=this._lastUpdatedBrightness!==p;this._lastAvailableImagesCount=b,this._firstPrepareComplete=!0,(this._lastUpdatedBrightness||p||this._hasAppearances||k||P||O)&&(!(this._hasAppearances||k||P||O)&&this._lastUpdatedBrightness&&p&&Math.abs(this._lastUpdatedBrightness-p)<.001||(this.updateBuckets(l,$,void 0,O||k||P,T,x),this._lastUpdatedBrightness=p))}evaluateQueryRenderedFeaturePadding(){let h=0;for(const l in this.buckets){const u=this.buckets[l];u.evaluateQueryRenderedFeaturePadding&&(h=Math.max(h,u.evaluateQueryRenderedFeaturePadding()))}return h}queryRenderedFeatures(h,l,u,p,x,b,T){if(!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData&&!this.latestFeatureIndex.is3DTile)return{};const k=this.evaluateQueryRenderedFeaturePadding(),P=function(O,$){const V=Q([],[.5*O.width,.5*-O.height,1]);return B(V,V,[1,-1,0]),D(V,V,O.calculateProjMatrix($.toUnwrapped())),Float32Array.from(V)}(x,this.tileID);return this.latestFeatureIndex.query(h,{tilespaceGeometry:l,pixelPosMatrix:P,transform:p,availableImages:u,tileTransform:this.tileTransform,worldview:this.worldview,queryRadius:k,scope:T})}querySourceFeatures(h,l){const u=this.latestFeatureIndex;if(!u||!u.rawTileData)return;const p=u.loadVTLayers(),x=l?l.sourceLayer:"",b=p._geojsonTileLayer||p[x];if(!b)return;const T=ow(l&&l.filter),{z:k,x:P,y:O}=this.tileID.canonical,$={z:k,x:P,y:O};for(let V=0;Vu)p=!1;else if(l)if(this.expirationTimeu.appearances&&u.appearances.length>0))return!0;return!1}updateBuckets(h,l,u,p,x,b){if(!this.latestFeatureIndex||!h.style)return;const T=b||h.style.listImages(),k=h.style.getBrightness(),P=x||new Set;for(const O in this.buckets){if(!h.style.hasLayer(O))continue;const $=this.buckets[O],V=$.layers[0],G=V.sourceLayer||"_geojsonTileLayer",Y=h.style.getLayerSourceCache(V),X=$.layers.some(Ae=>P.has(Ae.fqid)),te=(p||X)&&$ instanceof Xh?h.style.getOwnLayer(O):void 0;let se=u&&u[G]||{};Y&&!u&&(se=Y._state.getState(G,void 0));const ae=this.imageAtlas?Object.fromEntries(this.imageAtlas.patternPositions):{},fe=Object.keys(se).length>0&&!l;$.hasAppearances=$.layers.some(Ae=>Ae.appearances&&Ae.appearances.length>0);const ue=fe?$.stateDependentLayers:$.layers;if(fe&&$.stateDependentLayers.length!==0||l||X||p){const Ae=this.latestFeatureIndex.loadVTLayers()[G];if($.update(se,Ae,T,ae,ue,l,k,this.tileID.canonical),(p||X)&&!l&&$ instanceof Xh&&te&&te.type==="symbol"){const Ie=$;Ie.text&&Ie.text.uboBinder&&Ie.text.uboBinder.updateDynamicExpressions(te,Ae,this.tileID.canonical,T,se,k),Ie.icon&&Ie.icon.uboBinder&&Ie.icon.uboBinder.updateDynamicExpressions(te,Ae,this.tileID.canonical,T,se,k)}if($ instanceof Xh){const Ie=$,We=h.context;Ie.text&&Ie.text.uboBinder&&Ie.text.uboBinder.upload(We),Ie.icon&&Ie.icon.uboBinder&&Ie.icon.uboBinder.upload(We)}}if(fe&&$.stateDependentLayers.length!==0||l||$.hasAppearances){const Ae={zoom:h.transform.zoom,pitch:h.transform.pitch,brightness:h.style.getBrightness()||0,worldview:h.worldview},Ie=$.updateAppearances(this.tileID.canonical,se,T,Ae,h.imageManager,fe&&$.stateDependentLayers.length!==0);if(Ie&&Ie.hasUboChanges){const We=h.context;$ instanceof Xh&&$.text&&$.text.uboBinder&&$.text.uboBinder.upload(We),$ instanceof Xh&&$.icon&&$.icon.uboBinder&&$.icon.uboBinder.upload(We)}}($ instanceof QP||$ instanceof RP)&&h._terrain&&h._terrain.enabled&&Y&&$.uploadPending()&&h._terrain._clearRenderCacheForTile(Y.id,this.tileID);const we=h&&h.style&&h.style.getOwnLayer(O);we&&(this.queryPadding=Math.max(this.queryPadding,we.queryRadius($)||0))}}holdingForFade(){return this.symbolFadeHoldUntil!==void 0}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil=0;te--){const se=4*te,ae=Ny[se+0],fe=Ny[se+1],ue=Ny[se+2],we=Ny[se+3],Ae=ae+ue>>1,Ie=fe+we>>1,We=Ae+Ie-fe,ze=Ie+ae-Ae,He=fe*um+ae,Ve=we*um+ue,qe=Ie*um+Ae,bt=Math.hypot((dm[2*He+0]+dm[2*Ve+0])/2-dm[2*qe+0],(dm[2*He+1]+dm[2*Ve+1])/2-dm[2*qe+1])>=16;Cy[qe]=Cy[qe]||(bt?1:0),te<1022&&(Cy[qe]=Cy[qe]||Cy[(fe+ze>>1)*um+(ae+We>>1)]||Cy[(we+ze>>1)*um+(ue+We>>1)])}const $=new Ro,V=new Pi;let G=0;function Y(te,se){const ae=se*um+te;return _R[ae]===0&&($.emplaceBack(dm[2*ae+0],dm[2*ae+1],te*fr/th,se*fr/th),_R[ae]=++G),_R[ae]-1}function X(te,se,ae,fe,ue,we){const Ae=te+ae>>1,Ie=se+fe>>1;if(Math.abs(te-ue)+Math.abs(se-we)>1&&Cy[Ie*um+Ae])X(ue,we,te,se,Ae,Ie),X(ae,fe,ue,we,Ae,Ie);else{const We=Y(te,se),ze=Y(ae,fe),He=Y(ue,we);V.emplaceBack(We,ze,He)}}return X(0,0,th,th,th,0),X(th,th,0,0,0,th),{vertices:$,indices:V}}(this.tileID.canonical,l);p=b.vertices,x=b.indices}else{p=new Ro,x=new Pi;for(const{x:T,y:k}of u)p.emplaceBack(T,k,0,0);const b=ww(p.int16.subarray(0,4*p.length),void 0,4);for(let T=0;T0&&(T=M(new Float64Array(16),l.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(h,p,l,x,T,b),this._makeGlobeTileDebugTextBuffer(h,p,l,x,T,b)}_globePoint(h,l,u,p,x,b,T){let k=Jj(h,l,u);if(b){const P=1<.5?G=-1:V<-.5&&(G=1);let Y=(h/fr+u.x)/P+G,X=(l/fr+u.y)/P;Y=(Y-O)*p._pixelsPerMercatorPixel+O,X=(X-$)*p._pixelsPerMercatorPixel+$;const te=[Y*p.worldSize,X*p.worldSize,0];or(te,te,b),k=Dp(k,te,T)}return or(k,k,x)}_makeGlobeTileDebugBorderBuffer(h,l,u,p,x,b){const T=new Sc,k=new Rp,P=new Qd,O=(V,G,Y,X,te)=>{const se=(Y-V)/(te-1),ae=(X-G)/(te-1),fe=T.length;for(let ue=0;ueO*V+G;for(let V=0;V1)return!1;const u=l.getSource().maxzoom,p=1<1)return l;const x=p.getSource().maxzoom,b=1<{const k=this.getAtTileOffset(h,x,b,T),P=p.upVector(h.canonical,x.x,x.y);return Ue(P,P,k*p.upVectorScale(h.canonical,l,u).metersToTile),P}}getForTilePoints(h,l,u,p){if(this.isUsingMockSource())return!1;const x=Mw.create(this,h,p);return!!x&&(l.forEach(b=>{b[2]=this.exaggeration()*x.getElevationAt(b[0],b[1],u)}),!0)}getMinMaxForTile(h){if(this.isUsingMockSource())return null;const l=this.findDEMTileFor(h);if(!l||!l.dem)return null;const u=l.dem.tree,p=l.tileID,x=1<0&&(p+=(h[x]-0)*(h[x]-0)),l[x]<0&&(p+=(0-l[x])*(0-l[x]));return p},a.cL=function(h){return h*h*h*h*h},a.cM=pt,a.cN=45,a.cO=_w,a.cP=function(h,l,u){const p=Math.sqrt(h*h+l*l+u*u),x=p>0?Math.acos(u/p)*gi:0;let b=h!==0||l!==0?Math.atan2(-l,-h)*gi+90:0;return b<0&&(b+=360),[p,b,x]},a.cQ=Se,a.cR=xr,a.cS=zt,a.cT=me,a.cU=ys,a.cV=ke,a.cW=function(h){return[Math.pow(h[0],1/2.2),Math.pow(h[1],1/2.2),Math.pow(h[2],1/2.2)]},a.cX=GQ,a.cY=i$,a.cZ=ZQ,a.c_=O$,a.ca=2,a.cb=7,a.cc=6,a.cd=xt,a.ce=ye,a.cf=Ee,a.cg=0,a.ch=1,a.ci=4,a.cj=5,a.ck=bw,a.cl=Tc,a.cm=WQ,a.cn=v_,a.co=wX,a.cp=function(h,l,u,p,x,b,T,k,P){if(P.name==="globe")return wX(h,l,new v_(u,p,x),!1);const O=k_({z:u,x:p,y:x},P);return new ys([(b+O.x/O.scale)*l,l*(O.y/O.scale),T],[(b+O.x2/O.scale)*l,l*(O.y2/O.scale),k])},a.cq=function(h,l,u){return h[0]=Math.min(l[0],u[0]),h[1]=Math.min(l[1],u[1]),h[2]=Math.min(l[2],u[2]),h[3]=Math.min(l[3],u[3]),h},a.cr=function(h,l,u){return h[0]=Math.max(l[0],u[0]),h[1]=Math.max(l[1],u[1]),h[2]=Math.max(l[2],u[2]),h[3]=Math.max(l[3],u[3]),h},a.cs=function(h){const l=Math.round((h+45+360)%360/90)%4;return yc[l]},a.ct=Nt,a.cu=Zt,a.cv=6,a.cw=function(h){const l=I(new Float64Array(16));D(l,h.pixelMatrix,h.globeMatrix);const u=[0,$e,0],p=[0,Ke,0];return or(u,u,l),or(p,p,l),[u[0]>0&&u[0]<=h.width&&u[1]>0&&u[1]<=h.height&&!jB(h,new Je(h.center.lat,90)),p[0]>0&&p[0]<=h.width&&p[1]>0&&p[1]<=h.height&&!jB(h,new Je(h.center.lat,-90))]},a.cx=function(h,l){const{scale:u}=h.tileTransform,p=u*fr/(h.tileSize*Math.pow(2,l.zoom-h.tileID.overscaledZ+h.tileID.canonical.z));return function(x,b,T){var k=b[1],P=b[2],O=b[3],$=T[0],V=T[1];return x[0]=b[0]*$,x[1]=k*$,x[2]=P*V,x[3]=O*V,x}(new Float32Array(4),l.inverseAdjustmentMatrix,[p,p])},a.cy=HP,a.cz=de,a.d=function(h){return Vn.API_TILEJSON_REGEX.test(h)},a.d$=wIe,a.d0=Si,a.d1=class{static calculate(h,l,u){const p=new Set,x=new Map,b=new Set,T=new Set;for(const P of Object.values(h))for(const[O,$]of Object.entries(P.floors)){b.add(O),$.isDefault&&T.add(O),$.conflicts&&x.set(O,$.conflicts);const V=O===l,G=$.connections&&l&&$.connections.has(l);(V||G)&&p.add(O)}const k=P=>{const O=x.get(P)||new Set;for(const $ of p)if((x.get($)||new Set).has(P)||O.has($))return!0;return!1};if(u)for(const P of u)b.has(P)&&(k(P)||p.add(P));for(const P of T)p.has(P)||k(P)||p.add(P);return p}},a.d2=nR,a.d3=T$,a.d4=cs,a.d5=function(){return{API_URL:Vn.API_URL,DRACO_URL:Vn.DRACO_URL,MESHOPT_URL:Vn.MESHOPT_URL,MESHOPT_SIMD_URL:Vn.MESHOPT_SIMD_URL,BUILDING_GEN_URL:Vn.BUILDING_GEN_URL}},a.d6=nP,a.d7=NE,a.d8=Hf,a.d9=gr,a.dA=TP,a.dB=Sc,a.dC=Pi,a.dD=function(h,l){return[Math.pow(h[0],2.2)*l,Math.pow(h[1],2.2)*l,Math.pow(h[2],2.2)*l]},a.dE=_,a.dF=function(h,l){var u=Math.sin(l),p=Math.cos(l);return h[0]=p,h[1]=u,h[2]=0,h[3]=-u,h[4]=p,h[5]=0,h[6]=0,h[7]=0,h[8]=1,h},a.dG=Sr,a.dH=TX,a.dI=zn,a.dJ=ri,a.dK=M$,a.dL=function(h,l){const u=[0,0,0];return or(u,u,e2(am(l.canonical))),or(u,u,h),u},a.dM=h=>({u_matrix:new d(h),u_texsize:new Ou(h),u_pixels_to_tile_units:new j(h),u_device_pixel_ratio:new wa(h),u_width_scale:new wa(h),u_floor_width_scale:new wa(h),u_image:new x_(h),u_units_to_pixels:new Ou(h),u_tile_units_to_pixels:new wa(h),u_alpha_discard_threshold:new wa(h),u_trim_offset:new Ou(h),u_trim_fade_range:new Ou(h),u_trim_gradient_mix_range:new Ou(h),u_trim_color:new _w(h),u_zbias_factor:new wa(h),u_tile_to_meter:new wa(h),u_ground_shadow_factor:new __(h),u_pattern_transition:new wa(h)}),a.dN=h=>({u_matrix:new d(h),u_pixels_to_tile_units:new j(h),u_device_pixel_ratio:new wa(h),u_width_scale:new wa(h),u_floor_width_scale:new wa(h),u_units_to_pixels:new Ou(h),u_dash_image:new x_(h),u_gradient_image:new x_(h),u_image_height:new wa(h),u_texsize:new Ou(h),u_tile_units_to_pixels:new wa(h),u_alpha_discard_threshold:new wa(h),u_trim_offset:new Ou(h),u_trim_fade_range:new Ou(h),u_trim_gradient_mix_range:new Ou(h),u_trim_color:new _w(h),u_zbias_factor:new wa(h),u_tile_to_meter:new wa(h),u_ground_shadow_factor:new __(h)}),a.dO=h=>({u_camera_to_center_distance:new wa(h),u_extrude_scale:new j(h),u_device_pixel_ratio:new wa(h),u_matrix:new d(h),u_inv_rot_matrix:new d(h),u_merc_center:new Ou(h),u_tile_id:new __(h),u_zoom_transition:new wa(h),u_up_dir:new __(h),u_emissive_strength:new wa(h)}),a.dP=zj,a.dQ=bRe,a.dR=class{constructor(h,l,u,p){this.context=h,this.format=p,this.size=u,this.texture=h.gl.createTexture();const[x,b,T]=this.size,{gl:k}=h;k.bindTexture(k.TEXTURE_3D,this.texture),h.pixelStoreUnpackFlipY.set(!1),h.pixelStoreUnpack.set(1),h.pixelStoreUnpackPremultiplyAlpha.set(!1),"data"in l&&l.data&&k.texImage3D(k.TEXTURE_3D,0,this.format,x,b,T,0,QB(this.format),JB(this.format),l.data)}bind(h,l){const{context:u}=this,{gl:p}=u;p.bindTexture(p.TEXTURE_3D,this.texture),h!==this.minFilter&&(p.texParameteri(p.TEXTURE_3D,p.TEXTURE_MAG_FILTER,h),p.texParameteri(p.TEXTURE_3D,p.TEXTURE_MIN_FILTER,h),this.minFilter=h),l!==this.wrapS&&(p.texParameteri(p.TEXTURE_3D,p.TEXTURE_WRAP_S,l),p.texParameteri(p.TEXTURE_3D,p.TEXTURE_WRAP_T,l),this.wrapS=l)}destroy(){const{gl:h}=this.context;h.deleteTexture(this.texture),this.texture=null}},a.dS=AX,a.dT=(h,l,u,p,x,b)=>{const T=h.transform,k=T.projection.name==="globe";let P;if(b.paint.get("circle-pitch-alignment")==="map")if(k){const $=TX(T.zoom,l.canonical)*T._pixelsPerMercatorPixel;P=Float32Array.from([$,0,0,$])}else P=T.calculatePixelsToTileUnitsMatrix(u);else P=new Float32Array([T.pixelsToGLUnits[0],0,0,T.pixelsToGLUnits[1]]);const O={u_camera_to_center_distance:h.transform.getCameraToCenterDistance(T.projection),u_matrix:h.translatePosMatrix(l.projMatrix,u,b.paint.get("circle-translate"),b.paint.get("circle-translate-anchor")),u_device_pixel_ratio:Kl.devicePixelRatio,u_extrude_scale:P,u_inv_rot_matrix:AIe,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0],u_emissive_strength:b.paint.get("circle-emissive-strength")};if(k){O.u_inv_rot_matrix=p,O.u_merc_center=x,O.u_tile_id=[l.canonical.x,l.canonical.y,1<{const $=h.transform,V=$.pitch<15?cJ(.07,.7,pe((14-$.zoom)/5,0,1)):.07,G=u.paint.get("line-trim-color-use-theme").constantOr("default")==="none";return{u_matrix:dJ(h,l,u,p),u_texsize:l.imageAtlasTexture?l.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:$.calculatePixelsToTileUnitsMatrix(l),u_device_pixel_ratio:x,u_width_scale:b,u_floor_width_scale:T,u_image:0,u_tile_units_to_pixels:uJ(l,$),u_units_to_pixels:[1/$.pixelsToGLUnits[0],1/$.pixelsToGLUnits[1]],u_alpha_discard_threshold:0,u_trim_offset:k,u_trim_fade_range:u.paint.get("line-trim-fade-range"),u_trim_gradient_mix_range:[1,1],u_trim_color:u.paint.get("line-trim-color").toPremultipliedRenderColor(G?null:u.lut).toArray01(),u_zbias_factor:V,u_tile_to_meter:zt(l.tileID.canonical,0),u_ground_shadow_factor:P,u_pattern_transition:O}},a.dX=(h,l,u,p,x,b,T,k,P,O)=>{const $=h.transform,V=$.calculatePixelsToTileUnitsMatrix(l),G=u.paint.get("line-trim-color-use-theme").constantOr("default")==="none",Y=$.pitch<15?cJ(.07,.7,pe((14-$.zoom)/5,0,1)):.07;return{u_matrix:dJ(h,l,u,p),u_pixels_to_tile_units:V,u_device_pixel_ratio:b,u_width_scale:T,u_floor_width_scale:k,u_units_to_pixels:[1/$.pixelsToGLUnits[0],1/$.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:x,u_texsize:fJ(u)&&l.lineAtlasTexture?l.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:uJ(l,h.transform),u_alpha_discard_threshold:0,u_trim_offset:P,u_trim_fade_range:u.paint.get("line-trim-fade-range"),u_trim_gradient_mix_range:[1,1],u_trim_color:u.paint.get("line-trim-color").toPremultipliedRenderColor(G?null:u.lut).toArray01(),u_zbias_factor:Y,u_tile_to_meter:zt(l.tileID.canonical,0),u_ground_shadow_factor:O}},a.dY=it,a.dZ=t2,a.d_=Et,a.da=function(h){const l=h.indexOf(o_);return l>=0?h.slice(0,l):h},a.db=function(h){return h.indexOf(o_)>=0},a.dc=function(h){const l=h.lastIndexOf(o_);return l>=0?h.slice(l+1):""},a.dd=function(h){const l=[],u=h.id;return u===void 0&&l.push({message:`layers.${u}: missing required property "id"`}),h.render===void 0&&l.push({message:`layers.${u}: missing required method "render"`}),h.renderingMode&&h.renderingMode!=="2d"&&h.renderingMode!=="3d"&&l.push({message:`layers.${u}: property "renderingMode" must be either "2d" or "3d"`}),l},a.de=function(h,l,u,p){return h.type==="custom"?new mLe(h,l):new _Le[h.type](h,l,u,p)},a.df=Mt,a.dg=ow,a.dh=dP,a.di=class extends N_{constructor(h,l){super(h._vectorTileFeature,h._z,h._x,h._y,h.id),h.state&&(this.state=Object.assign({},h.state)),this.target=l.target,this.namespace=l.namespace,l.properties&&(this.properties=l.properties),this.target&&("featuresetId"in this.target&&!this.target.importId||"layerId"in this.target)&&(this.source=h.source,this.sourceLayer=h.sourceLayer,this.layer=h.layer)}toJSON(){const h=super.toJSON();return h.target=this.target,h.namespace=this.namespace,h}},a.dj=Ej,a.dk=function(h){return h({pluginStatus:hl,pluginURL:Hc}),Ej.on("pluginStateChange",h),h},a.dl=bB,a.dm=class extends Du{constructor(h){super(h),this.current=g}set(h,l,u){if(this.fetchUniformLocation(h,l)){for(let p=0;p<9;p++)if(u[p]!==this.current[p]){this.current=u,this.gl.uniformMatrix3fv(this.location,!1,u);break}}}},a.dn=ul,a.dp=function(h,l,u){const p=Op(u.zoom),x=h.style.map._antialias,b=h.terrain&&h.terrain.exaggeration()>0;return p===0&&!x&&!b},a.dq=function(h){const l=h.pixelsPerMeter,u=l/ut(1,h.center.lat),p=I(new Float64Array(16));return B(p,p,[h.point.x,h.point.y,0]),U(p,p,[u,u,l]),Float32Array.from(p)},a.dr=EP,a.ds=function(h){const l=80.051129;h=pe(h,-80.051129,l)/l*90;const u=Math.pow(Math.abs(Math.sin(Xn(h))),3);return Math.round(u*(Xe.length-1))},a.dt=function(h,l,u,p){const x=l.getNorth(),b=l.getSouth(),T=l.getWest(),k=l.getEast(),P=1<0){const X=180/p;E(Y,Y,[X/O+1,0,0,0,X/$+1,0,-.5*X/V,.5*X/G,1])}return Y[2]=P,Y[5]=h.x,Y[8]=h.y,Y},a.du=e2,a.dv=am,a.dw=function(h,l,u){const p=I(new Float64Array(16)),x=(l/(1<0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[]}get updateTime(){return this._updateTime}getReplacementRegionsForTile(h,l=!1){const u=lQ(new Ft(0,0),new Ft(fr,fr),h),p=[];if(l&&!zB(u,this._globalClipBounds))return p;for(const x of this._activeRegions){if(x.hiddenByOverlap||!zB(u,x))continue;const b=uPe(x.min,x.max,h);p.push({min:b.min,max:b.max,sourceId:this._sourceIds[x.priority],footprint:x.footprint,footprintTileId:x.tileId,order:x.order,clipMask:x.clipMask,clipScope:x.clipScope})}return p}setSources(h){this._setSources(h.map(l=>({getSourceId:()=>l.cache.id,getFootprints:()=>{const u=[];for(const p of l.cache.getVisibleCoordinates()){const x=l.cache.getTile(p).buckets[l.layer];x&&x.updateFootprints(p.toUnwrapped(),u)}return u},getOrder:()=>l.order,getClipMask:()=>l.clipMask,getClipScope:()=>l.clipScope})))}_addSource(h){const l=h.getFootprints();if(l.length===0)return;const u=h.getOrder(),p=h.getClipMask(),x=h.getClipScope();for(const b of l){if(!b.footprint)continue;const T=lQ(b.footprint.min,b.footprint.max,b.id);this._activeRegions.push({min:T.min,max:T.max,hiddenByOverlap:!1,priority:this._sourceIds.length,tileId:b.id,footprint:b.footprint,order:u,clipMask:p,clipScope:x})}this._sourceIds.push(h.getSourceId())}_computeReplacement(){this._activeRegions.sort((l,u)=>l.priority-u.priority||MP(l.min,u.min)||MP(l.max,u.max)||l.order-u.order||l.clipMask-u.clipMask||function(p,x){const b=(T,k)=>T+k;return p.length-x.length||p.reduce(b,"").localeCompare(x.reduce(b,""))}(l.clipScope,u.clipScope));let h=this._activeRegions.length!==this._prevRegions.length;if(!h){let l=0;for(;!h&&l!==this._activeRegions.length;){const u=this._activeRegions[l],p=this._prevRegions[l];h=u.priority!==p.priority||!oQ(u,p)||u.order!==p.order||u.clipMask!==p.clipMask||!So(u.clipScope,p.clipScope),this._activeRegions[l].hiddenByOverlap=p.hiddenByOverlap,++l}}if(h){++this._updateTime;for(const u of this._activeRegions)u.order!==c2&&(this._globalClipBounds.min.x=Math.min(this._globalClipBounds.min.x,u.min.x),this._globalClipBounds.min.y=Math.min(this._globalClipBounds.min.y,u.min.y),this._globalClipBounds.max.x=Math.max(this._globalClipBounds.max.x,u.max.x),this._globalClipBounds.max.y=Math.max(this._globalClipBounds.max.y,u.max.y));const l=u=>{const p=this._activeRegions;if(u>=p.length)return u;const x=p[u].priority;for(;u1){let u=0,p=l(u);for(;u!==p;){let x=u;const b=u;for(;x!==p;){const T=this._activeRegions[x];T.hiddenByOverlap=!1;for(let k=0;k=0;l--)this._addSource(h[l]);this._computeReplacement()}},a.eH=Ro,a.eI=mR,a.eJ=Rp,a.eK=c2,a.eL=class{constructor(h){this._createGrid(h),this._createPoles(h)}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const h of this._poleSegments)h.destroy();for(const h of this._gridSegments)h.withSkirts.destroy(),h.withoutSkirts.destroy()}_fillGridMeshWithLods(h,l){const u=new Sc,p=new Pi,x=[],b=h+1+2,T=l[0]+1,k=l[0]+1+(1+l.length),P=(O,$,V)=>{let G=O===b-1?O-2:O===0?O:O-1;return G+=V?24575:0,[G,$]};for(let O=0;O>>=0,h=Math.imul(2747636419^h,2654435769)>>>0,h=Math.imul(h^h>>>16,2654435769)>>>0,(h=Math.imul(h^h>>>16,2654435769)>>>0)/4294967296},a.ec=vX,a.ed=TB,a.ee=Lu,a.ef=H,a.eg=function(h,l){return h[0]=l[0],h[1]=l[1],h[2]=l[2],h[3]=l[4],h[4]=l[5],h[5]=l[6],h[6]=l[8],h[7]=l[9],h[8]=l[10],h},a.eh=Ip,a.ei=f_,a.ej=function(h,l,u,p,x){return pe((h-l)/(u-l)*(x-p)+p,p,x)},a.ek=Gn,a.el=function(h,l){var u=l[0],p=l[1],x=l[2],b=l[3],T=l[4],k=l[5],P=l[6],O=l[7],$=l[8],V=$*T-k*O,G=-$*b+k*P,Y=O*b-T*P,X=u*V+p*G+x*Y;return X?(h[0]=V*(X=1/X),h[1]=(-$*p+x*O)*X,h[2]=(k*p-x*T)*X,h[3]=G*X,h[4]=($*u-x*P)*X,h[5]=(-k*u+x*b)*X,h[6]=Y*X,h[7]=(-O*u+p*P)*X,h[8]=(T*u-p*b)*X,h):null},a.em=BI,a.en=2,a.eo=gt,a.ep=At,a.eq=ee,a.er=function(h,l){var u=new m(3);ee(u,l);var p=1/u[0],x=1/u[1],b=1/u[2],T=l[0]*p,k=l[1]*x,P=l[2]*b,O=l[4]*p,$=l[5]*x,V=l[6]*b,G=l[8]*p,Y=l[9]*x,X=l[10]*b,te=T+$+X,se=0;return te>0?(se=2*Math.sqrt(te+1),h[3]=.25*se,h[0]=(V-Y)/se,h[1]=(G-P)/se,h[2]=(k-O)/se):T>$&&T>X?(se=2*Math.sqrt(1+T-$-X),h[3]=(V-Y)/se,h[0]=.25*se,h[1]=(k+O)/se,h[2]=(G+P)/se):$>X?(se=2*Math.sqrt(1+$-T-X),h[3]=(G-P)/se,h[0]=(k+O)/se,h[1]=.25*se,h[2]=(V+Y)/se):(se=2*Math.sqrt(1+X-T-$),h[3]=(k-O)/se,h[0]=(G+P)/se,h[1]=(V+Y)/se,h[2]=.25*se),h},a.es=function(h,l){var u=2*Math.acos(l[3]),p=Math.sin(u/2);return p>f?(h[0]=l[0]/p,h[1]=l[1]/p,h[2]=l[2]/p):(h[0]=1,h[1]=0,h[2]=0),u},a.et=$$,a.eu=YP,a.ev=KP,a.ew=[1,1,1],a.ex=Mw,a.ey=function(h,l,u,p){var x=l[0],b=l[1],T=l[2],k=l[3];return h[0]=x+p*(u[0]-x),h[1]=b+p*(u[1]-b),h[2]=T+p*(u[2]-T),h[3]=k+p*(u[3]-k),h},a.ez=kw,a.f=xc,a.f0=jX,a.f1=function(h){const l=[0,0,0],u=I(new Float64Array(16));return D(u,h.pixelMatrix,h.globeMatrix),or(l,l,u),new Ft(l[0],l[1])},a.f2=jj,a.f3=function(h,l,u=!1){if(hl===wc.deferred||hl===wc.loading||hl===wc.loaded)throw new Error("setRTLTextPlugin cannot be called multiple times.");Hc=Kl.resolveURL(h),hl=wc.deferred,Xd=l,Tj(),u||sP()},a.f4=To,a.f5=Po,a.f6=Da,a.f7=function(h){const l=hI();if(!l)return;const u=l.delete(fp);h&&u.then(()=>h()).catch(h)},a.f8=Tr,a.f9=Sy,a.fA=ln,a.fB=function(h){let l=0;if(new Uint32Array(h,0,1)[0]!==$Q){const u=new Uint32Array(h,0,7),[,,p,x,b,T]=u;l=u.byteLength+x+b+T+b,(p!==h.byteLength||l>=h.byteLength)&&hr("Invalid b3dm header information.")}return qQ(h,l)},a.fC=function(h,l){const u=i$(h);for(const p of u){for(const x of p.meshes)zPe(x);p.lights&&(p.lightMeshIndex=p.meshes.length,p.meshes.push(UPe(p.lights,l)))}return u},a.fD=xR,a.fE=wn,a.fF=qh,a.fG=wc,a.fH=function(h){xb(),Wd!=null&&Wd.then(l=>{l.keys().then(u=>{for(let p=0;phr(x.message))}).catch(u=>hr(u.message))}).catch(l=>hr(l.message))},a.fa=2,a.fb=zh,a.fc=k_,a.fd=Wj,a.fe=Cee,a.ff=Iee,a.fg=iJ,a.fh=bn,a.fi="hd_road_elevation",a.fj=Vs,a.fk=Gt,a.fl=RP,a.fm=Fp,a.fn=w$,a.fo=1,a.fp=Xh,a.fq=function(h,l,u,p,x,b,T,k=1,P,O,$,V){h.createArrays(),h.tilePixelRatio=fr/(512*h.overscaling),h.compareText={},h.iconsNeedLinear=!1;const G=h.layers[0].layout,Y=h.layers[0]._unevaluatedLayout._values,X={};X.scaleFactor=k,X.textSizeScaleRange=G.get("text-size-scale-range"),X.iconSizeScaleRange=G.get("icon-size-scale-range");const[te,se]=X.textSizeScaleRange,[ae,fe]=X.iconSizeScaleRange;X.textScaleFactor=pe(X.scaleFactor,te,se),X.iconScaleFactor=pe(X.scaleFactor,ae,fe);const ue=Y["text-size"],we=Y["icon-size"];if(h.textSizeData.kind==="composite"){const{minZoom:Ve,maxZoom:qe}=h.textSizeData;X.compositeTextSizes=[ue.possiblyEvaluate(new fs(Ve,{worldview:$}),b),ue.possiblyEvaluate(new fs(qe,{worldview:$}),b)]}if(h.iconSizeData.kind==="composite"){const{minZoom:Ve,maxZoom:qe}=h.iconSizeData;X.compositeIconSizes=[we.possiblyEvaluate(new fs(Ve,{worldview:$}),b,V),we.possiblyEvaluate(new fs(qe,{worldview:$}),b,V)]}X.layoutTextSize=ue.possiblyEvaluate(new fs(T+1,{worldview:$}),b),X.layoutIconSize=we.possiblyEvaluate(new fs(T+1,{worldview:$}),b,V),X.textMaxSize=ue.possiblyEvaluate(new fs(18,{worldview:$}),b);const Ae=G.get("symbol-placement"),Ie=G.get("text-rotation-alignment")==="map"&&Ae!=="point",We=G.get("text-size");let ze=!1;const He=[];for(const Ve of h.features){const qe=G.get("text-font").evaluate(Ve,{},b).join(","),bt=We.evaluate(Ve,{},b)*X.textScaleFactor,jt=X.layoutTextSize.evaluate(Ve,{},b)*X.textScaleFactor,It=X.layoutIconSize.evaluate(Ve,{},b,V)*X.iconScaleFactor,Dt={horizontal:{},vertical:void 0},Pt=Ve.text;let Ht,_t=[0,0];if(Pt){const jn=Pt.toString(),Ti=G.get("text-letter-spacing").evaluate(Ve,{},b)*Ka,ms=G.get("text-line-height").evaluate(Ve,{},b)*Ka,ns=oB(jn)?Ti:0,$s=G.get("text-anchor").evaluate(Ve,{},b),xi=G.get("text-variable-anchor");if(!xi){const Li=G.get("text-radial-offset").evaluate(Ve,{},b);if(Li)_t=qJ($s,[Li*Ka,j$]);else{const Mo=G.get("text-offset").evaluate(Ve,{},b);_t=[Mo[0]*Ka,Mo[1]*Ka]}}let Ya=Ie?"center":G.get("text-justify").evaluate(Ve,{},b);const _i=Ae==="point",Ri=_i?G.get("text-max-width").evaluate(Ve,{},b)*Ka:1/0,aa=Li=>{h.allowVerticalPlacement&&bj(jn)&&(Dt.vertical=p$(Pt,l,u,x,qe,Ri,ms,$s,Li,ns,_t,Jc.vertical,!0,jt,bt,P,X.textScaleFactor))};if(!Ie&&xi){const Li=Ya==="auto"?xi.map(Za=>k$(Za)):[Ya];let Mo=!1;for(let Za=0;Za=0||!bj(jn)){const Li=p$(Pt,l,u,x,qe,Ri,ms,$s,Ya,ns,_t,Jc.horizontal,!1,jt,bt,P,X.textScaleFactor);Li&&(Dt.horizontal[Ya]=Li)}aa(_i?"left":Ya)}}let Rt,Bt,Yt,tr,br,ur,cr=!1;const rr=G.get("icon-text-fit").evaluate(Ve,{},b);if(Ve.icon&&Ve.icon.hasPrimary()){const jn=T2(Ve.icon,h.iconSizeData,Y["icon-size"],b,h.zoom,Ve,P,X.iconScaleFactor,$,V);Rt=jn.iconPrimary,Yt=jn.iconSecondary;const Ti=Rt.toString();if(Bt=p.get(Ti),Bt&&(br=G.get("icon-offset").evaluate(Ve,{},b),ur=G.get("icon-anchor").evaluate(Ve,{},b),Ht=tR(x.get(Ti),Yt?x.get(Yt.toString()):void 0,br,ur),cr=Bt.sdf,h.sdfIcons===void 0?h.sdfIcons=Bt.sdf:h.sdfIcons!==Bt.sdf&&hr("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(Bt.pixelRatio!==h.pixelRatio||G.get("icon-rotate").constantOr(1)!==0)&&(h.iconsNeedLinear=!0)),Yt){const ms=Yt.toString();tr=p.get(ms)}}ze=ze||!(!Ve.icon||!Ve.icon.hasSecondary());const _r=lR(Dt.horizontal)||Dt.vertical;h.iconsInText||(h.iconsInText=!!_r&&_r.iconsInText);const Pr=jt*X.textScaleFactor/Ka,{defaultShapedIcon:Wr,verticallyShapedIcon:Mr}=QRe(h,Ht,G,Ve,b,Dt,Pr,br,rr);rr!=="none"&&Ht&&(jJ(Ht)||kJ(Ht))&&(oR(0,Bt,Rt,Ht,Wr,rr,O,p,x),oR(0,tr,Yt,Ht,Wr,rr,O,p,x),Mr&&(oR(0,Bt,Rt,Ht,Mr,rr,O,p,x),oR(0,tr,Yt,Ht,Mr,rr,O,p,x))),Ht=Wr;const{iconBBox:fn,iconVerticalBBox:Wn,textBBox:mn,textVerticalBBox:es}=WRe(h,Ht,Mr,G,Ve,b,It,br,X,x,ur,Dt,jt,_t,V);He.push({feature:Ve,shapedTextOrientations:Dt,shapedText:_r,shapedIcon:Ht,iconPrimary:Rt,iconSecondary:Yt,iconOffset:br,iconAnchor:ur,verticallyShapedIcon:Mr,layoutTextSize:jt,layoutIconSize:It,textOffset:_t,isSDFIcon:cr,iconTextFit:rr,iconCollisionBounds:fn,iconVerticalCollisionBounds:Wn,textCollisionBounds:mn,textVerticalCollisionBounds:es})}return{featureData:He,sizes:X,hasAnySecondaryIcon:ze,textAlongLine:Ie,symbolPlacement:Ae}},a.fr=S$,a.fs=b$,a.ft=DJ,a.fu=OJ,a.fv=function(h,l,u,p,x,b,T,k,P,O){h.iconAtlasPositions=O.iconPositions;const{featureData:$,hasAnySecondaryIcon:V,sizes:G,textAlongLine:Y,symbolPlacement:X}=l;for(const te of $){const{shapedIcon:se,verticallyShapedIcon:ae,feature:fe,shapedTextOrientations:ue,shapedText:we,layoutTextSize:Ae,textOffset:Ie,isSDFIcon:We,iconPrimary:ze,iconSecondary:He,iconTextFit:Ve,iconOffset:qe,iconCollisionBounds:bt,iconVerticalCollisionBounds:jt,textCollisionBounds:It}=te;KJ(se,O.iconPositions,ze,He),KJ(ae,O.iconPositions,ze,He),XRe(ue,O.iconPositions),ZRe(ze,He,O.iconPositions),(we||se)&&JRe(h,fe,ue,se,ae,P,G,Ae,0,Ie,We,p,x,T,k,V,Ve,qe,Y,X,bt,jt,It)}u&&h.generateCollisionDebugBuffers(b,h.collisionBoxArray,G.textScaleFactor)},a.fw=QP,a.fx=us,a.fy=function(h){return h<=1?1:Math.pow(2,Math.floor(Math.log2(h)))},a.fz=TR,a.g=Vn,a.h=function(h,l){return Yg(Object.assign(h,{method:"GET"}),l)},a.i=function(h){return Vn.API_STYLE_REGEX.test(h)&&!_c(h)},a.j=function(h){return btoa(encodeURIComponent(h).replace(/%([0-9A-F]{2})/g,(l,u)=>String.fromCharCode(+("0x"+u))))},a.k=_b,a.l=function(h){return decodeURIComponent(atob(h).split("").map(l=>"%"+("00"+l.charCodeAt(0).toString(16)).slice(-2)).join(""))},a.m=function(h,l){return Yg(Object.assign(h,{type:"json"}),l)},a.n=Xg,a.o=Kl,a.p=function(h,l){return Yg(Object.assign(h,{method:"POST"}),l)},a.q=Xo,a.r=ht,a.s=function(h){try{const l=self[h];return l.setItem("_mapbox_test_",1),l.removeItem("_mapbox_test_"),!0}catch{return!1}},a.t=et,a.u=function(){return function h(l){return l?(l^Math.random()*(16>>l/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,h)}()},a.v=function(h){return!!h&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(h)},a.w=hr,a.x=class{constructor(h){this.cache=new Map,this.textures=new Map,this.textureAccessTimes=new Map,this.textureMemoryUsed=0,this.maxTextureMemory=1024*(h&&h.maxTextureMemoryMB?h.maxTextureMemoryMB:256)*1024,this.finalizationRegistry=new FinalizationRegistry(l=>{this.cache.delete(l),this.clearExpiredTextures()})}calculateTextureMemory(h){return h.image?Math.ceil(h.image.width*h.image.height*4*(h.patternPositions.size>0?1.33:1)):0}evictTexture(h){const l=this.textures.get(h);if(l){const u=this.calculateTextureMemory(h);l.destroy(),this.textures.delete(h),this.textureAccessTimes.delete(h),this.textureMemoryUsed-=u}}evictTexturesIfNeeded(h){for(;this.textureMemoryUsed+h>this.maxTextureMemory&&this.textures.size>0;){let l=null,u=1/0;for(const[p]of this.textures.entries()){const x=this.textureAccessTimes.get(p)||0;xthis._layers[gr.id]),ht=nt[0];if(ht.visibility==="none")continue;const it=ht.source||"";let mt=this.familiesBySource[it];mt||(mt=this.familiesBySource[it]=Object.create(null));const Gt=ht.sourceLayer||"_geojsonTileLayer";let Mt=mt[Gt];Mt||(Mt=mt[Gt]=[]),Mt.push(nt)}}}const A=1*f.fa;class C{constructor(he){const pe={},Fe=[];for(const ht in he){const it=he[ht],mt=pe[ht]={};for(const Gt in it.glyphs){const Mt=it.glyphs[+Gt];if(!Mt||Mt.bitmap.width===0||Mt.bitmap.height===0)continue;const gr=Mt.metrics.localGlyph?A:1,zr={x:0,y:0,w:Mt.bitmap.width+2*gr,h:Mt.bitmap.height+2*gr};Fe.push(zr),mt[Gt]=zr}}const{w:Ye,h:et}=f.J(Fe),nt=new f.f9({width:Ye||1,height:et||1});for(const ht in he){const it=he[ht];for(const mt in it.glyphs){const Gt=it.glyphs[+mt];if(!Gt||Gt.bitmap.width===0||Gt.bitmap.height===0)continue;const Mt=pe[ht][mt],gr=Gt.metrics.localGlyph?A:1;f.f9.copy(Gt.bitmap,nt,{x:0,y:0},{x:Mt.x+gr,y:Mt.y+gr},Gt.bitmap)}}this.image=nt,this.positions=pe}}function I(dt,he,pe){dt[he]?pe&&(dt[he].center=pe):dt[he]={floorIds:new Set,center:pe||[0,0],floors:{}}}function M(dt,he,pe,Fe){for(const Ye of he)I(dt,Ye),dt[Ye].floors[pe]=Fe,dt[Ye].floorIds.add(pe)}function D(dt){return{id:dt.properties.id.toString(),center:[dt.properties.center_lon||0,dt.properties.center_lat||0]}}function B(dt,he){const pe=dt.properties.id.toString(),Fe=!!dt.properties.is_default&&dt.properties.is_default,Ye=dt.properties.connected_floor_ids?new Set(dt.properties.connected_floor_ids.toString().split(";")):new Set,et=dt.properties.conflicted_floor_ids?new Set(dt.properties.conflicted_floor_ids.toString().split(";")):new Set,nt=dt.properties.structure_ids?new Set(dt.properties.structure_ids.toString().split(";")):new Set,ht=dt.properties.name.toString(),it=dt.properties.z_index,mt=function(Gt,Mt){const gr=Gt.loadGeometry();if(!gr||gr.length===0)return;const zr=gr.map(Hr=>Hr.map(hr=>f.fb(hr,Mt,Gt.extent)));return zr.length===0?void 0:{type:"Polygon",coordinates:[zr[0]]}}(dt,he);return{id:pe,isDefault:Fe,connections:Ye,conflicts:et,buildings:nt,name:ht,zIndex:it,geometry:mt}}function U(dt,he){return he.every(pe=>dt.properties&&dt.properties[pe]!=null)}function q(dt){return U(dt,["type","id","name"])&&dt.properties.type==="structure"}function H(dt){return U(dt,["type","id","name","z_index"])&&dt.properties.type==="floor"}f.f8(C,"GlyphAtlas");class K{constructor(he){this.tileID=new f.aR(he.tileID.overscaledZ,he.tileID.wrap,he.tileID.canonical.z,he.tileID.canonical.x,he.tileID.canonical.y),this.tileZoom=he.tileZoom,this.uid=he.uid,this.zoom=he.zoom,this.lut=he.lut,this.canonical=he.tileID.canonical,this.pixelRatio=he.pixelRatio,this.tileSize=he.tileSize,this.source=he.source,this.scope=he.scope,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=he.showCollisionBoxes,this.collectResourceTiming=!!he.request&&he.request.collectResourceTiming,this.promoteId=he.promoteId,this.renderSourceType=he.renderSourceType,this.tileTransform=f.fc(he.tileID.canonical,he.projection),this.projection=he.projection,this.worldview=he.worldview,this.localizableLayerIds=he.localizableLayerIds,this.brightness=he.brightness,this.extraShadowCaster=!!he.extraShadowCaster,this.tessellationStep=he.tessellationStep,this.scaleFactor=he.scaleFactor,this.worldview=he.worldview,this.indoor=he.indoor}parse(he,pe,Fe,Ye,et,nt){this.status="parsing",this.data=he,this.collisionBoxArray=new f.fd;const ht=new f.fe(Object.keys(he.layers).sort()),it=new f.ff(this.tileID,this.promoteId);it.bucketLayerIDs=[];const mt={},Gt=new f.fg(256,256),Mt={featureIndex:it,iconDependencies:new Map,patternDependencies:new Map,glyphDependencies:{},lineAtlas:Gt,availableImages:Fe,brightness:this.brightness,scaleFactor:this.scaleFactor,elevationFeatures:void 0,activeFloors:void 0};this.indoor&&(Mt.activeFloors=function(hr,rt,qt,xr){const wn=rt.indoorState.activeFloorsVisible;if(!rt.sourceLayers)return wn?rt.indoorState.activeFloors:void 0;const Cn=function(Jn,ks){if(!Jn)return f.w("No source layers defined in indoor specification"),ks;if(Jn.size===0)return ks;const zi=Jn.difference(ks);for(const zn of zi)f.w(`Missing source layer required in indoor specification: ${zn}`);return ks.intersection(ks)}(rt.sourceLayers,new Set(Object.keys(hr.layers))),Qn=rt.indoorState,Ns=function(Jn,ks,zi,zn,ri){const di={};for(const Vn of ks){const Da=Jn.layers[Vn];if(Da)for(let Po=0;Po=zn.maxzoom||zn.visibility==="none")continue;Q(zi,this.zoom,Mt.brightness,Fe,this.worldview,Mt.activeFloors);const ri=mt[zn.id]=zn.createBucket({index:it.bucketLayerIDs.length,layers:zi,zoom:this.zoom,lut:this.lut,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:Qn,sourceID:this.source,projection:this.projection.spec,tessellationStep:this.tessellationStep,styleDefinedModelURLs:Ye,worldview:this.worldview,localizable:Jn,availableImages:Fe,maxUniformBufferBindings:this.maxUniformBufferBindings,maxUniformBlockSizeDwords:this.maxUniformBlockSizeDwords,disableSymbolUBO:this.disableSymbolUBO});it.bucketLayerIDs.push(zi.map(Vn=>f.F(Vn.id,Vn.scope)));let di=ri.prepare?ri.prepare():null;di!=null?(di=di.then(()=>ri.populate(Ns,Mt,this.tileID.canonical,this.tileTransform)),gr.push(di)):ri.populate(Ns,Mt,this.tileID.canonical,this.tileTransform)}}const Hr=()=>{Gt.trim();const hr=!(!Mt.elevationFeatures||!Mt.elevationFeatures.some(zn=>zn.heightRange.min<0));let rt,qt,xr,wn,Cn,Qn,Ns;const Jn={type:"maybePrepare",renderSourceType:this.renderSourceType,zoom:this.zoom},ks=()=>{if(rt)return this.status="done",nt(rt);if(this.extraShadowCaster)this.status="done",nt(null,{buckets:Object.values(mt).filter(zn=>!zn.isEmpty()),featureIndex:it,collisionBoxArray:null,hasTunnelGeometry:hr,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:Mt.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(qt&&xr&&wn&&Ns){const ri=new C(qt),di=new Map;for(const[Po,To]of xr.entries()){const{imagePosition:xc}=f.fn(Po,To,f.fo);di.set(Po,xc)}const Vn={};for(const Po in mt){const To=mt[Po];To instanceof f.fp&&(Q(To.layers,this.zoom,Mt.brightness,Fe,this.worldview,Mt.activeFloors),Vn[Po]=f.fq(To,qt,ri.positions,xr,di,this.tileID.canonical,this.tileZoom,this.scaleFactor,this.pixelRatio,Cn,this.worldview,Fe))}const Da={iconsPending:!0,patternsPending:!0};this.rasterizeIfNeeded(et,xr,Cn,()=>{Da.iconsPending=!1,zi(Vn,ri,Da,void 0,Ns)}),this.rasterizeIfNeeded(et,wn,Qn,()=>{Da.patternsPending=!1,zi(Vn,ri,Da,void 0,Ns)})}},zi=(zn,ri,di,Vn,Da)=>{if(di.iconsPending||di.patternsPending)return;const Po=xr.size>0||wn.size>0,To=Object.keys(zn).length>0;if(!Po&&!To)return this.status="done",void nt(null,{buckets:Object.values(mt).filter(_c=>!_c.isEmpty()),featureIndex:it,collisionBoxArray:this.collisionBoxArray,hasTunnelGeometry:hr,glyphAtlasImage:ri.image,lineAtlas:Gt,imageAtlas:null,brightness:Mt.brightness});const xc=(_c,qd)=>{for(const Pl in mt){const vc=mt[Pl];if(Pl in zn)f.fv(vc,zn[Pl],this.showCollisionBoxes,Fe,this.tileID.canonical,this.tileZoom,this.projection,this.brightness,xr,qd);else if(vc.hasPattern&&(vc instanceof f.fw||vc instanceof f.fl||vc instanceof f.e0)){Q(vc.layers,this.zoom,Mt.brightness,Fe,this.worldview,Mt.activeFloors);const Gd=Object.fromEntries(qd.patternPositions);vc.addFeatures(Mt,this.tileID.canonical,Gd,Fe,this.tileTransform,this.brightness)}}this.status="done",nt(null,{buckets:Object.values(mt).filter(Pl=>!Pl.isEmpty()),featureIndex:it,collisionBoxArray:this.collisionBoxArray,hasTunnelGeometry:hr,glyphAtlasImage:ri.image,lineAtlas:Gt,imageAtlas:_c,brightness:Mt.brightness})};if(Po){const _c=new Map,qd=f.fr(xr,_c),Pl=f.fr(wn,_c),vc=new f.fs(qd,Pl,Da,this.lut,_c);et.send("checkAtlasCache",{descriptor:vc,scope:this.scope},(Gd,Vc)=>{let Hd,Au;if(Gd&&f.w(`[Worker] Error checking atlas cache: ${Gd.message}`),Vc)Hd=new f.ft(Vc.sourceHash),Au=Vc;else{const Kl=new f.fu(xr,wn,this.lut,Da);Hd=Kl,Au=Kl}xc(Hd,Au)})}else xc(null,{iconPositions:new Map,patternPositions:new Map})};if(!this.extraShadowCaster){const zn=f.fk(Mt.glyphDependencies,Vn=>Object.keys(Vn).map(Number));Object.keys(zn).length?et.send("getGlyphs",{uid:this.uid,stacks:zn},(Vn,Da)=>{rt||(rt=Vn,qt=Da,ks())},void 0,!1,Jn):qt={},Ns=new Map;const ri=Array.from(Mt.iconDependencies.keys()).map(Vn=>f.I.parse(Vn));ri.length?et.send("getImages",{images:ri,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},(Vn,Da)=>{if(!rt){rt=Vn,xr=new Map,Cn=this.updateImageMapAndGetImageTaskQueue(xr,Da.images,Mt.iconDependencies);for(const[Po,To]of Da.versions.entries())Ns.set(Po,To);ks()}},void 0,!1,Jn):(xr=new Map,Cn=new Map);const di=Array.from(Mt.patternDependencies.keys()).map(Vn=>f.I.parse(Vn));di.length?et.send("getImages",{images:di,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},(Vn,Da)=>{if(!rt){rt=Vn,wn=new Map,Qn=this.updateImageMapAndGetImageTaskQueue(wn,Da.images,Mt.patternDependencies);for(const[Po,To]of Da.versions.entries())Ns.set(Po,To);ks()}},void 0,!1,Jn):(wn=new Map,Qn=new Map)}if(Mt.elevationFeatures&&Mt.elevationFeatures.length>0){const zn=[];for(const di of Object.values(mt))if(di instanceof f.fl){const Vn=di.getUnevaluatedPortalGraph();Vn&&zn.push(Vn)}const ri=f.fm.evaluate(zn);for(const di of Object.values(mt))if(di instanceof f.fl){const Vn=he.layers[ht.decode(di.sourceLayerIndex)];di.setEvaluatedPortalGraph(ri,Vn,this.tileID.canonical,Mt.availableImages,Mt.brightness)}}ks()};gr.length>0?Promise.allSettled(gr).then(Hr).catch(nt):Hr()}updateParameters(he){this.scaleFactor=he.scaleFactor,this.showCollisionBoxes=he.showCollisionBoxes,this.projection=he.projection,this.brightness=he.brightness,this.tileTransform=f.fc(he.tileID.canonical,he.projection),this.extraShadowCaster=he.extraShadowCaster,this.lut=he.lut,this.worldview=he.worldview,this.indoor=he.indoor}rasterizeIfNeeded(he,pe,Fe,Ye){Array.from(pe.values()).some(et=>et.usvg)?this.rasterize(he,pe,Fe,Ye):Ye()}updateImageMapAndGetImageTaskQueue(he,pe,Fe){const Ye=new Map;for(const et of pe.keys()){const nt=Fe.get(et)||[];for(const ht of nt){const it=ht.toString(),mt=pe.get(ht.id.toString());mt.usvg?Ye.has(it)||(Ye.set(it,ht),he.set(it,Object.assign({},mt))):he.set(it,mt)}}return Ye}rasterize(he,pe,Fe,Ye){this.rasterizeTask=he.send("rasterizeImages",{scope:this.scope,tasks:Fe},(et,nt)=>{if(!et)for(const[ht,it]of nt.entries()){const mt=Object.assign(pe.get(ht),{data:it});pe.set(ht,mt)}Ye()})}cancelRasterize(){this.rasterizeTask&&this.rasterizeTask.cancel()}}function Q(dt,he,pe,Fe,Ye,et){const nt=new f.ae(he,{brightness:pe,worldview:Ye,activeFloors:et});for(const ht of dt)ht.recalculate(nt,Fe)}class J extends f.E{constructor({actor:he,layerIndex:pe,availableImages:Fe,availableModels:Ye,isSpriteLoaded:et,tileProvider:nt,brightness:ht,maxUniformBufferBindings:it,maxUniformBlockSizeDwords:mt,disableSymbolUBO:Gt}){super(),this.actor=he,this.layerIndex=pe,this.availableImages=Fe,this.availableModels=Ye,this.loadVectorData=f.aO,this.tileProvider=nt,this.loading={},this.loaded={},this.deduped=new f.aN(he.scheduler),this.isSpriteLoaded=et,this.scheduler=he.scheduler,this.brightness=ht,this.maxUniformBufferBindings=it,this.maxUniformBlockSizeDwords=mt,this.disableSymbolUBO=Gt}loadTileData(he,pe){if(!this.tileProvider)return this.loadVectorData(he,pe);const Fe=new AbortController,{z:Ye,x:et,y:nt}=he.tileID.canonical;return this.tileProvider.loadTile({z:Ye,x:et,y:nt},{request:he.request,signal:Fe.signal}).then(ht=>{if(Fe.signal.aborted)return;if(ht==null){const mt=new Error("Tile not found");return mt.status=404,pe(mt)}if(ht.data===null)return pe(null,null);const it=new Map;ht.expires&&it.set("expires",ht.expires),ht.cacheControl&&it.set("cache-control",ht.cacheControl),pe(null,{rawData:ht.data,responseHeaders:it})}).catch(ht=>{Fe.signal.aborted||pe(ht instanceof Error?ht:new Error(String(ht)))}),()=>Fe.abort()}loadTile(he,pe){const Fe=he.uid,Ye=he&&he.request,et=Ye&&Ye.collectResourceTiming,nt=this.loading[Fe]=new K(he);nt.maxUniformBufferBindings=this.maxUniformBufferBindings,nt.maxUniformBlockSizeDwords=this.maxUniformBlockSizeDwords,nt.disableSymbolUBO=this.disableSymbolUBO,nt.abort=this.loadTileData(he,(ht,it)=>{const mt=!this.loading[Fe];if(delete this.loading[Fe],nt.cancelRasterize(),mt||ht||!it)return nt.status="done",mt||(this.loaded[Fe]=nt),pe(ht);const Gt=it.rawData,Mt={},gr=f.aP(it.responseHeaders);gr&&gr.expires&&(Mt.expires=gr.expires),gr&&gr.cacheControl&&(Mt.cacheControl=gr.cacheControl),nt.vectorTile=it.vectorTile||new f.fx(new f.a$(Gt));const zr=()=>{nt.parse(nt.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,(Hr,hr)=>{if(Hr||!hr)return pe(Hr);const rt={};if(et){const qt=m(Ye);qt.length>0&&(rt.resourceTiming=JSON.parse(JSON.stringify(qt)))}pe(null,Object.assign({rawTileData:Gt.slice(0),responseHeaders:it.responseHeaders},hr,Mt,rt))})};this.isSpriteLoaded?zr():this.once("isSpriteLoaded",()=>{this.scheduler?this.scheduler.add(zr,{type:"parseTile",renderSourceType:he.renderSourceType,zoom:he.tileZoom}):zr()}),this.loaded=this.loaded||{},this.loaded[Fe]=nt})}reloadTile(he,pe){const Fe=this.loaded,Ye=he.uid;if(Fe&&Fe[Ye]){const et=Fe[Ye];et.updateParameters(he);const nt=(ht,it)=>{const mt=et.reloadCallback;mt&&(delete et.reloadCallback,et.parse(et.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,mt)),pe(ht,it)};et.status==="parsing"?et.reloadCallback=nt:et.status==="done"&&(et.vectorTile?et.parse(et.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,nt):nt())}else pe(null,void 0)}abortTile(he,pe){const Fe=he.uid,Ye=this.loading[Fe];Ye&&(Ye.abort&&Ye.abort(),delete this.loading[Fe]),pe()}removeTile(he,pe){const Fe=this.loaded,Ye=he.uid;Fe&&Fe[Ye]&&delete Fe[Ye],pe()}}class ee{constructor(he){this.loading={}}loadTile(he,pe){const Fe=he.uid,{cancel:Ye}=f.b1(he.request,(et,nt,ht)=>{const it=!this.loading[Fe];if(delete this.loading[Fe],it||et||!nt)return pe(et);this.decodeTile(Fe,nt,he.encoding).then(mt=>{const{expires:Gt,cacheControl:Mt}=f.aP(ht);pe(null,Object.assign(mt,{expires:Gt,cacheControl:Mt}))}).catch(mt=>pe(mt))});this.loading[Fe]={cancel:Ye}}async decodeTile(he,pe,Fe){const Ye=await createImageBitmap(new Blob([new Uint8Array(pe)],{type:"image/png"})),et=1-(Ye.width-f.fy(Ye.width))/2,nt=et<1,ht=this.getImageData(Ye,et);return Ye.close(),{dem:new f.fz(he,ht,Fe,nt),borderReady:nt}}reloadTile(he,pe){pe(null,null)}abortTile(he,pe){const Fe=he.uid,Ye=this.loading[Fe];Ye&&(Ye.cancel(),delete this.loading[Fe]),pe()}removeTile(he,pe){pe()}getImageData(he,pe){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(he.width,he.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d",{willReadFrequently:!0})),this.offscreenCanvas.width=he.width,this.offscreenCanvas.height=he.height,this.offscreenCanvasContext.drawImage(he,0,0,he.width,he.height);const Fe=this.offscreenCanvasContext.getImageData(-pe,-pe,he.width+2*pe,he.height+2*pe);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),Fe}}f.a_.setPbf(f.a$);class oe{constructor(he){this._mrt=new f.a_(he.partial?30:1/0),this._isHeaderLoaded=!1,this.uid=he.uid,this.tileID=he.tileID,this.source=he.source}parse(he,pe){const Fe=this._mrt;this.status="parsing",this._entireBuffer=he;try{Fe.parseHeader(he),this._isHeaderLoaded=!0;const Ye=[];for(const et in Fe.layers){const nt=Fe.getLayer(et),ht=nt.getDataRange(nt.getBandList()),it=Fe.createDecodingTask(ht),mt=he.slice(ht.firstByte,ht.lastByte+1),Gt=f.a_.performDecoding(mt,it).then(Mt=>it.complete(null,Mt)).catch(Mt=>it.complete(Mt,null));Ye.push(Gt)}Promise.allSettled(Ye).then(()=>pe(null,Fe)).catch(et=>pe(et))}catch(Ye){pe(Ye)}}}class de{constructor({actor:he}){this.actor=he,this.loading={},this.loaded={}}loadTile(he,pe){const Fe=he.uid,Ye=he.request,et=this.loading[Fe]=new oe(he),{cancel:nt}=f.b1(Ye,(ht,it,mt)=>{const Gt=!this.loading[Fe];if(delete this.loading[Fe],Gt||ht||!it)return et.status="done",Gt||(this.loaded[Fe]=et),pe(ht);et.parse(it,(Mt,gr)=>{if(Mt||!gr)return pe(Mt);pe(null,gr,mt)}),this.loaded[Fe]=et});et.abort=nt}reloadTile(he,pe){pe(null,void 0)}abortTile(he,pe){const Fe=he.uid,Ye=this.loading[Fe];Ye&&(Ye.abort&&Ye.abort(),delete this.loading[Fe]),pe()}removeTile(he,pe){const Fe=he.uid;this.loaded[Fe]&&delete this.loaded[Fe],pe()}decodeRasterArray(he,pe){f.a_.performDecoding(he.buffer,he.task).then(Fe=>pe(null,Fe)).catch(Fe=>pe(Fe))}}const ye=f.fA.prototype.toGeoJSON;class Ee{constructor(he){this._feature=he,this.extent=f.an,this.type=he.type,this.properties=he.tags,"id"in he&&!isNaN(he.id)&&(this.id=parseInt(he.id,10))}loadGeometry(){if(this._feature.type===1){const he=[];for(const pe of this._feature.geometry)he.push([new f.P(pe[0],pe[1])]);return he}{const he=[];for(const pe of this._feature.geometry){const Fe=[];for(const Ye of pe)Fe.push(new f.P(Ye[0],Ye[1]));he.push(Fe)}return he}}toGeoJSON(he,pe,Fe){return ye.call(this,he,pe,Fe)}}class Le{constructor(he,pe){this.name=he,this.extent=f.an,this.length=pe.length,this._jsonFeatures=pe}feature(he){return new Ee(this._jsonFeatures[he])}}class Se{constructor(he){this.layers={},this.extent=f.an;for(const pe of Object.keys(he))this.layers[pe]=new Le(pe,he[pe])}}const be=64/4096;class me{constructor(){this.features=new Map}clear(){this.features.clear()}load(he=[],pe){for(const Fe of he){const Ye=Fe.id;if(Ye==null)continue;let et=this.features.get(Ye);et&&this.updateCache(et,pe),Fe.geometry?(et=Pe(Fe),this.updateCache(et,pe),this.features.set(Ye,et)):this.features.delete(Ye),this.updateCache(et,pe)}}updateCache(he,pe){for(const{canonical:Fe,uid:Ye}of Object.values(pe)){const{z:et,x:nt,y:ht}=Fe;ke(he,Math.pow(2,et),nt,ht)&&delete pe[Ye]}}getTile(he,pe,Fe){const Ye=Math.pow(2,he),et=[];for(const nt of this.features.values())ke(nt,Ye,pe,Fe)&&et.push(Ze(nt,Ye,pe,Fe));return{features:et}}getFeatures(){return[...this.features.values()]}}function ke({minX:dt,minY:he,maxX:pe,maxY:Fe},Ye,et,nt){return dt<(et+1+be)/Ye&&he<(nt+1+be)/Ye&&pe>(et-be)/Ye&&Fe>(nt-be)/Ye}function Pe(dt){const{id:he,geometry:pe,properties:Fe}=dt;if(!pe)return;if(pe.type==="GeometryCollection")throw new Error("GeometryCollection not supported in dynamic mode.");const{type:Ye,coordinates:et}=pe,nt={id:he,type:1,geometry:[],tags:Fe,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},ht=nt.geometry;if(Ye==="Point")je(et,ht,nt);else if(Ye==="MultiPoint")for(const it of et)je(it,ht,nt);else if(Ye==="LineString")nt.type=2,xe(et,ht,nt);else if(Ye==="MultiLineString")nt.type=2,Ue(et,ht,nt);else if(Ye==="Polygon")nt.type=3,Ue(et,ht,nt,!0);else{if(Ye!=="MultiPolygon")throw new Error("Input data is not a valid GeoJSON object.");nt.type=3;for(const it of et)Ue(it,ht,nt,!0)}return nt}function je([dt,he],pe,Fe){const Ye=f.aH(dt);let et=f.aL(he);et=et<0?0:et>1?1:et,pe.push(Ye,et),Fe.minX=Math.min(Fe.minX,Ye),Fe.minY=Math.min(Fe.minY,et),Fe.maxX=Math.max(Fe.maxX,Ye),Fe.maxY=Math.max(Fe.maxY,et)}function xe(dt,he,pe,Fe=!1,Ye=!1){const et=[];for(const nt of dt)je(nt,et,pe);he.push(et),Fe&&function(nt,ht){let it=0;for(let mt=0,Gt=nt.length,Mt=Gt-2;mt0===ht)for(let mt=0,Gt=nt.length;mt=nt&&Mt>=nt||(mt>=nt?(Gt+=Math.round(Hr*((nt-mt)/zr)),mt=nt):Mt>=nt&&(gr=Gt+Math.round(Hr*((nt-mt)/zr)),Mt=nt),Gt>=nt&&gr>=nt||(Gt>=nt?(mt+=Math.round(zr*((nt-Gt)/Hr)),Gt=nt):gr>=nt&&(Mt=mt+Math.round(zr*((nt-Gt)/Hr)),gr=nt),ht&&mt===ht[ht.length-1][0]&&Gt===ht[ht.length-1][1]||(ht=[[mt,Gt]],Ye.push(ht)),ht.push([Mt,gr])))))}}function wt(dt,he,pe,Fe,Ye){const et=(pe-be)/he,nt=(Fe-be)/he,ht=(pe+1+be)/he,it=(Fe+1+be)/he;function mt(gr,zr){let Hr=0;return grht&&(Hr|=2),zrit&&(Hr|=8),Hr}let Gt=[];for(let gr=1;gr<=8;gr*=2){let zr=dt[dt.length-2],Hr=dt[dt.length-1],hr=!(mt(zr,Hr)&gr);for(let rt=0;rt>31}function xt(dt,he){const{geometry:pe,type:Fe}=dt;let Ye=0,et=0;if(Fe===1){he.writeVarint(kt(1,pe.length));for(const nt of pe){const ht=nt[0]-Ye,it=nt[1]-et;he.writeVarint(Vt(ht)),he.writeVarint(Vt(it)),Ye+=ht,et+=it}}else for(const nt of pe){if(nt.length===0)continue;he.writeVarint(kt(1,1));const ht=nt.length-(Fe===3?1:0);for(let it=0;itdt},rn=Math.fround||(Rr=new Float32Array(1),dt=>(Rr[0]=+dt,Rr[0]));var Rr;class $r{constructor(he){this.options=Object.assign(Object.create(Sr),he),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(he){const{log:pe,minZoom:Fe,maxZoom:Ye}=this.options;pe&&console.time("total time");const et=`prepare ${he.length} points`;pe&&console.time(et),this.points=he;const nt=[];for(let it=0;it=Fe;it--){const mt=+Date.now();ht=this.trees[it]=this._createTree(this._cluster(ht,it)),pe&&console.log("z%d: %d clusters in %dms",it,ht.numItems,+Date.now()-mt)}return pe&&console.timeEnd("total time"),this}getClusters(he,pe){let Fe=((he[0]+180)%360+360)%360-180;const Ye=Math.max(-90,Math.min(90,he[1]));let et=he[2]===180?180:((he[2]+180)%360+360)%360-180;const nt=Math.max(-90,Math.min(90,he[3]));if(he[2]-he[0]>=360)Fe=-180,et=180;else if(Fe>et){const Mt=this.getClusters([Fe,Ye,180,nt],pe),gr=this.getClusters([-180,Ye,et,nt],pe);return Mt.concat(gr)}const ht=this.trees[this._limitZoom(pe)],it=ht.range(tt(Fe),Tt(nt),tt(et),Tt(Ye)),mt=ht.data,Gt=[];for(const Mt of it){const gr=this.stride*Mt;Gt.push(mt[gr+5]>1?qr(mt,gr,this.clusterProps):this.points[mt[gr+3]])}return Gt}getChildren(he){const pe=this._getOriginId(he),Fe=this._getOriginZoom(he),Ye="No cluster with the specified id.",et=this.trees[Fe];if(!et)throw new Error(Ye);const nt=et.data;if(pe*this.stride>=nt.length)throw new Error(Ye);const ht=this.options.radius/(this.options.extent*Math.pow(2,Fe-1)),it=et.within(nt[pe*this.stride],nt[pe*this.stride+1],ht),mt=[];for(const Gt of it){const Mt=Gt*this.stride;nt[Mt+4]===he&&mt.push(nt[Mt+5]>1?qr(nt,Mt,this.clusterProps):this.points[nt[Mt+3]])}if(mt.length===0)throw new Error(Ye);return mt}getLeaves(he,pe,Fe){const Ye=[];return this._appendLeaves(Ye,he,pe=pe||10,Fe=Fe||0,0),Ye}getTile(he,pe,Fe){const Ye=this.trees[this._limitZoom(he)],et=Math.pow(2,he),{extent:nt,radius:ht}=this.options,it=ht/nt,mt=(Fe-it)/et,Gt=(Fe+1+it)/et,Mt={features:[]};return this._addTileFeatures(Ye.range((pe-it)/et,mt,(pe+1+it)/et,Gt),Ye.data,pe,Fe,et,Mt),pe===0&&this._addTileFeatures(Ye.range(1-it/et,mt,1,Gt),Ye.data,et,Fe,et,Mt),pe===et-1&&this._addTileFeatures(Ye.range(0,mt,it/et,Gt),Ye.data,-1,Fe,et,Mt),Mt.features.length?Mt:null}getClusterExpansionZoom(he){let pe=this._getOriginZoom(he)-1;for(;pe<=this.options.maxZoom;){const Fe=this.getChildren(he);if(pe++,Fe.length!==1)break;he=Fe[0].properties.cluster_id}return pe}_appendLeaves(he,pe,Fe,Ye,et){const nt=this.getChildren(pe);for(const ht of nt){const it=ht.properties;if(it&&it.cluster?et+it.point_count<=Ye?et+=it.point_count:et=this._appendLeaves(he,it.cluster_id,Fe,Ye,et):et1;let Gt,Mt,gr;if(mt)Gt=Nn(pe,it,this.clusterProps),Mt=pe[it],gr=pe[it+1];else{const hr=this.points[pe[it+3]];Gt=hr.properties;const[rt,qt]=hr.geometry.coordinates;Mt=tt(rt),gr=Tt(qt)}const zr={type:1,geometry:[[Math.round(this.options.extent*(Mt*et-Fe)),Math.round(this.options.extent*(gr*et-Ye))]],tags:Gt};let Hr;Hr=mt||this.options.generateId?pe[it+3]:this.points[pe[it+3]].id,Hr!==void 0&&(zr.id=Hr),nt.features.push(zr)}}_limitZoom(he){return Math.max(this.options.minZoom,Math.min(Math.floor(+he),this.options.maxZoom+1))}_cluster(he,pe){const{radius:Fe,extent:Ye,reduce:et,minPoints:nt}=this.options,ht=Fe/(Ye*Math.pow(2,pe)),it=he.data,mt=[],Gt=this.stride;for(let Mt=0;Mtpe&&(rt+=it[xr+5])}if(rt>hr&&rt>=nt){let qt,xr=gr*hr,wn=zr*hr,Cn=-1;const Qn=(Mt/Gt<<5)+(pe+1)+this.points.length;for(const Ns of Hr){const Jn=Ns*Gt;if(it[Jn+2]<=pe)continue;it[Jn+2]=pe;const ks=it[Jn+5];xr+=it[Jn]*ks,wn+=it[Jn+1]*ks,it[Jn+4]=Qn,et&&(qt||(qt=this._map(it,Mt,!0),Cn=this.clusterProps.length,this.clusterProps.push(qt)),et(qt,this._map(it,Jn)))}it[Mt+4]=Qn,mt.push(xr/rt,wn/rt,1/0,Qn,-1,rt),et&&mt.push(Cn)}else{for(let qt=0;qt1)for(const qt of Hr){const xr=qt*Gt;if(!(it[xr+2]<=pe)){it[xr+2]=pe;for(let wn=0;wn>5}_getOriginZoom(he){return(he-this.points.length)%32}_map(he,pe,Fe){if(he[pe+5]>1){const nt=this.clusterProps[he[pe+6]];return Fe?Object.assign({},nt):nt}const Ye=this.points[he[pe+3]].properties,et=this.options.map(Ye);return Fe&&et===Ye?Object.assign({},et):et}}function qr(dt,he,pe){return{type:"Feature",id:dt[he+3],properties:Nn(dt,he,pe),geometry:{type:"Point",coordinates:[(Fe=dt[he],360*(Fe-.5)),Zt(dt[he+1])]}};var Fe}function Nn(dt,he,pe){const Fe=dt[he+5],Ye=Fe>=1e4?`${Math.round(Fe/1e3)}k`:Fe>=1e3?Math.round(Fe/100)/10+"k":Fe,et=dt[he+6],nt=et===-1?{}:Object.assign({},pe[et]);return Object.assign(nt,{cluster:!0,cluster_id:dt[he+3],point_count:Fe,point_count_abbreviated:Ye})}function tt(dt){return dt/360+.5}function Tt(dt){const he=Math.sin(dt*Math.PI/180),pe=.5-.25*Math.log((1+he)/(1-he))/Math.PI;return pe<0?0:pe>1?1:pe}function Zt(dt){const he=(180-360*dt)*Math.PI/180;return 360*Math.atan(Math.exp(he))/Math.PI-90}function ar(dt,he,pe,Fe){let Ye=Fe;const et=he+(pe-he>>1);let nt,ht=pe-he;const it=dt[he],mt=dt[he+1],Gt=dt[pe],Mt=dt[pe+1];for(let gr=he+3;grYe)nt=gr,Ye=zr;else if(zr===Ye){const Hr=Math.abs(gr-et);HrFe&&(nt-he>3&&ar(dt,he,nt,Fe),dt[nt+2]=Ye,pe-nt>3&&ar(dt,nt,pe,Fe))}function Wt(dt,he,pe,Fe,Ye,et){let nt=Ye-pe,ht=et-Fe;if(nt!==0||ht!==0){const it=((dt-pe)*nt+(he-Fe)*ht)/(nt*nt+ht*ht);it>1?(pe=Ye,Fe=et):it>0&&(pe+=nt*it,Fe+=ht*it)}return nt=dt-pe,ht=he-Fe,nt*nt+ht*ht}function Kt(dt,he,pe,Fe){const Ye={id:dt??null,type:he,geometry:pe,tags:Fe,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if(he==="Point"||he==="MultiPoint"||he==="LineString")At(Ye,pe);else if(he==="Polygon")At(Ye,pe[0]);else if(he==="MultiLineString")for(const et of pe)At(Ye,et);else if(he==="MultiPolygon")for(const et of pe)At(Ye,et[0]);return Ye}function At(dt,he){for(let pe=0;pe0&&(nt+=Fe?(Ye*Gt-mt*et)/2:Math.sqrt(Math.pow(mt-Ye,2)+Math.pow(Gt-et,2))),Ye=mt,et=Gt}const ht=he.length-3;he[2]=1,ar(he,0,ht,pe),he[ht+2]=1,he.size=Math.abs(nt),he.start=0,he.end=he.size}function Fn(dt,he,pe,Fe){for(let Ye=0;Ye1?1:pe}function gs(dt,he,pe,Fe,Ye,et,nt,ht){if(Fe/=he,et>=(pe/=he)&&nt=Fe)return null;const it=[];for(const mt of dt){const Gt=mt.geometry;let Mt=mt.type;const gr=Ye===0?mt.minX:mt.minY,zr=Ye===0?mt.maxX:mt.maxY;if(gr>=pe&&zr=Fe)continue;let Hr=[];if(Mt==="Point"||Mt==="MultiPoint")$i(Gt,Hr,pe,Fe,Ye);else if(Mt==="LineString")Cr(Gt,Hr,pe,Fe,Ye,!1,ht.lineMetrics);else if(Mt==="MultiLineString")wi(Gt,Hr,pe,Fe,Ye,!1);else if(Mt==="Polygon")wi(Gt,Hr,pe,Fe,Ye,!0);else if(Mt==="MultiPolygon")for(const hr of Gt){const rt=[];wi(hr,rt,pe,Fe,Ye,!0),rt.length&&Hr.push(rt)}if(Hr.length){if(ht.lineMetrics&&Mt==="LineString"){for(const hr of Hr)it.push(Kt(mt.id,Mt,hr,mt.tags));continue}Mt!=="LineString"&&Mt!=="MultiLineString"||(Hr.length===1?(Mt="LineString",Hr=Hr[0]):Mt="MultiLineString"),Mt!=="Point"&&Mt!=="MultiPoint"||(Mt=Hr.length===3?"Point":"MultiPoint"),it.push(Kt(mt.id,Mt,Hr,mt.tags))}}return it.length?it:null}function $i(dt,he,pe,Fe,Ye){for(let et=0;et=pe&&nt<=Fe&&ii(he,dt[et],dt[et+1],dt[et+2])}}function Cr(dt,he,pe,Fe,Ye,et,nt){let ht=Bn(dt);const it=Ye===0?ia:Xr;let mt,Gt,Mt=dt.start;for(let rt=0;rtpe&&(Gt=it(ht,qt,xr,Cn,Qn,pe),nt&&(ht.start=Mt+mt*Gt)):Ns>Fe?Jn=pe&&(Gt=it(ht,qt,xr,Cn,Qn,pe),ks=!0),Jn>Fe&&Ns<=Fe&&(Gt=it(ht,qt,xr,Cn,Qn,Fe),ks=!0),!et&&ks&&(nt&&(ht.end=Mt+mt*Gt),he.push(ht),ht=Bn(dt)),nt&&(Mt+=mt)}let gr=dt.length-3;const zr=dt[gr],Hr=dt[gr+1],hr=Ye===0?zr:Hr;hr>=pe&&hr<=Fe&&ii(ht,zr,Hr,dt[gr+2]),gr=ht.length-3,et&&gr>=3&&(ht[gr]!==ht[0]||ht[gr+1]!==ht[1])&&ii(ht,ht[0],ht[1],ht[2]),ht.length&&he.push(ht)}function Bn(dt){const he=[];return he.size=dt.size,he.start=dt.start,he.end=dt.end,he}function wi(dt,he,pe,Fe,Ye,et){for(const nt of dt)Cr(nt,he,pe,Fe,Ye,et,!1)}function ii(dt,he,pe,Fe){dt.push(he,pe,Fe)}function ia(dt,he,pe,Fe,Ye,et){const nt=(et-he)/(Fe-he);return ii(dt,et,pe+(Ye-pe)*nt,1),nt}function Xr(dt,he,pe,Fe,Ye,et){const nt=(et-pe)/(Ye-pe);return ii(dt,he+(Fe-he)*nt,et,1),nt}function un(dt,he){const pe=[];for(let Fe=0;Fe0&&he.size<(Ye?nt:Fe))return void(pe.numPoints+=he.length/3);const ht=[];for(let it=0;itnt)&&(pe.numSimplified++,ht.push(he[it],he[it+1])),pe.numPoints++;Ye&&function(it,mt){let Gt=0;for(let Mt=0,gr=it.length,zr=gr-2;Mt0===mt)for(let Mt=0,gr=it.length;Mt24)throw new Error("maxZoom should be in the 0-24 range");if(pe.promoteId&&pe.generateId)throw new Error("promoteId and generateId cannot be used together.");let Ye=function(et,nt){const ht=[];if(et.type==="FeatureCollection")for(let it=0;it1&&console.time("creation"),zr=this.tiles[gr]=nn(he,pe,Fe,Ye,mt),this.tileCoords.push({z:pe,x:Fe,y:Ye}),Gt)){Gt>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",pe,Fe,Ye,zr.numFeatures,zr.numPoints,zr.numSimplified),console.timeEnd("creation"));const ks=`z${pe}`;this.stats[ks]=(this.stats[ks]||0)+1,this.total++}if(zr.source=he,et==null){if(pe===mt.indexMaxZoom||zr.numPoints<=mt.indexMaxPoints)continue}else{if(pe===mt.maxZoom||pe===et)continue;if(et!=null){const ks=et-pe;if(Fe!==nt>>ks||Ye!==ht>>ks)continue}}if(zr.source=null,he.length===0)continue;Gt>1&&console.time("clipping");const Hr=.5*mt.buffer/mt.extent,hr=.5-Hr,rt=.5+Hr,qt=1+Hr;let xr=null,wn=null,Cn=null,Qn=null,Ns=gs(he,Mt,Fe-Hr,Fe+rt,0,zr.minX,zr.maxX,mt),Jn=gs(he,Mt,Fe+hr,Fe+qt,0,zr.minX,zr.maxX,mt);he=null,Ns&&(xr=gs(Ns,Mt,Ye-Hr,Ye+rt,1,zr.minY,zr.maxY,mt),wn=gs(Ns,Mt,Ye+hr,Ye+qt,1,zr.minY,zr.maxY,mt),Ns=null),Jn&&(Cn=gs(Jn,Mt,Ye-Hr,Ye+rt,1,zr.minY,zr.maxY,mt),Qn=gs(Jn,Mt,Ye+hr,Ye+qt,1,zr.minY,zr.maxY,mt),Jn=null),Gt>1&&console.timeEnd("clipping"),it.push(xr||[],pe+1,2*Fe,2*Ye),it.push(wn||[],pe+1,2*Fe,2*Ye+1),it.push(Cn||[],pe+1,2*Fe+1,2*Ye),it.push(Qn||[],pe+1,2*Fe+1,2*Ye+1)}}getTile(he,pe,Fe){he=+he,pe=+pe,Fe=+Fe;const Ye=this.options,{extent:et,debug:nt}=Ye;if(he<0||he>24)return null;const ht=1<1&&console.log("drilling down to z%d-%d-%d",he,pe,Fe);let mt,Gt=he,Mt=pe,gr=Fe;for(;!mt&&Gt>0;)Gt--,Mt>>=1,gr>>=1,mt=this.tiles[Ft(Gt,Mt,gr)];return mt&&mt.source?(nt>1&&(console.log("found parent tile z%d-%d-%d",Gt,Mt,gr),console.time("drilling down")),this.splitTile(mt.source,Gt,Mt,gr,he,pe,Fe),nt>1&&console.timeEnd("drilling down"),this.tiles[it]?Qr(this.tiles[it],et):null):null}}function Ft(dt,he,pe){return 32*((1<mt.tags&&"3d_elevation_id"in mt.tags&&"source"in mt.tags&&mt.tags.source==="elevation",et=Fe.features.filter(mt=>Ye(mt));let nt={_geojsonTileLayer:Fe.features};et.length>0&&(nt={_geojsonTileLayer:Fe.features.filter(mt=>!Ye(mt)),hd_road_elevation:et});const ht=new Se(nt),it=function(mt){const Gt=new f.a$;for(const Mt of Object.keys(mt))Gt.writeMessage(3,yt,{name:Mt,features:mt[Mt]});return Gt.finish()}(nt).buffer;he(null,{vectorTile:ht,rawData:it})}class bs extends J{constructor(he){super(he),this.loadVectorData=So,this._dynamicIndex=new me}loadData(he,pe){const Fe=he&&he.request,Ye=Fe&&Fe.collectResourceTiming;this._geoJSONIndex=null,this.loadGeoJSON(he,(et,nt)=>{if(et||!nt)return pe(et);if(typeof nt!="object")return pe(new Error(`Input data given to '${he.source}' is not a valid GeoJSON object.`));{try{if(he.filter){const it=f.X(he.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if(it.result==="error")throw new Error(it.value.map(mt=>`${mt.key}: ${mt.message}`).join(", "));nt.features=nt.features.filter(mt=>it.value.evaluate({zoom:0},mt))}he.dynamic?(nt.type==="Feature"&&(nt={type:"FeatureCollection",features:[nt]}),he.append||(this._dynamicIndex.clear(),this.loaded={}),this._dynamicIndex.load(nt.features,this.loaded),he.cluster&&(nt.features=this._dynamicIndex.getFeatures())):this.loaded={},this._geoJSONIndex=he.cluster?new $r(function({superclusterOptions:it,clusterProperties:mt}){if(!mt||!it)return it;const Gt={},Mt={},gr={accumulated:null,zoom:0},zr={properties:null},Hr=Object.keys(mt);for(const hr of Hr){const[rt,qt]=mt[hr],xr=f.X(qt),wn=f.X(typeof rt=="string"?[rt,["accumulated"],["get",hr]]:rt);Gt[hr]=xr.value,Mt[hr]=wn.value}return it.map=hr=>{zr.properties=hr;const rt={};for(const qt of Hr)rt[qt]=Gt[qt].evaluate(gr,zr);return rt},it.reduce=(hr,rt)=>{zr.properties=rt;for(const qt of Hr)gr.accumulated=hr[qt],hr[qt]=Mt[qt].evaluate(gr,zr)},it}(he)).load(nt.features):he.dynamic?this._dynamicIndex:function(it,mt){return new Us(it,mt)}(nt,he.geojsonVtOptions)}catch(it){return pe(it)}const ht={};if(Ye){const it=m(Fe);it&&(ht.resourceTiming={},ht.resourceTiming[he.source]=JSON.parse(JSON.stringify(it)))}pe(null,ht)}})}reloadTile(he,pe){const Fe=this.loaded;return Fe&&Fe[he.uid]?he.partial?pe(null,void 0):super.reloadTile(he,pe):this.loadTile(he,pe)}loadGeoJSON(he,pe){if(he.request)f.m(he.request,pe);else{if(typeof he.data!="string")return pe(new Error(`Input data given to '${he.source}' is not a valid GeoJSON object.`));setTimeout(()=>{try{return pe(null,JSON.parse(he.data))}catch{return pe(new Error(`Input data given to '${he.source}' is not a valid GeoJSON object.`))}},0)}}getClusterExpansionZoom(he,pe){try{pe(null,this._geoJSONIndex.getClusterExpansionZoom(he.clusterId))}catch(Fe){pe(Fe)}}getClusterChildren(he,pe){try{pe(null,this._geoJSONIndex.getChildren(he.clusterId))}catch(Fe){pe(Fe)}}getClusterLeaves(he,pe){try{pe(null,this._geoJSONIndex.getLeaves(he.clusterId,he.limit,he.offset))}catch(Fe){pe(Fe)}}}class gi{constructor(he,pe,Fe){this.tileID=new f.aR(he.tileID.overscaledZ,he.tileID.wrap,he.tileID.canonical.z,he.tileID.canonical.x,he.tileID.canonical.y),this.tileZoom=he.tileZoom,this.uid=he.uid,this.zoom=he.zoom,this.canonical=he.tileID.canonical,this.pixelRatio=he.pixelRatio,this.tileSize=he.tileSize,this.source=he.source,this.overscaling=this.tileID.overscaleFactor(),this.projection=he.projection,this.brightness=pe,this.worldview=Fe}parse(he,pe,Fe,Ye){this.status="parsing";const et=new f.aR(Fe.tileID.overscaledZ,Fe.tileID.wrap,Fe.tileID.canonical.z,Fe.tileID.canonical.x,Fe.tileID.canonical.y),nt=[],ht=pe.familiesBySource[Fe.source],it=new f.ff(et,Fe.promoteId);it.bucketLayerIDs=[],it.is3DTile=!0,f.fB(he).then(mt=>{const Gt=mt.json.extensionsUsed&&mt.json.extensionsUsed.includes("MAPBOX_mesh_features")||mt.json.asset.extras&&mt.json.asset.extras.MAPBOX_mesh_features,Mt=mt.json.extensionsUsed&&mt.json.extensionsUsed.includes("EXT_meshopt_compression"),gr=new f.ae(this.zoom,{brightness:this.brightness,worldview:this.worldview});for(const zr in ht)for(const Hr of ht[zr]){const hr=Hr[0];it.bucketLayerIDs.push(Hr.map(xr=>f.F(xr.id,xr.scope))),hr.recalculate(gr,[]);const rt=f.fC(mt,1/f.cS(Fe.tileID.canonical)),qt=new f.fD(Hr,rt,et,Gt,Mt,this.brightness,it,this.worldview);Gt||(qt.needsUpload=!0),nt.push(qt),qt.evaluate(hr)}this.status="done",Ye(null,{buckets:nt,featureIndex:it,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:null})}).catch(mt=>Ye(new Error(mt.message)))}}class Xn{constructor({actor:he,layerIndex:pe,availableImages:Fe,availableModels:Ye,brightness:et,worldview:nt}){this.actor=he,this.layerIndex=pe,this.availableImages=Fe,this.availableModels=Ye,this.brightness=et,this.loading={},this.loaded={},this.worldview=nt}loadTile(he,pe){const Fe=he.uid,Ye=this.loading[Fe]=new gi(he,this.brightness,this.worldview);f.b1(he.request,(et,nt)=>{const ht=!this.loading[Fe];return delete this.loading[Fe],ht||et?(Ye.status="done",ht||(this.loaded[Fe]=Ye),pe(et)):nt&&nt.byteLength!==0?void Ye.parse(nt,this.layerIndex,he,(it,mt)=>{Ye.status="done",this.loaded=this.loaded||{},this.loaded[Fe]=Ye,it||!mt?pe(it):pe(null,mt)}):(Ye.status="done",this.loaded[Fe]=Ye,pe())})}reloadTile(he,pe){const Fe=this.loaded,Ye=he.uid;if(Fe&&Fe[Ye]){const et=Fe[Ye];et.projection=he.projection,et.brightness=he.brightness;const nt=(ht,it)=>{et.reloadCallback&&(delete et.reloadCallback,this.loadTile(he,pe)),pe(ht,it)};et.status==="parsing"?et.reloadCallback=nt:et.status==="done"&&this.loadTile(he,pe)}}abortTile(he,pe){const Fe=he.uid;this.loading[Fe]&&delete this.loading[Fe],pe()}removeTile(he,pe){const Fe=this.loaded,Ye=he.uid;Fe&&Fe[Ye]&&delete Fe[Ye],pe()}}const Ma=new Map,yc=new Map;class ul{constructor(he){this.self=he,this.actor=new f.A(he,this),this.layerIndexes={},this.availableImages={},this.availableModels={},this.isSpriteLoaded={},this.imageRasterizer=new f.z,this.rtlPluginParsingListeners=[],this.projections={},this.defaultProjection=f.c0({name:"mercator"}),this.workerSourceTypes={vector:J,geojson:bs,"raster-dem":ee,"raster-array":de,"batched-model":Xn},this.workerSources={},this.self.registerWorkerSource=(pe,Fe)=>{if(this.workerSourceTypes[pe])throw new Error(`Worker source with name "${pe}" already registered.`);this.workerSourceTypes[pe]=Fe},this.self.registerRTLTextPlugin=pe=>{if(f.fF.isParsed())throw new Error("RTL text plugin already registered.");f.fF.setState({pluginStatus:f.fG.parsed,pluginURL:f.fF.getPluginURL()}),f.fF.applyArabicShaping=pe.applyArabicShaping,f.fF.processBidirectionalText=pe.processBidirectionalText,f.fF.processStyledBidirectionalText=pe.processStyledBidirectionalText;for(const Fe of this.rtlPluginParsingListeners)Fe(null,!0);this.rtlPluginParsingListeners=[]}}clearCaches(he,pe,Fe){delete this.layerIndexes[he],delete this.availableImages[he],delete this.availableModels[he],delete this.workerSources[he],Fe()}checkIfReady(he,pe,Fe){Fe()}setReferrer(he,pe){this.referrer=pe}spriteLoaded(he,pe){this.isSpriteLoaded[he]||(this.isSpriteLoaded[he]={});const{scope:Fe,isLoaded:Ye}=pe;if(this.isSpriteLoaded[he][Fe]=Ye,this.workerSources[he]&&this.workerSources[he][Fe])for(const et in this.workerSources[he][Fe]){const nt=this.workerSources[he][Fe][et];for(const ht in nt){const it=nt[ht];it instanceof J&&(it.isSpriteLoaded=Ye,it.fire(new f.C("isSpriteLoaded")))}}}setImages(he,pe,Fe){this.availableImages[he]||(this.availableImages[he]={});const{scope:Ye,images:et}=pe;if(this.availableImages[he][Ye]=et,this.workerSources[he]&&this.workerSources[he][Ye]){for(const nt in this.workerSources[he][Ye]){const ht=this.workerSources[he][Ye][nt];for(const it in ht)ht[it].availableImages=et}Fe()}else Fe()}setModels(he,{scope:pe,models:Fe},Ye){if(this.availableModels[he]||(this.availableModels[he]={}),this.availableModels[he][pe]=Fe,this.workerSources[he]&&this.workerSources[he][pe]){for(const et in this.workerSources[he][pe]){const nt=this.workerSources[he][pe][et];for(const ht in nt)nt[ht].availableModels=Fe}Ye()}else Ye()}setProjection(he,pe){this.projections[he]=f.c0(pe)}setBrightness(he,pe,Fe){this.brightness=pe,Fe()}setContextParams(he,pe,Fe){this.maxUniformBufferBindings=pe.maxBindingPoints,this.maxUniformBlockSizeDwords=pe.maxUniformBlockSizeDwords,this.disableSymbolUBO=pe.disableSymbolUBO,Fe()}setWorldview(he,pe,Fe){this.worldview=pe,Fe()}setLayers(he,pe,Fe){this.getLayerIndex(he,pe.scope).replace(pe.layers,pe.options),Fe()}updateLayers(he,pe,Fe){this.getLayerIndex(he,pe.scope).update(pe.layers,pe.removedIds,pe.options),Fe()}loadTile(he,pe,Fe){pe.projection=this.projections[he]||this.defaultProjection,this.getWorkerSource(he,pe).loadTile(pe,Fe)}decodeRasterArray(he,pe,Fe){this.getWorkerSource(he,pe).decodeRasterArray(pe,Fe)}reloadTile(he,pe,Fe){pe.projection=this.projections[he]||this.defaultProjection,this.getWorkerSource(he,pe).reloadTile(pe,Fe)}abortTile(he,pe,Fe){this.getWorkerSource(he,pe).abortTile(pe,Fe)}removeTile(he,pe,Fe){this.getWorkerSource(he,pe).removeTile(pe,Fe)}removeSource(he,pe,Fe){if(!(this.workerSources[he]&&this.workerSources[he][pe.scope]&&this.workerSources[he][pe.scope][pe.type]&&this.workerSources[he][pe.scope][pe.type][pe.source]))return;const Ye=this.workerSources[he][pe.scope][pe.type][pe.source];delete this.workerSources[he][pe.scope][pe.type][pe.source],Ye.removeSource!==void 0?Ye.removeSource(pe,Fe):Fe()}loadTileProvider(he,pe,Fe){(async function(Ye,et){const nt=yc.get(Ye);if(nt)return nt;const ht=Ma.get(Ye);if(ht!==void 0)return ht;const it=import(et).then(mt=>{const Gt=mt.default;if(typeof Gt!="function")throw new Error(`TileProvider "${Ye}" module must default-export a class`);if(typeof Gt.prototype.loadTile!="function")throw new Error(`TileProvider "${Ye}" class must have a loadTile method`);return yc.set(Ye,Gt),Gt}).finally(()=>{Ma.delete(Ye)});return Ma.set(Ye,it),it})(pe.name,pe.url).then(Ye=>{const et=new Ye(pe.options);return this.getWorkerSource(he,{type:pe.type,source:pe.source,scope:pe.scope},et),et.load&&pe.request?et.load({request:pe.request}):null}).then(Ye=>Fe(null,Ye)).catch(Ye=>Fe(Ye instanceof Error?Ye:new Error(typeof Ye=="string"?Ye:"Unknown error")))}loadWorkerSource(he,pe,Fe){try{this.self.importScripts(pe.url),Fe()}catch(Ye){Fe(Ye)}}syncRTLPluginState(he,pe,Fe){if(f.fF.isParsed())Fe(null,!0);else if(f.fF.isParsing())this.rtlPluginParsingListeners.push(Fe);else try{f.fF.setState(pe);const Ye=f.fF.getPluginURL();!f.fF.isLoaded()||f.fF.isParsed()||f.fF.isParsing()||Ye==null||(f.fF.setState({pluginStatus:f.fG.parsing,pluginURL:f.fF.getPluginURL()}),this.self.importScripts(Ye),f.fF.isParsed()?Fe(null,!0):this.rtlPluginParsingListeners.push(Fe))}catch(Ye){Fe(Ye)}}setConfig(he,pe){Object.assign(f.g,pe)}getAvailableImages(he,pe){this.availableImages[he]||(this.availableImages[he]={});let Fe=this.availableImages[he][pe];return Fe||(Fe=[]),Fe}getAvailableModels(he,pe){this.availableModels[he]||(this.availableModels[he]={});let Fe=this.availableModels[he][pe];return Fe||(Fe={}),Fe}getLayerIndex(he,pe){this.layerIndexes[he]||(this.layerIndexes[he]={});let Fe=this.layerIndexes[he][pe];return Fe||(Fe=this.layerIndexes[he][pe]=new E,Fe.scope=pe),Fe}getWorkerSource(he,pe,Fe){const{type:Ye,source:et,scope:nt}=pe,ht=this.workerSources;if(ht[he]||(ht[he]={}),ht[he][nt]||(ht[he][nt]={}),ht[he][nt][Ye]||(ht[he][nt][Ye]={}),this.isSpriteLoaded[he]||(this.isSpriteLoaded[he]={}),!ht[he][nt][Ye][et]){const it={send:(Gt,Mt,gr,zr,Hr,hr)=>this.actor.send(Gt,Mt,gr,he,Hr,hr),scheduler:this.actor.scheduler},mt=this.workerSourceTypes[Ye];if(!mt)throw new Error(`Unknown worker source type "${Ye}".`);ht[he][nt][Ye][et]=new mt({actor:it,layerIndex:this.getLayerIndex(he,nt),availableImages:this.getAvailableImages(he,nt),availableModels:this.getAvailableModels(he,nt),isSpriteLoaded:this.isSpriteLoaded[he][nt],tileProvider:Fe,brightness:this.brightness,worldview:this.worldview,maxUniformBufferBindings:this.maxUniformBufferBindings,maxUniformBlockSizeDwords:this.maxUniformBlockSizeDwords,disableSymbolUBO:this.disableSymbolUBO})}return ht[he][nt][Ye][et]}rasterizeImagesWorker(he,pe,Fe){const Ye=new Map;for(const[et,{image:nt,imageVariant:ht}]of pe.tasks.entries()){const it=this.imageRasterizer.rasterize(ht,nt,pe.scope,he);Ye.set(et,it)}Fe(void 0,Ye)}removeRasterizedImages(he,pe,Fe){this.imageRasterizer.removeImagesFromCacheByIds(pe.imageIds,pe.scope,he),Fe()}enforceCacheSizeLimit(he,pe){f.fH(pe)}getWorkerPerformanceMetrics(he,pe,Fe){Fe(void 0,void 0)}}return f.fE(self)&&(self.worker=new ul(self)),ul}),o(["./shared"],function(a){var f="3.22.0";const m={create:"create",load:"load",fullLoad:"fullLoad"},y={mark(v){performance.mark(v)},measure(v,d,g){performance.measure(v,d,g)}};function _(v){const d=v.name.split("?")[0];return a.a(d)&&d.includes("mapbox-gl.js")?"javascript":a.a(d)&&d.includes("mapbox-gl.css")?"css":a.b(d)?"fontRange":a.c(d)?"sprite":a.i(d)?"style":a.d(d)?"tilejson":"other"}var w,E={},A=function(){if(w)return E;function v(S){return!d(S)}function d(S){return typeof window>"u"||typeof document>"u"?"not a browser":function(){if(!("Worker"in window&&"Blob"in window&&"URL"in window))return!1;var R,L,F=new Blob([""],{type:"text/javascript"}),z=URL.createObjectURL(F);try{L=new Worker(z),R=!0}catch{R=!1}return L&&L.terminate(),URL.revokeObjectURL(z),R}()?function(){var R=document.createElement("canvas");R.width=R.height=1;var L=R.getContext("2d");if(!L)return!1;var F=L.getImageData(0,0,1,1);return F&&F.width===R.width}()?(g[j=S&&S.failIfMajorPerformanceCaveat]===void 0&&(g[j]=function(R){var L,F=function(z){var W=document.createElement("canvas"),Z=Object.create(v.webGLContextAttributes);return Z.failIfMajorPerformanceCaveat=z,W.getContext("webgl2",Z)}(R);if(!F)return!1;try{L=F.createShader(F.VERTEX_SHADER)}catch{return!1}return!(!L||F.isContextLost())&&(F.shaderSource(L,"void main() {}"),F.compileShader(L),F.getShaderParameter(L,F.COMPILE_STATUS)===!0)}(j)),g[j]?document.documentMode?"insufficient ECMAScript 6 support":void 0:"insufficient WebGL2 support"):"insufficient Canvas/getImageData support":"insufficient worker support";var j}w=1,E.supported=v,E.notSupportedReason=d;var g={};return v.webGLContextAttributes={antialias:!1,alpha:!0,stencil:!0,depth:!0},E}();function C(v,d,g){const S=document.createElement(v);return d!=null&&(S.className=d),g&&g.appendChild(S),S}function I(v,d,g){const S=document.createElementNS("http://www.w3.org/2000/svg",v);for(const j of Object.keys(d))S.setAttributeNS(null,j,String(d[j]));return g&&g.appendChild(S),S}const M=typeof document<"u"?document.documentElement&&document.documentElement.style:null,D=M&&M.userSelect!==void 0?"userSelect":"WebkitUserSelect";let B;function U(){M&&D&&(B=M[D],M[D]="none")}function q(){M&&D&&(M[D]=B)}function H(v){v.preventDefault(),v.stopPropagation(),window.removeEventListener("click",H,!0)}function K(){window.addEventListener("click",H,!0),window.setTimeout(()=>{window.removeEventListener("click",H,!0)},0)}function Q(v,d){const g=v.getBoundingClientRect();return oe(v,g,d)}function J(v,d){const g=v.getBoundingClientRect(),S=[];for(let j=0;jthis._skuTokenExpiresAt}transformRequest(d,g){return this._transformRequestFn&&this._transformRequestFn(d,g)||{url:d}}normalizeStyleURL(d,g){if(!a.e(d))return d;const S=Se(d);return S.params.push(`sdk=js-${f}`),S.path=`/styles/v1${S.path}`,this._makeAPIURL(S,this._customAccessToken||g)}normalizeGlyphsURL(d,g){if(!a.e(d))return d;const S=Se(d);return S.path=`/fonts/v1${S.path}`,this._makeAPIURL(S,this._customAccessToken||g)}normalizeModelURL(d,g){if(!a.e(d))return d;const S=Se(d);return S.path=`/models/v1${S.path}`,this._makeAPIURL(S,this._customAccessToken||g)}normalizeSourceURL(d,g,S,j){if(!a.e(d))return d;const R=Se(d);return R.path=`/v4/${R.authority}.json`,R.params.push("secure"),S&&R.params.push(`language=${S}`),j&&R.params.push(`worldview=${j}`),this._makeAPIURL(R,this._customAccessToken||g)}normalizeIconsetURL(d,g){const S=Se(d);return a.e(d)?(S.path=`/styles/v1${S.path}/iconset.pbf`,this._makeAPIURL(S,this._customAccessToken||g)):be(S)}normalizeSpriteURL(d,g,S,j){const R=Se(d);return a.e(d)?(R.path=`/styles/v1${R.path}/sprite${g}${S}`,this._makeAPIURL(R,this._customAccessToken||j)):(R.path+=`${g}${S}`,be(R))}normalizeTileURL(d,g,S){if(this._isSkuTokenExpired()&&this._createSkuToken(),d&&!a.e(d))return d;const j=Se(d);j.path=j.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${g||S&&j.authority!=="raster"&&S===512?"@2x":""}${a.k.supported?".webp":"$1"}`),j.authority==="raster"?j.path=`/${a.g.RASTER_URL_PREFIX}${j.path}`:j.authority==="rasterarrays"?j.path=`/${a.g.RASTERARRAYS_URL_PREFIX}${j.path}`:j.authority==="3dtiles"?j.path=`/${a.g.TILES3D_URL_PREFIX}${j.path}`:(j.path=j.path.replace(/^.+\/v4\//,"/"),j.path=`/${a.g.TILE_URL_VERSION}${j.path}`);const R=this._customAccessToken||function(L){for(const F of L){const z=F.match(/^access_token=(.*)$/);if(z)return z[1]}return null}(j.params)||a.g.ACCESS_TOKEN;return a.g.REQUIRE_ACCESS_TOKEN&&R&&this._skuToken&&j.params.push(`sku=${this._skuToken}`),this._makeAPIURL(j,R)}canonicalizeTileURL(d,g){const S=Se(d);if(!S.path.match(/^(\/v4\/|\/(raster|rasterarrays)\/v1\/)/)||!S.path.match(/\.[\w]+$/))return d;let j="mapbox://";S.path.match(/^\/raster\/v1\//)?j+=`raster/${S.path.replace(`/${a.g.RASTER_URL_PREFIX}/`,"")}`:S.path.match(/^\/rasterarrays\/v1\//)?j+=`rasterarrays/${S.path.replace(`/${a.g.RASTERARRAYS_URL_PREFIX}/`,"")}`:j+=`tiles/${S.path.replace(`/${a.g.TILE_URL_VERSION}/`,"")}`;let R=S.params;return g&&(R=R.filter(L=>!L.match(/^access_token=/))),R.length&&(j+=`?${R.join("&")}`),j}canonicalizeTileset(d,g){const S=!!g&&a.e(g),j=[];for(const R of d.tiles||[])a.f(R)?j.push(this.canonicalizeTileURL(R,S)):j.push(R);return j}_makeAPIURL(d,g){const S="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",j=Se(a.g.API_URL);if(d.protocol=j.protocol,d.authority=j.authority,d.protocol==="http"){const R=d.params.indexOf("secure");R>=0&&d.params.splice(R,1)}if(j.path!=="/"&&(d.path=`${j.path}${d.path}`),!a.g.REQUIRE_ACCESS_TOKEN)return be(d);if(g=g||a.g.ACCESS_TOKEN,!this._silenceAuthErrors){if(!g)throw new Error(`An API access token is required to use Mapbox GL. ${S}`);if(g[0]==="s")throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${S}`)}return d.params=d.params.filter(R=>R.indexOf("access_token")===-1),d.params.push(`access_token=${g||""}`),be(d)}}const Le=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function Se(v){const d=v.match(Le);if(!d)throw new Error("Unable to parse URL object");return{protocol:d[1],authority:d[2],path:d[3]||"/",params:d[4]?d[4].split("&"):[]}}function be(v){const d=v.params.length?`?${v.params.join("&")}`:"";return`${v.protocol}://${v.authority}${v.path}${d}`}const me="mapbox.eventData";function ke(v){if(!v)return null;const d=v.split(".");if(!d||d.length!==3)return null;try{return JSON.parse(a.l(d[1]))}catch{return null}}function Pe(v){return!(!a.g.EVENTS_URL||!v&&!a.g.ACCESS_TOKEN)}class je{constructor(d){this.type=d,this.anonId=null,this.anonIdTimestamp=null,this.eventData={},this.queue=[],this.pendingRequest=null}getStorageKey(d){const g=ke(a.g.ACCESS_TOKEN);let S="";return S=g&&g.u?a.j(g.u):a.g.ACCESS_TOKEN||"",d?`${me}.${d}:${S}`:`${me}:${S}`}fetchEventData(){const d=a.s("localStorage"),g=this.getStorageKey(),S=this.getStorageKey("uuid"),j=this.getStorageKey("uuidTimestamp");if(d)try{const R=localStorage.getItem(g);R&&(this.eventData=JSON.parse(R));const L=localStorage.getItem(S);L&&(this.anonId=L);const F=localStorage.getItem(j);F&&(this.anonIdTimestamp=Number(F));const z=Date.now()-864e5;(!this.anonIdTimestamp||this.anonIdTimestamp=1&&localStorage.setItem(g,JSON.stringify(this.eventData)),L&&localStorage.setItem(j,L.toString())}catch{a.w("Unable to write to LocalStorage")}}processRequests(d){}postEvent(d,g,S,j){if(!a.g.EVENTS_URL)return;const R=Se(a.g.EVENTS_URL);R.params.push(`access_token=${j||a.g.ACCESS_TOKEN||""}`);const L={event:this.type,created:new Date(d).toISOString()},F=g?Object.assign(L,g):L,z={url:be(R),headers:{"Content-Type":"text/plain"},body:JSON.stringify([F])};this.pendingRequest=a.p(z,W=>{this.pendingRequest=null,S(W),this.saveEventData(),this.processRequests(j)})}queueRequest(d,g){this.queue.push(d),this.processRequests(g)}}class xe extends je{constructor(d){super("metrics"),d&&(this.data=d)}postMetricsEvent(d){if(!Pe(d))return;this.anonId||this.fetchEventData(),a.v(this.anonId)||this.refreshUUID();const g=Object.assign({},this.data,{sessionId:this.anonId});this.queueRequest({timestamp:Date.now(),payload:g},d)}processRequests(d){if(this.pendingRequest||this.queue.length===0)return;const{timestamp:g,payload:S}=this.queue.shift();this.postEvent(g,S,()=>{},d)}}const Ue=new class extends je{constructor(v){super("appUserTurnstile"),this._customAccessToken=v}postTurnstileEvent(v,d){Pe(d)&&Array.isArray(v)&&v.some(g=>a.e(g)||a.f(g))&&this.queueRequest(Date.now(),d)}processRequests(v){if(this.pendingRequest||this.queue.length===0)return;this.anonId&&this.anonIdTimestamp&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();const d=ke(a.g.ACCESS_TOKEN),g=d?d.u:a.g.ACCESS_TOKEN;let S=g!==this.eventData.tokenU;a.v(this.anonId)||(this.refreshUUID(),S=!0);const j=this.queue.shift();if(this.eventData.lastSuccess){const R=new Date(this.eventData.lastSuccess),L=new Date(j),F=(j-this.eventData.lastSuccess)/864e5;S=S||F>=1||F<-1||R.getDate()!==L.getDate()}else S=!0;S?this.postEvent(j,{sdkIdentifier:"mapbox-gl-js",sdkVersion:f,skuId:de,"enabled.telemetry":!1,userId:this.anonId},R=>{R||(this.eventData.lastSuccess=j,this.eventData.tokenU=g)},v):this.processRequests()}},Ze=Ue.postTurnstileEvent.bind(Ue),lt=new class extends je{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(v,d,g,S){this.skuToken=d,this.errorCb=S,a.g.EVENTS_URL&&(g||a.g.ACCESS_TOKEN?this.queueRequest({id:v,timestamp:Date.now()},g):this.errorCb(new Error(ye)))}processRequests(v){if(this.pendingRequest||this.queue.length===0)return;const{id:d,timestamp:g}=this.queue.shift();d&&this.success[d]||(this.anonId&&this.anonIdTimestamp||this.fetchEventData(),a.v(this.anonId)||this.refreshUUID(),this.postEvent(g,{sdkIdentifier:"mapbox-gl-js",sdkVersion:f,skuId:de,skuToken:this.skuToken,userId:this.anonId},S=>{S?this.errorCb(S):d&&(this.success[d]=!0)},v))}remove(){this.errorCb=null}},wt=lt.postMapLoadEvent.bind(lt),yt=new class extends je{constructor(){super("style.load"),this.eventIdPerMapInstanceMap=new Map,this.mapInstanceIdMap=new WeakMap}getMapInstanceId(v){let d=this.mapInstanceIdMap.get(v);return d||(d=a.u(),this.mapInstanceIdMap.set(v,d)),d}getEventId(v){const d=this.eventIdPerMapInstanceMap.get(v)||0;return this.eventIdPerMapInstanceMap.set(v,d+1),d}postStyleLoadEvent(v,d){const{map:g,style:S,importedStyles:j}=d;if(!Pe(v))return;const R=this.getMapInstanceId(g),L={mapInstanceId:R,eventId:this.getEventId(R),style:S};j.length&&(L.importedStyles=j),this.queueRequest({timestamp:Date.now(),payload:L},v)}processRequests(v){if(this.pendingRequest||this.queue.length===0)return;const{timestamp:d,payload:g}=this.queue.shift();this.postEvent(d,g,()=>{},v)}},gt=yt.postStyleLoadEvent.bind(yt),ft=new xe({attributes:[{name:"maps/js/layer-animations/style-with-appearances"}]}),kt=ft.postMetricsEvent.bind(ft),Vt=new xe({attributes:[{name:"maps/js/layer-animations/runtime-appearances"}]}),xt=Vt.postMetricsEvent.bind(Vt),or=new class extends je{constructor(){super("gljs.performance")}postPerformanceEvent(v,d){Pe(v)&&this.queueRequest({timestamp:Date.now(),performanceData:d},v)}processRequests(v){if(this.pendingRequest||this.queue.length===0)return;const{timestamp:d,performanceData:g}=this.queue.shift(),S=function(j){const R=performance.getEntriesByType("resource"),L=performance.getEntriesByType("mark"),F=function(ie){const ce={};if(ie){for(const le in ie)if(le!=="other")for(const ve of ie[le]){const _e=`${le}ResolveRangeMin`,Re=`${le}ResolveRangeMax`,Me=`${le}RequestCount`,Te=`${le}RequestCachedCount`;ce[_e]=Math.min(ce[_e]||1/0,ve.startTime),ce[Re]=Math.max(ce[Re]||-1/0,ve.responseEnd);const Xe=$e=>{ce[$e]===void 0&&(ce[$e]=0),++ce[$e]};ve.transferSize!==void 0&&ve.transferSize===0&&Xe(Te),Xe(Me)}}return ce}(function(ie,ce){const le={};if(ie)for(const ve of ie){const _e=ce(ve);le[_e]===void 0&&(le[_e]=[]),le[_e].push(ve)}return le}(R,_)),z=window.devicePixelRatio,W=navigator.connection||navigator.mozConnection||navigator.webkitConnection,Z=W?W.effectiveType:void 0,ne={counters:[],metadata:[],attributes:[]},re=(ie,ce,le)=>{le!=null&&ie.push({name:ce,value:le.toString()})};for(const ie in F)re(ne.counters,ie,F[ie]);if(j.interactionRange[0]!==1/0&&j.interactionRange[1]!==-1/0&&(re(ne.counters,"interactionRangeMin",j.interactionRange[0]),re(ne.counters,"interactionRangeMax",j.interactionRange[1])),L)for(const ie of Object.values(m)){const ce=L.find(le=>le.name===ie);ce&&re(ne.counters,ie,ce.startTime)}return re(ne.counters,"visibilityHidden",j.visibilityHidden),re(ne.attributes,"style",function(ie){if(ie)for(const ce of ie){const le=ce.name.split("?")[0];if(a.i(le)){const ve=le.split("/").slice(-2);if(ve.length===2)return`mapbox://styles/${ve[0]}/${ve[1]}`}}}(R)),re(ne.attributes,"terrainEnabled",j.terrainEnabled?"true":"false"),re(ne.attributes,"fogEnabled",j.fogEnabled?"true":"false"),re(ne.attributes,"projection",j.projection),re(ne.attributes,"zoom",j.zoom),re(ne.metadata,"devicePixelRatio",z),re(ne.metadata,"connectionEffectiveType",Z),re(ne.metadata,"navigatorUserAgent",navigator.userAgent),re(ne.metadata,"screenWidth",window.screen.width),re(ne.metadata,"screenHeight",window.screen.height),re(ne.metadata,"windowWidth",window.innerWidth),re(ne.metadata,"windowHeight",window.innerHeight),re(ne.metadata,"mapWidth",j.width/z),re(ne.metadata,"mapHeight",j.height/z),re(ne.metadata,"webglRenderer",j.renderer),re(ne.metadata,"webglVendor",j.vendor),re(ne.metadata,"sdkVersion",f),re(ne.metadata,"sdkIdentifier","mapbox-gl-js"),ne}(g);for(const j of S.metadata);for(const j of S.counters);for(const j of S.attributes);this.postEvent(d,S,()=>{},v)}},Sr=or.postPerformanceEvent.bind(or),rn=new class extends je{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(v,d,g,S){if(!a.g.API_URL||!a.g.SESSION_PATH)return;const j=Se(a.g.API_URL+a.g.SESSION_PATH);j.params.push(`sku=${d||""}`),j.params.push(`access_token=${S||a.g.ACCESS_TOKEN||""}`);const R={url:be(j),headers:{"Content-Type":"text/plain"}};this.pendingRequest=a.h(R,L=>{this.pendingRequest=null,g(L),this.saveEventData(),this.processRequests(S)})}getSessionAPI(v,d,g,S){this.skuToken=d,this.errorCb=S,a.g.EVENTS_URL&&a.g.SESSION_PATH&&a.g.API_URL&&(g||a.g.ACCESS_TOKEN?this.queueRequest({id:v,timestamp:Date.now()},g):this.errorCb(new Error(ye)))}processRequests(v){if(this.pendingRequest||this.queue.length===0)return;const{id:d,timestamp:g}=this.queue.shift();d&&this.success[d]||this.getSession(g,this.skuToken,S=>{S?this.errorCb(S):d&&(this.success[d]=!0)},v)}remove(){this.errorCb=null}},Rr=rn.getSessionAPI.bind(rn),$r=new Set;function qr(v,d){d?$r.add(v):$r.delete(v)}class Nn{constructor(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSourceCaches={},this._updatedPaintProps=new Set,this._updatedImages={}}isDirty(){return this._changed}setDirty(){this._changed=!0}getUpdatedSourceCaches(){return this._updatedSourceCaches}updateSourceCache(d,g){this._updatedSourceCaches[d]=g,this.setDirty()}discardSourceCacheUpdate(d){delete this._updatedSourceCaches[d]}updateLayer(d){const g=d.scope;this._updatedLayers[g]=this._updatedLayers[g]||new Set,this._updatedLayers[g].add(d.id),this.setDirty()}removeLayer(d){const g=d.scope;this._removedLayers[g]=this._removedLayers[g]||{},this._updatedLayers[g]=this._updatedLayers[g]||new Set,this._removedLayers[g][d.id]=d,this._updatedLayers[g].delete(d.id),this._updatedPaintProps.delete(d.fqid),this.setDirty()}getRemovedLayer(d){return this._removedLayers[d.scope]?this._removedLayers[d.scope][d.id]:null}discardLayerRemoval(d){this._removedLayers[d.scope]&&delete this._removedLayers[d.scope][d.id]}getLayerUpdatesByScope(){const d={};for(const g in this._updatedLayers)d[g]=d[g]||{},d[g].updatedIds=Array.from(this._updatedLayers[g].values());for(const g in this._removedLayers)d[g]=d[g]||{},d[g].removedIds=Object.keys(this._removedLayers[g]);return d}getUpdatedPaintProperties(){return this._updatedPaintProps}updatePaintProperties(d){this._updatedPaintProps.add(d.fqid),this.setDirty()}getUpdatedImages(d){return this._updatedImages[d]?Array.from(this._updatedImages[d].values()):[]}updateImage(d,g){this._updatedImages[g]=this._updatedImages[g]||new Set,this._updatedImages[g].add(a.I.toString(d)),this.setDirty()}resetUpdatedImages(d){this._updatedImages[d]&&this._updatedImages[d].clear()}reset(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSourceCaches={},this._updatedPaintProps.clear(),this._updatedImages={}}}function tt(v){const{userImage:d}=v;return!!(d&&d.render&&d.render())&&(v.data.replace(new Uint8Array(d.data.buffer)),!0)}const Tt={workerUrl:"",workerClass:null,workerParams:void 0};function Zt(v){return Tt.workerClass!=null?new Tt.workerClass:new self.Worker(Tt.workerUrl,Object.assign({name:v},Tt.workerParams))}const ar="mapboxgl_preloaded_worker_pool";class Wt{constructor(d){this.active={},this.name=d}acquire(d,g=Wt.workerCount){if(!this.workers)for(this.workers=[];this.workers.length{g.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[ar]}numActive(){return Object.keys(this.active).length}}Wt.workerCount=2;class Kt{constructor(d,g,S="Worker",j=Wt.workerCount){this.workerPool=d,this.actors=[],this.currentActor=0,this.id=a.r();const R=this.workerPool.acquire(this.id,j);for(let L=0;L{this.ready=!0})}broadcast(d,g,S){a.t(this.actors,(j,R)=>{j.send(d,g,R)},S=S||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach(d=>{d.remove()}),this.actors=[],this.workerPool.release(this.id)}}let At,pr;function yn(){return At||(At=new Wt),At}Kt.Actor=a.A;class Gn extends a.E{constructor(d){super(),this.imageProviders=new Map,this.images=new Map,this.updatedImages=new Map,this.callbackDispatchedThisFrame=new Map,this.imageVersions=new Map,this.loaded=new Map,this.requestors=[],this.patterns=new Map,this.patternsInFlight=new Set,this.atlasImage=new Map,this.atlasTexture=new Map,this.imageAtlasCache=new a.x,this.dirty=!0,this.spriteFormat=d,d!=="raster"&&a.y()&&(this.imageRasterizerDispatcher=new Kt((pr||(pr=new Wt("ImageRasterizer")),pr),this,"Image Rasterizer Worker",1))}addScope(d){this.loaded.set(d,!1),this.imageProviders.set(d,new Map),this.images.set(d,new Map),this.updatedImages.set(d,new Set),this.callbackDispatchedThisFrame.set(d,new Set),this.imageVersions.set(d,new Map),this.patterns.set(d,new Map),this.atlasImage.set(d,new a.q({width:1,height:1}))}removeScope(d){this.loaded.delete(d),this.imageProviders.delete(d),this.images.delete(d),this.updatedImages.delete(d),this.callbackDispatchedThisFrame.delete(d),this.imageVersions.delete(d),this.patterns.delete(d),this.atlasImage.delete(d);const g=this.atlasTexture.get(d);g&&(g.destroy(),this.atlasTexture.delete(d))}addImageProvider(d,g){this.imageProviders.has(g)||this.imageProviders.set(g,new Map),this.imageProviders.get(g).set(d.id,d)}removeImageProvider(d,g){this.imageProviders.has(g)&&this.imageProviders.get(g).delete(d)}getPendingImageProviders(){const d=[];for(const g of this.imageProviders.values())for(const S of g.values())S.hasPendingRequests()&&d.push(S);return d}get imageRasterizer(){return this._imageRasterizer||(this._imageRasterizer=new a.z),this._imageRasterizer}isLoaded(){for(const d of this.loaded.keys())if(!this.loaded.get(d))return!1;return!0}setLoaded(d,g){if(this.loaded.get(g)!==d&&(this.loaded.set(g,d),d)){for(const{ids:S,callback:j}of this.requestors)this._notify(S,g,j);this.requestors=[]}}hasImage(d,g){return!!this.getImage(d,g)}getImage(d,g){return this.images.get(g).get(d.toString())}addImage(d,g,S){if(this._validate(d,S)){this.images.get(g).set(d.toString(),S);const j=this.imageVersions.get(g),R=j.get(d.toString())||0;j.set(d.toString(),R+1)}}_validate(d,g){let S=!0;return this._validateStretch(g.stretchX,g.data&&g.data.width)||(this.fire(new a.B(new Error(`Image "${d.name}" has invalid "stretchX" value`))),S=!1),this._validateStretch(g.stretchY,g.data&&g.data.height)||(this.fire(new a.B(new Error(`Image "${d.name}" has invalid "stretchY" value`))),S=!1),this._validateContent(g.content,g)||(this.fire(new a.B(new Error(`Image "${d.name}" has invalid "content" value`))),S=!1),S}_validateStretch(d,g){if(!d)return!0;let S=0;for(const j of d){if(j[0]a.I.from(g))}getImageVersions(d){const g=this.imageVersions.get(d);if(g)return g}getImages(d,g,S){const j=[],R=[],L=this.imageProviders.get(g);for(const Z of d){if(!Z.iconsetId){j.push(Z);continue}const ne=L.get(Z.iconsetId);ne&&(this.getImage(Z,g)?R.push(Z):ne.addPendingRequest(Z))}if(j.length===0)return void this._notify(R,g,S);let F=!0;const z=!!this.loaded.get(g),W=this.images.get(g);if(!z)for(const Z of j)W.has(Z.toString())||(F=!1);z||F?this._notify(j,g,S):this.requestors.push({ids:j,scope:g,callback:S})}rasterizeImages(d,g){const S=new Map,{tasks:j,scope:R}=d;for(const[L,F]of j.entries()){const z=this.getImage(F.id,R);z&&S.set(L,{image:z,imageVariant:F})}this._rasterizeImages(R,S,g)}_rasterizeImages(d,g,S){if(a.y())this.imageRasterizerDispatcher.getActor().send("rasterizeImagesWorker",{tasks:g,scope:d},S);else{const j=new Map;for(const[R,{image:L,imageVariant:F}]of g.entries())j.set(R,this.imageRasterizer.rasterize(F,L,d,0));S(void 0,j)}}getUpdatedImages(d){return this.updatedImages.get(d)||new Set}_notify(d,g,S){const j=this.images.get(g),R=new Map;for(const L of d){if(!j.get(L.toString())){if(L.iconsetId)continue;this.fire(new a.C("styleimagemissing",{id:L.name}))}const F=j.get(L.toString());if(!F){a.w(`Image "${L.name}" could not be loaded. Please make sure you have added the image with map.addImage() or a "sprite" property in your style. You can provide missing images by listening for the "styleimagemissing" map event.`);continue}const z={data:F.usvg?null:F.data.clone(),pixelRatio:F.pixelRatio,sdf:F.sdf,usvg:F.usvg,stretchX:F.stretchX,stretchY:F.stretchY,content:F.content,hasRenderCallback:!!(F.userImage&&F.userImage.render)};F.usvg&&Object.assign(z,{width:F.icon.usvg_tree.width,height:F.icon.usvg_tree.height}),R.set(a.I.toString(L),z)}S(null,{images:R,versions:this.getImageVersions(g)})}getPixelSize(d){const{width:g,height:S}=this.atlasImage.get(d);return{width:g,height:S}}getPattern(d,g,S){const j=d.toString(),R=this.patterns.get(g),L=R.get(j),F=this.getImage(d,g);if(!F)return null;if(L){if(L.position.version===F.version)return L.position;L.position.version=F.version}else{if(F.usvg&&!F.data){const z=this.getPatternInFlightId(j,g);if(this.patternsInFlight.has(z))return null;this.patternsInFlight.add(z);const W=new a.D(d).scaleSelf(a.o.devicePixelRatio),Z=new Map([[W.toString(),{image:F,imageVariant:W}]]);return this._rasterizeImages(g,Z,(ne,re)=>this.storePatternImage(W,g,F,S,re)),null}this.storePattern(d,g,F)}return this._updatePatternAtlas(g,S),R.get(j).position}getPatternInFlightId(d,g){return a.F(d,g)}hasPatternsInFlight(){return this.patternsInFlight.size!==0}storePatternImage(d,g,S,j,R){const L=d.toString(),F=R?R.get(L):void 0;F&&(S.data=F,this.storePattern(d.id,g,S),this._updatePatternAtlas(g,j),this.patternsInFlight.delete(this.getPatternInFlightId(d.id.toString(),g)))}storePattern(d,g,S){const j={w:S.data.width+2*a.G,h:S.data.height+2*a.G,x:0,y:0},R=new a.H(j,S,a.G);this.patterns.get(g).set(d.toString(),{bin:j,position:R})}destroyAtlasTextures(){for(const d of this.atlasTexture.values())d&&d.destroy();this.atlasTexture.clear()}bind(d,g){const S=d.gl;let j=this.atlasTexture.get(g);j?this.dirty&&(j.update(this.atlasImage.get(g)),this.dirty=!1):(j=new a.T(d,this.atlasImage.get(g),S.RGBA8),this.atlasTexture.set(g,j)),j.bind(S.LINEAR,S.CLAMP_TO_EDGE)}_updatePatternAtlas(d,g){const S=this.patterns.get(d),j=Array.from(S.values()).map(({bin:W})=>W),{w:R,h:L}=a.J(j),F=this.atlasImage.get(d);F.resize({width:R||1,height:L||1});const z=this.images.get(d);for(const[W,{bin:Z,position:ne}]of S.entries()){let re=ne.padding;const ie=Z.x+re,ce=Z.y+re,le=z.get(W).data,ve=le.width,_e=le.height;re=re>1?re-1:re,a.q.copy(le,F,{x:0,y:0},{x:ie,y:ce},{width:ve,height:_e},g),a.q.copy(le,F,{x:0,y:_e-re},{x:ie,y:ce-re},{width:ve,height:re},g),a.q.copy(le,F,{x:0,y:0},{x:ie,y:ce+_e},{width:ve,height:re},g),a.q.copy(le,F,{x:ve-re,y:0},{x:ie-re,y:ce},{width:re,height:_e},g),a.q.copy(le,F,{x:0,y:0},{x:ie+ve,y:ce},{width:re,height:_e},g),a.q.copy(le,F,{x:ve-re,y:_e-re},{x:ie-re,y:ce-re},{width:re,height:re},g),a.q.copy(le,F,{x:0,y:_e-re},{x:ie+ve,y:ce-re},{width:re,height:re},g),a.q.copy(le,F,{x:0,y:0},{x:ie+ve,y:ce+_e},{width:re,height:re},g),a.q.copy(le,F,{x:ve-re,y:0},{x:ie-re,y:ce+_e},{width:re,height:re},g)}this.dirty=!0}beginFrame(){for(const d of this.images.keys())this.callbackDispatchedThisFrame.set(d,new Set)}dispatchRenderCallbacks(d,g){const S=this.images.get(g);for(const j of d){if(this.callbackDispatchedThisFrame.get(g).has(j.toString()))continue;this.callbackDispatchedThisFrame.get(g).add(j.toString());const R=S.get(j.toString());tt(R)&&this.updateImage(j,g,R)}}destroy(){this.imageRasterizerDispatcher&&this.imageRasterizerDispatcher.remove()}}function Fn(v){const d=v.value,g=v.valueSpec,S=v.style,j=v.styleSpec,R=v.key,L=v.arrayElementValidator||bs;if(!Array.isArray(d))return[new a.V(R,d,`array expected, ${a.M(d)} found`)];if(g.length&&d.length!==g.length)return[new a.V(R,d,`array length ${g.length} expected, length ${d.length} found`)];if(g["min-length"]&&d.lengthj)return[new a.V(d,g,`${g} is greater than the maximum value ${j}`)]}return[]}function sa(v){const d=v.key,g=v.value;if(!a.K(g))return[new a.V(d,g,`object expected, ${a.M(g)} found`)];const S=v.valueSpec,j=a.L(g.type);let R,L,F,z={};const W=j!=="categorical"&&g.property===void 0,Z=!W,ne=function(le){const ve=le.stops;return Array.isArray(ve)&&Array.isArray(ve[0])&&a.K(ve[0][0])}(g),re=gi({key:v.key,value:v.value,valueSpec:v.styleSpec.function,style:v.style,styleSpec:v.styleSpec,objectElementValidators:{stops:function(le){if(j==="identity")return[new a.V(le.key,le.value,'identity function may not have a "stops" property')];let ve=[];const _e=le.value;return ve=ve.concat(Fn({key:le.key,value:_e,valueSpec:le.valueSpec,style:le.style,styleSpec:le.styleSpec,arrayElementValidator:ie})),Array.isArray(_e)&&_e.length===0&&ve.push(new a.V(le.key,_e,"array must have at least one stop")),ve},default:function(le){return bs({key:le.key,value:le.value,valueSpec:S,style:le.style,styleSpec:le.styleSpec})}}});return j==="identity"&&W&&re.push(new a.V(v.key,v.value,'missing required property "property"')),j==="identity"||g.stops||re.push(new a.V(v.key,v.value,'missing required property "stops"')),j==="exponential"&&S.expression&&!a.O(S)&&re.push(new a.V(v.key,v.value,"exponential functions not supported")),v.styleSpec.$version>=8&&(Z&&!a.Q(S)?re.push(new a.V(v.key,v.value,"property functions not supported")):W&&!a.S(S)&&re.push(new a.V(v.key,v.value,"zoom functions not supported"))),j!=="categorical"&&!ne||g.property!==void 0||re.push(new a.V(v.key,v.value,'"property" property is required')),re;function ie(le){let ve=[];const _e=le.value,Re=le.key;if(!Array.isArray(_e))return[new a.V(Re,_e,`array expected, ${a.M(_e)} found`)];if(_e.length!==2)return[new a.V(Re,_e,`array length 2 expected, length ${_e.length} found`)];if(ne){if(!a.K(_e[0]))return[new a.V(Re,_e,`object expected, ${a.M(_e[0])} found`)];const Me=_e[0];if(Me.zoom===void 0)return[new a.V(Re,_e,"object stop key must have zoom")];if(Me.value===void 0)return[new a.V(Re,_e,"object stop key must have value")];const Te=a.L(Me.zoom);if(typeof Te!="number")return[new a.V(Re,Me.zoom,"stop zoom values must be numbers")];if(F&&F>Te)return[new a.V(Re,Me.zoom,"stop zoom values must appear in ascending order")];Te!==F&&(F=Te,L=void 0,z={}),ve=ve.concat(gi({key:`${Re}[0]`,value:_e[0],valueSpec:{zoom:{}},style:le.style,styleSpec:le.styleSpec,objectElementValidators:{zoom:Rs,value:ce}}))}else ve=ve.concat(ce({key:`${Re}[0]`,value:_e[0],style:le.style,styleSpec:le.styleSpec},_e));return a.U(a.W(_e[1]))?ve.concat([new a.V(`${Re}[1]`,_e[1],"expressions are not allowed in function stops.")]):ve.concat(bs({key:`${Re}[1]`,value:_e[1],valueSpec:S,style:le.style,styleSpec:le.styleSpec}))}function ce(le,ve){const _e=a.M(le.value),Re=a.L(le.value),Me=le.value!==null?le.value:ve;if(R){if(_e!==R)return[new a.V(le.key,Me,`${_e} stop domain type must match previous stop domain type ${R}`)]}else R=_e;if(_e!=="number"&&_e!=="string"&&_e!=="boolean"&&typeof Re!="number"&&typeof Re!="string"&&typeof Re!="boolean")return[new a.V(le.key,Me,"stop domain value must be a number, string, or boolean")];if(_e!=="number"&&j!=="categorical"){let Te=`number expected, ${_e} found`;return a.Q(S)&&j===void 0&&(Te+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new a.V(le.key,Me,Te)]}return j!=="categorical"||_e!=="number"||typeof Re=="number"&&isFinite(Re)&&Math.floor(Re)===Re?j!=="categorical"&&_e==="number"&&typeof Re=="number"&&typeof L=="number"&&L!==void 0&&Renew a.V(`${v.key}${S.key}`,v.value,S.message));const g=d.value.expression||d.value._styleExpression.expression;if(v.expressionContext==="property"&&v.propertyKey==="text-font"&&!g.outputDefined())return[new a.V(v.key,v.value,`Invalid data expression for "${v.propertyKey}". Output values must be contained as literals within the expression.`)];if(v.expressionContext==="property"&&v.propertyType==="layout"&&!a.$(g))return[new a.V(v.key,v.value,'"feature-state" data expressions are not supported with layout properties.')];if(v.expressionContext==="filter")return $i(g,v);if(v.expressionContext==="appearance")return Cr(g,v);if(v.expressionContext&&v.expressionContext.indexOf("cluster")===0){if(!a.Z(g,["zoom","feature-state"]))return[new a.V(v.key,v.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if(v.expressionContext==="cluster-initial"&&!a._(g))return[new a.V(v.key,v.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function $i(v,d){const g=new Set(["zoom","feature-state","pitch","distance-from-center"]);if(d.valueSpec&&d.valueSpec.expression)for(const j of d.valueSpec.expression.parameters)g.delete(j);if(g.size===0)return[];const S=[];return v instanceof a.a0&&g.has(v.name)?[new a.V(d.key,d.value,`["${v.name}"] expression is not supported in a filter for a ${d.object.type} layer with id: ${d.object.id}`)]:(v.eachChild(j=>{S.push(...$i(j,d))}),S)}function Cr(v,d){const g=new Set;if(d.valueSpec&&d.valueSpec.expression)for(const j of d.valueSpec.expression.parameters)g.add(j);if(g.size===0)return[];const S=[];return v instanceof a.a0&&!g.has(v.name)?[new a.V(d.key,d.value,`["${v.name}"] is not an allowed parameter`)]:(v.eachChild(j=>{S.push(...Cr(j,d))}),S)}function Bn(v){const d=v.key,g=v.value,S=v.valueSpec,j=[];return Array.isArray(S.values)?S.values.indexOf(a.L(g))===-1&&j.push(new a.V(d,g,`expected one of [${S.values.join(", ")}], ${JSON.stringify(g)} found`)):Object.keys(S.values).indexOf(a.L(g))===-1&&j.push(new a.V(d,g,`expected one of [${Object.keys(S.values).join(", ")}], ${JSON.stringify(g)} found`)),j}function wi(v){return a.a4(a.W(v.value))?gs(Object.assign({},v,{expressionContext:"filter",valueSpec:v.styleSpec[`filter_${v.layerType||"fill"}`]})):ii(v)}function ii(v){const d=v.value,g=v.key;if(!Array.isArray(d))return[new a.V(g,d,`array expected, ${a.M(d)} found`)];if(d.length<1)return[new a.V(g,d,"filter array must have at least 1 element")];const S=v.styleSpec;let j=Bn({key:`${g}[0]`,value:d[0],valueSpec:S.filter_operator});const R=()=>{d.length>=2&&(a.a2(d[1])||j.push(new a.V(`${g}[1]`,d[1],`string expected, ${a.M(d[1])} found`)));for(let L=2;L":case">=":d.length>=2&&a.L(d[1])==="$type"&&j.push(new a.V(g,d,`"$type" cannot be use with operator "${d[0]}"`)),d.length!==3&&j.push(new a.V(g,d,`filter array for operator "${d[0]}" must have 3 elements`)),R();break;case"==":case"!=":d.length!==3&&j.push(new a.V(g,d,`filter array for operator "${d[0]}" must have 3 elements`)),R();break;case"in":case"!in":R();break;case"any":case"all":case"none":for(let L=1;L{W in g&&d.push(new a.V(S,g[W],`"${W}" is prohibited for ref layers`))}),j.layers.forEach(W=>{a.L(W.id)===F&&(z=W)}),z?z.ref?d.push(new a.V(S,g.ref,"ref cannot reference another ref layer")):L=a.L(z.type):typeof F=="string"&&d.push(new a.V(S,g.ref,`ref layer "${F}" not found`))}else if(L!=="background"&&L!=="sky"&&L!=="slot")if(g.source)if(a.a2(g.source)){const z=j.sources&&j.sources[g.source],W=z&&a.L(z.type);z?W==="vector"&&L==="raster"?d.push(new a.V(S,g.source,`layer "${g.id}" requires a raster source`)):W==="raster"&&L!=="raster"?d.push(new a.V(S,g.source,`layer "${g.id}" requires a vector source`)):W!=="vector"||g["source-layer"]?W==="raster-dem"&&L!=="hillshade"?d.push(new a.V(S,g.source,"raster-dem source can only be used with layer type 'hillshade'.")):W!=="raster-array"||["raster","raster-particle"].includes(L)?L==="line"&&g.paint&&(g.paint["line-gradient"]||g.paint["line-trim-offset"])&&W==="geojson"&&!z.lineMetrics?d.push(new a.V(S,g,`layer "${g.id}" specifies a line-gradient, which requires the GeoJSON source to have \`lineMetrics\` enabled.`)):L==="raster-particle"&&W!=="raster-array"&&d.push(new a.V(S,g.source,`layer "${g.id}" requires a 'raster-array' source.`)):d.push(new a.V(S,g.source,"raster-array source can only be used with layer type 'raster'.")):d.push(new a.V(S,g,`layer "${g.id}" must specify a "source-layer"`)):d.push(new a.V(S,g.source,`source "${g.source}" not found`))}else d.push(new a.V(`${S}.source`,g.source,'"source" must be a string'));else d.push(new a.V(S,g,'missing required property "source"'));return d=d.concat(gi({key:S,value:g,valueSpec:R.layer,style:v.style,styleSpec:v.styleSpec,objectElementValidators:{"*":()=>[],type:()=>bs({key:`${S}.type`,value:g.type,valueSpec:R.layer.type,style:v.style,styleSpec:v.styleSpec,object:g,objectKey:"type"}),filter:z=>wi(Object.assign({layerType:L},z)),layout:z=>gi({layer:g,key:z.key,value:z.value,valueSpec:{},style:z.style,styleSpec:z.styleSpec,objectElementValidators:{"*":W=>un(Object.assign({layerType:L},W))}}),paint:z=>gi({layer:g,key:z.key,value:z.value,valueSpec:{},style:z.style,styleSpec:z.styleSpec,objectElementValidators:{"*":W=>Xr(Object.assign({layerType:L,layer:g},W))}}),appearances(z){const W=Fn({key:z.key,value:z.value,valueSpec:z.valueSpec,style:z.style,styleSpec:z.styleSpec,arrayElementValidator:re=>function(ie){const{key:ce,layer:le,layerType:ve}=ie,_e=a.L(ie.value),Re=a.L(_e.name),Me=a.L(_e.condition),Te=gi({key:ce,value:_e,valueSpec:ie.styleSpec.appearance,style:ie.style,styleSpec:ie.styleSpec,objectElementValidators:{condition:Xe=>function($e){const Ke=[];return Ke.push(...gs({key:$e.key,value:$e.object.condition,valueSpec:a.a8.appearance.condition,expressionContext:"appearance"})),Ke}(Object.assign({layer:le,layerType:ve},Xe)),properties:Xe=>function($e){const Ke=[],{styleSpec:De,layer:Be,layerType:Ge}=$e,ot=De[`paint_${Ge}`],Je=De[`layout_${Ge}`],St=$e.object[$e.objectKey];for(const pt in St){const Ot=pt in ot?"paint":pt in Je?"layout":void 0;if(!Ot){Ke.push(new a.V($e.key,pt,`unknown property "${pt}" for layer type "${Ge}"`));continue}const Ut=Object.assign({},$e,{key:`${$e.key}.${pt}`,object:St,objectKey:pt,layer:Be,layerType:Ge,value:St[pt],valueSpec:Ot==="paint"?ot[pt]:Je[pt]});Ke.push(...ia(Ut,Ot))}return Ke}(Object.assign({layer:le,layerType:ve},Xe))}});return Re!=="hidden"&&Me===void 0&&Te.push(new a.V(ie.key,"name",'Appearance with name different than "hidden" must have a condition')),Te}(Object.assign({layerType:L,layer:g},re))}),Z=Array.isArray(z.value)?z.value:[],ne=new Set;return Z.forEach((re,ie)=>{const ce=a.L(re.name);if(ce)if(ne.has(ce)){const le=a.L(g.id);W.push(new a.V(z.key,ce,`Duplicated appearance name "${ce}" for layer "${le}"`))}else ne.add(ce)}),W}}})),d}function Qr({key:v,value:d}){return a.a2(d)?[]:[new a.V(v,d,`string expected, ${a.M(d)} found`)]}const ls={promoteId:function v({key:d,value:g}){if(a.a2(g))return Qr({key:d,value:g});if(Array.isArray(g)){const j=[],R=a.W(g),L=a.X(R);return L.result==="error"?(L.value.forEach(F=>{j.push(new a.V(`${d}${F.key}`,null,`${F.message}`))}),j):(a.Z(L.value.expression,["zoom","heatmap-density","line-progress","raster-value","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center","measure-light","raster-particle-speed"])||j.push(new a.V(`${d}`,null,"promoteId expression should be only feature dependent")),j)}if(!a.K(g))return[new a.V(d,g,`string, expression or object expected, "${a.M(g)}" found`)];const S=[];for(const j in g)S.push(...v({key:`${d}.${j}`,value:g[j]}));return S}};function nn(v){const d=v.value,g=v.key,S=v.styleSpec,j=v.style;if(!a.K(d))return[new a.V(g,d,`object expected, ${a.M(d)} found`)];if(!("type"in d))return[new a.V(g,d,'"type" is required')];const R=a.L(d.type);let L=[];switch(["vector","raster","raster-dem","raster-array"].includes(R)&&("url"in d||"tiles"in d||L.push(new a.a5(g,d,'Either "url" or "tiles" is required.'))),R){case"vector":case"raster":case"raster-dem":case"raster-array":return L=L.concat(gi({key:g,value:d,valueSpec:S[`source_${R.replace("-","_")}`],style:v.style,styleSpec:S,objectElementValidators:ls})),L;case"geojson":if(L=gi({key:g,value:d,valueSpec:S.source_geojson,style:j,styleSpec:S,objectElementValidators:ls}),"cluster"in d&&"clusterProperties"in d){if(!a.K(d.clusterProperties))return[new a.V(`${g}.clusterProperties`,d,`object expected, ${a.M(d)} found`)];for(const F in d.clusterProperties){const z=d.clusterProperties[F];if(!Array.isArray(z))return[new a.V(`${g}.clusterProperties.${F}`,z,"array expected")];const[W,Z]=z,ne=typeof W=="string"?[W,["accumulated"],["get",F]]:W;L.push(...gs({key:`${g}.${F}.map`,value:Z,expressionContext:"cluster-map"})),L.push(...gs({key:`${g}.${F}.reduce`,value:ne,expressionContext:"cluster-reduce"}))}}return L;case"video":return gi({key:g,value:d,valueSpec:S.source_video,style:j,styleSpec:S});case"image":return gi({key:g,value:d,valueSpec:S.source_image,style:j,styleSpec:S});case"canvas":return[new a.V(g,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return Bn({key:`${g}.type`,value:d.type,valueSpec:{values:Ln(S)}})}}function Ln(v){return v.source.reduce((d,g)=>{const S=v[g];return S.type.type==="enum"&&(d=d.concat(Object.keys(S.type.values||{}))),d},[])}function ti(v){const d=v.value,g=v.styleSpec,S=g.light,j=v.style;if(d===void 0)return[];if(!a.K(d))return[new a.V("light",d,`object expected, ${a.M(d)} found`)];let R=[];for(const L in d){const F=L.match(/^(.*)-transition$/),z=L.match(/^(.*)-use-theme$/);R=R.concat(z&&S[z[1]]?bs({key:L,value:d[L],valueSpec:{type:"string"},style:j,styleSpec:g}):F&&S[F[1]]&&S[F[1]].transition?bs({key:L,value:d[L],valueSpec:g.transition,style:j,styleSpec:g}):S[L]?bs({key:L,value:d[L],valueSpec:S[L],style:j,styleSpec:g}):[new a.V(L,d[L],`unknown property "${L}"`)])}return R}function Wo(v){const d=v.value;if(!d)return[];const g=v.key;if(!a.K(d))return[new a.V(g,d,`object expected, ${a.M(d)} found`)];let S=[];const j=v.styleSpec,R=j["light-3d"],L=v.style,F=v.style.lights;for(const Z of["type","id"])if(!(Z in d))return S=S.concat([new a.V(g,d,`missing property "${Z}"`)]),S;if(!a.a2(d.type))return S=S.concat([new a.V(`${g}.type`,d.type,"string expected")]),S;if(F)for(let Z=0;Z[],array:Fn,boolean:function(v){const d=v.value,g=v.key;return a.a1(d)?[]:[new a.V(g,d,`boolean expected, ${a.M(d)} found`)]},number:Rs,color:function({key:v,value:d}){return a.a2(d)?a.a3.parseCSSColor(d)===null?[new a.V(v,d,`color expected, "${d}" found`)]:[]:[new a.V(v,d,`color expected, ${a.M(d)} found`)]},enum:Bn,filter:wi,function:sa,layer:xn,object:gi,source:nn,model:a.a9,light:ti,"light-3d":Wo,terrain:Us,fog:Ft,string:Qr,formatted:function(v){return Qr(v).length===0?[]:gs(v)},resolvedImage:function(v){return Qr(v).length===0?[]:gs(v)},projection:function(v){const d=v.value,g=v.styleSpec,S=g.projection,j=v.style;if(a.K(d)){let R=[];for(const L in d)R=R.concat(bs({key:L,value:d[L],valueSpec:S[L],style:j,styleSpec:g}));return R}return a.a2(d)?[]:[new a.V("projection",d,`object or string expected, ${a.M(d)} found`)]},import:function(v){const d=v.key,{value:g,styleSpec:S}=v;if(!a.K(g))return[new a.V(d,g,"import must be an object")];const{data:j,...R}=g;Object.defineProperty(R,"__line__",{value:g.__line__,enumerable:!1});let L=gi(Object.assign({},v,{value:R,valueSpec:S.import}));return a.L(R.id)===""&&L.push(new a.V(`${v.key}.id`,R,"import id can't be an empty string")),j&&(L=L.concat(Ma(j,S,{key:`${v.key}.data`}))),L},iconset:function(v){const d=v.value,g=v.key,S=v.styleSpec,j=v.style;if(!a.K(d))return[new a.V(g,d,"object expected")];if(!d.type)return[new a.V(g,d,'"type" is required')];const R=a.L(d.type);let L=[];if(L=L.concat(gi({key:g,value:d,valueSpec:S[`iconset_${R}`],style:j,styleSpec:S})),function(F,z){return!(F!=="source"||!z.source)}(R,d)){const F=j.sources&&j.sources[d.source],z=F&&a.L(F.type);F?z!=="raster-array"&&L.push(new a.V(g,d.source,`iconset cannot be used with a source of type ${String(z)}, it only be used with a "raster-array" source type`)):L.push(new a.V(g,d.source,`source "${d.source}" not found`))}return L}};function bs(v,d=!1){const g=v.value,S=v.valueSpec,j=v.styleSpec;if(S.expression){if(a.a6(a.L(g)))return sa(v);if(a.U(a.W(g)))return gs(v)}if(S.type&&So[S.type]){const R=So[S.type](v);return d===!0&&R.length>0&&Array.isArray(v.value)?gs(v):R}return gi(Object.assign({},v,{valueSpec:S.type?j[S.type]:S}))}function gi(v){const d=v.key,g=v.value,S=v.valueSpec||{},j=v.objectElementValidators||{},R=v.style,L=v.styleSpec;if(!a.K(g))return[new a.V(d,g,`object expected, ${a.M(g)} found`)];let F=[];for(const z in g){const W=z.split(".")[0];let Z;j[W]?Z=j[W]:S[W]?Z=bs:j["*"]?Z=j["*"]:S["*"]&&(Z=bs),Z?F=F.concat(Z({key:(d&&`${d}.`)+z,value:g[z],valueSpec:S[W]||S["*"],style:R,styleSpec:L,object:g,objectKey:z},g)):F.push(new a.a5(d,g[z],`unknown property "${z}"`))}for(const z in S){if(j[z])continue;const W=S[z];W.required&&W.default===void 0&&g[z]===void 0&&F.push(new a.V(d,g,`missing required property "${z}"`))}return F}function Xn({key:v,value:d}){const g=Qr({key:v,value:d});if(g.length)return g;const S=d;return S.indexOf("{fontstack}")===-1&&g.push(new a.V(v,d,'"glyphs" url must include a "{fontstack}" token')),S.indexOf("{range}")===-1&&g.push(new a.V(v,d,'"glyphs" url must include a "{range}" token')),g}function Ma(v,d=a.a8,g={}){return gi({key:g.key||"",value:v,valueSpec:Object.assign(d.$root,{"*":{type:"*"}}),styleSpec:d,style:v,objectElementValidators:{glyphs:Xn}})}function yc(v,d=a.a8){return Mt(Ma(v,d))}const ul=v=>Mt(nn(v)),dt=v=>Mt(ti(v)),he=v=>Mt(Wo(v)),pe=v=>Mt(Us(v)),Fe=v=>Mt(Ft(v)),Ye=v=>Mt(function(d){const g=d.value,S=d.style,j=d.styleSpec,R=j.snow;if(g===void 0)return[];if(!a.K(g))return[new a.V("snow",g,`object expected, ${a.M(g)} found`)];let L=[];for(const F in g){const z=F.match(/^(.*)-transition$/);L=L.concat(z&&R[z[1]]&&R[z[1]].transition?bs({key:F,value:g[F],valueSpec:j.transition,style:S,styleSpec:j}):R[F]?bs({key:F,value:g[F],valueSpec:R[F],style:S,styleSpec:j}):[new a.a5(F,g[F],`unknown property "${F}"`)])}return L}(v)),et=v=>Mt(function(d){const g=d.value,S=d.style,j=d.styleSpec,R=j.rain;if(g===void 0)return[];if(!a.K(g))return[new a.V("rain",g,`object expected, ${a.M(g)} found`)];let L=[];for(const F in g){const z=F.match(/^(.*)-transition$/);L=L.concat(z&&R[z[1]]&&R[z[1]].transition?bs({key:F,value:g[F],valueSpec:j.transition,style:S,styleSpec:j}):R[F]?bs({key:F,value:g[F],valueSpec:R[F],style:S,styleSpec:j}):[new a.a5(F,g[F],`unknown property "${F}"`)])}return L}(v)),nt=v=>Mt(xn(v)),ht=v=>Mt(wi(v)),it=v=>Mt(Xr(v)),mt=v=>Mt(un(v)),Gt=v=>Mt(a.a9(v));function Mt(v){return v.slice().sort((d,g)=>d.line&&g.line?d.line-g.line:0)}function gr(v,d){let g=!1;if(d&&d.length)for(const S of d)S instanceof a.a5?a.w(S.message):(v.fire(new a.B(new Error(S.message))),g=!0);return g}const zr=a.a8.light;let Hr;class hr extends a.E{constructor(d,g="flat"){super(),this._transitionable=new a.aa(Hr||(Hr=new a.ab({anchor:new a.ac(zr.anchor),position:new a.ad(zr.position),color:new a.ac(zr.color),intensity:new a.ac(zr.intensity)}))),this.setLight(d,g),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(d,g,S={}){this._validate(dt,d,S)||(this._transitionable.setTransitionOrValue(d),this.id=g)}updateTransitions(d){this._transitioning=this._transitionable.transitioned(d,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(d){this.properties=this._transitioning.possiblyEvaluate(d)}_validate(d,g,S){return(!S||S.validate!==!1)&&gr(this,d.call(yc,Object.assign({value:g,style:{glyphs:!0,sprite:!0},styleSpec:a.a8})))}}const rt=a.a8.terrain;let qt=class extends a.E{constructor(v,d,g,S,j){super(),this.scope=g,this._transitionable=new a.aa(new a.ab({source:new a.ac(rt.source),exaggeration:new a.ac(rt.exaggeration)}),g,S),this._transitionable.setTransitionOrValue(v,S),this._transitioning=this._transitionable.untransitioned(),this.drapeRenderMode=d,this.worldview=j}get(){return this._transitionable.serialize()}set(v,d){this._transitionable.setTransitionOrValue(v,d)}updateTransitions(v){this._transitioning=this._transitionable.transitioned(v,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(v){this.properties=this._transitioning.possiblyEvaluate(v)}getExaggeration(v){return this._transitioning.possiblyEvaluate(new a.ae(v,{worldview:this.worldview})).get("exaggeration")}getAttenuationRange(){if(!this.isZoomDependent())return null;const v=this._transitionable._values.exaggeration;if(!v)return null;const d=v.value.expression;if(!d)return null;let g=-1,S=-1,j=1;for(const R of d.zoomStops)j=d.evaluate(new a.ae(R,{worldview:this.worldview})),j>.01?(g=R,S=-1):S=R;return j<.01&&g>0&&S>g?[g,S]:null}isZoomDependent(){const v=this._transitionable._values.exaggeration;return v!=null&&v.value!=null&&v.value.expression!=null&&v.value.expression instanceof a.af}};const xr=.05;function wn(v,d,g,S){const j=a.aj(45,65,g),[R,L]=Cn(v,S);let F=1-Math.min(1,Math.exp((d-R)/(L-R)*-6));return F*=F*F,F=Math.min(1,1.00747*F),F*j*v.alpha}function Cn(v,d){const g=.5/Math.tan(.5*d);return[v.range[0]+g,v.range[1]+g]}function Qn(v,d,g,S,j){const R=a.ah([],[d,g,S],j.mercatorFogMatrix);return wn(v,a.ai(R),j.pitch,j._fov)}function Ns(v,d,g,S,j,R,L){const F=[[g,S,0],[j,S,0],[j,R,0],[g,R,0]];let z=Number.MAX_VALUE,W=-Number.MAX_VALUE;for(const Z of F){const ne=a.ah([],Z,d),re=a.ai(ne);z=Math.min(z,re),W=Math.max(W,re)}return[wn(v,z,L.pitch,L._fov),wn(v,W,L.pitch,L._fov)]}const Jn=a.a8.fog;class ks extends a.E{constructor(d,g,S,j){super();const R=new a.ab({range:new a.ac(Jn.range),color:new a.ac(Jn.color),"color-use-theme":new a.ac({type:"string","property-type":"data-constant",default:"default"}),"high-color":new a.ac(Jn["high-color"]),"high-color-use-theme":new a.ac({type:"string","property-type":"data-constant",default:"default"}),"space-color":new a.ac(Jn["space-color"]),"space-color-use-theme":new a.ac({type:"string","property-type":"data-constant",default:"default"}),"horizon-blend":new a.ac(Jn["horizon-blend"]),"star-intensity":new a.ac(Jn["star-intensity"]),"vertical-range":new a.ac(Jn["vertical-range"])});this._transitionable=new a.aa(R,S,new Map(j)),this.set(d,j),this._transitioning=this._transitionable.untransitioned(),this._transform=g,this.properties=new a.ak(R),this.scope=S}get state(){const d=this._transform,g=d.projection.name==="globe",S=a.al(d.zoom),j=this.properties.get("range"),R=[.5,3];return{range:g?[a.am(R[0],j[0],S),a.am(R[1],j[1],S)]:j,horizonBlend:this.properties.get("horizon-blend"),alpha:this.properties.get("color").a}}get(){return this._transitionable.serialize()}set(d,g,S={}){if(this._validate(Fe,d,S))return;const j=Object.assign({},d);for(const R of Object.keys(Jn))j[R]===void 0&&(j[R]=Jn[R].default);this._options=j,this._transitionable.setTransitionOrValue(this._options,g)}getOpacity(d){if(!this._transform.projection.supportsFog)return 0;const g=this.properties&&this.properties.get("color")||1;return(this._transform.projection.name==="globe"?1:a.aj(45,65,d))*g.a}getOpacityAtLatLng(d,g){return this._transform.projection.supportsFog?function(S,j,R){const L=a.ag.fromLngLat(j),F=R.elevation?R.elevation.getAtPointOrZero(L):0;return Qn(S,L.x,L.y,F,R)}(this.state,d,g):0}getOpacityForTile(d){if(!this._transform.projection.supportsFog)return[1,1];const g=this._transform.calculateFogTileMatrix(d.toUnwrapped());return Ns(this.state,g,0,0,a.an,a.an,this._transform)}getOpacityForBounds(d,g,S,j,R){return this._transform.projection.supportsFog?Ns(this.state,d,g,S,j,R,this._transform):[1,1]}getFovAdjustedRange(d){return this._transform.projection.supportsFog?Cn(this.state,d):[0,1]}isVisibleOnFrustum(d){if(!this._transform.projection.supportsFog)return!1;const g=[4,5,6,7];for(const S of g){const j=d.points[S];let R;if(j[2]>=0)R=j;else{const L=d.points[S-4];R=a.ao(L,j,L[2]/(L[2]-j[2]))}if(Qn(this.state,R[0],R[1],0,this._transform)>=xr)return!0}return!1}updateConfig(d){this._transitionable.setTransitionOrValue(this._options,new Map(d))}updateTransitions(d){this._transitioning=this._transitionable.transitioned(d,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(d){this.properties=this._transitioning.possiblyEvaluate(d)}_validate(d,g,S){return(!S||S.validate!==!1)&&gr(this,d.call(yc,Object.assign({value:g,style:{glyphs:!0,sprite:!0},styleSpec:a.a8})))}}let zi,zn,ri,di=class extends a.E{constructor(v,d,g,S){super();const j=zi||(zi=new a.ab({density:new a.ac(a.a8.snow.density),intensity:new a.ac(a.a8.snow.intensity),color:new a.ac(a.a8.snow.color),opacity:new a.ac(a.a8.snow.opacity),vignette:new a.ac(a.a8.snow.vignette),"vignette-color":new a.ac(a.a8.snow["vignette-color"]),"center-thinning":new a.ac(a.a8.snow["center-thinning"]),direction:new a.ac(a.a8.snow.direction),"flake-size":new a.ac(a.a8.snow["flake-size"])}));this._transitionable=new a.aa(j,g,new Map(S)),this.set(v,S),this._transitioning=this._transitionable.untransitioned(),this.properties=new a.ak(j),this.scope=g}get state(){const v=this.properties.get("opacity"),d=this.properties.get("color"),g=this.properties.get("direction"),S=a.ap(g[0]),j=-Math.max(a.ap(g[1]),.01),R=[Math.cos(S)*Math.cos(j),Math.sin(S)*Math.cos(j),Math.sin(j)],L=this.properties.get("vignette"),F=this.properties.get("vignette-color");return F.a=L,{density:this.properties.get("density"),intensity:this.properties.get("intensity"),color:new a.aq(d.r,d.g,d.b,d.a*v),direction:R,centerThinning:this.properties.get("center-thinning"),flakeSize:this.properties.get("flake-size"),vignetteColor:F}}get(){return this._transitionable.serialize()}set(v,d,g={}){if(this._validate(Ye,v,g))return;const S=Object.assign({},v),j=a.a8.snow;for(const R of Object.keys(j))S[R]===void 0&&(S[R]=j[R].default);this._options=S,this._transitionable.setTransitionOrValue(this._options,d)}updateConfig(v){this._transitionable.setTransitionOrValue(this._options,new Map(v))}updateTransitions(v){this._transitioning=this._transitionable.transitioned(v,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(v){this.properties=this._transitioning.possiblyEvaluate(v)}_validate(v,d,g){return(!g||g.validate!==!1)&&gr(this,v.call(yc,Object.assign({value:d,style:{glyphs:!0,sprite:!0},styleSpec:a.a8})))}},Vn=class extends a.E{constructor(v,d,g,S){super();const j=zn||(zn=new a.ab({density:new a.ac(a.a8.rain.density),intensity:new a.ac(a.a8.rain.intensity),color:new a.ac(a.a8.rain.color),opacity:new a.ac(a.a8.rain.opacity),vignette:new a.ac(a.a8.rain.vignette),"vignette-color":new a.ac(a.a8.rain["vignette-color"]),"center-thinning":new a.ac(a.a8.rain["center-thinning"]),direction:new a.ac(a.a8.rain.direction),"droplet-size":new a.ac(a.a8.rain["droplet-size"]),"distortion-strength":new a.ac(a.a8.rain["distortion-strength"])}));this._transitionable=new a.aa(j,g,new Map(S)),this.set(v,S),this._transitioning=this._transitionable.untransitioned(),this.properties=new a.ak(j),this.scope=g}get state(){const v=this.properties.get("opacity"),d=this.properties.get("color"),g=this.properties.get("direction"),S=a.ap(g[0]),j=-Math.max(a.ap(g[1]),.01),R=[Math.cos(S)*Math.cos(j),Math.sin(S)*Math.cos(j),Math.sin(j)],L=this.properties.get("vignette-color");return L.a=this.properties.get("vignette"),{density:this.properties.get("density"),intensity:this.properties.get("intensity"),color:new a.aq(d.r,d.g,d.b,d.a*v),direction:R,centerThinning:this.properties.get("center-thinning"),dropletSize:this.properties.get("droplet-size"),distortionStrength:this.properties.get("distortion-strength"),vignetteColor:L}}get(){return this._transitionable.serialize()}set(v,d,g={}){if(this._validate(et,v,g))return;const S=Object.assign({},v),j=a.a8.rain;for(const R of Object.keys(j))S[R]===void 0&&(S[R]=j[R].default);this._options=S,this._transitionable.setTransitionOrValue(this._options,d)}updateConfig(v){this._transitionable.setTransitionOrValue(this._options,new Map(v))}updateTransitions(v){this._transitioning=this._transitionable.transitioned(v,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(v){this.properties=this._transitioning.possiblyEvaluate(v)}_validate(v,d,g){return(!g||g.validate!==!1)&&gr(this,v.call(yc,Object.assign({value:d,style:{glyphs:!0,sprite:!0},styleSpec:a.a8})))}};class Da extends a.E{constructor(d,g,S,j){super(),this.scope=S,this._options=d,this.properties=new a.ak(g),this._transitionable=new a.aa(g,S,new Map(j)),this._transitionable.setTransitionOrValue(d.properties),this._transitioning=this._transitionable.untransitioned()}updateConfig(d){this._transitionable.setTransitionOrValue(this._options.properties,new Map(d))}updateTransitions(d){this._transitioning=this._transitionable.transitioned(d,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(d){this.properties=this._transitioning.possiblyEvaluate(d)}get(){return this._options.properties=this._transitionable.serialize(),this._options}set(d,g){this._options=d,this._transitionable.setTransitionOrValue(d.properties,g)}shadowsEnabled(){return!!this.properties&&this.properties.get("cast-shadows")===!0}}const Po=()=>ri||(ri=new a.ab({color:new a.ac(a.a8.properties_light_ambient.color),"color-use-theme":new a.ac({type:"string",default:"default","property-type":"data-constant"}),intensity:new a.ac(a.a8.properties_light_ambient.intensity)}));let To;const xc=()=>To||(To=new a.ab({direction:new a.ar(a.a8.properties_light_directional.direction),color:new a.ac(a.a8.properties_light_directional.color),"color-use-theme":new a.ac({type:"string",default:"default","property-type":"data-constant"}),intensity:new a.ac(a.a8.properties_light_directional.intensity),"cast-shadows":new a.ac(a.a8.properties_light_directional["cast-shadows"]),"shadow-quality":new a.ac(a.a8.properties_light_directional["shadow-quality"]),"shadow-intensity":new a.ac(a.a8.properties_light_directional["shadow-intensity"]),"shadow-draw-before-layer":new a.ac(a.a8.properties_light_directional["shadow-draw-before-layer"])}));class _c{constructor(d,g,S){this.screenBounds=d,this.cameraPoint=S.getCameraPoint(),this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=g,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this._bufferedScreenMercator(0,S)}static createFromScreenPoints(d,g){let S,j;if(d instanceof a.P||typeof d[0]=="number"){const R=a.P.convert(d);S=[R],j=g.isPointAboveHorizon(R)}else{const R=a.P.convert(d[0]),L=a.P.convert(d[1]),F=R.add(L)._div(2);S=[R,L],j=a.as(R,L).every(z=>g.isPointAboveHorizon(z))&&g.isPointAboveHorizon(F)}return new _c(S,j,g)}isPointQuery(){return this.screenBounds.length===1}bufferedScreenGeometry(d){return a.as(this.screenBounds[0],this.screenBounds.length===1?this.screenBounds[0]:this.screenBounds[1],d)}bufferedCameraGeometry(d){const g=this.screenBounds[0],S=this.screenBounds.length===1?this.screenBounds[0].add(new a.P(1,1)):this.screenBounds[1],j=a.as(g,S,0,!1);return this.cameraPoint.y>S.y&&(this.cameraPoint.x>g.x&&this.cameraPoint.x=S.x?j[2]=this.cameraPoint:this.cameraPoint.x<=g.x&&(j[3]=this.cameraPoint)),a.at(j,d)}bufferedCameraGeometryGlobe(d){const g=this.screenBounds[0],S=this.screenBounds.length===1?this.screenBounds[0].add(new a.P(1,1)):this.screenBounds[1],j=a.as(g,S,d),R=this.cameraPoint.clone(),L=+(R.x>g.x)+ +(R.x>S.x);switch(3*(+(R.y>g.y)+ +(R.y>S.y))+L){case 0:j[0]=R,j[4]=R.clone();break;case 1:j.splice(1,0,R);break;case 2:j[1]=R;break;case 3:j.splice(4,0,R);break;case 5:j.splice(2,0,R);break;case 6:j[3]=R;break;case 7:j.splice(3,0,R);break;case 8:j[2]=R}return j}containsTile(d,g,S,j=0){const R=Math.max(d.queryPadding,d.evaluateQueryRenderedFeaturePadding())/g._pixelsPerMercatorPixel+1,L=S?this._bufferedCameraMercator(R,g):this._bufferedScreenMercator(R,g);let F=d.tileID.wrap+(L.unwrapped?j:0);const z=L.polygon.map(ve=>a.au(d.tileTransform,ve,F));if(!a.av(z,0,0,a.an,a.an))return;F=d.tileID.wrap+(this.screenGeometryMercator.unwrapped?j:0);const W=this.screenGeometryMercator.polygon.map(ve=>a.aw(d.tileTransform,ve,F)),Z=W.map(ve=>new a.P(ve[0],ve[1])),ne=g.getFreeCameraOptions().position||new a.ag(0,0,0),re=a.aw(d.tileTransform,ne,F),ie=W.map(ve=>{const _e=a.ax(ve,ve,re);return a.ay(_e,_e),new a.az(re,_e)}),ce=a.aA(d,1,g.zoom)*g._pixelsPerMercatorPixel;return{queryGeometry:this,tilespaceGeometry:Z,tilespaceRays:ie,bufferedTilespaceGeometry:z,bufferedTilespaceBounds:(le=a.aB(z),le.min.x=a.aC(le.min.x,0,a.an),le.min.y=a.aC(le.min.y,0,a.an),le.max.x=a.aC(le.max.x,0,a.an),le.max.y=a.aC(le.max.y,0,a.an),le),tile:d,tileID:d.tileID,pixelToTileUnitsFactor:ce};var le}_bufferedScreenMercator(d,g){const S=vc(d);if(this._screenRaycastCache[S])return this._screenRaycastCache[S];{let j;return j=g.projection.name==="globe"?this._projectAndResample(this.bufferedScreenGeometry(d),g):{polygon:this.bufferedScreenGeometry(d).map(R=>g.pointCoordinate3D(R)),unwrapped:!0},this._screenRaycastCache[S]=j,j}}_bufferedCameraMercator(d,g){const S=vc(d);if(this._cameraRaycastCache[S])return this._cameraRaycastCache[S];{let j;return j=g.projection.name==="globe"?this._projectAndResample(this.bufferedCameraGeometryGlobe(d),g):{polygon:this.bufferedCameraGeometry(d).map(R=>g.pointCoordinate3D(R)),unwrapped:!0},this._cameraRaycastCache[S]=j,j}}_projectAndResample(d,g){const S=function(R,L){const F=a.aD([],L.pixelMatrix,L.globeMatrix),z=[0,-a.aF,0,1],W=[0,a.aF,0,1],Z=[0,0,0,1];a.aE(z,z,F),a.aE(W,W,F),a.aE(Z,Z,F);const ne=new a.P(z[0]/z[3],z[1]/z[3]),re=new a.P(W[0]/W[3],W[1]/W[3]),ie=a.aG(R,ne)&&z[3]1?qd(R.slice(0,ve),L):[],Me=venew a.P(Pl(Ke.x),Ke.y)),Me=Me.map(Ke=>new a.P(Pl(Ke.x),Ke.y));const Te=[...Re];Te.length===0&&Te.push(Me[Me.length-1]);const Xe=a.am(Te[Te.length-1].y,(Me.length===0?Re[0]:Me[0]).y,_e);let $e;return $e=ie?[new a.P(0,Xe),new a.P(0,0),new a.P(1,0),new a.P(1,Xe)]:[new a.P(1,Xe),new a.P(1,1),new a.P(0,1),new a.P(0,Xe)],Te.push(...$e),Me.length===0?Te.push(Re[0]):Te.push(...Me),{polygon:Te.map(Ke=>new a.ag(Ke.x,Ke.y)),unwrapped:!1}}(d,g);if(S)return S;const j=function(R,L){let F=!1,z=-1/0,W=0;for(let ne=0;nez&&(z=R[ne].x,W=ne);for(let ne=0;ne.5&&(ie.x{ne.x-=1}),{polygon:R,unwrapped:F}}(qd(d,g).map(R=>new a.P(Pl(R.x),R.y)),g);return{polygon:j.polygon.map(R=>new a.ag(R.x,R.y)),unwrapped:j.unwrapped}}}function qd(v,d){return a.aI(v,g=>{const S=d.pointCoordinate3D(g);g.x=S.x,g.y=S.y},1/256)}function Pl(v){return v<0?1+v%1:v%1}function vc(v){return 100*v|0}function Gd(v,d,g){try{d=function(j){if(!j.variants)return j;if(!Array.isArray(j.variants))throw new Error("variants must be an array");for(const R of j.variants){if(R==null||typeof R!="object"||R.constructor!==Object)throw new Error("variant must be an object");if(!Array.isArray(R.capabilities))throw new Error("capabilities must be an array");if(R.capabilities.length===1&&R.capabilities[0]==="meshopt")return Object.assign(j,R)}return j}(d)}catch(j){return new Error("Failed to process TileJSON variants",{cause:j})}const S=a.aJ(Object.assign({},d,v),["tilejson","tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","extra_bounds","scheme","tileSize","encoding","vector_layers","raster_layers","worldview_options","worldview_default","worldview"]);return v.url&&d.tiles&&v.tiles&&(S.tiles=d.tiles),S.tiles=g.canonicalizeTileset(S,v.url),S}function Vc(v,d,g,S,j){const R=function(F,z){if(F)return j(F);if(z){v.url&&z.tiles&&v.tiles&&delete v.tiles;const W=Gd(v,z,d);if(W instanceof Error)return j(W);j(null,W)}},L=function(F,z,W){if(!F)return null;if(!z&&!W)return F;W=W||F.worldview_default;const Z=Object.values(F.language||{});if(Z.length===0)return null;const ne=Object.values(F.worldview||{});if(ne.length===0)return null;const re=Z.every(ce=>ce===z),ie=ne.every(ce=>ce===W);return re&&ie?F:z in(F.language_options||{})||W in(F.worldview_options||{})?null:F.language_options&&F.worldview_options?F:null}(v.data,g,S);return L?a.o.frame(()=>R(null,L)):v.url?a.m(d.transformRequest(d.normalizeSourceURL(v.url,null,g,S),a.R.Source),R):a.o.frame(()=>{const{data:F,...z}=v;R(null,z)})}function Hd(v,d){const g=Math.pow(2,d.z),S=Math.floor(a.aH(v.getWest())*g),j=Math.floor(a.aL(v.getNorth())*g),R=Math.ceil(a.aH(v.getEast())*g),L=Math.ceil(a.aL(v.getSouth())*g);return d.x>=S&&d.x=j&&d.ythis.maxzoom||d.z{this._tileJSONRequest=null,this._loaded=!0,L?(g&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${g}`),S&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${S}`),this.fire(new a.B(L))):F&&(this._setTileJSON(F),Ze(F.tiles,this.map._requestManager._customAccessToken),this.fire(new a.C("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new a.C("data",{dataType:"source",sourceDataType:"content"}))),d&&d(L)};this.provider=this._options.provider;const R=function(L){if("provider"in L&&!L.provider)return null;let F=L.provider;if(!F&&"url"in L&&L.url&&(F=a.aM(L.url)),!F)return null;const z=a.g.TILE_PROVIDER_URLS[F];if(!z)return null;let W;try{W=new URL(z,a.g.API_URL).href}catch{return a.w(`TileProvider "${F}" has an invalid URL: "${z}"`),null}return{name:F,url:W}}(this._options);if(this.provider&&!R)return this._loaded=!0,this.fire(new a.B(new Error(`TileProvider "${this.provider}" is not registered`))),void(d&&d());this._tileJSONRequest=R?this._loadWithProvider(R,j):Vc(this._options,this.map._requestManager,g,S,j)}_loadWithProvider(d,g){this.provider=d.name;const S=new AbortController,j=this._options.url&&!this._options.tiles?this.map._requestManager.transformRequest(this._options.url,a.R.Source):void 0,R=j?Object.assign({},this._options,{url:j.url}):this._options;return this.dispatcher.broadcast("loadTileProvider",{name:d.name,url:d.url,source:this.id,scope:this.scope,type:this.type,options:R,request:j},(L,F)=>{if(S.signal.aborted)return;if(L)return void g(L);const z=F?F.find(W=>W!=null):null;if(z){const W=Gd(this._options,z,this.map._requestManager);W instanceof Error?g(W):g(null,W)}else g(null,{tiles:this._options.tiles})}),{cancel:()=>{S.abort()}}}_setTileJSON(d){if(Object.assign(this,d),this.hasWorldviews=!!d.worldview_options,d.worldview_default&&(this.worldviewDefault=d.worldview_default),d.vector_layers){this.vectorLayers=d.vector_layers,this.vectorLayerIds=[],this.localizableLayerIds=new Set;for(const g of d.vector_layers)this.vectorLayerIds.push(g.id),d.worldview&&d.worldview[g.source]&&this.localizableLayerIds.add(g.id)}this.tileBounds=Au.fromTileJSON(d)}loaded(){return this._loaded}hasTile(d){return!this.tileBounds||this.tileBounds.contains(d.canonical)}onAdd(d){this.map=d,this.load()}reload(){this.cancelTileJSONRequest();const d=a.F(this.id,this.scope);this.load(()=>this.map.style.clearSource(d))}setTiles(d){return this._options.tiles=d,this.reload(),this}setUrl(d){return this.url=d,this._options.url=d,this.reload(),this}onRemove(d){this.cancelTileJSONRequest()}serialize(){return Object.assign({},this._options)}loadTile(d,g){const S=d.tileID.canonical.url(this.tiles,this.scheme),j=this.map._requestManager.normalizeTileURL(S),R=this.map._requestManager.transformRequest(j,a.R.Tile),L=this.map.style?this.map.style.getLut(this.scope):null,F=L?{image:L.image.clone()}:null,z={request:R,data:void 0,uid:d.uid,tileID:d.tileID,tileZoom:d.tileZoom,zoom:d.tileID.overscaledZ,maxZoom:this.maxzoom,lut:F,tileSize:this.tileSize*d.tileID.overscaleFactor(),type:this.type,source:this.id,scope:this.scope,pixelRatio:a.o.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,renderSourceType:d.renderSourceType,brightness:this.map.style&&this.map.style.getBrightness()||0,extraShadowCaster:d.isExtraShadowCaster,tessellationStep:this.map._tessellationStep,scaleFactor:this.map.getScaleFactor(),worldview:this.map.getWorldview()||this.worldviewDefault,indoor:this.map.getIndoorTileOptions(this.id,this.scope)};if(this.hasWorldviews&&a.e(S)&&(z.localizableLayerIds=this.localizableLayerIds),z.request.collectResourceTiming=this._collectResourceTiming,d.actor&&d.state!=="expired")d.state==="loading"?d.reloadCallback=g:d.request=d.actor.send("reloadTile",z,W.bind(this));else if(d.actor=this._tileWorkers[j]=this._tileWorkers[j]||this.dispatcher.getActor(),this.dispatcher.ready||this.provider)d.request=d.actor.send("loadTile",z,W.bind(this),void 0,!0);else{const Z=a.aO.call({deduped:this._deduped},z,(ne,re)=>{if(ne||!re)W.call(this,ne);else{const ie=a.aP(re.responseHeaders);z.data={rawData:re.rawData.slice(0),expires:ie.expires,cacheControl:ie.cacheControl},d.actor&&d.actor.send("loadTile",z,W.bind(this),void 0,!0)}},!0);d.request={cancel:Z}}function W(Z,ne){return delete d.request,d.aborted?g(null):Z?g(Z):(ne&&ne.resourceTiming&&(d.resourceTiming=ne.resourceTiming),this.map._refreshExpiredTiles&&ne&&d.setExpiryData(ne),d.loadVectorData(ne,this.map.painter),a.aQ(this.dispatcher),g(null,ne),void(d.reloadCallback&&(this.loadTile(d,d.reloadCallback),d.reloadCallback=null)))}}abortTile(d){d.request&&(d.request.cancel(),delete d.request),d.actor&&d.actor.send("abortTile",{uid:d.uid,type:this.type,source:this.id,scope:this.scope})}unloadTile(d,g){d.actor&&d.actor.send("removeTile",{uid:d.uid,type:this.type,source:this.id,scope:this.scope}),d.destroy()}hasTransition(){return!1}afterUpdate(){this._tileWorkers={}}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}class j0 extends a.E{constructor(d,g,S,j){super(),this.id=d,this.dispatcher=S,this.setEventedParent(j),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=Object.assign({type:"raster"},g),Object.assign(this,a.aJ(g,["url","scheme","tileSize"]))}load(d){this._loaded=!1,this.fire(new a.C("dataloading",{dataType:"source"}));const g=this.map.getWorldview();this._tileJSONRequest=Vc(this._options,this.map._requestManager,null,g,(S,j)=>{this._tileJSONRequest=null,this._loaded=!0,S?this.fire(new a.B(S)):j&&(Object.assign(this,j),j.raster_layers&&(this.rasterLayers=j.raster_layers,this.rasterLayerIds=this.rasterLayers.map(R=>R.id)),this.tileBounds=Au.fromTileJSON(j),Ze(j.tiles),this.fire(new a.C("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new a.C("data",{dataType:"source",sourceDataType:"content"}))),d&&d(S)})}loaded(){return this._loaded}onAdd(d){this.map=d,this.load()}reload(){this.cancelTileJSONRequest();const d=a.F(this.id,this.scope);this.load(()=>this.map.style.clearSource(d))}setTiles(d){return this._options.tiles=d,this.reload(),this}setUrl(d){return this.url=d,this._options.url=d,this.reload(),this}onRemove(d){this.cancelTileJSONRequest()}serialize(){return Object.assign({},this._options)}hasTile(d){return!this.tileBounds||this.tileBounds.contains(d.canonical)}loadTile(d,g){const S=a.o.devicePixelRatio>=2,j=this.map._requestManager.normalizeTileURL(d.tileID.canonical.url(this.tiles,this.scheme),S,this.tileSize);d.request=a.n(this.map._requestManager.transformRequest(j,a.R.Tile),(R,L,F)=>{if(delete d.request,d.aborted)return d.state="unloaded",g(null);if(R)return d.state="errored",g(R);if(!L)return g(null);const z=a.aP(F);this.map._refreshExpiredTiles&&d.setExpiryData(z),d.setTexture(L,this.map.painter),d.state="loaded",a.aQ(this.dispatcher),g(null)})}abortTile(d,g){d.request&&(d.request.cancel(),delete d.request),g&&g()}unloadTile(d,g){d.texture&&d.texture instanceof a.T?(d.destroy(!1),d.texture&&d.texture instanceof a.T&&this.map.painter.saveTileTexture(d.texture)):d.destroy(),g&&g()}hasTransition(){return!1}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}function NE([v,d],g,S,{scaled:j=!0}={}){const{tileSize:R,buffer:L}=S,{x:F,y:z,z:W}=g;if(!isFinite(F)||!isFinite(z)||!isFinite(W))throw new Error("Invalid MRT header");const Z=2**W,ne=Z*a.aH(v),re=Z*a.aL(d);return function([ie,ce],le,{scaled:ve=!0}={}){if(!le)throw new Error("bandView is undefined");const{data:_e,tileSize:Re,buffer:Me,offset:Te,scale:Xe,dimension:$e}=le;if(ie<-Me||ie>Re+Me||ce<-Me||ce>Re+Me)throw new Error(`Point (${ie}, ${ce}) out of bounds for tileSize=${Re}, buffer=${Me}`);const Ke=(ce+Me)*(Re+2*Me)+(ie+Me);if(new Uint32Array(_e.buffer)[Ke]===4294967295)return null;let De=[];De=ve?[]:new le.data.constructor($e);for(let Be=0;Be<$e;Be++)De[Be]=Math.round(1e12*(_e[$e*Ke+Be]*Xe+Te))/1e12;return De}([Math.min(Math.max(-L,Math.floor((ne-F)*R)),R-1+L),Math.min(Math.max(-L,Math.floor((re-z)*R)),R-1+L)],S,{scaled:j})}class fp extends j0{constructor(d,g,S,j){super(d,g,S,j),this.type="raster-array",this.maxzoom=22,this.partial=!0,this._loadTilePending={},this._loadTileLoaded={},this._options=Object.assign({type:"raster-array"},g)}triggerRepaint(d){const g=this.map.painter._terrain,S=this.map.style.getSourceCache(this.id);g&&g.enabled&&S&&g._clearRenderCacheForTile(S.id,d.tileID),this.map.triggerRepaint()}loadTile(d,g){const S=this.map._requestManager.normalizeTileURL(d.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize),j=this.map._requestManager.transformRequest(S,a.R.Tile),R={request:j,uid:d.uid,tileID:d.tileID,type:this.type,source:this.id,scope:this.scope,partial:this.partial};d.source=this.id,d.scope=this.scope,d.requestParams=j,d.actor||(d.actor=this.dispatcher.getActor());const L=(F,z,W)=>{if(delete d.request,d.aborted)return d.state="unloaded",g(null);if(F)return F.name==="AbortError"?void 0:(d.state="errored",g(F));if(this.map._refreshExpiredTiles&&z){const Z=a.aP(W);d.setExpiryData(Z)}if(this.partial&&d.state!=="expired")d.state="empty";else if(!this.partial){if(!z)return g(null);d.state="loaded",d._isHeaderLoaded=!0,d._mrt=z}g(null)};d.request=this.partial?d.fetchHeader(void 0,L.bind(this)):d.actor.send("loadTile",R,L.bind(this),void 0,!0)}abortTile(d){d.request&&(d.request.cancel(),delete d.request),d.actor&&d.actor.send("abortTile",{uid:d.uid,type:this.type,source:this.id,scope:this.scope})}unloadTile(d,g){const S=d.texturePerLayer;if(d.flushAllQueues(),S.size){d.destroy(!1);for(const j of S.values())this.map.painter.saveTileTexture(j)}else d.destroy()}prepareTile(d,g,S,j){d._isHeaderLoaded&&(d.state!=="empty"&&(d.state="reloading"),d.fetchBandForRender(g,S,j,(R,L)=>{R?(d.state="errored",this.fire(new a.B(R))):L&&(d._isHeaderLoaded=!0,d.setTexturePerLayer(S,L,this.map.painter),d.state="loaded"),this.triggerRepaint(d)}))}getInitialBand(d){if(!this.rasterLayers)return 0;const g=this.rasterLayers.find(({id:R})=>R===d),S=g&&g.fields,j=S&&S.bands&&S.bands;return j?j[0]:0}getTextureDescriptor(d,g,S){if(!d)return;const j=g.sourceLayer||this.rasterLayerIds&&this.rasterLayerIds[0];if(!j)return;let R=null;g instanceof a.aS?R=g.paint.get("raster-array-band"):g instanceof a.aT&&(R=g.paint.get("raster-particle-array-band"));const L=R||this.getInitialBand(j);if(L==null)return;if(!d.textureDescriptorPerLayer.get(g.id))return void this.prepareTile(d,j,g.id,L);if(d.updateNeeded(g.id,L)&&!S)return;const F=d.textureDescriptorPerLayer.get(g.id);return Object.assign({},F,{texture:d.texturePerLayer.get(g.id)})}getImages(d,g){const S=new Map;for(const j of d)for(const R of g){const[L,F]=R.split("/"),z=j.getLayer(L);if(!z||!z.hasBand(F)||!z.hasDataForBand(F))continue;const{bytes:W,tileSize:Z,buffer:ne}=z.getBandView(F),re=Z+2*ne,ie={data:new a.q({width:re,height:re},W),pixelRatio:2,sdf:!1,usvg:!1,version:0};S.set(R,ie)}return S}queryRasterArrayValueByBandId(d,g,S){const j=g._mrt;return new Promise(R=>{const L={},F=new Set;for(const[z,W]of Object.entries(j.layers)){if(S.layerName&&z!==S.layerName)continue;const Z={};L[z]=Z;for(const{bands:ne}of W.dataIndex)for(const re of ne)S.bands&&!S.bands.includes(re)||(F.add(a.F(z,re)),g.fetchBand(z,null,re,ie=>{a.o.frame(()=>{Z[re]=ie?null:NE([d.lng,d.lat],j,W.getBandView(re)),F.delete(a.F(z,re)),F.size===0&&R(L)})},!1))}F.size===0&&R(L)})}_loadTileForQuery(d,g){if(this._loadTileLoaded[d.uid])return void g(null,d._mrt);if(this._loadTilePending[d.uid])return void this._loadTilePending[d.uid].push(g);this._loadTilePending[d.uid]=[g];const S=this.map._requestManager.normalizeTileURL(d.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize),j=this.map._requestManager.transformRequest(S,a.R.Tile);d.actor.send("loadTile",{request:j,uid:d.uid,tileID:d.tileID,type:this.type,source:this.id,scope:this.scope,partial:!1},(R,L,F)=>{if(R)return this._loadTilePending[d.uid].forEach(z=>z(R,null)),void delete this._loadTilePending[d.uid];if(!L)return this._loadTilePending[d.uid].forEach(z=>z(null,null)),void delete this._loadTilePending[d.uid];if(this.map._refreshExpiredTiles&&L){const z=a.aP(F);d.setExpiryData(z)}d._mrt=L,d._isHeaderLoaded=!0,d.state="loaded",this._loadTilePending[d.uid].forEach(z=>z(null,L)),this._loadTileLoaded[d.uid]=!0,delete this._loadTilePending[d.uid]},void 0,!0)}queryRasterArrayValueByAllBands(d,g,S){return new Promise((j,R)=>{this._loadTileForQuery(g,(L,F)=>{L?R(L):j(F?this.queryRasterArrayValueByBandId(d,g,S):null)})})}queryRasterArrayValue(d,g){const S=a.aU.convert(d),j=this.findLoadedParent(S);return j&&j._mrt?g.bands||!this.partial?this.queryRasterArrayValueByBandId(S,j,g):this.queryRasterArrayValueByAllBands(S,j,g):Promise.resolve(null)}findLoadedParent(d){const g=a.ag.fromLngLat(d,this.map.transform.tileSize),S=this.maxzoom+1,j=1<0&&(F[new a.aR(v.overscaledZ,j,d.z,S,d.y-1).key]={backfilled:!1},F[new a.aR(v.overscaledZ,v.wrap,d.z,d.x,d.y-1).key]={backfilled:!1},F[new a.aR(v.overscaledZ,L,d.z,R,d.y-1).key]={backfilled:!1}),d.y+1{if(this._loaded=!0,this._pendingLoad=null,S)this.fire(new a.B(S));else{const R={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&j&&j.resourceTiming&&j.resourceTiming[this.id]&&(R.resourceTiming=j.resourceTiming[this.id]),v&&(this._partialReload=!0),this.fire(new a.C("data",R)),this._partialReload=!1,this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(v),this._coalesce=!1)})}loaded(){return this._loaded}reload(){const v=a.F(this.id,this.scope);this.map.style.clearSource(v),this._updateWorkerData()}loadTile(v,d){const g=v.actor?"reloadTile":"loadTile";v.actor=this.actor;const S=this.map.style?this.map.style.getLut(this.scope):null,j=S?{image:S.image.clone()}:null,R=this._partialReload,L={type:this.type,uid:v.uid,tileID:v.tileID,tileZoom:v.tileZoom,zoom:v.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,lut:j,scope:this.scope,pixelRatio:a.o.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,brightness:this.map.style&&this.map.style.getBrightness()||0,extraShadowCaster:v.isExtraShadowCaster,scaleFactor:this.map.getScaleFactor(),partial:R,worldview:this.map.getWorldview(),indoor:this.map.getIndoorTileOptions(this.id,this.scope)};v.request=this.actor.send(g,L,(F,z)=>R&&!z?(v.state="loaded",d(null)):(delete v.request,v.destroy(!1),v.aborted?d(null):F?d(F):(v.loadVectorData(z,this.map.painter,g==="reloadTile"),d(null))),void 0,g==="loadTile")}abortTile(v){v.request&&(v.request.cancel(),delete v.request),v.aborted=!0}unloadTile(v,d){this.actor.send("removeTile",{uid:v.uid,type:this.type,source:this.id,scope:this.scope}),v.destroy()}onRemove(v){this._pendingLoad&&this._pendingLoad.cancel()}serialize(){return Object.assign({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}},video:class extends a.aV{constructor(v,d,g,S){super(v,d,g,S),this.roundZoom=!0,this.type="video",this.options=d}load(){this._loaded=!1;const v=this.options;this.urls=[];for(const d of v.urls)this.urls.push(this.map._requestManager.transformRequest(d,a.R.Source).url);a.aW(this.urls,(d,g)=>{this._loaded=!0,d?this.fire(new a.B(d)):g&&(this.video=g,this.video.loop=!0,this.video.setAttribute("playsinline",""),this.video.addEventListener("playing",()=>{this.map.triggerRepaint()}),this.map&&this.video.play(),this._finishLoading())})}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(v){if(this.video){const d=this.video.seekable;vd.end(0)?this.fire(new a.B(new a.V(`sources.${this.id}`,null,`Playback for this video can be set only between the ${d.start(0)} and ${d.end(0)}-second mark.`))):this.video.currentTime=v}}getVideo(){return this.video}onAdd(v){this.map||(this.map=v,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}prepare(){if(Object.keys(this.tiles).length===0||this.video.readyState<2)return;const v=this.map.painter.context,d=v.gl;this.texture?this.video.paused||(this.texture.bind(d.LINEAR,d.CLAMP_TO_EDGE),d.texSubImage2D(d.TEXTURE_2D,0,0,0,d.RGBA,d.UNSIGNED_BYTE,this.video)):(this.texture=new a.T(v,this.video,d.RGBA8),this.texture.bind(d.LINEAR,d.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._prepareData(v)}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:a.aV,model:a.aY,"batched-model":class extends a.E{constructor(v,d,g,S){super(),this.type="batched-model",this.id=v,this.tileSize=512,this._options=d,this.tiles=this._options.tiles,this.maxzoom=d.maxzoom||19,this.minzoom=d.minzoom||0,this.roundZoom=!0,this.usedInConflation=!0,this.dispatcher=g,this.reparseOverscaled=!1,this.scheme="xyz",this._loaded=!1,this.setEventedParent(S)}onAdd(v){this.map=v,this.load()}reload(){this.cancelTileJSONRequest();const v=a.F(this.id,this.scope);this.load(()=>this.map.style.clearSource(v))}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}load(v){this._loaded=!1,this.fire(new a.C("dataloading",{dataType:"source"}));const d=Array.isArray(this.map._language)?this.map._language.join():this.map._language,g=this.map.getWorldview();this._tileJSONRequest=Vc(this._options,this.map._requestManager,d,g,(S,j)=>{this._tileJSONRequest=null,this._loaded=!0,S?(d&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${d}`),g&&g.length!==2&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${g}`),this.fire(new a.B(S))):j&&(Object.assign(this,j),j.bounds&&(this.tileBounds=new Au(j.bounds,this.minzoom,this.maxzoom)),Ze(j.tiles,this.map._requestManager._customAccessToken),this.fire(new a.C("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new a.C("data",{dataType:"source",sourceDataType:"content"}))),v&&v(S)})}hasTransition(){return!1}hasTile(v){return!this.tileBounds||this.tileBounds.contains(v.canonical)}loaded(){return this._loaded}loadTile(v,d){const g=this.map._requestManager.normalizeTileURL(v.tileID.canonical.url(this.tiles,this.scheme)),S={request:this.map._requestManager.transformRequest(g,a.R.Tile),data:void 0,uid:v.uid,tileID:v.tileID,tileZoom:v.tileZoom,zoom:v.tileID.overscaledZ,tileSize:this.tileSize*v.tileID.overscaleFactor(),type:this.type,source:this.id,scope:this.scope,showCollisionBoxes:this.map.showCollisionBoxes,renderSourceType:v.renderSourceType,brightness:this.map.style&&this.map.style.getBrightness()||0,pixelRatio:a.o.devicePixelRatio,promoteId:this.promoteId};if(v.actor&&v.state!=="expired")if(v.state==="loading")v.reloadCallback=d;else{if(v.buckets){const R=Object.values(v.buckets);for(const L of R)L.dirty=!0;return void(v.state="loaded")}v.request=v.actor.send("reloadTile",S,j.bind(this))}else v.actor=this.dispatcher.getActor(),v.request=v.actor.send("loadTile",S,j.bind(this),void 0,!0);function j(R,L){return v.aborted?d(null):R&&R.status!==404?d(R):(this.map._refreshExpiredTiles&&L&&v.setExpiryData(L),v.loadModelData(L,this.map.painter),v.state="loaded",void d(null))}}serialize(){return Object.assign({},this._options)}},canvas:class extends a.aV{constructor(v,d,g,S){super(v,d,g,S),d.coordinates?Array.isArray(d.coordinates)&&d.coordinates.length===4&&!d.coordinates.some(j=>!Array.isArray(j)||j.length!==2||j.some(R=>typeof R!="number"))||this.fire(new a.B(new a.V(`sources.${v}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new a.B(new a.V(`sources.${v}`,null,'missing required property "coordinates"'))),d.animate&&typeof d.animate!="boolean"&&this.fire(new a.B(new a.V(`sources.${v}`,null,'optional "animate" property must be a boolean value'))),d.canvas?typeof d.canvas=="string"||d.canvas instanceof HTMLCanvasElement||this.fire(new a.B(new a.V(`sources.${v}`,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new a.B(new a.V(`sources.${v}`,null,'missing required property "canvas"'))),this.options=d,this.animate=d.animate===void 0||d.animate}load(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof HTMLCanvasElement?this.options.canvas:document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new a.B(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1)},this._finishLoading())}getCanvas(){return this.canvas}onAdd(v){this.map=v,this.load(),this.canvas&&this.animate&&this.play()}onRemove(v){this.pause()}prepare(){let v=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,v=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,v=!0),this._hasInvalidDimensions()||Object.keys(this.tiles).length===0)return;const d=this.map.painter.context;this.texture?!v&&!this._playing||this.texture instanceof a.aX||this.texture.update(this.canvas,{premultiply:!0}):this.texture=new a.T(d,this.canvas,d.gl.RGBA8,{premultiply:!0}),this._prepareData(d)}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const v of[this.canvas.width,this.canvas.height])if(isNaN(v)||v<=0)return!0;return!1}},custom:class extends a.E{constructor(v,d,g,S){super(),this.id=v,this.type="custom",this._dataType="raster",this._dispatcher=g,this._implementation=d,this.setEventedParent(S),this.scheme="xyz",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this._loaded=!1,this.roundZoom=!0,this._implementation||this.fire(new a.B(new Error(`Missing implementation for ${this.id} custom source`))),this._implementation.loadTile||this.fire(new a.B(new Error(`Missing loadTile implementation for ${this.id} custom source`))),this._implementation.bounds&&(this.tileBounds=new Au(this._implementation.bounds,this.minzoom,this.maxzoom));const j=d;j.update=this._update.bind(this),j.clearTiles=this._clearTiles.bind(this),j.coveringTiles=this._coveringTiles.bind(this),Object.assign(this,a.aJ(d,["dataType","scheme","minzoom","maxzoom","tileSize","attribution","minTileCacheSize","maxTileCacheSize"]))}serialize(){return a.aJ(this,["type","scheme","minzoom","maxzoom","tileSize","attribution"])}load(){this._loaded=!0,this.fire(new a.C("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new a.C("data",{dataType:"source",sourceDataType:"content"}))}loaded(){return this._loaded}onAdd(v){this.map=v,this._loaded=!1,this.fire(new a.C("dataloading",{dataType:"source"})),this._implementation.onAdd&&this._implementation.onAdd(v),this.load()}onRemove(v){this._implementation.onRemove&&this._implementation.onRemove(v)}hasTile(v){if(this._implementation.hasTile){const{x:d,y:g,z:S}=v.canonical;return this._implementation.hasTile({x:d,y:g,z:S})}return!this.tileBounds||this.tileBounds.contains(v.canonical)}loadTile(v,d){const{x:g,y:S,z:j}=v.tileID.canonical,R=new AbortController,L=Promise.resolve(this._implementation.loadTile({x:g,y:S,z:j},{signal:R.signal})).then((function(F){return delete v.request,v.aborted?(v.state="unloaded",d(null)):F===void 0?(v.state="errored",d(null)):F===null?(this.loadTileData(v,{width:this.tileSize,height:this.tileSize,data:null}),v.state="loaded",d(null)):function(z){return z instanceof ImageData||z instanceof HTMLCanvasElement||z instanceof ImageBitmap||z instanceof HTMLImageElement}(F)?(this.loadTileData(v,F),v.state="loaded",void d(null)):(v.state="errored",d(new Error(`Can't infer data type for ${this.id}, only raster data supported at the moment`)))}).bind(this)).catch(F=>{F.name!=="AbortError"&&(v.state="errored",d(F))});L.cancel=()=>R.abort(),v.request=L}loadTileData(v,d){v.setTexture(d,this.map.painter)}unloadTile(v,d){if(v.texture&&v.texture instanceof a.T?(v.destroy(!1),v.texture&&v.texture instanceof a.T&&this.map.painter.saveTileTexture(v.texture)):v.destroy(),this._implementation.unloadTile){const{x:g,y:S,z:j}=v.tileID.canonical;this._implementation.unloadTile({x:g,y:S,z:j})}d&&d()}abortTile(v,d){v.request&&v.request.cancel&&(v.request.cancel(),delete v.request),d&&d()}hasTransition(){return!1}_coveringTiles(){return this.map.transform.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,roundZoom:this.roundZoom}).map(v=>({x:v.canonical.x,y:v.canonical.y,z:v.canonical.z}))}_clearTiles(){const v=a.F(this.id,this.scope);this.map.style.clearSource(v)}_update(){this.fire(new a.C("data",{dataType:"source",sourceDataType:"content"}))}}},yb=function(v,d,g,S){const j=new gb[d.type](v,d,g,S);if(j.id!==v)throw new Error(`Expected Source id to be ${v} instead of ${j.id}`);return a.aZ(["load","abort","unload","serialize","prepare"],j),j};function CE(v,d,g=""){return`${g}:${d.id||""}:${d.layer.id}:${function(S){if("layerId"in S)return`layer:${S.layerId}`;{const{featuresetId:j,importId:R}=S;return`featureset:${j}${R?`:import:${R}`:""}`}}(v.target)}`}function Wd(v,d,g,S=""){if(v.uniqueFeatureID){const j=CE(v,d,S);if(g.has(j))return!0;g.add(j)}return!1}function hI(v,d,g,S,j=!1,R=void 0){const L=d.sourceCache.transform,F=d.sourceCache.tilesIn(v,d.has3DLayers,j);F.sort(_b);const z=[];for(const W of F){const Z=W.tile.queryRenderedFeatures(d,W,g,S,L,j,R);Object.keys(Z).length&&z.push({wrappedTileID:W.tile.tileID.wrapped().key,queryResults:Z})}for(const W in d.layers){const Z=d.layers[W];if(Z.styleLayer){const ne=Z.styleLayer.queryRenderedFeatures(v,d.sourceCache,S);Object.keys(ne).length&&z.push({wrappedTileID:0,queryResults:ne})}}return z.length===0?{}:function(W){const Z={},ne={};for(const re of W){const ie=re.queryResults,ce=re.wrappedTileID,le=ne[ce]=ne[ce]||{};for(const ve in ie){const _e=ie[ve],Re=le[ve]=le[ve]||{},Me=Z[ve]=Z[ve]||[];for(const Te of _e)Re[Te.featureIndex]||(Re[Te.featureIndex]=!0,Me.push(Te))}}return Z}(z)}function xb(v,d,g,S,j,R){const L={},F=S.queryRenderedSymbols(v),z=[];for(const W of Object.keys(F).map(Number))z.push(j[W]);z.sort(_b);for(const W of z){const Z=W.featureIndex.lookupSymbolFeatures(F[W.bucketInstanceId],W.bucketIndex,W.sourceLayerIndex,d,g,R);for(const ne in Z){const re=L[ne]=L[ne]||[],ie=Z[ne];ie.sort((ce,le)=>{const ve=W.featureSortOrder;if(ve){const _e=ve.indexOf(ce.featureIndex);return ve.indexOf(le.featureIndex)-_e}return le.featureIndex-ce.featureIndex});for(const ce of ie)re.push(ce)}}return L}function IE(v,d){const g=v.getRenderableIds().map(R=>v.getTileByID(R)),S=[],j={};for(let R=0;R{if(R)g(R);else try{const z=S.getHeaderLength(L);if(z>d)return void(this.request=this.fetchHeader(z,g));S.parseHeader(L),this._isHeaderLoaded=!0;let W=0;for(const Z of Object.values(S.layers))W=Math.max(W,Z.dataIndex[Z.dataIndex.length-1].lastByte);L.byteLength>=W&&(this.entireBuffer=L),g(null,this.entireBuffer||L,F)}catch(z){g(z)}}),this.request}fetchBandForRender(d,g,S,j){this.fetchBand(d,g,S,R=>{if(R)return void j(R);this.updateTextureDescriptor(d,g,S);const L=this.textureDescriptorPerLayer.get(g);j(null,L?L.img:null)})}fetchBand(d,g,S,j,R=!0){const L=this._mrt;if(!this._isHeaderLoaded||!L)return void j(new Error("Tile header is not ready"));const F=this.actor;if(!F)return void j(new Error("Can't fetch tile band without an actor"));let z;const W=a.F(String(S),a.F(this.tileID.key,d));let Z=this._taskQueue.get(W);Z?Z.add(j):(Z=new Set,Z.add(j),this._taskQueue.set(W,Z));const ne=(le,ve)=>{z.complete(le,ve),le?j(le):(Z.forEach(_e=>_e(null,ve)),this._taskQueue.delete(W))},re=(le,ve)=>{if(le)return j(le);const _e=F.send("decodeRasterArray",{type:"raster-array",source:this.source,scope:this.scope,tileID:this.tileID,uid:this.uid,buffer:ve,task:z},ne,void 0,!0);if(g!==null){const Re=this._workQueuePerLayer.get(g)||[];Re.push(()=>{_e&&_e.cancel(),z.cancel()}),this._workQueuePerLayer.has(g)||this._workQueuePerLayer.set(g,Re)}};let ie;try{ie=L.getLayer(d)}catch(le){if(this.state==="reloading")return;throw le}if(!ie)return void j(new Error(`Unknown sourceLayer "${d}"`));if(ie.hasDataForBand(S))return Z.forEach(le=>le(null,null)),void this._taskQueue.delete(W);const ce=ie.getDataRange([S]);if(z=L.createDecodingTask(ce),!z||z.tasks.length)if(g!==null&&this.flushQueues(g),this.entireBuffer)re(null,this.entireBuffer.slice(ce.firstByte,ce.lastByte+1));else{const le=Object.assign({},this.requestParams,{headers:{Range:`bytes=${ce.firstByte}-${ce.lastByte}`}}),ve=a.b1(le,re);if(g!==null){const _e=this._fetchQueuePerLayer.get(g)||[];_e.push(()=>{ve.cancel(),z.cancel()}),this._fetchQueuePerLayer.has(g)||this._fetchQueuePerLayer.set(g,_e)}}}updateNeeded(d,g){return(!this.textureDescriptorPerLayer.get(d)||this.textureDescriptorPerLayer.get(d).band!==g||this.refreshedUponExpiration)&&this.state!=="errored"}updateTextureDescriptor(d,g,S){if(!this._mrt)return;const j=this._mrt.getLayer(d);if(!j||!j.hasBand(S)||!j.hasDataForBand(S))return;const{bytes:R,tileSize:L,buffer:F,offset:z,scale:W}=j.getBandView(S),Z=L+2*F,ne=new a.q({width:Z,height:Z},R),re=this.texturePerLayer.get(g);re&&re instanceof a.T&&re.update(ne,{premultiply:!1}),this.textureDescriptorPerLayer.set(g,{layer:d,band:S,img:ne,buffer:F,offset:z,tileSize:L,format:j.pixelFormat,mix:[W,256*W,65536*W,16777216*W]})}destroy(d=!1){if(super.destroy(d),delete this._mrt,!d)for(const g of this.texturePerLayer.values())g&&g instanceof a.T&&g.destroy();this.texturePerLayer.clear(),this.textureDescriptorPerLayer.clear(),this.fbo&&(this.fbo.destroy(),delete this.fbo),delete this.request,delete this.requestParams,this._isHeaderLoaded=!1}}class Wg{constructor(d,g){this.max=d,this.onRemove=g,this.reset()}reset(){for(const d in this.data)for(const g of this.data[d])g.timeout&&clearTimeout(g.timeout),this.onRemove(g.value);return this.data={},this.order=[],this}add(d,g,S){const j=d.wrapped().key;this.data[j]===void 0&&(this.data[j]=[]);const R={value:g,timeout:void 0};if(S!==void 0&&(R.timeout=setTimeout(()=>{this.remove(d,R)},S)),this.data[j].push(R),this.order.push(j),this.order.length>this.max){const L=this._getAndRemoveByKey(this.order[0]);L&&this.onRemove(L)}return this}has(d){return d.wrapped().key in this.data}getAndRemove(d){return this.has(d)?this._getAndRemoveByKey(d.wrapped().key):null}_getAndRemoveByKey(d){const g=this.data[d].shift();return g.timeout&&clearTimeout(g.timeout),this.data[d].length===0&&delete this.data[d],this.order.splice(this.order.indexOf(d),1),g.value}getByKey(d){const g=this.data[d];return g?g[0].value:null}get(d){return this.has(d)?this.data[d.wrapped().key][0].value:null}remove(d,g){if(!this.has(d))return this;const S=d.wrapped().key,j=g===void 0?0:this.data[S].indexOf(g),R=this.data[S][j];return this.data[S].splice(j,1),R.timeout&&clearTimeout(R.timeout),this.data[S].length===0&&delete this.data[S],this.onRemove(R.value),this.order.splice(this.order.indexOf(S),1),this}setMaxSize(d){for(this.max=d;this.order.length>this.max;){const g=this._getAndRemoveByKey(this.order[0]);g&&this.onRemove(g)}return this}filter(d){const g=[];for(const S in this.data)for(const j of this.data[S])d(j.value)||g.push(j);for(const S of g)this.remove(S.value.tileID,S)}}class PE{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(d,g,S){const j=String(g);if(this.stateChanges[d]=this.stateChanges[d]||{},this.stateChanges[d][j]=this.stateChanges[d][j]||{},Object.assign(this.stateChanges[d][j],S),this.deletedStates[d]===null){this.deletedStates[d]={};for(const R in this.state[d])R!==j&&(this.deletedStates[d][R]=null)}else if(this.deletedStates[d]&&this.deletedStates[d][j]===null){this.deletedStates[d][j]={};for(const R in this.state[d][j])S[R]||(this.deletedStates[d][j][R]=null)}else for(const R in S)this.deletedStates[d]&&this.deletedStates[d][j]&&this.deletedStates[d][j][R]===null&&delete this.deletedStates[d][j][R]}removeFeatureState(d,g,S){if(this.deletedStates[d]===null)return;const j=String(g);if(this.deletedStates[d]=this.deletedStates[d]||{},S&&g!==void 0)this.deletedStates[d][j]!==null&&(this.deletedStates[d][j]=this.deletedStates[d][j]||{},this.deletedStates[d][j][S]=null);else if(g!==void 0)if(this.stateChanges[d]&&this.stateChanges[d][j])for(S in this.deletedStates[d][j]={},this.stateChanges[d][j])this.deletedStates[d][j][S]=null;else this.deletedStates[d][j]=null;else this.deletedStates[d]=null}getState(d,g){const S=this.state[d]||{},j=this.stateChanges[d]||{},R=this.deletedStates[d];if(R===null)return{};if(g!==void 0){const F=String(g),z=Object.assign({},S[F],j[F]);if(R){const W=R[g];if(W===null)return{};for(const Z in W)delete z[Z]}return z}const L=Object.assign({},S,j);if(R)for(const F in R)delete L[F];return L}initializeTileState(d,g){d.refreshFeatureState(g)}coalesceChanges(d,g){const S={};for(const j in this.stateChanges){this.state[j]=this.state[j]||{};const R={};for(const L in this.stateChanges[j])this.state[j][L]||(this.state[j][L]={}),Object.assign(this.state[j][L],this.stateChanges[j][L]),R[L]=this.state[j][L];S[j]=R}for(const j in this.deletedStates){this.state[j]=this.state[j]||{};const R={};if(this.deletedStates[j]===null)for(const L in this.state[j])R[L]={},this.state[j][L]={};else for(const L in this.deletedStates[j]){if(this.deletedStates[j][L]===null)this.state[j][L]={};else if(this.state[j][L])for(const F of Object.keys(this.deletedStates[j][L]))delete this.state[j][L][F];R[L]=this.state[j][L]}S[j]=S[j]||{},Object.assign(S[j],R)}if(this.stateChanges={},this.deletedStates={},Object.keys(S).length!==0)for(const j in d)d[j].refreshFeatureState(g,S)}}class Nu extends a.E{constructor(d,g,S){super(),this.id=d,this._renderSourceType=S,this._maxzoomOverride=null,g.on("data",j=>{j.dataType==="source"&&j.sourceDataType==="metadata"&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&j.dataType==="source"&&j.sourceDataType==="content"&&(this.reload(),this.transform&&this.update(this.transform))}),g.on("error",()=>{this._sourceErrored=!0}),this._source=g,this._tiles={},this._cache=new Wg(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=g.minTileCacheSize,this._maxTileCacheSize=g.maxTileCacheSize,this._loadedParentTiles={},this.castsShadows=!1,this.tileCoverLift=0,this._coveredTiles={},this._shadowCasterTiles={},this._state=new PE,this._isRaster=this._source.type==="raster"||this._source.type==="raster-dem"||this._source.type==="raster-array"||this._source.type==="custom"&&"_dataType"in this._source&&this._source._dataType==="raster",this._supportsFading=this._source.type==="raster"||this._source.type==="raster-array"||this._source.type==="image"||this._source.type==="video"||this._source.type==="custom",this._isRasterElevatedOverTerrain=!1}onAdd(d){this.map=d,this._minTileCacheSize=this._minTileCacheSize===void 0&&d?d._minTileCacheSize:this._minTileCacheSize,this._maxTileCacheSize=this._maxTileCacheSize===void 0&&d?d._maxTileCacheSize:this._maxTileCacheSize}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!this._source.loaded())return!1;for(const d in this._tiles)if(!this._tiles[d].loaded())return!1;return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const d=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,d&&this.reload(),this.transform&&this.update(this.transform)}setMaxzoomOverride(d){this._maxzoomOverride=d}_loadTile(d,g){return d.renderSourceType=this._renderSourceType,d.isExtraShadowCaster=this._shadowCasterTiles[d.tileID.key],this._source.loadTile(d,g)}_unloadTile(d){if(this._source.unloadTile)return this._source.unloadTile(d)}_abortTile(d){if(this._source.abortTile)return this._source.abortTile(d)}serialize(){return this._source.serialize()}prepare(d){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const g in this._tiles){const S=this._tiles[g];S.upload(d,this.map?this.map.painter:void 0),S.prepare(this.map.style.imageManager,this.map?this.map.painter:null,this._source.scope)}}getIds(){return Object.values(this._tiles).map(d=>d.tileID).sort(RE).map(d=>d.key)}getRenderableIds(d,g){const S=[];for(const j in this._tiles)this._isIdRenderable(+j,d,g)&&S.push(this._tiles[j]);return d?S.sort((j,R)=>{const L=j.tileID,F=R.tileID,z=new a.P(L.canonical.x,L.canonical.y)._rotate(this.transform.angle),W=new a.P(F.canonical.x,F.canonical.y)._rotate(this.transform.angle);return L.overscaledZ-F.overscaledZ||W.y-z.y||W.x-z.x}).map(j=>j.tileID.key):S.map(j=>j.tileID).sort(RE).map(j=>j.key)}hasRenderableParent(d){const g=this.findLoadedParent(d,0);return!!g&&this._isIdRenderable(g.tileID.key)}_isIdRenderable(d,g,S){return this._tiles[d]&&this._tiles[d].hasData()&&!this._coveredTiles[d]&&(g||!this._tiles[d].holdingForFade())&&(S||!this._shadowCasterTiles[d])}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const d in this._tiles)this._tiles[d].state!=="errored"&&this._reloadTile(+d,"reloading")}}_reloadTile(d,g){const S=this._tiles[d];S&&(S.state!=="loading"&&(S.state=g),this._loadTile(S,this._tileLoaded.bind(this,S,d,g)))}_tileLoaded(d,g,S,j,R){if(j){if(d.state="errored",a.b2(j)){if(this._source.fire(new a.C("data",{dataType:"source",sourceDataType:"error",sourceId:this._source.id,tile:d})),!(d.tileID.key in this._loadedParentTiles))return;if(this._source.type==="raster-dem"&&this.usedForTerrain&&this.map.painter.terrain){const F=this.map.painter.terrain;this.update(this.transform,F.getScaledDemTileSize(),!0),F.resetTileLookupCache(this.id)}else this.update(this.transform)}else this._source.fire(new a.B(j,{tile:d}));return}d.timeAdded=a.o.now(),S==="expired"&&(d.refreshedUponExpiration=!0),this._setTileReloadTimer(g,d),this._source.type==="raster-dem"&&d.dem&&this._backfillDEM(d),this._state.initializeTileState(d,this.map?this.map.painter:null);let L=new Map;R&&R.responseHeaders&&(L=R.responseHeaders),this._source.fire(new a.C("data",{dataType:"source",tile:d,coord:d.tileID,sourceCacheId:this.id,responseHeaders:L}))}_hasTunnelGeometry(){for(const d in this._tiles){const g=this._tiles[d];if(g&&g.hasTunnelGeometry)return!0}return!1}_backfillDEM(d){const g=this.getRenderableIds();for(let j=0;j1||(Math.abs(L)>1&&(Math.abs(L+z)===1?L+=z:Math.abs(L-z)===1&&(L-=z)),R.dem&&j.dem&&(j.dem.backfillBorder(R.dem,L,F),j.neighboringTiles&&j.neighboringTiles[W]&&(j.neighboringTiles[W].backfilled=!0)))}}getTile(d){return this.getTileByID(d.key)}getTileByID(d){return this._tiles[d]}_retainLoadedChildren(d,g,S,j){for(const R in this._tiles){let L=this._tiles[R];if(j[R]||!L.hasData()||L.tileID.overscaledZ<=g||L.tileID.overscaledZ>S)continue;let F=L.tileID;for(;L&&L.tileID.overscaledZ>g+1;){const W=L.tileID.scaledTo(L.tileID.overscaledZ-1);L=this._tiles[W.key],L&&L.hasData()&&(F=W)}let z=F;for(;z.overscaledZ>g;)if(z=z.scaledTo(z.overscaledZ-1),d[z.key]){j[F.key]=F;break}}}findLoadedParent(d,g){if(d.key in this._loadedParentTiles){const S=this._loadedParentTiles[d.key];return S&&S.tileID.overscaledZ>=g?S:null}for(let S=d.overscaledZ-1;S>=g;S--){const j=d.scaledTo(S),R=this._getLoadedTile(j);if(R)return R}}_getLoadedTile(d){const g=this._tiles[d.key];return g&&g.hasData()?g:this._cache.getByKey(this._source.reparseOverscaled?d.wrapped().key:d.canonical.key)}updateCacheSize(d,g){g=g||this._source.tileSize;const S=Math.ceil(d.width/g)+1,j=Math.ceil(d.height/g)+1,R=Math.floor(S*j*5),L=typeof this._minTileCacheSize=="number"?Math.max(this._minTileCacheSize,R):R,F=typeof this._maxTileCacheSize=="number"?Math.min(this._maxTileCacheSize,L):L;this._cache.setMaxSize(F)}handleWrapJump(d){const g=Math.round((d-(this._prevLng===void 0?d:this._prevLng))/360);if(this._prevLng=d,g){const S={};for(const j in this._tiles){const R=this._tiles[j];R.tileID=R.tileID.unwrapTo(R.tileID.wrap+g),S[R.tileID.key]=R}this._tiles=S;for(const j in this._timers)clearTimeout(this._timers[j]),delete this._timers[j];for(const j in this._tiles)this._setTileReloadTimer(+j,this._tiles[j])}}update(d,g,S,j,R){if(this.transform=d,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage||this.usedForTerrain&&!S)return;this.updateCacheSize(d,g),this.transform.projection.name!=="globe"&&this.handleWrapJump(this.transform.center.lng),this._shadowCasterTiles={},this._coveredTiles={};const L=this._source.type==="batched-model";let F,z=this._source.maxzoom;this._maxzoomOverride!==null&&(z=Math.min(z,this._maxzoomOverride));const W=this.map&&this.map.painter?this.map.painter._terrain:null;if(W&&W.sourceCache===this&&W.attenuationRange()){const ie=W.attenuationRange()[0],ce=Math.floor(ie)-Math.log2(W.getDemUpscale());z>ce&&(z=ce)}const Z=this._maxzoomOverride===null&&this._source.reparseOverscaled;if(this.used||this.usedForTerrain){if(this._source.tileID)F=d.getVisibleUnwrappedCoordinates(this._source.tileID).map(ie=>new a.aR(ie.canonical.z,ie.wrap,ie.canonical.z,ie.canonical.x,ie.canonical.y));else if(this.tileCoverLift!==0){const ie=d.clone();ie.tileCoverLift=this.tileCoverLift,F=ie.coveringTiles({tileSize:g||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:z,roundZoom:this._source.roundZoom&&!S,reparseOverscaled:Z,isTerrainDEM:this.usedForTerrain,calculateQuadrantVisibility:L}),this._source.minzoom<=1&&d.projection.name==="globe"&&(F.push(new a.aR(1,0,1,0,0)),F.push(new a.aR(1,0,1,1,0)),F.push(new a.aR(1,0,1,0,1)),F.push(new a.aR(1,0,1,1,1)))}else if(F=d.coveringTiles({tileSize:g||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:z,roundZoom:this._source.roundZoom&&!S,reparseOverscaled:Z,isTerrainDEM:this.usedForTerrain,calculateQuadrantVisibility:L}),this._source.hasTile){const ie=this._source.hasTile.bind(this._source);F=F.filter(ce=>ie(ce))}}else F=[];if(F.length>0&&this.transform.projection.name!=="globe"&&!this.usedForTerrain&&!this._supportsFading){const ie=d.coveringZoomLevel({tileSize:g||this._source.tileSize,roundZoom:this._source.roundZoom&&!S}),ce=Math.min(ie,z);if(L){const le=d.extendTileCover(F,ce);for(const ve of le)F.push(ve)}else if(R){const le=this.transform.getFrustum(ce),ve=d.extendTileCoverToNearPlane(F,le,ce);for(const _e of ve)F.push(_e);if(ce>=18&&this._hasTunnelGeometry()){const _e=d.extendTileCoverForTunnels(F,le,ce,20);for(const Re of _e)F.push(Re)}}else if(this.castsShadows&&j){const le=d.extendTileCover(F,ce,j,16);for(const ve of le)this._shadowCasterTiles[ve.key]=!0,F.push(ve)}}const ne=this._updateRetainedTiles(F);if(this._supportsFading&&F.length!==0){const ie={},ce={},le=a.o.now(),ve=Object.keys(ne);for(const Re of ve){const Me=ne[Re],Te=this._tiles[Re];if(!Te||Te.fadeEndTime!==void 0&&Te.fadeEndTime<=le)continue;const Xe=this.findLoadedParent(Me,Math.max(Me.overscaledZ-Nu.maxOverzooming,this._source.minzoom));Xe&&(this._addTile(Xe.tileID),ie[Xe.tileID.key]=Xe.tileID),ce[Re]=Me}const _e=F[F.length-1].overscaledZ;for(const Re in this._tiles){const Me=this._tiles[Re];if(ne[Re]||!Me.hasData())continue;let Te=Me.tileID;for(;Te.overscaledZ>_e;){Te=Te.scaledTo(Te.overscaledZ-1);const Xe=this._tiles[Te.key];if(Xe&&Xe.hasData()&&ce[Te.key]){ne[Re]=Me.tileID;break}}}for(const Re in ie)ne[Re]||(this._coveredTiles[Re]=!0,ne[Re]=ie[Re])}for(const ie in ne)this._tiles[ie].clearFadeHold();const re=a.b3(this._tiles,ne);for(const ie of re){const ce=this._tiles[ie];ce.hasSymbolBuckets&&!ce.holdingForFade()?ce.setHoldDuration(this.map._fadeDuration):ce.hasSymbolBuckets&&!ce.symbolFadeFinished()||this._removeTile(+ie)}this._updateLoadedParentTileCache(),this._renderSourceType===a.b4.Symbol&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const d in this._tiles)this._tiles[d].holdingForFade()&&this._removeTile(+d)}_updateRetainedTiles(d){const g={};if(d.length===0)return g;const S={},j=d.reduce((W,Z)=>Math.min(W,Z.overscaledZ),1/0),R=d[0].overscaledZ,L=Math.max(R-Nu.maxOverzooming,this._source.minzoom),F=Math.max(R+Nu.maxUnderzooming,this._source.minzoom),z={};for(const W of d){const Z=this._addTile(W);g[W.key]=W,Z.hasData()||j=this._source.maxzoom){const re=W.children(this._source.maxzoom)[0],ie=this.getTile(re);if(ie&&ie.hasData()){g[re.key]=re;continue}}else{const re=W.children(this._source.maxzoom);if(g[re[0].key]&&g[re[1].key]&&g[re[2].key]&&g[re[3].key])continue}let ne=Z.wasRequested();for(let re=W.overscaledZ-1;re>=L;--re){const ie=W.scaledTo(re);if(S[ie.key]||(S[ie.key]=!0,Z=this.getTile(ie),!Z&&ne&&(Z=this._addTile(ie)),Z&&(g[ie.key]=ie,ne=Z.wasRequested(),Z.hasData())))break}}return g}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const d in this._tiles){const g=[];let S,j=this._tiles[d].tileID;for(;j.overscaledZ>0;){if(j.key in this._loadedParentTiles){S=this._loadedParentTiles[j.key];break}g.push(j.key);const R=j.scaledTo(j.overscaledZ-1);if(S=this._getLoadedTile(R),S)break;j=R}for(const R of g)this._loadedParentTiles[R]=S}}_addTile(d){let g=this._tiles[d.key];if(g)return g.isExtraShadowCaster!==!0||this._shadowCasterTiles[d.key]||this._reloadTile(d.key,"reloading"),g;g=this._cache.getAndRemove(d),g&&(this._setTileReloadTimer(d.key,g),g.tileID=d,this._state.initializeTileState(g,this.map?this.map.painter:null),this._cacheTimers[d.key]&&(clearTimeout(this._cacheTimers[d.key]),delete this._cacheTimers[d.key],this._setTileReloadTimer(d.key,g)));const S=!!g;if(!S){const j=this.map?this.map.painter:null,R=this._source.tileSize*d.overscaleFactor();g=this._source.type==="raster-array"?new mp(d,R,this.transform.tileZoom,j,this._isRaster):new a.b0(d,R,this.transform.tileZoom,j,this._isRaster,this._source.worldview),this._loadTile(g,this._tileLoaded.bind(this,g,d.key,g.state))}return g.uses++,this._tiles[d.key]=g,S||this._source.fire(new a.C("dataloading",{tile:g,coord:g.tileID,dataType:"source"})),g}_setTileReloadTimer(d,g){d in this._timers&&(clearTimeout(this._timers[d]),delete this._timers[d]);const S=g.getExpiryTimeout();S&&(this._timers[d]=setTimeout(()=>{this._reloadTile(d,"expired"),delete this._timers[d]},S))}_removeTile(d){const g=this._tiles[d];g&&(g.uses--,delete this._tiles[d],this._timers[d]&&(clearTimeout(this._timers[d]),delete this._timers[d]),g.uses>0||(g.hasData()&&g.state!=="reloading"||g.state==="empty"?this._cache.add(g.tileID,g,g.getExpiryTimeout()):(g.aborted=!0,this._abortTile(g),this._unloadTile(g))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const d in this._tiles)this._removeTile(+d);this._source._clear&&this._source._clear(),this._cache.reset(),this.map&&this.usedForTerrain&&this.map.painter.terrain&&this.map.painter.terrain.resetTileLookupCache(this.id)}tilesIn(d,g,S){const j=[],R=this.transform;if(!R)return j;const L=R.projection.name==="globe",F=a.aH(R.center.lng);for(const z in this._tiles){const W=this._tiles[z];if(S&&W.clearQueryDebugViz(),W.holdingForFade())continue;let Z;if(L){const ne=W.tileID.canonical;if(ne.z===0){const re=[Math.abs(a.aC(F,...Kg(ne,-1))-F),Math.abs(a.aC(F,...Kg(ne,1))-F)];Z=[0,2*re.indexOf(Math.min(...re))-1]}else{const re=[Math.abs(a.aC(F,...Kg(ne,-1))-F),Math.abs(a.aC(F,...Kg(ne,0))-F),Math.abs(a.aC(F,...Kg(ne,1))-F)];Z=[re.indexOf(Math.min(...re))-1]}}else Z=[0];for(const ne of Z){const re=d.containsTile(W,R,g,ne);re&&j.push(re)}}return j}getShadowCasterCoordinates(){return this._getRenderableCoordinates(!1,!0)}getVisibleCoordinates(d){return this._getRenderableCoordinates(d)}_getRenderableCoordinates(d,g){const S=this.getRenderableIds(d,g).map(R=>this._tiles[R].tileID),j=this.transform.projection.name==="globe";for(const R of S)R.projMatrix=this.transform.calculateProjMatrix(R.toUnwrapped()),R.expandedProjMatrix=j?this.transform.calculateProjMatrix(R.toUnwrapped(),!1,!0):R.projMatrix;return S}sortCoordinatesByDistance(d){const g=d.slice(),S=this.transform._camera.position,j=this.transform._camera.forward(),R={};for(const L of g){const F=1/(1<R[L.key]-R[F.key]),g}hasTransition(){if(this._source.hasTransition())return!0;if(this._supportsFading){const d=a.o.now();for(const g in this._tiles){const S=this._tiles[g];if(S.fadeEndTime!==void 0&&S.fadeEndTime>=d)return!0}}return!1}setFeatureState(d,g,S){this._state.updateState(d=d||"_geojsonTileLayer",g,S)}removeFeatureState(d,g,S){this._state.removeFeatureState(d=d||"_geojsonTileLayer",g,S)}getFeatureState(d,g){return this._state.getState(d=d||"_geojsonTileLayer",g)}setDependencies(d,g,S){const j=this._tiles[d];j&&j.setDependencies(g,S)}reloadTilesForDependencies(d,g){for(const S in this._tiles)this._tiles[S].hasDependency(d,g)&&this._reloadTile(+S,"reloading");this._cache.filter(S=>!S.hasDependency(d,g))}_preloadTiles(d,g){if(!this._sourceLoaded){const z=()=>{this._sourceLoaded&&(this._source.off("data",z),this._preloadTiles(d,g))};return void this._source.on("data",z)}const S=new Map,j=Array.isArray(d)?d:[d],R=this.map.painter.terrain,L=this.usedForTerrain&&R?R.getScaledDemTileSize():this._source.tileSize;for(const z of j){const W=z.coveringTiles({tileSize:L,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const Z of W)S.set(Z.key,Z);this.usedForTerrain&&z.updateElevation(!1)}const F=Array.from(S.values());a.t(F,(z,W)=>{const Z=new a.b0(z,this._source.tileSize*z.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster,this._source.worldview);this._loadTile(Z,ne=>{this._source.type==="raster-dem"&&Z.dem&&this._backfillDEM(Z),W(ne,Z)})},g)}}function RE(v,d){const g=Math.abs(2*v.wrap)-+(v.wrap<0),S=Math.abs(2*d.wrap)-+(d.wrap<0);return v.overscaledZ-d.overscaledZ||S-g||d.canonical.y-v.canonical.y||d.canonical.x-v.canonical.x}function Kg(v,d){const g=1<0:S.type==="building"?j=!S.isHidden(d)&&S.paint.get("building-opacity")>0:S.type==="model"&&(j=!S.isHidden(d)&&S.paint.get("model-opacity").constantOr(1)>0),this.layersGotHidden=this.layersGotHidden||!j&&g.visible,g.visible=j}}updateZOffset(d,g){this.currentBuildingBuckets=[];for(const j of this.layers){const R=j.layer,L=this.style.getLayerSourceCache(R);let F=1;R.type==="fill-extrusion"?F=j.visible?R.paint.get("fill-extrusion-vertical-scale"):0:R.type==="building"&&(F=j.visible?R.paint.get("building-vertical-scale"):0);let z=L?L.getTile(g):null;if(!z&&L)for(const W in L._tiles){const Z=L._tiles[W];if(g.canonical.isChildOf(Z.tileID.canonical)){z=Z;break}}this.currentBuildingBuckets.push({bucket:z?z.getBucket(R):null,tileID:z?z.tileID:g,verticalScale:F})}d.hasAnyZOffset=!1;let S=!1;for(let j=0;j{S in d&&(g[S]=d[S])}),g}function ME(v){v=v.slice();const d=Object.create(null);for(const g of v)d[g.id]=g;for(let g=0;g0?(j-L)/F:0;return this.points[R].mult(1-z).add(this.points[g].mult(z))}}class DE{constructor(d,g,S){const j=this.boxCells=[],R=this.circleCells=[];this.xCellCount=Math.ceil(d/S),this.yCellCount=Math.ceil(g/S);for(let L=0;Lthis.width||j<0||g>this.height)return!R&&[];const F=[];if(d<=0&&g<=0&&this.width<=S&&this.height<=j){if(R)return!0;for(let z=0;z0:F}_queryCircle(d,g,S,j,R){const L=d-S,F=d+S,z=g-S,W=g+S;if(F<0||L>this.width||W<0||z>this.height)return!j&&[];const Z=[];return this._forEachCell(L,z,F,W,this._queryCellCircle,Z,{hitTest:j,circle:{x:d,y:g,radius:S},seenUids:{box:{},circle:{}}},R),j?Z.length>0:Z}query(d,g,S,j,R){return this._query(d,g,S,j,!1,R)}hitTest(d,g,S,j,R){return this._query(d,g,S,j,!0,R)}hitTestCircle(d,g,S,j){return this._queryCircle(d,g,S,!0,j)}_queryCell(d,g,S,j,R,L,F,z){const W=F.seenUids,Z=this.boxCells[R];if(Z!==null){const re=this.bboxes;for(const ie of Z)if(!W.box[ie]){W.box[ie]=!0;const ce=4*ie;if(d<=re[ce+2]&&g<=re[ce+3]&&S>=re[ce+0]&&j>=re[ce+1]&&(!z||z(this.boxKeys[ie]))){if(F.hitTest)return L.push(!0),!0;L.push({key:this.boxKeys[ie],x1:re[ce],y1:re[ce+1],x2:re[ce+2],y2:re[ce+3]})}}}const ne=this.circleCells[R];if(ne!==null){const re=this.circles;for(const ie of ne)if(!W.circle[ie]){W.circle[ie]=!0;const ce=3*ie;if(this._circleAndRectCollide(re[ce],re[ce+1],re[ce+2],d,g,S,j)&&(!z||z(this.circleKeys[ie]))){if(F.hitTest)return L.push(!0),!0;{const le=re[ce],ve=re[ce+1],_e=re[ce+2];L.push({key:this.circleKeys[ie],x1:le-_e,y1:ve-_e,x2:le+_e,y2:ve+_e})}}}}}_queryCellCircle(d,g,S,j,R,L,F,z){const W=F.circle,Z=F.seenUids,ne=this.boxCells[R];if(ne!==null){const ie=this.bboxes;for(const ce of ne)if(!Z.box[ce]){Z.box[ce]=!0;const le=4*ce;if(this._circleAndRectCollide(W.x,W.y,W.radius,ie[le+0],ie[le+1],ie[le+2],ie[le+3])&&(!z||z(this.boxKeys[ce])))return L.push(!0),!0}}const re=this.circleCells[R];if(re!==null){const ie=this.circles;for(const ce of re)if(!Z.circle[ce]){Z.circle[ce]=!0;const le=3*ce;if(this._circlesCollide(ie[le],ie[le+1],ie[le+2],W.x,W.y,W.radius)&&(!z||z(this.circleKeys[ce])))return L.push(!0),!0}}}_forEachCell(d,g,S,j,R,L,F,z){const W=this._convertToXCellCoord(d),Z=this._convertToYCellCoord(g),ne=this._convertToXCellCoord(S),re=this._convertToYCellCoord(j);for(let ie=W;ie<=ne;ie++)for(let ce=Z;ce<=re;ce++)if(R.call(this,d,g,S,j,this.xCellCount*ce+ie,L,F,z))return}_convertToXCellCoord(d){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(d*this.xScale)))}_convertToYCellCoord(d){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(d*this.yScale)))}_circlesCollide(d,g,S,j,R,L){const F=j-d,z=R-g,W=S+L;return W*W>F*F+z*z}_circleAndRectCollide(d,g,S,j,R,L,F){const z=(L-j)/2,W=Math.abs(d-(j+z));if(W>z+S)return!1;const Z=(F-R)/2,ne=Math.abs(g-(R+Z));if(ne>Z+S)return!1;if(W<=z||ne<=Z)return!0;const re=W-z,ie=ne-Z;return re*re+ie*ie<=S*S}}const z5=Math.tan(85*Math.PI/180);function Hf(v,d,g,S,j,R,L){const F=a.bb();if(g)if(R.name==="globe"){const z=a.bc(j,d);a.aD(F,F,z)}else{const z=a.bd([],L);F[0]=z[0],F[1]=z[1],F[4]=z[2],F[5]=z[3],S||a.ba(F,F,j.angle)}else a.aD(F,j.labelPlaneMatrix,v);return F}function ad(v,d,g,S,j,R,L){const F=Hf(v,d,g,S,j,R,L);return R.name==="globe"&&g||(F[2]=F[6]=F[10]=F[14]=0),F}function Qg(v,d,g,S,j,R,L){if(g){if(R.name==="globe"){const F=Hf(v,d,g,S,j,R,L);return a.b7(F,F),a.aD(F,v,F),F}{const F=a.b8(v),z=a.b9([]);return z[0]=L[0],z[1]=L[1],z[4]=L[2],z[5]=L[3],a.aD(F,F,z),S||a.ba(F,F,-j.angle),F}}return j.glCoordMatrix}function Cu(v,d,g,S){const j=[v,d,g,1];g?a.aE(j,j,S):sn(j,j,S);const R=j[3];return j[0]/=R,j[1]/=R,j[2]/=R,j}function wb(v,d){return Math.min(.5+v/d*.5,1.5)}function N0(v,d){const g=v[0]/v[3],S=v[1]/v[3];return g>=-d[0]&&g<=d[0]&&S>=-d[1]&&S<=d[1]}function bc(v,d,g,S,j,R,L,F,z,W,Z=1){const ne=g.transform,re=S?v.textSizeData:v.iconSizeData,ie=a.bj(re,g.transform.zoom,Z),ce=ne.projection.name==="globe",le=[256/g.width*2+1,256/g.height*2+1],ve=S?v.text.dynamicLayoutVertexArray:v.icon.dynamicLayoutVertexArray;ve.clear();let _e=null;ce&&(_e=S?v.text.globeExtVertexArray:v.icon.globeExtVertexArray);const Re=v.lineVertexArray,Me=S?v.text.placedSymbolArray:v.icon.placedSymbolArray,Te=g.transform.width/g.transform.height;let Xe,$e=!1;for(let Ke=0;KeMath.abs(g)?{useVertical:!0}:v===a.bk.vertical?S>0?{needsFlipping:!0}:null:d!==0&&function(j,R){return j===0||Math.abs(R/j)>z5}(g,S)?d===1?{needsFlipping:!0}:null:g<0?{needsFlipping:!0}:null}function FE(v,d,g,S,j,R,L,F,z,W,Z,ne,re,ie,ce,le,ve,_e,Re,Me){const Te=d/24,Xe=v.lineOffsetX*Te,$e=v.lineOffsetY*Te,{lineStartIndex:Ke,glyphStartIndex:De,numGlyphs:Be,segment:Ge,writingMode:ot,flipState:Je}=v,St=Ke+v.lineLength,pt=Ot=>{if(Z){const[vt,Et,Nt]=Ot.up,lr=W.length;a.bm(Z,lr+0,vt,Et,Nt),a.bm(Z,lr+1,vt,Et,Nt),a.bm(Z,lr+2,vt,Et,Nt),a.bm(Z,lr+3,vt,Et,Nt)}const[Ut,ut,st]=Ot.point;a.bn(W,Ut,ut,st,Ot.angle)};if(Be>1){const Ot=OE(Te,F,Xe,$e,g,ne,re,v,z,R,ie,le,!1,ve,_e,Re,Me);if(!Ot)return{notEnoughRoom:!0};if(S&&!g){let[Ut,ut,st]=Ot.first.point,[vt,Et,Nt]=Ot.last.point;[Ut,ut]=Cu(Ut,ut,st,L),[vt,Et]=Cu(vt,Et,Nt,L);const lr=Sb(ot,Je,(vt-Ut)*ce,Et-ut);if(v.flipState=lr&&lr.needsFlipping?1:2,lr)return lr}pt(Ot.first);for(let Ut=De+1;Ut0?vt:BE(re,st,Ut,1,j,void 0,ve,_e.canonical),Nt=Sb(ot,Je,(Et[0]-Ut[0])*ce,Et[1]-Ut[1]);if(v.flipState=Nt&&Nt.needsFlipping?1:2,Nt)return Nt}const Ot=Tb(Te*F.getoffsetX(De),Xe,$e,g,ne,re,Ge,Ke,St,z,R,ie,le,!1,!1,ve,_e,Re,Me);if(!Ot)return{notEnoughRoom:!0};pt(Ot)}return{}}function as(v,d,g,S,j){const{x:R,y:L,z:F}=S.projectTilePoint(v.x,v.y,d);if(!j)return Cu(R,L,F,g);const[z,W,Z]=j.getElevation(v,j.elevation,j.elevationFeature);return Cu(R+z,L+W,F+Z,g)}function BE(v,d,g,S,j,R,L,F){const z=as(v.sub(d)._unit()._add(v),F,j,L,R);return a.ax(z,g,z),a.ay(z,z),a.bg(z,g,z,S)}function Tb(v,d,g,S,j,R,L,F,z,W,Z,ne,re,ie,ce,le,ve,_e,Re){const Me=S?v-d:v+d;let Te=Me>0?1:-1,Xe=0;S&&(Te*=-1,Xe=Math.PI),Te<0&&(Xe+=Math.PI);let $e=F+L+(Te>0?0:1)|0,Ke=j,De=j,Be=0,Ge=0;const ot=Math.abs(Me),Je=[],St=[];let pt=R,Ot=pt,Ut=a.be([]);const ut=()=>BE(Ot,pt,De,ot-Be+1,Z,re,le,ve.canonical);for(;Be+Ge<=ot;){if($e+=Te,$e=z)return null;if(De=Ke,Ot=pt,Je.push(De),ie&&St.push(Ot),pt=new a.P(W.getx($e),W.gety($e)),Ke=ne[$e],!Ke){const Or=as(pt,ve.canonical,Z,le,re);Ke=Or[3]>0?ne[$e]=Or:ut()}Be+=Ge;const zt=a.ax([],Ke,De),Ir=a.bf(De,Ke);if(g&&Ir>0&&Ge>0&&a.bi(Ut,zt)/(Ge*Ir)0,Me),Ke=W*$e.perspectiveRatio,De=(S.x1*g+F.x-S.padding)*Ke+$e.point.x,Be=(S.y1*g+F.y-S.padding)*Ke+$e.point.y,Ge=(S.x2*g+F.x+S.padding)*Ke+$e.point.x,ot=(S.y2*g+F.y+S.padding)*Ke+$e.point.y,Je=$e.perspectiveRatio<=.55||$e.occluded;return!this.isInsideGrid(De,Be,Ge,ot)||!z&&this.grid.hitTest(De,Be,Ge,ot,ne)||Je?{box:[],offscreen:!1,occluded:$e.occluded}:{box:[De,Be,Ge,ot],offscreen:this.isOffscreen(De,Be,Ge,ot),occluded:!1}}placeCollisionCircles(d,g,S,j,R,L,F,z,W,Z,ne,re,ie,ce,le,ve){const _e=[],Re=this.transform.elevation,Me=d.getProjection(),Te=d.elevationType==="road",Xe=!!Re||Te,$e=a.bu.getAtTileOffsetFunc(ve,this.transform.center.lat,this.transform.worldSize,Me),Ke=new a.P(S.tileAnchorX,S.tileAnchorY),De=new a.P(S.tileAnchorX,S.tileAnchorY);let{x:Be,y:Ge,z:ot}=Me.projectTilePoint(De.x,De.y,ve.canonical),Je=null;if(Xe){const Ir=Te?d.getElevationFeatureForText(j):null;Je={getElevation:$e,elevation:Re,elevationFeature:Ir};const[Or,vr,Ar]=$e(Ke,Re,Ir);Be+=Or,Ge+=vr,ot+=Ar}const St=Me.name==="globe",pt=this.projectAndGetPerspectiveRatio(z,Be,Ge,ot,ve,St||!!Re||this.transform.pitch>0,Me),{perspectiveRatio:Ot}=pt,Ut=(re?F/Ot:F*Ot)/a.by,ut=Cu(Be,Ge,ot,W),st=S.lineOffsetX*Ut,vt=S.lineOffsetY*Ut,Et=a.ap(d.layers[0].layout.get("text-max-angle")),Nt=Math.cos(Et),lr=pt.signedDistanceFromCamera>0?OE(Ut,L,st,vt,Te&&S.flipState===1,ut,De,S,R,W,{},Xe&&!re?Je:null,re&&Xe,Me,ve,re,Nt):null;let Jt=!1,er=!1,zt=!0;if(lr&&!pt.occluded){const Ir=.5*ce*Ot+le,Or=new a.P(-100,-100),vr=new a.P(this.screenRightBoundary,this.screenBottomBoundary),Ar=new mI,{first:Jr,last:dn}=lr,on=Jr.path.length;let Tn=[];for(let ln=on-1;ln>=1;ln--)Tn.push(Jr.path[ln]);for(let ln=1;ln(Xe&&!St&&(Cs=$e(ailn[3]<=0)&&(Tn=[]));let En=[];if(Tn.length>0){let ln=1/0,ts=-1/0,Cs=1/0,ai=-1/0;for(const Fs of Tn)ln=Math.min(ln,Fs[0]),Cs=Math.min(Cs,Fs[1]),ts=Math.max(ts,Fs[0]),ai=Math.max(ai,Fs[1]);ts>=Or.x&&ln<=vr.x&&ai>=Or.y&&Cs<=vr.y&&(En=[Tn.map(Fs=>new a.P(Fs[0],Fs[1]))],(lnvr.x||Csvr.y)&&(En=a.bv(En,Or.x,Or.y,vr.x,vr.y)))}for(const ln of En){Ar.reset(ln,.25*Ir);let ts=0;ts=Ar.length<=.5*Ir?1:Math.ceil(Ar.paddedLength/Kr)+1;for(let Cs=0;Cs0?(a.aE(z,z,d),this.fogState&&R&&F.name!=="globe"&&(W=function(re,ie,ce,le,ve,_e){const Re=_e.calculateFogTileMatrix(ve),Me=[ie,ce,le];return a.ah(Me,Me,Re),wn(re,a.ai(Me),_e.pitch,_e._fov)}(this.fogState,g,S,j,R.toUnwrapped(),this.transform)>.9)):sn(z,z,d);const Z=z[3];return{point:new a.P((z[0]/Z+1)/2*this.transform.width+od,(-z[1]/Z+1)/2*this.transform.height+od),perspectiveRatio:Math.min(.5+this.transform.getCameraToCenterDistance(F)/Z*.5,1.5),signedDistanceFromCamera:Z,occluded:L&&z[2]>Z||W}}isOffscreen(d,g,S,j){return S=this.screenRightBoundary||jthis.screenBottomBoundary}isInsideGrid(d,g,S,j){return S>=0&&d=0&&gS.collisionGroupID===g}}return this.collisionGroups[d]}}function Rl(v,d,g,S,j){const{horizontalAlign:R,verticalAlign:L}=a.bF(v),F=-(R-.5)*d,z=-(L-.5)*g,W=a.bG(v,S);return new a.P(F+W[0]*j,z+W[1]*j)}function Wf(v,d,g,S,j){const R=new a.P(v,d);return g&&R._rotate(S?j:-j),R}class Ss{constructor(d,g,S,j,R,L){this.transform=d.clone(),this.projection=d.projection.name,this.collisionIndex=new Eb(this.transform,R),this.buildingIndex=L,this.frontCutoffStart=0,this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=g,this.retainedQueryData={},this.collisionGroups=new ws(S),this.collisionCircleArrays={},this.prevPlacement=j,j&&(j.prevPlacement=void 0),this.placedOrientations={},this.lastReplacementSourceUpdateTime=0}getBucketParts(d,g,S,j,R=1){const L=S.getBucket(g),F=S.latestFeatureIndex;if(!L||!F||g.fqid!==L.layerIds[0])return;const z=L.layers[0].layout,W=L.layers[0].paint,Z=S.collisionBoxArray,ne=Math.pow(2,this.transform.zoom-S.tileID.overscaledZ),re=S.tileSize/a.an,ie=S.tileID.toUnwrapped();this.transform.setProjection(L.projection);const ce=(le=S.tileID,ve=L.getProjection(),_e=this.transform,ve.name===this.projection?_e.calculateProjMatrix(le.toUnwrapped()):bb(_e,ve,le));var le,ve,_e;const Re=z.get("text-pitch-alignment")==="map",Me=z.get("text-rotation-alignment")==="map";g.compileFilter(g.options);const Te=g.dynamicFilter(),Xe=g.dynamicFilterNeedsFeature(),$e=g.dynamicFilterNeedsGeometry(),Ke=this.transform.calculatePixelsToTileUnitsMatrix(S),De=ad(ce,S.tileID.canonical,Re,Me,this.transform,L.getProjection(),Ke);let Be=null;const Ge=L.getProjection().createInversionMatrix(this.transform,S.tileID.canonical);if(Re){const vt=Qg(ce,S.tileID.canonical,Re,Me,this.transform,L.getProjection(),Ke);Be=a.aD([],this.transform.labelPlaneMatrix,vt)}let ot=null;Te&&S.latestFeatureIndex&&(ot={unwrappedTileID:ie,dynamicFilter:Te,dynamicFilterNeedsFeature:Xe,needGeometry:$e}),this.retainedQueryData[L.bucketInstanceId]=new xs(L.bucketInstanceId,F,L.sourceLayerIndex,L.index,S.tileID);const[Je,St]=L.layers[0].layout.get("text-size-scale-range"),pt=a.aC(R,Je,St),[Ot,Ut]=z.get("icon-size-scale-range"),ut=a.aC(R,Ot,Ut),st={bucket:L,layout:z,paint:W,posMatrix:ce,invMatrix:Ge,mercatorCenter:[a.aH(this.transform.center.lng),a.aL(this.transform.center.lat)],textLabelPlaneMatrix:De,labelToScreenMatrix:Be,clippingData:ot,scale:ne,textPixelRatio:re,holdingForFade:S.holdingForFade(),collisionBoxArray:Z,partiallyEvaluatedTextSize:a.bj(L.textSizeData,this.transform.zoom,pt),partiallyEvaluatedIconSize:a.bj(L.iconSizeData,this.transform.zoom,ut),collisionGroup:this.collisionGroups.get(L.sourceID),latestFeatureIndex:S.latestFeatureIndex};if(j)for(const vt of L.sortKeyRanges){const{sortKey:Et,symbolInstanceStart:Nt,symbolInstanceEnd:lr}=vt;d.push({sortKey:Et,symbolInstanceStart:Nt,symbolInstanceEnd:lr,parameters:st})}else d.push({symbolInstanceStart:0,symbolInstanceEnd:L.symbolInstances.length,parameters:st})}attemptAnchorPlacement(d,g,S,j,R,L,F,z,W,Z,ne,re,ie,ce,le,ve,_e,Re,Me,Te,Xe){const{textOffset0:$e,textOffset1:Ke,crossTileID:De}=le,Be=[$e,Ke],Ge=Rl(d,L,F,Be,z),ot=this.collisionIndex.placeCollisionBox(_e,z,g,S,j,R,Wf(Ge.x,Ge.y,W,Z,this.transform.angle),ce,ne,re,ie.predicate);if(Me){const Je=_e.getSymbolInstanceIconSize(Xe,this.transform.zoom,le.placedIconSymbolIndex);if(this.collisionIndex.placeCollisionBox(_e,Je,Me,S,j,R,Wf(Ge.x,Ge.y,W,Z,this.transform.angle),ce,ne,re,ie.predicate).box.length===0)return}if(ot.box.length>0){let Je;return this.prevPlacement&&this.prevPlacement.variableOffsets[De]&&this.prevPlacement.placements[De]&&this.prevPlacement.placements[De].text&&(Je=this.prevPlacement.variableOffsets[De].anchor),this.variableOffsets[De]={textOffset:Be,width:L,height:F,anchor:d,textScale:z,prevAnchor:Je},this.markUsedJustification(_e,d,le,Re),_e.allowVerticalPlacement&&(this.markUsedOrientation(_e,Re,le),this.placedOrientations[De]=Re),{shift:Ge,placedGlyphBoxes:ot}}}placeLayerBucketPart(d,g,S,j,R=1){const{bucket:L,layout:F,paint:z,posMatrix:W,textLabelPlaneMatrix:Z,labelToScreenMatrix:ne,clippingData:re,textPixelRatio:ie,mercatorCenter:ce,invMatrix:le,holdingForFade:ve,collisionBoxArray:_e,partiallyEvaluatedTextSize:Re,partiallyEvaluatedIconSize:Me,collisionGroup:Te,latestFeatureIndex:Xe}=d.parameters,$e=F.get("text-optional"),Ke=F.get("icon-optional"),De=F.get("text-allow-overlap"),Be=F.get("icon-allow-overlap"),Ge=F.get("text-rotation-alignment")==="map",ot=F.get("icon-rotation-alignment")==="map",Je=F.get("text-pitch-alignment")==="map",St=z.get("symbol-z-offset"),pt=F.get("symbol-elevation-reference")==="sea",Ot=F.get("symbol-placement"),[Ut,ut]=F.get("text-size-scale-range"),[st,vt]=F.get("icon-size-scale-range"),Et=a.aC(R,Ut,ut),Nt=a.aC(R,st,vt),lr=F.get("text-variable-anchor"),Jt=Ge&&Ot!=="point",er=ot&&Ot!=="point",zt=lr&&L.hasTextData(),Ir=L.hasIconTextFit()&&zt&&L.hasIconData();this.transform.setProjection(L.projection);const Or=zt||Jt,vr=er||Ir;let Ar=De&&(Be||!L.hasIconData()||Ke),Jr=Be&&(De||!L.hasTextData()||$e);const dn=!St.isConstant();!L.collisionArrays&&_e&&L.deserializeCollisionBoxes(_e),S&&j&&L.updateCollisionDebugBuffers(this.transform.zoom,_e,Et,Nt);const on=(Kr,En,ln)=>{const{crossTileID:ts,numVerticalGlyphVertices:Cs}=Kr;let ai=null;if(re&&re.dynamicFilterNeedsFeature||dn){const Vs=this.retainedQueryData[L.bucketInstanceId],Ys=Xe.loadFeature({featureIndex:Kr.featureIndex,bucketIndex:Vs.bucketIndex,sourceLayerIndex:Vs.sourceLayerIndex,layoutVertexArrayOffset:0}),Ts=Ys.properties?Ys.properties.worldview:null;if(L.localizable&&L.worldview&&typeof Ts=="string")if(Ts==="all")Ys.properties.$localized=!0;else{if(!Ts.split(",").includes(L.worldview))return;Ys.properties.$localized=!0,Ys.properties.worldview=L.worldview}ai=re&&re.needGeometry?a.bD(Ys,!0):Ys}if(re&&!(0,re.dynamicFilter)({zoom:this.transform.zoom,pitch:this.transform.pitch,worldview:L.worldview},ai,this.retainedQueryData[L.bucketInstanceId].tileID.canonical,new a.P(Kr.tileAnchorX,Kr.tileAnchorY),this.transform.calculateDistanceTileData(re.unwrappedTileID)))return this.placements[ts]=new Bh(!1,!1,!1,!0),void g.add(ts);const Fs=St.evaluate(ai,{});if((Kr.zOffset||0)+(Fs||0)>0&&this.frontCutoffStart>0){const Vs=2*this.frontCutoffStart-1,Ys=[Kr.tileAnchorX,Kr.tileAnchorY,0,1],Ts=a.aE(a.bE(),Ys,W);if(Ts[1]/Ts[3]{Vs.tileID=this.retainedQueryData[L.bucketInstanceId].tileID;const Ys=this.transform.elevation;Vs.elevation=pt?Fs:Fs+a.bu.getAtTileOffset(Vs.tileID,new a.P(Vs.tileAnchorX,Vs.tileAnchorY),Ys,Sa),Vs.elevation+=Kr.zOffset},Tc=ln.textBox;if(Tc){ro(Tc);const Vs=Ts=>{let Vi=a.bk.horizontal;if(L.allowVerticalPlacement&&!Ts&&this.prevPlacement){const Zo=this.prevPlacement.placedOrientations[ts];Zo&&(this.placedOrientations[ts]=Zo,Vi=Zo,this.markUsedOrientation(L,Vi,Kr))}return Vi},Ys=(Ts,Vi)=>{if(L.allowVerticalPlacement&&Cs>0&&ln.verticalTextBox){for(const Zo of L.writingModes)if(Zo===a.bk.vertical?(hn=Vi(),ni=hn):hn=Ts(),hn&&hn.box&&hn.box.length)break}else hn=Ts()};if(lr){let Ts=lr;if(this.prevPlacement&&this.prevPlacement.variableOffsets[ts]){const Si=this.prevPlacement.variableOffsets[ts];Ts.indexOf(Si.anchor)>0&&(Ts=Ts.filter(Ec=>Ec!==Si.anchor),Ts.unshift(Si.anchor))}const Vi=(Si,Ec,rm)=>{const Lp=L.getSymbolInstanceTextSize(Re,Kr,this.transform.zoom,En),Mp=(Si.x2-Si.x1)*Lp+2*Si.padding,vy=(Si.y2-Si.y1)*Lp+2*Si.padding,Kh=Kr.hasIconTextFit&&!Be?Ec:null;Kh&&ro(Kh);let eh={box:[],offscreen:!1,occluded:!1};const by=De?2*Ts.length:Ts.length;for(let Zl=0;Zl=Ts.length,Kr,En,L,rm,Kh,Re,Me);if(nm&&(eh=nm.placedGlyphBoxes,eh&&eh.box&&eh.box.length)){us=!0,ds=nm.shift;break}}return eh};Ys(()=>Vi(Tc,ln.iconBox,a.bk.horizontal),()=>{const Si=ln.verticalTextBox;return Si&&ro(Si),L.allowVerticalPlacement&&!(hn&&hn.box&&hn.box.length)&&Cs>0&&Si?Vi(Si,ln.verticalIconBox,a.bk.vertical):{box:null,offscreen:null,occluded:null}}),hn&&(us=hn.box,bn=hn.offscreen,Bs=hn.occluded);const Zo=Vs(!(!hn||!hn.box));if(!us&&this.prevPlacement){const Si=this.prevPlacement.variableOffsets[ts];Si&&(this.variableOffsets[ts]=Si,this.markUsedJustification(L,Si.anchor,Kr,Zo))}}else{const Ts=(Vi,Zo)=>{const Si=L.getSymbolInstanceTextSize(Re,Kr,this.transform.zoom,En),Ec=this.collisionIndex.placeCollisionBox(L,Si,Vi,ce,le,Or,new a.P(0,0),De,ie,W,Te.predicate);return Ec&&Ec.box&&Ec.box.length&&(this.markUsedOrientation(L,Zo,Kr),this.placedOrientations[ts]=Zo),Ec};Ys(()=>Ts(Tc,a.bk.horizontal),()=>{const Vi=ln.verticalTextBox;return L.allowVerticalPlacement&&Cs>0&&Vi?(ro(Vi),Ts(Vi,a.bk.vertical)):{box:null,offscreen:null,occluded:null}}),Vs(!!(hn&&hn.box&&hn.box.length))}}if(Is=hn,us=Is&&Is.box&&Is.box.length>0,bn=Is&&Is.offscreen,Bs=Is&&Is.occluded,Kr.useRuntimeCollisionCircles){const Vs=Kr.centerJustifiedTextSymbolIndex>=0?Kr.centerJustifiedTextSymbolIndex:Kr.verticalPlacedTextSymbolIndex,Ys=L.text.placedSymbolArray.get(Vs),Ts=a.bl(L.textSizeData,Re,Ys),Vi=F.get("text-padding");Ki=this.collisionIndex.placeCollisionCircles(L,De,Ys,Vs,L.lineVertexArray,L.glyphOffsetArray,Ts,W,Z,ne,S,Je,Te.predicate,Kr.collisionCircleDiameter*Ts/a.by,Vi,this.retainedQueryData[L.bucketInstanceId].tileID),us=De||Ki.circles.length>0&&!Ki.collisionDetected,bn=bn&&Ki.offscreen,Bs=Ki.occluded}if(ln.iconFeatureIndex&&(Lo=ln.iconFeatureIndex),ln.iconBox){const Vs=Ys=>{ro(Ys);const Ts=Kr.hasIconTextFit&&ds?Wf(ds.x,ds.y,Ge,Je,this.transform.angle):new a.P(0,0),Vi=L.getSymbolInstanceIconSize(Me,this.transform.zoom,Kr.placedIconSymbolIndex);return this.collisionIndex.placeCollisionBox(L,Vi,Ys,ce,le,vr,Ts,Be,ie,W,Te.predicate)};ni&&ni.box&&ni.box.length&&ln.verticalIconBox?(Mn=Vs(ln.verticalIconBox),vn=Mn.box.length>0):(Mn=Vs(ln.iconBox),vn=Mn.box.length>0),bn=bn&&Mn.offscreen,fi=Mn.occluded}const ys=$e||Kr.numHorizontalGlyphVertices===0&&Cs===0,Yc=Ke||Kr.numIconVertices===0;if(ys||Yc?Yc?ys||(vn=vn&&us):us=vn&&us:vn=us=vn&&us,us&&Is&&Is.box&&this.collisionIndex.insertCollisionBox(Is.box,F.get("text-ignore-placement"),L.bucketInstanceId,ni&&ni.box&&ha?ha:Ms,Te.ID),vn&&Mn&&this.collisionIndex.insertCollisionBox(Mn.box,F.get("icon-ignore-placement"),L.bucketInstanceId,Lo,Te.ID),Ki&&(us&&this.collisionIndex.insertCollisionCircles(Ki.circles,F.get("text-ignore-placement"),L.bucketInstanceId,Ms,Te.ID),S)){const Vs=L.bucketInstanceId;let Ys=this.collisionCircleArrays[Vs];Ys===void 0&&(Ys=this.collisionCircleArrays[Vs]=new Ur);for(let Ts=0;Ts=0;--En){const ln=Kr[En];on(L.symbolInstances.get(ln),ln,L.collisionArrays[ln])}L.hasAnyZOffset&&a.w(`${L.layerIds[0]} layer symbol-z-elevate: symbols are not sorted by elevation if symbol-z-order is evaluated to viewport-y`)}else if(L.hasAnyZOffset){const Kr=L.getSortedIndexesByZOffset();for(let En=0;En=0&&(d.text.placedSymbolArray.get(R).crossTileID=ne>=0&&R!==ne?0:W),L>=0&&(d.text.placedSymbolArray.get(L).crossTileID=ne>=0&&L!==ne?0:W),F>=0&&(d.text.placedSymbolArray.get(F).crossTileID=ne>=0&&F!==ne?0:W),z>=0&&(d.text.placedSymbolArray.get(z).crossTileID=ne>=0&&z!==ne?0:W)}markUsedOrientation(d,g,S){const j=g===a.bk.horizontal||g===a.bk.horizontalOnly?g:0,R=g===a.bk.vertical?g:0,{leftJustifiedTextSymbolIndex:L,centerJustifiedTextSymbolIndex:F,rightJustifiedTextSymbolIndex:z,verticalPlacedTextSymbolIndex:W}=S,Z=d.text.placedSymbolArray;L>=0&&(Z.get(L).placedOrientation=j),F>=0&&(Z.get(F).placedOrientation=j),z>=0&&(Z.get(z).placedOrientation=j),W>=0&&(Z.get(W).placedOrientation=R)}commit(d){this.commitTime=d,this.zoomAtLastRecencyCheck=this.transform.zoom;const g=this.prevPlacement;let S=!1;this.prevZoomAdjustment=g?g.zoomAdjustment(this.transform.zoom):0;const j=g?g.symbolFadeChange(d):1,R=g?g.opacities:{},L=g?g.variableOffsets:{},F=g?g.placedOrientations:{};for(const z in this.placements){const W=this.placements[z],Z=R[z];Z?(this.opacities[z]=new gp(Z,j,W.text,W.icon,null,W.clipped),S=S||W.text!==Z.text.placed||W.icon!==Z.icon.placed):(this.opacities[z]=new gp(null,j,W.text,W.icon,W.skipFade,W.clipped),S=S||W.text||W.icon)}for(const z in R){const W=R[z];if(!this.opacities[z]){const Z=new gp(W,j,!1,!1);Z.isHidden()||(this.opacities[z]=Z,S=S||W.text.placed||W.icon.placed)}}for(const z in L)this.variableOffsets[z]||!this.opacities[z]||this.opacities[z].isHidden()||(this.variableOffsets[z]=L[z]);for(const z in F)this.placedOrientations[z]||!this.opacities[z]||this.opacities[z].isHidden()||(this.placedOrientations[z]=F[z]);S?this.lastPlacementChangeTime=d:typeof this.lastPlacementChangeTime!="number"&&(this.lastPlacementChangeTime=g?g.lastPlacementChangeTime:d)}updateLayerOpacities(d,g,S,j){j&&(this.lastReplacementSourceUpdateTime=j.updateTime);const R=new Set;for(const L of g){const F=L.getBucket(d);F&&L.latestFeatureIndex&&d.fqid===F.layerIds[0]&&(this.updateBucketOpacities(F,R,L,L.collisionBoxArray,S,j,L.tileID,d.scope),F.elevationType==="offset"&&this.buildingIndex&&this.buildingIndex.updateZOffset(F,L.tileID),F.elevationType==="road"&&F.updateRoadElevation(L.tileID.canonical),F.updateZOffset())}}updateBucketOpacities(d,g,S,j,R,L,F,z){d.hasTextData()&&d.text.opacityVertexArray.clear(),d.hasIconData()&&d.icon.opacityVertexArray.clear(),d.hasIconCollisionBoxData()&&d.iconCollisionBox.collisionVertexArray.clear(),d.hasTextCollisionBoxData()&&d.textCollisionBox.collisionVertexArray.clear();const W=d.layers[0].layout,Z=d.layers[0].paint,ne=!!d.layers[0].dynamicFilter(),re=new gp(null,0,!1,!1,!0),ie=W.get("text-allow-overlap"),ce=W.get("icon-allow-overlap"),le=W.get("text-variable-anchor"),ve=W.get("text-rotation-alignment")==="map",_e=W.get("text-pitch-alignment")==="map",Re=Z.get("symbol-z-offset"),Me=W.get("symbol-elevation-reference")==="sea",Te=!Re.isConstant(),Xe=new gp(null,0,ie&&(ce||!d.hasIconData()||W.get("icon-optional")),ce&&(ie||!d.hasTextData()||W.get("text-optional")),!0);!d.collisionArrays&&j&&(d.hasIconCollisionBoxData()||d.hasTextCollisionBoxData())&&d.deserializeCollisionBoxes(j);const $e=(De,Be,Ge)=>{for(let ot=0;ot0||ot>0,lr=St>0,Jt=this.placedOrientations[Je],er=Jt===a.bk.vertical,zt=Jt===a.bk.horizontal||Jt===a.bk.horizontalOnly;!Nt&&!lr||Et.isHidden()||Ke++;let Ir=!1;if((Nt||lr)&&L)for(const Or of d.activeReplacements){if(a.bz(Or,R,a.bA.Symbol,z)||Or.min.x>pt||pt>Or.max.x||Or.min.y>Ot||Ot>Or.max.y)continue;const vr=a.bB(pt,Ot,F.canonical,Or.footprintTileId.canonical);if(Ir=a.bC(vr,Or.footprint),Ir)break}if(Ir&&this.collisionIndex.markSymbolAsClipped(d.bucketInstanceId,Be.featureIndex),Nt){const Or=Ir?$h:ey(Et.text);$e(d.text,Ge,er?$h:Or),$e(d.text,ot,zt?$h:Or);const vr=Et.text.isHidden(),{leftJustifiedTextSymbolIndex:Ar,centerJustifiedTextSymbolIndex:Jr,rightJustifiedTextSymbolIndex:dn,verticalPlacedTextSymbolIndex:on}=Be,Tn=d.text.placedSymbolArray,Kr=vr||er?1:0;Ar>=0&&(Tn.get(Ar).hidden=Kr),Jr>=0&&(Tn.get(Jr).hidden=Kr),dn>=0&&(Tn.get(dn).hidden=Kr),on>=0&&(Tn.get(on).hidden=vr||zt?1:0);const En=this.variableOffsets[Je];En&&this.markUsedJustification(d,En.anchor,Be,Jt);const ln=this.placedOrientations[Je];ln&&(this.markUsedJustification(d,"left",Be,ln),this.markUsedOrientation(d,ln,Be))}if(lr){const Or=Ir?$h:ey(Et.icon),{placedIconSymbolIndex:vr,verticalPlacedIconSymbolIndex:Ar}=Be,Jr=d.icon.placedSymbolArray,dn=Et.icon.isHidden()?1:0;vr>=0&&($e(d.icon,St,er?$h:Or),Jr.get(vr).hidden=dn),Ar>=0&&($e(d.icon,Be.numVerticalIconVertices,zt?$h:Or),Jr.get(Ar).hidden=dn)}if(d.hasIconCollisionBoxData()||d.hasTextCollisionBoxData()){const Or=d.collisionArrays[De];if(Or){let vr=new a.P(0,0),Ar=!0;if(Or.textBox||Or.verticalTextBox){if(le){const dn=this.variableOffsets[Je];dn?(vr=Rl(dn.anchor,dn.width,dn.height,dn.textOffset,dn.textScale),ve&&vr._rotate(_e?this.transform.angle:-this.transform.angle)):Ar=!1}ne&&(Ar=!Et.clipped),Or.textBox&&yp(d.textCollisionBox.collisionVertexArray,Et.text.placed,!Ar||er,st,Me,vr.x,vr.y),Or.verticalTextBox&&yp(d.textCollisionBox.collisionVertexArray,Et.text.placed,!Ar||zt,st,Me,vr.x,vr.y)}const Jr=Ar&&!!(!zt&&Or.verticalIconBox);Or.iconBox&&yp(d.iconCollisionBox.collisionVertexArray,Et.icon.placed,Jr,st,Me,Be.hasIconTextFit?vr.x:0,Be.hasIconTextFit?vr.y:0),Or.verticalIconBox&&yp(d.iconCollisionBox.collisionVertexArray,Et.icon.placed,!Jr,st,Me,Be.hasIconTextFit?vr.x:0,Be.hasIconTextFit?vr.y:0)}}}if(d.fullyClipped=Ke===0,d.sortFeatures(this.transform.angle),this.retainedQueryData[d.bucketInstanceId]&&(this.retainedQueryData[d.bucketInstanceId].featureSortOrder=d.featureSortOrder),d.hasTextData()&&d.text.opacityVertexBuffer&&d.text.opacityVertexBuffer.updateData(d.text.opacityVertexArray),d.hasIconData()&&d.icon.opacityVertexBuffer&&d.icon.opacityVertexBuffer.updateData(d.icon.opacityVertexArray),d.hasIconCollisionBoxData()&&d.iconCollisionBox.collisionVertexBuffer&&d.iconCollisionBox.collisionVertexBuffer.updateData(d.iconCollisionBox.collisionVertexArray),d.hasTextCollisionBoxData()&&d.textCollisionBox.collisionVertexBuffer&&d.textCollisionBox.collisionVertexBuffer.updateData(d.textCollisionBox.collisionVertexArray),d.bucketInstanceId in this.collisionCircleArrays){const De=this.collisionCircleArrays[d.bucketInstanceId];d.placementInvProjMatrix=De.invProjMatrix,d.placementViewportMatrix=De.viewportMatrix,d.collisionCircleArray=De.circles,delete this.collisionCircleArrays[d.bucketInstanceId]}}symbolFadeChange(d){return this.fadeDuration===0?1:(d-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(d){return Math.max(0,(this.transform.zoom-d)/1.5)}hasTransitions(d){return d-this.lastPlacementChangeTimed}isStale(){return this.stale}setStale(){this.stale=!0}}function yp(v,d,g,S,j,R,L){v.emplaceBack(d?1:0,g?1:0,R||0,L||0,S,j?1:0),v.emplaceBack(d?1:0,g?1:0,R||0,L||0,S,j?1:0),v.emplaceBack(d?1:0,g?1:0,R||0,L||0,S,j?1:0),v.emplaceBack(d?1:0,g?1:0,R||0,L||0,S,j?1:0)}const C0=Math.pow(2,25),I0=Math.pow(2,24),dl=Math.pow(2,17),ba=Math.pow(2,16),U5=Math.pow(2,9),P0=Math.pow(2,8),$E=Math.pow(2,1);function ey(v){if(v.opacity===0&&!v.placed)return 0;if(v.opacity===1&&v.placed)return 4294967295;const d=v.placed?1:0,g=Math.floor(127*v.opacity);return g*C0+d*I0+g*dl+d*ba+g*U5+d*P0+g*$E+d}const $h=0;class zE{constructor(d){this._sortAcrossTiles=d.layout.get("symbol-z-order")!=="viewport-y"&&d.layout.get("symbol-sort-key").constantOr(1)!==void 0,this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs=new Set,this._bucketParts=[]}continuePlacement(d,g,S,j,R,L){const F=this._bucketParts;for(;this._currentTileIndexz.sortKey-W.sortKey));this._currentPartIndex{const z=a.o.now()-L;return!this.isFullPlacementRequested()&&this._fadeDuration!==0&&z>2};for(;this._currentPlacementIndex>=0;){const z=g[d[this._currentPlacementIndex]],W=this.placement.collisionIndex.transform.zoom;if(z.type==="symbol"&&z.visibility!=="none"&&(!z.minzoom||z.minzoom<=W)&&(!z.maxzoom||z.maxzoom>W)){const Z=z,ne=Z.layout.get("symbol-z-elevate"),re=Z.layout.get("symbol-sort-key").constantOr(1)!==void 0,ie=Z.layout.get("symbol-z-order"),ce=ie==="viewport-y"||ie==="auto"&&!(ie!=="viewport-y"&&re),le=Z.layout.get("text-allow-overlap")||Z.layout.get("icon-allow-overlap")||Z.layout.get("text-ignore-placement")||Z.layout.get("icon-ignore-placement"),ve=ce&&le,_e=this._inProgressLayer=this._inProgressLayer||new zE(Z),Re=a.F(z.source,z.scope);if(_e.continuePlacement(ne||ve?j[Re]:S[Re],this.placement,this._showCollisionBoxes,z,F,R))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._forceFullPlacement=!1,this._done=!0}commit(d){return this.placement.commit(d),this.placement}}const Ko=512/a.an/2;class Pu{constructor(d,g,S){this.tileID=d,this.bucketInstanceId=S,this.index=new a.bI(g.length,16,Int32Array),this.keys=[],this.crossTileIDs=[];const j=d.canonical.x*a.an,R=d.canonical.y*a.an;for(let L=0;Lve-_e);for(const ve of le){const _e=this.crossTileIDs[ve];if(this.keys[ve]===Z&&!S.has(_e)){S.add(_e),W.crossTileID=_e;break}}}}}class Yl{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class pI{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(d){const g=Math.round((d-this.lng)/360);if(g!==0)for(const S in this.indexes){const j=this.indexes[S],R={};for(const L in j){const F=j[L];F.tileID=F.tileID.unwrapTo(F.tileID.wrap+g),R[F.tileID.key]=F}this.indexes[S]=R}this.lng=d}addBucket(d,g,S){if(this.indexes[d.overscaledZ]&&this.indexes[d.overscaledZ][d.key]){if(this.indexes[d.overscaledZ][d.key].bucketInstanceId===g.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(d.overscaledZ,this.indexes[d.overscaledZ][d.key])}for(let R=0;Rd.overscaledZ)for(const F in L){const z=L[F];z.tileID.isChildOf(d)&&z.findMatches(g.symbolInstances,d,j)}else{const F=L[d.scaledTo(Number(R)).key];F&&F.findMatches(g.symbolInstances,d,j)}}for(let R=0;R{g[S]=!0});for(const S in this.layerIndexes)g[S]||delete this.layerIndexes[S]}}const Ui=771;class tn{constructor(d,g,S,j){this.blendFunction=d,this.blendColor=g.toNonPremultipliedRenderColor(null),this.mask=S,this.blendEquation=j}}tn.Replace=[1,0,1,0],tn.disabled=new tn(tn.Replace,a.aq.transparent,[!1,!1,!1,!1]),tn.unblended=new tn(tn.Replace,a.aq.transparent,[!0,!0,!0,!0]),tn.alphaBlended=new tn([1,Ui,1,Ui],a.aq.transparent,[!0,!0,!0,!0]),tn.alphaBlendedNonPremultiplied=new tn([770,Ui,770,Ui],a.aq.transparent,[!0,!0,!0,!0]),tn.multiply=new tn([774,0,774,0],a.aq.transparent,[!0,!0,!0,!0]),tn.multiplyAccumulateAlpha=new tn([774,0,1,Ui],a.aq.transparent,[!0,!0,!0,!0]),tn.additive=new tn([1,1,1,1],a.aq.transparent,[!0,!0,!0,!0]);class Lr{constructor(d,g,S){this.func=d,this.mask=g,this.range=S}}Lr.ReadOnly=!1,Lr.ReadWrite=!0,Lr.disabled=new Lr(519,Lr.ReadOnly,[0,1]);const da=7680;class an{constructor(d,g,S,j,R,L){this.test=d,this.ref=g,this.mask=S,this.fail=j,this.depthFail=R,this.pass=L}}an.disabled=new an({func:519,mask:0},0,0,da,da,da);const qc=1029,xp=2305;class Zr{constructor(d,g,S){this.enable=d,this.mode=g,this.frontFace=S}}function L0(v,d){const g=a.bO(v,3);a.bR(v,d),a.bW(v,3,g)}function jb(v,d){const g=a.bL([]);return a.bM(g,g,-d),a.bN(g,g,-v),g}function kb(v,d){const g=[v[0],v[1],0],S=[d[0],d[1],0];if(a.ai(g)>=1e-15){const L=a.ay([],g);a.bJ(S,L,a.bi(S,L)),d[0]=S[0],d[1]=S[1]}const j=a.bh([],d,v);if(a.bK(j)<1e-15)return null;const R=Math.atan2(-j[1],j[0]);return jb(Math.atan2(Math.sqrt(v[0]*v[0]+v[1]*v[1]),-v[2]),R)}Zr.disabled=new Zr(!1,qc,xp),Zr.backCCW=new Zr(!0,qc,xp),Zr.backCW=new Zr(!0,qc,2304),Zr.frontCW=new Zr(!0,1028,2304),Zr.frontCCW=new Zr(!0,1028,xp);class M0{constructor(d,g){this.position=d,this.orientation=g}get position(){return this._position}set position(d){if(d){const g=d instanceof a.ag?d:new a.ag(d[0],d[1],d[2]);this._renderWorldCopies&&(g.x=a.bs(g.x,0,1)),this._position=g}else this._position=null}lookAtPoint(d,g,S){if(this.orientation=null,!this.position)return;const j=this.position,R=S||(this._elevation?this._elevation.getAtPointOrZero(a.ag.fromLngLat(d)):0),L=a.ag.fromLngLat(d,R),F=[L.x-j.x,L.y-j.y,L.z-j.z];g||(g=[0,0,1]),g[2]=Math.abs(g[2]),this.orientation=kb(F,g)}setPitchBearing(d,g){this.orientation=jb(a.ap(d),a.ap(-g))}}class D0{constructor(d,g){this._transform=a.b9([]),this.orientation=g,this.position=d}get mercatorPosition(){const d=this.position;return new a.ag(d[0],d[1],d[2])}get position(){const d=a.bO(this._transform,3);return[d[0],d[1],d[2]]}set position(d){var g;d&&a.bW(this._transform,3,[(g=d)[0],g[1],g[2],1])}get orientation(){return this._orientation}set orientation(d){this._orientation=d||a.bL([]),d&&L0(this._transform,this._orientation)}getPitchBearing(){const d=this.forward(),g=this.right();return{bearing:Math.atan2(-g[1],g[0]),pitch:Math.atan2(Math.sqrt(d[0]*d[0]+d[1]*d[1]),-d[2])}}setPitchBearing(d,g){this._orientation=jb(d,g),L0(this._transform,this._orientation)}forward(){const d=a.bO(this._transform,2);return[-d[0],-d[1],-d[2]]}up(){const d=a.bO(this._transform,1);return[-d[0],-d[1],-d[2]]}right(){const d=a.bO(this._transform,0);return[d[0],d[1],d[2]]}getCameraToWorld(d,g){const S=new Float64Array(16);return a.b7(S,this.getWorldToCamera(d,g)),S}getCameraToWorldMercator(){return this._transform}getWorldToCameraPosition(d,g,S){const j=this.position;a.bJ(j,j,-d);const R=new Float64Array(16);return a.bP(R,[S,S,S]),a.bx(R,R,j),R[10]*=g,R}getWorldToCamera(d,g){const S=new Float64Array(16),j=new Float64Array(4),R=this.position;return a.bQ(j,this._orientation),a.bJ(R,R,-d),a.bR(S,j),a.bx(S,S,R),S[1]*=-1,S[5]*=-1,S[9]*=-1,S[13]*=-1,S[8]*=g,S[9]*=g,S[10]*=g,S[11]*=g,S}getCameraToClipPerspective(d,g,S,j){const R=new Float64Array(16);return a.bS(R,d,g,S,j),R}getCameraToClipOrthographic(d,g,S,j,R,L){const F=new Float64Array(16);return a.bT(F,d,g,S,j,R,L),F}getDistanceToElevation(d,g=!1){const S=d===0?0:a.bU(d,g?a.bV(this.position[1]):this.position[1]),j=this.forward();return(S-this.position[2])/j[2]}clone(){return new D0([...this.position],[...this.orientation])}}const V5=(v,d)=>({u_matrix:v,u_ground_shadow_factor:d});class ld{constructor(d=0,g=0,S=0,j=0){if(isNaN(d)||d<0||isNaN(g)||g<0||isNaN(S)||S<0||isNaN(j)||j<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=d,this.bottom=g,this.left=S,this.right=j}interpolate(d,g,S){return g.top!=null&&d.top!=null&&(this.top=a.am(d.top,g.top,S)),g.bottom!=null&&d.bottom!=null&&(this.bottom=a.am(d.bottom,g.bottom,S)),g.left!=null&&d.left!=null&&(this.left=a.am(d.left,g.left,S)),g.right!=null&&d.right!=null&&(this.right=a.am(d.right,g.right,S)),this}getCenter(d,g){const S=a.aC((this.left+d-this.right)/2,0,d),j=a.aC((this.top+g-this.bottom)/2,0,g);return new a.P(S,j)}equals(d){return this.top===d.top&&this.bottom===d.bottom&&this.left===d.left&&this.right===d.right}clone(){return new ld(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}const _p=15;class O0{constructor(d,g,S,j,R,L,F){this.tileSize=512,this._renderWorldCopies=R===void 0||R,this._minZoom=d||0,this._maxZoom=g||22,this._minPitch=S??0,this._maxPitch=j??60,this.setProjection(L),this.setMaxBounds(F),this.width=0,this.height=0,this._center=new a.aU(0,0),this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._nearZ=0,this._farZ=0,this._nearClipOffset=0,this._unmodified=!0,this._edgeInsets=new ld,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._expandedProjMatrixCache={},this._distanceTileDataCache={},this._camera=new D0,this._centerAltitude=0,this._averageElevation=0,this.cameraElevationReference="ground",this._pixelsPerMercatorPixel=1,this.globeRadius=0,this.globeCenterInViewSpace=[0,0,0],this._tileCoverLift=0,this.freezeTileCoverage=!1,this._horizonShift=.1,this._orthographicProjectionAtLowPitch=!1,this._allowWorldUnderZoom=!1}clone(){const d=new O0(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies,this.getProjection(),this.maxBounds);return d._elevation=this._elevation,d._centerAltitude=this._centerAltitude,d._centerAltitudeValidForExaggeration=this._centerAltitudeValidForExaggeration,d.tileSize=this.tileSize,d.mercatorFromTransition=this.mercatorFromTransition,d.width=this.width,d.height=this.height,d.cameraElevationReference=this.cameraElevationReference,d._center=this._center,d._setZoom(this.zoom),d._seaLevelZoom=this._seaLevelZoom,d.angle=this.angle,d._fov=this._fov,d._pitch=this._pitch,d._nearZ=this._nearZ,d._farZ=this._farZ,d._nearClipOffset=this._nearClipOffset,d._averageElevation=this._averageElevation,d._orthographicProjectionAtLowPitch=this._orthographicProjectionAtLowPitch,d._unmodified=this._unmodified,d._edgeInsets=this._edgeInsets.clone(),d._camera=this._camera.clone(),d._calcMatrices(),d.freezeTileCoverage=this.freezeTileCoverage,d.frustumCorners=this.frustumCorners,d._allowWorldUnderZoom=this._allowWorldUnderZoom,d}get isOrthographic(){return this.projection.name!=="globe"&&this._orthographicProjectionAtLowPitch&&this.pitch<_p}get elevation(){return this._elevation}set elevation(d){this._elevation!==d&&(this._elevation=d,this._updateCameraOnTerrain(),this._calcMatrices())}get nearClipOffset(){return this._nearClipOffset}set nearClipOffset(d){this._nearClipOffset=d,this._calcMatrices()}get depthOcclusionForSymbolsAndCircles(){return this.projection.name!=="globe"&&!this.isOrthographic}updateElevation(d,g=!1){const S=this._elevation&&this._elevation.exaggeration()!==this._centerAltitudeValidForExaggeration;(this._seaLevelZoom==null||S)&&this._updateCameraOnTerrain(),(d||S)&&this._constrainCamera(g),this._calcMatrices()}getProjection(){return a.aJ(this.projection,["name","center","parallels"])}setProjection(d){this.projectionOptions=d||{name:"mercator"};const g=this.projection?this.getProjection():void 0;this.projection=a.c0(this.projectionOptions);const S=this.getProjection(),j=!a.b6(g,S);return j&&this._calcMatrices(),this.mercatorFromTransition=!1,j}setOrthographicProjectionAtLowPitch(d){return this._orthographicProjectionAtLowPitch!==d&&(this._orthographicProjectionAtLowPitch=d,this._calcMatrices(),!0)}setMercatorFromTransition(){const d=this.projection.name;this.mercatorFromTransition=!0,this.projectionOptions={name:"mercator"},this.projection=a.c0({name:"mercator"});const g=d!==this.projection.name;return g&&this._calcMatrices(),g}get minZoom(){return this._minZoom}set minZoom(d){this._minZoom!==d&&(this._minZoom=d,this.zoom=Math.max(this.zoom,d))}get maxZoom(){return this._maxZoom}set maxZoom(d){this._maxZoom!==d&&(this._maxZoom=d,this.zoom=Math.min(this.zoom,d))}get minPitch(){return this._minPitch}set minPitch(d){this._minPitch!==d&&(this._minPitch=d,this.pitch=Math.max(this.pitch,d))}get maxPitch(){return this._maxPitch}set maxPitch(d){this._maxPitch!==d&&(this._maxPitch=d,this.pitch=Math.min(this.pitch,d))}get renderWorldCopies(){return this._renderWorldCopies&&this.projection.supportsWorldCopies===!0}set renderWorldCopies(d){d===void 0?d=!0:d===null&&(d=!1),this._renderWorldCopies=d}get worldSize(){return this.tileSize*this.scale}get cameraWorldSizeForFog(){const d=Math.max(this._camera.getDistanceToElevation(this._averageElevation),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(d))}get cameraWorldSize(){const d=Math.max(this._camera.getDistanceToElevation(this._averageElevation,!0),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(d))}get pixelsPerMeter(){return this.projection.pixelsPerMeter(this.center.lat,this.worldSize)}get cameraPixelsPerMeter(){return a.bU(1,this.center.lat)*this.cameraWorldSizeForFog}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new a.P(this.width,this.height)}get bearing(){return a.bs(this.rotation,-180,180)}set bearing(d){this.rotation=d}get rotation(){return-this.angle/Math.PI*180}set rotation(d){const g=-d*Math.PI/180;this.angle!==g&&(this._unmodified=!1,this.angle=g,this._calcMatrices(),this.rotationMatrix=a.c1(),a.c2(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(d){const g=a.aC(d,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==g&&(this._unmodified=!1,this._pitch=g,this._calcMatrices())}get aspect(){return this.width/this.height}get fov(){return this._fov/Math.PI*180}set fov(d){d=Math.max(.01,Math.min(60,d)),this._fov!==d&&(this._unmodified=!1,this._fov=a.ap(d),this._calcMatrices())}get fovX(){return this._fov}get fovY(){const d=1/Math.tan(.5*this.fovX);return 2*Math.atan(1/this.aspect/d)}get averageElevation(){return this._averageElevation}set averageElevation(d){this._averageElevation=d,this._calcFogMatrices(),this._distanceTileDataCache={}}get zoom(){return this._zoom}set zoom(d){const g=Math.min(Math.max(d,this.minZoom),this.maxZoom);this._zoom!==g&&(this._unmodified=!1,this._setZoom(g),this._updateSeaLevelZoom(),this._constrain(),this._calcMatrices())}_setZoom(d){this._zoom=d,this.scale=this.zoomScale(d),this.tileZoom=Math.floor(d),this.zoomFraction=d-this.tileZoom}get tileCoverLift(){return this._tileCoverLift}set tileCoverLift(d){this._tileCoverLift!==d&&(this._tileCoverLift=d)}_updateCameraOnTerrain(){const d=this.elevation?this.elevation.getAtPoint(this.locationCoordinate(this.center),Number.NEGATIVE_INFINITY):Number.NEGATIVE_INFINITY,g=this.elevation&&d===Number.NEGATIVE_INFINITY&&this.elevation.visibleDemTiles.length>0&&this.elevation.exaggeration()>0&&this._centerAltitudeValidForExaggeration;if(!this._elevation||d===Number.NEGATIVE_INFINITY&&(!g||!this._centerAltitude))return this._centerAltitude=0,this._seaLevelZoom=null,void(this._centerAltitudeValidForExaggeration=void 0);const S=this._elevation;g||this._centerAltitude&&this._centerAltitudeValidForExaggeration&&S.exaggeration()&&this._centerAltitudeValidForExaggeration!==S.exaggeration()?(this._centerAltitude=this._centerAltitude/this._centerAltitudeValidForExaggeration*S.exaggeration(),this._centerAltitudeValidForExaggeration=S.exaggeration()):(this._centerAltitude=d||0,this._centerAltitudeValidForExaggeration=S.exaggeration()),this._updateSeaLevelZoom()}_updateSeaLevelZoom(){if(this._centerAltitudeValidForExaggeration===void 0)return;const d=Math.max(0,(this.pixelsPerMeter*this._centerAltitude+this.cameraToCenterDistance)/this.worldSize);this._seaLevelZoom=this._zoomFromMercatorZ(d)}sampleAverageElevation(){if(!this._elevation)return 0;const d=this._elevation,g=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8]],S=this.horizonLineFromTop();let j=0,R=0;for(let L=0;L{const ve=a.ck(re,ne,ie,ce,le);z.has(ve)||(R.push(new a.aR(ne,re,ie,ce,le)),z.add(ve))};for(let ne=0;nere.canonical.z)continue;const ie=re.canonical,ce=re.overscaledZ,le=re.wrap,ve=1<0,Me=ie.y+10,Xe=re.wrap-(Re?0:1),$e=re.wrap+(_e?0:1),Ke=Re?ie.x-1:ve-1,De=_e?ie.x+1:0;if(L)S[0]<0?(W(ce,$e,ie.z,De,ie.y),S[1]<0&&Me&&(W(ce,le,ie.z,ie.x,ie.y+1),W(ce,$e,ie.z,De,ie.y+1)),S[1]>0&&Te&&(W(ce,le,ie.z,ie.x,ie.y-1),W(ce,$e,ie.z,De,ie.y-1))):S[0]>0?(W(ce,Xe,ie.z,Ke,ie.y),S[1]<0&&Me&&(W(ce,le,ie.z,ie.x,ie.y+1),W(ce,Xe,ie.z,Ke,ie.y+1)),S[1]>0&&Te&&(W(ce,le,ie.z,ie.x,ie.y-1),W(ce,Xe,ie.z,Ke,ie.y-1))):S[1]<0&&Me?W(ce,le,ie.z,ie.x,ie.y+1):Te&&W(ce,le,ie.z,ie.x,ie.y-1);else{const Be=re.visibleQuadrants;1&Be&&(W(ce,Xe,ie.z,Ke,ie.y),Te&&(W(ce,le,ie.z,ie.x,ie.y-1),W(ce,Xe,ie.z,Ke,ie.y-1))),2&Be&&(W(ce,$e,ie.z,De,ie.y),Te&&(W(ce,le,ie.z,ie.x,ie.y-1),W(ce,$e,ie.z,De,ie.y-1))),4&Be&&(W(ce,Xe,ie.z,Ke,ie.y),Me&&(W(ce,le,ie.z,ie.x,ie.y+1),W(ce,Xe,ie.z,Ke,ie.y+1))),8&Be&&(W(ce,$e,ie.z,De,ie.y),Me&&(W(ce,le,ie.z,ie.x,ie.y+1),W(ce,$e,ie.z,De,ie.y+1)))}}const Z=[];for(const ne of R)R.some(re=>ne.isChildOf(re))||Z.push(ne);if(R=Z.filter(ne=>!d.some(re=>!!(ne.overscaledZ{const _e=ve.canonical.x+.5-ie[0],Re=ve.canonical.y+.5-ie[1];return _e*_e+Re*Re{const Ke=a.ck(Me,Re,Te,Xe,$e);R.has(Ke)||(j.push(new a.aR(Re,Me,Te,Xe,$e)),R.add(Ke))},F=d.reduce((Re,Me)=>Math.max(Re,Me.overscaledZ),S),z=1<{const Te=Math.floor(Re[0]),Xe=Math.floor(Re[1]),$e=(Re[0]-Te)*a.an,Ke=(Re[1]-Xe)*a.an,De=Math.floor(Me[0]),Be=Math.floor(Me[1]),Ge=(Me[0]-De)*a.an,ot=(Me[1]-Be)*a.an;for(let Je=-1;Je<=1;Je++){const St=Te+Je;if(!(St<0||St>=z)){Z.x=$e-Je*a.an,ne.x=Ge-(St-De)*a.an;for(let pt=-1;pt<=1;pt++){const Ot=Xe+pt;Z.y=Ke-pt*a.an,ne.y=ot-(Ot-Be)*a.an,a.cI(Z,ne,W)&&L(F,0,S,St,Ot)}}}},ie=g.points,ce=ie[a.c9],le=ie[a.ca],ve=this._projectToGround(ce,ie[a.cb]),_e=this._projectToGround(le,ie[a.cc]);return re(ce,ve),re(le,_e),j}_projectToGround(d,g){return a.cd(a.ce(),d,g,d[2]/(d[2]-g[2]))}_projectToZ(d,g,S){const j=d[2]-g[2];return Math.abs(j)<1e-6?a.cf(d):a.cd(a.ce(),d,g,(d[2]-S)/j)}extendTileCoverForTunnels(d,g,S,j){if(S<18)return[];const R=g.points,L=R[a.cg],F=R[a.ch],z=R[a.ci],W=R[a.cj];if(z[2]>=0&&W[2]>=0||L[2]<=0||F[2]<=0)return[];const Z=z[2]<0?this._projectToZ(L,z,0):z,ne=W[2]<0?this._projectToZ(F,W,0):W,re=-j,ie=z[2]3&&(le.length=3),le}_findExtensionTilesInQuad(d,g,S,j){const R=[],L=new Set;for(const De of d)L.add(De.key);const F=d.reduce((De,Be)=>Math.max(De,Be.overscaledZ),g),z=1<{const Ge=De.canonical.x+.5-$e,ot=De.canonical.y+.5-Ke,Je=Be.canonical.x+.5-$e,St=Be.canonical.y+.5-Ke;return Ge*Ge+ot*ot-(Je*Je+St*St)||De.canonical.x-Be.canonical.x||De.canonical.y-Be.canonical.y}),R}coveringTiles(d){let g=this.coveringZoomLevel(d);const S=g,j=this.elevation&&this.elevation.exaggeration(),R=j&&!d.isTerrainDEM,L=this.projection.name==="mercator";if(d.minzoom!==void 0&&gd.maxzoom&&(g=d.maxzoom);const F=this.locationCoordinate(this.center),z=this.center.lat,W=1<{const Et=new a.ag(st.x+25e-6,st.y,st.z),Nt=new a.ag(st.x,st.y+25e-6,st.z),lr=st.toLngLat(),Jt=Et.toLngLat(),er=Nt.toLngLat(),zt=this.locationCoordinate(lr),Ir=this.locationCoordinate(Jt),Or=this.locationCoordinate(er),vr=Math.hypot(Ir.x-zt.x,Ir.y-zt.y),Ar=Math.hypot(Or.x-zt.x,Or.y-zt.y);return Math.sqrt(vr*Ar)*Ke/25e-6},Be=st=>{const vt=Xe,Et=$e;return{aabb:a.cp(this,W,0,0,0,st,Et,vt,this.projection),zoom:0,x:0,y:0,minZ:Et,maxZ:vt,wrap:st,fullyVisible:!1}},Ge=[];let ot=[];const Je=g,St=d.reparseOverscaled?S:g,pt=(ve-this._centerAltitude)*le,Ot=st=>{if(!this._elevation||!st.tileID||!L)return;const vt=this._elevation.getMinMaxForTile(st.tileID),Et=st.aabb;vt?(Et.min[2]=vt.min,Et.max[2]=vt.max,Et.center[2]=(Et.min[2]+Et.max[2])/2):(st.shouldSplit=ut(st),st.shouldSplit||(Et.min[2]=Et.max[2]=Et.center[2]=this._centerAltitude))},Ut=(st,vt)=>{if(.707*vt{if(st.zoom=.9)return!0}else if(R&&(Nt=st.aabb.distanceZ(_e)*le),this.projection.isReprojectedInTileSpace&&S<=5){const Ar=Math.pow(2,st.zoom),Jr=De(new a.ag((st.x+.5)/Ar,(st.y+.5)/Ar));lr=Jr>.85?1:Jr}if(!L&&!ne){const Ar=Math.sqrt(vt*vt+Et*Et+Nt*Nt);let Jr=(1<0;){const st=Ge.pop(),vt=st.x,Et=st.y;let Nt=st.fullyVisible;const lr=()=>this.projection.name==="globe"&&(st.y===0||st.y===(1<Jt)continue;let er=0;if(!Nt){let vr=Re?st.aabb.intersectsPrecise(ie):st.aabb.intersectsPreciseFlat(ie);if(vr===0&&lr()){const Ar=new a.cn(st.zoom,vt,Et);vr=a.co(this,W,Ar,!0).intersectsPrecise(ie)}if(vr===0)continue;if(d.calculateQuadrantVisibility)if(ie.containsPoint(st.aabb.center))er=15;else for(let Ar=0;Ar<4;Ar++)st.aabb.quadrant(Ar).intersects(ie)!==0&&(er|=1<>1),Ir={aabb:L?st.aabb.quadrant(Jt):a.cp(this,W,st.zoom+1,er,zt,st.wrap,st.minZ,st.maxZ,this.projection),zoom:st.zoom+1,x:er,y:zt,wrap:st.wrap,fullyVisible:Nt,tileID:void 0,shouldSplit:void 0,minZ:st.minZ,maxZ:st.maxZ};R&&!ne&&(Ir.tileID=new a.aR(st.zoom+1===Je?St:st.zoom+1,st.wrap,st.zoom+1,er,zt),Ot(Ir)),Ge.push(Ir)}}if(this.fogCullDistSq){const st=this.fogCullDistSq,vt=this.horizonLineFromTop();ot=ot.filter(Et=>{const Nt=[0,0,0,1],lr=[a.an,a.an,0,1],Jt=this.calculateFogTileMatrix(Et.tileID.toUnwrapped());a.aE(Nt,Nt,Jt),a.aE(lr,lr,Jt);const er=a.cq([],Nt,lr),zt=a.cr([],Nt,lr),Ir=a.cK(er,zt);if(Ir===0)return!0;let Or=!1;const vr=this._elevation;if(vr&&Ir>st&&vt!==0){const Ar=this.calculateProjMatrix(Et.tileID.toUnwrapped());let Jr;d.isTerrainDEM||(Jr=vr.getMinMaxForTile(Et.tileID)),Jr||(Jr={min:$e,max:Xe});const dn=a.cs(this.rotation),on=[dn[0]*a.an,dn[1]*a.an,Jr.max];a.ah(on,on,Ar),Or=(1-on[1])*this.height*.5st.distanceSq-vt.distanceSq).map(st=>st.tileID)}resize(d,g){this.width=d,this.height=g,this.pixelsToGLUnits=[2/d,-2/g],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(d){return Math.pow(2,d)}scaleZoom(d){return Math.log2(d)}project(d){const g=a.aC(d.lat,-a.ct,a.ct),S=this.projection.project(d.lng,g);return new a.P(S.x*this.worldSize,S.y*this.worldSize)}unproject(d){return this.projection.unproject(d.x/this.worldSize,d.y/this.worldSize)}get point(){return this.project(this.center)}get pointMerc(){return this.point._div(this.worldSize)}get pixelsPerMeterRatio(){return this.pixelsPerMeter/a.bU(1,this.center.lat)/this.worldSize}setLocationAtPoint(d,g){let S,j;const R=this.centerPoint;if(this.projection.name==="globe"){const F=this.worldSize;S=(g.x-R.x)/F,j=(g.y-R.y)/F}else{const F=this.pointCoordinate(g),z=this.pointCoordinate(R);S=F.x-z.x,j=F.y-z.y}const L=this.locationCoordinate(d);this.setLocation(new a.ag(L.x-S,L.y-j))}setLocation(d){this.center=this.coordinateLocation(d),this.projection.wrap&&(this.center=this.center.wrap())}locationPoint(d,g){return this.projection.locationPoint(this,d,g)}locationPoint3D(d,g){return this.projection.locationPoint(this,d,g,!0)}pointLocation(d){return this.coordinateLocation(this.pointCoordinate(d))}pointLocation3D(d,g){return this.coordinateLocation(this.pointCoordinate3D(d,g))}locationCoordinate(d,g){const S=g?a.bU(g,d.lat):void 0,j=this.projection.project(d.lng,d.lat);return new a.ag(j.x,j.y,S)}coordinateLocation(d){return this.projection.unproject(d.x,d.y)}pointRayIntersection(d,g){const S=g??this._centerAltitude,j=[d.x,d.y,0,1],R=[d.x,d.y,1,1];a.aE(j,j,this.pixelMatrixInverse),a.aE(R,R,this.pixelMatrixInverse);const L=R[3];a.cu(j,j,1/j[3]),a.cu(R,R,1/L);const F=j[2],z=R[2];return{p0:j,p1:R,t:F===z?0:(S-F)/(z-F)}}screenPointToMercatorRay(d){const g=[d.x,d.y,0,1],S=[d.x,d.y,1,1];return a.aE(g,g,this.pixelMatrixInverse),a.aE(S,S,this.pixelMatrixInverse),a.cu(g,g,1/g[3]),a.cu(S,S,1/S[3]),g[2]=a.bU(g[2],this._center.lat)*this.worldSize,S[2]=a.bU(S[2],this._center.lat)*this.worldSize,a.cu(g,g,1/this.worldSize),a.cu(S,S,1/this.worldSize),new a.az([g[0],g[1],g[2]],a.ay([],a.ax([],S,g)))}rayIntersectionCoordinate(d){const{p0:g,p1:S,t:j}=d,R=a.bU(g[2],this._center.lat),L=a.bU(S[2],this._center.lat);return new a.ag(a.am(g[0],S[0],j)/this.worldSize,a.am(g[1],S[1],j)/this.worldSize,a.am(R,L,j))}pointCoordinate(d,g=this._centerAltitude){return this.projection.pointCoordinate(this,d.x,d.y,g)}pointCoordinate3D(d,g){if(!this.elevation)return this.pointCoordinate(d,g);let S=this.projection.pointCoordinate3D(this,d.x,d.y);if(S)return new a.ag(S[0],S[1],S[2]);let j=0,R=this.horizonLineFromTop();if(d.y>R)return this.pointCoordinate(d,g);const L=.02*R,F=d.clone();for(let z=0;z<10&&R-j>L;z++){F.y=a.am(j,R,.66);const W=this.projection.pointCoordinate3D(this,F.x,F.y);W?(R=F.y,S=W):j=F.y}return S?new a.ag(S[0],S[1],S[2]):this.pointCoordinate(d)}isPointAboveHorizon(d){return this.projection.isPointAboveHorizon(this,d)}isPointOnSurface(d){if(d.y<0||d.y>this.height||d.x<0||d.x>this.width)return!1;if(this.elevation||this.zoom>=a.cv)return!this.isPointAboveHorizon(d);const g=this.pointCoordinate(d);return g.y>=0&&g.y<=1}_coordinatePoint(d,g){const S=g&&this.elevation?this.elevation.getAtPointOrZero(d,this._centerAltitude):this._centerAltitude,j=[d.x*this.worldSize,d.y*this.worldSize,S+d.toAltitude(),1];return a.aE(j,j,this.pixelMatrix),j[3]>0?new a.P(j[0]/j[3],j[1]/j[3]):new a.P(Number.MAX_VALUE,Number.MAX_VALUE)}_getBoundsNonRectangular(){const{top:d,left:g}=this._edgeInsets,S=this.height-this._edgeInsets.bottom,j=this.width-this._edgeInsets.right,R=this.pointLocation3D(new a.P(g,d)),L=this.pointLocation3D(new a.P(j,d)),F=this.pointLocation3D(new a.P(j,S)),z=this.pointLocation3D(new a.P(g,S));let W=Math.min(R.lng,L.lng,F.lng,z.lng),Z=Math.max(R.lng,L.lng,F.lng,z.lng),ne=Math.min(R.lat,L.lat,F.lat,z.lat),re=Math.max(R.lat,L.lat,F.lat,z.lat);const ie=Math.pow(2,-this.zoom)/16*270,ce=this.projection.name==="globe"?1:4,le=(ve,_e,Re,Me,Te)=>{const Xe=(ve+Re)/2,$e=(_e+Me)/2,Ke=new a.P(Xe,$e),{lng:De,lat:Be}=this.pointLocation3D(Ke),Ge=Math.max(0,W-De,ne-Be,De-Z,Be-re);W=Math.min(W,De),Z=Math.max(Z,De),ne=Math.min(ne,Be),re=Math.max(re,Be),(Teie)&&(le(ve,_e,Xe,$e,Te+1),le(Xe,$e,Re,Me,Te+1))};if(le(g,d,j,d,1),le(j,d,j,S,1),le(j,S,g,S,1),le(g,S,g,d,1),this.projection.name==="globe"){const[ve,_e]=a.cw(this);ve?(re=90,Z=180,W=-180):_e&&(ne=-90,Z=180,W=-180)}return new a.aK(new a.aU(W,ne),new a.aU(Z,re))}_getBoundsRectangular(d,g){const{top:S,left:j}=this._edgeInsets,R=this.height-this._edgeInsets.bottom,L=this.width-this._edgeInsets.right,F=new a.P(j,S),z=new a.P(L,S),W=new a.P(L,R),Z=new a.P(j,R);let ne=this.pointCoordinate(F,d),re=this.pointCoordinate(z,d);const ie=this.pointCoordinate(W,g),ce=this.pointCoordinate(Z,g),le=(ve,_e)=>(_e.y-ve.y)/(_e.x-ve.x);return ne.y>1&&re.y>=0?ne=new a.ag((1-ce.y)/le(ce,ne)+ce.x,1):ne.y<0&&re.y<=1&&(ne=new a.ag(-ce.y/le(ce,ne)+ce.x,0)),re.y>1&&ne.y>=0?re=new a.ag((1-ie.y)/le(ie,re)+ie.x,1):re.y<0&&ne.y<=1&&(re=new a.ag(-ie.y/le(ie,re)+ie.x,0)),new a.aK().extend(this.coordinateLocation(ne)).extend(this.coordinateLocation(re)).extend(this.coordinateLocation(ce)).extend(this.coordinateLocation(ie))}_getBoundsRectangularTerrain(){const d=this.elevation;if(!d.visibleDemTiles.length||d.isUsingMockSource())return this._getBoundsRectangular(0,0);const g=d.visibleDemTiles.reduce((S,j)=>{if(j.dem){const R=j.dem.tree;S.min=Math.min(S.min,R.minimums[0]),S.max=Math.max(S.max,R.maximums[0])}return S},{min:Number.MAX_VALUE,max:0});return this._getBoundsRectangular(g.min*d.exaggeration(),g.max*d.exaggeration())}getBounds(){return this.projection.name==="mercator"||this.projection.name==="equirectangular"?this._terrainEnabled()?this._getBoundsRectangularTerrain():this._getBoundsRectangular(0,0):this._getBoundsNonRectangular()}horizonLineFromTop(d=!0){const g=this.height/2/Math.tan(this._fov/2)/Math.tan(Math.max(this._pitch,.1))-this.centerOffset.y,S=this.height/2-g*(1-this._horizonShift);return d?Math.max(0,S):S}getMaxBounds(){return this.maxBounds}setMaxBounds(d){this.maxBounds=d,this.minLat=-a.ct,this.maxLat=a.ct,this.minLng=-180,this.maxLng=180,d&&(this.minLat=d.getSouth(),this.maxLat=d.getNorth(),this.minLng=d.getWest(),this.maxLng=d.getEast(),this.maxLngne&&(F=ne-W),ne-Zie&&(L=ie-z),ie-re{for(let ut=0;ut<16;ut++)St[ut]=a.am(pt[ut],Ot[ut],Ut)})(F,F,z,a.cL(this.pitch>=_p?1:this.pitch/_p))}else F=z;const W=a.cz([],z,L);let Z=a.cz([],F,L);if(this.projection.isReprojectedInTileSpace){const Be=this.locationCoordinate(this.center),Ge=a.b9([]);a.bx(Ge,Ge,[Be.x*this.worldSize,Be.y*this.worldSize,0]),a.aD(Ge,Ge,a.cA(this)),a.bx(Ge,Ge,[-Be.x*this.worldSize,-Be.y*this.worldSize,0]),a.aD(Z,Z,Ge),a.aD(W,W,Ge),this.inverseAdjustmentMatrix=a.cB(this)}else this.inverseAdjustmentMatrix=[1,0,0,1];if(this.mercatorMatrix=a.cC([],Z,[this.worldSize,this.worldSize,this.worldSize/R,1]),this.projMatrix=Z,this.invProjMatrix=a.b7(new Float64Array(16),this.projMatrix),g){const Be=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,1/0);Be[8]=2*-d.x/this.width,Be[9]=2*d.y/this.height,this.expandedFarZProjMatrix=a.cz([],Be,L)}else this.expandedFarZProjMatrix=this.projMatrix;const ne=a.b7([],F);this.frustumCorners=a.cD.fromInvProjectionMatrix(ne,this.horizonLineFromTop(),this.height),this.cameraFrustum=a.cl.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,0,!g);const re=new Float32Array(16);a.b9(re),a.cC(re,re,[1,-1,1]),a.cE(re,re,this._pitch),a.ba(re,re,this.angle);const ie=a.bS(new Float32Array(16),this._fov,this.width/this.height,this._nearZ,this._farZ);this.starsProjMatrix=a.b8(ie);const ce=(Math.PI/2-this._pitch)*(this.height/this._fov)*this._horizonShift;ie[8]=2*-d.x/this.width,ie[9]=2*(d.y+ce)/this.height,this.skyboxMatrix=a.aD(re,ie,re);const le=this.point,ve=le.x,_e=le.y,Re=this.width%2/2,Me=this.height%2/2,Te=Math.cos(this.angle),Xe=Math.sin(this.angle),$e=ve-Math.round(ve)+Te*Re+Xe*Me,Ke=_e-Math.round(_e)+Te*Me+Xe*Re,De=new Float64Array(Z);if(a.bx(De,De,[$e>.5?$e-1:$e,Ke>.5?Ke-1:Ke,0]),this.alignedProjMatrix=De,Z=a.bb(),a.cC(Z,Z,[this.width/2,-this.height/2,1]),a.bx(Z,Z,[1,-1,0]),this.labelPlaneMatrix=Z,Z=a.bb(),a.cC(Z,Z,[1,-1,1]),a.bx(Z,Z,[-1,-1,0]),a.cC(Z,Z,[2/this.width,2/this.height,1]),this.glCoordMatrix=Z,this.pixelMatrix=a.aD(new Float64Array(16),this.labelPlaneMatrix,W),this._calcFogMatrices(),this._distanceTileDataCache={},Z=a.b7(new Float64Array(16),this.pixelMatrix),!Z)throw new Error("failed to invert matrix");if(this.pixelMatrixInverse=Z,this.projection.name==="globe"||this.mercatorFromTransition){this.globeMatrix=a.cF(this);const Be=[this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]];this.globeCenterInViewSpace=a.ah(Be,Be,L),this.globeRadius=this.worldSize/2/Math.PI-1}else this.globeMatrix=Z;this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={},this._expandedProjMatrixCache={}}_calcFogMatrices(){this._fogTileMatrixCache={};const d=this.cameraWorldSizeForFog,g=this.cameraPixelsPerMeter,S=this._camera.position,j=1/this.height/this._pixelsPerMercatorPixel,R=[d,d,g];a.bJ(R,R,j),a.bJ(S,S,-1),a.cG(S,S,R);const L=a.bb();a.bx(L,L,S),a.cC(L,L,R),this.mercatorFogMatrix=L,this.worldToFogMatrix=this._camera.getWorldToCameraPosition(d,g,j)}_computeCameraPosition(d){const g=(d=d||this.pixelsPerMeter)/this.pixelsPerMeter,S=this._camera.forward(),j=this.point,R=this._mercatorZfromZoom(this._seaLevelZoom?this._seaLevelZoom:this._zoom)*g-d/this.worldSize*this._centerAltitude;return[j.x/this.worldSize-S[0]*R,j.y/this.worldSize-S[1]*R,d/this.worldSize*this._centerAltitude-S[2]*R]}_updateCameraState(){this.height&&(this._camera.setPitchBearing(this._pitch,this.angle),this._camera.position=this._computeCameraPosition())}_translateCameraConstrained(d){const g=this._maxCameraBoundsDistance()*Math.cos(this._pitch),S=this._camera.position[2],j=d[2];let R=1;this.projection.wrap&&(this.center=this.center.wrap()),j>0&&(R=Math.min((g-S)/j,1)),this._camera.position=a.bg([],this._camera.position,d,R),this._updateStateFromCamera()}_updateStateFromCamera(){const d=this._camera.position,g=this._camera.forward(),{pitch:S,bearing:j}=this._camera.getPitchBearing(),R=a.bU(this._centerAltitude,this.center.lat)*this._pixelsPerMercatorPixel,L=this._mercatorZfromZoom(this._maxZoom)*Math.cos(a.ap(this._maxPitch)),F=Math.max((d[2]-R)/Math.cos(S),L),z=this._zoomFromMercatorZ(F);a.bg(d,d,g,F),this._pitch=a.aC(S,a.ap(this.minPitch),a.ap(this.maxPitch)),this.angle=a.bs(j,-Math.PI,Math.PI),this._setZoom(a.aC(z,this._minZoom,this._maxZoom)),this._updateSeaLevelZoom(),this._center=this.coordinateLocation(new a.ag(d[0],d[1],d[2])),this._unmodified=!1,this._constrain(),this._calcMatrices()}_worldSizeFromZoom(d){return Math.pow(2,d)*this.tileSize}_mercatorZfromZoom(d){return this.cameraToCenterDistance/this._worldSizeFromZoom(d)}_minimumHeightOverTerrain(){const d=Math.min(this._seaLevelZoom!=null?this._seaLevelZoom:this._zoom,this._maxZoom)+4;return this._mercatorZfromZoom(d)}_zoomFromMercatorZ(d){return this.scaleZoom(this.cameraToCenterDistance/(Math.max(0,d)*this.tileSize))}zoomFromMercatorZAdjusted(d){let g=0,S=a.cv,j=0,R=1/0;for(;S-g>1e-6&&S>g;){const L=g+.5*(S-g),F=this.tileSize*Math.pow(2,L),z=this.getCameraToCenterDistance(this.projection,L,F),W=this.scaleZoom(z/(Math.max(0,d)*this.tileSize)),Z=Math.abs(L-W);ZW||re.y>1)return!0}return!1}isHorizonVisible(){return this.pitch+a.cH(this.fovAboveCenter)>88||this.anyCornerOffEdge(new a.P(0,0),new a.P(this.width,this.height))}zoomDeltaToMovement(d,g){const S=a.ai(a.ax([],this._camera.position,d)),j=this._zoomFromMercatorZ(S)+g;return S-this._mercatorZfromZoom(j)}getCameraPoint(){if(this.projection.name==="globe"){const d=function([g,S,j],R){const L=[g,S,j,1];a.aE(L,L,R);const F=L[3]=Math.max(L[3],1e-6);return L[0]/=F,L[1]/=F,L[2]/=F,L}([this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]],this.pixelMatrix);return new a.P(d[0],d[1])}{const d=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new a.P(0,d))}}getCameraToCenterDistance(d,g=this.zoom,S=this.worldSize){const j=a.cy(d,g,this.width,this.height,1024),R=d.pixelSpaceConversion(this.center.lat,S,j);let L=.5/Math.tan(.5*this._fov)*this.height*R;return this.isOrthographic&&(L=a.am(1,L,a.cL(this.pitch>=_p?1:this.pitch/_p))),L}getWorldToCameraMatrix(){const d=this._camera.getWorldToCamera(this.worldSize,this.projection.zAxisUnit==="meters"?this.pixelsPerMeter:1);return this.projection.name==="globe"&&a.aD(d,d,this.globeMatrix),d}getFrustum(d){return a.cl.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,d,this.projection.zAxisUnit==="meters")}}const Wa=(v,d)=>{if(d>0&&v.terrain&&a.w("Cutoff is currently disabled on terrain"),d<=0||v.terrain)return{shouldRenderCutoff:!1,uniformValues:{u_cutoff_params:[0,0,0,1]}};const g=v.transform,S=g.pitch,j=g.isLODDisabled(!1)?60:30;if(S0,uniformValues:{u_cutoff_params:[g._nearZ,g._farZ,(Z-g._nearZ)/R,(Z-re-g._nearZ)/R]}}},Kf=2048;class Ab{constructor(d,g){this.aabb=d,this.lastCascade=g}}class gI{add(d,g){const S=this.receivers[d.key];S!==void 0?(S.aabb.min[0]=Math.min(S.aabb.min[0],g.min[0]),S.aabb.min[1]=Math.min(S.aabb.min[1],g.min[1]),S.aabb.min[2]=Math.min(S.aabb.min[2],g.min[2]),S.aabb.max[0]=Math.max(S.aabb.max[0],g.max[0]),S.aabb.max[1]=Math.max(S.aabb.max[1],g.max[1]),S.aabb.max[2]=Math.max(S.aabb.max[2],g.max[2])):this.receivers[d.key]=new Ab(g,null)}clear(){this.receivers={}}get(d){return this.receivers[d.key]}computeRequiredCascades(d,g,S){const j=a.cU.fromPoints(d.points);let R=0;for(const L in this.receivers){const F=this.receivers[L];if(!F||!j.intersectsAabb(F.aabb))continue;F.aabb.min=j.closestPoint(F.aabb.min),F.aabb.max=j.closestPoint(F.aabb.max);const z=F.aabb.getCorners();for(let W=0;W1||re[1]<-1||re[1]>1){Z=!1;break}}if(F.lastCascade=W,R=Math.max(R,W),Z)break}}return R+1}}class F0{constructor(d){this.painter=d,this._enabled=!1,this._drawShadowAfterLayer=-1,this._numCascadesToRender=0,this._cascades=[],this._groundShadowTiles=[],this._receivers=new gI,this._depthMode=new Lr(d.context.gl.LEQUAL,Lr.ReadWrite,[0,1]),this._uniformValues={u_light_matrix_0:new Float32Array(16),u_light_matrix_1:new Float32Array(16),u_shadow_intensity:0,u_fade_range:[0,0],u_shadow_normal_offset:[1,1,1],u_shadow_texel_size:1,u_shadow_map_resolution:1,u_shadow_direction:[0,0,1],u_shadow_bias:[36e-5,.0012,.012],u_shadowmap_0:0,u_shadowmap_1:0},this._forceDisable=!1,this.useNormalOffset=!1}destroy(){for(const d of this._cascades)d.texture.destroy(),d.framebuffer.destroy();this._cascades=[]}updateShadowParameters(d,g){const S=this.painter;if(this._enabled=!1,this._drawShadowAfterLayer=-1,this._receivers.clear(),!g||!g.properties)return;const j=g.properties.get("shadow-intensity"),R=g.properties.get("shadow-draw-before-layer");if(!g.shadowsEnabled()||j<=0)return;let L=-1,F=0;for(const _e of S.style.order){const Re=S.style._mergedLayers[_e];Re.hasShadowPass()&&!Re.isHidden(d.zoom)&&(L=F),!R||R!==_e&&R!==Re.slot||(this._drawShadowAfterLayer=F>0?F-1:0),F+=1}if(this._enabled=L>=0,!this.enabled)return;this._drawShadowAfterLayer<0&&(this._drawShadowAfterLayer=L);const z=S.context,W=Kf,Z=Kf;if(this._cascades.length===0||Kf!==this._cascades[0].texture.size[0]){this._cascades=[];for(let _e=0;_e<2;++_e){const Re=z.gl,Me=z.createFramebuffer(W,Z,0,"texture"),Te=new a.T(z,{width:W,height:Z,data:null},Re.DEPTH_COMPONENT16);Me.depthAttachment.set(Te.texture),this._cascades.push({framebuffer:Me,texture:Te,matrix:[],far:0,boundingSphereRadius:0,frustum:new a.cl,scale:0})}}this.shadowDirection=yI(g);let ne=0;if(d.elevation){const _e=d.elevation,Re=[1e4,-1e4];_e.visibleDemTiles.filter(Me=>Me.dem).forEach(Me=>{const Te=Me.dem.tree;Re[0]=Math.min(Re[0],Te.minimums[0]),Re[1]=Math.max(Re[1],Te.maximums[0])}),Re[0]!==1e4&&(ne=(Re[1]-Re[0])*_e.exaggeration())}const re=1.5*d.cameraToCenterDistance,ie=3*re,ce=new Float64Array(16);for(let _e=0;_e=0)return{};const R=function(z,W,Z){const ne=Z/(1<0&&(a.cT(R[1],R[1],[j[0]*L,0,0]),a.cT(R[2],R[2],[j[0]*L,0,0])),j[1]<0?(a.cT(R[0],R[0],[0,j[1]*L,0]),a.cT(R[1],R[1],[0,j[1]*L,0])):j[1]>0&&(a.cT(R[2],R[2],[0,j[1]*L,0]),a.cT(R[3],R[3],[0,j[1]*L,0]));const F={};return F.vertices=R,F.planes=[Nb(R[1],R[0],R[4]),Nb(R[2],R[1],R[5]),Nb(R[3],R[2],R[6]),Nb(R[0],R[3],R[7])],F}addShadowReceiver(d,g,S){this._receivers.add(d,a.cU.fromTileIdAndHeight(d,g,S))}getMaxCascadeForTile(d){const g=this._receivers.get(d);return g&&g.lastCascade?g.lastCascade:0}}function Nb(v,d,g){const S=a.ax([],g,d),j=a.ax([],v,d),R=a.bh([],S,j),L=a.ai(R);return L===0?[0,0,1,0]:(a.bJ(R,R,1/L),[R[0],R[1],R[2],-a.bi(R,d)])}function yI(v){const d=v.properties.get("direction"),g=a.cP(d.x,d.y,d.z);g[2]=a.aC(g[2],0,75);const S=a.cR([g[0],g[1],g[2]]);return a.cQ(S.x,S.y,S.z)}function cd(v,d,g){const S=d.properties.get("color-use-theme")==="none",j=d.properties.get("color"),R=d.properties.get("intensity"),L=d.properties.get("direction"),F=[L.x,L.y,L.z],z=g.properties.get("color-use-theme")==="none",W=g.properties.get("color"),Z=g.properties.get("intensity"),ne=Math.max(a.bi([0,0,1],F),0),re=[0,0,0];a.bJ(re,W.toPremultipliedRenderColor(z?null:v.getLut(d.scope)).toArray01Linear().slice(0,3),Z);const ie=[0,0,0];return a.bJ(ie,j.toPremultipliedRenderColor(S?null:v.getLut(g.scope)).toArray01Linear().slice(0,3),ne*R),a.cW([re[0]>0?re[0]/(re[0]+ie[0]):0,re[1]>0?re[1]/(re[1]+ie[1]):0,re[2]>0?re[2]/(re[2]+ie[2]):0])}function B0(v,d,g,S,j,R){const L=v.zoom,F=v.scale,z=v.worldSize,W=1/z,Z=v.aspect,ne=Math.sqrt(1+Z*Z)*Math.tan(.5*v.fovX),re=ne*ne,ie=S-g,ce=S+g;let le,ve;re>ie/ce?(le=S,ve=S*ne):(le=.5*ce*(1+re),ve=.5*Math.sqrt(ie*ie+2*(S*S+g*g)*re+ce*ce*re*re));const _e=v.projection.pixelsPerMeter(v.center.lat,z),Re=v._camera.getCameraToWorldMercator(),Me=[0,0,-le*W];a.ah(Me,Me,Re);let Te=ve*W;const Xe=function(Nt){return Nt[0]/=F,Nt[1]/=F,Nt[2]=a.bU(Nt[2],v._center.lat),Nt},$e=v._edgeInsets;if(!($e.left===0&&$e.top===0&&$e.right===0&&$e.bottom===0||$e.left===$e.right&&$e.top===$e.bottom)){const Nt=v._camera.getWorldToCamera(v.worldSize,v.projection.zAxisUnit==="meters"?_e:1),lr=v._camera.getCameraToClipPerspective(v._fov,v.width/v.height,g,S);lr[8]=2*-v.centerOffset.x/v.width,lr[9]=2*v.centerOffset.y/v.height;const Jt=new Float64Array(16);a.cz(Jt,lr,Nt);const er=new Float64Array(16);a.b7(er,Jt);const zt=a.cl.fromInvProjectionMatrix(er,z,L,!0);for(const Ir of zt.points){const Or=Xe(Ir);Te=Math.max(Te,a.bK(a.cV([],Me,Or)))}}Te*=j/(j-1);const Ke=Math.acos(d[2]),De=Math.atan2(-d[0],-d[1]),Be=new D0;Be.position=Me,Be.setPitchBearing(Ke,De);const Ge=Be.getWorldToCamera(z,_e),ot=Te*z,Je=Math.min(v._mercatorZfromZoom(17)*z*-2,-2*ot),St=Be.getCameraToClipOrthographic(-ot,ot,-ot,ot,Je,(ot+R*_e)/d[2]),pt=new Float64Array(16);a.aD(pt,St,Ge);const Ot=a.cQ(Math.floor(1e6*Me[0])/1e6*z,Math.floor(1e6*Me[1])/1e6*z,0),Ut=.5*j,ut=[0,0,0];a.ah(ut,Ot,pt),a.bJ(ut,ut,Ut);const st=[Math.floor(ut[0]),Math.floor(ut[1]),Math.floor(ut[2])],vt=[0,0,0];a.ax(vt,ut,st),a.bJ(vt,vt,-1/Ut);const Et=new Float64Array(16);return a.b9(Et),a.bx(Et,Et,vt),a.aD(pt,Et,pt),[pt,ot]}class q5 extends a.E{constructor(d){super(),this.requestManager=d,this.models={"":{}},this.modelUris={"":{}},this.modelByURL={},this.numModelsLoading={}}loadModel(d,g){return a.cX(this.requestManager.transformRequest(g,a.R.Model).url).then(S=>{const j=a.cY(S),R=new a.cZ(d,g,void 0,void 0,j);return R.computeBoundsAndApplyParent(),R}).catch(S=>{if(S&&S.status===404)return null;this.fire(new a.B(new Error(`Could not load model ${d} from ${g}: ${S.message}`)))})}load(d,g,S={forceReload:!1}){this.models[g]||(this.models[g]={});const j=Object.keys(d),R=[],L=[];for(const F of j){const z=d[F];this.hasURLBeenRequested(z)&&!S.forceReload||(this.modelByURL[z]={modelId:F,scope:g},R.push(this.loadModel(F,z)),L.push(F)),this.models[g][F]||(this.models[g][F]={model:null,numReferences:1})}this.numModelsLoading[g]=(this.numModelsLoading[g]||0)+L.length,Promise.allSettled(R).then(F=>{for(let z=0;z{this.fire(new a.B(new Error(`Could not load models: ${F.message}`)))})}isLoaded(){for(const d in this.numModelsLoading)if(this.numModelsLoading[d]>0)return!1;return!0}hasModel(d,g,S={exactIdMatch:!1}){return!!(S.exactIdMatch?this.getModel(d,g):this.getModelByURL(this.modelUris[g][d]))}getModel(d,g){return this.models[g]||(this.models[g]={}),this.models[g][d]?this.models[g][d].model:void 0}getModelByURL(d){if(!d)return null;const g=this.modelByURL[d];return g?this.models[g.scope][g.modelId].model:null}hasModelBeenAdded(d,g){return this.models[g]&&this.models[g][d]!==void 0}getModelURIs(d){return this.modelUris[d]||{}}addModel(d,g,S){this.models[S]||(this.models[S]={}),this.modelUris[S]||(this.modelUris[S]={});const j=this.requestManager.normalizeModelURL(g);if((this.hasModel(d,S,{exactIdMatch:!0})||this.hasModelBeenAdded(d,S))&&this.modelUris[S][d]===j)this.models[S][d].numReferences++;else if(this.hasURLBeenRequested(j)){const{scope:R,modelId:L}=this.modelByURL[j];this.models[R][L].numReferences++}else this.modelUris[S][d]=j,this.load({[d]:this.modelUris[S][d]},S)}addModelURLs(d,g){this.models[g]||(this.models[g]={}),this.modelUris[g]||(this.modelUris[g]={});const S=this.modelUris[g];for(const j in d)S[j]=this.requestManager.normalizeModelURL(d[j])}reloadModels(d){this.load(this.modelUris[d],d,{forceReload:!0})}addModelsFromBucket(d,g){this.models[g]||(this.models[g]={}),this.modelUris[g]||(this.modelUris[g]={});const S={};for(const j of d)this.hasModel(j,g,{exactIdMatch:!0})||this.hasURLBeenRequested(j)?this.models[g][j].numReferences++:this.modelUris[g][j]&&!this.hasURLBeenRequested(j)?S[j]=this.modelUris[g][j]:!this.hasURLBeenRequested(j)&&a.c_(j,!1)&&(this.modelUris[g][j]=this.requestManager.normalizeModelURL(j),S[j]=this.modelUris[g][j]);this.load(S,g)}hasURLBeenRequested(d){return this.modelByURL[d]!==void 0}removeModel(d,g,S=!1,j=!1){if(this.models[g]&&this.models[g][d]&&(this.models[g][d].numReferences--,this.models[g][d].numReferences===0||j)){const R=this.modelUris[g][d];S||delete this.modelUris[g][d],delete this.modelByURL[R];const L=this.models[g][d].model;if(!L)return;delete this.models[g][d],L.destroy()}}destroy(){for(const d of Object.keys(this.models))for(const g of Object.keys(this.models[d])){const S=this.models[d][g].model;delete this.models[d][g],S&&S.destroy()}this.models={"":{}},this.modelUris={"":{}},this.modelByURL={},this.numModelsLoading={}}listModels(d){return this.models[d]||(this.models[d]={}),Object.keys(this.models[d])}upload(d,g){this.models[g]||(this.models[g]={});for(const S in this.models[g])this.models[g][S].model&&this.models[g][S].model.upload(d.context)}}const UE=a.a8.colorTheme,ry=new a.ab({data:new a.ac(UE.data)});function xI(v){if(!v.metadata||!v.metadata.content_area)return;const d=a.o.devicePixelRatio,{left:g,top:S,width:j,height:R}=v.metadata.content_area,L=g*d,F=S*d;return[L,F,L+j*d,F+R*d]}function $0(v){if(v)return v.map(([d,g])=>[d*a.o.devicePixelRatio,g*a.o.devicePixelRatio])}class VE{constructor(d,g,S){this.id=d,this.scope=g,this.sourceCache=S,this.pendingRequests=new Set,this.missingRequests=new Set}addPendingRequest(d){this.missingRequests.has(d.name)||this.pendingRequests.has(d.name)||this.pendingRequests.add(d.name)}hasPendingRequests(){return this.pendingRequests.size>0}resolvePendingRequests(){const d=new Map;if(!this.sourceCache.loaded())return d;const g=this.sourceCache.getVisibleCoordinates();if(g.length===0)return d;const S=this.sourceCache.getSource();if(!(S instanceof fp))return d;const j=g.map(L=>this.sourceCache.getTile(L)),R=S.getImages(j,Array.from(this.pendingRequests));for(const[L,F]of R)d.set(a.I.from({name:L,iconsetId:this.id}),F),this.pendingRequests.delete(L);for(const L of this.pendingRequests)this.missingRequests.add(L);return this.pendingRequests.clear(),d}}class Yf{constructor(){this._previousClosestBuildingId=null,this._hysteresisRatio=.8,this._indoorMinimumZoom=16}findClosestBuilding(d,g,S,j,R){if(Sz*this._hysteresisRatio&&(L=this._previousClosestBuildingId):W&&!L&&(L=this._previousClosestBuildingId),this._previousClosestBuildingId=L,L}_calculateDistance(d,g){if(!g.center)return Number.MAX_VALUE;const S=d.lat-g.center[1],j=d.lng-g.center[0];return S*S+j*j}_isBuildingVisible(d,g,S){if(!S)return!1;for(const j of d.floorIds){const R=d.floors[j];if(!R.geometry)continue;const L=R.geometry;if(L.type==="Polygon"){const F=this._convertRingToPoints(L.coordinates[0]);if(a.bw(F,S))return!0}else if(L.type==="MultiPolygon"){const F=this._convertMultiPolygonToPoints(L.coordinates);if(a.d0(S,F))return!0}}return!1}_convertRingToPoints(d){return d.map(g=>new a.P(g[0],g[1]))}_convertMultiPolygonToPoints(d){return d.map(g=>g.length===0?[]:g[0].map(S=>new a.P(S[0],S[1])))}}class G5 extends a.E{constructor(d){super(),this._style=d,this._buildings={},this._activeFloors=new Set,this._closestBuildingId=null,this._indoorState={selectedFloorId:null,activeFloorsVisible:!0,activeFloors:this._activeFloors},this._buildingDetectionStrategy=new Yf,this._initialLoadDone=!1,a.aZ(["_updateUI"],this),this._style.on("style.load",()=>{this._style.isIndoorEnabled()&&(this._style.map.on("load",()=>{this._initialLoadDone=!0,this._indoorState&&this._indoorState.needsUpdate&&(this._indoorState.needsUpdate=!1,this._style.updateIndoorDependentLayers()),this._updateUI()}),this._style.map.on("move",this._updateUI),this._style.map.on("idle",this._updateUI))})}destroy(){this._buildings={},this._activeFloors=new Set,this._indoorState=null}selectFloor(d){d===this._selectedFloorId&&this._indoorState&&this._indoorState.activeFloorsVisible||(this._selectedFloorId=d,this._recalculateActiveFloors())}setActiveFloorsVisibility(d){this._updateActiveFloors(d),this._updateIndoorSelector()}setIndoorData(d){let g=!1;for(const[S,j]of Object.entries(d.buildings))if(this._buildings[S])for(const R of j.floorIds)this._buildings[S].floorIds.add(R),this._buildings[S].floors[R]?this._mergeFloors(this._buildings[S].floors[R],j.floors[R]):(this._buildings[S].floors[R]=j.floors[R],g=!0);else this._buildings[S]=j,g=!0;g&&this._recalculateActiveFloors()}getIndoorTileOptions(d,g){return this._indoorState?{sourceLayers:this._style.getIndoorSourceLayers(d,g),indoorState:this._indoorState}:null}getControlState(){const d=this._buildings,g=this._closestBuildingId,S=g&&d?d[g]:void 0;if(!S)return{selectedFloorId:null,activeFloorsVisible:!!this._indoorState&&this._indoorState.activeFloorsVisible,floors:[]};let j=null;for(const L of S.floorIds)if(this._activeFloors&&this._activeFloors.has(L)){j=L;break}const R=Array.from(S.floorIds).map(L=>({id:L,name:S.floors[L].name,zIndex:S.floors[L].zIndex})).sort((L,F)=>F.zIndex-L.zIndex).filter((L,F,z)=>F===0||L.zIndex!==z[F-1].zIndex);return{selectedFloorId:j,activeFloorsVisible:!!this._indoorState&&this._indoorState.activeFloorsVisible,floors:R}}_updateUI(){this._initialLoadDone=!0;const d=this._style.map.transform,g=this._buildingDetectionStrategy.findClosestBuilding(this._buildings,d.center,d.zoom,d.getBounds(),this._makeViewportPolygon());if(g!==this._closestBuildingId){const S=this._closestBuildingId;this._closestBuildingId=g,this._onBuildingTransition(S,g),this._updateIndoorSelector()}}_onBuildingTransition(d,g){if(!this._indoorState)return;!g&&d?(this._indoorState.activeFloors=new Set,this._indoorState.activeFloorsVisible=!1,this._style.updateIndoorDependentLayers()):!!g&&!d&&(this._recalculateActiveFloors(),this._updateActiveFloors(!0))}_updateIndoorSelector(){this.fire(new a.C("selector-update",this.getControlState()))}_updateActiveFloors(d){this._indoorState={selectedFloorId:this._selectedFloorId,activeFloorsVisible:d,activeFloors:this._activeFloors},this._initialLoadDone?this._style.updateIndoorDependentLayers():this._indoorState.needsUpdate=!0}_recalculateActiveFloors(){if(!this._buildings)return;const d=a.d1.calculate(this._buildings,this._selectedFloorId,this._activeFloors);(function(g,S){if(g===S)return!0;if(!g||!S||g.size!==S.size)return!1;for(const j of g)if(!S.has(j))return!1;return!0})(d,this._activeFloors)||(this._activeFloors=d,this._updateActiveFloors(!!this._indoorState&&this._indoorState.activeFloorsVisible),this._updateIndoorSelector())}_mergeFloors(d,g){g.geometry&&(d.geometry?(d.geometry.type==="Polygon"&&(d.geometry={type:"MultiPolygon",coordinates:[d.geometry.coordinates]}),g.geometry.type==="Polygon"?d.geometry.coordinates.push(g.geometry.coordinates):g.geometry.type==="MultiPolygon"&&d.geometry.coordinates.push(...g.geometry.coordinates)):d.geometry=g.geometry)}_makeViewportPolygon(){const d=this._style.map.transform,g=d.width,S=d.height;return[d.pointLocation(new a.P(0,0)),d.pointLocation(new a.P(g,0)),d.pointLocation(new a.P(g,S)),d.pointLocation(new a.P(0,S))].map(j=>new a.P(j.lng,j.lat))}}const vp=(v,d)=>gr(v,d&&d.filter(g=>g.identifier!=="source.canvas")),H5=a.aJ(cs,["addLayer","removeLayer","setLights","setPaintProperty","setLayoutProperty","setLayerProperty","setSlot","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setSnow","setRain","setProjection","setCamera","addImport","removeImport","updateImport","addIconset","removeIconset"]),_I=a.aJ(cs,["setCenter","setZoom","setBearing","setPitch"]),qE=new Set(["background","sky","slot","custom"]),Cb={version:8,layers:[],sources:{}},GE={duration:300,delay:0};class Ru extends a.E{constructor(d,g={}){if(super(),this.map=d,this.scope=g.scope||"",this.globalId=null,this.fragments=[],this.importDepth=g.importDepth||0,this.importsCache=g.importsCache||new Map,this.resolvedImports=g.resolvedImports||new Set,this.transition=Object.assign({},GE),this._buildingIndex=new k0(this),this.crossTileSymbolIndex=new ty,this._mergedOrder=[],this._drapedFirstOrder=[],this._mergedLayers={},this._mergedIndoor={},this._mergedSourceCaches={},this._mergedOtherSourceCaches={},this._mergedSymbolSourceCaches={},this._mergedFillExtrusionSourceCaches={},this._clipLayerPresent=!1,this._hasAppearances=!1,this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this._importedAsBasemap=!1,this._changes=g.styleChanges||new Nn,this._hasDataDrivenEmissive=!1,this.indoorManager=new G5(this),this.dispatcher=g.dispatcher?g.dispatcher:new Kt(yn(),this),this.map.painter&&this.map.painter.context){const j=this.map.painter.context.maxUniformBufferBindings,R=Math.floor(this.map.painter.context.maxUniformBlockSize/4);this.dispatcher.broadcast("setContextParams",{maxBindingPoints:j,maxUniformBlockSizeDwords:R,disableSymbolUBO:this.map.painter.context.disableSymbolUBO})}g.imageManager?this.imageManager=g.imageManager:(this.imageManager=new Gn(this.map._spriteFormat),this.imageManager.setEventedParent(this)),this.imageManager.addScope(this.scope),this.glyphManager=g.glyphManager?g.glyphManager:new a.d2(d._requestManager,g.localFontFamily?a.d3.all:g.localIdeographFontFamily?a.d3.ideographs:a.d3.none,g.localFontFamily||g.localIdeographFontFamily,g.useServerFontComposition),g.modelManager?this.modelManager=g.modelManager:(this.modelManager=new q5(d._requestManager),this.modelManager.setEventedParent(this)),this._layers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this._fillExtrusionSourceCaches={},this._loaded=!1,this._precompileDone=!1,this._shouldPrecompile=!1,this._availableImages=[],this._availableModels={},this._order=[],this._markersNeedUpdate=!1,this.options=g.configOptions?g.configOptions:new Map,this._configDependentLayers=g.configDependentLayers?g.configDependentLayers:new Set,this._indoorDependentLayers=g.indoorDependentLayers?g.indoorDependentLayers:new Set,this._config=g.config,this._styleColorTheme={lut:null,lutLoading:!1,lutLoadingCorrelationID:0,colorTheme:null,colorThemeOverride:g.colorThemeOverride},this._styleColorThemeForScope={},this._initialConfig=g.initialConfig,this.dispatcher.broadcast("setReferrer",a.d4()),this.dispatcher.broadcast("setConfig",a.d5());const S=this;this._rtlTextPluginCallback=Ru.registerForPluginStateChange(j=>{S.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:j.pluginStatus,pluginURL:j.pluginURL},(R,L)=>{if(a.d6(R),L&&L.every(F=>F))for(const F in S._sourceCaches){const z=S._sourceCaches[F],W=z.getSource().type;W!=="vector"&&W!=="geojson"||z.reload()}})}),this.on("data",j=>{if(j.dataType!=="source"||j.sourceDataType!=="metadata")return;const R=this.getOwnSource(j.sourceId);if(R&&R.vectorLayerIds)for(const L in this._layers){const F=this._layers[L];F.source===R.id&&this._validateLayer(F)}})}load(d){return d?(typeof d=="string"?this.loadURL(d):this.loadJSON(d),this):this}_getGlobalId(d){if(!d)return null;if(typeof d=="string"){if(a.e(d))return d;const g=a.d7(d);if(!g.startsWith("http"))try{return new URL(g,location.href).toString()}catch{return g}return g}return`json://${a.d8(JSON.stringify(d))}`}_diffStyle(d,g,S){this.globalId=this._getGlobalId(d);const j=(R,L)=>{try{L(null,this.setState(R,S))}catch(F){L(F,!1)}};if(typeof d=="string"){const R=this.map._requestManager.normalizeStyleURL(d),L=this.map._requestManager.transformRequest(R,a.R.Style);a.m(L,(F,z)=>{F?this.fire(new a.B(F)):z&&j(z,g)})}else typeof d=="object"&&j(d,g)}loadURL(d,g={}){this.fire(new a.C("dataloading",{dataType:"style"}));const S=typeof g.validate=="boolean"?g.validate:!a.e(d);this.globalId=this._getGlobalId(d),d=this.map._requestManager.normalizeStyleURL(d,g.accessToken),this.resolvedImports.add(d);const j=this.importsCache.get(d);if(j)return this._load(j,S);const R=this.map._requestManager.transformRequest(d,a.R.Style);this._request=a.m(R,(L,F)=>{if(this._request=null,L)this.fire(new a.B(L));else if(F)return this.importsCache.set(d,F),this._load(F,S)})}loadJSON(d,g={}){this.fire(new a.C("dataloading",{dataType:"style"})),this.globalId=this._getGlobalId(d),this._request=a.o.frame(()=>{this._request=null,this._load(d,g.validate!==!1)})}loadEmpty(){this.fire(new a.C("dataloading",{dataType:"style"})),this._load(Cb,!1)}_loadImports(d,g,S){if(this.importDepth>=4)return a.w("Style doesn't support nesting deeper than 5"),Promise.resolve();const j=[];for(const R of d){const L=this._createFragmentStyle(R),F=new Promise(Z=>{L.once("style.import.load",Z),L.once("error",Z)}).then(()=>{this.mergeAll(),this.fire(new a.C("data",{dataType:"style"}))});if(j.push(F),this.resolvedImports.has(R.url)){L.loadEmpty();continue}const z=R.data||this.importsCache.get(R.url);z?(R.data?(L.fire(new a.C("dataloading",{dataType:"style"})),L.globalId=L._getGlobalId(z),queueMicrotask(()=>L._load(z,g))):L.loadJSON(z,{validate:g}),this._isInternalStyle(z)&&(L.globalId=null)):R.url?L.loadURL(R.url,{validate:g}):L.loadEmpty();const W={style:L,id:R.id,config:R.config};if(S){const Z=this.fragments.findIndex(({id:ne})=>ne===S);this.fragments=this.fragments.slice(0,Z).concat(W).concat(this.fragments.slice(Z))}else this.fragments.push(W)}return Promise.allSettled(j)}getImportGlobalIds(d=this,g=new Set){for(const S of d.fragments)S.style.globalId&&g.add(S.style.globalId),this.getImportGlobalIds(S.style,g);return[...g.values()]}_createFragmentStyle(d){const g=this.scope?a.F(d.id,this.scope):d.id;let S;const j=this._initialConfig&&this._initialConfig[g];(d.config||j)&&(S=Object.assign({},d.config,j));const R=new Ru(this.map,{scope:g,styleChanges:this._changes,importDepth:this.importDepth+1,importsCache:this.importsCache,resolvedImports:new Set(this.resolvedImports),dispatcher:this.dispatcher,imageManager:this.imageManager,glyphManager:this.glyphManager,modelManager:this.modelManager,config:S,configOptions:this.options,colorThemeOverride:d["color-theme"],configDependentLayers:this._configDependentLayers,indoorDependentLayers:this._indoorDependentLayers});return R.setEventedParent(this.map,{style:R}),R}_reloadImports(){this.mergeAll(),this._updateMapProjection(),this.updateConfigDependencies(),this._updateLayers(this._indoorDependentLayers),this.map._triggerCameraUpdate(this.camera),this.dispatcher.broadcast("setLayers",{layers:this._serializeLayers(this._order),scope:this.scope,options:this.options}),this._shouldPrecompile=this.map._precompilePrograms&&this.isRootStyle()}_isInternalStyle(d){return this.isRootStyle()&&(d.fragment||!!d.schema&&d.fragment!==!1)}_load(d,g){if(this._isInternalStyle(d)){const R=Object.assign({},Cb,{imports:[{id:"basemap",data:d,url:""}]},d.center?{center:d.center}:{},d.bearing?{bearing:d.bearing}:{},d.pitch?{pitch:d.pitch}:{},d.zoom?{zoom:d.zoom}:{},d.light?{light:d.light}:{});return this._importedAsBasemap=!0,void this._load(R,g)}if(this.updateConfig(this._config,d.schema),g&&vp(this,yc(d)))return;this._loaded=!0;for(const R in d.sources)this.addSource(R,d.sources[R],{validate:!1,isInitialLoad:!0});this.stylesheet=a.d9(d);const S=()=>{if(d.iconsets)for(const z in d.iconsets)this.addIconset(z,d.iconsets[z]);d.sprite?this._loadIconset(d.sprite):(this.imageManager.setLoaded(!0,this.scope),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0})),!this.glyphManager.url&&d.glyphs&&this.glyphManager.setURL(d.glyphs);const R=ME(this.stylesheet.layers);if(this._order=R.map(z=>z.id),this.stylesheet.light&&a.w("The `light` root property is deprecated, prefer using `lights` with `flat` light type instead."),this.stylesheet.lights)if(this.stylesheet.lights.length===1&&this.stylesheet.lights[0].type==="flat"){const z=this.stylesheet.lights[0];this.light=new hr(z.properties,z.id)}else this.setLights(this.stylesheet.lights);this.light||(this.light=new hr(this.stylesheet.light)),this._layers={};for(const z of R){const W=a.de(z,this.scope,this._styleColorTheme.lut,this.options);W.expressionDependencies.configDependencies.size!==0&&this._configDependentLayers.add(W.fqid),W.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(W.fqid),this._hasAppearances=this._hasAppearances||W.getAppearances().length!==0,W.setEventedParent(this,{layer:{id:W.id}}),this._layers[W.id]=W;const Z=this.getOwnLayerSourceCache(W),ne=!!this.directionalLight&&this.directionalLight.shadowsEnabled();Z&&W.canCastShadows()&&ne&&(Z.castsShadows=!0)}if(this.glyphManager.url){const z=new Set;for(const W in this._layers){const Z=this._layers[W];if(Z.type==="symbol"&&Z.layout){const ne=Z.layout.get("text-font");ne&&ne.value&&ne.value.kind==="constant"&&z.add(ne.value.value.join(","))}}for(const W of z)this.glyphManager.prefetchRange(W,0)}this.stylesheet.featuresets&&this.setFeaturesetSelectors(this.stylesheet.featuresets),this.stylesheet.models&&this.addModelURLs(this.stylesheet.models);const L=this.stylesheet.terrain;L&&(this.checkCanvasFingerprintNoise(),this.disableElevatedTerrain||this.terrainSetForDrapingOnly()||this._createTerrain(L,1)),this.stylesheet.fog&&this._createFog(this.stylesheet.fog),this.stylesheet.snow&&this._createSnow(this.stylesheet.snow),this.stylesheet.rain&&this._createRain(this.stylesheet.rain),this.stylesheet.transition&&this.setTransition(this.stylesheet.transition),this.fire(new a.C("data",{dataType:"style"}));const F=this.isRootStyle();d.imports?this._loadImports(d.imports,g).then(()=>{this._reloadImports(),this.fire(new a.C(F?"style.load":"style.import.load"))}).catch(z=>{this.fire(new a.B(new Error("Failed to load imports",z))),this.fire(new a.C(F?"style.load":"style.import.load"))}):(this._reloadImports(),this.fire(new a.C(F?"style.load":"style.import.load")))};this._styleColorTheme.colorTheme=this.stylesheet["color-theme"];const j=this._styleColorTheme.colorThemeOverride?this._styleColorTheme.colorThemeOverride:this._styleColorTheme.colorTheme;if(j){const R=this._evaluateColorThemeData(j);this._loadColorTheme(R).then(()=>{S()}).catch(L=>{a.w(`Couldn't load color theme from the stylesheet: ${L}`),S()})}else this._styleColorTheme.lut=null,S()}isRootStyle(){return this.importDepth===0}hasAppearances(){return this._hasAppearances||this.fragments.some(d=>d.style.hasAppearances())}mergeAll(){let d,g,S,j,R,L,F,z,W,Z;const ne={};this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle(re=>{if(re.stylesheet){if(re.light!=null&&(d=re.light),re.stylesheet.lights)for(const ie of re.stylesheet.lights)ie.type==="ambient"&&re.ambientLight!=null&&(g=re.ambientLight),ie.type==="directional"&&re.directionalLight!=null&&(S=re.directionalLight);j=this._prioritizeTerrain(j,re.terrain,re.stylesheet.terrain),re.stylesheet.fog&&re.fog!=null&&(R=re.fog),re.stylesheet.snow&&re.snow!=null&&(L=re.snow),re.stylesheet.rain&&re.rain!=null&&(F=re.rain),re.stylesheet.camera!=null&&(Z=re.stylesheet.camera),re.stylesheet.projection!=null&&(z=re.stylesheet.projection),re.stylesheet.transition!=null&&(W=re.stylesheet.transition),ne[re.scope]=re._styleColorTheme}}),this.light=d,this.ambientLight=g,this.directionalLight=S,this.fog=R,this.snow=L,this.rain=F,this._styleColorThemeForScope=ne,j===null?delete this.terrain:this.terrain=j,this.camera=Z||{"camera-projection":"perspective"},this.projection=z||{name:"mercator"},this.transition=Object.assign({},GE,W),this.mergeSources(),this.mergeLayers(),this.mergeIndoor()}forEachFragmentStyle(d){const g=S=>{for(const j of S.fragments)g(j.style);d(S)};g(this)}_prioritizeTerrain(d,g,S){const j=d&&d.drapeRenderMode===0;return S===null?g&&g.drapeRenderMode===0?g:j?d:null:g!=null&&(!d||j||g&&g.drapeRenderMode===1)?g:d}mergeTerrain(){let d;this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle(g=>{d=this._prioritizeTerrain(d,g.terrain,g.stylesheet.terrain)}),d===null?delete this.terrain:this.terrain=d}mergeProjection(){let d;this.forEachFragmentStyle(g=>{g.stylesheet.projection!=null&&(d=g.stylesheet.projection)}),this.projection=d||{name:"mercator"}}mergeSources(){const d={},g={},S={},j={};this.forEachFragmentStyle(R=>{for(const L in R._sourceCaches){const F=a.F(L,R.scope);d[F]=R._sourceCaches[L]}for(const L in R._otherSourceCaches){const F=a.F(L,R.scope);g[F]=R._otherSourceCaches[L]}for(const L in R._symbolSourceCaches){const F=a.F(L,R.scope);S[F]=R._symbolSourceCaches[L]}for(const L in R._fillExtrusionSourceCaches){const F=a.F(L,R.scope);j[F]=R._fillExtrusionSourceCaches[L]}}),this._mergedSourceCaches=d,this._mergedOtherSourceCaches=g,this._mergedSymbolSourceCaches=S,this._mergedFillExtrusionSourceCaches=j}mergeIndoor(){this.forEachFragmentStyle(d=>{if(d.stylesheet&&d.stylesheet.indoor)for(const g of Object.values(d.stylesheet.indoor)){const S=g,j=a.F(S.sourceId,d.scope);this._mergedIndoor[j]=new Set(S.sourceLayers||[])}})}mergeLayers(){const d={},g=[],S={};this._mergedSlots=[],this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this.forEachFragmentStyle(L=>{for(const F of L._order){const z=L._layers[F];if(z.type==="slot"){const W=a.da(F);if(d[W])continue;d[W]=[]}z.slot&&d[z.slot]?d[z.slot].push(z):g.push(z)}}),this._mergedOrder=[];let j=-1;const R=(L=[])=>{for(const F of L)if(F.type==="slot"){const z=a.da(F.id);d[z]&&R(d[z]),this._mergedSlots.push(z)}else{const z=a.F(F.id,F.scope);this._mergedOrder.push(z),S[z]=F,F.is3D(!!this.terrain)&&(this._has3DLayers=!0,j=this._mergedOrder.length-1),F.type==="circle"&&(this._hasCircleLayers=!0),F.type==="symbol"&&(this._hasSymbolLayers=!0),F.type==="clip"&&(this._clipLayerPresent=!0)}};if(R(g),this._has3DLayers){const L={};for(let F=0;FL[F]-L[z])}this._mergedLayers=S,this.updateDrapeFirstLayers(),this._buildingIndex.processLayersChanged(),this._updateDataDrivenEmissiveStrength()}terrainSetForDrapingOnly(){return!!this.terrain&&this.terrain.drapeRenderMode===0}getCamera(){return this.stylesheet.camera}setCamera(d){return this.stylesheet.camera=Object.assign({},this.stylesheet.camera,d),this.camera=this.stylesheet.camera,this}_evaluateColorThemeData(d){return d.data?function(g,S,j){const R=Object.assign({},S);for(const F of Object.keys(UE))R[F]===void 0&&(R[F]=UE[F].default);const L=new a.aa(ry,g,new Map(j));return L.setTransitionOrValue(R,j),L.untransitioned().possiblyEvaluate(new a.ae(0,{worldview:void 0}))}(this.scope,d,this.options).get("data"):null}_loadColorTheme(d){this._styleColorTheme.lutLoading=!0,this._styleColorTheme.lutLoadingCorrelationID+=1;const g=this._styleColorTheme.lutLoadingCorrelationID;return new Promise((S,j)=>{const R="data:image/png;base64,";if(!d||d.length===0)return this._styleColorTheme.lut=null,this._styleColorTheme.lutLoading=!1,void S();let L=d;L.startsWith(R)||(L=R+L);const F=a.I.from("mapbox-reserved-lut"),z=new Image;z.src=L,z.onerror=()=>{this._styleColorTheme.lutLoading=!1,j(new Error("Failed to load image data"))},z.onload=()=>{if(this._styleColorTheme.lutLoadingCorrelationID!==g)return void S();this._styleColorTheme.lutLoading=!1;const{width:W,height:Z,data:ne}=a.o.getImageData(z);if(Z>32)return void j(new Error("The height of the image must be less than or equal to 32 pixels."));if(W!==Z*Z)return void j(new Error("The width of the image must be equal to the height squared."));this.getImage(F)&&this.removeImage(F),this.addImage(F,{data:new a.q({width:W,height:Z},ne),pixelRatio:1,sdf:!1,usvg:!1,version:0});const re=this.imageManager.getImage(F,this.scope);re?(this._styleColorTheme.lut={image:re.data,data:d},S()):j(new Error("Missing LUT image."))}})}getLut(d){const g=this._styleColorThemeForScope[d];return g?g.lut:null}setProjection(d){d?this.stylesheet.projection=d:delete this.stylesheet.projection,this.mergeProjection(),this._updateMapProjection()}applyProjectionUpdate(){this._loaded&&(this.dispatcher.broadcast("setProjection",this.map.transform.projectionOptions),this.map.transform.projection.requiresDraping?(this.getTerrain()||this.stylesheet.terrain)&&!this.disableElevatedTerrain||this.setTerrainForDraping():this.terrainSetForDrapingOnly()&&this.setTerrain(null,0))}_updateMapProjection(){this.isRootStyle()&&(this.map._useExplicitProjection?this.applyProjectionUpdate():this.map._prioritizeAndUpdateProjection(null,this.projection))}_loadSprite(d){this._spriteRequest=function(g,S,j){let R,L,F;const z=a.o.devicePixelRatio>1?"@2x":"";let W=a.m(S.transformRequest(S.normalizeSpriteURL(g,z,".json"),a.R.SpriteJSON),(re,ie)=>{W=null,F||(F=re,R=ie,ne())}),Z=a.n(S.transformRequest(S.normalizeSpriteURL(g,z,".png"),a.R.SpriteImage),(re,ie)=>{Z=null,F||(F=re,L=ie,ne())});function ne(){if(F)j(F);else if(R&&L){const re=a.o.getImageData(L),ie={};for(const ce in R){const{width:le,height:ve,x:_e,y:Re,sdf:Me,pixelRatio:Te,stretchX:Xe,stretchY:$e,content:Ke}=R[ce],De=new a.q({width:le,height:ve});a.q.copy(re,De,{x:_e,y:Re},{x:0,y:0},{width:le,height:ve},null),ie[ce]={data:De,pixelRatio:Te!==void 0?Te:1,sdf:Me!==void 0&&Me,stretchX:Xe,stretchY:$e,content:Ke,usvg:!1,version:0}}j(null,ie)}}return{cancel(){W&&(W.cancel(),W=null),Z&&(Z.cancel(),Z=null)}}}(d,this.map._requestManager,(g,S)=>{if(this._spriteRequest=null,g)this.fire(new a.B(g));else if(S){const j=new Map;for(const R in S)j.set(a.I.from(R),S[R]);this.addImages(j)}this.imageManager.setLoaded(!0,this.scope),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0}),this.fire(new a.C("data",{dataType:"style"}))})}addIconset(d,g){if(g.type==="sprite")return void this._loadSprite(g.url);const S=this.getOwnSourceCache(g.source);if(!S)return void this.fire(new a.B(new Error(`Source "${g.source}" as specified by iconset "${d}" does not exist and cannot be used as an iconset source`)));const j=S.getSource();if(j.type!=="raster-array")return void this.fire(new a.B(new Error(`Source "${g.source}" as specified by iconset "${d}" is not a "raster-array" source and cannot be used as an iconset source`)));j.partial=!1;const R=new VE(d,this.scope,S);this.imageManager.addImageProvider(R,this.scope)}removeIconset(d){this.imageManager.removeImageProvider(d,this.scope)}_loadIconset(d){if(!a.e(d)&&this.map._spriteFormat!=="icon_set"||this.map._spriteFormat==="raster")return void this._loadSprite(d);const g=this.map._spriteFormat==="auto";var S,j;this._spriteRequest=(j=(R,L)=>{if(this._spriteRequest=null,R)g?this._loadSprite(d):this.fire(new a.B(R));else if(L){const F=new Map;for(const z in L)F.set(a.I.from(z),L[z]);this.addImages(F)}this.imageManager.setLoaded(!0,this.scope),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0}),this.fire(new a.C("data",{dataType:"style"}))},a.b1((S=this.map._requestManager).transformRequest(S.normalizeIconsetURL(d),a.R.Iconset),(R,L)=>{if(R)return void j(R);const F={},z=a.c$(new a.a$(L));for(const W of z.icons){const Z={version:1,pixelRatio:a.o.devicePixelRatio,content:xI(W),stretchX:W.metadata?$0(W.metadata.stretch_x_areas):void 0,stretchY:W.metadata?$0(W.metadata.stretch_y_areas):void 0,sdf:!1,usvg:!0,icon:W};F[W.name]=Z}j(null,F)}))}_validateLayer(d){const g=this.getOwnSource(d.source);if(!g)return;const S=d.sourceLayer;S&&(g.type==="geojson"||g.vectorLayerIds&&g.vectorLayerIds.indexOf(S)===-1)&&this.fire(new a.B(new Error(`Source layer "${S}" does not exist on source "${g.id}" as specified by style layer "${d.id}"`)))}loaded(){if(!this._loaded||Object.keys(this._changes.getUpdatedSourceCaches()).length)return!1;for(const d in this._sourceCaches)if(!this._sourceCaches[d].loaded())return!1;if(!this.imageManager.isLoaded()||this.imageManager.hasPatternsInFlight()||!this.modelManager.isLoaded()||this._styleColorTheme.lutLoading)return!1;for(const{style:d}of this.fragments)if(!d.loaded())return!1;return!0}_serializeImports(){if(this.stylesheet.imports)return this.stylesheet.imports.map((d,g)=>{const S=this.fragments[g];return S&&S.style&&(d.data=S.style.serialize()),d})}_serializeSources(){const d={};for(const g in this._sourceCaches){const S=this._sourceCaches[g].getSource();d[S.id]||(d[S.id]=S.serialize())}return d}_serializeLayers(d){const g=[];for(const S of d){const j=this._layers[S];j&&j.type!=="custom"&&g.push(j.serialize())}return g}hasLightTransitions(){return!(!this.light||!this.light.hasTransition())||!(!this.ambientLight||!this.ambientLight.hasTransition())||!(!this.directionalLight||!this.directionalLight.hasTransition())}hasFogTransition(){return!!this.fog&&this.fog.hasTransition()}hasSnowTransition(){return!!this.snow&&this.snow.hasTransition()}hasRainTransition(){return!!this.rain&&this.rain.hasTransition()}hasTransitions(){if(this.hasLightTransitions()||this.hasFogTransition()||this.hasSnowTransition()||this.hasRainTransition())return!0;for(const d in this._sourceCaches)if(this._sourceCaches[d].hasTransition())return!0;for(const d in this._layers)if(this._layers[d].hasTransition())return!0;return!1}_updateDataDrivenEmissiveStrength(){for(const d in this._mergedLayers){const g=this._mergedLayers[d];if(g._transitionablePaint&&g._transitionablePaint._values){const S=g._transitionablePaint._values["line-emissive-strength"];if(S&&S.value&&S.value.isDataDriven())return void(this._hasDataDrivenEmissive=!0)}}this._hasDataDrivenEmissive=!1}hasDataDrivenEmissiveStrength(){return this._hasDataDrivenEmissive}get order(){return this.terrain?this._drapedFirstOrder:this._mergedOrder}_getOrder(d){return d?this.order:this._mergedOrder}isLayerDraped(d){return!!this.terrain&&d.isDraped(this.getLayerSourceCache(d))}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading")}_checkLayer(d){const g=this.getOwnLayer(d);if(g)return g;this.fire(new a.B(new Error(`The layer '${d}' does not exist in the map's style.`)))}_checkSource(d){const g=this.getOwnSource(d);if(g)return g;this.fire(new a.B(new Error(`The source '${d}' does not exist in the map's style.`)))}precompilePrograms(d,g){const S=this.map.painter;if(S)for(let j=d.minzoom||0;j<(d.maxzoom||25.5);j++){const R=d.getProgramIds();if(R)for(const L of R){const F=d.getDefaultProgramParams(L,g.zoom,this._styleColorTheme.lut);F&&(S.style=this,this.fog&&(S._fogVisible=!0,F.overrideFog=!0,S.getOrCreateProgram(L,F)),S._fogVisible=!1,F.overrideFog=!1,S.getOrCreateProgram(L,F),(this.stylesheet.terrain||this.stylesheet.projection&&this.stylesheet.projection.name==="globe")&&(F.overrideRtt=!0,S.getOrCreateProgram(L,F)))}}}update(d){if(!this._loaded)return;this.ambientLight&&this.ambientLight.recalculate(d),this.directionalLight&&this.directionalLight.recalculate(d);const g=this.calculateLightsBrightness();d.brightness=g||0,g!==this._brightness&&(this._brightness=g,this.dispatcher.broadcast("setBrightness",g)),d.worldview!==this._worldview&&(this._worldview=d.worldview,this.dispatcher.broadcast("setWorldview",this._worldview));const S=this._changes.isDirty();let j=!1;if(this._changes.isDirty()){const z=this._changes.getLayerUpdatesByScope();for(const W in z){const{updatedIds:Z,removedIds:ne}=z[W];(Z||ne)&&(this._updateWorkerLayers(W,Z,ne),j=!0)}this.updateSourceCaches(),this._updateTilesForChangedImages(),this.updateLayers(d),this.light&&this.light.updateTransitions(d),this.ambientLight&&this.ambientLight.updateTransitions(d),this.directionalLight&&this.directionalLight.updateTransitions(d),this.fog&&this.fog.updateTransitions(d),this.snow&&this.snow.updateTransitions(d),this.rain&&this.rain.updateTransitions(d),this._changes.reset()}const R={};for(const z in this._mergedSourceCaches){const W=this._mergedSourceCaches[z];R[z]=W.used,W.used=!1,W.tileCoverLift=0}const L={};for(const z of this._mergedOrder){const W=this._mergedLayers[z];if((W.visibility!=="none"||W.hasTransition())&&W.recalculate(d,this._availableImages),!W.isHidden(d.zoom)){const Z=this.getLayerSourceCache(W);Z&&(Z.used=!0,Z.tileCoverLift=Math.max(Z.tileCoverLift,W.tileCoverLift()))}if(W.type==="fill-extrusion"){const Z=a.F(W.source,W.scope);if(Z in this._mergedFillExtrusionSourceCaches){const ne=W.layout&&W.layout.get("source-max-zoom");if(ne!=null){const re=L[Z];L[Z]=re==null?ne:Math.min(re,ne)}}}!this._precompileDone&&this._shouldPrecompile&&("requestIdleCallback"in window?requestIdleCallback(()=>{this.precompilePrograms(W,d)}):this.precompilePrograms(W,d))}this._shouldPrecompile&&(this._precompileDone=!0);for(const z in this._mergedFillExtrusionSourceCaches)this._mergedFillExtrusionSourceCaches[z].setMaxzoomOverride(L[z]!=null?L[z]:null);this.terrain&&j&&this.mergeLayers();const F=this.imageManager.getPendingImageProviders();for(const z of F)z.sourceCache.used=!0;for(const z in R){const W=this._mergedSourceCaches[z];R[z]!==W.used&&W.getSource().fire(new a.C("data",{sourceDataType:"visibility",dataType:"source",sourceId:W.getSource().id}))}this.light&&this.light.recalculate(d),this.terrain&&this.terrain.recalculate(d),this.fog&&this.fog.recalculate(d),this.snow&&this.snow.recalculate(d),this.rain&&this.rain.recalculate(d),this.z=d.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),this.imageManager.clearUpdatedImages(this.scope),S&&this.fire(new a.C("data",{dataType:"style"}))}updateImageProviders(){const d=this.imageManager.getPendingImageProviders();for(const g of d){const S=g.resolvePendingRequests(),j=this.getFragmentStyle(g.scope);j&&j.addImages(S)}}_updateTilesForChangedImages(){const d={};for(const g in this._mergedSourceCaches){const S=this._mergedSourceCaches[g].getSource().scope;d[S]=d[S]||this._changes.getUpdatedImages(S),d[S].length!==0&&this._mergedSourceCaches[g].reloadTilesForDependencies(["icons","patterns"],d[S])}for(const g in d)this._changes.resetUpdatedImages(g)}_updateWorkerLayers(d,g,S){const j=this.getFragmentStyle(d);j&&this.dispatcher.broadcast("updateLayers",{layers:g?j._serializeLayers(g):[],scope:d,removedIds:S||[],options:j.options})}setState(d,g){if(this._checkLoaded(),vp(this,yc(d)))return!1;(d=a.d9(d)).layers=ME(d.layers);const S=function(L,F){if(!L)return[{command:cs.setStyle,args:[F]}];let z=[];try{if(!a.b6(L.version,F.version))return[{command:cs.setStyle,args:[F]}];if(a.b6(L.center,F.center)||z.push({command:cs.setCenter,args:[F.center]}),a.b6(L.zoom,F.zoom)||z.push({command:cs.setZoom,args:[F.zoom]}),a.b6(L.bearing,F.bearing)||z.push({command:cs.setBearing,args:[F.bearing]}),a.b6(L.pitch,F.pitch)||z.push({command:cs.setPitch,args:[F.pitch]}),a.b6(L.sprite,F.sprite)||z.push({command:cs.setSprite,args:[F.sprite]}),a.b6(L.glyphs,F.glyphs)||z.push({command:cs.setGlyphs,args:[F.glyphs]}),a.b6(L.imports,F.imports)||function(ie=[],ce=[],le){ce=ce||[];const ve=(ie=ie||[]).map(Xg),_e=ce.map(Xg),Re=ie.reduce(A0,{}),Me=ce.reduce(A0,{}),Te=ve.slice();let Xe,$e,Ke,De;for(Xe=0,$e=0;Xe{ie.source&&W[ie.source]?z.push({command:cs.removeLayer,args:[ie.id]}):ne.push(ie)});let re=L.terrain;re&&W[re.source]&&(z.push({command:cs.setTerrain,args:[void 0]}),re=void 0),z=z.concat(Z),a.b6(re,F.terrain)||z.push({command:cs.setTerrain,args:[F.terrain]}),function(ie,ce,le){ce=ce||[];const ve=(ie=ie||[]).map(Xg),_e=ce.map(Xg),Re=ie.reduce(A0,{}),Me=ce.reduce(A0,{}),Te=ve.slice(),Xe=Object.create(null);let $e,Ke,De,Be,Ge,ot,Je;for($e=0,Ke=0;$e!(L.command in _I));if(S.length===0)return!1;const j=S.filter(L=>!(L.command in H5));if(j.length>0)throw new Error(`Unimplemented: ${j.map(L=>L.command).join(", ")}.`);const R=[];return S.forEach(L=>{R.push(this[L.command](...L.args))}),g&&Promise.all(R).then(g).catch(g),this.stylesheet=d,this.mergeAll(),this.dispatcher.broadcast("setLayers",{layers:this._serializeLayers(this._order),scope:this.scope,options:this.options}),!0}_updateWorkerImages(){this._availableImages=this.imageManager.listImages(this.scope),this.dispatcher.broadcast("setImages",{scope:this.scope,images:this._availableImages})}_updateWorkerModels(){this._availableModels=this.modelManager.getModelURIs(this.scope),this.dispatcher.broadcast("setModels",{scope:this.scope,models:this._availableModels})}addImages(d){if(d.size===0)return this;for(const[g,S]of d.entries()){if(this.getImage(g))return this.fire(new a.B(new Error(`An image with the name "${g.name}" already exists.`)));this.imageManager.addImage(g,this.scope,S),this._changes.updateImage(g,this.scope)}return this._updateWorkerImages(),this.fire(new a.C("data",{dataType:"style"})),this}addImage(d,g){return this.getImage(d)?this.fire(new a.B(new Error(`An image with the name "${d.name}" already exists.`))):(this.imageManager.addImage(d,this.scope,g),this._changes.updateImage(d,this.scope),this._updateWorkerImages(),this.fire(new a.C("data",{dataType:"style"})),this)}updateImage(d,g,S=!1){this.imageManager.updateImage(d,this.scope,g),S&&(this._changes.updateImage(d,this.scope),this._updateWorkerImages(),this.fire(new a.C("data",{dataType:"style"})))}getImage(d){return this.imageManager.getImage(d,this.scope)}removeImage(d){return this.getImage(d)?(this.imageManager.removeImage(d,this.scope),this._changes.updateImage(d,this.scope),this._updateWorkerImages(),this.fire(new a.C("data",{dataType:"style"})),this):this.fire(new a.B(new Error("No image with this name exists.")))}listImages(){return this._checkLoaded(),this._availableImages.slice()}getActualScope(){return this._importedAsBasemap?"basemap":this.scope}addModelURLs(d){return this.modelManager.addModelURLs(d,this.getActualScope()),this._updateWorkerModels(),this.fire(new a.C("data",{dataType:"style"})),this}addModel(d,g,S={}){return this._checkLoaded(),this._validate(Gt,`models.${d}`,g,null,S)||(this.modelManager.addModel(d,g,this.getActualScope()),this.fire(new a.C("data",{dataType:"style"}))),this}hasModel(d){return this.modelManager.hasModel(d,this.getActualScope())}removeModel(d){return this.hasModel(d)?(this.modelManager.removeModel(d,this.getActualScope(),!1,!0),this.fire(new a.C("data",{dataType:"style"})),this):this.fire(new a.B(new Error("No model with this ID exists.")))}listModels(){return this._checkLoaded(),this.modelManager.listModels(this.getActualScope())}addSource(d,g,S={}){if(this._checkLoaded(),this.getOwnSource(d)!==void 0)throw new Error(`There is already a source with ID "${d}".`);if(!g.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(g).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(g.type)>=0&&this._validate(ul,`sources.${d}`,g,null,S))return;this.map&&this.map._collectResourceTiming&&(g.collectResourceTiming=!0);const j=yb(d,g,this.dispatcher,this);j.scope=this.scope,j.setEventedParent(this,()=>({isSourceLoaded:this._isSourceCacheLoaded(j.id),source:j.serialize(),sourceId:j.id}));const R=L=>{const F=(L===a.b4.Symbol?"symbol:":L===a.b4.FillExtrusion?"fill-extrusion:":"other:")+j.id,z=a.F(F,this.scope),W=this._sourceCaches[F]=new Nu(z,j,L);L===a.b4.Symbol?this._symbolSourceCaches[j.id]=W:L===a.b4.FillExtrusion?this._fillExtrusionSourceCaches[j.id]=W:this._otherSourceCaches[j.id]=W,W.onAdd(this.map)};R(a.b4.Other),g.type!=="vector"&&g.type!=="geojson"||(R(a.b4.Symbol),g.type==="vector"&&R(a.b4.FillExtrusion)),j.onAdd&&j.onAdd(this.map),S.isInitialLoad||(this.mergeSources(),this._changes.setDirty())}removeSource(d){this._checkLoaded();const g=this.getOwnSource(d);if(!g)throw new Error("There is no source with this ID");for(const j in this._layers)if(this._layers[j].source===d)return this.fire(new a.B(new Error(`Source "${d}" cannot be removed while layer "${j}" is using it.`)));if(this.terrain&&this.terrain.scope===this.scope&&this.terrain.get().source===d)return this.fire(new a.B(new Error(`Source "${d}" cannot be removed while terrain is using it.`)));if(this.stylesheet.iconsets){const j=Object.entries(this.stylesheet.iconsets).find(([R,L])=>L.type==="source"&&L.source===d);if(j)return this.fire(new a.B(new Error(`Source "${d}" cannot be removed while iconset "${j[0]}" is using it.`)))}const S=this.getOwnSourceCaches(d);for(const j of S){const R=a.da(j.id);delete this._sourceCaches[R],this._changes.discardSourceCacheUpdate(j.id),j.fire(new a.C("data",{sourceDataType:"metadata",dataType:"source",sourceId:j.getSource().id})),j.setEventedParent(null),j.clearTiles()}return delete this._otherSourceCaches[d],delete this._symbolSourceCaches[d],delete this._fillExtrusionSourceCaches[d],this.mergeSources(),g.setEventedParent(null),g.onRemove&&g.onRemove(this.map),this._changes.setDirty(),this}setGeoJSONSourceData(d,g){this._checkLoaded(),this.getOwnSource(d).setData(g),this._changes.setDirty()}getOwnSource(d){const g=this.getOwnSourceCache(d);return g&&g.getSource()}getOwnSources(){const d=[];for(const g in this._otherSourceCaches){const S=this.getOwnSourceCache(g);S&&d.push(S.getSource())}return d}areTilesLoaded(){const d=this._mergedSourceCaches;for(const g in d){const S=d[g]._tiles;for(const j in S){const R=S[j];if(R.state!=="loaded"&&R.state!=="errored")return!1}}return!0}setLights(d){if(this._checkLoaded(),!d)return delete this.ambientLight,void delete this.directionalLight;const g=this._getTransitionParameters();for(const R of d){if(this._validate(he,"lights",R))return;switch(R.type){case"ambient":if(this.ambientLight){const L=this.ambientLight;L.set(R),L.updateTransitions(g)}else this.ambientLight=new Da(R,Po(),this.scope,this.options);break;case"directional":if(this.directionalLight){const L=this.directionalLight;L.set(R),L.updateTransitions(g)}else this.directionalLight=new Da(R,xc(),this.scope,this.options)}}const S=Object.assign(g,{worldview:this.map.getWorldview()}),j=new a.ae(this.z||0,S);this.ambientLight&&this.ambientLight.recalculate(j),this.directionalLight&&this.directionalLight.recalculate(j),this._brightness=this.calculateLightsBrightness(),this.dispatcher.broadcast("setBrightness",this._brightness)}calculateLightsBrightness(){const d=this.directionalLight,g=this.ambientLight;if(!d||!g)return;const S=re=>.2126*(re[0]<=.03928?re[0]/12.92:Math.pow((re[0]+.055)/1.055,2.4))+.7152*(re[1]<=.03928?re[1]/12.92:Math.pow((re[1]+.055)/1.055,2.4))+.0722*(re[2]<=.03928?re[2]/12.92:Math.pow((re[2]+.055)/1.055,2.4)),j=d.properties.get("color").toNonPremultipliedRenderColor(null).toArray01(),R=d.properties.get("intensity"),L=d.properties.get("direction"),F=1-a.cP(L.x,L.y,L.z)[2]/90,z=S(j)*R*F,W=g.properties.get("color").toNonPremultipliedRenderColor(null).toArray01(),Z=g.properties.get("intensity"),ne=S(W)*Z;return Number(((z+ne)/2).toFixed(6))}getBrightness(){return this._brightness}getLights(){if(!this.enable3dLights())return null;const d=[];return this.directionalLight&&d.push(this.directionalLight.get()),this.ambientLight&&d.push(this.ambientLight.get()),d}enable3dLights(){return!!this.ambientLight&&!!this.directionalLight}getFragmentStyle(d){if(d==null||d===""&&this.isRootStyle())return this;if(a.db(d)){const g=a.dc(d),S=this.fragments.find(({id:R})=>R===g);if(!S)return;const j=a.da(d);return S.style.getFragmentStyle(j)}{const g=this.fragments.find(({id:S})=>S===d);return g?g.style:void 0}}setFeaturesetSelectors(d){if(!d)return;const g=(S,j="")=>`${S}::${j}`;this._featuresetSelectors={};for(const S in d){const j={},R=this._featuresetSelectors[S]=[];for(const L of d[S].selectors){if(L.featureNamespace){const z=this.getOwnLayer(L.layer);if(!z){a.w(`Layer is undefined for selector: ${L.layer}`);continue}const W=g(z.source,z.sourceLayer);if(W in j&&j[W]!==L.featureNamespace){a.w(`"featureNamespace ${L.featureNamespace} of featureset ${S}'s selector is not associated to the same source, skip this selector`);continue}j[W]=L.featureNamespace}let F;if(L.properties)for(const z in L.properties){const W=a.X(L.properties[z]);W.result==="success"&&(F=F||{},F[z]=W.value)}R.push({layerId:L.layer,namespace:L.featureNamespace,properties:F,uniqueFeatureID:L._uniqueFeatureID})}}}getFeaturesetDescriptors(d){const g=this.getFragmentStyle(d);if(!g||!g.stylesheet.featuresets)return[];const S=[];for(const j in g.stylesheet.featuresets)S.push({featuresetId:j,importId:g.scope?g.scope:void 0});return S}getFeaturesetLayers(d,g){const S=this.getFragmentStyle(g),j=S.stylesheet.featuresets;if(!j||!j[d])return this.fire(new a.B(new Error(`The featureset '${d}' does not exist in the map's style and cannot be queried.`))),[];const R=[];for(const L of j[d].selectors){const F=S.getOwnLayer(L.layer);F&&R.push(F)}return R}getConfigProperty(d,g){const S=this.getFragmentStyle(d);if(!S)return null;const j=a.F(g,S.scope),R=S.options.get(j),L=R?R.value||R.default:null;return L?L.serialize():null}isIndoorEnabled(){return Object.keys(this._mergedIndoor).length>0}getIndoorSourceLayers(d,g){const S=a.F(d,g);return this._mergedIndoor[S]}setIndoorData(d,g){this.indoorManager.setIndoorData(g)}updateIndoorDependentLayers(){this._updateLayers(this._indoorDependentLayers),this.map._styleDirty=!0,this.map.triggerRepaint()}setConfigProperty(d,g,S){const j=this.getFragmentStyle(d);if(!j)return;const R=j.stylesheet.schema;if(!R||!R[g])return;const L=a.X(S);if(L.result!=="success")return void vp(this,L.value);const F=L.value.expression,z=a.F(g,j.scope),W=j.options.get(z);if(!W)return;let Z;const{minValue:ne,maxValue:re,stepValue:ie,type:ce,values:le}=R[g],ve=a.X(R[g].default);ve.result==="success"&&(Z=ve.value.expression),Z?(this.options.set(z,Object.assign({},W,{value:F,default:Z,minValue:ne,maxValue:re,stepValue:ie,type:ce,values:le})),this.updateConfigDependencies(g)):this.fire(new a.B(new Error(`No schema defined for the config option "${g}" in the "${d}" fragment.`)))}getConfig(d){const g=this.getFragmentStyle(d);if(!g)return null;const S=g.stylesheet.schema;if(!S)return null;const j={};for(const R in S){const L=a.F(R,g.scope),F=g.options.get(L),z=F?F.value||F.default:null;j[R]=z?z.serialize():null}return j}setConfig(d,g){const S=this.getFragmentStyle(d);S&&(S.updateConfig(g,S.stylesheet.schema),this.updateConfigDependencies())}getSchema(d){const g=this.getFragmentStyle(d);return g?g.stylesheet.schema:null}setSchema(d,g){const S=this.getFragmentStyle(d);S&&(S.stylesheet.schema=g,S.updateConfig(S._config,g),this.updateConfigDependencies())}updateConfig(d,g){if(this._config=d,d||g)if(g)for(const S in g){let j,R;const L=a.X(g[S].default);if(L.result==="success"&&(j=L.value.expression),d&&d[S]!==void 0){const re=a.X(d[S]);re.result==="success"&&(R=re.value.expression)}const{minValue:F,maxValue:z,stepValue:W,type:Z,values:ne}=g[S];if(j){const re=a.F(S,this.scope);this.options.set(re,{default:j,value:R,minValue:F,maxValue:z,stepValue:W,type:Z,values:ne})}else this.fire(new a.B(new Error(`No schema defined for config option "${S}".`)))}else this.fire(new a.B(new Error("Attempting to set config for a style without schema.")))}_updateLayers(d,g=()=>!0){for(const S of d){const j=this.getLayer(S);j&&g(j)&&(j.possiblyEvaluateVisibility(),this._updateLayer(j),this._changes.setDirty())}}updateConfigDependencies(d){this._updateLayers(this._configDependentLayers,g=>!d||g.expressionDependencies.configDependencies.has(d)),this.ambientLight&&this.ambientLight.updateConfig(this.options),this.directionalLight&&this.directionalLight.updateConfig(this.options),this.fog&&this.fog.updateConfig(this.options),this.snow&&this.snow.updateConfig(this.options),this.rain&&this.rain.updateConfig(this.options),this.forEachFragmentStyle(g=>{const S=g._styleColorTheme.colorThemeOverride?g._styleColorTheme.colorThemeOverride:g._styleColorTheme.colorTheme;if(S){const j=g._evaluateColorThemeData(S);(!g._styleColorTheme.lut&&j!==""||g._styleColorTheme.lut&&j!==g._styleColorTheme.lut.data)&&g.setColorTheme(S)}}),this._changes.setDirty()}addLayer(d,g,S={}){this._checkLoaded();const j=d.id;if(this._layers[j])return void this.fire(new a.B(new Error(`Layer with id "${j}" already exists on this map`)));let R;if(d.type==="custom"){if(vp(this,a.dd(d)))return;R=a.de(d,this.scope,this._styleColorTheme.lut,this.options)}else{if(typeof d.source=="object"&&(this.addSource(j,d.source),d=a.d9(d),d=Object.assign(d,{source:j})),this._validate(nt,`layers.${j}`,d,{arrayIndex:-1},S))return;R=a.de(d,this.scope,this._styleColorTheme.lut,this.options),this._validateLayer(R),R.setEventedParent(this,{layer:{id:j}})}const L=a.F(R.source,R.scope);R.expressionDependencies.configDependencies.size!==0&&this._configDependentLayers.add(L),R.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(L);let F=this._order.length;if(g){const ne=this._order.indexOf(g);if(ne===-1)return void this.fire(new a.B(new Error(`Layer with id "${g}" does not exist on this map.`)));R.slot&&R.slot!==this._layers[g].slot?a.w(`Layer with id "${g}" has a different slot. Layers can only be rearranged within the same slot.`):F=ne}this._order.splice(F,0,j),this._handleLayerOrderChange(),this._layers[j]=R;const z=this.getOwnLayerSourceCache(R),W=!!this.directionalLight&&this.directionalLight.shadowsEnabled();z&&R.canCastShadows()&&W&&(z.castsShadows=!0);const Z=this._changes.getRemovedLayer(R);if(Z&&R.source&&z&&R.type!=="custom"){this._changes.discardLayerRemoval(R);const ne=a.F(R.source,R.scope);Z.type!==R.type?this._changes.updateSourceCache(ne,"clear"):(this._changes.updateSourceCache(ne,"reload"),z.pause())}this._updateLayer(R),R.onAdd&&R.onAdd(this.map),R.scope=this.scope,this.mergeLayers()}moveLayer(d,g){this._checkLoaded();const S=this._checkLayer(d);if(!S||d===g)return;const j=this._order.indexOf(d);this._order.splice(j,1);let R=this._order.length;if(g){const L=this._order.indexOf(g);if(L===-1)return void this.fire(new a.B(new Error(`Layer with id "${g}" does not exist on this map.`)));S.slot&&S.slot!==this._layers[g].slot?a.w(`Layer with id "${g}" has a different slot. Layers can only be rearranged within the same slot.`):R=L}this._order.splice(R,0,d),this._changes.setDirty(),this._handleLayerOrderChange(),this.mergeLayers()}removeLayer(d){this._checkLoaded();const g=this._checkLayer(d);if(!g)return;g.setEventedParent(null);const S=this._order.indexOf(d);this._order.splice(S,1),delete this._layers[d],this._changes.setDirty(),this._handleLayerOrderChange(),this._configDependentLayers.delete(g.fqid),this._indoorDependentLayers.delete(g.fqid),this._changes.removeLayer(g);const j=this.getOwnLayerSourceCache(g);if(j&&j.castsShadows){let R=!1;for(const L in this._layers)if(this._layers[L].source===g.source&&this._layers[L].canCastShadows()){R=!0;break}j.castsShadows=R}g.onRemove&&g.onRemove(this.map),this.mergeLayers()}getOwnLayer(d){return this._layers[d]}hasLayer(d){return d in this._mergedLayers}hasLayerType(d){for(const g in this._layers)if(this._layers[g].type===d)return!0;return!1}setLayerZoomRange(d,g,S){this._checkLoaded();const j=this._checkLayer(d);j&&(j.minzoom===g&&j.maxzoom===S||(g!=null&&(j.minzoom=g),S!=null&&(j.maxzoom=S),this._updateLayer(j)))}getSlots(){return this._checkLoaded(),this._mergedSlots}setSlot(d,g){this._checkLoaded();const S=this._checkLayer(d);S&&S.slot!==g&&(S.slot=g,this._updateLayer(S))}setFilter(d,g,S={}){this._checkLoaded();const j=this._checkLayer(d);if(j&&!a.b6(j.filter,g))return g==null?(j.filter=void 0,void this._updateLayer(j)):void(this._validate(ht,`layers.${j.id}.filter`,g,{layerType:j.type},S)||(j.filter=a.d9(g),this._updateLayer(j)))}getFilter(d){const g=this._checkLayer(d);if(g)return a.d9(g.filter)}setLayoutProperty(d,g,S,j={}){this._checkLoaded();const R=this._checkLayer(d);if(R&&!a.b6(R.getLayoutProperty(g),S)){if(S!=null&&(!j||j.validate!==!1)&&vp(R,mt.call(yc,{key:`layers.${d}.layout.${g}`,layerType:R.type,objectKey:g,value:S,styleSpec:a.a8,style:{glyphs:!0,sprite:!0}})))return;R.setLayoutProperty(g,S),R.expressionDependencies.configDependencies.size!==0&&this._configDependentLayers.add(R.fqid),R.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(R.fqid),this._updateLayer(R)}}setLayerProperty(d,g,S,j={}){this._checkLoaded();const R=this._checkLayer(d);R&&(g==="appearances"?(R.setAppearances(S),this._updateLayer(R)):R.isPaintProperty(g)?this.setPaintProperty(d,g,S,j):this.setLayoutProperty(d,g,S,j))}getLayoutProperty(d,g){const S=this._checkLayer(d);if(S)return S.getLayoutProperty(g)}setPaintProperty(d,g,S,j={}){this._checkLoaded();const R=this._checkLayer(d);if(!R||a.b6(R.getPaintProperty(g),S)||S!=null&&(!j||j.validate!==!1)&&vp(R,it.call(yc,{key:`layers.${d}.paint.${g}`,layerType:R.type,objectKey:g,value:S,styleSpec:a.a8})))return;const L=R.setPaintProperty(g,S);R.expressionDependencies.configDependencies.size!==0&&this._configDependentLayers.add(R.fqid),R.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(R.fqid),L&&this._updateLayer(R),this._changes.updatePaintProperties(R)}getPaintProperty(d,g){const S=this._checkLayer(d);if(S)return S.getPaintProperty(g)}setFeatureState(d,g){if(this._checkLoaded(),"target"in d){if("featuresetId"in d.target){const{featuresetId:z,importId:W}=d.target,Z=this.getFragmentStyle(W),ne=Z.getFeaturesetLayers(z);for(const{source:re,sourceLayer:ie}of ne)Z.setFeatureState({id:d.id,source:re,sourceLayer:ie},g)}else if("layerId"in d.target){const{layerId:z}=d.target,W=this.getLayer(z);this.setFeatureState({id:d.id,source:W.source,sourceLayer:W.sourceLayer},g)}return}const S=d.source,j=d.sourceLayer,R=this._checkSource(S);if(!R)return;const L=R.type;if(L==="geojson"&&j)return void this.fire(new a.B(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));if(L==="vector"&&!j)return void this.fire(new a.B(new Error("The sourceLayer parameter must be provided for vector source types.")));d.id===void 0&&this.fire(new a.B(new Error("The feature id parameter must be provided.")));const F=this.getOwnSourceCaches(S);for(const z of F)z.setFeatureState(j,d.id,g)}removeFeatureState(d,g){if(this._checkLoaded(),"target"in d){if("featuresetId"in d.target){const{featuresetId:z,importId:W}=d.target,Z=this.getFragmentStyle(W),ne=Z.getFeaturesetLayers(z);for(const{source:re,sourceLayer:ie}of ne)Z.removeFeatureState({id:d.id,source:re,sourceLayer:ie},g)}else if("layerId"in d.target){const{layerId:z}=d.target,W=this.getLayer(z);this.removeFeatureState({id:d.id,source:W.source,sourceLayer:W.sourceLayer},g)}return}const S=d.source,j=this._checkSource(S);if(!j)return;const R=j.type,L=R==="vector"?d.sourceLayer:void 0;if(R==="vector"&&!L)return void this.fire(new a.B(new Error("The sourceLayer parameter must be provided for vector source types.")));if(g&&typeof d.id!="string"&&typeof d.id!="number")return void this.fire(new a.B(new Error("A feature id is required to remove its specific state property.")));const F=this.getOwnSourceCaches(S);for(const z of F)z.removeFeatureState(L,d.id,g)}getFeatureState(d){if(this._checkLoaded(),"target"in d){let R;if("featuresetId"in d.target){const{featuresetId:L,importId:F}=d.target,z=this.getFragmentStyle(F),W=z.getFeaturesetLayers(L);for(const{source:Z,sourceLayer:ne}of W){const re=z.getFeatureState({id:d.id,source:Z,sourceLayer:ne});if(re&&!R)R=re;else if(!a.b6(R,re))return void this.fire(new a.B(new Error("The same feature id exists in multiple sources in the featureset, but their feature states are not consistent through the sources.")))}}else if("layerId"in d.target){const{layerId:L}=d.target,F=this.getLayer(L);R=this.getFeatureState({id:d.id,source:F.source,sourceLayer:F.sourceLayer})}return R}const g=d.source,S=d.sourceLayer,j=this._checkSource(g);if(j){if(j.type!=="vector"||S)return d.id===void 0&&this.fire(new a.B(new Error("The feature id parameter must be provided."))),this.getOwnSourceCaches(g)[0].getFeatureState(S,d.id);this.fire(new a.B(new Error("The sourceLayer parameter must be provided for vector source types.")))}}setTransition(d){return this.stylesheet.transition=Object.assign({},this.stylesheet.transition,d),this.transition=this.stylesheet.transition,this}getTransition(){return Object.assign({},this.stylesheet.transition)}setWorldview(d){d!==this._worldview&&(this._worldview=d,this.dispatcher.broadcast("setWorldview",this._worldview),this.reloadSources())}serialize(){this._checkLoaded();const d=this.getTerrain(),g=d&&this.terrain&&this.terrain.scope===this.scope?d:this.stylesheet.terrain;return a.df({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,fragment:this.stylesheet.fragment,iconsets:this.stylesheet.iconsets,featuresets:this.stylesheet.featuresets,imports:this._serializeImports(),schema:this.stylesheet.schema,camera:this.stylesheet.camera,light:this.stylesheet.light,lights:this.stylesheet.lights,terrain:g,fog:this.stylesheet.fog,snow:this.stylesheet.snow,rain:this.stylesheet.rain,indoor:this.stylesheet.indoor,center:this.stylesheet.center,"color-theme":this.stylesheet["color-theme"],zoom:this.stylesheet.zoom,bearing:this.stylesheet.bearing,pitch:this.stylesheet.pitch,sprite:this.stylesheet.sprite,glyphs:this.stylesheet.glyphs,transition:this.stylesheet.transition,projection:this.stylesheet.projection,sources:this._serializeSources(),layers:this._serializeLayers(this._order)},S=>S!==void 0)}_updateFilteredLayers(d){for(const g of Object.values(this._mergedLayers))d(g)&&this._updateLayer(g)}_updateLayer(d){this._changes.updateLayer(d);const g=this.getLayerSourceCache(d),S=a.F(d.source,d.scope),j=this._changes.getUpdatedSourceCaches();d.source&&!j[S]&&g&&g.getSource().type!=="raster"&&(this._changes.updateSourceCache(S,"reload"),g.pause()),d.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(d){const g=F=>this._mergedLayers[F].is3D(!!this.terrain),S=this.order,j={},R=[];for(let F=S.length-1;F>=0;F--){const z=S[F];if(g(z)){j[z]=F;for(const W of d){const Z=W[z];if(Z)for(const ne of Z)R.push(ne)}}}R.sort((F,z)=>z.intersectionZ-F.intersectionZ);const L=[];for(let F=S.length-1;F>=0;F--){const z=S[F];if(g(z))for(let W=R.length-1;W>=0;W--){const Z=R[W].feature;if(Z.layer&&j[Z.layer.id]{if(qE.has(Z.type))return;const ne=this.getOwnLayerSourceCache(Z),re=R[ne.id]=R[ne.id]||{sourceCache:ne,layers:{},has3DLayers:!1};Z.is3D(!!this.terrain)&&(re.has3DLayers=!0),re.layers[Z.fqid]=re.layers[Z.fqid]||{styleLayer:Z,targets:[]},re.layers[Z.fqid].targets.push({filter:j})};if(g&&g.layers){if(!Array.isArray(g.layers))return this.fire(new a.B(new Error("parameters.layers must be an Array."))),[];for(const Z of g.layers){const ne=this._layers[Z];if(!ne)return this.fire(new a.B(new Error(`The layer '${Z}' does not exist in the map's style and cannot be queried for features.`))),[];L(ne)}}else for(const Z in this._layers)L(this._layers[Z]);const F=this._queryRenderedFeatures(d,R,S),z=this._flattenAndSortRenderedFeatures(F),W=[];for(const Z of z)a.dh(Z.layer.id)===this.scope&&W.push(Z);return W}queryRenderedFeatureset(d,g,S){let j;g&&!Array.isArray(g)&&g.filter&&(this._validate(ht,"queryRenderedFeatures.filter",g.filter,null,g),j=a.dg(g.filter));const R="mock",L=[];if(g&&g.target)L.push(Object.assign({},g,{targetId:R,filter:j}));else{const Z=this.getFeaturesetDescriptors();for(const ne of Z)L.push({targetId:R,filter:j,target:ne});for(const{style:ne}of this.fragments){const re=ne.getFeaturesetDescriptors();for(const ie of re)L.push({targetId:R,filter:j,target:ie})}}const F=this.queryRenderedTargets(d,L,S),z=[],W=new Set;for(const Z of F)for(const ne of Z.variants[R])Wd(ne,Z,W)||z.push(new a.di(Z,ne));return z}queryRenderedTargets(d,g,S){const j={},R=(F,z,W,Z)=>{const ne=j[z.id]=j[z.id]||{sourceCache:z,layers:{},has3DLayers:!1};if(ne.layers[F.fqid]=ne.layers[F.fqid]||{styleLayer:F,targets:[]},F.is3D(!!this.terrain)&&(ne.has3DLayers=!0),!Z)return W.uniqueFeatureID=!1,void ne.layers[F.fqid].targets.push(W);ne.layers[F.fqid].targets.push(Object.assign({},W,{namespace:Z.namespace,properties:Z.properties,uniqueFeatureID:Z.uniqueFeatureID}))};for(const F of g)if("featuresetId"in F.target){const{featuresetId:z,importId:W}=F.target,Z=this.getFragmentStyle(W);if(!Z||!Z._featuresetSelectors)continue;const ne=Z._featuresetSelectors[z];if(!ne){this.fire(new a.B(new Error(`The featureset '${z}' does not exist in the map's style and cannot be queried for features.`)));continue}for(const re of ne){const ie=Z.getOwnLayer(re.layerId);ie&&!qE.has(ie.type)&&R(ie,Z.getOwnLayerSourceCache(ie),F,re)}}else if("layerId"in F.target){const{layerId:z}=F.target,W=this.getLayer(z);if(!W||qE.has(W.type))continue;R(W,this.getLayerSourceCache(W),F)}const L=this._queryRenderedFeatures(d,j,S);return this._flattenAndSortRenderedFeatures(L)}_queryRenderedFeatures(d,g,S){const j=[],R=!!this.map._showQueryGeometry,L=_c.createFromScreenPoints(d,S);for(const F in g){const z=hI(L,g[F],this._availableImages,S,R,this.getActualScope());Object.keys(z).length&&j.push(z)}if(this.placement)for(const F in g){if(g[F].sourceCache._renderSourceType!==a.b4.Symbol)continue;const z=xb(L.screenGeometry,g[F],this._availableImages,this.placement.collisionIndex,this.placement.retainedQueryData,this.map.getWorldview());Object.keys(z).length&&j.push(z)}return j}querySourceFeatures(d,g){const S=g&&g.filter;S&&this._validate(ht,"querySourceFeatures.filter",S,null,g);let j=[];const R=this.getOwnSourceCaches(d);for(const L of R)j=j.concat(IE(L,g));return j}addSourceType(d,g,S){return Ru.getSourceType(d)?S(new Error(`A source type called "${d}" already exists.`)):(Ru.setSourceType(d,g),g.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:d,url:g.workerSourceURL},S):S(null,null))}getFlatLight(){return this.light.getLight()}setFlatLight(d,g,S={}){this._checkLoaded();const j=this.light.getLight();let R=!1;for(const F in d)if(!a.b6(d[F],j[F])){R=!0;break}if(!R)return;const L=this._getTransitionParameters();this.light.setLight(d,g,S),this.light.updateTransitions(L)}getTerrain(){return this.terrain&&this.terrain.drapeRenderMode===1?this.terrain.get():null}setTerrainForDraping(){this.setTerrain({source:"",exaggeration:0},0)}checkCanvasFingerprintNoise(){this.disableElevatedTerrain===void 0&&(this.disableElevatedTerrain=a.o.hasCanvasFingerprintNoise(),this.disableElevatedTerrain&&a.w("Terrain and hillshade are disabled because of Canvas2D limitations when fingerprinting protection is enabled (e.g. in private browsing mode)."))}setTerrain(d,g=1){if(this._checkLoaded(),!d)return this.terrainSetForDrapingOnly()||(delete this.terrain,this.map.transform.projection.requiresDraping&&this.setTerrainForDraping()),g===0&&delete this.terrain,d===null?this.stylesheet.terrain=null:delete this.stylesheet.terrain,this._force3DLayerUpdate(),void(this._markersNeedUpdate=!0);this.checkCanvasFingerprintNoise();let S=d;const j=!("source"in d)||d.source==null;if(g===1){if(this.disableElevatedTerrain)return;if("source"in S&&typeof S.source=="object"){const F="terrain-dem-src";this.addSource(F,S.source),S=a.d9(S),S=Object.assign(S,{source:F})}const R=Object.assign({},S),L={};if(this.terrain&&j){R.source=this.terrain.get().source;const F=this.terrain?this.getFragmentStyle(this.terrain.scope):null;F&&(L.style=F.serialize())}if(this._validate(pe,"terrain",R,L))return}if(!this.terrain||this.terrain.scope!==this.scope&&!j||this.terrain&&g!==this.terrain.drapeRenderMode){if(!S)return;this._createTerrain(S,g),this.fire(new a.C("data",{dataType:"style"}))}else{const R=this.terrain,L=R.get();for(const F of Object.keys(a.a8.terrain))!S.hasOwnProperty(F)&&a.a8.terrain[F].default&&(S[F]=a.a8.terrain[F].default);for(const F in d)if(!a.b6(d[F],L[F])){R.set(d,this.options),this.stylesheet.terrain=d;const z=this._getTransitionParameters({duration:0});R.updateTransitions(z),this.fire(new a.C("data",{dataType:"style"}));break}}this.mergeTerrain(),this.updateDrapeFirstLayers(),this._markersNeedUpdate=!0}_createFog(d){const g=this.fog=new ks(d,this.map.transform,this.scope,this.options);this.stylesheet.fog=g.get();const S=this._getTransitionParameters({duration:0});g.updateTransitions(S)}_createSnow(d){const g=this.snow=new di(d,this.map.transform,this.scope,this.options);this.stylesheet.snow=g.get();const S=this._getTransitionParameters({duration:0});g.updateTransitions(S)}_createRain(d){const g=this.rain=new Vn(d,this.map.transform,this.scope,this.options);this.stylesheet.rain=g.get();const S=this._getTransitionParameters({duration:0});g.updateTransitions(S)}_updateMarkersOpacity(){this.map._markers.length!==0&&this.map._requestDomTask(()=>{for(const d of this.map._markers)d._evaluateOpacity()})}getFog(){return this.fog?this.fog.get():null}setFog(d){if(this._checkLoaded(),!d)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){const g=this.fog;if(!a.b6(g.get(),d)){g.set(d,this.options),this.stylesheet.fog=g.get();const S=this._getTransitionParameters({duration:0});g.updateTransitions(S)}}else this._createFog(d);this._markersNeedUpdate=!0}getSnow(){return this.snow?this.snow.get():null}setSnow(d){if(this._checkLoaded(),!d)return delete this.snow,void delete this.stylesheet.snow;if(this.snow){const g=this.snow;if(!a.b6(g.get(),d)){g.set(d,this.options),this.stylesheet.snow=g.get();const S=this._getTransitionParameters({duration:0});g.updateTransitions(S)}}else this._createSnow(d);this._markersNeedUpdate=!0}getRain(){return this.rain?this.rain.get():null}setRain(d){if(this._checkLoaded(),!d)return delete this.rain,void delete this.stylesheet.rain;if(this.rain){const g=this.rain;if(!a.b6(g.get(),d)){g.set(d,this.options),this.stylesheet.rain=g.get();const S=this._getTransitionParameters({duration:0});g.updateTransitions(S)}}else this._createRain(d);this._markersNeedUpdate=!0}_reloadColorTheme(){const d=()=>{for(const j in this._layers)this._layers[j].lut=this._styleColorTheme.lut;for(const j in this._sourceCaches)this._sourceCaches[j].clearTiles()},g=this._styleColorTheme.colorThemeOverride?this._styleColorTheme.colorThemeOverride:this._styleColorTheme.colorTheme;if(!g)return this._styleColorTheme.lut=null,void d();const S=this._evaluateColorThemeData(g);this._loadColorTheme(S).then(()=>{this.fire(new a.C("colorthemeset")),d()}).catch(j=>{a.w(`Couldn't set color theme: ${j}`)})}setColorTheme(d){this._checkLoaded(),this._styleColorTheme.colorThemeOverride&&a.w("Note: setColorTheme is called on a style with a color-theme override, the passed color-theme won't be visible."),this._styleColorTheme.colorTheme=d,this._reloadColorTheme()}setImportColorTheme(d,g){const S=this.getFragmentStyle(d);S&&(S._styleColorTheme.colorThemeOverride=g,S._reloadColorTheme())}_getTransitionParameters(d){return{now:a.o.now(),transition:Object.assign(this.transition,d)}}updateDrapeFirstLayers(){if(!this.terrain)return;const d=[],g=[];for(const S of this._mergedOrder)this.isLayerDraped(this._mergedLayers[S])?d.push(S):g.push(S);this._drapedFirstOrder=[],this._drapedFirstOrder.push(...d),this._drapedFirstOrder.push(...g)}_createTerrain(d,g){const S=this.terrain=new qt(d,g,this.scope,this.options,this.map.getWorldview());g===1&&(this.stylesheet.terrain=d),this.mergeTerrain(),this.updateDrapeFirstLayers(),this._force3DLayerUpdate();const j=this._getTransitionParameters({duration:0});S.updateTransitions(j)}_force3DLayerUpdate(){for(const d in this._layers){const g=this._layers[d];g.type==="fill-extrusion"&&this._updateLayer(g)}}_forceSymbolLayerUpdate(){for(const d in this._layers){const g=this._layers[d];g.type==="symbol"&&this._updateLayer(g)}}_validate(d,g,S,j,R={}){if(R&&R.validate===!1)return!1;const L=Object.assign({},this.serialize());return vp(this,d.call(yc,Object.assign({key:g,style:L,value:S,styleSpec:a.a8},j)))}_remove(){this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),a.dj.off("pluginStateChange",this._rtlTextPluginCallback);for(const d in this._mergedLayers)this._mergedLayers[d].setEventedParent(null);for(const d in this._mergedSourceCaches)this._mergedSourceCaches[d].clearTiles(),this._mergedSourceCaches[d].setEventedParent(null);this.imageManager.removeScope(this.scope),this.imageManager.imageAtlasCache.clear(),this.setEventedParent(null),delete this.fog,delete this.snow,delete this.rain,delete this.terrain,delete this.ambientLight,delete this.directionalLight,this.indoorManager.destroy(),this.isRootStyle()&&(this.imageManager.setEventedParent(null),this.imageManager.destroy(),this.modelManager.setEventedParent(null),this.modelManager.destroy(),this.dispatcher.remove())}clearSource(d){const g=this.getSourceCaches(d);for(const S of g)S.clearTiles()}clearSources(){for(const d in this._mergedSourceCaches)this._mergedSourceCaches[d].clearTiles()}clearLayers(){for(const d in this._mergedLayers){const g=this._mergedLayers[d];g._clear&&g._clear()}}reloadSource(d){const g=this.getSourceCaches(d);for(const S of g)S.resume(),S.reload()}reloadSources(){for(const d of this.getSources())d.reload&&d.reload()}reloadModels(){this.modelManager.reloadModels(""),this.forEachFragmentStyle(d=>{d.modelManager.reloadModels(d.scope)})}updateSources(d){let g;this.directionalLight&&(g=yI(this.directionalLight));const S=new Set,j=new Set,R=new Set;for(const L in this._mergedLayers){const F=this._mergedLayers[L];F.type==="building"?S.add(F.source):F.type==="raster"&&F.paint&&F.paint.get("raster-elevation-reference")==="ground"&&R.add(F.source),F.hasElevation()&&!j.has(F.source)&&j.add(F.source)}for(const L in this._mergedSourceCaches){const F=this._mergedSourceCaches[L],z=j.has(F._source.id);F._isRasterElevatedOverTerrain=R.has(F._source.id),S.has(F._source.id)&&(F._source.reparseOverscaled=!1),F.update(d,void 0,void 0,g,z)}}_generateCollisionBoxes(){for(const d in this._sourceCaches){const g=this._sourceCaches[d];g.resume(),g.reload()}}_handleLayerOrderChange(){this._requestFullLabelPlacement(),this.fire(new a.C("neworder"))}_requestFullLabelPlacement(){this.pauseablePlacement||(this.pauseablePlacement=new R0),this.pauseablePlacement.requestFullPlacement()}_setLabelPlacementStale(){this.placement&&this.placement.setStale()}_updatePlacement(d,g,S,j,R){this.pauseablePlacement||(this.pauseablePlacement=new R0);let L=!1,F=!1;const z={},W={};for(const le of this._mergedOrder){const ve=this._mergedLayers[le];if(ve.type!=="symbol")continue;const _e=a.F(ve.source,ve.scope);let Re=z[_e];if(!Re){const Te=this.getLayerSourceCache(ve);if(!Te)continue;const Xe=Te.getRenderableIds(!0).map($e=>Te.getTileByID($e));W[_e]=Xe.slice(),Re=z[_e]=Xe.sort(($e,Ke)=>Ke.tileID.overscaledZ-$e.tileID.overscaledZ||($e.tileID.isLessThan(Ke.tileID)?-1:1))}const Me=this.crossTileSymbolIndex.addLayer(ve,Re,d.center.lng,d.projection);L=L||Me}this.crossTileSymbolIndex.pruneUnusedLayers(this._mergedOrder);const Z=!!(this.placement&&!d.equals(this.placement.transform)),ne=!!(this.placement&&(this.placement.lastReplacementSourceUpdateTime!==0&&!R||this.placement.lastReplacementSourceUpdateTime!==R.updateTime)),re=Z||ne||L,ie=(re||this.pauseablePlacement.isStale())&&S===0,ce=this.pauseablePlacement.isDone()&&!this.placement.stillRecent(a.o.now(),d.zoom)&&S!==0;if((this.pauseablePlacement.isFullPlacementRequested()||!this.pauseablePlacement.placement||ie||ce)&&(this.pauseablePlacement=this.pauseablePlacement.startNewPlacement(d,this._mergedOrder,g,S,j,this.placement,this.fog&&d.projection.supportsFog?this.fog.state:null,this._buildingIndex),this.map.painter)){const le=this.map.painter.maxFrontCutoffRawStart;if(le>0){const ve=180*d.pitch/Math.PI;if(ve>=15){const _e=Math.min(1,Math.max(0,(ve-15)/5)),Re=_e*_e*(3-2*_e);this.pauseablePlacement.placement.frontCutoffStart=-.5*(1-Re)+le*Re}}}if(this.pauseablePlacement.isDone()?re&&S!==0&&this.pauseablePlacement.setStale():(this.pauseablePlacement.continuePlacement(this._mergedOrder,this._mergedLayers,z,W,this.map.painter.scaleFactor),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(a.o.now()),F=!0),L&&this.pauseablePlacement.setStale()),F||L){this._buildingIndex.onNewFrame(d.zoom);for(let le=0;leR===d.id)!==-1)return void this.fire(new a.B(new Error(`Import with id '${d.id}' already exists in the map's style.`)));if(!g)return S.push(d),this._loadImports([d],!0);const j=S.findIndex(({id:R})=>R===g);return j===-1&&this.fire(new a.B(new Error(`Import with id "${g}" does not exist on this map.`))),this.stylesheet.imports=S.slice(0,j).concat(d).concat(S.slice(j)),this._loadImports([d],!0,g)}updateImport(d,g){this._checkLoaded();const S=this.stylesheet.imports||[],j=this.getImportIndex(d);return j===-1?this:typeof g=="string"?(this.setImportUrl(d,g),this):(g.url&&g.url!==S[j].url&&this.setImportUrl(d,g.url),a.b6(g.config,S[j].config)||this.setImportConfig(d,g.config,g.data.schema),a.b6(g.data,S[j].data)||this.setImportData(d,g.data),this)}moveImport(d,g){this._checkLoaded();let S=this.stylesheet.imports||[];const j=this.getImportIndex(d);if(j===-1)return this;const R=this.getImportIndex(g);if(R===-1)return this;const L=S[j],F=this.fragments[j];return S=S.filter(({id:z})=>z!==d),this.fragments=this.fragments.filter(({id:z})=>z!==d),this.stylesheet.imports=S.slice(0,R).concat(L).concat(S.slice(R)),this.fragments=this.fragments.slice(0,R).concat(F).concat(this.fragments.slice(R)),this.mergeLayers(),this}setImportUrl(d,g){this._checkLoaded();const S=this.stylesheet.imports||[],j=this.getImportIndex(d);if(j===-1)return this;S[j].url=g;const R=this.fragments[j];return R.style=this._createFragmentStyle(S[j]),R.style.on("style.import.load",()=>this.mergeAll()),R.style.loadURL(g),this}setImportData(d,g){this._checkLoaded();const S=this.getImportIndex(d),j=this.stylesheet.imports||[];return S===-1?this:g?(this.fragments[S].style.setState(g),this._reloadImports(),this):(delete j[S].data,this.setImportUrl(d,j[S].url))}setImportConfig(d,g,S){this._checkLoaded();const j=this.getImportIndex(d),R=this.stylesheet.imports||[];if(j===-1)return this;g?R[j].config=g:delete R[j].config;const L=this.fragments[j];S&&L.style.stylesheet&&(L.style.stylesheet.schema=S);const F=L.style.stylesheet&&L.style.stylesheet.schema;return L.config=g,L.style.updateConfig(g,F),this.updateConfigDependencies(),this}removeImport(d){this._checkLoaded();const g=this.stylesheet.imports||[],S=this.getImportIndex(d);S!==-1&&(g.splice(S,1),this.fragments[S].style._remove(),this.fragments.splice(S,1),this._reloadImports())}getImportIndex(d){const g=(this.stylesheet.imports||[]).findIndex(S=>S.id===d);return g===-1&&this.fire(new a.B(new Error(`Import '${d}' does not exist in the map's style and cannot be updated.`))),g}getLayer(d){return this._mergedLayers[d]}getSources(){const d=[];for(const g in this._mergedOtherSourceCaches){const S=this._mergedOtherSourceCaches[g];S&&d.push(S.getSource())}return d}getSource(d,g){const S=this.getSourceCache(d,g);return S&&S.getSource()}getLayerSource(d){const g=this.getLayerSourceCache(d);return g&&g.getSource()}getSourceCache(d,g){const S=a.F(d,g);return this._mergedOtherSourceCaches[S]}getLayerSourceCache(d){const g=a.F(d.source,d.scope);return d.type==="symbol"?this._mergedSymbolSourceCaches[g]:d.type==="fill-extrusion"&&this._mergedFillExtrusionSourceCaches[g]||this._mergedOtherSourceCaches[g]}getSourceCaches(d){if(d==null)return Object.values(this._mergedSourceCaches);const g=[];return this._mergedOtherSourceCaches[d]&&g.push(this._mergedOtherSourceCaches[d]),this._mergedSymbolSourceCaches[d]&&g.push(this._mergedSymbolSourceCaches[d]),this._mergedFillExtrusionSourceCaches[d]&&g.push(this._mergedFillExtrusionSourceCaches[d]),g}updateSourceCaches(){const d=this._changes.getUpdatedSourceCaches();for(const g in d){const S=d[g];S==="reload"?this.reloadSource(g):S==="clear"&&this.clearSource(g)}}updateLayers(d){const g=this._changes.getUpdatedPaintProperties();for(const S of g){const j=this.getLayer(S);j&&j.updateTransitions(d)}}getGlyphsUrl(){return this.stylesheet.glyphs}setGlyphsUrl(d){this.stylesheet.glyphs=d,this.glyphManager.setURL(d)}getImages(d,g,S){this.imageManager.getImages(g.images,g.scope,S),this._updateTilesForChangedImages();const j=L=>{if(L){const F=g.images.map(z=>a.I.toString(z));L.setDependencies(g.tileID.key,g.type,F)}},R=a.F(g.source,g.scope);j(this._mergedOtherSourceCaches[R]),j(this._mergedSymbolSourceCaches[R]),g.images.some(L=>L.iconsetId)&&this.fire(new a.C("data",{dataType:"style"}))}rasterizeImages(d,g,S){this.imageManager.rasterizeImages(g,S)}checkAtlasCache(d,g,S){const j=this.imageManager.imageAtlasCache.findCachedAtlas(g.descriptor);S(null,j&&j.contentDescriptor?{iconPositions:j.iconPositions,patternPositions:j.patternPositions,sourceHash:j.contentDescriptor.hash}:null)}getGlyphs(d,g,S){this.glyphManager.getGlyphs(g.stacks,S)}getOwnSourceCache(d){return this._otherSourceCaches[d]}getOwnLayerSourceCache(d){return d.type==="symbol"?this._symbolSourceCaches[d.source]:d.type==="fill-extrusion"&&this._fillExtrusionSourceCaches[d.source]||this._otherSourceCaches[d.source]}getOwnSourceCaches(d){const g=[];return this._otherSourceCaches[d]&&g.push(this._otherSourceCaches[d]),this._symbolSourceCaches[d]&&g.push(this._symbolSourceCaches[d]),this._fillExtrusionSourceCaches[d]&&g.push(this._fillExtrusionSourceCaches[d]),g}_isSourceCacheLoaded(d){const g=this.getOwnSourceCaches(d);return g.length===0?(this.fire(new a.B(new Error(`There is no source with ID '${d}'`))),!1):g.every(S=>S.loaded())}has3DLayers(){return this._has3DLayers}hasSymbolLayers(){return this._hasSymbolLayers}hasCircleLayers(){return this._hasCircleLayers}isLayerClipped(d,g){if(!this._clipLayerPresent&&d.type!=="fill-extrusion"&&d.type!=="building")return!1;const S=d.type==="fill-extrusion"&&(d.sourceLayer==="building"||d.sourceLayer==="procedural_buildings"),j=d.type==="building";if(d.is3D(!!this.terrain)){if(S||j||g&&g.type==="batched-model"||d.type==="model")return!0}else if(d.type==="symbol")return!0;return!1}_clearWorkerCaches(){this.dispatcher.broadcast("clearCaches")}getBOMObject(){}destroy(){this._clearWorkerCaches(),this.imageManager.imageAtlasCache.clear(),this.fragments.forEach(d=>{d.style._remove()}),this.terrainSetForDrapingOnly()&&(delete this.terrain,delete this.stylesheet.terrain)}}Ru.getSourceType=function(v){return gb[v]},Ru.setSourceType=function(v,d){gb[v]=d},Ru.registerForPluginStateChange=a.dk;var HE=` #define EPSILON 0.0000001 #define PI 3.141592653589793 #ifdef RENDER_CUTOFF float cutoff_opacity(vec4 cutoff_params,float depth) {float near=cutoff_params.x;float far=cutoff_params.y;float cutoffStart=cutoff_params.z;float cutoffEnd=cutoff_params.w;float linearDepth=(depth-near)/(far-near);return clamp((linearDepth-cutoffStart)/(cutoffEnd-cutoffStart),0.0,1.0);} #endif`,WE=` #ifdef DUAL_SOURCE_BLENDING layout(location=0,index=0) out vec4 glFragColor;layout(location=0,index=1) out vec4 glFragColorSrc1; #elif defined(FLOAT_RENDER_TARGET) layout(location=0) out highp vec4 glFragColor; #else layout(location=0) out vec4 glFragColor; #endif #ifdef USE_MRT1 layout(location=1) out vec4 out_Target1; #endif highp float unpack_depth(highp vec4 rgba_depth) {const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}highp vec4 pack_depth(highp float ndc_z) {highp float depth=ndc_z*0.5+0.5;const highp vec4 bit_shift=vec4(255.0*255.0*255.0,255.0*255.0,255.0,1.0);const highp vec4 bit_mask =vec4(0.0,1.0/255.0,1.0/255.0,1.0/255.0);highp vec4 res=fract(depth*bit_shift);res-=res.xxyz*bit_mask;return res;} #ifdef INDICATOR_CUTOUT uniform vec3 u_indicator_cutout_centers;uniform vec4 u_indicator_cutout_params; #endif const float DITHER_THRESHOLDS[16]=float[16]( 1.0/17.0, 9.0/17.0, 3.0/17.0,11.0/17.0,13.0/17.0, 5.0/17.0,15.0/17.0, 7.0/17.0,4.0/17.0,12.0/17.0, 2.0/17.0,10.0/17.0,16.0/17.0, 8.0/17.0,14.0/17.0, 6.0/17.0 );vec4 applyCutout(vec4 color,float height) { #ifdef INDICATOR_CUTOUT float verticalFadeRange=u_indicator_cutout_centers.z*0.25;float holeMinOpacity=mix(1.0,u_indicator_cutout_params.x,smoothstep(u_indicator_cutout_centers.z,u_indicator_cutout_centers.z+verticalFadeRange,height));float holeRadius=max(u_indicator_cutout_params.y,0.0);float holeAspectRatio=u_indicator_cutout_params.z;float fadeStart=u_indicator_cutout_params.w;float distA=distance(vec2(gl_FragCoord.x,gl_FragCoord.y*holeAspectRatio),vec2(u_indicator_cutout_centers[0],u_indicator_cutout_centers[1]*holeAspectRatio));return color*min(smoothstep(fadeStart,holeRadius,distA)+holeMinOpacity,1.0); #else return color; #endif }float cutoutGroundRoofOpacity(vec4 groundRoof) { #ifdef INDICATOR_CUTOUT float fadeStartX=u_indicator_cutout_params.w;float holeRadius=u_indicator_cutout_params.y;float holeMinOpacity=mix(u_indicator_cutout_params.x,1.0,smoothstep(u_indicator_cutout_params.z,u_indicator_cutout_centers.z,groundRoof.y));float distX=abs(u_indicator_cutout_centers.x-groundRoof.x);float roofOpacity=mix(holeMinOpacity,1.0,smoothstep(fadeStartX,holeRadius,u_indicator_cutout_centers.y-groundRoof.w));float groundOpacity=min(smoothstep(fadeStartX,holeRadius,distX)+holeMinOpacity,1.0);return max(roofOpacity,groundOpacity); #else return 1.0; #endif } #ifdef DEBUG_WIREFRAME #define HANDLE_WIREFRAME_DEBUG \\ glFragColor=vec4(0.7,0.0,0.0,0.7); \\ gl_FragDepth=gl_FragCoord.z-0.0001; #else #define HANDLE_WIREFRAME_DEBUG #endif #ifdef RENDER_CUTOFF uniform highp vec4 u_cutoff_params;in float v_cutoff_opacity; #endif vec4 textureLodCustom(sampler2D image,highp vec2 pos,highp vec2 lod_coord) {highp vec2 size=vec2(textureSize(image,0));highp vec2 dx=dFdx(lod_coord.xy*size);highp vec2 dy=dFdy(lod_coord.xy*size);highp float delta_max_sqr=max(dot(dx,dx),dot(dy,dy));highp float lod=0.5*log2(delta_max_sqr);return textureLod(image,pos,lod);}vec4 applyLUT(highp sampler3D lut,vec4 col) {vec3 size=vec3(textureSize(lut,0));vec3 uvw=(col.rbg*float(size-1.0)+0.5)/size;return vec4(texture(lut,uvw).rgb*col.a,col.a);}vec3 applyLUT(highp sampler3D lut,vec3 col) {return applyLUT(lut,vec4(col,1.0)).rgb;}`,Zf=` #define EXTENT 8192.0 #define RAD_TO_DEG 180.0/PI #define DEG_TO_RAD PI/180.0 #define GLOBE_RADIUS EXTENT/PI/2.0 float wrap(float n,float min,float max) {float d=max-min;float w=mod(mod(n-min,d)+d,d)+min;return (w==min) ? max : w;} #ifdef PROJECTION_GLOBE_VIEW vec3 mercator_tile_position(mat4 matrix,vec2 tile_anchor,vec3 tile_id,vec2 mercator_center) { #ifndef PROJECTED_POS_ON_VIEWPORT float tiles=tile_id.z;vec2 mercator=(tile_anchor/EXTENT+tile_id.xy)/tiles;mercator-=mercator_center;mercator.x=wrap(mercator.x,-0.5,0.5);vec4 mercator_tile=vec4(mercator.xy*EXTENT,EXTENT/(2.0*PI),1.0);mercator_tile=matrix*mercator_tile;return mercator_tile.xyz; #else return vec3(0.0); #endif }vec3 mix_globe_mercator(vec3 globe,vec3 mercator,float t) {return mix(globe,mercator,t);}mat3 globe_mercator_surface_vectors(vec3 pos_normal,vec3 up_dir,float zoom_transition) {vec3 normal=zoom_transition==0.0 ? pos_normal : normalize(mix(pos_normal,up_dir,zoom_transition));vec3 xAxis=normalize(vec3(normal.z,0.0,-normal.x));vec3 yAxis=normalize(cross(normal,xAxis));return mat3(xAxis,yAxis,normal);} #endif vec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec4 decode_color(const vec2 encodedColor) {return vec4( unpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0 );}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const vec2 units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (units_to_pixels*pos+offset)/pattern_size;}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {return get_pattern_pos(pixel_coord_upper,pixel_coord_lower,pattern_size,vec2(tile_units_to_pixels),pos);}float mercatorXfromLng(float lng) {return (180.0+lng)/360.0;}float mercatorYfromLat(float lat) {return (180.0-(RAD_TO_DEG*log(tan(PI/4.0+lat/2.0*DEG_TO_RAD))))/360.0;}vec3 latLngToECEF(vec2 latLng) {latLng=DEG_TO_RAD*latLng;float cosLat=cos(latLng[0]);float sinLat=sin(latLng[0]);float cosLng=cos(latLng[1]);float sinLng=sin(latLng[1]);float sx=cosLat*sinLng*GLOBE_RADIUS;float sy=-sinLat*GLOBE_RADIUS;float sz=cosLat*cosLng*GLOBE_RADIUS;return vec3(sx,sy,sz);} #ifdef RENDER_CUTOFF uniform vec4 u_cutoff_params;out float v_cutoff_opacity; #endif const vec4 AWAY=vec4(-1000.0,-1000.0,-1000.0,1);const float skirtOffset=24575.0;vec3 decomposeToPosAndSkirt(ivec2 posWithComposedSkirt) {float skirt=float(float(posWithComposedSkirt.x) >=skirtOffset);vec2 pos=vec2(posWithComposedSkirt)-vec2(skirt*skirtOffset,0.0);return vec3(pos,skirt);} #ifndef HAS_SHADER_STORAGE_BLOCK_material_buffer #define GET_ATTRIBUTE_float(attrib,matInfo,attrib_id) attrib #define GET_ATTRIBUTE_vec4(attrib,matInfo,attrib_id) attrib #define GET_ATTRIBUTE_vec2(attrib,matInfo,attrib_id) attrib #define DECLARE_MATERIAL_TABLE_INFO #endif`,z0="in highp vec3 a_pos_3f;uniform lowp mat4 u_matrix;out highp vec3 v_uv;void main() {const mat3 half_neg_pi_around_x=mat3(1.0,0.0, 0.0,0.0,0.0,-1.0,0.0,1.0, 0.0);v_uv=half_neg_pi_around_x*a_pos_3f;vec4 pos=u_matrix*vec4(a_pos_3f,1.0);gl_Position=pos.xyww;}",KE=` #define ELEVATION_SCALE 7.0 #define ELEVATION_OFFSET 450.0 #ifdef PROJECTION_GLOBE_VIEW uniform vec3 u_tile_tl_up;uniform vec3 u_tile_tr_up;uniform vec3 u_tile_br_up;uniform vec3 u_tile_bl_up;uniform float u_tile_up_scale;vec3 elevationVector(vec2 pos) {vec2 uv=pos/EXTENT;vec3 up=normalize(mix( mix(u_tile_tl_up,u_tile_tr_up,uv.xxx),mix(u_tile_bl_up,u_tile_br_up,uv.xxx),uv.yyy));return up*u_tile_up_scale;} #else vec3 elevationVector(vec2 pos) { return vec3(0,0,1); } #endif #ifdef TERRAIN uniform highp sampler2D u_dem;uniform highp sampler2D u_dem_prev;uniform vec2 u_dem_tl;uniform vec2 u_dem_tl_prev;uniform float u_dem_scale;uniform float u_dem_scale_prev;uniform float u_dem_size;uniform float u_dem_lerp;uniform float u_exaggeration;uniform float u_meter_to_dem;uniform mat4 u_label_plane_matrix_inv;vec4 tileUvToDemSample(vec2 uv,float dem_size,float dem_scale,vec2 dem_tl) {vec2 pos=dem_size*(uv*dem_scale+dem_tl)+1.0;vec2 f=fract(pos);return vec4((pos-f+0.5)/(dem_size+2.0),f);}float currentElevation(vec2 apos) { #ifdef TERRAIN_DEM_FLOAT_FORMAT vec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale+u_dem_tl)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture(u_dem,pos).r; #else float dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale,u_dem_tl);vec2 pos=r.xy;vec2 f=r.zw;float tl=texture(u_dem,pos).r;float tr=texture(u_dem,pos+vec2(dd,0)).r;float bl=texture(u_dem,pos+vec2(0,dd)).r;float br=texture(u_dem,pos+vec2(dd,dd)).r;return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y); #endif }float prevElevation(vec2 apos) { #ifdef TERRAIN_DEM_FLOAT_FORMAT vec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale_prev+u_dem_tl_prev)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture(u_dem_prev,pos).r; #else float dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale_prev,u_dem_tl_prev);vec2 pos=r.xy;vec2 f=r.zw;float tl=texture(u_dem_prev,pos).r;float tr=texture(u_dem_prev,pos+vec2(dd,0)).r;float bl=texture(u_dem_prev,pos+vec2(0,dd)).r;float br=texture(u_dem_prev,pos+vec2(dd,dd)).r;return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y); #endif } #ifdef TERRAIN_VERTEX_MORPHING float elevation(vec2 apos) { #ifdef ZERO_EXAGGERATION return 0.0; #endif float nextElevation=currentElevation(apos);float prevElevation=prevElevation(apos);return mix(prevElevation,nextElevation,u_dem_lerp);} #else float elevation(vec2 apos) { #ifdef ZERO_EXAGGERATION return 0.0; #endif return currentElevation(apos);} #endif vec4 fourSample(vec2 pos,vec2 off) {float tl=texture(u_dem,pos).r;float tr=texture(u_dem,pos+vec2(off.x,0.0)).r;float bl=texture(u_dem,pos+vec2(0.0,off.y)).r;float br=texture(u_dem,pos+off).r;return vec4(tl,tr,bl,br);}float flatElevation(vec2 pack) {vec2 apos=floor(pack/8.0);vec2 span=10.0*(pack-apos*8.0);vec2 uvTex=(apos-vec2(1.0,1.0))/8190.0;float size=u_dem_size+2.0;float dd=1.0/size;vec2 pos=u_dem_size*(uvTex*u_dem_scale+u_dem_tl)+1.0;vec2 f=fract(pos);pos=(pos-f+0.5)*dd;vec4 h=fourSample(pos,vec2(dd));float z=mix(mix(h.x,h.y,f.x),mix(h.z,h.w,f.x),f.y);vec2 w=floor(0.5*(span*u_meter_to_dem-1.0));vec2 d=dd*w;h=fourSample(pos-d,2.0*d+vec2(dd));vec4 diff=abs(h.xzxy-h.ywzw);vec2 slope=min(vec2(0.25),u_meter_to_dem*0.5*(diff.xz+diff.yw)/(2.0*w+vec2(1.0)));vec2 fix=slope*span;float base=z+max(fix.x,fix.y);return u_exaggeration*base;}float elevationFromUint16(float word) {return u_exaggeration*(word/ELEVATION_SCALE-ELEVATION_OFFSET);} #else float elevation(vec2 pos) { return 0.0; } #endif #ifdef DEPTH_OCCLUSION uniform highp sampler2D u_depth;uniform highp vec2 u_depth_size_inv;uniform highp vec2 u_depth_range_unpack;uniform highp float u_occluder_half_size;uniform highp float u_occlusion_depth_offset; #ifdef DEPTH_D24 float unpack_depth(float depth) {return depth*u_depth_range_unpack.x+u_depth_range_unpack.y;}vec4 unpack_depth4(vec4 depth) {return depth*u_depth_range_unpack.x+vec4(u_depth_range_unpack.y);} #else highp float unpack_depth_rgba(vec4 rgba_depth) {const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;} #endif bool isOccluded(vec4 frag) {vec3 coord=frag.xyz/frag.w; #ifdef CLIP_ZERO_TO_ONE coord.z=-1.0+2.0*coord.z; #endif #ifdef DEPTH_D24 float depth=unpack_depth(texture(u_depth,(coord.xy+1.0)*0.5).r); #else float depth=unpack_depth_rgba(texture(u_depth,(coord.xy+1.0)*0.5)); #endif return coord.z+u_occlusion_depth_offset > depth;}highp vec4 getCornerDepths(vec2 coord) {highp vec3 df=vec3(u_occluder_half_size*u_depth_size_inv,0.0);highp vec2 uv=0.5*coord.xy+0.5; #ifdef DEPTH_D24 highp vec4 depth=vec4( texture(u_depth,uv-df.xz).r,texture(u_depth,uv+df.xz).r,texture(u_depth,uv-df.zy).r,texture(u_depth,uv+df.zy).r );depth=unpack_depth4(depth); #else highp vec4 depth=vec4( unpack_depth_rgba(texture(u_depth,uv-df.xz)),unpack_depth_rgba(texture(u_depth,uv+df.xz)),unpack_depth_rgba(texture(u_depth,uv-df.zy)),unpack_depth_rgba(texture(u_depth,uv+df.zy)) ); #endif return depth;}highp float occlusionFadeMultiSample(vec4 frag) {highp vec3 coord=frag.xyz/frag.w;highp vec2 uv=0.5*coord.xy+0.5; #ifdef CLIP_ZERO_TO_ONE coord.z=-1.0+2.0*coord.z; #endif int NX=3;int NY=4;highp vec2 df=u_occluder_half_size*u_depth_size_inv;highp vec2 oneStep=2.0*u_occluder_half_size*u_depth_size_inv/vec2(NX-1,NY-1);highp float res=0.0;for (int y=0; y < NY;++y) {for (int x=0; x < NX;++x) { #ifdef DEPTH_D24 highp float depth=unpack_depth(texture(u_depth,uv-df+vec2(float(x)*oneStep.x,float(y)*oneStep.y)).r); #else highp float depth=unpack_depth_rgba(texture(u_depth,uv-df+vec2(float(x)*oneStep.x,float(y)*oneStep.y))); #endif res+=1.0-clamp(300.0*(coord.z+u_occlusion_depth_offset-depth),0.0,1.0);}}res=clamp(2.0*res/float(NX*NY)-0.5,0.0,1.0);return res;}highp float occlusionFade(vec4 frag) {highp vec3 coord=frag.xyz/frag.w; #ifdef CLIP_ZERO_TO_ONE coord.z=-1.0+2.0*coord.z; #endif highp vec4 depth=getCornerDepths(coord.xy);return dot(vec4(0.25),vec4(1.0)-clamp(300.0*(vec4(coord.z+u_occlusion_depth_offset)-depth),0.0,1.0));} #else bool isOccluded(vec4 frag) { return false; }highp float occlusionFade(vec4 frag) { return 1.0; }highp float occlusionFadeMultiSample(vec4 frag) { return 1.0; } #endif`,YE=`#ifdef FOG uniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;uniform mediump mat4 u_fog_matrix;out vec3 v_fog_pos;float fog_range(float depth) {return (depth-u_fog_range[0])/(u_fog_range[1]-u_fog_range[0]);}float fog_horizon_blending(vec3 camera_dir) {float t=max(0.0,camera_dir.z/u_fog_horizon_blend);return u_fog_color.a*exp(-3.0*t*t);}float fog_opacity(float t) {const float decay=6.0;float falloff=1.0-min(1.0,exp(-decay*t));falloff*=falloff*falloff;return u_fog_color.a*min(1.0,1.00747*falloff);}vec3 fog_position(vec3 pos) {return (u_fog_matrix*vec4(pos,1.0)).xyz;}vec3 fog_position(vec2 pos) {return fog_position(vec3(pos,0.0));}float fog(vec3 pos) {float depth=length(pos);float opacity=fog_opacity(fog_range(depth));return opacity*fog_horizon_blending(pos/depth);} #endif`,ny=`#ifdef FOG uniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;uniform mediump vec2 u_fog_vertical_limit;uniform mediump float u_fog_temporal_offset;in vec3 v_fog_pos;uniform highp vec3 u_frustum_tl;uniform highp vec3 u_frustum_tr;uniform highp vec3 u_frustum_br;uniform highp vec3 u_frustum_bl;uniform highp vec3 u_globe_pos;uniform highp float u_globe_radius;uniform highp vec2 u_viewport;uniform float u_globe_transition;uniform int u_is_globe;float fog_range(float depth) {return (depth-u_fog_range[0])/(u_fog_range[1]-u_fog_range[0]);}float fog_horizon_blending(vec3 camera_dir) {float t=max(0.0,camera_dir.z/u_fog_horizon_blend);return u_fog_color.a*exp(-3.0*t*t);}float fog_opacity(float t) {const float decay=6.0;float falloff=1.0-min(1.0,exp(-decay*t));falloff*=falloff*falloff;return u_fog_color.a*min(1.0,1.00747*falloff);}float globe_glow_progress() {highp vec2 uv=gl_FragCoord.xy/u_viewport; #ifdef FLIP_Y uv.y=1.0-uv.y; #endif highp vec3 ray_dir=mix( mix(u_frustum_tl,u_frustum_tr,uv.x),mix(u_frustum_bl,u_frustum_br,uv.x),1.0-uv.y);highp vec3 dir=normalize(ray_dir);highp vec3 closest_point=dot(u_globe_pos,dir)*dir;highp float sdf=length(closest_point-u_globe_pos)/u_globe_radius;return sdf+PI*0.5;}float fog_opacity(vec3 pos) {float depth=length(pos);return fog_opacity(fog_range(depth));}vec3 fog_apply(vec3 color,vec3 pos,float opacity_limit) {float depth=length(pos);float opacity;if (u_is_globe==1) {float glow_progress=globe_glow_progress();float t=mix(glow_progress,depth,u_globe_transition);opacity=fog_opacity(fog_range(t));} else {opacity=fog_opacity(fog_range(depth));opacity*=fog_horizon_blending(pos/depth);}return mix(color,u_fog_color.rgb,min(opacity,opacity_limit));}vec3 fog_apply(vec3 color,vec3 pos) {return fog_apply(color,pos,1.0);}vec4 fog_apply_from_vert(vec4 color,float fog_opac) {float alpha=EPSILON+color.a;color.rgb=mix(color.rgb/alpha,u_fog_color.rgb,fog_opac)*alpha;return color;}vec3 fog_apply_sky_gradient(vec3 camera_ray,vec3 sky_color) {float horizon_blend=fog_horizon_blending(normalize(camera_ray));return mix(sky_color,u_fog_color.rgb,horizon_blend);}vec4 fog_apply_premultiplied(vec4 color,vec3 pos) {float alpha=EPSILON+color.a;color.rgb=fog_apply(color.rgb/alpha,pos)*alpha;return color;}vec4 fog_apply_premultiplied(vec4 color,vec3 pos,float heightMeters) {float verticalProgress=(u_fog_vertical_limit.x > 0.0 || u_fog_vertical_limit.y > 0.0) ? smoothstep(u_fog_vertical_limit.x,u_fog_vertical_limit.y,heightMeters) : 0.0;float opacityLimit=1.0-smoothstep(0.9,1.0,fog_opacity(pos));return mix(fog_apply_premultiplied(color,pos),color,min(verticalProgress,opacityLimit));}vec3 fog_dither(vec3 color) {return color;}vec4 fog_dither(vec4 color) {return vec4(fog_dither(color.rgb),color.a);} #endif`,sy=`#ifdef RASTER_ARRAY uniform highp sampler2D u_image0;uniform sampler2D u_image1;const vec4 NODATA=vec4(1);ivec4 _raTexLinearCoord(highp vec2 texCoord,highp vec2 texResolution,out highp vec2 fxy) {texCoord=texCoord*texResolution-0.5;fxy=fract(texCoord);texCoord-=fxy;return ivec4(texCoord.xxyy+vec2(1.5,0.5).xyxy);}vec2 _raTexLinearMix(highp vec2 fxy,highp vec4 colorMix,highp float colorOffset,highp vec4 t00,highp vec4 t10,highp vec4 t01,highp vec4 t11) {vec2 c00=t00==NODATA ? vec2(0) : vec2(colorOffset+dot(t00,colorMix),1);vec2 c10=t10==NODATA ? vec2(0) : vec2(colorOffset+dot(t10,colorMix),1);vec2 c01=t01==NODATA ? vec2(0) : vec2(colorOffset+dot(t01,colorMix),1);vec2 c11=t11==NODATA ? vec2(0) : vec2(colorOffset+dot(t11,colorMix),1);return mix(mix(c01,c11,fxy.x),mix(c00,c10,fxy.x),fxy.y);}vec2 raTexture2D_image0_linear(highp vec2 texCoord,highp vec2 texResolution,highp vec4 colorMix,highp float colorOffset) {vec2 fxy;ivec4 c=_raTexLinearCoord(texCoord,texResolution,fxy);return _raTexLinearMix(fxy,colorMix,colorOffset,texelFetch(u_image0,c.yz,0),texelFetch(u_image0,c.xz,0),texelFetch(u_image0,c.yw,0),texelFetch(u_image0,c.xw,0) );}vec2 raTexture2D_image1_linear(highp vec2 texCoord,highp vec2 texResolution,highp vec4 colorMix,highp float colorOffset) {vec2 fxy;ivec4 c=_raTexLinearCoord(texCoord,texResolution,fxy);return _raTexLinearMix(fxy,colorMix,colorOffset,texelFetch(u_image1,c.yz,0),texelFetch(u_image1,c.xz,0),texelFetch(u_image1,c.yw,0),texelFetch(u_image1,c.xw,0) );}vec2 raTexture2D_image0_nearest(highp vec2 texCoord,highp vec2 texResolution,highp vec4 colorMix,highp float colorOffset) {vec4 t=texelFetch(u_image0,ivec2(texCoord*texResolution),0);return t==NODATA ? vec2(0) : vec2(colorOffset+dot(t,colorMix),1);}vec2 raTexture2D_image1_nearest(highp vec2 texCoord,highp vec2 texResolution,highp vec4 colorMix,highp float colorOffset) {vec4 t=texelFetch(u_image1,ivec2(texCoord*texResolution),0);return t==NODATA ? vec2(0) : vec2(colorOffset+dot(t,colorMix),1);} #endif`,ZE=`#ifdef RASTER_ARRAY uniform sampler2D u_velocity;uniform mediump vec2 u_velocity_res;uniform mediump float u_max_speed;const vec4 NO_DATA=vec4(1);const vec2 INVALID_VELOCITY=vec2(-1);uniform highp vec2 u_uv_offset;uniform highp float u_data_offset;uniform highp vec2 u_data_scale;ivec4 rasterArrayLinearCoord(highp vec2 texCoord,highp vec2 texResolution,out highp vec2 fxy) {texCoord=texCoord*texResolution-0.5;fxy=fract(texCoord);texCoord-=fxy;return ivec4(texCoord.xxyy+vec2(1.5,0.5).xyxy);}highp vec2 lookup_velocity(highp vec2 uv) {uv=u_uv_offset.x+u_uv_offset.y*uv;highp vec2 fxy;ivec4 c=rasterArrayLinearCoord(uv,u_velocity_res,fxy);highp vec4 tl=texelFetch(u_velocity,c.yz,0);highp vec4 tr=texelFetch(u_velocity,c.xz,0);highp vec4 bl=texelFetch(u_velocity,c.yw,0);highp vec4 br=texelFetch(u_velocity,c.xw,0);if (tl==NO_DATA) {return INVALID_VELOCITY;}if (tr==NO_DATA) {return INVALID_VELOCITY;}if (bl==NO_DATA) {return INVALID_VELOCITY;}if (br==NO_DATA) {return INVALID_VELOCITY;}highp vec4 t=mix(mix(bl,br,fxy.x),mix(tl,tr,fxy.x),fxy.y);highp vec2 velocity=u_data_offset+vec2(dot(t.rg,u_data_scale),dot(t.ba,u_data_scale));velocity.y=-velocity.y;velocity/=max(u_max_speed,length(velocity));return velocity;} #endif uniform highp float u_particle_pos_scale;uniform highp vec2 u_particle_pos_offset;highp vec4 pack_pos_to_rgba(highp vec2 p) {highp vec2 v=(p+u_particle_pos_offset)/u_particle_pos_scale;highp vec4 r=vec4(v.x,fract(v.x*255.0),v.y,fract(v.y*255.0));return vec4(r.x-r.y/255.0,r.y,r.z-r.w/255.0,r.w);}highp vec2 unpack_pos_from_rgba(highp vec4 v) {v=floor(v*255.0+0.5)/255.0;highp vec2 p=vec2(v.x+(v.y/255.0),v.z+(v.w/255.0));return u_particle_pos_scale*p-u_particle_pos_offset;}`,Ib=`#ifdef RENDER_SHADOWS uniform mediump vec3 u_shadow_direction;uniform highp vec3 u_shadow_normal_offset;vec3 shadow_normal_offset(vec3 normal) {float tileInMeters=u_shadow_normal_offset[0];vec3 n=vec3(-normal.xy,tileInMeters*normal.z);float dotScale=min(1.0-dot(normal,u_shadow_direction),1.0)*0.5+0.5;return n*dotScale;}vec3 shadow_normal_offset_model(vec3 normal) {vec3 transformed_normal=vec3(-normal.xy,normal.z);float NDotL=dot(normalize(transformed_normal),u_shadow_direction);float dotScale=min(1.0-NDotL,1.0)*0.5+0.5;return normal*dotScale;}float shadow_normal_offset_multiplier0() {return u_shadow_normal_offset[1];}float shadow_normal_offset_multiplier1() {return u_shadow_normal_offset[2];} #endif`,Gc=`#ifdef RENDER_SHADOWS precision highp sampler2DShadow;uniform sampler2DShadow u_shadowmap_0;uniform sampler2DShadow u_shadowmap_1;uniform float u_shadow_intensity;uniform float u_shadow_map_resolution;uniform float u_shadow_texel_size;uniform highp vec3 u_shadow_normal_offset;uniform vec2 u_fade_range;uniform mediump vec3 u_shadow_direction;uniform highp vec3 u_shadow_bias;float shadow_sample(sampler2DShadow shadowmap,highp vec3 pos,highp float bias) { #ifdef CLIP_ZERO_TO_ONE highp vec3 coord=vec3(pos.xy*0.5+0.5,pos.z-bias); #else highp vec3 coord=vec3(pos.xy*0.5+0.5,pos.z*0.5+0.5-bias); #endif return texture(shadowmap,coord);}float shadow_occlusion(highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth,highp float bias) {light_view_pos0.xyz/=light_view_pos0.w; #ifdef SHADOWS_SINGLE_CASCADE vec2 abs_bounds=abs(light_view_pos0.xy);if (abs_bounds.x >=1.0 || abs_bounds.y >=1.0) {return 0.0;}return shadow_sample(u_shadowmap_0,light_view_pos0.xyz,bias); #else light_view_pos1.xyz/=light_view_pos1.w;vec4 abs_bounds=abs(vec4(light_view_pos0.xy,light_view_pos1.xy));if (abs_bounds.x < 1.0 && abs_bounds.y < 1.0) {return shadow_sample(u_shadowmap_0,light_view_pos0.xyz,bias);}if (abs_bounds.z >=1.0 || abs_bounds.w >=1.0) {return 0.0;}float occlusion1=shadow_sample(u_shadowmap_1,light_view_pos1.xyz,bias);return clamp(mix(occlusion1,0.0,smoothstep(u_fade_range.x,u_fade_range.y,view_depth)),0.0,1.0); #endif }highp float calculate_shadow_bias(float NDotL) { #ifdef NORMAL_OFFSET return 0.5*u_shadow_bias.x; #else return 0.5*(u_shadow_bias.x+clamp(u_shadow_bias.y*tan(acos(NDotL)),0.0,u_shadow_bias.z)); #endif }float shadowed_light_factor_normal(vec3 N,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float NDotL=dot(N,u_shadow_direction);float bias=calculate_shadow_bias(NDotL);float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return mix(0.0,(1.0-(u_shadow_intensity*occlusion))*NDotL,step(0.0,NDotL));}float shadowed_light_factor_normal_opacity(vec3 N,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth,float shadow_opacity) {float NDotL=dot(N,u_shadow_direction);float bias=calculate_shadow_bias(NDotL);float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias)*shadow_opacity;return mix(0.0,(1.0-(u_shadow_intensity*occlusion))*NDotL,step(0.0,NDotL));}float shadowed_light_factor_normal_unbiased(vec3 N,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float NDotL=dot(N,u_shadow_direction);float bias=0.0;float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return mix(0.0,(1.0-(u_shadow_intensity*occlusion))*NDotL,step(0.0,NDotL));}highp vec2 compute_receiver_plane_depth_bias(highp vec3 pos_dx,highp vec3 pos_dy) {highp vec2 biasUV=vec2( pos_dy.y*pos_dx.z-pos_dx.y*pos_dy.z,pos_dx.x*pos_dy.z-pos_dy.x*pos_dx.z);biasUV*=1.0/((pos_dx.x*pos_dy.y)-(pos_dx.y*pos_dy.x));return biasUV;}float shadowed_light_factor_plane_bias(highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {highp vec3 light_view_pos0_xyz=light_view_pos0.xyz/light_view_pos0.w*0.5+0.5;highp vec3 light_view_pos0_ddx=dFdx(light_view_pos0_xyz);highp vec3 light_view_pos0_ddy=dFdy(light_view_pos0_xyz);highp vec2 plane_depth_bias=compute_receiver_plane_depth_bias(light_view_pos0_ddx,light_view_pos0_ddy);highp float bias=dot(vec2(u_shadow_texel_size,u_shadow_texel_size),plane_depth_bias)+0.0001;float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return 1.0-(u_shadow_intensity*occlusion);}float shadowed_light_factor(highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float bias=0.0;float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return 1.0-(u_shadow_intensity*occlusion);}float shadow_occlusion(float ndotl,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float bias=calculate_shadow_bias(ndotl);return shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);} #endif`;const U0=/#include\s+"([^"]+)"/g,fr=/#pragma mapbox: ([\w\-]+) ([\w]+) ([\w]+) ([\w]+)/g,vI=/\b[A-Za-z_][A-Za-z0-9_]*\b/g,bI=new Set(["ifdef","ifndef","elif","if","defined"]),bp=new Set;zh(HE,bp),zh(Zf,bp),zh(WE,bp);const ud={"_prelude_fog.vertex.glsl":YE,"_prelude_terrain.vertex.glsl":KE,"_prelude_shadow.vertex.glsl":Ib,"_prelude_material_table.vertex.glsl":`#ifdef HAS_SHADER_STORAGE_BLOCK_material_buffer #define MATERIAL_TABLE_DEBUG 0 uniform int u_material_offset;uniform int u_vertex_offset;layout(std140,binding=0)readonly buffer material_buffer{uvec4 material_data[];};struct MaterialInfo{uint dataOffset; #if MATERIAL_TABLE_DEBUG vec4 colorDebug; #endif };uint read_buf_no_offset(uint iDword) {return material_data[iDword/4u][iDword % 4u];}uint read_buf(uint iDword) {iDword+=uint(u_material_offset/4);return read_buf_no_offset(iDword);}float read_buf_float(uint iDword){return uintBitsToFloat(read_buf(iDword));}uint read_buf_uint8(uint iDword,uint iUint8){uint dwordOffset=iDword+(iUint8/4u);uint byteOffset=iUint8 & 3u;uint bitOffset=8u*byteOffset;uint mask=0xffu << bitOffset;uint dwordVal=read_buf(dwordOffset);return (dwordVal & mask) >> bitOffset;}uint read_buf_uint16(uint iDword,uint iUint16){uint dwordOffset=iDword+(iUint16 >> 1u);uint bitOffset=(iUint16 & 1u)*16u;uint mask=0xffffu << bitOffset;uint dwordVal=read_buf(dwordOffset);return (dwordVal & mask) >> bitOffset;}uint nrDwordsForVertexIdEntries(uint nrMaterialLookupEntries) {return nrMaterialLookupEntries;}uint nrDwordsForMaterialIdEntries(uint nrMaterialLookupEntries) {return (nrMaterialLookupEntries*2u+3u)/4u;}uint findRangeBinarySearch(uint vertexId,uint numRanges,uint dwordOffset) {uint left=0u;uint right=numRanges-1u;for (uint i=0u; i < 16u; i++) { if (left > right) {break;}uint mid=(left+right)/2u;uint start=read_buf(dwordOffset+mid);uint nextStart=(mid+1u < numRanges) ? read_buf(dwordOffset+mid+1u) : 0xffffffffu;if (vertexId >=start && vertexId < nextStart) {return mid;} else if (vertexId < start) {if (mid==0u) {break;}right=mid-1u;} else {left=mid+1u;}}return 0u; }uint readVertexId(uint dwordOffset,uint iMaterialLookupEntry) {return read_buf(dwordOffset+iMaterialLookupEntry);}uint findRange(uint vertexId,uint numRanges,uint dwordOffset) {uint iRange;if(numRanges <=64u){uint vertexBegin;for(iRange=0u; iRange < numRanges;++iRange) {vertexBegin=readVertexId(dwordOffset,iRange);if(vertexBegin > vertexId) {break;}}iRange=iRange==0u? 0u : iRange-1u;} else { iRange=findRangeBinarySearch(vertexId,numRanges,dwordOffset);}return iRange;}MaterialInfo read_material_info(uint vertex_id) {MaterialInfo info; #if MATERIAL_TABLE_DEBUG const vec4 red=vec4(1.0,0.0,0.0,1.0);const vec4 orange=vec4(1.0,0.5,0.0,1.0);const vec4 yellow=vec4(1.0,1.0,0.0,1.0);const vec4 green=vec4(0.0,1.0,0.0,1.0);const vec4 indigo=vec4(0.294,0.0,0.510,1.0);const vec4 blue=vec4(0.0,0.0,1.0,1.0);const vec4 purple=vec4(0.5,0.0,0.5,1.0);const vec4 pink=vec4(1.0,0.0,1.0,1.0);info.colorDebug=green; #endif uint offset=0u; #if MATERIAL_TABLE_DEBUG bool keepFinding=true;uint magic=read_buf(offset);if(magic !=0xCAFEBABEu) {info.colorDebug=red;keepFinding=false;return info;} #endif offset++; #if MATERIAL_TABLE_DEBUG uint nrMaterials=read_buf(offset);uint nrVertices=read_buf(offset+1u);if(keepFinding && vertex_id >=nrVertices) {info.colorDebug=red;keepFinding=false;} #endif offset+=2u;uint nrMaterialLookupEntries=read_buf(offset++);uint perMaterialEntrySizeDwords=read_buf(offset++); #if MATERIAL_TABLE_DEBUG if(keepFinding && perMaterialEntrySizeDwords !=1u) {info.colorDebug=red;keepFinding=false;} #endif uint iMaterialLookup=findRange(vertex_id,nrMaterialLookupEntries,offset); #if MATERIAL_TABLE_DEBUG if(keepFinding) {uint vertexBeginCheck=readVertexId(offset,iMaterialLookup);if(vertexBeginCheck > vertex_id) {info.colorDebug=red;keepFinding=false;}if(iMaterialLookup < nrMaterialLookupEntries-1u) {uint vertexEndCheck=readVertexId(offset,iMaterialLookup+1u);if(vertexEndCheck <=vertex_id) {info.colorDebug=red;keepFinding=false;}}} #endif offset+=nrDwordsForVertexIdEntries(nrMaterialLookupEntries);uint materialId=iMaterialLookup; #if MATERIAL_TABLE_DEBUG if(keepFinding) {if(materialId >=nrMaterialLookupEntries) {info.colorDebug=red;}} #endif info.dataOffset=offset+materialId*perMaterialEntrySizeDwords;return info;}uint get_data_location(const MaterialInfo matInfo,uint attribOffsetBytes) {uint attribFieldOffsetDwords=attribOffsetBytes/4u;return matInfo.dataOffset+attribFieldOffsetDwords;}vec4 read_material_vec4(const MaterialInfo matInfo,uint attribOffsetBytes){uint loc=get_data_location(matInfo,attribOffsetBytes);return vec4(read_buf_float(loc),read_buf_float(loc+1u),read_buf_float(loc+2u),read_buf_float(loc+3u));}vec2 read_material_vec2(const MaterialInfo matInfo,uint attribOffsetBytes){uint loc=get_data_location(matInfo,attribOffsetBytes);return vec2(read_buf_float(loc),read_buf_float(loc+1u));}float read_material_float(const MaterialInfo matInfo,uint attribOffsetBytes){uint loc=get_data_location(matInfo,attribOffsetBytes);return read_buf_float(loc);} #define GET_ATTRIBUTE_float(attrib,matInfo,attrib_offset) read_material_float(matInfo,attrib_offset) #define GET_ATTRIBUTE_vec4(attrib,matInfo,attrib_offset) read_material_vec4(matInfo,attrib_offset) #define GET_ATTRIBUTE_vec2(attrib,matInfo,attrib_offset) read_material_vec2(matInfo,attrib_offset) #define DECLARE_MATERIAL_TABLE_INFO MaterialInfo materialInfo=read_material_info(uint(gl_VertexID)); #define DECLARE_MATERIAL_TABLE_INFO_DEBUG(dbgColor) MaterialInfo materialInfo=read_material_info(uint(gl_VertexID)); dbgColor=materialInfo.colorDebug; #endif`,"_prelude_fog.fragment.glsl":ny,"_prelude_shadow.fragment.glsl":Gc,"_prelude_lighting.glsl":` #ifdef LIGHTING_3D_MODE uniform mediump vec3 u_lighting_ambient_color;uniform mediump vec3 u_lighting_directional_dir;uniform mediump vec3 u_lighting_directional_color;uniform mediump vec3 u_ground_radiance;float calculate_ambient_directional_factor(vec3 normal) {float NdotL=dot(normal,u_lighting_directional_dir);const float factor_reduction_max=0.3;float dir_luminance=dot(u_lighting_directional_color,vec3(0.2126,0.7152,0.0722));float directional_factor_min=1.0-factor_reduction_max*min(dir_luminance,1.0);float ambient_directional_factor=mix(directional_factor_min,1.0,min((NdotL+1.0),1.0));const float vertical_factor_min=0.92;float vertical_factor=mix(vertical_factor_min,1.0,normal.z*0.5+0.5);return vertical_factor*ambient_directional_factor;}vec3 linearProduct(vec3 srgbIn,vec3 k) {return srgbIn*pow(k,vec3(1./2.2));}vec3 apply_lighting(vec3 color,vec3 normal,float dir_factor) {float ambient_directional_factor=calculate_ambient_directional_factor(normal);vec3 ambient_contrib=ambient_directional_factor*u_lighting_ambient_color;vec3 directional_contrib=u_lighting_directional_color*dir_factor;return linearProduct(color,ambient_contrib+directional_contrib);}vec4 apply_lighting(vec4 color,vec3 normal,float dir_factor) {return vec4(apply_lighting(color.rgb,normal,dir_factor),color.a);}vec3 apply_lighting(vec3 color,vec3 normal) {float dir_factor=max(dot(normal,u_lighting_directional_dir),0.0);return apply_lighting(color.rgb,normal,dir_factor);}vec4 apply_lighting(vec4 color,vec3 normal) {float dir_factor=max(dot(normal,u_lighting_directional_dir),0.0);return vec4(apply_lighting(color.rgb,normal,dir_factor),color.a);}vec3 apply_lighting_ground(vec3 color) {return color*u_ground_radiance;}vec4 apply_lighting_ground(vec4 color) {return vec4(apply_lighting_ground(color.rgb),color.a);}float calculate_NdotL(vec3 normal) {const float ext=0.70710678118;return (clamp(dot(normal,u_lighting_directional_dir),-ext,1.0)+ext)/(1.0+ext);}vec4 apply_lighting_with_emission_ground(vec4 color,float emissive_strength) {return mix(apply_lighting_ground(color),color,emissive_strength);}vec3 compute_flood_lighting(vec3 flood_light_color,float fully_occluded_factor,float occlusion,vec3 ground_shadow_factor) {vec3 fully_occluded_color=flood_light_color*mix(ground_shadow_factor,vec3(1.0),fully_occluded_factor);float occlusion_ramp=smoothstep(0.0,0.2,1.0-occlusion);return mix(fully_occluded_color,flood_light_color,occlusion_ramp);}vec3 compute_emissive_draped(vec3 unlit_color,float fully_occluded_factor,float occlusion,vec3 ground_shadow_factor) {vec3 fully_occluded_color=unlit_color*mix(ground_shadow_factor,vec3(1.0),fully_occluded_factor);return mix(fully_occluded_color,unlit_color,1.0-occlusion);} #endif`,"_prelude_raster_array.glsl":sy,"_prelude_raster_particle.glsl":ZE},iy={};Hn("",KE),Hn(ny,YE),Hn(Gc,Ib),Hn(sy,""),Hn(ZE,"");const Xf=Hn(WE,Zf),V0=HE,ay=[` #if defined(GL_EXT_blend_func_extended) && defined(DUAL_SOURCE_BLENDING) #extension GL_EXT_blend_func_extended : require #endif`,"precision mediump float;",V0,Xf.fragmentSource].join(` `),W5=["precision highp float;",V0,Xf.vertexSource].join(` `);var wI={background:Hn(`#include "_prelude_fog.fragment.glsl" #include "_prelude_lighting.glsl" uniform vec4 u_color;uniform float u_opacity;uniform mediump float u_emissive_strength; #ifdef LIGHTING_3D_MODE in vec4 v_color; #endif void main() {vec4 out_color; #ifdef FEATURE_CUTOUT vec2 uv=gl_FragCoord.xy*u_inv_viewport_size.xy; #ifdef FLIP_Y uv.y=1.0-uv.y; #endif float factorTex=min(texture(u_cutout_factor_image,uv).r,1.0);float cutoutFactor=(1.0-u_feature_cutout_params.x)*factorTex;out_color=u_color*(1.0-cutoutFactor); #else #ifdef LIGHTING_3D_MODE out_color=v_color; #else out_color=u_color; #endif #ifdef FOG out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos)); #endif #endif glFragColor=out_color*u_opacity; #ifdef USE_MRT1 out_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a); #endif #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(1.0); #endif HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl" #include "_prelude_lighting.glsl" in ivec2 a_pos;uniform mat4 u_matrix;uniform mediump float u_emissive_strength; #ifdef LIGHTING_3D_MODE uniform mediump vec4 u_color;out vec4 v_color; #endif void main() {gl_Position=u_matrix*vec4(a_pos,0,1); #ifndef FEATURE_CUTOUT #ifdef LIGHTING_3D_MODE v_color=apply_lighting_with_emission_ground(u_color,u_emissive_strength); #endif #ifdef FOG v_fog_pos=fog_position(vec2(a_pos)); #endif #endif }`),backgroundPattern:Hn(`#include "_prelude_fog.fragment.glsl" #include "_prelude_lighting.glsl" uniform vec2 u_pattern_tl;uniform vec2 u_pattern_br;uniform vec2 u_texsize;uniform float u_opacity;uniform float u_emissive_strength;uniform sampler2D u_image;in highp vec2 v_pos;void main() {highp vec2 imagecoord=mod(v_pos,1.0);highp vec2 pos=mix(u_pattern_tl/u_texsize,u_pattern_br/u_texsize,imagecoord);vec4 out_color=textureLodCustom(u_image,pos,v_pos); #ifdef LIGHTING_3D_MODE out_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength); #endif #ifdef FOG out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos)); #endif glFragColor=out_color*u_opacity; #ifdef USE_MRT1 out_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a); #endif #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(1.0); #endif HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl" uniform mat4 u_matrix;uniform vec2 u_pattern_size;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec2 u_pattern_units_to_pixels;in ivec2 a_pos;out highp vec2 v_pos;void main() {vec2 pos=vec2(a_pos);gl_Position=u_matrix*vec4(pos,0,1);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_pattern_size,u_pattern_units_to_pixels,pos); #ifdef FOG v_fog_pos=fog_position(pos); #endif }`),building:Hn(`#include "_prelude_fog.fragment.glsl" #include "_prelude_shadow.fragment.glsl" #include "_prelude_lighting.glsl" const float window_depth=0.5;const float ao_radius=0.2;in vec4 v_color;in highp vec3 v_normal;in highp vec3 v_pos; #ifdef RENDER_FRONT_CUTOFF in float v_front_cutoff_opacity; #endif #ifdef INDICATOR_CUTOUT #ifdef FEATURE_CUTOUT in vec4 v_ground_roof; #endif #endif #ifdef BUILDING_FAUX_FACADE in lowp float v_faux_facade;in highp float v_faux_facade_ed;in highp vec2 v_faux_facade_window;in highp vec2 v_faux_facade_floor;in highp vec2 v_faux_facade_range;in highp float v_aspect;in highp vec3 v_tbn_0;in highp vec3 v_tbn_1;in highp vec3 v_tbn_2;in highp vec4 v_faux_color_emissive;uniform float u_faux_facade_ao_intensity; #endif #ifdef RENDER_SHADOWS in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1; #endif #ifdef FLOOD_LIGHT in highp float v_flood_radius;in float v_has_flood_light; #endif uniform lowp float u_opacity;uniform vec3 u_camera_pos;uniform highp float u_tile_to_meter;uniform float u_facade_emissive_chance;uniform vec3 u_flood_light_color;uniform float u_flood_light_intensity;vec3 linearTosRGB(in vec3 color) {return pow(color,vec3(1./2.2));} #ifdef BUILDING_FAUX_FACADE highp float hash12(in highp vec2 p) {highp vec3 p3 =fract(vec3(p.xyx)*0.1031);p3+=dot(p3,p3.yzx+33.33);return fract((p3.x+p3.y)*p3.z);}float min3(in vec3 v) {return min(min(v.x,v.y),v.z);}highp vec2 get_uv_mask_id(in highp vec2 q,out highp float mask,out highp vec2 id) {highp vec2 p=q;mask=step(v_faux_facade_range.x,p.y)*step(p.y,v_faux_facade_range.y);p.y=p.y-v_faux_facade_range.x;highp vec2 uv=modf(p/v_faux_facade_floor,id);highp vec4 d=(v_faux_facade_floor.xyxy+vec4(-v_faux_facade_window,v_faux_facade_window))*0.5;highp vec4 edge=d/v_faux_facade_floor.xyxy;highp vec2 m=step(edge.xy,uv)*step(uv,edge.zw);mask*=m.x*m.y;uv-=vec2(0.5);uv*=vec2(0.5)/(vec2(0.5)-edge.xy);uv+=vec2(0.5);return uv;}highp float ray_unit_box(in highp vec3 ray_o,in highp vec3 ray_d,in highp vec3 bmin,in highp vec3 bmax) {highp vec3 planes=mix(bmin,bmax,step(0.0,ray_d));highp vec3 t=(planes-ray_o)/ray_d;return min3(t);}float get_emissive(in vec2 id) {if (u_facade_emissive_chance > 0.0) {return (step(hash12(id),u_facade_emissive_chance)+0.05)*v_faux_color_emissive.a;}return 0.0;}vec3 get_shade_info(in highp vec3 v,in highp vec3 v_normalized,in vec3 color,in vec2 id,in mat3 tbn,inout vec3 out_normal,inout float out_emissive) {vec3 out_color=color;highp vec3 abs_v=abs(v_normalized);bool x_major=abs_v.x >=abs_v.y && abs_v.x >=abs_v.z;bool y_major=abs_v.y >=abs_v.x && abs_v.y >=abs_v.z;bool z_major=abs_v.z >=abs_v.x && abs_v.z >=abs_v.y; #if 0 if (x_major) {out_color=v.x > 0.0 ? vec3(1.0,0.0,0.0) : vec3(0.0,1.0,1.0);} else if (y_major) {out_color=v.y > 0.0 ? vec3(0.0,1.0,0.0) : vec3(1.0,0.0,1.0);} else if (z_major) {out_color=v.z > 0.0 ? vec3(0.0,0.0,1.0) : vec3(1.0,1.0,0.0);}out_emissive=1.0; #else if (x_major) {out_normal=-sign(v.x)*tbn[0];} else if (y_major) {out_normal=vec3(0.0,0.0,-sign(v.y));} else if (z_major) {out_color=v_faux_color_emissive.rgb;out_emissive=v.z <=0.0 ? get_emissive(id) : out_emissive;}float ao=1.0;if (u_faux_facade_ao_intensity > 0.0) {vec4 ao_range=v_faux_facade_window.xxyy*0.5-vec4(0,ao_radius,0,ao_radius);vec2 ao_range_z=vec2(window_depth*0.5)-vec2(0.0,ao_radius);if (x_major || y_major) {ao*=smoothstep(-ao_range_z.x,-ao_range_z.y,v.z);} else if (z_major) {ao*=smoothstep(-ao_range.x,-ao_range.y,v.x)*(1.0-smoothstep(ao_range.y,ao_range.x,v.x));ao*=smoothstep(-ao_range.z,-ao_range.w,v.y)*(1.0-smoothstep(ao_range.w,ao_range.z,v.y));}ao=mix(1.0,min(1.0,ao+0.25),u_faux_facade_ao_intensity);}out_color*=ao; #endif return out_color;} #endif vec3 apply_lighting_linear(in vec3 color,in vec3 normal,in float dir_factor) {float ambient_directional_factor=calculate_ambient_directional_factor(normal);vec3 ambient_contrib=ambient_directional_factor*u_lighting_ambient_color;vec3 directional_contrib=u_lighting_directional_color*dir_factor;return color*(ambient_contrib+directional_contrib);}void main() {vec3 normal=normalize(v_normal);vec3 base_color=v_color.rgb;float emissive=v_color.a; #ifdef BUILDING_FAUX_FACADE if (v_faux_facade > 0.0) {highp mat3 tbn=mat3(v_tbn_0,v_tbn_1,v_tbn_2);highp vec3 v=vec3(v_pos.xy,v_pos.z/u_tile_to_meter)-u_camera_pos;highp vec3 view_tangent=transpose(tbn)*v;highp vec2 q=vec2(v_faux_facade_ed,v_pos.z);float mask=0.0;vec2 id=vec2(0.0);highp vec2 uv=get_uv_mask_id(q,mask,id);uv*=v_faux_facade_window;highp vec3 bmin=vec3(0.0,0.0,-window_depth);highp vec3 bmax=bmin+vec3(v_faux_facade_window,window_depth);highp vec3 ray_o=vec3(uv,0.0);highp vec3 ray_d=normalize(view_tangent);highp float t_min=ray_unit_box(ray_o,ray_d,bmin,bmax);highp vec3 hit=ray_o+t_min*ray_d;highp vec3 r=vec3(v_faux_facade_window,-window_depth);hit-=r*0.5;highp vec3 normalized=hit/r;vec3 out_normal=normal;float out_emissive=emissive;vec3 room_color=get_shade_info(hit,normalized,base_color,id,tbn,out_normal,out_emissive);base_color=mix(base_color,room_color,mask);normal=mix(normal,out_normal,mask);emissive=mix(emissive,out_emissive,mask);} #endif vec4 color=vec4(base_color,1.0);vec3 xy_flipped_normal=vec3(-normal.xy,normal.z);float shadowed_lighting_factor=0.0; #ifdef RENDER_SHADOWS #ifdef RENDER_CUTOFF shadowed_lighting_factor=shadowed_light_factor_normal_opacity(xy_flipped_normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w,v_cutoff_opacity);if (v_cutoff_opacity==0.0) {discard;} #else shadowed_lighting_factor=shadowed_light_factor_normal(xy_flipped_normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w); #endif #else shadowed_lighting_factor=max(0.0,dot(xy_flipped_normal,u_lighting_directional_dir)); #endif color.rgb=apply_lighting_linear(color.rgb,xy_flipped_normal,shadowed_lighting_factor);color.rgb=linearTosRGB(color.rgb); #ifdef FLOOD_LIGHT float flood_radiance=(1.0-min(v_pos.z/v_flood_radius,1.0))*u_flood_light_intensity*v_has_flood_light;color.rgb=mix(color.rgb,u_flood_light_color,flood_radiance); #endif color.rgb=mix(color.rgb,linearTosRGB(base_color.rgb),emissive); #ifdef FOG color=fog_dither(fog_apply_premultiplied(color,v_fog_pos,v_pos.z)); #endif color*=u_opacity; #ifdef INDICATOR_CUTOUT #ifdef FEATURE_CUTOUT {float ditherOpacity=cutoutGroundRoofOpacity(v_ground_roof);if (ditherOpacity < 1.0) {int index=(int(gl_FragCoord.x) % 4)*4+(int(gl_FragCoord.y) % 4);if (ditherOpacity < DITHER_THRESHOLDS[index]) {discard;}}} #else color=applyCutout(color,v_pos.z); #endif #endif #ifdef RENDER_FRONT_CUTOFF if (v_front_cutoff_opacity < 1.0) {int index=(int(gl_FragCoord.x) % 4)*4+(int(gl_FragCoord.y) % 4);if (v_front_cutoff_opacity < DITHER_THRESHOLDS[index]) {discard;}} #endif #ifdef FEATURE_CUTOUT color=apply_feature_cutout(color,gl_FragCoord,get_cutout_factors(gl_FragCoord).x); #endif glFragColor=color; #ifdef DEBUG_SHOW_NORMALS color.rgb=xy_flipped_normal*0.5+vec3(0.5,0.5,0.5);color.a=1.0;glFragColor=color; #endif #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(1.0); #endif HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl" #include "_prelude_shadow.vertex.glsl" in vec3 a_pos_3f;in ivec4 a_normal_3;in ivec4 a_centroid_3; #ifdef FLOOD_LIGHT in int a_flood_light_wall_radius_1i16; #endif #ifdef BUILDING_FAUX_FACADE in uvec4 a_faux_facade_data;in uvec2 a_faux_facade_vertical_range; #endif uniform mat4 u_matrix;uniform mat4 u_normal_matrix;uniform highp float u_tile_to_meter; #ifdef RENDER_FRONT_CUTOFF uniform vec3 u_front_cutoff_params;out float v_front_cutoff_opacity; #endif #ifdef INDICATOR_CUTOUT #ifdef FEATURE_CUTOUT out vec4 v_ground_roof; #endif #endif out vec4 v_color;out vec3 v_normal;out highp vec3 v_pos; #ifdef BUILDING_FAUX_FACADE out lowp float v_faux_facade;out highp float v_faux_facade_ed;out highp vec2 v_faux_facade_window;out highp vec2 v_faux_facade_floor;out highp vec2 v_faux_facade_range;out highp float v_aspect;out highp vec3 v_tbn_0;out highp vec3 v_tbn_1;out highp vec3 v_tbn_2;out highp vec4 v_faux_color_emissive; #endif #ifdef RENDER_SHADOWS uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1; #endif #ifdef FLOOD_LIGHT out highp float v_flood_radius;out float v_has_flood_light; #endif const float MAX_UINT_16=65535.0;const float MAX_INT_16=32767.0;const float MAX_UINT_8=255.0;const float TWO_POW_8=256.0;const float FLOOD_LIGHT_MAX_RADIUS_METER=2048.0;vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));} #ifdef BUILDING_FAUX_FACADE mat3 get_tbn(in vec3 normal) {const vec3 bitangent=vec3(0.0,0.0,1.0);vec3 tangent=normalize(vec3(normal.y,-normal.x,0.0));return mat3(tangent,bitangent,normal);} #endif #pragma mapbox: define-attribute-vertex-shader-only highp uvec2 part_color_emissive #pragma mapbox: define-attribute-vertex-shader-only highp uvec2 faux_facade_color_emissive void main() { #pragma mapbox: initialize-attribute-custom highp uvec2 part_color_emissive #pragma mapbox: initialize-attribute-custom highp uvec2 faux_facade_color_emissive #ifdef FLOOD_LIGHT v_flood_radius=(float(a_flood_light_wall_radius_1i16)/MAX_INT_16*FLOOD_LIGHT_MAX_RADIUS_METER);v_has_flood_light=step(0.0,v_flood_radius); #endif vec4 color_emissive=decode_color(vec2(part_color_emissive));v_color=vec4(sRGBToLinear(color_emissive.rgb),color_emissive.a);vec3 a_normal_3f=vec3(a_normal_3)/MAX_INT_16;v_normal=vec3(u_normal_matrix*vec4(a_normal_3f,0.0));float hidden=0.0;float depth_offset=0.0;vec2 centroid_xy=vec2(a_centroid_3.xy >> 2);vec2 spanBits=vec2(a_centroid_3.xy & 3); #ifdef BUILDING_FAUX_FACADE vec4 faux_facade_data=vec4(a_faux_facade_data);v_faux_facade=faux_facade_data.x;if (v_faux_facade > 0.0) {v_faux_facade_ed=faux_facade_data.x *u_tile_to_meter;float window_x_perc=floor(faux_facade_data.y/TWO_POW_8);float window_y_perc=faux_facade_data.y-TWO_POW_8*window_x_perc;vec2 window_perc=vec2(window_x_perc,window_y_perc)/MAX_UINT_8;v_faux_facade_floor=(faux_facade_data.zw/MAX_UINT_16*EXTENT)*u_tile_to_meter;v_faux_facade_window=window_perc*v_faux_facade_floor;v_faux_facade_range=(vec2(a_faux_facade_vertical_range)/MAX_UINT_16*EXTENT)*u_tile_to_meter;v_aspect=v_faux_facade_window.x/v_faux_facade_window.y;mat3 tbn=get_tbn(normalize(v_normal));v_tbn_0=tbn[0];v_tbn_1=tbn[1];v_tbn_2=tbn[2];v_faux_color_emissive=decode_color(vec2(faux_facade_color_emissive));v_faux_color_emissive.rgb=sRGBToLinear(v_faux_color_emissive.rgb);depth_offset=min(1000.0,float(a_centroid_3.z))*0.0000002;} #endif v_pos=a_pos_3f; #if defined(RENDER_CUTOFF) || defined(RENDER_FRONT_CUTOFF) float halfSpanX=spanBits.x*10.0/u_tile_to_meter;float halfSpanY=spanBits.y*10.0/u_tile_to_meter;vec2 screenUpInTile=vec2(u_matrix[0][1],u_matrix[1][1]);vec2 spanOffset=vec2(halfSpanX,halfSpanY)*sign(screenUpInTile);vec2 cutoff_highestCorner=centroid_xy+spanOffset;vec2 cutoff_lowestCorner=centroid_xy-spanOffset; #endif #if defined(RENDER_CUTOFF) || defined(RENDER_FRONT_CUTOFF) vec4 ground=u_matrix*vec4(centroid_xy,0.0,1.0); #endif #ifdef RENDER_CUTOFF v_cutoff_opacity=cutoff_opacity(u_cutoff_params,ground.z);hidden=float(v_cutoff_opacity==0.0);v_pos.z*=v_cutoff_opacity; #endif #ifdef RENDER_SHADOWS vec3 shadow_pos=v_pos; #ifdef NORMAL_OFFSET vec3 offset=shadow_normal_offset_model(v_normal);shadow_pos+=offset*shadow_normal_offset_multiplier0(); #endif v_pos_light_view_0=u_light_matrix_0*vec4(shadow_pos,1.0);v_pos_light_view_1=u_light_matrix_1*vec4(shadow_pos,1.0); #endif #ifdef FOG v_fog_pos=fog_position(v_pos); #endif #ifdef RENDER_FRONT_CUTOFF v_front_cutoff_opacity=1.0;{hidden=max(hidden,float(ground.w <=0.0));float ndc_y=ground.y/max(ground.w,0.001);float threshold=u_front_cutoff_params.x*2.0-1.0;float range_ndc=u_front_cutoff_params.y*2.0;hidden=max(hidden,float(ndc_y < threshold-range_ndc));float t=clamp((ndc_y-(threshold-range_ndc))/max(range_ndc,0.001),0.0,1.0);v_front_cutoff_opacity=mix(u_front_cutoff_params.z,1.0,t);} #endif gl_Position=mix(u_matrix*vec4(v_pos,1),AWAY,hidden);gl_Position.z-=depth_offset*gl_Position.w; #ifdef INDICATOR_CUTOUT #ifdef FEATURE_CUTOUT vec4 ic_ground=u_matrix*vec4(v_pos.xy,0.0,1.0);vec4 ic_roof=u_matrix*vec4(v_pos.xy,v_pos.z,1.0);v_ground_roof=vec4(ic_ground.xy/ic_ground.w,ic_roof.xy/ic_roof.w); #endif #endif }`),buildingBloom:Hn(`in vec4 v_color_emissive; #pragma mapbox: define-attribute highp vec4 bloom_attenuation #pragma mapbox: initialize-attribute highp vec4 bloom_attenuation float saturate(float val) {return clamp(val,0.0,1.0);}void main() {float emission=v_color_emissive.a;float opacity=1.0; #ifdef HAS_ATTRIBUTE_a_bloom_attenuation float distance=length(vec2(1.3*max(0.0,abs(bloom_attenuation.x)-bloom_attenuation.z),bloom_attenuation.y));distance+= mix(0.5,0.0,clamp(emission-1.0,0.0,1.0));opacity*=saturate(1.0-distance*distance); #endif #ifdef RENDER_CUTOFF opacity*=v_cutoff_opacity; #endif glFragColor=vec4(v_color_emissive.rgb,1.0)*opacity;}`,`in vec3 a_pos_3f; #pragma mapbox: define-attribute-vertex-shader-only highp uvec2 part_color_emissive #pragma mapbox: define-attribute highp vec4 bloom_attenuation out vec4 v_color_emissive;uniform mat4 u_matrix;vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}void main() { #pragma mapbox: initialize-attribute-custom highp uvec2 part_color_emissive #pragma mapbox: initialize-attribute highp vec4 bloom_attenuation #ifdef HAS_ATTRIBUTE_a_part_color_emissive vec4 color_emissive=decode_color(vec2(part_color_emissive));float part_emissive=color_emissive.a*5.0;v_color_emissive=vec4(sRGBToLinear(color_emissive.rgb),part_emissive); #else v_color_emissive=vec4(1.0); #endif gl_Position=u_matrix*vec4(a_pos_3f,1.0); #ifdef RENDER_CUTOFF v_cutoff_opacity=cutoff_opacity(u_cutoff_params,gl_Position.z); #endif }`),buildingDepth:Hn("void main() {}","in vec3 a_pos_3f;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos_3f,1.0);}"),circle:Hn(`#include "_prelude_fog.fragment.glsl" #include "_prelude_lighting.glsl" in vec3 v_data;in float v_visibility; #pragma mapbox: define highp vec4 color #pragma mapbox: define mediump float radius #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity #pragma mapbox: define highp vec4 stroke_color #pragma mapbox: define mediump float stroke_width #pragma mapbox: define lowp float stroke_opacity uniform float u_emissive_strength;void main() { #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize mediump float radius #pragma mapbox: initialize lowp float blur #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize highp vec4 stroke_color #pragma mapbox: initialize mediump float stroke_width #pragma mapbox: initialize lowp float stroke_opacity vec2 extrude=v_data.xy;float blur_positive=blur < 0.0 ? 0.0 : 1.0;lowp float antialiasblur=v_data.z;float extrude_length=length(extrude)+antialiasblur*(1.0-blur_positive);float antialiased_blur=-max(abs(blur),antialiasblur);float antialiase_blur_opacity=smoothstep(0.0,antialiasblur,extrude_length-1.0);float opacity_t=blur_positive==1.0 ? smoothstep(0.0,-antialiased_blur,1.0-extrude_length) : smoothstep(antialiased_blur,0.0,extrude_length-1.0)-antialiase_blur_opacity;float color_t=stroke_width < 0.01 ? 0.0 : smoothstep( antialiased_blur,0.0,extrude_length-radius/(radius+stroke_width) );vec4 out_color=mix(color*opacity,stroke_color*stroke_opacity,color_t); #ifdef LIGHTING_3D_MODE out_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength); #endif #ifdef FOG out_color=fog_apply_premultiplied(out_color,v_fog_pos); #endif glFragColor=out_color*(v_visibility*opacity_t); #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(1.0); #endif }`,`#include "_prelude_fog.vertex.glsl" #include "_prelude_terrain.vertex.glsl" #define NUM_VISIBILITY_RINGS 2 #define INV_SQRT2 0.70710678 #define ELEVATION_BIAS 0.0001 #define NUM_SAMPLES_PER_RING 16 uniform mat4 u_matrix;uniform mat2 u_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;in ivec2 a_pos; #ifdef PROJECTION_GLOBE_VIEW in ivec4 a_pos_3;in ivec4 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir; #endif #ifdef ELEVATED_ROADS in float a_circle_z_offset; #endif out vec3 v_data;out float v_visibility; #pragma mapbox: define highp vec4 color #pragma mapbox: define mediump float radius #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity #pragma mapbox: define highp vec4 stroke_color #pragma mapbox: define mediump float stroke_width #pragma mapbox: define lowp float stroke_opacity vec2 calc_offset(vec2 extrusion,float radius,float stroke_width, float view_scale) {return extrusion*(radius+stroke_width)*u_extrude_scale*view_scale;}float cantilevered_elevation(vec2 pos,float radius,float stroke_width,float view_scale) {vec2 c1=pos+calc_offset(vec2(-1.0,-1.0),radius,stroke_width,view_scale);vec2 c2=pos+calc_offset(vec2(1.0,-1.0),radius,stroke_width,view_scale);vec2 c3=pos+calc_offset(vec2(1.0,1.0),radius,stroke_width,view_scale);vec2 c4=pos+calc_offset(vec2(-1.0,1.0),radius,stroke_width,view_scale);float h1=elevation(c1)+ELEVATION_BIAS;float h2=elevation(c2)+ELEVATION_BIAS;float h3=elevation(c3)+ELEVATION_BIAS;float h4=elevation(c4)+ELEVATION_BIAS;return max(h4,max(h3,max(h1,h2)));}float circle_elevation(vec2 pos) { #if defined(TERRAIN) return elevation(pos)+ELEVATION_BIAS; #else return 0.0; #endif }vec4 project_vertex(vec2 extrusion,vec4 world_center,vec4 projected_center,float radius,float stroke_width, float view_scale,mat3 surface_vectors) {vec2 sample_offset=calc_offset(extrusion,radius,stroke_width,view_scale); #ifdef PITCH_WITH_MAP #ifdef PROJECTION_GLOBE_VIEW return u_matrix*( world_center+vec4(sample_offset.x*surface_vectors[0]+sample_offset.y*surface_vectors[1],0) ); #else return u_matrix*( world_center+vec4(sample_offset,0,0) ); #endif #else return projected_center+vec4(sample_offset,0,0); #endif }float get_sample_step() { #ifdef PITCH_WITH_MAP return 2.0*PI/float(NUM_SAMPLES_PER_RING); #else return PI/float(NUM_SAMPLES_PER_RING); #endif }void main() { #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize mediump float radius #pragma mapbox: initialize lowp float blur #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize highp vec4 stroke_color #pragma mapbox: initialize mediump float stroke_width #pragma mapbox: initialize lowp float stroke_opacity vec2 pos2=vec2(a_pos);vec2 extrude=vec2(mod(pos2,2.0)*2.0-1.0);vec2 circle_center=floor(pos2*0.5);float height=circle_elevation(circle_center);vec4 world_center;mat3 surface_vectors; #ifdef PROJECTION_GLOBE_VIEW surface_vectors=globe_mercator_surface_vectors(vec3(a_pos_normal_3)/16384.0,u_up_dir,u_zoom_transition);vec3 surface_extrusion=extrude.x*surface_vectors[0]+extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(circle_center)*height;vec3 globe_pos=vec3(a_pos_3)+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*height;vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,circle_center,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;vec3 pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);world_center=vec4(pos,1); #else surface_vectors=mat3(1.0);world_center=vec4(circle_center,height,1); #endif #ifdef ELEVATED_ROADS world_center.z+=a_circle_z_offset+ELEVATION_BIAS; #endif vec4 projected_center=u_matrix*world_center;float view_scale=0.0; #ifdef PITCH_WITH_MAP #ifdef SCALE_WITH_MAP view_scale=1.0; #else view_scale=projected_center.w/u_camera_to_center_distance; #endif #else #ifdef SCALE_WITH_MAP view_scale=u_camera_to_center_distance; #else view_scale=projected_center.w; #endif #endif gl_Position=project_vertex(extrude,world_center,projected_center,radius,stroke_width,view_scale,surface_vectors);float visibility=0.0; #ifdef TERRAIN float step=get_sample_step();vec4 occlusion_world_center;vec4 occlusion_projected_center; #ifdef PITCH_WITH_MAP float cantilevered_height=cantilevered_elevation(circle_center,radius,stroke_width,view_scale);occlusion_world_center=vec4(circle_center,cantilevered_height,1);occlusion_projected_center=u_matrix*occlusion_world_center; #else occlusion_world_center=world_center;occlusion_projected_center=projected_center; #endif for(int ring=0; ring < NUM_VISIBILITY_RINGS; ring++) {float scale=(float(ring)+1.0)/float(NUM_VISIBILITY_RINGS);for(int i=0; i < NUM_SAMPLES_PER_RING; i++) {vec2 extrusion=vec2(cos(step*float(i)),-sin(step*float(i)))*scale;vec4 frag_pos=project_vertex(extrusion,occlusion_world_center,occlusion_projected_center,radius,stroke_width,view_scale,surface_vectors);visibility+=float(!isOccluded(frag_pos));}}visibility/=float(NUM_VISIBILITY_RINGS)*float(NUM_SAMPLES_PER_RING); #else visibility=1.0; #endif #ifdef PROJECTION_GLOBE_VIEW visibility=1.0; #endif v_visibility=visibility;lowp float antialiasblur=1.0/u_device_pixel_ratio/(radius+stroke_width);v_data=vec3(extrude.x,extrude.y,antialiasblur); #ifdef FOG v_fog_pos=fog_position(world_center.xyz); #endif }`),clippingMask:Hn("void main() {glFragColor=vec4(1.0);}","in ivec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"),heatmap:Hn(`#include "_prelude_fog.fragment.glsl" uniform highp float u_intensity;in vec2 v_extrude; #pragma mapbox: define highp float weight #define GAUSS_COEF 0.3989422804014327 void main() { #pragma mapbox: initialize highp float weight float d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);glFragColor=vec4(val,1.0,1.0,1.0); #ifdef FOG if (u_is_globe==0) {glFragColor.r*=pow(1.0-fog_opacity(v_fog_pos),2.0);} #endif #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(1.0); #endif HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_terrain.vertex.glsl" #include "_prelude_fog.vertex.glsl" uniform mat4 u_matrix;uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;in ivec2 a_pos; #ifdef PROJECTION_GLOBE_VIEW in ivec4 a_pos_3;in ivec4 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir; #endif out vec2 v_extrude; #pragma mapbox: define highp float weight #pragma mapbox: define mediump float radius const highp float ZERO=1.0/255.0/16.0; #define GAUSS_COEF 0.3989422804014327 void main() { #pragma mapbox: initialize highp float weight #pragma mapbox: initialize mediump float radius vec2 unscaled_extrude=vec2(mod(vec2(a_pos),2.0)*2.0-1.0);float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec2 tilePos=floor(vec2(a_pos)*0.5);vec3 pos; #ifdef PROJECTION_GLOBE_VIEW vec3 pos_normal_3=vec3(a_pos_normal_3)/16384.0;mat3 surface_vectors=globe_mercator_surface_vectors(pos_normal_3,u_up_dir,u_zoom_transition);vec3 surface_extrusion=extrude.x*surface_vectors[0]+extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(tilePos)*elevation(tilePos);vec3 globe_pos=vec3(a_pos_3)+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*elevation(tilePos);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,tilePos,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition); #else pos=vec3(tilePos+extrude,elevation(tilePos)); #endif gl_Position=u_matrix*vec4(pos,1); #ifdef FOG v_fog_pos=fog_position(pos); #endif }`),heatmapTexture:Hn(`uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;in vec2 v_pos;void main() {float t=texture(u_image,v_pos).r;vec4 color=texture(u_color_ramp,vec2(t,0.5));glFragColor=color*u_opacity; #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(0.0); #endif HANDLE_WIREFRAME_DEBUG;}`,"in ivec2 a_pos;out vec2 v_pos;void main() {gl_Position=vec4(a_pos,0,1);v_pos=vec2(a_pos)*0.5+0.5;}"),collisionBox:Hn("in float v_placed;in float v_notUsed;void main() {vec4 red =vec4(1.0,0.0,0.0,1.0);vec4 blue=vec4(0.0,0.0,1.0,0.5);glFragColor =mix(red,blue,step(0.5,v_placed))*0.5;glFragColor*=mix(1.0,0.1,step(0.5,v_notUsed));}",`#include "_prelude_terrain.vertex.glsl" in ivec4 a_pos;in ivec2 a_anchor_pos;in ivec2 a_extrude;in uvec2 a_placed;in vec2 a_shift;in vec2 a_elevation_from_sea;in float a_size_scale;in vec2 a_padding;in float a_auto_z_offset;uniform mat4 u_matrix;uniform vec2 u_extrude_scale;uniform float u_camera_to_center_distance; #ifdef PROJECTION_GLOBE_VIEW uniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform float u_zoom_transition; #endif out float v_placed;out float v_notUsed;void main() {vec2 anchor_pos=vec2(a_anchor_pos);float feature_elevation=a_elevation_from_sea.x+a_auto_z_offset;float terrain_elevation=(a_elevation_from_sea.y==1.0 ? 0.0 : elevation(anchor_pos));vec3 proj_pos=vec3(a_pos)+elevationVector(anchor_pos)*(feature_elevation+terrain_elevation); #ifdef PROJECTION_GLOBE_VIEW #ifndef PROJECTED_POS_ON_VIEWPORT vec3 globe_pos=proj_pos;vec3 mercator_pos=mercator_tile_position(u_inv_rot_matrix,anchor_pos,u_tile_id,u_merc_center);proj_pos=mix_globe_mercator(globe_pos,mercator_pos,u_zoom_transition); #endif #endif vec4 projectedPoint=u_matrix*vec4(proj_pos,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float collision_perspective_ratio=clamp( 0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,1.5);gl_Position=projectedPoint;gl_Position.xy+=(vec2(a_extrude)*a_size_scale+a_shift+a_padding)*u_extrude_scale*gl_Position.w*collision_perspective_ratio;v_placed=float(a_placed.x);v_notUsed=float(a_placed.y);}`),collisionCircle:Hn("in float v_radius;in vec2 v_extrude;in float v_perspective_ratio;in float v_collision;void main() {float alpha=0.5*min(v_perspective_ratio,1.0);float stroke_radius=0.9*max(v_perspective_ratio,1.0);float distance_to_center=length(v_extrude);float distance_to_edge=abs(distance_to_center-v_radius);float opacity_t=smoothstep(-stroke_radius,0.0,-distance_to_edge);vec4 color=mix(vec4(0.0,0.0,1.0,0.5),vec4(1.0,0.0,0.0,1.0),v_collision);glFragColor=color*alpha*opacity_t;}",`in vec2 a_pos_2f;in float a_radius;in ivec2 a_flags;uniform mat4 u_matrix;uniform mat4 u_inv_matrix;uniform vec2 u_viewport_size;uniform float u_camera_to_center_distance;out float v_radius;out vec2 v_extrude;out float v_perspective_ratio;out float v_collision;vec3 toTilePosition(vec2 screenPos) {vec4 rayStart=u_inv_matrix*vec4(screenPos,-1.0,1.0);vec4 rayEnd =u_inv_matrix*vec4(screenPos, 1.0,1.0);rayStart.xyz/=rayStart.w;rayEnd.xyz /=rayEnd.w;highp float t=(0.0-rayStart.z)/(rayEnd.z-rayStart.z);return mix(rayStart.xyz,rayEnd.xyz,t);}void main() {vec2 quadCenterPos=a_pos_2f;float radius=a_radius;int vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2( mix(-1.0,1.0,float(vertexIdx >=2)),mix(-1.0,1.0,float(vertexIdx >=1 && vertexIdx <=2)));vec2 quadVertexExtent=quadVertexOffset*radius;vec3 tilePos=toTilePosition(quadCenterPos);vec4 clipPos=u_matrix*vec4(tilePos,1.0);highp float camera_to_anchor_distance=clipPos.w;highp float collision_perspective_ratio=clamp( 0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,4.0);float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_perspective_ratio=collision_perspective_ratio;v_collision=float(a_flags.x);gl_Position=vec4(clipPos.xyz/clipPos.w,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}`),debug:Hn("uniform highp vec4 u_color;uniform sampler2D u_overlay;in vec2 v_uv;void main() {vec4 overlay_color=texture(u_overlay,v_uv);glFragColor=mix(u_color,overlay_color,overlay_color.a);}",`#include "_prelude_terrain.vertex.glsl" in ivec2 a_pos; #ifdef PROJECTION_GLOBE_VIEW in ivec4 a_pos_3; #endif out vec2 v_uv;uniform mat4 u_matrix;uniform float u_overlay_scale;void main() {vec2 pos=vec2(a_pos);float h=elevation(pos);v_uv=pos/8192.0; #ifdef PROJECTION_GLOBE_VIEW gl_Position=u_matrix*vec4(vec3(a_pos_3)+elevationVector(pos)*h,1); #else gl_Position=u_matrix*vec4(pos*u_overlay_scale,h,1); #endif }`),elevatedStructuresDepth:Hn("void main() {}","in ivec2 a_pos;in float a_height;uniform mat4 u_matrix;uniform float u_depth_bias;void main() {gl_Position=u_matrix*vec4(a_pos,a_height,1);gl_Position.z=gl_Position.z+u_depth_bias;}"),elevatedStructuresDepthReconstruct:Hn(`#ifdef DEPTH_RECONSTRUCTION in float v_height; #endif void main() { #ifdef DEPTH_RECONSTRUCTION if (v_height >=0.0) discard; #else #ifdef FEATURE_CUTOUT apply_feature_cutout(vec4(0.0,0.0,0.0,1.0),gl_FragCoord,get_cutout_factors(gl_FragCoord).x); #endif #endif glFragColor=vec4(1.0,0.0,0.0,1.0);}`,`in ivec2 a_pos;in float a_height;uniform mat4 u_matrix;uniform vec3 u_camera_pos;uniform highp float u_depth_bias;uniform lowp float u_height_scale;uniform lowp float u_reset_depth; #ifdef DEPTH_RECONSTRUCTION out float v_height; #endif void main() {vec3 vpos=vec3(a_pos,a_height*u_height_scale); #ifdef DEPTH_RECONSTRUCTION if (u_camera_pos.z > vpos.z) {vpos-=(u_camera_pos-vpos)*(vpos.z/(u_camera_pos.z-vpos.z));}v_height=a_height; #endif gl_Position=u_matrix*vec4(vpos,1);gl_Position.z=u_reset_depth==1.0 ? gl_Position.w : gl_Position.z+u_depth_bias;}`),elevatedStructures:Hn(`#include "_prelude_fog.fragment.glsl" #include "_prelude_lighting.glsl" #include "_prelude_shadow.fragment.glsl" in vec3 v_normal;in float v_height; #ifdef RENDER_SHADOWS in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in float v_depth; #endif vec3 linearTosRGB(vec3 color) {return pow(color,vec3(1./2.2));}vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}vec3 compute_view_dependent_emissive_color(float ndotl,float emissive_strength,vec3 color) {color=sRGBToLinear(color);color=color*(ndotl+(1.0-min(ndotl*57.29,1.0))*emissive_strength);color=linearTosRGB(color.rgb);return color;}uniform float u_emissive_strength; #pragma mapbox: define highp vec4 structure_color void main() { #pragma mapbox: initialize highp vec4 structure_color vec3 color=structure_color.xyz;vec2 cutout_factors=vec2(0.0); #ifdef FEATURE_CUTOUT cutout_factors=get_cutout_factors(gl_FragCoord); #endif #ifdef LIGHTING_3D_MODE vec3 normal=normalize(v_normal);vec3 transformed_normal=vec3(-normal.xy,normal.z);float ndotl=calculate_NdotL(transformed_normal);float emissive_strength=u_emissive_strength;emissive_strength=0.0;vec3 emissive_color=compute_view_dependent_emissive_color(ndotl,emissive_strength,color.xyz); #ifdef RENDER_SHADOWS float light=shadowed_light_factor_normal(transformed_normal,v_pos_light_view_0,v_pos_light_view_1,v_depth);light=mix(light,1.0,cutout_factors.y);color.rgb=apply_lighting(color.rgb,transformed_normal,light); #else color=apply_lighting(color,transformed_normal); #endif color=mix(color,emissive_color,emissive_strength);if (v_height < 0.0) {float penetration=max(v_height+7.5,0.0);float occlusion=1.0-1.0/PI*acos(1.0-penetration/4.0);color=color*(1.0-pow(occlusion,2.0)*0.3);} #endif #ifdef FOG color=fog_apply(color,v_fog_pos); #endif vec4 out_color=vec4(color,1.0); #ifdef INDICATOR_CUTOUT out_color=applyCutout(out_color,v_height); #endif #ifdef FEATURE_CUTOUT out_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x); #endif glFragColor=out_color;HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl" #include "_prelude_shadow.vertex.glsl" in ivec2 a_pos;in float a_height;in ivec4 a_pos_normal_3;uniform mat4 u_matrix;out vec3 v_normal;out float v_height; #ifdef RENDER_SHADOWS uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out float v_depth; #endif #pragma mapbox: define highp vec4 structure_color void main() { #pragma mapbox: initialize highp vec4 structure_color v_normal=vec3(a_pos_normal_3)/16384.0;v_height=a_height;vec3 pos=vec3(vec2(a_pos),a_height);gl_Position=u_matrix*vec4(pos,1); #ifdef RENDER_SHADOWS vec3 shd_pos0=pos;vec3 shd_pos1=pos; #ifdef NORMAL_OFFSET vec3 offset=shadow_normal_offset(vec3(-v_normal.xy,v_normal.z));shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1(); #endif v_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w; #endif #ifdef FOG v_fog_pos=fog_position(vec2(a_pos)); #endif }`),fill:Hn(`#include "_prelude_fog.fragment.glsl" #include "_prelude_lighting.glsl" #include "_prelude_shadow.fragment.glsl" #pragma mapbox: define highp vec4 color #pragma mapbox: define lowp float opacity uniform float u_emissive_strength; #ifdef RENDER_SHADOWS uniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth; #endif #ifdef ELEVATED_ROADS in highp float v_road_z_offset; #endif #ifdef INDICATOR_CUTOUT in highp float v_z_offset; #endif void main() { #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize lowp float opacity vec2 cutout_factors=vec2(0.0); #ifdef FEATURE_CUTOUT cutout_factors=get_cutout_factors(gl_FragCoord); #endif vec4 out_color=color; #ifdef LIGHTING_3D_MODE out_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength); #ifdef RENDER_SHADOWS float light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);light=mix(light,1.0,cutout_factors.y);out_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light); #endif #endif #ifdef FOG out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos)); #endif out_color*=opacity; #ifdef INDICATOR_CUTOUT if (v_z_offset >=0.0) {out_color=applyCutout(out_color,v_z_offset);} #endif #ifdef FEATURE_CUTOUT out_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x); #endif glFragColor=out_color; #ifdef USE_MRT1 out_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a); #endif #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(1.0); #endif HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl" #include "_prelude_shadow.vertex.glsl" in ivec2 a_pos; #ifdef ELEVATED_ROADS in float a_road_z_offset;out highp float v_road_z_offset; #endif #ifdef RENDER_SHADOWS uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth; #endif #ifdef INDICATOR_CUTOUT out highp float v_z_offset; #endif uniform mat4 u_matrix; #pragma mapbox: define highp vec4 color #pragma mapbox: define lowp float opacity #pragma mapbox: define highp float z_offset void main() { #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize highp float z_offset #ifdef ELEVATED_ROADS z_offset+=a_road_z_offset;v_road_z_offset=z_offset; #endif float hidden=float(opacity==0.0);gl_Position=mix(u_matrix*vec4(a_pos,z_offset,1),AWAY,hidden); #ifdef RENDER_SHADOWS vec3 shd_pos0=vec3(a_pos,z_offset);vec3 shd_pos1=vec3(a_pos,z_offset); #ifdef NORMAL_OFFSET vec3 offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1(); #endif v_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w; #endif #ifdef FOG v_fog_pos=fog_position(vec2(a_pos)); #endif #ifdef INDICATOR_CUTOUT v_z_offset=z_offset; #endif }`),fillOutline:Hn(`#include "_prelude_fog.fragment.glsl" #include "_prelude_lighting.glsl" #include "_prelude_shadow.fragment.glsl" in highp vec2 v_pos;uniform float u_emissive_strength; #ifdef RENDER_SHADOWS uniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth; #endif #pragma mapbox: define highp vec4 outline_color #pragma mapbox: define lowp float opacity void main() { #pragma mapbox: initialize highp vec4 outline_color #pragma mapbox: initialize lowp float opacity float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=outline_color;vec2 cutout_factors=vec2(0.0); #ifdef FEATURE_CUTOUT cutout_factors=get_cutout_factors(gl_FragCoord); #endif #ifdef LIGHTING_3D_MODE out_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength); #ifdef RENDER_SHADOWS float light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);light=mix(light,1.0,cutout_factors.y);out_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light); #endif #endif #ifdef FOG out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos)); #endif #ifdef FEATURE_CUTOUT out_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x); #endif glFragColor=out_color*(alpha*opacity); #ifdef USE_MRT1 out_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a); #endif #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(1.0); #endif HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl" #include "_prelude_shadow.vertex.glsl" in ivec2 a_pos; #ifdef ELEVATED_ROADS in float a_road_z_offset; #endif #ifdef RENDER_SHADOWS uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth; #endif uniform mat4 u_matrix;uniform vec2 u_world;out highp vec2 v_pos; #pragma mapbox: define highp vec4 outline_color #pragma mapbox: define lowp float opacity #pragma mapbox: define highp float z_offset void main() { #pragma mapbox: initialize highp vec4 outline_color #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize highp float z_offset #ifdef ELEVATED_ROADS z_offset+=a_road_z_offset; #endif float hidden=float(opacity==0.0);gl_Position=mix(u_matrix*vec4(a_pos,z_offset,1),AWAY,hidden); #ifdef FLIP_Y v_pos=(vec2(gl_Position.x,-gl_Position.y)/gl_Position.w+1.0)/2.0*u_world; #else v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world; #endif #ifdef RENDER_SHADOWS vec3 shd_pos0=vec3(a_pos,z_offset);vec3 shd_pos1=vec3(a_pos,z_offset); #ifdef NORMAL_OFFSET vec3 offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1(); #endif v_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w; #endif #ifdef FOG v_fog_pos=fog_position(vec2(a_pos)); #endif }`),fillOutlinePattern:Hn(`#include "_prelude_fog.fragment.glsl" #include "_prelude_lighting.glsl" #include "_prelude_shadow.fragment.glsl" uniform vec2 u_texsize;uniform sampler2D u_image; #ifdef FILL_PATTERN_TRANSITION uniform float u_pattern_transition; #endif uniform float u_emissive_strength; #ifdef APPLY_LUT_ON_GPU uniform highp sampler3D u_lutTexture; #endif #ifdef RENDER_SHADOWS uniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth; #endif in highp vec2 v_pos;in highp vec2 v_pos_world; #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp uvec4 pattern #ifdef FILL_PATTERN_TRANSITION #pragma mapbox: define mediump uvec4 pattern_b #endif void main() { #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize mediump uvec4 pattern #ifdef FILL_PATTERN_TRANSITION #pragma mapbox: initialize mediump uvec4 pattern_b #endif vec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(pattern.zw);highp vec2 imagecoord=mod(v_pos,1.0);highp vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);highp vec2 lod_pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,v_pos);float dist=length(v_pos_world-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=textureLodCustom(u_image,pos,lod_pos); #ifdef APPLY_LUT_ON_GPU out_color=applyLUT(u_lutTexture,out_color); #endif #ifdef FILL_PATTERN_TRANSITION vec2 pattern_b_tl=pattern_b.xy;vec2 pattern_b_br=pattern_b.zw;highp vec2 pos_b=mix(pattern_b_tl/u_texsize,pattern_b_br/u_texsize,imagecoord);vec4 color_b=textureLodCustom(u_image,pos_b,lod_pos);out_color=out_color*(1.0-u_pattern_transition)+color_b*u_pattern_transition; #endif vec2 cutout_factors=vec2(0.0); #ifdef FEATURE_CUTOUT cutout_factors=get_cutout_factors(gl_FragCoord); #endif #ifdef LIGHTING_3D_MODE out_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength); #ifdef RENDER_SHADOWS float light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);light=mix(light,1.0,cutout_factors.y);out_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light); #endif #endif #ifdef FEATURE_CUTOUT out_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x); #endif #ifdef FOG out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos)); #endif glFragColor=out_color*(alpha*opacity); #ifdef USE_MRT1 out_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a); #endif #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(1.0); #endif HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl" #include "_prelude_shadow.vertex.glsl" uniform mat4 u_matrix;uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;in ivec2 a_pos; #ifdef ELEVATED_ROADS in float a_road_z_offset; #endif #ifdef RENDER_SHADOWS uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth; #endif out highp vec2 v_pos;out highp vec2 v_pos_world; #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp uvec4 pattern #ifdef FILL_PATTERN_TRANSITION #pragma mapbox: define mediump uvec4 pattern_b #endif #pragma mapbox: define lowp float pixel_ratio #pragma mapbox: define highp float z_offset void main() { #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize mediump uvec4 pattern #ifdef FILL_PATTERN_TRANSITION #pragma mapbox: initialize mediump uvec4 pattern_b #endif #pragma mapbox: initialize lowp float pixel_ratio #pragma mapbox: initialize highp float z_offset vec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(pattern.zw); #ifdef ELEVATED_ROADS z_offset+=a_road_z_offset; #endif float hidden=float(opacity==0.0);vec2 pos=vec2(a_pos);gl_Position=mix(u_matrix*vec4(pos,z_offset,1),AWAY,hidden);vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,pos); #ifdef FLIP_Y v_pos_world=(vec2(gl_Position.x,-gl_Position.y)/gl_Position.w+1.0)/2.0*u_world; #else v_pos_world=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world; #endif #ifdef RENDER_SHADOWS vec3 shd_pos0=vec3(pos,z_offset);vec3 shd_pos1=vec3(pos,z_offset); #ifdef NORMAL_OFFSET vec3 offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1(); #endif v_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w; #endif #ifdef FOG v_fog_pos=fog_position(pos); #endif }`),fillPattern:Hn(`#include "_prelude_fog.fragment.glsl" #include "_prelude_lighting.glsl" #include "_prelude_shadow.fragment.glsl" uniform vec2 u_texsize;uniform sampler2D u_image; #ifdef FILL_PATTERN_TRANSITION uniform float u_pattern_transition; #endif in highp vec2 v_pos;uniform float u_emissive_strength; #ifdef RENDER_SHADOWS uniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth; #endif #ifdef ELEVATED_ROADS in highp float v_road_z_offset; #endif #ifdef APPLY_LUT_ON_GPU uniform highp sampler3D u_lutTexture; #endif #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp uvec4 pattern #ifdef FILL_PATTERN_TRANSITION #pragma mapbox: define mediump uvec4 pattern_b #endif void main() { #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize mediump uvec4 pattern #ifdef FILL_PATTERN_TRANSITION #pragma mapbox: initialize mediump uvec4 pattern_b #endif vec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(pattern.zw);highp vec2 imagecoord=mod(v_pos,1.0);highp vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);highp vec2 lod_pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,v_pos);vec4 out_color=textureLodCustom(u_image,pos,lod_pos); #ifdef APPLY_LUT_ON_GPU out_color=applyLUT(u_lutTexture,out_color); #endif #ifdef FILL_PATTERN_TRANSITION vec2 pattern_b_tl=vec2(pattern_b.xy);vec2 pattern_b_br=vec2(pattern_b.zw);highp vec2 pos_b=mix(pattern_b_tl/u_texsize,pattern_b_br/u_texsize,imagecoord);vec4 color_b=textureLodCustom(u_image,pos_b,lod_pos);out_color=out_color*(1.0-u_pattern_transition)+color_b*u_pattern_transition; #endif vec2 cutout_factors=vec2(0.0); #ifdef FEATURE_CUTOUT cutout_factors=get_cutout_factors(gl_FragCoord); #endif #ifdef LIGHTING_3D_MODE out_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength); #ifdef RENDER_SHADOWS float light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);light=mix(light,1.0,cutout_factors.y); #ifdef ELEVATED_ROADS out_color.rgb*=mix(v_road_z_offset !=0.0 ? u_ground_shadow_factor : vec3(1.0),vec3(1.0),light); #else out_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light); #endif #endif #endif #ifdef FEATURE_CUTOUT out_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x); #endif #ifdef FOG out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos)); #endif glFragColor=out_color*opacity; #ifdef USE_MRT1 out_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a); #endif #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(1.0); #endif HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl" #include "_prelude_shadow.vertex.glsl" uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;in ivec2 a_pos; #ifdef ELEVATED_ROADS in float a_road_z_offset;out highp float v_road_z_offset; #endif #ifdef RENDER_SHADOWS uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth; #endif out highp vec2 v_pos; #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp uvec4 pattern #ifdef FILL_PATTERN_TRANSITION #pragma mapbox: define mediump uvec4 pattern_b #endif #pragma mapbox: define lowp float pixel_ratio #pragma mapbox: define highp float z_offset void main() { #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize mediump uvec4 pattern #pragma mapbox: initialize lowp float pixel_ratio #pragma mapbox: initialize highp float z_offset #ifdef FILL_PATTERN_TRANSITION #pragma mapbox: initialize mediump uvec4 pattern_b #endif vec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(pattern.zw);vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio; #ifdef ELEVATED_ROADS z_offset+=a_road_z_offset;v_road_z_offset=z_offset; #endif float hidden=float(opacity==0.0);vec2 pos=vec2(a_pos);gl_Position=mix(u_matrix*vec4(pos,z_offset,1),AWAY,hidden);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,pos); #ifdef RENDER_SHADOWS vec3 shd_pos0=vec3(pos,z_offset);vec3 shd_pos1=vec3(pos,z_offset); #ifdef NORMAL_OFFSET vec3 offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1(); #endif v_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w; #endif #ifdef FOG v_fog_pos=fog_position(pos); #endif }`),lineBlendComposite:Hn(`uniform sampler2D u_image;uniform float u_opacity;uniform int u_blend_mode;in vec2 v_pos; #define ADDITIVE 1 void main() {vec4 color=texture(u_image,v_pos);if (u_blend_mode==ADDITIVE) {if (color.a <=0.0) {discard;}float density=color.a;vec3 avgColor=color.rgb/max(density,0.001);float t=density/(1.0+density);glFragColor=vec4(avgColor*t*u_opacity,t*u_opacity);} else {vec3 multiplyFactor=color.rgb*u_opacity+(1.0-u_opacity);glFragColor=vec4(multiplyFactor,1.0);} #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(0.0); #endif HANDLE_WIREFRAME_DEBUG;}`,"in ivec2 a_pos;out vec2 v_pos;void main() {gl_Position=vec4(a_pos,0,1);v_pos=vec2(a_pos)*0.5+0.5;}"),fillExtrusion:Hn(`#include "_prelude_fog.fragment.glsl" #include "_prelude_shadow.fragment.glsl" #include "_prelude_lighting.glsl" in vec4 v_color;in vec4 v_flat; #ifdef RENDER_SHADOWS in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1; #endif uniform lowp float u_opacity; #ifdef RENDER_FRONT_CUTOFF in float v_front_cutoff_opacity; #endif #ifdef INDICATOR_CUTOUT #ifdef FEATURE_CUTOUT in vec4 v_ground_roof; #endif #endif #ifdef FAUX_AO uniform lowp vec2 u_ao;in vec2 v_ao; #endif #if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE) in vec4 v_roof_color; #endif #if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE) in highp vec3 v_normal; #endif uniform vec3 u_flood_light_color;uniform highp float u_vertical_scale;uniform float u_flood_light_intensity;uniform vec3 u_ground_shadow_factor; #if defined(LIGHTING_3D_MODE) && defined(FLOOD_LIGHT) in float v_flood_radius;in float v_has_floodlight; #endif in float v_height; #pragma mapbox: define highp float emissive_strength void main() { #pragma mapbox: initialize highp float emissive_strength #if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE) vec3 normal=normalize(v_normal); #endif float z;vec4 color=v_color; #ifdef ZERO_ROOF_RADIUS z=float(normal.z > 0.00001); #ifdef LIGHTING_3D_MODE normal=mix(normal,vec3(0.0,0.0,1.0),z); #else color=mix(v_color,v_roof_color,z); #endif #endif float h=max(0.0,v_height);float ao_shade=1.0; #ifdef FAUX_AO float intensity=u_ao[0];float h_floors=h/(u_ao[1]*u_vertical_scale);float y_shade=1.0-0.9*intensity*min(v_ao.y,1.0);ao_shade=(1.0-0.08*intensity)*(y_shade+(1.0-y_shade)*(1.0-pow(1.0-min(h_floors/16.0,1.0),16.0)))+0.08*intensity*min(h_floors/160.0,1.0);float concave=v_ao.x*v_ao.x; #ifdef ZERO_ROOF_RADIUS concave*=(1.0-z); #endif float x_shade=mix(1.0,mix(0.6,0.75,min(h_floors/30.0,1.0)),intensity)+0.1*intensity*min(h,1.0);ao_shade*=mix(1.0,x_shade*x_shade*x_shade,concave); #ifdef LIGHTING_3D_MODE #ifdef FLOOD_LIGHT color.rgb*=mix(ao_shade,1.0,v_has_floodlight); #else color.rgb*=ao_shade; #endif #else color.rgb*=ao_shade; #endif #endif #ifdef LIGHTING_3D_MODE float flood_radiance=0.0; #ifdef FLOOD_LIGHT flood_radiance=(1.0-min(h/v_flood_radius,1.0))*u_flood_light_intensity*v_has_floodlight; #endif #ifdef RENDER_SHADOWS #ifdef FLOOD_LIGHT float ndotl_unclamped=dot(normal,u_shadow_direction);float ndotl=max(0.0,ndotl_unclamped);float occlusion=ndotl_unclamped < 0.0 ? 1.0 : shadow_occlusion(ndotl,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);vec3 litColor=apply_lighting(color.rgb,normal,(1.0-u_shadow_intensity*occlusion)*ndotl);vec3 floodLitColor=compute_flood_lighting(u_flood_light_color*u_opacity,1.0-u_shadow_intensity,occlusion,u_ground_shadow_factor);color.rgb=mix(litColor,floodLitColor,flood_radiance); #else float shadowed_lighting_factor; #ifdef RENDER_CUTOFF shadowed_lighting_factor=shadowed_light_factor_normal_opacity(normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w,v_cutoff_opacity);if (v_cutoff_opacity==0.0) {discard;} #else shadowed_lighting_factor=shadowed_light_factor_normal(normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w); #endif color.rgb=apply_lighting(color.rgb,normal,shadowed_lighting_factor); #endif #else color.rgb=apply_lighting(color.rgb,normal); #ifdef FLOOD_LIGHT color.rgb=mix(color.rgb,u_flood_light_color*u_opacity,flood_radiance); #endif #endif color.rgb=mix(color.rgb,v_flat.rgb,emissive_strength);color*=u_opacity; #endif #ifdef FOG color=fog_dither(fog_apply_premultiplied(color,v_fog_pos,h)); #endif #ifdef INDICATOR_CUTOUT #ifdef FEATURE_CUTOUT {float ditherOpacity=cutoutGroundRoofOpacity(v_ground_roof);if (ditherOpacity < 1.0) {int index=(int(gl_FragCoord.x) % 4)*4+(int(gl_FragCoord.y) % 4);if (ditherOpacity < DITHER_THRESHOLDS[index]) {discard;}}} #else color=applyCutout(color,h); #endif #endif #ifdef RENDER_FRONT_CUTOFF if (v_front_cutoff_opacity < 1.0) {int index=(int(gl_FragCoord.x) % 4)*4+(int(gl_FragCoord.y) % 4);if (v_front_cutoff_opacity < DITHER_THRESHOLDS[index]) {discard;}} #endif #ifdef FEATURE_CUTOUT color=apply_feature_cutout(color,gl_FragCoord,get_cutout_factors(gl_FragCoord).x); #endif glFragColor=color; #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(1.0); #endif HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl" #include "_prelude_terrain.vertex.glsl" #include "_prelude_shadow.vertex.glsl" #include "_prelude_lighting.glsl" #include "_prelude_material_table.vertex.glsl" uniform mat4 u_matrix;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform float u_edge_radius;uniform float u_width_scale;in ivec4 a_pos_normal_ed; #if defined(HAS_CENTROID) || defined(TERRAIN) in uvec2 a_centroid_pos; #endif #ifdef RENDER_WALL_MODE in ivec4 a_join_normal_inside; #endif #ifdef PROJECTION_GLOBE_VIEW in ivec4 a_pos_3;in ivec4 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift; #endif #ifdef TERRAIN uniform int u_height_type;uniform int u_base_type; #endif uniform highp float u_vertical_scale; #ifdef RENDER_FRONT_CUTOFF uniform vec3 u_front_cutoff_params;out float v_front_cutoff_opacity; #endif out vec4 v_color;out vec4 v_flat; #ifdef RENDER_SHADOWS uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1; #endif #if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE) out vec4 v_roof_color; #endif #if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE) out highp vec3 v_normal; #endif #ifdef FAUX_AO uniform lowp vec2 u_ao;out vec2 v_ao; #endif #if defined(LIGHTING_3D_MODE) && defined(FLOOD_LIGHT) out float v_flood_radius;out float v_has_floodlight; #endif out float v_height; #ifdef INDICATOR_CUTOUT #ifdef FEATURE_CUTOUT out vec4 v_ground_roof; #endif #endif vec3 linearTosRGB(vec3 color) {return pow(color,vec3(1./2.2));}vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));} #pragma mapbox: define highp float base #pragma mapbox: define highp float height #pragma mapbox: define highp vec4 color #pragma mapbox: define highp float flood_light_wall_radius #pragma mapbox: define highp float line_width #pragma mapbox: define highp float emissive_strength void main() {DECLARE_MATERIAL_TABLE_INFO #pragma mapbox: initialize highp float base #pragma mapbox: initialize highp float height #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize highp float flood_light_wall_radius #pragma mapbox: initialize highp float line_width #pragma mapbox: initialize highp float emissive_strength base*=u_vertical_scale;height*=u_vertical_scale;vec4 top_up_ny_start=vec4(a_pos_normal_ed & 1);vec4 pos_nx=vec4(a_pos_normal_ed >> 1);float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny_start.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny_start.z-1.0)*(1.0-abs(x_normal)),0.0)); #if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE) v_normal=normal; #endif base=max(0.0,base);float attr_height=height;height=max(0.0,top_up_ny_start.y==0.0 && top_up_ny_start.x==1.0 ? height-u_edge_radius : height);float t=top_up_ny_start.x;vec2 centroid_pos=vec2(0.0); #if defined(HAS_CENTROID) || defined(TERRAIN) centroid_pos=vec2(a_centroid_pos); #endif float ele=0.0;float h=0.0;float c_ele=0.0;vec3 pos; #ifdef TERRAIN bool is_flat_height=centroid_pos.x !=0.0 && u_height_type==1;bool is_flat_base=centroid_pos.x !=0.0 && u_base_type==1;ele=elevation(pos_nx.xy);bool is_elevation_encoded=centroid_pos.y==0.0 || (centroid_pos.y > 0.0 && (int(centroid_pos.y) & 7)==7);c_ele=is_flat_height || is_flat_base ? (is_elevation_encoded ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos)) : ele;float h_height=is_flat_height ? max(c_ele+height,ele+base+2.0) : ele+height;float h_base=is_flat_base ? max(c_ele+base,ele+base) : ele+(base==0.0 ?-5.0 : base);h=t > 0.0 ? max(h_base,h_height) : h_base; #else h=t > 0.0 ? height : base; #endif pos=vec3(pos_nx.xy,h); #ifdef PROJECTION_GLOBE_VIEW float lift=float((t+base) > 0.0)*u_height_lift;h+=lift;vec3 globe_normal=normalize(mix(vec3(a_pos_normal_3)/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=vec3(a_pos_3)+globe_normal*(u_tile_up_scale*h);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,pos.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*pos.z;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition); #endif float cutoff=1.0;vec3 scaled_pos=pos; #if defined(RENDER_CUTOFF) || defined(RENDER_FRONT_CUTOFF) vec2 centroid_decoded=pos.xy;bool isBorderCentroid=false;if (centroid_pos.x > 0.0 && centroid_pos.y > 0.0) {int iy=int(centroid_pos.y);int spanYbits=iy & 7;if (spanYbits==7) {isBorderCentroid=true;int borderID=(iy >> 3) & 3;float coordAlongBorder=float(iy >> 5)*4.0;if (borderID==0) centroid_decoded=vec2(0.0,coordAlongBorder);else if (borderID==1) centroid_decoded=vec2(EXTENT,coordAlongBorder);else if (borderID==2) centroid_decoded=vec2(coordAlongBorder,0.0);else centroid_decoded=vec2(coordAlongBorder,EXTENT);} else {centroid_decoded=floor(centroid_pos/8.0);}} #endif #if defined(RENDER_CUTOFF) || defined(RENDER_FRONT_CUTOFF) vec4 ground=u_matrix*vec4(centroid_decoded,ele,1.0); #endif #ifdef RENDER_CUTOFF #ifdef CLIP_ZERO_TO_ONE cutoff=cutoff_opacity(u_cutoff_params,ground.z*2.0-ground.w); #else cutoff=cutoff_opacity(u_cutoff_params,ground.z); #endif if (centroid_pos.y !=0.0 && centroid_pos.x !=0.0) {vec3 centroid_random=vec3(centroid_pos.xy,centroid_pos.x+centroid_pos.y+1.0);vec3 ground_pos=centroid_random/8.0;vec3 g=floor(ground_pos);vec3 mod_=centroid_random-g*8.0;float seed=min(1.0,0.1*(min(3.5,max(mod_.x+mod_.y,0.2*attr_height))*0.35+mod_.z));if (cutoff < 0.8-seed) {cutoff=0.0;}}float cutoff_scale=cutoff;v_cutoff_opacity=cutoff;scaled_pos.z=mix(c_ele,h,cutoff_scale); #endif float hidden=float((centroid_pos.x==0.0 && centroid_pos.y==1.0) || (cutoff==0.0 && centroid_pos.x !=0.0) || (color.a==0.0)); #ifdef RENDER_FRONT_CUTOFF v_front_cutoff_opacity=1.0;if (centroid_pos.x > 0.0 && centroid_pos.y > 0.0) {hidden=max(hidden,float(ground.w <=0.0));float ndc_y=ground.y/max(ground.w,0.001);float threshold=u_front_cutoff_params.x*2.0-1.0;float range_ndc=u_front_cutoff_params.y*2.0;if (!isBorderCentroid) {hidden=max(hidden,float(ndc_y < threshold-range_ndc));}float t=clamp((ndc_y-(threshold-range_ndc))/max(range_ndc,0.001),0.0,1.0);v_front_cutoff_opacity=mix(u_front_cutoff_params.z,1.0,t);} #endif #ifdef RENDER_WALL_MODE vec3 join_normal_inside=vec3(a_join_normal_inside);vec2 wall_offset=u_width_scale*line_width*(join_normal_inside.xy/EXTENT);scaled_pos.xy+=(1.0-join_normal_inside.z)*wall_offset*0.5;scaled_pos.xy-=join_normal_inside.z*wall_offset*0.5; #endif gl_Position=mix(u_matrix*vec4(scaled_pos,1),AWAY,hidden);h=h-ele;v_height=h; #ifdef RENDER_SHADOWS vec3 shd_pos0=pos;vec3 shd_pos1=pos; #ifdef NORMAL_OFFSET vec3 offset=shadow_normal_offset(normal);shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1(); #endif v_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1); #endif float NdotL=0.0;float colorvalue=0.0; #ifndef LIGHTING_3D_MODE colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;NdotL=clamp(dot(normal,u_lightpos),0.0,1.0);NdotL=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),NdotL);if (normal.y !=0.0) {float r=0.84;r=mix(0.7,0.98,1.0-u_lightintensity);NdotL*=( (1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),r,1.0)));} #endif #ifdef FAUX_AO float concave=pos_nx.w-floor(pos_nx.w*0.5)*2.0;float start=top_up_ny_start.w;float y_ground=1.0-clamp(t+base,0.0,1.0);float top_height=height; #ifdef TERRAIN top_height=mix(max(c_ele+height,ele+base+2.0),ele+height,float(centroid_pos.x==0.0))-ele;y_ground+=y_ground*5.0/max(3.0,top_height); #endif v_ao=vec2(mix(concave,-concave,start),y_ground);NdotL*=(1.0+0.05*(1.0-top_up_ny_start.y)*u_ao[0]); #ifdef PROJECTION_GLOBE_VIEW top_height+=u_height_lift; #endif gl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w; #endif #ifdef LIGHTING_3D_MODE #ifdef FLOOD_LIGHT float is_wall=1.0-float(t > 0.0 && top_up_ny_start.y > 0.0);v_has_floodlight=float(flood_light_wall_radius > 0.0 && is_wall > 0.0);v_flood_radius=flood_light_wall_radius*u_vertical_scale; #endif v_color=vec4(color.rgb,1.0);float ndotl=calculate_NdotL(normal);v_flat.rgb=sRGBToLinear(color.rgb);v_flat.rgb=v_flat.rgb*(ndotl+(1.0-min(ndotl*57.29,1.0))*emissive_strength);v_flat=vec4(linearTosRGB(v_flat.rgb),1.0); #else v_color=vec4(0.0,0.0,0.0,1.0);v_color.rgb+=clamp(color.rgb*NdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_color*=u_opacity; #endif #if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE) float roofNdotL=clamp(u_lightpos.z,0.0,1.0);roofNdotL=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),roofNdotL);v_roof_color=vec4(0.0,0.0,0.0,1.0);v_roof_color.rgb+=clamp(color.rgb*roofNdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_roof_color*=u_opacity; #endif #ifdef FOG v_fog_pos=fog_position(pos); #endif #ifdef INDICATOR_CUTOUT #ifdef FEATURE_CUTOUT vec4 pos_ground=u_matrix*vec4(pos.xy,ele,1.0);vec4 pos_roof=u_matrix*vec4(pos.xy,ele+height,1.0);v_ground_roof=vec4(pos_ground.xy/pos_ground.w,pos_roof.xy/pos_roof.w); #endif #endif }`),fillExtrusionDepth:Hn("void main() {}",`#include "_prelude_terrain.vertex.glsl" #include "_prelude_material_table.vertex.glsl" uniform mat4 u_matrix;uniform float u_edge_radius;uniform float u_width_scale;uniform float u_vertical_scale; #ifdef TERRAIN uniform int u_height_type;uniform int u_base_type; #endif in ivec4 a_pos_normal_ed; #if defined(HAS_CENTROID) || defined(TERRAIN) in uvec2 a_centroid_pos; #endif #ifdef RENDER_WALL_MODE in ivec4 a_join_normal_inside; #endif #pragma mapbox: define highp float base #pragma mapbox: define highp float height #pragma mapbox: define highp float line_width #pragma mapbox: define highp vec4 color void main() {DECLARE_MATERIAL_TABLE_INFO #pragma mapbox: initialize highp float base #pragma mapbox: initialize highp float height #pragma mapbox: initialize highp float line_width #pragma mapbox: initialize highp vec4 color base*=u_vertical_scale;height*=u_vertical_scale;vec3 top_up_ny=vec3(a_pos_normal_ed.xyz & 1);vec3 pos_nx=vec3(a_pos_normal_ed.xyz >> 1);base=max(0.0,base);height=max(0.0,top_up_ny.y==0.0 && top_up_ny.x==1.0 ? height-u_edge_radius : height);float t=top_up_ny.x;vec2 centroid_pos=vec2(0.0); #if defined(HAS_CENTROID) || defined(TERRAIN) centroid_pos=vec2(a_centroid_pos); #endif vec3 pos; #ifdef TERRAIN bool is_flat_height=centroid_pos.x !=0.0 && u_height_type==1;bool is_flat_base=centroid_pos.x !=0.0 && u_base_type==1;float ele=elevation(pos_nx.xy);bool is_elevation_encoded=centroid_pos.y==0.0 || (centroid_pos.y > 0.0 && int(centroid_pos.y)-(int(centroid_pos.y)/8)*8==7);float c_ele=is_flat_height || is_flat_base ? (is_elevation_encoded ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos)) : ele;float h_height=is_flat_height ? max(c_ele+height,ele+base+2.0) : ele+height;float h_base=is_flat_base ? max(c_ele+base,ele+base) : ele+(base==0.0 ?-5.0 : base);float h=t > 0.0 ? max(h_base,h_height) : h_base;pos=vec3(pos_nx.xy,h); #else pos=vec3(pos_nx.xy,t > 0.0 ? height : base); #endif #ifdef RENDER_WALL_MODE vec3 join_normal_inside=vec3(a_join_normal_inside);vec2 wall_offset=u_width_scale*line_width*(join_normal_inside.xy/EXTENT);pos.xy+=(1.0-join_normal_inside.z)*wall_offset*0.5;pos.xy-=join_normal_inside.z*wall_offset*0.5; #endif float hidden=float((centroid_pos.x==0.0 && centroid_pos.y==1.0) || (color.a==0.0));gl_Position=mix(u_matrix*vec4(pos,1),AWAY,hidden);}`),fillExtrusionPattern:Hn(`#include "_prelude_fog.fragment.glsl" #include "_prelude_lighting.glsl" uniform vec2 u_texsize;uniform sampler2D u_image; #ifdef FILL_EXTRUSION_PATTERN_TRANSITION uniform float u_pattern_transition; #endif #ifdef FAUX_AO uniform lowp vec2 u_ao;in vec3 v_ao; #endif #ifdef LIGHTING_3D_MODE in vec3 v_normal; #endif #ifdef APPLY_LUT_ON_GPU uniform highp sampler3D u_lutTexture; #endif in highp vec2 v_pos;in vec4 v_lighting;uniform lowp float u_opacity; #pragma mapbox: define highp float base #pragma mapbox: define highp float height #pragma mapbox: define mediump uvec4 pattern #ifdef FILL_EXTRUSION_PATTERN_TRANSITION #pragma mapbox: define mediump uvec4 pattern_b #endif #pragma mapbox: define highp float pixel_ratio void main() { #pragma mapbox: initialize highp float base #pragma mapbox: initialize highp float height #pragma mapbox: initialize mediump uvec4 pattern #ifdef FILL_EXTRUSION_PATTERN_TRANSITION #pragma mapbox: initialize mediump uvec4 pattern_b #endif #pragma mapbox: initialize highp float pixel_ratio vec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(pattern.zw);highp vec2 imagecoord=mod(v_pos,1.0);highp vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);highp vec2 lod_pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,v_pos);vec4 out_color=textureLodCustom(u_image,pos,lod_pos); #ifdef APPLY_LUT_ON_GPU out_color=applyLUT(u_lutTexture,out_color); #endif #ifdef FILL_EXTRUSION_PATTERN_TRANSITION vec2 pattern_b_tl=vec2(pattern_b.xy);vec2 pattern_b_br=vec2(pattern_b.zw);highp vec2 pos_b=mix(pattern_b_tl/u_texsize,pattern_b_br/u_texsize,imagecoord);vec4 color_b=textureLodCustom(u_image,pos_b,lod_pos);out_color=out_color*(1.0-u_pattern_transition)+color_b*u_pattern_transition; #endif #ifdef LIGHTING_3D_MODE out_color=apply_lighting(out_color,normalize(v_normal))*u_opacity; #else out_color=out_color*v_lighting; #endif #ifdef FAUX_AO float intensity=u_ao[0];float h=max(0.0,v_ao.z);float h_floors=h/u_ao[1];float y_shade=1.0-0.9*intensity*min(v_ao.y,1.0);float shade=(1.0-0.08*intensity)*(y_shade+(1.0-y_shade)*(1.0-pow(1.0-min(h_floors/16.0,1.0),16.0)))+0.08*intensity*min(h_floors/160.0,1.0);float concave=v_ao.x*v_ao.x;float x_shade=mix(1.0,mix(0.6,0.75,min(h_floors/30.0,1.0)),intensity)+0.1*intensity*min(h,1.0);shade*=mix(1.0,x_shade*x_shade*x_shade,concave);out_color.rgb=out_color.rgb*shade; #endif #ifdef FOG out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos)); #endif #ifdef INDICATOR_CUTOUT out_color=applyCutout(out_color,height); #endif glFragColor=out_color; #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(1.0); #endif HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl" #include "_prelude_terrain.vertex.glsl" #include "_prelude_lighting.glsl" #include "_prelude_material_table.vertex.glsl" uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform float u_tile_units_to_pixels;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform float u_width_scale;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;in ivec4 a_pos_normal_ed; #if defined(HAS_CENTROID) || defined(TERRAIN) in uvec2 a_centroid_pos; #endif #ifdef RENDER_WALL_MODE in ivec4 a_join_normal_inside; #endif #ifdef PROJECTION_GLOBE_VIEW in ivec4 a_pos_3;in ivec4 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift; #endif #ifdef TERRAIN uniform int u_height_type;uniform int u_base_type; #endif out highp vec2 v_pos;out vec4 v_lighting; #ifdef FAUX_AO uniform lowp vec2 u_ao;out vec3 v_ao; #endif #ifdef LIGHTING_3D_MODE out vec3 v_normal; #endif #pragma mapbox: define highp float base #pragma mapbox: define highp float height #pragma mapbox: define highp vec4 color #pragma mapbox: define mediump uvec4 pattern #ifdef FILL_EXTRUSION_PATTERN_TRANSITION #pragma mapbox: define mediump uvec4 pattern_b #endif #pragma mapbox: define highp float pixel_ratio #pragma mapbox: define highp float line_width void main() {DECLARE_MATERIAL_TABLE_INFO #pragma mapbox: initialize highp float base #pragma mapbox: initialize highp float height #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize mediump uvec4 pattern #ifdef FILL_EXTRUSION_PATTERN_TRANSITION #pragma mapbox: initialize mediump uvec4 pattern_b #endif #pragma mapbox: initialize highp float pixel_ratio #pragma mapbox: initialize highp float line_width vec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(pattern.zw);vec4 top_up_ny_start=vec4(a_pos_normal_ed & 1);vec4 pos_nx=vec4(a_pos_normal_ed >> 1);float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny_start.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny_start.z-1.0)*(1.0-abs(x_normal)),0.0));float edgedistance=float(a_pos_normal_ed.w);vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;base=max(0.0,base);height=max(0.0,height);float t=top_up_ny_start.x;float z=t > 0.0 ? height : base;vec2 centroid_pos=vec2(0.0); #if defined(HAS_CENTROID) || defined(TERRAIN) centroid_pos=vec2(a_centroid_pos); #endif float ele=0.0;float h=z;vec3 p;float c_ele; #ifdef TERRAIN bool is_flat_height=centroid_pos.x !=0.0 && u_height_type==1;bool is_flat_base=centroid_pos.x !=0.0 && u_base_type==1;ele=elevation(pos_nx.xy);bool is_elevation_encoded=centroid_pos.y==0.0 || (centroid_pos.y > 0.0 && int(centroid_pos.y)-(int(centroid_pos.y)/8)*8==7);c_ele=is_flat_height || is_flat_base ? (is_elevation_encoded ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos)) : ele;float h_height=is_flat_height ? max(c_ele+height,ele+base+2.0) : ele+height;float h_base=is_flat_base ? max(c_ele+base,ele+base) : ele+(base==0.0 ?-5.0 : base);h=t > 0.0 ? max(h_base,h_height) : h_base;p=vec3(pos_nx.xy,h); #else p=vec3(pos_nx.xy,z); #endif #ifdef PROJECTION_GLOBE_VIEW float lift=float((t+base) > 0.0)*u_height_lift;h+=lift;vec3 globe_normal=normalize(mix(vec3(a_pos_normal_3)/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=vec3(a_pos_3)+globe_normal*(u_tile_up_scale*(p.z+lift));vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,p.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*p.z;p=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition); #endif #ifdef RENDER_WALL_MODE vec3 join_normal_inside=vec3(a_join_normal_inside);vec2 wall_offset=u_width_scale*line_width*(join_normal_inside.xy/EXTENT);p.xy+=(1.0-join_normal_inside.z)*wall_offset*0.5;p.xy-=join_normal_inside.z*wall_offset*0.5; #endif float hidden=float((centroid_pos.x==0.0 && centroid_pos.y==1.0) || (color.a==0.0));gl_Position=mix(u_matrix*vec4(p,1),AWAY,hidden);vec2 pos=normal.z==1.0 ? pos_nx.xy : vec2(edgedistance,z*u_height_factor);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float NdotL=0.0; #ifdef LIGHTING_3D_MODE NdotL=calculate_NdotL(normal); #else NdotL=clamp(dot(normal,u_lightpos),0.0,1.0);NdotL=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),NdotL); #endif if (normal.y !=0.0) {float r=0.84; #ifndef LIGHTING_3D_MODE r=mix(0.7,0.98,1.0-u_lightintensity); #endif NdotL*=( (1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),r,1.0)));} #ifdef FAUX_AO float concave=pos_nx.w-floor(pos_nx.w*0.5)*2.0;float start=top_up_ny_start.w;float y_ground=1.0-clamp(t+base,0.0,1.0);float top_height=height; #ifdef TERRAIN top_height=mix(max(c_ele+height,ele+base+2.0),ele+height,float(centroid_pos.x==0.0))-ele;y_ground+=y_ground*5.0/max(3.0,top_height); #endif v_ao=vec3(mix(concave,-concave,start),y_ground,h-ele);NdotL*=(1.0+0.05*(1.0-top_up_ny_start.y)*u_ao[0]); #ifdef PROJECTION_GLOBE_VIEW top_height+=u_height_lift; #endif gl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w; #endif #ifdef LIGHTING_3D_MODE v_normal=normal; #else v_lighting.rgb+=clamp(NdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity; #endif #ifdef FOG v_fog_pos=fog_position(p); #endif }`),groundShadow:Hn(`#include "_prelude_shadow.fragment.glsl" precision highp float;uniform vec3 u_ground_shadow_factor;in vec4 v_pos_light_view_0;in vec4 v_pos_light_view_1; #ifdef FOG in float v_fog_opacity; #endif void main() {float light=shadowed_light_factor_plane_bias(v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);vec3 shadow=mix(u_ground_shadow_factor,vec3(1.0),light); #ifdef RENDER_CUTOFF shadow=mix(vec3(1.0),shadow,cutoff_opacity(u_cutoff_params,1.0/gl_FragCoord.w)); #endif #ifdef FOG shadow=mix(shadow,vec3(1.0),v_fog_opacity); #endif #ifdef INDICATOR_CUTOUT shadow=mix(shadow,vec3(1.0),1.0-applyCutout(vec4(1.0),0.0).r); #endif #ifdef FEATURE_CUTOUT shadow=mix(shadow,vec3(1.0),get_cutout_factors(gl_FragCoord).y); #endif glFragColor=vec4(shadow,1.0);}`,`#include "_prelude_fog.vertex.glsl" uniform mat4 u_matrix;uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;in ivec2 a_pos;out vec4 v_pos_light_view_0;out vec4 v_pos_light_view_1; #ifdef FOG out float v_fog_opacity; #endif void main() {gl_Position=u_matrix*vec4(a_pos,0.0,1.0);v_pos_light_view_0=u_light_matrix_0*vec4(a_pos,0.0,1.0);v_pos_light_view_1=u_light_matrix_1*vec4(a_pos,0.0,1.0); #ifdef FOG v_fog_pos=fog_position(vec2(a_pos));v_fog_opacity=fog(v_fog_pos); #endif }`),fillExtrusionGroundEffect:Hn(`uniform highp float u_ao_pass;uniform highp float u_opacity;uniform highp float u_flood_light_intensity;uniform highp vec3 u_flood_light_color;uniform highp float u_attenuation;uniform sampler2D u_fb;uniform float u_fb_size; #ifdef SDF_SUBPASS in highp vec2 v_pos;in highp vec4 v_line_segment;in highp float v_flood_light_radius_tile;in highp vec2 v_ao;float line_df(highp vec2 a,highp vec2 b,highp vec2 p) {highp vec2 ba=b-a;highp vec2 pa=p-a;highp float r=clamp(dot(pa,ba)/dot(ba,ba),0.0,1.0);return length(pa-r*ba);} #ifdef FOG in highp float v_fog; #endif #endif void main() { #ifdef CLEAR_SUBPASS vec4 color=vec4(1.0); #ifdef CLEAR_FROM_TEXTURE color=texture(u_fb,gl_FragCoord.xy/vec2(u_fb_size)); #endif glFragColor=color; #else #ifdef SDF_SUBPASS highp float d=line_df(v_line_segment.xy,v_line_segment.zw,v_pos);highp float effect_radius=mix(v_flood_light_radius_tile,v_ao.y,u_ao_pass);d/=effect_radius;d=min(d,1.0);d=1.0-pow(1.0-d,u_attenuation);highp float effect_intensity=mix(u_flood_light_intensity,v_ao.x,u_ao_pass);highp float fog=1.0; #ifdef FOG fog=v_fog; #endif #ifdef RENDER_CUTOFF fog*=v_cutoff_opacity; #endif glFragColor=vec4(vec3(0.0),mix(1.0,d,effect_intensity*u_opacity*fog)); #else #ifdef USE_MRT1 out_Target1=vec4(1.0-texture(u_fb,gl_FragCoord.xy/vec2(u_fb_size)).a,0.0,0.0,0.0); #else vec4 color=mix(vec4(u_flood_light_color,1.0),vec4(vec3(0.0),1.0),u_ao_pass); #ifdef OVERDRAW_INSPECTOR color=vec4(1.0); #endif glFragColor=color; #endif #endif HANDLE_WIREFRAME_DEBUG; #endif }`,`#include "_prelude_fog.vertex.glsl" in highp ivec4 a_pos_end;in highp int a_angular_offset_factor;in highp uint a_hidden_by_landmark; #ifdef SDF_SUBPASS out highp vec2 v_pos;out highp vec4 v_line_segment;out highp float v_flood_light_radius_tile;out highp vec2 v_ao; #ifdef FOG out highp float v_fog; #endif #endif uniform highp float u_flood_light_intensity;uniform highp mat4 u_matrix;uniform highp float u_ao_pass;uniform highp float u_meter_to_tile;uniform highp float u_edge_radius;uniform highp float u_dynamic_offset;uniform highp vec2 u_ao; #pragma mapbox: define highp float flood_light_ground_radius const float TANGENT_CUTOFF=4.0;const float NORM=32767.0;void main() { #pragma mapbox: initialize highp float flood_light_ground_radius vec4 pos_end=vec4(a_pos_end);vec2 p=pos_end.xy;vec2 q=floor(pos_end.zw*0.5);vec2 start_bottom=pos_end.zw-q*2.0;float fl_ground_radius=abs(flood_light_ground_radius);float direction=flood_light_ground_radius < 0.0 ?-1.0 : 1.0;float flood_radius_tile=fl_ground_radius*u_meter_to_tile;vec2 v=normalize(q-p);float ao_radius=u_ao.y/3.5;float effect_radius=mix(flood_radius_tile,ao_radius,u_ao_pass)+u_edge_radius;float angular_offset_factor=float(a_angular_offset_factor)/NORM*TANGENT_CUTOFF;float angular_offset=direction*angular_offset_factor*effect_radius;float top=1.0-start_bottom.y;float side=(0.5-start_bottom.x)*2.0;vec2 extrusion_parallel=v*side*mix(u_dynamic_offset,angular_offset,top);vec2 perp=vec2(v.y,-v.x);vec2 extrusion_perp=direction*perp*effect_radius*top;vec3 pos=vec3(mix(q,p,start_bottom.x),0.0);pos.xy+=extrusion_parallel+extrusion_perp; #ifdef SDF_SUBPASS v_pos=pos.xy;v_line_segment=vec4(p,q)+perp.xyxy*u_edge_radius;v_flood_light_radius_tile=flood_radius_tile;v_ao=vec2(u_ao.x,ao_radius); #ifdef FOG v_fog_pos=fog_position(pos);v_fog=1.0-fog(v_fog_pos); #endif #endif float hidden_by_landmark=0.0; #ifdef HAS_CENTROID hidden_by_landmark=float(a_hidden_by_landmark); #endif float isFloodlit=float(fl_ground_radius > 0.0 && u_flood_light_intensity > 0.0);float hidden=mix(1.0-isFloodlit,isFloodlit,u_ao_pass);hidden+=hidden_by_landmark;gl_Position=mix(u_matrix*vec4(pos,1.0),AWAY,float(hidden > 0.0)); #ifdef RENDER_CUTOFF v_cutoff_opacity=cutoff_opacity(u_cutoff_params,gl_Position.z); #endif }`),hillshadePrepare:Hn(`precision highp float;uniform highp sampler2D u_image;in vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;float getElevation(vec2 coord) {return texture(u_image,coord).r/4.0;}void main() {vec2 epsilon=1.0/u_dimension;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y));float b=getElevation(v_pos+vec2(0,-epsilon.y));float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y));float d=getElevation(v_pos+vec2(-epsilon.x,0));float e=getElevation(v_pos+vec2(epsilon.x,0));float f=getElevation(v_pos+vec2(-epsilon.x,epsilon.y));float g=getElevation(v_pos+vec2(0,epsilon.y));float h=getElevation(v_pos+vec2(epsilon.x,epsilon.y));float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2( (c+e+e+h)-(a+d+d+f),(f+g+g+h)-(a+b+b+c) )/pow(2.0,exaggeration+(19.2562-u_zoom));glFragColor=clamp(vec4( deriv.x/2.0+0.5,deriv.y/2.0+0.5,1.0,1.0),0.0,1.0);}`,"uniform mat4 u_matrix;uniform vec2 u_dimension;in ivec2 a_pos;in uvec2 a_texture_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(vec2(a_texture_pos)/8192.0)*scale+epsilon;}"),hillshade:Hn(`#include "_prelude_fog.fragment.glsl" #include "_prelude_lighting.glsl" uniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_latrange;uniform vec2 u_light;uniform vec4 u_shadow;uniform vec4 u_highlight;uniform vec4 u_accent;uniform float u_emissive_strength;void main() {vec4 pixel=texture(u_image,v_pos);vec2 deriv=((pixel.rg*2.0)-1.0);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));float slope=atan(1.25*length(deriv)/scaleFactor);float aspect=deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);float intensity=u_light.x;float azimuth=u_light.y+PI;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadow,u_highlight,shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);glFragColor=accent_color*(1.0-shade_color.a)+shade_color; #ifdef LIGHTING_3D_MODE glFragColor=apply_lighting_with_emission_ground(glFragColor,u_emissive_strength); #endif #ifdef FOG glFragColor=fog_dither(fog_apply_premultiplied(glFragColor,v_fog_pos)); #endif #ifdef USE_MRT1 out_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a); #endif #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(1.0); #endif HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl" uniform mat4 u_matrix;in ivec2 a_pos;in uvec2 a_texture_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=vec2(a_texture_pos)/8192.0; #ifdef FOG v_fog_pos=fog_position(vec2(a_pos)); #endif }`),line:Hn(`#include "_prelude_fog.fragment.glsl" #include "_prelude_lighting.glsl" #include "_prelude_shadow.fragment.glsl" uniform lowp float u_device_pixel_ratio;uniform highp float u_width_scale;uniform highp float u_floor_width_scale;uniform float u_alpha_discard_threshold;uniform highp vec2 u_trim_offset;uniform highp vec2 u_trim_fade_range;uniform highp vec2 u_trim_gradient_mix_range;uniform lowp vec4 u_trim_color;uniform bool u_emissive_in_shadows;in vec4 v_width2_dilute;in vec2 v_normal;in float v_gamma_scale;in highp vec3 v_uv; #ifdef ELEVATED_ROADS in highp float v_road_z_offset; #endif #ifdef VARIABLE_LINE_WIDTH in float stub_side; #endif #ifdef RENDER_LINE_DASH uniform sampler2D u_dash_image;in vec2 v_tex; #endif #ifdef RENDER_LINE_GRADIENT uniform sampler2D u_gradient_image; #endif #ifdef INDICATOR_CUTOUT in highp float v_z_offset; #endif #ifdef RENDER_SHADOWS uniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth; #endif float luminance(vec3 c) {return (c.r+c.r+c.b+c.g+c.g+c.g)*0.1667;} #pragma mapbox: define highp vec4 color #pragma mapbox: define lowp float floorwidth #pragma mapbox: define mediump uvec4 dash #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity #pragma mapbox: define mediump float side_z_offset #pragma mapbox: define lowp float border_width #pragma mapbox: define lowp vec4 border_color #pragma mapbox: define lowp float emissive_strength float linearstep(float edge0,float edge1,float x) {return clamp((x-edge0)/(edge1-edge0),0.0,1.0);}void main() { #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize lowp float floorwidth #pragma mapbox: initialize mediump uvec4 dash #pragma mapbox: initialize lowp float blur #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize mediump float side_z_offset #pragma mapbox: initialize lowp float border_width #pragma mapbox: initialize lowp vec4 border_color #pragma mapbox: initialize lowp float emissive_strength float dist=length(v_normal)*v_width2_dilute.x; #ifdef VARIABLE_LINE_WIDTH blur=mix(blur,0.0,stub_side); #endif float diluted_opacity=opacity*v_width2_dilute.z;float blur2=(u_width_scale*blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2_dilute.y-blur2),v_width2_dilute.x-dist)/blur2,0.0,1.0); #ifdef VARIABLE_LINE_WIDTH alpha=mix(alpha,1.0,stub_side); #endif alpha=side_z_offset > 0.0 ? 1.0-alpha : alpha; #ifdef RENDER_LINE_DASH float sdfdist=texture(u_dash_image,v_tex).r;float sdfgamma=1.0/(2.0*u_device_pixel_ratio)/(float(dash.z)+float(dash.w)/65535.0);float scaled_floorwidth=(floorwidth*u_floor_width_scale);alpha*=linearstep(0.5-sdfgamma/scaled_floorwidth,0.5+sdfgamma/scaled_floorwidth,sdfdist); #endif highp vec4 out_color; #ifdef RENDER_LINE_GRADIENT out_color=texture(u_gradient_image,v_uv.xy); #else out_color=color; #endif float trim_alpha=1.0; #ifdef RENDER_LINE_TRIM_OFFSET highp float trim_start=u_trim_offset[0];highp float trim_end=u_trim_offset[1];highp float line_progress=v_uv[2];if (trim_end > trim_start) {highp float start_transition=max(0.0,min(1.0,(line_progress-trim_start)/max(u_trim_fade_range[0],1.0e-9)));highp float end_transition=max(0.0,min(1.0,(trim_end-line_progress)/max(u_trim_fade_range[1],1.0e-9)));highp float transition_factor=min(start_transition,end_transition);highp float gradient_trim_color_mix_factor=0.0; #ifdef RENDER_LINE_GRADIENT gradient_trim_color_mix_factor=smoothstep(u_trim_gradient_mix_range.x,u_trim_gradient_mix_range.y,line_progress); #endif highp vec4 trim_color=mix(u_trim_color,out_color,gradient_trim_color_mix_factor);out_color=mix(u_trim_gradient_mix_range.x < 1.0 ? color : out_color,trim_color,transition_factor);trim_alpha=1.0-transition_factor;} #endif if (u_alpha_discard_threshold !=0.0) {if (alpha < u_alpha_discard_threshold) {discard;}} #ifdef RENDER_LINE_BORDER #ifndef VARIABLE_LINE_WIDTH float edgeBlur=((border_width*u_width_scale)+1.0/u_device_pixel_ratio);float alpha2=clamp(min(dist-(v_width2_dilute.y-edgeBlur),v_width2_dilute.x-dist)/edgeBlur,0.0,1.0);if (alpha2 < 1.) {float smoothAlpha=smoothstep(0.6,1.0,alpha2);if (border_color.a==0.0) {float Y=(out_color.a > 0.01) ? luminance(out_color.rgb/out_color.a) : 1.;float adjustment=(Y > 0.) ? 0.5/Y : 0.45;if (out_color.a > 0.25 && Y < 0.25) {vec3 borderColor=(Y > 0.) ? out_color.rgb : vec3(1,1,1)*out_color.a;out_color.rgb=out_color.rgb+borderColor*(adjustment*(1.0-smoothAlpha));} else {out_color.rgb*=(0.6 +0.4*smoothAlpha);}} else {out_color=mix(border_color*trim_alpha,out_color,smoothAlpha);}out_color*=v_width2_dilute.w;} #endif #endif vec2 cutout_factors=vec2(0.0); #ifdef FEATURE_CUTOUT cutout_factors=get_cutout_factors(gl_FragCoord); #endif #ifdef LIGHTING_3D_MODE out_color=apply_lighting_with_emission_ground(out_color,emissive_strength); #ifdef RENDER_SHADOWS float light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);light=mix(light,1.0,cutout_factors.y);light=u_emissive_in_shadows ? mix(light,1.0,emissive_strength) : light; #ifdef ELEVATED_ROADS out_color.rgb*=mix(v_road_z_offset !=0.0 ? u_ground_shadow_factor : vec3(1.0),vec3(1.0),light); #else out_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light); #endif #endif #endif #ifdef FOG out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos)); #endif out_color*=(alpha*diluted_opacity); #ifdef LINE_BLEND_MULTIPLY glFragColor=vec4(out_color.rgb+(1.0-out_color.a),1.0);HANDLE_WIREFRAME_DEBUG;return; #endif #ifdef INDICATOR_CUTOUT out_color=applyCutout(out_color,v_z_offset); #endif #ifdef FEATURE_CUTOUT out_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x); #endif glFragColor=out_color; #ifdef DUAL_SOURCE_BLENDING glFragColorSrc1=vec4(vec3(0.0),emissive_strength); #else #ifdef USE_MRT1 out_Target1=vec4(emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a); #endif #endif #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(1.0); #endif HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl" #include "_prelude_shadow.vertex.glsl" #include "_prelude_terrain.vertex.glsl" #define EXTRUDE_SCALE 0.015873016 in ivec2 a_pos_normal;in uvec4 a_data; #if defined(ELEVATED) || defined(ELEVATED_ROADS) || defined(VARIABLE_LINE_WIDTH) in vec3 a_z_offset_width; #endif #ifdef ELEVATION_GROUND_SCALE in float a_elevation_ground_scale; #endif #if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET) || defined(RENDER_LINE_CURVE) in highp vec3 a_packed; #endif #ifdef RENDER_LINE_DASH in float a_linesofar; #endif uniform mat4 u_matrix;uniform mat2 u_pixels_to_tile_units;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;uniform float u_width_scale;uniform highp float u_floor_width_scale; #ifdef RENDER_LINE_CURVE uniform mat3 u_curve_points_x;uniform mat3 u_curve_points_y;uniform mat3 u_curve_points_z;uniform float u_curve_point_count; #endif #ifdef ELEVATED uniform lowp float u_zbias_factor;uniform lowp float u_tile_to_meter;float sample_elevation(vec2 apos) { #ifdef ELEVATION_REFERENCE_SEA return 0.0; #else return elevation(apos); #endif } #endif out vec2 v_normal;out vec4 v_width2_dilute;out float v_gamma_scale;out highp vec3 v_uv; #ifdef ELEVATED_ROADS out highp float v_road_z_offset; #endif #ifdef VARIABLE_LINE_WIDTH out float stub_side; #endif #ifdef RENDER_LINE_DASH uniform vec2 u_texsize;uniform float u_tile_units_to_pixels;out vec2 v_tex; #endif #ifdef RENDER_LINE_GRADIENT uniform float u_image_height; #endif #ifdef INDICATOR_CUTOUT out highp float v_z_offset; #endif #ifdef RENDER_SHADOWS uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth; #endif #pragma mapbox: define highp vec4 color #pragma mapbox: define lowp float floorwidth #pragma mapbox: define mediump uvec4 dash #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity #pragma mapbox: define mediump float gapwidth #pragma mapbox: define lowp float offset #pragma mapbox: define mediump float width #pragma mapbox: define mediump float side_z_offset #pragma mapbox: define lowp float border_width #pragma mapbox: define lowp vec4 border_color #pragma mapbox: define lowp float emissive_strength #ifdef RENDER_LINE_CURVE vec3 getCurvePoint(int index) {int row=index/3;int col=index-row*3;float x=u_curve_points_x[row][col];float y=u_curve_points_y[row][col];float z=u_curve_points_z[row][col];return vec3(x,y,z);}vec3 catmullRom(vec3 p0,vec3 p1,vec3 p2,vec3 p3,float t) {float t2=t*t;float t3=t2*t;return 0.5*( 2.0*p1+(-p0+p2)*t+(2.0*p0-5.0*p1+4.0*p2-p3)*t2+(-p0+3.0*p1-3.0*p2+p3)*t3 );}vec2 catmullRomTangent(vec2 p0,vec2 p1,vec2 p2,vec2 p3,float t) {float t2=t*t;return 0.5*( (-p0+p2)+(2.0*p0-5.0*p1+4.0*p2-p3)*2.0*t+(-p0+3.0*p1-3.0*p2+p3)*3.0*t2 );}struct CurveResult {vec3 point;vec2 tangent;};CurveResult calculateCurve(float line_progress) {float curve_progress=line_progress*(u_curve_point_count-1.0);float curve_progress_local=fract(curve_progress);float curve_segment=floor(curve_progress);int seg=int(curve_segment);vec3 p1=getCurvePoint(seg);vec3 p2=getCurvePoint(seg+1);float is_first_seg=step(curve_segment,0.5);vec3 p0_extrapolated=p1-(p2-p1);vec3 p0_fetched=getCurvePoint(max(seg-1,0));vec3 p0=mix(p0_fetched,p0_extrapolated,is_first_seg);int last_seg=int(u_curve_point_count)-2;float is_last_seg=step(float(last_seg)-0.5,curve_segment);vec3 p3_extrapolated=p2+(p2-p1);vec3 p3_fetched=getCurvePoint(min(seg+2,int(u_curve_point_count)-1));vec3 p3=mix(p3_fetched,p3_extrapolated,is_last_seg);vec3 point=catmullRom(p0,p1,p2,p3,curve_progress_local);vec2 tangent=catmullRomTangent(p0.xy,p1.xy,p2.xy,p3.xy,curve_progress_local)*(u_curve_point_count-1.0);CurveResult result;result.point=point;result.tangent=tangent;return result;} #endif void main() { #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize lowp float floorwidth #pragma mapbox: initialize mediump uvec4 dash #pragma mapbox: initialize lowp float blur #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize mediump float gapwidth #pragma mapbox: initialize lowp float offset #pragma mapbox: initialize mediump float width #pragma mapbox: initialize mediump float side_z_offset #pragma mapbox: initialize lowp float border_width #pragma mapbox: initialize lowp vec4 border_color #pragma mapbox: initialize lowp float emissive_strength float a_z_offset; #if defined(ELEVATED) || defined(ELEVATED_ROADS) a_z_offset=a_z_offset_width.x; #endif highp float line_progress=0.0; #if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET) || defined(RENDER_LINE_CURVE) line_progress=a_packed[2]; #endif float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=vec2(a_data.xy)-128.0;float a_direction=float(a_data.z & 3u)-1.0;vec2 pos_normal=vec2(a_pos_normal);vec2 pos=floor(pos_normal*0.5);mediump vec2 normal=pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;offset=-1.0*offset*u_width_scale;bool left=normal.y==1.0; #ifdef RENDER_LINE_CURVE CurveResult curve=calculateCurve(line_progress);pos=curve.point.xy*8192.0;a_extrude=length(a_extrude)*normalize(curve.tangent);a_extrude=left ? vec2(-a_extrude.y,a_extrude.x) : vec2(a_extrude.y,-a_extrude.x);a_z_offset+=curve.point.z; #endif gapwidth=gapwidth/2.0;float halfwidth;float dilute_scale=1.0;float dilute_border_scale=1.0; #ifdef VARIABLE_LINE_WIDTH float left_width=a_z_offset_width.y;float right_width=a_z_offset_width.z;halfwidth=(u_width_scale*(left ? left_width : right_width))/2.0;if (side_z_offset !=0.0) {float left_f=step(1.0,normal.y);float is_negative=step(side_z_offset,0.0);float apply=mix(1.0-left_f,left_f,is_negative);a_extrude*=apply;a_z_offset+=abs(side_z_offset)*apply;v_normal*=left_f;}offset=border_width > 0.0 ? (left_width+right_width)*u_width_scale*0.5 : offset;halfwidth=border_width > 0.0 ? border_width*u_width_scale*0.5 : halfwidth;bool zero_right_width=border_width==0.0 && right_width==0.0;stub_side=zero_right_width ?-normal.y : 0.0;v_normal=!left && zero_right_width ? vec2(0.0) : v_normal;ANTIALIASING=!left && zero_right_width ? 0.0 : ANTIALIASING; #else halfwidth=(u_width_scale*width)/2.0; #endif float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*EXTRUDE_SCALE;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*EXTRUDE_SCALE*normal.y*mat2(t,-u,u,t);float hidden=float(opacity==0.0);vec2 extrude=dist*u_pixels_to_tile_units;vec4 projected_extrude=u_matrix*vec4(extrude,0.0,0.0);vec2 projected_extrude_xy=projected_extrude.xy; #ifdef ELEVATED_ROADS v_road_z_offset=a_z_offset;gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,a_z_offset,1.0); #else #ifdef ELEVATED vec2 offsetTile=offset2*u_pixels_to_tile_units;vec2 offset_pos=pos+offsetTile;float ele=0.0;float scaled_z_offset=a_z_offset; #ifdef ELEVATION_GROUND_SCALE scaled_z_offset=a_z_offset*mix(1.0,u_exaggeration,a_elevation_ground_scale); #endif #ifdef CROSS_SLOPE_VERTICAL float top=pos_normal.y-2.0*floor(pos_normal.y*0.5);float line_height=2.0*u_tile_to_meter*outset*top*u_pixels_to_tile_units[1][1]+scaled_z_offset;ele=sample_elevation(offset_pos)+line_height;projected_extrude=vec4(0); #else #ifdef CROSS_SLOPE_HORIZONTAL float ele0=sample_elevation(offset_pos);float ele1=max(sample_elevation(offset_pos+extrude),sample_elevation(offset_pos+extrude/2.0));float ele2=max(sample_elevation(offset_pos-extrude),sample_elevation(offset_pos-extrude/2.0));float ele_max=max(ele0,max(ele1,ele2));ele=ele_max+scaled_z_offset; #else float ele0=sample_elevation(offset_pos);float ele1=max(sample_elevation(offset_pos+extrude),sample_elevation(offset_pos+extrude/2.0));float ele2=max(sample_elevation(offset_pos-extrude),sample_elevation(offset_pos-extrude/2.0));float ele_max=max(ele0,0.5*(ele1+ele2));ele=ele_max-ele0+ele1+scaled_z_offset; #endif #endif gl_Position=u_matrix*vec4(offset_pos,ele,1.0)+projected_extrude;float z=clamp(gl_Position.z/gl_Position.w,0.5,1.0);float zbias=max(0.00005,(pow(z,0.8)-z)*u_zbias_factor*u_exaggeration);gl_Position.z-=(gl_Position.w*zbias);gl_Position=mix(gl_Position,AWAY,hidden); #else gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0); #endif #endif #ifndef ELEVATED #ifndef VARIABLE_LINE_WIDTH #ifndef RENDER_TO_TEXTURE float base_w=gl_Position.w;vec2 screen_width=abs(projected_extrude.xy/base_w*u_units_to_pixels);float max_extrude_component=max(screen_width.x,screen_width.y);if (width >=1.0 && base_w > 0.0 && max_extrude_component > 0.0001) {float min_pixel=1.05;if (max_extrude_component < min_pixel) {vec2 abs_pos=abs(gl_Position.xy);float is_out=max(abs_pos.x,abs_pos.y)/base_w;dilute_scale=mix(max_extrude_component/min_pixel,1.0,smoothstep(2.5,4.5,is_out));projected_extrude/=dilute_scale;}else { #ifdef RENDER_LINE_BORDER float border_ratio=(border_width*u_width_scale+ANTIALIASING)/outset;screen_width*=border_ratio;float max_border_component=max(screen_width.x,screen_width.y);dilute_border_scale=min(1.0,max_border_component/min_pixel); #endif }} #endif #endif #ifdef ELEVATED_ROADS gl_Position=gl_Position+projected_extrude; #else gl_Position=mix(gl_Position+projected_extrude,AWAY,hidden); #endif #endif #ifdef ELEVATED_ROADS #ifdef RENDER_SHADOWS vec3 shd_pos=vec3(pos+(offset2+dist)*u_pixels_to_tile_units,a_z_offset);vec3 shd_pos0=shd_pos;vec3 shd_pos1=shd_pos; #ifdef NORMAL_OFFSET vec3 shd_pos_offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=shd_pos_offset*shadow_normal_offset_multiplier0();shd_pos1+=shd_pos_offset*shadow_normal_offset_multiplier1(); #endif v_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w; #endif #endif #ifndef RENDER_TO_TEXTURE float epsilon=0.0001;float extrude_length_without_perspective=max(length(dist),epsilon);float extrude_length_with_perspective=max(length(projected_extrude_xy/gl_Position.w*u_units_to_pixels),epsilon);v_gamma_scale=mix(extrude_length_without_perspective/extrude_length_with_perspective,1.0,step(0.01,blur)); #else v_gamma_scale=1.0; #endif #if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET) highp float a_uv_x=a_packed[0];float a_split_index=a_packed[1]; #ifdef RENDER_LINE_GRADIENT highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec3(a_uv_x,a_split_index*texel_height-half_texel_height,line_progress); #else v_uv=vec3(a_uv_x,0.0,line_progress); #endif #endif #ifdef RENDER_LINE_DASH vec4 dashf=vec4(dash);float totalLength=dashf.z+dashf.w/65535.0;float scale=totalLength==0.0 ? 0.0 : u_tile_units_to_pixels/totalLength;v_tex=vec2(a_linesofar*scale/(floorwidth*u_floor_width_scale),(-normal.y*dashf.y+dashf.x+0.5)/u_texsize.y); #endif v_width2_dilute=vec4(outset,inset,dilute_scale,dilute_border_scale); #ifdef FOG v_fog_pos=fog_position(pos); #endif #ifdef INDICATOR_CUTOUT v_z_offset=a_z_offset; #endif }`),linePattern:Hn(`#include "_prelude_fog.fragment.glsl" #include "_prelude_lighting.glsl" #include "_prelude_shadow.fragment.glsl" uniform highp float u_device_pixel_ratio;uniform highp float u_width_scale;uniform highp float u_alpha_discard_threshold;uniform highp vec2 u_texsize;uniform highp float u_tile_units_to_pixels;uniform highp vec2 u_trim_offset;uniform highp vec2 u_trim_fade_range;uniform lowp vec4 u_trim_color;uniform sampler2D u_image; #ifdef APPLY_LUT_ON_GPU uniform highp sampler3D u_lutTexture; #endif #ifdef LINE_PATTERN_TRANSITION uniform float u_pattern_transition; #endif in vec2 v_normal;in vec2 v_width2;in highp float v_linesofar;in float v_gamma_scale;in float v_width; #ifdef RENDER_LINE_TRIM_OFFSET in highp vec3 v_uv; #endif #ifdef ELEVATED_ROADS in highp float v_road_z_offset; #endif #ifdef LINE_JOIN_NONE in vec2 v_pattern_data; #endif #ifdef INDICATOR_CUTOUT in highp float v_z_offset; #endif #ifdef RENDER_SHADOWS uniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth; #endif #pragma mapbox: define mediump uvec4 pattern #ifdef LINE_PATTERN_TRANSITION #pragma mapbox: define mediump uvec4 pattern_b #endif #pragma mapbox: define mediump float pixel_ratio #pragma mapbox: define mediump float blur #pragma mapbox: define mediump float opacity #pragma mapbox: define lowp float emissive_strength void main() { #pragma mapbox: initialize mediump uvec4 pattern #ifdef LINE_PATTERN_TRANSITION #pragma mapbox: initialize mediump uvec4 pattern_b #endif #pragma mapbox: initialize mediump float pixel_ratio #pragma mapbox: initialize mediump float blur #pragma mapbox: initialize mediump float opacity #pragma mapbox: initialize lowp float emissive_strength vec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(pattern.zw);vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;highp float pattern_size=display_size.x/u_tile_units_to_pixels;float aspect=display_size.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(u_width_scale*blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);highp float pattern_x=v_linesofar/pattern_size*aspect;highp float x=mod(pattern_x,1.0);highp float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;highp vec2 pos=mix(pattern_tl*texel_size-texel_size,pattern_br*texel_size+texel_size,vec2(x,y));highp vec2 lod_pos=mix(pattern_tl*texel_size-texel_size,pattern_br*texel_size+texel_size,vec2(pattern_x,y));vec4 color=textureLodCustom(u_image,pos,lod_pos); #ifdef APPLY_LUT_ON_GPU color=applyLUT(u_lutTexture,color); #endif #ifdef LINE_PATTERN_TRANSITION vec2 pattern_b_tl=vec2(pattern_b.xy);vec2 pattern_b_br=vec2(pattern_b.zw);highp vec2 pos_b=mix(pattern_b_tl*texel_size-texel_size,pattern_b_br*texel_size+texel_size,vec2(x,y));vec4 color_b=textureLodCustom(u_image,pos_b,lod_pos);color=color*(1.0-u_pattern_transition)+color_b*u_pattern_transition; #endif #ifdef RENDER_LINE_TRIM_OFFSET highp float trim_start=u_trim_offset[0];highp float trim_end=u_trim_offset[1];highp float line_progress=v_uv[2];if (trim_end > trim_start) {highp float start_transition=max(0.0,min(1.0,(line_progress-trim_start)/max(u_trim_fade_range[0],1.0e-9)));highp float end_transition=max(0.0,min(1.0,(trim_end-line_progress)/max(u_trim_fade_range[1],1.0e-9)));highp float transition_factor=min(start_transition,end_transition);color=mix(color,color.a*u_trim_color,transition_factor);} #endif #ifdef LINE_JOIN_NONE highp float pattern_len=pattern_size/aspect;highp float segment_phase=pattern_len-mod(v_linesofar-v_pattern_data.x+pattern_len,pattern_len);highp float visible_start=segment_phase-step(pattern_len*0.5,segment_phase)*pattern_len;highp float visible_end=floor((v_pattern_data.y-segment_phase)/pattern_len)*pattern_len+segment_phase;visible_end+=step(pattern_len*0.5,v_pattern_data.y-visible_end)*pattern_len;if (v_pattern_data.x < visible_start || v_pattern_data.x >=visible_end) {color=vec4(0.0);} #endif #ifdef LIGHTING_3D_MODE color=apply_lighting_with_emission_ground(color,emissive_strength); #ifdef RENDER_SHADOWS float light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth); #ifdef ELEVATED_ROADS color.rgb*=mix(v_road_z_offset !=0.0 ? u_ground_shadow_factor : vec3(1.0),vec3(1.0),light); #else color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light); #endif #endif #endif #ifdef FOG color=fog_dither(fog_apply_premultiplied(color,v_fog_pos)); #endif color*=(alpha*opacity);if (u_alpha_discard_threshold !=0.0) {if (color.a < u_alpha_discard_threshold) {discard;}} #ifdef INDICATOR_CUTOUT color=applyCutout(color,v_z_offset); #endif glFragColor=color; #ifdef DUAL_SOURCE_BLENDING glFragColorSrc1=vec4(vec3(0.0),emissive_strength); #else #ifdef USE_MRT1 out_Target1=vec4(emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a); #endif #endif #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(1.0); #endif HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl" #include "_prelude_shadow.vertex.glsl" #include "_prelude_terrain.vertex.glsl" #define scale 0.015873016 in ivec2 a_pos_normal;in uvec4 a_data; #if defined(ELEVATED) || defined(ELEVATED_ROADS) in vec3 a_z_offset_width; #endif #ifdef ELEVATION_GROUND_SCALE in float a_elevation_ground_scale; #endif #ifdef RENDER_LINE_TRIM_OFFSET in highp vec3 a_packed; #endif in highp float a_linesofar; #ifdef LINE_JOIN_NONE in highp vec3 a_pattern_data;out vec2 v_pattern_data; #endif #ifdef INDICATOR_CUTOUT out highp float v_z_offset; #endif uniform mat4 u_matrix;uniform float u_tile_units_to_pixels;uniform vec2 u_units_to_pixels;uniform mat2 u_pixels_to_tile_units;uniform float u_device_pixel_ratio;uniform float u_width_scale;uniform float u_floor_width_scale; #ifdef ELEVATED uniform lowp float u_zbias_factor;uniform lowp float u_tile_to_meter;float sample_elevation(vec2 apos) { #ifdef ELEVATION_REFERENCE_SEA return 0.0; #else return elevation(apos); #endif } #endif out vec2 v_normal;out vec2 v_width2;out highp float v_linesofar;out float v_gamma_scale;out float v_width; #ifdef RENDER_LINE_TRIM_OFFSET out highp vec3 v_uv; #endif #ifdef ELEVATED_ROADS out highp float v_road_z_offset; #endif #ifdef RENDER_SHADOWS uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth; #endif #pragma mapbox: define mediump float blur #pragma mapbox: define mediump float opacity #pragma mapbox: define mediump float offset #pragma mapbox: define mediump float gapwidth #pragma mapbox: define mediump float width #pragma mapbox: define mediump float floorwidth #pragma mapbox: define mediump uvec4 pattern #ifdef LINE_PATTERN_TRANSITION #pragma mapbox: define mediump uvec4 pattern_b #endif #pragma mapbox: define mediump float pixel_ratio #pragma mapbox: define lowp float emissive_strength void main() { #pragma mapbox: initialize mediump float blur #pragma mapbox: initialize mediump float opacity #pragma mapbox: initialize mediump float offset #pragma mapbox: initialize mediump float gapwidth #pragma mapbox: initialize mediump float width #pragma mapbox: initialize mediump float floorwidth #pragma mapbox: initialize mediump uvec4 pattern #ifdef LINE_PATTERN_TRANSITION #pragma mapbox: initialize mediump uvec4 pattern_b #endif #pragma mapbox: initialize mediump float pixel_ratio #pragma mapbox: initialize lowp float emissive_strength float a_z_offset; #if defined(ELEVATED) || defined(ELEVATED_ROADS) a_z_offset=a_z_offset_width.x; #endif float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=vec2(a_data.xy)-128.0;float a_direction=float(a_data.z & 3u)-1.0;vec2 pos_normal=vec2(a_pos_normal);vec2 pos=floor(pos_normal*0.5);vec2 normal=pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=(u_width_scale*width)/2.0;offset=-1.0*offset*u_width_scale;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);vec2 dist=outset*a_extrude*scale;float u=0.5*a_direction;float t=1.0-abs(u);vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float hidden=float(opacity==0.0);vec2 extrude=dist*u_pixels_to_tile_units;vec4 projected_extrude=u_matrix*vec4(extrude,0.0,0.0);vec2 projected_extrude_xy=projected_extrude.xy; #ifdef ELEVATED_ROADS v_road_z_offset=a_z_offset;gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,a_z_offset,1.0)+projected_extrude; #else #ifdef ELEVATED vec2 offsetTile=offset2*u_pixels_to_tile_units;vec2 offset_pos=pos+offsetTile;float ele=0.0;float scaled_z_offset=a_z_offset; #ifdef ELEVATION_GROUND_SCALE scaled_z_offset=a_z_offset*mix(1.0,u_exaggeration,a_elevation_ground_scale); #endif #ifdef CROSS_SLOPE_VERTICAL float top=pos_normal.y-2.0*floor(pos_normal.y*0.5);float line_height=2.0*u_tile_to_meter*outset*top*u_pixels_to_tile_units[1][1]+scaled_z_offset;ele=sample_elevation(offset_pos)+line_height;projected_extrude=vec4(0); #else #ifdef CROSS_SLOPE_HORIZONTAL float ele0=sample_elevation(offset_pos);float ele1=max(sample_elevation(offset_pos+extrude),sample_elevation(offset_pos+extrude/2.0));float ele2=max(sample_elevation(offset_pos-extrude),sample_elevation(offset_pos-extrude/2.0));float ele_max=max(ele0,max(ele1,ele2));ele=ele_max+scaled_z_offset; #else float ele0=sample_elevation(offset_pos);float ele1=max(sample_elevation(offset_pos+extrude),sample_elevation(offset_pos+extrude/2.0));float ele2=max(sample_elevation(offset_pos-extrude),sample_elevation(offset_pos-extrude/2.0));float ele_max=max(ele0,0.5*(ele1+ele2));ele=ele_max-ele0+ele1+scaled_z_offset; #endif #endif gl_Position=u_matrix*vec4(offset_pos,ele,1.0)+projected_extrude;float z=clamp(gl_Position.z/gl_Position.w,0.5,1.0);float zbias=max(0.00005,(pow(z,0.8)-z)*u_zbias_factor*u_exaggeration);gl_Position.z-=(gl_Position.w*zbias);gl_Position=mix(gl_Position,AWAY,hidden); #else gl_Position=mix(u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude,AWAY,hidden); #endif #endif #ifdef ELEVATED_ROADS #ifdef RENDER_SHADOWS vec3 shd_pos=vec3(pos+(offset2+dist)*u_pixels_to_tile_units,a_z_offset);vec3 shd_pos0=shd_pos;vec3 shd_pos1=shd_pos; #ifdef NORMAL_OFFSET vec3 shd_pos_offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=shd_pos_offset*shadow_normal_offset_multiplier0();shd_pos1+=shd_pos_offset*shadow_normal_offset_multiplier1(); #endif v_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w; #endif #endif #ifndef RENDER_TO_TEXTURE float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude_xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=mix(extrude_length_without_perspective/extrude_length_with_perspective,1.0,step(0.01,blur)); #else v_gamma_scale=1.0; #endif #ifdef RENDER_LINE_TRIM_OFFSET highp float a_uv_x=a_packed[0];highp float line_progress=a_packed[2];v_uv=vec3(a_uv_x,0.0,line_progress); #endif v_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=(floorwidth*u_floor_width_scale); #ifdef LINE_JOIN_NONE v_width=(floorwidth*u_floor_width_scale)+ANTIALIASING;mediump float pixels_to_tile_units=1.0/u_tile_units_to_pixels;mediump float pixel_ratio_inverse=1.0/pixel_ratio;mediump float aspect=v_width/(float(pattern.w-pattern.y)*pixel_ratio_inverse);highp float subt_multiple=float(pattern.z-pattern.x)*pixel_ratio_inverse*pixels_to_tile_units*aspect*32.0;highp float subt=floor(a_pattern_data.z/subt_multiple)*subt_multiple;float offset_sign=(fract(a_pattern_data.x)-0.5)*4.0;float line_progress_offset=offset_sign*v_width*0.5*pixels_to_tile_units;v_linesofar=(a_pattern_data.z-subt)+a_linesofar+line_progress_offset;v_pattern_data=vec2(a_pattern_data.x+line_progress_offset,a_pattern_data.y); #endif #ifdef FOG v_fog_pos=fog_position(pos); #endif #ifdef INDICATOR_CUTOUT v_z_offset=a_z_offset; #endif }`),raster:Hn(`#include "_prelude_fog.fragment.glsl" #include "_prelude_lighting.glsl" #include "_prelude_raster_array.glsl" uniform float u_fade_t;uniform float u_opacity;uniform highp float u_raster_elevation;uniform highp float u_zoom_transition;in vec2 v_pos0;in vec2 v_pos1;in float v_depth; #ifdef PROJECTION_GLOBE_VIEW in float v_split_fade; #endif uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;uniform float u_emissive_strength; #ifndef RASTER_ARRAY uniform highp sampler2D u_image0;uniform sampler2D u_image1; #endif #ifdef RASTER_COLOR uniform sampler2D u_color_ramp;uniform highp vec4 u_colorization_mix;uniform highp float u_colorization_offset;uniform vec2 u_texture_res; #endif void main() {vec4 color0,color1,color;vec2 value; #ifdef RASTER_COLOR #ifdef RASTER_ARRAY #ifdef RASTER_ARRAY_LINEAR value=mix( raTexture2D_image0_linear(v_pos0,u_texture_res,u_colorization_mix,u_colorization_offset),raTexture2D_image1_linear(v_pos1,u_texture_res,u_colorization_mix,u_colorization_offset),u_fade_t ); #else value=mix( raTexture2D_image0_nearest(v_pos0,u_texture_res,u_colorization_mix,u_colorization_offset),raTexture2D_image1_nearest(v_pos1,u_texture_res,u_colorization_mix,u_colorization_offset),u_fade_t ); #endif if (value.y > 0.0) value.x/=value.y; #else color=mix(texture(u_image0,v_pos0),texture(u_image1,v_pos1),u_fade_t);value=vec2(u_colorization_offset+dot(color.rgb,u_colorization_mix.rgb),color.a); #endif color=texture(u_color_ramp,vec2(value.x,0.5));if (color.a > 0.0) color.rgb/=color.a;color.a*=value.y; #else color0=texture(u_image0,v_pos0);color1=texture(u_image1,v_pos1);if (color0.a > 0.0) color0.rgb/=color0.a;if (color1.a > 0.0) color1.rgb/=color1.a;color=mix(color0,color1,u_fade_t); #endif color.a*=u_opacity; #ifdef GLOBE_POLES color.a*=1.0-smoothstep(0.0,0.05,u_zoom_transition); #endif vec3 rgb=color.rgb;rgb=vec3( dot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.0;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);vec3 out_color=mix(u_high_vec,u_low_vec,rgb); #ifdef LIGHTING_3D_MODE out_color=apply_lighting_with_emission_ground(vec4(out_color,1.0),u_emissive_strength).rgb; #endif #ifdef FOG highp float fog_limit_high_meters=1000000.0;highp float fog_limit_low_meters=600000.0;float fog_limit=1.0-smoothstep(fog_limit_low_meters,fog_limit_high_meters,u_raster_elevation);out_color=fog_dither(fog_apply(out_color,v_fog_pos,fog_limit)); #endif glFragColor=vec4(out_color*color.a,color.a); #ifdef PROJECTION_GLOBE_VIEW glFragColor*=mix(1.0,1.0-smoothstep(0.0,0.05,u_zoom_transition),smoothstep(0.8,0.9,v_split_fade)); #endif #ifdef RENDER_CUTOFF glFragColor=glFragColor*cutoff_opacity(u_cutoff_params,v_depth); #endif #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(1.0); #endif #ifdef USE_MRT1 out_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a); #endif HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl" #include "_prelude_terrain.vertex.glsl" uniform mat4 u_matrix;uniform mat4 u_normalize_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform mat3 u_grid_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform vec2 u_perspective_transform;uniform vec2 u_texture_offset;uniform float u_raster_elevation;uniform float u_zoom_transition;uniform vec2 u_merc_center; #ifdef ELEVATED uniform lowp float u_zbias_factor; #endif #define GLOBE_UPSCALE GLOBE_RADIUS/6371008.8 #ifdef GLOBE_POLES in vec3 a_globe_pos;in vec2 a_uv; #else in ivec2 a_pos;in uvec2 a_texture_pos; #endif out vec2 v_pos0;out vec2 v_pos1;out float v_depth; #ifdef PROJECTION_GLOBE_VIEW out float v_split_fade; #endif void main() {vec2 uv; #ifdef GLOBE_POLES vec3 globe_pos=a_globe_pos;uv=a_uv;float ele=u_raster_elevation; #ifdef ELEVATION_REFERENCE_GROUND ele+=elevation(uv*EXTENT); #endif globe_pos+=normalize(globe_pos)*ele*GLOBE_UPSCALE;gl_Position=u_matrix*u_globe_matrix*vec4(globe_pos,1.0); #ifdef FOG v_fog_pos=fog_position((u_normalize_matrix*vec4(a_globe_pos,1.0)).xyz); #endif #else vec4 world_pos; #ifdef PROJECTION_GLOBE_VIEW vec2 texture_pos=vec2(a_texture_pos);uv=texture_pos/8192.0;vec3 decomposed_pos_and_skirt=decomposeToPosAndSkirt(a_pos);vec3 latLng=u_grid_matrix*vec3(decomposed_pos_and_skirt.xy,1.0);float mercatorY=mercatorYfromLat(latLng[0]);float mercatorX=mercatorXfromLng(latLng[1]); float tiles=u_grid_matrix[0][2];if (tiles > 0.0) {float idx=u_grid_matrix[1][2];float idy=u_grid_matrix[2][2];float uvY=mercatorY*tiles-idy;float uvX=mercatorX*tiles-idx;uv=vec2(uvX,uvY);}float ele=u_raster_elevation; #ifdef ELEVATION_REFERENCE_GROUND ele+=elevation(uv*EXTENT)-decomposed_pos_and_skirt.z; #endif vec4 merc_world_pos=vec4(0.0); v_split_fade=0.0;if (u_zoom_transition > 0.0) {vec2 merc_pos=vec2(mercatorX,mercatorY);merc_world_pos=vec4(merc_pos,ele,1.0);merc_world_pos.xy-=u_merc_center;merc_world_pos.x=wrap(merc_world_pos.x,-0.5,0.5);merc_world_pos=u_merc_matrix*merc_world_pos;float opposite_merc_center=mod(u_merc_center.x+0.5,1.0);float dist_from_poles=(abs(mercatorY-0.5)*2.0);float range=0.1;v_split_fade=abs(opposite_merc_center-mercatorX);v_split_fade=clamp(1.0-v_split_fade,0.0,1.0);v_split_fade=max(smoothstep(1.0-range,1.0,dist_from_poles),max(smoothstep(1.0-range,1.0,v_split_fade),smoothstep(1.0-range,1.0,1.0-v_split_fade)));}vec3 globe_pos=latLngToECEF(latLng.xy);globe_pos+=normalize(globe_pos)*ele*GLOBE_UPSCALE;vec4 globe_world_pos=u_globe_matrix*vec4(globe_pos,1.0);world_pos=vec4(mix(globe_world_pos.xyz,merc_world_pos.xyz,u_zoom_transition),1.0); #ifdef FOG v_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz); #endif #else float ele=0.0;vec2 decodedPos=vec2(a_pos); #ifdef ELEVATION_REFERENCE_GROUND vec3 decomposedPosAndSkirt=decomposeToPosAndSkirt(a_pos);float skirt=decomposedPosAndSkirt.z;decodedPos=decomposedPosAndSkirt.xy;uv=decodedPos/8192.0;ele=elevation(decodedPos)-skirt; #else uv=vec2(a_texture_pos)/8192.0; #endif world_pos=vec4(decodedPos,(u_raster_elevation+ele),1.0); #ifdef FOG v_fog_pos=fog_position(decodedPos); #endif #endif float w=1.0+dot(uv*EXTENT,u_perspective_transform);gl_Position=u_matrix*world_pos*w; #endif v_pos0=uv;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;v_pos0=u_texture_offset.x+u_texture_offset.y*v_pos0;v_pos1=u_texture_offset.x+u_texture_offset.y*v_pos1; #ifdef ELEVATED float z=clamp(gl_Position.z/gl_Position.w,0.5,1.0);float zbias=max(0.00005,(pow(z,0.8)-z)*u_zbias_factor);gl_Position.z-=(gl_Position.w*zbias); #endif #ifdef RENDER_CUTOFF v_depth=gl_Position.z; #endif }`),rasterParticle:Hn(`#include "_prelude_fog.fragment.glsl" #include "_prelude_lighting.glsl" uniform float u_fade_t;uniform float u_opacity;uniform highp float u_raster_elevation;in vec2 v_pos0;in vec2 v_pos1;uniform sampler2D u_image0;uniform sampler2D u_image1;void main() {vec4 color0,color1,color;color0=texture(u_image0,v_pos0);color1=texture(u_image1,v_pos1);if (color0.a > 0.0) color0.rgb/=color0.a;if (color1.a > 0.0) color1.rgb/=color1.a;color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 out_color=color.rgb; #ifdef LIGHTING_3D_MODE out_color=apply_lighting_with_emission_ground(vec4(out_color,1.0),1.0).rgb; #endif #ifdef FOG highp float fog_limit_high_meters=1000000.0;highp float fog_limit_low_meters=600000.0;float fog_limit=1.0-smoothstep(fog_limit_low_meters,fog_limit_high_meters,u_raster_elevation);out_color=fog_dither(fog_apply(out_color,v_fog_pos,fog_limit)); #endif glFragColor=vec4(out_color*color.a,color.a); #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(1.0); #endif HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl" uniform mat4 u_matrix;uniform mat4 u_normalize_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform mat3 u_grid_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_raster_elevation;uniform float u_zoom_transition;uniform vec2 u_merc_center; #define GLOBE_UPSCALE GLOBE_RADIUS/6371008.8 in ivec2 a_pos;in uvec2 a_texture_pos;out vec2 v_pos0;out vec2 v_pos1;void main() {float w=1.0;vec2 uv; #ifdef PROJECTION_GLOBE_VIEW vec3 decomposed_pos_and_skirt=decomposeToPosAndSkirt(a_pos);vec3 latLng=u_grid_matrix*vec3(decomposed_pos_and_skirt.xy,1.0);float mercatorY=mercatorYfromLat(latLng[0]);float mercatorX=mercatorXfromLng(latLng[1]);float tiles=u_grid_matrix[0][2];float idx=u_grid_matrix[1][2];float idy=u_grid_matrix[2][2];float uvX=mercatorX*tiles-idx;float uvY=mercatorY*tiles-idy;uv=vec2(uvX,uvY);vec3 globe_pos=latLngToECEF(latLng.xy);globe_pos+=normalize(globe_pos)*u_raster_elevation*GLOBE_UPSCALE;vec4 globe_world_pos=u_globe_matrix*vec4(globe_pos,1.0);vec4 merc_world_pos=vec4(0.0);if (u_zoom_transition > 0.0) {vec2 merc_pos=vec2(mercatorX,mercatorY);merc_world_pos=vec4(merc_pos,u_raster_elevation,1.0);merc_world_pos.xy-=u_merc_center;merc_world_pos.x=wrap(merc_world_pos.x,-0.5,0.5);merc_world_pos=u_merc_matrix*merc_world_pos;}vec4 interpolated_pos=vec4(mix(globe_world_pos.xyz,merc_world_pos.xyz,u_zoom_transition)*w,w);gl_Position=u_matrix*interpolated_pos; #ifdef FOG v_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz); #endif #else uv=vec2(a_texture_pos)/8192.0;gl_Position=u_matrix*vec4(vec2(a_pos)*w,u_raster_elevation*w,w); #ifdef FOG v_fog_pos=fog_position(vec2(a_pos)); #endif #endif v_pos0=uv;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}`),rasterParticleDraw:Hn("uniform sampler2D u_color_ramp;in float v_particle_speed;void main() {glFragColor=texture(u_color_ramp,vec2(v_particle_speed,0.5));}",`#include "_prelude_raster_particle.glsl" in int a_index;uniform sampler2D u_particle_texture;uniform float u_particle_texture_side_len;uniform vec2 u_tile_offset;out float v_particle_speed;void main() {ivec2 pixel_coord=ivec2( mod(float(a_index),u_particle_texture_side_len),float(a_index)/u_particle_texture_side_len);vec4 pixel=texelFetch(u_particle_texture,pixel_coord,0);vec2 pos=unpack_pos_from_rgba(pixel)+u_tile_offset;vec2 tex_coord=fract(pos);vec2 velocity=lookup_velocity(tex_coord);if (velocity==INVALID_VELOCITY) {gl_Position=AWAY;v_particle_speed=0.0;} else {gl_Position=vec4(2.0*pos-1.0,0,1);v_particle_speed=length(velocity);}gl_PointSize=1.0;}`),rasterParticleTexture:Hn("uniform sampler2D u_texture;uniform float u_opacity;in vec2 v_tex_pos;void main() {vec4 color=texture(u_texture,v_tex_pos);glFragColor=vec4(floor(255.0*color*u_opacity)/255.0);}","in ivec2 a_pos;out vec2 v_tex_pos;void main() {vec2 uv=0.5*vec2(a_pos)+vec2(0.5);v_tex_pos=uv;gl_Position=vec4(a_pos,0.0,1.0);}"),rasterParticleUpdate:Hn(`#include "_prelude_raster_particle.glsl" uniform sampler2D u_particle_texture;uniform mediump float u_particle_texture_side_len;uniform mediump float u_speed_factor;uniform highp float u_reset_rate;uniform highp float u_rand_seed;in highp vec2 v_tex_coord;vec2 linearstep(vec2 edge0,vec2 edge1,vec2 x) {return clamp((x-edge0)/(edge1-edge0),vec2(0),vec2(1));}const highp vec3 rand_constants=vec3(12.9898,78.233,4375.85453);highp float rand(const highp vec2 co) {highp float t=dot(rand_constants.xy,co);return fract(sin(t)*(rand_constants.z+t));}void main() {ivec2 pixel_coord=ivec2(v_tex_coord*u_particle_texture_side_len);highp vec4 pixel=texelFetch(u_particle_texture,pixel_coord,0);highp vec2 pos=unpack_pos_from_rgba(pixel);highp vec2 velocity=lookup_velocity(clamp(pos,0.0,1.0));highp vec2 dp=velocity==INVALID_VELOCITY ? vec2(0) : velocity*u_speed_factor;pos=pos+dp;highp vec2 seed=(pos+v_tex_coord)*u_rand_seed;highp vec2 random_pos=vec2(rand(seed+1.3),rand(seed+2.1));highp vec2 persist_rate=pow( linearstep(vec2(-u_particle_pos_offset),vec2(0),pos)*linearstep(vec2(1.0+u_particle_pos_offset),vec2(1),pos),vec2(4) );highp vec2 per_frame_persist=pow(persist_rate,abs(dp)/u_particle_pos_offset);highp float drop_rate=1.0-per_frame_persist.x*per_frame_persist.y;drop_rate=any(greaterThanEqual(abs(pos-0.5),vec2(0.5+u_particle_pos_offset))) ? 1.0 : drop_rate;highp float drop=step(1.0-drop_rate-u_reset_rate,rand(seed));highp vec2 next_pos=mix(pos,random_pos,drop);glFragColor=pack_pos_to_rgba(next_pos);}`,"in ivec2 a_pos;out vec2 v_tex_coord;void main() {v_tex_coord=0.5*vec2(a_pos+ivec2(1));gl_Position=vec4(a_pos,0.0,1.0);}"),symbol:Hn(`#include "_prelude_lighting.glsl" #include "_prelude_shadow.fragment.glsl" #define SDF_PX 8.0 #define SDF 1.0 #define ICON 0.0 uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;uniform bool u_is_halo;uniform lowp float u_scale_factor; #ifdef ICON_TRANSITION uniform float u_icon_transition; #endif #ifdef COLOR_ADJUSTMENT uniform mat4 u_color_adj_mat; #endif #ifdef INDICATOR_CUTOUT in highp float v_z_offset; #else #ifdef RENDER_SHADOWS in highp float v_z_offset; #endif #endif in vec2 v_tex_a; #ifdef ICON_TRANSITION in vec2 v_tex_b; #endif in float v_draw_halo;in vec3 v_gamma_scale_size_fade_opacity; #ifdef RENDER_TEXT_AND_SYMBOL in float is_sdf;in vec2 v_tex_a_icon; #endif #ifdef RENDER_SHADOWS uniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth; #endif #ifdef APPLY_LUT_ON_GPU uniform highp sampler3D u_lutTexture; #endif #ifdef USE_PAINT_PROPERTIES_UBO in lowp float v_opacity; #ifdef RENDER_SDF in lowp vec4 v_fill_np_color;in lowp vec4 v_halo_np_color;in lowp float v_halo_width;in lowp float v_halo_blur; #endif #ifdef LIGHTING_3D_MODE in lowp float v_emissive_strength; #endif #else #pragma mapbox: define highp vec4 fill_color #pragma mapbox: define highp vec4 halo_color #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp float halo_width #pragma mapbox: define lowp float halo_blur #pragma mapbox: define lowp float emissive_strength #endif void main() { #ifdef USE_PAINT_PROPERTIES_UBO lowp float opacity=v_opacity;lowp vec4 fill_color=vec4(0.0);lowp vec4 halo_color=vec4(0.0);lowp float halo_width=0.0;lowp float halo_blur=0.0; #ifdef RENDER_SDF fill_color=vec4(v_fill_np_color.rgb*v_fill_np_color.a,v_fill_np_color.a);halo_color=vec4(v_halo_np_color.rgb*v_halo_np_color.a,v_halo_np_color.a);halo_width=v_halo_width;halo_blur=v_halo_blur; #endif lowp float emissive_strength=0.0; #ifdef LIGHTING_3D_MODE emissive_strength=v_emissive_strength; #endif #else #pragma mapbox: initialize highp vec4 fill_color #pragma mapbox: initialize highp vec4 halo_color #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize lowp float halo_width #pragma mapbox: initialize lowp float halo_blur #pragma mapbox: initialize lowp float emissive_strength #endif vec4 out_color;float fade_opacity=v_gamma_scale_size_fade_opacity[2]; #ifdef RENDER_TEXT_AND_SYMBOL if (is_sdf==ICON) {vec2 tex_icon=v_tex_a_icon;lowp float alpha=opacity*fade_opacity;glFragColor=texture(u_texture_icon,tex_icon)*alpha; #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(1.0); #endif return;} #endif vec2 cutout_factors=vec2(0.0); #ifdef FEATURE_CUTOUT cutout_factors=get_cutout_factors(gl_FragCoord); #endif #ifdef RENDER_SDF float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_gamma_scale_size_fade_opacity.x;float size=v_gamma_scale_size_fade_opacity.y;float fontScale=u_is_text ? size/24.0 : size;out_color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;bool draw_halo=v_draw_halo > 0.0;if (draw_halo) {out_color=halo_color;gamma=(halo_blur*u_scale_factor*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width*u_scale_factor/fontScale)/SDF_PX;}lowp float dist=texture(u_texture,v_tex_a).r;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);out_color*=alpha; #else #ifdef ICON_TRANSITION vec4 a=texture(u_texture,v_tex_a)*(1.0-u_icon_transition);vec4 b=texture(u_texture,v_tex_b)*u_icon_transition;out_color=(a+b); #else out_color=texture(u_texture,v_tex_a); #endif #ifdef APPLY_LUT_ON_GPU out_color=applyLUT(u_lutTexture,out_color); #endif #ifdef COLOR_ADJUSTMENT out_color=u_color_adj_mat*out_color; #endif #endif out_color*=opacity*fade_opacity; #ifdef LIGHTING_3D_MODE out_color=apply_lighting_with_emission_ground(out_color,emissive_strength); #ifdef RENDER_SHADOWS float light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);light=mix(light,1.0,cutout_factors.y); #ifdef TERRAIN out_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light); #else out_color.rgb*=mix(v_z_offset !=0.0 ? u_ground_shadow_factor : vec3(1.0),vec3(1.0),light); #endif #endif #endif #ifdef INDICATOR_CUTOUT out_color=applyCutout(out_color,v_z_offset); #endif #ifdef FEATURE_CUTOUT out_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x); #endif glFragColor=out_color; #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(1.0); #endif HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_terrain.vertex.glsl" #include "_prelude_shadow.vertex.glsl" #define USING_APPEARANCE 1.0 in ivec4 a_pos_offset;in uvec4 a_tex_size;in ivec4 a_pixeloffset;in vec4 a_projected_pos;in uint a_fade_opacity; #ifdef Z_OFFSET in float a_auto_z_offset; #endif #ifdef PROJECTION_GLOBE_VIEW in ivec4 a_globe_anchor;in vec3 a_globe_normal; #endif #ifdef ICON_TRANSITION in uvec2 a_texb; #endif #ifdef OCCLUSION_QUERIES in float a_occlusion_query_opacity; #endif #ifdef ELEVATED_ROADS in vec3 a_x_axis;in vec3 a_y_axis;uniform float u_normal_scale; #endif #ifdef INDICATOR_CUTOUT out highp float v_z_offset; #else #ifdef RENDER_SHADOWS out highp float v_z_offset; #endif #endif uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_inv_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_elevation_from_sea;uniform bool u_pitch_with_map;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec3 u_up_vector;uniform vec2 u_texsize_icon;uniform bool u_is_halo; #ifdef PROJECTION_GLOBE_VIEW uniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix; #endif out vec2 v_tex_a; #ifdef ICON_TRANSITION out vec2 v_tex_b; #endif out float v_draw_halo;out vec3 v_gamma_scale_size_fade_opacity; #ifdef RENDER_TEXT_AND_SYMBOL out float is_sdf;out vec2 v_tex_a_icon; #endif #ifdef RENDER_SHADOWS uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth; #endif #ifdef USE_PAINT_PROPERTIES_UBO #ifndef MAX_UBO_SIZE_VEC4 #define MAX_UBO_SIZE_VEC4 1024u #endif #define SPP_HEADER_SIZE_VEC4 3u #define DWORDS_PER_VEC4 4u struct SymbolPaintProperties {vec4 fill_np_color;vec4 halo_np_color;float opacity;float halo_width;float halo_blur;float emissive_strength;float occlusion_opacity;float z_offset;vec2 translate;};struct PropertyType {bool isDataDriven;bool isZoomDependent;uint offsetDwords;};struct SymbolPropertyHeader {uint dataDrivenBlockSizeVec4;PropertyType fill_np_color;PropertyType halo_np_color;PropertyType opacity;PropertyType halo_width;PropertyType halo_blur;PropertyType emissive_strength;PropertyType occlusion_opacity;PropertyType z_offset;PropertyType translate;};uniform float u_zoom;uniform lowp vec4 u_spp_fill_np_color;uniform lowp vec4 u_spp_halo_np_color;uniform lowp float u_spp_opacity;uniform lowp float u_spp_halo_width;uniform lowp float u_spp_halo_blur;uniform lowp float u_spp_emissive_strength;uniform lowp float u_spp_occlusion_opacity;uniform lowp float u_spp_z_offset;uniform lowp vec2 u_spp_translate_rotation;in float a_feature_index;layout(std140) uniform SymbolPaintPropertiesHeaderUniform {uvec4 header[SPP_HEADER_SIZE_VEC4];} u_spp_header;layout(std140) uniform SymbolPaintPropertiesUniform {vec4 properties[MAX_UBO_SIZE_VEC4];} u_spp_properties;layout(std140) uniform SymbolPaintPropertiesIndexUniform {uvec4 block_indices[MAX_UBO_SIZE_VEC4];} u_spp_index;out lowp float v_opacity; #ifdef RENDER_SDF out lowp vec4 v_fill_np_color;out lowp vec4 v_halo_np_color;out lowp float v_halo_width;out lowp float v_halo_blur; #endif #ifdef LIGHTING_3D_MODE out lowp float v_emissive_strength; #endif PropertyType getPropertyType(uint propertyIndex,uint dataDrivenMask,uint zoomDependentMask,uint offsetDwords) {PropertyType type;type.isDataDriven=(dataDrivenMask & (1u << propertyIndex)) !=0u;type.isZoomDependent=(zoomDependentMask & (1u << propertyIndex)) !=0u;type.offsetDwords=offsetDwords;return type;}SymbolPropertyHeader readSymbolPropertiesHeader() {SymbolPropertyHeader header;uint dataDrivenMask=u_spp_header.header[0][0];uint zoomDependentMask=u_spp_header.header[0][1];header.dataDrivenBlockSizeVec4=u_spp_header.header[0][2];header.fill_np_color =getPropertyType(0u,dataDrivenMask,zoomDependentMask,u_spp_header.header[0][3]);header.halo_np_color =getPropertyType(1u,dataDrivenMask,zoomDependentMask,u_spp_header.header[1][0]);header.opacity =getPropertyType(2u,dataDrivenMask,zoomDependentMask,u_spp_header.header[1][1]);header.halo_width =getPropertyType(3u,dataDrivenMask,zoomDependentMask,u_spp_header.header[1][2]);header.halo_blur =getPropertyType(4u,dataDrivenMask,zoomDependentMask,u_spp_header.header[1][3]);header.emissive_strength =getPropertyType(5u,dataDrivenMask,zoomDependentMask,u_spp_header.header[2][0]);header.occlusion_opacity =getPropertyType(6u,dataDrivenMask,zoomDependentMask,u_spp_header.header[2][1]);header.z_offset =getPropertyType(7u,dataDrivenMask,zoomDependentMask,u_spp_header.header[2][2]);header.translate =getPropertyType(8u,dataDrivenMask,zoomDependentMask,u_spp_header.header[2][3]);return header;}uint uvec4At(uvec4 v,uint index) {return (index==0u) ? v.x : (index==1u) ? v.y : (index==2u) ? v.z : v.w;}float vec4At(vec4 v,uint index) {return (index==0u) ? v.x : (index==1u) ? v.y : (index==2u) ? v.z : v.w;}vec4 readVec4(uint baseOffsetVec4,uint propertyOffsetDwords) {return u_spp_properties.properties[baseOffsetVec4+propertyOffsetDwords/DWORDS_PER_VEC4];}float readFloat(vec4 slot,uint propertyOffsetDwords) {return slot[propertyOffsetDwords % DWORDS_PER_VEC4];}uint readUint(uvec4 slot,uint offset) {return slot[offset % DWORDS_PER_VEC4];}vec2 readVec2(vec4 slot,uint propertyOffsetDwords) {float x=vec4At(slot,propertyOffsetDwords % DWORDS_PER_VEC4);float y=vec4At(slot,propertyOffsetDwords % DWORDS_PER_VEC4+1u);return vec2(x,y);}uint getDataDrivenBlockOffsetVec4(uint dataDrivenBlockSizeVec4) {uint featureIndex=uint(a_feature_index);uvec4 slot=u_spp_index.block_indices[featureIndex/DWORDS_PER_VEC4];uint blockIndex=uvec4At(slot,featureIndex % DWORDS_PER_VEC4);return blockIndex*dataDrivenBlockSizeVec4;}vec4 readColorProperty(PropertyType propertyType,uint dataDrivenBlockSizeVec4) {uint blockOffsetVec4=getDataDrivenBlockOffsetVec4(dataDrivenBlockSizeVec4);vec4 color=readVec4(blockOffsetVec4,propertyType.offsetDwords);if (propertyType.isZoomDependent) {color=unpack_mix_color(color,u_zoom);} else {vec2 packedColor=readVec2(color,propertyType.offsetDwords);color=decode_color(packedColor);}return color;}vec2 readVec2Property(PropertyType propertyType,uint dataDrivenBlockSizeVec4) {uint blockOffsetVec4=getDataDrivenBlockOffsetVec4(dataDrivenBlockSizeVec4);vec4 slot=readVec4(blockOffsetVec4,propertyType.offsetDwords);if (propertyType.isZoomDependent) {vec2 minVal=slot.xy;vec2 maxVal=slot.zw;return mix(minVal,maxVal,u_zoom);}return readVec2(slot,propertyType.offsetDwords);}float readFloatProperty(PropertyType propertyType,uint dataDrivenBlockSizeVec4) {uint blockOffsetVec4=getDataDrivenBlockOffsetVec4(dataDrivenBlockSizeVec4);vec4 slot=readVec4(blockOffsetVec4,propertyType.offsetDwords);float value;if (propertyType.isZoomDependent) {vec2 packedValues=readVec2(slot,propertyType.offsetDwords);value=unpack_mix_vec2(packedValues,u_zoom);} else {value=readFloat(slot,propertyType.offsetDwords);}return value;}SymbolPaintProperties readSymbolPaintProperties() {SymbolPropertyHeader header=readSymbolPropertiesHeader();uint sizeVec4=header.dataDrivenBlockSizeVec4;SymbolPaintProperties props;props.fill_np_color =header.fill_np_color.isDataDriven ? readColorProperty(header.fill_np_color,sizeVec4) : u_spp_fill_np_color;props.halo_np_color =header.halo_np_color.isDataDriven ? readColorProperty(header.halo_np_color,sizeVec4) : u_spp_halo_np_color;props.opacity =header.opacity.isDataDriven ? readFloatProperty(header.opacity,sizeVec4) : u_spp_opacity;props.halo_width =header.halo_width.isDataDriven ? readFloatProperty(header.halo_width,sizeVec4) : u_spp_halo_width;props.halo_blur =header.halo_blur.isDataDriven ? readFloatProperty(header.halo_blur,sizeVec4) : u_spp_halo_blur;props.emissive_strength =header.emissive_strength.isDataDriven ? readFloatProperty(header.emissive_strength,sizeVec4) : u_spp_emissive_strength;props.occlusion_opacity =header.occlusion_opacity.isDataDriven ? readFloatProperty(header.occlusion_opacity,sizeVec4) : u_spp_occlusion_opacity;props.z_offset =header.z_offset.isDataDriven ? readFloatProperty(header.z_offset,sizeVec4) : u_spp_z_offset;props.translate =header.translate.isDataDriven ? readVec2Property(header.translate,sizeVec4) : vec2(0.0);return props;} #else #pragma mapbox: define highp vec4 fill_color #pragma mapbox: define highp vec4 halo_color #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp float halo_width #pragma mapbox: define lowp float halo_blur #pragma mapbox: define lowp float emissive_strength #pragma mapbox: define lowp float occlusion_opacity #pragma mapbox: define lowp float z_offset #endif vec2 unpack_opacity(uint packedOpacity) {return vec2(float(packedOpacity/2u)/127.0,float(packedOpacity & 1u));}void main() { #ifdef USE_PAINT_PROPERTIES_UBO SymbolPaintProperties paint_properties=readSymbolPaintProperties();lowp float opacity=paint_properties.opacity;v_opacity=opacity; #ifdef RENDER_SDF v_fill_np_color=paint_properties.fill_np_color;v_halo_np_color=paint_properties.halo_np_color;v_halo_width=paint_properties.halo_width;v_halo_blur=paint_properties.halo_blur; #endif #ifdef LIGHTING_3D_MODE v_emissive_strength=paint_properties.emissive_strength; #endif lowp float occlusion_opacity=paint_properties.occlusion_opacity;lowp float z_offset=paint_properties.z_offset; #else #pragma mapbox: initialize highp vec4 fill_color #pragma mapbox: initialize highp vec4 halo_color #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize lowp float halo_width #pragma mapbox: initialize lowp float halo_blur #pragma mapbox: initialize lowp float emissive_strength #pragma mapbox: initialize lowp float occlusion_opacity #pragma mapbox: initialize lowp float z_offset #endif vec2 a_pos=vec2(a_pos_offset.xy);vec2 a_offset=vec2(a_pos_offset.zw);vec2 a_tex=vec2(a_tex_size.xy);vec2 a_size=vec2(a_tex_size.zw);float a_size_min=floor(a_size[0]*0.5);float a_size_max= floor(a_size[1]*0.5);float a_apperance=a_size[1]-2.0*a_size_max;vec2 a_pxoffset=vec2(a_pixeloffset.xy);vec2 a_min_font_scale=vec2(a_pixeloffset.zw)/256.0;highp float segment_angle=-a_projected_pos[3];float size;if (a_apperance==USING_APPEARANCE) {size=a_size_max/128.0;} else if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size_max,u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 tile_anchor=a_pos;float e=u_elevation_from_sea ? z_offset : z_offset+elevation(tile_anchor); #ifdef Z_OFFSET e+=a_auto_z_offset; #endif vec3 h=elevationVector(tile_anchor)*e;float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;vec3 world_pos_globe; #ifdef PROJECTION_GLOBE_VIEW mercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);world_pos_globe=vec3(a_globe_anchor)+h;world_pos=mix_globe_mercator(world_pos_globe,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0; #else world_pos=vec3(tile_anchor,0)+h;globe_occlusion_fade=1.0; #endif vec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ? camera_to_anchor_distance/u_camera_to_center_distance : u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp( 0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float font_scale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetprojected_point;vec2 a; #ifdef PROJECTION_GLOBE_VIEW vec3 displacement=vec3(a_globe_normal.z,0,-a_globe_normal.x);offsetprojected_point=u_matrix*vec4(vec3(a_globe_anchor)+displacement,1);vec4 projected_point_globe=u_matrix*vec4(world_pos_globe,1);a=projected_point_globe.xy/projected_point_globe.w; #else offsetprojected_point=u_matrix*vec4(tile_anchor+vec2(1,0),0,1);a=projected_point.xy/projected_point.w; #endif vec2 b=offsetprojected_point.xy/offsetprojected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec4 projected_pos; #ifdef PROJECTION_GLOBE_VIEW #ifdef PROJECTED_POS_ON_VIEWPORT projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xyz+h,1.0); #else vec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz,mercator_pos,u_zoom_transition)+h;projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0); #endif #else projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0); #endif highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*max(a_min_font_scale,font_scale)+a_pxoffset/16.0); #ifdef TERRAIN #ifdef PITCH_WITH_MAP_TERRAIN vec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy); #endif #endif #ifdef Z_OFFSET z+=u_pitch_with_map ? a_auto_z_offset+z_offset : 0.0; #else z+=u_pitch_with_map ? z_offset : 0.0; #endif float occlusion_fade=globe_occlusion_fade;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float out_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change)); #ifdef DEPTH_OCCLUSION float depth_occlusion=occlusionFadeMultiSample(projected_point);float depth_occlusion_multplier=mix(occlusion_opacity,1.0,depth_occlusion);out_fade_opacity*=depth_occlusion_multplier; #endif #ifdef OCCLUSION_QUERIES float occludedFadeMultiplier=mix(occlusion_opacity,1.0,a_occlusion_query_opacity);out_fade_opacity*=occludedFadeMultiplier; #endif #ifdef Z_TEST_OCCLUSION out_fade_opacity*=occlusion_opacity; #endif float alpha=opacity*out_fade_opacity;float hidden=float(alpha==0.0 || projected_point.w <=0.0 || occlusion_fade==0.0);vec3 pos; #ifdef PROJECTION_GLOBE_VIEW vec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);pos=projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y; #else #ifdef ELEVATED_ROADS vec3 xAxis=vec3(a_x_axis.xy,a_x_axis.z*u_normal_scale);vec3 yAxis=vec3(a_y_axis.xy,a_y_axis.z*u_normal_scale);pos=projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y; #else pos=vec3(projected_pos.xy/projected_pos.w+offset,z); #endif #endif gl_Position=mix(u_coord_matrix*vec4(pos,1.0),AWAY,hidden); #ifdef USE_PAINT_PROPERTIES_UBO {vec2 tr=paint_properties.translate;vec2 rotated_tr=vec2( u_spp_translate_rotation.x*tr.x-u_spp_translate_rotation.y*tr.y,u_spp_translate_rotation.y*tr.x+u_spp_translate_rotation.x*tr.y );gl_Position.xy+=(u_coord_matrix*vec4(rotated_tr,0.0,0.0)).xy;} #endif float gamma_scale=gl_Position.w;v_draw_halo=(u_is_halo && float(gl_InstanceID)==0.0) ? 1.0 : 0.0;v_gamma_scale_size_fade_opacity=vec3(gamma_scale,size,out_fade_opacity);v_tex_a=a_tex/u_texsize; #ifdef RENDER_TEXT_AND_SYMBOL is_sdf=a_size[0]-2.0*a_size_min;v_tex_a_icon=a_tex/u_texsize_icon; #endif #ifdef ICON_TRANSITION v_tex_b=vec2(a_texb)/u_texsize; #endif #ifdef RENDER_SHADOWS vec4 shd_pos=u_inv_matrix*vec4(pos,1.0);vec3 shd_pos0=shd_pos.xyz;vec3 shd_pos1=shd_pos.xyz; #ifdef NORMAL_OFFSET vec3 shd_pos_offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=shd_pos_offset*shadow_normal_offset_multiplier0();shd_pos1+=shd_pos_offset*shadow_normal_offset_multiplier1(); #endif v_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w; #endif #ifdef INDICATOR_CUTOUT v_z_offset=e; #else #ifdef RENDER_SHADOWS v_z_offset=e; #endif #endif }`),terrainRaster:Hn(`#include "_prelude_fog.fragment.glsl" #include "_prelude_shadow.fragment.glsl" #include "_prelude_lighting.glsl" uniform sampler2D u_image0; #ifdef LIGHTING_3D_ALPHA_EMISSIVENESS uniform sampler2D u_image1;uniform float u_emissive_texture_available; #endif in vec2 v_pos0; #ifdef FOG in float v_fog_opacity; #endif #ifdef RENDER_SHADOWS in vec4 v_pos_light_view_0;in vec4 v_pos_light_view_1; #endif uniform vec3 u_ground_shadow_factor;void main() {vec4 image_color=texture(u_image0,v_pos0);vec4 color; #ifdef LIGHTING_3D_MODE const vec3 normal=vec3(0.0,0.0,1.0); #ifdef RENDER_SHADOWS float cutoffOpacity=1.0; #ifdef RENDER_CUTOFF cutoffOpacity=cutoff_opacity(u_cutoff_params,1.0/gl_FragCoord.w); #endif #ifdef LIGHTING_3D_ALPHA_EMISSIVENESS float emissive_strength=u_emissive_texture_available > 0.5 ? texture(u_image1,v_pos0).r : image_color.a;vec3 unlit_base=image_color.rgb*(1.0-emissive_strength);vec3 emissive_base=image_color.rgb*emissive_strength;float ndotl=u_shadow_direction.z;float occlusion=ndotl < 0.0 ? 1.0 : shadow_occlusion(v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w,0.0);ndotl=max(0.0,ndotl);vec3 lit=apply_lighting(unlit_base,normal,mix(1.0,(1.0-(u_shadow_intensity*occlusion))*ndotl,cutoffOpacity));vec3 emissive=compute_emissive_draped(emissive_base,1.0-u_shadow_intensity,occlusion,u_ground_shadow_factor);color.rgb=lit+emissive;color.a=1.0; #else float lighting_factor=shadowed_light_factor_normal_unbiased(normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);color=apply_lighting(image_color,normal,mix(1.0,lighting_factor,cutoffOpacity)); #endif #else float lighting_factor=u_lighting_directional_dir.z;color=apply_lighting(image_color,normal,lighting_factor); #ifdef LIGHTING_3D_ALPHA_EMISSIVENESS float emissive_strength=u_emissive_texture_available > 0.5 ? texture(u_image1,v_pos0).r : image_color.a;color.rgb=mix(color.rgb,image_color.rgb,emissive_strength);color.a=1.0; #endif #endif #else color=image_color; #endif #ifdef FOG #ifdef ZERO_EXAGGERATION color=fog_dither(fog_apply_premultiplied(color,v_fog_pos)); #else color=fog_dither(fog_apply_from_vert(color,v_fog_opacity)); #endif #endif glFragColor=color; #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(1.0); #endif HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl" #include "_prelude_terrain.vertex.glsl" uniform mat4 u_matrix;uniform float u_skirt_height;in ivec2 a_pos;out vec2 v_pos0; #ifdef FOG out float v_fog_opacity; #endif #ifdef RENDER_SHADOWS uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out vec4 v_pos_light_view_0;out vec4 v_pos_light_view_1; #endif void main() {vec3 decomposedPosAndSkirt=decomposeToPosAndSkirt(a_pos);float skirt=decomposedPosAndSkirt.z;vec2 decodedPos=decomposedPosAndSkirt.xy;float elevation=elevation(decodedPos)-skirt*u_skirt_height;v_pos0=decodedPos/8192.0;gl_Position=u_matrix*vec4(decodedPos,elevation,1.0); #ifdef FOG #ifdef ZERO_EXAGGERATION v_fog_pos=fog_position(decodedPos); #else v_fog_opacity=fog(fog_position(vec3(decodedPos,elevation))); #endif #endif #ifdef RENDER_SHADOWS vec3 pos=vec3(decodedPos,elevation);v_pos_light_view_0=u_light_matrix_0*vec4(pos,1.);v_pos_light_view_1=u_light_matrix_1*vec4(pos,1.); #endif }`),terrainDepth:Hn("precision highp float;in float v_depth;void main() {glFragColor=pack_depth(v_depth);}",`#include "_prelude_terrain.vertex.glsl" uniform mat4 u_matrix;in ivec2 a_pos;out float v_depth;void main() {float elevation=elevation(vec2(a_pos));gl_Position=u_matrix*vec4(a_pos,elevation,1.0);v_depth=gl_Position.z/gl_Position.w;}`),skybox:Hn(`#include "_prelude_fog.fragment.glsl" in lowp vec3 v_uv;uniform lowp samplerCube u_cubemap;uniform lowp float u_opacity;uniform highp float u_temporal_offset;uniform highp vec3 u_sun_direction;float sun_disk(highp vec3 ray_direction,highp vec3 sun_direction) {highp float cos_angle=dot(normalize(ray_direction),sun_direction);const highp float cos_sun_angular_diameter=0.99996192306;const highp float smoothstep_delta=1e-5;return smoothstep( cos_sun_angular_diameter-smoothstep_delta,cos_sun_angular_diameter+smoothstep_delta,cos_angle);}float map(float value,float start,float end,float new_start,float new_end) {return ((value-start)*(new_end-new_start))/(end-start)+new_start;}void main() {vec3 uv=v_uv;const float y_bias=0.015;uv.y+=y_bias;uv.y=pow(abs(uv.y),1.0/5.0);uv.y=map(uv.y,0.0,1.0,-1.0,1.0);vec3 sky_color=texture(u_cubemap,uv).rgb; #ifdef FOG sky_color=fog_apply_sky_gradient(v_uv.xzy,sky_color); #endif sky_color+=0.1*sun_disk(v_uv,u_sun_direction);glFragColor=vec4(sky_color*u_opacity,u_opacity); #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(1.0); #endif }`,z0),skyboxGradient:Hn(`#include "_prelude_fog.fragment.glsl" in highp vec3 v_uv;uniform lowp sampler2D u_color_ramp;uniform highp vec3 u_center_direction;uniform lowp float u_radius;uniform lowp float u_opacity;uniform highp float u_temporal_offset;void main() {float progress=acos(dot(normalize(v_uv),u_center_direction))/u_radius;vec4 color=texture(u_color_ramp,vec2(progress,0.5)); #ifdef FOG color.rgb=fog_apply_sky_gradient(v_uv.xzy,color.rgb/color.a)*color.a; #endif color*=u_opacity;glFragColor=color; #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(1.0); #endif }`,z0),skyboxCapture:Hn(` in highp vec3 v_position;uniform highp float u_sun_intensity;uniform highp float u_luminance;uniform lowp vec3 u_sun_direction;uniform highp vec4 u_color_tint_r;uniform highp vec4 u_color_tint_m;precision highp float; #define BETA_R vec3(5.5e-6,13.0e-6,22.4e-6) #define BETA_M vec3(21e-6,21e-6,21e-6) #define MIE_G 0.76 #define DENSITY_HEIGHT_SCALE_R 8000.0 #define DENSITY_HEIGHT_SCALE_M 1200.0 #define PLANET_RADIUS 6360e3 #define ATMOSPHERE_RADIUS 6420e3 #define SAMPLE_STEPS 10 #define DENSITY_STEPS 4 float ray_sphere_exit(vec3 orig,vec3 dir,float radius) {float a=dot(dir,dir);float b=2.0*dot(dir,orig);float c=dot(orig,orig)-radius*radius;float d=sqrt(b*b-4.0*a*c);return (-b+d)/(2.0*a);}vec3 extinction(vec2 density) {return exp(-vec3(BETA_R*u_color_tint_r.a*density.x+BETA_M*u_color_tint_m.a*density.y));}vec2 local_density(vec3 point) {float height=max(length(point)-PLANET_RADIUS,0.0);float exp_r=exp(-height/DENSITY_HEIGHT_SCALE_R);float exp_m=exp(-height/DENSITY_HEIGHT_SCALE_M);return vec2(exp_r,exp_m);}float phase_ray(float cos_angle) {return (3.0/(16.0*PI))*(1.0+cos_angle*cos_angle);}float phase_mie(float cos_angle) {return (3.0/(8.0*PI))*((1.0-MIE_G*MIE_G)*(1.0+cos_angle*cos_angle))/((2.0+MIE_G*MIE_G)*pow(1.0+MIE_G*MIE_G-2.0*MIE_G*cos_angle,1.5));}vec2 density_to_atmosphere(vec3 point,vec3 light_dir) {float ray_len=ray_sphere_exit(point,light_dir,ATMOSPHERE_RADIUS);float step_len=ray_len/float(DENSITY_STEPS);vec2 density_point_to_atmosphere=vec2(0.0);for (int i=0; i < DENSITY_STEPS;++i) {vec3 point_on_ray=point+light_dir*((float(i)+0.5)*step_len);density_point_to_atmosphere+=local_density(point_on_ray)*step_len;;}return density_point_to_atmosphere;}vec3 atmosphere(vec3 ray_dir,vec3 sun_direction,float sun_intensity) {vec2 density_orig_to_point=vec2(0.0);vec3 scatter_r=vec3(0.0);vec3 scatter_m=vec3(0.0);vec3 origin=vec3(0.0,PLANET_RADIUS,0.0);float ray_len=ray_sphere_exit(origin,ray_dir,ATMOSPHERE_RADIUS);float step_len=ray_len/float(SAMPLE_STEPS);for (int i=0; i < SAMPLE_STEPS;++i) {vec3 point_on_ray=origin+ray_dir*((float(i)+0.5)*step_len);vec2 density=local_density(point_on_ray)*step_len;density_orig_to_point+=density;vec2 density_point_to_atmosphere=density_to_atmosphere(point_on_ray,sun_direction);vec2 density_orig_to_atmosphere=density_orig_to_point+density_point_to_atmosphere;vec3 extinction=extinction(density_orig_to_atmosphere);scatter_r+=density.x*extinction;scatter_m+=density.y*extinction;}float cos_angle=dot(ray_dir,sun_direction);float phase_r=phase_ray(cos_angle);float phase_m=phase_mie(cos_angle);vec3 beta_r=BETA_R*u_color_tint_r.rgb*u_color_tint_r.a;vec3 beta_m=BETA_M*u_color_tint_m.rgb*u_color_tint_m.a;return (scatter_r*phase_r*beta_r+scatter_m*phase_m*beta_m)*sun_intensity;}const float A=0.15;const float B=0.50;const float C=0.10;const float D=0.20;const float E=0.02;const float F=0.30;vec3 uncharted2_tonemap(vec3 x) {return ((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;}void main() {vec3 ray_direction=v_position;ray_direction.y=pow(ray_direction.y,5.0);const float y_bias=0.015;ray_direction.y+=y_bias;vec3 color=atmosphere(normalize(ray_direction),u_sun_direction,u_sun_intensity);float white_scale=1.0748724675633854;color=uncharted2_tonemap((log2(2.0/pow(u_luminance,4.0)))*color)*white_scale;glFragColor=vec4(color,1.0);}`,"in highp vec3 a_pos_3f;uniform mat3 u_matrix_3f;out highp vec3 v_position;float map(float value,float start,float end,float new_start,float new_end) {return ((value-start)*(new_end-new_start))/(end-start)+new_start;}void main() {vec4 pos=vec4(u_matrix_3f*a_pos_3f,1.0);v_position=pos.xyz;v_position.y*=-1.0;v_position.y=map(v_position.y,-1.0,1.0,0.0,1.0);gl_Position=vec4(a_pos_3f.xy,0.0,1.0);}"),globeRaster:Hn(`#include "_prelude_fog.fragment.glsl" #include "_prelude_lighting.glsl" uniform sampler2D u_image0; #ifdef LIGHTING_3D_ALPHA_EMISSIVENESS uniform sampler2D u_image1;uniform float u_emissive_texture_available; #endif uniform float u_far_z_cutoff;in vec2 v_pos0; #ifndef FOG uniform highp vec3 u_frustum_tl;uniform highp vec3 u_frustum_tr;uniform highp vec3 u_frustum_br;uniform highp vec3 u_frustum_bl;uniform highp vec3 u_globe_pos;uniform highp float u_globe_radius;uniform vec2 u_viewport; #endif void main() {vec4 color; #ifdef CUSTOM_ANTIALIASING highp vec2 uv=gl_FragCoord.xy/u_viewport; #ifdef FLIP_Y uv.y=1.0-uv.y; #endif highp vec3 ray_dir=mix( mix(u_frustum_tl,u_frustum_tr,uv.x),mix(u_frustum_bl,u_frustum_br,uv.x),1.0-uv.y);highp vec3 dir=normalize(ray_dir);highp vec3 closest_point=dot(u_globe_pos,dir)*dir;highp float norm_dist_from_center=1.0-length(closest_point-u_globe_pos)/u_globe_radius;const float antialias_pixel=2.0;highp float antialias_factor=antialias_pixel*fwidth(norm_dist_from_center);highp float antialias=smoothstep(0.0,antialias_factor,norm_dist_from_center);vec4 raster=texture(u_image0,v_pos0); #ifdef LIGHTING_3D_MODE #ifdef LIGHTING_3D_ALPHA_EMISSIVENESS float emissive_strength=u_emissive_texture_available > 0.5 ? texture(u_image1,v_pos0).r : raster.a;raster=apply_lighting_with_emission_ground(raster,emissive_strength);color=vec4(clamp(raster.rgb,vec3(0),vec3(1))*antialias,antialias); #else raster=apply_lighting_ground(raster);color=vec4(raster.rgb*antialias,raster.a*antialias); #endif #else color=vec4(raster.rgb*antialias,raster.a*antialias); #endif #else color=texture(u_image0,v_pos0); #ifdef LIGHTING_3D_MODE #ifdef LIGHTING_3D_ALPHA_EMISSIVENESS float emissive_strength=u_emissive_texture_available > 0.5 ? texture(u_image1,v_pos0).r : color.a;color=apply_lighting_with_emission_ground(color,emissive_strength);color.a=1.0; #else color=apply_lighting_ground(color); #endif #endif #endif #ifdef FOG color=fog_dither(fog_apply_premultiplied(color,v_fog_pos)); #endif color*=1.0-step(u_far_z_cutoff,1.0/gl_FragCoord.w);glFragColor=color; #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(1.0); #endif HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl" #include "_prelude_terrain.vertex.glsl" uniform mat4 u_proj_matrix;uniform mat4 u_normalize_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform float u_zoom_transition;uniform vec2 u_merc_center;uniform mat3 u_grid_matrix;uniform float u_skirt_height; #ifdef GLOBE_POLES in vec3 a_globe_pos;in vec2 a_uv; #else in ivec2 a_pos; #endif out vec2 v_pos0;void main() { #ifdef GLOBE_POLES vec3 globe_pos=a_globe_pos;vec2 uv=a_uv; #else float tiles=u_grid_matrix[0][2];float idx=u_grid_matrix[1][2];float idy=u_grid_matrix[2][2];vec3 decomposed_pos_and_skirt=decomposeToPosAndSkirt(a_pos);vec3 latLng=u_grid_matrix*vec3(decomposed_pos_and_skirt.xy,1.0);float mercatorY=mercatorYfromLat(latLng[0]);float uvY=mercatorY*tiles-idy;float mercatorX=mercatorXfromLng(latLng[1]);float uvX=mercatorX*tiles-idx;vec3 globe_pos=latLngToECEF(latLng.xy);vec2 merc_pos=vec2(mercatorX,mercatorY);vec2 uv=vec2(uvX,uvY); #endif v_pos0=uv;vec2 tile_pos=uv*EXTENT;vec3 globe_derived_up_vector=normalize(globe_pos)*u_tile_up_scale; #ifdef GLOBE_POLES vec3 up_vector=globe_derived_up_vector; #else vec3 up_vector=elevationVector(tile_pos); #endif float height=elevation(tile_pos);globe_pos+=up_vector*height; #ifndef GLOBE_POLES globe_pos-=globe_derived_up_vector*u_skirt_height*decomposed_pos_and_skirt.z; #endif #ifdef GLOBE_POLES vec4 interpolated_pos=u_globe_matrix*vec4(globe_pos,1.0); #else vec4 globe_world_pos=u_globe_matrix*vec4(globe_pos,1.0);vec4 merc_world_pos=vec4(0.0);if (u_zoom_transition > 0.0) {merc_world_pos=vec4(merc_pos,height-u_skirt_height*decomposed_pos_and_skirt.z,1.0);merc_world_pos.xy-=u_merc_center;merc_world_pos.x=wrap(merc_world_pos.x,-0.5,0.5);merc_world_pos=u_merc_matrix*merc_world_pos;}vec4 interpolated_pos=vec4(mix(globe_world_pos.xyz,merc_world_pos.xyz,u_zoom_transition),1.0); #endif gl_Position=u_proj_matrix*interpolated_pos; #ifdef FOG v_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz); #endif }`),globeAtmosphere:Hn(`#include "_prelude_fog.fragment.glsl" uniform float u_transition;uniform highp float u_fadeout_range;uniform highp float u_temporal_offset;uniform vec4 u_atmosphere_fog_color;uniform vec4 u_high_color;uniform vec4 u_space_color;uniform float u_horizon_angle;in highp vec3 v_ray_dir;in highp vec3 v_horizon_dir;void main() {highp vec3 dir=normalize(v_ray_dir);float globe_pos_dot_dir; #ifdef PROJECTION_GLOBE_VIEW globe_pos_dot_dir=dot(u_globe_pos,dir);highp vec3 closest_point_forward=abs(globe_pos_dot_dir)*dir;float norm_dist_from_center=length(closest_point_forward-u_globe_pos)/u_globe_radius;if (norm_dist_from_center < 0.98) { #ifdef ALPHA_PASS glFragColor=vec4(0,0,0,0);return; #else #ifdef NATIVE glFragColor=vec4(1,1,1,1); #else glFragColor=vec4(0,0,0,1); #endif return; #endif } #endif highp vec3 horizon_dir=normalize(v_horizon_dir);float horizon_angle_mercator=dir.y < horizon_dir.y ? 0.0 : max(acos(clamp(dot(dir,horizon_dir),-1.0,1.0)),0.0);float horizon_angle; #ifdef PROJECTION_GLOBE_VIEW highp vec3 closest_point=globe_pos_dot_dir*dir;highp float closest_point_to_center=length(closest_point-u_globe_pos);highp float theta=asin(clamp(closest_point_to_center/length(u_globe_pos),-1.0,1.0));horizon_angle=globe_pos_dot_dir < 0.0 ? PI-theta-u_horizon_angle : theta-u_horizon_angle;float angle_t=pow(u_transition,10.0);horizon_angle=mix(horizon_angle,horizon_angle_mercator,angle_t); #else horizon_angle=horizon_angle_mercator; #endif horizon_angle/=PI;float t=exp(-horizon_angle/u_fadeout_range);float alpha_0=u_atmosphere_fog_color.a;float alpha_1=u_high_color.a;float alpha_2=u_space_color.a;vec3 color_stop_0=u_atmosphere_fog_color.rgb;vec3 color_stop_1=u_high_color.rgb;vec3 color_stop_2=u_space_color.rgb; #ifdef ALPHA_PASS float a0=mix(alpha_2,1.0,alpha_1);float a1=mix(a0,1.0,alpha_0);float a2=mix(a0,a1,t);float a =mix(alpha_2,a2,t);glFragColor=vec4(1.0,1.0,1.0,a); #else vec3 c0=mix(color_stop_2,color_stop_1,alpha_1);vec3 c1=mix(c0,color_stop_0,alpha_0);vec3 c2=mix(c0,c1,t);vec3 c=c2;glFragColor=vec4(c*t,t); #endif }`,`in vec3 a_pos;in vec2 a_uv;uniform vec3 u_frustum_tl;uniform vec3 u_frustum_tr;uniform vec3 u_frustum_br;uniform vec3 u_frustum_bl;uniform float u_horizon;out highp vec3 v_ray_dir;out highp vec3 v_horizon_dir;void main() {v_ray_dir=mix( mix(u_frustum_tl,u_frustum_tr,a_uv.x),mix(u_frustum_bl,u_frustum_br,a_uv.x),a_uv.y);v_horizon_dir=mix( mix(u_frustum_tl,u_frustum_bl,u_horizon),mix(u_frustum_tr,u_frustum_br,u_horizon),a_uv.x);gl_Position=vec4(a_pos,1.0);}`),model:Hn(`#include "_prelude_fog.fragment.glsl" #include "_prelude_shadow.fragment.glsl" #include "_prelude_lighting.glsl" uniform float u_opacity; #ifdef DITHERED_DISCARD uniform float u_dithered_discard_threshold; #endif uniform vec3 u_lightcolor;uniform vec3 u_lightpos;uniform float u_lightintensity;uniform vec4 u_baseColorFactor;uniform vec4 u_emissiveFactor;uniform float u_metallicFactor;uniform float u_roughnessFactor;uniform float u_emissive_strength;in highp vec4 v_position_height;in lowp vec4 v_color_mix; #ifdef RENDER_SHADOWS in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in float v_depth_shadows; #endif #ifdef OCCLUSION_TEXTURE_TRANSFORM uniform vec4 u_occlusionTextureTransform; #endif #pragma mapbox: define-attribute highp vec3 normal_3f #pragma mapbox: define-attribute highp vec3 color_3f #pragma mapbox: define-attribute highp vec4 color_4f #pragma mapbox: define-attribute highp vec2 uv_2f #pragma mapbox: initialize-attribute highp vec3 normal_3f #pragma mapbox: initialize-attribute highp vec3 color_3f #pragma mapbox: initialize-attribute highp vec4 color_4f #pragma mapbox: initialize-attribute highp vec2 uv_2f #ifdef HAS_ATTRIBUTE_a_pbr in lowp vec4 v_roughness_metallic_emissive_alpha;in mediump vec4 v_height_based_emission_params; #endif #ifdef HAS_TEXTURE_u_baseColorTexture uniform sampler2D u_baseColorTexture;uniform bool u_baseTextureIsAlpha;uniform bool u_alphaMask;uniform float u_alphaCutoff; #endif #ifdef HAS_TEXTURE_u_metallicRoughnessTexture uniform sampler2D u_metallicRoughnessTexture; #endif #ifdef HAS_TEXTURE_u_occlusionTexture uniform sampler2D u_occlusionTexture;uniform float u_aoIntensity; #endif #ifdef HAS_TEXTURE_u_normalTexture uniform sampler2D u_normalTexture; #endif #ifdef HAS_TEXTURE_u_emissionTexture uniform sampler2D u_emissionTexture; #endif #ifdef APPLY_LUT_ON_GPU uniform highp sampler3D u_lutTexture; #endif #ifdef TERRAIN_FRAGMENT_OCCLUSION in highp float v_depth;uniform highp sampler2D u_depthTexture;uniform highp vec2 u_inv_depth_size;uniform highp vec2 u_depth_range_unpack; #ifdef DEPTH_D24 highp float unpack_depth(highp float depth) {return depth*u_depth_range_unpack.x+u_depth_range_unpack.y;} #else highp float unpack_depth_rgba(highp vec4 rgba_depth) {const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;} #endif bool isOccluded() {highp vec2 coord=gl_FragCoord.xy*u_inv_depth_size; #ifdef FLIP_Y coord.y=1.0-coord.y; #endif #ifdef DEPTH_D24 highp float depth=unpack_depth(texture(u_depthTexture,coord).r); #else highp float depth=unpack_depth_rgba(texture(u_depthTexture,coord)); #endif return v_depth > depth+0.0005;} #endif #define saturate(_x) clamp(_x,0.,1.) vec3 linearTosRGB(vec3 color) {return pow(color,vec3(1./2.2));}vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}float calculate_NdotL(vec3 normal,vec3 lightDir) {const float ext=0.70710678118;return (clamp(dot(normal,lightDir),-ext,1.0)+ext)/(1.0+ext);}vec3 getDiffuseShadedColor(vec3 albedo,vec3 normal,vec3 lightDir,vec3 lightColor) { #ifdef LIGHTING_3D_MODE vec3 transformed_normal=vec3(-normal.xy,normal.z);float lighting_factor; #ifdef RENDER_SHADOWS lighting_factor=shadowed_light_factor_normal(transformed_normal,v_pos_light_view_0,v_pos_light_view_1,v_depth_shadows); #else lighting_factor=saturate(dot(transformed_normal,u_lighting_directional_dir)); #endif return apply_lighting(albedo,transformed_normal,lighting_factor); #else vec3 n=normal;float colorvalue=((albedo.x*0.2126)+(albedo.y*0.7152))+(albedo.z*0.0722);vec3 c=vec3(0.03,0.03,0.03);float directional=clamp(dot(n,vec3(lightDir)),0.0,1.0);directional=mix(1.0-u_lightintensity,max((1.0-colorvalue)+u_lightintensity,1.0),directional);vec3 c3=c+clamp((albedo*directional)*lightColor,mix(vec3(0.0),vec3(0.3),vec3(1.0)-lightColor),vec3(1.0));return c3; #endif }vec4 getBaseColor() {vec4 albedo=u_baseColorFactor; #ifdef HAS_ATTRIBUTE_a_color_3f albedo*=vec4(color_3f,1.0); #endif #ifdef HAS_ATTRIBUTE_a_pbr #else #ifdef HAS_ATTRIBUTE_a_color_4f albedo*=color_4f; #endif #endif #if defined (HAS_TEXTURE_u_baseColorTexture) && defined (HAS_ATTRIBUTE_a_uv_2f) vec4 texColor=texture(u_baseColorTexture,uv_2f);if(u_alphaMask) {if (texColor.w < u_alphaCutoff) {discard;}} #ifdef UNPREMULT_TEXTURE_IN_SHADER if(texColor.w > 0.0) {texColor.rgb/=texColor.w;}texColor.w=1.0; #endif if(u_baseTextureIsAlpha) {if (texColor.r < 0.5) {discard;}} else {texColor.rgb=sRGBToLinear(texColor.rgb);albedo*=texColor;} #endif vec4 color=vec4(mix(albedo.rgb,v_color_mix.rgb,v_color_mix.a),albedo.a); #ifdef APPLY_LUT_ON_GPU color=applyLUT(u_lutTexture,color); #endif return color;}highp mat3 cotangentFrame(highp vec3 N,highp vec3 p,highp vec2 uv ) { #ifdef HAS_TEXTURE_u_normalTexture highp vec3 dp1=vec3(dFdx(p.x),dFdx(p.y),dFdx(p.z));highp vec3 dp2=vec3(dFdy(p.x),dFdy(p.y),dFdy(p.z));highp vec2 duv1=vec2(dFdx(uv.x),dFdx(uv.y));highp vec2 duv2=vec2(dFdy(uv.x),dFdy(uv.y));highp vec3 dp2perp=cross( dp2,N );highp vec3 dp1perp=cross( N,dp1 );highp vec3 T=dp2perp*duv1.x+dp1perp*duv2.x;highp vec3 B=dp2perp*duv1.y+dp1perp*duv2.y; #ifdef FLIP_Y T=-T;B=-B; #endif highp float lengthT=dot(T,T);highp float lengthB=dot(B,B);highp float maxLength=max(lengthT,lengthB);highp float invmax=inversesqrt( maxLength );highp mat3 res=mat3( T*invmax,B*invmax,N );return res; #else return mat3(1.0); #endif }highp vec3 getNormal(){highp vec3 n; #ifdef HAS_ATTRIBUTE_a_normal_3f n=normalize(normal_3f); #else highp vec3 fdx=vec3(dFdx(v_position_height.x),dFdx(v_position_height.y),dFdx(v_position_height.z));highp vec3 fdy=vec3(dFdy(v_position_height.x),dFdy(v_position_height.y),dFdy(v_position_height.z)); #ifdef FLIP_Y n=normalize(cross(fdx,fdy)); #else n=normalize(cross(fdx,fdy))*-1.0; #endif #endif #if defined(HAS_TEXTURE_u_normalTexture) && defined(HAS_ATTRIBUTE_a_uv_2f) vec3 nMap=texture( u_normalTexture,uv_2f).xyz;nMap=normalize(2.0*nMap-vec3(1.0));highp vec3 v=normalize(-v_position_height.xyz);highp mat3 TBN=cotangentFrame(n,v,uv_2f);n=normalize(TBN*nMap); #endif return n;}struct Material {float perceptualRoughness;float alphaRoughness;float metallic;vec3 f90;vec4 baseColor;vec3 diffuseColor;vec3 specularColor;highp vec3 normal;};Material getPBRMaterial() {Material mat;mat.baseColor=getBaseColor();mat.perceptualRoughness=u_roughnessFactor;mat.metallic=u_metallicFactor; #ifdef HAS_ATTRIBUTE_a_pbr mat.perceptualRoughness=v_roughness_metallic_emissive_alpha.x;mat.metallic=v_roughness_metallic_emissive_alpha.y;mat.baseColor.w*=v_roughness_metallic_emissive_alpha.w; #endif #if defined(HAS_TEXTURE_u_metallicRoughnessTexture) && defined(HAS_ATTRIBUTE_a_uv_2f) vec4 mrSample=texture(u_metallicRoughnessTexture,uv_2f);mat.perceptualRoughness*=mrSample.g;mat.metallic*=mrSample.b; #endif const float c_minRoughness=0.04;mat.perceptualRoughness=clamp(mat.perceptualRoughness,c_minRoughness,1.0);mat.metallic=saturate(mat.metallic);mat.alphaRoughness=mat.perceptualRoughness*mat.perceptualRoughness;const vec3 f0=vec3(0.04);mat.diffuseColor=mat.baseColor.rgb*(vec3(1.0)-f0);mat.diffuseColor*=1.0-mat.metallic;mat.specularColor=mix(f0,mat.baseColor.rgb,mat.metallic);highp float reflectance=max(max(mat.specularColor.r,mat.specularColor.g),mat.specularColor.b);highp float reflectance90=saturate(reflectance*25.0);mat.f90=vec3(reflectance90);mat.normal=getNormal();return mat;}float V_GGX(float NdotL,float NdotV,float roughness) {float a2=roughness*roughness;float GGXV=NdotL*sqrt(NdotV*NdotV*(1.0-a2)+a2);float GGXL=NdotV*sqrt(NdotL*NdotL*(1.0-a2)+a2);return 0.5/(GGXV+GGXL);}float V_GGXFast(float NdotL,float NdotV,float roughness) {float a=roughness;float GGXV=NdotL*(NdotV*(1.0-a)+a);float GGXL=NdotV*(NdotL*(1.0-a)+a);return 0.5/(GGXV+GGXL);}vec3 F_Schlick(vec3 specularColor,vec3 f90,float VdotH) {return specularColor+(f90-specularColor)*pow(clamp(1.0-VdotH,0.0,1.0),5.0);}vec3 F_SchlickFast(vec3 specularColor,float VdotH) {float x=1.0-VdotH;float x4=x*x*x*x;return specularColor+(1.0-specularColor)*x4*x;}float D_GGX(highp float NdotH,float alphaRoughness) {highp float a4=alphaRoughness*alphaRoughness;highp float f=(NdotH*a4-NdotH)*NdotH+1.0;return a4/(PI*f*f);}vec3 diffuseBurley(Material mat,float LdotH,float NdotL,float NdotV) {float f90=2.0*LdotH*LdotH*mat.alphaRoughness-0.5;return (mat.diffuseColor/PI)*(1.0+f90*pow((1.0-NdotL),5.0))*(1.0+f90*pow((1.0-NdotV),5.0));}vec3 diffuseLambertian(Material mat) { #ifdef LIGHTING_3D_MODE return mat.diffuseColor; #else return mat.diffuseColor/PI; #endif }vec3 EnvBRDFApprox(vec3 specularColor,float roughness,highp float NdotV) {vec4 c0=vec4(-1,-0.0275,-0.572,0.022);vec4 c1=vec4(1,0.0425,1.04,-0.04);highp vec4 r=roughness*c0+c1;highp float a004=min(r.x*r.x,exp2(-9.28*NdotV))*r.x+r.y;vec2 AB=vec2(-1.04,1.04)*a004+r.zw;return specularColor*AB.x+AB.y;}vec3 computeIndirectLightContribution(Material mat,float NdotV,vec3 normal) {vec3 env_light=vec3(0.65,0.65,0.65); #ifdef LIGHTING_3D_MODE float ambient_factor=calculate_ambient_directional_factor(normal);env_light=u_lighting_ambient_color*ambient_factor; #endif vec3 envBRDF=EnvBRDFApprox(mat.specularColor,mat.perceptualRoughness,NdotV);vec3 indirectSpecular= envBRDF*env_light;vec3 indirectDiffuse=mat.diffuseColor*env_light;return indirectSpecular+indirectDiffuse;}vec3 computeLightContribution(Material mat,vec3 lightPosition,vec3 lightColor) {highp vec3 n=mat.normal;highp vec3 v=normalize(-v_position_height.xyz);highp vec3 l=normalize(lightPosition);highp vec3 h=normalize(v+l);float NdotV=clamp(abs(dot(n,v)),0.001,1.0);float NdotL=saturate(dot(n,l));highp float NdotH=saturate(dot(n,h));float VdotH=saturate(dot(v,h));vec3 f=F_SchlickFast(mat.specularColor,VdotH);float g=V_GGXFast(NdotL,NdotV,mat.alphaRoughness);float d=D_GGX(NdotH,mat.alphaRoughness);vec3 diffuseTerm=(1.0-f)*diffuseLambertian(mat);vec3 specularTerm=f*g*d;vec3 transformed_normal=vec3(-n.xy,n.z);float lighting_factor; #ifdef RENDER_SHADOWS lighting_factor=shadowed_light_factor_normal(transformed_normal,v_pos_light_view_0,v_pos_light_view_1,v_depth_shadows); #else lighting_factor=NdotL; #endif vec3 directLightColor=(specularTerm+diffuseTerm)*lighting_factor*lightColor;vec3 indirectLightColor=computeIndirectLightContribution(mat,NdotV,transformed_normal);vec3 color=(saturate(directLightColor)+indirectLightColor);float intensityFactor=1.0; #if !defined(LIGHTING_3D_MODE) const vec3 luminosityFactor=vec3(0.2126,0.7152,0.0722);float luminance=dot(diffuseTerm,luminosityFactor);intensityFactor=mix((1.0-u_lightintensity),max((1.0-luminance+u_lightintensity),1.0),NdotL); #endif color*=intensityFactor;return color;}void main() { #ifdef TERRAIN_FRAGMENT_OCCLUSION if (isOccluded()) {discard;} #endif vec3 lightDir=u_lightpos;vec3 lightColor=u_lightcolor; #ifdef LIGHTING_3D_MODE lightDir=u_lighting_directional_dir;lightDir.xy=-lightDir.xy;lightColor=u_lighting_directional_color; #endif vec4 finalColor; #ifdef DIFFUSE_SHADED vec3 N=getNormal();vec3 baseColor=getBaseColor().rgb;vec3 diffuse=getDiffuseShadedColor(baseColor,N,lightDir,lightColor); #ifdef HAS_TEXTURE_u_occlusionTexture float ao=(texture(u_occlusionTexture,uv_2f).r-1.0)*u_aoIntensity+1.0;diffuse*=ao; #endif finalColor=vec4(mix(diffuse,baseColor,u_emissive_strength),1.0)*u_opacity; #else Material mat=getPBRMaterial();vec3 color=computeLightContribution(mat,lightDir,lightColor);float ao=1.0; #if defined (HAS_TEXTURE_u_occlusionTexture) && defined(HAS_ATTRIBUTE_a_uv_2f) #ifdef OCCLUSION_TEXTURE_TRANSFORM vec2 uv=uv_2f.xy*u_occlusionTextureTransform.zw+u_occlusionTextureTransform.xy; #else vec2 uv=uv_2f; #endif ao=(texture(u_occlusionTexture,uv).x-1.0)*u_aoIntensity+1.0;color*=ao; #endif vec4 emissive=u_emissiveFactor; #if defined(HAS_TEXTURE_u_emissionTexture) && defined(HAS_ATTRIBUTE_a_uv_2f) emissive.rgb*=sRGBToLinear(texture(u_emissionTexture,uv_2f).rgb); #endif #ifdef APPLY_LUT_ON_GPU float emissiveFactorLength=max(length(u_emissiveFactor.rgb),0.001);emissive.rgb=sRGBToLinear(applyLUT(u_lutTexture,linearTosRGB(emissive.rgb/emissiveFactorLength).rbg))*emissiveFactorLength; #endif color+=emissive.rgb;float opacity=mat.baseColor.w*u_opacity; #ifdef HAS_ATTRIBUTE_a_pbr float resEmission=v_roughness_metallic_emissive_alpha.z;resEmission*=v_height_based_emission_params.z+v_height_based_emission_params.w*pow(clamp(v_height_based_emission_params.x,0.0,1.0),v_height_based_emission_params.y);vec3 color_mix=v_color_mix.rgb; #ifdef APPLY_LUT_ON_GPU color_mix=applyLUT(u_lutTexture,color_mix); #endif color=mix(color,color_mix,min(1.0,resEmission)); #ifdef HAS_ATTRIBUTE_a_color_4f float distance=length(vec2(1.3*max(0.0,abs(color_4f.x)-color_4f.z),color_4f.y));distance+= mix(0.5,0.0,clamp(resEmission-1.0,0.0,1.0));opacity*=v_roughness_metallic_emissive_alpha.w*saturate(1.0-distance*distance); #endif #endif vec3 unlitColor=mat.baseColor.rgb*ao+emissive.rgb;color=mix(color,unlitColor,u_emissive_strength);color=linearTosRGB(color);color*=opacity;finalColor=vec4(color,opacity); #endif #ifdef DITHERED_DISCARD if (abs(u_dithered_discard_threshold) < 1.0) {float ditherValue=fract(52.9829189*fract(0.06711056*gl_FragCoord.x+0.00583715*gl_FragCoord.y));float compareValue=mix(1.0-ditherValue,ditherValue,step(0.0,u_dithered_discard_threshold));if (abs(u_dithered_discard_threshold) < compareValue) {discard;}} #endif #ifdef FOG finalColor=fog_dither(fog_apply_premultiplied(finalColor,v_fog_pos,v_position_height.w)); #endif #ifdef RENDER_CUTOFF finalColor*=v_cutoff_opacity; #endif #ifdef INDICATOR_CUTOUT finalColor=applyCutout(finalColor,v_position_height.w); #endif #ifdef FEATURE_CUTOUT finalColor=apply_feature_cutout(finalColor,gl_FragCoord,get_cutout_factors(gl_FragCoord).x); #endif glFragColor=finalColor; #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(1.0); #endif HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl" #include "_prelude_shadow.vertex.glsl" in vec3 a_pos_3f; #pragma mapbox: define-attribute highp vec3 normal_3f #pragma mapbox: define-attribute highp vec2 uv_2f #pragma mapbox: define-attribute highp vec3 color_3f #pragma mapbox: define-attribute highp vec4 color_4f #pragma mapbox: define-attribute-vertex-shader-only highp uvec4 pbr #pragma mapbox: define-attribute-vertex-shader-only highp vec3 heightBasedEmissiveStrength uniform mat4 u_matrix;uniform mat4 u_node_matrix;uniform mat4 u_lighting_matrix;uniform vec3 u_camera_pos;uniform vec4 u_color_mix; #ifdef INSTANCED_ARRAYS in vec4 a_normal_matrix0;in vec4 a_normal_matrix1;in vec4 a_normal_matrix2;in vec4 a_normal_matrix3; #else uniform highp mat4 u_normal_matrix; #endif #ifdef RENDER_SHADOWS uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out float v_depth_shadows; #endif out vec4 v_position_height;out lowp vec4 v_color_mix; #ifdef TERRAIN_FRAGMENT_OCCLUSION out highp float v_depth; #endif #ifdef HAS_ATTRIBUTE_a_pbr out lowp vec4 v_roughness_metallic_emissive_alpha;out mediump vec4 v_height_based_emission_params; #endif vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}void main() { #pragma mapbox: initialize-attribute highp vec3 normal_3f #pragma mapbox: initialize-attribute highp vec2 uv_2f #pragma mapbox: initialize-attribute highp vec3 color_3f #pragma mapbox: initialize-attribute highp vec4 color_4f #pragma mapbox: initialize-attribute-custom highp uvec4 pbr #pragma mapbox: initialize-attribute-custom highp vec3 heightBasedEmissiveStrength highp mat4 normal_matrix; #ifdef INSTANCED_ARRAYS normal_matrix=mat4(a_normal_matrix0,a_normal_matrix1,a_normal_matrix2,a_normal_matrix3); #else normal_matrix=u_normal_matrix; #endif vec3 local_pos;mat3 rs; #ifdef MODEL_POSITION_ON_GPU vec3 pos_color=normal_matrix[0].xyz;vec4 translate=normal_matrix[1];vec3 pos_a=floor(pos_color);vec3 rgb=1.05*(pos_color-pos_a);float hidden=float(pos_a.x > EXTENT);float color_mix=pos_a.z/100.0;v_color_mix=vec4(sRGBToLinear(rgb),color_mix);float meter_to_tile=normal_matrix[0].w;vec4 pos=vec4(pos_a.xy,translate.z,1.0);rs[0].x=normal_matrix[1].w;rs[0].yz=normal_matrix[2].xy;rs[1].xy=normal_matrix[2].zw;rs[1].z=normal_matrix[3].x;rs[2].xyz=normal_matrix[3].yzw;vec4 pos_node=u_lighting_matrix*vec4(a_pos_3f,1.0);vec3 rotated_pos_node=rs*pos_node.xyz;vec3 pos_model_tile=(rotated_pos_node+vec3(translate.xy,0.0))*vec3(meter_to_tile,meter_to_tile,1.0);pos.xyz+=pos_model_tile;local_pos=pos.xyz;gl_Position=mix(u_matrix*pos,AWAY,hidden);pos.z*=meter_to_tile;v_position_height.xyz=pos.xyz-u_camera_pos; #else local_pos=a_pos_3f;gl_Position=u_matrix*vec4(a_pos_3f,1);v_position_height.xyz=vec3(u_lighting_matrix*vec4(a_pos_3f,1));v_color_mix=vec4(sRGBToLinear(u_color_mix.rgb),u_color_mix.a); #endif v_position_height.w=a_pos_3f.z; #ifdef HAS_ATTRIBUTE_a_pbr vec4 albedo_c=decode_color(vec2(pbr.xy));vec2 e_r_m=unpack_float(float(pbr.z));vec2 r_m= unpack_float(e_r_m.y*16.0);r_m.r=r_m.r*16.0;v_color_mix=vec4(albedo_c.rgb,1.0);v_roughness_metallic_emissive_alpha=vec4(vec3(r_m,e_r_m.x)/255.0,albedo_c.a);v_roughness_metallic_emissive_alpha.z*=2.0;float heightBasedRelativeIntepolation=a_pos_3f.z*heightBasedEmissiveStrength.x+heightBasedEmissiveStrength.y;v_height_based_emission_params.x=heightBasedRelativeIntepolation;v_height_based_emission_params.y=heightBasedEmissiveStrength.z;vec2 emissionMultiplierValues=unpack_float(float(pbr.w))/256.0;v_height_based_emission_params.z=emissionMultiplierValues.x;v_height_based_emission_params.w=emissionMultiplierValues.y-emissionMultiplierValues.x; #endif #ifdef FOG v_fog_pos=fog_position(local_pos); #endif #ifdef RENDER_CUTOFF v_cutoff_opacity=cutoff_opacity(u_cutoff_params,gl_Position.z); #endif #ifdef TERRAIN_FRAGMENT_OCCLUSION v_depth=gl_Position.z/gl_Position.w; #ifdef CLIP_ZERO_TO_ONE v_depth=-1.0+2.0*v_depth; #endif #endif #ifdef HAS_ATTRIBUTE_a_normal_3f #ifdef MODEL_POSITION_ON_GPU float x_squared_scale=dot(rs[0],rs[0]);float y_squared_scale=dot(rs[1],rs[1]);float z_squared_scale=dot(rs[2],rs[2]);vec3 squared_scale=vec3(x_squared_scale,y_squared_scale,z_squared_scale);normal_3f=rs*((u_lighting_matrix*vec4(normal_3f,0.0)).xyz/squared_scale);normal_3f=normalize(normal_3f); #else normal_3f=vec3(normal_matrix*vec4(normal_3f,0)); #endif #endif #ifdef HAS_ATTRIBUTE_a_pbr #ifdef HAS_ATTRIBUTE_a_color_4f v_roughness_metallic_emissive_alpha.w=clamp(color_4f.a*v_roughness_metallic_emissive_alpha.w*(v_roughness_metallic_emissive_alpha.z-1.0),0.0,1.0); #endif #endif #ifdef RENDER_SHADOWS vec4 shadow_pos=u_node_matrix*vec4(local_pos,1.0); #ifdef NORMAL_OFFSET #ifdef HAS_ATTRIBUTE_a_normal_3f #ifdef MODEL_POSITION_ON_GPU vec3 offset=shadow_normal_offset(vec3(-normal_3f.xy,normal_3f.z));shadow_pos.xyz+=offset*shadow_normal_offset_multiplier0(); #else vec3 offset=shadow_normal_offset_model(normal_3f);shadow_pos.xyz+=offset*shadow_normal_offset_multiplier0(); #endif #endif #endif v_pos_light_view_0=u_light_matrix_0*shadow_pos;v_pos_light_view_1=u_light_matrix_1*shadow_pos;v_depth_shadows=gl_Position.w; #endif }`),modelDepth:Hn("void main() {}",`in vec3 a_pos_3f;uniform mat4 u_matrix; #ifdef MODEL_POSITION_ON_GPU #ifdef INSTANCED_ARRAYS in vec4 a_normal_matrix0;in vec4 a_normal_matrix1;in vec4 a_normal_matrix2;in vec4 a_normal_matrix3; #else uniform highp mat4 u_instance; #endif uniform highp mat4 u_node_matrix; #endif void main() { #ifdef MODEL_POSITION_ON_GPU highp mat4 instance; #ifdef INSTANCED_ARRAYS instance=mat4(a_normal_matrix0,a_normal_matrix1,a_normal_matrix2,a_normal_matrix3); #else instance=u_instance; #endif vec3 pos_color=instance[0].xyz;vec4 translate=instance[1];vec3 pos_a=floor(pos_color);float hidden=float(pos_a.x > EXTENT);float meter_to_tile=instance[0].w;vec4 pos=vec4(pos_a.xy,translate.z,1.0);mat3 rs;rs[0].x=instance[1].w;rs[0].yz=instance[2].xy;rs[1].xy=instance[2].zw;rs[1].z=instance[3].x;rs[2].xyz=instance[3].yzw;vec4 pos_node=u_node_matrix*vec4(a_pos_3f,1.0);vec3 rotated_pos_node=rs*pos_node.xyz;vec3 pos_model_tile=(rotated_pos_node+vec3(translate.xy,0.0))*vec3(meter_to_tile,meter_to_tile,1.0);pos.xyz+=pos_model_tile;gl_Position=mix(u_matrix*pos,AWAY,hidden); #else gl_Position=u_matrix*vec4(a_pos_3f,1); #endif }`),stars:Hn(`in highp vec2 v_uv;in mediump float v_intensity;float shapeCircle(in vec2 uv) {float beginFade=0.6;float lengthFromCenter=length(v_uv);return 1.0-clamp((lengthFromCenter-beginFade)/(1.0-beginFade),0.0,1.0);}void main() {float alpha=shapeCircle(v_uv);vec3 color=vec3(1.0,1.0,1.0);alpha*=v_intensity;glFragColor=vec4(color*alpha,alpha);HANDLE_WIREFRAME_DEBUG;}`,` in vec3 a_pos_3f;in vec2 a_uv;in float a_size_scale;in float a_opacity;uniform mat4 u_matrix;uniform vec3 u_up;uniform vec3 u_right;uniform float u_intensity_multiplier;out highp vec2 v_uv;out mediump float v_intensity;void main() {v_uv=a_uv;v_intensity=a_opacity*u_intensity_multiplier;vec3 pos=a_pos_3f;pos+=a_uv.x*u_right*a_size_scale;pos+=a_uv.y*u_up*a_size_scale;gl_Position=u_matrix*vec4(pos,1.0);}`),snowParticle:Hn("in highp vec2 uv;in highp float alphaMultiplier;uniform vec4 u_particleColor;uniform vec2 u_simpleShapeParameters;void main() {float t=clamp((length(uv)-u_simpleShapeParameters.x)/(1.0-u_simpleShapeParameters.x),0.0,1.0);float alpha=1.0-pow(t,pow(10.0,u_simpleShapeParameters.y));alpha*=alphaMultiplier;alpha*=u_particleColor.a;vec3 color=u_particleColor.rgb*alpha;glFragColor=vec4(color,alpha) ;HANDLE_WIREFRAME_DEBUG;}",` in highp vec3 a_pos_3f;in highp vec2 a_uv;in highp vec4 a_snowParticleData;in highp vec4 a_snowParticleDataHorizontalOscillation;uniform mat4 u_modelview;uniform mat4 u_projection;uniform vec3 u_cam_pos;uniform vec2 u_screenSize;uniform float u_time;uniform float u_boxSize;uniform float u_velocityConeAperture; uniform float u_velocity;uniform vec3 u_direction;uniform float u_horizontalOscillationRadius; uniform float u_horizontalOscillationRate; uniform float u_billboardSize;uniform vec2 u_thinningCenterPos;uniform vec3 u_thinningShape;uniform float u_thinningAffectedRatio;uniform float u_thinningParticleOffset;out highp vec2 uv;out highp float alphaMultiplier;void main() {vec3 pos=a_pos_3f;float halfBoxSize=0.5*u_boxSize;pos.xyz*=halfBoxSize;pos+=u_cam_pos;float velocityConeApertureRad=radians(u_velocityConeAperture*0.5);float coneAnglePichRad=velocityConeApertureRad*a_snowParticleData.z;float coneAngleHeadingRad=a_snowParticleData.w*radians(360.0);vec3 localZ=normalize(u_direction);vec3 localX=normalize(cross(localZ,vec3(1,0,0)));vec3 localY=normalize(cross(localZ,localX));vec3 direction;direction.x=cos(coneAngleHeadingRad)*sin(coneAnglePichRad);direction.y=sin(coneAngleHeadingRad)*sin(coneAnglePichRad);direction.z=cos(coneAnglePichRad);direction=normalize(direction);vec3 simPosLocal=vec3(0,0,0);float velocityScale=(1.0+3.0*a_snowParticleData.y)*u_velocity;simPosLocal+=direction*velocityScale*u_time;float horizontalOscillationRadius=u_horizontalOscillationRadius*a_snowParticleDataHorizontalOscillation.x;float horizontalOscillationAngle=u_horizontalOscillationRate*u_time*(-1.0+2.0*a_snowParticleDataHorizontalOscillation.y);simPosLocal.xy+=horizontalOscillationRadius*vec2(cos(horizontalOscillationAngle),sin(horizontalOscillationAngle));vec3 simPos=localX*simPosLocal.x+ localY*simPosLocal.y+localZ*simPosLocal.z;pos+=simPos;pos=fract((pos+vec3(halfBoxSize))/vec3(u_boxSize))*u_boxSize-vec3(halfBoxSize);float clipZ=-u_cam_pos.z+pos.z;vec4 posView=u_modelview*vec4(pos,1.0);float size=u_billboardSize;alphaMultiplier=1.0;vec4 posScreen=u_projection*posView;posScreen/=posScreen.w;posScreen.xy=vec2(0.5)+posScreen.xy*0.5;posScreen.xy*=u_screenSize;vec2 thinningCenterPos=u_thinningCenterPos.xy;thinningCenterPos.y=u_screenSize.y-thinningCenterPos.y;float screenDist=length((thinningCenterPos-posScreen.xy)/(0.5*u_screenSize));screenDist+=a_snowParticleData.x*u_thinningParticleOffset;float scaleFactorMode=0.0;float thinningShapeDist=u_thinningShape.x+u_thinningShape.y;if (screenDist < thinningShapeDist) {float thinningFadeRatio=clamp((screenDist-u_thinningShape.x)/u_thinningShape.y,0.0,1.0);thinningFadeRatio=pow(thinningFadeRatio,u_thinningShape.z);if (a_snowParticleData.x < u_thinningAffectedRatio) {scaleFactorMode=1.0-thinningFadeRatio;alphaMultiplier=thinningFadeRatio;}}vec4 posScreen1=u_projection*vec4(posView.x-size,posView.yzw);posScreen1/=posScreen1.w;vec4 posScreen2=u_projection*vec4(posView.x+size,posView.yzw);posScreen2/=posScreen2.w;posScreen1.xy=vec2(0.5)+posScreen1.xy*0.5;posScreen1.xy*=u_screenSize;posScreen2.xy=vec2(0.5)+posScreen2.xy*0.5;posScreen2.xy*=u_screenSize;float screenLength=length(posScreen1.xy-posScreen2.xy);float screenEpsilon=3.0;float scaleFactor=1.0;if (screenLength < screenEpsilon) {scaleFactor=screenEpsilon/max(screenLength,0.01);scaleFactor=mix(scaleFactor,1.0,scaleFactorMode);}float screenEpsilon2=15.0;if (screenLength > screenEpsilon2) {scaleFactor=screenEpsilon2/max(screenLength,0.01);}size*=scaleFactor;vec2 right=size*vec2(1,0);vec2 up=size*vec2(0,1);posView.xy+=right*a_uv.x;posView.xy+=up*a_uv.y;uv=a_uv;gl_Position=u_projection*posView;}`),rainParticle:Hn("in highp vec2 uv;in highp float particleRandomValue;uniform sampler2D u_texScreen;uniform float u_distortionStrength;uniform vec4 u_color;uniform vec2 u_thinningCenterPos;uniform vec3 u_thinningShape;uniform float u_thinningAffectedRatio;uniform float u_thinningParticleOffset;uniform float u_shapeDirectionalPower;uniform float u_mode;void main() {vec2 st=uv*0.5+vec2(0.5);vec2 uvm=uv;uvm.y=-1.0+2.0*pow(st.y,u_shapeDirectionalPower);float shape=clamp(1.0-length(uvm),0.0,1.0);float alpha=abs(shape)*u_color.a;vec2 screenSize=vec2(textureSize(u_texScreen,0));vec2 thinningCenterPos=u_thinningCenterPos.xy;thinningCenterPos.y=screenSize.y-thinningCenterPos.y;float screenDist=length((thinningCenterPos-gl_FragCoord.xy)/(0.5*screenSize));screenDist+=(0.5+0.5*particleRandomValue)*u_thinningParticleOffset;float thinningShapeDist=u_thinningShape.x+u_thinningShape.y;float thinningAlpha=1.0;if (screenDist < thinningShapeDist) {float thinningFadeRatio=clamp((screenDist-u_thinningShape.x)/u_thinningShape.y,0.0,1.0);thinningFadeRatio=pow(thinningFadeRatio,u_thinningShape.z);thinningAlpha*=thinningFadeRatio;}vec2 offsetXY=normalize(uvm)*abs(shape);vec2 stScreen=(gl_FragCoord.xy+offsetXY*u_distortionStrength*thinningAlpha)/screenSize;vec3 colorScreen=texture(u_texScreen,stScreen).rgb;alpha*=thinningAlpha;glFragColor=mix(vec4(colorScreen,1.0),vec4(u_color.rgb*alpha,alpha),u_mode);HANDLE_WIREFRAME_DEBUG;}",` in highp vec3 a_pos_3f;in highp vec2 a_uv;in highp vec4 a_rainParticleData;uniform mat4 u_modelview;uniform mat4 u_projection;uniform vec3 u_cam_pos;uniform float u_time;uniform float u_boxSize;uniform float u_velocityConeAperture; uniform float u_velocity; uniform vec2 u_rainDropletSize;uniform vec3 u_rainDirection;out highp vec2 uv;out highp float particleRandomValue;void main() {vec3 pos=a_pos_3f;float halfBoxSize=0.5*u_boxSize;pos*=halfBoxSize; pos+=u_cam_pos;float velocityConeApertureRad=radians(u_velocityConeAperture*0.5);float coneAnglePichRad=velocityConeApertureRad*a_rainParticleData.z;float coneAngleHeadingRad=a_rainParticleData.w*radians(360.0);vec3 localZ=normalize(u_rainDirection);vec3 localX=normalize(cross(localZ,vec3(1,0,0)));vec3 localY=normalize(cross(localZ,localX));vec3 directionLocal;directionLocal.x=cos(coneAngleHeadingRad)*sin(coneAnglePichRad);directionLocal.y=sin(coneAngleHeadingRad)*sin(coneAnglePichRad);directionLocal.z=cos(coneAnglePichRad);directionLocal=normalize(directionLocal);vec3 directionWorld=localX*directionLocal.x+localY*directionLocal.y+localZ*directionLocal.z;float velocityScale=(1.0+3.0*a_rainParticleData.y)*u_velocity;vec3 simPosLocal=vec3(0,0,0);simPosLocal+=directionLocal*velocityScale*u_time;vec3 simPos=localX*simPosLocal.x+ localY*simPosLocal.y+localZ*simPosLocal.z;pos+=simPos;pos=fract((pos+vec3(halfBoxSize))/vec3(u_boxSize))*u_boxSize-vec3(halfBoxSize);vec4 posView=u_modelview*vec4(pos,1.0);vec3 directionView=normalize((u_modelview*vec4(directionWorld,0.0)).xyz);vec3 side=cross(directionView,normalize(posView.xyz));posView.xyz+=side*a_uv.x*u_rainDropletSize.x;posView.xyz+=directionView*a_uv.y*u_rainDropletSize.y;uv=a_uv;particleRandomValue=a_rainParticleData.x;gl_Position=u_projection*posView;}`),vignette:Hn("uniform vec3 u_vignetteShape;uniform vec4 u_vignetteColor;in vec2 st;void main() {float screenDist=length(st);float alpha=clamp((screenDist-u_vignetteShape.x)/u_vignetteShape.y,0.0,1.0);alpha=pow(alpha,u_vignetteShape.z)*u_vignetteColor.a;vec3 color=u_vignetteColor.rgb;glFragColor=vec4(color*alpha,alpha) ;}","in vec2 a_pos_2f;out vec2 st;void main() {st=a_pos_2f;gl_Position=vec4(a_pos_2f,0,1);}"),occlusion:Hn("uniform vec4 u_color;void main() {glFragColor=u_color;}",`#include "_prelude_terrain.vertex.glsl" in highp vec2 a_offset_xy;uniform highp vec3 u_anchorPos;uniform mat4 u_matrix;uniform vec2 u_screenSizePx;uniform vec2 u_occluderSizePx;void main() {vec3 world_pos=u_anchorPos; #ifdef TERRAIN float e=elevation(world_pos.xy);world_pos.z+=e; #endif vec4 projected_point=u_matrix*vec4(world_pos,1.0);projected_point.xy+=projected_point.w*a_offset_xy*0.5*u_occluderSizePx/u_screenSizePx;gl_Position=projected_point;}`)};function zh(v,d){const g=v.split(` `);for(let S of g){if(S=S.trimStart(),S[0]!=="#"||!S.includes("if")||S.startsWith("#endif"))continue;const j=S.match(vI);if(j)for(const R of j)bI.has(R)||d.add(R)}}function SI(v){return new Set(["uint","int","uvec2","ivec2","uvec3","ivec3","uvec4","ivec4"]).has(v)}function Hn(v,d){const g=new Set,S=[],j=[];v=v.replace(U0,(L,F)=>(j.push(F),"")),d=d.replace(U0,(L,F)=>(S.push(F),""));let R=new Set(bp);zh(v,R),zh(d,R);for(const L of[...S,...j])iy[L]||(iy[L]=new Set,zh(ud[L],iy[L])),R=new Set([...R,...iy[L]]);return{fragmentSource:v=v.replace(fr,(L,F,z,W,Z)=>(g.add(Z),F==="define"?` #ifndef HAS_UNIFORM_u_${Z} ${SI(W)?"flat ":""}in ${z} ${W} ${Z}; #else uniform ${z} ${W} u_${Z}; #endif `:F==="initialize"?` #ifdef HAS_UNIFORM_u_${Z} ${z} ${W} ${Z} = u_${Z}; #endif `:F==="define-attribute"?` #ifdef HAS_ATTRIBUTE_a_${Z} in ${z} ${W} ${Z}; #endif `:F==="initialize-attribute"?"":void 0)),vertexSource:d=d.replace(fr,(L,F,z,W,Z)=>{const ne=`MATERIAL_ATTRIBUTE_OFFSET_${Z}`,re=W==="float"?"vec2":W,ie=`GET_ATTRIBUTE_${re}(a_${Z}, materialInfo, ${ne})`,ce=Z.match(/color/)?"color":re;return F==="define-attribute-vertex-shader-only"?` #ifdef HAS_ATTRIBUTE_a_${Z} in ${z} ${W} a_${Z}; #endif `:g.has(Z)?F==="define"?` #ifndef HAS_UNIFORM_u_${Z} uniform lowp float u_${Z}_t; #if !defined(${ne}) in ${z} ${re} a_${Z}; #endif ${SI(W)?"flat ":""}out ${z} ${W} ${Z}; #else uniform ${z} ${W} u_${Z}; #endif `:F==="initialize"?ce==="vec4"||ce==="uvec4"?` #ifndef HAS_UNIFORM_u_${Z} ${Z} = a_${Z}; #else ${z} ${W} ${Z} = u_${Z}; #endif `:` #if !defined(HAS_UNIFORM_u_${Z}) #ifdef ${ne} ${Z} = unpack_mix_${ce}(${ie}, u_${Z}_t); #else ${Z} = unpack_mix_${ce}(a_${Z}, u_${Z}_t); #endif #else ${z} ${W} ${Z} = u_${Z}; #endif `:F==="define-attribute"?` #ifdef HAS_ATTRIBUTE_a_${Z} in ${z} ${W} a_${Z}; out ${z} ${W} ${Z}; #endif `:F==="initialize-attribute"?` #ifdef HAS_ATTRIBUTE_a_${Z} ${Z} = a_${Z}; #endif `:void 0:F==="define"?` #ifndef HAS_UNIFORM_u_${Z} uniform lowp float u_${Z}_t; #if !defined(${ne}) in ${z} ${re} a_${Z}; #endif #else uniform ${z} ${W} u_${Z}; #endif `:F==="define-instanced"?ce==="mat4"?` #ifdef INSTANCED_ARRAYS in vec4 a_${Z}0; in vec4 a_${Z}1; in vec4 a_${Z}2; in vec4 a_${Z}3; #else uniform ${z} ${W} u_${Z}; #endif `:` #ifdef INSTANCED_ARRAYS in ${z} ${re} a_${Z}; #else uniform ${z} ${W} u_${Z}; #endif `:F==="initialize-attribute-custom"?` #ifdef HAS_ATTRIBUTE_a_${Z} ${z} ${W} ${Z} = a_${Z}; #endif `:ce==="vec4"||ce==="uvec4"?` #ifndef HAS_UNIFORM_u_${Z} #ifdef ${ne} ${z} ${W} ${Z} = ${ie}; #else ${z} ${W} ${Z} = a_${Z}; #endif #else ${z} ${W} ${Z} = u_${Z}; #endif `:` #ifndef HAS_UNIFORM_u_${Z} #ifdef ${ne} ${z} ${W} ${Z} = unpack_mix_${ce}(${ie}, u_${Z}_t); #else ${z} ${W} ${Z} = unpack_mix_${ce}(a_${Z}, u_${Z}_t); #endif #else ${z} ${W} ${Z} = u_${Z}; #endif `}),usedDefines:R,vertexIncludes:S,fragmentIncludes:j}}class TI{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffers=[],this.vao=null}bind(d,g,S,j,R,L,F,z){this.context=d;let W=this.boundPaintVertexBuffers.length!==j.length;for(let ne=0;!W&&ne{const Xe=Me.paint.get("hillshade-shadow-color"),$e=Me.paint.get("hillshade-shadow-color-use-theme").constantOr("default")==="none",Ke=Me.paint.get("hillshade-highlight-color"),De=Me.paint.get("hillshade-highlight-color-use-theme").constantOr("default")==="none",Be=Me.paint.get("hillshade-accent-color"),Ge=Me.paint.get("hillshade-accent-color-use-theme").constantOr("default")==="none",ot=Me.paint.get("hillshade-emissive-strength");let Je=a.ap(Me.paint.get("hillshade-illumination-direction"));if(Me.paint.get("hillshade-illumination-anchor")==="viewport")Je-=_e.transform.angle;else if(_e.style&&_e.style.enable3dLights()&&_e.style.directionalLight){const pt=_e.style.directionalLight.properties.get("direction"),Ot=a.cP(pt.x,pt.y,pt.z);Je=a.ap(Ot[1])}const St=!_e.options.moving;return{u_matrix:Te||_e.transform.calculateProjMatrix(Re.tileID.toUnwrapped(),St),u_image:0,u_latrange:XE(0,Re.tileID),u_light:[Me.paint.get("hillshade-exaggeration"),Je],u_shadow:Xe.toPremultipliedRenderColor($e?null:Me.lut),u_highlight:Ke.toPremultipliedRenderColor(De?null:Me.lut),u_emissive_strength:ot,u_accent:Be.toPremultipliedRenderColor(Ge?null:Me.lut)}})(v,g,S,v.terrain?d.projMatrix:null);v.uploadCommonUniforms(F,re,d.toUnwrapped());const{tileBoundsBuffer:ce,tileBoundsIndexBuffer:le,tileBoundsSegments:ve}=v.getTileBoundsBuffers(g);re.draw(v,z.TRIANGLES,j,R,L,Zr.disabled,ie,S.id,ce,le,ve)}function EI(v,d,g){if(!d.needsDEMTextureUpload)return;const S=v.context,j=S.gl;S.pixelStoreUnpackPremultiplyAlpha.set(!1),d.demTexture=d.demTexture||v.getTileTexture(g.stride);const R=g.getPixels();d.demTexture?d.demTexture.update(R,{premultiply:!1}):d.demTexture=new a.T(S,R,j.R32F,{premultiply:!1}),d.needsDEMTextureUpload=!1}function Y5(v,d,g){const S=v.context,j=S.gl;if(!d.dem)return;const R=d.dem;if(S.activeTexture.set(j.TEXTURE1),EI(v,d,R),!d.demTexture)return;d.demTexture.bind(j.NEAREST,j.CLAMP_TO_EDGE);const L=R.dim;S.activeTexture.set(j.TEXTURE0);let F=d.hillshadeFBO;if(!F){const re=new a.T(S,{width:L,height:L,data:null},j.RGBA8);re.bind(j.LINEAR,j.CLAMP_TO_EDGE),F=d.hillshadeFBO=S.createFramebuffer(L,L,1,"renderbuffer"),F.colorAttachment0.set(re.texture)}S.bindFramebuffer.set(F.framebuffer),S.viewport.set([0,0,L,L]);const{tileBoundsBuffer:z,tileBoundsIndexBuffer:W,tileBoundsSegments:Z}=v.getMercatorTileBoundsBuffers(),ne=[];v.linearFloatFilteringSupported()&&ne.push("TERRAIN_DEM_FLOAT_FORMAT"),v.terrain&&v.terrain.renderingToTexture&&v.emissiveMode==="mrt-fallback"&&ne.push("USE_MRT1"),v.getOrCreateProgram("hillshadePrepare",{defines:ne}).draw(v,j.TRIANGLES,Lr.disabled,an.disabled,tn.unblended,Zr.disabled,((re,ie)=>{const ce=ie.stride,le=a.bb();return a.bT(le,0,a.an,-a.an,0,0,1),a.bx(le,le,[0,-a.an,0]),{u_matrix:le,u_image:1,u_dimension:[ce,ce],u_zoom:re.overscaledZ}})(d.tileID,R),g.id,z,W,Z),d.needsHillshadePrepare=!1}class yi{constructor(d){this.gl=d.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(d){}getDefault(){return this.default}setDefault(){this.set(this.default)}}class jI extends yi{getDefault(){return a.aq.transparent.toNonPremultipliedRenderColor(null)}set(d){const g=this.current;(d.r!==g.r||d.g!==g.g||d.b!==g.b||d.a!==g.a||this.dirty)&&(this.gl.clearColor(d.r,d.g,d.b,d.a),this.current=d,this.dirty=!1)}}class Z5 extends yi{getDefault(){return 1}set(d){(d!==this.current||this.dirty)&&(this.gl.clearDepth(d),this.current=d,this.dirty=!1)}}class Pb extends yi{getDefault(){return 0}set(d){(d!==this.current||this.dirty)&&(this.gl.clearStencil(d),this.current=d,this.dirty=!1)}}class X5 extends yi{getDefault(){return[!0,!0,!0,!0]}set(d){const g=this.current;(d[0]!==g[0]||d[1]!==g[1]||d[2]!==g[2]||d[3]!==g[3]||this.dirty)&&(this.gl.colorMask(d[0],d[1],d[2],d[3]),this.current=d,this.dirty=!1)}}class kI extends yi{getDefault(){return!0}set(d){(d!==this.current||this.dirty)&&(this.gl.depthMask(d),this.current=d,this.dirty=!1)}}class QE extends yi{getDefault(){return 255}set(d){(d!==this.current||this.dirty)&&(this.gl.stencilMask(d),this.current=d,this.dirty=!1)}}class Rb extends yi{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(d){const g=this.current;(d.func!==g.func||d.ref!==g.ref||d.mask!==g.mask||this.dirty)&&(this.gl.stencilFunc(d.func,d.ref,d.mask),this.current=d,this.dirty=!1)}}class JE extends yi{getDefault(){const d=this.gl;return[d.KEEP,d.KEEP,d.KEEP]}set(d){const g=this.current;(d[0]!==g[0]||d[1]!==g[1]||d[2]!==g[2]||this.dirty)&&(this.gl.stencilOp(d[0],d[1],d[2]),this.current=d,this.dirty=!1)}}class wp extends yi{getDefault(){return!1}set(d){if(d===this.current&&!this.dirty)return;const g=this.gl;d?g.enable(g.STENCIL_TEST):g.disable(g.STENCIL_TEST),this.current=d,this.dirty=!1}}class Sp extends yi{getDefault(){return[0,1]}set(d){const g=this.current;(d[0]!==g[0]||d[1]!==g[1]||this.dirty)&&(this.gl.depthRange(d[0],d[1]),this.current=d,this.dirty=!1)}}class oy extends yi{getDefault(){return!1}set(d){if(d===this.current&&!this.dirty)return;const g=this.gl;d?g.enable(g.DEPTH_TEST):g.disable(g.DEPTH_TEST),this.current=d,this.dirty=!1}}class Kd extends yi{getDefault(){return this.gl.LESS}set(d){(d!==this.current||this.dirty)&&(this.gl.depthFunc(d),this.current=d,this.dirty=!1)}}class AI extends yi{getDefault(){return!1}set(d){if(d===this.current&&!this.dirty)return;const g=this.gl;d?g.enable(g.BLEND):g.disable(g.BLEND),this.current=d,this.dirty=!1}}class ej extends yi{getDefault(){const d=this.gl;return[d.ONE,d.ZERO,d.ONE,d.ZERO]}set(d){const g=this.current;(d[0]!==g[0]||d[1]!==g[1]||d[2]!==g[2]||d[3]!==g[3]||this.dirty)&&(this.gl.blendFuncSeparate(d[0],d[1],d[2],d[3]),this.current=d,this.dirty=!1)}}class NI extends yi{getDefault(){return a.aq.transparent.toNonPremultipliedRenderColor(null)}set(d){const g=this.current;(d.r!==g.r||d.g!==g.g||d.b!==g.b||d.a!==g.a||this.dirty)&&(this.gl.blendColor(d.r,d.g,d.b,d.a),this.current=d,this.dirty=!1)}}class ly extends yi{getDefault(){return this.gl.FUNC_ADD}set(d){(d!==this.current||this.dirty)&&(this.gl.blendEquationSeparate(d,d),this.current=d,this.dirty=!1)}}class Lb extends yi{getDefault(){return!1}set(d){if(d===this.current&&!this.dirty)return;const g=this.gl;d?g.enable(g.CULL_FACE):g.disable(g.CULL_FACE),this.current=d,this.dirty=!1}}class Mb extends yi{getDefault(){return this.gl.BACK}set(d){(d!==this.current||this.dirty)&&(this.gl.cullFace(d),this.current=d,this.dirty=!1)}}class tj extends yi{getDefault(){return this.gl.CCW}set(d){(d!==this.current||this.dirty)&&(this.gl.frontFace(d),this.current=d,this.dirty=!1)}}let Db=class extends yi{getDefault(){return null}set(v){(v!==this.current||this.dirty)&&(this.gl.useProgram(v),this.current=v,this.dirty=!1)}};class q0 extends yi{getDefault(){return this.gl.TEXTURE0}set(d){(d!==this.current||this.dirty)&&(this.gl.activeTexture(d),this.current=d,this.dirty=!1)}}class CI extends yi{getDefault(){const d=this.gl;return[0,0,d.drawingBufferWidth,d.drawingBufferHeight]}set(d){const g=this.current;(d[0]!==g[0]||d[1]!==g[1]||d[2]!==g[2]||d[3]!==g[3]||this.dirty)&&(this.gl.viewport(d[0],d[1],d[2],d[3]),this.current=d,this.dirty=!1)}}class II extends yi{getDefault(){return null}set(d){if(d===this.current&&!this.dirty)return;const g=this.gl;g.bindFramebuffer(g.FRAMEBUFFER,d),this.current=d,this.dirty=!1}}class PI extends yi{getDefault(){return null}set(d){if(d===this.current&&!this.dirty)return;const g=this.gl;g.bindRenderbuffer(g.RENDERBUFFER,d),this.current=d,this.dirty=!1}}class cy extends yi{getDefault(){return null}set(d){if(d===this.current&&!this.dirty)return;const g=this.gl;g.bindTexture(g.TEXTURE_2D,d),this.current=d,this.dirty=!1}}class RI extends yi{getDefault(){return null}set(d){if(d===this.current&&!this.dirty)return;const g=this.gl;g.bindBuffer(g.ARRAY_BUFFER,d),this.current=d,this.dirty=!1}}class Q5 extends yi{getDefault(){return null}set(d){const g=this.gl;g.bindBuffer(g.ELEMENT_ARRAY_BUFFER,d),this.current=d,this.dirty=!1}}class J5 extends yi{getDefault(){return null}set(d){this.gl&&(d!==this.current||this.dirty)&&(this.gl.bindVertexArray(d),this.current=d,this.dirty=!1)}}class eB extends yi{getDefault(){return 4}set(d){if(d===this.current&&!this.dirty)return;const g=this.gl;g.pixelStorei(g.UNPACK_ALIGNMENT,d),this.current=d,this.dirty=!1}}class rj extends yi{getDefault(){return!1}set(d){if(d===this.current&&!this.dirty)return;const g=this.gl;g.pixelStorei(g.UNPACK_PREMULTIPLY_ALPHA_WEBGL,d),this.current=d,this.dirty=!1}}class nj extends yi{getDefault(){return!1}set(d){if(d===this.current&&!this.dirty)return;const g=this.gl;g.pixelStorei(g.UNPACK_FLIP_Y_WEBGL,d),this.current=d,this.dirty=!1}}class G0 extends yi{constructor(d,g){super(d),this.context=d,this.parent=g}getDefault(){return null}}class uy extends G0{constructor(d,g,S=0){super(d,g),this.attachmentPoint=d.gl.COLOR_ATTACHMENT0+S}setDirty(){this.dirty=!0}set(d){if(d===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const g=this.gl;g.framebufferTexture2D(g.FRAMEBUFFER,this.attachmentPoint,g.TEXTURE_2D,d,0),this.current=d,this.dirty=!1}}class sj extends G0{attachment(){return this.gl.DEPTH_ATTACHMENT}set(d){if(d===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const g=this.gl;g.framebufferRenderbuffer(g.FRAMEBUFFER,this.attachment(),g.RENDERBUFFER,d),this.current=d,this.dirty=!1}}class LI extends G0{attachment(){return this.gl.DEPTH_ATTACHMENT}set(d){if(d===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const g=this.gl;g.framebufferTexture2D(g.FRAMEBUFFER,this.attachment(),g.TEXTURE_2D,d,0),this.current=d,this.dirty=!1}}class tB extends sj{attachment(){return this.gl.DEPTH_STENCIL_ATTACHMENT}}const H0=(v,d,g,S)=>({u_matrix:v,u_image0:0,u_image1:1,u_skirt_height:d,u_ground_shadow_factor:g,u_emissive_texture_available:S}),dy=(v,d,g,S,j,R,L,F,z,W,Z,ne,re,ie,ce,le,ve)=>({u_proj_matrix:Float32Array.from(v),u_globe_matrix:d,u_normalize_matrix:Float32Array.from(S),u_merc_matrix:g,u_zoom_transition:j,u_merc_center:R,u_image0:0,u_image1:1,u_frustum_tl:L,u_frustum_tr:F,u_frustum_br:z,u_frustum_bl:W,u_globe_pos:Z,u_globe_radius:ne,u_viewport:re,u_grid_matrix:ve?Float32Array.from(ve):new Float32Array(9),u_skirt_height:ie,u_far_z_cutoff:ce,u_emissive_texture_available:le});function ij(v,d){return v!=null&&d!=null&&!(!v.hasData()||!d.hasData())&&v.demTexture!=null&&d.demTexture!=null&&v.tileID.key!==d.tileID.key}const Yo=new class{constructor(){this.operations={}}newMorphing(v,d,g,S,j){if(v in this.operations){const R=this.operations[v];R.to.tileID.key!==g.tileID.key&&(R.queued=g)}else this.operations[v]={startTime:S,phase:0,duration:j,from:d,to:g,queued:null}}getMorphValuesForProxy(v){if(!(v in this.operations))return null;const d=this.operations[v];return{from:d.from,to:d.to,phase:d.phase}}update(v){for(const d in this.operations){const g=this.operations[d];for(g.phase=(v-g.startTime)/g.duration;g.phase>=1||!this._validOp(g);)if(!this._nextOp(g,v)){delete this.operations[d];break}}}_nextOp(v,d){return!!v.queued&&(v.from=v.to,v.to=v.queued,v.queued=null,v.phase=0,v.startTime=d,!0)}_validOp(v){return v.from.hasData()&&v.to.hasData()}},Ob={0:null,1:"TERRAIN_VERTEX_MORPHING"};function W0(v,d,g){if(d===0)return 0;const S=d<1&&g===514?.25/d:1;return 6*Math.pow(1.5,22-v)*Math.max(d,1)*S}function Fb(v,d){const g=1<({u_matrix:v});function Z0(v,d,g,S,j){if(j>0){const R=a.o.now(),L=(R-v.timeAdded)/j,F=d?(R-d.timeAdded)/j:-1,z=g.getSource(),W=S.coveringZoomLevel({tileSize:z.tileSize,roundZoom:z.roundZoom}),Z=!d||Math.abs(d.tileID.overscaledZ-W)>Math.abs(v.tileID.overscaledZ-W),ne=Z&&v.refreshedUponExpiration?1:a.aC(Z?L:1-F,0,1);return d?{opacity:1,mix:1-ne,isFading:L<1}:{opacity:ne,mix:0,isFading:L<1}}return{opacity:1,mix:0,isFading:!1}}class Bb extends Nu{constructor(d){const g={type:"raster-dem",maxzoom:Math.ceil(d.transform.maxZoom)},S=yb("mock-dem",g,d.style.dispatcher,d.style);super("mock-dem",S,null),S.setEventedParent(this),this._sourceLoaded=!0}_loadTile(d,g){d.state="loaded",g(null)}}class aj extends Nu{constructor(d){const g=yb("proxy",{type:"geojson",maxzoom:Math.ceil(d.transform.maxZoom)},d.style.dispatcher,d.style);super("proxy",g,null),g.setEventedParent(this),this.map=this.getSource().map=d,this.used=this._sourceLoaded=!0,this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}update(d,g,S){if(d.freezeTileCoverage)return;this.transform=d;const j=d.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}).reduce((R,L)=>{if(R[L.key]="",!this._tiles[L.key]){const F=new a.b0(L,this._source.tileSize*L.overscaleFactor(),d.tileZoom,void 0,void 0,this._source.worldview);F.state="loaded",this._tiles[L.key]=F}return R},{});for(const R in this._tiles)R in j||(this.freeFBO(R),this._tiles[R].unloadVectorData(),delete this._tiles[R])}freeFBO(d){const g=this.proxyCachedFBO[d];if(g!==void 0){const S=Object.values(g);this.renderCachePool.push(...S),delete this.proxyCachedFBO[d]}}deallocRenderCache(){this.renderCache.forEach(d=>d.fb.destroy()),this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}}class $b extends a.aR{constructor(d,g,S){super(d.overscaledZ,d.wrap,d.canonical.z,d.canonical.x,d.canonical.y),this.proxyTileKey=g,this.projMatrix=S}}class X0 extends a.bu{constructor(d,g){super(),this._debugParams={sortTilesHiZFirst:!0,disableRenderCache:!1},this.painter=d,this.terrainTileForTile={},this.prevTerrainTileForTile={};const[S,j,R]=function(){const z=new a.dB,W=new a.dC,Z=131;z.reserve(17161),W.reserve(33800);const ne=a.an/128,re=a.an+ne/2,ie=re+ne;for(let le=-ne;lere||le<0||le>re?24575:0,Re=a.aC(Math.round(ve),0,a.an),Me=a.aC(Math.round(le),0,a.an);z.emplaceBack(Re+_e,Me)}const ce=(le,ve)=>{const _e=ve*Z+le;W.emplaceBack(_e+1,_e,_e+Z),W.emplaceBack(_e+Z,_e+Z+1,_e+1)};for(let le=1;le<129;le++)for(let ve=1;ve<129;ve++)ce(ve,le);return[0,129].forEach(le=>{for(let ve=0;ve<130;ve++)ce(ve,le),ce(le,ve)}),[z,W,32768]}(),L=d.context;this.gridBuffer=L.createVertexBuffer(S,a.dx.members),this.gridIndexBuffer=L.createIndexBuffer(j),this.gridSegments=a.dy.simpleSegment(0,0,S.length,j.length),this.gridNoSkirtSegments=a.dy.simpleSegment(0,0,S.length,R),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new aj(g.map),this.orthoMatrix=a.bb(),a.bT(this.orthoMatrix,this.painter.transform.projection.name==="globe"?.015:0,a.an,0,a.an,0,1);const F=L.gl;this._overlapStencilMode=new an({func:F.GEQUAL,mask:255},0,255,F.KEEP,F.KEEP,F.REPLACE),this._previousZoom=d.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=g,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new Bb(g.map),this._pendingGroundEffectLayers=[],this._emissiveTexture=!1}set style(d){d.on("data",this._onStyleDataEvent.bind(this)),this._style=d,this._style.map.on("moveend",()=>{this._clearLineLayersFromRenderCache()})}update(d,g,S){if(d&&d.terrain){this._style!==d&&(this.style=d,this._evaluationZoom=void 0);const j=d.terrain.properties,R=d.terrain.drapeRenderMode===0,L=d.terrain.isZoomDependent();this._previousUpdateTimestamp=this.enabled?this._updateTimestamp:void 0,this._updateTimestamp=a.o.now();const F=d.terrain&&d.terrain.scope,z=j.get("source"),W=R?this._mockSourceCache:d.getSourceCache(z,F);if(!W)return void a.w(`Couldn't find terrain source "${z}".`);if(this.sourceCache=W,this._attenuationRange=d.terrain.getAttenuationRange(),this._exaggeration=L?this.calculateExaggeration(g):j.get("exaggeration"),!g.projection.requiresDraping&&L&&this._exaggeration===0)return void this._disable();this.enabled=!0;const Z=()=>{this.sourceCache.used&&a.w(`Raster DEM source '${this.sourceCache.id}' is used both for terrain and as layer source. This leads to lower resolution of hillshade. For full hillshade resolution but higher memory consumption, define another raster DEM source.`);const ne=this.getScaledDemTileSize();this.sourceCache.update(g,ne,!0),this.resetTileLookupCache(this.sourceCache.id)};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,Z(),this._initializing=!0),Z(),g.updateElevation(!0,S),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(g),this._emptyDEMTextureDirty=!0,this._previousZoom=g.zoom}else this._disable()}calculateExaggeration(d){if(this._attenuationRange&&d.zoom>=Math.ceil(this._attenuationRange[1]))return this._style.terrain.getExaggeration(d.zoom);const g=this._previousCameraAltitude,S=d.getFreeCameraOptions().position.z/d.pixelsPerMeter*d.worldSize;this._previousCameraAltitude=S;const j=g!=null?S-g:Number.MAX_VALUE;if(Math.abs(j)<2)return this._exaggeration;const R=d.zoom,L=this._style.terrain;if(!this._previousUpdateTimestamp)return L.getExaggeration(R);let F=R-this._previousZoom;const z=this._previousUpdateTimestamp;let W=R;this._evaluationZoom!=null&&(W=this._evaluationZoom,Math.abs(R-W)>.5&&(F=.5*(R-W+F)),F*j<0&&(W+=F)),this._evaluationZoom=W;const Z=L.getExaggeration(W),ne=Z===L.getExaggeration(Math.max(0,W-.1));if(ne&&Math.abs(Z-this._exaggeration)<.01)return Z;let re=Math.min(.1,.00375*(this._updateTimestamp-z));return(ne||Z<.1||Math.abs(F)<1e-4)&&(re=Math.min(.2,4*re)),a.am(this._exaggeration,Z,re)}resetTileLookupCache(d){this._findCoveringTileCache[d]={}}attenuationRange(){return this._attenuationRange}getDemUpscale(){return this.proxySourceCache.getSource().tileSize/128}getScaledDemTileSize(){return this.sourceCache.getSource().tileSize/128*this.proxySourceCache.getSource().tileSize}_onStyleDataEvent(d){d.dataType==="source"&&d.coord?this._clearRenderCacheForTile(d.sourceCacheId,d.coord):d.dataType==="style"&&(this.invalidateRenderCache=!0,this._evaluationZoom=void 0,this._previousUpdateTimestamp=void 0,this._previousCameraAltitude=void 0)}_disable(){if(this.enabled&&(this.enabled=!1,this._emptyDEMTextureDirty=!0,this._sharedDepthStencil=void 0,this._evaluationZoom=void 0,this._previousUpdateTimestamp=void 0,this.proxySourceCache.deallocRenderCache(),this._style))for(const d in this._style._mergedSourceCaches)this._style._mergedSourceCaches[d].usedForTerrain=!1}destroy(){this._disable(),this._emptyDEMTexture&&this._emptyDEMTexture.destroy(),this.pool.forEach(d=>d.fb.destroy()),this.pool=[],this.framebufferCopyTexture&&this.framebufferCopyTexture.destroy()}_source(){return this.enabled?this.sourceCache:null}isUsingMockSource(){return this.sourceCache===this._mockSourceCache}exaggeration(){return this.enabled?this._exaggeration:0}get visibleDemTiles(){return this._visibleDemTiles}get drapeBufferSize(){const d=2*this.proxySourceCache.getSource().tileSize;return[d,d]}set useVertexMorphing(d){this._useVertexMorphing=d}updateTileBinding(d){if(!this.enabled)return;this.prevTerrainTileForTile=this.terrainTileForTile;const g=this.proxySourceCache,S=this.painter.transform;this._initializing&&(this._initializing=S._centerAltitude===0&&this.getAtPointOrZero(a.ag.fromLngLat(S.center),-1)===-1,this._emptyDEMTextureDirty=!this._initializing);const j=this.proxyCoords=g.getIds().map(z=>{const W=g.getTileByID(z).tileID;return W.projMatrix=S.calculateProjMatrix(W.toUnwrapped()),W});(function(z,W){const Z=W.transform.pointCoordinate(W.transform.getCameraPoint()),ne=new a.P(Z.x,Z.y);z.sort((re,ie)=>{if(ie.overscaledZ-re.overscaledZ)return ie.overscaledZ-re.overscaledZ;const ce=new a.P(re.canonical.x+(1<{this.proxyToSource[z.key]={}}),this.terrainTileForTile={};const L=this._style._mergedSourceCaches;for(const z in L){const W=L[z];if(!W.used||(W!==this.sourceCache&&this.resetTileLookupCache(W.id),this._setupProxiedCoordsForOrtho(W,d[z],R),W.usedForTerrain))continue;const Z=d[z];(W.getSource().reparseOverscaled||W._isRasterElevatedOverTerrain)&&this._assignTerrainTiles(Z)}this.proxiedCoords[g.id]=j.map(z=>new $b(z,z.key,this.orthoMatrix)),this._assignTerrainTiles(j),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(R),this.renderingToTexture=!1;const F={};this._visibleDemTiles=[];for(const z of this.proxyCoords){const W=this.terrainTileForTile[z.key];if(!W)continue;const Z=W.tileID.key;Z in F||(this._visibleDemTiles.push(W),F[Z]=Z)}}_assignTerrainTiles(d){this._initializing||d.forEach(g=>{if(this.terrainTileForTile[g.key])return;const S=this._findTileCoveringTileID(g,this.sourceCache);S&&(this.terrainTileForTile[g.key]=S)})}_prepareDEMTextures(){const d=this.painter.context,g=d.gl;for(const S in this.terrainTileForTile){const j=this.terrainTileForTile[S],R=j.dem;!R||j.demTexture&&!j.needsDEMTextureUpload||(d.activeTexture.set(g.TEXTURE1),EI(this.painter,j,R))}}_prepareDemTileUniforms(d,g,S,j){if(!g||g.demTexture==null)return!1;const R=d.tileID.canonical,L=Math.pow(2,g.tileID.canonical.z-R.z),F=j||"";return S[`u_dem_tl${F}`]=[R.x*L%1,R.y*L%1],S[`u_dem_scale${F}`]=L,!0}get emptyDEMTexture(){return!this._emptyDEMTextureDirty&&this._emptyDEMTexture?this._emptyDEMTexture:this._updateEmptyDEMTexture()}_getLoadedAreaMinimum(){if(!this.enabled)return 0;let d=0;const g=this._visibleDemTiles.reduce((S,j)=>{if(!j.dem)return S;const R=j.dem.tree.minimums[0];return R>0&&d++,S+R},0);return d?g/d:0}_updateEmptyDEMTexture(){const d=this.painter.context,g=d.gl;d.activeTexture.set(g.TEXTURE2);const S=this._getLoadedAreaMinimum(),j=new a.dz({width:1,height:1},new Float32Array([S]));this._emptyDEMTextureDirty=!1;let R=this._emptyDEMTexture;return R?R.update(j,{premultiply:!1}):R=this._emptyDEMTexture=new a.T(d,j,g.R32F,{premultiply:!1}),R}setupElevationDraw(d,g,S){const j=this.painter.context,R=j.gl,L={u_dem:2,u_dem_prev:4,u_dem_tl:[0,0],u_dem_tl_prev:[0,0],u_dem_scale:0,u_dem_scale_prev:0,u_dem_size:0,u_dem_lerp:1,u_depth:3,u_depth_size_inv:[0,0],u_depth_range_unpack:[0,1],u_occluder_half_size:16,u_occlusion_depth_offset:-1e-4,u_exaggeration:0};L.u_exaggeration=this.exaggeration();let F=null,z=null,W=1;if(S&&S.morphing&&this._useVertexMorphing){const ie=S.morphing.srcDemTile,ce=S.morphing.dstDemTile;W=S.morphing.phase,ie&&ce&&(this._prepareDemTileUniforms(d,ie,L,"_prev")&&(z=ie),this._prepareDemTileUniforms(d,ce,L)&&(F=ce))}const Z=ie=>ie&&ie.demTexture&&this.painter.linearFloatFilteringSupported()?R.LINEAR:R.NEAREST;let ne=null;var re;if(this.enabled?z&&F?(ne=F.demTexture,j.activeTexture.set(R.TEXTURE4),z.demTexture.bind(Z(z),R.CLAMP_TO_EDGE),L.u_dem_lerp=W):(F=this.terrainTileForTile[d.tileID.key],ne=this._prepareDemTileUniforms(d,F,L)?F.demTexture:this.emptyDEMTexture):ne=this.emptyDEMTexture,j.activeTexture.set(R.TEXTURE2),ne&&(L.u_dem_size=(re=ne).size[0]===1?1:re.size[0]-2,ne.bind(Z(F),R.CLAMP_TO_EDGE)),this.painter.setupDepthForOcclusion(S&&S.useDepthForOcclusion,g,L),S&&S.useMeterToDem&&F){const ie=(1<{if(_e===pt)return;const Ot=[Ob[pt],"PROJECTION_GLOBE_VIEW"];Me&&Ot.push("CUSTOM_ANTIALIASING");const Ut=W.isTileAffectedByFog(St);ve=W.getOrCreateProgram("globeRaster",{defines:Ot,overrideFog:Ut}),_e=pt},Xe=W.colorModeForRenderPass(),$e=new Lr(le.LEQUAL,Lr.ReadWrite,W.depthRangeFor3D);Yo.update(ie);const Ke=a.dq(Re),De=[a.aH(Re.center.lng),a.aL(Re.center.lat)],Be=W.globeSharedBuffers,Ge=[Re.width*a.o.devicePixelRatio,Re.height*a.o.devicePixelRatio],ot=Float32Array.from(Re.globeMatrix),Je={useDenormalizedUpVectorScale:!0};{const St=W.transform,pt=W0(St.zoom,Z.exaggeration(),Z.sourceCache._source.tileSize);_e=-1;const Ot=le.TRIANGLES;for(const Ut of re){const ut=ne.getTile(Ut),st=an.disabled,vt=Z.prevTerrainTileForTile[Ut.key],Et=Z.terrainTileForTile[Ut.key];ij(vt,Et)&&Yo.newMorphing(Ut.key,vt,Et,ie,250),K0(W,ut.emissiveTexture),ce.activeTexture.set(le.TEXTURE0),ut.texture&&ut.texture.bind(le.LINEAR,le.CLAMP_TO_EDGE);const Nt=Yo.getMorphValuesForProxy(Ut.key),lr=Nt?1:0;Nt&&Object.assign(Je,{morphing:{srcDemTile:Nt.from,dstDemTile:Nt.to,phase:a.dn(Nt.phase)}});const Jt=a.dr(Ut.canonical),er=a.ds(Jt.getCenter().lat),zt=a.dt(Ut.canonical,Jt,er,St.worldSize/St._pixelsPerMercatorPixel),Ir=a.du(a.dv(Ut.canonical)),Or=W.emissiveMode==="mrt-fallback"?1:0,vr=dy(St.expandedFarZProjMatrix,ot,Ke,Ir,a.al(St.zoom),De,St.frustumCorners.TL,St.frustumCorners.TR,St.frustumCorners.BR,St.frustumCorners.BL,St.globeCenterInViewSpace,St.globeRadius,Ge,pt,St._farZ,Or,zt);if(Te(Ut,lr),ve&&(Z.setupElevationDraw(ut,ve,Je),W.uploadCommonUniforms(ce,ve,Ut.toUnwrapped()),Be)){const[Ar,Jr,dn]=Be.getGridBuffers(er,pt!==0);ve.draw(W,Ot,$e,st,Xe,Zr.backCCW,vr,"globe_raster",Ar,Jr,dn)}}}if(Be&&(W.renderDefaultNorthPole||W.renderDefaultSouthPole)){const St=["GLOBE_POLES","PROJECTION_GLOBE_VIEW"];Me&&St.push("CUSTOM_ANTIALIASING"),ve=W.getOrCreateProgram("globeRaster",{defines:St});for(const pt of re){const{x:Ot,y:Ut,z:ut}=pt.canonical,st=Ut===0,vt=Ut===(1<Ar.draw(W,le.TRIANGLES,$e,an.disabled,Xe,Zr.disabled,dy(Re.expandedFarZProjMatrix,zt,zt,Ir,0,De,Re.frustumCorners.TL,Re.frustumCorners.TR,Re.frustumCorners.BR,Re.frustumCorners.BL,Re.globeCenterInViewSpace,Re.globeRadius,Ge,0,Re._farZ,Or),"globe_pole_raster",Jr,lr,Jt);Z.setupElevationDraw(er,ve,Je),W.uploadCommonUniforms(ce,ve,pt.toUnwrapped()),st&&W.renderDefaultNorthPole&&vr(ve,Et),vt&&W.renderDefaultSouthPole&&(zt=a.cC(a.bb(),zt,[1,-1,1]),vr(ve,Nt))}}}})(j,R,L,F,z);else{const W=j.context,Z=W.gl;let ne,re;const ie=j.shadowRenderer,ce=Wa(j,j.longestCutoffRange),le=Xe=>{if(re===Xe)return;const $e=[];$e.push(Ob[Xe]),ce.shouldRenderCutoff&&$e.push("RENDER_CUTOFF"),ie&&($e.push("RENDER_SHADOWS"),ie.useNormalOffset&&$e.push("NORMAL_OFFSET")),ne=j.getOrCreateProgram("terrainRaster",{defines:$e}),re=Xe},ve=j.colorModeForRenderPass(),_e=new Lr(Z.LEQUAL,Lr.ReadWrite,j.depthRangeFor3D);Yo.update(z);const Re=j.transform,Me=W0(Re.zoom,R.exaggeration(),R.sourceCache._source.tileSize);let Te=[0,0,0];if(ie){const Xe=j.style.directionalLight,$e=j.style.ambientLight;Xe&&$e&&(Te=cd(j.style,Xe,$e))}{re=-1;const Xe=Z.TRIANGLES,[$e,Ke]=[R.gridIndexBuffer,R.gridSegments];for(const De of F){const Be=L.getTile(De),Ge=an.disabled,ot=R.prevTerrainTileForTile[De.key],Je=R.terrainTileForTile[De.key];ij(ot,Je)&&Yo.newMorphing(De.key,ot,Je,z,250),K0(j,Be.emissiveTexture),W.activeTexture.set(Z.TEXTURE0),Be.texture&&Be.texture.bind(Z.LINEAR,Z.CLAMP_TO_EDGE);const St=Yo.getMorphValuesForProxy(De.key),pt=St?1:0;let Ot;St&&(Ot={morphing:{srcDemTile:St.from,dstDemTile:St.to,phase:a.dn(St.phase)}});const Ut=j.emissiveMode==="mrt-fallback"?1:0,ut=H0(De.projMatrix,Fb(De.canonical,Re.renderWorldCopies)?Me/10:Me,Te,Ut);if(le(pt),!ne)continue;R.setupElevationDraw(Be,ne,Ot);const st=De.toUnwrapped();ie&&ie.setupShadows(st,ne),j.uploadCommonUniforms(W,ne,st,null,ce),ne.draw(j,Xe,_e,Ge,ve,Zr.backCCW,ut,"terrain_raster",R.gridBuffer,$e,Ke)}}}}(g,this,this.proxySourceCache,d,this._updateTimestamp),this.renderingToTexture=!0,g.gpuTimingDeferredRenderEnd(),d.splice(0,d.length))}renderBatch(d){if(this._drapedRenderBatches.length===0)return d+1;this.renderingToTexture=!0;const g=this.painter,S=this.painter.context,j=this.proxySourceCache,R=this.proxiedCoords[j.id],L=this._drapedRenderBatches.shift(),F=g.style.order,z=[];this._updateFBOs(g.emissiveMode==="mrt-fallback");let W=0;for(const Z of R){const ne=j.getTileByID(Z.proxyTileKey),re=j.proxyCachedFBO[Z.key]?j.proxyCachedFBO[Z.key][d]:void 0,ie=re!==void 0?j.renderCache[re]:this.pool[W++],ce=re!==void 0;if(ne.texture=ie.tex,ne.emissiveTexture=ie.emissiveTex,ce&&!ie.dirty){z.push(ne.tileID);continue}S.bindFramebuffer.set(ie.fb.framebuffer);const le=S.gl;let ve;le.drawBuffers(g.emissiveMode==="mrt-fallback"?[le.COLOR_ATTACHMENT0,le.COLOR_ATTACHMENT1]:[le.COLOR_ATTACHMENT0]),this.renderedToTile=!1,ie.dirty&&(S.clear({color:a.aq.transparent,stencil:0}),ie.dirty=!1);for(let _e=L.start;_e<=L.end;++_e){const Re=g.style._mergedLayers[F[_e]];if(Re.isHidden(g.transform.zoom))continue;const Me=g.style.getLayerSourceCache(Re),Te=Me?this.proxyToSource[Z.key][Me.id]:[Z];if(!Te)continue;const Xe=Te;S.viewport.set([0,0,ie.fb.width,ie.fb.height]),ve!==(Me?Me.id:null)&&(this._setupStencil(ie,Te,Re,Me),ve=Me?Me.id:null),g.renderLayer(g,Me,Re,Xe)}if(le.drawBuffers([le.COLOR_ATTACHMENT0]),this._drapedRenderBatches.length===0)for(const _e of this._pendingGroundEffectLayers){const Re=g.style._mergedLayers[F[_e]];if(Re.isHidden(g.transform.zoom))continue;const Me=g.style.getLayerSourceCache(Re),Te=Me?this.proxyToSource[Z.key][Me.id]:[Z];if(!Te)continue;const Xe=Te;S.viewport.set([0,0,ie.fb.width,ie.fb.height]),ve!==(Me?Me.id:null)&&(this._setupStencil(ie,Te,Re,Me),ve=Me?Me.id:null),g.renderLayer(g,Me,Re,Xe)}this.renderedToTile?(ie.dirty=!0,z.push(ne.tileID)):ce||--W,W===5&&(W=0,this.renderToBackBuffer(z))}return this.renderToBackBuffer(z),this.renderingToTexture=!1,S.bindFramebuffer.set(null),S.viewport.set([0,0,g.width,g.height]),L.end+1}postRender(){}isLayerOrderingCorrect(d){const g=d.order.length;let S=-1,j=g;for(let R=0;RS}getMinElevationBelowMSL(){let d=0;return this._visibleDemTiles.filter(g=>g.dem).forEach(g=>{d=Math.min(d,g.dem.tree.minimums[0])}),d===0?d:(d-30)*this._exaggeration}raycast(d,g,S){if(!this._visibleDemTiles)return null;const j=this._visibleDemTiles.filter(R=>R.dem).map(R=>{const L=R.tileID,F=1<(R.t!==null?R.t:Number.MAX_VALUE)-(L.t!==null?L.t:Number.MAX_VALUE));for(const R of j){if(R.t==null)return null;const L=R.tile.dem.tree.raycast(R.minx,R.miny,R.maxx,R.maxy,d,g,S);if(L!=null)return L}return null}_createFBO(){const d=this.painter.context,g=d.gl,S=this.drapeBufferSize;d.activeTexture.set(g.TEXTURE0);const j=new a.T(d,{width:S[0],height:S[1],data:null},g.RGBA8);j.bind(g.LINEAR,g.CLAMP_TO_EDGE);const R=d.createFramebuffer(S[0],S[1],1,null);let L;return R.colorAttachment0.set(j.texture),this._emissiveTexture&&(L=new a.T(d,{width:S[0],height:S[1],data:null},g.R8),L.bind(g.LINEAR,g.CLAMP_TO_EDGE),R.createColorAttachment(d,1),R.colorAttachment1.set(L.texture)),R.depthAttachment=new tB(d,R.framebuffer),this._sharedDepthStencil===void 0?(this._sharedDepthStencil=d.createRenderbuffer(d.gl.DEPTH_STENCIL,S[0],S[1]),this._stencilRef=0,R.depthAttachment.set(this._sharedDepthStencil),d.clear({stencil:0})):R.depthAttachment.set(this._sharedDepthStencil),d.extTextureFilterAnisotropic&&g.texParameterf(g.TEXTURE_2D,d.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,d.extTextureFilterAnisotropicMax),{fb:R,tex:j,emissiveTex:L,dirty:!1}}_updateFBOs(d){if(this._emissiveTexture!==d){for(const g of this.pool)this._updateFBO(g,d);for(const g of this.proxySourceCache.renderCache)this._updateFBO(g,d);this._emissiveTexture=d}}_updateFBO(d,g){const S=d.fb,j=this.painter.context,R=j.gl,L=this.drapeBufferSize;if(g){const F=new a.T(j,{width:L[0],height:L[1],data:null},R.R8);F.bind(R.LINEAR,R.CLAMP_TO_EDGE),d.emissiveTex=F,S.createColorAttachment(j,1),S.colorAttachment1.set(F.texture)}else d.emissiveTex=void 0,S.removeColorAttachment(j,1);d.dirty=!0}_initFBOPool(){for(;this.pool.length{const g=this._style._mergedLayers[d],S=g.isHidden(this.painter.transform.zoom);return g.type==="hillshade"||g.type==="custom"?!S&&g.shouldRedrape():!S&&g.hasTransition()})}_clearLineLayersFromRenderCache(){let d=!1;for(const S of this._style.getSources())if(S instanceof Kl){d=!0;break}if(!d)return;const g={};for(let S=0;Sz>F.end)||a.w("fill-extrusion with flood lighting and/or ground ambient occlusion should be moved to be on top of all draped layers.")}this._drapedRenderBatches=S}_setupRenderCache(d){const g=this.proxySourceCache;if(this._shouldDisableRenderCache()||this.invalidateRenderCache){if(this.invalidateRenderCache=!1,g.renderCache.length>g.renderCachePool.length){const L=Object.values(g.proxyCachedFBO);g.proxyCachedFBO={};for(let F=0;F=0;L--){const F=S[L];if(g.getTileByID(F.key),g.proxyCachedFBO[F.key]!==void 0){const z=d[F.key],W=this.proxyToSource[F.key];let Z=0;for(const ne in W){const re=W[ne],ie=z[ne];if(!ie||ie.length!==re.length||re.some((ce,le)=>ce!==ie[le]||j[ne]&&j[ne].hasOwnProperty(ce.key))){Z=-1;break}++Z}for(const ne in g.proxyCachedFBO[F.key])g.renderCache[g.proxyCachedFBO[F.key][ne]].dirty=Z<0||Z!==Object.values(z).length}}const R=[...this._drapedRenderBatches];R.sort((L,F)=>F.end-F.start-(L.end-L.start));for(const L of R)for(const F of S){if(g.proxyCachedFBO[F.key])continue;let z=g.renderCachePool.pop();z===void 0&&g.renderCache.length<50&&(z=g.renderCache.length,g.renderCache.push(this._createFBO())),z!==void 0&&(g.proxyCachedFBO[F.key]={},g.proxyCachedFBO[F.key][L.start]=z,g.renderCache[z].dirty=!0)}this._tilesDirty={}}_setupStencil(d,g,S,j){if(!j||!this._sourceTilesOverlap[j.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));const R=this.painter.context,L=R.gl;if(g.length<=1)return void(this._overlapStencilType=!1);let F;if(S.isTileClipped())F=g.length,this._overlapStencilMode.test={func:L.EQUAL,mask:255},this._overlapStencilType="Clip";else{if(!(g[0].overscaledZ>g[g.length-1].overscaledZ))return void(this._overlapStencilType=!1);F=1,this._overlapStencilMode.test={func:L.GREATER,mask:255},this._overlapStencilType="Mask"}this._stencilRef+F>255&&(R.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=F,this._overlapStencilMode.ref=this._stencilRef,S.isTileClipped()&&this._renderTileClippingMasks(g,this._overlapStencilMode.ref)}clipOrMaskOverlapStencilType(){return this._overlapStencilType==="Clip"||this._overlapStencilType==="Mask"}stencilModeForRTTOverlap(d){return this.renderingToTexture&&this._overlapStencilType?(this._overlapStencilType==="Clip"&&(this._overlapStencilMode.ref=this.painter._tileClippingMaskIDs[d.key]),this._overlapStencilMode):an.disabled}_renderTileClippingMasks(d,g){const S=this.painter,j=this.painter.context,R=j.gl;S._tileClippingMaskIDs={},j.setColorMode(tn.disabled),j.setDepthMode(Lr.disabled);const L=S.getOrCreateProgram("clippingMask");for(const F of d){const z=S._tileClippingMaskIDs[F.key]=--g;L.draw(S,R.TRIANGLES,Lr.disabled,new an({func:R.ALWAYS,mask:0},z,255,R.KEEP,R.KEEP,R.REPLACE),tn.disabled,Zr.disabled,Y0(F.projMatrix),"$clipping",S.tileExtentBuffer,S.quadTriangleIndexBuffer,S.tileExtentSegments)}}pointCoordinate(d){const g=this.painter.transform;if(d.x<0||d.x>g.width||d.y<0||d.y>g.height)return null;const S=[d.x,d.y,1,1];a.aE(S,S,g.pixelMatrixInverse),a.cu(S,S,1/S[3]),S[0]/=g.worldSize,S[1]/=g.worldSize;const j=g._camera.position,R=a.bU(1,g.center.lat),L=[j[0],j[1],j[2]/R,0],F=a.cV([],S.slice(0,3),L);a.ay(F,F);const z=this.raycast(L,F,this._exaggeration);return z!==null&&z?(a.bg(L,L,F,z),L[3]=L[2],L[2]*=R,L):null}_setupProxiedCoordsForOrtho(d,g,S){if(d.getSource()instanceof a.aV)return this._setupProxiedCoordsForImageSource(d,g,S);this._findCoveringTileCache[d.id]=this._findCoveringTileCache[d.id]||{};const j=this.proxiedCoords[d.id]=[],R=this.proxyCoords;for(let z=0;zZ.overscaledZ-W.overscaledZ)}_setupProxiedCoordsForImageSource(d,g,S){if(!d.getSource().loaded())return;const j=this.proxiedCoords[d.id]=[],R=this.proxyCoords,L=d.getSource(),F=L.tileID;if(!F)return;const z=new a.P(F.x,F.y)._div(1<(ne.min.x=Math.min(ne.min.x,re.x-z.x),ne.min.y=Math.min(ne.min.y,re.y-z.y),ne.max.x=Math.max(ne.max.x,re.x-z.x),ne.max.y=Math.max(ne.max.y,re.y-z.y),ne),{min:new a.P(Number.MAX_VALUE,Number.MAX_VALUE),max:new a.P(-Number.MAX_VALUE,-Number.MAX_VALUE)}),Z=(ne,re)=>{const ie=ne.wrap+ne.canonical.x/(1<ve+W.max.x||ce+le<_e+W.min.y||ce>_e+W.max.y};for(let ne=0;neL.key===g.tileID.key);if(R)return R}if(g.tileID.key!==d.key){const R=d.canonical.z-g.tileID.canonical.z;let L,F,z;j=a.bb();const W=g.tileID.wrap-d.wrap<0?(L=a.an>>R,F=L*((g.tileID.canonical.x<=ne){const re=d.canonical.z-ne;g.getSource().reparseOverscaled?(F=Math.max(d.canonical.z+2,g.transform.tileZoom),L=new a.aR(F,d.wrap,ne,d.canonical.x>>re,d.canonical.y>>re)):re!==0&&(F=ne,L=new a.aR(F,d.wrap,ne,d.canonical.x>>re,d.canonical.y>>re))}L.key!==d.key&&(W.push(L.key),S=g.getTile(L))}const Z=ne=>{W.forEach(re=>{j[re]=ne}),W.length=0};for(F-=1;F>=z&&(!S||!S.hasData());F--){S&&Z(S.tileID.key);const ne=L.calculateScaledKey(F);if(S=g.getTileByID(ne),S&&S.hasData())break;const re=j[ne];if(re===null)break;re===void 0?W.push(ne):S=g.getTileByID(re)}return Z(S?S.tileID.key:null),S&&S.hasData()?S:null}findDEMTileFor(d){return this.enabled?this._findTileCoveringTileID(d,this.sourceCache):null}prepareDrawTile(){this.renderedToTile=!0}_clearRenderCacheForTile(d,g){let S=this._tilesDirty[d];S||(S=this._tilesDirty[d]={}),S[g.key]=!0}}function oj(v,d,g){const S=function(F,z,W){const Z=a.bi(z,F),ne=a.bi(W,[.2126,.7152,.0722]),re=(ce,le,ve)=>(1-ve)*ce+ve*le,ie=re(1-.3*Math.min(ne,1),1,Math.min(Z+1,1));return re(.92,1,Math.asin(a.aC(z[2],-1,1))/Math.PI+.5)*ie}(v,[0,0,1],d),j=[0,0,0];a.bJ(j,g.slice(0,3),S);const R=[0,0,0];a.bJ(R,d.slice(0,3),v[2]);const L=[0,0,0];return a.cT(L,j,R),a.cW(L)}const MI=["fill","fillOutline","fillPattern","line","linePattern","background","backgroundPattern","hillshade","raster"],DI=["stars","rainParticle","snowParticle","fillExtrusion","fillExtrusionGroundEffect","building","buildingBloom","elevatedStructures","model","symbol"];class Tp{static cacheKey(d,g,S,j){const R=[g];j&&R.push(j.cacheKey);for(const L of S)(typeof L=="string"&&L.includes(" ")||d.usedDefines.has(L))&&R.push(L);return R.join("/")}constructor(d,g,S,j,R,L){const F=d.gl;this.program=F.createProgram(),this.configuration=j,this.name=g,this.fixedDefines=[...L];const z=`#version 300 es ${(j?j.defines():[]).concat(L.map(le=>`#define ${le}`)).join(` `)}`,W=[z,ay];for(const le of S.fragmentIncludes)W.push(ud[le]);W.push(S.fragmentSource);const Z=W.join(` `),ne=[z,W5];for(const le of S.vertexIncludes)ne.push(ud[le]);this.forceManualRenderingForInstanceIDShaders=d.forceManualRenderingForInstanceIDShaders&&S.vertexSource.includes("gl_InstanceID"),this.forceManualRenderingForInstanceIDShaders&&ne.push("uniform int u_instanceID;"),ne.push(S.vertexSource);let re=ne.join(` `);this.forceManualRenderingForInstanceIDShaders&&(re=re.replaceAll("gl_InstanceID","u_instanceID"));const ie=F.createShader(F.FRAGMENT_SHADER);if(F.isContextLost())return void(this.failedToCreate=!0);F.shaderSource(ie,Z),F.compileShader(ie),F.attachShader(this.program,ie);const ce=F.createShader(F.VERTEX_SHADER);F.isContextLost()?this.failedToCreate=!0:(F.shaderSource(ce,re),F.compileShader(ce),F.attachShader(this.program,ce),this.attributes={},F.linkProgram(this.program),F.deleteShader(ce),F.deleteShader(ie),this.fixedUniforms=R(d),this.fixedUniformsEntries=Object.entries(this.fixedUniforms),this.binderUniforms=j?j.getUniforms(d):[],this.forceManualRenderingForInstanceIDShaders&&(this.instancingUniforms=(le=>({u_instanceID:new a.bX(le)}))(d)),(L.includes("TERRAIN")||L.includes("ELEVATED")||g.includes("symbol")||g.includes("circle"))&&(this.terrainUniforms=(le=>({u_dem:new a.bX(le),u_dem_prev:new a.bX(le),u_dem_tl:new a.b_(le),u_dem_scale:new a.bZ(le),u_dem_tl_prev:new a.b_(le),u_dem_scale_prev:new a.bZ(le),u_dem_size:new a.bZ(le),u_dem_lerp:new a.bZ(le),u_exaggeration:new a.bZ(le),u_depth:new a.bX(le),u_depth_size_inv:new a.b_(le),u_depth_range_unpack:new a.b_(le),u_occluder_half_size:new a.bZ(le),u_occlusion_depth_offset:new a.bZ(le),u_meter_to_dem:new a.bZ(le),u_label_plane_matrix_inv:new a.b$(le)}))(d)),L.includes("GLOBE")&&(this.globeUniforms=(le=>({u_tile_tl_up:new a.bY(le),u_tile_tr_up:new a.bY(le),u_tile_br_up:new a.bY(le),u_tile_bl_up:new a.bY(le),u_tile_up_scale:new a.bZ(le)}))(d)),L.includes("FOG")&&(this.fogUniforms=(le=>({u_fog_matrix:new a.b$(le),u_fog_range:new a.b_(le),u_fog_color:new a.cO(le),u_fog_horizon_blend:new a.bZ(le),u_fog_vertical_limit:new a.b_(le),u_fog_temporal_offset:new a.bZ(le),u_frustum_tl:new a.bY(le),u_frustum_tr:new a.bY(le),u_frustum_br:new a.bY(le),u_frustum_bl:new a.bY(le),u_globe_pos:new a.bY(le),u_globe_radius:new a.bZ(le),u_globe_transition:new a.bZ(le),u_is_globe:new a.bX(le),u_viewport:new a.b_(le)}))(d)),L.includes("RENDER_CUTOFF")&&(this.cutoffUniforms=(le=>({u_cutoff_params:new a.cO(le)}))(d)),L.includes("LIGHTING_3D_MODE")&&(this.lightsUniforms=(le=>({u_lighting_ambient_color:new a.bY(le),u_lighting_directional_dir:new a.bY(le),u_lighting_directional_color:new a.bY(le),u_ground_radiance:new a.bY(le)}))(d)),L.includes("RENDER_SHADOWS")&&(this.shadowUniforms=(le=>({u_light_matrix_0:new a.b$(le),u_light_matrix_1:new a.b$(le),u_fade_range:new a.b_(le),u_shadow_normal_offset:new a.bY(le),u_shadow_intensity:new a.bZ(le),u_shadow_texel_size:new a.bZ(le),u_shadow_map_resolution:new a.bZ(le),u_shadow_direction:new a.bY(le),u_shadow_bias:new a.bY(le),u_shadowmap_0:new a.bX(le),u_shadowmap_1:new a.bX(le)}))(d)))}getAttributeLocation(d,g){let S=this.attributes[g];return S===void 0&&(S=this.attributes[g]=d.getAttribLocation(this.program,g)),S}setTerrainUniformValues(d,g){if(!this.terrainUniforms)return;const S=this.terrainUniforms;if(!this.failedToCreate){d.program.set(this.program);for(const j in g)S[j]&&S[j].set(this.program,j,g[j])}}setGlobeUniformValues(d,g){if(!this.globeUniforms)return;const S=this.globeUniforms;if(!this.failedToCreate){d.program.set(this.program);for(const j in g)S[j]&&S[j].set(this.program,j,g[j])}}setFogUniformValues(d,g){if(!this.fogUniforms)return;const S=this.fogUniforms;if(!this.failedToCreate){d.program.set(this.program);for(const j in g)S[j].set(this.program,j,g[j])}}setCutoffUniformValues(d,g){if(!this.cutoffUniforms)return;const S=this.cutoffUniforms;if(!this.failedToCreate){d.program.set(this.program);for(const j in g)S[j].set(this.program,j,g[j])}}setLightsUniformValues(d,g){if(!this.lightsUniforms)return;const S=this.lightsUniforms;if(!this.failedToCreate){d.program.set(this.program);for(const j in g)S[j].set(this.program,j,g[j])}}setShadowUniformValues(d,g){if(this.failedToCreate||!this.shadowUniforms)return;const S=this.shadowUniforms;d.program.set(this.program);for(const j in g)S[j].set(this.program,j,g[j])}_drawDebugWireframe(d,g,S,j,R,L,F,z,W,Z){const ne=d.options.wireframe;if(ne.terrain===!1&&ne.layers2D===!1&&ne.layers3D===!1)return;const re=d.context;if(!(!(!ne.terrain||this.name!=="terrainRaster"&&this.name!=="globeRaster")||!(!ne.layers2D||d._terrain&&d._terrain.renderingToTexture||!MI.includes(this.name))||!(!ne.layers3D||!DI.includes(this.name))))return;const ie=re.gl,ce=d.wireframeDebugCache.getLinesFromTrianglesBuffer(d.frameCounter,R,re);if(!ce)return;const le=[...this.fixedDefines,"DEBUG_WIREFRAME"],ve=d.getOrCreateProgram(this.name,{config:this.configuration,defines:le});re.program.set(ve.program);const _e=(Te,Xe,$e)=>{if(Xe[Te]&&$e[Te])for(const Ke in Xe[Te])$e[Te][Ke]&&$e[Te][Ke].set($e.program,Ke,Xe[Te][Ke].current)};W&&W.setUniforms(ve.program,re,ve.binderUniforms,F,{zoom:z}),_e("fixedUniforms",this,ve),_e("terrainUniforms",this,ve),_e("globeUniforms",this,ve),_e("fogUniforms",this,ve),_e("lightsUniforms",this,ve),_e("shadowUniforms",this,ve),ce.bind(),re.setColorMode(new tn([ie.ONE,ie.ONE_MINUS_SRC_ALPHA,ie.ZERO,ie.ONE],a.aq.transparent,[!0,!0,!0,!1])),re.setDepthMode(new Lr(g.func===ie.LESS?ie.LEQUAL:g.func,Lr.ReadOnly,g.range)),re.setStencilMode(an.disabled);const Re=3*L.primitiveLength*2,Me=3*L.primitiveOffset*2*2;if(this.forceManualRenderingForInstanceIDShaders){const Te=Z||1;for(let Xe=0;Xe1?ie.drawElementsInstanced(ie.LINES,Re,ie.UNSIGNED_SHORT,Me,Z):ie.drawElements(ie.LINES,Re,ie.UNSIGNED_SHORT,Me);R.bind(),re.program.set(this.program),re.setDepthMode(g),re.setStencilMode(S),re.setColorMode(j)}checkUniforms(d,g,S){if(this.fixedDefines.includes(g)){for(const j of Object.keys(S))if(!S[j].initialized)throw new Error(`Program '${this.name}', from draw '${d}': uniform ${j} not set but required by ${g} being defined`)}}draw(d,g,S,j,R,L,F,z,W,Z,ne,re,ie,ce,le,ve){const _e=d.context,Re=_e.gl;if(this.failedToCreate)return;_e.program.set(this.program),_e.setDepthMode(S),_e.setStencilMode(j),_e.setColorMode(R),_e.setCullFace(L);for(const[De,Be]of this.fixedUniformsEntries)Be.set(this.program,De,F[De]);ce&&ce.setUniforms(this.program,_e,this.binderUniforms,re,{zoom:ie});const Me={[Re.POINTS]:1,[Re.LINES]:2,[Re.TRIANGLES]:3,[Re.LINE_STRIP]:1}[g];this.checkUniforms(z,"RENDER_SHADOWS",this.shadowUniforms);const Te=le||[],Xe=ce?ce.getPaintVertexBuffers():[],$e=g===Re.TRIANGLES&&Z,Ke=ve&&ve>0?1:void 0;for(const De of ne.get()){const Be=De.vaos||(De.vaos={});if((Be[z]||(Be[z]=new TI)).bind(_e,this,W,Xe,Z,De.vertexOffset,Te,Ke),this.forceManualRenderingForInstanceIDShaders){const Ge=ve||1;for(let ot=0;ot1?Re.drawElementsInstanced(g,De.primitiveLength*Me,Re.UNSIGNED_SHORT,De.primitiveOffset*Me*2,ve):Z?Re.drawElements(g,De.primitiveLength*Me,Re.UNSIGNED_SHORT,De.primitiveOffset*Me*2):Re.drawArrays(g,De.vertexOffset,De.vertexLength);$e&&this._drawDebugWireframe(d,S,j,R,Z,De,re,ie,ce,ve)}}}function OI(v,d,g=0){const S=Math.pow(2,d.tileID.overscaledZ),j=d.tileSize*Math.pow(2,v.transform.tileZoom)/S,R=j*(d.tileID.canonical.x+d.tileID.wrap*S),L=j*d.tileID.canonical.y;return{u_image:0,u_texsize:d.imageAtlasTexture?d.imageAtlasTexture.size:[0,0],u_tile_units_to_pixels:1/a.aA(d,1,v.transform.tileZoom),u_pixel_coord_upper:[R>>16,L>>16],u_pixel_coord_lower:[65535&R,65535&L],u_pattern_transition:g}}const zb={terrain:0,flat:1},rB=a.bb(),FI=(v,d,g,S,j,R,L,F,z,W,Z,ne,re,ie,ce,le,ve,_e,Re=[0,0,1])=>{const Me=d.style.light,Te=Me.properties.get("position"),Xe=[Te.x,Te.y,Te.z],$e=a.dE();Me.properties.get("anchor")==="viewport"&&(a.dF($e,-d.transform.angle),a.dG(Xe,Xe,$e));const Ke=Me.properties.get("color").toPremultipliedRenderColor(null),De=d.transform,Be={u_matrix:v,u_lightpos:Xe,u_lightintensity:Me.properties.get("intensity"),u_lightcolor:[Ke.r,Ke.g,Ke.b],u_vertical_gradient:+g,u_opacity:S,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:rB,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0,u_height_type:zb[W],u_base_type:zb[Z],u_ao:j,u_edge_radius:R,u_width_scale:L,u_flood_light_color:ce,u_vertical_scale:le,u_flood_light_intensity:ve,u_ground_shadow_factor:_e,u_front_cutoff_params:Re};return De.projection.name==="globe"&&(Be.u_tile_id=[F.canonical.x,F.canonical.y,1<({u_matrix:v,u_edge_radius:d,u_width_scale:g,u_vertical_scale:S,u_height_type:zb[j],u_base_type:zb[R]}),sB=(v,d,g,S,j,R,L,F,z,W,Z,ne,re,ie,ce,le,ve,_e)=>{const Re=FI(v,d,g,S,j,R,L,F,W,Z,ne,re,ie,ce,le,ve,1,[0,0,0]),Me={u_height_factor:-Math.pow(2,F.overscaledZ)/z.tileSize/8};return Object.assign(Re,OI(d,z,_e),Me)},Ub=(v,d,g)=>({u_matrix:v,u_emissive_strength:d,u_ground_shadow_factor:g}),Vb=(v,d,g,S,j,R=0)=>Object.assign(Ub(v,d,j),OI(g,S,R)),BI=(v,d,g,S)=>({u_matrix:v,u_world:g,u_emissive_strength:d,u_ground_shadow_factor:S}),hy=(v,d,g,S,j,R,L=0)=>Object.assign(Vb(v,d,g,S,R,L),{u_world:j}),$I=(v,d)=>({u_matrix:v,u_depth_bias:d}),zI=(v,d)=>({u_matrix:v,u_ground_shadow_factor:d}),Q0=(v,d,g,S,j)=>({u_matrix:v,u_camera_pos:[d[0],d[1],d[2]],u_depth_bias:g,u_height_scale:S,u_reset_depth:j}),qb=(v,d,g)=>({u_image:v,u_opacity:d,u_blend_mode:g}),Qf=(v,d,g,S,j,R,L,F,z,W=[0,0,1])=>({u_matrix:v,u_normal_matrix:d,u_opacity:g,u_faux_facade_ao_intensity:S,u_camera_pos:j,u_tile_to_meter:R,u_facade_emissive_chance:L,u_flood_light_color:F,u_flood_light_intensity:z,u_front_cutoff_params:W}),Gb=v=>({u_matrix:v}),Hb=v=>({u_matrix:v}),UI=(v,d,g,S,j,R,L,F)=>{const z=a.an/R.tileSize;return{u_matrix:v,u_inv_rot_matrix:d,u_camera_to_center_distance:g.getCameraToCenterDistance(F),u_extrude_scale:[g.pixelsToGLUnits[0]/z,g.pixelsToGLUnits[1]/z],u_zoom_transition:S,u_tile_id:L,u_merc_center:j}},Jf=(v,d,g,S)=>({u_matrix:v,u_inv_matrix:d,u_camera_to_center_distance:g.getCameraToCenterDistance(S),u_viewport_size:[g.width,g.height]}),J0=(v,d,g=1)=>({u_matrix:v,u_color:d,u_overlay:0,u_overlay_scale:g}),Wb=a.bb(),VI=(v,d,g,S,j,R,L)=>{const F=v.transform,z=F.projection.name==="globe",W=z?a.dH(F.zoom,d.canonical)*F._pixelsPerMercatorPixel:a.aA(g,1,R),Z={u_matrix:d.projMatrix,u_extrude_scale:W,u_intensity:L,u_inv_rot_matrix:Wb,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(z){Z.u_inv_rot_matrix=S,Z.u_merc_center=j,Z.u_tile_id=[d.canonical.x,d.canonical.y,1<({u_matrix:d,u_normalize_matrix:g,u_globe_matrix:S,u_merc_matrix:j,u_grid_matrix:R,u_tl_parent:L,u_scale_parent:Z,u_fade_t:ne.mix,u_opacity:ne.opacity*re.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:re.paint.get("raster-brightness-min"),u_brightness_high:re.paint.get("raster-brightness-max"),u_saturation_factor:a.dJ(re.paint.get("raster-saturation")),u_contrast_factor:a.dI(re.paint.get("raster-contrast")),u_spin_weights:GI(re.paint.get("raster-hue-rotate")),u_perspective_transform:ie,u_raster_elevation:ce,u_zoom_transition:F,u_merc_center:z,u_cutoff_params:W,u_colorization_mix:lj(a.dK,ve,Re),u_colorization_offset:Kb(a.dK,_e,Re),u_color_ramp:le,u_texture_offset:[Te/(Me+2*Te),Me/(Me+2*Te)],u_texture_res:[Me+2*Te,Me+2*Te],u_emissive_strength:Xe,u_zbias_factor:cj(v)});function GI(v){v*=Math.PI/180;const d=Math.sin(v),g=Math.cos(v);return[(2*g+1)/3,(-Math.sqrt(3)*d-g+1)/3,(Math.sqrt(3)*d-g+1)/3]}const Yd=.05,iB=(v,d,g,S,j,R,L,F,z,W,Z,ne)=>({u_matrix:v,u_normalize_matrix:d,u_globe_matrix:g,u_merc_matrix:S,u_grid_matrix:j,u_tl_parent:R,u_scale_parent:W,u_fade_t:Z.mix,u_opacity:Z.opacity,u_image0:0,u_image1:1,u_raster_elevation:ne,u_zoom_transition:L,u_merc_center:F,u_cutoff_params:z}),aB=(v,d,g,S,j,R,L,F,z,W)=>({u_particle_texture:v,u_particle_texture_side_len:d,u_tile_offset:g,u_velocity:S,u_color_ramp:R,u_velocity_res:j,u_max_speed:L,u_uv_offset:F,u_data_scale:[255*z[0],255*z[1]],u_data_offset:W,u_particle_pos_scale:1.1,u_particle_pos_offset:[Yd,Yd]}),HI=(v,d,g,S,j,R,L,F,z,W)=>({u_particle_texture:v,u_particle_texture_side_len:d,u_velocity:g,u_velocity_res:S,u_max_speed:j,u_speed_factor:R,u_reset_rate:L,u_rand_seed:Math.random(),u_uv_offset:F,u_data_scale:[255*z[0],255*z[1]],u_data_offset:W,u_particle_pos_scale:1.1,u_particle_pos_offset:[Yd,Yd]}),WI=a.bb(),Yb=(v,d,g,S,j,R,L,F,z,W,Z,ne,re,ie,ce,le,ve,_e,Re,Me,Te,Xe,$e,Ke)=>{const De=j.transform,Be={u_is_size_zoom_constant:+(v==="constant"||v==="source"),u_is_size_feature_constant:+(v==="constant"||v==="camera"),u_size_t:d?d.uSizeT:0,u_size:d?d.uSize:0,u_camera_to_center_distance:De.getCameraToCenterDistance(Re),u_rotate_symbol:+g,u_aspect_ratio:De.width/De.height,u_fade_change:j.options.fadeDuration?j.symbolFadeChange:1,u_matrix:R,u_label_plane_matrix:L,u_coord_matrix:F,u_is_text:+W,u_elevation_from_sea:z?1:0,u_pitch_with_map:+S,u_texsize:Z,u_texsize_icon:ne,u_texture:0,u_texture_icon:1,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:WI,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:WI,u_up_vector:[0,-1,0],u_color_adj_mat:Xe,u_icon_transition:$e||0,u_gamma_scale:S?j.transform.getCameraToCenterDistance(Re)*Math.cos(j.terrain?0:j.transform._pitch):1,u_device_pixel_ratio:a.o.devicePixelRatio,u_is_halo:1,u_scale_factor:Ke||1,u_ground_shadow_factor:Me,u_inv_matrix:a.b7(a.bb(),L),u_normal_scale:Te,u_lutTexture:10,u_zoom:De.zoom-Math.floor(De.zoom),u_spp_fill_np_color:[0,0,0,1],u_spp_halo_np_color:[0,0,0,0],u_spp_opacity:1,u_spp_halo_width:0,u_spp_halo_blur:0,u_spp_emissive_strength:0,u_spp_occlusion_opacity:1,u_spp_z_offset:0,u_spp_translate_rotation:[1,0]};return Re.name==="globe"&&(Be.u_tile_id=[ie.canonical.x,ie.canonical.y,1<({u_matrix:v,u_emissive_strength:d,u_opacity:g,u_color:S}),em=(v,d,g,S,j,R,L,F,z)=>Object.assign(function(W,Z,ne,re,ie,ce){const{width:le,height:ve}=re.imageManager.getPixelSize(Z),_e=Math.pow(2,ce.tileID.overscaledZ),Re=ce.tileSize*Math.pow(2,re.transform.tileZoom)/_e,Me=Re*(ce.tileID.canonical.x+ce.tileID.wrap*_e),Te=Re*ce.tileID.canonical.y;return{u_image:0,u_pattern_tl:ne.tl,u_pattern_br:ne.br,u_texsize:[le,ve],u_pattern_size:ne.displaySize,u_pattern_units_to_pixels:ie?[re.transform.width,-1*re.transform.height]:[1/a.aA(ce,1,re.transform.tileZoom),1/a.aA(ce,1,re.transform.tileZoom)],u_pixel_coord_upper:[Me>>16,Te>>16],u_pixel_coord_lower:[65535&Me,65535&Te]}}(0,R,L,S,F,z),{u_matrix:v,u_emissive_strength:d,u_opacity:g}),fy=new Float32Array(a.b9([])),Ep=(v,d,g,S,j,R,L,F,z,W,Z,ne,re,ie=[0,0,0],ce,le,ve)=>{const _e=j.style.light,Re=_e.properties.get("position"),Me=[-Re.x,-Re.y,Re.z],Te=a.dE();_e.properties.get("anchor")==="viewport"&&(a.dF(Te,-j.transform.angle),a.dG(Me,Me,Te));const Xe=Z.alphaMode==="MASK",$e=_e.properties.get("color").toNonPremultipliedRenderColor(null),Ke=re.paint.get("model-ambient-occlusion-intensity"),De=re.paint.get("model-color").constantOr(a.aq.white).toNonPremultipliedRenderColor(null);return De.a=re.paint.get("model-color-mix-intensity").constantOr(0),ve&&(De.r=ve[0],De.g=ve[1],De.b=ve[2],De.a=ve[3]),le&&(De.r=le.color.r,De.g=le.color.g,De.b=le.color.b,De.a=le.colorMix,ne=le.emissionStrength,R*=le.opacity),{u_matrix:v,u_lighting_matrix:d,u_normal_matrix:g,u_node_matrix:S||fy,u_lightpos:Me,u_lightintensity:_e.properties.get("intensity"),u_lightcolor:[$e.r,$e.g,$e.b],u_camera_pos:ie,u_opacity:R,u_baseTextureIsAlpha:0,u_alphaMask:+Xe,u_alphaCutoff:Z.alphaCutoff,u_baseColorFactor:L.toNonPremultipliedRenderColor(null).toArray01(),u_emissiveFactor:F.toNonPremultipliedRenderColor(null).toArray01(),u_metallicFactor:z,u_roughnessFactor:W,u_baseColorTexture:5,u_metallicRoughnessTexture:6,u_normalTexture:7,u_occlusionTexture:8,u_emissionTexture:9,u_lutTexture:10,u_color_mix:De.toArray01(),u_aoIntensity:Ke,u_emissive_strength:ne,u_occlusionTextureTransform:ce||[0,0,0,0]}},uj=(v,d=fy,g=fy)=>({u_matrix:v,u_instance:d,u_node_matrix:g}),Zb={fillExtrusion:v=>({u_matrix:new a.b$(v),u_lightpos:new a.bY(v),u_lightintensity:new a.bZ(v),u_lightcolor:new a.bY(v),u_vertical_gradient:new a.bZ(v),u_opacity:new a.bZ(v),u_edge_radius:new a.bZ(v),u_width_scale:new a.bZ(v),u_ao:new a.b_(v),u_height_type:new a.bX(v),u_base_type:new a.bX(v),u_tile_id:new a.bY(v),u_zoom_transition:new a.bZ(v),u_inv_rot_matrix:new a.b$(v),u_merc_center:new a.b_(v),u_up_dir:new a.bY(v),u_height_lift:new a.bZ(v),u_flood_light_color:new a.bY(v),u_vertical_scale:new a.bZ(v),u_flood_light_intensity:new a.bZ(v),u_ground_shadow_factor:new a.bY(v),u_front_cutoff_params:new a.bY(v)}),fillExtrusionDepth:v=>({u_matrix:new a.b$(v),u_edge_radius:new a.bZ(v),u_width_scale:new a.bZ(v),u_vertical_scale:new a.bZ(v),u_height_type:new a.bX(v),u_base_type:new a.bX(v)}),fillExtrusionPattern:v=>({u_matrix:new a.b$(v),u_lightpos:new a.bY(v),u_lightintensity:new a.bZ(v),u_lightcolor:new a.bY(v),u_vertical_gradient:new a.bZ(v),u_height_factor:new a.bZ(v),u_edge_radius:new a.bZ(v),u_width_scale:new a.bZ(v),u_ao:new a.b_(v),u_height_type:new a.bX(v),u_base_type:new a.bX(v),u_tile_id:new a.bY(v),u_zoom_transition:new a.bZ(v),u_inv_rot_matrix:new a.b$(v),u_merc_center:new a.b_(v),u_up_dir:new a.bY(v),u_height_lift:new a.bZ(v),u_image:new a.bX(v),u_texsize:new a.b_(v),u_pixel_coord_upper:new a.b_(v),u_pixel_coord_lower:new a.b_(v),u_tile_units_to_pixels:new a.bZ(v),u_opacity:new a.bZ(v),u_pattern_transition:new a.bZ(v)}),fillExtrusionGroundEffect:v=>({u_matrix:new a.b$(v),u_opacity:new a.bZ(v),u_ao_pass:new a.bZ(v),u_meter_to_tile:new a.bZ(v),u_ao:new a.b_(v),u_flood_light_intensity:new a.bZ(v),u_flood_light_color:new a.bY(v),u_attenuation:new a.bZ(v),u_edge_radius:new a.bZ(v),u_fb:new a.bX(v),u_fb_size:new a.bZ(v),u_dynamic_offset:new a.bZ(v)}),fill:v=>({u_matrix:new a.b$(v),u_emissive_strength:new a.bZ(v),u_ground_shadow_factor:new a.bY(v)}),fillPattern:v=>({u_matrix:new a.b$(v),u_emissive_strength:new a.bZ(v),u_image:new a.bX(v),u_texsize:new a.b_(v),u_pixel_coord_upper:new a.b_(v),u_pixel_coord_lower:new a.b_(v),u_tile_units_to_pixels:new a.bZ(v),u_ground_shadow_factor:new a.bY(v),u_pattern_transition:new a.bZ(v)}),fillOutline:v=>({u_matrix:new a.b$(v),u_emissive_strength:new a.bZ(v),u_world:new a.b_(v),u_ground_shadow_factor:new a.bY(v)}),fillOutlinePattern:v=>({u_matrix:new a.b$(v),u_emissive_strength:new a.bZ(v),u_world:new a.b_(v),u_image:new a.bX(v),u_texsize:new a.b_(v),u_pixel_coord_upper:new a.b_(v),u_pixel_coord_lower:new a.b_(v),u_tile_units_to_pixels:new a.bZ(v),u_ground_shadow_factor:new a.bY(v),u_pattern_transition:new a.bZ(v)}),lineBlendComposite:v=>({u_image:new a.bX(v),u_opacity:new a.bZ(v),u_blend_mode:new a.bX(v)}),building:v=>({u_matrix:new a.b$(v),u_normal_matrix:new a.b$(v),u_opacity:new a.bZ(v),u_faux_facade_ao_intensity:new a.bZ(v),u_camera_pos:new a.bY(v),u_tile_to_meter:new a.bZ(v),u_facade_emissive_chance:new a.bZ(v),u_flood_light_color:new a.bY(v),u_flood_light_intensity:new a.bZ(v),u_front_cutoff_params:new a.bY(v)}),buildingBloom:v=>({u_matrix:new a.b$(v)}),buildingDepth:v=>({u_matrix:new a.b$(v)}),elevatedStructuresDepth:v=>({u_matrix:new a.b$(v),u_depth_bias:new a.bZ(v)}),elevatedStructures:v=>({u_matrix:new a.b$(v),u_ground_shadow_factor:new a.bY(v)}),elevatedStructuresDepthReconstruct:v=>({u_matrix:new a.b$(v),u_camera_pos:new a.bY(v),u_depth_bias:new a.bZ(v),u_height_scale:new a.bZ(v),u_reset_depth:new a.bZ(v)}),circle:a.dO,collisionBox:v=>({u_matrix:new a.b$(v),u_inv_rot_matrix:new a.b$(v),u_camera_to_center_distance:new a.bZ(v),u_extrude_scale:new a.b_(v),u_zoom_transition:new a.bZ(v),u_merc_center:new a.b_(v),u_tile_id:new a.bY(v)}),collisionCircle:v=>({u_matrix:new a.b$(v),u_inv_matrix:new a.b$(v),u_camera_to_center_distance:new a.bZ(v),u_viewport_size:new a.b_(v)}),debug:v=>({u_color:new a.dl(v),u_matrix:new a.b$(v),u_overlay:new a.bX(v),u_overlay_scale:new a.bZ(v)}),clippingMask:v=>({u_matrix:new a.b$(v)}),heatmap:v=>({u_extrude_scale:new a.bZ(v),u_intensity:new a.bZ(v),u_matrix:new a.b$(v),u_inv_rot_matrix:new a.b$(v),u_merc_center:new a.b_(v),u_tile_id:new a.bY(v),u_zoom_transition:new a.bZ(v),u_up_dir:new a.bY(v)}),heatmapTexture:v=>({u_image:new a.bX(v),u_color_ramp:new a.bX(v),u_opacity:new a.bZ(v)}),hillshade:v=>({u_matrix:new a.b$(v),u_image:new a.bX(v),u_latrange:new a.b_(v),u_light:new a.b_(v),u_shadow:new a.dl(v),u_highlight:new a.dl(v),u_emissive_strength:new a.bZ(v),u_accent:new a.dl(v)}),hillshadePrepare:v=>({u_matrix:new a.b$(v),u_image:new a.bX(v),u_dimension:new a.b_(v),u_zoom:new a.bZ(v)}),line:a.dN,linePattern:a.dM,raster:v=>({u_matrix:new a.b$(v),u_normalize_matrix:new a.b$(v),u_globe_matrix:new a.b$(v),u_merc_matrix:new a.b$(v),u_grid_matrix:new a.dm(v),u_tl_parent:new a.b_(v),u_scale_parent:new a.bZ(v),u_fade_t:new a.bZ(v),u_opacity:new a.bZ(v),u_image0:new a.bX(v),u_image1:new a.bX(v),u_brightness_low:new a.bZ(v),u_brightness_high:new a.bZ(v),u_saturation_factor:new a.bZ(v),u_contrast_factor:new a.bZ(v),u_spin_weights:new a.bY(v),u_perspective_transform:new a.b_(v),u_raster_elevation:new a.bZ(v),u_zoom_transition:new a.bZ(v),u_merc_center:new a.b_(v),u_cutoff_params:new a.cO(v),u_colorization_mix:new a.cO(v),u_colorization_offset:new a.bZ(v),u_color_ramp:new a.bX(v),u_texture_offset:new a.b_(v),u_texture_res:new a.b_(v),u_emissive_strength:new a.bZ(v),u_zbias_factor:new a.bZ(v)}),rasterParticle:v=>({u_matrix:new a.b$(v),u_normalize_matrix:new a.b$(v),u_globe_matrix:new a.b$(v),u_merc_matrix:new a.b$(v),u_grid_matrix:new a.dm(v),u_tl_parent:new a.b_(v),u_scale_parent:new a.bZ(v),u_fade_t:new a.bZ(v),u_opacity:new a.bZ(v),u_image0:new a.bX(v),u_image1:new a.bX(v),u_raster_elevation:new a.bZ(v),u_zoom_transition:new a.bZ(v),u_merc_center:new a.b_(v),u_cutoff_params:new a.cO(v)}),rasterParticleTexture:v=>({u_texture:new a.bX(v),u_opacity:new a.bZ(v)}),rasterParticleDraw:v=>({u_particle_texture:new a.bX(v),u_particle_texture_side_len:new a.bZ(v),u_tile_offset:new a.b_(v),u_velocity:new a.bX(v),u_color_ramp:new a.bX(v),u_velocity_res:new a.b_(v),u_max_speed:new a.bZ(v),u_uv_offset:new a.b_(v),u_data_scale:new a.b_(v),u_data_offset:new a.bZ(v),u_particle_pos_scale:new a.bZ(v),u_particle_pos_offset:new a.b_(v)}),rasterParticleUpdate:v=>({u_particle_texture:new a.bX(v),u_particle_texture_side_len:new a.bZ(v),u_velocity:new a.bX(v),u_velocity_res:new a.b_(v),u_max_speed:new a.bZ(v),u_speed_factor:new a.bZ(v),u_reset_rate:new a.bZ(v),u_rand_seed:new a.bZ(v),u_uv_offset:new a.b_(v),u_data_scale:new a.b_(v),u_data_offset:new a.bZ(v),u_particle_pos_scale:new a.bZ(v),u_particle_pos_offset:new a.b_(v)}),symbol:v=>({u_is_size_zoom_constant:new a.bX(v),u_is_size_feature_constant:new a.bX(v),u_size_t:new a.bZ(v),u_size:new a.bZ(v),u_camera_to_center_distance:new a.bZ(v),u_rotate_symbol:new a.bX(v),u_aspect_ratio:new a.bZ(v),u_fade_change:new a.bZ(v),u_matrix:new a.b$(v),u_label_plane_matrix:new a.b$(v),u_coord_matrix:new a.b$(v),u_is_text:new a.bX(v),u_elevation_from_sea:new a.bX(v),u_pitch_with_map:new a.bX(v),u_texsize:new a.b_(v),u_texsize_icon:new a.b_(v),u_texture:new a.bX(v),u_texture_icon:new a.bX(v),u_gamma_scale:new a.bZ(v),u_device_pixel_ratio:new a.bZ(v),u_tile_id:new a.bY(v),u_zoom_transition:new a.bZ(v),u_inv_rot_matrix:new a.b$(v),u_merc_center:new a.b_(v),u_camera_forward:new a.bY(v),u_tile_matrix:new a.b$(v),u_up_vector:new a.bY(v),u_ecef_origin:new a.bY(v),u_is_halo:new a.bX(v),u_icon_transition:new a.bZ(v),u_color_adj_mat:new a.b$(v),u_scale_factor:new a.bZ(v),u_ground_shadow_factor:new a.bY(v),u_inv_matrix:new a.b$(v),u_normal_scale:new a.bZ(v),u_lutTexture:new a.bX(v),u_zoom:new a.bZ(v),u_spp_fill_np_color:new a.cO(v),u_spp_halo_np_color:new a.cO(v),u_spp_opacity:new a.bZ(v),u_spp_halo_width:new a.bZ(v),u_spp_halo_blur:new a.bZ(v),u_spp_emissive_strength:new a.bZ(v),u_spp_occlusion_opacity:new a.bZ(v),u_spp_z_offset:new a.bZ(v),u_spp_translate_rotation:new a.b_(v)}),background:v=>({u_matrix:new a.b$(v),u_emissive_strength:new a.bZ(v),u_opacity:new a.bZ(v),u_color:new a.dl(v)}),backgroundPattern:v=>({u_matrix:new a.b$(v),u_emissive_strength:new a.bZ(v),u_opacity:new a.bZ(v),u_image:new a.bX(v),u_pattern_tl:new a.b_(v),u_pattern_br:new a.b_(v),u_texsize:new a.b_(v),u_pattern_size:new a.b_(v),u_pixel_coord_upper:new a.b_(v),u_pixel_coord_lower:new a.b_(v),u_pattern_units_to_pixels:new a.b_(v)}),terrainRaster:v=>({u_matrix:new a.b$(v),u_image0:new a.bX(v),u_image1:new a.bX(v),u_skirt_height:new a.bZ(v),u_ground_shadow_factor:new a.bY(v),u_emissive_texture_available:new a.bZ(v)}),skybox:v=>({u_matrix:new a.b$(v),u_sun_direction:new a.bY(v),u_cubemap:new a.bX(v),u_opacity:new a.bZ(v),u_temporal_offset:new a.bZ(v)}),skyboxGradient:v=>({u_matrix:new a.b$(v),u_color_ramp:new a.bX(v),u_center_direction:new a.bY(v),u_radius:new a.bZ(v),u_opacity:new a.bZ(v),u_temporal_offset:new a.bZ(v)}),skyboxCapture:v=>({u_matrix_3f:new a.dm(v),u_sun_direction:new a.bY(v),u_sun_intensity:new a.bZ(v),u_color_tint_r:new a.cO(v),u_color_tint_m:new a.cO(v),u_luminance:new a.bZ(v)}),globeRaster:v=>({u_proj_matrix:new a.b$(v),u_globe_matrix:new a.b$(v),u_normalize_matrix:new a.b$(v),u_merc_matrix:new a.b$(v),u_zoom_transition:new a.bZ(v),u_merc_center:new a.b_(v),u_image0:new a.bX(v),u_image1:new a.bX(v),u_grid_matrix:new a.dm(v),u_skirt_height:new a.bZ(v),u_far_z_cutoff:new a.bZ(v),u_frustum_tl:new a.bY(v),u_frustum_tr:new a.bY(v),u_frustum_br:new a.bY(v),u_frustum_bl:new a.bY(v),u_globe_pos:new a.bY(v),u_globe_radius:new a.bZ(v),u_viewport:new a.b_(v),u_emissive_texture_available:new a.bZ(v)}),globeAtmosphere:v=>({u_frustum_tl:new a.bY(v),u_frustum_tr:new a.bY(v),u_frustum_br:new a.bY(v),u_frustum_bl:new a.bY(v),u_horizon:new a.bZ(v),u_transition:new a.bZ(v),u_fadeout_range:new a.bZ(v),u_atmosphere_fog_color:new a.cO(v),u_high_color:new a.cO(v),u_space_color:new a.cO(v),u_temporal_offset:new a.bZ(v),u_horizon_angle:new a.bZ(v)}),model:v=>({u_matrix:new a.b$(v),u_lighting_matrix:new a.b$(v),u_normal_matrix:new a.b$(v),u_node_matrix:new a.b$(v),u_lightpos:new a.bY(v),u_lightintensity:new a.bZ(v),u_lightcolor:new a.bY(v),u_camera_pos:new a.bY(v),u_opacity:new a.bZ(v),u_baseColorFactor:new a.cO(v),u_emissiveFactor:new a.cO(v),u_metallicFactor:new a.bZ(v),u_roughnessFactor:new a.bZ(v),u_baseTextureIsAlpha:new a.bX(v),u_alphaMask:new a.bX(v),u_alphaCutoff:new a.bZ(v),u_baseColorTexture:new a.bX(v),u_metallicRoughnessTexture:new a.bX(v),u_normalTexture:new a.bX(v),u_occlusionTexture:new a.bX(v),u_emissionTexture:new a.bX(v),u_lutTexture:new a.bX(v),u_color_mix:new a.cO(v),u_aoIntensity:new a.bZ(v),u_emissive_strength:new a.bZ(v),u_occlusionTextureTransform:new a.cO(v)}),modelDepth:v=>({u_matrix:new a.b$(v),u_instance:new a.b$(v),u_node_matrix:new a.b$(v)}),groundShadow:v=>({u_matrix:new a.b$(v),u_ground_shadow_factor:new a.bY(v)}),stars:v=>({u_matrix:new a.b$(v),u_up:new a.bY(v),u_right:new a.bY(v),u_intensity_multiplier:new a.bZ(v)}),snowParticle:v=>({u_modelview:new a.b$(v),u_projection:new a.b$(v),u_time:new a.bZ(v),u_cam_pos:new a.bY(v),u_velocityConeAperture:new a.bZ(v),u_velocity:new a.bZ(v),u_horizontalOscillationRadius:new a.bZ(v),u_horizontalOscillationRate:new a.bZ(v),u_boxSize:new a.bZ(v),u_billboardSize:new a.bZ(v),u_simpleShapeParameters:new a.b_(v),u_screenSize:new a.b_(v),u_thinningCenterPos:new a.b_(v),u_thinningShape:new a.bY(v),u_thinningAffectedRatio:new a.bZ(v),u_thinningParticleOffset:new a.bZ(v),u_particleColor:new a.cO(v),u_direction:new a.bY(v)}),rainParticle:v=>({u_modelview:new a.b$(v),u_projection:new a.b$(v),u_time:new a.bZ(v),u_cam_pos:new a.bY(v),u_texScreen:new a.bX(v),u_velocityConeAperture:new a.bZ(v),u_velocity:new a.bZ(v),u_boxSize:new a.bZ(v),u_rainDropletSize:new a.b_(v),u_distortionStrength:new a.bZ(v),u_rainDirection:new a.bY(v),u_color:new a.cO(v),u_screenSize:new a.b_(v),u_thinningCenterPos:new a.b_(v),u_thinningShape:new a.bY(v),u_thinningAffectedRatio:new a.bZ(v),u_thinningParticleOffset:new a.bZ(v),u_shapeDirectionalPower:new a.bZ(v),u_shapeNormalPower:new a.bZ(v),u_mode:new a.bZ(v)}),vignette:v=>({u_vignetteShape:new a.bY(v),u_vignetteColor:new a.cO(v)}),occlusion:v=>({u_matrix:new a.b$(v),u_anchorPos:new a.bY(v),u_screenSizePx:new a.b_(v),u_occluderSizePx:new a.b_(v),u_color:new a.cO(v)})};class dd{constructor(d,g,S,j){this.id=dd.uniqueIdxCounter,dd.uniqueIdxCounter++,this.context=d;const R=d.gl;this.buffer=R.createBuffer(),this.dynamicDraw=!!S,this.context.unbindVAO(),d.bindElementBuffer.set(this.buffer),R.bufferData(R.ELEMENT_ARRAY_BUFFER,g.arrayBuffer,this.dynamicDraw?R.DYNAMIC_DRAW:R.STATIC_DRAW),this.dynamicDraw||j||g.destroy()}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(d){this.id=dd.uniqueIdxCounter,dd.uniqueIdxCounter++;const g=this.context.gl;this.context.unbindVAO(),this.bind(),g.bufferSubData(g.ELEMENT_ARRAY_BUFFER,0,d.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}dd.uniqueIdxCounter=0;const dj={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class KI{constructor(d,g,S,j,R,L){this.length=g.length,this.attributes=S,this.itemSize=g.bytesPerElement,this.dynamicDraw=j,this.instanceCount=L,this.context=d;const F=d.gl;this.buffer=F.createBuffer(),d.bindVertexBuffer.set(this.buffer),F.bufferData(F.ARRAY_BUFFER,g.arrayBuffer,this.dynamicDraw?F.DYNAMIC_DRAW:F.STATIC_DRAW),this.dynamicDraw||R||g.destroy()}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(d){const g=this.context.gl;this.bind(),g.bufferSubData(g.ARRAY_BUFFER,0,d.arrayBuffer)}enableAttributes(d,g){for(const S of this.attributes){const j=g.getAttributeLocation(d,S.name);j!==-1&&d.enableVertexAttribArray(j)}}setVertexAttribPointers(d,g,S){for(const j of this.attributes){const R=g.getAttributeLocation(d,j.name);if(R!==-1){const L=j.offset+this.itemSize*(S||0);j.type==="Float32"?d.vertexAttribPointer(R,j.components,d.FLOAT,!1,this.itemSize,L):d.vertexAttribIPointer(R,j.components,d[dj[j.type]],this.itemSize,L)}}}setVertexAttribDivisor(d,g,S){for(let j=0;j0&&d.vertexAttribDivisor(R,S)}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class t_{constructor(d,g,S,j,R){this.context=d,this.width=g,this.height=S;const L=this.framebuffer=d.gl.createFramebuffer();j>0&&(this.colorAttachment0=new uy(d,L,0)),j>1&&(this.colorAttachment1=new uy(d,L,1)),R&&(this.depthAttachmentType=R,this.depthAttachment=R==="renderbuffer"?new sj(d,L):new LI(d,L))}static createWithTexture(d,g,S,j,R){const L=d.gl;if(d.activeTexture.set(L.TEXTURE1),d.viewport.set([0,0,S,j]),g&&g.width===S&&g.height===j)return L.bindTexture(L.TEXTURE_2D,g.colorAttachment0.get()),d.bindFramebuffer.set(g.framebuffer),g;g&&g.destroy();const F=new a.T(d,{width:S,height:j,data:null},d.extRenderToTextureHalfFloat?d.gl.RGBA16F:d.gl.RGBA8);F.bind(L.LINEAR,L.CLAMP_TO_EDGE);const z=d.createFramebuffer(S,j,1,null);if(z.colorAttachment0.set(F.texture),R){const W=d.createRenderbuffer(L.DEPTH24_STENCIL8,S,j);d.bindFramebuffer.set(z.framebuffer),L.framebufferRenderbuffer(L.FRAMEBUFFER,L.DEPTH_STENCIL_ATTACHMENT,L.RENDERBUFFER,W),z._stencilRbo=W}return z}createColorAttachment(d,g){g===0?this.colorAttachment0=new uy(d,this.framebuffer,0):g===1&&(this.colorAttachment1=new uy(d,this.framebuffer,1))}removeColorAttachment(d,g){const S=this.context.gl;let j;g===0?(j=this.colorAttachment0.get(),this.colorAttachment0=void 0):g===1&&(j=this.colorAttachment1.get(),this.colorAttachment1=void 0),j&&S.deleteTexture(j)}destroy(){const d=this.context.gl;if(this.colorAttachment0){const g=this.colorAttachment0.get();g&&d.deleteTexture(g)}if(this.colorAttachment1){const g=this.colorAttachment1.get();g&&d.deleteTexture(g)}if(this.depthAttachment&&this.depthAttachmentType)if(this.depthAttachmentType==="renderbuffer"){const g=this.depthAttachment.get();g&&d.deleteRenderbuffer(g)}else{const g=this.depthAttachment.get();g&&d.deleteTexture(g)}this._stencilRbo&&(d.deleteRenderbuffer(this._stencilRbo),this._stencilRbo=null),d.deleteFramebuffer(this.framebuffer)}}class my{constructor(d,g){this.gl=d,this.clearColor=new jI(this),this.clearDepth=new Z5(this),this.clearStencil=new Pb(this),this.colorMask=new X5(this),this.depthMask=new kI(this),this.stencilMask=new QE(this),this.stencilFunc=new Rb(this),this.stencilOp=new JE(this),this.stencilTest=new wp(this),this.depthRange=new Sp(this),this.depthTest=new oy(this),this.depthFunc=new Kd(this),this.blend=new AI(this),this.blendFunc=new ej(this),this.blendColor=new NI(this),this.blendEquation=new ly(this),this.cullFace=new Lb(this),this.cullFaceSide=new Mb(this),this.frontFace=new tj(this),this.program=new Db(this),this.activeTexture=new q0(this),this.viewport=new CI(this),this.bindFramebuffer=new II(this),this.bindRenderbuffer=new PI(this),this.bindTexture=new cy(this),this.bindVertexBuffer=new RI(this),this.bindElementBuffer=new Q5(this),this.bindVertexArrayOES=new J5(this),this.pixelStoreUnpack=new eB(this),this.pixelStoreUnpackPremultiplyAlpha=new rj(this),this.pixelStoreUnpackFlipY=new nj(this),this.options=g?Object.assign({},g):{},this.options.extTextureFilterAnisotropicForceOff||(this.extTextureFilterAnisotropic=d.getExtension("EXT_texture_filter_anisotropic")||d.getExtension("MOZ_EXT_texture_filter_anisotropic")||d.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=d.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT))),this.extDebugRendererInfo=d.getExtension("WEBGL_debug_renderer_info"),this.extDebugRendererInfo&&(this.renderer=d.getParameter(this.extDebugRendererInfo.UNMASKED_RENDERER_WEBGL),this.vendor=d.getParameter(this.extDebugRendererInfo.UNMASKED_VENDOR_WEBGL)),this.forceManualRenderingForInstanceIDShaders=g&&!!g.forceManualRenderingForInstanceIDShaders||this.renderer&&this.renderer.indexOf("PowerVR")!==-1,this.disableSymbolUBO=g&&!!g.forceDisableSymbolUBO,this.options.extTextureFloatLinearForceOff||(this.extTextureFloatLinear=d.getExtension("OES_texture_float_linear")),this.extRenderToTextureHalfFloat=d.getExtension("EXT_color_buffer_half_float"),this.extTimerQuery=d.getExtension("EXT_disjoint_timer_query_webgl2"),this.maxTextureSize=d.getParameter(d.MAX_TEXTURE_SIZE),this.maxUniformBlockSize=Math.min(d.getParameter(d.MAX_UNIFORM_BLOCK_SIZE),32768),this.maxUniformBufferBindings=d.getParameter(d.MAX_UNIFORM_BUFFER_BINDINGS),this.extBlendFuncExtended=d.getExtension("WEBGL_blend_func_extended")}setDefault(){this.unbindVAO(),this.clearColor.setDefault(),this.clearDepth.setDefault(),this.clearStencil.setDefault(),this.colorMask.setDefault(),this.depthMask.setDefault(),this.stencilMask.setDefault(),this.stencilFunc.setDefault(),this.stencilOp.setDefault(),this.stencilTest.setDefault(),this.depthRange.setDefault(),this.depthTest.setDefault(),this.depthFunc.setDefault(),this.blend.setDefault(),this.blendFunc.setDefault(),this.blendColor.setDefault(),this.blendEquation.setDefault(),this.cullFace.setDefault(),this.cullFaceSide.setDefault(),this.frontFace.setDefault(),this.program.setDefault(),this.activeTexture.setDefault(),this.bindFramebuffer.setDefault(),this.pixelStoreUnpack.setDefault(),this.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.pixelStoreUnpackFlipY.setDefault()}setDirty(){this.clearColor.dirty=!0,this.clearDepth.dirty=!0,this.clearStencil.dirty=!0,this.colorMask.dirty=!0,this.depthMask.dirty=!0,this.stencilMask.dirty=!0,this.stencilFunc.dirty=!0,this.stencilOp.dirty=!0,this.stencilTest.dirty=!0,this.depthRange.dirty=!0,this.depthTest.dirty=!0,this.depthFunc.dirty=!0,this.blend.dirty=!0,this.blendFunc.dirty=!0,this.blendColor.dirty=!0,this.blendEquation.dirty=!0,this.cullFace.dirty=!0,this.cullFaceSide.dirty=!0,this.frontFace.dirty=!0,this.program.dirty=!0,this.activeTexture.dirty=!0,this.viewport.dirty=!0,this.bindFramebuffer.dirty=!0,this.bindRenderbuffer.dirty=!0,this.bindTexture.dirty=!0,this.bindVertexBuffer.dirty=!0,this.bindElementBuffer.dirty=!0,this.bindVertexArrayOES.dirty=!0,this.pixelStoreUnpack.dirty=!0,this.pixelStoreUnpackPremultiplyAlpha.dirty=!0,this.pixelStoreUnpackFlipY.dirty=!0}createIndexBuffer(d,g,S){return new dd(this,d,g,S)}createVertexBuffer(d,g,S,j,R){return new KI(this,d,g,S,j,R)}createRenderbuffer(d,g,S){const j=this.gl,R=j.createRenderbuffer();return this.bindRenderbuffer.set(R),j.renderbufferStorage(j.RENDERBUFFER,d,g,S),this.bindRenderbuffer.set(null),R}createFramebuffer(d,g,S,j){return new t_(this,d,g,S,j)}clear({color:d,depth:g,stencil:S,colorMask:j}){const R=this.gl;let L=0;d&&(L|=R.COLOR_BUFFER_BIT,this.clearColor.set(d.toNonPremultipliedRenderColor(null)),this.colorMask.set(j||[!0,!0,!0,!0])),g!==void 0&&(L|=R.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(g),this.depthMask.set(!0)),S!==void 0&&(L|=R.STENCIL_BUFFER_BIT,this.clearStencil.set(S),this.stencilMask.set(255)),R.clear(L)}setCullFace(d){d.enable===!1?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(d.mode),this.frontFace.set(d.frontFace))}setDepthMode(d){d.func!==this.gl.ALWAYS||d.mask?(this.depthTest.set(!0),this.depthFunc.set(d.func),this.depthMask.set(d.mask),this.depthRange.set(d.range)):this.depthTest.set(!1)}setStencilMode(d){d.test.func!==this.gl.ALWAYS||d.mask?(this.stencilTest.set(!0),this.stencilMask.set(d.mask),this.stencilOp.set([d.fail,d.depthFail,d.pass]),this.stencilFunc.set({func:d.test.func,ref:d.ref,mask:d.test.mask})):this.stencilTest.set(!1)}setColorMode(d){a.b6(d.blendFunction,tn.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(d.blendFunction),this.blendColor.set(d.blendColor),d.blendEquation?this.blendEquation.set(d.blendEquation):this.blendEquation.setDefault()),this.colorMask.set(d.mask)}unbindVAO(){this.bindVertexArrayOES.set(null)}}let jp;function Tr(v,d,g,S,j,R,L){const F=v.context,z=F.gl,W=v.transform,Z=[a.aH(W.center.lng),a.aL(W.center.lat)],ne=g.layout.get("symbol-placement"),re=g.layout.get("text-variable-anchor"),ie=g.layout.get("icon-rotation-alignment")==="map",ce=g.layout.get("text-rotation-alignment")==="map",le=ne!=="point",ve=[];let _e=0,Re=0;for(let De=0;De0){const Or=a.bb(),vr=Jt;a.cz(Or,ot.placementInvProjMatrix,W.glCoordMatrix),a.cz(Or,Or,ot.placementViewportMatrix),ve.push({circleArray:zt,circleOffset:Re,transform:vr,invTransform:Or,projection:ot.getProjection()}),_e+=zt.length/4,Re=_e}if(!er)continue;v.terrain&&v.terrain.setupElevationDraw(Ge,lr);const Ir=Et?[Be.canonical.x,Be.canonical.y,1<=0&&(ie[Me.associatedIconIndex]={x:Je,y:St,z:pt,angle:vt})}else Jg($e,ne)}if(W){re.clear();const Re=v.icon.placedSymbolArray;for(let Me=0;Me{let hn=[0,0,0];if(ds){const ni=v.style.directionalLight,Is=v.style.ambientLight;ni&&Is&&(hn=cd(v.style,ni,Is))}return hn},En=ds=>{if(v.context.disableSymbolUBO)return;ds.push("USE_PAINT_PROPERTIES_UBO");const hn=Math.floor(v.context.maxUniformBlockSize/4),ni=Math.floor(hn/4);ds.push(`MAX_UBO_SIZE_VEC4 ${ni}u`)},ln=ds=>{Be.depthOcclusionForSymbolsAndCircles&&(g.hasOcclusionOpacityProperties||v.terrain)&&(ds.push("DEPTH_D24"),ds.push("DEPTH_OCCLUSION"))},ts=ds=>{g.lut&&!$e&&(g.lut.texture||(g.lut.texture=new a.dR(v.context,g.lut.image,[g.lut.image.height,g.lut.image.height,g.lut.image.height],Ke.gl.RGBA8)),Ke.activeTexture.set(Ke.gl.TEXTURE0+10),g.lut.texture&&g.lut.texture.bind(Ke.gl.LINEAR,Ke.gl.CLAMP_TO_EDGE),ds.push("APPLY_LUT_ON_GPU"))},Cs=()=>{const ds=Ge&&g.layout.get("symbol-placement")!=="point",hn=[];ln(hn),ts(hn);const ni=ds||dn,Is=zt.elevationType==="road",Ki=v.shadowRenderer,Mn=Is&&Je&&!!Ki&&Ki.enabled,Ms=Kr(Mn),ha=Is&&Je&&!v.terrain?ut:Ut,Lo=g.paint.get("icon-image-cross-fade");v.terrainRenderModeElevated()&&Je&&hn.push("PITCH_WITH_MAP_TERRAIN"),Ir&&(hn.push("PROJECTION_GLOBE_VIEW"),ni&&hn.push("PROJECTED_POS_ON_VIEWPORT")),Lo>0&&zt.hasAnySecondaryIcon&&hn.push("ICON_TRANSITION"),!zt.icon.zOffsetVertexBuffer||Is&&v.terrain||hn.push("Z_OFFSET"),_e===0&&Re===0&&Me===0&&Te===1||hn.push("COLOR_ADJUSTMENT"),zt.sdfIcons&&hn.push("RENDER_SDF"),Mn&&hn.push("RENDER_SHADOWS","NORMAL_OFFSET"),Is&&Je&&!v.terrain&&zt.icon.orientationVertexBuffer&&hn.push("ELEVATED_ROADS"),En(hn);const Sa=Ke.disableSymbolUBO?zt.icon.programConfigurations.get(g.id):null,ro=v.getOrCreateProgram("symbol",{config:Sa,defines:hn}),Tc=er.imageAtlasTexture?er.imageAtlasTexture.size:[0,0],ys=zt.iconSizeData,Yc=a.bj(ys,Be.zoom),Zc=Je||!Be.isOrthographic,Vs=Hf(vr,er.tileID.canonical,Je,Ge,Be,zt.getProjection(),Ar),Ys=Qg(vr,er.tileID.canonical,Je,Ge,Be,zt.getProjection(),Ar),Ts=zt.icon.uboBinder&&zt.icon.uboBinder.cachedHeader&&256&zt.icon.uboBinder.cachedHeader.dataDrivenMask?[0,0]:F,Vi=v.translatePosMatrix(Ys,er,Ts,W,!0),Zo=v.translatePosMatrix(vr,er,Ts,W),Si=ni?r_:Vs,Ec=Ge&&!Je&&!ds;let rm=lr;!Et&&!Be.mercatorFromTransition||Ge||(rm=Uh(Be));const Lp=Ir?rm:lr,Mp=g.getColorAdjustmentMatrix(_e,Re,Me,Te),vy=Yb(ys.kind,Yc,Ec,Je,v,Zo,Si,Vi,Xe,!1,Tc,[0,0],0,Jt,Or,st,on,Lp,zt.getProjection(),Ms,Tn,Mp,Lo,null),Kh=er.imageAtlasTexture?er.imageAtlasTexture:null,eh=g.layout.get("icon-size").constantOr(0)!==1||zt.iconsNeedLinear,by=zt.sdfIcons||v.options.rotating||v.options.zooming||eh||Zc?De.LINEAR:De.NEAREST,Zl=zt.sdfIcons&&g.paint.get("icon-halo-width").constantOr(1)!==0,nm=v.terrain&&Je&&ds?a.b7(a.bb(),Vs):r_;if(ds&&zt.icon){const sm=a.bu.getAtTileOffsetFunc(Jt,Be.center.lat,Be.worldSize,zt.getProjection()),im=ad(vr,er.tileID.canonical,Je,Ge,Be,zt.getProjection(),Ar),vw=g.layout.get("icon-size-scale-range"),wy=a.aC(v.scaleFactor,vw[0],vw[1]);bc(zt,vr,v,!1,im,Ys,Je,le,sm,Jt,wy)}return{program:ro,buffers:zt.icon,uniformValues:vy,atlasTexture:Kh,atlasTextureIcon:null,atlasInterpolation:by,atlasInterpolationIcon:null,isSDF:zt.sdfIcons,hasHalo:Zl,depthMode:ha,tile:er,renderWithShadows:Mn,labelPlaneMatrixInv:nm}},ai=()=>{const ds=ot&&g.layout.get("symbol-placement")!=="point",hn=[],ni=ds||vt||dn,Is=zt.elevationType==="road",Ki=v.shadowRenderer,Mn=Is&&St&&!!Ki&&Ki.enabled,Ms=Kr(Mn),ha=Is&&St&&!v.terrain?ut:Ut;v.terrainRenderModeElevated()&&St&&hn.push("PITCH_WITH_MAP_TERRAIN"),Ir&&(hn.push("PROJECTION_GLOBE_VIEW"),ni&&hn.push("PROJECTED_POS_ON_VIEWPORT")),!zt.text.zOffsetVertexBuffer||Is&&v.terrain||hn.push("Z_OFFSET"),zt.iconsInText&&hn.push("RENDER_TEXT_AND_SYMBOL"),hn.push("RENDER_SDF"),Mn&&hn.push("RENDER_SHADOWS","NORMAL_OFFSET"),Is&&St&&!v.terrain&&zt.text.orientationVertexBuffer&&hn.push("ELEVATED_ROADS"),ln(hn),En(hn);const Lo=Ke.disableSymbolUBO?zt.text.programConfigurations.get(g.id):null,Sa=v.getOrCreateProgram("symbol",{config:Lo,defines:hn});let ro,Tc=[0,0],ys=null;const Yc=zt.textSizeData;zt.iconsInText&&(Tc=er.imageAtlasTexture?er.imageAtlasTexture.size:[0,0],ys=er.imageAtlasTexture?er.imageAtlasTexture:null,ro=St||!Be.isOrthographic||v.options.rotating||v.options.zooming||Yc.kind==="composite"||Yc.kind==="camera"?De.LINEAR:De.NEAREST);const Zc=er.glyphAtlasTexture?er.glyphAtlasTexture.size:[0,0],Vs=g.layout.get("text-size-scale-range"),Ys=a.aC(v.scaleFactor,Vs[0],Vs[1]),Ts=a.bj(Yc,Be.zoom,Ys),Vi=Hf(vr,er.tileID.canonical,St,ot,Be,zt.getProjection(),Ar),Zo=Qg(vr,er.tileID.canonical,St,ot,Be,zt.getProjection(),Ar),Si=zt.text.uboBinder&&zt.text.uboBinder.cachedHeader&&256&zt.text.uboBinder.cachedHeader.dataDrivenMask?[0,0]:z,Ec=v.translatePosMatrix(Zo,er,Si,Z,!0),rm=v.translatePosMatrix(vr,er,Si,Z),Lp=ni?r_:Vi,Mp=ot&&!St&&!ds;let vy=lr;!Et&&!Be.mercatorFromTransition||ot||(vy=Uh(Be));const Kh=Yb(Yc.kind,Ts,Mp,St,v,rm,Lp,Ec,Xe,!0,Zc,Tc,0,Jt,Or,st,on,Ir?vy:lr,zt.getProjection(),Ms,Tn,null,null,Ys),eh=er.glyphAtlasTexture?er.glyphAtlasTexture:null,by=De.LINEAR,Zl=g.paint.get("text-halo-width").constantOr(1)!==0,nm=v.terrain&&St&&ds?a.b7(a.bb(),Vi):r_;if(ds&&zt.text){const sm=a.bu.getAtTileOffsetFunc(Jt,Be.center.lat,Be.worldSize,zt.getProjection()),im=ad(vr,er.tileID.canonical,St,ot,Be,zt.getProjection(),Ar);bc(zt,vr,v,!0,im,Zo,St,ve,sm,Jt,Ys)}return{program:Sa,buffers:zt.text,uniformValues:Kh,atlasTexture:eh,atlasTextureIcon:ys,atlasInterpolation:by,atlasInterpolationIcon:ro,isSDF:!0,hasHalo:Zl,depthMode:ha,tile:er,renderWithShadows:Mn,labelPlaneMatrixInv:nm}},Fs=zt.icon.segments.get().length,us=zt.text.segments.get().length,vn=Fs&&!L.onlyText?Cs():null,bn=us&&!L.onlyIcons?ai():null,Bs=g.paint.get("icon-opacity").constantOr(1),fi=g.paint.get("text-opacity").constantOr(1);if(pt&&zt.canOverlap){Ot=!0;const ds=Bs&&!L.onlyText?zt.icon.segments.get():[],hn=fi&&!L.onlyIcons?zt.text.segments.get():[];for(const ni of ds)Nt.push({segments:new a.dy([ni]),sortKey:ni.sortKey,state:vn});for(const ni of hn)Nt.push({segments:new a.dy([ni]),sortKey:ni.sortKey,state:bn})}else L.onlyText||Nt.push({segments:Bs?zt.icon.segments:new a.dy([]),sortKey:0,state:vn}),L.onlyIcons||Nt.push({segments:fi?zt.text.segments:new a.dy([]),sortKey:0,state:bn})}Ot&&Nt.sort((Jt,er)=>Jt.sortKey-er.sortKey);for(const Jt of Nt){const er=Jt.state;if(er)if(v.terrain?v.terrain.setupElevationDraw(er.tile,er.program,{useDepthForOcclusion:Be.depthOcclusionForSymbolsAndCircles,labelPlaneMatrixInv:er.labelPlaneMatrixInv}):v.setupDepthForOcclusion(Be.depthOcclusionForSymbolsAndCircles,er.program),Ke.activeTexture.set(De.TEXTURE0),er.atlasTexture&&er.atlasTexture.bind(er.atlasInterpolation,De.CLAMP_TO_EDGE,!0),er.atlasTextureIcon&&(Ke.activeTexture.set(De.TEXTURE1),er.atlasTextureIcon&&er.atlasTextureIcon.bind(er.atlasInterpolationIcon,De.CLAMP_TO_EDGE,!0)),er.renderWithShadows&&v.shadowRenderer.setupShadows(er.tile.tileID.toUnwrapped(),er.program,"vector-tile"),v.uploadCommonLightUniforms(v.context,er.program),er.hasHalo){const zt=er.uniformValues;zt.u_is_halo=1,Qb(er.buffers,Jt.segments,g,v,er.program,er.depthMode,j,R,zt,2),zt.u_is_halo=0}else{if(er.isSDF){const zt=er.uniformValues;er.hasHalo&&(zt.u_is_halo=1,Qb(er.buffers,Jt.segments,g,v,er.program,er.depthMode,j,R,zt,1)),zt.u_is_halo=0}Qb(er.buffers,Jt.segments,g,v,er.program,er.depthMode,j,R,er.uniformValues,1)}}}function Qb(v,d,g,S,j,R,L,F,z,W){const Z=S.context,ne=Z.gl,re=[v.dynamicLayoutVertexBuffer,v.opacityVertexBuffer,v.iconTransitioningVertexBuffer,v.globeExtVertexBuffer,v.zOffsetVertexBuffer,v.orientationVertexBuffer];v.featureIdBuffer&&re.push(v.featureIdBuffer);const ie=v.uboBinder?null:v.programConfigurations.get(g.id);if(v.uboBinder){v.uboBinder.layer=g;const ve=S.transform.zoom,_e=S.style.getBrightness?S.style.getBrightness():null,Re=v.uboBinder.getConstantUniformValues(ve,_e);z.u_spp_fill_np_color=Re.fill_np_color,z.u_spp_halo_np_color=Re.halo_np_color,z.u_spp_opacity=Re.opacity,z.u_spp_halo_width=Re.halo_width,z.u_spp_halo_blur=Re.halo_blur,z.u_spp_emissive_strength=Re.emissive_strength,z.u_spp_occlusion_opacity=Re.occlusion_opacity,z.u_spp_z_offset=Re.z_offset;const Me=g.paint.get(v.uboBinder.isText?"text-translate-anchor":"icon-translate-anchor"),Te=v.uboBinder.cachedHeader&&256&v.uboBinder.cachedHeader.dataDrivenMask&&Me==="map"?S.transform.angle:0;z.u_spp_translate_rotation=[Math.cos(Te),Math.sin(Te)]}const{batchIndices:ce,batchSegments:le}=v.getBatchGrouping(d);for(const ve of ce){const _e=le.get(ve);v.uboBinder&&v.uboBinder.bind(Z,j.program,ve),j.draw(S,ne.TRIANGLES,R,L,F,Zr.disabled,z,g.id,v.layoutVertexBuffer,v.indexBuffer,_e,g.paint,S.transform.zoom,ie,re,W)}}function Jb(v,d,g,S,j,R){const L=g.paint.get("line-width"),F=g.paint.get("line-emissive-strength").isConstant(),z=g.paint.get("line-emissive-strength").constantOr(0),W=g.paint.get("line-occlusion-opacity"),Z=g.layout.get("line-elevation-reference"),ne=g.layout.get("line-width-unit")==="meters",re=Z==="sea",ie=!(!v.terrain||!v.terrain.enabled),ce=v.context,le=ce.gl;if(g.hasElevatedBuckets&&v.transform.projection.name==="globe")return;const ve=g.layout.get("line-cross-slope"),_e=ve!==void 0,Re=ve<1,Me=j||v.colorModeForDrapableLayerRenderPass(F?z:null),Te=v.terrain&&v.terrain.renderingToTexture||R,Xe=Te?1:a.o.devicePixelRatio,$e=g.paint.get("line-dasharray"),Ke=$e.constantOr(1),De=g.layout.get("line-cap"),Be=$e.constantOr(null),Ge=De.constantOr(null),ot=g.paint.get("line-pattern"),Je=ot.constantOr(1),St=g.paint.get("line-pattern-cross-fade"),pt=ot.constantOr(null),Ot=g.paint.get("line-opacity").constantOr(1);let Ut=!Je&&Ot!==1||v.depthOcclusion&&W>0&&W<1;const ut=g.paint.get("line-gradient"),st=Je?"linePattern":"line",vt=a.dU(g);let Et;if(Te&&v.terrain&&v.terrain.clipOrMaskOverlapStencilType()&&(Ut=!1),W!==0&&v.depthOcclusion){const zt=g.paint._values["line-opacity"];zt&&zt.value&&zt.value.kind==="constant"?Et=zt.value:a.w(`Occlusion opacity for layer ${g.id} is supported only when line-opacity isn't data-driven.`)}L.value.kind!=="constant"&&L.value.isLineProgressConstant===!1&&vt.push("VARIABLE_LINE_WIDTH"),Te&&(v.emissiveMode!=="dual-source-blending"||F?v.emissiveMode==="mrt-fallback"&&vt.push("USE_MRT1"):vt.push("DUAL_SOURCE_BLENDING"));const Nt={},lr=(zt,Ir,Or,vr,Ar,Jr)=>{for(const dn of zt){const on=d.getTile(dn);if(Je&&!on.patternsLoaded())continue;const Tn=on.getBucket(g);if(!Tn||Tn.elevationType!=="none"&&!Ar||Tn.elevationType==="none"&&Ar)continue;v.prepareDrawTile();const Kr=[...Ir],En=v.shadowRenderer,ln=Tn.elevationType==="road"&&!!En&&En.enabled;let ts=[0,0,0];if(ln){const Mn=v.style.directionalLight,Ms=v.style.ambientLight;Mn&&Ms&&(ts=cd(v.style,Mn,Ms)),Kr.push("RENDER_SHADOWS","NORMAL_OFFSET")}const Cs=Tn.programConfigurations.get(g.id);let ai=!1;if(pt&&on.imageAtlas){const Mn=a.dV.from(pt),Ms=Mn.getPrimary().scaleSelf(Xe).toString(),ha=on.imageAtlas.patternPositions.get(Ms),Lo=Mn.getSecondary(),Sa=Lo?on.imageAtlas.patternPositions.get(Lo.scaleSelf(Xe).toString()):null;ai=!!ha&&!!Sa,ha&&Cs.setConstantPatternPositions(ha,Sa)}St>0&&(ai||Cs.getPatternTransitionVertexBuffer("line-pattern"))&&Kr.push("LINE_PATTERN_TRANSITION"),Tn.elevationGroundScaleVertexBuffer&&Kr.push("ELEVATION_GROUND_SCALE");const Fs=v.isTileAffectedByFog(dn),us=v.getOrCreateProgram(st,{config:Cs,defines:Kr,overrideFog:Fs});if(!Je&&Be&&Ge&&on.lineAtlas){const Mn=on.lineAtlas.getDash(Be,Ge);Mn&&Cs.setConstantPatternPositions(Mn)}ln&&En.setupShadows(on.tileID.toUnwrapped(),us,"vector-tile");let[vn,bn]=g.paint.get("line-trim-offset");(Ge==="round"||Ge==="square")&&vn!==bn&&(vn===0&&(vn-=1),bn===1&&(bn+=1));const Bs=Te?dn.projMatrix:null,fi=ne?1/Tn.tileToMeter/a.aA(on,1,v.transform.zoom):1,ds=ne?1/Tn.tileToMeter/a.aA(on,1,Math.floor(v.transform.zoom)):1,hn=Ke?g.paint._values["line-floorwidth"]:null;let ni;if(hn&&hn.value.kind==="constant"){const Mn=Tn.zoom;Mn in Nt||(Nt[Mn]=Math.max(.01,g.widthExpression().evaluate({zoom:Mn}))),ni=hn.value.value;const Ms=Math.floor(v.transform.zoom);hn.value.value=Nt[Mn]*Math.pow(2,Ms-on.tileID.overscaledZ)}const Is=Je?a.dW(v,on,g,Bs,Xe,fi,ds,[vn,bn],ts,St):a.dX(v,on,g,Bs,Tn.lineClipsArray.length,Xe,fi,ds,[vn,bn],ts);if(ut){const Mn=Tn.gradients[g.id];let Ms=Mn.texture;if(g.gradientVersion!==Mn.version){let ha=256;if(g.stepInterpolant){const Lo=d.getSource().maxzoom,Sa=dn.canonical.z===Lo?Math.ceil(1<{Et!=null&&(Et.value=Ot*W),us.draw(v,le.TRIANGLES,Or,Mn,Me,Zr.disabled,Is,g.id,Tn.layoutVertexBuffer,Tn.indexBuffer,Tn.segments,g.paint,v.transform.zoom,Cs,[Tn.layoutVertexBuffer2,Tn.patternVertexBuffer,Tn.zOffsetVertexBuffer,Tn.elevationGroundScaleVertexBuffer]),Et!=null&&(Et.value=Ot)};if(Ut&&!Ar){const Mn=v.stencilModeForClipping(dn).ref;Mn===0&&Te&&ce.clear({stencil:0});const Ms={func:le.EQUAL,mask:255};Is.u_alpha_discard_threshold=.8,Ki(new an(Ms,Mn,255,le.KEEP,le.KEEP,le.INVERT)),Is.u_alpha_discard_threshold=0,Ki(new an(Ms,Mn,255,le.KEEP,le.KEEP,le.KEEP))}else Is.u_alpha_discard_threshold=Ut&&Ar&&Jr?.8:0,Ki(Ar?vr:v.stencilModeForClipping(dn));ni!==void 0&&(hn.value.value=ni)}};let Jt=v.depthModeForSublayer(0,Lr.ReadOnly);const er=new Lr(v.depthOcclusion?le.GREATER:le.LEQUAL,Lr.ReadOnly,v.depthRangeFor3D);if(g.hasNonElevatedBuckets){const zt=!Te&&v.terrain;W!==0&&zt?a.w(`Occlusion opacity for layer ${g.id} is supported on terrain only if the layer has line-z-offset enabled.`):zt?a.w(`Cannot render non-elevated lines in immediate mode when terrain is enabled. Layer: ${g.id}.`):lr(S,vt,Jt,an.disabled,!1,!0)}if(g.hasElevatedBuckets){Z==="hd-road-markup"?ie||(Jt=er,vt.push("ELEVATED_ROADS")):(vt.push("ELEVATED"),Jt=er,_e&&vt.push(Re?"CROSS_SLOPE_HORIZONTAL":"CROSS_SLOPE_VERTICAL"),re&&vt.push("ELEVATION_REFERENCE_SEA"));const zt=Ut?v.stencilModeFor3D():an.disabled;v.forceTerrainMode=!0,lr(S,vt,Jt,zt,!0,!0),Ut&&lr(S,vt,Jt,zt,!0,!1),v.forceTerrainMode=!1}Ut&&(v.resetStencilClippingMasks(),Te&&ce.clear({stencil:0})),W===0||v.depthOcclusion||Te||v.layersWithOcclusionOpacity.push(v.currentLayer)}const Vh={additive:{clearColor:new a.aq(0,0,0,0),colorMode:tn.additive,compositeUniformValue:1},multiply:{clearColor:new a.aq(1,1,1,1),colorMode:tn.multiply,compositeUniformValue:0}};function hj(v,d){const g=1<=_p?1:ie.pitch/_p))),2*ce}(v.transform),W=v.transform.getFreeCameraOptions().position,Z="elevatedStructuresDepthReconstruct",ne=v.getOrCreateProgram(Z,{defines:["DEPTH_RECONSTRUCTION"]}),re=v.getOrCreateProgram(Z);for(const ie of S){const ce=d.getTile(ie),le=ce.getBucket(g);if(!le)continue;const ve=le.elevatedStructures;if(!ve)continue;const _e=le.elevationBufferData.heightRange,Re=hj(ie.toUnwrapped(),W),Me=v.translatePosMatrix(ie.projMatrix,ce,g.paint.get("fill-translate"),g.paint.get("fill-translate-anchor"));let Te,Xe,$e,Ke;if(j==="initialize"){if(!_e||_e.min>=1||ve.depthSegments.segments[0].primitiveLength===0)continue;Te=Q0(Me,Re,z,1,0),Xe=L,$e=ve.depthSegments,Ke=ne}else if(j==="reset"){if(!_e||_e.min>=0||ve.maskSegments.segments[0].primitiveLength===0)continue;Te=Q0(Me,Re,0,0,1),Xe=F,$e=ve.maskSegments,Ke=ne}else if(j==="geometry"){if(ve.depthSegments.segments[0].primitiveLength===0)continue;Te=Q0(Me,Re,z,1,0),Xe=L,$e=ve.depthSegments,Ke=re}Ke.draw(v,R.TRIANGLES,Xe,an.disabled,tn.disabled,Zr.disabled,Te,g.id,ve.vertexBuffer,ve.indexBuffer,$e,g.paint,v.transform.zoom)}}function s_(v,d,g,S){const{painter:j,sourceCache:R,layer:L,coords:F,colorMode:z,elevationType:W,terrainEnabled:Z,pass:ne}=v,re=j.context.gl,ie=L.paint.get("fill-pattern"),ce=L.paint.get("fill-pattern-cross-fade"),le=ie.constantOr(null);let ve=W;W!=="road"||d&&!Z||(ve="none");const _e=ve==="road",Re=v.painter.shadowRenderer,Me=_e&&!!Re&&Re.enabled,Te=new Lr(j.context.gl.LEQUAL,Lr.ReadOnly,j.depthRangeFor3D);let Xe=[0,0,0];if(Me){const Be=j.style.directionalLight,Ge=j.style.ambientLight;Be&&Ge&&(Xe=cd(j.style,Be,Ge))}const $e=ie&&ie.constantOr(1),Ke=j.terrain&&j.terrain.renderingToTexture,De=(Be,Ge)=>{let ot,Je,St,pt,Ot;Ge?(ot=$e&&!L.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",St=re.LINES):(ot=$e?"fillPattern":"fill",St=re.TRIANGLES);for(const Ut of F){const ut=R.getTile(Ut);if($e&&!ut.patternsLoaded())continue;const st=ut.getBucket(L);if(!st)continue;const vt=d?st.elevationBufferData:st.bufferData;if(vt.isEmpty())continue;j.prepareDrawTile();const Et=vt.programConfigurations.get(L.id),Nt=j.isTileAffectedByFog(Ut),lr=[],Jt=[];_e&&(lr.push("ELEVATED_ROADS"),Jt.push(vt.elevatedLayoutVertexBuffer)),Me&&lr.push("RENDER_SHADOWS","NORMAL_OFFSET"),Ke&&g&&lr.push("USE_MRT1"),$e&&(j.context.activeTexture.set(re.TEXTURE0),ut.imageAtlasTexture&&ut.imageAtlasTexture.bind(re.LINEAR,re.CLAMP_TO_EDGE),Et.updatePaintBuffers());let er=!1;if(le&&ut.imageAtlas){const Ar=ut.imageAtlas,Jr=a.dV.from(le),dn=Jr.getPrimary().scaleSelf(a.o.devicePixelRatio).toString(),on=Jr.getSecondary(),Tn=Ar.patternPositions.get(dn),Kr=on?Ar.patternPositions.get(on.scaleSelf(a.o.devicePixelRatio).toString()):null;er=!!Tn&&!!Kr,Tn&&Et.setConstantPatternPositions(Tn,Kr)}ce>0&&(er||Et.getPatternTransitionVertexBuffer("fill-pattern"))&&lr.push("FILL_PATTERN_TRANSITION");const zt=j.getOrCreateProgram(ot,{config:Et,overrideFog:Nt,defines:lr}),Ir=j.translatePosMatrix(Ut.projMatrix,ut,L.paint.get("fill-translate"),L.paint.get("fill-translate-anchor"));Me&&Re.setupShadows(ut.tileID.toUnwrapped(),zt,"vector-tile");const Or=L.paint.get("fill-emissive-strength");if(Ge){pt=vt.lineIndexBuffer,Ot=vt.lineSegments;const Ar=j.terrain&&j.terrain.renderingToTexture?j.terrain.drapeBufferSize:[re.drawingBufferWidth,re.drawingBufferHeight];Je=ot==="fillOutlinePattern"&&$e?hy(Ir,Or,j,ut,Ar,Xe,ce):BI(Ir,Or,Ar,Xe)}else pt=vt.indexBuffer,Ot=vt.triangleSegments,Je=$e?Vb(Ir,Or,j,ut,Xe,ce):Ub(Ir,Or,Xe);j.uploadCommonUniforms(j.context,zt,Ut.toUnwrapped());let vr=Be;(W==="road"&&!Z||W==="offset")&&(vr=Te),zt.draw(j,St,vr,S||j.stencilModeForClipping(Ut),z,Zr.disabled,Je,L.id,vt.layoutVertexBuffer,pt,Ot,L.paint,j.transform.zoom,Et,Jt)}};j.renderPass===ne&&De(j.depthModeForSublayer(1,j.renderPass==="opaque"?Lr.ReadWrite:Lr.ReadOnly),!1),ve==="none"&&j.renderPass==="translucent"&&L.paint.get("fill-antialias")&&De(j.depthModeForSublayer(L.getPaintProperty("fill-outline-color")?2:0,Lr.ReadOnly),!0)}function kp(v,d,g,S,j,R,L,F){g.resetLayerRenderingStats(v);const z=v.context,W=z.gl,Z=v.transform,ne=g.paint.get("fill-extrusion-pattern"),re=g.paint.get("fill-extrusion-pattern-cross-fade"),ie=ne.constantOr(null),ce=ne.constantOr(1),le=g.paint.get("fill-extrusion-opacity"),ve=v.style.enable3dLights(),_e=g.paint.get(ve&&!ce?"fill-extrusion-ambient-occlusion-wall-radius":"fill-extrusion-ambient-occlusion-radius"),Re=[g.paint.get("fill-extrusion-ambient-occlusion-intensity"),_e],Me=g.layout.get("fill-extrusion-edge-radius"),Te=Me>0&&!g.paint.get("fill-extrusion-rounded-roof"),Xe=Te?0:Me,$e=Z.projection.name==="globe"?a.e1():0,Ke=Z.projection.name==="globe",De=Ke?a.al(Z.zoom):0,Be=[a.aH(Z.center.lng),a.aL(Z.center.lat)],Ge=g.paint.get("fill-extrusion-flood-light-color-use-theme").constantOr("default")==="none",ot=g.paint.get("fill-extrusion-flood-light-color").toNonPremultipliedRenderColor(Ge?null:g.lut).toArray01().slice(0,3),Je=g.paint.get("fill-extrusion-flood-light-intensity"),St=g.paint.get("fill-extrusion-vertical-scale"),pt=g.paint.get("fill-extrusion-line-width").constantOr(1)!==0,Ot=g.paint.get("fill-extrusion-height-alignment"),Ut=g.paint.get("fill-extrusion-base-alignment"),ut=Wa(v,g.paint.get("fill-extrusion-cutoff-fade-range")),st=g.paint.get("fill-extrusion-front-cutoff"),vt=ew(Z.pitch,st,!!v.terrain),Et=vt[2]<1;Et&&(v.maxFrontCutoffRawStart=Math.max(v.maxFrontCutoffRawStart,st[0]));const Nt=[];let lr;Ke&&Nt.push("PROJECTION_GLOBE_VIEW"),Re[0]>0&&Nt.push("FAUX_AO"),Te&&Nt.push("ZERO_ROOF_RADIUS"),F&&Nt.push("HAS_CENTROID"),Je>0&&Nt.push("FLOOD_LIGHT"),ut.shouldRenderCutoff&&Nt.push("RENDER_CUTOFF"),Et&&Nt.push("RENDER_FRONT_CUTOFF"),pt&&Nt.push("RENDER_WALL_MODE");const Jt=v.renderPass==="shadow",er=v.shadowRenderer,zt=Jt&&!!er,Ir=Jt?Zr.disabled:Zr.backCCW;v.shadowRenderer&&(v.shadowRenderer.useNormalOffset=!0);let Or=[0,0,0];if(er){const Jr=v.style.directionalLight,dn=v.style.ambientLight;Jr&&dn&&(Or=cd(v.style,Jr,dn)),Jt||(Nt.push("RENDER_SHADOWS"),er.useNormalOffset&&Nt.push("NORMAL_OFFSET")),lr=Nt.concat(["SHADOWS_SINGLE_CASCADE"])}const vr=zt?"fillExtrusionDepth":ce?"fillExtrusionPattern":"fillExtrusion",Ar=g.getLayerRenderingStats();for(const Jr of S){const dn=d.getTile(Jr),on=dn.getBucket(g);if(!on||on.projection.name!==Z.projection.name)continue;let Tn=!1;er&&(Tn=er.getMaxCascadeForTile(Jr.toUnwrapped())===0);const Kr=v.isTileAffectedByFog(Jr),En=on.programConfigurations.get(g.id);let ln=!1;if(ie&&dn.imageAtlas){const bn=dn.imageAtlas,Bs=a.dV.from(ie),fi=Bs.getPrimary().scaleSelf(a.o.devicePixelRatio).toString(),ds=Bs.getSecondary(),hn=bn.patternPositions.get(fi),ni=ds?bn.patternPositions.get(ds.scaleSelf(a.o.devicePixelRatio).toString()):null;ln=!!hn&&!!ni,hn&&En.setConstantPatternPositions(hn,ni)}re>0&&(ln||En.getPatternTransitionVertexBuffer("fill-extrusion-pattern"))&&Nt.push("FILL_EXTRUSION_PATTERN_TRANSITION");const ts=v.getOrCreateProgram(vr,{config:En,defines:Tn?lr:Nt,overrideFog:Kr});if(v.terrain&&v.terrain.setupElevationDraw(dn,ts,{useMeterToDem:!0}),!on.centroidVertexBuffer){const bn=ts.getAttributeLocation(W,"a_centroid_pos");bn!==-1&&W.vertexAttribI4ui(bn,0,0,0,0)}!Jt&&er&&er.setupShadows(dn.tileID.toUnwrapped(),ts,"vector-tile"),ce&&(v.context.activeTexture.set(W.TEXTURE0),dn.imageAtlasTexture&&dn.imageAtlasTexture.bind(W.LINEAR,W.CLAMP_TO_EDGE),En.updatePaintBuffers());const Cs=g.paint.get("fill-extrusion-vertical-gradient"),ai=1/on.tileToMeter;let Fs;if(Jt&&er){if(tw(dn.tileID,on.maxHeight,v))continue;const bn=er.calculateShadowPassMatrixFromTile(dn.tileID.toUnwrapped());Fs=nB(bn,Xe,ai,St,Ot,Ut)}else{const bn=v.translatePosMatrix(Jr.expandedProjMatrix,dn,g.paint.get("fill-extrusion-translate"),g.paint.get("fill-extrusion-translate-anchor")),Bs=Z.projection.createInversionMatrix(Z,Jr.canonical);Fs=ce?sB(bn,v,Cs,le,Re,Xe,ai,Jr,dn,$e,Ot,Ut,De,Be,Bs,ot,St,re):FI(bn,v,Cs,le,Re,Xe,ai,Jr,$e,Ot,Ut,De,Be,Bs,ot,St,Je,Or,vt)}v.uploadCommonUniforms(z,ts,Jr.toUnwrapped(),null,ut);let us=on.segments;if(Z.projection.name==="mercator"&&!Jt&&(us=on.getVisibleSegments(dn.tileID,v.terrain,v.transform.getFrustum(0)),!us.get().length))continue;if(Ar)if(Jt)for(const bn of us.get())Ar.numRenderedVerticesInShadowPass+=bn.primitiveLength;else for(const bn of us.get())Ar.numRenderedVerticesInTransparentPass+=bn.primitiveLength;const vn=[];(v.terrain||F)&&vn.push(on.centroidVertexBuffer),Ke&&vn.push(on.layoutVertexExtBuffer),pt&&vn.push(on.wallVertexBuffer),ts.draw(v,z.gl.TRIANGLES,j,R,L,Ir,Fs,g.id,on.layoutVertexBuffer,on.indexBuffer,us,g.paint,v.transform.zoom,En,vn)}v.shadowRenderer&&(v.shadowRenderer.useNormalOffset=!1)}class fj{constructor(){this.translate=[0,0],this.translateAnchor="map",this.edgeRadius=0,this.cutoffFadeRange=0}}function ew(v,d,g){if(!(d[2]<1)||g)return[0,0,1];const S=180*v/Math.PI;if(S<15)return[-.5,d[1],d[2]];const j=Math.min(1,Math.max(0,(S-15)/5)),R=j*j*(3-2*j);return[-.5*(1-R)+d[0]*R,d[1],d[2]]}function Zd(v,d,g,S,j,R,L,F,z,W,Z,ne,re,ie,ce,le,ve,_e,Re,Me,Te){const Xe=d.context,$e=Xe.gl,Ke=d.transform,De=d.transform.zoom,Be=[],Ge=v.translate,ot=v.translateAnchor,Je=v.edgeRadius,St=Wa(d,v.cutoffFadeRange);Z==="clear"?(Be.push("CLEAR_SUBPASS"),Me&&(Be.push("CLEAR_FROM_TEXTURE"),Xe.activeTexture.set($e.TEXTURE0),Me.bind($e.LINEAR,$e.CLAMP_TO_EDGE))):Z==="sdf"?Be.push("SDF_SUBPASS"):Z==="emissive"&&(Be.push("USE_MRT1"),Xe.activeTexture.set($e.TEXTURE0),Me.bind($e.LINEAR,$e.CLAMP_TO_EDGE)),_e&&Be.push("HAS_CENTROID"),St.shouldRenderCutoff&&Be.push("RENDER_CUTOFF");const pt=(Ot,Ut,ut,st,vt)=>{let Et=Be;Ut.groundRadiusBuffer!=null&&(Et=Be.concat("HAS_ATTRIBUTE_a_flood_light_ground_radius"));const Nt=Ut.programConfigurations.get(S.id),lr=d.isTileAffectedByFog(Ot),Jt=d.getOrCreateProgram("fillExtrusionGroundEffect",{config:Nt,defines:Et,overrideFog:lr}),er=((Ir,Or,vr,Ar,Jr,dn,on,Tn,Kr,En,ln)=>({u_matrix:Or,u_opacity:vr,u_ao_pass:Ar?1:0,u_meter_to_tile:Jr,u_ao:dn,u_flood_light_intensity:on,u_flood_light_color:Tn,u_attenuation:Kr,u_edge_radius:En,u_fb:0,u_fb_size:ln,u_dynamic_offset:1}))(0,st,ne,W,vt,[re,ie*vt],ce,le,ve,De>=17?0:Je*vt,Me?Me.size[0]:0),zt=[];_e&&zt.push(Ut.hiddenByLandmarkVertexBuffer),Ut.groundRadiusBuffer!=null&&zt.push(Ut.groundRadiusBuffer),d.uploadCommonUniforms(Xe,Jt,Ot.toUnwrapped(),null,St),Jt.draw(d,Xe.gl.TRIANGLES,R,L,F,z,er,S.id,Ut.vertexBuffer,Ut.indexBuffer,ut,S.paint,De,Nt,zt)};for(const Ot of j){const Ut=g.getTile(Ot),ut=Ut.getBucket(S);if(!ut||ut.projection.name!==Ke.projection.name||!ut.groundEffect||ut.groundEffect&&!ut.groundEffect.hasData())continue;const st=ut.groundEffect,vt=1/ut.tileToMeter;{const Et=d.translatePosMatrix(Ot.projMatrix,Ut,Ge,ot),Nt=st.getDefaultSegment();pt(Ot,st,Nt,Et,vt)}if(Re)for(let Et=0;Et<4;Et++){const Nt=a.d$[Et](Ot),lr=g.getTile(Nt);if(!lr)continue;const Jt=lr.getBucket(S);if(!Jt||Jt.projection.name!==Ke.projection.name||!Jt.groundEffect||Jt.groundEffect&&!Jt.groundEffect.hasData())continue;const er=Jt.groundEffect;let zt,Ir;Et===0?(zt=[-a.an,0,0],Ir=1):Et===1?(zt=[a.an,0,0],Ir=0):Et===2?(zt=[0,-a.an,0],Ir=3):(zt=[0,a.an,0],Ir=2);const Or=er.regionSegments[Ir];if(!Or)continue;const vr=new Float32Array(16);a.bx(vr,Ot.projMatrix,zt),pt(Ot,er,Or,d.translatePosMatrix(vr,Ut,Ge,ot),vt)}}}function ZI(v,d,g,S,j,R,L){S.centroidVertexArray.length===0&&S.createCentroidsBuffer();const F=R?R.findDEMTileFor(g):null;if(!(F&&F.dem||L))return;R&&F&&F.dem&&S.selfDEMTileTimestamp!==F.dem._timestamp&&(S.borderDoneWithNeighborZ=[-1,-1,-1,-1],S.selfDEMTileTimestamp=F.dem._timestamp);const z=(_e,Re)=>{(_e.flags|Re.flags)&a.e3?(_e.flags|=a.e3,Re.flags|=a.e3):(_e.flags&=~a.e3,Re.flags&=~a.e3)},W=_e=>new a.P(Math.ceil((_e+a.e4)*a.e5),0),Z=(_e,Re,Me)=>{const Te=Math.ceil((_e+a.e4)*a.e5),Xe=Math.floor(Math.max(0,Math.min(a.an-1,Me))/4);return new a.P(Te,Xe<<5|(3&Re)<<3|7)},ne=_e=>{const Re=d.getSource().minzoom,Me=Xe=>{const $e=d.getTileByID(Xe);if($e&&$e.hasData())return $e.getBucket(j)},Te=[0,-1,1];for(const Xe of Te){if(_e.overscaledZ+Xe(re[0]=Math.min(_e.min.y,Re.min.y),re[1]=Math.max(_e.max.y,Re.max.y),re[2]=a.an-Re.min.x>_e.max.x?Re.min.x-a.an:_e.max.x,re),ce=(_e,Re)=>(re[0]=Math.min(_e.min.x,Re.min.x),re[1]=Math.max(_e.max.x,Re.max.x),re[2]=a.an-Re.min.y>_e.max.y?Re.min.y-a.an:_e.max.y,re),le=[(_e,Re)=>ie(_e,Re),(_e,Re)=>ie(Re,_e),(_e,Re)=>ce(_e,Re),(_e,Re)=>ce(Re,_e)],ve=(_e,Re,Me,Te,Xe,$e,Ke)=>{if(!R)return 0;const De=[[$e?Me:_e,$e?_e:Me,0],[$e?Me:Re,$e?Re:Me,0]],Be=Ke<0?a.an+Ke:Ke,Ge=[$e?Be:(_e+Re)/2,$e?(_e+Re)/2:Be,0];return Me===0&&Ke<0||Me!==0&&Ke>0?R.getForTilePoints(Xe,[Ge],!0,Te):De.push(Ge),R.getForTilePoints(g,De,!0,F),Math.max(De[0][2],De[1][2],Ge[2])/R.exaggeration()};for(let _e=0;_e<4;_e++){const Re=S.borderFeatureIndices[_e];if(Re.length===0)continue;const Me=a.d$[_e](g),Te=ne(Me);if(!(Te&&Te instanceof a.e0))continue;const Xe=R?R.findDEMTileFor(Me):null;if(!(Xe&&Xe.dem||L)||(R&&Xe&&Xe.dem&&S.borderDEMTileTimestamp[_e]!==Xe.dem._timestamp&&(S.borderDoneWithNeighborZ[_e]=-1,S.borderDEMTileTimestamp[_e]=Xe.dem._timestamp),S.borderDoneWithNeighborZ[_e]===Te.canonical.z))continue;Te.centroidVertexArray.length===0&&Te.createCentroidsBuffer();const $e=(_e<2?1:5)-_e,Ke=Te.borderDoneWithNeighborZ[$e]!==S.canonical.z,De=Te.borderFeatureIndices[$e];let Be=0;if(S.canonical.z!==Te.canonical.z){for(const St of Re)S.showCentroid(S.featuresOnBorder[St]);if(Ke)for(const St of De)Te.showCentroid(Te.featuresOnBorder[St]);S.borderDoneWithNeighborZ[_e]=Te.canonical.z,Te.borderDoneWithNeighborZ[$e]=S.canonical.z;continue}const Ge=new Map,ot=new Set,Je=new Set;for(let St=0;St1||ut.intersectsCount()>1;{let Jt=0;if(Xe&&Xe.dem&&!lr){const er=le[_e](Ot,st),zt=_e%2?a.an-1:0;Jt=ve(er[0],Math.min(a.an-1,er[1]),zt,Xe,Me,_e<2,er[2])}Ot.centroidXY=Z(Jt,_e,Nt),st.centroidXY=Z(Jt,$e,Nt)}if(S.writeCentroidToBuffer(Ot),Te.writeCentroidToBuffer(st),pt.buildingId!==void 0){for(const Jt of S.centroidData)Jt.buildingId===pt.buildingId&&Jt!==Ot&&(Jt.centroidXY=Ot.centroidXY,S.writeCentroidToBuffer(Jt));for(const Jt of Te.centroidData)Jt.buildingId===pt.buildingId&&Jt!==st&&(Jt.centroidXY=st.centroidXY,Te.writeCentroidToBuffer(Jt))}}for(const St of Re){if(ot.has(St))continue;const pt=S.featuresOnBorder[St],Ot=S.centroidData[pt.centroidDataIndex],Ut=pt.borders[_e];let ut;for(;BeUt[0]+3||st[0]>Ut[0]-3)break;Te.showCentroid(ut),Be++}if(ut&&BeUt[1]-3||(vt++,++Be===De.length))break;ut=Te.featuresOnBorder[De[Be]]}for(;st=De.length){S.showCentroid(pt);continue}ut=Te.featuresOnBorder[De[st]];let Et=!1;if(vt>=1){const Jt=ut.borders[$e];Math.abs(Ut[0]-Jt[0])<3&&Math.abs(Ut[1]-Jt[1])<3&&(vt=1,Et=!0,Be=st+1)}else if(vt===0){S.showCentroid(pt);continue}const Nt=Te.centroidData[ut.centroidDataIndex];L&&Et&&z(Ot,Nt);const lr=pt.intersectsCount()>1||ut.intersectsCount()>1;if(vt>1)Be=st,Ot.centroidXY=Nt.centroidXY=new a.P(0,0);else if(Xe&&Xe.dem&&!lr){const Jt=le[_e](Ot,Nt),er=_e%2?a.an-1:0,zt=ve(Jt[0],Math.min(a.an-1,Jt[1]),er,Xe,Me,_e<2,Jt[2]);Ot.centroidXY=Nt.centroidXY=W(zt)}else lr?Ot.centroidXY=Nt.centroidXY=new a.P(0,0):(Ot.centroidXY=S.encodeBorderCentroid(pt),Nt.centroidXY=Te.encodeBorderCentroid(ut));S.writeCentroidToBuffer(Ot),Te.writeCentroidToBuffer(Nt)}else S.showCentroid(pt)}S.borderDoneWithNeighborZ[_e]=Te.canonical.z,Te.borderDoneWithNeighborZ[$e]=S.canonical.z}(S.needsCentroidUpdate||!S.centroidVertexBuffer&&S.centroidVertexArray.length!==0)&&S.uploadCentroid(v)}const XI=[1,0,0],QI=[0,1,0],mj=[0,0,1];function tw(v,d,g){const S=g.transform,j=g.shadowRenderer;if(!j)return!0;const R=v.toUnwrapped(),L=S.tileSize*j._cascades[g.currentShadowCascade].scale;let F=d;if(S.elevation){const ce=S.elevation.getMinMaxForTile(v);ce&&(F+=ce.max)}const z=S.scaleZoom(L);F/=a.e2(S.center.lat,z);const W=[...j.shadowDirection];W[2]=-W[2];const Z=j.computeSimplifiedTileShadowVolume(R,F,L,W);if(!Z)return!1;const ne=[XI,QI,mj,W,[W[0],0,W[2]],[0,W[1],W[2]]],re=a.cl.fromInvProjectionMatrix(S.invProjMatrix,S.worldSize,z,S.projection.name!=="globe"),ie=j.getCurrentCascadeFrustum();return re.intersectsPrecise(Z.vertices,Z.planes,ne)===0||ie.intersectsPrecise(Z.vertices,Z.planes,ne)===0}function i_(v){const{painter:d,source:g,layer:S,coords:j}=v;let R=v.defines;const L=d.context,F=d.renderPass==="shadow",z=d.renderPass==="light-beam",W=d.shadowRenderer,Z=a.e2(d.transform.center.lat,d.transform.zoom),ne=Wa(d,S.paint.get("building-cutoff-fade-range"));ne.shouldRenderCutoff&&(R=R.concat("RENDER_CUTOFF"));const re=S.paint.get("building-front-cutoff"),ie=re[2]<1&&!d.terrain,ce=ew(d.transform.pitch,re,!!d.terrain);ie&&(R=R.concat("RENDER_FRONT_CUTOFF"),d.maxFrontCutoffRawStart=Math.max(d.maxFrontCutoffRawStart,re[0])),v.floodLightIntensity>0&&(R=R.concat("FLOOD_LIGHT"));for(const le of j){const ve=g.getTile(le),_e=ve.getBucket(S);if(!_e)continue;W&&W.getMaxCascadeForTile(le.toUnwrapped())===0&&(R=R.concat("SHADOWS_SINGLE_CASCADE"));const Re=_e.programConfigurations.get(S.id);let Me,Te,Xe,$e=d.translatePosMatrix(le.expandedProjMatrix,ve,[0,0],"map");if($e=a.cC(a.bb(),$e,[1,1,v.verticalScale]),F&&W){if(tw(ve.tileID,_e.maxHeight*Z,d))continue;let De=W.calculateShadowPassMatrixFromTile(ve.tileID.toUnwrapped());De=a.cC(a.bb(),De,[1,1,v.verticalScale]),Xe=Hb(De),Me=Te=d.getOrCreateProgram("buildingDepth",{config:Re,defines:R,overrideFog:!1})}else if(z)Me=Te=d.getOrCreateProgram("buildingBloom",{config:Re,defines:R,overrideFog:!1}),Xe=Gb($e);else{const De=d.transform.calculatePosMatrix(le.toUnwrapped(),d.transform.worldSize);a.cC(De,De,[1,1,v.verticalScale]);const Be=a.bb();a.cC(Be,De,[1,-1,1/Z]),a.b7(Be,Be),a.e6(Be,Be);const Ge=d.transform.getFreeCameraOptions().position,ot=1<{if(z){const Ge=De.entranceBloom;Be.draw(d,L.gl.TRIANGLES,v.depthMode,an.disabled,v.blendMode,Zr.disabled,Xe,S.id,Ge.layoutVertexBuffer,Ge.indexBuffer,Ge.segmentsBucket,S.paint,d.transform.zoom,Re,[Ge.layoutAttenuationBuffer,Ge.layoutColorBuffer])}else{const Ge=De.segmentsBucket;let ot=[De.layoutNormalBuffer,De.layoutCentroidBuffer,De.layoutColorBuffer,De.layoutFloodLightDataBuffer];De.layoutFacadePaintBuffer&&(ot=ot.concat([De.layoutFacadeDataBuffer,De.layoutFacadeVerticalRangeBuffer,De.layoutFacadePaintBuffer])),Be.draw(d,L.gl.TRIANGLES,v.depthMode,an.disabled,v.blendMode,F?Zr.disabled:Zr.backCW,Xe,S.id,De.layoutVertexBuffer,De.indexBuffer,Ge,S.paint,d.transform.zoom,Re,ot)}};d.uploadCommonUniforms(L,Te,le.toUnwrapped(),null,ne),_e.buildingWithoutFacade&&Ke(_e.buildingWithoutFacade,Te),_e.buildingWithFacade&&(Me!==Te&&d.uploadCommonUniforms(L,Me,le.toUnwrapped(),null,ne),Ke(_e.buildingWithFacade,Me))}}function pj(v,d,g,S,j,R,L,F,z,W,Z,ne,re,ie){const ce=v.context.gl,le=v.depthModeForSublayer(1,Lr.ReadOnly,ce.LEQUAL,!0),ve=.1*(1-(_e=Z))+3*_e;var _e;const Re=v._showOverdrawInspector,Me=ne,Te=new fj;Re||Zd(Te,v,d,g,S,le,new an({func:ce.ALWAYS,mask:255},255,255,ce.KEEP,ce.KEEP,ce.REPLACE),new tn([ce.ONE,ce.ONE,ce.ONE,ce.ONE],a.aq.transparent,[!1,!1,!1,!0],ce.MIN),Zr.disabled,j,"sdf",R,L,F,z,W,ve,Me,!1,void 0);{const Xe=Re?an.disabled:new an({func:ce.EQUAL,mask:255},255,255,ce.KEEP,ce.DECR,ce.DECR),$e=Re?v.colorModeForRenderPass():new tn([ce.ONE_MINUS_DST_ALPHA,ce.DST_ALPHA,ce.ONE,ce.ONE],a.aq.transparent,[!0,!0,!0,!0]);Zd(Te,v,d,g,S,le,Xe,$e,Zr.disabled,j,"color",R,L,F,z,W,ve,Me,!1,void 0)}}function gj(v){return[v[0]*a.e7,v[1]*a.e7,v[2]*a.e7,0]}function rw(v,d,g,S,j,R,L,F,z){const W=S.getSource(),Z=g.globeSharedBuffers;if(!Z)return;let ne,re,ie;if(d&&(ne=S.getTile(d)),W instanceof a.aV?(re=W.texture,ie=a.dw(0,0,g.transform)):ne&&d&&(re=ne.texture,ie=a.dw(d.canonical.z,d.canonical.x,g.transform)),!re||!ie)return;v||(ie=a.cC(a.bb(),ie,[1,-1,1]));const ce=g.context,le=ce.gl,ve=j.paint.get("raster-resampling")==="nearest"?le.NEAREST:le.LINEAR,_e=g.colorModeForDrapableLayerRenderPass(R),Re=L.defines;Re.push("GLOBE_POLES");const Me=new Lr(le.LEQUAL,Lr.ReadWrite,g.depthRangeFor3D),Te=Float32Array.from(g.transform.expandedFarZProjMatrix),Xe=Float32Array.from(a.du(a.dv(new a.cn(0,0,0))));g.terrain&&g.terrain.prepareDrawTile(),ce.activeTexture.set(le.TEXTURE0),re.bind(ve,le.CLAMP_TO_EDGE),ce.activeTexture.set(le.TEXTURE1),re.bind(ve,le.CLAMP_TO_EDGE),"useMipmap"in re&&ce.extTextureFilterAnisotropic&&g.transform.pitch>20&&le.texParameterf(le.TEXTURE_2D,ce.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,ce.extTextureFilterAnisotropicMax);const[$e,Ke,De,Be]=d?Z.getPoleBuffers(d.canonical.z,!1):Z.getPoleBuffers(0,!0),Ge=j.paint.get("raster-elevation");let ot;v?(ot=$e,g.renderDefaultNorthPole=Ge!==0):(ot=Ke,g.renderDefaultSouthPole=Ge!==0);const Je=gj(L.mix),St=((Ot,Ut,ut,st,vt,Et,Nt,lr,Jt,er,zt,Ir,Or,vr)=>qI(Ot,Ut,ut,st,new Float32Array(16),new Float32Array(9),[0,0],vt,[0,0],[0,0,0,0],1,{opacity:1,mix:0},Nt,[0,0],Jt,2,zt,Ir,Or,1,0,vr))(g,Te,Xe,ie,a.al(g.transform.zoom),0,j,0,Ge,0,Je,L.offset,L.range,R),pt=g.getOrCreateProgram("raster",{defines:Re});g.uploadCommonUniforms(ce,pt,null),pt.draw(g,le.TRIANGLES,Me,z,_e,F,St,j.id,ot,De,Be)}function yj(v){if(v.isOrthographic)return[0,0,0,0];const d=v._nearZ,g=v.projection.farthestPixelDistance(v),S=g-d,j=.2*v.height,R=d+j;return[d,g,(R-j-d)/S,(R-d)/S]}function JI(v,d,g,S){if(v)return d instanceof fp&&v instanceof mp?d.getTextureDescriptor(v,g,!0):{texture:v.texture,mix:gj(S.mix),offset:S.offset,buffer:0,tileSize:1}}var xj=a.e8([{name:"a_index",type:"Int16",components:1}]);class eP{constructor(d,g,S,j){const R={width:S[0],height:S[1],data:null},L=d.gl;this.targetColorTexture=new a.T(d,R,L.RGBA8,{useMipmap:!1}),this.backgroundColorTexture=new a.T(d,R,L.RGBA8,{useMipmap:!1}),this.context=d,this.updateParticleTexture(g,j),this.lastInvalidatedAt=0}updateParticleTexture(d,g){if(this.particleTextureDimension===g.width)return;(this.particleTexture0||this.particleTexture1||this.particleIndexBuffer||this.particleSegment)&&(this.particleTexture0.destroy(),this.particleTexture1.destroy(),this.particleIndexBuffer.destroy(),this.particleSegment.destroy());const S=this.context.gl,j=g.width*g.height;this.particleTexture0=new a.T(this.context,g,S.RGBA8,{premultiply:!1,useMipmap:!1}),this.particleTexture1=new a.T(this.context,g,S.RGBA8,{premultiply:!1,useMipmap:!1});const R=new a.e9;R.reserve(j);for(let L=0;L0){const Je=a.ec(g.canonical,z),St=a.ed(Je);re=a.aD(new Float32Array(16),z.globeMatrix,St),a.aD(re,z.projMatrix,re)}const ie=a.bb();ie[12]+=2*j/(a.o.devicePixelRatio*z.width),ie[13]+=2*R/(a.o.devicePixelRatio*z.height),a.aD(re,ie,re);const ce=v.getOrCreateProgram("debug",{defines:ne}),le=d.getTileByID(g.key);v.terrain&&v.terrain.setupElevationDraw(le,ce);const ve=Lr.disabled,_e=an.disabled,Re=v.colorModeForRenderPass(),Me="$debug";F.activeTexture.set(W.TEXTURE0),v.emptyTexture.bind(W.LINEAR,W.CLAMP_TO_EDGE),Z?le._makeGlobeTileDebugBuffers(v.context,z):le._makeDebugTileBoundsBuffers(v.context,z.projection);const Te=le._tileDebugBuffer||v.debugBuffer,Xe=le._tileDebugIndexBuffer||v.debugIndexBuffer,$e=le._tileDebugSegments||v.debugSegments;if(ce.draw(v,W.LINE_STRIP,ve,_e,Re,Zr.disabled,J0(re,S.toPremultipliedRenderColor(null)),Me,Te,Xe,$e,null,null,null,[le._globeTileDebugBorderBuffer]),L){const Je=le.latestRawTileData,St=Math.floor((Je&&Je.byteLength||0)/1024);let pt=g.canonical.toString();g.overscaledZ!==g.canonical.z&&(pt+=` => ${g.overscaledZ}`),pt+=` ${le.state}`,pt+=` ${St}kb`,function(Ot,Ut){Ot.initDebugOverlayCanvas();const ut=Ot.debugOverlayCanvas,st=Ot.context.gl,vt=Ot.debugOverlayCanvas.getContext("2d");vt.clearRect(0,0,ut.width,ut.height),vt.shadowColor="white",vt.shadowBlur=2,vt.lineWidth=1.5,vt.strokeStyle="white",vt.textBaseline="top",vt.font="bold 36px Open Sans, sans-serif",vt.fillText(Ut,5,5),vt.strokeText(Ut,5,5),Ot.debugOverlayTexture.update(ut),Ot.debugOverlayTexture.bind(st.LINEAR,st.CLAMP_TO_EDGE)}(v,pt)}const Ke=d.getTile(g).tileSize,De=512/Math.min(Ke,512)*(g.overscaledZ/z.zoom)*.5,Be=le._tileDebugTextBuffer||v.debugBuffer,Ge=le._tileDebugTextIndexBuffer||v.quadTriangleIndexBuffer,ot=le._tileDebugTextSegments||v.debugSegments;ce.draw(v,W.TRIANGLES,ve,_e,tn.alphaBlended,Zr.disabled,J0(re,a.aq.transparent.toPremultipliedRenderColor(null),De),Me,Be,Ge,ot,null,null,null,[le._globeTileDebugTextBuffer])}function rP(v,d,g,S){nw(v,0,d+g/2,v.transform.width,g,S)}function Sj(v,d,g,S){nw(v,d-g/2,0,g,v.transform.height,S)}function nw(v,d,g,S,j,R){const L=v.context,F=L.gl;F.enable(F.SCISSOR_TEST),F.scissor(d*a.o.devicePixelRatio,g*a.o.devicePixelRatio,S*a.o.devicePixelRatio,j*a.o.devicePixelRatio),L.clear({color:R}),F.disable(F.SCISSOR_TEST)}const uB=a.e8([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:wc}=uB;function Xd(v,d,g,S){v.emplaceBack(d,g,S)}class hl{constructor(d){this.vertexArray=new a.ee,this.indices=new a.dC,Xd(this.vertexArray,-1,-1,1),Xd(this.vertexArray,1,-1,1),Xd(this.vertexArray,-1,1,1),Xd(this.vertexArray,1,1,1),Xd(this.vertexArray,-1,-1,-1),Xd(this.vertexArray,1,-1,-1),Xd(this.vertexArray,-1,1,-1),Xd(this.vertexArray,1,1,-1),this.indices.emplaceBack(5,1,3),this.indices.emplaceBack(3,7,5),this.indices.emplaceBack(6,2,0),this.indices.emplaceBack(0,4,6),this.indices.emplaceBack(2,6,7),this.indices.emplaceBack(7,3,2),this.indices.emplaceBack(5,4,0),this.indices.emplaceBack(0,1,5),this.indices.emplaceBack(0,2,3),this.indices.emplaceBack(3,1,0),this.indices.emplaceBack(7,6,4),this.indices.emplaceBack(4,5,7),this.vertexBuffer=d.createVertexBuffer(this.vertexArray,wc),this.indexBuffer=d.createIndexBuffer(this.indices),this.segment=a.dy.simpleSegment(0,0,36,12)}}function Hc(v,d,g,S,j,R){const L=v.context.gl,F=d.paint.get("sky-atmosphere-color"),z=d.paint.get("sky-atmosphere-halo-color"),W=d.paint.get("sky-atmosphere-sun-intensity"),Z=((ne,re,ie,ce,le)=>({u_matrix_3f:ne,u_sun_direction:re,u_sun_intensity:ie,u_color_tint_r:[ce.r,ce.g,ce.b,ce.a],u_color_tint_m:[le.r,le.g,le.b,le.a],u_luminance:5e-5}))(a.eg(a.dE(),S),j,W,F.toPremultipliedRenderColor(null),z.toPremultipliedRenderColor(null));L.framebufferTexture2D(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_CUBE_MAP_POSITIVE_X+R,d.skyboxTexture,0),g.draw(v,L.TRIANGLES,Lr.disabled,an.disabled,tn.unblended,Zr.frontCW,Z,"skyboxCapture",d.skyboxGeometry.vertexBuffer,d.skyboxGeometry.indexBuffer,d.skyboxGeometry.segment)}const nP=a.e8([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2}]);class Tj{constructor(d){const g=new a.eh;g.emplaceBack(-1,1,1,0,0),g.emplaceBack(1,1,1,1,0),g.emplaceBack(1,-1,1,1,1),g.emplaceBack(-1,-1,1,0,1);const S=new a.dC;S.emplaceBack(0,1,2),S.emplaceBack(2,3,0),this.vertexBuffer=d.createVertexBuffer(g,nP.members),this.indexBuffer=d.createIndexBuffer(S),this.segments=a.dy.simpleSegment(0,0,4,2)}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy()}}const Ej=a.e8([{type:"Float32",name:"a_pos_3f",components:3},{type:"Float32",name:"a_uv",components:2},{type:"Float32",name:"a_size_scale",components:1},{type:"Float32",name:"a_opacity",components:1}]);class jj{constructor(){this.starsCount=16e3,this.sizeMultiplier=.15,this.sizeRange=100,this.intensityRange=200}}class sP{constructor(d){this.colorModeAlphaBlendedWriteRGB=new tn([1,Ui,1,Ui],a.aq.transparent,[!0,!0,!0,!1]),this.colorModeWriteAlpha=new tn([1,0,1,0],a.aq.transparent,[!1,!1,!1,!0]),this.params=new jj,this.updateNeeded=!0}update(d){const g=d.context;if(!this.atmosphereBuffer||this.updateNeeded){this.updateNeeded=!1,this.atmosphereBuffer=new Tj(g);const S=this.params.sizeRange,j=this.params.intensityRange,R=function(Z){const ne=a.em(30),re=[];for(let ie=0;ie{const De=R.projection.name==="globe"?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"];Ke&&De.push("ALPHA_PASS");const Be=d.getOrCreateProgram("globeAtmosphere",{defines:De}),Ge=((Je,St,pt,Ot,Ut,ut,st,vt,Et,Nt,lr,Jt)=>({u_frustum_tl:Je,u_frustum_tr:St,u_frustum_br:pt,u_frustum_bl:Ot,u_horizon:Ut,u_transition:ut,u_fadeout_range:st,u_atmosphere_fog_color:vt.toArray01(),u_high_color:Et.toArray01(),u_space_color:Nt.toArray01(),u_temporal_offset:lr,u_horizon_angle:Jt}))(R.frustumCorners.TL,R.frustumCorners.TR,R.frustumCorners.BR,R.frustumCorners.BL,R.frustumCorners.horizon,F,ve,Z,re,ce,Re,Xe);d.uploadCommonUniforms(S,Be);const ot=this.atmosphereBuffer;ot&&Be.draw(d,j.TRIANGLES,L,an.disabled,Ke?this.colorModeWriteAlpha:this.colorModeAlphaBlendedWriteRGB,Zr.backCW,Ge,Ke?"atmosphere_glow_alpha":"atmosphere_glow",ot.vertexBuffer,ot.indexBuffer,ot.segments)};$e(!1),$e(!0)}drawStars(d,g){const S=a.aC(g.properties.get("star-intensity"),0,1);if(S===0)return;const j=d.context,R=j.gl,L=d.transform,F=d.getOrCreateProgram("stars"),z=a.bL([]);a.bN(z,z,-L._pitch),a.bM(z,z,-L.angle),a.bN(z,z,a.ap(L._center.lat)),a.ek(z,z,-a.ap(L._center.lng));const W=a.bR(new Float32Array(16),z),Z=a.aD([],L.starsProjMatrix,W),ne=a.eg([],W),re=a.el([],ne),ie=[0,1,0];a.dG(ie,ie,re),a.bJ(ie,ie,this.params.sizeMultiplier);const ce=[1,0,0];a.dG(ce,ce,re),a.bJ(ce,ce,this.params.sizeMultiplier);const le=(ve=ie,_e=ce,Re=S,{u_matrix:Float32Array.from(Z),u_up:ve,u_right:_e,u_intensity_multiplier:Re});var ve,_e,Re;d.uploadCommonUniforms(j,F),this.starsVx&&this.starsIdx&&F.draw(d,R.TRIANGLES,Lr.disabled,an.disabled,this.colorModeAlphaBlendedWriteRGB,Zr.disabled,le,"atmosphere_stars",this.starsVx,this.starsIdx,this.starsSegments)}}class qh{constructor(){this.visibleTiles=[]}updateBorders(d,g){const S=[],j=[],R=d._getRenderableCoordinates(!1,!0);for(const z of R){const W=d.getTile(z);if(!W.hasData())continue;const Z=W.getBucket(g);Z&&(Z.isEmpty()||(S.push(z.key),j.push({bucket:Z,tileID:z.canonical})))}let L=S.length!==this.visibleTiles.length;if(!L){S.sort();for(let z=0;zz.tileID.z-W.tileID.z||z.tileID.x-W.tileID.x||z.tileID.y-W.tileID.y);for(const z of j){const W=new Array,Z=new Array,ne=z.bucket;for(const re of ne.featuresOnBorder)F.has(re.featureId)?Z.push(re.footprintIndex):(F.add(re.featureId),W.push(re.footprintIndex));ne.updateFootprintHiddenFlags(W,a.en,!1),ne.updateFootprintHiddenFlags(Z,a.en,!0)}}}function iP(v,d){const g=[...v],S=d.cameraWorldSizeForFog/d.worldSize,j=a.b9([]);return a.cC(j,j,[S,S,1]),a.aD(g,j,g),a.aD(g,d.worldToFogMatrix,g),g}function fs(v,d,g,S,j){const R=g.material,L=S.context,{baseColorTexture:F,metallicRoughnessTexture:z}=R.pbrMetallicRoughness,{normalTexture:W,occlusionTexture:Z,emissionTexture:ne}=R;function re(ce,le,ve){if(ce&&(v.push(le),L.activeTexture.set(L.gl.TEXTURE0+ve),ce.gfxTexture)){const{minFilter:_e,magFilter:Re,wrapS:Me,wrapT:Te}=ce.sampler;ce.gfxTexture.bindExtraParam(_e,Re,Me,Te)}}re(F,"HAS_TEXTURE_u_baseColorTexture",5),re(z,"HAS_TEXTURE_u_metallicRoughnessTexture",6),re(W,"HAS_TEXTURE_u_normalTexture",7),re(Z,"HAS_TEXTURE_u_occlusionTexture",8),re(ne,"HAS_TEXTURE_u_emissionTexture",9),j&&(j.texture||(j.texture=new a.dR(S.context,j.image,[j.image.height,j.image.height,j.image.height],L.gl.RGBA8)),L.activeTexture.set(L.gl.TEXTURE0+10),j.texture&&j.texture.bind(L.gl.LINEAR,L.gl.CLAMP_TO_EDGE),v.push("APPLY_LUT_ON_GPU")),g.texcoordBuffer&&(v.push("HAS_ATTRIBUTE_a_uv_2f"),d.push(g.texcoordBuffer)),g.colorBuffer&&(v.push(g.colorBuffer.itemSize===12?"HAS_ATTRIBUTE_a_color_3f":"HAS_ATTRIBUTE_a_color_4f"),d.push(g.colorBuffer)),g.normalBuffer&&(v.push("HAS_ATTRIBUTE_a_normal_3f"),d.push(g.normalBuffer)),g.pbrBuffer&&(v.push("HAS_ATTRIBUTE_a_pbr"),v.push("HAS_ATTRIBUTE_a_heightBasedEmissiveStrength"),d.push(g.pbrBuffer)),R.alphaMode!=="OPAQUE"&&R.alphaMode!=="MASK"||v.push("UNPREMULT_TEXTURE_IN_SHADER"),R.defined||v.push("DIFFUSE_SHADED");const ie=S.shadowRenderer;ie&&(v.push("RENDER_SHADOWS"),ie.useNormalOffset&&v.push("NORMAL_OFFSET"))}function py(v,d,g,S,j,R){const L=v.modelOpacity,F=d.context,z=new Lr(d.context.gl.LEQUAL,v.isLightMesh?Lr.ReadOnly:Lr.ReadWrite,d.depthRangeFor3D),W=d.transform,Z=v.mesh,ne=Z.material,re=ne.pbrMetallicRoughness,ie=d.style.fog;let ce;ce=d.transform.projection.zAxisUnit==="pixels"?[...v.nodeModelMatrix]:a.aD([],S.zScaleMatrix,v.nodeModelMatrix),a.aD(ce,S.negCameraPosMatrix,ce);const le=a.b7([],ce);a.e6(le,le);const ve=g.paint.get("model-color-use-theme").constantOr("default")==="none",_e=g.paint.get("model-emissive-strength").constantOr(0),Re=Ep(new Float32Array(v.worldViewProjection),new Float32Array(ce),new Float32Array(le),null,d,L,re.baseColorFactor,ne.emissiveFactor,re.metallicFactor,re.roughnessFactor,ne,_e,g,void 0,void 0,v.materialOverride,v.modelColor),Me={defines:[]},Te=[],Xe=d.shadowRenderer;Xe&&(Xe.useNormalOffset=!1),fs(Me.defines,Te,Z,d,ve?null:g.lut);let $e=null;if(ie){const Be=iP(v.nodeModelMatrix,d.transform);if($e=new Float32Array(Be),W.projection.name!=="globe"){const Ge=Z.aabb.min,ot=Z.aabb.max,[Je,St]=ie.getOpacityForBounds(Be,Ge[0],Ge[1],ot[0],ot[1]);Me.overrideFog=Je>=xr||St>=xr}}const Ke=Wa(d,g.paint.get("model-cutoff-fade-range"));Ke.shouldRenderCutoff&&Me.defines.push("RENDER_CUTOFF");const De=d.getOrCreateProgram("model",Me);d.uploadCommonUniforms(F,De,null,$e,Ke),d.renderPass!=="shadow"&&Xe&&Xe.setupShadowsFromMatrix(v.nodeModelMatrix,De),De.draw(d,F.gl.TRIANGLES,z,j,R,Z.material.doubleSided?Zr.disabled:Zr.backCCW,Re,g.id,Z.vertexBuffer,Z.indexBuffer,Z.segments,g.paint,d.transform.zoom,void 0,Te)}function sw(v,d){return v.style._importedAsBasemap?"basemap":d.scope}function iw(v,d,g,S,j,R,L,F,z,W){const Z=v.transform,ne=!!d.isGeometryBloom&&d.isGeometryBloom;if(ne&&v.renderPass==="shadow")return;const re=Z.projection.name==="globe"?a.ev(g,Z):[...g];a.aD(re,re,d.globalMatrix);const ie=a.aD([],S,re);if(d.meshes)for(const ce of d.meshes){const le=F.get(ce.material.name);if(le&&le.opacity<=0)continue;if(ce.material.alphaMode!=="BLEND"){L.push({mesh:ce,depth:0,modelIndex:j,worldViewProjection:ie,nodeModelMatrix:re,isLightMesh:ne,materialOverride:le,modelOpacity:z,modelColor:W,node:d,modelMatrix:g});continue}const ve=a.ah([],ce.centroid,ie);!Z.isOrthographic&&ve[2]<=0||R.push({mesh:ce,depth:ve[2],modelIndex:j,worldViewProjection:ie,nodeModelMatrix:re,isLightMesh:ne,materialOverride:le,modelOpacity:z,modelColor:W,node:d,modelMatrix:g})}if(d.children)for(const ce of d.children)iw(v,ce,g,S,j,R,L,F,z,W)}function gy(v,d,g,S){const j=g.shadowRenderer;if(!j)return;const R=j.getShadowPassDepthMode(),L=j.calculateShadowPassMatrixFromMatrix(d),F=uj(L);g.getOrCreateProgram("modelDepth").draw(g,g.context.gl.TRIANGLES,R,an.disabled,tn.disabled,Zr.disabled,F,S.id,v.vertexBuffer,v.indexBuffer,v.segments,S.paint,g.transform.zoom,void 0,void 0)}function kj(v,d,g,S){const j=function(Z,ne){if(ne.footprintDebugMesh)return ne.footprintDebugMesh;if(!ne.footprint)return null;const re=Z.context,ie=ne.footprint.vertices,ce=ne.footprint.indices,le=new a.dB;le.reserve(ie.length);for(const Ge of ie)le.emplaceBack(Ge.x,Ge.y);const ve=new a.dC;ve.reserve(ce.length);for(let Ge=0;Ge0){const re=R.terrain,ie=re.findDEMTileFor(F);ie&&ie.dem?z=a.ex.create(re,F,ie):ne=0}if(ne===0&&(L.terrainElevationMin=0,L.terrainElevationMax=0),ne===L.validForExaggeration&&(ne===0||z&&z._demTile&&z._demTile.tileID===L.validForDEMTile.id&&z._dem._timestamp===L.validForDEMTile.timestamp))return!1;for(const re in L.instancesPerModel){const ie=L.instancesPerModel[re];for(let ce=0;ceW&&(W=ie.max)}const Z=a.aC(S.x,R,L)-S.x,ne=a.aC(S.y,F,z)-S.y,re=a.bU(W,d.center.lat)-S.z;return d._zoomFromMercatorZ(Math.sqrt(Z*Z+ne*ne+re*re))}function hi(v,d,g,S,j,R,L){const F=v.context,z=v.renderPass==="shadow",W=v.shadowRenderer,Z=z&&W?W.getShadowPassDepthMode():new Lr(F.gl.LEQUAL,Lr.ReadWrite,v.depthRangeFor3D),ne=v.isTileAffectedByFog(R),re=v.transform.projection.name==="globe";if(g.meshes)for(const ie of g.meshes){const ce=re?[]:["MODEL_POSITION_ON_GPU"],le=[];let ve,_e,Re;const Me=!re&&S.instancedDataArray.length>20;Me&&ce.push("INSTANCED_ARRAYS");const Te=Wa(v,d.paint.get("model-cutoff-fade-range"));if(Te.shouldRenderCutoff&&ce.push("RENDER_CUTOFF"),z&&W)ve=v.getOrCreateProgram("modelDepth",{defines:ce}),_e=uj(L.shadowTileMatrix,L.shadowTileMatrix,Float32Array.from(g.globalMatrix)),Re=tn.disabled;else{fs(ce,le,ie,v,d.paint.get("model-color-use-theme").constantOr("default")==="none"?null:d.lut),ve=v.getOrCreateProgram("model",{defines:ce,overrideFog:ne});const $e=ie.material,Ke=$e.pbrMetallicRoughness,De=d.paint.get("model-opacity").constantOr(1),Be=d.paint.get("model-emissive-strength").constantOr(0);_e=Ep(R.expandedProjMatrix,Float32Array.from(g.globalMatrix),new Float32Array(16),null,v,De,Ke.baseColorFactor,$e.emissiveFactor,Ke.metallicFactor,Ke.roughnessFactor,$e,Be,d,j),W&&(L.shadowUniformsInitialized?ve.setShadowUniformValues(F,W.getShadowUniformValues()):(W.setupShadows(R.toUnwrapped(),ve,"model-tile"),L.shadowUniformsInitialized=!0)),Re=Te.shouldRenderCutoff||De<1||$e.alphaMode!=="OPAQUE"?tn.alphaBlended:tn.unblended}v.uploadCommonUniforms(F,ve,R.toUnwrapped(),null,Te);const Xe=ie.material.doubleSided?Zr.disabled:Zr.backCCW;if(Me)le.push(S.instancedDataBuffer),ve.draw(v,F.gl.TRIANGLES,Z,an.disabled,Re,Xe,_e,d.id,ie.vertexBuffer,ie.indexBuffer,ie.segments,d.paint,v.transform.zoom,void 0,le,S.instancedDataArray.length);else{const $e=z?"u_instance":"u_normal_matrix";for(let Ke=0;Kez[1]?L:z,R[0]=g.max[0],L=a.aE(a.bE(),R,j),F=L[1]z[1]?L:z,R[1]=g.min[1],L=a.aE(a.bE(),R,j),F=L[1]z[1]?L:z;const W=a.aC(S[0],0,1),Z=100*d.pixelsPerMeter*a.aC(S[1],0,1),ne=a.aC(S[2],0,1),re=a.ey(a.bE(),F,z,W),ie=Math.tan(.5*d.fovX),ce=-re[2]*ie;if(Z===0)return re[1]<-Math.abs(ce)?ne:1;const le=(-Math.abs(ce)-re[1])/Z,ve=(Re,Me,Te)=>(1-Te)*Re+Te*Me,_e=a.aC(ve(1,ne,le),ne,1);return ve(1,_e,a.aC((d.pitch-20)/20,0,1))}class ow{}class oP{constructor(){this._storage=new Map}getLinesFromTrianglesBuffer(d,g,S){{const ne=this._storage.get(g.id);if(ne)return ne.lastUsedFrameIdx=d,ne.buf}const j=S.gl,R=j.getBufferParameter(j.ELEMENT_ARRAY_BUFFER,j.BUFFER_SIZE),L=new ArrayBuffer(R),F=new Int16Array(L);j.getBufferSubData(j.ELEMENT_ARRAY_BUFFER,0,new Int16Array(L));const z=new a.eA;for(let ne=0;ne30&&(S.buf.destroy(),this._storage.delete(g))}destroy(){for(const[d,g]of this._storage)g.buf.destroy(),this._storage.delete(d)}}class lP{constructor(){this.occluderSize=30,this.depthOffset=-1e-4}}const xy=a.e8([{type:"Float32",name:"a_pos_3f",components:3},{type:"Float32",name:"a_uv",components:2},{type:"Float32",name:"a_rainParticleData",components:4}]);class cP{constructor(d){this.revealStart=11,this.revealRange=2}}const dB=a.e8([{type:"Float32",name:"a_pos_2f",components:2}]);class uP{destroy(){this.vignetteVx&&this.vignetteVx.destroy(),this.vignetteIdx&&this.vignetteIdx.destroy()}draw(d,g){const S=d.getOrCreateProgram("vignette");if(!this.vignetteVx||!this.vignetteIdx){const L=new a.eB,F=new a.dC;L.emplaceBack(-1,-1),L.emplaceBack(1,-1),L.emplaceBack(1,1),L.emplaceBack(-1,1),F.emplaceBack(0,1,2),F.emplaceBack(0,2,3),this.vignetteVx=d.context.createVertexBuffer(L,dB.members),this.vignetteIdx=d.context.createIndexBuffer(F)}const j=a.dy.simpleSegment(0,0,4,6);if(this.vignetteVx&&this.vignetteIdx){d.uploadCommonUniforms(d.context,S);const L={u_vignetteShape:(R={vignetteShape:[g.start,g.range,Math.pow(10,g.fadePower)],vignetteColor:[g.color.r,g.color.g,g.color.b,g.color.a*g.strength]}).vignetteShape,u_vignetteColor:R.vignetteColor};S.draw(d,d.context.gl.TRIANGLES,Lr.disabled,an.disabled,tn.alphaBlended,Zr.disabled,L,"vignette",this.vignetteVx,this.vignetteIdx,j)}var R}}class lw{constructor(){this._accumulatedOffsetX=0,this._accumulatedOffsetY=0,this._accumulatedElevation=0}update(d,g){const S=d.getFreeCameraOptions().position,j=S.toAltitude(),R=S.toLngLat(),L=a.ap(R.lng),F=a.ap(R.lat),z=d.pixelsPerMeter/g,W=L*a.eD,Z=a.eD*Math.log(Math.tan(Math.PI/4+F/2));if(this._offsetXPrev===void 0)this._offsetXPrev=0,this._offsetYPrev=0,this._elevationPrev=0,this._accumulatedOffsetX=0,this._accumulatedOffsetY=0,this._accumulatedElevation=0;else{const ne=-this._offsetYPrev+Z,re=-this._elevationPrev+j;this._accumulatedOffsetX+=(-this._offsetXPrev+W)*z,this._accumulatedOffsetY+=ne*z,this._accumulatedElevation+=re*z,this._offsetXPrev=W,this._offsetYPrev=Z,this._elevationPrev=j}}getPosition(){return[this._accumulatedOffsetX,this._accumulatedOffsetY,this._accumulatedElevation]}}function cw(v,d){return[-(v[0]-Math.floor(v[0]/d)*d),-(v[1]-Math.floor(v[1]/d)*d),-(v[2]-Math.floor(v[2]/d)*d)]}function Cj(v){const d=a.em(1323123451230),g=[];for(let S=0;S Rain"),this._vignetteParams={strength:1,start:.7,range:1,fadePower:.4,color:{r:.27,g:.27,b:.27,a:1}},this.particlesCount=16e3}update(d){const g=d.context;if(!this.particlesVx){const S=Cj(this.particlesCount),j=new a.eE,R=new a.dC;let L=0;const F=a.em(1323123451230);for(let z=0;zS)return;const j=Hh(0,1,g.revealStart,g.revealStart+g.revealRange,S);if(!this.particlesVx||!this.particlesIdx)return;const R=structuredClone(this._params);let L=[-R.direction.x,R.direction.y,-100];a.ay(L,L);const F=structuredClone(this._vignetteParams);F.strength*=j,R.overrideStyleParameters||(R.intensity=d.style.rain.state.density,R.timeFactor=d.style.rain.state.intensity,R.color=structuredClone(d.style.rain.state.color),L=structuredClone(d.style.rain.state.direction),R.screenThinning.intensity=d.style.rain.state.centerThinning,R.dropletSizeX=d.style.rain.state.dropletSize[0],R.dropletSizeYScale=d.style.rain.state.dropletSize[1]/d.style.rain.state.dropletSize[0],R.distortionStrength=100*d.style.rain.state.distortionStrength,F.strength=1,F.color=structuredClone(d.style.rain.state.vignetteColor));const z=this.updateOnRender(d,R.timeFactor),W=d.context,Z=W.gl,ne=d.transform;this.screenTexture&&this.screenTexture.size[0]===d.width&&this.screenTexture.size[1]===d.height||(this.screenTexture=new a.T(W,{width:d.width,height:d.height,data:null},Z.RGBA8)),R.distortionStrength>0&&(W.activeTexture.set(Z.TEXTURE0),this.screenTexture.bind(Z.LINEAR,Z.CLAMP_TO_EDGE),Z.copyTexSubImage2D(Z.TEXTURE_2D,0,0,0,0,0,d.width,d.height));const re=d.getOrCreateProgram("rainParticle");d.uploadCommonUniforms(W,re),W.activeTexture.set(Z.TEXTURE0),this.screenTexture.bind(Z.LINEAR,Z.CLAMP_TO_EDGE);const ie=[R.color.r,R.color.g,R.color.b,R.color.a],ce=(le,ve)=>{const _e=cw(this._movement.getPosition(),le),Re=R.dropletSizeX,Me=R.dropletSizeX*R.dropletSizeYScale,Te=d.width/2,Xe=d.height/2,$e=Hh(0,R.screenThinning.start,0,1,R.screenThinning.intensity),Ke=Hh(.001,R.screenThinning.range,0,1,R.screenThinning.intensity),De=Hh(0,R.screenThinning.particleOffset,0,1,R.screenThinning.intensity),Be=(Ge={modelview:z.modelviewMatrix,projection:z.projectionMatrix,time:this._accumulatedTimeFromStart,camPos:_e,velocityConeAperture:R.velocityConeAperture,velocity:R.velocity,boxSize:le,rainDropletSize:[Re,Me],distortionStrength:R.distortionStrength,rainDirection:L,color:ie,screenSize:[ne.width,ne.height],thinningCenterPos:[Te,Xe],thinningShape:[$e,Ke,Math.pow(10,R.screenThinning.fadePower)],thinningAffectedRatio:R.screenThinning.affectedRatio,thinningParticleOffset:De,shapeDirectionalPower:R.shapeDirPower,shapeNormalPower:R.shapeNormalPower,mode:ve?0:1},{u_modelview:Float32Array.from(Ge.modelview),u_projection:Float32Array.from(Ge.projection),u_time:Ge.time,u_cam_pos:Ge.camPos,u_texScreen:0,u_velocityConeAperture:Ge.velocityConeAperture,u_velocity:Ge.velocity,u_boxSize:Ge.boxSize,u_rainDropletSize:Ge.rainDropletSize,u_distortionStrength:Ge.distortionStrength,u_rainDirection:Ge.rainDirection,u_color:Ge.color,u_screenSize:Ge.screenSize,u_thinningCenterPos:Ge.thinningCenterPos,u_thinningShape:Ge.thinningShape,u_thinningAffectedRatio:Ge.thinningAffectedRatio,u_thinningParticleOffset:Ge.thinningParticleOffset,u_shapeDirectionalPower:Ge.shapeDirectionalPower,u_shapeNormalPower:Ge.shapeNormalPower,u_mode:Ge.mode});var Ge;const ot=Math.round(R.intensity*this.particlesCount),Je=a.dy.simpleSegment(0,0,4*ot,2*ot);re.draw(d,Z.TRIANGLES,Lr.disabled,an.disabled,tn.alphaBlended,Zr.disabled,Be,"rain_particles",this.particlesVx,this.particlesIdx,Je)};R.distortionStrength>0&&ce(R.boxSize,!0),ce(R.boxSize,!1),this._vignette.draw(d,F)}}const Cp=a.e8([{type:"Float32",name:"a_pos_3f",components:3},{type:"Float32",name:"a_uv",components:2},{type:"Float32",name:"a_snowParticleData",components:4},{type:"Float32",name:"a_snowParticleDataHorizontalOscillation",components:2}]);class dP extends a_{constructor(d){super(2.25),this._params={overrideStyleParameters:!1,intensity:.85,timeFactor:.75,velocityConeAperture:70,velocity:40,horizontalOscillationRadius:4,horizontalOscillationRate:1.5,boxSize:2e3,billboardSize:2,shapeFadeStart:.27,shapeFadePower:.21,screenThinning:{intensity:.4,start:.15,range:1.4,fadePower:.24,affectedRatio:1,particleOffset:-.2},color:{r:1,g:1,b:1,a:1},direction:{x:-50,y:-35}},this._revealParams=new cP("Precipitation > Snow"),this._vignetteParams={strength:.3,start:.78,range:.46,fadePower:.2,color:{r:1,g:1,b:1,a:1}},this.particlesCount=16e3}update(d){const g=d.context;if(!this.particlesVx){const S=Cj(this.particlesCount),j=new a.eF,R=new a.dC;let L=0;const F=a.em(1323123451230);for(let z=0;zL)return;const F=Hh(0,1,R.revealStart,R.revealStart+R.revealRange,L);j.strength*=F,g.overrideStyleParameters||(g.intensity=d.style.snow.state.density,g.timeFactor=d.style.snow.state.intensity,g.color=structuredClone(d.style.snow.state.color),S=structuredClone(d.style.snow.state.direction),g.screenThinning.intensity=d.style.snow.state.centerThinning,g.billboardSize=2.79*d.style.snow.state.flakeSize,j.strength=1,j.color=structuredClone(d.style.snow.state.vignetteColor));const z=this.updateOnRender(d,g.timeFactor);if(!this.particlesVx||!this.particlesIdx)return;const W=d.context,Z=W.gl,ne=d.transform,re=d.getOrCreateProgram("snowParticle");d.uploadCommonUniforms(W,re),((ie,ce,le)=>{const ve=cw(this._movement.getPosition(),ie),_e=ne.width/2,Re=ne.height/2,Me=Hh(0,le.screenThinning.start,0,1,le.screenThinning.intensity),Te=Hh(.001,le.screenThinning.range,0,1,le.screenThinning.intensity),Xe=Hh(0,le.screenThinning.particleOffset,0,1,le.screenThinning.intensity),$e=(Ke={modelview:z.modelviewMatrix,projection:z.projectionMatrix,time:this._accumulatedTimeFromStart,camPos:ve,velocityConeAperture:le.velocityConeAperture,velocity:le.velocity,horizontalOscillationRadius:le.horizontalOscillationRadius,horizontalOscillationRate:le.horizontalOscillationRate,boxSize:ie,billboardSize:1*le.billboardSize,simpleShapeParameters:[le.shapeFadeStart,le.shapeFadePower],screenSize:[ne.width,ne.height],thinningCenterPos:[_e,Re],thinningShape:[Me,Te,Math.pow(10,le.screenThinning.fadePower)],thinningAffectedRatio:le.screenThinning.affectedRatio,thinningParticleOffset:Xe,color:[le.color.r,le.color.g,le.color.b,le.color.a],direction:S},{u_modelview:Float32Array.from(Ke.modelview),u_projection:Float32Array.from(Ke.projection),u_time:Ke.time,u_cam_pos:Ke.camPos,u_velocityConeAperture:Ke.velocityConeAperture,u_velocity:Ke.velocity,u_horizontalOscillationRadius:Ke.horizontalOscillationRadius,u_horizontalOscillationRate:Ke.horizontalOscillationRate,u_boxSize:Ke.boxSize,u_billboardSize:Ke.billboardSize,u_simpleShapeParameters:Ke.simpleShapeParameters,u_screenSize:Ke.screenSize,u_thinningCenterPos:Ke.thinningCenterPos,u_thinningShape:Ke.thinningShape,u_thinningAffectedRatio:Ke.thinningAffectedRatio,u_thinningParticleOffset:Ke.thinningParticleOffset,u_particleColor:Ke.color,u_direction:Ke.direction});var Ke;const De=Math.round(le.intensity*this.particlesCount),Be=a.dy.simpleSegment(0,0,4*De,2*De);this.particlesVx&&this.particlesIdx&&re.draw(d,Z.TRIANGLES,Lr.disabled,an.disabled,tn.alphaBlended,Zr.disabled,$e,"snow_particles",this.particlesVx,this.particlesIdx,Be)})(g.boxSize,0,g),this._vignette.draw(d,j)}}const hP={symbol:function(v,d,g,S,j){if(v.renderPass!=="translucent")return;const R=an.disabled,L=v.colorModeForRenderPass(),F=g.layout.get("text-variable-anchor"),z=g.layout.get("text-size-scale-range"),W=a.aC(v.scaleFactor,z[0],z[1]);F&&function(re,ie,ce,le,ve,_e,Re,Me){const Te=ie.transform,Xe=ve==="map",$e=_e==="map";for(const Ke of re){const De=le.getTile(Ke),Be=De.getBucket(ce);if(!Be||!Be.text||!Be.text.segments.get().length)continue;const Ge=a.bj(Be.textSizeData,Te.zoom,Me),ot=pp(Ke,Be.getProjection(),Te),Je=Te.calculatePixelsToTileUnitsMatrix(De),St=Hf(ot,De.tileID.canonical,$e,Xe,Te,Be.getProjection(),Je),pt=Be.hasIconTextFit()&&Be.hasIconData();Ge&&YI(Be,Xe,$e,Re,Te,St,Ke,Math.pow(2,Te.zoom-De.tileID.overscaledZ),Ge,pt)}}(S,v,g,d,g.layout.get("text-rotation-alignment"),g.layout.get("text-pitch-alignment"),j,W);const Z=g.paint.get("icon-opacity").constantOr(1)!==0,ne=g.paint.get("text-opacity").constantOr(1)!==0;g.layout.get("symbol-sort-key").constantOr(1)!==void 0&&(Z||ne)?Xb(v,d,g,S,R,L):(Z&&Xb(v,d,g,S,R,L,{onlyIcons:!0}),ne&&Xb(v,d,g,S,R,L,{onlyText:!0})),d.map.showCollisionBoxes&&(Tr(v,d,g,S,g.paint.get("text-translate"),g.paint.get("text-translate-anchor"),!0),Tr(v,d,g,S,g.paint.get("icon-translate"),g.paint.get("icon-translate-anchor"),!1))},circle:function(v,d,g,S){if(v.renderPass!=="translucent")return;const j=g.paint.get("circle-opacity"),R=g.paint.get("circle-stroke-width"),L=g.paint.get("circle-stroke-opacity"),F=g.layout.get("circle-sort-key").constantOr(1)!==void 0,z=g.paint.get("circle-emissive-strength");if(j.constantOr(1)===0&&(R.constantOr(1)===0||L.constantOr(1)===0))return;const W=v.context,Z=W.gl,ne=v.transform,re=!(!v.terrain||!v.terrain.enabled),ie=g.layout.get("circle-elevation-reference"),ce=v.depthModeForSublayer(0,Lr.ReadOnly),le=new Lr(v.context.gl.LEQUAL,Lr.ReadOnly,v.depthRangeFor3D),ve=ie==="none"||re?ce:le,_e=an.disabled,Re=v.colorModeForDrapableLayerRenderPass(z),Me=ne.projection.name==="globe",Te=[a.aH(ne.center.lng),a.aL(ne.center.lat)],Xe=[];for(let Ke=0;KeKe.sortKey-De.sortKey);const $e={useDepthForOcclusion:ne.depthOcclusionForSymbolsAndCircles};for(const Ke of Xe){const{programConfiguration:De,program:Be,layoutVertexBuffer:Ge,dynamicBuffers:ot,indexBuffer:Je,uniformValues:St,tile:pt}=Ke.state,Ot=Ke.segments;v.terrain&&v.terrain.setupElevationDraw(pt,Be,$e),v.uploadCommonUniforms(W,Be,pt.tileID.toUnwrapped()),Be.draw(v,Z.TRIANGLES,ve,_e,Re,Zr.disabled,St,g.id,Ge,Je,Ot,g.paint,ne.zoom,De,ot)}},heatmap:function(v,d,g,S){if(g.paint.get("heatmap-opacity")!==0)if(v.renderPass==="offscreen"){const j=v.context,R=j.gl,L=an.disabled,F=new tn([R.ONE,R.ONE,R.ONE,R.ONE],a.aq.transparent,[!0,!0,!0,!0]),z=v.transform.projection.name==="globe"?.5:.25;g.heatmapFbo=t_.createWithTexture(j,g.heatmapFbo,v.width*z,v.height*z),j.clear({color:a.aq.transparent});const W=v.transform,Z=W.projection.name==="globe",ne=Z?["PROJECTION_GLOBE_VIEW"]:[],re=Z?Zr.frontCCW:Zr.disabled,ie=[a.aH(W.center.lng),a.aL(W.center.lat)];for(let ce=0;ce({u_image:0,u_color_ramp:1,u_opacity:ne.paint.get("heatmap-opacity")}))(0,R),R.id,j.viewportBuffer,j.quadTriangleIndexBuffer,j.viewportSegments,R.paint,j.transform.zoom)}(v,g))},line:function(v,d,g,S){const j=g.paint.get("line-opacity"),R=g.paint.get("line-width");if(j.constantOr(1)===0||R.constantOr(1)===0)return;const L=g.paint.get("line-blend-mode");if(L!=="default"&&v.transform.projection.name!=="globe")return v.terrain&&v.terrain.renderingToTexture?void function(F,z,W,Z,ne){if(F.renderPass!=="translucent")return;const re=F.context,ie=re.gl,ce=F.terrain;if(!ce)return;const le=re.bindFramebuffer.current,ve=F.emissiveMode==="mrt-fallback";W.lineBlendDrapeFbo=t_.createWithTexture(re,W.lineBlendDrapeFbo,ce.drapeBufferSize[0],ce.drapeBufferSize[1],!0),W.lineBlendDrapeStencil=W.lineBlendDrapeFbo._stencilRbo,ve&&ie.drawBuffers([ie.COLOR_ATTACHMENT0]),re.clear({color:Vh[ne].clearColor,depth:1,stencil:0});const _e=F.currentStencilSource,Re=F._tileClippingMaskIDs,Me=F.nextStencilID;F.currentStencilSource=void 0,F._tileClippingMaskIDs={},F.nextStencilID=1;const Te=F._terrain;F._terrain=null,F._renderTileClippingMasks(W,z,Z),Jb(F,z,W,Z,Vh[ne].colorMode,!0),F._terrain=Te,F.currentStencilSource=_e,F._tileClippingMaskIDs=Re,F.nextStencilID=Me,re.bindFramebuffer.set(le),ve&&ie.drawBuffers([ie.COLOR_ATTACHMENT0,ie.COLOR_ATTACHMENT1]);const Xe=ce.drapeBufferSize;re.viewport.set([0,0,Xe[0],Xe[1]]);const $e=W.lineBlendDrapeFbo;if(!$e)return;re.activeTexture.set(ie.TEXTURE0),ie.bindTexture(ie.TEXTURE_2D,$e.colorAttachment0.get());const Ke=ne==="additive"?1:W.paint.get("line-opacity").constantOr(1),De=W.paint.get("line-emissive-strength").constantOr(0),Be=ne==="additive"?F.colorModeForDrapableLayerRenderPass(De):Vh[ne].colorMode;F.getOrCreateProgram("lineBlendComposite").draw(F,ie.TRIANGLES,Lr.disabled,an.disabled,Be,Zr.disabled,qb(0,Ke,Vh[ne].compositeUniformValue),W.id,F.viewportBuffer,F.quadTriangleIndexBuffer,F.viewportSegments,W.paint,F.transform.zoom)}(v,d,g,S,L):v.renderPass==="offscreen"?void function(F,z,W,Z,ne){const re=F.context,ie=Math.ceil(F.width),ce=Math.ceil(F.height);W.lineBlendFbo=t_.createWithTexture(re,W.lineBlendFbo,ie,ce,!0),W.lineBlendStencil=W.lineBlendFbo._stencilRbo,re.clear({color:Vh[ne].clearColor,depth:1,stencil:0});const le=F.currentStencilSource,ve=F._tileClippingMaskIDs,_e=F.nextStencilID;F.currentStencilSource=void 0,F._tileClippingMaskIDs={},F.nextStencilID=1,F._renderTileClippingMasks(W,z,Z);const Re=F.renderPass;F.renderPass="translucent",Jb(F,z,W,Z,Vh[ne].colorMode),F.renderPass=Re,F.currentStencilSource=le,F._tileClippingMaskIDs=ve,F.nextStencilID=_e,re.viewport.set([0,0,F.width,F.height])}(v,d,g,S,L):v.renderPass==="translucent"?void function(F,z,W){const Z=F.context,ne=Z.gl,re=z.lineBlendFbo;if(!re)return;Z.activeTexture.set(ne.TEXTURE0),ne.bindTexture(ne.TEXTURE_2D,re.colorAttachment0.get());const ie=W==="additive"?1:z.paint.get("line-opacity").constantOr(1),ce=W==="additive"?F.colorModeForDrapableLayerRenderPass(z.paint.get("line-emissive-strength").constantOr(0)):Vh[W].colorMode;F.getOrCreateProgram("lineBlendComposite").draw(F,ne.TRIANGLES,Lr.disabled,an.disabled,ce,Zr.disabled,qb(0,ie,Vh[W].compositeUniformValue),z.id,F.viewportBuffer,F.quadTriangleIndexBuffer,F.viewportSegments,z.paint,F.transform.zoom)}(v,g,L):void 0;v.renderPass==="translucent"&&Jb(v,d,g,S)},fill:function(v,d,g,S){const j=g.paint.get("fill-color"),R=g.paint.get("fill-opacity");if(R.constantOr(1)===0)return;const L=g.paint.get("fill-emissive-strength"),F=v.colorModeForDrapableLayerRenderPass(L),z=g.paint.get("fill-pattern"),W=v.opaquePassEnabledForLayer()&&!z.constantOr(1)&&j.constantOr(a.aq.transparent).a===1&&R.constantOr(0)===1?"opaque":"translucent";let Z="none";g.layout.get("fill-elevation-reference")!=="none"?Z="road":g.paint.get("fill-z-offset").constantOr(1)!==0&&(Z="offset");const ne=!(!v.terrain||!v.terrain.enabled),re={painter:v,sourceCache:d,layer:g,coords:S,colorMode:F,elevationType:Z,terrainEnabled:ne,pass:W};if(v.renderPass==="shadow")return void(v.shadowRenderer&&Z==="road"&&!ne&&function(ce){const{painter:le,sourceCache:ve,layer:_e,coords:Re}=ce,Me=le.context.gl,Te=ce.painter.shadowRenderer;for(const Xe of Re){const $e=ve.getTile(Xe),Ke=$e.getBucket(_e);if(!Ke)continue;const De=Ke.elevatedStructures;if(!De||!De.shadowCasterSegments||De.shadowCasterSegments.segments[0].primitiveLength===0)continue;le.prepareDrawTile();const Be=Ke.bufferData.programConfigurations.get(_e.id),Ge=le.isTileAffectedByFog(Xe),ot=le.getOrCreateProgram("elevatedStructuresDepth",{config:Be,overrideFog:Ge}),Je=Te.calculateShadowPassMatrixFromTile($e.tileID.toUnwrapped());le.uploadCommonUniforms(le.context,ot,Xe.toUnwrapped());const St=$I(Je,0);ot.draw(le,Me.TRIANGLES,Te.getShadowPassDepthMode(),an.disabled,tn.disabled,Zr.disabled,St,_e.id,De.vertexBuffer,De.indexBuffer,De.shadowCasterSegments,_e.paint,le.transform.zoom,Be)}}(re));const ie=v.emissiveMode==="mrt-fallback";if(Z!=="offset"){if(s_(re,!1,ie),Z==="road"){const ce=!ne&&v.renderPass==="translucent";ce&&n_(v,d,g,S,"geometry"),s_(re,!0,ie,an.disabled),ce&&function(le){const{painter:ve,sourceCache:_e,layer:Re,coords:Me,colorMode:Te}=le,Xe=ve.context.gl,$e=le.painter.shadowRenderer,Ke=!!$e&&$e.enabled,De=new Lr(ve.context.gl.LEQUAL,Lr.ReadOnly,ve.depthRangeFor3D);let Be=[0,0,0];if(Ke){const ot=ve.style.directionalLight,Je=ve.style.ambientLight;ot&&Je&&(Be=cd(ve.style,ot,Je))}const Ge=ot=>{for(const Je of Me){const St=_e.getTile(Je),pt=St.getBucket(Re);if(!pt)continue;const Ot=pt.elevatedStructures;if(!Ot)continue;let Ut,ut;if(ot?(Ut=Ot.renderableBridgeSegments,ut=Ot.bridgeProgramConfigurations.get(Re.id)):(Ut=Ot.renderableTunnelSegments,ut=Ot.tunnelProgramConfigurations.get(Re.id)),!Ut||Ut.segments[0].primitiveLength===0)continue;ut.updatePaintBuffers(),ve.prepareDrawTile();const st=ve.isTileAffectedByFog(Je),vt=[];Ke&&vt.push("RENDER_SHADOWS","NORMAL_OFFSET");const Et=ve.getOrCreateProgram("elevatedStructures",{config:ut,overrideFog:st,defines:vt}),Nt=ve.translatePosMatrix(Je.projMatrix,St,Re.paint.get("fill-translate"),Re.paint.get("fill-translate-anchor"));Ke&&$e.setupShadows(St.tileID.toUnwrapped(),Et,"vector-tile");const lr=zI(Nt,Be);ve.uploadCommonUniforms(ve.context,Et,Je.toUnwrapped()),Et.draw(ve,Xe.TRIANGLES,De,an.disabled,Te,Zr.backCCW,lr,Re.id,Ot.vertexBuffer,Ot.indexBuffer,Ut,Re.paint,ve.transform.zoom,ut,[Ot.vertexBufferNormal])}};Ge(!0),Ge(!1)}(re)}}else s_(re,!1,ie,v.stencilModeFor3D())},"fill-extrusion":function(v,d,g,S){const j=g.paint.get("fill-extrusion-opacity"),R=v.context,L=R.gl,F=v.terrain,z=F&&F.renderingToTexture;if(j===0)return;const W=v.emissiveMode==="mrt-fallback",Z=v.conflationActive&&v.style.isLayerClipped(g,d.getSource()),ne=v.style.order.indexOf(g.fqid);if(Z&&function(re,ie,ce,le,ve){for(const _e of le){const Re=ie.getTile(_e).getBucket(ce);Re&&(Re.updateReplacement(_e,re.replacementSource,ve),Re.uploadCentroid(re.context))}}(v,d,g,S,ne),F||Z)for(const re of S){const ie=d.getTile(re).getBucket(g);ie&&ZI(v.context,d,re,ie,g,F,Z)}if(v.renderPass==="shadow"&&v.shadowRenderer){if(F&&j<.65&&g._transitionablePaint._values["fill-extrusion-opacity"].value.expression instanceof a.af)return;const re=v.shadowRenderer.getShadowPassDepthMode();kp(v,d,g,S,re,an.disabled,tn.disabled,Z)}else if(v.renderPass==="translucent"){const re=!g.paint.get("fill-extrusion-pattern").constantOr(1),ie=g.paint.get("fill-extrusion-color").constantOr(a.aq.white);if(!z&&ie.a!==0){const ce=new Lr(v.context.gl.LEQUAL,Lr.ReadWrite,v.depthRangeFor3D);j===1&&re?kp(v,d,g,S,ce,an.disabled,tn.unblended,Z):(kp(v,d,g,S,ce,an.disabled,tn.disabled,Z),kp(v,d,g,S,ce,v.stencilModeFor3D(),v.colorModeForRenderPass(),Z),v.resetStencilClippingMasks())}if(v.style.enable3dLights()&&re&&(!F&&v.transform.projection.name!=="globe"||z)){const ce=g.paint.get("fill-extrusion-opacity"),le=g.paint.get("fill-extrusion-ambient-occlusion-intensity"),ve=g.paint.get("fill-extrusion-ambient-occlusion-ground-radius"),_e=g.paint.get("fill-extrusion-flood-light-intensity"),Re=g.paint.get("fill-extrusion-flood-light-color-use-theme").constantOr("default")==="none",Me=g.paint.get("fill-extrusion-flood-light-color").toNonPremultipliedRenderColor(Re?null:g.lut).toArray01().slice(0,3),Te=le>0&&ve>0,Xe=_e>0,$e=(Be,Ge,ot)=>(1-ot)*Be+ot*Ge,Ke=new fj;Ke.translate=g.paint.get("fill-extrusion-translate"),Ke.translateAnchor=g.paint.get("fill-extrusion-translate-anchor"),Ke.edgeRadius=g.layout.get("fill-extrusion-edge-radius"),Ke.cutoffFadeRange=g.paint.get("fill-extrusion-cutoff-fade-range");const De=Be=>{const Ge=v.depthModeForSublayer(1,Lr.ReadOnly,L.LEQUAL,!0),ot=g.paint.get(Be?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),Je=$e(.1,3,ot),St=v._showOverdrawInspector;if(!St){const pt=new an({func:L.ALWAYS,mask:255},255,255,L.KEEP,L.KEEP,L.REPLACE),Ot=new tn([L.ONE,L.ONE,L.ONE,L.ONE],a.aq.transparent,[!1,!1,!1,!0],L.MIN);Zd(Ke,v,d,g,S,Ge,pt,Ot,Zr.disabled,Be,"sdf",ce,le,ve,_e,Me,Je,Z,!1)}{const pt=St?an.disabled:new an({func:L.EQUAL,mask:255},255,255,L.KEEP,L.DECR,L.DECR),Ot=St?v.colorModeForRenderPass():new tn([L.ONE_MINUS_DST_ALPHA,L.DST_ALPHA,L.ONE,L.ONE],a.aq.transparent,[!0,!0,!0,!0]);Zd(Ke,v,d,g,S,Ge,pt,Ot,Zr.disabled,Be,"color",ce,le,ve,_e,Me,Je,Z,!1)}};if(z){const Be=()=>{const ot=F.drapeBufferSize[0],Je=F.drapeBufferSize[1];let St=F.framebufferCopyTexture;return St&&(!St||St.size[0]===ot&&St.size[1]===Je)||(St&&St.destroy(),St=F.framebufferCopyTexture=new a.T(R,new a.q({width:ot,height:Je}),L.RGBA8)),St.bind(L.LINEAR,L.CLAMP_TO_EDGE),L.copyTexSubImage2D(L.TEXTURE_2D,0,0,0,0,0,ot,Je),St},Ge=(ot,Je,St)=>{const pt=v.depthModeForSublayer(1,Lr.ReadOnly,L.LEQUAL,!1),Ot=g.paint.get(ot?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),Ut=$e(.1,3,Ot);{const ut=new tn([L.ONE,L.ONE,L.ONE,L.ONE],a.aq.transparent,[!1,!1,!1,!0]);Zd(Ke,v,d,g,S,pt,an.disabled,ut,Zr.disabled,ot,"clear",ce,le,ve,_e,Me,Ut,Z,Je)}{const ut=new an({func:L.ALWAYS,mask:255},255,255,L.KEEP,L.KEEP,L.REPLACE),st=new tn([L.ONE,L.ONE,L.ONE,L.ONE],a.aq.transparent,[!1,!1,!1,!0],L.MIN);Zd(Ke,v,d,g,S,pt,ut,st,Zr.disabled,ot,"sdf",ce,le,ve,_e,Me,Ut,Z,Je)}W&&!ot&&(St=Be());{const ut=ot?L.ZERO:L.ONE_MINUS_DST_ALPHA,st=new an({func:L.EQUAL,mask:255},255,255,L.KEEP,L.DECR,L.DECR),vt=new tn([ut,L.DST_ALPHA,L.ONE_MINUS_DST_ALPHA,L.ZERO],a.aq.transparent,[!0,!0,!0,!0]);Zd(Ke,v,d,g,S,pt,st,vt,Zr.disabled,ot,"color",ce,le,ve,_e,Me,Ut,Z,Je)}if(!W||ot){const ut=new tn([L.ONE,L.ONE,L.ONE,ot?L.ZERO:L.ONE],a.aq.transparent,[!1,!1,!1,!0],ot?L.FUNC_ADD:L.MAX);Zd(Ke,v,d,g,S,pt,an.disabled,ut,Zr.disabled,ot,"clear",ce,le,ve,_e,Me,Ut,Z,Je,St)}else{L.drawBuffers([L.NONE,L.COLOR_ATTACHMENT1]);const ut=new an({func:L.EQUAL,mask:255},254,255,L.KEEP,L.DECR,L.DECR),st=new tn([L.ONE,L.ONE,L.ONE,L.ONE],a.aq.transparent,[!0,!1,!1,!1],L.MAX);Zd(Ke,v,d,g,S,pt,ut,st,Zr.disabled,ot,"emissive",ce,le,ve,_e,Me,Ut,Z,Je,St),L.drawBuffers([L.COLOR_ATTACHMENT0])}};if(Te||Xe){let ot;v.prepareDrawTile(),W&&!Te||(ot=Be()),Te&&Ge(!0,!1,ot),Xe&&Ge(!1,!0,ot)}}else Te&&De(!0),Xe&&De(!1),(Te||Xe)&&v.resetStencilClippingMasks()}}},building:function(v,d,g,S){v.currentLayer0&&R>0,W=!0;const Z=g.paint.get("building-vertical-scale");if(Z<=0)return;v.shadowRenderer||(W=!1);const ne=v.conflationActive&&v.style.isLayerClipped(g,d.getSource()),re=v.style.order.indexOf(g.fqid);if(function(ie,ce,le,ve,_e,Re){for(const Me of Re){const Te=ce.getTile(Me).getBucket(le);Te&&(_e&&Te.updateReplacement(Me,ie.replacementSource,ve),Te.uploadUpdatedIndexBuffer(ie.context))}}(v,d,g,re,ne,S),function(ie,ce,le,ve){for(const _e of ve){const Re=ce.getTile(_e).getBucket(le);Re&&Re.needsEvaluation()&&Re.uploadUpdatedColorBuffer(ie.context)}}(v,d,g,S),g.resetLayerRenderingStats(v),v.shadowRenderer&&(v.shadowRenderer.useNormalOffset=!0),v.renderPass==="shadow"&&v.shadowRenderer){const ie=[],ce=v.shadowRenderer.getShadowPassDepthMode();i_({painter:v,source:d,layer:g,coords:S,defines:ie,blendMode:tn.disabled,depthMode:ce,opacity:F,verticalScale:Z,facadeEmissiveChance:0,facadeAOIntensity:0,floodLightIntensity:0,floodLightColor:[0,0,0]})}else if(v.renderPass==="translucent"){let ie=["HAS_ATTRIBUTE_a_part_color_emissive","LIGHTING_3D_MODE"];W&&(ie=ie.concat("RENDER_SHADOWS")),v.shadowRenderer&&v.shadowRenderer.useNormalOffset&&(ie=ie.concat("NORMAL_OFFSET"));const ce=g.paint.get("building-facade-emissive-chance"),le=g.paint.get("building-ambient-occlusion-intensity"),ve=g.paint.get("building-flood-light-intensity"),_e=g.paint.get("building-flood-light-color-use-theme").constantOr("default")==="none",Re=g.paint.get("building-flood-light-color").toNonPremultipliedRenderColor(_e?null:g.lut).toArray01().slice(0,3),Me=g.paint.get("building-flood-light-ground-attenuation"),Te=ve>0,Xe=new Lr(v.context.gl.LEQUAL,Lr.ReadWrite,v.depthRangeFor3D);F<1&&i_({painter:v,source:d,layer:g,coords:S,defines:ie,blendMode:tn.disabled,depthMode:Xe,opacity:F,verticalScale:Z,facadeEmissiveChance:ce,facadeAOIntensity:le,floodLightIntensity:ve,floodLightColor:Re,depthOnly:!0});const $e=v.colorModeForRenderPass();i_({painter:v,source:d,layer:g,coords:S,defines:ie,blendMode:$e,depthMode:Xe,opacity:F,verticalScale:Z,facadeEmissiveChance:ce,facadeAOIntensity:le,floodLightIntensity:ve,floodLightColor:Re});const Ke=g.paint.get("building-front-cutoff");ew(v.transform.pitch,Ke,!!v.terrain),z&&pj(v,d,g,S,!0,F,j,R,ve,Re,L,ne),Te&&pj(v,d,g,S,!1,F,j,R,ve,Re,Me,ne)}else if(v.renderPass==="light-beam"){const ie=["HAS_ATTRIBUTE_a_part_color_emissive","HAS_ATTRIBUTE_a_bloom_attenuation"],ce=new Lr(v.context.gl.LEQUAL,Lr.ReadOnly,v.depthRangeFor3D);i_({painter:v,source:d,layer:g,coords:S,defines:ie,blendMode:tn.alphaBlended,depthMode:ce,opacity:F,verticalScale:Z,facadeEmissiveChance:0,facadeAOIntensity:0,floodLightIntensity:0,floodLightColor:[0,0,0]})}v.shadowRenderer&&(v.shadowRenderer.useNormalOffset=!1),v.resetStencilClippingMasks()},hillshade:function(v,d,g,S){if(v.renderPass!=="offscreen"&&v.renderPass!=="translucent"||v.style.disableElevatedTerrain)return;const j=v.context,R=v.terrain&&v.terrain.renderingToTexture,[L,F]=v.renderPass!=="translucent"||R?[{},S]:v.stencilConfigForOverlap(S);for(const z of F){const W=d.getTile(z);if(W.needsHillshadePrepare&&v.renderPass==="offscreen")Y5(v,W,g);else if(v.renderPass==="translucent"){const Z=v.depthModeForSublayer(0,Lr.ReadOnly),ne=g.paint.get("hillshade-emissive-strength"),re=v.colorModeForDrapableLayerRenderPass(ne),ie=R&&v.terrain?v.terrain.stencilModeForRTTOverlap(z):L[z.overscaledZ];K5(v,z,W,g,Z,ie,re)}}j.viewport.set([0,0,v.width,v.height]),v.resetStencilClippingMasks()},raster:function(v,d,g,S,j,R){if(v.renderPass!=="translucent")return;const L=g.paint.get("raster-opacity");if(L===0)return;const F=v.transform.projection.name==="globe",z=g.paint.get("raster-elevation")!==0,W=z&&F,Z=v.terrain&&v.terrain.exaggeration()>0&&z&&g.paint.get("raster-elevation-reference")==="ground",ne=!F&&Z;if(v.renderElevatedRasterBackface&&!W)return;const re=v.context,ie=re.gl,ce=d.getSource(),le=function(Be,Ge,ot,Je,St){const pt=Ge.paint.get("raster-color"),Ot=Be.type==="raster-array",Ut=[],ut=Ge.paint.get("raster-resampling"),st=Ge.paint.get("raster-color-mix");let vt=Ge.paint.get("raster-color-range");const Et=[st[0],st[1],st[2],0],Nt=st[3];let lr=ut==="nearest"?Je.NEAREST:Je.LINEAR;if(Ot&&(Ut.push("RASTER_ARRAY"),pt||Ut.push("RASTER_COLOR"),ut==="linear"&&Ut.push("RASTER_ARRAY_LINEAR"),lr=Je.NEAREST,!vt&&Be.rasterLayers)){const Jt=Be.rasterLayers.find(({id:er})=>er===Ge.sourceLayer);Jt&&Jt.fields&&Jt.fields.range&&(vt=Jt.fields.range)}if(vt=vt||[0,1],pt){Ut.push("RASTER_COLOR"),ot.activeTexture.set(Je.TEXTURE2),Ge.updateColorRamp(vt);let Jt=Ge.colorRampTexture;Jt||(Jt=Ge.colorRampTexture=new a.T(ot,Ge.colorRamp,Je.RGBA8)),Jt.bind(lr,Je.CLAMP_TO_EDGE)}return St&&Ut.push("USE_MRT1"),{mix:Et,range:vt,offset:Nt,defines:Ut,resampling:lr}}(ce,g,re,ie,v.terrain&&v.terrain.renderingToTexture&&v.emissiveMode==="mrt-fallback");if(ce instanceof a.aV&&!S.length&&!F)return;const ve=g.paint.get("raster-emissive-strength"),_e=v.colorModeForDrapableLayerRenderPass(ve),Re=v.terrain&&v.terrain.renderingToTexture,Me=!v.options.moving,Te=g.paint.get("raster-resampling")==="nearest"?ie.NEAREST:ie.LINEAR;if(ce instanceof a.aV&&!S.length&&(ce.onNorthPole||ce.onSouthPole)){const Be=z?v.stencilModeFor3D():an.disabled;return void rw(!!ce.onNorthPole,null,v,d,g,ve,le,Zr.disabled,Be)}if(!S.length)return;const[Xe,$e]=ce instanceof a.aV||Re?[{},S]:v.stencilConfigForOverlap(S),Ke=$e[$e.length-1].overscaledZ;W&&le.defines.push("PROJECTION_GLOBE_VIEW"),z&&le.defines.push("RENDER_CUTOFF","ELEVATED"),Z&&le.defines.push("ELEVATION_REFERENCE_GROUND");const De=(Be,Ge,ot)=>{for(const Je of Be){const St=Je.toUnwrapped(),pt=d.getTile(Je);if(Re&&(!pt||!pt.hasData()))continue;re.activeTexture.set(ie.TEXTURE0);const Ot=JI(pt,ce,g,le);if(!Ot||!Ot.texture)continue;const{texture:Ut,mix:ut,offset:st,tileSize:vt,buffer:Et}=Ot;let Nt,lr;Re?(Nt=Lr.disabled,lr=Je.projMatrix):z?(Nt=new Lr(ie.LEQUAL,Lr.ReadWrite,v.depthRangeFor3D),lr=F?Float32Array.from(v.transform.expandedFarZProjMatrix):v.transform.calculateProjMatrix(St,Me)):(Nt=v.depthModeForSublayer(Je.overscaledZ-Ke,L===1?Lr.ReadWrite:Lr.ReadOnly,ie.LESS),lr=v.transform.calculateProjMatrix(St,Me));const Jt=v.terrain&&Re?v.terrain.stencilModeForRTTOverlap(Je):Xe[Je.overscaledZ],er=R?0:g.paint.get("raster-fade-duration");pt.registerFadeDuration(er);const zt=d.findLoadedParent(Je,0),Ir=Z0(pt,zt,d,v.transform,er);let Or,vr;!Ir.isFading&&pt.refreshedUponExpiration&&(pt.refreshedUponExpiration=!1),v.terrain&&v.terrain.prepareDrawTile(),re.activeTexture.set(ie.TEXTURE0),Ut.bind(Te,ie.CLAMP_TO_EDGE),re.activeTexture.set(ie.TEXTURE1),zt?(zt.texture&&zt.texture.bind(Te,ie.CLAMP_TO_EDGE),Or=Math.pow(2,zt.tileID.overscaledZ-pt.tileID.overscaledZ),vr=[pt.tileID.canonical.x*Or%1,pt.tileID.canonical.y*Or%1]):Ut.bind(Te,ie.CLAMP_TO_EDGE),"useMipmap"in Ut&&re.extTextureFilterAnisotropic&&v.transform.pitch>20&&ie.texParameterf(ie.TEXTURE_2D,re.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,re.extTextureFilterAnisotropicMax);const Ar=v.transform;let Jr;const dn=z?yj(Ar):[0,0,0,0];let on,Tn,Kr,En,ln,ts=0;if(W&&ce instanceof a.aV&&ce.coordinates.length>3)on=Float32Array.from(a.du(a.dv(new a.cn(0,0,0)))),Tn=Float32Array.from(Ar.globeMatrix),Kr=Float32Array.from(a.dq(Ar)),En=[a.aH(Ar.center.lng),a.aL(Ar.center.lat)],Jr=ce.elevatedGlobePerspectiveTransform,ln=ce.elevatedGlobeGridMatrix||new Float32Array(9);else if(W){const us=a.dr(Je.canonical);ts=a.ds(us.getCenter().lat),on=Float32Array.from(a.du(a.dv(Je.canonical))),Tn=Float32Array.from(Ar.globeMatrix),Kr=Float32Array.from(a.dq(Ar)),En=[a.aH(Ar.center.lng),a.aL(Ar.center.lat)],Jr=[0,0],ln=Float32Array.from(a.dt(Je.canonical,us,ts,Ar.worldSize/Ar._pixelsPerMercatorPixel))}else Jr=ce instanceof a.aV?ce.perspectiveTransform:[0,0],on=new Float32Array(16),Tn=new Float32Array(9),Kr=new Float32Array(16),En=[0,0],ln=new Float32Array(9);const Cs=qI(v,lr,on,Tn,Kr,ln,vr||[0,0],a.al(v.transform.zoom),En,dn,Or||1,Ir,g,Jr,z?g.paint.get("raster-elevation"):0,2,ut,st,le.range,vt,Et,ve),ai=v.isTileAffectedByFog(Je),Fs=v.getOrCreateProgram("raster",{defines:le.defines,overrideFog:ai});if(v.uploadCommonUniforms(re,Fs,St),ce instanceof a.aV){const us=ce.elevatedGlobeVertexBuffer,vn=ce.elevatedGlobeIndexBuffer;if(Re||!F)ce.boundsBuffer&&ce.boundsSegments&&Fs.draw(v,ie.TRIANGLES,Nt,an.disabled,_e,Zr.disabled,Cs,g.id,ce.boundsBuffer,v.quadTriangleIndexBuffer,ce.boundsSegments);else if(us&&vn){const bn=Ar.zoom<=a.cJ?ce.elevatedGlobeSegments:ce.getSegmentsForLongitude(Ar.center.lng);bn&&Fs.draw(v,ie.TRIANGLES,Nt,an.disabled,_e,Ge,Cs,g.id,us,vn,bn)}}else if(W){Nt=new Lr(ie.LEQUAL,Lr.ReadOnly,v.depthRangeFor3D);const us=v.globeSharedBuffers;if(us){Z&&(v.terrain.setupElevationDraw(pt,Fs),v.uploadCommonUniforms(re,Fs,pt.tileID.toUnwrapped()));const[vn,bn,Bs]=us.getGridBuffers(ts,!1),fi=Fs.getAttributeLocation(ie,"a_texture_pos");fi!==-1&&ie.vertexAttribI4ui(fi,0,0,0,0),Fs.draw(v,ie.TRIANGLES,Nt,ot||Jt,v.colorModeForRenderPass(),Ge,Cs,g.id,vn,bn,Bs)}}else if(ne)Nt=new Lr(ie.LEQUAL,Lr.ReadWrite,v.depthRangeFor3D),v.terrain.setupElevationDraw(pt,Fs),v.uploadCommonUniforms(re,Fs,pt.tileID.toUnwrapped()),Ar.pitch>20&&Fs.draw(v,ie.TRIANGLES,Nt,an.disabled,tn.disabled,Zr.frontCCW,Cs,g.id,v.terrain.gridBuffer,v.terrain.gridIndexBuffer,v.terrain.gridSegments),Fs.draw(v,ie.TRIANGLES,Nt,Jt,_e,Zr.backCCW,Cs,g.id,v.terrain.gridBuffer,v.terrain.gridIndexBuffer,v.terrain.gridSegments);else{const{tileBoundsBuffer:us,tileBoundsIndexBuffer:vn,tileBoundsSegments:bn}=v.getTileBoundsBuffers(pt);Fs.draw(v,ie.TRIANGLES,Nt,Jt,_e,Zr.disabled,Cs,g.id,us,vn,bn)}}if(!(ce instanceof a.aV)&&W)for(const Je of Be){const St=Je.canonical.y===(1<a.d$[Et](St));ut.push(St);const st=St.canonical.x,vt=St.canonical.y;for(const Et of ut){const Nt=Te.getTile(Ge?Et.wrapped():Et);if(!Nt)continue;const lr=Nt.rasterParticleState;if(!lr)continue;const Jt=Et.canonical.x+(1<Ke.tileID)),ie&&(W.activeTexture.set(Z.TEXTURE0),v.imageManager.bind(v.context,g.scope));const $e=[];if(v.terrain&&v.terrain.renderingToTexture&&v.emissiveMode==="mrt-fallback"&&$e.push("USE_MRT1"),z){const Ke=v.getOrCreateProgram(Me,{overrideFog:!1,overrideRtt:!0,defines:$e}),De=new Float32Array(a.b9([])),Be=new a.aR(0,0,0,0,0),Ge=ie?em(De,F,L,v,0,g.scope,ce,z,{tileID:Be,tileSize:re}):e_(De,F,L,j.toPremultipliedRenderColor(R?null:g.lut));return void Ke.draw(v,Z.TRIANGLES,_e,ve,Re,Zr.disabled,Ge,g.id,v.viewportBuffer,v.quadTriangleIndexBuffer,v.viewportSegments)}for(const Ke of Xe){const De=v.isTileAffectedByFog(Ke),Be=v.getOrCreateProgram(Me,{overrideFog:De,defines:$e}),Ge=Ke.toUnwrapped(),ot=S?Ke.projMatrix:v.transform.calculateProjMatrix(Ge);v.prepareDrawTile();const Je=d?d.getTile(Ke):Te?Te[Ke.key]:new a.b0(Ke,re,ne.zoom,v),St=ie?em(ot,F,L,v,0,g.scope,ce,z,{tileID:Ke,tileSize:re}):e_(ot,F,L,j.toPremultipliedRenderColor(R?null:g.lut));v.uploadCommonUniforms(W,Be,Ge);const{tileBoundsBuffer:pt,tileBoundsIndexBuffer:Ot,tileBoundsSegments:Ut}=v.getTileBoundsBuffers(Je);Be.draw(v,Z.TRIANGLES,_e,ve,Re,Zr.disabled,St,g.id,pt,Ot,Ut)}},sky:function(v,d,g){const S=v._atmosphere?a.al(v.transform.zoom):1,j=g.paint.get("sky-opacity")*S;if(j===0)return;const R=v.context,L=g.paint.get("sky-type"),F=new Lr(R.gl.LEQUAL,Lr.ReadOnly,[0,1]),z=v.frameCounter/1e3%1;L==="atmosphere"?v.renderPass==="offscreen"?g.needsSkyboxCapture(v)&&(function(W,Z){const ne=W.context,re=ne.gl;let ie=Z.skyboxFbo;if(!ie){ie=Z.skyboxFbo=ne.createFramebuffer(32,32,1,null),Z.skyboxGeometry=new hl(ne),Z.skyboxTexture=ne.gl.createTexture(),re.bindTexture(re.TEXTURE_CUBE_MAP,Z.skyboxTexture),re.texParameteri(re.TEXTURE_CUBE_MAP,re.TEXTURE_WRAP_S,re.CLAMP_TO_EDGE),re.texParameteri(re.TEXTURE_CUBE_MAP,re.TEXTURE_WRAP_T,re.CLAMP_TO_EDGE),re.texParameteri(re.TEXTURE_CUBE_MAP,re.TEXTURE_MIN_FILTER,re.LINEAR),re.texParameteri(re.TEXTURE_CUBE_MAP,re.TEXTURE_MAG_FILTER,re.LINEAR);for(let _e=0;_e<6;++_e)re.texImage2D(re.TEXTURE_CUBE_MAP_POSITIVE_X+_e,0,re.RGBA,32,32,0,re.RGBA,re.UNSIGNED_BYTE,null)}ne.bindFramebuffer.set(ie.framebuffer),ne.viewport.set([0,0,32,32]);const ce=Z.getCenter(W,!0),le=W.getOrCreateProgram("skyboxCapture"),ve=new Float64Array(16);a.b9(ve),a.ef(ve,ve,.5*-Math.PI),Hc(W,Z,le,ve,ce,0),a.b9(ve),a.ef(ve,ve,.5*Math.PI),Hc(W,Z,le,ve,ce,1),a.b9(ve),a.cE(ve,ve,.5*-Math.PI),Hc(W,Z,le,ve,ce,2),a.b9(ve),a.cE(ve,ve,.5*Math.PI),Hc(W,Z,le,ve,ce,3),a.b9(ve),Hc(W,Z,le,ve,ce,4),a.b9(ve),a.ef(ve,ve,Math.PI),Hc(W,Z,le,ve,ce,5),ne.viewport.set([0,0,W.width,W.height])}(v,g),g.markSkyboxValid(v)):v.renderPass==="sky"&&function(W,Z,ne,re,ie){const ce=W.context,le=ce.gl,ve=W.transform,_e=W.getOrCreateProgram("skybox");ce.activeTexture.set(le.TEXTURE0),le.bindTexture(le.TEXTURE_CUBE_MAP,Z.skyboxTexture);const Re=((Me,Te,Xe,$e,Ke)=>({u_matrix:Me,u_sun_direction:Te,u_cubemap:0,u_opacity:$e,u_temporal_offset:Ke}))(ve.skyboxMatrix,Z.getCenter(W,!1),0,re,ie);W.uploadCommonUniforms(ce,_e),_e.draw(W,le.TRIANGLES,ne,an.disabled,W.colorModeForRenderPass(),Zr.backCW,Re,"skybox",Z.skyboxGeometry.vertexBuffer,Z.skyboxGeometry.indexBuffer,Z.skyboxGeometry.segment)}(v,g,F,j,z):L==="gradient"&&v.renderPass==="sky"&&function(W,Z,ne,re,ie){const ce=W.context,le=ce.gl,ve=W.transform,_e=W.getOrCreateProgram("skyboxGradient");Z.skyboxGeometry||(Z.skyboxGeometry=new hl(ce)),ce.activeTexture.set(le.TEXTURE0);let Re=Z.colorRampTexture;Re||(Re=Z.colorRampTexture=new a.T(ce,Z.colorRamp,le.RGBA8)),Re.bind(le.LINEAR,le.CLAMP_TO_EDGE);const Me=((Te,Xe,$e,Ke,De)=>({u_matrix:Te,u_color_ramp:0,u_center_direction:Xe,u_radius:a.ap($e),u_opacity:Ke,u_temporal_offset:De}))(ve.skyboxMatrix,Z.getCenter(W,!1),Z.paint.get("sky-gradient-radius"),re,ie);W.uploadCommonUniforms(ce,_e),_e.draw(W,le.TRIANGLES,ne,an.disabled,W.colorModeForRenderPass(),Zr.backCW,Me,"skyboxGradient",Z.skyboxGeometry.vertexBuffer,Z.skyboxGeometry.indexBuffer,Z.skyboxGeometry.segment)}(v,g,F,j,z)},custom:function(v,d,g,S){const j=v.context,R=g.implementation;if(!v.transform.projection.unsupportedLayers||!v.transform.projection.unsupportedLayers.includes("custom")||v.terrain&&(v.terrain.renderingToTexture||v.renderPass==="offscreen")&&g.isDraped(d)){if(v.renderPass==="offscreen"){const L=R.prerender;if(L){if(v.setCustomLayerDefaults(),j.setColorMode(v.colorModeForRenderPass()),v.transform.projection.name==="globe"){const F=v.transform.pointMerc;L.call(R,j.gl,v.transform.customLayerMatrix(),v.transform.getProjection(),v.transform.globeToMercatorMatrix(),a.al(v.transform.zoom),[F.x,F.y],v.transform.pixelsPerMeterRatio)}else L.call(R,j.gl,v.transform.customLayerMatrix());j.setDirty(),v.setBaseState()}}else if(v.renderPass==="translucent"){if(v.terrain&&v.terrain.renderingToTexture){const F=R.renderToTile;if(F){const z=S[0].canonical,W={x:z.x+S[0].wrap*(R.wrapTileId?0:1<{W&&(W.useNormalOffset=!0,Z||(W.enabled=!0))},re=d.getSource();if(v.renderPass==="light-beam"&&re.type!=="batched-model")return;if(re.type==="vector"||re.type==="geojson")return function(Te,Xe,$e,Ke,De){const Be=Te.transform,Ge=Be.projection.name==="globe",ot=Be.getFreeCameraOptions().position;if(!Te.modelManager)return;const Je=Te.modelManager;$e.modelManager=Je;const St=Te.shadowRenderer;if(!$e._unevaluatedLayout._values.hasOwnProperty("model-id"))return;const pt=$e._unevaluatedLayout._values["model-id"],Ot=Object.assign({},$e.layout.get("model-id").parameters),Ut=Te.style.order.indexOf($e.fqid),ut=$e.paint.get("model-opacity").constantOr(1);for(const st of Ke){const vt=Xe.getTile(st).getBucket($e);if(!vt||vt.projection.name!==Be.projection.name)continue;const Et=vt.getModelUris();if(Et&&!vt.modelsRequested&&(Je.addModelsFromBucket(Et,De),vt.modelsRequested=!0),Ge)Ot.zoom=st.overscaledZ;else{const vr=yy(st,Be);Ot.zoom=vr}const Nt=pt.possiblyEvaluate(Ot);if(sr(Te,vt,st),Qt.shadowUniformsInitialized=!1,Qt.useSingleShadowCascade=!!St&&St.getMaxCascadeForTile(st.toUnwrapped())===0,Te.renderPass==="shadow"&&St){if(Te.currentShadowCascade===1&&vt.isInsideFirstShadowMapFrustum)continue;const vr=Be.calculatePosMatrix(st.toUnwrapped(),Be.worldSize);if(Qt.tileMatrix.set(vr),Qt.shadowTileMatrix=Float32Array.from(St.calculateShadowPassMatrixFromMatrix(vr)),Qt.aabb.min=[0,0,0],Qt.aabb.max[0]=Qt.aabb.max[1]=a.an,Qt.aabb.max[2]=0,aP(vt,Qt,Te,$e.scope))continue}const lr=1<0&&Te.style.isLayerClipped($e,Xe.getSource())&&vt.updateReplacement(st,Te.replacementSource,Ut,$e.scope)&&(vt.uploaded=!1,vt.upload(Te.context));let er=0;const zt=new Array,Ir=new Array,Or=new Array;for(let vr in vt.instancesPerModel){const Ar=vt.instancesPerModel[vr];Ar.features.length>0&&!Ge&&(vr=Nt.evaluate(Ar.features[0].feature,{}));const Jr=Je.getModel(vr,De);if(Jr||Je.hasURLBeenRequested(vr)||vt.modelUris.includes(vr)||(vt.modelUris.push(vr),vt.modelsRequested=!1),Jr&&Jr.uploaded)if(Ge){const dn=a.bJ([],[ot.x,ot.y,ot.z],Te.transform.worldSize);a.eo(dn,dn);for(let on=0;on0&&En.elevationUpdate(vr.terrain,on,Kr,Jr.source),En.needsReEvaluation(vr,Tn,Jr)&&En.evaluate(Jr))}})(Te,Xe,$e,Ke),function(){const vr=new Map;let Ar,Jr,dn;zt?(Ar=Ke.length-1,Jr=-1,dn=-1):(Ar=0,Jr=Ke.length,dn=1);const on=new Float64Array(16),Tn=a.ce(),Kr=new a.P(0,0);for(let En=Ar;En!==Jr;En+=dn){const ln=Ke[En],ts=Xe.getTile(ln).getBucket($e);if(!ts||!ts.uploaded)continue;let Cs=!1;ot&&(Cs=ot.getMaxCascadeForTile(ln.toUnwrapped())===0);const ai=Be.calculatePosMatrix(ln.toUnwrapped(),Be.worldSize),Fs=ts.modelTraits;!lr&&zt&&(a.b7(on,ai),a.ah(Tn,St,on),Kr.x=Tn[0],Kr.y=Tn[1]);const us=[];ts.setFilter($e.filter);for(const vn of ts.getNodesInfo()){if(vn.hiddenByReplacement||!vn.node.meshes)continue;const bn=vn.node;let Bs=0;Te.terrain&&bn.elevation&&(Bs=bn.elevation*Te.terrain.exaggeration());const fi=(()=>{const ro=vn.aabb;return Nt.min=[...ro.min],Nt.max=[...ro.max],Nt.min[2]+=Bs,Nt.max[2]+=Bs,a.ah(Nt.min,Nt.min,ai),a.ah(Nt.max,Nt.max,ai),Nt})(),ds=vn.evaluatedScale;if(ds[0]<=1&&ds[1]<=1&&ds[2]<=1&&fi.intersects(Jt)===0)continue;if(!lr&&zt){const ro=.16666666666666666;vn.cameraCollisionOpacity=St[0]>fi.min[0]&&St[0]fi.min[1]&&St[1]!zt||vn.opacity===1&&bn.opacity===1?vn.depthbn.depth?-1:1);for(const vn of us){const bn=vn.nodeInfo,Bs=bn.node;if(Te._debugParams.show3DModelFootprints&&Bs.footprint){const Mn=Bs.id||Bs.name||"footprint";vr.has(Mn)||vr.set(Mn,{node:Bs,mvp:vn.wvpForTile})}let fi=a.aD([],ut,vn.tileModelMatrix);a.aD(fi,Ot,fi);const ds=a.b7([],fi);a.e6(ds,ds),a.cC(ds,ds,at),fi=a.aD(fi,fi,Bs.globalMatrix);const hn=Te.renderPass==="light-beam",ni=$e.paint.get("model-color-use-theme").constantOr("default")==="none",Is=Fs&a.ez.HasMapboxMeshFeatures,Ki=Is?0:bn.evaluatedRMEA[0][2];for(let Mn=0;Mn=xr||Ec>=xr}}const ys=Ms.material;let Yc;ys.occlusionTexture&&ys.occlusionTexture.offsetScale&&(Yc=ys.occlusionTexture.offsetScale,Sa.defines.push("OCCLUSION_TEXTURE_TRANSFORM"));const Zc=Te.getOrCreateProgram("model",Sa);!lr&&ot&&ot.setupShadowsFromMatrix(vn.tileModelMatrix,Zc,ot.useNormalOffset),Te.uploadCommonUniforms(De,Zc,null,Tc);const Vs=ys.pbrMetallicRoughness;Vs.metallicFactor=.9,Vs.roughnessFactor=.5;const Ys=Ep(new Float32Array(Lo),new Float32Array(fi),new Float32Array(ds),new Float32Array(Bs.globalMatrix),Te,vn.opacity,Vs.baseColorFactor,ys.emissiveFactor,Vs.metallicFactor,Vs.roughnessFactor,ys,Ki,$e,[0,0,0],Yc);!ha&&(bn.hasTranslucentParts||vn.opacity<1)&&Zc.draw(Te,De.gl.TRIANGLES,vt,an.disabled,tn.disabled,Zr.backCCW,Ys,$e.id,Ms.vertexBuffer,Ms.indexBuffer,Ms.segments,$e.paint,Te.transform.zoom,void 0,ro),Zc.draw(Te,De.gl.TRIANGLES,ha?Et:vt,an.disabled,ha||vn.opacity<1||bn.hasTranslucentParts?tn.alphaBlended:tn.unblended,Zr.backCCW,Ys,$e.id,Ms.vertexBuffer,Ms.indexBuffer,Ms.segments,$e.paint,Te.transform.zoom,void 0,ro)}}}if(Te._debugParams.show3DModelFootprints&&vr.size>0){const En=Array.from(vr.keys()).sort();for(const ln of En){const{node:ts,mvp:Cs}=vr.get(ln);kj(Te,0,ts,Cs)}}}()}(v,d,g,S),void ne();if(re.type!=="model")return;const ie=re.getModels(),ce=[],le=v.transform.getFreeCameraOptions().position,ve=a.bJ([],[le.x,le.y,le.z],v.transform.worldSize);a.eo(ve,ve);const _e=[],Re=[];let Me=0;for(const Te of ie){const Xe=d.getFeatureState("",Te.id),$e={type:"Unknown",id:Te.id,properties:Te.featureProperties},Ke=g.paint.get("model-rotation").evaluate($e,Xe),De=g.paint.get("model-scale").evaluate($e,Xe),Be=g.paint.get("model-translation").evaluate($e,Xe),Ge=g.paint.get("model-opacity").evaluate($e,Xe);Aj(g,Te.id,Xe,Te.featureProperties,Te.nodeOverrideNames,Te.nodeOverrides),Np(g,Te.id,Xe,Te.featureProperties,Te.materialOverrideNames,Te.materialOverrides),Te.nodeOverrides.size>0&&Te.computeBoundsAndApplyParent(),Te.computeModelMatrix(v,Ke,De,Be,F,L,!1);const ot=a.b9([]),Je=a.e2(Te.position.lat,v.transform.zoom),St=a.bP([],[1,1,1/Je]);a.bx(ot,ot,ve),ce.push({zScaleMatrix:St,negCameraPosMatrix:ot});for(const pt of Te.nodes)iw(v,pt,Te.matrix,v.transform.expandedFarZProjMatrix,Me,_e,Re,Te.materialOverrides,Ge);Me++}if(_e.sort((Te,Xe)=>Xe.depth-Te.depth),v.renderPass!=="shadow"){if(v._debugParams.show3DModelFootprints){const Te=v.transform.projMatrix,Xe=new Map,$e=(De,Be)=>{if(De.footprint){const Ge=De.id||De.name||"footprint";if(!Xe.has(Ge)){const ot=a.aD([],Te,Be);Xe.set(Ge,{node:De,mvp:ot})}}};for(const De of Re)$e(De.node,De.modelMatrix);for(const De of _e)$e(De.node,De.modelMatrix);const Ke=Array.from(Xe.keys()).sort();for(const De of Ke){const{node:Be,mvp:Ge}=Xe.get(De);kj(v,0,Be,Ge)}}Gh(v,g,_e,Re,ce),ne()}else{for(const Te of Re)gy(Te.mesh,Te.nodeModelMatrix,v,g);for(const Te of _e)gy(Te.mesh,Te.nodeModelMatrix,v,g);ne()}}},Ij={line:function(v,d,g){if(v.hasElevatedBuckets=!1,v.hasNonElevatedBuckets=!1,v._unevaluatedLayout.getValue("line-elevation-reference")!==void 0||v._unevaluatedLayout.getValue("line-z-offset")!==void 0){if(d){const S=d.getVisibleCoordinates();for(const j of S){const R=d.getTile(j).getBucket(v);if(R&&(R.elevationType!=="none"?v.hasElevatedBuckets=!0:v.hasNonElevatedBuckets=!0,v.hasElevatedBuckets&&v.hasNonElevatedBuckets))break}}}else v.hasNonElevatedBuckets=!0},model:function(v,d,g){const S=d.getSource();if(!S.loaded())return;if(S.type==="vector"||S.type==="geojson")return void(g.modelManager&&g.modelManager.upload(g,sw(g,v)));if(S.type==="batched-model"||S.type!=="model")return;const j=S.getModels();for(const R of j)R.upload(g.context)},raster:function(v,d,g){const S=d.getSource();if(!(S instanceof fp&&S.loaded()))return;const j=v.sourceLayer||S.rasterLayerIds&&S.rasterLayerIds[0];if(!j)return;const R=v.paint.get("raster-array-band")||S.getInitialBand(j);if(R==null)return;const L=d.getIds().map(F=>d.getTileByID(F));for(const F of L)F.updateNeeded(v.id,R)&&S.prepareTile(F,j,v.id,R)},"raster-particle":function(v,d,g){const S=d.getSource();if(!(S instanceof fp&&S.loaded()))return;const j=v.sourceLayer||S.rasterLayerIds&&S.rasterLayerIds[0];if(!j)return;const R=v.paint.get("raster-particle-array-band")||S.getInitialBand(j);if(R==null)return;const L=d.getIds().map(F=>d.getTileByID(F));for(const F of L)F.updateNeeded(v.id,R)&&S.prepareTile(F,j,v.id,R)}},Pj={fill:n_},Rj={fill:function(v,d,g,S){if(!g.layout||g.layout.get("fill-elevation-reference")==="none"||g.paint.get("fill-opacity").constantOr(1)===0)return;const j=v.context.gl,R=new Lr(j.LEQUAL,Lr.ReadOnly,v.depthRangeFor3D),L=new an({func:j.ALWAYS,mask:255},255,255,j.KEEP,j.KEEP,j.REPLACE),F=v.transform.getFreeCameraOptions().position,z=v.getOrCreateProgram("elevatedStructuresDepthReconstruct");for(const W of S){const Z=d.getTile(W),ne=Z.getBucket(g);if(!ne)continue;const re=ne.elevatedStructures;if(!re||re.depthSegments.segments[0].primitiveLength===0)continue;const ie=hj(W.toUnwrapped(),F),ce=v.translatePosMatrix(W.projMatrix,Z,g.paint.get("fill-translate"),g.paint.get("fill-translate-anchor")),le=Q0(ce,ie,0,1,0);z.draw(v,j.TRIANGLES,R,L,tn.disabled,Zr.disabled,le,g.id,re.vertexBuffer,re.indexBuffer,re.depthSegments,g.paint,v.transform.zoom)}}};class hB{constructor(d,g,S,j,R){this.context=new my(d,g),this.transform=S,this._tileTextures={},this.frameCopies=[],this.loadTimeStamps=[],this._timeStamp=a.o.now(),this._averageFPS=0,this._fpsHistory=[],this._dt=0,this._debugParams={forceEnablePrecipitation:!1,showTerrainProxyTiles:!1,fpsWindow:30,continousRedraw:!1,show3DModelFootprints:!1,enabledLayers:{}};const L=["fill","line","symbol","circle","heatmap","fill-extrusion","building","raster","raster-particle","hillshade","model","background","sky"];for(const z of L)this._debugParams.enabledLayers[z]=!0;for(const z of L);this.occlusionParams=new lP,this.setup(),this.numSublayers=Nu.maxUnderzooming+Nu.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.deferredRenderGpuTimeQueries=[],this.gpuTimers={},this.frameCounter=0,this._backgroundTiles={},this.conflationActive=!1,this.replacementSource=new a.eG,this.longestCutoffRange=0,this.minCutoffZoom=0,this._fogVisible=!1,this._cachedTileFogOpacities={},this._shadowRenderer=new F0(this),this._wireframeDebugCache=new oP,this.renderDefaultNorthPole=!0,this.renderDefaultSouthPole=!0,this.layersWithOcclusionOpacity=[];const F=new a.q({width:1,height:1},Uint8Array.of(0,0,0,0));this.emptyDepthTexture=new a.T(this.context,F,d.RGBA8),this._clippingActiveLastFrame=!1,this.scaleFactor=j,this.maxFrontCutoffRawStart=0,this.worldview=R,this._forceEmissiveMode=!1,this.emissiveMode="constant"}updateTerrain(d,g){const S=!!d&&!!d.terrain&&this.transform.projection.supportsTerrain;if(!(S||this._terrain&&this._terrain.enabled))return;this._terrain||(this._terrain=new X0(this,d));const j=this._terrain;this.transform.elevation=S?j:null,j.update(d,this.transform,g),this.transform.elevation&&!j.enabled&&(this.transform.elevation=null)}_updateFog(d){const g=d.fog;if(!g||this.transform.projection.name==="globe"||g.getOpacity(this.transform.pitch)<1||g.properties.get("horizon-blend")<.03)return void(this.transform.fogCullDistSq=null);const[S,j]=g.getFovAdjustedRange(this.transform._fov);if(S>j)return void(this.transform.fogCullDistSq=null);const R=S+.78*(j-S);this.transform.fogCullDistSq=R*R}get terrain(){return this.transform._terrainEnabled()&&this._terrain&&this._terrain.enabled||this._forceTerrainMode?this._terrain:null}get forceTerrainMode(){return this._forceTerrainMode}set forceTerrainMode(d){d&&!this._terrain&&(this._terrain=new X0(this,this.style)),this._forceTerrainMode=d}get shadowRenderer(){return this._shadowRenderer&&this._shadowRenderer.enabled?this._shadowRenderer:null}get wireframeDebugCache(){return this._wireframeDebugCache}resize(d,g){if(this.width=d*a.o.devicePixelRatio,this.height=g*a.o.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const S of this.style.order)this.style._mergedLayers[S].resize()}setup(){const d=this.context,g=new a.dB;g.emplaceBack(0,0),g.emplaceBack(a.an,0),g.emplaceBack(0,a.an),g.emplaceBack(a.an,a.an),this.tileExtentBuffer=d.createVertexBuffer(g,a.dx.members),this.tileExtentSegments=a.dy.simpleSegment(0,0,4,2);const S=new a.dB;S.emplaceBack(0,0),S.emplaceBack(a.an,0),S.emplaceBack(0,a.an),S.emplaceBack(a.an,a.an),this.debugBuffer=d.createVertexBuffer(S,a.dx.members),this.debugSegments=a.dy.simpleSegment(0,0,4,5);const j=new a.dB;j.emplaceBack(-1,-1),j.emplaceBack(1,-1),j.emplaceBack(-1,1),j.emplaceBack(1,1),this.viewportBuffer=d.createVertexBuffer(j,a.dx.members),this.viewportSegments=a.dy.simpleSegment(0,0,4,2);const R=new a.eH;R.emplaceBack(0,0,0,0),R.emplaceBack(a.an,0,a.an,0),R.emplaceBack(0,a.an,0,a.an),R.emplaceBack(a.an,a.an,a.an,a.an),this.mercatorBoundsBuffer=d.createVertexBuffer(R,a.eI.members),this.mercatorBoundsSegments=a.dy.simpleSegment(0,0,4,2);const L=new a.dC;L.emplaceBack(0,1,2),L.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=d.createIndexBuffer(L);const F=new a.eJ;for(const W of[0,1,3,2,0])F.emplaceBack(W);this.debugIndexBuffer=d.createIndexBuffer(F),this.emptyTexture=new a.T(d,new a.q({width:1,height:1},Uint8Array.of(0,0,0,0)),d.gl.RGBA8),this.identityMat=a.bb();const z=this.context.gl;this.stencilClearMode=new an({func:z.ALWAYS,mask:0},0,255,z.ZERO,z.ZERO,z.ZERO),this.loadTimeStamps.push(performance.now())}getMercatorTileBoundsBuffers(){return{tileBoundsBuffer:this.mercatorBoundsBuffer,tileBoundsIndexBuffer:this.quadTriangleIndexBuffer,tileBoundsSegments:this.mercatorBoundsSegments}}getTileBoundsBuffers(d){return d._makeTileBoundsBuffers(this.context,this.transform.projection),d._tileBoundsBuffer?{tileBoundsBuffer:d._tileBoundsBuffer,tileBoundsIndexBuffer:d._tileBoundsIndexBuffer,tileBoundsSegments:d._tileBoundsSegments}:this.getMercatorTileBoundsBuffers()}clearStencil(){const d=this.context.gl;this.nextStencilID=1,this.currentStencilSource=void 0,this._tileClippingMaskIDs={},this.getOrCreateProgram("clippingMask").draw(this,d.TRIANGLES,Lr.disabled,this.stencilClearMode,tn.disabled,Zr.disabled,Y0(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs={})}_renderTileClippingMasks(d,g,S){if(!g||this.currentStencilSource===g.id||!d.isTileClipped()||!S||S.length===0)return;if(this._tileClippingMaskIDs&&!this.terrain){let F=!1;for(const z of S)if(this._tileClippingMaskIDs[z.key]===void 0){F=!0;break}if(!F)return}this.currentStencilSource=g.id;const j=this.context,R=j.gl;this.nextStencilID+S.length>256&&this.clearStencil(),j.setColorMode(tn.disabled),j.setDepthMode(Lr.disabled);const L=this.getOrCreateProgram("clippingMask");this._tileClippingMaskIDs={};for(const F of S){const z=g.getTile(F),W=this._tileClippingMaskIDs[F.key]=this.nextStencilID++,{tileBoundsBuffer:Z,tileBoundsIndexBuffer:ne,tileBoundsSegments:re}=this.getTileBoundsBuffers(z);L.draw(this,R.TRIANGLES,Lr.disabled,new an({func:R.ALWAYS,mask:0},W,255,R.KEEP,R.KEEP,R.REPLACE),tn.disabled,Zr.disabled,Y0(F.projMatrix),"$clipping",Z,ne,re)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const d=this.nextStencilID++,g=this.context.gl;return new an({func:g.NOTEQUAL,mask:255},d,255,g.KEEP,g.KEEP,g.REPLACE)}stencilModeForClipping(d){if(this.terrain)return this.terrain.stencilModeForRTTOverlap(d);const g=this.context.gl;return new an({func:g.EQUAL,mask:255},this._tileClippingMaskIDs[d.key],0,g.KEEP,g.KEEP,g.REPLACE)}stencilConfigForOverlap(d){const g=this.context.gl,S=d.sort((L,F)=>F.overscaledZ-L.overscaledZ),j=S[S.length-1].overscaledZ,R=S[0].overscaledZ-j+1;if(R>1){this.currentStencilSource=void 0,this.nextStencilID+R>256&&this.clearStencil();const L={};for(let F=0;Fthis._debugParams.fpsWindow&&this._fpsHistory.splice(0,this._fpsHistory.length-this._debugParams.fpsWindow),this._averageFPS=Math.round(this._fpsHistory.reduce((d,g)=>d+g/this._fpsHistory.length,0))}render(d,g){const S=a.o.now();this._dt=S-this._timeStamp,this._timeStamp=S,this._wireframeDebugCache.update(this.frameCounter),this._debugParams.continousRedraw=d.map.repaint,this.style=d,this.options=g;const j=this.style._mergedLayers,R=!(!this.terrain||!this.terrain.enabled),L=()=>this.style._getOrder(R).filter(ut=>{const st=j[ut];return!(st.type in this._debugParams.enabledLayers)||this._debugParams.enabledLayers[st.type]});let F=L(),z=!1,W=!1,Z=null,ne=0,re=!1;for(const ut of F){const st=j[ut];st.visibility!=="none"&&(st.type==="circle"?z=!0:st.type==="building"?(Z=st,++ne):st.type==="symbol"&&(st.hasOcclusionOpacityProperties?W=!0:z=!0))}this.updateEmissiveMode();let ie=F.map(ut=>j[ut]);const ce=this.style._mergedSourceCaches;this.imageManager=d.imageManager,this.modelManager=d.modelManager,this.symbolFadeChange=d.placement.symbolFadeChange(a.o.now()),this.imageManager.beginFrame();for(const ut in ce){const st=ce[ut];st.used&&(st.prepare(this.context),st.getSource().usedInConflation&&++ne)}let le=!1;for(const ut of ie)ut.isHidden(this.transform.zoom)||(ut.type==="clip"&&(le=!0),this.prepareLayer(ut));const ve={},_e={},Re={},Me={},Te={};for(const ut in ce){const st=ce[ut];ve[ut]=st.getVisibleCoordinates(),_e[ut]=ve[ut].slice().reverse(),Re[ut]=st.getVisibleCoordinates(!0).reverse(),Me[ut]=st.getShadowCasterCoordinates(),Te[ut]=st.sortCoordinatesByDistance(ve[ut])}const Xe=ut=>{const st=this.style.getLayerSourceCache(ut);return st&&st.used?st.getSource():null};if(ne||le||this._clippingActiveLastFrame){const ut=[],st=[];let vt=0;for(const Et of ie)this.isSourceForClippingOrConflation(Et,Xe(Et))&&(ut.push(Et),st.push(vt)),vt++;if(ut&&(le||ut.length>1)||this._clippingActiveLastFrame){le=!1;const Et=[];for(let Nt=0;Nt0){const Et=Xe(st);Et&&(this.minCutoffZoom=Math.max(Et.minzoom,this.minCutoffZoom)),st.minzoom&&(this.minCutoffZoom=Math.max(st.minzoom,this.minCutoffZoom))}st.is3D(R)&&(this.opaquePassCutoff===1/0&&(this.opaquePassCutoff=ut),this._lastOcclusionLayer=ut)}const $e=this.style&&this.style.fog;$e?(this._fogVisible=$e.getOpacity(this.transform.pitch)!==0,this._fogVisible&&this.transform.projection.name!=="globe"&&(this._fogVisible=$e.isVisibleOnFrustum(this.transform.cameraFrustum))):this._fogVisible=!1,this._cachedTileFogOpacities={},this.terrain&&(this.terrain.updateTileBinding(Re),this.opaquePassCutoff=0,F=L(),ie=F.map(ut=>j[ut]));const Ke=this._shadowRenderer;if(Ke){Ke.updateShadowParameters(this.transform,this.style.directionalLight);for(const ut in ce)for(const st of ve[ut]){let vt={min:0,max:0};this.terrain&&(vt=this.terrain.getMinMaxForTile(st)||vt),Ke.addShadowReceiver(st.toUnwrapped(),vt.min,vt.max)}}this.transform.projection.name!=="globe"||this.globeSharedBuffers||(this.globeSharedBuffers=new a.eL(this.context)),this.style.fog&&this.transform.projection.supportsFog?(this._atmosphere||(this._atmosphere=new sP(this)),this._atmosphere.update(this)):this._atmosphere&&(this._atmosphere.destroy(),this._atmosphere=void 0);const De=this._debugParams.forceEnablePrecipitation||!(!this.style||!this.style.snow),Be=this._debugParams.forceEnablePrecipitation||!(!this.style||!this.style.rain);if(De&&!this._snow&&(this._snow=new dP(this)),!De&&this._snow&&(this._snow.destroy(),delete this._snow),Be&&!this._rain&&(this._rain=new o_(this)),!Be&&this._rain&&(this._rain.destroy(),delete this._rain),this._snow&&this._snow.update(this),this._rain&&this._rain.update(this),Z){this.buildingTileBorderManager||(this.buildingTileBorderManager=new qh);const ut=this.style.getLayerSourceCache(Z);this.buildingTileBorderManager.updateBorders(ut,Z)}if(!$r.has(this.context.gl))return;this.renderPass="offscreen";for(const ut of ie){const st=d.getLayerSourceCache(ut);if(!ut.hasOffscreenPass()||ut.isHidden(this.transform.zoom))continue;const vt=st?_e[st.id]:void 0;(ut.type==="custom"||ut.type==="raster"||ut.type==="raster-particle"||ut.isSky()||vt&&vt.length)&&this.renderLayer(this,st,ut,vt)}this.depthRangeFor3D=[0,1-(ie.length+2)*this.numSublayers*this.depthEpsilon],this._shadowRenderer&&(this.renderPass="shadow",this._shadowRenderer.drawShadowPass(this.style,Me)),this.context.bindFramebuffer.set(null),this.context.viewport.set([0,0,this.width,this.height]);const Ge=this.transform.projection.name==="globe"||this.transform.isHorizonVisible(),ot=(()=>{if(g.showOverdrawInspector)return a.aq.black;const ut=this.style.fog;if(ut&&this.transform.projection.supportsFog){const st=this.style.getLut(ut.scope);if(!Ge){const vt=ut.properties.get("color-use-theme")==="none",Et=ut.properties.get("color").toNonPremultipliedRenderColor(vt?null:st).toArray01();return new a.aq(...Et)}if(Ge){const vt=ut.properties.get("space-color-use-theme")==="none",Et=ut.properties.get("space-color").toNonPremultipliedRenderColor(vt?null:st).toArray01();return new a.aq(...Et)}}return a.aq.transparent})();if(this.context.clear({color:ot,depth:1}),this.clearStencil(),this._showOverdrawInspector=g.showOverdrawInspector,this.renderPass="opaque",this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&Ge&&this._atmosphere.drawStars(this,this.style.fog),!this.terrain)for(this.currentLayer=F.length-1;this.currentLayer>=0;this.currentLayer--){const ut=ie[this.currentLayer],st=d.getLayerSourceCache(ut);if(ut.isSky())continue;const vt=st?(ut.is3D(R)?Te:_e)[st.id]:void 0;this._renderTileClippingMasks(ut,st,vt),this.renderLayer(this,st,ut,vt)}if(this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&Ge&&this._atmosphere.drawAtmosphereGlow(this,this.style.fog),this.renderPass="sky",(!this._atmosphere||a.al(this.transform.zoom)>0)&&(this.transform.projection.name==="globe"||this.transform.isHorizonVisible()))for(this.currentLayer=0;this.currentLayer{for(this.currentLayer=0;this.currentLayer=this._lastOcclusionLayer&&this.layersWithOcclusionOpacity.length>0){const vt=this.currentLayer;this.depthOcclusion=!0;for(const Et of this.layersWithOcclusionOpacity){this.currentLayer=Et;const Nt=ie[this.currentLayer],lr=d.getLayerSourceCache(Nt),Jt=lr?_e[lr.id]:void 0;this.terrain||this._renderTileClippingMasks(Nt,lr,lr?ve[lr.id]:void 0),this.renderLayer(this,lr,Nt,Jt)}this.depthOcclusion=!1,this.currentLayer=vt,this.renderPass="translucent",this.layersWithOcclusionOpacity=[]}++this.currentLayer}}if(this.terrain&&this.terrain.postRender(),this._snow&&this._snow.draw(this),this._rain&&this._rain.draw(this),this.options.showTileBoundaries||this.options.showQueryGeometry||this.options.showTileAABBs){let ut=null;ie.forEach(st=>{const vt=d.getLayerSourceCache(st);vt&&!st.isHidden(this.transform.zoom)&&vt.getVisibleCoordinates().length&&(!ut||ut.getSource().maxzoom0?g.pop():null}terrainRenderModeElevated(){return this.style&&!!this.style.getTerrain()&&!!this.terrain&&!this.terrain.renderingToTexture||this.forceTerrainMode}linearFloatFilteringSupported(){return this.context.extTextureFloatLinear!=null}currentGlobalDefines(d,g,S){const j=S===void 0?this.terrain&&this.terrain.renderingToTexture:S,R=[];return this.style&&this.style.enable3dLights()&&(d==="globeRaster"||d==="terrainRaster"?(R.push("LIGHTING_3D_MODE"),R.push("LIGHTING_3D_ALPHA_EMISSIVENESS")):j||R.push("LIGHTING_3D_MODE")),this.terrainRenderModeElevated()&&(R.push("TERRAIN"),this.linearFloatFilteringSupported()&&R.push("TERRAIN_DEM_FLOAT_FORMAT")),this.transform.projection.name==="globe"&&R.push("GLOBE"),!this._fogVisible||j||g!==void 0&&!g||R.push("FOG"),j&&R.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&R.push("OVERDRAW_INSPECTOR"),R}getOrCreateProgram(d,g){this.cache=this.cache||{};const S=g&&g.defines||[],j=g&&g.config,R=this.currentGlobalDefines(d,g&&g.overrideFog,g&&g.overrideRtt).concat(S),L=Tp.cacheKey(wI[d],d,R,j);return this.cache[L]||(this.cache[L]=new Tp(this.context,d,wI[d],j,Zb[d],R)),this.cache[L]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.frontFace.setDefault(),this.context.cullFaceSide.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){const d=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(d.FUNC_ADD)}initDebugOverlayCanvas(){this.debugOverlayCanvas==null&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new a.T(this.context,this.debugOverlayCanvas,this.context.gl.RGBA8))}destroy(){this._terrain&&this._terrain.destroy(),this._atmosphere&&(this._atmosphere.destroy(),this._atmosphere=void 0),this.globeSharedBuffers&&this.globeSharedBuffers.destroy(),this.emptyTexture.destroy(),this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),this._wireframeDebugCache.destroy(),this.depthFBO&&(this.depthFBO.destroy(),this.depthFBO=void 0,this.depthTexture=void 0),this.emptyDepthTexture&&this.emptyDepthTexture.destroy()}prepareDrawTile(){this.terrain&&this.terrain.prepareDrawTile()}uploadCommonLightUniforms(d,g){if(this.style.enable3dLights()){const S=this.style.directionalLight,j=this.style.ambientLight;if(S&&j){const R=((L,F,z)=>{const W=L.properties.get("direction"),Z=L.properties.get("color-use-theme")==="none",ne=L.properties.get("color").toNonPremultipliedRenderColor(Z?null:z.getLut(L.scope)).toArray01(),re=L.properties.get("intensity"),ie=F.properties.get("color-use-theme")==="none",ce=F.properties.get("color").toNonPremultipliedRenderColor(ie?null:z.getLut(F.scope)).toArray01(),le=F.properties.get("intensity"),ve=[W.x,W.y,W.z],_e=a.dD(ce,le),Re=a.dD(ne,re);return{u_lighting_ambient_color:_e,u_lighting_directional_dir:ve,u_lighting_directional_color:Re,u_ground_radiance:oj(ve,Re,_e)}})(S,j,this.style);g.setLightsUniformValues(d,R)}}}uploadCommonUniforms(d,g,S,j,R){if(this.uploadCommonLightUniforms(d,g),this.terrain&&this.terrain.renderingToTexture)return;const L=this.style.fog;if(L){const F=L.getOpacity(this.transform.pitch),z=((W,Z,ne,re,ie,ce,le,ve,_e,Re,Me,Te)=>{const Xe=W.transform,$e=Z.properties.get("color-use-theme")==="none",Ke=Z.properties.get("color").toNonPremultipliedRenderColor($e?null:W.style.getLut(Z.scope)).toArray01();Ke[3]=re;const De=W.frameCounter/1e3%1,[Be,Ge]=Z.properties.get("vertical-range");return{u_fog_matrix:ne?Xe.calculateFogTileMatrix(ne):Te||W.identityMat,u_fog_range:Z.getFovAdjustedRange(Xe._fov),u_fog_color:Ke,u_fog_horizon_blend:Z.properties.get("horizon-blend"),u_fog_vertical_limit:[Math.min(Be,Ge),Ge],u_fog_temporal_offset:De,u_frustum_tl:ie,u_frustum_tr:ce,u_frustum_br:le,u_frustum_bl:ve,u_globe_pos:_e,u_globe_radius:Re,u_viewport:Me,u_globe_transition:a.al(Xe.zoom),u_is_globe:+(Xe.projection.name==="globe")}})(this,L,S,F,this.transform.frustumCorners.TL,this.transform.frustumCorners.TR,this.transform.frustumCorners.BR,this.transform.frustumCorners.BL,this.transform.globeCenterInViewSpace,this.transform.globeRadius,[this.transform.width*a.o.devicePixelRatio,this.transform.height*a.o.devicePixelRatio],j);g.setFogUniformValues(d,z)}R&&g.setCutoffUniformValues(d,R.uniformValues)}setTileLoadedFlag(d){this.tileLoaded=d}saveCanvasCopy(){const d=this.canvasCopy();d&&(this.frameCopies.push(d),this.tileLoaded=!1)}canvasCopy(){const d=this.context.gl,g=d.createTexture();return d.bindTexture(d.TEXTURE_2D,g),d.copyTexImage2D(d.TEXTURE_2D,0,d.RGBA,0,0,d.drawingBufferWidth,d.drawingBufferHeight,0),g}getCanvasCopiesAndTimestamps(){return{canvasCopies:this.frameCopies,timeStamps:this.loadTimeStamps}}averageElevationNeedsEasing(){if(!this.transform._elevation)return!1;const d=this.style&&this.style.fog;return!!d&&d.getOpacity(this.transform.pitch)!==0}getBackgroundTiles(){const d=this._backgroundTiles,g=this._backgroundTiles={},S=this.transform.coveringTiles({tileSize:512});for(const j of S)g[j.key]=d[j.key]||new a.b0(j,512,this.transform.tileZoom,this,void 0,this.worldview);return g}clearBackgroundTiles(){this._backgroundTiles={}}isSourceForClippingOrConflation(d,g){return!(!d.is3D(!(!this.terrain||!this.terrain.enabled))||d.type!=="clip"&&d.type!=="building"&&(d.minzoom&&d.minzoom>this.transform.zoom||(this.style._clipLayerPresent||d.sourceLayer!=="building"&&d.sourceLayer!=="procedural_buildings")&&(!g||g.type!=="batched-model")))}isTileAffectedByFog(d){if(!this.style||!this.style.fog)return!1;if(this.transform.projection.name==="globe")return!0;let g=this._cachedTileFogOpacities[d.key];return g||(this._cachedTileFogOpacities[d.key]=g=this.style.fog.getOpacityForTile(d)),g[0]>=xr||g[1]>=xr}setupDepthForOcclusion(d,g,S){const j=this.context,R=j.gl,L=!!S;var F;S||(S={u_dem:2,u_dem_prev:4,u_dem_tl:[0,0],u_dem_tl_prev:[0,0],u_dem_scale:0,u_dem_scale_prev:0,u_dem_size:0,u_dem_lerp:1,u_depth:3,u_depth_size_inv:[0,0],u_depth_range_unpack:[0,1],u_occluder_half_size:16,u_occlusion_depth_offset:-1e-4,u_exaggeration:0}),j.activeTexture.set(R.TEXTURE3),d&&this.depthFBO&&this.depthTexture?(this.depthTexture.bind(R.NEAREST,R.CLAMP_TO_EDGE),S.u_depth_size_inv=[1/this.depthFBO.width,1/this.depthFBO.height],S.u_depth_range_unpack=[2/((F=this.depthRangeFor3D)[1]-F[0]),-1-2*F[0]/(F[1]-F[0])],S.u_occluder_half_size=.5*this.occlusionParams.occluderSize,S.u_occlusion_depth_offset=this.occlusionParams.depthOffset):this.emptyDepthTexture.bind(R.NEAREST,R.CLAMP_TO_EDGE),j.activeTexture.set(R.TEXTURE0),L||g.setTerrainUniformValues(j,S)}updateEmissiveMode(){if(this._forceEmissiveMode)return;const d=this.style.hasDataDrivenEmissiveStrength();this.emissiveMode=d?this.context.extBlendFuncExtended?"dual-source-blending":"mrt-fallback":"constant"}}function Lj(v,d){let g=!1,S=null;const j=()=>{S=null,g&&(v(),S=setTimeout(j,d),g=!1)};return()=>(g=!0,S||j(),S)}class fB{constructor(d){this._hashName=d&&encodeURIComponent(d),a.aZ(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=Lj(this._updateHashUnthrottled.bind(this),300)}addTo(d){return this._map=d,window.addEventListener("hashchange",this._onHashChange,!1),d.on("moveend",this._updateHash),this}remove(){return this._map?(this._map.off("moveend",this._updateHash),window.removeEventListener("hashchange",this._onHashChange,!1),clearTimeout(this._updateHash()),this._map=void 0,this):this}getHashString(){const d=this._map;if(!d)return"";const g=fl(d);if(this._hashName){const S=this._hashName;let j=!1;const R=location.hash.slice(1).split("&").map(L=>{const F=L.split("=")[0];return F===S?(j=!0,`${F}=${g}`):L}).filter(L=>L);return j||R.push(`${S}=${g}`),`#${R.join("&")}`}return`#${g}`}_getCurrentHash(){const d=location.hash.replace("#","");if(this._hashName){let g;return d.split("&").map(S=>S.split("=")).forEach(S=>{S[0]===this._hashName&&(g=S)}),(g&&g[1]||"").split("/")}return d.split("/")}_onHashChange(){const d=this._map;if(!d)return!1;const g=this._getCurrentHash();if(g.length>=3&&!g.some(S=>isNaN(Number(S)))){const S=d.dragRotate.isEnabled()&&d.touchZoomRotate.isEnabled()?+(g[3]||0):d.getBearing();return d.jumpTo({center:[+g[2],+g[1]],zoom:+g[0],bearing:S,pitch:+(g[4]||0)}),!0}return!1}_updateHashUnthrottled(){history.replaceState(history.state,"",location.href.replace(/(#.+)?$/,this.getHashString()))}}function fl(v,d){const g=v.getCenter(),S=Math.round(100*v.getZoom())/100,j=Math.ceil((S*Math.LN2+Math.log(512/360/.5))/Math.LN10),R=Math.pow(10,j),L=Math.round(g.lng*R)/R,F=Math.round(g.lat*R)/R,z=v.getBearing(),W=v.getPitch();let Z=d?`/${L}/${F}/${S}`:`${S}/${F}/${L}`;return(z||W)&&(Z+="/"+Math.round(10*z)/10),W&&(Z+=`/${Math.round(W)}`),Z}const uw={linearity:.3,easing:a.eN(0,0,.3,1)},l_=Object.assign({deceleration:2500,maxSpeed:1400},uw),mB=Object.assign({deceleration:20,maxSpeed:1400},uw),Xs=Object.assign({deceleration:1e3,maxSpeed:360},uw),On=Object.assign({deceleration:1e3,maxSpeed:90},uw);class fP{constructor(d){this._map=d,this.clear()}clear(){this._inertiaBuffer=[]}record(d){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:a.o.now(),settings:d})}_drainInertiaBuffer(){const d=this._inertiaBuffer,g=a.o.now();for(;d.length>0&&g-d[0].time>160;)d.shift()}_onMoveEnd(d){if(this._map._prefersReducedMotion()||(this._drainInertiaBuffer(),this._inertiaBuffer.length<2))return;const g={zoom:0,bearing:0,pitch:0,pan:new a.P(0,0),pinchAround:void 0,around:void 0};for(const{settings:R}of this._inertiaBuffer)g.zoom+=R.zoomDelta||0,g.bearing+=R.bearingDelta||0,g.pitch+=R.pitchDelta||0,R.panDelta&&g.pan._add(R.panDelta),R.around&&(g.around=R.around),R.pinchAround&&(g.pinchAround=R.pinchAround);const S=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,j={};if(g.pan.mag()){const R=Qd(g.pan.mag(),S,Object.assign({},l_,d||{}));j.offset=g.pan.mult(R.amount/g.pan.mag()),j.center=this._map.transform.center,Sc(j,R)}if(g.zoom){const R=Qd(g.zoom,S,mB);j.zoom=this._map.transform.zoom+R.amount,Sc(j,R)}if(g.bearing){const R=Qd(g.bearing,S,Xs);j.bearing=this._map.transform.bearing+a.aC(R.amount,-179,179),Sc(j,R)}if(g.pitch){const R=Qd(g.pitch,S,On);j.pitch=this._map.transform.pitch+R.amount,Sc(j,R)}if(j.zoom||j.bearing){const R=g.pinchAround===void 0?g.around:g.pinchAround;j.around=R?this._map.unproject(R):this._map.getCenter()}return this.clear(),j.noMoveStart=!0,j}}function Sc(v,d){(!v.duration||v.durationg.unproject(z)),F=R.reduce((z,W,Z,ne)=>z.add(W.div(ne.length)),new a.P(0,0));super(d,{points:R,point:F,lngLats:L,lngLat:g.unproject(F),originalEvent:S}),this._defaultPrevented=!1}}class Mj extends a.C{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(d,g){super("wheel",{originalEvent:g}),this._defaultPrevented=!1}}class Dj{constructor(d,g){this._map=d,this._clickTolerance=g.clickTolerance}reset(){this._mousedownPos=void 0}wheel(d){return this._firePreventable(new Mj(this._map,d))}mousedown(d,g){return this._mousedownPos=g,this._firePreventable(new Ro(d.type,this._map,d))}mouseup(d){this._map.fire(new Ro(d.type,this._map,d))}preclick(d){const g=new MouseEvent("preclick",d);this._map.fire(new Ro(g.type,this._map,g))}click(d,g){this._mousedownPos&&this._mousedownPos.dist(g)>=this._clickTolerance||(this.preclick(d),this._map.fire(new Ro(d.type,this._map,d)))}dblclick(d){return this._firePreventable(new Ro(d.type,this._map,d))}mouseover(d){this._map.fire(new Ro(d.type,this._map,d))}mouseout(d){this._map.fire(new Ro(d.type,this._map,d))}touchstart(d){return this._firePreventable(new Wc(d.type,this._map,d))}touchmove(d){this._map.fire(new Wc(d.type,this._map,d))}touchend(d){this._map.fire(new Wc(d.type,this._map,d))}touchcancel(d){this._map.fire(new Wc(d.type,this._map,d))}_firePreventable(d){if(this._map.fire(d),d.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Oj{constructor(d){this._map=d}reset(){this._delayContextMenu=!1,this._contextMenuEvent=void 0}mousemove(d){this._map.fire(new Ro(d.type,this._map,d))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new Ro("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(d){this._delayContextMenu?this._contextMenuEvent=d:this._map.fire(new Ro(d.type,this._map,d)),this._map.listens("contextmenu")&&d.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Fj{constructor(d,g){this._map=d,this._el=d.getCanvasContainer(),this._container=d.getContainer(),this._clickTolerance=g.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(d,g){this.isEnabled()&&d.shiftKey&&d.button===0&&(U(),this._startPos=this._lastPos=g,this._active=!0)}mousemoveWindow(d,g){if(!this._active)return;const S=g,j=this._startPos,R=this._lastPos;if(!j||!R||R.equals(S)||!this._box&&S.dist(j){this._box&&(this._box.style.transform=`translate(${L}px,${z}px)`,this._box.style.width=F-L+"px",this._box.style.height=W-z+"px")})}mouseupWindow(d,g){if(!this._active)return;const S=this._startPos,j=g;if(S&&d.button===0){if(this.reset(),K(),S.x!==j.x||S.y!==j.y)return this._map.fire(new a.C("boxzoomend",{originalEvent:d})),{cameraAnimation:R=>R.fitScreenCoordinates(S,j,this._map.getBearing(),{linear:!1})};this._fireEvent("boxzoomcancel",d)}}keydown(d){this._active&&d.keyCode===27&&(this.reset(),this._fireEvent("boxzoomcancel",d))}blur(){this.reset()}reset(){this._active=!1,this._container.classList.remove("mapboxgl-crosshair"),this._box&&(this._box.remove(),this._box=null),q(),delete this._startPos,delete this._lastPos}_fireEvent(d,g){return this._map.fire(new a.C(d,{originalEvent:g}))}}function c_(v,d){const g={};for(let S=0;Sthis.numTouches)&&(this.aborted=!0),this.aborted||(this.startTime===0&&(this.startTime=d.timeStamp),S.length===this.numTouches&&(this.centroid=function(j){const R=new a.P(0,0);for(const L of j)R._add(L);return R.div(j.length)}(g),this.touches=c_(S,g)))}touchmove(d,g,S){if(this.aborted||!this.centroid)return;const j=c_(S,g);for(const R in this.touches){const L=j[R];(!L||L.dist(this.touches[R])>30)&&(this.aborted=!0)}}touchend(d,g,S){if((!this.centroid||d.timeStamp-this.startTime>500)&&(this.aborted=!0),S.length===0){const j=!this.aborted&&this.centroid;if(this.reset(),j)return j}}}class Jd{constructor(d){this.singleTap=new Lu(d),this.numTaps=d.numTaps,this.reset()}reset(){this.lastTime=1/0,this.lastTap=void 0,this.count=0,this.singleTap.reset()}touchstart(d,g,S){this.singleTap.touchstart(d,g,S)}touchmove(d,g,S){this.singleTap.touchmove(d,g,S)}touchend(d,g,S){const j=this.singleTap.touchend(d,g,S);if(j){const R=d.timeStamp-this.lastTime<500,L=!this.lastTap||this.lastTap.dist(j)<30;if(R&&L||this.reset(),this.count++,this.lastTime=d.timeStamp,this.lastTap=j,this.count===this.numTaps)return this.reset(),j}}}class _y{constructor(){this._zoomIn=new Jd({numTouches:1,numTaps:2}),this._zoomOut=new Jd({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(d,g,S){this._zoomIn.touchstart(d,g,S),this._zoomOut.touchstart(d,g,S)}touchmove(d,g,S){this._zoomIn.touchmove(d,g,S),this._zoomOut.touchmove(d,g,S)}touchend(d,g,S){const j=this._zoomIn.touchend(d,g,S),R=this._zoomOut.touchend(d,g,S);return j?(this._active=!0,d.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:L=>L.easeTo({duration:300,zoom:L.getZoom()+1,around:L.unproject(j)},{originalEvent:d})}):R?(this._active=!0,d.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:L=>L.easeTo({duration:300,zoom:L.getZoom()-1,around:L.unproject(R)},{originalEvent:d})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}const dw=0,Bj=2,$j={[dw]:1,[Bj]:2},Wh={Control:"ctrlKey",Alt:"altKey",Shift:"shiftKey",Meta:"metaKey"};class u_{constructor(d){this.reset(),this._clickTolerance=d.clickTolerance||1}blur(){this.reset()}reset(){this._active=!1,this._moved=!1,this._lastPoint=void 0,this._eventButton=void 0}_correctButton(d,g){return!1}_move(d,g){return{}}mousedown(d,g){if(this._lastPoint)return;const S=ee(d);this._correctButton(d,S)&&(this._lastPoint=g,this._eventButton=S)}mousemoveWindow(d,g){const S=this._lastPoint;if(S){if(d.preventDefault(),this._eventButton!=null&&function(j,R){const L=$j[R];return j.buttons===void 0||(j.buttons&L)!==L}(d,this._eventButton))this.reset();else if(this._moved||!(g.dist(S)0&&(this._active=!0);const j=c_(S,g),R=new a.P(0,0),L=new a.P(0,0);let F=0;for(const W in j){const Z=j[W],ne=this._touches[W];ne&&(R._add(Z),L._add(Z.sub(ne)),F++,j[W]=Z)}if(this._touches=j,F{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show"),this._alertContainer.removeAttribute("role")},500)}}class h_{constructor(){this.reset()}reset(){this._active=!1,this._firstTwoTouches=void 0}_start(d){}_move(d,g,S){return{}}touchstart(d,g,S){this._firstTwoTouches||S.length<2||(this._firstTwoTouches=[S[0].identifier,S[1].identifier],this._start([g[0],g[1]]))}touchmove(d,g,S){const j=this._firstTwoTouches;if(!j)return;d.preventDefault();const[R,L]=j,F=Pi(S,g,R),z=Pi(S,g,L);if(!F||!z)return;const W=this._aroundCenter?null:F.add(z).div(2);return this._move([F,z],W,d)}touchend(d,g,S){if(!this._firstTwoTouches)return;const[j,R]=this._firstTwoTouches,L=Pi(S,g,j),F=Pi(S,g,R);L&&F||(this._active&&K(),this.reset())}touchcancel(){this.reset()}enable(d){this._enabled=!0,this._aroundCenter=!!d&&d.around==="center"}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}function Pi(v,d,g){for(let S=0;SMath.abs(v.x)}class Vj extends h_{constructor(d){super(),this._map=d}reset(){super.reset(),this._valid=void 0,this._firstMove=void 0,this._lastPoints=void 0}_start(d){this._lastPoints=d,f_(d[0].sub(d[1]))&&(this._valid=!1)}_move(d,g,S){const j=this._lastPoints;if(!j)return;const R=d[0].sub(j[0]),L=d[1].sub(j[1]);return this._map._cooperativeGestures&&!a.eO()&&S.touches.length<3||(this._valid=this.gestureBeginsVertically(R,L,S.timeStamp),!this._valid)?void 0:(this._lastPoints=d,this._active=!0,{pitchDelta:(R.y+L.y)/2*-.5})}gestureBeginsVertically(d,g,S){if(this._valid!==void 0)return this._valid;const j=d.mag()>=2,R=g.mag()>=2;if(!j&&!R)return;if(!j||!R)return this._firstMove==null&&(this._firstMove=S),S-this._firstMove<100&&void 0;const L=d.y>0==g.y>0;return f_(d)&&f_(g)&&L}}const qj={panStep:100,bearingStep:15,pitchStep:10};class Pp{constructor(){const d=qj;this._panStep=d.panStep,this._bearingStep=d.bearingStep,this._pitchStep=d.pitchStep,this._rotationDisabled=!1}blur(){this.reset()}reset(){this._active=!1}keydown(d){if(d.altKey||d.ctrlKey||d.metaKey)return;let g=0,S=0,j=0,R=0,L=0;switch(d.keyCode){case 61:case 107:case 171:case 187:g=1;break;case 189:case 109:case 173:g=-1;break;case 37:d.shiftKey?S=-1:(d.preventDefault(),R=-1);break;case 39:d.shiftKey?S=1:(d.preventDefault(),R=1);break;case 38:d.shiftKey?j=1:(d.preventDefault(),L=-1);break;case 40:d.shiftKey?j=-1:(d.preventDefault(),L=1);break;default:return}return this._rotationDisabled&&(S=0,j=0),{cameraAnimation:F=>{const z=F.getZoom();F.easeTo({duration:300,easeId:"keyboardHandler",easing:Gj,zoom:g?Math.round(z)+g*(d.shiftKey?2:1):z,bearing:F.getBearing()+S*this._bearingStep,pitch:F.getPitch()+j*this._pitchStep,offset:[-R*this._panStep,-L*this._panStep],center:F.getCenter()},{originalEvent:d})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0}enableRotation(){this._rotationDisabled=!1}}function Gj(v){return v*(2-v)}const Rp=4.000244140625,Hj=1/450;class pw{constructor(d,g){this._map=d,this._el=d.getCanvasContainer(),this._handler=g,this._delta=0,this._lastDelta=0,this._defaultZoomRate=.01,this._wheelZoomRate=Hj,a.aZ(["_onTimeout","_addScrollZoomBlocker","_showBlockerAlert"],this)}setZoomRate(d){this._defaultZoomRate=d}setWheelZoomRate(d){this._wheelZoomRate=d}isEnabled(){return!!this._enabled}isActive(){return this._active||this._finishTimeout!==void 0}isZooming(){return!!this._zooming}enable(d){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!d&&d.around==="center",this._map._cooperativeGestures&&this._addScrollZoomBlocker())}disable(){this.isEnabled()&&(this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove()))}wheel(d){if(!this.isEnabled())return;if(this._map._cooperativeGestures){if(!(d.ctrlKey||d.metaKey||this.isZooming()||a.eO()))return void this._showBlockerAlert();this._alertContainer.style.visibility!=="hidden"&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}let g=d.deltaMode===WheelEvent.DOM_DELTA_LINE?40*d.deltaY:d.deltaY;const S=a.o.now(),j=S-(this._lastWheelEventTime||0);this._lastWheelEventTime=S,g!==0&&g%Rp===0?this._type="wheel":g!==0&&Math.abs(g)<4?this._type="trackpad":j>400?(this._type=null,this._lastValue=g,this._timeout=window.setTimeout(this._onTimeout,40,d)):this._type||(this._type=Math.abs(j*g)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,g+=this._lastValue)),d.shiftKey&&g&&(g/=4),this._type&&(this._lastWheelEvent=d,this._delta-=g,this._active||this._start(d)),d.preventDefault()}_onTimeout(d){this._type="wheel",this._delta-=this._lastValue,this._active||this._start(d)}_start(d){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);const g=Q(this._el,d);this._aroundPoint=this._aroundCenter?this._map.transform.centerPoint:g,this._aroundCoord=this._map.transform.pointCoordinate3D(this._aroundPoint),this._targetZoom=void 0,this._frameId||(this._frameId=!0,this._handler._triggerRenderFrame())}renderFrame(){if(!this._frameId||(this._frameId=null,!this.isActive()))return;const d=this._map.transform;this._type==="wheel"&&d.projection.wrap&&(d._center.lng>=180||d._center.lng<=-180)&&(this._prevEase=null,this._easing=null,this._lastWheelEvent=null,this._lastWheelEventTime=0);const g=()=>d._terrainEnabled()&&this._aroundCoord?d.computeZoomRelativeTo(this._aroundCoord):d.zoom;if(this._delta!==0){const W=this._type==="wheel"&&Math.abs(this._delta)>Rp?this._wheelZoomRate:this._defaultZoomRate;let Z=2/(1+Math.exp(-Math.abs(this._delta*W)));this._delta<0&&Z!==0&&(Z=1/Z);const ne=g(),re=Math.pow(2,ne),ie=typeof this._targetZoom=="number"?d.zoomScale(this._targetZoom):re;this._targetZoom=Math.min(d.maxZoom,Math.max(d.minZoom,d.scaleZoom(ie*Z))),this._type==="wheel"&&(this._startZoom=ne,this._easing=this._smoothOutEasing(200)),this._lastDelta=this._delta,this._delta=0}const S=typeof this._targetZoom=="number"?this._targetZoom:g(),j=this._startZoom,R=this._easing;let L,F=!1;if(this._type==="wheel"&&j&&R){const W=Math.min((a.o.now()-this._lastWheelEventTime)/200,1),Z=R(W);L=a.am(j,S,Z),W<1?this._frameId||(this._frameId=!0):F=!0}else L=S,F=!0;this._active=!0,F&&(this._active=!1,this._finishTimeout=window.setTimeout(()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200));let z=L-g();return z*this._lastDelta<0&&(z=0),{noInertia:!0,needsRenderFrame:!F,zoomDelta:z,around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(d){let g=a.eP;if(this._prevEase){const S=this._prevEase,j=(a.o.now()-S.start)/S.duration,R=S.easing(j+.01)-S.easing(j),L=.27/Math.sqrt(R*R+1e-4)*.01,F=Math.sqrt(.0729-L*L);g=a.eN(L,F,.25,1)}return this._prevEase={start:a.o.now(),duration:d,easing:g},g}blur(){this.reset()}reset(){this._active=!1}_addScrollZoomBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=C("div","mapboxgl-scroll-zoom-blocker",this._map._container),this._alertContainer.textContent=/(Mac|iPad)/i.test(navigator.userAgent)?this._map._getUIString("ScrollZoomBlocker.CmdMessage"):this._map._getUIString("ScrollZoomBlocker.CtrlMessage"),this._alertContainer.style.fontSize=`${Math.max(10,Math.min(24,Math.floor(.05*this._el.clientWidth)))}px`)}_showBlockerAlert(){this._alertContainer.style.visibility="visible",this._alertContainer.classList.add("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.setAttribute("role","alert"),clearTimeout(this._alertTimer),this._alertTimer=window.setTimeout(()=>{this._alertContainer.classList.remove("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.removeAttribute("role")},200)}}class gw{constructor(d,g){this._clickZoom=d,this._tapZoom=g}enable(){this._clickZoom.enable(),this._tapZoom.enable()}disable(){this._clickZoom.disable(),this._tapZoom.disable()}isEnabled(){return this._clickZoom.isEnabled()&&this._tapZoom.isEnabled()}isActive(){return this._clickZoom.isActive()||this._tapZoom.isActive()}}class yw{constructor(){this.reset()}reset(){this._active=!1}blur(){this.reset()}dblclick(d,g){return d.preventDefault(),{cameraAnimation:S=>{S.easeTo({duration:300,zoom:S.getZoom()+(d.shiftKey?-1:1),around:S.unproject(g)},{originalEvent:d})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class mP{constructor(){this._tap=new Jd({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,this._swipePoint=void 0,this._swipeTouch=0,this._tapTime=0,this._tap.reset()}touchstart(d,g,S){this._swipePoint||(this._tapTime&&d.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?S.length>0&&(this._swipePoint=g[0],this._swipeTouch=S[0].identifier):this._tap.touchstart(d,g,S))}touchmove(d,g,S){if(this._tapTime){if(this._swipePoint){if(S[0].identifier!==this._swipeTouch)return;const j=g[0],R=j.y-this._swipePoint.y;return this._swipePoint=j,d.preventDefault(),this._active=!0,{zoomDelta:R/128}}}else this._tap.touchmove(d,g,S)}touchend(d,g,S){this._tapTime?this._swipePoint&&S.length===0&&this.reset():this._tap.touchend(d,g,S)&&(this._tapTime=d.timeStamp)}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Wj{constructor(d,g,S){this._el=d,this._mousePan=g,this._touchPan=S}enable(d){this._inertiaOptions=d||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("mapboxgl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("mapboxgl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class pP{constructor(d,g,S){this._pitchWithRotate=d.pitchWithRotate,this._mouseRotate=g,this._mousePitch=S}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()}}class gP{constructor(d,g,S,j){this._el=d,this._touchZoom=g,this._touchRotate=S,this._tapDragZoom=j,this._rotationDisabled=!1,this._enabled=!0}enable(d){this._touchZoom.enable(d),this._rotationDisabled||this._touchRotate.enable(d),this._tapDragZoom.enable(),this._el.classList.add("mapboxgl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("mapboxgl-touch-zoom-rotate")}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable()}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}}const m_=v=>v.zoom||v.drag||v.pitch||v.rotate;class yP extends a.C{}class xP{constructor(){this.constants=[1,1,.01],this.radius=0}setup(d,g){const S=a.ax([],g,d);this.radius=a.ai(S[2]<0?a.eR([],S,this.constants):[S[0],S[1],0])}projectRay(d){a.eR(d,d,this.constants),a.ay(d,d),a.eS(d,d,this.constants);const g=a.bJ([],d,this.radius);if(g[2]>0){const S=a.bJ([],[0,0,1],a.bi(g,[0,0,1])),j=a.bJ([],a.ay([],[g[0],g[1],0]),this.radius),R=a.cT([],g,a.bJ([],a.ax([],a.cT([],j,S),g),2));g[0]=R[0],g[1]=R[1]}return g}}function p_(v){return v.panDelta&&v.panDelta.mag()||v.zoomDelta||v.bearingDelta||v.pitchDelta}class _P{constructor(d,g){this._map=d,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new fP(d),this._bearingSnap=g.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new xP,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(g),a.aZ(["handleEvent","handleWindowEvent"],this);const S=this._el;this._listeners=[[S,"touchstart",{passive:!0}],[S,"touchmove",{passive:!1}],[S,"touchend",void 0],[S,"touchcancel",void 0],[S,"mousedown",void 0],[S,"mousemove",void 0],[S,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[S,"mouseover",void 0],[S,"mouseout",void 0],[S,"dblclick",void 0],[S,"click",void 0],[S,"keydown",{capture:!1}],[S,"keyup",void 0],[S,"wheel",{passive:!1}],[S,"contextmenu",void 0],[window,"blur",void 0]];for(const[j,R,L]of this._listeners){const F=j===document?this.handleWindowEvent:this.handleEvent;j.addEventListener(R,F,L)}}destroy(){for(const[d,g,S]of this._listeners){const j=d===document?this.handleWindowEvent:this.handleEvent;d.removeEventListener(g,j,S)}}_addDefaultHandlers(d){const g=this._map,S=g.getCanvasContainer();this._add("mapEvent",new Dj(g,d));const j=g.boxZoom=new Fj(g,d);this._add("boxZoom",j);const R=new _y,L=new yw;g.doubleClickZoom=new gw(L,R),this._add("tapZoom",R),this._add("clickZoom",L);const F=new mP;this._add("tapDragZoom",F);const z=g.touchPitch=new Vj(g);this._add("touchPitch",z);const W=new hw(d),Z=new d_(d);g.dragRotate=new pP(d,W,Z),this._add("mouseRotate",W,["mousePitch"]),this._add("mousePitch",Z,["mouseRotate"]);const ne=new Mu(d),re=new zj(g,d);g.dragPan=new Wj(S,ne,re),this._add("mousePan",ne),this._add("touchPan",re,["touchZoom","touchRotate"]);const ie=new Ip,ce=new Uj;g.touchZoomRotate=new gP(S,ce,ie,F),this._add("touchRotate",ie,["touchPan","touchZoom"]),this._add("touchZoom",ce,["touchPan","touchRotate"]),this._add("blockableMapEvent",new Oj(g));const le=g.scrollZoom=new pw(g,this);this._add("scrollZoom",le,["mousePan"]);const ve=g.keyboard=new Pp;this._add("keyboard",ve);for(const _e of["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"])d.interactive&&d[_e]&&g[_e].enable(d[_e])}_add(d,g,S){this._handlers.push({handlerName:d,handler:g,allowed:S}),this._handlersById[d]=g}stop(d){if(!this._updatingCamera){for(const{handler:g}of this._handlers)g.reset();this._inertia.clear(),this._fireEvents({},{},d),this._changes=[],this._originalZoom=void 0}}isActive(){for(const{handler:d}of this._handlers)if(d.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!m_(this._eventsInProgress)||this.isZooming()}_isDragging(){return!!this._eventsInProgress.drag}_blockedByActive(d,g,S){for(const j in d)if(j!==S&&(!g||g.indexOf(j)<0))return!0;return!1}handleWindowEvent(d){this.handleEvent(d,`${d.type}Window`)}_getMapTouches(d){const g=[];for(const S of d)this._el.contains(S.target)&&g.push(S);return g}handleEvent(d,g){this._updatingCamera=!0;const S=d.type==="renderFrame",j=S?void 0:d,R={needsRenderFrame:!1},L={},F={},z=d.touches?this._getMapTouches(d.touches):void 0,W=z?J(this._el,z):S?void 0:Q(this._el,d);for(const{handlerName:re,handler:ie,allowed:ce}of this._handlers){if(!ie.isEnabled())continue;let le;this._blockedByActive(F,ce,re)?ie.reset():ie[g||d.type]&&(le=ie[g||d.type](d,W,z),this.mergeHandlerResult(R,L,le,re,j),le&&le.needsRenderFrame&&this._triggerRenderFrame()),(le||ie.isActive())&&(F[re]=ie)}const Z={};for(const re in this._previousActiveHandlers)F[re]||(Z[re]=j);this._previousActiveHandlers=F,(Object.keys(Z).length||p_(R))&&(this._changes.push([R,L,Z]),this._triggerRenderFrame()),(Object.keys(F).length||p_(R))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:ne}=R;ne&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],ne(this._map))}mergeHandlerResult(d,g,S,j,R){if(!S)return;Object.assign(d,S);const L={handlerName:j,originalEvent:S.originalEvent||R};S.zoomDelta!==void 0&&(g.zoom=L),S.panDelta!==void 0&&(g.drag=L),S.pitchDelta!==void 0&&(g.pitch=L),S.bearingDelta!==void 0&&(g.rotate=L)}_applyChanges(){const d={},g={},S={};for(const[j,R,L]of this._changes)j.panDelta&&(d.panDelta=(d.panDelta||new a.P(0,0))._add(j.panDelta)),j.zoomDelta&&(d.zoomDelta=(d.zoomDelta||0)+j.zoomDelta),j.bearingDelta&&(d.bearingDelta=(d.bearingDelta||0)+j.bearingDelta),j.pitchDelta&&(d.pitchDelta=(d.pitchDelta||0)+j.pitchDelta),j.around!==void 0&&(d.around=j.around),j.aroundCoord!==void 0&&(d.aroundCoord=j.aroundCoord),j.pinchAround!==void 0&&(d.pinchAround=j.pinchAround),j.noInertia&&(d.noInertia=j.noInertia),Object.assign(g,R),Object.assign(S,L);this._updateMapTransform(d,g,S),this._changes=[]}_updateMapTransform(d,g,S){const j=this._map,R=j.transform,L=Re=>[Re.x,Re.y,Re.z];if((()=>{const Re=this._eventsInProgress.drag;return Re&&!this._handlersById[Re.handlerName].isActive()})()&&!p_(d)){const Re=R.zoom;R.cameraElevationReference="sea",this._originalZoom!=null&&R._orthographicProjectionAtLowPitch&&R.projection.name!=="globe"&&R.pitch===0?(R.cameraElevationReference="ground",R.zoom=this._originalZoom):(R.recenterOnTerrain(),R.cameraElevationReference="ground"),Re!==R.zoom&&this._map._update(!0)}if(R._isCameraConstrained&&j._stop(!0),!p_(d))return void this._fireEvents(g,S,!0);let{panDelta:F,zoomDelta:z,bearingDelta:W,pitchDelta:Z,around:ne,aroundCoord:re,pinchAround:ie}=d;R._isCameraConstrained&&(z>0&&(z=0),R._isCameraConstrained=!1),ie!==void 0&&(ne=ie),(z||(Re=>g[Re]&&!this._eventsInProgress[Re])("drag"))&&ne&&(this._dragOrigin=L(R.pointCoordinate3D(ne)),this._originalZoom=R.zoom,this._trackingEllipsoid.setup(R._camera.position,this._dragOrigin)),R.cameraElevationReference="sea",j._stop(!0),ne=ne||j.transform.centerPoint,W&&(R.bearing+=W),Z&&(R.pitch+=Z),R._updateCameraState();const ce=[0,0,0];if(F)if(R.projection.name==="mercator"){const Re=this._trackingEllipsoid.projectRay(R.screenPointToMercatorRay(ne).dir),Me=this._trackingEllipsoid.projectRay(R.screenPointToMercatorRay(ne.sub(F)).dir);ce[0]=Me[0]-Re[0],ce[1]=Me[1]-Re[1]}else{const Re=R.pointCoordinate(ne);if(R.projection.name==="globe"){F=F.rotate(-R.angle);const Me=R._pixelsPerMercatorPixel/R.worldSize;ce[0]=-F.x*a.eQ(a.bV(Re.y))*Me,ce[1]=-F.y*a.eQ(R.center.lat)*Me}else{const Me=R.pointCoordinate(ne.sub(F));Re&&Me&&(ce[0]=Me.x-Re.x,ce[1]=Me.y-Re.y)}}const le=R.zoom,ve=[0,0,0];if(z){const Re=L(re||R.pointCoordinate3D(ne)),Me={dir:a.ay([],a.ax([],Re,R._camera.position))};if(Me.dir[2]<0){const Te=R.zoomDeltaToMovement(Re,z);a.bJ(ve,Me.dir,Te)}}const _e=a.cT(ce,ce,ve);R._translateCameraConstrained(_e),z&&Math.abs(R.zoom-le)>1e-4&&R.recenterOnTerrain(),R.cameraElevationReference="ground",this._map._update(),d.noInertia||this._inertia.record(d),this._fireEvents(g,S,!0)}_fireEvents(d,g,S){const j=m_(this._eventsInProgress),R=m_(d),L={};for(const Z in d){const{originalEvent:ne}=d[Z];this._eventsInProgress[Z]||(L[`${Z}start`]=ne),this._eventsInProgress[Z]=d[Z]}!j&&R&&this._fireEvent("movestart",R.originalEvent);for(const Z in L)this._fireEvent(Z,L[Z]);R&&this._fireEvent("move",R.originalEvent);for(const Z in d){const{originalEvent:ne}=d[Z];this._fireEvent(Z,ne)}const F={};let z;for(const Z in this._eventsInProgress){const{handlerName:ne,originalEvent:re}=this._eventsInProgress[Z];this._handlersById[ne].isActive()||(delete this._eventsInProgress[Z],z=g[ne]||re,F[`${Z}end`]=z)}for(const Z in F)this._fireEvent(Z,F[Z]);const W=m_(this._eventsInProgress);if(S&&(j||R)&&!W){this._updatingCamera=!0;const Z=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),ne=re=>re!==0&&-this._bearingSnap{this._frameId=void 0,this.handleEvent(new yP("renderFrame",{timeStamp:d})),this._applyChanges()})}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}const Kj="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class vP extends a.E{constructor(d,g){super(),this._moving=!1,this._zooming=!1,this.transform=d,this._bearingSnap=g.bearingSnap,this._respectPrefersReducedMotion=g.respectPrefersReducedMotion!==!1,a.aZ(["_renderFrameCallback"],this)}getCenter(){return new a.aU(this.transform.center.lng,this.transform.center.lat)}setCenter(d,g){return this.jumpTo({center:d},g)}panBy(d,g,S){return d=a.P.convert(d).mult(-1),this.panTo(this.transform.center,Object.assign({offset:d},g),S)}panTo(d,g,S){return this.easeTo(Object.assign({center:d},g),S)}getZoom(){return this.transform.zoom}setZoom(d,g){return this.jumpTo({zoom:d},g),this}zoomTo(d,g,S){return this.easeTo(Object.assign({zoom:d},g),S)}zoomIn(d,g){return this.zoomTo(this.getZoom()+1,d,g),this}zoomOut(d,g){return this.zoomTo(this.getZoom()-1,d,g),this}getBearing(){return this.transform.bearing}setBearing(d,g){return this.jumpTo({bearing:d},g),this}getPadding(){return this.transform.padding}setPadding(d,g){return this.jumpTo({padding:d},g),this}rotateTo(d,g,S){return this.easeTo(Object.assign({bearing:d},g),S)}resetNorth(d,g){return this.rotateTo(0,Object.assign({duration:1e3},d),g),this}resetNorthPitch(d,g){return this.easeTo(Object.assign({bearing:0,pitch:0,duration:1e3},d),g),this}snapToNorth(d,g){return Math.abs(this.getBearing())d.aspect?S/(2*Math.tan(.5*d.fovX)*d.aspect):j/(2*Math.tan(.5*d.fovY)*d.aspect)}_cameraForBoundsOnGlobe(d,g,S,j,R,L){const F=d.clone(),z=this._extendCameraOptions(L);F.bearing=j,F.pitch=R;const W=a.aU.convert(g),Z=a.aU.convert(S),ne=.5*(W.lat+Z.lat),re=.5*(W.lng+Z.lng),ie=a.eT(ne,re),ce=a.ay([],ie),le=a.ay([],a.bh([],ce,[0,1,0])),ve=a.bh([],le,ce),_e=[le[0],le[1],le[2],0,ve[0],ve[1],ve[2],0,ce[0],ce[1],ce[2],0,0,0,0,1],Re=[ie,a.eT(W.lat,W.lng),a.eT(Z.lat,W.lng),a.eT(Z.lat,Z.lng),a.eT(W.lat,Z.lng),a.eT(ne,W.lng),a.eT(ne,Z.lng),a.eT(W.lat,re),a.eT(Z.lat,re)];let Me=a.cU.fromPoints(Re.map(Et=>[a.bi(le,Et),a.bi(ve,Et),a.bi(ce,Et)]));const Te=a.ah([],Me.center,_e);a.eU(Te)===0&&a.eV(Te,0,0,1),a.ay(Te,Te),a.bJ(Te,Te,a.aF),F.center=a.eW(Te);const Xe=F.getWorldToCameraMatrix(),$e=a.b7(new Float64Array(16),Xe);Me=a.cU.applyTransform(Me,a.aD([],Xe,_e));const Ke=this._extendAABB(Me,F,z,j);if(!Ke)return void a.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");Me=Ke,a.ah(Te,Te,Xe);const De=.5*(Me.max[2]-Me.min[2]),Be=this._minimumAABBFrustumDistance(F,Me),Ge=a.bJ([],[0,0,1],De),ot=a.cT(Ge,Te,Ge),Je=Be+(F.pitch===0?0:a.bf(Te,ot)),St=F.globeCenterInViewSpace,pt=a.ax([],Te,[St[0],St[1],St[2]]);a.ay(pt,pt),a.bJ(pt,pt,Je);const Ot=a.cT([],Te,pt);a.ah(Ot,Ot,$e);const Ut=a.eD/a.aF,ut=a.ai(Ot),st=a.bU(Math.max(ut*Ut-a.eD,Number.EPSILON),0),vt=Math.min(F.zoomFromMercatorZAdjusted(st),z.maxZoom);return vt>.5*(a.cJ+a.cv)?(F.setProjection({name:"mercator"}),F.zoom=vt,this._cameraForBounds(F,g,S,j,R,L)):{center:F.center,zoom:vt,bearing:j,pitch:R}}_extendAABB(d,g,S,j){const R=.5*((S.padding.left||0)+(S.padding.right||0)),L=.5*((S.padding.top||0)+(S.padding.bottom||0)),F=L,z=R,W=R,Z=L,ne=g.width-(z+W),re=g.height-(F+Z),ie=a.ax([],d.max,d.min),ce=Math.min(ne/ie[0],re/ie[1]),le=Math.min(g.scaleZoom(g.scale*ce),S.maxZoom);if(isNaN(le))return null;const ve=g.scale/g.zoomScale(le),_e=new a.cU([d.min[0]-z*ve,d.min[1]-Z*ve,d.min[2]],[d.max[0]+W*ve,d.max[1]+F*ve,d.max[2]]),Re=(typeof S.offset.x=="number"&&typeof S.offset.y=="number"?new a.P(S.offset.x,S.offset.y):a.P.convert(S.offset)).rotate(-a.ap(j));return _e.center[0]-=Re.x*ve,_e.center[1]+=Re.y*ve,_e}queryTerrainElevation(d,g){const S=this.transform.elevation;return S?(g=Object.assign({},{exaggerated:!0},g),S.getAtPoint(a.ag.fromLngLat(d),null,g.exaggerated)):null}_cameraForBounds(d,g,S,j,R,L){if(d.projection.name==="globe")return this._cameraForBoundsOnGlobe(d,g,S,j,R,L);const F=d.clone(),z=this._extendCameraOptions(L);F.bearing=j,F.pitch=R;const W=a.aU.convert(g),Z=a.aU.convert(S),ne=new a.aU(W.lng,Z.lat),re=new a.aU(Z.lng,W.lat),ie=F.project(W),ce=F.project(Z),le=this.queryTerrainElevation(W),ve=this.queryTerrainElevation(Z),_e=this.queryTerrainElevation(ne),Re=this.queryTerrainElevation(re),Me=[[ie.x,ie.y,Math.min(le||0,ve||0,_e||0,Re||0)],[ce.x,ce.y,Math.max(le||0,ve||0,_e||0,Re||0)]];let Te=a.cU.fromPoints(Me);const Xe=F.getWorldToCameraMatrix(),$e=a.b7(new Float64Array(16),Xe);Te=a.cU.applyTransform(Te,Xe);const Ke=this._extendAABB(Te,F,z,j);if(!Ke)return void a.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");Te=Ke;const De=.5*a.ax([],Te.max,Te.min)[2],Be=this._minimumAABBFrustumDistance(F,Te),Ge=[0,0,1,0];a.aE(Ge,Ge,Xe),a.eX(Ge,Ge);const ot=a.bJ([],Ge,Be+De),Je=a.cT([],Te.center,ot);a.ah(Te.center,Te.center,$e),a.ah(Je,Je,$e);const St=F.unproject(new a.P(Te.center[0],Te.center[1])),pt=a.eY(F.projection,St),Ot=Math.pow(2,pt),Ut=Math.min(F._zoomFromMercatorZ(Je[2]*F.pixelsPerMeter*Ot/F.worldSize),z.maxZoom);return F.mercatorFromTransition&&Ut<.5*(a.cJ+a.cv)?(F.setProjection({name:"globe"}),F.zoom=Ut,this._cameraForBounds(F,g,S,j,R,L)):{center:St,zoom:Ut,bearing:j,pitch:R}}fitBounds(d,g,S){const j=this.cameraForBounds(d,g);return this._fitInternal(j,g,S)}fitScreenCoordinates(d,g,S,j,R){const L=a.P.convert(d),F=a.P.convert(g),z=new a.P(Math.min(L.x,F.x),Math.min(L.y,F.y)),W=new a.P(Math.max(L.x,F.x),Math.max(L.y,F.y));if(this.transform.projection.name==="mercator"&&this.transform.anyCornerOffEdge(L,F))return this;const Z=this.transform.pointLocation3D(z),ne=this.transform.pointLocation3D(W),re=this.transform.pointLocation3D(new a.P(z.x,W.y)),ie=this.transform.pointLocation3D(new a.P(W.x,z.y)),ce=[Math.min(Z.lng,ne.lng,re.lng,ie.lng),Math.min(Z.lat,ne.lat,re.lat,ie.lat)],le=[Math.max(Z.lng,ne.lng,re.lng,ie.lng),Math.max(Z.lat,ne.lat,re.lat,ie.lat)],ve=j&&j.pitch?j.pitch:this.getPitch(),_e=this._cameraForBounds(this.transform,ce,le,S,ve,j);return this._fitInternal(_e,j,R)}_fitInternal(d,g,S){return d?(g=Object.assign(d,g)).linear?this.easeTo(g,S):this.flyTo(g,S):this}jumpTo(d,g){this.stop();const S=d.preloadOnly?this.transform.clone():this.transform;let j=!1,R=!1,L=!1;"zoom"in d&&S.zoom!==+d.zoom&&(j=!0,S.zoom=+d.zoom),d.center!==void 0&&(S.center=a.aU.convert(d.center)),"bearing"in d&&S.bearing!==+d.bearing&&(R=!0,S.bearing=+d.bearing),"pitch"in d&&S.pitch!==+d.pitch&&(L=!0,S.pitch=+d.pitch);const F=typeof d.padding=="number"?this._extendPadding(d.padding):d.padding;if(d.padding!=null&&!S.isPaddingEqual(F))if(d.retainPadding===!1){const z=S.clone();z.padding=F,S.setLocationAtPoint(S.center,z.centerPoint)}else S.padding=F;return d.preloadOnly?(this._preloadTiles(S),this):(this.fire(new a.C("movestart",g)).fire(new a.C("move",g)),j&&this.fire(new a.C("zoomstart",g)).fire(new a.C("zoom",g)).fire(new a.C("zoomend",g)),R&&this.fire(new a.C("rotatestart",g)).fire(new a.C("rotate",g)).fire(new a.C("rotateend",g)),L&&this.fire(new a.C("pitchstart",g)).fire(new a.C("pitch",g)).fire(new a.C("pitchend",g)),this.fire(new a.C("moveend",g)))}getFreeCameraOptions(){return this.transform.projection.supportsFreeCamera||a.w(Kj),this.transform.getFreeCameraOptions()}setFreeCameraOptions(d,g){const S=this.transform;if(!S.projection.supportsFreeCamera)return a.w(Kj),this;this.stop();const j=S.zoom,R=S.pitch,L=S.bearing;S.setFreeCameraOptions(d);const F=j!==S.zoom,z=R!==S.pitch,W=L!==S.bearing;return this.fire(new a.C("movestart",g)).fire(new a.C("move",g)),F&&this.fire(new a.C("zoomstart",g)).fire(new a.C("zoom",g)).fire(new a.C("zoomend",g)),W&&this.fire(new a.C("rotatestart",g)).fire(new a.C("rotate",g)).fire(new a.C("rotateend",g)),z&&this.fire(new a.C("pitchstart",g)).fire(new a.C("pitch",g)).fire(new a.C("pitchend",g)),this.fire(new a.C("moveend",g)),this}easeTo(d,g){this._stop(!1,d.easeId),((d=Object.assign({offset:[0,0],duration:500,easing:a.eP},d)).animate===!1||this._prefersReducedMotion(d))&&(d.duration=0);const S=this.transform,j=this.getZoom(),R=this.getBearing(),L=this.getPitch(),F=this.getPadding(),z="zoom"in d?+d.zoom:j,W="bearing"in d?this._normalizeBearing(d.bearing,R):R,Z="pitch"in d?+d.pitch:L,ne=this._extendPadding(d.padding),re=a.P.convert(d.offset);let ie,ce,le;if(S.projection.name==="globe"){const Ge=a.ag.fromLngLat(S.center),ot=re.rotate(-S.angle);Ge.x+=ot.x/S.worldSize,Ge.y+=ot.y/S.worldSize;const Je=Ge.toLngLat(),St=a.aU.convert(d.center||Je);this._normalizeCenter(St),ie=S.centerPoint.add(ot),ce=new a.P(Ge.x,Ge.y).mult(S.worldSize),le=new a.P(a.aH(St.lng),a.aL(St.lat)).mult(S.worldSize).sub(ce)}else{ie=S.centerPoint.add(re);const Ge=S.pointLocation(ie),ot=a.aU.convert(d.center||Ge);this._normalizeCenter(ot),ce=S.project(Ge),le=S.project(ot).sub(ce)}const ve=S.zoomScale(z-j);let _e,Re;d.around&&(_e=a.aU.convert(d.around),Re=S.locationPoint(_e));const Me=this._zooming||z!==j,Te=this._rotating||R!==W,Xe=this._pitching||Z!==L,$e=!S.isPaddingEqual(ne),Ke=d.retainPadding===!1?S.clone():S,De=Ge=>ot=>{if(Me&&(Ge.zoom=a.am(j,z,ot)),Te&&(Ge.bearing=a.am(R,W,ot)),Xe&&(Ge.pitch=a.am(L,Z,ot)),$e&&(Ke.interpolatePadding(F,ne,ot),ie=Ke.centerPoint.add(re)),_e)Ge.setLocationAtPoint(_e,Re);else{const Je=Ge.zoomScale(Ge.zoom-j),St=z>j?Math.min(2,ve):Math.max(.5,ve),pt=Math.pow(St,1-ot),Ot=Ge.unproject(ce.add(le.mult(ot*pt)).mult(Je));Ge.setLocationAtPoint(Ge.renderWorldCopies?Ot.wrap():Ot,ie)}return d.preloadOnly||this._fireMoveEvents(g),Ge};if(d.preloadOnly){const Ge=this._emulate(De,d.duration,S);return this._preloadTiles(Ge),this}const Be={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=Me,this._rotating=Te,this._pitching=Xe,this._padding=$e,this._easeId=d.easeId,this._prepareEase(g,d.noMoveStart,Be),this._ease(De(S),Ge=>{S.cameraElevationReference==="sea"&&S.recenterOnTerrain(),this._afterEase(g,Ge)},d),this}_prepareEase(d,g,S={}){this._moving=!0,this.transform.cameraElevationReference="sea",this.transform._orthographicProjectionAtLowPitch&&this.transform.pitch===0&&this.transform.projection.name!=="globe"&&(this.transform.cameraElevationReference="ground"),g||S.moving||this.fire(new a.C("movestart",d)),this._zooming&&!S.zooming&&this.fire(new a.C("zoomstart",d)),this._rotating&&!S.rotating&&this.fire(new a.C("rotatestart",d)),this._pitching&&!S.pitching&&this.fire(new a.C("pitchstart",d))}_fireMoveEvents(d){this.fire(new a.C("move",d)),this._zooming&&this.fire(new a.C("zoom",d)),this._rotating&&this.fire(new a.C("rotate",d)),this._pitching&&this.fire(new a.C("pitch",d))}_afterEase(d,g){if(this._easeId&&g&&this._easeId===g)return;this._easeId=void 0,this.transform.cameraElevationReference="ground";const S=this._zooming,j=this._rotating,R=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,S&&this.fire(new a.C("zoomend",d)),j&&this.fire(new a.C("rotateend",d)),R&&this.fire(new a.C("pitchend",d)),this.fire(new a.C("moveend",d))}flyTo(d,g){if(this._prefersReducedMotion(d)){const Et=a.aJ(d,["center","zoom","bearing","pitch","around","padding","retainPadding"]);return this.jumpTo(Et,g)}this.stop(),d=Object.assign({offset:[0,0],speed:1.2,curve:1.42,easing:a.eP},d);const S=this.transform,j=this.getZoom(),R=this.getBearing(),L=this.getPitch(),F=this.getPadding(),z="zoom"in d?a.aC(+d.zoom,S.minZoom,S.maxZoom):j,W="bearing"in d?this._normalizeBearing(d.bearing,R):R,Z="pitch"in d?+d.pitch:L,ne=this._extendPadding(d.padding),re=S.zoomScale(z-j),ie=a.P.convert(d.offset);let ce=S.centerPoint.add(ie);const le=S.pointLocation(ce),ve=a.aU.convert(d.center||le);this._normalizeCenter(ve);const _e=S.project(le),Re=S.project(ve).sub(_e);let Me=d.curve;const Te=Math.max(S.width,S.height),Xe=Te/re,$e=Re.mag();if("minZoom"in d){const Et=a.aC(Math.min(d.minZoom,j,z),S.minZoom,S.maxZoom),Nt=Te/S.zoomScale(Et-j);Me=Math.sqrt(Nt/$e*2)}const Ke=Me*Me;function De(Et){const Nt=(Xe*Xe-Te*Te+(Et?-1:1)*Ke*Ke*$e*$e)/(2*(Et?Xe:Te)*Ke*$e);return Math.log(Math.sqrt(Nt*Nt+1)-Nt)}function Be(Et){return(Math.exp(Et)-Math.exp(-Et))/2}function Ge(Et){return(Math.exp(Et)+Math.exp(-Et))/2}const ot=De(0);let Je=function(Et){return Ge(ot)/Ge(ot+Me*Et)},St=function(Et){return Te*((Ge(ot)*(Be(Nt=ot+Me*Et)/Ge(Nt))-Be(ot))/Ke)/$e;var Nt},pt=(De(1)-ot)/Me;if(Math.abs($e)<1e-6||!isFinite(pt)){if(Math.abs(Te-Xe)<1e-6)return this.easeTo(d,g);const Et=Xed.maxDuration&&(d.duration=0);const Ot=R!==W,Ut=Z!==L,ut=!S.isPaddingEqual(ne),st=d.retainPadding===!1?S.clone():S,vt=Et=>Nt=>{const lr=Nt*pt,Jt=1/Je(lr);Et.zoom=Nt===1?z:j+Et.scaleZoom(Jt),Ot&&(Et.bearing=a.am(R,W,Nt)),Ut&&(Et.pitch=a.am(L,Z,Nt)),ut&&(st.interpolatePadding(F,ne,Nt),ce=st.centerPoint.add(ie));const er=Nt===1?ve:Et.unproject(_e.add(Re.mult(St(lr))).mult(Jt));return Et.setLocationAtPoint(Et.renderWorldCopies?er.wrap():er,ce),Et._updateCameraOnTerrain(),d.preloadOnly||this._fireMoveEvents(g),Et};if(d.preloadOnly){const Et=this._emulate(vt,d.duration,S);return this._preloadTiles(Et),this}return this._zooming=!0,this._rotating=Ot,this._pitching=Ut,this._padding=ut,this._prepareEase(g,!1),this._ease(vt(S),()=>this._afterEase(g),d),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_requestRenderFrame(d){}_cancelRenderFrame(d){}_stop(d,g){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),this._easeFrameId=void 0,this._onEaseFrame=void 0),this._onEaseEnd){const S=this._onEaseEnd;this._onEaseEnd=void 0,S.call(this,g)}if(!d){const S=this.handlers;S&&S.stop(!1)}return this}_ease(d,g,S){S.animate===!1||S.duration===0?(d(1),g()):(this._easeStart=a.o.now(),this._easeOptions=S,this._onEaseFrame=d,this._onEaseEnd=g,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){const d=Math.min((a.o.now()-this._easeStart)/this._easeOptions.duration,1),g=this._onEaseFrame;g&&g(this._easeOptions.easing(d)),d<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()}_normalizeBearing(d,g){d=a.bs(d,-180,180);const S=Math.abs(d-g);return Math.abs(d-360-g)180?-360:S<-180?360:0}_prefersReducedMotion(d){return this._respectPrefersReducedMotion&&a.o.prefersReducedMotion&&!(d&&d.essential)}_emulate(d,g,S){const j=Math.ceil(15*g/1e3),R=[],L=d(S.clone());for(let F=0;F<=j;F++){const z=L(F/j);R.push(z.clone())}return R}_preloadTiles(d,g){}}class Yj{constructor(d={}){this.options=d,a.aZ(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact"],this)}getDefaultPosition(){return"bottom-right"}onAdd(d){const g=this.options&&this.options.compact,S=d._getUIString("AttributionControl.ToggleAttribution");this._map=d,this._container=C("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=C("button","mapboxgl-ctrl-attrib-button",this._container),this._compactButton.type="button",this._compactButton.addEventListener("click",this._toggleAttribution),this._compactButton.setAttribute("aria-label",S);const j=C("span","mapboxgl-ctrl-icon",this._compactButton);return j.setAttribute("aria-hidden","true"),j.setAttribute("title",S),this._innerContainer=C("div","mapboxgl-ctrl-attrib-inner",this._container),g&&this._container.classList.add("mapboxgl-compact"),this._updateAttributions(),this._updateEditLink(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("moveend",this._updateEditLink),g===void 0&&(this._map.on("resize",this._updateCompact),this._updateCompact()),this._container}onRemove(){this._container.remove(),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("moveend",this._updateEditLink),this._map.off("resize",this._updateCompact),this._map=void 0,this._attribHTML=void 0}_toggleAttribution(){this._container.classList.contains("mapboxgl-compact-show")?(this._container.classList.remove("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","false")):(this._container.classList.add("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","true"))}_updateEditLink(){let d=this._editLink;d||(d=this._editLink=this._container.querySelector(".mapbox-improve-map"));const g=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:this._map._requestManager._customAccessToken||a.g.ACCESS_TOKEN}];if(d){const S=g.reduce((j,R,L)=>(R.value&&(j+=`${R.key}=${R.value}${Lj.length-R.length),d=d.filter((j,R)=>{for(let L=R+1;L=0)return!1;return!0}),this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?d=[...this.options.customAttribution,...d]:d.unshift(this.options.customAttribution));const S=d.map(j=>function(R){const L=new DOMParser().parseFromString(R,"text/html");return Array.from(L.body.querySelectorAll("*")).reverse().forEach(F=>{const z=F.textContent||"";if(F.tagName!=="A")return void F.replaceWith(...F.childNodes);const W=F.getAttribute("href");if(!W||!/^(https?:|mailto:)/i.test(W))return void F.replaceWith(L.createTextNode(z));const Z=L.createElement("a");Z.href=W,Z.textContent=z,Z.rel="noopener nofollow";const ne=F.getAttribute("class");ne&&(Z.className=ne),F.replaceWith(Z)}),L.body.innerHTML}(j)).join(" | ");S!==this._attribHTML&&(this._attribHTML=S,d.length?(this._innerContainer.innerHTML=S,this._container.classList.remove("mapboxgl-attrib-empty")):this._container.classList.add("mapboxgl-attrib-empty"),this._editLink=null)}_updateCompact(){this._map.getCanvasContainer().offsetWidth<=640?this._container.classList.add("mapboxgl-compact"):this._container.classList.remove("mapboxgl-compact","mapboxgl-compact-show")}}class Zj{constructor(){a.aZ(["_updateLogo","_updateCompact"],this)}onAdd(d){this._map=d,this._container=C("div","mapboxgl-ctrl");const g=C("a","mapboxgl-ctrl-logo");return g.target="_blank",g.rel="noopener nofollow",g.href="https://www.mapbox.com/",g.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),g.setAttribute("rel","noopener nofollow"),this._container.appendChild(g),this._container.style.display="none",this._map.on("sourcedata",this._updateLogo),this._updateLogo(),this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){this._container.remove(),this._map.off("sourcedata",this._updateLogo),this._map.off("resize",this._updateCompact)}getDefaultPosition(){return"bottom-left"}_updateLogo(d){d&&d.sourceDataType!=="metadata"||(this._container.style.display=this._logoRequired()?"block":"none")}_logoRequired(){if(!this._map.style)return!0;const d=this._map.style._sourceCaches;if(Object.entries(d).length===0)return!0;for(const g in d){const S=d[g].getSource();if(S.hasOwnProperty("mapbox_logo")&&!S.mapbox_logo)return!1}return!0}_updateCompact(){const d=this._container.children;if(d.length){const g=d[0];this._map.getCanvasContainer().offsetWidth<250?g.classList.add("mapboxgl-compact"):g.classList.remove("mapboxgl-compact")}}}class bP{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(d){const g=++this._id;return this._queue.push({callback:d,id:g,cancelled:!1}),g}remove(d){const g=this._currentlyRunning,S=g?this._queue.concat(g):this._queue;for(const j of S)if(j.id===d)return void(j.cancelled=!0)}run(d=0){const g=this._currentlyRunning=this._queue;this._queue=[];for(const S of g)if(!S.cancelled&&(S.callback(d),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}class pB{constructor(d){this.jumpTo(d)}getValue(d){if(d<=this._startTime)return this._start;if(d>=this._endTime)return this._end;const g=a.dn((d-this._startTime)/(this._endTime-this._startTime));return this._start*(1-g)+this._end*g}isEasing(d){return d>=this._startTime&&d<=this._endTime}jumpTo(d){this._startTime=-1/0,this._endTime=-1/0,this._start=d,this._end=d}easeTo(d,g,S){this._start=this.getValue(g),this._end=d,this._startTime=g,this._endTime=g+S}}const gB={"AttributionControl.ToggleAttribution":"Toggle attribution","FullscreenControl.Enter":"Enter fullscreen","FullscreenControl.Exit":"Exit fullscreen","GeolocateControl.FindMyLocation":"Find my location","GeolocateControl.LocationNotAvailable":"Location not available","LogoControl.Title":"Mapbox homepage","Map.Title":"Map","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","ScrollZoomBlocker.CtrlMessage":"Use ctrl + scroll to zoom the map","ScrollZoomBlocker.CmdMessage":"Use ⌘ + scroll to zoom the map","TouchPanBlocker.Message":"Use two fingers to move the map"};class Os extends a.C{constructor(d,g,S,j){const{point:R,lngLat:L,originalEvent:F,target:z}=d;super(d.type,{point:R,lngLat:L,originalEvent:F,target:z}),this.preventDefault=()=>{d.preventDefault()},this.id=g,this.interaction=S,this.feature=j}}class xw{constructor(d){this.map=d,this.interactionsByType=new Map,this.delegatedInteractions=new Map,this.typeById=new Map,this.filters=new Map,this.handleType=this.handleType.bind(this),this.handleMove=this.handleMove.bind(this),this.handleOut=this.handleOut.bind(this),this.hoveredFeatures=new Map,this.prevHoveredFeatures=new Map}add(d,g){if(this.typeById.has(d))throw new Error(`Interaction id "${d}" already exists.`);const S=g.filter;let j=g.type;S&&this.filters.set(d,a.dg(S)),j==="mouseover"&&(j="mouseenter"),j==="mouseout"&&(j="mouseleave");const R=this.interactionsByType.get(j)||new Map;j==="mouseenter"||j==="mouseleave"?(this.delegatedInteractions.size===0&&(this.map.on("mousemove",this.handleMove),this.map.on("mouseout",this.handleOut)),this.delegatedInteractions.set(d,g)):R.size===0&&this.map.on(j,this.handleType),R.size===0&&this.interactionsByType.set(j,R),R.set(d,g),this.typeById.set(d,j)}get(d){const g=this.typeById.get(d);if(!g)return;const S=this.interactionsByType.get(g);return S?S.get(d):void 0}remove(d){const g=this.typeById.get(d);if(!g)return;this.typeById.delete(d),this.filters.delete(d);const S=this.interactionsByType.get(g);S&&(S.delete(d),g==="mouseenter"||g==="mouseleave"?(this.delegatedInteractions.delete(d),this.delegatedInteractions.size===0&&(this.map.off("mousemove",this.handleMove),this.map.off("mouseout",this.handleOut))):S.size===0&&this.map.off(g,this.handleType))}queryTargets(d,g){const S=[];for(const[j,R]of g)R.target&&S.push({targetId:j,target:R.target,filter:this.filters.get(j)});return this.map.style.queryRenderedTargets(d,S,this.map.transform)}handleMove(d){this.prevHoveredFeatures=this.hoveredFeatures,this.hoveredFeatures=new Map;const g=this.queryTargets(d.point,Array.from(this.delegatedInteractions).reverse());g.length&&(d.type="mouseenter",this.handleType(d,g));const S=new Map;for(const[j,{feature:R}]of this.prevHoveredFeatures)this.hoveredFeatures.has(j)||S.set(R.id,R);S.size&&(d.type="mouseleave",this.handleType(d,Array.from(S.values())))}handleOut(d){const g=Array.from(this.hoveredFeatures.values()).map(({feature:S})=>S);g.length&&(d.type="mouseleave",this.handleType(d,g)),this.hoveredFeatures.clear()}handleType(d,g){const S=d.type==="mouseenter";if(S&&!this.interactionsByType.has(d.type))return void a.w("mouseenter interaction required for mouseleave to work.");const j=Array.from(this.interactionsByType.get(d.type)).reverse(),R=!!g;g=g||this.queryTargets(d.point,j);let L=!1;const F=new Set;for(const z of g){for(const[W,Z]of j){if(!Z.target)continue;const ne=z.variants?z.variants[W]:null;if(ne){for(const re of ne){if(Wd(re,z,F,W))continue;const ie=new a.di(z,re),ce=CE(re,z,W);R&&ie.id!==void 0&&(ie.state=this.map.getFeatureState(ie));const le=S?this.prevHoveredFeatures.get(ce):null,ve=new Os(d,W,Z,ie),_e=le?le.stop:Z.handler(ve);if(S&&this.hoveredFeatures.set(ce,{feature:z,stop:_e}),_e!==!1){L=!0;break}}if(L)break}}if(L)break}if(!L)for(const[z,W]of j){const{handler:Z,target:ne}=W;if(!ne&&Z(new Os(d,z,W,null))!==!1)break}}}function yB(v,d){if(Array.isArray(v)&&Array.isArray(d)){const g=new Set(v),S=new Set(d);return g.size===S.size&&v.every(j=>S.has(j))}return a.b6(v,d)}const xB={center:[0,0],zoom:0,bearing:0,pitch:0,minZoom:-2,maxZoom:22,minPitch:0,maxPitch:85,interactive:!0,scrollZoom:!0,boxZoom:!0,dragRotate:!0,dragPan:!0,keyboard:!0,doubleClickZoom:!0,touchZoomRotate:!0,touchPitch:!0,cooperativeGestures:!1,performanceMetricsCollection:!0,bearingSnap:7,clickTolerance:3,pitchWithRotate:!0,hash:!1,attributionControl:!0,antialias:!1,failIfMajorPerformanceCaveat:!1,preserveDrawingBuffer:!1,trackResize:!0,renderWorldCopies:!0,refreshExpiredTiles:!0,minTileCacheSize:null,maxTileCacheSize:null,localIdeographFontFamily:"sans-serif",localFontFamily:null,useServerFontComposition:!0,transformRequest:null,accessToken:null,fadeDuration:300,respectPrefersReducedMotion:!0,crossSourceCollisions:!0,collectResourceTiming:!1,testMode:!1,precompilePrograms:!0,scaleFactor:1},_B={showCompass:!0,showZoom:!0,visualizePitch:!1};class g_{constructor(d,g,S=!1){this._clickTolerance=10,this.element=g,this.mouseRotate=new hw({clickTolerance:d.dragRotate._mouseRotate._clickTolerance}),this.map=d,S&&(this.mousePitch=new d_({clickTolerance:d.dragRotate._mousePitch._clickTolerance})),a.aZ(["mousedown","mousemove","mouseup","touchstart","touchmove","touchend","reset"],this),g.addEventListener("mousedown",this.mousedown),g.addEventListener("touchstart",this.touchstart,{passive:!1}),g.addEventListener("touchmove",this.touchmove),g.addEventListener("touchend",this.touchend),g.addEventListener("touchcancel",this.reset)}down(d,g){this.mouseRotate.mousedown(d,g),this.mousePitch&&this.mousePitch.mousedown(d,g),U()}move(d,g){const S=this.map,j=this.mouseRotate.mousemoveWindow(d,g),R=j&&j.bearingDelta;if(R&&S.setBearing(S.getBearing()+R),this.mousePitch){const L=this.mousePitch.mousemoveWindow(d,g),F=L&&L.pitchDelta;F&&S.setPitch(S.getPitch()+F)}}off(){const d=this.element;d.removeEventListener("mousedown",this.mousedown),d.removeEventListener("touchstart",this.touchstart),d.removeEventListener("touchmove",this.touchmove),d.removeEventListener("touchend",this.touchend),d.removeEventListener("touchcancel",this.reset),this.offTemp()}offTemp(){q(),window.removeEventListener("mousemove",this.mousemove),window.removeEventListener("mouseup",this.mouseup)}mousedown(d){this.down(Object.assign({},d,{button:d.button,type:d.type,ctrlKey:!0,preventDefault:()=>d.preventDefault()}),Q(this.element,d)),window.addEventListener("mousemove",this.mousemove),window.addEventListener("mouseup",this.mouseup)}mousemove(d){this.move(d,Q(this.element,d))}mouseup(d){this.mouseRotate.mouseupWindow(d),this.mousePitch&&this.mousePitch.mouseupWindow(d),this.offTemp()}touchstart(d){d.targetTouches.length!==1?this.reset():(this._startPos=this._lastPos=J(this.element,d.targetTouches)[0],this.down({type:"mousedown",button:0,ctrlKey:!0,preventDefault:()=>d.preventDefault()},this._startPos))}touchmove(d){d.targetTouches.length!==1?this.reset():(this._lastPos=J(this.element,d.targetTouches)[0],this.move({buttons:1,preventDefault:()=>d.preventDefault()},this._lastPos))}touchend(d){d.targetTouches.length===0&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)g.width||d.y>g.height;g.locationPoint3D(S).distSqr(d)180;){const S=g.locationPoint3D(v);if(S.x>=0&&S.y>=0&&S.x<=g.width&&S.y<=g.height)break;v.lng>g.center.lng?v.lng-=360:v.lng+=360}return v}const y_={center:"translate(-50%,-50%)",top:"translate(-50%,0)","top-left":"translate(0,0)","top-right":"translate(-100%,0)",bottom:"translate(-50%,-100%)","bottom-left":"translate(0,-100%)","bottom-right":"translate(-100%,-100%)",left:"translate(0,-50%)",right:"translate(-100%,-50%)"},Kc={rotation:0,rotationAlignment:"auto",pitchAlignment:"auto",occludedOpacity:.2,altitude:0};class Du extends a.E{constructor(d,g){super(),(d instanceof HTMLElement||g)&&(d=Object.assign({element:d},g)),a.aZ(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress","_clearFadeTimer"],this);const{anchor:S="center",color:j="#3FB1CE",scale:R=1,draggable:L=!1,clickTolerance:F=0,rotation:z=Kc.rotation,rotationAlignment:W=Kc.rotationAlignment,pitchAlignment:Z=Kc.pitchAlignment,occludedOpacity:ne=Kc.occludedOpacity,altitude:re=Kc.altitude}=d||{};this._anchor=S,this._color=j,this._scale=R,this._draggable=L,this._clickTolerance=F,this._rotation=z,this._rotationAlignment=W,this._pitchAlignment=Z,this._occludedOpacity=ne,this._altitude=re,this._state="inactive",this._isDragging=!1,this._updateMoving=()=>this._update(!0),d&&d.element?(this._element=d.element,this._offset=a.P.convert(d&&d.offset||[0,0])):(this._defaultMarker=!0,this._element=this._createDefaultMarker(),this._offset=a.P.convert(d&&d.offset||[0,-14])),this._element.hasAttribute("aria-label")||this._element.setAttribute("aria-label","Map marker"),this._element.hasAttribute("role")||this._element.setAttribute("role","img"),this._element.classList.add("mapboxgl-marker"),this._element.addEventListener("dragstart",le=>{le.preventDefault()}),this._element.addEventListener("mousedown",le=>{le.preventDefault()});const ie=this._element.classList;for(const le in y_)ie.remove(`mapboxgl-marker-anchor-${le}`);ie.add(`mapboxgl-marker-anchor-${this._anchor}`);const ce=d&&d.className?d.className.trim().split(/\s+/):[];ie.add(...ce),this._popup=null}_createDefaultMarker(){const d=C("div"),g=I("svg",{display:"block",height:41*this._scale+"px",width:27*this._scale+"px",viewBox:"0 0 27 41"},d);if(this._altitude===0){const S=I("radialGradient",{id:"shadowGradient"},I("defs",{},g));I("stop",{offset:"10%","stop-opacity":.4},S),I("stop",{offset:"100%","stop-opacity":.05},S),I("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},g)}return I("path",{fill:this._color,d:"M27,13.5C27,19.07 20.25,27 14.75,34.5C14.02,35.5 12.98,35.5 12.25,34.5C6.75,27 0,19.22 0,13.5C0,6.04 6.04,0 13.5,0C20.96,0 27,6.04 27,13.5Z"},g),I("path",{opacity:.25,d:"M13.5,0C6.04,0 0,6.04 0,13.5C0,19.22 6.75,27 12.25,34.5C13,35.52 14.02,35.5 14.75,34.5C20.25,27 27,19.07 27,13.5C27,6.04 20.96,0 13.5,0ZM13.5,1C20.42,1 26,6.58 26,13.5C26,15.9 24.5,19.18 22.22,22.74C19.95,26.3 16.71,30.14 13.94,33.91C13.74,34.18 13.61,34.32 13.5,34.44C13.39,34.32 13.26,34.18 13.06,33.91C10.28,30.13 7.41,26.31 5.02,22.77C2.62,19.23 1,15.95 1,13.5C1,6.58 6.58,1 13.5,1Z"},g),I("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},g),d}addTo(d){return d===this._map||(this.remove(),this._map=d,d.getCanvasContainer().appendChild(this._element),d.on("move",this._updateMoving),d.on("moveend",this._update),d.on("remove",this._clearFadeTimer),d._addMarker(this),this.setDraggable(this._draggable),this._update(),d.on("click",this._onMapClick)),this}remove(){const d=this._map;return d&&(d.off("click",this._onMapClick),d.off("move",this._updateMoving),d.off("moveend",this._update),d.off("mousedown",this._addDragHandler),d.off("touchstart",this._addDragHandler),d.off("mouseup",this._onUp),d.off("touchend",this._onUp),d.off("mousemove",this._onMove),d.off("touchmove",this._onMove),d.off("remove",this._clearFadeTimer),d._removeMarker(this),this._map=void 0),this._clearFadeTimer(),this._element.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(d){return this._lngLat=a.aU.convert(d),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(!0),this}setAltitude(d){return d===this._altitude||(this._defaultMarker&&(this._altitude===0&&d!==0||this._altitude!==0&&d===0)&&(this._element=this._createDefaultMarker()),this._altitude=d||Kc.altitude,this._update()),this}getAltitude(){return this._altitude}getElement(){return this._element}setPopup(d){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeAttribute("role"),this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),d){if(!("offset"in d.options)){const j=Math.sqrt(Math.pow(13.5,2)/2);d.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[j,-1*(38.1-13.5+j)],"bottom-right":[-j,-1*(38.1-13.5+j)],left:[13.5,-1*(38.1-13.5)],right:[-13.5,-1*(38.1-13.5)]}:this._offset}this._popup=d,d._marker=this,d._altitude=this._altitude,this._lngLat&&this._popup.setLngLat(this._lngLat),this._element.setAttribute("role","button"),this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress),this._element.setAttribute("aria-expanded","false")}return this}_onKeyPress(d){const g=d.code,S=d.charCode||d.keyCode;g!=="Space"&&g!=="Enter"&&S!==32&&S!==13||this.togglePopup()}_onMapClick(d){const g=d.originalEvent.target,S=this._element;this._popup&&(g===S||S.contains(g))&&this.togglePopup()}getPopup(){return this._popup}togglePopup(){const d=this._popup;return d?(d.isOpen()?(d.remove(),this._element.setAttribute("aria-expanded","false")):this._map&&(d.addTo(this._map),this._element.setAttribute("aria-expanded","true")),this):this}_behindTerrain(){const d=this._map,g=this._pos;if(!d||!g)return!1;const S=d.unproject(g,this._altitude),j=d.getFreeCameraOptions();if(!j.position)return!1;const R=j.position.toLngLat();return R.distanceTo(S)<.9*R.distanceTo(this._lngLat)}_evaluateOpacity(){const d=this._map;if(!d)return;const g=this._pos;if(!g||g.x<0||g.x>d.transform.width||g.y<0||g.y>d.transform.height)return void this._clearFadeTimer();const S=d.unproject(g,this._altitude);let j;d._showingGlobe()&&a.e$(d.transform,this._lngLat)?j=0:(j=1-d._queryFogOpacity(S),d.transform._terrainEnabled()&&d.getTerrain()&&this._behindTerrain()&&(j*=this._occludedOpacity)),this._element.style.opacity=`${j}`,this._element.style.pointerEvents=j>0?"auto":"none",this._popup&&this._popup._setOpacity(j),this._fadeTimer=null}_clearFadeTimer(){this._fadeTimer&&(clearTimeout(this._fadeTimer),this._fadeTimer=null)}_updateDOM(){const d=this._pos;if(!d||!this._map)return;const g=this._offset.mult(this._scale);this._element.style.transform=` translate(${d.x}px,${d.y}px) ${y_[this._anchor]} ${this._calculateXYTransform()} ${this._calculateZTransform()} translate(${g.x}px,${g.y}px) `}_calculateXYTransform(){const d=this._pos,g=this._map,S=this.getPitchAlignment();if(!g||!d||S!=="map")return"";if(!g._showingGlobe()){const z=g.getPitch();return z?`rotateX(${z}deg)`:""}const j=a.cH(a.f0(g.transform,this._lngLat)),R=d.sub(a.f1(g.transform)),L=Math.abs(R.x)+Math.abs(R.y);if(L===0)return"";const F=j/L;return`rotateX(${-R.y*F}deg) rotateY(${R.x*F}deg)`}_calculateZTransform(){const d=this._pos,g=this._map;if(!g||!d)return"";let S=0;const j=this.getRotationAlignment();if(j==="map")if(g._showingGlobe()){const R=g.project(new a.aU(this._lngLat.lng,this._lngLat.lat+.001),this._altitude),L=g.project(new a.aU(this._lngLat.lng,this._lngLat.lat-.001),this._altitude).sub(R);S=a.cH(Math.atan2(L.y,L.x))-90}else S=-g.getBearing();else if(j==="horizon"){const R=a.aj(4,6,g.getZoom()),L=a.f1(g.transform);L.y+=R*g.transform.height;const F=d.sub(L),z=a.cH(Math.atan2(F.y,F.x));S=(z>90?z-270:z+90)*(1-R)}return S+=this._rotation,S?`rotateZ(${S}deg)`:""}_update(d){cancelAnimationFrame(this._updateFrameId);const g=this._map;g&&(g.transform.renderWorldCopies&&(this._lngLat=Xj(this._lngLat,this._pos,g.transform)),this._pos=g.project(this._lngLat,this._altitude),d===!0?this._updateFrameId=requestAnimationFrame(()=>{this._element&&this._pos&&this._anchor&&(this._pos=this._pos.round(),this._updateDOM())}):this._pos=this._pos.round(),g._requestDomTask(()=>{this._map&&(this._element&&this._pos&&this._anchor&&this._updateDOM(),(g._showingGlobe()||g.getTerrain()||g.getFog())&&!this._fadeTimer&&(this._fadeTimer=window.setTimeout(this._evaluateOpacity.bind(this),60)))}))}getOffset(){return this._offset}setOffset(d){return this._offset=a.P.convert(d),this._update(),this}addClassName(d){return this._element.classList.add(d),this}removeClassName(d){return this._element.classList.remove(d),this}toggleClassName(d){return this._element.classList.toggle(d)}_onMove(d){const g=this._map;if(!g)return;const S=this._pointerdownPos,j=this._positionDelta;if(S&&j){if(!this._isDragging){const R=this._clickTolerance||g._clickTolerance;if(d.point.dist(S)v.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(v.minPitch!=null&&v.maxPitch!=null&&v.minPitch>v.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(v.minPitch!=null&&v.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(v.maxPitch!=null&&v.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");v.antialias&&a.eZ(window)&&(v.antialias=!1,a.w("Antialiasing is disabled for this WebGL context to avoid browser bug: https://github.com/mapbox/mapbox-gl-js/issues/11609")),super(new O0(v.minZoom,v.maxZoom,v.minPitch,v.maxPitch,v.renderWorldCopies,null,null),v),this._repaint=!!v.repaint,this._interactive=v.interactive,this._minTileCacheSize=v.minTileCacheSize,this._maxTileCacheSize=v.maxTileCacheSize,this._failIfMajorPerformanceCaveat=v.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=v.preserveDrawingBuffer,this._antialias=v.antialias,this._trackResize=v.trackResize,this._bearingSnap=v.bearingSnap,this._refreshExpiredTiles=v.refreshExpiredTiles,this._fadeDuration=v.fadeDuration,this._isInitialLoad=!0,this._crossSourceCollisions=v.crossSourceCollisions,this._collectResourceTiming=v.collectResourceTiming,this._language=this._parseLanguage(v.language),this._worldview=v.worldview,this._renderTaskQueue=new bP,this._domRenderTaskQueue=new bP,this._controls=[],this._markers=[],this._popups=[],this._mapId=a.r(),this._locale=Object.assign({},gB,v.locale),this._clickTolerance=v.clickTolerance,this._cooperativeGestures=v.cooperativeGestures,this._performanceMetricsCollection=v.performanceMetricsCollection,this._tessellationStep=v.tessellationStep,this._containerWidth=0,this._containerHeight=0,this._showParseStatus=!0,this._precompilePrograms=v.precompilePrograms,this._averageElevationLastSampledAt=-1/0,this._averageElevationExaggeration=0,this._averageElevation=new pB(0),this._interactionRange=[1/0,-1/0],this._visibilityHidden=0,this._useExplicitProjection=!1,this._frameId=0,this._scaleFactor=v.scaleFactor,this._requestManager=new Ee(v.transformRequest,v.accessToken,v.testMode);const g=ke(v.accessToken||a.g.ACCESS_TOKEN);if(g&&"atlas"in g&&typeof g.atlas=="number"&&(this._tokenExpiration=g.atlas),this._silenceAuthErrors=!!v.testMode,this._contextCreateOptions=v.contextCreateOptions?Object.assign({},v.contextCreateOptions):{},typeof v.container=="string"){const S=document.getElementById(v.container);if(!S)throw new Error(`Container '${v.container.toString()}' not found.`);this._container=S}else{if(!(v.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=v.container}if(this._container.childNodes.length>0&&a.w("The map container element should be empty, otherwise the map's interactivity will be negatively impacted. If you want to display a message when WebGL is not supported, use the Mapbox GL Supported plugin instead."),v.maxBounds&&this.setMaxBounds(v.maxBounds),this._spriteFormat="auto",a.aZ(["_onWindowOnline","_onWindowResize","_onVisibilityChange","_onMapScroll","_contextLost","_contextRestored"],this),this._setupContainer(),this._setupPainter(),this.painter===void 0)throw new Error("Failed to initialize WebGL.");if(this.on("move",()=>this._update(!1)),this.on("moveend",()=>this._update(!1)),this.on("zoom",()=>this._update(!0)),this._fullscreenchangeEvent="onfullscreenchange"in document?"fullscreenchange":"webkitfullscreenchange",window.addEventListener("online",this._onWindowOnline,!1),window.addEventListener("resize",this._onWindowResize,!1),window.addEventListener("orientationchange",this._onWindowResize,!1),window.addEventListener(this._fullscreenchangeEvent,this._onWindowResize,!1),window.addEventListener("visibilitychange",this._onVisibilityChange,!1),this.handlers=new _P(this,v),this._localFontFamily=v.localFontFamily,this._localIdeographFontFamily=v.localIdeographFontFamily,this._useServerFontComposition=v.useServerFontComposition,(v.style||!v.testMode)&&this.setStyle(v.style||a.g.DEFAULT_STYLE,{config:v.config,localFontFamily:this._localFontFamily,localIdeographFontFamily:this._localIdeographFontFamily,useServerFontComposition:this._useServerFontComposition}),v.projection&&this.setProjection(v.projection),v.hash&&(this._hash=new fB(typeof v.hash=="string"&&v.hash||void 0).addTo(this)),!this._hash||!this._hash._onHashChange()){d.center==null&&d.zoom==null||(this.transform._unmodified=!1),this.jumpTo({center:v.center,zoom:v.zoom,bearing:v.bearing,pitch:v.pitch});const S=v.bounds;S&&(this.resize(),this.fitBounds(S,Object.assign({},v.fitBoundsOptions,{duration:0})))}this.resize(),v.attributionControl&&this.addControl(new Yj({customAttribution:v.customAttribution})),this._logoControl=new Zj,this.addControl(this._logoControl,v.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet),this._postStyleLoadEvent(),this._postStyleWithAppearanceEvent()}),this.on("data",S=>{this._update(S.dataType==="style"),this.fire(new a.C(`${S.dataType}data`,S))}),this.on("dataloading",S=>{this.fire(new a.C(`${S.dataType}dataloading`,S))}),this._interactions=new xw(this)}_getMapId(){return this._mapId}addControl(v,d){if(d===void 0&&(d=v.getDefaultPosition?v.getDefaultPosition():"top-right"),!v||!v.onAdd)return this.fire(new a.B(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const g=v.onAdd(this);this._controls.push(v);const S=this._controlPositions[d];return d.indexOf("bottom")!==-1?S.insertBefore(g,S.firstChild):S.appendChild(g),this}removeControl(v){if(!v||!v.onRemove)return this.fire(new a.B(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const d=this._controls.indexOf(v);return d>-1&&this._controls.splice(d,1),v.onRemove(this),this}hasControl(v){return this._controls.indexOf(v)>-1}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}resize(v){if(this._updateContainerDimensions(),this._containerWidth===this.transform.width&&this._containerHeight===this.transform.height)return this;this._resizeCanvas(this._containerWidth,this._containerHeight),this.transform.resize(this._containerWidth,this._containerHeight),this.painter.resize(Math.ceil(this._containerWidth),Math.ceil(this._containerHeight));const d=!this._moving;return d&&this.fire(new a.C("movestart",v)).fire(new a.C("move",v)),this.fire(new a.C("resize",v)),d&&this.fire(new a.C("moveend",v)),this}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(v){return this.transform.setMaxBounds(a.aK.convert(v)),this._update()}setMinZoom(v){if((v=v??-2)>=-2&&v<=this.transform.maxZoom)return this.transform.minZoom=v,this._update(),this.getZoom()=this.transform.minZoom)return this.transform.maxZoom=v,this._update(),this.getZoom()>v?this.setZoom(v):this.fire(new a.C("zoomstart")).fire(new a.C("zoom")).fire(new a.C("zoomend")),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(v){if((v=v??0)<0)throw new Error("minPitch must be greater than or equal to 0");if(v>=0&&v<=this.transform.maxPitch)return this.transform.minPitch=v,this._update(),this.getPitch()85)throw new Error("maxPitch must be less than or equal to 85");if(v>=this.transform.minPitch)return this.transform.maxPitch=v,this._update(),this.getPitch()>v?this.setPitch(v):this.fire(new a.C("pitchstart")).fire(new a.C("pitch")).fire(new a.C("pitchend")),this;throw new Error("maxPitch must be greater than or equal to minPitch")}getMaxPitch(){return this.transform.maxPitch}getScaleFactor(){return this._scaleFactor}setScaleFactor(v){return this._scaleFactor=v,this.painter.scaleFactor=v,this.style&&this.style._setLabelPlacementStale(),this.style._updateFilteredLayers(d=>d.type==="symbol"),this._update(!0),this}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(v){return this.transform.renderWorldCopies=v,this.transform.renderWorldCopies||this._forceMarkerAndPopupUpdate(!0),this._update()}getLanguage(){return this._language}_parseLanguage(v){return v==="auto"?navigator.language:Array.isArray(v)?v.length===0?void 0:v.map(d=>d==="auto"?navigator.language:d):v}setLanguage(v){const d=this._parseLanguage(v);if(!this.style||d===this._language)return this;this._language=d,this.style.reloadSources();for(const g of this._controls)g._setLanguage&&g._setLanguage(this._language);return this}getWorldview(){return this._worldview}setWorldview(v){return this.style&&v!==this._worldview?(this._worldview=v,this._styleDirty=!0,this.style.setWorldview(v),this):this}getProjection(){return this.transform.mercatorFromTransition?{name:"globe",center:[0,0]}:this.transform.getProjection()}_showingGlobe(){return this.transform.projection.name==="globe"}setProjection(v){return this._lazyInitEmptyStyle(),v?typeof v=="string"&&(v={name:v}):v=null,this._useExplicitProjection=!!v,this._prioritizeAndUpdateProjection(v,this.style.projection)}_updateProjectionTransition(){if(this.getProjection().name!=="globe")return;const v=this.transform,d=v.projection.name;let g;d==="globe"&&v.zoom>=a.cv?(v.setMercatorFromTransition(),g=!0):d==="mercator"&&v.zoom=a.cv?this.transform.setMercatorFromTransition():this.transform.setProjection(v),this.style.applyProjectionUpdate();const S=this.transform.getProjection().name==="mercator"&&g!==this.transform.mercatorFromTransition;return(d||S)&&(this.painter.clearBackgroundTiles(),this.style.clearSources(),this._update(!0),this._forceMarkerAndPopupUpdate(!0)),this}project(v,d){return this.transform.locationPoint3D(a.aU.convert(v),d)}unproject(v,d){return this.transform.pointLocation3D(a.P.convert(v),d)}isMoving(){return this._moving||this.handlers&&this.handlers.isMoving()||!1}isZooming(){return this._zooming||this.handlers&&this.handlers.isZooming()||!1}isRotating(){return this._rotating||this.handlers&&this.handlers.isRotating()||!1}_isDragging(){return this.handlers&&this.handlers._isDragging()||!1}_createDelegatedListener(v,d,g){const S=j=>{let R=[];if(Array.isArray(d)){const L=d.filter(F=>this.getLayer(F));R=L.length?this.queryRenderedFeatures(j,{layers:L}):[]}else R=this.queryRenderedFeatures(j,{target:d});return R};if(v==="mouseenter"||v==="mouseover"){let j=!1;return{listener:g,targets:d,delegates:{mousemove:L=>{const F=S(L.point);F.length?j||(j=!0,g.call(this,new Ro(v,this,L.originalEvent,{features:F}))):j=!1},mouseout:()=>{j=!1}}}}if(v==="mouseleave"||v==="mouseout"){let j=!1;return{listener:g,targets:d,delegates:{mousemove:F=>{S(F.point).length?j=!0:j&&(j=!1,g.call(this,new Ro(v,this,F.originalEvent)))},mouseout:F=>{j&&(j=!1,g.call(this,new Ro(v,this,F.originalEvent)))}}}}{const j=R=>{const L=S(R.point);L.length&&(R.features=L,g.call(this,R),delete R.features)};return{listener:g,targets:d,delegates:{[v]:j}}}}on(v,d,g){if(typeof d=="function"||g===void 0)return super.on(v,d);if(typeof d=="string"&&(d=[d]),!this._areTargetsValid(d))return this;const S=this._createDelegatedListener(v,d,g);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[v]=this._delegatedListeners[v]||[],this._delegatedListeners[v].push(S);for(const j in S.delegates)this.on(j,S.delegates[j]);return this}once(v,d,g){if(typeof d=="function"||g===void 0)return super.once(v,d);if(typeof d=="string"&&(d=[d]),!this._areTargetsValid(d))return this;const S=this._createDelegatedListener(v,d,g);for(const j in S.delegates)this.once(j,S.delegates[j]);return this}off(v,d,g){if(typeof d=="function"||g===void 0)return super.off(v,d);if(typeof d=="string"&&(d=[d]),!this._areTargetsValid(d))return this;const S=this._delegatedListeners?this._delegatedListeners[v]:void 0;return S&&(j=>{for(let R=0;R{if(g){const j=typeof g=="string"?g:g instanceof Error?g.message:g.error;a.w(`Unable to perform style diff: ${j}. Rebuilding the style from scratch.`),this._updateStyle(v,d)}else S&&this._update(!0)},()=>this._postStyleLoadEvent()),this):(this._localIdeographFontFamily=d.localIdeographFontFamily,this._localFontFamily=d.localFontFamily,this._updateStyle(v,d))}_getUIString(v){const d=this._locale[v];if(d==null)throw new Error(`Missing UI string '${v}'`);return d}_updateStyle(v,d){if(this.style&&(this.style.setEventedParent(null),this.style._remove(),this.style=void 0),v){const g=Object.assign({},d);d&&d.config&&(g.initialConfig=d.config,delete g.config),this.style=new Ru(this,g).load(v),this.style.setEventedParent(this,{style:this.style})}return this._updateTerrain(),this}_lazyInitEmptyStyle(){this.style||(this.style=new Ru(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():(a.w("There is no style added to the map."),!1)}_isValidId(v){return v==null?(this.fire(new a.B(new Error("IDs can't be empty."))),!1):!a.db(v)||(this.fire(new a.B(new Error(`IDs can't contain special symbols: "${v}".`))),!1)}_isTargetValid(v){return"featuresetId"in v?this._isValidId("importId"in v?v.importId:v.featuresetId):"layerId"in v&&this._isValidId(v.layerId)}_areTargetsValid(v){if(Array.isArray(v)){for(const d of v)if(!this._isValidId(d))return!1;return!0}return this._isTargetValid(v)}addSource(v,d){return this._isValidId(v)?(this._lazyInitEmptyStyle(),this.style.addSource(v,d),this._update(!0)):this}isSourceLoaded(v){return!!this._isValidId(v)&&!!this.style&&this.style._isSourceCacheLoaded(v)}areTilesLoaded(){return this.style.areTilesLoaded()}addSourceType(v,d,g){this._lazyInitEmptyStyle(),this.style.addSourceType(v,d,g)}removeSource(v){return this._isValidId(v)?(this.style.removeSource(v),this._updateTerrain(),this._update(!0)):this}getSource(v){return this._isValidId(v)?this.style.getOwnSource(v):null}addImage(v,d,{pixelRatio:g=1,sdf:S=!1,stretchX:j,stretchY:R,content:L}={}){this._lazyInitEmptyStyle();const F=a.I.from(v);if(d instanceof HTMLImageElement||ImageBitmap&&d instanceof ImageBitmap){const{width:z,height:W,data:Z}=a.o.getImageData(d);this.style.addImage(F,{data:new a.q({width:z,height:W},Z),pixelRatio:g,stretchX:j,stretchY:R,content:L,sdf:S,version:0,usvg:!1})}else if(d.width===void 0||d.height===void 0)this.fire(new a.B(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));else{const{width:z,height:W}=d,Z=d;this.style.addImage(F,{data:new a.q({width:z,height:W},new Uint8Array(Z.data)),pixelRatio:g,stretchX:j,stretchY:R,content:L,sdf:S,usvg:!1,version:0,userImage:Z}),Z.onAdd&&Z.onAdd(this,v)}}updateImage(v,d){this._lazyInitEmptyStyle();const g=a.I.from(v),S=this.style.getImage(g);if(!S)return void this.fire(new a.B(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const j=d instanceof HTMLImageElement||ImageBitmap&&d instanceof ImageBitmap?a.o.getImageData(d):d,{width:R,height:L,data:F}=j;if(R===void 0||L===void 0)return void this.fire(new a.B(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));if(R!==(S.usvg?S.icon.usvg_tree.width:S.data.width)||L!==(S.usvg?S.icon.usvg_tree.height:S.data.height))return void this.fire(new a.B(new Error(`The width and height of the updated image (${R}, ${L}) must be that same as the previous version of the image (${S.data.width}, ${S.data.height})`)));const z=!(d instanceof HTMLImageElement||ImageBitmap&&d instanceof ImageBitmap);let W=!1;S.usvg?(S.data=new a.q({width:R,height:L},new Uint8Array(F)),S.usvg=!1,S.icon=void 0,W=!0):S.data.replace(F,z),this.style.updateImage(g,S,W)}hasImage(v){return v?!!this.style&&!!this.style.getImage(a.I.from(v)):(this.fire(new a.B(new Error("Missing required image id"))),!1)}removeImage(v){this.style.removeImage(a.I.from(v))}loadImage(v,d){a.n(this._requestManager.transformRequest(v,a.R.Image),(g,S)=>{d(g,S)})}listImages(){return this.style.listImages().map(v=>v.name)}addModel(v,d){this._lazyInitEmptyStyle(),this.style.addModel(v,d)}hasModel(v){return v?this.style.hasModel(v):(this.fire(new a.B(new Error("Missing required model id"))),!1)}removeModel(v){this.style.removeModel(v)}listModels(){return this.style.listModels()}addLayer(v,d){return this._isValidId(v.id)?(this._lazyInitEmptyStyle(),this.style.addLayer(v,d),this._update(!0)):this}getSlot(v){const d=this.getLayer(v);return d&&d.slot||null}setSlot(v,d){return this.style.setSlot(v,d),this.style.mergeLayers(),this._update(!0)}addImport(v,d){return this.style.addImport(v,d).catch(g=>this.fire(new a.B(new Error("Failed to add import",g)))),this}updateImport(v,d){return typeof d!="string"&&d.id!==v?(this.removeImport(v),this.addImport(d)):(this.style.updateImport(v,d),this._update(!0))}removeImport(v){return this.style.removeImport(v),this}moveImport(v,d){return this.style.moveImport(v,d),this._update(!0)}moveLayer(v,d){return this._isValidId(v)?(this.style.moveLayer(v,d),this._update(!0)):this}removeLayer(v){return this._isValidId(v)?(this.style.removeLayer(v),this._update(!0)):this}getLayer(v){if(!this._isValidId(v))return null;const d=this.style.getOwnLayer(v);return d?d.type==="custom"?d.implementation:d.serialize():void 0}getSlots(){return this.style.getSlots()}setLayerZoomRange(v,d,g){return this._isValidId(v)?(this.style.setLayerZoomRange(v,d,g),this._update(!0)):this}setFilter(v,d,g={}){return this._isValidId(v)?(this.style.setFilter(v,d,g),this._update(!0)):this}getFilter(v){return this._isValidId(v)?this.style.getFilter(v):null}setPaintProperty(v,d,g,S={}){return this._isValidId(v)?(this.style.setPaintProperty(v,d,g,S),this._update(!0)):this}getPaintProperty(v,d){return this._isValidId(v)?this.style.getPaintProperty(v,d):null}setLayoutProperty(v,d,g,S={}){return this._isValidId(v)?(this.style.setLayoutProperty(v,d,g,S),this._update(!0)):this}getLayoutProperty(v,d){return this._isValidId(v)?this.style.getLayoutProperty(v,d):null}setLayerProperty(v,d,g,S={}){return this._isValidId(v)?(d==="appearances"&&this._postAddingAppearancesToStyleEvent(),this.style.setLayerProperty(v,d,g,S),this._update(!0)):this}getGlyphsUrl(){return this.style.getGlyphsUrl()}setGlyphsUrl(v){return this.style.setGlyphsUrl(v),this._update(!0)}getSchema(v){return this.style.getSchema(v)}setSchema(v,d){return this.style.setSchema(v,d),this._update(!0)}getConfig(v){return this.style.getConfig(v)}setConfig(v,d){return this.style.setConfig(v,d),this._update(!0)}getConfigProperty(v,d){return this.style.getConfigProperty(v,d)}setConfigProperty(v,d,g){return this.style.setConfigProperty(v,d,g),this._update(!0)}getFeaturesetDescriptors(v){return this.style.getFeaturesetDescriptors(v)}setLights(v){if(this._lazyInitEmptyStyle(),v&&v.length===1&&v[0].type==="flat"){const d=v[0];d.properties?this.style.setFlatLight(d.properties,d.id,{}):this.style.setFlatLight({},"flat")}else this.style.setLights(v),this.painter.terrain&&(this.painter.terrain.invalidateRenderCache=!0);return this._update(!0)}getLights(){const v=this.style.getLights()||[];return v.length===0&&v.push({id:this.style.light.id,type:"flat",properties:this.style.getFlatLight()}),v}setLight(v,d={}){return console.log("The `map.setLight` function is deprecated, prefer using `map.setLights` with `flat` light type instead."),this.setLights([{id:"flat",type:"flat",properties:v}])}getLight(){return console.log("The `map.getLight` function is deprecated, prefer using `map.getLights` instead."),this.style.getFlatLight()}setTerrain(v){return this._lazyInitEmptyStyle(),!v&&this.transform.projection.requiresDraping?this.style.setTerrainForDraping():this.style.setTerrain(v),this._averageElevationLastSampledAt=-1/0,this._update(!0)}getTerrain(){return this.style?this.style.getTerrain():null}setFog(v){return this._lazyInitEmptyStyle(),this.style.setFog(v),this._update(!0)}getFog(){return this.style?this.style.getFog():null}setSnow(v){return this._lazyInitEmptyStyle(),this.style.setSnow(v),this._update(!0)}getSnow(){return this.style?this.style.getSnow():null}setRain(v){return this._lazyInitEmptyStyle(),this.style.setRain(v),this._update(!0)}getRain(){return this.style?this.style.getRain():null}setColorTheme(v){return this._lazyInitEmptyStyle(),this.style.setColorTheme(v),this._update(!0)}setImportColorTheme(v,d){return this._lazyInitEmptyStyle(),this.style.setImportColorTheme(v,d),this._update(!0)}setCamera(v){return this.style.setCamera(v),this._triggerCameraUpdate(v)}getNearClipOffset(){return this.transform.nearClipOffset}setNearClipOffset(v){const d=this.transform.nearClipOffset!==v;return this.transform.nearClipOffset=v,this._update(d)}_triggerCameraUpdate(v){return this._update(this.transform.setOrthographicProjectionAtLowPitch(v["camera-projection"]==="orthographic"))}getCamera(){return this.style.camera}_queryFogOpacity(v){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(a.aU.convert(v),this.transform):0}setFeatureState(v,d){return v.source&&!this._isValidId(v.source)?this:(this.style.setFeatureState(v,d),this._update())}removeFeatureState(v,d){return v.source&&!this._isValidId(v.source)?this:(this.style.removeFeatureState(v,d),this._update())}getFeatureState(v){return v.source&&!this._isValidId(v.source)?null:this.style.getFeatureState(v)}_selectIndoorFloor(v){this.style.indoorManager.selectFloor(v)}_setIndoorActiveFloorsVisibility(v){this.style.indoorManager.setActiveFloorsVisibility(v)}getIndoorTileOptions(v,d){return this.style.isIndoorEnabled()?this.style.indoorManager.getIndoorTileOptions(v,d):null}_updateContainerDimensions(){if(!this._container)return;const v=this._container.getBoundingClientRect().width||400,d=this._container.getBoundingClientRect().height||300;let g,S,j,R=this._container;for(;R&&(!S||!j);){const L=window.getComputedStyle(R).transform;L&&L!=="none"&&(g=L.match(/matrix.*\((.+)\)/)[1].split(", "),g[0]&&g[0]!=="0"&&g[0]!=="1"&&(S=g[0]),g[3]&&g[3]!=="0"&&g[3]!=="1"&&(j=g[3])),R=R.parentElement}this._containerWidth=S?Math.abs(v/S):v,this._containerHeight=j?Math.abs(d/j):d}_detectMissingCSS(){window.getComputedStyle(this._missingCSSCanary).getPropertyValue("background-color")!=="rgb(250, 128, 114)"&&a.w("This page appears to be missing CSS declarations for Mapbox GL JS, which may cause the map to display incorrectly. Please ensure your page includes mapbox-gl.css, as described in https://www.mapbox.com/mapbox-gl-js/api/.")}_setupContainer(){const v=this._container;v.classList.add("mapboxgl-map"),(this._missingCSSCanary=C("div","mapboxgl-canary",v)).style.visibility="hidden",this._detectMissingCSS();const d=this._canvasContainer=C("div","mapboxgl-canvas-container",v);this._canvas=C("canvas","mapboxgl-canvas",d),this._interactive&&(d.classList.add("mapboxgl-interactive"),this._canvas.setAttribute("tabindex","0")),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region"),this._updateContainerDimensions(),this._resizeCanvas(this._containerWidth,this._containerHeight);const g=this._controlContainer=C("div","mapboxgl-control-container",v),S=this._controlPositions={};["top-left","top","top-right","right","bottom-right","bottom","bottom-left","left"].forEach(j=>{S[j]=C("div",`mapboxgl-ctrl-${j}`,g)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(v,d){const g=a.o.devicePixelRatio||1;this._canvas.width=g*Math.ceil(v),this._canvas.height=g*Math.ceil(d),this._canvas.style.width=`${v}px`,this._canvas.style.height=`${d}px`}_addMarker(v){this._markers.push(v)}_removeMarker(v){const d=this._markers.indexOf(v);d!==-1&&this._markers.splice(d,1)}_addPopup(v){this._popups.push(v)}_removePopup(v){const d=this._popups.indexOf(v);d!==-1&&this._popups.splice(d,1)}_setupPainter(){const v=Object.assign({},A.supported.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),d=this._canvas.getContext("webgl2",v);d?(qr(d,!0),this.painter=new hB(d,this._contextCreateOptions,this.transform,this._scaleFactor,this._worldview),this.on("data",g=>{if(g.dataType==="source"){const S=this.transform.elevation?this.transform.elevation._source():null;S&&g.sourceCacheId===S.id&&this.style&&this.style._setLabelPlacementStale(),this.painter.setTileLoadedFlag(!0)}}),a.k.testSupport(d)):this.fire(new a.B(new Error("Failed to initialize WebGL")))}_contextLost(v){v.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new a.C("webglcontextlost",{originalEvent:v}))}_contextRestored(v){this._setupPainter(),this.painter.resize(Math.ceil(this._containerWidth),Math.ceil(this._containerHeight)),this._updateTerrain(),this.style&&(this.style.clearLayers(),this.style.imageManager.destroyAtlasTextures(),this.style.imageManager.imageAtlasCache.destroyTextures(),this.style.reloadModels(),this.style.clearSources()),this._update(),this.fire(new a.C("webglcontextrestored",{originalEvent:v}))}_onMapScroll(v){if(v.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1}idle(){return!this.isMoving()&&this.loaded()}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}frameReady(){return this.loaded()&&!this._placementDirty}_update(v){return this.style?(this._styleDirty=this._styleDirty||v,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(v){return this._update(),this._renderTaskQueue.add(v)}_cancelRenderFrame(v){this._renderTaskQueue.remove(v)}_requestDomTask(v){!this.loaded()||this.loaded()&&!this.isMoving()?v():this._domRenderTaskQueue.add(v)}_render(v){let d;this.fire(new a.C("renderstart")),++this._frameId;const g=this.painter.context.extTimerQuery,S=a.o.now(),j=this.painter.context.gl;if(this.listens("gpu-timing-frame")&&(d=j.createQuery(),j.beginQuery(g.TIME_ELAPSED_EXT,d)),this.painter.context.setDirty(),this.painter.setBaseState(),(this.isMoving()||this.isRotating()||this.isZooming())&&(this._interactionRange[0]=Math.min(this._interactionRange[0],performance.now()),this._interactionRange[1]=Math.max(this._interactionRange[1],performance.now())),this._renderTaskQueue.run(v),this._domRenderTaskQueue.run(v),this._removed)return;this._updateProjectionTransition();const R=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;const z=this.transform.zoom,W=this.transform.pitch,Z=a.o.now(),ne=new a.ae(z,{now:Z,fadeDuration:R,pitch:W,transition:this.style.transition,worldview:this._worldview});this.style.update(ne)}this.style&&this.style.hasFogTransition()&&(this.style._markersNeedUpdate=!0,this._sourcesDirty=!0);let L=!1;if(this.style&&this._sourcesDirty?(this._sourcesDirty=!1,this.painter._updateFog(this.style),this._updateTerrain(),L=this._updateAverageElevation(S),this.style.updateSources(this.transform),this.style.updateImageProviders(),this.isMoving()||this._forceMarkerAndPopupUpdate()):L=this._updateAverageElevation(S),this.style&&(this._placementDirty=this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,R,this._crossSourceCollisions,this.painter.replacementSource)),this.style&&this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showParseStatus:this.showParseStatus,wireframe:{terrain:this.showTerrainWireframe,layers2D:this.showLayers2DWireframe,layers3D:this.showLayers3DWireframe},showOverdrawInspector:this._showOverdrawInspector,showQueryGeometry:!!this._showQueryGeometry,showTileAABBs:this.showTileAABBs,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:R,isInitialLoad:this._isInitialLoad,showPadding:this.showPadding,gpuTiming:!!this.listens("gpu-timing-layer"),gpuTimingDeferredRender:!!this.listens("gpu-timing-deferred-render"),speedIndexTiming:this.speedIndexTiming}),this.fire(new a.C("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,y.mark(m.load),this.fire(new a.C("load"))),this.style&&this.style.hasTransitions()&&(this._styleDirty=!0),this.style&&(this.style.snow||this.style.rain)&&(this._styleDirty=!0),this.style&&this.style.imageManager.hasPatternsInFlight()&&(this._styleDirty=!0),this.style&&!this.style.modelManager.isLoaded()&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),d){const z=a.o.now()-S;j.endQuery(g.TIME_ELAPSED_EXT),setTimeout(()=>{const W=j.getQueryParameter(d,j.QUERY_RESULT)/1e6;j.deleteQuery(d),this.fire(new a.C("gpu-timing-frame",{cpuTime:z,gpuTime:W}))},50)}if(this.listens("gpu-timing-layer")){const z=this.painter.collectGpuTimers();setTimeout(()=>{const W=this.painter.queryGpuTimers(z);this.fire(new a.C("gpu-timing-layer",{layerTimes:W}))},50)}if(this.listens("gpu-timing-deferred-render")){const z=this.painter.collectDeferredRenderGpuQueries();setTimeout(()=>{const W=this.painter.queryGpuTimeDeferredRender(z);this.fire(new a.C("gpu-timing-deferred-render",{gpuTime:W}))},50)}const F=this._sourcesDirty||this._styleDirty||this._placementDirty||L;if(F||this._repaint)this.triggerRepaint();else{const z=this.idle();if(z&&(L=this._updateAverageElevation(S,!0)),L)this.triggerRepaint();else if(this._triggerFrame(!1),z&&(this.fire(new a.C("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){const W=this._calculateSpeedIndex();this.fire(new a.C("speedindexcompleted",{speedIndex:W})),this.speedIndexTiming=!1}}!this._loaded||this._fullyLoaded||F||(this._fullyLoaded=!0,y.mark(m.fullLoad),this._performanceMetricsCollection&&Sr(this._requestManager._customAccessToken,{width:this.painter.width,height:this.painter.height,interactionRange:this._interactionRange,visibilityHidden:this._visibilityHidden,terrainEnabled:!!this.painter.style.getTerrain(),fogEnabled:!!this.painter.style.getFog(),projection:this.getProjection().name,zoom:this.transform.zoom,renderer:this.painter.context.renderer,vendor:this.painter.context.vendor}),this._authenticate())}_forceMarkerAndPopupUpdate(v){for(const d of this._markers)v&&!this.getRenderWorldCopies()&&(d._lngLat=d._lngLat.wrap()),d._update();for(const d of this._popups)!v||this.getRenderWorldCopies()||d._trackPointer||(d._lngLat=d._lngLat.wrap()),d._update()}_updateAverageElevation(v,d=!1){const g=j=>(this.transform.averageElevation=j,this._update(!1),!0);if(!this.painter.averageElevationNeedsEasing())return this.transform.averageElevation!==0&&g(0);const S=this.transform.elevation&&this.transform.elevation.exaggeration()!==this._averageElevationExaggeration;if(S||(d||v-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(v)){const j=this.transform.averageElevation;let R=this.transform.sampleAverageElevation();this.transform.elevation!=null&&(this._averageElevationExaggeration=this.transform.elevation.exaggeration()),isNaN(R)?R=0:this._averageElevationLastSampledAt=v;const L=Math.abs(j-R);if(L>1){if(this._isInitialLoad||S)return this._averageElevation.jumpTo(R),g(R);this._averageElevation.easeTo(R,v,300)}else if(L>1e-4)return this._averageElevation.jumpTo(R),g(R)}return!!this._averageElevation.isEasing(v)&&g(this._averageElevation.getValue(v))}_isTokenExpired(){return this._tokenExpiration!=null&&Date.now()>this._tokenExpiration}_revokeAuth(){const v=this.painter.context.gl;qr(v,!1),this._logoControl instanceof Zj&&this._logoControl._updateLogo(),v&&v.clear(v.DEPTH_BUFFER_BIT|v.COLOR_BUFFER_BIT|v.STENCIL_BUFFER_BIT),this._silenceAuthErrors||this.fire(new a.B(new Error("A valid Mapbox access token is required to use Mapbox GL JS. To create an account or a new access token, visit https://account.mapbox.com/")))}_authenticate(){Rr(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,v=>{v&&(v.message!==ye&&v.status!==401||this._revokeAuth())}),this._isTokenExpired()&&this._revokeAuth(),wt(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,()=>{})}_postStyleLoadEvent(){this.style.globalId&>(this._requestManager._customAccessToken,{map:this,style:this.style.globalId,importedStyles:this.style.getImportGlobalIds()})}_postStyleWithAppearanceEvent(){this.style.globalId&&this.style.hasAppearances()&&kt(this._requestManager._customAccessToken)}_postAddingAppearancesToStyleEvent(){xt(this._requestManager._customAccessToken)}_updateTerrain(){const v=this._isDragging();this.painter.updateTerrain(this.style,v)}_calculateSpeedIndex(){const v=this.painter.canvasCopy(),d=this.painter.getCanvasCopiesAndTimestamps();d.timeStamps.push(performance.now());const g=this.painter.context.gl,S=g.createFramebuffer();function j(R){g.framebufferTexture2D(g.FRAMEBUFFER,g.COLOR_ATTACHMENT0,g.TEXTURE_2D,R,0);const L=new Uint8Array(g.drawingBufferWidth*g.drawingBufferHeight*4);return g.readPixels(0,0,g.drawingBufferWidth,g.drawingBufferHeight,g.RGBA,g.UNSIGNED_BYTE,L),L}return g.bindFramebuffer(g.FRAMEBUFFER,S),this._canvasPixelComparison(j(v),d.canvasCopies.map(j),d.timeStamps)}_canvasPixelComparison(v,d,g){let S=g[1]-g[0];const j=v.length/4;for(let R=0;R{const g=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,g&&this._render(d)}))}_preloadTiles(v){const d=this.style?this.style.getSourceCaches():[];return a.t(d,(g,S)=>g._preloadTiles(v,S),()=>{this.triggerRepaint()}),this}_onWindowOnline(){this._update()}_onWindowResize(v){this._trackResize&&this.resize({originalEvent:v})._update()}_onVisibilityChange(){document.visibilityState==="hidden"&&this._visibilityHidden++}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(v){this._showTileBoundaries!==v&&(this._showTileBoundaries=v,this._update())}get showParseStatus(){return!!this._showParseStatus}set showParseStatus(v){this._showParseStatus!==v&&(this._showParseStatus=v,this._update())}get showTerrainWireframe(){return!!this._showTerrainWireframe}set showTerrainWireframe(v){this._showTerrainWireframe!==v&&(this._showTerrainWireframe=v,this._update())}get showLayers2DWireframe(){return!!this._showLayers2DWireframe}set showLayers2DWireframe(v){this._showLayers2DWireframe!==v&&(this._showLayers2DWireframe=v,this._update())}get showLayers3DWireframe(){return!!this._showLayers3DWireframe}set showLayers3DWireframe(v){this._showLayers3DWireframe!==v&&(this._showLayers3DWireframe=v,this._update())}get speedIndexTiming(){return!!this._speedIndexTiming}set speedIndexTiming(v){this._speedIndexTiming!==v&&(this._speedIndexTiming=v,this._update())}get showPadding(){return!!this._showPadding}set showPadding(v){this._showPadding!==v&&(this._showPadding=v,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(v){this._showCollisionBoxes!==v&&(this._showCollisionBoxes=v,this.style&&v?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(v){this._showOverdrawInspector!==v&&(this._showOverdrawInspector=v,this._update())}get repaint(){return!!this._repaint}set repaint(v){this._repaint!==v&&(this._repaint=v,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(v){this._vertices=v,this._update()}get showTileAABBs(){return!!this._showTileAABBs}set showTileAABBs(v){this._showTileAABBs!==v&&(this._showTileAABBs=v,v&&this._update())}_setCacheLimits(v,d){a.e_(v,d)}get version(){return f}},NavigationControl:class{constructor(v={}){this.options=Object.assign({},_B,v),this._container=C("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",d=>d.preventDefault()),this.options.showZoom&&(a.aZ(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",d=>{this._map&&this._map.zoomIn({},{originalEvent:d})}),C("span","mapboxgl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("mapboxgl-ctrl-zoom-out",d=>{this._map&&this._map.zoomOut({},{originalEvent:d})}),C("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(a.aZ(["_rotateCompassArrow"],this),this._compass=this._createButton("mapboxgl-ctrl-compass",d=>{const g=this._map;g&&(this.options.visualizePitch?g.resetNorthPitch({},{originalEvent:d}):g.resetNorth({},{originalEvent:d}))}),this._compassIcon=C("span","mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}_updateZoomButtons(){const v=this._map;if(!v)return;const d=v.getZoom(),g=d===v.getMaxZoom(),S=d===v.getMinZoom();this._zoomInButton.disabled=g,this._zoomOutButton.disabled=S,this._zoomInButton.setAttribute("aria-disabled",g.toString()),this._zoomOutButton.setAttribute("aria-disabled",S.toString())}_rotateCompassArrow(){const v=this._map;if(!v)return;const d=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(v.transform.pitch*(Math.PI/180)),.5)}) rotateX(${v.transform.pitch}deg) rotateZ(${v.transform.angle*(180/Math.PI)}deg)`:`rotate(${v.transform.angle*(180/Math.PI)}deg)`;v._requestDomTask(()=>{this._compassIcon&&(this._compassIcon.style.transform=d)})}onAdd(v){return this._map=v,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),v.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&v.on("pitch",this._rotateCompassArrow),v.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new g_(v,this._compass,this.options.visualizePitch)),this._container}onRemove(){const v=this._map;v&&(this._container.remove(),this.options.showZoom&&v.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&v.off("pitch",this._rotateCompassArrow),v.off("rotate",this._rotateCompassArrow),this._handler&&this._handler.off(),this._handler=void 0),this._map=void 0)}_createButton(v,d){const g=C("button",v,this._container);return g.type="button",g.addEventListener("click",d),g}_setButtonTitle(v,d){if(!this._map)return;const g=this._map._getUIString(`NavigationControl.${d}`);v.setAttribute("aria-label",g),v.firstElementChild&&v.firstElementChild.setAttribute("title",g)}},GeolocateControl:class extends a.E{constructor(v={}){super();const d=navigator.geolocation;this.options=Object.assign({geolocation:d},x_,v),a.aZ(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],this),this._updateMarkerRotationThrottled=Lj(this._updateMarkerRotation,20),this._numberOfWatches=0}onAdd(v){return this._map=v,this._container=C("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkGeolocationSupport(this._setupUI),this._container}onRemove(){this._clearRequestTimeout(),this._geolocationWatchID!==void 0&&(this.options.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),this._container.remove(),this._map.off("zoom",this._onZoom),this._map=void 0,this._numberOfWatches=0,this._noTimeout=!1}_checkGeolocationSupport(v){const d=(g=!!this.options.geolocation)=>{this._supportsGeolocation=g,v(g)};this._supportsGeolocation!==void 0?v(this._supportsGeolocation):navigator.permissions!==void 0?navigator.permissions.query({name:"geolocation"}).then(g=>d(g.state!=="denied")).catch(()=>d()):d()}_isOutOfMapMaxBounds(v){const d=this._map.getMaxBounds(),g=v.coords;return!!d&&(g.longituded.getEast()||g.latituded.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting")}}_onSuccess(v){if(this._map){if(this._clearRequestTimeout(),this._isOutOfMapMaxBounds(v))return this._setErrorState(),this.fire(new a.C("outofmaxbounds",v)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=v,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this.options.followUserLocation?(this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active")):(this._watchState="BACKGROUND",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"));break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background")}this.options.showUserLocation&&this._watchState!=="OFF"&&this._updateMarker(v),this.options.followUserLocation&&(!this.options.trackUserLocation||this._watchState==="ACTIVE_LOCK")&&this._updateCamera(v),this.options.showUserLocation&&this._userLocationDotMarker.removeClassName("mapboxgl-user-location-dot-stale"),this.fire(new a.C("geolocate",Object.assign({coords:v.coords,timestamp:v.timestamp},v.toJSON?{toJSON:v.toJSON.bind(v)}:{}))),this._finish()}}_updateCamera(v){const d=new a.aU(v.coords.longitude,v.coords.latitude),g=v.coords.accuracy,S=this._map.getBearing(),j=Object.assign({bearing:S},this.options.fitBoundsOptions);this._map.fitBounds(d.toBounds(g),j,{geolocateSource:!0})}_updateMarker(v){if(v){const d=new a.aU(v.coords.longitude,v.coords.latitude);this._accuracyCircleMarker.setLngLat(d).addTo(this._map),this._userLocationDotMarker.setLngLat(d).addTo(this._map),this._accuracy=v.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()}_updateCircleRadius(){const v=this._map.transform,d=a.bU(1,v._center.lat)*v.worldSize,g=Math.ceil(2*this._accuracy*d);this._circleElement.style.width=`${g}px`,this._circleElement.style.height=`${g}px`}_onZoom(){this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}_updateMarkerRotation(){this._userLocationDotMarker&&typeof this._heading=="number"?(this._userLocationDotMarker.setRotation(this._heading),this._userLocationDotMarker.addClassName("mapboxgl-user-location-show-heading")):(this._userLocationDotMarker.removeClassName("mapboxgl-user-location-show-heading"),this._userLocationDotMarker.setRotation(0))}_onError(v){if(this._map){if(this._clearRequestTimeout(),this.options.trackUserLocation)if(v.code===1){this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const d=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.setAttribute("aria-label",d),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",d),this._geolocationWatchID!==void 0&&this._clearWatch()}else{if(v.code===3&&this._noTimeout)return;this._setErrorState()}this._watchState!=="OFF"&&this.options.showUserLocation&&this._userLocationDotMarker.addClassName("mapboxgl-user-location-dot-stale"),this.fire(new a.C("error",{code:v.code,message:v.message,PERMISSION_DENIED:v.PERMISSION_DENIED,POSITION_UNAVAILABLE:v.POSITION_UNAVAILABLE,TIMEOUT:v.TIMEOUT})),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_startRequestTimeout(){this._clearRequestTimeout();const v=this.options.positionOptions.timeout;v&&(this._requestTimeoutId=window.setTimeout(()=>{this._onError({code:3,message:"Geolocation request timed out"})},v))}_clearRequestTimeout(){this._requestTimeoutId!==void 0&&(clearTimeout(this._requestTimeoutId),this._requestTimeoutId=void 0)}_setupUI(v){if(this._map!==void 0){if(this._container.addEventListener("contextmenu",d=>d.preventDefault()),this._geolocateButton=C("button","mapboxgl-ctrl-geolocate",this._container),C("span","mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",v===!1){a.w("Geolocation support is not available so the GeolocateControl will be disabled.");const d=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.setAttribute("aria-label",d),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",d)}else{const d=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.setAttribute("aria-label",d),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",d)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=C("div","mapboxgl-user-location"),this._dotElement.appendChild(C("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(C("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new Du({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=C("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new Du({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onZoom)),this._geolocateButton.addEventListener("click",this.trigger.bind(this)),this._setup=!0,this.options.showButton||(this._container.style.display="none"),this.options.trackUserLocation&&this._map.on("movestart",d=>{d.geolocateSource||this._watchState!=="ACTIVE_LOCK"||d.originalEvent&&d.originalEvent.type==="resize"||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this.fire(new a.C("trackuserlocationend")))})}}_onDeviceOrientation(v){this._userLocationDotMarker&&(v.webkitCompassHeading?this._heading=v.webkitCompassHeading:v.absolute===!0&&(this._heading=-1*v.alpha),this._updateMarkerRotationThrottled())}trigger(){if(!this._setup)return a.w("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case"OFF":this._watchState="WAITING_ACTIVE",this.fire(new a.C("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":this._numberOfWatches--,this._noTimeout=!1,this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this.fire(new a.C("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new a.C("trackuserlocationstart"))}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"BACKGROUND":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background");break;case"BACKGROUND_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error")}if(this._watchState==="OFF"&&this._geolocationWatchID!==void 0)this._clearWatch();else if(this._geolocationWatchID===void 0){let v;this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),this._numberOfWatches++,this._numberOfWatches>1?(v={maximumAge:6e5,timeout:0},this._noTimeout=!0):(v=this.options.positionOptions,this._noTimeout=!1),this._geolocationWatchID=this.options.geolocation.watchPosition(this._onSuccess,this._onError,v),this._startRequestTimeout(),this.options.showUserHeading&&this._addDeviceOrientationListener()}}else this.options.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._startRequestTimeout(),this._timeoutId=window.setTimeout(this._finish,1e4);return!0}setFollowUserLocation(v){return this.options.followUserLocation=v??x_.followUserLocation,this.options.trackUserLocation&&this._watchState!=="OFF"&&(this.options.followUserLocation?this._watchState!=="BACKGROUND"&&this._watchState!=="BACKGROUND_ERROR"||(this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new a.C("trackuserlocationstart"))):this._watchState!=="ACTIVE_LOCK"&&this._watchState!=="ACTIVE_ERROR"||(this._watchState="BACKGROUND",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"),this.fire(new a.C("trackuserlocationend")))),this}_addDeviceOrientationListener(){const v=()=>{const d="ondeviceorientationabsolute"in window?"deviceorientationabsolute":"deviceorientation";window.addEventListener(d,this._onDeviceOrientation)};typeof DeviceOrientationEvent.requestPermission=="function"?DeviceOrientationEvent.requestPermission().then(d=>{d==="granted"&&v()}).catch(console.error):v()}_clearWatch(){this._clearRequestTimeout(),this.options.geolocation.clearWatch(this._geolocationWatchID),window.removeEventListener("deviceorientation",this._onDeviceOrientation),window.removeEventListener("deviceorientationabsolute",this._onDeviceOrientation),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},AttributionControl:Yj,ScaleControl:class{constructor(v={}){this.options=Object.assign({},wa,v),a.aZ(["_update","_setScale","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_update(){const v=this.options.maxWidth||100,d=this._map,g=d._containerHeight/2,S=d._containerWidth/2-v/2,j=d.unproject([S,g]),R=d.unproject([S+v,g]),L=j.distanceTo(R);if(this.options.unit==="imperial"){const F=3.2808*L;F>5280?this._setScale(v,F/5280,"mile"):this._setScale(v,F,"foot")}else this.options.unit==="nautical"?this._setScale(v,L/1852,"nautical-mile"):L>=1e3?this._setScale(v,L/1e3,"kilometer"):this._setScale(v,L,"meter")}_setScale(v,d,g){this._map._requestDomTask(()=>{const S=function(R){const L=Math.pow(10,`${Math.floor(R)}`.length-1);let F=R/L;return F=F>=10?10:F>=5?5:F>=3?3:F>=2?2:F>=1?1:function(z){const W=Math.pow(10,Math.ceil(-Math.log(z)/Math.LN10));return Math.round(z*W)/W}(F),L*F}(d),j=S/d;this._container.innerHTML=g!=="nautical-mile"?new Intl.NumberFormat(this._language,{style:"unit",unitDisplay:"short",unit:g}).format(S):`${S} ${Ou[g]}`,this._container.style.width=v*j+"px"})}onAdd(v){return this._map=v,this._language=v.getLanguage(),this._container=C("div","mapboxgl-ctrl mapboxgl-ctrl-scale",v.getContainer()),this._container.dir="auto",this._map.on("move",this._update),this._update(),this._container}onRemove(){this._container.remove(),this._map.off("move",this._update),this._map=void 0}_setLanguage(v){this._language=v,this._update()}setUnit(v){this.options.unit=v,this._update()}},FullscreenControl:class{constructor(v={}){this._fullscreen=!1,v&&v.container&&(v.container instanceof HTMLElement?this._container=v.container:a.w("Full screen control 'container' must be a DOM element.")),a.aZ(["_onClickFullscreen","_changeIcon"],this),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onwebkitfullscreenchange"in document&&(this._fullscreenchange="webkitfullscreenchange")}onAdd(v){return this._map=v,this._container||(this._container=this._map.getContainer()),this._controlContainer=C("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._controlContainer.style.display="none",a.w("This device does not support fullscreen mode.")),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,document.removeEventListener(this._fullscreenchange,this._changeIcon)}_checkFullscreenSupport(){return!(!document.fullscreenEnabled&&!document.webkitFullscreenEnabled)}_setupUI(){const v=this._fullscreenButton=C("button","mapboxgl-ctrl-fullscreen",this._controlContainer);C("span","mapboxgl-ctrl-icon",v).setAttribute("aria-hidden","true"),v.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),document.addEventListener(this._fullscreenchange,this._changeIcon)}_updateTitle(){const v=this._getTitle();this._fullscreenButton.setAttribute("aria-label",v),this._fullscreenButton.firstElementChild&&this._fullscreenButton.firstElementChild.setAttribute("title",v)}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_changeIcon(){(document.fullscreenElement||document.webkitFullscreenElement)===this._container!==this._fullscreen&&(this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("mapboxgl-ctrl-shrink"),this._fullscreenButton.classList.toggle("mapboxgl-ctrl-fullscreen"),this._updateTitle())}_onClickFullscreen(){this._isFullscreen()?document.exitFullscreen?document.exitFullscreen():document.webkitCancelFullScreen&&document.webkitCancelFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen&&this._container.webkitRequestFullscreen()}},IndoorControl:class{constructor(){a.aZ(["_onIndoorUpdate","_onStyleData","_scrollUp","_scrollDown","_toggleIndoor"],this),this._visibleFloorStart=0,this._lastSelectedFloorId=null}onAdd(v){return this._map=v,this._container=C("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.style.display="none",this._map.on("styledata",this._onStyleData),this._updateConnection(),this._container}_onStyleData(){this._updateConnection()}_updateConnection(){if(this._map&&this._map.style&&this._map.style.indoorManager){const v=this._map.style.indoorManager;v.off("selector-update",this._onIndoorUpdate),v.on("selector-update",this._onIndoorUpdate),this._onIndoorUpdate(v.getControlState())}}_createButton(v,d){const g=C("button",v,this._container);return g.type="button",g.addEventListener("click",d),g}_setButtonTitle(v,d){v.setAttribute("aria-label",d),v.textContent=d}onRemove(){this._container&&this._container.remove(),this._map&&(this._map.off("styledata",this._onStyleData),this._map.style&&this._map.style.indoorManager.off("selector-update",this._onIndoorUpdate),this._map=null)}getDefaultPosition(){return"top-right"}_onIndoorUpdate(v){if(!v||!v.floors||v.floors.length===0)return this._model=v,void(this._container.style.display="none");const d=this._model;this._model=v,this._container.style.display="inline-block";const g=!d||d.floors.length!==v.floors.length||d.floors.some((S,j)=>S.id!==v.floors[j].id);if(g&&(this._visibleFloorStart=0,this._lastSelectedFloorId=null),v.selectedFloorId){if(v.selectedFloorId!==this._lastSelectedFloorId||g){const S=v.floors.findIndex(j=>j.id===v.selectedFloorId);if(S!==-1){const j=v.floors.length;let R,L;j<=5?(R=0,L=j-1):this._visibleFloorStart===0?(R=0,L=3):this._visibleFloorStart>=j-3?(R=j-3-1,L=j-1):(R=this._visibleFloorStart,L=this._visibleFloorStart+3-1),SL&&(this._visibleFloorStart=S-2)}}this._lastSelectedFloorId=v.selectedFloorId}this._render()}_render(){if(!this._container||!this._model||!this._model.floors)return;this._container.innerHTML="";const v=this._createButton("mapboxgl-ctrl-indoor-toggle",this._toggleIndoor);C("span","mapboxgl-ctrl-icon",v).setAttribute("aria-hidden","true"),this._model.activeFloorsVisible||v.classList.add("mapboxgl-ctrl-level-button-selected"),this._container.appendChild(v);const d=this._model.floors,g=d.length;if(g<=5)return void d.forEach(L=>this._createFloorButton(L));const S=this._visibleFloorStart===0,j=this._visibleFloorStart>=g-3;if(S)this._createFloorButton(d[0]);else{const L=this._createButton("mapboxgl-ctrl-arrow-up",this._scrollUp);C("span","mapboxgl-ctrl-icon",L).setAttribute("aria-hidden","true"),this._container.appendChild(L)}let R=[];if(R=S?d.slice(1,4):j?d.slice(this._visibleFloorStart-1,this._visibleFloorStart+3-1):d.slice(this._visibleFloorStart,this._visibleFloorStart+3),R.forEach(L=>this._createFloorButton(L)),j)this._createFloorButton(d[g-1]);else{const L=this._createButton("mapboxgl-ctrl-arrow-down",this._scrollDown);C("span","mapboxgl-ctrl-icon",L).setAttribute("aria-hidden","true"),this._container.appendChild(L)}}_createFloorButton(v){const d=this._createButton("mapboxgl-ctrl-level-button",()=>{const R=v.id;this._model&&this._model.selectedFloorId===R&&this._model.activeFloorsVisible||this._map&&(this._model&&!this._model.activeFloorsVisible&&this._map.style&&this._map.style.indoorManager&&this._map.style.indoorManager.setActiveFloorsVisibility(!0),this._map._selectIndoorFloor(R))}),g=(v.name||"").trim(),S=v.zIndex.toString(),j=g?Array.from(g).slice(0,3).join(""):S;this._setButtonTitle(d,j),this._model&&this._model.activeFloorsVisible&&v.id===this._model.selectedFloorId&&d.classList.add("mapboxgl-ctrl-level-button-selected"),this._container&&this._container.appendChild(d)}_toggleIndoor(){this._map&&this._map.style&&this._map.style.indoorManager&&this._model&&this._model.activeFloorsVisible&&this._map.style.indoorManager.setActiveFloorsVisibility(!1)}_scrollUp(){if(this._visibleFloorStart>0){this._visibleFloorStart--,this._visibleFloorStart===1&&(this._visibleFloorStart=0);const v=this._model&&this._model.floors||[];if(v.length>3){const d=v.length-3;this._visibleFloorStart===d-1&&(this._visibleFloorStart=d-2)}this._render()}}_scrollDown(){if(this._model&&this._model.floors){const v=this._model.floors.length-3;this._visibleFloorStartv&&(this._visibleFloorStart=v),this._render())}}},Popup:class extends a.E{constructor(v){super(),this.options=Object.assign(Object.create(__),v),this._altitude=this.options.altitude,a.aZ(["_update","_onClose","remove","_onMouseEvent"],this),this._classList=new Set(v&&v.className?v.className.trim().split(/\s+/):[])}addTo(v){return this._map&&this.remove(),this._map=v,this.options.closeOnClick&&v.on("preclick",this._onClose),this.options.closeOnMove&&v.on("move",this._onClose),v.on("remove",this.remove),this._update(),v._addPopup(this),this._focusFirstElement(),this._trackPointer?(v.on("mousemove",this._onMouseEvent),v.on("mouseup",this._onMouseEvent),v._canvasContainer.classList.add("mapboxgl-track-pointer")):v.on("move",this._update),this.fire(new a.C("open")),this}isOpen(){return!!this._map}remove(){this._content&&this._content.remove(),this._container&&(this._container.remove(),this._container=void 0);const v=this._map;return v&&(v.off("move",this._update),v.off("move",this._onClose),v.off("preclick",this._onClose),v.off("click",this._onClose),v.off("remove",this.remove),v.off("mousemove",this._onMouseEvent),v.off("mouseup",this._onMouseEvent),v.off("drag",this._onMouseEvent),v._canvasContainer&&v._canvasContainer.classList.remove("mapboxgl-track-pointer"),v._removePopup(this),this._map=void 0),this.fire(new a.C("close")),this}getLngLat(){return this._lngLat}setLngLat(v){this._lngLat=a.aU.convert(v),this._pos=null,this._trackPointer=!1,this._update();const d=this._map;return d&&(d.on("move",this._update),d.off("mousemove",this._onMouseEvent),d._canvasContainer.classList.remove("mapboxgl-track-pointer")),this}getAltitude(){return this._altitude}setAltitude(v){return this._altitude=v,this._update(),this}trackPointer(){this._trackPointer=!0,this._pos=null,this._update();const v=this._map;return v&&(v.off("move",this._update),v.on("mousemove",this._onMouseEvent),v.on("drag",this._onMouseEvent),v._canvasContainer.classList.add("mapboxgl-track-pointer")),this}getElement(){return this._container}setText(v){return this.setDOMContent(document.createTextNode(v))}setHTML(v){const d=document.createDocumentFragment(),g=document.createElement("body");let S;for(g.innerHTML=v;S=g.firstChild,S;)d.appendChild(S);return this.setDOMContent(d)}getMaxWidth(){return this._container&&this._container.style.maxWidth}setMaxWidth(v){return this.options.maxWidth=v,this._update(),this}setDOMContent(v){let d=this._content;if(d)for(;d.hasChildNodes();)d.firstChild&&d.removeChild(d.firstChild);else d=this._content=C("div","mapboxgl-popup-content",this._container||void 0);if(d.appendChild(v),this.options.closeButton){const g=this._closeButton=C("button","mapboxgl-popup-close-button",d);g.type="button",g.setAttribute("aria-label","Close popup"),g.innerHTML='',g.addEventListener("click",this._onClose)}return this._update(),this._focusFirstElement(),this}addClassName(v){return this._classList.add(v),this._updateClassList(),this}removeClassName(v){return this._classList.delete(v),this._updateClassList(),this}setOffset(v){return this.options.offset=v,this._update(),this}toggleClassName(v){let d;return this._classList.delete(v)?d=!1:(this._classList.add(v),d=!0),this._updateClassList(),d}_onMouseEvent(v){this._update(v.point)}_getAnchor(v){if(this.options.anchor)return this.options.anchor;const d=this._map,g=this._container,S=this._pos;if(!d||!g||!S)return"bottom";const j=g.offsetWidth,R=g.offsetHeight,L=S.xd.transform.width-j/2;if(S.y+vd.transform.height-R){if(L)return"bottom-left";if(F)return"bottom-right"}return L?"left":F?"right":"bottom"}_updateClassList(){const v=this._container;if(!v)return;const d=[...this._classList];d.push("mapboxgl-popup"),this._anchor&&d.push(`mapboxgl-popup-anchor-${this._anchor}`),this._trackPointer&&d.push("mapboxgl-popup-track-pointer"),v.className=d.join(" ")}_update(v){const d=this._map,g=this._content;if(!d||!this._lngLat&&!this._trackPointer||!g)return;let S=this._container;if(S||(S=this._container=C("div","mapboxgl-popup",d.getContainer()),this._tip=C("div","mapboxgl-popup-tip",S),S.appendChild(g)),this.options.maxWidth&&S.style.maxWidth!==this.options.maxWidth&&(S.style.maxWidth=this.options.maxWidth),d.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=Xj(this._lngLat,this._pos,d.transform)),!this._trackPointer||v){const j=this._pos=this._trackPointer&&v instanceof a.P?v:d.project(this._lngLat,this._altitude),R=_w(this.options.offset),L=this._anchor=this._getAnchor(R.y),F=_w(this.options.offset,L),z=j.add(F).round();d._requestDomTask(()=>{this._container&&L&&(this._container.style.transform=`${y_[L]} translate(${z.x}px,${z.y}px)`)})}if(!this._marker&&d._showingGlobe()){const j=a.e$(d.transform,this._lngLat)?0:1;this._setOpacity(j)}this._updateClassList()}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const v=this._container.querySelector(vB);v&&v.focus()}_onClose(){this.remove()}_setOpacity(v){this._container&&(this._container.style.opacity=`${v}`),this._content&&(this._content.style.pointerEvents=v?"auto":"none")}},Marker:Du,Style:Ru,LngLat:a.aU,LngLatBounds:a.aK,Point:a.P,MercatorCoordinate:a.ag,FreeCameraOptions:M0,Evented:a.E,config:a.g,prewarm:function(){yn().acquire(ar)},clearPrewarmedResources:function(){const v=At;v&&(v.isPreloaded()&&v.numActive()===1?(v.release(ar),At=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},get accessToken(){return a.g.ACCESS_TOKEN},set accessToken(v){a.g.ACCESS_TOKEN=v},get baseApiUrl(){return a.g.API_URL},set baseApiUrl(v){a.g.API_URL=v},get workerCount(){return Wt.workerCount},set workerCount(v){Wt.workerCount=v},get maxParallelImageRequests(){return a.g.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(v){a.g.MAX_PARALLEL_IMAGE_REQUESTS=v},clearStorage(v){a.f7(v)},get workerUrl(){return Tt.workerUrl},set workerUrl(v){Tt.workerUrl=v},get workerClass(){return Tt.workerClass},set workerClass(v){Tt.workerClass=v},get workerParams(){return Tt.workerParams},set workerParams(v){Tt.workerParams=v},get dracoUrl(){return a.f6()},set dracoUrl(v){a.g.DRACO_URL=a.o.resolveURL(v)},get meshoptUrl(){return a.f5()},set meshoptUrl(v){const d=a.o.resolveURL(v);a.g.MESHOPT_URL=d,a.g.MESHOPT_SIMD_URL=d},get buildingGenUrl(){return a.f4()},set buildingGenUrl(v){a.g.BUILDING_GEN_URL=a.o.resolveURL(v)},setNow:a.o.setNow,restoreNow:a.o.restoreNow}});var c=s;return c})})(F1e);var ntt=F1e.exports;const yh=bi(ntt),gie={coming_soon:"#3B82F6",office_exclusive:"#6366F1",temp_off_market:"#D97706",withdrawn:"#64748B",pre_market:"#06B6D4",active:"#10B981",price_improvement:"#F97316",under_contract:"#8B5CF6",sold:"#6B7280"},yie={coming_soon:"Coming Soon",office_exclusive:"Office Exclusive",temp_off_market:"Temporarily Off Market",withdrawn:"Withdrawn",pre_market:"Pre-Market",active:"Active",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"};function stt(t){return t>=1e6?`$${(t/1e6).toFixed(1)}M`:`$${(t/1e3).toFixed(0)}K`}function itt({listings:t,isLoading:e}){const r=ra(),n=N.useRef(null),s=N.useRef(null),o=N.useRef([]),[c,a]=N.useState(""),[f,m]=N.useState(!0);return N.useEffect(()=>{(async()=>{m(!0);try{const{data:w}=await Ce.from("settings").select("value").eq("key","mapbox_public_token").maybeSingle();w!=null&&w.value&&a(w.value)}catch(w){console.error("Error fetching mapbox token:",w)}m(!1)})()},[]),N.useEffect(()=>{if(!n.current||!c||s.current)return;yh.accessToken=c;const _=t.filter(A=>A.latitude!=null&&A.longitude!=null);let w=[-98.5795,39.8283],E=4;if(_.length>0){const A=_.reduce((I,M)=>I+M.longitude,0)/_.length,C=_.reduce((I,M)=>I+M.latitude,0)/_.length;w=[A,C],E=_.length===1?12:10}return s.current=new yh.Map({container:n.current,style:"mapbox://styles/mapbox/light-v11",zoom:E,center:w}),s.current.addControl(new yh.NavigationControl,"top-right"),()=>{var A;(A=s.current)==null||A.remove(),s.current=null}},[c]),N.useEffect(()=>{if(!s.current||!c)return;o.current.forEach(w=>w.remove()),o.current=[];const _=t.filter(w=>w.latitude!=null&&w.longitude!=null);if(_.forEach(w=>{var U,q,H;const E=gie[w.status]||"#10B981",A=((U=w.photos)==null?void 0:U.find(K=>K.is_primary))||((q=w.photos)==null?void 0:q[0]),I=window.location.hostname==="listings.relevelup.com"||window.location.hostname.startsWith("listings.")?`/${w.slug||w.id}`:`/public/listing/${w.slug||w.id}`,M=document.createElement("div");M.className="cursor-pointer",M.innerHTML=`
`;const D=new yh.Popup({offset:25,closeButton:!0,maxWidth:"280px"}).setHTML(`
${A!=null&&A.photo_url?``:""}
${stt(w.price)}
${w.property_address||""}
${w.city}, ${w.state}
${yie[w.status]||w.status} ${w.bedrooms?`${w.bedrooms} bed`:""} ${w.bathrooms?`${w.bathrooms} bath`:""}
${(H=w.agent)!=null&&H.name?`
Listed by ${w.agent.name}
`:""}
Click to view details →
`),B=new yh.Marker(M).setLngLat([w.longitude,w.latitude]).setPopup(D).addTo(s.current);o.current.push(B)}),_.length>1){const w=new yh.LngLatBounds;_.forEach(E=>w.extend([E.longitude,E.latitude])),s.current.fitBounds(w,{padding:60,maxZoom:13})}else _.length===1&&s.current.flyTo({center:[_[0].longitude,_[0].latitude],zoom:12})},[t,c]),N.useEffect(()=>(window.__navigateToPublicListing__=_=>{r(_)},()=>{delete window.__navigateToPublicListing__}),[r]),f||e?i.jsx(jl,{className:"w-full h-[500px] rounded-lg"}):!c||t.filter(_=>_.latitude!=null&&_.longitude!=null).length===0?null:i.jsxs("div",{className:"space-y-3",children:[i.jsx("div",{className:"flex flex-wrap items-center gap-3 text-sm",children:Object.entries(gie).map(([_,w])=>i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsx("div",{className:"w-3 h-3 rounded-full border-2 border-white shadow",style:{background:w}}),i.jsx("span",{className:"text-xs text-gray-600",children:yie[_]})]},_))}),i.jsx("div",{ref:n,className:"w-full h-[500px] rounded-lg shadow-lg border border-gray-200"})]})}const v6={active:"Active",coming_soon:"Coming Soon",office_exclusive:"Office Exclusive",temp_off_market:"Temporarily Off Market",withdrawn:"Withdrawn",pre_market:"Pre-Market",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"},att={single_family:"Single Family",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury",commercial:"Commercial",other:"Other"},i1="#0d0d0d",xie="#1a1a1a",oi="#c9a84c",By="#f0d78c";function $1e(){const[t,e]=N.useState(""),[r,n]=N.useState(!1),[s,o]=N.useState(!1),[c,a]=N.useState(!1),[f,m]=N.useState(-1),y=N.useRef(null),[_,w]=N.useState({status:"",propertyType:"",minPrice:"",maxPrice:""}),{data:E}=Fet(),A=N.useMemo(()=>{if(!E)return[];const oe=t.trim().toLowerCase(),de=[...E.cities.map(Ee=>({label:Ee.label,value:Ee.city,type:"city",count:Ee.count})),...E.neighborhoods.map(Ee=>({label:Ee.label,value:Ee.neighborhood,type:"neighborhood",count:Ee.count})),...E.zips.map(Ee=>({label:`ZIP ${Ee.label}`,value:Ee.zip,type:"zip",count:Ee.count}))];return(oe?de.filter(Ee=>Ee.label.toLowerCase().includes(oe)||Ee.value.toLowerCase().includes(oe)):de).slice(0,8)},[E,t]);N.useEffect(()=>{const oe=de=>{y.current&&!y.current.contains(de.target)&&a(!1)};return document.addEventListener("mousedown",oe),()=>document.removeEventListener("mousedown",oe)},[]);const{data:C,isLoading:I}=Oet({city:t||void 0,status:_.status||void 0,propertyType:_.propertyType||void 0,minPrice:_.minPrice?Number(_.minPrice):void 0,maxPrice:_.maxPrice?Number(_.maxPrice):void 0}),M=oe=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(oe),D=()=>{w({status:"",propertyType:"",minPrice:"",maxPrice:""}),e("")},B=t||_.status||_.propertyType||_.minPrice||_.maxPrice,U=typeof window<"u"&&(window.location.hostname==="listings.relevelup.com"||window.location.hostname.startsWith("listings.")),q=oe=>U?`/${oe.slug||oe.id}`:`/public/listing/${oe.slug||oe.id}`,{featured:H,restListings:K,luxeCount:Q,cities:J,activeCount:ee}=N.useMemo(()=>{const oe=C||[],de=oe.filter(Ze=>Ze.status==="active"),ye=de.length>0?de:oe,Ee=new Intl.DateTimeFormat("en-CA",{timeZone:"America/New_York",year:"numeric",month:"2-digit",day:"2-digit"}).format(new Date),[Le,Se,be]=Ee.split("-").map(Number),me=Math.floor(Date.UTC(Le,Se-1,be)/864e5),ke=ye.length>0?ye[me%ye.length]:void 0,Pe=oe.filter(Ze=>!ke||Ze.id!==ke.id),je=Array.from(new Set(oe.map(Ze=>Ze.city).filter(Boolean))).slice(0,8),xe=oe.filter(Ze=>(Ze.price||0)>=1e6).length,Ue=de.length;return{featured:ke,restListings:Pe,luxeCount:xe,cities:je,activeCount:Ue}},[C]);return i.jsxs(i.Fragment,{children:[i.jsxs(_o,{children:[i.jsx("title",{children:"LevelUp Listings — Curated Homes for Sale"}),i.jsx("meta",{name:"description",content:"A curated collection of exclusive properties from LevelUp real estate agents. Discover luxury homes, coming soon listings, and market-defining architecture."}),i.jsx("link",{rel:"canonical",href:"https://listings.relevelup.com"}),i.jsx("meta",{property:"og:title",content:"LevelUp Listings — Curated Homes for Sale"}),i.jsx("meta",{property:"og:description",content:"A curated collection of exclusive properties from LevelUp real estate agents."}),i.jsx("meta",{property:"og:type",content:"website"}),i.jsx("meta",{property:"og:url",content:"https://listings.relevelup.com"}),i.jsx("meta",{name:"twitter:card",content:"summary_large_image"}),i.jsx("script",{type:"application/ld+json",children:JSON.stringify({"@context":"https://schema.org","@type":"WebSite",name:"LevelUp Listings",url:"https://listings.relevelup.com"})})]}),i.jsxs("div",{className:"min-h-screen text-white",style:{backgroundColor:i1,fontFamily:"'Fira Sans', system-ui, sans-serif"},children:[i.jsx("style",{children:` .lu-serif { font-family: 'DM Serif Display', Georgia, serif; font-weight: 400; letter-spacing: -0.01em; } .lu-eyebrow { font-family: 'Fira Sans', sans-serif; font-weight: 500; letter-spacing: 0.3em; text-transform: uppercase; font-size: 11px; } .lu-gold { color: ${oi}; } .lu-gold-line { background: linear-gradient(90deg, transparent, ${oi}, transparent); } .lu-card-hover { transition: transform .6s cubic-bezier(.2,.7,.2,1), box-shadow .6s; } .lu-card-hover:hover { transform: translateY(-6px); } .lu-img-zoom { transition: transform 1.2s cubic-bezier(.2,.7,.2,1); } .group:hover .lu-img-zoom { transform: scale(1.06); } .lu-hero-title { animation: luFadeUp 1.1s cubic-bezier(.2,.7,.2,1) both; } .lu-hero-sub { animation: luFadeUp 1.1s .15s cubic-bezier(.2,.7,.2,1) both; } .lu-hero-search { animation: luFadeUp 1.1s .3s cubic-bezier(.2,.7,.2,1) both; } .lu-hero-stats { animation: luFadeUp 1.1s .45s cubic-bezier(.2,.7,.2,1) both; } @keyframes luFadeUp { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } } .lu-grain::after { content: ''; position: absolute; inset: 0; pointer-events: none; opacity: .18; background-image: url("data:image/svg+xml;utf8,"); } .lu-marquee { display: flex; gap: 3rem; animation: luMarquee 40s linear infinite; } @keyframes luMarquee { to { transform: translateX(-50%); } } .lu-input-dark { background: rgba(255,255,255,0.06) !important; border-color: rgba(201,168,76,0.25) !important; color: #fff !important; } .lu-input-dark::placeholder { color: rgba(255,255,255,0.5) !important; } `}),i.jsxs("header",{className:"sticky top-0 z-50 backdrop-blur-md",style:{backgroundColor:"rgba(13,13,13,0.75)",borderBottom:"1px solid rgba(201,168,76,0.15)"},children:[i.jsxs("div",{className:"max-w-7xl mx-auto px-6 py-4 flex items-center justify-between",children:[i.jsxs(Br,{to:"/",className:"flex items-center gap-3",children:[i.jsx("img",{src:pie,alt:"LevelUp",className:"h-7"}),i.jsx("span",{className:"hidden sm:inline-block h-5 w-px",style:{background:"rgba(255,255,255,0.2)"}}),i.jsx("span",{className:"hidden sm:inline lu-eyebrow lu-gold",children:"Listings"})]}),i.jsxs("nav",{className:"hidden md:flex items-center gap-8",children:[i.jsx("a",{href:"#featured",className:"text-sm text-white/80 hover:text-white transition",children:"Featured"}),i.jsx("a",{href:"#collection",className:"text-sm text-white/80 hover:text-white transition",children:"Collection"}),i.jsx("a",{href:"#map",className:"text-sm text-white/80 hover:text-white transition",children:"Map"}),i.jsx(Br,{to:"/home-value",className:"text-sm text-white/80 hover:text-white transition",children:"Home Value"}),i.jsx("a",{href:"https://relevelup.com",target:"_blank",rel:"noopener noreferrer",className:"text-sm px-4 py-2 rounded-full transition",style:{border:`1px solid ${oi}`,color:oi},children:"About LevelUp"})]}),i.jsx("button",{type:"button",onClick:()=>o(oe=>!oe),className:"md:hidden inline-flex items-center justify-center w-10 h-10 rounded-full",style:{border:`1px solid ${oi}`,color:oi},"aria-label":"Toggle menu","aria-expanded":s,children:s?i.jsx(Ci,{className:"w-5 h-5"}):i.jsx(ib,{className:"w-5 h-5"})})]}),s&&i.jsx("div",{className:"md:hidden border-t",style:{borderColor:"rgba(201,168,76,0.15)"},children:i.jsxs("nav",{className:"max-w-7xl mx-auto px-6 py-4 flex flex-col gap-1",children:[i.jsx("a",{href:"#featured",onClick:()=>o(!1),className:"py-3 text-white/85 hover:text-white transition border-b",style:{borderColor:"rgba(255,255,255,0.06)"},children:"Featured"}),i.jsx("a",{href:"#collection",onClick:()=>o(!1),className:"py-3 text-white/85 hover:text-white transition border-b",style:{borderColor:"rgba(255,255,255,0.06)"},children:"Collection"}),i.jsx("a",{href:"#map",onClick:()=>o(!1),className:"py-3 text-white/85 hover:text-white transition border-b",style:{borderColor:"rgba(255,255,255,0.06)"},children:"Map"}),i.jsx(Br,{to:"/home-value",onClick:()=>o(!1),className:"py-3 text-white/85 hover:text-white transition border-b",style:{borderColor:"rgba(255,255,255,0.06)"},children:"Home Value"}),i.jsx("a",{href:"https://relevelup.com",target:"_blank",rel:"noopener noreferrer",onClick:()=>o(!1),className:"mt-3 text-center text-sm px-4 py-3 rounded-full",style:{border:`1px solid ${oi}`,color:oi},children:"About LevelUp"})]})})]}),i.jsxs("section",{className:"relative overflow-hidden lu-grain",style:{minHeight:"92vh"},children:[i.jsxs("div",{className:"absolute inset-0",children:[i.jsx("img",{src:rtt,alt:"Luxury home at dusk",className:"w-full h-full object-cover",style:{filter:"brightness(0.55) contrast(1.05)"}}),i.jsx("div",{className:"absolute inset-0",style:{background:"linear-gradient(180deg, rgba(13,13,13,0.55) 0%, rgba(13,13,13,0.25) 40%, rgba(13,13,13,0.9) 100%)"}})]}),i.jsxs("div",{className:"relative max-w-7xl mx-auto px-6 pt-24 md:pt-32 pb-16 flex flex-col justify-center",style:{minHeight:"92vh"},children:[i.jsxs("div",{className:"max-w-4xl",children:[i.jsxs("div",{className:"lu-hero-title flex items-center gap-3 mb-6",children:[i.jsx("span",{className:"h-px w-10",style:{background:oi}}),i.jsx("span",{className:"lu-eyebrow lu-gold",children:"The LevelUp Collection"})]}),i.jsxs("h1",{className:"lu-serif lu-hero-title text-white text-5xl sm:text-6xl md:text-7xl lg:text-8xl leading-[1.02] mb-6",children:["Homes with a",i.jsx("br",{}),i.jsx("span",{className:"italic",style:{color:By},children:"quiet"})," kind of luxury."]}),i.jsx("p",{className:"lu-hero-sub text-white/75 text-lg md:text-xl max-w-2xl mb-10 leading-relaxed",children:"A private, hand-picked collection of properties represented by LevelUp agents — from waterfront estates to architectural landmarks and everything in between."}),i.jsxs("div",{className:"lu-hero-search max-w-3xl",ref:y,children:[i.jsxs("div",{className:"flex items-stretch rounded-full overflow-hidden shadow-2xl relative",style:{background:"rgba(13,13,13,0.7)",border:`1px solid ${oi}`,backdropFilter:"blur(12px)"},children:[i.jsxs("div",{className:"relative flex-1",children:[i.jsx(Dd,{className:"absolute left-6 top-1/2 -translate-y-1/2 h-5 w-5",style:{color:oi}}),i.jsx(Dr,{placeholder:"City, neighborhood, or ZIP",value:t,onChange:oe=>{e(oe.target.value),a(!0),m(-1)},onFocus:()=>a(!0),onKeyDown:oe=>{if(!(!c||A.length===0))if(oe.key==="ArrowDown")oe.preventDefault(),m(de=>Math.min(de+1,A.length-1));else if(oe.key==="ArrowUp")oe.preventDefault(),m(de=>Math.max(de-1,0));else if(oe.key==="Enter"&&f>=0){oe.preventDefault();const de=A[f];e(de.value),a(!1)}else oe.key==="Escape"&&a(!1)},className:"pl-16 h-16 text-base md:text-lg border-0 bg-transparent text-white placeholder:text-white/50 focus-visible:ring-0 rounded-none"})]}),i.jsxs("button",{onClick:()=>n(!r),className:"hidden sm:flex items-center gap-2 px-6 border-l text-sm text-white/80 hover:text-white transition",style:{borderColor:"rgba(201,168,76,0.3)"},children:[i.jsx(M4e,{className:"h-4 w-4"}),"Filters"]}),i.jsxs("button",{className:"px-8 flex items-center gap-2 font-medium transition hover:brightness-110",style:{background:oi,color:i1},onClick:()=>a(!1),children:[i.jsx(Dd,{className:"h-5 w-5"}),i.jsx("span",{className:"hidden md:inline",children:"Search"})]})]}),c&&A.length>0&&i.jsxs("div",{className:"mt-2 rounded-2xl overflow-hidden shadow-2xl animate-fade-in",style:{background:"rgba(13,13,13,0.96)",border:"1px solid rgba(201,168,76,0.35)",backdropFilter:"blur(12px)"},children:[i.jsx("div",{className:"px-5 pt-3 pb-2 text-[10px] tracking-[0.2em] uppercase",style:{color:oi},children:"Suggestions"}),i.jsx("ul",{className:"max-h-80 overflow-y-auto",children:A.map((oe,de)=>i.jsx("li",{children:i.jsxs("button",{type:"button",onMouseEnter:()=>m(de),onClick:()=>{e(oe.value),a(!1)},className:"w-full flex items-center justify-between gap-3 px-5 py-3 text-left transition",style:{background:f===de?"rgba(201,168,76,0.12)":"transparent"},children:[i.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[oe.type==="city"&&i.jsx(ui,{className:"h-4 w-4 shrink-0",style:{color:oi}}),oe.type==="neighborhood"&&i.jsx(Ja,{className:"h-4 w-4 shrink-0",style:{color:oi}}),oe.type==="zip"&&i.jsx(ea,{className:"h-4 w-4 shrink-0",style:{color:oi}}),i.jsx("span",{className:"text-white/90 truncate",children:oe.label})]}),i.jsxs("span",{className:"text-xs text-white/50 shrink-0",children:[oe.count," ",oe.count===1?"listing":"listings"]})]})},`${oe.type}-${oe.value}-${de}`))})]}),c&&t.trim()&&A.length===0&&i.jsx("div",{className:"mt-2 rounded-2xl px-5 py-4 text-sm text-white/70",style:{background:"rgba(13,13,13,0.96)",border:"1px solid rgba(201,168,76,0.25)"},children:"No matches yet — try a nearby city or ZIP."}),r&&i.jsxs("div",{className:"mt-4 p-6 rounded-2xl grid sm:grid-cols-2 md:grid-cols-4 gap-4 animate-fade-in",style:{background:"rgba(26,26,26,0.9)",border:"1px solid rgba(201,168,76,0.25)"},children:[i.jsxs("div",{children:[i.jsx("label",{className:"lu-eyebrow text-white/60 mb-2 block",children:"Status"}),i.jsxs(Ia,{value:_.status||"all",onValueChange:oe=>w({..._,status:oe==="all"?"":oe}),children:[i.jsx(_a,{className:"lu-input-dark",children:i.jsx(Pa,{})}),i.jsxs(va,{children:[i.jsx(gn,{value:"all",children:"Any status"}),Object.entries(v6).map(([oe,de])=>i.jsx(gn,{value:oe,children:de},oe))]})]})]}),i.jsxs("div",{children:[i.jsx("label",{className:"lu-eyebrow text-white/60 mb-2 block",children:"Type"}),i.jsxs(Ia,{value:_.propertyType||"all",onValueChange:oe=>w({..._,propertyType:oe==="all"?"":oe}),children:[i.jsx(_a,{className:"lu-input-dark",children:i.jsx(Pa,{})}),i.jsxs(va,{children:[i.jsx(gn,{value:"all",children:"Any type"}),Object.entries(att).map(([oe,de])=>i.jsx(gn,{value:oe,children:de},oe))]})]})]}),i.jsxs("div",{children:[i.jsx("label",{className:"lu-eyebrow text-white/60 mb-2 block",children:"Min Price"}),i.jsx(Dr,{type:"number",placeholder:"No min",value:_.minPrice,onChange:oe=>w({..._,minPrice:oe.target.value}),className:"lu-input-dark"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"lu-eyebrow text-white/60 mb-2 block",children:"Max Price"}),i.jsx(Dr,{type:"number",placeholder:"No max",value:_.maxPrice,onChange:oe=>w({..._,maxPrice:oe.target.value}),className:"lu-input-dark"})]}),B&&i.jsx("div",{className:"sm:col-span-2 md:col-span-4 flex justify-end",children:i.jsxs(Lt,{variant:"ghost",size:"sm",onClick:D,className:"text-white/70 hover:text-white gap-1",children:[i.jsx(Ci,{className:"h-4 w-4"})," Clear all"]})})]})]}),i.jsx("div",{className:"lu-hero-stats mt-14 grid grid-cols-3 gap-6 max-w-2xl",children:[{label:"Listings",value:((C==null?void 0:C.length)??0).toString()},{label:"Active Now",value:ee.toString()},{label:"Luxury $1M+",value:Q.toString()}].map(oe=>i.jsxs("div",{children:[i.jsx("div",{className:"lu-serif text-4xl md:text-5xl",style:{color:By},children:oe.value}),i.jsx("div",{className:"lu-eyebrow text-white/60 mt-1",children:oe.label})]},oe.label))})]}),i.jsxs("div",{className:"absolute bottom-6 left-1/2 -translate-x-1/2 flex flex-col items-center gap-2 text-white/60",children:[i.jsx("span",{className:"lu-eyebrow",children:"Scroll"}),i.jsx(Go,{className:"h-4 w-4 animate-bounce"})]})]})]}),J.length>0&&i.jsx("section",{className:"py-8 overflow-hidden",style:{background:xie,borderTop:"1px solid rgba(201,168,76,0.15)",borderBottom:"1px solid rgba(201,168,76,0.15)"},children:i.jsx("div",{className:"lu-marquee whitespace-nowrap",children:[...J,...J,...J].map((oe,de)=>i.jsxs("span",{className:"flex items-center gap-3 lu-serif text-2xl md:text-3xl text-white/40",children:[oe,i.jsx("span",{className:"h-1.5 w-1.5 rounded-full",style:{background:oi}})]},de))})}),H&&i.jsx("section",{id:"featured",className:"py-20 md:py-28",children:i.jsxs("div",{className:"max-w-7xl mx-auto px-6",children:[i.jsxs("div",{className:"flex items-end justify-between mb-10 md:mb-14",children:[i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[i.jsx(ki,{className:"h-4 w-4",style:{color:oi}}),i.jsx("span",{className:"lu-eyebrow lu-gold",children:"Today's Featured Residence"})]}),i.jsxs("h2",{className:"lu-serif text-4xl md:text-5xl lg:text-6xl",children:["Today's ",i.jsx("span",{className:"italic",style:{color:By},children:"standout"}),"."]})]}),i.jsx("div",{className:"hidden md:block h-px flex-1 mx-8 lu-gold-line"})]}),i.jsx(Br,{to:q(H),className:"group block",children:i.jsxs("div",{className:"grid lg:grid-cols-5 gap-6 lg:gap-10 items-stretch",children:[i.jsxs("div",{className:"lg:col-span-3 relative overflow-hidden rounded-2xl aspect-[4/3] bg-black",children:[(()=>{var de,ye;const oe=((de=H.photos)==null?void 0:de.find(Ee=>Ee.is_primary))||((ye=H.photos)==null?void 0:ye[0]);return oe?i.jsx("img",{src:oe.photo_url,alt:H.property_address||H.city,className:"w-full h-full object-cover lu-img-zoom"}):i.jsx("div",{className:"w-full h-full flex items-center justify-center",children:i.jsx(ea,{className:"h-16 w-16 text-white/20"})})})(),i.jsx("div",{className:"absolute top-5 left-5 px-4 py-1.5 rounded-full lu-eyebrow",style:{background:oi,color:i1},children:v6[H.status]||"Featured"})]}),i.jsxs("div",{className:"lg:col-span-2 flex flex-col justify-center",children:[i.jsxs("div",{className:"lu-eyebrow text-white/60 mb-4 flex items-center gap-2",children:[i.jsx(ui,{className:"h-3.5 w-3.5",style:{color:oi}}),H.city,H.state?`, ${H.state}`:""]}),H.property_address&&i.jsx("h3",{className:"lu-serif text-3xl md:text-4xl mb-4 leading-tight",children:H.property_address}),i.jsx("div",{className:"lu-serif text-5xl md:text-6xl mb-6",style:{color:By},children:M(H.price)}),i.jsxs("div",{className:"flex items-center gap-6 text-white/70 mb-8",children:[H.bedrooms&&i.jsxs("span",{className:"flex items-center gap-2",children:[i.jsx(UT,{className:"h-4 w-4",style:{color:oi}}),H.bedrooms," bd"]}),H.bathrooms&&i.jsxs("span",{className:"flex items-center gap-2",children:[i.jsx(o0,{className:"h-4 w-4",style:{color:oi}}),H.bathrooms," ba"]}),H.square_footage&&i.jsxs("span",{className:"flex items-center gap-2",children:[i.jsx(vH,{className:"h-4 w-4",style:{color:oi}}),H.square_footage.toLocaleString()," sf"]})]}),H.description&&i.jsx("p",{className:"text-white/60 leading-relaxed mb-8 line-clamp-4",children:H.description}),i.jsxs("div",{className:"inline-flex items-center gap-3 lu-eyebrow group-hover:gap-5 transition-all",style:{color:oi},children:["View Residence ",i.jsx(ji,{className:"h-4 w-4"})]})]})]})})]})}),i.jsx("section",{id:"collection",className:"py-20 md:py-28",style:{background:xie},children:i.jsxs("div",{className:"max-w-7xl mx-auto px-6",children:[i.jsxs("div",{className:"text-center mb-14",children:[i.jsxs("div",{className:"flex items-center justify-center gap-3 mb-4",children:[i.jsx("span",{className:"h-px w-10",style:{background:oi}}),i.jsx("span",{className:"lu-eyebrow lu-gold",children:"The Collection"}),i.jsx("span",{className:"h-px w-10",style:{background:oi}})]}),i.jsxs("h2",{className:"lu-serif text-4xl md:text-5xl lg:text-6xl mb-4",children:["Every home, ",i.jsx("span",{className:"italic",style:{color:By},children:"carefully considered"}),"."]}),i.jsx("p",{className:"text-white/60 max-w-2xl mx-auto",children:"Browse the full catalogue of LevelUp-represented properties. Filter, refine, and find the one that feels like yours."})]}),I?i.jsx("div",{className:"grid sm:grid-cols-2 lg:grid-cols-3 gap-8",children:[...Array(6)].map((oe,de)=>i.jsxs("div",{className:"space-y-3",children:[i.jsx(jl,{className:"aspect-[4/5] bg-white/5"}),i.jsx(jl,{className:"h-6 w-32 bg-white/5"}),i.jsx(jl,{className:"h-4 w-full bg-white/5"})]},de))}):K.length>0?i.jsx("div",{className:"grid sm:grid-cols-2 lg:grid-cols-3 gap-x-8 gap-y-14",children:K.map(oe=>{var ye,Ee,Le,Se,be;const de=((ye=oe.photos)==null?void 0:ye.find(me=>me.is_primary))||((Ee=oe.photos)==null?void 0:Ee[0]);return i.jsxs(Br,{to:q(oe),className:"group lu-card-hover block",children:[i.jsxs("div",{className:"relative aspect-[4/5] overflow-hidden bg-black mb-5 rounded-lg",children:[de?i.jsx("img",{src:de.photo_url,alt:oe.property_address||oe.city,className:"w-full h-full object-cover lu-img-zoom"}):i.jsx("div",{className:"w-full h-full flex items-center justify-center",children:i.jsx(ea,{className:"h-12 w-12 text-white/20"})}),i.jsx("div",{className:"absolute inset-0 opacity-0 group-hover:opacity-100 transition-opacity",style:{background:"linear-gradient(180deg, transparent 40%, rgba(13,13,13,0.85) 100%)"}}),i.jsx("div",{className:"absolute top-4 left-4 px-3 py-1 lu-eyebrow rounded-full",style:{background:"rgba(13,13,13,0.75)",color:oi,border:`1px solid ${oi}`},children:v6[oe.status]}),i.jsxs("div",{className:"absolute bottom-4 left-4 right-4 flex items-center gap-4 text-white/90 text-sm opacity-0 group-hover:opacity-100 translate-y-2 group-hover:translate-y-0 transition-all",children:[oe.bedrooms&&i.jsxs("span",{children:[oe.bedrooms," bd"]}),oe.bathrooms&&i.jsxs("span",{children:[oe.bathrooms," ba"]}),oe.square_footage&&i.jsxs("span",{children:[oe.square_footage.toLocaleString()," sf"]})]})]}),i.jsxs("div",{children:[i.jsxs("div",{className:"lu-eyebrow text-white/50 mb-2 flex items-center gap-2",children:[i.jsx(ui,{className:"h-3 w-3",style:{color:oi}}),oe.city,oe.state?`, ${oe.state}`:""]}),i.jsx("div",{className:"lu-serif text-2xl md:text-3xl mb-1",style:{color:By},children:M(oe.price)}),oe.property_address&&i.jsx("p",{className:"text-white/70 text-sm truncate",children:oe.property_address}),((Le=oe.agent)==null?void 0:Le.name)&&i.jsxs("p",{className:"text-white/40 text-xs mt-3 flex items-center gap-2",children:[i.jsx(Ja,{className:"h-3 w-3"}),oe.agent.name,(((Se=oe.agent.brokerage)==null?void 0:Se.name)||oe.agent.brokerage_name)&&i.jsxs("span",{className:"truncate",children:["· ",((be=oe.agent.brokerage)==null?void 0:be.name)||oe.agent.brokerage_name]})]})]})]},oe.id)})}):i.jsxs("div",{className:"text-center py-20",children:[i.jsx("div",{className:"w-20 h-20 mx-auto mb-6 rounded-full flex items-center justify-center",style:{border:`1px solid ${oi}`},children:i.jsx(ea,{className:"h-8 w-8",style:{color:oi}})}),i.jsx("h3",{className:"lu-serif text-2xl mb-2",children:"No listings match yet"}),i.jsx("p",{className:"text-white/60 mb-6",children:"Adjust your search — or check back soon for new arrivals."}),B&&i.jsx(Lt,{onClick:D,style:{background:oi,color:i1},className:"hover:brightness-110",children:"Clear filters"})]})]})}),C&&C.length>0&&i.jsx("section",{id:"map",className:"py-20 md:py-28",children:i.jsxs("div",{className:"max-w-7xl mx-auto px-6",children:[i.jsx("div",{className:"flex flex-col md:flex-row md:items-end md:justify-between gap-4 mb-10",children:i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[i.jsx("span",{className:"h-px w-10",style:{background:oi}}),i.jsx("span",{className:"lu-eyebrow lu-gold",children:"Explore"})]}),i.jsxs("h2",{className:"lu-serif text-4xl md:text-5xl",children:["Every listing, ",i.jsx("span",{className:"italic",style:{color:By},children:"on the map"}),"."]})]})}),i.jsx("div",{className:"rounded-2xl overflow-hidden",style:{border:"1px solid rgba(201,168,76,0.2)"},children:i.jsx(itt,{listings:C,isLoading:I})})]})}),i.jsxs("section",{className:"relative py-24 md:py-32 overflow-hidden lu-grain",children:[i.jsx("div",{className:"absolute inset-0",style:{background:`radial-gradient(ellipse at center, rgba(201,168,76,0.15) 0%, ${i1} 70%)`}}),i.jsxs("div",{className:"relative max-w-4xl mx-auto px-6 text-center",children:[i.jsxs("div",{className:"flex items-center justify-center gap-3 mb-6",children:[i.jsx("span",{className:"h-px w-10",style:{background:oi}}),i.jsx("span",{className:"lu-eyebrow lu-gold",children:"For Agents"}),i.jsx("span",{className:"h-px w-10",style:{background:oi}})]}),i.jsxs("h2",{className:"lu-serif text-4xl md:text-6xl mb-6 leading-tight",children:["Your listings deserve a",i.jsx("br",{}),i.jsx("span",{className:"italic",style:{color:By},children:"stage this good"}),"."]}),i.jsx("p",{className:"text-white/70 text-lg mb-10 max-w-2xl mx-auto",children:"Join LevelUp and get every listing published to this collection — with a cinematic microsite, lead capture, and marketing tools that do the heavy lifting."}),i.jsxs("a",{href:"https://relevelup.com",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-3 px-8 py-4 rounded-full font-medium transition hover:brightness-110",style:{background:oi,color:i1},children:["Explore LevelUp",i.jsx(ji,{className:"h-4 w-4"})]})]})]}),i.jsx("footer",{className:"py-14",style:{background:"#080808",borderTop:"1px solid rgba(201,168,76,0.15)"},children:i.jsxs("div",{className:"max-w-7xl mx-auto px-6 flex flex-col md:flex-row items-center justify-between gap-6",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("img",{src:pie,alt:"LevelUp",className:"h-6"}),i.jsx("span",{className:"h-4 w-px bg-white/20"}),i.jsx("span",{className:"lu-eyebrow lu-gold",children:"Listings"})]}),i.jsxs("p",{className:"text-white/40 text-sm",children:["© ",new Date().getFullYear()," LevelUp. All rights reserved."]}),i.jsx("a",{href:"https://relevelup.com",target:"_blank",rel:"noopener noreferrer",className:"text-white/60 hover:text-white text-sm transition",children:"relevelup.com →"})]})})]}),i.jsx(fet,{}),i.jsx(met,{})]})}const ott=Object.freeze(Object.defineProperty({__proto__:null,default:$1e},Symbol.toStringTag,{value:"Module"})),ltt=N.lazy(()=>Oe(()=>import("./PublicHomeValue-oV_z-qfP.js"),[]));function ctt(){const t=js(),e=window.location.hostname;if(!(e==="listings.relevelup.com"||e.startsWith("listings.")))return null;const n=t.pathname.slice(1);return!n||n===""?i.jsx($1e,{}):n==="home-value"||n==="whats-my-home-worth"?i.jsx(N.Suspense,{fallback:i.jsx("div",{}),children:i.jsx(ltt,{})}):n.startsWith("public/")?null:i.jsx(uK,{slugOverride:n})}const utt=N.lazy(()=>Oe(()=>import("./CommercialMarketplace-BB2B9NJ2.js"),[]));function dtt(){const e=js().pathname.slice(1);return e?e.startsWith("public/")?null:i.jsx(uK,{slugOverride:e}):i.jsx(N.Suspense,{fallback:i.jsx("div",{className:"min-h-screen bg-[#0a0d12]"}),children:i.jsx(utt,{})})}function aF({card:t,variant:e}){const r=t.brokerage_display_name||t.brokerage_logo_url,n=t.team_name||t.team_logo_url;if(!r&&!n)return null;const s={standard:{container:"bg-slate-50 border border-slate-100",text:"text-slate-600",subtext:"text-slate-400"},luxury:{container:"bg-[#1e2636] border border-[#c9a84c]/10",text:"text-[#e2e8f0]",subtext:"text-[#4a5568]"},bold:{container:"bg-gray-50 border border-gray-100",text:"text-[#1a1a2e]",subtext:"text-gray-400"},classic:{container:"bg-white border border-[#d4cfc5] shadow-sm",text:"text-[#1b3a4b]",subtext:"text-[#a0aec0]"}}[e];return i.jsx("div",{className:`rounded-2xl p-4 mb-6 ${s.container}`,children:i.jsxs("div",{className:`flex flex-col items-center gap-3 ${r&&n?"divide-y divide-current/10":""}`,children:[r&&i.jsxs("div",{className:"flex flex-col items-center gap-1.5 w-full",children:[t.brokerage_logo_url&&i.jsx("img",{src:t.brokerage_logo_url,alt:t.brokerage_display_name||"Brokerage",style:{height:`${t.brokerage_logo_size||56}px`},className:"max-w-[280px] object-contain"}),t.brokerage_display_name&&!t.brokerage_logo_url&&i.jsx("p",{className:`text-sm font-medium ${s.text}`,children:t.brokerage_display_name})]}),n&&i.jsxs("div",{className:`flex flex-col items-center gap-1.5 w-full ${r?"pt-3":""}`,children:[t.team_logo_url&&i.jsx("img",{src:t.team_logo_url,alt:t.team_name||"Team",style:{height:`${t.team_logo_size||56}px`},className:"max-w-[280px] object-contain"}),t.team_name&&!t.team_logo_url&&i.jsx("p",{className:`text-sm font-medium ${s.text}`,children:t.team_name})]})]})})}const htt=t=>mr({queryKey:["agent-card-public",t],queryFn:async()=>{if(!t)throw new Error("No slug provided");const{data:e,error:r}=await Ce.from("agent_cards").select("*").eq("slug",t).eq("is_published",!0).single();if(r)throw r;const{data:n}=await Ce.from("profiles").select("name, email, phone, brokerage_id").eq("id",e.user_id).single();let s=null;if(n!=null&&n.brokerage_id){const{data:a}=await Ce.from("brokerages").select("name").eq("id",n.brokerage_id).single();s=(a==null?void 0:a.name)||null}let o=null;try{const{data:a}=await Ce.from("profiles").select("avatar_url").eq("id",e.user_id).single();if(a!=null&&a.avatar_url)o=a.avatar_url;else{const{data:f}=await Ce.storage.from("avatars").list(`${e.user_id}`);if(f&&f.length>0){const{data:m}=Ce.storage.from("avatars").getPublicUrl(`${e.user_id}/${f[0].name}`);o=`${m.publicUrl}?t=${Date.now()}`}}}catch{}const c={...n||{name:null,email:null,phone:null,brokerage_id:null},email:e.display_email||(n==null?void 0:n.email)||null};return{...e,social_links:e.social_links||[],profile:c,brokerage_name:e.brokerage_display_name||s,avatar_url:o}},enabled:!!t}),ter=()=>mr({queryKey:["agent-cards-admin"],queryFn:async()=>{const{data:t,error:e}=await Ce.from("agent_cards").select("*").order("created_at",{ascending:!1});if(e)throw e;return t}}),rer=t=>mr({queryKey:["agent-card",t],queryFn:async()=>{if(!t)return null;const{data:e,error:r}=await Ce.from("agent_cards").select("*").eq("user_id",t).maybeSingle();if(r)throw r;return e},enabled:!!t}),ner=()=>{const t=jr();return kr({mutationFn:async e=>{const{data:r,error:n}=await Ce.from("agent_cards").insert(e).select().single();if(n)throw n;return r},onSuccess:()=>{t.invalidateQueries({queryKey:["agent-cards-admin"]}),t.invalidateQueries({queryKey:["agent-card"]}),$t.success("Agent card created")},onError:e=>$t.error(e.message)})},ser=()=>{const t=jr();return kr({mutationFn:async({id:e,...r})=>{const{data:n,error:s}=await Ce.from("agent_cards").update(r).eq("id",e).select().single();if(s)throw s;return n},onSuccess:(e,r)=>{t.invalidateQueries({queryKey:["agent-cards-admin"]}),t.invalidateQueries({queryKey:["agent-card"]}),$t.success("Agent card updated")},onError:e=>$t.error(e.message)})},ci=async(t,e,r,n)=>{const s=new URLSearchParams(window.location.search);await Ce.from("agent_card_interactions").insert({card_id:t,interaction_type:e,interaction_detail:r||null,referrer:document.referrer||null,user_agent:navigator.userAgent||null,utm_source:s.get("utm_source")||null,utm_medium:s.get("utm_medium")||null,utm_campaign:s.get("utm_campaign")||null,metadata:{}})},ftt=async(t,e)=>{const{error:r}=await Ce.from("agent_card_leads").insert({card_id:t,...e});if(r)throw r},ier=t=>mr({queryKey:["agent-card-analytics",t],queryFn:async()=>{if(!t)return null;const{data:e,error:r}=await Ce.from("agent_card_interactions").select("interaction_type, interaction_detail, created_at").eq("card_id",t).order("created_at",{ascending:!1}).limit(500);if(r)throw r;const{data:n,error:s}=await Ce.from("agent_card_leads").select("*").eq("card_id",t).order("created_at",{ascending:!1});if(s)throw s;const o=(e==null?void 0:e.filter(f=>f.interaction_type==="card_view").length)||0,c=(e==null?void 0:e.filter(f=>f.interaction_type==="button_click").length)||0,a=(e==null?void 0:e.filter(f=>f.interaction_type==="contact_saved").length)||0;return{views:o,clicks:c,saves:a,leads:n||[],interactions:e||[]}},enabled:!!t});function oF({open:t,onOpenChange:e,cardId:r,type:n,agentName:s}){const[o,c]=N.useState(""),[a,f]=N.useState(""),[m,y]=N.useState(""),[_,w]=N.useState(""),[E,A]=N.useState(""),[C,I]=N.useState(!1),M=async D=>{if(D.preventDefault(),!o.trim()){$t.error("Please enter your name");return}I(!0);try{await ftt(r,{lead_type:n,name:o.trim(),email:a.trim()||void 0,phone:m.trim()||void 0,message:E.trim()||void 0,intent:_||void 0}),ci(r,"lead_submitted",n),Ce.functions.invoke("card-lead-notify",{body:{cardId:r,leadType:n,name:o.trim(),email:a.trim()||void 0,phone:m.trim()||void 0,message:E.trim()||void 0,intent:_||void 0}}).catch(B=>console.error("Card lead notify failed:",B)),$t.success(n==="booking"?"Request sent! They'll be in touch soon.":n==="connect"?"Info shared! They'll be in touch soon.":"Referral submitted! Thank you."),e(!1),c(""),f(""),y(""),w(""),A("")}catch{$t.error("Something went wrong. Please try again.")}finally{I(!1)}};return i.jsx(Ha,{open:t,onOpenChange:e,children:i.jsxs(Ra,{className:"sm:max-w-md rounded-2xl",children:[i.jsxs(Ho,{children:[i.jsx(Co,{children:n==="booking"?"Book a Call":n==="connect"?"Connect with Me":"Refer a Friend"}),i.jsx(td,{children:n==="booking"?`Let ${s} know you'd like to connect.`:n==="connect"?`Share your info and ${s} will reach out.`:`Know someone who could use ${s}'s help?`})]}),i.jsxs("form",{onSubmit:M,className:"space-y-4",children:[i.jsxs("div",{children:[i.jsx(Fr,{htmlFor:"lead-name",children:"Name *"}),i.jsx(Dr,{id:"lead-name",value:o,onChange:D=>c(D.target.value),placeholder:"Your name",required:!0})]}),i.jsxs("div",{children:[i.jsx(Fr,{htmlFor:"lead-phone",children:"Phone"}),i.jsx(Dr,{id:"lead-phone",type:"tel",value:m,onChange:D=>y(D.target.value),placeholder:"(555) 123-4567"})]}),i.jsxs("div",{children:[i.jsx(Fr,{htmlFor:"lead-email",children:"Email"}),i.jsx(Dr,{id:"lead-email",type:"email",value:a,onChange:D=>f(D.target.value),placeholder:"you@example.com"})]}),n==="booking"&&i.jsxs("div",{children:[i.jsx(Fr,{htmlFor:"lead-intent",children:"I'm looking to..."}),i.jsxs(Ia,{value:_,onValueChange:w,children:[i.jsx(_a,{children:i.jsx(Pa,{placeholder:"Select one"})}),i.jsxs(va,{children:[i.jsx(gn,{value:"buy",children:"Buy a home"}),i.jsx(gn,{value:"sell",children:"Sell my home"}),i.jsx(gn,{value:"both",children:"Buy & Sell"}),i.jsx(gn,{value:"other",children:"Something else"})]})]})]}),n!=="connect"&&i.jsxs("div",{children:[i.jsx(Fr,{htmlFor:"lead-message",children:n==="referral"?"Tell us about them":"Message (optional)"}),i.jsx(Dr,{id:"lead-message",value:E,onChange:D=>A(D.target.value),placeholder:n==="referral"?"Their name, phone, situation...":"Anything you'd like us to know"})]}),i.jsx(Lt,{type:"submit",className:"w-full rounded-2xl",disabled:C,children:C?"Sending...":"Submit"})]})]})})}const mtt=t=>mr({queryKey:["card-blocks",t],queryFn:async()=>{if(!t)return[];const{data:e,error:r}=await Ce.from("card_blocks").select("*").eq("card_id",t).eq("is_visible",!0).order("sort_order",{ascending:!0});if(r)throw r;return e||[]},enabled:!!t}),aer=t=>mr({queryKey:["card-blocks-all",t],queryFn:async()=>{if(!t)return[];const{data:e,error:r}=await Ce.from("card_blocks").select("*").eq("card_id",t).order("sort_order",{ascending:!0});if(r)throw r;return e||[]},enabled:!!t}),oer=()=>{const t=jr();return kr({mutationFn:async e=>{const{data:r,error:n}=await Ce.from("card_blocks").insert(e).select().single();if(n)throw n;return r},onSuccess:(e,r)=>{t.invalidateQueries({queryKey:["card-blocks",r.card_id]}),t.invalidateQueries({queryKey:["card-blocks-all",r.card_id]}),$t.success("Block added")},onError:e=>$t.error(e.message)})},ler=()=>{const t=jr();return kr({mutationFn:async({id:e,...r})=>{const{data:n,error:s}=await Ce.from("card_blocks").update(r).eq("id",e).select().single();if(s)throw s;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["card-blocks"]}),t.invalidateQueries({queryKey:["card-blocks-all"]}),$t.success("Block updated")},onError:e=>$t.error(e.message)})},cer=()=>{const t=jr();return kr({mutationFn:async e=>{const{error:r}=await Ce.from("card_blocks").delete().eq("id",e);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["card-blocks"]}),t.invalidateQueries({queryKey:["card-blocks-all"]}),$t.success("Block removed")},onError:e=>$t.error(e.message)})};function ptt(t){const e=t.match(/(?:iframe\.mediadelivery\.net\/embed\/|video\.bunnycdn\.com\/play\/)(\d+)\/([a-f0-9-]+)/i);return e?`https://iframe.mediadelivery.net/embed/${e[1]}/${e[2]}?autoplay=false&responsive=true`:(t.includes("iframe.mediadelivery.net"),t)}function gtt(t){const e=t.match(/(?:youtube\.com\/watch\?v=|youtu\.be\/|youtube\.com\/embed\/)([a-zA-Z0-9_-]{11})/);return e?`https://www.youtube.com/embed/${e[1]}`:null}const ytt={standard:"rounded-2xl overflow-hidden mb-6 bg-slate-100",luxury:"rounded-xl overflow-hidden mb-6 bg-[#1e2636] border border-[#c9a84c]/10",bold:"rounded-2xl overflow-hidden mb-6",classic:"rounded-lg overflow-hidden mb-6 border border-[#d4cfc5] shadow-sm"};function xtt({block:t,variant:e}){const r=t.config;if(!r.video_url)return null;const n=r.video_url.includes("mediadelivery.net")||r.video_url.includes("bunnycdn.com"),s=gtt(r.video_url),o=n||!!s,c=n?ptt(r.video_url):s||r.video_url;return i.jsx("div",{className:ytt[e],children:o?i.jsx("div",{style:{position:"relative",paddingTop:"56.25%"},children:i.jsx("iframe",{src:c,loading:"lazy",style:{border:0,position:"absolute",top:0,left:0,width:"100%",height:"100%"},allow:"accelerometer; gyroscope; autoplay; encrypted-media; picture-in-picture",allowFullScreen:!0})}):i.jsx("video",{src:r.video_url,controls:!0,className:"w-full",preload:"metadata"})})}const _tt={standard:{container:"mb-6",card:"bg-slate-50 rounded-2xl p-5 border border-slate-100",quote:"text-sm text-slate-600 italic",name:"text-sm font-semibold text-slate-800",role:"text-xs text-slate-500",dot:"bg-primary",dotInactive:"bg-slate-300",nav:"text-slate-400 hover:text-slate-600"},luxury:{container:"mb-6",card:"bg-[#1e2636] rounded-xl p-5 border border-[#c9a84c]/10",quote:"text-sm text-[#a0aec0] italic font-serif",name:"text-sm font-semibold text-white",role:"text-xs text-[#c9a84c]",dot:"bg-[#c9a84c]",dotInactive:"bg-[#2a3040]",nav:"text-[#4a5568] hover:text-[#c9a84c]"},bold:{container:"mb-6",card:"bg-[#fff3e0] rounded-2xl p-5",quote:"text-sm text-[#1a1a2e] font-medium",name:"text-sm font-black text-[#1a1a2e]",role:"text-xs text-[#ff5722] font-bold",dot:"bg-[#ff5722]",dotInactive:"bg-gray-300",nav:"text-gray-400 hover:text-[#ff5722]"},classic:{container:"mb-6",card:"bg-white rounded-lg p-5 border border-[#d4cfc5] shadow-sm",quote:"text-sm text-[#4a5568] italic font-serif",name:"text-sm font-semibold text-[#1b3a4b]",role:"text-xs text-[#5a7a6f]",dot:"bg-[#1b3a4b]",dotInactive:"bg-[#d4cfc5]",nav:"text-[#a0aec0] hover:text-[#1b3a4b]"}};function vtt({block:t,variant:e}){const n=t.config.testimonials||[],[s,o]=N.useState(0);if(n.length===0)return null;const c=_tt[e],a=n[s];return i.jsxs("div",{className:c.container,children:[i.jsxs("div",{className:c.card,children:[i.jsx(C4e,{className:"h-4 w-4 mb-2 opacity-30"}),i.jsxs("p",{className:`${c.quote} mb-3`,children:['"',a.quote,'"']}),i.jsxs("div",{children:[i.jsx("p",{className:c.name,children:a.name}),a.role&&i.jsx("p",{className:c.role,children:a.role})]})]}),n.length>1&&i.jsxs("div",{className:"flex items-center justify-center gap-3 mt-3",children:[i.jsx("button",{onClick:()=>o(f=>(f-1+n.length)%n.length),className:c.nav,children:i.jsx(ip,{className:"h-4 w-4"})}),i.jsx("div",{className:"flex gap-1.5",children:n.map((f,m)=>i.jsx("div",{className:`h-1.5 w-1.5 rounded-full transition-colors cursor-pointer ${m===s?c.dot:c.dotInactive}`,onClick:()=>o(m)},m))}),i.jsx("button",{onClick:()=>o(f=>(f+1)%n.length),className:c.nav,children:i.jsx(Vd,{className:"h-4 w-4"})})]})]})}const btt={standard:{container:"flex flex-wrap gap-2 mb-6 justify-center",tag:"px-3 py-1.5 text-xs font-medium rounded-full bg-primary/10 text-primary"},luxury:{container:"flex flex-wrap gap-2 mb-6 justify-center",tag:"px-3 py-1.5 text-xs font-medium rounded-full bg-[#c9a84c]/10 text-[#e8d48b] border border-[#c9a84c]/20"},bold:{container:"flex flex-wrap gap-2 mb-6 justify-center",tag:"px-3 py-1.5 text-xs font-black rounded-full bg-[#1a1a2e] text-white uppercase tracking-wide"},classic:{container:"flex flex-wrap gap-2 mb-6 justify-center",tag:"px-3 py-1.5 text-xs font-medium rounded-md bg-[#1b3a4b]/10 text-[#1b3a4b] border border-[#d4cfc5]"}};function wtt({block:t,variant:e}){const n=t.config.tags||[];if(n.length===0)return null;const s=btt[e];return i.jsx("div",{className:s.container,children:n.map((o,c)=>i.jsx("span",{className:s.tag,children:o},c))})}const Stt={standard:{container:"space-y-2 mb-6",link:"w-full flex items-center justify-between h-12 px-4 rounded-2xl bg-slate-50 hover:bg-slate-100 border border-slate-100 transition-colors text-sm font-medium text-slate-700",icon:"text-primary"},luxury:{container:"space-y-2 mb-6",link:"w-full flex items-center justify-between h-12 px-4 rounded-xl bg-[#1e2636] hover:bg-[#252d3f] border border-[#c9a84c]/10 transition-colors text-sm font-medium text-[#e2e8f0]",icon:"text-[#c9a84c]"},bold:{container:"space-y-2 mb-6",link:"w-full flex items-center justify-between h-12 px-4 rounded-2xl bg-gray-50 hover:bg-gray-100 transition-colors text-sm font-bold text-[#1a1a2e]",icon:"text-[#ff5722]"},classic:{container:"space-y-2 mb-6",link:"w-full flex items-center justify-between h-12 px-4 rounded-lg bg-white hover:bg-[#f5f1eb] border border-[#d4cfc5] shadow-sm transition-colors text-sm font-medium text-[#1b3a4b]",icon:"text-[#5a7a6f]"}};function Ttt({block:t,cardId:e,variant:r}){const s=t.config.links||[];if(s.length===0)return null;const o=Stt[r];return i.jsx("div",{className:o.container,children:s.map((c,a)=>i.jsxs("a",{href:c.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>ci(e,"button_click",`custom_link_${c.label}`),className:o.link,children:[i.jsx("span",{children:c.label}),i.jsx(sb,{className:`h-4 w-4 ${o.icon}`})]},a))})}const Ett={instagram:{label:"Instagram",icon:"M12 2.163c3.204 0 3.584.012 4.85.07 3.252.148 4.771 1.691 4.919 4.919.058 1.265.069 1.645.069 4.849 0 3.205-.012 3.584-.069 4.849-.149 3.225-1.664 4.771-4.919 4.919-1.266.058-1.644.07-4.85.07-3.204 0-3.584-.012-4.849-.07-3.26-.149-4.771-1.699-4.919-4.92-.058-1.265-.07-1.644-.07-4.849 0-3.204.013-3.583.07-4.849.149-3.227 1.664-4.771 4.919-4.919 1.266-.057 1.645-.069 4.849-.069zM12 0C8.741 0 8.333.014 7.053.072 2.695.272.273 2.69.073 7.052.014 8.333 0 8.741 0 12c0 3.259.014 3.668.072 4.948.2 4.358 2.618 6.78 6.98 6.98C8.333 23.986 8.741 24 12 24c3.259 0 3.668-.014 4.948-.072 4.354-.2 6.782-2.618 6.979-6.98.059-1.28.073-1.689.073-4.948 0-3.259-.014-3.667-.072-4.947-.196-4.354-2.617-6.78-6.979-6.98C15.668.014 15.259 0 12 0zm0 5.838a6.162 6.162 0 100 12.324 6.162 6.162 0 000-12.324zM12 16a4 4 0 110-8 4 4 0 010 8zm6.406-11.845a1.44 1.44 0 100 2.881 1.44 1.44 0 000-2.881z",color:"#E4405F",hoverBg:"hover:bg-[#E4405F]/10"},facebook:{label:"Facebook",icon:"M24 12.073c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.99 4.388 10.954 10.125 11.854v-8.385H7.078v-3.47h3.047V9.43c0-3.007 1.792-4.669 4.533-4.669 1.312 0 2.686.235 2.686.235v2.953H15.83c-1.491 0-1.956.925-1.956 1.874v2.25h3.328l-.532 3.47h-2.796v8.385C19.612 23.027 24 18.062 24 12.073z",color:"#1877F2",hoverBg:"hover:bg-[#1877F2]/10"},linkedin:{label:"LinkedIn",icon:"M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433c-1.144 0-2.063-.926-2.063-2.065 0-1.138.92-2.063 2.063-2.063 1.14 0 2.064.925 2.064 2.063 0 1.139-.925 2.065-2.064 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z",color:"#0A66C2",hoverBg:"hover:bg-[#0A66C2]/10"},twitter:{label:"X",icon:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z",color:"#000000",hoverBg:"hover:bg-black/10"},youtube:{label:"YouTube",icon:"M23.498 6.186a3.016 3.016 0 00-2.122-2.136C19.505 3.545 12 3.545 12 3.545s-7.505 0-9.377.505A3.017 3.017 0 00.502 6.186C0 8.07 0 12 0 12s0 3.93.502 5.814a3.016 3.016 0 002.122 2.136c1.871.505 9.376.505 9.376.505s7.505 0 9.377-.505a3.015 3.015 0 002.122-2.136C24 15.93 24 12 24 12s0-3.93-.502-5.814z M9.545 15.568V8.432L15.818 12z",color:"#FF0000",hoverBg:"hover:bg-[#FF0000]/10"},tiktok:{label:"TikTok",icon:"M12.525.02c1.31-.02 2.61-.01 3.91-.02.08 1.53.63 3.09 1.75 4.17 1.12 1.11 2.7 1.62 4.24 1.79v4.03c-1.44-.05-2.89-.35-4.2-.97-.57-.26-1.1-.59-1.62-.93-.01 2.92.01 5.84-.02 8.75-.08 1.4-.54 2.79-1.35 3.94-1.31 1.92-3.58 3.17-5.91 3.21-1.43.08-2.86-.31-4.08-1.03-2.02-1.19-3.44-3.37-3.65-5.71-.02-.5-.03-1-.01-1.49.18-1.9 1.12-3.72 2.58-4.96 1.66-1.44 3.98-2.13 6.15-1.72.02 1.48-.04 2.96-.04 4.44-.99-.32-2.15-.23-3.02.37-.63.41-1.11 1.04-1.36 1.75-.21.51-.15 1.07-.14 1.61.24 1.64 1.82 3.02 3.5 2.87 1.12-.01 2.19-.66 2.77-1.61.19-.33.4-.67.41-1.06.1-1.79.06-3.57.07-5.36.01-4.03-.01-8.05.02-12.07z",color:"#000000",hoverBg:"hover:bg-black/10"},zillow:{label:"Zillow",icon:"M12 0L1 6v12l11 6 11-6V6L12 0zm0 2.18L21 7.5v9L12 21.82 3 16.5v-9L12 2.18z",color:"#006AFF",hoverBg:"hover:bg-[#006AFF]/10"},realtor:{label:"Realtor",icon:"M12 2L2 7v10l10 5 10-5V7L12 2zm0 2.18l8 4v8l-8 4-8-4v-8l8-4z",color:"#D92228",hoverBg:"hover:bg-[#D92228]/10"},spotify:{label:"Spotify",icon:"M12 0C5.4 0 0 5.4 0 12s5.4 12 12 12 12-5.4 12-12S18.66 0 12 0zm5.521 17.34c-.24.359-.66.48-1.021.24-2.82-1.74-6.36-2.101-10.561-1.141-.418.122-.779-.179-.899-.539-.12-.421.18-.78.54-.9 4.56-1.021 8.52-.6 11.64 1.32.42.18.479.659.301 1.02zm1.44-3.3c-.301.42-.841.6-1.262.3-3.239-1.98-8.159-2.58-11.939-1.38-.479.12-1.02-.12-1.14-.6-.12-.48.12-1.021.6-1.141C9.6 9.9 15 10.561 18.72 12.84c.361.181.54.78.241 1.2zm.12-3.36C15.24 8.4 8.82 8.16 5.16 9.301c-.6.179-1.2-.181-1.38-.721-.18-.601.18-1.2.72-1.381 4.26-1.26 11.28-1.02 15.721 1.621.539.3.719 1.02.419 1.56-.299.421-1.02.599-1.559.3z",color:"#1DB954",hoverBg:"hover:bg-[#1DB954]/10"},apple_music:{label:"Apple Music",icon:"M23.994 6.124a9.23 9.23 0 00-.24-2.19c-.317-1.31-1.062-2.31-2.18-3.043A5.022 5.022 0 0019.7.198a10.7 10.7 0 00-1.564-.15C17.637.017 17.14 0 12.002 0h-.004C6.858 0 6.362.017 5.862.047 5.34.08 4.82.13 4.309.325a5.017 5.017 0 00-1.874.826C1.317 2.07.573 3.07.255 4.38A9.234 9.234 0 00.02 6.57C-.013 7.068-.03 7.564 0 12.002v.004c-.03 4.438.013 4.934.047 5.432.033.522.083 1.042.278 1.554a5.017 5.017 0 00.826 1.874c.92 1.118 1.92 1.862 3.23 2.18a9.23 9.23 0 002.19.24c.498.03.994.013 5.432.047h.004c4.438.034 4.934-.013 5.432-.047a9.23 9.23 0 002.19-.24c1.31-.317 2.31-1.062 3.043-2.18a5.022 5.022 0 00.627-1.874c.195-.492.245-1.012.278-1.534.03-.498.047-.994.047-5.432v-.004c.034-4.438-.013-4.934-.047-5.432zM17.42 16.41c0 .612-.15 1.21-.44 1.758a3.58 3.58 0 01-1.207 1.31c-.518.339-1.09.521-1.705.545-.13.005-.26 0-.39-.017a2.617 2.617 0 01-1.653-.772 2.305 2.305 0 01-.668-1.653c-.005-.13 0-.26.017-.39.07-.52.275-.986.602-1.39a2.998 2.998 0 011.218-.94 3.14 3.14 0 011.12-.282c.17-.009.336.002.502.034V9.472L10.2 10.637v7.093c0 .612-.15 1.21-.44 1.758a3.58 3.58 0 01-1.207 1.31c-.518.339-1.09.521-1.705.545-.13.005-.26 0-.39-.017a2.617 2.617 0 01-1.653-.772A2.305 2.305 0 014.137 18.9c-.005-.13 0-.26.017-.39.07-.52.275-.986.602-1.39a2.998 2.998 0 011.218-.94 3.14 3.14 0 011.12-.282c.17-.009.336.002.502.034V8.377c0-.453.066-.903.195-1.34a3.2 3.2 0 01.694-1.204 2.62 2.62 0 011.063-.738c.39-.14.793-.208 1.196-.196l4.84-1.01v10.52z",color:"#FA243C",hoverBg:"hover:bg-[#FA243C]/10"}};function jtt({path:t,color:e,size:r=20}){return i.jsx("svg",{viewBox:"0 0 24 24",width:r,height:r,fill:e,children:i.jsx("path",{d:t})})}const ktt={standard:{container:"bg-white rounded-2xl border border-slate-100 p-5 mb-6 shadow-sm",title:"text-sm font-semibold text-slate-800 mb-3",linkClass:"h-11 w-11 rounded-xl bg-slate-50 border border-slate-100 flex items-center justify-center transition-all duration-200 hover:scale-110 hover:shadow-md"},luxury:{container:"bg-zinc-900/50 backdrop-blur rounded-2xl border border-amber-900/20 p-5 mb-6",title:"text-sm font-semibold text-amber-200/80 mb-3",linkClass:"h-11 w-11 rounded-xl bg-zinc-800/80 border border-amber-900/20 flex items-center justify-center transition-all duration-200 hover:scale-110 hover:border-amber-500/40 hover:shadow-md hover:shadow-amber-500/10"},bold:{container:"bg-white/10 backdrop-blur rounded-2xl border border-white/20 p-5 mb-6",title:"text-sm font-semibold text-white/90 mb-3",linkClass:"h-11 w-11 rounded-xl bg-white/10 border border-white/20 flex items-center justify-center transition-all duration-200 hover:scale-110 hover:bg-white/20 hover:shadow-md"},classic:{container:"bg-stone-50 rounded-2xl border border-stone-200 p-5 mb-6",title:"text-sm font-semibold text-stone-800 mb-3",linkClass:"h-11 w-11 rounded-xl bg-white border border-stone-200 flex items-center justify-center transition-all duration-200 hover:scale-110 hover:shadow-md"}};function Att({block:t,cardId:e,variant:r}){const s=t.config.platforms||[],o=ktt[r];return s.length===0?null:i.jsxs("div",{className:o.container,children:[i.jsx("h3",{className:o.title,children:"Follow Me"}),i.jsx("div",{className:"flex flex-wrap gap-3 justify-center",children:s.map((c,a)=>{const f=Ett[c.platform.toLowerCase()];return!f||!c.url?null:i.jsx("a",{href:c.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>ci(e,"button_click",`social_${c.platform}`),className:o.linkClass,title:f.label,children:i.jsx(jtt,{path:f.icon,color:f.color})},a)})})]})}function lF({cardId:t,variant:e}){const{data:r}=mtt(t);if(!r||r.length===0)return null;const n=r.filter(c=>c.block_type==="social_media"&&c.is_visible),s=r.filter(c=>c.block_type!=="social_media"),o=n.length>0?{...n[0],config:{platforms:n.flatMap(c=>c.config.platforms||[])}}:null;return r.findIndex(c=>c.block_type==="social_media"),i.jsxs(i.Fragment,{children:[s.map(c=>{switch(c.block_type){case"video_intro":return i.jsx(xtt,{block:c,variant:e},c.id);case"testimonials":return i.jsx(vtt,{block:c,variant:e},c.id);case"specialties":return i.jsx(wtt,{block:c,variant:e},c.id);case"custom_links":return i.jsx(Ttt,{block:c,cardId:t,variant:e},c.id);default:return null}}),o&&i.jsx(Att,{block:o,cardId:t,variant:e})]})}async function Ntt(t){try{const e=await fetch(t);if(!e.ok)return null;const r=await e.blob(),n=r.type||"image/jpeg";return new Promise(s=>{const o=new FileReader;o.onloadend=()=>{const a=o.result.split(",")[1];s({base64:a,mimeType:n})},o.onerror=()=>s(null),o.readAsDataURL(r)})}catch{return null}}function Ctt(t){const e=t.trim().split(/\s+/);if(e.length<=1)return{first:e[0]||"",last:""};const r=e.pop();return{first:e.join(" "),last:r}}async function cF(t){const{first:e,last:r}=Ctt(t.name),n=["BEGIN:VCARD","VERSION:3.0",`FN:${t.name}`,`N:${r};${e};;;`];if(t.phone&&n.push(`TEL;TYPE=CELL:${t.phone}`),t.email&&n.push(`EMAIL;TYPE=INTERNET:${t.email}`),t.brokerage&&n.push(`ORG:${t.brokerage}`),n.push(`URL:${t.cardUrl}`),t.avatarUrl){const a=await Ntt(t.avatarUrl);if(a){const m={"image/jpeg":"JPEG","image/jpg":"JPEG","image/png":"PNG","image/gif":"GIF","image/webp":"JPEG"}[a.mimeType]||"JPEG";n.push(`PHOTO;ENCODING=b;TYPE=${m}:${a.base64}`)}}n.push("END:VCARD");const s=new Blob([n.join(`\r `)],{type:"text/vcard"}),o=URL.createObjectURL(s),c=document.createElement("a");c.href=o,c.download=`${t.name.replace(/\s+/g,"_")}.vcf`,c.click(),URL.revokeObjectURL(o),$t.success("Contact saved!")}function Itt({card:t}){var M;const[e,r]=N.useState(!1),[n,s]=N.useState("booking"),o=((M=t.profile)==null?void 0:M.name)||"Agent",c=o.split(" ").map(D=>D[0]).join("").toUpperCase().slice(0,2),a=(D,B)=>{ci(t.id,"button_click",D),B()},f=()=>a("call",()=>{var D;(D=t.profile)!=null&&D.phone?window.location.href=`tel:${t.profile.phone}`:$t.error("Phone number not available")}),m=()=>a("text",()=>{var D;(D=t.profile)!=null&&D.phone?window.location.href=`sms:${t.profile.phone}`:$t.error("Phone number not available")}),y=()=>a("email",()=>{var D;(D=t.profile)!=null&&D.email?window.location.href=`mailto:${t.profile.email}`:$t.error("Email not available")}),_=()=>{t.booking_url?a("book",()=>window.open(t.booking_url,"_blank")):(s("booking"),r(!0),ci(t.id,"button_click","book"))},w=()=>{var D,B;ci(t.id,"contact_saved"),cF({name:o,phone:(D=t.profile)==null?void 0:D.phone,email:(B=t.profile)==null?void 0:B.email,brokerage:t.brokerage_name,avatarUrl:t.avatar_url,cardUrl:window.location.href})},E=async()=>{ci(t.id,"share_event");const D=`https://cards.relevelup.com/${t.slug}`,B="Here's my contact card — save it so we can stay in touch.";if(navigator.share)try{await navigator.share({title:`${o}`,text:B,url:D})}catch{}else await navigator.clipboard.writeText(D),$t.success("Link copied!")},A=()=>{s("referral"),r(!0),ci(t.id,"button_click","refer")},C=()=>{s("connect"),r(!0),ci(t.id,"button_click","connect")},I={instagram:"📸",facebook:"📘",linkedin:"💼",twitter:"🐦",youtube:"🎬",tiktok:"🎵"};return i.jsxs("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 via-white to-slate-50",children:[i.jsxs("div",{className:"max-w-md mx-auto px-5 py-10",children:[i.jsxs("div",{className:"text-center mb-8",children:[t.show_photo&&i.jsxs(Od,{className:"h-28 w-28 mx-auto mb-4 ring-4 ring-white shadow-lg",children:[i.jsx(Fd,{src:t.avatar_url||void 0,alt:o}),i.jsx(Bd,{className:"text-2xl font-semibold bg-primary text-primary-foreground",children:c})]}),i.jsx("h1",{className:"text-2xl font-bold text-slate-900 mb-0.5",children:o}),t.title&&i.jsx("p",{className:"text-sm font-medium text-primary mb-1",children:t.title}),t.brokerage_name&&!t.brokerage_logo_url&&i.jsx("p",{className:"text-sm font-medium text-slate-500 mb-1",children:t.brokerage_name}),t.team_name&&!t.team_logo_url&&i.jsx("p",{className:"text-xs font-medium text-slate-400 mb-3",children:t.team_name}),t.positioning_statement&&i.jsxs("p",{className:"text-base text-slate-600 italic leading-relaxed max-w-xs mx-auto",children:['"',t.positioning_statement,'"']})]}),i.jsxs("div",{className:"grid grid-cols-3 gap-3 mb-4",children:[i.jsxs(Lt,{onClick:f,className:"flex flex-col items-center gap-1.5 h-auto py-4 bg-primary hover:bg-primary/90 text-primary-foreground rounded-2xl shadow-sm",children:[i.jsx(Un,{className:"h-5 w-5"}),i.jsx("span",{className:"text-xs font-medium",children:"Call"})]}),i.jsxs(Lt,{onClick:m,className:"flex flex-col items-center gap-1.5 h-auto py-4 bg-primary hover:bg-primary/90 text-primary-foreground rounded-2xl shadow-sm",children:[i.jsx(Nh,{className:"h-5 w-5"}),i.jsx("span",{className:"text-xs font-medium",children:"Text"})]}),i.jsxs(Lt,{onClick:y,className:"flex flex-col items-center gap-1.5 h-auto py-4 bg-primary hover:bg-primary/90 text-primary-foreground rounded-2xl shadow-sm",children:[i.jsx(rs,{className:"h-5 w-5"}),i.jsx("span",{className:"text-xs font-medium",children:"Email"})]})]}),i.jsxs(Lt,{onClick:_,className:"w-full h-12 text-base font-semibold rounded-2xl shadow-sm mb-6",variant:"outline",children:[i.jsx(xo,{className:"h-5 w-5 mr-2"}),t.custom_cta_label||"Book a Call"]}),t.show_credentials&&t.review_snippet&&i.jsx("div",{className:"flex items-center justify-center gap-4 mb-6 text-sm text-slate-600",children:i.jsxs("div",{className:"text-center flex items-center gap-1",children:[i.jsx(gc,{className:"h-4 w-4 text-amber-500 fill-amber-500"}),i.jsx("span",{className:"font-bold text-slate-900",children:"5.0"})]})}),t.review_snippet&&i.jsx("div",{className:"bg-slate-50 rounded-2xl p-4 mb-6 border border-slate-100",children:i.jsxs("p",{className:"text-sm text-slate-600 italic text-center",children:['"',t.review_snippet,'"']})}),t.show_bio&&t.bio&&i.jsxs("div",{className:"mb-6",children:[i.jsx("h2",{className:"text-sm font-semibold text-slate-800 mb-2",children:"About Me"}),i.jsx("p",{className:"text-sm text-slate-600 leading-relaxed",children:t.bio})]}),i.jsx(aF,{card:t,variant:"standard"}),i.jsx(lF,{cardId:t.id,variant:"standard"}),i.jsxs("div",{className:"space-y-2 mb-6",children:[t.show_save_contact&&i.jsxs(Lt,{variant:"ghost",onClick:w,className:"w-full justify-start h-12 rounded-2xl text-slate-700 hover:bg-slate-100",children:[i.jsx(mc,{className:"h-4 w-4 mr-3 text-primary"}),"Save Contact"]}),t.show_leave_review&&t.review_source_url&&i.jsxs(Lt,{variant:"ghost",onClick:()=>{ci(t.id,"button_click","review"),window.open(t.review_source_url,"_blank")},className:"w-full justify-start h-12 rounded-2xl text-slate-700 hover:bg-slate-100",children:[i.jsx(gc,{className:"h-4 w-4 mr-3 text-amber-500"}),"Leave a Review"]}),t.show_refer_friend&&i.jsxs(Lt,{variant:"ghost",onClick:A,className:"w-full justify-start h-12 rounded-2xl text-slate-700 hover:bg-slate-100",children:[i.jsx(El,{className:"h-4 w-4 mr-3 text-primary"}),"Refer a Friend"]}),i.jsxs(Lt,{variant:"ghost",onClick:C,className:"w-full justify-start h-12 rounded-2xl text-slate-700 hover:bg-slate-100",children:[i.jsx(l4,{className:"h-4 w-4 mr-3 text-primary"}),"Connect with Me"]}),i.jsxs(Lt,{variant:"ghost",onClick:E,className:"w-full justify-start h-12 rounded-2xl text-slate-700 hover:bg-slate-100",children:[i.jsx(xC,{className:"h-4 w-4 mr-3 text-primary"}),"Share My Card"]})]}),t.show_social_links&&t.social_links&&t.social_links.length>0&&i.jsx("div",{className:"flex justify-center gap-4 mb-8",children:t.social_links.slice(0,3).map((D,B)=>i.jsx("a",{href:D.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>ci(t.id,"button_click",`social_${D.platform}`),className:"h-10 w-10 rounded-full bg-slate-100 hover:bg-slate-200 flex items-center justify-center text-lg transition-colors",children:I[D.platform.toLowerCase()]||"🔗"},B))}),i.jsx("div",{className:"text-center",children:i.jsx("p",{className:"text-xs text-slate-400",children:"Powered by LevelUp"})})]}),i.jsx(oF,{open:e,onOpenChange:r,cardId:t.id,type:n,agentName:o})]})}function Ptt({card:t}){var M;const[e,r]=N.useState(!1),[n,s]=N.useState("booking"),o=((M=t.profile)==null?void 0:M.name)||"Agent",c=o.split(" ").map(D=>D[0]).join("").toUpperCase().slice(0,2),a=(D,B)=>{ci(t.id,"button_click",D),B()},f=()=>a("call",()=>{var D;(D=t.profile)!=null&&D.phone?window.location.href=`tel:${t.profile.phone}`:$t.error("Phone number not available")}),m=()=>a("text",()=>{var D;(D=t.profile)!=null&&D.phone?window.location.href=`sms:${t.profile.phone}`:$t.error("Phone number not available")}),y=()=>a("email",()=>{var D;(D=t.profile)!=null&&D.email?window.location.href=`mailto:${t.profile.email}`:$t.error("Email not available")}),_=()=>{t.booking_url?a("book",()=>window.open(t.booking_url,"_blank")):(s("booking"),r(!0),ci(t.id,"button_click","book"))},w=()=>{var D,B;ci(t.id,"contact_saved"),cF({name:o,phone:(D=t.profile)==null?void 0:D.phone,email:(B=t.profile)==null?void 0:B.email,brokerage:t.brokerage_name,avatarUrl:t.avatar_url,cardUrl:window.location.href})},E=async()=>{ci(t.id,"share_event");const D=`https://cards.relevelup.com/${t.slug}`,B="Here's my contact card — save it so we can stay in touch.";if(navigator.share)try{await navigator.share({title:`${o}`,text:B,url:D})}catch{}else await navigator.clipboard.writeText(D),$t.success("Link copied!")},A=()=>{s("referral"),r(!0),ci(t.id,"button_click","refer")},C=()=>{s("connect"),r(!0),ci(t.id,"button_click","connect")},I={instagram:"📸",facebook:"📘",linkedin:"💼",twitter:"🐦",youtube:"🎬",tiktok:"🎵"};return i.jsxs("div",{className:"min-h-screen bg-gradient-to-b from-[#0f1419] via-[#1a1f2e] to-[#0f1419]",children:[i.jsxs("div",{className:"max-w-md mx-auto px-5 py-10",children:[i.jsx("div",{className:"w-16 h-0.5 bg-gradient-to-r from-[#c9a84c] to-[#e8d48b] mx-auto mb-8"}),i.jsxs("div",{className:"text-center mb-8",children:[t.show_photo&&i.jsxs(Od,{className:"h-32 w-32 mx-auto mb-5 ring-2 ring-[#c9a84c]/40 shadow-2xl",children:[i.jsx(Fd,{src:t.avatar_url||void 0,alt:o}),i.jsx(Bd,{className:"text-2xl font-serif bg-[#c9a84c]/20 text-[#e8d48b]",children:c})]}),i.jsx("h1",{className:"text-2xl font-serif font-bold text-white tracking-wide mb-0.5",children:o}),t.title&&i.jsx("p",{className:"text-sm font-medium text-[#e8d48b] mb-1",children:t.title}),t.brokerage_name&&!t.brokerage_logo_url&&i.jsx("p",{className:"text-sm font-medium text-[#c9a84c] tracking-widest uppercase mb-1",children:t.brokerage_name}),t.team_name&&!t.team_logo_url&&i.jsx("p",{className:"text-xs font-medium text-[#a0aec0] mb-3",children:t.team_name}),t.positioning_statement&&i.jsxs("p",{className:"text-base text-[#a0aec0] italic leading-relaxed max-w-xs mx-auto font-serif",children:['"',t.positioning_statement,'"']})]}),i.jsx("div",{className:"grid grid-cols-3 gap-3 mb-4",children:[{icon:Un,label:"Call",handler:f},{icon:Nh,label:"Text",handler:m},{icon:rs,label:"Email",handler:y}].map(({icon:D,label:B,handler:U})=>i.jsxs("button",{onClick:U,className:"flex flex-col items-center gap-1.5 py-4 bg-[#1e2636] hover:bg-[#252d3f] border border-[#c9a84c]/20 rounded-xl transition-colors",children:[i.jsx(D,{className:"h-5 w-5 text-[#c9a84c]"}),i.jsx("span",{className:"text-xs font-medium text-[#e2e8f0]",children:B})]},B))}),i.jsxs("button",{onClick:_,className:"w-full h-12 text-base font-semibold rounded-xl mb-6 bg-gradient-to-r from-[#c9a84c] to-[#e8d48b] text-[#0f1419] hover:opacity-90 transition-opacity flex items-center justify-center gap-2",children:[i.jsx(xo,{className:"h-5 w-5"}),t.custom_cta_label||"Book a Call"]}),t.show_credentials&&t.review_snippet&&i.jsx("div",{className:"flex items-center justify-center gap-4 mb-6 text-sm",children:i.jsxs("div",{className:"text-center flex items-center gap-1",children:[i.jsx(gc,{className:"h-4 w-4 text-[#c9a84c] fill-[#c9a84c]"}),i.jsx("span",{className:"font-bold text-white",children:"5.0"})]})}),t.review_snippet&&i.jsx("div",{className:"bg-[#1e2636] rounded-xl p-4 mb-6 border border-[#c9a84c]/10",children:i.jsxs("p",{className:"text-sm text-[#a0aec0] italic text-center font-serif",children:['"',t.review_snippet,'"']})}),t.show_bio&&t.bio&&i.jsxs("div",{className:"mb-6",children:[i.jsx("h2",{className:"text-sm font-semibold text-[#c9a84c] mb-2 tracking-wide uppercase",children:"About"}),i.jsx("p",{className:"text-sm text-[#a0aec0] leading-relaxed",children:t.bio})]}),i.jsx(aF,{card:t,variant:"luxury"}),i.jsx(lF,{cardId:t.id,variant:"luxury"}),i.jsxs("div",{className:"space-y-1 mb-6",children:[t.show_save_contact&&i.jsxs("button",{onClick:w,className:"w-full flex items-center gap-3 h-12 px-4 rounded-xl text-[#e2e8f0] hover:bg-[#1e2636] transition-colors text-sm",children:[i.jsx(mc,{className:"h-4 w-4 text-[#c9a84c]"})," Save Contact"]}),t.show_leave_review&&t.review_source_url&&i.jsxs("button",{onClick:()=>{ci(t.id,"button_click","review"),window.open(t.review_source_url,"_blank")},className:"w-full flex items-center gap-3 h-12 px-4 rounded-xl text-[#e2e8f0] hover:bg-[#1e2636] transition-colors text-sm",children:[i.jsx(gc,{className:"h-4 w-4 text-[#c9a84c]"})," Leave a Review"]}),t.show_refer_friend&&i.jsxs("button",{onClick:A,className:"w-full flex items-center gap-3 h-12 px-4 rounded-xl text-[#e2e8f0] hover:bg-[#1e2636] transition-colors text-sm",children:[i.jsx(El,{className:"h-4 w-4 text-[#c9a84c]"})," Refer a Friend"]}),i.jsxs("button",{onClick:C,className:"w-full flex items-center gap-3 h-12 px-4 rounded-xl text-[#e2e8f0] hover:bg-[#1e2636] transition-colors text-sm",children:[i.jsx(l4,{className:"h-4 w-4 text-[#c9a84c]"})," Connect with Me"]}),i.jsxs("button",{onClick:E,className:"w-full flex items-center gap-3 h-12 px-4 rounded-xl text-[#e2e8f0] hover:bg-[#1e2636] transition-colors text-sm",children:[i.jsx(xC,{className:"h-4 w-4 text-[#c9a84c]"})," Share My Card"]})]}),t.show_social_links&&t.social_links&&t.social_links.length>0&&i.jsx("div",{className:"flex justify-center gap-4 mb-8",children:t.social_links.slice(0,3).map((D,B)=>i.jsx("a",{href:D.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>ci(t.id,"button_click",`social_${D.platform}`),className:"h-10 w-10 rounded-full bg-[#1e2636] border border-[#c9a84c]/20 hover:border-[#c9a84c]/50 flex items-center justify-center text-lg transition-colors",children:I[D.platform.toLowerCase()]||"🔗"},B))}),i.jsx("div",{className:"text-center",children:i.jsx("p",{className:"text-xs text-[#4a5568]",children:"Powered by LevelUp"})})]}),i.jsx(oF,{open:e,onOpenChange:r,cardId:t.id,type:n,agentName:o})]})}function Rtt({card:t}){var B,U,q,H;const[e,r]=N.useState(!1),[n,s]=N.useState("booking"),o=((B=t.profile)==null?void 0:B.name)||"Agent",c=o.split(" ").map(K=>K[0]).join("").toUpperCase().slice(0,2),a={accent:((U=t.bold_theme_colors)==null?void 0:U.accent)||"#ff5722",dark:((q=t.bold_theme_colors)==null?void 0:q.dark)||"#1a1a2e",button:((H=t.bold_theme_colors)==null?void 0:H.button)||"#ff5722"},f=(K,Q)=>{const J=parseInt(K.replace("#",""),16),ee=Math.max(0,(J>>16)-Q),oe=Math.max(0,(J>>8&255)-Q),de=Math.max(0,(J&255)-Q);return`#${(ee<<16|oe<<8|de).toString(16).padStart(6,"0")}`};f(a.accent,25),f(a.dark,-20),f(a.button,25);const m=(K,Q)=>{ci(t.id,"button_click",K),Q()},y=()=>m("call",()=>{var K;(K=t.profile)!=null&&K.phone?window.location.href=`tel:${t.profile.phone}`:$t.error("Phone number not available")}),_=()=>m("text",()=>{var K;(K=t.profile)!=null&&K.phone?window.location.href=`sms:${t.profile.phone}`:$t.error("Phone number not available")}),w=()=>m("email",()=>{var K;(K=t.profile)!=null&&K.email?window.location.href=`mailto:${t.profile.email}`:$t.error("Email not available")}),E=()=>{t.booking_url?m("book",()=>window.open(t.booking_url,"_blank")):(s("booking"),r(!0),ci(t.id,"button_click","book"))},A=()=>{var K,Q;ci(t.id,"contact_saved"),cF({name:o,phone:(K=t.profile)==null?void 0:K.phone,email:(Q=t.profile)==null?void 0:Q.email,brokerage:t.brokerage_name,avatarUrl:t.avatar_url,cardUrl:window.location.href})},C=async()=>{ci(t.id,"share_event");const K=`https://cards.relevelup.com/${t.slug}`,Q="Here's my contact card — save it so we can stay in touch.";if(navigator.share)try{await navigator.share({title:`${o}`,text:Q,url:K})}catch{}else await navigator.clipboard.writeText(K),$t.success("Link copied!")},I=()=>{s("referral"),r(!0),ci(t.id,"button_click","refer")},M=()=>{s("connect"),r(!0),ci(t.id,"button_click","connect")},D={instagram:"📸",facebook:"📘",linkedin:"💼",twitter:"🐦",youtube:"🎬",tiktok:"🎵"};return i.jsxs("div",{className:"min-h-screen",style:{backgroundColor:a.accent},children:[i.jsxs("div",{className:"px-5 pt-10 pb-14 text-center relative",style:{backgroundColor:a.dark},children:[t.show_photo&&i.jsxs(Od,{className:"h-28 w-28 mx-auto mb-4 shadow-2xl",style:{boxShadow:`0 0 0 4px ${a.accent}`},children:[i.jsx(Fd,{src:t.avatar_url||void 0,alt:o}),i.jsx(Bd,{className:"text-2xl font-black text-white",style:{backgroundColor:a.accent},children:c})]}),i.jsx("h1",{className:"text-3xl font-black text-white tracking-tight mb-0.5",children:o}),t.title&&i.jsx("p",{className:"text-sm font-bold mb-1",style:{color:`${a.accent}cc`},children:t.title}),t.brokerage_name&&!t.brokerage_logo_url&&i.jsx("p",{className:"text-sm font-bold uppercase tracking-wider mb-1",style:{color:a.accent},children:t.brokerage_name}),t.team_name&&!t.team_logo_url&&i.jsx("p",{className:"text-xs font-bold text-white/60 uppercase tracking-wider",children:t.team_name})]}),i.jsxs("div",{className:"max-w-md mx-auto px-5 -mt-6",children:[i.jsxs("div",{className:"bg-white rounded-3xl shadow-2xl px-5 py-8",children:[t.positioning_statement&&i.jsx("p",{className:"text-center font-bold text-lg leading-snug mb-6 max-w-xs mx-auto",style:{color:a.dark},children:t.positioning_statement}),i.jsx("div",{className:"grid grid-cols-3 gap-3 mb-4",children:[{icon:Un,label:"Call",handler:y},{icon:Nh,label:"Text",handler:_},{icon:rs,label:"Email",handler:w}].map(({icon:K,label:Q,handler:J})=>i.jsxs("button",{onClick:J,className:"flex flex-col items-center gap-1.5 py-4 text-white rounded-2xl transition-opacity font-bold hover:opacity-85",style:{backgroundColor:a.dark},children:[i.jsx(K,{className:"h-5 w-5"}),i.jsx("span",{className:"text-xs",children:Q})]},Q))}),i.jsxs("button",{onClick:E,className:"w-full h-14 text-base font-black rounded-2xl mb-6 text-white transition-opacity hover:opacity-90 flex items-center justify-center gap-2 uppercase tracking-wide",style:{backgroundColor:a.button},children:[i.jsx(xo,{className:"h-5 w-5"}),t.custom_cta_label||"Book a Call"]}),t.show_credentials&&t.review_snippet&&i.jsx("div",{className:"flex items-center justify-center gap-5 mb-6",children:t.review_snippet&&i.jsxs("div",{className:"text-center flex items-center gap-1",children:[i.jsx(gc,{className:"h-5 w-5",style:{color:a.accent,fill:a.accent}}),i.jsx("span",{className:"font-black text-2xl",style:{color:a.dark},children:"5.0"})]})}),t.review_snippet&&i.jsx("div",{className:"rounded-2xl p-4 mb-6",style:{backgroundColor:`${a.accent}15`},children:i.jsxs("p",{className:"text-sm font-medium text-center",style:{color:a.dark},children:['"',t.review_snippet,'"']})}),t.show_bio&&t.bio&&i.jsxs("div",{className:"mb-6",children:[i.jsx("h2",{className:"text-xs font-black mb-2 uppercase tracking-wider",style:{color:a.accent},children:"About Me"}),i.jsx("p",{className:"text-sm text-gray-600 leading-relaxed",children:t.bio})]}),i.jsx(aF,{card:t,variant:"bold"}),i.jsx(lF,{cardId:t.id,variant:"bold"}),i.jsxs("div",{className:"space-y-1 mb-6",children:[t.show_save_contact&&i.jsxs("button",{onClick:A,className:"w-full flex items-center gap-3 h-12 px-4 rounded-2xl hover:bg-gray-100 transition-colors text-sm font-bold",style:{color:a.dark},children:[i.jsx(mc,{className:"h-4 w-4",style:{color:a.accent}})," Save Contact"]}),t.show_leave_review&&t.review_source_url&&i.jsxs("button",{onClick:()=>{ci(t.id,"button_click","review"),window.open(t.review_source_url,"_blank")},className:"w-full flex items-center gap-3 h-12 px-4 rounded-2xl hover:bg-gray-100 transition-colors text-sm font-bold",style:{color:a.dark},children:[i.jsx(gc,{className:"h-4 w-4",style:{color:a.accent}})," Leave a Review"]}),t.show_refer_friend&&i.jsxs("button",{onClick:I,className:"w-full flex items-center gap-3 h-12 px-4 rounded-2xl hover:bg-gray-100 transition-colors text-sm font-bold",style:{color:a.dark},children:[i.jsx(El,{className:"h-4 w-4",style:{color:a.accent}})," Refer a Friend"]}),i.jsxs("button",{onClick:M,className:"w-full flex items-center gap-3 h-12 px-4 rounded-2xl hover:bg-gray-100 transition-colors text-sm font-bold",style:{color:a.dark},children:[i.jsx(l4,{className:"h-4 w-4",style:{color:a.accent}})," Connect with Me"]}),i.jsxs("button",{onClick:C,className:"w-full flex items-center gap-3 h-12 px-4 rounded-2xl hover:bg-gray-100 transition-colors text-sm font-bold",style:{color:a.dark},children:[i.jsx(xC,{className:"h-4 w-4",style:{color:a.accent}})," Share My Card"]})]}),t.show_social_links&&t.social_links&&t.social_links.length>0&&i.jsx("div",{className:"flex justify-center gap-4 mb-6",children:t.social_links.slice(0,3).map((K,Q)=>i.jsx("a",{href:K.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>ci(t.id,"button_click",`social_${K.platform}`),className:"h-10 w-10 rounded-full flex items-center justify-center text-lg transition-opacity hover:opacity-85",style:{backgroundColor:a.dark},children:D[K.platform.toLowerCase()]||"🔗"},Q))})]}),i.jsx("div",{className:"text-center py-6",children:i.jsx("p",{className:"text-xs text-white/50",children:"Powered by LevelUp"})})]}),i.jsx(oF,{open:e,onOpenChange:r,cardId:t.id,type:n,agentName:o})]})}function Ltt({card:t}){var M;const[e,r]=N.useState(!1),[n,s]=N.useState("booking"),o=((M=t.profile)==null?void 0:M.name)||"Agent",c=o.split(" ").map(D=>D[0]).join("").toUpperCase().slice(0,2),a=(D,B)=>{ci(t.id,"button_click",D),B()},f=()=>a("call",()=>{var D;(D=t.profile)!=null&&D.phone?window.location.href=`tel:${t.profile.phone}`:$t.error("Phone number not available")}),m=()=>a("text",()=>{var D;(D=t.profile)!=null&&D.phone?window.location.href=`sms:${t.profile.phone}`:$t.error("Phone number not available")}),y=()=>a("email",()=>{var D;(D=t.profile)!=null&&D.email?window.location.href=`mailto:${t.profile.email}`:$t.error("Email not available")}),_=()=>{t.booking_url?a("book",()=>window.open(t.booking_url,"_blank")):(s("booking"),r(!0),ci(t.id,"button_click","book"))},w=()=>{var D,B;ci(t.id,"contact_saved"),cF({name:o,phone:(D=t.profile)==null?void 0:D.phone,email:(B=t.profile)==null?void 0:B.email,brokerage:t.brokerage_name,avatarUrl:t.avatar_url,cardUrl:window.location.href})},E=async()=>{ci(t.id,"share_event");const D=`https://cards.relevelup.com/${t.slug}`,B="Here's my contact card — save it so we can stay in touch.";if(navigator.share)try{await navigator.share({title:`${o}`,text:B,url:D})}catch{}else await navigator.clipboard.writeText(D),$t.success("Link copied!")},A=()=>{s("referral"),r(!0),ci(t.id,"button_click","refer")},C=()=>{s("connect"),r(!0),ci(t.id,"button_click","connect")},I={instagram:"📸",facebook:"📘",linkedin:"💼",twitter:"🐦",youtube:"🎬",tiktok:"🎵"};return i.jsxs("div",{className:"min-h-screen bg-[#f5f1eb]",children:[i.jsx("div",{className:"bg-[#1b3a4b] h-2"}),i.jsxs("div",{className:"max-w-md mx-auto px-5 py-10",children:[i.jsxs("div",{className:"text-center mb-8",children:[t.show_photo&&i.jsxs(Od,{className:"h-28 w-28 mx-auto mb-4 ring-4 ring-white shadow-lg",children:[i.jsx(Fd,{src:t.avatar_url||void 0,alt:o}),i.jsx(Bd,{className:"text-2xl font-serif bg-[#1b3a4b] text-white",children:c})]}),i.jsx("h1",{className:"text-2xl font-serif font-bold text-[#1b3a4b] mb-0.5",children:o}),t.title&&i.jsx("p",{className:"text-sm font-medium text-[#5a7a6f] mb-1",children:t.title}),t.brokerage_name&&!t.brokerage_logo_url&&i.jsx("p",{className:"text-sm font-medium text-[#5a7a6f] mb-1",children:t.brokerage_name}),t.team_name&&!t.team_logo_url&&i.jsx("p",{className:"text-xs font-medium text-[#a0aec0] mb-3",children:t.team_name}),t.positioning_statement&&i.jsxs("p",{className:"text-base text-[#4a5568] italic leading-relaxed max-w-xs mx-auto font-serif",children:['"',t.positioning_statement,'"']})]}),i.jsx("div",{className:"grid grid-cols-3 gap-3 mb-4",children:[{icon:Un,label:"Call",handler:f},{icon:Nh,label:"Text",handler:m},{icon:rs,label:"Email",handler:y}].map(({icon:D,label:B,handler:U})=>i.jsxs("button",{onClick:U,className:"flex flex-col items-center gap-1.5 py-4 bg-white hover:bg-[#e8e3db] border border-[#d4cfc5] rounded-lg transition-colors shadow-sm",children:[i.jsx(D,{className:"h-5 w-5 text-[#1b3a4b]"}),i.jsx("span",{className:"text-xs font-semibold text-[#1b3a4b]",children:B})]},B))}),i.jsxs("button",{onClick:_,className:"w-full h-12 text-base font-semibold rounded-lg mb-6 bg-[#1b3a4b] hover:bg-[#264d61] text-white transition-colors flex items-center justify-center gap-2 shadow-sm",children:[i.jsx(xo,{className:"h-5 w-5"}),t.custom_cta_label||"Book a Call"]}),t.show_credentials&&t.review_snippet&&i.jsx("div",{className:"bg-white rounded-lg border border-[#d4cfc5] p-4 mb-6 shadow-sm",children:i.jsx("div",{className:"flex items-center justify-center gap-6",children:i.jsxs("div",{className:"text-center flex items-center gap-1",children:[i.jsx(gc,{className:"h-4 w-4 text-[#d4a843] fill-[#d4a843]"}),i.jsx("span",{className:"font-bold text-[#1b3a4b] font-serif",children:"5.0"})]})})}),t.review_snippet&&i.jsx("div",{className:"bg-white rounded-lg border border-[#d4cfc5] p-4 mb-6 shadow-sm",children:i.jsxs("p",{className:"text-sm text-[#4a5568] italic text-center font-serif",children:['"',t.review_snippet,'"']})}),t.show_bio&&t.bio&&i.jsxs("div",{className:"mb-6",children:[i.jsx("h2",{className:"text-sm font-semibold text-[#1b3a4b] mb-2 font-serif",children:"About"}),i.jsx("p",{className:"text-sm text-[#4a5568] leading-relaxed",children:t.bio})]}),i.jsx(aF,{card:t,variant:"classic"}),i.jsx(lF,{cardId:t.id,variant:"classic"}),i.jsxs("div",{className:"bg-white rounded-lg border border-[#d4cfc5] shadow-sm divide-y divide-[#e8e3db] mb-6",children:[t.show_save_contact&&i.jsxs("button",{onClick:w,className:"w-full flex items-center gap-3 h-12 px-4 text-[#1b3a4b] hover:bg-[#f5f1eb] transition-colors text-sm font-medium",children:[i.jsx(mc,{className:"h-4 w-4 text-[#5a7a6f]"})," Save Contact"]}),t.show_leave_review&&t.review_source_url&&i.jsxs("button",{onClick:()=>{ci(t.id,"button_click","review"),window.open(t.review_source_url,"_blank")},className:"w-full flex items-center gap-3 h-12 px-4 text-[#1b3a4b] hover:bg-[#f5f1eb] transition-colors text-sm font-medium",children:[i.jsx(gc,{className:"h-4 w-4 text-[#d4a843]"})," Leave a Review"]}),t.show_refer_friend&&i.jsxs("button",{onClick:A,className:"w-full flex items-center gap-3 h-12 px-4 text-[#1b3a4b] hover:bg-[#f5f1eb] transition-colors text-sm font-medium",children:[i.jsx(El,{className:"h-4 w-4 text-[#5a7a6f]"})," Refer a Friend"]}),i.jsxs("button",{onClick:C,className:"w-full flex items-center gap-3 h-12 px-4 text-[#1b3a4b] hover:bg-[#f5f1eb] transition-colors text-sm font-medium",children:[i.jsx(l4,{className:"h-4 w-4 text-[#5a7a6f]"})," Connect with Me"]}),i.jsxs("button",{onClick:E,className:"w-full flex items-center gap-3 h-12 px-4 text-[#1b3a4b] hover:bg-[#f5f1eb] transition-colors text-sm font-medium",children:[i.jsx(xC,{className:"h-4 w-4 text-[#5a7a6f]"})," Share My Card"]})]}),t.show_social_links&&t.social_links&&t.social_links.length>0&&i.jsx("div",{className:"flex justify-center gap-4 mb-8",children:t.social_links.slice(0,3).map((D,B)=>i.jsx("a",{href:D.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>ci(t.id,"button_click",`social_${D.platform}`),className:"h-10 w-10 rounded-full bg-white border border-[#d4cfc5] hover:bg-[#e8e3db] flex items-center justify-center text-lg transition-colors shadow-sm",children:I[D.platform.toLowerCase()]||"🔗"},B))}),i.jsx("div",{className:"text-center",children:i.jsx("p",{className:"text-xs text-[#a0aec0]",children:"Powered by LevelUp"})})]}),i.jsx(oF,{open:e,onOpenChange:r,cardId:t.id,type:n,agentName:o})]})}function Mtt({card:t}){switch(t.theme){case"luxury":return i.jsx(Ptt,{card:t});case"bold":return i.jsx(Rtt,{card:t});case"classic":return i.jsx(Ltt,{card:t});case"standard":default:return i.jsx(Itt,{card:t})}}function Dtt(t){if(!t)return null;try{const e=new URL(t),r=new URL("https://relzejiswnotikjgvjhz.supabase.co").host;return e.protocol!=="https:"||e.host!==r||!e.pathname.includes("/storage/v1/object/public/")?null:e.toString()}catch{return null}}function Ott(t){return`https://docs.google.com/gview?url=${encodeURIComponent(t)}&embedded=true`}function Ftt(){if(typeof window>"u")return null;const t=Dtt(new URLSearchParams(window.location.search).get("oh_disclosure"));return t?i.jsx("div",{className:"sticky top-0 z-50 bg-primary text-primary-foreground shadow-md",children:i.jsxs("div",{className:"mx-auto flex max-w-md items-center justify-between gap-3 px-4 py-2.5",children:[i.jsx("span",{className:"text-sm font-medium",children:"Thanks for visiting the open house!"}),i.jsxs("a",{href:Ott(t),target:"_blank",rel:"noopener noreferrer",className:"inline-flex shrink-0 items-center gap-1.5 rounded-lg bg-background px-3 py-1.5 text-xs font-semibold text-foreground",children:[i.jsx(Ym,{className:"h-3.5 w-3.5"})," See Disclosures"]})]})}):null}function Btt(){const t=js();N.useEffect(()=>(document.body.classList.add("agent-card-page"),()=>{document.body.classList.remove("agent-card-page")}),[]);const e=t.pathname.slice(1);return!e||e===""?i.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white flex items-center justify-center p-6",children:i.jsxs("div",{className:"text-center",children:[i.jsx("h1",{className:"text-2xl font-bold text-slate-800 mb-2",children:"Agent Cards"}),i.jsx("p",{className:"text-slate-500",children:"Visit a specific agent's card URL to view their digital business card."})]})}):i.jsx($tt,{slug:e})}function $tt({slug:t}){return i.jsx(ztt,{slug:t})}function ztt({slug:t}){var o;const{data:e,isLoading:r,error:n}=htt(t);if(N.useEffect(()=>{e!=null&&e.id&&ci(e.id,"card_view")},[e==null?void 0:e.id]),r)return i.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white flex items-center justify-center",children:i.jsxs("div",{className:"w-full max-w-md mx-auto p-6 space-y-6",children:[i.jsxs("div",{className:"flex flex-col items-center gap-4",children:[i.jsx(jl,{className:"h-28 w-28 rounded-full"}),i.jsx(jl,{className:"h-6 w-48"}),i.jsx(jl,{className:"h-4 w-36"})]}),i.jsx(jl,{className:"h-12 w-full"}),i.jsx(jl,{className:"h-12 w-full"})]})});if(n||!e)return i.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white flex items-center justify-center p-6",children:i.jsxs("div",{className:"text-center",children:[i.jsx("h1",{className:"text-2xl font-bold text-slate-800 mb-2",children:"Card Not Found"}),i.jsx("p",{className:"text-slate-500",children:"This agent card doesn't exist or isn't published yet."})]})});const s=((o=e.profile)==null?void 0:o.name)||"Agent";return i.jsxs(i.Fragment,{children:[i.jsxs(_o,{children:[i.jsxs("title",{children:[s," | Real Estate Agent"]}),i.jsx("meta",{name:"description",content:e.positioning_statement||`Connect with ${s}, your trusted real estate professional.`}),i.jsx("meta",{property:"og:title",content:`${s} | Real Estate Agent`}),i.jsx("meta",{property:"og:description",content:e.positioning_statement||`Connect with ${s}`}),e.avatar_url&&i.jsx("meta",{property:"og:image",content:e.avatar_url})]}),i.jsx(Ftt,{}),i.jsx(Mtt,{card:e})]})}function Utt({presentationId:t,ctaLabel:e,agentName:r,prefillName:n,prefillEmail:s,prefillPhone:o}){const[c,a]=N.useState(n||""),[f,m]=N.useState(s||""),[y,_]=N.useState(o||""),[w,E]=N.useState(""),[A,C]=N.useState(""),[I,M]=N.useState(!1),[D,B]=N.useState(!1),U=async q=>{if(q.preventDefault(),!c.trim()){$t.error("Please enter your name");return}M(!0);try{const{error:H}=await Ce.from("smart_presentation_leads").insert({presentation_id:t,name:c.trim(),email:f.trim()||null,phone:y.trim()||null,intent:w||null,message:A.trim()||null});if(H)throw H;try{await Ce.rpc("log_presentation_view",{p_presentation_id:t,p_section_index:null,p_cta_clicked:!0,p_ip_hash:null,p_user_agent:navigator.userAgent,p_referrer:null})}catch{}Ce.functions.invoke("presentation-lead-notify",{body:{presentationId:t,name:c.trim(),email:f.trim()||void 0,phone:y.trim()||void 0,intent:w||void 0,message:A.trim()||void 0}}).catch(K=>console.error("Presentation lead notify failed:",K)),B(!0)}catch{$t.error("Something went wrong. Please try again.")}finally{M(!1)}};return D?i.jsxs("div",{className:"text-center py-8",children:[i.jsx("div",{className:"w-16 h-16 rounded-full bg-emerald-100 flex items-center justify-center mx-auto mb-4",children:i.jsx(pa,{className:"h-8 w-8 text-emerald-600"})}),i.jsx("h3",{className:"text-xl font-semibold text-gray-900 mb-2",children:"Thank you!"}),i.jsx("p",{className:"text-gray-500",children:r?`${r} will be in touch soon.`:"We'll be in touch soon."})]}):i.jsxs("form",{onSubmit:U,className:"space-y-4 max-w-md mx-auto",children:[i.jsxs("div",{children:[i.jsx(Fr,{htmlFor:"pres-lead-name",children:"Name *"}),i.jsx(Dr,{id:"pres-lead-name",value:c,onChange:q=>a(q.target.value),placeholder:"Your name",required:!0})]}),i.jsxs("div",{children:[i.jsx(Fr,{htmlFor:"pres-lead-phone",children:"Phone"}),i.jsx(Dr,{id:"pres-lead-phone",type:"tel",value:y,onChange:q=>_(q.target.value),placeholder:"(555) 123-4567"})]}),i.jsxs("div",{children:[i.jsx(Fr,{htmlFor:"pres-lead-email",children:"Email"}),i.jsx(Dr,{id:"pres-lead-email",type:"email",value:f,onChange:q=>m(q.target.value),placeholder:"you@example.com"})]}),i.jsxs("div",{children:[i.jsx(Fr,{htmlFor:"pres-lead-intent",children:"I'm looking to..."}),i.jsxs(Ia,{value:w,onValueChange:E,children:[i.jsx(_a,{children:i.jsx(Pa,{placeholder:"Select one"})}),i.jsxs(va,{children:[i.jsx(gn,{value:"buy",children:"Buy a home"}),i.jsx(gn,{value:"sell",children:"Sell my home"}),i.jsx(gn,{value:"both",children:"Buy & Sell"}),i.jsx(gn,{value:"other",children:"Something else"})]})]})]}),i.jsxs("div",{children:[i.jsx(Fr,{htmlFor:"pres-lead-message",children:"Message (optional)"}),i.jsx(Dr,{id:"pres-lead-message",value:A,onChange:q=>C(q.target.value),placeholder:"Anything you'd like us to know"})]}),i.jsx(Lt,{type:"submit",className:"w-full text-lg py-6 rounded-xl bg-blue-600 hover:bg-blue-700 text-white shadow-lg",disabled:I,children:I?"Sending...":e})]})}function Vtt(){const t=js();N.useEffect(()=>(document.body.classList.add("presentation-page"),()=>{document.body.classList.remove("presentation-page")}),[]);const e=t.pathname.slice(1);return!e||e===""?i.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white flex items-center justify-center p-6",children:i.jsxs("div",{className:"text-center",children:[i.jsx("h1",{className:"text-2xl font-bold text-slate-800 mb-2",children:"Smart Presentations"}),i.jsx("p",{className:"text-slate-500",children:"Visit a specific presentation URL to view it."})]})}):i.jsx(qtt,{shareToken:e})}function qtt({shareToken:t}){var A;const[e,r]=N.useState(null),[n,s]=N.useState(!0),[o,c]=N.useState(0),[a,f]=N.useState(!1);N.useEffect(()=>{m()},[t]);const m=async()=>{const{data:C,error:I}=await Ce.from("smart_presentations").select("*").eq("share_token",t).eq("status","published").single();if(I||!C){f(!0),s(!1);return}const{data:M}=await Ce.from("profiles").select("name, email, phone, avatar_url, title, brokerage_id").eq("id",C.owner_user_id).single();let D;if(M!=null&&M.brokerage_id){const{data:U}=await Ce.from("brokerages").select("name").eq("id",M.brokerage_id).single();D=(U==null?void 0:U.name)||void 0}let B=null;if(C.contact_id){const{data:U}=await Ce.from("innercircle_contacts").select("first_name, last_name, email, phone").eq("id",C.contact_id).single();B=U}r({...C,owner_name:M==null?void 0:M.name,owner_email:M==null?void 0:M.email,owner_phone:M==null?void 0:M.phone,owner_avatar:M==null?void 0:M.avatar_url,owner_title:(M==null?void 0:M.title)||void 0,brokerage_name:D,contact_name:B?[B.first_name,B.last_name].filter(Boolean).join(" "):void 0,contact_email:(B==null?void 0:B.email)||void 0,contact_phone:(B==null?void 0:B.phone)||void 0}),s(!1);try{await Ce.rpc("log_presentation_view",{p_presentation_id:C.id,p_section_index:0,p_cta_clicked:!1,p_ip_hash:null,p_user_agent:navigator.userAgent,p_referrer:document.referrer||null})}catch{}},y=async()=>{if(e){try{await Ce.rpc("log_presentation_view",{p_presentation_id:e.id,p_section_index:null,p_cta_clicked:!0,p_ip_hash:null,p_user_agent:navigator.userAgent,p_referrer:null})}catch{}e.cta_url&&window.open(e.cta_url,"_blank")}},_=C=>{const I=C.match(/(?:youtube\.com\/watch\?v=|youtu\.be\/)([a-zA-Z0-9_-]+)/);if(I)return`https://www.youtube.com/embed/${I[1]}?rel=0`;if(C.includes("iframe.mediadelivery.net/play/")){const B=C.replace("/play/","/embed/"),U=B.includes("?")?"&":"?";return`${B}${U}responsive=true`}if(C.includes("iframe.mediadelivery.net")){const B=C.includes("?")?"&":"?";return`${C}${B}responsive=true`}const M=C.match(/loom\.com\/share\/([a-zA-Z0-9]+)/);if(M)return`https://www.loom.com/embed/${M[1]}`;const D=C.match(/video\.bunnycdn\.com\/play\/(\d+)\/([a-f0-9-]+)/);return D?`https://iframe.mediadelivery.net/embed/${D[1]}/${D[2]}?responsive=true`:C};if(n)return i.jsx("div",{className:"min-h-screen bg-white flex items-center justify-center",children:i.jsxs("div",{className:"space-y-4 w-full max-w-2xl px-4",children:[i.jsx(jl,{className:"h-12 w-3/4 mx-auto"}),i.jsx(jl,{className:"h-64 w-full"}),i.jsx(jl,{className:"h-8 w-1/2 mx-auto"})]})});if(a||!e)return i.jsx("div",{className:"min-h-screen bg-white flex items-center justify-center",children:i.jsxs("div",{className:"text-center",children:[i.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Presentation Not Found"}),i.jsx("p",{className:"text-gray-500",children:"This presentation may have been removed or is no longer available."})]})});const w=e.sections.filter(C=>C.is_visible!==!1),E=w[o];return i.jsxs("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white",children:[i.jsx("header",{className:"bg-white border-b border-gray-100 sticky top-0 z-10",children:i.jsx("div",{className:"max-w-5xl mx-auto px-4 py-3 flex items-center justify-end",children:i.jsxs("div",{className:"flex items-center gap-3",children:[e.owner_avatar&&i.jsx("img",{src:e.owner_avatar,alt:e.owner_name||"Agent",className:"h-10 w-10 rounded-full object-cover border border-gray-200"}),i.jsxs("div",{className:"text-right text-sm",children:[i.jsx("p",{className:"font-semibold text-gray-900",children:e.owner_name}),e.owner_title&&i.jsx("p",{className:"text-gray-500 text-xs",children:e.owner_title}),e.brokerage_name&&!e.owner_title&&i.jsx("p",{className:"text-gray-500 text-xs",children:e.brokerage_name})]})]})})}),i.jsxs("main",{className:"max-w-5xl mx-auto px-4 py-8",children:[i.jsxs("div",{className:"text-center mb-8",children:[i.jsx("h1",{className:"text-3xl md:text-4xl font-bold text-gray-900 mb-2",children:e.heading||(e.client_name?`Welcome, ${e.client_name}!`:e.title)}),e.property_address&&i.jsxs("p",{className:"text-lg text-gray-600",children:["Here's the plan for your home at ",i.jsx("strong",{children:e.property_address}),"."]})]}),i.jsxs("div",{className:"grid md:grid-cols-5 gap-8",children:[i.jsxs("div",{className:"md:col-span-3",children:[E!=null&&E.video_url?i.jsx("div",{className:"relative w-full rounded-xl overflow-hidden shadow-lg bg-gray-900",style:{paddingTop:"56.25%"},children:i.jsx("iframe",{src:_(E.video_url),className:"absolute inset-0 w-full h-full border-0",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,loading:"lazy"})}):E!=null&&E.image_url?i.jsx("div",{className:"rounded-xl overflow-hidden shadow-lg",children:i.jsx("img",{src:E.image_url,alt:E.title,className:"w-full h-auto object-cover",loading:"lazy"})}):i.jsxs("div",{className:"aspect-video bg-gradient-to-br from-blue-50 to-slate-100 rounded-xl flex flex-col items-center justify-center shadow-lg",children:[i.jsx("span",{className:"text-5xl mb-3",children:E==null?void 0:E.icon}),i.jsx("h3",{className:"text-xl font-semibold text-gray-800",children:E==null?void 0:E.title}),i.jsx("p",{className:"text-gray-500 mt-1 text-sm",children:E==null?void 0:E.description})]}),(E==null?void 0:E.text)&&i.jsx("div",{className:"mt-4 p-4 bg-white rounded-lg border text-gray-700 text-sm leading-relaxed prose prose-sm max-w-none",dangerouslySetInnerHTML:{__html:E.text}})]}),i.jsx("div",{className:"md:col-span-2 space-y-3",children:w.map((C,I)=>i.jsx("button",{onClick:()=>c(I),className:Xt("w-full text-left p-4 rounded-xl border transition-all",o===I?"border-blue-500 bg-blue-50 shadow-sm":"border-gray-200 bg-white hover:border-blue-200 hover:bg-blue-50/50"),children:i.jsxs("div",{className:"flex items-start gap-3",children:[i.jsxs("span",{className:"text-blue-600 font-bold text-sm mt-0.5",children:[String(I+1).padStart(2,"0"),"."]}),i.jsxs("div",{children:[i.jsx("span",{className:"mr-2",children:C.icon}),i.jsx("span",{className:"font-semibold text-gray-900",children:C.title}),i.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:C.description})]})]})},I))})]}),i.jsxs("div",{className:"mt-12 max-w-md mx-auto bg-white rounded-2xl border border-gray-200 shadow-sm p-6 text-center",children:[e.owner_avatar&&i.jsx("img",{src:e.owner_avatar,alt:e.owner_name||"Agent",className:"h-20 w-20 rounded-full object-cover mx-auto mb-3 border-2 border-gray-100"}),i.jsx("h3",{className:"text-lg font-bold text-gray-900",children:e.owner_name}),e.owner_title&&i.jsx("p",{className:"text-sm text-gray-500",children:e.owner_title}),e.brokerage_name&&i.jsx("p",{className:"text-sm text-gray-500",children:e.brokerage_name}),i.jsxs("div",{className:"mt-3 flex flex-col items-center gap-1 text-sm text-gray-600",children:[e.owner_phone&&i.jsx("a",{href:`tel:${e.owner_phone}`,className:"hover:text-blue-600 transition-colors",children:e.owner_phone}),e.owner_email&&i.jsx("a",{href:`mailto:${e.owner_email}`,className:"hover:text-blue-600 transition-colors",children:e.owner_email})]})]}),e.cta_label&&i.jsxs("div",{className:"text-center mt-8 py-8",children:[i.jsx("h2",{className:"text-2xl font-bold text-gray-900 mb-4",children:"Ready to Get Started?"}),(A=e.cta_url)!=null&&A.trim()?i.jsxs(Lt,{size:"lg",onClick:y,className:"text-lg px-8 py-6 rounded-xl bg-blue-600 hover:bg-blue-700 text-white shadow-lg",children:[e.cta_label,i.jsx(sb,{className:"h-5 w-5 ml-2"})]}):i.jsx("div",{className:"max-w-md mx-auto bg-white rounded-2xl border border-gray-200 shadow-sm p-6",children:i.jsx(Utt,{presentationId:e.id,ctaLabel:e.cta_label,agentName:e.owner_name||void 0,prefillName:e.contact_name,prefillEmail:e.contact_email,prefillPhone:e.contact_phone})})]})]}),i.jsx("footer",{className:"border-t border-gray-100 bg-white mt-12 py-6 text-center text-xs text-gray-400",children:"Powered by LevelUp"})]})}function uer(){const{user:t}=Zn(),e=zs(),{data:r}=nE();return mr({queryKey:["open-houses",e,r==null?void 0:r.teamId,r==null?void 0:r.role],queryFn:async()=>{const{data:n,error:s}=await Ce.from("open_houses").select("*").eq("agent_id",e).order("event_date",{ascending:!1});if(s)throw s;let o=n||[];if((r==null?void 0:r.role)==="team_leader"&&r.teamId){const{data:c,error:a}=await Ce.rpc("get_team_open_houses",{_user_id:e});if(!a&&c){const f=[...new Set(c.map(_=>_.agent_id))],m={};if(f.length>0){const{data:_}=await Ce.from("profiles").select("id, name").in("id",f);_==null||_.forEach(w=>{w.name&&(m[w.id]=w.name)})}const y=c.map(_=>({..._,agent_name:m[_.agent_id]||void 0}));o=[...o,...y]}}return o.sort((c,a)=>a.event_date.localeCompare(c.event_date)),o},enabled:!!t&&!!e})}function der(t){const{user:e}=Zn();return mr({queryKey:["open-house",t],queryFn:async()=>{const{data:r,error:n}=await Ce.from("open_houses").select("*").eq("id",t).single();if(n)throw n;return r},enabled:!!e&&!!t})}function her(t){const{user:e}=Zn(),r=jr();return N.useEffect(()=>{if(!t)return;const n=`visitors-${t}-${Math.random().toString(36).slice(2,10)}`,s=Ce.channel(n).on("postgres_changes",{event:"*",schema:"public",table:"open_house_visitors",filter:`open_house_id=eq.${t}`},()=>{r.invalidateQueries({queryKey:["open-house-visitors",t]}),r.invalidateQueries({queryKey:["open-houses"]})}).subscribe();return()=>{Ce.removeChannel(s)}},[t,r]),mr({queryKey:["open-house-visitors",t],queryFn:async()=>{const{data:n,error:s}=await Ce.from("open_house_visitors").select("*").eq("open_house_id",t).order("created_at",{ascending:!1});if(s)throw s;return n},enabled:!!e&&!!t})}function fer(){const t=jr(),e=zs();return kr({mutationFn:async r=>{const{data:n,error:s}=await Ce.from("open_houses").insert({...r,agent_id:e}).select().single();if(s)throw s;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["open-houses"]}),Fi({title:"Open house created!"})},onError:r=>{Fi({title:"Error",description:r.message,variant:"destructive"})}})}function mer(){const t=jr();return kr({mutationFn:async({id:e,...r})=>{const{error:n}=await Ce.from("open_houses").update(r).eq("id",e);if(n)throw n},onSuccess:(e,r)=>{t.invalidateQueries({queryKey:["open-houses"]}),t.invalidateQueries({queryKey:["open-house",r.id]})}})}function per(){const t=jr();return kr({mutationFn:async e=>{const{error:r}=await Ce.from("open_houses").delete().eq("id",e);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["open-houses"]}),Fi({title:"Open house deleted"})}})}function z1e(t){return mr({queryKey:["public-open-house",t],queryFn:async()=>{const{data:e,error:r}=await Ce.from("open_houses").select("*, profiles:agent_id(name, avatar_url, title, email, phone)").eq("slug",t).eq("is_active",!0).single();if(r)throw r;let n=null;if(e.agent_id){const{data:s}=await Ce.from("agent_cards").select("slug").eq("user_id",e.agent_id).eq("is_published",!0).maybeSingle();s&&(n=s.slug)}return{...e,agent_card_slug:n}},enabled:!!t})}function ger(t){const{user:e}=Zn();return mr({queryKey:["survey-questions",t],queryFn:async()=>{const{data:r,error:n}=await Ce.from("open_house_survey_questions").select("*").eq("open_house_id",t).order("sort_order");if(n)throw n;return r},enabled:!!e&&!!t})}function Gtt(t){return mr({queryKey:["public-survey-questions",t],queryFn:async()=>{const{data:e,error:r}=await Ce.from("open_house_survey_questions").select("*").eq("open_house_id",t).eq("is_active",!0).order("sort_order");if(r)throw r;return e},enabled:!!t})}function Htt(){return kr({mutationFn:async t=>{const{error:e}=await Ce.from("open_house_survey_responses").insert(t);if(e)throw e}})}function yer(t){const{user:e}=Zn();return mr({queryKey:["survey-responses",t],queryFn:async()=>{const{data:r,error:n}=await Ce.from("open_house_survey_questions").select("*").eq("open_house_id",t).order("sort_order");if(n)throw n;const s=(r||[]).map(a=>a.id);if(s.length===0)return{questions:[],responses:[]};const{data:o,error:c}=await Ce.from("open_house_survey_responses").select("*").in("question_id",s).order("created_at",{ascending:!1});if(c)throw c;return{questions:r,responses:o||[]}},enabled:!!e&&!!t})}function xer(){const t=jr();return kr({mutationFn:async e=>{const{data:r,error:n}=await Ce.from("open_house_survey_questions").insert(e).select().single();if(n)throw n;return r},onSuccess:(e,r)=>{t.invalidateQueries({queryKey:["survey-questions",r.open_house_id]})}})}function _er(){const t=jr();return kr({mutationFn:async({id:e,open_house_id:r,...n})=>{const{error:s}=await Ce.from("open_house_survey_questions").update(n).eq("id",e);if(s)throw s},onSuccess:(e,r)=>{t.invalidateQueries({queryKey:["survey-questions",r.open_house_id]})}})}function ver(){const t=jr();return kr({mutationFn:async({id:e,open_house_id:r})=>{const{error:n}=await Ce.from("open_house_survey_questions").delete().eq("id",e);if(n)throw n},onSuccess:(e,r)=>{t.invalidateQueries({queryKey:["survey-questions",r.open_house_id]})}})}function ber(){const t=jr();return kr({mutationFn:async e=>{const{error:r}=await Ce.rpc("seed_default_survey_questions",{_open_house_id:e});if(r)throw r},onSuccess:(e,r)=>{t.invalidateQueries({queryKey:["survey-questions",r]})}})}function Wtt(){return kr({mutationFn:async t=>{const e=crypto.randomUUID(),{error:r}=await Ce.from("open_house_visitors").insert({...t,id:e});if(r)throw r;return{id:e}}})}function Ktt(){return kr({mutationFn:async({visitor_id:t,...e})=>{const{error:r}=await Ce.from("open_house_visitors").update(e).eq("id",t);if(r)throw r}})}function Ytt(){return kr({mutationFn:async t=>{await Ce.rpc("increment_open_house_scan",{_slug:t})}})}async function U1e(t){const{data:e,error:r}=await Ce.from("open_house_rooms").select("*").eq("open_house_id",t).order("sort_order");if(r)throw r;const n=e||[];if(n.length===0)return[];const s=n.map(f=>f.id),{data:o,error:c}=await Ce.from("open_house_room_media").select("*").in("room_id",s).order("sort_order");if(c)throw c;const a={};return(o||[]).forEach(f=>{var y;const m=f;(a[y=m.room_id]||(a[y]=[])).push(m)}),n.map(f=>({...f,media:a[f.id]||[]}))}function wer(t){const{user:e}=Zn();return mr({queryKey:["open-house-rooms",t],queryFn:()=>U1e(t),enabled:!!e&&!!t})}function Ztt(t){return mr({queryKey:["public-open-house-rooms",t],queryFn:()=>U1e(t),enabled:!!t})}function Ser(){const t=jr();return kr({mutationFn:async e=>{const{data:r,error:n}=await Ce.from("open_house_rooms").insert(e).select().single();if(n)throw n;return r},onSuccess:(e,r)=>{t.invalidateQueries({queryKey:["open-house-rooms",r.open_house_id]})}})}function Ter(){const t=jr();return kr({mutationFn:async({id:e,open_house_id:r,...n})=>{const{error:s}=await Ce.from("open_house_rooms").update(n).eq("id",e);if(s)throw s},onSuccess:(e,r)=>{t.invalidateQueries({queryKey:["open-house-rooms",r.open_house_id]})}})}function Eer(){const t=jr();return kr({mutationFn:async({id:e,open_house_id:r})=>{const{error:n}=await Ce.from("open_house_rooms").delete().eq("id",e);if(n)throw n},onSuccess:(e,r)=>{t.invalidateQueries({queryKey:["open-house-rooms",r.open_house_id]})}})}function jer(){const t=jr();return kr({mutationFn:async({open_house_id:e,...r})=>{const{data:n,error:s}=await Ce.from("open_house_room_media").insert(r).select().single();if(s)throw s;return n},onSuccess:(e,r)=>{t.invalidateQueries({queryKey:["open-house-rooms",r.open_house_id]})}})}function ker(){const t=jr();return kr({mutationFn:async({id:e,open_house_id:r})=>{const{error:n}=await Ce.from("open_house_room_media").delete().eq("id",e);if(n)throw n},onSuccess:(e,r)=>{t.invalidateQueries({queryKey:["open-house-rooms",r.open_house_id]})}})}function Aer(){const t=jr();return kr({mutationFn:async({open_house_id:e,orderedIds:r})=>{for(let n=0;n{const n=["open-house-rooms",e];await t.cancelQueries({queryKey:n});const s=t.getQueryData(n);if(s){const o=new Map(s.map(a=>[a.id,a])),c=r.map((a,f)=>({...o.get(a),sort_order:f})).filter(Boolean);t.setQueryData(n,c)}return{prev:s,key:n}},onError:(e,r,n)=>{n!=null&&n.prev&&t.setQueryData(n.key,n.prev)},onSettled:(e,r,n)=>{t.invalidateQueries({queryKey:["open-house-rooms",n.open_house_id]})}})}function Ner(){const t=jr();return kr({mutationFn:async({open_house_id:e,room_id:r,orderedIds:n})=>{for(let s=0;s{const s=["open-house-rooms",e];await t.cancelQueries({queryKey:s});const o=t.getQueryData(s);return o&&t.setQueryData(s,o.map(c=>{if(c.id!==r)return c;const a=new Map(c.media.map(f=>[f.id,f]));return{...c,media:n.map((f,m)=>{const y=a.get(f);return y?{...y,sort_order:m}:null}).filter(Boolean)}})),{prev:o,key:s}},onError:(e,r,n)=>{n!=null&&n.prev&&t.setQueryData(n.key,n.prev)},onSettled:(e,r,n)=>{t.invalidateQueries({queryKey:["open-house-rooms",n.open_house_id]})}})}function Cer(t){const{user:e}=Zn();return mr({queryKey:["open-house-leads",t],queryFn:async()=>{const{data:r,error:n}=await Ce.from("open_house_leads").select("*").eq("open_house_id",t).order("created_at",{ascending:!1});if(n)throw n;return r||[]},enabled:!!e&&!!t})}function Ier(){const t=jr();return kr({mutationFn:async({id:e,status:r,open_house_id:n})=>{const{error:s}=await Ce.from("open_house_leads").update({status:r}).eq("id",e);if(s)throw s;return{open_house_id:n}},onSuccess:e=>{t.invalidateQueries({queryKey:["open-house-leads",e.open_house_id]})}})}var uF="Switch",[Xtt,Per]=cl(uF),[Qtt,Jtt]=Xtt(uF),V1e=N.forwardRef((t,e)=>{const{__scopeSwitch:r,name:n,checked:s,defaultChecked:o,required:c,disabled:a,value:f="on",onCheckedChange:m,form:y,..._}=t,[w,E]=N.useState(null),A=is(e,B=>E(B)),C=N.useRef(!1),I=w?y||!!w.closest("form"):!0,[M,D]=ed({prop:s,defaultProp:o??!1,onChange:m,caller:uF});return i.jsxs(Qtt,{scope:r,checked:M,disabled:a,children:[i.jsx(cn.button,{type:"button",role:"switch","aria-checked":M,"aria-required":c,"data-state":W1e(M),"data-disabled":a?"":void 0,disabled:a,value:f,..._,ref:A,onClick:Gr(t.onClick,B=>{D(U=>!U),I&&(C.current=B.isPropagationStopped(),C.current||B.stopPropagation())})}),I&&i.jsx(H1e,{control:w,bubbles:!C.current,name:n,value:f,checked:M,required:c,disabled:a,form:y,style:{transform:"translateX(-100%)"}})]})});V1e.displayName=uF;var q1e="SwitchThumb",G1e=N.forwardRef((t,e)=>{const{__scopeSwitch:r,...n}=t,s=Jtt(q1e,r);return i.jsx(cn.span,{"data-state":W1e(s.checked),"data-disabled":s.disabled?"":void 0,...n,ref:e})});G1e.displayName=q1e;var ert="SwitchBubbleInput",H1e=N.forwardRef(({__scopeSwitch:t,control:e,checked:r,bubbles:n=!0,...s},o)=>{const c=N.useRef(null),a=is(c,o),f=OC(r),m=jC(e);return N.useEffect(()=>{const y=c.current;if(!y)return;const _=window.HTMLInputElement.prototype,E=Object.getOwnPropertyDescriptor(_,"checked").set;if(f!==r&&E){const A=new Event("click",{bubbles:n});E.call(y,r),y.dispatchEvent(A)}},[f,r,n]),i.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:r,...s,tabIndex:-1,ref:a,style:{...s.style,...m,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});H1e.displayName=ert;function W1e(t){return t?"checked":"unchecked"}var K1e=V1e,trt=G1e;const lE=N.forwardRef(({className:t,...e},r)=>i.jsx(K1e,{className:Xt("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50",t),...e,ref:r,children:i.jsx(trt,{className:Xt("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));lE.displayName=K1e.displayName;const rrt=["Excellent","Good","Neutral","Bad","Very Bad"],nrt=[5,4,3,2,1];function srt({questions:t,visitorId:e,onComplete:r,onSkip:n}){const s=Htt(),[o,c]=N.useState({}),a=t.filter(w=>w.question_type==="rating"),f=t.filter(w=>w.question_type!=="rating"),m=(w,E)=>{c(A=>({...A,[w]:{rating_value:E}}))},y=(w,E)=>{c(A=>({...A,[w]:{text_value:E}}))},_=async()=>{const w=Object.entries(o).filter(([,E])=>E.rating_value!=null||E.text_value&&E.text_value.trim()).map(([E,A])=>{var C;return{visitor_id:e,question_id:E,rating_value:A.rating_value??null,text_value:((C=A.text_value)==null?void 0:C.trim())||null}});if(w.length>0)try{await s.mutateAsync(w)}catch{}r()};return i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"flex items-center justify-between mb-2",children:[i.jsx("h2",{className:"text-lg font-bold text-slate-900",children:"Quick Feedback"}),i.jsx("button",{onClick:n,className:"text-sm text-slate-400 hover:text-slate-600 underline",children:"Skip"})]}),i.jsx("p",{className:"text-sm text-slate-500 -mt-2",children:"Your feedback helps the agent — totally optional!"}),a.length>0&&i.jsxs("div",{className:"space-y-1",children:[i.jsxs("div",{className:"flex items-center gap-1",children:[i.jsx("div",{className:"flex-1"}),rrt.map(w=>i.jsx("div",{className:"w-12 text-center",children:i.jsx("span",{className:"text-[10px] text-slate-400 leading-tight block",children:w})},w))]}),a.map(w=>i.jsxs("div",{className:"flex items-center gap-1 py-1.5 border-b border-slate-100 last:border-0",children:[i.jsx("span",{className:"flex-1 text-sm text-slate-700 pr-2",children:w.question_text}),nrt.map(E=>{var A;return i.jsx("div",{className:"w-12 flex justify-center",children:i.jsx("button",{type:"button",onClick:()=>m(w.id,E),className:`w-6 h-6 rounded-full border-2 transition-all ${((A=o[w.id])==null?void 0:A.rating_value)===E?"bg-slate-900 border-slate-900":"border-slate-300 hover:border-slate-500"}`})},E)})]},w.id))]}),f.map(w=>{var E;return i.jsxs("div",{children:[i.jsx("label",{className:"text-sm font-medium text-slate-700 block mb-1",children:w.question_text}),i.jsx(zc,{value:((E=o[w.id])==null?void 0:E.text_value)||"",onChange:A=>y(w.id,A.target.value),placeholder:"Your thoughts...",className:"h-16 text-sm resize-none rounded-xl border-slate-200"})]},w.id)}),i.jsx(Lt,{onClick:_,disabled:s.isPending,className:"w-full h-12 text-base bg-slate-900 hover:bg-slate-800 text-white rounded-xl",children:s.isPending?i.jsx(Fc,{className:"h-5 w-5 animate-spin"}):"Submit Feedback"})]})}function Pq(t){return/iframe\.mediadelivery\.net\/embed\//.test(t)}function irt({rooms:t}){var C;const[e,r]=N.useState(((C=t[0])==null?void 0:C.id)||""),[n,s]=N.useState(null),[o,c]=N.useState(null),a=N.useRef({}),f=t.find(I=>I.id===n)||t[0],m=o!==null?f==null?void 0:f.media[o]:null,y=(f==null?void 0:f.media.length)??0,_=()=>{c(null),s(null)},w=()=>c(I=>I===null||y===0?I:(I-1+y)%y),E=()=>c(I=>I===null||y===0?I:(I+1)%y);N.useEffect(()=>{if(o===null)return;const I=M=>{M.key==="Escape"?_():M.key==="ArrowLeft"?w():M.key==="ArrowRight"&&E()};return window.addEventListener("keydown",I),()=>window.removeEventListener("keydown",I)},[o,y]),N.useEffect(()=>{const I=new IntersectionObserver(M=>{const D=M.filter(B=>B.isIntersecting).sort((B,U)=>B.boundingClientRect.top-U.boundingClientRect.top);D[0]&&r(D[0].target.dataset.roomId||"")},{rootMargin:"-90px 0px -55% 0px"});return Object.values(a.current).forEach(M=>M&&I.observe(M)),()=>I.disconnect()},[t]);const A=I=>{r(I);const M=a.current[I];M&&window.scrollTo({top:M.getBoundingClientRect().top+window.scrollY-80,behavior:"smooth"})};return t.length?i.jsxs("div",{className:"hidden md:block",children:[i.jsx("div",{className:"sticky top-0 z-20 -mx-5 px-5 py-3 bg-slate-950/80 backdrop-blur-md border-b border-white/10 overflow-x-auto",children:i.jsx("div",{className:"flex gap-2 min-w-max",children:t.map(I=>i.jsxs("button",{onClick:()=>A(I.id),className:Xt("px-4 py-2 rounded-full text-sm font-medium whitespace-nowrap transition",e===I.id?"bg-white text-slate-900":"bg-white/5 text-white/70 hover:bg-white/10"),children:[I.name,i.jsx("span",{className:"ml-1.5 text-xs opacity-60",children:I.media.length})]},I.id))})}),t.map(I=>i.jsxs("section",{"data-room-id":I.id,ref:M=>{a.current[I.id]=M},className:"mt-10 first:mt-6",children:[i.jsx("h3",{className:"text-2xl font-bold",children:I.name}),I.description&&i.jsx("p",{className:"text-white/60 mt-1.5 text-sm max-w-2xl",children:I.description}),I.media.length===0?i.jsx("p",{className:"text-white/40 text-sm mt-6 italic",children:"No media yet for this room."}):i.jsx("div",{className:"mt-5 grid grid-cols-2 gap-4",children:I.media.map((M,D)=>i.jsx("button",{onClick:()=>{s(I.id),c(D)},className:Xt("relative aspect-[3/2] rounded-xl overflow-hidden bg-white/5 group",D===0&&I.media.length!==2&&"col-span-2 aspect-[16/9]"),children:M.kind==="video"?i.jsxs(i.Fragment,{children:[Pq(M.url)?i.jsx("div",{className:"absolute inset-0 bg-slate-900"}):i.jsx("video",{src:M.url,className:"w-full h-full object-cover"}),i.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/30 group-hover:bg-black/50 transition",children:i.jsx("div",{className:"w-14 h-14 rounded-full bg-white/90 flex items-center justify-center",children:i.jsx(tA,{className:"h-6 w-6 text-slate-900"})})})]}):i.jsx("img",{src:M.url,alt:I.name,loading:"lazy",className:"w-full h-full object-cover group-hover:scale-[1.03] transition-transform duration-500"})},M.id))})]},I.id)),m&&f&&i.jsxs("div",{className:"fixed inset-0 z-50 bg-black/95 flex items-center justify-center p-6 cursor-zoom-out",onClick:_,children:[i.jsxs("div",{className:"absolute top-5 left-1/2 -translate-x-1/2 px-3 py-1.5 rounded-full bg-white/10 backdrop-blur-sm text-white/80 text-xs font-medium",children:[f.name," — ",(o??0)+1," / ",y]}),i.jsx("button",{onClick:I=>{I.stopPropagation(),_()},className:"absolute top-5 right-5 h-10 w-10 rounded-full bg-white/10 hover:bg-white/20 text-white text-xl flex items-center justify-center transition","aria-label":"Close",children:"×"}),y>1&&i.jsx("button",{onClick:I=>{I.stopPropagation(),w()},className:"absolute left-5 top-1/2 -translate-y-1/2 h-12 w-12 rounded-full bg-white/10 hover:bg-white/20 text-white flex items-center justify-center transition","aria-label":"Previous",children:i.jsx(ip,{className:"h-6 w-6"})}),m.kind==="video"?Pq(m.url)?i.jsx("iframe",{src:`${m.url}?autoplay=true`,allow:"accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,className:"w-full max-w-5xl aspect-video rounded-lg",onClick:I=>I.stopPropagation()},m.url):i.jsx("video",{src:m.url,controls:!0,autoPlay:!0,className:"max-w-full max-h-full rounded-lg",onClick:I=>I.stopPropagation()},m.url):i.jsx("img",{src:m.url,alt:"",className:"max-w-full max-h-full rounded-lg cursor-default",onClick:I=>I.stopPropagation()}),y>1&&i.jsx("button",{onClick:I=>{I.stopPropagation(),E()},className:"absolute right-5 top-1/2 -translate-y-1/2 h-12 w-12 rounded-full bg-white/10 hover:bg-white/20 text-white flex items-center justify-center transition","aria-label":"Next",children:i.jsx(Vd,{className:"h-6 w-6"})})]})]}):null}function art({rooms:t}){var a;const e=[];t.forEach(f=>{e.push({type:"cover",roomId:f.id,roomName:f.name,description:f.description,mediaCount:f.media.length}),f.media.forEach((m,y)=>{e.push({type:"media",roomId:f.id,roomName:f.name,url:m.url,kind:m.kind,index:y,total:f.media.length})})});const r=N.useRef(null),[n,s]=N.useState(0);N.useEffect(()=>{const f=r.current;if(!f)return;let m=0;const y=()=>{cancelAnimationFrame(m),m=requestAnimationFrame(()=>{const _=Math.round(f.scrollLeft/f.clientWidth);s(_)})};return f.addEventListener("scroll",y,{passive:!0}),()=>{f.removeEventListener("scroll",y),cancelAnimationFrame(m)}},[]);const o=f=>{const m=r.current;m&&m.scrollTo({left:f*m.clientWidth,behavior:"smooth"})};if(!e.length)return null;const c=(a=e[n])==null?void 0:a.roomId;return i.jsxs("div",{className:"md:hidden -mx-5",children:[i.jsx("div",{className:"px-5 py-3 overflow-x-auto sticky top-0 z-20 bg-slate-950/80 backdrop-blur-md border-b border-white/10",children:i.jsx("div",{className:"flex gap-2 min-w-max",children:t.map(f=>{const m=e.findIndex(_=>_.roomId===f.id),y=c===f.id;return i.jsx("button",{onClick:()=>o(m),className:Xt("px-3.5 py-1.5 rounded-full text-xs font-medium whitespace-nowrap transition",y?"bg-white text-slate-900":"bg-white/10 text-white/80"),children:f.name},f.id)})})}),i.jsx("div",{ref:r,className:"flex overflow-x-auto snap-x snap-mandatory scroll-smooth no-scrollbar",style:{scrollSnapType:"x mandatory"},children:e.map((f,m)=>i.jsx("div",{className:"shrink-0 w-screen snap-center",children:i.jsxs("div",{className:"w-full aspect-[9/16] max-h-[75vh] bg-slate-900 relative",children:[f.type==="cover"?i.jsxs("div",{className:"w-full h-full flex flex-col items-center justify-center p-8 text-center bg-gradient-to-br from-slate-800 to-slate-950",children:[i.jsx("p",{className:"text-xs uppercase tracking-widest text-white/40 mb-2",children:"Next room"}),i.jsx("h3",{className:"text-3xl font-bold",children:f.roomName}),f.description&&i.jsx("p",{className:"text-white/70 text-sm mt-3 max-w-xs",children:f.description}),i.jsxs("p",{className:"text-white/40 text-xs mt-5",children:[f.mediaCount," ",f.mediaCount===1?"item":"items"," — swipe to view →"]})]}):f.kind==="video"?Pq(f.url)?i.jsx("iframe",{src:f.url,allow:"accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,className:"w-full h-full"}):i.jsx("video",{src:f.url,controls:!0,playsInline:!0,className:"w-full h-full object-cover"}):i.jsx("img",{src:f.url,alt:f.roomName,className:"w-full h-full object-cover"}),f.type==="media"&&i.jsxs("div",{className:"absolute top-3 left-3 right-3 flex items-center justify-between pointer-events-none",children:[i.jsx("div",{className:"px-3 py-1 rounded-full bg-black/50 backdrop-blur-sm text-xs text-white font-medium",children:f.roomName}),i.jsxs("div",{className:"px-2.5 py-1 rounded-full bg-black/50 backdrop-blur-sm text-[10px] text-white/80",children:[f.index+1," / ",f.total]})]})]})},m))}),i.jsxs("div",{className:"flex items-center justify-between px-5 mt-3",children:[i.jsxs("button",{onClick:()=>o(Math.max(0,n-1)),disabled:n===0,className:"flex items-center gap-1 text-sm text-white/70 disabled:opacity-30",children:[i.jsx(ip,{className:"h-4 w-4"})," Prev"]}),i.jsxs("span",{className:"text-xs text-white/50",children:[n+1," / ",e.length]}),i.jsxs("button",{onClick:()=>o(Math.min(e.length-1,n+1)),disabled:n===e.length-1,className:"flex items-center gap-1 text-sm text-white/70 disabled:opacity-30",children:["Next ",i.jsx(Vd,{className:"h-4 w-4"})]})]})]})}const b6={question:{label:"Ask a Question",title:"Ask the agent",placeholder:"What would you like to know about the home?",icon:Nh},showing:{label:"Schedule a Showing",title:"Request a private showing",placeholder:"Anything specific to focus on during the showing? (optional)",icon:xo},disclosure:{label:"Request Disclosures",title:"Request seller disclosures",placeholder:"Any specific documents? (optional)",icon:Ym},offer:{label:"I'm Interested — Let's Talk",title:"Express interest / make an offer",placeholder:"Tell the agent about your interest or any offer thoughts.",icon:yg}},ort=["Seller's Property Disclosure","HOA Documents & Bylaws","Inspection Reports","Title / CC&Rs","Utility & Tax History"];function lrt(t){return t==null||t<=0?null:`$${t.toLocaleString("en-US")}`}function crt({openHouse:t,visitorId:e,visitorName:r,visitorEmail:n,visitorPhone:s,previewMode:o=!1}){var Vt;const c=t.profiles,a=((Vt=c==null?void 0:c.name)==null?void 0:Vt.split(" ").map(xt=>xt[0]).join("").slice(0,2))||"?",f=t.brand_color_override||null,[m,y]=N.useState(null),[_,w]=N.useState(""),[E,A]=N.useState(n||""),[C,I]=N.useState(s||""),[M,D]=N.useState(!1),[B,U]=N.useState(null),[q,H]=N.useState(""),[K,Q]=N.useState(""),[J,ee]=N.useState(""),[oe,de]=N.useState([]),[ye,Ee]=N.useState(""),[Le,Se]=N.useState(""),[be,me]=N.useState(""),[ke,Pe]=N.useState(""),je=lrt(t.price),xe=t.tour_mode==="rooms",{data:Ue=[]}=Ztt(xe?t.id:void 0),Ze=[t.enable_question&&"question",t.enable_showing&&"showing",t.enable_disclosures&&"disclosure",t.enable_offer&&"offer"].filter(Boolean),lt=xt=>{y(xt),w(""),H(""),Q(""),ee(""),de([]),Ee(""),Se(""),me(""),Pe("")},wt=()=>{y(null)},yt=xt=>{de(or=>or.includes(xt)?or.filter(Sr=>Sr!==xt):[...or,xt])},gt=xt=>xt==="showing"?{preferred_date:q||null,preferred_time:K||null,alternate_date:J||null}:xt==="disclosure"?{requested_documents:oe}:xt==="offer"?{offer_amount:ye||null,financing:Le||null,timeline:be||null,pre_approved:ke||null}:{},ft=m?m==="showing"?!!q:m==="question"?_.trim().length>0:!0:!1,kt=async()=>{if(m){if(o){Fi({title:"Preview mode",description:"Lead not sent — this is just a preview."}),U(m),setTimeout(()=>{y(null),U(null)},1500);return}D(!0);try{const xt=gt(m),{error:or}=await Ce.from("open_house_leads").insert({open_house_id:t.id,visitor_id:e,action_type:m,payload:{message:_.trim()||null,email:E.trim()||null,phone:C.trim()||null,visitor_name:r,...xt}});if(or)throw or;Ce.functions.invoke("send-virtual-open-house-lead",{body:{open_house_id:t.id,visitor_id:e,action_type:m,message:_.trim()||null,visitor_name:r,visitor_email:E.trim()||null,visitor_phone:C.trim()||null,extras:xt}}).catch(()=>{}),U(m),Fi({title:"Sent!",description:"The agent has been notified."}),setTimeout(()=>{wt(),U(null)},1400)}catch(xt){Fi({title:"Something went wrong",description:xt.message,variant:"destructive"})}finally{D(!1)}}};return i.jsxs("div",{className:"min-h-screen bg-slate-950 text-white",children:[i.jsxs("div",{className:"relative w-full aspect-video bg-slate-900 md:max-h-[70vh]",children:[t.hero_video_url?i.jsx("video",{src:t.hero_video_url,poster:t.hero_video_thumbnail_url||t.photo_url||void 0,controls:!0,playsInline:!0,className:"w-full h-full object-cover"}):t.photo_url?i.jsx("img",{src:t.photo_url,alt:t.property_address,className:"w-full h-full object-cover"}):i.jsx("div",{className:"w-full h-full flex items-center justify-center text-white/40",children:"No tour video yet"}),i.jsx("div",{className:"absolute inset-x-0 bottom-0 h-32 bg-gradient-to-t from-slate-950 to-transparent pointer-events-none"})]}),i.jsxs("div",{className:"max-w-5xl mx-auto px-5 pb-32 -mt-10 relative z-10",children:[i.jsxs("div",{className:"bg-slate-900/80 backdrop-blur-md border border-white/10 rounded-2xl p-6 shadow-2xl",children:[i.jsx("h1",{className:"text-2xl font-bold leading-tight",children:t.property_address}),t.city&&i.jsxs("p",{className:"text-sm text-white/60 mt-1 flex items-center gap-1",children:[i.jsx(ui,{className:"h-3.5 w-3.5"}),t.city,t.state?`, ${t.state}`:""," ",t.zip]}),je&&i.jsx("p",{className:"text-3xl font-bold text-white mt-3",children:je}),i.jsxs("div",{className:"flex flex-wrap gap-4 mt-4 text-sm text-white/80",children:[t.beds!=null&&i.jsxs("span",{className:"flex items-center gap-1.5",children:[i.jsx(UT,{className:"h-4 w-4"}),t.beds," bd"]}),t.baths!=null&&i.jsxs("span",{className:"flex items-center gap-1.5",children:[i.jsx(o0,{className:"h-4 w-4"}),t.baths," ba"]}),t.sqft!=null&&i.jsxs("span",{className:"flex items-center gap-1.5",children:[i.jsx(vH,{className:"h-4 w-4"}),t.sqft.toLocaleString()," sqft"]})]}),t.property_description?i.jsx("p",{className:"text-white/80 text-sm mt-5 whitespace-pre-wrap leading-relaxed",children:t.property_description}):t.agent_greeting&&i.jsxs("p",{className:"text-white/70 text-sm mt-5 border-l-2 border-white/20 pl-3 italic",children:['"',t.agent_greeting,'"']})]}),c&&i.jsxs("div",{className:"mt-5 flex items-center gap-3 bg-white/5 border border-white/10 rounded-xl p-4",children:[t.team_photo_url?i.jsx("img",{src:t.team_photo_url,alt:c.name||"Team",className:"h-16 w-24 shrink-0 rounded-lg object-cover ring-2 ring-white/20"}):i.jsxs(i.Fragment,{children:[i.jsxs(Od,{className:"h-12 w-12 ring-2 ring-white/20",style:f?{boxShadow:`0 0 0 2px ${f}`}:void 0,children:[i.jsx(Fd,{src:c.avatar_url||"",alt:c.name||""}),i.jsx(Bd,{className:"bg-white/10 text-white",children:a})]}),t.co_host_name&&i.jsxs(Od,{className:"h-12 w-12 -ml-6 ring-2 ring-slate-950",children:[i.jsx(Fd,{src:t.co_host_photo_url||"",alt:t.co_host_name}),i.jsx(Bd,{className:"bg-white/10 text-white",children:String(t.co_host_name).split(" ").map(xt=>xt[0]).join("").slice(0,2)})]})]}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("p",{className:"font-semibold text-white truncate",children:[c.name,t.co_host_name?` & ${t.co_host_name}`:""]}),(t.brokerage_display_name||c.title)&&i.jsx("p",{className:"text-xs text-white/60 truncate",children:[!t.co_host_name&&c.title,t.brokerage_display_name].filter(Boolean).join(" · ")})]}),(c.phone||c.email)&&i.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[c.phone&&i.jsx("a",{href:`tel:${c.phone}`,"aria-label":`Call ${c.name}`,className:"h-10 w-10 rounded-full bg-white/10 hover:bg-white/20 transition-colors flex items-center justify-center text-white",style:f?{backgroundColor:`${f}33`,color:"white"}:void 0,children:i.jsx(Un,{className:"h-4 w-4"})}),c.email&&i.jsx("a",{href:`mailto:${c.email}`,"aria-label":`Email ${c.name}`,className:"h-10 w-10 rounded-full bg-white/10 hover:bg-white/20 transition-colors flex items-center justify-center text-white",style:f?{backgroundColor:`${f}33`,color:"white"}:void 0,children:i.jsx(rs,{className:"h-4 w-4"})})]})]}),xe&&Ue.length>0&&i.jsxs("div",{className:"mt-8",children:[i.jsx(irt,{rooms:Ue}),i.jsx(art,{rooms:Ue})]}),Ze.length>0&&i.jsxs("div",{className:"mt-10 pt-6 border-t border-white/10",children:[i.jsx("p",{className:"text-xs uppercase tracking-wider text-white/40 mb-3",children:"Interested in this home?"}),i.jsx("div",{className:"flex flex-wrap gap-2",children:Ze.map(xt=>{const or=b6[xt],Sr=or.icon;return i.jsxs("button",{onClick:()=>lt(xt),className:"flex items-center gap-2 px-4 py-2.5 rounded-full border border-white/15 bg-white/5 text-white/90 hover:bg-white/10 hover:border-white/30 transition-colors text-sm",children:[i.jsx(Sr,{className:"h-4 w-4",style:f?{color:f}:void 0}),i.jsx("span",{className:"font-medium",children:or.label})]},xt)})})]}),i.jsx("p",{className:"text-center text-white/30 text-xs mt-8",children:"Powered by LevelUp Virtual Open House"})]}),i.jsx(hve,{open:!!m,onOpenChange:xt=>!xt&&wt(),children:i.jsx(gW,{side:"bottom",className:"rounded-t-2xl max-h-[92vh] overflow-y-auto",children:m&&i.jsxs(i.Fragment,{children:[i.jsxs(mve,{className:"text-left",children:[i.jsx(pve,{children:b6[m].title}),i.jsxs(gve,{children:[(c==null?void 0:c.name)||"The agent"," will be notified by email."]})]}),B===m?i.jsxs("div",{className:"py-10 flex flex-col items-center gap-3",children:[i.jsx("div",{className:"w-14 h-14 rounded-full bg-green-100 flex items-center justify-center",children:i.jsx(Nl,{className:"h-7 w-7 text-green-600"})}),i.jsx("p",{className:"font-medium",children:"Message sent!"})]}):i.jsxs("div",{className:"space-y-4 pt-4",children:[i.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[i.jsxs("div",{children:[i.jsx(Fr,{className:"text-xs",children:"Email"}),i.jsx(Dr,{type:"email",value:E,onChange:xt=>A(xt.target.value),placeholder:"you@example.com",className:"mt-1"})]}),i.jsxs("div",{children:[i.jsx(Fr,{className:"text-xs",children:"Phone"}),i.jsx(Dr,{type:"tel",value:C,onChange:xt=>I(xt.target.value),placeholder:"(555) 123-4567",className:"mt-1"})]})]}),m==="showing"&&i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[i.jsxs("div",{children:[i.jsx(Fr,{className:"text-xs",children:"Preferred date *"}),i.jsx(Dr,{type:"date",value:q,onChange:xt=>H(xt.target.value),className:"mt-1"})]}),i.jsxs("div",{children:[i.jsx(Fr,{className:"text-xs",children:"Preferred time"}),i.jsx(Dr,{type:"time",value:K,onChange:xt=>Q(xt.target.value),className:"mt-1"})]})]}),i.jsxs("div",{children:[i.jsx(Fr,{className:"text-xs",children:"Alternate date (optional)"}),i.jsx(Dr,{type:"date",value:J,onChange:xt=>ee(xt.target.value),className:"mt-1"})]})]}),m==="disclosure"&&i.jsxs("div",{children:[i.jsx(Fr,{className:"text-xs",children:"Which documents? (select all that apply)"}),i.jsx("div",{className:"mt-2 space-y-2",children:ort.map(xt=>i.jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[i.jsx(aE,{checked:oe.includes(xt),onCheckedChange:()=>yt(xt)}),i.jsx("span",{children:xt})]},xt))})]}),m==="offer"&&i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[i.jsxs("div",{children:[i.jsx(Fr,{className:"text-xs",children:"Estimated offer"}),i.jsx(Dr,{value:ye,onChange:xt=>Ee(xt.target.value),placeholder:"$",className:"mt-1"})]}),i.jsxs("div",{children:[i.jsx(Fr,{className:"text-xs",children:"Financing"}),i.jsxs(Ia,{value:Le,onValueChange:Se,children:[i.jsx(_a,{className:"mt-1",children:i.jsx(Pa,{placeholder:"Select..."})}),i.jsxs(va,{children:[i.jsx(gn,{value:"Cash",children:"Cash"}),i.jsx(gn,{value:"Conventional",children:"Conventional"}),i.jsx(gn,{value:"FHA",children:"FHA"}),i.jsx(gn,{value:"VA",children:"VA"}),i.jsx(gn,{value:"Other",children:"Other"})]})]})]})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[i.jsxs("div",{children:[i.jsx(Fr,{className:"text-xs",children:"Timeline"}),i.jsxs(Ia,{value:be,onValueChange:me,children:[i.jsx(_a,{className:"mt-1",children:i.jsx(Pa,{placeholder:"Select..."})}),i.jsxs(va,{children:[i.jsx(gn,{value:"ASAP",children:"ASAP"}),i.jsx(gn,{value:"30 days",children:"30 days"}),i.jsx(gn,{value:"60 days",children:"60 days"}),i.jsx(gn,{value:"90+ days",children:"90+ days"})]})]})]}),i.jsxs("div",{children:[i.jsx(Fr,{className:"text-xs",children:"Pre-approved?"}),i.jsxs(Ia,{value:ke,onValueChange:Pe,children:[i.jsx(_a,{className:"mt-1",children:i.jsx(Pa,{placeholder:"Select..."})}),i.jsxs(va,{children:[i.jsx(gn,{value:"Yes",children:"Yes"}),i.jsx(gn,{value:"No",children:"No"}),i.jsx(gn,{value:"In progress",children:"In progress"})]})]})]})]})]}),i.jsxs("div",{children:[i.jsxs(Fr,{className:"text-xs",children:["Message",m==="question"?" *":" (optional)"]}),i.jsx(zc,{value:_,onChange:xt=>w(xt.target.value),placeholder:b6[m].placeholder,rows:4,className:"mt-1"})]}),i.jsx(Lt,{onClick:kt,disabled:M||!ft,className:"w-full h-12 text-white hover:opacity-90",style:f?{backgroundColor:f}:void 0,children:M?i.jsx(Fc,{className:"h-4 w-4 animate-spin"}):"Send to agent"})]})]})})})]})}const urt=zg({first_name:Ds().trim().min(1,"First name is required").max(50),last_name:Ds().trim().max(50).optional(),email:Ds().trim().email("Please enter a valid email").max(255).optional().or(oO("")),phone:Ds().trim().max(20).optional().or(oO(""))}),drt=[{value:"buying",label:"Looking to Buy",emoji:"🏠"},{value:"selling",label:"Thinking of Selling",emoji:"📋"},{value:"browsing",label:"Just Browsing",emoji:"👀"},{value:"neighbor",label:"I'm a Neighbor",emoji:"👋"}];function Y1e({slug:t}={}){var Kt;const e=Vf(),r=t||e.slug,[n]=c0(),s=n.get("kiosk")==="1"||n.get("mode")==="kiosk",o=8,{data:c,isLoading:a,error:f}=z1e(r),m=Wtt(),y=Ktt(),_=Ytt(),w=N.useRef(!1),[E,A]=N.useState("welcome"),[C,I]=N.useState(null),[M,D]=N.useState({first_name:"",last_name:"",email:"",phone:"",visitor_address:""}),[B,U]=N.useState(""),[q,H]=N.useState(!1),[K,Q]=N.useState(!1),[J,ee]=N.useState(""),[oe,de]=N.useState(""),[ye,Ee]=N.useState(o),[Le,Se]=N.useState(!1),[be,me]=N.useState(null),ke=c==null?void 0:c.agent_card_slug,Pe=ke?`https://cards.relevelup.com/${ke}${c!=null&&c.disclosure_pdf_url?`?oh_disclosure=${encodeURIComponent(c.disclosure_pdf_url)}`:""}`:null,je=E==="done"&&!s&&!!Pe&&!!(c!=null&&c.auto_forward_to_card);N.useEffect(()=>{if(!je||Le){me(null);return}let At=c!=null&&c.disclosure_pdf_url?10:3;me(At);const pr=setInterval(()=>{if(At-=1,At<=0){clearInterval(pr),window.location.href=Pe;return}me(At)},1e3);return()=>clearInterval(pr)},[je,Le,Pe,c==null?void 0:c.disclosure_pdf_url]);const xe=N.useCallback(()=>{I(null),D({first_name:"",last_name:"",email:"",phone:"",visitor_address:""}),U(""),H(!1),Q(!1),ee(""),de(""),Ee(o),A(s?"info":"welcome")},[s]),Ue=N.useCallback((At,pr)=>{c!=null&&c.id&&Ce.functions.invoke("guestbook-lead-notify",{body:{open_house_id:c.id,visitor_id:At,first_name:pr.first_name??M.first_name,last_name:pr.last_name??M.last_name,email:pr.email??M.email,phone:pr.phone??M.phone,visitor_intent:pr.visitor_intent??B,message:pr.message,wants_market_updates:pr.wants_market_updates??q,has_agent:pr.has_agent??K,working_with_agent_name:pr.working_with_agent_name??J,visitor_address:pr.visitor_address??M.visitor_address}}).catch(yn=>console.error("Guest book lead notify failed:",yn))},[c==null?void 0:c.id,M,B,q,K,J]);N.useEffect(()=>{if(!s||E!=="done")return;Ee(o);const At=setInterval(()=>{Ee(pr=>pr<=1?(clearInterval(At),xe(),0):pr-1)},1e3);return()=>clearInterval(At)},[s,E,xe]),N.useEffect(()=>{if(!s)return;A(pr=>pr==="welcome"?"info":pr);let At=null;return(async()=>{var pr,yn;try{At=await((yn=(pr=navigator.wakeLock)==null?void 0:pr.request)==null?void 0:yn.call(pr,"screen"))}catch{}})(),()=>{var pr;try{(pr=At==null?void 0:At.release)==null||pr.call(At)}catch{}}},[s]);const Ze=N.useCallback(()=>{var pr;const At=document.documentElement;document.fullscreenElement||(pr=At.requestFullscreen||At.webkitRequestFullscreen)==null||pr.call(At).catch(()=>{})},[]),{data:lt,isLoading:wt}=Gtt(c==null?void 0:c.id),yt=!!(c!=null&&c.enable_survey),gt=(c==null?void 0:c.ask_visitor_intent)!==!1,ft=(c==null?void 0:c.ask_visitor_address)===!0;N.useEffect(()=>{if(!r||!(c!=null&&c.id)||w.current)return;const At=`oh_scan_${c.id}`;if(sessionStorage.getItem(At)){w.current=!0;return}w.current=!0,sessionStorage.setItem(At,"1"),_.mutate(r)},[r,c==null?void 0:c.id]),N.useEffect(()=>{E==="pending_survey"&&(wt||A(yt&&((lt==null?void 0:lt.length)??0)>0?"survey":"done"))},[E,wt,yt,lt]);const kt=At=>{if(!At)return"";const[pr,yn]=At.split(":"),Gn=parseInt(pr),Fn=Gn>=12?"PM":"AM";return`${Gn>12?Gn-12:Gn||12}:${yn} ${Fn}`},Vt=async()=>{de("");const At=urt.safeParse(M);if(!At.success){de(At.error.issues[0].message);return}if(!M.email&&!M.phone){de("Please provide either an email or phone number");return}const pr=(c==null?void 0:c.kind)==="virtual";let yn=null;if(!C&&(c!=null&&c.id))try{const Gn=await m.mutateAsync({open_house_id:c.id,first_name:M.first_name.trim(),last_name:M.last_name.trim()||void 0,email:M.email.trim()||void 0,phone:M.phone.trim()||void 0,visitor_address:ft&&M.visitor_address.trim()?M.visitor_address.trim():void 0,wants_market_updates:q,has_agent:K,working_with_agent_name:K&&J.trim()?J.trim():void 0,partial_signin:pr?!1:gt});yn=Gn.id,I(Gn.id)}catch{if(pr){de("We could not start the virtual tour. Please try again.");return}}if(pr){gt?A("intent"):(yn&&Ue(yn,{}),A("done"));return}if(!gt){yn&&Ue(yn,{}),yt?!wt&<&<.length>0?A("survey"):A("pending_survey"):A("done");return}A("intent")},xt=async At=>{U(At);try{let pr=C;if(pr?await y.mutateAsync({visitor_id:pr,visitor_intent:At,wants_market_updates:q,has_agent:K,working_with_agent_name:K&&J.trim()?J.trim():null,partial_signin:!1}):(pr=(await m.mutateAsync({open_house_id:c.id,first_name:M.first_name.trim(),last_name:M.last_name.trim()||void 0,email:M.email.trim()||void 0,phone:M.phone.trim()||void 0,visitor_address:ft&&M.visitor_address.trim()?M.visitor_address.trim():void 0,visitor_intent:At,wants_market_updates:q,has_agent:K,working_with_agent_name:K&&J.trim()?J.trim():void 0,partial_signin:!1})).id,I(pr)),pr&&Ue(pr,{visitor_intent:At,wants_market_updates:q,has_agent:K,working_with_agent_name:K&&J.trim()?J.trim():null}),(c==null?void 0:c.kind)==="virtual"){A("done");return}yt?!wt&<&<.length>0?A("survey"):A("pending_survey"):A("done")}catch{de("Something went wrong. Please try again.")}};if(a)return i.jsx("div",{className:"min-h-screen bg-gradient-to-br from-slate-900 via-slate-800 to-slate-900 flex items-center justify-center",children:i.jsx("div",{className:"w-10 h-10 border-4 border-white/20 border-t-white rounded-full animate-spin"})});if(f||!c)return i.jsx("div",{className:"min-h-screen bg-gradient-to-br from-slate-900 via-slate-800 to-slate-900 flex items-center justify-center p-6",children:i.jsxs("div",{className:"text-center text-white",children:[i.jsx(ea,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),i.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Open House Not Found"}),i.jsx("p",{className:"text-white/60",children:"This sign-in page doesn't exist or is no longer active."})]})});const or=c.profiles,Sr=((Kt=or==null?void 0:or.name)==null?void 0:Kt.split(" ").map(At=>At[0]).join("").slice(0,2))||"?",rn=c.event_type==="community",Rr=c.kind==="virtual",$r=typeof window<"u"&&new URLSearchParams(window.location.search).get("preview")==="1";if(Rr&&($r||E==="done"))return!$r&&!C?i.jsx("div",{className:"min-h-screen bg-gradient-to-br from-slate-900 via-slate-800 to-slate-900 flex items-center justify-center",children:i.jsx("div",{className:"w-10 h-10 border-4 border-white/20 border-t-white rounded-full animate-spin"})}):i.jsxs(i.Fragment,{children:[i.jsxs(_o,{children:[i.jsxs("title",{children:["Virtual Tour | ",c.property_address]}),i.jsx("meta",{name:"description",content:`Take a virtual tour of ${c.property_address}`}),i.jsx("meta",{name:"robots",content:"noindex, nofollow"})]}),$r&&i.jsx("div",{className:"fixed top-3 left-1/2 -translate-x-1/2 z-[100] bg-amber-500 text-white text-xs font-semibold px-3 py-1.5 rounded-full shadow-lg pointer-events-none",children:"Agent Preview Mode — visitors won't see this"}),i.jsx(crt,{openHouse:c,visitorId:$r?"preview":C,visitorName:$r?"Preview Visitor":`${M.first_name} ${M.last_name}`.trim(),visitorEmail:$r?"":M.email,visitorPhone:$r?"":M.phone,previewMode:$r})]});const Nn=`${Rr?"Virtual Open House":rn?"Community Event":"Open House"} — ${c.property_address}`,Tt=[[c.city,c.state].filter(Boolean).join(", "),c.event_date?Ls(new Date(c.event_date+"T00:00:00"),"EEE, MMM d"):null,or!=null&&or.name?`Hosted by ${or.name}`:null].filter(Boolean).join(" · "),Zt=c.photo_url||"",ar=Zt&&Zt.includes("/storage/v1/object/public/")?Zt.replace("/object/public/","/render/image/public/")+"?width=1200&height=630&resize=cover":Zt||"https://dashboard.relevelup.com/og-image.png",Wt=typeof window<"u"?window.location.href:`https://guestbook.relevelup.com/${r}`;return i.jsxs(i.Fragment,{children:[i.jsxs(_o,{children:[i.jsx("title",{children:Nn}),i.jsx("meta",{name:"description",content:Tt||`Sign in to ${c.property_address}`}),i.jsx("meta",{property:"og:type",content:"website"}),i.jsx("meta",{property:"og:title",content:Nn}),i.jsx("meta",{property:"og:description",content:Tt||`Sign in to ${c.property_address}`}),i.jsx("meta",{property:"og:image",content:ar}),i.jsx("meta",{property:"og:image:width",content:"1200"}),i.jsx("meta",{property:"og:image:height",content:"630"}),i.jsx("meta",{property:"og:url",content:Wt}),i.jsx("meta",{property:"og:site_name",content:"ReLevel Up"}),i.jsx("meta",{name:"twitter:card",content:"summary_large_image"}),i.jsx("meta",{name:"twitter:title",content:Nn}),i.jsx("meta",{name:"twitter:description",content:Tt||`Sign in to ${c.property_address}`}),i.jsx("meta",{name:"twitter:image",content:ar}),i.jsx("meta",{name:"robots",content:"noindex, nofollow"})]}),i.jsx("div",{className:"min-h-screen bg-gradient-to-br from-slate-900 via-slate-800 to-slate-900 flex items-center justify-center p-4",children:i.jsxs("div",{className:"w-full max-w-md",children:[i.jsxs("div",{className:"text-center mb-6",children:[i.jsxs(Od,{className:"h-16 w-16 mx-auto mb-3 ring-2 ring-white/20",children:[i.jsx(Fd,{src:(or==null?void 0:or.avatar_url)||"",alt:(or==null?void 0:or.name)||""}),i.jsx(Bd,{className:"bg-white/10 text-white text-lg",children:Sr})]}),i.jsx("p",{className:"text-white/60 text-sm",children:or==null?void 0:or.name}),(or==null?void 0:or.title)&&i.jsx("p",{className:"text-white/40 text-xs",children:or.title})]}),i.jsxs("div",{className:"bg-white rounded-2xl shadow-2xl overflow-hidden",children:[c.photo_url&&i.jsxs("div",{className:"relative h-44 sm:h-52 overflow-hidden",children:[i.jsx("img",{src:c.photo_url,alt:c.property_address,className:"w-full h-full object-cover"}),i.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-slate-900/80 via-slate-900/20 to-transparent"}),i.jsxs("div",{className:"absolute bottom-0 left-0 right-0 px-6 pb-4",children:[i.jsx("h1",{className:"text-white font-bold text-lg leading-tight drop-shadow-md",children:c.property_address}),i.jsxs("div",{className:"flex flex-wrap gap-3 mt-1.5 text-white/70 text-xs",children:[c.city&&i.jsxs("span",{className:"flex items-center gap-1",children:[i.jsx(ui,{className:"h-3 w-3"}),c.city,c.state?`, ${c.state}`:""," ",c.zip]}),!Rr&&i.jsxs(i.Fragment,{children:[i.jsxs("span",{className:"flex items-center gap-1",children:[i.jsx(xo,{className:"h-3 w-3"}),Ls(new Date(c.event_date+"T00:00:00"),"MMM d, yyyy")]}),c.start_time&&i.jsxs("span",{className:"flex items-center gap-1",children:[i.jsx(ql,{className:"h-3 w-3"}),kt(c.start_time),c.end_time?` – ${kt(c.end_time)}`:""]})]})]})]})]}),!c.photo_url&&i.jsx("div",{className:"bg-gradient-to-r from-slate-800 to-slate-700 px-6 py-5",children:i.jsxs("div",{className:"flex items-start gap-3",children:[i.jsx("div",{className:"w-10 h-10 rounded-xl bg-white/10 flex items-center justify-center shrink-0 mt-0.5",children:rn?i.jsx(Ja,{className:"h-5 w-5 text-white"}):i.jsx(ea,{className:"h-5 w-5 text-white"})}),i.jsxs("div",{children:[i.jsx("h1",{className:"text-white font-bold text-lg leading-tight",children:c.property_address}),i.jsxs("div",{className:"flex flex-wrap gap-3 mt-2 text-white/60 text-xs",children:[c.city&&i.jsxs("span",{className:"flex items-center gap-1",children:[i.jsx(ui,{className:"h-3 w-3"}),c.city,c.state?`, ${c.state}`:""," ",c.zip]}),!Rr&&i.jsxs(i.Fragment,{children:[i.jsxs("span",{className:"flex items-center gap-1",children:[i.jsx(xo,{className:"h-3 w-3"}),Ls(new Date(c.event_date+"T00:00:00"),"MMM d, yyyy")]}),c.start_time&&i.jsxs("span",{className:"flex items-center gap-1",children:[i.jsx(ql,{className:"h-3 w-3"}),kt(c.start_time),c.end_time?` – ${kt(c.end_time)}`:""]})]})]})]})]})}),i.jsxs("div",{className:"p-6",children:[E==="welcome"&&i.jsxs("div",{className:"text-center space-y-6",children:[i.jsxs("div",{children:[i.jsx("h2",{className:"text-xl font-bold text-slate-900 mb-2",children:"Welcome!"}),i.jsx("p",{className:"text-slate-500 text-sm",children:c.agent_greeting||"Please sign in below."})]}),i.jsxs(Lt,{onClick:()=>A("info"),className:"w-full h-14 text-base bg-slate-900 hover:bg-slate-800 text-white rounded-xl",children:["Sign In ",i.jsx(ji,{className:"h-5 w-5 ml-2"})]}),i.jsx("p",{className:"text-xs text-slate-400",children:"Quick & easy — takes 30 seconds"})]}),E==="info"&&i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[i.jsx("button",{onClick:()=>A("welcome"),className:"text-slate-400 hover:text-slate-600",children:i.jsx($x,{className:"h-4 w-4"})}),i.jsx("h2",{className:"text-lg font-bold text-slate-900",children:"Your Info"})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[i.jsxs("div",{children:[i.jsx(Fr,{className:"text-slate-600 text-xs",children:"First Name *"}),i.jsx(Dr,{value:M.first_name,onChange:At=>D(pr=>({...pr,first_name:At.target.value})),placeholder:"First",className:"mt-1 h-12 rounded-xl border-slate-200 text-base",autoFocus:!0})]}),i.jsxs("div",{children:[i.jsx(Fr,{className:"text-slate-600 text-xs",children:"Last Name"}),i.jsx(Dr,{value:M.last_name,onChange:At=>D(pr=>({...pr,last_name:At.target.value})),placeholder:"Last",className:"mt-1 h-12 rounded-xl border-slate-200 text-base"})]})]}),i.jsxs("div",{children:[i.jsx(Fr,{className:"text-slate-600 text-xs",children:"Email"}),i.jsx(Dr,{type:"email",value:M.email,onChange:At=>D(pr=>({...pr,email:At.target.value})),placeholder:"your@email.com",className:"mt-1 h-12 rounded-xl border-slate-200 text-base"})]}),i.jsxs("div",{children:[i.jsx(Fr,{className:"text-slate-600 text-xs",children:"Phone"}),i.jsx(Dr,{type:"tel",value:M.phone,onChange:At=>D(pr=>({...pr,phone:At.target.value})),placeholder:"(555) 123-4567",className:"mt-1 h-12 rounded-xl border-slate-200 text-base"})]}),ft&&i.jsxs("div",{children:[i.jsx(Fr,{className:"text-slate-600 text-xs",children:"Your Home Address"}),i.jsx(Dr,{value:M.visitor_address,onChange:At=>D(pr=>({...pr,visitor_address:At.target.value})),placeholder:"Street, City, State ZIP",className:"mt-1 h-12 rounded-xl border-slate-200 text-base",autoComplete:"street-address"})]}),i.jsxs("label",{className:"flex items-center gap-2 cursor-pointer pt-1",children:[i.jsx("input",{type:"checkbox",checked:q,onChange:At=>H(At.target.checked),className:"rounded border-slate-300 text-slate-900 focus:ring-slate-500"}),i.jsx("span",{className:"text-sm text-slate-600",children:"Send me market updates for this area"})]}),i.jsxs("div",{className:"space-y-2 pt-1",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("span",{className:"text-sm text-slate-600",children:"Already working with an agent?"}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-xs font-medium text-slate-400",children:K?"Yes":"No"}),i.jsx(lE,{checked:K,onCheckedChange:Q})]})]}),K&&i.jsx(Dr,{value:J,onChange:At=>ee(At.target.value),placeholder:"Agent's name",className:"mt-1 h-10 rounded-xl border-slate-200 text-sm"})]}),oe&&i.jsx("p",{className:"text-destructive text-sm",children:oe}),i.jsxs(Lt,{onClick:Vt,className:"w-full h-14 text-base bg-slate-900 hover:bg-slate-800 text-white rounded-xl",children:["Continue ",i.jsx(ji,{className:"h-5 w-5 ml-2"})]})]}),E==="intent"&&i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[i.jsx("button",{onClick:()=>A("info"),className:"text-slate-400 hover:text-slate-600",children:i.jsx($x,{className:"h-4 w-4"})}),i.jsx("h2",{className:"text-lg font-bold text-slate-900",children:"What brings you here?"})]}),i.jsx("div",{className:"grid grid-cols-2 gap-3",children:drt.map(At=>i.jsxs("button",{onClick:()=>xt(At.value),disabled:m.isPending,className:"flex flex-col items-center gap-2 p-5 rounded-xl border-2 border-slate-200 hover:border-slate-900 hover:bg-slate-50 transition-all text-center group",children:[i.jsx("span",{className:"text-2xl",children:At.emoji}),i.jsx("span",{className:"text-sm font-medium text-slate-700 group-hover:text-slate-900",children:At.label})]},At.value))}),oe&&i.jsx("p",{className:"text-destructive text-sm text-center",children:oe})]}),E==="pending_survey"&&i.jsxs("div",{className:"flex flex-col items-center justify-center py-8 gap-3",children:[i.jsx("div",{className:"w-8 h-8 border-[3px] border-slate-200 border-t-slate-900 rounded-full animate-spin"}),i.jsx("p",{className:"text-sm text-slate-500",children:"Loading survey..."})]}),E==="survey"&&C&<&&i.jsx(srt,{questions:lt,visitorId:C,onComplete:()=>A("done"),onSkip:()=>A("done")}),E==="done"&&i.jsxs("div",{className:"text-center space-y-4 py-4",children:[i.jsx("div",{className:"w-16 h-16 rounded-full bg-green-100 flex items-center justify-center mx-auto",children:i.jsx(Nl,{className:"h-8 w-8 text-green-600"})}),i.jsxs("div",{children:[i.jsx("h2",{className:"text-xl font-bold text-slate-900",children:"You're all set!"}),i.jsxs("p",{className:"text-slate-500 text-sm mt-1",children:["Thanks for signing in, ",M.first_name,". ",rn?"Enjoy the event!":"Enjoy the open house!"]})]}),i.jsxs("div",{className:"flex flex-col sm:flex-row gap-2 justify-center",children:[(c==null?void 0:c.disclosure_pdf_url)&&i.jsxs("a",{href:`https://docs.google.com/gview?url=${encodeURIComponent(c.disclosure_pdf_url)}&embedded=true`,target:"_blank",rel:"noopener noreferrer",onClick:()=>Se(!0),className:"inline-flex items-center justify-center gap-2 px-5 py-3 rounded-xl bg-slate-100 hover:bg-slate-200 text-slate-800 font-medium text-sm transition-colors",children:[i.jsx(Ym,{className:"h-4 w-4"}),"View Seller's Disclosures"]}),Pe&&i.jsxs("a",{href:Pe,className:"inline-flex items-center justify-center gap-2 px-5 py-3 rounded-xl bg-slate-900 hover:bg-slate-800 text-white font-medium text-sm transition-colors",children:[i.jsx(ji,{className:"h-4 w-4"}),"View ",or!=null&&or.name?`${or.name.split(" ")[0]}'s`:"My"," Business Card"]})]}),Pe&&be!==null&&!Le&&i.jsxs("p",{className:"text-xs text-slate-400",children:["Opening the business card in ",be,"s…"," ",i.jsx("button",{type:"button",className:"underline",onClick:()=>Se(!0),children:"Stay here"})]}),(or==null?void 0:or.name)&&i.jsxs("p",{className:"text-sm text-slate-400",children:["Your host today: ",i.jsx("strong",{className:"text-slate-600",children:or.name})]}),s&&i.jsxs("div",{className:"pt-4 space-y-3",children:[i.jsx(Lt,{onClick:xe,className:"w-full h-14 text-base font-semibold rounded-xl",children:"Sign in next visitor"}),i.jsxs("p",{className:"text-xs text-slate-400",children:["Ready for the next visitor in ",ye,"s…"]})]})]})]})]}),i.jsx("p",{className:"text-center text-white/30 text-xs mt-6",children:"Powered by LevelUp Guest Book"}),s&&i.jsxs("div",{className:"fixed top-3 right-3 flex items-center gap-2 z-50",children:[i.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full bg-white/10 backdrop-blur-sm text-white/80 text-[11px] px-2.5 py-1 border border-white/10",children:[i.jsx(F4e,{className:"h-3 w-3"})," Tablet Mode"]}),i.jsx("button",{onClick:Ze,className:"inline-flex items-center gap-1 rounded-full bg-white/10 backdrop-blur-sm text-white/80 text-[11px] px-2.5 py-1 border border-white/10 hover:bg-white/20",title:"Enter full screen",children:i.jsx(_4e,{className:"h-3 w-3"})})]})]})})]})}const hrt=Object.freeze(Object.defineProperty({__proto__:null,default:Y1e},Symbol.toStringTag,{value:"Module"}));function Rer(t){return mr({queryKey:["open-house-rsvps",t],queryFn:async()=>{const{data:e,error:r}=await Ce.from("open_house_rsvps").select("*").eq("open_house_id",t).order("created_at",{ascending:!1});if(r)throw r;return e||[]},enabled:!!t})}function frt(){const t=jr();return kr({mutationFn:async e=>{const{error:r}=await Ce.from("open_house_rsvps").insert({open_house_id:e.open_house_id,first_name:e.first_name,last_name:e.last_name||null,email:e.email||null,phone:e.phone||null,has_agent:e.has_agent??!1,working_with_agent_name:e.working_with_agent_name||null,message:e.message||null});if(r)throw r;return null},onSuccess:(e,r)=>{t.invalidateQueries({queryKey:["open-house-rsvps",r.open_house_id]})}})}function Ler(t){const e=jr();return kr({mutationFn:async r=>{const{error:n}=await Ce.from("open_house_rsvps").delete().eq("id",r);if(n)throw n},onSuccess:()=>e.invalidateQueries({queryKey:["open-house-rsvps",t]})})}function Mer(t){const e=jr();return kr({mutationFn:async({id:r,checkedIn:n})=>{const{error:s}=await Ce.from("open_house_rsvps").update({checked_in_at:n?new Date().toISOString():null}).eq("id",r);if(s)throw s},onSuccess:()=>e.invalidateQueries({queryKey:["open-house-rsvps",t]})})}const mrt=zg({first_name:Ds().trim().min(1,"First name is required").max(50),last_name:Ds().trim().max(50).optional(),email:Ds().trim().email("Please enter a valid email").max(255),phone:Ds().trim().max(20).optional().or(oO("")),message:Ds().trim().max(500).optional().or(oO(""))}),w6=t=>{if(!t)return"";const[e,r]=t.split(":"),n=parseInt(e,10),s=n>=12?"PM":"AM";return`${n>12?n-12:n||12}:${r} ${s}`},prt=t=>{if(!t)return null;const[e,r,n]=t.split(/[-/T]/).map(Number);return!e||!r||!n?null:new Date(e,r-1,n)};function Z1e({slug:t}={}){const e=Vf(),r=t||e.slug,{data:n,isLoading:s,error:o}=z1e(r),c=frt(),[a,f]=N.useState({first_name:"",last_name:"",email:"",phone:"",message:""}),[m,y]=N.useState(!1),[_,w]=N.useState(""),[E,A]=N.useState(""),[C,I]=N.useState(!1),M=N.useMemo(()=>prt(n==null?void 0:n.event_date),[n==null?void 0:n.event_date]),D=N.useMemo(()=>{const Q=n==null?void 0:n.photo_url;return Q?Q.includes("/storage/v1/object/public/")?Q.replace("/object/public/","/render/image/public/")+"?width=1600&quality=80":Q:""},[n]),B=n==null?void 0:n.profiles,U=[n==null?void 0:n.city,n==null?void 0:n.state].filter(Boolean).join(", "),q=async()=>{A("");const Q=mrt.safeParse(a);if(!Q.success){A(Q.error.issues[0].message);return}try{await c.mutateAsync({open_house_id:n.id,first_name:a.first_name.trim(),last_name:a.last_name.trim()||void 0,email:a.email.trim(),phone:a.phone.trim()||void 0,has_agent:m,working_with_agent_name:m&&_.trim()?_.trim():void 0,message:a.message.trim()||void 0}),I(!0)}catch(J){A((J==null?void 0:J.message)||"Something went wrong. Please try again.")}},H=N.useMemo(()=>{if(!n||!M)return"";const Q=Ee=>String(Ee).padStart(2,"0"),J=`${M.getFullYear()}${Q(M.getMonth()+1)}${Q(M.getDate())}`,ee=(n.start_time||"12:00").slice(0,5).replace(":","")+"00",oe=(n.end_time||"14:00").slice(0,5).replace(":","")+"00",de=encodeURIComponent(`Open House — ${n.property_address}`),ye=encodeURIComponent([n.property_address,U,n.zip].filter(Boolean).join(", "));return`https://calendar.google.com/calendar/render?action=TEMPLATE&text=${de}&dates=${J}T${ee}/${J}T${oe}&location=${ye}`},[n,M,U]);if(s)return i.jsx("div",{className:"min-h-screen flex items-center justify-center bg-[#0f1c22]",children:i.jsx("div",{className:"h-10 w-10 rounded-full border-2 border-white/20 border-t-white animate-spin"})});if(o||!n)return i.jsx("div",{className:"min-h-screen flex items-center justify-center bg-[#0f1c22] p-6 text-center",children:i.jsxs("div",{className:"text-white/80",children:[i.jsx(ea,{className:"h-8 w-8 mx-auto mb-3 opacity-50"}),i.jsx("h1",{className:"text-xl font-semibold mb-1",children:"Open house not found"}),i.jsx("p",{className:"text-sm text-white/50",children:"This RSVP link may have expired."})]})});const K=`https://www.google.com/maps/search/?api=1&query=${encodeURIComponent([n.property_address,U,n.zip].filter(Boolean).join(", "))}`;return i.jsxs("div",{className:"min-h-screen bg-[#f6f2ee]",children:[i.jsxs(_o,{children:[i.jsx("title",{children:`RSVP — Open House at ${n.property_address}`}),i.jsx("meta",{name:"description",content:`Reserve your spot for the open house at ${n.property_address}${M?` on ${Ls(M,"EEEE, MMMM d")}`:""}.`})]}),i.jsxs("header",{className:"relative",children:[i.jsxs("div",{className:"relative h-[46vh] min-h-[320px] w-full overflow-hidden bg-[#1b3a4b]",children:[D&&i.jsx("img",{src:D,alt:n.property_address,className:"absolute inset-0 h-full w-full object-cover"}),i.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-[#0f1c22] via-[#0f1c22]/55 to-[#0f1c22]/25"}),i.jsx("div",{className:"absolute inset-x-0 bottom-0 p-6 sm:p-10",children:i.jsxs("div",{className:"mx-auto max-w-3xl",children:[i.jsx("p",{className:"text-[11px] uppercase tracking-[0.35em] text-[#d4b978] mb-3",children:"Open House"}),i.jsx("h1",{className:"font-serif text-3xl sm:text-4xl font-bold text-white leading-tight",children:n.property_address}),U&&i.jsxs("p",{className:"mt-1 text-white/70",children:[U," ",n.zip||""]}),i.jsxs("div",{className:"mt-4 flex flex-wrap gap-x-5 gap-y-2 text-sm text-white/85",children:[M&&i.jsxs("span",{className:"flex items-center gap-1.5",children:[i.jsx(xo,{className:"h-4 w-4 text-[#d4b978]"}),Ls(M,"EEEE, MMMM d, yyyy")]}),n.start_time&&i.jsxs("span",{className:"flex items-center gap-1.5",children:[i.jsx(ql,{className:"h-4 w-4 text-[#d4b978]"}),w6(n.start_time),n.end_time?` – ${w6(n.end_time)}`:""]})]})]})})]}),i.jsx("div",{className:"h-1 bg-gradient-to-r from-[#b8975a] via-[#d4b978] to-[#b8975a]"})]}),i.jsxs("main",{className:"mx-auto max-w-3xl px-5 py-8 sm:py-12 space-y-8",children:[(n.price||n.beds||n.baths||n.sqft)&&i.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[n.price?i.jsx(yL,{icon:i.jsx(ea,{className:"h-4 w-4"}),label:"Price",value:`$${Number(n.price).toLocaleString()}`}):null,n.beds?i.jsx(yL,{icon:i.jsx(Qge,{className:"h-4 w-4"}),label:"Beds",value:String(n.beds)}):null,n.baths?i.jsx(yL,{icon:i.jsx(o0,{className:"h-4 w-4"}),label:"Baths",value:String(n.baths)}):null,n.sqft?i.jsx(yL,{icon:i.jsx(yC,{className:"h-4 w-4"}),label:"Sq Ft",value:Number(n.sqft).toLocaleString()}):null]}),n.property_description&&i.jsx("p",{className:"text-[15px] leading-relaxed text-[#3a4a51] whitespace-pre-line",children:n.property_description}),i.jsx("section",{id:"rsvp",className:"rounded-2xl bg-white shadow-[0_10px_40px_rgba(15,28,34,0.08)] overflow-hidden",children:C?i.jsxs("div",{className:"p-8 sm:p-12 text-center",children:[i.jsx("div",{className:"mx-auto mb-4 flex h-14 w-14 items-center justify-center rounded-full bg-emerald-500/10",children:i.jsx(Nl,{className:"h-7 w-7 text-emerald-600"})}),i.jsx("h2",{className:"font-serif text-2xl font-semibold text-[#1b3a4b]",children:"You're on the list!"}),i.jsxs("p",{className:"mt-2 text-[#5b6b72]",children:["We'll see you ",M?Ls(M,"EEEE, MMMM d"):"soon",n.start_time?` at ${w6(n.start_time)}`:"",". A confirmation reminder will land in your inbox before the event."]}),i.jsxs("div",{className:"mt-6 flex flex-wrap justify-center gap-3",children:[H&&i.jsx(Lt,{asChild:!0,className:"bg-[#1b3a4b] hover:bg-[#25505f]",children:i.jsxs("a",{href:H,target:"_blank",rel:"noreferrer",children:[i.jsx(Jge,{className:"mr-2 h-4 w-4"}),"Add to calendar"]})}),i.jsx(Lt,{asChild:!0,variant:"outline",children:i.jsxs("a",{href:K,target:"_blank",rel:"noreferrer",children:[i.jsx(ui,{className:"mr-2 h-4 w-4"}),"Get directions"]})})]})]}):i.jsxs("div",{className:"p-6 sm:p-8",children:[i.jsx("h2",{className:"font-serif text-2xl font-semibold text-[#1b3a4b]",children:"Reserve your spot"}),i.jsx("p",{className:"mt-1 text-sm text-[#5b6b72]",children:"Let us know you're coming and we'll save you a spot and send a reminder."}),i.jsxs("div",{className:"mt-6 grid gap-4 sm:grid-cols-2",children:[i.jsxs("div",{className:"space-y-1.5",children:[i.jsx(Fr,{htmlFor:"rsvp-first",children:"First name *"}),i.jsx(Dr,{id:"rsvp-first",value:a.first_name,onChange:Q=>f(J=>({...J,first_name:Q.target.value})),className:"h-11"})]}),i.jsxs("div",{className:"space-y-1.5",children:[i.jsx(Fr,{htmlFor:"rsvp-last",children:"Last name"}),i.jsx(Dr,{id:"rsvp-last",value:a.last_name,onChange:Q=>f(J=>({...J,last_name:Q.target.value})),className:"h-11"})]}),i.jsxs("div",{className:"space-y-1.5",children:[i.jsx(Fr,{htmlFor:"rsvp-email",children:"Email *"}),i.jsx(Dr,{id:"rsvp-email",type:"email",value:a.email,onChange:Q=>f(J=>({...J,email:Q.target.value})),className:"h-11"})]}),i.jsxs("div",{className:"space-y-1.5",children:[i.jsx(Fr,{htmlFor:"rsvp-phone",children:"Phone"}),i.jsx(Dr,{id:"rsvp-phone",type:"tel",value:a.phone,onChange:Q=>f(J=>({...J,phone:Q.target.value})),className:"h-11"})]})]}),i.jsxs("div",{className:"mt-4 rounded-xl border border-[#e4dcd3] bg-[#faf7f4] p-4",children:[i.jsxs("div",{className:"flex items-center justify-between gap-3",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-sm font-medium text-[#1b3a4b]",children:"Are you working with an agent?"}),i.jsx("p",{className:"text-xs text-[#7a888e]",children:"So we can respect your existing representation."})]}),i.jsx(lE,{checked:m,onCheckedChange:y})]}),m&&i.jsx(Dr,{value:_,onChange:Q=>w(Q.target.value),placeholder:"Your agent's name (optional)",className:"mt-3 h-10 bg-white"})]}),i.jsxs("div",{className:"mt-4 space-y-1.5",children:[i.jsx(Fr,{htmlFor:"rsvp-msg",children:"Anything you'd like us to know?"}),i.jsx(zc,{id:"rsvp-msg",rows:3,value:a.message,onChange:Q=>f(J=>({...J,message:Q.target.value})),className:"resize-y"})]}),E&&i.jsx("p",{className:"mt-3 text-sm text-destructive",children:E}),i.jsx(Lt,{onClick:q,disabled:c.isPending,className:"mt-6 h-12 w-full bg-gradient-to-r from-[#1b3a4b] to-[#406E71] text-base hover:opacity-95",children:c.isPending?"Reserving…":i.jsxs(i.Fragment,{children:["RSVP for this open house",i.jsx(ji,{className:"ml-2 h-4 w-4"})]})}),i.jsx("p",{className:"mt-3 text-center text-xs text-[#8b979c]",children:"We'll only use your info to follow up about this property."})]})}),(B==null?void 0:B.name)&&i.jsxs("section",{className:"rounded-2xl bg-white/70 border border-[#e4dcd3] p-5 flex items-center gap-4",children:[i.jsxs(Od,{className:"h-14 w-14",children:[i.jsx(Fd,{src:B.avatar_url||void 0,alt:B.name}),i.jsx(Bd,{children:B.name.slice(0,1)})]}),i.jsxs("div",{className:"min-w-0",children:[i.jsx("p",{className:"text-[11px] uppercase tracking-[0.25em] text-[#a08a5f]",children:"Hosted by"}),i.jsx("p",{className:"font-semibold text-[#1b3a4b]",children:B.name}),B.title&&i.jsx("p",{className:"text-sm text-[#5b6b72]",children:B.title}),i.jsxs("div",{className:"mt-1 flex flex-wrap gap-x-4 text-sm text-[#406E71]",children:[B.phone&&i.jsx("a",{href:`tel:${B.phone}`,children:B.phone}),B.email&&i.jsx("a",{href:`mailto:${B.email}`,className:"truncate",children:B.email})]})]})]}),i.jsx("div",{className:"text-center",children:i.jsxs("a",{href:K,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1.5 text-sm text-[#406E71] hover:underline",children:[i.jsx(ui,{className:"h-4 w-4"}),"Get directions to ",n.property_address]})})]})]})}function yL({icon:t,label:e,value:r}){return i.jsxs("div",{className:"rounded-xl bg-white border border-[#e9e2da] px-4 py-3",children:[i.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] uppercase tracking-wider text-[#9aa5aa]",children:[t,e]}),i.jsx("div",{className:"mt-1 text-lg font-semibold text-[#1b3a4b]",children:r})]})}const grt=Object.freeze(Object.defineProperty({__proto__:null,default:Z1e},Symbol.toStringTag,{value:"Module"}));function Der(t){const{user:e}=Zn();return mr({queryKey:["cohost-tokens",t],queryFn:async()=>{const{data:r,error:n}=await Ce.from("open_house_cohost_tokens").select("*").eq("open_house_id",t).order("created_at",{ascending:!1});if(n)throw n;return r},enabled:!!e&&!!t})}function Oer(){const t=jr(),{user:e}=Zn();return kr({mutationFn:async({openHouseId:r,label:n})=>{const{data:s,error:o}=await Ce.from("open_house_cohost_tokens").insert({open_house_id:r,label:n||null,created_by:e.id,expires_at:new Date(Date.now()+864e5).toISOString()}).select().single();if(o)throw o;return s},onSuccess:(r,n)=>{t.invalidateQueries({queryKey:["cohost-tokens",n.openHouseId]})}})}function Fer(){const t=jr();return kr({mutationFn:async({id:e,openHouseId:r})=>{const{error:n}=await Ce.from("open_house_cohost_tokens").update({is_active:!1}).eq("id",e);if(n)throw n},onSuccess:(e,r)=>{t.invalidateQueries({queryKey:["cohost-tokens",r.openHouseId]})}})}function yrt(t){return mr({queryKey:["cohost-validate",t],queryFn:async()=>{const{data:e,error:r}=await Ce.from("open_house_cohost_tokens").select("*, open_houses(*)").eq("token",t).eq("is_active",!0).single();if(r)throw r;if(e.expires_at&&new Date(e.expires_at)-1&&t.splice(r,1)}const ep=(t,e,r)=>r>e?e:r{},iT=()=>{};const Yx={},Q1e=t=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t);function J1e(t){return typeof t=="object"&&t!==null}const eSe=t=>/^0[^.\s]+$/u.test(t);function tSe(t){let e;return()=>(e===void 0&&(e=t()),e)}const Eh=t=>t,_rt=(t,e)=>r=>e(t(r)),qC=(...t)=>t.reduce(_rt),uN=(t,e,r)=>{const n=e-t;return n===0?1:(r-t)/n};class mK{constructor(){this.subscriptions=[]}add(e){return fK(this.subscriptions,e),()=>dO(this.subscriptions,e)}notify(e,r,n){const s=this.subscriptions.length;if(s)if(s===1)this.subscriptions[0](e,r,n);else for(let o=0;ot*1e3,vh=t=>t/1e3;function rSe(t,e){return e?t*(1e3/e):0}const nSe=(t,e,r)=>(((1-3*r+3*e)*t+(3*r-6*e))*t+3*e)*t,vrt=1e-7,brt=12;function wrt(t,e,r,n,s){let o,c,a=0;do c=e+(r-e)/2,o=nSe(c,n,s)-t,o>0?r=c:e=c;while(Math.abs(o)>vrt&&++awrt(o,0,1,t,r);return o=>o===0||o===1?o:nSe(s(o),e,n)}const sSe=t=>e=>e<=.5?t(2*e)/2:(2-t(2*(1-e)))/2,iSe=t=>e=>1-t(1-e),aSe=GC(.33,1.53,.69,.99),pK=iSe(aSe),oSe=sSe(pK),lSe=t=>t>=1?1:(t*=2)<1?.5*pK(t):.5*(2-Math.pow(2,-10*(t-1))),gK=t=>1-Math.sin(Math.acos(t)),cSe=iSe(gK),uSe=sSe(gK),Srt=GC(.42,0,1,1),Trt=GC(0,0,.58,1),dSe=GC(.42,0,.58,1),Ert=t=>Array.isArray(t)&&typeof t[0]!="number",hSe=t=>Array.isArray(t)&&typeof t[0]=="number",_ie={linear:Eh,easeIn:Srt,easeInOut:dSe,easeOut:Trt,circIn:gK,circInOut:uSe,circOut:cSe,backIn:pK,backInOut:oSe,backOut:aSe,anticipate:lSe},jrt=t=>typeof t=="string",vie=t=>{if(hSe(t)){iT(t.length===4,"Cubic bezier arrays must contain four numerical values.","cubic-bezier-length");const[e,r,n,s]=t;return GC(e,r,n,s)}else if(jrt(t))return iT(_ie[t]!==void 0,`Invalid easing type '${t}'`,"invalid-easing-type"),_ie[t];return t},xL=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"],bie={value:null,addProjectionMetrics:null};function krt(t,e){let r=new Set,n=new Set,s=!1,o=!1;const c=new WeakSet;let a={delta:0,timestamp:0,isProcessing:!1},f=0;function m(_){c.has(_)&&(y.schedule(_),t()),f++,_(a)}const y={schedule:(_,w=!1,E=!1)=>{const C=E&&s?r:n;return w&&c.add(_),C.add(_),_},cancel:_=>{n.delete(_),c.delete(_)},process:_=>{if(a=_,s){o=!0;return}s=!0;const w=r;r=n,n=w,r.forEach(m),e&&bie.value&&bie.value.frameloop[e].push(f),f=0,r.clear(),s=!1,o&&(o=!1,y.process(_))}};return y}const Art=40;function fSe(t,e){let r=!1,n=!0;const s={delta:0,timestamp:0,isProcessing:!1},o=()=>r=!0,c=xL.reduce((B,U)=>(B[U]=krt(o,e?U:void 0),B),{}),{setup:a,read:f,resolveKeyframes:m,preUpdate:y,update:_,preRender:w,render:E,postRender:A}=c,C=()=>{const B=Yx.useManualTiming,U=B?s.timestamp:performance.now();r=!1,B||(s.delta=n?1e3/60:Math.max(Math.min(U-s.timestamp,Art),1)),s.timestamp=U,s.isProcessing=!0,a.process(s),f.process(s),m.process(s),y.process(s),_.process(s),w.process(s),E.process(s),A.process(s),s.isProcessing=!1,r&&e&&(n=!1,t(C))},I=()=>{r=!0,n=!0,s.isProcessing||t(C)};return{schedule:xL.reduce((B,U)=>{const q=c[U];return B[U]=(H,K=!1,Q=!1)=>(r||I(),q.schedule(H,K,Q)),B},{}),cancel:B=>{for(let U=0;U(OM===void 0&&pu.set(rc.isProcessing||Yx.useManualTiming?rc.timestamp:performance.now()),OM),set:t=>{OM=t,queueMicrotask(Nrt)}},mSe=t=>e=>typeof e=="string"&&e.startsWith(t),pSe=mSe("--"),Crt=mSe("var(--"),yK=t=>Crt(t)?Irt.test(t.split("/*")[0].trim()):!1,Irt=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function wie(t){return typeof t!="string"?!1:t.split("/*")[0].includes("var(--")}const cE={test:t=>typeof t=="number",parse:parseFloat,transform:t=>t},dN={...cE,transform:t=>ep(0,1,t)},_L={...cE,default:1},lA=t=>Math.round(t*1e5)/1e5,xK=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function Prt(t){return t==null}const Rrt=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,_K=(t,e)=>r=>!!(typeof r=="string"&&Rrt.test(r)&&r.startsWith(t)||e&&!Prt(r)&&Object.prototype.hasOwnProperty.call(r,e)),gSe=(t,e,r)=>n=>{if(typeof n!="string")return n;const[s,o,c,a]=n.match(xK);return{[t]:parseFloat(s),[e]:parseFloat(o),[r]:parseFloat(c),alpha:a!==void 0?parseFloat(a):1}},Lrt=t=>ep(0,255,t),T6={...cE,transform:t=>Math.round(Lrt(t))},iv={test:_K("rgb","red"),parse:gSe("red","green","blue"),transform:({red:t,green:e,blue:r,alpha:n=1})=>"rgba("+T6.transform(t)+", "+T6.transform(e)+", "+T6.transform(r)+", "+lA(dN.transform(n))+")"};function Mrt(t){let e="",r="",n="",s="";return t.length>5?(e=t.substring(1,3),r=t.substring(3,5),n=t.substring(5,7),s=t.substring(7,9)):(e=t.substring(1,2),r=t.substring(2,3),n=t.substring(3,4),s=t.substring(4,5),e+=e,r+=r,n+=n,s+=s),{red:parseInt(e,16),green:parseInt(r,16),blue:parseInt(n,16),alpha:s?parseInt(s,16)/255:1}}const Rq={test:_K("#"),parse:Mrt,transform:iv.transform},HC=t=>({test:e=>typeof e=="string"&&e.endsWith(t)&&e.split(" ").length===1,parse:parseFloat,transform:e=>`${e}${t}`}),Wy=HC("deg"),Hm=HC("%"),Dn=HC("px"),Drt=HC("vh"),Ort=HC("vw"),Sie={...Hm,parse:t=>Hm.parse(t)/100,transform:t=>Hm.transform(t*100)},G1={test:_K("hsl","hue"),parse:gSe("hue","saturation","lightness"),transform:({hue:t,saturation:e,lightness:r,alpha:n=1})=>"hsla("+Math.round(t)+", "+Hm.transform(lA(e))+", "+Hm.transform(lA(r))+", "+lA(dN.transform(n))+")"},nl={test:t=>iv.test(t)||Rq.test(t)||G1.test(t),parse:t=>iv.test(t)?iv.parse(t):G1.test(t)?G1.parse(t):Rq.parse(t),transform:t=>typeof t=="string"?t:t.hasOwnProperty("red")?iv.transform(t):G1.transform(t),getAnimatableNone:t=>{const e=nl.parse(t);return e.alpha=0,nl.transform(e)}},Frt=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function Brt(t){var e,r;return isNaN(t)&&typeof t=="string"&&(((e=t.match(xK))==null?void 0:e.length)||0)+(((r=t.match(Frt))==null?void 0:r.length)||0)>0}const ySe="number",xSe="color",$rt="var",zrt="var(",Tie="${}",Urt=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function aT(t){const e=t.toString(),r=[],n={color:[],number:[],var:[]},s=[];let o=0;const a=e.replace(Urt,f=>(nl.test(f)?(n.color.push(o),s.push(xSe),r.push(nl.parse(f))):f.startsWith(zrt)?(n.var.push(o),s.push($rt),r.push(f)):(n.number.push(o),s.push(ySe),r.push(parseFloat(f))),++o,Tie)).split(Tie);return{values:r,split:a,indexes:n,types:s}}function Vrt(t){return aT(t).values}function _Se({split:t,types:e}){const r=t.length;return n=>{let s="";for(let o=0;otypeof t=="number"?0:nl.test(t)?nl.getAnimatableNone(t):t,Hrt=(t,e)=>typeof t=="number"?e!=null&&e.trim().endsWith("/")?t:0:Grt(t);function Wrt(t){const e=aT(t);return _Se(e)(e.values.map((n,s)=>Hrt(n,e.split[s])))}const Df={test:Brt,parse:Vrt,createTransformer:qrt,getAnimatableNone:Wrt};function E6(t,e,r){return r<0&&(r+=1),r>1&&(r-=1),r<1/6?t+(e-t)*6*r:r<1/2?e:r<2/3?t+(e-t)*(2/3-r)*6:t}function Krt({hue:t,saturation:e,lightness:r,alpha:n}){t/=360,e/=100,r/=100;let s=0,o=0,c=0;if(!e)s=o=c=r;else{const a=r<.5?r*(1+e):r+e-r*e,f=2*r-a;s=E6(f,a,t+1/3),o=E6(f,a,t),c=E6(f,a,t-1/3)}return{red:Math.round(s*255),green:Math.round(o*255),blue:Math.round(c*255),alpha:n}}function hO(t,e){return r=>r>0?e:t}const qa=(t,e,r)=>t+(e-t)*r,j6=(t,e,r)=>{const n=t*t,s=r*(e*e-n)+n;return s<0?0:Math.sqrt(s)},Yrt=[Rq,iv,G1],Zrt=t=>Yrt.find(e=>e.test(t));function Eie(t){const e=Zrt(t);if(hF(!!e,`'${t}' is not an animatable color. Use the equivalent color code instead.`,"color-not-animatable"),!e)return!1;let r=e.parse(t);return e===G1&&(r=Krt(r)),r}const jie=(t,e)=>{const r=Eie(t),n=Eie(e);if(!r||!n)return hO(t,e);const s={...r};return o=>(s.red=j6(r.red,n.red,o),s.green=j6(r.green,n.green,o),s.blue=j6(r.blue,n.blue,o),s.alpha=qa(r.alpha,n.alpha,o),iv.transform(s))},Lq=new Set(["none","hidden"]);function Xrt(t,e){return Lq.has(t)?r=>r<=0?t:e:r=>r>=1?e:t}function Qrt(t,e){return r=>qa(t,e,r)}function vK(t){return typeof t=="number"?Qrt:typeof t=="string"?yK(t)?hO:nl.test(t)?jie:tnt:Array.isArray(t)?vSe:typeof t=="object"?nl.test(t)?jie:Jrt:hO}function vSe(t,e){const r=[...t],n=r.length,s=t.map((o,c)=>vK(o)(o,e[c]));return o=>{for(let c=0;c{for(const o in n)r[o]=n[o](s);return r}}function ent(t,e){const r=[],n={color:0,var:0,number:0};for(let s=0;s{const r=Df.createTransformer(e),n=aT(t),s=aT(e);return n.indexes.var.length===s.indexes.var.length&&n.indexes.color.length===s.indexes.color.length&&n.indexes.number.length>=s.indexes.number.length?Lq.has(t)&&!s.values.length||Lq.has(e)&&!n.values.length?Xrt(t,e):qC(vSe(ent(n,s),s.values),r):(hF(!0,`Complex values '${t}' and '${e}' too different to mix. Ensure all colors are of the same type, and that each contains the same quantity of number and color values. Falling back to instant transition.`,"complex-values-different"),hO(t,e))};function bSe(t,e,r){return typeof t=="number"&&typeof e=="number"&&typeof r=="number"?qa(t,e,r):vK(t)(t,e)}const rnt=t=>{const e=({timestamp:r})=>t(r);return{start:(r=!0)=>ga.update(e,r),stop:()=>Zx(e),now:()=>rc.isProcessing?rc.timestamp:pu.now()}},wSe=(t,e,r=10)=>{let n="";const s=Math.max(Math.round(e/r),2);for(let o=0;o=fO?1/0:e}function nnt(t,e=100,r){const n=r({...t,keyframes:[0,e]}),s=Math.min(bK(n),fO);return{type:"keyframes",ease:o=>n.next(s*o).value/e,duration:vh(s)}}const co={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1};function Mq(t,e){return t*Math.sqrt(1-e*e)}const snt=12;function int(t,e,r){let n=r;for(let s=1;s{const y=m*c,_=y*t,w=y-r,E=Mq(m,c),A=Math.exp(-_);return k6-w/E*A},o=m=>{const _=m*c*t,w=_*r+r,E=Math.pow(c,2)*Math.pow(m,2)*t,A=Math.exp(-_),C=Mq(Math.pow(m,2),c);return(-s(m)+k6>0?-1:1)*((w-E)*A)/C}):(s=m=>{const y=Math.exp(-m*t),_=(m-r)*t+1;return-k6+y*_},o=m=>{const y=Math.exp(-m*t),_=(r-m)*(t*t);return y*_});const a=5/t,f=int(s,o,a);if(t=Ju(t),isNaN(f))return{stiffness:co.stiffness,damping:co.damping,duration:t};{const m=Math.pow(f,2)*n;return{stiffness:m,damping:c*2*Math.sqrt(n*m),duration:t}}}const ont=["duration","bounce"],lnt=["stiffness","damping","mass"];function kie(t,e){return e.some(r=>t[r]!==void 0)}function cnt(t){let e={velocity:co.velocity,stiffness:co.stiffness,damping:co.damping,mass:co.mass,isResolvedFromDuration:!1,...t};if(!kie(t,lnt)&&kie(t,ont))if(e.velocity=0,t.visualDuration){const r=t.visualDuration,n=2*Math.PI/(r*1.2),s=n*n,o=2*ep(.05,1,1-(t.bounce||0))*Math.sqrt(s);e={...e,mass:co.mass,stiffness:s,damping:o}}else{const r=ant({...t,velocity:0});e={...e,...r,mass:co.mass},e.isResolvedFromDuration=!0}return e}function mO(t=co.visualDuration,e=co.bounce){const r=typeof t!="object"?{visualDuration:t,keyframes:[0,1],bounce:e}:t;let{restSpeed:n,restDelta:s}=r;const o=r.keyframes[0],c=r.keyframes[r.keyframes.length-1],a={done:!1,value:o},{stiffness:f,damping:m,mass:y,duration:_,velocity:w,isResolvedFromDuration:E}=cnt({...r,velocity:-vh(r.velocity||0)}),A=w||0,C=m/(2*Math.sqrt(f*y)),I=c-o,M=vh(Math.sqrt(f/y)),D=Math.abs(I)<5;n||(n=D?co.restSpeed.granular:co.restSpeed.default),s||(s=D?co.restDelta.granular:co.restDelta.default);let B,U,q,H,K,Q;if(C<1)q=Mq(M,C),H=(A+C*M*I)/q,B=ee=>{const oe=Math.exp(-C*M*ee);return c-oe*(H*Math.sin(q*ee)+I*Math.cos(q*ee))},K=C*M*H+I*q,Q=C*M*I-H*q,U=ee=>Math.exp(-C*M*ee)*(K*Math.sin(q*ee)+Q*Math.cos(q*ee));else if(C===1){B=oe=>c-Math.exp(-M*oe)*(I+(A+M*I)*oe);const ee=A+M*I;U=oe=>Math.exp(-M*oe)*(M*ee*oe-A)}else{const ee=M*Math.sqrt(C*C-1);B=Ee=>{const Le=Math.exp(-C*M*Ee),Se=Math.min(ee*Ee,300);return c-Le*((A+C*M*I)*Math.sinh(Se)+ee*I*Math.cosh(Se))/ee};const oe=(A+C*M*I)/ee,de=C*M*oe-I*ee,ye=C*M*I-oe*ee;U=Ee=>{const Le=Math.exp(-C*M*Ee),Se=Math.min(ee*Ee,300);return Le*(de*Math.sinh(Se)+ye*Math.cosh(Se))}}const J={calculatedDuration:E&&_||null,velocity:ee=>Ju(U(ee)),next:ee=>{if(!E&&C<1){const de=Math.exp(-C*M*ee),ye=Math.sin(q*ee),Ee=Math.cos(q*ee),Le=c-de*(H*ye+I*Ee),Se=Ju(de*(K*ye+Q*Ee));return a.done=Math.abs(Se)<=n&&Math.abs(c-Le)<=s,a.value=a.done?c:Le,a}const oe=B(ee);if(E)a.done=ee>=_;else{const de=Ju(U(ee));a.done=Math.abs(de)<=n&&Math.abs(c-oe)<=s}return a.value=a.done?c:oe,a},toString:()=>{const ee=Math.min(bK(J),fO),oe=wSe(de=>J.next(ee*de).value,ee,30);return ee+"ms "+oe},toTransition:()=>{}};return J}mO.applyToOptions=t=>{const e=nnt(t,100,mO);return t.ease=e.ease,t.duration=Ju(e.duration),t.type="keyframes",t};const unt=5;function SSe(t,e,r){const n=Math.max(e-unt,0);return rSe(r-t(n),e-n)}function Dq({keyframes:t,velocity:e=0,power:r=.8,timeConstant:n=325,bounceDamping:s=10,bounceStiffness:o=500,modifyTarget:c,min:a,max:f,restDelta:m=.5,restSpeed:y}){const _=t[0],w={done:!1,value:_},E=Q=>a!==void 0&&Qf,A=Q=>a===void 0?f:f===void 0||Math.abs(a-Q)-C*Math.exp(-Q/n),B=Q=>M+D(Q),U=Q=>{const J=D(Q),ee=B(Q);w.done=Math.abs(J)<=m,w.value=w.done?M:ee};let q,H;const K=Q=>{E(w.value)&&(q=Q,H=mO({keyframes:[w.value,A(w.value)],velocity:SSe(B,Q,w.value),damping:s,stiffness:o,restDelta:m,restSpeed:y}))};return K(0),{calculatedDuration:null,next:Q=>{let J=!1;return!H&&q===void 0&&(J=!0,U(Q),K(Q)),q!==void 0&&Q>=q?H.next(Q-q):(!J&&U(Q),w)}}}function dnt(t,e,r){const n=[],s=r||Yx.mix||bSe,o=t.length-1;for(let c=0;ce[0];if(o===2&&e[0]===e[1])return()=>e[1];const c=t[0]===t[1];t[0]>t[o-1]&&(t=[...t].reverse(),e=[...e].reverse());const a=dnt(e,n,s),f=a.length,m=y=>{if(c&&y1)for(;_m(ep(t[0],t[o-1],y)):m}function fnt(t,e){const r=t[t.length-1];for(let n=1;n<=e;n++){const s=uN(0,e,n);t.push(qa(r,1,s))}}function mnt(t){const e=[0];return fnt(e,t.length-1),e}function pnt(t,e){return t.map(r=>r*e)}function gnt(t,e){return t.map(()=>e||dSe).splice(0,t.length-1)}function cA({duration:t=300,keyframes:e,times:r,ease:n="easeInOut"}){const s=Ert(n)?n.map(vie):vie(n),o={done:!1,value:e[0]},c=pnt(r&&r.length===e.length?r:mnt(e),t),a=hnt(c,e,{ease:Array.isArray(s)?s:gnt(e,s)});return{calculatedDuration:t,next:f=>(o.value=a(f),o.done=f>=t,o)}}const ynt=t=>t!==null;function fF(t,{repeat:e,repeatType:r="loop"},n,s=1){const o=t.filter(ynt),a=s<0||e&&r!=="loop"&&e%2===1?0:o.length-1;return!a||n===void 0?o[a]:n}const xnt={decay:Dq,inertia:Dq,tween:cA,keyframes:cA,spring:mO};function TSe(t){typeof t.type=="string"&&(t.type=xnt[t.type])}class wK{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(e=>{this.resolve=e})}notifyFinished(){this.resolve()}then(e,r){return this.finished.then(e,r)}}const _nt=t=>t/100;class pO extends wK{constructor(e){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.delayState={done:!1,value:void 0},this.stop=()=>{var n,s;const{motionValue:r}=this.options;r&&r.updatedAt!==pu.now()&&this.tick(pu.now()),this.isStopped=!0,this.state!=="idle"&&(this.teardown(),(s=(n=this.options).onStop)==null||s.call(n))},this.options=e,this.initAnimation(),this.play(),e.autoplay===!1&&this.pause()}initAnimation(){const{options:e}=this;TSe(e);const{type:r=cA,repeat:n=0,repeatDelay:s=0,repeatType:o,velocity:c=0}=e;let{keyframes:a}=e;const f=r||cA;f!==cA&&typeof a[0]!="number"&&(this.mixKeyframes=qC(_nt,bSe(a[0],a[1])),a=[0,100]);const m=f({...e,keyframes:a});o==="mirror"&&(this.mirroredGenerator=f({...e,keyframes:[...a].reverse(),velocity:-c})),m.calculatedDuration===null&&(m.calculatedDuration=bK(m));const{calculatedDuration:y}=m;this.calculatedDuration=y,this.resolvedDuration=y+s,this.totalDuration=this.resolvedDuration*(n+1)-s,this.generator=m}updateTime(e){const r=Math.round(e-this.startTime)*this.playbackSpeed;this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=r}tick(e,r=!1){const{generator:n,totalDuration:s,mixKeyframes:o,mirroredGenerator:c,resolvedDuration:a,calculatedDuration:f}=this;if(this.startTime===null)return n.next(0);const{delay:m=0,keyframes:y,repeat:_,repeatType:w,repeatDelay:E,type:A,onUpdate:C,finalKeyframe:I}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,e):this.speed<0&&(this.startTime=Math.min(e-s/this.speed,this.startTime)),r?this.currentTime=e:this.updateTime(e);const M=this.currentTime-m*(this.playbackSpeed>=0?1:-1),D=this.playbackSpeed>=0?M<0:M>s;this.currentTime=Math.max(M,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=s);let B=this.currentTime,U=n;if(_){const Q=Math.min(this.currentTime,s)/a;let J=Math.floor(Q),ee=Q%1;!ee&&Q>=1&&(ee=1),ee===1&&J--,J=Math.min(J,_+1),!!(J%2)&&(w==="reverse"?(ee=1-ee,E&&(ee-=E/a)):w==="mirror"&&(U=c)),B=ep(0,1,ee)*a}let q;D?(this.delayState.value=y[0],q=this.delayState):q=U.next(B),o&&!D&&(q.value=o(q.value));let{done:H}=q;!D&&f!==null&&(H=this.playbackSpeed>=0?this.currentTime>=s:this.currentTime<=0);const K=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&H);return K&&A!==Dq&&(q.value=fF(y,this.options,I,this.speed)),C&&C(q.value),K&&this.finish(),q}then(e,r){return this.finished.then(e,r)}get duration(){return vh(this.calculatedDuration)}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+vh(e)}get time(){return vh(this.currentTime)}set time(e){e=Ju(e),this.currentTime=e,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=e:this.driver&&(this.startTime=this.driver.now()-e/this.playbackSpeed),this.driver?this.driver.start(!1):(this.startTime=0,this.state="paused",this.holdTime=e,this.tick(e))}getGeneratorVelocity(){const e=this.currentTime;if(e<=0)return this.options.velocity||0;if(this.generator.velocity)return this.generator.velocity(e);const r=this.generator.next(e).value;return SSe(n=>this.generator.next(n).value,e,r)}get speed(){return this.playbackSpeed}set speed(e){const r=this.playbackSpeed!==e;r&&this.driver&&this.updateTime(pu.now()),this.playbackSpeed=e,r&&this.driver&&(this.time=vh(this.currentTime))}play(){var s,o;if(this.isStopped)return;const{driver:e=rnt,startTime:r}=this.options;this.driver||(this.driver=e(c=>this.tick(c))),(o=(s=this.options).onPlay)==null||o.call(s);const n=this.driver.now();this.state==="finished"?(this.updateFinished(),this.startTime=n):this.holdTime!==null?this.startTime=n-this.holdTime:this.startTime||(this.startTime=r??n),this.state==="finished"&&this.speed<0&&(this.startTime+=this.calculatedDuration),this.holdTime=null,this.state="running",this.driver.start()}pause(){this.state="paused",this.updateTime(pu.now()),this.holdTime=this.currentTime}complete(){this.state!=="running"&&this.play(),this.state="finished",this.holdTime=null}finish(){var e,r;this.notifyFinished(),this.teardown(),this.state="finished",(r=(e=this.options).onComplete)==null||r.call(e)}cancel(){var e,r;this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),(r=(e=this.options).onCancel)==null||r.call(e)}teardown(){this.state="idle",this.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(e){return this.startTime=0,this.tick(e,!0)}attachTimeline(e){var r;return this.options.allowFlatten&&(this.options.type="keyframes",this.options.ease="linear",this.initAnimation()),(r=this.driver)==null||r.stop(),e.observe(this)}}function vnt(t){for(let e=1;et*180/Math.PI,Oq=t=>{const e=av(Math.atan2(t[1],t[0]));return Fq(e)},bnt={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:t=>(Math.abs(t[0])+Math.abs(t[3]))/2,rotate:Oq,rotateZ:Oq,skewX:t=>av(Math.atan(t[1])),skewY:t=>av(Math.atan(t[2])),skew:t=>(Math.abs(t[1])+Math.abs(t[2]))/2},Fq=t=>(t=t%360,t<0&&(t+=360),t),Aie=Oq,Nie=t=>Math.sqrt(t[0]*t[0]+t[1]*t[1]),Cie=t=>Math.sqrt(t[4]*t[4]+t[5]*t[5]),wnt={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:Nie,scaleY:Cie,scale:t=>(Nie(t)+Cie(t))/2,rotateX:t=>Fq(av(Math.atan2(t[6],t[5]))),rotateY:t=>Fq(av(Math.atan2(-t[2],t[0]))),rotateZ:Aie,rotate:Aie,skewX:t=>av(Math.atan(t[4])),skewY:t=>av(Math.atan(t[1])),skew:t=>(Math.abs(t[1])+Math.abs(t[4]))/2};function Bq(t){return t.includes("scale")?1:0}function $q(t,e){if(!t||t==="none")return Bq(e);const r=t.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let n,s;if(r)n=wnt,s=r;else{const a=t.match(/^matrix\(([-\d.e\s,]+)\)$/u);n=bnt,s=a}if(!s)return Bq(e);const o=n[e],c=s[1].split(",").map(Tnt);return typeof o=="function"?o(c):c[o]}const Snt=(t,e)=>{const{transform:r="none"}=getComputedStyle(t);return $q(r,e)};function Tnt(t){return parseFloat(t.trim())}const uE=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],dE=new Set(uE),Iie=t=>t===cE||t===Dn,Ent=new Set(["x","y","z"]),jnt=uE.filter(t=>!Ent.has(t));function knt(t){const e=[];return jnt.forEach(r=>{const n=t.getValue(r);n!==void 0&&(e.push([r,n.get()]),n.set(r.startsWith("scale")?1:0))}),e}const _x={width:({x:t},{paddingLeft:e="0",paddingRight:r="0",boxSizing:n})=>{const s=t.max-t.min;return n==="border-box"?s:s-parseFloat(e)-parseFloat(r)},height:({y:t},{paddingTop:e="0",paddingBottom:r="0",boxSizing:n})=>{const s=t.max-t.min;return n==="border-box"?s:s-parseFloat(e)-parseFloat(r)},top:(t,{top:e})=>parseFloat(e),left:(t,{left:e})=>parseFloat(e),bottom:({y:t},{top:e})=>parseFloat(e)+(t.max-t.min),right:({x:t},{left:e})=>parseFloat(e)+(t.max-t.min),x:(t,{transform:e})=>$q(e,"x"),y:(t,{transform:e})=>$q(e,"y")};_x.translateX=_x.x;_x.translateY=_x.y;const Ev=new Set;let zq=!1,Uq=!1,Vq=!1;function ESe(){if(Uq){const t=Array.from(Ev).filter(n=>n.needsMeasurement),e=new Set(t.map(n=>n.element)),r=new Map;e.forEach(n=>{const s=knt(n);s.length&&(r.set(n,s),n.render())}),t.forEach(n=>n.measureInitialState()),e.forEach(n=>{n.render();const s=r.get(n);s&&s.forEach(([o,c])=>{var a;(a=n.getValue(o))==null||a.set(c)})}),t.forEach(n=>n.measureEndState()),t.forEach(n=>{n.suspendedScrollY!==void 0&&window.scrollTo(0,n.suspendedScrollY)})}Uq=!1,zq=!1,Ev.forEach(t=>t.complete(Vq)),Ev.clear()}function jSe(){Ev.forEach(t=>{t.readKeyframes(),t.needsMeasurement&&(Uq=!0)})}function Ant(){Vq=!0,jSe(),ESe(),Vq=!1}class SK{constructor(e,r,n,s,o,c=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...e],this.onComplete=r,this.name=n,this.motionValue=s,this.element=o,this.isAsync=c}scheduleResolve(){this.state="scheduled",this.isAsync?(Ev.add(this),zq||(zq=!0,ga.read(jSe),ga.resolveKeyframes(ESe))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:e,name:r,element:n,motionValue:s}=this;if(e[0]===null){const o=s==null?void 0:s.get(),c=e[e.length-1];if(o!==void 0)e[0]=o;else if(n&&r){const a=n.readValue(r,c);a!=null&&(e[0]=a)}e[0]===void 0&&(e[0]=c),s&&o===void 0&&s.set(e[0])}vnt(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),Ev.delete(this)}cancel(){this.state==="scheduled"&&(Ev.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const Nnt=t=>t.startsWith("--");function kSe(t,e,r){Nnt(e)?t.style.setProperty(e,r):t.style[e]=r}const Cnt={};function ASe(t,e){const r=tSe(t);return()=>Cnt[e]??r()}const Int=ASe(()=>window.ScrollTimeline!==void 0,"scrollTimeline"),NSe=ASe(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),Ok=([t,e,r,n])=>`cubic-bezier(${t}, ${e}, ${r}, ${n})`,Pie={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:Ok([0,.65,.55,1]),circOut:Ok([.55,0,1,.45]),backIn:Ok([.31,.01,.66,-.59]),backOut:Ok([.33,1.53,.69,.99])};function CSe(t,e){if(t)return typeof t=="function"?NSe()?wSe(t,e):"ease-out":hSe(t)?Ok(t):Array.isArray(t)?t.map(r=>CSe(r,e)||Pie.easeOut):Pie[t]}function Pnt(t,e,r,{delay:n=0,duration:s=300,repeat:o=0,repeatType:c="loop",ease:a="easeOut",times:f}={},m=void 0){const y={[e]:r};f&&(y.offset=f);const _=CSe(a,s);Array.isArray(_)&&(y.easing=_);const w={delay:n,duration:s,easing:Array.isArray(_)?"linear":_,fill:"both",iterations:o+1,direction:c==="reverse"?"alternate":"normal"};return m&&(w.pseudoElement=m),t.animate(y,w)}function ISe(t){return typeof t=="function"&&"applyToOptions"in t}function Rnt({type:t,...e}){return ISe(t)&&NSe()?t.applyToOptions(e):(e.duration??(e.duration=300),e.ease??(e.ease="easeOut"),e)}class PSe extends wK{constructor(e){if(super(),this.finishedTime=null,this.isStopped=!1,this.manualStartTime=null,!e)return;const{element:r,name:n,keyframes:s,pseudoElement:o,allowFlatten:c=!1,finalKeyframe:a,onComplete:f}=e;this.isPseudoElement=!!o,this.allowFlatten=c,this.options=e,iT(typeof e.type!="string",`Mini animate() doesn't support "type" as a string.`,"mini-spring");const m=Rnt(e);this.animation=Pnt(r,n,s,m,o),m.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!o){const y=fF(s,this.options,a,this.speed);this.updateMotionValue&&this.updateMotionValue(y),kSe(r,n,y),this.animation.cancel()}f==null||f(),this.notifyFinished()}}play(){this.isStopped||(this.manualStartTime=null,this.animation.play(),this.state==="finished"&&this.updateFinished())}pause(){this.animation.pause()}complete(){var e,r;(r=(e=this.animation).finish)==null||r.call(e)}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;const{state:e}=this;e==="idle"||e==="finished"||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){var r,n,s;const e=(r=this.options)==null?void 0:r.element;!this.isPseudoElement&&(e!=null&&e.isConnected)&&((s=(n=this.animation).commitStyles)==null||s.call(n))}get duration(){var r,n;const e=((n=(r=this.animation.effect)==null?void 0:r.getComputedTiming)==null?void 0:n.call(r).duration)||0;return vh(Number(e))}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+vh(e)}get time(){return vh(Number(this.animation.currentTime)||0)}set time(e){const r=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=Ju(e),r&&this.animation.pause()}get speed(){return this.animation.playbackRate}set speed(e){e<0&&(this.finishedTime=null),this.animation.playbackRate=e}get state(){return this.finishedTime!==null?"finished":this.animation.playState}get startTime(){return this.manualStartTime??Number(this.animation.startTime)}set startTime(e){this.manualStartTime=this.animation.startTime=e}attachTimeline({timeline:e,rangeStart:r,rangeEnd:n,observe:s}){var o;return this.allowFlatten&&((o=this.animation.effect)==null||o.updateTiming({easing:"linear"})),this.animation.onfinish=null,e&&Int()?(this.animation.timeline=e,r&&(this.animation.rangeStart=r),n&&(this.animation.rangeEnd=n),Eh):s(this)}}const RSe={anticipate:lSe,backInOut:oSe,circInOut:uSe};function Lnt(t){return t in RSe}function Mnt(t){typeof t.ease=="string"&&Lnt(t.ease)&&(t.ease=RSe[t.ease])}const A6=10;class Dnt extends PSe{constructor(e){Mnt(e),TSe(e),super(e),e.startTime!==void 0&&e.autoplay!==!1&&(this.startTime=e.startTime),this.options=e}updateMotionValue(e){const{motionValue:r,onUpdate:n,onComplete:s,element:o,...c}=this.options;if(!r)return;if(e!==void 0){r.set(e);return}const a=new pO({...c,autoplay:!1}),f=Math.max(A6,pu.now()-this.startTime),m=ep(0,A6,f-A6),y=a.sample(f).value,{name:_}=this.options;o&&_&&kSe(o,_,y),r.setWithVelocity(a.sample(Math.max(0,f-m)).value,y,m),a.stop()}}const Rie=(t,e)=>e==="zIndex"?!1:!!(typeof t=="number"||Array.isArray(t)||typeof t=="string"&&(Df.test(t)||t==="0")&&!t.startsWith("url("));function Ont(t){const e=t[0];if(t.length===1)return!0;for(let r=0;rObject.hasOwnProperty.call(Element.prototype,"animate"));function Vnt(t){var _;const{motionValue:e,name:r,repeatDelay:n,repeatType:s,damping:o,type:c,keyframes:a}=t;if(!(((_=e==null?void 0:e.owner)==null?void 0:_.current)instanceof HTMLElement))return!1;const{onUpdate:m,transformTemplate:y}=e.owner.getProps();return Unt()&&r&&(LSe.has(r)||znt.has(r)&&$nt(a))&&(r!=="transform"||!y)&&!m&&!n&&s!=="mirror"&&o!==0&&c!=="inertia"}const qnt=40;class Gnt extends wK{constructor({autoplay:e=!0,delay:r=0,type:n="keyframes",repeat:s=0,repeatDelay:o=0,repeatType:c="loop",keyframes:a,name:f,motionValue:m,element:y,..._}){var A;super(),this.stop=()=>{var C,I;this._animation&&(this._animation.stop(),(C=this.stopTimeline)==null||C.call(this)),(I=this.keyframeResolver)==null||I.cancel()},this.createdAt=pu.now();const w={autoplay:e,delay:r,type:n,repeat:s,repeatDelay:o,repeatType:c,name:f,motionValue:m,element:y,..._},E=(y==null?void 0:y.KeyframeResolver)||SK;this.keyframeResolver=new E(a,(C,I,M)=>this.onKeyframesResolved(C,I,w,!M),f,m,y),(A=this.keyframeResolver)==null||A.scheduleResolve()}onKeyframesResolved(e,r,n,s){var M,D;this.keyframeResolver=void 0;const{name:o,type:c,velocity:a,delay:f,isHandoff:m,onUpdate:y}=n;this.resolvedAt=pu.now();let _=!0;Fnt(e,o,c,a)||(_=!1,(Yx.instantAnimations||!f)&&(y==null||y(fF(e,n,r))),e[0]=e[e.length-1],qq(n),n.repeat=0);const E={startTime:s?this.resolvedAt?this.resolvedAt-this.createdAt>qnt?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:r,...n,keyframes:e},A=_&&!m&&Vnt(E),C=(D=(M=E.motionValue)==null?void 0:M.owner)==null?void 0:D.current;let I;if(A)try{I=new Dnt({...E,element:C})}catch{I=new pO(E)}else I=new pO(E);I.finished.then(()=>{this.notifyFinished()}).catch(Eh),this.pendingTimeline&&(this.stopTimeline=I.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=I}get finished(){return this._animation?this.animation.finished:this._finished}then(e,r){return this.finished.finally(e).then(()=>{})}get animation(){var e;return this._animation||((e=this.keyframeResolver)==null||e.resume(),Ant()),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(e){this.animation.time=e}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(e){this.animation.speed=e}get startTime(){return this.animation.startTime}attachTimeline(e){return this._animation?this.stopTimeline=this.animation.attachTimeline(e):this.pendingTimeline=e,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){var e;this._animation&&this.animation.cancel(),(e=this.keyframeResolver)==null||e.cancel()}}function MSe(t,e,r,n=0,s=1){const o=Array.from(t).sort((m,y)=>m.sortNodePosition(y)).indexOf(e),c=t.size,a=(c-1)*n;return typeof r=="function"?r(o,c):s===1?o*n:a-o*n}const Hnt=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function Wnt(t){const e=Hnt.exec(t);if(!e)return[,];const[,r,n,s]=e;return[`--${r??n}`,s]}const Knt=4;function DSe(t,e,r=1){iT(r<=Knt,`Max CSS variable fallback depth detected in property "${t}". This may indicate a circular fallback dependency.`,"max-css-var-depth");const[n,s]=Wnt(t);if(!n)return;const o=window.getComputedStyle(e).getPropertyValue(n);if(o){const c=o.trim();return Q1e(c)?parseFloat(c):c}return yK(s)?DSe(s,e,r+1):s}const Ynt={type:"spring",stiffness:500,damping:25,restSpeed:10},Znt=t=>({type:"spring",stiffness:550,damping:t===0?2*Math.sqrt(550):30,restSpeed:10}),Xnt={type:"keyframes",duration:.8},Qnt={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},Jnt=(t,{keyframes:e})=>e.length>2?Xnt:dE.has(t)?t.startsWith("scale")?Znt(e[1]):Ynt:Qnt;function OSe(t,e){if(t!=null&&t.inherit&&e){const{inherit:r,...n}=t;return{...e,...n}}return t}function TK(t,e){const r=(t==null?void 0:t[e])??(t==null?void 0:t.default)??t;return r!==t?OSe(r,t):r}const est=new Set(["when","delay","delayChildren","staggerChildren","staggerDirection","repeat","repeatType","repeatDelay","from","elapsed"]);function tst(t){for(const e in t)if(!est.has(e))return!0;return!1}const EK=(t,e,r,n={},s,o)=>c=>{const a=TK(n,t)||{},f=a.delay||n.delay||0;let{elapsed:m=0}=n;m=m-Ju(f);const y={keyframes:Array.isArray(r)?r:[null,r],ease:"easeOut",velocity:e.getVelocity(),...a,delay:-m,onUpdate:w=>{e.set(w),a.onUpdate&&a.onUpdate(w)},onComplete:()=>{c(),a.onComplete&&a.onComplete()},name:t,motionValue:e,element:o?void 0:s};tst(a)||Object.assign(y,Jnt(t,y)),y.duration&&(y.duration=Ju(y.duration)),y.repeatDelay&&(y.repeatDelay=Ju(y.repeatDelay)),y.from!==void 0&&(y.keyframes[0]=y.from);let _=!1;if((y.type===!1||y.duration===0&&!y.repeatDelay)&&(qq(y),y.delay===0&&(_=!0)),(Yx.instantAnimations||Yx.skipAnimations||s!=null&&s.shouldSkipAnimations)&&(_=!0,qq(y),y.delay=0),y.allowFlatten=!a.type&&!a.ease,_&&!o&&e.get()!==void 0){const w=fF(y.keyframes,a);if(w!==void 0){ga.update(()=>{y.onUpdate(w),y.onComplete()});return}}return a.isSync?new pO(y):new Gnt(y)};function Lie(t){const e=[{},{}];return t==null||t.values.forEach((r,n)=>{e[0][n]=r.get(),e[1][n]=r.getVelocity()}),e}function jK(t,e,r,n){if(typeof e=="function"){const[s,o]=Lie(n);e=e(r!==void 0?r:t.custom,s,o)}if(typeof e=="string"&&(e=t.variants&&t.variants[e]),typeof e=="function"){const[s,o]=Lie(n);e=e(r!==void 0?r:t.custom,s,o)}return e}function jv(t,e,r){const n=t.getProps();return jK(n,e,r!==void 0?r:n.custom,t)}const FSe=new Set(["width","height","top","left","right","bottom",...uE]),Mie=30,rst=t=>!isNaN(parseFloat(t));class nst{constructor(e,r={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=n=>{var o;const s=pu.now();if(this.updatedAt!==s&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(n),this.current!==this.prev&&((o=this.events.change)==null||o.notify(this.current),this.dependents))for(const c of this.dependents)c.dirty()},this.hasAnimated=!1,this.setCurrent(e),this.owner=r.owner}setCurrent(e){this.current=e,this.updatedAt=pu.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=rst(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return this.on("change",e)}on(e,r){this.events[e]||(this.events[e]=new mK);const n=this.events[e].add(r);return e==="change"?()=>{n(),ga.read(()=>{this.events.change.getSize()||this.stop()})}:n}clearListeners(){for(const e in this.events)this.events[e].clear()}attach(e,r){this.passiveEffect=e,this.stopPassiveEffect=r}set(e){this.passiveEffect?this.passiveEffect(e,this.updateAndNotify):this.updateAndNotify(e)}setWithVelocity(e,r,n){this.set(r),this.prev=void 0,this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt-n}jump(e,r=!0){this.updateAndNotify(e),this.prev=e,this.prevUpdatedAt=this.prevFrameValue=void 0,r&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){var e;(e=this.events.change)==null||e.notify(this.current)}addDependent(e){this.dependents||(this.dependents=new Set),this.dependents.add(e)}removeDependent(e){this.dependents&&this.dependents.delete(e)}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const e=pu.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>Mie)return 0;const r=Math.min(this.updatedAt-this.prevUpdatedAt,Mie);return rSe(parseFloat(this.current)-parseFloat(this.prevFrameValue),r)}start(e){return this.stop(),new Promise(r=>{this.hasAnimated=!0,this.animation=e(r),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){var e,r;(e=this.dependents)==null||e.clear(),(r=this.events.destroy)==null||r.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function oT(t,e){return new nst(t,e)}const Gq=t=>Array.isArray(t);function sst(t,e,r){t.hasValue(e)?t.getValue(e).set(r):t.addValue(e,oT(r))}function ist(t){return Gq(t)?t[t.length-1]||0:t}function ast(t,e){const r=jv(t,e);let{transitionEnd:n={},transition:s={},...o}=r||{};o={...o,...n};for(const c in o){const a=ist(o[c]);sst(t,c,a)}}const hc=t=>!!(t&&t.getVelocity);function ost(t){return!!(hc(t)&&t.add)}function Hq(t,e){const r=t.getValue("willChange");if(ost(r))return r.add(e);if(!r&&Yx.WillChange){const n=new Yx.WillChange("auto");t.addValue("willChange",n),n.add(e)}}function kK(t){return t.replace(/([A-Z])/g,e=>`-${e.toLowerCase()}`)}const lst="framerAppearId",BSe="data-"+kK(lst);function $Se(t){return t.props[BSe]}function cst({protectedKeys:t,needsAnimating:e},r){const n=t.hasOwnProperty(r)&&e[r]!==!0;return e[r]=!1,n}function zSe(t,e,{delay:r=0,transitionOverride:n,type:s}={}){let{transition:o,transitionEnd:c,...a}=e;const f=t.getDefaultTransition();o=o?OSe(o,f):f;const m=o==null?void 0:o.reduceMotion;n&&(o=n);const y=[],_=s&&t.animationState&&t.animationState.getState()[s];for(const w in a){const E=t.getValue(w,t.latestValues[w]??null),A=a[w];if(A===void 0||_&&cst(_,w))continue;const C={delay:r,...TK(o||{},w)},I=E.get();if(I!==void 0&&!E.isAnimating()&&!Array.isArray(A)&&A===I&&!C.velocity){ga.update(()=>E.set(A));continue}let M=!1;if(window.MotionHandoffAnimation){const U=$Se(t);if(U){const q=window.MotionHandoffAnimation(U,w,ga);q!==null&&(C.startTime=q,M=!0)}}Hq(t,w);const D=m??t.shouldReduceMotion;E.start(EK(w,E,A,D&&FSe.has(w)?{type:!1}:C,t,M));const B=E.animation;B&&y.push(B)}if(c){const w=()=>ga.update(()=>{c&&ast(t,c)});y.length?Promise.all(y).then(w):w()}return y}function Wq(t,e,r={}){var f;const n=jv(t,e,r.type==="exit"?(f=t.presenceContext)==null?void 0:f.custom:void 0);let{transition:s=t.getDefaultTransition()||{}}=n||{};r.transitionOverride&&(s=r.transitionOverride);const o=n?()=>Promise.all(zSe(t,n,r)):()=>Promise.resolve(),c=t.variantChildren&&t.variantChildren.size?(m=0)=>{const{delayChildren:y=0,staggerChildren:_,staggerDirection:w}=s;return ust(t,e,m,y,_,w,r)}:()=>Promise.resolve(),{when:a}=s;if(a){const[m,y]=a==="beforeChildren"?[o,c]:[c,o];return m().then(()=>y())}else return Promise.all([o(),c(r.delay)])}function ust(t,e,r=0,n=0,s=0,o=1,c){const a=[];for(const f of t.variantChildren)f.notify("AnimationStart",e),a.push(Wq(f,e,{...c,delay:r+(typeof n=="function"?0:n)+MSe(t.variantChildren,f,n,s,o)}).then(()=>f.notify("AnimationComplete",e)));return Promise.all(a)}function dst(t,e,r={}){t.notify("AnimationStart",e);let n;if(Array.isArray(e)){const s=e.map(o=>Wq(t,o,r));n=Promise.all(s)}else if(typeof e=="string")n=Wq(t,e,r);else{const s=typeof e=="function"?jv(t,e,r.custom):e;n=Promise.all(zSe(t,s,r))}return n.then(()=>{t.notify("AnimationComplete",e)})}const hst={test:t=>t==="auto",parse:t=>t},USe=t=>e=>e.test(t),VSe=[cE,Dn,Hm,Wy,Ort,Drt,hst],Die=t=>VSe.find(USe(t));function fst(t){return typeof t=="number"?t===0:t!==null?t==="none"||t==="0"||eSe(t):!0}const mst=new Set(["brightness","contrast","saturate","opacity"]);function pst(t){const[e,r]=t.slice(0,-1).split("(");if(e==="drop-shadow")return t;const[n]=r.match(xK)||[];if(!n)return t;const s=r.replace(n,"");let o=mst.has(e)?1:0;return n!==r&&(o*=100),e+"("+o+s+")"}const gst=/\b([a-z-]*)\(.*?\)/gu,Kq={...Df,getAnimatableNone:t=>{const e=t.match(gst);return e?e.map(pst).join(" "):t}},Yq={...Df,getAnimatableNone:t=>{const e=Df.parse(t);return Df.createTransformer(t)(e.map(n=>typeof n=="number"?0:typeof n=="object"?{...n,alpha:1}:n))}},Oie={...cE,transform:Math.round},yst={rotate:Wy,rotateX:Wy,rotateY:Wy,rotateZ:Wy,scale:_L,scaleX:_L,scaleY:_L,scaleZ:_L,skew:Wy,skewX:Wy,skewY:Wy,distance:Dn,translateX:Dn,translateY:Dn,translateZ:Dn,x:Dn,y:Dn,z:Dn,perspective:Dn,transformPerspective:Dn,opacity:dN,originX:Sie,originY:Sie,originZ:Dn},AK={borderWidth:Dn,borderTopWidth:Dn,borderRightWidth:Dn,borderBottomWidth:Dn,borderLeftWidth:Dn,borderRadius:Dn,borderTopLeftRadius:Dn,borderTopRightRadius:Dn,borderBottomRightRadius:Dn,borderBottomLeftRadius:Dn,width:Dn,maxWidth:Dn,height:Dn,maxHeight:Dn,top:Dn,right:Dn,bottom:Dn,left:Dn,inset:Dn,insetBlock:Dn,insetBlockStart:Dn,insetBlockEnd:Dn,insetInline:Dn,insetInlineStart:Dn,insetInlineEnd:Dn,padding:Dn,paddingTop:Dn,paddingRight:Dn,paddingBottom:Dn,paddingLeft:Dn,paddingBlock:Dn,paddingBlockStart:Dn,paddingBlockEnd:Dn,paddingInline:Dn,paddingInlineStart:Dn,paddingInlineEnd:Dn,margin:Dn,marginTop:Dn,marginRight:Dn,marginBottom:Dn,marginLeft:Dn,marginBlock:Dn,marginBlockStart:Dn,marginBlockEnd:Dn,marginInline:Dn,marginInlineStart:Dn,marginInlineEnd:Dn,fontSize:Dn,backgroundPositionX:Dn,backgroundPositionY:Dn,...yst,zIndex:Oie,fillOpacity:dN,strokeOpacity:dN,numOctaves:Oie},xst={...AK,color:nl,backgroundColor:nl,outlineColor:nl,fill:nl,stroke:nl,borderColor:nl,borderTopColor:nl,borderRightColor:nl,borderBottomColor:nl,borderLeftColor:nl,filter:Kq,WebkitFilter:Kq,mask:Yq,WebkitMask:Yq},qSe=t=>xst[t],_st=new Set([Kq,Yq]);function GSe(t,e){let r=qSe(t);return _st.has(r)||(r=Df),r.getAnimatableNone?r.getAnimatableNone(e):void 0}const vst=new Set(["auto","none","0"]);function bst(t,e,r){let n=0,s;for(;n{e.getValue(f).set(m)}),this.resolveNoneKeyframes()}}function HSe(t,e,r){if(t==null)return[];if(t instanceof EventTarget)return[t];if(typeof t=="string"){const s=document.querySelectorAll(t);return s?Array.from(s):[]}return Array.from(t).filter(n=>n!=null)}const WSe=(t,e)=>e&&typeof t=="number"?e.transform(t):t;function FM(t){return J1e(t)&&"offsetHeight"in t&&!("ownerSVGElement"in t)}const{schedule:NK,cancel:Ber}=fSe(queueMicrotask,!1),uf={x:!1,y:!1};function KSe(){return uf.x||uf.y}function Sst(t){return t==="x"||t==="y"?uf[t]?null:(uf[t]=!0,()=>{uf[t]=!1}):uf.x||uf.y?null:(uf.x=uf.y=!0,()=>{uf.x=uf.y=!1})}function YSe(t,e){const r=HSe(t),n=new AbortController,s={passive:!0,...e,signal:n.signal};return[r,s,()=>n.abort()]}function Tst(t){return!(t.pointerType==="touch"||KSe())}function Est(t,e,r={}){const[n,s,o]=YSe(t,r);return n.forEach(c=>{let a=!1,f=!1,m;const y=()=>{c.removeEventListener("pointerleave",A)},_=I=>{m&&(m(I),m=void 0),y()},w=I=>{a=!1,window.removeEventListener("pointerup",w),window.removeEventListener("pointercancel",w),f&&(f=!1,_(I))},E=()=>{a=!0,window.addEventListener("pointerup",w,s),window.addEventListener("pointercancel",w,s)},A=I=>{if(I.pointerType!=="touch"){if(a){f=!0;return}_(I)}},C=I=>{if(!Tst(I))return;f=!1;const M=e(c,I);typeof M=="function"&&(m=M,c.addEventListener("pointerleave",A,s))};c.addEventListener("pointerenter",C,s),c.addEventListener("pointerdown",E,s)}),o}const ZSe=(t,e)=>e?t===e?!0:ZSe(t,e.parentElement):!1,CK=t=>t.pointerType==="mouse"?typeof t.button!="number"||t.button<=0:t.isPrimary!==!1,jst=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function kst(t){return jst.has(t.tagName)||t.isContentEditable===!0}const Ast=new Set(["INPUT","SELECT","TEXTAREA"]);function Nst(t){return Ast.has(t.tagName)||t.isContentEditable===!0}const BM=new WeakSet;function Fie(t){return e=>{e.key==="Enter"&&t(e)}}function N6(t,e){t.dispatchEvent(new PointerEvent("pointer"+e,{isPrimary:!0,bubbles:!0}))}const Cst=(t,e)=>{const r=t.currentTarget;if(!r)return;const n=Fie(()=>{if(BM.has(r))return;N6(r,"down");const s=Fie(()=>{N6(r,"up")}),o=()=>N6(r,"cancel");r.addEventListener("keyup",s,e),r.addEventListener("blur",o,e)});r.addEventListener("keydown",n,e),r.addEventListener("blur",()=>r.removeEventListener("keydown",n),e)};function Bie(t){return CK(t)&&!KSe()}const $ie=new WeakSet;function Ist(t,e,r={}){const[n,s,o]=YSe(t,r),c=a=>{const f=a.currentTarget;if(!Bie(a)||$ie.has(a))return;BM.add(f),r.stopPropagation&&$ie.add(a);const m=e(f,a),y=(E,A)=>{window.removeEventListener("pointerup",_),window.removeEventListener("pointercancel",w),BM.has(f)&&BM.delete(f),Bie(E)&&typeof m=="function"&&m(E,{success:A})},_=E=>{y(E,f===window||f===document||r.useGlobalTarget||ZSe(f,E.target))},w=E=>{y(E,!1)};window.addEventListener("pointerup",_,s),window.addEventListener("pointercancel",w,s)};return n.forEach(a=>{(r.useGlobalTarget?window:a).addEventListener("pointerdown",c,s),FM(a)&&(a.addEventListener("focus",m=>Cst(m,s)),!kst(a)&&!a.hasAttribute("tabindex")&&(a.tabIndex=0))}),o}function IK(t){return J1e(t)&&"ownerSVGElement"in t}const $M=new WeakMap;let Ky;const XSe=(t,e,r)=>(n,s)=>s&&s[0]?s[0][t+"Size"]:IK(n)&&"getBBox"in n?n.getBBox()[e]:n[r],Pst=XSe("inline","width","offsetWidth"),Rst=XSe("block","height","offsetHeight");function Lst({target:t,borderBoxSize:e}){var r;(r=$M.get(t))==null||r.forEach(n=>{n(t,{get width(){return Pst(t,e)},get height(){return Rst(t,e)}})})}function Mst(t){t.forEach(Lst)}function Dst(){typeof ResizeObserver>"u"||(Ky=new ResizeObserver(Mst))}function Ost(t,e){Ky||Dst();const r=HSe(t);return r.forEach(n=>{let s=$M.get(n);s||(s=new Set,$M.set(n,s)),s.add(e),Ky==null||Ky.observe(n)}),()=>{r.forEach(n=>{const s=$M.get(n);s==null||s.delete(e),s!=null&&s.size||Ky==null||Ky.unobserve(n)})}}const zM=new Set;let H1;function Fst(){H1=()=>{const t={get width(){return window.innerWidth},get height(){return window.innerHeight}};zM.forEach(e=>e(t))},window.addEventListener("resize",H1)}function Bst(t){return zM.add(t),H1||Fst(),()=>{zM.delete(t),!zM.size&&typeof H1=="function"&&(window.removeEventListener("resize",H1),H1=void 0)}}function zie(t,e){return typeof t=="function"?Bst(t):Ost(t,e)}function $st(t){return IK(t)&&t.tagName==="svg"}const zst=[...VSe,nl,Df],Ust=t=>zst.find(USe(t)),Uie=()=>({translate:0,scale:1,origin:0,originPoint:0}),W1=()=>({x:Uie(),y:Uie()}),Vie=()=>({min:0,max:0}),_l=()=>({x:Vie(),y:Vie()}),Vst=new WeakMap;function mF(t){return t!==null&&typeof t=="object"&&typeof t.start=="function"}function hN(t){return typeof t=="string"||Array.isArray(t)}const PK=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],RK=["initial",...PK];function pF(t){return mF(t.animate)||RK.some(e=>hN(t[e]))}function QSe(t){return!!(pF(t)||t.variants)}function qst(t,e,r){for(const n in e){const s=e[n],o=r[n];if(hc(s))t.addValue(n,s);else if(hc(o))t.addValue(n,oT(s,{owner:t}));else if(o!==s)if(t.hasValue(n)){const c=t.getValue(n);c.liveStyle===!0?c.jump(s):c.hasAnimated||c.set(s)}else{const c=t.getStaticValue(n);t.addValue(n,oT(c!==void 0?c:s,{owner:t}))}}for(const n in r)e[n]===void 0&&t.removeValue(n);return e}const Zq={current:null},JSe={current:!1},Gst=typeof window<"u";function Hst(){if(JSe.current=!0,!!Gst)if(window.matchMedia){const t=window.matchMedia("(prefers-reduced-motion)"),e=()=>Zq.current=t.matches;t.addEventListener("change",e),e()}else Zq.current=!1}const qie=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];let gO={};function eTe(t){gO=t}function Wst(){return gO}class Kst{scrapeMotionValuesFromProps(e,r,n){return{}}constructor({parent:e,props:r,presenceContext:n,reducedMotionConfig:s,skipAnimations:o,blockInitialAnimation:c,visualState:a},f={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.shouldSkipAnimations=!1,this.values=new Map,this.KeyframeResolver=SK,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.hasBeenMounted=!1,this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{const E=pu.now();this.renderScheduledAtthis.bindToMotionValue(o,s)),this.reducedMotionConfig==="never"?this.shouldReduceMotion=!1:this.reducedMotionConfig==="always"?this.shouldReduceMotion=!0:(JSe.current||Hst(),this.shouldReduceMotion=Zq.current),this.shouldSkipAnimations=this.skipAnimationsConfig??!1,(n=this.parent)==null||n.addChild(this),this.update(this.props,this.presenceContext),this.hasBeenMounted=!0}unmount(){var e;this.projection&&this.projection.unmount(),Zx(this.notifyUpdate),Zx(this.render),this.valueSubscriptions.forEach(r=>r()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),(e=this.parent)==null||e.removeChild(this);for(const r in this.events)this.events[r].clear();for(const r in this.features){const n=this.features[r];n&&(n.unmount(),n.isMounted=!1)}this.current=null}addChild(e){this.children.add(e),this.enteringChildren??(this.enteringChildren=new Set),this.enteringChildren.add(e)}removeChild(e){this.children.delete(e),this.enteringChildren&&this.enteringChildren.delete(e)}bindToMotionValue(e,r){if(this.valueSubscriptions.has(e)&&this.valueSubscriptions.get(e)(),r.accelerate&&LSe.has(e)&&this.current instanceof HTMLElement){const{factory:c,keyframes:a,times:f,ease:m,duration:y}=r.accelerate,_=new PSe({element:this.current,name:e,keyframes:a,times:f,ease:m,duration:Ju(y)}),w=c(_);this.valueSubscriptions.set(e,()=>{w(),_.cancel()});return}const n=dE.has(e);n&&this.onBindTransform&&this.onBindTransform();const s=r.on("change",c=>{this.latestValues[e]=c,this.props.onUpdate&&ga.preRender(this.notifyUpdate),n&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});let o;typeof window<"u"&&window.MotionCheckAppearSync&&(o=window.MotionCheckAppearSync(this,e,r)),this.valueSubscriptions.set(e,()=>{s(),o&&o(),r.owner&&r.stop()})}sortNodePosition(e){return!this.current||!this.sortInstanceNodePosition||this.type!==e.type?0:this.sortInstanceNodePosition(this.current,e.current)}updateFeatures(){let e="animation";for(e in gO){const r=gO[e];if(!r)continue;const{isEnabled:n,Feature:s}=r;if(!this.features[e]&&s&&n(this.props)&&(this.features[e]=new s(this)),this.features[e]){const o=this.features[e];o.isMounted?o.update():(o.mount(),o.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):_l()}getStaticValue(e){return this.latestValues[e]}setStaticValue(e,r){this.latestValues[e]=r}update(e,r){(e.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=e,this.prevPresenceContext=this.presenceContext,this.presenceContext=r;for(let n=0;nr.variantChildren.delete(e)}addValue(e,r){const n=this.values.get(e);r!==n&&(n&&this.removeValue(e),this.bindToMotionValue(e,r),this.values.set(e,r),this.latestValues[e]=r.get())}removeValue(e){this.values.delete(e);const r=this.valueSubscriptions.get(e);r&&(r(),this.valueSubscriptions.delete(e)),delete this.latestValues[e],this.removeValueFromRenderState(e,this.renderState)}hasValue(e){return this.values.has(e)}getValue(e,r){if(this.props.values&&this.props.values[e])return this.props.values[e];let n=this.values.get(e);return n===void 0&&r!==void 0&&(n=oT(r===null?void 0:r,{owner:this}),this.addValue(e,n)),n}readValue(e,r){let n=this.latestValues[e]!==void 0||!this.current?this.latestValues[e]:this.getBaseTargetFromProps(this.props,e)??this.readValueFromInstance(this.current,e,this.options);return n!=null&&(typeof n=="string"&&(Q1e(n)||eSe(n))?n=parseFloat(n):!Ust(n)&&Df.test(r)&&(n=GSe(e,r)),this.setBaseTarget(e,hc(n)?n.get():n)),hc(n)?n.get():n}setBaseTarget(e,r){this.baseTarget[e]=r}getBaseTarget(e){var o;const{initial:r}=this.props;let n;if(typeof r=="string"||typeof r=="object"){const c=jK(this.props,r,(o=this.presenceContext)==null?void 0:o.custom);c&&(n=c[e])}if(r&&n!==void 0)return n;const s=this.getBaseTargetFromProps(this.props,e);return s!==void 0&&!hc(s)?s:this.initialValues[e]!==void 0&&n===void 0?void 0:this.baseTarget[e]}on(e,r){return this.events[e]||(this.events[e]=new mK),this.events[e].add(r)}notify(e,...r){this.events[e]&&this.events[e].notify(...r)}scheduleRenderMicrotask(){NK.render(this.render)}}class tTe extends Kst{constructor(){super(...arguments),this.KeyframeResolver=wst}sortInstanceNodePosition(e,r){return e.compareDocumentPosition(r)&2?1:-1}getBaseTargetFromProps(e,r){const n=e.style;return n?n[r]:void 0}removeValueFromRenderState(e,{vars:r,style:n}){delete r[e],delete n[e]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:e}=this.props;hc(e)&&(this.childSubscription=e.on("change",r=>{this.current&&(this.current.textContent=`${r}`)}))}}class y0{constructor(e){this.isMounted=!1,this.node=e}update(){}}function rTe({top:t,left:e,right:r,bottom:n}){return{x:{min:e,max:r},y:{min:t,max:n}}}function Yst({x:t,y:e}){return{top:e.min,right:t.max,bottom:e.max,left:t.min}}function Zst(t,e){if(!e)return t;const r=e({x:t.left,y:t.top}),n=e({x:t.right,y:t.bottom});return{top:r.y,left:r.x,bottom:n.y,right:n.x}}function C6(t){return t===void 0||t===1}function Xq({scale:t,scaleX:e,scaleY:r}){return!C6(t)||!C6(e)||!C6(r)}function W_(t){return Xq(t)||nTe(t)||t.z||t.rotate||t.rotateX||t.rotateY||t.skewX||t.skewY}function nTe(t){return Gie(t.x)||Gie(t.y)}function Gie(t){return t&&t!=="0%"}function yO(t,e,r){const n=t-r,s=e*n;return r+s}function Hie(t,e,r,n,s){return s!==void 0&&(t=yO(t,s,n)),yO(t,r,n)+e}function Qq(t,e=0,r=1,n,s){t.min=Hie(t.min,e,r,n,s),t.max=Hie(t.max,e,r,n,s)}function sTe(t,{x:e,y:r}){Qq(t.x,e.translate,e.scale,e.originPoint),Qq(t.y,r.translate,r.scale,r.originPoint)}const Wie=.999999999999,Kie=1.0000000000001;function Xst(t,e,r,n=!1){var a;const s=r.length;if(!s)return;e.x=e.y=1;let o,c;for(let f=0;fWie&&(e.x=1),e.yWie&&(e.y=1)}function Cm(t,e){t.min+=e,t.max+=e}function Yie(t,e,r,n,s=.5){const o=qa(t.min,t.max,s);Qq(t,e,r,o,n)}function Zie(t,e){return typeof t=="string"?parseFloat(t)/100*(e.max-e.min):t}function UM(t,e,r){const n=r??t;Yie(t.x,Zie(e.x,n.x),e.scaleX,e.scale,e.originX),Yie(t.y,Zie(e.y,n.y),e.scaleY,e.scale,e.originY)}function iTe(t,e){return rTe(Zst(t.getBoundingClientRect(),e))}function Qst(t,e,r){const n=iTe(t,r),{scroll:s}=e;return s&&(Cm(n.x,s.offset.x),Cm(n.y,s.offset.y)),n}const Jst={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},eit=uE.length;function tit(t,e,r){let n="",s=!0;for(let o=0;o{if(!e.target)return t;if(typeof t=="string")if(Dn.test(t))t=parseFloat(t);else return t;const r=Xie(t,e.target.x),n=Xie(t,e.target.y);return`${r}% ${n}%`}},rit={correct:(t,{treeScale:e,projectionDelta:r})=>{const n=t,s=Df.parse(t);if(s.length>5)return n;const o=Df.createTransformer(t),c=typeof s[0]!="number"?1:0,a=r.x.scale*e.x,f=r.y.scale*e.y;s[0+c]/=a,s[1+c]/=f;const m=qa(a,f,.5);return typeof s[2+c]=="number"&&(s[2+c]/=m),typeof s[3+c]=="number"&&(s[3+c]/=m),o(s)}},Jq={borderRadius:{...ak,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:ak,borderTopRightRadius:ak,borderBottomLeftRadius:ak,borderBottomRightRadius:ak,boxShadow:rit};function oTe(t,{layout:e,layoutId:r}){return dE.has(t)||t.startsWith("origin")||(e||r!==void 0)&&(!!Jq[t]||t==="opacity")}function MK(t,e,r){var c;const n=t.style,s=e==null?void 0:e.style,o={};if(!n)return o;for(const a in n)(hc(n[a])||s&&hc(s[a])||oTe(a,t)||((c=r==null?void 0:r.getValue(a))==null?void 0:c.liveStyle)!==void 0)&&(o[a]=n[a]);return o}function nit(t){return window.getComputedStyle(t)}class sit extends tTe{constructor(){super(...arguments),this.type="html",this.renderInstance=aTe}readValueFromInstance(e,r){var n;if(dE.has(r))return(n=this.projection)!=null&&n.isProjecting?Bq(r):Snt(e,r);{const s=nit(e),o=(pSe(r)?s.getPropertyValue(r):s[r])||0;return typeof o=="string"?o.trim():o}}measureInstanceViewportBox(e,{transformPagePoint:r}){return iTe(e,r)}build(e,r,n){LK(e,r,n.transformTemplate)}scrapeMotionValuesFromProps(e,r,n){return MK(e,r,n)}}const iit={offset:"stroke-dashoffset",array:"stroke-dasharray"},ait={offset:"strokeDashoffset",array:"strokeDasharray"};function oit(t,e,r=1,n=0,s=!0){t.pathLength=1;const o=s?iit:ait;t[o.offset]=`${-n}`,t[o.array]=`${e} ${r}`}const lit=["offsetDistance","offsetPath","offsetRotate","offsetAnchor"];function lTe(t,{attrX:e,attrY:r,attrScale:n,pathLength:s,pathSpacing:o=1,pathOffset:c=0,...a},f,m,y){if(LK(t,a,m),f){t.style.viewBox&&(t.attrs.viewBox=t.style.viewBox);return}t.attrs=t.style,t.style={};const{attrs:_,style:w}=t;_.transform&&(w.transform=_.transform,delete _.transform),(w.transform||_.transformOrigin)&&(w.transformOrigin=_.transformOrigin??"50% 50%",delete _.transformOrigin),w.transform&&(w.transformBox=(y==null?void 0:y.transformBox)??"fill-box",delete _.transformBox);for(const E of lit)_[E]!==void 0&&(w[E]=_[E],delete _[E]);e!==void 0&&(_.x=e),r!==void 0&&(_.y=r),n!==void 0&&(_.scale=n),s!==void 0&&oit(_,s,o,c,!1)}const cTe=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues","viewBox","gradientTransform","pathLength","startOffset","textLength","lengthAdjust"]),uTe=t=>typeof t=="string"&&t.toLowerCase()==="svg";function cit(t,e,r,n){aTe(t,e,void 0,n);for(const s in e.attrs)t.setAttribute(cTe.has(s)?s:kK(s),e.attrs[s])}function dTe(t,e,r){const n=MK(t,e,r);for(const s in t)if(hc(t[s])||hc(e[s])){const o=uE.indexOf(s)!==-1?"attr"+s.charAt(0).toUpperCase()+s.substring(1):s;n[o]=t[s]}return n}class uit extends tTe{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=_l}getBaseTargetFromProps(e,r){return e[r]}readValueFromInstance(e,r){if(dE.has(r)){const n=qSe(r);return n&&n.default||0}return r=cTe.has(r)?r:kK(r),e.getAttribute(r)}scrapeMotionValuesFromProps(e,r,n){return dTe(e,r,n)}build(e,r,n){lTe(e,r,this.isSVGTag,n.transformTemplate,n.style)}renderInstance(e,r,n,s){cit(e,r,n,s)}mount(e){this.isSVGTag=uTe(e.tagName),super.mount(e)}}const dit=RK.length;function hTe(t){if(!t)return;if(!t.isControllingVariants){const r=t.parent?hTe(t.parent)||{}:{};return t.props.initial!==void 0&&(r.initial=t.props.initial),r}const e={};for(let r=0;rPromise.all(e.map(({animation:r,options:n})=>dst(t,r,n)))}function pit(t){let e=mit(t),r=Qie(),n=!0,s=!1;const o=m=>(y,_)=>{var E;const w=jv(t,_,m==="exit"?(E=t.presenceContext)==null?void 0:E.custom:void 0);if(w){const{transition:A,transitionEnd:C,...I}=w;y={...y,...I,...C}}return y};function c(m){e=m(t)}function a(m){const{props:y}=t,_=hTe(t.parent)||{},w=[],E=new Set;let A={},C=1/0;for(let M=0;MC&&q,ee=!1;const oe=Array.isArray(U)?U:[U];let de=oe.reduce(o(D),{});H===!1&&(de={});const{prevResolvedValues:ye={}}=B,Ee={...ye,...de},Le=me=>{J=!0,E.has(me)&&(ee=!0,E.delete(me)),B.needsAnimating[me]=!0;const ke=t.getValue(me);ke&&(ke.liveStyle=!1)};for(const me in Ee){const ke=de[me],Pe=ye[me];if(A.hasOwnProperty(me))continue;let je=!1;Gq(ke)&&Gq(Pe)?je=!fTe(ke,Pe):je=ke!==Pe,je?ke!=null?Le(me):E.add(me):ke!==void 0&&E.has(me)?Le(me):B.protectedKeys[me]=!0}B.prevProp=U,B.prevResolvedValues=de,B.isActive&&(A={...A,...de}),(n||s)&&t.blockInitialAnimation&&(J=!1);const Se=K&&Q;J&&(!Se||ee)&&w.push(...oe.map(me=>{const ke={type:D};if(typeof me=="string"&&(n||s)&&!Se&&t.manuallyAnimateOnMount&&t.parent){const{parent:Pe}=t,je=jv(Pe,me);if(Pe.enteringChildren&&je){const{delayChildren:xe}=je.transition||{};ke.delay=MSe(Pe.enteringChildren,t,xe)}}return{animation:me,options:ke}}))}if(E.size){const M={};if(typeof y.initial!="boolean"){const D=jv(t,Array.isArray(y.initial)?y.initial[0]:y.initial);D&&D.transition&&(M.transition=D.transition)}E.forEach(D=>{const B=t.getBaseTarget(D),U=t.getValue(D);U&&(U.liveStyle=!0),M[D]=B??null}),w.push({animation:M})}let I=!!w.length;return n&&(y.initial===!1||y.initial===y.animate)&&!t.manuallyAnimateOnMount&&(I=!1),n=!1,s=!1,I?e(w):Promise.resolve()}function f(m,y){var w;if(r[m].isActive===y)return Promise.resolve();(w=t.variantChildren)==null||w.forEach(E=>{var A;return(A=E.animationState)==null?void 0:A.setActive(m,y)}),r[m].isActive=y;const _=a(m);for(const E in r)r[E].protectedKeys={};return _}return{animateChanges:a,setActive:f,setAnimateFunction:c,getState:()=>r,reset:()=>{r=Qie(),s=!0}}}function git(t,e){return typeof e=="string"?e!==t:Array.isArray(e)?!fTe(e,t):!1}function M_(t=!1){return{isActive:t,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function Qie(){return{animate:M_(!0),whileInView:M_(),whileHover:M_(),whileTap:M_(),whileDrag:M_(),whileFocus:M_(),exit:M_()}}function e9(t,e){t.min=e.min,t.max=e.max}function sf(t,e){e9(t.x,e.x),e9(t.y,e.y)}function Jie(t,e){t.translate=e.translate,t.scale=e.scale,t.originPoint=e.originPoint,t.origin=e.origin}const mTe=1e-4,yit=1-mTe,xit=1+mTe,pTe=.01,_it=0-pTe,vit=0+pTe;function gu(t){return t.max-t.min}function bit(t,e,r){return Math.abs(t-e)<=r}function eae(t,e,r,n=.5){t.origin=n,t.originPoint=qa(e.min,e.max,t.origin),t.scale=gu(r)/gu(e),t.translate=qa(r.min,r.max,t.origin)-t.originPoint,(t.scale>=yit&&t.scale<=xit||isNaN(t.scale))&&(t.scale=1),(t.translate>=_it&&t.translate<=vit||isNaN(t.translate))&&(t.translate=0)}function uA(t,e,r,n){eae(t.x,e.x,r.x,n?n.originX:void 0),eae(t.y,e.y,r.y,n?n.originY:void 0)}function tae(t,e,r,n=0){const s=n?qa(r.min,r.max,n):r.min;t.min=s+e.min,t.max=t.min+gu(e)}function wit(t,e,r,n){tae(t.x,e.x,r.x,n==null?void 0:n.x),tae(t.y,e.y,r.y,n==null?void 0:n.y)}function rae(t,e,r,n=0){const s=n?qa(r.min,r.max,n):r.min;t.min=e.min-s,t.max=t.min+gu(e)}function xO(t,e,r,n){rae(t.x,e.x,r.x,n==null?void 0:n.x),rae(t.y,e.y,r.y,n==null?void 0:n.y)}function nae(t,e,r,n,s){return t-=e,t=yO(t,1/r,n),s!==void 0&&(t=yO(t,1/s,n)),t}function Sit(t,e=0,r=1,n=.5,s,o=t,c=t){if(Hm.test(e)&&(e=parseFloat(e),e=qa(c.min,c.max,e/100)-c.min),typeof e!="number")return;let a=qa(o.min,o.max,n);t===o&&(a-=e),t.min=nae(t.min,e,r,a,s),t.max=nae(t.max,e,r,a,s)}function sae(t,e,[r,n,s],o,c){Sit(t,e[r],e[n],e[s],e.scale,o,c)}const Tit=["x","scaleX","originX"],Eit=["y","scaleY","originY"];function iae(t,e,r,n){sae(t.x,e,Tit,r?r.x:void 0,n?n.x:void 0),sae(t.y,e,Eit,r?r.y:void 0,n?n.y:void 0)}function aae(t){return t.translate===0&&t.scale===1}function gTe(t){return aae(t.x)&&aae(t.y)}function oae(t,e){return t.min===e.min&&t.max===e.max}function jit(t,e){return oae(t.x,e.x)&&oae(t.y,e.y)}function lae(t,e){return Math.round(t.min)===Math.round(e.min)&&Math.round(t.max)===Math.round(e.max)}function yTe(t,e){return lae(t.x,e.x)&&lae(t.y,e.y)}function cae(t){return gu(t.x)/gu(t.y)}function uae(t,e){return t.translate===e.translate&&t.scale===e.scale&&t.originPoint===e.originPoint}function Em(t){return[t("x"),t("y")]}function kit(t,e,r){let n="";const s=t.x.translate/e.x,o=t.y.translate/e.y,c=(r==null?void 0:r.z)||0;if((s||o||c)&&(n=`translate3d(${s}px, ${o}px, ${c}px) `),(e.x!==1||e.y!==1)&&(n+=`scale(${1/e.x}, ${1/e.y}) `),r){const{transformPerspective:m,rotate:y,rotateX:_,rotateY:w,skewX:E,skewY:A}=r;m&&(n=`perspective(${m}px) ${n}`),y&&(n+=`rotate(${y}deg) `),_&&(n+=`rotateX(${_}deg) `),w&&(n+=`rotateY(${w}deg) `),E&&(n+=`skewX(${E}deg) `),A&&(n+=`skewY(${A}deg) `)}const a=t.x.scale*e.x,f=t.y.scale*e.y;return(a!==1||f!==1)&&(n+=`scale(${a}, ${f})`),n||"none"}const xTe=["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"],Ait=xTe.length,dae=t=>typeof t=="string"?parseFloat(t):t,hae=t=>typeof t=="number"||Dn.test(t);function Nit(t,e,r,n,s,o){s?(t.opacity=qa(0,r.opacity??1,Cit(n)),t.opacityExit=qa(e.opacity??1,0,Iit(n))):o&&(t.opacity=qa(e.opacity??1,r.opacity??1,n));for(let c=0;cne?1:r(uN(t,e,n))}function Pit(t,e,r){const n=hc(t)?t:oT(t);return n.start(EK("",n,e,r)),n.animation}function fN(t,e,r,n={passive:!0}){return t.addEventListener(e,r,n),()=>t.removeEventListener(e,r)}const Rit=(t,e)=>t.depth-e.depth;class Lit{constructor(){this.children=[],this.isDirty=!1}add(e){fK(this.children,e),this.isDirty=!0}remove(e){dO(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(Rit),this.isDirty=!1,this.children.forEach(e)}}function Mit(t,e){const r=pu.now(),n=({timestamp:s})=>{const o=s-r;o>=e&&(Zx(n),t(o-e))};return ga.setup(n,!0),()=>Zx(n)}function VM(t){return hc(t)?t.get():t}class Dit{constructor(){this.members=[]}add(e){fK(this.members,e);for(let r=this.members.length-1;r>=0;r--){const n=this.members[r];if(n===e||n===this.lead||n===this.prevLead)continue;const s=n.instance;(!s||s.isConnected===!1)&&!n.snapshot&&(dO(this.members,n),n.unmount())}e.scheduleRender()}remove(e){if(dO(this.members,e),e===this.prevLead&&(this.prevLead=void 0),e===this.lead){const r=this.members[this.members.length-1];r&&this.promote(r)}}relegate(e){var r;for(let n=this.members.indexOf(e)-1;n>=0;n--){const s=this.members[n];if(s.isPresent!==!1&&((r=s.instance)==null?void 0:r.isConnected)!==!1)return this.promote(s),!0}return!1}promote(e,r){var s;const n=this.lead;if(e!==n&&(this.prevLead=n,this.lead=e,e.show(),n)){n.updateSnapshot(),e.scheduleRender();const{layoutDependency:o}=n.options,{layoutDependency:c}=e.options;(o===void 0||o!==c)&&(e.resumeFrom=n,r&&(n.preserveOpacity=!0),n.snapshot&&(e.snapshot=n.snapshot,e.snapshot.latestValues=n.animationValues||n.latestValues),(s=e.root)!=null&&s.isUpdating&&(e.isLayoutDirty=!0)),e.options.crossfade===!1&&n.hide()}}exitAnimationComplete(){this.members.forEach(e=>{var r,n,s,o,c;(n=(r=e.options).onExitComplete)==null||n.call(r),(c=(s=e.resumingFrom)==null?void 0:(o=s.options).onExitComplete)==null||c.call(o)})}scheduleRender(){this.members.forEach(e=>e.instance&&e.scheduleRender(!1))}removeLeadSnapshot(){var e;(e=this.lead)!=null&&e.snapshot&&(this.lead.snapshot=void 0)}}const qM={hasAnimatedSinceResize:!0,hasEverUpdated:!1},I6=["","X","Y","Z"],Oit=1e3;let Fit=0;function P6(t,e,r,n){const{latestValues:s}=e;s[t]&&(r[t]=s[t],e.setStaticValue(t,0),n&&(n[t]=0))}function vTe(t){if(t.hasCheckedOptimisedAppear=!0,t.root===t)return;const{visualElement:e}=t.options;if(!e)return;const r=$Se(e);if(window.MotionHasOptimisedAnimation(r,"transform")){const{layout:s,layoutId:o}=t.options;window.MotionCancelOptimisedAnimation(r,"transform",ga,!(s||o))}const{parent:n}=t;n&&!n.hasCheckedOptimisedAppear&&vTe(n)}function bTe({attachResizeListener:t,defaultParent:e,measureScroll:r,checkIsScrollRoot:n,resetTransform:s}){return class{constructor(c={},a=e==null?void 0:e()){this.id=Fit++,this.animationId=0,this.animationCommitId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.layoutVersion=0,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,this.nodes.forEach(zit),this.nodes.forEach(Wit),this.nodes.forEach(Kit),this.nodes.forEach(Uit)},this.resolvedRelativeTargetAt=0,this.linkedParentVersion=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=c,this.root=a?a.root||a:this,this.path=a?[...a.path,a]:[],this.parent=a,this.depth=a?a.depth+1:0;for(let f=0;fthis.root.updateBlockedByResize=!1;ga.read(()=>{_=window.innerWidth}),t(c,()=>{const E=window.innerWidth;E!==_&&(_=E,this.root.updateBlockedByResize=!0,y&&y(),y=Mit(w,250),qM.hasAnimatedSinceResize&&(qM.hasAnimatedSinceResize=!1,this.nodes.forEach(gae)))})}a&&this.root.registerSharedNode(a,this),this.options.animate!==!1&&m&&(a||f)&&this.addEventListener("didUpdate",({delta:y,hasLayoutChanged:_,hasRelativeLayoutChanged:w,layout:E})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const A=this.options.transition||m.getDefaultTransition()||Jit,{onLayoutAnimationStart:C,onLayoutAnimationComplete:I}=m.getProps(),M=!this.targetLayout||!yTe(this.targetLayout,E),D=!_&&w;if(this.options.layoutRoot||this.resumeFrom||D||_&&(M||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const B={...TK(A,"layout"),onPlay:C,onComplete:I};(m.shouldReduceMotion||this.options.layoutRoot)&&(B.delay=0,B.type=!1),this.startAnimation(B),this.setAnimationOrigin(y,D)}else _||gae(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=E})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const c=this.getStack();c&&c.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),Zx(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(Yit),this.animationId++)}getTransformTemplate(){const{visualElement:c}=this.options;return c&&c.getProps().transformTemplate}willUpdate(c=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&vTe(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let y=0;y{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!gu(this.snapshot.measuredBox.x)&&!gu(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let f=0;f{const q=U/1e3;yae(_.x,c.x,q),yae(_.y,c.y,q),this.setTargetDelta(_),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(xO(w,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),Xit(this.relativeTarget,this.relativeTargetOrigin,w,q),B&&jit(this.relativeTarget,B)&&(this.isProjectionDirty=!1),B||(B=_l()),sf(B,this.relativeTarget)),C&&(this.animationValues=y,Nit(y,m,this.latestValues,q,D,M)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=q},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(c){var a,f,m;this.notifyListeners("animationStart"),(a=this.currentAnimation)==null||a.stop(),(m=(f=this.resumingFrom)==null?void 0:f.currentAnimation)==null||m.stop(),this.pendingAnimation&&(Zx(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=ga.update(()=>{qM.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=oT(0)),this.motionValue.jump(0,!1),this.currentAnimation=Pit(this.motionValue,[0,1e3],{...c,velocity:0,isSync:!0,onUpdate:y=>{this.mixTargetDelta(y),c.onUpdate&&c.onUpdate(y)},onStop:()=>{},onComplete:()=>{c.onComplete&&c.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);const c=this.getStack();c&&c.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(Oit),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const c=this.getLead();let{targetWithTransforms:a,target:f,layout:m,latestValues:y}=c;if(!(!a||!f||!m)){if(this!==c&&this.layout&&m&&wTe(this.options.animationType,this.layout.layoutBox,m.layoutBox)){f=this.target||_l();const _=gu(this.layout.layoutBox.x);f.x.min=c.target.x.min,f.x.max=f.x.min+_;const w=gu(this.layout.layoutBox.y);f.y.min=c.target.y.min,f.y.max=f.y.min+w}sf(a,f),UM(a,y),uA(this.projectionDeltaWithTransform,this.layoutCorrected,a,y)}}registerSharedNode(c,a){this.sharedNodes.has(c)||this.sharedNodes.set(c,new Dit),this.sharedNodes.get(c).add(a);const m=a.options.initialPromotionConfig;a.promote({transition:m?m.transition:void 0,preserveFollowOpacity:m&&m.shouldPreserveFollowOpacity?m.shouldPreserveFollowOpacity(a):void 0})}isLead(){const c=this.getStack();return c?c.lead===this:!0}getLead(){var a;const{layoutId:c}=this.options;return c?((a=this.getStack())==null?void 0:a.lead)||this:this}getPrevLead(){var a;const{layoutId:c}=this.options;return c?(a=this.getStack())==null?void 0:a.prevLead:void 0}getStack(){const{layoutId:c}=this.options;if(c)return this.root.sharedNodes.get(c)}promote({needsReset:c,transition:a,preserveFollowOpacity:f}={}){const m=this.getStack();m&&m.promote(this,f),c&&(this.projectionDelta=void 0,this.needsReset=!0),a&&this.setOptions({transition:a})}relegate(){const c=this.getStack();return c?c.relegate(this):!1}resetSkewAndRotation(){const{visualElement:c}=this.options;if(!c)return;let a=!1;const{latestValues:f}=c;if((f.z||f.rotate||f.rotateX||f.rotateY||f.rotateZ||f.skewX||f.skewY)&&(a=!0),!a)return;const m={};f.z&&P6("z",c,m,this.animationValues);for(let y=0;y{var a;return(a=c.currentAnimation)==null?void 0:a.stop()}),this.root.nodes.forEach(mae),this.root.sharedNodes.clear()}}}function Bit(t){t.updateLayout()}function $it(t){var r;const e=((r=t.resumeFrom)==null?void 0:r.snapshot)||t.snapshot;if(t.isLead()&&t.layout&&e&&t.hasListeners("didUpdate")){const{layoutBox:n,measuredBox:s}=t.layout,{animationType:o}=t.options,c=e.source!==t.layout.source;if(o==="size")Em(_=>{const w=c?e.measuredBox[_]:e.layoutBox[_],E=gu(w);w.min=n[_].min,w.max=w.min+E});else if(o==="x"||o==="y"){const _=o==="x"?"y":"x";e9(c?e.measuredBox[_]:e.layoutBox[_],n[_])}else wTe(o,e.layoutBox,n)&&Em(_=>{const w=c?e.measuredBox[_]:e.layoutBox[_],E=gu(n[_]);w.max=w.min+E,t.relativeTarget&&!t.currentAnimation&&(t.isProjectionDirty=!0,t.relativeTarget[_].max=t.relativeTarget[_].min+E)});const a=W1();uA(a,n,e.layoutBox);const f=W1();c?uA(f,t.applyTransform(s,!0),e.measuredBox):uA(f,n,e.layoutBox);const m=!gTe(a);let y=!1;if(!t.resumeFrom){const _=t.getClosestProjectingParent();if(_&&!_.resumeFrom){const{snapshot:w,layout:E}=_;if(w&&E){const A=t.options.layoutAnchor||void 0,C=_l();xO(C,e.layoutBox,w.layoutBox,A);const I=_l();xO(I,n,E.layoutBox,A),yTe(C,I)||(y=!0),_.options.layoutRoot&&(t.relativeTarget=I,t.relativeTargetOrigin=C,t.relativeParent=_)}}}t.notifyListeners("didUpdate",{layout:n,snapshot:e,delta:f,layoutDelta:a,hasLayoutChanged:m,hasRelativeLayoutChanged:y})}else if(t.isLead()){const{onExitComplete:n}=t.options;n&&n()}t.options.transition=void 0}function zit(t){t.parent&&(t.isProjecting()||(t.isProjectionDirty=t.parent.isProjectionDirty),t.isSharedProjectionDirty||(t.isSharedProjectionDirty=!!(t.isProjectionDirty||t.parent.isProjectionDirty||t.parent.isSharedProjectionDirty)),t.isTransformDirty||(t.isTransformDirty=t.parent.isTransformDirty))}function Uit(t){t.isProjectionDirty=t.isSharedProjectionDirty=t.isTransformDirty=!1}function Vit(t){t.clearSnapshot()}function mae(t){t.clearMeasurements()}function qit(t){t.isLayoutDirty=!0,t.updateLayout()}function pae(t){t.isLayoutDirty=!1}function Git(t){t.isAnimationBlocked&&t.layout&&!t.isLayoutDirty&&(t.snapshot=t.layout,t.isLayoutDirty=!0)}function Hit(t){const{visualElement:e}=t.options;e&&e.getProps().onBeforeLayoutMeasure&&e.notify("BeforeLayoutMeasure"),t.resetTransform()}function gae(t){t.finishAnimation(),t.targetDelta=t.relativeTarget=t.target=void 0,t.isProjectionDirty=!0}function Wit(t){t.resolveTargetDelta()}function Kit(t){t.calcProjection()}function Yit(t){t.resetSkewAndRotation()}function Zit(t){t.removeLeadSnapshot()}function yae(t,e,r){t.translate=qa(e.translate,0,r),t.scale=qa(e.scale,1,r),t.origin=e.origin,t.originPoint=e.originPoint}function xae(t,e,r,n){t.min=qa(e.min,r.min,n),t.max=qa(e.max,r.max,n)}function Xit(t,e,r,n){xae(t.x,e.x,r.x,n),xae(t.y,e.y,r.y,n)}function Qit(t){return t.animationValues&&t.animationValues.opacityExit!==void 0}const Jit={duration:.45,ease:[.4,0,.1,1]},_ae=t=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(t),vae=_ae("applewebkit/")&&!_ae("chrome/")?Math.round:Eh;function bae(t){t.min=vae(t.min),t.max=vae(t.max)}function eat(t){bae(t.x),bae(t.y)}function wTe(t,e,r){return t==="position"||t==="preserve-aspect"&&!bit(cae(e),cae(r),.2)}function tat(t){var e;return t!==t.root&&((e=t.scroll)==null?void 0:e.wasRoot)}const rat=bTe({attachResizeListener:(t,e)=>fN(t,"resize",e),measureScroll:()=>{var t,e;return{x:document.documentElement.scrollLeft||((t=document.body)==null?void 0:t.scrollLeft)||0,y:document.documentElement.scrollTop||((e=document.body)==null?void 0:e.scrollTop)||0}},checkIsScrollRoot:()=>!0}),R6={current:void 0},STe=bTe({measureScroll:t=>({x:t.scrollLeft,y:t.scrollTop}),defaultParent:()=>{if(!R6.current){const t=new rat({});t.mount(window),t.setOptions({layoutScroll:!0}),R6.current=t}return R6.current},resetTransform:(t,e)=>{t.style.transform=e!==void 0?e:"none"},checkIsScrollRoot:t=>window.getComputedStyle(t).position==="fixed"}),DK=N.createContext({transformPagePoint:t=>t,isStatic:!1,reducedMotion:"never"});function wae(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function nat(...t){return e=>{let r=!1;const n=t.map(s=>{const o=wae(s,e);return!r&&typeof o=="function"&&(r=!0),o});if(r)return()=>{for(let s=0;s{const{width:E,height:A,top:C,left:I,right:M,bottom:D}=f.current;if(e||o===!1||!a.current||!E||!A)return;const B=r==="left"?`left: ${I}`:`right: ${M}`,U=n==="bottom"?`bottom: ${D}`:`top: ${C}`;a.current.dataset.motionPopId=c;const q=document.createElement("style");m&&(q.nonce=m);const H=s??document.head;return H.appendChild(q),q.sheet&&q.sheet.insertRule(` [data-motion-pop-id="${c}"] { position: absolute !important; width: ${E}px !important; height: ${A}px !important; ${B}px !important; ${U}px !important; } `),()=>{var K;(K=a.current)==null||K.removeAttribute("data-motion-pop-id"),H.contains(q)&&H.removeChild(q)}},[e]),i.jsx(iat,{isPresent:e,childRef:a,sizeRef:f,pop:o,children:o===!1?t:N.cloneElement(t,{ref:_})})}const oat=({children:t,initial:e,isPresent:r,onExitComplete:n,custom:s,presenceAffectsLayout:o,mode:c,anchorX:a,anchorY:f,root:m})=>{const y=hK(lat),_=N.useId();let w=!0,E=N.useMemo(()=>(w=!1,{id:_,initial:e,isPresent:r,custom:s,onExitComplete:A=>{y.set(A,!0);for(const C of y.values())if(!C)return;n&&n()},register:A=>(y.set(A,!1),()=>y.delete(A))}),[r,y,n]);return o&&w&&(E={...E}),N.useMemo(()=>{y.forEach((A,C)=>y.set(C,!1))},[r]),N.useEffect(()=>{!r&&!y.size&&n&&n()},[r]),t=i.jsx(aat,{pop:c==="popLayout",isPresent:r,anchorX:a,anchorY:f,root:m,children:t}),i.jsx(dF.Provider,{value:E,children:t})};function lat(){return new Map}function TTe(t=!0){const e=N.useContext(dF);if(e===null)return[!0,null];const{isPresent:r,onExitComplete:n,register:s}=e,o=N.useId();N.useEffect(()=>{if(t)return s(o)},[t]);const c=N.useCallback(()=>t&&n&&n(o),[o,n,t]);return!r&&n?[!1,c]:[!0]}const vL=t=>t.key||"";function Sae(t){const e=[];return N.Children.forEach(t,r=>{N.isValidElement(r)&&e.push(r)}),e}const ETe=({children:t,custom:e,initial:r=!0,onExitComplete:n,presenceAffectsLayout:s=!0,mode:o="sync",propagate:c=!1,anchorX:a="left",anchorY:f="top",root:m})=>{const[y,_]=TTe(c),w=N.useMemo(()=>Sae(t),[t]),E=c&&!y?[]:w.map(vL),A=N.useRef(!0),C=N.useRef(w),I=hK(()=>new Map),M=N.useRef(new Set),[D,B]=N.useState(w),[U,q]=N.useState(w);X1e(()=>{A.current=!1,C.current=w;for(let Q=0;Q{const J=vL(Q),ee=c&&!y?!1:w===U||E.includes(J),oe=()=>{if(M.current.has(J))return;if(I.has(J))M.current.add(J),I.set(J,!0);else return;let de=!0;I.forEach(ye=>{ye||(de=!1)}),de&&(K==null||K(),q(C.current),c&&(_==null||_()),n&&n())};return i.jsx(oat,{isPresent:ee,initial:!A.current||r?void 0:!1,custom:e,presenceAffectsLayout:s,mode:o,root:m,onExitComplete:ee?void 0:oe,anchorX:a,anchorY:f,children:Q},J)})})},jTe=N.createContext({strict:!1}),Tae={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]};let Eae=!1;function cat(){if(Eae)return;const t={};for(const e in Tae)t[e]={isEnabled:r=>Tae[e].some(n=>!!r[n])};eTe(t),Eae=!0}function kTe(){return cat(),Wst()}function uat(t){const e=kTe();for(const r in t)e[r]={...e[r],...t[r]};eTe(e)}const dat=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","propagate","ignoreStrict","viewport"]);function _O(t){return t.startsWith("while")||t.startsWith("drag")&&t!=="draggable"||t.startsWith("layout")||t.startsWith("onTap")||t.startsWith("onPan")||t.startsWith("onLayout")||dat.has(t)}let ATe=t=>!_O(t);function hat(t){typeof t=="function"&&(ATe=e=>e.startsWith("on")?!_O(e):t(e))}try{hat(require("@emotion/is-prop-valid").default)}catch{}function fat(t,e,r){const n={};for(const s in t)s==="values"&&typeof t.values=="object"||hc(t[s])||(ATe(s)||r===!0&&_O(s)||!e&&!_O(s)||t.draggable&&s.startsWith("onDrag"))&&(n[s]=t[s]);return n}const gF=N.createContext({});function mat(t,e){if(pF(t)){const{initial:r,animate:n}=t;return{initial:r===!1||hN(r)?r:void 0,animate:hN(n)?n:void 0}}return t.inherit!==!1?e:{}}function pat(t){const{initial:e,animate:r}=mat(t,N.useContext(gF));return N.useMemo(()=>({initial:e,animate:r}),[jae(e),jae(r)])}function jae(t){return Array.isArray(t)?t.join(" "):t}const OK=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function NTe(t,e,r){for(const n in e)!hc(e[n])&&!oTe(n,r)&&(t[n]=e[n])}function gat({transformTemplate:t},e){return N.useMemo(()=>{const r=OK();return LK(r,e,t),Object.assign({},r.vars,r.style)},[e])}function yat(t,e){const r=t.style||{},n={};return NTe(n,r,t),Object.assign(n,gat(t,e)),n}function xat(t,e){const r={},n=yat(t,e);return t.drag&&t.dragListener!==!1&&(r.draggable=!1,n.userSelect=n.WebkitUserSelect=n.WebkitTouchCallout="none",n.touchAction=t.drag===!0?"none":`pan-${t.drag==="x"?"y":"x"}`),t.tabIndex===void 0&&(t.onTap||t.onTapStart||t.whileTap)&&(r.tabIndex=0),r.style=n,r}const CTe=()=>({...OK(),attrs:{}});function _at(t,e,r,n){const s=N.useMemo(()=>{const o=CTe();return lTe(o,e,uTe(n),t.transformTemplate,t.style),{...o.attrs,style:{...o.style}}},[e]);if(t.style){const o={};NTe(o,t.style,t),s.style={...o,...s.style}}return s}const vat=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function FK(t){return typeof t!="string"||t.includes("-")?!1:!!(vat.indexOf(t)>-1||/[A-Z]/u.test(t))}function bat(t,e,r,{latestValues:n},s,o=!1,c){const f=(c??FK(t)?_at:xat)(e,n,s,t),m=fat(e,typeof t=="string",o),y=t!==N.Fragment?{...m,...f,ref:r}:{},{children:_}=e,w=N.useMemo(()=>hc(_)?_.get():_,[_]);return N.createElement(t,{...y,children:w})}function wat({scrapeMotionValuesFromProps:t,createRenderState:e},r,n,s){return{latestValues:Sat(r,n,s,t),renderState:e()}}function Sat(t,e,r,n){const s={},o=n(t,{});for(const w in o)s[w]=VM(o[w]);let{initial:c,animate:a}=t;const f=pF(t),m=QSe(t);e&&m&&!f&&t.inherit!==!1&&(c===void 0&&(c=e.initial),a===void 0&&(a=e.animate));let y=r?r.initial===!1:!1;y=y||c===!1;const _=y?a:c;if(_&&typeof _!="boolean"&&!mF(_)){const w=Array.isArray(_)?_:[_];for(let E=0;E(e,r)=>{const n=N.useContext(gF),s=N.useContext(dF),o=()=>wat(t,e,n,s);return r?o():hK(o)},Tat=ITe({scrapeMotionValuesFromProps:MK,createRenderState:OK}),Eat=ITe({scrapeMotionValuesFromProps:dTe,createRenderState:CTe}),jat=Symbol.for("motionComponentSymbol");function kat(t,e,r){const n=N.useRef(r);N.useInsertionEffect(()=>{n.current=r});const s=N.useRef(null);return N.useCallback(o=>{var a;o&&((a=t.onMount)==null||a.call(t,o));const c=n.current;if(typeof c=="function")if(o){const f=c(o);typeof f=="function"&&(s.current=f)}else s.current?(s.current(),s.current=null):c(o);else c&&(c.current=o);e&&(o?e.mount(o):e.unmount())},[e])}const PTe=N.createContext({});function A1(t){return t&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"current")}function Aat(t,e,r,n,s,o){var B,U;const{visualElement:c}=N.useContext(gF),a=N.useContext(jTe),f=N.useContext(dF),m=N.useContext(DK),y=m.reducedMotion,_=m.skipAnimations,w=N.useRef(null),E=N.useRef(!1);n=n||a.renderer,!w.current&&n&&(w.current=n(t,{visualState:e,parent:c,props:r,presenceContext:f,blockInitialAnimation:f?f.initial===!1:!1,reducedMotionConfig:y,skipAnimations:_,isSVG:o}),E.current&&w.current&&(w.current.manuallyAnimateOnMount=!0));const A=w.current,C=N.useContext(PTe);A&&!A.projection&&s&&(A.type==="html"||A.type==="svg")&&Nat(w.current,r,s,C);const I=N.useRef(!1);N.useInsertionEffect(()=>{A&&I.current&&A.update(r,f)});const M=r[BSe],D=N.useRef(!!M&&typeof window<"u"&&!((B=window.MotionHandoffIsComplete)!=null&&B.call(window,M))&&((U=window.MotionHasOptimisedAnimation)==null?void 0:U.call(window,M)));return X1e(()=>{E.current=!0,A&&(I.current=!0,window.MotionIsMounted=!0,A.updateFeatures(),A.scheduleRenderMicrotask(),D.current&&A.animationState&&A.animationState.animateChanges())}),N.useEffect(()=>{A&&(!D.current&&A.animationState&&A.animationState.animateChanges(),D.current&&(queueMicrotask(()=>{var q;(q=window.MotionHandoffMarkAsComplete)==null||q.call(window,M)}),D.current=!1),A.enteringChildren=void 0)}),A}function Nat(t,e,r,n){const{layoutId:s,layout:o,drag:c,dragConstraints:a,layoutScroll:f,layoutRoot:m,layoutAnchor:y,layoutCrossfade:_}=e;t.projection=new r(t.latestValues,e["data-framer-portal-id"]?void 0:RTe(t.parent)),t.projection.setOptions({layoutId:s,layout:o,alwaysMeasureLayout:!!c||a&&A1(a),visualElement:t,animationType:typeof o=="string"?o:"both",initialPromotionConfig:n,crossfade:_,layoutScroll:f,layoutRoot:m,layoutAnchor:y})}function RTe(t){if(t)return t.options.allowProjection!==!1?t.projection:RTe(t.parent)}function L6(t,{forwardMotionProps:e=!1,type:r}={},n,s){n&&uat(n);const o=r?r==="svg":FK(t),c=o?Eat:Tat;function a(m,y){let _;const w={...N.useContext(DK),...m,layoutId:Cat(m)},{isStatic:E}=w,A=pat(m),C=c(m,E);if(!E&&typeof window<"u"){Iat();const I=Pat(w);_=I.MeasureLayout,A.visualElement=Aat(t,C,w,s,I.ProjectionNode,o)}return i.jsxs(gF.Provider,{value:A,children:[_&&A.visualElement?i.jsx(_,{visualElement:A.visualElement,...w}):null,bat(t,m,kat(C,A.visualElement,y),C,E,e,o)]})}a.displayName=`motion.${typeof t=="string"?t:`create(${t.displayName??t.name??""})`}`;const f=N.forwardRef(a);return f[jat]=t,f}function Cat({layoutId:t}){const e=N.useContext(dK).id;return e&&t!==void 0?e+"-"+t:t}function Iat(t,e){N.useContext(jTe).strict}function Pat(t){const e=kTe(),{drag:r,layout:n}=e;if(!r&&!n)return{};const s={...r,...n};return{MeasureLayout:r!=null&&r.isEnabled(t)||n!=null&&n.isEnabled(t)?s.MeasureLayout:void 0,ProjectionNode:s.ProjectionNode}}function Rat(t,e){if(typeof Proxy>"u")return L6;const r=new Map,n=(o,c)=>L6(o,c,t,e),s=(o,c)=>n(o,c);return new Proxy(s,{get:(o,c)=>c==="create"?n:(r.has(c)||r.set(c,L6(c,void 0,t,e)),r.get(c))})}const Lat=(t,e)=>e.isSVG??FK(t)?new uit(e):new sit(e,{allowProjection:t!==N.Fragment});class Mat extends y0{constructor(e){super(e),e.animationState||(e.animationState=pit(e))}updateAnimationControlsSubscription(){const{animate:e}=this.node.getProps();mF(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:e}=this.node.getProps(),{animate:r}=this.node.prevProps||{};e!==r&&this.updateAnimationControlsSubscription()}unmount(){var e;this.node.animationState.reset(),(e=this.unmountControls)==null||e.call(this)}}let Dat=0;class Oat extends y0{constructor(){super(...arguments),this.id=Dat++,this.isExitComplete=!1}update(){var o;if(!this.node.presenceContext)return;const{isPresent:e,onExitComplete:r}=this.node.presenceContext,{isPresent:n}=this.node.prevPresenceContext||{};if(!this.node.animationState||e===n)return;if(e&&n===!1){if(this.isExitComplete){const{initial:c,custom:a}=this.node.getProps();if(typeof c=="string"){const f=jv(this.node,c,a);if(f){const{transition:m,transitionEnd:y,..._}=f;for(const w in _)(o=this.node.getValue(w))==null||o.jump(_[w])}}this.node.animationState.reset(),this.node.animationState.animateChanges()}else this.node.animationState.setActive("exit",!1);this.isExitComplete=!1;return}const s=this.node.animationState.setActive("exit",!e);r&&!e&&s.then(()=>{this.isExitComplete=!0,r(this.id)})}mount(){const{register:e,onExitComplete:r}=this.node.presenceContext||{};r&&r(this.id),e&&(this.unmount=e(this.id))}unmount(){}}const Fat={animation:{Feature:Mat},exit:{Feature:Oat}};function WC(t){return{point:{x:t.pageX,y:t.pageY}}}const Bat=t=>e=>CK(e)&&t(e,WC(e));function dA(t,e,r,n){return fN(t,e,Bat(r),n)}const LTe=({current:t})=>t?t.ownerDocument.defaultView:null,kae=(t,e)=>Math.abs(t-e);function $at(t,e){const r=kae(t.x,e.x),n=kae(t.y,e.y);return Math.sqrt(r**2+n**2)}const Aae=new Set(["auto","scroll"]);class MTe{constructor(e,r,{transformPagePoint:n,contextWindow:s=window,dragSnapToOrigin:o=!1,distanceThreshold:c=3,element:a}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.lastRawMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=E=>{this.handleScroll(E.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=bL(this.lastRawMoveEventInfo,this.transformPagePoint));const E=M6(this.lastMoveEventInfo,this.history),A=this.startEvent!==null,C=$at(E.offset,{x:0,y:0})>=this.distanceThreshold;if(!A&&!C)return;const{point:I}=E,{timestamp:M}=rc;this.history.push({...I,timestamp:M});const{onStart:D,onMove:B}=this.handlers;A||(D&&D(this.lastMoveEvent,E),this.startEvent=this.lastMoveEvent),B&&B(this.lastMoveEvent,E)},this.handlePointerMove=(E,A)=>{this.lastMoveEvent=E,this.lastRawMoveEventInfo=A,this.lastMoveEventInfo=bL(A,this.transformPagePoint),ga.update(this.updatePoint,!0)},this.handlePointerUp=(E,A)=>{this.end();const{onEnd:C,onSessionEnd:I,resumeAnimation:M}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&M&&M(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const D=M6(E.type==="pointercancel"?this.lastMoveEventInfo:bL(A,this.transformPagePoint),this.history);this.startEvent&&C&&C(E,D),I&&I(E,D)},!CK(e))return;this.dragSnapToOrigin=o,this.handlers=r,this.transformPagePoint=n,this.distanceThreshold=c,this.contextWindow=s||window;const f=WC(e),m=bL(f,this.transformPagePoint),{point:y}=m,{timestamp:_}=rc;this.history=[{...y,timestamp:_}];const{onSessionStart:w}=r;w&&w(e,M6(m,this.history)),this.removeListeners=qC(dA(this.contextWindow,"pointermove",this.handlePointerMove),dA(this.contextWindow,"pointerup",this.handlePointerUp),dA(this.contextWindow,"pointercancel",this.handlePointerUp)),a&&this.startScrollTracking(a)}startScrollTracking(e){let r=e.parentElement;for(;r;){const n=getComputedStyle(r);(Aae.has(n.overflowX)||Aae.has(n.overflowY))&&this.scrollPositions.set(r,{x:r.scrollLeft,y:r.scrollTop}),r=r.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener("scroll",this.onElementScroll,{capture:!0}),window.addEventListener("scroll",this.onWindowScroll),this.removeScrollListeners=()=>{window.removeEventListener("scroll",this.onElementScroll,{capture:!0}),window.removeEventListener("scroll",this.onWindowScroll)}}handleScroll(e){const r=this.scrollPositions.get(e);if(!r)return;const n=e===window,s=n?{x:window.scrollX,y:window.scrollY}:{x:e.scrollLeft,y:e.scrollTop},o={x:s.x-r.x,y:s.y-r.y};o.x===0&&o.y===0||(n?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=o.x,this.lastMoveEventInfo.point.y+=o.y):this.history.length>0&&(this.history[0].x-=o.x,this.history[0].y-=o.y),this.scrollPositions.set(e,s),ga.update(this.updatePoint,!0))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),Zx(this.updatePoint)}}function bL(t,e){return e?{point:e(t.point)}:t}function Nae(t,e){return{x:t.x-e.x,y:t.y-e.y}}function M6({point:t},e){return{point:t,delta:Nae(t,DTe(e)),offset:Nae(t,zat(e)),velocity:Uat(e,.1)}}function zat(t){return t[0]}function DTe(t){return t[t.length-1]}function Uat(t,e){if(t.length<2)return{x:0,y:0};let r=t.length-1,n=null;const s=DTe(t);for(;r>=0&&(n=t[r],!(s.timestamp-n.timestamp>Ju(e)));)r--;if(!n)return{x:0,y:0};n===t[0]&&t.length>2&&s.timestamp-n.timestamp>Ju(e)*2&&(n=t[1]);const o=vh(s.timestamp-n.timestamp);if(o===0)return{x:0,y:0};const c={x:(s.x-n.x)/o,y:(s.y-n.y)/o};return c.x===1/0&&(c.x=0),c.y===1/0&&(c.y=0),c}function Vat(t,{min:e,max:r},n){return e!==void 0&&tr&&(t=n?qa(r,t,n.max):Math.min(t,r)),t}function Cae(t,e,r){return{min:e!==void 0?t.min+e:void 0,max:r!==void 0?t.max+r-(t.max-t.min):void 0}}function qat(t,{top:e,left:r,bottom:n,right:s}){return{x:Cae(t.x,r,s),y:Cae(t.y,e,n)}}function Iae(t,e){let r=e.min-t.min,n=e.max-t.max;return e.max-e.minn?r=uN(e.min,e.max-n,t.min):n>s&&(r=uN(t.min,t.max-s,e.min)),ep(0,1,r)}function Wat(t,e){const r={};return e.min!==void 0&&(r.min=e.min-t.min),e.max!==void 0&&(r.max=e.max-t.min),r}const t9=.35;function Kat(t=t9){return t===!1?t=0:t===!0&&(t=t9),{x:Pae(t,"left","right"),y:Pae(t,"top","bottom")}}function Pae(t,e,r){return{min:Rae(t,e),max:Rae(t,r)}}function Rae(t,e){return typeof t=="number"?t:t[e]||0}const Yat=new WeakMap;class Zat{constructor(e){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=_l(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=e}start(e,{snapToCursor:r=!1,distanceThreshold:n}={}){const{presenceContext:s}=this.visualElement;if(s&&s.isPresent===!1)return;const o=_=>{r&&this.snapToCursor(WC(_).point),this.stopAnimation()},c=(_,w)=>{const{drag:E,dragPropagation:A,onDragStart:C}=this.getProps();if(E&&!A&&(this.openDragLock&&this.openDragLock(),this.openDragLock=Sst(E),!this.openDragLock))return;this.latestPointerEvent=_,this.latestPanInfo=w,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),Em(M=>{let D=this.getAxisMotionValue(M).get()||0;if(Hm.test(D)){const{projection:B}=this.visualElement;if(B&&B.layout){const U=B.layout.layoutBox[M];U&&(D=gu(U)*(parseFloat(D)/100))}}this.originPoint[M]=D}),C&&ga.update(()=>C(_,w),!1,!0),Hq(this.visualElement,"transform");const{animationState:I}=this.visualElement;I&&I.setActive("whileDrag",!0)},a=(_,w)=>{this.latestPointerEvent=_,this.latestPanInfo=w;const{dragPropagation:E,dragDirectionLock:A,onDirectionLock:C,onDrag:I}=this.getProps();if(!E&&!this.openDragLock)return;const{offset:M}=w;if(A&&this.currentDirection===null){this.currentDirection=Qat(M),this.currentDirection!==null&&C&&C(this.currentDirection);return}this.updateAxis("x",w.point,M),this.updateAxis("y",w.point,M),this.visualElement.render(),I&&ga.update(()=>I(_,w),!1,!0)},f=(_,w)=>{this.latestPointerEvent=_,this.latestPanInfo=w,this.stop(_,w),this.latestPointerEvent=null,this.latestPanInfo=null},m=()=>{const{dragSnapToOrigin:_}=this.getProps();(_||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:y}=this.getProps();this.panSession=new MTe(e,{onSessionStart:o,onStart:c,onMove:a,onSessionEnd:f,resumeAnimation:m},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:y,distanceThreshold:n,contextWindow:LTe(this.visualElement),element:this.visualElement.current})}stop(e,r){const n=e||this.latestPointerEvent,s=r||this.latestPanInfo,o=this.isDragging;if(this.cancel(),!o||!s||!n)return;const{velocity:c}=s;this.startAnimation(c);const{onDragEnd:a}=this.getProps();a&&ga.postRender(()=>a(n,s))}cancel(){this.isDragging=!1;const{projection:e,animationState:r}=this.visualElement;e&&(e.isAnimationBlocked=!1),this.endPanSession();const{dragPropagation:n}=this.getProps();!n&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),r&&r.setActive("whileDrag",!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(e,r,n){const{drag:s}=this.getProps();if(!n||!wL(e,s,this.currentDirection))return;const o=this.getAxisMotionValue(e);let c=this.originPoint[e]+n[e];this.constraints&&this.constraints[e]&&(c=Vat(c,this.constraints[e],this.elastic[e])),o.set(c)}resolveConstraints(){var o;const{dragConstraints:e,dragElastic:r}=this.getProps(),n=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):(o=this.visualElement.projection)==null?void 0:o.layout,s=this.constraints;e&&A1(e)?this.constraints||(this.constraints=this.resolveRefConstraints()):e&&n?this.constraints=qat(n.layoutBox,e):this.constraints=!1,this.elastic=Kat(r),s!==this.constraints&&!A1(e)&&n&&this.constraints&&!this.hasMutatedConstraints&&Em(c=>{this.constraints!==!1&&this.getAxisMotionValue(c)&&(this.constraints[c]=Wat(n.layoutBox[c],this.constraints[c]))})}resolveRefConstraints(){const{dragConstraints:e,onMeasureDragConstraints:r}=this.getProps();if(!e||!A1(e))return!1;const n=e.current;iT(n!==null,"If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.","drag-constraints-ref");const{projection:s}=this.visualElement;if(!s||!s.layout)return!1;const o=Qst(n,s.root,this.visualElement.getTransformPagePoint());let c=Gat(s.layout.layoutBox,o);if(r){const a=r(Yst(c));this.hasMutatedConstraints=!!a,a&&(c=rTe(a))}return c}startAnimation(e){const{drag:r,dragMomentum:n,dragElastic:s,dragTransition:o,dragSnapToOrigin:c,onDragTransitionEnd:a}=this.getProps(),f=this.constraints||{},m=Em(y=>{if(!wL(y,r,this.currentDirection))return;let _=f&&f[y]||{};(c===!0||c===y)&&(_={min:0,max:0});const w=s?200:1e6,E=s?40:1e7,A={type:"inertia",velocity:n?e[y]:0,bounceStiffness:w,bounceDamping:E,timeConstant:750,restDelta:1,restSpeed:10,...o,..._};return this.startAxisValueAnimation(y,A)});return Promise.all(m).then(a)}startAxisValueAnimation(e,r){const n=this.getAxisMotionValue(e);return Hq(this.visualElement,e),n.start(EK(e,n,0,r,this.visualElement,!1))}stopAnimation(){Em(e=>this.getAxisMotionValue(e).stop())}getAxisMotionValue(e){const r=`_drag${e.toUpperCase()}`,n=this.visualElement.getProps(),s=n[r];return s||this.visualElement.getValue(e,(n.initial?n.initial[e]:void 0)||0)}snapToCursor(e){Em(r=>{const{drag:n}=this.getProps();if(!wL(r,n,this.currentDirection))return;const{projection:s}=this.visualElement,o=this.getAxisMotionValue(r);if(s&&s.layout){const{min:c,max:a}=s.layout.layoutBox[r],f=o.get()||0;o.set(e[r]-qa(c,a,.5)+f)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:e,dragConstraints:r}=this.getProps(),{projection:n}=this.visualElement;if(!A1(r)||!n||!this.constraints)return;this.stopAnimation();const s={x:0,y:0};Em(c=>{const a=this.getAxisMotionValue(c);if(a&&this.constraints!==!1){const f=a.get();s[c]=Hat({min:f,max:f},this.constraints[c])}});const{transformTemplate:o}=this.visualElement.getProps();this.visualElement.current.style.transform=o?o({},""):"none",n.root&&n.root.updateScroll(),n.updateLayout(),this.constraints=!1,this.resolveConstraints(),Em(c=>{if(!wL(c,e,null))return;const a=this.getAxisMotionValue(c),{min:f,max:m}=this.constraints[c];a.set(qa(f,m,s[c]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;Yat.set(this.visualElement,this);const e=this.visualElement.current,r=dA(e,"pointerdown",m=>{const{drag:y,dragListener:_=!0}=this.getProps(),w=m.target,E=w!==e&&Nst(w);y&&_&&!E&&this.start(m)});let n;const s=()=>{const{dragConstraints:m}=this.getProps();A1(m)&&m.current&&(this.constraints=this.resolveRefConstraints(),n||(n=Xat(e,m.current,()=>this.scalePositionWithinConstraints())))},{projection:o}=this.visualElement,c=o.addEventListener("measure",s);o&&!o.layout&&(o.root&&o.root.updateScroll(),o.updateLayout()),ga.read(s);const a=fN(window,"resize",()=>this.scalePositionWithinConstraints()),f=o.addEventListener("didUpdate",({delta:m,hasLayoutChanged:y})=>{this.isDragging&&y&&(Em(_=>{const w=this.getAxisMotionValue(_);w&&(this.originPoint[_]+=m[_].translate,w.set(w.get()+m[_].translate))}),this.visualElement.render())});return()=>{a(),r(),c(),f&&f(),n&&n()}}getProps(){const e=this.visualElement.getProps(),{drag:r=!1,dragDirectionLock:n=!1,dragPropagation:s=!1,dragConstraints:o=!1,dragElastic:c=t9,dragMomentum:a=!0}=e;return{...e,drag:r,dragDirectionLock:n,dragPropagation:s,dragConstraints:o,dragElastic:c,dragMomentum:a}}}function Lae(t){let e=!0;return()=>{if(e){e=!1;return}t()}}function Xat(t,e,r){const n=zie(t,Lae(r)),s=zie(e,Lae(r));return()=>{n(),s()}}function wL(t,e,r){return(e===!0||e===t)&&(r===null||r===t)}function Qat(t,e=10){let r=null;return Math.abs(t.y)>e?r="y":Math.abs(t.x)>e&&(r="x"),r}class Jat extends y0{constructor(e){super(e),this.removeGroupControls=Eh,this.removeListeners=Eh,this.controls=new Zat(e)}mount(){const{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||Eh}update(){const{dragControls:e}=this.node.getProps(),{dragControls:r}=this.node.prevProps||{};e!==r&&(this.removeGroupControls(),e&&(this.removeGroupControls=e.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}}const D6=t=>(e,r)=>{t&&ga.update(()=>t(e,r),!1,!0)};class eot extends y0{constructor(){super(...arguments),this.removePointerDownListener=Eh}onPointerDown(e){this.session=new MTe(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:LTe(this.node)})}createPanHandlers(){const{onPanSessionStart:e,onPanStart:r,onPan:n,onPanEnd:s}=this.node.getProps();return{onSessionStart:D6(e),onStart:D6(r),onMove:D6(n),onEnd:(o,c)=>{delete this.session,s&&ga.postRender(()=>s(o,c))}}}mount(){this.removePointerDownListener=dA(this.node.current,"pointerdown",e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}let O6=!1;class tot extends N.Component{componentDidMount(){const{visualElement:e,layoutGroup:r,switchLayoutGroup:n,layoutId:s}=this.props,{projection:o}=e;o&&(r.group&&r.group.add(o),n&&n.register&&s&&n.register(o),O6&&o.root.didUpdate(),o.addEventListener("animationComplete",()=>{this.safeToRemove()}),o.setOptions({...o.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),qM.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){const{layoutDependency:r,visualElement:n,drag:s,isPresent:o}=this.props,{projection:c}=n;return c&&(c.isPresent=o,e.layoutDependency!==r&&c.setOptions({...c.options,layoutDependency:r}),O6=!0,s||e.layoutDependency!==r||r===void 0||e.isPresent!==o?c.willUpdate():this.safeToRemove(),e.isPresent!==o&&(o?c.promote():c.relegate()||ga.postRender(()=>{const a=c.getStack();(!a||!a.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{visualElement:e,layoutAnchor:r}=this.props,{projection:n}=e;n&&(n.options.layoutAnchor=r,n.root.didUpdate(),NK.postRender(()=>{!n.currentAnimation&&n.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:e,layoutGroup:r,switchLayoutGroup:n}=this.props,{projection:s}=e;O6=!0,s&&(s.scheduleCheckAfterUnmount(),r&&r.group&&r.group.remove(s),n&&n.deregister&&n.deregister(s))}safeToRemove(){const{safeToRemove:e}=this.props;e&&e()}render(){return null}}function OTe(t){const[e,r]=TTe(),n=N.useContext(dK);return i.jsx(tot,{...t,layoutGroup:n,switchLayoutGroup:N.useContext(PTe),isPresent:e,safeToRemove:r})}const rot={pan:{Feature:eot},drag:{Feature:Jat,ProjectionNode:STe,MeasureLayout:OTe}};function Mae(t,e,r){const{props:n}=t;t.animationState&&n.whileHover&&t.animationState.setActive("whileHover",r==="Start");const s="onHover"+r,o=n[s];o&&ga.postRender(()=>o(e,WC(e)))}class not extends y0{mount(){const{current:e}=this.node;e&&(this.unmount=Est(e,(r,n)=>(Mae(this.node,n,"Start"),s=>Mae(this.node,s,"End"))))}unmount(){}}class sot extends y0{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(":focus-visible")}catch{e=!0}!e||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=qC(fN(this.node.current,"focus",()=>this.onFocus()),fN(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function Dae(t,e,r){const{props:n}=t;if(t.current instanceof HTMLButtonElement&&t.current.disabled)return;t.animationState&&n.whileTap&&t.animationState.setActive("whileTap",r==="Start");const s="onTap"+(r==="End"?"":r),o=n[s];o&&ga.postRender(()=>o(e,WC(e)))}class iot extends y0{mount(){const{current:e}=this.node;if(!e)return;const{globalTapTarget:r,propagate:n}=this.node.props;this.unmount=Ist(e,(s,o)=>(Dae(this.node,o,"Start"),(c,{success:a})=>Dae(this.node,c,a?"End":"Cancel")),{useGlobalTarget:r,stopPropagation:(n==null?void 0:n.tap)===!1})}unmount(){}}const r9=new WeakMap,F6=new WeakMap,aot=t=>{const e=r9.get(t.target);e&&e(t)},oot=t=>{t.forEach(aot)};function lot({root:t,...e}){const r=t||document;F6.has(r)||F6.set(r,{});const n=F6.get(r),s=JSON.stringify(e);return n[s]||(n[s]=new IntersectionObserver(oot,{root:t,...e})),n[s]}function cot(t,e,r){const n=lot(e);return r9.set(t,r),n.observe(t),()=>{r9.delete(t),n.unobserve(t)}}const uot={some:0,all:1};class dot extends y0{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){var f;(f=this.stopObserver)==null||f.call(this);const{viewport:e={}}=this.node.getProps(),{root:r,margin:n,amount:s="some",once:o}=e,c={root:r?r.current:void 0,rootMargin:n,threshold:typeof s=="number"?s:uot[s]},a=m=>{const{isIntersecting:y}=m;if(this.isInView===y||(this.isInView=y,o&&!y&&this.hasEnteredView))return;y&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",y);const{onViewportEnter:_,onViewportLeave:w}=this.node.getProps(),E=y?_:w;E&&E(m)};this.stopObserver=cot(this.node.current,c,a)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:e,prevProps:r}=this.node;["amount","margin","root"].some(hot(e,r))&&this.startObserver()}unmount(){var e;(e=this.stopObserver)==null||e.call(this),this.hasEnteredView=!1,this.isInView=!1}}function hot({viewport:t={}},{viewport:e={}}={}){return r=>t[r]!==e[r]}const fot={inView:{Feature:dot},tap:{Feature:iot},focus:{Feature:sot},hover:{Feature:not}},mot={layout:{ProjectionNode:STe,MeasureLayout:OTe}},pot={...Fat,...fot,...rot,...mot},yr=Rat(pot,Lat);function got(t){switch(t){case"buying":return{label:"Buying",emoji:"🏠",color:"bg-emerald-500/15 text-emerald-400 border-emerald-500/30"};case"selling":return{label:"Selling",emoji:"📋",color:"bg-blue-500/15 text-blue-400 border-blue-500/30"};case"neighbor":return{label:"Neighbor",emoji:"👋",color:"bg-amber-500/15 text-amber-400 border-amber-500/30"};case"browsing":return{label:"Browsing",emoji:"👀",color:"bg-slate-500/15 text-slate-300 border-slate-500/30"};default:return{label:"Visitor",emoji:"🙂",color:"bg-slate-500/15 text-slate-300 border-slate-500/30"}}}function Oae(t){return t.visitor_intent==="buying"&&!t.has_agent}function yot({token:t}={}){var E;const e=Vf(),r=t||e.token,{data:n,isLoading:s,isError:o}=yrt(r);jr();const c=(E=n==null?void 0:n.open_houses)==null?void 0:E.id,{data:a}=mr({queryKey:["cohost-visitors",r,c],queryFn:async()=>{const{data:A,error:C}=await Ce.rpc("get_cohost_visitors",{_token:r});if(C)throw C;return A||[]},enabled:!!r&&!!c,refetchInterval:15e3});if(s)return i.jsx("div",{className:"min-h-screen bg-gradient-to-br from-slate-950 via-slate-900 to-slate-950 flex items-center justify-center",children:i.jsx("div",{className:"animate-pulse text-white/40",children:"Validating access..."})});if(o||!n)return i.jsx("div",{className:"min-h-screen bg-gradient-to-br from-slate-950 via-slate-900 to-slate-950 flex items-center justify-center p-6",children:i.jsxs("div",{className:"text-center text-white",children:[i.jsx("h1",{className:"text-xl font-bold mb-2",children:"Link Expired or Invalid"}),i.jsx("p",{className:"text-white/40 text-sm",children:"This co-host link is no longer active. Ask the host for a new one."})]})});const f=n.open_houses,m=(a==null?void 0:a.length)||0,y=(a==null?void 0:a.filter(A=>A.visitor_intent==="buying").length)||0,_=(a==null?void 0:a.filter(Oae).length)||0,w=A=>{if(!A)return"";const[C,I]=A.split(":"),M=parseInt(C);return`${M>12?M-12:M||12}:${I} ${M>=12?"PM":"AM"}`};return i.jsxs("div",{className:"fixed inset-0 bg-gradient-to-br from-slate-950 via-slate-900 to-slate-950 flex flex-col",children:[i.jsxs("div",{className:"border-b border-white/10 px-4 sm:px-6 py-3 flex items-center justify-between bg-black/30 backdrop-blur-xl",children:[i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("div",{className:"w-2 h-2 rounded-full bg-emerald-400 animate-pulse"}),i.jsx("span",{className:"text-xs font-medium text-emerald-400 uppercase tracking-wider",children:"Live · Co-Host View"})]}),i.jsx("h1",{className:"text-white font-bold text-sm sm:text-base truncate",children:f.property_address})]}),i.jsxs("div",{className:"flex items-center gap-4 sm:gap-6 text-white/70",children:[i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsx(El,{className:"h-4 w-4"}),i.jsx("span",{className:"font-bold text-white",children:m})]}),i.jsxs("div",{className:"flex items-center gap-1.5 text-orange-400",children:[i.jsx(rye,{className:"h-4 w-4"}),i.jsx("span",{className:"font-bold text-white",children:_})]}),i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsx(ea,{className:"h-4 w-4"}),i.jsx("span",{className:"font-bold text-white",children:y})]})]})]}),i.jsxs("div",{className:"px-4 sm:px-6 py-2 flex items-center gap-4 text-xs text-white/40 border-b border-white/5",children:[i.jsx("span",{children:Ls(new Date(f.event_date+"T00:00:00"),"EEEE, MMMM d, yyyy")}),f.start_time&&i.jsxs("span",{children:[w(f.start_time),f.end_time?` – ${w(f.end_time)}`:""]})]}),i.jsx(cp,{className:"flex-1 p-4 sm:p-6",children:a!=null&&a.length?i.jsx("div",{className:"space-y-2 max-w-3xl mx-auto",children:i.jsx(ETe,{children:a.map((A,C)=>{var D;const I=got(A.visitor_intent),M=Oae(A);return i.jsxs(yr.div,{initial:{opacity:0,x:-40,scale:.95},animate:{opacity:1,x:0,scale:1},transition:{duration:.4,delay:C*.05},className:`flex items-center gap-4 p-4 rounded-xl border ${M?"bg-orange-500/10 border-orange-500/30":"bg-white/5 border-white/10"}`,children:[i.jsx("div",{className:`w-11 h-11 rounded-full flex items-center justify-center text-lg font-bold shrink-0 ${M?"bg-gradient-to-br from-orange-500 to-amber-500 text-white":"bg-white/10 text-white/80"}`,children:(D=A.first_name[0])==null?void 0:D.toUpperCase()}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[i.jsxs("span",{className:"font-semibold text-white truncate",children:[A.first_name," ",A.last_name||""]}),M&&i.jsx(pi,{className:"bg-orange-500/20 text-orange-300 border-orange-500/40 text-[10px] px-1.5 py-0",children:"🔥 HOT"}),A.has_agent&&i.jsx(pi,{variant:"outline",className:"text-[10px] px-1.5 py-0 border-yellow-500/40 text-yellow-400",children:"⚠️ Has Agent"})]}),i.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[i.jsxs(pi,{variant:"outline",className:`text-[10px] px-1.5 py-0 ${I.color}`,children:[I.emoji," ",I.label]}),i.jsx("span",{className:"text-white/30 text-xs",children:Ls(new Date(A.created_at),"h:mm a")})]})]})]},A.id)})})}):i.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-center py-20",children:[i.jsx("div",{className:"w-20 h-20 rounded-full bg-white/5 flex items-center justify-center mb-4",children:i.jsx(RD,{className:"h-10 w-10 text-white/20"})}),i.jsx("h2",{className:"text-xl font-bold text-white/60 mb-1",children:"Waiting for visitors..."}),i.jsx("p",{className:"text-white/30 text-sm",children:"New sign-ins will appear here in real-time"})]})})]})}function xot(){const e=js().pathname.slice(1);if(N.useEffect(()=>(document.body.classList.add("guestbook-page"),()=>{document.body.classList.remove("guestbook-page")}),[]),e.startsWith("live/")){const r=e.slice(5);if(r)return i.jsx(yot,{token:r})}if(e.startsWith("rsvp/")){const r=e.slice(5);if(r)return i.jsx(Z1e,{slug:r})}return!e||e===""?i.jsx("div",{className:"min-h-screen bg-gradient-to-br from-slate-900 via-slate-800 to-slate-900 flex items-center justify-center p-6",children:i.jsxs("div",{className:"text-center text-white",children:[i.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Guest Book"}),i.jsx("p",{className:"text-white/60",children:"The modern open house sign-in experience."}),i.jsx("p",{className:"text-white/40 text-sm mt-2",children:"Visit a specific open house link to sign in."})]})}):i.jsx(Y1e,{slug:e})}function _ot(t){const e=t.replace(/[^0-9.]/g,"");if(!/^\d*\.?\d*$/.test(e))return null;const r=Number(e)||0;return Number.isFinite(r)?{text:e,value:r}:null}function vot({value:t,onValueChange:e,onBlur:r,...n}){const[s,o]=N.useState(null);return i.jsx(Dr,{...n,inputMode:"decimal",value:(s==null?void 0:s.value)===t?s.text:t||"",onChange:c=>{const a=_ot(c.target.value);a&&(o(a),e(a.value))},onBlur:c=>{o(null),r==null||r(c)}})}const Fae=[{key:"payoffs",label:"Loan payoff",cls:"bg-primary-foreground/55"},{key:"commission",label:"Commission",cls:"bg-primary-foreground/35"},{key:"titleTotal",label:"Title & closing",cls:"bg-primary-foreground/20"},{key:"concessions",label:"Concessions & credits",cls:"bg-destructive"}];function Bae(t){if(!t)return null;const[e,r,n]=t.split(/[-/T]/).map(Number);return!e||!r||!n?null:new Intl.DateTimeFormat("en-US",{timeZone:"UTC",month:"long",day:"numeric",year:"numeric"}).format(Date.UTC(e,r-1,n))}function $ae({value:t,className:e}){return i.jsx("span",{className:Xt("tabular-nums",e),children:vm(t)})}function bot({data:t,agent:e,interactive:r=!0,compact:n=!1}){var K,Q;const s=r&&t.allow_client_edits!==!1,[o,c]=N.useState(()=>t.scenarios.map(J=>({...J}))),[a,f]=N.useState(()=>({...t.inputs})),[m,y]=N.useState(()=>Math.min(1,Math.max(0,t.scenarios.length-1))),[_,w]=N.useState(!1),E=N.useMemo(()=>o.map(J=>sJe(a,J,t.close_date)),[o,a,t.close_date]),A=E[m]??E[0],C=E[Math.min(1,E.length-1)],I=[t.property_address,[t.city,t.state].filter(Boolean).join(", "),t.zip].filter(Boolean).join(" · "),M=t.mode==="offers",D=E.reduce((J,ee,oe)=>{var de;return ee.net>(((de=E[J])==null?void 0:de.net)??-1/0)?oe:J},0),B=(J,ee)=>c(oe=>oe.map((de,ye)=>ye===J?{...de,...ee}:de)),U=()=>{c(t.scenarios.map(J=>({...J}))),f({...t.inputs})};if(!A)return null;const q=Math.max(A.price,1),H=[{label:"Sale price",get:J=>J.price},{label:`Listing commission (${a.listingCommissionPct}%)`,get:J=>-J.listingCommission,sub:!0},{label:`Buyer agent commission (${a.buyerCommissionPct}%)`,get:J=>-J.buyerCommission,sub:!0,hide:!a.buyerCommissionPct},{label:"Brokerage fee",get:J=>-J.brokerageFee,sub:!0,hide:!a.brokerageFee},{label:"Title & settlement",get:J=>-J.titleTotal,sub:!0},{label:"Mortgage payoff(s)",get:J=>-J.payoffs,sub:!0},{label:a.taxesInArrears?"Prorated property taxes":"Property tax credit",get:J=>-J.taxProration,sub:!0,hide:!a.annualTaxes},{label:"Buyer concessions",get:J=>-J.concessions,sub:!0,hide:E.every(J=>!J.concessions)},{label:"Repair credits",get:J=>-J.repairs,sub:!0,hide:E.every(J=>!J.repairs)},{label:"Other costs",get:J=>-J.otherTotal,sub:!0,hide:!((K=E[0])!=null&&K.otherTotal)}];return i.jsxs("div",{className:Xt("space-y-6",!n&&"mx-auto max-w-5xl"),children:[!n&&i.jsxs("header",{className:"flex flex-col gap-5 rounded-3xl border bg-card p-6 shadow-sm sm:flex-row sm:items-center sm:justify-between",children:[i.jsxs("div",{className:"flex items-center gap-4",children:[e!=null&&e.avatar_url?i.jsx("img",{src:e.avatar_url,alt:e.name??"Agent",className:"h-16 w-16 rounded-2xl object-cover"}):i.jsx("div",{className:"flex h-16 w-16 items-center justify-center rounded-2xl bg-primary text-xl font-semibold text-primary-foreground",children:((e==null?void 0:e.name)??"A").slice(0,1)}),i.jsxs("div",{children:[i.jsx("p",{className:"text-xs font-medium uppercase tracking-[0.18em] text-muted-foreground",children:"Prepared by"}),i.jsx("p",{className:"text-lg font-semibold text-foreground",children:(e==null?void 0:e.name)??"Your agent"}),i.jsx("p",{className:"text-sm text-muted-foreground",children:[e==null?void 0:e.title,e==null?void 0:e.brokerage_name].filter(Boolean).join(" · ")})]})]}),i.jsxs("div",{className:"flex flex-wrap gap-2 print:hidden",children:[(e==null?void 0:e.phone)&&i.jsxs(i.Fragment,{children:[i.jsx(Lt,{asChild:!0,variant:"outline",size:"sm",children:i.jsxs("a",{href:`tel:${e.phone}`,children:[i.jsx(Un,{className:"mr-1.5 h-4 w-4"}),"Call"]})}),i.jsx(Lt,{asChild:!0,variant:"outline",size:"sm",children:i.jsxs("a",{href:`sms:${e.phone}`,children:[i.jsx(Nh,{className:"mr-1.5 h-4 w-4"}),"Text"]})})]}),(e==null?void 0:e.email)&&i.jsx(Lt,{asChild:!0,size:"sm",children:i.jsxs("a",{href:`mailto:${e.email}?subject=${encodeURIComponent(`Question about my net sheet${t.property_address?` — ${t.property_address}`:""}`)}`,children:[i.jsx(rs,{className:"mr-1.5 h-4 w-4"}),"Ask a question"]})})]})]}),i.jsxs("section",{className:"overflow-hidden rounded-3xl bg-primary p-6 text-primary-foreground shadow-lg sm:p-10",children:[i.jsxs("div",{className:"flex flex-col gap-6 lg:flex-row lg:items-end lg:justify-between",children:[i.jsxs("div",{className:"space-y-3",children:[i.jsx("p",{className:"text-xs font-medium uppercase tracking-[0.22em] opacity-75",children:t.title||"Seller net sheet"}),I&&i.jsxs("p",{className:"flex items-center gap-2 text-sm opacity-90",children:[i.jsx(ui,{className:"h-4 w-4"}),I]}),i.jsxs("div",{children:[i.jsxs("p",{className:"text-sm opacity-80",children:["Estimated walk-away · ",(Q=o[m])==null?void 0:Q.label]}),i.jsx("p",{className:"font-serif text-5xl font-semibold tracking-tight tabular-nums sm:text-6xl",children:vm(A.net)})]}),i.jsxs("p",{className:"text-sm opacity-80",children:[Math.round(A.netPct*100),"% of the ",vm(A.price)," sale price",Bae(t.close_date)&&i.jsxs(i.Fragment,{children:[" · ",i.jsx(xo,{className:"inline h-3.5 w-3.5 -mt-0.5"})," closing ",Bae(t.close_date)]})]})]}),t.client_name&&i.jsxs("p",{className:"text-sm opacity-80 lg:text-right",children:["Prepared for",i.jsx("br",{}),i.jsx("span",{className:"text-lg font-semibold opacity-100",children:t.client_name})]})]}),i.jsxs("div",{className:"mt-8",children:[i.jsxs("div",{className:"flex h-4 w-full overflow-hidden rounded-full bg-primary-foreground/15",children:[i.jsx("div",{className:"h-full border-r-2 border-primary bg-primary-foreground transition-all duration-500",style:{width:`${Math.max(0,A.net/q*100)}%`}}),Fae.map(J=>{const ee=J.key==="concessions"?A.concessions+A.repairs:A[J.key];return ee>0?i.jsx("div",{className:Xt("h-full transition-all duration-500",J.cls),style:{width:`${ee/q*100}%`}},J.key):null})]}),i.jsxs("div",{className:"mt-3 flex flex-wrap gap-x-5 gap-y-1 text-xs opacity-85",children:[i.jsxs("span",{className:"flex items-center gap-1.5",children:[i.jsx("i",{className:"h-2.5 w-2.5 rounded-full bg-primary-foreground"}),"Your net ",vm(A.net)]}),Fae.map(J=>{const ee=J.key==="concessions"?A.concessions+A.repairs:A[J.key];return ee>0?i.jsxs("span",{className:"flex items-center gap-1.5",children:[i.jsx("i",{className:Xt("h-2.5 w-2.5 rounded-full",J.cls)}),J.label," ",vm(ee)]},J.key):null})]})]})]}),t.message&&!n&&i.jsx("p",{className:"rounded-2xl border bg-card p-5 text-sm leading-relaxed text-foreground",children:t.message}),i.jsx("section",{className:Xt("grid gap-4",o.length===3?"md:grid-cols-3":o.length===2?"md:grid-cols-2":""),children:o.map((J,ee)=>{var ye,Ee;const oe=E[ee],de=oe.net-C.net;return i.jsxs("div",{role:"button",tabIndex:0,onClick:()=>y(ee),onKeyDown:Le=>Le.key==="Enter"&&y(ee),className:Xt("relative cursor-pointer rounded-3xl border bg-card p-5 text-left transition-all",ee===m?"border-primary ring-2 ring-primary/30 shadow-md":"hover:border-primary/40"),children:[M&&ee===D&&E.length>1&&i.jsx("span",{className:"absolute right-4 top-4 rounded-full bg-primary px-2.5 py-0.5 text-[11px] font-semibold text-primary-foreground",children:"Highest net"}),i.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.16em] text-muted-foreground",children:J.label}),i.jsxs("p",{className:"mt-1 text-sm text-muted-foreground",children:["Sale price ",i.jsx($ae,{value:oe.price,className:"font-medium text-foreground"})]}),i.jsx("p",{className:"mt-3 text-3xl font-semibold tracking-tight text-foreground",children:i.jsx($ae,{value:oe.net})}),i.jsx("p",{className:"text-xs text-muted-foreground",children:"estimated net"}),ee!==Math.min(1,E.length-1)&&E.length>1&&i.jsxs("p",{className:Xt("mt-2 inline-flex items-center gap-1 text-xs font-medium",de>=0?"text-primary":"text-destructive"),children:[i.jsx(Lf,{className:Xt("h-3.5 w-3.5",de<0&&"rotate-180")}),de>=0?"+":"−",vm(Math.abs(de))," vs ",o[Math.min(1,o.length-1)].label.toLowerCase()]}),J.note&&i.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:J.note}),s&&ee===m&&i.jsxs("div",{className:"mt-4 space-y-3 border-t pt-4 print:hidden",onClick:Le=>Le.stopPropagation(),children:[i.jsx("label",{className:"block text-xs font-medium text-muted-foreground",children:"Try a different price"}),i.jsx(Gm,{min:Math.round((((ye=t.scenarios[ee])==null?void 0:ye.price)||oe.price)*.8/1e3)*1e3,max:Math.round((((Ee=t.scenarios[ee])==null?void 0:Ee.price)||oe.price)*1.2/1e3)*1e3||1e5,step:1e3,value:[J.price],onValueChange:([Le])=>B(ee,{price:Le})}),i.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[i.jsxs("div",{children:[i.jsx("span",{className:"text-[11px] text-muted-foreground",children:"Price"}),i.jsx(Dr,{inputMode:"numeric",value:J.price||"",onChange:Le=>B(ee,{price:Number(Le.target.value.replace(/\D/g,""))})})]}),i.jsxs("div",{children:[i.jsx("span",{className:"text-[11px] text-muted-foreground",children:"Buyer credit"}),i.jsx(Dr,{inputMode:"numeric",value:J.concessions||"",placeholder:"0",onChange:Le=>B(ee,{concessions:Number(Le.target.value.replace(/\D/g,""))})})]})]})]})]},J.id)})}),s&&i.jsxs("section",{className:"grid gap-4 rounded-3xl border bg-card p-5 sm:grid-cols-3 print:hidden",children:[i.jsxs("div",{children:[i.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Mortgage payoff"}),i.jsx(Dr,{inputMode:"numeric",value:a.firstPayoff||"",placeholder:"0",onChange:J=>f({...a,firstPayoff:Number(J.target.value.replace(/\D/g,""))})})]}),i.jsxs("div",{children:[i.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Total commission %"}),i.jsx(vot,{"aria-label":"Total commission %",value:a.listingCommissionPct+a.buyerCommissionPct,onValueChange:J=>{const ee=a.listingCommissionPct+a.buyerCommissionPct,oe=t.inputs.listingCommissionPct+t.inputs.buyerCommissionPct,de=ee?a.listingCommissionPct/ee:oe?t.inputs.listingCommissionPct/oe:.5,ye=+(J*de).toFixed(3);f({...a,listingCommissionPct:ye,buyerCommissionPct:+(J-ye).toFixed(3)})}})]}),i.jsxs("div",{className:"flex items-end justify-between gap-3",children:[i.jsx("p",{className:"text-xs text-muted-foreground",children:"Changes here are just for you — they don't change your agent's copy."}),i.jsxs(Lt,{variant:"ghost",size:"sm",onClick:U,children:[i.jsx(I4e,{className:"mr-1.5 h-4 w-4"}),"Reset"]})]})]}),i.jsxs("section",{className:"overflow-hidden rounded-3xl border bg-card",children:[i.jsxs("div",{className:"flex items-center justify-between border-b px-5 py-4",children:[i.jsx("h2",{className:"font-semibold text-foreground",children:"Line-by-line comparison"}),!n&&i.jsxs(Lt,{variant:"outline",size:"sm",className:"print:hidden",onClick:()=>window.print(),children:[i.jsx(N4e,{className:"mr-1.5 h-4 w-4"}),"Print / PDF"]})]}),i.jsx("div",{className:"overflow-x-auto",children:i.jsxs("table",{className:"w-full min-w-[520px] text-sm",children:[i.jsx("thead",{children:i.jsxs("tr",{className:"text-left text-xs uppercase tracking-wider text-muted-foreground",children:[i.jsx("th",{className:"px-5 py-3 font-medium"}),o.map((J,ee)=>i.jsx("th",{className:Xt("px-5 py-3 text-right font-medium",ee===m&&"text-primary"),children:J.label},J.id))]})}),i.jsxs("tbody",{children:[H.filter(J=>!J.hide).map(J=>i.jsxs("tr",{className:"border-t",children:[i.jsx("td",{className:Xt("px-5 py-2.5",J.sub?"text-muted-foreground":"font-medium text-foreground"),children:J.label==="Title & settlement"?i.jsxs("button",{className:"inline-flex items-center gap-1 text-left hover:text-foreground",onClick:()=>w(ee=>!ee),children:[J.label,i.jsx(Go,{className:Xt("h-3.5 w-3.5 transition-transform",_&&"rotate-180")})]}):J.label}),E.map((ee,oe)=>i.jsx("td",{className:Xt("px-5 py-2.5 text-right tabular-nums",J.sub?"text-muted-foreground":"font-medium text-foreground"),children:J.get(ee)<0?`−${vm(-J.get(ee),!0)}`:vm(J.get(ee),!0)},oe))]},J.label)).flatMap(J=>J.key!=="Title & settlement"||!_?[J]:[J,...a.titleFees.map(ee=>i.jsxs("tr",{className:"bg-muted/40 text-xs",children:[i.jsx("td",{className:"px-5 py-1.5 pl-9 text-muted-foreground",children:ee.label}),E.map((oe,de)=>i.jsxs("td",{className:"px-5 py-1.5 text-right tabular-nums text-muted-foreground",children:["−",vm(ee.amount,!0)]},de))]},ee.id))]),i.jsxs("tr",{className:"border-t-2 border-primary/30 bg-primary/5",children:[i.jsx("td",{className:"px-5 py-4 font-semibold text-foreground",children:"Estimated net to you"}),E.map((J,ee)=>i.jsx("td",{className:"px-5 py-4 text-right text-lg font-semibold tabular-nums text-primary",children:vm(J.net,!0)},ee))]})]})]})})]}),i.jsx("p",{className:"px-1 text-xs leading-relaxed text-muted-foreground",children:"These figures are estimates for planning only and are not a guarantee of final proceeds. Actual amounts are set by your title company at closing and may vary with payoff figures, prorations, taxes, and contract terms."})]})}function wot({dealId:t}){const{data:e}=mr({queryKey:["portal-net-sheet",t],queryFn:async()=>{const{data:n,error:s}=await Ce.rpc("get_portal_net_sheet",{_deal_id:t});if(s)throw s;return n??null}}),{data:r}=aJe(e??void 0);return r!=null&&r.sheet?i.jsxs("section",{className:"space-y-3",children:[i.jsx("h2",{className:"text-lg font-semibold",children:"Your net proceeds"}),i.jsx(bot,{data:r.sheet,agent:r.agent,compact:!0}),i.jsx("a",{href:`/net-sheet/${r.sheet.slug}`,target:"_blank",rel:"noreferrer",className:"inline-block text-sm font-medium text-primary underline-offset-4 hover:underline",children:"Open full net sheet & print"})]}):null}function Xx(t){return t==="seller"||t==="listing"}function vO(t){return t==="buyer"||t==="buy-side"}const Sot="/assets/homeowner-garden-C8lI4Nq2.jpg";function Tot(t,e,r,n=30){if(t===null||!(t>0)||!(e>0)||e>100)return null;const s=Math.floor(t/(e/100)/1e3)*1e3,o=s-t,c=r/100/12,a=n*12,f=o<=0?0:c===0?o/a:o*c/(1-Math.pow(1+c,-a));return{price:s,loan:Math.max(0,o),payment:Math.round(f)}}const B6=t=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(t),Eot=["Kitchen remodel","Bathroom update","Added a bathroom","New roof","Finished basement","Deck or patio","New HVAC","Flooring","Windows","Solar panels","Landscaping","Other"];function jot({accessKey:t,agentName:e,onDone:r,preview:n=!1}){const[s,o]=N.useState(!1),[c,a]=N.useState([]),[f,m]=N.useState(""),[y,_]=N.useState(""),[w,E]=N.useState(""),[A,C]=N.useState(!1),[I,M]=N.useState(!1),D=U=>{const q=Number(U.replace(/[^0-9.]/g,""));return U.trim()&&q>0?q:null};async function B(){if(!c.length&&!w.trim()){$t.error("Pick at least one update or add a note");return}if(n){$t.info("Preview only — homeowner actions are turned off");return}C(!0);const{error:U}=await Ce.rpc("homeowner_hub_report_renovation",{_key:t,_items:c,_spend:D(f),_value_guess:D(y),_note:w.trim()||null});if(C(!1),U){$t.error("Could not send your updates. Please try again.");return}M(!0),o(!1),r(),$t.success(`${e} will review your updates`)}return i.jsxs("section",{className:"homeowner-valuation py-8 flex flex-wrap justify-between items-center gap-4",children:[i.jsxs("div",{children:[i.jsx("p",{className:"homeowner-kicker",children:"TUNE MY VALUE"}),i.jsx("h2",{className:"portal-serif text-2xl mt-2",children:"Made updates to your home?"}),i.jsxs("p",{className:"homeowner-muted text-sm mt-2",children:["Tell ",e," what you’ve improved so your value reflects it. Nothing changes until they review it."]})]}),i.jsxs(Lt,{variant:"outline",className:"homeowner-control",disabled:I,onClick:()=>o(!0),children:[I?i.jsx(pa,{className:"h-4 w-4 mr-2"}):i.jsx(h4e,{className:"h-4 w-4 mr-2"}),I?"Updates sent":"Report home updates"]}),i.jsx(Ha,{open:s,onOpenChange:o,children:i.jsxs(Ra,{className:"max-h-[90dvh] overflow-y-auto",children:[i.jsxs(Ho,{children:[i.jsx(Co,{children:"What have you updated?"}),i.jsxs(td,{children:["Only ",e," sees this."]})]}),i.jsx("div",{className:"grid grid-cols-2 gap-2",children:Eot.map(U=>i.jsxs("label",{className:"flex items-center gap-2 text-sm rounded-md border p-2 cursor-pointer",children:[i.jsx(aE,{checked:c.includes(U),onCheckedChange:q=>a(H=>q?[...H,U]:H.filter(K=>K!==U))}),U]},U))}),i.jsxs("div",{className:"grid sm:grid-cols-2 gap-3",children:[i.jsxs("div",{children:[i.jsx(Fr,{htmlFor:"tmv-spend",children:"About how much you spent ($)"}),i.jsx(Dr,{id:"tmv-spend",inputMode:"numeric",placeholder:"e.g. 40,000",value:f,onChange:U=>m(U.target.value)})]}),i.jsxs("div",{children:[i.jsx(Fr,{htmlFor:"tmv-guess",children:"What you think it’s worth ($)"}),i.jsx(Dr,{id:"tmv-guess",inputMode:"numeric",placeholder:"e.g. 520,000",value:y,onChange:U=>_(U.target.value)})]})]}),i.jsxs("div",{children:[i.jsx(Fr,{htmlFor:"tmv-note",children:"Anything else?"}),i.jsx(zc,{id:"tmv-note",maxLength:1e3,value:w,onChange:U=>E(U.target.value),placeholder:"e.g. Quartz counters, new appliances in 2025"})]}),i.jsx(Lt,{className:"homeowner-primary w-full",disabled:A,onClick:B,children:A?"Sending…":`Send to ${e}`})]})})]})}function kot({equity:t,searchUrl:e}){const[r,n]=N.useState(20),[s,o]=N.useState(6.5),c=Tot(t,r,s);if(!c)return null;const a=e?`${e}${e.includes("?")?"&":"?"}maxPrice=${c.price}`:null;return i.jsxs("section",{className:"homeowner-financial-section py-8","aria-label":"Equity trade-up",children:[i.jsxs("p",{className:"homeowner-kicker flex items-center gap-2",children:[i.jsx(yH,{className:"h-4 w-4"})," YOUR NEXT MOVE"]}),i.jsx("h2",{className:"portal-serif text-2xl mt-2",children:"See what your equity could buy"}),i.jsxs("p",{className:"homeowner-muted text-sm mt-2",children:["Using ",B6(t)," of equity as a ",r,"% down payment."]}),i.jsxs("div",{className:"grid md:grid-cols-2 gap-8 mt-5",children:[i.jsxs("div",{className:"space-y-5",children:[i.jsxs("div",{children:[i.jsxs(Fr,{className:"block mb-3",children:["Down payment: ",r,"%"]}),i.jsx(Gm,{"aria-label":"Down payment percent",min:5,max:50,step:1,value:[r],onValueChange:f=>n(f[0])})]}),i.jsxs("div",{children:[i.jsxs(Fr,{className:"block mb-3",children:["Interest rate: ",s.toFixed(2),"%"]}),i.jsx(Gm,{"aria-label":"Interest rate",min:3,max:9,step:.125,value:[s],onValueChange:f=>o(f[0])})]})]}),i.jsxs("div",{children:[i.jsx("p",{className:"homeowner-muted text-sm",children:"Home price up to"}),i.jsx("p",{className:"portal-serif text-4xl tabular-nums",children:B6(c.price)}),i.jsxs("p",{className:"homeowner-muted text-sm mt-2",children:["About ",B6(c.payment),"/mo principal & interest on a 30-year loan. Excludes taxes, insurance and closing costs; not a loan approval."]}),a&&i.jsx(Lt,{asChild:!0,className:"homeowner-primary mt-4",children:i.jsxs("a",{href:a,target:"_blank",rel:"noopener noreferrer",children:[i.jsx(Qu,{className:"h-4 w-4 mr-2"}),"Browse homes in this range"]})})]})]})]})}function $6({balance:t,rate:e,months:r},n=0){if(t===null||e===null||r===null||t<0||e<0||e>30||r<1||r>600||![t,e,r,n].every(Number.isFinite))return null;const s=e/1200,o=s===0?t/r:t*s/(1-(1+s)**-r),c=Math.min(r,Math.max(0,Math.floor(n))),a=Math.max(0,s===0?t-o*c:t*(1+s)**c-o*((1+s)**c-1)/s);return{payment:o,remaining:a,principalPaid:t-a}}function SL(t,e=new Date){var o,c;if(!t)return 0;const[r,n]=t.split(/[-/T]/).map(Number),s=new Intl.DateTimeFormat("en-US",{timeZone:"America/New_York",year:"numeric",month:"numeric"}).formatToParts(e);return Math.max(0,(Number((o=s.find(a=>a.type==="year"))==null?void 0:o.value)-r)*12+Number((c=s.find(a=>a.type==="month"))==null?void 0:c.value)-n)}function Aot(t,e){return t!==null&&e!==null&&Number.isFinite(t)&&Number.isFinite(e)&&t>0&&e>=0?t-e:null}function Not(t){return(t==null?void 0:t.is_won_stage)===!0&&t.is_lost_stage!==!0}function Cot(t,e,r,n){if(t===null||e===null||r===null||!(t>0)||e<0||e>30||r<1||r>600||!(n>=0)||![t,e,r,n].every(Number.isFinite))return null;const s=e/1200,o=s===0?t/r:t*s/(1-(1+s)**-r),c=o*r-t;let a=t,f=0,m=0;for(;a>.005&&f<600;){const y=a*s;m+=y,a=a+y-(o+n),f++}return{payment:o,payoffMonths:f,monthsSaved:Math.max(0,r-f),interestSaved:Math.max(0,c-m)}}const fm=t=>t===null?"—":new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(t);function Iot({accessKey:t,standalone:e=!1,preview:r=!1}){var Se,be,me,ke,Pe,je,xe,Ue,Ze,lt,wt,yt;const n=jr(),[s,o]=N.useState(!1),[c,a]=N.useState(!1),[f,m]=N.useState(!1),[y,_]=N.useState(7),[w,E]=N.useState(150),[A,C]=N.useState({}),{data:I,isLoading:M,error:D}=mr({queryKey:["homeowner-hub-public",t],queryFn:async()=>{const{data:gt,error:ft}=await Ce.rpc("homeowner_hub_read",{_key:t});if(ft)throw ft;return gt}});N.useEffect(()=>{I!=null&&I.hub.id&&!r&&Ce.rpc("homeowner_hub_visit",{_key:t})},[t,I==null?void 0:I.hub.id,r]),N.useEffect(()=>{if(e)return document.body.classList.add("client-portal-page","homeowner-hub-page"),()=>document.body.classList.remove("client-portal-page","homeowner-hub-page")},[e]);const B=I==null?void 0:I.hub;function U(){B&&(C(Object.fromEntries(["address","city","state","zip_code","home_value","mortgage_balance","interest_rate","remaining_months"].map(gt=>[gt,String(B[gt]??"")]))),o(!0))}async function q(){if(r){$t.info("Preview only — homeowner actions are turned off");return}a(!0);try{const{error:gt}=await Ce.rpc("homeowner_hub_save",{_key:t,_details:A});if(gt)throw gt;await n.invalidateQueries({queryKey:["homeowner-hub-public",t]}),o(!1),$t.success("Your home details are saved")}catch{$t.error("Could not save. Check the amounts and try again.")}finally{a(!1)}}async function H(){if(r){$t.info("Preview only — homeowner actions are turned off");return}m(!0);try{const{error:gt}=await Ce.rpc("homeowner_hub_request",{_key:t});if(gt)throw gt;await n.invalidateQueries({queryKey:["homeowner-hub-public",t]}),$t.success("Your agent has received your valuation request")}catch{$t.error("Your request could not be sent. Please try again.")}finally{m(!1)}}if(M)return e?i.jsx("div",{className:"homeowner-page flex min-h-screen items-center justify-center",children:i.jsx(Fc,{className:"animate-spin"})}):null;if(!B||!I||D)return e?i.jsx("div",{className:"homeowner-page min-h-screen flex items-center justify-center p-6",children:i.jsxs("div",{children:[i.jsx("h1",{className:"portal-serif text-4xl",children:"Homeowner Hub unavailable"}),i.jsx("p",{className:"mt-3",children:"Please ask your agent for your personal link."})]})}):null;const K=$6({balance:B.mortgage_balance,rate:B.balance_source==="property_intel"?null:B.interest_rate,months:B.remaining_months},SL(B.balance_updated_at)),Q=(K==null?void 0:K.remaining)??B.mortgage_balance,J=Aot(B.home_value,Q),ee=$6({balance:B.mortgage_balance,rate:B.balance_source==="property_intel"?null:B.interest_rate,months:B.remaining_months},SL(B.balance_updated_at)+12),oe=J===null||B.home_value===null?null:J-B.home_value*y/100,de=B.remaining_months===null?null:Math.max(1,B.remaining_months-SL(B.balance_updated_at)),ye=Cot(Q??null,B.balance_source==="property_intel"?null:B.interest_rate,de,w),Ee=B.valuation_requested_at&&Date.now()-Date.parse(B.valuation_requested_at)<864e5,Le=i.jsxs("section",{className:"homeowner-hub min-w-0","aria-label":"Homeowner Hub",children:[r&&i.jsx("div",{role:"status",className:"sticky top-0 z-50 mb-4 rounded-md border border-primary bg-primary px-4 py-2 text-center text-sm font-medium text-primary-foreground",children:"Preview — the homeowner can't see this banner. Your visit isn't counted and buttons won't send anything."}),i.jsxs("header",{className:"homeowner-heading",children:[i.jsx("img",{src:Sot,alt:"",width:1536,height:768,className:"homeowner-garden",fetchPriority:"high"}),i.jsxs("div",{className:"homeowner-heading-inner",children:[i.jsxs("div",{className:"homeowner-hero-top",children:[i.jsxs("p",{className:"homeowner-kicker flex items-center gap-2",children:[i.jsx(o4,{className:"h-4 w-4"})," PRIVATE HOMEOWNER HUB"]}),i.jsxs(Lt,{variant:"outline",className:"homeowner-hero-control",onClick:U,children:[i.jsx(aye,{className:"h-4 w-4 mr-2"}),"My home details"]})]}),i.jsxs("div",{className:"homeowner-hero-title",children:[i.jsx("p",{className:"homeowner-kicker",children:B.client_name?`AT HOME WITH ${B.client_name.split(" ")[0].toUpperCase()}`:"YOUR HOME · YOUR NEXT CHAPTER"}),i.jsx("h1",{className:"portal-serif mt-3",children:"Homeowner Hub"}),i.jsx("p",{className:"homeowner-hero-subtitle mt-3",children:"A little clarity for your biggest investment."}),i.jsxs("p",{className:"homeowner-address mt-5 flex items-start gap-2",children:[i.jsx(ui,{className:"h-4 w-4 shrink-0 mt-1"}),[B.address,B.city,B.state].filter(Boolean).join(", ")||"Let’s add your home address"]})]})]})]}),i.jsxs("div",{className:"homeowner-content",children:[B.mls_facts&&(()=>{const gt=B.mls_facts,ft=[[gt.beds,"Beds"],[gt.baths,"Baths"],[gt.sqft&&Number(gt.sqft).toLocaleString("en-US"),"Sq ft"],[gt.yearBuilt,"Built"]].filter(([kt])=>kt);return i.jsxs("section",{className:"homeowner-facts flex flex-wrap items-center gap-6 pt-8","aria-label":"Home facts",children:[gt.photo&&i.jsx("img",{src:gt.photo,alt:"Your home",className:"w-28 h-20 rounded-lg object-cover",loading:"lazy"}),i.jsxs("dl",{className:"flex flex-wrap gap-6",children:[ft.map(([kt,Vt])=>i.jsxs("div",{children:[i.jsx("dt",{className:"homeowner-muted text-xs uppercase tracking-wide",children:Vt}),i.jsx("dd",{className:"portal-serif text-2xl",children:kt})]},Vt)),gt.lastSalePrice&&i.jsxs("div",{children:[i.jsxs("dt",{className:"homeowner-muted text-xs uppercase tracking-wide",children:["Last sold",gt.lastSaleDate?` · ${gt.lastSaleDate.split(/[-/T]/)[0]}`:""]}),i.jsx("dd",{className:"portal-serif text-2xl",children:fm(gt.lastSalePrice)})]})]})]})})(),i.jsxs("div",{className:"homeowner-equity grid gap-8 md:grid-cols-[1.2fr_1fr] py-10",children:[i.jsxs("div",{className:"min-w-0",children:[i.jsxs("p",{className:"homeowner-kicker flex items-center gap-2",children:[i.jsx(Lf,{className:"h-4 w-4"})," YOUR HOME, IN NUMBERS"]}),i.jsx("h2",{className:"portal-serif text-2xl mt-3",children:"Estimated home equity"}),i.jsx("p",{className:"portal-serif homeowner-equity-value mt-2 tabular-nums break-words",children:fm(J)}),i.jsx("p",{className:"homeowner-muted text-sm mt-3 max-w-sm",children:J===null?"Add a home value and mortgage balance to see your estimate.":"Home value minus estimated remaining mortgage. Not a cash offer."})]}),i.jsxs("div",{className:"homeowner-equity-breakdown flex items-center gap-6",children:[i.jsxs("svg",{viewBox:"0 0 120 120",className:"homeowner-equity-ring shrink-0",role:"img","aria-label":"Estimated equity as a share of your home value",children:[i.jsx("circle",{cx:"60",cy:"60",r:"50",className:"homeowner-ring-track"}),J!==null&&B.home_value!==null&&i.jsx("circle",{cx:"60",cy:"60",r:"50",className:"homeowner-ring-value",strokeDasharray:`${Math.min(1,Math.max(0,J/B.home_value))*314.16} 314.16`,transform:"rotate(-90 60 60)"}),i.jsx(ea,{x:"46",y:"46",width:"28",height:"28",className:"homeowner-ring-home"})]}),i.jsxs("dl",{className:"grid gap-5 min-w-0",children:[i.jsxs("div",{children:[i.jsxs("dt",{className:"homeowner-muted text-sm flex items-center gap-2",children:[i.jsx("span",{className:"homeowner-legend homeowner-legend-equity"}),"Home value estimate"]}),i.jsx("dd",{className:"text-2xl tabular-nums mt-1",children:fm(B.home_value)}),i.jsx("p",{className:"homeowner-muted text-xs mt-1",children:B.home_value===null?"Not provided":B.value_source==="property_intel"?"Property-provider estimate":B.value_source==="agent_entered"?((Se=B.mls_facts)==null?void 0:Se.lastSalePrice)===B.home_value?"Last MLS sale price":"Agent-entered estimate":"Homeowner-entered estimate"})]}),i.jsxs("div",{children:[i.jsxs("dt",{className:"homeowner-muted text-sm flex items-center gap-2",children:[i.jsx("span",{className:"homeowner-legend homeowner-legend-mortgage"}),"Mortgage balance"]}),i.jsx("dd",{className:"text-2xl tabular-nums mt-1",children:fm(Q)}),i.jsx("p",{className:"homeowner-muted text-xs mt-1",children:B.balance_source==="property_intel"?"Property-provider estimate · not a payoff balance":K?"Projected from your loan details":Q===null?"Not provided":"Last balance provided"})]})]})]})]}),B.property_intel_at&&i.jsxs("section",{className:"py-5 border-y space-y-3","aria-label":"Saved property details",children:[i.jsxs("p",{className:"homeowner-muted text-xs",children:["Saved property estimates · ",new Intl.DateTimeFormat("en-US",{timeZone:"America/New_York",month:"short",day:"numeric",year:"numeric"}).format(Date.parse(B.property_intel_at))]}),i.jsxs("dl",{className:"flex flex-wrap gap-6",children:[((be=B.property_intel)==null?void 0:be.lender_name)&&i.jsxs("div",{children:[i.jsx("dt",{className:"homeowner-muted text-xs",children:"Recorded lender"}),i.jsx("dd",{className:"text-sm",children:B.property_intel.lender_name})]}),((me=B.property_intel)==null?void 0:me.years_owned)!=null&&i.jsxs("div",{children:[i.jsx("dt",{className:"homeowner-muted text-xs",children:"Recorded years owned"}),i.jsx("dd",{children:B.property_intel.years_owned})]}),((ke=B.property_intel)==null?void 0:ke.last_sale_price)!=null&&i.jsxs("div",{children:[i.jsx("dt",{className:"homeowner-muted text-xs",children:"Last recorded sale"}),i.jsx("dd",{children:fm(B.property_intel.last_sale_price)})]})]})]}),i.jsxs("div",{className:"homeowner-financials grid md:grid-cols-2 gap-8 py-8",children:[i.jsxs("section",{className:"homeowner-financial-section min-w-0",children:[i.jsxs("h2",{className:"portal-serif text-2xl flex items-center gap-2",children:[i.jsx(Lf,{className:"h-5 w-5"}),"Mortgage momentum"]}),i.jsx("p",{className:"homeowner-muted text-sm mt-2",children:"Principal & interest only; excludes taxes, insurance and extra payments."}),i.jsxs("dl",{className:"grid grid-cols-2 gap-4 mt-5",children:[i.jsxs("div",{children:[i.jsx("dt",{className:"homeowner-muted text-sm",children:"Monthly payment estimate"}),i.jsx("dd",{className:"text-2xl mt-1",children:fm((K==null?void 0:K.payment)??null)})]}),i.jsxs("div",{children:[i.jsx("dt",{className:"homeowner-muted text-sm",children:"Next 12 months’ paydown"}),i.jsx("dd",{className:"text-2xl mt-1",children:fm(ee&&Q!==null?Q-ee.remaining:null)})]})]}),K&&Q!==null&&ee&&i.jsx("svg",{viewBox:"0 0 240 48",className:"w-full h-12 mt-5 homeowner-chart",role:"img","aria-label":"Projected cumulative mortgage principal paid over the next twelve months",children:Array.from({length:12},(gt,ft)=>{const kt=$6({balance:B.mortgage_balance,rate:B.balance_source==="property_intel"?null:B.interest_rate,months:B.remaining_months},SL(B.balance_updated_at)+ft+1),Vt=ee.remaining_(gt[0]??7),className:"homeowner-slider"})]})]}),ye&&i.jsxs("section",{className:"homeowner-financial-section py-8 min-w-0","aria-label":"Pay off sooner",children:[i.jsxs("h2",{className:"portal-serif text-2xl flex items-center gap-2",children:[i.jsx(Lf,{className:"h-5 w-5"}),"What if you paid a little extra?"]}),i.jsxs("p",{className:"homeowner-muted text-sm mt-2",children:["Add ",fm(w)," a month to principal and see what changes."]}),i.jsx(Gm,{className:"mt-5 max-w-md",min:0,max:1e3,step:25,value:[w],onValueChange:gt=>E(gt[0]),"aria-label":"Extra monthly payment"}),i.jsxs("dl",{className:"grid grid-cols-2 gap-4 mt-5 max-w-md",children:[i.jsxs("div",{children:[i.jsx("dt",{className:"homeowner-muted text-sm",children:"Paid off sooner by"}),i.jsxs("dd",{className:"text-2xl tabular-nums",children:[Math.floor(ye.monthsSaved/12)," yr ",ye.monthsSaved%12," mo"]})]}),i.jsxs("div",{children:[i.jsx("dt",{className:"homeowner-muted text-sm",children:"Interest you keep"}),i.jsx("dd",{className:"text-2xl tabular-nums",children:fm(Math.round(ye.interestSaved))})]})]}),i.jsx("p",{className:"homeowner-muted text-xs mt-2",children:"Estimate only; principal & interest, based on the details on file."})]}),i.jsxs("section",{className:"homeowner-valuation py-8 flex flex-wrap justify-between items-center gap-4",children:[i.jsxs("div",{children:[i.jsx("p",{className:"homeowner-kicker",children:"A REAL PERSON. A MORE PERSONAL VALUE."}),i.jsx("h2",{className:"portal-serif text-2xl mt-2",children:"What is your home worth today?"}),i.jsxs("p",{className:"homeowner-muted text-sm mt-2",children:["Ask ",((Pe=I.agent)==null?void 0:Pe.name)||"your agent"," for a fresh, local valuation."]})]}),i.jsxs(Lt,{className:"homeowner-primary",disabled:f||!!Ee,onClick:H,children:[Ee?i.jsx(pa,{className:"h-4 w-4 mr-2"}):i.jsx(Qu,{className:"h-4 w-4 mr-2"}),Ee?"Valuation requested":f?"Sending…":"Request my home value"]})]}),i.jsx(jot,{preview:r,accessKey:t,agentName:((je=I.agent)==null?void 0:je.name)||"your agent",onDone:()=>n.invalidateQueries({queryKey:["homeowner-hub-public",t]})}),i.jsx(kot,{equity:oe??J,searchUrl:(xe=I.site)!=null&&xe.has_idx?`${I.site.url}/search?statuses=Active`:null}),((Ue=I.site)==null?void 0:Ue.has_idx)&&i.jsxs("section",{className:"homeowner-neighborhood py-10",children:[i.jsx("p",{className:"homeowner-kicker",children:"NEIGHBORHOOD RADAR"}),i.jsx("h2",{className:"portal-serif text-2xl mt-2",children:"See what’s moving around you"}),i.jsx("p",{className:"homeowner-muted text-sm mt-2",children:"Explore your agent’s MLS listings. Asking prices are not sold comparable values."}),i.jsx("div",{className:"flex flex-wrap gap-3 mt-4",children:[["Active","Explore nearby homes"],["Pending","Under contract nearby"],["Sold","Recent sales"]].map(([gt,ft])=>{var kt;return i.jsx(Lt,{asChild:!0,variant:"outline",className:"homeowner-control homeowner-neighborhood-link",children:i.jsxs("a",{href:`${(kt=I.site)==null?void 0:kt.url}/search?q=${encodeURIComponent(B.zip_code||[B.city,B.state].filter(Boolean).join(", "))}&statuses=${gt}`,target:"_blank",rel:"noopener noreferrer",children:[ft,i.jsx(Qu,{className:"h-4 w-4 ml-2"})]})},gt)})}),i.jsx("p",{className:"homeowner-muted text-xs mt-3",children:"Availability of pending and sold listings depends on your agent’s MLS permissions."})]}),i.jsxs("footer",{className:"homeowner-advisor flex flex-wrap items-center justify-between gap-4 py-7",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[((Ze=I.agent)==null?void 0:Ze.avatar_url)&&i.jsx("img",{src:I.agent.avatar_url,alt:I.agent.name,className:"w-16 h-16 rounded-full object-cover"}),i.jsxs("div",{children:[i.jsx("p",{className:"homeowner-muted text-xs",children:"Your real estate advisor"}),i.jsx("p",{className:"font-medium",children:(lt=I.agent)==null?void 0:lt.name})]})]}),i.jsxs("div",{className:"flex gap-2",children:[((wt=I.agent)==null?void 0:wt.phone)&&i.jsx(Lt,{asChild:!0,variant:"outline",size:"icon",className:"homeowner-control",children:i.jsx("a",{href:`tel:${I.agent.phone}`,"aria-label":"Call your agent",children:i.jsx(Un,{className:"h-4 w-4"})})}),((yt=I.agent)==null?void 0:yt.email)&&i.jsx(Lt,{asChild:!0,variant:"outline",size:"icon",className:"homeowner-control",children:i.jsx("a",{href:`mailto:${I.agent.email}`,"aria-label":"Email your agent",children:i.jsx(rs,{className:"h-4 w-4"})})})]})]}),i.jsxs("p",{className:"homeowner-muted text-xs leading-relaxed mt-6",children:["Estimates use details you or your agent provide, including saved property-provider estimates when labeled. No automatic appraisal, verified ownership, live mortgage balance or guaranteed appreciation is implied. ",B.value_updated_at&&`Value last entered ${new Intl.DateTimeFormat("en-US",{timeZone:"America/New_York",month:"short",day:"numeric",year:"numeric"}).format(Date.parse(B.value_updated_at))}.`]})]}),i.jsx(Ha,{open:s,onOpenChange:o,children:i.jsxs(Ra,{className:"max-h-[90dvh] overflow-y-auto",children:[i.jsx(Ho,{children:i.jsx(Co,{children:"My home details"})}),i.jsxs("form",{onSubmit:gt=>{gt.preventDefault(),q()},className:"space-y-4",children:[i.jsx("p",{className:"text-sm text-muted-foreground",children:"Leave unknown amounts blank. Only include this home’s mortgage; additional liens are not included."}),i.jsx("div",{className:"grid sm:grid-cols-2 gap-3",children:[["address","Street address"],["city","City"],["state","State"],["zip_code","ZIP code"],["home_value","Estimated home value ($)"],["mortgage_balance","Current mortgage balance ($)"],["interest_rate","Interest rate (%)"],["remaining_months","Months remaining"]].map(([gt,ft])=>i.jsxs("div",{children:[i.jsx(Fr,{htmlFor:`hub-${gt}`,children:ft}),i.jsx(Dr,{id:`hub-${gt}`,value:A[gt]??"",type:["home_value","mortgage_balance","interest_rate","remaining_months"].includes(gt)?"number":"text",min:gt==="home_value"||gt==="remaining_months"?1:0,max:gt==="interest_rate"?30:gt==="remaining_months"?600:1e9,step:gt==="remaining_months"?1:"any",maxLength:gt==="address"?250:100,onChange:kt=>C(Vt=>({...Vt,[gt]:kt.target.value}))})]},gt))}),i.jsx(Lt,{type:"submit",disabled:c,className:"w-full",children:c?"Saving…":"Save home details"})]})]})})]});return e?i.jsx("div",{className:"homeowner-page min-h-screen",children:i.jsx("div",{className:"homeowner-shell",children:Le})}):Le}function Pot({portal:t,children:e}){var c;const r=Not((c=t==null?void 0:t.deal_pipeline)==null?void 0:c.deal_pipeline_stages),[n,s]=N.useState("transaction"),{data:o}=mr({queryKey:["portal-homeowner-enabled",t==null?void 0:t.slug],queryFn:async()=>{const{data:a,error:f}=await Ce.rpc("homeowner_hub_read",{_key:t.slug});return f?null:a},enabled:r&&!!(t!=null&&t.slug)});return!r||!o?i.jsx(i.Fragment,{children:e}):i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"homeowner-portal-tabs max-w-5xl mx-auto px-4 py-5",children:i.jsx(nF,{value:n,onValueChange:s,children:i.jsxs(UC,{className:"homeowner-control",children:[i.jsx(Mf,{value:"transaction",children:"Your transaction"}),i.jsx(Mf,{value:"homeowner",children:"Homeowner Hub"})]})})}),n==="homeowner"?i.jsx("div",{className:"max-w-5xl mx-auto px-5 pb-10",children:i.jsx(Iot,{accessKey:t.slug},t.slug)}):e]})}function Rot({dealData:t,agentProfile:e,welcomeMessage:r,isWon:n,branding:s}){var m;const o=t!=null&&t.property_address?`${t.property_address}, ${t.city||""}, ${t.state||""}`.replace(/,\s*,/g,",").replace(/,\s*$/,""):null,c=(s==null?void 0:s.logo_url)||null,a=(s==null?void 0:s.cover_photo_url)||null,f=(s==null?void 0:s.tagline)||"Your Real Estate Concierge";return i.jsxs("div",{className:"relative overflow-hidden",children:[i.jsxs("div",{className:"relative px-4 pt-10 pb-20",children:[a&&i.jsx("div",{className:"absolute inset-0",style:{backgroundImage:`url(${a})`,backgroundSize:"cover",backgroundPosition:"center",filter:"var(--portal-hero-filter-mobile)"}}),i.jsx("div",{className:"absolute inset-0",style:{background:a?"var(--portal-hero-scrim-mobile)":"radial-gradient(ellipse 100% 70% at 50% 0%, hsl(var(--portal-gold) / 0.12), transparent 60%), linear-gradient(180deg, hsl(0 0% 7%), hsl(0 0% 4%))"}}),i.jsx("div",{className:"absolute inset-0 opacity-[0.05]",style:{backgroundImage:"radial-gradient(circle at 25% 25%, hsl(var(--portal-gold)) 1px, transparent 1px)",backgroundSize:"32px 32px"}}),i.jsxs("div",{className:"relative text-center max-w-lg mx-auto",children:[c&&i.jsx(yr.div,{initial:{opacity:0,y:-8},animate:{opacity:1,y:0},transition:{duration:.5},className:"mb-6 flex justify-center",children:i.jsx("div",{className:"rounded-xl px-4 py-2.5",style:{background:"hsl(0 0% 100% / 0.06)",backdropFilter:"blur(8px)",border:"1px solid hsl(var(--portal-gold) / 0.2)"},children:i.jsx("img",{src:c,alt:"Brand",className:"h-9 max-w-[160px] object-contain"})})}),e&&i.jsxs(yr.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.5,delay:.05},className:"mb-6",children:[e.avatar_url?i.jsx("div",{className:"w-20 h-20 mx-auto mb-3 relative",children:i.jsx("div",{className:"absolute inset-0 rounded-full",style:{background:"var(--portal-gradient-gold)",padding:"2px"},children:i.jsx("img",{src:e.avatar_url,alt:e.name,className:"w-full h-full rounded-full object-cover",style:{background:"hsl(var(--portal-surface))"}})})}):i.jsx("div",{className:"w-20 h-20 mx-auto mb-3 rounded-full flex items-center justify-center portal-serif text-3xl",style:{background:"hsl(var(--portal-surface-2))",border:"1px solid hsl(var(--portal-gold) / 0.3)",color:"var(--portal-hero-accent)"},children:((m=e.name)==null?void 0:m.charAt(0))||"?"}),i.jsx("p",{className:"portal-serif text-lg",style:{color:"var(--portal-hero-ink)"},children:e.name}),i.jsx("p",{className:"text-[10px] mt-1 tracking-[0.22em] uppercase",style:{color:"var(--portal-hero-ink-dim)"},children:f})]}),i.jsxs(yr.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.6,delay:.1},children:[i.jsxs("div",{className:"inline-flex items-center gap-1.5 rounded-full px-3 py-1 text-[10px] tracking-[0.2em] uppercase mb-4",style:{background:"hsl(var(--portal-gold) / 0.08)",border:"1px solid hsl(var(--portal-gold) / 0.25)",color:"var(--portal-hero-accent)"},children:[i.jsx(ea,{className:"w-3 h-3"}),Xx(t==null?void 0:t.deal_type)?"Sale":vO(t==null?void 0:t.deal_type)?"Purchase":"Transaction",n&&i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"opacity-50",children:"·"}),"Complete"]})]}),i.jsx("h1",{className:"portal-serif text-[2.5rem] leading-[1.05] mb-3",style:{color:"var(--portal-hero-ink)"},children:(t==null?void 0:t.deal_name)||"Your Transaction"}),i.jsx("div",{className:"portal-hairline w-24 mx-auto mb-4"}),o&&i.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-sm",style:{color:"var(--portal-hero-ink-muted)"},children:[i.jsx(ui,{className:"w-3.5 h-3.5",style:{color:"var(--portal-hero-accent)"}}),i.jsx("span",{children:o})]}),r&&i.jsxs("p",{className:"mt-6 text-sm leading-relaxed max-w-md mx-auto italic portal-serif",style:{color:"var(--portal-hero-ink-muted)",fontSize:"1.05rem"},children:["“",r,"”"]})]})]})]}),e&&i.jsx("div",{className:"max-w-lg mx-auto px-4 -mt-10 relative z-10",children:i.jsx("div",{className:"rounded-2xl p-3",style:{background:"hsl(var(--portal-surface))",border:"1px solid hsl(var(--portal-gold) / 0.2)",boxShadow:"var(--portal-shadow-tile)"},children:i.jsxs("div",{className:"flex items-center justify-center gap-2",children:[e.phone&&i.jsxs("a",{href:`tel:${e.phone}`,className:"flex-1 flex items-center justify-center gap-2 px-3 py-2.5 rounded-xl transition-colors",style:{background:"hsl(var(--portal-gold) / 0.06)",color:"var(--portal-hero-accent)",border:"1px solid hsl(var(--portal-gold) / 0.15)"},children:[i.jsx(Un,{className:"w-4 h-4"}),i.jsx("span",{className:"text-sm font-medium",children:"Call"})]}),e.email&&i.jsxs("a",{href:`mailto:${e.email}`,className:"flex-1 flex items-center justify-center gap-2 px-3 py-2.5 rounded-xl transition-colors",style:{background:"hsl(var(--portal-gold) / 0.06)",color:"var(--portal-hero-accent)",border:"1px solid hsl(var(--portal-gold) / 0.15)"},children:[i.jsx(rs,{className:"w-4 h-4"}),i.jsx("span",{className:"text-sm font-medium",children:"Email"})]}),e.phone&&i.jsxs("a",{href:`sms:${e.phone}`,className:"flex-1 flex items-center justify-center gap-2 px-3 py-2.5 rounded-xl transition-colors",style:{background:"hsl(var(--portal-gold) / 0.06)",color:"var(--portal-hero-accent)",border:"1px solid hsl(var(--portal-gold) / 0.15)"},children:[i.jsx(Fv,{className:"w-4 h-4"}),i.jsx("span",{className:"text-sm font-medium",children:"Text"})]})]})})})]})}function FTe({targetCloseDate:t,actualCloseDate:e,clientName:r,dealType:n}){if(e||!t)return null;const s=t.split(/[-/T]/),o=new Date(Number(s[0]),Number(s[1])-1,Number(s[2])),a=HYe(o,new Date);if(nT(o)&&!Th(o))return null;const f=Th(o),m=f?"0":String(Math.max(0,a)),y=Math.max(4,Math.min(100,(60-Math.min(60,a))/60*100));return i.jsxs("div",{className:"portal-tile p-8 text-center",children:[i.jsx("p",{className:"portal-eyebrow mb-4",children:f?"The Moment Has Arrived":"Countdown to Closing"}),f?i.jsxs(i.Fragment,{children:[i.jsx("h3",{className:"portal-serif text-5xl mb-2",style:{color:"hsl(var(--portal-gold))"},children:"Closing Day"}),i.jsxs("p",{className:"text-sm mt-3",style:{color:"hsl(var(--portal-ink-muted))"},children:["Congratulations",r?`, ${r.split(" ")[0]}`:"","."]})]}):i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"flex items-baseline justify-center gap-3",children:[i.jsx(yr.span,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.6},className:"portal-serif tabular-nums leading-none",style:{fontSize:"5.5rem",color:"hsl(var(--portal-gold))",textShadow:"0 0 40px hsl(var(--portal-gold) / 0.4)"},children:m}),i.jsx("span",{className:"portal-serif",style:{fontSize:"1.5rem",color:"hsl(var(--portal-ink-muted))"},children:a===1?"day":"days"})]}),i.jsx("div",{className:"portal-hairline w-16 mx-auto my-4"}),i.jsx("p",{className:"text-xs tracking-[0.2em] uppercase",style:{color:"hsl(var(--portal-ink-muted))"},children:Xx(n)?"Until closing day":"Until you hold the keys"}),i.jsx("div",{className:"mt-6 mx-auto max-w-[260px]",children:i.jsx("div",{className:"h-[2px] rounded-full overflow-hidden",style:{background:"hsl(var(--portal-gold) / 0.15)"},children:i.jsx(yr.div,{initial:{width:0},animate:{width:`${y}%`},transition:{duration:1.2,ease:"easeOut"},className:"h-full rounded-full",style:{background:"var(--portal-gradient-gold)",boxShadow:"0 0 12px hsl(var(--portal-gold) / 0.6)"}})})})]})]})}function zer(t){return t.type!=="application/pdf"?"Please choose a PDF":t.size?t.size>15*1024*1024?"PDF must be under 15 MB":null:"The PDF is empty"}function Lot(t,e){return te.has(r.id))}function Ver(t){return t.reduce((e,r)=>e+r.file_size,0)>25*1024*1024?"Choose documents totaling no more than 25 MB.":null}const Mot={Lead:{expect:"Your agent will learn what matters most to you and your move.",action:"Share your goals, timing, and preferred way to stay in touch."},Consultation:{expect:"Together you will review your options and create a plan.",action:"Bring your questions and any important timing or financing details."},"Agreement Signed":{expect:"Your agent is organizing the next steps with you.",action:"Keep a copy of your signed agreements and confirm your contact details."},Active:{expect:"Your agent will keep you updated as your search or marketing progresses.",action:"Share feedback and let your agent know when your priorities change."},"Under Contract":{expect:"Inspections, financing, and title review move forward according to your contract.",action:"Check your key dates and respond promptly to requests from your agent or lender."},Closing:{expect:"The closing team will coordinate final documents and any remaining requirements.",action:"Confirm your appointment and ID requirements. Verify wire instructions by calling a trusted number."},"Closed Won":{expect:"Your agent can help with post-closing questions and your next chapter.",action:"Save your closing documents somewhere secure."}};function BTe({journeyStages:t,currentIndex:e,dealType:r}){const[n,s]=N.useState(e);return N.useEffect(()=>s(e),[e]),t.length?i.jsxs("section",{className:"portal-roadmap",children:[i.jsx("p",{className:"portal-eyebrow mb-2",children:"The Journey"}),i.jsxs("div",{className:"mb-6 flex flex-wrap items-baseline justify-between gap-2",children:[i.jsx("h2",{className:"portal-serif text-2xl",children:Xx(r)?"Your path to closing":"Your path to the keys"}),i.jsxs("span",{className:"text-xs text-muted-foreground",children:["Step ",e+1," of ",t.length]})]}),i.jsx("ol",{className:"space-y-1",children:t.map((o,c)=>{const a=Lot(c,e),f=n===c,m=Mot[o.key];return i.jsxs("li",{className:"portal-roadmap-step","data-status":a,children:[i.jsxs(Lt,{variant:"ghost",className:"portal-roadmap-trigger h-auto w-full justify-start gap-3 whitespace-normal py-3 text-left","aria-expanded":f,"aria-current":a==="current"?"step":void 0,onClick:()=>s(f?null:c),children:[i.jsx("span",{className:"portal-roadmap-marker flex h-8 w-8 shrink-0 items-center justify-center rounded-full",children:a==="completed"?i.jsx(pa,{className:"h-4 w-4"}):c+1}),i.jsxs("span",{className:"min-w-0 flex-1",children:[i.jsx("span",{className:"portal-serif block text-lg",children:o.label}),i.jsx("span",{className:"block text-xs font-normal",children:a==="current"?"You are here":a==="completed"?"Completed":"Ahead of you"})]}),f?i.jsx(eye,{className:"h-4 w-4 shrink-0"}):i.jsx(Go,{className:"h-4 w-4 shrink-0"})]}),f&&i.jsxs("div",{className:"portal-roadmap-details ml-11 space-y-3 border-l pl-4 pb-4 text-sm",children:[i.jsx("p",{children:o.description}),m&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{children:[i.jsx("p",{className:"portal-eyebrow mb-1",children:"What to expect"}),i.jsx("p",{children:m.expect})]}),i.jsxs("div",{children:[i.jsx("p",{className:"portal-eyebrow mb-1",children:"Your next move"}),i.jsx("p",{children:m.action})]})]})]})]},o.key)})})]}):null}function $Te({currentStage:t,agentUpdate:e,nextStepText:r,nextStepVideoUrl:n}){const s=o=>{var c,a;if(o.includes("youtube.com/watch")){const f=new URL(o).searchParams.get("v");return f?`https://www.youtube.com/embed/${f}`:null}if(o.includes("youtu.be/")){const f=(c=o.split("youtu.be/")[1])==null?void 0:c.split("?")[0];return f?`https://www.youtube.com/embed/${f}`:null}if(o.includes("loom.com/share/")){const f=(a=o.split("loom.com/share/")[1])==null?void 0:a.split("?")[0];return f?`https://www.loom.com/embed/${f}`:null}return o};return i.jsxs("div",{children:[i.jsx("p",{className:"portal-eyebrow mb-2",children:"Right Now"}),i.jsx("h4",{className:"portal-serif text-3xl mb-2 portal-gold-underline",style:{color:"hsl(var(--portal-ink))"},children:t.label}),i.jsx("p",{className:"text-sm leading-relaxed mt-4",style:{color:"hsl(var(--portal-ink-muted))"},children:t.description}),e&&i.jsxs("div",{className:"mt-5 rounded-xl p-4",style:{background:"hsl(var(--portal-surface-2))",border:"1px solid hsl(var(--portal-gold) / 0.15)"},children:[i.jsx("p",{className:"portal-eyebrow mb-2",children:"Note From Your Agent"}),i.jsxs("p",{className:"text-sm leading-relaxed portal-serif italic",style:{color:"hsl(var(--portal-ink))",fontSize:"1rem"},children:["“",e,"”"]})]}),r&&i.jsxs("div",{className:"mt-5 rounded-xl p-4",style:{background:"linear-gradient(135deg, hsl(var(--portal-gold) / 0.08), hsl(var(--portal-gold) / 0.02))",border:"1px solid hsl(var(--portal-gold) / 0.25)"},children:[i.jsx("p",{className:"portal-eyebrow mb-2",children:"What’s Next"}),i.jsx("p",{className:"text-sm leading-relaxed",style:{color:"hsl(var(--portal-ink))"},children:r})]}),n&&i.jsx("div",{className:"mt-5 rounded-xl overflow-hidden aspect-video relative group",style:{background:"hsl(var(--portal-bg))",border:"1px solid hsl(var(--portal-gold) / 0.2)"},children:i.jsx("iframe",{src:s(n)||n,className:"w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,title:"Next step video"})})]})}function Qx(t){const e=t.split(/[-/T]/);if(e.length>=3){const r=Number(e[0]);return r>99?new Date(r,Number(e[1])-1,Number(e[2])):new Date(Number(e[2]),Number(e[0])-1,Number(e[1]))}return new Date(`${t}T12:00:00`)}function qer(t){const e=t.trim();if(!e)return;const r=e.split(/[-/]/).filter(Boolean);if(r.length<3)return;const n=r.map(f=>Number(f));if(n.some(f=>Number.isNaN(f)))return;n[0];let s,o,c;if(r[0].length===4)[c,s,o]=n,s=s-1;else if([s,o,c]=n,s=s-1,r[2].length===2)c=c<=49?2e3+c:1900+c;else if(r[2].length!==4)return;const a=new Date(c,s,o);if(!(a.getFullYear()!==c||a.getMonth()!==s||a.getDate()!==o))return a}function Dot(t){return Array.isArray(t)?t.filter(e=>e&&typeof e.id=="string"&&typeof e.label=="string"&&typeof e.date=="string"&&/^\d{4}-\d{2}-\d{2}/.test(e.date)).map(e=>({id:e.id,label:e.label.trim(),date:e.date.slice(0,10),done:!!e.done,show_in_portal:e.show_in_portal!==!1,notes:e.notes??null,provisional:!!e.provisional,source_key:typeof e.source_key=="string"?e.source_key:null})).sort((e,r)=>e.date.localeCompare(r.date)):[]}function Oot(t){return Dot(t).filter(e=>e.show_in_portal)}function Ger(t,e){const[r,n,s]=t.split(/[-/T]/).map(Number),o=new Date(r,n-1,s+e);return`${o.getFullYear()}-${String(o.getMonth()+1).padStart(2,"0")}-${String(o.getDate()).padStart(2,"0")}`}const Fot=["January","February","March","April","May","June","July","August","September","October","November","December"],Bot=t=>String(t).padStart(2,"0");function zTe(t){const e=t.filter(n=>/^\d{4}-\d{2}-\d{2}/.test(n.date||""));return Array.from(new Set(e.map(n=>n.date.slice(0,7)))).sort().map(n=>{const[s,o]=n.split(/[-/T]/).map(Number),c=new Date(s,o-1,1).getDay(),a=new Date(s,o,0).getDate(),f=[];for(let y=0;yw.date.slice(0,10)===_)})}for(;f.length%7;)f.push(null);const m=[];for(let y=0;y{var n;return(n=r.date)==null?void 0:n.startsWith(e)}).sort((r,n)=>r.date.localeCompare(n.date))}const VTe=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function $ot({events:t,variant:e="app",provisionalNote:r}){const n=zTe(t);if(!n.length)return null;const s=e==="portal",o=s?{color:"hsl(var(--portal-ink))"}:void 0,c=s?{color:"hsl(var(--portal-ink-dim))"}:void 0,a=s?{background:"hsl(var(--portal-surface-2))"}:void 0,f=m=>s?{background:m?"hsl(var(--portal-gold) / 0.12)":"hsl(var(--portal-gold) / 0.22)",border:"1px solid hsl(var(--portal-gold) / 0.5)"}:void 0;return i.jsxs("div",{className:"space-y-6",children:[t.some(m=>m.provisional)&&i.jsxs("div",{className:s?"rounded-md p-3 text-xs":"rounded-md border border-accent bg-accent/30 p-3 text-xs",style:s?{border:"1px solid hsl(var(--portal-gold) / 0.4)",color:"hsl(var(--portal-ink))"}:void 0,children:[i.jsx("p",{className:"font-semibold uppercase tracking-wide",children:"Seller acceptance unverified"}),i.jsxs("p",{className:"mt-0.5",children:["* ",r||"Provisional dates assume the offer is accepted. They will be recalculated from the actual acceptance date."]})]}),n.map(m=>i.jsxs("div",{className:"break-inside-avoid",children:[i.jsx("h3",{className:s?"portal-serif text-xl mb-2":"text-lg font-semibold mb-2",style:o,children:m.title}),i.jsxs("div",{className:"grid grid-cols-7 gap-1 text-[10px] sm:text-xs",children:[VTe.map(y=>i.jsx("div",{className:s?"px-1 uppercase tracking-wider":"px-1 uppercase tracking-wider text-muted-foreground",style:c,children:y},y)),m.weeks.flat().map((y,_)=>i.jsx("div",{className:`min-h-[52px] sm:min-h-[64px] rounded p-1 ${s?"":y!=null&&y.events.length?y.events.every(w=>w.provisional)?"bg-accent/40 border border-accent":"bg-primary/10 border border-primary/40":y?"bg-muted/50":""}`,style:y?y.events.length?f(y.events.every(w=>w.provisional)):a:void 0,children:y&&i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"font-medium",style:o,children:y.day}),y.events.map((w,E)=>i.jsxs("div",{className:`leading-tight font-medium ${w.done?"line-through opacity-60":""} ${s?"":"text-primary"}`,style:s?{color:"hsl(var(--portal-gold))"}:void 0,children:[w.label,w.provisional?"*":""]},E))]})},_))]}),i.jsx("ul",{className:"mt-3 space-y-2 text-sm",children:UTe(t,m.key).map((y,_)=>i.jsxs("li",{children:[i.jsxs("span",{className:"text-xs font-semibold uppercase tracking-wide",style:o,children:[Ls(Qx(y.date),"MMM d"),y.provisional?"*":""," · ",y.label]}),y.note&&i.jsx("p",{className:s?"text-xs":"text-xs text-muted-foreground",style:c,children:y.note})]},_))})]},m.key))]})}const af=t=>t.replace(/[&<>"]/g,e=>({"&":"&","<":"<",">":">",'"':"""})[e]);function Her(t){var c;const e=zTe(t.events),r=window.open("","_blank");if(!r)return!1;const n=t.events.some(a=>a.provisional)?``:"",s=e.map(a=>{const f=a.weeks.flat().map(_=>_?`
${_.day}
${_.events.map(w=>`
${af(w.label)}${w.provisional?"*":""}
`).join("")}`:''),m=[];for(let _=0;_${f.slice(_,_+7).join("")}`);const y=UTe(t.events,a.key).map(_=>`
  • ${af(Ls(Qx(_.date),"MMM d").toUpperCase())}${_.provisional?"*":""}  |  ${af(_.label.toUpperCase())}${_.note?`
    ${af(_.note)}`:""}
  • `).join("");return`

    ${af(t.title)}

    ${af(t.subtitle||"")}

    ${af(t.agent||"")}
    ${n}

    ${a.title}

    ${VTe.map(_=>``).join("")}${m.join("")}
    ${_.toUpperCase()}
      ${y}
    `}).join(""),o=(c=t.terms)!=null&&c.length?`

    Who does what

      ${t.terms.map(a=>`
    • ${af(a.label.toUpperCase())}
      ${af(a.detail)}
    • `).join("")}
    `:"";return r.document.write(`${af(t.title)} — Transaction Calendar${s}${o}