const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/BoostCompanion-BMuOMbtV.js","assets/BoostPanel-DW2-fWZj.js","assets/useAssistantChat-1-_iwvhg.js","assets/useSmartQueue-CnGU3lK9.js","assets/useBoostGift-N_2f_AE8.js","assets/sun-B0oSom2S.js","assets/announcements-CHWMrHjI.js","assets/pause-BoQZRhay.js","assets/bell-off-DXbdWUPG.js","assets/LeadSiteHome-CVlq-YRv.js","assets/useLeadSiteSearchSuggestions-xIZmfpOf.js","assets/hash-Dfpl_Ep0.js","assets/map-DXxdBCo3.js","assets/AgentReviewsSection-DZwWi6PT.js","assets/credits-PIR_bev7.js","assets/ExchangeListingsSection-DD_fId_e.js","assets/leadSiteAgent--GbV6IdE.js","assets/ScrollLivingHero-DnlbRFhq.js","assets/LeadSiteLuxuryHome-DVg4nzI7.js","assets/RecentSalesSnapshot-I7_J2ARU.js","assets/LeadSiteExchangeListings-CcGQek0G.js","assets/truck-D_qCFY5a.js","assets/LeadSiteLuxuryHome-DKt_VWIz.css","assets/LeadSiteLandRanchHome-44eClgT6.js","assets/use-in-view-BBzhCIX7.js","assets/tree-pine-DipGIHvD.js","assets/mountain-B-kdUT8N.js","assets/LeadSiteSearch-CPh71tNZ.js","assets/ListingCardExtras-B56dxw32.js","assets/bell-ring-BP_kJDSU.js","assets/useInfiniteQuery-Bj1O72Ao.js","assets/LeadSiteMap-V0pOH2Gz.js","assets/LeadSiteLuxurySearch-DQwbiYYV.js","assets/LeadSiteListingDetail-DTApWA5h.js","assets/ListingVideoTour-CyvsobN8.js","assets/expand-kax60Aoy.js","assets/car-CtikVBR3.js","assets/thermometer-B4GJC7Gw.js","assets/snowflake-B_QL3Epe.js","assets/waves-C7CyrbS3.js","assets/useListingVideos-BBlzvy-Z.js","assets/LeadSiteLuxuryListingDetail-Da8l1S-G.js","assets/LeadSiteAbout-B-FxsuXi.js","assets/LeadSiteLuxuryAbout-DgMhLjeb.js","assets/ExpReadySpotlight-B52ylh5S.js","assets/LeadSiteBlog-DCt_wiiG.js","assets/renderPostContent-Czn49UfS.js","assets/LeadSiteCommunity-4c-j6Rq2.js","assets/wine-DgkhgZCd.js","assets/trees-kL-M-yVp.js","assets/music-BQI3I2D7.js","assets/LeadSiteSellers-cGuAqtre.js","assets/LeadSiteCityPage-OgPbHvAj.js","assets/CityFaqSection-v8zbA4VY.js","assets/LeadSiteExpReady-CjIGz-gj.js","assets/paintbrush-BUPNd3oQ.js","assets/VacationRentals-DHX5hTtd.js","assets/paw-print-DQuFEopO.js","assets/OrgSiteLayout-Bj1gNQ_y.js","assets/orgSiteBrand-DKMUe12O.js","assets/OrgSiteHome-yQhz_sh6.js","assets/OrgSiteAgents-DHXl-tc6.js","assets/OrgSitePages-BgEiS3tX.js","assets/OrgSiteListings-DAnbVb1n.js","assets/CanvaSupport-CQePR9Kd.js","assets/unplug-D3zqFpAq.js","assets/SmsOptIn-Ds3NsDX3.js","assets/signpost-Dt7n2deY.js","assets/ConnectChatGPT-CMYHVHkA.js","assets/circle-check-big-DlmOkMKf.js","assets/LevelUpMCP-Bh0dD7Hb.js","assets/terminal-BTMaf7Wa.js","assets/SubscriptionSuccess-I6wrZ6b8.js","assets/SetupBrokerage-BbWE_7z1.js","assets/InviteSignup-2CSwO0PW.js","assets/eye-off-DR8JiU0k.js","assets/CoachingHub-rjMvHIc_.js","assets/useCoaching-tt-Mforu.js","assets/CoachAgentWorkspace-DAS3MMmD.js","assets/CoachingFiles-DOc-uDQA.js","assets/folder-open-Ccg8Hdgt.js","assets/save-CVUhH5AI.js","assets/MyCoach-CaAM2R3Z.js","assets/CoachReviews-D9QIzRZR.js","assets/circle-x-DORaGM4e.js","assets/AdminCoaching-Cph6hS_S.js","assets/arrow-left-right-gtHDVO2i.js","assets/user-minus-Dexq1BbJ.js","assets/inbox-DFdGyUhh.js","assets/CoachBilling-DFZyZCAc.js","assets/credit-card-_vesgZb9.js","assets/CoachSettings-rBGAtmd9.js","assets/GoogleCalendarCard-DRyt82iS.js","assets/calendar-off-Ce__Aa01.js","assets/useCoachGoogleCalendar-GwMQJplt.js","assets/link-D9C3r-at.js","assets/Microsoft365Return-FGt7YNfb.js","assets/useMicrosoft365-Dmw3G5cw.js","assets/freshAccessToken-ClZhRgpc.js","assets/CoachWaitlist-C2FfgxkC.js","assets/mail-check-CeI6PcUx.js","assets/CoachProfile-iJcMja-5.js","assets/Trial-CLfhGtVs.js","assets/testimonial-avatar-5-DBoTqx4u.js","assets/TrialSuccess-ClF2RMUI.js","assets/party-popper-X5CCFDlX.js","assets/LaborDaySale-BNUPwhFY.js","assets/OpenHouseInviteModal-TfGLegBY.js","assets/infinity-DocBDy0O.js","assets/workflow-BOVmW9Ji.js","assets/BrokerageLaborDaySale-FOCQAfzI.js","assets/BrokerageSolutions-CnhsLvyZ.js","assets/receipt-DII9Vplw.js","assets/banknote-BmGy6g4f.js","assets/pencil-line-BuK4EuWf.js","assets/Upgrade-BgJH69i5.js","assets/log-in-h28AU6eO.js","assets/InstagramGift-B_P9PRm_.js","assets/VideoShare-LXnpVsJ5.js","assets/VideoPageTemplates-DPX01BGJ.js","assets/message-circle-heart-C6tJg0LB.js","assets/door-open-CZidYwCv.js","assets/brain-65UYW3ll.js","assets/coffee-Xh5WoTYB.js","assets/CommercialWizard-k7WR-7SK.js","assets/useListingExchange-iSNqHznB.js","assets/useTeamListingAccess-CDAmpNYN.js","assets/CommercialWorkspace-CtmAf2RD.js","assets/useListingDocuments-CuhFGmi3.js","assets/ListingPhotoGrid-C6haqRT7.js","assets/sortable.esm-CbYgtyU2.js","assets/grip-vertical-CdQhzxit.js","assets/ShareListingDialog-qkfTlv5s.js","assets/EmailListingToSphereDialog-B3Ywhw4s.js","assets/index-BjqnwHC_.js","assets/separator-CKlc-U-6.js","assets/GmailComposeDialog-DDEcBCNi.js","assets/edgeError-DsxtxDmY.js","assets/useMassEmailReady-BJOZqyA_.js","assets/useSenderIdentity-lGr4UePp.js","assets/useVerifiedSenderCheck-Blpvcq4W.js","assets/VerifySenderRequiredDialog-CnJuWQJK.js","assets/useContactIntakePage-CcxEnACz.js","assets/ToContactAutocomplete-6VJi45uJ.js","assets/outlookSend-CMcz9YkO.js","assets/paperclip-DD9BNBE0.js","assets/ListingSocialDialog-Cr5q_bIW.js","assets/useAgentBrand-BG_R8Il6.js","assets/listingGraphic-Dz02nV1B.js","assets/file-search-1YSVYzJC.js","assets/qr-code-BUen_bTj.js","assets/CommercialPitchPreview-x_88-uDJ.js","assets/PublicLiveEvent-CwdiYyFJ.js","assets/pin-DWyYR3Nu.js","assets/arrow-up-B1rUOJxd.js","assets/useLiveEngagement-D8kI06n2.js","assets/sparkle-BUtl8jc2.js","assets/LiveEvents-EZO-ynpB.js","assets/AdminPageHeader-CHdk665Q.js","assets/useLiveEvents-DFKqc2Wa.js","assets/image-plus-CDHASE-_.js","assets/LiveEventConsole-CzP_PnwG.js","assets/mouse-pointer-click-Cf6WTtA7.js","assets/ban-8R6KElw9.js","assets/Dashboard-RFM0F_0U.js","assets/useContentEngagement-BG-heeR1.js","assets/usePrograms-DL2F2q5h.js","assets/timezone-CvT-MSl2.js","assets/addMilliseconds-Hk2YygKo.js","assets/isWithinInterval-xxdyea40.js","assets/useGmailIntegration-CqRm-w2d.js","assets/GoalTargetsDialog-BKlDVgv5.js","assets/useBrokerageContent-yisvSRsD.js","assets/beta-badge-BqE3p2nq.js","assets/useEventGamification-DdVR5gUd.js","assets/RelationshipHealthWidget-Cn6hgPp4.js","assets/useRelationshipScore-CIQ_kyeE.js","assets/file-image-BFM4bGwj.js","assets/Profile-CXG9S2yG.js","assets/RichTextEditor-Cd0ZtT_d.js","assets/index-DUkIhZyd.js","assets/index-BqMbZnCW.js","assets/index-Cppb-0g4.js","assets/heading-1-D7ogKghK.js","assets/heading-2-BbF-St3n.js","assets/undo-D8IhvZ3h.js","assets/list-ordered-B04peY-U.js","assets/align-left-BOCzKn8X.js","assets/align-right-DjDzqzY5.js","assets/ImageCropper-B6zsgYAI.js","assets/zoom-out-TIp4WW9d.js","assets/rotate-cw-DPQ3Lzg8.js","assets/ImageCropper-D8Md-CES.css","assets/useBrandKit-rgjq1ltY.js","assets/useStagingStudio-D3GedxNc.js","assets/checkoutTab-CTwp_lj2.js","assets/BrokerageLogoUpload-O8ronWjW.js","assets/user-round-Fyn3FGw6.js","assets/mail-x--McMUwl7.js","assets/Events-DYclks1U.js","assets/EventLeaderboard-BXGhN3jY.js","assets/medal-QablARK5.js","assets/MainStageSchedule-OOssV8mX.js","assets/history-Dv4obWBK.js","assets/EventDetail-C9hL0trI.js","assets/ShareButton-DC_yaCbo.js","assets/user-cog-G8MaHzjy.js","assets/Apps-C8RtOqSv.js","assets/monitor-play-l9B-sAhP.js","assets/skip-forward-Db5GfMnD.js","assets/Templates-cOmDZkS2.js","assets/TemplateDetail-D0rHjCwK.js","assets/Programs-BnOehRne.js","assets/ProgramDetail-DrV_soZ5.js","assets/accordion-X9DdBLaH.js","assets/index-Cg7QlDWK.js","assets/ProgramEnroll-B2h99WTW.js","assets/tag-DTdVVmuv.js","assets/ProgramWorkspace-BfEb8814.js","assets/file-spreadsheet-Bh9A-IUO.js","assets/layout-template-D48r9m52.js","assets/Programs-C4Laifhx.js","assets/route-Cf6A3sAj.js","assets/collapsible-Dtuif5Ty.js","assets/AcademyVideoDetail-DSr4nGjd.js","assets/LinkedTemplatePills-DA7oZ3DD.js","assets/ToolboxDetail-CL2MqiQM.js","assets/SocialSwag-DWJf1hrG.js","assets/SocialStudio-OHF65hy1.js","assets/CanvaImportDialog-DKv60vz2.js","assets/useCanvaMailStudio-LkmQ9GTb.js","assets/unlink-CEjti-qg.js","assets/platforms-C5sBJBpr.js","assets/music-2-72IFSl8Z.js","assets/jpegConvert-B8raQ9Nn.js","assets/repeat-2-BLdne8Oz.js","assets/useCalendarTimezone-Cb9cuPDW.js","assets/calendarTz-JHe45SGp.js","assets/type-CzHCtWkn.js","assets/settings-2-erOXBoae.js","assets/scheduleTz-GW3NFYC0.js","assets/YouTubePublishing-DUlbWZId.js","assets/CalendarSettingsDialog-Cc3K6j_8.js","assets/earth--Bhnzaby.js","assets/tiktokCallbackError-HhZqZSBp.js","assets/jszip.min-RKzhptPj.js","assets/MarketingStudio-BbnnAJ_O.js","assets/message-square-quote--pKZkO5Z.js","assets/BrandKit-Bmq4FNTK.js","assets/useBrandPresets-gly1A0HY.js","assets/BrandingBarEditor-CmQYyXT1.js","assets/ReactKonvaCore-DIi4AdLi.js","assets/index-BjcVIc26.js","assets/ListingTemplates-DTs_PQko.js","assets/index-xVp0PEHv.js","assets/EditorialTemplate-DChZRw3z.js","assets/PersonalBranding-ClKaPLe2.js","assets/toggle-group-CHyMECpi.js","assets/SocialSwagDetail-ESg3J7N0.js","assets/Community-Q1naGIPh.js","assets/MentionTextarea--DqBq2hm.js","assets/reply-DUePoMMp.js","assets/pin-off-SN5Szl-D.js","assets/Support-CF6FHqCI.js","assets/SupportAttachmentList-e1nIKtbs.js","assets/file-video-BV79tb1N.js","assets/BrokerageResources-CLaS06bF.js","assets/AdminDashboard-4cs7WWLf.js","assets/coins-BOTYn32r.js","assets/shopping-bag-ztT7t4dr.js","assets/flask-conical-e8qK9yEX.js","assets/database-C81Odspp.js","assets/MemberManagement-8i-KaxWG.js","assets/SendCelebrationDialog-DhUAh-pO.js","assets/sortable-table-head-1oULvhmW.js","assets/arrow-down-t1UHHMJT.js","assets/useTeams-DmtwH1Jr.js","assets/CreateTeamDialog-CO6oKF0E.js","assets/TeamSharedAssetsView-DwfYjfQ8.js","assets/LeadPondView-BmEFgbbr.js","assets/arrow-right-left-Dr66D_B8.js","assets/sticky-note-Cti4f2Tk.js","assets/droplets-B-MdD-LW.js","assets/hand-DJ1Q2UUB.js","assets/contact-DonaNOIe.js","assets/crown-QOW5LN9D.js","assets/calendar-heart-Cghsn7aL.js","assets/UnassignedMembers-DOXOU5sl.js","assets/InviteCodes-C2QBN9Pz.js","assets/Events-B-SUmuR4.js","assets/useNotifications-BQ2LpRwE.js","assets/repeat-BOsf2tnw.js","assets/MCPAuditLog-7xj0lyKv.js","assets/shield-alert-DQyvMIbU.js","assets/Templates-D1PGNQXa.js","assets/Academy-BYVWF23Z.js","assets/LinkedTemplatePicker-X1n9G2s6.js","assets/VideoLibraryPicker-9ZZ_QsaK.js","assets/Toolbox-cW5acfmf.js","assets/SocialSwag-Cl3tZkte.js","assets/SocialSwag2-BPFzYrJ1.js","assets/Community-DBDH6G3F.js","assets/Analytics-nYqX_049.js","assets/ShareAnalytics-hZnvODqV.js","assets/mouse-pointer-BizIs4IF.js","assets/panels-top-left-VVBv75ic.js","assets/LineChart-QwmHov7w.js","assets/chrome-Ds9pRba2.js","assets/BrokerageResources-BfGIrkxS.js","assets/DashboardManagement-C1TvkfAE.js","assets/SupportTickets-DUyMRGz-.js","assets/EmailTemplates-HcgT2Uwo.js","assets/index-B0cRay4o.js","assets/code-IKZSsSTO.js","assets/variable-CsayEVXn.js","assets/monitor-CFdTojfb.js","assets/AgentEmailTemplates-xhkcZrf_.js","assets/BrokerageDashboard-CE7fVuN2.js","assets/BrokerageLenderReport-Djuc_Drp.js","assets/MyBrokerage-BSWT7oaH.js","assets/useBrokerageOnboarding-Cq0-Ul0P.js","assets/OnboardingChecklist-CjgOYhJr.js","assets/BrokerageContent-BZLkekZH.js","assets/BrokerageHelpBoard-oyLE-cyG.js","assets/useBrokerageHelpBoard-w5dE20n8.js","assets/BrokerageHelpBoardNew-BiiXwf2k.js","assets/BrokerageHelpBoardDetail-CRKrAYZf.js","assets/Newsletters-Cx6LKSZN.js","assets/VisualHtmlEditor-BuopgT8M.js","assets/NewsletterGraphicsPicker-CNz9B0Xe.js","assets/underline-CQ9VFosc.js","assets/uploadBase64Images-DN8Yl3w5.js","assets/SendNewsletterDialog-BgypDVGg.js","assets/undo-2-CfE_oJDh.js","assets/useContactCustomTags-B-0KFW-o.js","assets/useSmartLists-grnyE_I7.js","assets/useMailingAddressGate-B3M2_Sn1.js","assets/SenderAddressDialog-gh-Uml4j.js","assets/code-xml-TNJrrWLL.js","assets/list-filter-BuTo7QTL.js","assets/NewsletterDetail-DxlWG2wa.js","assets/Newsletters-CqVNKpgl.js","assets/library-DMl3Gi5N.js","assets/MemberBroadcasts-A_45nsvR.js","assets/bookmark-plus-D2daKiFR.js","assets/BoostAnnouncements-BFbE9pIr.js","assets/NewsletterGraphics-D26GfeHG.js","assets/Wishlist-CaVuYuUk.js","assets/WishlistDetail-s2f4FeWI.js","assets/LevelUpBrief-mE-ZDCjO.js","assets/AdditionalServices-ewH10EZy.js","assets/Discounts-DWV_pbvb.js","assets/Subscriptions-G0vx_SVW.js","assets/instagramEmailReview-DK4Cq88H.js","assets/InstagramGiftEmails-D939P_yC.js","assets/Referrals-DVW__qk9.js","assets/AgentOSControlCenter-K2GgbwFE.js","assets/AskAI--bOGVaaQ.js","assets/InnerCircleHome-B3OGHlfm.js","assets/SnoozeContactDialog-CIrBkPW9.js","assets/pen-tool-kcJpSKh6.js","assets/milestoneMail-Cs6qfJaR.js","assets/handoff-B7AOa2Ye.js","assets/milestones-De303X1G.js","assets/stamp-ePVOmHi2.js","assets/mail-open-CFX2pQRs.js","assets/InnerCircleContacts-ByJcZdWC.js","assets/mailingAddress-BJ5Zh-Ye.js","assets/SyncDirectionSelector-CadUkWqI.js","assets/refresh-ccw-OBSvBH9Q.js","assets/merge-DxfhtcUW.js","assets/ContactCriteriaForm-nsAFQYNo.js","assets/usePopbys-Bz0ns60F.js","assets/ContactTagChip-xGL3Jr0O.js","assets/info-DLclu7Qk.js","assets/RelationshipScoreBadge-BZlJa6jc.js","assets/MailStudioHandoffButton-Q5-aNgiF.js","assets/useVideoShareTracking-PNA4lamQ.js","assets/EnrollContactsDialog-BnjtOyXH.js","assets/useDripCampaigns-Dnwe3DbV.js","assets/CampaignBuilderDialog-CPNZa9fh.js","assets/quill.snow-B2hMCWhH.js","assets/quill-BzY4kI8E.css","assets/braces-CzSQC_NZ.js","assets/holidayCalendar-BrEpfYm_.js","assets/VideoUploadDialog-IfnB70aO.js","assets/useVideoTouch-DpriCKRe.js","assets/CardVideoRecorderDialog-CdLtFps1.js","assets/VideoRecorder-Cf8uS4fT.js","assets/flip-horizontal-B3yYxXCu.js","assets/videoSegmentation-23AN6N06.js","assets/monitor-up-Clb_hhTp.js","assets/mic-CzRYd-q2.js","assets/folder-CyK64Eg5.js","assets/NeighborhoodFilter-C-kda1Z3.js","assets/useNeighborhoods-DoeyBlcm.js","assets/sphereMap-M8-At4F-.js","assets/sprout-C_iFQ9ej.js","assets/ContactAvatar-AeK8AcZJ.js","assets/user-x-D9yxmCMR.js","assets/map-pinned-CfUekUQu.js","assets/InnerCircleContactDetail-Cw82d__m.js","assets/useLenders-CfKsLR4P.js","assets/SendToLenderDialog-B3CqbWhV.js","assets/HomeownerHubManager-CUeSFE3s.js","assets/moon-DFw63Ak2.js","assets/useCMA-WIW7dhKD.js","assets/useClientPortal-DE6wY1jr.js","assets/AiCmaDialog-BLaaaFjB.js","assets/futureSeller-B4rSKFNg.js","assets/useSentEmails-owwgzW1B.js","assets/propertyService-CF23d51O.js","assets/building-iNOd50ns.js","assets/archive-nwVLj8Dk.js","assets/useContactFinder-9LJu6FjO.js","assets/SentEmails-CdyLzcxq.js","assets/InnerCirclePlans-CkeAzDgt.js","assets/pen-CmfJJEAm.js","assets/CMAList-BNMrlCNZ.js","assets/SendCMADialog-CafFyZas.js","assets/UpgradeLockedCard-BHwYHvCt.js","assets/CMABuilder-C-8Gf-xY.js","assets/ListingPresentations-oG5lgVzl.js","assets/session-DoC7gRjW.js","assets/jspdf.es.min-BbJaEcC9.js","assets/SendPresentationDialog-cc407vDh.js","assets/ListingPresentationBuilder-OTxMe0Qh.js","assets/PdfCanvasPreview-ChnrwMVI.js","assets/pdf.worker.min-D5NRzAXJ.js","assets/ImageUploadField-Cyh1qEcO.js","assets/move-Dui7en7X.js","assets/InnerCirclePopbys-D4b0I_he.js","assets/locate-D6pkFs3K.js","assets/navigation-CxtHiAFJ.js","assets/ListingExchange-BqF5t8a8.js","assets/ListingLaunchKitModal-DyYSldD6.js","assets/ListingSelectionBar-CAmeK1eY.js","assets/musicVideoHandoff-Bs6IOG8F.js","assets/ListingDetail-B246lWrS.js","assets/ListingForm-CNVMKSO9.js","assets/CustomizeListingPage-Dq998zvq.js","assets/box-CLUThfpW.js","assets/VideoStudio-B-gTYR4i.js","assets/wifi-CbT7uccE.js","assets/VideoShareWithTemplate-BQ7sEO0E.js","assets/useStageChat-C-C8BMls.js","assets/chatHistory-S_-cQRaj.js","assets/browser-CjSdxGTc.js","assets/tv-CKS2SNK8.js","assets/video-off--wvLrmFz.js","assets/guestRoom-BUPAqtxs.js","assets/kits-DACmZcCF.js","assets/BackdropPanel-BBrsUdgC.js","assets/ListingPhotoImport-Ck2fSim3.js","assets/images-B_nPSv6C.js","assets/panel-right-close-CsfLO6Nb.js","assets/clapperboard-CDB3OIm8.js","assets/scissors-CqgZwLgC.js","assets/switch-camera-DKwJEa2k.js","assets/MainStageGate-B625OKaC.js","assets/survey-Bzks3ZEq.js","assets/phone-off-CUEze-Bq.js","assets/eraser-1NCmE-jr.js","assets/theater-C67kCDW-.js","assets/MainStageAdmin-Bgcx3g61.js","assets/StudioKitsAdmin-o-YrELox.js","assets/StudioGuestJoin-CTwOJ5kf.js","assets/VideoLibrary-DSC1rZFW.js","assets/tags-DhK7mY6d.js","assets/hard-drive-D86SKad_.js","assets/DealPipeline-Cvnquvgd.js","assets/lucide-react-8KXzytT0.js","assets/archive-restore-BcvP_lrs.js","assets/arrow-down-left-HLFL_N2A.js","assets/arrow-down-right-Dqoj3dJm.js","assets/badge-check-DVMF9PLO.js","assets/circle-user-B7gRrj56.js","assets/beaker-Bx7jWzcZ.js","assets/brain-circuit-5n8fPa1l.js","assets/calendar-x-CLKh5-lg.js","assets/chart-line-Crj4LhrX.js","assets/file-code-D0G4maV7.js","assets/table-D3ZhF4_u.js","assets/circle-dollar-sign-D5-2TWiR.js","assets/clock-3-D6nRCk9q.js","assets/sunset-CF13myzY.js","assets/cloud-upload-Dw4ydfri.js","assets/corner-down-right-Brx6NahA.js","assets/file-check-2-Dwx69voX.js","assets/file-check-D4HnAPea.js","assets/file-down-Dct6wUbo.js","assets/file-plus-2-rMaaDcEK.js","assets/piggy-bank-DUhWCAuc.js","assets/folder-plus-CPiANrx4.js","assets/footprints-5mrQp31r.js","assets/hand-heart-wSA3h0ZW.js","assets/heading-3-Cpt26OC_.js","assets/heart-handshake-CgB7V77h.js","assets/id-card-C4IROxzO.js","assets/locate-fixed-DT5NyCvk.js","assets/list-plus-CKiXYGJZ.js","assets/lock-keyhole-DcBvngyJ.js","assets/mail-plus-CcJU9wfq.js","assets/mail-warning-DvkKQqRt.js","assets/message-square-more-DkpII4nh.js","assets/message-square-plus-huc9DuZw.js","assets/message-square-reply-Bgxmy8Jv.js","assets/messages-square-A2bYGiBM.js","assets/mouse-pointer-2-D62K9wUq.js","assets/skip-back-CkV8yiP2.js","assets/octagon-alert-CzEeD8m_.js","assets/power-off-C1fyPAJi.js","assets/power-BDIOffwT.js","assets/rectangle-vertical-B1RrWMel.js","assets/scroll-text-DWFugmkF.js","assets/shield-off-DnBsTG2t.js","assets/shield-question-EBkpcff8.js","assets/shuffle-bVmyse_z.js","assets/table-2-BXK02nku.js","assets/text-cursor-input-BeEdgjPt.js","assets/thumbs-down-DYaaOIWI.js","assets/twitter-BSymDUNM.js","assets/user-round-check-Bv-tXpNv.js","assets/user-round-search-Dh8zn3Lo.js","assets/users-round-PgNQhaZb.js","assets/useCommissionPlans-DBOgAzhS.js","assets/ComplianceMessageThread-DQq1bC62.js","assets/SendForSignatureDialog-D4av2f-9.js","assets/useFormEnvelopes-ng4mY3vR.js","assets/PortalInviteDialog-DZ_SWpV7.js","assets/PlaybookLibraryDialog-Cht2XyEb.js","assets/LenderPartnerDialog-D7FvmaYI.js","assets/PhotoUploadField-Bdud9KyZ.js","assets/PortalListView-CfMBP4Jn.js","assets/complianceMetrics-Ce83UgLe.js","assets/FormsLibrary-WpbJlRsm.js","assets/FormPlacementEditor-HYCuGA57.js","assets/TransactionCoordinator-0lmZXOHq.js","assets/PortalReferrals-DBChfZnD.js","assets/usePortalReferrals-B20UzoCn.js","assets/AgentVendors-r2R6ndWo.js","assets/VendorFormDialog-B3gF2cS8.js","assets/BrokerageForms-EHyQAu3g.js","assets/BrokerageVendors-CuPrydpw.js","assets/ClientPortalsHub-BKdT5oY2.js","assets/PortalMessagesPanel-BKoyKkHd.js","assets/ClientPortalDetail-UMVD0lB2.js","assets/MyCardEditor-B1F-NCn-.js","assets/CardBlocksEditor-Cp48GUHa.js","assets/Integrations-cAc8N53b.js","assets/SesIntegrationCard-D5Rebukw.js","assets/RecruitVerifiedSenders-cSbUsqmp.js","assets/Microsoft365Card-offPMM14.js","assets/BrowserExtension-DlUSaoDb.js","assets/IntegrationsGmailCallback-Cw_4YWrD.js","assets/IntegrationsMetaCallback-DEHp8bKn.js","assets/AgentActivation-XDnQs1xU.js","assets/MembershipReviews-CZyefUc6.js","assets/LeadNotifications-3mFcXiEi.js","assets/WeeklyDigest-CuJAZ1m5.js","assets/AgentPoints-D99YQp93.js","assets/AgentCards-CS-MmfYx.js","assets/Marketplace-JIWLgi2S.js","assets/RewardStore-BPOyruia.js","assets/usePointRewardSettings-oGuR_640.js","assets/Integrations-B-GtB9GK.js","assets/SocialConnections-DUlCJFlJ.js","assets/SocialAutopilot-PT8l5bOa.js","assets/McpUpdates-OgLveb_2.js","assets/NotificationSettings-Baz82Hha.js","assets/PresentationAnalytics-DDEAU_3w.js","assets/ListingPresentationStudioAdmin-Dn9lIyQe.js","assets/ListingRevivalAdmin-FajBhewk.js","assets/useListingRevivalAccess-CIKsDZTA.js","assets/GuestBookAnalytics-D1INaGaQ.js","assets/IntegrationsCallback-DzjaSG4j.js","assets/AdminRecruiting-CLr22s-L.js","assets/RecruitPipelineStageEditor-Dw5N7NSD.js","assets/videoThumb-B7-rh5G3.js","assets/index-DgsxHxJr.js","assets/BrokerageRecruiting-C89rmRvf.js","assets/600-BSKZD_mM.css","assets/BrokerageOnboarding-COpcgH3_.js","assets/BrokerageTransactions-DBV3Vn5Z.js","assets/useDealEscrow-vzOWozhA.js","assets/BrokerageOperations-zaV-Z9HI.js","assets/renewals-DaSVMhWM.js","assets/WebsitesHub-BAG-L_vO.js","assets/useMyWebsites-BUojLUPq.js","assets/SiteGrade-DWMjmmAf.js","assets/TeamWebsite-BQMHTRvv.js","assets/OrgSiteBuilder-DM9f1Zun.js","assets/SiteSwitcher-BIFAdE_M.js","assets/BrokerageWebsite-BXkg9AYr.js","assets/BrokerageAgentWebsites-Bco-ZIJk.js","assets/BrokerageCommissionPlans-cQZhaW1a.js","assets/BrokerageContentActivity-DFr2DQ5a.js","assets/BetaSocialPostGenerator-_ZVuQPEE.js","assets/AdminLMS-DNOlMCAz.js","assets/useLMS-SvTkpuyz.js","assets/AdminCourseDetail-BbvPQvOz.js","assets/LevelUpU-nRqG19o3.js","assets/LevelUpUCourse-CFGpqTVe.js","assets/MobileAgentApp-w5MfcUUL.js","assets/StagingStudio-xTTWhStU.js","assets/presets-BCNQCHbK.js","assets/download-BqCckdNk.js","assets/BeforeAfterSlider-CZ5HmnKu.js","assets/BuyCreditsDialog-DuXjlzfQ.js","assets/StagingLibrary-BA4xKf1d.js","assets/StagingCredits-DjA4HeQm.js","assets/AgentWallet-BE_NIob6.js","assets/useHomeReel-CkjZ60e9.js","assets/StagingSharePage-DKAYMTJS.js","assets/StagingStudioAdmin-BPUTdwKT.js","assets/ContactFinderAdmin-CD1KkOwC.js","assets/PostcardManager-DvG3N6fG.js","assets/PostcardZoneEditor-BWTDxDtC.js","assets/usePostcardZones-msKpLDb6.js","assets/MailStudioTemplates-CqZFHx38.js","assets/HomeReelManager-DAhPWmnR.js","assets/videoRenderSink-KDd1M0JO.js","assets/AdminMusicVideos-Cw4w9aN0.js","assets/AdminVideoLab-B1lLc-Nb.js","assets/BoostPreview-DujAqPd5.js","assets/AdminCredits-BZ-zC_rP.js","assets/MailStudio-BX2O9JuQ.js","assets/farmToCrm-l6jxPthf.js","assets/artwork-Bnwb-9Vv.js","assets/MailStudio-D-BotKHo.css","assets/InnerCirclePopbyMap-BmLUES0A.js","assets/SphereMap-BkD57AyF.js","assets/PropertyIntelligenceDashboard-DIRgcNpq.js","assets/LiveVisitorFeed-CxCTwmKV.js","assets/LeadSites-iRfetOUg.js","assets/LeadSiteEditor-q03HXgNs.js","assets/ImageUrlField-CSs0Gmfp.js","assets/HomepageModuleManager-Dj9wEpA6.js","assets/VideoUrlField-C-Y5Sxug.js","assets/AdminLeadSiteThemes-Dktcy0zv.js","assets/AdminFreeWebsiteOfferStudio-BnqzLeHq.js","assets/AdminMlsFeeds-DqntkeOw.js","assets/AdminWebsiteRequests-ObUQzWRa.js","assets/NeedAWebsite-eBSRzo11.js","assets/MLSListings-BeehWhtz.js","assets/MLSListingDetail-GK6KBiHM.js","assets/WebsiteActivityPage-DQ11hCQ0.js","assets/PublicRecruitForm-3jPRFdfv.js","assets/PublicEventInviteUnsubscribe-CNMaalgU.js","assets/SocialConnections-BZ8wRTyR.js","assets/SocialConnectionsCallback-Bmdoz92C.js","assets/LinkedInCallback-CQRbFuZS.js","assets/TikTokCallback-C8l87Wtp.js","assets/MarketplaceCart-CdIJQBVf.js","assets/MarketplaceOrderDetail-B6IN4cgJ.js","assets/RewardStore-CrVHwX5P.js","assets/ReferFriends-DguuKlq4.js","assets/SmartPresentations-DEpz_vqX.js","assets/useSmartPresentations-CbxOrtnf.js","assets/SmartPresentationCreate-CpdKueCx.js","assets/TeleprompterOverlay-CSOeSbI2.js","assets/GuestBook-CtTjUcIr.js","assets/SignDocument-CJeySc-e.js","assets/Blog-CJa2IvQd.js","assets/TrialCTA-DE65cknc.js","assets/BlogPost-DzoI41L1.js","assets/AdminBlog-CywUw7aD.js","assets/ReviewLanding-BFo77cZ-.js","assets/ReviewIntake-DL0AmW4P.js","assets/PublicReviewsPage--UJdLr5-.js","assets/PublicReviewSubmit-CkxlVlF4.js","assets/Reviews-1h8mVFBq.js","assets/NetSheets-B8T3WoOx.js","assets/LenderHub-tT8_dPE-.js","assets/states-BVqvKcH4.js","assets/LendersLanding-247E87eP.js","assets/LendingPartners-B2RNEupN.js","assets/AdminLenders-BLcXX_pQ.js","assets/CardStudio-DoNIUrKV.js","assets/ListingStudio-CEIDQ9cj.js","assets/SmartDrips-Kwou-ROA.js","assets/WeeklyReels-DfQYaVGw.js","assets/ReelCard-DX3nkBJi.js","assets/useWeeklyReels-CldFNDno.js","assets/WeeklyReelsOnboarding-Dqr3clfH.js","assets/WeeklyReelsAdmin-CkTHrD2t.js","assets/AttractLayout-XujIxRxz.js","assets/useAttractSettings-CoSCjRSa.js","assets/useAttractIntelligence-DasxwNyW.js","assets/HealthScoreBadge-D9leBq8B.js","assets/AttractToday-WLus98Cn.js","assets/useAttractIntelSync-DcEPuog0.js","assets/useAttractAgents-BzRFaHj1.js","assets/useAttractFollowUps-CyAWgcqb.js","assets/useAttractActivities-D_-wQVW2.js","assets/RecommendationCard-cvtwgIAv.js","assets/QuickAddRelationship-Dngx3aTt.js","assets/relationshipStages-Buh5_cBI.js","assets/useAttractEvents-YOZm6bpy.js","assets/AttractRelationships-DAZGTPty.js","assets/AttractPageHeader-GKB0Br2o.js","assets/AgentEditSheet-BtxG2UbY.js","assets/AttractFollowUp-Clz7GCNL.js","assets/AttractTemplates-DEzC6X-r.js","assets/AttractReports-BdHdTTIs.js","assets/AttractSettings-OON_r6DZ.js","assets/AttractToolkit-B4rCjEJR.js","assets/Objections-CeCOC5RG.js","assets/AttractCalculator-mc6BgEMa.js","assets/attractionPageTemplate-C9AaZMgq.js","assets/AttractEventList-D-d22Vxr.js","assets/AttractEventBuilder-CFc0fYPc.js","assets/useAttractKits-mYP7RiFo.js","assets/AttractEventDetail-CfdPPkVV.js","assets/AttractEventCheckIn-SKjshw1X.js","assets/AttractOnboarding-CEcGMJlJ.js","assets/ContentStudio-8l_b12E7.js","assets/KitList-CBj0GdJM.js","assets/KitBuilder-BMP7oQ2-.js","assets/KitPreview-DxS4NTGK.js","assets/KitAnalytics-BNbD9SXc.js","assets/KitTemplates-CP5tuHjK.js","assets/AttractAgentDetail-j7I2Y3ax.js","assets/AttractOpportunities-h5DwvV3O.js","assets/AttractIntelligenceDebug-Cq1w8qX_.js","assets/PublicAttractKit-oFwpaNCx.js","assets/PublicAttractEvent--EcY-klx.js","assets/PublicAttractionPage-kJLUc1Zm.js","assets/AttractionPageView-DLOeSQ1S.js","assets/RevivalLanding-3tozEmN9.js","assets/types-kW6jHCE4.js","assets/RevivalPlan-Chw04kuH.js","assets/revivalPdf-DSAPiwY-.js","assets/ListingRevival-B_bGtdrV.js","assets/useListingRevival-BYrNWzdO.js","assets/AreaChart-CFP8QR26.js","assets/RevivalCampaignWizard-B2mjaxBZ.js","assets/campaignMail-kvoGKNwe.js","assets/RevivalCampaignDetail-hepCC5pY.js","assets/LetterEditor-hbnWsgU8.js","assets/FsboBreakthrough-BDbTT7Gi.js","assets/useFsboBreakthrough-CcuOM1jw.js","assets/types-CK1tolb7.js","assets/FsboPropertyDialog-C8EC5tqI.js","assets/FsboCampaignWizard-B_gkdnh3.js","assets/FsboCampaignDetail-BwJUS0hs.js","assets/FsboLanding-xR14WhYb.js","assets/publicApi-BEaFpcRg.js","assets/FsboGuide-B5AVoV73.js","assets/FsboBreakthroughAdmin-D6xyLvKI.js","assets/AttractLandingPageBuilder-BhE0CnsG.js","assets/AttractAccess-BHs7dED4.js","assets/Teams-BgAO7_XX.js","assets/MyTeam-DrKVSRNH.js","assets/TeamLeaderSettings-DMXy5ZfY.js","assets/TeamHub-CJJ-5jyx.js","assets/SchedulerSettings-DKX3Pav4.js","assets/MyCalendar-BMwXBEKS.js","assets/BookingManagePage-DUdoiQQN.js","assets/LandingPages-BHeb01G_.js","assets/BuyerMatch-BD4kakTy.js","assets/SendBuyerMatchEmailDialog-D8LAJvIB.js","assets/BuyerMatchEditor-Kgtj1jYt.js","assets/matching-BdEgbJjD.js","assets/PublicBuyerMatch-C8pYc-qe.js","assets/LandingPageEditor-BVcn5ORz.js","assets/LandingPageDefaults-Qpiq_HME.js","assets/WebsiteAppsHub-fAHIzbU9.js","assets/ClaimFreeLeadSiteCard-CB1eYWS7.js","assets/useWebsiteApps-CPnIvrlB.js","assets/ClaimWebsite-CeMRWNsU.js","assets/VideoGreeterEditor-CbHJqxpa.js","assets/ExitIntentEditor-DkYNqRsw.js","assets/widgetTemplates-keLygp7O.js","assets/LeadMagnetEditor-2D6hNzdQ.js","assets/RelationshipScorecard-CDi_9jRo.js","assets/SphereGaps-Btwo3HUq.js","assets/ConnectPageSettings-C0uWLoB_.js","assets/EmailCampaigns-WIJX3B4m.js","assets/sesRequest-BsAIPGx-.js","assets/EmailCompliance-DdW7HUXh.js","assets/EmailCampaignComposer-B_xb2kXb.js","assets/EditorModeSelector-90ltg2ce.js","assets/EmailCampaignDetail-dzH31joa.js","assets/SharedCampaignTemplates-DOe7f-nY.js","assets/TemplateEditorDialog-Ct-ZDTN3.js","assets/AgentTemplates-DHAFQIYi.js","assets/TheLocalMoveHome-DHaDrk3v.js","assets/tlm-hero-bg-BbD3acLf.js","assets/TheLocalMoveGetStarted-CXO29jsa.js","assets/TheLocalMoveCheckout-BZothoSO.js","assets/AdminWebsiteOrders-CdNVcO15.js"])))=>i.map(i=>d[i]); var pPe=Object.defineProperty;var LJ=t=>{throw TypeError(t)};var gPe=(t,e,r)=>e in t?pPe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var dn=(t,e,r)=>gPe(t,typeof e!="symbol"?e+"":e,r),WB=(t,e,r)=>e.has(t)||LJ("Cannot "+r);var Et=(t,e,r)=>(WB(t,e,"read from private field"),r?r.call(t):e.get(t)),Jn=(t,e,r)=>e.has(t)?LJ("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),vn=(t,e,r,n)=>(WB(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),qs=(t,e,r)=>(WB(t,e,"access private method"),r);var $P=(t,e,r,n)=>({set _(s){vn(t,e,s,r)},get _(){return Et(t,e,n)}});function yPe(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 nc=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function hi(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function xPe(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 Fde={exports:{}},FO={},Bde={exports:{}},Zs={};/** * @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 _N=Symbol.for("react.element"),vPe=Symbol.for("react.portal"),_Pe=Symbol.for("react.fragment"),bPe=Symbol.for("react.strict_mode"),wPe=Symbol.for("react.profiler"),SPe=Symbol.for("react.provider"),TPe=Symbol.for("react.context"),EPe=Symbol.for("react.forward_ref"),jPe=Symbol.for("react.suspense"),APe=Symbol.for("react.memo"),kPe=Symbol.for("react.lazy"),MJ=Symbol.iterator;function NPe(t){return t===null||typeof t!="object"?null:(t=MJ&&t[MJ]||t["@@iterator"],typeof t=="function"?t:null)}var $de={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},zde=Object.assign,Ude={};function rT(t,e,r){this.props=t,this.context=e,this.refs=Ude,this.updater=r||$de}rT.prototype.isReactComponent={};rT.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")};rT.prototype.forceUpdate=function(t){this.updater.enqueueForceUpdate(this,t,"forceUpdate")};function Vde(){}Vde.prototype=rT.prototype;function BG(t,e,r){this.props=t,this.context=e,this.refs=Ude,this.updater=r||$de}var $G=BG.prototype=new Vde;$G.constructor=BG;zde($G,rT.prototype);$G.isPureReactComponent=!0;var DJ=Array.isArray,qde=Object.prototype.hasOwnProperty,zG={current:null},Gde={key:!0,ref:!0,__self:!0,__source:!0};function Hde(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)qde.call(e,n)&&!Gde.hasOwnProperty(n)&&(s[n]=e[n]);var a=arguments.length-2;if(a===1)s.children=r;else if(1>>1,ve=me[Ee];if(0>>1;Ees(ot,_e))jts(vt,ot)?(me[Ee]=vt,me[jt]=_e,Ee=jt):(me[Ee]=ot,me[nt]=_e,Ee=nt);else if(jts(vt,_e))me[Ee]=vt,me[jt]=_e,Ee=jt;else break e}}return je}function s(me,je){var _e=me.sortIndex-je.sortIndex;return _e!==0?_e:me.id-je.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=[],p=[],y=1,v=null,S=3,E=!1,k=!1,R=!1,P=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 je=r(p);je!==null;){if(je.callback===null)n(p);else if(je.startTime<=me)n(p),je.sortIndex=je.expirationTime,e(f,je);else break;je=r(p)}}function V(me){if(R=!1,B(me),!k)if(r(f)!==null)k=!0,ke(G);else{var je=r(p);je!==null&&we(V,je.startTime-me)}}function G(me,je){k=!1,R&&(R=!1,M(J),J=-1),E=!0;var _e=S;try{for(B(je),v=r(f);v!==null&&(!(v.expirationTime>je)||me&&!le());){var Ee=v.callback;if(typeof Ee=="function"){v.callback=null,S=v.priorityLevel;var ve=Ee(v.expirationTime<=je);je=t.unstable_now(),typeof ve=="function"?v.callback=ve:v===r(f)&&n(f),B(je)}else n(f);v=r(f)}if(v!==null)var qe=!0;else{var nt=r(p);nt!==null&&we(V,nt.startTime-je),qe=!1}return qe}finally{v=null,S=_e,E=!1}}var W=!1,Y=null,J=-1,Q=5,ee=-1;function le(){return!(t.unstable_now()-eeme||125Ee?(me.sortIndex=_e,e(p,me),r(f)===null&&me===r(p)&&(R?(M(J),J=-1):R=!0,we(V,_e-Ee))):(me.sortIndex=ve,e(f,me),k||E||(k=!0,ke(G))),me},t.unstable_shouldYield=le,t.unstable_wrapCallback=function(me){var je=S;return function(){var _e=S;S=je;try{return me.apply(this,arguments)}finally{S=_e}}}})(Xde);Zde.exports=Xde;var $Pe=Zde.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 zPe=N,vd=$Pe;function Vr(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"),Q6=Object.prototype.hasOwnProperty,UPe=/^[: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]*$/,FJ={},BJ={};function VPe(t){return Q6.call(BJ,t)?!0:Q6.call(FJ,t)?!1:UPe.test(t)?BJ[t]=!0:(FJ[t]=!0,!1)}function qPe(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 GPe(t,e,r,n){if(e===null||typeof e>"u"||qPe(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 ou(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 lc={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){lc[t]=new ou(t,0,!1,t,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var e=t[0];lc[e]=new ou(e,1,!1,t[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(t){lc[t]=new ou(t,2,!1,t.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){lc[t]=new ou(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){lc[t]=new ou(t,3,!1,t.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(t){lc[t]=new ou(t,3,!0,t,null,!1,!1)});["capture","download"].forEach(function(t){lc[t]=new ou(t,4,!1,t,null,!1,!1)});["cols","rows","size","span"].forEach(function(t){lc[t]=new ou(t,6,!1,t,null,!1,!1)});["rowSpan","start"].forEach(function(t){lc[t]=new ou(t,5,!1,t.toLowerCase(),null,!1,!1)});var qG=/[\-:]([a-z])/g;function GG(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(qG,GG);lc[e]=new ou(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(qG,GG);lc[e]=new ou(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(qG,GG);lc[e]=new ou(e,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(t){lc[t]=new ou(t,1,!1,t.toLowerCase(),null,!1,!1)});lc.xlinkHref=new ou("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(t){lc[t]=new ou(t,1,!1,t.toLowerCase(),null,!0,!0)});function HG(t,e,r,n){var s=lc.hasOwnProperty(e)?lc[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{ZB=!1,Error.prepareStackTrace=r}return(t=t?t.displayName||t.name:"")?U2(t):""}function HPe(t){switch(t.tag){case 5:return U2(t.type);case 16:return U2("Lazy");case 13:return U2("Suspense");case 19:return U2("SuspenseList");case 0:case 2:case 15:return t=XB(t.type,!1),t;case 11:return t=XB(t.type.render,!1),t;case 1:return t=XB(t.type,!0),t;default:return""}}function rU(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 Xw:return"Fragment";case Zw:return"Portal";case J6:return"Profiler";case WG:return"StrictMode";case eU:return"Suspense";case tU:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case ehe:return(t.displayName||"Context")+".Consumer";case Jde:return(t._context.displayName||"Context")+".Provider";case KG:var e=t.render;return t=t.displayName,t||(t=e.displayName||e.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case YG:return e=t.displayName||null,e!==null?e:rU(t.type)||"Memo";case Ay:e=t._payload,t=t._init;try{return rU(t(e))}catch{}}return null}function WPe(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 rU(e);case 8:return e===WG?"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 mx(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function rhe(t){var e=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(e==="checkbox"||e==="radio")}function KPe(t){var e=rhe(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 VP(t){t._valueTracker||(t._valueTracker=KPe(t))}function nhe(t){if(!t)return!1;var e=t._valueTracker;if(!e)return!0;var r=e.getValue(),n="";return t&&(n=rhe(t)?t.checked?"true":"false":t.value),t=n,t!==r?(e.setValue(t),!0):!1}function cM(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 nU(t,e){var r=e.checked;return lo({},e,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:r??t._wrapperState.initialChecked})}function zJ(t,e){var r=e.defaultValue==null?"":e.defaultValue,n=e.checked!=null?e.checked:e.defaultChecked;r=mx(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 she(t,e){e=e.checked,e!=null&&HG(t,"checked",e,!1)}function sU(t,e){she(t,e);var r=mx(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")?iU(t,e.type,r):e.hasOwnProperty("defaultValue")&&iU(t,e.type,mx(e.defaultValue)),e.checked==null&&e.defaultChecked!=null&&(t.defaultChecked=!!e.defaultChecked)}function UJ(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 iU(t,e,r){(e!=="number"||cM(t.ownerDocument)!==t)&&(r==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+r&&(t.defaultValue=""+r))}var V2=Array.isArray;function v1(t,e,r,n){if(t=t.options,e){e={};for(var s=0;s"+e.valueOf().toString()+"",e=qP.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;e.firstChild;)t.appendChild(e.firstChild)}});function DA(t,e){if(e){var r=t.firstChild;if(r&&r===t.lastChild&&r.nodeType===3){r.nodeValue=e;return}}t.textContent=e}var rA={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},YPe=["Webkit","ms","Moz","O"];Object.keys(rA).forEach(function(t){YPe.forEach(function(e){e=e+t.charAt(0).toUpperCase()+t.substring(1),rA[e]=rA[t]})});function lhe(t,e,r){return e==null||typeof e=="boolean"||e===""?"":r||typeof e!="number"||e===0||rA.hasOwnProperty(t)&&rA[t]?(""+e).trim():e+"px"}function che(t,e){t=t.style;for(var r in e)if(e.hasOwnProperty(r)){var n=r.indexOf("--")===0,s=lhe(r,e[r],n);r==="float"&&(r="cssFloat"),n?t.setProperty(r,s):t[r]=s}}var ZPe=lo({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 lU(t,e){if(e){if(ZPe[t]&&(e.children!=null||e.dangerouslySetInnerHTML!=null))throw Error(Vr(137,t));if(e.dangerouslySetInnerHTML!=null){if(e.children!=null)throw Error(Vr(60));if(typeof e.dangerouslySetInnerHTML!="object"||!("__html"in e.dangerouslySetInnerHTML))throw Error(Vr(61))}if(e.style!=null&&typeof e.style!="object")throw Error(Vr(62))}}function cU(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 uU=null;function ZG(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var dU=null,_1=null,b1=null;function GJ(t){if(t=SN(t)){if(typeof dU!="function")throw Error(Vr(280));var e=t.stateNode;e&&(e=VO(e),dU(t.stateNode,t.type,e))}}function uhe(t){_1?b1?b1.push(t):b1=[t]:_1=t}function dhe(){if(_1){var t=_1,e=b1;if(b1=_1=null,GJ(t),e)for(t=0;t>>=0,t===0?32:31-(oRe(t)/lRe|0)|0}var GP=64,HP=4194304;function q2(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 fM(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=q2(a):(o&=c,o!==0&&(n=q2(o)))}else c=r&~s,c!==0?n=q2(c):o!==0&&(n=q2(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 bN(t,e,r){t.pendingLanes|=e,e!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,e=31-ff(e),t[e]=r}function hRe(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=sA),eee=" ",tee=!1;function Ihe(t,e){switch(t){case"keyup":return $Re.indexOf(e.keyCode)!==-1;case"keydown":return e.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Phe(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var Qw=!1;function URe(t,e){switch(t){case"compositionend":return Phe(e);case"keypress":return e.which!==32?null:(tee=!0,eee);case"textInput":return t=e.data,t===eee&&tee?null:t;default:return null}}function VRe(t,e){if(Qw)return t==="compositionend"||!s9&&Ihe(t,e)?(t=Nhe(),vL=t9=Ky=null,Qw=!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=iee(r)}}function Dhe(t,e){return t&&e?t===e?!0:t&&t.nodeType===3?!1:e&&e.nodeType===3?Dhe(t,e.parentNode):"contains"in t?t.contains(e):t.compareDocumentPosition?!!(t.compareDocumentPosition(e)&16):!1:!1}function Ohe(){for(var t=window,e=cM();e instanceof t.HTMLIFrameElement;){try{var r=typeof e.contentWindow.location.href=="string"}catch{r=!1}if(r)t=e.contentWindow;else break;e=cM(t.document)}return e}function i9(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 QRe(t){var e=Ohe(),r=t.focusedElem,n=t.selectionRange;if(e!==r&&r&&r.ownerDocument&&Dhe(r.ownerDocument.documentElement,r)){if(n!==null&&i9(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=aee(r,o);var c=aee(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,Jw=null,yU=null,aA=null,xU=!1;function oee(t,e,r){var n=r.window===r?r.document:r.nodeType===9?r:r.ownerDocument;xU||Jw==null||Jw!==cM(n)||(n=Jw,"selectionStart"in n&&i9(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}),aA&&UA(aA,n)||(aA=n,n=gM(yU,"onSelect"),0r1||(t.current=TU[r1],TU[r1]=null,r1--)}function va(t,e){r1++,TU[r1]=t.current,t.current=e}var px={},Ec=Mx(px),Lu=Mx(!1),s_=px;function nS(t,e){var r=t.type.contextTypes;if(!r)return px;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 Mu(t){return t=t.childContextTypes,t!=null}function xM(){Da(Lu),Da(Ec)}function mee(t,e,r){if(Ec.current!==px)throw Error(Vr(168));va(Ec,e),va(Lu,r)}function Hhe(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(Vr(108,WPe(t)||"Unknown",s));return lo({},r,n)}function vM(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||px,s_=Ec.current,va(Ec,t),va(Lu,Lu.current),!0}function pee(t,e,r){var n=t.stateNode;if(!n)throw Error(Vr(169));r?(t=Hhe(t,e,s_),n.__reactInternalMemoizedMergedChildContext=t,Da(Lu),Da(Ec),va(Ec,t)):Da(Lu),va(Lu,r)}var Op=null,qO=!1,d$=!1;function Whe(t){Op===null?Op=[t]:Op.push(t)}function uLe(t){qO=!0,Whe(t)}function Dx(){if(!d$&&Op!==null){d$=!0;var t=0,e=Hi;try{var r=Op;for(Hi=1;t>=c,s-=c,Vp=1<<32-ff(e)+s|r<J?(Q=Y,Y=null):Q=Y.sibling;var ee=S(M,Y,B[J],V);if(ee===null){Y===null&&(Y=Q);break}t&&Y&&ee.alternate===null&&e(M,Y),D=o(ee,D,J),W===null?G=ee:W.sibling=ee,W=ee,Y=Q}if(J===B.length)return r(M,Y),Ga&&xv(M,J),G;if(Y===null){for(;JJ?(Q=Y,Y=null):Q=Y.sibling;var le=S(M,Y,ee.value,V);if(le===null){Y===null&&(Y=Q);break}t&&Y&&le.alternate===null&&e(M,Y),D=o(le,D,J),W===null?G=le:W.sibling=le,W=le,Y=Q}if(ee.done)return r(M,Y),Ga&&xv(M,J),G;if(Y===null){for(;!ee.done;J++,ee=B.next())ee=v(M,ee.value,V),ee!==null&&(D=o(ee,D,J),W===null?G=ee:W.sibling=ee,W=ee);return Ga&&xv(M,J),G}for(Y=n(M,Y);!ee.done;J++,ee=B.next())ee=E(Y,M,J,ee.value,V),ee!==null&&(t&&ee.alternate!==null&&Y.delete(ee.key===null?J:ee.key),D=o(ee,D,J),W===null?G=ee:W.sibling=ee,W=ee);return t&&Y.forEach(function(pe){return e(M,pe)}),Ga&&xv(M,J),G}function P(M,D,B,V){if(typeof B=="object"&&B!==null&&B.type===Xw&&B.key===null&&(B=B.props.children),typeof B=="object"&&B!==null){switch(B.$$typeof){case UP:e:{for(var G=B.key,W=D;W!==null;){if(W.key===G){if(G=B.type,G===Xw){if(W.tag===7){r(M,W.sibling),D=s(W,B.props.children),D.return=M,M=D;break e}}else if(W.elementType===G||typeof G=="object"&&G!==null&&G.$$typeof===Ay&&xee(G)===W.type){r(M,W.sibling),D=s(W,B.props),D.ref=o2(M,W,B),D.return=M,M=D;break e}r(M,W);break}else e(M,W);W=W.sibling}B.type===Xw?(D=Xv(B.props.children,M.mode,V,B.key),D.return=M,M=D):(V=AL(B.type,B.key,B.props,null,M.mode,V),V.ref=o2(M,D,B),V.return=M,M=V)}return c(M);case Zw:e:{for(W=B.key;D!==null;){if(D.key===W)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=v$(B,M.mode,V),D.return=M,M=D}return c(M);case Ay:return W=B._init,P(M,D,W(B._payload),V)}if(V2(B))return k(M,D,B,V);if(r2(B))return R(M,D,B,V);JP(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=x$(B,M.mode,V),D.return=M,M=D),c(M)):r(M,D)}return P}var iS=Xhe(!0),Qhe=Xhe(!1),wM=Mx(null),SM=null,i1=null,c9=null;function u9(){c9=i1=SM=null}function d9(t){var e=wM.current;Da(wM),t._currentValue=e}function AU(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 S1(t,e){SM=t,c9=i1=null,t=t.dependencies,t!==null&&t.firstContext!==null&&(t.lanes&e&&(Iu=!0),t.firstContext=null)}function fh(t){var e=t._currentValue;if(c9!==t)if(t={context:t,memoizedValue:e,next:null},i1===null){if(SM===null)throw Error(Vr(308));i1=t,SM.dependencies={lanes:0,firstContext:t}}else i1=i1.next=t;return e}var Iv=null;function h9(t){Iv===null?Iv=[t]:Iv.push(t)}function Jhe(t,e,r,n){var s=e.interleaved;return s===null?(r.next=r,h9(e)):(r.next=s.next,s.next=r),e.interleaved=r,sg(t,n)}function sg(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 ky=!1;function f9(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function efe(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 Kp(t,e){return{eventTime:t,lane:e,tag:0,payload:null,callback:null,next:null}}function nx(t,e,r){var n=t.updateQueue;if(n===null)return null;if(n=n.shared,gi&2){var s=n.pending;return s===null?e.next=e:(e.next=s.next,s.next=e),n.pending=e,sg(t,r)}return s=n.interleaved,s===null?(e.next=e,h9(n)):(e.next=s.next,s.next=e),n.interleaved=e,sg(t,r)}function bL(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,QG(t,r)}}function vee(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 TM(t,e,r,n){var s=t.updateQueue;ky=!1;var o=s.firstBaseUpdate,c=s.lastBaseUpdate,a=s.shared.pending;if(a!==null){s.shared.pending=null;var f=a,p=f.next;f.next=null,c===null?o=p:c.next=p,c=f;var y=t.alternate;y!==null&&(y=y.updateQueue,a=y.lastBaseUpdate,a!==c&&(a===null?y.firstBaseUpdate=p:a.next=p,y.lastBaseUpdate=f))}if(o!==null){var v=s.baseState;c=0,y=p=f=null,a=o;do{var S=a.lane,E=a.eventTime;if((n&S)===S){y!==null&&(y=y.next={eventTime:E,lane:0,tag:a.tag,payload:a.payload,callback:a.callback,next:null});e:{var k=t,R=a;switch(S=e,E=r,R.tag){case 1:if(k=R.payload,typeof k=="function"){v=k.call(E,v,S);break e}v=k;break e;case 3:k.flags=k.flags&-65537|128;case 0:if(k=R.payload,S=typeof k=="function"?k.call(E,v,S):k,S==null)break e;v=lo({},v,S);break e;case 2:ky=!0}}a.callback!==null&&a.lane!==0&&(t.flags|=64,S=s.effects,S===null?s.effects=[a]:S.push(a))}else E={eventTime:E,lane:S,tag:a.tag,payload:a.payload,callback:a.callback,next:null},y===null?(p=y=E,f=v):y=y.next=E,c|=S;if(a=a.next,a===null){if(a=s.shared.pending,a===null)break;S=a,a=S.next,S.next=null,s.lastBaseUpdate=S,s.shared.pending=null}}while(!0);if(y===null&&(f=v),s.baseState=f,s.firstBaseUpdate=p,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);o_|=c,t.lanes=c,t.memoizedState=v}}function _ee(t,e,r){if(t=e.effects,e.effects=null,t!==null)for(e=0;er?r:4,t(!0);var n=f$.transition;f$.transition={};try{t(!1),e()}finally{Hi=r,f$.transition=n}}function yfe(){return mh().memoizedState}function mLe(t,e,r){var n=ix(t);if(r={lane:n,action:r,hasEagerState:!1,eagerState:null,next:null},xfe(t))vfe(e,r);else if(r=Jhe(t,e,r,n),r!==null){var s=su();mf(r,t,n,s),_fe(r,e,n)}}function pLe(t,e,r){var n=ix(t),s={lane:n,action:r,hasEagerState:!1,eagerState:null,next:null};if(xfe(t))vfe(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,vf(a,c)){var f=e.interleaved;f===null?(s.next=s,h9(e)):(s.next=f.next,f.next=s),e.interleaved=s;return}}catch{}finally{}r=Jhe(t,e,s,n),r!==null&&(s=su(),mf(r,t,n,s),_fe(r,e,n))}}function xfe(t){var e=t.alternate;return t===ao||e!==null&&e===ao}function vfe(t,e){oA=jM=!0;var r=t.pending;r===null?e.next=e:(e.next=r.next,r.next=e),t.pending=e}function _fe(t,e,r){if(r&4194240){var n=e.lanes;n&=t.pendingLanes,r|=n,e.lanes=r,QG(t,r)}}var AM={readContext:fh,useCallback:xc,useContext:xc,useEffect:xc,useImperativeHandle:xc,useInsertionEffect:xc,useLayoutEffect:xc,useMemo:xc,useReducer:xc,useRef:xc,useState:xc,useDebugValue:xc,useDeferredValue:xc,useTransition:xc,useMutableSource:xc,useSyncExternalStore:xc,useId:xc,unstable_isNewReconciler:!1},gLe={readContext:fh,useCallback:function(t,e){return rm().memoizedState=[t,e===void 0?null:e],t},useContext:fh,useEffect:wee,useImperativeHandle:function(t,e,r){return r=r!=null?r.concat([t]):null,SL(4194308,4,hfe.bind(null,e,t),r)},useLayoutEffect:function(t,e){return SL(4194308,4,t,e)},useInsertionEffect:function(t,e){return SL(4,2,t,e)},useMemo:function(t,e){var r=rm();return e=e===void 0?null:e,t=t(),r.memoizedState=[t,e],t},useReducer:function(t,e,r){var n=rm();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=mLe.bind(null,ao,t),[n.memoizedState,t]},useRef:function(t){var e=rm();return t={current:t},e.memoizedState=t},useState:bee,useDebugValue:b9,useDeferredValue:function(t){return rm().memoizedState=t},useTransition:function(){var t=bee(!1),e=t[0];return t=fLe.bind(null,t[1]),rm().memoizedState=t,[e,t]},useMutableSource:function(){},useSyncExternalStore:function(t,e,r){var n=ao,s=rm();if(Ga){if(r===void 0)throw Error(Vr(407));r=r()}else{if(r=e(),Ol===null)throw Error(Vr(349));a_&30||sfe(n,e,r)}s.memoizedState=r;var o={value:r,getSnapshot:e};return s.queue=o,wee(afe.bind(null,n,o,t),[t]),n.flags|=2048,ZA(9,ife.bind(null,n,o,r,e),void 0,null),r},useId:function(){var t=rm(),e=Ol.identifierPrefix;if(Ga){var r=qp,n=Vp;r=(n&~(1<<32-ff(n)-1)).toString(32)+r,e=":"+e+"R"+r,r=KA++,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[um]=e,t[GA]=n,Cfe(t,e,!1,!1),e.stateNode=t;e:{switch(c=cU(r,n),r){case"dialog":Pa("cancel",t),Pa("close",t),s=n;break;case"iframe":case"object":case"embed":Pa("load",t),s=n;break;case"video":case"audio":for(s=0;slS&&(e.flags|=128,n=!0,l2(o,!1),e.lanes=4194304)}else{if(!n)if(t=EM(c),t!==null){if(e.flags|=128,n=!0,r=t.updateQueue,r!==null&&(e.updateQueue=r,e.flags|=4),l2(o,!0),o.tail===null&&o.tailMode==="hidden"&&!c.alternate&&!Ga)return vc(e),null}else 2*Co()-o.renderingStartTime>lS&&r!==1073741824&&(e.flags|=128,n=!0,l2(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=Co(),e.sibling=null,r=ro.current,va(ro,n?r&1|2:r&1),e):(vc(e),null);case 22:case 23:return A9(),n=e.memoizedState!==null,t!==null&&t.memoizedState!==null!==n&&(e.flags|=8192),n&&e.mode&1?ad&1073741824&&(vc(e),e.subtreeFlags&6&&(e.flags|=8192)):vc(e),null;case 24:return null;case 25:return null}throw Error(Vr(156,e.tag))}function TLe(t,e){switch(o9(e),e.tag){case 1:return Mu(e.type)&&xM(),t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 3:return aS(),Da(Lu),Da(Ec),g9(),t=e.flags,t&65536&&!(t&128)?(e.flags=t&-65537|128,e):null;case 5:return p9(e),null;case 13:if(Da(ro),t=e.memoizedState,t!==null&&t.dehydrated!==null){if(e.alternate===null)throw Error(Vr(340));sS()}return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 19:return Da(ro),null;case 4:return aS(),null;case 10:return d9(e.type._context),null;case 22:case 23:return A9(),null;case 24:return null;default:return null}}var tR=!1,wc=!1,ELe=typeof WeakSet=="function"?WeakSet:Set,An=null;function a1(t,e){var r=t.ref;if(r!==null)if(typeof r=="function")try{r(null)}catch(n){xo(t,e,n)}else r.current=null}function DU(t,e,r){try{r()}catch(n){xo(t,e,n)}}var Ree=!1;function jLe(t,e){if(vU=mM,t=Ohe(),i9(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,p=0,y=0,v=t,S=null;t:for(;;){for(var E;v!==r||s!==0&&v.nodeType!==3||(a=c+s),v!==o||n!==0&&v.nodeType!==3||(f=c+n),v.nodeType===3&&(c+=v.nodeValue.length),(E=v.firstChild)!==null;)S=v,v=E;for(;;){if(v===t)break t;if(S===r&&++p===s&&(a=c),S===o&&++y===n&&(f=c),(E=v.nextSibling)!==null)break;v=S,S=v.parentNode}v=E}r=a===-1||f===-1?null:{start:a,end:f}}else r=null}r=r||{start:0,end:0}}else r=null;for(_U={focusedElem:t,selectionRange:r},mM=!1,An=e;An!==null;)if(e=An,t=e.child,(e.subtreeFlags&1028)!==0&&t!==null)t.return=e,An=t;else for(;An!==null;){e=An;try{var k=e.alternate;if(e.flags&1024)switch(e.tag){case 0:case 11:case 15:break;case 1:if(k!==null){var R=k.memoizedProps,P=k.memoizedState,M=e.stateNode,D=M.getSnapshotBeforeUpdate(e.elementType===e.type?R:Zh(e.type,R),P);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(Vr(163))}}catch(V){xo(e,e.return,V)}if(t=e.sibling,t!==null){t.return=e.return,An=t;break}An=e.return}return k=Ree,Ree=!1,k}function lA(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&&DU(e,r,o)}s=s.next}while(s!==n)}}function WO(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 OU(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 Rfe(t){var e=t.alternate;e!==null&&(t.alternate=null,Rfe(e)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(e=t.stateNode,e!==null&&(delete e[um],delete e[GA],delete e[SU],delete e[lLe],delete e[cLe])),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 Lfe(t){return t.tag===5||t.tag===3||t.tag===4}function Lee(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||Lfe(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 FU(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=yM));else if(n!==4&&(t=t.child,t!==null))for(FU(t,e,r),t=t.sibling;t!==null;)FU(t,e,r),t=t.sibling}function BU(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(BU(t,e,r),t=t.sibling;t!==null;)BU(t,e,r),t=t.sibling}var Kl=null,Jh=!1;function hy(t,e,r){for(r=r.child;r!==null;)Mfe(t,e,r),r=r.sibling}function Mfe(t,e,r){if(_m&&typeof _m.onCommitFiberUnmount=="function")try{_m.onCommitFiberUnmount(BO,r)}catch{}switch(r.tag){case 5:wc||a1(r,e);case 6:var n=Kl,s=Jh;Kl=null,hy(t,e,r),Kl=n,Jh=s,Kl!==null&&(Jh?(t=Kl,r=r.stateNode,t.nodeType===8?t.parentNode.removeChild(r):t.removeChild(r)):Kl.removeChild(r.stateNode));break;case 18:Kl!==null&&(Jh?(t=Kl,r=r.stateNode,t.nodeType===8?u$(t.parentNode,r):t.nodeType===1&&u$(t,r),$A(t)):u$(Kl,r.stateNode));break;case 4:n=Kl,s=Jh,Kl=r.stateNode.containerInfo,Jh=!0,hy(t,e,r),Kl=n,Jh=s;break;case 0:case 11:case 14:case 15:if(!wc&&(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)&&DU(r,e,c),s=s.next}while(s!==n)}hy(t,e,r);break;case 1:if(!wc&&(a1(r,e),n=r.stateNode,typeof n.componentWillUnmount=="function"))try{n.props=r.memoizedProps,n.state=r.memoizedState,n.componentWillUnmount()}catch(a){xo(r,e,a)}hy(t,e,r);break;case 21:hy(t,e,r);break;case 22:r.mode&1?(wc=(n=wc)||r.memoizedState!==null,hy(t,e,r),wc=n):hy(t,e,r);break;default:hy(t,e,r)}}function Mee(t){var e=t.updateQueue;if(e!==null){t.updateQueue=null;var r=t.stateNode;r===null&&(r=t.stateNode=new ELe),e.forEach(function(n){var s=MLe.bind(null,t,n);r.has(n)||(r.add(n),n.then(s,s))})}}function $h(t,e){var r=e.deletions;if(r!==null)for(var n=0;ns&&(s=c),n&=~o}if(n=s,n=Co()-n,n=(120>n?120:480>n?480:1080>n?1080:1920>n?1920:3e3>n?3e3:4320>n?4320:1960*kLe(n/1960))-n,10t?16:t,Yy===null)var n=!1;else{if(t=Yy,Yy=null,CM=0,gi&6)throw Error(Vr(331));var s=gi;for(gi|=4,An=t.current;An!==null;){var o=An,c=o.child;if(An.flags&16){var a=o.deletions;if(a!==null){for(var f=0;fCo()-E9?Zv(t,0):T9|=r),Du(t,e)}function Vfe(t,e){e===0&&(t.mode&1?(e=HP,HP<<=1,!(HP&130023424)&&(HP=4194304)):e=1);var r=su();t=sg(t,e),t!==null&&(bN(t,e,r),Du(t,r))}function LLe(t){var e=t.memoizedState,r=0;e!==null&&(r=e.retryLane),Vfe(t,r)}function MLe(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(Vr(314))}n!==null&&n.delete(e),Vfe(t,r)}var qfe;qfe=function(t,e,r){if(t!==null)if(t.memoizedProps!==e.pendingProps||Lu.current)Iu=!0;else{if(!(t.lanes&r)&&!(e.flags&128))return Iu=!1,wLe(t,e,r);Iu=!!(t.flags&131072)}else Iu=!1,Ga&&e.flags&1048576&&Khe(e,bM,e.index);switch(e.lanes=0,e.tag){case 2:var n=e.type;TL(t,e),t=e.pendingProps;var s=nS(e,Ec.current);S1(e,r),s=x9(null,e,n,t,s,r);var o=v9();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,Mu(n)?(o=!0,vM(e)):o=!1,e.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,f9(e),s.updater=HO,e.stateNode=s,s._reactInternals=e,NU(e,n,t,r),e=PU(null,e,n,!0,o,r)):(e.tag=0,Ga&&o&&a9(e),Kc(null,e,s,r),e=e.child),e;case 16:n=e.elementType;e:{switch(TL(t,e),t=e.pendingProps,s=n._init,n=s(n._payload),e.type=n,s=e.tag=OLe(n),t=Zh(n,t),s){case 0:e=IU(null,e,n,t,r);break e;case 1:e=Cee(null,e,n,t,r);break e;case 11:e=kee(null,e,n,t,r);break e;case 14:e=Nee(null,e,n,Zh(n.type,t),r);break e}throw Error(Vr(306,n,""))}return e;case 0:return n=e.type,s=e.pendingProps,s=e.elementType===n?s:Zh(n,s),IU(t,e,n,s,r);case 1:return n=e.type,s=e.pendingProps,s=e.elementType===n?s:Zh(n,s),Cee(t,e,n,s,r);case 3:e:{if(Afe(e),t===null)throw Error(Vr(387));n=e.pendingProps,o=e.memoizedState,s=o.element,efe(t,e),TM(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=oS(Error(Vr(423)),e),e=Iee(t,e,n,r,s);break e}else if(n!==s){s=oS(Error(Vr(424)),e),e=Iee(t,e,n,r,s);break e}else for(hd=rx(e.stateNode.containerInfo.firstChild),pd=e,Ga=!0,nf=null,r=Qhe(e,null,n,r),e.child=r;r;)r.flags=r.flags&-3|4096,r=r.sibling;else{if(sS(),n===s){e=ig(t,e,r);break e}Kc(t,e,n,r)}e=e.child}return e;case 5:return tfe(e),t===null&&jU(e),n=e.type,s=e.pendingProps,o=t!==null?t.memoizedProps:null,c=s.children,bU(n,s)?c=null:o!==null&&bU(n,o)&&(e.flags|=32),jfe(t,e),Kc(t,e,c,r),e.child;case 6:return t===null&&jU(e),null;case 13:return kfe(t,e,r);case 4:return m9(e,e.stateNode.containerInfo),n=e.pendingProps,t===null?e.child=iS(e,null,n,r):Kc(t,e,n,r),e.child;case 11:return n=e.type,s=e.pendingProps,s=e.elementType===n?s:Zh(n,s),kee(t,e,n,s,r);case 7:return Kc(t,e,e.pendingProps,r),e.child;case 8:return Kc(t,e,e.pendingProps.children,r),e.child;case 12:return Kc(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,va(wM,n._currentValue),n._currentValue=c,o!==null)if(vf(o.value,c)){if(o.children===s.children&&!Lu.current){e=ig(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=Kp(-1,r&-r),f.tag=2;var p=o.updateQueue;if(p!==null){p=p.shared;var y=p.pending;y===null?f.next=f:(f.next=y.next,y.next=f),p.pending=f}}o.lanes|=r,f=o.alternate,f!==null&&(f.lanes|=r),AU(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(Vr(341));c.lanes|=r,a=c.alternate,a!==null&&(a.lanes|=r),AU(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}Kc(t,e,s.children,r),e=e.child}return e;case 9:return s=e.type,n=e.pendingProps.children,S1(e,r),s=fh(s),n=n(s),e.flags|=1,Kc(t,e,n,r),e.child;case 14:return n=e.type,s=Zh(n,e.pendingProps),s=Zh(n.type,s),Nee(t,e,n,s,r);case 15:return Tfe(t,e,e.type,e.pendingProps,r);case 17:return n=e.type,s=e.pendingProps,s=e.elementType===n?s:Zh(n,s),TL(t,e),e.tag=1,Mu(n)?(t=!0,vM(e)):t=!1,S1(e,r),bfe(e,n,s),NU(e,n,s,r),PU(null,e,n,!0,t,r);case 19:return Nfe(t,e,r);case 22:return Efe(t,e,r)}throw Error(Vr(156,e.tag))};function Gfe(t,e){return xhe(t,e)}function DLe(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 sh(t,e,r,n){return new DLe(t,e,r,n)}function N9(t){return t=t.prototype,!(!t||!t.isReactComponent)}function OLe(t){if(typeof t=="function")return N9(t)?1:0;if(t!=null){if(t=t.$$typeof,t===KG)return 11;if(t===YG)return 14}return 2}function ax(t,e){var r=t.alternate;return r===null?(r=sh(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 AL(t,e,r,n,s,o){var c=2;if(n=t,typeof t=="function")N9(t)&&(c=1);else if(typeof t=="string")c=5;else e:switch(t){case Xw:return Xv(r.children,s,o,e);case WG:c=8,s|=8;break;case J6:return t=sh(12,r,e,s|2),t.elementType=J6,t.lanes=o,t;case eU:return t=sh(13,r,e,s),t.elementType=eU,t.lanes=o,t;case tU:return t=sh(19,r,e,s),t.elementType=tU,t.lanes=o,t;case the:return YO(r,s,o,e);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case Jde:c=10;break e;case ehe:c=9;break e;case KG:c=11;break e;case YG:c=14;break e;case Ay:c=16,n=null;break e}throw Error(Vr(130,t==null?t:typeof t,""))}return e=sh(c,r,e,s),e.elementType=t,e.type=n,e.lanes=o,e}function Xv(t,e,r,n){return t=sh(7,t,n,e),t.lanes=r,t}function YO(t,e,r,n){return t=sh(22,t,n,e),t.elementType=the,t.lanes=r,t.stateNode={isHidden:!1},t}function x$(t,e,r){return t=sh(6,t,null,e),t.lanes=r,t}function v$(t,e,r){return e=sh(4,t.children!==null?t.children:[],t.key,e),e.lanes=r,e.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},e}function FLe(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=JB(0),this.expirationTimes=JB(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=JB(0),this.identifierPrefix=n,this.onRecoverableError=s,this.mutableSourceEagerHydrationData=null}function C9(t,e,r,n,s,o,c,a,f){return t=new FLe(t,e,r,a,f),e===1?(e=1,o===!0&&(e|=8)):e=0,o=sh(3,null,null,e),t.current=o,o.stateNode=t,o.memoizedState={element:n,isDehydrated:r,cache:null,transitions:null,pendingSuspenseBoundaries:null},f9(o),t}function BLe(t,e,r){var n=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(Yfe)}catch(t){console.error(t)}}Yfe(),Yde.exports=jd;var xg=Yde.exports;const Zfe=hi(xg);var Xfe,Vee=xg;Xfe=Vee.createRoot,Vee.hydrateRoot;const qLe="modulepreload",GLe=function(t){return"/"+t},qee={},Fe=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=GLe(f),f in qee)return;qee[f]=!0;const p=f.endsWith(".css"),y=p?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${y}`))return;const v=document.createElement("link");if(v.rel=p?"stylesheet":qLe,p||(v.as="script"),v.crossOrigin="",v.href=f,a&&v.setAttribute("nonce",a),document.head.appendChild(v),p)return new Promise((S,E)=>{v.addEventListener("load",S),v.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)})},HLe=new Set(["localhost","relevelup.com","thelocalmove.com","www.thelocalmove.com"]),WLe=t=>t.toLowerCase().replace(/:\d+$/,"").replace(/^www\./,"");function KLe(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")||HLe.has(t))}function Qfe(t){return Jfe(t)!==null}function Jfe(t){const e=WLe(t);return KLe(e)?null:e}const YLe=1,ZLe=1e6;let _$=0;function XLe(){return _$=(_$+1)%Number.MAX_SAFE_INTEGER,_$.toString()}const b$=new Map,Gee=t=>{if(b$.has(t))return;const e=setTimeout(()=>{b$.delete(t),dA({type:"REMOVE_TOAST",toastId:t})},ZLe);b$.set(t,e)},QLe=(t,e)=>{switch(e.type){case"ADD_TOAST":return{...t,toasts:[e.toast,...t.toasts].slice(0,YLe)};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?Gee(r):t.toasts.forEach(n=>{Gee(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)}}},kL=[];let NL={toasts:[]};function dA(t){NL=QLe(NL,t),kL.forEach(e=>{e(NL)})}function Ai({...t}){const e=XLe(),r=s=>dA({type:"UPDATE_TOAST",toast:{...s,id:e}}),n=()=>dA({type:"DISMISS_TOAST",toastId:e});return dA({type:"ADD_TOAST",toast:{...t,id:e,open:!0,onOpenChange:s=>{s||n()}}}),{id:e,dismiss:n,update:r}}function eme(){const[t,e]=N.useState(NL);return N.useEffect(()=>(kL.push(e),()=>{const r=kL.indexOf(e);r>-1&&kL.splice(r,1)}),[t]),{...t,toast:Ai,dismiss:r=>dA({type:"DISMISS_TOAST",toastId:r})}}function Fr(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 Hee(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function ag(...t){return e=>{let r=!1;const n=t.map(s=>{const o=Hee(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 Jo(t,e=[]){let r=[];function n(o,c){const a=N.createContext(c),f=r.length;r=[...r,c];const p=v=>{var M;const{scope:S,children:E,...k}=v,R=((M=S==null?void 0:S[t])==null?void 0:M[f])||a,P=N.useMemo(()=>k,Object.values(k));return i.jsx(R.Provider,{value:P,children:E})};p.displayName=o+"Provider";function y(v,S){var R;const E=((R=S==null?void 0:S[t])==null?void 0:R[f])||a,k=N.useContext(E);if(k)return k;if(c!==void 0)return c;throw new Error(`\`${v}\` must be used within \`${o}\``)}return[p,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,eMe(s,...e)]}function eMe(...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:p})=>{const v=f(o)[`__scope${p}`];return{...a,...v}},{});return N.useMemo(()=>({[`__scope${e.scopeName}`]:c}),[c])}};return r.scopeName=e.scopeName,r}function gx(t){const e=tMe(t),r=N.forwardRef((n,s)=>{const{children:o,...c}=n,a=N.Children.toArray(o),f=a.find(rMe);if(f){const p=f.props.children,y=a.map(v=>v===f?N.Children.count(p)>1?N.Children.only(null):N.isValidElement(p)?p.props.children:null:v);return i.jsx(e,{...c,ref:s,children:N.isValidElement(p)?N.cloneElement(p,void 0,y):null})}return i.jsx(e,{...c,ref:s,children:o})});return r.displayName=`${t}.Slot`,r}var tme=gx("Slot");function tMe(t){const e=N.forwardRef((r,n)=>{const{children:s,...o}=r;if(N.isValidElement(s)){const c=sMe(s),a=nMe(o,s.props);return s.type!==N.Fragment&&(a.ref=n?ag(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 rme=Symbol("radix.slottable");function nme(t){const e=({children:r})=>i.jsx(i.Fragment,{children:r});return e.displayName=`${t}.Slottable`,e.__radixId=rme,e}function rMe(t){return N.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===rme}function nMe(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 sMe(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 EN(t){const e=t+"CollectionProvider",[r,n]=Jo(e),[s,o]=r(e,{collectionRef:{current:null},itemMap:new Map}),c=R=>{const{scope:P,children:M}=R,D=Xe.useRef(null),B=Xe.useRef(new Map).current;return i.jsx(s,{scope:P,itemMap:B,collectionRef:D,children:M})};c.displayName=e;const a=t+"CollectionSlot",f=gx(a),p=Xe.forwardRef((R,P)=>{const{scope:M,children:D}=R,B=o(a,M),V=Zn(P,B.collectionRef);return i.jsx(f,{ref:V,children:D})});p.displayName=a;const y=t+"CollectionItemSlot",v="data-radix-collection-item",S=gx(y),E=Xe.forwardRef((R,P)=>{const{scope:M,children:D,...B}=R,V=Xe.useRef(null),G=Zn(P,V),W=o(y,M);return Xe.useEffect(()=>(W.itemMap.set(V,{ref:V,...B}),()=>void W.itemMap.delete(V))),i.jsx(S,{[v]:"",ref:G,children:D})});E.displayName=y;function k(R){const P=o(t+"CollectionConsumer",R);return Xe.useCallback(()=>{const D=P.collectionRef.current;if(!D)return[];const B=Array.from(D.querySelectorAll(`[${v}]`));return Array.from(P.itemMap.values()).sort((W,Y)=>B.indexOf(W.ref.current)-B.indexOf(Y.ref.current))},[P.collectionRef,P.itemMap])}return[{Provider:c,Slot:p,ItemSlot:E},k,n]}var iMe=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],nn=iMe.reduce((t,e)=>{const r=gx(`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 L9(t,e){t&&xg.flushSync(()=>t.dispatchEvent(e))}function _o(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 aMe(t,e=globalThis==null?void 0:globalThis.document){const r=_o(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 oMe="DismissableLayer",qU="dismissableLayer.update",lMe="dismissableLayer.pointerDownOutside",cMe="dismissableLayer.focusOutside",Wee,sme=N.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),A_=N.forwardRef((t,e)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:n,onPointerDownOutside:s,onFocusOutside:o,onInteractOutside:c,onDismiss:a,...f}=t,p=N.useContext(sme),[y,v]=N.useState(null),S=(y==null?void 0:y.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,E]=N.useState({}),k=Zn(e,Y=>v(Y)),R=Array.from(p.layers),[P]=[...p.layersWithOutsidePointerEventsDisabled].slice(-1),M=R.indexOf(P),D=y?R.indexOf(y):-1,B=p.layersWithOutsidePointerEventsDisabled.size>0,V=D>=M,G=dMe(Y=>{const J=Y.target,Q=[...p.branches].some(ee=>ee.contains(J));!V||Q||(s==null||s(Y),c==null||c(Y),Y.defaultPrevented||a==null||a())},S),W=hMe(Y=>{const J=Y.target;[...p.branches].some(ee=>ee.contains(J))||(o==null||o(Y),c==null||c(Y),Y.defaultPrevented||a==null||a())},S);return aMe(Y=>{D===p.layers.size-1&&(n==null||n(Y),!Y.defaultPrevented&&a&&(Y.preventDefault(),a()))},S),N.useEffect(()=>{if(y)return r&&(p.layersWithOutsidePointerEventsDisabled.size===0&&(Wee=S.body.style.pointerEvents,S.body.style.pointerEvents="none"),p.layersWithOutsidePointerEventsDisabled.add(y)),p.layers.add(y),Kee(),()=>{r&&p.layersWithOutsidePointerEventsDisabled.size===1&&(S.body.style.pointerEvents=Wee)}},[y,S,r,p]),N.useEffect(()=>()=>{y&&(p.layers.delete(y),p.layersWithOutsidePointerEventsDisabled.delete(y),Kee())},[y,p]),N.useEffect(()=>{const Y=()=>E({});return document.addEventListener(qU,Y),()=>document.removeEventListener(qU,Y)},[]),i.jsx(nn.div,{...f,ref:k,style:{pointerEvents:B?V?"auto":"none":void 0,...t.style},onFocusCapture:Fr(t.onFocusCapture,W.onFocusCapture),onBlurCapture:Fr(t.onBlurCapture,W.onBlurCapture),onPointerDownCapture:Fr(t.onPointerDownCapture,G.onPointerDownCapture)})});A_.displayName=oMe;var uMe="DismissableLayerBranch",ime=N.forwardRef((t,e)=>{const r=N.useContext(sme),n=N.useRef(null),s=Zn(e,n);return N.useEffect(()=>{const o=n.current;if(o)return r.branches.add(o),()=>{r.branches.delete(o)}},[r.branches]),i.jsx(nn.div,{...t,ref:s})});ime.displayName=uMe;function dMe(t,e=globalThis==null?void 0:globalThis.document){const r=_o(t),n=N.useRef(!1),s=N.useRef(()=>{});return N.useEffect(()=>{const o=a=>{if(a.target&&!n.current){let f=function(){ame(lMe,r,p,{discrete:!0})};const p={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 hMe(t,e=globalThis==null?void 0:globalThis.document){const r=_o(t),n=N.useRef(!1);return N.useEffect(()=>{const s=o=>{o.target&&!n.current&&ame(cMe,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 Kee(){const t=new CustomEvent(qU);document.dispatchEvent(t)}function ame(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?L9(s,o):s.dispatchEvent(o)}var fMe=A_,mMe=ime,Do=globalThis!=null&&globalThis.document?N.useLayoutEffect:()=>{},pMe="Portal",iT=N.forwardRef((t,e)=>{var a;const{container:r,...n}=t,[s,o]=N.useState(!1);Do(()=>o(!0),[]);const c=r||s&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return c?Zfe.createPortal(i.jsx(nn.div,{...n,ref:e}),c):null});iT.displayName=pMe;function gMe(t,e){return N.useReducer((r,n)=>e[r][n]??r,t)}var vl=t=>{const{present:e,children:r}=t,n=yMe(e),s=typeof r=="function"?r({present:n.isPresent}):N.Children.only(r),o=Zn(n.ref,xMe(s));return typeof r=="function"||n.isPresent?N.cloneElement(s,{ref:o}):null};vl.displayName="Presence";function yMe(t){const[e,r]=N.useState(),n=N.useRef(null),s=N.useRef(t),o=N.useRef("none"),c=t?"mounted":"unmounted",[a,f]=gMe(c,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return N.useEffect(()=>{const p=sR(n.current);o.current=a==="mounted"?p:"none"},[a]),Do(()=>{const p=n.current,y=s.current;if(y!==t){const S=o.current,E=sR(p);t?f("MOUNT"):E==="none"||(p==null?void 0:p.display)==="none"?f("UNMOUNT"):f(y&&S!==E?"ANIMATION_OUT":"UNMOUNT"),s.current=t}},[t,f]),Do(()=>{if(e){let p;const y=e.ownerDocument.defaultView??window,v=E=>{const R=sR(n.current).includes(E.animationName);if(E.target===e&&R&&(f("ANIMATION_END"),!s.current)){const P=e.style.animationFillMode;e.style.animationFillMode="forwards",p=y.setTimeout(()=>{e.style.animationFillMode==="forwards"&&(e.style.animationFillMode=P)})}},S=E=>{E.target===e&&(o.current=sR(n.current))};return e.addEventListener("animationstart",S),e.addEventListener("animationcancel",v),e.addEventListener("animationend",v),()=>{y.clearTimeout(p),e.removeEventListener("animationstart",S),e.removeEventListener("animationcancel",v),e.removeEventListener("animationend",v)}}else f("ANIMATION_END")},[e,f]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:N.useCallback(p=>{n.current=p?getComputedStyle(p):null,r(p)},[])}}function sR(t){return(t==null?void 0:t.animationName)||"none"}function xMe(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 vMe=VG[" useInsertionEffect ".trim().toString()]||Do;function _d({prop:t,defaultProp:e,onChange:r=()=>{},caller:n}){const[s,o,c]=_Me({defaultProp:e,onChange:r}),a=t!==void 0,f=a?t:s;{const y=N.useRef(t!==void 0);N.useEffect(()=>{const v=y.current;v!==a&&console.warn(`${n} is changing from ${v?"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 p=N.useCallback(y=>{var v;if(a){const S=bMe(y)?y(t):y;S!==t&&((v=c.current)==null||v.call(c,S))}else o(y)},[a,t,o,c]);return[f,p]}function _Me({defaultProp:t,onChange:e}){const[r,n]=N.useState(t),s=N.useRef(r),o=N.useRef(e);return vMe(()=>{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 bMe(t){return typeof t=="function"}var ome=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"}),wMe="VisuallyHidden",e3=N.forwardRef((t,e)=>i.jsx(nn.span,{...t,ref:e,style:{...ome,...t.style}}));e3.displayName=wMe;var SMe=e3,M9="ToastProvider",[D9,TMe,EMe]=EN("Toast"),[lme,Xqt]=Jo("Toast",[EMe]),[jMe,t3]=lme(M9),cme=t=>{const{__scopeToast:e,label:r="Notification",duration:n=5e3,swipeDirection:s="right",swipeThreshold:o=50,children:c}=t,[a,f]=N.useState(null),[p,y]=N.useState(0),v=N.useRef(!1),S=N.useRef(!1);return r.trim()||console.error(`Invalid prop \`label\` supplied to \`${M9}\`. Expected non-empty \`string\`.`),i.jsx(D9.Provider,{scope:e,children:i.jsx(jMe,{scope:e,label:r,duration:n,swipeDirection:s,swipeThreshold:o,toastCount:p,viewport:a,onViewportChange:f,onToastAdd:N.useCallback(()=>y(E=>E+1),[]),onToastRemove:N.useCallback(()=>y(E=>E-1),[]),isFocusedToastEscapeKeyDownRef:v,isClosePausedRef:S,children:c})})};cme.displayName=M9;var ume="ToastViewport",AMe=["F8"],GU="toast.viewportPause",HU="toast.viewportResume",dme=N.forwardRef((t,e)=>{const{__scopeToast:r,hotkey:n=AMe,label:s="Notifications ({hotkey})",...o}=t,c=t3(ume,r),a=TMe(r),f=N.useRef(null),p=N.useRef(null),y=N.useRef(null),v=N.useRef(null),S=Zn(e,v,c.onViewportChange),E=n.join("+").replace(/Key/g,"").replace(/Digit/g,""),k=c.toastCount>0;N.useEffect(()=>{const P=M=>{var B;n.length!==0&&n.every(V=>M[V]||M.code===V)&&((B=v.current)==null||B.focus())};return document.addEventListener("keydown",P),()=>document.removeEventListener("keydown",P)},[n]),N.useEffect(()=>{const P=f.current,M=v.current;if(k&&P&&M){const D=()=>{if(!c.isClosePausedRef.current){const W=new CustomEvent(GU);M.dispatchEvent(W),c.isClosePausedRef.current=!0}},B=()=>{if(c.isClosePausedRef.current){const W=new CustomEvent(HU);M.dispatchEvent(W),c.isClosePausedRef.current=!1}},V=W=>{!P.contains(W.relatedTarget)&&B()},G=()=>{P.contains(document.activeElement)||B()};return P.addEventListener("focusin",D),P.addEventListener("focusout",V),P.addEventListener("pointermove",D),P.addEventListener("pointerleave",G),window.addEventListener("blur",D),window.addEventListener("focus",B),()=>{P.removeEventListener("focusin",D),P.removeEventListener("focusout",V),P.removeEventListener("pointermove",D),P.removeEventListener("pointerleave",G),window.removeEventListener("blur",D),window.removeEventListener("focus",B)}}},[k,c.isClosePausedRef]);const R=N.useCallback(({tabbingDirection:P})=>{const D=a().map(B=>{const V=B.ref.current,G=[V,...$Me(V)];return P==="forwards"?G:G.reverse()});return(P==="forwards"?D.reverse():D).flat()},[a]);return N.useEffect(()=>{const P=v.current;if(P){const M=D=>{var G,W,Y;const B=D.altKey||D.ctrlKey||D.metaKey;if(D.key==="Tab"&&!B){const J=document.activeElement,Q=D.shiftKey;if(D.target===P&&Q){(G=p.current)==null||G.focus();return}const pe=R({tabbingDirection:Q?"backwards":"forwards"}),Te=pe.findIndex(Ae=>Ae===J);w$(pe.slice(Te+1))?D.preventDefault():Q?(W=p.current)==null||W.focus():(Y=y.current)==null||Y.focus()}};return P.addEventListener("keydown",M),()=>P.removeEventListener("keydown",M)}},[a,R]),i.jsxs(mMe,{ref:f,role:"region","aria-label":s.replace("{hotkey}",E),tabIndex:-1,style:{pointerEvents:k?void 0:"none"},children:[k&&i.jsx(WU,{ref:p,onFocusFromOutsideViewport:()=>{const P=R({tabbingDirection:"forwards"});w$(P)}}),i.jsx(D9.Slot,{scope:r,children:i.jsx(nn.ol,{tabIndex:-1,...o,ref:S})}),k&&i.jsx(WU,{ref:y,onFocusFromOutsideViewport:()=>{const P=R({tabbingDirection:"backwards"});w$(P)}})]})});dme.displayName=ume;var hme="ToastFocusProxy",WU=N.forwardRef((t,e)=>{const{__scopeToast:r,onFocusFromOutsideViewport:n,...s}=t,o=t3(hme,r);return i.jsx(e3,{"aria-hidden":!0,tabIndex:0,...s,ref:e,style:{position:"fixed"},onFocus:c=>{var p;const a=c.relatedTarget;!((p=o.viewport)!=null&&p.contains(a))&&n()}})});WU.displayName=hme;var jN="Toast",kMe="toast.swipeStart",NMe="toast.swipeMove",CMe="toast.swipeCancel",IMe="toast.swipeEnd",fme=N.forwardRef((t,e)=>{const{forceMount:r,open:n,defaultOpen:s,onOpenChange:o,...c}=t,[a,f]=_d({prop:n,defaultProp:s??!0,onChange:o,caller:jN});return i.jsx(vl,{present:r||a,children:i.jsx(LMe,{open:a,...c,ref:e,onClose:()=>f(!1),onPause:_o(t.onPause),onResume:_o(t.onResume),onSwipeStart:Fr(t.onSwipeStart,p=>{p.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:Fr(t.onSwipeMove,p=>{const{x:y,y:v}=p.detail.delta;p.currentTarget.setAttribute("data-swipe","move"),p.currentTarget.style.setProperty("--radix-toast-swipe-move-x",`${y}px`),p.currentTarget.style.setProperty("--radix-toast-swipe-move-y",`${v}px`)}),onSwipeCancel:Fr(t.onSwipeCancel,p=>{p.currentTarget.setAttribute("data-swipe","cancel"),p.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),p.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),p.currentTarget.style.removeProperty("--radix-toast-swipe-end-x"),p.currentTarget.style.removeProperty("--radix-toast-swipe-end-y")}),onSwipeEnd:Fr(t.onSwipeEnd,p=>{const{x:y,y:v}=p.detail.delta;p.currentTarget.setAttribute("data-swipe","end"),p.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),p.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),p.currentTarget.style.setProperty("--radix-toast-swipe-end-x",`${y}px`),p.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${v}px`),f(!1)})})})});fme.displayName=jN;var[PMe,RMe]=lme(jN,{onClose(){}}),LMe=N.forwardRef((t,e)=>{const{__scopeToast:r,type:n="foreground",duration:s,open:o,onClose:c,onEscapeKeyDown:a,onPause:f,onResume:p,onSwipeStart:y,onSwipeMove:v,onSwipeCancel:S,onSwipeEnd:E,...k}=t,R=t3(jN,r),[P,M]=N.useState(null),D=Zn(e,Ae=>M(Ae)),B=N.useRef(null),V=N.useRef(null),G=s||R.duration,W=N.useRef(0),Y=N.useRef(G),J=N.useRef(0),{onToastAdd:Q,onToastRemove:ee}=R,le=_o(()=>{var Le;(P==null?void 0:P.contains(document.activeElement))&&((Le=R.viewport)==null||Le.focus()),c()}),pe=N.useCallback(Ae=>{!Ae||Ae===1/0||(window.clearTimeout(J.current),W.current=new Date().getTime(),J.current=window.setTimeout(le,Ae))},[le]);N.useEffect(()=>{const Ae=R.viewport;if(Ae){const Le=()=>{pe(Y.current),p==null||p()},ke=()=>{const we=new Date().getTime()-W.current;Y.current=Y.current-we,window.clearTimeout(J.current),f==null||f()};return Ae.addEventListener(GU,ke),Ae.addEventListener(HU,Le),()=>{Ae.removeEventListener(GU,ke),Ae.removeEventListener(HU,Le)}}},[R.viewport,G,f,p,pe]),N.useEffect(()=>{o&&!R.isClosePausedRef.current&&pe(G)},[o,G,R.isClosePausedRef,pe]),N.useEffect(()=>(Q(),()=>ee()),[Q,ee]);const Te=N.useMemo(()=>P?_me(P):null,[P]);return R.viewport?i.jsxs(i.Fragment,{children:[Te&&i.jsx(MMe,{__scopeToast:r,role:"status","aria-live":n==="foreground"?"assertive":"polite","aria-atomic":!0,children:Te}),i.jsx(PMe,{scope:r,onClose:le,children:xg.createPortal(i.jsx(D9.ItemSlot,{scope:r,children:i.jsx(fMe,{asChild:!0,onEscapeKeyDown:Fr(a,()=>{R.isFocusedToastEscapeKeyDownRef.current||le(),R.isFocusedToastEscapeKeyDownRef.current=!1}),children:i.jsx(nn.li,{role:"status","aria-live":"off","aria-atomic":!0,tabIndex:0,"data-state":o?"open":"closed","data-swipe-direction":R.swipeDirection,...k,ref:D,style:{userSelect:"none",touchAction:"none",...t.style},onKeyDown:Fr(t.onKeyDown,Ae=>{Ae.key==="Escape"&&(a==null||a(Ae.nativeEvent),Ae.nativeEvent.defaultPrevented||(R.isFocusedToastEscapeKeyDownRef.current=!0,le()))}),onPointerDown:Fr(t.onPointerDown,Ae=>{Ae.button===0&&(B.current={x:Ae.clientX,y:Ae.clientY})}),onPointerMove:Fr(t.onPointerMove,Ae=>{if(!B.current)return;const Le=Ae.clientX-B.current.x,ke=Ae.clientY-B.current.y,we=!!V.current,me=["left","right"].includes(R.swipeDirection),je=["left","up"].includes(R.swipeDirection)?Math.min:Math.max,_e=me?je(0,Le):0,Ee=me?0:je(0,ke),ve=Ae.pointerType==="touch"?10:2,qe={x:_e,y:Ee},nt={originalEvent:Ae,delta:qe};we?(V.current=qe,iR(NMe,v,nt,{discrete:!1})):Yee(qe,R.swipeDirection,ve)?(V.current=qe,iR(kMe,y,nt,{discrete:!1}),Ae.target.setPointerCapture(Ae.pointerId)):(Math.abs(Le)>ve||Math.abs(ke)>ve)&&(B.current=null)}),onPointerUp:Fr(t.onPointerUp,Ae=>{const Le=V.current,ke=Ae.target;if(ke.hasPointerCapture(Ae.pointerId)&&ke.releasePointerCapture(Ae.pointerId),V.current=null,B.current=null,Le){const we=Ae.currentTarget,me={originalEvent:Ae,delta:Le};Yee(Le,R.swipeDirection,R.swipeThreshold)?iR(IMe,E,me,{discrete:!0}):iR(CMe,S,me,{discrete:!0}),we.addEventListener("click",je=>je.preventDefault(),{once:!0})}})})})}),R.viewport)})]}):null}),MMe=t=>{const{__scopeToast:e,children:r,...n}=t,s=t3(jN,e),[o,c]=N.useState(!1),[a,f]=N.useState(!1);return FMe(()=>c(!0)),N.useEffect(()=>{const p=window.setTimeout(()=>f(!0),1e3);return()=>window.clearTimeout(p)},[]),a?null:i.jsx(iT,{asChild:!0,children:i.jsx(e3,{...n,children:o&&i.jsxs(i.Fragment,{children:[s.label," ",r]})})})},DMe="ToastTitle",mme=N.forwardRef((t,e)=>{const{__scopeToast:r,...n}=t;return i.jsx(nn.div,{...n,ref:e})});mme.displayName=DMe;var OMe="ToastDescription",pme=N.forwardRef((t,e)=>{const{__scopeToast:r,...n}=t;return i.jsx(nn.div,{...n,ref:e})});pme.displayName=OMe;var gme="ToastAction",yme=N.forwardRef((t,e)=>{const{altText:r,...n}=t;return r.trim()?i.jsx(vme,{altText:r,asChild:!0,children:i.jsx(O9,{...n,ref:e})}):(console.error(`Invalid prop \`altText\` supplied to \`${gme}\`. Expected non-empty \`string\`.`),null)});yme.displayName=gme;var xme="ToastClose",O9=N.forwardRef((t,e)=>{const{__scopeToast:r,...n}=t,s=RMe(xme,r);return i.jsx(vme,{asChild:!0,children:i.jsx(nn.button,{type:"button",...n,ref:e,onClick:Fr(t.onClick,s.onClose)})})});O9.displayName=xme;var vme=N.forwardRef((t,e)=>{const{__scopeToast:r,altText:n,...s}=t;return i.jsx(nn.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":n||void 0,...s,ref:e})});function _me(t){const e=[];return Array.from(t.childNodes).forEach(n=>{if(n.nodeType===n.TEXT_NODE&&n.textContent&&e.push(n.textContent),BMe(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(..._me(n))}}),e}function iR(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?L9(s,o):s.dispatchEvent(o)}var Yee=(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 FMe(t=()=>{}){const e=_o(t);Do(()=>{let r=0,n=0;return r=window.requestAnimationFrame(()=>n=window.requestAnimationFrame(e)),()=>{window.cancelAnimationFrame(r),window.cancelAnimationFrame(n)}},[e])}function BMe(t){return t.nodeType===t.ELEMENT_NODE}function $Me(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 w$(t){const e=document.activeElement;return t.some(r=>r===e?!0:(r.focus(),document.activeElement!==e))}var zMe=cme,bme=dme,wme=fme,Sme=mme,Tme=pme,Eme=yme,jme=O9;function Ame(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,Xee=$s,aT=(t,e)=>r=>{var n;if((e==null?void 0:e.variants)==null)return Xee(t,r==null?void 0:r.class,r==null?void 0:r.className);const{variants:s,defaultVariants:o}=e,c=Object.keys(s).map(p=>{const y=r==null?void 0:r[p],v=o==null?void 0:o[p];if(y===null)return null;const S=Zee(y)||Zee(v);return s[p][S]}),a=r&&Object.entries(r).reduce((p,y)=>{let[v,S]=y;return S===void 0||(p[v]=S),p},{}),f=e==null||(n=e.compoundVariants)===null||n===void 0?void 0:n.reduce((p,y)=>{let{class:v,className:S,...E}=y;return Object.entries(E).every(k=>{let[R,P]=k;return Array.isArray(P)?P.includes({...o,...a}[R]):{...o,...a}[R]===P})?[...p,v,S]:p},[]);return Xee(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 UMe=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),kme=(...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 VMe={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 qMe=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,...VMe,width:e,height:e,stroke:t,strokeWidth:n?Number(r)*24/Number(e):r,className:kme("lucide",s),...a},[...c.map(([p,y])=>N.createElement(p,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 ir=(t,e)=>{const r=N.forwardRef(({className:n,...s},o)=>N.createElement(qMe,{ref:o,iconNode:e,className:kme(`lucide-${UMe(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 Qee=ir("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 yx=ir("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=ir("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 GMe=ir("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 wm=ir("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 E1=ir("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 k_=ir("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 HMe=ir("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 oT=ir("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 AN=ir("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 cS=ir("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 RM=ir("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 WMe=ir("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 Nme=ir("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 so=ir("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 KMe=ir("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 KU=ir("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 F9=ir("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 B9=ir("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 Sm=ir("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 Cme=ir("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 co=ir("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 Jee=ir("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 QA=ir("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 Oa=ir("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 xl=ir("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 Om=ir("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 kd=ir("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 Ime=ir("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 YU=ir("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 Pme=ir("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 Bl=ir("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 YMe=ir("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 $9=ir("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 c_=ir("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 ZU=ir("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 S$=ir("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 Ml=ir("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 ete=ir("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 XU=ir("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 Yp=ir("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 oc=ir("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 ZMe=ir("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 XMe=ir("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 N_=ir("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 r3=ir("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 z9=ir("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 QMe=ir("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 JMe=ir("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 km=ir("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 tte=ir("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 eDe=ir("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 tDe=ir("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 Rme=ir("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 rDe=ir("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 nDe=ir("Gem",[["path",{d:"M6 3h12l4 6-10 13L2 9Z",key:"1pcd5k"}],["path",{d:"M11 3 8 9l4 13 4-13-3-6",key:"1fcu3u"}],["path",{d:"M2 9h20",key:"16fsjt"}]]);/** * @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 pf=ir("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 Qv=ir("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 JA=ir("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 sDe=ir("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 iDe=ir("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 aDe=ir("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 QU=ir("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 Nm=ir("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 Gi=ir("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 rte=ir("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 U9=ir("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 V9=ir("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 q9=ir("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 Lme=ir("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 n3=ir("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 oDe=ir("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 Mme=ir("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 lDe=ir("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 cDe=ir("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 uDe=ir("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 nte=ir("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 G9=ir("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 dDe=ir("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 JU=ir("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 jc=ir("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 xx=ir("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 s3=ir("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 ns=ir("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 di=ir("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 hDe=ir("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 fDe=ir("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 kN=ir("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 C_=ir("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 mDe=ir("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 uS=ir("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 ph=ir("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 pDe=ir("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 Dme=ir("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 gDe=ir("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 ste=ir("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 i3=ir("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 yDe=ir("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 Ome=ir("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 xDe=ir("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 vDe=ir("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 zn=ir("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 _De=ir("Plane",[["path",{d:"M17.8 19.2 16 11l3.5-3.5C21 6 21.5 4 21 3c-1-.5-3 0-4.5 1.5L13 8 4.8 6.2c-.5-.1-.9.1-1.1.5l-.3.5c-.2.5-.1 1 .3 1.3L9 12l-2 3H4l-1 1 3 2 2 3 1-1v-3l3-2 3.5 5.3c.3.4.8.5 1.3.3l.5-.2c.4-.3.6-.7.5-1.2z",key:"1v9wt8"}]]);/** * @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 bDe=ir("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 LM=ir("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 Tm=ir("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 wDe=ir("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 SDe=ir("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 TDe=ir("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 EDe=ir("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 Fme=ir("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 jDe=ir("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 ite=ir("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 ADe=ir("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 a3=ir("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 kDe=ir("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 NDe=ir("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 bd=ir("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 MM=ir("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 H9=ir("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 NN=ir("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 CDe=ir("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 o3=ir("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 ek=ir("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 Bme=ir("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 IDe=ir("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 T$=ir("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 PDe=ir("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 vi=ir("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 RDe=ir("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 eV=ir("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 W9=ir("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 $l=ir("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 K9=ir("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 LDe=ir("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 CN=ir("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 MDe=ir("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 $me=ir("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 DM=ir("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 zme=ir("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 _f=ir("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 lT=ir("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 OM=ir("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 tV=ir("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 rV=ir("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 l3=ir("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 Dl=ir("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 ml=ir("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 hA=ir("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 DDe=ir("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 ODe=ir("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 c3=ir("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 FDe=ir("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 Y9=ir("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 ki=ir("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 Ume=ir("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 dS=ir("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 ate=ir("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"}]]),Z9="-",BDe=t=>{const e=zDe(t),{conflictingClassGroups:r,conflictingClassGroupModifiers:n}=t;return{getClassGroupId:c=>{const a=c.split(Z9);return a[0]===""&&a.length!==1&&a.shift(),Vme(a,e)||$De(c)},getConflictingClassGroupIds:(c,a)=>{const f=r[c]||[];return a&&n[c]?[...f,...n[c]]:f}}},Vme=(t,e)=>{var c;if(t.length===0)return e.classGroupId;const r=t[0],n=e.nextPart.get(r),s=n?Vme(t.slice(1),n):void 0;if(s)return s;if(e.validators.length===0)return;const o=t.join(Z9);return(c=e.validators.find(({validator:a})=>a(o)))==null?void 0:c.classGroupId},ote=/^\[(.+)\]$/,$De=t=>{if(ote.test(t)){const e=ote.exec(t)[1],r=e==null?void 0:e.substring(0,e.indexOf(":"));if(r)return"arbitrary.."+r}},zDe=t=>{const{theme:e,prefix:r}=t,n={nextPart:new Map,validators:[]};return VDe(Object.entries(t.classGroups),r).forEach(([o,c])=>{nV(c,n,o,e)}),n},nV=(t,e,r,n)=>{t.forEach(s=>{if(typeof s=="string"){const o=s===""?e:lte(e,s);o.classGroupId=r;return}if(typeof s=="function"){if(UDe(s)){nV(s(n),e,r,n);return}e.validators.push({validator:s,classGroupId:r});return}Object.entries(s).forEach(([o,c])=>{nV(c,lte(e,o),r,n)})})},lte=(t,e)=>{let r=t;return e.split(Z9).forEach(n=>{r.nextPart.has(n)||r.nextPart.set(n,{nextPart:new Map,validators:[]}),r=r.nextPart.get(n)}),r},UDe=t=>t.isThemeGetter,VDe=(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,qDe=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)}}},qme="!",GDe=t=>{const{separator:e,experimentalParseClassName:r}=t,n=e.length===1,s=e[0],o=e.length,c=a=>{const f=[];let p=0,y=0,v;for(let P=0;Py?v-y:void 0;return{modifiers:f,hasImportantModifier:E,baseClassName:k,maybePostfixModifierPosition:R}};return r?a=>r({className:a,parseClassName:c}):c},HDe=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},WDe=t=>({cache:qDe(t.cacheSize),parseClassName:GDe(t),...BDe(t)}),KDe=/\s+/,YDe=(t,e)=>{const{parseClassName:r,getClassGroupId:n,getConflictingClassGroupIds:s}=e,o=[],c=t.trim().split(KDe);let a="";for(let f=c.length-1;f>=0;f-=1){const p=c[f],{modifiers:y,hasImportantModifier:v,baseClassName:S,maybePostfixModifierPosition:E}=r(p);let k=!!E,R=n(k?S.substring(0,E):S);if(!R){if(!k){a=p+(a.length>0?" "+a:a);continue}if(R=n(S),!R){a=p+(a.length>0?" "+a:a);continue}k=!1}const P=HDe(y).join(":"),M=v?P+qme:P,D=M+R;if(o.includes(D))continue;o.push(D);const B=s(R,k);for(let V=0;V0?" "+a:a)}return a};function ZDe(){let t=0,e,r,n="";for(;t{if(typeof t=="string")return t;let e,r="";for(let n=0;nv(y),t());return r=WDe(p),n=r.cache.get,s=r.cache.set,o=a,a(f)}function a(f){const p=n(f);if(p)return p;const y=YDe(f,r);return s(f,y),y}return function(){return o(ZDe.apply(null,arguments))}}const Ia=t=>{const e=r=>r[t]||[];return e.isThemeGetter=!0,e},Hme=/^\[(?:([a-z-]+):)?(.+)\]$/i,QDe=/^\d+\/\d+$/,JDe=new Set(["px","full","screen"]),eOe=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,tOe=/\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$/,rOe=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,nOe=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,sOe=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Sp=t=>j1(t)||JDe.has(t)||QDe.test(t),fy=t=>cT(t,"length",hOe),j1=t=>!!t&&!Number.isNaN(Number(t)),E$=t=>cT(t,"number",j1),u2=t=>!!t&&Number.isInteger(Number(t)),iOe=t=>t.endsWith("%")&&j1(t.slice(0,-1)),Fs=t=>Hme.test(t),my=t=>eOe.test(t),aOe=new Set(["length","size","percentage"]),oOe=t=>cT(t,aOe,Wme),lOe=t=>cT(t,"position",Wme),cOe=new Set(["image","url"]),uOe=t=>cT(t,cOe,mOe),dOe=t=>cT(t,"",fOe),d2=()=>!0,cT=(t,e,r)=>{const n=Hme.exec(t);return n?n[1]?typeof e=="string"?n[1]===e:e.has(n[1]):r(n[2]):!1},hOe=t=>tOe.test(t)&&!rOe.test(t),Wme=()=>!1,fOe=t=>nOe.test(t),mOe=t=>sOe.test(t),pOe=()=>{const t=Ia("colors"),e=Ia("spacing"),r=Ia("blur"),n=Ia("brightness"),s=Ia("borderColor"),o=Ia("borderRadius"),c=Ia("borderSpacing"),a=Ia("borderWidth"),f=Ia("contrast"),p=Ia("grayscale"),y=Ia("hueRotate"),v=Ia("invert"),S=Ia("gap"),E=Ia("gradientColorStops"),k=Ia("gradientColorStopPositions"),R=Ia("inset"),P=Ia("margin"),M=Ia("opacity"),D=Ia("padding"),B=Ia("saturate"),V=Ia("scale"),G=Ia("sepia"),W=Ia("skew"),Y=Ia("space"),J=Ia("translate"),Q=()=>["auto","contain","none"],ee=()=>["auto","hidden","clip","visible","scroll"],le=()=>["auto",Fs,e],pe=()=>[Fs,e],Te=()=>["",Sp,fy],Ae=()=>["auto",j1,Fs],Le=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],ke=()=>["solid","dashed","dotted","double","none"],we=()=>["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"],je=()=>["","0",Fs],_e=()=>["auto","avoid","all","avoid-page","page","left","right","column"],Ee=()=>[j1,Fs];return{cacheSize:500,separator:":",theme:{colors:[d2],spacing:[Sp,fy],blur:["none","",my,Fs],brightness:Ee(),borderColor:[t],borderRadius:["none","","full",my,Fs],borderSpacing:pe(),borderWidth:Te(),contrast:Ee(),grayscale:je(),hueRotate:Ee(),invert:je(),gap:pe(),gradientColorStops:[t],gradientColorStopPositions:[iOe,fy],inset:le(),margin:le(),opacity:Ee(),padding:pe(),saturate:Ee(),scale:Ee(),sepia:je(),skew:Ee(),space:pe(),translate:pe()},classGroups:{aspect:[{aspect:["auto","square","video",Fs]}],container:["container"],columns:[{columns:[my]}],"break-after":[{"break-after":_e()}],"break-before":[{"break-before":_e()}],"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(),Fs]}],overflow:[{overflow:ee()}],"overflow-x":[{"overflow-x":ee()}],"overflow-y":[{"overflow-y":ee()}],overscroll:[{overscroll:Q()}],"overscroll-x":[{"overscroll-x":Q()}],"overscroll-y":[{"overscroll-y":Q()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[R]}],"inset-x":[{"inset-x":[R]}],"inset-y":[{"inset-y":[R]}],start:[{start:[R]}],end:[{end:[R]}],top:[{top:[R]}],right:[{right:[R]}],bottom:[{bottom:[R]}],left:[{left:[R]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",u2,Fs]}],basis:[{basis:le()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",Fs]}],grow:[{grow:je()}],shrink:[{shrink:je()}],order:[{order:["first","last","none",u2,Fs]}],"grid-cols":[{"grid-cols":[d2]}],"col-start-end":[{col:["auto",{span:["full",u2,Fs]},Fs]}],"col-start":[{"col-start":Ae()}],"col-end":[{"col-end":Ae()}],"grid-rows":[{"grid-rows":[d2]}],"row-start-end":[{row:["auto",{span:[u2,Fs]},Fs]}],"row-start":[{"row-start":Ae()}],"row-end":[{"row-end":Ae()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",Fs]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",Fs]}],gap:[{gap:[S]}],"gap-x":[{"gap-x":[S]}],"gap-y":[{"gap-y":[S]}],"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:[P]}],mx:[{mx:[P]}],my:[{my:[P]}],ms:[{ms:[P]}],me:[{me:[P]}],mt:[{mt:[P]}],mr:[{mr:[P]}],mb:[{mb:[P]}],ml:[{ml:[P]}],"space-x":[{"space-x":[Y]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[Y]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",Fs,e]}],"min-w":[{"min-w":[Fs,e,"min","max","fit"]}],"max-w":[{"max-w":[Fs,e,"none","full","min","max","fit","prose",{screen:[my]},my]}],h:[{h:[Fs,e,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[Fs,e,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[Fs,e,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[Fs,e,"auto","min","max","fit"]}],"font-size":[{text:["base",my,fy]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",E$]}],"font-family":[{font:[d2]}],"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",Fs]}],"line-clamp":[{"line-clamp":["none",j1,E$]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",Sp,Fs]}],"list-image":[{"list-image":["none",Fs]}],"list-style-type":[{list:["none","disc","decimal",Fs]}],"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:[...ke(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",Sp,fy]}],"underline-offset":[{"underline-offset":["auto",Sp,Fs]}],"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:pe()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Fs]}],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",Fs]}],"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(),lOe]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",oOe]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},uOe]}],"bg-color":[{bg:[t]}],"gradient-from-pos":[{from:[k]}],"gradient-via-pos":[{via:[k]}],"gradient-to-pos":[{to:[k]}],"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:[...ke(),"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:ke()}],"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:["",...ke()]}],"outline-offset":[{"outline-offset":[Sp,Fs]}],"outline-w":[{outline:[Sp,fy]}],"outline-color":[{outline:[t]}],"ring-w":[{ring:Te()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[t]}],"ring-opacity":[{"ring-opacity":[M]}],"ring-offset-w":[{"ring-offset":[Sp,fy]}],"ring-offset-color":[{"ring-offset":[t]}],shadow:[{shadow:["","inner","none",my,dOe]}],"shadow-color":[{shadow:[d2]}],opacity:[{opacity:[M]}],"mix-blend":[{"mix-blend":[...we(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":we()}],filter:[{filter:["","none"]}],blur:[{blur:[r]}],brightness:[{brightness:[n]}],contrast:[{contrast:[f]}],"drop-shadow":[{"drop-shadow":["","none",my,Fs]}],grayscale:[{grayscale:[p]}],"hue-rotate":[{"hue-rotate":[y]}],invert:[{invert:[v]}],saturate:[{saturate:[B]}],sepia:[{sepia:[G]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[r]}],"backdrop-brightness":[{"backdrop-brightness":[n]}],"backdrop-contrast":[{"backdrop-contrast":[f]}],"backdrop-grayscale":[{"backdrop-grayscale":[p]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[y]}],"backdrop-invert":[{"backdrop-invert":[v]}],"backdrop-opacity":[{"backdrop-opacity":[M]}],"backdrop-saturate":[{"backdrop-saturate":[B]}],"backdrop-sepia":[{"backdrop-sepia":[G]}],"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",Fs]}],duration:[{duration:Ee()}],ease:[{ease:["linear","in","out","in-out",Fs]}],delay:[{delay:Ee()}],animate:[{animate:["none","spin","ping","pulse","bounce",Fs]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[V]}],"scale-x":[{"scale-x":[V]}],"scale-y":[{"scale-y":[V]}],rotate:[{rotate:[u2,Fs]}],"translate-x":[{"translate-x":[J]}],"translate-y":[{"translate-y":[J]}],"skew-x":[{"skew-x":[W]}],"skew-y":[{"skew-y":[W]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",Fs]}],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",Fs]}],"caret-color":[{caret:[t]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":pe()}],"scroll-mx":[{"scroll-mx":pe()}],"scroll-my":[{"scroll-my":pe()}],"scroll-ms":[{"scroll-ms":pe()}],"scroll-me":[{"scroll-me":pe()}],"scroll-mt":[{"scroll-mt":pe()}],"scroll-mr":[{"scroll-mr":pe()}],"scroll-mb":[{"scroll-mb":pe()}],"scroll-ml":[{"scroll-ml":pe()}],"scroll-p":[{"scroll-p":pe()}],"scroll-px":[{"scroll-px":pe()}],"scroll-py":[{"scroll-py":pe()}],"scroll-ps":[{"scroll-ps":pe()}],"scroll-pe":[{"scroll-pe":pe()}],"scroll-pt":[{"scroll-pt":pe()}],"scroll-pr":[{"scroll-pr":pe()}],"scroll-pb":[{"scroll-pb":pe()}],"scroll-pl":[{"scroll-pl":pe()}],"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",Fs]}],fill:[{fill:[t,"none"]}],"stroke-w":[{stroke:[Sp,fy,E$]}],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"]}}},gOe=XDe(pOe);function qt(...t){return gOe($s(t))}function Va(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 cte(t){const e=new Date(t);return new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",year:"numeric"}).format(e)}function Qqt(t){return t?t.replace(/<[^>]*>/g,""):""}const yOe=zMe,Kme=N.forwardRef(({className:t,...e},r)=>i.jsx(bme,{ref:r,className:qt("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}));Kme.displayName=bme.displayName;const xOe=aT("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"}}),Yme=N.forwardRef(({className:t,variant:e,...r},n)=>i.jsx(wme,{ref:n,className:qt(xOe({variant:e}),t),...r}));Yme.displayName=wme.displayName;const vOe=N.forwardRef(({className:t,...e},r)=>i.jsx(Eme,{ref:r,className:qt("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}));vOe.displayName=Eme.displayName;const Zme=N.forwardRef(({className:t,...e},r)=>i.jsx(jme,{ref:r,className:qt("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(ki,{className:"h-4 w-4"})}));Zme.displayName=jme.displayName;const Xme=N.forwardRef(({className:t,...e},r)=>i.jsx(Sme,{ref:r,className:qt("text-sm font-semibold",t),...e}));Xme.displayName=Sme.displayName;const Qme=N.forwardRef(({className:t,...e},r)=>i.jsx(Tme,{ref:r,className:qt("text-sm opacity-90",t),...e}));Qme.displayName=Tme.displayName;function _Oe(){const{toasts:t}=eme();return i.jsxs(yOe,{children:[t.map(function({id:e,title:r,description:n,action:s,...o}){return i.jsxs(Yme,{...o,children:[i.jsxs("div",{className:"grid gap-1",children:[r&&i.jsx(Xme,{children:r}),n&&i.jsx(Qme,{children:n})]}),s,i.jsx(Zme,{})]},e)}),i.jsx(Kme,{})]})}var ute=["light","dark"],bOe="(prefers-color-scheme: dark)",wOe=N.createContext(void 0),SOe={setTheme:t=>{},themes:[]},TOe=()=>{var t;return(t=N.useContext(wOe))!=null?t:SOe};N.memo(({forcedTheme:t,storageKey:e,attribute:r,enableSystem:n,enableColorScheme:s,defaultTheme:o,value:c,attrs:a,nonce:f})=>{let p=o==="system",y=r==="class"?`var d=document.documentElement,c=d.classList;${`c.remove(${a.map(k=>`'${k}'`).join(",")})`};`:`var d=document.documentElement,n='${r}',s='setAttribute';`,v=s?ute.includes(o)&&o?`if(e==='light'||e==='dark'||!e)d.style.colorScheme=e||'${o}'`:"if(e==='light'||e==='dark')d.style.colorScheme=e":"",S=(k,R=!1,P=!0)=>{let M=c?c[k]:k,D=R?k+"|| ''":`'${M}'`,B="";return s&&P&&!R&&ute.includes(k)&&(B+=`d.style.colorScheme = '${k}';`),r==="class"?R||M?B+=`c.add(${D})`:B+="null":M&&(B+=`d[s](n,${D})`),B},E=t?`!function(){${y}${S(t)}}()`:n?`!function(){try{${y}var e=localStorage.getItem('${e}');if('system'===e||(!e&&${p})){var t='${bOe}',m=window.matchMedia(t);if(m.media!==t||m.matches){${S("dark")}}else{${S("light")}}}else if(e){${c?`var x=${JSON.stringify(c)};`:""}${S(c?"x[e]":"e",!0)}}${p?"":"else{"+S(o,!1,!1)+"}"}${v}}catch(e){}}()`:`!function(){try{${y}var e=localStorage.getItem('${e}');if(e){${c?`var x=${JSON.stringify(c)};`:""}${S(c?"x[e]":"e",!0)}}else{${S(o,!1,!1)};}${v}}catch(t){}}();`;return N.createElement("script",{nonce:f,dangerouslySetInnerHTML:{__html:E}})});var EOe=t=>{switch(t){case"success":return kOe;case"info":return COe;case"warning":return NOe;case"error":return IOe;default:return null}},jOe=Array(12).fill(0),AOe=({visible:t,className:e})=>Xe.createElement("div",{className:["sonner-loading-wrapper",e].filter(Boolean).join(" "),"data-visible":t},Xe.createElement("div",{className:"sonner-spinner"},jOe.map((r,n)=>Xe.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${n}`})))),kOe=Xe.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},Xe.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"})),NOe=Xe.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},Xe.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"})),COe=Xe.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},Xe.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"})),IOe=Xe.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},Xe.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"})),POe=Xe.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"},Xe.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),Xe.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),ROe=()=>{let[t,e]=Xe.useState(document.hidden);return Xe.useEffect(()=>{let r=()=>{e(document.hidden)};return document.addEventListener("visibilitychange",r),()=>window.removeEventListener("visibilitychange",r)},[]),t},sV=1,LOe=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:sV++,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],Xe.isValidElement(f))s=!1,this.create({id:r,type:"default",message:f});else if(DOe(f)&&!f.ok){s=!1;let p=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:p,description:y})}else if(e.success!==void 0){s=!1;let p=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:p,description:y})}}).catch(async f=>{if(o=["reject",f],e.error!==void 0){s=!1;let p=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:p,description:y})}}).finally(()=>{var f;s&&(this.dismiss(r),r=void 0),(f=e.finally)==null||f.call(e)}),a=()=>new Promise((f,p)=>c.then(()=>o[0]==="reject"?p(o[1]):f(o[1])).catch(p));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)||sV++;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}},Au=new LOe,MOe=(t,e)=>{let r=(e==null?void 0:e.id)||sV++;return Au.addToast({title:t,...e,id:r}),r},DOe=t=>t&&typeof t=="object"&&"ok"in t&&typeof t.ok=="boolean"&&"status"in t&&typeof t.status=="number",OOe=MOe,FOe=()=>Au.toasts,BOe=()=>Au.getActiveToasts(),$t=Object.assign(OOe,{success:Au.success,info:Au.info,warning:Au.warning,error:Au.error,custom:Au.custom,message:Au.message,promise:Au.promise,dismiss:Au.dismiss,loading:Au.loading},{getHistory:FOe,getToasts:BOe});function $Oe(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))}$Oe(`: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 aR(t){return t.label!==void 0}var zOe=3,UOe="32px",VOe="16px",dte=4e3,qOe=356,GOe=14,HOe=20,WOe=200;function zh(...t){return t.filter(Boolean).join(" ")}function KOe(t){let[e,r]=t.split("-"),n=[];return e&&n.push(e),r&&n.push(r),n}var YOe=t=>{var e,r,n,s,o,c,a,f,p,y,v;let{invert:S,toast:E,unstyled:k,interacting:R,setHeights:P,visibleToasts:M,heights:D,index:B,toasts:V,expanded:G,removeToast:W,defaultRichColors:Y,closeButton:J,style:Q,cancelButtonStyle:ee,actionButtonStyle:le,className:pe="",descriptionClassName:Te="",duration:Ae,position:Le,gap:ke,loadingIcon:we,expandByDefault:me,classNames:je,icons:_e,closeButtonAriaLabel:Ee="Close toast",pauseWhenPageIsHidden:ve}=t,[qe,nt]=Xe.useState(null),[ot,jt]=Xe.useState(null),[vt,Gt]=Xe.useState(!1),[pt,Ct]=Xe.useState(!1),[tr,wt]=Xe.useState(!1),[lr,Sr]=Xe.useState(!1),[sn,cr]=Xe.useState(!1),[yr,Pr]=Xe.useState(0),[jn,Je]=Xe.useState(0),St=Xe.useRef(E.duration||Ae||dte),Jt=Xe.useRef(null),Ir=Xe.useRef(null),ur=B===0,ar=B+1<=M,It=E.type,pr=E.dismissible!==!1,Tn=E.className||"",ss=E.descriptionClassName||"",is=Xe.useMemo(()=>D.findIndex(en=>en.toastId===E.id)||0,[D,E.id]),Us=Xe.useMemo(()=>{var en;return(en=E.closeButton)!=null?en:J},[E.closeButton,J]),Ea=Xe.useMemo(()=>E.duration||Ae||dte,[E.duration,Ae]),vs=Xe.useRef(0),ua=Xe.useRef(0),Nr=Xe.useRef(0),qn=Xe.useRef(null),[Yi,ja]=Le.split("-"),So=Xe.useMemo(()=>D.reduce((en,Fn,ti)=>ti>=is?en:en+Fn.height,0),[D,is]),Zr=ROe(),fn=E.invert||S,xn=It==="loading";ua.current=Xe.useMemo(()=>is*ke+So,[is,So]),Xe.useEffect(()=>{St.current=Ea},[Ea]),Xe.useEffect(()=>{Gt(!0)},[]),Xe.useEffect(()=>{let en=Ir.current;if(en){let Fn=en.getBoundingClientRect().height;return Je(Fn),P(ti=>[{toastId:E.id,height:Fn,position:E.position},...ti]),()=>P(ti=>ti.filter(bl=>bl.toastId!==E.id))}},[P,E.id]),Xe.useLayoutEffect(()=>{if(!vt)return;let en=Ir.current,Fn=en.style.height;en.style.height="auto";let ti=en.getBoundingClientRect().height;en.style.height=Fn,Je(ti),P(bl=>bl.find(el=>el.toastId===E.id)?bl.map(el=>el.toastId===E.id?{...el,height:ti}:el):[{toastId:E.id,height:ti,position:E.position},...bl])},[vt,E.title,E.description,P,E.id]);let Xr=Xe.useCallback(()=>{Ct(!0),Pr(ua.current),P(en=>en.filter(Fn=>Fn.toastId!==E.id)),setTimeout(()=>{W(E)},WOe)},[E,W,P,ua]);Xe.useEffect(()=>{if(E.promise&&It==="loading"||E.duration===1/0||E.type==="loading")return;let en;return G||R||ve&&Zr?(()=>{if(Nr.current{var Fn;(Fn=E.onAutoClose)==null||Fn.call(E,E),Xr()},St.current)),()=>clearTimeout(en)},[G,R,E,It,ve,Zr,Xr]),Xe.useEffect(()=>{E.delete&&Xr()},[Xr,E.delete]);function ds(){var en,Fn,ti;return _e!=null&&_e.loading?Xe.createElement("div",{className:zh(je==null?void 0:je.loader,(en=E==null?void 0:E.classNames)==null?void 0:en.loader,"sonner-loader"),"data-visible":It==="loading"},_e.loading):we?Xe.createElement("div",{className:zh(je==null?void 0:je.loader,(Fn=E==null?void 0:E.classNames)==null?void 0:Fn.loader,"sonner-loader"),"data-visible":It==="loading"},we):Xe.createElement(AOe,{className:zh(je==null?void 0:je.loader,(ti=E==null?void 0:E.classNames)==null?void 0:ti.loader),visible:It==="loading"})}return Xe.createElement("li",{tabIndex:0,ref:Ir,className:zh(pe,Tn,je==null?void 0:je.toast,(e=E==null?void 0:E.classNames)==null?void 0:e.toast,je==null?void 0:je.default,je==null?void 0:je[It],(r=E==null?void 0:E.classNames)==null?void 0:r[It]),"data-sonner-toast":"","data-rich-colors":(n=E.richColors)!=null?n:Y,"data-styled":!(E.jsx||E.unstyled||k),"data-mounted":vt,"data-promise":!!E.promise,"data-swiped":sn,"data-removed":pt,"data-visible":ar,"data-y-position":Yi,"data-x-position":ja,"data-index":B,"data-front":ur,"data-swiping":tr,"data-dismissible":pr,"data-type":It,"data-invert":fn,"data-swipe-out":lr,"data-swipe-direction":ot,"data-expanded":!!(G||me&&vt),style:{"--index":B,"--toasts-before":B,"--z-index":V.length-B,"--offset":`${pt?yr:ua.current}px`,"--initial-height":me?"auto":`${jn}px`,...Q,...E.style},onDragEnd:()=>{wt(!1),nt(null),qn.current=null},onPointerDown:en=>{xn||!pr||(Jt.current=new Date,Pr(ua.current),en.target.setPointerCapture(en.pointerId),en.target.tagName!=="BUTTON"&&(wt(!0),qn.current={x:en.clientX,y:en.clientY}))},onPointerUp:()=>{var en,Fn,ti,bl;if(lr||!pr)return;qn.current=null;let el=Number(((en=Ir.current)==null?void 0:en.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),Ft=Number(((Fn=Ir.current)==null?void 0:Fn.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),Bo=new Date().getTime()-((ti=Jt.current)==null?void 0:ti.getTime()),js=qe==="x"?el:Ft,Ci=Math.abs(js)/Bo;if(Math.abs(js)>=HOe||Ci>.11){Pr(ua.current),(bl=E.onDismiss)==null||bl.call(E,E),jt(qe==="x"?el>0?"right":"left":Ft>0?"down":"up"),Xr(),Sr(!0),cr(!1);return}wt(!1),nt(null)},onPointerMove:en=>{var Fn,ti,bl,el;if(!qn.current||!pr||((Fn=window.getSelection())==null?void 0:Fn.toString().length)>0)return;let Ft=en.clientY-qn.current.y,Bo=en.clientX-qn.current.x,js=(ti=t.swipeDirections)!=null?ti:KOe(Le);!qe&&(Math.abs(Bo)>1||Math.abs(Ft)>1)&&nt(Math.abs(Bo)>Math.abs(Ft)?"x":"y");let Ci={x:0,y:0};qe==="y"?(js.includes("top")||js.includes("bottom"))&&(js.includes("top")&&Ft<0||js.includes("bottom")&&Ft>0)&&(Ci.y=Ft):qe==="x"&&(js.includes("left")||js.includes("right"))&&(js.includes("left")&&Bo<0||js.includes("right")&&Bo>0)&&(Ci.x=Bo),(Math.abs(Ci.x)>0||Math.abs(Ci.y)>0)&&cr(!0),(bl=Ir.current)==null||bl.style.setProperty("--swipe-amount-x",`${Ci.x}px`),(el=Ir.current)==null||el.style.setProperty("--swipe-amount-y",`${Ci.y}px`)}},Us&&!E.jsx?Xe.createElement("button",{"aria-label":Ee,"data-disabled":xn,"data-close-button":!0,onClick:xn||!pr?()=>{}:()=>{var en;Xr(),(en=E.onDismiss)==null||en.call(E,E)},className:zh(je==null?void 0:je.closeButton,(s=E==null?void 0:E.classNames)==null?void 0:s.closeButton)},(o=_e==null?void 0:_e.close)!=null?o:POe):null,E.jsx||N.isValidElement(E.title)?E.jsx?E.jsx:typeof E.title=="function"?E.title():E.title:Xe.createElement(Xe.Fragment,null,It||E.icon||E.promise?Xe.createElement("div",{"data-icon":"",className:zh(je==null?void 0:je.icon,(c=E==null?void 0:E.classNames)==null?void 0:c.icon)},E.promise||E.type==="loading"&&!E.icon?E.icon||ds():null,E.type!=="loading"?E.icon||(_e==null?void 0:_e[It])||EOe(It):null):null,Xe.createElement("div",{"data-content":"",className:zh(je==null?void 0:je.content,(a=E==null?void 0:E.classNames)==null?void 0:a.content)},Xe.createElement("div",{"data-title":"",className:zh(je==null?void 0:je.title,(f=E==null?void 0:E.classNames)==null?void 0:f.title)},typeof E.title=="function"?E.title():E.title),E.description?Xe.createElement("div",{"data-description":"",className:zh(Te,ss,je==null?void 0:je.description,(p=E==null?void 0:E.classNames)==null?void 0:p.description)},typeof E.description=="function"?E.description():E.description):null),N.isValidElement(E.cancel)?E.cancel:E.cancel&&aR(E.cancel)?Xe.createElement("button",{"data-button":!0,"data-cancel":!0,style:E.cancelButtonStyle||ee,onClick:en=>{var Fn,ti;aR(E.cancel)&&pr&&((ti=(Fn=E.cancel).onClick)==null||ti.call(Fn,en),Xr())},className:zh(je==null?void 0:je.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&&aR(E.action)?Xe.createElement("button",{"data-button":!0,"data-action":!0,style:E.actionButtonStyle||le,onClick:en=>{var Fn,ti;aR(E.action)&&((ti=(Fn=E.action).onClick)==null||ti.call(Fn,en),!en.defaultPrevented&&Xr())},className:zh(je==null?void 0:je.actionButton,(v=E==null?void 0:E.classNames)==null?void 0:v.actionButton)},E.action.label):null))};function hte(){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 ZOe(t,e){let r={};return[t,e].forEach((n,s)=>{let o=s===1,c=o?"--mobile-offset":"--offset",a=o?VOe:UOe;function f(p){["top","right","bottom","left"].forEach(y=>{r[`${c}-${y}`]=typeof p=="number"?`${p}px`:p})}typeof n=="number"||typeof n=="string"?f(n):typeof n=="object"?["top","right","bottom","left"].forEach(p=>{n[p]===void 0?r[`${c}-${p}`]=a:r[`${c}-${p}`]=typeof n[p]=="number"?`${n[p]}px`:n[p]}):f(a)}),r}var XOe=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:p,theme:y="light",richColors:v,duration:S,style:E,visibleToasts:k=zOe,toastOptions:R,dir:P=hte(),gap:M=GOe,loadingIcon:D,icons:B,containerAriaLabel:V="Notifications",pauseWhenPageIsHidden:G}=t,[W,Y]=Xe.useState([]),J=Xe.useMemo(()=>Array.from(new Set([n].concat(W.filter(ve=>ve.position).map(ve=>ve.position)))),[W,n]),[Q,ee]=Xe.useState([]),[le,pe]=Xe.useState(!1),[Te,Ae]=Xe.useState(!1),[Le,ke]=Xe.useState(y!=="system"?y:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),we=Xe.useRef(null),me=s.join("+").replace(/Key/g,"").replace(/Digit/g,""),je=Xe.useRef(null),_e=Xe.useRef(!1),Ee=Xe.useCallback(ve=>{Y(qe=>{var nt;return(nt=qe.find(ot=>ot.id===ve.id))!=null&&nt.delete||Au.dismiss(ve.id),qe.filter(({id:ot})=>ot!==ve.id)})},[]);return Xe.useEffect(()=>Au.subscribe(ve=>{if(ve.dismiss){Y(qe=>qe.map(nt=>nt.id===ve.id?{...nt,delete:!0}:nt));return}setTimeout(()=>{Zfe.flushSync(()=>{Y(qe=>{let nt=qe.findIndex(ot=>ot.id===ve.id);return nt!==-1?[...qe.slice(0,nt),{...qe[nt],...ve},...qe.slice(nt+1)]:[ve,...qe]})})})}),[]),Xe.useEffect(()=>{if(y!=="system"){ke(y);return}if(y==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?ke("dark"):ke("light")),typeof window>"u")return;let ve=window.matchMedia("(prefers-color-scheme: dark)");try{ve.addEventListener("change",({matches:qe})=>{ke(qe?"dark":"light")})}catch{ve.addListener(({matches:nt})=>{try{ke(nt?"dark":"light")}catch(ot){console.error(ot)}})}},[y]),Xe.useEffect(()=>{W.length<=1&&pe(!1)},[W]),Xe.useEffect(()=>{let ve=qe=>{var nt,ot;s.every(jt=>qe[jt]||qe.code===jt)&&(pe(!0),(nt=we.current)==null||nt.focus()),qe.code==="Escape"&&(document.activeElement===we.current||(ot=we.current)!=null&&ot.contains(document.activeElement))&&pe(!1)};return document.addEventListener("keydown",ve),()=>document.removeEventListener("keydown",ve)},[s]),Xe.useEffect(()=>{if(we.current)return()=>{je.current&&(je.current.focus({preventScroll:!0}),je.current=null,_e.current=!1)}},[we.current]),Xe.createElement("section",{ref:e,"aria-label":`${V} ${me}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},J.map((ve,qe)=>{var nt;let[ot,jt]=ve.split("-");return W.length?Xe.createElement("ol",{key:ve,dir:P==="auto"?hte():P,tabIndex:-1,ref:we,className:a,"data-sonner-toaster":!0,"data-theme":Le,"data-y-position":ot,"data-lifted":le&&W.length>1&&!o,"data-x-position":jt,style:{"--front-toast-height":`${((nt=Q[0])==null?void 0:nt.height)||0}px`,"--width":`${qOe}px`,"--gap":`${M}px`,...E,...ZOe(f,p)},onBlur:vt=>{_e.current&&!vt.currentTarget.contains(vt.relatedTarget)&&(_e.current=!1,je.current&&(je.current.focus({preventScroll:!0}),je.current=null))},onFocus:vt=>{vt.target instanceof HTMLElement&&vt.target.dataset.dismissible==="false"||_e.current||(_e.current=!0,je.current=vt.relatedTarget)},onMouseEnter:()=>pe(!0),onMouseMove:()=>pe(!0),onMouseLeave:()=>{Te||pe(!1)},onDragEnd:()=>pe(!1),onPointerDown:vt=>{vt.target instanceof HTMLElement&&vt.target.dataset.dismissible==="false"||Ae(!0)},onPointerUp:()=>Ae(!1)},W.filter(vt=>!vt.position&&qe===0||vt.position===ve).map((vt,Gt)=>{var pt,Ct;return Xe.createElement(YOe,{key:vt.id,icons:B,index:Gt,toast:vt,defaultRichColors:v,duration:(pt=R==null?void 0:R.duration)!=null?pt:S,className:R==null?void 0:R.className,descriptionClassName:R==null?void 0:R.descriptionClassName,invert:r,visibleToasts:k,closeButton:(Ct=R==null?void 0:R.closeButton)!=null?Ct:c,interacting:Te,position:ve,style:R==null?void 0:R.style,unstyled:R==null?void 0:R.unstyled,classNames:R==null?void 0:R.classNames,cancelButtonStyle:R==null?void 0:R.cancelButtonStyle,actionButtonStyle:R==null?void 0:R.actionButtonStyle,removeToast:Ee,toasts:W.filter(tr=>tr.position==vt.position),heights:Q.filter(tr=>tr.position==vt.position),setHeights:ee,expandByDefault:o,gap:M,loadingIcon:D,expanded:le,pauseWhenPageIsHidden:G,swipeDirections:t.swipeDirections})})):null}))});const QOe=({...t})=>{const{theme:e="system"}=TOe();return i.jsx(XOe,{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 JOe=VG[" useId ".trim().toString()]||(()=>{}),e3e=0;function Fl(t){const[e,r]=N.useState(JOe());return Do(()=>{r(n=>n??String(e3e++))},[t]),e?`radix-${e}`:""}var j$="focusScope.autoFocusOnMount",A$="focusScope.autoFocusOnUnmount",fte={bubbles:!1,cancelable:!0},t3e="FocusScope",IN=N.forwardRef((t,e)=>{const{loop:r=!1,trapped:n=!1,onMountAutoFocus:s,onUnmountAutoFocus:o,...c}=t,[a,f]=N.useState(null),p=_o(s),y=_o(o),v=N.useRef(null),S=Zn(e,R=>f(R)),E=N.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;N.useEffect(()=>{if(n){let R=function(B){if(E.paused||!a)return;const V=B.target;a.contains(V)?v.current=V:by(v.current,{select:!0})},P=function(B){if(E.paused||!a)return;const V=B.relatedTarget;V!==null&&(a.contains(V)||by(v.current,{select:!0}))},M=function(B){if(document.activeElement===document.body)for(const G of B)G.removedNodes.length>0&&by(a)};document.addEventListener("focusin",R),document.addEventListener("focusout",P);const D=new MutationObserver(M);return a&&D.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",R),document.removeEventListener("focusout",P),D.disconnect()}}},[n,a,E.paused]),N.useEffect(()=>{if(a){pte.add(E);const R=document.activeElement;if(!a.contains(R)){const M=new CustomEvent(j$,fte);a.addEventListener(j$,p),a.dispatchEvent(M),M.defaultPrevented||(r3e(o3e(Jme(a)),{select:!0}),document.activeElement===R&&by(a))}return()=>{a.removeEventListener(j$,p),setTimeout(()=>{const M=new CustomEvent(A$,fte);a.addEventListener(A$,y),a.dispatchEvent(M),M.defaultPrevented||by(R??document.body,{select:!0}),a.removeEventListener(A$,y),pte.remove(E)},0)}}},[a,p,y,E]);const k=N.useCallback(R=>{if(!r&&!n||E.paused)return;const P=R.key==="Tab"&&!R.altKey&&!R.ctrlKey&&!R.metaKey,M=document.activeElement;if(P&&M){const D=R.currentTarget,[B,V]=n3e(D);B&&V?!R.shiftKey&&M===V?(R.preventDefault(),r&&by(B,{select:!0})):R.shiftKey&&M===B&&(R.preventDefault(),r&&by(V,{select:!0})):M===D&&R.preventDefault()}},[r,n,E.paused]);return i.jsx(nn.div,{tabIndex:-1,...c,ref:S,onKeyDown:k})});IN.displayName=t3e;function r3e(t,{select:e=!1}={}){const r=document.activeElement;for(const n of t)if(by(n,{select:e}),document.activeElement!==r)return}function n3e(t){const e=Jme(t),r=mte(e,t),n=mte(e.reverse(),t);return[r,n]}function Jme(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 mte(t,e){for(const r of t)if(!s3e(r,{upTo:e}))return r}function s3e(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 i3e(t){return t instanceof HTMLInputElement&&"select"in t}function by(t,{select:e=!1}={}){if(t&&t.focus){const r=document.activeElement;t.focus({preventScroll:!0}),t!==r&&i3e(t)&&e&&t.select()}}var pte=a3e();function a3e(){let t=[];return{add(e){const r=t[0];e!==r&&(r==null||r.pause()),t=gte(t,e),t.unshift(e)},remove(e){var r;t=gte(t,e),(r=t[0])==null||r.resume()}}}function gte(t,e){const r=[...t],n=r.indexOf(e);return n!==-1&&r.splice(n,1),r}function o3e(t){return t.filter(e=>e.tagName!=="A")}var k$=0;function u3(){N.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??yte()),document.body.insertAdjacentElement("beforeend",t[1]??yte()),k$++,()=>{k$===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),k$--}},[])}function yte(){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 dm=function(){return dm=Object.assign||function(e){for(var r,n=1,s=arguments.length;n"u")return T3e;var e=E3e(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])}},A3e=npe(),A1="data-scroll-locked",k3e=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(c3e,` { overflow: hidden `).concat(n,`; padding-right: `).concat(a,"px ").concat(n,`; } body[`).concat(A1,`] { 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(CL,` { right: `).concat(a,"px ").concat(n,`; } .`).concat(IL,` { margin-right: `).concat(a,"px ").concat(n,`; } .`).concat(CL," .").concat(CL,` { right: 0 `).concat(n,`; } .`).concat(IL," .").concat(IL,` { margin-right: 0 `).concat(n,`; } body[`).concat(A1,`] { `).concat(u3e,": ").concat(a,`px; } `)},vte=function(){var t=parseInt(document.body.getAttribute(A1)||"0",10);return isFinite(t)?t:0},N3e=function(){N.useEffect(function(){return document.body.setAttribute(A1,(vte()+1).toString()),function(){var t=vte()-1;t<=0?document.body.removeAttribute(A1):document.body.setAttribute(A1,t.toString())}},[])},C3e=function(t){var e=t.noRelative,r=t.noImportant,n=t.gapMode,s=n===void 0?"margin":n;N3e();var o=N.useMemo(function(){return j3e(s)},[s]);return N.createElement(A3e,{styles:k3e(o,!e,s,r?"":"!important")})},iV=!1;if(typeof window<"u")try{var oR=Object.defineProperty({},"passive",{get:function(){return iV=!0,!0}});window.addEventListener("test",oR,oR),window.removeEventListener("test",oR,oR)}catch{iV=!1}var yw=iV?{passive:!1}:!1,I3e=function(t){return t.tagName==="TEXTAREA"},spe=function(t,e){if(!(t instanceof Element))return!1;var r=window.getComputedStyle(t);return r[e]!=="hidden"&&!(r.overflowY===r.overflowX&&!I3e(t)&&r[e]==="visible")},P3e=function(t){return spe(t,"overflowY")},R3e=function(t){return spe(t,"overflowX")},_te=function(t,e){var r=e.ownerDocument,n=e;do{typeof ShadowRoot<"u"&&n instanceof ShadowRoot&&(n=n.host);var s=ipe(t,n);if(s){var o=ape(t,n),c=o[1],a=o[2];if(c>a)return!0}n=n.parentNode}while(n&&n!==r.body);return!1},L3e=function(t){var e=t.scrollTop,r=t.scrollHeight,n=t.clientHeight;return[e,r,n]},M3e=function(t){var e=t.scrollLeft,r=t.scrollWidth,n=t.clientWidth;return[e,r,n]},ipe=function(t,e){return t==="v"?P3e(e):R3e(e)},ape=function(t,e){return t==="v"?L3e(e):M3e(e)},D3e=function(t,e){return t==="h"&&e==="rtl"?-1:1},O3e=function(t,e,r,n,s){var o=D3e(t,window.getComputedStyle(e).direction),c=o*n,a=r.target,f=e.contains(a),p=!1,y=c>0,v=0,S=0;do{if(!a)break;var E=ape(t,a),k=E[0],R=E[1],P=E[2],M=R-P-o*k;(k||M)&&ipe(t,a)&&(v+=M,S+=k);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(v)<1||!s)||!y&&(Math.abs(S)<1||!s))&&(p=!0),p},lR=function(t){return"changedTouches"in t?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0]},bte=function(t){return[t.deltaX,t.deltaY]},wte=function(t){return t&&"current"in t?t.current:t},F3e=function(t,e){return t[0]===e[0]&&t[1]===e[1]},B3e=function(t){return` .block-interactivity-`.concat(t,` {pointer-events: none;} .allow-interactivity-`).concat(t,` {pointer-events: all;} `)},$3e=0,xw=[];function z3e(t){var e=N.useRef([]),r=N.useRef([0,0]),n=N.useRef(),s=N.useState($3e++)[0],o=N.useState(npe)[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 R=l3e([t.lockRef.current],(t.shards||[]).map(wte),!0).filter(Boolean);return R.forEach(function(P){return P.classList.add("allow-interactivity-".concat(s))}),function(){document.body.classList.remove("block-interactivity-".concat(s)),R.forEach(function(P){return P.classList.remove("allow-interactivity-".concat(s))})}}},[t.inert,t.lockRef.current,t.shards]);var a=N.useCallback(function(R,P){if("touches"in R&&R.touches.length===2||R.type==="wheel"&&R.ctrlKey)return!c.current.allowPinchZoom;var M=lR(R),D=r.current,B="deltaX"in R?R.deltaX:D[0]-M[0],V="deltaY"in R?R.deltaY:D[1]-M[1],G,W=R.target,Y=Math.abs(B)>Math.abs(V)?"h":"v";if("touches"in R&&Y==="h"&&W.type==="range")return!1;var J=_te(Y,W);if(!J)return!0;if(J?G=Y:(G=Y==="v"?"h":"v",J=_te(Y,W)),!J)return!1;if(!n.current&&"changedTouches"in R&&(B||V)&&(n.current=G),!G)return!0;var Q=n.current||G;return O3e(Q,P,R,Q==="h"?B:V,!0)},[]),f=N.useCallback(function(R){var P=R;if(!(!xw.length||xw[xw.length-1]!==o)){var M="deltaY"in P?bte(P):lR(P),D=e.current.filter(function(G){return G.name===P.type&&(G.target===P.target||P.target===G.shadowParent)&&F3e(G.delta,M)})[0];if(D&&D.should){P.cancelable&&P.preventDefault();return}if(!D){var B=(c.current.shards||[]).map(wte).filter(Boolean).filter(function(G){return G.contains(P.target)}),V=B.length>0?a(P,B[0]):!c.current.noIsolation;V&&P.cancelable&&P.preventDefault()}}},[]),p=N.useCallback(function(R,P,M,D){var B={name:R,delta:P,target:M,should:D,shadowParent:U3e(M)};e.current.push(B),setTimeout(function(){e.current=e.current.filter(function(V){return V!==B})},1)},[]),y=N.useCallback(function(R){r.current=lR(R),n.current=void 0},[]),v=N.useCallback(function(R){p(R.type,bte(R),R.target,a(R,t.lockRef.current))},[]),S=N.useCallback(function(R){p(R.type,lR(R),R.target,a(R,t.lockRef.current))},[]);N.useEffect(function(){return xw.push(o),t.setCallbacks({onScrollCapture:v,onWheelCapture:v,onTouchMoveCapture:S}),document.addEventListener("wheel",f,yw),document.addEventListener("touchmove",f,yw),document.addEventListener("touchstart",y,yw),function(){xw=xw.filter(function(R){return R!==o}),document.removeEventListener("wheel",f,yw),document.removeEventListener("touchmove",f,yw),document.removeEventListener("touchstart",y,yw)}},[]);var E=t.removeScrollBar,k=t.inert;return N.createElement(N.Fragment,null,k?N.createElement(o,{styles:B3e(s)}):null,E?N.createElement(C3e,{noRelative:t.noRelative,gapMode:t.gapMode}):null)}function U3e(t){for(var e=null;t!==null;)t instanceof ShadowRoot&&(e=t.host,t=t.host),t=t.parentNode;return e}const V3e=y3e(rpe,z3e);var PN=N.forwardRef(function(t,e){return N.createElement(d3,dm({},t,{ref:e,sideCar:V3e}))});PN.classNames=d3.classNames;var q3e=function(t){if(typeof document>"u")return null;var e=Array.isArray(t)?t[0]:t;return e.ownerDocument.body},vw=new WeakMap,cR=new WeakMap,uR={},P$=0,ope=function(t){return t&&(t.host||ope(t.parentNode))},G3e=function(t,e){return e.map(function(r){if(t.contains(r))return r;var n=ope(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})},H3e=function(t,e,r,n){var s=G3e(e,Array.isArray(t)?t:[t]);uR[r]||(uR[r]=new WeakMap);var o=uR[r],c=[],a=new Set,f=new Set(s),p=function(v){!v||a.has(v)||(a.add(v),p(v.parentNode))};s.forEach(p);var y=function(v){!v||f.has(v)||Array.prototype.forEach.call(v.children,function(S){if(a.has(S))y(S);else try{var E=S.getAttribute(n),k=E!==null&&E!=="false",R=(vw.get(S)||0)+1,P=(o.get(S)||0)+1;vw.set(S,R),o.set(S,P),c.push(S),R===1&&k&&cR.set(S,!0),P===1&&S.setAttribute(r,"true"),k||S.setAttribute(n,"true")}catch(M){console.error("aria-hidden: cannot operate on ",S,M)}})};return y(e),a.clear(),P$++,function(){c.forEach(function(v){var S=vw.get(v)-1,E=o.get(v)-1;vw.set(v,S),o.set(v,E),S||(cR.has(v)||v.removeAttribute(n),cR.delete(v)),E||v.removeAttribute(r)}),P$--,P$||(vw=new WeakMap,vw=new WeakMap,cR=new WeakMap,uR={})}},h3=function(t,e,r){r===void 0&&(r="data-aria-hidden");var n=Array.from(Array.isArray(t)?t:[t]),s=q3e(t);return s?(n.push.apply(n,Array.from(s.querySelectorAll("[aria-live]"))),H3e(n,s,r,"aria-hidden")):function(){return null}},f3="Dialog",[lpe,cpe]=Jo(f3),[W3e,Ef]=lpe(f3),upe=t=>{const{__scopeDialog:e,children:r,open:n,defaultOpen:s,onOpenChange:o,modal:c=!0}=t,a=N.useRef(null),f=N.useRef(null),[p,y]=_d({prop:n,defaultProp:s??!1,onChange:o,caller:f3});return i.jsx(W3e,{scope:e,triggerRef:a,contentRef:f,contentId:Fl(),titleId:Fl(),descriptionId:Fl(),open:p,onOpenChange:y,onOpenToggle:N.useCallback(()=>y(v=>!v),[y]),modal:c,children:r})};upe.displayName=f3;var dpe="DialogTrigger",hpe=N.forwardRef((t,e)=>{const{__scopeDialog:r,...n}=t,s=Ef(dpe,r),o=Zn(e,s.triggerRef);return i.jsx(nn.button,{type:"button","aria-haspopup":"dialog","aria-expanded":s.open,"aria-controls":s.contentId,"data-state":J9(s.open),...n,ref:o,onClick:Fr(t.onClick,s.onOpenToggle)})});hpe.displayName=dpe;var X9="DialogPortal",[K3e,fpe]=lpe(X9,{forceMount:void 0}),mpe=t=>{const{__scopeDialog:e,forceMount:r,children:n,container:s}=t,o=Ef(X9,e);return i.jsx(K3e,{scope:e,forceMount:r,children:N.Children.map(n,c=>i.jsx(vl,{present:r||o.open,children:i.jsx(iT,{asChild:!0,container:s,children:c})}))})};mpe.displayName=X9;var FM="DialogOverlay",ppe=N.forwardRef((t,e)=>{const r=fpe(FM,t.__scopeDialog),{forceMount:n=r.forceMount,...s}=t,o=Ef(FM,t.__scopeDialog);return o.modal?i.jsx(vl,{present:n||o.open,children:i.jsx(Z3e,{...s,ref:e})}):null});ppe.displayName=FM;var Y3e=gx("DialogOverlay.RemoveScroll"),Z3e=N.forwardRef((t,e)=>{const{__scopeDialog:r,...n}=t,s=Ef(FM,r);return i.jsx(PN,{as:Y3e,allowPinchZoom:!0,shards:[s.contentRef],children:i.jsx(nn.div,{"data-state":J9(s.open),...n,ref:e,style:{pointerEvents:"auto",...n.style}})})}),u_="DialogContent",gpe=N.forwardRef((t,e)=>{const r=fpe(u_,t.__scopeDialog),{forceMount:n=r.forceMount,...s}=t,o=Ef(u_,t.__scopeDialog);return i.jsx(vl,{present:n||o.open,children:o.modal?i.jsx(X3e,{...s,ref:e}):i.jsx(Q3e,{...s,ref:e})})});gpe.displayName=u_;var X3e=N.forwardRef((t,e)=>{const r=Ef(u_,t.__scopeDialog),n=N.useRef(null),s=Zn(e,r.contentRef,n);return N.useEffect(()=>{const o=n.current;if(o)return h3(o)},[]),i.jsx(ype,{...t,ref:s,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Fr(t.onCloseAutoFocus,o=>{var c;o.preventDefault(),(c=r.triggerRef.current)==null||c.focus()}),onPointerDownOutside:Fr(t.onPointerDownOutside,o=>{const c=o.detail.originalEvent,a=c.button===0&&c.ctrlKey===!0;(c.button===2||a)&&o.preventDefault()}),onFocusOutside:Fr(t.onFocusOutside,o=>o.preventDefault())})}),Q3e=N.forwardRef((t,e)=>{const r=Ef(u_,t.__scopeDialog),n=N.useRef(!1),s=N.useRef(!1);return i.jsx(ype,{...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,p;(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;((p=r.triggerRef.current)==null?void 0:p.contains(c))&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&s.current&&o.preventDefault()}})}),ype=N.forwardRef((t,e)=>{const{__scopeDialog:r,trapFocus:n,onOpenAutoFocus:s,onCloseAutoFocus:o,...c}=t,a=Ef(u_,r),f=N.useRef(null),p=Zn(e,f);return u3(),i.jsxs(i.Fragment,{children:[i.jsx(IN,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:s,onUnmountAutoFocus:o,children:i.jsx(A_,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":J9(a.open),...c,ref:p,onDismiss:()=>a.onOpenChange(!1)})}),i.jsxs(i.Fragment,{children:[i.jsx(eFe,{titleId:a.titleId}),i.jsx(rFe,{contentRef:f,descriptionId:a.descriptionId})]})]})}),Q9="DialogTitle",xpe=N.forwardRef((t,e)=>{const{__scopeDialog:r,...n}=t,s=Ef(Q9,r);return i.jsx(nn.h2,{id:s.titleId,...n,ref:e})});xpe.displayName=Q9;var vpe="DialogDescription",_pe=N.forwardRef((t,e)=>{const{__scopeDialog:r,...n}=t,s=Ef(vpe,r);return i.jsx(nn.p,{id:s.descriptionId,...n,ref:e})});_pe.displayName=vpe;var bpe="DialogClose",wpe=N.forwardRef((t,e)=>{const{__scopeDialog:r,...n}=t,s=Ef(bpe,r);return i.jsx(nn.button,{type:"button",...n,ref:e,onClick:Fr(t.onClick,()=>s.onOpenChange(!1))})});wpe.displayName=bpe;function J9(t){return t?"open":"closed"}var Spe="DialogTitleWarning",[J3e,Tpe]=JLe(Spe,{contentName:u_,titleName:Q9,docsSlug:"dialog"}),eFe=({titleId:t})=>{const e=Tpe(Spe),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},tFe="DialogDescriptionWarning",rFe=({contentRef:t,descriptionId:e})=>{const n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Tpe(tFe).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},m3=upe,e7=hpe,p3=mpe,uT=ppe,dT=gpe,RN=xpe,LN=_pe,MN=wpe,Epe="AlertDialog",[nFe,Jqt]=Jo(Epe,[cpe]),vg=cpe(),jpe=t=>{const{__scopeAlertDialog:e,...r}=t,n=vg(e);return i.jsx(m3,{...n,...r,modal:!0})};jpe.displayName=Epe;var sFe="AlertDialogTrigger",Ape=N.forwardRef((t,e)=>{const{__scopeAlertDialog:r,...n}=t,s=vg(r);return i.jsx(e7,{...s,...n,ref:e})});Ape.displayName=sFe;var iFe="AlertDialogPortal",kpe=t=>{const{__scopeAlertDialog:e,...r}=t,n=vg(e);return i.jsx(p3,{...n,...r})};kpe.displayName=iFe;var aFe="AlertDialogOverlay",Npe=N.forwardRef((t,e)=>{const{__scopeAlertDialog:r,...n}=t,s=vg(r);return i.jsx(uT,{...s,...n,ref:e})});Npe.displayName=aFe;var k1="AlertDialogContent",[oFe,lFe]=nFe(k1),cFe=nme("AlertDialogContent"),Cpe=N.forwardRef((t,e)=>{const{__scopeAlertDialog:r,children:n,...s}=t,o=vg(r),c=N.useRef(null),a=Zn(e,c),f=N.useRef(null);return i.jsx(J3e,{contentName:k1,titleName:Ipe,docsSlug:"alert-dialog",children:i.jsx(oFe,{scope:r,cancelRef:f,children:i.jsxs(dT,{role:"alertdialog",...o,...s,ref:a,onOpenAutoFocus:Fr(s.onOpenAutoFocus,p=>{var y;p.preventDefault(),(y=f.current)==null||y.focus({preventScroll:!0})}),onPointerDownOutside:p=>p.preventDefault(),onInteractOutside:p=>p.preventDefault(),children:[i.jsx(cFe,{children:n}),i.jsx(dFe,{contentRef:c})]})})})});Cpe.displayName=k1;var Ipe="AlertDialogTitle",Ppe=N.forwardRef((t,e)=>{const{__scopeAlertDialog:r,...n}=t,s=vg(r);return i.jsx(RN,{...s,...n,ref:e})});Ppe.displayName=Ipe;var Rpe="AlertDialogDescription",Lpe=N.forwardRef((t,e)=>{const{__scopeAlertDialog:r,...n}=t,s=vg(r);return i.jsx(LN,{...s,...n,ref:e})});Lpe.displayName=Rpe;var uFe="AlertDialogAction",Mpe=N.forwardRef((t,e)=>{const{__scopeAlertDialog:r,...n}=t,s=vg(r);return i.jsx(MN,{...s,...n,ref:e})});Mpe.displayName=uFe;var Dpe="AlertDialogCancel",Ope=N.forwardRef((t,e)=>{const{__scopeAlertDialog:r,...n}=t,{cancelRef:s}=lFe(Dpe,r),o=vg(r),c=Zn(e,s);return i.jsx(MN,{...o,...n,ref:c})});Ope.displayName=Dpe;var dFe=({contentRef:t})=>{const e=`\`${k1}\` requires a description for the component to be accessible for screen reader users. You can add a description to the \`${k1}\` by passing a \`${Rpe}\` 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 \`${k1}\`. 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},hFe=jpe,fFe=Ape,mFe=kpe,Fpe=Npe,Bpe=Cpe,$pe=Mpe,zpe=Ope,Upe=Ppe,Vpe=Lpe;const tk=aT("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"}}),Dt=N.forwardRef(({className:t,variant:e,size:r,asChild:n=!1,...s},o)=>{const c=n?tme:"button";return i.jsx(c,{className:qt(tk({variant:e,size:r,className:t})),ref:o,...s})});Dt.displayName="Button";const qpe=hFe,eGt=fFe,pFe=mFe,Gpe=N.forwardRef(({className:t,...e},r)=>i.jsx(Fpe,{className:qt("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}));Gpe.displayName=Fpe.displayName;const t7=N.forwardRef(({className:t,...e},r)=>i.jsxs(pFe,{children:[i.jsx(Gpe,{}),i.jsx(Bpe,{ref:r,className:qt("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})]}));t7.displayName=Bpe.displayName;const r7=({className:t,...e})=>i.jsx("div",{className:qt("flex flex-col space-y-2 text-center sm:text-left",t),...e});r7.displayName="AlertDialogHeader";const n7=({className:t,...e})=>i.jsx("div",{className:qt("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...e});n7.displayName="AlertDialogFooter";const s7=N.forwardRef(({className:t,...e},r)=>i.jsx(Upe,{ref:r,className:qt("text-lg font-semibold",t),...e}));s7.displayName=Upe.displayName;const i7=N.forwardRef(({className:t,...e},r)=>i.jsx(Vpe,{ref:r,className:qt("text-sm text-muted-foreground",t),...e}));i7.displayName=Vpe.displayName;const a7=N.forwardRef(({className:t,...e},r)=>i.jsx($pe,{ref:r,className:qt(tk(),t),...e}));a7.displayName=$pe.displayName;const o7=N.forwardRef(({className:t,...e},r)=>i.jsx(zpe,{ref:r,className:qt(tk({variant:"outline"}),"mt-2 sm:mt-0",t),...e}));o7.displayName=zpe.displayName;let BM=null;const gFe=["delete","remove","revoke","cannot be undone","permanently"];function tGt(t,e={}){const r=typeof t=="string"?{description:t,...e}:t,n=`${r.title??""} ${r.description??""}`.toLowerCase(),s=r.destructive??gFe.some(o=>n.includes(o));return new Promise(o=>{if(!BM){o(window.confirm(r.description??r.title??"Are you sure?"));return}BM({...r,destructive:s,resolve:o})})}function yFe(){const[t,e]=N.useState(null);N.useEffect(()=>(BM=s=>e(s),()=>{BM=null}),[]);const r=s=>{t==null||t.resolve(s),e(null)},n=!!(t!=null&&t.destructive);return i.jsx(qpe,{open:!!t,onOpenChange:s=>!s&&r(!1),children:i.jsxs(t7,{className:"sm:max-w-md",children:[i.jsx(r7,{children:i.jsxs("div",{className:"flex items-start gap-3",children:[i.jsx("div",{className:qt("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(lT,{className:"h-5 w-5"})}),i.jsxs("div",{className:"space-y-1.5 text-left",children:[i.jsx(s7,{children:(t==null?void 0:t.title)??(n?"Are you sure?":"Please confirm")}),(t==null?void 0:t.description)&&i.jsx(i7,{className:"leading-relaxed",children:t.description})]})]})}),i.jsxs(n7,{className:"gap-2 sm:gap-2",children:[i.jsx(o7,{onClick:()=>r(!1),children:(t==null?void 0:t.cancelText)??"Cancel"}),i.jsx(a7,{onClick:()=>r(!0),className:qt(n&&"bg-destructive text-destructive-foreground hover:bg-destructive/90"),children:(t==null?void 0:t.confirmText)??(n?"Delete":"Continue")})]})]})})}const xFe=["top","right","bottom","left"],vx=Math.min,cd=Math.max,$M=Math.round,dR=Math.floor,_x=t=>({x:t,y:t}),vFe={left:"right",right:"left",bottom:"top",top:"bottom"},_Fe={start:"end",end:"start"};function aV(t,e,r){return cd(t,vx(e,r))}function og(t,e){return typeof t=="function"?t(e):t}function lg(t){return t.split("-")[0]}function hT(t){return t.split("-")[1]}function l7(t){return t==="x"?"y":"x"}function c7(t){return t==="y"?"height":"width"}function bx(t){return["top","bottom"].includes(lg(t))?"y":"x"}function u7(t){return l7(bx(t))}function bFe(t,e,r){r===void 0&&(r=!1);const n=hT(t),s=u7(t),o=c7(s);let c=s==="x"?n===(r?"end":"start")?"right":"left":n==="start"?"bottom":"top";return e.reference[o]>e.floating[o]&&(c=zM(c)),[c,zM(c)]}function wFe(t){const e=zM(t);return[oV(t),e,oV(e)]}function oV(t){return t.replace(/start|end/g,e=>_Fe[e])}function SFe(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 TFe(t,e,r,n){const s=hT(t);let o=SFe(lg(t),r==="start",n);return s&&(o=o.map(c=>c+"-"+s),e&&(o=o.concat(o.map(oV)))),o}function zM(t){return t.replace(/left|right|bottom|top/g,e=>vFe[e])}function EFe(t){return{top:0,right:0,bottom:0,left:0,...t}}function Hpe(t){return typeof t!="number"?EFe(t):{top:t,right:t,bottom:t,left:t}}function UM(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 Ste(t,e,r){let{reference:n,floating:s}=t;const o=bx(e),c=u7(e),a=c7(c),f=lg(e),p=o==="y",y=n.x+n.width/2-s.width/2,v=n.y+n.height/2-s.height/2,S=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:v};break;case"left":E={x:n.x-s.width,y:v};break;default:E={x:n.x,y:n.y}}switch(hT(e)){case"start":E[c]-=S*(r&&p?-1:1);break;case"end":E[c]+=S*(r&&p?-1:1);break}return E}const jFe=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 p=await c.getElementRects({reference:t,floating:e,strategy:s}),{x:y,y:v}=Ste(p,n,f),S=n,E={},k=0;for(let R=0;R({name:"arrow",options:t,async fn(e){const{x:r,y:n,placement:s,rects:o,platform:c,elements:a,middlewareData:f}=e,{element:p,padding:y=0}=og(t,e)||{};if(p==null)return{};const v=Hpe(y),S={x:r,y:n},E=u7(s),k=c7(E),R=await c.getDimensions(p),P=E==="y",M=P?"top":"left",D=P?"bottom":"right",B=P?"clientHeight":"clientWidth",V=o.reference[k]+o.reference[E]-S[E]-o.floating[k],G=S[E]-o.reference[E],W=await(c.getOffsetParent==null?void 0:c.getOffsetParent(p));let Y=W?W[B]:0;(!Y||!await(c.isElement==null?void 0:c.isElement(W)))&&(Y=a.floating[B]||o.floating[k]);const J=V/2-G/2,Q=Y/2-R[k]/2-1,ee=vx(v[M],Q),le=vx(v[D],Q),pe=ee,Te=Y-R[k]-le,Ae=Y/2-R[k]/2+J,Le=aV(pe,Ae,Te),ke=!f.arrow&&hT(s)!=null&&Ae!==Le&&o.reference[k]/2-(AeAe<=0)){var le,pe;const Ae=(((le=o.flip)==null?void 0:le.index)||0)+1,Le=Y[Ae];if(Le)return{data:{index:Ae,overflows:ee},reset:{placement:Le}};let ke=(pe=ee.filter(we=>we.overflows[0]<=0).sort((we,me)=>we.overflows[1]-me.overflows[1])[0])==null?void 0:pe.placement;if(!ke)switch(E){case"bestFit":{var Te;const we=(Te=ee.filter(me=>{if(W){const je=bx(me.placement);return je===D||je==="y"}return!0}).map(me=>[me.placement,me.overflows.filter(je=>je>0).reduce((je,_e)=>je+_e,0)]).sort((me,je)=>me[1]-je[1])[0])==null?void 0:Te[0];we&&(ke=we);break}case"initialPlacement":ke=a;break}if(s!==ke)return{reset:{placement:ke}}}return{}}}};function Tte(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function Ete(t){return xFe.some(e=>t[e]>=0)}const NFe=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(e){const{rects:r}=e,{strategy:n="referenceHidden",...s}=og(t,e);switch(n){case"referenceHidden":{const o=await rk(e,{...s,elementContext:"reference"}),c=Tte(o,r.reference);return{data:{referenceHiddenOffsets:c,referenceHidden:Ete(c)}}}case"escaped":{const o=await rk(e,{...s,altBoundary:!0}),c=Tte(o,r.floating);return{data:{escapedOffsets:c,escaped:Ete(c)}}}default:return{}}}}};async function CFe(t,e){const{placement:r,platform:n,elements:s}=t,o=await(n.isRTL==null?void 0:n.isRTL(s.floating)),c=lg(r),a=hT(r),f=bx(r)==="y",p=["left","top"].includes(c)?-1:1,y=o&&f?-1:1,v=og(e,t);let{mainAxis:S,crossAxis:E,alignmentAxis:k}=typeof v=="number"?{mainAxis:v,crossAxis:0,alignmentAxis:null}:{mainAxis:v.mainAxis||0,crossAxis:v.crossAxis||0,alignmentAxis:v.alignmentAxis};return a&&typeof k=="number"&&(E=a==="end"?k*-1:k),f?{x:E*y,y:S*p}:{x:S*p,y:E*y}}const IFe=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 CFe(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}}}}},PFe=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:P=>{let{x:M,y:D}=P;return{x:M,y:D}}},...f}=og(t,e),p={x:r,y:n},y=await rk(e,f),v=bx(lg(s)),S=l7(v);let E=p[S],k=p[v];if(o){const P=S==="y"?"top":"left",M=S==="y"?"bottom":"right",D=E+y[P],B=E-y[M];E=aV(D,E,B)}if(c){const P=v==="y"?"top":"left",M=v==="y"?"bottom":"right",D=k+y[P],B=k-y[M];k=aV(D,k,B)}const R=a.fn({...e,[S]:E,[v]:k});return{...R,data:{x:R.x-r,y:R.y-n,enabled:{[S]:o,[v]:c}}}}}},RFe=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:p=!0}=og(t,e),y={x:r,y:n},v=bx(s),S=l7(v);let E=y[S],k=y[v];const R=og(a,e),P=typeof R=="number"?{mainAxis:R,crossAxis:0}:{mainAxis:0,crossAxis:0,...R};if(f){const B=S==="y"?"height":"width",V=o.reference[S]-o.floating[B]+P.mainAxis,G=o.reference[S]+o.reference[B]-P.mainAxis;EG&&(E=G)}if(p){var M,D;const B=S==="y"?"width":"height",V=["top","left"].includes(lg(s)),G=o.reference[v]-o.floating[B]+(V&&((M=c.offset)==null?void 0:M[v])||0)+(V?0:P.crossAxis),W=o.reference[v]+o.reference[B]+(V?0:((D=c.offset)==null?void 0:D[v])||0)-(V?P.crossAxis:0);kW&&(k=W)}return{[S]:E,[v]:k}}}},LFe=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=()=>{},...p}=og(t,e),y=await rk(e,p),v=lg(s),S=hT(s),E=bx(s)==="y",{width:k,height:R}=o.floating;let P,M;v==="top"||v==="bottom"?(P=v,M=S===(await(c.isRTL==null?void 0:c.isRTL(a.floating))?"start":"end")?"left":"right"):(M=v,P=S==="end"?"top":"bottom");const D=R-y.top-y.bottom,B=k-y.left-y.right,V=vx(R-y[P],D),G=vx(k-y[M],B),W=!e.middlewareData.shift;let Y=V,J=G;if((r=e.middlewareData.shift)!=null&&r.enabled.x&&(J=B),(n=e.middlewareData.shift)!=null&&n.enabled.y&&(Y=D),W&&!S){const ee=cd(y.left,0),le=cd(y.right,0),pe=cd(y.top,0),Te=cd(y.bottom,0);E?J=k-2*(ee!==0||le!==0?ee+le:cd(y.left,y.right)):Y=R-2*(pe!==0||Te!==0?pe+Te:cd(y.top,y.bottom))}await f({...e,availableWidth:J,availableHeight:Y});const Q=await c.getDimensions(a.floating);return k!==Q.width||R!==Q.height?{reset:{rects:!0}}:{}}}};function g3(){return typeof window<"u"}function fT(t){return Wpe(t)?(t.nodeName||"").toLowerCase():"#document"}function gd(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function Fm(t){var e;return(e=(Wpe(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function Wpe(t){return g3()?t instanceof Node||t instanceof gd(t).Node:!1}function bf(t){return g3()?t instanceof Element||t instanceof gd(t).Element:!1}function Cm(t){return g3()?t instanceof HTMLElement||t instanceof gd(t).HTMLElement:!1}function jte(t){return!g3()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof gd(t).ShadowRoot}function DN(t){const{overflow:e,overflowX:r,overflowY:n,display:s}=wf(t);return/auto|scroll|overlay|hidden|clip/.test(e+n+r)&&!["inline","contents"].includes(s)}function MFe(t){return["table","td","th"].includes(fT(t))}function y3(t){return[":popover-open",":modal"].some(e=>{try{return t.matches(e)}catch{return!1}})}function d7(t){const e=h7(),r=bf(t)?wf(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 DFe(t){let e=wx(t);for(;Cm(e)&&!hS(e);){if(d7(e))return e;if(y3(e))return null;e=wx(e)}return null}function h7(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function hS(t){return["html","body","#document"].includes(fT(t))}function wf(t){return gd(t).getComputedStyle(t)}function x3(t){return bf(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function wx(t){if(fT(t)==="html")return t;const e=t.assignedSlot||t.parentNode||jte(t)&&t.host||Fm(t);return jte(e)?e.host:e}function Kpe(t){const e=wx(t);return hS(e)?t.ownerDocument?t.ownerDocument.body:t.body:Cm(e)&&DN(e)?e:Kpe(e)}function nk(t,e,r){var n;e===void 0&&(e=[]),r===void 0&&(r=!0);const s=Kpe(t),o=s===((n=t.ownerDocument)==null?void 0:n.body),c=gd(s);if(o){const a=lV(c);return e.concat(c,c.visualViewport||[],DN(s)?s:[],a&&r?nk(a):[])}return e.concat(s,nk(s,[],r))}function lV(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function Ype(t){const e=wf(t);let r=parseFloat(e.width)||0,n=parseFloat(e.height)||0;const s=Cm(t),o=s?t.offsetWidth:r,c=s?t.offsetHeight:n,a=$M(r)!==o||$M(n)!==c;return a&&(r=o,n=c),{width:r,height:n,$:a}}function f7(t){return bf(t)?t:t.contextElement}function N1(t){const e=f7(t);if(!Cm(e))return _x(1);const r=e.getBoundingClientRect(),{width:n,height:s,$:o}=Ype(e);let c=(o?$M(r.width):r.width)/n,a=(o?$M(r.height):r.height)/s;return(!c||!Number.isFinite(c))&&(c=1),(!a||!Number.isFinite(a))&&(a=1),{x:c,y:a}}const OFe=_x(0);function Zpe(t){const e=gd(t);return!h7()||!e.visualViewport?OFe:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function FFe(t,e,r){return e===void 0&&(e=!1),!r||e&&r!==gd(t)?!1:e}function d_(t,e,r,n){e===void 0&&(e=!1),r===void 0&&(r=!1);const s=t.getBoundingClientRect(),o=f7(t);let c=_x(1);e&&(n?bf(n)&&(c=N1(n)):c=N1(t));const a=FFe(o,r,n)?Zpe(o):_x(0);let f=(s.left+a.x)/c.x,p=(s.top+a.y)/c.y,y=s.width/c.x,v=s.height/c.y;if(o){const S=gd(o),E=n&&bf(n)?gd(n):n;let k=S,R=lV(k);for(;R&&n&&E!==k;){const P=N1(R),M=R.getBoundingClientRect(),D=wf(R),B=M.left+(R.clientLeft+parseFloat(D.paddingLeft))*P.x,V=M.top+(R.clientTop+parseFloat(D.paddingTop))*P.y;f*=P.x,p*=P.y,y*=P.x,v*=P.y,f+=B,p+=V,k=gd(R),R=lV(k)}}return UM({width:y,height:v,x:f,y:p})}function BFe(t){let{elements:e,rect:r,offsetParent:n,strategy:s}=t;const o=s==="fixed",c=Fm(n),a=e?y3(e.floating):!1;if(n===c||a&&o)return r;let f={scrollLeft:0,scrollTop:0},p=_x(1);const y=_x(0),v=Cm(n);if((v||!v&&!o)&&((fT(n)!=="body"||DN(c))&&(f=x3(n)),Cm(n))){const S=d_(n);p=N1(n),y.x=S.x+n.clientLeft,y.y=S.y+n.clientTop}return{width:r.width*p.x,height:r.height*p.y,x:r.x*p.x-f.scrollLeft*p.x+y.x,y:r.y*p.y-f.scrollTop*p.y+y.y}}function $Fe(t){return Array.from(t.getClientRects())}function cV(t,e){const r=x3(t).scrollLeft;return e?e.left+r:d_(Fm(t)).left+r}function zFe(t){const e=Fm(t),r=x3(t),n=t.ownerDocument.body,s=cd(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),o=cd(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight);let c=-r.scrollLeft+cV(t);const a=-r.scrollTop;return wf(n).direction==="rtl"&&(c+=cd(e.clientWidth,n.clientWidth)-s),{width:s,height:o,x:c,y:a}}function UFe(t,e){const r=gd(t),n=Fm(t),s=r.visualViewport;let o=n.clientWidth,c=n.clientHeight,a=0,f=0;if(s){o=s.width,c=s.height;const p=h7();(!p||p&&e==="fixed")&&(a=s.offsetLeft,f=s.offsetTop)}return{width:o,height:c,x:a,y:f}}function VFe(t,e){const r=d_(t,!0,e==="fixed"),n=r.top+t.clientTop,s=r.left+t.clientLeft,o=Cm(t)?N1(t):_x(1),c=t.clientWidth*o.x,a=t.clientHeight*o.y,f=s*o.x,p=n*o.y;return{width:c,height:a,x:f,y:p}}function Ate(t,e,r){let n;if(e==="viewport")n=UFe(t,r);else if(e==="document")n=zFe(Fm(t));else if(bf(e))n=VFe(e,r);else{const s=Zpe(t);n={...e,x:e.x-s.x,y:e.y-s.y}}return UM(n)}function Xpe(t,e){const r=wx(t);return r===e||!bf(r)||hS(r)?!1:wf(r).position==="fixed"||Xpe(r,e)}function qFe(t,e){const r=e.get(t);if(r)return r;let n=nk(t,[],!1).filter(a=>bf(a)&&fT(a)!=="body"),s=null;const o=wf(t).position==="fixed";let c=o?wx(t):t;for(;bf(c)&&!hS(c);){const a=wf(c),f=d7(c);!f&&a.position==="fixed"&&(s=null),(o?!f&&!s:!f&&a.position==="static"&&!!s&&["absolute","fixed"].includes(s.position)||DN(c)&&!f&&Xpe(t,c))?n=n.filter(y=>y!==c):s=a,c=wx(c)}return e.set(t,n),n}function GFe(t){let{element:e,boundary:r,rootBoundary:n,strategy:s}=t;const c=[...r==="clippingAncestors"?y3(e)?[]:qFe(e,this._c):[].concat(r),n],a=c[0],f=c.reduce((p,y)=>{const v=Ate(e,y,s);return p.top=cd(v.top,p.top),p.right=vx(v.right,p.right),p.bottom=vx(v.bottom,p.bottom),p.left=cd(v.left,p.left),p},Ate(e,a,s));return{width:f.right-f.left,height:f.bottom-f.top,x:f.left,y:f.top}}function HFe(t){const{width:e,height:r}=Ype(t);return{width:e,height:r}}function WFe(t,e,r){const n=Cm(e),s=Fm(e),o=r==="fixed",c=d_(t,!0,o,e);let a={scrollLeft:0,scrollTop:0};const f=_x(0);if(n||!n&&!o)if((fT(e)!=="body"||DN(s))&&(a=x3(e)),n){const E=d_(e,!0,o,e);f.x=E.x+e.clientLeft,f.y=E.y+e.clientTop}else s&&(f.x=cV(s));let p=0,y=0;if(s&&!n&&!o){const E=s.getBoundingClientRect();y=E.top+a.scrollTop,p=E.left+a.scrollLeft-cV(s,E)}const v=c.left+a.scrollLeft-f.x-p,S=c.top+a.scrollTop-f.y-y;return{x:v,y:S,width:c.width,height:c.height}}function R$(t){return wf(t).position==="static"}function kte(t,e){if(!Cm(t)||wf(t).position==="fixed")return null;if(e)return e(t);let r=t.offsetParent;return Fm(t)===r&&(r=r.ownerDocument.body),r}function Qpe(t,e){const r=gd(t);if(y3(t))return r;if(!Cm(t)){let s=wx(t);for(;s&&!hS(s);){if(bf(s)&&!R$(s))return s;s=wx(s)}return r}let n=kte(t,e);for(;n&&MFe(n)&&R$(n);)n=kte(n,e);return n&&hS(n)&&R$(n)&&!d7(n)?r:n||DFe(t)||r}const KFe=async function(t){const e=this.getOffsetParent||Qpe,r=this.getDimensions,n=await r(t.floating);return{reference:WFe(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}};function YFe(t){return wf(t).direction==="rtl"}const ZFe={convertOffsetParentRelativeRectToViewportRelativeRect:BFe,getDocumentElement:Fm,getClippingRect:GFe,getOffsetParent:Qpe,getElementRects:KFe,getClientRects:$Fe,getDimensions:HFe,getScale:N1,isElement:bf,isRTL:YFe};function XFe(t,e){let r=null,n;const s=Fm(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:p,top:y,width:v,height:S}=t.getBoundingClientRect();if(a||e(),!v||!S)return;const E=dR(y),k=dR(s.clientWidth-(p+v)),R=dR(s.clientHeight-(y+S)),P=dR(p),D={rootMargin:-E+"px "+-k+"px "+-R+"px "+-P+"px",threshold:cd(0,vx(1,f))||1};let B=!0;function V(G){const W=G[0].intersectionRatio;if(W!==f){if(!B)return c();W?c(!1,W):n=setTimeout(()=>{c(!1,1e-7)},1e3)}B=!1}try{r=new IntersectionObserver(V,{...D,root:s.ownerDocument})}catch{r=new IntersectionObserver(V,D)}r.observe(t)}return c(!0),o}function QFe(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,p=f7(t),y=s||o?[...p?nk(p):[],...nk(e)]:[];y.forEach(M=>{s&&M.addEventListener("scroll",r,{passive:!0}),o&&M.addEventListener("resize",r)});const v=p&&a?XFe(p,r):null;let S=-1,E=null;c&&(E=new ResizeObserver(M=>{let[D]=M;D&&D.target===p&&E&&(E.unobserve(e),cancelAnimationFrame(S),S=requestAnimationFrame(()=>{var B;(B=E)==null||B.observe(e)})),r()}),p&&!f&&E.observe(p),E.observe(e));let k,R=f?d_(t):null;f&&P();function P(){const M=d_(t);R&&(M.x!==R.x||M.y!==R.y||M.width!==R.width||M.height!==R.height)&&r(),R=M,k=requestAnimationFrame(P)}return r(),()=>{var M;y.forEach(D=>{s&&D.removeEventListener("scroll",r),o&&D.removeEventListener("resize",r)}),v==null||v(),(M=E)==null||M.disconnect(),E=null,f&&cancelAnimationFrame(k)}}const JFe=IFe,e4e=PFe,t4e=kFe,r4e=LFe,n4e=NFe,Nte=AFe,s4e=RFe,i4e=(t,e,r)=>{const n=new Map,s={platform:ZFe,...r},o={...s.platform,_c:n};return jFe(t,e,{...s,platform:o})};var PL=typeof document<"u"?N.useLayoutEffect:N.useEffect;function VM(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(!VM(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)&&!VM(t[o],e[o]))return!1}return!0}return t!==t&&e!==e}function Jpe(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function Cte(t,e){const r=Jpe(t);return Math.round(e*r)/r}function L$(t){const e=N.useRef(t);return PL(()=>{e.current=t}),e}function a4e(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:p}=t,[y,v]=N.useState({x:0,y:0,strategy:r,placement:e,middlewareData:{},isPositioned:!1}),[S,E]=N.useState(n);VM(S,n)||E(n);const[k,R]=N.useState(null),[P,M]=N.useState(null),D=N.useCallback(me=>{me!==W.current&&(W.current=me,R(me))},[]),B=N.useCallback(me=>{me!==Y.current&&(Y.current=me,M(me))},[]),V=o||k,G=c||P,W=N.useRef(null),Y=N.useRef(null),J=N.useRef(y),Q=f!=null,ee=L$(f),le=L$(s),pe=L$(p),Te=N.useCallback(()=>{if(!W.current||!Y.current)return;const me={placement:e,strategy:r,middleware:S};le.current&&(me.platform=le.current),i4e(W.current,Y.current,me).then(je=>{const _e={...je,isPositioned:pe.current!==!1};Ae.current&&!VM(J.current,_e)&&(J.current=_e,xg.flushSync(()=>{v(_e)}))})},[S,e,r,le,pe]);PL(()=>{p===!1&&J.current.isPositioned&&(J.current.isPositioned=!1,v(me=>({...me,isPositioned:!1})))},[p]);const Ae=N.useRef(!1);PL(()=>(Ae.current=!0,()=>{Ae.current=!1}),[]),PL(()=>{if(V&&(W.current=V),G&&(Y.current=G),V&&G){if(ee.current)return ee.current(V,G,Te);Te()}},[V,G,Te,ee,Q]);const Le=N.useMemo(()=>({reference:W,floating:Y,setReference:D,setFloating:B}),[D,B]),ke=N.useMemo(()=>({reference:V,floating:G}),[V,G]),we=N.useMemo(()=>{const me={position:r,left:0,top:0};if(!ke.floating)return me;const je=Cte(ke.floating,y.x),_e=Cte(ke.floating,y.y);return a?{...me,transform:"translate("+je+"px, "+_e+"px)",...Jpe(ke.floating)>=1.5&&{willChange:"transform"}}:{position:r,left:je,top:_e}},[r,a,ke.floating,y.x,y.y]);return N.useMemo(()=>({...y,update:Te,refs:Le,elements:ke,floatingStyles:we}),[y,Te,Le,ke,we])}const o4e=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?Nte({element:n.current,padding:s}).fn(r):{}:n?Nte({element:n,padding:s}).fn(r):{}}}},l4e=(t,e)=>({...JFe(t),options:[t,e]}),c4e=(t,e)=>({...e4e(t),options:[t,e]}),u4e=(t,e)=>({...s4e(t),options:[t,e]}),d4e=(t,e)=>({...t4e(t),options:[t,e]}),h4e=(t,e)=>({...r4e(t),options:[t,e]}),f4e=(t,e)=>({...n4e(t),options:[t,e]}),m4e=(t,e)=>({...o4e(t),options:[t,e]});var p4e="Arrow",ege=N.forwardRef((t,e)=>{const{children:r,width:n=10,height:s=5,...o}=t;return i.jsx(nn.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"})})});ege.displayName=p4e;var g4e=ege;function ON(t){const[e,r]=N.useState(void 0);return Do(()=>{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,p=Array.isArray(f)?f[0]:f;c=p.inlineSize,a=p.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 m7="Popper",[tge,Ox]=Jo(m7),[y4e,rge]=tge(m7),nge=t=>{const{__scopePopper:e,children:r}=t,[n,s]=N.useState(null);return i.jsx(y4e,{scope:e,anchor:n,onAnchorChange:s,children:r})};nge.displayName=m7;var sge="PopperAnchor",ige=N.forwardRef((t,e)=>{const{__scopePopper:r,virtualRef:n,...s}=t,o=rge(sge,r),c=N.useRef(null),a=Zn(e,c);return N.useEffect(()=>{o.onAnchorChange((n==null?void 0:n.current)||c.current)}),n?null:i.jsx(nn.div,{...s,ref:a})});ige.displayName=sge;var p7="PopperContent",[x4e,v4e]=tge(p7),age=N.forwardRef((t,e)=>{var vt,Gt,pt,Ct,tr,wt;const{__scopePopper:r,side:n="bottom",sideOffset:s=0,align:o="center",alignOffset:c=0,arrowPadding:a=0,avoidCollisions:f=!0,collisionBoundary:p=[],collisionPadding:y=0,sticky:v="partial",hideWhenDetached:S=!1,updatePositionStrategy:E="optimized",onPlaced:k,...R}=t,P=rge(p7,r),[M,D]=N.useState(null),B=Zn(e,lr=>D(lr)),[V,G]=N.useState(null),W=ON(V),Y=(W==null?void 0:W.width)??0,J=(W==null?void 0:W.height)??0,Q=n+(o!=="center"?"-"+o:""),ee=typeof y=="number"?y:{top:0,right:0,bottom:0,left:0,...y},le=Array.isArray(p)?p:[p],pe=le.length>0,Te={padding:ee,boundary:le.filter(b4e),altBoundary:pe},{refs:Ae,floatingStyles:Le,placement:ke,isPositioned:we,middlewareData:me}=a4e({strategy:"fixed",placement:Q,whileElementsMounted:(...lr)=>QFe(...lr,{animationFrame:E==="always"}),elements:{reference:P.anchor},middleware:[l4e({mainAxis:s+J,alignmentAxis:c}),f&&c4e({mainAxis:!0,crossAxis:!1,limiter:v==="partial"?u4e():void 0,...Te}),f&&d4e({...Te}),h4e({...Te,apply:({elements:lr,rects:Sr,availableWidth:sn,availableHeight:cr})=>{const{width:yr,height:Pr}=Sr.reference,jn=lr.floating.style;jn.setProperty("--radix-popper-available-width",`${sn}px`),jn.setProperty("--radix-popper-available-height",`${cr}px`),jn.setProperty("--radix-popper-anchor-width",`${yr}px`),jn.setProperty("--radix-popper-anchor-height",`${Pr}px`)}}),V&&m4e({element:V,padding:a}),w4e({arrowWidth:Y,arrowHeight:J}),S&&f4e({strategy:"referenceHidden",...Te})]}),[je,_e]=cge(ke),Ee=_o(k);Do(()=>{we&&(Ee==null||Ee())},[we,Ee]);const ve=(vt=me.arrow)==null?void 0:vt.x,qe=(Gt=me.arrow)==null?void 0:Gt.y,nt=((pt=me.arrow)==null?void 0:pt.centerOffset)!==0,[ot,jt]=N.useState();return Do(()=>{M&&jt(window.getComputedStyle(M).zIndex)},[M]),i.jsx("div",{ref:Ae.setFloating,"data-radix-popper-content-wrapper":"",style:{...Le,transform:we?Le.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ot,"--radix-popper-transform-origin":[(Ct=me.transformOrigin)==null?void 0:Ct.x,(tr=me.transformOrigin)==null?void 0:tr.y].join(" "),...((wt=me.hide)==null?void 0:wt.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:i.jsx(x4e,{scope:r,placedSide:je,onArrowChange:G,arrowX:ve,arrowY:qe,shouldHideArrow:nt,children:i.jsx(nn.div,{"data-side":je,"data-align":_e,...R,ref:B,style:{...R.style,animation:we?void 0:"none"}})})})});age.displayName=p7;var oge="PopperArrow",_4e={top:"bottom",right:"left",bottom:"top",left:"right"},lge=N.forwardRef(function(e,r){const{__scopePopper:n,...s}=e,o=v4e(oge,n),c=_4e[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(g4e,{...s,ref:r,style:{...s.style,display:"block"}})})});lge.displayName=oge;function b4e(t){return t!==null}var w4e=t=>({name:"transformOrigin",options:t,fn(e){var P,M,D;const{placement:r,rects:n,middlewareData:s}=e,c=((P=s.arrow)==null?void 0:P.centerOffset)!==0,a=c?0:t.arrowWidth,f=c?0:t.arrowHeight,[p,y]=cge(r),v={start:"0%",center:"50%",end:"100%"}[y],S=(((M=s.arrow)==null?void 0:M.x)??0)+a/2,E=(((D=s.arrow)==null?void 0:D.y)??0)+f/2;let k="",R="";return p==="bottom"?(k=c?v:`${S}px`,R=`${-f}px`):p==="top"?(k=c?v:`${S}px`,R=`${n.floating.height+f}px`):p==="right"?(k=`${-f}px`,R=c?v:`${E}px`):p==="left"&&(k=`${n.floating.width+f}px`,R=c?v:`${E}px`),{data:{x:k,y:R}}}});function cge(t){const[e,r="center"]=t.split("-");return[e,r]}var v3=nge,FN=ige,_3=age,b3=lge,[w3,rGt]=Jo("Tooltip",[Ox]),S3=Ox(),uge="TooltipProvider",S4e=700,uV="tooltip.open",[T4e,g7]=w3(uge),dge=t=>{const{__scopeTooltip:e,delayDuration:r=S4e,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 p=f.current;return()=>window.clearTimeout(p)},[]),i.jsx(T4e,{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(p=>{a.current=p},[]),disableHoverableContent:s,children:o})};dge.displayName=uge;var sk="Tooltip",[E4e,T3]=w3(sk),hge=t=>{const{__scopeTooltip:e,children:r,open:n,defaultOpen:s,onOpenChange:o,disableHoverableContent:c,delayDuration:a}=t,f=g7(sk,t.__scopeTooltip),p=S3(e),[y,v]=N.useState(null),S=Fl(),E=N.useRef(0),k=c??f.disableHoverableContent,R=a??f.delayDuration,P=N.useRef(!1),[M,D]=_d({prop:n,defaultProp:s??!1,onChange:Y=>{Y?(f.onOpen(),document.dispatchEvent(new CustomEvent(uV))):f.onClose(),o==null||o(Y)},caller:sk}),B=N.useMemo(()=>M?P.current?"delayed-open":"instant-open":"closed",[M]),V=N.useCallback(()=>{window.clearTimeout(E.current),E.current=0,P.current=!1,D(!0)},[D]),G=N.useCallback(()=>{window.clearTimeout(E.current),E.current=0,D(!1)},[D]),W=N.useCallback(()=>{window.clearTimeout(E.current),E.current=window.setTimeout(()=>{P.current=!0,D(!0),E.current=0},R)},[R,D]);return N.useEffect(()=>()=>{E.current&&(window.clearTimeout(E.current),E.current=0)},[]),i.jsx(v3,{...p,children:i.jsx(E4e,{scope:e,contentId:S,open:M,stateAttribute:B,trigger:y,onTriggerChange:v,onTriggerEnter:N.useCallback(()=>{f.isOpenDelayedRef.current?W():V()},[f.isOpenDelayedRef,W,V]),onTriggerLeave:N.useCallback(()=>{k?G():(window.clearTimeout(E.current),E.current=0)},[G,k]),onOpen:V,onClose:G,disableHoverableContent:k,children:r})})};hge.displayName=sk;var dV="TooltipTrigger",fge=N.forwardRef((t,e)=>{const{__scopeTooltip:r,...n}=t,s=T3(dV,r),o=g7(dV,r),c=S3(r),a=N.useRef(null),f=Zn(e,a,s.onTriggerChange),p=N.useRef(!1),y=N.useRef(!1),v=N.useCallback(()=>p.current=!1,[]);return N.useEffect(()=>()=>document.removeEventListener("pointerup",v),[v]),i.jsx(FN,{asChild:!0,...c,children:i.jsx(nn.button,{"aria-describedby":s.open?s.contentId:void 0,"data-state":s.stateAttribute,...n,ref:f,onPointerMove:Fr(t.onPointerMove,S=>{S.pointerType!=="touch"&&!y.current&&!o.isPointerInTransitRef.current&&(s.onTriggerEnter(),y.current=!0)}),onPointerLeave:Fr(t.onPointerLeave,()=>{s.onTriggerLeave(),y.current=!1}),onPointerDown:Fr(t.onPointerDown,()=>{s.open&&s.onClose(),p.current=!0,document.addEventListener("pointerup",v,{once:!0})}),onFocus:Fr(t.onFocus,()=>{p.current||s.onOpen()}),onBlur:Fr(t.onBlur,s.onClose),onClick:Fr(t.onClick,s.onClose)})})});fge.displayName=dV;var j4e="TooltipPortal",[nGt,A4e]=w3(j4e,{forceMount:void 0}),fS="TooltipContent",mge=N.forwardRef((t,e)=>{const r=A4e(fS,t.__scopeTooltip),{forceMount:n=r.forceMount,side:s="top",...o}=t,c=T3(fS,t.__scopeTooltip);return i.jsx(vl,{present:n||c.open,children:c.disableHoverableContent?i.jsx(pge,{side:s,...o,ref:e}):i.jsx(k4e,{side:s,...o,ref:e})})}),k4e=N.forwardRef((t,e)=>{const r=T3(fS,t.__scopeTooltip),n=g7(fS,t.__scopeTooltip),s=N.useRef(null),o=Zn(e,s),[c,a]=N.useState(null),{trigger:f,onClose:p}=r,y=s.current,{onPointerInTransitChange:v}=n,S=N.useCallback(()=>{a(null),v(!1)},[v]),E=N.useCallback((k,R)=>{const P=k.currentTarget,M={x:k.clientX,y:k.clientY},D=R4e(M,P.getBoundingClientRect()),B=L4e(M,D),V=M4e(R.getBoundingClientRect()),G=O4e([...B,...V]);a(G),v(!0)},[v]);return N.useEffect(()=>()=>S(),[S]),N.useEffect(()=>{if(f&&y){const k=P=>E(P,y),R=P=>E(P,f);return f.addEventListener("pointerleave",k),y.addEventListener("pointerleave",R),()=>{f.removeEventListener("pointerleave",k),y.removeEventListener("pointerleave",R)}}},[f,y,E,S]),N.useEffect(()=>{if(c){const k=R=>{const P=R.target,M={x:R.clientX,y:R.clientY},D=(f==null?void 0:f.contains(P))||(y==null?void 0:y.contains(P)),B=!D4e(M,c);D?S():B&&(S(),p())};return document.addEventListener("pointermove",k),()=>document.removeEventListener("pointermove",k)}},[f,y,c,p,S]),i.jsx(pge,{...t,ref:o})}),[N4e,C4e]=w3(sk,{isInside:!1}),I4e=nme("TooltipContent"),pge=N.forwardRef((t,e)=>{const{__scopeTooltip:r,children:n,"aria-label":s,onEscapeKeyDown:o,onPointerDownOutside:c,...a}=t,f=T3(fS,r),p=S3(r),{onClose:y}=f;return N.useEffect(()=>(document.addEventListener(uV,y),()=>document.removeEventListener(uV,y)),[y]),N.useEffect(()=>{if(f.trigger){const v=S=>{const E=S.target;E!=null&&E.contains(f.trigger)&&y()};return window.addEventListener("scroll",v,{capture:!0}),()=>window.removeEventListener("scroll",v,{capture:!0})}},[f.trigger,y]),i.jsx(A_,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:o,onPointerDownOutside:c,onFocusOutside:v=>v.preventDefault(),onDismiss:y,children:i.jsxs(_3,{"data-state":f.stateAttribute,...p,...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(I4e,{children:n}),i.jsx(N4e,{scope:r,isInside:!0,children:i.jsx(SMe,{id:f.contentId,role:"tooltip",children:s||n})})]})})});mge.displayName=fS;var gge="TooltipArrow",P4e=N.forwardRef((t,e)=>{const{__scopeTooltip:r,...n}=t,s=S3(r);return C4e(gge,r).isInside?null:i.jsx(b3,{...s,...n,ref:e})});P4e.displayName=gge;function R4e(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 L4e(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 M4e(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 D4e(t,e){const{x:r,y:n}=t;let s=!1;for(let o=0,c=e.length-1;on!=S>n&&r<(v-p)*(n-y)/(S-y)+p&&(s=!s)}return s}function O4e(t){const e=t.slice();return e.sort((r,n)=>r.xn.x?1:r.yn.y?1:0),F4e(e)}function F4e(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 B4e=dge,$4e=hge,z4e=fge,yge=mge;const xge=B4e,U4e=$4e,V4e=z4e,vge=N.forwardRef(({className:t,sideOffset:e=4,...r},n)=>i.jsx(yge,{ref:n,sideOffset:e,className:qt("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}));vge.displayName=yge.displayName;var mT=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(){}},h_=typeof window>"u"||"Deno"in globalThis;function Yc(){}function q4e(t,e){return typeof t=="function"?t(e):t}function hV(t){return typeof t=="number"&&t>=0&&t!==1/0}function _ge(t,e){return Math.max(t+(e||0)-Date.now(),0)}function ox(t,e){return typeof t=="function"?t(e):t}function Jd(t,e){return typeof t=="function"?t(e):t}function Ite(t,e){const{type:r="all",exact:n,fetchStatus:s,predicate:o,queryKey:c,stale:a}=t;if(c){if(n){if(e.queryHash!==y7(c,e.options))return!1}else if(!ik(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 Pte(t,e){const{exact:r,status:n,predicate:s,mutationKey:o}=t;if(o){if(!e.options.mutationKey)return!1;if(r){if(f_(e.options.mutationKey)!==f_(o))return!1}else if(!ik(e.options.mutationKey,o))return!1}return!(n&&e.state.status!==n||s&&!s(e))}function y7(t,e){return((e==null?void 0:e.queryKeyHashFn)||f_)(t)}function f_(t){return JSON.stringify(t,(e,r)=>fV(r)?Object.keys(r).sort().reduce((n,s)=>(n[s]=r[s],n),{}):r)}function ik(t,e){return t===e?!0:typeof t!=typeof e?!1:t&&e&&typeof t=="object"&&typeof e=="object"?Object.keys(e).every(r=>ik(t[r],e[r])):!1}function bge(t,e){if(t===e)return t;const r=Rte(t)&&Rte(e);if(r||fV(t)&&fV(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 p=0;for(let y=0;y{setTimeout(e,t)})}function mV(t,e,r){return typeof r.structuralSharing=="function"?r.structuralSharing(t,e):r.structuralSharing!==!1?bge(t,e):e}function H4e(t,e,r=0){const n=[...t,e];return r&&n.length>r?n.slice(1):n}function W4e(t,e,r=0){const n=[e,...t];return r&&n.length>r?n.slice(0,-1):n}var x7=Symbol();function wge(t,e){return!t.queryFn&&(e!=null&&e.initialPromise)?()=>e.initialPromise:!t.queryFn||t.queryFn===x7?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function Sge(t,e){return typeof t=="function"?t(...e):!!t}var $v,Fy,q1,kde,K4e=(kde=class extends mT{constructor(){super();Jn(this,$v);Jn(this,Fy);Jn(this,q1);vn(this,q1,e=>{if(!h_&&window.addEventListener){const r=()=>e();return window.addEventListener("visibilitychange",r,!1),()=>{window.removeEventListener("visibilitychange",r)}}})}onSubscribe(){Et(this,Fy)||this.setEventListener(Et(this,q1))}onUnsubscribe(){var e;this.hasListeners()||((e=Et(this,Fy))==null||e.call(this),vn(this,Fy,void 0))}setEventListener(e){var r;vn(this,q1,e),(r=Et(this,Fy))==null||r.call(this),vn(this,Fy,e(n=>{typeof n=="boolean"?this.setFocused(n):this.onFocus()}))}setFocused(e){Et(this,$v)!==e&&(vn(this,$v,e),this.onFocus())}onFocus(){const e=this.isFocused();this.listeners.forEach(r=>{r(e)})}isFocused(){var e;return typeof Et(this,$v)=="boolean"?Et(this,$v):((e=globalThis.document)==null?void 0:e.visibilityState)!=="hidden"}},$v=new WeakMap,Fy=new WeakMap,q1=new WeakMap,kde),v7=new K4e,G1,By,H1,Nde,Y4e=(Nde=class extends mT{constructor(){super();Jn(this,G1,!0);Jn(this,By);Jn(this,H1);vn(this,H1,e=>{if(!h_&&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(){Et(this,By)||this.setEventListener(Et(this,H1))}onUnsubscribe(){var e;this.hasListeners()||((e=Et(this,By))==null||e.call(this),vn(this,By,void 0))}setEventListener(e){var r;vn(this,H1,e),(r=Et(this,By))==null||r.call(this),vn(this,By,e(this.setOnline.bind(this)))}setOnline(e){Et(this,G1)!==e&&(vn(this,G1,e),this.listeners.forEach(n=>{n(e)}))}isOnline(){return Et(this,G1)}},G1=new WeakMap,By=new WeakMap,H1=new WeakMap,Nde),GM=new Y4e;function pV(){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 Z4e(t){return Math.min(1e3*2**t,3e4)}function Tge(t){return(t??"online")==="online"?GM.isOnline():!0}var Ege=class extends Error{constructor(t){super("CancelledError"),this.revert=t==null?void 0:t.revert,this.silent=t==null?void 0:t.silent}};function M$(t){return t instanceof Ege}function jge(t){let e=!1,r=0,n=!1,s;const o=pV(),c=R=>{var P;n||(S(new Ege(R)),(P=t.abort)==null||P.call(t))},a=()=>{e=!0},f=()=>{e=!1},p=()=>v7.isFocused()&&(t.networkMode==="always"||GM.isOnline())&&t.canRun(),y=()=>Tge(t.networkMode)&&t.canRun(),v=R=>{var P;n||(n=!0,(P=t.onSuccess)==null||P.call(t,R),s==null||s(),o.resolve(R))},S=R=>{var P;n||(n=!0,(P=t.onError)==null||P.call(t,R),s==null||s(),o.reject(R))},E=()=>new Promise(R=>{var P;s=M=>{(n||p())&&R(M)},(P=t.onPause)==null||P.call(t)}).then(()=>{var R;s=void 0,n||(R=t.onContinue)==null||R.call(t)}),k=()=>{if(n)return;let R;const P=r===0?t.initialPromise:void 0;try{R=P??t.fn()}catch(M){R=Promise.reject(M)}Promise.resolve(R).then(v).catch(M=>{var W;if(n)return;const D=t.retry??(h_?0:3),B=t.retryDelay??Z4e,V=typeof B=="function"?B(r,M):B,G=D===!0||typeof D=="number"&&rp()?void 0:E()).then(()=>{e?S(M):k()})})};return{promise:o,cancel:c,continue:()=>(s==null||s(),o),cancelRetry:a,continueRetry:f,canStart:y,start:()=>(y()?k():E().then(k),o)}}var X4e=t=>setTimeout(t,0);function Q4e(){let t=[],e=0,r=a=>{a()},n=a=>{a()},s=X4e;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 fl=Q4e(),zv,Cde,Age=(Cde=class{constructor(){Jn(this,zv)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),hV(this.gcTime)&&vn(this,zv,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(h_?1/0:5*60*1e3))}clearGcTimeout(){Et(this,zv)&&(clearTimeout(Et(this,zv)),vn(this,zv,void 0))}},zv=new WeakMap,Cde),W1,Uv,Qd,Vv,_c,gN,qv,Xh,Cp,Ide,J4e=(Ide=class extends Age{constructor(e){super();Jn(this,Xh);Jn(this,W1);Jn(this,Uv);Jn(this,Qd);Jn(this,Vv);Jn(this,_c);Jn(this,gN);Jn(this,qv);vn(this,qv,!1),vn(this,gN,e.defaultOptions),this.setOptions(e.options),this.observers=[],vn(this,Vv,e.client),vn(this,Qd,Et(this,Vv).getQueryCache()),this.queryKey=e.queryKey,this.queryHash=e.queryHash,vn(this,W1,e5e(this.options)),this.state=e.state??Et(this,W1),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var e;return(e=Et(this,_c))==null?void 0:e.promise}setOptions(e){this.options={...Et(this,gN),...e},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&Et(this,Qd).remove(this)}setData(e,r){const n=mV(this.state.data,e,this.options);return qs(this,Xh,Cp).call(this,{data:n,type:"success",dataUpdatedAt:r==null?void 0:r.updatedAt,manual:r==null?void 0:r.manual}),n}setState(e,r){qs(this,Xh,Cp).call(this,{type:"setState",state:e,setStateOptions:r})}cancel(e){var n,s;const r=(n=Et(this,_c))==null?void 0:n.promise;return(s=Et(this,_c))==null||s.cancel(e),r?r.then(Yc).catch(Yc):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(Et(this,W1))}isActive(){return this.observers.some(e=>Jd(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===x7||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(e=>ox(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:!_ge(this.state.dataUpdatedAt,e)}onFocus(){var r;const e=this.observers.find(n=>n.shouldFetchOnWindowFocus());e==null||e.refetch({cancelRefetch:!1}),(r=Et(this,_c))==null||r.continue()}onOnline(){var r;const e=this.observers.find(n=>n.shouldFetchOnReconnect());e==null||e.refetch({cancelRefetch:!1}),(r=Et(this,_c))==null||r.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),Et(this,Qd).notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(r=>r!==e),this.observers.length||(Et(this,_c)&&(Et(this,qv)?Et(this,_c).cancel({revert:!0}):Et(this,_c).cancelRetry()),this.scheduleGc()),Et(this,Qd).notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||qs(this,Xh,Cp).call(this,{type:"invalidate"})}fetch(e,r){var p,y,v;if(this.state.fetchStatus!=="idle"){if(this.state.data!==void 0&&(r!=null&&r.cancelRefetch))this.cancel({silent:!0});else if(Et(this,_c))return Et(this,_c).continueRetry(),Et(this,_c).promise}if(e&&this.setOptions(e),!this.options.queryFn){const S=this.observers.find(E=>E.options.queryFn);S&&this.setOptions(S.options)}const n=new AbortController,s=S=>{Object.defineProperty(S,"signal",{enumerable:!0,get:()=>(vn(this,qv,!0),n.signal)})},o=()=>{const S=wge(this.options,r),k=(()=>{const R={client:Et(this,Vv),queryKey:this.queryKey,meta:this.meta};return s(R),R})();return vn(this,qv,!1),this.options.persister?this.options.persister(S,k,this):S(k)},a=(()=>{const S={fetchOptions:r,options:this.options,queryKey:this.queryKey,client:Et(this,Vv),state:this.state,fetchFn:o};return s(S),S})();(p=this.options.behavior)==null||p.onFetch(a,this),vn(this,Uv,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((y=a.fetchOptions)==null?void 0:y.meta))&&qs(this,Xh,Cp).call(this,{type:"fetch",meta:(v=a.fetchOptions)==null?void 0:v.meta});const f=S=>{var E,k,R,P;M$(S)&&S.silent||qs(this,Xh,Cp).call(this,{type:"error",error:S}),M$(S)||((k=(E=Et(this,Qd).config).onError)==null||k.call(E,S,this),(P=(R=Et(this,Qd).config).onSettled)==null||P.call(R,this.state.data,S,this)),this.scheduleGc()};return vn(this,_c,jge({initialPromise:r==null?void 0:r.initialPromise,fn:a.fetchFn,abort:n.abort.bind(n),onSuccess:S=>{var E,k,R,P;if(S===void 0){f(new Error(`${this.queryHash} data is undefined`));return}try{this.setData(S)}catch(M){f(M);return}(k=(E=Et(this,Qd).config).onSuccess)==null||k.call(E,S,this),(P=(R=Et(this,Qd).config).onSettled)==null||P.call(R,S,this.state.error,this),this.scheduleGc()},onError:f,onFail:(S,E)=>{qs(this,Xh,Cp).call(this,{type:"failed",failureCount:S,error:E})},onPause:()=>{qs(this,Xh,Cp).call(this,{type:"pause"})},onContinue:()=>{qs(this,Xh,Cp).call(this,{type:"continue"})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0})),Et(this,_c).start()}},W1=new WeakMap,Uv=new WeakMap,Qd=new WeakMap,Vv=new WeakMap,_c=new WeakMap,gN=new WeakMap,qv=new WeakMap,Xh=new WeakSet,Cp=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,...kge(n.data,this.options),fetchMeta:e.meta??null};case"success":return vn(this,Uv,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 M$(s)&&s.revert&&Et(this,Uv)?{...Et(this,Uv),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),fl.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),Et(this,Qd).notify({query:this,type:"updated",action:e})})},Ide);function kge(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Tge(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function e5e(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 im,Pde,t5e=(Pde=class extends mT{constructor(e={}){super();Jn(this,im);this.config=e,vn(this,im,new Map)}build(e,r,n){const s=r.queryKey,o=r.queryHash??y7(s,r);let c=this.get(o);return c||(c=new J4e({client:e,queryKey:s,queryHash:o,options:e.defaultQueryOptions(r),state:n,defaultOptions:e.getQueryDefaults(s)}),this.add(c)),c}add(e){Et(this,im).has(e.queryHash)||(Et(this,im).set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){const r=Et(this,im).get(e.queryHash);r&&(e.destroy(),r===e&&Et(this,im).delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){fl.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return Et(this,im).get(e)}getAll(){return[...Et(this,im).values()]}find(e){const r={exact:!0,...e};return this.getAll().find(n=>Ite(r,n))}findAll(e={}){const r=this.getAll();return Object.keys(e).length>0?r.filter(n=>Ite(e,n)):r}notify(e){fl.batch(()=>{this.listeners.forEach(r=>{r(e)})})}onFocus(){fl.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){fl.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},im=new WeakMap,Pde),am,Hc,Gv,om,wy,Rde,r5e=(Rde=class extends Age{constructor(e){super();Jn(this,om);Jn(this,am);Jn(this,Hc);Jn(this,Gv);this.mutationId=e.mutationId,vn(this,Hc,e.mutationCache),vn(this,am,[]),this.state=e.state||Nge(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){Et(this,am).includes(e)||(Et(this,am).push(e),this.clearGcTimeout(),Et(this,Hc).notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){vn(this,am,Et(this,am).filter(r=>r!==e)),this.scheduleGc(),Et(this,Hc).notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){Et(this,am).length||(this.state.status==="pending"?this.scheduleGc():Et(this,Hc).remove(this))}continue(){var e;return((e=Et(this,Gv))==null?void 0:e.continue())??this.execute(this.state.variables)}async execute(e){var o,c,a,f,p,y,v,S,E,k,R,P,M,D,B,V,G,W,Y,J;const r=()=>{qs(this,om,wy).call(this,{type:"continue"})};vn(this,Gv,jge({fn:()=>this.options.mutationFn?this.options.mutationFn(e):Promise.reject(new Error("No mutationFn found")),onFail:(Q,ee)=>{qs(this,om,wy).call(this,{type:"failed",failureCount:Q,error:ee})},onPause:()=>{qs(this,om,wy).call(this,{type:"pause"})},onContinue:r,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>Et(this,Hc).canRun(this)}));const n=this.state.status==="pending",s=!Et(this,Gv).canStart();try{if(n)r();else{qs(this,om,wy).call(this,{type:"pending",variables:e,isPaused:s}),await((c=(o=Et(this,Hc).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&&qs(this,om,wy).call(this,{type:"pending",context:ee,variables:e,isPaused:s})}const Q=await Et(this,Gv).start();return await((y=(p=Et(this,Hc).config).onSuccess)==null?void 0:y.call(p,Q,e,this.state.context,this)),await((S=(v=this.options).onSuccess)==null?void 0:S.call(v,Q,e,this.state.context)),await((k=(E=Et(this,Hc).config).onSettled)==null?void 0:k.call(E,Q,null,this.state.variables,this.state.context,this)),await((P=(R=this.options).onSettled)==null?void 0:P.call(R,Q,null,e,this.state.context)),qs(this,om,wy).call(this,{type:"success",data:Q}),Q}catch(Q){try{throw await((D=(M=Et(this,Hc).config).onError)==null?void 0:D.call(M,Q,e,this.state.context,this)),await((V=(B=this.options).onError)==null?void 0:V.call(B,Q,e,this.state.context)),await((W=(G=Et(this,Hc).config).onSettled)==null?void 0:W.call(G,void 0,Q,this.state.variables,this.state.context,this)),await((J=(Y=this.options).onSettled)==null?void 0:J.call(Y,void 0,Q,e,this.state.context)),Q}finally{qs(this,om,wy).call(this,{type:"error",error:Q})}}finally{Et(this,Hc).runNext(this)}}},am=new WeakMap,Hc=new WeakMap,Gv=new WeakMap,om=new WeakSet,wy=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),fl.batch(()=>{Et(this,am).forEach(n=>{n.onMutationUpdate(e)}),Et(this,Hc).notify({mutation:this,type:"updated",action:e})})},Rde);function Nge(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Bp,Qh,yN,Lde,n5e=(Lde=class extends mT{constructor(e={}){super();Jn(this,Bp);Jn(this,Qh);Jn(this,yN);this.config=e,vn(this,Bp,new Set),vn(this,Qh,new Map),vn(this,yN,0)}build(e,r,n){const s=new r5e({mutationCache:this,mutationId:++$P(this,yN)._,options:e.defaultMutationOptions(r),state:n});return this.add(s),s}add(e){Et(this,Bp).add(e);const r=hR(e);if(typeof r=="string"){const n=Et(this,Qh).get(r);n?n.push(e):Et(this,Qh).set(r,[e])}this.notify({type:"added",mutation:e})}remove(e){if(Et(this,Bp).delete(e)){const r=hR(e);if(typeof r=="string"){const n=Et(this,Qh).get(r);if(n)if(n.length>1){const s=n.indexOf(e);s!==-1&&n.splice(s,1)}else n[0]===e&&Et(this,Qh).delete(r)}}this.notify({type:"removed",mutation:e})}canRun(e){const r=hR(e);if(typeof r=="string"){const n=Et(this,Qh).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=hR(e);if(typeof r=="string"){const s=(n=Et(this,Qh).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(){fl.batch(()=>{Et(this,Bp).forEach(e=>{this.notify({type:"removed",mutation:e})}),Et(this,Bp).clear(),Et(this,Qh).clear()})}getAll(){return Array.from(Et(this,Bp))}find(e){const r={exact:!0,...e};return this.getAll().find(n=>Pte(r,n))}findAll(e={}){return this.getAll().filter(r=>Pte(e,r))}notify(e){fl.batch(()=>{this.listeners.forEach(r=>{r(e)})})}resumePausedMutations(){const e=this.getAll().filter(r=>r.state.isPaused);return fl.batch(()=>Promise.all(e.map(r=>r.continue().catch(Yc))))}},Bp=new WeakMap,Qh=new WeakMap,yN=new WeakMap,Lde);function hR(t){var e;return(e=t.options.scope)==null?void 0:e.id}function Mte(t){return{onFetch:(e,r)=>{var y,v,S,E,k;const n=e.options,s=(S=(v=(y=e.fetchOptions)==null?void 0:y.meta)==null?void 0:v.fetchMore)==null?void 0:S.direction,o=((E=e.state.data)==null?void 0:E.pages)||[],c=((k=e.state.data)==null?void 0:k.pageParams)||[];let a={pages:[],pageParams:[]},f=0;const p=async()=>{let R=!1;const P=B=>{Object.defineProperty(B,"signal",{enumerable:!0,get:()=>(e.signal.aborted?R=!0:e.signal.addEventListener("abort",()=>{R=!0}),e.signal)})},M=wge(e.options,e.fetchOptions),D=async(B,V,G)=>{if(R)return Promise.reject();if(V==null&&B.pages.length)return Promise.resolve(B);const Y=(()=>{const le={client:e.client,queryKey:e.queryKey,pageParam:V,direction:G?"backward":"forward",meta:e.options.meta};return P(le),le})(),J=await M(Y),{maxPages:Q}=e.options,ee=G?W4e:H4e;return{pages:ee(B.pages,J,Q),pageParams:ee(B.pageParams,V,Q)}};if(s&&o.length){const B=s==="backward",V=B?Cge:gV,G={pages:o,pageParams:c},W=V(n,G);a=await D(G,W,B)}else{const B=t??o.length;do{const V=f===0?c[0]??n.initialPageParam:gV(n,a);if(f>0&&V==null)break;a=await D(a,V),f++}while(f{var R,P;return(P=(R=e.options).persister)==null?void 0:P.call(R,p,{client:e.client,queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},r)}:e.fetchFn=p}}}function gV(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 Cge(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 sGt(t,e){return e?gV(t,e)!=null:!1}function iGt(t,e){return!e||!t.getPreviousPageParam?!1:Cge(t,e)!=null}var yo,$y,zy,K1,Y1,Uy,Z1,X1,Mde,s5e=(Mde=class{constructor(t={}){Jn(this,yo);Jn(this,$y);Jn(this,zy);Jn(this,K1);Jn(this,Y1);Jn(this,Uy);Jn(this,Z1);Jn(this,X1);vn(this,yo,t.queryCache||new t5e),vn(this,$y,t.mutationCache||new n5e),vn(this,zy,t.defaultOptions||{}),vn(this,K1,new Map),vn(this,Y1,new Map),vn(this,Uy,0)}mount(){$P(this,Uy)._++,Et(this,Uy)===1&&(vn(this,Z1,v7.subscribe(async t=>{t&&(await this.resumePausedMutations(),Et(this,yo).onFocus())})),vn(this,X1,GM.subscribe(async t=>{t&&(await this.resumePausedMutations(),Et(this,yo).onOnline())})))}unmount(){var t,e;$P(this,Uy)._--,Et(this,Uy)===0&&((t=Et(this,Z1))==null||t.call(this),vn(this,Z1,void 0),(e=Et(this,X1))==null||e.call(this),vn(this,X1,void 0))}isFetching(t){return Et(this,yo).findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return Et(this,$y).findAll({...t,status:"pending"}).length}getQueryData(t){var r;const e=this.defaultQueryOptions({queryKey:t});return(r=Et(this,yo).get(e.queryHash))==null?void 0:r.state.data}ensureQueryData(t){const e=this.defaultQueryOptions(t),r=Et(this,yo).build(this,e),n=r.state.data;return n===void 0?this.fetchQuery(t):(t.revalidateIfStale&&r.isStaleByTime(ox(e.staleTime,r))&&this.prefetchQuery(e),Promise.resolve(n))}getQueriesData(t){return Et(this,yo).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=Et(this,yo).get(n.queryHash),o=s==null?void 0:s.state.data,c=q4e(e,o);if(c!==void 0)return Et(this,yo).build(this,n).setData(c,{...r,manual:!0})}setQueriesData(t,e,r){return fl.batch(()=>Et(this,yo).findAll(t).map(({queryKey:n})=>[n,this.setQueryData(n,e,r)]))}getQueryState(t){var r;const e=this.defaultQueryOptions({queryKey:t});return(r=Et(this,yo).get(e.queryHash))==null?void 0:r.state}removeQueries(t){const e=Et(this,yo);fl.batch(()=>{e.findAll(t).forEach(r=>{e.remove(r)})})}resetQueries(t,e){const r=Et(this,yo);return fl.batch(()=>(r.findAll(t).forEach(n=>{n.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){const r={revert:!0,...e},n=fl.batch(()=>Et(this,yo).findAll(t).map(s=>s.cancel(r)));return Promise.all(n).then(Yc).catch(Yc)}invalidateQueries(t,e={}){return fl.batch(()=>(Et(this,yo).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=fl.batch(()=>Et(this,yo).findAll(t).filter(s=>!s.isDisabled()&&!s.isStatic()).map(s=>{let o=s.fetch(void 0,r);return r.throwOnError||(o=o.catch(Yc)),s.state.fetchStatus==="paused"?Promise.resolve():o}));return Promise.all(n).then(Yc)}fetchQuery(t){const e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);const r=Et(this,yo).build(this,e);return r.isStaleByTime(ox(e.staleTime,r))?r.fetch(e):Promise.resolve(r.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(Yc).catch(Yc)}fetchInfiniteQuery(t){return t.behavior=Mte(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(Yc).catch(Yc)}ensureInfiniteQueryData(t){return t.behavior=Mte(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return GM.isOnline()?Et(this,$y).resumePausedMutations():Promise.resolve()}getQueryCache(){return Et(this,yo)}getMutationCache(){return Et(this,$y)}getDefaultOptions(){return Et(this,zy)}setDefaultOptions(t){vn(this,zy,t)}setQueryDefaults(t,e){Et(this,K1).set(f_(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){const e=[...Et(this,K1).values()],r={};return e.forEach(n=>{ik(t,n.queryKey)&&Object.assign(r,n.defaultOptions)}),r}setMutationDefaults(t,e){Et(this,Y1).set(f_(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){const e=[...Et(this,Y1).values()],r={};return e.forEach(n=>{ik(t,n.mutationKey)&&Object.assign(r,n.defaultOptions)}),r}defaultQueryOptions(t){if(t._defaulted)return t;const e={...Et(this,zy).queries,...this.getQueryDefaults(t.queryKey),...t,_defaulted:!0};return e.queryHash||(e.queryHash=y7(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===x7&&(e.enabled=!1),e}defaultMutationOptions(t){return t!=null&&t._defaulted?t:{...Et(this,zy).mutations,...(t==null?void 0:t.mutationKey)&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){Et(this,yo).clear(),Et(this,$y).clear()}},yo=new WeakMap,$y=new WeakMap,zy=new WeakMap,K1=new WeakMap,Y1=new WeakMap,Uy=new WeakMap,Z1=new WeakMap,X1=new WeakMap,Mde),Tu,si,xN,Wc,Hv,Q1,Vy,qy,vN,J1,eS,Wv,Kv,Gy,tS,Oi,H2,yV,xV,vV,_V,bV,wV,SV,Ige,Dde,i5e=(Dde=class extends mT{constructor(e,r){super();Jn(this,Oi);Jn(this,Tu);Jn(this,si);Jn(this,xN);Jn(this,Wc);Jn(this,Hv);Jn(this,Q1);Jn(this,Vy);Jn(this,qy);Jn(this,vN);Jn(this,J1);Jn(this,eS);Jn(this,Wv);Jn(this,Kv);Jn(this,Gy);Jn(this,tS,new Set);this.options=r,vn(this,Tu,e),vn(this,qy,null),vn(this,Vy,pV()),this.options.experimental_prefetchInRender||Et(this,Vy).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&&(Et(this,si).addObserver(this),Dte(Et(this,si),this.options)?qs(this,Oi,H2).call(this):this.updateResult(),qs(this,Oi,_V).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return TV(Et(this,si),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return TV(Et(this,si),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,qs(this,Oi,bV).call(this),qs(this,Oi,wV).call(this),Et(this,si).removeObserver(this)}setOptions(e){const r=this.options,n=Et(this,si);if(this.options=Et(this,Tu).defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Jd(this.options.enabled,Et(this,si))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");qs(this,Oi,SV).call(this),Et(this,si).setOptions(this.options),r._defaulted&&!qM(this.options,r)&&Et(this,Tu).getQueryCache().notify({type:"observerOptionsUpdated",query:Et(this,si),observer:this});const s=this.hasListeners();s&&Ote(Et(this,si),n,this.options,r)&&qs(this,Oi,H2).call(this),this.updateResult(),s&&(Et(this,si)!==n||Jd(this.options.enabled,Et(this,si))!==Jd(r.enabled,Et(this,si))||ox(this.options.staleTime,Et(this,si))!==ox(r.staleTime,Et(this,si)))&&qs(this,Oi,yV).call(this);const o=qs(this,Oi,xV).call(this);s&&(Et(this,si)!==n||Jd(this.options.enabled,Et(this,si))!==Jd(r.enabled,Et(this,si))||o!==Et(this,Gy))&&qs(this,Oi,vV).call(this,o)}getOptimisticResult(e){const r=Et(this,Tu).getQueryCache().build(Et(this,Tu),e),n=this.createResult(r,e);return o5e(this,n)&&(vn(this,Wc,n),vn(this,Q1,this.options),vn(this,Hv,Et(this,si).state)),n}getCurrentResult(){return Et(this,Wc)}trackResult(e,r){return new Proxy(e,{get:(n,s)=>(this.trackProp(s),r==null||r(s),Reflect.get(n,s))})}trackProp(e){Et(this,tS).add(e)}getCurrentQuery(){return Et(this,si)}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){const r=Et(this,Tu).defaultQueryOptions(e),n=Et(this,Tu).getQueryCache().build(Et(this,Tu),r);return n.fetch().then(()=>this.createResult(n,r))}fetch(e){return qs(this,Oi,H2).call(this,{...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),Et(this,Wc)))}createResult(e,r){var Q;const n=Et(this,si),s=this.options,o=Et(this,Wc),c=Et(this,Hv),a=Et(this,Q1),p=e!==n?e.state:Et(this,xN),{state:y}=e;let v={...y},S=!1,E;if(r._optimisticResults){const ee=this.hasListeners(),le=!ee&&Dte(e,r),pe=ee&&Ote(e,n,r,s);(le||pe)&&(v={...v,...kge(y.data,e.options)}),r._optimisticResults==="isRestoring"&&(v.fetchStatus="idle")}let{error:k,errorUpdatedAt:R,status:P}=v;E=v.data;let M=!1;if(r.placeholderData!==void 0&&E===void 0&&P==="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((Q=Et(this,eS))==null?void 0:Q.state.data,Et(this,eS)):r.placeholderData,ee!==void 0&&(P="success",E=mV(o==null?void 0:o.data,ee,r),S=!0)}if(r.select&&E!==void 0&&!M)if(o&&E===(c==null?void 0:c.data)&&r.select===Et(this,vN))E=Et(this,J1);else try{vn(this,vN,r.select),E=r.select(E),E=mV(o==null?void 0:o.data,E,r),vn(this,J1,E),vn(this,qy,null)}catch(ee){vn(this,qy,ee)}Et(this,qy)&&(k=Et(this,qy),E=Et(this,J1),R=Date.now(),P="error");const D=v.fetchStatus==="fetching",B=P==="pending",V=P==="error",G=B&&D,W=E!==void 0,J={status:P,fetchStatus:v.fetchStatus,isPending:B,isSuccess:P==="success",isError:V,isInitialLoading:G,isLoading:G,data:E,dataUpdatedAt:v.dataUpdatedAt,error:k,errorUpdatedAt:R,failureCount:v.fetchFailureCount,failureReason:v.fetchFailureReason,errorUpdateCount:v.errorUpdateCount,isFetched:v.dataUpdateCount>0||v.errorUpdateCount>0,isFetchedAfterMount:v.dataUpdateCount>p.dataUpdateCount||v.errorUpdateCount>p.errorUpdateCount,isFetching:D,isRefetching:D&&!B,isLoadingError:V&&!W,isPaused:v.fetchStatus==="paused",isPlaceholderData:S,isRefetchError:V&&W,isStale:_7(e,r),refetch:this.refetch,promise:Et(this,Vy),isEnabled:Jd(r.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){const ee=Te=>{J.status==="error"?Te.reject(J.error):J.data!==void 0&&Te.resolve(J.data)},le=()=>{const Te=vn(this,Vy,J.promise=pV());ee(Te)},pe=Et(this,Vy);switch(pe.status){case"pending":e.queryHash===n.queryHash&&ee(pe);break;case"fulfilled":(J.status==="error"||J.data!==pe.value)&&le();break;case"rejected":(J.status!=="error"||J.error!==pe.reason)&&le();break}}return J}updateResult(){const e=Et(this,Wc),r=this.createResult(Et(this,si),this.options);if(vn(this,Hv,Et(this,si).state),vn(this,Q1,this.options),Et(this,Hv).data!==void 0&&vn(this,eS,Et(this,si)),qM(r,e))return;vn(this,Wc,r);const n=()=>{if(!e)return!0;const{notifyOnChangeProps:s}=this.options,o=typeof s=="function"?s():s;if(o==="all"||!o&&!Et(this,tS).size)return!0;const c=new Set(o??Et(this,tS));return this.options.throwOnError&&c.add("error"),Object.keys(Et(this,Wc)).some(a=>{const f=a;return Et(this,Wc)[f]!==e[f]&&c.has(f)})};qs(this,Oi,Ige).call(this,{listeners:n()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&qs(this,Oi,_V).call(this)}},Tu=new WeakMap,si=new WeakMap,xN=new WeakMap,Wc=new WeakMap,Hv=new WeakMap,Q1=new WeakMap,Vy=new WeakMap,qy=new WeakMap,vN=new WeakMap,J1=new WeakMap,eS=new WeakMap,Wv=new WeakMap,Kv=new WeakMap,Gy=new WeakMap,tS=new WeakMap,Oi=new WeakSet,H2=function(e){qs(this,Oi,SV).call(this);let r=Et(this,si).fetch(this.options,e);return e!=null&&e.throwOnError||(r=r.catch(Yc)),r},yV=function(){qs(this,Oi,bV).call(this);const e=ox(this.options.staleTime,Et(this,si));if(h_||Et(this,Wc).isStale||!hV(e))return;const n=_ge(Et(this,Wc).dataUpdatedAt,e)+1;vn(this,Wv,setTimeout(()=>{Et(this,Wc).isStale||this.updateResult()},n))},xV=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(Et(this,si)):this.options.refetchInterval)??!1},vV=function(e){qs(this,Oi,wV).call(this),vn(this,Gy,e),!(h_||Jd(this.options.enabled,Et(this,si))===!1||!hV(Et(this,Gy))||Et(this,Gy)===0)&&vn(this,Kv,setInterval(()=>{(this.options.refetchIntervalInBackground||v7.isFocused())&&qs(this,Oi,H2).call(this)},Et(this,Gy)))},_V=function(){qs(this,Oi,yV).call(this),qs(this,Oi,vV).call(this,qs(this,Oi,xV).call(this))},bV=function(){Et(this,Wv)&&(clearTimeout(Et(this,Wv)),vn(this,Wv,void 0))},wV=function(){Et(this,Kv)&&(clearInterval(Et(this,Kv)),vn(this,Kv,void 0))},SV=function(){const e=Et(this,Tu).getQueryCache().build(Et(this,Tu),this.options);if(e===Et(this,si))return;const r=Et(this,si);vn(this,si,e),vn(this,xN,e.state),this.hasListeners()&&(r==null||r.removeObserver(this),e.addObserver(this))},Ige=function(e){fl.batch(()=>{e.listeners&&this.listeners.forEach(r=>{r(Et(this,Wc))}),Et(this,Tu).getQueryCache().notify({query:Et(this,si),type:"observerResultsUpdated"})})},Dde);function a5e(t,e){return Jd(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&e.retryOnMount===!1)}function Dte(t,e){return a5e(t,e)||t.state.data!==void 0&&TV(t,e,e.refetchOnMount)}function TV(t,e,r){if(Jd(e.enabled,t)!==!1&&ox(e.staleTime,t)!=="static"){const n=typeof r=="function"?r(t):r;return n==="always"||n!==!1&&_7(t,e)}return!1}function Ote(t,e,r,n){return(t!==e||Jd(n.enabled,t)===!1)&&(!r.suspense||t.state.status!=="error")&&_7(t,r)}function _7(t,e){return Jd(e.enabled,t)!==!1&&t.isStaleByTime(ox(e.staleTime,t))}function o5e(t,e){return!qM(t.getCurrentResult(),e)}var Hy,Wy,Eu,$p,tg,RL,EV,Ode,l5e=(Ode=class extends mT{constructor(r,n){super();Jn(this,tg);Jn(this,Hy);Jn(this,Wy);Jn(this,Eu);Jn(this,$p);vn(this,Hy,r),this.setOptions(n),this.bindMethods(),qs(this,tg,RL).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=Et(this,Hy).defaultMutationOptions(r),qM(this.options,n)||Et(this,Hy).getMutationCache().notify({type:"observerOptionsUpdated",mutation:Et(this,Eu),observer:this}),n!=null&&n.mutationKey&&this.options.mutationKey&&f_(n.mutationKey)!==f_(this.options.mutationKey)?this.reset():((s=Et(this,Eu))==null?void 0:s.state.status)==="pending"&&Et(this,Eu).setOptions(this.options)}onUnsubscribe(){var r;this.hasListeners()||(r=Et(this,Eu))==null||r.removeObserver(this)}onMutationUpdate(r){qs(this,tg,RL).call(this),qs(this,tg,EV).call(this,r)}getCurrentResult(){return Et(this,Wy)}reset(){var r;(r=Et(this,Eu))==null||r.removeObserver(this),vn(this,Eu,void 0),qs(this,tg,RL).call(this),qs(this,tg,EV).call(this)}mutate(r,n){var s;return vn(this,$p,n),(s=Et(this,Eu))==null||s.removeObserver(this),vn(this,Eu,Et(this,Hy).getMutationCache().build(Et(this,Hy),this.options)),Et(this,Eu).addObserver(this),Et(this,Eu).execute(r)}},Hy=new WeakMap,Wy=new WeakMap,Eu=new WeakMap,$p=new WeakMap,tg=new WeakSet,RL=function(){var n;const r=((n=Et(this,Eu))==null?void 0:n.state)??Nge();vn(this,Wy,{...r,isPending:r.status==="pending",isSuccess:r.status==="success",isError:r.status==="error",isIdle:r.status==="idle",mutate:this.mutate,reset:this.reset})},EV=function(r){fl.batch(()=>{var n,s,o,c,a,f,p,y;if(Et(this,$p)&&this.hasListeners()){const v=Et(this,Wy).variables,S=Et(this,Wy).context;(r==null?void 0:r.type)==="success"?((s=(n=Et(this,$p)).onSuccess)==null||s.call(n,r.data,v,S),(c=(o=Et(this,$p)).onSettled)==null||c.call(o,r.data,null,v,S)):(r==null?void 0:r.type)==="error"&&((f=(a=Et(this,$p)).onError)==null||f.call(a,r.error,v,S),(y=(p=Et(this,$p)).onSettled)==null||y.call(p,void 0,r.error,v,S))}this.listeners.forEach(v=>{v(Et(this,Wy))})})},Ode),Pge=N.createContext(void 0),Er=t=>{const e=N.useContext(Pge);if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},c5e=({client:t,children:e})=>(N.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),i.jsx(Pge.Provider,{value:t,children:e})),Rge=N.createContext(!1),u5e=()=>N.useContext(Rge);Rge.Provider;function d5e(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var h5e=N.createContext(d5e()),f5e=()=>N.useContext(h5e),m5e=(t,e)=>{(t.suspense||t.throwOnError||t.experimental_prefetchInRender)&&(e.isReset()||(t.retryOnMount=!1))},p5e=t=>{N.useEffect(()=>{t.clearReset()},[t])},g5e=({result:t,errorResetBoundary:e,throwOnError:r,query:n,suspense:s})=>t.isError&&!e.isReset()&&!t.isFetching&&n&&(s&&t.data===void 0||Sge(r,[t.error,n])),y5e=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))}},x5e=(t,e)=>t.isLoading&&t.isFetching&&!e,v5e=(t,e)=>(t==null?void 0:t.suspense)&&e.isPending,Fte=(t,e,r)=>e.fetchOptimistic(t).catch(()=>{r.clearReset()});function _5e(t,e,r){var v,S,E,k,R;const n=u5e(),s=f5e(),o=Er(),c=o.defaultQueryOptions(t);(S=(v=o.getDefaultOptions().queries)==null?void 0:v._experimental_beforeQuery)==null||S.call(v,c),c._optimisticResults=n?"isRestoring":"optimistic",y5e(c),m5e(c,s),p5e(s);const a=!o.getQueryCache().get(c.queryHash),[f]=N.useState(()=>new e(o,c)),p=f.getOptimisticResult(c),y=!n&&t.subscribed!==!1;if(N.useSyncExternalStore(N.useCallback(P=>{const M=y?f.subscribe(fl.batchCalls(P)):Yc;return f.updateResult(),M},[f,y]),()=>f.getCurrentResult(),()=>f.getCurrentResult()),N.useEffect(()=>{f.setOptions(c)},[c,f]),v5e(c,p))throw Fte(c,f,s);if(g5e({result:p,errorResetBoundary:s,throwOnError:c.throwOnError,query:o.getQueryCache().get(c.queryHash),suspense:c.suspense}))throw p.error;if((k=(E=o.getDefaultOptions().queries)==null?void 0:E._experimental_afterQuery)==null||k.call(E,c,p),c.experimental_prefetchInRender&&!h_&&x5e(p,n)){const P=a?Fte(c,f,s):(R=o.getQueryCache().get(c.queryHash))==null?void 0:R.promise;P==null||P.catch(Yc).finally(()=>{f.updateResult()})}return c.notifyOnChangeProps?p:f.trackResult(p)}function fr(t,e){return _5e(t,i5e)}function wr(t,e){const r=Er(),[n]=N.useState(()=>new l5e(r,t));N.useEffect(()=>{n.setOptions(t)},[n,t]);const s=N.useSyncExternalStore(N.useCallback(c=>n.subscribe(fl.batchCalls(c)),[n]),()=>n.getCurrentResult(),()=>n.getCurrentResult()),o=N.useCallback((c,a)=>{n.mutate(c,a).catch(Yc)},[n]);if(s.error&&Sge(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 ak(){return ak=Object.assign?Object.assign.bind():function(t){for(var e=1;e"u")throw new Error(e)}function Lge(t,e){if(!t){typeof console<"u"&&console.warn(e);try{throw new Error(e)}catch{}}}function w5e(){return Math.random().toString(36).substr(2,8)}function $te(t,e){return{usr:t.state,key:t.key,idx:e}}function jV(t,e,r,n){return r===void 0&&(r=null),ak({pathname:typeof t=="string"?t:t.pathname,search:"",hash:""},typeof e=="string"?pT(e):e,{state:r,key:e&&e.key||n||w5e()})}function HM(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 pT(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 S5e(t,e,r,n){n===void 0&&(n={});let{window:s=document.defaultView,v5Compat:o=!1}=n,c=s.history,a=Zy.Pop,f=null,p=y();p==null&&(p=0,c.replaceState(ak({},c.state,{idx:p}),""));function y(){return(c.state||{idx:null}).idx}function v(){a=Zy.Pop;let P=y(),M=P==null?null:P-p;p=P,f&&f({action:a,location:R.location,delta:M})}function S(P,M){a=Zy.Push;let D=jV(R.location,P,M);p=y()+1;let B=$te(D,p),V=R.createHref(D);try{c.pushState(B,"",V)}catch(G){if(G instanceof DOMException&&G.name==="DataCloneError")throw G;s.location.assign(V)}o&&f&&f({action:a,location:R.location,delta:1})}function E(P,M){a=Zy.Replace;let D=jV(R.location,P,M);p=y();let B=$te(D,p),V=R.createHref(D);c.replaceState(B,"",V),o&&f&&f({action:a,location:R.location,delta:0})}function k(P){let M=s.location.origin!=="null"?s.location.origin:s.location.href,D=typeof P=="string"?P:HM(P);return D=D.replace(/ $/,"%20"),oo(M,"No window.location.(origin|href) available to create URL for href: "+D),new URL(D,M)}let R={get action(){return a},get location(){return t(s,c)},listen(P){if(f)throw new Error("A history only accepts one active listener");return s.addEventListener(Bte,v),f=P,()=>{s.removeEventListener(Bte,v),f=null}},createHref(P){return e(s,P)},createURL:k,encodeLocation(P){let M=k(P);return{pathname:M.pathname,search:M.search,hash:M.hash}},push:S,replace:E,go(P){return c.go(P)}};return R}var zte;(function(t){t.data="data",t.deferred="deferred",t.redirect="redirect",t.error="error"})(zte||(zte={}));function T5e(t,e,r){return r===void 0&&(r="/"),E5e(t,e,r,!1)}function E5e(t,e,r,n){let s=typeof e=="string"?pT(e):e,o=mS(s.pathname||"/",r);if(o==null)return null;let c=Mge(t);j5e(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("/")&&(oo(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 p=lx([n,f.relativePath]),y=r.concat(f);o.children&&o.children.length>0&&(oo(o.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+p+'".')),Mge(o.children,e,y,p)),!(o.path==null&&!o.index)&&e.push({path:p,score:R5e(p,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 Dge(o.path))s(o,c,f)}),e}function Dge(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=Dge(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 j5e(t){t.sort((e,r)=>e.score!==r.score?r.score-e.score:L5e(e.routesMeta.map(n=>n.childrenIndex),r.routesMeta.map(n=>n.childrenIndex)))}const A5e=/^:[\w-]+$/,k5e=3,N5e=2,C5e=1,I5e=10,P5e=-2,Ute=t=>t==="*";function R5e(t,e){let r=t.split("/"),n=r.length;return r.some(Ute)&&(n+=P5e),e&&(n+=N5e),r.filter(s=>!Ute(s)).reduce((s,o)=>s+(A5e.test(o)?k5e:o===""?C5e:I5e),n)}function L5e(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 M5e(t,e,r){let{routesMeta:n}=t,s={},o="/",c=[];for(let a=0;a{let{paramName:S,isOptional:E}=y;if(S==="*"){let R=a[v]||"";c=o.slice(0,o.length-R.length).replace(/(.)\/+$/,"$1")}const k=a[v];return E&&!k?p[S]=void 0:p[S]=(k||"").replace(/%2F/g,"/"),p},{}),pathname:o,pathnameBase:c,pattern:t}}function D5e(t,e,r){e===void 0&&(e=!1),r===void 0&&(r=!0),Lge(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 O5e(t){try{return t.split("/").map(e=>decodeURIComponent(e).replace(/\//g,"%2F")).join("/")}catch(e){return Lge(!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 mS(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 F5e(t,e){e===void 0&&(e="/");let{pathname:r,search:n="",hash:s=""}=typeof t=="string"?pT(t):t;return{pathname:r?r.startsWith("/")?r:B5e(r,e):e,search:U5e(n),hash:V5e(s)}}function B5e(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 D$(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 $5e(t){return t.filter((e,r)=>r===0||e.route.path&&e.route.path.length>0)}function b7(t,e){let r=$5e(t);return e?r.map((n,s)=>s===r.length-1?n.pathname:n.pathnameBase):r.map(n=>n.pathnameBase)}function w7(t,e,r,n){n===void 0&&(n=!1);let s;typeof t=="string"?s=pT(t):(s=ak({},t),oo(!s.pathname||!s.pathname.includes("?"),D$("?","pathname","search",s)),oo(!s.pathname||!s.pathname.includes("#"),D$("#","pathname","hash",s)),oo(!s.search||!s.search.includes("#"),D$("#","search","hash",s)));let o=t===""||s.pathname==="",c=o?"/":s.pathname,a;if(c==null)a=r;else{let v=e.length-1;if(!n&&c.startsWith("..")){let S=c.split("/");for(;S[0]==="..";)S.shift(),v-=1;s.pathname=S.join("/")}a=v>=0?e[v]:"/"}let f=F5e(s,a),p=c&&c!=="/"&&c.endsWith("/"),y=(o||c===".")&&r.endsWith("/");return!f.pathname.endsWith("/")&&(p||y)&&(f.pathname+="/"),f}const lx=t=>t.join("/").replace(/\/\/+/g,"/"),z5e=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),U5e=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,V5e=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t;function q5e(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}const Oge=["post","put","patch","delete"];new Set(Oge);const G5e=["get",...Oge];new Set(G5e);/** * 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 ok(){return ok=Object.assign?Object.assign.bind():function(t){for(var e=1;e{a.current=!0}),N.useCallback(function(p,y){if(y===void 0&&(y={}),!a.current)return;if(typeof p=="number"){n.go(p);return}let v=w7(p,JSON.parse(c),o,y.relative==="path");t==null&&e!=="/"&&(v.pathname=v.pathname==="/"?e:lx([e,v.pathname])),(y.replace?n.replace:n.push)(v,y.state,y)},[e,n,c,o,t])}const K5e=N.createContext(null);function Y5e(t){let e=N.useContext(Bm).outlet;return e&&N.createElement(K5e.Provider,{value:t},e)}function $m(){let{matches:t}=N.useContext(Bm),e=t[t.length-1];return e?e.params:{}}function A3(t,e){let{relative:r}=e===void 0?{}:e,{future:n}=N.useContext(_g),{matches:s}=N.useContext(Bm),{pathname:o}=Es(),c=JSON.stringify(b7(s,n.v7_relativeSplatPath));return N.useMemo(()=>w7(t,JSON.parse(c),o,r==="path"),[t,c,o,r])}function Z5e(t,e){return X5e(t,e)}function X5e(t,e,r,n){gT()||oo(!1);let{navigator:s}=N.useContext(_g),{matches:o}=N.useContext(Bm),c=o[o.length-1],a=c?c.params:{};c&&c.pathname;let f=c?c.pathnameBase:"/";c&&c.route;let p=Es(),y;if(e){var v;let P=typeof e=="string"?pT(e):e;f==="/"||(v=P.pathname)!=null&&v.startsWith(f)||oo(!1),y=P}else y=p;let S=y.pathname||"/",E=S;if(f!=="/"){let P=f.replace(/^\//,"").split("/");E="/"+S.replace(/^\//,"").split("/").slice(P.length).join("/")}let k=T5e(t,{pathname:E}),R=rBe(k&&k.map(P=>Object.assign({},P,{params:Object.assign({},a,P.params),pathname:lx([f,s.encodeLocation?s.encodeLocation(P.pathname).pathname:P.pathname]),pathnameBase:P.pathnameBase==="/"?f:lx([f,s.encodeLocation?s.encodeLocation(P.pathnameBase).pathname:P.pathnameBase])})),o,r,n);return e&&R?N.createElement(j3.Provider,{value:{location:ok({pathname:"/",search:"",hash:"",state:null,key:"default"},y),navigationType:Zy.Pop}},R):R}function Q5e(){let t=aBe(),e=q5e(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 J5e=N.createElement(Q5e,null);class eBe 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(Bm.Provider,{value:this.props.routeContext},N.createElement(Bge.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function tBe(t){let{routeContext:e,match:r,children:n}=t,s=N.useContext(E3);return s&&s.static&&s.staticContext&&(r.route.errorElement||r.route.ErrorBoundary)&&(s.staticContext._deepestRenderedBoundaryId=r.route.id),N.createElement(Bm.Provider,{value:e},n)}function rBe(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(v=>v.route.id&&(a==null?void 0:a[v.route.id])!==void 0);y>=0||oo(!1),c=c.slice(0,Math.min(c.length,y+1))}let f=!1,p=-1;if(r&&n&&n.v7_partialHydration)for(let y=0;y=0?c=c.slice(0,p+1):c=[c[0]];break}}}return c.reduceRight((y,v,S)=>{let E,k=!1,R=null,P=null;r&&(E=a&&v.route.id?a[v.route.id]:void 0,R=v.route.errorElement||J5e,f&&(p<0&&S===0?(k=!0,P=null):p===S&&(k=!0,P=v.route.hydrateFallbackElement||null)));let M=e.concat(c.slice(0,S+1)),D=()=>{let B;return E?B=R:k?B=P:v.route.Component?B=N.createElement(v.route.Component,null):v.route.element?B=v.route.element:B=y,N.createElement(tBe,{match:v,routeContext:{outlet:y,matches:M,isDataRoute:r!=null},children:B})};return r&&(v.route.ErrorBoundary||v.route.errorElement||S===0)?N.createElement(eBe,{location:r.location,revalidation:r.revalidation,component:R,error:E,children:D(),routeContext:{outlet:null,matches:M,isDataRoute:!0}}):D()},null)}var zge=function(t){return t.UseBlocker="useBlocker",t.UseRevalidator="useRevalidator",t.UseNavigateStable="useNavigate",t}(zge||{}),KM=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}(KM||{});function nBe(t){let e=N.useContext(E3);return e||oo(!1),e}function sBe(t){let e=N.useContext(Fge);return e||oo(!1),e}function iBe(t){let e=N.useContext(Bm);return e||oo(!1),e}function Uge(t){let e=iBe(),r=e.matches[e.matches.length-1];return r.route.id||oo(!1),r.route.id}function aBe(){var t;let e=N.useContext(Bge),r=sBe(KM.UseRouteError),n=Uge(KM.UseRouteError);return e!==void 0?e:(t=r.errors)==null?void 0:t[n]}function oBe(){let{router:t}=nBe(zge.UseNavigateStable),e=Uge(KM.UseNavigateStable),r=N.useRef(!1);return $ge(()=>{r.current=!0}),N.useCallback(function(s,o){o===void 0&&(o={}),r.current&&(typeof s=="number"?t.navigate(s):t.navigate(s,ok({fromRouteId:e},o)))},[t,e])}function lBe(t,e){t==null||t.v7_startTransition,t==null||t.v7_relativeSplatPath}function cs(t){let{to:e,replace:r,state:n,relative:s}=t;gT()||oo(!1);let{future:o,static:c}=N.useContext(_g),{matches:a}=N.useContext(Bm),{pathname:f}=Es(),p=Wi(),y=w7(e,b7(a,o.v7_relativeSplatPath),f,s==="path"),v=JSON.stringify(y);return N.useEffect(()=>p(JSON.parse(v),{replace:r,state:n,relative:s}),[p,v,s,r,n]),null}function oGt(t){return Y5e(t.context)}function ge(t){oo(!1)}function cBe(t){let{basename:e="/",children:r=null,location:n,navigationType:s=Zy.Pop,navigator:o,static:c=!1,future:a}=t;gT()&&oo(!1);let f=e.replace(/^\/*/,"/"),p=N.useMemo(()=>({basename:f,navigator:o,static:c,future:ok({v7_relativeSplatPath:!1},a)}),[f,a,o,c]);typeof n=="string"&&(n=pT(n));let{pathname:y="/",search:v="",hash:S="",state:E=null,key:k="default"}=n,R=N.useMemo(()=>{let P=mS(y,f);return P==null?null:{location:{pathname:P,search:v,hash:S,state:E,key:k},navigationType:s}},[f,y,v,S,E,k,s]);return R==null?null:N.createElement(_g.Provider,{value:p},N.createElement(j3.Provider,{children:r,value:R}))}function Fp(t){let{children:e,location:r}=t;return Z5e(AV(e),r)}new Promise(()=>{});function AV(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,AV(n.props.children,o));return}n.type!==ge&&oo(!1),!n.props.index||!n.props.children||oo(!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=AV(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 YM(){return YM=Object.assign?Object.assign.bind():function(t){for(var e=1;e=0)&&(r[s]=t[s]);return r}function uBe(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function dBe(t,e){return t.button===0&&(!e||e==="_self")&&!uBe(t)}function kV(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 hBe(t,e){let r=kV(t);return e&&e.forEach((n,s)=>{r.has(s)||e.getAll(s).forEach(o=>{r.append(s,o)})}),r}const fBe=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],mBe=["aria-current","caseSensitive","className","end","style","to","viewTransition","children"],pBe="6";try{window.__reactRouterVersion=pBe}catch{}const gBe=N.createContext({isTransitioning:!1}),yBe="startTransition",Vte=VG[yBe];function xBe(t){let{basename:e,children:r,future:n,window:s}=t,o=N.useRef();o.current==null&&(o.current=b5e({window:s,v5Compat:!0}));let c=o.current,[a,f]=N.useState({action:c.action,location:c.location}),{v7_startTransition:p}=n||{},y=N.useCallback(v=>{p&&Vte?Vte(()=>f(v)):f(v)},[f,p]);return N.useLayoutEffect(()=>c.listen(y),[c,y]),N.useEffect(()=>lBe(n),[n]),N.createElement(cBe,{basename:e,children:r,location:a.location,navigationType:a.action,navigator:c,future:n})}const vBe=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",_Be=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,qr=N.forwardRef(function(e,r){let{onClick:n,relative:s,reloadDocument:o,replace:c,state:a,target:f,to:p,preventScrollReset:y,viewTransition:v}=e,S=Vge(e,fBe),{basename:E}=N.useContext(_g),k,R=!1;if(typeof p=="string"&&_Be.test(p)&&(k=p,vBe))try{let B=new URL(window.location.href),V=p.startsWith("//")?new URL(B.protocol+p):new URL(p),G=mS(V.pathname,E);V.origin===B.origin&&G!=null?p=G+V.search+V.hash:R=!0}catch{}let P=H5e(p,{relative:s}),M=wBe(p,{replace:c,state:a,target:f,preventScrollReset:y,relative:s,viewTransition:v});function D(B){n&&n(B),B.defaultPrevented||M(B)}return N.createElement("a",YM({},S,{href:k||P,onClick:R||o?n:D,ref:r,target:f}))}),lGt=N.forwardRef(function(e,r){let{"aria-current":n="page",caseSensitive:s=!1,className:o="",end:c=!1,style:a,to:f,viewTransition:p,children:y}=e,v=Vge(e,mBe),S=A3(f,{relative:v.relative}),E=Es(),k=N.useContext(Fge),{navigator:R,basename:P}=N.useContext(_g),M=k!=null&&SBe(S)&&p===!0,D=R.encodeLocation?R.encodeLocation(S).pathname:S.pathname,B=E.pathname,V=k&&k.navigation&&k.navigation.location?k.navigation.location.pathname:null;s||(B=B.toLowerCase(),V=V?V.toLowerCase():null,D=D.toLowerCase()),V&&P&&(V=mS(V,P)||V);const G=D!=="/"&&D.endsWith("/")?D.length-1:D.length;let W=B===D||!c&&B.startsWith(D)&&B.charAt(G)==="/",Y=V!=null&&(V===D||!c&&V.startsWith(D)&&V.charAt(D.length)==="/"),J={isActive:W,isPending:Y,isTransitioning:M},Q=W?n:void 0,ee;typeof o=="function"?ee=o(J):ee=[o,W?"active":null,Y?"pending":null,M?"transitioning":null].filter(Boolean).join(" ");let le=typeof a=="function"?a(J):a;return N.createElement(qr,YM({},v,{"aria-current":Q,className:ee,ref:r,style:le,to:f,viewTransition:p}),typeof y=="function"?y(J):y)});var NV;(function(t){t.UseScrollRestoration="useScrollRestoration",t.UseSubmit="useSubmit",t.UseSubmitFetcher="useSubmitFetcher",t.UseFetcher="useFetcher",t.useViewTransitionState="useViewTransitionState"})(NV||(NV={}));var qte;(function(t){t.UseFetcher="useFetcher",t.UseFetchers="useFetchers",t.UseScrollRestoration="useScrollRestoration"})(qte||(qte={}));function bBe(t){let e=N.useContext(E3);return e||oo(!1),e}function wBe(t,e){let{target:r,replace:n,state:s,preventScrollReset:o,relative:c,viewTransition:a}=e===void 0?{}:e,f=Wi(),p=Es(),y=A3(t,{relative:c});return N.useCallback(v=>{if(dBe(v,r)){v.preventDefault();let S=n!==void 0?n:HM(p)===HM(y);f(t,{replace:S,state:s,preventScrollReset:o,relative:c,viewTransition:a})}},[p,f,y,n,s,r,t,o,c,a])}function Fx(t){let e=N.useRef(kV(t)),r=N.useRef(!1),n=Es(),s=N.useMemo(()=>hBe(n.search,r.current?null:e.current),[n.search]),o=Wi(),c=N.useCallback((a,f)=>{const p=kV(typeof a=="function"?a(s):a);r.current=!0,o("?"+p,f)},[o,s]);return[s,c]}function SBe(t,e){e===void 0&&(e={});let r=N.useContext(gBe);r==null&&oo(!1);let{basename:n}=bBe(NV.useViewTransitionState),s=A3(t,{relative:e.relative});if(!r.isTransitioning)return!1;let o=mS(r.currentLocation.pathname,n)||r.currentLocation.pathname,c=mS(r.nextLocation.pathname,n)||r.nextLocation.pathname;return WM(s.pathname,c)!=null||WM(s.pathname,o)!=null}var TBe=typeof Element<"u",EBe=typeof Map=="function",jBe=typeof Set=="function",ABe=typeof ArrayBuffer=="function"&&!!ArrayBuffer.isView;function LL(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(!LL(t[n],e[n]))return!1;return!0}var o;if(EBe&&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(!LL(n.value[1],e.get(n.value[0])))return!1;return!0}if(jBe&&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(ABe&&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(TBe&&t instanceof Element)return!1;for(n=r;n--!==0;)if(!((s[n]==="_owner"||s[n]==="__v"||s[n]==="__o")&&t.$$typeof)&&!LL(t[s[n]],e[s[n]]))return!1;return!0}return t!==t&&e!==e}var kBe=function(e,r){try{return LL(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 NBe=hi(kBe);var CBe=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 p=[r,n,s,o,c,a],y=0;f=new Error(e.replace(/%s/g,function(){return p[y++]})),f.name="Invariant Violation"}throw f.framesToPop=1,f}},IBe=CBe;const Gte=hi(IBe);var PBe=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),p=0;p(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))(qge||{}),O$={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"]}},Hte=Object.values(qge),S7={accesskey:"accessKey",charset:"charSet",class:"className",contenteditable:"contentEditable",contextmenu:"contextMenu","http-equiv":"httpEquiv",itemprop:"itemProp",tabindex:"tabIndex"},LBe=Object.entries(S7).reduce((t,[e,r])=>(t[r]=e,t),{}),uf="data-rh",C1={DEFAULT_TITLE:"defaultTitle",DEFER:"defer",ENCODE_SPECIAL_CHARACTERS:"encodeSpecialCharacters",ON_CHANGE_CLIENT_STATE:"onChangeClientState",TITLE_TEMPLATE:"titleTemplate",PRIORITIZE_SEO_TAGS:"prioritizeSeoTags"},I1=(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},MBe=t=>{let e=I1(t,"title");const r=I1(t,C1.TITLE_TEMPLATE);if(Array.isArray(e)&&(e=e.join("")),r&&e)return r.replace(/%s/g,()=>e);const n=I1(t,C1.DEFAULT_TITLE);return e||n||void 0},DBe=t=>I1(t,C1.ON_CHANGE_CLIENT_STATE)||(()=>{}),F$=(t,e)=>e.filter(r=>typeof r[t]<"u").map(r=>r[t]).reduce((r,n)=>({...r,...n}),{}),OBe=(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),h2=(t,e,r)=>{const n={};return r.filter(s=>Array.isArray(s[t])?!0:(typeof s[t]<"u"&&FBe(`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 p;const y=Object.keys(f);for(let S=0;Ss.push(f));const a=Object.keys(c);for(let f=0;f{if(Array.isArray(t)&&t.length){for(let r=0;r({baseTag:OBe(["href"],t),bodyAttributes:F$("bodyAttributes",t),defer:I1(t,C1.DEFER),encode:I1(t,C1.ENCODE_SPECIAL_CHARACTERS),htmlAttributes:F$("htmlAttributes",t),linkTags:h2("link",["rel","href"],t),metaTags:h2("meta",["name","charset","http-equiv","property","itemprop"],t),noscriptTags:h2("noscript",["innerHTML"],t),onChangeClientState:DBe(t),scriptTags:h2("script",["src","innerHTML"],t),styleTags:h2("style",["cssText"],t),title:MBe(t),titleAttributes:F$("titleAttributes",t),prioritizeSeoTags:BBe(t,C1.PRIORITIZE_SEO_TAGS)}),Gge=t=>Array.isArray(t)?t.join(""):t,zBe=(t,e)=>{const r=Object.keys(t);for(let n=0;nArray.isArray(t)?t.reduce((r,n)=>(zBe(n,e)?r.priority.push(n):r.default.push(n),r),{priority:[],default:[]}):{default:t,priority:[]},Wte=(t,e)=>({...t,[e]:void 0}),UBe=["noscript","script","style"],CV=(t,e=!0)=>e===!1?String(t):String(t).replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'"),Hge=t=>Object.keys(t).reduce((e,r)=>{const n=typeof t[r]<"u"?`${r}="${t[r]}"`:`${r}`;return e?`${e} ${n}`:n},""),VBe=(t,e,r,n)=>{const s=Hge(r),o=Gge(e);return s?`<${t} ${uf}="true" ${s}>${CV(o,n)}`:`<${t} ${uf}="true">${CV(o,n)}`},qBe=(t,e,r=!0)=>e.reduce((n,s)=>{const o=s,c=Object.keys(o).filter(p=>!(p==="innerHTML"||p==="cssText")).reduce((p,y)=>{const v=typeof o[y]>"u"?y:`${y}="${CV(o[y],r)}"`;return p?`${p} ${v}`:v},""),a=o.innerHTML||o.cssText||"",f=UBe.indexOf(t)===-1;return`${n}<${t} ${uf}="true" ${c}${f?"/>":`>${a}`}`},""),Wge=(t,e={})=>Object.keys(t).reduce((r,n)=>{const s=S7[n];return r[s||n]=t[n],r},e),GBe=(t,e,r)=>{const n={key:e,[uf]:!0},s=Wge(r,n);return[Xe.createElement("title",s,e)]},ML=(t,e)=>e.map((r,n)=>{const s={key:n,[uf]:!0};return Object.keys(r).forEach(o=>{const a=S7[o]||o;if(a==="innerHTML"||a==="cssText"){const f=r.innerHTML||r.cssText;s.dangerouslySetInnerHTML={__html:f}}else s[a]=r[o]}),Xe.createElement(t,s)}),Xd=(t,e,r=!0)=>{switch(t){case"title":return{toComponent:()=>GBe(t,e.title,e.titleAttributes),toString:()=>VBe(t,e.title,e.titleAttributes,r)};case"bodyAttributes":case"htmlAttributes":return{toComponent:()=>Wge(e),toString:()=>Hge(e)};default:return{toComponent:()=>ML(t,e),toString:()=>qBe(t,e,r)}}},HBe=({metaTags:t,linkTags:e,scriptTags:r,encode:n})=>{const s=B$(t,O$.meta),o=B$(e,O$.link),c=B$(r,O$.script);return{priorityMethods:{toComponent:()=>[...ML("meta",s.priority),...ML("link",o.priority),...ML("script",c.priority)],toString:()=>`${Xd("meta",s.priority,n)} ${Xd("link",o.priority,n)} ${Xd("script",c.priority,n)}`},metaTags:s.default,linkTags:o.default,scriptTags:c.default}},WBe=t=>{const{baseTag:e,bodyAttributes:r,encode:n=!0,htmlAttributes:s,noscriptTags:o,styleTags:c,title:a="",titleAttributes:f,prioritizeSeoTags:p}=t;let{linkTags:y,metaTags:v,scriptTags:S}=t,E={toComponent:()=>{},toString:()=>""};return p&&({priorityMethods:E,linkTags:y,metaTags:v,scriptTags:S}=HBe(t)),{priority:E,base:Xd("base",e,n),bodyAttributes:Xd("bodyAttributes",r,n),htmlAttributes:Xd("htmlAttributes",s,n),link:Xd("link",y,n),meta:Xd("meta",v,n),noscript:Xd("noscript",o,n),script:Xd("script",S,n),style:Xd("style",c,n),title:Xd("title",{title:a,titleAttributes:f},n)}},IV=WBe,fR=[],Kge=!!(typeof window<"u"&&window.document&&window.document.createElement),PV=class{constructor(t,e){dn(this,"instances",[]);dn(this,"canUseDOM",Kge);dn(this,"context");dn(this,"value",{setHelmet:t=>{this.context.helmet=t},helmetInstances:{get:()=>this.canUseDOM?fR:this.instances,add:t=>{(this.canUseDOM?fR:this.instances).push(t)},remove:t=>{const e=(this.canUseDOM?fR:this.instances).indexOf(t);(this.canUseDOM?fR:this.instances).splice(e,1)}}});this.context=t,this.canUseDOM=e||!1,e||(t.helmet=IV({baseTag:[],bodyAttributes:{},encodeSpecialCharacters:!0,htmlAttributes:{},linkTags:[],metaTags:[],noscriptTags:[],scriptTags:[],styleTags:[],title:"",titleAttributes:{}}))}},KBe={},Yge=Xe.createContext(KBe),Yv,Zge=(Yv=class extends N.Component{constructor(r){super(r);dn(this,"helmetData");this.helmetData=new PV(this.props.context||{},Yv.canUseDOM)}render(){return Xe.createElement(Yge.Provider,{value:this.helmetData.value},this.props.children)}},dn(Yv,"canUseDOM",Kge),Yv),_w=(t,e)=>{const r=document.head||document.querySelector("head"),n=r.querySelectorAll(`${t}[${uf}]`),s=[].slice.call(n),o=[];let c;return e&&e.length&&e.forEach(a=>{const f=document.createElement(t);for(const p in a)if(Object.prototype.hasOwnProperty.call(a,p))if(p==="innerHTML")f.innerHTML=a.innerHTML;else if(p==="cssText")f.styleSheet?f.styleSheet.cssText=a.cssText:f.appendChild(document.createTextNode(a.cssText));else{const y=p,v=typeof a[y]>"u"?"":a[y];f.setAttribute(p,v)}f.setAttribute(uf,"true"),s.some((p,y)=>(c=y,f.isEqualNode(p)))?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}},RV=(t,e)=>{const r=document.getElementsByTagName(t)[0];if(!r)return;const n=r.getAttribute(uf),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 p=o.indexOf(a);p!==-1&&o.splice(p,1)}for(let a=o.length-1;a>=0;a-=1)r.removeAttribute(o[a]);s.length===o.length?r.removeAttribute(uf):r.getAttribute(uf)!==c.join(",")&&r.setAttribute(uf,c.join(","))},YBe=(t,e)=>{typeof t<"u"&&document.title!==t&&(document.title=Gge(t)),RV("title",e)},Kte=(t,e)=>{const{baseTag:r,bodyAttributes:n,htmlAttributes:s,linkTags:o,metaTags:c,noscriptTags:a,onChangeClientState:f,scriptTags:p,styleTags:y,title:v,titleAttributes:S}=t;RV("body",n),RV("html",s),YBe(v,S);const E={baseTag:_w("base",r),linkTags:_w("link",o),metaTags:_w("meta",c),noscriptTags:_w("noscript",a),scriptTags:_w("script",p),styleTags:_w("style",y)},k={},R={};Object.keys(E).forEach(P=>{const{newTags:M,oldTags:D}=E[P];M.length&&(k[P]=M),D.length&&(R[P]=E[P].oldTags)}),e&&e(),f(t,k,R)},f2=null,ZBe=t=>{f2&&cancelAnimationFrame(f2),t.defer?f2=requestAnimationFrame(()=>{Kte(t,()=>{f2=null})}):(Kte(t),f2=null)},XBe=ZBe,Yte=class extends N.Component{constructor(){super(...arguments);dn(this,"rendered",!1)}shouldComponentUpdate(e){return!RBe(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=$Be(e.get().map(o=>{const c={...o.props};return delete c.context,c}));Zge.canUseDOM?XBe(s):IV&&(n=IV(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}},X6,Oo=(X6=class extends N.Component{shouldComponentUpdate(t){return!NBe(Wte(this.props,"helmetData"),Wte(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 Gte(Hte.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 ${Hte.join(", ")} are allowed. Helmet does not support rendering <${t.type}> elements. Refer to our API for more information.`),Gte(!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 Xe.Children.forEach(t,n=>{if(!n||!n.props)return;const{children:s,...o}=n.props,c=Object.keys(o).reduce((f,p)=>(f[LBe[p]||p]=o[p],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 PV)){const s=n;n=new PV(s.context,!0),delete r.helmetData}return n?Xe.createElement(Yte,{...r,context:n.value}):Xe.createElement(Yge.Consumer,null,s=>Xe.createElement(Yte,{...r,context:s}))}},dn(X6,"defaultProps",{defer:!0,encodeSpecialCharacters:!0,prioritizeSeoTags:!1}),X6);const QBe=t=>{let e;return t?e=t:typeof fetch>"u"?e=(...r)=>Fe(async()=>{const{default:n}=await Promise.resolve().then(()=>yT);return{default:n}},void 0).then(({default:n})=>n(...r)):e=fetch,(...r)=>e(...r)};class T7 extends Error{constructor(e,r="FunctionsError",n){super(e),this.name=r,this.context=n}}class JBe extends T7{constructor(e){super("Failed to send a request to the Edge Function","FunctionsFetchError",e)}}class e$e extends T7{constructor(e){super("Relay Error invoking the Edge Function","FunctionsRelayError",e)}}class t$e extends T7{constructor(e){super("Edge Function returned a non-2xx status code","FunctionsHttpError",e)}}var LV;(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"})(LV||(LV={}));var r$e=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{p(n.next(y))}catch(v){c(v)}}function f(y){try{p(n.throw(y))}catch(v){c(v)}}function p(y){y.done?o(y.value):s(y.value).then(a,f)}p((n=n.apply(t,e||[])).next())})};class n$e{constructor(e,{headers:r={},customFetch:n,region:s=LV.Any}={}){this.url=e,this.headers=r,this.region=s,this.fetch=QBe(n)}setAuth(e){this.headers.Authorization=`Bearer ${e}`}invoke(e,r={}){var n;return r$e(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 p;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",p=c):typeof c=="string"?(a["Content-Type"]="text/plain",p=c):typeof FormData<"u"&&c instanceof FormData?p=c:(a["Content-Type"]="application/json",p=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:p}).catch(k=>{throw new JBe(k)}),v=y.headers.get("x-relay-error");if(v&&v==="true")throw new e$e(y);if(!y.ok)throw new t$e(y);let S=((n=y.headers.get("Content-Type"))!==null&&n!==void 0?n:"text/plain").split(";")[0].trim(),E;return S==="application/json"?E=yield y.json():S==="application/octet-stream"?E=yield y.blob():S==="text/event-stream"?E=y:S==="multipart/form-data"?E=yield y.formData():E=yield y.text(),{data:E,error:null}}catch(s){return{data:null,error:s}}})}}var Nu={},E7={},k3={},BN={},N3={},C3={},s$e=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")},pS=s$e();const i$e=pS.fetch,Xge=pS.fetch.bind(pS),Qge=pS.Headers,a$e=pS.Request,o$e=pS.Response,yT=Object.freeze(Object.defineProperty({__proto__:null,Headers:Qge,Request:a$e,Response:o$e,default:Xge,fetch:i$e},Symbol.toStringTag,{value:"Module"})),l$e=xPe(yT);var I3={};Object.defineProperty(I3,"__esModule",{value:!0});let c$e=class extends Error{constructor(e){super(e.message),this.name="PostgrestError",this.details=e.details,this.hint=e.hint,this.code=e.code}};I3.default=c$e;var Jge=nc&&nc.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(C3,"__esModule",{value:!0});const u$e=Jge(l$e),d$e=Jge(I3);let h$e=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=u$e.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 p=null,y=null,v=null,S=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 R=(c=this.headers.Prefer)===null||c===void 0?void 0:c.match(/count=(exact|planned|estimated)/),P=(a=o.headers.get("content-range"))===null||a===void 0?void 0:a.split("/");R&&P&&P.length>1&&(v=parseInt(P[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(y)&&(y.length>1?(p={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,v=null,S=406,E="Not Acceptable"):y.length===1?y=y[0]:y=null)}else{const R=await o.text();try{p=JSON.parse(R),Array.isArray(p)&&o.status===404&&(y=[],p=null,S=200,E="OK")}catch{o.status===404&&R===""?(S=204,E="No Content"):p={message:R}}if(p&&this.isMaybeSingle&&(!((f=p==null?void 0:p.details)===null||f===void 0)&&f.includes("0 rows"))&&(p=null,S=200,E="OK"),p&&this.shouldThrowOnError)throw new d$e.default(p)}return{error:p,data:y,count:v,status:S,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}};C3.default=h$e;var f$e=nc&&nc.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(N3,"__esModule",{value:!0});const m$e=f$e(C3);let p$e=class extends m$e.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("|"),p=(a=this.headers.Accept)!==null&&a!==void 0?a:"application/json";return this.headers.Accept=`application/vnd.pgrst.plan+${c}; for="${p}"; 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}};N3.default=p$e;var g$e=nc&&nc.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(BN,"__esModule",{value:!0});const y$e=g$e(N3);let x$e=class extends y$e.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}};BN.default=x$e;var v$e=nc&&nc.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(k3,"__esModule",{value:!0});const m2=v$e(BN);let _$e=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 m2.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 m2.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((p,y)=>p.concat(Object.keys(y)),[]);if(f.length>0){const p=[...new Set(f)].map(y=>`"${y}"`);this.url.searchParams.set("columns",p.join(","))}}return new m2.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 m2.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 m2.default({method:r,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch,allowEmpty:!1})}};k3.default=_$e;var P3={},R3={};Object.defineProperty(R3,"__esModule",{value:!0});R3.version=void 0;R3.version="0.0.0-automated";Object.defineProperty(P3,"__esModule",{value:!0});P3.DEFAULT_HEADERS=void 0;const b$e=R3;P3.DEFAULT_HEADERS={"X-Client-Info":`postgrest-js/${b$e.version}`};var eye=nc&&nc.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(E7,"__esModule",{value:!0});const w$e=eye(k3),S$e=eye(BN),T$e=P3;let E$e=class tye{constructor(e,{headers:r={},schema:n,fetch:s}={}){this.url=e,this.headers=Object.assign(Object.assign({},T$e.DEFAULT_HEADERS),r),this.schemaName=n,this.fetch=s}from(e){const r=new URL(`${this.url}/${e}`);return new w$e.default(r,{headers:Object.assign({},this.headers),schema:this.schemaName,fetch:this.fetch})}schema(e){return new tye(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,v])=>v!==void 0).map(([y,v])=>[y,Array.isArray(v)?`{${v.join(",")}}`:`${v}`]).forEach(([y,v])=>{a.searchParams.append(y,v)})):(c="POST",f=r);const p=Object.assign({},this.headers);return o&&(p.Prefer=`count=${o}`),new S$e.default({method:c,url:a,headers:p,schema:this.schemaName,body:f,fetch:this.fetch,allowEmpty:!1})}};E7.default=E$e;var xT=nc&&nc.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Nu,"__esModule",{value:!0});Nu.PostgrestError=Nu.PostgrestBuilder=Nu.PostgrestTransformBuilder=Nu.PostgrestFilterBuilder=Nu.PostgrestQueryBuilder=Nu.PostgrestClient=void 0;const rye=xT(E7);Nu.PostgrestClient=rye.default;const nye=xT(k3);Nu.PostgrestQueryBuilder=nye.default;const sye=xT(BN);Nu.PostgrestFilterBuilder=sye.default;const iye=xT(N3);Nu.PostgrestTransformBuilder=iye.default;const aye=xT(C3);Nu.PostgrestBuilder=aye.default;const oye=xT(I3);Nu.PostgrestError=oye.default;var j$e=Nu.default={PostgrestClient:rye.default,PostgrestQueryBuilder:nye.default,PostgrestFilterBuilder:sye.default,PostgrestTransformBuilder:iye.default,PostgrestBuilder:aye.default,PostgrestError:oye.default};const{PostgrestClient:A$e,PostgrestQueryBuilder:mGt,PostgrestFilterBuilder:pGt,PostgrestTransformBuilder:gGt,PostgrestBuilder:yGt,PostgrestError:xGt}=j$e;let MV;typeof window>"u"?MV=require("ws"):MV=window.WebSocket;const k$e=MV,N$e="2.11.10",C$e={"X-Client-Info":`realtime-js/${N$e}`},I$e="1.0.0",lye=1e4,P$e=1e3;var P1;(function(t){t[t.connecting=0]="connecting",t[t.open=1]="open",t[t.closing=2]="closing",t[t.closed=3]="closed"})(P1||(P1={}));var Gc;(function(t){t.closed="closed",t.errored="errored",t.joined="joined",t.joining="joining",t.leaving="leaving"})(Gc||(Gc={}));var ef;(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"})(ef||(ef={}));var DV;(function(t){t.websocket="websocket"})(DV||(DV={}));var kv;(function(t){t.Connecting="connecting",t.Open="open",t.Closing="closing",t.Closed="closed"})(kv||(kv={}));class R$e{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 p=JSON.parse(n.decode(e.slice(c,e.byteLength)));return{ref:null,topic:a,event:f,payload:p}}}class cye{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 ga;(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"})(ga||(ga={}));const Zte=(t,e,r={})=>{var n;const s=(n=r.skipTypes)!==null&&n!==void 0?n:[];return Object.keys(e).reduce((o,c)=>(o[c]=L$e(c,t,e,s),o),{})},L$e=(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)?uye(o,c):OV(c)},uye=(t,e)=>{if(t.charAt(0)==="_"){const r=t.slice(1,t.length);return F$e(e,r)}switch(t){case ga.bool:return M$e(e);case ga.float4:case ga.float8:case ga.int2:case ga.int4:case ga.int8:case ga.numeric:case ga.oid:return D$e(e);case ga.json:case ga.jsonb:return O$e(e);case ga.timestamp:return B$e(e);case ga.abstime:case ga.date:case ga.daterange:case ga.int4range:case ga.int8range:case ga.money:case ga.reltime:case ga.text:case ga.time:case ga.timestamptz:case ga.timetz:case ga.tsrange:case ga.tstzrange:return OV(e);default:return OV(e)}},OV=t=>t,M$e=t=>{switch(t){case"t":return!0;case"f":return!1;default:return t}},D$e=t=>{if(typeof t=="string"){const e=parseFloat(t);if(!Number.isNaN(e))return e}return t},O$e=t=>{if(typeof t=="string")try{return JSON.parse(t)}catch(e){return console.log(`JSON parse error: ${e}`),t}return t},F$e=(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=>uye(e,a))}return t},B$e=t=>typeof t=="string"?t.replace(" ","T"):t,dye=t=>{let e=t;return e=e.replace(/^ws/i,"http"),e=e.replace(/(\/socket\/websocket|\/socket|\/websocket)\/?$/i,""),e.replace(/\/+$/,"")};class $${constructor(e,r,n={},s=lye){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 Xte;(function(t){t.SYNC="sync",t.JOIN="join",t.LEAVE="leave"})(Xte||(Xte={}));class fA{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=fA.syncState(this.state,s,o,c),this.pendingDiffs.forEach(f=>{this.state=fA.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=fA.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,(p,y)=>{c[p]||(f[p]=y)}),this.map(c,(p,y)=>{const v=o[p];if(v){const S=y.map(P=>P.presence_ref),E=v.map(P=>P.presence_ref),k=y.filter(P=>E.indexOf(P.presence_ref)<0),R=v.filter(P=>S.indexOf(P.presence_ref)<0);k.length>0&&(a[p]=k),R.length>0&&(f[p]=R)}else a[p]=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 p;const y=(p=e[a])!==null&&p!==void 0?p:[];if(e[a]=this.cloneDeep(f),y.length>0){const v=e[a].map(E=>E.presence_ref),S=y.filter(E=>v.indexOf(E.presence_ref)<0);e[a].unshift(...S)}n(a,y,f)}),this.map(c,(a,f)=>{let p=e[a];if(!p)return;const y=f.map(v=>v.presence_ref);p=p.filter(v=>y.indexOf(v.presence_ref)<0),e[a]=p,s(a,p,f),p.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 Qte;(function(t){t.ALL="*",t.INSERT="INSERT",t.UPDATE="UPDATE",t.DELETE="DELETE"})(Qte||(Qte={}));var Jte;(function(t){t.BROADCAST="broadcast",t.PRESENCE="presence",t.POSTGRES_CHANGES="postgres_changes",t.SYSTEM="system"})(Jte||(Jte={}));var Rp;(function(t){t.SUBSCRIBED="SUBSCRIBED",t.TIMED_OUT="TIMED_OUT",t.CLOSED="CLOSED",t.CHANNEL_ERROR="CHANNEL_ERROR"})(Rp||(Rp={}));class j7{constructor(e,r={config:{}},n){this.topic=e,this.params=r,this.socket=n,this.bindings={},this.state=Gc.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 $$(this,ef.join,this.params,this.timeout),this.rejoinTimer=new cye(()=>this._rejoinUntilConnected(),this.socket.reconnectAfterMs),this.joinPush.receive("ok",()=>{this.state=Gc.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=Gc.closed,this.socket._remove(this)}),this._onError(s=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,s),this.state=Gc.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("timeout",()=>{this._isJoining()&&(this.socket.log("channel",`timeout ${this.topic}`,this.joinPush.timeout),this.state=Gc.errored,this.rejoinTimer.scheduleTimeout())}),this._on(ef.reply,{},(s,o)=>{this._trigger(this._replyEventName(o),s)}),this.presence=new fA(this),this.broadcastEndpointURL=dye(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(Rp.CHANNEL_ERROR,y)),this._onClose(()=>e==null?void 0:e(Rp.CLOSED));const f={},p={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:p},f)),this.joinedOnce=!0,this._rejoin(r),this.joinPush.receive("ok",async({postgres_changes:y})=>{var v;if(this.socket.setAuth(),y===void 0){e==null||e(Rp.SUBSCRIBED);return}else{const S=this.bindings.postgres_changes,E=(v=S==null?void 0:S.length)!==null&&v!==void 0?v:0,k=[];for(let R=0;R{this.state=Gc.errored,e==null||e(Rp.CHANNEL_ERROR,new Error(JSON.stringify(Object.values(y).join(", ")||"error")))}).receive("timeout",()=>{e==null||e(Rp.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 p=await this._fetchWithTimeout(this.broadcastEndpointURL,f,(n=r.timeout)!==null&&n!==void 0?n:this.timeout);return await((s=p.body)===null||s===void 0?void 0:s.cancel()),p.ok?"ok":"error"}catch(p){return p.name==="AbortError"?"timed out":"error"}}else return new Promise(o=>{var c,a,f;const p=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"),p.receive("ok",()=>o("ok")),p.receive("error",()=>o("error")),p.receive("timeout",()=>o("timed out"))})}updateJoinPayload(e){this.joinPush.updatePayload(e)}unsubscribe(e=this.timeout){this.state=Gc.leaving;const r=()=>{this.socket.log("channel",`leave ${this.topic}`),this._trigger(ef.close,"leave",this._joinRef())};return this.joinPush.destroy(),new Promise(n=>{const s=new $$(this,ef.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 $$(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:p,join:y}=ef;if(n&&[a,f,p,y].indexOf(c)>=0&&n!==this._joinRef())return;let S=this._onMessage(c,r,n);if(r&&!S)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 k,R,P;return((k=E.filter)===null||k===void 0?void 0:k.event)==="*"||((P=(R=E.filter)===null||R===void 0?void 0:R.event)===null||P===void 0?void 0:P.toLocaleLowerCase())===c}).map(E=>E.callback(S,n)):(o=this.bindings[c])===null||o===void 0||o.filter(E=>{var k,R,P,M,D,B;if(["broadcast","presence","postgres_changes"].includes(c))if("id"in E){const V=E.id,G=(k=E.filter)===null||k===void 0?void 0:k.event;return V&&((R=r.ids)===null||R===void 0?void 0:R.includes(V))&&(G==="*"||(G==null?void 0:G.toLocaleLowerCase())===((P=r.data)===null||P===void 0?void 0:P.type.toLocaleLowerCase()))}else{const V=(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 V==="*"||V===((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 S=="object"&&"ids"in S){const k=S.data,{schema:R,table:P,commit_timestamp:M,type:D,errors:B}=k;S=Object.assign(Object.assign({},{schema:R,table:P,commit_timestamp:M,eventType:D,new:{},old:{},errors:B}),this._getPayloadRecords(k))}E.callback(S,n)})}_isClosed(){return this.state===Gc.closed}_isJoined(){return this.state===Gc.joined}_isJoining(){return this.state===Gc.joining}_isLeaving(){return this.state===Gc.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&&j7.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(ef.close,{},e)}_onError(e){this._on(ef.error,{},r=>e(r))}_canPush(){return this.socket.isConnected()&&this._isJoined()}_rejoin(e=this.timeout){this._isLeaving()||(this.socket._leaveOpenTopic(this.topic),this.state=Gc.joining,this.joinPush.resend(e))}_getPayloadRecords(e){const r={new:{},old:{}};return(e.type==="INSERT"||e.type==="UPDATE")&&(r.new=Zte(e.columns,e.record)),(e.type==="UPDATE"||e.type==="DELETE")&&(r.old=Zte(e.columns,e.old_record)),r}}const ere=()=>{},$$e=` addEventListener("message", (e) => { if (e.data.event === "start") { setInterval(() => postMessage({ event: "keepAlive" }), e.data.interval); } });`;class z$e{constructor(e,r){var n;this.accessTokenValue=null,this.apiKey=null,this.channels=new Array,this.endPoint="",this.httpEndpoint="",this.headers=C$e,this.params={},this.timeout=lye,this.heartbeatIntervalMs=25e3,this.heartbeatTimer=void 0,this.pendingHeartbeatRef=null,this.heartbeatCallback=ere,this.ref=0,this.logger=ere,this.conn=null,this.sendBuffer=[],this.serializer=new R$e,this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.accessToken=null,this._resolveFetch=o=>{let c;return o?c=o:typeof fetch>"u"?c=(...a)=>Fe(async()=>{const{default:f}=await Promise.resolve().then(()=>yT);return{default:f}},void 0).then(({default:f})=>f(...a)):c=fetch,(...a)=>c(...a)},this.endPoint=`${e}/${DV.websocket}`,this.httpEndpoint=dye(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 cye(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=k$e),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 U$e(this.endpointURL(),void 0,{close:()=>{this.conn=null}})}}endpointURL(){return this._appendParams(this.endPoint,Object.assign({},this.params,{vsn:I$e}))}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 P1.connecting:return kv.Connecting;case P1.open:return kv.Open;case P1.closing:return kv.Closing;default:return kv.Closed}}isConnected(){return this.connectionState()===kv.Open}channel(e,r={config:{}}){const n=`realtime:${e}`,s=this.getChannels().find(o=>o.topic===n);if(s)return s;{const o=new j7(`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(ef.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(P$e,"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(ef.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([$$e],{type:"application/javascript"});r=URL.createObjectURL(n)}return r}}class U$e{constructor(e,r,n){this.binaryType="arraybuffer",this.onclose=()=>{},this.onerror=()=>{},this.onmessage=()=>{},this.onopen=()=>{},this.readyState=P1.connecting,this.send=()=>{},this.url=null,this.url=e,this.close=n.close}}class A7 extends Error{constructor(e){super(e),this.__isStorageError=!0,this.name="StorageError"}}function Cl(t){return typeof t=="object"&&t!==null&&"__isStorageError"in t}class V$e extends A7{constructor(e,r){super(e),this.name="StorageApiError",this.status=r}toJSON(){return{name:this.name,message:this.message,status:this.status}}}class FV extends A7{constructor(e,r){super(e),this.name="StorageUnknownError",this.originalError=r}}var q$e=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{p(n.next(y))}catch(v){c(v)}}function f(y){try{p(n.throw(y))}catch(v){c(v)}}function p(y){y.done?o(y.value):s(y.value).then(a,f)}p((n=n.apply(t,e||[])).next())})};const hye=t=>{let e;return t?e=t:typeof fetch>"u"?e=(...r)=>Fe(async()=>{const{default:n}=await Promise.resolve().then(()=>yT);return{default:n}},void 0).then(({default:n})=>n(...r)):e=fetch,(...r)=>e(...r)},G$e=()=>q$e(void 0,void 0,void 0,function*(){return typeof Response>"u"?(yield Fe(()=>Promise.resolve().then(()=>yT),void 0)).Response:Response}),BV=t=>{if(Array.isArray(t))return t.map(r=>BV(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]=BV(n)}),e};var I_=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{p(n.next(y))}catch(v){c(v)}}function f(y){try{p(n.throw(y))}catch(v){c(v)}}function p(y){y.done?o(y.value):s(y.value).then(a,f)}p((n=n.apply(t,e||[])).next())})};const z$=t=>t.msg||t.message||t.error_description||t.error||JSON.stringify(t),H$e=(t,e,r)=>I_(void 0,void 0,void 0,function*(){const n=yield G$e();t instanceof n&&!(r!=null&&r.noResolveJson)?t.json().then(s=>{e(new V$e(z$(s),t.status||500))}).catch(s=>{e(new FV(z$(s),s))}):e(new FV(z$(t),t))}),W$e=(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 $N(t,e,r,n,s,o){return I_(this,void 0,void 0,function*(){return new Promise((c,a)=>{t(r,W$e(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=>H$e(f,a,n))})})}function ZM(t,e,r,n){return I_(this,void 0,void 0,function*(){return $N(t,"GET",e,r,n)})}function Ny(t,e,r,n,s){return I_(this,void 0,void 0,function*(){return $N(t,"POST",e,n,s,r)})}function K$e(t,e,r,n,s){return I_(this,void 0,void 0,function*(){return $N(t,"PUT",e,n,s,r)})}function Y$e(t,e,r,n){return I_(this,void 0,void 0,function*(){return $N(t,"HEAD",e,Object.assign(Object.assign({},r),{noResolveJson:!0}),n)})}function fye(t,e,r,n,s){return I_(this,void 0,void 0,function*(){return $N(t,"DELETE",e,n,s,r)})}var wu=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{p(n.next(y))}catch(v){c(v)}}function f(y){try{p(n.throw(y))}catch(v){c(v)}}function p(y){y.done?o(y.value):s(y.value).then(a,f)}p((n=n.apply(t,e||[])).next())})};const Z$e={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},tre={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1};class X$e{constructor(e,r={},n,s){this.url=e,this.headers=r,this.bucketId=n,this.fetch=hye(s)}uploadOrUpdate(e,r,n,s){return wu(this,void 0,void 0,function*(){try{let o;const c=Object.assign(Object.assign({},tre),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 p=this._removeEmptyFolders(r),y=this._getFinalPath(p),v=yield this.fetch(`${this.url}/object/${y}`,Object.assign({method:e,body:o,headers:a},c!=null&&c.duplex?{duplex:c.duplex}:{})),S=yield v.json();return v.ok?{data:{path:p,id:S.Id,fullPath:S.Key},error:null}:{data:null,error:S}}catch(o){if(Cl(o))return{data:null,error:o};throw o}})}upload(e,r,n){return wu(this,void 0,void 0,function*(){return this.uploadOrUpdate("POST",e,r,n)})}uploadToSignedUrl(e,r,n,s){return wu(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 p=Object.assign({upsert:tre.upsert},s),y=Object.assign(Object.assign({},this.headers),{"x-upsert":String(p.upsert)});typeof Blob<"u"&&n instanceof Blob?(f=new FormData,f.append("cacheControl",p.cacheControl),f.append("",n)):typeof FormData<"u"&&n instanceof FormData?(f=n,f.append("cacheControl",p.cacheControl)):(f=n,y["cache-control"]=`max-age=${p.cacheControl}`,y["content-type"]=p.contentType);const v=yield this.fetch(a.toString(),{method:"PUT",body:f,headers:y}),S=yield v.json();return v.ok?{data:{path:o,fullPath:S.Key},error:null}:{data:null,error:S}}catch(f){if(Cl(f))return{data:null,error:f};throw f}})}createSignedUploadUrl(e,r){return wu(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 Ny(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 A7("No token returned by API");return{data:{signedUrl:c.toString(),path:e,token:a},error:null}}catch(n){if(Cl(n))return{data:null,error:n};throw n}})}update(e,r,n){return wu(this,void 0,void 0,function*(){return this.uploadOrUpdate("PUT",e,r,n)})}move(e,r,n){return wu(this,void 0,void 0,function*(){try{return{data:yield Ny(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(Cl(s))return{data:null,error:s};throw s}})}copy(e,r,n){return wu(this,void 0,void 0,function*(){try{return{data:{path:(yield Ny(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(Cl(s))return{data:null,error:s};throw s}})}createSignedUrl(e,r,n){return wu(this,void 0,void 0,function*(){try{let s=this._getFinalPath(e),o=yield Ny(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(Cl(s))return{data:null,error:s};throw s}})}createSignedUrls(e,r,n){return wu(this,void 0,void 0,function*(){try{const s=yield Ny(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(Cl(s))return{data:null,error:s};throw s}})}download(e,r){return wu(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 ZM(this.fetch,`${this.url}/${s}/${a}${c}`,{headers:this.headers,noResolveJson:!0})).blob(),error:null}}catch(a){if(Cl(a))return{data:null,error:a};throw a}})}info(e){return wu(this,void 0,void 0,function*(){const r=this._getFinalPath(e);try{const n=yield ZM(this.fetch,`${this.url}/object/info/${r}`,{headers:this.headers});return{data:BV(n),error:null}}catch(n){if(Cl(n))return{data:null,error:n};throw n}})}exists(e){return wu(this,void 0,void 0,function*(){const r=this._getFinalPath(e);try{return yield Y$e(this.fetch,`${this.url}/object/${r}`,{headers:this.headers}),{data:!0,error:null}}catch(n){if(Cl(n)&&n instanceof FV){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 p=s.join("&");return p!==""&&(p=`?${p}`),{data:{publicUrl:encodeURI(`${this.url}/${a}/public/${n}${p}`)}}}remove(e){return wu(this,void 0,void 0,function*(){try{return{data:yield fye(this.fetch,`${this.url}/object/${this.bucketId}`,{prefixes:e},{headers:this.headers}),error:null}}catch(r){if(Cl(r))return{data:null,error:r};throw r}})}list(e,r,n){return wu(this,void 0,void 0,function*(){try{const s=Object.assign(Object.assign(Object.assign({},Z$e),r),{prefix:e||""});return{data:yield Ny(this.fetch,`${this.url}/object/list/${this.bucketId}`,s,{headers:this.headers},n),error:null}}catch(s){if(Cl(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 Q$e="2.7.1",J$e={"X-Client-Info":`storage-js/${Q$e}`};var bw=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{p(n.next(y))}catch(v){c(v)}}function f(y){try{p(n.throw(y))}catch(v){c(v)}}function p(y){y.done?o(y.value):s(y.value).then(a,f)}p((n=n.apply(t,e||[])).next())})};class eze{constructor(e,r={},n){this.url=e,this.headers=Object.assign(Object.assign({},J$e),r),this.fetch=hye(n)}listBuckets(){return bw(this,void 0,void 0,function*(){try{return{data:yield ZM(this.fetch,`${this.url}/bucket`,{headers:this.headers}),error:null}}catch(e){if(Cl(e))return{data:null,error:e};throw e}})}getBucket(e){return bw(this,void 0,void 0,function*(){try{return{data:yield ZM(this.fetch,`${this.url}/bucket/${e}`,{headers:this.headers}),error:null}}catch(r){if(Cl(r))return{data:null,error:r};throw r}})}createBucket(e,r={public:!1}){return bw(this,void 0,void 0,function*(){try{return{data:yield Ny(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(Cl(n))return{data:null,error:n};throw n}})}updateBucket(e,r){return bw(this,void 0,void 0,function*(){try{return{data:yield K$e(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(Cl(n))return{data:null,error:n};throw n}})}emptyBucket(e){return bw(this,void 0,void 0,function*(){try{return{data:yield Ny(this.fetch,`${this.url}/bucket/${e}/empty`,{},{headers:this.headers}),error:null}}catch(r){if(Cl(r))return{data:null,error:r};throw r}})}deleteBucket(e){return bw(this,void 0,void 0,function*(){try{return{data:yield fye(this.fetch,`${this.url}/bucket/${e}`,{},{headers:this.headers}),error:null}}catch(r){if(Cl(r))return{data:null,error:r};throw r}})}}class tze extends eze{constructor(e,r={},n){super(e,r,n)}from(e){return new X$e(this.url,this.headers,e,this.fetch)}}const rze="2.49.10";let W2="";typeof Deno<"u"?W2="deno":typeof document<"u"?W2="web":typeof navigator<"u"&&navigator.product==="ReactNative"?W2="react-native":W2="node";const nze={"X-Client-Info":`supabase-js-${W2}/${rze}`},sze={headers:nze},ize={schema:"public"},aze={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},oze={};var lze=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{p(n.next(y))}catch(v){c(v)}}function f(y){try{p(n.throw(y))}catch(v){c(v)}}function p(y){y.done?o(y.value):s(y.value).then(a,f)}p((n=n.apply(t,e||[])).next())})};const cze=t=>{let e;return t?e=t:typeof fetch>"u"?e=Xge:e=fetch,(...r)=>e(...r)},uze=()=>typeof Headers>"u"?Qge:Headers,dze=(t,e,r)=>{const n=cze(r),s=uze();return(o,c)=>lze(void 0,void 0,void 0,function*(){var a;const f=(a=yield e())!==null&&a!==void 0?a:t;let p=new s(c==null?void 0:c.headers);return p.has("apikey")||p.set("apikey",t),p.has("Authorization")||p.set("Authorization",`Bearer ${f}`),n(o,Object.assign(Object.assign({},c),{headers:p}))})};var hze=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{p(n.next(y))}catch(v){c(v)}}function f(y){try{p(n.throw(y))}catch(v){c(v)}}function p(y){y.done?o(y.value):s(y.value).then(a,f)}p((n=n.apply(t,e||[])).next())})};function fze(t){return t.endsWith("/")?t:t+"/"}function mze(t,e){var r,n;const{db:s,auth:o,realtime:c,global:a}=t,{db:f,auth:p,realtime:y,global:v}=e,S={db:Object.assign(Object.assign({},f),s),auth:Object.assign(Object.assign({},p),o),realtime:Object.assign(Object.assign({},y),c),global:Object.assign(Object.assign(Object.assign({},v),a),{headers:Object.assign(Object.assign({},(r=v==null?void 0:v.headers)!==null&&r!==void 0?r:{}),(n=a==null?void 0:a.headers)!==null&&n!==void 0?n:{})}),accessToken:()=>hze(this,void 0,void 0,function*(){return""})};return t.accessToken?S.accessToken=t.accessToken:delete S.accessToken,S}const mye="2.69.1",Gw=30*1e3,$V=3,U$=$V*Gw,pze="http://localhost:9999",gze="supabase.auth.token",yze={"X-Client-Info":`gotrue-js/${mye}`},zV="X-Supabase-Api-Version",pye={"2024-01-01":{timestamp:Date.parse("2024-01-01T00:00:00.0Z"),name:"2024-01-01"}},xze=/^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}$|[a-z0-9_-]{2}$)$/i,vze=6e5;class k7 extends Error{constructor(e,r,n){super(e),this.__isAuthError=!0,this.name="AuthError",this.status=r,this.code=n}}function Bs(t){return typeof t=="object"&&t!==null&&"__isAuthError"in t}class _ze extends k7{constructor(e,r,n){super(e,r,n),this.name="AuthApiError",this.status=r,this.code=n}}function bze(t){return Bs(t)&&t.name==="AuthApiError"}class gye extends k7{constructor(e,r){super(e),this.name="AuthUnknownError",this.originalError=r}}class Bx extends k7{constructor(e,r,n,s){super(e,n,s),this.name=r,this.status=n}}class Sy extends Bx{constructor(){super("Auth session missing!","AuthSessionMissingError",400,void 0)}}function wze(t){return Bs(t)&&t.name==="AuthSessionMissingError"}class V$ extends Bx{constructor(){super("Auth session or user missing","AuthInvalidTokenResponseError",500,void 0)}}class mR extends Bx{constructor(e){super(e,"AuthInvalidCredentialsError",400,void 0)}}class pR extends Bx{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 Sze(t){return Bs(t)&&t.name==="AuthImplicitGrantRedirectError"}class rre extends Bx{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 UV extends Bx{constructor(e,r){super(e,"AuthRetryableFetchError",r,void 0)}}function q$(t){return Bs(t)&&t.name==="AuthRetryableFetchError"}class nre extends Bx{constructor(e,r,n){super(e,"AuthWeakPasswordError",r,"weak_password"),this.reasons=n}}class mA extends Bx{constructor(e){super(e,"AuthInvalidJwtError",400,"invalid_jwt")}}const sre="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".split(""),ire=` \r=`.split(""),Tze=(()=>{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 are(t){const e=[],r=c=>{e.push(String.fromCodePoint(c))},n={utf8seq:0,codepoint:0},s={queue:0,queuedBits:0},o=c=>{Aze(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 jze(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}Eze(n,e)}}function Aze(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 kze(t){const e=[],r={queue:0,queuedBits:0},n=s=>{e.push(s)};for(let s=0;se.push(r)),new Uint8Array(e)}function Cze(t){return Math.round(Date.now()/1e3)+t}function Ize(){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 Jf=()=>typeof window<"u"&&typeof document<"u",ov={tested:!1,writable:!1},pA=()=>{if(!Jf())return!1;try{if(typeof globalThis.localStorage!="object")return!1}catch{return!1}if(ov.tested)return ov.writable;const t=`lswt-${Math.random()}${Math.random()}`;try{globalThis.localStorage.setItem(t,t),globalThis.localStorage.removeItem(t),ov.tested=!0,ov.writable=!0}catch{ov.tested=!0,ov.writable=!1}return ov.writable};function Pze(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 xye=t=>{let e;return t?e=t:typeof fetch>"u"?e=(...r)=>Fe(async()=>{const{default:n}=await Promise.resolve().then(()=>yT);return{default:n}},void 0).then(({default:n})=>n(...r)):e=fetch,(...r)=>e(...r)},Rze=t=>typeof t=="object"&&t!==null&&"status"in t&&"ok"in t&&"json"in t&&typeof t.json=="function",vye=async(t,e,r)=>{await t.setItem(e,JSON.stringify(r))},gR=async(t,e)=>{const r=await t.getItem(e);if(!r)return null;try{return JSON.parse(r)}catch{return r}},yR=async(t,e)=>{await t.removeItem(e)};class L3{constructor(){this.promise=new L3.promiseConstructor((e,r)=>{this.resolve=e,this.reject=r})}}L3.promiseConstructor=Promise;function G$(t){const e=t.split(".");if(e.length!==3)throw new mA("Invalid JWT structure");for(let n=0;n{setTimeout(()=>e(null),t)})}function Mze(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 Dze(t){return("0"+t.toString(16)).substr(-2)}function Oze(){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,Dze).join("")}async function Fze(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 Bze(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 Fze(t);return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function ww(t,e,r=!1){const n=Oze();let s=n;r&&(s+="/PASSWORD_RECOVERY"),await vye(t,`${e}-code-verifier`,s);const o=await Bze(n);return[o,n===o?"plain":"s256"]}const $ze=/^2[0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1])$/i;function zze(t){const e=t.headers.get(zV);if(!e||!e.match($ze))return null;try{return new Date(`${e}T00:00:00.0Z`)}catch{return null}}function Uze(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 Vze(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 qze=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),Gze=[502,503,504];async function ore(t){var e;if(!Rze(t))throw new UV(_v(t),0);if(Gze.includes(t.status))throw new UV(_v(t),t.status);let r;try{r=await t.json()}catch(o){throw new gye(_v(o),o)}let n;const s=zze(t);if(s&&s.getTime()>=pye["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 nre(_v(r),t.status,((e=r.weak_password)===null||e===void 0?void 0:e.reasons)||[]);if(n==="session_not_found")throw new Sy}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 nre(_v(r),t.status,r.weak_password.reasons);throw new _ze(_v(r),t.status||500,n)}const Hze=(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 Js(t,e,r,n){var s;const o=Object.assign({},n==null?void 0:n.headers);o[zV]||(o[zV]=pye["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 Wze(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 Wze(t,e,r,n,s,o){const c=Hze(e,n,s,o);let a;try{a=await t(r,Object.assign({},c))}catch(f){throw console.error(f),new UV(_v(f),0)}if(a.ok||await ore(a),n!=null&&n.noResolveJson)return a;try{return await a.json()}catch(f){await ore(f)}}function Ty(t){var e;let r=null;Xze(t)&&(r=Object.assign({},t),t.expires_at||(r.expires_at=Cze(t.expires_in)));const n=(e=t.user)!==null&&e!==void 0?e:t;return{data:{session:r,user:n},error:null}}function lre(t){const e=Ty(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 Dy(t){var e;return{data:{user:(e=t.user)!==null&&e!==void 0?e:t},error:null}}function Kze(t){return{data:t,error:null}}function Yze(t){const{action_link:e,email_otp:r,hashed_token:n,redirect_to:s,verification_type:o}=t,c=qze(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 Zze(t){return t}function Xze(t){return t.access_token&&t.refresh_token&&t.expires_in}var Qze=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(k=>{const R=parseInt(k.split(";")[0].split("=")[1].substring(0,1)),P=JSON.parse(k.split(";")[1].split("=")[1]);p[`${P}Page`]=R}),p.total=parseInt(S)),{data:Object.assign(Object.assign({},v),p),error:null}}catch(p){if(Bs(p))return{data:{users:[]},error:p};throw p}}async getUserById(e){try{return await Js(this.fetch,"GET",`${this.url}/admin/users/${e}`,{headers:this.headers,xform:Dy})}catch(r){if(Bs(r))return{data:{user:null},error:r};throw r}}async updateUserById(e,r){try{return await Js(this.fetch,"PUT",`${this.url}/admin/users/${e}`,{body:r,headers:this.headers,xform:Dy})}catch(n){if(Bs(n))return{data:{user:null},error:n};throw n}}async deleteUser(e,r=!1){try{return await Js(this.fetch,"DELETE",`${this.url}/admin/users/${e}`,{headers:this.headers,body:{should_soft_delete:r},xform:Dy})}catch(n){if(Bs(n))return{data:{user:null},error:n};throw n}}async _listFactors(e){try{const{data:r,error:n}=await Js(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(Bs(r))return{data:null,error:r};throw r}}async _deleteFactor(e){try{return{data:await Js(this.fetch,"DELETE",`${this.url}/admin/users/${e.userId}/factors/${e.id}`,{headers:this.headers}),error:null}}catch(r){if(Bs(r))return{data:null,error:r};throw r}}}const e6e={getItem:t=>pA()?globalThis.localStorage.getItem(t):null,setItem:(t,e)=>{pA()&&globalThis.localStorage.setItem(t,e)},removeItem:t=>{pA()&&globalThis.localStorage.removeItem(t)}};function cre(t={}){return{getItem:e=>t[e]||null,setItem:(e,r)=>{t[e]=r},removeItem:e=>{delete t[e]}}}function t6e(){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 Sw={debug:!!(globalThis&&pA()&&globalThis.localStorage&&globalThis.localStorage.getItem("supabase.gotrue-js.locks.debug")==="true")};class _ye extends Error{constructor(e){super(e),this.isAcquireTimeout=!0}}class r6e extends _ye{}async function n6e(t,e,r){Sw.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquire lock",t,e);const n=new globalThis.AbortController;return e>0&&setTimeout(()=>{n.abort(),Sw.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){Sw.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquired",t,s.name);try{return await r()}finally{Sw.debug&&console.log("@supabase/gotrue-js: navigatorLock: released",t,s.name)}}else{if(e===0)throw Sw.debug&&console.log("@supabase/gotrue-js: navigatorLock: not immediately available",t),new r6e(`Acquiring an exclusive Navigator LockManager lock "${t}" immediately failed`);if(Sw.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()}}))}t6e();const s6e={url:pze,storageKey:gze,autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:yze,flowType:"implicit",debug:!1,hasCustomAuthorizationHeader:!1};async function ure(t,e,r){return await r()}class lk{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=lk.nextInstanceID,lk.nextInstanceID+=1,this.instanceID>0&&Jf()&&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({},s6e),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 Jze({url:s.url,headers:s.headers,fetch:s.fetch}),this.url=s.url,this.headers=s.headers,this.fetch=xye(s.fetch),this.lock=s.lock||ure,this.detectSessionInUrl=s.detectSessionInUrl,this.flowType=s.flowType,this.hasCustomAuthorizationHeader=s.hasCustomAuthorizationHeader,s.lock?this.lock=s.lock:Jf()&&(!((r=globalThis==null?void 0:globalThis.navigator)===null||r===void 0)&&r.locks)?this.lock=n6e:this.lock=ure,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:pA()?this.storage=e6e:(this.memoryStorage={},this.storage=cre(this.memoryStorage)):(this.memoryStorage={},this.storage=cre(this.memoryStorage)),Jf()&&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} (${mye}) ${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=Pze(window.location.href);let n="none";if(this._isImplicitGrantCallback(r)?n="implicit":await this._isPKCECallback(r)&&(n="pkce"),Jf()&&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),Sze(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 Bs(r)?{error:r}:{error:new gye("Unexpected error during initialization",r)}}finally{await this._handleVisibilityChange(),this._debug("#_initialize()","end")}}async signInAnonymously(e){var r,n,s;try{const o=await Js(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:Ty}),{data:c,error:a}=o;if(a||!c)return{data:{user:null,session:null},error:a};const f=c.session,p=c.user;return c.session&&(await this._saveSession(c.session),await this._notifyAllSubscribers("SIGNED_IN",f)),{data:{user:p,session:f},error:null}}catch(o){if(Bs(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:v,options:S}=e;let E=null,k=null;this.flowType==="pkce"&&([E,k]=await ww(this.storage,this.storageKey)),o=await Js(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,redirectTo:S==null?void 0:S.emailRedirectTo,body:{email:y,password:v,data:(r=S==null?void 0:S.data)!==null&&r!==void 0?r:{},gotrue_meta_security:{captcha_token:S==null?void 0:S.captchaToken},code_challenge:E,code_challenge_method:k},xform:Ty})}else if("phone"in e){const{phone:y,password:v,options:S}=e;o=await Js(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{phone:y,password:v,data:(n=S==null?void 0:S.data)!==null&&n!==void 0?n:{},channel:(s=S==null?void 0:S.channel)!==null&&s!==void 0?s:"sms",gotrue_meta_security:{captcha_token:S==null?void 0:S.captchaToken}},xform:Ty})}else throw new mR("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,p=c.user;return c.session&&(await this._saveSession(c.session),await this._notifyAllSubscribers("SIGNED_IN",f)),{data:{user:p,session:f},error:null}}catch(o){if(Bs(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 Js(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:lre})}else if("phone"in e){const{phone:o,password:c,options:a}=e;r=await Js(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:lre})}else throw new mR("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 V$}:(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(Bs(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 gR(this.storage,`${this.storageKey}-code-verifier`),[n,s]=(r??"").split("/");try{const{data:o,error:c}=await Js(this.fetch,"POST",`${this.url}/token?grant_type=pkce`,{headers:this.headers,body:{auth_code:e,code_verifier:n},xform:Ty});if(await yR(this.storage,`${this.storageKey}-code-verifier`),c)throw c;return!o||!o.session||!o.user?{data:{user:null,session:null,redirectType:null},error:new V$}:(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(Bs(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 Js(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:Ty}),{data:f,error:p}=a;return p?{data:{user:null,session:null},error:p}:!f||!f.session||!f.user?{data:{user:null,session:null},error:new V$}:(f.session&&(await this._saveSession(f.session),await this._notifyAllSubscribers("SIGNED_IN",f.session)),{data:f,error:p})}catch(r){if(Bs(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 p=null,y=null;this.flowType==="pkce"&&([p,y]=await ww(this.storage,this.storageKey));const{error:v}=await Js(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:p,code_challenge_method:y},redirectTo:f==null?void 0:f.emailRedirectTo});return{data:{user:null,session:null},error:v}}if("phone"in e){const{phone:a,options:f}=e,{data:p,error:y}=await Js(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:p==null?void 0:p.message_id},error:y}}throw new mR("You must provide either an email or phone number.")}catch(a){if(Bs(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 Js(this.fetch,"POST",`${this.url}/verify`,{headers:this.headers,body:Object.assign(Object.assign({},e),{gotrue_meta_security:{captcha_token:o}}),redirectTo:s,xform:Ty});if(a)throw a;if(!c)throw new Error("An error occurred on token verification.");const f=c.session,p=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:p,session:f},error:null}}catch(s){if(Bs(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 ww(this.storage,this.storageKey)),await Js(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:Kze})}catch(o){if(Bs(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 Sy;const{error:s}=await Js(this.fetch,"GET",`${this.url}/reauthenticate`,{headers:this.headers,jwt:r.access_token});return{data:{user:null,session:null},error:s}})}catch(e){if(Bs(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 Js(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 Js(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 mR("You must provide either an email or phone number and a type")}catch(r){if(Bs(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 gR(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&&p==="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,p,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 Js(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:e,xform:Dy}):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 Sy}:await Js(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:Dy})})}catch(r){if(Bs(r))return wze(r)&&(await this._removeSession(),await yR(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 Sy;const c=s.session;let a=null,f=null;this.flowType==="pkce"&&e.email!=null&&([a,f]=await ww(this.storage,this.storageKey));const{data:p,error:y}=await Js(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:Dy});if(y)throw y;return c.user=p.user,await this._saveSession(c),await this._notifyAllSubscribers("USER_UPDATED",c),{data:{user:c.user},error:null}})}catch(n){if(Bs(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 Sy;const r=Date.now()/1e3;let n=r,s=!0,o=null;const{payload:c}=G$(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(Bs(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 Sy;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(Bs(r))return{data:{user:null,session:null},error:r};throw r}}async _getSessionFromURL(e,r){try{if(!Jf())throw new pR("No browser detected.");if(e.error||e.error_description||e.error_code)throw new pR(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 rre("Not a valid PKCE flow url.");break;case"pkce":if(this.flowType==="implicit")throw new pR("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 rre("No code detected.");const{data:D,error:B}=await this._exchangeCodeForSession(e.code);if(B)throw B;const V=new URL(window.location.href);return V.searchParams.delete("code"),window.history.replaceState(window.history.state,"",V.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:p}=e;if(!o||!a||!c||!p)throw new pR("No session defined in URL");const y=Math.round(Date.now()/1e3),v=parseInt(a);let S=y+v;f&&(S=parseInt(f));const E=S-y;E*1e3<=Gw&&console.warn(`@supabase/gotrue-js: Session as retrieved from URL expires in ${E}s, should have been closer to ${v}s`);const k=S-v;y-k>=120?console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued over 120s ago, URL could be stale",k,S,y):y-k<0&&console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued in the future? Check the device clock for skew",k,S,y);const{data:R,error:P}=await this._getUser(o);if(P)throw P;const M={provider_token:n,provider_refresh_token:s,access_token:o,expires_in:v,expires_at:S,refresh_token:c,token_type:p,user:R.user};return window.location.hash="",this._debug("#_getSessionFromURL()","clearing window.location.hash"),{data:{session:M,redirectType:e.type},error:null}}catch(n){if(Bs(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 gR(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&&!(bze(a)&&(a.status===404||a.status===401||a.status===403)))return{error:a}}return e!=="others"&&(await this._removeSession(),await yR(this.storage,`${this.storageKey}-code-verifier`)),{error:null}})}onAuthStateChange(e){const r=Ize(),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 ww(this.storage,this.storageKey,!0));try{return await Js(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(Bs(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(Bs(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,p,y;const{data:v,error:S}=o;if(S)throw S;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 Js(this.fetch,"GET",E,{headers:this.headers,jwt:(y=(p=v.session)===null||p===void 0?void 0:p.access_token)!==null&&y!==void 0?y:void 0})});if(s)throw s;return Jf()&&!(!((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(Bs(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 Js(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(Bs(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 Mze(async s=>(s>0&&await Lze(200*Math.pow(2,s-1)),this._debug(r,"refreshing attempt",s),await Js(this.fetch,"POST",`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:e},headers:this.headers,xform:Ty})),(s,o)=>{const c=200*Math.pow(2,s);return o&&q$(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(),Gw);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)/Gw);this._debug("#_autoRefreshTokenTick()",`access token expires in ${s} ticks, a tick lasts ${Gw}ms, refresh threshold is ${$V} ticks`),s<=$V&&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 _ye)this._debug("auto refresh token tick lock not available");else throw e}}async _handleVisibilityChange(){if(this._debug("#_handleVisibilityChange()"),!Jf()||!(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 ww(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 Js(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(Bs(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:p}=await Js(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 p?{data:null,error:p}:(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(Bs(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 Js(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(Bs(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 Js(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(Bs(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}=G$(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(v=>v.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+vze>Date.now()))return n;const{data:s,error:o}=await Js(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 mA("JWKS is empty");if(this.jwks=s,this.jwks_cached_at=Date.now(),n=s.keys.find(c=>c.kid===e),!n)throw new mA("No matching signing key found in JWKS");return n}async getClaims(e,r={keys:[]}){try{let n=e;if(!n){const{data:E,error:k}=await this.getSession();if(k||!E.session)return{data:null,error:k};n=E.session.access_token}const{header:s,payload:o,signature:c,raw:{header:a,payload:f}}=G$(n);if(Uze(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 p=Vze(s.alg),y=await this.fetchJwk(s.kid,r),v=await crypto.subtle.importKey("jwk",y,p,!0,["verify"]);if(!await crypto.subtle.verify(p,v,c,Nze(`${a}.${f}`)))throw new mA("Invalid JWT signature");return{data:{claims:o,header:s,signature:c},error:null}}catch(n){if(Bs(n))return{data:null,error:n};throw n}}}lk.nextInstanceID=0;const i6e=lk;class a6e extends i6e{constructor(e){super(e)}}var o6e=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{p(n.next(y))}catch(v){c(v)}}function f(y){try{p(n.throw(y))}catch(v){c(v)}}function p(y){y.done?o(y.value):s(y.value).then(a,f)}p((n=n.apply(t,e||[])).next())})};class l6e{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=fze(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 p=`sb-${f.hostname.split(".")[0]}-auth-token`,y={db:ize,realtime:oze,auth:Object.assign(Object.assign({},aze),{storageKey:p}),global:sze},v=mze(n??{},y);this.storageKey=(s=v.auth.storageKey)!==null&&s!==void 0?s:"",this.headers=(o=v.global.headers)!==null&&o!==void 0?o:{},v.accessToken?(this.accessToken=v.accessToken,this.auth=new Proxy({},{get:(S,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=v.auth)!==null&&c!==void 0?c:{},this.headers,v.global.fetch),this.fetch=dze(r,this._getAccessToken.bind(this),v.global.fetch),this.realtime=this._initRealtimeClient(Object.assign({headers:this.headers,accessToken:this._getAccessToken.bind(this)},v.realtime)),this.rest=new A$e(new URL("rest/v1",f).href,{headers:this.headers,schema:v.db.schema,fetch:this.fetch}),v.accessToken||this._listenForAuthEvents()}get functions(){return new n$e(this.functionsUrl.href,{headers:this.headers,customFetch:this.fetch})}get storage(){return new tze(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 o6e(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},p,y){const v={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new a6e({url:this.authUrl.href,headers:Object.assign(Object.assign({},v),p),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 z$e(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 c6e=(t,e,r)=>new l6e(t,e,r),u6e="lovable-preview-auth:result";function d6e(t,e){return typeof t!="object"||t===null||!("type"in t)||t.type!==u6e||!("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 h6e(){var D,B,V;if(typeof window>"u")return;const t=location.hostname,r=["lovableproject.com","lovableproject-dev.com","lovable.app","gpt-eng.com","gptengineer.run"].some(G=>t===G||t.endsWith("."+G)),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])??((V=new RegExp("^("+n+")(?=[.-])","i").exec(t))==null?void 0:V[1]):void 0,o=window.parent;if(!s||!(o!==null&&o!==window))return localStorage;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)$/,p=location.ancestorOrigins,y=(p==null?void 0:p[0])??(document.referrer?new URL(document.referrer).origin:""),v=y&&f.test(y)?[y]:a?["https://lovable.dev","http://localhost:3000"]:["https://lovable.dev"],S=2e3,E=()=>Math.random().toString(36).slice(2)+Date.now().toString(36),k=(G,W,Y)=>new Promise(J=>{const Q=E();let ee=!1;const le=Le=>{ee||(ee=!0,clearTimeout(Te),window.removeEventListener("message",pe),J(Le))},pe=Le=>{if(!v.includes(Le.origin))return;const ke=d6e(Le.data,Q);ke&&le(ke)};window.addEventListener("message",pe);const Te=setTimeout(()=>{le(null)},S),Ae={type:G,requestId:Q,projectId:s,key:W};Y!==void 0&&(Ae.value=Y);for(const Le of v)window.parent.postMessage(Ae,Le)});let R=!0;const P=250,M=G=>{try{return localStorage.getItem(G)}catch{return}};return{getItem:async G=>{const W=M(G);let Y=await k("lovable-preview-auth:get",G,W??void 0);if(!Y&&R&&(await new Promise(J=>setTimeout(J,P)),Y=await k("lovable-preview-auth:get",G,W??void 0)),R=!1,Y!=null&&Y.ok&&Y.value!==null){if(Y.value==="")return W!==void 0&&M(G)===W&&localStorage.removeItem(G),null;if(W===null&&M(G)===null)try{localStorage.setItem(G,Y.value)}catch{}return Y.value}return localStorage.getItem(G)},setItem:(G,W)=>(localStorage.setItem(G,W),k("lovable-preview-auth:set",G,W).then(Y=>{Y!=null&&Y.ok&&Y.value!==null&&localStorage.getItem(G)===W&&(Y.value===""?localStorage.removeItem(G):localStorage.setItem(G,Y.value))})),removeItem:G=>{const W=M(G);return localStorage.removeItem(G),k("lovable-preview-auth:remove",G,W??void 0).then(()=>{})}}}const f6e="https://relzejiswnotikjgvjhz.supabase.co",m6e="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InJlbHplamlzd25vdGlramd2amh6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjE5NTAzNDQsImV4cCI6MjA3NzUyNjM0NH0.dzIkIr_oFSbFE3oWS0ktIr83iKHHkZxt40Gc7SpC_mM",Re=c6e(f6e,m6e,{auth:{storage:h6e(),persistSession:!0,autoRefreshToken:!0}}),vGt=Object.freeze(Object.defineProperty({__proto__:null,supabase:Re},Symbol.toStringTag,{value:"Module"})),bye=N.createContext(void 0),p6e=({children:t})=>{const[e,r]=N.useState(null),[n,s]=N.useState(null),[o,c]=N.useState(!0),[a,f]=N.useState(!0),[p,y]=N.useState(!1),[v,S]=N.useState(!1),[E,k]=N.useState(!1),[R,P]=N.useState(null),[M,D]=N.useState([]),[B,V]=N.useState(null),G=N.useRef(null),W=N.useRef(!1),Y=N.useRef(!1),J=Wi(),Q=()=>{y(!1),S(!1),k(!1),P(null),D([]),V(null),G.current=null,W.current=!1},ee=async Ae=>{if(W.current&&G.current===Ae||Y.current)return;Y.current=!0,f(!0);const Le=window.setTimeout(()=>{console.warn("Role check timeout reached — unblocking UI."),Y.current=!1,f(!1)},8e3);try{console.log("Checking roles via RPC for user:",Ae);const[{data:ke,error:we},{data:me,error:je},{data:_e,error:Ee}]=await Promise.all([Re.rpc("has_role",{_user_id:Ae,_role:"admin"}),Re.rpc("has_role",{_user_id:Ae,_role:"brokerage_manager"}),Re.rpc("has_role",{_user_id:Ae,_role:"coach"})]);if(we||je)console.error("Role RPC errors:",{isAdminError:we,isBrokerError:je,isCoachError:Ee}),y(!1),S(!1),k(!1);else{const nt=!!ke,ot=!!me,jt=!!_e;console.log("RPC roles result:",{adminValue:nt,brokerValue:ot,coachValue:jt}),y(nt),S(ot),k(jt)}G.current=Ae,W.current=!0,window.clearTimeout(Le),f(!1);const{data:ve,error:qe}=await Re.from("profiles").select("brokerage_id, is_paused, paused_reason").eq("id",Ae).single();if(!qe&&(ve!=null&&ve.is_paused)){const nt=ve.paused_reason;try{sessionStorage.setItem("accountPausedReason",nt||"")}catch{}await Re.auth.signOut(),Q(),J("/auth?paused=1",{replace:!0});return}if(P(!qe&&ve?ve.brokerage_id:null),me){console.log("Fetching managed brokerages for user:",Ae);const{data:nt,error:ot}=await Re.from("brokerage_manager_assignments").select("brokerage_id").eq("user_id",Ae);if(console.log("Managed brokerage assignments result:",{assignments:nt,assignmentsError:ot}),ot||!nt){console.error("Error fetching managed brokerage assignments:",ot),D([]);return}const jt=Array.from(new Set(nt.map(Ct=>Ct.brokerage_id).filter(Boolean)));if(jt.length===0){D([]);return}const{data:vt,error:Gt}=await Re.from("brokerages").select("id, name").in("id",jt);if(console.log("Managed brokerages details result:",{brokeragesData:vt,brokeragesError:Gt}),Gt||!vt){console.error("Error fetching managed brokerages details:",Gt),D([]);return}const pt=vt.map(Ct=>({id:Ct.id,name:Ct.name})).sort((Ct,tr)=>jt.indexOf(Ct.id)-jt.indexOf(tr.id));console.log("Parsed managed brokerages:",pt),D(pt),pt.length>0&&V(Ct=>Ct??pt[0].id)}else console.log("User is not a brokerage manager, skipping managed brokerages fetch"),D([]);G.current=Ae,W.current=!0}catch(ke){console.error("Unexpected error in checkRoles:",ke),Q()}finally{window.clearTimeout(Le),Y.current=!1,f(!1)}};N.useEffect(()=>{let Ae=!0,Le=!1;const ke=()=>{!Ae||Le||(Le=!0,c(!1))},{data:{subscription:we}}=Re.auth.onAuthStateChange((je,_e)=>{console.log("Auth event:",je),Ae&&(s(_e),r((_e==null?void 0:_e.user)??null),ke(),je==="PASSWORD_RECOVERY"&&(console.log("Password recovery detected, redirecting to profile"),setTimeout(()=>{J("/profile?reset=true")},100)),_e!=null&&_e.user?(!W.current||G.current!==_e.user.id)&&setTimeout(()=>{ee(_e.user.id)},0):(Q(),f(!1)))}),me=window.setTimeout(()=>{console.warn("Auth initialization timeout reached. Continuing without blocking UI."),ke()},8e3);return()=>{Ae=!1,window.clearTimeout(me),we.unsubscribe()}},[]);const le=async(Ae,Le)=>{var je;const ke=(Ae||"").trim().toLowerCase(),{data:we,error:me}=await Re.auth.signInWithPassword({email:ke,password:Le});if(me)throw $t.error(/invalid login credentials/i.test(me.message)?`That email and password don't match an account. Check the email address, or use "Forgot password" to set a new password.`:me.message),me;if((je=we.user)!=null&&je.id){const{data:_e}=await Re.from("profiles").select("is_paused, paused_reason").eq("id",we.user.id).maybeSingle();if(_e!=null&&_e.is_paused){const Ee=_e.paused_reason||"";try{sessionStorage.setItem("accountPausedReason",Ee)}catch{}await Re.auth.signOut(),Q(),r(null),s(null);const ve=new Error(Ee?`Your account is paused. ${Ee}`:"Your account is paused. Please contact LevelUp support to reactivate it.");throw ve.name="AccountPaused",$t.error(ve.message),ve}}$t.success("Welcome back!")},pe=async(Ae,Le,ke)=>{var Ee;const we="https://dashboard.relevelup.com/dashboard",me=localStorage.getItem("levelup_referral_code")||null,{data:je,error:_e}=await Re.auth.signUp({email:Ae,password:Le,options:{emailRedirectTo:we,data:{name:ke,referred_by_code:me}}});if(_e)throw $t.error(_e.message),_e;if(me&&((Ee=je.user)!=null&&Ee.id))try{await Re.from("profiles").update({referred_by_code:me}).eq("id",je.user.id),localStorage.removeItem("levelup_referral_code")}catch(ve){console.warn("Failed to attach referral code to profile",ve)}$t.success("Account created! Welcome to LevelUp."),J("/dashboard")},Te=async()=>{try{const{data:{session:Ae}}=await Re.auth.getSession();if(Ae){const{error:Le}=await Re.auth.signOut();Le?Le.message==="Auth session missing!"?console.warn("Sign out warning (ignored):",Le.message):(console.error("Sign out error:",Le),$t.error(Le.message)):$t.success("Signed out successfully")}else console.log("No active session found, redirecting to auth");r(null),s(null),y(!1),S(!1),P(null),D([]),V(null),J("/auth")}catch(Ae){console.error("Unexpected sign out error:",Ae),J("/auth")}};return i.jsx(bye.Provider,{value:{user:e,session:n,loading:o,rolesLoading:a,signIn:le,signUp:pe,signOut:Te,isAdmin:p,isBrokerageManager:v,isCoach:E,brokerageId:R,managedBrokerages:M,selectedBrokerageId:B,setSelectedBrokerageId:V},children:t})},Wn=()=>{const t=N.useContext(bye);if(t===void 0)throw new Error("useAuth must be used within an AuthProvider");return t},wye=N.createContext({onlineUsers:[],totalOnline:0}),g6e=3*60*1e3,y6e=45*1e3,x6e=30*1e3,v6e=({children:t})=>{const{user:e,brokerageId:r,isAdmin:n}=Wn(),[s,o]=N.useState([]),c=N.useRef(new Date().toISOString()),a=N.useCallback(async()=>{e&&await Re.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()-g6e).toISOString(),{data:v}=await Re.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(!(v!=null&&v.length)){o([]);return}const S=v.map(R=>R.user_id),{data:E}=await Re.from("profiles").select("id, name, email, avatar_url, brokerage_id").in("id",S),k=new Map((E||[]).map(R=>[R.id,R]));o(v.map(R=>{var M;const P=k.get(R.user_id);return{id:R.user_id,name:(P==null?void 0:P.name)||((M=P==null?void 0:P.email)==null?void 0:M.split("@")[0])||"Member",avatarUrl:(P==null?void 0:P.avatar_url)||void 0,brokerageId:(P==null?void 0:P.brokerage_id)||void 0,onlineSince:R.online_since||R.last_seen_at}}))},[e==null?void 0:e.id]);N.useEffect(()=>{if(!e){o([]);return}c.current=new Date().toISOString();let y=!1;const v=async()=>{y||(await a(),await f())};v();const S=window.setInterval(()=>{a()},y6e),E=window.setInterval(()=>{f()},x6e),k=()=>{document.visibilityState==="visible"&&v()};return document.addEventListener("visibilitychange",k),()=>{y=!0,window.clearInterval(S),window.clearInterval(E),document.removeEventListener("visibilitychange",k)}},[e==null?void 0:e.id,a,f]);const p=s.filter(y=>!!(y.id===(e==null?void 0:e.id)||n||r&&y.brokerageId===r||!r&&!y.brokerageId));return i.jsx(wye.Provider,{value:{onlineUsers:p,totalOnline:p.length},children:t})},_Gt=()=>N.useContext(wye),Sye=N.createContext(void 0),lv="levelup_admin_session",py="levelup_impersonation",H$="levelup_impersonation_return",_6e=({children:t})=>{const[e,r]=N.useState(!1),[n,s]=N.useState(null),[o,c]=N.useState(!1);N.useEffect(()=>{const p=sessionStorage.getItem(py);if(p)try{const y=JSON.parse(p);r(!0),s(y)}catch{sessionStorage.removeItem(py)}},[]);const a=async(p,y)=>{c(!0);try{const{data:{session:v}}=await Re.auth.getSession();if(!v)return $t.error("No active session found"),!1;const S={access_token:v.access_token,refresh_token:v.refresh_token};sessionStorage.setItem(lv,JSON.stringify(S)),y&&sessionStorage.setItem(H$,y);const E=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/impersonate-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${v.access_token}`},body:JSON.stringify({targetUserId:p})}),k=await E.json();if(!E.ok)throw new Error(k.error||"Failed to impersonate user");const R={id:k.targetUser.id,name:k.targetUser.name,email:k.targetUser.email};if(sessionStorage.setItem(py,JSON.stringify(R)),k.method==="session"){const{error:P}=await Re.auth.setSession({access_token:k.access_token,refresh_token:k.refresh_token});if(P)throw console.error("Set session error:",P),sessionStorage.removeItem(lv),sessionStorage.removeItem(py),new Error("Failed to establish impersonation session")}else{const P=k.type||"recovery",{error:M}=await Re.auth.verifyOtp({token_hash:k.token_hash,type:P});if(M)throw console.error("Verify OTP error:",M),sessionStorage.removeItem(lv),sessionStorage.removeItem(py),new Error("Failed to establish impersonation session")}return r(!0),s(R),$t.success(`Now viewing as ${R.name}`),window.location.href="/dashboard",!0}catch(v){return console.error("Impersonation error:",v),$t.error(v.message||"Failed to impersonate user"),sessionStorage.removeItem(lv),sessionStorage.removeItem(py),!1}finally{c(!1)}},f=async()=>{c(!0);try{const p=sessionStorage.getItem(lv);if(!p){await Re.auth.signOut(),window.location.href="/auth";return}const y=JSON.parse(p);await Re.auth.signOut();const{error:v}=await Re.auth.setSession({access_token:y.access_token,refresh_token:y.refresh_token});if(sessionStorage.removeItem(lv),sessionStorage.removeItem(py),v){console.error("Failed to restore admin session:",v),$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 S=sessionStorage.getItem(H$)||"/admin/members";sessionStorage.removeItem(H$),window.location.href=S}catch(p){console.error("Stop impersonation error:",p),$t.error("Failed to restore admin session"),sessionStorage.removeItem(lv),sessionStorage.removeItem(py),window.location.href="/auth"}finally{c(!1)}};return i.jsx(Sye.Provider,{value:{isImpersonating:e,impersonatedUser:n,startImpersonation:a,stopImpersonation:f,isLoading:o},children:t})},Tye=()=>{const t=N.useContext(Sye);if(t===void 0)throw new Error("useImpersonation must be used within an ImpersonationProvider");return t},b6e=()=>{const{isImpersonating:t,impersonatedUser:e,stopImpersonation:r,isLoading:n}=Tye();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(lT,{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(Dt,{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(jc,{className:"h-4 w-4 animate-spin"}):i.jsxs(i.Fragment,{children:[i.jsx(ki,{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"})]})})]})})},Eye=N.createContext(void 0),Tw="levelup_acting_as",xR="levelup_acting_as_self",w6e=({children:t})=>{const{user:e}=Wn(),[r,n]=N.useState(!1),[s,o]=N.useState([]),[c,a]=N.useState(null),[f,p]=N.useState({}),[y,v]=N.useState(!0),[S,E]=N.useState(()=>sessionStorage.getItem(xR)==="true");N.useEffect(()=>{if(!(e!=null&&e.id)){n(!1),o([]),a(null),p({}),v(!1);return}(async()=>{v(!0);try{const{data:B}=await Re.rpc("has_role",{_user_id:e.id,_role:"assistant"});if(!B){n(!1),o([]),a(null),p({}),v(!1);return}n(!0);const{data:V,error:G}=await Re.from("agent_assistant_assignments").select("agent_id, permissions").eq("assistant_id",e.id);if(G||!V||V.length===0){o([]),v(!1);return}const W=V.map(Q=>Q.agent_id),{data:Y}=await Re.from("profiles").select("id, name, email, avatar_url").in("id",W),J=(Y||[]).map(Q=>({id:Q.id,name:Q.name||Q.email||"Unknown",email:Q.email||"",avatar_url:Q.avatar_url}));if(o(J),sessionStorage.getItem(xR)==="true")E(!0),a(null),p({});else{const Q=sessionStorage.getItem(Tw);if(Q){const ee=J.find(le=>le.id===Q);if(ee){a(ee);const le=V.find(pe=>pe.agent_id===Q);p((le==null?void 0:le.permissions)||{})}else if(J.length>0){a(J[0]);const le=V.find(pe=>pe.agent_id===J[0].id);p((le==null?void 0:le.permissions)||{}),sessionStorage.setItem(Tw,J[0].id)}}else if(J.length>0){a(J[0]);const ee=V.find(le=>le.agent_id===J[0].id);p((ee==null?void 0:ee.permissions)||{}),sessionStorage.setItem(Tw,J[0].id)}}}catch(B){console.error("Error loading assistant data:",B)}finally{v(!1)}})()},[e==null?void 0:e.id]);const k=D=>{a(D),E(!1),sessionStorage.removeItem(xR),D?(sessionStorage.setItem(Tw,D.id),Re.from("agent_assistant_assignments").select("permissions").eq("assistant_id",(e==null?void 0:e.id)||"").eq("agent_id",D.id).single().then(({data:B})=>{p((B==null?void 0:B.permissions)||{})})):(sessionStorage.removeItem(Tw),p({}))},R=()=>{E(!0),a(null),p({}),sessionStorage.setItem(xR,"true"),sessionStorage.removeItem(Tw)},P=D=>!r||S?!0:f[D]===!0,M=r&&c&&!S?c.id:(e==null?void 0:e.id)||null;return i.jsx(Eye.Provider,{value:{isAssistant:r,assignedAgents:s,actingAsAgent:c,setActingAsAgent:k,effectiveUserId:M,permissions:f,hasPermission:P,isLoading:y,isActingAsSelf:S,setActingAsSelf:R},children:t})},M3=()=>{const t=N.useContext(Eye);if(t===void 0)throw new Error("useActingAs must be used within an ActingAsProvider");return t},Ls=()=>{const{effectiveUserId:t}=M3();return t};var jye={exports:{}},Aye={};/** * @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 gS=N;function S6e(t,e){return t===e&&(t!==0||1/t===1/e)||t!==t&&e!==e}var T6e=typeof Object.is=="function"?Object.is:S6e,E6e=gS.useState,j6e=gS.useEffect,A6e=gS.useLayoutEffect,k6e=gS.useDebugValue;function N6e(t,e){var r=e(),n=E6e({inst:{value:r,getSnapshot:e}}),s=n[0].inst,o=n[1];return A6e(function(){s.value=r,s.getSnapshot=e,W$(s)&&o({inst:s})},[t,r,e]),j6e(function(){return W$(s)&&o({inst:s}),t(function(){W$(s)&&o({inst:s})})},[t]),k6e(r),r}function W$(t){var e=t.getSnapshot;t=t.value;try{var r=e();return!T6e(t,r)}catch{return!0}}function C6e(t,e){return e()}var I6e=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?C6e:N6e;Aye.useSyncExternalStore=gS.useSyncExternalStore!==void 0?gS.useSyncExternalStore:I6e;jye.exports=Aye;var P6e=jye.exports;function R6e(){return P6e.useSyncExternalStore(L6e,()=>!0,()=>!1)}function L6e(){return()=>{}}var N7="Avatar",[M6e,bGt]=Jo(N7),[D6e,kye]=M6e(N7),Nye=N.forwardRef((t,e)=>{const{__scopeAvatar:r,...n}=t,[s,o]=N.useState("idle");return i.jsx(D6e,{scope:r,imageLoadingStatus:s,onImageLoadingStatusChange:o,children:i.jsx(nn.span,{...n,ref:e})})});Nye.displayName=N7;var Cye="AvatarImage",Iye=N.forwardRef((t,e)=>{const{__scopeAvatar:r,src:n,onLoadingStatusChange:s=()=>{},...o}=t,c=kye(Cye,r),a=O6e(n,o),f=_o(p=>{s(p),c.onImageLoadingStatusChange(p)});return Do(()=>{a!=="idle"&&f(a)},[a,f]),a==="loaded"?i.jsx(nn.img,{...o,ref:e,src:n}):null});Iye.displayName=Cye;var Pye="AvatarFallback",Rye=N.forwardRef((t,e)=>{const{__scopeAvatar:r,delayMs:n,...s}=t,o=kye(Pye,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(nn.span,{...s,ref:e}):null});Rye.displayName=Pye;function dre(t,e){return t?e?(t.src!==e&&(t.src=e),t.complete&&t.naturalWidth>0?"loaded":"loading"):"error":"idle"}function O6e(t,{referrerPolicy:e,crossOrigin:r}){const n=R6e(),s=N.useRef(null),o=n?(s.current||(s.current=new window.Image),s.current):null,[c,a]=N.useState(()=>dre(o,t));return Do(()=>{a(dre(o,t))},[o,t]),Do(()=>{const f=v=>()=>{a(v)};if(!o)return;const p=f("loaded"),y=f("error");return o.addEventListener("load",p),o.addEventListener("error",y),e&&(o.referrerPolicy=e),typeof r=="string"&&(o.crossOrigin=r),()=>{o.removeEventListener("load",p),o.removeEventListener("error",y)}},[o,r,e]),c}var Lye=Nye,Mye=Iye,Dye=Rye;const wd=N.forwardRef(({className:t,...e},r)=>i.jsx(Lye,{ref:r,className:qt("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",t),...e}));wd.displayName=Lye.displayName;const Sd=N.forwardRef(({className:t,...e},r)=>i.jsx(Mye,{ref:r,className:qt("aspect-square h-full w-full",t),...e}));Sd.displayName=Mye.displayName;const Td=N.forwardRef(({className:t,...e},r)=>i.jsx(Dye,{ref:r,className:qt("flex h-full w-full items-center justify-center rounded-full bg-muted",t),...e}));Td.displayName=Dye.displayName;const F6e=aT("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 ii({className:t,variant:e,...r}){return i.jsx("div",{className:qt(F6e({variant:e}),t),...r})}var B6e=N.createContext(void 0);function P_(t){const e=N.useContext(B6e);return t||e||"ltr"}var K$="rovingFocusGroup.onEntryFocus",$6e={bubbles:!1,cancelable:!0},zN="RovingFocusGroup",[VV,Oye,z6e]=EN(zN),[U6e,vT]=Jo(zN,[z6e]),[V6e,q6e]=U6e(zN),Fye=N.forwardRef((t,e)=>i.jsx(VV.Provider,{scope:t.__scopeRovingFocusGroup,children:i.jsx(VV.Slot,{scope:t.__scopeRovingFocusGroup,children:i.jsx(G6e,{...t,ref:e})})}));Fye.displayName=zN;var G6e=N.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:r,orientation:n,loop:s=!1,dir:o,currentTabStopId:c,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:f,onEntryFocus:p,preventScrollOnEntryFocus:y=!1,...v}=t,S=N.useRef(null),E=Zn(e,S),k=P_(o),[R,P]=_d({prop:c,defaultProp:a??null,onChange:f,caller:zN}),[M,D]=N.useState(!1),B=_o(p),V=Oye(r),G=N.useRef(!1),[W,Y]=N.useState(0);return N.useEffect(()=>{const J=S.current;if(J)return J.addEventListener(K$,B),()=>J.removeEventListener(K$,B)},[B]),i.jsx(V6e,{scope:r,orientation:n,dir:k,loop:s,currentTabStopId:R,onItemFocus:N.useCallback(J=>P(J),[P]),onItemShiftTab:N.useCallback(()=>D(!0),[]),onFocusableItemAdd:N.useCallback(()=>Y(J=>J+1),[]),onFocusableItemRemove:N.useCallback(()=>Y(J=>J-1),[]),children:i.jsx(nn.div,{tabIndex:M||W===0?-1:0,"data-orientation":n,...v,ref:E,style:{outline:"none",...t.style},onMouseDown:Fr(t.onMouseDown,()=>{G.current=!0}),onFocus:Fr(t.onFocus,J=>{const Q=!G.current;if(J.target===J.currentTarget&&Q&&!M){const ee=new CustomEvent(K$,$6e);if(J.currentTarget.dispatchEvent(ee),!ee.defaultPrevented){const le=V().filter(ke=>ke.focusable),pe=le.find(ke=>ke.active),Te=le.find(ke=>ke.id===R),Le=[pe,Te,...le].filter(Boolean).map(ke=>ke.ref.current);zye(Le,y)}}G.current=!1}),onBlur:Fr(t.onBlur,()=>D(!1))})})}),Bye="RovingFocusGroupItem",$ye=N.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:r,focusable:n=!0,active:s=!1,tabStopId:o,children:c,...a}=t,f=Fl(),p=o||f,y=q6e(Bye,r),v=y.currentTabStopId===p,S=Oye(r),{onFocusableItemAdd:E,onFocusableItemRemove:k,currentTabStopId:R}=y;return N.useEffect(()=>{if(n)return E(),()=>k()},[n,E,k]),i.jsx(VV.ItemSlot,{scope:r,id:p,focusable:n,active:s,children:i.jsx(nn.span,{tabIndex:v?0:-1,"data-orientation":y.orientation,...a,ref:e,onMouseDown:Fr(t.onMouseDown,P=>{n?y.onItemFocus(p):P.preventDefault()}),onFocus:Fr(t.onFocus,()=>y.onItemFocus(p)),onKeyDown:Fr(t.onKeyDown,P=>{if(P.key==="Tab"&&P.shiftKey){y.onItemShiftTab();return}if(P.target!==P.currentTarget)return;const M=K6e(P,y.orientation,y.dir);if(M!==void 0){if(P.metaKey||P.ctrlKey||P.altKey||P.shiftKey)return;P.preventDefault();let B=S().filter(V=>V.focusable).map(V=>V.ref.current);if(M==="last")B.reverse();else if(M==="prev"||M==="next"){M==="prev"&&B.reverse();const V=B.indexOf(P.currentTarget);B=y.loop?Y6e(B,V+1):B.slice(V+1)}setTimeout(()=>zye(B))}}),children:typeof c=="function"?c({isCurrentTabStop:v,hasTabStop:R!=null}):c})})});$ye.displayName=Bye;var H6e={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function W6e(t,e){return e!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function K6e(t,e,r){const n=W6e(t.key,r);if(!(e==="vertical"&&["ArrowLeft","ArrowRight"].includes(n))&&!(e==="horizontal"&&["ArrowUp","ArrowDown"].includes(n)))return H6e[n]}function zye(t,e=!1){const r=document.activeElement;for(const n of t)if(n===r||(n.focus({preventScroll:e}),document.activeElement!==r))return}function Y6e(t,e){return t.map((r,n)=>t[(e+n)%t.length])}var C7=Fye,I7=$ye,qV=["Enter"," "],Z6e=["ArrowDown","PageUp","Home"],Uye=["ArrowUp","PageDown","End"],X6e=[...Z6e,...Uye],Q6e={ltr:[...qV,"ArrowRight"],rtl:[...qV,"ArrowLeft"]},J6e={ltr:["ArrowLeft"],rtl:["ArrowRight"]},UN="Menu",[ck,eUe,tUe]=EN(UN),[R_,Vye]=Jo(UN,[tUe,Ox,vT]),D3=Ox(),qye=vT(),[rUe,L_]=R_(UN),[nUe,VN]=R_(UN),Gye=t=>{const{__scopeMenu:e,open:r=!1,children:n,dir:s,onOpenChange:o,modal:c=!0}=t,a=D3(e),[f,p]=N.useState(null),y=N.useRef(!1),v=_o(o),S=P_(s);return N.useEffect(()=>{const E=()=>{y.current=!0,document.addEventListener("pointerdown",k,{capture:!0,once:!0}),document.addEventListener("pointermove",k,{capture:!0,once:!0})},k=()=>y.current=!1;return document.addEventListener("keydown",E,{capture:!0}),()=>{document.removeEventListener("keydown",E,{capture:!0}),document.removeEventListener("pointerdown",k,{capture:!0}),document.removeEventListener("pointermove",k,{capture:!0})}},[]),i.jsx(v3,{...a,children:i.jsx(rUe,{scope:e,open:r,onOpenChange:v,content:f,onContentChange:p,children:i.jsx(nUe,{scope:e,onClose:N.useCallback(()=>v(!1),[v]),isUsingKeyboardRef:y,dir:S,modal:c,children:n})})})};Gye.displayName=UN;var sUe="MenuAnchor",P7=N.forwardRef((t,e)=>{const{__scopeMenu:r,...n}=t,s=D3(r);return i.jsx(FN,{...s,...n,ref:e})});P7.displayName=sUe;var R7="MenuPortal",[iUe,Hye]=R_(R7,{forceMount:void 0}),Wye=t=>{const{__scopeMenu:e,forceMount:r,children:n,container:s}=t,o=L_(R7,e);return i.jsx(iUe,{scope:e,forceMount:r,children:i.jsx(vl,{present:r||o.open,children:i.jsx(iT,{asChild:!0,container:s,children:n})})})};Wye.displayName=R7;var ch="MenuContent",[aUe,L7]=R_(ch),Kye=N.forwardRef((t,e)=>{const r=Hye(ch,t.__scopeMenu),{forceMount:n=r.forceMount,...s}=t,o=L_(ch,t.__scopeMenu),c=VN(ch,t.__scopeMenu);return i.jsx(ck.Provider,{scope:t.__scopeMenu,children:i.jsx(vl,{present:n||o.open,children:i.jsx(ck.Slot,{scope:t.__scopeMenu,children:c.modal?i.jsx(oUe,{...s,ref:e}):i.jsx(lUe,{...s,ref:e})})})})}),oUe=N.forwardRef((t,e)=>{const r=L_(ch,t.__scopeMenu),n=N.useRef(null),s=Zn(e,n);return N.useEffect(()=>{const o=n.current;if(o)return h3(o)},[]),i.jsx(M7,{...t,ref:s,trapFocus:r.open,disableOutsidePointerEvents:r.open,disableOutsideScroll:!0,onFocusOutside:Fr(t.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>r.onOpenChange(!1)})}),lUe=N.forwardRef((t,e)=>{const r=L_(ch,t.__scopeMenu);return i.jsx(M7,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>r.onOpenChange(!1)})}),cUe=gx("MenuContent.ScrollLock"),M7=N.forwardRef((t,e)=>{const{__scopeMenu:r,loop:n=!1,trapFocus:s,onOpenAutoFocus:o,onCloseAutoFocus:c,disableOutsidePointerEvents:a,onEntryFocus:f,onEscapeKeyDown:p,onPointerDownOutside:y,onFocusOutside:v,onInteractOutside:S,onDismiss:E,disableOutsideScroll:k,...R}=t,P=L_(ch,r),M=VN(ch,r),D=D3(r),B=qye(r),V=eUe(r),[G,W]=N.useState(null),Y=N.useRef(null),J=Zn(e,Y,P.onContentChange),Q=N.useRef(0),ee=N.useRef(""),le=N.useRef(0),pe=N.useRef(null),Te=N.useRef("right"),Ae=N.useRef(0),Le=k?PN:N.Fragment,ke=k?{as:cUe,allowPinchZoom:!0}:void 0,we=je=>{var vt,Gt;const _e=ee.current+je,Ee=V().filter(pt=>!pt.disabled),ve=document.activeElement,qe=(vt=Ee.find(pt=>pt.ref.current===ve))==null?void 0:vt.textValue,nt=Ee.map(pt=>pt.textValue),ot=bUe(nt,_e,qe),jt=(Gt=Ee.find(pt=>pt.textValue===ot))==null?void 0:Gt.ref.current;(function pt(Ct){ee.current=Ct,window.clearTimeout(Q.current),Ct!==""&&(Q.current=window.setTimeout(()=>pt(""),1e3))})(_e),jt&&setTimeout(()=>jt.focus())};N.useEffect(()=>()=>window.clearTimeout(Q.current),[]),u3();const me=N.useCallback(je=>{var Ee,ve;return Te.current===((Ee=pe.current)==null?void 0:Ee.side)&&SUe(je,(ve=pe.current)==null?void 0:ve.area)},[]);return i.jsx(aUe,{scope:r,searchRef:ee,onItemEnter:N.useCallback(je=>{me(je)&&je.preventDefault()},[me]),onItemLeave:N.useCallback(je=>{var _e;me(je)||((_e=Y.current)==null||_e.focus(),W(null))},[me]),onTriggerLeave:N.useCallback(je=>{me(je)&&je.preventDefault()},[me]),pointerGraceTimerRef:le,onPointerGraceIntentChange:N.useCallback(je=>{pe.current=je},[]),children:i.jsx(Le,{...ke,children:i.jsx(IN,{asChild:!0,trapped:s,onMountAutoFocus:Fr(o,je=>{var _e;je.preventDefault(),(_e=Y.current)==null||_e.focus({preventScroll:!0})}),onUnmountAutoFocus:c,children:i.jsx(A_,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:p,onPointerDownOutside:y,onFocusOutside:v,onInteractOutside:S,onDismiss:E,children:i.jsx(C7,{asChild:!0,...B,dir:M.dir,orientation:"vertical",loop:n,currentTabStopId:G,onCurrentTabStopIdChange:W,onEntryFocus:Fr(f,je=>{M.isUsingKeyboardRef.current||je.preventDefault()}),preventScrollOnEntryFocus:!0,children:i.jsx(_3,{role:"menu","aria-orientation":"vertical","data-state":uxe(P.open),"data-radix-menu-content":"",dir:M.dir,...D,...R,ref:J,style:{outline:"none",...R.style},onKeyDown:Fr(R.onKeyDown,je=>{const Ee=je.target.closest("[data-radix-menu-content]")===je.currentTarget,ve=je.ctrlKey||je.altKey||je.metaKey,qe=je.key.length===1;Ee&&(je.key==="Tab"&&je.preventDefault(),!ve&&qe&&we(je.key));const nt=Y.current;if(je.target!==nt||!X6e.includes(je.key))return;je.preventDefault();const jt=V().filter(vt=>!vt.disabled).map(vt=>vt.ref.current);Uye.includes(je.key)&&jt.reverse(),vUe(jt)}),onBlur:Fr(t.onBlur,je=>{je.currentTarget.contains(je.target)||(window.clearTimeout(Q.current),ee.current="")}),onPointerMove:Fr(t.onPointerMove,uk(je=>{const _e=je.target,Ee=Ae.current!==je.clientX;if(je.currentTarget.contains(_e)&&Ee){const ve=je.clientX>Ae.current?"right":"left";Te.current=ve,Ae.current=je.clientX}}))})})})})})})});Kye.displayName=ch;var uUe="MenuGroup",D7=N.forwardRef((t,e)=>{const{__scopeMenu:r,...n}=t;return i.jsx(nn.div,{role:"group",...n,ref:e})});D7.displayName=uUe;var dUe="MenuLabel",Yye=N.forwardRef((t,e)=>{const{__scopeMenu:r,...n}=t;return i.jsx(nn.div,{...n,ref:e})});Yye.displayName=dUe;var XM="MenuItem",hre="menu.itemSelect",O3=N.forwardRef((t,e)=>{const{disabled:r=!1,onSelect:n,...s}=t,o=N.useRef(null),c=VN(XM,t.__scopeMenu),a=L7(XM,t.__scopeMenu),f=Zn(e,o),p=N.useRef(!1),y=()=>{const v=o.current;if(!r&&v){const S=new CustomEvent(hre,{bubbles:!0,cancelable:!0});v.addEventListener(hre,E=>n==null?void 0:n(E),{once:!0}),L9(v,S),S.defaultPrevented?p.current=!1:c.onClose()}};return i.jsx(Zye,{...s,ref:f,disabled:r,onClick:Fr(t.onClick,y),onPointerDown:v=>{var S;(S=t.onPointerDown)==null||S.call(t,v),p.current=!0},onPointerUp:Fr(t.onPointerUp,v=>{var S;p.current||(S=v.currentTarget)==null||S.click()}),onKeyDown:Fr(t.onKeyDown,v=>{const S=a.searchRef.current!=="";r||S&&v.key===" "||qV.includes(v.key)&&(v.currentTarget.click(),v.preventDefault())})})});O3.displayName=XM;var Zye=N.forwardRef((t,e)=>{const{__scopeMenu:r,disabled:n=!1,textValue:s,...o}=t,c=L7(XM,r),a=qye(r),f=N.useRef(null),p=Zn(e,f),[y,v]=N.useState(!1),[S,E]=N.useState("");return N.useEffect(()=>{const k=f.current;k&&E((k.textContent??"").trim())},[o.children]),i.jsx(ck.ItemSlot,{scope:r,disabled:n,textValue:s??S,children:i.jsx(I7,{asChild:!0,...a,focusable:!n,children:i.jsx(nn.div,{role:"menuitem","data-highlighted":y?"":void 0,"aria-disabled":n||void 0,"data-disabled":n?"":void 0,...o,ref:p,onPointerMove:Fr(t.onPointerMove,uk(k=>{n?c.onItemLeave(k):(c.onItemEnter(k),k.defaultPrevented||k.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Fr(t.onPointerLeave,uk(k=>c.onItemLeave(k))),onFocus:Fr(t.onFocus,()=>v(!0)),onBlur:Fr(t.onBlur,()=>v(!1))})})})}),hUe="MenuCheckboxItem",Xye=N.forwardRef((t,e)=>{const{checked:r=!1,onCheckedChange:n,...s}=t;return i.jsx(rxe,{scope:t.__scopeMenu,checked:r,children:i.jsx(O3,{role:"menuitemcheckbox","aria-checked":QM(r)?"mixed":r,...s,ref:e,"data-state":F7(r),onSelect:Fr(s.onSelect,()=>n==null?void 0:n(QM(r)?!0:!r),{checkForDefaultPrevented:!1})})})});Xye.displayName=hUe;var Qye="MenuRadioGroup",[fUe,mUe]=R_(Qye,{value:void 0,onValueChange:()=>{}}),Jye=N.forwardRef((t,e)=>{const{value:r,onValueChange:n,...s}=t,o=_o(n);return i.jsx(fUe,{scope:t.__scopeMenu,value:r,onValueChange:o,children:i.jsx(D7,{...s,ref:e})})});Jye.displayName=Qye;var exe="MenuRadioItem",txe=N.forwardRef((t,e)=>{const{value:r,...n}=t,s=mUe(exe,t.__scopeMenu),o=r===s.value;return i.jsx(rxe,{scope:t.__scopeMenu,checked:o,children:i.jsx(O3,{role:"menuitemradio","aria-checked":o,...n,ref:e,"data-state":F7(o),onSelect:Fr(n.onSelect,()=>{var c;return(c=s.onValueChange)==null?void 0:c.call(s,r)},{checkForDefaultPrevented:!1})})})});txe.displayName=exe;var O7="MenuItemIndicator",[rxe,pUe]=R_(O7,{checked:!1}),nxe=N.forwardRef((t,e)=>{const{__scopeMenu:r,forceMount:n,...s}=t,o=pUe(O7,r);return i.jsx(vl,{present:n||QM(o.checked)||o.checked===!0,children:i.jsx(nn.span,{...s,ref:e,"data-state":F7(o.checked)})})});nxe.displayName=O7;var gUe="MenuSeparator",sxe=N.forwardRef((t,e)=>{const{__scopeMenu:r,...n}=t;return i.jsx(nn.div,{role:"separator","aria-orientation":"horizontal",...n,ref:e})});sxe.displayName=gUe;var yUe="MenuArrow",ixe=N.forwardRef((t,e)=>{const{__scopeMenu:r,...n}=t,s=D3(r);return i.jsx(b3,{...s,...n,ref:e})});ixe.displayName=yUe;var xUe="MenuSub",[wGt,axe]=R_(xUe),K2="MenuSubTrigger",oxe=N.forwardRef((t,e)=>{const r=L_(K2,t.__scopeMenu),n=VN(K2,t.__scopeMenu),s=axe(K2,t.__scopeMenu),o=L7(K2,t.__scopeMenu),c=N.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:f}=o,p={__scopeMenu:t.__scopeMenu},y=N.useCallback(()=>{c.current&&window.clearTimeout(c.current),c.current=null},[]);return N.useEffect(()=>y,[y]),N.useEffect(()=>{const v=a.current;return()=>{window.clearTimeout(v),f(null)}},[a,f]),i.jsx(P7,{asChild:!0,...p,children:i.jsx(Zye,{id:s.triggerId,"aria-haspopup":"menu","aria-expanded":r.open,"aria-controls":s.contentId,"data-state":uxe(r.open),...t,ref:ag(e,s.onTriggerChange),onClick:v=>{var S;(S=t.onClick)==null||S.call(t,v),!(t.disabled||v.defaultPrevented)&&(v.currentTarget.focus(),r.open||r.onOpenChange(!0))},onPointerMove:Fr(t.onPointerMove,uk(v=>{o.onItemEnter(v),!v.defaultPrevented&&!t.disabled&&!r.open&&!c.current&&(o.onPointerGraceIntentChange(null),c.current=window.setTimeout(()=>{r.onOpenChange(!0),y()},100))})),onPointerLeave:Fr(t.onPointerLeave,uk(v=>{var E,k;y();const S=(E=r.content)==null?void 0:E.getBoundingClientRect();if(S){const R=(k=r.content)==null?void 0:k.dataset.side,P=R==="right",M=P?-5:5,D=S[P?"left":"right"],B=S[P?"right":"left"];o.onPointerGraceIntentChange({area:[{x:v.clientX+M,y:v.clientY},{x:D,y:S.top},{x:B,y:S.top},{x:B,y:S.bottom},{x:D,y:S.bottom}],side:R}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>o.onPointerGraceIntentChange(null),300)}else{if(o.onTriggerLeave(v),v.defaultPrevented)return;o.onPointerGraceIntentChange(null)}})),onKeyDown:Fr(t.onKeyDown,v=>{var E;const S=o.searchRef.current!=="";t.disabled||S&&v.key===" "||Q6e[n.dir].includes(v.key)&&(r.onOpenChange(!0),(E=r.content)==null||E.focus(),v.preventDefault())})})})});oxe.displayName=K2;var lxe="MenuSubContent",cxe=N.forwardRef((t,e)=>{const r=Hye(ch,t.__scopeMenu),{forceMount:n=r.forceMount,...s}=t,o=L_(ch,t.__scopeMenu),c=VN(ch,t.__scopeMenu),a=axe(lxe,t.__scopeMenu),f=N.useRef(null),p=Zn(e,f);return i.jsx(ck.Provider,{scope:t.__scopeMenu,children:i.jsx(vl,{present:n||o.open,children:i.jsx(ck.Slot,{scope:t.__scopeMenu,children:i.jsx(M7,{id:a.contentId,"aria-labelledby":a.triggerId,...s,ref:p,align:"start",side:c.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:y=>{var v;c.isUsingKeyboardRef.current&&((v=f.current)==null||v.focus()),y.preventDefault()},onCloseAutoFocus:y=>y.preventDefault(),onFocusOutside:Fr(t.onFocusOutside,y=>{y.target!==a.trigger&&o.onOpenChange(!1)}),onEscapeKeyDown:Fr(t.onEscapeKeyDown,y=>{c.onClose(),y.preventDefault()}),onKeyDown:Fr(t.onKeyDown,y=>{var E;const v=y.currentTarget.contains(y.target),S=J6e[c.dir].includes(y.key);v&&S&&(o.onOpenChange(!1),(E=a.trigger)==null||E.focus(),y.preventDefault())})})})})})});cxe.displayName=lxe;function uxe(t){return t?"open":"closed"}function QM(t){return t==="indeterminate"}function F7(t){return QM(t)?"indeterminate":t?"checked":"unchecked"}function vUe(t){const e=document.activeElement;for(const r of t)if(r===e||(r.focus(),document.activeElement!==e))return}function _Ue(t,e){return t.map((r,n)=>t[(e+n)%t.length])}function bUe(t,e,r){const s=e.length>1&&Array.from(e).every(p=>p===e[0])?e[0]:e,o=r?t.indexOf(r):-1;let c=_Ue(t,Math.max(o,0));s.length===1&&(c=c.filter(p=>p!==r));const f=c.find(p=>p.toLowerCase().startsWith(s.toLowerCase()));return f!==r?f:void 0}function wUe(t,e){const{x:r,y:n}=t;let s=!1;for(let o=0,c=e.length-1;on!=S>n&&r<(v-p)*(n-y)/(S-y)+p&&(s=!s)}return s}function SUe(t,e){if(!e)return!1;const r={x:t.clientX,y:t.clientY};return wUe(r,e)}function uk(t){return e=>e.pointerType==="mouse"?t(e):void 0}var TUe=Gye,EUe=P7,jUe=Wye,AUe=Kye,kUe=D7,NUe=Yye,CUe=O3,IUe=Xye,PUe=Jye,RUe=txe,LUe=nxe,MUe=sxe,DUe=ixe,OUe=oxe,FUe=cxe,F3="DropdownMenu",[BUe,SGt]=Jo(F3,[Vye]),lu=Vye(),[$Ue,dxe]=BUe(F3),hxe=t=>{const{__scopeDropdownMenu:e,children:r,dir:n,open:s,defaultOpen:o,onOpenChange:c,modal:a=!0}=t,f=lu(e),p=N.useRef(null),[y,v]=_d({prop:s,defaultProp:o??!1,onChange:c,caller:F3});return i.jsx($Ue,{scope:e,triggerId:Fl(),triggerRef:p,contentId:Fl(),open:y,onOpenChange:v,onOpenToggle:N.useCallback(()=>v(S=>!S),[v]),modal:a,children:i.jsx(TUe,{...f,open:y,onOpenChange:v,dir:n,modal:a,children:r})})};hxe.displayName=F3;var fxe="DropdownMenuTrigger",mxe=N.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,disabled:n=!1,...s}=t,o=dxe(fxe,r),c=lu(r);return i.jsx(EUe,{asChild:!0,...c,children:i.jsx(nn.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:ag(e,o.triggerRef),onPointerDown:Fr(t.onPointerDown,a=>{!n&&a.button===0&&a.ctrlKey===!1&&(o.onOpenToggle(),o.open||a.preventDefault())}),onKeyDown:Fr(t.onKeyDown,a=>{n||(["Enter"," "].includes(a.key)&&o.onOpenToggle(),a.key==="ArrowDown"&&o.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});mxe.displayName=fxe;var zUe="DropdownMenuPortal",pxe=t=>{const{__scopeDropdownMenu:e,...r}=t,n=lu(e);return i.jsx(jUe,{...n,...r})};pxe.displayName=zUe;var gxe="DropdownMenuContent",yxe=N.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,s=dxe(gxe,r),o=lu(r),c=N.useRef(!1);return i.jsx(AUe,{id:s.contentId,"aria-labelledby":s.triggerId,...o,...n,ref:e,onCloseAutoFocus:Fr(t.onCloseAutoFocus,a=>{var f;c.current||(f=s.triggerRef.current)==null||f.focus(),c.current=!1,a.preventDefault()}),onInteractOutside:Fr(t.onInteractOutside,a=>{const f=a.detail.originalEvent,p=f.button===0&&f.ctrlKey===!0,y=f.button===2||p;(!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)"}})});yxe.displayName=gxe;var UUe="DropdownMenuGroup",VUe=N.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,s=lu(r);return i.jsx(kUe,{...s,...n,ref:e})});VUe.displayName=UUe;var qUe="DropdownMenuLabel",xxe=N.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,s=lu(r);return i.jsx(NUe,{...s,...n,ref:e})});xxe.displayName=qUe;var GUe="DropdownMenuItem",vxe=N.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,s=lu(r);return i.jsx(CUe,{...s,...n,ref:e})});vxe.displayName=GUe;var HUe="DropdownMenuCheckboxItem",_xe=N.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,s=lu(r);return i.jsx(IUe,{...s,...n,ref:e})});_xe.displayName=HUe;var WUe="DropdownMenuRadioGroup",KUe=N.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,s=lu(r);return i.jsx(PUe,{...s,...n,ref:e})});KUe.displayName=WUe;var YUe="DropdownMenuRadioItem",bxe=N.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,s=lu(r);return i.jsx(RUe,{...s,...n,ref:e})});bxe.displayName=YUe;var ZUe="DropdownMenuItemIndicator",wxe=N.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,s=lu(r);return i.jsx(LUe,{...s,...n,ref:e})});wxe.displayName=ZUe;var XUe="DropdownMenuSeparator",Sxe=N.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,s=lu(r);return i.jsx(MUe,{...s,...n,ref:e})});Sxe.displayName=XUe;var QUe="DropdownMenuArrow",JUe=N.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,s=lu(r);return i.jsx(DUe,{...s,...n,ref:e})});JUe.displayName=QUe;var eVe="DropdownMenuSubTrigger",Txe=N.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,s=lu(r);return i.jsx(OUe,{...s,...n,ref:e})});Txe.displayName=eVe;var tVe="DropdownMenuSubContent",Exe=N.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,s=lu(r);return i.jsx(FUe,{...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)"}})});Exe.displayName=tVe;var rVe=hxe,nVe=mxe,sVe=pxe,jxe=yxe,Axe=xxe,kxe=vxe,Nxe=_xe,Cxe=bxe,Ixe=wxe,Pxe=Sxe,Rxe=Txe,Lxe=Exe;const qN=rVe,GN=nVe,iVe=N.forwardRef(({className:t,inset:e,children:r,...n},s)=>i.jsxs(Rxe,{ref:s,className:qt("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(kd,{className:"ml-auto h-4 w-4"})]}));iVe.displayName=Rxe.displayName;const aVe=N.forwardRef(({className:t,...e},r)=>i.jsx(Lxe,{ref:r,className:qt("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}));aVe.displayName=Lxe.displayName;const _T=N.forwardRef(({className:t,sideOffset:e=4,...r},n)=>i.jsx(sVe,{children:i.jsx(jxe,{ref:n,sideOffset:e,className:qt("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})}));_T.displayName=jxe.displayName;const Cu=N.forwardRef(({className:t,inset:e,...r},n)=>i.jsx(kxe,{ref:n,className:qt("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}));Cu.displayName=kxe.displayName;const oVe=N.forwardRef(({className:t,children:e,checked:r,...n},s)=>i.jsxs(Nxe,{ref:s,className:qt("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(Ixe,{children:i.jsx(Oa,{className:"h-4 w-4"})})}),e]}));oVe.displayName=Nxe.displayName;const lVe=N.forwardRef(({className:t,children:e,...r},n)=>i.jsxs(Cxe,{ref:n,className:qt("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(Ixe,{children:i.jsx(c_,{className:"h-2 w-2 fill-current"})})}),e]}));lVe.displayName=Cxe.displayName;const Mxe=N.forwardRef(({className:t,inset:e,...r},n)=>i.jsx(Axe,{ref:n,className:qt("px-2 py-1.5 text-sm font-semibold",e&&"pl-8",t),...r}));Mxe.displayName=Axe.displayName;const dk=N.forwardRef(({className:t,...e},r)=>i.jsx(Pxe,{ref:r,className:qt("-mx-1 my-1 h-px bg-muted",t),...e}));dk.displayName=Pxe.displayName;const cVe=()=>{const{isAssistant:t,actingAsAgent:e,assignedAgents:r,setActingAsAgent:n,isActingAsSelf:s,setActingAsSelf:o}=M3();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(Dl,{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(ml,{className:"h-4 w-4 flex-shrink-0"}),i.jsx("span",{className:"font-medium text-sm",children:"Acting as"})]}),i.jsxs(qN,{children:[i.jsx(GN,{asChild:!0,children:i.jsxs(Dt,{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(Dl,{className:"h-4 w-4"}),i.jsx("strong",{children:"My Account"})]}):e?i.jsxs(i.Fragment,{children:[i.jsxs(wd,{className:"h-5 w-5",children:[i.jsx(Sd,{src:e.avatar_url||void 0}),i.jsx(Td,{className:"text-[10px] bg-primary-foreground/30",children:c(e.name)})]}),i.jsx("strong",{children:e.name})]}):i.jsx("strong",{children:"Select..."}),i.jsx(xl,{className:"h-3 w-3"})]})}),i.jsxs(_T,{align:"start",className:"z-[2147483647]",children:[i.jsxs(Cu,{onClick:o,className:"gap-2",children:[i.jsx(Dl,{className:"h-4 w-4"}),i.jsx("span",{children:"My Account"}),s&&i.jsx(ii,{variant:"secondary",className:"ml-auto text-[10px]",children:"Current"})]}),i.jsx(dk,{}),r.map(a=>i.jsxs(Cu,{onClick:()=>n(a),className:"gap-2",children:[i.jsxs(wd,{className:"h-6 w-6",children:[i.jsx(Sd,{src:a.avatar_url||void 0}),i.jsx(Td,{className:"text-[10px]",children:c(a.name)})]}),i.jsx("span",{children:a.name}),!s&&a.id===(e==null?void 0:e.id)&&i.jsx(ii,{variant:"secondary",className:"ml-auto text-[10px]",children:"Current"})]},a.id))]})]})]}),i.jsx(ii,{variant:"secondary",className:"bg-primary-foreground/20 text-primary-foreground border-0 text-xs",children:s?"Personal Mode":"Assistant Mode"})]})})};function Dxe(){var f,p;const{user:t,isAdmin:e}=Wn(),{data:r,isLoading:n}=fr({queryKey:["partnership-membership",t==null?void 0:t.id],enabled:!!(t!=null&&t.id),staleTime:5*60*1e3,queryFn:async()=>{const{data:y}=await Re.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:v},{data:S}]=await Promise.all([Re.from("partnership_packages").select("*").eq("id",y.package_id).maybeSingle(),Re.from("partnership_programs").select("id, name, enabled, brokerage_id").eq("id",y.program_id).maybeSingle()]);return!v||!(S!=null&&S.enabled)?null:{membership:y,pkg:v,program:S}}}),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,k;const v=((E=r==null?void 0:r.pkg)==null?void 0:E.feature_limits)||{},S=(k=v==null?void 0:v[y])==null?void 0:k.monthly_limit;return typeof S=="number"?S: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:((p=r==null?void 0:r.pkg)==null?void 0:p.name)??null,features:s,hasFeature:c,limitFor:a,isRestricted:o&&!e}}const B7={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"},TGt=Object.keys(B7),uVe={home:null,crm:"crm",deals:"deals",listings:"listing_exchange",marketing:"marketing_studio",websites:"website",academy:"learn",events:"learn",apps:null,brokerage:"community",more:null},fre={"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"},dVe={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 hVe(t){return t.id in fre?fre[t.id]:uVe[t.primaryCategory]??null}function EGt(t){return dVe[t]??null}const fVe=[["/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 mVe(t){let e=null;for(const r of fVe){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 $n=N.forwardRef(({className:t,...e},r)=>i.jsx("div",{ref:r,className:qt("rounded-lg border bg-card text-card-foreground shadow-sm",t),...e}));$n.displayName="Card";const fd=N.forwardRef(({className:t,...e},r)=>i.jsx("div",{ref:r,className:qt("flex flex-col space-y-1.5 p-6",t),...e}));fd.displayName="CardHeader";const md=N.forwardRef(({className:t,...e},r)=>i.jsx("h3",{ref:r,className:qt("text-2xl font-semibold leading-none tracking-tight",t),...e}));md.displayName="CardTitle";const hk=N.forwardRef(({className:t,...e},r)=>i.jsx("p",{ref:r,className:qt("text-sm text-muted-foreground",t),...e}));hk.displayName="CardDescription";const Yn=N.forwardRef(({className:t,...e},r)=>i.jsx("div",{ref:r,className:qt("p-6 pt-0",t),...e}));Yn.displayName="CardContent";const GV=N.forwardRef(({className:t,...e},r)=>i.jsx("div",{ref:r,className:qt("flex items-center p-6 pt-0",t),...e}));GV.displayName="CardFooter";const Bu=N.forwardRef(({className:t,...e},r)=>i.jsx("textarea",{className:qt("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}));Bu.displayName="Textarea";const Fa=m3,Oxe=e7,pVe=p3,jGt=MN,Fxe=N.forwardRef(({className:t,...e},r)=>i.jsx(uT,{ref:r,className:qt("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}));Fxe.displayName=uT.displayName;const Sa=N.forwardRef(({className:t,children:e,overlayClassName:r,...n},s)=>i.jsxs(pVe,{children:[i.jsx(Fxe,{className:r}),i.jsxs(dT,{ref:s,className:qt("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(MN,{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(ki,{className:"h-4 w-4"}),i.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Sa.displayName=dT.displayName;const Fo=({className:t,...e})=>i.jsx("div",{className:qt("flex flex-col space-y-1.5 text-center sm:text-left",t),...e});Fo.displayName="DialogHeader";const Bxe=({className:t,...e})=>i.jsx("div",{className:qt("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...e});Bxe.displayName="DialogFooter";const bo=N.forwardRef(({className:t,...e},r)=>i.jsx(RN,{ref:r,className:qt("text-lg font-semibold leading-none tracking-tight",t),...e}));bo.displayName=RN.displayName;const Fu=N.forwardRef(({className:t,...e},r)=>i.jsx(LN,{ref:r,className:qt("text-sm text-muted-foreground",t),...e}));Fu.displayName=LN.displayName;function gVe({featureKey:t,open:e,onOpenChange:r}){const{user:n}=Wn(),s=Er(),[o,c]=N.useState(""),{data:a}=fr({queryKey:["partnership-upgrade-requests",n==null?void 0:n.id],enabled:!!(n!=null&&n.id)&&e,queryFn:async()=>{const{data:v}=await Re.from("lead_site_upgrade_requests").select("id, feature_key, status").eq("user_id",n.id);return v||[]}}),f=!!(a!=null&&a.some(v=>v.feature_key===t&&v.status!=="declined")),p=wr({mutationFn:async()=>{const{error:v}=await Re.from("lead_site_upgrade_requests").insert({user_id:n.id,feature_key:t,notes:o||null});if(v)throw v},onSuccess:()=>{s.invalidateQueries({queryKey:["partnership-upgrade-requests"]}),$t.success("Request sent — we'll be in touch shortly."),c(""),r(!1)},onError:v=>$t.error((v==null?void 0:v.message)||"Could not send your request")}),y=B7[t]||t;return i.jsx(Fa,{open:e,onOpenChange:r,children:i.jsxs(Sa,{className:"sm:max-w-md",children:[i.jsxs(Fo,{children:[i.jsxs(bo,{className:"flex items-center gap-2",children:[i.jsx(vi,{className:"h-5 w-5 text-primary"}),"Request ",y]}),i.jsxs(Fu,{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(Oa,{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(Bu,{placeholder:"Anything we should know? (optional)",value:o,onChange:v=>c(v.target.value),rows:4}),i.jsxs(Bxe,{children:[i.jsx(Dt,{variant:"outline",onClick:()=>r(!1),children:"Close"}),!f&&i.jsx(Dt,{onClick:()=>p.mutate(),disabled:p.isPending,children:p.isPending?"Sending…":"Send request"})]})]})})}function yVe({featureKey:t}){const[e,r]=N.useState(!1),n=B7[t]||t;return i.jsxs("div",{className:"flex items-center justify-center py-16 px-4",children:[i.jsx($n,{className:"max-w-lg w-full border-border/60",children:i.jsxs(Yn,{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(xx,{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(Dt,{onClick:()=>r(!0),className:"gap-2",children:[i.jsx(vi,{className:"h-4 w-4"})," Request access"]})]})}),i.jsx(gVe,{featureKey:t,open:e,onOpenChange:r})]})}const xVe=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 Re.storage.from("avatars").list(`${t}`);if(a&&a.length>0){const{data:f}=Re.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 Re.storage.from("avatars").list(`${t}`);if(c&&c.length>0){const{data:a}=Re.storage.from("avatars").getPublicUrl(`${t}/${c[0].name}`);r(`${a.publicUrl}?t=${Date.now()}`)}}catch(c){console.error("Error refreshing avatar:",c)}}}},AGt=async t=>{const e=new Map;return await Promise.all(t.map(async r=>{try{const{data:n}=await Re.storage.from("avatars").list(`${r}`);if(n&&n.length>0){const{data:s}=Re.storage.from("avatars").getPublicUrl(`${r}/${n[0].name}`);e.set(r,s.publicUrl)}}catch{}})),e},vVe=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 Re.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(v=>({...v,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",p=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)&&!!p&&p){const v=new Date().getTime(),S=new Date(p).getTime(),E=Math.ceil((S-v)/(1e3*60*60*24)),k=E<=0;r({isTrial:!0,isExpired:k,expiresAt:p,daysLeft:k?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},B3=()=>{const{data:t,isLoading:e}=fr({queryKey:["feature-flags"],queryFn:async()=>{const{data:n,error:s}=await Re.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")}},mre="community_last_seen_post_at";function _Ve(){const{user:t}=Wn(),e=Es(),[r,n]=N.useState(0),[s,o]=N.useState(null);N.useEffect(()=>{if(!t)return;const a=localStorage.getItem(`${mre}_${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 k=JSON.parse(E);if(k.ts&&Date.now()-k.ts{if(!t)return;const a=Re.channel("community-new-posts").on("postgres_changes",{event:"INSERT",schema:"public",table:"community_posts"},async f=>{const p=f.new;if(p.user_id===t.id)return;const y=e.pathname==="/community";y||n(R=>R+1);const{data:v}=await Re.from("profiles").select("name").eq("id",p.user_id).single(),S=(v==null?void 0:v.name)||"Someone",E=p.content.replace(/@\[([^\]]+)\]\([^)]+\)/g,"@$1"),k=E.length>50?E.substring(0,50)+"...":E;y||$t("New Community Post",{description:`${S}: ${k}`,action:{label:"View",onClick:()=>{window.location.href="/community"}}})}).subscribe();return()=>{Re.removeChannel(a)}},[t,e.pathname]);const c=N.useCallback(()=>{if(!t)return;const a=new Date().toISOString();localStorage.setItem(`${mre}_${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 bVe(){const{isAdmin:t}=Wn(),{data:e=0}=fr({queryKey:["wishlist-open-count"],queryFn:async()=>{const{count:r,error:n}=await Re.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 Y$=t=>`levelup:activeTeam:${t}`,wVe=()=>{const t=Ls();return fr({queryKey:["user-teams",t],queryFn:async()=>{const{data:e,error:r}=await Re.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 Re.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,p;return c.role!==a.role?c.role==="team_leader"?-1:1:(((f=c.team)==null?void 0:f.name)||"").localeCompare(((p=a.team)==null?void 0:p.name)||"")})},enabled:!!t,staleTime:5*60*1e3})},bT=()=>{const t=Ls(),e=wVe(),r=N.useMemo(()=>e.data||[],[e.data]),[n,s]=N.useState(()=>!t||typeof window>"u"?null:window.localStorage.getItem(Y$(t)));N.useEffect(()=>{!t||typeof window>"u"||s(window.localStorage.getItem(Y$(t)))},[t]);const o=N.useCallback(a=>{s(a),t&&typeof window<"u"&&window.localStorage.setItem(Y$(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}},pre="weekly_reels";function $7(){const{user:t,loading:e,isAdmin:r}=Wn(),{data:n,isLoading:s}=fr({queryKey:["feature-entitlement",pre,t==null?void 0:t.id],enabled:!!t&&!r,staleTime:5*60*1e3,queryFn:async()=>{const{data:o,error:c}=await Re.from("feature_entitlements").select("enabled, expires_at, tier").eq("user_id",t.id).eq("feature_key",pre).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 $xe=m3,SVe=e7,TVe=p3,zxe=N.forwardRef(({className:t,...e},r)=>i.jsx(uT,{className:qt("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}));zxe.displayName=uT.displayName;const EVe=aT("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"}}),z7=N.forwardRef(({side:t="right",className:e,children:r,...n},s)=>i.jsxs(TVe,{children:[i.jsx(zxe,{}),i.jsxs(dT,{ref:s,className:qt(EVe({side:t}),e),...n,children:[r,i.jsxs(MN,{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(ki,{className:"h-4 w-4"}),i.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));z7.displayName=dT.displayName;const Uxe=({className:t,...e})=>i.jsx("div",{className:qt("flex flex-col space-y-2 text-center sm:text-left",t),...e});Uxe.displayName="SheetHeader";const jVe=({className:t,...e})=>i.jsx("div",{className:qt("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...e});jVe.displayName="SheetFooter";const Vxe=N.forwardRef(({className:t,...e},r)=>i.jsx(RN,{ref:r,className:qt("text-lg font-semibold text-foreground",t),...e}));Vxe.displayName=RN.displayName;const qxe=N.forwardRef(({className:t,...e},r)=>i.jsx(LN,{ref:r,className:qt("text-sm text-muted-foreground",t),...e}));qxe.displayName=LN.displayName;function fk(t,[e,r]){return Math.min(r,Math.max(e,t))}function AVe(t,e){return N.useReducer((r,n)=>e[r][n]??r,t)}var U7="ScrollArea",[Gxe,kGt]=Jo(U7),[kVe,xh]=Gxe(U7),Hxe=N.forwardRef((t,e)=>{const{__scopeScrollArea:r,type:n="hover",dir:s,scrollHideDelay:o=600,...c}=t,[a,f]=N.useState(null),[p,y]=N.useState(null),[v,S]=N.useState(null),[E,k]=N.useState(null),[R,P]=N.useState(null),[M,D]=N.useState(0),[B,V]=N.useState(0),[G,W]=N.useState(!1),[Y,J]=N.useState(!1),Q=Zn(e,le=>f(le)),ee=P_(s);return i.jsx(kVe,{scope:r,type:n,dir:ee,scrollHideDelay:o,scrollArea:a,viewport:p,onViewportChange:y,content:v,onContentChange:S,scrollbarX:E,onScrollbarXChange:k,scrollbarXEnabled:G,onScrollbarXEnabledChange:W,scrollbarY:R,onScrollbarYChange:P,scrollbarYEnabled:Y,onScrollbarYEnabledChange:J,onCornerWidthChange:D,onCornerHeightChange:V,children:i.jsx(nn.div,{dir:ee,...c,ref:Q,style:{position:"relative","--radix-scroll-area-corner-width":M+"px","--radix-scroll-area-corner-height":B+"px",...t.style}})})});Hxe.displayName=U7;var Wxe="ScrollAreaViewport",Kxe=N.forwardRef((t,e)=>{const{__scopeScrollArea:r,children:n,nonce:s,...o}=t,c=xh(Wxe,r),a=N.useRef(null),f=Zn(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(nn.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})})]})});Kxe.displayName=Wxe;var zm="ScrollAreaScrollbar",V7=N.forwardRef((t,e)=>{const{forceMount:r,...n}=t,s=xh(zm,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(NVe,{...n,ref:e,forceMount:r}):s.type==="scroll"?i.jsx(CVe,{...n,ref:e,forceMount:r}):s.type==="auto"?i.jsx(Yxe,{...n,ref:e,forceMount:r}):s.type==="always"?i.jsx(q7,{...n,ref:e}):null});V7.displayName=zm;var NVe=N.forwardRef((t,e)=>{const{forceMount:r,...n}=t,s=xh(zm,t.__scopeScrollArea),[o,c]=N.useState(!1);return N.useEffect(()=>{const a=s.scrollArea;let f=0;if(a){const p=()=>{window.clearTimeout(f),c(!0)},y=()=>{f=window.setTimeout(()=>c(!1),s.scrollHideDelay)};return a.addEventListener("pointerenter",p),a.addEventListener("pointerleave",y),()=>{window.clearTimeout(f),a.removeEventListener("pointerenter",p),a.removeEventListener("pointerleave",y)}}},[s.scrollArea,s.scrollHideDelay]),i.jsx(vl,{present:r||o,children:i.jsx(Yxe,{"data-state":o?"visible":"hidden",...n,ref:e})})}),CVe=N.forwardRef((t,e)=>{const{forceMount:r,...n}=t,s=xh(zm,t.__scopeScrollArea),o=t.orientation==="horizontal",c=z3(()=>f("SCROLL_END"),100),[a,f]=AVe("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 p=window.setTimeout(()=>f("HIDE"),s.scrollHideDelay);return()=>window.clearTimeout(p)}},[a,s.scrollHideDelay,f]),N.useEffect(()=>{const p=s.viewport,y=o?"scrollLeft":"scrollTop";if(p){let v=p[y];const S=()=>{const E=p[y];v!==E&&(f("SCROLL"),c()),v=E};return p.addEventListener("scroll",S),()=>p.removeEventListener("scroll",S)}},[s.viewport,o,f,c]),i.jsx(vl,{present:r||a!=="hidden",children:i.jsx(q7,{"data-state":a==="hidden"?"hidden":"visible",...n,ref:e,onPointerEnter:Fr(t.onPointerEnter,()=>f("POINTER_ENTER")),onPointerLeave:Fr(t.onPointerLeave,()=>f("POINTER_LEAVE"))})})}),Yxe=N.forwardRef((t,e)=>{const r=xh(zm,t.__scopeScrollArea),{forceMount:n,...s}=t,[o,c]=N.useState(!1),a=t.orientation==="horizontal",f=z3(()=>{if(r.viewport){const p=r.viewport.offsetWidth{const{orientation:r="vertical",...n}=t,s=xh(zm,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}}),p=e0e(a.viewport,a.content),y={...n,sizes:a,onSizesChange:f,hasThumb:p>0&&p<1,onThumbChange:S=>o.current=S,onThumbPointerUp:()=>c.current=0,onThumbPointerDown:S=>c.current=S};function v(S,E){return DVe(S,c.current,a,E)}return r==="horizontal"?i.jsx(IVe,{...y,ref:e,onThumbPositionChange:()=>{if(s.viewport&&o.current){const S=s.viewport.scrollLeft,E=gre(S,a,s.dir);o.current.style.transform=`translate3d(${E}px, 0, 0)`}},onWheelScroll:S=>{s.viewport&&(s.viewport.scrollLeft=S)},onDragScroll:S=>{s.viewport&&(s.viewport.scrollLeft=v(S,s.dir))}}):r==="vertical"?i.jsx(PVe,{...y,ref:e,onThumbPositionChange:()=>{if(s.viewport&&o.current){const S=s.viewport.scrollTop,E=gre(S,a);o.current.style.transform=`translate3d(0, ${E}px, 0)`}},onWheelScroll:S=>{s.viewport&&(s.viewport.scrollTop=S)},onDragScroll:S=>{s.viewport&&(s.viewport.scrollTop=v(S))}}):null}),IVe=N.forwardRef((t,e)=>{const{sizes:r,onSizesChange:n,...s}=t,o=xh(zm,t.__scopeScrollArea),[c,a]=N.useState(),f=N.useRef(null),p=Zn(e,f,o.onScrollbarXChange);return N.useEffect(()=>{f.current&&a(getComputedStyle(f.current))},[f]),i.jsx(Xxe,{"data-orientation":"horizontal",...s,ref:p,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":$3(r)+"px",...t.style},onThumbPointerDown:y=>t.onThumbPointerDown(y.x),onDragScroll:y=>t.onDragScroll(y.x),onWheelScroll:(y,v)=>{if(o.viewport){const S=o.viewport.scrollLeft+y.deltaX;t.onWheelScroll(S),r0e(S,v)&&y.preventDefault()}},onResize:()=>{f.current&&o.viewport&&c&&n({content:o.viewport.scrollWidth,viewport:o.viewport.offsetWidth,scrollbar:{size:f.current.clientWidth,paddingStart:eD(c.paddingLeft),paddingEnd:eD(c.paddingRight)}})}})}),PVe=N.forwardRef((t,e)=>{const{sizes:r,onSizesChange:n,...s}=t,o=xh(zm,t.__scopeScrollArea),[c,a]=N.useState(),f=N.useRef(null),p=Zn(e,f,o.onScrollbarYChange);return N.useEffect(()=>{f.current&&a(getComputedStyle(f.current))},[f]),i.jsx(Xxe,{"data-orientation":"vertical",...s,ref:p,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":$3(r)+"px",...t.style},onThumbPointerDown:y=>t.onThumbPointerDown(y.y),onDragScroll:y=>t.onDragScroll(y.y),onWheelScroll:(y,v)=>{if(o.viewport){const S=o.viewport.scrollTop+y.deltaY;t.onWheelScroll(S),r0e(S,v)&&y.preventDefault()}},onResize:()=>{f.current&&o.viewport&&c&&n({content:o.viewport.scrollHeight,viewport:o.viewport.offsetHeight,scrollbar:{size:f.current.clientHeight,paddingStart:eD(c.paddingTop),paddingEnd:eD(c.paddingBottom)}})}})}),[RVe,Zxe]=Gxe(zm),Xxe=N.forwardRef((t,e)=>{const{__scopeScrollArea:r,sizes:n,hasThumb:s,onThumbChange:o,onThumbPointerUp:c,onThumbPointerDown:a,onThumbPositionChange:f,onDragScroll:p,onWheelScroll:y,onResize:v,...S}=t,E=xh(zm,r),[k,R]=N.useState(null),P=Zn(e,Q=>R(Q)),M=N.useRef(null),D=N.useRef(""),B=E.viewport,V=n.content-n.viewport,G=_o(y),W=_o(f),Y=z3(v,10);function J(Q){if(M.current){const ee=Q.clientX-M.current.left,le=Q.clientY-M.current.top;p({x:ee,y:le})}}return N.useEffect(()=>{const Q=ee=>{const le=ee.target;(k==null?void 0:k.contains(le))&&G(ee,V)};return document.addEventListener("wheel",Q,{passive:!1}),()=>document.removeEventListener("wheel",Q,{passive:!1})},[B,k,V,G]),N.useEffect(W,[n,W]),yS(k,Y),yS(E.content,Y),i.jsx(RVe,{scope:r,scrollbar:k,hasThumb:s,onThumbChange:_o(o),onThumbPointerUp:_o(c),onThumbPositionChange:W,onThumbPointerDown:_o(a),children:i.jsx(nn.div,{...S,ref:P,style:{position:"absolute",...S.style},onPointerDown:Fr(t.onPointerDown,Q=>{Q.button===0&&(Q.target.setPointerCapture(Q.pointerId),M.current=k.getBoundingClientRect(),D.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",E.viewport&&(E.viewport.style.scrollBehavior="auto"),J(Q))}),onPointerMove:Fr(t.onPointerMove,J),onPointerUp:Fr(t.onPointerUp,Q=>{const ee=Q.target;ee.hasPointerCapture(Q.pointerId)&&ee.releasePointerCapture(Q.pointerId),document.body.style.webkitUserSelect=D.current,E.viewport&&(E.viewport.style.scrollBehavior=""),M.current=null})})})}),JM="ScrollAreaThumb",Qxe=N.forwardRef((t,e)=>{const{forceMount:r,...n}=t,s=Zxe(JM,t.__scopeScrollArea);return i.jsx(vl,{present:r||s.hasThumb,children:i.jsx(LVe,{ref:e,...n})})}),LVe=N.forwardRef((t,e)=>{const{__scopeScrollArea:r,style:n,...s}=t,o=xh(JM,r),c=Zxe(JM,r),{onThumbPositionChange:a}=c,f=Zn(e,v=>c.onThumbChange(v)),p=N.useRef(void 0),y=z3(()=>{p.current&&(p.current(),p.current=void 0)},100);return N.useEffect(()=>{const v=o.viewport;if(v){const S=()=>{if(y(),!p.current){const E=OVe(v,a);p.current=E,a()}};return a(),v.addEventListener("scroll",S),()=>v.removeEventListener("scroll",S)}},[o.viewport,y,a]),i.jsx(nn.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:Fr(t.onPointerDownCapture,v=>{const E=v.target.getBoundingClientRect(),k=v.clientX-E.left,R=v.clientY-E.top;c.onThumbPointerDown({x:k,y:R})}),onPointerUp:Fr(t.onPointerUp,c.onThumbPointerUp)})});Qxe.displayName=JM;var G7="ScrollAreaCorner",Jxe=N.forwardRef((t,e)=>{const r=xh(G7,t.__scopeScrollArea),n=!!(r.scrollbarX&&r.scrollbarY);return r.type!=="scroll"&&n?i.jsx(MVe,{...t,ref:e}):null});Jxe.displayName=G7;var MVe=N.forwardRef((t,e)=>{const{__scopeScrollArea:r,...n}=t,s=xh(G7,r),[o,c]=N.useState(0),[a,f]=N.useState(0),p=!!(o&&a);return yS(s.scrollbarX,()=>{var v;const y=((v=s.scrollbarX)==null?void 0:v.offsetHeight)||0;s.onCornerHeightChange(y),f(y)}),yS(s.scrollbarY,()=>{var v;const y=((v=s.scrollbarY)==null?void 0:v.offsetWidth)||0;s.onCornerWidthChange(y),c(y)}),p?i.jsx(nn.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 eD(t){return t?parseInt(t,10):0}function e0e(t,e){const r=t/e;return isNaN(r)?0:r}function $3(t){const e=e0e(t.viewport,t.content),r=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,n=(t.scrollbar.size-r)*e;return Math.max(n,18)}function DVe(t,e,r,n="ltr"){const s=$3(r),o=s/2,c=e||o,a=s-c,f=r.scrollbar.paddingStart+c,p=r.scrollbar.size-r.scrollbar.paddingEnd-a,y=r.content-r.viewport,v=n==="ltr"?[0,y]:[y*-1,0];return t0e([f,p],v)(t)}function gre(t,e,r="ltr"){const n=$3(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],p=fk(t,f);return t0e([0,c],[0,a])(p)}function t0e(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 r0e(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 z3(t,e){const r=_o(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 yS(t,e){const r=_o(e);Do(()=>{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 n0e=Hxe,FVe=Kxe,BVe=Jxe;const Um=N.forwardRef(({className:t,children:e,...r},n)=>i.jsxs(n0e,{ref:n,className:qt("relative overflow-hidden",t),...r,children:[i.jsx(FVe,{className:"h-full w-full rounded-[inherit]",children:e}),i.jsx(s0e,{}),i.jsx(BVe,{})]}));Um.displayName=n0e.displayName;const s0e=N.forwardRef(({className:t,orientation:e="vertical",...r},n)=>i.jsx(V7,{ref:n,orientation:e,className:qt("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(Qxe,{className:"relative flex-1 rounded-full bg-border"})}));s0e.displayName=V7.displayName;const $Ve="/assets/levelup-logo-Eif24dqY.png",zVe="/assets/levelup-logo-icon-C-7iromj.png",UVe="/assets/levelup-logo-mobile-B9skSjUG.png";var HN=t=>t.type==="checkbox",Rv=t=>t instanceof Date,Zc=t=>t==null;const i0e=t=>typeof t=="object";var Mo=t=>!Zc(t)&&!Array.isArray(t)&&i0e(t)&&!Rv(t),a0e=t=>Mo(t)&&t.target?HN(t.target)?t.target.checked:t.target.value:t,VVe=t=>t.substring(0,t.search(/\.\d+(\.|$)/))||t,o0e=(t,e)=>t.has(VVe(e)),qVe=t=>{const e=t.constructor&&t.constructor.prototype;return Mo(e)&&e.hasOwnProperty("isPrototypeOf")},H7=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function ol(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(!(H7&&(t instanceof Blob||n))&&(r||Mo(t)))if(e=r?[]:{},!r&&!qVe(t))e=t;else for(const s in t)t.hasOwnProperty(s)&&(e[s]=ol(t[s]));else return t;return e}var U3=t=>/^\w*$/.test(t),No=t=>t===void 0,W7=t=>Array.isArray(t)?t.filter(Boolean):[],K7=t=>W7(t.replace(/["|']|\]/g,"").split(/\.|\[/)),hn=(t,e,r)=>{if(!e||!Mo(t))return r;const n=(U3(e)?[e]:K7(e)).reduce((s,o)=>Zc(s)?s:s[o],t);return No(n)||n===t?No(t[e])?r:t[e]:n},ld=t=>typeof t=="boolean",$i=(t,e,r)=>{let n=-1;const s=U3(e)?[e]:K7(e),o=s.length,c=o-1;for(;++nXe.useContext(Y7),GVe=t=>{const{children:e,...r}=t;return Xe.createElement(Y7.Provider,{value:r},e)};var l0e=(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]!==sf.all&&(e._proxyFormState[c]=!n||sf.all),r&&(r[c]=!0),t[c]}});return s};const Z7=typeof window<"u"?Xe.useLayoutEffect:Xe.useEffect;function HVe(t){const e=V3(),{control:r=e.control,disabled:n,name:s,exact:o}=t||{},[c,a]=Xe.useState(r._formState),f=Xe.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return Z7(()=>r._subscribe({name:s,formState:f.current,exact:o,callback:p=>{!n&&a({...r._formState,...p})}}),[s,n,o]),Xe.useEffect(()=>{f.current.isValid&&r._setValid(!0)},[r]),Xe.useMemo(()=>l0e(c,r,f.current,!1),[c,r])}var pm=t=>typeof t=="string",c0e=(t,e,r,n,s)=>pm(t)?(n&&e.watch.add(t),hn(r,t,s)):Array.isArray(t)?t.map(o=>(n&&e.watch.add(o),hn(r,o))):(n&&(e.watchAll=!0),r),HV=t=>Zc(t)||!i0e(t);function zp(t,e,r=new WeakSet){if(HV(t)||HV(e))return t===e;if(Rv(t)&&Rv(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(Rv(c)&&Rv(a)||Mo(c)&&Mo(a)||Array.isArray(c)&&Array.isArray(a)?!zp(c,a,r):c!==a)return!1}}return!0}function WVe(t){const e=V3(),{control:r=e.control,name:n,defaultValue:s,disabled:o,exact:c,compute:a}=t||{},f=Xe.useRef(s),p=Xe.useRef(a),y=Xe.useRef(void 0);p.current=a;const v=Xe.useMemo(()=>r._getWatch(n,f.current),[r,n]),[S,E]=Xe.useState(p.current?p.current(v):v);return Z7(()=>r._subscribe({name:n,formState:{values:!0},exact:c,callback:k=>{if(!o){const R=c0e(n,r._names,k.values||r._formValues,!1,f.current);if(p.current){const P=p.current(R);zp(P,y.current)||(E(P),y.current=P)}else E(R)}}}),[r,o,n,c]),Xe.useEffect(()=>r._removeUnmounted()),S}function KVe(t){const e=V3(),{name:r,disabled:n,control:s=e.control,shouldUnregister:o,defaultValue:c}=t,a=o0e(s._names.array,r),f=Xe.useMemo(()=>hn(s._formValues,r,hn(s._defaultValues,r,c)),[s,r,c]),p=WVe({control:s,name:r,defaultValue:f,exact:!0}),y=HVe({control:s,name:r,exact:!0}),v=Xe.useRef(t),S=Xe.useRef(s.register(r,{...t.rules,value:p,...ld(t.disabled)?{disabled:t.disabled}:{}}));v.current=t;const E=Xe.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!hn(y.errors,r)},isDirty:{enumerable:!0,get:()=>!!hn(y.dirtyFields,r)},isTouched:{enumerable:!0,get:()=>!!hn(y.touchedFields,r)},isValidating:{enumerable:!0,get:()=>!!hn(y.validatingFields,r)},error:{enumerable:!0,get:()=>hn(y.errors,r)}}),[y,r]),k=Xe.useCallback(D=>S.current.onChange({target:{value:a0e(D),name:r},type:tD.CHANGE}),[r]),R=Xe.useCallback(()=>S.current.onBlur({target:{value:hn(s._formValues,r),name:r},type:tD.BLUR}),[r,s._formValues]),P=Xe.useCallback(D=>{const B=hn(s._fields,r);B&&D&&(B._f.ref={focus:()=>D.focus&&D.focus(),select:()=>D.select&&D.select(),setCustomValidity:V=>D.setCustomValidity(V),reportValidity:()=>D.reportValidity()})},[s._fields,r]),M=Xe.useMemo(()=>({name:r,value:p,...ld(n)||y.disabled?{disabled:y.disabled||n}:{},onChange:k,onBlur:R,ref:P}),[r,n,y.disabled,k,R,P,p]);return Xe.useEffect(()=>{const D=s._options.shouldUnregister||o;s.register(r,{...v.current.rules,...ld(v.current.disabled)?{disabled:v.current.disabled}:{}});const B=(V,G)=>{const W=hn(s._fields,V);W&&W._f&&(W._f.mount=G)};if(B(r,!0),D){const V=ol(hn(s._options.defaultValues,r));$i(s._defaultValues,r,V),No(hn(s._formValues,r))&&$i(s._formValues,r,V)}return!a&&s.register(r),()=>{(a?D&&!s._state.action:D)?s.unregister(r):B(r,!1)}},[r,s,a,o]),Xe.useEffect(()=>{s._setDisabledField({disabled:n,name:r})},[n,r,s]),Xe.useMemo(()=>({field:M,formState:y,fieldState:E}),[M,y,E])}const YVe=t=>t.render(KVe(t));var u0e=(t,e,r,n,s)=>e?{...r[t],types:{...r[t]&&r[t].types?r[t].types:{},[n]:s||!0}}:{},gA=t=>Array.isArray(t)?t:[t],yre=()=>{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=[]}}},ju=t=>Mo(t)&&!Object.keys(t).length,X7=t=>t.type==="file",af=t=>typeof t=="function",rD=t=>{if(!H7)return!1;const e=t?t.ownerDocument:0;return t instanceof(e&&e.defaultView?e.defaultView.HTMLElement:HTMLElement)},d0e=t=>t.type==="select-multiple",Q7=t=>t.type==="radio",ZVe=t=>Q7(t)||HN(t),Z$=t=>rD(t)&&t.isConnected;function XVe(t,e){const r=e.slice(0,-1).length;let n=0;for(;n{for(const e in t)if(af(t[e]))return!0;return!1};function nD(t,e={}){const r=Array.isArray(t);if(Mo(t)||r)for(const n in t)Array.isArray(t[n])||Mo(t[n])&&!h0e(t[n])?(e[n]=Array.isArray(t[n])?[]:{},nD(t[n],e[n])):Zc(t[n])||(e[n]=!0);return e}function f0e(t,e,r){const n=Array.isArray(t);if(Mo(t)||n)for(const s in t)Array.isArray(t[s])||Mo(t[s])&&!h0e(t[s])?No(e)||HV(r[s])?r[s]=Array.isArray(t[s])?nD(t[s],[]):{...nD(t[s])}:f0e(t[s],Zc(e)?{}:e[s],r[s]):r[s]=!zp(t[s],e[s]);return r}var p2=(t,e)=>f0e(t,e,nD(e));const xre={value:!1,isValid:!1},vre={value:!0,isValid:!0};var m0e=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&&!No(t[0].attributes.value)?No(t[0].value)||t[0].value===""?vre:{value:t[0].value,isValid:!0}:vre:xre}return xre},p0e=(t,{valueAsNumber:e,valueAsDate:r,setValueAs:n})=>No(t)?t:e?t===""?NaN:t&&+t:r&&pm(t)?new Date(t):n?n(t):t;const _re={isValid:!1,value:null};var g0e=t=>Array.isArray(t)?t.reduce((e,r)=>r&&r.checked&&!r.disabled?{isValid:!0,value:r.value}:e,_re):_re;function bre(t){const e=t.ref;return X7(e)?e.files:Q7(e)?g0e(t.refs).value:d0e(e)?[...e.selectedOptions].map(({value:r})=>r):HN(e)?m0e(t.refs).value:p0e(No(e.value)?t.ref.value:e.value,t)}var JVe=(t,e,r,n)=>{const s={};for(const o of t){const c=hn(e,o);c&&$i(s,o,c._f)}return{criteriaMode:r,names:[...t],fields:s,shouldUseNativeValidation:n}},sD=t=>t instanceof RegExp,g2=t=>No(t)?t:sD(t)?t.source:Mo(t)?sD(t.value)?t.value.source:t.value:t,wre=t=>({isOnSubmit:!t||t===sf.onSubmit,isOnBlur:t===sf.onBlur,isOnChange:t===sf.onChange,isOnAll:t===sf.all,isOnTouch:t===sf.onTouched});const Sre="AsyncFunction";var e8e=t=>!!t&&!!t.validate&&!!(af(t.validate)&&t.validate.constructor.name===Sre||Mo(t.validate)&&Object.values(t.validate).find(e=>e.constructor.name===Sre)),t8e=t=>t.mount&&(t.required||t.min||t.max||t.maxLength||t.minLength||t.pattern||t.validate),Tre=(t,e,r)=>!r&&(e.watchAll||e.watch.has(t)||[...e.watch].some(n=>t.startsWith(n)&&/^\.\w+/.test(t.slice(n.length))));const yA=(t,e,r,n)=>{for(const s of r||Object.keys(t)){const o=hn(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(yA(a,e))break}else if(Mo(a)&&yA(a,e))break}}};function Ere(t,e,r){const n=hn(t,r);if(n||U3(r))return{error:n,name:r};const s=r.split(".");for(;s.length;){const o=s.join("."),c=hn(e,o),a=hn(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 r8e=(t,e,r,n)=>{r(t);const{name:s,...o}=t;return ju(o)||Object.keys(o).length>=Object.keys(e).length||Object.keys(o).find(c=>e[c]===(!n||sf.all))},n8e=(t,e,r)=>!t||!e||t===e||gA(t).some(n=>n&&(r?n===e:n.startsWith(e)||e.startsWith(n))),s8e=(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,i8e=(t,e)=>!W7(hn(t,e)).length&&qo(t,e),a8e=(t,e,r)=>{const n=gA(hn(t,r));return $i(n,"root",e[r]),$i(t,r,n),t},DL=t=>pm(t);function jre(t,e,r="validate"){if(DL(t)||Array.isArray(t)&&t.every(DL)||ld(t)&&!t)return{type:r,message:DL(t)?t:"",ref:e}}var Ew=t=>Mo(t)&&!sD(t)?t:{value:t,message:""},Are=async(t,e,r,n,s,o)=>{const{ref:c,refs:a,required:f,maxLength:p,minLength:y,min:v,max:S,pattern:E,validate:k,name:R,valueAsNumber:P,mount:M}=t._f,D=hn(r,R);if(!M||e.has(R))return{};const B=a?a[0]:c,V=pe=>{s&&B.reportValidity&&(B.setCustomValidity(ld(pe)?"":pe||""),B.reportValidity())},G={},W=Q7(c),Y=HN(c),J=W||Y,Q=(P||X7(c))&&No(c.value)&&No(D)||rD(c)&&c.value===""||D===""||Array.isArray(D)&&!D.length,ee=u0e.bind(null,R,n,G),le=(pe,Te,Ae,Le=Tp.maxLength,ke=Tp.minLength)=>{const we=pe?Te:Ae;G[R]={type:pe?Le:ke,message:we,ref:c,...ee(pe?Le:ke,we)}};if(o?!Array.isArray(D)||!D.length:f&&(!J&&(Q||Zc(D))||ld(D)&&!D||Y&&!m0e(a).isValid||W&&!g0e(a).isValid)){const{value:pe,message:Te}=DL(f)?{value:!!f,message:f}:Ew(f);if(pe&&(G[R]={type:Tp.required,message:Te,ref:B,...ee(Tp.required,Te)},!n))return V(Te),G}if(!Q&&(!Zc(v)||!Zc(S))){let pe,Te;const Ae=Ew(S),Le=Ew(v);if(!Zc(D)&&!isNaN(D)){const ke=c.valueAsNumber||D&&+D;Zc(Ae.value)||(pe=ke>Ae.value),Zc(Le.value)||(Te=kenew Date(new Date().toDateString()+" "+_e),me=c.type=="time",je=c.type=="week";pm(Ae.value)&&D&&(pe=me?we(D)>we(Ae.value):je?D>Ae.value:ke>new Date(Ae.value)),pm(Le.value)&&D&&(Te=me?we(D)+pe.value,Le=!Zc(Te.value)&&D.length<+Te.value;if((Ae||Le)&&(le(Ae,pe.message,Te.message),!n))return V(G[R].message),G}if(E&&!Q&&pm(D)){const{value:pe,message:Te}=Ew(E);if(sD(pe)&&!D.match(pe)&&(G[R]={type:Tp.pattern,message:Te,ref:c,...ee(Tp.pattern,Te)},!n))return V(Te),G}if(k){if(af(k)){const pe=await k(D,r),Te=jre(pe,B);if(Te&&(G[R]={...Te,...ee(Tp.validate,Te.message)},!n))return V(Te.message),G}else if(Mo(k)){let pe={};for(const Te in k){if(!ju(pe)&&!n)break;const Ae=jre(await k[Te](D,r),B,Te);Ae&&(pe={...Ae,...ee(Te,Ae.message)},V(Ae.message),n&&(G[R]=pe))}if(!ju(pe)&&(G[R]={ref:B,...pe},!n))return G}}return V(!0),G};const o8e={mode:sf.onSubmit,reValidateMode:sf.onChange,shouldFocusError:!0};function l8e(t={}){let e={...o8e,...t},r={submitCount:0,isDirty:!1,isReady:!1,isLoading:af(e.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1},n={},s=Mo(e.defaultValues)||Mo(e.values)?ol(e.defaultValues||e.values)||{}:{},o=e.shouldUnregister?{}:ol(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,p=0;const y={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1};let v={...y};const S={array:yre(),state:yre()},E=e.criteriaMode===sf.all,k=Je=>St=>{clearTimeout(p),p=setTimeout(Je,St)},R=async Je=>{if(!e.disabled&&(y.isValid||v.isValid||Je)){const St=e.resolver?ju((await Y()).errors):await Q(n,!0);St!==r.isValid&&S.state.next({isValid:St})}},P=(Je,St)=>{!e.disabled&&(y.isValidating||y.validatingFields||v.isValidating||v.validatingFields)&&((Je||Array.from(a.mount)).forEach(Jt=>{Jt&&(St?$i(r.validatingFields,Jt,St):qo(r.validatingFields,Jt))}),S.state.next({validatingFields:r.validatingFields,isValidating:!ju(r.validatingFields)}))},M=(Je,St=[],Jt,Ir,ur=!0,ar=!0)=>{if(Ir&&Jt&&!e.disabled){if(c.action=!0,ar&&Array.isArray(hn(n,Je))){const It=Jt(hn(n,Je),Ir.argA,Ir.argB);ur&&$i(n,Je,It)}if(ar&&Array.isArray(hn(r.errors,Je))){const It=Jt(hn(r.errors,Je),Ir.argA,Ir.argB);ur&&$i(r.errors,Je,It),i8e(r.errors,Je)}if((y.touchedFields||v.touchedFields)&&ar&&Array.isArray(hn(r.touchedFields,Je))){const It=Jt(hn(r.touchedFields,Je),Ir.argA,Ir.argB);ur&&$i(r.touchedFields,Je,It)}(y.dirtyFields||v.dirtyFields)&&(r.dirtyFields=p2(s,o)),S.state.next({name:Je,isDirty:le(Je,St),dirtyFields:r.dirtyFields,errors:r.errors,isValid:r.isValid})}else $i(o,Je,St)},D=(Je,St)=>{$i(r.errors,Je,St),S.state.next({errors:r.errors})},B=Je=>{r.errors=Je,S.state.next({errors:r.errors,isValid:!1})},V=(Je,St,Jt,Ir)=>{const ur=hn(n,Je);if(ur){const ar=hn(o,Je,No(Jt)?hn(s,Je):Jt);No(ar)||Ir&&Ir.defaultChecked||St?$i(o,Je,St?ar:bre(ur._f)):Ae(Je,ar),c.mount&&R()}},G=(Je,St,Jt,Ir,ur)=>{let ar=!1,It=!1;const pr={name:Je};if(!e.disabled){if(!Jt||Ir){(y.isDirty||v.isDirty)&&(It=r.isDirty,r.isDirty=pr.isDirty=le(),ar=It!==pr.isDirty);const Tn=zp(hn(s,Je),St);It=!!hn(r.dirtyFields,Je),Tn?qo(r.dirtyFields,Je):$i(r.dirtyFields,Je,!0),pr.dirtyFields=r.dirtyFields,ar=ar||(y.dirtyFields||v.dirtyFields)&&It!==!Tn}if(Jt){const Tn=hn(r.touchedFields,Je);Tn||($i(r.touchedFields,Je,Jt),pr.touchedFields=r.touchedFields,ar=ar||(y.touchedFields||v.touchedFields)&&Tn!==Jt)}ar&&ur&&S.state.next(pr)}return ar?pr:{}},W=(Je,St,Jt,Ir)=>{const ur=hn(r.errors,Je),ar=(y.isValid||v.isValid)&&ld(St)&&r.isValid!==St;if(e.delayError&&Jt?(f=k(()=>D(Je,Jt)),f(e.delayError)):(clearTimeout(p),f=null,Jt?$i(r.errors,Je,Jt):qo(r.errors,Je)),(Jt?!zp(ur,Jt):ur)||!ju(Ir)||ar){const It={...Ir,...ar&&ld(St)?{isValid:St}:{},errors:r.errors,name:Je};r={...r,...It},S.state.next(It)}},Y=async Je=>{P(Je,!0);const St=await e.resolver(o,e.context,JVe(Je||a.mount,n,e.criteriaMode,e.shouldUseNativeValidation));return P(Je),St},J=async Je=>{const{errors:St}=await Y(Je);if(Je)for(const Jt of Je){const Ir=hn(St,Jt);Ir?$i(r.errors,Jt,Ir):qo(r.errors,Jt)}else r.errors=St;return St},Q=async(Je,St,Jt={valid:!0})=>{for(const Ir in Je){const ur=Je[Ir];if(ur){const{_f:ar,...It}=ur;if(ar){const pr=a.array.has(ar.name),Tn=ur._f&&e8e(ur._f);Tn&&y.validatingFields&&P([Ir],!0);const ss=await Are(ur,a.disabled,o,E,e.shouldUseNativeValidation&&!St,pr);if(Tn&&y.validatingFields&&P([Ir]),ss[ar.name]&&(Jt.valid=!1,St))break;!St&&(hn(ss,ar.name)?pr?a8e(r.errors,ss,ar.name):$i(r.errors,ar.name,ss[ar.name]):qo(r.errors,ar.name))}!ju(It)&&await Q(It,St,Jt)}}return Jt.valid},ee=()=>{for(const Je of a.unMount){const St=hn(n,Je);St&&(St._f.refs?St._f.refs.every(Jt=>!Z$(Jt)):!Z$(St._f.ref))&&vt(Je)}a.unMount=new Set},le=(Je,St)=>!e.disabled&&(Je&&St&&$i(o,Je,St),!zp(_e(),s)),pe=(Je,St,Jt)=>c0e(Je,a,{...c.mount?o:No(St)?s:pm(Je)?{[Je]:St}:St},Jt,St),Te=Je=>W7(hn(c.mount?o:s,Je,e.shouldUnregister?hn(s,Je,[]):[])),Ae=(Je,St,Jt={})=>{const Ir=hn(n,Je);let ur=St;if(Ir){const ar=Ir._f;ar&&(!ar.disabled&&$i(o,Je,p0e(St,ar)),ur=rD(ar.ref)&&Zc(St)?"":St,d0e(ar.ref)?[...ar.ref.options].forEach(It=>It.selected=ur.includes(It.value)):ar.refs?HN(ar.ref)?ar.refs.forEach(It=>{(!It.defaultChecked||!It.disabled)&&(Array.isArray(ur)?It.checked=!!ur.find(pr=>pr===It.value):It.checked=ur===It.value||!!ur)}):ar.refs.forEach(It=>It.checked=It.value===ur):X7(ar.ref)?ar.ref.value="":(ar.ref.value=ur,ar.ref.type||S.state.next({name:Je,values:ol(o)})))}(Jt.shouldDirty||Jt.shouldTouch)&&G(Je,ur,Jt.shouldTouch,Jt.shouldDirty,!0),Jt.shouldValidate&&je(Je)},Le=(Je,St,Jt)=>{for(const Ir in St){if(!St.hasOwnProperty(Ir))return;const ur=St[Ir],ar=Je+"."+Ir,It=hn(n,ar);(a.array.has(Je)||Mo(ur)||It&&!It._f)&&!Rv(ur)?Le(ar,ur,Jt):Ae(ar,ur,Jt)}},ke=(Je,St,Jt={})=>{const Ir=hn(n,Je),ur=a.array.has(Je),ar=ol(St);$i(o,Je,ar),ur?(S.array.next({name:Je,values:ol(o)}),(y.isDirty||y.dirtyFields||v.isDirty||v.dirtyFields)&&Jt.shouldDirty&&S.state.next({name:Je,dirtyFields:p2(s,o),isDirty:le(Je,ar)})):Ir&&!Ir._f&&!Zc(ar)?Le(Je,ar,Jt):Ae(Je,ar,Jt),Tre(Je,a)&&S.state.next({...r,name:Je}),S.state.next({name:c.mount?Je:void 0,values:ol(o)})},we=async Je=>{c.mount=!0;const St=Je.target;let Jt=St.name,Ir=!0;const ur=hn(n,Jt),ar=Tn=>{Ir=Number.isNaN(Tn)||Rv(Tn)&&isNaN(Tn.getTime())||zp(Tn,hn(o,Jt,Tn))},It=wre(e.mode),pr=wre(e.reValidateMode);if(ur){let Tn,ss;const is=St.type?bre(ur._f):a0e(Je),Us=Je.type===tD.BLUR||Je.type===tD.FOCUS_OUT,Ea=!t8e(ur._f)&&!e.resolver&&!hn(r.errors,Jt)&&!ur._f.deps||s8e(Us,hn(r.touchedFields,Jt),r.isSubmitted,pr,It),vs=Tre(Jt,a,Us);$i(o,Jt,is),Us?(ur._f.onBlur&&ur._f.onBlur(Je),f&&f(0)):ur._f.onChange&&ur._f.onChange(Je);const ua=G(Jt,is,Us),Nr=!ju(ua)||vs;if(!Us&&S.state.next({name:Jt,type:Je.type,values:ol(o)}),Ea)return(y.isValid||v.isValid)&&(e.mode==="onBlur"?Us&&R():Us||R()),Nr&&S.state.next({name:Jt,...vs?{}:ua});if(!Us&&vs&&S.state.next({...r}),e.resolver){const{errors:qn}=await Y([Jt]);if(ar(is),Ir){const Yi=Ere(r.errors,n,Jt),ja=Ere(qn,n,Yi.name||Jt);Tn=ja.error,Jt=ja.name,ss=ju(qn)}}else P([Jt],!0),Tn=(await Are(ur,a.disabled,o,E,e.shouldUseNativeValidation))[Jt],P([Jt]),ar(is),Ir&&(Tn?ss=!1:(y.isValid||v.isValid)&&(ss=await Q(n,!0)));Ir&&(ur._f.deps&&je(ur._f.deps),W(Jt,ss,Tn,ua))}},me=(Je,St)=>{if(hn(r.errors,St)&&Je.focus)return Je.focus(),1},je=async(Je,St={})=>{let Jt,Ir;const ur=gA(Je);if(e.resolver){const ar=await J(No(Je)?Je:ur);Jt=ju(ar),Ir=Je?!ur.some(It=>hn(ar,It)):Jt}else Je?(Ir=(await Promise.all(ur.map(async ar=>{const It=hn(n,ar);return await Q(It&&It._f?{[ar]:It}:It)}))).every(Boolean),!(!Ir&&!r.isValid)&&R()):Ir=Jt=await Q(n);return S.state.next({...!pm(Je)||(y.isValid||v.isValid)&&Jt!==r.isValid?{}:{name:Je},...e.resolver||!Je?{isValid:Jt}:{},errors:r.errors}),St.shouldFocus&&!Ir&&yA(n,me,Je?ur:a.mount),Ir},_e=Je=>{const St={...c.mount?o:s};return No(Je)?St:pm(Je)?hn(St,Je):Je.map(Jt=>hn(St,Jt))},Ee=(Je,St)=>({invalid:!!hn((St||r).errors,Je),isDirty:!!hn((St||r).dirtyFields,Je),error:hn((St||r).errors,Je),isValidating:!!hn(r.validatingFields,Je),isTouched:!!hn((St||r).touchedFields,Je)}),ve=Je=>{Je&&gA(Je).forEach(St=>qo(r.errors,St)),S.state.next({errors:Je?r.errors:{}})},qe=(Je,St,Jt)=>{const Ir=(hn(n,Je,{_f:{}})._f||{}).ref,ur=hn(r.errors,Je)||{},{ref:ar,message:It,type:pr,...Tn}=ur;$i(r.errors,Je,{...Tn,...St,ref:Ir}),S.state.next({name:Je,errors:r.errors,isValid:!1}),Jt&&Jt.shouldFocus&&Ir&&Ir.focus&&Ir.focus()},nt=(Je,St)=>af(Je)?S.state.subscribe({next:Jt=>"values"in Jt&&Je(pe(void 0,St),Jt)}):pe(Je,St,!0),ot=Je=>S.state.subscribe({next:St=>{n8e(Je.name,St.name,Je.exact)&&r8e(St,Je.formState||y,yr,Je.reRenderRoot)&&Je.callback({values:{...o},...r,...St,defaultValues:s})}}).unsubscribe,jt=Je=>(c.mount=!0,v={...v,...Je.formState},ot({...Je,formState:v})),vt=(Je,St={})=>{for(const Jt of Je?gA(Je):a.mount)a.mount.delete(Jt),a.array.delete(Jt),St.keepValue||(qo(n,Jt),qo(o,Jt)),!St.keepError&&qo(r.errors,Jt),!St.keepDirty&&qo(r.dirtyFields,Jt),!St.keepTouched&&qo(r.touchedFields,Jt),!St.keepIsValidating&&qo(r.validatingFields,Jt),!e.shouldUnregister&&!St.keepDefaultValue&&qo(s,Jt);S.state.next({values:ol(o)}),S.state.next({...r,...St.keepDirty?{isDirty:le()}:{}}),!St.keepIsValid&&R()},Gt=({disabled:Je,name:St})=>{(ld(Je)&&c.mount||Je||a.disabled.has(St))&&(Je?a.disabled.add(St):a.disabled.delete(St))},pt=(Je,St={})=>{let Jt=hn(n,Je);const Ir=ld(St.disabled)||ld(e.disabled);return $i(n,Je,{...Jt||{},_f:{...Jt&&Jt._f?Jt._f:{ref:{name:Je}},name:Je,mount:!0,...St}}),a.mount.add(Je),Jt?Gt({disabled:ld(St.disabled)?St.disabled:e.disabled,name:Je}):V(Je,!0,St.value),{...Ir?{disabled:St.disabled||e.disabled}:{},...e.progressive?{required:!!St.required,min:g2(St.min),max:g2(St.max),minLength:g2(St.minLength),maxLength:g2(St.maxLength),pattern:g2(St.pattern)}:{},name:Je,onChange:we,onBlur:we,ref:ur=>{if(ur){pt(Je,St),Jt=hn(n,Je);const ar=No(ur.value)&&ur.querySelectorAll&&ur.querySelectorAll("input,select,textarea")[0]||ur,It=ZVe(ar),pr=Jt._f.refs||[];if(It?pr.find(Tn=>Tn===ar):ar===Jt._f.ref)return;$i(n,Je,{_f:{...Jt._f,...It?{refs:[...pr.filter(Z$),ar,...Array.isArray(hn(s,Je))?[{}]:[]],ref:{type:ar.type,name:Je}}:{ref:ar}}}),V(Je,!1,void 0,ar)}else Jt=hn(n,Je,{}),Jt._f&&(Jt._f.mount=!1),(e.shouldUnregister||St.shouldUnregister)&&!(o0e(a.array,Je)&&c.action)&&a.unMount.add(Je)}}},Ct=()=>e.shouldFocusError&&yA(n,me,a.mount),tr=Je=>{ld(Je)&&(S.state.next({disabled:Je}),yA(n,(St,Jt)=>{const Ir=hn(n,Jt);Ir&&(St.disabled=Ir._f.disabled||Je,Array.isArray(Ir._f.refs)&&Ir._f.refs.forEach(ur=>{ur.disabled=Ir._f.disabled||Je}))},0,!1))},wt=(Je,St)=>async Jt=>{let Ir;Jt&&(Jt.preventDefault&&Jt.preventDefault(),Jt.persist&&Jt.persist());let ur=ol(o);if(S.state.next({isSubmitting:!0}),e.resolver){const{errors:ar,values:It}=await Y();r.errors=ar,ur=ol(It)}else await Q(n);if(a.disabled.size)for(const ar of a.disabled)qo(ur,ar);if(qo(r.errors,"root"),ju(r.errors)){S.state.next({errors:{}});try{await Je(ur,Jt)}catch(ar){Ir=ar}}else St&&await St({...r.errors},Jt),Ct(),setTimeout(Ct);if(S.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:ju(r.errors)&&!Ir,submitCount:r.submitCount+1,errors:r.errors}),Ir)throw Ir},lr=(Je,St={})=>{hn(n,Je)&&(No(St.defaultValue)?ke(Je,ol(hn(s,Je))):(ke(Je,St.defaultValue),$i(s,Je,ol(St.defaultValue))),St.keepTouched||qo(r.touchedFields,Je),St.keepDirty||(qo(r.dirtyFields,Je),r.isDirty=St.defaultValue?le(Je,ol(hn(s,Je))):le()),St.keepError||(qo(r.errors,Je),y.isValid&&R()),S.state.next({...r}))},Sr=(Je,St={})=>{const Jt=Je?ol(Je):s,Ir=ol(Jt),ur=ju(Je),ar=ur?s:Ir;if(St.keepDefaultValues||(s=Jt),!St.keepValues){if(St.keepDirtyValues){const It=new Set([...a.mount,...Object.keys(p2(s,o))]);for(const pr of Array.from(It))hn(r.dirtyFields,pr)?$i(ar,pr,hn(o,pr)):ke(pr,hn(ar,pr))}else{if(H7&&No(Je))for(const It of a.mount){const pr=hn(n,It);if(pr&&pr._f){const Tn=Array.isArray(pr._f.refs)?pr._f.refs[0]:pr._f.ref;if(rD(Tn)){const ss=Tn.closest("form");if(ss){ss.reset();break}}}}if(St.keepFieldsRef)for(const It of a.mount)ke(It,hn(ar,It));else n={}}o=e.shouldUnregister?St.keepDefaultValues?ol(s):{}:ol(ar),S.array.next({values:{...ar}}),S.state.next({values:{...ar}})}a={mount:St.keepDirtyValues?a.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},c.mount=!y.isValid||!!St.keepIsValid||!!St.keepDirtyValues,c.watch=!!e.shouldUnregister,S.state.next({submitCount:St.keepSubmitCount?r.submitCount:0,isDirty:ur?!1:St.keepDirty?r.isDirty:!!(St.keepDefaultValues&&!zp(Je,s)),isSubmitted:St.keepIsSubmitted?r.isSubmitted:!1,dirtyFields:ur?{}:St.keepDirtyValues?St.keepDefaultValues&&o?p2(s,o):r.dirtyFields:St.keepDefaultValues&&Je?p2(s,Je):St.keepDirty?r.dirtyFields:{},touchedFields:St.keepTouched?r.touchedFields:{},errors:St.keepErrors?r.errors:{},isSubmitSuccessful:St.keepIsSubmitSuccessful?r.isSubmitSuccessful:!1,isSubmitting:!1})},sn=(Je,St)=>Sr(af(Je)?Je(o):Je,St),cr=(Je,St={})=>{const Jt=hn(n,Je),Ir=Jt&&Jt._f;if(Ir){const ur=Ir.refs?Ir.refs[0]:Ir.ref;ur.focus&&(ur.focus(),St.shouldSelect&&af(ur.select)&&ur.select())}},yr=Je=>{r={...r,...Je}},jn={control:{register:pt,unregister:vt,getFieldState:Ee,handleSubmit:wt,setError:qe,_subscribe:ot,_runSchema:Y,_focusError:Ct,_getWatch:pe,_getDirty:le,_setValid:R,_setFieldArray:M,_setDisabledField:Gt,_setErrors:B,_getFieldArray:Te,_reset:Sr,_resetDefaultValues:()=>af(e.defaultValues)&&e.defaultValues().then(Je=>{sn(Je,e.resetOptions),S.state.next({isLoading:!1})}),_removeUnmounted:ee,_disableForm:tr,_subjects:S,_proxyFormState:y,get _fields(){return n},get _formValues(){return o},get _state(){return c},set _state(Je){c=Je},get _defaultValues(){return s},get _names(){return a},set _names(Je){a=Je},get _formState(){return r},get _options(){return e},set _options(Je){e={...e,...Je}}},subscribe:jt,trigger:je,register:pt,handleSubmit:wt,watch:nt,setValue:ke,getValues:_e,reset:sn,resetField:lr,clearErrors:ve,unregister:vt,setError:qe,setFocus:cr,getFieldState:Ee};return{...jn,formControl:jn}}function J7(t={}){const e=Xe.useRef(void 0),r=Xe.useRef(void 0),[n,s]=Xe.useState({isDirty:!1,isValidating:!1,isLoading:af(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:af(t.defaultValues)?void 0:t.defaultValues});if(!e.current)if(t.formControl)e.current={...t.formControl,formState:n},t.defaultValues&&!af(t.defaultValues)&&t.formControl.reset(t.defaultValues,t.resetOptions);else{const{formControl:c,...a}=l8e(t);e.current={...a,formState:n}}const o=e.current.control;return o._options=t,Z7(()=>{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]),Xe.useEffect(()=>o._disableForm(t.disabled),[o,t.disabled]),Xe.useEffect(()=>{t.mode&&(o._options.mode=t.mode),t.reValidateMode&&(o._options.reValidateMode=t.reValidateMode)},[o,t.mode,t.reValidateMode]),Xe.useEffect(()=>{t.errors&&(o._setErrors(t.errors),o._focusError())},[o,t.errors]),Xe.useEffect(()=>{t.shouldUnregister&&o._subjects.state.next({values:o._getWatch()})},[o,t.shouldUnregister]),Xe.useEffect(()=>{if(o._proxyFormState.isDirty){const c=o._getDirty();c!==n.isDirty&&o._subjects.state.next({isDirty:c})}},[o,n.isDirty]),Xe.useEffect(()=>{t.values&&!zp(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]),Xe.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=l0e(n,o),e.current}const kre=(t,e,r)=>{if(t&&"reportValidity"in t){const n=hn(r,e);t.setCustomValidity(n&&n.message||""),t.reportValidity()}},y0e=(t,e)=>{for(const r in e.fields){const n=e.fields[r];n&&n.ref&&"reportValidity"in n.ref?kre(n.ref,r,t):n.refs&&n.refs.forEach(s=>kre(s,r,t))}},c8e=(t,e)=>{e.shouldUseNativeValidation&&y0e(t,e);const r={};for(const n in t){const s=hn(e.fields,n),o=Object.assign(t[n]||{},{ref:s&&s.ref});if(u8e(e.names||Object.keys(t),n)){const c=Object.assign({},hn(r,n));$i(c,"root",o),$i(r,n,c)}else $i(r,n,o)}return r},u8e=(t,e)=>t.some(r=>r.startsWith(e+"."));var d8e=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(v){return t.push(v)})}),e){var f=r[c].types,p=f&&f[n.code];r[c]=u0e(c,e,r,s,p?[].concat(p,n.message):n.message)}t.shift()}return r},eH=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(p){return o.shouldUseNativeValidation&&y0e({},o),{errors:{},values:r.raw?n:p}})}catch(p){return a(p)}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:c8e(d8e(c.errors,!o.shouldUseNativeValidation&&o.criteriaMode==="all"),o)};throw c}))}catch(c){return Promise.reject(c)}}},Nre;function jr(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 p=c.prototype,y=Object.keys(p);for(let v=0;v{var f,p;return r!=null&&r.Parent&&a instanceof r.Parent?!0:(p=(f=a==null?void 0:a._zod)==null?void 0:f.traits)==null?void 0:p.has(t)}}),Object.defineProperty(c,"name",{value:t}),c}class R1 extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class x0e extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}(Nre=globalThis).__zod_globalConfig??(Nre.__zod_globalConfig={});const tH=globalThis.__zod_globalConfig;function cg(t){return tH}function v0e(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 WV(t,e){return typeof e=="bigint"?e.toString():e}function rH(t){return{get value(){{const e=t();return Object.defineProperty(this,"value",{value:e}),e}}}}function nH(t){return t==null}function sH(t){const e=t.startsWith("^")?1:0,r=t.endsWith("$")?t.length-1:t.length;return t.slice(e,r)}function h8e(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 iD(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}const m8e=rH(()=>{var t;if(tH.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 xS(t){if(iD(t)===!1)return!1;const e=t.constructor;if(e===void 0||typeof e!="function")return!0;const r=e.prototype;return!(iD(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function b0e(t){return xS(t)?{...t}:Array.isArray(t)?[...t]:t instanceof Map?new Map(t):t instanceof Set?new Set(t):t}const p8e=new Set(["string","number","symbol"]);function vS(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function zx(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 Vn(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 g8e(t){return Object.keys(t).filter(e=>t[e]._zod.optin==="optional"&&t[e]._zod.optout==="optional")}const y8e={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 x8e(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=$x(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 M_(this,"shape",c),c},checks:[]});return zx(t,o)}function v8e(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=$x(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 M_(this,"shape",c),c},checks:[]});return zx(t,o)}function _8e(t,e){if(!xS(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=$x(t._zod.def,{get shape(){const o={...t._zod.def.shape,...e};return M_(this,"shape",o),o}});return zx(t,s)}function b8e(t,e){if(!xS(e))throw new Error("Invalid input to safeExtend: expected a plain object");const r=$x(t._zod.def,{get shape(){const n={...t._zod.def.shape,...e};return M_(this,"shape",n),n}});return zx(t,r)}function w8e(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=$x(t._zod.def,{get shape(){const s={...t._zod.def.shape,...e._zod.def.shape};return M_(this,"shape",s),s},get catchall(){return e._zod.def.catchall},checks:e._zod.def.checks??[]});return zx(t,r)}function S8e(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=$x(e._zod.def,{get shape(){const a=e._zod.def.shape,f={...a};if(r)for(const p in r){if(!(p in a))throw new Error(`Unrecognized key: "${p}"`);r[p]&&(f[p]=t?new t({type:"optional",innerType:a[p]}):a[p])}else for(const p in a)f[p]=t?new t({type:"optional",innerType:a[p]}):a[p];return M_(this,"shape",f),f},checks:[]});return zx(e,c)}function T8e(t,e,r){const n=$x(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 M_(this,"shape",o),o}});return zx(e,n)}function l1(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 vR(t){return typeof t=="string"?t:t==null?void 0:t.message}function ug(t,e,r){var f,p,y,v,S,E;const n=t.message?t.message:vR((y=(p=(f=t.inst)==null?void 0:f._zod.def)==null?void 0:p.error)==null?void 0:y.call(p,t))??vR((v=e==null?void 0:e.error)==null?void 0:v.call(e,t))??vR((S=r.customError)==null?void 0:S.call(r,t))??vR((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 iH(t){return Array.isArray(t)?"array":typeof t=="string"?"string":"unknown"}function mk(...t){const[e,r,n]=t;return typeof e=="string"?{message:e,code:"custom",input:r,inst:n}:{...e}}const w0e=(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,WV,2),Object.defineProperty(t,"toString",{value:()=>t.message,enumerable:!1})},S0e=jr("$ZodError",w0e),T0e=jr("$ZodError",w0e,{Parent:Error});function j8e(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 A8e(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,p=0;for(;p(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 R1;if(c.issues.length){const a=new((s==null?void 0:s.Err)??t)(c.issues.map(f=>ug(f,o,cg())));throw _0e(a,s==null?void 0:s.callee),a}return c.value},oH=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=>ug(f,o,cg())));throw _0e(a,s==null?void 0:s.callee),a}return c.value},q3=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 R1;return o.issues.length?{success:!1,error:new(t??S0e)(o.issues.map(c=>ug(c,s,cg())))}:{success:!0,data:o.value}},k8e=q3(T0e),G3=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=>ug(c,s,cg())))}:{success:!0,data:o.value}},N8e=G3(T0e),C8e=t=>(e,r,n)=>{const s=n?{...n,direction:"backward"}:{direction:"backward"};return aH(t)(e,r,s)},I8e=t=>(e,r,n)=>aH(t)(e,r,n),P8e=t=>async(e,r,n)=>{const s=n?{...n,direction:"backward"}:{direction:"backward"};return oH(t)(e,r,s)},R8e=t=>async(e,r,n)=>oH(t)(e,r,n),L8e=t=>(e,r,n)=>{const s=n?{...n,direction:"backward"}:{direction:"backward"};return q3(t)(e,r,s)},M8e=t=>(e,r,n)=>q3(t)(e,r,n),D8e=t=>async(e,r,n)=>{const s=n?{...n,direction:"backward"}:{direction:"backward"};return G3(t)(e,r,s)},O8e=t=>async(e,r,n)=>G3(t)(e,r,n),F8e=/^[cC][0-9a-z]{6,}$/,B8e=/^[0-9a-z]+$/,$8e=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,z8e=/^[0-9a-vA-V]{20}$/,U8e=/^[A-Za-z0-9]{27}$/,V8e=/^[a-zA-Z0-9_-]{21}$/,q8e=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,G8e=/^([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})$/,Pre=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)$/,H8e=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,W8e="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function K8e(){return new RegExp(W8e,"u")}const Y8e=/^(?:(?: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])$/,Z8e=/^(([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}|:))$/,X8e=/^((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])$/,Q8e=/^(([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])$/,J8e=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,E0e=/^[A-Za-z0-9_-]*$/,eqe=/^https?$/,tqe=/^\+[1-9]\d{6,14}$/,j0e="(?:(?:\\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])))",rqe=new RegExp(`^${j0e}$`);function A0e(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 nqe(t){return new RegExp(`^${A0e(t)}$`)}function sqe(t){const e=A0e({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(`^${j0e}T(?:${n})$`)}const iqe=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}$`)},aqe=/^-?\d+$/,k0e=/^-?\d+(?:\.\d+)?$/,oqe=/^(?:true|false)$/i,lqe=/^[^A-Z]*$/,cqe=/^[^a-z]*$/,$u=jr("$ZodCheck",(t,e)=>{var r;t._zod??(t._zod={}),t._zod.def=e,(r=t._zod).onattach??(r.onattach=[])}),N0e={number:"number",bigint:"bigint",object:"date"},C0e=jr("$ZodCheckLessThan",(t,e)=>{$u.init(t,e);const r=N0e[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{$u.init(t,e);const r=N0e[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})}}),uqe=jr("$ZodCheckMultipleOf",(t,e)=>{$u.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):h8e(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})}}),dqe=jr("$ZodCheckNumberFormat",(t,e)=>{var c;$u.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]=y8e[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=aqe)}),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})}}),hqe=jr("$ZodCheckMaxLength",(t,e)=>{var r;$u.init(t,e),(r=t._zod.def).when??(r.when=n=>{const s=n.value;return!nH(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=iH(s);n.issues.push({origin:c,code:"too_big",maximum:e.maximum,inclusive:!0,input:s,inst:t,continue:!e.abort})}}),fqe=jr("$ZodCheckMinLength",(t,e)=>{var r;$u.init(t,e),(r=t._zod.def).when??(r.when=n=>{const s=n.value;return!nH(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=iH(s);n.issues.push({origin:c,code:"too_small",minimum:e.minimum,inclusive:!0,input:s,inst:t,continue:!e.abort})}}),mqe=jr("$ZodCheckLengthEquals",(t,e)=>{var r;$u.init(t,e),(r=t._zod.def).when??(r.when=n=>{const s=n.value;return!nH(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=iH(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})}}),H3=jr("$ZodCheckStringFormat",(t,e)=>{var r,n;$u.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=()=>{})}),pqe=jr("$ZodCheckRegex",(t,e)=>{H3.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})}}),gqe=jr("$ZodCheckLowerCase",(t,e)=>{e.pattern??(e.pattern=lqe),H3.init(t,e)}),yqe=jr("$ZodCheckUpperCase",(t,e)=>{e.pattern??(e.pattern=cqe),H3.init(t,e)}),xqe=jr("$ZodCheckIncludes",(t,e)=>{$u.init(t,e);const r=vS(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})}}),vqe=jr("$ZodCheckStartsWith",(t,e)=>{$u.init(t,e);const r=new RegExp(`^${vS(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})}}),_qe=jr("$ZodCheckEndsWith",(t,e)=>{$u.init(t,e);const r=new RegExp(`.*${vS(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})}}),bqe=jr("$ZodCheckOverwrite",(t,e)=>{$u.init(t,e),t._zod.check=r=>{r.value=e.tx(r.value)}});class wqe{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 Sqe={major:4,minor:4,patch:3},uo=jr("$ZodType",(t,e)=>{var s;var r;t??(t={}),t._zod.def=e,t._zod.bag=t._zod.bag||{},t._zod.version=Sqe;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,p)=>{let y=l1(a),v;for(const S of f){if(S._zod.def.when){if(E8e(a)||!S._zod.def.when(a))continue}else if(y)continue;const E=a.issues.length,k=S._zod.check(a);if(k instanceof Promise&&(p==null?void 0:p.async)===!1)throw new R1;if(v||k instanceof Promise)v=(v??Promise.resolve()).then(async()=>{await k,a.issues.length!==E&&(y||(y=l1(a,E)))});else{if(a.issues.length===E)continue;y||(y=l1(a,E))}}return v?v.then(()=>a):a},c=(a,f,p)=>{if(l1(a))return a.aborted=!0,a;const y=o(f,n,p);if(y instanceof Promise){if(p.async===!1)throw new R1;return y.then(v=>t._zod.parse(v,p))}return t._zod.parse(y,p)};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(v=>c(v,a,f)):c(y,a,f)}const p=t._zod.parse(a,f);if(p instanceof Promise){if(f.async===!1)throw new R1;return p.then(y=>o(y,n,f))}return o(p,n,f)}}Ji(t,"~standard",()=>({validate:o=>{var c;try{const a=k8e(t,o);return a.success?{value:a.data}:{issues:(c=a.error)==null?void 0:c.issues}}catch{return N8e(t,o).then(f=>{var p;return f.success?{value:f.data}:{issues:(p=f.error)==null?void 0:p.issues}})}},vendor:"zod",version:1}))}),lH=jr("$ZodString",(t,e)=>{var r;uo.init(t,e),t._zod.pattern=[...((r=t==null?void 0:t._zod.bag)==null?void 0:r.patterns)??[]].pop()??iqe(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}}),Wa=jr("$ZodStringFormat",(t,e)=>{H3.init(t,e),lH.init(t,e)}),Tqe=jr("$ZodGUID",(t,e)=>{e.pattern??(e.pattern=G8e),Wa.init(t,e)}),Eqe=jr("$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=Pre(n))}else e.pattern??(e.pattern=Pre());Wa.init(t,e)}),jqe=jr("$ZodEmail",(t,e)=>{e.pattern??(e.pattern=H8e),Wa.init(t,e)}),Aqe=jr("$ZodURL",(t,e)=>{Wa.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)===eqe.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})}}}),kqe=jr("$ZodEmoji",(t,e)=>{e.pattern??(e.pattern=K8e()),Wa.init(t,e)}),Nqe=jr("$ZodNanoID",(t,e)=>{e.pattern??(e.pattern=V8e),Wa.init(t,e)}),Cqe=jr("$ZodCUID",(t,e)=>{e.pattern??(e.pattern=F8e),Wa.init(t,e)}),Iqe=jr("$ZodCUID2",(t,e)=>{e.pattern??(e.pattern=B8e),Wa.init(t,e)}),Pqe=jr("$ZodULID",(t,e)=>{e.pattern??(e.pattern=$8e),Wa.init(t,e)}),Rqe=jr("$ZodXID",(t,e)=>{e.pattern??(e.pattern=z8e),Wa.init(t,e)}),Lqe=jr("$ZodKSUID",(t,e)=>{e.pattern??(e.pattern=U8e),Wa.init(t,e)}),Mqe=jr("$ZodISODateTime",(t,e)=>{e.pattern??(e.pattern=sqe(e)),Wa.init(t,e)}),Dqe=jr("$ZodISODate",(t,e)=>{e.pattern??(e.pattern=rqe),Wa.init(t,e)}),Oqe=jr("$ZodISOTime",(t,e)=>{e.pattern??(e.pattern=nqe(e)),Wa.init(t,e)}),Fqe=jr("$ZodISODuration",(t,e)=>{e.pattern??(e.pattern=q8e),Wa.init(t,e)}),Bqe=jr("$ZodIPv4",(t,e)=>{e.pattern??(e.pattern=Y8e),Wa.init(t,e),t._zod.bag.format="ipv4"}),$qe=jr("$ZodIPv6",(t,e)=>{e.pattern??(e.pattern=Z8e),Wa.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})}}}),zqe=jr("$ZodCIDRv4",(t,e)=>{e.pattern??(e.pattern=X8e),Wa.init(t,e)}),Uqe=jr("$ZodCIDRv6",(t,e)=>{e.pattern??(e.pattern=Q8e),Wa.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 P0e(t){if(t==="")return!0;if(/\s/.test(t)||t.length%4!==0)return!1;try{return atob(t),!0}catch{return!1}}const Vqe=jr("$ZodBase64",(t,e)=>{e.pattern??(e.pattern=J8e),Wa.init(t,e),t._zod.bag.contentEncoding="base64",t._zod.check=r=>{P0e(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:t,continue:!e.abort})}});function qqe(t){if(!E0e.test(t))return!1;const e=t.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=e.padEnd(Math.ceil(e.length/4)*4,"=");return P0e(r)}const Gqe=jr("$ZodBase64URL",(t,e)=>{e.pattern??(e.pattern=E0e),Wa.init(t,e),t._zod.bag.contentEncoding="base64url",t._zod.check=r=>{qqe(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:t,continue:!e.abort})}}),Hqe=jr("$ZodE164",(t,e)=>{e.pattern??(e.pattern=tqe),Wa.init(t,e)});function Wqe(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 Kqe=jr("$ZodJWT",(t,e)=>{Wa.init(t,e),t._zod.check=r=>{Wqe(r.value,e.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:t,continue:!e.abort})}}),R0e=jr("$ZodNumber",(t,e)=>{uo.init(t,e),t._zod.pattern=t._zod.bag.pattern??k0e,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}}),Yqe=jr("$ZodNumberFormat",(t,e)=>{dqe.init(t,e),R0e.init(t,e)}),Zqe=jr("$ZodBoolean",(t,e)=>{uo.init(t,e),t._zod.pattern=oqe,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}}),Xqe=jr("$ZodUnknown",(t,e)=>{uo.init(t,e),t._zod.parse=r=>r}),Qqe=jr("$ZodNever",(t,e)=>{uo.init(t,e),t._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:t}),r)});function Rre(t,e,r){t.issues.length&&e.issues.push(...c1(r,t.issues)),e.value[r]=t.value}const Jqe=jr("$ZodArray",(t,e)=>{uo.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;cRre(p,r,c))):Rre(f,r,c)}return o.length?Promise.all(o).then(()=>r):r}});function aD(t,e,r,n,s,o){const c=r in n;if(t.issues.length){if(s&&o&&!c)return;e.issues.push(...c1(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 L0e(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=g8e(t.shape);return{...t,keys:e,keySet:new Set(e),numKeys:e.length,optionalKeys:new Set(r)}}function M0e(t,e,r,n,s,o){const c=[],a=s.keySet,f=s.catchall._zod,p=f.def.type,y=f.optin==="optional",v=f.optout==="optional";for(const S in e){if(S==="__proto__"||a.has(S))continue;if(p==="never"){c.push(S);continue}const E=f.run({value:e[S],issues:[]},n);E instanceof Promise?t.push(E.then(k=>aD(k,r,S,e,y,v))):aD(E,r,S,e,y,v)}return c.length&&r.issues.push({code:"unrecognized_keys",keys:c,input:e,inst:o}),t.length?Promise.all(t).then(()=>r):r}const eGe=jr("$ZodObject",(t,e)=>{uo.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=rH(()=>L0e(e));Ji(t._zod,"propValues",()=>{const a=e.shape,f={};for(const p in a){const y=a[p]._zod;if(y.values){f[p]??(f[p]=new Set);for(const v of y.values)f[p].add(v)}}return f});const s=iD,o=e.catchall;let c;t._zod.parse=(a,f)=>{c??(c=n.value);const p=a.value;if(!s(p))return a.issues.push({expected:"object",code:"invalid_type",input:p,inst:t}),a;a.value={};const y=[],v=c.shape;for(const S of c.keys){const E=v[S],k=E._zod.optin==="optional",R=E._zod.optout==="optional",P=E._zod.run({value:p[S],issues:[]},f);P instanceof Promise?y.push(P.then(M=>aD(M,a,S,p,k,R))):aD(P,a,S,p,k,R)}return o?M0e(y,p,a,f,n.value,t):y.length?Promise.all(y).then(()=>a):a}}),tGe=jr("$ZodObjectJIT",(t,e)=>{eGe.init(t,e);const r=t._zod.parse,n=rH(()=>L0e(e)),s=S=>{var B,V;const E=new wqe(["shape","payload","ctx"]),k=n.value,R=G=>{const W=Ire(G);return`shape[${W}]._zod.run({ value: input[${W}], issues: [] }, ctx)`};E.write("const input = payload.value;");const P=Object.create(null);let M=0;for(const G of k.keys)P[G]=`key_${M++}`;E.write("const newResult = {};");for(const G of k.keys){const W=P[G],Y=Ire(G),J=S[G],Q=((B=J==null?void 0:J._zod)==null?void 0:B.optin)==="optional",ee=((V=J==null?void 0:J._zod)==null?void 0:V.optout)==="optional";E.write(`const ${W} = ${R(G)};`),Q&&ee?E.write(` if (${W}.issues.length) { if (${Y} in input) { payload.issues = payload.issues.concat(${W}.issues.map(iss => ({ ...iss, path: iss.path ? [${Y}, ...iss.path] : [${Y}] }))); } } if (${W}.value === undefined) { if (${Y} in input) { newResult[${Y}] = undefined; } } else { newResult[${Y}] = ${W}.value; } `):Q?E.write(` if (${W}.issues.length) { payload.issues = payload.issues.concat(${W}.issues.map(iss => ({ ...iss, path: iss.path ? [${Y}, ...iss.path] : [${Y}] }))); } if (${W}.value === undefined) { if (${Y} in input) { newResult[${Y}] = undefined; } } else { newResult[${Y}] = ${W}.value; } `):E.write(` const ${W}_present = ${Y} in input; if (${W}.issues.length) { payload.issues = payload.issues.concat(${W}.issues.map(iss => ({ ...iss, path: iss.path ? [${Y}, ...iss.path] : [${Y}] }))); } if (!${W}_present && !${W}.issues.length) { payload.issues.push({ code: "invalid_type", expected: "nonoptional", input: undefined, path: [${Y}] }); } if (${W}_present) { if (${W}.value === undefined) { newResult[${Y}] = undefined; } else { newResult[${Y}] = ${W}.value; } } `)}E.write("payload.value = newResult;"),E.write("return payload;");const D=E.compile();return(G,W)=>D(S,G,W)};let o;const c=iD,a=!tH.jitless,p=a&&m8e.value,y=e.catchall;let v;t._zod.parse=(S,E)=>{v??(v=n.value);const k=S.value;return c(k)?a&&p&&(E==null?void 0:E.async)===!1&&E.jitless!==!0?(o||(o=s(e.shape)),S=o(S,E),y?M0e([],k,S,E,v,t):S):r(S,E):(S.issues.push({expected:"object",code:"invalid_type",input:k,inst:t}),S)}});function Lre(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=>!l1(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=>ug(c,n,cg())))}),e)}const rGe=jr("$ZodUnion",(t,e)=>{uo.init(t,e),Ji(t._zod,"optin",()=>e.options.some(n=>n._zod.optin==="optional")?"optional":void 0),Ji(t._zod,"optout",()=>e.options.some(n=>n._zod.optout==="optional")?"optional":void 0),Ji(t._zod,"values",()=>{if(e.options.every(n=>n._zod.values))return new Set(e.options.flatMap(n=>Array.from(n._zod.values)))}),Ji(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=>sH(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=>Lre(a,n,t,s)):Lre(c,n,t,s)}}),nGe=jr("$ZodIntersection",(t,e)=>{uo.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,p])=>Mre(r,f,p)):Mre(r,o,c)}});function KV(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(xS(t)&&xS(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=KV(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}),l1(t))return t;const c=KV(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 sGe=jr("$ZodRecord",(t,e)=>{uo.init(t,e),t._zod.parse=(r,n)=>{const s=r.value;if(!xS(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 p of c)if(typeof p=="string"||typeof p=="number"||typeof p=="symbol"){a.add(typeof p=="number"?p.toString():p);const y=e.keyType._zod.run({value:p,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=>ug(E,n,cg())),input:p,path:[p],inst:t});continue}const v=y.value,S=e.valueType._zod.run({value:s[p],issues:[]},n);S instanceof Promise?o.push(S.then(E=>{E.issues.length&&r.issues.push(...c1(p,E.issues)),r.value[v]=E.value})):(S.issues.length&&r.issues.push(...c1(p,S.issues)),r.value[v]=S.value)}let f;for(const p in s)a.has(p)||(f=f??[],f.push(p));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"&&k0e.test(a)&&f.issues.length){const v=e.keyType._zod.run({value:Number(a),issues:[]},n);if(v instanceof Promise)throw new Error("Async schemas not supported in object keys currently");v.issues.length===0&&(f=v)}if(f.issues.length){e.mode==="loose"?r.value[a]=s[a]:r.issues.push({code:"invalid_key",origin:"record",issues:f.issues.map(v=>ug(v,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(v=>{v.issues.length&&r.issues.push(...c1(a,v.issues)),r.value[f.value]=v.value})):(y.issues.length&&r.issues.push(...c1(a,y.issues)),r.value[f.value]=y.value)}}return o.length?Promise.all(o).then(()=>r):r}}),iGe=jr("$ZodEnum",(t,e)=>{uo.init(t,e);const r=v0e(e.entries),n=new Set(r);t._zod.values=n,t._zod.pattern=new RegExp(`^(${r.filter(s=>p8e.has(typeof s)).map(s=>typeof s=="string"?vS(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}}),aGe=jr("$ZodLiteral",(t,e)=>{if(uo.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"?vS(n):n?vS(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}}),oGe=jr("$ZodTransform",(t,e)=>{uo.init(t,e),t._zod.optin="optional",t._zod.parse=(r,n)=>{if(n.direction==="backward")throw new x0e(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 R1;return r.value=s,r.fallback=!0,r}});function Dre(t,e){return e===void 0&&(t.issues.length||t.fallback)?{issues:[],value:void 0}:t}const D0e=jr("$ZodOptional",(t,e)=>{uo.init(t,e),t._zod.optin="optional",t._zod.optout="optional",Ji(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,void 0]):void 0),Ji(t._zod,"pattern",()=>{const r=e.innerType._zod.pattern;return r?new RegExp(`^(${sH(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=>Dre(c,s)):Dre(o,s)}return r.value===void 0?r:e.innerType._zod.run(r,n)}}),lGe=jr("$ZodExactOptional",(t,e)=>{D0e.init(t,e),Ji(t._zod,"values",()=>e.innerType._zod.values),Ji(t._zod,"pattern",()=>e.innerType._zod.pattern),t._zod.parse=(r,n)=>e.innerType._zod.run(r,n)}),cGe=jr("$ZodNullable",(t,e)=>{uo.init(t,e),Ji(t._zod,"optin",()=>e.innerType._zod.optin),Ji(t._zod,"optout",()=>e.innerType._zod.optout),Ji(t._zod,"pattern",()=>{const r=e.innerType._zod.pattern;return r?new RegExp(`^(${sH(r.source)}|null)$`):void 0}),Ji(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)}),uGe=jr("$ZodDefault",(t,e)=>{uo.init(t,e),t._zod.optin="optional",Ji(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=>Ore(o,e)):Ore(s,e)}});function Ore(t,e){return t.value===void 0&&(t.value=e.defaultValue),t}const dGe=jr("$ZodPrefault",(t,e)=>{uo.init(t,e),t._zod.optin="optional",Ji(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))}),hGe=jr("$ZodNonOptional",(t,e)=>{uo.init(t,e),Ji(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=>Fre(o,t)):Fre(s,t)}});function Fre(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 fGe=jr("$ZodCatch",(t,e)=>{uo.init(t,e),t._zod.optin="optional",Ji(t._zod,"optout",()=>e.innerType._zod.optout),Ji(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=>ug(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=>ug(o,n,cg()))},input:r.value}),r.issues=[],r.fallback=!0),r)}}),mGe=jr("$ZodPipe",(t,e)=>{uo.init(t,e),Ji(t._zod,"values",()=>e.in._zod.values),Ji(t._zod,"optin",()=>e.in._zod.optin),Ji(t._zod,"optout",()=>e.out._zod.optout),Ji(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=>_R(c,e.in,n)):_R(o,e.in,n)}const s=e.in._zod.run(r,n);return s instanceof Promise?s.then(o=>_R(o,e.out,n)):_R(s,e.out,n)}});function _R(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 pGe=jr("$ZodReadonly",(t,e)=>{uo.init(t,e),Ji(t._zod,"propValues",()=>e.innerType._zod.propValues),Ji(t._zod,"values",()=>e.innerType._zod.values),Ji(t._zod,"optin",()=>{var r,n;return(n=(r=e.innerType)==null?void 0:r._zod)==null?void 0:n.optin}),Ji(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(Bre):Bre(s)}});function Bre(t){return t.value=Object.freeze(t.value),t}const gGe=jr("$ZodCustom",(t,e)=>{$u.init(t,e),uo.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=>$re(o,r,n,t));$re(s,r,n,t)}});function $re(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(mk(s))}}var zre;class yGe{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 xGe(){return new yGe}(zre=globalThis).__zod_globalRegistry??(zre.__zod_globalRegistry=xGe());const Y2=globalThis.__zod_globalRegistry;function vGe(t,e){return new t({type:"string",...Vn(e)})}function _Ge(t,e){return new t({type:"string",format:"email",check:"string_format",abort:!1,...Vn(e)})}function Ure(t,e){return new t({type:"string",format:"guid",check:"string_format",abort:!1,...Vn(e)})}function bGe(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,...Vn(e)})}function wGe(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...Vn(e)})}function SGe(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...Vn(e)})}function TGe(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...Vn(e)})}function EGe(t,e){return new t({type:"string",format:"url",check:"string_format",abort:!1,...Vn(e)})}function jGe(t,e){return new t({type:"string",format:"emoji",check:"string_format",abort:!1,...Vn(e)})}function AGe(t,e){return new t({type:"string",format:"nanoid",check:"string_format",abort:!1,...Vn(e)})}function kGe(t,e){return new t({type:"string",format:"cuid",check:"string_format",abort:!1,...Vn(e)})}function NGe(t,e){return new t({type:"string",format:"cuid2",check:"string_format",abort:!1,...Vn(e)})}function CGe(t,e){return new t({type:"string",format:"ulid",check:"string_format",abort:!1,...Vn(e)})}function IGe(t,e){return new t({type:"string",format:"xid",check:"string_format",abort:!1,...Vn(e)})}function PGe(t,e){return new t({type:"string",format:"ksuid",check:"string_format",abort:!1,...Vn(e)})}function RGe(t,e){return new t({type:"string",format:"ipv4",check:"string_format",abort:!1,...Vn(e)})}function LGe(t,e){return new t({type:"string",format:"ipv6",check:"string_format",abort:!1,...Vn(e)})}function MGe(t,e){return new t({type:"string",format:"cidrv4",check:"string_format",abort:!1,...Vn(e)})}function DGe(t,e){return new t({type:"string",format:"cidrv6",check:"string_format",abort:!1,...Vn(e)})}function OGe(t,e){return new t({type:"string",format:"base64",check:"string_format",abort:!1,...Vn(e)})}function FGe(t,e){return new t({type:"string",format:"base64url",check:"string_format",abort:!1,...Vn(e)})}function BGe(t,e){return new t({type:"string",format:"e164",check:"string_format",abort:!1,...Vn(e)})}function $Ge(t,e){return new t({type:"string",format:"jwt",check:"string_format",abort:!1,...Vn(e)})}function zGe(t,e){return new t({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...Vn(e)})}function UGe(t,e){return new t({type:"string",format:"date",check:"string_format",...Vn(e)})}function VGe(t,e){return new t({type:"string",format:"time",check:"string_format",precision:null,...Vn(e)})}function qGe(t,e){return new t({type:"string",format:"duration",check:"string_format",...Vn(e)})}function GGe(t,e){return new t({type:"number",checks:[],...Vn(e)})}function HGe(t,e){return new t({type:"number",check:"number_format",abort:!1,format:"safeint",...Vn(e)})}function WGe(t,e){return new t({type:"boolean",...Vn(e)})}function KGe(t){return new t({type:"unknown"})}function YGe(t,e){return new t({type:"never",...Vn(e)})}function Vre(t,e){return new C0e({check:"less_than",...Vn(e),value:t,inclusive:!1})}function X$(t,e){return new C0e({check:"less_than",...Vn(e),value:t,inclusive:!0})}function qre(t,e){return new I0e({check:"greater_than",...Vn(e),value:t,inclusive:!1})}function Q$(t,e){return new I0e({check:"greater_than",...Vn(e),value:t,inclusive:!0})}function Gre(t,e){return new uqe({check:"multiple_of",...Vn(e),value:t})}function O0e(t,e){return new hqe({check:"max_length",...Vn(e),maximum:t})}function oD(t,e){return new fqe({check:"min_length",...Vn(e),minimum:t})}function F0e(t,e){return new mqe({check:"length_equals",...Vn(e),length:t})}function ZGe(t,e){return new pqe({check:"string_format",format:"regex",...Vn(e),pattern:t})}function XGe(t){return new gqe({check:"string_format",format:"lowercase",...Vn(t)})}function QGe(t){return new yqe({check:"string_format",format:"uppercase",...Vn(t)})}function JGe(t,e){return new xqe({check:"string_format",format:"includes",...Vn(e),includes:t})}function e9e(t,e){return new vqe({check:"string_format",format:"starts_with",...Vn(e),prefix:t})}function t9e(t,e){return new _qe({check:"string_format",format:"ends_with",...Vn(e),suffix:t})}function wT(t){return new bqe({check:"overwrite",tx:t})}function r9e(t){return wT(e=>e.normalize(t))}function n9e(){return wT(t=>t.trim())}function s9e(){return wT(t=>t.toLowerCase())}function i9e(){return wT(t=>t.toUpperCase())}function a9e(){return wT(t=>f8e(t))}function o9e(t,e,r){return new t({type:"array",element:e,...Vn(r)})}function l9e(t,e,r){return new t({type:"custom",check:"custom",fn:e,...Vn(r)})}function c9e(t,e){const r=u9e(n=>(n.addIssue=s=>{if(typeof s=="string")n.issues.push(mk(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(mk(o))}},t(n.value,n)),e);return r}function u9e(t,e){const r=new $u({check:"custom",...Vn(e)});return r._zod.check=t,r}function B0e(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)??Y2,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 Xo(t,e,r={path:[],schemaPath:[]}){var y,v;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=(v=(y=t._zod).toJSONSchema)==null?void 0:v.call(y);if(a)c.schema=a;else{const S={...r,schemaPath:[...r.schemaPath,t],path:r.path};if(t._zod.processJSONSchema)t._zod.processJSONSchema(e,c.schema,S);else{const k=c.schema,R=e.processors[s.type];if(!R)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${s.type}`);R(t,e,k,S)}const E=t._zod.parent;E&&(c.ref||(c.ref=E),Xo(E,e,S),e.seen.get(E).isParent=!0)}const f=e.metadataRegistry.get(t);return f&&Object.assign(c.schema,f),e.io==="input"&&qc(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 $0e(t,e){var c,a,f,p;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 v=(c=t.metadataRegistry.get(y[0]))==null?void 0:c.id;if(v){const S=n.get(v);if(S&&S!==y[0])throw new Error(`Duplicate schema id "${v}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);n.set(v,y[0])}}const s=y=>{var R;const v=t.target==="draft-2020-12"?"$defs":"definitions";if(t.external){const P=(R=t.external.registry.get(y[0]))==null?void 0:R.id,M=t.external.uri??(B=>B);if(P)return{ref:M(P)};const D=y[1].defId??y[1].schema.id??`schema${t.counter++}`;return y[1].defId=D,{defId:D,ref:`${M("__shared")}#/${v}/${D}`}}if(y[1]===r)return{ref:"#"};const E=`#/${v}/`,k=y[1].schema.id??`__schema${t.counter++}`;return{defId:k,ref:E+k}},o=y=>{if(y[1].schema.$ref)return;const v=y[1],{ref:S,defId:E}=s(y);v.def={...v.schema},E&&(v.defId=E);const k=v.schema;for(const R in k)delete k[R];k.$ref=S};if(t.cycles==="throw")for(const y of t.seen.entries()){const v=y[1];if(v.cycle)throw new Error(`Cycle detected: #/${(a=v.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 v=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((p=t.metadataRegistry.get(y[0]))==null?void 0:p.id){o(y);continue}if(v.cycle){o(y);continue}if(v.count>1&&t.reused==="ref"){o(y);continue}}}function z0e(t,e){var a,f,p,y;const r=t.seen.get(e);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");const n=v=>{const S=t.seen.get(v);if(S.ref===null)return;const E=S.def??S.schema,k={...E},R=S.ref;if(S.ref=null,R){n(R);const M=t.seen.get(R),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,k),v._zod.parent===R)for(const V in E)V==="$ref"||V==="allOf"||V in k||delete E[V];if(D.$ref&&M.def)for(const V in E)V==="$ref"||V==="allOf"||V in M.def&&JSON.stringify(E[V])===JSON.stringify(M.def[V])&&delete E[V]}const P=v._zod.parent;if(P&&P!==R){n(P);const M=t.seen.get(P);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:v,jsonSchema:E,path:S.path??[]})};for(const v of[...t.seen.entries()].reverse())n(v[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 v=(f=t.external.registry.get(e))==null?void 0:f.id;if(!v)throw new Error("Schema is missing an `id` property");s.$id=t.external.uri(v)}Object.assign(s,r.def??r.schema);const o=(p=t.metadataRegistry.get(e))==null?void 0:p.id;o!==void 0&&s.id===o&&delete s.id;const c=((y=t.external)==null?void 0:y.defs)??{};for(const v of t.seen.entries()){const S=v[1];S.def&&S.defId&&(S.def.id===S.defId&&delete S.def.id,c[S.defId]=S.def)}t.external||Object.keys(c).length>0&&(t.target==="draft-2020-12"?s.$defs=c:s.definitions=c);try{const v=JSON.parse(JSON.stringify(s));return Object.defineProperty(v,"~standard",{value:{...e["~standard"],jsonSchema:{input:lD(e,"input",t.processors),output:lD(e,"output",t.processors)}},enumerable:!1,writable:!1}),v}catch{throw new Error("Error converting schema to JSON.")}}function qc(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 qc(n.element,r);if(n.type==="set")return qc(n.valueType,r);if(n.type==="lazy")return qc(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 qc(n.innerType,r);if(n.type==="intersection")return qc(n.left,r)||qc(n.right,r);if(n.type==="record"||n.type==="map")return qc(n.keyType,r)||qc(n.valueType,r);if(n.type==="pipe")return t._zod.traits.has("$ZodCodec")?!0:qc(n.in,r)||qc(n.out,r);if(n.type==="object"){for(const s in n.shape)if(qc(n.shape[s],r))return!0;return!1}if(n.type==="union"){for(const s of n.options)if(qc(s,r))return!0;return!1}if(n.type==="tuple"){for(const s of n.items)if(qc(s,r))return!0;return!!(n.rest&&qc(n.rest,r))}return!1}const d9e=(t,e={})=>r=>{const n=B0e({...r,processors:e});return Xo(t,n),$0e(n,t),z0e(n,t)},lD=(t,e,r={})=>n=>{const{libraryOptions:s,target:o}=n??{},c=B0e({...s??{},target:o,io:e,processors:r});return Xo(t,c),$0e(c,t),z0e(c,t)},h9e={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},f9e=(t,e,r,n)=>{const s=r;s.type="string";const{minimum:o,maximum:c,format:a,patterns:f,contentEncoding:p}=t._zod.bag;if(typeof o=="number"&&(s.minLength=o),typeof c=="number"&&(s.maxLength=c),a&&(s.format=h9e[a]??a,s.format===""&&delete s.format,a==="time"&&delete s.format),p&&(s.contentEncoding=p),f&&f.size>0){const y=[...f];y.length===1?s.pattern=y[0].source:y.length>1&&(s.allOf=[...y.map(v=>({...e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"?{type:"string"}:{},pattern:v.source}))])}},m9e=(t,e,r,n)=>{const s=r,{minimum:o,maximum:c,format:a,multipleOf:f,exclusiveMaximum:p,exclusiveMinimum:y}=t._zod.bag;typeof a=="string"&&a.includes("int")?s.type="integer":s.type="number";const v=typeof y=="number"&&y>=(o??Number.NEGATIVE_INFINITY),S=typeof p=="number"&&p<=(c??Number.POSITIVE_INFINITY),E=e.target==="draft-04"||e.target==="openapi-3.0";v?E?(s.minimum=y,s.exclusiveMinimum=!0):s.exclusiveMinimum=y:typeof o=="number"&&(s.minimum=o),S?E?(s.maximum=p,s.exclusiveMaximum=!0):s.exclusiveMaximum=p:typeof c=="number"&&(s.maximum=c),typeof f=="number"&&(s.multipleOf=f)},p9e=(t,e,r,n)=>{r.type="boolean"},g9e=(t,e,r,n)=>{r.not={}},y9e=(t,e,r,n)=>{},x9e=(t,e,r,n)=>{const s=t._zod.def,o=v0e(s.entries);o.every(c=>typeof c=="number")&&(r.type="number"),o.every(c=>typeof c=="string")&&(r.type="string"),r.enum=o},v9e=(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},_9e=(t,e,r,n)=>{if(e.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},b9e=(t,e,r,n)=>{if(e.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},w9e=(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=Xo(o.element,e,{...n,path:[...n.path,"items"]})},S9e=(t,e,r,n)=>{var p;const s=r,o=t._zod.def;s.type="object",s.properties={};const c=o.shape;for(const y in c)s.properties[y]=Xo(c[y],e,{...n,path:[...n.path,"properties",y]});const a=new Set(Object.keys(c)),f=new Set([...a].filter(y=>{const v=o.shape[y]._zod;return e.io==="input"?v.optin===void 0:v.optout===void 0}));f.size>0&&(s.required=Array.from(f)),((p=o.catchall)==null?void 0:p._zod.def.type)==="never"?s.additionalProperties=!1:o.catchall?o.catchall&&(s.additionalProperties=Xo(o.catchall,e,{...n,path:[...n.path,"additionalProperties"]})):e.io==="output"&&(s.additionalProperties=!1)},T9e=(t,e,r,n)=>{const s=t._zod.def,o=s.inclusive===!1,c=s.options.map((a,f)=>Xo(a,e,{...n,path:[...n.path,o?"oneOf":"anyOf",f]}));o?r.oneOf=c:r.anyOf=c},E9e=(t,e,r,n)=>{const s=t._zod.def,o=Xo(s.left,e,{...n,path:[...n.path,"allOf",0]}),c=Xo(s.right,e,{...n,path:[...n.path,"allOf",1]}),a=p=>"allOf"in p&&Object.keys(p).length===1,f=[...a(o)?o.allOf:[o],...a(c)?c.allOf:[c]];r.allOf=f},j9e=(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=Xo(o.valueType,e,{...n,path:[...n.path,"patternProperties","*"]});s.patternProperties={};for(const v of f)s.patternProperties[v.source]=y}else(e.target==="draft-07"||e.target==="draft-2020-12")&&(s.propertyNames=Xo(o.keyType,e,{...n,path:[...n.path,"propertyNames"]})),s.additionalProperties=Xo(o.valueType,e,{...n,path:[...n.path,"additionalProperties"]});const p=c._zod.values;if(p){const y=[...p].filter(v=>typeof v=="string"||typeof v=="number");y.length>0&&(s.required=y)}},A9e=(t,e,r,n)=>{const s=t._zod.def,o=Xo(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"}]},k9e=(t,e,r,n)=>{const s=t._zod.def;Xo(s.innerType,e,n);const o=e.seen.get(t);o.ref=s.innerType},N9e=(t,e,r,n)=>{const s=t._zod.def;Xo(s.innerType,e,n);const o=e.seen.get(t);o.ref=s.innerType,r.default=JSON.parse(JSON.stringify(s.defaultValue))},C9e=(t,e,r,n)=>{const s=t._zod.def;Xo(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)))},I9e=(t,e,r,n)=>{const s=t._zod.def;Xo(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},P9e=(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;Xo(c,e,n);const a=e.seen.get(t);a.ref=c},R9e=(t,e,r,n)=>{const s=t._zod.def;Xo(s.innerType,e,n);const o=e.seen.get(t);o.ref=s.innerType,r.readOnly=!0},U0e=(t,e,r,n)=>{const s=t._zod.def;Xo(s.innerType,e,n);const o=e.seen.get(t);o.ref=s.innerType},L9e=jr("ZodISODateTime",(t,e)=>{Mqe.init(t,e),fo.init(t,e)});function M9e(t){return zGe(L9e,t)}const D9e=jr("ZodISODate",(t,e)=>{Dqe.init(t,e),fo.init(t,e)});function O9e(t){return UGe(D9e,t)}const F9e=jr("ZodISOTime",(t,e)=>{Oqe.init(t,e),fo.init(t,e)});function B9e(t){return VGe(F9e,t)}const $9e=jr("ZodISODuration",(t,e)=>{Fqe.init(t,e),fo.init(t,e)});function z9e(t){return qGe($9e,t)}const V0e=(t,e)=>{S0e.init(t,e),t.name="ZodError",Object.defineProperties(t,{format:{value:r=>A8e(t,r)},flatten:{value:r=>j8e(t,r)},addIssue:{value:r=>{t.issues.push(r),t.message=JSON.stringify(t.issues,WV,2)}},addIssues:{value:r=>{t.issues.push(...r),t.message=JSON.stringify(t.issues,WV,2)}},isEmpty:{get(){return t.issues.length===0}}})},U9e=jr("ZodError",V0e),vh=jr("ZodError",V0e,{Parent:Error}),V9e=aH(vh),q9e=oH(vh),G9e=q3(vh),H9e=G3(vh),W9e=C8e(vh),K9e=I8e(vh),Y9e=P8e(vh),Z9e=R8e(vh),X9e=L8e(vh),Q9e=M8e(vh),J9e=D8e(vh),e7e=O8e(vh),Hre=new WeakMap;function WN(t,e,r){const n=Object.getPrototypeOf(t);let s=Hre.get(n);if(s||(s=new Set,Hre.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 ho=jr("ZodType",(t,e)=>(uo.init(t,e),Object.assign(t["~standard"],{jsonSchema:{input:lD(t,"input"),output:lD(t,"output")}}),t.toJSONSchema=d9e(t,{}),t.def=e,t.type=e.type,Object.defineProperty(t,"_def",{value:e}),t.parse=(r,n)=>V9e(t,r,n,{callee:t.parse}),t.safeParse=(r,n)=>G9e(t,r,n),t.parseAsync=async(r,n)=>q9e(t,r,n,{callee:t.parseAsync}),t.safeParseAsync=async(r,n)=>H9e(t,r,n),t.spa=t.safeParseAsync,t.encode=(r,n)=>W9e(t,r,n),t.decode=(r,n)=>K9e(t,r,n),t.encodeAsync=async(r,n)=>Y9e(t,r,n),t.decodeAsync=async(r,n)=>Z9e(t,r,n),t.safeEncode=(r,n)=>X9e(t,r,n),t.safeDecode=(r,n)=>Q9e(t,r,n),t.safeEncodeAsync=async(r,n)=>J9e(t,r,n),t.safeDecodeAsync=async(r,n)=>e7e(t,r,n),WN(t,"ZodType",{check(...r){const n=this.def;return this.clone($x(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 zx(this,r,n)},brand(){return this},register(r,n){return r.add(this,n),this},refine(r,n){return this.check(Z7e(r,n))},superRefine(r,n){return this.check(X7e(r,n))},overwrite(r){return this.check(wT(r))},optional(){return Zre(this)},exactOptional(){return O7e(this)},nullable(){return Xre(this)},nullish(){return Zre(Xre(this))},nonoptional(r){return V7e(this,r)},array(){return j7e(this)},or(r){return N7e([this,r])},and(r){return I7e(this,r)},transform(r){return Qre(this,M7e(r))},default(r){return $7e(this,r)},prefault(r){return U7e(this,r)},catch(r){return G7e(this,r)},pipe(r){return Qre(this,r)},readonly(){return K7e(this)},describe(r){const n=this.clone();return Y2.add(n,{description:r}),n},meta(...r){if(r.length===0)return Y2.get(this);const n=this.clone();return Y2.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=Y2.get(t))==null?void 0:r.description},configurable:!0}),t)),q0e=jr("_ZodString",(t,e)=>{lH.init(t,e),ho.init(t,e),t._zod.processJSONSchema=(n,s,o)=>f9e(t,n,s);const r=t._zod.bag;t.format=r.format??null,t.minLength=r.minimum??null,t.maxLength=r.maximum??null,WN(t,"_ZodString",{regex(...n){return this.check(ZGe(...n))},includes(...n){return this.check(JGe(...n))},startsWith(...n){return this.check(e9e(...n))},endsWith(...n){return this.check(t9e(...n))},min(...n){return this.check(oD(...n))},max(...n){return this.check(O0e(...n))},length(...n){return this.check(F0e(...n))},nonempty(...n){return this.check(oD(1,...n))},lowercase(n){return this.check(XGe(n))},uppercase(n){return this.check(QGe(n))},trim(){return this.check(n9e())},normalize(...n){return this.check(r9e(...n))},toLowerCase(){return this.check(s9e())},toUpperCase(){return this.check(i9e())},slugify(){return this.check(a9e())}})}),t7e=jr("ZodString",(t,e)=>{lH.init(t,e),q0e.init(t,e),t.email=r=>t.check(_Ge(r7e,r)),t.url=r=>t.check(EGe(n7e,r)),t.jwt=r=>t.check($Ge(x7e,r)),t.emoji=r=>t.check(jGe(s7e,r)),t.guid=r=>t.check(Ure(Wre,r)),t.uuid=r=>t.check(bGe(bR,r)),t.uuidv4=r=>t.check(wGe(bR,r)),t.uuidv6=r=>t.check(SGe(bR,r)),t.uuidv7=r=>t.check(TGe(bR,r)),t.nanoid=r=>t.check(AGe(i7e,r)),t.guid=r=>t.check(Ure(Wre,r)),t.cuid=r=>t.check(kGe(a7e,r)),t.cuid2=r=>t.check(NGe(o7e,r)),t.ulid=r=>t.check(CGe(l7e,r)),t.base64=r=>t.check(OGe(p7e,r)),t.base64url=r=>t.check(FGe(g7e,r)),t.xid=r=>t.check(IGe(c7e,r)),t.ksuid=r=>t.check(PGe(u7e,r)),t.ipv4=r=>t.check(RGe(d7e,r)),t.ipv6=r=>t.check(LGe(h7e,r)),t.cidrv4=r=>t.check(MGe(f7e,r)),t.cidrv6=r=>t.check(DGe(m7e,r)),t.e164=r=>t.check(BGe(y7e,r)),t.datetime=r=>t.check(M9e(r)),t.date=r=>t.check(O9e(r)),t.time=r=>t.check(B9e(r)),t.duration=r=>t.check(z9e(r))});function Ns(t){return vGe(t7e,t)}const fo=jr("ZodStringFormat",(t,e)=>{Wa.init(t,e),q0e.init(t,e)}),r7e=jr("ZodEmail",(t,e)=>{jqe.init(t,e),fo.init(t,e)}),Wre=jr("ZodGUID",(t,e)=>{Tqe.init(t,e),fo.init(t,e)}),bR=jr("ZodUUID",(t,e)=>{Eqe.init(t,e),fo.init(t,e)}),n7e=jr("ZodURL",(t,e)=>{Aqe.init(t,e),fo.init(t,e)}),s7e=jr("ZodEmoji",(t,e)=>{kqe.init(t,e),fo.init(t,e)}),i7e=jr("ZodNanoID",(t,e)=>{Nqe.init(t,e),fo.init(t,e)}),a7e=jr("ZodCUID",(t,e)=>{Cqe.init(t,e),fo.init(t,e)}),o7e=jr("ZodCUID2",(t,e)=>{Iqe.init(t,e),fo.init(t,e)}),l7e=jr("ZodULID",(t,e)=>{Pqe.init(t,e),fo.init(t,e)}),c7e=jr("ZodXID",(t,e)=>{Rqe.init(t,e),fo.init(t,e)}),u7e=jr("ZodKSUID",(t,e)=>{Lqe.init(t,e),fo.init(t,e)}),d7e=jr("ZodIPv4",(t,e)=>{Bqe.init(t,e),fo.init(t,e)}),h7e=jr("ZodIPv6",(t,e)=>{$qe.init(t,e),fo.init(t,e)}),f7e=jr("ZodCIDRv4",(t,e)=>{zqe.init(t,e),fo.init(t,e)}),m7e=jr("ZodCIDRv6",(t,e)=>{Uqe.init(t,e),fo.init(t,e)}),p7e=jr("ZodBase64",(t,e)=>{Vqe.init(t,e),fo.init(t,e)}),g7e=jr("ZodBase64URL",(t,e)=>{Gqe.init(t,e),fo.init(t,e)}),y7e=jr("ZodE164",(t,e)=>{Hqe.init(t,e),fo.init(t,e)}),x7e=jr("ZodJWT",(t,e)=>{Kqe.init(t,e),fo.init(t,e)}),G0e=jr("ZodNumber",(t,e)=>{R0e.init(t,e),ho.init(t,e),t._zod.processJSONSchema=(n,s,o)=>m9e(t,n,s),WN(t,"ZodNumber",{gt(n,s){return this.check(qre(n,s))},gte(n,s){return this.check(Q$(n,s))},min(n,s){return this.check(Q$(n,s))},lt(n,s){return this.check(Vre(n,s))},lte(n,s){return this.check(X$(n,s))},max(n,s){return this.check(X$(n,s))},int(n){return this.check(Kre(n))},safe(n){return this.check(Kre(n))},positive(n){return this.check(qre(0,n))},nonnegative(n){return this.check(Q$(0,n))},negative(n){return this.check(Vre(0,n))},nonpositive(n){return this.check(X$(0,n))},multipleOf(n,s){return this.check(Gre(n,s))},step(n,s){return this.check(Gre(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 xA(t){return GGe(G0e,t)}const v7e=jr("ZodNumberFormat",(t,e)=>{Yqe.init(t,e),G0e.init(t,e)});function Kre(t){return HGe(v7e,t)}const _7e=jr("ZodBoolean",(t,e)=>{Zqe.init(t,e),ho.init(t,e),t._zod.processJSONSchema=(r,n,s)=>p9e(t,r,n)});function b7e(t){return WGe(_7e,t)}const w7e=jr("ZodUnknown",(t,e)=>{Xqe.init(t,e),ho.init(t,e),t._zod.processJSONSchema=(r,n,s)=>y9e()});function YV(){return KGe(w7e)}const S7e=jr("ZodNever",(t,e)=>{Qqe.init(t,e),ho.init(t,e),t._zod.processJSONSchema=(r,n,s)=>g9e(t,r,n)});function T7e(t){return YGe(S7e,t)}const E7e=jr("ZodArray",(t,e)=>{Jqe.init(t,e),ho.init(t,e),t._zod.processJSONSchema=(r,n,s)=>w9e(t,r,n,s),t.element=e.element,WN(t,"ZodArray",{min(r,n){return this.check(oD(r,n))},nonempty(r){return this.check(oD(1,r))},max(r,n){return this.check(O0e(r,n))},length(r,n){return this.check(F0e(r,n))},unwrap(){return this.element}})});function j7e(t,e){return o9e(E7e,t,e)}const A7e=jr("ZodObject",(t,e)=>{tGe.init(t,e),ho.init(t,e),t._zod.processJSONSchema=(r,n,s)=>S9e(t,r,n,s),Ji(t,"shape",()=>e.shape),WN(t,"ZodObject",{keyof(){return _S(Object.keys(this._zod.def.shape))},catchall(r){return this.clone({...this._zod.def,catchall:r})},passthrough(){return this.clone({...this._zod.def,catchall:YV()})},loose(){return this.clone({...this._zod.def,catchall:YV()})},strict(){return this.clone({...this._zod.def,catchall:T7e()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(r){return _8e(this,r)},safeExtend(r){return b8e(this,r)},merge(r){return w8e(this,r)},pick(r){return x8e(this,r)},omit(r){return v8e(this,r)},partial(...r){return S8e(H0e,this,r[0])},required(...r){return T8e(W0e,this,r[0])}})});function bg(t,e){const r={type:"object",shape:t??{},...Vn(e)};return new A7e(r)}const k7e=jr("ZodUnion",(t,e)=>{rGe.init(t,e),ho.init(t,e),t._zod.processJSONSchema=(r,n,s)=>T9e(t,r,n,s),t.options=e.options});function N7e(t,e){return new k7e({type:"union",options:t,...Vn(e)})}const C7e=jr("ZodIntersection",(t,e)=>{nGe.init(t,e),ho.init(t,e),t._zod.processJSONSchema=(r,n,s)=>E9e(t,r,n,s)});function I7e(t,e){return new C7e({type:"intersection",left:t,right:e})}const Yre=jr("ZodRecord",(t,e)=>{sGe.init(t,e),ho.init(t,e),t._zod.processJSONSchema=(r,n,s)=>j9e(t,r,n,s),t.keyType=e.keyType,t.valueType=e.valueType});function P7e(t,e,r){return!e||!e._zod?new Yre({type:"record",keyType:Ns(),valueType:t,...Vn(e)}):new Yre({type:"record",keyType:t,valueType:e,...Vn(r)})}const ZV=jr("ZodEnum",(t,e)=>{iGe.init(t,e),ho.init(t,e),t._zod.processJSONSchema=(n,s,o)=>x9e(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 ZV({...e,checks:[],...Vn(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 ZV({...e,checks:[],...Vn(s),entries:o})}});function _S(t,e){const r=Array.isArray(t)?Object.fromEntries(t.map(n=>[n,n])):t;return new ZV({type:"enum",entries:r,...Vn(e)})}const R7e=jr("ZodLiteral",(t,e)=>{aGe.init(t,e),ho.init(t,e),t._zod.processJSONSchema=(r,n,s)=>v9e(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 cD(t,e){return new R7e({type:"literal",values:Array.isArray(t)?t:[t],...Vn(e)})}const L7e=jr("ZodTransform",(t,e)=>{oGe.init(t,e),ho.init(t,e),t._zod.processJSONSchema=(r,n,s)=>b9e(t,r),t._zod.parse=(r,n)=>{if(n.direction==="backward")throw new x0e(t.constructor.name);r.addIssue=o=>{if(typeof o=="string")r.issues.push(mk(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(mk(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 M7e(t){return new L7e({type:"transform",transform:t})}const H0e=jr("ZodOptional",(t,e)=>{D0e.init(t,e),ho.init(t,e),t._zod.processJSONSchema=(r,n,s)=>U0e(t,r,n,s),t.unwrap=()=>t._zod.def.innerType});function Zre(t){return new H0e({type:"optional",innerType:t})}const D7e=jr("ZodExactOptional",(t,e)=>{lGe.init(t,e),ho.init(t,e),t._zod.processJSONSchema=(r,n,s)=>U0e(t,r,n,s),t.unwrap=()=>t._zod.def.innerType});function O7e(t){return new D7e({type:"optional",innerType:t})}const F7e=jr("ZodNullable",(t,e)=>{cGe.init(t,e),ho.init(t,e),t._zod.processJSONSchema=(r,n,s)=>A9e(t,r,n,s),t.unwrap=()=>t._zod.def.innerType});function Xre(t){return new F7e({type:"nullable",innerType:t})}const B7e=jr("ZodDefault",(t,e)=>{uGe.init(t,e),ho.init(t,e),t._zod.processJSONSchema=(r,n,s)=>N9e(t,r,n,s),t.unwrap=()=>t._zod.def.innerType,t.removeDefault=t.unwrap});function $7e(t,e){return new B7e({type:"default",innerType:t,get defaultValue(){return typeof e=="function"?e():b0e(e)}})}const z7e=jr("ZodPrefault",(t,e)=>{dGe.init(t,e),ho.init(t,e),t._zod.processJSONSchema=(r,n,s)=>C9e(t,r,n,s),t.unwrap=()=>t._zod.def.innerType});function U7e(t,e){return new z7e({type:"prefault",innerType:t,get defaultValue(){return typeof e=="function"?e():b0e(e)}})}const W0e=jr("ZodNonOptional",(t,e)=>{hGe.init(t,e),ho.init(t,e),t._zod.processJSONSchema=(r,n,s)=>k9e(t,r,n,s),t.unwrap=()=>t._zod.def.innerType});function V7e(t,e){return new W0e({type:"nonoptional",innerType:t,...Vn(e)})}const q7e=jr("ZodCatch",(t,e)=>{fGe.init(t,e),ho.init(t,e),t._zod.processJSONSchema=(r,n,s)=>I9e(t,r,n,s),t.unwrap=()=>t._zod.def.innerType,t.removeCatch=t.unwrap});function G7e(t,e){return new q7e({type:"catch",innerType:t,catchValue:typeof e=="function"?e:()=>e})}const H7e=jr("ZodPipe",(t,e)=>{mGe.init(t,e),ho.init(t,e),t._zod.processJSONSchema=(r,n,s)=>P9e(t,r,n,s),t.in=e.in,t.out=e.out});function Qre(t,e){return new H7e({type:"pipe",in:t,out:e})}const W7e=jr("ZodReadonly",(t,e)=>{pGe.init(t,e),ho.init(t,e),t._zod.processJSONSchema=(r,n,s)=>R9e(t,r,n,s),t.unwrap=()=>t._zod.def.innerType});function K7e(t){return new W7e({type:"readonly",innerType:t})}const Y7e=jr("ZodCustom",(t,e)=>{gGe.init(t,e),ho.init(t,e),t._zod.processJSONSchema=(r,n,s)=>_9e(t,r)});function Z7e(t,e={}){return l9e(Y7e,t,e)}function X7e(t,e){return c9e(t,e)}var Q7e="Label",K0e=N.forwardRef((t,e)=>i.jsx(nn.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())}}));K0e.displayName=Q7e;var Y0e=K0e;const J7e=aT("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Mr=N.forwardRef(({className:t,...e},r)=>i.jsx(Y0e,{ref:r,className:qt(J7e(),t),...e}));Mr.displayName=Y0e.displayName;const cH=GVe,Z0e=N.createContext({}),cl=({...t})=>i.jsx(Z0e.Provider,{value:{name:t.name},children:i.jsx(YVe,{...t})}),W3=()=>{const t=N.useContext(Z0e),e=N.useContext(X0e),{getFieldState:r,formState:n}=V3(),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}},X0e=N.createContext({}),Ho=N.forwardRef(({className:t,...e},r)=>{const n=N.useId();return i.jsx(X0e.Provider,{value:{id:n},children:i.jsx("div",{ref:r,className:qt("space-y-2",t),...e})})});Ho.displayName="FormItem";const Wo=N.forwardRef(({className:t,...e},r)=>{const{error:n,formItemId:s}=W3();return i.jsx(Mr,{ref:r,className:qt(n&&"text-destructive",t),htmlFor:s,...e})});Wo.displayName="FormLabel";const Ko=N.forwardRef(({...t},e)=>{const{error:r,formItemId:n,formDescriptionId:s,formMessageId:o}=W3();return i.jsx(tme,{ref:e,id:n,"aria-describedby":r?`${s} ${o}`:`${s}`,"aria-invalid":!!r,...t})});Ko.displayName="FormControl";const OL=N.forwardRef(({className:t,...e},r)=>{const{formDescriptionId:n}=W3();return i.jsx("p",{ref:r,id:n,className:qt("text-sm text-muted-foreground",t),...e})});OL.displayName="FormDescription";const df=N.forwardRef(({className:t,children:e,...r},n)=>{const{error:s,formMessageId:o}=W3(),c=s?String(s==null?void 0:s.message):e;return c?i.jsx("p",{ref:n,id:o,className:qt("text-sm font-medium text-destructive",t),...r,children:c}):null});df.displayName="FormMessage";const Dr=N.forwardRef(({className:t,type:e,...r},n)=>i.jsx("input",{type:e,className:qt("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 KN(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 eHe=[" ","Enter","ArrowUp","ArrowDown"],tHe=[" ","Enter"],m_="Select",[K3,Y3,rHe]=EN(m_),[ST,NGt]=Jo(m_,[rHe,Ox]),Z3=Ox(),[nHe,Ux]=ST(m_),[sHe,iHe]=ST(m_),Q0e=t=>{const{__scopeSelect:e,children:r,open:n,defaultOpen:s,onOpenChange:o,value:c,defaultValue:a,onValueChange:f,dir:p,name:y,autoComplete:v,disabled:S,required:E,form:k}=t,R=Z3(e),[P,M]=N.useState(null),[D,B]=N.useState(null),[V,G]=N.useState(!1),W=P_(p),[Y,J]=_d({prop:n,defaultProp:s??!1,onChange:o,caller:m_}),[Q,ee]=_d({prop:c,defaultProp:a,onChange:f,caller:m_}),le=N.useRef(null),pe=P?k||!!P.closest("form"):!0,[Te,Ae]=N.useState(new Set),Le=Array.from(Te).map(ke=>ke.props.value).join(";");return i.jsx(v3,{...R,children:i.jsxs(nHe,{required:E,scope:e,trigger:P,onTriggerChange:M,valueNode:D,onValueNodeChange:B,valueNodeHasChildren:V,onValueNodeHasChildrenChange:G,contentId:Fl(),value:Q,onValueChange:ee,open:Y,onOpenChange:J,dir:W,triggerPointerDownPosRef:le,disabled:S,children:[i.jsx(K3.Provider,{scope:e,children:i.jsx(sHe,{scope:t.__scopeSelect,onNativeOptionAdd:N.useCallback(ke=>{Ae(we=>new Set(we).add(ke))},[]),onNativeOptionRemove:N.useCallback(ke=>{Ae(we=>{const me=new Set(we);return me.delete(ke),me})},[]),children:r})}),pe?i.jsxs(Sve,{"aria-hidden":!0,required:E,tabIndex:-1,name:y,autoComplete:v,value:Q,onChange:ke=>ee(ke.target.value),disabled:S,form:k,children:[Q===void 0?i.jsx("option",{value:""}):null,Array.from(Te)]},Le):null]})})};Q0e.displayName=m_;var J0e="SelectTrigger",eve=N.forwardRef((t,e)=>{const{__scopeSelect:r,disabled:n=!1,...s}=t,o=Z3(r),c=Ux(J0e,r),a=c.disabled||n,f=Zn(e,c.onTriggerChange),p=Y3(r),y=N.useRef("touch"),[v,S,E]=Eve(R=>{const P=p().filter(B=>!B.disabled),M=P.find(B=>B.value===c.value),D=jve(P,R,M);D!==void 0&&c.onValueChange(D.value)}),k=R=>{a||(c.onOpenChange(!0),E()),R&&(c.triggerPointerDownPosRef.current={x:Math.round(R.pageX),y:Math.round(R.pageY)})};return i.jsx(FN,{asChild:!0,...o,children:i.jsx(nn.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":Tve(c.value)?"":void 0,...s,ref:f,onClick:Fr(s.onClick,R=>{R.currentTarget.focus(),y.current!=="mouse"&&k(R)}),onPointerDown:Fr(s.onPointerDown,R=>{y.current=R.pointerType;const P=R.target;P.hasPointerCapture(R.pointerId)&&P.releasePointerCapture(R.pointerId),R.button===0&&R.ctrlKey===!1&&R.pointerType==="mouse"&&(k(R),R.preventDefault())}),onKeyDown:Fr(s.onKeyDown,R=>{const P=v.current!=="";!(R.ctrlKey||R.altKey||R.metaKey)&&R.key.length===1&&S(R.key),!(P&&R.key===" ")&&eHe.includes(R.key)&&(k(),R.preventDefault())})})})});eve.displayName=J0e;var tve="SelectValue",rve=N.forwardRef((t,e)=>{const{__scopeSelect:r,className:n,style:s,children:o,placeholder:c="",...a}=t,f=Ux(tve,r),{onValueNodeHasChildrenChange:p}=f,y=o!==void 0,v=Zn(e,f.onValueNodeChange);return Do(()=>{p(y)},[p,y]),i.jsx(nn.span,{...a,ref:v,style:{pointerEvents:"none"},children:Tve(f.value)?i.jsx(i.Fragment,{children:c}):o})});rve.displayName=tve;var aHe="SelectIcon",nve=N.forwardRef((t,e)=>{const{__scopeSelect:r,children:n,...s}=t;return i.jsx(nn.span,{"aria-hidden":!0,...s,ref:e,children:n||"▼"})});nve.displayName=aHe;var oHe="SelectPortal",sve=t=>i.jsx(iT,{asChild:!0,...t});sve.displayName=oHe;var p_="SelectContent",ive=N.forwardRef((t,e)=>{const r=Ux(p_,t.__scopeSelect),[n,s]=N.useState();if(Do(()=>{s(new DocumentFragment)},[]),!r.open){const o=n;return o?xg.createPortal(i.jsx(ave,{scope:t.__scopeSelect,children:i.jsx(K3.Slot,{scope:t.__scopeSelect,children:i.jsx("div",{children:t.children})})}),o):null}return i.jsx(ove,{...t,ref:e})});ive.displayName=p_;var Wh=10,[ave,Vx]=ST(p_),lHe="SelectContentImpl",cHe=gx("SelectContent.RemoveScroll"),ove=N.forwardRef((t,e)=>{const{__scopeSelect:r,position:n="item-aligned",onCloseAutoFocus:s,onEscapeKeyDown:o,onPointerDownOutside:c,side:a,sideOffset:f,align:p,alignOffset:y,arrowPadding:v,collisionBoundary:S,collisionPadding:E,sticky:k,hideWhenDetached:R,avoidCollisions:P,...M}=t,D=Ux(p_,r),[B,V]=N.useState(null),[G,W]=N.useState(null),Y=Zn(e,vt=>V(vt)),[J,Q]=N.useState(null),[ee,le]=N.useState(null),pe=Y3(r),[Te,Ae]=N.useState(!1),Le=N.useRef(!1);N.useEffect(()=>{if(B)return h3(B)},[B]),u3();const ke=N.useCallback(vt=>{const[Gt,...pt]=pe().map(wt=>wt.ref.current),[Ct]=pt.slice(-1),tr=document.activeElement;for(const wt of vt)if(wt===tr||(wt==null||wt.scrollIntoView({block:"nearest"}),wt===Gt&&G&&(G.scrollTop=0),wt===Ct&&G&&(G.scrollTop=G.scrollHeight),wt==null||wt.focus(),document.activeElement!==tr))return},[pe,G]),we=N.useCallback(()=>ke([J,B]),[ke,J,B]);N.useEffect(()=>{Te&&we()},[Te,we]);const{onOpenChange:me,triggerPointerDownPosRef:je}=D;N.useEffect(()=>{if(B){let vt={x:0,y:0};const Gt=Ct=>{var tr,wt;vt={x:Math.abs(Math.round(Ct.pageX)-(((tr=je.current)==null?void 0:tr.x)??0)),y:Math.abs(Math.round(Ct.pageY)-(((wt=je.current)==null?void 0:wt.y)??0))}},pt=Ct=>{vt.x<=10&&vt.y<=10?Ct.preventDefault():B.contains(Ct.target)||me(!1),document.removeEventListener("pointermove",Gt),je.current=null};return je.current!==null&&(document.addEventListener("pointermove",Gt),document.addEventListener("pointerup",pt,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",Gt),document.removeEventListener("pointerup",pt,{capture:!0})}}},[B,me,je]),N.useEffect(()=>{const vt=()=>me(!1);return window.addEventListener("blur",vt),window.addEventListener("resize",vt),()=>{window.removeEventListener("blur",vt),window.removeEventListener("resize",vt)}},[me]);const[_e,Ee]=Eve(vt=>{const Gt=pe().filter(tr=>!tr.disabled),pt=Gt.find(tr=>tr.ref.current===document.activeElement),Ct=jve(Gt,vt,pt);Ct&&setTimeout(()=>Ct.ref.current.focus())}),ve=N.useCallback((vt,Gt,pt)=>{const Ct=!Le.current&&!pt;(D.value!==void 0&&D.value===Gt||Ct)&&(Q(vt),Ct&&(Le.current=!0))},[D.value]),qe=N.useCallback(()=>B==null?void 0:B.focus(),[B]),nt=N.useCallback((vt,Gt,pt)=>{const Ct=!Le.current&&!pt;(D.value!==void 0&&D.value===Gt||Ct)&&le(vt)},[D.value]),ot=n==="popper"?XV:lve,jt=ot===XV?{side:a,sideOffset:f,align:p,alignOffset:y,arrowPadding:v,collisionBoundary:S,collisionPadding:E,sticky:k,hideWhenDetached:R,avoidCollisions:P}:{};return i.jsx(ave,{scope:r,content:B,viewport:G,onViewportChange:W,itemRefCallback:ve,selectedItem:J,onItemLeave:qe,itemTextRefCallback:nt,focusSelectedItem:we,selectedItemText:ee,position:n,isPositioned:Te,searchRef:_e,children:i.jsx(PN,{as:cHe,allowPinchZoom:!0,children:i.jsx(IN,{asChild:!0,trapped:D.open,onMountAutoFocus:vt=>{vt.preventDefault()},onUnmountAutoFocus:Fr(s,vt=>{var Gt;(Gt=D.trigger)==null||Gt.focus({preventScroll:!0}),vt.preventDefault()}),children:i.jsx(A_,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:o,onPointerDownOutside:c,onFocusOutside:vt=>vt.preventDefault(),onDismiss:()=>D.onOpenChange(!1),children:i.jsx(ot,{role:"listbox",id:D.contentId,"data-state":D.open?"open":"closed",dir:D.dir,onContextMenu:vt=>vt.preventDefault(),...M,...jt,onPlaced:()=>Ae(!0),ref:Y,style:{display:"flex",flexDirection:"column",outline:"none",...M.style},onKeyDown:Fr(M.onKeyDown,vt=>{const Gt=vt.ctrlKey||vt.altKey||vt.metaKey;if(vt.key==="Tab"&&vt.preventDefault(),!Gt&&vt.key.length===1&&Ee(vt.key),["ArrowUp","ArrowDown","Home","End"].includes(vt.key)){let Ct=pe().filter(tr=>!tr.disabled).map(tr=>tr.ref.current);if(["ArrowUp","End"].includes(vt.key)&&(Ct=Ct.slice().reverse()),["ArrowUp","ArrowDown"].includes(vt.key)){const tr=vt.target,wt=Ct.indexOf(tr);Ct=Ct.slice(wt+1)}setTimeout(()=>ke(Ct)),vt.preventDefault()}})})})})})})});ove.displayName=lHe;var uHe="SelectItemAlignedPosition",lve=N.forwardRef((t,e)=>{const{__scopeSelect:r,onPlaced:n,...s}=t,o=Ux(p_,r),c=Vx(p_,r),[a,f]=N.useState(null),[p,y]=N.useState(null),v=Zn(e,Y=>y(Y)),S=Y3(r),E=N.useRef(!1),k=N.useRef(!0),{viewport:R,selectedItem:P,selectedItemText:M,focusSelectedItem:D}=c,B=N.useCallback(()=>{if(o.trigger&&o.valueNode&&a&&p&&R&&P&&M){const Y=o.trigger.getBoundingClientRect(),J=p.getBoundingClientRect(),Q=o.valueNode.getBoundingClientRect(),ee=M.getBoundingClientRect();if(o.dir!=="rtl"){const tr=ee.left-J.left,wt=Q.left-tr,lr=Y.left-wt,Sr=Y.width+lr,sn=Math.max(Sr,J.width),cr=window.innerWidth-Wh,yr=fk(wt,[Wh,Math.max(Wh,cr-sn)]);a.style.minWidth=Sr+"px",a.style.left=yr+"px"}else{const tr=J.right-ee.right,wt=window.innerWidth-Q.right-tr,lr=window.innerWidth-Y.right-wt,Sr=Y.width+lr,sn=Math.max(Sr,J.width),cr=window.innerWidth-Wh,yr=fk(wt,[Wh,Math.max(Wh,cr-sn)]);a.style.minWidth=Sr+"px",a.style.right=yr+"px"}const le=S(),pe=window.innerHeight-Wh*2,Te=R.scrollHeight,Ae=window.getComputedStyle(p),Le=parseInt(Ae.borderTopWidth,10),ke=parseInt(Ae.paddingTop,10),we=parseInt(Ae.borderBottomWidth,10),me=parseInt(Ae.paddingBottom,10),je=Le+ke+Te+me+we,_e=Math.min(P.offsetHeight*5,je),Ee=window.getComputedStyle(R),ve=parseInt(Ee.paddingTop,10),qe=parseInt(Ee.paddingBottom,10),nt=Y.top+Y.height/2-Wh,ot=pe-nt,jt=P.offsetHeight/2,vt=P.offsetTop+jt,Gt=Le+ke+vt,pt=je-Gt;if(Gt<=nt){const tr=le.length>0&&P===le[le.length-1].ref.current;a.style.bottom="0px";const wt=p.clientHeight-R.offsetTop-R.offsetHeight,lr=Math.max(ot,jt+(tr?qe:0)+wt+we),Sr=Gt+lr;a.style.height=Sr+"px"}else{const tr=le.length>0&&P===le[0].ref.current;a.style.top="0px";const lr=Math.max(nt,Le+R.offsetTop+(tr?ve:0)+jt)+pt;a.style.height=lr+"px",R.scrollTop=Gt-nt+R.offsetTop}a.style.margin=`${Wh}px 0`,a.style.minHeight=_e+"px",a.style.maxHeight=pe+"px",n==null||n(),requestAnimationFrame(()=>E.current=!0)}},[S,o.trigger,o.valueNode,a,p,R,P,M,o.dir,n]);Do(()=>B(),[B]);const[V,G]=N.useState();Do(()=>{p&&G(window.getComputedStyle(p).zIndex)},[p]);const W=N.useCallback(Y=>{Y&&k.current===!0&&(B(),D==null||D(),k.current=!1)},[B,D]);return i.jsx(hHe,{scope:r,contentWrapper:a,shouldExpandOnScrollRef:E,onScrollButtonChange:W,children:i.jsx("div",{ref:f,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:V},children:i.jsx(nn.div,{...s,ref:v,style:{boxSizing:"border-box",maxHeight:"100%",...s.style}})})})});lve.displayName=uHe;var dHe="SelectPopperPosition",XV=N.forwardRef((t,e)=>{const{__scopeSelect:r,align:n="start",collisionPadding:s=Wh,...o}=t,c=Z3(r);return i.jsx(_3,{...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)"}})});XV.displayName=dHe;var[hHe,uH]=ST(p_,{}),QV="SelectViewport",cve=N.forwardRef((t,e)=>{const{__scopeSelect:r,nonce:n,...s}=t,o=Vx(QV,r),c=uH(QV,r),a=Zn(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(K3.Slot,{scope:r,children:i.jsx(nn.div,{"data-radix-select-viewport":"",role:"presentation",...s,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...s.style},onScroll:Fr(s.onScroll,p=>{const y=p.currentTarget,{contentWrapper:v,shouldExpandOnScrollRef:S}=c;if(S!=null&&S.current&&v){const E=Math.abs(f.current-y.scrollTop);if(E>0){const k=window.innerHeight-Wh*2,R=parseFloat(v.style.minHeight),P=parseFloat(v.style.height),M=Math.max(R,P);if(M0?V:0,v.style.justifyContent="flex-end")}}}f.current=y.scrollTop})})})]})});cve.displayName=QV;var uve="SelectGroup",[fHe,mHe]=ST(uve),dve=N.forwardRef((t,e)=>{const{__scopeSelect:r,...n}=t,s=Fl();return i.jsx(fHe,{scope:r,id:s,children:i.jsx(nn.div,{role:"group","aria-labelledby":s,...n,ref:e})})});dve.displayName=uve;var hve="SelectLabel",fve=N.forwardRef((t,e)=>{const{__scopeSelect:r,...n}=t,s=mHe(hve,r);return i.jsx(nn.div,{id:s.id,...n,ref:e})});fve.displayName=hve;var uD="SelectItem",[pHe,mve]=ST(uD),pve=N.forwardRef((t,e)=>{const{__scopeSelect:r,value:n,disabled:s=!1,textValue:o,...c}=t,a=Ux(uD,r),f=Vx(uD,r),p=a.value===n,[y,v]=N.useState(o??""),[S,E]=N.useState(!1),k=Zn(e,D=>{var B;return(B=f.itemRefCallback)==null?void 0:B.call(f,D,n,s)}),R=Fl(),P=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(pHe,{scope:r,value:n,disabled:s,textId:R,isSelected:p,onItemTextChange:N.useCallback(D=>{v(B=>B||((D==null?void 0:D.textContent)??"").trim())},[]),children:i.jsx(K3.ItemSlot,{scope:r,value:n,disabled:s,textValue:y,children:i.jsx(nn.div,{role:"option","aria-labelledby":R,"data-highlighted":S?"":void 0,"aria-selected":p&&S,"data-state":p?"checked":"unchecked","aria-disabled":s||void 0,"data-disabled":s?"":void 0,tabIndex:s?void 0:-1,...c,ref:k,onFocus:Fr(c.onFocus,()=>E(!0)),onBlur:Fr(c.onBlur,()=>E(!1)),onClick:Fr(c.onClick,()=>{P.current!=="mouse"&&M()}),onPointerUp:Fr(c.onPointerUp,()=>{P.current==="mouse"&&M()}),onPointerDown:Fr(c.onPointerDown,D=>{P.current=D.pointerType}),onPointerMove:Fr(c.onPointerMove,D=>{var B;P.current=D.pointerType,s?(B=f.onItemLeave)==null||B.call(f):P.current==="mouse"&&D.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Fr(c.onPointerLeave,D=>{var B;D.currentTarget===document.activeElement&&((B=f.onItemLeave)==null||B.call(f))}),onKeyDown:Fr(c.onKeyDown,D=>{var V;((V=f.searchRef)==null?void 0:V.current)!==""&&D.key===" "||(tHe.includes(D.key)&&M(),D.key===" "&&D.preventDefault())})})})})});pve.displayName=uD;var Z2="SelectItemText",gve=N.forwardRef((t,e)=>{const{__scopeSelect:r,className:n,style:s,...o}=t,c=Ux(Z2,r),a=Vx(Z2,r),f=mve(Z2,r),p=iHe(Z2,r),[y,v]=N.useState(null),S=Zn(e,M=>v(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,k=N.useMemo(()=>i.jsx("option",{value:f.value,disabled:f.disabled,children:E},f.value),[f.disabled,f.value,E]),{onNativeOptionAdd:R,onNativeOptionRemove:P}=p;return Do(()=>(R(k),()=>P(k)),[R,P,k]),i.jsxs(i.Fragment,{children:[i.jsx(nn.span,{id:f.textId,...o,ref:S}),f.isSelected&&c.valueNode&&!c.valueNodeHasChildren?xg.createPortal(o.children,c.valueNode):null]})});gve.displayName=Z2;var yve="SelectItemIndicator",xve=N.forwardRef((t,e)=>{const{__scopeSelect:r,...n}=t;return mve(yve,r).isSelected?i.jsx(nn.span,{"aria-hidden":!0,...n,ref:e}):null});xve.displayName=yve;var JV="SelectScrollUpButton",vve=N.forwardRef((t,e)=>{const r=Vx(JV,t.__scopeSelect),n=uH(JV,t.__scopeSelect),[s,o]=N.useState(!1),c=Zn(e,n.onScrollButtonChange);return Do(()=>{if(r.viewport&&r.isPositioned){let a=function(){const p=f.scrollTop>0;o(p)};const f=r.viewport;return a(),f.addEventListener("scroll",a),()=>f.removeEventListener("scroll",a)}},[r.viewport,r.isPositioned]),s?i.jsx(bve,{...t,ref:c,onAutoScroll:()=>{const{viewport:a,selectedItem:f}=r;a&&f&&(a.scrollTop=a.scrollTop-f.offsetHeight)}}):null});vve.displayName=JV;var e8="SelectScrollDownButton",_ve=N.forwardRef((t,e)=>{const r=Vx(e8,t.__scopeSelect),n=uH(e8,t.__scopeSelect),[s,o]=N.useState(!1),c=Zn(e,n.onScrollButtonChange);return Do(()=>{if(r.viewport&&r.isPositioned){let a=function(){const p=f.scrollHeight-f.clientHeight,y=Math.ceil(f.scrollTop)f.removeEventListener("scroll",a)}},[r.viewport,r.isPositioned]),s?i.jsx(bve,{...t,ref:c,onAutoScroll:()=>{const{viewport:a,selectedItem:f}=r;a&&f&&(a.scrollTop=a.scrollTop+f.offsetHeight)}}):null});_ve.displayName=e8;var bve=N.forwardRef((t,e)=>{const{__scopeSelect:r,onAutoScroll:n,...s}=t,o=Vx("SelectScrollButton",r),c=N.useRef(null),a=Y3(r),f=N.useCallback(()=>{c.current!==null&&(window.clearInterval(c.current),c.current=null)},[]);return N.useEffect(()=>()=>f(),[f]),Do(()=>{var y;const p=a().find(v=>v.ref.current===document.activeElement);(y=p==null?void 0:p.ref.current)==null||y.scrollIntoView({block:"nearest"})},[a]),i.jsx(nn.div,{"aria-hidden":!0,...s,ref:e,style:{flexShrink:0,...s.style},onPointerDown:Fr(s.onPointerDown,()=>{c.current===null&&(c.current=window.setInterval(n,50))}),onPointerMove:Fr(s.onPointerMove,()=>{var p;(p=o.onItemLeave)==null||p.call(o),c.current===null&&(c.current=window.setInterval(n,50))}),onPointerLeave:Fr(s.onPointerLeave,()=>{f()})})}),gHe="SelectSeparator",wve=N.forwardRef((t,e)=>{const{__scopeSelect:r,...n}=t;return i.jsx(nn.div,{"aria-hidden":!0,...n,ref:e})});wve.displayName=gHe;var t8="SelectArrow",yHe=N.forwardRef((t,e)=>{const{__scopeSelect:r,...n}=t,s=Z3(r),o=Ux(t8,r),c=Vx(t8,r);return o.open&&c.position==="popper"?i.jsx(b3,{...s,...n,ref:e}):null});yHe.displayName=t8;var xHe="SelectBubbleInput",Sve=N.forwardRef(({__scopeSelect:t,value:e,...r},n)=>{const s=N.useRef(null),o=Zn(n,s),c=KN(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 v=new Event("change",{bubbles:!0});y.call(a,e),a.dispatchEvent(v)}},[c,e]),i.jsx(nn.select,{...r,style:{...ome,...r.style},ref:o,defaultValue:e})});Sve.displayName=xHe;function Tve(t){return t===""||t===void 0}function Eve(t){const e=_o(t),r=N.useRef(""),n=N.useRef(0),s=N.useCallback(c=>{const a=r.current+c;e(a),function f(p){r.current=p,window.clearTimeout(n.current),p!==""&&(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 jve(t,e,r){const s=e.length>1&&Array.from(e).every(p=>p===e[0])?e[0]:e,o=r?t.indexOf(r):-1;let c=vHe(t,Math.max(o,0));s.length===1&&(c=c.filter(p=>p!==r));const f=c.find(p=>p.textValue.toLowerCase().startsWith(s.toLowerCase()));return f!==r?f:void 0}function vHe(t,e){return t.map((r,n)=>t[(e+n)%t.length])}var _He=Q0e,Ave=eve,bHe=rve,wHe=nve,SHe=sve,kve=ive,THe=cve,EHe=dve,Nve=fve,Cve=pve,jHe=gve,AHe=xve,Ive=vve,Pve=_ve,Rve=wve;const ba=_He,CGt=EHe,wa=bHe,la=N.forwardRef(({className:t,children:e,...r},n)=>i.jsxs(Ave,{ref:n,className:qt("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(wHe,{asChild:!0,children:i.jsx(xl,{className:"h-4 w-4 opacity-50"})})]}));la.displayName=Ave.displayName;const Lve=N.forwardRef(({className:t,...e},r)=>i.jsx(Ive,{ref:r,className:qt("flex cursor-default items-center justify-center py-1",t),...e,children:i.jsx(Ime,{className:"h-4 w-4"})}));Lve.displayName=Ive.displayName;const Mve=N.forwardRef(({className:t,...e},r)=>i.jsx(Pve,{ref:r,className:qt("flex cursor-default items-center justify-center py-1",t),...e,children:i.jsx(xl,{className:"h-4 w-4"})}));Mve.displayName=Pve.displayName;const ca=N.forwardRef(({className:t,children:e,position:r="popper",...n},s)=>i.jsx(SHe,{children:i.jsxs(kve,{ref:s,className:qt("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(Lve,{}),i.jsx(THe,{className:qt("p-1",r==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:e}),i.jsx(Mve,{})]})}));ca.displayName=kve.displayName;const kHe=N.forwardRef(({className:t,...e},r)=>i.jsx(Nve,{ref:r,className:qt("py-1.5 pl-8 pr-2 text-sm font-semibold",t),...e}));kHe.displayName=Nve.displayName;const mn=N.forwardRef(({className:t,children:e,...r},n)=>i.jsxs(Cve,{ref:n,className:qt("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(AHe,{children:i.jsx(Oa,{className:"h-4 w-4"})})}),i.jsx(jHe,{children:e})]}));mn.displayName=Cve.displayName;const NHe=N.forwardRef(({className:t,...e},r)=>i.jsx(Rve,{ref:r,className:qt("-mx-1 my-1 h-px bg-muted",t),...e}));NHe.displayName=Rve.displayName;const CHe=bg({category:_S(["general","technology","crm","marketing"]),subject:Ns().min(5,"Subject must be at least 5 characters").max(200),description:Ns().min(20,"Please provide more details (at least 20 characters)").max(1e4,"Please keep the description under 10,000 characters")}),IHe={general:"General Support",technology:"Technology Support",crm:"CRM Support",marketing:"Marketing Support"};function PHe({trigger:t}){const[e,r]=N.useState(!1),[n,s]=N.useState(!1),{user:o}=Wn(),c=J7({resolver:eH(CHe),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:p}=await Re.from("support_tickets").insert({user_id:o.id,category:f.category,subject:f.subject,description:f.description});if(p)throw p;try{await Re.functions.invoke("support-ticket-notify",{body:{category:IHe[f.category],subject:f.subject}})}catch(y){console.log("Notification send attempted:",y)}$t.success("Support ticket submitted successfully!"),c.reset(),r(!1)}catch(p){console.error("Error submitting ticket:",p),$t.error("Failed to submit ticket. Please try again.")}finally{s(!1)}};return i.jsxs(Fa,{open:e,onOpenChange:r,children:[i.jsx(Oxe,{asChild:!0,children:t||i.jsxs(Dt,{variant:"ghost",size:"icon",className:"relative",children:[i.jsx(mDe,{className:"h-5 w-5"}),i.jsx("span",{className:"sr-only",children:"Support"})]})}),i.jsxs(Sa,{className:"sm:max-w-[500px]",children:[i.jsxs(Fo,{children:[i.jsx(bo,{children:"Need Help?"}),i.jsx(Fu,{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(zn,{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(cH,{...c,children:i.jsxs("form",{onSubmit:c.handleSubmit(a),className:"space-y-4",children:[i.jsx(cl,{control:c.control,name:"category",render:({field:f})=>i.jsxs(Ho,{children:[i.jsx(Wo,{children:"Category"}),i.jsxs(ba,{onValueChange:f.onChange,defaultValue:f.value,children:[i.jsx(Ko,{children:i.jsx(la,{children:i.jsx(wa,{placeholder:"Select a category"})})}),i.jsxs(ca,{children:[i.jsx(mn,{value:"general",children:"General Support"}),i.jsx(mn,{value:"technology",children:"Technology Support"}),i.jsx(mn,{value:"crm",children:"CRM Support"}),i.jsx(mn,{value:"marketing",children:"Marketing Support"})]})]}),i.jsx(df,{})]})}),i.jsx(cl,{control:c.control,name:"subject",render:({field:f})=>i.jsxs(Ho,{children:[i.jsx(Wo,{children:"Subject"}),i.jsx(Ko,{children:i.jsx(Dr,{placeholder:"Brief description of your issue",...f})}),i.jsx(df,{})]})}),i.jsx(cl,{control:c.control,name:"description",render:({field:f})=>{var p;return i.jsxs(Ho,{children:[i.jsx(Wo,{children:"Description"}),i.jsx(Ko,{children:i.jsx(Bu,{placeholder:"Please describe your issue in detail...",className:"min-h-[120px]",...f})}),i.jsxs("p",{className:"text-right text-xs text-muted-foreground",children:[(((p=f.value)==null?void 0:p.length)??0).toLocaleString()," / 10,000"]}),i.jsx(df,{})]})}}),i.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[i.jsx(Dt,{type:"button",variant:"outline",onClick:()=>r(!1),children:"Cancel"}),i.jsx(Dt,{type:"submit",disabled:n,children:n?"Submitting...":"Submit Ticket"})]})]})})]})]})}function On(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 Qi(t,e){return t instanceof Date?new t.constructor(e):new Date(e)}function Rl(t,e){const r=On(t);return isNaN(e)?Qi(t,NaN):(e&&r.setDate(r.getDate()+e),r)}function Ed(t,e){const r=On(t);if(isNaN(e))return Qi(t,NaN);if(!e)return r;const n=r.getDate(),s=Qi(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 dH=6048e5,RHe=864e5,hH=6e4,fH=36e5,LHe=1e3,wR=43200,Jre=1440;let MHe={};function qx(){return MHe}function Ac(t,e){var a,f,p,y;const r=qx(),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=(p=r.locale)==null?void 0:p.options)==null?void 0:y.weekStartsOn)??0,s=On(t),o=s.getDay(),c=(o=s.getTime()?r+1:e.getTime()>=c.getTime()?r:r-1}function Sx(t){const e=On(t);return e.setHours(0,0,0,0),e}function Tx(t){const e=On(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 hf(t,e){const r=Sx(t),n=Sx(e),s=+r-Tx(r),o=+n-Tx(n);return Math.round((s-o)/RHe)}function DHe(t){const e=Dve(t),r=Qi(t,0);return r.setFullYear(e,0,4),r.setHours(0,0,0,0),dg(r)}function r8(t,e){const r=e*7;return Rl(t,r)}function OHe(t,e){return Ed(t,e*12)}function FHe(t){let e;return t.forEach(function(r){const n=On(r);(e===void 0||e{const n=On(r);(!e||e>n||isNaN(+n))&&(e=n)}),e||new Date(NaN)}function FL(t,e){const r=On(t),n=On(e),s=r.getTime()-n.getTime();return s<0?-1:s>0?1:s}function mH(t){return Qi(t,Date.now())}function sc(t,e){const r=Sx(t),n=Sx(e);return+r==+n}function pH(t){return t instanceof Date||typeof t=="object"&&Object.prototype.toString.call(t)==="[object Date]"}function n8(t){if(!pH(t)&&typeof t!="number")return!1;const e=On(t);return!isNaN(Number(e))}function bS(t,e){const r=On(t),n=On(e),s=r.getFullYear()-n.getFullYear(),o=r.getMonth()-n.getMonth();return s*12+o}function $He(t,e,r){const n=Ac(t,r),s=Ac(e,r),o=+n-Tx(n),c=+s-Tx(s);return Math.round((o-c)/dH)}function zHe(t,e){const r=On(t),n=On(e),s=ene(r,n),o=Math.abs(hf(r,n));r.setDate(r.getDate()-s*o);const c=+(ene(r,n)===-s),a=s*(o-c);return a===0?0:a}function ene(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 UHe(t){return e=>{const n=(t?Math[t]:Math.trunc)(e);return n===0?0:n}}function VHe(t,e){return+On(t)-+On(e)}function qHe(t){const e=On(t);return e.setHours(23,59,59,999),e}function YN(t){const e=On(t),r=e.getMonth();return e.setFullYear(e.getFullYear(),r+1,0),e.setHours(23,59,59,999),e}function GHe(t){const e=On(t);return+qHe(e)==+YN(e)}function HHe(t,e){const r=On(t),n=On(e),s=FL(r,n),o=Math.abs(bS(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=FL(r,n)===-s;GHe(On(t))&&o===1&&FL(t,n)===1&&(a=!1),c=s*(o-Number(a))}return c===0?0:c}function WHe(t,e,r){const n=VHe(t,e)/1e3;return UHe(r==null?void 0:r.roundingMethod)(n)}function KHe(t,e){const r=On(t.start),n=On(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(On(c)),c.setDate(c.getDate()+a),c.setHours(0,0,0,0);return s?f.reverse():f}function iu(t){const e=On(t);return e.setDate(1),e.setHours(0,0,0,0),e}function Ove(t){const e=On(t),r=Qi(t,0);return r.setFullYear(e.getFullYear(),0,1),r.setHours(0,0,0,0),r}function X3(t,e){var a,f,p,y;const r=qx(),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=(p=r.locale)==null?void 0:p.options)==null?void 0:y.weekStartsOn)??0,s=On(t),o=s.getDay(),c=(o{let n;const s=YHe[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 J$(t){return(e={})=>{const r=e.width?String(e.width):t.defaultWidth;return t.formats[r]||t.formats[t.defaultWidth]}}const XHe={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},QHe={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},JHe={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},eWe={date:J$({formats:XHe,defaultWidth:"full"}),time:J$({formats:QHe,defaultWidth:"full"}),dateTime:J$({formats:JHe,defaultWidth:"full"})},tWe={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},rWe=(t,e,r,n)=>tWe[t];function y2(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 nWe={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},sWe={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},iWe={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"]},aWe={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"]},oWe={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"}},lWe={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"}},cWe=(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"},uWe={ordinalNumber:cWe,era:y2({values:nWe,defaultWidth:"wide"}),quarter:y2({values:sWe,defaultWidth:"wide",argumentCallback:t=>t-1}),month:y2({values:iWe,defaultWidth:"wide"}),day:y2({values:aWe,defaultWidth:"wide"}),dayPeriod:y2({values:oWe,defaultWidth:"wide",formattingValues:lWe,defaultFormattingWidth:"wide"})};function x2(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)?hWe(a,v=>v.test(c)):dWe(a,v=>v.test(c));let p;p=t.valueCallback?t.valueCallback(f):f,p=r.valueCallback?r.valueCallback(p):p;const y=e.slice(c.length);return{value:p,rest:y}}}function dWe(t,e){for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&e(t[r]))return r}function hWe(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 mWe=/^(\d+)(th|st|nd|rd)?/i,pWe=/\d+/i,gWe={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},yWe={any:[/^b/i,/^(a|c)/i]},xWe={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},vWe={any:[/1/i,/2/i,/3/i,/4/i]},_We={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},bWe={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]},wWe={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},SWe={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]},TWe={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},EWe={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}},jWe={ordinalNumber:fWe({matchPattern:mWe,parsePattern:pWe,valueCallback:t=>parseInt(t,10)}),era:x2({matchPatterns:gWe,defaultMatchWidth:"wide",parsePatterns:yWe,defaultParseWidth:"any"}),quarter:x2({matchPatterns:xWe,defaultMatchWidth:"wide",parsePatterns:vWe,defaultParseWidth:"any",valueCallback:t=>t+1}),month:x2({matchPatterns:_We,defaultMatchWidth:"wide",parsePatterns:bWe,defaultParseWidth:"any"}),day:x2({matchPatterns:wWe,defaultMatchWidth:"wide",parsePatterns:SWe,defaultParseWidth:"any"}),dayPeriod:x2({matchPatterns:TWe,defaultMatchWidth:"any",parsePatterns:EWe,defaultParseWidth:"any"})},Q3={code:"en-US",formatDistance:ZHe,formatLong:eWe,formatRelative:rWe,localize:uWe,match:jWe,options:{weekStartsOn:0,firstWeekContainsDate:1}};function AWe(t){const e=On(t);return hf(e,Ove(e))+1}function gH(t){const e=On(t),r=+dg(e)-+DHe(e);return Math.round(r/dH)+1}function yH(t,e){var y,v,S,E;const r=On(t),n=r.getFullYear(),s=qx(),o=(e==null?void 0:e.firstWeekContainsDate)??((v=(y=e==null?void 0:e.locale)==null?void 0:y.options)==null?void 0:v.firstWeekContainsDate)??s.firstWeekContainsDate??((E=(S=s.locale)==null?void 0:S.options)==null?void 0:E.firstWeekContainsDate)??1,c=Qi(t,0);c.setFullYear(n+1,0,o),c.setHours(0,0,0,0);const a=Ac(c,e),f=Qi(t,0);f.setFullYear(n,0,o),f.setHours(0,0,0,0);const p=Ac(f,e);return r.getTime()>=a.getTime()?n+1:r.getTime()>=p.getTime()?n:n-1}function kWe(t,e){var a,f,p,y;const r=qx(),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=(p=r.locale)==null?void 0:p.options)==null?void 0:y.firstWeekContainsDate)??1,s=yH(t,e),o=Qi(t,0);return o.setFullYear(s,0,n),o.setHours(0,0,0,0),Ac(o,e)}function xH(t,e){const r=On(t),n=+Ac(r,e)-+kWe(r,e);return Math.round(n/dH)+1}function zi(t,e){const r=t<0?"-":"",n=Math.abs(t).toString().padStart(e,"0");return r+n}const gy={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)}},jw={am:"am",pm:"pm",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},tne={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 gy.y(t,e)},Y:function(t,e,r,n){const s=yH(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=Dve(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 gy.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=xH(t,n);return e==="wo"?r.ordinalNumber(s,{unit:"week"}):zi(s,e.length)},I:function(t,e,r){const n=gH(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"}):gy.d(t,e)},D:function(t,e,r){const n=AWe(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=jw.noon:n===0?s=jw.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=jw.evening:n>=12?s=jw.afternoon:n>=4?s=jw.morning:s=jw.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 gy.h(t,e)},H:function(t,e,r){return e==="Ho"?r.ordinalNumber(t.getHours(),{unit:"hour"}):gy.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"}):gy.m(t,e)},s:function(t,e,r){return e==="so"?r.ordinalNumber(t.getSeconds(),{unit:"second"}):gy.s(t,e)},S:function(t,e){return gy.S(t,e)},X:function(t,e,r){const n=t.getTimezoneOffset();if(n===0)return"Z";switch(e){case"X":return nne(n);case"XXXX":case"XX":return bv(n);case"XXXXX":case"XXX":default:return bv(n,":")}},x:function(t,e,r){const n=t.getTimezoneOffset();switch(e){case"x":return nne(n);case"xxxx":case"xx":return bv(n);case"xxxxx":case"xxx":default:return bv(n,":")}},O:function(t,e,r){const n=t.getTimezoneOffset();switch(e){case"O":case"OO":case"OOO":return"GMT"+rne(n,":");case"OOOO":default:return"GMT"+bv(n,":")}},z:function(t,e,r){const n=t.getTimezoneOffset();switch(e){case"z":case"zz":case"zzz":return"GMT"+rne(n,":");case"zzzz":default:return"GMT"+bv(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 rne(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 nne(t,e){return t%60===0?(t>0?"-":"+")+zi(Math.abs(t)/60,2):bv(t,e)}function bv(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 sne=(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"})}},Bve=(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"})}},NWe=(t,e)=>{const r=t.match(/(P+)(p+)?/)||[],n=r[1],s=r[2];if(!s)return sne(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}}",sne(n,e)).replace("{{time}}",Bve(s,e))},s8={p:Bve,P:NWe},CWe=/^D+$/,IWe=/^Y+$/,PWe=["D","DD","YY","YYYY"];function $ve(t){return CWe.test(t)}function zve(t){return IWe.test(t)}function i8(t,e,r){const n=RWe(t,e,r);if(console.warn(n),PWe.includes(t))throw new RangeError(n)}function RWe(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 LWe=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,MWe=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,DWe=/^'([^]*?)'?$/,OWe=/''/g,FWe=/[a-zA-Z]/;function As(t,e,r){var y,v,S,E,k,R,P,M;const n=qx(),s=(r==null?void 0:r.locale)??n.locale??Q3,o=(r==null?void 0:r.firstWeekContainsDate)??((v=(y=r==null?void 0:r.locale)==null?void 0:y.options)==null?void 0:v.firstWeekContainsDate)??n.firstWeekContainsDate??((E=(S=n.locale)==null?void 0:S.options)==null?void 0:E.firstWeekContainsDate)??1,c=(r==null?void 0:r.weekStartsOn)??((R=(k=r==null?void 0:r.locale)==null?void 0:k.options)==null?void 0:R.weekStartsOn)??n.weekStartsOn??((M=(P=n.locale)==null?void 0:P.options)==null?void 0:M.weekStartsOn)??0,a=On(t);if(!n8(a))throw new RangeError("Invalid time value");let f=e.match(MWe).map(D=>{const B=D[0];if(B==="p"||B==="P"){const V=s8[B];return V(D,s.formatLong)}return D}).join("").match(LWe).map(D=>{if(D==="''")return{isToken:!1,value:"'"};const B=D[0];if(B==="'")return{isToken:!1,value:BWe(D)};if(tne[B])return{isToken:!0,value:D};if(B.match(FWe))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 p={firstWeekContainsDate:o,weekStartsOn:c,locale:s};return f.map(D=>{if(!D.isToken)return D.value;const B=D.value;(!(r!=null&&r.useAdditionalWeekYearTokens)&&zve(B)||!(r!=null&&r.useAdditionalDayOfYearTokens)&&$ve(B))&&i8(B,e,String(t));const V=tne[B[0]];return V(a,B,s.localize,p)}).join("")}function BWe(t){const e=t.match(DWe);return e?e[1].replace(OWe,"'"):t}function $We(t,e,r){const n=qx(),s=(r==null?void 0:r.locale)??n.locale??Q3,o=2520,c=FL(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,p;c>0?(f=On(e),p=On(t)):(f=On(t),p=On(e));const y=WHe(p,f),v=(Tx(p)-Tx(f))/1e3,S=Math.round((y-v)/60);let E;if(S<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):S===0?s.formatDistance("lessThanXMinutes",1,a):s.formatDistance("xMinutes",S,a);if(S<45)return s.formatDistance("xMinutes",S,a);if(S<90)return s.formatDistance("aboutXHours",1,a);if(Sn.getTime()}function vH(t,e){const r=On(t),n=On(e);return+r<+n}function WWe(t,e){const r=e instanceof Date?Qi(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 KWe=10;class Vve{constructor(){dn(this,"subPriority",0)}validate(e,r){return!0}}class YWe extends Vve{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 ZWe extends Vve{constructor(){super(...arguments);dn(this,"priority",KWe);dn(this,"subPriority",-1)}set(r,n){return n.timestampIsSet?r:Qi(r,WWe(r,Date))}}class Ni{run(e,r,n,s){const o=this.parse(e,r,n,s);return o?{setter:new YWe(o.value,this.validate,this.set,this.priority,this.subPriority),rest:o.rest}:null}validate(e,r,n){return!0}}class XWe extends Ni{constructor(){super(...arguments);dn(this,"priority",140);dn(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 Ro={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}/},hm={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 Lo(t,e){return t&&{value:e(t.value),rest:t.rest}}function io(t,e){const r=e.match(t);return r?{value:parseInt(r[0],10),rest:e.slice(r[0].length)}:null}function fm(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*fH+o*hH+c*LHe),rest:e.slice(r[0].length)}}function qve(t){return io(Ro.anyDigitsSigned,t)}function wo(t,e){switch(t){case 1:return io(Ro.singleDigit,e);case 2:return io(Ro.twoDigits,e);case 3:return io(Ro.threeDigits,e);case 4:return io(Ro.fourDigits,e);default:return io(new RegExp("^\\d{1,"+t+"}"),e)}}function dD(t,e){switch(t){case 1:return io(Ro.singleDigitSigned,e);case 2:return io(Ro.twoDigitsSigned,e);case 3:return io(Ro.threeDigitsSigned,e);case 4:return io(Ro.fourDigitsSigned,e);default:return io(new RegExp("^-?\\d{1,"+t+"}"),e)}}function _H(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 Gve(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 Hve(t){return t%400===0||t%4===0&&t%100!==0}class QWe extends Ni{constructor(){super(...arguments);dn(this,"priority",130);dn(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 Lo(wo(4,r),o);case"yo":return Lo(s.ordinalNumber(r,{unit:"year"}),o);default:return Lo(wo(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=Gve(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 JWe extends Ni{constructor(){super(...arguments);dn(this,"priority",130);dn(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 Lo(wo(4,r),o);case"Yo":return Lo(s.ordinalNumber(r,{unit:"year"}),o);default:return Lo(wo(n.length,r),o)}}validate(r,n){return n.isTwoDigitYear||n.year>0}set(r,n,s,o){const c=yH(r,o);if(s.isTwoDigitYear){const f=Gve(s.year,c);return r.setFullYear(f,0,o.firstWeekContainsDate),r.setHours(0,0,0,0),Ac(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),Ac(r,o)}}class eKe extends Ni{constructor(){super(...arguments);dn(this,"priority",130);dn(this,"incompatibleTokens",["G","y","Y","u","Q","q","M","L","w","d","D","e","c","t","T"])}parse(r,n){return dD(n==="R"?4:n.length,r)}set(r,n,s){const o=Qi(r,0);return o.setFullYear(s,0,4),o.setHours(0,0,0,0),dg(o)}}class tKe extends Ni{constructor(){super(...arguments);dn(this,"priority",130);dn(this,"incompatibleTokens",["G","y","Y","R","w","I","i","e","c","t","T"])}parse(r,n){return dD(n==="u"?4:n.length,r)}set(r,n,s){return r.setFullYear(s,0,1),r.setHours(0,0,0,0),r}}class rKe extends Ni{constructor(){super(...arguments);dn(this,"priority",120);dn(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 wo(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 nKe extends Ni{constructor(){super(...arguments);dn(this,"priority",120);dn(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 wo(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 sKe extends Ni{constructor(){super(...arguments);dn(this,"incompatibleTokens",["Y","R","q","Q","L","w","I","D","i","e","c","t","T"]);dn(this,"priority",110)}parse(r,n,s){const o=c=>c-1;switch(n){case"M":return Lo(io(Ro.month,r),o);case"MM":return Lo(wo(2,r),o);case"Mo":return Lo(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 iKe extends Ni{constructor(){super(...arguments);dn(this,"priority",110);dn(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 Lo(io(Ro.month,r),o);case"LL":return Lo(wo(2,r),o);case"Lo":return Lo(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 aKe(t,e,r){const n=On(t),s=xH(n,r)-e;return n.setDate(n.getDate()-s*7),n}class oKe extends Ni{constructor(){super(...arguments);dn(this,"priority",100);dn(this,"incompatibleTokens",["y","R","u","q","Q","M","L","I","d","D","i","t","T"])}parse(r,n,s){switch(n){case"w":return io(Ro.week,r);case"wo":return s.ordinalNumber(r,{unit:"week"});default:return wo(n.length,r)}}validate(r,n){return n>=1&&n<=53}set(r,n,s,o){return Ac(aKe(r,s,o),o)}}function lKe(t,e){const r=On(t),n=gH(r)-e;return r.setDate(r.getDate()-n*7),r}class cKe extends Ni{constructor(){super(...arguments);dn(this,"priority",100);dn(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 io(Ro.week,r);case"Io":return s.ordinalNumber(r,{unit:"week"});default:return wo(n.length,r)}}validate(r,n){return n>=1&&n<=53}set(r,n,s){return dg(lKe(r,s))}}const uKe=[31,28,31,30,31,30,31,31,30,31,30,31],dKe=[31,29,31,30,31,30,31,31,30,31,30,31];class hKe extends Ni{constructor(){super(...arguments);dn(this,"priority",90);dn(this,"subPriority",1);dn(this,"incompatibleTokens",["Y","R","q","Q","w","I","D","i","e","c","t","T"])}parse(r,n,s){switch(n){case"d":return io(Ro.date,r);case"do":return s.ordinalNumber(r,{unit:"date"});default:return wo(n.length,r)}}validate(r,n){const s=r.getFullYear(),o=Hve(s),c=r.getMonth();return o?n>=1&&n<=dKe[c]:n>=1&&n<=uKe[c]}set(r,n,s){return r.setDate(s),r.setHours(0,0,0,0),r}}class fKe extends Ni{constructor(){super(...arguments);dn(this,"priority",90);dn(this,"subpriority",1);dn(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 io(Ro.dayOfYear,r);case"Do":return s.ordinalNumber(r,{unit:"date"});default:return wo(n.length,r)}}validate(r,n){const s=r.getFullYear();return Hve(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 bH(t,e,r){var v,S,E,k;const n=qx(),s=(r==null?void 0:r.weekStartsOn)??((S=(v=r==null?void 0:r.locale)==null?void 0:v.options)==null?void 0:S.weekStartsOn)??n.weekStartsOn??((k=(E=n.locale)==null?void 0:E.options)==null?void 0:k.weekStartsOn)??0,o=On(t),c=o.getDay(),f=(e%7+7)%7,p=7-s,y=e<0||e>6?e-(c+p)%7:(f+p)%7-(c+p)%7;return Rl(o,y)}class mKe extends Ni{constructor(){super(...arguments);dn(this,"priority",90);dn(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=bH(r,s,o),r.setHours(0,0,0,0),r}}class pKe extends Ni{constructor(){super(...arguments);dn(this,"priority",90);dn(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 Lo(wo(n.length,r),c);case"eo":return Lo(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=bH(r,s,o),r.setHours(0,0,0,0),r}}class gKe extends Ni{constructor(){super(...arguments);dn(this,"priority",90);dn(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 Lo(wo(n.length,r),c);case"co":return Lo(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=bH(r,s,o),r.setHours(0,0,0,0),r}}function yKe(t,e){const r=On(t),n=VWe(r),s=e-n;return Rl(r,s)}class xKe extends Ni{constructor(){super(...arguments);dn(this,"priority",90);dn(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 wo(n.length,r);case"io":return s.ordinalNumber(r,{unit:"day"});case"iii":return Lo(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 Lo(s.day(r,{width:"narrow",context:"formatting"}),o);case"iiiiii":return Lo(s.day(r,{width:"short",context:"formatting"})||s.day(r,{width:"narrow",context:"formatting"}),o);case"iiii":default:return Lo(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=yKe(r,s),r.setHours(0,0,0,0),r}}class vKe extends Ni{constructor(){super(...arguments);dn(this,"priority",80);dn(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(_H(s),0,0,0),r}}class _Ke extends Ni{constructor(){super(...arguments);dn(this,"priority",80);dn(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(_H(s),0,0,0),r}}class bKe extends Ni{constructor(){super(...arguments);dn(this,"priority",80);dn(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(_H(s),0,0,0),r}}class wKe extends Ni{constructor(){super(...arguments);dn(this,"priority",70);dn(this,"incompatibleTokens",["H","K","k","t","T"])}parse(r,n,s){switch(n){case"h":return io(Ro.hour12h,r);case"ho":return s.ordinalNumber(r,{unit:"hour"});default:return wo(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 SKe extends Ni{constructor(){super(...arguments);dn(this,"priority",70);dn(this,"incompatibleTokens",["a","b","h","K","k","t","T"])}parse(r,n,s){switch(n){case"H":return io(Ro.hour23h,r);case"Ho":return s.ordinalNumber(r,{unit:"hour"});default:return wo(n.length,r)}}validate(r,n){return n>=0&&n<=23}set(r,n,s){return r.setHours(s,0,0,0),r}}class TKe extends Ni{constructor(){super(...arguments);dn(this,"priority",70);dn(this,"incompatibleTokens",["h","H","k","t","T"])}parse(r,n,s){switch(n){case"K":return io(Ro.hour11h,r);case"Ko":return s.ordinalNumber(r,{unit:"hour"});default:return wo(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 EKe extends Ni{constructor(){super(...arguments);dn(this,"priority",70);dn(this,"incompatibleTokens",["a","b","h","H","K","t","T"])}parse(r,n,s){switch(n){case"k":return io(Ro.hour24h,r);case"ko":return s.ordinalNumber(r,{unit:"hour"});default:return wo(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 jKe extends Ni{constructor(){super(...arguments);dn(this,"priority",60);dn(this,"incompatibleTokens",["t","T"])}parse(r,n,s){switch(n){case"m":return io(Ro.minute,r);case"mo":return s.ordinalNumber(r,{unit:"minute"});default:return wo(n.length,r)}}validate(r,n){return n>=0&&n<=59}set(r,n,s){return r.setMinutes(s,0,0),r}}class AKe extends Ni{constructor(){super(...arguments);dn(this,"priority",50);dn(this,"incompatibleTokens",["t","T"])}parse(r,n,s){switch(n){case"s":return io(Ro.second,r);case"so":return s.ordinalNumber(r,{unit:"second"});default:return wo(n.length,r)}}validate(r,n){return n>=0&&n<=59}set(r,n,s){return r.setSeconds(s,0),r}}class kKe extends Ni{constructor(){super(...arguments);dn(this,"priority",30);dn(this,"incompatibleTokens",["t","T"])}parse(r,n){const s=o=>Math.trunc(o*Math.pow(10,-n.length+3));return Lo(wo(n.length,r),s)}set(r,n,s){return r.setMilliseconds(s),r}}class NKe extends Ni{constructor(){super(...arguments);dn(this,"priority",10);dn(this,"incompatibleTokens",["t","T","x"])}parse(r,n){switch(n){case"X":return fm(hm.basicOptionalMinutes,r);case"XX":return fm(hm.basic,r);case"XXXX":return fm(hm.basicOptionalSeconds,r);case"XXXXX":return fm(hm.extendedOptionalSeconds,r);case"XXX":default:return fm(hm.extended,r)}}set(r,n,s){return n.timestampIsSet?r:Qi(r,r.getTime()-Tx(r)-s)}}class CKe extends Ni{constructor(){super(...arguments);dn(this,"priority",10);dn(this,"incompatibleTokens",["t","T","X"])}parse(r,n){switch(n){case"x":return fm(hm.basicOptionalMinutes,r);case"xx":return fm(hm.basic,r);case"xxxx":return fm(hm.basicOptionalSeconds,r);case"xxxxx":return fm(hm.extendedOptionalSeconds,r);case"xxx":default:return fm(hm.extended,r)}}set(r,n,s){return n.timestampIsSet?r:Qi(r,r.getTime()-Tx(r)-s)}}class IKe extends Ni{constructor(){super(...arguments);dn(this,"priority",40);dn(this,"incompatibleTokens","*")}parse(r){return qve(r)}set(r,n,s){return[Qi(r,s*1e3),{timestampIsSet:!0}]}}class PKe extends Ni{constructor(){super(...arguments);dn(this,"priority",20);dn(this,"incompatibleTokens","*")}parse(r){return qve(r)}set(r,n,s){return[Qi(r,s),{timestampIsSet:!0}]}}const RKe={G:new XWe,y:new QWe,Y:new JWe,R:new eKe,u:new tKe,Q:new rKe,q:new nKe,M:new sKe,L:new iKe,w:new oKe,I:new cKe,d:new hKe,D:new fKe,E:new mKe,e:new pKe,c:new gKe,i:new xKe,a:new vKe,b:new _Ke,B:new bKe,h:new wKe,H:new SKe,K:new TKe,k:new EKe,m:new jKe,s:new AKe,S:new kKe,X:new NKe,x:new CKe,t:new IKe,T:new PKe},LKe=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,MKe=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,DKe=/^'([^]*?)'?$/,OKe=/''/g,FKe=/\S/,BKe=/[a-zA-Z]/;function $Ke(t,e,r,n){var R,P,M,D;const s=UWe(),o=s.locale??Q3,c=s.firstWeekContainsDate??((P=(R=s.locale)==null?void 0:R.options)==null?void 0:P.firstWeekContainsDate)??1,a=s.weekStartsOn??((D=(M=s.locale)==null?void 0:M.options)==null?void 0:D.weekStartsOn)??0;if(e==="")return t===""?On(r):Qi(r,NaN);const f={firstWeekContainsDate:c,weekStartsOn:a,locale:o},p=[new ZWe],y=e.match(MKe).map(B=>{const V=B[0];if(V in s8){const G=s8[V];return G(B,o.formatLong)}return B}).join("").match(LKe),v=[];for(let B of y){zve(B)&&i8(B,e,t),$ve(B)&&i8(B,e,t);const V=B[0],G=RKe[V];if(G){const{incompatibleTokens:W}=G;if(Array.isArray(W)){const J=v.find(Q=>W.includes(Q.token)||Q.token===V);if(J)throw new RangeError(`The format string mustn't contain \`${J.fullToken}\` and \`${B}\` at the same time`)}else if(G.incompatibleTokens==="*"&&v.length>0)throw new RangeError(`The format string mustn't contain \`${B}\` and any other token at the same time`);v.push({token:V,fullToken:B});const Y=G.run(t,B,o.match,f);if(!Y)return Qi(r,NaN);p.push(Y.setter),t=Y.rest}else{if(V.match(BKe))throw new RangeError("Format string contains an unescaped latin alphabet character `"+V+"`");if(B==="''"?B="'":V==="'"&&(B=zKe(B)),t.indexOf(B)===0)t=t.slice(B.length);else return Qi(r,NaN)}}if(t.length>0&&FKe.test(t))return Qi(r,NaN);const S=p.map(B=>B.priority).sort((B,V)=>V-B).filter((B,V,G)=>G.indexOf(B)===V).map(B=>p.filter(V=>V.priority===B).sort((V,G)=>G.subPriority-V.subPriority)).map(B=>B[0]);let E=On(r);if(isNaN(E.getTime()))return Qi(r,NaN);const k={};for(const B of S){if(!B.validate(E,f))return Qi(r,NaN);const V=B.set(E,k,f);Array.isArray(V)?(E=V[0],Object.assign(k,V[1])):E=V}return Qi(r,E)}function zKe(t){return t.match(DKe)[1].replace(OKe,"'")}function wS(t){return+On(t)2)return e;if(/:/.test(r[0])?n=r[0]:(e.date=r[0],n=r[1],SR.timeZoneDelimiter.test(e.date)&&(e.date=t.split(SR.timeZoneDelimiter)[0],n=t.substr(e.date.length,t.length))),n){const s=SR.timezone.exec(n);s?(e.time=n.replace(s[1],""),e.timezone=s[1]):e.time=n}return e}function YKe(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 ZKe(t,e){if(e===null)return new Date(NaN);const r=t.match(GKe);if(!r)return new Date(NaN);const n=!!r[4],s=v2(r[1]),o=v2(r[2])-1,c=v2(r[3]),a=v2(r[4]),f=v2(r[5])-1;if(n)return nYe(e,a,f)?JKe(e,a,f):new Date(NaN);{const p=new Date(0);return!tYe(e,o,c)||!rYe(e,s)?new Date(NaN):(p.setUTCFullYear(e,o,Math.max(s,c)),p)}}function v2(t){return t?parseInt(t):1}function XKe(t){const e=t.match(HKe);if(!e)return NaN;const r=tz(e[1]),n=tz(e[2]),s=tz(e[3]);return sYe(r,n,s)?r*fH+n*hH+s*1e3:NaN}function tz(t){return t&&parseFloat(t.replace(",","."))||0}function QKe(t){if(t==="Z")return 0;const e=t.match(WKe);if(!e)return 0;const r=e[1]==="+"?-1:1,n=parseInt(e[2]),s=e[3]&&parseInt(e[3])||0;return iYe(n,s)?r*(n*fH+s*hH):NaN}function JKe(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 eYe=[31,null,31,30,31,30,31,31,30,31,30,31];function Wve(t){return t%400===0||t%4===0&&t%100!==0}function tYe(t,e,r){return e>=0&&e<=11&&r>=1&&r<=(eYe[e]||(Wve(t)?29:28))}function rYe(t,e){return e>=1&&e<=(Wve(t)?366:365)}function nYe(t,e,r){return e>=1&&e<=53&&r>=0&&r<=6}function sYe(t,e,r){return t===24?e===0&&r===0:r>=0&&r<60&&e>=0&&e<60&&t>=0&&t<25}function iYe(t,e){return e>=0&&e<=59}function rz(t,e){const r=On(t),n=r.getFullYear(),s=r.getDate(),o=Qi(t,0);o.setFullYear(n,e,15),o.setHours(0,0,0,0);const c=zWe(o);return r.setMonth(e,Math.min(s,c)),r}function ine(t,e){const r=On(t);return isNaN(+r)?Qi(t,NaN):(r.setFullYear(e),r)}function aYe(t,e){return Ed(t,-e)}const oYe=()=>{const{user:t}=Wn(),e=Wi(),[r,n]=N.useState([]),[s,o]=N.useState(0),[c,a]=N.useState(!1),[f,p]=N.useState(null),y=N.useRef(null);N.useEffect(()=>{y.current=f},[f]),N.useEffect(()=>{if(!t)return;const R=`notification_last_read_${t.id}`,P=localStorage.getItem(R);P&&!y.current&&(y.current=P,p(P));const M=`nb_cache_${t.id}`,D=60*1e3,B=async()=>{try{const J=sessionStorage.getItem(M);if(J){const Q=JSON.parse(J);if(Q.ts&&Date.now()-Q.ts{n(W);const Y=y.current?new Date(y.current):null,J=W.filter(Q=>Y?new Date(Q.created_at)>Y:!0);o(J.length)};B();const G=Re.channel("push-notifications").on("postgres_changes",{event:"INSERT",schema:"public",table:"push_notifications"},W=>{const Y=W.new;n(Q=>{const ee=[Y,...Q].slice(0,20);try{sessionStorage.setItem(M,JSON.stringify({ts:Date.now(),data:ee}))}catch{}return ee});const J=y.current?new Date(y.current):null;(!J||new Date(Y.created_at)>J)&&o(Q=>Q+1),Notification.permission==="granted"&&new Notification(Y.title,{body:Y.body,icon:"/favicon.ico"})}).subscribe();return()=>{Re.removeChannel(G)}},[t]);const v=R=>{const P=R.toLowerCase();return P.includes("community")||P.includes("post")?ph:P.includes("academy")||P.includes("video")?hA:P.includes("template")?i3:P.includes("event")?co:P.includes("newsletter")?Dme:P.includes("brokerage")?Nme:P.includes("swag")||P.includes("social")?pf:P.includes("toolbox")||P.includes("tool")?Y9:P.includes("brief")?vi:ph},S=R=>{a(!1),R.url&&R.url!=="/"&&e(R.url)},E=()=>{if(!t)return;const R=new Date().toISOString(),P=`notification_last_read_${t.id}`;localStorage.setItem(P,R),p(R),o(0)},k=R=>{a(R),R&&s>0&&E()};return i.jsxs(qN,{open:c,onOpenChange:k,children:[i.jsx(GN,{asChild:!0,children:i.jsxs(Dt,{variant:"ghost",size:"icon",className:"relative",children:[i.jsx(AN,{className:"h-5 w-5"}),s>0&&i.jsx(ii,{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(_T,{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(Dt,{variant:"ghost",size:"sm",className:"text-xs h-6",onClick:E,children:"Mark all read"})]}),i.jsx(Um,{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(R=>{const P=v(R.title);return i.jsxs(Cu,{className:"group flex items-start gap-3 p-3 cursor-pointer data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground",onClick:()=>S(R),children:[i.jsx("div",{className:"flex-shrink-0 mt-0.5",children:i.jsx(P,{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:R.title}),i.jsx("span",{className:"text-xs text-muted-foreground line-clamp-2 group-data-[highlighted]:text-accent-foreground/80",children:R.body}),i.jsx("span",{className:"text-xs text-muted-foreground group-data-[highlighted]:text-accent-foreground/80",children:Uve(new Date(R.created_at),{addSuffix:!0})})]})]},R.id)})})]})]})};function lYe(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 Kve(){const{user:t}=Wn(),{data:e,isLoading:r}=fr({queryKey:["agent-lead-site",t==null?void 0:t.id],queryFn:async()=>{const{data:n,error:s}=await Re.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 lYe(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 Yve(t=!0){const{user:e}=Wn(),{data:r,isLoading:n}=fr({queryKey:["free-lead-site-offer",e==null?void 0:e.id],enabled:!!e&&t,staleTime:5*60*1e3,queryFn:async()=>{const{data:s}=await Re.from("profiles").select("brokerage_id").eq("id",e.id).maybeSingle();if(!(s!=null&&s.brokerage_id))return null;const{data:o}=await Re.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 cYe="coaching_access";function uYe(){const{user:t,loading:e,isAdmin:r,isCoach:n}=Wn(),{data:s,isLoading:o}=fr({queryKey:["coaching-access",t==null?void 0:t.id],enabled:!!t,staleTime:5*60*1e3,queryFn:async()=>{const[c,a]=await Promise.all([Re.from("coaching_assignments").select("id").eq("agent_id",t.id).eq("status","active").limit(1),Re.from("feature_entitlements").select("enabled, expires_at").eq("user_id",t.id).eq("feature_key",cYe).maybeSingle()]),f=(c.data||[]).length>0,p=a.data,y=!!(p!=null&&p.enabled)&&(!p.expires_at||new Date(p.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 Ks=Re,IGt=[{value:"contract",label:"Under contract"},{value:"inspection",label:"Inspection / due diligence"},{value:"closing",label:"Closing"},{value:"closed",label:"Closed"}];function PGt(t){return t.total_items===0?"not_started":t.rejected_items>0?"changes_requested":t.approved_items>=t.total_items?"compliant":"in_review"}const RGt={not_started:"Not started",in_review:"In review",changes_requested:"Changes requested",compliant:"Compliant"};function dYe(){return fr({queryKey:["transaction-admin-seats"],queryFn:async()=>{const{data:t}=await Re.auth.getUser();if(!t.user)return[];const{data:e,error:r}=await Ks.from("brokerage_transaction_admins").select("brokerage_id").eq("user_id",t.user.id);if(r)throw r;return e||[]}})}function LGt(t){return fr({queryKey:["transaction-admins",t],enabled:!!t,queryFn:async()=>{const{data:e,error:r}=await Ks.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 Ks.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 MGt(){const t=Er();return wr({mutationFn:async({brokerageId:e,userId:r})=>{const{error:n}=await Ks.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 DGt(){const t=Er();return wr({mutationFn:async({id:e})=>{const{error:r}=await Ks.from("brokerage_transaction_admins").delete().eq("id",e);if(r)throw r},onSuccess:(e,r)=>t.invalidateQueries({queryKey:["transaction-admins",r.brokerageId]})})}function OGt(t){return fr({queryKey:["compliance-settings",t],enabled:!!t,queryFn:async()=>{const{data:e,error:r}=await Ks.from("brokerage_compliance_settings").select("*").eq("brokerage_id",t).maybeSingle();if(r)throw r;return e}})}function FGt(){const t=Er();return wr({mutationFn:async e=>{const{error:r}=await Ks.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 BGt(t){return fr({queryKey:["compliance-templates",t],enabled:!!t,queryFn:async()=>{const{data:e,error:r}=await Ks.from("brokerage_checklist_templates").select("*").eq("brokerage_id",t).order("created_at",{ascending:!0});if(r)throw r;return e||[]}})}function $Gt(t){return fr({queryKey:["compliance-template-items",t],enabled:!!t,queryFn:async()=>{const{data:e,error:r}=await Ks.from("brokerage_checklist_template_items").select("*").eq("template_id",t).order("sort_order",{ascending:!0});if(r)throw r;return e||[]}})}function zGt(){const t=Er();return wr({mutationFn:async e=>{if(e.id){const{error:s}=await Ks.from("brokerage_checklist_templates").update(e).eq("id",e.id);if(s)throw s;return e.id}const{data:r,error:n}=await Ks.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 UGt(){const t=Er();return wr({mutationFn:async({id:e})=>{const{error:r}=await Ks.from("brokerage_checklist_templates").delete().eq("id",e);if(r)throw r},onSuccess:(e,r)=>t.invalidateQueries({queryKey:["compliance-templates",r.brokerageId]})})}function VGt(){const t=Er();return wr({mutationFn:async e=>{if(e.id){const{error:n}=await Ks.from("brokerage_checklist_template_items").update(e).eq("id",e.id);if(n)throw n;return}const{error:r}=await Ks.from("brokerage_checklist_template_items").insert(e);if(r)throw r},onSuccess:(e,r)=>t.invalidateQueries({queryKey:["compliance-template-items",r.template_id]})})}function qGt(){const t=Er();return wr({mutationFn:async({id:e})=>{const{error:r}=await Ks.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 GGt(t){return fr({queryKey:["compliance-deals",t],enabled:!!t,queryFn:async()=>{const{data:e,error:r}=await Ks.rpc("get_brokerage_compliance_deals",{_brokerage_id:t});if(r)throw r;return e||[]}})}function HGt(t){return fr({queryKey:["deal-compliance-items",t],enabled:!!t,queryFn:async()=>{const{data:e,error:r}=await Ks.from("deal_compliance_items").select("*").eq("deal_id",t).order("sort_order",{ascending:!0});if(r)throw r;return e||[]}})}function WGt(t){return fr({queryKey:["deal-compliance-events",t],enabled:!!t,queryFn:async()=>{const{data:e,error:r}=await Ks.from("deal_compliance_events").select("*").eq("deal_id",t).order("created_at",{ascending:!1}).limit(200);if(r)throw r;return e||[]}})}async function ZN(t){var r;const{data:e}=await Re.auth.getUser();await Ks.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 KGt(){const t=Er();return wr({mutationFn:async({item:e,status:r,note:n})=>{var c;const{data:s}=await Re.auth.getUser(),{error:o}=await Ks.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 ZN({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 YGt(){const t=Er();return wr({mutationFn:async({dealId:e,brokerageId:r,templateId:n,deal:s})=>{const{data:o,error:c}=await Ks.from("brokerage_checklist_template_items").select("*").eq("template_id",n).order("sort_order",{ascending:!0});if(c)throw c;const a=(y,v)=>{if(!y)return null;const[S,E,k]=y.split(/[-/T]/).map(Number);return new Date(Date.UTC(S,E-1,k+(v||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:p}=await Ks.from("deal_compliance_items").insert(f);if(p)throw p;await ZN({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 ZGt(t){return fr({queryKey:["deal-compliance-files",t],enabled:!!t,queryFn:async()=>{const{data:e,error:r}=await Ks.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 XGt(){const t=Er();return wr({mutationFn:async({item:e,file:r})=>{var v,S;const{data:n}=await Re.auth.getUser(),s=(v=n.user)==null?void 0:v.id;if(!s)throw new Error("Not signed in");const{data:o}=await Ks.from("deal_files").select("id, version_no").eq("compliance_item_id",e.id).order("version_no",{ascending:!1}).limit(1),c=(((S=o==null?void 0:o[0])==null?void 0:S.version_no)||0)+1,a=r.name.split(".").pop(),f=`${s}/${e.deal_id}/${crypto.randomUUID()}.${a}`,{error:p}=await Re.storage.from("deal-files").upload(f,r);if(p)throw p;o!=null&&o.length&&await Ks.from("deal_files").update({is_current:!1}).eq("compliance_item_id",e.id);const{error:y}=await Ks.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 Ks.from("deal_compliance_items").update({status:"submitted",review_note:null,reviewed_at:null,reviewed_by:null}).eq("id",e.id),await ZN({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 QGt(t){const{data:e,error:r}=await Re.storage.from("deal-files").createSignedUrl(t,3600);if(r)throw r;window.open(e.signedUrl,"_blank","noopener,noreferrer")}function JGt(t){return fr({queryKey:["deal-compliance-messages",t],enabled:!!t,refetchInterval:3e4,queryFn:async()=>{const{data:e,error:r}=await Ks.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 Ks.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 e9t(){const t=Er();return wr({mutationFn:async({dealId:e,brokerageId:r,body:n,senderRole:s,itemId:o})=>{var y;const{data:c}=await Re.auth.getUser(),a=(y=c.user)==null?void 0:y.id;if(!a)throw new Error("Not signed in");const{data:f,error:p}=await Ks.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(p)throw p;try{await Re.functions.invoke("compliance-message-notify",{body:{messageId:f.id}})}catch(v){console.error("compliance message notify failed",v)}return f.id},onSuccess:(e,r)=>t.invalidateQueries({queryKey:["deal-compliance-messages",r.dealId]})})}function t9t(){const t=Er();return wr({mutationFn:async({dealId:e,senderRole:r})=>{const{error:n}=await Ks.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 r9t(t){return fr({queryKey:["brokerage-agent-roster",t],enabled:!!t,queryFn:async()=>{const{data:e,error:r}=await Ks.from("profiles").select("id, name, email, avatar_url").eq("brokerage_id",t).order("name",{ascending:!0});if(r)throw r;return e||[]}})}function n9t(t){return fr({queryKey:["agent-pipeline-stages",t],enabled:!!t,queryFn:async()=>{const e=async()=>{const{data:n,error:s}=await Ks.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 Ks.rpc("initialize_deal_pipeline_stages",{p_user_id:t});n||(r=await e())}return r}})}function s9t(){const t=Er();return wr({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 Ks.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 Ks.rpc("ensure_deal_compliance",{_deal_id:o})}catch(c){console.error("ensure_deal_compliance failed",c)}return await ZN({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 i9t(t){return fr({queryKey:["staff-deal-detail",t],enabled:!!t,queryFn:async()=>{const{data:e,error:r}=await Ks.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 a9t(){const t=Er();return wr({mutationFn:async e=>{const r=e.price!=null&&e.commissionPercentage!=null?Math.round(e.price*(e.commissionPercentage/100)*100)/100:null,{error:n}=await Ks.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 ZN({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 eF=[{id:"home",label:"Home",icon:Mme,route:"/dashboard",accent:"nav-home"},{id:"crm",label:"CRM",icon:Nm,description:"Contacts and follow-up",accent:"nav-crm"},{id:"deals",label:"Deals",icon:V9,description:"Pipeline, transactions and tasks",accent:"nav-deals"},{id:"listings",label:"Listings",icon:so,description:"Win and market listings",accent:"nav-listings"},{id:"marketing",label:"Marketing",icon:kN,description:"Content, email and video",accent:"nav-marketing"},{id:"websites",label:"Websites",icon:Qv,description:"Your site and add-ons",accent:"nav-websites"},{id:"academy",label:"Learn",icon:JA,description:"Training, programs and coaching",accent:"nav-academy"},{id:"mainstage",label:"Main Stage",icon:Fme,route:"/main-stage",accent:"nav-mainstage"},{id:"events",label:"Events",icon:$me,route:"/events",accent:"nav-events"},{id:"apps",label:"Apps",icon:sDe,route:"/apps",accent:"nav-apps"},{id:"team",label:"Team",icon:ml,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:n3,description:"Your brokerage, teams and recruiting",accent:"nav-brokerage",visible:t=>!t.isAdmin&&(!!t.brokerageId||t.isBrokerageManager||t.isOnTeam)},{id:"more",label:"More",icon:XMe,description:"Community, marketplace and help",accent:"nav-more"}],kl=t=>e=>e.hasPermission(t),hYe=[{id:"mission-control",label:"Mission Control",route:"/mission-control",icon:WMe,description:"Your daily relationship command center",primaryCategory:"crm",section:"Overview",visible:kl("contacts"),searchKeywords:["agent os","mission control","dashboard"],displayOrder:10},{id:"client-portals",label:"Client Portals",route:"/mission-control/client-portals",icon:vi,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:KU,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:ml,description:"Every contact in your database",primaryCategory:"crm",section:"Contacts",visible:kl("contacts"),searchKeywords:["contacts","database","sphere","people"],displayOrder:30},{id:"contact-map",label:"Contact Map",route:"/mission-control/sphere-map",icon:di,iconTone:"red",description:"See your sphere on a map — boundaries, farms and prospects",primaryCategory:"crm",section:"Contacts",visible:kl("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:Qee,description:"See who needs attention next",primaryCategory:"crm",section:"Contacts",visible:kl("contacts"),searchKeywords:["relationship","scorecard","report"],displayOrder:40},{id:"sphere-gaps",label:"Sphere Gaps",route:"/mission-control/sphere-gaps",icon:NDe,description:"Find missing info across your sphere",primaryCategory:"crm",section:"Contacts",visible:kl("contacts"),searchKeywords:["gaps","missing data"],displayOrder:50},{id:"sent-emails",label:"Sent Emails",route:"/mission-control/sent-emails",icon:MM,description:"History of everything you have sent",primaryCategory:"crm",section:"Contacts",visible:kl("contacts"),searchKeywords:["sent","email history"],displayOrder:60},{id:"connect-page",label:"Connect Page",route:"/mission-control/connect-page",icon:nte,description:"Your shareable intake and link page",primaryCategory:"crm",section:"Contacts",visible:kl("contacts"),searchKeywords:["connect","link in bio","intake"],displayOrder:70},{id:"property-intelligence",label:"Property Intelligence",route:"/mission-control/property-intelligence",icon:so,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:Sm,description:"Structured touch plans for your people",primaryCategory:"crm",section:"Follow-Up",visible:kl("contacts"),searchKeywords:["touch plan","follow up plan"],displayOrder:80},{id:"smart-drips",label:"Smart Drips",route:"/mission-control/smart-drips",icon:dS,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:ns,description:"Reusable email templates",primaryCategory:"crm",section:"Follow-Up",searchKeywords:["email template"],displayOrder:100},{id:"signals",label:"Signals",route:"/mission-control/signals",icon:EDe,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:pf,description:"Plan and log in-person pop-bys",primaryCategory:"crm",section:"Follow-Up",visible:kl("popbys"),searchKeywords:["pop by","gifts","drop off"],displayOrder:120},{id:"pipeline",label:"Deal Pipeline",route:"/mission-control/pipeline",icon:V9,description:"Track every deal from lead to close",primaryCategory:"deals",section:"Pipeline",visible:kl("pipeline"),searchKeywords:["pipeline","deals","kanban"],displayOrder:130},{id:"lending-partners",label:"Lending Partners",route:"/mission-control/lenders",icon:n3,description:"Loan officers, loan milestones and lead exchange",primaryCategory:"deals",section:"Pipeline",visible:kl("pipeline"),searchKeywords:["lender","loan officer","mortgage","pre-approval","referral"],displayOrder:135},{id:"transactions",label:"Transactions",route:"/mission-control/transactions",icon:ZU,description:"Closed and in-progress transactions",primaryCategory:"deals",section:"Pipeline",visible:kl("pipeline"),searchKeywords:["transactions","closings"],displayOrder:140},{id:"forms",label:"Forms Library",route:"/mission-control/forms",icon:QMe,description:"Your PDF form templates, filled from any deal",primaryCategory:"deals",section:"Pipeline",visible:kl("pipeline"),searchKeywords:["forms","pdf","templates","contracts","documents"],displayOrder:145},{id:"tasks",label:"Tasks",route:"/mission-control/tasks",icon:RDe,description:"Everything on your plate today",primaryCategory:"deals",section:"Pipeline",visible:kl("pipeline"),searchKeywords:["tasks","to do"],displayOrder:150},{id:"scorecard",label:"Scorecard",route:"/mission-control/scorecard",icon:QA,description:"Your production numbers at a glance",primaryCategory:"deals",section:"Pipeline",visible:kl("scorecard"),searchKeywords:["scorecard","production","goals"],displayOrder:160},{id:"my-calendar",label:"My Calendar",route:"/mission-control/calendar",icon:Sm,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:Sm,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:Gi,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:so,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:"listing-exchange",label:"Listing Exchange",route:"/mission-control/listings",icon:so,description:"Publish and browse member listings",primaryCategory:"listings",section:"Manage Listings",visible:kl("listings"),searchKeywords:["listings","exchange","my listings"],displayOrder:10},{id:"listing-presentation-studio",label:"Listing Presentation Studio",route:"/apps/listing-presentation-studio",icon:wDe,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:Rme,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:Gi,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:KU,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:ZU,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:rte,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:i3,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:PDe,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:$l,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:rte,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:T$,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:T$,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:tte,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:Dme,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:ns,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:MM,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:pf,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:hA,description:"All of your recorded videos",primaryCategory:"marketing",section:"Video",visible:kl("videos"),searchKeywords:["videos","library"],displayOrder:90},{id:"video-studio",label:"Video Studio",route:"/video-studio",icon:hA,description:"Record vertical or horizontal videos with a scrolling teleprompter",primaryCategory:"marketing",section:"Video",visible:kl("videos"),searchKeywords:["teleprompter","studio","reels","record video","social video"],displayOrder:95},{id:"quickvid",label:"Video Messages",route:"/video-studio",icon:hA,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:tte,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:ite,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:QU,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:nte,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:lDe,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:rDe,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:"Get My Website",route:"/get-my-website",icon:Qv,description:"Claim the free site your brokerage offers",primaryCategory:"websites",section:"My Website",visible:t=>!t.hasLeadSite&&t.hasFreeSiteOffer,searchKeywords:["website","claim site","free site"],displayOrder:5},{id:"need-a-website",label:"Need a Website",route:"/need-a-website",icon:Qv,description:"Request your free beta agent website",primaryCategory:"websites",section:"My Website",badge:"beta",visible:t=>!t.hasLeadSite&&!t.hasFreeSiteOffer,searchKeywords:["website","need a website","beta site","free website"],displayOrder:6},{id:"view-site",label:"View Site",route:t=>t.siteUrl||"#",icon:r3,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:Ome,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:so,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:ml,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:Gi,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:QA,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:Qee,description:"See who is browsing your site",primaryCategory:"websites",section:"My Website",visible:t=>t.hasLeadSite,searchKeywords:["website activity","visitors","analytics"],displayOrder:50},{id:"mobile-command",label:"Mobile Command",route:"/m",icon:T$,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:vi,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:JA,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:cS,description:"On-demand training videos",primaryCategory:"academy",section:"Learn",searchKeywords:["academy","videos","training"],displayOrder:20},{id:"toolbox",label:"Toolbox",route:"/toolbox",icon:Y9,description:"Scripts, checklists and downloads",primaryCategory:"academy",section:"Learn",searchKeywords:["toolbox","scripts","downloads"],displayOrder:30},{id:"events",label:"Events",route:"/events",icon:$me,description:"Live trainings and member events",primaryCategory:"events",section:"Events",searchKeywords:["events","live","webinar"],displayOrder:10},{id:"programs",label:"Programs",route:"/programs",icon:ite,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:JA,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:Nm,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:ph,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:uDe,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:N_,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:K9,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:OM,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:pf,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:cDe,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:vi,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:LM,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:LM,description:"Install the LevelUp Chrome extension",primaryCategory:"more",section:"Help & Services",searchKeywords:["extension","chrome"],displayOrder:100},{id:"attract",label:"LevelUp Attract",route:"/attract",icon:vi,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:xx,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:dS,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:so,description:"Your brokerage hub",primaryCategory:"brokerage",section:"My Brokerage",visible:t=>!!t.brokerageId&&!t.isAdmin,searchKeywords:["brokerage"],displayOrder:130},{id:"help-board",label:"Help Board",route:"/brokerage/help-board",icon:aDe,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:cS,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:ml,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:ml,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:H9,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:ml,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:kN,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:S$,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:Qv,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:Mme,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:xDe,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-transactions",label:"Transactions & Compliance",route:"/brokerage/transactions",icon:S$,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:QU,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:km,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:Nme,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:vi,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:S$,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 Zve(t,e){return typeof t.route=="function"?t.route(e):t.route}function Xve(){const{user:t,isAdmin:e,isBrokerageManager:r,isCoach:n,brokerageId:s}=Wn(),{hasPermission:o}=M3(),{isInnerCircleEnabled:c,isMarketplaceEnabled:a,isFeatureEnabled:f}=B3(),{hasAccess:p}=$7(),{data:y,teams:v}=bT(),{leadSite:S,hasLeadSite:E,siteUrl:k}=Kve(),{hasOffer:R}=Yve(!E),P=Dxe(),{hasAccess:M}=uYe(),{data:D}=dYe(),B=Er(),{data:V}=fr({queryKey:["my-coach-nav",t==null?void 0:t.id],enabled:!!(t!=null&&t.id),staleTime:5*60*1e3,queryFn:async()=>{const{data:we}=await Re.from("coaching_assignments").select("id").eq("agent_id",t.id).eq("status","active").limit(1);return(we||[]).length>0}}),{data:G}=fr({queryKey:["user-tool-favorites",t==null?void 0:t.id],enabled:!!(t!=null&&t.id),staleTime:60*1e3,queryFn:async()=>{const{data:we}=await Re.from("user_tool_favorites").select("tool_id").eq("user_id",t.id);return(we||[]).map(me=>me.tool_id)}}),W=N.useMemo(()=>new Set(G||[]),[G]),Y=wr({mutationFn:async we=>{t!=null&&t.id&&(W.has(we)?await Re.from("user_tool_favorites").delete().eq("user_id",t.id).eq("tool_id",we):await Re.from("user_tool_favorites").insert({user_id:t.id,tool_id:we}))},onSuccess:()=>{B.invalidateQueries({queryKey:["user-tool-favorites"]}),B.invalidateQueries({queryKey:["app-catalog"]})}}),J=N.useMemo(()=>{var we,me;return{isAdmin:!!e,isBrokerageManager:!!r,isTransactionAdmin:((D==null?void 0:D.length)||0)>0,isCoach:!!n,isOnTeam:!!y,isTeamLeader:(v||[]).some(je=>je.role==="team_leader"),hasCoach:!!V,brokerageId:s??null,hasPermission:o,isInnerCircleEnabled:!!c,stagingStudioEnabled:f("staging_studio_enabled"),isMarketplaceEnabled:!!a,hasWeeklyReels:!!p,hasLeadSite:!!E,hasLeadSiteMLS:!!(S!=null&&S.mls_provider_id),hasFreeSiteOffer:!!R,leadSiteId:(S==null?void 0:S.id)??null,siteUrl:k??null,email:(t==null?void 0:t.email)??null,isPartnershipMember:P.isMember,hasCoachingOnboarding:P.isMember&&!!((we=P.pkg)!=null&&we.includes_coaching),hasCoachingAccess:!!M||P.isMember&&!!((me=P.pkg)!=null&&me.includes_coaching)}},[e,r,D,n,y,v,V,s,o,c,a,f,p,E,S,R,k,t==null?void 0:t.email,P.isMember,P.pkg,M]),Q=N.useMemo(()=>hYe.filter(we=>we.visible?we.visible(J):!0).map(we=>{if(!P.isRestricted)return we;const me=hVe(we);return!me||P.hasFeature(me)?we:{...we,locked:!0,route:`/upgrade/${me}`}}).sort((we,me)=>we.displayOrder-me.displayOrder),[J,P.isRestricted,P.features]),ee=N.useMemo(()=>eF.filter(we=>we.visible?we.visible(J):!0),[J]),le=N.useMemo(()=>ee.filter(we=>!we.route).map(we=>{const me=Q.filter(Ee=>Ee.primaryCategory===we.id),je=[],_e=new Map;for(const Ee of me)_e.has(Ee.section)||(_e.set(Ee.section,[]),je.push(Ee.section)),_e.get(Ee.section).push(Ee);return{id:we.id,label:we.label,sections:je.map(Ee=>({title:Ee,items:_e.get(Ee)}))}}),[Q,ee]),pe=N.useMemo(()=>new Map(le.map(we=>[we.id,we])),[le]),Te=we=>we.toolId||`nav:${we.id}`,Ae=we=>W.has(Te(we));return{ctx:J,categories:le,railCategories:ee,categoryMap:pe,destinations:Q,favorites:W,isFavorite:Ae,favoritesFor:we=>Q.filter(me=>me.primaryCategory===we&&Ae(me)),favoriteKey:Te,toggleFavorite:we=>Y.mutate(we),searchDestinations:we=>{const me=we.trim().toLowerCase();return me?Q.map(_e=>{const Ee=_e.label.toLowerCase(),ve=(_e.description||"").toLowerCase(),qe=(_e.searchKeywords||[]).join(" ").toLowerCase();let nt=0;return Ee===me?nt=100:Ee.startsWith(me)?nt=80:Ee.includes(me)?nt=60:qe.includes(me)?nt=40:ve.includes(me)?nt=20:_e.section.toLowerCase().includes(me)&&(nt=10),nt&&Ae(_e)&&(nt+=5),{d:_e,score:nt}}).filter(_e=>_e.score>0).sort((_e,Ee)=>Ee.score-_e.score).map(_e=>_e.d):[]},routeFor:we=>Zve(we,J)}}var ane=1,fYe=.9,mYe=.8,pYe=.17,nz=.1,sz=.999,gYe=.9999,yYe=.99,xYe=/[\\\/_+.#"@\[\(\{&]/,vYe=/[\\\/_+.#"@\[\(\{&]/g,_Ye=/[\s-]/,Qve=/[\s-]/g;function a8(t,e,r,n,s,o,c){if(o===e.length)return s===t.length?ane:yYe;var a=`${s},${o}`;if(c[a]!==void 0)return c[a];for(var f=n.charAt(o),p=r.indexOf(f,s),y=0,v,S,E,k;p>=0;)v=a8(t,e,r,n,p+1,o+1,c),v>y&&(p===s?v*=ane:xYe.test(t.charAt(p-1))?(v*=mYe,E=t.slice(s,p-1).match(vYe),E&&s>0&&(v*=Math.pow(sz,E.length))):_Ye.test(t.charAt(p-1))?(v*=fYe,k=t.slice(s,p-1).match(Qve),k&&s>0&&(v*=Math.pow(sz,k.length))):(v*=pYe,s>0&&(v*=Math.pow(sz,p-s))),t.charAt(p)!==e.charAt(o)&&(v*=gYe)),(vv&&(v=S*nz)),v>y&&(y=v),p=r.indexOf(f,p+1);return c[a]=y,y}function one(t){return t.toLowerCase().replace(Qve," ")}function bYe(t,e,r){return t=r&&r.length>0?`${t+" "+r.join(" ")}`:t,a8(t,e,one(t),one(e),0,0,{})}var _2='[cmdk-group=""]',iz='[cmdk-group-items=""]',wYe='[cmdk-group-heading=""]',Jve='[cmdk-item=""]',lne=`${Jve}:not([aria-disabled="true"])`,o8="cmdk-item-select",Hw="data-value",SYe=(t,e,r)=>bYe(t,e,r),e_e=N.createContext(void 0),XN=()=>N.useContext(e_e),t_e=N.createContext(void 0),wH=()=>N.useContext(t_e),r_e=N.createContext(void 0),n_e=N.forwardRef((t,e)=>{let r=Ww(()=>{var ve,qe;return{search:"",value:(qe=(ve=t.value)!=null?ve:t.defaultValue)!=null?qe:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),n=Ww(()=>new Set),s=Ww(()=>new Map),o=Ww(()=>new Map),c=Ww(()=>new Set),a=s_e(t),{label:f,children:p,value:y,onValueChange:v,filter:S,shouldFilter:E,loop:k,disablePointerSelection:R=!1,vimBindings:P=!0,...M}=t,D=Fl(),B=Fl(),V=Fl(),G=N.useRef(null),W=LYe();g_(()=>{if(y!==void 0){let ve=y.trim();r.current.value=ve,Y.emit()}},[y]),g_(()=>{W(6,Te)},[]);let Y=N.useMemo(()=>({subscribe:ve=>(c.current.add(ve),()=>c.current.delete(ve)),snapshot:()=>r.current,setState:(ve,qe,nt)=>{var ot,jt,vt,Gt;if(!Object.is(r.current[ve],qe)){if(r.current[ve]=qe,ve==="search")pe(),ee(),W(1,le);else if(ve==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let pt=document.getElementById(V);pt?pt.focus():(ot=document.getElementById(D))==null||ot.focus()}if(W(7,()=>{var pt;r.current.selectedItemId=(pt=Ae())==null?void 0:pt.id,Y.emit()}),nt||W(5,Te),((jt=a.current)==null?void 0:jt.value)!==void 0){let pt=qe??"";(Gt=(vt=a.current).onValueChange)==null||Gt.call(vt,pt);return}}Y.emit()}},emit:()=>{c.current.forEach(ve=>ve())}}),[]),J=N.useMemo(()=>({value:(ve,qe,nt)=>{var ot;qe!==((ot=o.current.get(ve))==null?void 0:ot.value)&&(o.current.set(ve,{value:qe,keywords:nt}),r.current.filtered.items.set(ve,Q(qe,nt)),W(2,()=>{ee(),Y.emit()}))},item:(ve,qe)=>(n.current.add(ve),qe&&(s.current.has(qe)?s.current.get(qe).add(ve):s.current.set(qe,new Set([ve]))),W(3,()=>{pe(),ee(),r.current.value||le(),Y.emit()}),()=>{o.current.delete(ve),n.current.delete(ve),r.current.filtered.items.delete(ve);let nt=Ae();W(4,()=>{pe(),(nt==null?void 0:nt.getAttribute("id"))===ve&&le(),Y.emit()})}),group:ve=>(s.current.has(ve)||s.current.set(ve,new Set),()=>{o.current.delete(ve),s.current.delete(ve)}),filter:()=>a.current.shouldFilter,label:f||t["aria-label"],getDisablePointerSelection:()=>a.current.disablePointerSelection,listId:D,inputId:V,labelId:B,listInnerRef:G}),[]);function Q(ve,qe){var nt,ot;let jt=(ot=(nt=a.current)==null?void 0:nt.filter)!=null?ot:SYe;return ve?jt(ve,r.current.search,qe):0}function ee(){if(!r.current.search||a.current.shouldFilter===!1)return;let ve=r.current.filtered.items,qe=[];r.current.filtered.groups.forEach(ot=>{let jt=s.current.get(ot),vt=0;jt.forEach(Gt=>{let pt=ve.get(Gt);vt=Math.max(pt,vt)}),qe.push([ot,vt])});let nt=G.current;Le().sort((ot,jt)=>{var vt,Gt;let pt=ot.getAttribute("id"),Ct=jt.getAttribute("id");return((vt=ve.get(Ct))!=null?vt:0)-((Gt=ve.get(pt))!=null?Gt:0)}).forEach(ot=>{let jt=ot.closest(iz);jt?jt.appendChild(ot.parentElement===jt?ot:ot.closest(`${iz} > *`)):nt.appendChild(ot.parentElement===nt?ot:ot.closest(`${iz} > *`))}),qe.sort((ot,jt)=>jt[1]-ot[1]).forEach(ot=>{var jt;let vt=(jt=G.current)==null?void 0:jt.querySelector(`${_2}[${Hw}="${encodeURIComponent(ot[0])}"]`);vt==null||vt.parentElement.appendChild(vt)})}function le(){let ve=Le().find(nt=>nt.getAttribute("aria-disabled")!=="true"),qe=ve==null?void 0:ve.getAttribute(Hw);Y.setState("value",qe||void 0)}function pe(){var ve,qe,nt,ot;if(!r.current.search||a.current.shouldFilter===!1){r.current.filtered.count=n.current.size;return}r.current.filtered.groups=new Set;let jt=0;for(let vt of n.current){let Gt=(qe=(ve=o.current.get(vt))==null?void 0:ve.value)!=null?qe:"",pt=(ot=(nt=o.current.get(vt))==null?void 0:nt.keywords)!=null?ot:[],Ct=Q(Gt,pt);r.current.filtered.items.set(vt,Ct),Ct>0&&jt++}for(let[vt,Gt]of s.current)for(let pt of Gt)if(r.current.filtered.items.get(pt)>0){r.current.filtered.groups.add(vt);break}r.current.filtered.count=jt}function Te(){var ve,qe,nt;let ot=Ae();ot&&(((ve=ot.parentElement)==null?void 0:ve.firstChild)===ot&&((nt=(qe=ot.closest(_2))==null?void 0:qe.querySelector(wYe))==null||nt.scrollIntoView({block:"nearest"})),ot.scrollIntoView({block:"nearest"}))}function Ae(){var ve;return(ve=G.current)==null?void 0:ve.querySelector(`${Jve}[aria-selected="true"]`)}function Le(){var ve;return Array.from(((ve=G.current)==null?void 0:ve.querySelectorAll(lne))||[])}function ke(ve){let qe=Le()[ve];qe&&Y.setState("value",qe.getAttribute(Hw))}function we(ve){var qe;let nt=Ae(),ot=Le(),jt=ot.findIndex(Gt=>Gt===nt),vt=ot[jt+ve];(qe=a.current)!=null&&qe.loop&&(vt=jt+ve<0?ot[ot.length-1]:jt+ve===ot.length?ot[0]:ot[jt+ve]),vt&&Y.setState("value",vt.getAttribute(Hw))}function me(ve){let qe=Ae(),nt=qe==null?void 0:qe.closest(_2),ot;for(;nt&&!ot;)nt=ve>0?PYe(nt,_2):RYe(nt,_2),ot=nt==null?void 0:nt.querySelector(lne);ot?Y.setState("value",ot.getAttribute(Hw)):we(ve)}let je=()=>ke(Le().length-1),_e=ve=>{ve.preventDefault(),ve.metaKey?je():ve.altKey?me(1):we(1)},Ee=ve=>{ve.preventDefault(),ve.metaKey?ke(0):ve.altKey?me(-1):we(-1)};return N.createElement(nn.div,{ref:e,tabIndex:-1,...M,"cmdk-root":"",onKeyDown:ve=>{var qe;(qe=M.onKeyDown)==null||qe.call(M,ve);let nt=ve.nativeEvent.isComposing||ve.keyCode===229;if(!(ve.defaultPrevented||nt))switch(ve.key){case"n":case"j":{P&&ve.ctrlKey&&_e(ve);break}case"ArrowDown":{_e(ve);break}case"p":case"k":{P&&ve.ctrlKey&&Ee(ve);break}case"ArrowUp":{Ee(ve);break}case"Home":{ve.preventDefault(),ke(0);break}case"End":{ve.preventDefault(),je();break}case"Enter":{ve.preventDefault();let ot=Ae();if(ot){let jt=new Event(o8);ot.dispatchEvent(jt)}}}}},N.createElement("label",{"cmdk-label":"",htmlFor:J.inputId,id:J.labelId,style:DYe},f),tF(t,ve=>N.createElement(t_e.Provider,{value:Y},N.createElement(e_e.Provider,{value:J},ve))))}),TYe=N.forwardRef((t,e)=>{var r,n;let s=Fl(),o=N.useRef(null),c=N.useContext(r_e),a=XN(),f=s_e(t),p=(n=(r=f.current)==null?void 0:r.forceMount)!=null?n:c==null?void 0:c.forceMount;g_(()=>{if(!p)return a.item(s,c==null?void 0:c.id)},[p]);let y=i_e(s,o,[t.value,t.children,o],t.keywords),v=wH(),S=Ex(W=>W.value&&W.value===y.current),E=Ex(W=>p||a.filter()===!1?!0:W.search?W.filtered.items.get(s)>0:!0);N.useEffect(()=>{let W=o.current;if(!(!W||t.disabled))return W.addEventListener(o8,k),()=>W.removeEventListener(o8,k)},[E,t.onSelect,t.disabled]);function k(){var W,Y;R(),(Y=(W=f.current).onSelect)==null||Y.call(W,y.current)}function R(){v.setState("value",y.current,!0)}if(!E)return null;let{disabled:P,value:M,onSelect:D,forceMount:B,keywords:V,...G}=t;return N.createElement(nn.div,{ref:ag(o,e),...G,id:s,"cmdk-item":"",role:"option","aria-disabled":!!P,"aria-selected":!!S,"data-disabled":!!P,"data-selected":!!S,onPointerMove:P||a.getDisablePointerSelection()?void 0:R,onClick:P?void 0:k},t.children)}),EYe=N.forwardRef((t,e)=>{let{heading:r,children:n,forceMount:s,...o}=t,c=Fl(),a=N.useRef(null),f=N.useRef(null),p=Fl(),y=XN(),v=Ex(E=>s||y.filter()===!1?!0:E.search?E.filtered.groups.has(c):!0);g_(()=>y.group(c),[]),i_e(c,a,[t.value,t.heading,f]);let S=N.useMemo(()=>({id:c,forceMount:s}),[s]);return N.createElement(nn.div,{ref:ag(a,e),...o,"cmdk-group":"",role:"presentation",hidden:v?void 0:!0},r&&N.createElement("div",{ref:f,"cmdk-group-heading":"","aria-hidden":!0,id:p},r),tF(t,E=>N.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":r?p:void 0},N.createElement(r_e.Provider,{value:S},E))))}),jYe=N.forwardRef((t,e)=>{let{alwaysRender:r,...n}=t,s=N.useRef(null),o=Ex(c=>!c.search);return!r&&!o?null:N.createElement(nn.div,{ref:ag(s,e),...n,"cmdk-separator":"",role:"separator"})}),AYe=N.forwardRef((t,e)=>{let{onValueChange:r,...n}=t,s=t.value!=null,o=wH(),c=Ex(p=>p.search),a=Ex(p=>p.selectedItemId),f=XN();return N.useEffect(()=>{t.value!=null&&o.setState("search",t.value)},[t.value]),N.createElement(nn.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:p=>{s||o.setState("search",p.target.value),r==null||r(p.target.value)}})}),kYe=N.forwardRef((t,e)=>{let{children:r,label:n="Suggestions",...s}=t,o=N.useRef(null),c=N.useRef(null),a=Ex(p=>p.selectedItemId),f=XN();return N.useEffect(()=>{if(c.current&&o.current){let p=c.current,y=o.current,v,S=new ResizeObserver(()=>{v=requestAnimationFrame(()=>{let E=p.offsetHeight;y.style.setProperty("--cmdk-list-height",E.toFixed(1)+"px")})});return S.observe(p),()=>{cancelAnimationFrame(v),S.unobserve(p)}}},[]),N.createElement(nn.div,{ref:ag(o,e),...s,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":a,"aria-label":n,id:f.listId},tF(t,p=>N.createElement("div",{ref:ag(c,f.listInnerRef),"cmdk-list-sizer":""},p)))}),NYe=N.forwardRef((t,e)=>{let{open:r,onOpenChange:n,overlayClassName:s,contentClassName:o,container:c,...a}=t;return N.createElement(m3,{open:r,onOpenChange:n},N.createElement(p3,{container:c},N.createElement(uT,{"cmdk-overlay":"",className:s}),N.createElement(dT,{"aria-label":t.label,"cmdk-dialog":"",className:o},N.createElement(n_e,{ref:e,...a}))))}),CYe=N.forwardRef((t,e)=>Ex(r=>r.filtered.count===0)?N.createElement(nn.div,{ref:e,...t,"cmdk-empty":"",role:"presentation"}):null),IYe=N.forwardRef((t,e)=>{let{progress:r,children:n,label:s="Loading...",...o}=t;return N.createElement(nn.div,{ref:e,...o,"cmdk-loading":"",role:"progressbar","aria-valuenow":r,"aria-valuemin":0,"aria-valuemax":100,"aria-label":s},tF(t,c=>N.createElement("div",{"aria-hidden":!0},c)))}),zu=Object.assign(n_e,{List:kYe,Item:TYe,Input:AYe,Group:EYe,Separator:jYe,Dialog:NYe,Empty:CYe,Loading:IYe});function PYe(t,e){let r=t.nextElementSibling;for(;r;){if(r.matches(e))return r;r=r.nextElementSibling}}function RYe(t,e){let r=t.previousElementSibling;for(;r;){if(r.matches(e))return r;r=r.previousElementSibling}}function s_e(t){let e=N.useRef(t);return g_(()=>{e.current=t}),e}var g_=typeof window>"u"?N.useEffect:N.useLayoutEffect;function Ww(t){let e=N.useRef();return e.current===void 0&&(e.current=t()),e}function Ex(t){let e=wH(),r=()=>t(e.snapshot());return N.useSyncExternalStore(e.subscribe,r,r)}function i_e(t,e,r,n=[]){let s=N.useRef(),o=XN();return g_(()=>{var c;let a=(()=>{var p;for(let y of r){if(typeof y=="string")return y.trim();if(typeof y=="object"&&"current"in y)return y.current?(p=y.current.textContent)==null?void 0:p.trim():s.current}})(),f=n.map(p=>p.trim());o.value(t,a,f),(c=e.current)==null||c.setAttribute(Hw,a),s.current=a}),s}var LYe=()=>{let[t,e]=N.useState(),r=Ww(()=>new Map);return g_(()=>{r.current.forEach(n=>n()),r.current=new Map},[t]),(n,s)=>{r.current.set(n,s),e({})}};function MYe(t){let e=t.type;return typeof e=="function"?e(t.props):"render"in e?e.render(t.props):t}function tF({asChild:t,children:e},r){return t&&N.isValidElement(e)?N.cloneElement(MYe(e),{ref:e.ref},r(e.props.children)):r(e)}var DYe={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const gk=N.forwardRef(({className:t,...e},r)=>i.jsx(zu,{ref:r,className:qt("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",t),...e}));gk.displayName=zu.displayName;const OYe=({children:t,...e})=>i.jsx(Fa,{...e,children:i.jsx(Sa,{className:"overflow-hidden p-0 shadow-lg",children:i.jsx(gk,{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})})}),yk=N.forwardRef(({className:t,...e},r)=>i.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[i.jsx(bd,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),i.jsx(zu.Input,{ref:r,className:qt("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})]}));yk.displayName=zu.Input.displayName;const xk=N.forwardRef(({className:t,...e},r)=>i.jsx(zu.List,{ref:r,className:qt("max-h-[300px] overflow-y-auto overflow-x-hidden",t),...e}));xk.displayName=zu.List.displayName;const vk=N.forwardRef((t,e)=>i.jsx(zu.Empty,{ref:e,className:"py-6 text-center text-sm",...t}));vk.displayName=zu.Empty.displayName;const Up=N.forwardRef(({className:t,...e},r)=>i.jsx(zu.Group,{ref:r,className:qt("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}));Up.displayName=zu.Group.displayName;const FYe=N.forwardRef(({className:t,...e},r)=>i.jsx(zu.Separator,{ref:r,className:qt("-mx-1 h-px bg-border",t),...e}));FYe.displayName=zu.Separator.displayName;const of=N.forwardRef(({className:t,...e},r)=>i.jsx(zu.Item,{ref:r,className:qt("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}));of.displayName=zu.Item.displayName;const rd=t=>Number.isFinite(Number(t))?Number(t):0,Ip=t=>Math.round(t*100)/100,BYe=[{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 $Ye(){return{listingCommissionPct:3,buyerCommissionPct:3,brokerageFee:0,titleFees:BYe.map(t=>({...t})),firstPayoff:0,secondPayoff:0,annualTaxes:0,taxesInArrears:!0,otherCosts:[]}}function zYe(t,e=5){const r=Math.max(0,rd(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 o9t(t){const e=Math.max(0,rd(t));return["A","B","C"].map(r=>({id:`offer-${r}`,label:`Offer ${r}`,price:e,concessions:0,repairs:0}))}function UYe(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;aP+rd(M.amount),0)),p=Ip(rd(t.firstPayoff)+rd(t.secondPayoff)),y=VYe(t.annualTaxes,r,t.taxesInArrears),v=Ip((t.otherCosts||[]).reduce((P,M)=>P+rd(M.amount),0)),S=rd(e.concessions),E=rd(e.repairs),k=Ip(c+a+f+p+y+v+S+E),R=Ip(n-k);return{price:n,commission:c,listingCommission:s,buyerCommission:o,brokerageFee:a,titleTotal:f,payoffs:p,taxProration:y,concessions:S,repairs:E,otherTotal:v,totalCosts:k,net:R,netPct:n>0?R/n:0}}const em=(t,e=!1)=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:e?2:0,maximumFractionDigits:e?2:0}).format(t||0),QN=()=>Re.from("seller_net_sheets"),l9t=t=>`${window.location.origin}/net-sheet/${t}`;function c9t(t){const e=Ls();return fr({queryKey:["net-sheets",e,t??"all"],enabled:!!e,queryFn:async()=>{let r=QN().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 u9t(t){return fr({queryKey:["net-sheet",t],enabled:!!t,queryFn:async()=>{const{data:e,error:r}=await QN().select("*").eq("id",t).single();if(r)throw r;return e}})}function GYe(){const t=Ls(),e=Er();return wr({mutationFn:async r=>{const{price:n,...s}=r,{data:o,error:c}=await QN().insert({...s,owner_user_id:t,title:r.title??"Seller net sheet",mode:"price",inputs:$Ye(),scenarios:zYe(n||3e5)}).select().single();if(c)throw c;return o},onSuccess:()=>e.invalidateQueries({queryKey:["net-sheets"]})})}function d9t(){const t=Er();return wr({mutationFn:async({id:e,...r})=>{const{error:n}=await QN().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 h9t(){const t=Er();return wr({mutationFn:async e=>{const{error:r}=await QN().delete().eq("id",e);if(r)throw r},onSuccess:()=>t.invalidateQueries({queryKey:["net-sheets"]})})}function HYe(t){return fr({queryKey:["public-net-sheet",t],enabled:!!t,queryFn:async()=>{const{data:e,error:r}=await Re.rpc("get_public_net_sheet",{_slug:t});if(r)throw r;return e}})}const WYe=[{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 KYe(t,e=WYe){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 YYe(t){return/mac|iphone|ipad|ipod/i.test(t)?"⌘K":"Ctrl K"}function ZYe(t){return t.replace(/[,()*%\\]/g," ").trim()}const XYe={event:{label:"Events",icon:Sm,color:"bg-blue-500/10 text-blue-600"},template:{label:"Templates",icon:i3,color:"bg-purple-500/10 text-purple-600"},academy:{label:"Academy",icon:JA,color:"bg-amber-500/10 text-amber-600"},toolbox:{label:"Toolbox",icon:Y9,color:"bg-green-500/10 text-green-600"},"social-swag":{label:"Social Swag",icon:vi,color:"bg-fuchsia-500/10 text-fuchsia-600"}},cne=({hotkey:t=!0}={})=>{const[e,r]=N.useState(!1),[n,s]=N.useState(""),[o,c]=N.useState([]),[a,f]=N.useState(!1),p=Wi(),{searchDestinations:y,isFavorite:v,routeFor:S}=Xve(),E=n.trim()?y(n).slice(0,4):[],k=Ls(),[R,P]=N.useState([]),[M,D]=N.useState([]),B=KYe(n),V=GYe(),G=typeof navigator<"u"?YYe(navigator.platform||navigator.userAgent):"Ctrl K",W=async ee=>{if(ee.id==="new-net-sheet"){r(!1),s("");try{const le=await V.mutateAsync({});p(`/mission-control/net-sheets/${le.id}`)}catch{p(ee.path)}return}J(ee.path)};N.useEffect(()=>{if(!t)return;const ee=le=>{le.key==="k"&&(le.metaKey||le.ctrlKey)&&(le.preventDefault(),r(pe=>!pe))};return document.addEventListener("keydown",ee),()=>document.removeEventListener("keydown",ee)},[t]);const Y=N.useCallback(async ee=>{if(!ee.trim()){c([]),P([]),D([]);return}f(!0);const le=`%${ee}%`;try{const[pe,Te,Ae,Le,ke]=await Promise.all([Re.from("events").select("id, title, description, event_date").eq("is_published",!0).or(`title.ilike.${le},description.ilike.${le}`).limit(5),Re.from("canva_templates").select("id, name, description, publish_date").or(`name.ilike.${le},description.ilike.${le}`).limit(5),Re.from("academy_videos").select("id, title, description, publish_date").eq("is_published",!0).or(`title.ilike.${le},description.ilike.${le}`).limit(5),Re.from("resource_kits").select("id, name, description, publish_date").eq("is_published",!0).or(`name.ilike.${le},description.ilike.${le}`).limit(5),Re.from("social_swag").select("id, title, description, publish_date").eq("is_published",!0).or(`title.ilike.${le},description.ilike.${le}`).limit(5)]),we=[],me=ZYe(ee);if(me&&k){const je=`%${me}%`,_e=me.split(/\s+/),Ee=_e.length>1?`and(first_name.ilike.%${_e[0]}%,last_name.ilike.%${_e.slice(1).join(" ")}%)`:null,[ve,qe]=await Promise.all([Re.from("innercircle_contacts").select("id, first_name, last_name, email, phone, address, city").eq("owner_user_id",k).or([`first_name.ilike.${je}`,`last_name.ilike.${je}`,`email.ilike.${je}`,`phone.ilike.${je}`,`address.ilike.${je}`,Ee].filter(Boolean).join(",")).limit(6),Re.from("deal_pipeline").select("id, deal_name, property_address, city, deal_type").eq("owner_user_id",k).or(`deal_name.ilike.${je},property_address.ilike.${je},city.ilike.${je}`).limit(6)]);P((ve.data??[]).map(nt=>({id:nt.id,title:[nt.first_name,nt.last_name].filter(Boolean).join(" ")||nt.email||"Contact",sub:[nt.phone,nt.email,nt.address].filter(Boolean).join(" · ")}))),D((qe.data??[]).map(nt=>({id:nt.id,title:nt.property_address||nt.deal_name||"Deal",sub:[nt.deal_name!==nt.property_address?nt.deal_name:null,nt.city,nt.deal_type].filter(Boolean).join(" · ")})))}pe.data&&pe.data.forEach(je=>{we.push({id:je.id,title:je.title,description:je.description,type:"event",date:je.event_date,path:`/event/${je.id}`})}),Te.data&&Te.data.forEach(je=>{we.push({id:je.id,title:je.name,description:je.description,type:"template",date:je.publish_date,path:`/templates/${je.id}`})}),Ae.data&&Ae.data.forEach(je=>{we.push({id:je.id,title:je.title,description:je.description,type:"academy",date:je.publish_date,path:`/academy/${je.id}`})}),Le.data&&Le.data.forEach(je=>{we.push({id:je.id,title:je.name,description:je.description,type:"toolbox",date:je.publish_date,path:`/toolbox/${je.id}`})}),ke.data&&ke.data.forEach(je=>{we.push({id:je.id,title:je.title,description:je.description,type:"social-swag",date:je.publish_date,path:`/social-swag/${je.id}`})}),c(we)}catch(pe){console.error("Search error:",pe)}finally{f(!1)}},[k]);N.useEffect(()=>{const ee=setTimeout(()=>{Y(n)},200);return()=>clearTimeout(ee)},[n,Y]);const J=ee=>{r(!1),s(""),p(ee)},Q=o.reduce((ee,le)=>(ee[le.type]||(ee[le.type]=[]),ee[le.type].push(le),ee),{});return i.jsxs(i.Fragment,{children:[i.jsxs(Dt,{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(bd,{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:G})]}),i.jsxs(OYe,{open:e,onOpenChange:r,children:[i.jsx(yk,{placeholder:"Name, address, or an action like “New Net Sheet”…",value:n,onValueChange:s}),i.jsxs(xk,{className:"max-h-[70vh]",children:[R.length>0&&i.jsx(Up,{heading:"Contacts",children:R.map(ee=>i.jsxs(of,{value:`contact-${ee.id}-${ee.title}-${ee.sub}-${n}`,onSelect:()=>J(`/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(Dl,{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(Up,{heading:"Deals",children:M.map(ee=>i.jsxs(of,{value:`deal-${ee.id}-${ee.title}-${ee.sub}-${n}`,onSelect:()=>J(`/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(Gi,{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(Up,{heading:n?"Actions":"Quick actions",children:B.map(ee=>i.jsxs(of,{value:`action-${ee.id}-${ee.label}-${ee.keywords.join(" ")}`,onSelect:()=>W(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(dS,{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(Up,{heading:"Go to",children:E.map(ee=>{const le=ee.icon;return i.jsxs(of,{value:`nav-${ee.id}-${ee.label}`,onSelect:()=>{const pe=S(ee);ee.external||ee.openInNewTab?(r(!1),s(""),window.open(pe,"_blank","noopener,noreferrer")):J(pe)},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(le,{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,v(ee)&&i.jsx(RM,{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(ii,{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&&R.length===0&&M.length===0&&B.length===0&&i.jsxs(vk,{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(Q).map(([ee,le])=>{const pe=XYe[ee],Te=pe.icon;return i.jsx(Up,{heading:pe.label,children:le.map(Ae=>i.jsxs(of,{value:`${Ae.type}-${Ae.id}-${Ae.title}`,onSelect:()=>J(Ae.path),className:"flex items-start gap-3 py-3 cursor-pointer",children:[i.jsx("div",{className:`p-2 rounded-md ${pe.color}`,children:i.jsx(Te,{className:"h-4 w-4"})}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("div",{className:"font-medium truncate",children:Ae.title}),Ae.description&&i.jsx("div",{className:"text-sm text-muted-foreground truncate group-data-[selected=true]:text-primary-foreground/80",children:Ae.description})]}),i.jsxs("div",{className:"flex flex-col items-end gap-1 shrink-0",children:[i.jsx(ii,{variant:"secondary",className:"text-xs",children:pe.label}),i.jsx("span",{className:"text-xs text-muted-foreground",children:Uve(new Date(Ae.date),{addSuffix:!0})})]})]},`${Ae.type}-${Ae.id}`))},ee)})]})]})]})},QYe=({expiresAt:t,className:e,showUpgradeButton:r=!0})=>{const[n,s]=N.useState(null),o=Wi();if(N.useEffect(()=>{const p=()=>{const v=new Date().getTime(),E=new Date(t).getTime()-v;if(E<=0){s({days:0,hours:0,minutes:0});return}const k=Math.floor(E/(1e3*60*60*24)),R=Math.floor(E%(1e3*60*60*24)/(1e3*60*60)),P=Math.floor(E%(1e3*60*60)/(1e3*60));s({days:k,hours:R,minutes:P})};p();const y=setInterval(p,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:qt("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(lT,{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(Dt,{size:"sm",onClick:()=>o("/subscription"),className:"bg-primary hover:bg-primary/90 text-xs h-7 px-3",children:[i.jsx(vi,{className:"h-3 w-3 mr-1"}),"Upgrade Now"]})]}):i.jsxs("div",{className:qt("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(Ml,{className:qt("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:qt("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:qt("text-sm font-bold",a?"text-destructive":f?"text-amber-600":"text-primary"),children:[n.days,"d"]}),i.jsxs("span",{className:qt("text-sm font-bold",a?"text-destructive":f?"text-amber-600":"text-primary"),children:[n.hours,"h"]}),i.jsxs("span",{className:qt("text-sm font-bold",a?"text-destructive":f?"text-amber-600":"text-primary"),children:[n.minutes,"m"]}),i.jsx("span",{className:qt("text-xs",a?"text-destructive/70":f?"text-amber-600/70":"text-primary/70"),children:"remaining"})]})]})]}),r&&i.jsxs(Dt,{size:"sm",onClick:()=>o("/subscription"),variant:a?"destructive":f?"default":"outline",className:qt("text-xs h-7 px-3",f&&"bg-amber-500 hover:bg-amber-600 text-white"),children:[i.jsx(vi,{className:"h-3 w-3 mr-1"}),"Upgrade"]})]})},JYe=()=>{const t=Wi();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($n,{className:"w-full max-w-2xl shadow-2xl border-destructive/20 my-8",children:[i.jsxs(fd,{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(lT,{className:"h-8 w-8 text-destructive"})}),i.jsx(md,{className:"text-2xl",children:"Your Free Trial Has Ended"}),i.jsx(hk,{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(Yn,{className:"space-y-6",children:[i.jsxs("div",{className:"grid sm:grid-cols-2 gap-4",children:[i.jsx($n,{className:"border-2 border-primary/20 hover:border-primary/50 transition-colors cursor-pointer",onClick:()=>t("/subscription"),children:i.jsxs(Yn,{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(ml,{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(Dt,{className:"w-full",onClick:e=>{e.stopPropagation(),t("/subscription")},children:[i.jsx(vi,{className:"h-4 w-4 mr-2"}),"Choose Individual"]})]})}),i.jsx($n,{className:"border-2 border-amber-500/20 hover:border-amber-500/50 transition-colors cursor-pointer",onClick:()=>t("/subscription"),children:i.jsxs(Yn,{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(so,{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(Dt,{variant:"outline",className:"w-full border-amber-500 text-amber-600 hover:bg-amber-50",onClick:e=>{e.stopPropagation(),t("/subscription")},children:[i.jsx(so,{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(zn,{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(ns,{className:"h-4 w-4"}),i.jsx("span",{children:"support@relevelup.com"})]})]})]})]})]})})},eZe=({hasUnseenBrief:t,onClick:e,className:r})=>i.jsxs(U4e,{children:[i.jsx(V4e,{asChild:!0,children:i.jsxs(Dt,{variant:"ghost",size:"icon",onClick:e,className:qt("relative transition-colors",t&&"text-primary hover:text-primary",r),children:[i.jsx(kN,{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(vge,{children:i.jsx("p",{children:"The LevelUp Brief"})})]});var rF="Checkbox",[tZe,f9t]=Jo(rF),[rZe,SH]=tZe(rF);function nZe(t){const{__scopeCheckbox:e,checked:r,children:n,defaultChecked:s,disabled:o,form:c,name:a,onCheckedChange:f,required:p,value:y="on",internal_do_not_use_render:v}=t,[S,E]=_d({prop:r,defaultProp:s??!1,onChange:f,caller:rF}),[k,R]=N.useState(null),[P,M]=N.useState(null),D=N.useRef(!1),B=k?!!c||!!k.closest("form"):!0,V={checked:S,disabled:o,setChecked:E,control:k,setControl:R,name:a,form:c,value:y,hasConsumerStoppedPropagationRef:D,required:p,defaultChecked:cx(s)?!1:s,isFormControl:B,bubbleInput:P,setBubbleInput:M};return i.jsx(rZe,{scope:e,...V,children:sZe(v)?v(V):n})}var a_e="CheckboxTrigger",o_e=N.forwardRef(({__scopeCheckbox:t,onKeyDown:e,onClick:r,...n},s)=>{const{control:o,value:c,disabled:a,checked:f,required:p,setControl:y,setChecked:v,hasConsumerStoppedPropagationRef:S,isFormControl:E,bubbleInput:k}=SH(a_e,t),R=Zn(s,y),P=N.useRef(f);return N.useEffect(()=>{const M=o==null?void 0:o.form;if(M){const D=()=>v(P.current);return M.addEventListener("reset",D),()=>M.removeEventListener("reset",D)}},[o,v]),i.jsx(nn.button,{type:"button",role:"checkbox","aria-checked":cx(f)?"mixed":f,"aria-required":p,"data-state":h_e(f),"data-disabled":a?"":void 0,disabled:a,value:c,...n,ref:R,onKeyDown:Fr(e,M=>{M.key==="Enter"&&M.preventDefault()}),onClick:Fr(r,M=>{v(D=>cx(D)?!0:!D),k&&E&&(S.current=M.isPropagationStopped(),S.current||M.stopPropagation())})})});o_e.displayName=a_e;var TH=N.forwardRef((t,e)=>{const{__scopeCheckbox:r,name:n,checked:s,defaultChecked:o,required:c,disabled:a,value:f,onCheckedChange:p,form:y,...v}=t;return i.jsx(nZe,{__scopeCheckbox:r,checked:s,defaultChecked:o,disabled:a,required:c,onCheckedChange:p,name:n,form:y,value:f,internal_do_not_use_render:({isFormControl:S})=>i.jsxs(i.Fragment,{children:[i.jsx(o_e,{...v,ref:e,__scopeCheckbox:r}),S&&i.jsx(d_e,{__scopeCheckbox:r})]})})});TH.displayName=rF;var l_e="CheckboxIndicator",c_e=N.forwardRef((t,e)=>{const{__scopeCheckbox:r,forceMount:n,...s}=t,o=SH(l_e,r);return i.jsx(vl,{present:n||cx(o.checked)||o.checked===!0,children:i.jsx(nn.span,{"data-state":h_e(o.checked),"data-disabled":o.disabled?"":void 0,...s,ref:e,style:{pointerEvents:"none",...t.style}})})});c_e.displayName=l_e;var u_e="CheckboxBubbleInput",d_e=N.forwardRef(({__scopeCheckbox:t,...e},r)=>{const{control:n,hasConsumerStoppedPropagationRef:s,checked:o,defaultChecked:c,required:a,disabled:f,name:p,value:y,form:v,bubbleInput:S,setBubbleInput:E}=SH(u_e,t),k=Zn(r,E),R=KN(o),P=ON(n);N.useEffect(()=>{const D=S;if(!D)return;const B=window.HTMLInputElement.prototype,G=Object.getOwnPropertyDescriptor(B,"checked").set,W=!s.current;if(R!==o&&G){const Y=new Event("click",{bubbles:W});D.indeterminate=cx(o),G.call(D,cx(o)?!1:o),D.dispatchEvent(Y)}},[S,R,o,s]);const M=N.useRef(cx(o)?!1:o);return i.jsx(nn.input,{type:"checkbox","aria-hidden":!0,defaultChecked:c??M.current,required:a,disabled:f,name:p,value:y,form:v,...e,tabIndex:-1,ref:k,style:{...e.style,...P,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});d_e.displayName=u_e;function sZe(t){return typeof t=="function"}function cx(t){return t==="indeterminate"}function h_e(t){return cx(t)?"indeterminate":t?"checked":"unchecked"}const TT=N.forwardRef(({className:t,...e},r)=>i.jsx(TH,{ref:r,className:qt("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(c_e,{className:qt("flex items-center justify-center text-current"),children:i.jsx(Oa,{className:"h-4 w-4"})})}));TT.displayName=TH.displayName;var EH="Radio",[iZe,f_e]=Jo(EH),[aZe,oZe]=iZe(EH),m_e=N.forwardRef((t,e)=>{const{__scopeRadio:r,name:n,checked:s=!1,required:o,disabled:c,value:a="on",onCheck:f,form:p,...y}=t,[v,S]=N.useState(null),E=Zn(e,P=>S(P)),k=N.useRef(!1),R=v?p||!!v.closest("form"):!0;return i.jsxs(aZe,{scope:r,checked:s,disabled:c,children:[i.jsx(nn.button,{type:"button",role:"radio","aria-checked":s,"data-state":x_e(s),"data-disabled":c?"":void 0,disabled:c,value:a,...y,ref:E,onClick:Fr(t.onClick,P=>{s||f==null||f(),R&&(k.current=P.isPropagationStopped(),k.current||P.stopPropagation())})}),R&&i.jsx(y_e,{control:v,bubbles:!k.current,name:n,value:a,checked:s,required:o,disabled:c,form:p,style:{transform:"translateX(-100%)"}})]})});m_e.displayName=EH;var p_e="RadioIndicator",g_e=N.forwardRef((t,e)=>{const{__scopeRadio:r,forceMount:n,...s}=t,o=oZe(p_e,r);return i.jsx(vl,{present:n||o.checked,children:i.jsx(nn.span,{"data-state":x_e(o.checked),"data-disabled":o.disabled?"":void 0,...s,ref:e})})});g_e.displayName=p_e;var lZe="RadioBubbleInput",y_e=N.forwardRef(({__scopeRadio:t,control:e,checked:r,bubbles:n=!0,...s},o)=>{const c=N.useRef(null),a=Zn(c,o),f=KN(r),p=ON(e);return N.useEffect(()=>{const y=c.current;if(!y)return;const v=window.HTMLInputElement.prototype,E=Object.getOwnPropertyDescriptor(v,"checked").set;if(f!==r&&E){const k=new Event("click",{bubbles:n});E.call(y,r),y.dispatchEvent(k)}},[f,r,n]),i.jsx(nn.input,{type:"radio","aria-hidden":!0,defaultChecked:r,...s,tabIndex:-1,ref:a,style:{...s.style,...p,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});y_e.displayName=lZe;function x_e(t){return t?"checked":"unchecked"}var cZe=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],nF="RadioGroup",[uZe,m9t]=Jo(nF,[vT,f_e]),v_e=vT(),__e=f_e(),[dZe,hZe]=uZe(nF),b_e=N.forwardRef((t,e)=>{const{__scopeRadioGroup:r,name:n,defaultValue:s,value:o,required:c=!1,disabled:a=!1,orientation:f,dir:p,loop:y=!0,onValueChange:v,...S}=t,E=v_e(r),k=P_(p),[R,P]=_d({prop:o,defaultProp:s??null,onChange:v,caller:nF});return i.jsx(dZe,{scope:r,name:n,required:c,disabled:a,value:R,onValueChange:P,children:i.jsx(C7,{asChild:!0,...E,orientation:f,dir:k,loop:y,children:i.jsx(nn.div,{role:"radiogroup","aria-required":c,"aria-orientation":f,"data-disabled":a?"":void 0,dir:k,...S,ref:e})})})});b_e.displayName=nF;var w_e="RadioGroupItem",S_e=N.forwardRef((t,e)=>{const{__scopeRadioGroup:r,disabled:n,...s}=t,o=hZe(w_e,r),c=o.disabled||n,a=v_e(r),f=__e(r),p=N.useRef(null),y=Zn(e,p),v=o.value===s.value,S=N.useRef(!1);return N.useEffect(()=>{const E=R=>{cZe.includes(R.key)&&(S.current=!0)},k=()=>S.current=!1;return document.addEventListener("keydown",E),document.addEventListener("keyup",k),()=>{document.removeEventListener("keydown",E),document.removeEventListener("keyup",k)}},[]),i.jsx(I7,{asChild:!0,...a,focusable:!c,active:v,children:i.jsx(m_e,{disabled:c,required:o.required,checked:v,...f,...s,name:o.name,ref:y,onCheck:()=>o.onValueChange(s.value),onKeyDown:Fr(E=>{E.key==="Enter"&&E.preventDefault()}),onFocus:Fr(s.onFocus,()=>{var E;S.current&&((E=p.current)==null||E.click())})})})});S_e.displayName=w_e;var fZe="RadioGroupIndicator",T_e=N.forwardRef((t,e)=>{const{__scopeRadioGroup:r,...n}=t,s=__e(r);return i.jsx(g_e,{...s,...n,ref:e})});T_e.displayName=fZe;var E_e=b_e,j_e=S_e,mZe=T_e;const A_e=N.forwardRef(({className:t,...e},r)=>i.jsx(E_e,{className:qt("grid gap-2",t),...e,ref:r}));A_e.displayName=E_e.displayName;const k_e=N.forwardRef(({className:t,...e},r)=>i.jsx(j_e,{ref:r,className:qt("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(mZe,{className:"flex items-center justify-center",children:i.jsx(c_,{className:"h-2.5 w-2.5 fill-current text-current"})})}));k_e.displayName=j_e.displayName;const pZe=({brief:t,open:e,onClose:r,onDismiss:n})=>{const{user:s}=Wn(),[o,c]=N.useState({}),[a,f]=N.useState({}),[p,y]=N.useState([]);N.useEffect(()=>{e&&s&&t.polls.length>0&&v()},[e,s,t.polls]);const v=async()=>{if(!s)return;const P=t.polls.map(D=>D.id),{data:M}=await Re.from("levelup_brief_poll_responses").select("poll_id, option_id").eq("user_id",s.id).in("poll_id",P);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)}},S=(P,M)=>{c(D=>({...D,[P]:M}))},E=(P,M,D)=>{c(B=>{const V=B[P]||[];return D?{...B,[P]:[...V,M]}:{...B,[P]:V.filter(G=>G!==M)}})},k=async P=>{if(!s)return;const M=o[P];if(!M||Array.isArray(M)&&M.length===0){$t.error("Please select an option");return}y(D=>[...D,P]);try{await Re.from("levelup_brief_poll_responses").delete().eq("poll_id",P).eq("user_id",s.id);const D=Array.isArray(M)?M:[M],B=D.map(G=>({poll_id:P,option_id:G,user_id:s.id})),{error:V}=await Re.from("levelup_brief_poll_responses").insert(B);if(V)throw V;f(G=>({...G,[P]: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!==P))}},R=P=>(P.includes("mediadelivery.net")||P.includes("bunny"),P);return i.jsx(Fa,{open:e,onOpenChange:P=>!P&&r(),children:i.jsxs(Sa,{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(ki,{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(kN,{className:"h-6 w-6"})}),i.jsxs("div",{children:[i.jsx(ii,{variant:"secondary",className:"mb-1 bg-white/20 text-white border-0",children:"The LevelUp Brief"}),i.jsx(bo,{className:"text-xl font-bold text-white",children:t.brief.title})]})]})]}),i.jsx(Um,{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:R(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(P=>i.jsxs(Dt,{variant:"outline",size:"sm",onClick:()=>window.open(P.url,"_blank"),className:"gap-2",children:[i.jsx(N_,{className:"h-4 w-4"}),P.title]},P.id))})]}),t.polls.map(P=>{var B,V;const M=((B=a[P.id])==null?void 0:B.length)>0,D=p.includes(P.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:P.question}),M&&i.jsxs(ii,{variant:"secondary",className:"gap-1",children:[i.jsx(Bl,{className:"h-3 w-3"}),"Responded"]})]}),P.poll_type==="single"?i.jsx(A_e,{value:o[P.id]||((V=a[P.id])==null?void 0:V[0])||"",onValueChange:G=>S(P.id,G),className:"space-y-2",children:P.options.map(G=>i.jsxs("div",{className:"flex items-center space-x-2",children:[i.jsx(k_e,{value:G.id,id:G.id}),i.jsx(Mr,{htmlFor:G.id,className:"cursor-pointer",children:G.option_text})]},G.id))}):i.jsx("div",{className:"space-y-2",children:P.options.map(G=>{const Y=(o[P.id]||a[P.id]||[]).includes(G.id);return i.jsxs("div",{className:"flex items-center space-x-2",children:[i.jsx(TT,{id:G.id,checked:Y,onCheckedChange:J=>E(P.id,G.id,J)}),i.jsx(Mr,{htmlFor:G.id,className:"cursor-pointer",children:G.option_text})]},G.id)})}),i.jsx(Dt,{size:"sm",onClick:()=>k(P.id),disabled:D,children:D?"Submitting...":M?"Update Response":"Submit"})]},P.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(Dt,{onClick:r,className:"w-full max-w-xs",children:"Got it!"}),i.jsx(Dt,{variant:"ghost",size:"sm",onClick:n,children:"Don't show again"})]})]})})},gZe=()=>{const{user:t}=Wn(),[e,r]=N.useState(null),[n,s]=N.useState(!1),[o,c]=N.useState(!0),[a,f]=N.useState(!1),p=N.useCallback(async()=>{if(!t){c(!1);return}try{const{data:k,error:R}=await Re.from("levelup_briefs").select("*").eq("is_published",!0).lte("publish_date",new Date().toISOString()).order("publish_date",{ascending:!1}).limit(1).single();if(R||!k){c(!1);return}const{data:P}=await Re.from("levelup_brief_views").select("*").eq("brief_id",k.id).eq("user_id",t.id).maybeSingle(),[M,D]=await Promise.all([Re.from("levelup_brief_links").select("*").eq("brief_id",k.id).order("sort_order"),Re.from("levelup_brief_polls").select("*").eq("brief_id",k.id).order("sort_order")]),B=[];if(D.data)for(const J of D.data){const{data:Q}=await Re.from("levelup_brief_poll_options").select("*").eq("poll_id",J.id).order("sort_order");B.push({...J,options:Q||[]})}const V={brief:k,links:M.data||[],polls:B};r(V);const G=!!P,W=(P==null?void 0:P.dismissed_at)!=null,Y=localStorage.getItem(`brief-dismissed-${k.id}`)==="true";if(W||Y)f(!1),s(!1);else if(!G)s(!0),f(!0);else if(k.show_frequency==="every_login")s(!0),f(!0);else if(k.show_frequency==="daily"){const J=new Date(P.viewed_at);(new Date().getTime()-J.getTime())/(1e3*60*60)>=24&&(s(!0),f(!0))}else f(!1)}catch(k){console.error("Error fetching brief:",k)}finally{c(!1)}},[t]);N.useEffect(()=>{p()},[p]);const y=async()=>{if(!(!t||!e))try{const{data:k}=await Re.from("levelup_brief_views").select("id").eq("brief_id",e.brief.id).eq("user_id",t.id).maybeSingle();k?await Re.from("levelup_brief_views").update({viewed_at:new Date().toISOString()}).eq("id",k.id):await Re.from("levelup_brief_views").insert({brief_id:e.brief.id,user_id:t.id})}catch(k){console.error("Error marking brief as viewed:",k)}};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:k,error:R}=await Re.from("levelup_brief_views").select("id").eq("brief_id",e.brief.id).eq("user_id",t.id).maybeSingle();if(R&&console.error("Error checking existing brief view:",R),k){const{error:P}=await Re.from("levelup_brief_views").update({dismissed_at:new Date().toISOString()}).eq("id",k.id).eq("user_id",t.id);P&&console.error("Error updating brief dismiss:",P)}else{const{error:P}=await Re.from("levelup_brief_views").insert({brief_id:e.brief.id,user_id:t.id,dismissed_at:new Date().toISOString()});P&&console.error("Error inserting brief dismiss:",P)}localStorage.setItem(`brief-dismissed-${e.brief.id}`,"true")}catch(k){console.error("Error dismissing brief:",k),e&&localStorage.setItem(`brief-dismissed-${e.brief.id}`,"true")}}},refetch:p}};function yZe(){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"),p=localStorage.getItem("install-banner-shown");if(f||p)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 S=/iPhone|iPad|iPod/i.test(navigator.userAgent);n(S),e(!0),localStorage.setItem("install-banner-shown","true");const E=k=>{k.preventDefault(),o(k)};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(oc,{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(CDe,{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(Dt,{size:"sm",variant:"secondary",onClick:a,className:"text-xs",children:"Install"}),i.jsx(Dt,{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(ki,{className:"h-4 w-4"})})]})]})}):null}const xZe=({children:t,onRefresh:e})=>{const[r,n]=N.useState(!1),[s,o]=N.useState(0),[c,a]=N.useState(!1),f=N.useRef(null),p=N.useRef(0),y=Er(),v=80,S=120,E=N.useCallback(D=>{const B=f.current;B&&B.scrollTop<=0&&(p.current=D.touches[0].clientY,n(!0))},[]),k=N.useCallback(D=>{if(!r||c)return;const B=f.current;if(!B||B.scrollTop>0){n(!1),o(0);return}const G=D.touches[0].clientY-p.current;if(G>0){const Y=Math.min(G*.5,S);o(Y),Y>10&&D.preventDefault()}},[r,c]),R=N.useCallback(async()=>{if(r)if(n(!1),s>=v&&!c){a(!0),o(v);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]),P=Math.min(s/v,1),M=P*180;return i.jsxs("div",{ref:f,className:"h-full overflow-auto",onTouchStart:E,onTouchMove:k,onTouchEnd:R,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:P},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(jDe,{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})]})},vZe=()=>{const{user:t}=Wn(),[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 Re.from("membership_reviews").select("id").eq("user_id",t.id).maybeSingle();if(E){s(!0),r(!1),f(!1);return}const{data:k}=await Re.from("profiles").select("login_count").eq("id",t.id).single(),R=(k==null?void 0:k.login_count)||0;c(R);const P=sessionStorage.getItem("review-prompt-dismissed");r(R>=4&&!P)}catch(E){console.error("Error checking review eligibility:",E)}finally{f(!1)}})()},[t]);const p=N.useCallback(()=>{sessionStorage.setItem("review-prompt-dismissed","true"),r(!1)},[]),y=N.useCallback(async(S,E)=>{if(!t)return{success:!1,error:"Not authenticated"};try{const{error:k}=await Re.from("membership_reviews").insert({user_id:t.id,rating:S,review_text:E});if(k)throw k;return s(!0),r(!1),{success:!0,pointsAwarded:25}}catch(k){return console.error("Error submitting review:",k),{success:!1,error:k.message}}},[t]),v=N.useCallback(async()=>{if(t)try{await Re.from("membership_reviews").update({posted_to_google:!0}).eq("user_id",t.id)}catch(S){console.error("Error updating Google review status:",S)}},[t]);return{shouldShowPrompt:e,hasSubmittedReview:n,loginCount:o,isLoading:a,dismissPrompt:p,submitReview:y,markPostedToGoogle:v}},_Ze="https://search.google.com/local/writereview?placeid=ChIJM73ERQD1QogRPxupMFObuck&source=g.page.m.ia._&laa=nmx-review-solicitation-ia2",bZe=()=>{const{shouldShowPrompt:t,isLoading:e,dismissPrompt:r,submitReview:n,markPostedToGoogle:s}=vZe(),[o,c]=N.useState(!1),[a,f]=N.useState("review"),[p,y]=N.useState(0),[v,S]=N.useState(0),[E,k]=N.useState(""),[R,P]=N.useState(!1),[M,D]=N.useState(!1);if(e||!t&&!M)return null;const B=async()=>{if(p===0){Ai({title:"Please select a rating",variant:"destructive"});return}P(!0);const W=await n(p,E);P(!1),W.success?(D(!0),Ai({title:"Thank you for your feedback!",description:"Your review helps us improve."}),f("google")):Ai({title:"Error submitting review",description:W.error,variant:"destructive"})},V=async W=>{W&&(await navigator.clipboard.writeText(E||`${p} star rating for LevelUp!`),Ai({title:"Review copied!",description:"Paste it on Google Reviews."}),await s(),window.open(_Ze,"_blank")),c(!1),r()},G=()=>{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($l,{className:"h-3.5 w-3.5 fill-current"}),i.jsx("span",{className:"hidden sm:inline",children:"Leave a Review"})]}),i.jsx(Fa,{open:o,onOpenChange:G,children:i.jsx(Sa,{className:"sm:max-w-md",children:a==="review"?i.jsxs(i.Fragment,{children:[i.jsxs(Fo,{children:[i.jsx(bo,{className:"text-center",children:"How are you enjoying LevelUp?"}),i.jsx(Fu,{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(W=>i.jsx("button",{type:"button",onClick:()=>y(W),onMouseEnter:()=>S(W),onMouseLeave:()=>S(0),className:"p-1 transition-transform hover:scale-110",children:i.jsx($l,{className:qt("h-8 w-8 transition-colors",(v||p)>=W?"fill-yellow-400 text-yellow-400":"text-muted-foreground")})},W))}),i.jsx(Bu,{placeholder:"Tell us about your experience (optional)",value:E,onChange:W=>k(W.target.value),rows:4,className:"resize-none"}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(Dt,{variant:"outline",onClick:G,className:"flex-1",children:"Maybe Later"}),i.jsx(Dt,{onClick:B,disabled:R||p===0,className:"flex-1",children:R?"Submitting...":"Submit Review"})]})]})]}):i.jsxs(i.Fragment,{children:[i.jsxs(Fo,{children:[i.jsx(bo,{className:"text-center",children:"🎉 Thank you!"}),i.jsx(Fu,{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(Dt,{variant:"outline",onClick:()=>V(!1),className:"flex-1",children:"No Thanks"}),i.jsx(Dt,{onClick:()=>V(!0),className:"flex-1",children:"Yes, Open Google"})]})]})]})})})]})};function wZe(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(!v){c(!1);return}(async()=>{try{const R="vapid_public_key";let P=localStorage.getItem(R);if(!P){const{data:B,error:V}=await Re.functions.invoke("get-vapid-public-key",{body:{}});if(V)throw V;if(P=(B==null?void 0:B.vapidPublicKey)??null,!P)throw new Error("Missing VAPID public key");localStorage.setItem(R,P)}y(P);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(R){console.error("Error initializing push notifications:",R)}finally{c(!1)}})()},[v]);const S=N.useCallback(async()=>{if(!v||!a||!t)return console.error("Push notifications not supported or user not logged in"),!1;if(!p)return $t.error("Push notifications are not ready yet. Please try again in a moment."),!1;try{c(!0);const k=await a.pushManager.getSubscription();if(k){try{await k.unsubscribe()}catch(V){console.warn("Failed to unsubscribe existing push subscription:",V)}const{error:B}=await Re.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 R=wZe(p);let P;try{P=await a.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:R})}catch(B){console.error("PushManager.subscribe() failed:",B);const V=(B==null?void 0:B.message)||String(B);return V.includes("permission")?$t.error("Push permission denied. Check your browser notification settings."):V.includes("key")||V.includes("VAPID")?$t.error("Push configuration error. Please contact support."):V.includes("AbortError")?$t.error("Push subscription was cancelled. Please try again."):$t.error(`Failed to subscribe: ${V}`),!1}const M=P.toJSON(),{error:D}=await Re.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(k){if(console.error("Error subscribing to push notifications:",k),!(k instanceof Error&&k.message.includes("toast"))){const R=k instanceof Error?k.message:"Unknown error";$t.error("Failed to enable push notifications: "+R)}return!1}finally{c(!1)}},[v,a,t,p]),E=N.useCallback(async()=>{if(!a||!t)return!1;try{c(!0);const k=await a.pushManager.getSubscription();return k&&await k.unsubscribe(),await Re.from("push_subscriptions").delete().eq("user_id",t.id),s(!1),$t.success("Push notifications disabled"),!0}catch(k){console.error("Error unsubscribing:",k);const R=k instanceof Error?k.message:"Unknown error";return $t.error("Failed to disable push notifications: "+R),!1}finally{c(!1)}},[a,t]);return{isSupported:v,permission:e,isSubscribed:n,isLoading:o,vapidPublicKey:p,subscribe:S,unsubscribe:E}}const az="push_notification_prompt_dismissed",TZe=["/dashboard","/admin"],EZe=()=>{const{user:t}=Wn(),{isSupported:e,isSubscribed:r,isLoading:n,subscribe:s}=SZe(),o=Es(),[c,a]=N.useState(!1),[f,p]=N.useState(!1),y=TZe.some(E=>o.pathname===E||o.pathname.startsWith(`${E}/`));N.useEffect(()=>{if(y){a(!1);return}if(!t||!e||r||n||localStorage.getItem(`${az}_${t.id}`))return;const k=setTimeout(()=>{a(!0)},2e3);return()=>clearTimeout(k)},[t,e,r,n,y]);const v=async()=>{p(!0);const E=await s();p(!1),E&&(t&&localStorage.setItem(`${az}_${t.id}`,"true"),a(!1))},S=()=>{t&&localStorage.setItem(`${az}_${t.id}`,"true"),a(!1)};return!e||r||y?null:i.jsx(Fa,{open:c,onOpenChange:E=>!E&&S(),children:i.jsxs(Sa,{className:"sm:max-w-md",children:[i.jsxs(Fo,{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(AN,{className:"h-6 w-6 text-primary"})}),i.jsx(bo,{className:"text-center",children:"Stay in the Loop!"}),i.jsx(Fu,{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(Dt,{onClick:v,disabled:f,className:"w-full",children:f?"Enabling...":"Enable Notifications"}),i.jsx(Dt,{variant:"ghost",onClick:S,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."})]})})},une=t=>{let e;const r=new Set,n=(p,y)=>{const v=typeof p=="function"?p(e):p;if(!Object.is(v,e)){const S=e;e=y??(typeof v!="object"||v===null)?v:Object.assign({},e,v),r.forEach(E=>E(e,S))}},s=()=>e,a={setState:n,getState:s,getInitialState:()=>f,subscribe:p=>(r.add(p),()=>r.delete(p))},f=e=t(n,s,a);return a},jZe=t=>t?une(t):une,AZe=t=>t;function kZe(t,e=AZe){const r=Xe.useSyncExternalStore(t.subscribe,Xe.useCallback(()=>e(t.getState()),[t,e]),Xe.useCallback(()=>e(t.getInitialState()),[t,e]));return Xe.useDebugValue(r),r}const dne=t=>{const e=jZe(t),r=n=>kZe(e,n);return Object.assign(r,e),r},NZe=t=>t?dne(t):dne;function CZe(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 l8=t=>e=>{try{const r=t(e);return r instanceof Promise?r:{then(n){return l8(n)(r)},catch(n){return this}}}catch(r){return{then(n){return this},catch(n){return l8(n)(r)}}}},IZe=(t,e)=>(r,n,s)=>{let o={storage:CZe(()=>window.localStorage),partialize:P=>P,version:0,merge:(P,M)=>({...M,...P}),...e},c=!1,a=0;const f=new Set,p=new Set;let y=o.storage;if(!y)return t((...P)=>{console.warn(`[zustand persist middleware] Unable to update item '${o.name}', the given storage is currently unavailable.`),r(...P)},n,s);const v=()=>{const P=o.partialize({...n()});return y.setItem(o.name,{state:P,version:o.version})},S=s.setState;s.setState=(P,M)=>(S(P,M),v());const E=t((...P)=>(r(...P),v()),n,s);s.getInitialState=()=>E;let k;const R=()=>{var P,M;if(!y)return;const D=++a;c=!1,f.forEach(V=>{var G;return V((G=n())!=null?G:E)});const B=((M=o.onRehydrateStorage)==null?void 0:M.call(o,(P=n())!=null?P:E))||void 0;return l8(y.getItem.bind(y))(o.name).then(V=>{if(V)if(typeof V.version=="number"&&V.version!==o.version){if(o.migrate){const G=o.migrate(V.state,V.version);return G instanceof Promise?G.then(W=>[!0,W]):[!0,G]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,V.state];return[!1,void 0]}).then(V=>{var G;if(D!==a)return;const[W,Y]=V;if(k=o.merge(Y,(G=n())!=null?G:E),r(k,!0),W)return v()}).then(()=>{D===a&&(B==null||B(n(),void 0),k=n(),c=!0,p.forEach(V=>V(k)))}).catch(V=>{D===a&&(B==null||B(void 0,V))})};return s.persist={setOptions:P=>{o={...o,...P},P.storage&&(y=P.storage)},clearStorage:()=>{y==null||y.removeItem(o.name)},getOptions:()=>o,rehydrate:()=>R(),hasHydrated:()=>c,onHydrate:P=>(f.add(P),()=>{f.delete(P)}),onFinishHydration:P=>(p.add(P),()=>{p.delete(P)})},o.skipHydration||R(),k||E},PZe=IZe,N_e=NZe()(PZe((t,e)=>({cartItems:[],addToCart:(r,n,s=1,o)=>{t(c=>{const a=c.cartItems.findIndex(f=>{var p;return f.product.id===r.id&&((p=f.variant)==null?void 0:p.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})})),RZe="/admin/beta/boost",LZe=N.lazy(()=>Fe(()=>import("./BoostCompanion-BMuOMbtV.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8])));function MZe(){const{user:t,isAdmin:e}=Wn(),{isFeatureEnabled:r}=B3(),{pathname:n}=Es(),s=n==="/main-stage"||n.startsWith("/main-stage/");return!(!!t&&(e||r("boost_mascot"))&&n!==RZe&&!s)||!t?null:i.jsx(N.Suspense,{fallback:null,children:i.jsx(LZe,{userId:t.id})})}async function DZe(t){const{data:e,error:r}=await Re.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 p9t(t){const{data:e,error:r}=await Re.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 C_e="America/New_York",g9t=t=>new Intl.DateTimeFormat("en-US",{timeZone:C_e,weekday:"short",month:"short",day:"numeric"}).format(new Date(t)),y9t=t=>new Intl.DateTimeFormat("en-US",{timeZone:C_e,hour:"numeric",minute:"2-digit",timeZoneName:"short"}).format(new Date(t)),x9t=t=>t.trim().toUpperCase().replace(/\s+/g,"");function v9t(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 _9t(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 b9t=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 I_e(){const{data:t}=fr({queryKey:["main-stage-live-nav"],queryFn:async()=>(await DZe()).some(e=>e.status==="live"),refetchInterval:6e4,staleTime:3e4});return!!t}function OZe({activeCategory:t,currentCategory:e,onSelect:r,onHover:n,badgeCounts:s,categories:o=eF}){const c=I_e();return i.jsx("nav",{"aria-label":"Primary",className:"flex flex-col gap-1 p-2",children:o.map(a=>{const f=a.icon,p=t===a.id,y=e===a.id,v=(s==null?void 0:s[a.id])??0,S=`hsl(var(--${a.accent}))`,E=p||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:p,"aria-controls":a.route?void 0:"primary-nav-flyout","aria-current":y?"page":void 0,style:{color:E?S:void 0,backgroundColor:E?`hsl(var(--${a.accent}) / 0.12)`:void 0},className:qt("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:S}}),i.jsxs("span",{className:"relative",children:[i.jsx(f,{className:"h-5 w-5 transition-colors",style:{color:S}}),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"})]}),v>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:S},children:v>9?"9+":v})]}),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 FZe({category:t,top:e,left:r,onClose:n,onNavigate:s,isFavorite:o,favorites:c,onToggleFavorite:a,isCurrent:f,badgeCounts:p}){const y=N.useRef(null);N.useEffect(()=>{const S=k=>{k.key==="Escape"&&n()},E=k=>{var P;if(!y.current)return;const R=k.target;!y.current.contains(R)&&!((P=R==null?void 0:R.closest)!=null&&P.call(R,"[data-nav-rail]"))&&n()};return document.addEventListener("keydown",S),document.addEventListener("mousedown",E),()=>{document.removeEventListener("keydown",S),document.removeEventListener("mousedown",E)}},[n]);const v=S=>{const E=S.icon,k=S.badgeKey?(p==null?void 0:p[S.badgeKey])??0:0;return i.jsxs("div",{className:qt("group flex items-start gap-3 rounded-lg border border-transparent p-2 transition-colors hover:bg-muted/60",f(S)&&"border-primary/30 bg-primary/5"),children:[i.jsxs("button",{type:"button",onClick:()=>s(S),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:qt("mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-lg",S.iconTone==="red"?"bg-destructive/10 text-destructive":"bg-primary/10 text-primary"),children:i.jsx(E,{className:qt("h-4 w-4",S.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:S.label}),S.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"}),S.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"}),S.locked&&i.jsx(xx,{className:"h-3 w-3 text-muted-foreground","aria-label":"Upgrade required"}),k>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:k>9?"9+":k})]}),S.description&&i.jsx("span",{className:"mt-0.5 block text-xs leading-snug text-muted-foreground line-clamp-2",children:S.description})]})]}),i.jsx("button",{type:"button","aria-label":o(S)?`Remove ${S.label} from favorites`:`Add ${S.label} to favorites`,onClick:R=>{R.stopPropagation(),a(S)},className:qt("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(S)&&"opacity-100 text-primary",!o(S)&&"text-muted-foreground/60 hover:text-primary"),children:i.jsx(RM,{className:qt("h-4 w-4",o(S)&&"fill-current")})})]},S.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(RM,{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(v)})]}),t.sections.map(S=>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:S.title}),i.jsx("div",{className:"grid grid-cols-1 gap-1 sm:grid-cols-2",children:S.items.map(v)})]},S.title)),t.sections.length===0&&i.jsx("p",{className:"px-2 py-6 text-sm text-muted-foreground",children:"Nothing here yet."})]})]})}function BZe({categories:t,railCategories:e=eF,currentCategory:r,onNavigate:n,onNavigateRoute:s,isCurrent:o,badgeCounts:c,isFavorite:a,onToggleFavorite:f}){const[p,y]=N.useState(r),v=I_e();return i.jsx("nav",{"aria-label":"Primary",className:"p-2",children:e.map(S=>{const E=S.icon;if(S.route)return i.jsxs("button",{type:"button",onClick:()=>s(S.route),className:qt("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===S.id&&"bg-sidebar-accent"),children:[i.jsx(E,{className:"h-4 w-4",style:{color:`hsl(var(--${S.accent}))`}}),S.label,S.id==="mainstage"&&v&&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"]})]},S.id);const k=t.find(P=>P.id===S.id),R=p===S.id;return i.jsxs("div",{children:[i.jsxs("button",{type:"button","aria-expanded":R,onClick:()=>y(R?null:S.id),className:qt("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===S.id&&"text-primary"),children:[i.jsx(E,{className:"h-4 w-4",style:{color:`hsl(var(--${S.accent}))`}}),S.label,i.jsx(xl,{className:qt("ml-auto h-4 w-4 transition-transform",R&&"rotate-180")})]}),R&&k&&i.jsx("div",{className:"space-y-3 pb-3 pl-4 pr-1",children:k.sections.map(P=>i.jsxs("div",{children:[i.jsx("p",{className:"px-2 py-1 text-[11px] font-semibold uppercase tracking-wider text-muted-foreground",children:P.title}),P.items.map(M=>{const D=M.icon,B=M.badgeKey?(c==null?void 0:c[M.badgeKey])??0:0,V=(a==null?void 0:a(M))??!1;return i.jsxs("div",{className:qt("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:qt("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":V?`Remove ${M.label} from favorites`:`Add ${M.label} to favorites`,onClick:()=>f(M),className:qt("rounded p-2",V?"text-primary":"text-muted-foreground/60"),children:i.jsx(RM,{className:qt("h-4 w-4",V&&"fill-current")})})]},M.id)})]},P.title))})]},S.id)})})}function P_e(){const t=Wi(),e=Es(),r=Xve(),n=N.useCallback(a=>Zve(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 p=n(f);p!=="/"&&e.pathname.startsWith(p)&&(!a||p.length>a.len)&&(a={id:f.primaryCategory,len:p.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 $Ze({communityUnreadCount:t=0,wishlistOpenCount:e=0,flyoutTop:r=64,flyoutLeft:n=80}){const{nav:s,navigate:o,currentCategory:c,isCurrent:a,go:f}=P_e(),[p,y]=N.useState(null),v=N.useRef(null),S=R=>{const P=eF.find(M=>M.id===R);if(P!=null&&P.route){y(null),o(P.route);return}y(M=>M===R?null:R)},E=p?s.categoryMap.get(p):void 0,k={more:t+e};return i.jsxs("div",{"data-nav-rail":!0,className:"flex h-full flex-col",onMouseLeave:()=>{v.current&&window.clearTimeout(v.current),v.current=window.setTimeout(()=>y(null),250)},onMouseEnter:()=>{v.current&&window.clearTimeout(v.current)},children:[i.jsx(OZe,{activeCategory:p,currentCategory:c,onSelect:S,categories:s.railCategories,badgeCounts:k}),E&&i.jsx(FZe,{category:E,top:r,left:n,onClose:()=>y(null),onNavigate:R=>{y(null),f(R)},isFavorite:s.isFavorite,favorites:s.favoritesFor(E.id),onToggleFavorite:R=>s.toggleFavorite(s.favoriteKey(R)),isCurrent:a,badgeCounts:{community:t,wishlist:e}})]})}function zZe({communityUnreadCount:t=0,wishlistOpenCount:e=0,onNavigated:r}){const{nav:n,navigate:s,currentCategory:o,isCurrent:c,go:a}=P_e();return i.jsx(BZe,{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 UZe=({bannerHeight:t,communityUnreadCount:e,wishlistOpenCount:r,isTrial:n,isExpired:s})=>{const o=Wi();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:zVe,alt:"LevelUp",className:"h-8 w-auto"})})}),i.jsxs(Um,{className:"flex-1 [&_[data-radix-scroll-area-scrollbar]]:w-1.5",children:[i.jsx($Ze,{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(vi,{className:"h-4 w-4"}),"Upgrade"]})})]})]})},VZe=({isTrial:t,isExpired:e,expiresAt:r,communityUnreadCount:n,wishlistOpenCount:s,pathname:o,onSignOut:c,onNavigated:a})=>{const f=Wi();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:$Ve,alt:"LevelUp",className:"h-8 w-auto"})}),i.jsxs(Um,{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:qt("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(vi,{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(zZe,{communityUnreadCount:n,wishlistOpenCount:s,onNavigated:a})]}),i.jsxs("div",{className:"border-t border-sidebar-border p-3",children:[i.jsxs(Dt,{variant:"ghost",size:"sm",className:qt("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(Dl,{className:"h-4 w-4"}),"Profile"]}),i.jsxs(Dt,{variant:"ghost",size:"sm",className:qt("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(c3,{className:"h-4 w-4"}),"Credits & Wallet"]}),i.jsxs(Dt,{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(s3,{className:"h-4 w-4"}),"Sign Out"]})]})]})},SS=({children:t,title:e})=>{var ot;const{user:r,signOut:n,isAdmin:s,isBrokerageManager:o,isCoach:c,brokerageId:a}=Wn(),{isAssistant:f,actingAsAgent:p,hasPermission:y}=M3();$7();const{isImpersonating:v}=Tye(),E=(f&&!!p?40:0)+(v?40:0),{avatarUrl:k}=xVe(r==null?void 0:r.id),{isTrial:R,isExpired:P,expiresAt:M}=vVe(r==null?void 0:r.id),{isInnerCircleEnabled:D,isMarketplaceEnabled:B}=B3(),{currentBrief:V,shouldShowPopup:G,hasUnseenBrief:W,openBrief:Y,closeBrief:J,dismissBrief:Q}=gZe(),{unreadCount:ee}=_Ve(),{openCount:le}=bVe();bT();const Te=N_e(jt=>jt.cartItems).reduce((jt,vt)=>jt+vt.quantity,0),{leadSite:Ae,hasLeadSite:Le,siteUrl:ke}=Kve();Yve(!Le);const we=Wi(),me=Es(),[je,_e]=N.useState(null);N.useEffect(()=>{r!=null&&r.id&&Re.from("profiles").select("name").eq("id",r.id).single().then(({data:jt})=>{jt!=null&&jt.name&&_e(jt.name)})},[r==null?void 0:r.id]);const Ee=je||((ot=r==null?void 0:r.user_metadata)==null?void 0:ot.name)||(r==null?void 0:r.email)||"User",[ve,qe]=N.useState(!1),nt=jt=>jt.split(" ").map(vt=>vt[0]).join("").toUpperCase().slice(0,2);return i.jsx(xge,{children:i.jsxs("div",{className:"min-h-screen bg-background flex",children:[R&&P&&me.pathname!=="/subscription"&&i.jsx(JYe,{}),typeof document<"u"&&xg.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(UZe,{bannerHeight:E,communityUnreadCount:ee,wishlistOpenCount:le,isTrial:R,isExpired:P})}),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($xe,{open:ve,onOpenChange:qe,children:[i.jsx(SVe,{asChild:!0,children:i.jsx(Dt,{variant:"ghost",size:"icon",className:"md:hidden",children:i.jsx(C_,{className:"h-5 w-5"})})}),i.jsx(z7,{side:"left",className:"w-72 p-0 bg-card",children:i.jsx(VZe,{isTrial:R,isExpired:P,expiresAt:M,communityUnreadCount:ee,wishlistOpenCount:le,pathname:me.pathname,onSignOut:n,onNavigated:()=>qe(!1)})})]}),i.jsx("div",{className:"flex-1 md:hidden",children:i.jsx("img",{src:UVe,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(cne,{})}),i.jsxs("div",{className:"flex items-center gap-3 ml-auto",children:[R&&!P&&M&&i.jsx(QYe,{expiresAt:M,className:"hidden lg:flex"}),i.jsx("div",{className:"md:hidden",children:i.jsx(cne,{hotkey:!1})}),V&&i.jsx(eZe,{hasUnseenBrief:W,onClick:Y}),B&&i.jsxs(Dt,{variant:"ghost",size:"icon",className:"relative",onClick:()=>we("/marketplace/cart"),children:[i.jsx(Bme,{className:"h-5 w-5"}),Te>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:Te>99?"99+":Te})]}),i.jsx(Dt,{variant:"ghost",size:"icon","aria-label":"My Calendar",title:"My Calendar",onClick:()=>we("/mission-control/calendar"),children:i.jsx(Sm,{className:"h-5 w-5"})}),i.jsx(oYe,{}),i.jsx(PHe,{}),i.jsxs("span",{className:"hidden sm:block text-sm font-medium text-foreground",children:["Hello, ",Ee.split(" ")[0],"!"]}),i.jsxs(qN,{children:[i.jsx(GN,{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(wd,{className:"h-9 w-9 cursor-pointer hover:opacity-80 transition-opacity",children:[i.jsx(Sd,{src:k||void 0}),i.jsx(Td,{className:"bg-primary text-primary-foreground font-medium text-sm",children:nt(Ee)})]})})}),i.jsxs(_T,{align:"end",className:"w-48",children:[i.jsxs(Cu,{onClick:()=>we("/profile"),className:"cursor-pointer",children:[i.jsx(Dl,{className:"h-4 w-4 mr-2"}),"Profile"]}),i.jsxs(Cu,{onClick:()=>we("/credits"),className:"cursor-pointer",children:[i.jsx(c3,{className:"h-4 w-4 mr-2"}),"Credits & Wallet"]}),i.jsxs(Cu,{onClick:()=>we("/mission-control/integrations"),className:"cursor-pointer",children:[i.jsx(LM,{className:"h-4 w-4 mr-2"}),"Integrations"]}),i.jsxs(Cu,{onClick:()=>we("/mission-control/browser-extension"),className:"cursor-pointer",children:[i.jsx(LM,{className:"h-4 w-4 mr-2"}),"Browser Extension"]}),i.jsx(dk,{}),i.jsxs(Cu,{onClick:n,className:"cursor-pointer text-destructive focus:text-destructive",children:[i.jsx(s3,{className:"h-4 w-4 mr-2"}),"Sign Out"]})]})]})]})]})}),i.jsx(xZe,{children:i.jsx("main",{className:"p-4 sm:p-6 lg:p-8 overflow-x-hidden",children:t})}),V&&i.jsx(pZe,{brief:V,open:G,onClose:J,onDismiss:Q}),i.jsx(yZe,{}),i.jsx(bZe,{}),i.jsx(EZe,{}),i.jsx(MZe,{})]})]})})},ct=({children:t,requireAdmin:e=!1,requireBrokerageManager:r=!1})=>{const{user:n,loading:s,rolesLoading:o,isAdmin:c,isBrokerageManager:a}=Wn(),f=Es(),p=Dxe();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(cs,{to:"/auth",replace:!0})}if(e&&!c)return i.jsx(cs,{to:"/dashboard",replace:!0});if(r&&!a&&!c)return i.jsx(cs,{to:"/dashboard",replace:!0});if(p.isRestricted&&!p.isLoading){const y=mVe(f.pathname);if(y&&!p.hasFeature(y))return i.jsx(SS,{title:"Upgrade required",children:i.jsx(yVe,{featureKey:y})})}return i.jsx(i.Fragment,{children:t})};function oz({children:t}){const{isAdmin:e,loading:r,rolesLoading:n}=Wn(),{isFeatureEnabled:s,isLoading:o}=B3();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(cs,{to:"/apps",replace:!0}):i.jsx(SS,{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 jH={};(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 _e=new OffscreenCanvas(1,1),Ee=_e.getContext("2d");Ee.fillRect(0,0,1,1);var ve=_e.transferToImageBitmap();Ee.createPattern(ve,"no-repeat")}catch{return!1}return!0}();function f(){}function p(_e){var Ee=r.exports.Promise,ve=Ee!==void 0?Ee:e.Promise;return typeof ve=="function"?new ve(_e):(_e(f,f),null)}var y=function(_e,Ee){return{transform:function(ve){if(_e)return ve;if(Ee.has(ve))return Ee.get(ve);var qe=new OffscreenCanvas(ve.width,ve.height),nt=qe.getContext("2d");return nt.drawImage(ve,0,0),Ee.set(ve,qe),qe},clear:function(){Ee.clear()}}}(a,new Map),v=function(){var _e=Math.floor(16.666666666666668),Ee,ve,qe={},nt=0;return typeof requestAnimationFrame=="function"&&typeof cancelAnimationFrame=="function"?(Ee=function(ot){var jt=Math.random();return qe[jt]=requestAnimationFrame(function vt(Gt){nt===Gt||nt+_e-1{const{data:e,error:r}=await Re.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 GZe(){const t=Er();return wr({mutationFn:async e=>{const{error:r}=await Re.from("celebration_queue").update({seen_at:new Date().toISOString()}).eq("id",e);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["celebrations"]})}})}function w9t(){const t=Er(),{user:e}=Wn();return wr({mutationFn:async r=>{const{error:n}=await Re.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 HZe={points_earned:OM,listing_created:Gi,deal_closed:Yp,custom:$l},fne={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"},mne=()=>{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 WZe(){const{user:t}=Wn(),e=Er(),{data:r}=qZe(),n=GZe(),[s,o]=N.useState(null),[c,a]=N.useState(!1),f=N.useCallback(()=>{const E=Date.now()+3e3,k={startVelocity:30,spread:360,ticks:60,zIndex:9999},R=(M,D)=>Math.random()*(D-M)+M,P=setInterval(()=>{const M=E-Date.now();if(M<=0){clearInterval(P);return}const D=50*(M/3e3);hne({...k,particleCount:D,origin:{x:R(.1,.3),y:Math.random()-.2},colors:["#ff6b6b","#feca57","#48dbfb","#ff9ff3","#54a0ff","#5f27cd"]}),hne({...k,particleCount:D,origin:{x:R(.7,.9),y:Math.random()-.2},colors:["#ff6b6b","#feca57","#48dbfb","#ff9ff3","#54a0ff","#5f27cd"]})},250)},[]);N.useEffect(()=>{mne()||r&&r.length>0&&!s&&(o(r[0]),a(!0),setTimeout(f,100))},[r,s,f]);const p=async()=>{if(s){const S=s.id;a(!1),o(null),e.setQueryData(["celebrations","pending",t==null?void 0:t.id],E=>(E==null?void 0:E.filter(k=>k.id!==S))??[]),await n.mutateAsync(S)}};if(mne()||!s)return null;const y=HZe[s.celebration_type]||$l,v=fne[s.celebration_type]||fne.custom;return i.jsx(Fa,{open:c,onOpenChange:S=>!S&&p(),children:i.jsxs(Sa,{className:"sm:max-w-md text-center border-0 overflow-hidden",children:[i.jsx("div",{className:`absolute inset-0 bg-gradient-to-br ${v} 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 ${v} 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(vi,{className:"w-5 h-5 text-yellow-500 animate-pulse"}),i.jsx(vi,{className:"w-5 h-5 text-yellow-500 animate-pulse delay-75"}),i.jsx(vi,{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(Dt,{onClick:p,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 pl({className:t,...e}){return i.jsx("div",{className:qt("animate-pulse rounded-md bg-muted",t),...e})}var sF="Tabs",[KZe,S9t]=Jo(sF,[vT]),R_e=vT(),[YZe,AH]=KZe(sF),L_e=N.forwardRef((t,e)=>{const{__scopeTabs:r,value:n,onValueChange:s,defaultValue:o,orientation:c="horizontal",dir:a,activationMode:f="automatic",...p}=t,y=P_(a),[v,S]=_d({prop:n,onChange:s,defaultProp:o??"",caller:sF});return i.jsx(YZe,{scope:r,baseId:Fl(),value:v,onValueChange:S,orientation:c,dir:y,activationMode:f,children:i.jsx(nn.div,{dir:y,"data-orientation":c,...p,ref:e})})});L_e.displayName=sF;var M_e="TabsList",D_e=N.forwardRef((t,e)=>{const{__scopeTabs:r,loop:n=!0,...s}=t,o=AH(M_e,r),c=R_e(r);return i.jsx(C7,{asChild:!0,...c,orientation:o.orientation,dir:o.dir,loop:n,children:i.jsx(nn.div,{role:"tablist","aria-orientation":o.orientation,...s,ref:e})})});D_e.displayName=M_e;var O_e="TabsTrigger",F_e=N.forwardRef((t,e)=>{const{__scopeTabs:r,value:n,disabled:s=!1,...o}=t,c=AH(O_e,r),a=R_e(r),f=z_e(c.baseId,n),p=U_e(c.baseId,n),y=n===c.value;return i.jsx(I7,{asChild:!0,...a,focusable:!s,active:y,children:i.jsx(nn.button,{type:"button",role:"tab","aria-selected":y,"aria-controls":p,"data-state":y?"active":"inactive","data-disabled":s?"":void 0,disabled:s,id:f,...o,ref:e,onMouseDown:Fr(t.onMouseDown,v=>{!s&&v.button===0&&v.ctrlKey===!1?c.onValueChange(n):v.preventDefault()}),onKeyDown:Fr(t.onKeyDown,v=>{[" ","Enter"].includes(v.key)&&c.onValueChange(n)}),onFocus:Fr(t.onFocus,()=>{const v=c.activationMode!=="manual";!y&&!s&&v&&c.onValueChange(n)})})})});F_e.displayName=O_e;var B_e="TabsContent",$_e=N.forwardRef((t,e)=>{const{__scopeTabs:r,value:n,forceMount:s,children:o,...c}=t,a=AH(B_e,r),f=z_e(a.baseId,n),p=U_e(a.baseId,n),y=n===a.value,v=N.useRef(y);return N.useEffect(()=>{const S=requestAnimationFrame(()=>v.current=!1);return()=>cancelAnimationFrame(S)},[]),i.jsx(vl,{present:s||y,children:({present:S})=>i.jsx(nn.div,{"data-state":y?"active":"inactive","data-orientation":a.orientation,role:"tabpanel","aria-labelledby":f,hidden:!S,id:p,tabIndex:0,...c,ref:e,style:{...t.style,animationDuration:v.current?"0s":void 0},children:S&&o})})});$_e.displayName=B_e;function z_e(t,e){return`${t}-trigger-${e}`}function U_e(t,e){return`${t}-content-${e}`}var ZZe=L_e,V_e=D_e,q_e=F_e,G_e=$_e;const iF=ZZe,JN=N.forwardRef(({className:t,...e},r)=>i.jsx(V_e,{ref:r,className:qt("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",t),...e}));JN.displayName=V_e.displayName;const gf=N.forwardRef(({className:t,...e},r)=>i.jsx(q_e,{ref:r,className:qt("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}));gf.displayName=q_e.displayName;const ux=N.forwardRef(({className:t,...e},r)=>i.jsx(G_e,{ref:r,className:qt("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",t),...e}));ux.displayName=G_e.displayName;const _k="#0d0d0d",hD="#1a1a1a",tc="#c9a84c",eC="#f0d78c",Im={captured:"lup_lead_captured_v1",stickyDismissed:"lup_sticky_dismissed_v1",exitShown:"lup_exit_shown_v1",savedListings:"lup_saved_listings_v1"};async function aF(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 Re.functions.invoke("public-site-lead",{body:e});if(n)throw n;try{localStorage.setItem(Im.captured,JSON.stringify({email:t.email,ts:Date.now()}))}catch{}return r}function kH(){try{return!!localStorage.getItem(Im.captured)}catch{return!1}}function XZe(){try{const t=localStorage.getItem(Im.captured);return t?JSON.parse(t).email??null:null}catch{return null}}function NH({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?xg.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, ${hD} 0%, ${_k} 100%)`,border:`1px solid ${tc}33`,boxShadow:`0 30px 80px rgba(0,0,0,0.6), 0 0 0 1px ${tc}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(ki,{className:"h-4 w-4"})}),r]})}),document.body):null}function CH(){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 IH({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(Dl,{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:p=>e({...t,first_name:p.target.value}),className:a,style:f})]}),i.jsxs("div",{className:"relative",children:[i.jsx(ns,{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:p=>e({...t,email:p.target.value}),className:a,style:f})]}),s&&i.jsxs("div",{className:"relative",children:[i.jsx(zn,{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:p=>e({...t,phone:p.target.value}),className:a,style:f})]}),o&&i.jsxs("div",{className:"relative",children:[i.jsx(di,{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:p=>e({...t,area:p.target.value}),className:a,style:f})]}),i.jsx("input",{type:"text",value:r,onChange:p=>n(p.target.value),tabIndex:-1,autoComplete:"off",className:"absolute -left-[9999px] w-0 h-0 opacity-0","aria-hidden":"true"})]})}function PH({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, ${eC} 0%, ${tc} 100%)`,color:_k,boxShadow:`0 8px 24px ${tc}55`},children:t})}function pne({open:t,onClose:e,initialCriteria:r}){const{values:n,setValues:s,loading:o,setLoading:c,honeypot:a,setHoneypot:f}=CH(),[p,y]=N.useState(!1),v=async S=>{if(S.preventDefault(),!!n.email){c(!0);try{await aF({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(Im.stickyDismissed,"1")}catch{}setTimeout(e,2200)}catch{$t.error("Something went wrong. Please try again.")}finally{c(!1)}}};return i.jsx(NH,{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(AN,{className:"h-4 w-4",style:{color:tc}}),i.jsx("span",{className:"text-xs uppercase tracking-[0.2em]",style:{color:eC},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."}),p?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:`${tc}22`,border:`1px solid ${tc}55`},children:i.jsx(vi,{className:"h-5 w-5",style:{color:tc}})}),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:v,className:"space-y-4",children:[i.jsx(IH,{values:n,setValues:s,honeypot:a,setHoneypot:f}),i.jsx(PH,{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 QZe(){const[t,e]=N.useState(!0),[r,n]=N.useState(!1);N.useEffect(()=>{try{const o=!!localStorage.getItem(Im.stickyDismissed)||kH();e(o)}catch{e(!1)}},[]);const s=()=>{e(!0);try{localStorage.setItem(Im.stickyDismissed,"1")}catch{}};return t?i.jsx(pne,{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, ${hD} 0%, ${_k} 100%)`,borderTop:`1px solid ${tc}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:`${tc}22`,border:`1px solid ${tc}55`},children:i.jsx(AN,{className:"h-4 w-4",style:{color:tc}})}),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, ${eC} 0%, ${tc} 100%)`,color:_k},children:"Get Alerts"}),i.jsx("button",{onClick:s,className:"p-2 text-white/50 hover:text-white transition","aria-label":"Dismiss",children:i.jsx(ki,{className:"h-4 w-4"})})]})}),i.jsx(pne,{open:r,onClose:()=>n(!1)})]})}function JZe(){const[t,e]=N.useState(!1),r=N.useRef(!1);N.useEffect(()=>{try{if(sessionStorage.getItem(Im.exitShown)||kH())return}catch{}const S=setTimeout(()=>{r.current=!0},8e3),E=k=>{if(r.current&&!(k.clientY>0)){e(!0);try{sessionStorage.setItem(Im.exitShown,"1")}catch{}window.removeEventListener("mouseleave",E),document.removeEventListener("mouseleave",E)}};return document.addEventListener("mouseleave",E),()=>{clearTimeout(S),document.removeEventListener("mouseleave",E)}},[]);const{values:n,setValues:s,loading:o,setLoading:c,honeypot:a,setHoneypot:f}=CH(),[p,y]=N.useState(!1),v=async S=>{if(S.preventDefault(),!!n.email){c(!0);try{await aF({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(NH,{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, ${_k} 0%, ${hD} 60%, ${tc} 130%)`},children:i.jsx("div",{className:"absolute top-4 left-6",children:i.jsx("span",{className:"text-[10px] uppercase tracking-[0.25em]",style:{color:eC},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:hD,border:`1px solid ${tc}55`,boxShadow:"0 8px 24px rgba(0,0,0,0.5)"},children:i.jsx(vi,{className:"h-6 w-6",style:{color:tc}})}),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."}),p?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:v,className:"space-y-4",children:[i.jsx(IH,{values:n,setValues:s,honeypot:a,setHoneypot:f,showPhone:!1}),i.jsx(PH,{type:"submit",disabled:o||!n.email,children:o?"Sending…":"Send My List"})]})]})]})})}function eXe(){const[t,e]=N.useState([]);N.useEffect(()=>{try{const a=localStorage.getItem(Im.savedListings);a&&e(JSON.parse(a))}catch{}},[]);const r=a=>{e(a);try{localStorage.setItem(Im.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 tXe({listingId:t,listingAddress:e,className:r}){const{has:n,add:s,remove:o}=eXe(),c=n(t),[a,f]=N.useState(!1),p=()=>{if(c){o(t);return}if(kH()){s(t),$t.success("Saved to your favorites"),aF({lead_type:"saved_listing",email:XZe()||"unknown@local",listing_id:t,listing_address:e}).catch(()=>{});return}f(!0)};return i.jsxs(i.Fragment,{children:[i.jsx("button",{onClick:p,className:r,"aria-label":c?"Remove from favorites":"Save to favorites",children:i.jsx(Nm,{className:`h-5 w-5 ${c?"fill-current":""}`})}),i.jsx(rXe,{open:a,onClose:()=>f(!1),listingId:t,listingAddress:e,onSaved:()=>s(t)})]})}function rXe({open:t,onClose:e,listingId:r,listingAddress:n,onSaved:s}){const{values:o,setValues:c,loading:a,setLoading:f,honeypot:p,setHoneypot:y}=CH(),v=async S=>{if(S.preventDefault(),!!o.email){f(!0);try{await aF({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(NH,{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(Nm,{className:"h-4 w-4",style:{color:tc}}),i.jsx("span",{className:"text-xs uppercase tracking-[0.2em]",style:{color:eC},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:v,className:"space-y-4",children:[i.jsx(IH,{values:o,setValues:c,honeypot:p,setHoneypot:y}),i.jsx(PH,{type:"submit",disabled:a||!o.email,children:a?"Saving…":"Save Home"})]})]})})}var H_e=["PageUp","PageDown"],W_e=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],K_e={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},ET="Slider",[c8,nXe,sXe]=EN(ET),[Y_e,T9t]=Jo(ET,[sXe]),[iXe,oF]=Y_e(ET),Z_e=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:p=[n],value:y,onValueChange:v=()=>{},onValueCommit:S=()=>{},inverted:E=!1,form:k,...R}=t,P=N.useRef(new Set),M=N.useRef(0),B=c==="horizontal"?aXe:oXe,[V=[],G]=_d({prop:y,defaultProp:p,onChange:le=>{var Te;(Te=[...P.current][M.current])==null||Te.focus(),v(le)}}),W=N.useRef(V);function Y(le){const pe=hXe(V,le);ee(le,pe)}function J(le){ee(le,M.current)}function Q(){const le=W.current[M.current];V[M.current]!==le&&S(V)}function ee(le,pe,{commit:Te}={commit:!1}){const Ae=gXe(o),Le=yXe(Math.round((le-n)/o)*o+n,Ae),ke=fk(Le,[n,s]);G((we=[])=>{const me=uXe(we,ke,pe);if(pXe(me,f*o)){M.current=me.indexOf(ke);const je=String(me)!==String(we);return je&&Te&&S(me),je?me:we}else return we})}return i.jsx(iXe,{scope:t.__scopeSlider,name:r,disabled:a,min:n,max:s,valueIndexToChangeRef:M,thumbs:P.current,values:V,orientation:c,form:k,children:i.jsx(c8.Provider,{scope:t.__scopeSlider,children:i.jsx(c8.Slot,{scope:t.__scopeSlider,children:i.jsx(B,{"aria-disabled":a,"data-disabled":a?"":void 0,...R,ref:e,onPointerDown:Fr(R.onPointerDown,()=>{a||(W.current=V)}),min:n,max:s,inverted:E,onSlideStart:a?void 0:Y,onSlideMove:a?void 0:J,onSlideEnd:a?void 0:Q,onHomeKeyDown:()=>!a&&ee(n,0,{commit:!0}),onEndKeyDown:()=>!a&&ee(s,V.length-1,{commit:!0}),onStepKeyDown:({event:le,direction:pe})=>{if(!a){const Le=H_e.includes(le.key)||le.shiftKey&&W_e.includes(le.key)?10:1,ke=M.current,we=V[ke],me=o*Le*pe;ee(we+me,ke,{commit:!0})}}})})})})});Z_e.displayName=ET;var[X_e,Q_e]=Y_e(ET,{startEdge:"left",endEdge:"right",size:"width",direction:1}),aXe=N.forwardRef((t,e)=>{const{min:r,max:n,dir:s,inverted:o,onSlideStart:c,onSlideMove:a,onSlideEnd:f,onStepKeyDown:p,...y}=t,[v,S]=N.useState(null),E=Zn(e,B=>S(B)),k=N.useRef(void 0),R=P_(s),P=R==="ltr",M=P&&!o||!P&&o;function D(B){const V=k.current||v.getBoundingClientRect(),G=[0,V.width],Y=RH(G,M?[r,n]:[n,r]);return k.current=V,Y(B-V.left)}return i.jsx(X_e,{scope:t.__scopeSlider,startEdge:M?"left":"right",endEdge:M?"right":"left",direction:M?1:-1,size:"width",children:i.jsx(J_e,{dir:R,"data-orientation":"horizontal",...y,ref:E,style:{...y.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:B=>{const V=D(B.clientX);c==null||c(V)},onSlideMove:B=>{const V=D(B.clientX);a==null||a(V)},onSlideEnd:()=>{k.current=void 0,f==null||f()},onStepKeyDown:B=>{const G=K_e[M?"from-left":"from-right"].includes(B.key);p==null||p({event:B,direction:G?-1:1})}})})}),oXe=N.forwardRef((t,e)=>{const{min:r,max:n,inverted:s,onSlideStart:o,onSlideMove:c,onSlideEnd:a,onStepKeyDown:f,...p}=t,y=N.useRef(null),v=Zn(e,y),S=N.useRef(void 0),E=!s;function k(R){const P=S.current||y.current.getBoundingClientRect(),M=[0,P.height],B=RH(M,E?[n,r]:[r,n]);return S.current=P,B(R-P.top)}return i.jsx(X_e,{scope:t.__scopeSlider,startEdge:E?"bottom":"top",endEdge:E?"top":"bottom",size:"height",direction:E?1:-1,children:i.jsx(J_e,{"data-orientation":"vertical",...p,ref:v,style:{...p.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:R=>{const P=k(R.clientY);o==null||o(P)},onSlideMove:R=>{const P=k(R.clientY);c==null||c(P)},onSlideEnd:()=>{S.current=void 0,a==null||a()},onStepKeyDown:R=>{const M=K_e[E?"from-bottom":"from-top"].includes(R.key);f==null||f({event:R,direction:M?-1:1})}})})}),J_e=N.forwardRef((t,e)=>{const{__scopeSlider:r,onSlideStart:n,onSlideMove:s,onSlideEnd:o,onHomeKeyDown:c,onEndKeyDown:a,onStepKeyDown:f,...p}=t,y=oF(ET,r);return i.jsx(nn.span,{...p,ref:e,onKeyDown:Fr(t.onKeyDown,v=>{v.key==="Home"?(c(v),v.preventDefault()):v.key==="End"?(a(v),v.preventDefault()):H_e.concat(W_e).includes(v.key)&&(f(v),v.preventDefault())}),onPointerDown:Fr(t.onPointerDown,v=>{const S=v.target;S.setPointerCapture(v.pointerId),v.preventDefault(),y.thumbs.has(S)?S.focus():n(v)}),onPointerMove:Fr(t.onPointerMove,v=>{v.target.hasPointerCapture(v.pointerId)&&s(v)}),onPointerUp:Fr(t.onPointerUp,v=>{const S=v.target;S.hasPointerCapture(v.pointerId)&&(S.releasePointerCapture(v.pointerId),o(v))})})}),ebe="SliderTrack",tbe=N.forwardRef((t,e)=>{const{__scopeSlider:r,...n}=t,s=oF(ebe,r);return i.jsx(nn.span,{"data-disabled":s.disabled?"":void 0,"data-orientation":s.orientation,...n,ref:e})});tbe.displayName=ebe;var u8="SliderRange",rbe=N.forwardRef((t,e)=>{const{__scopeSlider:r,...n}=t,s=oF(u8,r),o=Q_e(u8,r),c=N.useRef(null),a=Zn(e,c),f=s.values.length,p=s.values.map(S=>ibe(S,s.min,s.max)),y=f>1?Math.min(...p):0,v=100-Math.max(...p);return i.jsx(nn.span,{"data-orientation":s.orientation,"data-disabled":s.disabled?"":void 0,...n,ref:a,style:{...t.style,[o.startEdge]:y+"%",[o.endEdge]:v+"%"}})});rbe.displayName=u8;var d8="SliderThumb",nbe=N.forwardRef((t,e)=>{const r=nXe(t.__scopeSlider),[n,s]=N.useState(null),o=Zn(e,a=>s(a)),c=N.useMemo(()=>n?r().findIndex(a=>a.ref.current===n):-1,[r,n]);return i.jsx(lXe,{...t,ref:o,index:c})}),lXe=N.forwardRef((t,e)=>{const{__scopeSlider:r,index:n,name:s,...o}=t,c=oF(d8,r),a=Q_e(d8,r),[f,p]=N.useState(null),y=Zn(e,D=>p(D)),v=f?c.form||!!f.closest("form"):!0,S=ON(f),E=c.values[n],k=E===void 0?0:ibe(E,c.min,c.max),R=dXe(n,c.values.length),P=S==null?void 0:S[a.size],M=P?fXe(P,k,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(${k}% + ${M}px)`},children:[i.jsx(c8.ItemSlot,{scope:t.__scopeSlider,children:i.jsx(nn.span,{role:"slider","aria-label":t["aria-label"]||R,"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:Fr(t.onFocus,()=>{c.valueIndexToChangeRef.current=n})})}),v&&i.jsx(sbe,{name:s??(c.name?c.name+(c.values.length>1?"[]":""):void 0),form:c.form,value:E},n)]})});nbe.displayName=d8;var cXe="RadioBubbleInput",sbe=N.forwardRef(({__scopeSlider:t,value:e,...r},n)=>{const s=N.useRef(null),o=Zn(s,n),c=KN(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 v=new Event("input",{bubbles:!0});y.call(a,e),a.dispatchEvent(v)}},[c,e]),i.jsx(nn.input,{style:{display:"none"},...r,ref:o,defaultValue:e})});sbe.displayName=cXe;function uXe(t=[],e,r){const n=[...t];return n[r]=e,n.sort((s,o)=>s-o)}function ibe(t,e,r){const o=100/(r-e)*(t-e);return fk(o,[0,100])}function dXe(t,e){return e>2?`Value ${t+1} of ${e}`:e===2?["Minimum","Maximum"][t]:void 0}function hXe(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 fXe(t,e,r){const n=t/2,o=RH([0,50],[0,n]);return(n-o(e)*r)*r}function mXe(t){return t.slice(0,-1).map((e,r)=>t[r+1]-e)}function pXe(t,e){if(e>0){const r=mXe(t);return Math.min(...r)>=e}return!0}function RH(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 gXe(t){return(String(t).split(".")[1]||"").length}function yXe(t,e){const r=Math.pow(10,e);return Math.round(t*r)/r}var abe=Z_e,xXe=tbe,vXe=rbe,_Xe=nbe;const Zp=N.forwardRef(({className:t,...e},r)=>i.jsxs(abe,{ref:r,className:qt("relative flex w-full touch-none select-none items-center",t),...e,children:[i.jsx(xXe,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:i.jsx(vXe,{className:"absolute h-full bg-primary"})}),i.jsx(_Xe,{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"})]}));Zp.displayName=abe.displayName;const bXe=t=>fr({queryKey:["public-listings",t],queryFn:async()=>{let e=Re.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(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}}),wXe=()=>fr({queryKey:["public-listings-search-index"],staleTime:5*60*1e3,queryFn:async()=>{const{data:t,error:e}=await Re.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)}}}),SXe=t=>fr({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=Re.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(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}),TXe=()=>wr({mutationFn:async({listingId:t,agentId:e,firstName:r,lastName:n,email:s,phone:o,shareToken:c,leadType:a="info_request",preferredDate:f,preferredTime:p,showingMode:y,message:v})=>{let S=null,E=null;if(c){const{data:D}=await Re.from("listing_shares").select("id, sharing_agent_id").eq("share_token",c).eq("listing_id",t).maybeSingle();D&&(S=D.id,E=D.sharing_agent_id)}const k=crypto.randomUUID(),R={id:k},{error:P}=await Re.from("listing_leads").insert({id:k,listing_id:t,agent_id:E||e,first_name:r,last_name:n,email:s,phone:o,share_id:S,referred_by_agent_id:E,lead_type:a,preferred_date:f||null,preferred_time:p||null,showing_mode:y||null,message:v||null});if(P)throw P;const{error:M}=await Re.functions.invoke("process-listing-lead",{body:{leadId:R.id}});return M&&console.error("Error processing lead:",M),R}}),EXe=()=>wr({mutationFn:async t=>{const{error:e}=await Re.rpc("increment_listing_share_click",{p_share_token:t});if(e)throw e}});function jXe({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(cS,{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(di,{className:"h-3.5 w-3.5"}),r]})]}),i.jsx("div",{className:"space-y-10",children:n.map((p,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:p.heading})]}),p.intro&&i.jsx("p",{className:`text-sm sm:text-base leading-relaxed ${a} mb-4`,children:p.intro}),i.jsx("ul",{className:"space-y-3",children:(p.items??[]).map((v,S)=>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:v.name}),v.note&&i.jsx("p",{className:`text-sm mt-1 leading-relaxed ${a}`,children:v.note})]},S))})]},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(zn,{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(ns,{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 TR="border-white/15 bg-white/5 text-white placeholder:text-white/40";function AXe({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),[p,y]=N.useState(!1);if(N.useEffect(()=>{let S=!1;return Re.functions.invoke("community-guide-public",{body:{action:"teaser",listingId:t}}).then(({data:E})=>{!S&&E&&r(E)}).catch(()=>{}),()=>{S=!0}},[t]),!(e!=null&&e.available))return null;const v=async S=>{if(S.preventDefault(),!n.firstName.trim()||!n.email.trim()){$t.error("Please add your name and email.");return}c(!0);try{const{data:E,error:k}=await Re.functions.invoke("community-guide-public",{body:{action:"unlock",listingId:t,...n}});if(k||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(cS,{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((S,E)=>i.jsxs("li",{className:"flex gap-2 text-sm text-white/70",children:[i.jsx(Oa,{className:"h-4 w-4 text-primary shrink-0 mt-0.5"}),S]},E))}),a?i.jsxs(Dt,{className:"w-full mt-5",onClick:()=>y(!0),children:[i.jsx(cS,{className:"h-4 w-4 mr-2"}),"Read your guide"]}):i.jsxs("form",{onSubmit:v,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(Mr,{htmlFor:"cg-first",className:"text-xs text-white/60",children:"First name"}),i.jsx(Dr,{id:"cg-first",value:n.firstName,onChange:S=>s({...n,firstName:S.target.value}),className:TR,required:!0})]}),i.jsxs("div",{className:"space-y-1.5",children:[i.jsx(Mr,{htmlFor:"cg-last",className:"text-xs text-white/60",children:"Last name"}),i.jsx(Dr,{id:"cg-last",value:n.lastName,onChange:S=>s({...n,lastName:S.target.value}),className:TR})]})]}),i.jsxs("div",{className:"space-y-1.5",children:[i.jsx(Mr,{htmlFor:"cg-email",className:"text-xs text-white/60",children:"Email"}),i.jsx(Dr,{id:"cg-email",type:"email",value:n.email,onChange:S=>s({...n,email:S.target.value}),className:TR,required:!0})]}),i.jsxs("div",{className:"space-y-1.5",children:[i.jsx(Mr,{htmlFor:"cg-phone",className:"text-xs text-white/60",children:"Cell phone"}),i.jsx(Dr,{id:"cg-phone",type:"tel",value:n.phone,onChange:S=>s({...n,phone:S.target.value}),className:TR})]}),i.jsxs(Dt,{type:"submit",className:"w-full",disabled:o,children:[o?i.jsx(jc,{className:"h-4 w-4 mr-2 animate-spin"}):i.jsx(oc,{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(xx,{className:"h-3 w-3"}),"Instant access. We never share your details."]})]})]}),i.jsx(Fa,{open:p,onOpenChange:y,children:i.jsx(Sa,{className:"max-w-2xl p-0 gap-0",children:i.jsx(Um,{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(jXe,{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(Dt,{variant:"outline",onClick:()=>kXe(a==null?void 0:a.title),children:[i.jsx(oc,{className:"h-4 w-4 mr-2"}),"Save as PDF"]})})]})})})})]})}function kXe(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 gne={sale:"For Sale",lease:"For Lease",sale_or_lease:"For Sale or Lease",investment:"Investment Offering"},obe={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"},E9t=["NNN","Modified Gross","Full Service","Gross","Absolute Net","Ground Lease"],NXe={sf_year:"/SF/YR",sf_month:"/SF/MO",month:"/MO"},CXe={om:"Offering Memorandum",flyer:"Flyer",rent_roll:"Rent Roll",financials:"Financials",survey:"Survey",site_plan:"Site Plan",lease:"Lease Documents",other:"Other"},j9t={public:"Open download",email:"Email required",nda:"NDA required"},IXe={principal:"Principal / Investor",broker:"Broker",tenant:"Tenant / User",lender:"Lender",other:"Other"},A9t=[{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"}],lz=[{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"}],k9t=[{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 lf(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 yne(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`:lf(e)}function h8(t){return t==null?null:`${new Intl.NumberFormat("en-US").format(Number(t))} SF`}function lbe(t,e=2){return t==null?null:`${Number(t).toFixed(e).replace(/\.?0+$/,"")}%`}function f8(t){if(!(t!=null&&t.lease_rate))return null;const e=NXe[t.lease_rate_unit||"sf_year"]??"";return`${t.lease_rate_unit==="month"?lf(t.lease_rate):`$${Number(t.lease_rate).toFixed(2).replace(/\.00$/,"")}`}${e}${t.lease_type?` ${t.lease_type}`:""}`}function xne(t,e){if(!t)return lf(e)??"Price on request";if(t.deal_type==="lease")return f8(t)??"Rate on request";const r=t.asking_price??e;if(t.deal_type==="sale_or_lease"){const n=[lf(r),f8(t)].filter(Boolean);return n.length?n.join(" · "):"Price on request"}return lf(r)??"Price on request"}function PXe(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?obe[e.commercial_type]:"Commercial"} Opportunity`:t.property_address||`${t.city??""}, ${t.state??""}`}function RXe(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 N9t(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 lz)(s[c.key]||r[c.key])&&n.push(c.key);return{done:n,total:lz.length,score:Math.round(n.length/lz.length*100)}}const C9t={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 I9t(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 P9t="https://commercial.relevelup.com",Pm=Re;function R9t(t){return fr({queryKey:["commercial-details",t],queryFn:async()=>{const{data:e,error:r}=await Pm.from("commercial_listing_details").select("*").eq("listing_id",t).maybeSingle();if(r)throw r;return e??null},enabled:!!t})}function L9t(){const t=Er(),{user:e}=Wn();return wr({mutationFn:async({listingId:r,values:n})=>{const{data:s,error:o}=await Pm.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 M9t(t){return fr({queryKey:["commercial-pitch",t],queryFn:async()=>{const{data:e,error:r}=await Pm.from("commercial_pitch_details").select("*").eq("listing_id",t).maybeSingle();if(r)throw r;return e??null},enabled:!!t})}function D9t(){const t=Er(),{user:e}=Wn();return wr({mutationFn:async({listingId:r,values:n})=>{const{data:s,error:o}=await Pm.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 O9t(){const t=Er();return wr({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 Pm.from("listings").update(c).eq("id",e);if(a)throw a;return(s||o)&&await Pm.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 F9t(){const t=Er();return wr({mutationFn:async({listingId:e,values:r})=>{const{error:n}=await Pm.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 B9t(t,e=90){return fr({queryKey:["commercial-engagement",t,e],queryFn:async()=>{const r=new Date(Date.now()-e*864e5).toISOString(),{data:n,error:s}=await Pm.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 $9t(t){return fr({queryKey:["commercial-leads",t],queryFn:async()=>{const{data:e,error:r}=await Pm.from("listing_leads").select("*").eq("listing_id",t).order("created_at",{ascending:!1});if(r)throw r;return e??[]},enabled:!!t})}const vne="lu_commercial_session";function cbe(){try{let t=localStorage.getItem(vne);return t||(t=crypto.randomUUID(),localStorage.setItem(vne,t)),t}catch{return"anonymous"}}async function Aw(t,e,r={}){try{await Pm.from("commercial_engagement_events").insert({listing_id:t,event_type:e,session_id:cbe(),source:typeof document<"u"&&document.referrer||null,metadata:r})}catch{}}const LXe={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 MXe({open:t,onOpenChange:e,listingId:r,kind:n,documentId:s,requiresNda:o,brokerName:c}){const a=LXe[n],[f,p]=N.useState({firstName:"",lastName:"",email:"",phone:"",company:"",role:"principal",message:""}),[y,v]=N.useState(!1),[S,E]=N.useState(!1),[k,R]=N.useState(null),P=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 Re.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:cbe()}});if(D)throw D;if(M!=null&&M.error)throw new Error(M.error);R({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(Fa,{open:t,onOpenChange:M=>{e(M),M||R(null)},children:i.jsxs(Sa,{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:k?"Access granted":a.title}),i.jsx("p",{className:"mt-1.5 text-sm text-white/60",children:k?k.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})]}),k?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(Bl,{className:"h-5 w-5 text-emerald-400"}),i.jsx("p",{className:"text-sm text-white/80",children:k.fileName??"Request received"})]}),k.signedUrl&&i.jsx(Dt,{className:"w-full",onClick:()=>window.open(k.signedUrl,"_blank"),children:"Download again"}),i.jsx(Dt,{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(cv,{label:"First name *",children:i.jsx(Dr,{value:f.firstName,onChange:M=>p({...f,firstName:M.target.value}),className:"border-white/15 bg-white/5 text-white"})}),i.jsx(cv,{label:"Last name",children:i.jsx(Dr,{value:f.lastName,onChange:M=>p({...f,lastName:M.target.value}),className:"border-white/15 bg-white/5 text-white"})})]}),i.jsx(cv,{label:"Email *",children:i.jsx(Dr,{type:"email",value:f.email,onChange:M=>p({...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(cv,{label:"Company",children:i.jsx(Dr,{value:f.company,onChange:M=>p({...f,company:M.target.value}),className:"border-white/15 bg-white/5 text-white"})}),i.jsx(cv,{label:"Phone",children:i.jsx(Dr,{value:f.phone,onChange:M=>p({...f,phone:M.target.value}),className:"border-white/15 bg-white/5 text-white"})})]}),i.jsx(cv,{label:"I am a *",children:i.jsxs(ba,{value:f.role,onValueChange:M=>p({...f,role:M}),children:[i.jsx(la,{className:"border-white/15 bg-white/5 text-white",children:i.jsx(wa,{})}),i.jsx(ca,{children:Object.entries(IXe).map(([M,D])=>i.jsx(mn,{value:M,children:D},M))})]})}),n!=="om_request"&&i.jsx(cv,{label:"Message",children:i.jsx(Bu,{rows:3,value:f.message,onChange:M=>p({...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(TT,{checked:y,onCheckedChange:M=>v(!!M),className:"mt-0.5 border-white/30"}),i.jsxs("span",{className:"text-xs leading-relaxed text-white/65",children:[i.jsx(o3,{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(Dt,{className:"w-full",size:"lg",onClick:P,disabled:S,children:[S?i.jsx(jc,{className:"mr-2 h-4 w-4 animate-spin"}):i.jsx(xx,{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 cv({label:t,children:e}){return i.jsxs("div",{className:"space-y-1.5",children:[i.jsx(Mr,{className:"text-[11px] font-medium uppercase tracking-wider text-white/50",children:t}),e]})}function ube(t){if(!t)return[];const e=[],r=(n,s)=>{s&&e.push({label:n,value:s})};return r("Cap Rate",lbe(t.cap_rate)),r("NOI",yne(t.noi)),r("Occupancy",t.occupancy_pct!=null?`${Math.round(Number(t.occupancy_pct))}%`:null),r("Building SF",h8(t.building_sf)),r("Available SF",h8(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?lf(t.price_per_sf,2):null),r("Price / Unit",yne(t.price_per_unit)),r("Lease Rate",t.deal_type!=="sale"?f8(t):null),r("Year Built",null),r("Zoning",t.zoning??null),e}function z9t({details:t,className:e="",tone:r="light"}){const n=ube(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 DXe(t){return fr({queryKey:["commercial-microsite",t],queryFn:async()=>{const{data:e,error:r}=await Re.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 OXe({slug:t}){var le,pe;const{data:e,isLoading:r,error:n}=DXe(t),[s,o]=N.useState(null),[c,a]=N.useState(null),f=e==null?void 0:e.listing,p=(e==null?void 0:e.details)??void 0,y=(e==null?void 0:e.documents)??[],v=(f==null?void 0:f.photos)??[],S=f==null?void 0:f.agent,E=!!(p!=null&&p.is_confidential||p!=null&&p.hide_address),k=N.useMemo(()=>ube(p).slice(0,8),[p]);if(N.useEffect(()=>{f!=null&&f.id&&Aw(f.id,"page_view",{slug:t})},[f==null?void 0:f.id,t]),N.useEffect(()=>{if(s===null)return;const Te=Ae=>{Ae.key==="Escape"&&o(null),Ae.key==="ArrowRight"&&o(Le=>Le===null?Le:(Le+1)%v.length),Ae.key==="ArrowLeft"&&o(Le=>Le===null?Le:(Le-1+v.length)%v.length)};return window.addEventListener("keydown",Te),()=>window.removeEventListener("keydown",Te)},[s,v.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 R=PXe(f,p),P=RXe(f,p),M=f.latitude&&f.longitude?`${f.latitude},${f.longitude}`:E?[p==null?void 0:p.submarket,f.city,f.state].filter(Boolean).join(", ")||null:[f.property_address,f.city,f.state].filter(Boolean).join(", ")||null,D=(le=v[0])==null?void 0:le.photo_url,B=(p==null?void 0:p.tenants)??[],V=(p==null?void 0:p.spaces)??[],G=(p==null?void 0:p.demographics)??{},W=(p==null?void 0:p.traffic_counts)??[],Y=(p==null?void 0:p.investment_highlights)??[],J=(p==null?void 0:p.property_highlights)??[],Q=["radius_1","radius_3","radius_5"].some(Te=>(G==null?void 0:G[Te])&&Object.values(G[Te]).some(Boolean)),ee=(Te,Ae)=>{a({kind:Te,documentId:Ae}),Aw(f.id,Te==="om_request"?"om_request":Te,{})};return i.jsxs("div",{className:"min-h-screen bg-[#0b0f14] text-white antialiased",children:[i.jsxs(Oo,{children:[i.jsx("title",{children:`${R} | ${P}`}),i.jsx("meta",{name:"description",content:(f.description??"").slice(0,155)||`${gne[(p==null?void 0:p.deal_type)??"sale"]} — ${P}`}),E&&i.jsx("meta",{name:"robots",content:"noindex,nofollow"}),i.jsx("meta",{property:"og:title",content:R}),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:R,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:gne[(p==null?void 0:p.deal_type)??"sale"]}),(p==null?void 0:p.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:obe[p.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(xx,{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:R}),i.jsxs("p",{className:"mt-4 flex items-center gap-2 text-sm uppercase tracking-[0.2em] text-white/60",children:[i.jsx(di,{className:"h-4 w-4"})," ",P]}),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:(p==null?void 0:p.deal_type)==="lease"?"Lease rate":"Asking price"}),i.jsx("p",{className:"mt-1 text-3xl font-semibold tabular-nums md:text-4xl",children:xne(p,f.price)})]}),(p==null?void 0:p.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:lbe(p.cap_rate)})]})]}),i.jsxs("div",{className:"mt-9 flex flex-wrap gap-3",children:[i.jsxs(Dt,{size:"lg",className:"rounded-full px-7",onClick:()=>{var Te;return ee("om_request",((Te=y.find(Ae=>Ae.doc_kind==="om"))==null?void 0:Te.id)??null)},children:["Request Offering Memorandum ",i.jsx(ji,{className:"ml-2 h-4 w-4"})]}),i.jsx(Dt,{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"})]})]})]}),k.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(k.length,4)}, minmax(0, 1fr))`},children:k.map(Te=>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:Te.label}),i.jsx("p",{className:"mt-2 text-2xl font-semibold tabular-nums md:text-3xl",children:Te.value})]},Te.label))})}),Y.length>0&&i.jsx(yy,{eyebrow:"The opportunity",title:"Investment highlights",children:i.jsx("div",{className:"grid gap-x-12 gap-y-8 md:grid-cols-2",children:Y.map((Te,Ae)=>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(Ae+1).padStart(2,"0")}),i.jsx("p",{className:"text-lg leading-relaxed text-white/85",children:Te})]},Ae))})}),(f.description||J.length>0)&&i.jsx(yy,{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((Te,Ae)=>i.jsx("p",{children:Te},Ae))}),J.length>0&&i.jsx("ul",{className:"space-y-3 self-start rounded-2xl border border-white/10 bg-white/[0.03] p-7",children:J.map((Te,Ae)=>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"})," ",Te]},Ae))})]})}),v.length>1&&i.jsx(yy,{eyebrow:"Gallery",title:"Property imagery",children:i.jsx("div",{className:"grid gap-3 md:grid-cols-3",children:v.slice(1,10).map((Te,Ae)=>i.jsx("button",{onClick:()=>{o(Ae+1),Aw(f.id,"gallery_view",{})},className:`group relative overflow-hidden rounded-xl ${Ae===0?"md:col-span-2 md:row-span-2":""}`,children:i.jsx("img",{src:Te.photo_url,alt:`${R} — image ${Ae+2}`,loading:"lazy",className:`w-full object-cover transition-transform duration-700 group-hover:scale-[1.04] ${Ae===0?"h-full min-h-[280px] md:min-h-[560px]":"h-[180px] md:h-[275px]"}`})},Te.id))})}),((p==null?void 0:p.noi)||(p==null?void 0:p.gross_income)||(p==null?void 0:p.operating_expenses)||(p==null?void 0:p.occupancy_pct)!=null)&&i.jsxs(yy,{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:lf(p==null?void 0:p.noi)},{l:"Gross income",v:lf(p==null?void 0:p.gross_income)},{l:"Operating expenses",v:lf(p==null?void 0:p.operating_expenses)},{l:"Occupancy",v:(p==null?void 0:p.occupancy_pct)!=null?`${Math.round(Number(p.occupancy_pct))}%`:null},{l:"Price per SF",v:(p==null?void 0:p.price_per_sf)!=null?lf(p.price_per_sf,2):null},{l:"Price per unit",v:lf(p==null?void 0:p.price_per_unit)},{l:"Tenancy",v:p!=null&&p.tenancy?`${p.tenancy[0].toUpperCase()}${p.tenancy.slice(1)} tenant`:null},{l:"Broker co-op",v:(p==null?void 0:p.broker_coop_pct)!=null?`${p.broker_coop_pct}%`:null}].filter(Te=>Te.v).map(Te=>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:Te.l}),i.jsx("p",{className:"mt-2 text-xl font-semibold tabular-nums",children:Te.v})]},Te.l))}),(p==null?void 0:p.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(p.call_for_offers_at).toLocaleDateString(void 0,{month:"long",day:"numeric",year:"numeric"})]})]}),(B.length>0||V.length>0)&&i.jsx(yy,{eyebrow:"Occupancy",title:V.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:V.length?"Suite":"Tenant"}),i.jsx("th",{className:"px-6 py-4",children:"SF"}),i.jsx("th",{className:"px-6 py-4",children:V.length?"Rate":"Rent"}),i.jsx("th",{className:"px-6 py-4",children:V.length?"Availability":"Lease expiry"})]})}),i.jsx("tbody",{className:"divide-y divide-white/5",children:(V.length?V:B).map((Te,Ae)=>i.jsxs("tr",{className:"text-white/80",children:[i.jsx("td",{className:"px-6 py-4 font-medium text-white",children:Te.suite??Te.name??"—"}),i.jsx("td",{className:"px-6 py-4 tabular-nums",children:Te.sf?h8(Number(Te.sf)):"—"}),i.jsx("td",{className:"px-6 py-4",children:Te.rate??Te.rent??"—"}),i.jsx("td",{className:"px-6 py-4",children:Te.availability??Te.lease_expiry??"—"})]},Ae))})]})})}),i.jsx(yy,{eyebrow:"Location",title:p!=null&&p.submarket?`${p.submarket} submarket`:P,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:()=>Aw(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.":P}),i.jsxs("div",{className:"space-y-5",children:[(p==null?void 0:p.zoning)&&i.jsx(kw,{label:"Zoning",value:p.zoning}),(p==null?void 0:p.lot_acres)!=null&&i.jsx(kw,{label:"Site size",value:`${p.lot_acres} acres`}),(p==null?void 0:p.parking_spaces)!=null&&i.jsx(kw,{label:"Parking",value:`${p.parking_spaces} spaces`}),(p==null?void 0:p.opportunity_zone)&&i.jsx(kw,{label:"Opportunity Zone",value:"Qualified"}),W.filter(Te=>Te.road||Te.count).map((Te,Ae)=>i.jsx(kw,{label:`Traffic count — ${Te.road??"Adjacent road"}`,value:`${Te.count??"—"} VPD`},Ae)),!(p!=null&&p.zoning)&&(p==null?void 0:p.lot_acres)==null&&(p==null?void 0:p.parking_spaces)==null&&!(p!=null&&p.opportunity_zone)&&i.jsx(kw,{label:"Submarket",value:(p==null?void 0:p.submarket)||P})]})]})}),Q&&i.jsx(yy,{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(([Te,Ae])=>{const Le=G==null?void 0:G[Te];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:Ae}),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(([,ke])=>ke).map(([ke,we])=>i.jsxs("div",{className:"flex justify-between gap-4",children:[i.jsx("dt",{className:"text-white/50",children:ke}),i.jsx("dd",{className:"font-medium tabular-nums",children:we})]},ke))})]},Te)})})}),y.length>0&&i.jsx(yy,{eyebrow:"Deal room",title:"Offering documents",children:i.jsx("div",{className:"grid gap-4 md:grid-cols-2",children:y.map(Te=>{const Ae=Te.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:Ae?i.jsx(oc,{className:"h-5 w-5"}):Te.gate_level==="nda"?i.jsx(o3,{className:"h-5 w-5"}):i.jsx(xx,{className:"h-5 w-5"})}),i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsx("p",{className:"truncate font-medium",children:Te.title||CXe[Te.doc_kind||"other"]}),i.jsx("p",{className:"text-xs text-white/45",children:Ae?"Available to download":Te.gate_level==="nda"?"Confidentiality acknowledgement required":"Registration required"})]}),i.jsx(Dt,{size:"sm",variant:"outline",className:"border-white/20 bg-transparent text-white hover:bg-white/10 hover:text-white",onClick:()=>ee("om_request",Te.id),children:Ae?"Download":"Request"})]},Te.id)})})}),S&&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:[S.avatar_url&&i.jsx("img",{src:S.avatar_url,alt:S.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:S.name}),i.jsx("p",{className:"text-sm text-white/55",children:((pe=S.brokerage)==null?void 0:pe.name)||S.brokerage_name})]})]}),i.jsxs("div",{className:"flex flex-wrap gap-3",children:[S.email&&i.jsxs(Dt,{variant:"outline",className:"rounded-full border-white/20 bg-transparent text-white hover:bg-white/10 hover:text-white",onClick:()=>{Aw(f.id,"contact_click",{}),window.location.href=`mailto:${S.email}`},children:[i.jsx(ns,{className:"mr-2 h-4 w-4"})," Email"]}),S.phone&&i.jsxs(Dt,{variant:"outline",className:"rounded-full border-white/20 bg-transparent text-white hover:bg-white/10 hover:text-white",onClick:()=>{Aw(f.id,"contact_click",{}),window.location.href=`tel:${S.phone}`},children:[i.jsx(zn,{className:"mr-2 h-4 w-4"})," Call"]}),i.jsx(Dt,{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:R}),i.jsxs("p",{className:"truncate text-xs text-white/50",children:[xne(p,f.price)," · ",P]})]}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(Dt,{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(Dt,{size:"sm",className:"rounded-full",onClick:()=>{var Te;return ee("om_request",((Te=y.find(Ae=>Ae.doc_kind==="om"))==null?void 0:Te.id)??null)},children:"Request OM"})]})]})}),i.jsx(Fa,{open:s!==null,onOpenChange:Te=>!Te&&o(null),children:i.jsx(Sa,{className:"max-w-[96vw] border-none bg-transparent p-0 shadow-none",children:s!==null&&v[s]&&i.jsxs("div",{className:"relative",children:[i.jsx("img",{src:v[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(ki,{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(Te=>(Te-1+v.length)%v.length),children:i.jsx(Om,{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(Te=>(Te+1)%v.length),children:i.jsx(kd,{className:"h-6 w-6"})})]})})}),c&&i.jsx(MXe,{open:!0,onOpenChange:Te=>!Te&&a(null),listingId:f.id,kind:c.kind,documentId:c.documentId,requiresNda:!!(p!=null&&p.requires_nda)||(p==null?void 0:p.om_gate_mode)==="nda",brokerName:S==null?void 0:S.name})]})}function yy({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 kw({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 _ne="/assets/levelup-logo-color-BeKd2k_g.png",FXe={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"},cz={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"},bne={single_family:"Single Family",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury",commercial:"Commercial",other:"Other"},uz=t=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(t),b2=t=>new Intl.NumberFormat("en-US").format(t);function dbe(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 LH({slugOverride:t}={}){var ua,Nr,qn,Yi,ja,So,Zr;const e=$m(),r=t||e.slugOrId,[n]=Fx(),{data:s,isLoading:o}=SXe(r||""),c=TXe(),a=EXe(),f=n.get("ref"),[p,y]=N.useState(""),[v,S]=N.useState(""),[E,k]=N.useState(""),[R,P]=N.useState(""),[M,D]=N.useState(""),[B,V]=N.useState(""),[G,W]=N.useState(""),[Y,J]=N.useState("in_person"),[Q,ee]=N.useState("info"),[le,pe]=N.useState(!1),[Te,Ae]=N.useState(!1),[Le,ke]=N.useState(null),[we,me]=N.useState(!1);N.useState(!1);const[je,_e]=N.useState(!1),[Ee,ve]=N.useState(20),[qe,nt]=N.useState(6.5),[ot,jt]=N.useState(30),vt=N.useRef(null),[Gt,pt]=N.useState(!1);N.useEffect(()=>{const fn=()=>pt(window.scrollY>300);return window.addEventListener("scroll",fn,{passive:!0}),()=>window.removeEventListener("scroll",fn)},[]),N.useEffect(()=>{f&&a.mutate(f)},[f]),N.useEffect(()=>{window.scrollTo({top:0,left:0,behavior:"auto"})},[r]);const Ct=(s==null?void 0:s.photos)||[],tr=Ct.find(fn=>fn.is_primary)||Ct[0],wt=N.useMemo(()=>{if(!(s!=null&&s.price))return 0;const fn=s.price*(1-Ee/100),xn=qe/100/12,Xr=ot*12;return xn===0?fn/Xr:fn*xn/(1-Math.pow(1+xn,-Xr))},[s==null?void 0:s.price,Ee,qe,ot]),lr=async()=>{const fn=window.location.href;if(navigator.share)try{await navigator.share({title:document.title,url:fn})}catch{}else await navigator.clipboard.writeText(fn),$t.success("Link copied to clipboard")},Sr=async fn=>{if(fn.preventDefault(),!p.trim()||!E.trim()||!s)return;const xn=Q==="showing";if(xn&&!B){$t.error("Please pick a preferred date for your showing");return}pe(!0);try{await c.mutateAsync({listingId:s.id,agentId:s.agent_id,firstName:p.trim(),lastName:v.trim(),email:E.trim(),phone:R.trim(),shareToken:f,leadType:xn?"showing_request":"info_request",preferredDate:xn?B:null,preferredTime:xn&&G||null,showingMode:xn?Y:null,message:M.trim()||null}),Ae(!0),$t.success(xn?"Showing request sent! The agent will confirm details shortly.":"Thanks! The agent will be in touch soon.")}catch(Xr){console.error("Lead submission error:",Xr),$t.error(`Failed to submit: ${Xr.message||"Please try again"}`)}finally{pe(!1)}},sn=()=>{Le!==null&&ke(Le===0?Ct.length-1:Le-1)},cr=()=>{Le!==null&&ke(Le===Ct.length-1?0:Le+1)};if((s==null?void 0:s.listing_class)==="commercial")return i.jsx(OXe,{slug:r});if(o)return i.jsx("div",{className:"min-h-screen bg-neutral-950",children:i.jsx(pl,{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(qr,{to:"/public/listings",className:"flex items-center gap-2",children:i.jsx("img",{src:_ne,alt:"LevelUp",className:"h-8"})})})}),i.jsxs("div",{className:"container mx-auto px-4 py-24 text-center",children:[i.jsx(Gi,{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(Dt,{asChild:!0,children:i.jsx(qr,{to:typeof window<"u"&&window.location.host==="listings.relevelup.com"?"/":"/public/listings",children:"Browse All Listings"})})]})]});const yr=s.property_address?`${s.property_address} — ${s.city}, ${s.state}`:`${s.city}, ${s.state} Home for Sale`,Pr=((Nr=(ua=s.agent)==null?void 0:ua.brokerage)==null?void 0:Nr.name)||((qn=s.agent)==null?void 0:qn.brokerage_name),jn=((Yi=s.agent)==null?void 0:Yi.name)||"",Je=dbe(s.video_link),St=Pr||jn||"",Jt=cz[s.status]==="Sold"?"Just Sold":cz[s.status],Ir=Jt?`${Jt}: ${yr}`:yr,ur=[`${uz(s.price)} · ${s.city}, ${s.state}`,jn?`Presented by ${jn}${Pr?`, ${Pr}`:""}.`:""].filter(Boolean).join(" · "),ar=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,It=s.description||"",pr=It.length>420,Tn=je||!pr?It:It.slice(0,420).trimEnd()+"…",ss=s.page_config||{},is=fn=>{var xn;return(((xn=ss.sections)==null?void 0:xn[fn])??!0)!==!1},Us=Array.isArray(ss.addons)?ss.addons:[],Ea=ss.custom_note||"",vs=ss.accent_color||null;return i.jsxs(i.Fragment,{children:[i.jsxs(Oo,{children:[i.jsx("title",{children:St?`${yr} | ${St}`:yr}),i.jsx("meta",{name:"description",content:`${uz(s.price)} · ${s.bedrooms||""}BD ${s.bathrooms||""}BA ${s.square_footage?s.square_footage.toLocaleString()+" sqft · ":""}${bne[s.property_type]} in ${s.city}, ${s.state}. ${It.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:Ir}),i.jsx("meta",{property:"og:description",content:ur}),i.jsx("meta",{property:"og:type",content:"website"}),i.jsx("meta",{property:"og:url",content:`https://listings.relevelup.com/${s.slug||s.id}`}),tr&&i.jsx("meta",{property:"og:image",content:tr.photo_url}),St&&i.jsx("meta",{property:"og:site_name",content:St}),i.jsx("meta",{name:"twitter:card",content:"summary_large_image"}),i.jsx("meta",{name:"twitter:title",content:Ir}),i.jsx("meta",{name:"twitter:description",content:ur}),tr&&i.jsx("meta",{name:"twitter:image",content:tr.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:It,url:`https://listings.relevelup.com/${s.slug||s.id}`,datePosted:s.created_at,image:Ct.map(fn=>fn.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(qr,{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(yx,{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(([fn,xn])=>i.jsx("a",{href:`#${fn}`,className:"px-3 py-1.5 rounded-full text-white/70 hover:text-white hover:bg-white/10 transition",children:xn},fn))}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(tXe,{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:lr,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(NN,{className:"h-4 w-4 text-white"})}),i.jsx(Dt,{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:vt,id:"overview",className:"relative h-[100svh] min-h-[620px] w-full overflow-hidden",children:[tr?i.jsx("img",{src:tr.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(ii,{className:`${FXe[s.status]} text-white border-0 uppercase tracking-widest text-[10px] px-3 py-1 rounded-full shadow-lg`,children:cz[s.status]}),Ct.length>0&&i.jsxs("button",{onClick:()=>ke(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(Jee,{className:"h-3.5 w-3.5"}),Ct.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:uz(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:b2(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(Dl,{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}),Pr&&i.jsx("p",{className:"text-xs text-white/60",children:Pr})]}),i.jsx(Dt,{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(Dl,{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(Dt,{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"]})]})})]}),is("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:oT,label:"Bedrooms",value:s.bedrooms},s.bathrooms&&{icon:k_,label:"Bathrooms",value:s.bathrooms},s.square_footage&&{icon:W9,label:"Interior",value:`${b2(s.square_footage)} sqft`},s.lot_size&&{icon:a3,label:"Lot Size",value:s.lot_size},s.year_built&&{icon:co,label:"Year Built",value:s.year_built},!s.year_built&&s.square_footage&&{icon:KU,label:"Price / sqft",value:`$${b2(Math.round(s.price/s.square_footage))}`}].filter(Boolean).slice(0,5).map((fn,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(fn.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:fn.label}),i.jsx("p",{className:"font-display text-2xl text-white font-light",children:fn.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:[is("story")&&It&&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:Tn})}),pr&&i.jsx("button",{onClick:()=>_e(!je),className:"mt-4 text-sm text-white/60 hover:text-white underline underline-offset-4",children:je?"Show less":"Read more"}),i.jsxs("div",{className:"mt-8 flex flex-wrap gap-2",children:[i.jsxs(ii,{variant:"outline",className:"border-white/20 text-white/80 bg-white/5",children:[i.jsx(so,{className:"h-3 w-3 mr-1.5"}),bne[s.property_type]]}),s.has_hoa&&i.jsx(ii,{variant:"outline",className:"border-white/20 text-white/80 bg-white/5",children:"HOA"}),s.mls_link&&i.jsx(Dt,{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(N_,{className:"h-3.5 w-3.5 mr-1.5"})," MLS"]})})]}),(Ea||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(vi,{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:['"',Ea||s.agent_notes,'"']})]})]}),is("gallery")&&Ct.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:()=>ke(0),className:"text-sm text-white/60 hover:text-white underline underline-offset-4 hidden sm:inline",children:["View all ",Ct.length]})]}),i.jsx("div",{className:"grid grid-cols-4 gap-2 sm:gap-3",children:Ct.slice(0,7).map((fn,xn)=>{const Xr=["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"],ds=xn===6&&Ct.length>7;return i.jsxs("button",{onClick:()=>ke(xn),className:`${Xr[xn]} relative rounded-xl overflow-hidden group bg-neutral-900`,children:[i.jsx("img",{src:fn.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"}),ds&&i.jsxs("div",{className:"absolute inset-0 bg-black/60 flex flex-col items-center justify-center text-white",children:[i.jsx(Jee,{className:"h-6 w-6 mb-1"}),i.jsxs("span",{className:"font-medium",children:["+",Ct.length-7," more"]})]})]},fn.id)})})]}),is("video")&&!((ja=s.video)!=null&&ja.playback_url)&&Je&&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:Je,className:"absolute inset-0 h-full w-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,title:"Video Tour"})})]}),is("video")&&((So=s.video)==null?void 0:So.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"})})]}),is("map")&&ar&&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:ar,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(di,{className:"h-4 w-4"}),s.property_address?`${s.property_address}, `:"",s.city,", ",s.state]})]}),is("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:["$",b2(Math.round(wt))]}),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(Mr,{className:"text-white/70 text-xs uppercase tracking-widest",children:"Down Payment"}),i.jsxs("span",{className:"text-white font-medium",children:[Ee,"%"]})]}),i.jsx(Zp,{value:[Ee],onValueChange:fn=>ve(fn[0]),min:0,max:50,step:1}),i.jsxs("p",{className:"text-xs text-white/50 mt-2",children:["$",b2(Math.round(s.price*Ee/100))," down"]})]}),i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center justify-between mb-2",children:[i.jsx(Mr,{className:"text-white/70 text-xs uppercase tracking-widest",children:"Interest Rate"}),i.jsxs("span",{className:"text-white font-medium",children:[qe.toFixed(2),"%"]})]}),i.jsx(Zp,{value:[qe],onValueChange:fn=>nt(fn[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(Mr,{className:"text-white/70 text-xs uppercase tracking-widest",children:"Loan Term"}),i.jsxs("span",{className:"text-white font-medium",children:[ot," yr"]})]}),i.jsx(Zp,{value:[ot],onValueChange:fn=>jt(fn[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."})]})]}),Us.map(fn=>{const xn=fn.type,Xr=fn.data||{};if(xn==="extra_video"&&Xr.url){const ds=String(Xr.url).includes("youtu")?`https://www.youtube.com/embed/${String(Xr.url).split(/[/=]/).pop()}`:Xr.url;return i.jsxs("section",{children:[i.jsx("p",{className:"text-[11px] uppercase tracking-[0.3em] text-white/40 mb-2",children:Xr.eyebrow||"Featured Video"}),i.jsx("h2",{className:"font-display text-3xl sm:text-4xl font-light text-white mb-6",children:Xr.title||"Watch"}),i.jsx("div",{className:"relative rounded-2xl overflow-hidden bg-black shadow-2xl aspect-video",children:i.jsx("iframe",{src:ds,className:"absolute inset-0 h-full w-full",allowFullScreen:!0,title:Xr.title||"Video"})})]},fn.id)}return xn==="3d_tour"&&Xr.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:Xr.title||"Step inside"}),i.jsx("div",{className:"relative rounded-2xl overflow-hidden bg-black shadow-2xl aspect-video",children:i.jsx("iframe",{src:Xr.url,className:"absolute inset-0 h-full w-full",allowFullScreen:!0,title:"3D Tour"})})]},fn.id):xn==="floor_plan"&&Xr.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:Xr.title||"Layout"}),i.jsx("img",{src:Xr.image_url,alt:"Floor plan",className:"w-full rounded-2xl border border-white/10"})]},fn.id):xn==="testimonial"&&Xr.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:['"',Xr.quote,'"']}),Xr.author&&i.jsxs("p",{className:"mt-4 text-sm text-white/60",children:["— ",Xr.author]})]},fn.id):xn==="custom_cta"&&Xr.label?i.jsxs("section",{className:"rounded-2xl p-8 text-center",style:{background:vs?`${vs}22`:"rgba(255,255,255,0.05)",border:`1px solid ${vs||"rgba(255,255,255,0.1)"}`},children:[Xr.title&&i.jsx("h3",{className:"font-display text-3xl text-white mb-4",children:Xr.title}),i.jsx(Dt,{asChild:!0,size:"lg",style:vs?{background:vs}:void 0,children:i.jsx("a",{href:Xr.url||"#agent",children:Xr.label})})]},fn.id):null})]}),i.jsxs("aside",{id:"agent",className:"lg:sticky lg:top-24 lg:self-start space-y-6",children:[i.jsx(AXe,{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(Dl,{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}),Pr&&i.jsx("p",{className:"text-sm text-white/60 mt-0.5",children:Pr})]})]}),i.jsxs("div",{className:"mt-4 grid grid-cols-2 gap-2",children:[s.agent.phone&&i.jsx(Dt,{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(zn,{className:"h-3.5 w-3.5 mr-1.5"}),"Call"]})}),s.agent.email&&i.jsx(Dt,{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(ns,{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(Dl,{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(Dt,{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(zn,{className:"h-3.5 w-3.5 mr-1.5"}),"Call"]})}),s.co_agent_email&&i.jsx(Dt,{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(ns,{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(wne,{submitted:Te,activeTab:Q,setActiveTab:ee,firstName:p,setFirstName:y,lastName:v,setLastName:S,email:E,setEmail:k,phone:R,setPhone:P,message:M,setMessage:D,preferredDate:B,setPreferredDate:V,preferredTime:G,setPreferredTime:W,showingMode:Y,setShowingMode:J,isSubmitting:le,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:[((Zr=s.agent)==null?void 0:Zr.phone)&&i.jsx(Dt,{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(zn,{className:"h-4 w-4 mr-1.5"}),"Call"]})}),i.jsxs(Dt,{onClick:()=>me(!0),className:"bg-white text-neutral-900 hover:bg-white/90 flex-[2] font-medium",children:[i.jsx(B9,{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:_ne,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(Fa,{open:Le!==null,onOpenChange:()=>ke(null),children:i.jsxs(Sa,{className:"max-w-6xl p-0 bg-black/95 border-0",children:[i.jsx(Fo,{className:"sr-only",children:i.jsx(bo,{children:"Photo Gallery"})}),i.jsx("button",{onClick:()=>ke(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(ki,{className:"h-5 w-5"})}),Le!==null&&Ct[Le]&&i.jsxs("div",{className:"relative",children:[i.jsx("img",{src:Ct[Le].photo_url,alt:`Photo ${Le+1}`,className:"w-full max-h-[85vh] object-contain"}),Ct.length>1&&i.jsxs(i.Fragment,{children:[i.jsx("button",{onClick:sn,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(Om,{className:"h-6 w-6"})}),i.jsx("button",{onClick:cr,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(kd,{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," / ",Ct.length]})]})]})]})}),i.jsx(Fa,{open:we,onOpenChange:me,children:i.jsxs(Sa,{className:"max-w-md p-0 bg-white text-neutral-900",children:[i.jsx(Fo,{className:"sr-only",children:i.jsx(bo,{children:"Contact the agent"})}),i.jsx("div",{className:"p-6",children:i.jsx(wne,{submitted:Te,activeTab:Q,setActiveTab:ee,firstName:p,setFirstName:y,lastName:v,setLastName:S,email:E,setEmail:k,phone:R,setPhone:P,message:M,setMessage:D,preferredDate:B,setPreferredDate:V,preferredTime:G,setPreferredTime:W,showingMode:Y,setShowingMode:J,isSubmitting:le,onSubmit:Sr})})]})})]})]})}function wne(t){const{submitted:e,activeTab:r,setActiveTab:n,firstName:s,setFirstName:o,lastName:c,setLastName:a,email:f,setEmail:p,phone:y,setPhone:v,message:S,setMessage:E,preferredDate:k,setPreferredDate:R,preferredTime:P,setPreferredTime:M,showingMode:D,setShowingMode:B,isSubmitting:V,onSubmit:G}=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(Oa,{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(iF,{value:r,onValueChange:W=>n(W),children:[i.jsxs(JN,{className:"grid w-full grid-cols-2 mb-4",children:[i.jsxs(gf,{value:"info",className:"gap-1.5",children:[i.jsx(ph,{className:"h-3.5 w-3.5"})," Get Info"]}),i.jsxs(gf,{value:"showing",className:"gap-1.5",children:[i.jsx(B9,{className:"h-3.5 w-3.5"})," Request Tour"]})]}),i.jsxs("form",{onSubmit:G,className:"space-y-3",children:[i.jsxs(ux,{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(Mr,{htmlFor:"preferredDate",children:"Preferred Date *"}),i.jsx(Dr,{id:"preferredDate",type:"date",value:k,onChange:W=>R(W.target.value),min:new Date().toISOString().split("T")[0],required:r==="showing"})]}),i.jsxs("div",{children:[i.jsx(Mr,{htmlFor:"preferredTime",children:"Preferred Time"}),i.jsxs(ba,{value:P,onValueChange:M,children:[i.jsx(la,{id:"preferredTime",children:i.jsx(wa,{placeholder:"Any time"})}),i.jsxs(ca,{children:[i.jsx(mn,{value:"morning",children:"Morning (9am–12pm)"}),i.jsx(mn,{value:"afternoon",children:"Afternoon (12pm–5pm)"}),i.jsx(mn,{value:"evening",children:"Evening (5pm–8pm)"})]})]})]})]}),i.jsxs("div",{children:[i.jsx(Mr,{htmlFor:"showingMode",children:"Tour Type"}),i.jsxs(ba,{value:D,onValueChange:W=>B(W),children:[i.jsx(la,{id:"showingMode",children:i.jsx(wa,{})}),i.jsxs(ca,{children:[i.jsx(mn,{value:"in_person",children:"🏡 In-person showing"}),i.jsx(mn,{value:"video",children:"📱 Video tour (FaceTime/Zoom)"}),i.jsx(mn,{value:"either",children:"Either works for me"})]})]})]})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[i.jsxs("div",{children:[i.jsx(Mr,{htmlFor:"firstName",children:"First Name *"}),i.jsx(Dr,{id:"firstName",value:s,onChange:W=>o(W.target.value),required:!0})]}),i.jsxs("div",{children:[i.jsx(Mr,{htmlFor:"lastName",children:"Last Name"}),i.jsx(Dr,{id:"lastName",value:c,onChange:W=>a(W.target.value)})]})]}),i.jsxs("div",{children:[i.jsx(Mr,{htmlFor:"email",children:"Email *"}),i.jsx(Dr,{id:"email",type:"email",value:f,onChange:W=>p(W.target.value),required:!0})]}),i.jsxs("div",{children:[i.jsxs(Mr,{htmlFor:"phone",children:["Phone ",r==="showing"&&"*"]}),i.jsx(Dr,{id:"phone",type:"tel",value:y,onChange:W=>v(W.target.value),required:r==="showing"})]}),i.jsxs("div",{children:[i.jsx(Mr,{htmlFor:"message",children:r==="showing"?"Anything else?":"Message (optional)"}),i.jsx(Bu,{id:"message",value:S,onChange:W=>E(W.target.value),rows:2})]}),i.jsx(Dt,{type:"submit",disabled:V,className:"w-full bg-neutral-900 hover:bg-neutral-800 text-white h-11",children:V?"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 BXe=Object.freeze(Object.defineProperty({__proto__:null,default:LH,toVideoEmbedUrl:dbe},Symbol.toStringTag,{value:"Module"})),Sne="/assets/levelup-logo-white-C2RAgAoG.png",$Xe="/assets/listings-hero-noir-BHCJrhvU.jpg";var hbe={exports:{}};(function(t,e){(function(r,n){t.exports=n()})(nc,function(){let r,n,s;function o(a,f){if(!r)r=f;else if(!n)n=f;else{const p={};r(p),s=f(p);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,p=typeof Float32Array<"u"?Float32Array:Array;function y(h,l){var u=l[0],m=l[1],x=l[2],b=l[3],T=u*b-x*m;return T?(h[0]=b*(T=1/T),h[1]=-m*T,h[2]=-x*T,h[3]=u*T,h):null}function v(){var h=new p(9);return p!=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 S(h,l){var u=l[0],m=l[1],x=l[2],b=l[3],T=l[4],A=l[5],C=l[6],O=l[7],$=l[8];return h[0]=T*$-A*O,h[1]=x*O-m*$,h[2]=m*A-x*T,h[3]=A*C-b*$,h[4]=u*$-x*C,h[5]=x*b-u*A,h[6]=b*O-T*C,h[7]=m*C-u*O,h[8]=u*T-m*b,h}function E(h,l,u){var m=l[0],x=l[1],b=l[2],T=l[3],A=l[4],C=l[5],O=l[6],$=l[7],U=l[8],q=u[0],K=u[1],X=u[2],te=u[3],se=u[4],ae=u[5],he=u[6],ue=u[7],be=u[8];return h[0]=q*m+K*T+X*O,h[1]=q*x+K*A+X*$,h[2]=q*b+K*C+X*U,h[3]=te*m+se*T+ae*O,h[4]=te*x+se*A+ae*$,h[5]=te*b+se*C+ae*U,h[6]=he*m+ue*T+be*O,h[7]=he*x+ue*A+be*$,h[8]=he*b+ue*C+be*U,h}function k(){var h=new p(16);return p!=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 R(h){var l=new p(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 P(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],m=l[1],x=l[2],b=l[3],T=l[4],A=l[5],C=l[6],O=l[7],$=l[8],U=l[9],q=l[10],K=l[11],X=l[12],te=l[13],se=l[14],ae=l[15],he=u*A-m*T,ue=u*C-x*T,be=u*O-b*T,Ne=m*C-x*A,Ie=m*O-b*A,We=x*O-b*C,ze=$*te-U*X,He=$*se-q*X,Ue=$*ae-K*X,Ve=U*se-q*te,yt=U*ae-K*te,bt=q*ae-K*se,At=he*bt-ue*yt+be*Ve+Ne*Ue-Ie*He+We*ze;return At?(h[0]=(A*bt-C*yt+O*Ve)*(At=1/At),h[1]=(x*yt-m*bt-b*Ve)*At,h[2]=(te*We-se*Ie+ae*Ne)*At,h[3]=(q*Ie-U*We-K*Ne)*At,h[4]=(C*Ue-T*bt-O*He)*At,h[5]=(u*bt-x*Ue+b*He)*At,h[6]=(se*be-X*We-ae*ue)*At,h[7]=($*We-q*be+K*ue)*At,h[8]=(T*yt-A*Ue+O*ze)*At,h[9]=(m*Ue-u*yt-b*ze)*At,h[10]=(X*Ie-te*be+ae*he)*At,h[11]=(U*be-$*Ie-K*he)*At,h[12]=(A*He-T*Ve-C*ze)*At,h[13]=(u*Ve-m*He+x*ze)*At,h[14]=(te*ue-X*Ne-se*he)*At,h[15]=($*Ne-U*ue+q*he)*At,h):null}function D(h,l,u){var m=l[0],x=l[1],b=l[2],T=l[3],A=l[4],C=l[5],O=l[6],$=l[7],U=l[8],q=l[9],K=l[10],X=l[11],te=l[12],se=l[13],ae=l[14],he=l[15],ue=u[0],be=u[1],Ne=u[2],Ie=u[3];return h[0]=ue*m+be*A+Ne*U+Ie*te,h[1]=ue*x+be*C+Ne*q+Ie*se,h[2]=ue*b+be*O+Ne*K+Ie*ae,h[3]=ue*T+be*$+Ne*X+Ie*he,h[4]=(ue=u[4])*m+(be=u[5])*A+(Ne=u[6])*U+(Ie=u[7])*te,h[5]=ue*x+be*C+Ne*q+Ie*se,h[6]=ue*b+be*O+Ne*K+Ie*ae,h[7]=ue*T+be*$+Ne*X+Ie*he,h[8]=(ue=u[8])*m+(be=u[9])*A+(Ne=u[10])*U+(Ie=u[11])*te,h[9]=ue*x+be*C+Ne*q+Ie*se,h[10]=ue*b+be*O+Ne*K+Ie*ae,h[11]=ue*T+be*$+Ne*X+Ie*he,h[12]=(ue=u[12])*m+(be=u[13])*A+(Ne=u[14])*U+(Ie=u[15])*te,h[13]=ue*x+be*C+Ne*q+Ie*se,h[14]=ue*b+be*O+Ne*K+Ie*ae,h[15]=ue*T+be*$+Ne*X+Ie*he,h}function B(h,l,u){var m,x,b,T,A,C,O,$,U,q,K,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],A=l[4],C=l[5],O=l[6],$=l[7],U=l[8],q=l[9],K=l[10],X=l[11],h[0]=m=l[0],h[1]=x,h[2]=b,h[3]=T,h[4]=A,h[5]=C,h[6]=O,h[7]=$,h[8]=U,h[9]=q,h[10]=K,h[11]=X,h[12]=m*te+A*se+U*ae+l[12],h[13]=x*te+C*se+q*ae+l[13],h[14]=b*te+O*se+K*ae+l[14],h[15]=T*te+$*se+X*ae+l[15]),h}function V(h,l,u){var m=u[0],x=u[1],b=u[2];return h[0]=l[0]*m,h[1]=l[1]*m,h[2]=l[2]*m,h[3]=l[3]*m,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 G(h,l,u){var m=Math.sin(u),x=Math.cos(u),b=l[4],T=l[5],A=l[6],C=l[7],O=l[8],$=l[9],U=l[10],q=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*m,h[5]=T*x+$*m,h[6]=A*x+U*m,h[7]=C*x+q*m,h[8]=O*x-b*m,h[9]=$*x-T*m,h[10]=U*x-A*m,h[11]=q*x-C*m,h}function W(h,l,u){var m=Math.sin(u),x=Math.cos(u),b=l[0],T=l[1],A=l[2],C=l[3],O=l[8],$=l[9],U=l[10],q=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*m,h[1]=T*x-$*m,h[2]=A*x-U*m,h[3]=C*x-q*m,h[8]=b*m+O*x,h[9]=T*m+$*x,h[10]=A*m+U*x,h[11]=C*m+q*x,h}function Y(h,l,u){var m=Math.sin(u),x=Math.cos(u),b=l[0],T=l[1],A=l[2],C=l[3],O=l[4],$=l[5],U=l[6],q=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*m,h[1]=T*x+$*m,h[2]=A*x+U*m,h[3]=C*x+q*m,h[4]=O*x-b*m,h[5]=$*x-T*m,h[6]=U*x-A*m,h[7]=q*x-C*m,h}function J(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 Q(h,l,u){var m,x,b,T=u[0],A=u[1],C=u[2],O=Math.sqrt(T*T+A*A+C*C);return O0&&(b=1/Math.sqrt(b)),h[0]=l[0]*b,h[1]=l[1]*b,h[2]=l[2]*b,h}function Ct(h,l){return h[0]*l[0]+h[1]*l[1]+h[2]*l[2]}function tr(h,l,u){var m=l[0],x=l[1],b=l[2],T=u[0],A=u[1],C=u[2];return h[0]=x*C-b*A,h[1]=b*T-m*C,h[2]=m*A-x*T,h}function wt(h,l,u,m){var x=l[0],b=l[1],T=l[2];return h[0]=x+m*(u[0]-x),h[1]=b+m*(u[1]-b),h[2]=T+m*(u[2]-T),h}function lr(h,l,u){var m=l[0],x=l[1],b=l[2],T=u[3]*m+u[7]*x+u[11]*b+u[15];return h[0]=(u[0]*m+u[4]*x+u[8]*b+u[12])/(T=T||1),h[1]=(u[1]*m+u[5]*x+u[9]*b+u[13])/T,h[2]=(u[2]*m+u[6]*x+u[10]*b+u[14])/T,h}function Sr(h,l,u){var m=l[0],x=l[1],b=l[2];return h[0]=m*u[0]+x*u[3]+b*u[6],h[1]=m*u[1]+x*u[4]+b*u[7],h[2]=m*u[2]+x*u[5]+b*u[8],h}function sn(h,l,u){var m=u[0],x=u[1],b=u[2],T=u[3],A=l[0],C=l[1],O=l[2],$=x*O-b*C,U=b*A-m*O,q=m*C-x*A;return h[0]=A+T*($+=$)+x*(q+=q)-b*(U+=U),h[1]=C+T*U+b*$-m*q,h[2]=O+T*q+m*U-x*$,h}function cr(h){return h[0]=0,h[1]=0,h[2]=0,h}function yr(h,l){return h[0]===l[0]&&h[1]===l[1]&&h[2]===l[2]}var Pr=je,jn=_e,Je=Le;function St(){var h=new p(4);return p!=Float32Array&&(h[0]=0,h[1]=0,h[2]=0,h[3]=0),h}function Jt(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 Ir(h,l){var u=l[0],m=l[1],x=l[2],b=l[3],T=u*u+m*m+x*x+b*b;return T>0&&(T=1/Math.sqrt(T)),h[0]=u*T,h[1]=m*T,h[2]=x*T,h[3]=b*T,h}function ur(h,l){return h[0]*l[0]+h[1]*l[1]+h[2]*l[2]+h[3]*l[3]}function ar(h,l,u){var m=l[0],x=l[1],b=l[2],T=l[3];return h[0]=u[0]*m+u[4]*x+u[8]*b+u[12]*T,h[1]=u[1]*m+u[5]*x+u[9]*b+u[13]*T,h[2]=u[2]*m+u[6]*x+u[10]*b+u[14]*T,h[3]=u[3]*m+u[7]*x+u[11]*b+u[15]*T,h}function It(){var h=new p(4);return p!=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 Tn(h,l,u){u*=.5;var m=l[0],x=l[1],b=l[2],T=l[3],A=Math.sin(u),C=Math.cos(u);return h[0]=m*C+T*A,h[1]=x*C+b*A,h[2]=b*C-x*A,h[3]=T*C-m*A,h}function ss(h,l,u){u*=.5;var m=l[0],x=l[1],b=l[2],T=l[3],A=Math.sin(u),C=Math.cos(u);return h[0]=m*C-b*A,h[1]=x*C+T*A,h[2]=b*C+m*A,h[3]=T*C-x*A,h}Te(),St();var is,Us,Ea,vs=Ir,ua=(is=Te(),Us=ke(1,0,0),Ea=ke(0,1,0),function(h,l,u){var m=Ct(l,u);return m<-.999999?(tr(is,Us,l),Je(is)<1e-6&&tr(is,Ea,l),pt(is,is),function(x,b,T){T*=.5;var A=Math.sin(T);x[0]=A*b[0],x[1]=A*b[1],x[2]=A*b[2],x[3]=Math.cos(T)}(h,is,Math.PI),h):m>.999999?(h[0]=0,h[1]=0,h[2]=0,h[3]=1,h):(tr(is,l,u),h[0]=is[0],h[1]=is[1],h[2]=is[2],h[3]=1+m,vs(h,h))});function Nr(){var h=new p(2);return p!=Float32Array&&(h[0]=0,h[1]=0),h}function qn(h,l){var u=new p(2);return u[0]=h,u[1]=l,u}function Yi(h,l,u){return h[0]=l,h[1]=u,h}function ja(h,l,u){return h[0]=l[0]+u[0],h[1]=l[1]+u[1],h}function So(h,l,u){return h[0]=l[0]-u[0],h[1]=l[1]-u[1],h}function Zr(h,l,u){return h[0]=l[0]*u,h[1]=l[1]*u,h}function fn(h){var l=h[0],u=h[1];return Math.sqrt(l*l+u*u)}function xn(h,l){var u=l[0],m=l[1],x=u*u+m*m;return x>0&&(x=1/Math.sqrt(x)),h[0]=l[0]*x,h[1]=l[1]*x,h}function Xr(h,l){return h[0]*l[0]+h[1]*l[1]}It(),It(),v();var ds,en,Fn=So;function ti(h){return h&&h.__esModule&&Object.prototype.hasOwnProperty.call(h,"default")?h.default:h}Nr();var bl=function(){if(en)return ds;function h(l,u,m,x){this.cx=3*l,this.bx=3*(m-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=m,this.p2y=x}return en=1,ds=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 m=l,x=0;x<8;x++){var b=this.sampleCurveX(m)-l;if(Math.abs(b)b?A=m:C=m,m=.5*(C-A)+A;return m},solve:function(l,u){return this.sampleCurveY(this.solveCurveX(l,u))}},ds}(),el=ti(bl);function Ft(h,l){this.x=h,this.y=l}function Bo(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 ut(h,l,u,m){const x=new el(h,l,u,m);return function(b){return x.solve(b)}}const de=ut(.25,.1,.25,1);function fe(h,l,u){return Math.min(u,Math.max(l,h))}function Oe(h,l,u){return(u=fe((u-h)/(l-h),0,1))*u*(3-2*u)}function Ye(h,l,u){const m=u-l,x=((h-l)%m+m)%m+l;return x===l?u:x}function et(h,l,u){if(!h.length)return u(null,[]);let m=h.length;const x=new Array(h.length);let b=null;h.forEach((T,A)=>{l(T,(C,O)=>{C&&(b=C),x[A]=O,--m===0&&u(b,x)})})}let rt=1;function dt(){return rt++}function it(h){return h<=1?1:Math.pow(2,Math.ceil(Math.log2(h)))}function ht(h,l){h.forEach(u=>{l[u]&&(l[u]=l[u].bind(l))})}function Ut(h,l,u){const m={};for(const x in h)m[x]=l.call(this,h[x],x,h);return m}function Rt(h,l,u){const m={};for(const x in h)l.call(this,h[x],x,h)&&(m[x]=h[x]);return m}function dr(h){return Array.isArray(h)?h.map(dr):typeof h=="object"&&h?Ut(h,dr):h}function Br(h,l){for(let u=0;u=0)return!0;return!1}const Gr={};function $r(h){Gr[h]||(typeof console<"u"&&console.warn(h),Gr[h]=!0)}function on(h,l,u){return(u.y-h.y)*(l.x-h.x)>(l.y-h.y)*(u.x-h.x)}function Nn(h){let l=0;for(let u,m,x=0,b=h.length,T=b-1;x@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(u,m,x,b)=>{const T=x||b;return l[m]=!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 Ii,yi=null;function bs(h,l){return[h[4*l],h[4*l+1],h[4*l+2],h[4*l+3]]}function ai(h,l,u,m){for(;l>1;h[x]>1;h[x]<=m?l=x+1:u=x}return l}function Ds(h){return h>0?1/(1.001-h):1+h}function oi(h){return h>0?1-1/(1.001-h):-h}function xi(h,l,u){return(h-l.min)*(u.max-u.min)/(l.max-l.min)+u.min}const Dn={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(!Dn.API_URL)return null;try{const h=new URL(Dn.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 Aa(){return new URL(Dn.DRACO_URL,Dn.API_URL).href}function To(){if(typeof WebAssembly!="object")throw new Error("WebAssembly not supported, cannot instantiate meshoptimizer");return new URL(function(){if(Ii===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]);Ii=WebAssembly.validate(h)}return Ii}()?Dn.MESHOPT_SIMD_URL:Dn.MESHOPT_URL,Dn.API_URL).href}function po(){return new URL(Dn.BUILDING_GEN_URL,Dn.API_URL).href}function cc(h){return Dn.API_URL_REGEX.test(h)}function uc(h){return Dn.API_SPRITE_REGEX.test(h)}let Nd,wl,dc,Cd,Nc,Id;function hu(){return Nd==null&&(Nd=self.OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&typeof self.createImageBitmap=="function"),Nd}const Ul={now:()=>Cd!==void 0?Cd:performance.now(),setNow(h){Cd=h},restoreNow(){Cd=void 0},frame(h){const l=requestAnimationFrame(h);return{cancel:()=>cancelAnimationFrame(l)}},getImageData(h,l=0){const{width:u,height:m}=h;Nc||(Nc=document.createElement("canvas"));const x=Nc.getContext("2d",{willReadFrequently:!0});if(!x)throw new Error("failed to create canvas 2d context");return(u>Nc.width||m>Nc.height)&&(Nc.width=u,Nc.height=m),x.clearRect(-l,-l,u+2*l,m+2*l),x.drawImage(h,0,0,u,m),x.getImageData(-l,-l,u+2*l,m+2*l)},resolveURL:h=>(wl||(wl=document.createElement("a")),wl.href=h,wl.href),get devicePixelRatio(){return window.devicePixelRatio},get prefersReducedMotion(){return!!window.matchMedia&&(dc==null&&(dc=window.matchMedia("(prefers-reduced-motion: reduce)")),dc.matches)},hasCanvasFingerprintNoise(){if(Id!==void 0)return Id;if(!hu())return Id=!1,!1;const h=new OffscreenCanvas(85,1),l=h.getContext("2d",{willReadFrequently:!0});let u=0;for(let x=0;x0?`?${b}`:""}`}const Hm="mapbox-tiles";let $_=500,z_=50;const HT=["language","worldview","jobid"];let Pd;function _C(){try{return caches}catch{}}function U_(){const h=_C();h&&Pd==null&&(Pd=h.open(Hm))}let WT=1/0;const V_={supported:!1,testSupport:function(h){!KT&&Ag&&(fu?kg(h):Wm=h)}};let Wm,Ag,KT=!1,fu=!1;const YT=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,Ag),h.isContextLost())return;V_.supported=!0}catch{}h.deleteTexture(l),KT=!0}YT.document&&(Ag=YT.document.createElement("img"),Ag.onload=function(){Wm&&kg(Wm),Wm=null,fu=!0},Ag.onerror=function(){KT=!0,Wm=null},Ag.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const r0={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Iconset:"Iconset",Image:"Image",Model:"Model"};Object.freeze(r0);class ZT extends Error{constructor(l,u,m){u===401&&cc(m)&&(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=m}toString(){return`${this.name}: ${this.message} (${this.status}): ${this.url}`}}function XT(h){return typeof h=="object"&&h!==null&&"status"in h&&h.status===404}const es=Ms()?()=>self.worker.referrer:()=>(location.protocol==="blob:"?parent:self).location.href,Ng=function(h,l){return/^file:/.test(u=h.url)||/^file:/.test(es())&&!/^\w+:/.test(u)?function(m,x){const b=new XMLHttpRequest;b.open(m.method||"GET",m.url,!0),m.type==="arrayBuffer"&&(b.responseType="arraybuffer");for(const T in m.headers)b.setRequestHeader(T,m.headers[T]);return m.type==="json"&&(b.responseType="text",b.setRequestHeader("Accept","application/json")),b.withCredentials=m.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(m.type==="json")try{T=JSON.parse(b.response)}catch(C){return x(C)}const A=new Headers;b.getAllResponseHeaders().trim().split(/[\r\n]+/).forEach(C=>{const O=C.split(": "),$=O.shift(),U=O.join(": ");A.append($,U)}),x(null,T,A)}else x(new ZT(b.statusText,b.status,m.url))},b.send(m.body),{cancel:()=>b.abort()}}(h,l):function(m,x){const b=new AbortController,T=new Request(m.url,{method:m.method||"GET",body:m.body,credentials:m.credentials,headers:m.headers,referrer:es(),referrerPolicy:m.referrerPolicy,signal:b.signal});let A=!1,C=!1;const O=($=T.url).indexOf("sku=")>0&&cc($);var $;m.type==="json"&&T.headers.set("Accept","application/json");const U=(K,X,te)=>{if(C)return;if(K&&K.message!=="SecurityError"&&$r(K.toString()),X&&te)return q(X);const se=Date.now();fetch(T).then(ae=>{if(ae.ok){const he=O?ae.clone():null;return q(ae,he,se)}return x(new ZT(ae.statusText,ae.status,m.url))}).catch(ae=>{ae.name!=="AbortError"&&x(new Error(`${ae.message} ${m.url}`))})},q=(K,X,te)=>{(m.type==="arrayBuffer"?K.arrayBuffer():m.type==="json"?K.json():K.text()).then(se=>{C||(X&&te&&function(ae,he,ue){if(U_(),Pd==null)return;const be=Fi(he.headers.get("cache-control")||"");if(be["no-store"])return;const Ne={status:he.status,statusText:he.statusText,headers:new Headers};he.headers.forEach((Ue,Ve)=>Ne.headers.set(Ve,Ue)),be["max-age"]&&Ne.headers.set("Expires",new Date(ue+1e3*be["max-age"]).toUTCString());const Ie=Ne.headers.get("expires");if(!Ie||new Date(Ie).getTime()-ue<42e4)return;let We=GT(ae.url,{persistentParams:HT});if(he.status===206){const Ue=ae.headers.get("Range");if(!Ue)return;Ne.status=200,We=t0(We,{range:Ue})}const ze=new Response((He=he.status)!==200&&He!==404&&[101,103,204,205,304].includes(He)?null:he.body,Ne);var He;U_(),Pd!=null&&Pd.then(Ue=>Ue.put(We,ze)).catch(Ue=>$r(Ue.message))}(T,X,te),A=!0,x(null,se,K.headers))}).catch(se=>{C||x(new Error(se.message))})};return O?function(K,X){if(U_(),Pd==null)return X(null);Pd.then(te=>{let se=GT(K.url,{persistentParams:HT});const ae=K.headers.get("Range");ae&&(se=t0(se,{range:ae})),te.match(se).then(he=>{const ue=function(be){if(!be)return!1;const Ne=new Date(be.headers.get("expires")||0),Ie=Fi(be.headers.get("cache-control")||"");return Number(Ne)>Date.now()&&!Ie["no-cache"]}(he);te.delete(se).catch(X),ue&&te.put(se,he.clone()).catch(X),X(null,he,ue)}).catch(X)}).catch(X)}(T,U):U(null,null),{cancel:()=>{C=!0,A||b.abort()}}}(h,l);var u},Cg=function(h,l){return Ng(Object.assign(h,{type:"arrayBuffer"}),l)};function R4(h){const l=document.createElement("a");return l.href=h,l.protocol===location.protocol&&l.host===location.host}let q_,Af;q_=[],Af=0;const Ig=function(h,l){if(V_.supported&&(h.headers||(h.headers={}),h.headers.accept="image/webp,*/*"),Af>=Dn.MAX_PARALLEL_IMAGE_REQUESTS){const b={requestParameters:h,callback:l,cancelled:!1,cancel(){this.cancelled=!0}};return q_.push(b),b}Af++;let u=!1;const m=()=>{if(!u)for(u=!0,Af--;q_.length&&Af{m(),b?l(b):T&&function(C,O){const $=new Blob([new Uint8Array(C)],{type:"image/png"});createImageBitmap($).then(U=>{O(null,U)}).catch(U=>{O(new Error(`Could not load image because of ${U.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`))})}(T,(C,O)=>l(C,O,A))});return{cancel:()=>{x.cancel(),m()}}};var n0,G_,bC,Km={exports:{}},wC={exports:{}},QT={exports:{}},L4=function(){if(bC)return Km.exports;bC=1;var h=(n0||(n0=1,wC.exports=function(u,m){var x,b,T,A,C,O,$,U;for(b=u.length-(x=3&u.length),T=m,C=3432918353,O=461845907,U=0;U>>16)*C&65535)<<16)&4294967295)<<15|$>>>17))*O+((($>>>16)*O&65535)<<16)&4294967295)<<13|T>>>19))+((5*(T>>>16)&65535)<<16)&4294967295))+(((A>>>16)+58964&65535)<<16);switch($=0,x){case 3:$^=(255&u.charCodeAt(U+2))<<16;case 2:$^=(255&u.charCodeAt(U+1))<<8;case 1:T^=$=(65535&($=($=(65535&($^=255&u.charCodeAt(U)))*C+((($>>>16)*C&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}),wC.exports),l=(G_||(G_=1,QT.exports=function(u,m){for(var x,b=u.length,T=m^b,A=0;b>=4;)x=1540483477*(65535&(x=255&u.charCodeAt(A)|(255&u.charCodeAt(++A))<<8|(255&u.charCodeAt(++A))<<16|(255&u.charCodeAt(++A))<<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,++A;switch(b){case 3:T^=(255&u.charCodeAt(A+2))<<16;case 2:T^=(255&u.charCodeAt(A+1))<<8;case 1:T=1540483477*(65535&(T^=255&u.charCodeAt(A)))+((1540483477*(T>>>16)&65535)<<16)}return T=1540483477*(65535&(T^=T>>>13))+((1540483477*(T>>>16)&65535)<<16),(T^=T>>>15)>>>0}),QT.exports);return Km.exports=h,Km.exports.murmur3=h,Km.exports.murmur2=l,Km.exports}(),kf=ti(L4);class qu{constructor(l,...u){Object.assign(this,u[0]||{}),this.type=l}}class Pg extends qu{constructor(l,u={}){super("error",Object.assign({error:l},u))}}function mu(h,l,u){u[h]&&u[h].indexOf(l)!==-1||(u[h]=u[h]||[],u[h].push(l))}function H_(h,l,u){if(u&&u[h]){const m=u[h].indexOf(l);m!==-1&&u[h].splice(m,1)}}class s0{on(l,u){return this._listeners=this._listeners||{},mu(l,u,this._listeners),this}off(l,u){return H_(l,u,this._listeners),H_(l,u,this._oneTimeListeners),this}once(l,u){return u?(this._oneTimeListeners=this._oneTimeListeners||{},mu(l,u,this._oneTimeListeners),this):new Promise(m=>{this.once(l,m)})}fire(l,u){const m=typeof l=="string"?new qu(l,u):l,x=m.type;if(this.listens(x)){m.target=this;const b=this._listeners&&this._listeners[x]?this._listeners[x].slice():[];for(const C of b)C.call(this,m);const T=this._oneTimeListeners&&this._oneTimeListeners[x]?this._oneTimeListeners[x].slice():[];for(const C of T)H_(x,C,this._oneTimeListeners),C.call(this,m);const A=this._eventedParent;if(A){const C=typeof this._eventedParentData=="function"?this._eventedParentData():this._eventedParentData;Object.assign(m,C),A.fire(m)}}else m instanceof Pg&&console.error(m.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 hc{constructor(l){typeof l=="string"?this.name=l:(this.name=l.name,this.iconsetId=l.iconsetId)}static from(l){return new hc(l)}static toString(l){return l.iconsetId?`${l.name}${l.iconsetId}`:l.name}static parse(l){const[u,m]=l.split("");return new hc({name:u,iconsetId:m})}static isEqual(l,u){return l.name===u.name&&l.iconsetId===u.iconsetId}toString(){return hc.toString(this)}serialize(){return{name:this.name,iconsetId:this.iconsetId}}}var JT,W_={},eE=function(){if(JT)return W_;JT=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 m(b){return(T=b[b.length-1]==="%"?parseFloat(b)/100:parseFloat(b))<0?0:T>1?1:T;var T}function x(b,T,A){return A<0?A+=1:A>1&&(A-=1),6*A<1?b+(T-b)*A*6:2*A<1?T:3*A<2?b+(T-b)*(2/3-A)*6:b}try{W_.parseCSSColor=function(b){var T,A=b.replace(/ /g,"").toLowerCase();if(A in h)return h[A].slice();if(A[0]==="#")return A.length===4?(T=parseInt(A.substr(1),16))>=0&&T<=4095?[(3840&T)>>4|(3840&T)>>8,240&T|(240&T)>>4,15&T|(15&T)<<4,1]:null:A.length===7&&(T=parseInt(A.substr(1),16))>=0&&T<=16777215?[(16711680&T)>>16,(65280&T)>>8,255&T,1]:null;var C=A.indexOf("("),O=A.indexOf(")");if(C!==-1&&O+1===A.length){var $=A.substr(0,C),U=A.substr(C+1,O-(C+1)).split(","),q=1;switch($){case"rgba":if(U.length!==4)return null;q=m(U.pop());case"rgb":return U.length!==3?null:[u(U[0]),u(U[1]),u(U[2]),q];case"hsla":if(U.length!==4)return null;q=m(U.pop());case"hsl":if(U.length!==3)return null;var K=(parseFloat(U[0])%360+360)%360/360,X=m(U[1]),te=m(U[2]),se=te<=.5?te*(X+1):te+X-te*X,ae=2*te-se;return[l(255*x(ae,se,K+1/3)),l(255*x(ae,se,K)),l(255*x(ae,se,K-1/3)),q];default:return null}}return null}}catch{}return W_}();class Qn{constructor(l,u,m,x=1){this.r=l,this.g=u,this.b=m,this.a=x}static parse(l){if(!l)return;if(l instanceof Qn)return l;if(typeof l!="string")return;const u=eE.parseCSSColor(l);return u?new Qn(u[0]/255,u[1]/255,u[2]/255,u[3]):void 0}toString(){const[l,u,m,x]=[this.r,this.g,this.b,this.a];return`rgba(${Math.round(255*l)},${Math.round(255*u)},${Math.round(255*m)},${x})`}toNonPremultipliedRenderColor(l){const{r:u,g:m,b:x,a:b}=this;return new K_(l,u,m,x,b)}toPremultipliedRenderColor(l){const{r:u,g:m,b:x,a:b}=this;return new Rg(l,u*b,m*b,x*b,b)}clone(){return new Qn(this.r,this.g,this.b,this.a)}}class tE{constructor(l,u,m,x,b,T=!1){if(this.premultiplied=!1,this.premultiplied=T,l){const A=l.image.height,C=A*A;this.premultiplied?(u=b===0?0:u/b*(A-1),m=b===0?0:m/b*(A-1),x=b===0?0:x/b*(A-1)):(u*=A-1,m*=A-1,x*=A-1),u=Math.max(0,Math.min(A-1,u)),m=Math.max(0,Math.min(A-1,m)),x=Math.max(0,Math.min(A-1,x));const O=Math.floor(u),$=Math.floor(m),U=Math.floor(x),q=Math.ceil(u),K=Math.ceil(m),X=Math.ceil(x),te=u-O,se=m-$,ae=x-U,he=l.image.data,ue=4*(O+$*C+U*A),be=4*(O+$*C+X*A),Ne=4*(O+K*C+U*A),Ie=4*(O+K*C+X*A),We=4*(q+$*C+U*A),ze=4*(q+$*C+X*A),He=4*(q+K*C+U*A),Ue=4*(q+K*C+X*A);this.r=Qr(Qr(Qr(he[ue],he[be],ae),Qr(he[Ne],he[Ie],ae),se),Qr(Qr(he[We],he[ze],ae),Qr(he[He],he[Ue],ae),se),te)/255*(this.premultiplied?b:1),this.g=Qr(Qr(Qr(he[ue+1],he[be+1],ae),Qr(he[Ne+1],he[Ie+1],ae),se),Qr(Qr(he[We+1],he[ze+1],ae),Qr(he[He+1],he[Ue+1],ae),se),te)/255*(this.premultiplied?b:1),this.b=Qr(Qr(Qr(he[ue+2],he[be+2],ae),Qr(he[Ne+2],he[Ie+2],ae),se),Qr(Qr(he[We+2],he[ze+2],ae),Qr(he[He+2],he[Ue+2],ae),se),te)/255*(this.premultiplied?b:1),this.a=b}else this.r=u,this.g=m,this.b=x,this.a=b}toArray(){const{r:l,g:u,b:m,a:x}=this;return[255*l,255*u,255*m,x]}toHslaArray(){let{r:l,g:u,b:m,a:x}=this;if(this.premultiplied){if(x===0)return[0,0,0,0];const X=1/x;l*=X,u*=X,m*=X}const b=Math.min(Math.max(l,0),1),T=Math.min(Math.max(u,0),1),A=Math.min(Math.max(m,0),1),C=Math.min(b,T,A),O=Math.max(b,T,A),$=O-C,U=.5*(C+O);if($===0)return[0,0,100*U,x];const q=U>.5?$/(2-O-C):$/(O+C);let K;switch(O){case b:K=60*((T-A)/$+(TQr(m,l[x],u))}Qn.black=new Qn(0,0,0,1),Qn.white=new Qn(1,1,1,1),Qn.transparent=new Qn(0,0,0,0),Qn.red=new Qn(1,0,0,1),Qn.blue=new Qn(0,0,1,1);var Y_=Object.freeze({__proto__:null,array:Gu,color:function(h,l,u){return new Qn(Qr(h.r,l.r,u),Qr(h.g,l.g,u),Qr(h.b,l.b,u),Qr(h.a,l.a,u))},number:Qr});class pu extends Error{constructor(l,u){super(u),this.message=u,this.key=l}}class Ym{constructor(l,u=[]){this.parent=l,this.bindings={};for(const[m,x]of u)this.bindings[m]=x}concat(l){return new Ym(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 Sh={kind:"null"},Or={kind:"number"},hs={kind:"string"},ps={kind:"boolean"},Sl={kind:"color"},Nf={kind:"object"},gs={kind:"value"},Zm={kind:"collator"},i0={kind:"formatted"},a0={kind:"resolvedImage"};function tl(h,l){return{kind:"array",itemType:h,N:l}}function ha(h){if(h.kind==="array"){const l=ha(h.itemType);return typeof h.N=="number"?`array<${l}, ${h.N}>`:h.itemType.kind==="value"?"array":`array<${l}>`}return h.kind}const M4=[Sh,Or,hs,ps,Sl,i0,Nf,tl(gs),a0];function o0(h,l){if(l.kind==="error")return null;if(h.kind==="array"){if(l.kind==="array"&&(l.N===0&&l.itemType.kind==="value"||!o0(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 M4)if(!o0(u,l))return null}}return`Expected ${ha(h)} but found ${ha(l)} instead.`}function rE(h,l){return l.some(u=>u.kind===h.kind)}function Lg(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 Th(h,l){return h.kind==="array"&&l.kind==="array"?h.N===l.N&&Th(h.itemType,l.itemType):h.kind===l.kind}class nE{constructor(l,u,m){this.sensitivity=l?u?"variant":"case":u?"accent":"base",this.locale=m,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 l0{constructor(l,u,m,x,b){this.text=l.normalize?l.normalize():l,this.image=u,this.scale=m,this.fontStack=x,this.textColor=b}}class $o{constructor(l){this.sections=l}static fromString(l){return new $o([new l0(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 $o?l:$o.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 m={};u.fontStack&&(m["text-font"]=["literal",u.fontStack.split(",")]),u.scale&&(m["font-scale"]=u.scale),u.textColor&&(m["text-color"]=["rgba"].concat(u.textColor.toNonPremultipliedRenderColor(null).toArray())),l.push(m)}return l}}class gu{constructor(l,u={}){this.id=hc.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,m,x,b;try{({id:u,params:m,sx:x,sy:b}=JSON.parse(l)||{})}catch{return null}return u?new gu(u,{params:m,sx:x,sy:b}):null}scaleSelf(l,u=l){return this.sx*=l,this.sy*=u,this}}class Vl{constructor(l,u,m,x,b=!1){this.primaryId=hc.from(l),this.primaryOptions=u,m&&(this.secondaryId=hc.from(m)),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 gu(this.primaryId,this.primaryOptions)}hasSecondary(){return!!this.secondaryId}getSecondary(){return this.secondaryId?new gu(this.secondaryId,this.secondaryOptions):null}static from(l){return typeof l=="string"?Vl.build({name:l}):l}static build(l,u,m,x){return!l||typeof l=="object"&&!("name"in l)?null:new Vl(l,m,u,x)}}function SC(h,l,u,m){return typeof h=="number"&&h>=0&&h<=255&&typeof l=="number"&&l>=0&&l<=255&&typeof u=="number"&&u>=0&&u<=255?m===void 0||typeof m=="number"&&m>=0&&m<=1?null:`Invalid rgba value [${[h,l,u,m].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${(typeof m=="number"?[h,l,u,m]:[h,l,u]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function Mg(h){if(h===null||typeof h=="string"||typeof h=="boolean"||typeof h=="number"||h instanceof Qn||h instanceof nE||h instanceof $o||h instanceof Vl)return!0;if(Array.isArray(h)){for(const l of h)if(!Mg(l))return!1;return!0}if(typeof h=="object"){for(const l in h)if(!Mg(h[l]))return!1;return!0}return!1}function Pi(h){if(h===null)return Sh;if(typeof h=="string")return hs;if(typeof h=="boolean")return ps;if(typeof h=="number")return Or;if(h instanceof Qn)return Sl;if(h instanceof nE)return Zm;if(h instanceof $o)return i0;if(h instanceof Vl)return a0;if(Array.isArray(h)){const l=h.length;let u;for(const m of h){const x=Pi(m);if(u){if(u===x)continue;u=gs;break}u=x}return tl(u||gs,l)}return Nf}function Yr(h){const l=typeof h;return h===null?"":l==="string"||l==="number"||l==="boolean"?String(h):h instanceof $o||h instanceof Vl||h instanceof Qn?h.toString():JSON.stringify(h)}class Cr{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(!Mg(l[1]))return u.error("invalid value");const m=l[1];let x=Pi(m);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 Cr(x,m)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}serialize(){return this.type.kind==="array"||this.type.kind==="object"?["literal",this.value]:this.value instanceof Qn?["rgba"].concat(this.value.toNonPremultipliedRenderColor(null).toArray()):this.value instanceof $o?this.value.serialize():this.value}}class ta{constructor(l){this.name="ExpressionEvaluationError",this.message=l}toJSON(){return this.message}}const Jr={string:hs,number:Or,boolean:ps,object:Nf};class Cc{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 m,x=1;const b=l[0];if(b==="array"){let A,C;if(l.length>2){const O=l[1];if(typeof O!="string"||!(O in Jr)||O==="object")return u.error('The item type argument of "array" must be one of string, number, boolean',1);A=Jr[O],x++}else A=gs;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);C=l[2],x++}m=tl(A,C)}else m=Jr[b];const T=[];for(;xl.outputDefined())}serialize(){const l=this.type,u=[l.kind];if(l.kind==="array"){const m=l.itemType;if(m.kind==="string"||m.kind==="number"||m.kind==="boolean"){u.push(m.kind);const x=l.N;(typeof x=="number"||this.args.length>1)&&u.push(x)}}return u.concat(this.args.map(m=>m.serialize()))}}class Xm{constructor(l){this.type=i0,this.sections=l}static parse(l,u){if(l.length<2)return u.error("Expected at least one argument.");const m=l[1];if(!Array.isArray(m)&&typeof m=="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 A=l[T];if(b&&typeof A=="object"&&!Array.isArray(A)){b=!1;let C=null;if(A["font-scale"]&&(C=u.parseObjectValue(A["font-scale"],T,"font-scale",Or),!C))return null;let O=null;if(A["text-font"]&&(O=u.parseObjectValue(A["text-font"],T,"text-font",tl(hs)),!O))return null;let $=null;if(A["text-color"]&&($=u.parseObjectValue(A["text-color"],T,"text-color",Sl),!$))return null;const U=x[x.length-1];U.scale=C,U.font=O,U.textColor=$}else{const C=u.parse(l[T],T,gs);if(!C)return null;const O=C.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:C,scale:null,font:null,textColor:null})}}return new Xm(x)}evaluate(l){return new $o(this.sections.map(u=>{const m=u.content.evaluate(l);return Th(Pi(m),a0)?new l0("",m,null,null,null):new l0(Yr(m),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 m={};u.scale&&(m["font-scale"]=u.scale.serialize()),u.font&&(m["text-font"]=u.font.serialize()),u.textColor&&(m["text-color"]=u.textColor.serialize()),l.push(m)}return l}}class Hr{constructor(l,u,m,x){this._imageWarnHistory={},this.type=a0,this.namePrimary=l,this.nameSecondary=u,m&&(this.paramsPrimary=m.params,this.iconsetIdPrimary=m.iconset?m.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 m=1;const x=[];function b(){if(mhc.isEqual(T,b)),x.available){const T=x.getSecondary()?x.getSecondary().id:null;T&&(x.available=l.availableImages.some(A=>hc.isEqual(A,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 m={};if(u&&(m.iconset={id:u}),l){m.params={};for(const x in l)l[x]&&(m.params[x]=l[x].serialize())}return Object.keys(m).length>0?m: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 c0(h){return X_(h)?"string":u0(h)?"number":d0(h)?"boolean":Array.isArray(h)?"array":h===null?"null":Z_(h)?"object":typeof h}function Z_(h){return h!=null&&!Array.isArray(h)&&typeof h!="function"&&!(h instanceof String||h instanceof Number||h instanceof Boolean)&&typeof h=="object"}function X_(h){return typeof h=="string"||h instanceof String}function u0(h){return typeof h=="number"||h instanceof Number}function d0(h){return typeof h=="boolean"||h instanceof Boolean}const D4={"to-boolean":ps,"to-color":Sl,"to-number":Or,"to-string":hs};class Hu{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 m=l[0],x=[];let b=Sh;if(m==="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=tl(u.expectedType.itemType,T)}else{if(!(T>0&&Mg(l[1][0])))return null;b=tl(Pi(l[1][0]),T)}for(let A=0;A4?`Invalid rbga value ${JSON.stringify(u)}: expected an array containing either three or four numeric values.`:SC(u[0],u[1],u[2],u[3]),!m))return new Qn(u[0]/255,u[1]/255,u[2]/255,u[3])}throw new ta(m||`Could not parse color from value '${typeof u=="string"?u:String(JSON.stringify(u))}'`)}if(this.type.kind==="number"){let u=null;for(const m of this.args){if(u=m.evaluate(l),u===null)return 0;const x=Number(u);if(!isNaN(x))return x}throw new ta(`Could not convert ${JSON.stringify(u)} to number.`)}return this.type.kind==="formatted"?$o.fromString(Yr(this.args[0].evaluate(l))):this.type.kind==="resolvedImage"?Vl.build(Yr(this.args[0].evaluate(l))):this.type.kind==="array"?this.args.map(u=>u.evaluate(l)):Yr(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 Xm([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if(this.type.kind==="resolvedImage")return new Hr(this.args[0]).serialize();const l=this.type.kind==="array"?[]:[`to-${this.type.kind}`];return this.eachChild(u=>{l.push(u.serialize())}),l}}const Qm=["Unknown","Point","LineString","Polygon"];class h0{constructor(l,u,m){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=m}id(){return this.feature&&this.feature.id!==void 0?this.feature.id:null}geometryType(){return this.feature?typeof this.feature.type=="number"?Qm[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:m,y:x}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(m*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]=Qn.parse(l)),u}getConfig(l){return this.options?this.options.get(l):null}}class Ba{constructor(l,u,m,x,b){this.name=l,this.type=u,this._evaluate=m,this.args=x,this._overloadIndex=b}evaluate(l){if(!this._evaluate){const u=Ba.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 m=l[0],x=Ba.definitions[m];if(!x)return u.error(`Unknown expression "${m}". 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,A=[];let C=null,O=-1;for(const[$,U]of T){if(Array.isArray($)&&$.length!==l.length-1)continue;A.push($),O++,C=new ib(u.registry,u.path,null,u.scope,void 0,u._scope,u.options,u.iconImageUseTheme);const q=[];let K=!1;for(let X=1;Xq)).map(Cf).join(" | "),U=[];for(let q=1;qu;){if(m-u>600){const C=m-u+1,O=l-u+1,$=Math.log(C),U=.5*Math.exp(2*$/3),q=.5*Math.sqrt($*U*(C-U)/C)*(O-C/2<0?-1:1);TC(h,l,Math.max(u,Math.floor(l-O*U/C+q)),Math.min(m,Math.floor(l+(C-O)*U/C+q)),x)}const b=h[l];let T=u,A=m;for(f0(h,u,l),x(h[m],b)>0&&f0(h,u,m);T0;)A--}x(h[u],b)===0?f0(h,u,A):(A++,f0(h,A,m)),A<=l&&(u=A+1),l<=A&&(m=A-1)}}function f0(h,l,u){const m=h[l];h[l]=h[u],h[u]=m}function J_(h,l){return hl?1:0}function EC(h){let l=0;for(let u,m,x=0,b=h.length,T=b-1;x=l[2]||h[1]<=l[1]||h[3]>=l[3])}function O4(h,l,u){const m=h[0]-l[0],x=h[1]-l[1],b=h[0]-u[0],T=h[1]-u[1];return m*T-b*x===0&&m*b<=0&&x*T<=0}function sE(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 Dg(h,l,u=!1){let m=!1;for(let x=0,b=l.length;x0&&A<0||T<0&&A>0}function p0(h,l,u,m){return(x=[m[0]-u[0],m[1]-u[1]])[0]*(b=[l[0]-h[0],l[1]-h[1]])[1]-x[1]*b[0]!==0&&!(!jC(h,l,u,m)||!jC(u,m,h,l));var x,b}function iE(h){const l=new Ft(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),u=new Ft(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY);for(const m of h[0])l.x>m.x&&(l.x=m.x),l.y>m.y&&(l.y=m.y),u.xu[2]){const x=.5*m;let b=h[0]-u[0]>x?-m:u[0]-h[0]>x?m:0;b===0&&(b=h[0]-u[2]>x?-m:u[2]-h[0]>x?m:0),h[0]+=b}Wu(l,h)}function lE(h,l,u,m){const x=Math.pow(2,m.z)*If,b=[m.x*If,m.y*If],T=[];if(!h)return T;for(const A of h)for(const C of A){const O=[C.x+b[0],C.y+b[1]];yu(O,l,u,x),T.push(O)}return T}function cE(h,l,u,m){const x=Math.pow(2,m.z)*If,b=[m.x*If,m.y*If],T=[];if(!h)return T;for(const C of h){const O=[];for(const $ of C){const U=[$.x+b[0],$.y+b[1]];Wu(l,U),O.push(U)}T.push(O)}if(l[2]-l[0]<=x/2){(A=l)[0]=A[1]=1/0,A[2]=A[3]=-1/0;for(const C of T)for(const O of C)yu(O,l,u,x)}var A;return T}class Pf{constructor(l,u){this.type=ps,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(Mg(l[1])){const m=l[1];if(m.type==="FeatureCollection")for(let x=0;xu)return tb(b,T,(u-(m-A))/A)}return l[l.length-1]}pointToSegmentDistance(l,u,m){let[x,b]=u,T=Ic(m[0]-x)*this.kx,A=(m[1]-b)*this.ky;if(T!==0||A!==0){const C=(Ic(l[0]-x)*this.kx*T+(l[1]-b)*this.ky*A)/(T*T+A*A);C>1?(x=m[0],b=m[1]):C>0&&(x+=T/this.kx*C,b+=A/this.ky*C)}return T=Ic(l[0]-x)*this.kx,A=(l[1]-b)*this.ky,Math.sqrt(T*T+A*A)}pointOnLine(l,u){let m=1/0,x=l[0][0],b=l[0][1],T=0,A=0;for(let C=0;C1?(O=l[C+1][0],$=l[C+1][1]):K>0&&(O+=U/this.kx*K,$+=q/this.ky*K)),U=Ic(u[0]-O)*this.kx,q=(u[1]-$)*this.ky;const X=U*U+q*q;Xb.index||x.index===b.index&&x.t>b.t){const O=x;x=b,b=O}const T=[x.point],A=x.index+1,C=b.index;!hE(m[A],T[0])&&A<=C&&T.push(m[A]);for(let O=A+1;O<=C;O++)T.push(m[O]);return hE(m[C],b.point)||T.push(b.point),T}lineSliceAlong(l,u,m){let x=0;const b=[];for(let T=0;Tl&&b.length===0&&b.push(tb(A,C,(l-(x-O))/O)),x>=u)return b.push(tb(A,C,(u-(x-O))/O)),b;x>l&&b.push(C)}return b}bufferPoint(l,u){const m=u/this.ky,x=u/this.kx;return[l[0]-x,l[1]-m,l[0]+x,l[1]+m]}bufferBBox(l,u){const m=u/this.ky,x=u/this.kx;return[l[0]-x,l[1]-m,l[2]+x,l[3]+m]}insideBBox(l,u){return Ic(l[0]-u[0])>=0&&Ic(l[0]-u[2])<=0&&l[1]>=u[1]&&l[1]<=u[3]}}function hE(h,l){return h[0]===l[0]&&h[1]===l[1]}function tb(h,l,u){const m=Ic(l[0]-h[0]);return[h[0]+m*u,h[1]+(l[1]-h[1])*u]}function Ic(h){for(;h<-180;)h+=360;for(;h>180;)h-=360;return h}class y0{constructor(l=[],u=(m,x)=>mx?1:0){if(this.data=l,this.length=this.data.length,this.compare=u,this.length>0)for(let m=(this.length>>1)-1;m>=0;m--)this._down(m)}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:m}=this,x=u[l];for(;l>0;){const b=l-1>>1,T=u[b];if(m(x,T)>=0)break;u[l]=T,l=b}u[l]=x}_down(l){const{data:u,compare:m}=this,x=this.length>>1,b=u[l];for(;l=0)break;u[l]=u[T],l=T}u[l]=b}}var or=8192;function kC(h,l){return l.dist-h.dist}function NC(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=ep(h);if(l){if(u===2)return[h,null];const m=Math.floor(u/2);return[[h[0],h[0]+m],[h[0]+m,h[1]]]}{if(u===1)return[h,null];const m=Math.floor(u/2)-1;return[[h[0],h[0]+m],[h[0]+m+1,h[1]]]}}function Rf(h,l){const u=[1/0,1/0,-1/0,-1/0];if(!Ku(l,h.length))return u;for(let m=l[0];m<=l[1];++m)Wu(u,h[m]);return u}function x0(h){const l=[1/0,1/0,-1/0,-1/0];for(let u=0;ul[2]&&(m=h[0]-l[2]),h[1]>l[3]&&(x=h[1]-l[3]),h[3]=m)return m;if(m0(x,b)){if(LC(h,l))return 0}else if(LC(l,h))return 0;let T=m;for(const A of h)for(let C=0,O=A.length,$=O-1;C=b)continue;const $=O.range1;if(ep($)<=A){if(!Ku($,h.length))return NaN;if(l){const U=li(h,$,u,m);if((b=Math.min(b,U))===0)return b}else for(let U=$[0];U<=$[1];++U){const q=U4(h[U],u,m);if((b=Math.min(b,q))===0)return b}}else{const U=Bg($,l);if(U[0]!==null){const q=$g(Rf(h,U[0]),C,m);q=T)continue;const U=$.range1,q=$.range2;if(ep(U)<=C&&ep(q)<=O){if(!Ku(U,h.length)||!Ku(q,u.length))return NaN;if(l&&m?T=Math.min(T,z4(h,U,u,q,x)):l||m?l&&!m?T=Math.min(T,PC(u,q,h,U,x)):!l&&m&&(T=Math.min(T,PC(h,U,u,q,x))):T=Math.min(T,RC(h,U,u,q,x)),T===0)return T}else{const K=Bg(U,l),X=Bg(q,m);rb(A,T,x,h,u,K[0],X[0]),rb(A,T,x,h,u,K[0],X[1]),rb(A,T,x,h,u,K[1],X[0]),rb(A,T,x,h,u,K[1],X[1])}}return T}function mE(h,l,u,m,x=1/0){let b=x;const T=Rf(h,[0,h.length-1]);for(const A of u)if(!(b!==1/0&&$g(T,Rf(A,[0,A.length-1]),m)>=b)&&(b=Math.min(b,MC(h,l,A,!0,m,b)),b===0))return b;return b}function nb(h,l,u,m,x=1/0){let b=x;const T=Rf(h,[0,h.length-1]);for(const A of u){if(b!==1/0&&$g(T,x0(A),m)>=b)continue;const C=q4(h,l,A,m,b);if(isNaN(C))return C;if((b=Math.min(b,C))===0)return b}return b}function pE(h){return h==="Point"||h==="MultiPoint"||h==="LineString"||h==="MultiLineString"||h==="Polygon"||h==="MultiPolygon"}class tp{constructor(l,u){this.type=Or,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(Mg(l[1])){const m=l[1];if(m.type==="FeatureCollection"){for(let x=0;x{l&&!rp(u)&&(l=!1)}),l}function zg(h){if(h instanceof Ba&&h.name==="feature-state")return!1;let l=!0;return h.eachChild(u=>{l&&!zg(u)&&(l=!1)}),l}function Rd(h,l){if(h instanceof Ba&&l.indexOf(h.name)>=0)return!1;let u=!0;return h.eachChild(m=>{u&&!Rd(m,l)&&(u=!1)}),u}function DC(h,l,u){return[h,l,u].filter(Boolean).join("")}function gE(h,l){switch(h){case"string":return Yr(l);case"number":return+l;case"boolean":return!!l;case"color":return Qn.parse(l);case"formatted":return $o.fromString(Yr(l));case"resolvedImage":return Vl.build(Yr(l))}return l}function OC(h,l,u,m){return m!==void 0&&(h=m*Math.round(h/m)),l!==void 0&&hu&&(h=u),h}class Ug{constructor(l,u,m,x=!1){this.type=l,this.key=u,this.scope=m,this.featureConstant=x}static parse(l,u){let m=u.expectedType;if(m==null&&(m=gs),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 Cr))return u.error("Key name of 'config' expression must be a string literal.");let b,T=!0;const A=Yr(x.value);if(l.length>=3){const C=u.parse(l[2],2);if(!(C instanceof Cr))return u.error("Scope of 'config' expression must be a string literal.");b=Yr(C.value)}if(u.options){const C=DC(A,b,u._scope),O=u.options.get(C);O&&(T=rp(O.value||O.default))}return new Ug(m,A,b,T)}evaluate(l){const u=DC(this.key,this.scope,l.scope),m=l.getConfig(u);if(!m)return null;const{type:x,value:b,values:T,minValue:A,maxValue:C,stepValue:O}=m,$=m.default.evaluate(l);let U=$;if(b){const q=l.scope;l.scope=(q||"").split("").slice(1).join(""),U=b.evaluate(l),l.scope=q}return x&&(U=gE(x,U)),U===void 0||A===void 0&&C===void 0&&O===void 0||(typeof U=="number"?U=OC(U,A,C,O):Array.isArray(U)&&(U=U.map(q=>typeof q=="number"?OC(q,A,C,O):q))),b!==void 0&&U!==void 0&&T&&!T.includes(U)&&(U=$,x&&(U=gE(x,U))),(x&&x!==this.type||U!==void 0&&!Th(Pi(U),this.type))&&(U=gE(this.type.kind,U)),U}eachChild(){}outputDefined(){return!1}serialize(){const l=["config",this.key];return this.scope&&l.concat(this.scope),l}}class sb{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 m=l[1];return u.scope.has(m)?new sb(m,u.scope.get(m)):u.error(`Unknown variable "${m}". Make sure "${m}" 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 ib{constructor(l,u=[],m,x=new Ym,b=[],T,A,C){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=m,this._scope=T,this.options=A,this.iconImageUseTheme=C}parse(l,u,m,x,b={}){return u||m?this.concat(u,null,m,x)._parse(l,b):this._parse(l,b)}parseObjectValue(l,u,m,x,b,T={}){return this.concat(u,m,x,b)._parse(l,T)}_parse(l,u){function m(x,b,T){return T==="assert"?new Cc(b,[x]):T==="coerce"?new Hu(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,A=b.type;if(T.kind!=="string"&&T.kind!=="number"&&T.kind!=="boolean"&&T.kind!=="object"&&T.kind!=="array"||A.kind!=="value")if(T.kind!=="color"&&T.kind!=="formatted"&&T.kind!=="resolvedImage"||A.kind!=="value"&&A.kind!=="string"){if(this.checkSubtype(T,A))return null}else b=m(b,T,u.typeAnnotation||"coerce");else b=m(b,T,u.typeAnnotation||"assert")}if(!(b instanceof Cr)&&b.type.kind!=="resolvedImage"&&yE(b)){const T=new h0(this._scope,this.options,this.iconImageUseTheme);try{b=new Cr(b.type,b.evaluate(T))}catch(A){return this.error(A.message),null}}return b}return Hu.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,m,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 ib(this.registry,b,m||null,T,this.errors,this._scope,this.options,this.iconImageUseTheme)}error(l,...u){const m=`${this.key}${u.map(x=>`[${x}]`).join("")}`;this.errors.push(new pu(m,l))}checkSubtype(l,u){const m=o0(l,u);return m&&this.error(m),m}}function yE(h){if(h instanceof sb)return yE(h.boundExpression);if(h instanceof Ba&&h.name==="error"||h instanceof Q_||h instanceof Pf||h instanceof tp||h instanceof Ug)return!1;const l=h instanceof Hu||h instanceof Cc;let u=!0;return h.eachChild(m=>{u=l?u&&yE(m):u&&m instanceof Cr}),!!u&&rp(h)&&Rd(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 ab(h,l){const u=h.length-1;let m,x,b=0,T=u,A=0;for(;b<=T;)if(A=Math.floor((b+T)/2),m=h[A],x=h[A+1],m<=l){if(A===u||ll))throw new ta("Input is not a number.");T=A-1}return 0}class v0{constructor(l,u,m){this.type=l,this.input=u,this.labels=[],this.outputs=[];for(const[x,b]of m)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 m=u.parse(l[1],1,Or);if(!m)return null;const x=[];let b=null;u.expectedType&&u.expectedType.kind!=="value"&&(b=u.expectedType);for(let T=1;T=A)return u.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',O);const U=u.parse(C,$,b);if(!U)return null;b=b||U.type,x.push([A,U])}return new v0(b,m,x)}evaluate(l){const u=this.labels,m=this.outputs;if(u.length===1)return m[0].evaluate(l);const x=this.input.evaluate(l);if(x<=u[0])return m[0].evaluate(l);const b=u.length;return x>=u[b-1]?m[b-1].evaluate(l):m[ab(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 FC=.95047,BC=1.08883,$C=4/29,Vg=6/29,zC=3*Vg*Vg,G4=Vg*Vg*Vg,H4=Math.PI/180,W4=180/Math.PI;function xE(h){return h>G4?Math.pow(h,1/3):h/zC+$C}function vE(h){return h>Vg?h*h*h:zC*(h-$C)}function _0(h){return 255*(h<=.0031308?12.92*h:1.055*Math.pow(h,1/2.4)-.055)}function qg(h){return(h/=255)<=.04045?h/12.92:Math.pow((h+.055)/1.055,2.4)}function _E(h){const l=qg(h.r),u=qg(h.g),m=qg(h.b),x=xE((.4124564*l+.3575761*u+.1804375*m)/FC),b=xE((.2126729*l+.7151522*u+.072175*m)/1);return{l:116*b-16,a:500*(x-b),b:200*(b-xE((.0193339*l+.119192*u+.9503041*m)/BC)),alpha:h.a}}function UC(h){let l=(h.l+16)/116,u=isNaN(h.a)?l:l+h.a/500,m=isNaN(h.b)?l:l-h.b/200;return l=1*vE(l),u=FC*vE(u),m=BC*vE(m),new Qn(_0(3.2404542*u-1.5371385*l-.4985314*m),_0(-.969266*u+1.8760108*l+.041556*m),_0(.0556434*u-.2040259*l+1.0572252*m),h.alpha)}function K4(h,l,u){const m=l-h;return h+u*(m>180||m<-180?m-360*Math.round(m/360):m)}const b0={forward:_E,reverse:UC,interpolate:function(h,l,u){return{l:Qr(h.l,l.l,u),a:Qr(h.a,l.a,u),b:Qr(h.b,l.b,u),alpha:Qr(h.alpha,l.alpha,u)}}},Gg={forward:function(h){const{l,a:u,b:m}=_E(h),x=Math.atan2(m,u)*W4;return{h:x<0?x+360:x,c:Math.sqrt(u*u+m*m),l,alpha:h.a}},reverse:function(h){const l=h.h*H4,u=h.c;return UC({l:h.l,a:Math.cos(l)*u,b:Math.sin(l)*u,alpha:h.alpha})},interpolate:function(h,l,u){return{h:K4(h.h,l.h,u),c:Qr(h.c,l.c,u),l:Qr(h.l,l.l,u),alpha:Qr(h.alpha,l.alpha,u)}}};var bE=Object.freeze({__proto__:null,hcl:Gg,lab:b0});class zo{constructor(l,u,m,x,b){this.type=l,this.operator=u,this.interpolation=m,this.input=x,this.labels=[],this.outputs=[];for(const[T,A]of b)this.labels.push(T),this.outputs.push(A)}static interpolationFactor(l,u,m,x){let b=0;if(l.name==="exponential")b=ob(u,l.base,m,x);else if(l.name==="linear")b=ob(u,1,m,x);else if(l.name==="cubic-bezier"){const T=l.controlPoints;b=new el(T[0],T[1],T[2],T[3]).solve(ob(u,1,m,x))}return b}static parse(l,u){let[m,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,Or),!b)return null;const A=[];let C=null;m==="interpolate-hcl"||m==="interpolate-lab"?C=Sl:u.expectedType&&u.expectedType.kind!=="value"&&(C=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.',q);const X=u.parse(U,K,C);if(!X)return null;C=C||X.type,A.push([$,X])}return C.kind==="number"||C.kind==="color"||C.kind==="array"&&C.itemType.kind==="number"&&typeof C.N=="number"?new zo(C,m,x,b,A):u.error(`Type ${ha(C)} is not interpolatable.`)}evaluate(l){const u=this.labels,m=this.outputs;if(u.length===1)return m[0].evaluate(l);const x=this.input.evaluate(l);if(x<=u[0])return m[0].evaluate(l);const b=u.length;if(x>=u[b-1])return m[b-1].evaluate(l);const T=ab(u,x),A=zo.interpolationFactor(this.interpolation,x,u[T],u[T+1]),C=m[T].evaluate(l),O=m[T+1].evaluate(l);return this.operator==="interpolate"?Y_[this.type.kind.toLowerCase()](C,O,A):this.operator==="interpolate-hcl"?Gg.reverse(Gg.interpolate(Gg.forward(C),Gg.forward(O),A)):b0.reverse(b0.interpolate(b0.forward(C),b0.forward(O),A))}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 m=0;mo0(x,A.type));return new w0(T?gs:m,b)}evaluate(l){let u,m=null,x=0;for(const b of this.args){if(x++,m=b.evaluate(l),m&&m instanceof Vl&&!m.available&&(u||(u=m),m=null,x===this.args.length))return u;if(m!==null)break}return m}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 lb{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 m=[];for(let b=1;b=m.length)throw new ta("Array index out of bounds: index exceeds array size");if(u!==Math.floor(u))throw new ta("Array index must be an integer. Use at-interpolated for fractional indices");return m[u]}eachChild(l){l(this.index),l(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize()]}}class T0{constructor(l,u,m){this.type=l,this.index=u,this.input=m}static parse(l,u){if(l.length!==3)return u.error(`Expected 2 arguments, but found ${l.length-1} instead.`);const m=u.parse(l[1],1,Or),x=u.parse(l[2],2,tl(u.expectedType||gs));return m&&x?new T0(x.type.itemType,m,x):null}evaluate(l){const u=this.index.evaluate(l),m=this.input.evaluate(l);if(u<0)throw new ta(`Array index out of bounds: ${u} < 0.`);if(u>m.length-1)throw new ta(`Array index out of bounds: ${u} > ${m.length-1}.`);if(u===Math.floor(u))return m[u];const x=Math.floor(u),b=Math.ceil(u),T=m[x],A=m[b];if(typeof T!="number"||typeof A!="number")throw new ta(`Cannot interpolate between non-number values at index ${u}.`);const C=u-x;return T*(1-C)+A*C}eachChild(l){l(this.index),l(this.input)}outputDefined(){return!1}serialize(){return["at-interpolated",this.index.serialize(),this.input.serialize()]}}class E0{constructor(l,u){this.type=ps,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 m=u.parse(l[1],1,gs),x=u.parse(l[2],2,gs);return m&&x?rE(m.type,[ps,hs,Or,Sh,gs])?new E0(m,x):(u.error(`Expected first argument to be of type boolean, string, number or null, but found ${ha(m.type)} instead`),null):null}evaluate(l){const u=this.needle.evaluate(l),m=this.haystack.evaluate(l);if(m==null)return!1;if(!Lg(u,["boolean","string","number","null"]))throw new ta(`Expected first argument to be of type boolean, string, number or null, but found ${ha(Pi(u))} instead.`);if(!Lg(m,["string","array"]))throw new ta(`Expected second argument to be of type array or string, but found ${ha(Pi(m))} instead.`);return m.indexOf(u)>=0}eachChild(l){l(this.needle),l(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}class cb{constructor(l,u,m){this.type=Or,this.needle=l,this.haystack=u,this.fromIndex=m}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 m=u.parse(l[1],1,gs),x=u.parse(l[2],2,gs);if(!m||!x)return null;if(!rE(m.type,[ps,hs,Or,Sh,gs]))return u.error(`Expected first argument to be of type boolean, string, number or null, but found ${ha(m.type)} instead`),null;if(l.length===4){const b=u.parse(l[3],3,Or);return b?new cb(m,x,b):null}return new cb(m,x)}evaluate(l){const u=this.needle.evaluate(l),m=this.haystack.evaluate(l);if(!Lg(u,["boolean","string","number","null"]))throw new ta(`Expected first argument to be of type boolean, string, number or null, but found ${ha(Pi(u))} instead.`);if(!Lg(m,["string","array"]))throw new ta(`Expected second argument to be of type array or string, but found ${ha(Pi(m))} instead.`);if(this.fromIndex){const x=this.fromIndex.evaluate(l);return m.indexOf(u,x)}return m.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 wE{constructor(l,u,m,x,b,T){this.inputType=l,this.type=u,this.input=m,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 m,x;u.expectedType&&u.expectedType.kind!=="value"&&(x=u.expectedType);const b={},T=[];for(let O=2;ONumber.MAX_SAFE_INTEGER)return q.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if(typeof X=="number"&&Math.floor(X)!==X)return q.error("Numeric branch labels must be integer values.");if(m){if(q.checkSubtype(m,Pi(X)))return null}else m=Pi(X);if(b[String(X)]!==void 0)return q.error("Branch labels must be unique.");b[String(X)]=T.length}const K=u.parse(U,O,x);if(!K)return null;x=x||K.type,T.push(K)}const A=u.parse(l[1],1,gs);if(!A)return null;const C=u.parse(l[l.length-1],l.length-1,x);return C?A.type.kind!=="value"&&u.concat(1).checkSubtype(m,A.type)?null:new wE(m,x,A,b,T,C):null}evaluate(l){const u=this.input.evaluate(l);return(Th(Pi(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(),m=[],x={};for(const T of u){const A=x[this.cases[T]];A===void 0?(x[this.cases[T]]=m.length,m.push([this.cases[T],[T]])):m[A][1].push(T)}const b=T=>this.inputType.kind==="number"?Number(T):T;for(const[T,A]of m)l.push(A.length===1?b(A[0]):A.map(b)),l.push(this.outputs[T].serialize());return l.push(this.otherwise.serialize()),l}}class ub{constructor(l,u,m){this.type=l,this.branches=u,this.otherwise=m}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 m;u.expectedType&&u.expectedType.kind!=="value"&&(m=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 j0{constructor(l,u,m,x){this.type=l,this.input=u,this.beginIndex=m,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 m=u.parse(l[1],1,gs),x=u.parse(l[2],2,Or);if(!m||!x)return null;if(!rE(m.type,[tl(gs),hs,gs]))return u.error(`Expected first argument to be of type array or string, but found ${ha(m.type)} instead`),null;if(l.length===4){const b=u.parse(l[3],3,Or);return b?new j0(m.type,m,x,b):null}return new j0(m.type,m,x)}evaluate(l){const u=this.input.evaluate(l),m=this.beginIndex.evaluate(l);if(!Lg(u,["string","array"]))throw new ta(`Expected first argument to be of type array or string, but found ${ha(Pi(u))} instead.`);if(this.endIndex){const x=this.endIndex.evaluate(l);return u.slice(m,x)}return u.slice(m)}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 SE{constructor(l,u){this.type=tl(hs),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 m=u.parse(l[1],1,hs),x=u.parse(l[2],2,hs);return m&&x?new SE(m,x):void 0}evaluate(l){const u=this.str.evaluate(l),m=this.delimiter.evaluate(l);return u.split(m)}eachChild(l){l(this.str),l(this.delimiter)}outputDefined(){return!1}serialize(){return["split",this.str.serialize(),this.delimiter.serialize()]}}function VC(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 qC(h,l,u,m){return m.compare(l,u)===0}function np(h,l,u){const m=h!=="=="&&h!=="!=";return class fbe{constructor(b,T,A){this.type=ps,this.lhs=b,this.rhs=T,this.collator=A,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 A=b[0];let C=T.parse(b[1],1,gs);if(!C)return null;if(!VC(A,C.type))return T.concat(1).error(`"${A}" comparisons are not supported for type '${ha(C.type)}'.`);let O=T.parse(b[2],2,gs);if(!O)return null;if(!VC(A,O.type))return T.concat(2).error(`"${A}" comparisons are not supported for type '${ha(O.type)}'.`);if(C.type.kind!==O.type.kind&&C.type.kind!=="value"&&O.type.kind!=="value")return T.error(`Cannot compare types '${ha(C.type)}' and '${ha(O.type)}'.`);m&&(C.type.kind==="value"&&O.type.kind!=="value"?C=new Cc(O.type,[C]):C.type.kind!=="value"&&O.type.kind==="value"&&(O=new Cc(C.type,[O])));let $=null;if(b.length===4){if(C.type.kind!=="string"&&O.type.kind!=="string"&&C.type.kind!=="value"&&O.type.kind!=="value")return T.error("Cannot use collator to compare non-string types.");if($=T.parse(b[3],3,Zm),!$)return null}return new fbe(C,O,$)}evaluate(b){const T=this.lhs.evaluate(b),A=this.rhs.evaluate(b);if(m&&this.hasUntypedArgument){const C=Pi(T),O=Pi(A);if(C.kind!==O.kind||C.kind!=="string"&&C.kind!=="number")throw new ta(`Expected arguments for "${h}" to be (string, string) or (number, number), but found (${C.kind}, ${O.kind}) instead.`)}if(this.collator&&!m&&this.hasUntypedArgument){const C=Pi(T),O=Pi(A);if(C.kind!=="string"||O.kind!=="string")return l(b,T,A)}return this.collator?u(b,T,A,this.collator.evaluate(b)):l(b,T,A)}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 GC=np("==",function(h,l,u){return l===u},qC),db=np("!=",function(h,l,u){return l!==u},function(h,l,u,m){return!qC(0,l,u,m)}),Y4=np("<",function(h,l,u){return l",function(h,l,u){return l>u},function(h,l,u,m){return m.compare(l,u)>0}),Z4=np("<=",function(h,l,u){return l<=u},function(h,l,u,m){return m.compare(l,u)<=0}),X4=np(">=",function(h,l,u){return l>=u},function(h,l,u,m){return m.compare(l,u)>=0});class hb{constructor(l,u,m,x,b,T){this.type=hs,this.number=l,this.locale=u,this.currency=m,this.unit=x,this.minFractionDigits=b,this.maxFractionDigits=T}static parse(l,u){if(l.length!==3)return u.error("Expected two arguments.");const m=u.parse(l[1],1,Or);if(!m)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",hs),!b))return null;let T=null;if(x.currency&&(T=u.parseObjectValue(x.currency,2,"currency",hs),!T))return null;let A=null;if(x.unit&&(A=u.parseObjectValue(x.unit,2,"unit",hs),!A))return null;let C=null;if(x["min-fraction-digits"]&&(C=u.parseObjectValue(x["min-fraction-digits"],2,"min-fraction-digits",Or),!C))return null;let O=null;return x["max-fraction-digits"]&&(O=u.parseObjectValue(x["max-fraction-digits"],2,"max-fraction-digits",Or),!O)?null:new hb(m,b,T,A,C,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 fb{constructor(l){this.type=Or,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 m=u.parse(l[1],1);return m?m.type.kind!=="array"&&m.type.kind!=="string"&&m.type.kind!=="value"?(u.error(`Expected argument of type string or array, but found ${ha(m.type)} instead.`),null):new fb(m):null}evaluate(l){const u=this.input.evaluate(l);if(typeof u=="string"||Array.isArray(u))return u.length;throw new ta(`Expected value to be of type string or array, but found ${ha(Pi(u))} instead.`)}eachChild(l){l(this.input)}outputDefined(){return!1}serialize(){const l=["length"];return this.eachChild(u=>{l.push(u.serialize())}),l}}function WC(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 Hg={"==":GC,"!=":db,">":HC,"<":Y4,">=":X4,"<=":Z4,array:Cc,at:S0,"at-interpolated":T0,boolean:Cc,case:ub,coalesce:w0,collator:Q_,format:Xm,image:Hr,in:E0,"index-of":cb,interpolate:zo,"interpolate-hcl":zo,"interpolate-lab":zo,length:fb,let:lb,literal:Cr,match:wE,number:Cc,"number-format":hb,object:Cc,slice:j0,step:v0,string:Cc,"to-boolean":Hu,"to-color":Hu,"to-number":Hu,"to-string":Hu,var:sb,within:Pf,distance:tp,config:Ug,split:SE};function KC(h,[l,u,m,x]){l=l.evaluate(h),u=u.evaluate(h),m=m.evaluate(h);const b=x?x.evaluate(h):1,T=SC(l,u,m,b);if(T)throw new ta(T);return new Qn(l/255,u/255,m/255,b)}function YC(h,[l,u,m,x]){l=l.evaluate(h),u=u.evaluate(h),m=m.evaluate(h);const b=x?x.evaluate(h):1,T=function(O,$,U,q){return typeof O=="number"&&O>=0&&O<=360?typeof $=="number"&&$>=0&&$<=100&&typeof U=="number"&&U>=0&&U<=100?q===void 0||typeof q=="number"&&q>=0&&q<=1?null:`Invalid hsla value [${[O,$,U,q].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid hsla value [${(typeof q=="number"?[O,$,U,q]:[O,$,U]).join(", ")}]: 's', and 'l' must be between 0 and 100.`:`Invalid hsla value [${(typeof q=="number"?[O,$,U,q]:[O,$,U]).join(", ")}]: 'h' must be between 0 and 360.`}(l,u,m,b);if(T)throw new ta(T);const A=`hsla(${l}, ${u}%, ${m}%, ${b})`,C=Qn.parse(A);if(!C)throw new ta(`Failed to parse HSLA color: ${A}`);return C}function A0(h,l){return h in l}function mb(h,l){const u=l[h];return u===void 0?null:u}function Lf(h){return{type:h}}function pb(h){if(h instanceof Ug)return new Set([h.key]);let l=new Set;return h.eachChild(u=>{l=new Set([...l,...pb(u)])}),l}function gb(h){if(h instanceof Ba&&h.name==="is-active-floor")return!0;let l=!1;return h.eachChild(u=>{!l&&gb(u)&&(l=!0)}),l}function ZC(h){return{result:"success",value:h}}function Mf(h){return{result:"error",value:h}}function k0(h,l){return!!h&&!!h.parameters&&h.parameters.indexOf(l)>-1}function yb(h){return h["property-type"]==="data-driven"}function XC(h){return k0(h.expression,"measure-light")}function TE(h){return k0(h.expression,"zoom")}function xb(h){return!!h.expression&&h.expression.interpolated}function EE(h){return typeof h=="object"&&h!==null&&!Array.isArray(h)}function QC(h){return h}function JC(h,l){const u=l.type==="color",m=h.stops&&typeof h.stops[0][0]=="object",x=m||!(m||h.property!==void 0),b=h.type||(xb(l)?"exponential":"interval");if(u&&((h=Object.assign({},h)).stops&&(h.stops=h.stops.map(O=>[O[0],Qn.parse(O[1])])),h.default=Qn.parse(h.default?h.default:l.default)),h.colorSpace&&h.colorSpace!=="rgb"&&!bE[h.colorSpace])throw new Error(`Unknown color space: ${h.colorSpace}`);let T,A,C;if(b==="exponential")T=eI;else if(b==="interval")T=J4;else if(b==="categorical"){T=Q4,A=Object.create(null);for(const O of h.stops)A[O[0]]=O[1];C=typeof h.stops[0][0]}else{if(b!=="identity")throw new Error(`Unknown function type "${b}"`);T=tI}if(m){const O={},$=[];for(let K=0;KK[0]),evaluate:({zoom:K},X)=>eI({stops:U,base:h.base},l,K).evaluate(K,X)}}if(x){const O=b==="exponential"?{name:"exponential",base:h.base!==void 0?h.base:1}:null;return{kind:"camera",interpolationType:O,interpolationFactor:zo.interpolationFactor.bind(void 0,O),zoomStops:h.stops.map($=>$[0]),evaluate:({zoom:$})=>T(h,l,$,A,C)}}return{kind:"source",evaluate(O,$){const U=$&&$.properties?$.properties[h.property]:void 0;return U===void 0?Ld(h.default,l.default):T(h,l,U,A,C)}}}function Ld(h,l,u){return h!==void 0?h:l!==void 0?l:u!==void 0?u:void 0}function Q4(h,l,u,m,x){return Ld(typeof u===x?m[u]:void 0,h.default,l.default)}function J4(h,l,u){if(!u0(u))return Ld(h.default,l.default);const m=h.stops.length;if(m===1||u<=h.stops[0][0])return h.stops[0][1];if(u>=h.stops[m-1][0])return h.stops[m-1][1];const x=ab(h.stops.map(b=>b[0]),u);return h.stops[x][1]}function eI(h,l,u){const m=h.base!==void 0?h.base:1;if(!u0(u))return Ld(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=ab(h.stops.map($=>$[0]),u),T=function($,U,q,K){const X=K-q,te=$-q;return X===0?0:U===1?te/X:(Math.pow(U,te)-1)/(Math.pow(U,X)-1)}(u,m,h.stops[b][0],h.stops[b+1][0]),A=h.stops[b][1],C=h.stops[b+1][1];let O=Y_[l.type]||QC;if(h.colorSpace&&h.colorSpace!=="rgb"){const $=bE[h.colorSpace];O=(U,q)=>$.reverse($.interpolate($.forward(U),$.forward(q),T))}return typeof A.evaluate=="function"?{evaluate(...$){const U=A.evaluate.apply(void 0,$),q=C.evaluate.apply(void 0,$);if(U!==void 0&&q!==void 0)return O(U,q,T)}}:O(A,C,T)}function tI(h,l,u){return l.type==="color"?u=Qn.parse(u):l.type==="formatted"?u=$o.fromString(u.toString()):l.type==="resolvedImage"?u=Vl.build(u.toString()):c0(u)===l.type||l.type==="enum"&&l.values[u]||(u=void 0),Ld(u,h.default,l.default)}Ba.register(Hg,{error:[{kind:"error"},[hs],(h,[l])=>{throw new ta(l.evaluate(h))}],typeof:[hs,[gs],(h,[l])=>ha(Pi(l.evaluate(h)))],"to-rgba":[tl(Or,4),[Sl],(h,[l])=>l.evaluate(h).toNonPremultipliedRenderColor(null).toArray()],"to-hsla":[tl(Or,4),[Sl],(h,[l])=>l.evaluate(h).toNonPremultipliedRenderColor(null).toHslaArray()],rgb:[Sl,[Or,Or,Or],KC],rgba:[Sl,[Or,Or,Or,Or],KC],hsl:[Sl,[Or,Or,Or],YC],hsla:[Sl,[Or,Or,Or,Or],YC],has:{type:ps,overloads:[[[hs],(h,[l])=>A0(l.evaluate(h),h.properties())],[[hs,Nf],(h,[l,u])=>A0(l.evaluate(h),u.evaluate(h))]]},get:{type:gs,overloads:[[[hs],(h,[l])=>mb(l.evaluate(h),h.properties())],[[hs,Nf],(h,[l,u])=>mb(l.evaluate(h),u.evaluate(h))]]},"feature-state":[gs,[hs],(h,[l])=>mb(l.evaluate(h),h.featureState||{})],properties:[Nf,[],h=>h.properties()],"geometry-type":[hs,[],h=>h.geometryType()],worldview:[hs,[],h=>h.globals.worldview||""],"is-active-floor":[ps,Lf(hs),(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(m=>{const x=m.evaluate(h);return u.has(x)})}],id:[gs,[],h=>h.id()],zoom:[Or,[],h=>h.globals.zoom],pitch:[Or,[],h=>h.globals.pitch||0],"distance-from-center":[Or,[],h=>h.distanceFromCenter()],"measure-light":[Or,[hs],(h,[l])=>h.measureLight(l.evaluate(h))],"heatmap-density":[Or,[],h=>h.globals.heatmapDensity||0],"line-progress":[Or,[],h=>h.globals.lineProgress||0],"raster-value":[Or,[],h=>h.globals.rasterValue||0],"raster-particle-speed":[Or,[],h=>h.globals.rasterParticleSpeed||0],"sky-radial-progress":[Or,[],h=>h.globals.skyRadialProgress||0],accumulated:[gs,[],h=>h.globals.accumulated===void 0?null:h.globals.accumulated],"+":[Or,Lf(Or),(h,l)=>{let u=0;for(const m of l)u+=m.evaluate(h);return u}],"*":[Or,Lf(Or),(h,l)=>{let u=1;for(const m of l)u*=m.evaluate(h);return u}],"-":{type:Or,overloads:[[[Or,Or],(h,[l,u])=>l.evaluate(h)-u.evaluate(h)],[[Or],(h,[l])=>-l.evaluate(h)]]},"/":[Or,[Or,Or],(h,[l,u])=>l.evaluate(h)/u.evaluate(h)],"%":[Or,[Or,Or],(h,[l,u])=>l.evaluate(h)%u.evaluate(h)],ln2:[Or,[],()=>Math.LN2],pi:[Or,[],()=>Math.PI],e:[Or,[],()=>Math.E],"^":[Or,[Or,Or],(h,[l,u])=>Math.pow(l.evaluate(h),u.evaluate(h))],sqrt:[Or,[Or],(h,[l])=>Math.sqrt(l.evaluate(h))],log10:[Or,[Or],(h,[l])=>Math.log(l.evaluate(h))/Math.LN10],ln:[Or,[Or],(h,[l])=>Math.log(l.evaluate(h))],log2:[Or,[Or],(h,[l])=>Math.log2(l.evaluate(h))],sin:[Or,[Or],(h,[l])=>Math.sin(l.evaluate(h))],cos:[Or,[Or],(h,[l])=>Math.cos(l.evaluate(h))],tan:[Or,[Or],(h,[l])=>Math.tan(l.evaluate(h))],asin:[Or,[Or],(h,[l])=>Math.asin(l.evaluate(h))],acos:[Or,[Or],(h,[l])=>Math.acos(l.evaluate(h))],atan:[Or,[Or],(h,[l])=>Math.atan(l.evaluate(h))],min:[Or,Lf(Or),(h,l)=>Math.min(...l.map(u=>u.evaluate(h)))],max:[Or,Lf(Or),(h,l)=>Math.max(...l.map(u=>u.evaluate(h)))],abs:[Or,[Or],(h,[l])=>Math.abs(l.evaluate(h))],round:[Or,[Or],(h,[l])=>{const u=l.evaluate(h);return u<0?-Math.round(-u):Math.round(u)}],floor:[Or,[Or],(h,[l])=>Math.floor(l.evaluate(h))],ceil:[Or,[Or],(h,[l])=>Math.ceil(l.evaluate(h))],"filter-==":[ps,[hs,gs],(h,[l,u])=>h.properties()[l.value]===u.value],"filter-id-==":[ps,[gs],(h,[l])=>h.id()===l.value],"filter-type-==":[ps,[hs],(h,[l])=>h.geometryType()===l.value],"filter-<":[ps,[hs,gs],(h,[l,u])=>{const m=h.properties()[l.value],x=u.value;return typeof m==typeof x&&m{const u=h.id(),m=l.value;return typeof u==typeof m&&u":[ps,[hs,gs],(h,[l,u])=>{const m=h.properties()[l.value],x=u.value;return typeof m==typeof x&&m>x}],"filter-id->":[ps,[gs],(h,[l])=>{const u=h.id(),m=l.value;return typeof u==typeof m&&u>m}],"filter-<=":[ps,[hs,gs],(h,[l,u])=>{const m=h.properties()[l.value],x=u.value;return typeof m==typeof x&&m<=x}],"filter-id-<=":[ps,[gs],(h,[l])=>{const u=h.id(),m=l.value;return typeof u==typeof m&&u<=m}],"filter->=":[ps,[hs,gs],(h,[l,u])=>{const m=h.properties()[l.value],x=u.value;return typeof m==typeof x&&m>=x}],"filter-id->=":[ps,[gs],(h,[l])=>{const u=h.id(),m=l.value;return typeof u==typeof m&&u>=m}],"filter-has":[ps,[gs],(h,[l])=>l.value in h.properties()],"filter-has-id":[ps,[],h=>h.id()!==null&&h.id()!==void 0],"filter-type-in":[ps,[tl(hs)],(h,[l])=>l.value.indexOf(h.geometryType())>=0],"filter-id-in":[ps,[tl(gs)],(h,[l])=>l.value.indexOf(h.id())>=0],"filter-in-small":[ps,[hs,tl(gs)],(h,[l,u])=>u.value.indexOf(h.properties()[l.value])>=0],"filter-in-large":[ps,[hs,tl(gs)],(h,[l,u])=>function(m,x,b,T){for(;b<=T;){const A=b+T>>1;if(x[A]===m)return!0;x[A]>m?T=A-1:b=A+1}return!1}(h.properties()[l.value],u.value,0,u.value.length-1)],all:{type:ps,overloads:[[[ps,ps],(h,[l,u])=>l.evaluate(h)&&u.evaluate(h)],[Lf(ps),(h,l)=>{for(const u of l)if(!u.evaluate(h))return!1;return!0}]]},any:{type:ps,overloads:[[[ps,ps],(h,[l,u])=>l.evaluate(h)||u.evaluate(h)],[Lf(ps),(h,l)=>{for(const u of l)if(u.evaluate(h))return!0;return!1}]]},"!":[ps,[ps],(h,[l])=>!l.evaluate(h)],"is-supported-script":[ps,[hs],(h,[l])=>{const u=h.globals&&h.globals.isSupportedScript;return!u||u(l.evaluate(h))}],upcase:[hs,[hs],(h,[l])=>l.evaluate(h).toUpperCase()],downcase:[hs,[hs],(h,[l])=>l.evaluate(h).toLowerCase()],concat:[hs,Lf(gs),(h,l)=>l.map(u=>Yr(u.evaluate(h))).join("")],"resolved-locale":[hs,[Zm],(h,[l])=>l.evaluate(h).resolvedLocale()],random:[Or,[Or,Or,gs],(h,l)=>{const[u,m,x]=l.map(T=>T.evaluate(h));if(u>m||u===m)return u;let b;if(typeof x=="string")b=function(T){let A=0;if(T.length===0)return A;for(let C=0;CJSON.stringify(U)).join(", ")}, but found ${JSON.stringify($)} instead.`);return $}catch($){const U=$;return this._warningHistory[U.message]||(this._warningHistory[U.message]=!0,typeof console<"u"&&console.warn(`Failed to evaluate expression "${JSON.stringify(this.expression.serialize())}". ${U.message}`)),this._defaultValue}}}function N0(h){return Array.isArray(h)&&h.length>0&&typeof h[0]=="string"&&h[0]in Hg}function Df(h,l,u,m,x){const b=new ib(Hg,[],l?function(A){const C={color:Sl,string:hs,number:Or,enum:hs,boolean:ps,formatted:i0,resolvedImage:a0};return A.type==="array"?tl(C[A.value]||gs,A.length):C[A.type]}(l):void 0,void 0,void 0,u,m,x),T=b.parse(h,void 0,void 0,void 0,l&&l.type==="string"?{typeAnnotation:"coerce"}:void 0);return T?ZC(new vb(T,l,u,m,x)):Mf(b.errors)}class Wg{constructor(l,u,m,x){this.kind=l,this._styleExpression=u,this.isLightConstant=m,this.isLineProgressConstant=x,this.isStateDependent=l!=="constant"&&!zg(u.expression),this.configDependencies=pb(u.expression),this.isIndoorDependent=gb(u.expression)}evaluateWithoutErrorHandling(l,u,m,x,b,T){return this._styleExpression.evaluateWithoutErrorHandling(l,u,m,x,b,T)}evaluate(l,u,m,x,b,T,A){return this._styleExpression.evaluate(l,u,m,x,b,T,void 0,void 0,A)}}class sp{constructor(l,u,m,x,b,T){this.kind=l,this.zoomStops=m,this._styleExpression=u,this.isStateDependent=l!=="camera"&&!zg(u.expression),this.isIndoorDependent=gb(u.expression),this.isLightConstant=b,this.isLineProgressConstant=T,this.configDependencies=pb(u.expression),this.interpolationType=x}evaluateWithoutErrorHandling(l,u,m,x,b,T){return this._styleExpression.evaluateWithoutErrorHandling(l,u,m,x,b,T)}evaluate(l,u,m,x,b,T){return this._styleExpression.evaluate(l,u,m,x,b,T)}interpolationFactor(l,u,m){return this.interpolationType?zo.interpolationFactor(this.interpolationType,l,u,m):0}}function jE(h,l,u,m,x){if((h=Df(h,l,u,m,x)).result==="error")return h;const b=h.value.expression,T=rp(b);if(!T&&!yb(l))return Mf([new pu("","data expressions not supported")]);const A=Rd(b,["zoom","pitch","distance-from-center"]);if(!A&&!TE(l))return Mf([new pu("","zoom expressions not supported")]);const C=Rd(b,["measure-light"]);if(!C&&!XC(l))return Mf([new pu("","measure-light expression not supported")]);const O=Rd(b,["line-progress"]);if(!O&&!function(q){return k0(q.expression,"line-progress")}(l))return Mf([new pu("","line-progress expression not supported")]);const $=l.expression&&l.expression.relaxZoomRestriction,U=Yu(b);return U||A||$?U instanceof pu?Mf([U]):U instanceof zo&&!xb(l)?Mf([new pu("",'"interpolate" expressions cannot be used with this property')]):ZC(U?new sp(T&&O?"camera":"composite",h.value,U.labels,U instanceof zo?U.interpolation:void 0,C,O):new Wg(T&&O?"constant":"source",h.value,C,O)):Mf([new pu("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression, or in the properties of atmosphere.')])}class _b{constructor(l,u){this._parameters=l,this._specification=u,Object.assign(this,JC(this._parameters,this._specification))}static deserialize(l){return new _b(l._parameters,l._specification)}static serialize(l){return{_parameters:l._parameters,_specification:l._specification}}}function Yu(h){let l=null;if(h instanceof lb)l=Yu(h.result);else if(h instanceof w0){for(const u of h.args)if(l=Yu(u),l)break}else(h instanceof v0||h instanceof zo)&&h.input instanceof Ba&&h.input.name==="zoom"&&(l=h);return l instanceof pu||h.eachChild(u=>{const m=Yu(u);m instanceof pu?l=m:l&&m&&l!==m&&(l=new pu("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),l}var AE,rI,C0=function(){if(rI)return AE;rI=1,AE=l;var h=3;function l(u,m,x){var b=this.cells=[];if(u instanceof ArrayBuffer){this.arrayBuffer=u;var T=new Int32Array(this.arrayBuffer);u=T[0],this.d=(m=T[1])+2*(x=T[2]);for(var A=0;A=q[te+0]&&b>=q[te+1])?(C[X]=!0,A.push(U[X])):C[X]=!1}}},l.prototype._forEachCell=function(u,m,x,b,T,A,C,O){for(var $=this._convertToCellCoord(u),U=this._convertToCellCoord(m),q=this._convertToCellCoord(x),K=this._convertToCellCoord(b),X=$;X<=q;X++)for(var te=U;te<=K;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,m,x,b,se,A,C,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,m=h+this.cells.length+1+1,x=0,b=0;b=0||(x[b]=jh(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 m!=="Object"&&(x.$name=m),x}throw new Error("can't serialize object of type "+typeof h)}function Of(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||I0(h)||h instanceof ImageBitmap||ArrayBuffer.isView(h)||h instanceof ImageData)return h;if(Array.isArray(h))return h.map(Of);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,bb=h=>h>=1872&&h<=1919,wb=h=>h>=2208&&h<=2303,Sb=h=>h>=11904&&h<=12031,Ah=h=>h>=12032&&h<=12255,kE=h=>h>=12272&&h<=12287,P0=h=>h>=12288&&h<=12351,R0=h=>h>=12352&&h<=12447,ap=h=>h>=12448&&h<=12543,NE=h=>h>=12544&&h<=12591,Tb=h=>h>=12704&&h<=12735,Md=h=>h>=12736&&h<=12783,sI=h=>h>=12784&&h<=12799,iI=h=>h>=12800&&h<=13055,aI=h=>h>=13056&&h<=13311,CE=h=>h>=13312&&h<=19903,Eb=h=>h>=19968&&h<=40959,L0=h=>h>=40960&&h<=42127,IE=h=>h>=42128&&h<=42191,PE=h=>h>=44032&&h<=55215,jb=h=>h>=63744&&h<=64255,RE=h=>h>=64336&&h<=65023,oI=h=>h>=65040&&h<=65055,LE=h=>h>=65072&&h<=65103,lI=h=>h>=65104&&h<=65135,ME=h=>h>=65136&&h<=65279,DE=h=>h>=65280&&h<=65519;function OE(h){for(const l of h)if(FE(l.charCodeAt(0)))return!0;return!1}function e5(h){for(const l of h)if(!t5(l.charCodeAt(0)))return!1;return!0}function t5(h){return!(nI(h)||bb(h)||wb(h)||RE(h)||ME(h))}function r5(h){return!(h<11904||!(Tb(h)||NE(h)||LE(h)||jb(h)||aI(h)||Sb(h)||Md(h)||P0(h)||CE(h)||Eb(h)||iI(h)||DE(h)||R0(h)||kE(h)||Ah(h)||sI(h)||ap(h)||oI(h)||IE(h)||L0(h)))}function FE(h){return!(h!==746&&h!==747&&(h<4352||!(Tb(h)||NE(h)||LE(h)&&!(h>=65097&&h<=65103)||jb(h)||aI(h)||Sb(h)||Md(h)||!(!P0(h)||h>=12296&&h<=12305||h>=12308&&h<=12319||h===12336)||CE(h)||Eb(h)||iI(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)||PE(h)||R0(h)||kE(h)||(l=>l>=12688&&l<=12703)(h)||Ah(h)||sI(h)||ap(h)&&h!==12540||!(!DE(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)||!(!lI(h)||h>=65112&&h<=65118||h>=65123&&h<=65126)||(l=>l>=5120&&l<=5759)(h)||(l=>l>=6320&&l<=6399)(h)||oI(h)||(l=>l>=19904&&l<=19967)(h)||L0(h)||IE(h))))}function cI(h){return h===12312||h===12313||h===12316||h===12540||h===12448}function op(h){return!(FE(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)||P0(l)||ap(l)||(u=>u>=57344&&u<=63743)(l)||LE(l)||lI(l)||DE(l)||l===8734||l===8756||l===8757||l>=9984&&l<=10087||l>=10102&&l<=10131||l===65532||l===65533)}(h))}function uI(h){return nI(h)||bb(h)||wb(h)||RE(h)||ME(h)}function BE(h){return h>=1424&&h<=2303||RE(h)||ME(h)}function Ab(h,l){return!(!l&&BE(h)||h>=2304&&h<=3583||h>=3840&&h<=4255||(u=>u>=6016&&u<=6143)(h))}function n5(h){for(const l of h)if(BE(l.charCodeAt(0)))return!0;return!1}const fc={unavailable:"unavailable",deferred:"deferred",loading:"loading",parsing:"parsing",parsed:"parsed",loaded:"loaded",error:"error"};let Dd=null,rl=fc.unavailable,Pc=null;const dI=function(h){h&&typeof h=="string"&&h.indexOf("NetworkError")>-1&&(rl=fc.error),Dd&&Dd(h)};function $E(){zE.fire(new qu("pluginStateChange",{pluginStatus:rl,pluginURL:Pc}))}const zE=new s0,UE=function(){return rl},hI=function(){if(rl!==fc.deferred||!Pc)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");rl=fc.loading,$E(),Pc&&Cg({url:Pc},h=>{h?dI(h):(rl=fc.loaded,$E())})},kh={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>rl===fc.loaded||kh.applyArabicShaping!=null,isLoading:()=>rl===fc.loading,setState(h){rl=h.pluginStatus,Pc=h.pluginURL},isParsing:()=>rl===fc.parsing,isParsed:()=>rl===fc.parsed,getPluginURL:()=>Pc},fI=function(){kh.isLoading()||kh.isLoaded()||UE()!=="deferred"||hI()};class as{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,m){for(const x of u)if(!Ab(x.charCodeAt(0),m))return!1;return!0}(l,kh.isLoaded())}}class Yg{constructor(l,u,m,x,b){this.property=l,this.value=u,this.expression=function(T,A,C,O,$){if(EE(T))return new _b(T,A);if(N0(T)||Array.isArray(T)&&T.length>0){const U=jE(T,A,C,O,$);if(U.result==="error")throw new Error(U.value.map(q=>`${q.key}: ${q.message}`).join(", "));return U.value}{let U=T;return typeof T=="string"&&A.type==="color"&&(U=Qn.parse(T)),{kind:"constant",configDependencies:new Set,isIndoorDependent:!1,evaluate:()=>U}}}(u===void 0?l.specification.default:u,l.specification,m,x,b)}isIndoorDependent(){return this.expression.isIndoorDependent}isDataDriven(){return this.expression.kind==="source"||this.expression.kind==="composite"}possiblyEvaluate(l,u,m,x){return this.property.possiblyEvaluate(this,l,u,m,x)}}class kb{constructor(l,u,m,x){this.property=l,this.value=new Yg(l,void 0,u,m,x)}transitioned(l,u){return new Zg(this.property,this.value,u,Object.assign({},l.transition,this.transition),l.now)}untransitioned(){return new Zg(this.property,this.value,null,{},0)}}class Nb{constructor(l,u,m,x){this._properties=l,this._values=Object.create(l.defaultTransitionablePropertyValues),this._scope=u,this._options=m,this._iconImageUseTheme=x,this._isIndoorDependent=!1,this.configDependencies=new Set}getValue(l){return dr(this._values[l].value.value)}setValue(l,u){this._values.hasOwnProperty(l)||(this._values[l]=new kb(this._values[l].property,this._scope,this._options,this._iconImageUseTheme)),this._values[l].value=new Yg(this._values[l].property,u===null?void 0:dr(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 m=this._properties.properties;if(l)for(const x in l){const b=l[x];if(x.endsWith("-transition")){const T=x.slice(0,-11);m[T]&&this.setTransition(T,b)}else m.hasOwnProperty(x)&&this.setValue(x,b)}}getTransition(l){return dr(this._values[l].transition)}setTransition(l,u){this._values.hasOwnProperty(l)||(this._values[l]=new kb(this._values[l].property)),this._values[l].transition=dr(u)||void 0}serialize(){const l={};for(const u of Object.keys(this._values)){const m=this.getValue(u);m!==void 0&&(l[u]=m);const x=this.getTransition(u);x!==void 0&&(l[`${u}-transition`]=x)}return l}transitioned(l,u){const m=new VE(this._properties);for(const x of Object.keys(this._values))m._values[x]=this._values[x].transitioned(l,u._values[x]);return m}untransitioned(){const l=new VE(this._properties);for(const u of Object.keys(this._values))l._values[u]=this._values[u].untransitioned();return l}isIndoorDependent(){return this._isIndoorDependent}}class Zg{constructor(l,u,m,x,b){const T=x.delay||0,A=x.duration||0;b=b||0,this.property=l,this.value=u,this.begin=b+T,this.end=this.begin+A,l.specification.transition&&(x.delay||x.duration)&&(this.prior=m)}possiblyEvaluate(l,u,m){const x=l.now||0,b=this.value.possiblyEvaluate(l,u,m),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 mI(h){return h instanceof Number||h instanceof String||h instanceof Boolean?h.valueOf():h}function Cb(h){if(Array.isArray(h))return h.map(Cb);if(h instanceof Object&&!(h instanceof Number||h instanceof String||h instanceof Boolean)){const l={};for(const u in h)l[u]=Cb(h[u]);return l}return mI(h)}function GE(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(!GE(l)&&typeof l!="boolean")return!1;return!0;default:return!0}}function Ib(h,l="",u=null,m="fill"){if(h==null)return{filter:()=>!0,needGeometry:!1,needFeature:!1};GE(h)||(h=Pb(h));const x=h;let b=!0;try{b=function($){if(!Qg($))return $;let U=Cb($);return gI(U),U=pI(U),U}(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,A=null;if(m!=="background"&&m!=="sky"&&m!=="slot"){A=st[`filter_${m}`];const $=Df(b,A,l,u);if($.result==="error")throw new Error($.value.map(U=>`${U.key}: ${U.message}`).join(", "));T=(U,q,K)=>$.value.evaluate(U,q,{},K)}let C=null,O=null;if(b!==x){const $=Df(x,A,l,u);if($.result==="error")throw new Error($.value.map(U=>`${U.key}: ${U.message}`).join(", "));C=(U,q,K,X,te)=>$.value.evaluate(U,q,{},K,void 0,void 0,X,te),O=!rp($.value.expression)}return{filter:T,dynamicFilter:C||void 0,needGeometry:xI(b),needFeature:!!O}}function pI(h){if(!Array.isArray(h))return h;const l=function(u){if(yI.has(u[0])){for(let m=1;mpI(u))}function gI(h){let l=!1;const u=[];if(h[0]==="case"){for(let m=1;m",">=","<","<=","to-boolean"]);function s5(h,l){return hl?1:0}function xI(h){if(!Array.isArray(h))return!1;if(h[0]==="within"||h[0]==="distance")return!0;for(let l=1;l"||l==="<="||l===">="?Rb(h[1],h[2],l):l==="any"?(u=h.slice(1),["any"].concat(u.map(Pb))):l==="all"?["all"].concat(h.slice(1).map(Pb)):l==="none"?["all"].concat(h.slice(1).map(Pb).map(M0)):l==="in"?HE(h[1],h.slice(2)):l==="!in"?M0(HE(h[1],h.slice(2))):l==="has"?Ch(h[1]):l!=="!has"||M0(Ch(h[1]));var u}function Rb(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 HE(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(s5)]]:["filter-in-small",h,["literal",l]]}}function Ch(h){switch(h){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",h]}}function M0(h){return["!",h]}const D0="";function cp(h,l){return l?`${h}${D0}${l}`:h}function vI(h){const l=h.indexOf(D0);return l>=0?h.slice(l+1):""}let _I;const WE=()=>_I||(_I=new ri({"icon-size":new Ht(st.layout_symbol["icon-size"]),"icon-image":new Ht(st.layout_symbol["icon-image"]),"icon-rotate":new Ht(st.layout_symbol["icon-rotate"]),"icon-offset":new Ht(st.layout_symbol["icon-offset"]),"text-size":new Ht(st.layout_symbol["text-size"]),"text-rotate":new Ht(st.layout_symbol["text-rotate"]),"text-offset":new Ht(st.layout_symbol["text-offset"])}));let KE;const YE=()=>KE||(KE=new ri({"icon-opacity":new Ht(st.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new Ht(st.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new Ht(st.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new Ht(st.paint_symbol["text-emissive-strength"]),"icon-color":new Ht(st.paint_symbol["icon-color"]),"icon-halo-color":new Ht(st.paint_symbol["icon-halo-color"]),"icon-halo-width":new Ht(st.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Ht(st.paint_symbol["icon-halo-blur"]),"icon-translate":new Ht(st.paint_symbol["icon-translate"]),"text-opacity":new Ht(st.paint_symbol["text-opacity"]),"text-occlusion-opacity":new Ht(st.paint_symbol["text-occlusion-opacity"]),"text-color":new Ht(st.paint_symbol["text-color"],{runtimeType:Sl,getOverride:h=>h.textColor,hasOverride:h=>!!h.textColor}),"text-halo-color":new Ht(st.paint_symbol["text-halo-color"]),"text-halo-width":new Ht(st.paint_symbol["text-halo-width"]),"text-halo-blur":new Ht(st.paint_symbol["text-halo-blur"]),"text-translate":new Ht(st.paint_symbol["text-translate"]),"symbol-z-offset":new Ht(st.paint_symbol["symbol-z-offset"]),"icon-color-use-theme":new Ht({type:"string",default:"default","property-type":"data-driven"}),"icon-halo-color-use-theme":new Ht({type:"string",default:"default","property-type":"data-driven"}),"text-color-use-theme":new Ht({type:"string",default:"default","property-type":"data-driven"}),"text-halo-color-use-theme":new Ht({type:"string",default:"default","property-type":"data-driven"})}));class i5{constructor(l,u,m,x,b,T){this._conditionSpec=l,this._propertiesSpec=m;const A=Df(l,st.appearance.condition);if(A.result==="success"&&(this.condition=A.value),this.name=u,m){this.layoutProperties=new Nh(WE()),this.unevaluatedLayout=new qE(WE(),x,b,T),this.paintProperties=new Nh(YE()),this.unevaluatedPaint=new qE(YE(),x,b,"");for(const C in m)C in this.unevaluatedLayout._values?this.unevaluatedLayout.setValue(C,m[C]):C in this.unevaluatedPaint._values&&this.unevaluatedPaint.setValue(C,m[C])}}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,m){this.unevaluatedLayout&&(this.layoutProperties=this.unevaluatedLayout.possiblyEvaluate(l,void 0,u,m)),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():{},m=this.unevaluatedPaint?this.unevaluatedPaint.serialize():{},x=Object.assign({},u,m);return Object.keys(x).length>0&&(l.properties=x),l}hasIconLayoutProperties(){const l=this.hasLayoutProperty("icon-image"),u=this.hasLayoutProperty("icon-size"),m=this.hasLayoutProperty("icon-offset"),x=this.hasLayoutProperty("icon-rotate");return l||u||m||x}hasTextLayoutProperties(){const l=this.hasLayoutProperty("text-size"),u=this.hasLayoutProperty("text-offset"),m=this.hasLayoutProperty("text-rotate");return l||u||m}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 ZE="-transition",a5=new Set(["fill","line","background","hillshade","raster"]);class nl extends s0{constructor(l,u,m,x,b,T){if(super(),this.id=l.id,this.fqid=cp(this.id,m),this.type=l.type,this.scope=m,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 A=Df(this.filter,st[`filter_${l.type}`]);A.result!=="error"&&(this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...A.value.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||A.value.isIndoorDependent)}if(l.slot&&(this.slot=l.slot),l.appearances&&this.setAppearances(l.appearances),u.layout&&(this._unevaluatedLayout=new qE(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 Nb(u.paint,this.scope,b);for(const A in l.paint)this.setPaintProperty(A,l.paint[A]);for(const A in l.layout)this.setLayoutProperty(A,l.layout[A]);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 Nh(u.paint)}}}onAdd(l){}onRemove(l){}isDraped(l){return!this.is3D(!0)&&a5.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 m=this._unevaluatedLayout;m._properties.properties[l]&&(m.setValue(l,u),this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...m.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||m.isIndoorDependent(),l==="visibility"&&this.possiblyEvaluateVisibility())}setAppearances(l){this.appearances=[],l.forEach(u=>{this.appearances.push(new i5(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(ZE)?this._transitionablePaint.getTransition(l.slice(0,-11)):this._transitionablePaint.getValue(l)}isPaintProperty(l){return!!this._transitionablePaint._properties.properties[l]}setPaintProperty(l,u){const m=this._transitionablePaint,x=m._properties.properties;if(l.endsWith(ZE)){const U=l.slice(0,-11);return x[U]&&m.setTransition(U,u||void 0),!1}if(!x[l])return!1;const b=m._values[l],T=b.value.isDataDriven(),A=b.value;m.setValue(l,u),this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...m.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||m.isIndoorDependent(),this._handleSpecialPaintPropertyUpdate(l);const C=m._values[l].value,O=C.isDataDriven(),$=l.endsWith("pattern")||l==="line-dasharray";return O||T||$||this._handleOverridablePaintPropertyUpdate(l,A,C)}_handleSpecialPaintPropertyUpdate(l){}getProgramIds(){return null}getDefaultProgramParams(l,u,m){return null}_handleOverridablePaintPropertyUpdate(l,u,m){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())),Rt(l,(u,m)=>!(u===void 0||m==="layout"&&!Object.keys(u).length||m==="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 lp&&yb(u.property.specification)&&(u.value.kind==="source"||u.value.kind==="composite")&&u.value.isStateDependent)return!0}for(const l of this.appearances)if(!zg(l.condition.expression))return!0;return!1}compileFilter(l){this._filterCompiled||(this._featureFilter=Ib(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,m){return{}}queryRadius(l){}queryIntersectsFeature(l,u,m,x,b,T,A,C,O,$){}}const Lb={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class O0{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 o5=new ArrayBuffer(0);class Gs{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=o5),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 Rn(h,l=1){let u=0,m=0;return{members:h.map(x=>{const b=Lb[x.type].BYTES_PER_ELEMENT,T=u=bI(u,Math.max(l,b)),A=x.components||1;return m=Math.max(m,b),u+=b*A,{name:x.name,type:x.type,components:A,offset:T}}),size:bI(u,Math.max(m,l)),alignment:l}}function bI(h,l){return Math.ceil(h/l)*l}class mc extends Gs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(l,u){const m=this.length;return this.resize(m+1),this.emplace(m,l,u)}emplace(l,u,m){const x=2*l;return this.int16[x+0]=u,this.int16[x+1]=m,l}}mc.prototype.bytesPerElement=4,_r(mc,"StructArrayLayout2i4");class Od extends Gs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(l,u,m){const x=this.length;return this.resize(x+1),this.emplace(x,l,u,m)}emplace(l,u,m,x){const b=3*l;return this.int16[b+0]=u,this.int16[b+1]=m,this.int16[b+2]=x,l}}Od.prototype.bytesPerElement=6,_r(Od,"StructArrayLayout3i6");class Eo extends Gs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(l,u,m,x){const b=this.length;return this.resize(b+1),this.emplace(b,l,u,m,x)}emplace(l,u,m,x,b){const T=4*l;return this.int16[T+0]=u,this.int16[T+1]=m,this.uint16[T+2]=x,this.uint16[T+3]=b,l}}Eo.prototype.bytesPerElement=8,_r(Eo,"StructArrayLayout2i2ui8");class Rc extends Gs{_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}}Rc.prototype.bytesPerElement=4,_r(Rc,"StructArrayLayout1f4");class XE extends Gs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(l,u,m){const x=this.length;return this.resize(x+1),this.emplace(x,l,u,m)}emplace(l,u,m,x){const b=4*l,T=2*l;return this.int16[b+0]=u,this.int16[b+1]=m,this.float32[T+1]=x,l}}XE.prototype.bytesPerElement=8,_r(XE,"StructArrayLayout2i1f8");class QE extends Gs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(l,u,m){const x=this.length;return this.resize(x+1),this.emplace(x,l,u,m)}emplace(l,u,m,x){const b=4*l;return this.int16[b+0]=u,this.int16[b+1]=m,this.int16[b+2]=x,l}}QE.prototype.bytesPerElement=8,_r(QE,"StructArrayLayout3i8");class JE extends Gs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(l,u,m,x){const b=this.length;return this.resize(b+1),this.emplace(b,l,u,m,x)}emplace(l,u,m,x,b){const T=4*l;return this.int16[T+0]=u,this.int16[T+1]=m,this.int16[T+2]=x,this.int16[T+3]=b,l}}JE.prototype.bytesPerElement=8,_r(JE,"StructArrayLayout4i8");class ej extends Gs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(l,u,m,x,b){const T=this.length;return this.resize(T+1),this.emplace(T,l,u,m,x,b)}emplace(l,u,m,x,b,T){const A=5*l;return this.int16[A+0]=u,this.int16[A+1]=m,this.int16[A+2]=x,this.int16[A+3]=b,this.int16[A+4]=T,l}}ej.prototype.bytesPerElement=10,_r(ej,"StructArrayLayout5i10");class F0 extends Gs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(l,u,m,x,b,T,A){const C=this.length;return this.resize(C+1),this.emplace(C,l,u,m,x,b,T,A)}emplace(l,u,m,x,b,T,A,C){const O=6*l,$=12*l,U=3*l;return this.int16[O+0]=u,this.int16[O+1]=m,this.uint8[$+4]=x,this.uint8[$+5]=b,this.uint8[$+6]=T,this.uint8[$+7]=A,this.float32[U+2]=C,l}}F0.prototype.bytesPerElement=12,_r(F0,"StructArrayLayout2i4ub1f12");class xu extends Gs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(l,u,m){const x=this.length;return this.resize(x+1),this.emplace(x,l,u,m)}emplace(l,u,m,x){const b=3*l;return this.float32[b+0]=u,this.float32[b+1]=m,this.float32[b+2]=x,l}}xu.prototype.bytesPerElement=12,_r(xu,"StructArrayLayout3f12");class Fd extends Gs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(l,u,m,x,b){const T=this.length;return this.resize(T+1),this.emplace(T,l,u,m,x,b)}emplace(l,u,m,x,b,T){const A=6*l,C=3*l;return this.uint16[A+0]=u,this.uint16[A+1]=m,this.uint16[A+2]=x,this.uint16[A+3]=b,this.float32[C+2]=T,l}}Fd.prototype.bytesPerElement=12,_r(Fd,"StructArrayLayout4ui1f12");class Jg extends Gs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(l,u,m,x){const b=this.length;return this.resize(b+1),this.emplace(b,l,u,m,x)}emplace(l,u,m,x,b){const T=4*l;return this.uint16[T+0]=u,this.uint16[T+1]=m,this.uint16[T+2]=x,this.uint16[T+3]=b,l}}Jg.prototype.bytesPerElement=8,_r(Jg,"StructArrayLayout4ui8");class Mb extends Gs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(l,u,m,x,b,T){const A=this.length;return this.resize(A+1),this.emplace(A,l,u,m,x,b,T)}emplace(l,u,m,x,b,T,A){const C=6*l;return this.int16[C+0]=u,this.int16[C+1]=m,this.int16[C+2]=x,this.int16[C+3]=b,this.int16[C+4]=T,this.int16[C+5]=A,l}}Mb.prototype.bytesPerElement=12,_r(Mb,"StructArrayLayout6i12");class tj extends Gs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(l,u,m,x,b,T,A,C,O,$,U,q){const K=this.length;return this.resize(K+1),this.emplace(K,l,u,m,x,b,T,A,C,O,$,U,q)}emplace(l,u,m,x,b,T,A,C,O,$,U,q,K){const X=12*l;return this.int16[X+0]=u,this.int16[X+1]=m,this.int16[X+2]=x,this.int16[X+3]=b,this.uint16[X+4]=T,this.uint16[X+5]=A,this.uint16[X+6]=C,this.uint16[X+7]=O,this.int16[X+8]=$,this.int16[X+9]=U,this.int16[X+10]=q,this.int16[X+11]=K,l}}tj.prototype.bytesPerElement=24,_r(tj,"StructArrayLayout4i4ui4i24");class rj extends Gs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(l,u,m,x,b,T){const A=this.length;return this.resize(A+1),this.emplace(A,l,u,m,x,b,T)}emplace(l,u,m,x,b,T,A){const C=10*l,O=5*l;return this.int16[C+0]=u,this.int16[C+1]=m,this.int16[C+2]=x,this.float32[O+2]=b,this.float32[O+3]=T,this.float32[O+4]=A,l}}rj.prototype.bytesPerElement=20,_r(rj,"StructArrayLayout3i3f20");class Ih extends Gs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(l,u,m,x){const b=this.length;return this.resize(b+1),this.emplace(b,l,u,m,x)}emplace(l,u,m,x,b){const T=4*l;return this.float32[T+0]=u,this.float32[T+1]=m,this.float32[T+2]=x,this.float32[T+3]=b,l}}Ih.prototype.bytesPerElement=16,_r(Ih,"StructArrayLayout4f16");class B0 extends Gs{_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}}B0.prototype.bytesPerElement=4,_r(B0,"StructArrayLayout1ul4");class vu extends Gs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(l,u){const m=this.length;return this.resize(m+1),this.emplace(m,l,u)}emplace(l,u,m){const x=2*l;return this.uint16[x+0]=u,this.uint16[x+1]=m,l}}vu.prototype.bytesPerElement=4,_r(vu,"StructArrayLayout2ui4");class Db extends Gs{_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,m,x,b,T,A,C,O,$,U,q,K){const X=this.length;return this.resize(X+1),this.emplace(X,l,u,m,x,b,T,A,C,O,$,U,q,K)}emplace(l,u,m,x,b,T,A,C,O,$,U,q,K,X){const te=20*l,se=10*l;return this.int16[te+0]=u,this.int16[te+1]=m,this.int16[te+2]=x,this.int16[te+3]=b,this.int16[te+4]=T,this.float32[se+3]=A,this.float32[se+4]=C,this.float32[se+5]=O,this.float32[se+6]=$,this.int16[te+14]=U,this.uint32[se+8]=q,this.uint16[te+18]=K,this.uint16[te+19]=X,l}}Db.prototype.bytesPerElement=40,_r(Db,"StructArrayLayout5i4f1i1ul2ui40");class $0 extends Gs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(l,u,m,x,b,T,A){const C=this.length;return this.resize(C+1),this.emplace(C,l,u,m,x,b,T,A)}emplace(l,u,m,x,b,T,A,C){const O=8*l;return this.int16[O+0]=u,this.int16[O+1]=m,this.int16[O+2]=x,this.int16[O+4]=b,this.int16[O+5]=T,this.int16[O+6]=A,this.int16[O+7]=C,l}}$0.prototype.bytesPerElement=16,_r($0,"StructArrayLayout3i2i2i16");class nj extends Gs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(l,u,m,x,b){const T=this.length;return this.resize(T+1),this.emplace(T,l,u,m,x,b)}emplace(l,u,m,x,b,T){const A=4*l,C=8*l;return this.float32[A+0]=u,this.float32[A+1]=m,this.float32[A+2]=x,this.int16[C+6]=b,this.int16[C+7]=T,l}}nj.prototype.bytesPerElement=16,_r(nj,"StructArrayLayout2f1f2i16");class z0 extends Gs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(l,u,m,x,b,T){const A=this.length;return this.resize(A+1),this.emplace(A,l,u,m,x,b,T)}emplace(l,u,m,x,b,T,A){const C=20*l,O=5*l;return this.uint8[C+0]=u,this.uint8[C+1]=m,this.float32[O+1]=x,this.float32[O+2]=b,this.float32[O+3]=T,this.float32[O+4]=A,l}}z0.prototype.bytesPerElement=20,_r(z0,"StructArrayLayout2ub4f20");class bi extends Gs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(l,u,m){const x=this.length;return this.resize(x+1),this.emplace(x,l,u,m)}emplace(l,u,m,x){const b=3*l;return this.uint16[b+0]=u,this.uint16[b+1]=m,this.uint16[b+2]=x,l}}bi.prototype.bytesPerElement=6,_r(bi,"StructArrayLayout3ui6");class Ob extends Gs{_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,m,x,b,T,A,C,O,$,U,q,K,X,te,se,ae,he,ue,be,Ne){const Ie=this.length;return this.resize(Ie+1),this.emplace(Ie,l,u,m,x,b,T,A,C,O,$,U,q,K,X,te,se,ae,he,ue,be,Ne)}emplace(l,u,m,x,b,T,A,C,O,$,U,q,K,X,te,se,ae,he,ue,be,Ne,Ie){const We=30*l,ze=15*l,He=60*l;return this.int16[We+0]=u,this.int16[We+1]=m,this.int16[We+2]=x,this.float32[ze+2]=b,this.float32[ze+3]=T,this.uint16[We+8]=A,this.uint16[We+9]=C,this.uint32[ze+5]=O,this.uint32[ze+6]=$,this.uint32[ze+7]=U,this.uint16[We+16]=q,this.uint16[We+17]=K,this.uint16[We+18]=X,this.float32[ze+10]=te,this.float32[ze+11]=se,this.uint8[He+48]=ae,this.uint8[He+49]=he,this.uint8[He+50]=ue,this.uint32[ze+13]=be,this.int16[We+28]=Ne,this.uint8[He+58]=Ie,l}}Ob.prototype.bytesPerElement=60,_r(Ob,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class sj extends Gs{_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,m,x,b,T,A,C,O,$,U,q,K,X,te,se,ae,he,ue,be,Ne,Ie,We,ze,He,Ue,Ve,yt,bt,At,Pt,kt,zt){const mt=this.length;return this.resize(mt+1),this.emplace(mt,l,u,m,x,b,T,A,C,O,$,U,q,K,X,te,se,ae,he,ue,be,Ne,Ie,We,ze,He,Ue,Ve,yt,bt,At,Pt,kt,zt)}emplace(l,u,m,x,b,T,A,C,O,$,U,q,K,X,te,se,ae,he,ue,be,Ne,Ie,We,ze,He,Ue,Ve,yt,bt,At,Pt,kt,zt,mt){const Nt=20*l,Mt=40*l,Vt=80*l;return this.float32[Nt+0]=u,this.float32[Nt+1]=m,this.int16[Mt+4]=x,this.int16[Mt+5]=b,this.int16[Mt+6]=T,this.int16[Mt+7]=A,this.int16[Mt+8]=C,this.int16[Mt+9]=O,this.int16[Mt+10]=$,this.int16[Mt+11]=U,this.int16[Mt+12]=q,this.uint16[Mt+13]=K,this.uint16[Mt+14]=X,this.uint16[Mt+15]=te,this.uint16[Mt+16]=se,this.uint16[Mt+17]=ae,this.uint16[Mt+18]=he,this.uint16[Mt+19]=ue,this.uint16[Mt+20]=be,this.uint16[Mt+21]=Ne,this.uint16[Mt+22]=Ie,this.uint16[Mt+23]=We,this.uint16[Mt+24]=ze,this.uint16[Mt+25]=He,this.uint16[Mt+26]=Ue,this.uint16[Mt+27]=Ve,this.uint32[Nt+14]=yt,this.float32[Nt+15]=bt,this.float32[Nt+16]=At,this.float32[Nt+17]=Pt,this.float32[Nt+18]=kt,this.uint8[Vt+76]=zt,this.uint16[Mt+39]=mt,l}}sj.prototype.bytesPerElement=80,_r(sj,"StructArrayLayout2f9i15ui1ul4f1ub1ui80");class Fb extends Gs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(l,u,m,x,b,T){const A=this.length;return this.resize(A+1),this.emplace(A,l,u,m,x,b,T)}emplace(l,u,m,x,b,T,A){const C=6*l;return this.float32[C+0]=u,this.float32[C+1]=m,this.float32[C+2]=x,this.float32[C+3]=b,this.float32[C+4]=T,this.float32[C+5]=A,l}}Fb.prototype.bytesPerElement=24,_r(Fb,"StructArrayLayout6f24");class up extends Gs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(l,u,m,x,b){const T=this.length;return this.resize(T+1),this.emplace(T,l,u,m,x,b)}emplace(l,u,m,x,b,T){const A=5*l;return this.float32[A+0]=u,this.float32[A+1]=m,this.float32[A+2]=x,this.float32[A+3]=b,this.float32[A+4]=T,l}}up.prototype.bytesPerElement=20,_r(up,"StructArrayLayout5f20");class U0 extends Gs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(l,u,m,x,b,T,A){const C=this.length;return this.resize(C+1),this.emplace(C,l,u,m,x,b,T,A)}emplace(l,u,m,x,b,T,A,C){const O=7*l;return this.float32[O+0]=u,this.float32[O+1]=m,this.float32[O+2]=x,this.float32[O+3]=b,this.float32[O+4]=T,this.float32[O+5]=A,this.float32[O+6]=C,l}}U0.prototype.bytesPerElement=28,_r(U0,"StructArrayLayout7f28");class ij extends Gs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(l,u,m,x,b,T,A,C,O,$,U){const q=this.length;return this.resize(q+1),this.emplace(q,l,u,m,x,b,T,A,C,O,$,U)}emplace(l,u,m,x,b,T,A,C,O,$,U,q){const K=11*l;return this.float32[K+0]=u,this.float32[K+1]=m,this.float32[K+2]=x,this.float32[K+3]=b,this.float32[K+4]=T,this.float32[K+5]=A,this.float32[K+6]=C,this.float32[K+7]=O,this.float32[K+8]=$,this.float32[K+9]=U,this.float32[K+10]=q,l}}ij.prototype.bytesPerElement=44,_r(ij,"StructArrayLayout11f44");class aj extends Gs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(l,u,m,x,b,T,A,C,O){const $=this.length;return this.resize($+1),this.emplace($,l,u,m,x,b,T,A,C,O)}emplace(l,u,m,x,b,T,A,C,O,$){const U=9*l;return this.float32[U+0]=u,this.float32[U+1]=m,this.float32[U+2]=x,this.float32[U+3]=b,this.float32[U+4]=T,this.float32[U+5]=A,this.float32[U+6]=C,this.float32[U+7]=O,this.float32[U+8]=$,l}}aj.prototype.bytesPerElement=36,_r(aj,"StructArrayLayout9f36");class dp extends Gs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(l,u){const m=this.length;return this.resize(m+1),this.emplace(m,l,u)}emplace(l,u,m){const x=2*l;return this.float32[x+0]=u,this.float32[x+1]=m,l}}dp.prototype.bytesPerElement=8,_r(dp,"StructArrayLayout2f8");class oj extends Gs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(l,u,m,x){const b=this.length;return this.resize(b+1),this.emplace(b,l,u,m,x)}emplace(l,u,m,x,b){const T=6*l;return this.uint32[3*l+0]=u,this.uint16[T+2]=m,this.uint16[T+3]=x,this.uint16[T+4]=b,l}}oj.prototype.bytesPerElement=12,_r(oj,"StructArrayLayout1ul3ui12");class hp extends Gs{_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}}hp.prototype.bytesPerElement=2,_r(hp,"StructArrayLayout1ui2");class lj extends Gs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(l,u,m,x,b,T,A,C,O,$,U,q,K,X,te,se){const ae=this.length;return this.resize(ae+1),this.emplace(ae,l,u,m,x,b,T,A,C,O,$,U,q,K,X,te,se)}emplace(l,u,m,x,b,T,A,C,O,$,U,q,K,X,te,se,ae){const he=16*l;return this.float32[he+0]=u,this.float32[he+1]=m,this.float32[he+2]=x,this.float32[he+3]=b,this.float32[he+4]=T,this.float32[he+5]=A,this.float32[he+6]=C,this.float32[he+7]=O,this.float32[he+8]=$,this.float32[he+9]=U,this.float32[he+10]=q,this.float32[he+11]=K,this.float32[he+12]=X,this.float32[he+13]=te,this.float32[he+14]=se,this.float32[he+15]=ae,l}}lj.prototype.bytesPerElement=64,_r(lj,"StructArrayLayout16f64");class Bb extends Gs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(l,u,m,x,b,T,A){const C=this.length;return this.resize(C+1),this.emplace(C,l,u,m,x,b,T,A)}emplace(l,u,m,x,b,T,A,C){const O=10*l,$=5*l;return this.uint16[O+0]=u,this.uint16[O+1]=m,this.uint16[O+2]=x,this.uint16[O+3]=b,this.float32[$+2]=T,this.float32[$+3]=A,this.float32[$+4]=C,l}}Bb.prototype.bytesPerElement=20,_r(Bb,"StructArrayLayout4ui3f20");class $b extends Gs{_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}}$b.prototype.bytesPerElement=2,_r($b,"StructArrayLayout1i2");class zb extends Gs{_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}}zb.prototype.bytesPerElement=1,_r(zb,"StructArrayLayout1ub1");class wI extends O0{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]}}wI.prototype.size=40;class cj extends Db{get(l){return new wI(this,l)}}_r(cj,"CollisionBoxArray");class SI extends O0{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}}SI.prototype.size=60;class TI extends Ob{get(l){return new SI(this,l)}}_r(TI,"PlacedSymbolArray");class V0 extends O0{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]}}V0.prototype.size=80;class EI extends sj{get(l){return new V0(this,l)}}_r(EI,"SymbolInstanceArray");class jI extends Rc{getoffsetX(l){return this.float32[1*l+0]}}_r(jI,"GlyphOffsetArray");class q0 extends mc{getx(l){return this.int16[2*l+0]}gety(l){return this.int16[2*l+1]}}_r(q0,"SymbolLineVertexArray");class AI extends O0{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]}}AI.prototype.size=12;class uj extends oj{get(l){return new AI(this,l)}}_r(uj,"FeatureIndexArray");class kI extends vu{geta_centroid_pos0(l){return this.uint16[2*l+0]}geta_centroid_pos1(l){return this.uint16[2*l+1]}}_r(kI,"FillExtrusionCentroidArray");class dj extends O0{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]}}dj.prototype.size=6;class hj extends Od{get(l){return new dj(this,l)}}_r(hj,"FillExtrusionWallArray");const NI=Rn([{name:"a_pos",components:2,type:"Int16"}],4),l5=Rn([{name:"a_circle_z_offset",components:1,type:"Float32"}],4),c5=Rn([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]);class Cs{constructor(l=[]){this.segments=l}_prepareSegment(l,u,m,x,b){let T=this.segments[this.segments.length-1];return l>Cs.MAX_VERTEX_ARRAY_LENGTH&&$r(`Max vertices per segment is ${Cs.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${l}`),(!T||T.vertexLength+l>Cs.MAX_VERTEX_ARRAY_LENGTH||T.sortKey!==x||b!==void 0&&T&&T.batchIndex!==void 0&&T.batchIndex!==b)&&(T={vertexOffset:u,primitiveOffset:m,vertexLength:0,primitiveLength:0},x!==void 0&&(T.sortKey=x),b!==void 0&&(T.batchIndex=b),this.segments.push(T)),T}prepareSegment(l,u,m,x,b){return this._prepareSegment(l,u.length,m.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,m,x){return new Cs([{vertexOffset:l,primitiveOffset:u,vertexLength:m,primitiveLength:x,vaos:{},sortKey:0}])}}function Ub(h,l){return 256*(h=fe(Math.floor(h),0,255))+fe(Math.floor(l),0,255)}Cs.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,_r(Cs,"SegmentVector");const u5=Rn([{name:"a_pattern",components:4,type:"Uint16"},{name:"a_pixel_ratio",components:1,type:"Float32"}]),d5=Rn([{name:"a_pattern_b",components:4,type:"Uint16"}]),h5=Rn([{name:"a_dash",components:4,type:"Uint16"}]);class G0{constructor(){this.ids=[],this.uniqueIds=[],this.positions=[],this.indexed=!1}add(l,u,m,x){this.ids.push(fj(l)),this.positions.push(u,m,x)}eachPosition(l,u){const m=fj(l);let x=0,b=this.ids.length-1;for(;x>1;this.ids[T]>=m?b=T:x=T+1}for(;this.ids[x]===m;)u(this.positions[3*x],this.positions[3*x+1],this.positions[3*x+2]),x++}static serialize(l,u){const m=new Float64Array(l.ids),x=new Uint32Array(l.positions);return H0(m,x,0,m.length-1),u&&(u.add(m.buffer),u.add(x.buffer)),{ids:m,positions:x}}static deserialize(l){const u=new G0;let m;u.ids=l.ids,u.positions=l.positions;for(const x of u.ids)x!==m&&u.uniqueIds.push(x),m=x;return u.indexed=!0,u}}function fj(h){const l=+h;return Number.isSafeInteger(l)?l:kf(String(h))}function H0(h,l,u,m){for(;u>1];let b=u-1,T=m+1;for(;;){do b++;while(h[b]x);if(b>=T)break;Lc(h,b,T),Lc(l,3*b,3*T),Lc(l,3*b+1,3*T+1),Lc(l,3*b+2,3*T+2)}T-u`u_${b}`),this.type=m,this.context=x}setUniform(l,u,m,x,b){const T=x.constantOr(this.value);u.set(l,b,T instanceof Qn?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 m5(l):new fa(l)}}class z{constructor(l,u){this.uniformNames=u.map(m=>`u_${m}`),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,m,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 f5(l):new fa(l)}}class H{constructor(l,u,m,x){this.expression=l,this.type=m,this.maxValue=0,this.paintVertexAttributes=u.map(b=>({name:`a_${b}`,type:"Float32",components:m==="color"?2:1,offset:0})),this.paintVertexArray=new x}populatePaintArray(l,u,m,x,b,T,A,C){const O=this.paintVertexArray.length,$=this.expression.kind==="composite"||this.expression.kind==="source"?this.expression.evaluate(new as(0,{brightness:T,worldview:C}),u,{},b,x,A):this.expression.kind==="constant"&&this.expression.value,U=L(this.lutExpression,u,{},x,b,T,A,C);this.paintVertexArray.resize(l),this._setPaintValue(O,l,$,U?null:this.context.lut)}updatePaintArray(l,u,m,x,b,T,A,C){const O=this.expression.kind==="composite"||this.expression.kind==="source"?this.expression.evaluate({zoom:0,brightness:A,worldview:C},m,x,void 0,b):this.expression.kind==="constant"&&this.expression.value,$=L(this.lutExpression,m,x,b,void 0,A,void 0,C);this._setPaintValue(l,u,O,$?null:this.context.lut)}_setPaintValue(l,u,m,x){if(this.type==="color"){const b=I(m.toPremultipliedRenderColor(x));for(let T=l;T`u_${A}_t`),this.type=m,this.useIntegerZoom=x,this.context=b,this.maxValue=0,this.paintVertexAttributes=u.map(A=>({name:`a_${A}`,type:"Float32",components:m==="color"?4:2,offset:0})),this.paintVertexArray=new T}populatePaintArray(l,u,m,x,b,T,A,C){const O=this.expression.evaluate(new as(this.context.zoom,{brightness:T,worldview:C}),u,{},b,x,A),$=this.expression.evaluate(new as(this.context.zoom+1,{brightness:T,worldview:C}),u,{},b,x,A),U=L(this.lutExpression,u,{},x,b,T,A,C),q=this.paintVertexArray.length;this.paintVertexArray.resize(l),this._setPaintValue(q,l,O,$,U?null:this.context.lut)}updatePaintArray(l,u,m,x,b,T,A,C){const O=this.expression.evaluate({zoom:this.context.zoom,brightness:A,worldview:C},m,x,void 0,b),$=this.expression.evaluate({zoom:this.context.zoom+1,brightness:A,worldview:C},m,x,void 0,b),U=L(this.lutExpression,m,x,b,void 0,A,void 0,C);this._setPaintValue(l,u,O,$,U?null:this.context.lut)}_setPaintValue(l,u,m,x,b){if(this.type==="color"){const T=I(m.toPremultipliedRenderColor(b)),A=I(x.toPremultipliedRenderColor(b));for(let C=l;C!0){this.binders={},this._buffers=[],this.context=u;const x=[],b=l;for(const T in l.paint._values){const A=b.paint.get(T);if(T.endsWith("-use-theme")||!m(T)||!(A instanceof lp&&yb(A.property.specification)))continue;const C=oe(T,l.type),O=A.value,$=A.property.specification.type,U=!!A.property.useIntegerZoom,q=T==="line-dasharray"||T.endsWith("pattern"),K=b.paint.get(`${T}-use-theme`),X=T==="line-dasharray"&&b.layout.get("line-cap").value.kind!=="constant"||K&&K.value.kind!=="constant";if(O.kind!=="constant"||X)if(O.kind==="source"||X||q){const te=Pe(T,$,"source");this.binders[T]=q?new ne(O,C,$,te,l.id):new H(O,C,$,te),x.push(`/a_${T}`)}else{const te=Pe(T,$,"composite");this.binders[T]=new Z(O,C,$,U,u,te),x.push(`/z_${T}`)}else this.binders[T]=q?new z(O.value,C):new F(O.value,C,$,u),x.push(`/u_${T}`);K&&(this.binders[T].lutExpression=K.value)}this.cacheKey=x.sort().join("")}getMaxValue(l){const u=this.binders[l];return u instanceof H||u instanceof Z?u.maxValue:0}populatePaintArrays(l,u,m,x,b,T,A,C){for(const O in this.binders){const $=this.binders[O];$.context=this.context,($ instanceof H||$ instanceof Z||$ instanceof ne)&&$.populatePaintArray(l,u,m,x,b,T,A,C)}}setConstantPatternPositions(l,u){for(const m in this.binders){const x=this.binders[m];x instanceof z&&x.setConstantPatternPositions(l,u)}}getPatternTransitionVertexBuffer(l){const u=this.binders[l];return u instanceof ne?u.paintTransitionVertexBuffer:null}updatePaintArrays(l,u,m,x,b,T,A,C,O,$){let U=!1;const q=Object.keys(l),K=q.length!==0&&!C,X=K?q: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 H||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 he of X){const ue=l[he.toString()];u.eachPosition(he,(be,Ne,Ie)=>{const We=x.feature(be);se.updatePaintArray(Ne,Ie,We,ue,T,A,O,$)})}if(!K)for(const he of m.uniqueIds){const ue=l[he.toString()];m.eachPosition(he,(be,Ne,Ie)=>{const We=x.feature(be);se.updatePaintArray(Ne,Ie,We,ue,T,A,O,$)})}U=!0}}return U}defines(){const l=[];for(const u in this.binders){const m=this.binders[u];(m instanceof F||m instanceof z)&&l.push(...m.uniformNames.map(x=>`#define HAS_UNIFORM_${x}`))}return l}getPaintVertexBuffers(){return this._buffers}getUniforms(l){const u=[];for(const m in this.binders){const x=this.binders[m];if(x instanceof F||x instanceof z||x instanceof Z)for(const b of x.uniformNames)u.push({name:b,property:m,binding:x.getBinding(l,b)})}return u}setUniforms(l,u,m,x,b){for(const{name:T,property:A,binding:C}of m)this.binders[A].setUniform(l,C,b,x.get(A),T)}updatePaintBuffers(){this._buffers=[];for(const l in this.binders){const u=this.binders[l];(u instanceof H||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 m=this.binders[u];(m instanceof H||m instanceof Z||m instanceof ne)&&m.upload(l)}this.updatePaintBuffers()}destroy(){for(const l in this.binders){const u=this.binders[l];(u instanceof H||u instanceof Z||u instanceof ne)&&u.destroy()}}}class ie{constructor(l,u,m=()=>!0){this.programConfigurations={};for(const x of l)this.programConfigurations[x.id]=new re(x,u,m);this.needsUpload=!1,this._featureMap=new G0,this._featureMapWithoutIds=new G0,this._bufferOffset=0,this._idlessCounter=0}populatePaintArrays(l,u,m,x,b,T,A,C,O){for(const $ in this.programConfigurations)this.programConfigurations[$].populatePaintArrays(l,u,x,b,T,A,C,O);u.id!==void 0?this._featureMap.add(u.id,m,this._bufferOffset,l):(this._featureMapWithoutIds.add(this._idlessCounter,m,this._bufferOffset,l),this._idlessCounter+=1),this._bufferOffset=l,this.needsUpload=!0}updatePaintArrays(l,u,m,x,b,T,A,C){for(const O of m)this.needsUpload=this.programConfigurations[O.id].updatePaintArrays(l,this._featureMap,this._featureMapWithoutIds,u,O,x,b,T,A||0,C)||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 oe(h,l){return ce[h]||[h.replace(`${l}-`,"").replace(/-/g,"_")]}const xe={"line-pattern":{source:Fd,composite:Fd},"fill-pattern":{source:Fd,composite:Fd},"fill-extrusion-pattern":{source:Fd,composite:Fd},"line-dasharray":{source:Jg,composite:Jg}},ye={color:{source:dp,composite:Ih},number:{source:Rc,composite:dp}};function Pe(h,l,u){const m=xe[h];return m&&m[u]||ye[l][u]}_r(F,"ConstantBinder"),_r(z,"PatternConstantBinder"),_r(H,"SourceExpressionBinder"),_r(ne,"PatternCompositeBinder"),_r(Z,"CompositeExpressionBinder"),_r(re,"ProgramConfiguration",{omit:["_buffers"]}),_r(ie,"ProgramConfigurationSet");const Me=or/Math.PI/2,Se=64,Ze=[Se,32,16],$e=-Me,Ke=Me;function De(h,l,u,m=Me){return u=Xn(u),[h*Math.sin(u)*m,-l*m,h*Math.cos(u)*m]}function Be(h,l,u){return De(Math.cos(Xn(h)),Math.sin(Xn(h)),l,u)}const Ge=63710088e-1,at=2*Math.PI*Ge;class Qe{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 Qe(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,m=this.lat*u,x=l.lat*u,b=Math.sin(m)*Math.sin(x)+Math.cos(m)*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,m=u/Math.cos(Math.PI/180*this.lat);return new xt({lng:this.lng-m,lat:this.lat-u},{lng:this.lng+m,lat:this.lat+u})}toEcef(l){return Be(this.lat,this.lng,Me+l*Me/Ge)}static convert(l){if(l instanceof Qe)return l;if(Array.isArray(l)&&(l.length===2||l.length===3))return new Qe(Number(l[0]),Number(l[1]));if(!Array.isArray(l)&&typeof l=="object"&&l!==null)return new Qe(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 xt{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 Qe?new Qe(l.lng,l.lat):Qe.convert(l),this}setSouthWest(l){return this._sw=l instanceof Qe?new Qe(l.lng,l.lat):Qe.convert(l),this}extend(l){const u=this._sw,m=this._ne;let x,b;if(l instanceof Qe)x=l,b=l;else{if(!(l instanceof xt))return Array.isArray(l)?l.length===4||l.every(Array.isArray)?this.extend(xt.convert(l)):this.extend(Qe.convert(l)):typeof l=="object"&&l!==null&&l.hasOwnProperty("lat")&&(l.hasOwnProperty("lon")||l.hasOwnProperty("lng"))?this.extend(Qe.convert(l)):this;if(x=l._sw,b=l._ne,!x||!b)return this}return u||m?(u.lng=Math.min(x.lng,u.lng),u.lat=Math.min(x.lat,u.lat),m.lng=Math.max(b.lng,m.lng),m.lat=Math.max(b.lat,m.lat)):(this._sw=new Qe(x.lng,x.lat),this._ne=new Qe(b.lng,b.lat)),this}getCenter(){return new Qe((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 Qe(this.getWest(),this.getNorth())}getSouthEast(){return new Qe(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:m}=Qe.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<=m&&m<=this._ne.lat&&x}static convert(l){if(l)return l instanceof xt?l:new xt(l)}}function ft(h){return at*Math.cos(h*Math.PI/180)}function Lt(h){return(180+h)/360}function Bt(h){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+h*Math.PI/360)))/360}function lt(h,l){return h/ft(l)}function tt(h){return 360*h-180}function gt(h){return 360/Math.PI*Math.atan(Math.exp((180-360*h)*Math.PI/180))-90}function _t(h,l){return h*ft(gt(l))}const Tt=85.051129;function rr(h){return Math.cos(Xn(fe(h,-85.051129,Tt)))}function Wt(h,l){const u=fe(l,0,25.5),m=Math.pow(2,u);return rr(h)*at/(512*m)}function Kt(h){return 1/Math.cos(h*Math.PI/180)}function Ot(h,l=0){const u=Math.exp(Math.PI*(1-(h.y+l/or)/(1<=C?(Lr(h,l,u,O,$,b,U,A,C),Lr(h,O,$,m,x,U,T,A,C)):h.push(T)}function gr(h,l,u){let m=h[0],x=m.x,b=m.y;l(m);const T=[m];for(let A=1;Ah.x+1||mh.y+1)&&$r("Geometry exceeds allowed extent, reduce your vector tile buffer size"),h}function Ur(h,l,u){const m=h.loadGeometry(),x=h.extent,b=or/x;if(l&&u&&u.projection.isReprojectedInTileSpace){const T=1<{const K=tt((l.x+q.x/x)/T),X=gt((l.y+q.y/x)/T),te=$.project(K,X);q.x=(te.x*A-C)*x,q.y=(te.y*A-O)*x};for(let q=0;q=x||X.y<0||X.y>=x||(U(X),K.push(X));m[q]=K}}for(const T of m)for(const A of T)_n(A,b);return m}function bn(h,l){return{type:h.type,id:h.id,properties:h.properties,geometry:l?Ur(h):[]}}class rn{constructor(l,u,m,x,b){this.properties={},this.extent=m,this.type=0,this.id=void 0,this._pbf=l,this._geometry=-1,this._keys=x,this._values=b,l.readFields(Hn,this,u)}loadGeometry(){const l=this._pbf;l.pos=this._geometry;const u=l.readVarint()+l.pos,m=[];let x,b=1,T=0,A=0,C=0;for(;l.pos>3}if(T--,b===1||b===2)A+=l.readSVarint(),C+=l.readSVarint(),b===1&&(x&&m.push(x),x=[]),x&&x.push(new Ft(A,C));else{if(b!==7)throw new Error(`unknown command ${b}`);x&&x.push(x[0].clone())}}return x&&m.push(x),m}bbox(){const l=this._pbf;l.pos=this._geometry;const u=l.readVarint()+l.pos;let m=1,x=0,b=0,T=0,A=1/0,C=-1/0,O=1/0,$=-1/0;for(;l.pos>3}if(x--,m===1||m===2)b+=l.readSVarint(),T+=l.readSVarint(),bC&&(C=b),T$&&($=T);else if(m!==7)throw new Error(`unknown command ${m}`)}return[A,O,C,$]}toGeoJSON(l,u,m){const x=this.extent*Math.pow(2,m),b=this.extent*l,T=this.extent*u,A=this.loadGeometry();function C(q){return[360*(q.x+b)/x-180,360/Math.PI*Math.atan(Math.exp((1-2*(q.y+T)/x)*Math.PI))-90]}function O(q){return q.map(C)}let $;if(this.type===1){const q=[];for(const X of A)q.push(X[0]);const K=O(q);$=q.length===1?{type:"Point",coordinates:K[0]}:{type:"MultiPoint",coordinates:K}}else if(this.type===2){const q=A.map(O);$=q.length===1?{type:"LineString",coordinates:q[0]}:{type:"MultiLineString",coordinates:q}}else{if(this.type!==3)throw new Error("unknown feature type");{const q=function(X){const te=X.length;if(te<=1)return[X];const se=[];let ae,he;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 rn(this._pbf,u,this.extent,this._keys,this._values)}}function Is(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(m){let x=null;const b=m.readVarint()+m.pos;for(;m.pos>3;x=T===1?m.readString():T===2?m.readFloat():T===3?m.readDouble():T===4?m.readVarint64():T===5?m.readVarint():T===6?m.readSVarint():T===7?m.readBoolean():null}if(x==null)throw new Error("unknown feature value");return x}(u))}class ts{constructor(l,u){this.layers=l.readFields(gn,{},u)}}function gn(h,l,u){if(h===3){const m=new Xs(u,u.readVarint()+u.pos);m.length&&(l[m.name]=m)}}const yn="3d_elevation_id",Ps="level";class ni{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,m){return this.get(l,!0,u,m)}optional(l,u,m){return this.get(l,!1,u,m)}success(){return this._valid}get(l,u,m,x){const b=this.feature.properties.hasOwnProperty(l)?+this.feature.properties[l]:void 0;return this._valid&&b!==void 0&&!Number.isNaN(b)?m(x?x(b):b):u&&(this._valid=!1),this}}class rs{constructor(l,u){this.featureFunc=l,this.vertexFunc=u}parseFeature(l,u,m){return this.featureFunc(l,u,m)}parseVertex(l,u,m){return this.vertexFunc(l,u,m)}}const ln=new rs((h,l,u)=>h.reset(l).require(yn,m=>{u.id=m}).optional("fixed_height_relative",m=>{u.constantHeight=m},Ss.decodeRelativeHeight).geometry(m=>{u.bounds=m},iE).success(),(h,l,u)=>h.reset(l).require(yn,m=>{u.id=m}).require("elevation_idx",m=>{u.idx=m}).require("extent",m=>{u.extent=m}).require("height_relative",m=>{u.height=m},Ss.decodeRelativeHeight).geometry(m=>{u.position=m},Ss.getPoint).success()),Ys=new rs((h,l,u)=>h.reset(l).require(yn,m=>{u.id=m}).optional("fixed_height",m=>{u.constantHeight=m},Ss.decodeMetricHeight).geometry(m=>{u.bounds=m},iE).success(),(h,l,u)=>h.reset(l).require(yn,m=>{u.id=m}).require("elevation_idx",m=>{u.idx=m}).require("extent",m=>{u.extent=m}).require("height",m=>{u.height=m},Ss.decodeMetricHeight).geometry(m=>{u.position=m},Ss.getPoint).success());class Ss{static getPoint(l){return qn(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"?Ys:void 0:ln}static parse(l){const u=[],m=[],x=l.length,b=new ni;for(let T=0;T=0);if(b===0)return 0;b!==l.length&&(u=!1)}return u?2:1}function ma(h,l){for(const u of h.projections){const m=ra(l,h.points[0],u.axis);if(u.projection[1]m[1])return 0}return 1}function Ka(h,l){let u=0;const m=[0,0,0,0];for(let x=0;x=0&&u++;return u}class pc{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=us.fromPoints(this.points),this.projections=[],this.frustumEdges=[Pr([],this.points[2],this.points[3]),Pr([],this.points[0],this.points[3]),Pr([],this.points[4],this.points[0]),Pr([],this.points[5],this.points[1]),Pr([],this.points[6],this.points[2]),Pr([],this.points[7],this.points[3])];for(const m of this.frustumEdges){const x=[0,-m[2],m[1]],b=[m[2],0,-m[0]];this.projections.push({axis:x,projection:ra(this.points,this.points[0],x)}),this.projections.push({axis:b,projection:ra(this.points,this.points[0],b)})}}static fromInvProjectionMatrix(l,u,m,x){const b=Math.pow(2,m),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 $=ar([],O,l),U=1/$[3]/u*b;return(q=$)[0]=(K=$)[0]*(X=[U,U,x?1/$[3]:U,U])[0],q[1]=K[1]*X[1],q[2]=K[2]*X[2],q[3]=K[3]*X[3],q;var q,K,X}),A=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(O=>{const $=pt([],tr([],Pr([],T[O[0]],T[O[1]]),Pr([],T[O[2]],T[O[1]]))),U=-Ct($,T[O[1]]);return $.concat(U)}),C=[];for(let O=0;OO[1]||O[0]>C[1])return 0}return 1}containsPoint(l){for(const u of this.planes){const m=u[3];if(Ct([u[0],u[1],u[2]],l)+m<0)return!1}return!0}}class us{static fromPoints(l){const u=[1/0,1/0,1/0],m=[-1/0,-1/0,-1/0];for(const x of l)Ee(u,u,x),ve(m,m,x);return new us(u,m)}static fromTileIdAndHeight(l,u,m){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])]}}_r(us,"Aabb");class Mc{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,m=u[1],x=-u[0],b=(l.extent+1)*this.metersToTile;return[new Ft(Math.trunc(l.position[0]+m*b),Math.trunc(l.position[1]+x*b)),new Ft(Math.trunc(l.position[0]-m*b),Math.trunc(l.position[1]-x*b))]}next(){this.index++}valid(){return this.index{return A.a0?qe(C,C,1/O):we(C,0,0,1)}getSafeArea(){return this.safeArea}isTunnel(){return this.heightRange.max<=-5}getClosestEdge(l){if(this.edges.length===0)return;let u=0,m=Number.POSITIVE_INFINITY,x=0;const[b,T,A,C,O,$,U]=this._tmpVec2;Yi(U,l.x,l.y);const q=new Bi(U,null);for(let K=0;K0?Xr(C,A)/be:0,Ie=fe(Ne,0,1),We=Math.abs((Ne-Ie)*this.edgeProps[K].len);So(O,U,se),Yi($,te[1],-te[0]);const ze=We+Math.abs(Xr(O,$));ze=0;--T){const A=this.edges[T].a,C=this.edges[T].b,{position:O,height:$,extent:U}=this.vertices[A],{position:q,height:K,extent:X}=this.vertices[C],te=this.vertexProps[A].dir,se=this.vertexProps[C].dir;if(we(u,O[0]/l,O[1]/l,$),we(m,q[0]/l,q[1]/l,K),we(x,te[1],-te[0],0),qe(x,x,U),we(b,se[1],-se[0],0),qe(b,b,X),this.distSqLines(ke(u[0]+.5*x[0],u[1]+.5*x[1],u[2]+.5*x[2]),ke(m[0]-.5*b[0],m[1]-.5*b[1],m[2]-.5*b[2]),ke(u[0]-.5*x[0],u[1]-.5*x[1],u[2]-.5*x[2]),ke(m[0]+.5*b[0],m[1]+.5*b[1],m[2]+.5*b[2]))<=.0025000000000000005)continue;const ae=this.vertices.length,he=ja(Nr(),O,q);this.vertices.push({position:Zr(he,he,.5),height:.5*($+K),extent:.5*(U+X)});const ue=ja(Nr(),te,se);this.vertexProps.push({dir:xn(ue,ue)}),this.edges.splice(T,1),this.edgeProps.splice(T,1),this.edges.push({a:A,b:ae}),this.edges.push({a:ae,b:C});const be=So(Nr(),this.vertices[ae].position,O),Ne=fn(be),Ie={vec:be,dir:Zr(Nr(),be,1/Ne),len:Ne};this.edgeProps.push(Ie),this.edgeProps.push(Ie)}}distSqLines(l,u,m,x){const b=je(Te(),u,l),T=je(Te(),x,m),A=je(Te(),l,m),C=Ct(b,b),O=Ct(b,T),$=Ct(b,A),U=Ct(T,T),q=Ct(T,A),K=C*U-O*O;if(K===0)return jt(wt(b,m,x,Ct(A,T)/Ct(T,T)),l);const X=(C*q-O*$)/K;return jt(wt(b,l,u,(O*q-$*U)/K),wt(T,m,x,X))}}class Os{static parseFrom(l,u){const m=Ss.parse(l);if(!m)return[];let{vertices:x,features:b}=m;const T=1/Ot(u);b.sort(($,U)=>$.id-U.id),x.sort(($,U)=>$.id-U.id||$.idx-U.idx),x=x.filter(($,U,q)=>U===q.findIndex(K=>K.id===$.id&&K.idx===$.idx));const A=new Array;let C=0;const O=x.length;for(const $ of b){if($.constantHeight){A.push(new Dc($.id,$.bounds,$.constantHeight));continue}for(;C!==O&&x[C].id<$.id;)C++;if(C===O||x[C].id!==$.id)continue;const U=new Array,q=new Array,K=C;for(;C!==O&&x[C].id===$.id;){const X=x[C];if(U.push({position:X.position,height:X.height,extent:X.extent}),C!==K&&x[C-1].idx===X.idx-1){const te=C-K;q.push({a:te-1,b:te})}C++}A.push(new Dc($.id,$.bounds,void 0,U,q,T))}return A}static getElevationFeature(l,u){if(!u)return;const m=+l.properties[yn];return Number.isNaN(m)?void 0:u.find(x=>x.id===m)}}class Vs{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)*or,this.yOffset=(l.y*this.zScale-u.y)*or)}constantElevation(l,u){if(l.constantHeight!=null)return this.computeBiasedHeight(l.constantHeight,u)}pointElevation(l,u,m){const x=this.constantElevation(u,m);return x??(l.x=l.x*this.zScale+this.xOffset,l.y=l.y*this.zScale+this.yOffset,this.computeBiasedHeight(u.pointElevation(l),m))}computeBiasedHeight(l,u){return u<=0?l:l+u*Oe(0,u,l>=0?l:Math.abs(.5*l))}}_r(Dc,"ElevationFeature");class ys{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 mc,this.indexArray=new bi,this.segments=new Cs,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 Rc),this.worldview=l.worldview,this.hasAppearances=null}updateFootprints(l,u){}updateAppearances(l,u,m,x){return{hasLayoutChanges:!1,hasUboChanges:!1}}populate(l,u,m,x){const b=this.layers[0],T=[];let A=null;b.type==="circle"&&(A=b.layout.get("circle-sort-key"));for(const{feature:O,id:$,index:U,sourceLayerIndex:q}of l){const K=this.layers[0]._featureFilter.needGeometry,X=bn(O,K);if(!this.layers[0]._featureFilter.filter(new as(this.zoom,{worldview:this.worldview,activeFloors:u.activeFloors}),X,m))continue;const te=A?A.evaluate(X,{},m):void 0,se={id:$,properties:O.properties,type:O.type,sourceLayerIndex:q,index:U,geometry:K?X.geometry:Ur(O,m,x),patterns:{},sortKey:te};T.push(se)}A&&T.sort((O,$)=>O.sortKey-$.sortKey);let C=null;x.projection.name==="globe"&&(this.globeExtVertexArray=new Mb,C=x.projection);for(const O of T){const{geometry:$,index:U,sourceLayerIndex:q}=O,K=l[U].feature;this.addFeature(O,$,U,u.availableImages,m,C,u.brightness,u.elevationFeatures),u.featureIndex.insert(K,$,U,q,this.index)}this.hasElevation||(this.elevatedLayoutVertexArray=void 0)}update(l,u,m,x,b,T,A){this.programConfigurations.updatePaintArrays(l,u,b,m,x,T,A,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,NI.members),this.indexBuffer=l.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=l.createVertexBuffer(this.globeExtVertexArray,c5.members)),this.elevatedLayoutVertexArray&&(this.elevatedLayoutVertexBuffer=l.createVertexBuffer(this.elevatedLayoutVertexArray,l5.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,m,x,b,T,A,C){let O;this.elevationMode!=="none"&&(O=Os.getElevationFeature(l,C));for(const $ of u)for(const U of $){const q=U.x,K=U.y;if(q<0||q>=or||K<0||K>=or)continue;if(T){const se=T.projectTilePoint(q,K,b),ae=T.upVector(b,q,K);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(q,K,-1,-1),this.addCircleVertex(q,K,1,-1),this.addCircleVertex(q,K,1,1),this.addCircleVertex(q,K,-1,1),this.elevationMode!=="none"){const se=O?O.pointElevation(new Ft(q,K)):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,m,{},x,b,A,void 0,this.worldview)}addCircleVertex(l,u,m,x){this.layoutVertexArray.emplaceBack(2*l+(m+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 Ri(h,l){for(let u=0;u1){if(Ff(h,l))return!0;for(let m=0;m1?u:u.sub(l)._mult(x)._add(l))}function ty(h,l){let u,m,x,b=!1;for(let T=0;Tl.y!=x.y>l.y&&l.x<(x.x-m.x)*(l.y-m.y)/(x.y-m.y)+m.x&&(b=!b)}return b}function ql(h,l){let u=!1;for(let m=0,x=h.length-1;ml.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 Bf(h,l,u,m,x){for(const T of h)if(l<=T.x&&u<=T.y&&m>=T.x&&x>=T.y)return!0;const b=[new Ft(l,u),new Ft(l,x),new Ft(m,x),new Ft(m,u)];if(h.length>2){for(const T of b)if(ql(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=on(h,l,u[0]);return b!==on(h,l,u[1])||b!==on(h,l,u[2])||b!==on(h,l,u[3])}function zf(h,l,u,m,x,b){let T=l.y-h.y,A=h.x-l.x;if(b=b||0){const C=T*T+A*A;if(C===0)return!0;const O=Math.sqrt(C);T/=O,A/=O}return!((u.x-h.x)*T+(u.y-h.y)*A-b<0||(m.x-h.x)*T+(m.y-h.y)*A-b<0||(x.x-h.x)*T+(x.y-h.y)*A-b<0)}function qb(h,l,u,m,x,b,T){return!(zf(h,l,m,x,b,T)||zf(l,u,m,x,b,T)||zf(u,h,m,x,b,T)||zf(m,x,h,l,u,T)||zf(x,b,h,l,u,T)||zf(b,m,h,l,u,T))}function ry(h,l,u){const m=l.paint.get(h).value;return m.kind==="constant"?m.value:u.programConfigurations.get(l.id).getMaxValue(h)}function CI(h){return Math.sqrt(h[0]*h[0]+h[1]*h[1])}function wY(h,l,u,m,x){if(!l[0]&&!l[1])return h;const b=Ft.convert(l)._mult(x);u==="viewport"&&b._rotate(-m);const T=[];for(let A=0;A>u&&l.y===this.y>>u}url(l,u){const m=function(b,T,A){const C=2**A,O=2*Math.PI*6378137,$=O*(b/C-.5),U=O*(.5-(T+1)/C);return`${$},${U},${$+O/C},${U+O/C}`}(this.x,this.y,this.z),x=function(b,T,A){let C,O="";for(let $=b;$>0;$--)C=1<<$-1,O+=(T&C?1:0)+(A&C?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}",m)}toString(){return`${this.z}/${this.x}/${this.y}`}}class jY{constructor(l,u){this.wrap=l,this.canonical=u,this.key=Gb(l,u.z,u.z,u.x,u.y)}}class Tl{constructor(l,u,m,x,b){this.overscaledZ=l,this.wrap=u,this.canonical=new Y0(m,+x,+b),this.key=u===0&&l===m?this.canonical.key:Gb(u,l,m,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 Tl(l,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new Tl(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 Gb(this.wrap*+u,l,this.canonical.z,this.canonical.x,this.canonical.y);{const m=this.canonical.z-l;return Gb(this.wrap*+u,l,l,this.canonical.x>>m,this.canonical.y>>m)}}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 Tl(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const u=this.canonical.z+1,m=2*this.canonical.x,x=2*this.canonical.y;return[new Tl(u,this.wrap,u,m,x),new Tl(u,this.wrap,u,m+1,x),new Tl(u,this.wrap,u,m,x+1),new Tl(u,this.wrap,u,m+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 Tl(h.overscaledZ,h.wrap,h.canonical.z,h.canonical.x,(h.canonical.y===0?1<new Tl(h.overscaledZ,h.wrap,h.canonical.z,h.canonical.x,h.canonical.y===(1<1?null:function(m,x,b,T){const A=Math.sin(b);return m*(Math.sin((1-T)*b)/A)+x*(Math.sin(T*b)/A)}(h.a[l],h.b[l],h.angle,fe(u,0,1))+h.center[l]}function Uf(h){if(h.z<=1)return xke[h.z+2*h.y+h.x];const l=g5(RI(h));return us.fromPoints(l)}function pp(h,l,u){return qe(h,h,1-u),nt(h,h,l,u)}function NY(h,l){const u=gp(l.zoom);if(u===0)return Uf(h);const m=RI(h),x=g5(m),b=Lt(m.getWest())*l.worldSize,T=Lt(m.getEast())*l.worldSize,A=Bt(m.getNorth())*l.worldSize,C=Bt(m.getSouth())*l.worldSize,O=[b,A,0],$=[T,A,0],U=[b,C,0],q=[T,C,0],K=M([],l.globeMatrix);return lr(O,O,K),lr($,$,K),lr(U,U,K),lr(q,q,K),x[0]=pp(x[0],U,u),x[1]=pp(x[1],q,u),x[2]=pp(x[2],$,u),x[3]=pp(x[3],O,u),us.fromPoints(x)}function CY(h,l,u){for(const m of h)lr(m,m,l),qe(m,m,u)}function IY(h,l,u,m){const x=l/h.worldSize,b=h.globeMatrix;if(u.z<=1){const He=Uf(u).getCorners();return CY(He,b,x),us.fromPoints(He)}const T=RI(u,m),A=g5(T,Me+PI(h._tileCoverLift));CY(A,b,x);const C=Number.MAX_VALUE,O=[-C,-C,-C],$=[C,C,C];if(T.contains(h.center)){for(const Ve of A)Ee($,$,Ve),ve(O,O,Ve);O[2]=0;const He=h.point,Ue=[He.x*x,He.y*x,0];return Ee($,$,Ue),ve(O,O,Ue),new us($,O)}if(h._tileCoverLift>0){for(const He of A)Ee($,$,He),ve(O,O,He);return new us($,O)}const U=[b[12]*x,b[13]*x,b[14]*x],q=T.getCenter(),K=fe(h.center.lat,-85.051129,Tt),X=fe(q.lat,-85.051129,Tt),te=Lt(h.center.lng),se=Bt(K);let ae=te-Lt(q.lng);const he=se-Bt(X);ae>.5?ae-=1:ae<-.5&&(ae+=1);let ue=0;Math.abs(ae)>Math.abs(he)?ue=ae>=0?1:3:(ue=he>=0?0:2,nt(U,U,[b[4]*x,b[5]*x,b[6]*x],-Math.sin(Xn(he>=0?T.getSouth():T.getNorth()))*Me));const be=A[ue],Ne=A[(ue+1)%4],Ie=new vke(be,Ne,U),We=[p5(Ie,0)||be[0],p5(Ie,1)||be[1],p5(Ie,2)||be[2]],ze=gp(h.zoom);if(ze>0){const He=function({x:Ve,y:yt,z:bt},At,Pt,kt,zt){const mt=1/(1<.5?xr=-1:sr<-.5&&(xr=1),Nt=((Nt+xr)*At-(kt*=At))*Pt+kt,Mt=((Mt+xr)*At-kt)*Pt+kt,Vt=(Vt*At-(zt*=At))*Pt+zt,Yt=(Yt*At-zt)*Pt+zt,[[Nt,Yt,0],[Mt,Yt,0],[Mt,Vt,0],[Nt,Vt,0]]}(u,l,h._pixelsPerMercatorPixel,te,se);for(let Ve=0;VeMath.PI/2*1.01}const DY=Xn(85),_ke=Math.cos(DY),bke=Math.sin(DY),wke=k(),OY=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 FY(h,l,u,m,x,b,T,A,C){if(b&&h.queryGeometry.isAboveHorizon)return!1;b&&(C*=h.pixelToTileUnitsFactor);const O=h.tileID.canonical,$=u.projection.upVectorScale(O,u.center.lat,u.worldSize).metersToTile;for(const U of l)for(const q of U){const K=q.add(A),X=x&&u.elevation?u.elevation.exaggeration()*x.getElevationAt(K.x,K.y,!0):0,te=u.projection.projectTilePoint(K.x,K.y,O);if(X>0){const ue=u.projection.upVector(O,K.x,K.y);te.x+=ue[0]*$*X,te.y+=ue[1]*$*X,te.z+=ue[2]*$*X}const se=b?K:Ske(te.x,te.y,te.z,m),ae=b?h.tilespaceRays.map(ue=>Eke(ue,X)):h.queryGeometry.screenGeometry,he=ar([],[te.x,te.y,te.z,1],m);if(!T&&b?C*=he[3]/u.cameraToCenterDistance:T&&!b&&(C*=u.cameraToCenterDistance/he[3]),b){const ue=gt((q.y/or+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||m.x>l.width-x.width||m.y>l.height-x.height)throw new RangeError("out of range destination coordinates for image copy");const C=h.data,O=l.data,$=b===4&&A;for(let U=0;U{l[h.evaluationKey]=C;const O=h.expression.evaluate(l),$=O?O.toNonPremultipliedRenderColor(null):null;$&&(x.data[T+A+0]=Math.floor(255*$.r),x.data[T+A+1]=Math.floor(255*$.g),x.data[T+A+2]=Math.floor(255*$.b),x.data[T+A+3]=Math.floor(255*$.a))};if(h.clips)for(let T=0,A=0;T80*u){A=h[0],C=h[1];let $=A,U=C;for(let q=u;q$&&($=K),X>U&&(U=X)}O=Math.max($-A,U-C),O=O!==0?32767/O:0}return xj(b,T,u,A,C,O,0),T}function KY(h,l,u,m,x){let b;if(x===function(T,A,C,O){let $=0;for(let U=A,q=C-O;U0)for(let T=l;T=l;T-=m)b=QY(T/m|0,h[T],h[T+1],b);return b&&Wb(b,b.next)&&(bj(b),b=b.next),b}function Z0(h,l){if(!h)return h;l||(l=h);let u,m=h;do if(u=!1,m.steiner||!Wb(m,m.next)&&Ya(m.prev,m,m.next)!==0)m=m.next;else{if(bj(m),m=l=m.prev,m===m.next)break;u=!0}while(u||m!==l);return l}function xj(h,l,u,m,x,b,T){if(!h)return;!T&&b&&function(C,O,$,U){let q=C;do q.z===0&&(q.z=b5(q.x,q.y,O,$,U)),q.prevZ=q.prev,q.nextZ=q.next,q=q.next;while(q!==C);q.prevZ.nextZ=null,q.prevZ=null,function(K){let X,te=1;do{let se,ae=K;K=null;let he=null;for(X=0;ae;){X++;let ue=ae,be=0;for(let Ie=0;Ie0||Ne>0&&ue;)be!==0&&(Ne===0||!ue||ae.z<=ue.z)?(se=ae,ae=ae.nextZ,be--):(se=ue,ue=ue.nextZ,Ne--),he?he.nextZ=se:K=se,se.prevZ=he,he=se;ae=ue}he.nextZ=null,te*=2}while(X>1)}(q)}(h,m,x,b);let A=h;for(;h.prev!==h.next;){const C=h.prev,O=h.next;if(b?Ike(h,m,x,b):Cke(h))l.push(C.i,h.i,O.i),bj(h),h=O.next,A=O.next;else if((h=O)===A){T?T===1?xj(h=Pke(Z0(h),l),l,u,m,x,b,2):T===2&&Rke(h,l,u,m,x,b):xj(Z0(h),l,u,m,x,b,1);break}}}function Cke(h){const l=h.prev,u=h,m=h.next;if(Ya(l,u,m)>=0)return!1;const x=l.x,b=u.x,T=m.x,A=l.y,C=u.y,O=m.y,$=Math.min(x,b,T),U=Math.min(A,C,O),q=Math.max(x,b,T),K=Math.max(A,C,O);let X=m.next;for(;X!==l;){if(X.x>=$&&X.x<=q&&X.y>=U&&X.y<=K&&vj(x,A,b,C,T,O,X.x,X.y)&&Ya(X.prev,X,X.next)>=0)return!1;X=X.next}return!0}function Ike(h,l,u,m){const x=h.prev,b=h,T=h.next;if(Ya(x,b,T)>=0)return!1;const A=x.x,C=b.x,O=T.x,$=x.y,U=b.y,q=T.y,K=Math.min(A,C,O),X=Math.min($,U,q),te=Math.max(A,C,O),se=Math.max($,U,q),ae=b5(K,X,l,u,m),he=b5(te,se,l,u,m);let ue=h.prevZ,be=h.nextZ;for(;ue&&ue.z>=ae&&be&&be.z<=he;){if(ue.x>=K&&ue.x<=te&&ue.y>=X&&ue.y<=se&&ue!==x&&ue!==T&&vj(A,$,C,U,O,q,ue.x,ue.y)&&Ya(ue.prev,ue,ue.next)>=0||(ue=ue.prevZ,be.x>=K&&be.x<=te&&be.y>=X&&be.y<=se&&be!==x&&be!==T&&vj(A,$,C,U,O,q,be.x,be.y)&&Ya(be.prev,be,be.next)>=0))return!1;be=be.nextZ}for(;ue&&ue.z>=ae;){if(ue.x>=K&&ue.x<=te&&ue.y>=X&&ue.y<=se&&ue!==x&&ue!==T&&vj(A,$,C,U,O,q,ue.x,ue.y)&&Ya(ue.prev,ue,ue.next)>=0)return!1;ue=ue.prevZ}for(;be&&be.z<=he;){if(be.x>=K&&be.x<=te&&be.y>=X&&be.y<=se&&be!==x&&be!==T&&vj(A,$,C,U,O,q,be.x,be.y)&&Ya(be.prev,be,be.next)>=0)return!1;be=be.nextZ}return!0}function Pke(h,l){let u=h;do{const m=u.prev,x=u.next.next;!Wb(m,x)&&ZY(m,u,u.next,x)&&_j(m,x)&&_j(x,m)&&(l.push(m.i,u.i,x.i),bj(u),bj(u.next),u=h=x),u=u.next}while(u!==h);return Z0(u)}function Rke(h,l,u,m,x,b){let T=h;do{let A=T.next.next;for(;A!==T.prev;){if(T.i!==A.i&&Fke(T,A)){let C=XY(T,A);return T=Z0(T,T.next),C=Z0(C,C.next),xj(T,l,u,m,x,b,0),void xj(C,l,u,m,x,b,0)}A=A.next}T=T.next}while(T!==h)}function Lke(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 Mke(h,l){const u=function(x,b){let T=b;const A=x.x,C=x.y;let O,$=-1/0;if(Wb(x,T))return T;do{if(Wb(x,T.next))return T.next;if(C<=T.y&&C>=T.next.y&&T.next.y!==T.y){const te=T.x+(C-T.y)*(T.next.x-T.x)/(T.next.y-T.y);if(te<=A&&te>$&&($=te,O=T.x=T.x&&T.x>=q&&A!==T.x&&YY(CO.x||T.x===O.x&&Dke(O,T)))&&(O=T,X=te)}T=T.next}while(T!==U);return O}(h,l);if(!u)return l;const m=XY(u,h);return Z0(m,m.next),Z0(u,u.next)}function Dke(h,l){return Ya(h.prev,h,l.prev)<0&&Ya(l.next,h,h.next)<0}function b5(h,l,u,m,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-m)*x|0)|l<<8))|l<<4))|l<<2))|l<<1))<<1}function Oke(h){let l=h,u=h;do(l.x=(h-T)*(b-A)&&(h-T)*(m-A)>=(u-T)*(l-A)&&(u-T)*(b-A)>=(x-T)*(m-A)}function vj(h,l,u,m,x,b,T,A){return!(h===T&&l===A)&&YY(h,l,u,m,x,b,T,A)}function Fke(h,l){return h.next.i!==l.i&&h.prev.i!==l.i&&!function(u,m){let x=u;do{if(x.i!==u.i&&x.next.i!==u.i&&x.i!==m.i&&x.next.i!==m.i&&ZY(x,x.next,u,m))return!0;x=x.next}while(x!==u);return!1}(h,l)&&(_j(h,l)&&_j(l,h)&&function(u,m){let x=u,b=!1;const T=(u.x+m.x)/2,A=(u.y+m.y)/2;do x.y>A!=x.next.y>A&&x.next.y!==x.y&&T<(x.next.x-x.x)*(A-x.y)/(x.next.y-x.y)+x.x&&(b=!b),x=x.next;while(x!==u);return b}(h,l)&&(Ya(h.prev,h,l.prev)||Ya(h,l.prev,l))||Wb(h,l)&&Ya(h.prev,h,h.next)>0&&Ya(l.prev,l,l.next)>0)}function Ya(h,l,u){return(l.y-h.y)*(u.x-l.x)-(l.x-h.x)*(u.y-l.y)}function Wb(h,l){return h.x===l.x&&h.y===l.y}function ZY(h,l,u,m){const x=DI(Ya(h,l,u)),b=DI(Ya(h,l,m)),T=DI(Ya(u,m,h)),A=DI(Ya(u,m,l));return x!==b&&T!==A||!(x!==0||!MI(h,u,l))||!(b!==0||!MI(h,m,l))||!(T!==0||!MI(u,h,m))||!(A!==0||!MI(u,l,m))}function MI(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 DI(h){return h>0?1:h<0?-1:0}function _j(h,l){return Ya(h.prev,h,h.next)<0?Ya(h,l,h.next)>=0&&Ya(h,h.prev,l)>=0:Ya(h,l,h.prev)<0||Ya(h,h.next,l)<0}function XY(h,l){const u=w5(h.i,h.x,h.y),m=w5(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,m.next=u,u.prev=m,b.next=m,m.prev=b,m}function QY(h,l,u,m){const x=w5(h,l,u);return m?(x.next=m.next,x.prev=m,m.next.prev=x,m.next=x):(x.prev=x,x.next=x),x}function bj(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 w5(h,l,u){return{i:h,x:l,y:u,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function wj(h,l){const u=h.length;if(u<=1)return[h];const m=[];let x,b;for(let T=0;T1)for(let T=0;T=or&&u>=or}static evaluate(l){if(l.length===0)return new yp;let u=[];for(const C of l)u.push(...C.portals);if(u.length===0)return new yp;for(const C of u){const O=C.va,$=C.vb;(yp.isOnBorder(O.x,$.x)||yp.isOnBorder(O.y,$.y))&&(C.type="border")}const m=u.filter(C=>C.type!=="unevaluated"),x=u.filter(C=>C.type==="unevaluated");if(x.length===0)return new yp;x.sort((C,O)=>C.hash===O.hash?C.isTunnel===O.isTunnel?0:C.isTunnel?-1:1:C.hashC.hashb!=="fill-tunnel-structure-color"),this.tunnelProgramConfigurations=new ie(u,{zoom:m,lut:x},b=>b!=="fill-bridge-guard-rail-color")}addVertices(l,u){const m=this.unevalVertices.length;for(let x=0;x=b.min.x&&U.x<=b.max.x&&U.y>=b.min.y&&U.y<=b.max.y||q.x>=b.min.x&&q.x<=b.max.x&&q.y>=b.min.y&&q.y<=b.max.y||$f(U,q,A))||this.isOnBorder(U.x,q.x)||this.isOnBorder(U.y,q.y))continue;const K=Oc.computeEdgeHash(this.unevalVertices[O],this.unevalVertices[$]);let X,te=this.vertexHashLookup.get(Oc.computePosHash(U));te!=null?X=te.next:(te=this.vertexHashLookup.get(Oc.computePosHash(q)),X=te!=null?te.prev:K),this.unevalEdges.push({polygonIdx:l,a:O,b:$,hash:K,portalHash:X,isTunnel:x,type:"unevaluated",featureInfo:T})}}addPortalCandidates(l,u,m,x,b){if(u.length!==0){this.vertexHashLookup.clear();for(const T of u){if(T.length===0)continue;const A=T[0];let C=Oc.computeEdgeHash(A[A.length-2],A[A.length-1]);for(let O=0;O({vertexOffset:0,primitiveOffset:this.indexArray.length}),m=q=>{q.primitiveLength=this.indexArray.length-q.primitiveOffset},x=new $ke(this.vertexPositions,this.vertexNormals,this.indexArray);this.prepareEdges(l.portals,this.unevalEdges);const b=u(),T=u(),A=u(),C=(q,K)=>{q.sort((te,se)=>te.type===K&&se.type!==K?-1:te.type!==K&&se.type===K?1:0);const X=q.findIndex(te=>te.type!==K);return X>=0?X:q.length};let O=0;this.unevalEdges.length>0&&(O=C(this.unevalEdges,"none"),this.constructBridgeStructures(x,this.unevalVertices,this.unevalHeights,this.unevalEdges,{min:0,max:O},this.tileToMeters)),m(A);const $=u(),U=u();if(this.unevalEdges.length>0){const q=this.unevalEdges.splice(O),K=C(q,"tunnel")+O;this.unevalEdges.push(...q),this.constructTunnelStructures(x,this.unevalVertices,this.unevalHeights,this.unevalEdges,{min:0,max:O},{min:O,max:K})}m($),x.addTriangles(this.unevalTriangles,this.unevalVertices,this.unevalHeights),m(U),x.addTriangles(this.unevalTunnelTriangles,this.unevalVertices,this.unevalHeights),m(T),x.addTriangles(this.unevalTunnelTriangles,this.unevalVertices,[-.1]),m(b),this.maskSegments=Cs.simpleSegment(0,U.primitiveOffset,0,U.primitiveLength),this.depthSegments=Cs.simpleSegment(0,T.primitiveOffset,0,T.primitiveLength),this.renderableBridgeSegments=Cs.simpleSegment(0,A.primitiveOffset,0,A.primitiveLength),this.renderableTunnelSegments=Cs.simpleSegment(0,$.primitiveOffset,0,$.primitiveLength),this.shadowCasterSegments=Cs.simpleSegment(0,b.primitiveOffset,0,b.primitiveLength)}update(l,u,m,x,b,T,A,C){this.bridgeProgramConfigurations.updatePaintArrays(l,u,b,m,x,T,A,C),this.tunnelProgramConfigurations.updatePaintArrays(l,u,b,m,x,T,A,C)}upload(l){this.vertexBuffer||this.vertexPositions.length===0||this.vertexNormals.length===0||this.indexArray.length===0||(this.vertexBuffer=l.createVertexBuffer(this.vertexPositions,kke.members),this.vertexBufferNormal=l.createVertexBuffer(this.vertexNormals,Nke.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,m,x,b){const T=(A,C)=>{for(let O=0;Owe(Pt,u[kt].x,u[kt].y,m[kt]*C),U=Te(),q=Te(),K=Te(),X=Te(),te=Te(),se=(Pt,kt)=>{const zt=A.get(Oc.computePosHash(u[kt])),mt=zt.from,Nt=zt.to;if(!mt||!Nt)return;$(U,mt),$(q,kt),$(K,Nt),cr(X),yr(U,q)||(Pr(te,q,U),pt(X,te)),yr(K,q)||(Pr(te,K,q),me(X,X,pt(te,te)));const Mt=Je(X);return Mt>0?qe(Pt,X,1/Mt):void 0};let ae=Number.POSITIVE_INFINITY;this.sortSubarray(x,b.min,b.max,(Pt,kt)=>Pt.featureInfo.featureIndex-kt.featureInfo.featureIndex);const he=Te(),ue=Te(),be=Te(),Ne=Te(),Ie=Te(),We=Te(),ze=Te(),He=Te(),Ue=Te(),Ve=[Te(),Te(),Te(),Te()],yt=[Te(),Te(),Te(),Te()],bt=[{coord:new Ft(0,0),height:0},{coord:new Ft(0,0),height:0}],At=(Pt,kt)=>Pt>kt;for(let Pt=b.min;Ptae.featureInfo.featureIndex-he.featureInfo.featureIndex;this.sortSubarray(x,b.min,b.max,C),this.sortSubarray(x,T.min,T.max,C);const O=ae=>pt(ae,ae),$=[{coord:new Ft(0,0),height:0},{coord:new Ft(0,0),height:0}],U=(ae,he)=>aeA.hash===C.hash?C.polygonIdx-A.polygonIdx:C.hash>A.hash?1:-1);let m=0,x=0,b=0,T=u[m].polygonIdx;do x++,(x===u.length||u[m].hash!==u[x].hash)&&((x-m===1||u[x-1].polygonIdx!==T)&&(bO.portalHash<$.portalHash?1:-1);let A=0,C=0;for(;A!==u.length&&C!==l.length;){const O=u[A],$=l[C];O.portalHash>$.hash?A++:$.hash>O.portalHash?C++:(O.type=$.type,A++)}}}isOnBorder(l,u){return l<=0&&u<=0||l>=or&&u>=or}addFeatureSection(l,u,m,x){return l!==u&&(u=l,m.push({featureIndex:l,vertexStart:x.getVertexCount()}),x.clearVertexLookup()),u}sortSubarray(l,u,m,x){const b=l.slice(u,m);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(Oc.computePosHash(l))<<32n|BigInt(Oc.computePosHash(u))}static computePosHash(l){return((65535&l.x)<<16|65535&l.y)>>>0}}function zke(h,l){return h>l?1:h0))return u;u=u.left}}return null}contains(l){for(var u=this._root,m=this._compare;u;){var x=m(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 m=this.minNode(u.right);m.parent!==u&&(this.replace(m,m.right),m.right=u.right,m.right.parent=m),this.replace(u,m),m.left=u.left,m.left.parent=m}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 m=u.left,x=u.right,b=null;m&&(m.parent=null,b=this.maxNode(m),this.splay(b),this._root=b),x&&(m?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,m=[],x=!1,b=0;!x;)u?(m.push(u),u=u.left):m.length>0?(l(u=m.pop(),b++),u=u.right):x=!0;return this}range(l,u,m,x){const b=[],T=this._compare;let A,C=this._root;for(;b.length!==0||C;)if(C)b.push(C),C=C.left;else{if(C=b.pop(),A=T(C.key,u),A>0)break;if(T(C.key,l)>=0&&m.call(x,C))return this;C=C.right}return this}keys(){for(var l=this._root,u=[],m=[],x=!1;!x;)l?(u.push(l),l=l.left):u.length>0?(l=u.pop(),m.push(l.key),l=l.right):x=!0;return m}values(){for(var l=this._root,u=[],m=[],x=!1;!x;)l?(u.push(l),l=l.left):u.length>0?(l=u.pop(),m.push(l.data),l=l.right):x=!0;return m}at(l){for(var u=this._root,m=[],x=!1,b=0;!x;)if(u)m.push(u),u=u.left;else if(m.length>0){if(u=m.pop(),b===l)return u;b++,u=u.right}else x=!0;return null}load(l=[],u=[],m=!1){if(this._size!==0)throw new Error("bulk-load: tree is not empty");const x=l.length;return m&&A5(l,u,0,x-1,this._compare),this._root=j5(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,m,x,b){return new E5(m,b).load(l,u,x)}}function j5(h,l,u,m,x){const b=x-m;if(b>0){const T=m+Math.floor(b/2),A={key:l[T],data:u[T],parent:h};return A.left=j5(A,l,u,m,T),A.right=j5(A,l,u,T+1,x),A}return null}function A5(h,l,u,m,x){if(u>=m)return;const b=h[u+m>>1];let T=u-1,A=m+1;for(;;){do T++;while(x(h[T],b)<0);do A--;while(x(h[A],b)>0);if(T>=A)break;let C=h[T];h[T]=h[A],h[A]=C,C=l[T],l[T]=l[A],l[A]=C}A5(h,l,u,A,x),A5(h,l,A+1,m,x)}const eZ=11102230246251565e-32,yc=134217729,Uke=(3+8*eZ)*eZ;function k5(h,l,u,m,x){let b,T,A,C,O=l[0],$=m[0],U=0,q=0;$>O==$>-O?(b=O,O=l[++U]):(b=$,$=m[++q]);let K=0;if(UO==$>-O?(T=O+b,A=b-(T-O),O=l[++U]):(T=$+b,A=b-(T-$),$=m[++q]),b=T,A!==0&&(x[K++]=A);UO==$>-O?(T=b+O,C=T-b,A=b-(T-C)+(O-C),O=l[++U]):(T=b+$,C=T-b,A=b-(T-C)+($-C),$=m[++q]),b=T,A!==0&&(x[K++]=A);for(;U0:(m[0]-l[0])*(u[1]-l[1])-(u[0]-l[0])*(m[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 Yb(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 Vf(h,l){return h[0]===l[0]&&h[1]===l[1]}function N5(h,l,u){const m=function(x,b,T,A,C,O){const $=(b-O)*(T-C),U=(x-C)*(A-O),q=$-U;if($===0||U===0||$>0!=U>0)return q;const K=Math.abs($+U);return Math.abs(q)>=33306690738754716e-32*K?q:-function(X,te,se,ae,he,ue,be){let Ne,Ie,We,ze,He,Ue,Ve,yt,bt,At,Pt,kt,zt,mt,Nt,Mt,Vt,Yt;const xr=X-he,sr=se-he,nr=te-ue,Zt=ae-ue;mt=xr*Zt,Ue=yc*xr,Ve=Ue-(Ue-xr),yt=xr-Ve,Ue=yc*Zt,bt=Ue-(Ue-Zt),At=Zt-bt,Nt=yt*At-(mt-Ve*bt-yt*bt-Ve*At),Mt=nr*sr,Ue=yc*nr,Ve=Ue-(Ue-nr),yt=nr-Ve,Ue=yc*sr,bt=Ue-(Ue-sr),At=sr-bt,Vt=yt*At-(Mt-Ve*bt-yt*bt-Ve*At),Pt=Nt-Vt,He=Nt-Pt,Kb[0]=Nt-(Pt+He)+(He-Vt),kt=mt+Pt,He=kt-mt,zt=mt-(kt-He)+(Pt-He),Pt=zt-Mt,He=zt-Pt,Kb[1]=zt-(Pt+He)+(He-Mt),Yt=kt+Pt,He=Yt-kt,Kb[2]=kt-(Yt-He)+(Pt-He),Kb[3]=Yt;let mr=function(Un,un){let Gn=un[0];for(let wn=1;wn<4;wn++)Gn+=un[wn];return Gn}(0,Kb),kr=22204460492503146e-32*be;if(mr>=kr||-mr>=kr||(He=X-xr,Ne=X-(xr+He)+(He-he),He=se-sr,We=se-(sr+He)+(He-he),He=te-nr,Ie=te-(nr+He)+(He-ue),He=ae-Zt,ze=ae-(Zt+He)+(He-ue),Ne===0&&Ie===0&&We===0&&ze===0)||(kr=11093356479670487e-47*be+Uke*Math.abs(mr),mr+=xr*ze+Zt*Ne-(nr*We+sr*Ie),mr>=kr||-mr>=kr))return mr;mt=Ne*Zt,Ue=yc*Ne,Ve=Ue-(Ue-Ne),yt=Ne-Ve,Ue=yc*Zt,bt=Ue-(Ue-Zt),At=Zt-bt,Nt=yt*At-(mt-Ve*bt-yt*bt-Ve*At),Mt=Ie*sr,Ue=yc*Ie,Ve=Ue-(Ue-Ie),yt=Ie-Ve,Ue=yc*sr,bt=Ue-(Ue-sr),At=sr-bt,Vt=yt*At-(Mt-Ve*bt-yt*bt-Ve*At),Pt=Nt-Vt,He=Nt-Pt,Fc[0]=Nt-(Pt+He)+(He-Vt),kt=mt+Pt,He=kt-mt,zt=mt-(kt-He)+(Pt-He),Pt=zt-Mt,He=zt-Pt,Fc[1]=zt-(Pt+He)+(He-Mt),Yt=kt+Pt,He=Yt-kt,Fc[2]=kt-(Yt-He)+(Pt-He),Fc[3]=Yt;const zr=k5(4,Kb,4,Fc,tZ);mt=xr*ze,Ue=yc*xr,Ve=Ue-(Ue-xr),yt=xr-Ve,Ue=yc*ze,bt=Ue-(Ue-ze),At=ze-bt,Nt=yt*At-(mt-Ve*bt-yt*bt-Ve*At),Mt=nr*We,Ue=yc*nr,Ve=Ue-(Ue-nr),yt=nr-Ve,Ue=yc*We,bt=Ue-(Ue-We),At=We-bt,Vt=yt*At-(Mt-Ve*bt-yt*bt-Ve*At),Pt=Nt-Vt,He=Nt-Pt,Fc[0]=Nt-(Pt+He)+(He-Vt),kt=mt+Pt,He=kt-mt,zt=mt-(kt-He)+(Pt-He),Pt=zt-Mt,He=zt-Pt,Fc[1]=zt-(Pt+He)+(He-Mt),Yt=kt+Pt,He=Yt-kt,Fc[2]=kt-(Yt-He)+(Pt-He),Fc[3]=Yt;const Rr=k5(zr,tZ,4,Fc,rZ);mt=Ne*ze,Ue=yc*Ne,Ve=Ue-(Ue-Ne),yt=Ne-Ve,Ue=yc*ze,bt=Ue-(Ue-ze),At=ze-bt,Nt=yt*At-(mt-Ve*bt-yt*bt-Ve*At),Mt=Ie*We,Ue=yc*Ie,Ve=Ue-(Ue-Ie),yt=Ie-Ve,Ue=yc*We,bt=Ue-(Ue-We),At=We-bt,Vt=yt*At-(Mt-Ve*bt-yt*bt-Ve*At),Pt=Nt-Vt,He=Nt-Pt,Fc[0]=Nt-(Pt+He)+(He-Vt),kt=mt+Pt,He=kt-mt,zt=mt-(kt-He)+(Pt-He),Pt=zt-Mt,He=zt-Pt,Fc[1]=zt-(Pt+He)+(He-Mt),Yt=kt+Pt,He=Yt-kt,Fc[2]=kt-(Yt-He)+(Pt-He),Fc[3]=Yt;const cn=k5(Rr,rZ,4,Fc,nZ);return nZ[cn-1]}(x,b,T,A,C,O,K)}(h[0],h[1],l[0],l[1],u[0],u[1]);return m>0?-1:m<0?1:0}function sy(h,l){const u=h.point,m=l.point;return u[0]>m[0]?1:u[0]m[1]?1:-1:function(x,b,T){return x.left!==b.left?x.left?1:-1:N5(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 iy(h,l,u){const m=new Yb(l,!1,h,h.isSubject),x=new Yb(l,!0,h.otherEvent,h.isSubject);return Vf(h.point,h.otherEvent.point)&&console.warn("what is that, a collapsed segment?",h),m.contourId=x.contourId=h.contourId,sy(x,h.otherEvent)>0&&(h.otherEvent.left=!0,x.left=!1),h.otherEvent.otherEvent=x,h.otherEvent=m,u.push(x),u.push(m),u}function OI(h,l){return h[0]*l[1]-h[1]*l[0]}function C5(h,l){return h[0]*l[0]+h[1]*l[1]}function I5(h,l,u){const m=function(C,O,$,U){const q=[O[0]-C[0],O[1]-C[1]],K=[U[0]-$[0],U[1]-$[1]];function X(We,ze,He){return[We[0]+ze*He[0],We[1]+ze*He[1]]}const te=[$[0]-C[0],$[1]-C[1]];let se=OI(q,K),ae=se*se;const he=C5(q,q);if(ae>0){const We=OI(te,K)/se;if(We<0||We>1)return null;const ze=OI(te,q)/se;return ze<0||ze>1?null:We===0||We===1?[X(C,We,q)]:ze===0||ze===1?[X($,ze,K)]:[X(C,We,q)]}if(se=OI(te,q),ae=se*se,ae>0)return null;const ue=C5(q,te)/he,be=ue+C5(q,K)/he,Ne=Math.min(ue,be),Ie=Math.max(ue,be);return Ne<=1&&Ie>=0?Ne===1?[X(C,Ne>0?Ne:0,q)]:Ie===0?[X(C,Ie<1?Ie:1,q)]:[X(C,Ne>0?Ne:0,q),X(C,Ie<1?Ie:1,q)]:null}(h.point,h.otherEvent.point,l.point,l.otherEvent.point),x=m?m.length:0;if(x===0||x===1&&(Vf(h.point,l.point)||Vf(h.otherEvent.point,l.otherEvent.point))||x===2&&h.isSubject===l.isSubject)return 0;if(x===1)return!Vf(h.point,m[0])&&!Vf(h.otherEvent.point,m[0])&&iy(h,m[0],u),!Vf(l.point,m[0])&&!Vf(l.otherEvent.point,m[0])&&iy(l,m[0],u),1;const b=[];let T=!1,A=!1;return Vf(h.point,l.point)?T=!0:sy(h,l)===1?b.push(l,h):b.push(h,l),Vf(h.otherEvent.point,l.otherEvent.point)?A=!0:sy(h.otherEvent,l.otherEvent)===1?b.push(l.otherEvent,h.otherEvent):b.push(h.otherEvent,l.otherEvent),T&&A||T?(l.type=1,h.type=l.inOut===h.inOut?2:3,T&&!A&&iy(b[1].otherEvent,b[0].point,u),2):A?(iy(b[0],b[1].point,u),3):b[0]!==b[3].otherEvent?(iy(b[0],b[1].point,u),iy(b[1],b[2].point,u),3):(iy(b[0],b[1].point,u),iy(b[3].otherEvent,b[2].point,u),3)}function Vke(h,l){if(h===l)return 0;if(N5(h.point,h.otherEvent.point,l.point)!==0||N5(h.point,h.otherEvent.point,l.otherEvent.point)!==0)return Vf(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 sy(h,l)===1?1:-1}class qke{constructor(){this.points=[],this.holeIds=[],this.holeOf=null,this.depth=null}isExterior(){return this.holeOf==null}}function Gke(h,l,u,m){let x,b=h+1,T=l[h].point;const A=l.length;for(bm;)b--;return b}function Hke(h,l,u){const m=new qke;if(h.prevInResult!=null){const x=h.prevInResult,b=x.outputContourId;if(x.resultTransition>0){const T=l[b];if(T.holeOf!=null){const A=T.holeOf;l[A].holeIds.push(u),m.holeOf=A,m.depth=l[b].depth}else l[b].holeIds.push(u),m.holeOf=b,m.depth=l[b].depth+1}else m.holeOf=null,m.depth=l[b].depth}else m.holeOf=null,m.depth=0;return m}const iZ=Math.max,aZ=Math.min;let FI=0;function oZ(h,l,u,m,x,b){let T,A,C,O,$,U;for(T=0,A=h.length-1;T0?U.left=!0:$.left=!0;const q=C[0],K=C[1];x[0]=aZ(x[0],q),x[1]=aZ(x[1],K),x[2]=iZ(x[2],q),x[3]=iZ(x[3],K),m.push($),m.push(U)}}const BI=[];function lZ(h,l,u){let m=h,x=l;typeof h[0][0][0]=="number"&&(m=[h]),typeof l[0][0][0]=="number"&&(x=[l]);let b=function(q,K,X){let te=null;return q.length*K.length===0&&(X===0?te=BI:X===2?te=q:(X===1||X===3)&&(te=q.length===0?K:q)),te}(m,x,u);if(b)return b===BI?null:b;const T=[1/0,1/0,-1/0,-1/0],A=[1/0,1/0,-1/0,-1/0],C=function(q,K,X,te,se){const ae=new y0(void 0,sy);let he,ue,be,Ne,Ie,We;for(be=0,Ne=q.length;bete[2]||te[0]>X[2]||X[1]>te[3]||te[1]>X[3])&&(se===0?ae=BI:se===2?ae=q:(se===1||se===3)&&(ae=q.concat(K))),ae}(m,x,T,A,u),b)return b===BI?null:b;const O=function(q,K,X,te,se,ae){const he=new E5(Vke),ue=[],be=Math.min(te[2],se[2]);let Ne,Ie,We;for(;q.length!==0;){let ze=q.pop();if(ue.push(ze),ae===0&&ze.point[0]>be||ae===2&&ze.point[0]>te[2])break;if(ze.left){Ie=Ne=he.insert(ze),We=he.minNode(),Ne=Ne!==We?he.prev(Ne):null,Ie=he.next(Ie);const He=Ne?Ne.key:null;let Ue;if(Tj(ze,He,ae),Ie&&I5(ze,Ie.key,q)===2&&(Tj(ze,He,ae),Tj(Ie.key,ze,ae)),Ne&&I5(Ne.key,ze,q)===2){let Ve=Ne;Ve=Ve!==We?he.prev(Ve):null,Ue=Ve?Ve.key:null,Tj(He,Ue,ae),Tj(ze,He,ae)}}else ze=ze.otherEvent,Ie=Ne=he.find(ze),Ne&&Ie&&(Ne=Ne!==We?he.prev(Ne):null,Ie=he.next(Ie),he.remove(ze),Ie&&Ne&&I5(Ne.key,Ie.key,q))}return ue}(C,0,0,T,A,u),$=function(q){let K,X;const te=function(he){let ue,be,Ne,Ie,We;const ze=[];for(be=0,Ne=he.length;be{se[We]=!0,We=te.length)&&te[Ne];);ae.push(ue)}return ae}(O),U=[];for(let q=0;q<$.length;q++){let K=$[q];if(K.isExterior()){let X=[K.points];for(let te=0;te{T.push(new Ft(U,C+(U-A)/(O-A)*($-C)))}:(T,A,C,O,$,U)=>{T.push(new Ft(A+(U-C)/($-C)*(O-A),U))};for(const T of h){const A=[];for(const C of T){if(C.length<=2)continue;const O=[];for(let q=0;ql&&b(O,K,X,te,se,l):ae>u?he=l&&b(O,K,X,te,se,l),he>u&&ae<=u&&b(O,K,X,te,se,u)}let $=C[C.length-1];const U=m===0?$.x:$.y;U>=l&&U<=u&&O.push($),O.length&&($=O[O.length-1],O[0].x===$.x&&O[0].y===$.y||O.push(O[0]),A.push(O))}A.length&&x.push(A)}return x}function Wke(h,l){const u=lZ(P5(h),P5([l]),0);return u==null?[]:cZ(u)}function Kke(h,l,u=0){let x=P5(h,65536);const b=[];for(;l.valid();l.next()){const[T,A]=l.get();let C=T.x*65536,O=T.y*65536,$=A.x*65536,U=A.y*65536;const q=$-C,K=U-O,X=Math.hypot(q,K);if(X===0)continue;C-=q*u,O-=K*u,$+=q*u,U+=K*u;const te=Math.trunc(K/X*3),se=-Math.trunc(q/X*3);b.push([[[C,O],[$,U],[$+te,U+se],[C+te,O+se],[C,O]]])}return b.length>0&&(x=lZ(x,b,2)),cZ(x,1/65536,128)}function P5(h,l=1){return[h.map(u=>u.map(m=>[m.x*l,m.y*l]))]}function cZ(h,l=1,u){return h.map(m=>m.map((x,b)=>{const T=x.map(A=>{let C=A[0],O=A[1];return u&&(C=Math.round(C/u)*u,O=Math.round(O/u)*u),new Ft(C*l,O*l)._round()});return b>0&&T.reverse(),T}))}class R5{constructor(l,u){this.layoutVertexArray=new mc,this.indexArray=new bi,this.lineIndexArray=new vu,this.triangleSegments=new Cs,this.lineSegments=new Cs,this.programConfigurations=new ie(l.layers,{zoom:l.zoom,lut:l.lut}),this.uploaded=!1,u&&(this.elevatedLayoutVertexArray=new Rc)}update(l,u,m,x,b,T,A,C){this.programConfigurations.updatePaintArrays(l,u,b,m,x,T,A,C)}isEmpty(){return this.layoutVertexArray.length===0}needsUpload(){return this.programConfigurations.needsUpload}upload(l){this.uploaded||(this.layoutVertexBuffer=l.createVertexBuffer(this.layoutVertexArray,jke.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,Ake.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,m,x,b,T,A){this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,l,u,m,x,b,T,void 0,A)}}class zI{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 R5(l,!1),this.elevationBufferData=new R5(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,m,x){return{hasLayoutChanges:!1,hasUboChanges:!1}}populate(l,u,m,x){this.hasPattern=S5("fill",this.layers,this.pixelRatio,u);const b=this.layers[0].layout.get("fill-sort-key"),T=[];for(const{feature:A,id:C,index:O,sourceLayerIndex:$}of l){const U=this.layers[0]._featureFilter.needGeometry,q=bn(A,U);if(!this.layers[0]._featureFilter.filter(new as(this.zoom,{worldview:this.worldview,activeFloors:u.activeFloors}),q,m))continue;const K=b?b.evaluate(q,{},m,u.availableImages):void 0,X={id:C,properties:A.properties,type:A.type,sourceLayerIndex:$,index:O,geometry:U?q.geometry:Ur(A,m,x),patterns:{},sortKey:K};T.push(X)}b&&T.sort((A,C)=>A.sortKey-C.sortKey);for(const A of T){const{geometry:C,index:O,sourceLayerIndex:$}=A;if(this.hasPattern){const U=T5("fill",this.layers,A,this.zoom,this.pixelRatio,u);this.patternFeatures.push(U)}else this.addFeature(A,C,O,m,{},u.availableImages,u.brightness,u.elevationFeatures);u.featureIndex.insert(l[O].feature,C,O,$,this.index)}}update(l,u,m,x,b,T,A){this.bufferData.update(l,u,m,x,b,T,A,this.worldview),this.elevationBufferData.update(l,u,m,x,b,T,A,this.worldview),this.elevatedStructures&&this.elevatedStructures.update(l,u,m,x,b,T,A,this.worldview)}addFeatures(l,u,m,x,b,T){for(const A of this.patternFeatures)this.addFeature(A,A.geometry,A.index,u,m,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,m,x,b,T=[],A,C){const O=wj(u,500);this.elevationMode!=="none"?this.addElevatedRoadFeature(l,O,x,m,C):this.addGeometry(O,this.bufferData),this.bufferData.populatePaintArrays(l,m,b,T,x,A,this.worldview),this.elevationBufferData.populatePaintArrays(l,m,b,T,x,A,this.worldview)}getUnevaluatedPortalGraph(){return this.elevatedStructures?this.elevatedStructures.unevaluatedPortals:void 0}setEvaluatedPortalGraph(l,u,m,x,b){this.elevatedStructures&&(this.elevatedStructures.construct(l),this.elevatedStructures.populatePaintArrays(u,m,x,b,this.worldview))}addElevatedRoadFeature(l,u,m,x,b){const T=new Array,A=Os.getElevationFeature(l,b);if(!A)return void this.addGeometry(u,this.bufferData);{const O=this.clipPolygonsToTile(u,1);O.length>0&&T.push({polygons:O,elevationFeature:A,elevationTileID:m})}const C={guardRailEnabled:this.layers[0].layout.get("fill-construct-bridge-guard-rail").evaluate(l,{},m),featureIndex:x};for(const O of T)if(O.elevationFeature){if(this.elevationMode==="hd-road-base"){this.elevatedStructures||(this.elevatedStructures=new Oc(O.elevationTileID,this.layers,this.zoom,this.lut));const U=O.elevationFeature.isTunnel();let q=0;l.properties.hasOwnProperty(Ps)&&(q=+l.properties[Ps]),this.elevatedStructures.addPortalCandidates(O.elevationFeature.id,O.polygons,U,O.elevationFeature,q)}O.elevationFeature.constantHeight==null&&(O.polygons=this.prepareElevatedPolygons(O.polygons,O.elevationFeature,O.elevationTileID));const $=new Vs(m,O.elevationTileID);this.addElevatedGeometry(O.polygons,$,O.elevationFeature,this.elevationMode==="hd-road-base"?0:.05,x,C)}}addElevatedGeometry(l,u,m,x,b,T){const A={elevation:m,elevationSampler:u,bias:x,index:b,featureInfo:T},[C,O]=this.addGeometry(l,this.elevationBufferData,A);this.elevationBufferData.heightRange==null?this.elevationBufferData.heightRange={min:C,max:O}:(this.elevationBufferData.heightRange.min=Math.min(this.elevationBufferData.heightRange.min,C),this.elevationBufferData.heightRange.max=Math.max(this.elevationBufferData.heightRange.max,O))}addGeometry(l,u,m){let x=Number.POSITIVE_INFINITY,b=Number.NEGATIVE_INFINITY,T=null;m&&(T=m.elevationSampler.constantElevation(m.elevation,m.bias),T!=null&&(x=T,b=T));const A=(C,O,$)=>{if(m!=null)if(O.push(C),T!=null)u.elevatedLayoutVertexArray.emplaceBack(T),$.push(T);else{const U=m.elevationSampler.pointElevation(C,m.elevation,m.bias);u.elevatedLayoutVertexArray.emplaceBack(U),$.push(U),x=Math.min(x,U),b=Math.max(b,U)}};for(const C of l){let O=0;for(const ue of C)O+=ue.length;const $=u.triangleSegments.prepareSegment(O,u.layoutVertexArray,u.indexArray),U=$.vertexLength,q=[],K=[],X=[],te=[],se=[],ae=u.layoutVertexArray.length;for(const ue of C){if(ue.length===0)continue;ue!==C[0]&&K.push(q.length/2);const be=u.lineSegments.prepareSegment(ue.length,u.layoutVertexArray,u.lineIndexArray),Ne=be.vertexLength;m&&se.push(u.layoutVertexArray.length-ae),A(ue[0],X,te),u.layoutVertexArray.emplaceBack(ue[0].x,ue[0].y),u.lineIndexArray.emplaceBack(Ne+ue.length-1,Ne),q.push(ue[0].x),q.push(ue[0].y);for(let Ie=1;Ie0&&m&&this.elevationMode==="hd-road-base"){const ue=m.elevation.isTunnel(),be=m.elevation.safeArea,Ne=this.elevatedStructures.addVertices(X,te);this.elevatedStructures.addTriangles(he,Ne,ue);const Ie=se.length;if(Ie>0){for(let We=0;We=m&&K.max.x<=b&&K.min.y>=x&&K.max.y<=T?C:O).push(q)}if(C.length===l.length)return l;const $=[new Ft(m,x),new Ft(b,x),new Ft(b,T),new Ft(m,T),new Ft(m,x)],U=C;for(const q of O)U.push(...Wke(q,$));return U}}let uZ,dZ,hZ,fZ;_r(zI,"FillBucket",{omit:["layers","patternFeatures"]}),_r(R5,"FillBufferData"),_r(Oc,"ElevatedStructures");class UI{constructor(l,u,m,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 U=1;UU.cellIdx-q.cellIdx||U.triIdx-q.triIdx);let $=0;for(;$this.max.x||this.min.x>l.x||l.y>this.max.y||this.min.y>l.y)return;const m=qf(l.x-this.min.x,this.xScale,this.cellsX),x=qf(l.y-this.min.y,this.yScale,this.cellsY),b=this.cells[x*this.cellsX+m];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=qf(l.x-this.min.x,this.xScale,this.cellsX),b=qf(u.x-this.min.x,this.xScale,this.cellsX),T=qf(l.y-this.min.y,this.yScale,this.cellsY),A=qf(u.y-this.min.y,this.yScale,this.cellsY);for(let C=T;C<=A;C++)for(let O=x;O<=b;O++){const $=this.cells[C*this.cellsX+O];if($)for(let U=0;U<$.len;U++){const q=this.payload[$.start+U],K=Math.floor(q/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 m of this.footprints)u.push({footprint:m,id:l})}updateAppearances(l,u,m,x){return{hasLayoutChanges:!1,hasUboChanges:!1}}populate(l,u,m,x){const b=[];for(const{feature:T,id:A,index:C,sourceLayerIndex:O}of l){const $=this.layers[0]._featureFilter.needGeometry,U=bn(T,$);if(!this.layers[0]._featureFilter.filter(new as(this.zoom,{worldview:this.worldview,activeFloors:u.activeFloors}),U,m))continue;const q={id:A,properties:T.properties,type:T.type,sourceLayerIndex:O,index:C,geometry:$?U.geometry:Ur(T,m,x),patterns:{}};b.push(q)}for(const T of b){const{geometry:A,index:C,sourceLayerIndex:O}=T;this.addFeature(T,A,C,m,{},u.availableImages,u.brightness),u.featureIndex.insert(l[C].feature,A,C,O,this.index)}}isEmpty(){return this.footprints.length===0}uploadPending(){return!1}upload(l){}update(l,u,m,x,b,T,A){}destroy(){}addFeature(l,u,m,x,b,T=[],A){for(const C of wj(u,2)){const O=[],$=[],U=[],q=new Ft(1/0,1/0),K=new Ft(-1/0,-1/0);for(const se of C)if(se.length!==0){se!==C[0]&&U.push($.length/2);for(let ae=0;ael.max.x||h.max.xl.max.y||h.max.ynew Ft((C.x+b.x*or)*A-T.x*or,(C.y+b.y*or)*A-T.y*or))}return M5(u,x,h.indices,0,h.indices.length,0,0)}function vZ(h,l,u,m){const x=Math.pow(2,m.z-u.z);return new Ft((h+u.x*or)*x-m.x*or,(l+u.y*or)*x-m.y*or)}function _Z(h,l){const u=[];l.grid.queryPoint(h,u);const m=l.indices,x=l.vertices;for(let b=0;b0&&(m.length>1&&u.push(m),m=[])}return m.length>1&&u.push(m),u}const O5=rn.types,iNe=["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"],aNe=["fill-extrusion-flood-light-ground-radius"],oNe=Math.pow(2,13),lNe=Math.pow(2,15)-1,HI=new Ft(0,1),xp=2147483648,WI=1073741824;function jj(h,l,u,m,x,b,T,A){h.emplaceBack((l<<1)+T,(u<<1)+b,(Math.floor(m*oNe)<<1)+x,Math.round(A))}function Aj(h,l,u){h.emplaceBack(l.x*or,l.y*or,u?1:0)}function KI(h,l,u,m,x,b){h.emplaceBack(l.x,l.y,(u.x<<1)+m,(u.y<<1)+x,b)}function kj(h,l,u){h.emplaceBack(l.x,l.y,l.z,u[0]*16384,u[1]*16384,u[2]*16384)}class wZ{constructor(){this.vertexOffset=0,this.vertexCount=0,this.indexOffset=0,this.indexCount=0}}class F5{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 B5{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,m){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===or)&&u.x===m.x)!=((u.y===0||u.y===or)&&u.y===m.y)&&this.processBorderOverlap(u,m),x&&this.checkBorderIntersection(u,m)}checkBorderIntersection(l,u){u.x<0!=l.x<0&&this.addBorderIntersection(0,Qr(u.y,l.y,(0-u.x)/(l.x-u.x))),u.x>or!=l.x>or&&this.addBorderIntersection(1,Qr(u.y,l.y,(or-u.x)/(l.x-u.x))),u.y<0!=l.y<0&&this.addBorderIntersection(2,Qr(u.x,l.x,(0-u.y)/(l.y-u.y))),u.y>or!=l.y>or&&this.addBorderIntersection(3,Qr(u.x,l.x,(or-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 m=this.borders[l];um[1]&&(m[1]=u)}processBorderOverlap(l,u){if(l.x===u.x){if(l.y===u.y)return;const m=l.x===0?0:1;this.addBorderIntersection(m,u.y),this.addBorderIntersection(m,l.y)}else{const m=l.y===0?2:3;this.addBorderIntersection(m,u.x),this.addBorderIntersection(m,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 SZ(h,l){const u=h.add(l)._unit(),m=fe(h.x*u.x+h.y*u.y,-1,1);var x,b,T;return T=Math.acos(m),Math.min(4,Math.max(-4,Math.tan(T)))/4*lNe*((x=h).x*(b=l).y-x.y*b.x<0?-1:1)}const cNe=[h=>h.x<0,h=>h.x>or,h=>h.y<0,h=>h.y>or];function uNe(h,l,u,m){const x=[4];if(m===0)return x;u._mult(m);const b=h.sub(u),T=l.sub(u),A=[h,l,b,T];for(let C=0;C<4;C++)for(const O of A)if(cNe[C](O)){x.push(C);break}return x}class $5{constructor(l){this.groundRadiusArray=null,this.groundRadiusBuffer=null,this.vertexArray=new ej,this.indexArray=new bi,this.programConfigurations=new ie(l.layers,{zoom:l.zoom,lut:l.lut},u=>aNe.includes(u)),this._segments=new Cs,this.hiddenByLandmarkVertexArray=new zb,this._segmentToGroundQuads={},this._segmentToGroundQuads[0]=[],this._segmentToRegionTriCounts={},this._segmentToRegionTriCounts[0]=[0,0,0,0,0],this.regionSegments={},this.regionSegments[4]=new Cs}getDefaultSegment(){return this.regionSegments[4]}hasData(){return this.vertexArray.length!==0}addData(l,u,m,x=!1){const b=l.length;if(b>2){let T=Math.max(0,this._segments.get().length-1);const A=this._segments._prepareSegment(4*b,this.vertexArray.length,2*this._segmentToGroundQuads[T].length);let C;T!==this._segments.get().length-1&&(T++,this._segmentToGroundQuads[T]=[],this._segmentToRegionTriCounts[T]=[0,0,0,0,0]);{const O=l[0],$=l[1];C=SZ(O.sub(l[b-1])._perp()._unit(),$.sub(O)._perp()._unit())}for(let O=0;Ox.region-b.region);for(let m=0;mC+O,0);let A=0;for(let C=0;C<=4;C++){const O=T[C];if(O!==0){let $=this.regionSegments[C];$||($=this.regionSegments[C]=new Cs);const U={vertexOffset:b.vertexOffset,primitiveOffset:b.primitiveOffset+A,vertexLength:b.vertexLength,primitiveLength:O};$.get().push(U)}A+=O}for(let C=0;C0?this.hiddenByLandmarkVertexBuffer=l.createVertexBuffer(this.hiddenByLandmarkVertexArray,eNe.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 YI{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 bi,this.footprintVertices=new mc,this.footprintSegments=[],this.layoutVertexArray=new JE,this.centroidVertexArray=new kI,this.wallVertexArray=new hj,this.indexArray=new bi,this.programConfigurations=new ie(l.layers,{zoom:l.zoom,lut:l.lut},u=>iNe.includes(u)),this.segments=new Cs,this.stateDependentLayerIds=this.layers.filter(u=>u.isStateDependent()).map(u=>u.id),this.groundEffect=new $5(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,m,x){return{hasLayoutChanges:!1,hasUboChanges:!1}}populate(l,u,m,x){this.features=[],this.hasPattern=S5("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=Ot(m),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:A,sourceLayerIndex:C}of l){const O=this.layers[0]._featureFilter.needGeometry,$=bn(b,O);if(!this.layers[0]._featureFilter.filter(new as(this.zoom,{worldview:this.worldview,activeFloors:u.activeFloors}),$,m))continue;const U={id:T,sourceLayerIndex:C,index:A,geometry:O?$.geometry:Ur(b,m,x),properties:b.properties,type:b.type,patterns:{}},q=this.layoutVertexArray.length,K=O5[U.type]==="Polygon";if(this.hasPattern)this.features.push({featureId:b.id,feature:T5("fill-extrusion",this.layers,U,this.zoom,this.pixelRatio,u)});else if(this.wallMode)for(const X of U.geometry)for(const te of bZ(X,K))this.addFeature(b.id,U,[te],A,m,{},u.availableImages,x,u.brightness);else this.addFeature(b.id,U,U.geometry,A,m,{},u.availableImages,x,u.brightness);u.featureIndex.insert(b,U.geometry,A,C,this.index,q)}this._finalizeBuildingGroups(),this.sortBorders(),this.projection.name==="mercator"&&this.splitToSubtiles(),this.groundEffect.prepareBorderSegments(),this.polygonSegments.length=0}addFeatures(l,u,m,x,b,T){for(const{featureId:A,feature:C}of this.features){const O=O5[C.type]==="Polygon",{geometry:$}=C;if(this.wallMode)for(const U of $)for(const q of bZ(U,O))this.addFeature(A,C,[q],C.index,u,m,x,b,T);else this.addFeature(A,C,$,C.index,u,m,x,b,T)}this._finalizeBuildingGroups(),this.sortBorders(),this.projection.name==="mercator"&&this.splitToSubtiles()}update(l,u,m,x,b,T,A){this.programConfigurations.updatePaintArrays(l,u,b,m,x,T,A,this.worldview),this.groundEffect.update(l,u,b,m,x,T,A,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,rNe),this.indexBuffer=l.createIndexBuffer(this.indexArray),this.wallVertexBuffer=l.createVertexBuffer(this.wallVertexArray,Jke.members),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=l.createVertexBuffer(this.layoutVertexExtArray,tNe.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,Qke.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,m,x,b,T,A,C,O){const $=this.layers[0].paint.get("fill-extrusion-flood-light-ground-radius").evaluate(u,{})/this.tileToMeter,U=[new Ft(0,0),new Ft(or,or)],q=C.projection,K=q.name==="globe",X=this.wallMode||O5[u.type]==="Polygon",te=new B5;te.centroidDataIndex=this.centroidData.length;const se=new F5;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,he=this.layers[0].paint.get("fill-extrusion-height").evaluate(u,{},b);let ue;if(se.height=he,se.vertexArrayOffset=this.layoutVertexArray.length,se.groundVertexArrayOffset=this.groundEffect.vertexArray.length,K&&!this.layoutVertexExtArray&&(this.layoutVertexExtArray=new Mb),this.wallMode){if(K)return void $r("Non zero fill-extrusion-line-width is not yet supported on globe.");if(m.length!==1)return;ue=function(Ue){const Ve=Ue[0].x===Ue[Ue.length-1].x&&Ue[0].y===Ue[Ue.length-1].y;(function(nr){let Zt=0;const mr=nr.length;for(let kr=0;kr=0})(Ue)||(Ue=Ue.reverse());const bt={geometry:[],joinNormals:[],indices:[]},At=[],Pt=[],kt=[];let zt=Ue.length;for(;zt>=2&&Ue[zt-1].equals(Ue[zt-2]);)zt--;if(zt<(Ve?3:2))return bt;let mt,Nt,Mt,Vt,Yt,xr=0;for(;xr0;let Rr="miter";const cn=2;Rr==="miter"&&kr>cn&&(Rr="bevel"),Rr==="bevel"&&(kr>100&&(Rr="flipbevel"),kr{const os=new Ft(un.x,un.y),Kn=new Ft(un.x,un.y);os.x+=Gn.x*mi,os.y+=Gn.y*mi,Kn.x-=Gn.x*Math.max(wn,1),Kn.y-=Gn.y*Math.max(wn,1),kt.push(Gn),At.push(os),Pt.push(Kn)};if(Rr==="miter")Zt._mult(kr),Un(mt,Zt,0,0);else if(Rr==="flipbevel")Zt=Yt.mult(-1),Un(mt,Zt,0,0),Un(mt,Zt.mult(-1),0,0);else{const un=-Math.sqrt(kr*kr-1),Gn=zr?un:0,wn=zr?0:un;Nt&&Un(mt,Vt,Gn,wn),Mt&&Un(mt,Yt,Gn,wn)}}bt.geometry=[...At,...Pt.reverse(),At[0]],bt.joinNormals=[...kt,...kt.reverse(),kt[kt.length-1]];const sr=bt.geometry.length-1;for(let nr=0;nrUe<(Ve.length-1)/2||Ue===Ve.length-1,Ne=this.wallMode?[m]:wj(m,500);for(let Ue=Ne.length-1;Ue>=0;Ue--){const Ve=Ne[Ue];(Ve.length===0||hNe(Ve[0]))&&Ne.splice(Ue,1)}let Ie;if(K)Ie=CZ(Ne,U,b);else{Ie=[];for(const Ue of Ne)Ie.push({polygon:Ue,bounds:U})}const We=X?this.edgeRadius:0,ze=We>0&&this.zoom<17,He=(Ue,Ve)=>{if(Ue.length===0)return!1;const yt=Ue[Ue.length-1];return Ve.x===yt.x&&Ve.y===yt.y};for(const{polygon:Ue,bounds:Ve}of Ie){let yt=0,bt=0;for(const zt of Ue)X&&!zt[0].equals(zt[zt.length-1])&&zt.push(zt[0]),bt+=X?zt.length-1:zt.length;const At=this.segments.prepareSegment((X?5:4)*bt,this.layoutVertexArray,this.indexArray);se.footprintSegIdx<0&&(se.footprintSegIdx=this.footprintSegments.length),se.polygonSegIdx<0&&(se.polygonSegIdx=this.polygonSegments.length);const Pt={triangleArrayOffset:this.indexArray.length,triangleCount:0,triangleSegIdx:this.segments.segments.length-1},kt=new wZ;if(kt.vertexOffset=this.footprintVertices.length,kt.indexOffset=3*this.footprintIndices.length,kt.ringIndices=[],X){const zt=[],mt=[];yt=At.vertexLength;for(let Mt=0;Mt4&&AZ(mt[mt.length-2],mt[0],mt[1]),Mt=We?dNe(mt[mt.length-2],mt[0],mt[1],We):0;const Vt=[];let Yt,xr,sr;xr=mt[1].sub(mt[0])._perp()._unit();let nr=!0;for(let Zt=1,mr=0;Zt0?1:0,Gn=kr.dist(zr);if(mr+Gn>32768&&(mr=0),We){sr=Rr.sub(zr)._perp()._unit();let Kn=EZ(kr,zr,Rr,TZ(xr,sr),We);isNaN(Kn)&&(Kn=0);const Rs=zr.sub(kr)._unit();kr=kr.add(Rs.mult(Mt))._round(),zr=zr.add(Rs.mult(-Kn))._round(),Mt=Kn,xr=sr,ae&&this.zoom>=17&&(He(Vt,kr)||Vt.push(kr),He(Vt,zr)||Vt.push(zr))}const wn=At.vertexLength,mi=mt.length>4&&AZ(kr,zr,Rr);let os=kZ(mr,Nt,nr);if(jj(this.layoutVertexArray,kr.x,kr.y,Un,un,0,0,os),jj(this.layoutVertexArray,kr.x,kr.y,Un,un,0,1,os),this.wallMode){const Kn=be(Zt-1,mt),Rs=ue.joinNormals[Zt-1];Aj(this.wallVertexArray,Rs,Kn),Aj(this.wallVertexArray,Rs,Kn)}if(mr+=Gn,os=kZ(mr,mi,!nr),Nt=mi,jj(this.layoutVertexArray,zr.x,zr.y,Un,un,0,0,os),jj(this.layoutVertexArray,zr.x,zr.y,Un,un,0,1,os),this.wallMode){const Kn=be(Zt,mt),Rs=ue.joinNormals[Zt];Aj(this.wallVertexArray,Rs,Kn),Aj(this.wallVertexArray,Rs,Kn)}if(At.vertexLength+=4,this.indexArray.emplaceBack(wn+0,wn+1,wn+2),this.indexArray.emplaceBack(wn+1,wn+3,wn+2),At.primitiveLength+=2,We){const Kn=yt+(Zt===1?mt.length-2:Zt-2),Rs=Zt===1?yt:Kn+1;if(this.indexArray.emplaceBack(wn+1,Kn,wn+3),this.indexArray.emplaceBack(Kn,Rs,wn+3),At.primitiveLength+=2,Yt===void 0&&(Yt=wn),!z5(Rr,mt[Zt],Ve)){const ci=Zt===mt.length-1?Yt:At.vertexLength;this.indexArray.emplaceBack(wn+2,wn+3,ci),this.indexArray.emplaceBack(wn+3,ci+1,ci),this.indexArray.emplaceBack(wn+3,Rs,ci+1),At.primitiveLength+=3}nr=!nr}if(K){const Kn=this.layoutVertexExtArray,Rs=q.projectTilePoint(kr.x,kr.y,b),ci=q.projectTilePoint(zr.x,zr.y,b),za=q.upVector(b,kr.x,kr.y),ui=q.upVector(b,zr.x,zr.y);kj(Kn,Rs,za),kj(Kn,Rs,za),kj(Kn,ci,ui),kj(Kn,ci,ui)}}X&&(yt+=mt.length-1),ae&&We&&this.zoom>=17&&(Vt.length!==0&&He(Vt,Vt[0])&&Vt.pop(),this.groundEffect.addData(Vt,Ve,$,We>0))}this.footprintSegments.push(kt),Pt.triangleCount=this.indexArray.length-Pt.triangleArrayOffset,this.polygonSegments.push(Pt),++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?HI:this.encodeCentroid(te,se),u.properties&&u.properties.hasOwnProperty("building_id")){const Ue=se.buildingId;let Ve=this.buildingGroups.get(Ue);Ve||(Ve={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(Ue,Ve)),Ve.accX+=te.acc.x,Ve.accY+=te.acc.y,Ve.accCount+=te.accCount,Ve.mergedMin.x=Math.min(Ve.mergedMin.x,se.min.x),Ve.mergedMin.y=Math.min(Ve.mergedMin.y,se.min.y),Ve.mergedMax.x=Math.max(Ve.mergedMax.x,se.max.x),Ve.mergedMax.y=Math.max(Ve.mergedMax.y,se.max.y),Ve.partIndices.push(this.centroidData.length)}if(this.centroidData.push(se),te.borders){this.featuresOnBorder.push(te);const Ue=this.featuresOnBorder.length-1;for(let Ve=0;Vethis.featuresOnBorder[u].borders[l][0]-this.featuresOnBorder[m].borders[l][0])}splitToSubtiles(){const l=[];for(let A=0;Aor),$=2*O+(+(C.min.x+C.max.x>or)^O);for(let U=0;UA.triangleSegmentIdx===C.triangleSegmentIdx?A.subtile-C.subtile:A.triangleSegmentIdx-C.triangleSegmentIdx);let m=0,x=0,b=0;for(const A of l){if(A.triangleSegmentIdx!==m)break;b++}const T=l.length;for(;x!==l.length;){m=l[x].triangleSegmentIdx;let A=0,C=x,O=x;for(let $=C;$0&&this.triangleSubSegments.push({segment:K,min:U,max:q}),C=O;for(let X=C;X[te[0]*(1-ae[0])+se[0]*ae[0],te[1]*(1-ae[1])+se[1]*ae[1]],K=[],X=[];for(const te of this.triangleSubSegments){K[0]=te.min.x/or,K[1]=te.min.y/or,X[0]=te.max.x/or,X[1]=te.max.y/or;const se=q($,U,K),ae=q($,U,X);if(new us([se[0],se[1],b],[ae[0],ae[1],T]).intersectsPrecise(m)===0){O&&(x.segments.push(O),O=void 0);continue}const he=te.segment;O&&O.vertexOffset!==he.vertexOffset&&(x.segments.push(O),O=void 0),O?(O.vertexLength+=he.vertexLength,O.primitiveLength+=he.primitiveLength):O={vertexOffset:he.vertexOffset,primitiveLength:he.primitiveLength,vertexLength:he.vertexLength,primitiveOffset:he.primitiveOffset,sortKey:void 0,vaos:{}}}return O&&x.segments.push(O),x}encodeCentroid(l,u){const m=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(fe(m.x,1,8191)<<3|b,fe(m.y,1,8191)<<3|T)}encodeBorderCentroid(l){if(!l.borders)return new Ft(0,0);const u=l.borders,m=Number.MAX_VALUE;if(u[0][0]!==m||u[1][0]!==m){const x=u[0][0]!==m?0:1;return new Ft(6|(u[0][0]!==m?0:65528),(u[x][0]+u[x][1])/2<<3|6)}{const x=u[2][0]!==m?2:3;return new Ft((u[x][0]+u[x][1])/2<<3|6,6|(u[2][0]!==m?0:65528))}}showCentroid(l){const u=this.centroidData[l.centroidDataIndex];if(u.flags&=xp,u.groupCentroidPos.x!==0||u.groupCentroidPos.y!==0){const m=u.span(),x=Math.min(7,Math.round(m.x*this.tileToMeter/10)),b=Math.min(6,Math.round(m.y*this.tileToMeter/10));u.centroidXY=new Ft(fe(u.groupCentroidPos.x,1,8191)<<3|x,fe(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,m=l.vertexCount+l.vertexArrayOffset,x=-1073741824&l.flags?HI: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;TC.max.x||C.min.x>T.max.x||T.min.y>C.max.y||C.min.y>T.max.y||T.footprint.buildingIds.has(C.buildingId)&&(C.flags|=T.clipMask!==GI.None?-1073741824:xp);else for(const C of this.centroidData)if(!(C.flags&xp||C.flags&WI||T.min.x>C.max.x||C.min.x>T.max.x||T.min.y>C.max.y||C.min.y>T.max.y))for(let O=0;Ou!=K>u&&l<(this.footprintVertices.int16[2*($+T.vertexOffset)+0]-U)*(u-q)/(K-q)+U&&(x=!x)}A=C}}return x}getHeightAtTileCoord(l,u){let m=Number.NEGATIVE_INFINITY,x=!0;const b=4*(l+or)*or+(u+or);if(this.partLookup.hasOwnProperty(b)){const T=this.partLookup[b];return T?{height:T.height,hidden:!!(T.flags&xp)}: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<=m||this.footprintContainsPoint(l,u,T)&&(m=T.height,this.partLookup[b]=T,x=!!(T.flags&xp));if(m!==Number.NEGATIVE_INFINITY)return{height:m,hidden:x};this.partLookup[b]=void 0}}function TZ(h,l){const u=h.add(l)._unit();return h.x*u.x+h.y*u.y}function dNe(h,l,u,m){const x=l.sub(h)._perp()._unit(),b=u.sub(l)._perp()._unit();return EZ(h,l,u,TZ(x,b),m)}function EZ(h,l,u,m,x){const b=Math.sqrt(1-m*m);return Math.min(h.dist(l)/3,l.dist(u)/3,x*b/m)}function z5(h,l,u){return h.xu[1].x&&l.x>u[1].x||h.yu[1].y&&l.y>u[1].y}function jZ(h,l){return h.xl[1].x||h.yl[1].y}function hNe(h){return h.every(l=>l.x<=0)||h.every(l=>l.x>=or)||h.every(l=>l.y<=0)||h.every(l=>l.y>=or)}function AZ(h,l,u){if(h.x<0||h.x>=or||l.x<0||l.x>=or||u.x<0||u.x>=or)return!1;const m=u.sub(l),x=m.perp(),b=h.sub(l);return(m.x*b.x+m.y*b.y)/Math.sqrt((m.x*m.x+m.y*m.y)*(b.x*b.x+b.y*b.y))>-.866&&x.x*b.x+x.y*b.y<0}function kZ(h,l,u){const m=l?2|h:-3&h;return u?1|m:-2&m}function NZ(){const h=Math.PI/32,l=Math.tan(h),u=Ge;return u*Math.sqrt(1+2*l*l)-u}function CZ(h,l,u){const m=1<{for(const ze of Ie)X.push({polygon:ze,bounds:We})},se=Math.ceil(Math.log2($)),ae=Math.ceil(Math.log2(U)),he=se-ae,ue=[];for(let Ie=0;Ie0?0:1);for(let Ie=0;IeWe+1?Ne.push({polygons:At,bounds:kt,depth:We+1}):te(At,kt)}if(Pt.length){const kt=[new Ft(ze===0?bt:He.x,ze===1?bt:He.y),Ue];ue.length>We+1?Ne.push({polygons:Pt,bounds:kt,depth:We+1}):te(Pt,kt)}}return X}(h,l,Math.ceil((b-x)/11.25),Math.ceil((T-A)/11.25),1,(C,O,$)=>{if(C===0)return .5*(O+$);{const U=gt((u.y+O/or)/m);return(Bt(.5*(gt((u.y+$/or)/m)+U))*m-u.y)*or}})}function fNe(h,l,u,m,x,b){const T=Math.pow(2,m.z-x.z);for(let A=0;A=C[T]&&(A=l,C=h),A[T]x&&LZ(A,C,T,x),A[T]b&&LZ(C,A,T,b)}}function ZI(h,l,u,m,x,b){const T=[];for(let A=0;A=m&&X.x>=m||(K.x>=m?K=new Ft(m,K.y+(m-K.x)/(X.x-K.x)*(X.y-K.y))._round():X.x>=m&&(X=new Ft(m,K.y+(m-K.x)/(X.x-K.x)*(X.y-K.y))._round()),K.y>=x&&X.y>=x||(K.y>=x?K=new Ft(K.x+(x-K.y)/(X.y-K.y)*(X.x-K.x),x)._round():X.y>=x&&(X=new Ft(K.x+(x-K.y)/(X.y-K.y)*(X.x-K.x),x)._round()),O&&K.equals(O[O.length-1])||(O=[K],T.push(O),b&&b.push({progress:{min:se+DZ(ae,he,K)*te,max:1},parentIndex:A,prevPoint:ae,nextPoint:he})),O.push(X),b&&(b[b.length-1].progress.max=se+DZ(ae,he,X)*te,b[b.length-1].nextPoint=he)))))}if(b&&U>0)for(let q=$;qO.t-$.t);let T=0,A=0,C=[];for(m.push(C);T!==h.length;){if(A===b.length){for(;T!==h.length;)C.length!==0&&C[C.length-1].equals(h[T])||C.push(h[T]),T++;break}b[A].t<=T?(C.length!==0&&C[C.length-1].equals(b[A].point)||C.push(b[A].point),Math.trunc(b[A].t),A++):(C.length!==0&&C[C.length-1].equals(h[T])||C.push(h[T]),T++)}}function DZ(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 Nj(h,l){return h.x*l.x+h.y*l.y}function OZ(h,l){if(h.length===1){let u=0;const m=l[u++];let x;for(;!x||m.equals(x);)if(x=l[u++],!x)return 1/0;for(;u{bt[0]=At,bt[1]=Pt,bt[2]=kt,bt[3]=1},yt=NZ();K>0&&(K+=yt),X+=yt;for(const bt of q){const At=[],Pt=[];for(const kt of bt){const zt=kt.x+te.x,mt=kt.y+te.y,Nt=U.projection.projectTilePoint(zt,mt,Ne),Mt=U.projection.upVector(Ne,kt.x,kt.y);let Vt=K,Yt=X;if(ae){const xr=$Z(zt,mt,K,X,ae,he,ue,be);Vt+=xr.base,Yt+=xr.top}K!==0?Ve(He,Nt.x+Mt[0]*ze*Vt,Nt.y+Mt[1]*ze*Vt,Nt.z+Mt[2]*ze*Vt):Ve(He,Nt.x,Nt.y,Nt.z),Ve(Ue,Nt.x+Mt[0]*ze*Yt,Nt.y+Mt[1]*ze*Yt,Nt.z+Mt[2]*ze*Yt),lr(He,He,se),lr(Ue,Ue,se),At.push(new X0(He[0],He[1],He[2])),Pt.push(new X0(Ue[0],Ue[1],Ue[2]))}Ie.push(At),We.push(Pt)}return[Ie,We]}(h,l,u,m,x,b,T,A,C,O,$):T?function(U,q,K,X,te,se,ae,he,ue){const be=[],Ne=[],Ie=[0,0,0,1];for(const We of U){const ze=[],He=[];for(const Ue of We){const Ve=Ue.x+X.x,yt=Ue.y+X.y,bt=$Z(Ve,yt,q,K,se,ae,he,ue);Ie[0]=Ve,Ie[1]=yt,Ie[2]=bt.base,Ie[3]=1,ar(Ie,Ie,te),Ie[3]=Math.max(Ie[3],1e-5);const At=new X0(Ie[0]/Ie[3],Ie[1]/Ie[3],Ie[2]/Ie[3]);Ie[0]=Ve,Ie[1]=yt,Ie[2]=bt.top,Ie[3]=1,ar(Ie,Ie,te),Ie[3]=Math.max(Ie[3],1e-5);const Pt=new X0(Ie[0]/Ie[3],Ie[1]/Ie[3],Ie[2]/Ie[3]);ze.push(At),He.push(Pt)}be.push(ze),Ne.push(He)}return[be,Ne]}(l,u,m,x,b,T,A,C,O):function(U,q,K,X,te){const se=[],ae=[],he=te[8]*q,ue=te[9]*q,be=te[10]*q,Ne=te[11]*q,Ie=te[8]*K,We=te[9]*K,ze=te[10]*K,He=te[11]*K;for(const Ue of U){const Ve=[],yt=[];for(const bt of Ue){const At=bt.x+X.x,Pt=bt.y+X.y,kt=te[0]*At+te[4]*Pt+te[12],zt=te[1]*At+te[5]*Pt+te[13],mt=te[2]*At+te[6]*Pt+te[14],Nt=te[3]*At+te[7]*Pt+te[15],Mt=kt+he,Vt=zt+ue,Yt=mt+be,xr=Math.max(Nt+Ne,1e-5),sr=kt+Ie,nr=zt+We,Zt=mt+ze,mr=Math.max(Nt+He,1e-5);Ve.push(new X0(Mt/xr,Vt/xr,Yt/xr)),yt.push(new X0(sr/mr,nr/mr,Zt/mr))}se.push(Ve),ae.push(yt)}return[se,ae]}(l,u,m,x,b)}function $Z(h,l,u,m,x,b,T,A){const C=T*x.getElevationAt(h,l,!0,!0),O=b[0]!==0,$=O?b[1]===0?T*(b[0]/7-450):T*function(U,q,K){const X=Math.floor(q[0]/8),te=Math.floor(q[1]/8),se=10*(q[0]-8*X),ae=10*(q[1]-8*te),he=U.getElevationAt(X,te,!0,!0),ue=U.getMeterToDEM(K),be=Math.floor(.5*(se*ue-1)),Ne=Math.floor(.5*(ae*ue-1)),Ie=U.tileCoordToPixel(X,te),We=2*be+1,ze=2*Ne+1,He=function(Pt,kt,zt,mt,Nt){return[Pt.getElevationAtPixel(kt,zt,!0),Pt.getElevationAtPixel(kt+Nt,zt,!0),Pt.getElevationAtPixel(kt,zt+Nt,!0),Pt.getElevationAtPixel(kt+mt,zt+Nt,!0)]}(U,Ie.x-be,Ie.y-Ne,We,ze),Ue=Math.abs(He[0]-He[1]),Ve=Math.abs(He[2]-He[3]),yt=Math.abs(He[0]-He[2])+Math.abs(He[1]-He[3]),bt=Math.min(.25,.5*ue*(Ue+Ve)/We),At=Math.min(.25,.5*ue*yt/ze);return he+Math.max(bt*se,At*ae)}(x,b,A):C;return{base:C+(u===0?-1:u),top:O?Math.max($+m,C+u+2):C+m}}const U5=4096;class pNe{constructor(l){this.module=l,this.memoryStack=this.module.malloc(U5),this.memoryStackNextFree=this.memoryStack}createIntArray(l){const u=this.memoryStackNextFree;return this.memoryStackNextFree+=l.length*Int32Array.BYTES_PER_ELEMENT,this.memoryStackNextFree-this.memoryStack>U5?-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>U5?-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,m){this.module.setFauxFacadeOptions(l?1:0,u?1:0,m)}setFacadeClassifierOptions(l){this.module.setFacadeClassifierOptions(l)}generateMesh(l,u){this.memoryStackNextFree=this.memoryStack;for(const A of l){const C=this.createIntArray(A.ringIndices),O=this.createFloatArray(A.coordinates);if(C===-1||O===-1)return`building_gen: Out of stack memory: ${this.memoryStackNextFree-this.memoryStack}/4096`;this.module.addFeature(A.id,A.sourceId,A.minHeight,A.height,A.roofType,O,C,A.ringIndices.length-1)}for(const A of u){let C;C=A.entrances?JSON.parse(A.entrances):[];const O=this.createFloatArray(C),$=this.createFloatArray(A.coordinates);if(O===-1||$===-1)return`building_gen: Out of stack memory: ${this.memoryStackNextFree-this.memoryStack}/4096`;this.module.addFacade(A.sourceId,A.crossPerc,A.distanceToRoad,O,C.length,$,A.coordinates.length)}if(!this.module.generateMesh()){const A=this.module.getLastError();return this.readStringBuffer(A)}const m=this.module.getMeshCount(),x=new Array(m);for(let A=0;A>2)-3,se=K[X++]>>2;if(X++,x.json=JSON.parse(ZZ.decode(K.subarray(X,X+se))),X+=se,X>>0,Math.ceil(1.2*be)),Ie=Math.ceil((Ne-be)/65536);try{return te.grow(Ie),se(),!0}catch{return!1}},b:ae}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(K,he):K.then(ue=>ue.arrayBuffer()).then(ue=>WebAssembly.instantiate(ue,he))).then(ue=>{const{Rb:be,Qb:Ne,P:Ie,T:We,X:ze,Ja:He,La:Ue,Qa:Ve,Va:yt,Wa:bt,eb:At,jb:Pt,f:kt,e:zt,yb:mt,zb:Nt,Ab:Mt,Bb:Vt,Db:Yt,Gb:xr}=ue.instance.exports;te=zt;const sr=(()=>{let nr=0,Zt=0,mr=0,kr=0;return zr=>{mr&&(be(kr),be(nr),Zt+=mr,mr=nr=0),nr||(Zt+=128,nr=Ne(Zt));const Rr=zr.length+7&-8;let cn=nr;Rr>=Zt&&(mr=Rr,cn=kr=Ne(Rr));for(let Un=0;Un{Rh=K,Cj=void 0}))}()),q&&$.push(function(){if(V5)return;const K=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"},he={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return{ready:se,supported:!0,decodeGltfBuffer(ue,be,Ne,Ie,We,ze){(function(He,Ue,Ve,yt,bt,At,Pt){const kt=He.exports.sbrk,zt=yt+3&-4,mt=kt(zt*bt),Nt=kt(At.length),Mt=new Uint8Array(He.exports.memory.buffer);Mt.set(At,Nt);const Vt=Ue(mt,yt,bt,Nt,At.length);if(Vt===0&&Pt&&Pt(mt,zt,bt),Ve.set(Mt.subarray(mt,mt+yt*bt)),kt(mt-kt(0)),Vt!==0)throw new Error(`Malformed buffer data: ${Vt}`)})(te,te.exports[he[We]],ue,be,Ne,Ie,te.exports[ae[ze]])}}}(fetch(To()));return K.ready.then(()=>{V5=K})}()),T)for(let K=0;K{const A=Ng(m,(C,O)=>{C?T(C):b(O)});x&&x.addEventListener("abort",()=>{A.cancel(),T(new DOMException("Aborted","AbortError"))},{once:!0})})}({url:h,type:"arrayBuffer"},l);return JZ(u,0,h,l)}function G5(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 H5(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 Gf{constructor(l,u,m,x){this.context=l,this.format=m,this.useMipmap=x&&x.useMipmap,this.texture=l.gl.createTexture(),this.update(u,{premultiply:x&&x.premultiply})}update(l,u){const m=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:A,y:C}=u&&u.position?u.position:{x:0,y:0},O=A+m,$=C+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 U=l instanceof HTMLImageElement||l instanceof HTMLCanvasElement||l instanceof HTMLVideoElement||l instanceof ImageData||ImageBitmap&&l instanceof ImageBitmap;if(!this.size&&O>0&&$>0){const q=this.useMipmap?Math.floor(Math.log2(Math.max(O,$)))+1:1;T.texStorage2D(T.TEXTURE_2D,q,this.format,O,$),this.size=[O,$]}this.size&&(U?T.texSubImage2D(T.TEXTURE_2D,0,A,C,G5(this.format),H5(this.format),l):"data"in l&&l.data&&T.texSubImage2D(T.TEXTURE_2D,0,A,C,m,x,G5(this.format),H5(this.format),l.data)),this.useMipmap&&T.generateMipmap(T.TEXTURE_2D)}bind(l,u,m=!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&&!m?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,m,x,b){const{context:T}=this,{gl:A}=T;A.bindTexture(A.TEXTURE_2D,this.texture),u!==this.magFilter&&(A.texParameteri(A.TEXTURE_2D,A.TEXTURE_MAG_FILTER,u),this.magFilter=u),l!==this.minFilter&&(A.texParameteri(A.TEXTURE_2D,A.TEXTURE_MIN_FILTER,this.useMipmap?l===A.NEAREST?A.NEAREST_MIPMAP_NEAREST:A.LINEAR_MIPMAP_LINEAR:l),this.minFilter=l),m!==this.wrapS&&(A.texParameteri(A.TEXTURE_2D,A.TEXTURE_WRAP_S,m),this.wrapS=m),x!==this.wrapT&&(A.texParameteri(A.TEXTURE_2D,A.TEXTURE_WRAP_T,x),this.wrapT=x),b!==this.compareMode&&(b?(A.texParameteri(A.TEXTURE_2D,A.TEXTURE_COMPARE_MODE,A.COMPARE_REF_TO_TEXTURE),A.texParameteri(A.TEXTURE_2D,A.TEXTURE_COMPARE_FUNC,b)):A.texParameteri(A.TEXTURE_2D,A.TEXTURE_COMPARE_MODE,A.NONE),this.compareMode=b)}destroy(){const{gl:l}=this.context;l.deleteTexture(this.texture),this.texture=null}}class Pj{constructor(l,u){this.context=l,this.texture=u}bind(l,u){const{context:m}=this,{gl:x}=m;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 wNe=Rn([{name:"a_pos_3f",components:3,type:"Float32"}]),SNe=Rn([{name:"a_color_3f",components:3,type:"Float32"}]),TNe=Rn([{name:"a_color_4f",components:4,type:"Float32"}]),ENe=Rn([{name:"a_uv_2f",components:2,type:"Float32"}]),jNe=Rn([{name:"a_normal_3f",components:3,type:"Float32"}]),ANe=Rn([{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"}]),kNe=Rn([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]);function tX(h,l){const u=eP(h.projection,h.zoom,h.width,h.height),m=function(b,T,A,C,O){const $=new Qe(A.lng-180*ay,A.lat),U=new Qe(A.lng+180*ay,A.lat),q=b.project($.lng,$.lat),K=b.project(U.lng,U.lat),X=-Math.atan2(K.y-q.y,K.x-q.x),te=Ar.fromLngLat(A);te.y=fe(te.y,-1+ay,1-ay);const se=te.toLngLat(),ae=b.project(se.lng,se.lat),he=Ar.fromLngLat(se);he.x+=ay;const ue=he.toLngLat(),be=b.project(ue.lng,ue.lat),Ne=nX(be.x-ae.x,be.y-ae.y,X),Ie=Ar.fromLngLat(se);Ie.y+=ay;const We=Ie.toLngLat(),ze=b.project(We.lng,We.lat),He=nX(ze.x-ae.x,ze.y-ae.y,X),Ue=Math.abs(Ne.x)/Math.abs(He.y),Ve=P([]);Y(Ve,Ve,-X*(1-(O?0:C)));const yt=P([]);return V(yt,yt,[1,1-(1-Ue)*C,1]),yt[4]=-He.x/He.y*C,Y(yt,yt,X),D(yt,Ve,yt),yt}(h.projection,0,h.center,u,l),x=rX(h);return V(m,m,[x,x,1]),m}function rX(h){const l=h.projection,u=eP(h.projection,h.zoom,h.width,h.height),m=W5(l,h.center),x=W5(l,Qe.convert(l.center));return Math.pow(2,m*u+(1-u)*x)}function eP(h,l,u,m,x=1/0){const b=h.range;if(!b)return 0;const T=Math.min(x,Math.max(u,m)),A=Math.log2(T/1024);return Oe(b[0]+A,b[1]+A,l)}const ay=1/4e4;function W5(h,l){const u=fe(l.lat,-85.051129,Tt),m=new Qe(l.lng-180*ay,u),x=new Qe(l.lng+180*ay,u),b=h.project(m.lng,u),T=h.project(x.lng,u),A=Ar.fromLngLat(m),C=Ar.fromLngLat(x),O=T.x-b.x,$=T.y-b.y,U=C.x-A.x,q=C.y-A.y,K=Math.sqrt((U*U+q*q)/(O*O+$*$));return Math.log2(K)}function nX(h,l,u){const m=Math.cos(u),x=Math.sin(u);return{x:h*m-l*x,y:h*x+l*m}}function sX(h,l,u){P(h),Y(h,h,Xn(l[2])),G(h,h,Xn(l[0])),W(h,h,Xn(l[1])),V(h,h,u),D(h,h,[1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1])}function tP(h,l,u,m,x,b,T,A){const C=[u[0]-l[0],u[1]-l[1],0],O=[m[0]-l[0],m[1]-l[1],0];if(Le(C)<1e-12||Le(O)<1e-12)return pr(h);const $=tr([],C,O);pt($,$),je(O,m,l),C[2]=(b-x)*A,O[2]=(T-x)*A;const U=C;return tr(U,C,O),pt(U,U),ua(h,$,U)}function rP(h,l,u=!1){const m=gp(l.zoom),x=function(b,T,A){const C=T.worldSize,O=[b[12],b[13],b[14]],$=gt(O[1]/C),U=tt(O[0]/C),q=P([]),K=lt(1,$)*C,X=lt(1,0)*C*Wt($,T.zoom),te=1/x5(C);let se=X*te;if(A){const be=eP(T.projection,T.zoom,T.width,T.height,1024);se=te*T.projection.pixelSpaceConversion(T.center.lat,C,be)}const ae=Be($,U);me(ae,ae,qe([],pt([],ae),K*se*O[2]));const he=function(be){const Ne=[be[0],be[1],be[2]];let Ie=[0,1,0];const We=tr([],Ie,Ne);return tr(Ie,Ne,We),vt(Ie)===0&&(Ie=[0,1,0],tr(We,Ne,Ie)),pt(We,We),pt(Ie,Ie),pt(Ne,Ne),[We[0],We[1],We[2],0,Ie[0],Ie[1],Ie[2],0,Ne[0],Ne[1],Ne[2],0,be[0],be[1],be[2],1]}(ae);V(q,q,[se,se,se*K]),B(q,q,[-O[0],-O[1],-O[2]]);const ue=D([],T.globeMatrix,he);return D(ue,ue,q),D(ue,ue,b),ue}(h,l,u);if(m>0){const b=function(T,A){const C=A.worldSize,O=lt(1,0)*C*Wt(A.center.lat,A.zoom)/x5(C),$=lt(1,A.center.lat)*C,U=P([]);W(U,U,Xn(A.center.lng)),G(U,U,Xn(A.center.lat)),B(U,U,[0,0,Me]),V(U,U,[O,O,O*$]);const q=A.point;return B(U,U,[-q.x,-q.y,0]),D(U,U,T),D(U,A.globeMatrix,U)}(h,l);return function(T,A,C){const O=(X,te,se)=>{const ae=Le(X),he=Le(te),ue=pp(X,te,se);return qe(ue,ue,1/Le(ue)*Qr(ae,he,se))},$=O([T[0],T[1],T[2]],[A[0],A[1],A[2]],C),U=O([T[4],T[5],T[6]],[A[4],A[5],A[6]],C),q=O([T[8],T[9],T[10]],[A[8],A[9],A[10]],C),K=pp([T[12],T[13],T[14]],[A[12],A[13],A[14]],C);return[$[0],$[1],$[2],0,U[0],U[1],U[2],0,q[0],q[1],q[2],0,K[0],K[1],K[2],1]}(x,b,m)}return x}function K5(h,l,u,m){const x=us.projectAabbCorners(m,u);let b=Number.MAX_VALUE;for(let A=0;A0||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])&&($=K)}U=$}while(U!==O);return C.length>0&&C.push(C[0]),C}(x);if(Ri(h,T))return b}const Q0=64,Xb={CoordinateSpaceTile:1,HasMapboxMeshFeatures:4,HasMeshoptCompression:8};function nP(h,l,u,m,x,b,T,A,C,O=!1){const $=u.zoom,U=u.project(m),q=Wt(m.lat,$),K=1/q;P(h),B(h,h,[U.x+T[0]*K,U.y+T[1]*K,T[2]]);let X=1,te=1;const se=u.worldSize;if(O){if(u.projection.name==="mercator"){let be=0;u.elevation&&(be=u.elevation.getAtPointOrZero(new Ar(U.x/se,U.y/se),0));const Ne=ar([],[U.x,U.y,be,1],u.projMatrix)[3]/u.cameraToCenterDistance;X=Ne,te=Ne*Wt(u.center.lat,$)}else if(u.projection.name==="globe"){const be=rP(h,u),Ne=[0,0,0,1];ar(Ne,Ne,D([],u.projMatrix,be));const Ie=Ne[3]/u.cameraToCenterDistance,We=gp($),ze=u.projection.pixelsPerMeter(m.lat,se)*Wt(m.lat,$),He=u.projection.pixelsPerMeter(u.center.lat,se)*Wt(u.center.lat,$);X=Ie/Qr(ze,rr(u.center.lat),We),te=Ie*q/ze,X*=He,te*=He}}else X=K;V(h,h,[X,X,te]);const ae=[...h],he=l.orientation,ue=[];if(sX(ue,[he[0]+(x?x[0]:0),he[1]+(x?x[1]:0),he[2]+(x?x[2]:0)],b),D(h,ae,ue),A&&u.elevation){let be=0;const Ne=[];if(C&&u.elevation){be=function(We,ze,He,Ue,Ve){const yt=ze.elevation;if(!yt)return 0;const bt=us.projectAabbCorners(He,Ue),At=lt(1,Ve.lat)*ze.worldSize,Pt=function(Zt,mr){const kr=[0,0,1],zr=[{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 Rr of zr){const cn=Zt[Rr.corners[0]],Un=Zt[Rr.corners[1]],un=Zt[Rr.corners[2]],Gn=[Un[0]-cn[0],Un[1]-cn[1],mr*(Un[2]-cn[2])],wn=tr(Gn,Gn,[un[0]-cn[0],un[1]-cn[1],mr*(un[2]-cn[2])]);pt(wn,wn),Rr.dotProductWithUp=Ct(wn,kr)}return zr.sort((Rr,cn)=>Rr.dotProductWithUp-cn.dotProductWithUp),zr[0].corners}(bt,At),kt=bt[Pt[0]],zt=bt[Pt[1]],mt=bt[Pt[2]],Nt=bt[Pt[3]],Mt=yt.getAtPointOrZero(new Ar(kt[0]/ze.worldSize,kt[1]/ze.worldSize),0),Vt=yt.getAtPointOrZero(new Ar(zt[0]/ze.worldSize,zt[1]/ze.worldSize),0),Yt=yt.getAtPointOrZero(new Ar(mt[0]/ze.worldSize,mt[1]/ze.worldSize),0),xr=yt.getAtPointOrZero(new Ar(Nt[0]/ze.worldSize,Nt[1]/ze.worldSize),0),sr=(Mt+xr)/2,nr=(Vt+Yt)/2;return sr>nr?Vt=l.gl.NEAREST_MIPMAP_NEAREST}),h.uploaded=!0,h.image=null)}function NNe(h,l,u){h.indexBuffer=l.createIndexBuffer(h.indexArray,!1,!0),h.vertexBuffer=l.createVertexBuffer(h.vertexArray,wNe.members,!1,!0),h.normalArray&&(h.normalBuffer=l.createVertexBuffer(h.normalArray,jNe.members,!1,!0)),h.texcoordArray&&(h.texcoordBuffer=l.createVertexBuffer(h.texcoordArray,ENe.members,!1,!0)),h.colorArray&&(h.colorBuffer=l.createVertexBuffer(h.colorArray,(h.colorArray.bytesPerElement===12?SNe:TNe).members,!1,!0)),h.featureArray&&(h.pbrBuffer=l.createVertexBuffer(h.featureArray,kNe.members,!0)),h.segments=Cs.simpleSegment(0,0,h.vertexArray.length,h.indexArray.length);const m=h.material;m.pbrMetallicRoughness.baseColorTexture&&Rj(m.pbrMetallicRoughness.baseColorTexture,l),m.pbrMetallicRoughness.metallicRoughnessTexture&&Rj(m.pbrMetallicRoughness.metallicRoughnessTexture,l),m.normalTexture&&Rj(m.normalTexture,l),m.occlusionTexture&&Rj(m.occlusionTexture,l,u),m.emissionTexture&&Rj(m.emissionTexture,l)}function Y5(h,l,u){if(h.meshes)for(const m of h.meshes)NNe(m,l,u);if(h.children)for(const m of h.children)Y5(m,l,u)}function sP(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)sP(l)}function CNe(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 Z5(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&&CNe(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)Z5(l)}function J0(h,l){const u=h.json.bufferViews[l.bufferView],m=QI[l.componentType];return new m(h.buffers[u.buffer],(l.byteOffset||0)+(u.byteOffset||0),l.count*(u.byteStride&&u.byteStride!==Ij[l.type]*m.BYTES_PER_ELEMENT?u.byteStride/m.BYTES_PER_ELEMENT:Ij[l.type]))}function X5(h,l,u,m){const x=QI[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],A=T.byteStride?T.byteStride/x.BYTES_PER_ELEMENT:Ij[l.type],C=u.float32,O=C.length/u.capacity;for(let $=0,U=0;$0){for(let se=0;se0){b.texcoordArray=new dp;const q=l.json.accessors[x.TEXCOORD_0];b.texcoordArray.resize(q.count);const K=J0(l,q);X5(l,q,b.texcoordArray,K)}if(x._FEATURE_ID_RGBA4444!==void 0){const q=l.json.accessors[x._FEATURE_ID_RGBA4444];l.json.extensionsUsed&&l.json.extensionsUsed.includes("EXT_meshopt_compression")&&(b.featureData=J0(l,q))}x._FEATURE_RGBA4444!==void 0&&(b.featureData=new Uint32Array(J0(l,l.json.accessors[x._FEATURE_RGBA4444]).buffer));const U=h.material;return b.material=function(q,K){const{emissiveFactor:X=[0,0,0],alphaMode:te="OPAQUE",alphaCutoff:se=.5,normalTexture:ae,occlusionTexture:he,emissiveTexture:ue,doubleSided:be,name:Ne}=q,{baseColorFactor:Ie=[1,1,1,1],metallicFactor:We=1,roughnessFactor:ze=1,baseColorTexture:He,metallicRoughnessTexture:Ue}=q.pbrMetallicRoughness||{},Ve=he?K[he.index]:void 0;if(he&&he.extensions&&he.extensions.KHR_texture_transform&&Ve){const yt=he.extensions.KHR_texture_transform;Ve.offsetScale=[yt.offset[0],yt.offset[1],yt.scale[0],yt.scale[1]]}return{name:Ne,pbrMetallicRoughness:{baseColorFactor:new Qn(...Ie),metallicFactor:We,roughnessFactor:ze,baseColorTexture:He?K[He.index]:void 0,metallicRoughnessTexture:Ue?K[Ue.index]:void 0},doubleSided:be,emissiveFactor:new Qn(...X),alphaMode:te,alphaCutoff:se,normalTexture:ae?K[ae.index]:void 0,occlusionTexture:Ve,emissionTexture:ue?K[ue.index]:void 0,defined:q.defined===void 0}}(U!==void 0?l.json.materials[U]:{defined:!1},u),b}function aX(h,l,u){const{matrix:m,rotation:x,translation:b,scale:T,mesh:A,extras:C,children:O,name:$}=h,U={};if(U.name=$,U.localMatrix=m||function(q,K,X,te){var se=K[0],ae=K[1],he=K[2],ue=K[3],be=se+se,Ne=ae+ae,Ie=he+he,We=se*be,ze=se*Ne,He=se*Ie,Ue=ae*Ne,Ve=ae*Ie,yt=he*Ie,bt=ue*be,At=ue*Ne,Pt=ue*Ie,kt=te[0],zt=te[1],mt=te[2];return q[0]=(1-(Ue+yt))*kt,q[1]=(ze+Pt)*kt,q[2]=(He-At)*kt,q[3]=0,q[4]=(ze-Pt)*zt,q[5]=(1-(We+yt))*zt,q[6]=(Ve+bt)*zt,q[7]=0,q[8]=(He+At)*mt,q[9]=(Ve-bt)*mt,q[10]=(1-(We+Ue))*mt,q[11]=0,q[12]=X[0],q[13]=X[1],q[14]=X[2],q[15]=1,q}([],x||[0,0,0,1],b||[0,0,0],T||[1,1,1]),U.globalMatrix=R(U.localMatrix),A!==void 0){U.meshes=u[A];const q=U.anchor=[0,0];for(const K of U.meshes){const{min:X,max:te}=K.aabb;q[0]+=X[0]+te[0],q[1]+=X[1]+te[1]}q[0]=Math.floor(q[0]/U.meshes.length/2),q[1]=Math.floor(q[1]/U.meshes.length/2)}if(C&&(C.id&&(U.id=C.id),C.lights&&(U.lights=function(q){if(!q.length)return[];const K=function(he){const ue=atob(he),be=new Uint8Array(ue.length);for(let Ne=0;Ne1&&m[m.length-1].equals(m[0])&&m.pop();let x=0;for(let T=0;T0&&m.reverse();const b=Hb(m.flatMap(T=>[T.x,T.y]),[]);return b.length===0?null:{vertices:m,indices:b}}function LNe(h,l){const u=[],m=[];let x=0;const b=[];for(const T of h){x=u.length;const A=T.vertexArray.float32,C=T.indexArray.uint16;for(let O=0;O0&&([m[T+1],m[T+2]]=[m[T+2],m[T+1]])}return{vertices:u,indices:m}}function Q5(h){const l=function(C,O){const $=[],U=WebGL2RenderingContext;if(C.json.textures)for(const q of C.json.textures){const K={magFilter:U.LINEAR,minFilter:U.NEAREST,wrapS:U.REPEAT,wrapT:U.REPEAT};q.sampler!==void 0&&Object.assign(K,C.json.samplers[q.sampler]),$.push({image:O[q.source],sampler:K,uploaded:!1})}return $}(h,h.images),u=function(C,O){const $=[];for(const U of C.json.meshes){const q=[];for(const K of U.primitives)q.push(INe(K,C,O));$.push(q)}return $}(h,l),{scenes:m,scene:x,nodes:b}=h.json,T=m?m[x||0].nodes:[...b.keys()],A=[];for(const C of T)A.push(aX(b[C],h,u));return function(C,O,$){const U={},q=new Set;for(let K=0;K0){const K=Array.from(q.values()).sort((X,te)=>X-te);for(let X=K.length-1;X>=0;X--)C.splice(K[X],1)}}(A,T,h.json.nodes),A}function MNe(h){h.heightmap=new Float32Array(4096),h.heightmap.fill(-1);const l=h.vertexArray.float32,u=h.aabb.min[0]-1,m=h.aabb.min[1]-1,x=Q0/(h.aabb.max[0]-u+2),b=Q0/(h.aabb.max[1]-m+2);for(let T=0;Th.heightmap[O*Q0+C]&&(h.heightmap[O*Q0+C]=A)}}function oX(h,l,u,m,x){u.reserve(u.length+4*h.length),m.reserve(m.length+10*h.length),x.reserve(x.length+10*h.length);let b=m.length;for(const T of h){const A=Math.min(10,Math.max(4,1.3*T.height))*l,C=[-T.normal[1],T.normal[0],0],O=Math.min(.29,.1*T.width/T.depth),$=T.width-2*T.depth*l*(O+.01),U=nt([],T.pos,C,$/2),q=nt([],T.pos,C,-$/2),K=[U[0],U[1],U[2]+T.height],X=[q[0],q[1],q[2]+T.height],te=nt([],T.normal,C,O);qe(te,te,A);const se=nt([],T.normal,C,-O);qe(se,se,A),me(te,U,te),me(se,q,se),U[2]+=.1,q[2]+=.1,m.emplaceBack(te[0],te[1],te[2]),m.emplaceBack(se[0],se[1],se[2]),m.emplaceBack(U[0],U[1],U[2]),m.emplaceBack(q[0],q[1],q[2]),m.emplaceBack(K[0],K[1],K[2]),m.emplaceBack(X[0],X[1],X[2]),m.emplaceBack(U[0],U[1],U[2]),m.emplaceBack(q[0],q[1],q[2]),m.emplaceBack(te[0],te[1],te[2]),m.emplaceBack(se[0],se[1],se[2]);const ae=$/A/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 DNe(h,l){const u={};u.indexArray=new bi,u.vertexArray=new xu,u.colorArray=new Ih,oX(h,l,u.indexArray,u.vertexArray,u.colorArray);const m={defined:!0};m.emissiveFactor=Qn.black;const x={};return x.baseColorFactor=Qn.white,m.pbrMetallicRoughness=x,u.material=m,u.aabb=new us([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),u}const lX=Rn([{name:"a_pos_3f",components:3,type:"Float32"}]),ONe=Rn([{name:"a_normal_3",components:3,type:"Int16"}]),FNe=Rn([{name:"a_centroid_3",components:3,type:"Int16"}]),cX=Rn([{name:"a_part_color_emissive",components:2,type:"Uint16"}]),BNe=Rn([{name:"a_faux_facade_color_emissive",components:2,type:"Uint16"}]),$Ne=Rn([{name:"a_faux_facade_data",components:4,type:"Uint16"}]),zNe=Rn([{name:"a_faux_facade_vertical_range",components:2,type:"Uint16"}]),UNe=Rn([{name:"a_bloom_attenuation",components:4,type:"Float32"}]),VNe=Rn([{name:"a_flood_light_wall_radius_1i16",components:1,type:"Int16"}]),uX=rn.types,iP=32767;function qNe(h,l){const u=or+l;for(const m of h)for(const x of m)if(x.x<-l||x.x>u||x.y<-l||x.y>u)return!1;return!0}function GNe(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 J5{constructor(){this.layoutVertexArray=new xu,this.layoutAttenuationArray=new Ih,this.layoutColorArray=new vu,this.indexArray=new bi,this.indexArrayForConflation=new bi,this.segmentsBucket=new Cs}}class eB{constructor(l){this.layoutFacadePaintArray=null,this.layoutFacadeDataArray=null,this.layoutFacadeVerticalRangeArray=null,this.segmentsBucket=new Cs,this.entranceBloom=new J5;const u=66560;this.layoutVertexArray=new xu,this.layoutVertexArray.reserve(u),this.layoutNormalArray=new Od,this.layoutNormalArray.reserve(u),this.layoutCentroidArray=new Od,this.layoutCentroidArray.reserve(u),this.layoutColorArray=new vu,this.layoutColorArray.reserve(u),this.layoutFloodLightDataArray=new $b,this.layoutFloodLightDataArray.reserve(u),this.layoutAOArray=new zb,this.layoutAOArray.reserve(u),this.indexArray=new bi,this.indexArray.reserve(66560),this.indexArrayForConflation=new bi,this.segmentsBucket=new Cs,this.entranceBloom=new J5,l&&(this.layoutFacadePaintArray=new vu,this.layoutFacadeDataArray=new Jg,this.layoutFacadeVerticalRangeArray=new vu)}reserve(l,u,m){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),m&&(this.layoutFacadePaintArray.reserveForAdditional(l),this.layoutFacadeDataArray.reserveForAdditional(l),this.layoutFacadeVerticalRangeArray.reserveForAdditional(l))}}class dX{constructor(l){this.colorBufferUploaded=!1,this.maxHeight=0,this.replacementUpdateTime=0,this.activeReplacements=[],this.footprints=[],this.footprintsVertices=new dp,this.footprintsIndices=new hp,this.footprintsMin=new Ft(1/0,1/0),this.footprintsMax=new Ft(-1/0,-1/0),this.featuresOnBorder=[],this.buildingWithoutFacade=new eB(!1),this.buildingWithFacade=new eB(!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 $5(l),this.groundEffect.groundRadiusArray=new Rc,this.hasAppearances=null}updateFootprints(l,u){const m=new UI([],[],1),x={vertices:[],indices:new Uint32Array(0),grid:m,min:this.footprintsMin,max:this.footprintsMax,buildingIds:this.buildingIds};u.push({footprint:x,id:l})}updateAppearances(l,u,m,x){return{hasLayoutChanges:!1,hasUboChanges:!1}}prepare(){return function(){if(XI!=null||zZ!=null)return null;if(Zb!=null)return Zb;const l=fetch(po());return Zb=function(u){let m,x,b,T,A;function C(){m=new Uint8Array(A.buffer),x=new Int16Array(A.buffer),b=new Int32Array(A.buffer),T=new Float32Array(A.buffer)}function O(){throw new Error("Unexpected BuildingGen error.")}const $=()=>{},U={a:{a:O,f:function(q){const K=m.length,X=Math.max(q>>>0,Math.ceil(1.2*K)),te=Math.ceil((X-K)/65536);try{return A.grow(te),C(),!0}catch{return!1}},g:O,b:$,c:$,d:$,e:$}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(u,U):u.then(q=>q.arrayBuffer()).then(q=>WebAssembly.instantiate(q,U))).then(q=>{const K=q.instance.exports;return(0,K.g)(),A=K.f,C(),new pNe({setStyle:K.h,setAOOptions:K.i,setMetricOptions:K.j,setStructuralOptions:K.k,setFacadeOptions:K.l,setFauxFacadeOptions:K.m,setFacadeClassifierOptions:K.n,addFeature:K.o,addFacade:K.p,generateMesh:K.q,getLastError:K.r,getOuterRingLength:K.s,getMeshCount:K.t,getPositionsPtr:K.u,getPositionsLength:K.v,getNormalsPtr:K.w,getNormalsLength:K.x,getAOPtr:K.y,getAOLength:K.z,getUVPtr:K.A,getUVLength:K.B,getFauxFacadePtr:K.C,getFauxFacadeLength:K.D,getIndicesPtr:K.E,getIndicesLength:K.F,getBuildingPart:K.G,getRingCount:K.H,getRingPtr:K.I,getRingLength:K.J,malloc:K.K,free:K.L,heapU8:m,heap16:x,heap32:b,heapF32:T})})}(l).then(u=>(Zb=null,XI=u,XI)).catch(u=>{$r("Could not load building-gen"),Zb=null,zZ=u instanceof Error?u:new Error("Unknown error")}),Zb}()}populate(l,u,m,x){const b=gNe();if(!b)return;const T=Ot(m);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 A=new Map,C=new Map;let O=0;for(const{feature:ae}of l){if(uX[ae.type]!=="LineString"){A.set(ae.id,ae.properties.source_id);continue}const he=this.layers[0]._featureFilter.needGeometry;if(he&&!this.layers[0]._featureFilter.filter(new as(this.zoom),ae,m))continue;const ue=bn(ae,he);if(!he&&!this.layers[0]._featureFilter.filter(new as(this.zoom),ue,m))continue;const be=he?ue.geometry:Ur(ae,m,x),Ne=[];for(const He of be)for(const Ue of He)Ne.push(Ue.x),Ne.push(Ue.y);const Ie={coordinates:Ne,crossPerc:ae.properties.cross_perc,distanceToRoad:ae.properties.distance_to_road,entrances:ae.properties.entrances,sourceId:0},We=ae.properties.source_id;let ze=C.get(We);ze||(ze=[],C.set(We,ze)),ze.push(Ie),++O}this.maxHeight=0;const $=new Array,U=new Set,q=ae=>{ae!=null&&U.add(ae)},K=(ae,he)=>{ae!=null&&$.push({buildingId:ae,footprintIndex:he})},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:he,index:ue,sourceLayerIndex:be}of l){if(uX[ae.type]==="LineString")continue;const Ne=this.layers[0]._featureFilter.needGeometry;if(Ne&&!this.layers[0]._featureFilter.filter(new as(this.zoom),ae,m))continue;let Ie=null;if(ae.properties&&ae.properties.hasOwnProperty("building_id")&&(Ie=Number(ae.properties.building_id),U.has(Ie)))continue;const We=bn(ae,Ne);if(!Ne&&!this.layers[0]._featureFilter.filter(new as(this.zoom),We,m))continue;const ze=Ne?We.geometry:Ur(ae,m,x),He=wj(ze,500);let Ue=!1;for(const Cn of He)if(Cn.length!==1){Ue=!0;break}if(Ue){q(Ie);continue}if(!qNe(ze,163)){q(Ie);continue}const Ve=this.layers[0],yt=GNe(Ve.layout.get("building-roof-shape").evaluate(ae,{},m)),bt=Ve.layout.get("building-base").evaluate(ae,{},m),At=Ve.layout.get("building-height").evaluate(ae,{},m),Pt=Ve.layout.get("building-flood-light-ground-radius").evaluate(ae,{},m),kt=Ve.paint.get("building-ambient-occlusion-intensity"),zt=Pt/this.tileToMeter;ae.properties["building-part"]="roof";const mt=Ve.paint.get("building-color").evaluate(ae,{},this.canonical).toPremultipliedRenderColor(this.lut),Nt=Ve.paint.get("building-emissive-strength").evaluate(ae,{},this.canonical);ae.properties["building-part"]="wall";const Mt=Ve.paint.get("building-color").evaluate(ae,{},this.canonical).toPremultipliedRenderColor(this.lut),Vt=Ve.paint.get("building-emissive-strength").evaluate(ae,{},this.canonical);ae.properties["building-part"]="window";const Yt=Ve.paint.get("building-color").evaluate(ae,{},this.canonical).toPremultipliedRenderColor(this.lut),xr=Ve.paint.get("building-emissive-strength").evaluate(ae,{},this.canonical);ae.properties["building-part"]="door";const sr=Ve.paint.get("building-color").evaluate(ae,{},this.canonical).toPremultipliedRenderColor(this.lut),nr=Ve.paint.get("building-emissive-strength").evaluate(ae,{},this.canonical);let Zt=Ve.layout.get("building-flood-light-wall-radius").evaluate(ae,{},m);Zt=fe(Zt,0,2048);const mr=Zt/2048*iP,kr=A.get(he),zr=C.get(kr)||[],Rr=zr.length!==0&&Ve.layout.get("building-facade").evaluate(ae,{},m);b.setFacadeOptions(4,!0),b.setFauxFacadeOptions(Rr,!1,1);let cn=0,Un=0,un=0,Gn=0,wn=0,mi=0,os=0,Kn=0,Rs=0,ci=0,za=0;if(Rr){let Cn=Math.round(Ve.layout.get("building-facade-floors").evaluate(ae,{},m));if(bt===0){Cn=Math.max(1,Cn-(zr.length>0?1:0));let Ti=4;if(At>100){const Na=[10,13,15];Ti=Na[ae.id?ae.id%Na.length:0]}else At<=10&&(Ti=3);b.setFacadeOptions(Ti,!0),wn=(At<15?1.3:1.61803)*Ti/T}else wn=bt/T;mi=At/T,wn=Math.min(wn,mi),un=Ve.layout.get("building-facade-unit-width").evaluate(ae,{},m)/T,Gn=(mi-wn)/Cn,b.setFauxFacadeOptions(!0,!0,un);const Qa=Ve.layout.get("building-facade-window").evaluate(ae,{},m);cn=Qa[0],Un=Qa[1],os=Math.floor(65535*Math.min(1,wn/or)),Kn=Math.floor(65535*Math.min(1,mi/or)),Rs=Math.floor(255*cn)<<8|Math.floor(255*Un),ci=Math.floor(65535*Math.min(1,un/or)),za=Math.floor(65535*Math.min(1,Gn/or))}const ui=Array(He.length),wi={x:1/0,y:1/0},Zi={x:-1/0,y:-1/0},Si={x:0,y:0};let Ao=0;for(let Cn=0;Cn0){const Ti=[],Na=Array(Qa.length+1);Na[0]=0;for(let Ju=0;Juor||wi.y<0||Zi.y>or)&&this.featuresOnBorder.push({featureId:ae.id,footprintIndex:this.footprints.length});{const Cn=Hb(wp,null,2);this.footprintsIndices.resize(this.footprintsIndices.length+Cn.length),this.footprintsIndices.uint16.set(Cn,uw),this.buildingIds.add(Ie??ae.id),this.footprintsMin.x=Math.min(this.footprintsMin.x,Xu.x),this.footprintsMin.y=Math.min(this.footprintsMin.y,Xu.y),this.footprintsMax.x=Math.max(this.footprintsMax.x,Qu.x),this.footprintsMax.y=Math.max(this.footprintsMax.y,Qu.y);const Qa={footprintVertexOffset:bp,footprintVertexLength:this.footprintsVertices.length-bp,footprintIndexOffset:uw,footprintIndexLength:this.footprintsIndices.length-uw,min:Xu,max:Qu,hiddenFlags:0,indicesOffset:LP,indicesLength:qB,bloomIndicesOffset:ko,bloomIndicesLength:pi,groundEffectVertexOffset:av,groundEffectVertexLength:dw,hasFauxFacade:Rr,height:cw,promoteId:he,feature:We,parts:Za,buildingBloom:jl},Ti=this.footprints.length;ae.id!==void 0&&this.featureFootprintLookup.set(ae.id,Ti),K(Ie,Ti),this.footprints.push(Qa)}this.programConfigurations.populatePaintArrays(En.layoutVertexArray.length,ae,ue,{},u.availableImages,m,u.brightness),this.groundEffect.addPaintPropertiesData(ae,ue,{},u.availableImages,m,u.brightness),u.featureIndex.insert(ae,ze,ue,be,this.index,sl)}$.forEach(({buildingId:ae,footprintIndex:he})=>{U.has(ae)&&(this.footprints[he].hiddenFlags|=4)});const se=new Set;this.buildingIds.forEach((ae,he,ue)=>{U.has(ae)||se.add(ae)}),this.buildingIds=se,this.groundEffect.prepareBorderSegments()}update(l,u,m,x,b,T,A){this.programConfigurations.updatePaintArrays(l,u,b,m,x,T,A),this.groundEffect.update(l,u,b,m,x,T,A),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=m=>{m.layoutVertexBuffer=l.createVertexBuffer(m.layoutVertexArray,lX.members),m.layoutNormalBuffer=l.createVertexBuffer(m.layoutNormalArray,ONe.members),m.layoutCentroidBuffer=l.createVertexBuffer(m.layoutCentroidArray,FNe.members),m.layoutFloodLightDataBuffer=l.createVertexBuffer(m.layoutFloodLightDataArray,VNe.members),m.layoutFacadeDataArray&&m.layoutFacadeDataArray.length&&(m.layoutFacadeDataBuffer=l.createVertexBuffer(m.layoutFacadeDataArray,$Ne.members)),m.layoutFacadeVerticalRangeArray&&m.layoutFacadeVerticalRangeArray.length&&(m.layoutFacadeVerticalRangeBuffer=l.createVertexBuffer(m.layoutFacadeVerticalRangeArray,zNe.members)),m.entranceBloom.layoutVertexArray.length&&(m.entranceBloom.layoutVertexBuffer=l.createVertexBuffer(m.entranceBloom.layoutVertexArray,lX.members),m.entranceBloom.layoutAttenuationBuffer=l.createVertexBuffer(m.entranceBloom.layoutAttenuationArray,UNe.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,m=!0){let x=!1;const b=m?u:0,T=0|(m?-1:~u);this.groundEffect.hiddenByLandmarkVertexArray.length===0&&this.groundEffect.hiddenByLandmarkVertexArray.resize(this.groundEffect.vertexArray.length);for(const A of l){const C=this.footprints[A],O=C.hiddenFlags&T|b;C.hiddenFlags!==O&&(C.hiddenFlags=O,x=!0,this.groundEffect.updateHiddenByLandmarkRange(C.groundEffectVertexOffset,C.groundEffectVertexLength,C.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 C=x.indicesOffset;C{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))};m(this.buildingWithoutFacade),m(this.buildingWithFacade),this.indexArrayForConflationUploaded=!0}uploadUpdatedColorBuffer(l){const u=m=>{m.layoutColorBuffer?m.layoutColorBuffer.updateData(m.layoutColorArray):m.layoutColorBuffer=l.createVertexBuffer(m.layoutColorArray,cX.members,!0),m.layoutFacadePaintArray&&(m.layoutFacadePaintBuffer?m.layoutFacadePaintBuffer.updateData(m.layoutFacadePaintArray):m.layoutFacadePaintBuffer=l.createVertexBuffer(m.layoutFacadePaintArray,BNe.members,!0)),m.entranceBloom.layoutColorBuffer?m.entranceBloom.layoutColorBuffer.updateData(m.entranceBloom.layoutColorArray):m.entranceBloom.layoutColorBuffer=l.createVertexBuffer(m.entranceBloom.layoutColorArray,cX.members,!0)};u(this.buildingWithoutFacade),u(this.buildingWithFacade),this.colorBufferUploaded=!0}evaluate(l,u){const m=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 A=l.paint.get("building-color").evaluate(T,b,this.canonical).toPremultipliedRenderColor(this.lut),C=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 U=l.paint.get("building-color").evaluate(T,b,this.canonical).toPremultipliedRenderColor(this.lut),q=l.paint.get("building-emissive-strength").evaluate(T,b,this.canonical);T.properties["building-part"]="door";const K=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 he,ue=A;ae.part===1?(ue=A,he=C):ae.part===0?(ue=O,he=$):ae.part===2?(ue=U,he=q):ae.part===3&&(ue=K,he=X),he=fe(he,0,1);for(let be=0;beT.max.x||C.max.xT.max.y||C.max.yA.max.x||A.min.x>l||u>A.max.y||A.min.y>u||A.height<=m||HNe(T,this.footprintsVertices.float32.subarray(2*A.footprintVertexOffset,2*(A.footprintVertexOffset+A.footprintVertexLength)),this.footprintsIndices.uint16.subarray(A.footprintIndexOffset,A.footprintIndexOffset+A.footprintIndexLength))&&(m=A.height,this.footprintLookup[b]=A,x=A.hiddenFlags!==0);if(m!==Number.NEGATIVE_INFINITY)return{height:m,hidden:x};this.footprintLookup[b]=void 0}}function HNe(h,l,u){for(let m=0;m1&&(C=l[++A]);const $=Math.abs(O-C.left),U=Math.abs(O-C.right),q=Math.min($,U);let K;const X=b/m*(x+1);if(C.isDash){const te=x-Math.abs(X);K=Math.sqrt(q*q+te*te)}else K=x-Math.sqrt(q*q+X*X);this.image.data[T+O]=Math.max(0,Math.min(255,K+128))}}}addRegularDash(l,u){for(let C=l.length-1;C>=0;--C){const O=l[C],$=l[C+1];O.zeroLength?l.splice(C,1):$&&$.isDash===O.isDash&&($.left=O.left,l.splice(C,1))}const m=l[0],x=l[l.length-1];m.isDash===x.isDash&&(m.left=x.left-this.width,x.right=m.right+this.width);const b=this.width*this.nextRow;let T=0,A=l[T];for(let C=0;C1&&(A=l[++T]);const O=Math.abs(C-A.left),$=Math.abs(C-A.right),U=Math.min(O,$);this.image.data[b+C]=Math.max(0,Math.min(255,(A.isDash?U:-U)+u+128))}}addDash(l,u){const m=this.getKey(l,u);if(this.positions[m])return this.positions[m];const x=u==="round",b=x?7:0,T=2*b+1;if(this.nextRow+T>this.height)return $r("LineAtlas out of space"),null;l.length===0&&l.push(1);let A=0;for(let U=0;Uu.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 F0,this.layoutVertexArray2=new xu,this.patternVertexArray=new xu,this.indexArray=new bi,this.programConfigurations=new ie(l.layers,{zoom:l.zoom,lut:l.lut}),this.segments=new Cs,this.maxLineLength=0,this.zOffsetVertexArray=new xu,this.elevationGroundScaleVertexArray=new Rc,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,m,x){return{hasLayoutChanges:!1,hasUboChanges:!1}}populate(l,u,m,x){this.hasPattern=S5("line",this.layers,this.pixelRatio,u);const b=this.layers[0].layout.get("line-sort-key");this.tileToMeter=Ot(m);const T=this.layers[0].layout.get("line-elevation-reference");if(T==="hd-road-markup")this.elevationType="road";else{const q=this.layers[0].layout.get("line-z-offset"),K=q.isConstant()&&!q.constantOr(0);this.elevationType=T!=="sea"&&T!=="ground"&&K?"none":"offset",this.elevationType==="offset"&&T==="none"&&$r(`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 A=this.layers[0].layout.get("line-cross-slope");this.hasCrossSlope=this.elevationType==="offset"&&A!==void 0;const C=[];for(const{feature:q,id:K,index:X,sourceLayerIndex:te}of l){const se=this.layers[0]._featureFilter.needGeometry,ae=bn(q,se);if(!this.layers[0]._featureFilter.filter(new as(this.zoom,{worldview:this.worldview,activeFloors:u.activeFloors}),ae,m))continue;const he=b?b.evaluate(ae,{},m):void 0,ue={id:K,properties:q.properties,type:q.type,sourceLayerIndex:te,index:X,geometry:se?ae.geometry:Ur(q,m,x),patterns:{},sortKey:he};C.push(ue)}b&&C.sort((q,K)=>q.sortKey-K.sortKey);const{lineAtlas:O,featureIndex:$}=u,U=this.addConstantDashes(O);for(const q of C){const{geometry:K,index:X,sourceLayerIndex:te}=q;if(U&&this.addFeatureDashes(q,O),this.hasPattern){const se=T5("line",this.layers,q,this.zoom,this.pixelRatio,u);this.patternFeatures.push(se)}else this.addFeature(q,K,X,m,O.positions,u.availableImages,u.brightness,u.elevationFeatures);$.insert(l[X].feature,K,X,te,this.index)}}addConstantDashes(l){let u=!1;for(const m of this.layers){const x=m.paint.get("line-dasharray").value,b=m.layout.get("line-cap").value;if(x.kind!=="constant"||b.kind!=="constant")u=!0;else{const T=b.value,A=x.value;if(!A)continue;l.addDash(A,T)}}return u}addFeatureDashes(l,u){const m=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 A,C;if(b.kind==="constant"){if(A=b.value,!A)continue}else A=b.evaluate({zoom:m},l);C=T.kind==="constant"?T.value:T.evaluate({zoom:m},l),u.addDash(A,C),l.patterns[x.id]=[u.getKey(A,C)]}}update(l,u,m,x,b,T,A,C,O){this.programConfigurations.updatePaintArrays(l,u,b,m,x,T,A,O)}addFeatures(l,u,m,x,b,T){for(const A of this.patternFeatures)this.addFeature(A,A.geometry,A.index,u,m,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,JNe)),this.patternVertexArray.length!==0&&(this.patternVertexBuffer=l.createVertexBuffer(this.patternVertexArray,tCe)),!this.zOffsetVertexBuffer&&this.zOffsetVertexArray.length>0&&(this.zOffsetVertexBuffer=l.createVertexBuffer(this.zOffsetVertexArray,YNe.members,!0)),!this.elevationGroundScaleVertexBuffer&&this.elevationGroundScaleVertexArray.length>0&&(this.elevationGroundScaleVertexBuffer=l.createVertexBuffer(this.elevationGroundScaleVertexArray,ZNe.members,!0)),this.layoutVertexBuffer=l.createVertexBuffer(this.layoutVertexArray,XNe),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 m,x;if(u&&u>0?(m=`mapbox_clip_start_${u}`,x=`mapbox_clip_end_${u}`):(m="mapbox_clip_start",x="mapbox_clip_end"),l.properties&&l.properties.hasOwnProperty(m)&&l.properties.hasOwnProperty(x))return{start:+l.properties[m],end:+l.properties[x]}}addFeature(l,u,m,x,b,T,A,C){const O=this.layers[0].layout,$=O.get("line-join").evaluate(l,{}),U=O.get("line-cap").evaluate(l,{}),q=O.get("line-miter-limit"),K=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,C,$,U,q,K)){const[ae,he]=this.clipRuntimeLinesToTile(u,1);for(let ue=0;ue0?Ne.parentIndex:null)}this.fillNonElevatedRoadSegment(se)}}else for(let se=0;se0?se:null);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,l,m,b,T,x,A,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 ZI(l,-u,-u,or+u,or+u)}clipRuntimeLinesToTile(l,u){const m=[];return[ZI(l,-u,-u,or+u,or+u,m),m]}addElevatedRoadFeature(l,u,m,x,b,T,A,C){const O=[],$=Os.getElevationFeature(l,x);if($){const U=this.clipLinesToTile(u,1),q=this.prepareElevatedLines(U,$,m);for(const K of q)O.push({geometry:K,elevation:$,elevationTileID:m,segment:{progress:{min:0,max:1},nextDir:void 0,prevDir:void 0}})}if(O.length===0)return!1;for(const U of O){const q=this.layoutVertexArray.length;this.addLine(U.geometry,l,m,b,T,A,C);const K=new Vs(m,U.elevationTileID);if(U.elevation)for(let X=q;X>1,this.layoutVertexArray.int16[6*X+1]>>1),se=K.pointElevation(te,U.elevation,.05);this.updateHeightRange(se),this.zOffsetVertexArray.emplaceBack(se,0,0)}else this.fillNonElevatedRoadSegment(q)}return!0}prepareElevatedLines(l,u,m){if(u.constantHeight!=null)return l;const x=[],b=1/Ot(m);for(const T of l)mNe(T,new Mc(u,b),0,x);return x}fillNonElevatedRoadSegment(l){for(let u=l;u0,q=C&&C.progress.max<1;if(this.lineClips){let He={min:this.lineClips.start,max:this.lineClips.end},Ue=1;if(C){const bt=this.lineClips.end-this.lineClips.start;He=function(At,Pt,kt){return{min:xi(At.min,Pt,kt),max:xi(At.max,Pt,kt)}}(C.progress,{min:0,max:1},He),bt>0&&(Ue=(He.max-He.min)/bt)}const Ve=+u.properties.mapbox_clip_feature_len,yt=+u.properties.mapbox_clip_seg_len;if(Number.isNaN(Ve)||Number.isNaN(yt)){for(let At=0;At=2&&l[X-1].equals(l[X-2]);)X--;let te=0;for(;te0,Nt=this.overscaling<=16?122880/(512*this.overscaling):0;if(Ue&&Ve==="round"){if(PtT&&(Ve="bevel"),Ve==="bevel"&&(Pt>2&&(Ve="flipbevel"),Pt2*Nt){const Yt=ae.sub(ae.sub(he)._mult(Nt/Mt)._round());this.updateDistance(he,Yt),this.addCurrentVertex(Yt,be,0,0,se,ze),he=Yt}this.updateDistance(he,ae),bt._mult(Pt),this.addCurrentVertex(ae,bt,0,0,se,ze);const Vt=ae.dist(ue);if(Vt>2*Nt){const Yt=ae.add(ue.sub(ae)._mult(Nt/Vt)._round());this.updateDistance(ae,Yt),this.addCurrentVertex(Yt,Ne,0,0,se,ze),ae=Yt}}else bt._mult(Pt),this.addCurrentVertex(ae,bt,0,0,se,ze);else if(Ve==="flipbevel"){if(Pt>100)bt=Ne.mult(-1);else{const Mt=Pt*be.add(Ne).mag()/be.sub(Ne).mag();bt._perp()._mult(Mt*(mt?-1:1))}this.addCurrentVertex(ae,bt,0,0,se,ze),this.addCurrentVertex(ae,bt.mult(-1),0,0,se,ze)}else if(Ve==="bevel"||Ve==="fakeround"){const Mt=ae.dist(he);let Vt=1;if(this.elevationType==="offset"&&Ve==="bevel"&&this.currentLineJoinType!=="round"&&!this.patternJoinNone&&ze!=null&&he&&ue){const mr=4*Nt;Mt1){this.lineSoFar=l.w;const te=(u.x-l.x)/U,se=(u.y-l.y)/U,ae=(u.z-l.z)/U,he=(u.w-l.w)/U,ue=u.x-l.x,be=u.y-l.y,Ne=Math.sqrt(ue*ue+be*be);if(Ne===0)return;const Ie=-be/Ne,We=ue/Ne,ze=Ie,He=We,Ue=-Ie,Ve=-We;for(let yt=1;yt=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,$),C.primitiveLength++),T?this.e2=$:this.e1=$,O!=null&&this.zOffsetVertexArray.emplaceBack(O.zOffset,O.variableWidth,O.variableWidth),this.elevationGroundScaleValue){const U=O?O.elevationGroundScale:this.evaluateElevationGroundScale();this.elevationGroundScaleVertexArray.emplaceBack(U)}}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 tB(h,l,u){return h.xu||h.yu}let pX,gX;function yX(h,l,u){return l*(or/(h.tileSize*Math.pow(2,u-h.tileID.overscaledZ)))}_r(aP,"LineBucket",{omit:["layers","patternFeatures","currentVertex","currentVertexIsOutside"]});const xX=(h,l,u)=>(1-u)*h+u*l;function vX(h,l){return 1/yX(h,1,l.tileZoom)}function _X(h,l,u,m){return h.translatePosMatrix(m||l.tileID.projMatrix,l,u.paint.get("line-translate"),u.paint.get("line-translate-anchor"))}const bX=h=>{const l=[];wX(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 m=h.layout.get("line-join").constantOr("miter")==="none",x=!!h.paint.get("line-pattern").constantOr(1);return m&&x&&l.push("LINE_JOIN_NONE"),l};function wX(h){const l=h.paint.get("line-dasharray").value;return l.kind!=="constant"||l.value}let rB;const SX=()=>rB||(rB={layout:pX||(pX=new ri({"line-cap":new Ht(st.layout_line["line-cap"]),"line-join":new Ht(st.layout_line["line-join"]),"line-miter-limit":new Qt(st.layout_line["line-miter-limit"]),"line-round-limit":new Qt(st.layout_line["line-round-limit"]),"line-sort-key":new Ht(st.layout_line["line-sort-key"]),"line-z-offset":new Ht(st.layout_line["line-z-offset"]),"line-elevation-reference":new Qt(st.layout_line["line-elevation-reference"]),"line-cross-slope":new Qt(st.layout_line["line-cross-slope"]),visibility:new Qt(st.layout_line.visibility),"line-width-unit":new Qt(st.layout_line["line-width-unit"]),"line-elevation-ground-scale":new Ht(st.layout_line["line-elevation-ground-scale"])})),paint:gX||(gX=new ri({"line-opacity":new Ht(st.paint_line["line-opacity"]),"line-color":new Ht(st.paint_line["line-color"]),"line-translate":new Qt(st.paint_line["line-translate"]),"line-translate-anchor":new Qt(st.paint_line["line-translate-anchor"]),"line-width":new Ht(st.paint_line["line-width"]),"line-gap-width":new Ht(st.paint_line["line-gap-width"]),"line-offset":new Ht(st.paint_line["line-offset"]),"line-blur":new Ht(st.paint_line["line-blur"]),"line-dasharray":new Ht(st.paint_line["line-dasharray"]),"line-pattern":new Ht(st.paint_line["line-pattern"]),"line-pattern-cross-fade":new Qt(st.paint_line["line-pattern-cross-fade"]),"line-gradient":new Xg(st.paint_line["line-gradient"]),"line-trim-offset":new Qt(st.paint_line["line-trim-offset"]),"line-trim-fade-range":new Qt(st.paint_line["line-trim-fade-range"]),"line-trim-color":new Qt(st.paint_line["line-trim-color"]),"line-emissive-strength":new Ht(st.paint_line["line-emissive-strength"]),"line-border-width":new Ht(st.paint_line["line-border-width"]),"line-border-color":new Ht(st.paint_line["line-border-color"]),"line-occlusion-opacity":new Qt(st.paint_line["line-occlusion-opacity"]),"line-blend-mode":new Qt(st.paint_line["line-blend-mode"]),"line-color-use-theme":new Ht({type:"string",default:"default","property-type":"data-driven"}),"line-gradient-use-theme":new Ht({type:"string",default:"default","property-type":"data-driven"}),"line-trim-color-use-theme":new Ht({type:"string",default:"default","property-type":"data-driven"}),"line-border-color-use-theme":new Ht({type:"string",default:"default","property-type":"data-driven"})}))},rB);class iCe extends Ht{possiblyEvaluate(l,u){return u=new as(Math.floor(u.zoom),{now:u.now,fadeDuration:u.fadeDuration,transition:u.transition,worldview:u.worldview}),super.possiblyEvaluate(l,u)}evaluate(l,u,m,x){return u=Object.assign({},u,{zoom:Math.floor(u.zoom)}),super.evaluate(l,u,m,x)}}let Lj;function TX(h,l){return l>0?l+2*h:h}const aCe=Rn([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),oCe=Rn([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),lCe=Rn([{name:"a_projected_pos",components:4,type:"Float32"}],4);Rn([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const cCe=Rn([{name:"a_auto_z_offset",components:1,type:"Float32"}],4),uCe=Rn([{name:"a_feature_index",components:1,type:"Float32"}],4),dCe=Rn([{name:"a_x_axis",components:3,type:"Float32"},{name:"a_y_axis",components:3,type:"Float32"}]),hCe=Rn([{name:"a_texb",components:2,type:"Uint16"}]),fCe=Rn([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_elevation_from_sea",components:2,type:"Float32"}]),mCe=Rn([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"},{name:"a_auto_z_offset",components:1,type:"Float32"}]);Rn([{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 EX=Rn([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),pCe=Rn([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);Rn([{name:"triangle",components:3,type:"Uint16"}]),Rn([{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"}]),Rn([{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"}]),Rn([{type:"Float32",name:"offsetX"}]),Rn([{type:"Int16",name:"x"},{type:"Int16",name:"y"}]);const nB=class BL{constructor(l=null,u=0,m=4096){this.batchIndex=u,this.headerBuffer=null,this.propertiesBuffer=null,this.blockIndicesBuffer=null,this.context=l||null,this.propsDwords=m,this.totalBytes=4*this.propsDwords,this.headerData=new Uint32Array(BL.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,BL.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,m){const x=4*m.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++)m.dataDrivenMask&1<{if(!A)return;const O=m.getUniformBlockIndex(u,T);O!==m.INVALID_INDEX&&(m.uniformBlockBinding(u,O,C),m.bindBufferBase(m.UNIFORM_BUFFER,C,A))},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)}}};nB.HEADER_DWORDS=12,nB.HEADER_BYTES=48;let sB=nB;function iB(h,l,u,m){return[Ub(255*h,255*l),Ub(255*u,255*m)]}function jX(h,l,u,m,x,b,T,A){return!!h&&(h.kind==="constant"?h.value==="none":h.kind==="composite"||h.kind==="source"?h.evaluate({zoom:0,brightness:b,worldview:A},l,u,x,m,T)==="none":typeof h=="string"&&h==="none")}_r(sB,"SymbolPropertiesUBO",{omit:["headerBuffer","propertiesBuffer","blockIndicesBuffer"]});class aB{constructor(l,u,m,x,b="",T,A){this.layer=l,this.zoom=u,this.lut=m,this.isText=x,this.propDefs=this._getPropDefs(),this.worldview=b,this.maxUniformBufferBindings=T||24,this.uboSizeDwords=A||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 m=0,x=0,b=0,T=0;const A=[0,0,0,0,0,0,0,0,0];for(let C=0;C<9;C++){const{name:O,isColor:$,isVec2:U}=u[C],q=l.get(O),K=!(!q||typeof q.isConstant!="function"||q.isConstant()),X=this._appearancesHavePaintProperties(O),te=K||X,se=!(!q||!q.value||q.value.kind!=="composite"),ae=this.layer._transitionablePaint._values[O],he=!te&&(ae&&ae.value&&ae.value.expression&&ae.value.expression.kind)==="camera";te?(m|=1<u.hasPaintProperty(l):this.isText?u=>u.hasTextPaintProperties():u=>u.hasIconPaintProperties())}_checkIfAllPropertiesAreConstant(l,u){const m=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 A=m.get(T);if(A&&typeof A=="object"&&"isConstant"in A&&!A.isConstant())return!1}return!this._appearancesHavePaintProperties()}_hashDataDrivenValues(l,u){if(u.dataDrivenMask===0)return"";const m=[];for(let x=0;x<9;x++){if(!(u.dataDrivenMask&1<=X){$r(`Too many symbol features: batch ${q} requires binding points up to ${3*q+2}, device limit ${X}. Some features will render incorrectly.`);const se={batchIndex:0,localFeatureIndex:0,vtFeatureIndex:u,featureId:C};return this.allFeatures.push(se),C!=null&&(this.featureVertexRangesFromId.has(C)||this.featureVertexRangesFromId.set(C,[]),this.featureVertexRangesFromId.get(C).push(se)),0}this.ubos[q]||(this.ubos[q]=new sB(A,q,this.uboSizeDwords),this.ubos[q].writeHeader(O)),this.ubos[q].writeDataDrivenBlock($,K,O);const te={batchIndex:q,localFeatureIndex:K,vtFeatureIndex:u,featureId:C};return this.allFeatures.push(te),C!=null&&(this.featureVertexRangesFromId.has(C)||this.featureVertexRangesFromId.set(C,[]),this.featureVertexRangesFromId.get(C).push(te)),K}updateFeatures(l,u,m,x,b,T,A){if(this.layer=u,this.cachedConstantUniforms=null,!this.cachedHeader)return;const C=this.cachedHeader;for(const O of l){const $=this.featureVertexRangesFromId.get(O);if(!$)continue;const U=T[O]||{};for(const q of $){if(!m)continue;const K=m.feature(q.vtFeatureIndex);if(!K)continue;const X={type:K.type,id:O,properties:K.properties||{},geometry:[]},te=this.activeAppearanceByVtIndex?this.activeAppearanceByVtIndex.get(q.vtFeatureIndex):void 0,se=this.evaluateAllProperties(X,U,x,b,A,void 0,te);this.ubos[q.batchIndex]&&this.ubos[q.batchIndex].writeDataDrivenBlock(se,q.localFeatureIndex,C)}}}updateDynamicExpressions(l,u,m,x,b,T){if(this.layer=l,this.cachedConstantUniforms=null,!this.cachedHeader)return;const A=this.cachedHeader;for(const C of this.allFeatures){if(!u)continue;const O=u.feature(C.vtFeatureIndex);if(!O)continue;const $=C.featureId!=null&&b[C.featureId]||{},U={type:O.type,id:C.featureId,properties:O.properties||{},geometry:[]},q=this.activeAppearanceByVtIndex?this.activeAppearanceByVtIndex.get(C.vtFeatureIndex):void 0,K=this.evaluateAllProperties(U,$,m,x,T,void 0,q);this.ubos[C.batchIndex]&&this.ubos[C.batchIndex].writeDataDrivenBlock(K,C.localFeatureIndex,A)}}updateFeaturePaintForAppearance(l,u,m,x,b,T,A){if(!this.layer||(this.activeAppearanceByVtIndex||(this.activeAppearanceByVtIndex=new Map),this.activeAppearanceByVtIndex.set(l,A||null),!this.cachedHeader))return!1;const C=this.cachedHeader;if(C.dataDrivenMask===0)return!1;let O=!1;for(const $ of this.allFeatures){if($.vtFeatureIndex!==l)continue;const U=this.evaluateAllProperties(u,m,x,b,T,void 0,A);this.ubos[$.batchIndex]&&(this.ubos[$.batchIndex].writeDataDrivenBlock(U,$.localFeatureIndex,C),O=!0)}return O}getConstantUniformValues(l,u){const m=this.cachedHeader,x=!(!m||!m.cameraMask);if(this.cachedConstantUniforms&&this.cachedConstantBrightness===u&&(!x||this.cachedConstantRenderZoom===l))return this.cachedConstantUniforms;const b=this.layer.paint,T=this.propDefs,A=x?new as(l,{brightness:u,worldview:this.worldview}):null,C={type:1,id:void 0,properties:{},geometry:[]},O=q=>{const K=T[q],X=b.get(K.name);if(!X)return[0,0,0,1];const te=K.useThemeName?b.get(K.useThemeName):void 0,se=jX(te&&typeof te!="string"?te.value:void 0,C,{},[],void 0,u,void 0,this.worldview)?null:this.lut;let ae;ae=m&&m.cameraMask&1<{const X=b.get(T[q].name);if(!X)return K;if(m&&m.cameraMask&1<{m.text=function(x,b,T){const A=b.layout.get("text-transform").evaluate(T,{});return A==="uppercase"?x=x.toLocaleUpperCase():A==="lowercase"&&(x=x.toLocaleLowerCase()),kh.applyArabicShaping&&(x=kh.applyArabicShaping(x)),x}(m.text,l,u)}),h}const Mj={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂","←":"↑","→":"↓"};function yCe(h){return h==="︶"||h==="﹈"||h==="︸"||h==="﹄"||h==="﹂"||h==="︾"||h==="︼"||h==="︺"||h==="︘"||h==="﹀"||h==="︐"||h==="︓"||h==="︔"||h==="`"||h===" ̄"||h==="︑"||h==="︒"}function xCe(h){return h==="︵"||h==="﹇"||h==="︷"||h==="﹃"||h==="﹁"||h==="︽"||h==="︻"||h==="︹"||h==="︗"||h==="︿"}const oB=4294967296,AX=1/oB,kX=typeof TextDecoder>"u"?null:new TextDecoder("utf-8");let oP=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&m,h(x,l,this),this.pos===b&&this.skip(m)}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)*oB;return this.pos+=8,h}readSFixed64(){const h=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*oB;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,m;return m=l[this.pos++],u=127&m,m<128?u:(m=l[this.pos++],u|=(127&m)<<7,m<128?u:(m=l[this.pos++],u|=(127&m)<<14,m<128?u:(m=l[this.pos++],u|=(127&m)<<21,m<128?u:(m=l[this.pos],u|=(15&m)<<28,function(x,b,T){const A=T.buf;let C,O;if(O=A[T.pos++],C=(112&O)>>4,O<128||(O=A[T.pos++],C|=(127&O)<<3,O<128)||(O=A[T.pos++],C|=(127&O)<<10,O<128)||(O=A[T.pos++],C|=(127&O)<<17,O<128)||(O=A[T.pos++],C|=(127&O)<<24,O<128)||(O=A[T.pos++],C|=(1&O)<<31,O<128))return Qb(x,C,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&&kX?kX.decode(this.buf.subarray(l,h)):function(u,m,x){let b="",T=m;for(;T239?4:A>223?3:A>191?2:1;if(T+q>x)break;q===1?A<128&&(U=A):q===2?(C=u[T+1],(192&C)==128&&(U=(31&A)<<6|63&C,U<=127&&(U=null))):q===3?(C=u[T+1],O=u[T+2],(192&C)==128&&(192&O)==128&&(U=(15&A)<<12|(63&C)<<6|63&O,(U<=2047||U>=55296&&U<=57343)&&(U=null))):q===4&&(C=u[T+1],O=u[T+2],$=u[T+3],(192&C)==128&&(192&O)==128&&(192&$)==128&&(U=(15&A)<<18|(63&C)<<12|(63&O)<<6|63&$,(U<=65535||U>=1114112)&&(U=null))),U===null?(U=65533,q=1):U>65535&&(U-=65536,b+=String.fromCharCode(U>>>10&1023|55296),U=56320|1023&U),b+=String.fromCharCode(U),T+=q}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 m,x;if(l>=0?(m=l%4294967296|0,x=l/4294967296|0):(m=~(-l%4294967296),x=~(-l/4294967296),4294967295^m?m=m+1|0:(m=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,A){A.buf[A.pos++]=127&b|128,b>>>=7,A.buf[A.pos++]=127&b|128,b>>>=7,A.buf[A.pos++]=127&b|128,b>>>=7,A.buf[A.pos++]=127&b|128,A.buf[A.pos]=127&(b>>>=7)}(m,0,u),function(b,T){const A=(7&b)<<4;T.buf[T.pos++]|=A|((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(m,x,b){for(let T,A,C=0;C55295&&T<57344){if(!A){T>56319||C+1===x.length?(m[b++]=239,m[b++]=191,m[b++]=189):A=T;continue}if(T<56320){m[b++]=239,m[b++]=191,m[b++]=189,A=T;continue}T=A-55296<<10|T-56320|65536,A=null}else A&&(m[b++]=239,m[b++]=191,m[b++]=189,A=null);T<128?m[b++]=T:(T<2048?m[b++]=T>>6|192:(T<65536?m[b++]=T>>12|224:(m[b++]=T>>18|240,m[b++]=T>>12&63|128),m[b++]=T>>6&63|128),m[b++]=63&T|128)}return b}(this.buf,h,this.pos);const u=this.pos-l;u>=128&&NX(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&&NX(u,m,this),this.pos=u-1,this.writeVarint(m),this.pos+=m}writeMessage(h,l,u){this.writeTag(h,2),this.writeRawMessage(l,u)}writePackedVarint(h,l){l.length&&this.writeMessage(h,vCe,l)}writePackedSVarint(h,l){l.length&&this.writeMessage(h,_Ce,l)}writePackedBoolean(h,l){l.length&&this.writeMessage(h,SCe,l)}writePackedFloat(h,l){l.length&&this.writeMessage(h,bCe,l)}writePackedDouble(h,l){l.length&&this.writeMessage(h,wCe,l)}writePackedFixed32(h,l){l.length&&this.writeMessage(h,TCe,l)}writePackedSFixed32(h,l){l.length&&this.writeMessage(h,ECe,l)}writePackedFixed64(h,l){l.length&&this.writeMessage(h,jCe,l)}writePackedSFixed64(h,l){l.length&&this.writeMessage(h,ACe,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 Qb(h,l,u){return u?4294967296*l+(h>>>0):4294967296*(l>>>0)+(h>>>0)}function NX(h,l,u){const m=l<=16383?1:l<=2097151?2:l<=268435455?3:Math.floor(Math.log(l)/(7*Math.LN2));u.realloc(m);for(let x=u.pos-1;x>=h;x--)u.buf[x+m]=u.buf[x]}function vCe(h,l){for(let u=0;u=0&&m>=l&&lP[this.text.charCodeAt(m)];m--)u--;this.text=this.text.substring(l,u),this.sectionIndex=this.sectionIndex.slice(l,u)}substring(l,u){const m=new Jb;return m.text=this.text.substring(l,u),m.sectionIndex=this.sectionIndex.slice(l,u),m.sections=this.sections,m}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(Dj.forText(l.scale,l.fontStack||u));const m=this.sections.length-1;for(let x=0;x=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function lB(h,l,u,m,x,b,T,A,C,O,$,U,q,K,X,te=1,se=1){const ae=Jb.fromFeature(h,x,te,se);U===Bc.vertical&&ae.verticalizePunctuation(q);let he=[];const ue=function(ze,He,Ue,Ve,yt,bt,At=1){if(!ze)return[];const Pt=[],kt=function(Nt,Mt,Vt,Yt,xr,sr,nr=1){let Zt=0;for(let mr=0;mr=0;let mt=0;for(let Nt=0;Nt0&&sl>wn&&(wn=sl)}else{const Za=Ue[ci.fontStack];if(!Za)continue;Za[ui]&&(Si=Za[ui]);const jl=He[ci.fontStack];if(!jl)continue;const ko=jl.glyphs[ui];if(!ko)continue;if(Zi=ko.metrics,Ua=ui!==8203?$a:0,nr){const pi=jl.ascender!==void 0?Math.abs(jl.ascender):0,sl=jl.descender!==void 0?Math.abs(jl.descender):0,Xa=(pi+sl)*wi;mi-u/2;){if(T--,T<0)return!1;A-=h[T].dist(b),b=h[T]}A+=h[T].dist(h[T+1]),T++;const C=[];let O=0;for(;Am;)O-=C.shift().angleDelta;if(O>x)return!1;T++,A+=$.dist(U)}return!0}function BX(h){let l=0;for(let u=0;uO){const X=(O-C)/K,te=Qr(U.x,q.x,X),se=Qr(U.y,q.y,X),ae=new _p(te,se,0,q.angleTo(U),$);return!T||FX(h,ae,A,T,l)?ae:void 0}C+=K}}function LCe(h,l,u,m,x,b,T,A,C){const O=$X(m,b,T),$=zX(m,x),U=$*T,q=h[0].x===0||h[0].x===C||h[0].y===0||h[0].y===C;return l-U=0&&be=0&&Ne=0&&q+O<=$){const Ie=new _p(be,Ne,0,he,X);m&&!FX(h,Ie,b,m,x)||K.push(Ie)}}U+=ae}return A||K.length||T||(K=UX(h,U/2,u,m,x,b,T,!0,C)),K}function VX(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,A)=>A.h-T.h);const m=[{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 A=m.length-1;A>=0;A--){const C=m[A];if(!(T.w>C.w||T.h>C.h)){if(T.x=C.x,T.y=C.y,b=Math.max(b,T.y+T.h),x=Math.max(x,T.x+T.w),T.w===C.w&&T.h===C.h){const O=m.pop();O&&Al.id?1:h.versionl.version?1:h.sxl.sx?1:h.syl.sy?1:0}function fB(h){let l=0;for(let u=0;u0,qX(l,m,this.iconDescriptors,b),qX(u,m,this.patternDescriptors,b),this.iconDescriptors.sort(uP),this.patternDescriptors.sort(uP);let T=0;const A=x?x.data:"";A&&(T=Lh(T,fB(A))),T=Lh(T,1);for(const C of this.iconDescriptors)T=Lh(T,fB(C.id)),T=Lh(T,C.version),T=Lh(T,C.sx),T=Lh(T,C.sy);T=Lh(T,1);for(const C of this.patternDescriptors)T=Lh(T,fB(C.id)),T=Lh(T,C.version),T=Lh(T,C.sx),T=Lh(T,C.sy);this.hash=T}subsetOf(l){return this.isSubsetArray(this.iconDescriptors,l.iconDescriptors,uP)&&this.isSubsetArray(this.patternDescriptors,l.patternDescriptors,uP)}isSubsetArray(l,u,m){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 m=new Map;for(const x of u)m.set(x.key,x.value);return m}class GX{constructor(l){this.sourceAtlasHash=l}}class HX{constructor(l,u,m,x){const b=new Map,T=new Map;this.haveRenderCallbacks=[];const A=[],C=x!==void 0,O=C?new Map:void 0,$=C?gB(l,O):l,U=C?gB(u,O):u;this.addImages($,b,1,A),this.addImages(U,T,2,A);const{w:q,h:K}=VX(A),X=new Vo({width:q||1,height:K||1});for(const[te,se]of $.entries()){const ae=b.get(te).paddedRect;Vo.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 U.entries()){const ae=T.get(te),he=ae.paddedRect;let ue=ae.padding;const be=he.x+ue,Ne=he.y+ue,Ie=se.data.width,We=se.data.height;ue=ue>1?ue-1:ue,Vo.copy(se.data,X,{x:0,y:0},{x:be,y:Ne},se.data,m),Vo.copy(se.data,X,{x:0,y:We-ue},{x:be,y:Ne-ue},{width:Ie,height:ue},m),Vo.copy(se.data,X,{x:0,y:0},{x:be,y:Ne+We},{width:Ie,height:ue},m),Vo.copy(se.data,X,{x:Ie-ue,y:0},{x:be-ue,y:Ne},{width:ue,height:We},m),Vo.copy(se.data,X,{x:0,y:0},{x:be+Ie,y:Ne},{width:ue,height:We},m),Vo.copy(se.data,X,{x:Ie-ue,y:We-ue},{x:be-ue,y:Ne-ue},{width:ue,height:ue},m),Vo.copy(se.data,X,{x:0,y:We-ue},{x:be+Ie,y:Ne-ue},{width:ue,height:ue},m),Vo.copy(se.data,X,{x:0,y:0},{x:be+Ie,y:Ne+We},{width:ue,height:ue},m),Vo.copy(se.data,X,{x:Ie-ue,y:0},{x:be-ue,y:Ne+We},{width:ue,height:ue},m)}this.lut=m,this.image=X,this.iconPositions=b,this.patternPositions=T,C&&(this.contentDescriptor=new mB($,U,x,m,O))}addImages(l,u,m,x){for(const[b,T]of l.entries()){const{bin:A,imagePosition:C,imageVariant:O}=pB(b,T,m);u.set(b,C),x.push(A),T.hasRenderCallback&&this.haveRenderCallbacks.push(O.id)}}patchUpdatedImages(l,u,m,x){this.haveRenderCallbacks=this.haveRenderCallbacks.filter(b=>l.hasImage(b,m)),l.dispatchRenderCallbacks(this.haveRenderCallbacks,m);for(const b of l.getUpdatedImages(m)){for(const T of this.iconPositions.keys()){const A=gu.parse(T);if(hc.isEqual(A.id,b)){const C=l.getImage(b,m);this.patchUpdatedImage(this.iconPositions.get(T),C,u,null)}}for(const T of this.patternPositions.keys()){const A=gu.parse(T);if(hc.isEqual(A.id,b)){const C=l.getImage(b,m);this.patchUpdatedImage(this.patternPositions.get(T),C,u,x||this.lut)}}}}patchUpdatedImage(l,u,m,x=null){if(!l||!u||l.version===u.version)return;l.version=u.version;const[b,T]=l.tl,A=l.sdf;if(this.lut||A){const C={width:u.data.width,height:u.data.height},O=new Vo(C);Vo.copy(u.data,O,{x:0,y:0},{x:0,y:0},C,x,A),m.update(O,{position:{x:b,y:T},recreateWhenResize:!1})}else m.update(u.data,{position:{x:b,y:T},recreateWhenResize:!1})}}_r(Oj,"ImagePosition"),_r(HX,"ImageAtlas",{omit:["lut"]}),_r(GX,"ImageAtlasReference");class Fj{constructor(l){this.pendingRequests=new Map,this.cachedRanges=new Map,this.useServerFontComposition=!l||l.useServerFontComposition===void 0||l.useServerFontComposition}loadGlyphRange(l,u,m,x,b){if(this.useServerFontComposition)return void Fj.loadGlyphRange(l,u,m,x,b);const T=l.split(",").map(A=>A.trim()).filter(A=>A.length>0);T.length!==0?T.length!==1?this._loadMultipleFonts(T,u,m,x,b):this._loadFont(T[0],u,m,x,b):b(new Error("Empty fontstack"))}_loadMultipleFonts(l,u,m,x,b){const T=l.map(()=>null),A={completed:0,firstError:null,callbackCalled:!1},C=(O,$,U)=>{if(!A.callbackCalled&&($&&!A.firstError&&(A.firstError=$),U&&(T[O]=U),A.completed++,A.completed===l.length)){A.callbackCalled=!0;const q=T.filter(X=>X!==null);if(q.length===0)return void b(A.firstError||new Error("All fonts failed to load"));const K=this._composeGlyphs(q);b(null,K)}};for(let O=0;O{C(O,$,U)})}_loadFont(l,u,m,x,b){const T=`${l}:${u}`;if(this.cachedRanges.has(T)){const C=this.cachedRanges.get(T);return void Ul.frame(()=>b(null,C))}const A=this.pendingRequests.get(T);A?A.push(b):(this.pendingRequests.set(T,[b]),Fj.loadGlyphRange(l,u,m,x,(C,O)=>{C||this.cachedRanges.set(T,O||null);const $=this.pendingRequests.get(T);if(this.pendingRequests.delete(T),$)for(const U of $)U(C,O)}))}_composeGlyphs(l){const u={};let m,x;for(const b of l)if(m===void 0&&b.ascender!==void 0&&(m=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:m,descender:x}}}Fj.loadGlyphRange=function(h,l,u,m,x){const b=256*l,T=b+255,A=m.transformRequest(m.normalizeGlyphsURL(u).replace("{fontstack}",h).replace("{range}",`${b}-${T}`),r0.Glyphs);Cg(A,(C,O)=>{if(C)x(C);else if(O){const $={},U=function(q){return new oP(q).readFields(kCe,{})}(O);for(const q of U.glyphs)$[q.id]=q;x(null,{glyphs:$,ascender:U.ascender,descender:U.descender})}})};const Bj=1e20;function WX(h,l,u,m,x,b,T,A,C){for(let O=l;O-1);C++,b[C]=A,T[C]=O,T[C+1]=Bj}for(let A=0,C=0;A{if(T){x.ascender=T.ascender,x.descender=T.descender;for(const A in T.glyphs)this._doesCharSupportLocalGlyph(+A)||(x.glyphs[+A]=T.glyphs[+A]);x.ranges[u]=!0}for(const A of x.requests[u]||[])A(b,T);delete x.requests[u]}))}getGlyphs(l,u){const m=[],x=this.url||Dn.GLYPHS_URL;for(const b in l)for(const T of l[b])m.push({stack:b,id:T});et(m,({stack:b,id:T},A)=>{let C=this.entries[b];C||(C=this.entries[b]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let O=C.glyphs[T];if(O!==void 0)return void A(null,{stack:b,id:T,glyph:O});if(O=this._tinySDF(C,b,T),O)return C.glyphs[T]=O,void A(null,{stack:b,id:T,glyph:O});const $=Math.floor(T/256);if(256*$>65535)return $r("glyphs > 65535 not supported"),void A(null,{stack:b,id:T,glyph:O});if(C.ranges[$])return void A(null,{stack:b,id:T,glyph:O});let U=C.requests[$];U||(U=C.requests[$]=[],this.glyphLoader.loadGlyphRange(b,$,x,this.requestManager,(q,K)=>{if(K){C.ascender=K.ascender,C.descender=K.descender;for(const X in K.glyphs)this._doesCharSupportLocalGlyph(+X)||(C.glyphs[+X]=K.glyphs[+X]);C.ranges[$]=!0}for(const X of U)X(q,K);delete C.requests[$]})),U.push((q,K)=>{q?A(q):K&&A(null,{stack:b,id:T,glyph:K.glyphs[T]||null})})},(b,T)=>{if(b)u(b);else if(T){const A={};for(const{stack:C,id:O,glyph:$}of T)A[C]===void 0&&(A[C]={}),A[C].glyphs===void 0&&(A[C].glyphs={}),A[C].glyphs[O]=$&&{id:$.id,bitmap:$.bitmap.clone(),metrics:$.metrics},A[C].ascender=this.entries[C].ascender,A[C].descender=this.entries[C].descender;u(null,A)}})}_doesCharSupportLocalGlyph(l){return this.localGlyphMode!==yB.none&&(this.localGlyphMode===yB.all?!!this.localFontFamily:!!this.localFontFamily&&(Eb(l)||PE(l)||R0(l)||ap(l)||P0(l)||CE(l)||(u=l)>=131072&&u<=173791||(m=>m>=66736&&m<=66815)(l)));var u}_tinySDF(l,u,m){const x=this.localFontFamily;if(!x||!this._doesCharSupportLocalGlyph(m))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 dP.TinySDF({fontFamily:x,fontWeight:se,fontSize:48,buffer:6,radius:16}),b.fontWeight=se}const T=b.fontWeight;if(this.localGlyphs[T][m])return this.localGlyphs[T][m];const A=String.fromCodePoint(m),{data:C,width:O,height:$,glyphWidth:U,glyphHeight:q,glyphLeft:K,glyphTop:X,glyphAdvance:te}=b.draw(A);return this.localGlyphs[T][m]={id:m,bitmap:new ny({width:O,height:$},C),metrics:{width:U/2,height:q/2,left:K/2,top:X/2-27,advance:te/2,localGlyph:!0}}}}function YX(h,l){return h+l[1]-l[0]}function xB(h,l,u,m,x=1){const b=[],T=h.imagePrimary,A=T.pixelRatio,C=T.paddedRect.w-2,O=T.paddedRect.h-2,$=(h.right-h.left)*x,U=(h.bottom-h.top)*x,q=T.stretchX||[[0,C]],K=T.stretchY||[[0,O]],X=q.reduce(YX,0),te=K.reduce(YX,0),se=C-X,ae=O-te;let he=0,ue=X,be=0,Ne=te,Ie=0,We=se,ze=0,He=ae;if(T.content&&m){const Ve=T.content;he=hP(q,0,Ve[0]),be=hP(K,0,Ve[1]),ue=hP(q,Ve[0],Ve[2]),Ne=hP(K,Ve[1],Ve[3]),Ie=Ve[0]-he,ze=Ve[1]-be,We=Ve[2]-Ve[0]-ue,He=Ve[3]-Ve[1]-Ne}const Ue=(Ve,yt,bt,At)=>{const Pt=fP(Ve.stretch-he,ue,$,h.left*x),kt=mP(Ve.fixed-Ie,We,Ve.stretch,X),zt=fP(yt.stretch-be,Ne,U,h.top*x),mt=mP(yt.fixed-ze,He,yt.stretch,te),Nt=fP(bt.stretch-he,ue,$,h.left*x),Mt=mP(bt.fixed-Ie,We,bt.stretch,X),Vt=fP(At.stretch-be,Ne,U,h.top*x),Yt=mP(At.fixed-ze,He,At.stretch,te),xr=new Ft(Pt,zt),sr=new Ft(Nt,zt),nr=new Ft(Nt,Vt),Zt=new Ft(Pt,Vt),mr=new Ft(kt/A,mt/A),kr=new Ft(Mt/A,Yt/A),zr=l*Math.PI/180;if(zr){const wn=Math.sin(zr),mi=Math.cos(zr),os=[mi,-wn,wn,mi];xr._matMult(os),sr._matMult(os),Zt._matMult(os),nr._matMult(os)}const Rr=Ve.stretch+Ve.fixed,cn=bt.stretch+bt.fixed,Un=yt.stretch+yt.fixed,un=At.stretch+At.fixed,Gn=h.imageSecondary;return{tl:xr,tr:sr,bl:Zt,br:nr,texPrimary:{x:T.paddedRect.x+1+Rr,y:T.paddedRect.y+1+Un,w:cn-Rr,h:un-Un},texSecondary:Gn?{x:Gn.paddedRect.x+1+Rr,y:Gn.paddedRect.y+1+Un,w:cn-Rr,h:un-Un}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:mr,pixelOffsetBR:kr,minFontScaleX:We/A/$,minFontScaleY:He/A/U,isSDF:u}};if(T.stretchX||T.stretchY){const Ve=ZX(q,se,X),yt=ZX(K,ae,te);for(let bt=0;bt0?[he,-ue]:be<0?[-he,ue]:he===0?[ue,he]:[ue,-he]}(u);let K=Math.abs(l.top-l.bottom);for(const ae of l.positionedLines)K-=ae.lineOffset;const X=l.positionedLines.length,te=K/X;let se=l.top-u[1];for(let ae=0;aeb)&&(b=X.x),(!K||X.y>T)&&(T=X.y)}const C=Math.min(b-m,T-x);let O=C/2;const $=new y0([],FCe);if(C===0)return new Ft(m,x);for(let K=m;KU.d||!U.d)&&(U=K,u&&console.log("found best %d after %d probes",Math.round(1e4*K.d)/1e4,q)),K.max-U.d<=l||(O=K.h/2,$.push(new tw(K.p.x-O,K.p.y-O,O,h)),$.push(new tw(K.p.x+O,K.p.y-O,O,h)),$.push(new tw(K.p.x-O,K.p.y+O,O,h)),$.push(new tw(K.p.x+O,K.p.y+O,O,h)),q+=4)}return u&&(console.log(`num probes: ${q}`),console.log(`best distance: ${U.d}`)),U.p}function FCe(h,l){return l.max-h.max}dP.TinySDF=class{constructor({fontSize:h=24,buffer:l=3,radius:u=8,cutoff:m=.25,fontFamily:x="sans-serif",fontWeight:b="normal",fontStyle:T="normal",lang:A=null}={}){this.buffer=l,this.cutoff=m,this.radius=u,this.lang=A;const C=this.size=h+4*l,O=this._createCanvas(C),$=this.ctx=O.getContext("2d",{willReadFrequently:!0});$.font=`${T} ${b} ${h}px ${x}`,$.textBaseline="alphabetic",$.textAlign="left",$.fillStyle="black",this.gridOuter=new Float64Array(C*C),this.gridInner=new Float64Array(C*C),this.f=new Float64Array(C),this.z=new Float64Array(C+1),this.v=new Uint16Array(C)}_createCanvas(h){const l=document.createElement("canvas");return l.width=l.height=h,l}draw(h){const{width:l,actualBoundingBoxAscent:u,actualBoundingBoxDescent:m,actualBoundingBoxLeft:x,actualBoundingBoxRight:b}=this.ctx.measureText(h),T=Math.ceil(u),A=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(b-x))),C=Math.min(this.size-this.buffer,T+Math.ceil(m)),O=A+2*this.buffer,$=C+2*this.buffer,U=Math.max(O*$,0),q=new Uint8ClampedArray(U),K={data:q,width:O,height:$,glyphWidth:A,glyphHeight:C,glyphTop:T,glyphLeft:0,glyphAdvance:l};if(A===0||C===0)return K;const{ctx:X,buffer:te,gridInner:se,gridOuter:ae}=this;this.lang&&(X.lang=this.lang),X.clearRect(te,te,A,C),X.fillText(h,te,te+T);const he=X.getImageData(te,te,A,C);ae.fill(Bj,0,U),se.fill(0,0,U);for(let ue=0;ue0?We*We:0,se[Ie]=We<0?We*We:0}}WX(ae,0,0,O,$,O,this.f,this.v,this.z),WX(se,te,te,A,C,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&&(A=!A),C=Math.min(C,Bd(b,X,te))}}return(A?1:-1)*Math.sqrt(C)}(this.p,x),this.max=this.d+this.h*Math.SQRT2}}const BCe=Object.keys,vB=Number.POSITIVE_INFINITY,$Ce=Math.sqrt(2);function oy(h,l,u,m,x,b){const T=uB(h)&&h.collisionPadding?h.collisionPadding:[0,0,0,0],A={top:h.top-T[1],bottom:h.bottom+T[3],left:h.left-T[0],right:h.right+T[2],scaled:!1};return m!==void 0&&function(C,O){C.top*=O,C.bottom*=O,C.left*=O,C.right*=O,C.scaled=!0}(A,m),b&&(A.left+=b[0],A.right+=b[0],A.top+=b[1],A.bottom+=b[1]),u&&function(C,O,$){if(!O)return;const U=Xn(O),q=new Ft($?$[0]:0,$?$[1]:0),K=new Ft(C.left,C.top),X=new Ft(C.right,C.top),te=new Ft(C.left,C.bottom),se=new Ft(C.right,C.bottom);K._rotateAround(U,q),X._rotateAround(U,q),te._rotateAround(U,q),se._rotateAround(U,q),C.left=Math.min(K.x,X.x,te.x,se.x),C.right=Math.max(K.x,X.x,te.x,se.x),C.top=Math.min(K.y,X.y,te.y,se.y),C.bottom=Math.max(K.y,X.y,te.y,se.y)}(A,u,x),l?{top:Math.min(l.top,A.top),bottom:Math.max(l.bottom,A.bottom),left:Math.min(l.left,A.left),right:Math.max(l.right,A.right),scaled:l.scaled||A.scaled}:A}function JX(h,[l,u]){let m=0,x=0;if(u===vB){l<0&&(l=0);const b=l/$Ce;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":m=-b;break;case"top-left":case"bottom-left":m=b;break;case"left":m=l;break;case"right":m=-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":m=-l;break;case"top-left":case"bottom-left":case"left":m=l}}return[m,x]}function zCe(h,l,u,m,x,b,T,A,C,O,$,U,q,K,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},he={textBBox:null,textVerticalBBox:null},{baseIconRotate:ue,baseTextRotate:be,iconScaleFactor:Ne}=function(We,ze,He){const Ue=We.get("icon-rotate").evaluate(ze,{},He),Ve=We.get("text-rotate").evaluate(ze,{},He),[yt,bt]=We.get("icon-size-scale-range");return{baseIconRotate:Ue,baseTextRotate:Ve,iconScaleFactor:fe(1,yt,bt)}}(m,x,b);l&&(ae.iconBBox=oy(l,ae.iconBBox,ue),u)&&(ae.iconVerticalBBox=oy(u,ae.iconVerticalBBox,ue+90));const Ie=gP(U.horizontal);Ie&&(he.textBBox=oy(Ie,he.textBBox,be,1,K)),U.vertical&&(he.textVerticalBBox=oy(U.vertical,he.textVerticalBBox,be+90,1,K));for(const We of se)We.hasIconLayoutProperties()&&UCe(ae,h,te,We,x,b,A,ue,T,C,l,O,Ne,$,X),We.hasTextLayoutProperties()&&VCe(he,te,We,x,b,K,be,q,Ie,U.vertical);return{iconBBox:ae.iconBBox,iconVerticalBBox:ae.iconVerticalBBox,textBBox:he.textBBox,textVerticalBBox:he.textVerticalBBox}}function UCe(h,l,u,m,x,b,T,A,C,O,$,U,q,K,X){const{appearanceIconOffset:te,appearanceIconRotate:se,appearanceIconSize:ae}=eQ(m,u,x,b,T,A,C,O.iconScaleFactor);let he=null,ue=null,be=null;m.hasLayoutProperty("icon-image")?be=function(Ie,We,ze,He,Ue,Ve,yt,bt){let At=null;const Pt=We.getAppearanceValueAndResolveTokens(ze,"icon-image",He,Ue,bt);if(Pt){const kt=Ie.getResolvedImageFromTokens(Pt),zt=ze.hasLayoutProperty("icon-size")?ze.getUnevaluatedLayoutProperty("icon-size"):We._unevaluatedLayout._values["icon-size"],mt=$j(kt,ev(Ie.zoom,zt,Ie.worldview,bt),zt,Ue,Ie.zoom,He,Ie.pixelRatio,yt,Ie.worldview,bt);At=Ve.get(mt.iconPrimary.toString())}return At}(l,u,m,x,b,U,q,X):$&&(be=$.imagePrimary),be&&(he=cP(be,null,te,K),l.allowVerticalPlacement&&(ue=cP(be,null,te,K)));const Ne=C>0?ae/C:1;he&&(h.iconBBox=oy(he,h.iconBBox,se,Ne!==1?Ne:void 0)),ue&&(h.iconVerticalBBox=oy(ue,h.iconVerticalBBox,se+90,Ne!==1?Ne:void 0))}function eQ(h,l,u,m,x,b,T,A){const C=h.hasLayoutProperty("icon-offset")?l.getAppearanceValueAndResolveTokens(h,"icon-offset",u,m,[]):null,O=C&&Array.isArray(C)?C:x,$=h.hasLayoutProperty("icon-rotate")?l.getAppearanceValueAndResolveTokens(h,"icon-rotate",u,m,[]):null,U=typeof $=="number"?$:b,q=h.hasLayoutProperty("icon-size")?l.getAppearanceValueAndResolveTokens(h,"icon-size",u,m,[]):null;return{appearanceIconOffset:O,appearanceIconRotate:U,appearanceIconSize:typeof q=="number"?q*A:T}}function VCe(h,l,u,m,x,b,T,A,C,O){const{appearanceTextOffset:$,appearanceTextRotate:U,appearanceTextSize:q}=tQ(u,l,m,x,b,T,A),K=q/A,X=[($[0]-b[0])*K,($[1]-b[1])*K],te=X[0]!==0||X[1]!==0;C&&(h.textBBox=oy(C,h.textBBox,U,K,$,te?X:void 0)),O&&(h.textVerticalBBox=oy(O,h.textVerticalBBox,U+90,K,$,te?X:void 0))}function tQ(h,l,u,m,x,b,T){const A=h.hasLayoutProperty("text-offset")?l.getAppearanceValueAndResolveTokens(h,"text-offset",u,m,[]):null,C=A&&Array.isArray(A)?[A[0]*$a,A[1]*$a]:x,O=h.hasLayoutProperty("text-rotate")?l.getAppearanceValueAndResolveTokens(h,"text-rotate",u,m,[]):null,$=typeof O=="number"?O:b,U=h.hasLayoutProperty("text-size")?l.getAppearanceValueAndResolveTokens(h,"text-size",u,m,[]):null;return{appearanceTextOffset:C,appearanceTextRotate:$,appearanceTextSize:typeof U=="number"?U:T}}function pP(h,l,u,m,x,b,T,A,C){if(!l||!l.usvg)return;const O=OX(m),$=OX(x),U=b!=="both"&&b!=="width"||!MX(m)?1:$.width/O.width,q=b!=="both"&&b!=="height"||!DX(m)?1:$.height/O.height;u.scaleSelf(U,q);const K=u.toString();T.set(K,u),A.set(K,l);const{imagePosition:X}=pB(K,l,1);C.set(K,X)}function rQ(h,l,u,m,x,b,T,A,C,O){if(!h)return;const $=function(U,q,K,X,te,se,ae){if(U.kind==="camera")return U.maxSize;if(U.kind==="composite"){const he=q.possiblyEvaluate(new as(U.maxZoom,{worldview:se}),K,ae).evaluate(te,{},K,ae),ue=q.possiblyEvaluate(new as(U.minZoom,{worldview:se}),K,ae).evaluate(te,{},K,ae);return Math.max(he,ue)}return q.possiblyEvaluate(new as(X,{worldview:se}),K,ae).evaluate(te,{},K,ae)}(l,u,m,x,b,C,O);return h.scaleSelf($*A*T)}function $j(h,l,u,m,x,b,T,A,C,O){return{iconPrimary:rQ(h.getPrimary(),l,u,m,x,b,T,A,C,O),iconSecondary:rQ(h.getSecondary(),l,u,m,x,b,T,A,C,O)}}function qCe(h,l,u){if(!l)return;const m=u.get(h.toString()),x=u.get(l.toString());m&&x&&(m.paddedRect.w===x.paddedRect.w&&m.paddedRect.h===x.paddedRect.h||$r(`Mismatch in icon variant sizes: ${h.toString()} and ${l.toString()}`),m.usvg!==x.usvg&&$r(`Mismatch in icon variant image types: ${h.id} and ${l.id}`))}function nQ(h,l,u,m){if(!h)return;const x=l.get(u.toString());if(x&&(h.imagePrimary=x),m){const b=l.get(m.toString());h.imageSecondary=b}}function GCe(h,l){for(const u in h.horizontal)sQ(h.horizontal[u],l);sQ(h.vertical,l)}function sQ(h,l){if(h){for(const u of h.positionedLines)for(const m of u.positionedGlyphs)if(m.image!==null){const x=m.image.toString();m.rect=l.get(x).paddedRect}}}function _B(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 HCe(h,l,u,m,x,b,T,A,C){const O=gP(b.horizontal)||b.vertical,$=u.get("icon-text-fit-padding").evaluate(m,{},x);let U,q=l;return l&&C!=="none"&&(h.allowVerticalPlacement&&b.vertical&&(U=dB(l,b.vertical,C,$,A,T)),O&&(q=dB(l,O,C,$,A,T))),{defaultShapedIcon:q,verticallyShapedIcon:U}}function iQ(h,l){return h*l/24}function WCe(h,l,u,m,x,b,T,A,C,O,$,U,q,K,X,te,se,ae,he,ue,be,Ne,Ie,We){let ze=T.textMaxSize.evaluate(l,{},q);ze===void 0?ze=A*T.textScaleFactor:ze*=T.textScaleFactor;const He=h.layers[0].layout,Ue=iQ(A,T.textScaleFactor),Ve=gP(u.horizontal)||u.vertical,yt=h.hasAnyAppearanceLayoutProperty(["text-size","text-offset","text-rotate"]),bt=h.getAppearanceFeatureData(l.index);(se!=="none"||yt)&&bt&&(bt.textShaping=Ve,bt.iconTextFitPadding=He.get("icon-text-fit-padding").evaluate(l,{},q),bt.fontScale=Ue,bt.textScaleFactor=T.textScaleFactor);const At=K.name==="globe",Pt=h.tilePixelRatio*ze/24,kt=(Yt=h.overscaling,h.zoom>18&&Yt>2&&(Yt>>=1),Math.max(or/(512*Yt),1)*He.get("symbol-spacing")),zt=He.get("text-padding")*h.tilePixelRatio,mt=He.get("icon-padding")*h.tilePixelRatio,Nt=Xn(He.get("text-max-angle")),Mt=He.get("icon-rotation-alignment")==="map"&&ue!=="point",Vt=kt/2;var Yt;h.hasAnyIconTextFit===!1&&se!=="none"&&(h.hasAnyIconTextFit=!0);const xr=l.properties?+l.properties[yn]:null,sr=xr&&h.elevationFeatureIdToIndex?h.elevationFeatureIdToIndex.get(xr):65535,nr=(Zt,mr,kr)=>{if(mr.x<0||mr.x>=or||mr.y<0||mr.y>=or)return;let zr=null;if(At){const{x:Rr,y:cn,z:Un}=K.projectTilePoint(mr.x,mr.y,kr);zr={anchor:new _p(Rr,cn,Un,0,void 0),up:K.upVector(kr,mr.x,mr.y)}}(function(Rr,cn,Un,un,Gn,wn,mi,os,Kn,Rs,ci,za,ui,wi,Zi,Si,Ao,Ua,En,El,Li,Za,jl,ko,pi,sl,Xa,LP,cw,Gl,qB,uw){const bp=Rr.addToLineVertexArray(cn,un);let wp,Xu,Qu,av,dw,Cn,Qa,Ti=0,Na=0,Ju=0,$c=0,zc=-1,Uc=-1;const Ud={};let MP=kf("");const Fh=Un?Un.anchor:cn,hw=LP!=="none";let fw=0,pa=0;if(Kn._unevaluatedLayout.getValue("text-radial-offset")===void 0){const Mi=Kn.layout.get("text-offset").evaluate(Li,{},pi);fw=Mi[0]*$a,pa=Mi[1]*$a}else fw=Kn.layout.get("text-radial-offset").evaluate(Li,{},pi)*$a,pa=vB;if(Rr.allowVerticalPlacement&&Gn.vertical){const Mi=Gn.vertical;if(Zi)Cn=SB(Mi),os&&(Qa=SB(os));else{const Al=Kn.layout.get("text-rotate").evaluate(Li,{},pi)+90;Qu=yP(Rs,Fh,cn,ci,za,ui,Mi,wi,Al,Si,uw),os&&(av=yP(Rs,Fh,cn,ci,za,ui,os,Ua,Al,null,qB))}}if(wn){const Mi=Kn.layout.get("icon-rotate").evaluate(Li,{},pi),Al=xB(wn,Mi,jl,hw,Za.iconScaleFactor),Hl=os?xB(os,Mi,jl,hw,Za.iconScaleFactor):void 0;Xu=yP(Rs,Fh,cn,ci,za,ui,wn,Ua,Mi,null,Gl);const qd=function(Bh,t2,mw,lPe,cPe,jJ,AJ,uPe,Yqt,HB){const kJ=Bh.layers[0],NJ=kJ.appearances;let pw=t2.length;if(mw&&(pw=Math.max(pw,mw.length)),NJ.length===0)return pw;const[dPe,hPe]=lPe.get("icon-size-scale-range"),fPe=fe(1,dPe,hPe);for(const BP of NJ)if(BP.hasLayoutProperty("icon-image")){const CJ=kJ.getAppearanceValueAndResolveTokens(BP,"icon-image",jJ,AJ,HB);if(CJ){const IJ=Bh.getResolvedImageFromTokens(CJ);if(IJ){const PJ=BP.hasLayoutProperty("icon-size")?BP.getUnevaluatedLayoutProperty("icon-size"):cPe._values["icon-size"],mPe=$j(IJ,ev(Bh.zoom,PJ,Bh.worldview,HB),PJ,AJ,Bh.zoom,jJ,Bh.pixelRatio,fPe,Bh.worldview,HB),RJ=uPe.get(mPe.iconPrimary.toString());RJ&&(pw=Math.max(pw,MCe(RJ)))}}}return pw}(Rr,Al,Hl,Kn.layout,Kn._unevaluatedLayout,Li,pi,Rr.iconAtlasPositions,0,ko);Ti=4*qd;const DP=Kn.layout.get("icon-size").evaluate(Li,{},pi,ko),OP=Za.compositeIconSizes?Za.compositeIconSizes[0].evaluate(Li,{},pi,ko):0,GB=Za.compositeIconSizes?Za.compositeIconSizes[1].evaluate(Li,{},pi,ko):0,FP=wB(Rr.layerIds[0],Rr.iconSizeData,DP,Za.iconScaleFactor,OP,GB);Rr.addSymbols(Rr.icon,Al,FP,El,En,Li,void 0,Un,cn,bp.lineStartIndex,bp.lineLength,-1,ko,pi,sl,Xa,Rr.symbolInstances.length,qd),zc=Rr.icon.placedSymbolArray.length-1,Hl&&(Na=4*qd,Rr.addSymbols(Rr.icon,Hl,FP,El,En,Li,Bc.vertical,Un,cn,bp.lineStartIndex,bp.lineLength,-1,ko,pi,sl,Xa,Rr.symbolInstances.length,qd),Uc=Rr.icon.placedSymbolArray.length-1)}for(const Mi in Gn.horizontal){const Al=Mi,Hl=Gn.horizontal[Al];wp||(MP=kf(Hl.text),Zi?dw=SB(Hl):wp=yP(Rs,Fh,cn,ci,za,ui,Hl,wi,Kn.layout.get("text-rotate").evaluate(Li,{},pi),Si,uw));const qd=Hl.positionedLines.length===1;if(Ju+=aQ(Rr,Un,cn,Hl,mi,Kn,Zi,Li,Si,bp,Gn.vertical?Bc.horizontal:Bc.horizontalOnly,qd?BCe(Gn.horizontal):[Al],Ud,zc,Za,ko,pi,Rr.symbolInstances.length,sl),qd)break}Gn.vertical&&($c+=aQ(Rr,Un,cn,Gn.vertical,mi,Kn,Zi,Li,Si,bp,Bc.vertical,["vertical"],Ud,Uc,Za,ko,pi,Rr.symbolInstances.length,sl));let na=-1;const Ca=(Mi,Al)=>Mi?Math.max(Mi,Al):Al;na=Ca(dw,na),na=Ca(Cn,na),na=Ca(Qa,na);const Vd=na>-1?1:0;Rr.glyphOffsetArray.length>=65535&&$r("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),Li.sortKey!==void 0&&Rr.addToSortKeyRanges(Rr.symbolInstances.length,Li.sortKey),Rr.symbolInstances.emplaceBack(cn.x,cn.y,Fh.x,Fh.y,Fh.z,Ud.right>=0?Ud.right:-1,Ud.center>=0?Ud.center:-1,Ud.left>=0?Ud.left:-1,Ud.vertical>=0?Ud.vertical:-1,zc,Uc,MP,wp!==void 0?wp:Rr.collisionBoxArray.length,wp!==void 0?wp+1:Rr.collisionBoxArray.length,Qu!==void 0?Qu:Rr.collisionBoxArray.length,Qu!==void 0?Qu+1:Rr.collisionBoxArray.length,Xu!==void 0?Xu:Rr.collisionBoxArray.length,Xu!==void 0?Xu+1:Rr.collisionBoxArray.length,av||Rr.collisionBoxArray.length,av?av+1:Rr.collisionBoxArray.length,ci,Ju,$c,Ti,Na,Vd,0,fw,pa,na,0,hw?1:0,cw)})(h,mr,zr,Zt,u,m,b,x,h.layers[0],h.collisionBoxArray,l.index,l.sourceLayerIndex,h.index,zt,he,O,0,mt,Mt,ae,l,T,$,U,q,X,te,se,sr,be,Ne,Ie)};if(ue==="line")for(const Zt of ZI(l.geometry,0,0,or,or)){const mr=LCe(Zt,kt,Nt,u.vertical||Ve,m,24,Pt,h.overscaling,or);for(const kr of mr)Ve&&KCe(h,Ve.text,Vt,kr)||nr(Zt,kr,q)}else if(ue==="line-center"){for(const Zt of l.geometry)if(Zt.length>1){const mr=RCe(Zt,Nt,u.vertical||Ve,m,24,Pt);mr&&nr(Zt,mr,q)}}else if(l.type==="Polygon")for(const Zt of wj(l.geometry,0)){const mr=OCe(Zt,16);nr(Zt[0],new _p(mr.x,mr.y,0,0,void 0),q)}else if(l.type==="LineString")for(const Zt of l.geometry)nr(Zt,new _p(Zt[0].x,Zt[0].y,0,0,void 0),q);else if(l.type==="Point")for(const Zt of l.geometry)for(const mr of Zt)nr([mr],new _p(mr.x,mr.y,0,0,void 0),q)}const bB=255,tv=bB*vp;function aQ(h,l,u,m,x,b,T,A,C,O,$,U,q,K,X,te,se,ae,he){const ue=QX(0,m,C,b,T,A,x,h.allowVerticalPlacement,void 0,X.textScaleFactor),be=b.layout.get("text-size").evaluate(A,{},se),Ne=X.compositeTextSizes?X.compositeTextSizes[0].evaluate(A,{},se):0,Ie=X.compositeTextSizes?X.compositeTextSizes[1].evaluate(A,{},se):0,We=wB(h.layerIds[0],h.textSizeData,be,X.textScaleFactor,Ne,Ie);h.addSymbols(h.text,ue,We,C,T,A,$,l,u,O.lineStartIndex,O.lineLength,K,te,se,he,!1,ae,ue.length);for(const ze of U)q[ze]=h.text.placedSymbolArray.length-1;return 4*ue.length}function wB(h,l,u,m,x,b){const T=l;let A=null;return T.kind==="source"?(A=[vp*u*m],A[0]>tv&&$r(`${h}: Value for "text-size" is >= ${bB}. Reduce your "text-size".`)):T.kind==="composite"&&(A=[vp*x*m,vp*b*m],(A[0]>tv||A[1]>tv)&&$r(`${h}: Value for "text-size" is >= ${bB}. Reduce your "text-size".`)),A}function gP(h){for(const l in h)return h[l];return null}function yP(h,l,u,m,x,b,T,A,C,O,$){let U,q,K,X;if(U=$?$.top:T.top,q=$?$.bottom:T.bottom,K=$?$.left:T.left,X=$?$.right:T.right,uB(T)&&T.collisionPadding){const te=T.collisionPadding;K-=te[0],U-=te[1],X+=te[2],q+=te[3]}if(C){const te=new Ft(K,U),se=new Ft(X,U),ae=new Ft(K,q),he=new Ft(X,q),ue=Xn(C);let be=new Ft(0,0);O&&(be=new Ft(O[0],O[1])),te._rotateAround(ue,be),se._rotateAround(ue,be),ae._rotateAround(ue,be),he._rotateAround(ue,be),K=Math.min(te.x,se.x,ae.x,he.x),X=Math.max(te.x,se.x,ae.x,he.x),U=Math.min(te.y,se.y,ae.y,he.y),q=Math.max(te.y,se.y,ae.y,he.y)}return h.emplaceBack(l.x,l.y,l.z,u.x,u.y,K,U,X,q,A,m,x,b),h.length-1}function SB(h){uB(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 KCe(h,l,u,m){const x=h.compareText;if(l in x){const b=x[l];for(let T=b.length-1;T>=0;T--)if(m.dist(b[T])ue&&(be(Ie,At,ze,He,yt,bt),be(At,We,yt,bt,Ue,Ve))}be(U,q,m,b,x,b),be(q,K,x,b,x,T),be(K,X,x,T,m,T),be(X,U,m,T,m,b),te-=ue,se-=ue,ae+=ue,he+=ue;const Ne=1/Math.max(ae-te,he-se);return{scale:Ne,x:te*Ne,y:se*Ne,x2:ae*Ne,y2:he*Ne,projection:l}}function lQ(h,{x:l,y:u},m=0){return new Ft(((l-m)*h.scale-h.x)*or,(u*h.scale-h.y)*or)}const YCe=P(new Float32Array(16));class ly{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 Qe(0,0)}projectTilePoint(l,u,m){return{x:l,y:u,z:0}}locationPoint(l,u,m,x=!0){return l._coordinatePoint(l.locationCoordinate(u,m),x)}pixelsPerMeter(l,u){return lt(1,l)*u}pixelSpaceConversion(l,u,m){return 1}farthestPixelDistance(l){return oQ(l,l.pixelsPerMeter)}pointCoordinate(l,u,m,x){const b=l.horizonLineFromTop(!1),T=new Ft(u,Math.max(b,m));return l.rayIntersectionCoordinate(l.pointRayIntersection(T,x))}pointCoordinate3D(l,u,m){const x=new Ft(u,m);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 m=l.horizonLineFromTop();return u.y0?u<-rw+m&&(u=-rw+m):u>rw-m&&(u=rw-m);const T=b/Math.pow(vP(u),x);let A=T*Math.sin(x*l),C=b-T*Math.cos(x*l);return A=.5*(A/Math.PI+.5),C=.5*(C/Math.PI+.5),{x:A,y:this.southernCenter?C:1-C,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:m,f:x}=this,b=x-u,T=Math.sign(b),A=Math.sign(m)*Math.sqrt(l*l+b*b);let C=Math.atan2(l,Math.abs(b))*T;b*m<0&&(C-=Math.PI*Math.sign(l)*T);const O=fe(mo(C/m)+this.center[0],-180,180),$=fe(mo(2*Math.atan(Math.pow(x/A,1/m))-rw),-85.051129,Tt);return new Qe(O,this.southernCenter?-$:$)}}class cQ extends ly{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:Lt(l),y:Bt(u),z:0}}unproject(l,u){const m=tt(l),x=gt(u);return new Qe(m,x)}}const uQ=Xn(Tt);class eIe extends ly{project(l,u){const m=(u=Xn(u))*u,x=m*m;return{x:.5*((l=Xn(l))*(.8707-.131979*m+x*(x*(.003971*m-.001529*x)-.013791))/Math.PI+.5),y:1-.5*(u*(1.007226+m*(.015085+x*(.028874*m-.044475-.005916*x)))/Math.PI+1),z:0}}unproject(l,u){l=(2*l-.5)*Math.PI;let m=u=(2*(1-u)-1)*Math.PI,x=25,b=0,T=m*m;do{T=m*m;const O=T*T;b=(m*(1.007226+T*(.015085+O*(.028874*T-.044475-.005916*O)))-u)/(1.007226+T*(.045255+O*(.259866*T-.311325-.005916*11*O))),m=fe(m-b,-uQ,uQ)}while(Math.abs(b)>1e-6&&--x>0);T=m*m;const A=fe(mo(l/(.8707+T*(T*(T*T*T*(.003971-.001529*T)-.013791)-.131979))),-180,180),C=mo(m);return new Qe(A,C)}}const dQ=Xn(Tt);class tIe extends ly{project(l,u){u=Xn(u),l=Xn(l);const m=Math.cos(u),x=2/Math.PI,b=Math.acos(m*Math.cos(l/2)),T=Math.sin(b)/b,A=.5*(l*x+2*m*Math.sin(l/2)/T)||0,C=.5*(u+Math.sin(u)/T)||0;return{x:.5*(A/Math.PI+.5),y:1-.5*(C/Math.PI+1),z:0}}unproject(l,u){let m=l=(2*l-.5)*Math.PI,x=u=(2*(1-u)-1)*Math.PI,b=25;const T=1e-6;let A=0,C=0;do{const O=Math.cos(x),$=Math.sin(x),U=2*$*O,q=$*$,K=O*O,X=Math.cos(m/2),te=Math.sin(m/2),se=2*X*te,ae=te*te,he=1-K*X*X,ue=he?1/he:0,be=he?Math.acos(O*X)*Math.sqrt(1/he):0,Ne=.5*(2*be*O*te+2*m/Math.PI)-l,Ie=.5*(be*$+x)-u,We=.5*ue*(K*ae+be*O*X*q)+1/Math.PI,ze=ue*(se*U/4-be*$*te),He=.125*ue*(U*te-be*$*K*se),Ue=.5*ue*(q*X+be*ae*O)+.5,Ve=ze*He-Ue*We;A=(Ie*ze-Ne*Ue)/Ve,C=(Ne*He-Ie*We)/Ve,m=fe(m-A,-Math.PI,Math.PI),x=fe(x-C,-dQ,dQ)}while((Math.abs(A)>T||Math.abs(C)>T)&&--b>0);return new Qe(mo(m),mo(x))}}class hQ extends ly{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:m,cosPhi:x}=this;return{x:Xn(l)*x*m+.5,y:-Math.sin(Xn(u))/x*m+.5,z:0}}unproject(l,u){const{scale:m,cosPhi:x}=this,b=-(u-.5)/m,T=fe(mo((l-.5)/m)/x,-180,180),A=Math.asin(fe(b*x,-1,1)),C=fe(mo(A),-85.051129,Tt);return new Qe(T,C)}}class rIe extends cQ{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,m){const x=pj(l,u,m);return lr(x,x,gj(Uf(m))),{x:x[0],y:x[1],z:x[2]}}locationPoint(l,u,m){const x=Be(u.lat,u.lng),b=pt([],x),T=m?l._centerAltitude+m:l.elevation?l.elevation.getAtPointOrZero(l.locationCoordinate(u),l._centerAltitude):l._centerAltitude;nt(x,x,b,lt(1,0)*or*T);const A=P(new Float64Array(16));return D(A,l.pixelMatrix,l.globeMatrix),lr(x,x,A),new Ft(x[0],x[1])}pixelsPerMeter(l,u){return lt(1,0)*u}pixelSpaceConversion(l,u,m){const x=lt(1,l)*u,b=Qr(lt(1,45)*u,x,m);return this.pixelsPerMeter(l,u)/b}createTileMatrix(l,u,m){const x=y5(Uf(m.canonical));return D(new Float64Array(16),l.globeMatrix,x)}createInversionMatrix(l,u){const{center:m}=l,x=gj(Uf(u));return W(x,x,Xn(m.lng)),G(x,x,Xn(m.lat)),V(x,x,[l._pixelsPerMercatorPixel,l._pixelsPerMercatorPixel,1]),Float32Array.from(x)}pointCoordinate(l,u,m,x){return kY(l,u,m,!0)||new Ar(0,0)}pointCoordinate3D(l,u,m){const x=this.pointCoordinate(l,u,m,0);return[x.x,x.y,x.z]}isPointAboveHorizon(l,u){return!kY(l,u.x,u.y,!1)}farthestPixelDistance(l){const u=function(x,b){const T=x.cameraToCenterDistance,A=x._centerAltitude*b,C=x._camera,O=x._camera.forward(),$=me([],qe([],O,-T),[0,0,A]),U=x.worldSize/(2*Math.PI),q=[0,0,-U],K=x.width/x.height,X=Math.tan(x.fovAboveCenter),te=qe([],C.up(),X),se=qe([],C.right(),X*K),ae=pt([],me([],me([],O,te),se)),he=[];let ue;if(new In($,ae).closestPointOnSphere(q,U,he)){const be=me([],he,q),Ne=Pr([],be,$);ue=Math.cos(x.fovAboveCenter)*Le(Ne)}else{const be=Pr([],$,q),Ne=Pr([],q,$);pt(Ne,Ne);const Ie=Le(be)-U;ue=Math.sqrt(Ie*(Ie+2*U));const We=Math.acos(ue/(U+Ie))-Math.acos(Ct(O,Ne));ue*=Math.cos(We)}return 1.01*ue}(l,this.pixelsPerMeter(l.center.lat,l.worldSize)),m=gp(l.zoom);if(m>0){const x=oQ(l,lt(1,l.center.lat)*l.worldSize),b=l.worldSize/(2*Math.PI),T=Math.max(l.width,l.height)/l.worldSize*Math.PI;return Qr(u,x+b*(1-Math.cos(T)),Math.pow(m,10))}return u}upVector(l,u,m){return pj(u,m,l,1)}upVectorScale(l){return{metersToTile:PI(LI(Uf(l)))}}}function fQ(h){const l=h.parallels,u=!!l&&Math.abs(l[0]+l[1])<.01;switch(h.name){case"mercator":return new cQ(h);case"equirectangular":return new QCe(h);case"naturalEarth":return new eIe(h);case"equalEarth":return new XCe(h);case"winkelTripel":return new tIe(h);case"albers":return u?new hQ(h):new ZCe(h);case"lambertConformalConic":return u?new hQ(h):new JCe(h);case"globe":return new rIe(h)}throw new Error(`Invalid projection name: ${h.name}`)}class nIe{constructor(l,u){this.lastParams=null,this.lastAllFeaturesIndex=-2,this.appearancesVersion=u,this.appearances=l;const m=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:!rp(T),stateDependent:!zg(T),zoomDependent:!Rd(T,["zoom"]),pitchDependent:!Rd(T,["pitch"]),brightnessDependent:!Rd(T,["brightness","measure-light"]),worldviewDependent:!Rd(T,["worldview"])}}(x));this.anyFeatureDependent=m.some(x=>x.featureDependent),this.anyStateDependent=m.some(x=>x.stateDependent)}update(l,u){const m=this.lastParams,x=!m||m.zoom!==l.zoom||m.pitch!==(l.pitch||0)||m.brightness!==(l.brightness||0)||m.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-A),b=new Map;for(const T of x){const A=m.get(T);b.set(T,new Cs(A))}return u&&(this.cachedBatchIndices=x,this.cachedBatchSegments=b),{batchIndices:x,batchSegments:b}}snapshotSymbolVertexData(l,u){const m=l*sw;return this.layoutVertexArray.uint16.slice(m,m+u*sw)}restoreSymbolVertexData(l,u){this.layoutVertexArray.uint16.set(u,l*sw)}updateSymbolVertexData(l,u,m,x,b,T,A,C,O,$,U,q,K){const X=this.layoutVertexArray.uint16,te=l*sw;X[te]=u,X[te+1]=m,X[te+2]=x,X[te+3]=b,X[te+4]=T,X[te+5]=A,X[te+6]=C,X[te+7]=O,X[te+8]=$,X[te+9]=U,X[te+10]=q,X[te+11]=K}upload(l,u,m,x,b,T){this.isEmpty()||(m&&(this.cachedBatchIndices=null,this.cachedBatchSegments=null,this.layoutVertexBuffer=l.createVertexBuffer(this.layoutVertexArray,aCe.members,!!T),this.indexBuffer=l.createIndexBuffer(this.indexArray,u),this.dynamicLayoutVertexBuffer=l.createVertexBuffer(this.dynamicLayoutVertexArray,lCe.members,!0),this.opacityVertexBuffer=l.createVertexBuffer(this.opacityVertexArray,iIe,!0),this.iconTransitioningVertexArray.length>0&&(this.iconTransitioningVertexBuffer=l.createVertexBuffer(this.iconTransitioningVertexArray,hCe.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=l.createVertexBuffer(this.globeExtVertexArray,oCe.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||b)&&(this.zOffsetVertexBuffer=l.createVertexBuffer(this.zOffsetVertexArray,cCe.members,!0)),!this.orientationVertexBuffer&&this.orientationVertexArray&&this.orientationVertexArray.length>0&&(this.orientationVertexBuffer=l.createVertexBuffer(this.orientationVertexArray,dCe.members,!0)),this.opacityVertexBuffer.itemSize=1,this.featureIdArray&&this.featureIdArray.length>0&&(this.featureIdBuffer=l.createVertexBuffer(this.featureIdArray,uCe.members,!1))),(m||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())}}_r(TB,"SymbolBuffers",{omit:["cachedBatchIndices","cachedBatchSegments"]});class EB{constructor(l,u,m){this.layoutVertexArray=new l,this.layoutAttributes=u,this.indexArray=new m,this.segments=new Cs,this.collisionVertexArray=new z0,this.collisionVertexArrayExt=new Ih}upload(l){this.layoutVertexBuffer=l.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=l.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=l.createVertexBuffer(this.collisionVertexArray,fCe.members,!0),this.collisionVertexBufferExt=l.createVertexBuffer(this.collisionVertexArrayExt,mCe.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}_r(EB,"CollisionBuffers");class Mh{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=P([]),this.placementViewportMatrix=P([]);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=ev(this.zoom,u["text-size"],this.worldview,l.availableImages),this.iconSizeData=ev(this.zoom,u["icon-size"],this.worldview,l.availableImages);const m=this.layers[0].layout,x=m.get("symbol-sort-key"),b=m.get("symbol-z-order");this.lut=l.lut,this.canOverlap=m.get("text-allow-overlap")||m.get("icon-allow-overlap")||m.get("text-ignore-placement")||m.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=m.get("text-writing-mode").map(T=>Bc[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 m=Array.isArray(l)?l:[l];return u.some(x=>m.some(b=>x.hasLayoutProperty(b)))}getAppearanceFeatureData(l){return this.featureAppearanceData.get(l)}createArrays(){this.text=new TB(new ie(this.layers,{zoom:this.zoom,lut:this.lut},l=>l.startsWith("text")||l.startsWith("symbol"))),this.icon=new TB(new ie(this.layers,{zoom:this.zoom,lut:this.lut},l=>l.startsWith("icon")||l.startsWith("symbol"))),this.disableSymbolUBO||(this.text.uboBinder=new aB(this.layers[0],this.zoom,this.lut,!0,"",this.maxUniformBufferBindings,this.maxUniformBlockSizeDwords),this.icon.uboBinder=new aB(this.layers[0],this.zoom,this.lut,!1,"",this.maxUniformBufferBindings,this.maxUniformBlockSizeDwords)),this.glyphOffsetArray=new jI,this.lineVertexArray=new q0,this.symbolInstances=new EI}calculateGlyphDependencies(l,u,m,x,b){for(const T of l){const A=T.codePointAt(0);if(A===void 0)break;if(u[A]=!0,x&&b&&A<=65535){const C=Mj[T];C&&(u[C.charCodeAt(0)]=!0)}}}calculateEffectiveAppearanceIconSize(l,u,m,x,b,T,A){if(!l.hasLayoutProperty("icon-size"))return A*T;let C=1;const O=l.getUnevaluatedLayoutProperty("icon-size"),$=ev(this.zoom,O,this.worldview,b),U=ew($,u);if($.kind!=="constant"&&$.kind!=="camera"||(C=U.uSize),$.kind==="composite"){const{minZoom:q,maxZoom:K}=$,X=O.possiblyEvaluate(new as(q,{worldview:this.worldview}),x),te=O.possiblyEvaluate(new as(K,{worldview:this.worldview}),x),se=X.evaluate(m,{},x,b);C=se+(te.evaluate(m,{},x,b)-se)*U.uSizeT}return $.kind==="source"&&(C=O.possiblyEvaluate(new as(this.zoom,{worldview:this.worldview}),x).evaluate(m,{},x,b)),C*T}updateFootprints(l,u){}updateReplacement(l,u){if(u.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=u.updateTime;const m=u.getReplacementRegionsForTile(l.toUnwrapped(),!0);return!qI(this.activeReplacements,m)&&(this.activeReplacements=m,!0)}getResolvedImageFromTokens(l){return typeof l=="string"?Vl.build(l):l}populate(l,u,m,x){const b=this.layers[0],T=b.layout,A=this.projection.name==="globe",C=T.get("text-font"),O=T.get("text-field"),$=T.get("icon-image"),[U,q]=T.get("icon-size-scale-range"),K=fe(u.scaleFactor||1,U,q),[X,te]=T.get("text-size-scale-range"),se=fe(u.scaleFactor||1,X,te),ae=(O.value.kind!=="constant"||O.value.value instanceof $o&&!O.value.value.isEmpty()||O.value.value.toString().length>0)&&(C.value.kind!=="constant"||C.value.value.length>0),he=$.value.kind!=="constant"||!!$.value.value||Object.keys($.parameters).length>0,ue=this.hasAnyAppearanceLayoutProperty("icon-image"),be=T.get("symbol-sort-key");if(this.features=[],this.featureAppearanceData=new Map,!ae&&!he&&!ue)return;const Ne=u.iconDependencies,Ie=u.glyphDependencies,We=u.availableImages,ze=new as(this.zoom,{worldview:this.worldview,activeFloors:u.activeFloors}),He=Ue=>{const Ve=Ue.id.toString();Ne.has(Ve)?Ne.get(Ve).push(Ue):Ne.set(Ve,[Ue])};for(const Ue of l){const{feature:Ve,id:yt,index:bt,sourceLayerIndex:At}=Ue,Pt=b._featureFilter.needGeometry,kt=bn(Ve,Pt);if(!b._featureFilter.filter(ze,kt,m))continue;if(Pt||(kt.geometry=Ur(Ve,m,x)),A&&Ve.type!==1&&m.z<=5){const sr=kt.geometry,nr=.98078528056,Zt=(mr,kr)=>Ct(pj(mr.x,mr.y,m,1),pj(kr.x,kr.y,m,1)){if(!sr.getLayoutProperty("icon-image"))return;const nr=this.getCombinedIconPrimary(sr,Nt,kt,m,We,Yt,K);nr&&He(nr)}),zt){const sr=C.evaluate(kt,{},m).join(","),nr=T.get("text-rotation-alignment")==="map"&&T.get("symbol-placement")!=="point";this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(Bc.vertical)>=0;for(const Zt of zt.sections)if(Zt.image){const mr=Zt.image.getPrimary().scaleSelf(this.pixelRatio*se),kr=mr.id.toString(),zr=Ne.get(kr)||[];zr.push(mr),Ne.set(kr,zr)}else{const mr=OE(zt.toString()),kr=Zt.fontStack||sr,zr=Ie[kr]=Ie[kr]||{};this.calculateGlyphDependencies(Zt.text,zr,nr,this.allowVerticalPlacement,mr)}}}if(T.get("symbol-placement")==="line"&&(this.features=function(Ue){const Ve={},yt={},bt=[];let At=0;function Pt(Nt){bt.push(Ue[Nt]),At++}function kt(Nt,Mt,Vt){const Yt=yt[Nt];return delete yt[Nt],yt[Mt]=Yt,bt[Yt].geometry[0].pop(),bt[Yt].geometry[0]=bt[Yt].geometry[0].concat(Vt[0]),Yt}function zt(Nt,Mt,Vt){const Yt=Ve[Mt];return delete Ve[Mt],Ve[Nt]=Yt,bt[Yt].geometry[0].shift(),bt[Yt].geometry[0]=Vt[0].concat(bt[Yt].geometry[0]),Yt}function mt(Nt,Mt,Vt){const Yt=Vt?Mt[0][Mt[0].length-1]:Mt[0][0];return`${Nt}:${Yt.x}:${Yt.y}`}for(let Nt=0;NtNt.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 Ue of u.elevationFeatures)this.elevationFeatureIdToIndex.set(Ue.id,this.elevationFeatures.length),this.elevationFeatures.push(Ue)}}else T.get("symbol-z-elevate")&&(this.elevationType="offset");this.elevationType!=="none"&&(this.zOffsetBuffersNeedUpload=!0),this.sortFeaturesByKey&&this.features.sort((Ue,Ve)=>Ue.sortKey-Ve.sortKey)}getCombinedIconPrimary(l,u,m,x,b,T,A){let C,O;if(l.hasLayoutProperty("icon-image")){const $=u.getAppearanceValueAndResolveTokens(l,"icon-image",m,x,b);C=this.getResolvedImageFromTokens($)}else{const $=u.getValueAndResolveTokens("icon-image",m,x,b);C=this.getResolvedImageFromTokens($)}if(C){const $=l.hasLayoutProperty("icon-size")?l.getUnevaluatedLayoutProperty("icon-size"):u._unevaluatedLayout._values["icon-size"];O=$j(C,ev(this.zoom,$,this.worldview,b),$,x,this.zoom,T,this.pixelRatio,A,this.worldview,b).iconPrimary}return O}updateSymbolInstanceIconVertices(l,u,m,x,b,T){const{canonical:A,availableImages:C,globalProperties:O,layer:$,iconScaleFactor:U,featureState:q,layoutIconOffset:K,layoutIconSize:X,layoutIconRotate:te}=T;if(l.placedIconSymbolIndex<0)return{vertexOffsetDelta:0,hasChanges:!1};if(u.activeAppearanceIndex===m)return{vertexOffsetDelta:l.numIconVertices,hasChanges:!1};const se=m>=0?$.appearances[m]:null;if(se){const ae=this.getCombinedIconPrimary(se,$,x,A,C,{sortKey:void 0,text:void 0,icon:null,index:l.featureIndex,sourceLayerIndex:l.featureIndex,geometry:[],properties:u.properties,type:"Point",id:u.id},U);if(!ae)return{vertexOffsetDelta:0,hasChanges:!1};const he=ae.toString(),ue=this.iconAtlasPositions&&this.iconAtlasPositions.get(he);if(ue){const{appearanceIconOffset:be,appearanceIconRotate:Ne}=eQ(se,$,x,A,K,te,X,U);let Ie=cP(ue,void 0,be,$.layout.get("icon-anchor").evaluate(x,q,A));const We=ue.sdf,ze=$.layout.get("icon-text-fit").constantOr("none");ze!=="none"&&u.textShaping&&u.iconTextFitPadding&&u.fontScale&&(Ie=dB(Ie,u.textShaping,ze,u.iconTextFitPadding,be,u.fontScale));const He=this.calculateEffectiveAppearanceIconSize(se,O.zoom,x,A,C,U,X),Ue=0,Ve=1+(Math.min(tv,Math.round(He*vp))<<1),yt=xB(Ie,Ne,We,ze!=="none",U);u.isUsingAppearanceIconVertexData||(u.isUsingAppearanceIconVertexData=!0,u.layoutBasedIconVertexData=this.icon.snapshotSymbolVertexData(b,l.numIconVertices));const bt=Math.floor(l.numIconVertices/4),At=Math.min(yt.length,bt);let Pt=b;for(let zt=0;zt0||l.numVerticalGlyphVertices>0;if(!be)return{vertexOffsetDelta:be?l.numHorizontalGlyphVertices+l.numVerticalGlyphVertices:0,hasChanges:!1};if(u.activeAppearanceIndex===m)return{vertexOffsetDelta:l.numHorizontalGlyphVertices+l.numVerticalGlyphVertices,hasChanges:!1};const Ne=m>=0?C.appearances[m]:null;if(Ne&&u.textShaping){const{appearanceTextOffset:Ie,appearanceTextRotate:We,appearanceTextSize:ze}=tQ(Ne,C,x,A,q,X,K);u.fontScale=iQ(ze,u.textScaleFactor);const He=Ne.getUnevaluatedLayoutProperty("text-size");let Ue=this.textSizeData,Ve=ae,yt=he;Ne.hasLayoutProperty("text-size")&&(Ue=ev(this.zoom,He,this.worldview,ue),Ve=this.textSizeData.kind==="composite"?this.textSizeData.minZoom:0,yt=this.textSizeData.kind==="composite"?this.textSizeData.maxZoom:0);const bt=u.textShaping.bottom-q[1],At=u.textShaping.left-q[0],Pt=u.textShaping.right-q[0];u.textShaping.top=Ie[1]+(u.textShaping.top-q[1]),u.textShaping.bottom=Ie[1]+bt,u.textShaping.left=Ie[0]+At,u.textShaping.right=Ie[0]+Pt;const kt=QX(0,u.textShaping,Ie,C,!1,x,$,this.allowVerticalPlacement,We),zt=ze&&Ue.kind==="composite"?He.possiblyEvaluate(new as(Ve,{}),A).evaluate(x,U,A):te,mt=ze&&Ue.kind==="composite"?He.possiblyEvaluate(new as(yt,{}),A).evaluate(x,U,A):se,Nt=wB(Ne.name,Ue,ze,O,zt,mt),Mt=Array.isArray(Nt)?Nt[1]:ze,Vt=0,Yt=1+(Math.min(tv,Math.round(Mt*vp))<<1);u.isUsingAppearanceTextVertexData||(u.isUsingAppearanceTextVertexData=!0,u.layoutBasedTextVertexData=this.text.snapshotSymbolVertexData(b,l.numHorizontalGlyphVertices+l.numVerticalGlyphVertices));for(let xr=0;xr0){const O=new Set(Object.keys(l).map($=>{const U=Number($);return!isNaN(U)&&Number.isSafeInteger(U)&&String(U)===$?U:$}));this.text.uboBinder&&this.text.uboBinder.updateFeatures(O,b[0],u,C,m,l,A),this.icon.uboBinder&&this.icon.uboBinder.updateFeatures(O,b[0],u,C,m,l,A)}}}updateRoadElevation(l){if(this.elevationType!=="road"||!this.elevationFeatures||this.elevationStateComplete)return;this.elevationStateComplete=!0,this.hasAnyZOffset=!1;let u=!1;const m=Ot(l),x=1/m;let b=!1,T=!1;for(let A=0;A0||q>0,se=K>0,ae=this.elevationFeatures[C.elevationFeatureIndex];if(ae){const he=new Ft(C.tileAnchorX,C.tileAnchorY),ue=.075+ae.pointElevation(he);C.zOffset!==ue&&(u=!0,C.zOffset=ue),ue!==0&&(this.hasAnyZOffset=!0);const be=ae.computeSlopeNormal(he,x),Ne=ua(It(),ke(0,0,1),be);sn(O,O,Ne),sn($,$,Ne),O[2]*=m,$[2]*=m,O[0]===1&&O[1]===0&&O[2]===0&&$[0]===0&&$[1]===1&&$[2]===0||(b=b||te,T=T||se)}if(te&&(_P(this.text.orientationVertexArray,U,O,$),_P(this.text.orientationVertexArray,q,O,$)),se){const{placedIconSymbolIndex:he,verticalPlacedIconSymbolIndex:ue}=C;he>=0&&_P(this.icon.orientationVertexArray,K,O,$),ue>=0&&_P(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,A)=>{m+=T,m>b.length&&b.resize(m);for(let C=-T;C<0;C++)b.emplace(C+m,A)},u=(b,T,A)=>{x+=T,x>b.length&&b.resize(x);for(let C=-T;C<0;C++)b.emplace(C+x,A)};if(!this.zOffsetBuffersNeedUpload)return;this.zOffsetBuffersNeedUpload=!1;let m=0,x=0;for(let b=0;b0;if((A>0||C>0)&&(l(this.text.zOffsetVertexArray,A,$),l(this.text.zOffsetVertexArray,C,$)),U){const{placedIconSymbolIndex:q,verticalPlacedIconSymbolIndex:K}=T;q>=0&&u(this.icon.zOffsetVertexArray,O,$),K>=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,m,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,m,x,b,T=!1){const A={hasLayoutChanges:!1,hasUboChanges:!1};if(!l||!m||!this.featureAppearanceData)return A;const C=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 A;const U=this.layers[0],q=U.layout;this.featureAppearances&&this.featureAppearances.appearancesVersion===U.appearancesVersion||(this.featureAppearances=new nIe(U.appearances,U.appearancesVersion));const K=this.featureAppearances.update(x,T);if(K.kind==="no-changes")return A;let X=1,te=0,se=!1,ae=!1;if(O){const[Ie,We]=q.get("icon-size-scale-range");X=fe(1,Ie,We)}let he=1,ue=0,be=!1;if($){const[Ie,We]=q.get("text-size-scale-range");he=fe(1,Ie,We)}const Ne=new Map;if(b&&m)for(const Ie of m){const We=b.getImage(Ie,U.scope);if(We){const ze=new gu(Ie.toString());Ne.set(ze.toString(),We)}}for(let Ie=0;IePt.isActive({globals:x,feature:Ve,canonical:l,featureState:Ue})):-1;yt=At>=0?At:-1}const bt=ze.activeAppearanceIndex!==yt;if($){const At=q.get("text-size"),Pt=this.textSizeData.kind==="composite"?this.textSizeData.minZoom:0,kt=this.textSizeData.kind==="composite"?this.textSizeData.maxZoom:0,zt={canonical:l,layer:U,featureState:Ue,availableImages:m,textScaleFactor:he,imageMap:Ne,layoutTextOffset:q.get("text-offset").evaluate(Ve,Ue,l).map(Nt=>Nt*$a),layoutTextSize:At.evaluate(Ve,Ue,l),layoutTextRotate:q.get("text-rotate").evaluate(Ve,Ue,l),layoutMinZoomSize:At.evaluate(Ve,{zoom:Pt},l),layoutMaxZoomSize:At.evaluate(Ve,{zoom:kt},l),layoutTextSizeMinZoom:Pt,layoutTextSizeMaxZoom:kt},mt=this.updateSymbolInstanceTextVertices(We,ze,yt,Ve,ue,zt);ue+=mt.vertexOffsetDelta,be=be||mt.hasChanges}if(O){const At={canonical:l,layer:U,featureState:Ue,availableImages:m,globalProperties:x,iconScaleFactor:X,layoutIconOffset:q.get("icon-offset").evaluate(Ve,Ue,l),layoutIconSize:q.get("icon-size").evaluate(Ve,Ue,l,m),layoutIconRotate:q.get("icon-rotate").evaluate(Ve,Ue,l)},Pt=this.updateSymbolInstanceIconVertices(We,ze,yt,Ve,te,At);te+=Pt.vertexOffsetDelta,se=se||Pt.hasChanges}if(bt){const At=We.featureIndex,Pt=x?x.brightness:null,kt=Ue||{},zt=yt>=0?U.appearances[yt]:null;this.text.uboBinder&&(this.text.uboBinder.layer=U,ae=this.text.uboBinder.updateFeaturePaintForAppearance(At,Ve,kt,l,m,Pt,zt)||ae),this.icon.uboBinder&&(this.icon.uboBinder.layer=U,ae=this.icon.uboBinder.updateFeaturePaintForAppearance(At,Ve,kt,l,m,Pt,zt)||ae)}ze.activeAppearanceIndex=yt}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),be&&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||be,hasUboChanges:ae}}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}getProjection(){return this.projectionInstance||(this.projectionInstance=fQ(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(l,u){const m=this.lineVertexArray.length;if(l.segment!==void 0)for(const{x,y:b}of u)this.lineVertexArray.emplaceBack(x,b);return{lineStartIndex:m,lineLength:this.lineVertexArray.length-m}}addSymbols(l,u,m,x,b,T,A,C,O,$,U,q,K,X,te,se,ae,he){const ue=l.indexArray,be=l.layoutVertexArray,Ne=l.globeExtVertexArray,Ie=he,We=l.uboBinder?l.uboBinder.getCurrentBatchIndex():void 0,ze=l.segments.prepareSegment(4*Ie,be,ue,this.canOverlap?T.sortKey:void 0,We),He=this.glyphOffsetArray.length,Ue=ze.vertexLength,Ve=this.allowVerticalPlacement&&A===Bc.vertical?Math.PI/2:0,yt=T.text&&T.text.sections;let bt=be.length,At=-1;for(let zt=0;zt=0)){const zt=4*Pt;for(let mt=0;mt=0?u.rightJustifiedTextSymbolIndex:u.centerJustifiedTextSymbolIndex>=0?u.centerJustifiedTextSymbolIndex:u.leftJustifiedTextSymbolIndex>=0?u.leftJustifiedTextSymbolIndex:u.verticalPlacedTextSymbolIndex>=0?u.verticalPlacedTextSymbolIndex:x),T=hB(this.textSizeData,l,b)/$a;return this.tilePixelRatio*T}getSymbolInstanceIconSize(l,u,m){const x=this.icon.placedSymbolArray.get(m),b=hB(this.iconSizeData,l,x);return this.tilePixelRatio*b}_commitDebugCollisionVertexUpdate(l,u,m,x){l.emplaceBack(u,-m,-m,x),l.emplaceBack(u,m,-m,x),l.emplaceBack(u,m,m,x),l.emplaceBack(u,-m,m,x)}_updateTextDebugCollisionBoxes(l,u,m,x,b,T,A){for(let C=x;C0}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 m=l.placedSymbolArray.get(u),x=m.vertexStartIndex+4*m.numGlyphs;for(let b=m.vertexStartIndex;bx[A]-x[C]||b[C]-b[A]),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 m=this.sortKeyRanges[this.sortKeyRanges.length-1];m&&m.sortKey===u?m.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 m=this.symbolInstances.get(u);this.featureSortOrder.push(m.featureIndex);const{rightJustifiedTextSymbolIndex:x,centerJustifiedTextSymbolIndex:b,leftJustifiedTextSymbolIndex:T,verticalPlacedTextSymbolIndex:A,placedIconSymbolIndex:C,verticalPlacedIconSymbolIndex:O}=m;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),A>=0&&this.addIndicesForPlacedSymbol(this.text,A),C>=0&&this.addIndicesForPlacedSymbol(this.icon,C),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 m=(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 m of l){const x=m.batchIndex;if(x===void 0)continue;const b=u.get(x);if(!b){m.primitiveOffset=this.text.indexArray.length,m.primitiveLength=0;continue}m.primitiveOffset=this.text.indexArray.length;const T=this.text.indexArray.length;for(const{index:A}of b){const C=this.symbolInstances.get(A),{rightJustifiedTextSymbolIndex:O,centerJustifiedTextSymbolIndex:$,leftJustifiedTextSymbolIndex:U,verticalPlacedTextSymbolIndex:q}=C;O>=0&&this.addIndicesForPlacedSymbol(this.text,O),$>=0&&$!==O&&this.addIndicesForPlacedSymbol(this.text,$),U>=0&&U!==$&&U!==O&&this.addIndicesForPlacedSymbol(this.text,U),q>=0&&this.addIndicesForPlacedSymbol(this.text,q)}m.primitiveLength=this.text.indexArray.length-T}}rebuildIconSegmentIndices(l,u){for(const m of l){const x=m.batchIndex;if(x===void 0)continue;const b=u.get(x);if(!b){m.primitiveOffset=this.icon.indexArray.length,m.primitiveLength=0;continue}m.primitiveOffset=this.icon.indexArray.length;const T=this.icon.indexArray.length;for(const{index:A}of b){const C=this.symbolInstances.get(A),{placedIconSymbolIndex:O,verticalPlacedIconSymbolIndex:$}=C;O>=0&&this.addIndicesForPlacedSymbol(this.icon,O),$>=0&&this.addIndicesForPlacedSymbol(this.icon,$)}m.primitiveLength=this.icon.indexArray.length-T}}sortFeaturesWithinSegments(){this.featureSortOrder=[];const l=Math.sin(this.sortedAngle),u=Math.cos(this.sortedAngle),m=this.getOrCreateSortedSymbolsByBatch(l,u),x=Array.from(m.keys()).sort((b,T)=>b-T);for(const b of x){const T=m.get(b);for(const{index:A}of T){const C=this.symbolInstances.get(A);this.featureSortOrder.push(C.featureIndex)}}this.text.indexArray.clear(),this.icon.indexArray.clear(),this.rebuildTextSegmentIndices(this.text.segments.get(),m),this.rebuildIconSegmentIndices(this.icon.segments.get(),m),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 m;return this.elevationFeatures&&um in h?String(h[m]):"")}let pQ,gQ,jB;_r(Mh,"SymbolBucket",{omit:["layers","collisionBoxArray","compareText","features"]}),Mh.addDynamicAttributes=nw;class yQ{constructor(l){this.type=l.property.overrides?l.property.overrides.runtimeType:Sh,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}}_r(yQ,"FormatSectionOverride",{omit:["defaultValue"]});const AB=()=>jB||(jB={layout:pQ||(pQ=new ri({"symbol-placement":new Qt(st.layout_symbol["symbol-placement"]),"symbol-spacing":new Qt(st.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Qt(st.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new Ht(st.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Qt(st.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new Qt(st.layout_symbol["symbol-z-elevate"]),"symbol-elevation-reference":new Qt(st.layout_symbol["symbol-elevation-reference"]),"icon-allow-overlap":new Qt(st.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new Qt(st.layout_symbol["icon-ignore-placement"]),"icon-optional":new Qt(st.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Qt(st.layout_symbol["icon-rotation-alignment"]),"icon-size":new Ht(st.layout_symbol["icon-size"]),"icon-size-scale-range":new Qt(st.layout_symbol["icon-size-scale-range"]),"icon-text-fit":new Ht(st.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new Ht(st.layout_symbol["icon-text-fit-padding"]),"icon-image":new Ht(st.layout_symbol["icon-image"]),"icon-image-use-theme":new Qt({type:"string",default:"default","property-type":"data-constant"}),"icon-rotate":new Ht(st.layout_symbol["icon-rotate"]),"icon-padding":new Qt(st.layout_symbol["icon-padding"]),"icon-keep-upright":new Qt(st.layout_symbol["icon-keep-upright"]),"icon-offset":new Ht(st.layout_symbol["icon-offset"]),"icon-anchor":new Ht(st.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Qt(st.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Qt(st.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Qt(st.layout_symbol["text-rotation-alignment"]),"text-field":new Ht(st.layout_symbol["text-field"]),"text-font":new Ht(st.layout_symbol["text-font"]),"text-size":new Ht(st.layout_symbol["text-size"]),"text-size-scale-range":new Qt(st.layout_symbol["text-size-scale-range"]),"text-max-width":new Ht(st.layout_symbol["text-max-width"]),"text-line-height":new Ht(st.layout_symbol["text-line-height"]),"text-letter-spacing":new Ht(st.layout_symbol["text-letter-spacing"]),"text-justify":new Ht(st.layout_symbol["text-justify"]),"text-radial-offset":new Ht(st.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Qt(st.layout_symbol["text-variable-anchor"]),"text-anchor":new Ht(st.layout_symbol["text-anchor"]),"text-max-angle":new Qt(st.layout_symbol["text-max-angle"]),"text-writing-mode":new Qt(st.layout_symbol["text-writing-mode"]),"text-rotate":new Ht(st.layout_symbol["text-rotate"]),"text-padding":new Qt(st.layout_symbol["text-padding"]),"text-keep-upright":new Qt(st.layout_symbol["text-keep-upright"]),"text-transform":new Ht(st.layout_symbol["text-transform"]),"text-offset":new Ht(st.layout_symbol["text-offset"]),"text-allow-overlap":new Qt(st.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new Qt(st.layout_symbol["text-ignore-placement"]),"text-optional":new Qt(st.layout_symbol["text-optional"]),visibility:new Qt(st.layout_symbol.visibility)})),paint:gQ||(gQ=new ri({"icon-opacity":new Ht(st.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new Ht(st.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new Ht(st.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new Ht(st.paint_symbol["text-emissive-strength"]),"icon-color":new Ht(st.paint_symbol["icon-color"]),"icon-halo-color":new Ht(st.paint_symbol["icon-halo-color"]),"icon-halo-width":new Ht(st.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Ht(st.paint_symbol["icon-halo-blur"]),"icon-translate":new Qt(st.paint_symbol["icon-translate"]),"icon-translate-anchor":new Qt(st.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new Qt(st.paint_symbol["icon-image-cross-fade"]),"text-opacity":new Ht(st.paint_symbol["text-opacity"]),"text-occlusion-opacity":new Ht(st.paint_symbol["text-occlusion-opacity"]),"text-color":new Ht(st.paint_symbol["text-color"],{runtimeType:Sl,getOverride:h=>h.textColor,hasOverride:h=>!!h.textColor}),"text-halo-color":new Ht(st.paint_symbol["text-halo-color"]),"text-halo-width":new Ht(st.paint_symbol["text-halo-width"]),"text-halo-blur":new Ht(st.paint_symbol["text-halo-blur"]),"text-translate":new Qt(st.paint_symbol["text-translate"]),"text-translate-anchor":new Qt(st.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new Qt(st.paint_symbol["icon-color-saturation"]),"icon-color-contrast":new Qt(st.paint_symbol["icon-color-contrast"]),"icon-color-brightness-min":new Qt(st.paint_symbol["icon-color-brightness-min"]),"icon-color-brightness-max":new Qt(st.paint_symbol["icon-color-brightness-max"]),"symbol-z-offset":new Ht(st.paint_symbol["symbol-z-offset"]),"icon-color-use-theme":new Ht({type:"string",default:"default","property-type":"data-driven"}),"icon-halo-color-use-theme":new Ht({type:"string",default:"default","property-type":"data-driven"}),"text-color-use-theme":new Ht({type:"string",default:"default","property-type":"data-driven"}),"text-halo-color-use-theme":new Ht({type:"string",default:"default","property-type":"data-driven"})}))},jB);class bP extends nl{constructor(l,u,m,x){super(l,AB(),u,m,x,l.layout?l.layout["icon-image-use-theme"]:null),this._colorAdjustmentMatrix=P([]),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 m=this.layout.get("text-writing-mode");if(m){const x=[];for(const b of m)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,m,x){return this._saturation===l&&this._contrast===u&&this._brightnessMin===m&&this._brightnessMax===x||(this._colorAdjustmentMatrix=function(b,T,A,C){b=oi(b),T=Ds(T);const O=k(),$=b/3,U=1-2*$,q=[U,$,$,0,$,U,$,0,$,$,U,0,0,0,0,1],K=.5-.5*T,X=C-A;return D(O,[X,0,0,0,0,X,0,0,0,0,X,0,A,A,A,1],[T,0,0,0,0,T,0,0,0,0,T,0,K,K,K,1]),D(O,O,q),O}(l,u,m,x),this._saturation=l,this._contrast=u,this._brightnessMin=m,this._brightnessMax=x),this._colorAdjustmentMatrix}getValueAndResolveTokens(l,u,m,x){const b=this.layout.get(l).evaluate(u,{},m,x),T=this._unevaluatedLayout._values[l];return T.isDataDriven()||N0(T.value)||!b?b:mQ(u.properties,b)}getAppearanceValueAndResolveTokens(l,u,m,x,b){const T=l.getLayoutProperty(u);if(!T)return;const A=T.evaluate(m,{},x,b),C=l.getUnevaluatedLayoutProperties()._values[u];return C.isDataDriven()||N0(C.value)||!A||typeof A!="string"?A:mQ(m.properties,A)}createBucket(l){return new Mh(l)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const l of AB().paint.overridableProperties){if(!bP.hasPaintOverride(this.layout,l))continue;const u=this.paint.get(l),m=new yQ(u),x=new vb(m,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 Wg("source",x):new sp("composite",x,u.value.zoomStops,u.value.interpolationType),this.paint._values[l]=new lp(u.property,b,u.parameters)}}_handleOverridablePaintPropertyUpdate(l,u,m){return!(!this.layout||u.isDataDriven()||m.isDataDriven())&&bP.hasPaintOverride(this.layout,l)}static hasPaintOverride(l,u){const m=l.get("text-field"),x=AB().paint.properties[u];let b=!1;const T=A=>{for(const C of A)if(x.overrides&&x.overrides.hasOverride(C))return void(b=!0)};if(m.value.kind==="constant"&&m.value.value instanceof $o)T(m.value.value.sections);else if(m.value.kind==="source"){const A=O=>{b||(O instanceof Cr&&Pi(O.value)===i0?T(O.value.sections):O instanceof Xm?T(O.sections):O.eachChild(A))},C=m.value;C._styleExpression&&A(C._styleExpression.expression)}return b}getProgramIds(){return["symbol"]}getDefaultProgramParams(l,u,m){return{config:new re(this,{zoom:u,lut:m}),overrideFog:!1}}hasElevation(){return this.layout&&this.layout.get("symbol-elevation-reference")==="hd-road-markup"}}let xQ,vQ,_Q,bQ;var wP=Rn([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Uint16",components:2}]);function SP(h,l,u,m,x,b,T,A){const C=[h,l,1,u,m,1,x,b,1],O=[T,A,1],$=S([],C),[U,q,K]=Sr(O,O,$);return E(C,C,[U,0,0,0,q,0,0,0,K])}function wQ(h,l,u,m,x,b,T,A){const C=function(O,$,U,q,K,X,te,se){const ae=SP(0,0,1,0,1,1,0,1),he=SP(O,$,U,q,K,X,te,se);return E(he,he,S([],ae))}(h,l,u,m,x,b,T,A);return[C[2]/C[8]/or,C[5]/C[8]/or]}function TP(h){return[h[0],Math.min(Math.max(h[1],-85.051129),Tt)]}class SQ extends s0{constructor(l,u,m,x){super(),this.id=l,this.dispatcher=m,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 qu("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return l&&(this.coordinates=l),this._loaded=!0,void this._finishLoading();this._imageRequest=Ig(this.map._requestManager.transformRequest(this.url,r0.Image),(m,x)=>{this._imageRequest=null,this._loaded=!0,m?this.fire(new Pg(m)):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 Pj(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 qu("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 Pj||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],m=l[0][1];for(const b of l)b[1]>m&&(m=b[1]),b[1]Tt?this.onNorthPole=!0:x<-85.051129&&(this.onSouthPole=!0),!this.onNorthPole&&!this.onSouthPole){const b=l.map(Ar.fromLngLat);this.tileID=function(T){let A=1/0,C=1/0,O=-1/0,$=-1/0;for(const te of T)A=Math.min(A,te.x),C=Math.min(C,te.y),O=Math.max(O,te.x),$=Math.max($,te.y);const U=Math.max(O-A,$-C),q=Math.max(0,Math.floor(-Math.log2(U))),K=Math.pow(2,q);let X=Math.floor((A+O)/2*K);return X>1&&(X-=1),new Y0(q,X,Math.floor((C+$)/2*K))}(b),this.minzoom=this.maxzoom=this.tileID.z}return this.fire(new qu("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){!this.texture||this.texture instanceof Pj||(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=rv(new Y0(0,0,0),this.map.transform.projection),m=[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,he=se[1].y-se[0].y,ue=se[2].x-se[1].x,be=se[2].y-se[1].y,Ne=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*be-ue*he,Ue=ue*Ie-Ne*be,Ve=Ne*ze-We*Ie,yt=We*he-ae*ze;return He>0&&Ue>0&&Ve>0&&yt>0||He<0&&Ue<0&&Ve<0&&yt<0}(m))return console.warn("Image source coordinates are defining non-convex area in the Mercator projection"),void(this._unsupportedCoords=!0);const x=rv(this.tileID,this.map.transform.projection),[b,T,A,C]=this.coordinates.map(se=>{const ae=x.projection.project(se[0],se[1]);return lQ(x,ae)._round()});this.perspectiveTransform=wQ(b.x,b.y,T.x,T.y,A.x,A.y,C.x,C.y);const O=this._boundsArray=new Eo;O.emplaceBack(b.x,b.y,0,0),O.emplaceBack(T.x,T.y,or,0),O.emplaceBack(C.x,C.y,0,or),O.emplaceBack(A.x,A.y,or,or),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=l.createVertexBuffer(O,wP.members),this.boundsSegments=Cs.simpleSegment(0,0,4,2);const $=[],U=function(se){return[TP(se[0]),TP(se[1]),TP(se[2]),TP(se[3])]}(this.coordinates),[q,K,X,te]=function(se){let ae=se[0][0],he=ae,ue=se[0][1],be=ue;for(let Ne=1;Nehe&&(he=se[Ne][0]),se[Ne][1]be&&(be=se[Ne][1]);return[ae,ue,he-ae,be-ue]}(U);{const se=new Eo,[ae,he,ue,be]=function(kt){let zt=kt[0].x,mt=zt,Nt=kt[0].y,Mt=Nt;for(let Vt=1;Vtmt&&(mt=kt[Vt].x),kt[Vt].yMt&&(Mt=kt[Vt].y);return[zt,Nt,mt-zt,Mt-Nt]}(m),Ne=kt=>[(kt.x-ae)/ue,(kt.y-he)/be],[Ie,We,ze,He]=m.map(Ne),Ue=function(kt,zt,mt,Nt,Mt,Vt,Yt,xr){const sr=SP(0,0,1,0,1,1,0,1);return E(sr,sr,S([],SP(kt,zt,mt,Nt,Mt,Vt,Yt,xr)))}(Ie[0],Ie[1],We[0],We[1],ze[0],ze[1],He[0],He[1]);this.elevatedGlobePerspectiveTransform=wQ(Ie[0],Ie[1],We[0],We[1],ze[0],ze[1],He[0],He[1]);const Ve=(kt,zt)=>{$.push(kt.lng);const mt=Math.round((kt.lng-q)/X*or),Nt=Math.round((kt.lat-K)/te*or),Mt=Ne(zt),Vt=Sr([],[Mt[0],Mt[1],1],Ue),Yt=Math.round(Vt[0]/Vt[2]*or),xr=Math.round(Vt[1]/Vt[2]*or);se.emplaceBack(mt,Nt,Yt,xr)},yt=m[3].x-m[0].x,bt=m[3].y-m[0].y,At=m[2].x-m[1].x,Pt=m[2].y-m[1].y;for(let kt=0;kt<65;kt++){const zt=kt/64,mt=[m[0].x+zt*yt,m[0].y+zt*bt],Nt=[m[1].x+zt*At,m[1].y+zt*Pt],Mt=Nt[0]-mt[0],Vt=Nt[1]-mt[1];for(let Yt=0;Yt<65;Yt++){const xr=Yt/64,sr={x:mt[0]+Mt*xr,y:mt[1]+Vt*xr};Ve(u.projection.unproject(sr.x,sr.y),sr)}}this.elevatedGlobeVertexBuffer=l.createVertexBuffer(se,wP.members)}{this.maxLongitudeTriangleSize=0;let se=[],ae=new bi;const he=(ue,be,Ne)=>{ae.emplaceBack(ue,be,Ne);const Ie=$[ue],We=$[be],ze=$[Ne],He=Math.min(Math.min(Ie,We),ze),Ue=Math.max(Math.max(Ie,We),ze)-He;Ue>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=Ue),se.push(He+Ue/2)};for(let ue=0;ue<64;ue++)for(let be=0;be<64;be++){const Ne=65*ue+be,Ie=Ne+1,We=Ne+65,ze=We+1;he(Ne,We,Ie),he(Ie,We,ze)}[se,ae]=function(ue,be){const Ne=Array.from({length:ue.length},(ze,He)=>He);Ne.sort((ze,He)=>ue[ze]-ue[He]);const Ie=[],We=new bi;for(let ze=0;ze{T.segments.push({vertexOffset:0,primitiveOffset:U,vertexLength:u.segments[0].vertexLength,primitiveLength:q,sortKey:void 0,vaos:{}})},C=.51*this.maxLongitudeTriangleSize;if(Math.abs(m[0]-x)<=C){const U=da(m,0,m.length,x+C);return U===m.length||A(U,ai(m,U+1,m.length,x+360-C)-U),T}x0}}let EQ,jQ,AQ,kQ,NQ,CQ,IQ;class PQ extends nl{constructor(l,u,m,x){super(l,{layout:EQ||(EQ=new ri({visibility:new Qt(st["layout_raster-particle"].visibility)})),paint:jQ||(jQ=new ri({"raster-particle-array-band":new Qt(st["paint_raster-particle"]["raster-particle-array-band"]),"raster-particle-count":new Qt(st["paint_raster-particle"]["raster-particle-count"]),"raster-particle-color":new Xg(st["paint_raster-particle"]["raster-particle-color"]),"raster-particle-max-speed":new Qt(st["paint_raster-particle"]["raster-particle-max-speed"]),"raster-particle-speed-factor":new Qt(st["paint_raster-particle"]["raster-particle-speed-factor"]),"raster-particle-fade-opacity-factor":new Qt(st["paint_raster-particle"]["raster-particle-fade-opacity-factor"]),"raster-particle-reset-rate-factor":new Qt(st["paint_raster-particle"]["raster-particle-reset-rate-factor"]),"raster-particle-elevation":new Qt(st["paint_raster-particle"]["raster-particle-elevation"]),"raster-particle-color-use-theme":new Ht({type:"string",default:"default","property-type":"data-driven"})}))},u,m,x),this._updateColorRamp(),this.lastInvalidatedAt=Ul.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=yj({expression:l,evaluationKey:"rasterParticleSpeed",image:this.colorRamp,clips:[{start:0,end:u}],resolution:256}),this.colorRampTexture=null}_invalidateAnimationState(){this.lastInvalidatedAt=Ul.now()}tileCoverLift(){return this.paint.get("raster-particle-elevation")}}class lIe extends nl{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 NB(h,l,u){const m=[0,0,1],x=pr([]);return ss(x,x,u?-Xn(h)+Math.PI:Xn(h)),Tn(x,x,-Xn(l)),sn(m,m,x),pt(m,m)}class EP{constructor(l,u,m,x){this.message=(l?`${l}: `:"")+m,x&&(this.identifier=x),u!=null&&u.__line__&&(this.line=u.__line__)}}function CB(h,l){const u=h.indexOf("://")===-1;try{return new URL(h,u&&l?"http://example.com":void 0),!0}catch{return!1}}class RQ{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 LQ{constructor(){this.maxScale=1,this.maxXYTranslationDistance=0,this.instancedDataArray=new lj,this.instancesEvaluatedElevation=[],this.features=[],this.idToFeaturesIndex={}}colorForInstance(l){const u=16*l,m=this.instancedDataArray.float32;let x=Math.floor(m[u+2]);const b=1.05*(m[u+2]-x);return x/=100,[m[u]%1*1.05,m[u+1]%1*1.05,b,x]}tileCoordinatesForInstance(l){const u=16*l,m=this.instancedDataArray.float32;let x=m[u+0];return x=x>or?x-or:x,new Ft(Math.trunc(x),Math.trunc(m[u+1]))}translationForInstance(l){const u=16*l,m=this.instancedDataArray.float32;return[m[u+4],m[u+5],m[u+6]]}rotationScaleForInstance(l){const u=16*l,m=this.instancedDataArray.float32;return[m[u+7],m[u+8],m[u+9],m[u+10],m[u+11],m[u+12],m[u+13],m[u+14],m[u+15]]}transformForInstance(l){const u=16*l,m=this.instancedDataArray.float32;return[m[u+7],m[u+8],m[u+9],m[u+4],m[u+10],m[u+11],m[u+12],m[u+5],m[u+13],m[u+14],m[u+15],m[u+6],0,0,0,1]}}class IB{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,m,x){return{hasLayoutChanges:!1,hasUboChanges:!1}}populate(l,u,m,x){this.tileToMeter=Ot(m);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:A,id:C,index:O,sourceLayerIndex:$}of l){const U=C??(A.properties&&A.properties.hasOwnProperty("id")?A.properties.id:void 0),q=bn(A,b);if(!this.layers[0]._featureFilter.filter(new as(this.zoom,{worldview:this.worldview,activeFloors:u.activeFloors}),q,m))continue;const K={id:U,sourceLayerIndex:$,index:O,geometry:b?q.geometry:Ur(A,m,x),properties:A.properties,type:A.type,patterns:{}},X=this.addFeature(K,K.geometry,q,T,m);X&&u.featureIndex.insert(A,K.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 m=0;for(const x of this.modelUris){const b=l.getModel(x,u);if(!b)continue;const T=this.instancesPerModel[x];if(T){const A=.5*ot(b.aabb.max,b.aabb.min)*T.maxScale+T.maxXYTranslationDistance,C=Math.min(or,Math.max(A/this.tileToMeter,256));m=Math.max(C,m)}}return m}update(l,u,m,x){for(const b in this.instancesPerModel){const T=this.instancesPerModel[b];for(const A in l)T.idToFeaturesIndex.hasOwnProperty(A)&&(this.evaluate(T.features[T.idToFeaturesIndex[A]],l[A],T,!0),this.uploaded=!1)}this.maxHeight=0}updateZoomBasedPaintProperties(){if(!this.hasZoomDependentProperties)return!1;let l=!1;for(const u in this.instancesPerModel){const m=this.instancesPerModel[u];for(const x of m.features){const b=this.layers[0],T=x.feature,A=this.canonical,C=b.paint.get("model-rotation").evaluate(T,{},A),O=b.paint.get("model-scale").evaluate(T,{},A),$=b.paint.get("model-translation").evaluate(T,{},A);yr(x.rotation,C)&&yr(x.scale,O)&&yr(x.translation,$)||(this.evaluate(x,x.featureStates,m,!0),l=!0)}}return l}updateReplacement(l,u,m,x){if(u.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=u.updateTime;const b=u.getReplacementRegionsForTile(l.toUnwrapped(),!0);if(qI(this.activeReplacements,b))return!1;this.activeReplacements=b;let T=!1;for(const A in this.instancesPerModel){const C=this.instancesPerModel[A],O=C.instancedDataArray;for(const $ of C.features){const U=$.instancedDataOffset,q=$.instancedDataCount;for(let K=0;Kor;te=se?te-or:te;const ae=Math.floor(te),he=Math.floor(O.float32[X+1]);let ue=!1;for(const be of this.activeReplacements)if(!pZ(be,m,GI.Model,x)&&!(be.min.x>ae||ae>be.max.x||be.min.y>he||he>be.max.y)&&(ue=_Z(vZ(ae,he,l.canonical,be.footprintTileId.canonical),be.footprint),ue))break;O.float32[X]=ue?te+or: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 m=this.instancesPerModel[u];m.instancedDataArray.length<0||m.instancedDataArray.length===0||(m.instancedDataBuffer?m.instancedDataBuffer.updateData(m.instancedDataArray):m.instancedDataBuffer=l.createVertexBuffer(m.instancedDataArray,ANe.members,!0,void 0,this.instanceCount))}this.uploaded=!0}destroy(l){for(const m in this.instancesPerModel){const x=this.instancesPerModel[m];x.instancedDataArray.length!==0&&x.instancedDataBuffer&&x.instancedDataBuffer.destroy()}const u=this.layers[0].modelManager;if(l&&u&&this.modelUris&&this.modelsRequested)for(const m of this.modelUris)u.removeModel(m,"",!0)}addFeature(l,u,m,x,b){const T=this.layers[0],A=T.layout.get("model-id"),C=T.layout.get("model-allow-density-reduction"),O=A.evaluate(m,{},this.canonical);if(!O)return $r(`modelId is not evaluated for layer ${T.id} and it is not going to get rendered.`),O;(CB(O,!1)||this.styleDefinedModelURLs[O]!==void 0)&&(this.modelUris.includes(O)||this.modelUris.push(O)),this.instancesPerModel[O]||(this.instancesPerModel[O]=new LQ);const $=this.instancesPerModel[O],U=$.instancedDataArray,q=new RQ(m,U.length);let K;x&&(K=Os.getElevationFeature(l,x));for(const X of u)for(const te of X){if(te.x<0||te.x>=or||te.y<0||te.y>=or)continue;if(this.lookupDim!==0&&C){const ae=(this.lookupDim-1)/or,he=this.lookupDim*(te.y*ae|0)+te.x*ae|0;if(this.lookup){if(this.lookup[he]!==0)continue;this.lookup[he]=1}}this.instanceCount++;const se=U.length;if(U.resize(se+1),x){$.instancesRoadElevation||($.instancesRoadElevation=[]);const ae=K?K.pointElevation(new Ft(te.x,te.y)):0;$.instancesRoadElevation.push(ae)}$.instancesEvaluatedElevation.push(0),U.float32[16*se]=te.x,U.float32[16*se+1]=te.y}return q.instancedDataCount=$.instancedDataArray.length-q.instancedDataOffset,q.instancedDataCount>0&&(l.id&&($.idToFeaturesIndex[l.id]=$.features.length),$.features.push(q),this.evaluate(q,{},$,!1)),O}getModelUris(){return this.modelUris}evaluate(l,u,m,x){const b=this.layers[0],T=l.feature,A=this.canonical,C=l.rotation=b.paint.get("model-rotation").evaluate(T,u,A),O=l.scale=b.paint.get("model-scale").evaluate(T,u,A),$=l.translation=b.paint.get("model-translation").evaluate(T,u,A),U=Object.assign({},b.paint.get("model-color").evaluate(T,u,A));U.a=b.paint.get("model-color-mix-intensity").evaluate(T,u,A);const q=[];this.maxVerticalOffset<$[2]&&(this.maxVerticalOffset=$[2]);const K=$[0]*$[0]+$[1]*$[1],X=K>0?Math.sqrt(K):0;m.maxScale=Math.max(Math.max(m.maxScale,O[0]),Math.max(O[1],O[2])),m.maxXYTranslationDistance=Math.max(m.maxXYTranslationDistance,X),this.maxScale=Math.max(Math.max(this.maxScale,O[0]),Math.max(O[1],O[2])),sX(q,C,O);const te=Math.round(100*U.a)+U.b/1.05;for(let se=0;se10?this.tileToMeter:Ot(A,Ne)),ue[he+4]=$[0],ue[he+5]=$[1],ue[he+6]=$[2]+(m.instancesRoadElevation?m.instancesRoadElevation[ae]:0)+be,ue[he+7]=q[0],ue[he+8]=q[1],ue[he+9]=q[2],ue[he+10]=q[4],ue[he+11]=q[5],ue[he+12]=q[6],ue[he+13]=q[8],ue[he+14]=q[9],ue[he+15]=q[10],m.instancesEvaluatedElevation[ae]=$[2]}}}_r(IB,"ModelBucket",{omit:["layers"]}),_r(LQ,"PerModelAttributes"),_r(RQ,"ModelFeature");class iw{constructor(l,u,m){this._demTile=l,this._dem=this._demTile.dem,this._scale=u,this._offset=m}static create(l,u,m){const x=m||l.findDEMTileFor(u);if(!x||!x.dem)return;const b=x.dem,T=x.tileID,A=1<O.fqid),this.stateDependentLayerIds=this.layers.filter(O=>O.isStateDependent()).map(O=>O.id),this.modelTraits|=Xb.CoordinateSpaceTile,this.uploaded=!1,this.hasPattern=!1,x&&(this.modelTraits|=Xb.HasMapboxMeshFeatures),b&&(this.modelTraits|=Xb.HasMeshoptCompression),this.zoom=-1,this.terrainExaggeration=1,this.projection={name:"mercator"},this.replacementUpdateTime=0,this.elevationReadFromZ=255,this.brightness=T,this.worldview=C,this.dirty=!0,this.needsUpload=!1,this.filter=null,this.nodesInfo=[];for(const O of u)this.nodesInfo.push(new FQ(O)),DQ(O,A.featureIndexArray.length,A.grid),A.featureIndexArray.emplaceBack(this.nodesInfo.length-1,0,A.bucketLayerIDs.length-1,0);this.states={},this.hasAppearances=null}updateFootprints(l,u){for(const m of this.getNodesInfo()){const x=m.node;x.footprint&&u.push({footprint:x.footprint,id:l})}}updateAppearances(l,u,m,x){return{hasLayoutChanges:!1,hasUboChanges:!1}}update(l){const u=Object.keys(l).length!==0;if(u&&!this.stateDependentLayers.length)return;const m=u?this.stateDependentLayers:this.layers;if(!Bo(l,this.states))for(const x of m)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 m of u){const x=m.node;this.uploaded?this.updatePbrBuffer(x):Y5(x,l,!0)}for(const m of u)sP(m.node);this.uploaded=!0,this.needsUpload=!1}updatePbrBuffer(l){let u=!1;if(!l.meshes)return u;for(const m of l.meshes)m.pbrBuffer&&(m.pbrBuffer.updateData(m.featureArray),u=!0);return u}needsReEvaluation(l,u,m){const x=l.transform.projectionOptions,b=l.style.getBrightness(),T=this.brightness!==b;if(!this.uploaded||this.dirty||x.name!==this.projection.name||Kj(m.paint.get("model-color").value,T)||Kj(m.paint.get("model-color-mix-intensity").value,T)||Kj(m.paint.get("model-roughness").value,T)||Kj(m.paint.get("model-emissive-strength").value,T)||Kj(m.paint.get("model-height-based-emissive-strength-multiplier").value,T)){this.projection=x,this.brightness=b;const A=this.getNodesInfo();for(const C of A)C.state=null;return!0}return!1}evaluateTransform(l,u){if(l.transform.zoom===this.zoom)return;this.zoom=l.transform.zoom;const m=this.getNodesInfo(),x=this.id.canonical;for(const b of m){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 m=this.getNodesInfo();for(const x of m){if(!x.node.meshes)continue;const b=x.feature,T=u&&u[b.id];if(Bo(T,x.state))continue;x.state=structuredClone(T);const A=x.node.meshes&&x.node.meshes[0].featureData,C=x.evaluatedColor[2],O=x.evaluatedRMEA[2],$=this.id.canonical;if(x.hasTranslucentParts=!1,A){for(let U=0;U=Ie)continue;const zt=PB[kt],mt=Math.abs(zt);mt>Ve&&(Ue=zt,Ve=mt,yt=Pt,bt=At)}if(Ve>.1){const At=1-(Ie+.5*Math.abs(yt*bt))/X;let Pt=u._dem.get(ze,We)+Ue*At;const kt=u._dem.get(ze+yt,We+bt),zt=u._dem.get(ze-yt,We-bt,!0);(Pt-kt)*(Pt-zt)>0&&(Pt=(kt+zt)/2),PB[He]=u._dem.set(ze,We,Pt),nv[He]=Ie}}}}}A&&(u._demTile.needsDEMTextureUpload=!0,u._dem._timestamp=Ul.now())}setFilter(l){this.filter=l?Ib(l):null}getNodesInfo(){return this.filter?this.nodesInfo.filter(l=>this.filter.filter(new as(this.id.overscaledZ,{worldview:this.worldview}),l.feature,this.id.canonical)):this.nodesInfo}destroy(){const l=this.getNodesInfo();for(const u of l)sP(u.node),Z5(u.node)}isEmpty(){return!this.nodesInfo.length}updateReplacement(l,u){if(u.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=u.updateTime;const m=u.getReplacementRegionsForTile(l.toUnwrapped());for(const x of this.getNodesInfo()){const b=x.node.footprint;x.hiddenByReplacement=!!b&&!m.find(T=>T.footprint===b)}}getHeightAtTileCoord(l,u){const m=[],x=[0,0,0],b=P([]);for(const T of this.getNodesInfo()){const A=T.node.meshes[0],C=A.transformedAabb;if(lC.max[0]||u>C.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,lr(x,x,b);const O=(x[0]-A.aabb.min[0])/(A.aabb.max[0]-A.aabb.min[0])*Q0|0,$=Math.min(63,(x[1]-A.aabb.min[1])/(A.aabb.max[1]-A.aabb.min[1])*Q0|0)*Q0+Math.min(63,O),U=A.heightmap[$];if(!(U<0&&T.node.footprint))return T.hiddenByReplacement?void 0:{height:U,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),m),m.length>0)return{height:void 0,maxHeight:T.feature.properties.height,hidden:T.hiddenByReplacement,verticalScale:T.evaluatedScale[2]}}}}function Kj(h,l){return h instanceof Wg&&!h.isLightConstant&&l}function cIe(h,l,u,m,x,b,T,A){let C=(61440&l|(61440&l)>>4)>>8,O=(3840&l|(3840&l)>>4)>>4,$=240&l|(240&l)>>4;u[3]>0&&(C=Qr(C,255*u[0],u[3]),O=Qr(O,255*u[1],u[3]),$=Qr($,255*u[2],u[3]));const U=C<<8|O,q=$<<8|Math.floor(255*m[3]),K=function(Ie){const We=fe(Ie,0,2);return Math.min(Math.round(.5*We*255),255)}(m[2])<<8|15*m[0]<<4|15*m[1],X=fe(x[0],0,1),te=fe(x[1],0,1),se=fe(x[2],0,1),ae=fe(x[3],0,1);let he,ue,be,Ne;if(X!==te&&T!==b&&te!==X){const Ie=T-b;ue=1/(Ie*(te-X)),be=-(b+Ie*X)/(Ie*(te-X));const We=fe(x[4],-1,1);Ne=Math.pow(10,We),he=255*se<<8|255*ae}else he=65535,ue=0,be=1,Ne=1;if(h.emplaceBack(U,q,K,he,ue,be,Ne),A){const Ie=A.length;A.clear();for(let We=0;We>16&65535,$=b?C>>16&65535:65535&C,U=(15&$)<8?15&$:0,q=h.evaluatedRMEA[U],K=h.evaluatedColor[U],X=h.emissionHeightBasedParams[U];let te;if(A&&U===2&&m.lights&&(te=new Bb,te.resize(10*m.lights.length)),cIe(T.featureArray,O,K,q,X,T.aabb.min[2],T.aabb.max[2],te),te&&A){A=!1;const se=m.meshes[m.lightMeshIndex];se.featureArray=te,se.featureArray._trim()}}T.featureArray._trim(),x++}}_r(jP,"Tiled3dModelBucket",{omit:["layers"]}),_r(FQ,"Tiled3dModelFeature");const dIe=["id","tile","layer","source","sourceLayer","state"];class sv{constructor(l,u,m,x,b){this.type="Feature",this._vectorTileFeature=l,this._z=u,this._x=m,this._y=x,this.properties=l?l.properties:{},this.id=b}clone(){const l=new sv(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 dIe)this[u]!==void 0&&(l[u]=this[u]);return l}}class iv extends s0{constructor(l,u,m,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 eX(this.map._requestManager.transformRequest(l,r0.Model).url,u)}async loadModel(l,u,m){try{const x=await this.loadGLTFFromURI(u.uri,m);if(m.aborted)return;const b=this._modelsInfo.get(l);if(!b)return;const T=Q5(x),A=b.modelSpec,C=new iX(l,A.uri,A.position,A.orientation,T);iv.applyModelSpecification(C,A),C.computeBoundsAndApplyParent(),this.models.push(C),b.model=C}catch(x){if(x instanceof Error&&x.name==="AbortError")return;const b=x instanceof Error?x.message:"Unknown error";this.fire(new Pg(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 m in this._options.models){const x=this._options.models[m],b=this._modelsInfo.get(m);if(b&&b.model){b.modelSpec=x;const T=b.model;T.position=x.position!=null?new Qe(x.position[0],x.position[1]):new Qe(0,0),T.orientation=x.orientation!=null?x.orientation:[0,0,0],iv.applyModelSpecification(T,x),T.computeBoundsAndApplyParent(),this.models.push(T)}else b?b.modelSpec=x:(this._modelsInfo.set(m,{modelSpec:x,model:null}),u.push(this.loadModel(m,x,l)))}u.length!==0?(await Promise.allSettled(u),l.aborted||this.fire(new qu("data",{dataType:"source",sourceDataType:"metadata"}))):this.loaded()&&this.fire(new qu("data",{dataType:"source",sourceDataType:"metadata"}))}static applyModelSpecification(l,u){u.nodeOverrides&&iv.convertNodeOverrides(l,u.nodeOverrides),u.materialOverrides&&iv.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(m=>typeof m=="string")){l.nodeOverrideNames=[];for(const m of u)l.nodeOverrideNames.push(m)}else Object.entries(u).forEach(([m,x])=>{const b={orientation:[0,0,0]};if(x.hasOwnProperty("orientation")){const T=x.orientation;T&&(b.orientation=T)}l.nodeOverrides.set(m,b)})}static convertMaterialOverrides(l,u){if(Array.isArray(u)&&u.every(m=>typeof m=="string")){l.materialOverrideNames=[];for(const m of u)l.materialOverrideNames.push(m)}else Object.entries(u).forEach(([m,x])=>{const b={color:new Qn(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 A=x["model-color-mix-intensity"];A!==void 0&&(b.colorMix=A);const C=x["model-emissive-strength"];C!==void 0&&(b.emissionStrength=C);const O=x["model-opacity"];O!==void 0&&(b.opacity=O),l.materialOverrides.set(m,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 m in l){const x=l[m],b=this._modelsInfo.get(m);b&&b.modelSpec.uri===x.uri&&u.set(m,b)}if(this._modelsInfo.size!==u.size){this.cancelModelRequests();for(const[m,x]of u)x.model||u.delete(m)}this._modelsInfo=u,this._options.models=l,this.load()}}function RB(h,l,u,m){const x=1<C>=Ne.vertexArrayOffset&&Cbe.polygon).flat());const se=K?A:null,[ae,he]=BZ(b,m,U,$,O,T,se,q,X,b.center.lat,h.tileID.canonical),ue=h.queryGeometry;return FZ(ae,he,ue.isPointQuery()?ue.screenBounds:ue.screenGeometry)}},building:class extends nl{constructor(h,l,u,m){super(h,{layout:hX||(hX=new ri({visibility:new Qt(st.layout_building.visibility),"building-facade":new Ht(st.layout_building["building-facade"]),"building-facade-floors":new Ht(st.layout_building["building-facade-floors"]),"building-facade-unit-width":new Ht(st.layout_building["building-facade-unit-width"]),"building-facade-window":new Ht(st.layout_building["building-facade-window"]),"building-roof-shape":new Ht(st.layout_building["building-roof-shape"]),"building-height":new Ht(st.layout_building["building-height"]),"building-base":new Ht(st.layout_building["building-base"]),"building-flood-light-wall-radius":new Ht(st.layout_building["building-flood-light-wall-radius"]),"building-flood-light-ground-radius":new Ht(st.layout_building["building-flood-light-ground-radius"]),"building-flip-roof-orientation":new Ht(st.layout_building["building-flip-roof-orientation"])})),paint:fX||(fX=new ri({"building-opacity":new Qt(st.paint_building["building-opacity"]),"building-ambient-occlusion-intensity":new Qt(st.paint_building["building-ambient-occlusion-intensity"]),"building-ambient-occlusion-ground-intensity":new Qt(st.paint_building["building-ambient-occlusion-ground-intensity"]),"building-ambient-occlusion-ground-radius":new Qt(st.paint_building["building-ambient-occlusion-ground-radius"]),"building-ambient-occlusion-ground-attenuation":new Qt(st.paint_building["building-ambient-occlusion-ground-attenuation"]),"building-vertical-scale":new Qt(st.paint_building["building-vertical-scale"]),"building-cast-shadows":new Qt(st.paint_building["building-cast-shadows"]),"building-color":new Ht(st.paint_building["building-color"]),"building-emissive-strength":new Ht(st.paint_building["building-emissive-strength"]),"building-facade-emissive-chance":new Qt(st.paint_building["building-facade-emissive-chance"]),"building-cutoff-fade-range":new Qt(st.paint_building["building-cutoff-fade-range"]),"building-front-cutoff":new Qt(st.paint_building["building-front-cutoff"]),"building-flood-light-color":new Qt(st.paint_building["building-flood-light-color"]),"building-flood-light-intensity":new Qt(st.paint_building["building-flood-light-intensity"]),"building-flood-light-ground-attenuation":new Qt(st.paint_building["building-flood-light-ground-attenuation"]),"building-color-use-theme":new Ht({type:"string",default:"default","property-type":"data-driven"}),"building-flood-light-color-use-theme":new Ht({type:"string",default:"default","property-type":"data-driven"})}))},l,u,m),this._stats={numRenderedVerticesInShadowPass:0,numRenderedVerticesInTransparentPass:0}}createBucket(h){return new dX(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,m,x,b,T,A,C,O){let $=this.layout.get("building-height").evaluate(l,u);const U=this.layout.get("building-base").evaluate(l,u),q=h.tile.getBucket(this).getFootprint(l);if(q){if(q.hiddenFlags!==0)return!1;$=q.height}const[K,X]=BZ(b,m,U,$,new Ft(0,0),T,null,[0,0],1,b.center.lat,h.tileID.canonical),te=h.queryGeometry;return FZ(K,X,te.isPointQuery()?te.screenBounds:te.screenGeometry)}},line:class extends nl{constructor(h,l,u,m){const x=SX();super(h,x,l,u,m),x.layout&&(this.layout=new Nh(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 v0,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(Lj)return Lj;const u=SX();return Lj=new iCe(u.paint.properties["line-width"].specification),Lj.useIntegerZoom=!0,Lj})().possiblyEvaluate(this._transitioningPaint._values["line-width"].value,h)}createBucket(h){return new aP(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 m=bX(this);return{config:new re(this,{zoom:l,lut:u}),defines:m,overrideFog:!1}}queryRadius(h){const l=h,u=TX(ry("line-width",this,l),ry("line-gap-width",this,l)),m=ry("line-offset",this,l);return u/2+Math.abs(m)+CI(this.paint.get("line-translate"))}queryIntersectsFeature(h,l,u,m,x,b){if(h.queryGeometry.isAboveHorizon)return!1;const T=wY(h.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),b.angle,h.pixelToTileUnitsFactor),A=h.pixelToTileUnitsFactor/2*TX(this.paint.get("line-width").evaluate(l,u),this.paint.get("line-gap-width").evaluate(l,u)),C=this.paint.get("line-offset").evaluate(l,u);return C&&(m=function(O,$){const U=[],q=new Ft(0,0);for(let K=0;K=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 BQ{constructor(l){this._stringToNumber={},this._numberToString=[];for(let u=0;u=0&&q[3]>=0&&O.insert(C,q[0],q[1],q[2],q[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new ts(new oP(this.rawTileData)).layers,this.sourceLayerCoder=new BQ(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:m,transform:x,tileTransform:b,pixelPosMatrix:T,availableImages:A,worldview:C}=u;this.loadVTLayers(),this.serializedLayersCache.clear();const O=u.queryRadius?u.queryRadius:0,$=m.bufferedTilespaceBounds,U=this.grid.query($.min.x,$.min.y,$.max.x,$.max.y,(te,se,ae,he)=>Bf(m.bufferedTilespaceGeometry,te-O,se-O,ae+O,he+O));U.sort(pIe);let q=null;x.elevation&&U.length>0&&(q=iw.create(x.elevation,this.tileID));const K={};let X;for(let te=0;te(he||(he=Ur(ue,this.tileID.canonical,b)),be.queryIntersectsFeature(m,ue,Ne,he,this.z,x,T,q,Ie,u.scope)))}return K}loadMatchingFeature(l,u,m,x,b,T){const{featureIndex:A,bucketIndex:C,sourceLayerIndex:O,layoutVertexArrayOffset:$}=u,U=this.bucketLayerIDs[C],q=m.layers,K=Object.keys(q);if(K.length&&!Br(K,U))return;const X=m.sourceCache,te=this.sourceLayerCoder.decode(O),se=this.vtLayers[te].feature(A),ae=this.getId(se,te);for(let he=0;he`${A.key}: ${A.message}`).join(", ");return void $r(`Failed to create expression for promoteId: ${T}`)}this.promoteIdExpression=b.value}m=this.promoteIdExpression.evaluate({zoom:0},l)}else m=l.properties[x];typeof m=="boolean"&&(m=Number(m))}return m}}function zQ(h,l,u,m,x){return Ut(h,(b,T)=>{const A=l instanceof Nh?l.get(T):null;return A&&A.evaluate?A.evaluate(u,m,void 0,x):A})}function pIe(h,l){return l-h}function UQ(h,l){const u={};if(!l)return u;for(const m of h){const x=m.layerIds.map(b=>l.getLayer(b)).filter(Boolean);if(x.length!==0){m.layers=x,m.stateDependentLayerIds&&(m.stateDependentLayers=m.stateDependentLayerIds.map(b=>x.filter(T=>T.id===b)[0]));for(const b of x)u[b.fqid]=m}}return u}_r($Q,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});const $d=32,Hf=33,cy=new Uint16Array(8184);for(let h=0;h<2046;h++){let l=h+2,u=0,m=0,x=0,b=0,T=0,A=0;for(1&l?x=b=T=$d:u=m=A=$d;(l>>=1)>1;){const O=u+x>>1,$=m+b>>1;1&l?(x=u,b=m,u=T,m=A):(u=x,m=b,x=T,b=A),T=O,A=$}const C=4*h;cy[C+0]=u,cy[C+1]=m,cy[C+2]=x,cy[C+3]=b}const Wf=new Uint16Array(2178),uy=new Uint8Array(1089),AP=new Uint16Array(1089);function VQ(h){return h===0?-.03125:h===32?.03125:0}const qQ={Other:0,Symbol:1,FillExtrusion:2},GQ={type:2,extent:or,loadGeometry:()=>[[new Ft(0,0),new Ft(8193,0),new Ft(8193,8193),new Ft(0,8193),new Ft(0,0)]]};class gIe{constructor(){this.tasks={},this.taskQueue=[],ht(["process"],this),this.invoker=new mIe(this.process),this.nextId=0}add(l,u){const m=this.nextId++,x=function({type:b,renderSourceType:T,zoom:A}){A=A||0;const C=T===qQ.Symbol;return b==="message"?0:b!=="maybePrepare"||C?b!=="parseTile"||C?b==="parseTile"&&C?300-A:b==="maybePrepare"&&C?400-A:500:200-A:100-A}(u);if(x===0){try{l()}finally{}return null}return this.tasks[m]={fn:l,metadata:u,priority:x,id:m},this.taskQueue.push(m),this.invoker.trigger(),{cancel:()=>{delete this.tasks[m]}}}process(){try{if(this.taskQueue=this.taskQueue.filter(m=>!!this.tasks[m]),!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 kIe(h,l,u){h===1?(l.rgb_color=CP(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 NIe(h,l,u){h===1?l.transform=NP(u,u.readVarint()+u.pos):h===2?l.spread_method=u.readVarint():h===3?l.stops.push(KQ(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 KQ(h,l){return h.readFields(CIe,{offset:0,opacity:255,rgb_color:LB},l)}function CIe(h,l,u){h===1?l.offset=u.readFloat():h===2?l.opacity=u.readVarint():h===3&&(l.rgb_color=CP(u.readVarint()))}function IIe(h,l,u){h===1?l.transform=NP(u,u.readVarint()+u.pos):h===2?l.spread_method=u.readVarint():h===3?l.stops.push(KQ(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 PIe(h,l,u){h===1?l.transform=NP(u,u.readVarint()+u.pos):h===2?l.clip_path_idx=u.readVarint():h===3&&l.children.push(kP(u,u.readVarint()+u.pos))}function RIe(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(kP(u,u.readVarint()+u.pos))}class LIe{static calculate(l={},u=[]){const m=new Map,x=new Map;if(Object.keys(l).length===0)return m;u.forEach(b=>{x.set(b.name,b.rgb_color||new Qn(0,0,0))});for(const[b,T]of Object.entries(l))x.has(b)?m.set(x.get(b).toString(),T):console.warn(`Ignoring unknown image variable "${b}"`);return m}}function aw(h,l=255,u){const m=l/255,x=h.toString(),b=u.has(x)?u.get(x).clone():h.clone();return b.a*=m,b.toString()}function Yj(h,l){if(!hu()){const u=document.createElement("canvas");return u.width=h,u.height=l,u}return new OffscreenCanvas(h,l)}let MB,Zj=null;function DB(h,l,u,m,x){for(const b of m.children)YQ(h,l,u,b,x)}function YQ(h,l,u,m,x){m.group?(h.save(),function(b,T,A,C,O){const $=C.mask_idx!=null?A.masks[C.mask_idx]:null,U=C.clip_path_idx!=null?A.clip_paths[C.clip_path_idx]:null;if(C.transform&&(T=ow(C.transform).preMultiplySelf(T)),!function(X,te,se){return X.opacity!==255||te||se}(C,U!=null,$!=null))return void DB(b,T,A,C,O);const q=Yj(b.canvas.width,b.canvas.height),K=q.getContext("2d");DB(K,T,A,C,O),U&&rJ(K,T,A,U),$&&nJ(K,T,A,$,O),b.globalAlpha=C.opacity/255,b.drawImage(q,0,0)}(h,l,u,m.group,x),h.restore()):m.path&&(h.save(),function(b,T,A,C,O){b.setTransform(T),C.paint_order===1?(ZQ(b,A,C,O),QQ(b,A,C,O)):(QQ(b,A,C,O),ZQ(b,A,C,O))}(h,l,u,m.path,x),h.restore())}function ZQ(h,l,u,m){const x=u.fill;if(!x)return;const b=x.opacity/255;switch(h.save(),h.beginPath(),sJ(u,h),x.paint){case"rgb_color":h.fillStyle=aw(x.rgb_color,x.opacity,m);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=JQ(h,T,b,m);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=eJ(h,T,b,m)}}h.fill(XQ(u)),h.restore()}function XQ(h){return h.rule===1?"nonzero":h.rule===2?"evenodd":void 0}function QQ(h,l,u,m){const x=u.stroke;if(!x)return;const b=iJ(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=aw(x.rgb_color,x.opacity,m);break;case"linear_gradient_idx":h.strokeStyle=JQ(h,l.linear_gradients[x.linear_gradient_idx],T,m,!0);break;case"radial_gradient_idx":h.strokeStyle=eJ(h,l.radial_gradients[x.radial_gradient_idx],T,m,!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 JQ(h,l,u,m,x=!1){if(l.stops.length===1){const q=l.stops[0];return aw(q.rgb_color,q.opacity*u,m)}const{x1:b,y1:T,x2:A,y2:C}=l;let O=new DOMPoint(b,T),$=new DOMPoint(A,C);if(x){const q=ow(l.transform);O=q.transformPoint(O),$=q.transformPoint($)}const U=h.createLinearGradient(O.x,O.y,$.x,$.y);for(const q of l.stops)U.addColorStop(q.offset,aw(q.rgb_color,q.opacity*u,m));return U}function eJ(h,l,u,m,x=!1){if(l.stops.length===1){const ae=l.stops[0];return aw(ae.rgb_color,ae.opacity*u,m)}const b=ow(l.transform),{fx:T,fy:A,fr:C,cx:O,cy:$,r:U}=l;let q=new DOMPoint(T,A),K=new DOMPoint(O,$),X=C,te=U;if(x){q=b.transformPoint(q),K=b.transformPoint(K);const ae=(b.a+b.d)/2;X=C*ae,te=l.r*ae}const se=h.createRadialGradient(q.x,q.y,X,K.x,K.y,te);for(const ae of l.stops)se.addColorStop(ae.offset,aw(ae.rgb_color,ae.opacity*u,m));return se}function tJ(h,l,u,m){const x=m.transform?ow(m.transform).preMultiplySelf(l):l,b=Yj(h.canvas.width,h.canvas.height),T=b.getContext("2d");for(const C of m.children)if(C.group)tJ(T,x,u,C.group);else if(C.path){const O=C.path,$=new Path2D;$.addPath(iJ(O),x),T.fill($,XQ(O))}const A=m.clip_path_idx!=null?u.clip_paths[m.clip_path_idx]:null;A&&rJ(T,x,u,A),h.globalCompositeOperation="source-over",h.drawImage(b,0,0)}function rJ(h,l,u,m){const x=Yj(h.canvas.width,h.canvas.height);tJ(x.getContext("2d"),l,u,m),h.globalCompositeOperation="destination-in",h.drawImage(x,0,0)}function nJ(h,l,u,m,x){if(m.children.length===0)return;const b=m.mask_idx!=null?u.masks[m.mask_idx]:null;b&&nJ(h,l,u,b,x);const T=h.canvas.width,A=h.canvas.height,C=Yj(T,A),O=C.getContext("2d"),$=m.width,U=m.height,q=m.left,K=m.top,X=new Path2D,te=new Path2D;te.rect(q,K,$,U),X.addPath(te,l),O.clip(X);for(const he of m.children)YQ(O,l,u,he,x);const se=O.getImageData(0,0,T,A),ae=se.data;if(m.mask_type===1)for(let he=0;hel[T])return null}else{const A=1/m[T];let C=(h[T]-u[T])*A,O=(l[T]-u[T])*A;if(C>O){const $=C;C=O,O=$}if(C>x&&(x=C),Ob)return null}return x}function lJ(h,l,u,m,x,b,T,A,C,O,$){const U=m-h,q=x-l,K=b-u,X=T-h,te=A-l,se=C-u,ae=$[1]*se-$[2]*te,he=$[2]*X-$[0]*se,ue=$[0]*te-$[1]*X,be=U*ae+q*he+K*ue;if(Math.abs(be)<1e-15)return null;const Ne=1/be,Ie=O[0]-h,We=O[1]-l,ze=O[2]-u,He=(Ie*ae+We*he+ze*ue)*Ne;if(He<0||He>1)return null;const Ue=We*K-ze*q,Ve=ze*U-Ie*K,yt=Ie*q-We*U,bt=($[0]*Ue+$[1]*Ve+$[2]*yt)*Ne;return bt<0||He+bt>1?null:(X*Ue+te*Ve+se*yt)*Ne}function cJ(h,l,u){return(h-l)/(u-l)}function uJ(h,l,u,m,x,b,T,A,C){const O=1<{const he=se?1:0,ue=(K+1)*te-he,be=X*te,Ne=(X+1)*te-he;ae[0]=K*te,ae[1]=be,ae[2]=ue,ae[3]=Ne};let U=new aJ(C);const q=[];for(let K=0;K=1;C/=2){const K=A[A.length-1];U=new aJ(C);for(let X=0;X0;){const{idx:X,t:te,nodex:se,nodey:ae,depth:he}=K.pop();if(this.leaves[X]){uJ(se,ae,he,l,u,m,x,U,q);const be=1<=kt[2])return te}continue}let ue=0;for(let be=0;be=O[$[ze]]&&($.splice(ze,0,be),We=!0);We||($[ue]=be),ue++}}for(let be=0;be=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 m=[0,0,0,0],x=PP.getUnpackVector(u);let b=Math.floor((l+x[3])/x[2]);return m[2]=b%256,b=Math.floor(b/256),m[1]=b%256,b=Math.floor(b/256),m[0]=b,m}getPixels(){return new WY({width:this.stride,height:this.stride},this.pixels)}backfillBorder(l,u,m){if(this.dim!==l.dim)throw new Error("dem dimension mismatch");let x=u*this.dim,b=u*this.dim+this.dim,T=m*this.dim,A=m*this.dim+this.dim;switch(u){case-1:x=b-1;break;case 1:b=x+1}switch(m){case-1:T=A-1;break;case 1:A=T+1}const C=-u*this.dim,O=-m*this.dim;for(let $=T;$=1;m--){const x=m===1?1:0,b=m===2?1:0;for(let T=0;T>>1^-(1&h[l]);return h}function KIe(h,l){switch(l){case"uint32":return h;case"uint16":for(let u=0;u>4|(61440&m)>>8|(240&x)<<4|61440&x,h[u+1]=15&m|(3840&m)>>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&m)>>4|(48&x)>>2|48&b|(48&T)<<2,h[u+2]=(12&m)>>2|12&x|(12&b)<<2|(12&T)<<4,h[u+3]=3&m|(3&x)<<2|(3&b)<<4|(3&T)<<6}return h;default:throw new Error(`Invalid pixel format, "${l}"`)}}_r(PP,"DEMData"),_r(dJ,"DemMinMaxQuadTree",{omit:["dem"]});var Zu=Uint8Array,Xj=Uint16Array,YIe=Int32Array,fJ=new Zu([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]),mJ=new Zu([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]),ZIe=new Zu([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),pJ=function(h,l){for(var u=new Xj(31),m=0;m<31;++m)u[m]=l+=1<>1|(21845&ka)<<1;xJ[ka]=((65280&(lw=(61680&(lw=(52428&lw)>>2|(13107&lw)<<2))>>4|(3855&lw)<<4))>>8|(255&lw)<<8)>>1}var Qj=function(h,l,u){for(var m=h.length,x=0,b=new Xj(l);x>C]=O;return T},Jj=new Zu(288);for(ka=0;ka<144;++ka)Jj[ka]=8;for(ka=144;ka<256;++ka)Jj[ka]=9;for(ka=256;ka<280;++ka)Jj[ka]=7;for(ka=280;ka<288;++ka)Jj[ka]=8;var vJ=new Zu(32);for(ka=0;ka<32;++ka)vJ[ka]=5;var JIe=Qj(Jj,9),ePe=Qj(vJ,5),FB=function(h){for(var l=h[0],u=1;ul&&(l=h[u]);return l},Dh=function(h,l,u){var m=l/8|0;return(h[m]|h[m+1]<<8)>>(7&l)&u},BB=function(h,l){var u=l/8|0;return(h[u]|h[u+1]<<8|h[u+2]<<16)>>(7&l)},tPe=function(h){return(h+7)/8|0},rPe=["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"],Oh=function(h,l,u){var m=new Error(l||rPe[h]);if(m.code=h,Error.captureStackTrace&&Error.captureStackTrace(m,Oh),!u)throw m;return m},nPe=new Zu(0),sPe=typeof TextDecoder<"u"&&new TextDecoder;try{sPe.decode(nPe,{stream:!0})}catch{}const iPe={gzip_data:"gzip"};class zd extends Error{constructor(l){super(l),this.name="MRTError"}}const aPe={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},_J={uint32:1,uint16:2,uint8:4},oPe={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};let $B;class RP{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 zd(`Layer '${l}' not found`);return u}getHeaderLength(l){const u=new Uint8Array(l),m=new DataView(l);if(u[0]!==13)throw new zd("File is not a valid MRT.");return m.getUint32(1,!0)}parseHeader(l){const u=new Uint8Array(l),m=this.getHeaderLength(l);if(u.length= ${m} but got buffer of length ${u.length}`);const x=new $B(u.subarray(0,m)).readFields(FIe,{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 zd(`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 bJ(b,{cacheSize:this._cacheSize});return this}createDecodingTask(l){const u=[],m=this.getLayer(l.layerName);for(let x of l.blockIndices){const b=m.dataIndex[x],T=b.firstByte-l.firstByte,A=b.lastByte-l.firstByte;if(m._blocksInProgress.has(x))continue;const C={layerName:m.name,firstByte:T,lastByte:A,pixelFormat:m.pixelFormat,blockIndex:x,blockShape:[b.bands.length].concat(m.bandShape),buffer:m.buffer,codec:b.codec.codec,filters:b.filters.map(O=>O.filter)};m._blocksInProgress.add(x),u.push(C)}return new wJ(u,()=>{u.forEach(x=>m._blocksInProgress.delete(x.blockIndex))},(x,b)=>{if(u.forEach(T=>m._blocksInProgress.delete(T.blockIndex)),x)throw x;b.forEach(T=>{this.getLayer(T.layerName).processDecodedData(T)})})}}class bJ{constructor({version:l,name:u,units:m,tileSize:x,pixelFormat:b,buffer:T,dataIndex:A},C){if(this.version=l,this.version!==1)throw new zd(`Cannot parse raster layer encoded with MRT version ${l}`);this.name=u,this.units=m,this.tileSize=x,this.buffer=T,this.pixelFormat=aPe[b],this.dataIndex=A,this.bandShape=[x+2*T,x+2*T,_J[this.pixelFormat]],this._decodedBlocks=new IP(C?C.cacheSize:5),this._blocksInProgress=new Set}get dimension(){return _J[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[m,x]of this.dataIndex.entries()){for(const[b,T]of x.bands.entries())if(T===l)return{bandIndex:u+b,blockIndex:m,blockBandIndex:b};u+=x.bands.length}break;case"number":for(const[m,x]of this.dataIndex.entries()){if(l>=u&&lthis.cacheSize)throw new zd(`Number of blocks to decode (${b.size}) exceeds cache size (${this.cacheSize}).`);return{layerName:this.name,firstByte:u,lastByte:m,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:m}=this.getBlockForBand(l);if(u<0)throw new zd(`Band not found: ${JSON.stringify(l)}`);const x=this._decodedBlocks.get(u.toString());if(!x)throw new zd(`Data for band ${JSON.stringify(l)} of layer "${this.name}" not decoded.`);const b=this.dataIndex[u],T=this.bandShape.reduce((O,$)=>O*$,1),A=m*T,C=x.subarray(A,A+T);return{data:C,bytes:new Uint8Array(C.buffer).subarray(C.byteOffset,C.byteOffset+C.byteLength),tileSize:this.tileSize,buffer:this.buffer,pixelFormat:this.pixelFormat,dimension:this.dimension,offset:b.offset,scale:b.scale}}}RP.setPbf=function(h){$B=h};class wJ{constructor(l,u,m){this.tasks=l,this._onCancel=u,this._onComplete=m,this._finalized=!1}cancel(){this._finalized||(this._onCancel(),this._finalized=!0)}complete(l,u){this._finalized||(this._onComplete(l,u),this._finalized=!0)}}RP.performDecoding=function(h,l){const u=new Uint8Array(h);return Promise.all(l.tasks.map(m=>{const{layerName:x,firstByte:b,lastByte:T,pixelFormat:A,blockShape:C,blockIndex:O,filters:$,codec:U}=m,q=u.subarray(b,T+1),K=new Uint32Array(C[0]*C[1]*C[2]);let X;if(U!=="gzip_data")throw new zd(`Unhandled codec: ${U}`);return X=function(te,se){if(!globalThis.DecompressionStream&&se==="gzip_data")return Promise.resolve((Ne=function(ze){ze[0]==31&&ze[1]==139&&ze[2]==8||Oh(6,"invalid gzip data");var He=ze[3],Ue=10;4&He&&(Ue+=2+(ze[10]|ze[11]<<8));for(var Ve=(He>>3&1)+(He>>4&1);Ve>0;Ve-=!ze[Ue++]);return Ue+(2&He)}(ae=te),Ne+8>ae.length&&Oh(6,"invalid gzip data"),function(ze,He,Ue,Ve){var yt=ze.length;if(!yt||He.f&&!He.l)return Ue||new Zu(0);var bt=!Ue,At=bt||He.i!=2,Pt=He.i;bt&&(Ue=new Zu(3*yt));var kt=function(pi){var sl=Ue.length;if(pi>sl){var Xa=new Zu(Math.max(2*sl,pi));Xa.set(Ue),Ue=Xa}},zt=He.f||0,mt=He.p||0,Nt=He.b||0,Mt=He.l,Vt=He.d,Yt=He.m,xr=He.n,sr=8*yt;do{if(!Mt){zt=Dh(ze,mt,1);var nr=Dh(ze,mt+1,3);if(mt+=3,!nr){var Zt=ze[(os=tPe(mt)+4)-4]|ze[os-3]<<8,mr=os+Zt;if(mr>yt){Pt&&Oh(0);break}At&&kt(Nt+Zt),Ue.set(ze.subarray(os,mr),Nt),He.b=Nt+=Zt,He.p=mt=8*mr,He.f=zt;continue}if(nr==1)Mt=JIe,Vt=ePe,Yt=9,xr=5;else if(nr==2){var kr=Dh(ze,mt,31)+257,zr=Dh(ze,mt+10,15)+4,Rr=kr+Dh(ze,mt+5,31)+1;mt+=14;for(var cn=new Zu(Rr),Un=new Zu(19),un=0;un>4)<16)cn[un++]=os;else{var Rs=0,ci=0;for(os==16?(ci=3+Dh(ze,mt,3),mt+=2,Rs=cn[un-1]):os==17?(ci=3+Dh(ze,mt,7),mt+=3):os==18&&(ci=11+Dh(ze,mt,127),mt+=7);ci--;)cn[un++]=Rs}}var za=cn.subarray(0,kr),ui=cn.subarray(kr);Yt=FB(za),xr=FB(ui),Mt=Qj(za,Yt),Vt=Qj(ui,xr)}else Oh(1);if(mt>sr){Pt&&Oh(0);break}}At&&kt(Nt+131072);for(var wi=(1<>4;if((mt+=15&Rs)>sr){Pt&&Oh(0);break}if(Rs||Oh(2),Ao<256)Ue[Nt++]=Ao;else{if(Ao==256){Si=mt,Mt=null;break}var Ua=Ao-254;Ao>264&&(Ua=Dh(ze,mt,(1<<(Li=fJ[un=Ao-257]))-1)+yJ[un],mt+=Li);var En=Vt[BB(ze,mt)&Zi],El=En>>4;if(En||Oh(3),mt+=15&En,ui=QIe[El],El>3){var Li=mJ[El];ui+=BB(ze,mt)&(1<sr){Pt&&Oh(0);break}At&&kt(Nt+131072);var Za=Nt+Ua;if(Ntpi.length)&&(Xa=pi.length),new Zu(pi.subarray(0,Xa))}(Ue,0,Nt):Ue.subarray(0,Nt)}(ae.subarray(Ne,-8),{i:2},new Zu(((ue=ae)[(be=ue.length)-4]|ue[be-3]<<8|ue[be-2]<<16|ue[be-1]<<24)>>>0),he)));var ae,he,ue,be,Ne;const Ie=iPe[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))}(q,U).then(te=>(function(se,ae){se.readFields(qIe,ae)}(new $B(te),K),new oPe[A](K.buffer))),X.then(te=>{for(let se=$.length-1;se>=0;se--)switch($[se]){case"delta_filter":HIe(te,C);break;case"zigzag_filter":WIe(te);break;case"bitshuffle_filter":KIe(te,A);break;default:throw new zd(`Unhandled filter "${$[se]}"`)}return{layerName:x,blockIndex:O,data:te}}).catch(te=>{throw te})}))},_r(wJ,"MRTDecodingBatch",{omit:["_onCancel","_onComplete"]}),_r(RP,"MapboxRasterTile"),_r(bJ,"MapboxRasterLayer",{omit:["_blocksInProgress"]});const SJ=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class zB{static from(l){if(!(l instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[u,m]=new Uint8Array(l,0,2);if(u!==219)throw new Error("Data does not appear to be in a KDBush format.");const x=m>>4;if(x!==1)throw new Error(`Got v${x} data when expected v1.`);const b=SJ[15&m];if(!b)throw new Error("Unrecognized array type.");const[T]=new Uint16Array(l,2,1),[A]=new Uint32Array(l,4,1);return new zB(A,T,b,l)}constructor(l,u=64,m=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=m,this.IndexArrayType=l<65536?Uint16Array:Uint32Array;const b=SJ.indexOf(this.ArrayType),T=2*l*this.ArrayType.BYTES_PER_ELEMENT,A=l*this.IndexArrayType.BYTES_PER_ELEMENT,C=(8-A%8)%8;if(b<0)throw new Error(`Unexpected typed array class: ${m}.`);x&&x instanceof ArrayBuffer?(this.data=x,this.ids=new this.IndexArrayType(this.data,8,l),this.coords=new this.ArrayType(this.data,8+A+C,2*l),this._pos=2*l,this._finished=!0):(this.data=new ArrayBuffer(8+T+A+C),this.ids=new this.IndexArrayType(this.data,8,l),this.coords=new this.ArrayType(this.data,8+A+C,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 m=this._pos>>1;return this.ids[m]=m,this.coords[this._pos++]=l,this.coords[this._pos++]=u,m}finish(){const l=this._pos>>1;if(l!==this.numItems)throw new Error(`Added ${l} items when expected ${this.numItems}.`);return UB(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(l,u,m,x){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:b,coords:T,nodeSize:A}=this,C=[0,b.length-1,0],O=[];for(;C.length;){const $=C.pop()||0,U=C.pop()||0,q=C.pop()||0;if(U-q<=A){for(let se=q;se<=U;se++){const ae=T[2*se],he=T[2*se+1];ae>=l&&ae<=m&&he>=u&&he<=x&&O.push(b[se])}continue}const K=q+U>>1,X=T[2*K],te=T[2*K+1];X>=l&&X<=m&&te>=u&&te<=x&&O.push(b[K]),($===0?l<=X:u<=te)&&(C.push(q),C.push(K-1),C.push(1-$)),($===0?m>=X:x>=te)&&(C.push(K+1),C.push(U),C.push(1-$))}return O}within(l,u,m){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:x,coords:b,nodeSize:T}=this,A=[0,x.length-1,0],C=[],O=m*m;for(;A.length;){const $=A.pop()||0,U=A.pop()||0,q=A.pop()||0;if(U-q<=T){for(let se=q;se<=U;se++)EJ(b[2*se],b[2*se+1],l,u)<=O&&C.push(x[se]);continue}const K=q+U>>1,X=b[2*K],te=b[2*K+1];EJ(X,te,l,u)<=O&&C.push(x[K]),($===0?l-m<=X:u-m<=te)&&(A.push(q),A.push(K-1),A.push(1-$)),($===0?l+m>=X:u+m>=te)&&(A.push(K+1),A.push(U),A.push(1-$))}return C}}function UB(h,l,u,m,x,b){if(x-m<=u)return;const T=m+x>>1;TJ(h,l,T,m,x,b),UB(h,l,u,m,T-1,1-b),UB(h,l,u,T+1,x,1-b)}function TJ(h,l,u,m,x,b){for(;x>m;){if(x-m>600){const O=x-m+1,$=u-m+1,U=Math.log(O),q=.5*Math.exp(2*U/3),K=.5*Math.sqrt(U*q*(O-q)/O)*($-O/2<0?-1:1);TJ(h,l,u,Math.max(m,Math.floor(u-$*q/O+K)),Math.min(x,Math.floor(u+(O-$)*q/O+K)),b)}const T=l[2*u+b];let A=m,C=x;for(e2(h,l,m,u),l[2*x+b]>T&&e2(h,l,m,x);AT;)C--}l[2*m+b]===T?e2(h,l,m,C):(C++,e2(h,l,C,x)),C<=u&&(m=C+1),u<=C&&(x=C-1)}}function e2(h,l,u,m){VB(h,u,m),VB(l,2*u,2*m),VB(l,2*u+1,2*m+1)}function VB(h,l,u){const m=h[l];h[l]=h[u],h[u]=m}function EJ(h,l,u,m){const x=h-u,b=l-m;return x*x+b*b}a.$=zg,a.A=class{constructor(h,l,u){this.target=h,this.parent=l,this.mapId=u,this.callbacks={},this.cancelCallbacks={},ht(["receive"],this),this.target.addEventListener("message",this.receive,!1),this.scheduler=new gIe}send(h,l,u,m,x=!1,b){const T=Math.round(1e18*Math.random()).toString(36).substring(0,10);u&&(u.metadata=b,this.callbacks[T]=u);const A=new Set;return this.target.postMessage({id:T,type:h,hasCallback:!!u,targetMapId:m,mustQueue:x,sourceMapId:this.mapId,data:jh(l,A)},A),{cancel:()=>{u&&delete this.callbacks[T],this.target.postMessage({id:T,type:"",targetMapId:m,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 m=this.cancelCallbacks[u];delete this.cancelCallbacks[u],m&&m.cancel()}else if(l.mustQueue||Ms(self)){const m=this.callbacks[u],x=this.scheduler.add(()=>this.processTask(u,l),m&&m.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(Of(l.error)):u(null,Of(l.data)))}else{const u=new Set,m=l.hasCallback?(b,T)=>{this.target.postMessage({id:h,type:"",sourceMapId:this.mapId,error:b?jh(b):null,data:jh(T,u)},u)}:()=>{},x=Of(l.data);if(this.parent[l.type])this.parent[l.type](l.sourceMapId,x,m);else if(this.parent.getWorkerSource){const b=l.type.split("."),{source:T,scope:A}=x;this.parent.getWorkerSource(l.sourceMapId,{type:b[0],source:T,scope:A,uid:0})[b[1]](x,m)}else m(new Error(`Could not find function ${l.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}},a.B=Pg,a.C=qu,a.D=gu,a.E=s0,a.F=cp,a.G=2,a.H=Oj,a.I=hc,a.J=VX,a.K=Z_,a.L=mI,a.M=c0,a.N=u0,a.O=xb,a.P=Ft,a.Q=yb,a.R=r0,a.S=TE,a.T=Gf,a.U=N0,a.V=EP,a.W=Cb,a.X=Df,a.Y=jE,a.Z=Rd,a._=rp,a.a=function(h){return Dn.API_CDN_URL_REGEX.test(h)},a.a$=oP,a.a0=Ba,a.a1=d0,a.a2=X_,a.a3=eE,a.a4=GE,a.a5=class extends EP{},a.a6=EE,a.a7=XC,a.a8=st,a.a9=function(h){const l=h.value;return l?X_(l)?CB(l,!0)?[]:[new EP(h.key,l,`invalid url "${l}"`)]:[new EP(h.key,l,`string expected, "${c0(l)}" found`)]:[]},a.aA=yX,a.aB=function(h){let l=1/0,u=1/0,m=-1/0,x=-1/0;for(const b of h)l=Math.min(l,b.x),u=Math.min(u,b.y),m=Math.max(m,b.x),x=Math.max(x,b.y);return{min:new Ft(l,u),max:new Ft(m,x)}},a.aC=fe,a.aD=D,a.aE=ar,a.aF=Me,a.aG=ql,a.aH=Lt,a.aI=gr,a.aJ=function(h,l){const u={};for(let m=0;m=0?l.slice(u+1):""}catch{return""}},a.aN=class{constructor(h){this.entries={},this.scheduler=h}request(h,l,u,m){const x=this.entries[h]=this.entries[h]||{callbacks:[]};if(x.result){const[b,T]=x.result;return this.scheduler?this.scheduler.add(()=>{m(b,T)},l):m(b,T),()=>{}}return x.callbacks.push(m),x.cancel||(x.cancel=u((b,T)=>{x.result=[b,T];for(const A of x.callbacks)this.scheduler?this.scheduler.add(()=>{A(b,T)},l):A(b,T);setTimeout(()=>delete this.entries[h],3e3)})),()=>{x.result||(x.callbacks=x.callbacks.filter(b=>b!==m),x.callbacks.length||(x.cancel(),delete this.entries[h]))}}},a.aO=function(h,l,u){const m=JSON.stringify(h.request);return h.data&&(this.deduped.entries[m]={result:[null,h.data]}),this.deduped.request(m,{type:"parseTile",renderSourceType:h.renderSourceType,zoom:h.tileZoom},x=>{const b=Cg(h.request,(T,A,C)=>{T?XT(T)?x(null,null):x(T):A&&x(null,{rawData:A,vectorTile:u?void 0:new ts(new oP(A)),responseHeaders:new Map(C.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){WT++,WT>z_&&(h.getActor().send("enforceCacheSizeLimit",$_),WT=0)},a.aR=Tl,a.aS=TQ,a.aT=PQ,a.aU=Qe,a.aV=SQ,a.aW=function(h,l){const u=document.createElement("video");u.muted=!0,u.onloadstart=function(){l(null,u)};for(let m=0;m{}}},a.aX=Pj,a.aY=iv,a.aZ=ht,a.a_=RP,a.aa=Nb,a.ab=ri,a.ac=Qt,a.ad=class{constructor(h){this.specification=h}possiblyEvaluate(h,l){return Ln(h.expression.evaluate(l))}interpolate(h,l,u){return{x:Qr(h.x,l.x,u),y:Qr(h.y,l.y,u),z:Qr(h.z,l.z,u),azimuthal:Qr(h.azimuthal,l.azimuthal,u),polar:Qr(h.polar,l.polar,u)}}},a.ae=as,a.af=sp,a.ag=Ar,a.ah=lr,a.ai=Le,a.aj=Oe,a.ak=Nh,a.al=gp,a.am=Qr,a.an=or,a.ao=Gu,a.ap=Xn,a.aq=Qn,a.ar=class{constructor(h){this.specification=h}possiblyEvaluate(h,l){return function([u,m]){const x=Ln([1,u,m]);return{x:x.x,y:x.y,z:x.z}}(h.expression.evaluate(l))}interpolate(h,l,u){return{x:Qr(h.x,l.x,u),y:Qr(h.y,l.y,u),z:Qr(h.z,l.z,u)}}},a.as=function(h,l,u=0,m=!0){const x=new Ft(u,u),b=h.sub(x),T=l.add(x),A=[b,new Ft(T.x,b.y),T,new Ft(b.x,T.y)];return m&&A.push(b.clone()),A},a.at=function(h,l){const u=[];for(let m=0;mthis.buckets[U].layers.some(q=>T.has(q.fqid))),C=Object.keys(this.buckets).some(U=>this.buckets[U].layers.some(q=>q.hasTransition&&q.hasTransition())),O=this._firstPrepareComplete&&b!==this._lastAvailableImagesCount;this._hasAppearances===null&&(this._hasAppearances=this.hasAppearances(l));const $=this._lastUpdatedBrightness!==m;this._lastAvailableImagesCount=b,this._firstPrepareComplete=!0,(this._lastUpdatedBrightness||m||this._hasAppearances||A||C||O)&&(!(this._hasAppearances||A||C||O)&&this._lastUpdatedBrightness&&m&&Math.abs(this._lastUpdatedBrightness-m)<.001||(this.updateBuckets(l,$,void 0,O||A||C,T,x),this._lastUpdatedBrightness=m))}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,m,x,b,T){if(!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData&&!this.latestFeatureIndex.is3DTile)return{};const A=this.evaluateQueryRenderedFeaturePadding(),C=function(O,$){const U=J([],[.5*O.width,.5*-O.height,1]);return B(U,U,[1,-1,0]),D(U,U,O.calculateProjMatrix($.toUnwrapped())),Float32Array.from(U)}(x,this.tileID);return this.latestFeatureIndex.query(h,{tilespaceGeometry:l,pixelPosMatrix:C,transform:m,availableImages:u,tileTransform:this.tileTransform,worldview:this.worldview,queryRadius:A,scope:T})}querySourceFeatures(h,l){const u=this.latestFeatureIndex;if(!u||!u.rawTileData)return;const m=u.loadVTLayers(),x=l?l.sourceLayer:"",b=m._geojsonTileLayer||m[x];if(!b)return;const T=Ib(l&&l.filter),{z:A,x:C,y:O}=this.tileID.canonical,$={z:A,x:C,y:O};for(let U=0;Uu)m=!1;else if(l)if(this.expirationTimeu.appearances&&u.appearances.length>0))return!0;return!1}updateBuckets(h,l,u,m,x,b){if(!this.latestFeatureIndex||!h.style)return;const T=b||h.style.listImages(),A=h.style.getBrightness(),C=x||new Set;for(const O in this.buckets){if(!h.style.hasLayer(O))continue;const $=this.buckets[O],U=$.layers[0],q=U.sourceLayer||"_geojsonTileLayer",K=h.style.getLayerSourceCache(U),X=$.layers.some(Ne=>C.has(Ne.fqid)),te=(m||X)&&$ instanceof Mh?h.style.getOwnLayer(O):void 0;let se=u&&u[q]||{};K&&!u&&(se=K._state.getState(q,void 0));const ae=this.imageAtlas?Object.fromEntries(this.imageAtlas.patternPositions):{},he=Object.keys(se).length>0&&!l;$.hasAppearances=$.layers.some(Ne=>Ne.appearances&&Ne.appearances.length>0);const ue=he?$.stateDependentLayers:$.layers;if(he&&$.stateDependentLayers.length!==0||l||X||m){const Ne=this.latestFeatureIndex.loadVTLayers()[q];if($.update(se,Ne,T,ae,ue,l,A,this.tileID.canonical),(m||X)&&!l&&$ instanceof Mh&&te&&te.type==="symbol"){const Ie=$;Ie.text&&Ie.text.uboBinder&&Ie.text.uboBinder.updateDynamicExpressions(te,Ne,this.tileID.canonical,T,se,A),Ie.icon&&Ie.icon.uboBinder&&Ie.icon.uboBinder.updateDynamicExpressions(te,Ne,this.tileID.canonical,T,se,A)}if($ instanceof Mh){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(he&&$.stateDependentLayers.length!==0||l||$.hasAppearances){const Ne={zoom:h.transform.zoom,pitch:h.transform.pitch,brightness:h.style.getBrightness()||0,worldview:h.worldview},Ie=$.updateAppearances(this.tileID.canonical,se,T,Ne,h.imageManager,he&&$.stateDependentLayers.length!==0);if(Ie&&Ie.hasUboChanges){const We=h.context;$ instanceof Mh&&$.text&&$.text.uboBinder&&$.text.uboBinder.upload(We),$ instanceof Mh&&$.icon&&$.icon.uboBinder&&$.icon.uboBinder.upload(We)}}($ instanceof aP||$ instanceof zI)&&h._terrain&&h._terrain.enabled&&K&&$.uploadPending()&&h._terrain._clearRenderCacheForTile(K.id,this.tileID);const be=h&&h.style&&h.style.getOwnLayer(O);be&&(this.queryPadding=Math.max(this.queryPadding,be.queryRadius($)||0))}}holdingForFade(){return this.symbolFadeHoldUntil!==void 0}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil=0;te--){const se=4*te,ae=cy[se+0],he=cy[se+1],ue=cy[se+2],be=cy[se+3],Ne=ae+ue>>1,Ie=he+be>>1,We=Ne+Ie-he,ze=Ie+ae-Ne,He=he*Hf+ae,Ue=be*Hf+ue,Ve=Ie*Hf+Ne,yt=Math.hypot((Wf[2*He+0]+Wf[2*Ue+0])/2-Wf[2*Ve+0],(Wf[2*He+1]+Wf[2*Ue+1])/2-Wf[2*Ve+1])>=16;uy[Ve]=uy[Ve]||(yt?1:0),te<1022&&(uy[Ve]=uy[Ve]||uy[(he+ze>>1)*Hf+(ae+We>>1)]||uy[(be+ze>>1)*Hf+(ue+We>>1)])}const $=new Eo,U=new bi;let q=0;function K(te,se){const ae=se*Hf+te;return AP[ae]===0&&($.emplaceBack(Wf[2*ae+0],Wf[2*ae+1],te*or/$d,se*or/$d),AP[ae]=++q),AP[ae]-1}function X(te,se,ae,he,ue,be){const Ne=te+ae>>1,Ie=se+he>>1;if(Math.abs(te-ue)+Math.abs(se-be)>1&&uy[Ie*Hf+Ne])X(ue,be,te,se,Ne,Ie),X(ae,he,ue,be,Ne,Ie);else{const We=K(te,se),ze=K(ae,he),He=K(ue,be);U.emplaceBack(We,ze,He)}}return X(0,0,$d,$d,$d,0),X($d,$d,0,0,0,$d),{vertices:$,indices:U}}(this.tileID.canonical,l);m=b.vertices,x=b.indices}else{m=new Eo,x=new bi;for(const{x:T,y:A}of u)m.emplaceBack(T,A,0,0);const b=Hb(m.int16.subarray(0,4*m.length),void 0,4);for(let T=0;T0&&(T=M(new Float64Array(16),l.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(h,m,l,x,T,b),this._makeGlobeTileDebugTextBuffer(h,m,l,x,T,b)}_globePoint(h,l,u,m,x,b,T){let A=pj(h,l,u);if(b){const C=1<.5?q=-1:U<-.5&&(q=1);let K=(h/or+u.x)/C+q,X=(l/or+u.y)/C;K=(K-O)*m._pixelsPerMercatorPixel+O,X=(X-$)*m._pixelsPerMercatorPixel+$;const te=[K*m.worldSize,X*m.worldSize,0];lr(te,te,b),A=pp(A,te,T)}return lr(A,A,x)}_makeGlobeTileDebugBorderBuffer(h,l,u,m,x,b){const T=new mc,A=new hp,C=new Od,O=(U,q,K,X,te)=>{const se=(K-U)/(te-1),ae=(X-q)/(te-1),he=T.length;for(let ue=0;ueO*U+q;for(let U=0;U1)return!1;const u=l.getSource().maxzoom,m=1<1)return l;const x=m.getSource().maxzoom,b=1<{const A=this.getAtTileOffset(h,x,b,T),C=m.upVector(h.canonical,x.x,x.y);return qe(C,C,A*m.upVectorScale(h.canonical,l,u).metersToTile),C}}getForTilePoints(h,l,u,m){if(this.isUsingMockSource())return!1;const x=iw.create(this,h,m);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,m=l.tileID,x=1<0&&(m+=(h[x]-0)*(h[x]-0)),l[x]<0&&(m+=(0-l[x])*(0-l[x]));return m},a.cL=function(h){return h*h*h*h*h},a.cM=ft,a.cN=45,a.cO=Vb,a.cP=function(h,l,u){const m=Math.sqrt(h*h+l*l+u*u),x=m>0?Math.acos(u/m)*Ci:0;let b=h!==0||l!==0?Math.atan2(-l,-h)*Ci+90:0;return b<0&&(b+=360),[m,b,x]},a.cQ=ke,a.cR=Ln,a.cS=Ot,a.cT=me,a.cU=us,a.cV=je,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=eX,a.cY=Q5,a.cZ=iX,a.c_=CB,a.ca=2,a.cb=7,a.cc=6,a.cd=wt,a.ce=Te,a.cf=Ae,a.cg=0,a.ch=1,a.ci=4,a.cj=5,a.ck=Gb,a.cl=pc,a.cm=rX,a.cn=Y0,a.co=IY,a.cp=function(h,l,u,m,x,b,T,A,C){if(C.name==="globe")return IY(h,l,new Y0(u,m,x),!1);const O=rv({z:u,x:m,y:x},C);return new us([(b+O.x/O.scale)*l,l*(O.y/O.scale),T],[(b+O.x2/O.scale)*l,l*(O.y2/O.scale),A])},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 du[l]},a.ct=Tt,a.cu=Jt,a.cv=6,a.cw=function(h){const l=P(new Float64Array(16));D(l,h.pixelMatrix,h.globeMatrix);const u=[0,$e,0],m=[0,Ke,0];return lr(u,u,l),lr(m,m,l),[u[0]>0&&u[0]<=h.width&&u[1]>0&&u[1]<=h.height&&!v5(h,new Qe(h.center.lat,90)),m[0]>0&&m[0]<=h.width&&m[1]>0&&m[1]<=h.height&&!v5(h,new Qe(h.center.lat,-90))]},a.cx=function(h,l){const{scale:u}=h.tileTransform,m=u*or/(h.tileSize*Math.pow(2,l.zoom-h.tileID.overscaledZ+h.tileID.canonical.z));return function(x,b,T){var A=b[1],C=b[2],O=b[3],$=T[0],U=T[1];return x[0]=b[0]*$,x[1]=A*$,x[2]=C*U,x[3]=O*U,x}(new Float32Array(4),l.inverseAdjustmentMatrix,[m,m])},a.cy=eP,a.cz=pe,a.d=function(h){return Dn.API_TILEJSON_REGEX.test(h)},a.d$=gke,a.d0=fi,a.d1=class{static calculate(h,l,u){const m=new Set,x=new Map,b=new Set,T=new Set;for(const C of Object.values(h))for(const[O,$]of Object.entries(C.floors)){b.add(O),$.isDefault&&T.add(O),$.conflicts&&x.set(O,$.conflicts);const U=O===l,q=$.connections&&l&&$.connections.has(l);(U||q)&&m.add(O)}const A=C=>{const O=x.get(C)||new Set;for(const $ of m)if((x.get($)||new Set).has(C)||O.has($))return!0;return!1};if(u)for(const C of u)b.has(C)&&(A(C)||m.add(C));for(const C of T)m.has(C)||A(C)||m.add(C);return m}},a.d2=dP,a.d3=yB,a.d4=es,a.d5=function(){return{API_URL:Dn.API_URL,DRACO_URL:Dn.DRACO_URL,MESHOPT_URL:Dn.MESHOPT_URL,MESHOPT_SIMD_URL:Dn.MESHOPT_SIMD_URL,BUILDING_GEN_URL:Dn.BUILDING_GEN_URL}},a.d6=dI,a.d7=GT,a.d8=kf,a.d9=dr,a.dA=PI,a.dB=mc,a.dC=bi,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=v,a.dF=function(h,l){var u=Math.sin(l),m=Math.cos(l);return h[0]=m,h[1]=u,h[2]=0,h[3]=-u,h[4]=m,h[5]=0,h[6]=0,h[7]=0,h[8]=1,h},a.dG=Sr,a.dH=RY,a.dI=Ds,a.dJ=oi,a.dK=kB,a.dL=function(h,l){const u=[0,0,0];return lr(u,u,gj(Uf(l.canonical))),lr(u,u,h),u},a.dM=h=>({u_matrix:new d(h),u_texsize:new bu(h),u_pixels_to_tile_units:new j(h),u_device_pixel_ratio:new fa(h),u_width_scale:new fa(h),u_floor_width_scale:new fa(h),u_image:new W0(h),u_units_to_pixels:new bu(h),u_tile_units_to_pixels:new fa(h),u_alpha_discard_threshold:new fa(h),u_trim_offset:new bu(h),u_trim_fade_range:new bu(h),u_trim_gradient_mix_range:new bu(h),u_trim_color:new Vb(h),u_zbias_factor:new fa(h),u_tile_to_meter:new fa(h),u_ground_shadow_factor:new K0(h),u_pattern_transition:new fa(h)}),a.dN=h=>({u_matrix:new d(h),u_pixels_to_tile_units:new j(h),u_device_pixel_ratio:new fa(h),u_width_scale:new fa(h),u_floor_width_scale:new fa(h),u_units_to_pixels:new bu(h),u_dash_image:new W0(h),u_gradient_image:new W0(h),u_image_height:new fa(h),u_texsize:new bu(h),u_tile_units_to_pixels:new fa(h),u_alpha_discard_threshold:new fa(h),u_trim_offset:new bu(h),u_trim_fade_range:new bu(h),u_trim_gradient_mix_range:new bu(h),u_trim_color:new Vb(h),u_zbias_factor:new fa(h),u_tile_to_meter:new fa(h),u_ground_shadow_factor:new K0(h)}),a.dO=h=>({u_camera_to_center_distance:new fa(h),u_extrude_scale:new j(h),u_device_pixel_ratio:new fa(h),u_matrix:new d(h),u_inv_rot_matrix:new d(h),u_merc_center:new bu(h),u_tile_id:new K0(h),u_zoom_transition:new fa(h),u_up_dir:new K0(h),u_emissive_strength:new fa(h)}),a.dP=nj,a.dQ=pCe,a.dR=class{constructor(h,l,u,m){this.context=h,this.format=m,this.size=u,this.texture=h.gl.createTexture();const[x,b,T]=this.size,{gl:A}=h;A.bindTexture(A.TEXTURE_3D,this.texture),h.pixelStoreUnpackFlipY.set(!1),h.pixelStoreUnpack.set(1),h.pixelStoreUnpackPremultiplyAlpha.set(!1),"data"in l&&l.data&&A.texImage3D(A.TEXTURE_3D,0,this.format,x,b,T,0,G5(this.format),H5(this.format),l.data)}bind(h,l){const{context:u}=this,{gl:m}=u;m.bindTexture(m.TEXTURE_3D,this.texture),h!==this.minFilter&&(m.texParameteri(m.TEXTURE_3D,m.TEXTURE_MAG_FILTER,h),m.texParameteri(m.TEXTURE_3D,m.TEXTURE_MIN_FILTER,h),this.minFilter=h),l!==this.wrapS&&(m.texParameteri(m.TEXTURE_3D,m.TEXTURE_WRAP_S,l),m.texParameteri(m.TEXTURE_3D,m.TEXTURE_WRAP_T,l),this.wrapS=l)}destroy(){const{gl:h}=this.context;h.deleteTexture(this.texture),this.texture=null}},a.dS=OY,a.dT=(h,l,u,m,x,b)=>{const T=h.transform,A=T.projection.name==="globe";let C;if(b.paint.get("circle-pitch-alignment")==="map")if(A){const $=RY(T.zoom,l.canonical)*T._pixelsPerMercatorPixel;C=Float32Array.from([$,0,0,$])}else C=T.calculatePixelsToTileUnitsMatrix(u);else C=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:Ul.devicePixelRatio,u_extrude_scale:C,u_inv_rot_matrix:wke,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(A){O.u_inv_rot_matrix=m,O.u_merc_center=x,O.u_tile_id=[l.canonical.x,l.canonical.y,1<{const $=h.transform,U=$.pitch<15?xX(.07,.7,fe((14-$.zoom)/5,0,1)):.07,q=u.paint.get("line-trim-color-use-theme").constantOr("default")==="none";return{u_matrix:_X(h,l,u,m),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:vX(l,$),u_units_to_pixels:[1/$.pixelsToGLUnits[0],1/$.pixelsToGLUnits[1]],u_alpha_discard_threshold:0,u_trim_offset:A,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(q?null:u.lut).toArray01(),u_zbias_factor:U,u_tile_to_meter:Ot(l.tileID.canonical,0),u_ground_shadow_factor:C,u_pattern_transition:O}},a.dX=(h,l,u,m,x,b,T,A,C,O)=>{const $=h.transform,U=$.calculatePixelsToTileUnitsMatrix(l),q=u.paint.get("line-trim-color-use-theme").constantOr("default")==="none",K=$.pitch<15?xX(.07,.7,fe((14-$.zoom)/5,0,1)):.07;return{u_matrix:_X(h,l,u,m),u_pixels_to_tile_units:U,u_device_pixel_ratio:b,u_width_scale:T,u_floor_width_scale:A,u_units_to_pixels:[1/$.pixelsToGLUnits[0],1/$.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:x,u_texsize:wX(u)&&l.lineAtlasTexture?l.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:vX(l,h.transform),u_alpha_discard_threshold:0,u_trim_offset:C,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(q?null:u.lut).toArray01(),u_zbias_factor:K,u_tile_to_meter:Ot(l.tileID.canonical,0),u_ground_shadow_factor:O}},a.dY=it,a.dZ=yj,a.d_=_t,a.da=function(h){const l=h.indexOf(D0);return l>=0?h.slice(0,l):h},a.db=function(h){return h.indexOf(D0)>=0},a.dc=function(h){const l=h.lastIndexOf(D0);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,m){return h.type==="custom"?new lIe(h,l):new fIe[h.type](h,l,u,m)},a.df=Rt,a.dg=Ib,a.dh=vI,a.di=class extends sv{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=zE,a.dk=function(h){return h({pluginStatus:rl,pluginURL:Pc}),zE.on("pluginStateChange",h),h},a.dl=m5,a.dm=class extends _u{constructor(h){super(h),this.current=g}set(h,l,u){if(this.fetchUniformLocation(h,l)){for(let m=0;m<9;m++)if(u[m]!==this.current[m]){this.current=u,this.gl.uniformMatrix3fv(this.location,!1,u);break}}}},a.dn=e0,a.dp=function(h,l,u){const m=gp(u.zoom),x=h.style.map._antialias,b=h.terrain&&h.terrain.exaggeration()>0;return m===0&&!x&&!b},a.dq=function(h){const l=h.pixelsPerMeter,u=l/lt(1,h.center.lat),m=P(new Float64Array(16));return B(m,m,[h.point.x,h.point.y,0]),V(m,m,[u,u,l]),Float32Array.from(m)},a.dr=RI,a.ds=function(h){const l=80.051129;h=fe(h,-80.051129,l)/l*90;const u=Math.pow(Math.abs(Math.sin(Xn(h))),3);return Math.round(u*(Ze.length-1))},a.dt=function(h,l,u,m){const x=l.getNorth(),b=l.getSouth(),T=l.getWest(),A=l.getEast(),C=1<0){const X=180/m;E(K,K,[X/O+1,0,0,0,X/$+1,0,-.5*X/U,.5*X/q,1])}return K[2]=C,K[5]=h.x,K[8]=h.y,K},a.du=gj,a.dv=Uf,a.dw=function(h,l,u){const m=P(new Float64Array(16)),x=(l/(1<0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[]}get updateTime(){return this._updateTime}getReplacementRegionsForTile(h,l=!1){const u=yZ(new Ft(0,0),new Ft(or,or),h),m=[];if(l&&!L5(u,this._globalClipBounds))return m;for(const x of this._activeRegions){if(x.hiddenByOverlap||!L5(u,x))continue;const b=sNe(x.min,x.max,h);m.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 m}setSources(h){this._setSources(h.map(l=>({getSourceId:()=>l.cache.id,getFootprints:()=>{const u=[];for(const m of l.cache.getVisibleCoordinates()){const x=l.cache.getTile(m).buckets[l.layer];x&&x.updateFootprints(m.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(),m=h.getClipMask(),x=h.getClipScope();for(const b of l){if(!b.footprint)continue;const T=yZ(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:m,clipScope:x})}this._sourceIds.push(h.getSourceId())}_computeReplacement(){this._activeRegions.sort((l,u)=>l.priority-u.priority||VI(l.min,u.min)||VI(l.max,u.max)||l.order-u.order||l.clipMask-u.clipMask||function(m,x){const b=(T,A)=>T+A;return m.length-x.length||m.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],m=this._prevRegions[l];h=u.priority!==m.priority||!gZ(u,m)||u.order!==m.order||u.clipMask!==m.clipMask||!Bo(u.clipScope,m.clipScope),this._activeRegions[l].hiddenByOverlap=m.hiddenByOverlap,++l}}if(h){++this._updateTime;for(const u of this._activeRegions)u.order!==Ej&&(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 m=this._activeRegions;if(u>=m.length)return u;const x=m[u].priority;for(;u1){let u=0,m=l(u);for(;u!==m;){let x=u;const b=u;for(;x!==m;){const T=this._activeRegions[x];T.hiddenByOverlap=!1;for(let A=0;A=0;l--)this._addSource(h[l]);this._computeReplacement()}},a.eH=Eo,a.eI=wP,a.eJ=hp,a.eK=Ej,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 mc,m=new bi,x=[],b=h+1+2,T=l[0]+1,A=l[0]+1+(1+l.length),C=(O,$,U)=>{let q=O===b-1?O-2:O===0?O:O-1;return q+=U?24575:0,[q,$]};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=NY,a.ed=y5,a.ee=xu,a.ef=W,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=up,a.ei=U0,a.ej=function(h,l,u,m,x){return fe((h-l)/(u-l)*(x-m)+m,m,x)},a.ek=ss,a.el=function(h,l){var u=l[0],m=l[1],x=l[2],b=l[3],T=l[4],A=l[5],C=l[6],O=l[7],$=l[8],U=$*T-A*O,q=-$*b+A*C,K=O*b-T*C,X=u*U+m*q+x*K;return X?(h[0]=U*(X=1/X),h[1]=(-$*m+x*O)*X,h[2]=(A*m-x*T)*X,h[3]=q*X,h[4]=($*u-x*C)*X,h[5]=(-A*u+x*b)*X,h[6]=K*X,h[7]=(-O*u+m*C)*X,h[8]=(T*u-m*b)*X,h):null},a.em=WC,a.en=2,a.eo=Gt,a.ep=It,a.eq=ee,a.er=function(h,l){var u=new p(3);ee(u,l);var m=1/u[0],x=1/u[1],b=1/u[2],T=l[0]*m,A=l[1]*x,C=l[2]*b,O=l[4]*m,$=l[5]*x,U=l[6]*b,q=l[8]*m,K=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]=(U-K)/se,h[1]=(q-C)/se,h[2]=(A-O)/se):T>$&&T>X?(se=2*Math.sqrt(1+T-$-X),h[3]=(U-K)/se,h[0]=.25*se,h[1]=(A+O)/se,h[2]=(q+C)/se):$>X?(se=2*Math.sqrt(1+$-T-X),h[3]=(q-C)/se,h[0]=(A+O)/se,h[1]=.25*se,h[2]=(U+K)/se):(se=2*Math.sqrt(1+X-T-$),h[3]=(A-O)/se,h[0]=(q+C)/se,h[1]=(U+K)/se,h[2]=.25*se),h},a.es=function(h,l){var u=2*Math.acos(l[3]),m=Math.sin(u/2);return m>f?(h[0]=l[0]/m,h[1]=l[1]/m,h[2]=l[2]/m):(h[0]=1,h[1]=0,h[2]=0),u},a.et=RB,a.eu=nP,a.ev=rP,a.ew=[1,1,1],a.ex=iw,a.ey=function(h,l,u,m){var x=l[0],b=l[1],T=l[2],A=l[3];return h[0]=x+m*(u[0]-x),h[1]=b+m*(u[1]-b),h[2]=T+m*(u[2]-T),h[3]=A+m*(u[3]-A),h},a.ez=Xb,a.f=cc,a.f0=MY,a.f1=function(h){const l=[0,0,0],u=P(new Float64Array(16));return D(u,h.pixelMatrix,h.globeMatrix),lr(l,l,u),new Ft(l[0],l[1])},a.f2=UE,a.f3=function(h,l,u=!1){if(rl===fc.deferred||rl===fc.loading||rl===fc.loaded)throw new Error("setRTLTextPlugin cannot be called multiple times.");Pc=Ul.resolveURL(h),rl=fc.deferred,Dd=l,$E(),u||hI()},a.f4=po,a.f5=To,a.f6=Aa,a.f7=function(h){const l=_C();if(!l)return;const u=l.delete(Hm);h&&u.then(()=>h()).catch(h)},a.f8=_r,a.f9=ny,a.fA=rn,a.fB=function(h){let l=0;if(new Uint32Array(h,0,1)[0]!==YZ){const u=new Uint32Array(h,0,7),[,,m,x,b,T]=u;l=u.byteLength+x+b+T+b,(m!==h.byteLength||l>=h.byteLength)&&$r("Invalid b3dm header information.")}return JZ(h,l)},a.fC=function(h,l){const u=Q5(h);for(const m of u){for(const x of m.meshes)MNe(x);m.lights&&(m.lightMeshIndex=m.meshes.length,m.meshes.push(DNe(m.lights,l)))}return u},a.fD=jP,a.fE=Ms,a.fF=kh,a.fG=fc,a.fH=function(h){U_(),Pd!=null&&Pd.then(l=>{l.keys().then(u=>{for(let m=0;m$r(x.message))}).catch(u=>$r(u.message))}).catch(l=>$r(l.message))},a.fa=2,a.fb=Eh,a.fc=rv,a.fd=cj,a.fe=BQ,a.ff=$Q,a.fg=mX,a.fh=yn,a.fi="hd_road_elevation",a.fj=Os,a.fk=Ut,a.fl=zI,a.fm=yp,a.fn=pB,a.fo=1,a.fp=Mh,a.fq=function(h,l,u,m,x,b,T,A=1,C,O,$,U){h.createArrays(),h.tilePixelRatio=or/(512*h.overscaling),h.compareText={},h.iconsNeedLinear=!1;const q=h.layers[0].layout,K=h.layers[0]._unevaluatedLayout._values,X={};X.scaleFactor=A,X.textSizeScaleRange=q.get("text-size-scale-range"),X.iconSizeScaleRange=q.get("icon-size-scale-range");const[te,se]=X.textSizeScaleRange,[ae,he]=X.iconSizeScaleRange;X.textScaleFactor=fe(X.scaleFactor,te,se),X.iconScaleFactor=fe(X.scaleFactor,ae,he);const ue=K["text-size"],be=K["icon-size"];if(h.textSizeData.kind==="composite"){const{minZoom:Ue,maxZoom:Ve}=h.textSizeData;X.compositeTextSizes=[ue.possiblyEvaluate(new as(Ue,{worldview:$}),b),ue.possiblyEvaluate(new as(Ve,{worldview:$}),b)]}if(h.iconSizeData.kind==="composite"){const{minZoom:Ue,maxZoom:Ve}=h.iconSizeData;X.compositeIconSizes=[be.possiblyEvaluate(new as(Ue,{worldview:$}),b,U),be.possiblyEvaluate(new as(Ve,{worldview:$}),b,U)]}X.layoutTextSize=ue.possiblyEvaluate(new as(T+1,{worldview:$}),b),X.layoutIconSize=be.possiblyEvaluate(new as(T+1,{worldview:$}),b,U),X.textMaxSize=ue.possiblyEvaluate(new as(18,{worldview:$}),b);const Ne=q.get("symbol-placement"),Ie=q.get("text-rotation-alignment")==="map"&&Ne!=="point",We=q.get("text-size");let ze=!1;const He=[];for(const Ue of h.features){const Ve=q.get("text-font").evaluate(Ue,{},b).join(","),yt=We.evaluate(Ue,{},b)*X.textScaleFactor,bt=X.layoutTextSize.evaluate(Ue,{},b)*X.textScaleFactor,At=X.layoutIconSize.evaluate(Ue,{},b,U)*X.iconScaleFactor,Pt={horizontal:{},vertical:void 0},kt=Ue.text;let zt,mt=[0,0];if(kt){const wn=kt.toString(),mi=q.get("text-letter-spacing").evaluate(Ue,{},b)*$a,os=q.get("text-line-height").evaluate(Ue,{},b)*$a,Kn=e5(wn)?mi:0,Rs=q.get("text-anchor").evaluate(Ue,{},b),ci=q.get("text-variable-anchor");if(!ci){const Si=q.get("text-radial-offset").evaluate(Ue,{},b);if(Si)mt=JX(Rs,[Si*$a,vB]);else{const Ao=q.get("text-offset").evaluate(Ue,{},b);mt=[Ao[0]*$a,Ao[1]*$a]}}let za=Ie?"center":q.get("text-justify").evaluate(Ue,{},b);const ui=Ne==="point",wi=ui?q.get("text-max-width").evaluate(Ue,{},b)*$a:1/0,Zi=Si=>{h.allowVerticalPlacement&&OE(wn)&&(Pt.vertical=lB(kt,l,u,x,Ve,wi,os,Rs,Si,Kn,mt,Bc.vertical,!0,bt,yt,C,X.textScaleFactor))};if(!Ie&&ci){const Si=za==="auto"?ci.map(Ua=>_B(Ua)):[za];let Ao=!1;for(let Ua=0;Ua=0||!OE(wn)){const Si=lB(kt,l,u,x,Ve,wi,os,Rs,za,Kn,mt,Bc.horizontal,!1,bt,yt,C,X.textScaleFactor);Si&&(Pt.horizontal[za]=Si)}Zi(ui?"left":za)}}let Nt,Mt,Vt,Yt,xr,sr,nr=!1;const Zt=q.get("icon-text-fit").evaluate(Ue,{},b);if(Ue.icon&&Ue.icon.hasPrimary()){const wn=$j(Ue.icon,h.iconSizeData,K["icon-size"],b,h.zoom,Ue,C,X.iconScaleFactor,$,U);Nt=wn.iconPrimary,Vt=wn.iconSecondary;const mi=Nt.toString();if(Mt=m.get(mi),Mt&&(xr=q.get("icon-offset").evaluate(Ue,{},b),sr=q.get("icon-anchor").evaluate(Ue,{},b),zt=cP(x.get(mi),Vt?x.get(Vt.toString()):void 0,xr,sr),nr=Mt.sdf,h.sdfIcons===void 0?h.sdfIcons=Mt.sdf:h.sdfIcons!==Mt.sdf&&$r("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(Mt.pixelRatio!==h.pixelRatio||q.get("icon-rotate").constantOr(1)!==0)&&(h.iconsNeedLinear=!0)),Vt){const os=Vt.toString();Yt=m.get(os)}}ze=ze||!(!Ue.icon||!Ue.icon.hasSecondary());const mr=gP(Pt.horizontal)||Pt.vertical;h.iconsInText||(h.iconsInText=!!mr&&mr.iconsInText);const kr=bt*X.textScaleFactor/$a,{defaultShapedIcon:zr,verticallyShapedIcon:Rr}=HCe(h,zt,q,Ue,b,Pt,kr,xr,Zt);Zt!=="none"&&zt&&(MX(zt)||DX(zt))&&(pP(0,Mt,Nt,zt,zr,Zt,O,m,x),pP(0,Yt,Vt,zt,zr,Zt,O,m,x),Rr&&(pP(0,Mt,Nt,zt,Rr,Zt,O,m,x),pP(0,Yt,Vt,zt,Rr,Zt,O,m,x))),zt=zr;const{iconBBox:cn,iconVerticalBBox:Un,textBBox:un,textVerticalBBox:Gn}=zCe(h,zt,Rr,q,Ue,b,At,xr,X,x,sr,Pt,bt,mt,U);He.push({feature:Ue,shapedTextOrientations:Pt,shapedText:mr,shapedIcon:zt,iconPrimary:Nt,iconSecondary:Vt,iconOffset:xr,iconAnchor:sr,verticallyShapedIcon:Rr,layoutTextSize:bt,layoutIconSize:At,textOffset:mt,isSDFIcon:nr,iconTextFit:Zt,iconCollisionBounds:cn,iconVerticalCollisionBounds:Un,textCollisionBounds:un,textVerticalCollisionBounds:Gn})}return{featureData:He,sizes:X,hasAnySecondaryIcon:ze,textAlongLine:Ie,symbolPlacement:Ne}},a.fr=gB,a.fs=mB,a.ft=GX,a.fu=HX,a.fv=function(h,l,u,m,x,b,T,A,C,O){h.iconAtlasPositions=O.iconPositions;const{featureData:$,hasAnySecondaryIcon:U,sizes:q,textAlongLine:K,symbolPlacement:X}=l;for(const te of $){const{shapedIcon:se,verticallyShapedIcon:ae,feature:he,shapedTextOrientations:ue,shapedText:be,layoutTextSize:Ne,textOffset:Ie,isSDFIcon:We,iconPrimary:ze,iconSecondary:He,iconTextFit:Ue,iconOffset:Ve,iconCollisionBounds:yt,iconVerticalCollisionBounds:bt,textCollisionBounds:At}=te;nQ(se,O.iconPositions,ze,He),nQ(ae,O.iconPositions,ze,He),GCe(ue,O.iconPositions),qCe(ze,He,O.iconPositions),(be||se)&&WCe(h,he,ue,se,ae,C,q,Ne,0,Ie,We,m,x,T,A,U,Ue,Ve,K,X,yt,bt,At)}u&&h.generateCollisionDebugBuffers(b,h.collisionBoxArray,q.textScaleFactor)},a.fw=aP,a.fx=ts,a.fy=function(h){return h<=1?1:Math.pow(2,Math.floor(Math.log2(h)))},a.fz=PP,a.g=Dn,a.h=function(h,l){return Ng(Object.assign(h,{method:"GET"}),l)},a.i=function(h){return Dn.API_STYLE_REGEX.test(h)&&!uc(h)},a.j=function(h){return btoa(encodeURIComponent(h).replace(/%([0-9A-F]{2})/g,(l,u)=>String.fromCharCode(+("0x"+u))))},a.k=V_,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 Ng(Object.assign(h,{type:"json"}),l)},a.n=Ig,a.o=Ul,a.p=function(h,l){return Ng(Object.assign(h,{method:"POST"}),l)},a.q=Vo,a.r=dt,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=$r,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[m]of this.textures.entries()){const x=this.textureAccessTimes.get(m)||0;xthis._layers[dr.id]),dt=rt[0];if(dt.visibility==="none")continue;const it=dt.source||"";let ht=this.familiesBySource[it];ht||(ht=this.familiesBySource[it]=Object.create(null));const Ut=dt.sourceLayer||"_geojsonTileLayer";let Rt=ht[Ut];Rt||(Rt=ht[Ut]=[]),Rt.push(rt)}}}const k=1*f.fa;class R{constructor(de){const fe={},Oe=[];for(const dt in de){const it=de[dt],ht=fe[dt]={};for(const Ut in it.glyphs){const Rt=it.glyphs[+Ut];if(!Rt||Rt.bitmap.width===0||Rt.bitmap.height===0)continue;const dr=Rt.metrics.localGlyph?k:1,Br={x:0,y:0,w:Rt.bitmap.width+2*dr,h:Rt.bitmap.height+2*dr};Oe.push(Br),ht[Ut]=Br}}const{w:Ye,h:et}=f.J(Oe),rt=new f.f9({width:Ye||1,height:et||1});for(const dt in de){const it=de[dt];for(const ht in it.glyphs){const Ut=it.glyphs[+ht];if(!Ut||Ut.bitmap.width===0||Ut.bitmap.height===0)continue;const Rt=fe[dt][ht],dr=Ut.metrics.localGlyph?k:1;f.f9.copy(Ut.bitmap,rt,{x:0,y:0},{x:Rt.x+dr,y:Rt.y+dr},Ut.bitmap)}}this.image=rt,this.positions=fe}}function P(ut,de,fe){ut[de]?fe&&(ut[de].center=fe):ut[de]={floorIds:new Set,center:fe||[0,0],floors:{}}}function M(ut,de,fe,Oe){for(const Ye of de)P(ut,Ye),ut[Ye].floors[fe]=Oe,ut[Ye].floorIds.add(fe)}function D(ut){return{id:ut.properties.id.toString(),center:[ut.properties.center_lon||0,ut.properties.center_lat||0]}}function B(ut,de){const fe=ut.properties.id.toString(),Oe=!!ut.properties.is_default&&ut.properties.is_default,Ye=ut.properties.connected_floor_ids?new Set(ut.properties.connected_floor_ids.toString().split(";")):new Set,et=ut.properties.conflicted_floor_ids?new Set(ut.properties.conflicted_floor_ids.toString().split(";")):new Set,rt=ut.properties.structure_ids?new Set(ut.properties.structure_ids.toString().split(";")):new Set,dt=ut.properties.name.toString(),it=ut.properties.z_index,ht=function(Ut,Rt){const dr=Ut.loadGeometry();if(!dr||dr.length===0)return;const Br=dr.map(Gr=>Gr.map($r=>f.fb($r,Rt,Ut.extent)));return Br.length===0?void 0:{type:"Polygon",coordinates:[Br[0]]}}(ut,de);return{id:fe,isDefault:Oe,connections:Ye,conflicts:et,buildings:rt,name:dt,zIndex:it,geometry:ht}}function V(ut,de){return de.every(fe=>ut.properties&&ut.properties[fe]!=null)}function G(ut){return V(ut,["type","id","name"])&&ut.properties.type==="structure"}function W(ut){return V(ut,["type","id","name","z_index"])&&ut.properties.type==="floor"}f.f8(R,"GlyphAtlas");class Y{constructor(de){this.tileID=new f.aR(de.tileID.overscaledZ,de.tileID.wrap,de.tileID.canonical.z,de.tileID.canonical.x,de.tileID.canonical.y),this.tileZoom=de.tileZoom,this.uid=de.uid,this.zoom=de.zoom,this.lut=de.lut,this.canonical=de.tileID.canonical,this.pixelRatio=de.pixelRatio,this.tileSize=de.tileSize,this.source=de.source,this.scope=de.scope,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=de.showCollisionBoxes,this.collectResourceTiming=!!de.request&&de.request.collectResourceTiming,this.promoteId=de.promoteId,this.renderSourceType=de.renderSourceType,this.tileTransform=f.fc(de.tileID.canonical,de.projection),this.projection=de.projection,this.worldview=de.worldview,this.localizableLayerIds=de.localizableLayerIds,this.brightness=de.brightness,this.extraShadowCaster=!!de.extraShadowCaster,this.tessellationStep=de.tessellationStep,this.scaleFactor=de.scaleFactor,this.worldview=de.worldview,this.indoor=de.indoor}parse(de,fe,Oe,Ye,et,rt){this.status="parsing",this.data=de,this.collisionBoxArray=new f.fd;const dt=new f.fe(Object.keys(de.layers).sort()),it=new f.ff(this.tileID,this.promoteId);it.bucketLayerIDs=[];const ht={},Ut=new f.fg(256,256),Rt={featureIndex:it,iconDependencies:new Map,patternDependencies:new Map,glyphDependencies:{},lineAtlas:Ut,availableImages:Oe,brightness:this.brightness,scaleFactor:this.scaleFactor,elevationFeatures:void 0,activeFloors:void 0};this.indoor&&(Rt.activeFloors=function($r,on,Nn,Ln){const Ms=on.indoorState.activeFloorsVisible;if(!on.sourceLayers)return Ms?on.indoorState.activeFloors:void 0;const Fi=function(bs,ai){if(!bs)return f.w("No source layers defined in indoor specification"),ai;if(bs.size===0)return ai;const da=bs.difference(ai);for(const Ds of da)f.w(`Missing source layer required in indoor specification: ${Ds}`);return ai.intersection(ai)}(on.sourceLayers,new Set(Object.keys($r.layers))),Ii=on.indoorState,yi=function(bs,ai,da,Ds,oi){const xi={};for(const Dn of ai){const Aa=bs.layers[Dn];if(Aa)for(let To=0;To=Ds.maxzoom||Ds.visibility==="none")continue;J(da,this.zoom,Rt.brightness,Oe,this.worldview,Rt.activeFloors);const oi=ht[Ds.id]=Ds.createBucket({index:it.bucketLayerIDs.length,layers:da,zoom:this.zoom,lut:this.lut,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:Ii,sourceID:this.source,projection:this.projection.spec,tessellationStep:this.tessellationStep,styleDefinedModelURLs:Ye,worldview:this.worldview,localizable:bs,availableImages:Oe,maxUniformBufferBindings:this.maxUniformBufferBindings,maxUniformBlockSizeDwords:this.maxUniformBlockSizeDwords,disableSymbolUBO:this.disableSymbolUBO});it.bucketLayerIDs.push(da.map(Dn=>f.F(Dn.id,Dn.scope)));let xi=oi.prepare?oi.prepare():null;xi!=null?(xi=xi.then(()=>oi.populate(yi,Rt,this.tileID.canonical,this.tileTransform)),dr.push(xi)):oi.populate(yi,Rt,this.tileID.canonical,this.tileTransform)}}const Gr=()=>{Ut.trim();const $r=!(!Rt.elevationFeatures||!Rt.elevationFeatures.some(Ds=>Ds.heightRange.min<0));let on,Nn,Ln,Ms,Fi,Ii,yi;const bs={type:"maybePrepare",renderSourceType:this.renderSourceType,zoom:this.zoom},ai=()=>{if(on)return this.status="done",rt(on);if(this.extraShadowCaster)this.status="done",rt(null,{buckets:Object.values(ht).filter(Ds=>!Ds.isEmpty()),featureIndex:it,collisionBoxArray:null,hasTunnelGeometry:$r,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:Rt.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(Nn&&Ln&&Ms&&yi){const oi=new R(Nn),xi=new Map;for(const[To,po]of Ln.entries()){const{imagePosition:cc}=f.fn(To,po,f.fo);xi.set(To,cc)}const Dn={};for(const To in ht){const po=ht[To];po instanceof f.fp&&(J(po.layers,this.zoom,Rt.brightness,Oe,this.worldview,Rt.activeFloors),Dn[To]=f.fq(po,Nn,oi.positions,Ln,xi,this.tileID.canonical,this.tileZoom,this.scaleFactor,this.pixelRatio,Fi,this.worldview,Oe))}const Aa={iconsPending:!0,patternsPending:!0};this.rasterizeIfNeeded(et,Ln,Fi,()=>{Aa.iconsPending=!1,da(Dn,oi,Aa,void 0,yi)}),this.rasterizeIfNeeded(et,Ms,Ii,()=>{Aa.patternsPending=!1,da(Dn,oi,Aa,void 0,yi)})}},da=(Ds,oi,xi,Dn,Aa)=>{if(xi.iconsPending||xi.patternsPending)return;const To=Ln.size>0||Ms.size>0,po=Object.keys(Ds).length>0;if(!To&&!po)return this.status="done",void rt(null,{buckets:Object.values(ht).filter(uc=>!uc.isEmpty()),featureIndex:it,collisionBoxArray:this.collisionBoxArray,hasTunnelGeometry:$r,glyphAtlasImage:oi.image,lineAtlas:Ut,imageAtlas:null,brightness:Rt.brightness});const cc=(uc,Nd)=>{for(const wl in ht){const dc=ht[wl];if(wl in Ds)f.fv(dc,Ds[wl],this.showCollisionBoxes,Oe,this.tileID.canonical,this.tileZoom,this.projection,this.brightness,Ln,Nd);else if(dc.hasPattern&&(dc instanceof f.fw||dc instanceof f.fl||dc instanceof f.e0)){J(dc.layers,this.zoom,Rt.brightness,Oe,this.worldview,Rt.activeFloors);const Cd=Object.fromEntries(Nd.patternPositions);dc.addFeatures(Rt,this.tileID.canonical,Cd,Oe,this.tileTransform,this.brightness)}}this.status="done",rt(null,{buckets:Object.values(ht).filter(wl=>!wl.isEmpty()),featureIndex:it,collisionBoxArray:this.collisionBoxArray,hasTunnelGeometry:$r,glyphAtlasImage:oi.image,lineAtlas:Ut,imageAtlas:uc,brightness:Rt.brightness})};if(To){const uc=new Map,Nd=f.fr(Ln,uc),wl=f.fr(Ms,uc),dc=new f.fs(Nd,wl,Aa,this.lut,uc);et.send("checkAtlasCache",{descriptor:dc,scope:this.scope},(Cd,Nc)=>{let Id,hu;if(Cd&&f.w(`[Worker] Error checking atlas cache: ${Cd.message}`),Nc)Id=new f.ft(Nc.sourceHash),hu=Nc;else{const Ul=new f.fu(Ln,Ms,this.lut,Aa);Id=Ul,hu=Ul}cc(Id,hu)})}else cc(null,{iconPositions:new Map,patternPositions:new Map})};if(!this.extraShadowCaster){const Ds=f.fk(Rt.glyphDependencies,Dn=>Object.keys(Dn).map(Number));Object.keys(Ds).length?et.send("getGlyphs",{uid:this.uid,stacks:Ds},(Dn,Aa)=>{on||(on=Dn,Nn=Aa,ai())},void 0,!1,bs):Nn={},yi=new Map;const oi=Array.from(Rt.iconDependencies.keys()).map(Dn=>f.I.parse(Dn));oi.length?et.send("getImages",{images:oi,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},(Dn,Aa)=>{if(!on){on=Dn,Ln=new Map,Fi=this.updateImageMapAndGetImageTaskQueue(Ln,Aa.images,Rt.iconDependencies);for(const[To,po]of Aa.versions.entries())yi.set(To,po);ai()}},void 0,!1,bs):(Ln=new Map,Fi=new Map);const xi=Array.from(Rt.patternDependencies.keys()).map(Dn=>f.I.parse(Dn));xi.length?et.send("getImages",{images:xi,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},(Dn,Aa)=>{if(!on){on=Dn,Ms=new Map,Ii=this.updateImageMapAndGetImageTaskQueue(Ms,Aa.images,Rt.patternDependencies);for(const[To,po]of Aa.versions.entries())yi.set(To,po);ai()}},void 0,!1,bs):(Ms=new Map,Ii=new Map)}if(Rt.elevationFeatures&&Rt.elevationFeatures.length>0){const Ds=[];for(const xi of Object.values(ht))if(xi instanceof f.fl){const Dn=xi.getUnevaluatedPortalGraph();Dn&&Ds.push(Dn)}const oi=f.fm.evaluate(Ds);for(const xi of Object.values(ht))if(xi instanceof f.fl){const Dn=de.layers[dt.decode(xi.sourceLayerIndex)];xi.setEvaluatedPortalGraph(oi,Dn,this.tileID.canonical,Rt.availableImages,Rt.brightness)}}ai()};dr.length>0?Promise.allSettled(dr).then(Gr).catch(rt):Gr()}updateParameters(de){this.scaleFactor=de.scaleFactor,this.showCollisionBoxes=de.showCollisionBoxes,this.projection=de.projection,this.brightness=de.brightness,this.tileTransform=f.fc(de.tileID.canonical,de.projection),this.extraShadowCaster=de.extraShadowCaster,this.lut=de.lut,this.worldview=de.worldview,this.indoor=de.indoor}rasterizeIfNeeded(de,fe,Oe,Ye){Array.from(fe.values()).some(et=>et.usvg)?this.rasterize(de,fe,Oe,Ye):Ye()}updateImageMapAndGetImageTaskQueue(de,fe,Oe){const Ye=new Map;for(const et of fe.keys()){const rt=Oe.get(et)||[];for(const dt of rt){const it=dt.toString(),ht=fe.get(dt.id.toString());ht.usvg?Ye.has(it)||(Ye.set(it,dt),de.set(it,Object.assign({},ht))):de.set(it,ht)}}return Ye}rasterize(de,fe,Oe,Ye){this.rasterizeTask=de.send("rasterizeImages",{scope:this.scope,tasks:Oe},(et,rt)=>{if(!et)for(const[dt,it]of rt.entries()){const ht=Object.assign(fe.get(dt),{data:it});fe.set(dt,ht)}Ye()})}cancelRasterize(){this.rasterizeTask&&this.rasterizeTask.cancel()}}function J(ut,de,fe,Oe,Ye,et){const rt=new f.ae(de,{brightness:fe,worldview:Ye,activeFloors:et});for(const dt of ut)dt.recalculate(rt,Oe)}class Q extends f.E{constructor({actor:de,layerIndex:fe,availableImages:Oe,availableModels:Ye,isSpriteLoaded:et,tileProvider:rt,brightness:dt,maxUniformBufferBindings:it,maxUniformBlockSizeDwords:ht,disableSymbolUBO:Ut}){super(),this.actor=de,this.layerIndex=fe,this.availableImages=Oe,this.availableModels=Ye,this.loadVectorData=f.aO,this.tileProvider=rt,this.loading={},this.loaded={},this.deduped=new f.aN(de.scheduler),this.isSpriteLoaded=et,this.scheduler=de.scheduler,this.brightness=dt,this.maxUniformBufferBindings=it,this.maxUniformBlockSizeDwords=ht,this.disableSymbolUBO=Ut}loadTileData(de,fe){if(!this.tileProvider)return this.loadVectorData(de,fe);const Oe=new AbortController,{z:Ye,x:et,y:rt}=de.tileID.canonical;return this.tileProvider.loadTile({z:Ye,x:et,y:rt},{request:de.request,signal:Oe.signal}).then(dt=>{if(Oe.signal.aborted)return;if(dt==null){const ht=new Error("Tile not found");return ht.status=404,fe(ht)}if(dt.data===null)return fe(null,null);const it=new Map;dt.expires&&it.set("expires",dt.expires),dt.cacheControl&&it.set("cache-control",dt.cacheControl),fe(null,{rawData:dt.data,responseHeaders:it})}).catch(dt=>{Oe.signal.aborted||fe(dt instanceof Error?dt:new Error(String(dt)))}),()=>Oe.abort()}loadTile(de,fe){const Oe=de.uid,Ye=de&&de.request,et=Ye&&Ye.collectResourceTiming,rt=this.loading[Oe]=new Y(de);rt.maxUniformBufferBindings=this.maxUniformBufferBindings,rt.maxUniformBlockSizeDwords=this.maxUniformBlockSizeDwords,rt.disableSymbolUBO=this.disableSymbolUBO,rt.abort=this.loadTileData(de,(dt,it)=>{const ht=!this.loading[Oe];if(delete this.loading[Oe],rt.cancelRasterize(),ht||dt||!it)return rt.status="done",ht||(this.loaded[Oe]=rt),fe(dt);const Ut=it.rawData,Rt={},dr=f.aP(it.responseHeaders);dr&&dr.expires&&(Rt.expires=dr.expires),dr&&dr.cacheControl&&(Rt.cacheControl=dr.cacheControl),rt.vectorTile=it.vectorTile||new f.fx(new f.a$(Ut));const Br=()=>{rt.parse(rt.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,(Gr,$r)=>{if(Gr||!$r)return fe(Gr);const on={};if(et){const Nn=p(Ye);Nn.length>0&&(on.resourceTiming=JSON.parse(JSON.stringify(Nn)))}fe(null,Object.assign({rawTileData:Ut.slice(0),responseHeaders:it.responseHeaders},$r,Rt,on))})};this.isSpriteLoaded?Br():this.once("isSpriteLoaded",()=>{this.scheduler?this.scheduler.add(Br,{type:"parseTile",renderSourceType:de.renderSourceType,zoom:de.tileZoom}):Br()}),this.loaded=this.loaded||{},this.loaded[Oe]=rt})}reloadTile(de,fe){const Oe=this.loaded,Ye=de.uid;if(Oe&&Oe[Ye]){const et=Oe[Ye];et.updateParameters(de);const rt=(dt,it)=>{const ht=et.reloadCallback;ht&&(delete et.reloadCallback,et.parse(et.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,ht)),fe(dt,it)};et.status==="parsing"?et.reloadCallback=rt:et.status==="done"&&(et.vectorTile?et.parse(et.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,rt):rt())}else fe(null,void 0)}abortTile(de,fe){const Oe=de.uid,Ye=this.loading[Oe];Ye&&(Ye.abort&&Ye.abort(),delete this.loading[Oe]),fe()}removeTile(de,fe){const Oe=this.loaded,Ye=de.uid;Oe&&Oe[Ye]&&delete Oe[Ye],fe()}}class ee{constructor(de){this.loading={}}loadTile(de,fe){const Oe=de.uid,{cancel:Ye}=f.b1(de.request,(et,rt,dt)=>{const it=!this.loading[Oe];if(delete this.loading[Oe],it||et||!rt)return fe(et);this.decodeTile(Oe,rt,de.encoding).then(ht=>{const{expires:Ut,cacheControl:Rt}=f.aP(dt);fe(null,Object.assign(ht,{expires:Ut,cacheControl:Rt}))}).catch(ht=>fe(ht))});this.loading[Oe]={cancel:Ye}}async decodeTile(de,fe,Oe){const Ye=await createImageBitmap(new Blob([new Uint8Array(fe)],{type:"image/png"})),et=1-(Ye.width-f.fy(Ye.width))/2,rt=et<1,dt=this.getImageData(Ye,et);return Ye.close(),{dem:new f.fz(de,dt,Oe,rt),borderReady:rt}}reloadTile(de,fe){fe(null,null)}abortTile(de,fe){const Oe=de.uid,Ye=this.loading[Oe];Ye&&(Ye.cancel(),delete this.loading[Oe]),fe()}removeTile(de,fe){fe()}getImageData(de,fe){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(de.width,de.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d",{willReadFrequently:!0})),this.offscreenCanvas.width=de.width,this.offscreenCanvas.height=de.height,this.offscreenCanvasContext.drawImage(de,0,0,de.width,de.height);const Oe=this.offscreenCanvasContext.getImageData(-fe,-fe,de.width+2*fe,de.height+2*fe);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),Oe}}f.a_.setPbf(f.a$);class le{constructor(de){this._mrt=new f.a_(de.partial?30:1/0),this._isHeaderLoaded=!1,this.uid=de.uid,this.tileID=de.tileID,this.source=de.source}parse(de,fe){const Oe=this._mrt;this.status="parsing",this._entireBuffer=de;try{Oe.parseHeader(de),this._isHeaderLoaded=!0;const Ye=[];for(const et in Oe.layers){const rt=Oe.getLayer(et),dt=rt.getDataRange(rt.getBandList()),it=Oe.createDecodingTask(dt),ht=de.slice(dt.firstByte,dt.lastByte+1),Ut=f.a_.performDecoding(ht,it).then(Rt=>it.complete(null,Rt)).catch(Rt=>it.complete(Rt,null));Ye.push(Ut)}Promise.allSettled(Ye).then(()=>fe(null,Oe)).catch(et=>fe(et))}catch(Ye){fe(Ye)}}}class pe{constructor({actor:de}){this.actor=de,this.loading={},this.loaded={}}loadTile(de,fe){const Oe=de.uid,Ye=de.request,et=this.loading[Oe]=new le(de),{cancel:rt}=f.b1(Ye,(dt,it,ht)=>{const Ut=!this.loading[Oe];if(delete this.loading[Oe],Ut||dt||!it)return et.status="done",Ut||(this.loaded[Oe]=et),fe(dt);et.parse(it,(Rt,dr)=>{if(Rt||!dr)return fe(Rt);fe(null,dr,ht)}),this.loaded[Oe]=et});et.abort=rt}reloadTile(de,fe){fe(null,void 0)}abortTile(de,fe){const Oe=de.uid,Ye=this.loading[Oe];Ye&&(Ye.abort&&Ye.abort(),delete this.loading[Oe]),fe()}removeTile(de,fe){const Oe=de.uid;this.loaded[Oe]&&delete this.loaded[Oe],fe()}decodeRasterArray(de,fe){f.a_.performDecoding(de.buffer,de.task).then(Oe=>fe(null,Oe)).catch(Oe=>fe(Oe))}}const Te=f.fA.prototype.toGeoJSON;class Ae{constructor(de){this._feature=de,this.extent=f.an,this.type=de.type,this.properties=de.tags,"id"in de&&!isNaN(de.id)&&(this.id=parseInt(de.id,10))}loadGeometry(){if(this._feature.type===1){const de=[];for(const fe of this._feature.geometry)de.push([new f.P(fe[0],fe[1])]);return de}{const de=[];for(const fe of this._feature.geometry){const Oe=[];for(const Ye of fe)Oe.push(new f.P(Ye[0],Ye[1]));de.push(Oe)}return de}}toGeoJSON(de,fe,Oe){return Te.call(this,de,fe,Oe)}}class Le{constructor(de,fe){this.name=de,this.extent=f.an,this.length=fe.length,this._jsonFeatures=fe}feature(de){return new Ae(this._jsonFeatures[de])}}class ke{constructor(de){this.layers={},this.extent=f.an;for(const fe of Object.keys(de))this.layers[fe]=new Le(fe,de[fe])}}const we=64/4096;class me{constructor(){this.features=new Map}clear(){this.features.clear()}load(de=[],fe){for(const Oe of de){const Ye=Oe.id;if(Ye==null)continue;let et=this.features.get(Ye);et&&this.updateCache(et,fe),Oe.geometry?(et=_e(Oe),this.updateCache(et,fe),this.features.set(Ye,et)):this.features.delete(Ye),this.updateCache(et,fe)}}updateCache(de,fe){for(const{canonical:Oe,uid:Ye}of Object.values(fe)){const{z:et,x:rt,y:dt}=Oe;je(de,Math.pow(2,et),rt,dt)&&delete fe[Ye]}}getTile(de,fe,Oe){const Ye=Math.pow(2,de),et=[];for(const rt of this.features.values())je(rt,Ye,fe,Oe)&&et.push(nt(rt,Ye,fe,Oe));return{features:et}}getFeatures(){return[...this.features.values()]}}function je({minX:ut,minY:de,maxX:fe,maxY:Oe},Ye,et,rt){return ut<(et+1+we)/Ye&&de<(rt+1+we)/Ye&&fe>(et-we)/Ye&&Oe>(rt-we)/Ye}function _e(ut){const{id:de,geometry:fe,properties:Oe}=ut;if(!fe)return;if(fe.type==="GeometryCollection")throw new Error("GeometryCollection not supported in dynamic mode.");const{type:Ye,coordinates:et}=fe,rt={id:de,type:1,geometry:[],tags:Oe,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},dt=rt.geometry;if(Ye==="Point")Ee(et,dt,rt);else if(Ye==="MultiPoint")for(const it of et)Ee(it,dt,rt);else if(Ye==="LineString")rt.type=2,ve(et,dt,rt);else if(Ye==="MultiLineString")rt.type=2,qe(et,dt,rt);else if(Ye==="Polygon")rt.type=3,qe(et,dt,rt,!0);else{if(Ye!=="MultiPolygon")throw new Error("Input data is not a valid GeoJSON object.");rt.type=3;for(const it of et)qe(it,dt,rt,!0)}return rt}function Ee([ut,de],fe,Oe){const Ye=f.aH(ut);let et=f.aL(de);et=et<0?0:et>1?1:et,fe.push(Ye,et),Oe.minX=Math.min(Oe.minX,Ye),Oe.minY=Math.min(Oe.minY,et),Oe.maxX=Math.max(Oe.maxX,Ye),Oe.maxY=Math.max(Oe.maxY,et)}function ve(ut,de,fe,Oe=!1,Ye=!1){const et=[];for(const rt of ut)Ee(rt,et,fe);de.push(et),Oe&&function(rt,dt){let it=0;for(let ht=0,Ut=rt.length,Rt=Ut-2;ht0===dt)for(let ht=0,Ut=rt.length;ht=rt&&Rt>=rt||(ht>=rt?(Ut+=Math.round(Gr*((rt-ht)/Br)),ht=rt):Rt>=rt&&(dr=Ut+Math.round(Gr*((rt-ht)/Br)),Rt=rt),Ut>=rt&&dr>=rt||(Ut>=rt?(ht+=Math.round(Br*((rt-Ut)/Gr)),Ut=rt):dr>=rt&&(Rt=ht+Math.round(Br*((rt-Ut)/Gr)),dr=rt),dt&&ht===dt[dt.length-1][0]&&Ut===dt[dt.length-1][1]||(dt=[[ht,Ut]],Ye.push(dt)),dt.push([Rt,dr])))))}}function jt(ut,de,fe,Oe,Ye){const et=(fe-we)/de,rt=(Oe-we)/de,dt=(fe+1+we)/de,it=(Oe+1+we)/de;function ht(dr,Br){let Gr=0;return drdt&&(Gr|=2),Brit&&(Gr|=8),Gr}let Ut=[];for(let dr=1;dr<=8;dr*=2){let Br=ut[ut.length-2],Gr=ut[ut.length-1],$r=!(ht(Br,Gr)&dr);for(let on=0;on>31}function wt(ut,de){const{geometry:fe,type:Oe}=ut;let Ye=0,et=0;if(Oe===1){de.writeVarint(Ct(1,fe.length));for(const rt of fe){const dt=rt[0]-Ye,it=rt[1]-et;de.writeVarint(tr(dt)),de.writeVarint(tr(it)),Ye+=dt,et+=it}}else for(const rt of fe){if(rt.length===0)continue;de.writeVarint(Ct(1,1));const dt=rt.length-(Oe===3?1:0);for(let it=0;itut},sn=Math.fround||(cr=new Float32Array(1),ut=>(cr[0]=+ut,cr[0]));var cr;class yr{constructor(de){this.options=Object.assign(Object.create(Sr),de),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(de){const{log:fe,minZoom:Oe,maxZoom:Ye}=this.options;fe&&console.time("total time");const et=`prepare ${de.length} points`;fe&&console.time(et),this.points=de;const rt=[];for(let it=0;it=Oe;it--){const ht=+Date.now();dt=this.trees[it]=this._createTree(this._cluster(dt,it)),fe&&console.log("z%d: %d clusters in %dms",it,dt.numItems,+Date.now()-ht)}return fe&&console.timeEnd("total time"),this}getClusters(de,fe){let Oe=((de[0]+180)%360+360)%360-180;const Ye=Math.max(-90,Math.min(90,de[1]));let et=de[2]===180?180:((de[2]+180)%360+360)%360-180;const rt=Math.max(-90,Math.min(90,de[3]));if(de[2]-de[0]>=360)Oe=-180,et=180;else if(Oe>et){const Rt=this.getClusters([Oe,Ye,180,rt],fe),dr=this.getClusters([-180,Ye,et,rt],fe);return Rt.concat(dr)}const dt=this.trees[this._limitZoom(fe)],it=dt.range(Je(Oe),St(rt),Je(et),St(Ye)),ht=dt.data,Ut=[];for(const Rt of it){const dr=this.stride*Rt;Ut.push(ht[dr+5]>1?Pr(ht,dr,this.clusterProps):this.points[ht[dr+3]])}return Ut}getChildren(de){const fe=this._getOriginId(de),Oe=this._getOriginZoom(de),Ye="No cluster with the specified id.",et=this.trees[Oe];if(!et)throw new Error(Ye);const rt=et.data;if(fe*this.stride>=rt.length)throw new Error(Ye);const dt=this.options.radius/(this.options.extent*Math.pow(2,Oe-1)),it=et.within(rt[fe*this.stride],rt[fe*this.stride+1],dt),ht=[];for(const Ut of it){const Rt=Ut*this.stride;rt[Rt+4]===de&&ht.push(rt[Rt+5]>1?Pr(rt,Rt,this.clusterProps):this.points[rt[Rt+3]])}if(ht.length===0)throw new Error(Ye);return ht}getLeaves(de,fe,Oe){const Ye=[];return this._appendLeaves(Ye,de,fe=fe||10,Oe=Oe||0,0),Ye}getTile(de,fe,Oe){const Ye=this.trees[this._limitZoom(de)],et=Math.pow(2,de),{extent:rt,radius:dt}=this.options,it=dt/rt,ht=(Oe-it)/et,Ut=(Oe+1+it)/et,Rt={features:[]};return this._addTileFeatures(Ye.range((fe-it)/et,ht,(fe+1+it)/et,Ut),Ye.data,fe,Oe,et,Rt),fe===0&&this._addTileFeatures(Ye.range(1-it/et,ht,1,Ut),Ye.data,et,Oe,et,Rt),fe===et-1&&this._addTileFeatures(Ye.range(0,ht,it/et,Ut),Ye.data,-1,Oe,et,Rt),Rt.features.length?Rt:null}getClusterExpansionZoom(de){let fe=this._getOriginZoom(de)-1;for(;fe<=this.options.maxZoom;){const Oe=this.getChildren(de);if(fe++,Oe.length!==1)break;de=Oe[0].properties.cluster_id}return fe}_appendLeaves(de,fe,Oe,Ye,et){const rt=this.getChildren(fe);for(const dt of rt){const it=dt.properties;if(it&&it.cluster?et+it.point_count<=Ye?et+=it.point_count:et=this._appendLeaves(de,it.cluster_id,Oe,Ye,et):et1;let Ut,Rt,dr;if(ht)Ut=jn(fe,it,this.clusterProps),Rt=fe[it],dr=fe[it+1];else{const $r=this.points[fe[it+3]];Ut=$r.properties;const[on,Nn]=$r.geometry.coordinates;Rt=Je(on),dr=St(Nn)}const Br={type:1,geometry:[[Math.round(this.options.extent*(Rt*et-Oe)),Math.round(this.options.extent*(dr*et-Ye))]],tags:Ut};let Gr;Gr=ht||this.options.generateId?fe[it+3]:this.points[fe[it+3]].id,Gr!==void 0&&(Br.id=Gr),rt.features.push(Br)}}_limitZoom(de){return Math.max(this.options.minZoom,Math.min(Math.floor(+de),this.options.maxZoom+1))}_cluster(de,fe){const{radius:Oe,extent:Ye,reduce:et,minPoints:rt}=this.options,dt=Oe/(Ye*Math.pow(2,fe)),it=de.data,ht=[],Ut=this.stride;for(let Rt=0;Rtfe&&(on+=it[Ln+5])}if(on>$r&&on>=rt){let Nn,Ln=dr*$r,Ms=Br*$r,Fi=-1;const Ii=(Rt/Ut<<5)+(fe+1)+this.points.length;for(const yi of Gr){const bs=yi*Ut;if(it[bs+2]<=fe)continue;it[bs+2]=fe;const ai=it[bs+5];Ln+=it[bs]*ai,Ms+=it[bs+1]*ai,it[bs+4]=Ii,et&&(Nn||(Nn=this._map(it,Rt,!0),Fi=this.clusterProps.length,this.clusterProps.push(Nn)),et(Nn,this._map(it,bs)))}it[Rt+4]=Ii,ht.push(Ln/on,Ms/on,1/0,Ii,-1,on),et&&ht.push(Fi)}else{for(let Nn=0;Nn1)for(const Nn of Gr){const Ln=Nn*Ut;if(!(it[Ln+2]<=fe)){it[Ln+2]=fe;for(let Ms=0;Ms>5}_getOriginZoom(de){return(de-this.points.length)%32}_map(de,fe,Oe){if(de[fe+5]>1){const rt=this.clusterProps[de[fe+6]];return Oe?Object.assign({},rt):rt}const Ye=this.points[de[fe+3]].properties,et=this.options.map(Ye);return Oe&&et===Ye?Object.assign({},et):et}}function Pr(ut,de,fe){return{type:"Feature",id:ut[de+3],properties:jn(ut,de,fe),geometry:{type:"Point",coordinates:[(Oe=ut[de],360*(Oe-.5)),Jt(ut[de+1])]}};var Oe}function jn(ut,de,fe){const Oe=ut[de+5],Ye=Oe>=1e4?`${Math.round(Oe/1e3)}k`:Oe>=1e3?Math.round(Oe/100)/10+"k":Oe,et=ut[de+6],rt=et===-1?{}:Object.assign({},fe[et]);return Object.assign(rt,{cluster:!0,cluster_id:ut[de+3],point_count:Oe,point_count_abbreviated:Ye})}function Je(ut){return ut/360+.5}function St(ut){const de=Math.sin(ut*Math.PI/180),fe=.5-.25*Math.log((1+de)/(1-de))/Math.PI;return fe<0?0:fe>1?1:fe}function Jt(ut){const de=(180-360*ut)*Math.PI/180;return 360*Math.atan(Math.exp(de))/Math.PI-90}function Ir(ut,de,fe,Oe){let Ye=Oe;const et=de+(fe-de>>1);let rt,dt=fe-de;const it=ut[de],ht=ut[de+1],Ut=ut[fe],Rt=ut[fe+1];for(let dr=de+3;drYe)rt=dr,Ye=Br;else if(Br===Ye){const Gr=Math.abs(dr-et);GrOe&&(rt-de>3&&Ir(ut,de,rt,Oe),ut[rt+2]=Ye,fe-rt>3&&Ir(ut,rt,fe,Oe))}function ur(ut,de,fe,Oe,Ye,et){let rt=Ye-fe,dt=et-Oe;if(rt!==0||dt!==0){const it=((ut-fe)*rt+(de-Oe)*dt)/(rt*rt+dt*dt);it>1?(fe=Ye,Oe=et):it>0&&(fe+=rt*it,Oe+=dt*it)}return rt=ut-fe,dt=de-Oe,rt*rt+dt*dt}function ar(ut,de,fe,Oe){const Ye={id:ut??null,type:de,geometry:fe,tags:Oe,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if(de==="Point"||de==="MultiPoint"||de==="LineString")It(Ye,fe);else if(de==="Polygon")It(Ye,fe[0]);else if(de==="MultiLineString")for(const et of fe)It(Ye,et);else if(de==="MultiPolygon")for(const et of fe)It(Ye,et[0]);return Ye}function It(ut,de){for(let fe=0;fe0&&(rt+=Oe?(Ye*Ut-ht*et)/2:Math.sqrt(Math.pow(ht-Ye,2)+Math.pow(Ut-et,2))),Ye=ht,et=Ut}const dt=de.length-3;de[2]=1,Ir(de,0,dt,fe),de[dt+2]=1,de.size=Math.abs(rt),de.start=0,de.end=de.size}function is(ut,de,fe,Oe){for(let Ye=0;Ye1?1:fe}function vs(ut,de,fe,Oe,Ye,et,rt,dt){if(Oe/=de,et>=(fe/=de)&&rt=Oe)return null;const it=[];for(const ht of ut){const Ut=ht.geometry;let Rt=ht.type;const dr=Ye===0?ht.minX:ht.minY,Br=Ye===0?ht.maxX:ht.maxY;if(dr>=fe&&Br=Oe)continue;let Gr=[];if(Rt==="Point"||Rt==="MultiPoint")ua(Ut,Gr,fe,Oe,Ye);else if(Rt==="LineString")Nr(Ut,Gr,fe,Oe,Ye,!1,dt.lineMetrics);else if(Rt==="MultiLineString")Yi(Ut,Gr,fe,Oe,Ye,!1);else if(Rt==="Polygon")Yi(Ut,Gr,fe,Oe,Ye,!0);else if(Rt==="MultiPolygon")for(const $r of Ut){const on=[];Yi($r,on,fe,Oe,Ye,!0),on.length&&Gr.push(on)}if(Gr.length){if(dt.lineMetrics&&Rt==="LineString"){for(const $r of Gr)it.push(ar(ht.id,Rt,$r,ht.tags));continue}Rt!=="LineString"&&Rt!=="MultiLineString"||(Gr.length===1?(Rt="LineString",Gr=Gr[0]):Rt="MultiLineString"),Rt!=="Point"&&Rt!=="MultiPoint"||(Rt=Gr.length===3?"Point":"MultiPoint"),it.push(ar(ht.id,Rt,Gr,ht.tags))}}return it.length?it:null}function ua(ut,de,fe,Oe,Ye){for(let et=0;et=fe&&rt<=Oe&&ja(de,ut[et],ut[et+1],ut[et+2])}}function Nr(ut,de,fe,Oe,Ye,et,rt){let dt=qn(ut);const it=Ye===0?So:Zr;let ht,Ut,Rt=ut.start;for(let on=0;onfe&&(Ut=it(dt,Nn,Ln,Fi,Ii,fe),rt&&(dt.start=Rt+ht*Ut)):yi>Oe?bs=fe&&(Ut=it(dt,Nn,Ln,Fi,Ii,fe),ai=!0),bs>Oe&&yi<=Oe&&(Ut=it(dt,Nn,Ln,Fi,Ii,Oe),ai=!0),!et&&ai&&(rt&&(dt.end=Rt+ht*Ut),de.push(dt),dt=qn(ut)),rt&&(Rt+=ht)}let dr=ut.length-3;const Br=ut[dr],Gr=ut[dr+1],$r=Ye===0?Br:Gr;$r>=fe&&$r<=Oe&&ja(dt,Br,Gr,ut[dr+2]),dr=dt.length-3,et&&dr>=3&&(dt[dr]!==dt[0]||dt[dr+1]!==dt[1])&&ja(dt,dt[0],dt[1],dt[2]),dt.length&&de.push(dt)}function qn(ut){const de=[];return de.size=ut.size,de.start=ut.start,de.end=ut.end,de}function Yi(ut,de,fe,Oe,Ye,et){for(const rt of ut)Nr(rt,de,fe,Oe,Ye,et,!1)}function ja(ut,de,fe,Oe){ut.push(de,fe,Oe)}function So(ut,de,fe,Oe,Ye,et){const rt=(et-de)/(Oe-de);return ja(ut,et,fe+(Ye-fe)*rt,1),rt}function Zr(ut,de,fe,Oe,Ye,et){const rt=(et-fe)/(Ye-fe);return ja(ut,de+(Oe-de)*rt,et,1),rt}function fn(ut,de){const fe=[];for(let Oe=0;Oe0&&de.size<(Ye?rt:Oe))return void(fe.numPoints+=de.length/3);const dt=[];for(let it=0;itrt)&&(fe.numSimplified++,dt.push(de[it],de[it+1])),fe.numPoints++;Ye&&function(it,ht){let Ut=0;for(let Rt=0,dr=it.length,Br=dr-2;Rt0===ht)for(let Rt=0,dr=it.length;Rt24)throw new Error("maxZoom should be in the 0-24 range");if(fe.promoteId&&fe.generateId)throw new Error("promoteId and generateId cannot be used together.");let Ye=function(et,rt){const dt=[];if(et.type==="FeatureCollection")for(let it=0;it1&&console.time("creation"),Br=this.tiles[dr]=en(de,fe,Oe,Ye,ht),this.tileCoords.push({z:fe,x:Oe,y:Ye}),Ut)){Ut>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",fe,Oe,Ye,Br.numFeatures,Br.numPoints,Br.numSimplified),console.timeEnd("creation"));const ai=`z${fe}`;this.stats[ai]=(this.stats[ai]||0)+1,this.total++}if(Br.source=de,et==null){if(fe===ht.indexMaxZoom||Br.numPoints<=ht.indexMaxPoints)continue}else{if(fe===ht.maxZoom||fe===et)continue;if(et!=null){const ai=et-fe;if(Oe!==rt>>ai||Ye!==dt>>ai)continue}}if(Br.source=null,de.length===0)continue;Ut>1&&console.time("clipping");const Gr=.5*ht.buffer/ht.extent,$r=.5-Gr,on=.5+Gr,Nn=1+Gr;let Ln=null,Ms=null,Fi=null,Ii=null,yi=vs(de,Rt,Oe-Gr,Oe+on,0,Br.minX,Br.maxX,ht),bs=vs(de,Rt,Oe+$r,Oe+Nn,0,Br.minX,Br.maxX,ht);de=null,yi&&(Ln=vs(yi,Rt,Ye-Gr,Ye+on,1,Br.minY,Br.maxY,ht),Ms=vs(yi,Rt,Ye+$r,Ye+Nn,1,Br.minY,Br.maxY,ht),yi=null),bs&&(Fi=vs(bs,Rt,Ye-Gr,Ye+on,1,Br.minY,Br.maxY,ht),Ii=vs(bs,Rt,Ye+$r,Ye+Nn,1,Br.minY,Br.maxY,ht),bs=null),Ut>1&&console.timeEnd("clipping"),it.push(Ln||[],fe+1,2*Oe,2*Ye),it.push(Ms||[],fe+1,2*Oe,2*Ye+1),it.push(Fi||[],fe+1,2*Oe+1,2*Ye),it.push(Ii||[],fe+1,2*Oe+1,2*Ye+1)}}getTile(de,fe,Oe){de=+de,fe=+fe,Oe=+Oe;const Ye=this.options,{extent:et,debug:rt}=Ye;if(de<0||de>24)return null;const dt=1<1&&console.log("drilling down to z%d-%d-%d",de,fe,Oe);let ht,Ut=de,Rt=fe,dr=Oe;for(;!ht&&Ut>0;)Ut--,Rt>>=1,dr>>=1,ht=this.tiles[Ft(Ut,Rt,dr)];return ht&&ht.source?(rt>1&&(console.log("found parent tile z%d-%d-%d",Ut,Rt,dr),console.time("drilling down")),this.splitTile(ht.source,Ut,Rt,dr,de,fe,Oe),rt>1&&console.timeEnd("drilling down"),this.tiles[it]?Xr(this.tiles[it],et):null):null}}function Ft(ut,de,fe){return 32*((1<ht.tags&&"3d_elevation_id"in ht.tags&&"source"in ht.tags&&ht.tags.source==="elevation",et=Oe.features.filter(ht=>Ye(ht));let rt={_geojsonTileLayer:Oe.features};et.length>0&&(rt={_geojsonTileLayer:Oe.features.filter(ht=>!Ye(ht)),hd_road_elevation:et});const dt=new ke(rt),it=function(ht){const Ut=new f.a$;for(const Rt of Object.keys(ht))Ut.writeMessage(3,vt,{name:Rt,features:ht[Rt]});return Ut.finish()}(rt).buffer;de(null,{vectorTile:dt,rawData:it})}class js extends Q{constructor(de){super(de),this.loadVectorData=Bo,this._dynamicIndex=new me}loadData(de,fe){const Oe=de&&de.request,Ye=Oe&&Oe.collectResourceTiming;this._geoJSONIndex=null,this.loadGeoJSON(de,(et,rt)=>{if(et||!rt)return fe(et);if(typeof rt!="object")return fe(new Error(`Input data given to '${de.source}' is not a valid GeoJSON object.`));{try{if(de.filter){const it=f.X(de.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if(it.result==="error")throw new Error(it.value.map(ht=>`${ht.key}: ${ht.message}`).join(", "));rt.features=rt.features.filter(ht=>it.value.evaluate({zoom:0},ht))}de.dynamic?(rt.type==="Feature"&&(rt={type:"FeatureCollection",features:[rt]}),de.append||(this._dynamicIndex.clear(),this.loaded={}),this._dynamicIndex.load(rt.features,this.loaded),de.cluster&&(rt.features=this._dynamicIndex.getFeatures())):this.loaded={},this._geoJSONIndex=de.cluster?new yr(function({superclusterOptions:it,clusterProperties:ht}){if(!ht||!it)return it;const Ut={},Rt={},dr={accumulated:null,zoom:0},Br={properties:null},Gr=Object.keys(ht);for(const $r of Gr){const[on,Nn]=ht[$r],Ln=f.X(Nn),Ms=f.X(typeof on=="string"?[on,["accumulated"],["get",$r]]:on);Ut[$r]=Ln.value,Rt[$r]=Ms.value}return it.map=$r=>{Br.properties=$r;const on={};for(const Nn of Gr)on[Nn]=Ut[Nn].evaluate(dr,Br);return on},it.reduce=($r,on)=>{Br.properties=on;for(const Nn of Gr)dr.accumulated=$r[Nn],$r[Nn]=Rt[Nn].evaluate(dr,Br)},it}(de)).load(rt.features):de.dynamic?this._dynamicIndex:function(it,ht){return new el(it,ht)}(rt,de.geojsonVtOptions)}catch(it){return fe(it)}const dt={};if(Ye){const it=p(Oe);it&&(dt.resourceTiming={},dt.resourceTiming[de.source]=JSON.parse(JSON.stringify(it)))}fe(null,dt)}})}reloadTile(de,fe){const Oe=this.loaded;return Oe&&Oe[de.uid]?de.partial?fe(null,void 0):super.reloadTile(de,fe):this.loadTile(de,fe)}loadGeoJSON(de,fe){if(de.request)f.m(de.request,fe);else{if(typeof de.data!="string")return fe(new Error(`Input data given to '${de.source}' is not a valid GeoJSON object.`));setTimeout(()=>{try{return fe(null,JSON.parse(de.data))}catch{return fe(new Error(`Input data given to '${de.source}' is not a valid GeoJSON object.`))}},0)}}getClusterExpansionZoom(de,fe){try{fe(null,this._geoJSONIndex.getClusterExpansionZoom(de.clusterId))}catch(Oe){fe(Oe)}}getClusterChildren(de,fe){try{fe(null,this._geoJSONIndex.getChildren(de.clusterId))}catch(Oe){fe(Oe)}}getClusterLeaves(de,fe){try{fe(null,this._geoJSONIndex.getLeaves(de.clusterId,de.limit,de.offset))}catch(Oe){fe(Oe)}}}class Ci{constructor(de,fe,Oe){this.tileID=new f.aR(de.tileID.overscaledZ,de.tileID.wrap,de.tileID.canonical.z,de.tileID.canonical.x,de.tileID.canonical.y),this.tileZoom=de.tileZoom,this.uid=de.uid,this.zoom=de.zoom,this.canonical=de.tileID.canonical,this.pixelRatio=de.pixelRatio,this.tileSize=de.tileSize,this.source=de.source,this.overscaling=this.tileID.overscaleFactor(),this.projection=de.projection,this.brightness=fe,this.worldview=Oe}parse(de,fe,Oe,Ye){this.status="parsing";const et=new f.aR(Oe.tileID.overscaledZ,Oe.tileID.wrap,Oe.tileID.canonical.z,Oe.tileID.canonical.x,Oe.tileID.canonical.y),rt=[],dt=fe.familiesBySource[Oe.source],it=new f.ff(et,Oe.promoteId);it.bucketLayerIDs=[],it.is3DTile=!0,f.fB(de).then(ht=>{const Ut=ht.json.extensionsUsed&&ht.json.extensionsUsed.includes("MAPBOX_mesh_features")||ht.json.asset.extras&&ht.json.asset.extras.MAPBOX_mesh_features,Rt=ht.json.extensionsUsed&&ht.json.extensionsUsed.includes("EXT_meshopt_compression"),dr=new f.ae(this.zoom,{brightness:this.brightness,worldview:this.worldview});for(const Br in dt)for(const Gr of dt[Br]){const $r=Gr[0];it.bucketLayerIDs.push(Gr.map(Ln=>f.F(Ln.id,Ln.scope))),$r.recalculate(dr,[]);const on=f.fC(ht,1/f.cS(Oe.tileID.canonical)),Nn=new f.fD(Gr,on,et,Ut,Rt,this.brightness,it,this.worldview);Ut||(Nn.needsUpload=!0),rt.push(Nn),Nn.evaluate($r)}this.status="done",Ye(null,{buckets:rt,featureIndex:it,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:null})}).catch(ht=>Ye(new Error(ht.message)))}}class Xn{constructor({actor:de,layerIndex:fe,availableImages:Oe,availableModels:Ye,brightness:et,worldview:rt}){this.actor=de,this.layerIndex=fe,this.availableImages=Oe,this.availableModels=Ye,this.brightness=et,this.loading={},this.loaded={},this.worldview=rt}loadTile(de,fe){const Oe=de.uid,Ye=this.loading[Oe]=new Ci(de,this.brightness,this.worldview);f.b1(de.request,(et,rt)=>{const dt=!this.loading[Oe];return delete this.loading[Oe],dt||et?(Ye.status="done",dt||(this.loaded[Oe]=Ye),fe(et)):rt&&rt.byteLength!==0?void Ye.parse(rt,this.layerIndex,de,(it,ht)=>{Ye.status="done",this.loaded=this.loaded||{},this.loaded[Oe]=Ye,it||!ht?fe(it):fe(null,ht)}):(Ye.status="done",this.loaded[Oe]=Ye,fe())})}reloadTile(de,fe){const Oe=this.loaded,Ye=de.uid;if(Oe&&Oe[Ye]){const et=Oe[Ye];et.projection=de.projection,et.brightness=de.brightness;const rt=(dt,it)=>{et.reloadCallback&&(delete et.reloadCallback,this.loadTile(de,fe)),fe(dt,it)};et.status==="parsing"?et.reloadCallback=rt:et.status==="done"&&this.loadTile(de,fe)}}abortTile(de,fe){const Oe=de.uid;this.loading[Oe]&&delete this.loading[Oe],fe()}removeTile(de,fe){const Oe=this.loaded,Ye=de.uid;Oe&&Oe[Ye]&&delete Oe[Ye],fe()}}const mo=new Map,du=new Map;class e0{constructor(de){this.self=de,this.actor=new f.A(de,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:Q,geojson:js,"raster-dem":ee,"raster-array":pe,"batched-model":Xn},this.workerSources={},this.self.registerWorkerSource=(fe,Oe)=>{if(this.workerSourceTypes[fe])throw new Error(`Worker source with name "${fe}" already registered.`);this.workerSourceTypes[fe]=Oe},this.self.registerRTLTextPlugin=fe=>{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=fe.applyArabicShaping,f.fF.processBidirectionalText=fe.processBidirectionalText,f.fF.processStyledBidirectionalText=fe.processStyledBidirectionalText;for(const Oe of this.rtlPluginParsingListeners)Oe(null,!0);this.rtlPluginParsingListeners=[]}}clearCaches(de,fe,Oe){delete this.layerIndexes[de],delete this.availableImages[de],delete this.availableModels[de],delete this.workerSources[de],Oe()}checkIfReady(de,fe,Oe){Oe()}setReferrer(de,fe){this.referrer=fe}spriteLoaded(de,fe){this.isSpriteLoaded[de]||(this.isSpriteLoaded[de]={});const{scope:Oe,isLoaded:Ye}=fe;if(this.isSpriteLoaded[de][Oe]=Ye,this.workerSources[de]&&this.workerSources[de][Oe])for(const et in this.workerSources[de][Oe]){const rt=this.workerSources[de][Oe][et];for(const dt in rt){const it=rt[dt];it instanceof Q&&(it.isSpriteLoaded=Ye,it.fire(new f.C("isSpriteLoaded")))}}}setImages(de,fe,Oe){this.availableImages[de]||(this.availableImages[de]={});const{scope:Ye,images:et}=fe;if(this.availableImages[de][Ye]=et,this.workerSources[de]&&this.workerSources[de][Ye]){for(const rt in this.workerSources[de][Ye]){const dt=this.workerSources[de][Ye][rt];for(const it in dt)dt[it].availableImages=et}Oe()}else Oe()}setModels(de,{scope:fe,models:Oe},Ye){if(this.availableModels[de]||(this.availableModels[de]={}),this.availableModels[de][fe]=Oe,this.workerSources[de]&&this.workerSources[de][fe]){for(const et in this.workerSources[de][fe]){const rt=this.workerSources[de][fe][et];for(const dt in rt)rt[dt].availableModels=Oe}Ye()}else Ye()}setProjection(de,fe){this.projections[de]=f.c0(fe)}setBrightness(de,fe,Oe){this.brightness=fe,Oe()}setContextParams(de,fe,Oe){this.maxUniformBufferBindings=fe.maxBindingPoints,this.maxUniformBlockSizeDwords=fe.maxUniformBlockSizeDwords,this.disableSymbolUBO=fe.disableSymbolUBO,Oe()}setWorldview(de,fe,Oe){this.worldview=fe,Oe()}setLayers(de,fe,Oe){this.getLayerIndex(de,fe.scope).replace(fe.layers,fe.options),Oe()}updateLayers(de,fe,Oe){this.getLayerIndex(de,fe.scope).update(fe.layers,fe.removedIds,fe.options),Oe()}loadTile(de,fe,Oe){fe.projection=this.projections[de]||this.defaultProjection,this.getWorkerSource(de,fe).loadTile(fe,Oe)}decodeRasterArray(de,fe,Oe){this.getWorkerSource(de,fe).decodeRasterArray(fe,Oe)}reloadTile(de,fe,Oe){fe.projection=this.projections[de]||this.defaultProjection,this.getWorkerSource(de,fe).reloadTile(fe,Oe)}abortTile(de,fe,Oe){this.getWorkerSource(de,fe).abortTile(fe,Oe)}removeTile(de,fe,Oe){this.getWorkerSource(de,fe).removeTile(fe,Oe)}removeSource(de,fe,Oe){if(!(this.workerSources[de]&&this.workerSources[de][fe.scope]&&this.workerSources[de][fe.scope][fe.type]&&this.workerSources[de][fe.scope][fe.type][fe.source]))return;const Ye=this.workerSources[de][fe.scope][fe.type][fe.source];delete this.workerSources[de][fe.scope][fe.type][fe.source],Ye.removeSource!==void 0?Ye.removeSource(fe,Oe):Oe()}loadTileProvider(de,fe,Oe){(async function(Ye,et){const rt=du.get(Ye);if(rt)return rt;const dt=mo.get(Ye);if(dt!==void 0)return dt;const it=import(et).then(ht=>{const Ut=ht.default;if(typeof Ut!="function")throw new Error(`TileProvider "${Ye}" module must default-export a class`);if(typeof Ut.prototype.loadTile!="function")throw new Error(`TileProvider "${Ye}" class must have a loadTile method`);return du.set(Ye,Ut),Ut}).finally(()=>{mo.delete(Ye)});return mo.set(Ye,it),it})(fe.name,fe.url).then(Ye=>{const et=new Ye(fe.options);return this.getWorkerSource(de,{type:fe.type,source:fe.source,scope:fe.scope},et),et.load&&fe.request?et.load({request:fe.request}):null}).then(Ye=>Oe(null,Ye)).catch(Ye=>Oe(Ye instanceof Error?Ye:new Error(typeof Ye=="string"?Ye:"Unknown error")))}loadWorkerSource(de,fe,Oe){try{this.self.importScripts(fe.url),Oe()}catch(Ye){Oe(Ye)}}syncRTLPluginState(de,fe,Oe){if(f.fF.isParsed())Oe(null,!0);else if(f.fF.isParsing())this.rtlPluginParsingListeners.push(Oe);else try{f.fF.setState(fe);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()?Oe(null,!0):this.rtlPluginParsingListeners.push(Oe))}catch(Ye){Oe(Ye)}}setConfig(de,fe){Object.assign(f.g,fe)}getAvailableImages(de,fe){this.availableImages[de]||(this.availableImages[de]={});let Oe=this.availableImages[de][fe];return Oe||(Oe=[]),Oe}getAvailableModels(de,fe){this.availableModels[de]||(this.availableModels[de]={});let Oe=this.availableModels[de][fe];return Oe||(Oe={}),Oe}getLayerIndex(de,fe){this.layerIndexes[de]||(this.layerIndexes[de]={});let Oe=this.layerIndexes[de][fe];return Oe||(Oe=this.layerIndexes[de][fe]=new E,Oe.scope=fe),Oe}getWorkerSource(de,fe,Oe){const{type:Ye,source:et,scope:rt}=fe,dt=this.workerSources;if(dt[de]||(dt[de]={}),dt[de][rt]||(dt[de][rt]={}),dt[de][rt][Ye]||(dt[de][rt][Ye]={}),this.isSpriteLoaded[de]||(this.isSpriteLoaded[de]={}),!dt[de][rt][Ye][et]){const it={send:(Ut,Rt,dr,Br,Gr,$r)=>this.actor.send(Ut,Rt,dr,de,Gr,$r),scheduler:this.actor.scheduler},ht=this.workerSourceTypes[Ye];if(!ht)throw new Error(`Unknown worker source type "${Ye}".`);dt[de][rt][Ye][et]=new ht({actor:it,layerIndex:this.getLayerIndex(de,rt),availableImages:this.getAvailableImages(de,rt),availableModels:this.getAvailableModels(de,rt),isSpriteLoaded:this.isSpriteLoaded[de][rt],tileProvider:Oe,brightness:this.brightness,worldview:this.worldview,maxUniformBufferBindings:this.maxUniformBufferBindings,maxUniformBlockSizeDwords:this.maxUniformBlockSizeDwords,disableSymbolUBO:this.disableSymbolUBO})}return dt[de][rt][Ye][et]}rasterizeImagesWorker(de,fe,Oe){const Ye=new Map;for(const[et,{image:rt,imageVariant:dt}]of fe.tasks.entries()){const it=this.imageRasterizer.rasterize(dt,rt,fe.scope,de);Ye.set(et,it)}Oe(void 0,Ye)}removeRasterizedImages(de,fe,Oe){this.imageRasterizer.removeImagesFromCacheByIds(fe.imageIds,fe.scope,de),Oe()}enforceCacheSizeLimit(de,fe){f.fH(fe)}getWorkerPerformanceMetrics(de,fe,Oe){Oe(void 0,void 0)}}return f.fE(self)&&(self.worker=new e0(self)),e0}),o(["./shared"],function(a){var f="3.22.0";const p={create:"create",load:"load",fullLoad:"fullLoad"},y={mark(_){performance.mark(_)},measure(_,d,g){performance.measure(_,d,g)}};function v(_){const d=_.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 S,E={},k=function(){if(S)return E;function _(w){return!d(w)}function d(w){return typeof window>"u"||typeof document>"u"?"not a browser":function(){if(!("Worker"in window&&"Blob"in window&&"URL"in window))return!1;var I,L,F=new Blob([""],{type:"text/javascript"}),z=URL.createObjectURL(F);try{L=new Worker(z),I=!0}catch{I=!1}return L&&L.terminate(),URL.revokeObjectURL(z),I}()?function(){var I=document.createElement("canvas");I.width=I.height=1;var L=I.getContext("2d");if(!L)return!1;var F=L.getImageData(0,0,1,1);return F&&F.width===I.width}()?(g[j=w&&w.failIfMajorPerformanceCaveat]===void 0&&(g[j]=function(I){var L,F=function(z){var H=document.createElement("canvas"),Z=Object.create(_.webGLContextAttributes);return Z.failIfMajorPerformanceCaveat=z,H.getContext("webgl2",Z)}(I);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}S=1,E.supported=_,E.notSupportedReason=d;var g={};return _.webGLContextAttributes={antialias:!1,alpha:!0,stencil:!0,depth:!0},E}();function R(_,d,g){const w=document.createElement(_);return d!=null&&(w.className=d),g&&g.appendChild(w),w}function P(_,d,g){const w=document.createElementNS("http://www.w3.org/2000/svg",_);for(const j of Object.keys(d))w.setAttributeNS(null,j,String(d[j]));return g&&g.appendChild(w),w}const M=typeof document<"u"?document.documentElement&&document.documentElement.style:null,D=M&&M.userSelect!==void 0?"userSelect":"WebkitUserSelect";let B;function V(){M&&D&&(B=M[D],M[D]="none")}function G(){M&&D&&(M[D]=B)}function W(_){_.preventDefault(),_.stopPropagation(),window.removeEventListener("click",W,!0)}function Y(){window.addEventListener("click",W,!0),window.setTimeout(()=>{window.removeEventListener("click",W,!0)},0)}function J(_,d){const g=_.getBoundingClientRect();return le(_,g,d)}function Q(_,d){const g=_.getBoundingClientRect(),w=[];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 w=ke(d);return w.params.push(`sdk=js-${f}`),w.path=`/styles/v1${w.path}`,this._makeAPIURL(w,this._customAccessToken||g)}normalizeGlyphsURL(d,g){if(!a.e(d))return d;const w=ke(d);return w.path=`/fonts/v1${w.path}`,this._makeAPIURL(w,this._customAccessToken||g)}normalizeModelURL(d,g){if(!a.e(d))return d;const w=ke(d);return w.path=`/models/v1${w.path}`,this._makeAPIURL(w,this._customAccessToken||g)}normalizeSourceURL(d,g,w,j){if(!a.e(d))return d;const I=ke(d);return I.path=`/v4/${I.authority}.json`,I.params.push("secure"),w&&I.params.push(`language=${w}`),j&&I.params.push(`worldview=${j}`),this._makeAPIURL(I,this._customAccessToken||g)}normalizeIconsetURL(d,g){const w=ke(d);return a.e(d)?(w.path=`/styles/v1${w.path}/iconset.pbf`,this._makeAPIURL(w,this._customAccessToken||g)):we(w)}normalizeSpriteURL(d,g,w,j){const I=ke(d);return a.e(d)?(I.path=`/styles/v1${I.path}/sprite${g}${w}`,this._makeAPIURL(I,this._customAccessToken||j)):(I.path+=`${g}${w}`,we(I))}normalizeTileURL(d,g,w){if(this._isSkuTokenExpired()&&this._createSkuToken(),d&&!a.e(d))return d;const j=ke(d);j.path=j.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${g||w&&j.authority!=="raster"&&w===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 I=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&&I&&this._skuToken&&j.params.push(`sku=${this._skuToken}`),this._makeAPIURL(j,I)}canonicalizeTileURL(d,g){const w=ke(d);if(!w.path.match(/^(\/v4\/|\/(raster|rasterarrays)\/v1\/)/)||!w.path.match(/\.[\w]+$/))return d;let j="mapbox://";w.path.match(/^\/raster\/v1\//)?j+=`raster/${w.path.replace(`/${a.g.RASTER_URL_PREFIX}/`,"")}`:w.path.match(/^\/rasterarrays\/v1\//)?j+=`rasterarrays/${w.path.replace(`/${a.g.RASTERARRAYS_URL_PREFIX}/`,"")}`:j+=`tiles/${w.path.replace(`/${a.g.TILE_URL_VERSION}/`,"")}`;let I=w.params;return g&&(I=I.filter(L=>!L.match(/^access_token=/))),I.length&&(j+=`?${I.join("&")}`),j}canonicalizeTileset(d,g){const w=!!g&&a.e(g),j=[];for(const I of d.tiles||[])a.f(I)?j.push(this.canonicalizeTileURL(I,w)):j.push(I);return j}_makeAPIURL(d,g){const w="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",j=ke(a.g.API_URL);if(d.protocol=j.protocol,d.authority=j.authority,d.protocol==="http"){const I=d.params.indexOf("secure");I>=0&&d.params.splice(I,1)}if(j.path!=="/"&&(d.path=`${j.path}${d.path}`),!a.g.REQUIRE_ACCESS_TOKEN)return we(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. ${w}`);if(g[0]==="s")throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${w}`)}return d.params=d.params.filter(I=>I.indexOf("access_token")===-1),d.params.push(`access_token=${g||""}`),we(d)}}const Le=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function ke(_){const d=_.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 we(_){const d=_.params.length?`?${_.params.join("&")}`:"";return`${_.protocol}://${_.authority}${_.path}${d}`}const me="mapbox.eventData";function je(_){if(!_)return null;const d=_.split(".");if(!d||d.length!==3)return null;try{return JSON.parse(a.l(d[1]))}catch{return null}}function _e(_){return!(!a.g.EVENTS_URL||!_&&!a.g.ACCESS_TOKEN)}class Ee{constructor(d){this.type=d,this.anonId=null,this.anonIdTimestamp=null,this.eventData={},this.queue=[],this.pendingRequest=null}getStorageKey(d){const g=je(a.g.ACCESS_TOKEN);let w="";return w=g&&g.u?a.j(g.u):a.g.ACCESS_TOKEN||"",d?`${me}.${d}:${w}`:`${me}:${w}`}fetchEventData(){const d=a.s("localStorage"),g=this.getStorageKey(),w=this.getStorageKey("uuid"),j=this.getStorageKey("uuidTimestamp");if(d)try{const I=localStorage.getItem(g);I&&(this.eventData=JSON.parse(I));const L=localStorage.getItem(w);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,w,j){if(!a.g.EVENTS_URL)return;const I=ke(a.g.EVENTS_URL);I.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:we(I),headers:{"Content-Type":"text/plain"},body:JSON.stringify([F])};this.pendingRequest=a.p(z,H=>{this.pendingRequest=null,w(H),this.saveEventData(),this.processRequests(j)})}queueRequest(d,g){this.queue.push(d),this.processRequests(g)}}class ve extends Ee{constructor(d){super("metrics"),d&&(this.data=d)}postMetricsEvent(d){if(!_e(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:w}=this.queue.shift();this.postEvent(g,w,()=>{},d)}}const qe=new class extends Ee{constructor(_){super("appUserTurnstile"),this._customAccessToken=_}postTurnstileEvent(_,d){_e(d)&&Array.isArray(_)&&_.some(g=>a.e(g)||a.f(g))&&this.queueRequest(Date.now(),d)}processRequests(_){if(this.pendingRequest||this.queue.length===0)return;this.anonId&&this.anonIdTimestamp&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();const d=je(a.g.ACCESS_TOKEN),g=d?d.u:a.g.ACCESS_TOKEN;let w=g!==this.eventData.tokenU;a.v(this.anonId)||(this.refreshUUID(),w=!0);const j=this.queue.shift();if(this.eventData.lastSuccess){const I=new Date(this.eventData.lastSuccess),L=new Date(j),F=(j-this.eventData.lastSuccess)/864e5;w=w||F>=1||F<-1||I.getDate()!==L.getDate()}else w=!0;w?this.postEvent(j,{sdkIdentifier:"mapbox-gl-js",sdkVersion:f,skuId:pe,"enabled.telemetry":!1,userId:this.anonId},I=>{I||(this.eventData.lastSuccess=j,this.eventData.tokenU=g)},_):this.processRequests()}},nt=qe.postTurnstileEvent.bind(qe),ot=new class extends Ee{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(_,d,g,w){this.skuToken=d,this.errorCb=w,a.g.EVENTS_URL&&(g||a.g.ACCESS_TOKEN?this.queueRequest({id:_,timestamp:Date.now()},g):this.errorCb(new Error(Te)))}processRequests(_){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:pe,skuToken:this.skuToken,userId:this.anonId},w=>{w?this.errorCb(w):d&&(this.success[d]=!0)},_))}remove(){this.errorCb=null}},jt=ot.postMapLoadEvent.bind(ot),vt=new class extends Ee{constructor(){super("style.load"),this.eventIdPerMapInstanceMap=new Map,this.mapInstanceIdMap=new WeakMap}getMapInstanceId(_){let d=this.mapInstanceIdMap.get(_);return d||(d=a.u(),this.mapInstanceIdMap.set(_,d)),d}getEventId(_){const d=this.eventIdPerMapInstanceMap.get(_)||0;return this.eventIdPerMapInstanceMap.set(_,d+1),d}postStyleLoadEvent(_,d){const{map:g,style:w,importedStyles:j}=d;if(!_e(_))return;const I=this.getMapInstanceId(g),L={mapInstanceId:I,eventId:this.getEventId(I),style:w};j.length&&(L.importedStyles=j),this.queueRequest({timestamp:Date.now(),payload:L},_)}processRequests(_){if(this.pendingRequest||this.queue.length===0)return;const{timestamp:d,payload:g}=this.queue.shift();this.postEvent(d,g,()=>{},_)}},Gt=vt.postStyleLoadEvent.bind(vt),pt=new ve({attributes:[{name:"maps/js/layer-animations/style-with-appearances"}]}),Ct=pt.postMetricsEvent.bind(pt),tr=new ve({attributes:[{name:"maps/js/layer-animations/runtime-appearances"}]}),wt=tr.postMetricsEvent.bind(tr),lr=new class extends Ee{constructor(){super("gljs.performance")}postPerformanceEvent(_,d){_e(_)&&this.queueRequest({timestamp:Date.now(),performanceData:d},_)}processRequests(_){if(this.pendingRequest||this.queue.length===0)return;const{timestamp:d,performanceData:g}=this.queue.shift(),w=function(j){const I=performance.getEntriesByType("resource"),L=performance.getEntriesByType("mark"),F=function(ie){const ce={};if(ie){for(const oe in ie)if(oe!=="other")for(const xe of ie[oe]){const ye=`${oe}ResolveRangeMin`,Pe=`${oe}ResolveRangeMax`,Me=`${oe}RequestCount`,Se=`${oe}RequestCachedCount`;ce[ye]=Math.min(ce[ye]||1/0,xe.startTime),ce[Pe]=Math.max(ce[Pe]||-1/0,xe.responseEnd);const Ze=$e=>{ce[$e]===void 0&&(ce[$e]=0),++ce[$e]};xe.transferSize!==void 0&&xe.transferSize===0&&Ze(Se),Ze(Me)}}return ce}(function(ie,ce){const oe={};if(ie)for(const xe of ie){const ye=ce(xe);oe[ye]===void 0&&(oe[ye]=[]),oe[ye].push(xe)}return oe}(I,v)),z=window.devicePixelRatio,H=navigator.connection||navigator.mozConnection||navigator.webkitConnection,Z=H?H.effectiveType:void 0,ne={counters:[],metadata:[],attributes:[]},re=(ie,ce,oe)=>{oe!=null&&ie.push({name:ce,value:oe.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(p)){const ce=L.find(oe=>oe.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 oe=ce.name.split("?")[0];if(a.i(oe)){const xe=oe.split("/").slice(-2);if(xe.length===2)return`mapbox://styles/${xe[0]}/${xe[1]}`}}}(I)),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 w.metadata);for(const j of w.counters);for(const j of w.attributes);this.postEvent(d,w,()=>{},_)}},Sr=lr.postPerformanceEvent.bind(lr),sn=new class extends Ee{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(_,d,g,w){if(!a.g.API_URL||!a.g.SESSION_PATH)return;const j=ke(a.g.API_URL+a.g.SESSION_PATH);j.params.push(`sku=${d||""}`),j.params.push(`access_token=${w||a.g.ACCESS_TOKEN||""}`);const I={url:we(j),headers:{"Content-Type":"text/plain"}};this.pendingRequest=a.h(I,L=>{this.pendingRequest=null,g(L),this.saveEventData(),this.processRequests(w)})}getSessionAPI(_,d,g,w){this.skuToken=d,this.errorCb=w,a.g.EVENTS_URL&&a.g.SESSION_PATH&&a.g.API_URL&&(g||a.g.ACCESS_TOKEN?this.queueRequest({id:_,timestamp:Date.now()},g):this.errorCb(new Error(Te)))}processRequests(_){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,w=>{w?this.errorCb(w):d&&(this.success[d]=!0)},_)}remove(){this.errorCb=null}},cr=sn.getSessionAPI.bind(sn),yr=new Set;function Pr(_,d){d?yr.add(_):yr.delete(_)}class jn{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 Je(_){const{userImage:d}=_;return!!(d&&d.render&&d.render())&&(_.data.replace(new Uint8Array(d.data.buffer)),!0)}const St={workerUrl:"",workerClass:null,workerParams:void 0};function Jt(_){return St.workerClass!=null?new St.workerClass:new self.Worker(St.workerUrl,Object.assign({name:_},St.workerParams))}const Ir="mapboxgl_preloaded_worker_pool";class ur{constructor(d){this.active={},this.name=d}acquire(d,g=ur.workerCount){if(!this.workers)for(this.workers=[];this.workers.length{g.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[Ir]}numActive(){return Object.keys(this.active).length}}ur.workerCount=2;class ar{constructor(d,g,w="Worker",j=ur.workerCount){this.workerPool=d,this.actors=[],this.currentActor=0,this.id=a.r();const I=this.workerPool.acquire(this.id,j);for(let L=0;L{this.ready=!0})}broadcast(d,g,w){a.t(this.actors,(j,I)=>{j.send(d,g,I)},w=w||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 It,pr;function Tn(){return It||(It=new ur),It}ar.Actor=a.A;class ss 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 ar((pr||(pr=new ur("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 w of g.values())w.hasPendingRequests()&&d.push(w);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:w,callback:j}of this.requestors)this._notify(w,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,w){if(this._validate(d,w)){this.images.get(g).set(d.toString(),w);const j=this.imageVersions.get(g),I=j.get(d.toString())||0;j.set(d.toString(),I+1)}}_validate(d,g){let w=!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`))),w=!1),this._validateStretch(g.stretchY,g.data&&g.data.height)||(this.fire(new a.B(new Error(`Image "${d.name}" has invalid "stretchY" value`))),w=!1),this._validateContent(g.content,g)||(this.fire(new a.B(new Error(`Image "${d.name}" has invalid "content" value`))),w=!1),w}_validateStretch(d,g){if(!d)return!0;let w=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,w){const j=[],I=[],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)?I.push(Z):ne.addPendingRequest(Z))}if(j.length===0)return void this._notify(I,g,w);let F=!0;const z=!!this.loaded.get(g),H=this.images.get(g);if(!z)for(const Z of j)H.has(Z.toString())||(F=!1);z||F?this._notify(j,g,w):this.requestors.push({ids:j,scope:g,callback:w})}rasterizeImages(d,g){const w=new Map,{tasks:j,scope:I}=d;for(const[L,F]of j.entries()){const z=this.getImage(F.id,I);z&&w.set(L,{image:z,imageVariant:F})}this._rasterizeImages(I,w,g)}_rasterizeImages(d,g,w){if(a.y())this.imageRasterizerDispatcher.getActor().send("rasterizeImagesWorker",{tasks:g,scope:d},w);else{const j=new Map;for(const[I,{image:L,imageVariant:F}]of g.entries())j.set(I,this.imageRasterizer.rasterize(F,L,d,0));w(void 0,j)}}getUpdatedImages(d){return this.updatedImages.get(d)||new Set}_notify(d,g,w){const j=this.images.get(g),I=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}),I.set(a.I.toString(L),z)}w(null,{images:I,versions:this.getImageVersions(g)})}getPixelSize(d){const{width:g,height:w}=this.atlasImage.get(d);return{width:g,height:w}}getPattern(d,g,w){const j=d.toString(),I=this.patterns.get(g),L=I.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 H=new a.D(d).scaleSelf(a.o.devicePixelRatio),Z=new Map([[H.toString(),{image:F,imageVariant:H}]]);return this._rasterizeImages(g,Z,(ne,re)=>this.storePatternImage(H,g,F,w,re)),null}this.storePattern(d,g,F)}return this._updatePatternAtlas(g,w),I.get(j).position}getPatternInFlightId(d,g){return a.F(d,g)}hasPatternsInFlight(){return this.patternsInFlight.size!==0}storePatternImage(d,g,w,j,I){const L=d.toString(),F=I?I.get(L):void 0;F&&(w.data=F,this.storePattern(d.id,g,w),this._updatePatternAtlas(g,j),this.patternsInFlight.delete(this.getPatternInFlightId(d.id.toString(),g)))}storePattern(d,g,w){const j={w:w.data.width+2*a.G,h:w.data.height+2*a.G,x:0,y:0},I=new a.H(j,w,a.G);this.patterns.get(g).set(d.toString(),{bin:j,position:I})}destroyAtlasTextures(){for(const d of this.atlasTexture.values())d&&d.destroy();this.atlasTexture.clear()}bind(d,g){const w=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),w.RGBA8),this.atlasTexture.set(g,j)),j.bind(w.LINEAR,w.CLAMP_TO_EDGE)}_updatePatternAtlas(d,g){const w=this.patterns.get(d),j=Array.from(w.values()).map(({bin:H})=>H),{w:I,h:L}=a.J(j),F=this.atlasImage.get(d);F.resize({width:I||1,height:L||1});const z=this.images.get(d);for(const[H,{bin:Z,position:ne}]of w.entries()){let re=ne.padding;const ie=Z.x+re,ce=Z.y+re,oe=z.get(H).data,xe=oe.width,ye=oe.height;re=re>1?re-1:re,a.q.copy(oe,F,{x:0,y:0},{x:ie,y:ce},{width:xe,height:ye},g),a.q.copy(oe,F,{x:0,y:ye-re},{x:ie,y:ce-re},{width:xe,height:re},g),a.q.copy(oe,F,{x:0,y:0},{x:ie,y:ce+ye},{width:xe,height:re},g),a.q.copy(oe,F,{x:xe-re,y:0},{x:ie-re,y:ce},{width:re,height:ye},g),a.q.copy(oe,F,{x:0,y:0},{x:ie+xe,y:ce},{width:re,height:ye},g),a.q.copy(oe,F,{x:xe-re,y:ye-re},{x:ie-re,y:ce-re},{width:re,height:re},g),a.q.copy(oe,F,{x:0,y:ye-re},{x:ie+xe,y:ce-re},{width:re,height:re},g),a.q.copy(oe,F,{x:0,y:0},{x:ie+xe,y:ce+ye},{width:re,height:re},g),a.q.copy(oe,F,{x:xe-re,y:0},{x:ie-re,y:ce+ye},{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 w=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 I=w.get(j.toString());Je(I)&&this.updateImage(j,g,I)}}destroy(){this.imageRasterizerDispatcher&&this.imageRasterizerDispatcher.remove()}}function is(_){const d=_.value,g=_.valueSpec,w=_.style,j=_.styleSpec,I=_.key,L=_.arrayElementValidator||js;if(!Array.isArray(d))return[new a.V(I,d,`array expected, ${a.M(d)} found`)];if(g.length&&d.length!==g.length)return[new a.V(I,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 Ea(_){const d=_.key,g=_.value;if(!a.K(g))return[new a.V(d,g,`object expected, ${a.M(g)} found`)];const w=_.valueSpec,j=a.L(g.type);let I,L,F,z={};const H=j!=="categorical"&&g.property===void 0,Z=!H,ne=function(oe){const xe=oe.stops;return Array.isArray(xe)&&Array.isArray(xe[0])&&a.K(xe[0][0])}(g),re=Ci({key:_.key,value:_.value,valueSpec:_.styleSpec.function,style:_.style,styleSpec:_.styleSpec,objectElementValidators:{stops:function(oe){if(j==="identity")return[new a.V(oe.key,oe.value,'identity function may not have a "stops" property')];let xe=[];const ye=oe.value;return xe=xe.concat(is({key:oe.key,value:ye,valueSpec:oe.valueSpec,style:oe.style,styleSpec:oe.styleSpec,arrayElementValidator:ie})),Array.isArray(ye)&&ye.length===0&&xe.push(new a.V(oe.key,ye,"array must have at least one stop")),xe},default:function(oe){return js({key:oe.key,value:oe.value,valueSpec:w,style:oe.style,styleSpec:oe.styleSpec})}}});return j==="identity"&&H&&re.push(new a.V(_.key,_.value,'missing required property "property"')),j==="identity"||g.stops||re.push(new a.V(_.key,_.value,'missing required property "stops"')),j==="exponential"&&w.expression&&!a.O(w)&&re.push(new a.V(_.key,_.value,"exponential functions not supported")),_.styleSpec.$version>=8&&(Z&&!a.Q(w)?re.push(new a.V(_.key,_.value,"property functions not supported")):H&&!a.S(w)&&re.push(new a.V(_.key,_.value,"zoom functions not supported"))),j!=="categorical"&&!ne||g.property!==void 0||re.push(new a.V(_.key,_.value,'"property" property is required')),re;function ie(oe){let xe=[];const ye=oe.value,Pe=oe.key;if(!Array.isArray(ye))return[new a.V(Pe,ye,`array expected, ${a.M(ye)} found`)];if(ye.length!==2)return[new a.V(Pe,ye,`array length 2 expected, length ${ye.length} found`)];if(ne){if(!a.K(ye[0]))return[new a.V(Pe,ye,`object expected, ${a.M(ye[0])} found`)];const Me=ye[0];if(Me.zoom===void 0)return[new a.V(Pe,ye,"object stop key must have zoom")];if(Me.value===void 0)return[new a.V(Pe,ye,"object stop key must have value")];const Se=a.L(Me.zoom);if(typeof Se!="number")return[new a.V(Pe,Me.zoom,"stop zoom values must be numbers")];if(F&&F>Se)return[new a.V(Pe,Me.zoom,"stop zoom values must appear in ascending order")];Se!==F&&(F=Se,L=void 0,z={}),xe=xe.concat(Ci({key:`${Pe}[0]`,value:ye[0],valueSpec:{zoom:{}},style:oe.style,styleSpec:oe.styleSpec,objectElementValidators:{zoom:Us,value:ce}}))}else xe=xe.concat(ce({key:`${Pe}[0]`,value:ye[0],style:oe.style,styleSpec:oe.styleSpec},ye));return a.U(a.W(ye[1]))?xe.concat([new a.V(`${Pe}[1]`,ye[1],"expressions are not allowed in function stops.")]):xe.concat(js({key:`${Pe}[1]`,value:ye[1],valueSpec:w,style:oe.style,styleSpec:oe.styleSpec}))}function ce(oe,xe){const ye=a.M(oe.value),Pe=a.L(oe.value),Me=oe.value!==null?oe.value:xe;if(I){if(ye!==I)return[new a.V(oe.key,Me,`${ye} stop domain type must match previous stop domain type ${I}`)]}else I=ye;if(ye!=="number"&&ye!=="string"&&ye!=="boolean"&&typeof Pe!="number"&&typeof Pe!="string"&&typeof Pe!="boolean")return[new a.V(oe.key,Me,"stop domain value must be a number, string, or boolean")];if(ye!=="number"&&j!=="categorical"){let Se=`number expected, ${ye} found`;return a.Q(w)&&j===void 0&&(Se+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new a.V(oe.key,Me,Se)]}return j!=="categorical"||ye!=="number"||typeof Pe=="number"&&isFinite(Pe)&&Math.floor(Pe)===Pe?j!=="categorical"&&ye==="number"&&typeof Pe=="number"&&typeof L=="number"&&L!==void 0&&Penew a.V(`${_.key}${w.key}`,_.value,w.message));const g=d.value.expression||d.value._styleExpression.expression;if(_.expressionContext==="property"&&_.propertyKey==="text-font"&&!g.outputDefined())return[new a.V(_.key,_.value,`Invalid data expression for "${_.propertyKey}". Output values must be contained as literals within the expression.`)];if(_.expressionContext==="property"&&_.propertyType==="layout"&&!a.$(g))return[new a.V(_.key,_.value,'"feature-state" data expressions are not supported with layout properties.')];if(_.expressionContext==="filter")return ua(g,_);if(_.expressionContext==="appearance")return Nr(g,_);if(_.expressionContext&&_.expressionContext.indexOf("cluster")===0){if(!a.Z(g,["zoom","feature-state"]))return[new a.V(_.key,_.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if(_.expressionContext==="cluster-initial"&&!a._(g))return[new a.V(_.key,_.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function ua(_,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 w=[];return _ instanceof a.a0&&g.has(_.name)?[new a.V(d.key,d.value,`["${_.name}"] expression is not supported in a filter for a ${d.object.type} layer with id: ${d.object.id}`)]:(_.eachChild(j=>{w.push(...ua(j,d))}),w)}function Nr(_,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 w=[];return _ instanceof a.a0&&!g.has(_.name)?[new a.V(d.key,d.value,`["${_.name}"] is not an allowed parameter`)]:(_.eachChild(j=>{w.push(...Nr(j,d))}),w)}function qn(_){const d=_.key,g=_.value,w=_.valueSpec,j=[];return Array.isArray(w.values)?w.values.indexOf(a.L(g))===-1&&j.push(new a.V(d,g,`expected one of [${w.values.join(", ")}], ${JSON.stringify(g)} found`)):Object.keys(w.values).indexOf(a.L(g))===-1&&j.push(new a.V(d,g,`expected one of [${Object.keys(w.values).join(", ")}], ${JSON.stringify(g)} found`)),j}function Yi(_){return a.a4(a.W(_.value))?vs(Object.assign({},_,{expressionContext:"filter",valueSpec:_.styleSpec[`filter_${_.layerType||"fill"}`]})):ja(_)}function ja(_){const d=_.value,g=_.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 w=_.styleSpec;let j=qn({key:`${g}[0]`,value:d[0],valueSpec:w.filter_operator});const I=()=>{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`)),I();break;case"==":case"!=":d.length!==3&&j.push(new a.V(g,d,`filter array for operator "${d[0]}" must have 3 elements`)),I();break;case"in":case"!in":I();break;case"any":case"all":case"none":for(let L=1;L{H in g&&d.push(new a.V(w,g[H],`"${H}" is prohibited for ref layers`))}),j.layers.forEach(H=>{a.L(H.id)===F&&(z=H)}),z?z.ref?d.push(new a.V(w,g.ref,"ref cannot reference another ref layer")):L=a.L(z.type):typeof F=="string"&&d.push(new a.V(w,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],H=z&&a.L(z.type);z?H==="vector"&&L==="raster"?d.push(new a.V(w,g.source,`layer "${g.id}" requires a raster source`)):H==="raster"&&L!=="raster"?d.push(new a.V(w,g.source,`layer "${g.id}" requires a vector source`)):H!=="vector"||g["source-layer"]?H==="raster-dem"&&L!=="hillshade"?d.push(new a.V(w,g.source,"raster-dem source can only be used with layer type 'hillshade'.")):H!=="raster-array"||["raster","raster-particle"].includes(L)?L==="line"&&g.paint&&(g.paint["line-gradient"]||g.paint["line-trim-offset"])&&H==="geojson"&&!z.lineMetrics?d.push(new a.V(w,g,`layer "${g.id}" specifies a line-gradient, which requires the GeoJSON source to have \`lineMetrics\` enabled.`)):L==="raster-particle"&&H!=="raster-array"&&d.push(new a.V(w,g.source,`layer "${g.id}" requires a 'raster-array' source.`)):d.push(new a.V(w,g.source,"raster-array source can only be used with layer type 'raster'.")):d.push(new a.V(w,g,`layer "${g.id}" must specify a "source-layer"`)):d.push(new a.V(w,g.source,`source "${g.source}" not found`))}else d.push(new a.V(`${w}.source`,g.source,'"source" must be a string'));else d.push(new a.V(w,g,'missing required property "source"'));return d=d.concat(Ci({key:w,value:g,valueSpec:I.layer,style:_.style,styleSpec:_.styleSpec,objectElementValidators:{"*":()=>[],type:()=>js({key:`${w}.type`,value:g.type,valueSpec:I.layer.type,style:_.style,styleSpec:_.styleSpec,object:g,objectKey:"type"}),filter:z=>Yi(Object.assign({layerType:L},z)),layout:z=>Ci({layer:g,key:z.key,value:z.value,valueSpec:{},style:z.style,styleSpec:z.styleSpec,objectElementValidators:{"*":H=>fn(Object.assign({layerType:L},H))}}),paint:z=>Ci({layer:g,key:z.key,value:z.value,valueSpec:{},style:z.style,styleSpec:z.styleSpec,objectElementValidators:{"*":H=>Zr(Object.assign({layerType:L,layer:g},H))}}),appearances(z){const H=is({key:z.key,value:z.value,valueSpec:z.valueSpec,style:z.style,styleSpec:z.styleSpec,arrayElementValidator:re=>function(ie){const{key:ce,layer:oe,layerType:xe}=ie,ye=a.L(ie.value),Pe=a.L(ye.name),Me=a.L(ye.condition),Se=Ci({key:ce,value:ye,valueSpec:ie.styleSpec.appearance,style:ie.style,styleSpec:ie.styleSpec,objectElementValidators:{condition:Ze=>function($e){const Ke=[];return Ke.push(...vs({key:$e.key,value:$e.object.condition,valueSpec:a.a8.appearance.condition,expressionContext:"appearance"})),Ke}(Object.assign({layer:oe,layerType:xe},Ze)),properties:Ze=>function($e){const Ke=[],{styleSpec:De,layer:Be,layerType:Ge}=$e,at=De[`paint_${Ge}`],Qe=De[`layout_${Ge}`],xt=$e.object[$e.objectKey];for(const ft in xt){const Lt=ft in at?"paint":ft in Qe?"layout":void 0;if(!Lt){Ke.push(new a.V($e.key,ft,`unknown property "${ft}" for layer type "${Ge}"`));continue}const Bt=Object.assign({},$e,{key:`${$e.key}.${ft}`,object:xt,objectKey:ft,layer:Be,layerType:Ge,value:xt[ft],valueSpec:Lt==="paint"?at[ft]:Qe[ft]});Ke.push(...So(Bt,Lt))}return Ke}(Object.assign({layer:oe,layerType:xe},Ze))}});return Pe!=="hidden"&&Me===void 0&&Se.push(new a.V(ie.key,"name",'Appearance with name different than "hidden" must have a condition')),Se}(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 oe=a.L(g.id);H.push(new a.V(z.key,ce,`Duplicated appearance name "${ce}" for layer "${oe}"`))}else ne.add(ce)}),H}}})),d}function Xr({key:_,value:d}){return a.a2(d)?[]:[new a.V(_,d,`string expected, ${a.M(d)} found`)]}const ds={promoteId:function _({key:d,value:g}){if(a.a2(g))return Xr({key:d,value:g});if(Array.isArray(g)){const j=[],I=a.W(g),L=a.X(I);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 w=[];for(const j in g)w.push(..._({key:`${d}.${j}`,value:g[j]}));return w}};function en(_){const d=_.value,g=_.key,w=_.styleSpec,j=_.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 I=a.L(d.type);let L=[];switch(["vector","raster","raster-dem","raster-array"].includes(I)&&("url"in d||"tiles"in d||L.push(new a.a5(g,d,'Either "url" or "tiles" is required.'))),I){case"vector":case"raster":case"raster-dem":case"raster-array":return L=L.concat(Ci({key:g,value:d,valueSpec:w[`source_${I.replace("-","_")}`],style:_.style,styleSpec:w,objectElementValidators:ds})),L;case"geojson":if(L=Ci({key:g,value:d,valueSpec:w.source_geojson,style:j,styleSpec:w,objectElementValidators:ds}),"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[H,Z]=z,ne=typeof H=="string"?[H,["accumulated"],["get",F]]:H;L.push(...vs({key:`${g}.${F}.map`,value:Z,expressionContext:"cluster-map"})),L.push(...vs({key:`${g}.${F}.reduce`,value:ne,expressionContext:"cluster-reduce"}))}}return L;case"video":return Ci({key:g,value:d,valueSpec:w.source_video,style:j,styleSpec:w});case"image":return Ci({key:g,value:d,valueSpec:w.source_image,style:j,styleSpec:w});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 qn({key:`${g}.type`,value:d.type,valueSpec:{values:Fn(w)}})}}function Fn(_){return _.source.reduce((d,g)=>{const w=_[g];return w.type.type==="enum"&&(d=d.concat(Object.keys(w.type.values||{}))),d},[])}function ti(_){const d=_.value,g=_.styleSpec,w=g.light,j=_.style;if(d===void 0)return[];if(!a.K(d))return[new a.V("light",d,`object expected, ${a.M(d)} found`)];let I=[];for(const L in d){const F=L.match(/^(.*)-transition$/),z=L.match(/^(.*)-use-theme$/);I=I.concat(z&&w[z[1]]?js({key:L,value:d[L],valueSpec:{type:"string"},style:j,styleSpec:g}):F&&w[F[1]]&&w[F[1]].transition?js({key:L,value:d[L],valueSpec:g.transition,style:j,styleSpec:g}):w[L]?js({key:L,value:d[L],valueSpec:w[L],style:j,styleSpec:g}):[new a.V(L,d[L],`unknown property "${L}"`)])}return I}function bl(_){const d=_.value;if(!d)return[];const g=_.key;if(!a.K(d))return[new a.V(g,d,`object expected, ${a.M(d)} found`)];let w=[];const j=_.styleSpec,I=j["light-3d"],L=_.style,F=_.style.lights;for(const Z of["type","id"])if(!(Z in d))return w=w.concat([new a.V(g,d,`missing property "${Z}"`)]),w;if(!a.a2(d.type))return w=w.concat([new a.V(`${g}.type`,d.type,"string expected")]),w;if(F)for(let Z=0;Z<_.arrayIndex;Z++){const ne=a.L(d.type),re=F[Z];a.L(re.type)===ne&&w.push(new a.V(g,d.id,`duplicate light type "${d.type}", previously defined at line ${re.id.__line__}`))}const z=`properties_light_${d.type}`;if(!(z in j))return w=w.concat([new a.V(`${g}.type`,d,`Invalid light type ${d.type}`)]),w;const H=j[z];for(const Z in d)if(Z==="properties"){const ne=d[Z];if(!a.K(ne))return w=w.concat([new a.V("properties",ne,`object expected, ${a.M(ne)} found`)]),w;for(const re in ne){const ie=re.match(/^(.*)-transition$/),ce=re.match(/^(.*)-use-theme$/);w=w.concat(ce&&H[ce[1]]?js({key:Z,value:ne[re],valueSpec:{type:"string"},style:L,styleSpec:j}):ie&&H[ie[1]]&&H[ie[1]].transition?js({key:Z,value:d[Z],valueSpec:j.transition,style:L,styleSpec:j}):H[re]?js({key:re,value:ne[re],valueSpec:H[re],style:L,styleSpec:j}):[new a.a5(_.key,ne[re],`unknown property "${re}"`)])}}else w=w.concat(I[Z]?js({key:Z,value:d[Z],valueSpec:I[Z],style:L,styleSpec:j}):[new a.a5(Z,d[Z],`unknown property "${Z}"`)]);return w}function el(_){const d=_.value,g=_.key,w=_.style,j=_.styleSpec,I=j.terrain;if(d==null)return[];if(!a.K(d))return[new a.V("terrain",d,`object expected, ${a.M(d)} found`)];let L=[];for(const F in d){const z=F.match(/^(.*)-transition$/),H=F.match(/^(.*)-use-theme$/);L=L.concat(H&&I[H[1]]?js({key:F,value:d[F],valueSpec:{type:"string"},style:w,styleSpec:j}):z&&I[z[1]]&&I[z[1]].transition?js({key:F,value:d[F],valueSpec:j.transition,style:w,styleSpec:j}):I[F]?js({key:F,value:d[F],valueSpec:I[F],style:w,styleSpec:j}):[new a.a5(F,d[F],`unknown property "${F}"`)])}if(d.source)if(a.a2(d.source)){const F=w.sources&&w.sources[d.source],z=F&&a.L(F.type);F?z!=="raster-dem"&&L.push(new a.V(`${g}.source`,d.source,`terrain cannot be used with a source of type ${z}, it only be used with a "raster-dem" source type`)):L.push(new a.V(`${g}.source`,d.source,`source "${d.source}" not found`))}else L.push(new a.V(`${g}.source`,d.source,"source must be a string"));else L.push(new a.V(g,d,'terrain is missing required property "source"'));return L}function Ft(_){const d=_.value,g=_.style,w=_.styleSpec,j=w.fog;if(d===void 0)return[];if(!a.K(d))return[new a.V("fog",d,`object expected, ${a.M(d)} found`)];let I=[];for(const L in d){const F=L.match(/^(.*)-transition$/),z=L.match(/^(.*)-use-theme$/);I=I.concat(z&&j[z[1]]?js({key:L,value:d[L],valueSpec:{type:"string"},style:g,styleSpec:w}):F&&j[F[1]]&&j[F[1]].transition?js({key:L,value:d[L],valueSpec:w.transition,style:g,styleSpec:w}):j[L]?js({key:L,value:d[L],valueSpec:j[L],style:g,styleSpec:w}):[new a.a5(L,d[L],`unknown property "${L}"`)])}return I}const Bo={"*":()=>[],array:is,boolean:function(_){const d=_.value,g=_.key;return a.a1(d)?[]:[new a.V(g,d,`boolean expected, ${a.M(d)} found`)]},number:Us,color:function({key:_,value:d}){return a.a2(d)?a.a3.parseCSSColor(d)===null?[new a.V(_,d,`color expected, "${d}" found`)]:[]:[new a.V(_,d,`color expected, ${a.M(d)} found`)]},enum:qn,filter:Yi,function:Ea,layer:xn,object:Ci,source:en,model:a.a9,light:ti,"light-3d":bl,terrain:el,fog:Ft,string:Xr,formatted:function(_){return Xr(_).length===0?[]:vs(_)},resolvedImage:function(_){return Xr(_).length===0?[]:vs(_)},projection:function(_){const d=_.value,g=_.styleSpec,w=g.projection,j=_.style;if(a.K(d)){let I=[];for(const L in d)I=I.concat(js({key:L,value:d[L],valueSpec:w[L],style:j,styleSpec:g}));return I}return a.a2(d)?[]:[new a.V("projection",d,`object or string expected, ${a.M(d)} found`)]},import:function(_){const d=_.key,{value:g,styleSpec:w}=_;if(!a.K(g))return[new a.V(d,g,"import must be an object")];const{data:j,...I}=g;Object.defineProperty(I,"__line__",{value:g.__line__,enumerable:!1});let L=Ci(Object.assign({},_,{value:I,valueSpec:w.import}));return a.L(I.id)===""&&L.push(new a.V(`${_.key}.id`,I,"import id can't be an empty string")),j&&(L=L.concat(mo(j,w,{key:`${_.key}.data`}))),L},iconset:function(_){const d=_.value,g=_.key,w=_.styleSpec,j=_.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 I=a.L(d.type);let L=[];if(L=L.concat(Ci({key:g,value:d,valueSpec:w[`iconset_${I}`],style:j,styleSpec:w})),function(F,z){return!(F!=="source"||!z.source)}(I,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 js(_,d=!1){const g=_.value,w=_.valueSpec,j=_.styleSpec;if(w.expression){if(a.a6(a.L(g)))return Ea(_);if(a.U(a.W(g)))return vs(_)}if(w.type&&Bo[w.type]){const I=Bo[w.type](_);return d===!0&&I.length>0&&Array.isArray(_.value)?vs(_):I}return Ci(Object.assign({},_,{valueSpec:w.type?j[w.type]:w}))}function Ci(_){const d=_.key,g=_.value,w=_.valueSpec||{},j=_.objectElementValidators||{},I=_.style,L=_.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 H=z.split(".")[0];let Z;j[H]?Z=j[H]:w[H]?Z=js:j["*"]?Z=j["*"]:w["*"]&&(Z=js),Z?F=F.concat(Z({key:(d&&`${d}.`)+z,value:g[z],valueSpec:w[H]||w["*"],style:I,styleSpec:L,object:g,objectKey:z},g)):F.push(new a.a5(d,g[z],`unknown property "${z}"`))}for(const z in w){if(j[z])continue;const H=w[z];H.required&&H.default===void 0&&g[z]===void 0&&F.push(new a.V(d,g,`missing required property "${z}"`))}return F}function Xn({key:_,value:d}){const g=Xr({key:_,value:d});if(g.length)return g;const w=d;return w.indexOf("{fontstack}")===-1&&g.push(new a.V(_,d,'"glyphs" url must include a "{fontstack}" token')),w.indexOf("{range}")===-1&&g.push(new a.V(_,d,'"glyphs" url must include a "{range}" token')),g}function mo(_,d=a.a8,g={}){return Ci({key:g.key||"",value:_,valueSpec:Object.assign(d.$root,{"*":{type:"*"}}),styleSpec:d,style:_,objectElementValidators:{glyphs:Xn}})}function du(_,d=a.a8){return Rt(mo(_,d))}const e0=_=>Rt(en(_)),ut=_=>Rt(ti(_)),de=_=>Rt(bl(_)),fe=_=>Rt(el(_)),Oe=_=>Rt(Ft(_)),Ye=_=>Rt(function(d){const g=d.value,w=d.style,j=d.styleSpec,I=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&&I[z[1]]&&I[z[1]].transition?js({key:F,value:g[F],valueSpec:j.transition,style:w,styleSpec:j}):I[F]?js({key:F,value:g[F],valueSpec:I[F],style:w,styleSpec:j}):[new a.a5(F,g[F],`unknown property "${F}"`)])}return L}(_)),et=_=>Rt(function(d){const g=d.value,w=d.style,j=d.styleSpec,I=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&&I[z[1]]&&I[z[1]].transition?js({key:F,value:g[F],valueSpec:j.transition,style:w,styleSpec:j}):I[F]?js({key:F,value:g[F],valueSpec:I[F],style:w,styleSpec:j}):[new a.a5(F,g[F],`unknown property "${F}"`)])}return L}(_)),rt=_=>Rt(xn(_)),dt=_=>Rt(Yi(_)),it=_=>Rt(Zr(_)),ht=_=>Rt(fn(_)),Ut=_=>Rt(a.a9(_));function Rt(_){return _.slice().sort((d,g)=>d.line&&g.line?d.line-g.line:0)}function dr(_,d){let g=!1;if(d&&d.length)for(const w of d)w instanceof a.a5?a.w(w.message):(_.fire(new a.B(new Error(w.message))),g=!0);return g}const Br=a.a8.light;let Gr;class $r extends a.E{constructor(d,g="flat"){super(),this._transitionable=new a.aa(Gr||(Gr=new a.ab({anchor:new a.ac(Br.anchor),position:new a.ad(Br.position),color:new a.ac(Br.color),intensity:new a.ac(Br.intensity)}))),this.setLight(d,g),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(d,g,w={}){this._validate(ut,d,w)||(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,w){return(!w||w.validate!==!1)&&dr(this,d.call(du,Object.assign({value:g,style:{glyphs:!0,sprite:!0},styleSpec:a.a8})))}}const on=a.a8.terrain;let Nn=class extends a.E{constructor(_,d,g,w,j){super(),this.scope=g,this._transitionable=new a.aa(new a.ab({source:new a.ac(on.source),exaggeration:new a.ac(on.exaggeration)}),g,w),this._transitionable.setTransitionOrValue(_,w),this._transitioning=this._transitionable.untransitioned(),this.drapeRenderMode=d,this.worldview=j}get(){return this._transitionable.serialize()}set(_,d){this._transitionable.setTransitionOrValue(_,d)}updateTransitions(_){this._transitioning=this._transitionable.transitioned(_,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(_){this.properties=this._transitioning.possiblyEvaluate(_)}getExaggeration(_){return this._transitioning.possiblyEvaluate(new a.ae(_,{worldview:this.worldview})).get("exaggeration")}getAttenuationRange(){if(!this.isZoomDependent())return null;const _=this._transitionable._values.exaggeration;if(!_)return null;const d=_.value.expression;if(!d)return null;let g=-1,w=-1,j=1;for(const I of d.zoomStops)j=d.evaluate(new a.ae(I,{worldview:this.worldview})),j>.01?(g=I,w=-1):w=I;return j<.01&&g>0&&w>g?[g,w]:null}isZoomDependent(){const _=this._transitionable._values.exaggeration;return _!=null&&_.value!=null&&_.value.expression!=null&&_.value.expression instanceof a.af}};const Ln=.05;function Ms(_,d,g,w){const j=a.aj(45,65,g),[I,L]=Fi(_,w);let F=1-Math.min(1,Math.exp((d-I)/(L-I)*-6));return F*=F*F,F=Math.min(1,1.00747*F),F*j*_.alpha}function Fi(_,d){const g=.5/Math.tan(.5*d);return[_.range[0]+g,_.range[1]+g]}function Ii(_,d,g,w,j){const I=a.ah([],[d,g,w],j.mercatorFogMatrix);return Ms(_,a.ai(I),j.pitch,j._fov)}function yi(_,d,g,w,j,I,L){const F=[[g,w,0],[j,w,0],[j,I,0],[g,I,0]];let z=Number.MAX_VALUE,H=-Number.MAX_VALUE;for(const Z of F){const ne=a.ah([],Z,d),re=a.ai(ne);z=Math.min(z,re),H=Math.max(H,re)}return[Ms(_,z,L.pitch,L._fov),Ms(_,H,L.pitch,L._fov)]}const bs=a.a8.fog;class ai extends a.E{constructor(d,g,w,j){super();const I=new a.ab({range:new a.ac(bs.range),color:new a.ac(bs.color),"color-use-theme":new a.ac({type:"string","property-type":"data-constant",default:"default"}),"high-color":new a.ac(bs["high-color"]),"high-color-use-theme":new a.ac({type:"string","property-type":"data-constant",default:"default"}),"space-color":new a.ac(bs["space-color"]),"space-color-use-theme":new a.ac({type:"string","property-type":"data-constant",default:"default"}),"horizon-blend":new a.ac(bs["horizon-blend"]),"star-intensity":new a.ac(bs["star-intensity"]),"vertical-range":new a.ac(bs["vertical-range"])});this._transitionable=new a.aa(I,w,new Map(j)),this.set(d,j),this._transitioning=this._transitionable.untransitioned(),this._transform=g,this.properties=new a.ak(I),this.scope=w}get state(){const d=this._transform,g=d.projection.name==="globe",w=a.al(d.zoom),j=this.properties.get("range"),I=[.5,3];return{range:g?[a.am(I[0],j[0],w),a.am(I[1],j[1],w)]:j,horizonBlend:this.properties.get("horizon-blend"),alpha:this.properties.get("color").a}}get(){return this._transitionable.serialize()}set(d,g,w={}){if(this._validate(Oe,d,w))return;const j=Object.assign({},d);for(const I of Object.keys(bs))j[I]===void 0&&(j[I]=bs[I].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(w,j,I){const L=a.ag.fromLngLat(j),F=I.elevation?I.elevation.getAtPointOrZero(L):0;return Ii(w,L.x,L.y,F,I)}(this.state,d,g):0}getOpacityForTile(d){if(!this._transform.projection.supportsFog)return[1,1];const g=this._transform.calculateFogTileMatrix(d.toUnwrapped());return yi(this.state,g,0,0,a.an,a.an,this._transform)}getOpacityForBounds(d,g,w,j,I){return this._transform.projection.supportsFog?yi(this.state,d,g,w,j,I,this._transform):[1,1]}getFovAdjustedRange(d){return this._transform.projection.supportsFog?Fi(this.state,d):[0,1]}isVisibleOnFrustum(d){if(!this._transform.projection.supportsFog)return!1;const g=[4,5,6,7];for(const w of g){const j=d.points[w];let I;if(j[2]>=0)I=j;else{const L=d.points[w-4];I=a.ao(L,j,L[2]/(L[2]-j[2]))}if(Ii(this.state,I[0],I[1],0,this._transform)>=Ln)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,w){return(!w||w.validate!==!1)&&dr(this,d.call(du,Object.assign({value:g,style:{glyphs:!0,sprite:!0},styleSpec:a.a8})))}}let da,Ds,oi,xi=class extends a.E{constructor(_,d,g,w){super();const j=da||(da=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(w)),this.set(_,w),this._transitioning=this._transitionable.untransitioned(),this.properties=new a.ak(j),this.scope=g}get state(){const _=this.properties.get("opacity"),d=this.properties.get("color"),g=this.properties.get("direction"),w=a.ap(g[0]),j=-Math.max(a.ap(g[1]),.01),I=[Math.cos(w)*Math.cos(j),Math.sin(w)*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*_),direction:I,centerThinning:this.properties.get("center-thinning"),flakeSize:this.properties.get("flake-size"),vignetteColor:F}}get(){return this._transitionable.serialize()}set(_,d,g={}){if(this._validate(Ye,_,g))return;const w=Object.assign({},_),j=a.a8.snow;for(const I of Object.keys(j))w[I]===void 0&&(w[I]=j[I].default);this._options=w,this._transitionable.setTransitionOrValue(this._options,d)}updateConfig(_){this._transitionable.setTransitionOrValue(this._options,new Map(_))}updateTransitions(_){this._transitioning=this._transitionable.transitioned(_,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(_){this.properties=this._transitioning.possiblyEvaluate(_)}_validate(_,d,g){return(!g||g.validate!==!1)&&dr(this,_.call(du,Object.assign({value:d,style:{glyphs:!0,sprite:!0},styleSpec:a.a8})))}},Dn=class extends a.E{constructor(_,d,g,w){super();const j=Ds||(Ds=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(w)),this.set(_,w),this._transitioning=this._transitionable.untransitioned(),this.properties=new a.ak(j),this.scope=g}get state(){const _=this.properties.get("opacity"),d=this.properties.get("color"),g=this.properties.get("direction"),w=a.ap(g[0]),j=-Math.max(a.ap(g[1]),.01),I=[Math.cos(w)*Math.cos(j),Math.sin(w)*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*_),direction:I,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(_,d,g={}){if(this._validate(et,_,g))return;const w=Object.assign({},_),j=a.a8.rain;for(const I of Object.keys(j))w[I]===void 0&&(w[I]=j[I].default);this._options=w,this._transitionable.setTransitionOrValue(this._options,d)}updateConfig(_){this._transitionable.setTransitionOrValue(this._options,new Map(_))}updateTransitions(_){this._transitioning=this._transitionable.transitioned(_,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(_){this.properties=this._transitioning.possiblyEvaluate(_)}_validate(_,d,g){return(!g||g.validate!==!1)&&dr(this,_.call(du,Object.assign({value:d,style:{glyphs:!0,sprite:!0},styleSpec:a.a8})))}};class Aa extends a.E{constructor(d,g,w,j){super(),this.scope=w,this._options=d,this.properties=new a.ak(g),this._transitionable=new a.aa(g,w,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 To=()=>oi||(oi=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 po;const cc=()=>po||(po=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 uc{constructor(d,g,w){this.screenBounds=d,this.cameraPoint=w.getCameraPoint(),this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=g,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this._bufferedScreenMercator(0,w)}static createFromScreenPoints(d,g){let w,j;if(d instanceof a.P||typeof d[0]=="number"){const I=a.P.convert(d);w=[I],j=g.isPointAboveHorizon(I)}else{const I=a.P.convert(d[0]),L=a.P.convert(d[1]),F=I.add(L)._div(2);w=[I,L],j=a.as(I,L).every(z=>g.isPointAboveHorizon(z))&&g.isPointAboveHorizon(F)}return new uc(w,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],w=this.screenBounds.length===1?this.screenBounds[0].add(new a.P(1,1)):this.screenBounds[1],j=a.as(g,w,0,!1);return this.cameraPoint.y>w.y&&(this.cameraPoint.x>g.x&&this.cameraPoint.x=w.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],w=this.screenBounds.length===1?this.screenBounds[0].add(new a.P(1,1)):this.screenBounds[1],j=a.as(g,w,d),I=this.cameraPoint.clone(),L=+(I.x>g.x)+ +(I.x>w.x);switch(3*(+(I.y>g.y)+ +(I.y>w.y))+L){case 0:j[0]=I,j[4]=I.clone();break;case 1:j.splice(1,0,I);break;case 2:j[1]=I;break;case 3:j.splice(4,0,I);break;case 5:j.splice(2,0,I);break;case 6:j[3]=I;break;case 7:j.splice(3,0,I);break;case 8:j[2]=I}return j}containsTile(d,g,w,j=0){const I=Math.max(d.queryPadding,d.evaluateQueryRenderedFeaturePadding())/g._pixelsPerMercatorPixel+1,L=w?this._bufferedCameraMercator(I,g):this._bufferedScreenMercator(I,g);let F=d.tileID.wrap+(L.unwrapped?j:0);const z=L.polygon.map(xe=>a.au(d.tileTransform,xe,F));if(!a.av(z,0,0,a.an,a.an))return;F=d.tileID.wrap+(this.screenGeometryMercator.unwrapped?j:0);const H=this.screenGeometryMercator.polygon.map(xe=>a.aw(d.tileTransform,xe,F)),Z=H.map(xe=>new a.P(xe[0],xe[1])),ne=g.getFreeCameraOptions().position||new a.ag(0,0,0),re=a.aw(d.tileTransform,ne,F),ie=H.map(xe=>{const ye=a.ax(xe,xe,re);return a.ay(ye,ye),new a.az(re,ye)}),ce=a.aA(d,1,g.zoom)*g._pixelsPerMercatorPixel;return{queryGeometry:this,tilespaceGeometry:Z,tilespaceRays:ie,bufferedTilespaceGeometry:z,bufferedTilespaceBounds:(oe=a.aB(z),oe.min.x=a.aC(oe.min.x,0,a.an),oe.min.y=a.aC(oe.min.y,0,a.an),oe.max.x=a.aC(oe.max.x,0,a.an),oe.max.y=a.aC(oe.max.y,0,a.an),oe),tile:d,tileID:d.tileID,pixelToTileUnitsFactor:ce};var oe}_bufferedScreenMercator(d,g){const w=dc(d);if(this._screenRaycastCache[w])return this._screenRaycastCache[w];{let j;return j=g.projection.name==="globe"?this._projectAndResample(this.bufferedScreenGeometry(d),g):{polygon:this.bufferedScreenGeometry(d).map(I=>g.pointCoordinate3D(I)),unwrapped:!0},this._screenRaycastCache[w]=j,j}}_bufferedCameraMercator(d,g){const w=dc(d);if(this._cameraRaycastCache[w])return this._cameraRaycastCache[w];{let j;return j=g.projection.name==="globe"?this._projectAndResample(this.bufferedCameraGeometryGlobe(d),g):{polygon:this.bufferedCameraGeometry(d).map(I=>g.pointCoordinate3D(I)),unwrapped:!0},this._cameraRaycastCache[w]=j,j}}_projectAndResample(d,g){const w=function(I,L){const F=a.aD([],L.pixelMatrix,L.globeMatrix),z=[0,-a.aF,0,1],H=[0,a.aF,0,1],Z=[0,0,0,1];a.aE(z,z,F),a.aE(H,H,F),a.aE(Z,Z,F);const ne=new a.P(z[0]/z[3],z[1]/z[3]),re=new a.P(H[0]/H[3],H[1]/H[3]),ie=a.aG(I,ne)&&z[3]1?Nd(I.slice(0,xe),L):[],Me=xenew a.P(wl(Ke.x),Ke.y)),Me=Me.map(Ke=>new a.P(wl(Ke.x),Ke.y));const Se=[...Pe];Se.length===0&&Se.push(Me[Me.length-1]);const Ze=a.am(Se[Se.length-1].y,(Me.length===0?Pe[0]:Me[0]).y,ye);let $e;return $e=ie?[new a.P(0,Ze),new a.P(0,0),new a.P(1,0),new a.P(1,Ze)]:[new a.P(1,Ze),new a.P(1,1),new a.P(0,1),new a.P(0,Ze)],Se.push(...$e),Me.length===0?Se.push(Pe[0]):Se.push(...Me),{polygon:Se.map(Ke=>new a.ag(Ke.x,Ke.y)),unwrapped:!1}}(d,g);if(w)return w;const j=function(I,L){let F=!1,z=-1/0,H=0;for(let ne=0;nez&&(z=I[ne].x,H=ne);for(let ne=0;ne.5&&(ie.x{ne.x-=1}),{polygon:I,unwrapped:F}}(Nd(d,g).map(I=>new a.P(wl(I.x),I.y)),g);return{polygon:j.polygon.map(I=>new a.ag(I.x,I.y)),unwrapped:j.unwrapped}}}function Nd(_,d){return a.aI(_,g=>{const w=d.pointCoordinate3D(g);g.x=w.x,g.y=w.y},1/256)}function wl(_){return _<0?1+_%1:_%1}function dc(_){return 100*_|0}function Cd(_,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 I of j.variants){if(I==null||typeof I!="object"||I.constructor!==Object)throw new Error("variant must be an object");if(!Array.isArray(I.capabilities))throw new Error("capabilities must be an array");if(I.capabilities.length===1&&I.capabilities[0]==="meshopt")return Object.assign(j,I)}return j}(d)}catch(j){return new Error("Failed to process TileJSON variants",{cause:j})}const w=a.aJ(Object.assign({},d,_),["tilejson","tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","extra_bounds","scheme","tileSize","encoding","vector_layers","raster_layers","worldview_options","worldview_default","worldview"]);return _.url&&d.tiles&&_.tiles&&(w.tiles=d.tiles),w.tiles=g.canonicalizeTileset(w,_.url),w}function Nc(_,d,g,w,j){const I=function(F,z){if(F)return j(F);if(z){_.url&&z.tiles&&_.tiles&&delete _.tiles;const H=Cd(_,z,d);if(H instanceof Error)return j(H);j(null,H)}},L=function(F,z,H){if(!F)return null;if(!z&&!H)return F;H=H||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===H);return re&&ie?F:z in(F.language_options||{})||H in(F.worldview_options||{})?null:F.language_options&&F.worldview_options?F:null}(_.data,g,w);return L?a.o.frame(()=>I(null,L)):_.url?a.m(d.transformRequest(d.normalizeSourceURL(_.url,null,g,w),a.R.Source),I):a.o.frame(()=>{const{data:F,...z}=_;I(null,z)})}function Id(_,d){const g=Math.pow(2,d.z),w=Math.floor(a.aH(_.getWest())*g),j=Math.floor(a.aL(_.getNorth())*g),I=Math.ceil(a.aH(_.getEast())*g),L=Math.ceil(a.aL(_.getSouth())*g);return d.x>=w&&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}`),w&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${w}`),this.fire(new a.B(L))):F&&(this._setTileJSON(F),nt(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 I=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 H;try{H=new URL(z,a.g.API_URL).href}catch{return a.w(`TileProvider "${F}" has an invalid URL: "${z}"`),null}return{name:F,url:H}}(this._options);if(this.provider&&!I)return this._loaded=!0,this.fire(new a.B(new Error(`TileProvider "${this.provider}" is not registered`))),void(d&&d());this._tileJSONRequest=I?this._loadWithProvider(I,j):Nc(this._options,this.map._requestManager,g,w,j)}_loadWithProvider(d,g){this.provider=d.name;const w=new AbortController,j=this._options.url&&!this._options.tiles?this.map._requestManager.transformRequest(this._options.url,a.R.Source):void 0,I=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:I,request:j},(L,F)=>{if(w.signal.aborted)return;if(L)return void g(L);const z=F?F.find(H=>H!=null):null;if(z){const H=Cd(this._options,z,this.map._requestManager);H instanceof Error?g(H):g(null,H)}else g(null,{tiles:this._options.tiles})}),{cancel:()=>{w.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=hu.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 w=d.tileID.canonical.url(this.tiles,this.scheme),j=this.map._requestManager.normalizeTileURL(w),I=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:I,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(w)&&(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,H.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,H.bind(this),void 0,!0);else{const Z=a.aO.call({deduped:this._deduped},z,(ne,re)=>{if(ne||!re)H.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,H.bind(this),void 0,!0)}},!0);d.request={cancel:Z}}function H(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 t0 extends a.E{constructor(d,g,w,j){super(),this.id=d,this.dispatcher=w,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=Nc(this._options,this.map._requestManager,null,g,(w,j)=>{this._tileJSONRequest=null,this._loaded=!0,w?this.fire(new a.B(w)):j&&(Object.assign(this,j),j.raster_layers&&(this.rasterLayers=j.raster_layers,this.rasterLayerIds=this.rasterLayers.map(I=>I.id)),this.tileBounds=hu.fromTileJSON(j),nt(j.tiles),this.fire(new a.C("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new a.C("data",{dataType:"source",sourceDataType:"content"}))),d&&d(w)})}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 w=a.o.devicePixelRatio>=2,j=this.map._requestManager.normalizeTileURL(d.tileID.canonical.url(this.tiles,this.scheme),w,this.tileSize);d.request=a.n(this.map._requestManager.transformRequest(j,a.R.Tile),(I,L,F)=>{if(delete d.request,d.aborted)return d.state="unloaded",g(null);if(I)return d.state="errored",g(I);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 GT([_,d],g,w,{scaled:j=!0}={}){const{tileSize:I,buffer:L}=w,{x:F,y:z,z:H}=g;if(!isFinite(F)||!isFinite(z)||!isFinite(H))throw new Error("Invalid MRT header");const Z=2**H,ne=Z*a.aH(_),re=Z*a.aL(d);return function([ie,ce],oe,{scaled:xe=!0}={}){if(!oe)throw new Error("bandView is undefined");const{data:ye,tileSize:Pe,buffer:Me,offset:Se,scale:Ze,dimension:$e}=oe;if(ie<-Me||ie>Pe+Me||ce<-Me||ce>Pe+Me)throw new Error(`Point (${ie}, ${ce}) out of bounds for tileSize=${Pe}, buffer=${Me}`);const Ke=(ce+Me)*(Pe+2*Me)+(ie+Me);if(new Uint32Array(ye.buffer)[Ke]===4294967295)return null;let De=[];De=xe?[]:new oe.data.constructor($e);for(let Be=0;Be<$e;Be++)De[Be]=Math.round(1e12*(ye[$e*Ke+Be]*Ze+Se))/1e12;return De}([Math.min(Math.max(-L,Math.floor((ne-F)*I)),I-1+L),Math.min(Math.max(-L,Math.floor((re-z)*I)),I-1+L)],w,{scaled:j})}class Hm extends t0{constructor(d,g,w,j){super(d,g,w,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,w=this.map.style.getSourceCache(this.id);g&&g.enabled&&w&&g._clearRenderCacheForTile(w.id,d.tileID),this.map.triggerRepaint()}loadTile(d,g){const w=this.map._requestManager.normalizeTileURL(d.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize),j=this.map._requestManager.transformRequest(w,a.R.Tile),I={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,H)=>{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(H);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",I,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 w=d.texturePerLayer;if(d.flushAllQueues(),w.size){d.destroy(!1);for(const j of w.values())this.map.painter.saveTileTexture(j)}else d.destroy()}prepareTile(d,g,w,j){d._isHeaderLoaded&&(d.state!=="empty"&&(d.state="reloading"),d.fetchBandForRender(g,w,j,(I,L)=>{I?(d.state="errored",this.fire(new a.B(I))):L&&(d._isHeaderLoaded=!0,d.setTexturePerLayer(w,L,this.map.painter),d.state="loaded"),this.triggerRepaint(d)}))}getInitialBand(d){if(!this.rasterLayers)return 0;const g=this.rasterLayers.find(({id:I})=>I===d),w=g&&g.fields,j=w&&w.bands&&w.bands;return j?j[0]:0}getTextureDescriptor(d,g,w){if(!d)return;const j=g.sourceLayer||this.rasterLayerIds&&this.rasterLayerIds[0];if(!j)return;let I=null;g instanceof a.aS?I=g.paint.get("raster-array-band"):g instanceof a.aT&&(I=g.paint.get("raster-particle-array-band"));const L=I||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)&&!w)return;const F=d.textureDescriptorPerLayer.get(g.id);return Object.assign({},F,{texture:d.texturePerLayer.get(g.id)})}getImages(d,g){const w=new Map;for(const j of d)for(const I of g){const[L,F]=I.split("/"),z=j.getLayer(L);if(!z||!z.hasBand(F)||!z.hasDataForBand(F))continue;const{bytes:H,tileSize:Z,buffer:ne}=z.getBandView(F),re=Z+2*ne,ie={data:new a.q({width:re,height:re},H),pixelRatio:2,sdf:!1,usvg:!1,version:0};w.set(I,ie)}return w}queryRasterArrayValueByBandId(d,g,w){const j=g._mrt;return new Promise(I=>{const L={},F=new Set;for(const[z,H]of Object.entries(j.layers)){if(w.layerName&&z!==w.layerName)continue;const Z={};L[z]=Z;for(const{bands:ne}of H.dataIndex)for(const re of ne)w.bands&&!w.bands.includes(re)||(F.add(a.F(z,re)),g.fetchBand(z,null,re,ie=>{a.o.frame(()=>{Z[re]=ie?null:GT([d.lng,d.lat],j,H.getBandView(re)),F.delete(a.F(z,re)),F.size===0&&I(L)})},!1))}F.size===0&&I(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 w=this.map._requestManager.normalizeTileURL(d.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize),j=this.map._requestManager.transformRequest(w,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},(I,L,F)=>{if(I)return this._loadTilePending[d.uid].forEach(z=>z(I,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,w){return new Promise((j,I)=>{this._loadTileForQuery(g,(L,F)=>{L?I(L):j(F?this.queryRasterArrayValueByBandId(d,g,w):null)})})}queryRasterArrayValue(d,g){const w=a.aU.convert(d),j=this.findLoadedParent(w);return j&&j._mrt?g.bands||!this.partial?this.queryRasterArrayValueByBandId(w,j,g):this.queryRasterArrayValueByAllBands(w,j,g):Promise.resolve(null)}findLoadedParent(d){const g=a.ag.fromLngLat(d,this.map.transform.tileSize),w=this.maxzoom+1,j=1<0&&(F[new a.aR(_.overscaledZ,j,d.z,w,d.y-1).key]={backfilled:!1},F[new a.aR(_.overscaledZ,_.wrap,d.z,d.x,d.y-1).key]={backfilled:!1},F[new a.aR(_.overscaledZ,L,d.z,I,d.y-1).key]={backfilled:!1}),d.y+1{if(this._loaded=!0,this._pendingLoad=null,w)this.fire(new a.B(w));else{const I={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&j&&j.resourceTiming&&j.resourceTiming[this.id]&&(I.resourceTiming=j.resourceTiming[this.id]),_&&(this._partialReload=!0),this.fire(new a.C("data",I)),this._partialReload=!1,this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(_),this._coalesce=!1)})}loaded(){return this._loaded}reload(){const _=a.F(this.id,this.scope);this.map.style.clearSource(_),this._updateWorkerData()}loadTile(_,d){const g=_.actor?"reloadTile":"loadTile";_.actor=this.actor;const w=this.map.style?this.map.style.getLut(this.scope):null,j=w?{image:w.image.clone()}:null,I=this._partialReload,L={type:this.type,uid:_.uid,tileID:_.tileID,tileZoom:_.tileZoom,zoom:_.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:_.isExtraShadowCaster,scaleFactor:this.map.getScaleFactor(),partial:I,worldview:this.map.getWorldview(),indoor:this.map.getIndoorTileOptions(this.id,this.scope)};_.request=this.actor.send(g,L,(F,z)=>I&&!z?(_.state="loaded",d(null)):(delete _.request,_.destroy(!1),_.aborted?d(null):F?d(F):(_.loadVectorData(z,this.map.painter,g==="reloadTile"),d(null))),void 0,g==="loadTile")}abortTile(_){_.request&&(_.request.cancel(),delete _.request),_.aborted=!0}unloadTile(_,d){this.actor.send("removeTile",{uid:_.uid,type:this.type,source:this.id,scope:this.scope}),_.destroy()}onRemove(_){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(_,d,g,w){super(_,d,g,w),this.roundZoom=!0,this.type="video",this.options=d}load(){this._loaded=!1;const _=this.options;this.urls=[];for(const d of _.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(_){if(this.video){const d=this.video.seekable;_d.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=_}}getVideo(){return this.video}onAdd(_){this.map||(this.map=_,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 _=this.map.painter.context,d=_.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(_,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(_)}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(_,d,g,w){super(),this.type="batched-model",this.id=_,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(w)}onAdd(_){this.map=_,this.load()}reload(){this.cancelTileJSONRequest();const _=a.F(this.id,this.scope);this.load(()=>this.map.style.clearSource(_))}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}load(_){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=Nc(this._options,this.map._requestManager,d,g,(w,j)=>{this._tileJSONRequest=null,this._loaded=!0,w?(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(w))):j&&(Object.assign(this,j),j.bounds&&(this.tileBounds=new hu(j.bounds,this.minzoom,this.maxzoom)),nt(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"}))),_&&_(w)})}hasTransition(){return!1}hasTile(_){return!this.tileBounds||this.tileBounds.contains(_.canonical)}loaded(){return this._loaded}loadTile(_,d){const g=this.map._requestManager.normalizeTileURL(_.tileID.canonical.url(this.tiles,this.scheme)),w={request:this.map._requestManager.transformRequest(g,a.R.Tile),data:void 0,uid:_.uid,tileID:_.tileID,tileZoom:_.tileZoom,zoom:_.tileID.overscaledZ,tileSize:this.tileSize*_.tileID.overscaleFactor(),type:this.type,source:this.id,scope:this.scope,showCollisionBoxes:this.map.showCollisionBoxes,renderSourceType:_.renderSourceType,brightness:this.map.style&&this.map.style.getBrightness()||0,pixelRatio:a.o.devicePixelRatio,promoteId:this.promoteId};if(_.actor&&_.state!=="expired")if(_.state==="loading")_.reloadCallback=d;else{if(_.buckets){const I=Object.values(_.buckets);for(const L of I)L.dirty=!0;return void(_.state="loaded")}_.request=_.actor.send("reloadTile",w,j.bind(this))}else _.actor=this.dispatcher.getActor(),_.request=_.actor.send("loadTile",w,j.bind(this),void 0,!0);function j(I,L){return _.aborted?d(null):I&&I.status!==404?d(I):(this.map._refreshExpiredTiles&&L&&_.setExpiryData(L),_.loadModelData(L,this.map.painter),_.state="loaded",void d(null))}}serialize(){return Object.assign({},this._options)}},canvas:class extends a.aV{constructor(_,d,g,w){super(_,d,g,w),d.coordinates?Array.isArray(d.coordinates)&&d.coordinates.length===4&&!d.coordinates.some(j=>!Array.isArray(j)||j.length!==2||j.some(I=>typeof I!="number"))||this.fire(new a.B(new a.V(`sources.${_}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new a.B(new a.V(`sources.${_}`,null,'missing required property "coordinates"'))),d.animate&&typeof d.animate!="boolean"&&this.fire(new a.B(new a.V(`sources.${_}`,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.${_}`,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.${_}`,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(_){this.map=_,this.load(),this.canvas&&this.animate&&this.play()}onRemove(_){this.pause()}prepare(){let _=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,_=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,_=!0),this._hasInvalidDimensions()||Object.keys(this.tiles).length===0)return;const d=this.map.painter.context;this.texture?!_&&!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 _ of[this.canvas.width,this.canvas.height])if(isNaN(_)||_<=0)return!0;return!1}},custom:class extends a.E{constructor(_,d,g,w){super(),this.id=_,this.type="custom",this._dataType="raster",this._dispatcher=g,this._implementation=d,this.setEventedParent(w),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 hu(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(_){this.map=_,this._loaded=!1,this.fire(new a.C("dataloading",{dataType:"source"})),this._implementation.onAdd&&this._implementation.onAdd(_),this.load()}onRemove(_){this._implementation.onRemove&&this._implementation.onRemove(_)}hasTile(_){if(this._implementation.hasTile){const{x:d,y:g,z:w}=_.canonical;return this._implementation.hasTile({x:d,y:g,z:w})}return!this.tileBounds||this.tileBounds.contains(_.canonical)}loadTile(_,d){const{x:g,y:w,z:j}=_.tileID.canonical,I=new AbortController,L=Promise.resolve(this._implementation.loadTile({x:g,y:w,z:j},{signal:I.signal})).then((function(F){return delete _.request,_.aborted?(_.state="unloaded",d(null)):F===void 0?(_.state="errored",d(null)):F===null?(this.loadTileData(_,{width:this.tileSize,height:this.tileSize,data:null}),_.state="loaded",d(null)):function(z){return z instanceof ImageData||z instanceof HTMLCanvasElement||z instanceof ImageBitmap||z instanceof HTMLImageElement}(F)?(this.loadTileData(_,F),_.state="loaded",void d(null)):(_.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"&&(_.state="errored",d(F))});L.cancel=()=>I.abort(),_.request=L}loadTileData(_,d){_.setTexture(d,this.map.painter)}unloadTile(_,d){if(_.texture&&_.texture instanceof a.T?(_.destroy(!1),_.texture&&_.texture instanceof a.T&&this.map.painter.saveTileTexture(_.texture)):_.destroy(),this._implementation.unloadTile){const{x:g,y:w,z:j}=_.tileID.canonical;this._implementation.unloadTile({x:g,y:w,z:j})}d&&d()}abortTile(_,d){_.request&&_.request.cancel&&(_.request.cancel(),delete _.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(_=>({x:_.canonical.x,y:_.canonical.y,z:_.canonical.z}))}_clearTiles(){const _=a.F(this.id,this.scope);this.map.style.clearSource(_)}_update(){this.fire(new a.C("data",{dataType:"source",sourceDataType:"content"}))}}},z_=function(_,d,g,w){const j=new $_[d.type](_,d,g,w);if(j.id!==_)throw new Error(`Expected Source id to be ${_} instead of ${j.id}`);return a.aZ(["load","abort","unload","serialize","prepare"],j),j};function HT(_,d,g=""){return`${g}:${d.id||""}:${d.layer.id}:${function(w){if("layerId"in w)return`layer:${w.layerId}`;{const{featuresetId:j,importId:I}=w;return`featureset:${j}${I?`:import:${I}`:""}`}}(_.target)}`}function Pd(_,d,g,w=""){if(_.uniqueFeatureID){const j=HT(_,d,w);if(g.has(j))return!0;g.add(j)}return!1}function _C(_,d,g,w,j=!1,I=void 0){const L=d.sourceCache.transform,F=d.sourceCache.tilesIn(_,d.has3DLayers,j);F.sort(V_);const z=[];for(const H of F){const Z=H.tile.queryRenderedFeatures(d,H,g,w,L,j,I);Object.keys(Z).length&&z.push({wrappedTileID:H.tile.tileID.wrapped().key,queryResults:Z})}for(const H in d.layers){const Z=d.layers[H];if(Z.styleLayer){const ne=Z.styleLayer.queryRenderedFeatures(_,d.sourceCache,w);Object.keys(ne).length&&z.push({wrappedTileID:0,queryResults:ne})}}return z.length===0?{}:function(H){const Z={},ne={};for(const re of H){const ie=re.queryResults,ce=re.wrappedTileID,oe=ne[ce]=ne[ce]||{};for(const xe in ie){const ye=ie[xe],Pe=oe[xe]=oe[xe]||{},Me=Z[xe]=Z[xe]||[];for(const Se of ye)Pe[Se.featureIndex]||(Pe[Se.featureIndex]=!0,Me.push(Se))}}return Z}(z)}function U_(_,d,g,w,j,I){const L={},F=w.queryRenderedSymbols(_),z=[];for(const H of Object.keys(F).map(Number))z.push(j[H]);z.sort(V_);for(const H of z){const Z=H.featureIndex.lookupSymbolFeatures(F[H.bucketInstanceId],H.bucketIndex,H.sourceLayerIndex,d,g,I);for(const ne in Z){const re=L[ne]=L[ne]||[],ie=Z[ne];ie.sort((ce,oe)=>{const xe=H.featureSortOrder;if(xe){const ye=xe.indexOf(ce.featureIndex);return xe.indexOf(oe.featureIndex)-ye}return oe.featureIndex-ce.featureIndex});for(const ce of ie)re.push(ce)}}return L}function WT(_,d){const g=_.getRenderableIds().map(I=>_.getTileByID(I)),w=[],j={};for(let I=0;I{if(I)g(I);else try{const z=w.getHeaderLength(L);if(z>d)return void(this.request=this.fetchHeader(z,g));w.parseHeader(L),this._isHeaderLoaded=!0;let H=0;for(const Z of Object.values(w.layers))H=Math.max(H,Z.dataIndex[Z.dataIndex.length-1].lastByte);L.byteLength>=H&&(this.entireBuffer=L),g(null,this.entireBuffer||L,F)}catch(z){g(z)}}),this.request}fetchBandForRender(d,g,w,j){this.fetchBand(d,g,w,I=>{if(I)return void j(I);this.updateTextureDescriptor(d,g,w);const L=this.textureDescriptorPerLayer.get(g);j(null,L?L.img:null)})}fetchBand(d,g,w,j,I=!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 H=a.F(String(w),a.F(this.tileID.key,d));let Z=this._taskQueue.get(H);Z?Z.add(j):(Z=new Set,Z.add(j),this._taskQueue.set(H,Z));const ne=(oe,xe)=>{z.complete(oe,xe),oe?j(oe):(Z.forEach(ye=>ye(null,xe)),this._taskQueue.delete(H))},re=(oe,xe)=>{if(oe)return j(oe);const ye=F.send("decodeRasterArray",{type:"raster-array",source:this.source,scope:this.scope,tileID:this.tileID,uid:this.uid,buffer:xe,task:z},ne,void 0,!0);if(g!==null){const Pe=this._workQueuePerLayer.get(g)||[];Pe.push(()=>{ye&&ye.cancel(),z.cancel()}),this._workQueuePerLayer.has(g)||this._workQueuePerLayer.set(g,Pe)}};let ie;try{ie=L.getLayer(d)}catch(oe){if(this.state==="reloading")return;throw oe}if(!ie)return void j(new Error(`Unknown sourceLayer "${d}"`));if(ie.hasDataForBand(w))return Z.forEach(oe=>oe(null,null)),void this._taskQueue.delete(H);const ce=ie.getDataRange([w]);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 oe=Object.assign({},this.requestParams,{headers:{Range:`bytes=${ce.firstByte}-${ce.lastByte}`}}),xe=a.b1(oe,re);if(g!==null){const ye=this._fetchQueuePerLayer.get(g)||[];ye.push(()=>{xe.cancel(),z.cancel()}),this._fetchQueuePerLayer.has(g)||this._fetchQueuePerLayer.set(g,ye)}}}updateNeeded(d,g){return(!this.textureDescriptorPerLayer.get(d)||this.textureDescriptorPerLayer.get(d).band!==g||this.refreshedUponExpiration)&&this.state!=="errored"}updateTextureDescriptor(d,g,w){if(!this._mrt)return;const j=this._mrt.getLayer(d);if(!j||!j.hasBand(w)||!j.hasDataForBand(w))return;const{bytes:I,tileSize:L,buffer:F,offset:z,scale:H}=j.getBandView(w),Z=L+2*F,ne=new a.q({width:Z,height:Z},I),re=this.texturePerLayer.get(g);re&&re instanceof a.T&&re.update(ne,{premultiply:!1}),this.textureDescriptorPerLayer.set(g,{layer:d,band:w,img:ne,buffer:F,offset:z,tileSize:L,format:j.pixelFormat,mix:[H,256*H,65536*H,16777216*H]})}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 Ag{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,w){const j=d.wrapped().key;this.data[j]===void 0&&(this.data[j]=[]);const I={value:g,timeout:void 0};if(w!==void 0&&(I.timeout=setTimeout(()=>{this.remove(d,I)},w)),this.data[j].push(I),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 w=d.wrapped().key,j=g===void 0?0:this.data[w].indexOf(g),I=this.data[w][j];return this.data[w].splice(j,1),I.timeout&&clearTimeout(I.timeout),this.data[w].length===0&&delete this.data[w],this.onRemove(I.value),this.order.splice(this.order.indexOf(w),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 w in this.data)for(const j of this.data[w])d(j.value)||g.push(j);for(const w of g)this.remove(w.value.tileID,w)}}class KT{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(d,g,w){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],w),this.deletedStates[d]===null){this.deletedStates[d]={};for(const I in this.state[d])I!==j&&(this.deletedStates[d][I]=null)}else if(this.deletedStates[d]&&this.deletedStates[d][j]===null){this.deletedStates[d][j]={};for(const I in this.state[d][j])w[I]||(this.deletedStates[d][j][I]=null)}else for(const I in w)this.deletedStates[d]&&this.deletedStates[d][j]&&this.deletedStates[d][j][I]===null&&delete this.deletedStates[d][j][I]}removeFeatureState(d,g,w){if(this.deletedStates[d]===null)return;const j=String(g);if(this.deletedStates[d]=this.deletedStates[d]||{},w&&g!==void 0)this.deletedStates[d][j]!==null&&(this.deletedStates[d][j]=this.deletedStates[d][j]||{},this.deletedStates[d][j][w]=null);else if(g!==void 0)if(this.stateChanges[d]&&this.stateChanges[d][j])for(w in this.deletedStates[d][j]={},this.stateChanges[d][j])this.deletedStates[d][j][w]=null;else this.deletedStates[d][j]=null;else this.deletedStates[d]=null}getState(d,g){const w=this.state[d]||{},j=this.stateChanges[d]||{},I=this.deletedStates[d];if(I===null)return{};if(g!==void 0){const F=String(g),z=Object.assign({},w[F],j[F]);if(I){const H=I[g];if(H===null)return{};for(const Z in H)delete z[Z]}return z}const L=Object.assign({},w,j);if(I)for(const F in I)delete L[F];return L}initializeTileState(d,g){d.refreshFeatureState(g)}coalesceChanges(d,g){const w={};for(const j in this.stateChanges){this.state[j]=this.state[j]||{};const I={};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]),I[L]=this.state[j][L];w[j]=I}for(const j in this.deletedStates){this.state[j]=this.state[j]||{};const I={};if(this.deletedStates[j]===null)for(const L in this.state[j])I[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];I[L]=this.state[j][L]}w[j]=w[j]||{},Object.assign(w[j],I)}if(this.stateChanges={},this.deletedStates={},Object.keys(w).length!==0)for(const j in d)d[j].refreshFeatureState(g,w)}}class fu extends a.E{constructor(d,g,w){super(),this.id=d,this._renderSourceType=w,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 Ag(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 KT,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 w=this._tiles[g];w.upload(d,this.map?this.map.painter:void 0),w.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(YT).map(d=>d.key)}getRenderableIds(d,g){const w=[];for(const j in this._tiles)this._isIdRenderable(+j,d,g)&&w.push(this._tiles[j]);return d?w.sort((j,I)=>{const L=j.tileID,F=I.tileID,z=new a.P(L.canonical.x,L.canonical.y)._rotate(this.transform.angle),H=new a.P(F.canonical.x,F.canonical.y)._rotate(this.transform.angle);return L.overscaledZ-F.overscaledZ||H.y-z.y||H.x-z.x}).map(j=>j.tileID.key):w.map(j=>j.tileID).sort(YT).map(j=>j.key)}hasRenderableParent(d){const g=this.findLoadedParent(d,0);return!!g&&this._isIdRenderable(g.tileID.key)}_isIdRenderable(d,g,w){return this._tiles[d]&&this._tiles[d].hasData()&&!this._coveredTiles[d]&&(g||!this._tiles[d].holdingForFade())&&(w||!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 w=this._tiles[d];w&&(w.state!=="loading"&&(w.state=g),this._loadTile(w,this._tileLoaded.bind(this,w,d,g)))}_tileLoaded(d,g,w,j,I){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(),w==="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;I&&I.responseHeaders&&(L=I.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)),I.dem&&j.dem&&(j.dem.backfillBorder(I.dem,L,F),j.neighboringTiles&&j.neighboringTiles[H]&&(j.neighboringTiles[H].backfilled=!0)))}}getTile(d){return this.getTileByID(d.key)}getTileByID(d){return this._tiles[d]}_retainLoadedChildren(d,g,w,j){for(const I in this._tiles){let L=this._tiles[I];if(j[I]||!L.hasData()||L.tileID.overscaledZ<=g||L.tileID.overscaledZ>w)continue;let F=L.tileID;for(;L&&L.tileID.overscaledZ>g+1;){const H=L.tileID.scaledTo(L.tileID.overscaledZ-1);L=this._tiles[H.key],L&&L.hasData()&&(F=H)}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 w=this._loadedParentTiles[d.key];return w&&w.tileID.overscaledZ>=g?w:null}for(let w=d.overscaledZ-1;w>=g;w--){const j=d.scaledTo(w),I=this._getLoadedTile(j);if(I)return I}}_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 w=Math.ceil(d.width/g)+1,j=Math.ceil(d.height/g)+1,I=Math.floor(w*j*5),L=typeof this._minTileCacheSize=="number"?Math.max(this._minTileCacheSize,I):I,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 w={};for(const j in this._tiles){const I=this._tiles[j];I.tileID=I.tileID.unwrapTo(I.tileID.wrap+g),w[I.tileID.key]=I}this._tiles=w;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,w,j,I){if(this.transform=d,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage||this.usedForTerrain&&!w)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 H=this.map&&this.map.painter?this.map.painter._terrain:null;if(H&&H.sourceCache===this&&H.attenuationRange()){const ie=H.attenuationRange()[0],ce=Math.floor(ie)-Math.log2(H.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&&!w,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&&!w,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&&!w}),ce=Math.min(ie,z);if(L){const oe=d.extendTileCover(F,ce);for(const xe of oe)F.push(xe)}else if(I){const oe=this.transform.getFrustum(ce),xe=d.extendTileCoverToNearPlane(F,oe,ce);for(const ye of xe)F.push(ye);if(ce>=18&&this._hasTunnelGeometry()){const ye=d.extendTileCoverForTunnels(F,oe,ce,20);for(const Pe of ye)F.push(Pe)}}else if(this.castsShadows&&j){const oe=d.extendTileCover(F,ce,j,16);for(const xe of oe)this._shadowCasterTiles[xe.key]=!0,F.push(xe)}}const ne=this._updateRetainedTiles(F);if(this._supportsFading&&F.length!==0){const ie={},ce={},oe=a.o.now(),xe=Object.keys(ne);for(const Pe of xe){const Me=ne[Pe],Se=this._tiles[Pe];if(!Se||Se.fadeEndTime!==void 0&&Se.fadeEndTime<=oe)continue;const Ze=this.findLoadedParent(Me,Math.max(Me.overscaledZ-fu.maxOverzooming,this._source.minzoom));Ze&&(this._addTile(Ze.tileID),ie[Ze.tileID.key]=Ze.tileID),ce[Pe]=Me}const ye=F[F.length-1].overscaledZ;for(const Pe in this._tiles){const Me=this._tiles[Pe];if(ne[Pe]||!Me.hasData())continue;let Se=Me.tileID;for(;Se.overscaledZ>ye;){Se=Se.scaledTo(Se.overscaledZ-1);const Ze=this._tiles[Se.key];if(Ze&&Ze.hasData()&&ce[Se.key]){ne[Pe]=Me.tileID;break}}}for(const Pe in ie)ne[Pe]||(this._coveredTiles[Pe]=!0,ne[Pe]=ie[Pe])}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 w={},j=d.reduce((H,Z)=>Math.min(H,Z.overscaledZ),1/0),I=d[0].overscaledZ,L=Math.max(I-fu.maxOverzooming,this._source.minzoom),F=Math.max(I+fu.maxUnderzooming,this._source.minzoom),z={};for(const H of d){const Z=this._addTile(H);g[H.key]=H,Z.hasData()||j=this._source.maxzoom){const re=H.children(this._source.maxzoom)[0],ie=this.getTile(re);if(ie&&ie.hasData()){g[re.key]=re;continue}}else{const re=H.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=H.overscaledZ-1;re>=L;--re){const ie=H.scaledTo(re);if(w[ie.key]||(w[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 w,j=this._tiles[d].tileID;for(;j.overscaledZ>0;){if(j.key in this._loadedParentTiles){w=this._loadedParentTiles[j.key];break}g.push(j.key);const I=j.scaledTo(j.overscaledZ-1);if(w=this._getLoadedTile(I),w)break;j=I}for(const I of g)this._loadedParentTiles[I]=w}}_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 w=!!g;if(!w){const j=this.map?this.map.painter:null,I=this._source.tileSize*d.overscaleFactor();g=this._source.type==="raster-array"?new Wm(d,I,this.transform.tileZoom,j,this._isRaster):new a.b0(d,I,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,w||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 w=g.getExpiryTimeout();w&&(this._timers[d]=setTimeout(()=>{this._reloadTile(d,"expired"),delete this._timers[d]},w))}_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,w){const j=[],I=this.transform;if(!I)return j;const L=I.projection.name==="globe",F=a.aH(I.center.lng);for(const z in this._tiles){const H=this._tiles[z];if(w&&H.clearQueryDebugViz(),H.holdingForFade())continue;let Z;if(L){const ne=H.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(H,I,g,ne);re&&j.push(re)}}return j}getShadowCasterCoordinates(){return this._getRenderableCoordinates(!1,!0)}getVisibleCoordinates(d){return this._getRenderableCoordinates(d)}_getRenderableCoordinates(d,g){const w=this.getRenderableIds(d,g).map(I=>this._tiles[I].tileID),j=this.transform.projection.name==="globe";for(const I of w)I.projMatrix=this.transform.calculateProjMatrix(I.toUnwrapped()),I.expandedProjMatrix=j?this.transform.calculateProjMatrix(I.toUnwrapped(),!1,!0):I.projMatrix;return w}sortCoordinatesByDistance(d){const g=d.slice(),w=this.transform._camera.position,j=this.transform._camera.forward(),I={};for(const L of g){const F=1/(1<I[L.key]-I[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 w=this._tiles[g];if(w.fadeEndTime!==void 0&&w.fadeEndTime>=d)return!0}}return!1}setFeatureState(d,g,w){this._state.updateState(d=d||"_geojsonTileLayer",g,w)}removeFeatureState(d,g,w){this._state.removeFeatureState(d=d||"_geojsonTileLayer",g,w)}getFeatureState(d,g){return this._state.getState(d=d||"_geojsonTileLayer",g)}setDependencies(d,g,w){const j=this._tiles[d];j&&j.setDependencies(g,w)}reloadTilesForDependencies(d,g){for(const w in this._tiles)this._tiles[w].hasDependency(d,g)&&this._reloadTile(+w,"reloading");this._cache.filter(w=>!w.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 w=new Map,j=Array.isArray(d)?d:[d],I=this.map.painter.terrain,L=this.usedForTerrain&&I?I.getScaledDemTileSize():this._source.tileSize;for(const z of j){const H=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 H)w.set(Z.key,Z);this.usedForTerrain&&z.updateElevation(!1)}const F=Array.from(w.values());a.t(F,(z,H)=>{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),H(ne,Z)})},g)}}function YT(_,d){const g=Math.abs(2*_.wrap)-+(_.wrap<0),w=Math.abs(2*d.wrap)-+(d.wrap<0);return _.overscaledZ-d.overscaledZ||w-g||d.canonical.y-_.canonical.y||d.canonical.x-_.canonical.x}function kg(_,d){const g=1<<_.z;return[_.x/g+d,(_.x+1)/g+d]}fu.maxOverzooming=10,fu.maxUnderzooming=3;class r0{constructor(d){this.style=d,this.layersGotHidden=!1,this.layers=[]}processLayersChanged(){this.layers=[];const d=!1,g=!1;for(const w in this.style._mergedLayers){const j=this.style._mergedLayers[w];if(j.type==="fill-extrusion"||j.type==="building")this.layers.push({layer:j,visible:d,visibilityChanged:g});else if(j.type==="model"){const I=this.style.getLayerSource(j);I&&I.type==="batched-model"&&this.layers.push({layer:j,visible:d,visibilityChanged:g})}}}onNewFrame(d){this.layersGotHidden=!1;for(const g of this.layers){const w=g.layer;let j=!1;w.type==="fill-extrusion"?j=!w.isHidden(d)&&w.paint.get("fill-extrusion-opacity")>0:w.type==="building"?j=!w.isHidden(d)&&w.paint.get("building-opacity")>0:w.type==="model"&&(j=!w.isHidden(d)&&w.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 I=j.layer,L=this.style.getLayerSourceCache(I);let F=1;I.type==="fill-extrusion"?F=j.visible?I.paint.get("fill-extrusion-vertical-scale"):0:I.type==="building"&&(F=j.visible?I.paint.get("building-vertical-scale"):0);let z=L?L.getTile(g):null;if(!z&&L)for(const H in L._tiles){const Z=L._tiles[H];if(g.canonical.isChildOf(Z.tileID.canonical)){z=Z;break}}this.currentBuildingBuckets.push({bucket:z?z.getBucket(I):null,tileID:z?z.tileID:g,verticalScale:F})}d.hasAnyZOffset=!1;let w=!1;for(let j=0;j{w in d&&(g[w]=d[w])}),g}function XT(_){_=_.slice();const d=Object.create(null);for(const g of _)d[g.id]=g;for(let g=0;g<_.length;g++){const w=_[g];if(w&&"ref"in w){const j=d[w.ref];j&&(_[g]=ZT(w,j))}}return _}const es={setStyle:"setStyle",addLayer:"addLayer",removeLayer:"removeLayer",setPaintProperty:"setPaintProperty",setLayoutProperty:"setLayoutProperty",setSlot:"setSlot",setFilter:"setFilter",addSource:"addSource",removeSource:"removeSource",setGeoJSONSourceData:"setGeoJSONSourceData",setLayerZoomRange:"setLayerZoomRange",setLayerProperty:"setLayerProperty",setCenter:"setCenter",setZoom:"setZoom",setBearing:"setBearing",setPitch:"setPitch",setSprite:"setSprite",setGlyphs:"setGlyphs",setTransition:"setTransition",setLight:"setLight",setTerrain:"setTerrain",setFog:"setFog",setSnow:"setSnow",setRain:"setRain",setCamera:"setCamera",setLights:"setLights",setProjection:"setProjection",addImport:"addImport",removeImport:"removeImport",updateImport:"updateImport",addIconset:"addIconset",removeIconset:"removeIconset"};function Ng(_,d,g){g.push({command:es.addSource,args:[_,d[_]]})}function Cg(_,d,g){d.push({command:es.removeSource,args:[_]}),g[_]=!0}function R4(_,d,g,w){Cg(_,g,w),Ng(_,d,g)}function q_(_,d,g){let w;for(w in _[g])if(_[g].hasOwnProperty(w)&&w!=="data"&&!a.b6(_[g][w],d[g][w]))return!1;for(w in d[g])if(d[g].hasOwnProperty(w)&&w!=="data"&&!a.b6(_[g][w],d[g][w]))return!1;return!0}function Af(_,d,g,w,j,I){let L;for(L in d=d||{},_=_||{})_.hasOwnProperty(L)&&(a.b6(_[L],d[L])||g.push({command:I,args:[w,L,d[L],j]}));for(L in d)d.hasOwnProperty(L)&&!_.hasOwnProperty(L)&&(a.b6(_[L],d[L])||g.push({command:I,args:[w,L,d[L],j]}))}function Ig(_){return _.id}function n0(_,d){return _[d.id]=d,_}function G_(_,d,g){const w=d.createTileMatrix(_,_.worldSize,g.toUnwrapped());return a.aD(new Float32Array(16),_.projMatrix,w)}function bC(_,d,g){if(d.projection.name===g.projection.name)return _.projMatrix;const w=g.clone();return w.setProjection(d.projection),G_(w,d.getProjection(),_)}function Km(_,d,g){return d.name===g.projection.name?_.projMatrix:G_(g,d,_)}class wC{constructor(d,g){this.reset(d,g)}reset(d,g){this.points=d||[],this._distances=[0];for(let w=1;w0?(j-L)/F:0;return this.points[I].mult(1-z).add(this.points[g].mult(z))}}class QT{constructor(d,g,w){const j=this.boxCells=[],I=this.circleCells=[];this.xCellCount=Math.ceil(d/w),this.yCellCount=Math.ceil(g/w);for(let L=0;Lthis.width||j<0||g>this.height)return!I&&[];const F=[];if(d<=0&&g<=0&&this.width<=w&&this.height<=j){if(I)return!0;for(let z=0;z0:F}_queryCircle(d,g,w,j,I){const L=d-w,F=d+w,z=g-w,H=g+w;if(F<0||L>this.width||H<0||z>this.height)return!j&&[];const Z=[];return this._forEachCell(L,z,F,H,this._queryCellCircle,Z,{hitTest:j,circle:{x:d,y:g,radius:w},seenUids:{box:{},circle:{}}},I),j?Z.length>0:Z}query(d,g,w,j,I){return this._query(d,g,w,j,!1,I)}hitTest(d,g,w,j,I){return this._query(d,g,w,j,!0,I)}hitTestCircle(d,g,w,j){return this._queryCircle(d,g,w,!0,j)}_queryCell(d,g,w,j,I,L,F,z){const H=F.seenUids,Z=this.boxCells[I];if(Z!==null){const re=this.bboxes;for(const ie of Z)if(!H.box[ie]){H.box[ie]=!0;const ce=4*ie;if(d<=re[ce+2]&&g<=re[ce+3]&&w>=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[I];if(ne!==null){const re=this.circles;for(const ie of ne)if(!H.circle[ie]){H.circle[ie]=!0;const ce=3*ie;if(this._circleAndRectCollide(re[ce],re[ce+1],re[ce+2],d,g,w,j)&&(!z||z(this.circleKeys[ie]))){if(F.hitTest)return L.push(!0),!0;{const oe=re[ce],xe=re[ce+1],ye=re[ce+2];L.push({key:this.circleKeys[ie],x1:oe-ye,y1:xe-ye,x2:oe+ye,y2:xe+ye})}}}}}_queryCellCircle(d,g,w,j,I,L,F,z){const H=F.circle,Z=F.seenUids,ne=this.boxCells[I];if(ne!==null){const ie=this.bboxes;for(const ce of ne)if(!Z.box[ce]){Z.box[ce]=!0;const oe=4*ce;if(this._circleAndRectCollide(H.x,H.y,H.radius,ie[oe+0],ie[oe+1],ie[oe+2],ie[oe+3])&&(!z||z(this.boxKeys[ce])))return L.push(!0),!0}}const re=this.circleCells[I];if(re!==null){const ie=this.circles;for(const ce of re)if(!Z.circle[ce]){Z.circle[ce]=!0;const oe=3*ce;if(this._circlesCollide(ie[oe],ie[oe+1],ie[oe+2],H.x,H.y,H.radius)&&(!z||z(this.circleKeys[ce])))return L.push(!0),!0}}}_forEachCell(d,g,w,j,I,L,F,z){const H=this._convertToXCellCoord(d),Z=this._convertToYCellCoord(g),ne=this._convertToXCellCoord(w),re=this._convertToYCellCoord(j);for(let ie=H;ie<=ne;ie++)for(let ce=Z;ce<=re;ce++)if(I.call(this,d,g,w,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,w,j,I,L){const F=j-d,z=I-g,H=w+L;return H*H>F*F+z*z}_circleAndRectCollide(d,g,w,j,I,L,F){const z=(L-j)/2,H=Math.abs(d-(j+z));if(H>z+w)return!1;const Z=(F-I)/2,ne=Math.abs(g-(I+Z));if(ne>Z+w)return!1;if(H<=z||ne<=Z)return!0;const re=H-z,ie=ne-Z;return re*re+ie*ie<=w*w}}const L4=Math.tan(85*Math.PI/180);function kf(_,d,g,w,j,I,L){const F=a.bb();if(g)if(I.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],w||a.ba(F,F,j.angle)}else a.aD(F,j.labelPlaneMatrix,_);return F}function qu(_,d,g,w,j,I,L){const F=kf(_,d,g,w,j,I,L);return I.name==="globe"&&g||(F[2]=F[6]=F[10]=F[14]=0),F}function Pg(_,d,g,w,j,I,L){if(g){if(I.name==="globe"){const F=kf(_,d,g,w,j,I,L);return a.b7(F,F),a.aD(F,_,F),F}{const F=a.b8(_),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),w||a.ba(F,F,-j.angle),F}}return j.glCoordMatrix}function mu(_,d,g,w){const j=[_,d,g,1];g?a.aE(j,j,w):Qr(j,j,w);const I=j[3];return j[0]/=I,j[1]/=I,j[2]/=I,j}function H_(_,d){return Math.min(.5+_/d*.5,1.5)}function s0(_,d){const g=_[0]/_[3],w=_[1]/_[3];return g>=-d[0]&&g<=d[0]&&w>=-d[1]&&w<=d[1]}function hc(_,d,g,w,j,I,L,F,z,H,Z=1){const ne=g.transform,re=w?_.textSizeData:_.iconSizeData,ie=a.bj(re,g.transform.zoom,Z),ce=ne.projection.name==="globe",oe=[256/g.width*2+1,256/g.height*2+1],xe=w?_.text.dynamicLayoutVertexArray:_.icon.dynamicLayoutVertexArray;xe.clear();let ye=null;ce&&(ye=w?_.text.globeExtVertexArray:_.icon.globeExtVertexArray);const Pe=_.lineVertexArray,Me=w?_.text.placedSymbolArray:_.icon.placedSymbolArray,Se=g.transform.width/g.transform.height;let Ze,$e=!1;for(let Ke=0;KeMath.abs(g)?{useVertical:!0}:_===a.bk.vertical?w>0?{needsFlipping:!0}:null:d!==0&&function(j,I){return j===0||Math.abs(I/j)>L4}(g,w)?d===1?{needsFlipping:!0}:null:g<0?{needsFlipping:!0}:null}function eE(_,d,g,w,j,I,L,F,z,H,Z,ne,re,ie,ce,oe,xe,ye,Pe,Me){const Se=d/24,Ze=_.lineOffsetX*Se,$e=_.lineOffsetY*Se,{lineStartIndex:Ke,glyphStartIndex:De,numGlyphs:Be,segment:Ge,writingMode:at,flipState:Qe}=_,xt=Ke+_.lineLength,ft=Lt=>{if(Z){const[gt,_t,Tt]=Lt.up,rr=H.length;a.bm(Z,rr+0,gt,_t,Tt),a.bm(Z,rr+1,gt,_t,Tt),a.bm(Z,rr+2,gt,_t,Tt),a.bm(Z,rr+3,gt,_t,Tt)}const[Bt,lt,tt]=Lt.point;a.bn(H,Bt,lt,tt,Lt.angle)};if(Be>1){const Lt=JT(Se,F,Ze,$e,g,ne,re,_,z,I,ie,oe,!1,xe,ye,Pe,Me);if(!Lt)return{notEnoughRoom:!0};if(w&&!g){let[Bt,lt,tt]=Lt.first.point,[gt,_t,Tt]=Lt.last.point;[Bt,lt]=mu(Bt,lt,tt,L),[gt,_t]=mu(gt,_t,Tt,L);const rr=W_(at,Qe,(gt-Bt)*ce,_t-lt);if(_.flipState=rr&&rr.needsFlipping?1:2,rr)return rr}ft(Lt.first);for(let Bt=De+1;Bt0?gt:tE(re,tt,Bt,1,j,void 0,xe,ye.canonical),Tt=W_(at,Qe,(_t[0]-Bt[0])*ce,_t[1]-Bt[1]);if(_.flipState=Tt&&Tt.needsFlipping?1:2,Tt)return Tt}const Lt=K_(Se*F.getoffsetX(De),Ze,$e,g,ne,re,Ge,Ke,xt,z,I,ie,oe,!1,!1,xe,ye,Pe,Me);if(!Lt)return{notEnoughRoom:!0};ft(Lt)}return{}}function Qn(_,d,g,w,j){const{x:I,y:L,z:F}=w.projectTilePoint(_.x,_.y,d);if(!j)return mu(I,L,F,g);const[z,H,Z]=j.getElevation(_,j.elevation,j.elevationFeature);return mu(I+z,L+H,F+Z,g)}function tE(_,d,g,w,j,I,L,F){const z=Qn(_.sub(d)._unit()._add(_),F,j,L,I);return a.ax(z,g,z),a.ay(z,z),a.bg(z,g,z,w)}function K_(_,d,g,w,j,I,L,F,z,H,Z,ne,re,ie,ce,oe,xe,ye,Pe){const Me=w?_-d:_+d;let Se=Me>0?1:-1,Ze=0;w&&(Se*=-1,Ze=Math.PI),Se<0&&(Ze+=Math.PI);let $e=F+L+(Se>0?0:1)|0,Ke=j,De=j,Be=0,Ge=0;const at=Math.abs(Me),Qe=[],xt=[];let ft=I,Lt=ft,Bt=a.be([]);const lt=()=>tE(Lt,ft,De,at-Be+1,Z,re,oe,xe.canonical);for(;Be+Ge<=at;){if($e+=Se,$e=z)return null;if(De=Ke,Lt=ft,Qe.push(De),ie&&xt.push(Lt),ft=new a.P(H.getx($e),H.gety($e)),Ke=ne[$e],!Ke){const Lr=Qn(ft,xe.canonical,Z,oe,re);Ke=Lr[3]>0?ne[$e]=Lr:lt()}Be+=Ge;const Ot=a.ax([],Ke,De),Ar=a.bf(De,Ke);if(g&&Ar>0&&Ge>0&&a.bi(Bt,Ot)/(Ge*Ar)0,Me),Ke=H*$e.perspectiveRatio,De=(w.x1*g+F.x-w.padding)*Ke+$e.point.x,Be=(w.y1*g+F.y-w.padding)*Ke+$e.point.y,Ge=(w.x2*g+F.x+w.padding)*Ke+$e.point.x,at=(w.y2*g+F.y+w.padding)*Ke+$e.point.y,Qe=$e.perspectiveRatio<=.55||$e.occluded;return!this.isInsideGrid(De,Be,Ge,at)||!z&&this.grid.hitTest(De,Be,Ge,at,ne)||Qe?{box:[],offscreen:!1,occluded:$e.occluded}:{box:[De,Be,Ge,at],offscreen:this.isOffscreen(De,Be,Ge,at),occluded:!1}}placeCollisionCircles(d,g,w,j,I,L,F,z,H,Z,ne,re,ie,ce,oe,xe){const ye=[],Pe=this.transform.elevation,Me=d.getProjection(),Se=d.elevationType==="road",Ze=!!Pe||Se,$e=a.bu.getAtTileOffsetFunc(xe,this.transform.center.lat,this.transform.worldSize,Me),Ke=new a.P(w.tileAnchorX,w.tileAnchorY),De=new a.P(w.tileAnchorX,w.tileAnchorY);let{x:Be,y:Ge,z:at}=Me.projectTilePoint(De.x,De.y,xe.canonical),Qe=null;if(Ze){const Ar=Se?d.getElevationFeatureForText(j):null;Qe={getElevation:$e,elevation:Pe,elevationFeature:Ar};const[Lr,gr,Tr]=$e(Ke,Pe,Ar);Be+=Lr,Ge+=gr,at+=Tr}const xt=Me.name==="globe",ft=this.projectAndGetPerspectiveRatio(z,Be,Ge,at,xe,xt||!!Pe||this.transform.pitch>0,Me),{perspectiveRatio:Lt}=ft,Bt=(re?F/Lt:F*Lt)/a.by,lt=mu(Be,Ge,at,H),tt=w.lineOffsetX*Bt,gt=w.lineOffsetY*Bt,_t=a.ap(d.layers[0].layout.get("text-max-angle")),Tt=Math.cos(_t),rr=ft.signedDistanceFromCamera>0?JT(Bt,L,tt,gt,Se&&w.flipState===1,lt,De,w,I,H,{},Ze&&!re?Qe:null,re&&Ze,Me,xe,re,Tt):null;let Wt=!1,Kt=!1,Ot=!0;if(rr&&!ft.occluded){const Ar=.5*ce*Lt+oe,Lr=new a.P(-100,-100),gr=new a.P(this.screenRightBoundary,this.screenBottomBoundary),Tr=new wC,{first:Wr,last:an}=rr,tn=Wr.path.length;let _n=[];for(let rn=tn-1;rn>=1;rn--)_n.push(Wr.path[rn]);for(let rn=1;rn(Ze&&!xt&&(ws=$e(Xsrn[3]<=0)&&(_n=[]));let bn=[];if(_n.length>0){let rn=1/0,Hn=-1/0,ws=1/0,Xs=-1/0;for(const Is of _n)rn=Math.min(rn,Is[0]),ws=Math.min(ws,Is[1]),Hn=Math.max(Hn,Is[0]),Xs=Math.max(Xs,Is[1]);Hn>=Lr.x&&rn<=gr.x&&Xs>=Lr.y&&ws<=gr.y&&(bn=[_n.map(Is=>new a.P(Is[0],Is[1]))],(rngr.x||wsgr.y)&&(bn=a.bv(bn,Lr.x,Lr.y,gr.x,gr.y)))}for(const rn of bn){Tr.reset(rn,.25*Ar);let Hn=0;Hn=Tr.length<=.5*Ar?1:Math.ceil(Tr.paddedLength/Ur)+1;for(let ws=0;ws0?(a.aE(z,z,d),this.fogState&&I&&F.name!=="globe"&&(H=function(re,ie,ce,oe,xe,ye){const Pe=ye.calculateFogTileMatrix(xe),Me=[ie,ce,oe];return a.ah(Me,Me,Pe),Ms(re,a.ai(Me),ye.pitch,ye._fov)}(this.fogState,g,w,j,I.toUnwrapped(),this.transform)>.9)):Qr(z,z,d);const Z=z[3];return{point:new a.P((z[0]/Z+1)/2*this.transform.width+Gu,(-z[1]/Z+1)/2*this.transform.height+Gu),perspectiveRatio:Math.min(.5+this.transform.getCameraToCenterDistance(F)/Z*.5,1.5),signedDistanceFromCamera:Z,occluded:L&&z[2]>Z||H}}isOffscreen(d,g,w,j){return w=this.screenRightBoundary||jthis.screenBottomBoundary}isInsideGrid(d,g,w,j){return w>=0&&d=0&&gw.collisionGroupID===g}}return this.collisionGroups[d]}}function Sl(_,d,g,w,j){const{horizontalAlign:I,verticalAlign:L}=a.bF(_),F=-(I-.5)*d,z=-(L-.5)*g,H=a.bG(_,w);return new a.P(F+H[0]*j,z+H[1]*j)}function Nf(_,d,g,w,j){const I=new a.P(_,d);return g&&I._rotate(w?j:-j),I}class gs{constructor(d,g,w,j,I,L){this.transform=d.clone(),this.projection=d.projection.name,this.collisionIndex=new Y_(this.transform,I),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 ps(w),this.collisionCircleArrays={},this.prevPlacement=j,j&&(j.prevPlacement=void 0),this.placedOrientations={},this.lastReplacementSourceUpdateTime=0}getBucketParts(d,g,w,j,I=1){const L=w.getBucket(g),F=w.latestFeatureIndex;if(!L||!F||g.fqid!==L.layerIds[0])return;const z=L.layers[0].layout,H=L.layers[0].paint,Z=w.collisionBoxArray,ne=Math.pow(2,this.transform.zoom-w.tileID.overscaledZ),re=w.tileSize/a.an,ie=w.tileID.toUnwrapped();this.transform.setProjection(L.projection);const ce=(oe=w.tileID,xe=L.getProjection(),ye=this.transform,xe.name===this.projection?ye.calculateProjMatrix(oe.toUnwrapped()):G_(ye,xe,oe));var oe,xe,ye;const Pe=z.get("text-pitch-alignment")==="map",Me=z.get("text-rotation-alignment")==="map";g.compileFilter(g.options);const Se=g.dynamicFilter(),Ze=g.dynamicFilterNeedsFeature(),$e=g.dynamicFilterNeedsGeometry(),Ke=this.transform.calculatePixelsToTileUnitsMatrix(w),De=qu(ce,w.tileID.canonical,Pe,Me,this.transform,L.getProjection(),Ke);let Be=null;const Ge=L.getProjection().createInversionMatrix(this.transform,w.tileID.canonical);if(Pe){const gt=Pg(ce,w.tileID.canonical,Pe,Me,this.transform,L.getProjection(),Ke);Be=a.aD([],this.transform.labelPlaneMatrix,gt)}let at=null;Se&&w.latestFeatureIndex&&(at={unwrappedTileID:ie,dynamicFilter:Se,dynamicFilterNeedsFeature:Ze,needGeometry:$e}),this.retainedQueryData[L.bucketInstanceId]=new hs(L.bucketInstanceId,F,L.sourceLayerIndex,L.index,w.tileID);const[Qe,xt]=L.layers[0].layout.get("text-size-scale-range"),ft=a.aC(I,Qe,xt),[Lt,Bt]=z.get("icon-size-scale-range"),lt=a.aC(I,Lt,Bt),tt={bucket:L,layout:z,paint:H,posMatrix:ce,invMatrix:Ge,mercatorCenter:[a.aH(this.transform.center.lng),a.aL(this.transform.center.lat)],textLabelPlaneMatrix:De,labelToScreenMatrix:Be,clippingData:at,scale:ne,textPixelRatio:re,holdingForFade:w.holdingForFade(),collisionBoxArray:Z,partiallyEvaluatedTextSize:a.bj(L.textSizeData,this.transform.zoom,ft),partiallyEvaluatedIconSize:a.bj(L.iconSizeData,this.transform.zoom,lt),collisionGroup:this.collisionGroups.get(L.sourceID),latestFeatureIndex:w.latestFeatureIndex};if(j)for(const gt of L.sortKeyRanges){const{sortKey:_t,symbolInstanceStart:Tt,symbolInstanceEnd:rr}=gt;d.push({sortKey:_t,symbolInstanceStart:Tt,symbolInstanceEnd:rr,parameters:tt})}else d.push({symbolInstanceStart:0,symbolInstanceEnd:L.symbolInstances.length,parameters:tt})}attemptAnchorPlacement(d,g,w,j,I,L,F,z,H,Z,ne,re,ie,ce,oe,xe,ye,Pe,Me,Se,Ze){const{textOffset0:$e,textOffset1:Ke,crossTileID:De}=oe,Be=[$e,Ke],Ge=Sl(d,L,F,Be,z),at=this.collisionIndex.placeCollisionBox(ye,z,g,w,j,I,Nf(Ge.x,Ge.y,H,Z,this.transform.angle),ce,ne,re,ie.predicate);if(Me){const Qe=ye.getSymbolInstanceIconSize(Ze,this.transform.zoom,oe.placedIconSymbolIndex);if(this.collisionIndex.placeCollisionBox(ye,Qe,Me,w,j,I,Nf(Ge.x,Ge.y,H,Z,this.transform.angle),ce,ne,re,ie.predicate).box.length===0)return}if(at.box.length>0){let Qe;return this.prevPlacement&&this.prevPlacement.variableOffsets[De]&&this.prevPlacement.placements[De]&&this.prevPlacement.placements[De].text&&(Qe=this.prevPlacement.variableOffsets[De].anchor),this.variableOffsets[De]={textOffset:Be,width:L,height:F,anchor:d,textScale:z,prevAnchor:Qe},this.markUsedJustification(ye,d,oe,Pe),ye.allowVerticalPlacement&&(this.markUsedOrientation(ye,Pe,oe),this.placedOrientations[De]=Pe),{shift:Ge,placedGlyphBoxes:at}}}placeLayerBucketPart(d,g,w,j,I=1){const{bucket:L,layout:F,paint:z,posMatrix:H,textLabelPlaneMatrix:Z,labelToScreenMatrix:ne,clippingData:re,textPixelRatio:ie,mercatorCenter:ce,invMatrix:oe,holdingForFade:xe,collisionBoxArray:ye,partiallyEvaluatedTextSize:Pe,partiallyEvaluatedIconSize:Me,collisionGroup:Se,latestFeatureIndex:Ze}=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",at=F.get("icon-rotation-alignment")==="map",Qe=F.get("text-pitch-alignment")==="map",xt=z.get("symbol-z-offset"),ft=F.get("symbol-elevation-reference")==="sea",Lt=F.get("symbol-placement"),[Bt,lt]=F.get("text-size-scale-range"),[tt,gt]=F.get("icon-size-scale-range"),_t=a.aC(I,Bt,lt),Tt=a.aC(I,tt,gt),rr=F.get("text-variable-anchor"),Wt=Ge&&Lt!=="point",Kt=at&&Lt!=="point",Ot=rr&&L.hasTextData(),Ar=L.hasIconTextFit()&&Ot&&L.hasIconData();this.transform.setProjection(L.projection);const Lr=Ot||Wt,gr=Kt||Ar;let Tr=De&&(Be||!L.hasIconData()||Ke),Wr=Be&&(De||!L.hasTextData()||$e);const an=!xt.isConstant();!L.collisionArrays&&ye&&L.deserializeCollisionBoxes(ye),w&&j&&L.updateCollisionDebugBuffers(this.transform.zoom,ye,_t,Tt);const tn=(Ur,bn,rn)=>{const{crossTileID:Hn,numVerticalGlyphVertices:ws}=Ur;let Xs=null;if(re&&re.dynamicFilterNeedsFeature||an){const Os=this.retainedQueryData[L.bucketInstanceId],Vs=Ze.loadFeature({featureIndex:Ur.featureIndex,bucketIndex:Os.bucketIndex,sourceLayerIndex:Os.sourceLayerIndex,layoutVertexArrayOffset:0}),ys=Vs.properties?Vs.properties.worldview:null;if(L.localizable&&L.worldview&&typeof ys=="string")if(ys==="all")Vs.properties.$localized=!0;else{if(!ys.split(",").includes(L.worldview))return;Vs.properties.$localized=!0,Vs.properties.worldview=L.worldview}Xs=re&&re.needGeometry?a.bD(Vs,!0):Vs}if(re&&!(0,re.dynamicFilter)({zoom:this.transform.zoom,pitch:this.transform.pitch,worldview:L.worldview},Xs,this.retainedQueryData[L.bucketInstanceId].tileID.canonical,new a.P(Ur.tileAnchorX,Ur.tileAnchorY),this.transform.calculateDistanceTileData(re.unwrappedTileID)))return this.placements[Hn]=new Sh(!1,!1,!1,!0),void g.add(Hn);const Is=xt.evaluate(Xs,{});if((Ur.zOffset||0)+(Is||0)>0&&this.frontCutoffStart>0){const Os=2*this.frontCutoffStart-1,Vs=[Ur.tileAnchorX,Ur.tileAnchorY,0,1],ys=a.aE(a.bE(),Vs,H);if(ys[1]/ys[3]{Os.tileID=this.retainedQueryData[L.bucketInstanceId].tileID;const Vs=this.transform.elevation;Os.elevation=ft?Is:Is+a.bu.getAtTileOffset(Os.tileID,new a.P(Os.tileAnchorX,Os.tileAnchorY),Vs,ma),Os.elevation+=Ur.zOffset},pc=rn.textBox;if(pc){Ka(pc);const Os=ys=>{let Ri=a.bk.horizontal;if(L.allowVerticalPlacement&&!ys&&this.prevPlacement){const Uo=this.prevPlacement.placedOrientations[Hn];Uo&&(this.placedOrientations[Hn]=Uo,Ri=Uo,this.markUsedOrientation(L,Ri,Ur))}return Ri},Vs=(ys,Ri)=>{if(L.allowVerticalPlacement&&ws>0&&rn.verticalTextBox){for(const Uo of L.writingModes)if(Uo===a.bk.vertical?(ln=Ri(),Ys=ln):ln=ys(),ln&&ln.box&&ln.box.length)break}else ln=ys()};if(rr){let ys=rr;if(this.prevPlacement&&this.prevPlacement.variableOffsets[Hn]){const fi=this.prevPlacement.variableOffsets[Hn];ys.indexOf(fi.anchor)>0&&(ys=ys.filter(gc=>gc!==fi.anchor),ys.unshift(fi.anchor))}const Ri=(fi,gc,Ff)=>{const fp=L.getSymbolInstanceTextSize(Pe,Ur,this.transform.zoom,bn),mp=(fi.x2-fi.x1)*fp+2*fi.padding,ey=(fi.y2-fi.y1)*fp+2*fi.padding,Ph=Ur.hasIconTextFit&&!Be?gc:null;Ph&&Ka(Ph);let Bd={box:[],offscreen:!1,occluded:!1};const ty=De?2*ys.length:ys.length;for(let ql=0;ql=ys.length,Ur,bn,L,Ff,Ph,Pe,Me);if(Bf&&(Bd=Bf.placedGlyphBoxes,Bd&&Bd.box&&Bd.box.length)){ts=!0,rs=Bf.shift;break}}return Bd};Vs(()=>Ri(pc,rn.iconBox,a.bk.horizontal),()=>{const fi=rn.verticalTextBox;return fi&&Ka(fi),L.allowVerticalPlacement&&!(ln&&ln.box&&ln.box.length)&&ws>0&&fi?Ri(fi,rn.verticalIconBox,a.bk.vertical):{box:null,offscreen:null,occluded:null}}),ln&&(ts=ln.box,yn=ln.offscreen,Ps=ln.occluded);const Uo=Os(!(!ln||!ln.box));if(!ts&&this.prevPlacement){const fi=this.prevPlacement.variableOffsets[Hn];fi&&(this.variableOffsets[Hn]=fi,this.markUsedJustification(L,fi.anchor,Ur,Uo))}}else{const ys=(Ri,Uo)=>{const fi=L.getSymbolInstanceTextSize(Pe,Ur,this.transform.zoom,bn),gc=this.collisionIndex.placeCollisionBox(L,fi,Ri,ce,oe,Lr,new a.P(0,0),De,ie,H,Se.predicate);return gc&&gc.box&&gc.box.length&&(this.markUsedOrientation(L,Uo,Ur),this.placedOrientations[Hn]=Uo),gc};Vs(()=>ys(pc,a.bk.horizontal),()=>{const Ri=rn.verticalTextBox;return L.allowVerticalPlacement&&ws>0&&Ri?(Ka(Ri),ys(Ri,a.bk.vertical)):{box:null,offscreen:null,occluded:null}}),Os(!!(ln&&ln.box&&ln.box.length))}}if(Ss=ln,ts=Ss&&Ss.box&&Ss.box.length>0,yn=Ss&&Ss.offscreen,Ps=Ss&&Ss.occluded,Ur.useRuntimeCollisionCircles){const Os=Ur.centerJustifiedTextSymbolIndex>=0?Ur.centerJustifiedTextSymbolIndex:Ur.verticalPlacedTextSymbolIndex,Vs=L.text.placedSymbolArray.get(Os),ys=a.bl(L.textSizeData,Pe,Vs),Ri=F.get("text-padding");Bi=this.collisionIndex.placeCollisionCircles(L,De,Vs,Os,L.lineVertexArray,L.glyphOffsetArray,ys,H,Z,ne,w,Qe,Se.predicate,Ur.collisionCircleDiameter*ys/a.by,Ri,this.retainedQueryData[L.bucketInstanceId].tileID),ts=De||Bi.circles.length>0&&!Bi.collisionDetected,yn=yn&&Bi.offscreen,Ps=Bi.occluded}if(rn.iconFeatureIndex&&(jo=rn.iconFeatureIndex),rn.iconBox){const Os=Vs=>{Ka(Vs);const ys=Ur.hasIconTextFit&&rs?Nf(rs.x,rs.y,Ge,Qe,this.transform.angle):new a.P(0,0),Ri=L.getSymbolInstanceIconSize(Me,this.transform.zoom,Ur.placedIconSymbolIndex);return this.collisionIndex.placeCollisionBox(L,Ri,Vs,ce,oe,gr,ys,Be,ie,H,Se.predicate)};Ys&&Ys.box&&Ys.box.length&&rn.verticalIconBox?(In=Os(rn.verticalIconBox),gn=In.box.length>0):(In=Os(rn.iconBox),gn=In.box.length>0),yn=yn&&In.offscreen,ni=In.occluded}const us=$e||Ur.numHorizontalGlyphVertices===0&&ws===0,Mc=Ke||Ur.numIconVertices===0;if(us||Mc?Mc?us||(gn=gn&&ts):ts=gn&&ts:gn=ts=gn&&ts,ts&&Ss&&Ss.box&&this.collisionIndex.insertCollisionBox(Ss.box,F.get("text-ignore-placement"),L.bucketInstanceId,Ys&&Ys.box&&ra?ra:ks,Se.ID),gn&&In&&this.collisionIndex.insertCollisionBox(In.box,F.get("icon-ignore-placement"),L.bucketInstanceId,jo,Se.ID),Bi&&(ts&&this.collisionIndex.insertCollisionCircles(Bi.circles,F.get("text-ignore-placement"),L.bucketInstanceId,ks,Se.ID),w)){const Os=L.bucketInstanceId;let Vs=this.collisionCircleArrays[Os];Vs===void 0&&(Vs=this.collisionCircleArrays[Os]=new Or);for(let ys=0;ys=0;--bn){const rn=Ur[bn];tn(L.symbolInstances.get(rn),rn,L.collisionArrays[rn])}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 Ur=L.getSortedIndexesByZOffset();for(let bn=0;bn=0&&(d.text.placedSymbolArray.get(I).crossTileID=ne>=0&&I!==ne?0:H),L>=0&&(d.text.placedSymbolArray.get(L).crossTileID=ne>=0&&L!==ne?0:H),F>=0&&(d.text.placedSymbolArray.get(F).crossTileID=ne>=0&&F!==ne?0:H),z>=0&&(d.text.placedSymbolArray.get(z).crossTileID=ne>=0&&z!==ne?0:H)}markUsedOrientation(d,g,w){const j=g===a.bk.horizontal||g===a.bk.horizontalOnly?g:0,I=g===a.bk.vertical?g:0,{leftJustifiedTextSymbolIndex:L,centerJustifiedTextSymbolIndex:F,rightJustifiedTextSymbolIndex:z,verticalPlacedTextSymbolIndex:H}=w,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),H>=0&&(Z.get(H).placedOrientation=I)}commit(d){this.commitTime=d,this.zoomAtLastRecencyCheck=this.transform.zoom;const g=this.prevPlacement;let w=!1;this.prevZoomAdjustment=g?g.zoomAdjustment(this.transform.zoom):0;const j=g?g.symbolFadeChange(d):1,I=g?g.opacities:{},L=g?g.variableOffsets:{},F=g?g.placedOrientations:{};for(const z in this.placements){const H=this.placements[z],Z=I[z];Z?(this.opacities[z]=new Ym(Z,j,H.text,H.icon,null,H.clipped),w=w||H.text!==Z.text.placed||H.icon!==Z.icon.placed):(this.opacities[z]=new Ym(null,j,H.text,H.icon,H.skipFade,H.clipped),w=w||H.text||H.icon)}for(const z in I){const H=I[z];if(!this.opacities[z]){const Z=new Ym(H,j,!1,!1);Z.isHidden()||(this.opacities[z]=Z,w=w||H.text.placed||H.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]);w?this.lastPlacementChangeTime=d:typeof this.lastPlacementChangeTime!="number"&&(this.lastPlacementChangeTime=g?g.lastPlacementChangeTime:d)}updateLayerOpacities(d,g,w,j){j&&(this.lastReplacementSourceUpdateTime=j.updateTime);const I=new Set;for(const L of g){const F=L.getBucket(d);F&&L.latestFeatureIndex&&d.fqid===F.layerIds[0]&&(this.updateBucketOpacities(F,I,L,L.collisionBoxArray,w,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,w,j,I,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 H=d.layers[0].layout,Z=d.layers[0].paint,ne=!!d.layers[0].dynamicFilter(),re=new Ym(null,0,!1,!1,!0),ie=H.get("text-allow-overlap"),ce=H.get("icon-allow-overlap"),oe=H.get("text-variable-anchor"),xe=H.get("text-rotation-alignment")==="map",ye=H.get("text-pitch-alignment")==="map",Pe=Z.get("symbol-z-offset"),Me=H.get("symbol-elevation-reference")==="sea",Se=!Pe.isConstant(),Ze=new Ym(null,0,ie&&(ce||!d.hasIconData()||H.get("icon-optional")),ce&&(ie||!d.hasTextData()||H.get("text-optional")),!0);!d.collisionArrays&&j&&(d.hasIconCollisionBoxData()||d.hasTextCollisionBoxData())&&d.deserializeCollisionBoxes(j);const $e=(De,Be,Ge)=>{for(let at=0;at0||at>0,rr=xt>0,Wt=this.placedOrientations[Qe],Kt=Wt===a.bk.vertical,Ot=Wt===a.bk.horizontal||Wt===a.bk.horizontalOnly;!Tt&&!rr||_t.isHidden()||Ke++;let Ar=!1;if((Tt||rr)&&L)for(const Lr of d.activeReplacements){if(a.bz(Lr,I,a.bA.Symbol,z)||Lr.min.x>ft||ft>Lr.max.x||Lr.min.y>Lt||Lt>Lr.max.y)continue;const gr=a.bB(ft,Lt,F.canonical,Lr.footprintTileId.canonical);if(Ar=a.bC(gr,Lr.footprint),Ar)break}if(Ar&&this.collisionIndex.markSymbolAsClipped(d.bucketInstanceId,Be.featureIndex),Tt){const Lr=Ar?Th:Lg(_t.text);$e(d.text,Ge,Kt?Th:Lr),$e(d.text,at,Ot?Th:Lr);const gr=_t.text.isHidden(),{leftJustifiedTextSymbolIndex:Tr,centerJustifiedTextSymbolIndex:Wr,rightJustifiedTextSymbolIndex:an,verticalPlacedTextSymbolIndex:tn}=Be,_n=d.text.placedSymbolArray,Ur=gr||Kt?1:0;Tr>=0&&(_n.get(Tr).hidden=Ur),Wr>=0&&(_n.get(Wr).hidden=Ur),an>=0&&(_n.get(an).hidden=Ur),tn>=0&&(_n.get(tn).hidden=gr||Ot?1:0);const bn=this.variableOffsets[Qe];bn&&this.markUsedJustification(d,bn.anchor,Be,Wt);const rn=this.placedOrientations[Qe];rn&&(this.markUsedJustification(d,"left",Be,rn),this.markUsedOrientation(d,rn,Be))}if(rr){const Lr=Ar?Th:Lg(_t.icon),{placedIconSymbolIndex:gr,verticalPlacedIconSymbolIndex:Tr}=Be,Wr=d.icon.placedSymbolArray,an=_t.icon.isHidden()?1:0;gr>=0&&($e(d.icon,xt,Kt?Th:Lr),Wr.get(gr).hidden=an),Tr>=0&&($e(d.icon,Be.numVerticalIconVertices,Ot?Th:Lr),Wr.get(Tr).hidden=an)}if(d.hasIconCollisionBoxData()||d.hasTextCollisionBoxData()){const Lr=d.collisionArrays[De];if(Lr){let gr=new a.P(0,0),Tr=!0;if(Lr.textBox||Lr.verticalTextBox){if(oe){const an=this.variableOffsets[Qe];an?(gr=Sl(an.anchor,an.width,an.height,an.textOffset,an.textScale),xe&&gr._rotate(ye?this.transform.angle:-this.transform.angle)):Tr=!1}ne&&(Tr=!_t.clipped),Lr.textBox&&Zm(d.textCollisionBox.collisionVertexArray,_t.text.placed,!Tr||Kt,tt,Me,gr.x,gr.y),Lr.verticalTextBox&&Zm(d.textCollisionBox.collisionVertexArray,_t.text.placed,!Tr||Ot,tt,Me,gr.x,gr.y)}const Wr=Tr&&!!(!Ot&&Lr.verticalIconBox);Lr.iconBox&&Zm(d.iconCollisionBox.collisionVertexArray,_t.icon.placed,Wr,tt,Me,Be.hasIconTextFit?gr.x:0,Be.hasIconTextFit?gr.y:0),Lr.verticalIconBox&&Zm(d.iconCollisionBox.collisionVertexArray,_t.icon.placed,!Wr,tt,Me,Be.hasIconTextFit?gr.x:0,Be.hasIconTextFit?gr.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 Zm(_,d,g,w,j,I,L){_.emplaceBack(d?1:0,g?1:0,I||0,L||0,w,j?1:0),_.emplaceBack(d?1:0,g?1:0,I||0,L||0,w,j?1:0),_.emplaceBack(d?1:0,g?1:0,I||0,L||0,w,j?1:0),_.emplaceBack(d?1:0,g?1:0,I||0,L||0,w,j?1:0)}const i0=Math.pow(2,25),a0=Math.pow(2,24),tl=Math.pow(2,17),ha=Math.pow(2,16),M4=Math.pow(2,9),o0=Math.pow(2,8),rE=Math.pow(2,1);function Lg(_){if(_.opacity===0&&!_.placed)return 0;if(_.opacity===1&&_.placed)return 4294967295;const d=_.placed?1:0,g=Math.floor(127*_.opacity);return g*i0+d*a0+g*tl+d*ha+g*M4+d*o0+g*rE+d}const Th=0;class nE{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,w,j,I,L){const F=this._bucketParts;for(;this._currentTileIndexz.sortKey-H.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]],H=this.placement.collisionIndex.transform.zoom;if(z.type==="symbol"&&z.visibility!=="none"&&(!z.minzoom||z.minzoom<=H)&&(!z.maxzoom||z.maxzoom>H)){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),oe=Z.layout.get("text-allow-overlap")||Z.layout.get("icon-allow-overlap")||Z.layout.get("text-ignore-placement")||Z.layout.get("icon-ignore-placement"),xe=ce&&oe,ye=this._inProgressLayer=this._inProgressLayer||new nE(Z),Pe=a.F(z.source,z.scope);if(ye.continuePlacement(ne||xe?j[Pe]:w[Pe],this.placement,this._showCollisionBoxes,z,F,I))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._forceFullPlacement=!1,this._done=!0}commit(d){return this.placement.commit(d),this.placement}}const $o=512/a.an/2;class gu{constructor(d,g,w){this.tileID=d,this.bucketInstanceId=w,this.index=new a.bI(g.length,16,Int32Array),this.keys=[],this.crossTileIDs=[];const j=d.canonical.x*a.an,I=d.canonical.y*a.an;for(let L=0;Lxe-ye);for(const xe of oe){const ye=this.crossTileIDs[xe];if(this.keys[xe]===Z&&!w.has(ye)){w.add(ye),H.crossTileID=ye;break}}}}}class Vl{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class SC{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(d){const g=Math.round((d-this.lng)/360);if(g!==0)for(const w in this.indexes){const j=this.indexes[w],I={};for(const L in j){const F=j[L];F.tileID=F.tileID.unwrapTo(F.tileID.wrap+g),I[F.tileID.key]=F}this.indexes[w]=I}this.lng=d}addBucket(d,g,w){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 I=0;Id.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(I)).key];F&&F.findMatches(g.symbolInstances,d,j)}}for(let I=0;I{g[w]=!0});for(const w in this.layerIndexes)g[w]||delete this.layerIndexes[w]}}const Pi=771;class Yr{constructor(d,g,w,j){this.blendFunction=d,this.blendColor=g.toNonPremultipliedRenderColor(null),this.mask=w,this.blendEquation=j}}Yr.Replace=[1,0,1,0],Yr.disabled=new Yr(Yr.Replace,a.aq.transparent,[!1,!1,!1,!1]),Yr.unblended=new Yr(Yr.Replace,a.aq.transparent,[!0,!0,!0,!0]),Yr.alphaBlended=new Yr([1,Pi,1,Pi],a.aq.transparent,[!0,!0,!0,!0]),Yr.alphaBlendedNonPremultiplied=new Yr([770,Pi,770,Pi],a.aq.transparent,[!0,!0,!0,!0]),Yr.multiply=new Yr([774,0,774,0],a.aq.transparent,[!0,!0,!0,!0]),Yr.multiplyAccumulateAlpha=new Yr([774,0,1,Pi],a.aq.transparent,[!0,!0,!0,!0]),Yr.additive=new Yr([1,1,1,1],a.aq.transparent,[!0,!0,!0,!0]);class Cr{constructor(d,g,w){this.func=d,this.mask=g,this.range=w}}Cr.ReadOnly=!1,Cr.ReadWrite=!0,Cr.disabled=new Cr(519,Cr.ReadOnly,[0,1]);const ta=7680;class Jr{constructor(d,g,w,j,I,L){this.test=d,this.ref=g,this.mask=w,this.fail=j,this.depthFail=I,this.pass=L}}Jr.disabled=new Jr({func:519,mask:0},0,0,ta,ta,ta);const Cc=1029,Xm=2305;class Hr{constructor(d,g,w){this.enable=d,this.mode=g,this.frontFace=w}}function c0(_,d){const g=a.bO(_,3);a.bR(_,d),a.bW(_,3,g)}function Z_(_,d){const g=a.bL([]);return a.bM(g,g,-d),a.bN(g,g,-_),g}function X_(_,d){const g=[_[0],_[1],0],w=[d[0],d[1],0];if(a.ai(g)>=1e-15){const L=a.ay([],g);a.bJ(w,L,a.bi(w,L)),d[0]=w[0],d[1]=w[1]}const j=a.bh([],d,_);if(a.bK(j)<1e-15)return null;const I=Math.atan2(-j[1],j[0]);return Z_(Math.atan2(Math.sqrt(_[0]*_[0]+_[1]*_[1]),-_[2]),I)}Hr.disabled=new Hr(!1,Cc,Xm),Hr.backCCW=new Hr(!0,Cc,Xm),Hr.backCW=new Hr(!0,Cc,2304),Hr.frontCW=new Hr(!0,1028,2304),Hr.frontCCW=new Hr(!0,1028,Xm);class u0{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,w){if(this.orientation=null,!this.position)return;const j=this.position,I=w||(this._elevation?this._elevation.getAtPointOrZero(a.ag.fromLngLat(d)):0),L=a.ag.fromLngLat(d,I),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=X_(F,g)}setPitchBearing(d,g){this.orientation=Z_(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&&c0(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=Z_(d,g),c0(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 w=new Float64Array(16);return a.b7(w,this.getWorldToCamera(d,g)),w}getCameraToWorldMercator(){return this._transform}getWorldToCameraPosition(d,g,w){const j=this.position;a.bJ(j,j,-d);const I=new Float64Array(16);return a.bP(I,[w,w,w]),a.bx(I,I,j),I[10]*=g,I}getWorldToCamera(d,g){const w=new Float64Array(16),j=new Float64Array(4),I=this.position;return a.bQ(j,this._orientation),a.bJ(I,I,-d),a.bR(w,j),a.bx(w,w,I),w[1]*=-1,w[5]*=-1,w[9]*=-1,w[13]*=-1,w[8]*=g,w[9]*=g,w[10]*=g,w[11]*=g,w}getCameraToClipPerspective(d,g,w,j){const I=new Float64Array(16);return a.bS(I,d,g,w,j),I}getCameraToClipOrthographic(d,g,w,j,I,L){const F=new Float64Array(16);return a.bT(F,d,g,w,j,I,L),F}getDistanceToElevation(d,g=!1){const w=d===0?0:a.bU(d,g?a.bV(this.position[1]):this.position[1]),j=this.forward();return(w-this.position[2])/j[2]}clone(){return new d0([...this.position],[...this.orientation])}}const D4=(_,d)=>({u_matrix:_,u_ground_shadow_factor:d});class Hu{constructor(d=0,g=0,w=0,j=0){if(isNaN(d)||d<0||isNaN(g)||g<0||isNaN(w)||w<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=w,this.right=j}interpolate(d,g,w){return g.top!=null&&d.top!=null&&(this.top=a.am(d.top,g.top,w)),g.bottom!=null&&d.bottom!=null&&(this.bottom=a.am(d.bottom,g.bottom,w)),g.left!=null&&d.left!=null&&(this.left=a.am(d.left,g.left,w)),g.right!=null&&d.right!=null&&(this.right=a.am(d.right,g.right,w)),this}getCenter(d,g){const w=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(w,j)}equals(d){return this.top===d.top&&this.bottom===d.bottom&&this.left===d.left&&this.right===d.right}clone(){return new Hu(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}const Qm=15;class h0{constructor(d,g,w,j,I,L,F){this.tileSize=512,this._renderWorldCopies=I===void 0||I,this._minZoom=d||0,this._maxZoom=g||22,this._minPitch=w??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 Hu,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 h0(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.pitch0&&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 w=this._elevation;g||this._centerAltitude&&this._centerAltitudeValidForExaggeration&&w.exaggeration()&&this._centerAltitudeValidForExaggeration!==w.exaggeration()?(this._centerAltitude=this._centerAltitude/this._centerAltitudeValidForExaggeration*w.exaggeration(),this._centerAltitudeValidForExaggeration=w.exaggeration()):(this._centerAltitude=d||0,this._centerAltitudeValidForExaggeration=w.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]],w=this.horizonLineFromTop();let j=0,I=0;for(let L=0;L{const xe=a.ck(re,ne,ie,ce,oe);z.has(xe)||(I.push(new a.aR(ne,re,ie,ce,oe)),z.add(xe))};for(let ne=0;nere.canonical.z)continue;const ie=re.canonical,ce=re.overscaledZ,oe=re.wrap,xe=1<0,Me=ie.y+10,Ze=re.wrap-(Pe?0:1),$e=re.wrap+(ye?0:1),Ke=Pe?ie.x-1:xe-1,De=ye?ie.x+1:0;if(L)w[0]<0?(H(ce,$e,ie.z,De,ie.y),w[1]<0&&Me&&(H(ce,oe,ie.z,ie.x,ie.y+1),H(ce,$e,ie.z,De,ie.y+1)),w[1]>0&&Se&&(H(ce,oe,ie.z,ie.x,ie.y-1),H(ce,$e,ie.z,De,ie.y-1))):w[0]>0?(H(ce,Ze,ie.z,Ke,ie.y),w[1]<0&&Me&&(H(ce,oe,ie.z,ie.x,ie.y+1),H(ce,Ze,ie.z,Ke,ie.y+1)),w[1]>0&&Se&&(H(ce,oe,ie.z,ie.x,ie.y-1),H(ce,Ze,ie.z,Ke,ie.y-1))):w[1]<0&&Me?H(ce,oe,ie.z,ie.x,ie.y+1):Se&&H(ce,oe,ie.z,ie.x,ie.y-1);else{const Be=re.visibleQuadrants;1&Be&&(H(ce,Ze,ie.z,Ke,ie.y),Se&&(H(ce,oe,ie.z,ie.x,ie.y-1),H(ce,Ze,ie.z,Ke,ie.y-1))),2&Be&&(H(ce,$e,ie.z,De,ie.y),Se&&(H(ce,oe,ie.z,ie.x,ie.y-1),H(ce,$e,ie.z,De,ie.y-1))),4&Be&&(H(ce,Ze,ie.z,Ke,ie.y),Me&&(H(ce,oe,ie.z,ie.x,ie.y+1),H(ce,Ze,ie.z,Ke,ie.y+1))),8&Be&&(H(ce,$e,ie.z,De,ie.y),Me&&(H(ce,oe,ie.z,ie.x,ie.y+1),H(ce,$e,ie.z,De,ie.y+1)))}}const Z=[];for(const ne of I)I.some(re=>ne.isChildOf(re))||Z.push(ne);if(I=Z.filter(ne=>!d.some(re=>!!(ne.overscaledZ{const ye=xe.canonical.x+.5-ie[0],Pe=xe.canonical.y+.5-ie[1];return ye*ye+Pe*Pe{const Ke=a.ck(Me,Pe,Se,Ze,$e);I.has(Ke)||(j.push(new a.aR(Pe,Me,Se,Ze,$e)),I.add(Ke))},F=d.reduce((Pe,Me)=>Math.max(Pe,Me.overscaledZ),w),z=1<{const Se=Math.floor(Pe[0]),Ze=Math.floor(Pe[1]),$e=(Pe[0]-Se)*a.an,Ke=(Pe[1]-Ze)*a.an,De=Math.floor(Me[0]),Be=Math.floor(Me[1]),Ge=(Me[0]-De)*a.an,at=(Me[1]-Be)*a.an;for(let Qe=-1;Qe<=1;Qe++){const xt=Se+Qe;if(!(xt<0||xt>=z)){Z.x=$e-Qe*a.an,ne.x=Ge-(xt-De)*a.an;for(let ft=-1;ft<=1;ft++){const Lt=Ze+ft;Z.y=Ke-ft*a.an,ne.y=at-(Lt-Be)*a.an,a.cI(Z,ne,H)&&L(F,0,w,xt,Lt)}}}},ie=g.points,ce=ie[a.c9],oe=ie[a.ca],xe=this._projectToGround(ce,ie[a.cb]),ye=this._projectToGround(oe,ie[a.cc]);return re(ce,xe),re(oe,ye),j}_projectToGround(d,g){return a.cd(a.ce(),d,g,d[2]/(d[2]-g[2]))}_projectToZ(d,g,w){const j=d[2]-g[2];return Math.abs(j)<1e-6?a.cf(d):a.cd(a.ce(),d,g,(d[2]-w)/j)}extendTileCoverForTunnels(d,g,w,j){if(w<18)return[];const I=g.points,L=I[a.cg],F=I[a.ch],z=I[a.ci],H=I[a.cj];if(z[2]>=0&&H[2]>=0||L[2]<=0||F[2]<=0)return[];const Z=z[2]<0?this._projectToZ(L,z,0):z,ne=H[2]<0?this._projectToZ(F,H,0):H,re=-j,ie=z[2]3&&(oe.length=3),oe}_findExtensionTilesInQuad(d,g,w,j){const I=[],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,at=De.canonical.y+.5-Ke,Qe=Be.canonical.x+.5-$e,xt=Be.canonical.y+.5-Ke;return Ge*Ge+at*at-(Qe*Qe+xt*xt)||De.canonical.x-Be.canonical.x||De.canonical.y-Be.canonical.y}),I}coveringTiles(d){let g=this.coveringZoomLevel(d);const w=g,j=this.elevation&&this.elevation.exaggeration(),I=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,H=1<{const _t=new a.ag(tt.x+25e-6,tt.y,tt.z),Tt=new a.ag(tt.x,tt.y+25e-6,tt.z),rr=tt.toLngLat(),Wt=_t.toLngLat(),Kt=Tt.toLngLat(),Ot=this.locationCoordinate(rr),Ar=this.locationCoordinate(Wt),Lr=this.locationCoordinate(Kt),gr=Math.hypot(Ar.x-Ot.x,Ar.y-Ot.y),Tr=Math.hypot(Lr.x-Ot.x,Lr.y-Ot.y);return Math.sqrt(gr*Tr)*Ke/25e-6},Be=tt=>{const gt=Ze,_t=$e;return{aabb:a.cp(this,H,0,0,0,tt,_t,gt,this.projection),zoom:0,x:0,y:0,minZ:_t,maxZ:gt,wrap:tt,fullyVisible:!1}},Ge=[];let at=[];const Qe=g,xt=d.reparseOverscaled?w:g,ft=(xe-this._centerAltitude)*oe,Lt=tt=>{if(!this._elevation||!tt.tileID||!L)return;const gt=this._elevation.getMinMaxForTile(tt.tileID),_t=tt.aabb;gt?(_t.min[2]=gt.min,_t.max[2]=gt.max,_t.center[2]=(_t.min[2]+_t.max[2])/2):(tt.shouldSplit=lt(tt),tt.shouldSplit||(_t.min[2]=_t.max[2]=_t.center[2]=this._centerAltitude))},Bt=(tt,gt)=>{if(.707*gt{if(tt.zoom=.9)return!0}else if(I&&(Tt=tt.aabb.distanceZ(ye)*oe),this.projection.isReprojectedInTileSpace&&w<=5){const Tr=Math.pow(2,tt.zoom),Wr=De(new a.ag((tt.x+.5)/Tr,(tt.y+.5)/Tr));rr=Wr>.85?1:Wr}if(!L&&!ne){const Tr=Math.sqrt(gt*gt+_t*_t+Tt*Tt);let Wr=(1<0;){const tt=Ge.pop(),gt=tt.x,_t=tt.y;let Tt=tt.fullyVisible;const rr=()=>this.projection.name==="globe"&&(tt.y===0||tt.y===(1<Wt)continue;let Kt=0;if(!Tt){let gr=Pe?tt.aabb.intersectsPrecise(ie):tt.aabb.intersectsPreciseFlat(ie);if(gr===0&&rr()){const Tr=new a.cn(tt.zoom,gt,_t);gr=a.co(this,H,Tr,!0).intersectsPrecise(ie)}if(gr===0)continue;if(d.calculateQuadrantVisibility)if(ie.containsPoint(tt.aabb.center))Kt=15;else for(let Tr=0;Tr<4;Tr++)tt.aabb.quadrant(Tr).intersects(ie)!==0&&(Kt|=1<>1),Ar={aabb:L?tt.aabb.quadrant(Wt):a.cp(this,H,tt.zoom+1,Kt,Ot,tt.wrap,tt.minZ,tt.maxZ,this.projection),zoom:tt.zoom+1,x:Kt,y:Ot,wrap:tt.wrap,fullyVisible:Tt,tileID:void 0,shouldSplit:void 0,minZ:tt.minZ,maxZ:tt.maxZ};I&&!ne&&(Ar.tileID=new a.aR(tt.zoom+1===Qe?xt:tt.zoom+1,tt.wrap,tt.zoom+1,Kt,Ot),Lt(Ar)),Ge.push(Ar)}}if(this.fogCullDistSq){const tt=this.fogCullDistSq,gt=this.horizonLineFromTop();at=at.filter(_t=>{const Tt=[0,0,0,1],rr=[a.an,a.an,0,1],Wt=this.calculateFogTileMatrix(_t.tileID.toUnwrapped());a.aE(Tt,Tt,Wt),a.aE(rr,rr,Wt);const Kt=a.cq([],Tt,rr),Ot=a.cr([],Tt,rr),Ar=a.cK(Kt,Ot);if(Ar===0)return!0;let Lr=!1;const gr=this._elevation;if(gr&&Ar>tt&>!==0){const Tr=this.calculateProjMatrix(_t.tileID.toUnwrapped());let Wr;d.isTerrainDEM||(Wr=gr.getMinMaxForTile(_t.tileID)),Wr||(Wr={min:$e,max:Ze});const an=a.cs(this.rotation),tn=[an[0]*a.an,an[1]*a.an,Wr.max];a.ah(tn,tn,Tr),Lr=(1-tn[1])*this.height*.5tt.distanceSq-gt.distanceSq).map(tt=>tt.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),w=this.projection.project(d.lng,g);return new a.P(w.x*this.worldSize,w.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 w,j;const I=this.centerPoint;if(this.projection.name==="globe"){const F=this.worldSize;w=(g.x-I.x)/F,j=(g.y-I.y)/F}else{const F=this.pointCoordinate(g),z=this.pointCoordinate(I);w=F.x-z.x,j=F.y-z.y}const L=this.locationCoordinate(d);this.setLocation(new a.ag(L.x-w,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 w=g?a.bU(g,d.lat):void 0,j=this.projection.project(d.lng,d.lat);return new a.ag(j.x,j.y,w)}coordinateLocation(d){return this.projection.unproject(d.x,d.y)}pointRayIntersection(d,g){const w=g??this._centerAltitude,j=[d.x,d.y,0,1],I=[d.x,d.y,1,1];a.aE(j,j,this.pixelMatrixInverse),a.aE(I,I,this.pixelMatrixInverse);const L=I[3];a.cu(j,j,1/j[3]),a.cu(I,I,1/L);const F=j[2],z=I[2];return{p0:j,p1:I,t:F===z?0:(w-F)/(z-F)}}screenPointToMercatorRay(d){const g=[d.x,d.y,0,1],w=[d.x,d.y,1,1];return a.aE(g,g,this.pixelMatrixInverse),a.aE(w,w,this.pixelMatrixInverse),a.cu(g,g,1/g[3]),a.cu(w,w,1/w[3]),g[2]=a.bU(g[2],this._center.lat)*this.worldSize,w[2]=a.bU(w[2],this._center.lat)*this.worldSize,a.cu(g,g,1/this.worldSize),a.cu(w,w,1/this.worldSize),new a.az([g[0],g[1],g[2]],a.ay([],a.ax([],w,g)))}rayIntersectionCoordinate(d){const{p0:g,p1:w,t:j}=d,I=a.bU(g[2],this._center.lat),L=a.bU(w[2],this._center.lat);return new a.ag(a.am(g[0],w[0],j)/this.worldSize,a.am(g[1],w[1],j)/this.worldSize,a.am(I,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 w=this.projection.pointCoordinate3D(this,d.x,d.y);if(w)return new a.ag(w[0],w[1],w[2]);let j=0,I=this.horizonLineFromTop();if(d.y>I)return this.pointCoordinate(d,g);const L=.02*I,F=d.clone();for(let z=0;z<10&&I-j>L;z++){F.y=a.am(j,I,.66);const H=this.projection.pointCoordinate3D(this,F.x,F.y);H?(I=F.y,w=H):j=F.y}return w?new a.ag(w[0],w[1],w[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 w=g&&this.elevation?this.elevation.getAtPointOrZero(d,this._centerAltitude):this._centerAltitude,j=[d.x*this.worldSize,d.y*this.worldSize,w+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,w=this.height-this._edgeInsets.bottom,j=this.width-this._edgeInsets.right,I=this.pointLocation3D(new a.P(g,d)),L=this.pointLocation3D(new a.P(j,d)),F=this.pointLocation3D(new a.P(j,w)),z=this.pointLocation3D(new a.P(g,w));let H=Math.min(I.lng,L.lng,F.lng,z.lng),Z=Math.max(I.lng,L.lng,F.lng,z.lng),ne=Math.min(I.lat,L.lat,F.lat,z.lat),re=Math.max(I.lat,L.lat,F.lat,z.lat);const ie=Math.pow(2,-this.zoom)/16*270,ce=this.projection.name==="globe"?1:4,oe=(xe,ye,Pe,Me,Se)=>{const Ze=(xe+Pe)/2,$e=(ye+Me)/2,Ke=new a.P(Ze,$e),{lng:De,lat:Be}=this.pointLocation3D(Ke),Ge=Math.max(0,H-De,ne-Be,De-Z,Be-re);H=Math.min(H,De),Z=Math.max(Z,De),ne=Math.min(ne,Be),re=Math.max(re,Be),(Seie)&&(oe(xe,ye,Ze,$e,Se+1),oe(Ze,$e,Pe,Me,Se+1))};if(oe(g,d,j,d,1),oe(j,d,j,w,1),oe(j,w,g,w,1),oe(g,w,g,d,1),this.projection.name==="globe"){const[xe,ye]=a.cw(this);xe?(re=90,Z=180,H=-180):ye&&(ne=-90,Z=180,H=-180)}return new a.aK(new a.aU(H,ne),new a.aU(Z,re))}_getBoundsRectangular(d,g){const{top:w,left:j}=this._edgeInsets,I=this.height-this._edgeInsets.bottom,L=this.width-this._edgeInsets.right,F=new a.P(j,w),z=new a.P(L,w),H=new a.P(L,I),Z=new a.P(j,I);let ne=this.pointCoordinate(F,d),re=this.pointCoordinate(z,d);const ie=this.pointCoordinate(H,g),ce=this.pointCoordinate(Z,g),oe=(xe,ye)=>(ye.y-xe.y)/(ye.x-xe.x);return ne.y>1&&re.y>=0?ne=new a.ag((1-ce.y)/oe(ce,ne)+ce.x,1):ne.y<0&&re.y<=1&&(ne=new a.ag(-ce.y/oe(ce,ne)+ce.x,0)),re.y>1&&ne.y>=0?re=new a.ag((1-ie.y)/oe(ie,re)+ie.x,1):re.y<0&&ne.y<=1&&(re=new a.ag(-ie.y/oe(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((w,j)=>{if(j.dem){const I=j.dem.tree;w.min=Math.min(w.min,I.minimums[0]),w.max=Math.max(w.max,I.maximums[0])}return w},{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,w=this.height/2-g*(1-this._horizonShift);return d?Math.max(0,w):w}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-H),ne-Zie&&(L=ie-z),ie-re{for(let lt=0;lt<16;lt++)xt[lt]=a.am(ft[lt],Lt[lt],Bt)})(F,F,z,a.cL(this.pitch>=Qm?1:this.pitch/Qm))}else F=z;const H=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(H,H,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/I,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 oe=this.point,xe=oe.x,ye=oe.y,Pe=this.width%2/2,Me=this.height%2/2,Se=Math.cos(this.angle),Ze=Math.sin(this.angle),$e=xe-Math.round(xe)+Se*Pe+Ze*Me,Ke=ye-Math.round(ye)+Se*Me+Ze*Pe,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,H),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,w=this._camera.position,j=1/this.height/this._pixelsPerMercatorPixel,I=[d,d,g];a.bJ(I,I,j),a.bJ(w,w,-1),a.cG(w,w,I);const L=a.bb();a.bx(L,L,w),a.cC(L,L,I),this.mercatorFogMatrix=L,this.worldToFogMatrix=this._camera.getWorldToCameraPosition(d,g,j)}_computeCameraPosition(d){const g=(d=d||this.pixelsPerMeter)/this.pixelsPerMeter,w=this._camera.forward(),j=this.point,I=this._mercatorZfromZoom(this._seaLevelZoom?this._seaLevelZoom:this._zoom)*g-d/this.worldSize*this._centerAltitude;return[j.x/this.worldSize-w[0]*I,j.y/this.worldSize-w[1]*I,d/this.worldSize*this._centerAltitude-w[2]*I]}_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),w=this._camera.position[2],j=d[2];let I=1;this.projection.wrap&&(this.center=this.center.wrap()),j>0&&(I=Math.min((g-w)/j,1)),this._camera.position=a.bg([],this._camera.position,d,I),this._updateStateFromCamera()}_updateStateFromCamera(){const d=this._camera.position,g=this._camera.forward(),{pitch:w,bearing:j}=this._camera.getPitchBearing(),I=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]-I)/Math.cos(w),L),z=this._zoomFromMercatorZ(F);a.bg(d,d,g,F),this._pitch=a.aC(w,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,w=a.cv,j=0,I=1/0;for(;w-g>1e-6&&w>g;){const L=g+.5*(w-g),F=this.tileSize*Math.pow(2,L),z=this.getCameraToCenterDistance(this.projection,L,F),H=this.scaleZoom(z/(Math.max(0,d)*this.tileSize)),Z=Math.abs(L-H);ZH||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 w=a.ai(a.ax([],this._camera.position,d)),j=this._zoomFromMercatorZ(w)+g;return w-this._mercatorZfromZoom(j)}getCameraPoint(){if(this.projection.name==="globe"){const d=function([g,w,j],I){const L=[g,w,j,1];a.aE(L,L,I);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,w=this.worldSize){const j=a.cy(d,g,this.width,this.height,1024),I=d.pixelSpaceConversion(this.center.lat,w,j);let L=.5/Math.tan(.5*this._fov)*this.height*I;return this.isOrthographic&&(L=a.am(1,L,a.cL(this.pitch>=Qm?1:this.pitch/Qm))),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 Ba=(_,d)=>{if(d>0&&_.terrain&&a.w("Cutoff is currently disabled on terrain"),d<=0||_.terrain)return{shouldRenderCutoff:!1,uniformValues:{u_cutoff_params:[0,0,0,1]}};const g=_.transform,w=g.pitch,j=g.isLODDisabled(!1)?60:30;if(w0,uniformValues:{u_cutoff_params:[g._nearZ,g._farZ,(Z-g._nearZ)/I,(Z-re-g._nearZ)/I]}}},Cf=2048;class Q_{constructor(d,g){this.aabb=d,this.lastCascade=g}}class TC{add(d,g){const w=this.receivers[d.key];w!==void 0?(w.aabb.min[0]=Math.min(w.aabb.min[0],g.min[0]),w.aabb.min[1]=Math.min(w.aabb.min[1],g.min[1]),w.aabb.min[2]=Math.min(w.aabb.min[2],g.min[2]),w.aabb.max[0]=Math.max(w.aabb.max[0],g.max[0]),w.aabb.max[1]=Math.max(w.aabb.max[1],g.max[1]),w.aabb.max[2]=Math.max(w.aabb.max[2],g.max[2])):this.receivers[d.key]=new Q_(g,null)}clear(){this.receivers={}}get(d){return this.receivers[d.key]}computeRequiredCascades(d,g,w){const j=a.cU.fromPoints(d.points);let I=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 H=0;H1||re[1]<-1||re[1]>1){Z=!1;break}}if(F.lastCascade=H,I=Math.max(I,H),Z)break}}return I+1}}class f0{constructor(d){this.painter=d,this._enabled=!1,this._drawShadowAfterLayer=-1,this._numCascadesToRender=0,this._cascades=[],this._groundShadowTiles=[],this._receivers=new TC,this._depthMode=new Cr(d.context.gl.LEQUAL,Cr.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 w=this.painter;if(this._enabled=!1,this._drawShadowAfterLayer=-1,this._receivers.clear(),!g||!g.properties)return;const j=g.properties.get("shadow-intensity"),I=g.properties.get("shadow-draw-before-layer");if(!g.shadowsEnabled()||j<=0)return;let L=-1,F=0;for(const ye of w.style.order){const Pe=w.style._mergedLayers[ye];Pe.hasShadowPass()&&!Pe.isHidden(d.zoom)&&(L=F),!I||I!==ye&&I!==Pe.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=w.context,H=Cf,Z=Cf;if(this._cascades.length===0||Cf!==this._cascades[0].texture.size[0]){this._cascades=[];for(let ye=0;ye<2;++ye){const Pe=z.gl,Me=z.createFramebuffer(H,Z,0,"texture"),Se=new a.T(z,{width:H,height:Z,data:null},Pe.DEPTH_COMPONENT16);Me.depthAttachment.set(Se.texture),this._cascades.push({framebuffer:Me,texture:Se,matrix:[],far:0,boundingSphereRadius:0,frustum:new a.cl,scale:0})}}this.shadowDirection=EC(g);let ne=0;if(d.elevation){const ye=d.elevation,Pe=[1e4,-1e4];ye.visibleDemTiles.filter(Me=>Me.dem).forEach(Me=>{const Se=Me.dem.tree;Pe[0]=Math.min(Pe[0],Se.minimums[0]),Pe[1]=Math.max(Pe[1],Se.maximums[0])}),Pe[0]!==1e4&&(ne=(Pe[1]-Pe[0])*ye.exaggeration())}const re=1.5*d.cameraToCenterDistance,ie=3*re,ce=new Float64Array(16);for(let ye=0;ye=0)return{};const I=function(z,H,Z){const ne=Z/(1<0&&(a.cT(I[1],I[1],[j[0]*L,0,0]),a.cT(I[2],I[2],[j[0]*L,0,0])),j[1]<0?(a.cT(I[0],I[0],[0,j[1]*L,0]),a.cT(I[1],I[1],[0,j[1]*L,0])):j[1]>0&&(a.cT(I[2],I[2],[0,j[1]*L,0]),a.cT(I[3],I[3],[0,j[1]*L,0]));const F={};return F.vertices=I,F.planes=[J_(I[1],I[0],I[4]),J_(I[2],I[1],I[5]),J_(I[3],I[2],I[6]),J_(I[0],I[3],I[7])],F}addShadowReceiver(d,g,w){this._receivers.add(d,a.cU.fromTileIdAndHeight(d,g,w))}getMaxCascadeForTile(d){const g=this._receivers.get(d);return g&&g.lastCascade?g.lastCascade:0}}function J_(_,d,g){const w=a.ax([],g,d),j=a.ax([],_,d),I=a.bh([],w,j),L=a.ai(I);return L===0?[0,0,1,0]:(a.bJ(I,I,1/L),[I[0],I[1],I[2],-a.bi(I,d)])}function EC(_){const d=_.properties.get("direction"),g=a.cP(d.x,d.y,d.z);g[2]=a.aC(g[2],0,75);const w=a.cR([g[0],g[1],g[2]]);return a.cQ(w.x,w.y,w.z)}function Wu(_,d,g){const w=d.properties.get("color-use-theme")==="none",j=d.properties.get("color"),I=d.properties.get("intensity"),L=d.properties.get("direction"),F=[L.x,L.y,L.z],z=g.properties.get("color-use-theme")==="none",H=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,H.toPremultipliedRenderColor(z?null:_.getLut(d.scope)).toArray01Linear().slice(0,3),Z);const ie=[0,0,0];return a.bJ(ie,j.toPremultipliedRenderColor(w?null:_.getLut(g.scope)).toArray01Linear().slice(0,3),ne*I),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 m0(_,d,g,w,j,I){const L=_.zoom,F=_.scale,z=_.worldSize,H=1/z,Z=_.aspect,ne=Math.sqrt(1+Z*Z)*Math.tan(.5*_.fovX),re=ne*ne,ie=w-g,ce=w+g;let oe,xe;re>ie/ce?(oe=w,xe=w*ne):(oe=.5*ce*(1+re),xe=.5*Math.sqrt(ie*ie+2*(w*w+g*g)*re+ce*ce*re*re));const ye=_.projection.pixelsPerMeter(_.center.lat,z),Pe=_._camera.getCameraToWorldMercator(),Me=[0,0,-oe*H];a.ah(Me,Me,Pe);let Se=xe*H;const Ze=function(Tt){return Tt[0]/=F,Tt[1]/=F,Tt[2]=a.bU(Tt[2],_._center.lat),Tt},$e=_._edgeInsets;if(!($e.left===0&&$e.top===0&&$e.right===0&&$e.bottom===0||$e.left===$e.right&&$e.top===$e.bottom)){const Tt=_._camera.getWorldToCamera(_.worldSize,_.projection.zAxisUnit==="meters"?ye:1),rr=_._camera.getCameraToClipPerspective(_._fov,_.width/_.height,g,w);rr[8]=2*-_.centerOffset.x/_.width,rr[9]=2*_.centerOffset.y/_.height;const Wt=new Float64Array(16);a.cz(Wt,rr,Tt);const Kt=new Float64Array(16);a.b7(Kt,Wt);const Ot=a.cl.fromInvProjectionMatrix(Kt,z,L,!0);for(const Ar of Ot.points){const Lr=Ze(Ar);Se=Math.max(Se,a.bK(a.cV([],Me,Lr)))}}Se*=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,ye),at=Se*z,Qe=Math.min(_._mercatorZfromZoom(17)*z*-2,-2*at),xt=Be.getCameraToClipOrthographic(-at,at,-at,at,Qe,(at+I*ye)/d[2]),ft=new Float64Array(16);a.aD(ft,xt,Ge);const Lt=a.cQ(Math.floor(1e6*Me[0])/1e6*z,Math.floor(1e6*Me[1])/1e6*z,0),Bt=.5*j,lt=[0,0,0];a.ah(lt,Lt,ft),a.bJ(lt,lt,Bt);const tt=[Math.floor(lt[0]),Math.floor(lt[1]),Math.floor(lt[2])],gt=[0,0,0];a.ax(gt,lt,tt),a.bJ(gt,gt,-1/Bt);const _t=new Float64Array(16);return a.b9(_t),a.bx(_t,_t,gt),a.aD(ft,_t,ft),[ft,at]}class O4 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(w=>{const j=a.cY(w),I=new a.cZ(d,g,void 0,void 0,j);return I.computeBoundsAndApplyParent(),I}).catch(w=>{if(w&&w.status===404)return null;this.fire(new a.B(new Error(`Could not load model ${d} from ${g}: ${w.message}`)))})}load(d,g,w={forceReload:!1}){this.models[g]||(this.models[g]={});const j=Object.keys(d),I=[],L=[];for(const F of j){const z=d[F];this.hasURLBeenRequested(z)&&!w.forceReload||(this.modelByURL[z]={modelId:F,scope:g},I.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(I).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,w={exactIdMatch:!1}){return!!(w.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,w){this.models[w]||(this.models[w]={}),this.modelUris[w]||(this.modelUris[w]={});const j=this.requestManager.normalizeModelURL(g);if((this.hasModel(d,w,{exactIdMatch:!0})||this.hasModelBeenAdded(d,w))&&this.modelUris[w][d]===j)this.models[w][d].numReferences++;else if(this.hasURLBeenRequested(j)){const{scope:I,modelId:L}=this.modelByURL[j];this.models[I][L].numReferences++}else this.modelUris[w][d]=j,this.load({[d]:this.modelUris[w][d]},w)}addModelURLs(d,g){this.models[g]||(this.models[g]={}),this.modelUris[g]||(this.modelUris[g]={});const w=this.modelUris[g];for(const j in d)w[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 w={};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)?w[j]=this.modelUris[g][j]:!this.hasURLBeenRequested(j)&&a.c_(j,!1)&&(this.modelUris[g][j]=this.requestManager.normalizeModelURL(j),w[j]=this.modelUris[g][j]);this.load(w,g)}hasURLBeenRequested(d){return this.modelByURL[d]!==void 0}removeModel(d,g,w=!1,j=!1){if(this.models[g]&&this.models[g][d]&&(this.models[g][d].numReferences--,this.models[g][d].numReferences===0||j)){const I=this.modelUris[g][d];w||delete this.modelUris[g][d],delete this.modelByURL[I];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 w=this.models[d][g].model;delete this.models[d][g],w&&w.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 w in this.models[g])this.models[g][w].model&&this.models[g][w].model.upload(d.context)}}const sE=a.a8.colorTheme,Dg=new a.ab({data:new a.ac(sE.data)});function jC(_){if(!_.metadata||!_.metadata.content_area)return;const d=a.o.devicePixelRatio,{left:g,top:w,width:j,height:I}=_.metadata.content_area,L=g*d,F=w*d;return[L,F,L+j*d,F+I*d]}function p0(_){if(_)return _.map(([d,g])=>[d*a.o.devicePixelRatio,g*a.o.devicePixelRatio])}class iE{constructor(d,g,w){this.id=d,this.scope=g,this.sourceCache=w,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 w=this.sourceCache.getSource();if(!(w instanceof Hm))return d;const j=g.map(L=>this.sourceCache.getTile(L)),I=w.getImages(j,Array.from(this.pendingRequests));for(const[L,F]of I)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 If{constructor(){this._previousClosestBuildingId=null,this._hysteresisRatio=.8,this._indoorMinimumZoom=16}findClosestBuilding(d,g,w,j,I){if(wz*this._hysteresisRatio&&(L=this._previousClosestBuildingId):H&&!L&&(L=this._previousClosestBuildingId),this._previousClosestBuildingId=L,L}_calculateDistance(d,g){if(!g.center)return Number.MAX_VALUE;const w=d.lat-g.center[1],j=d.lng-g.center[0];return w*w+j*j}_isBuildingVisible(d,g,w){if(!w)return!1;for(const j of d.floorIds){const I=d.floors[j];if(!I.geometry)continue;const L=I.geometry;if(L.type==="Polygon"){const F=this._convertRingToPoints(L.coordinates[0]);if(a.bw(F,w))return!0}else if(L.type==="MultiPolygon"){const F=this._convertMultiPolygonToPoints(L.coordinates);if(a.d0(w,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(w=>new a.P(w[0],w[1])))}}class F4 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 If,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[w,j]of Object.entries(d.buildings))if(this._buildings[w])for(const I of j.floorIds)this._buildings[w].floorIds.add(I),this._buildings[w].floors[I]?this._mergeFloors(this._buildings[w].floors[I],j.floors[I]):(this._buildings[w].floors[I]=j.floors[I],g=!0);else this._buildings[w]=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,w=g&&d?d[g]:void 0;if(!w)return{selectedFloorId:null,activeFloorsVisible:!!this._indoorState&&this._indoorState.activeFloorsVisible,floors:[]};let j=null;for(const L of w.floorIds)if(this._activeFloors&&this._activeFloors.has(L)){j=L;break}const I=Array.from(w.floorIds).map(L=>({id:L,name:w.floors[L].name,zIndex:w.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:I}}_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 w=this._closestBuildingId;this._closestBuildingId=g,this._onBuildingTransition(w,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,w){if(g===w)return!0;if(!g||!w||g.size!==w.size)return!1;for(const j of g)if(!w.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,w=d.height;return[d.pointLocation(new a.P(0,0)),d.pointLocation(new a.P(g,0)),d.pointLocation(new a.P(g,w)),d.pointLocation(new a.P(0,w))].map(j=>new a.P(j.lng,j.lat))}}const Jm=(_,d)=>dr(_,d&&d.filter(g=>g.identifier!=="source.canvas")),B4=a.aJ(es,["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"]),AC=a.aJ(es,["setCenter","setZoom","setBearing","setPitch"]),aE=new Set(["background","sky","slot","custom"]),eb={version:8,layers:[],sources:{}},oE={duration:300,delay:0};class yu 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({},oE),this._buildingIndex=new r0(this),this.crossTileSymbolIndex=new Mg,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 jn,this._hasDataDrivenEmissive=!1,this.indoorManager=new F4(this),this.dispatcher=g.dispatcher?g.dispatcher:new ar(Tn(),this),this.map.painter&&this.map.painter.context){const j=this.map.painter.context.maxUniformBufferBindings,I=Math.floor(this.map.painter.context.maxUniformBlockSize/4);this.dispatcher.broadcast("setContextParams",{maxBindingPoints:j,maxUniformBlockSizeDwords:I,disableSymbolUBO:this.map.painter.context.disableSymbolUBO})}g.imageManager?this.imageManager=g.imageManager:(this.imageManager=new ss(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 O4(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 w=this;this._rtlTextPluginCallback=yu.registerForPluginStateChange(j=>{w.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:j.pluginStatus,pluginURL:j.pluginURL},(I,L)=>{if(a.d6(I),L&&L.every(F=>F))for(const F in w._sourceCaches){const z=w._sourceCaches[F],H=z.getSource().type;H!=="vector"&&H!=="geojson"||z.reload()}})}),this.on("data",j=>{if(j.dataType!=="source"||j.sourceDataType!=="metadata")return;const I=this.getOwnSource(j.sourceId);if(I&&I.vectorLayerIds)for(const L in this._layers){const F=this._layers[L];F.source===I.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,w){this.globalId=this._getGlobalId(d);const j=(I,L)=>{try{L(null,this.setState(I,w))}catch(F){L(F,!1)}};if(typeof d=="string"){const I=this.map._requestManager.normalizeStyleURL(d),L=this.map._requestManager.transformRequest(I,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 w=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,w);const I=this.map._requestManager.transformRequest(d,a.R.Style);this._request=a.m(I,(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,w)})}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(eb,!1)}_loadImports(d,g,w){if(this.importDepth>=4)return a.w("Style doesn't support nesting deeper than 5"),Promise.resolve();const j=[];for(const I of d){const L=this._createFragmentStyle(I),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(I.url)){L.loadEmpty();continue}const z=I.data||this.importsCache.get(I.url);z?(I.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)):I.url?L.loadURL(I.url,{validate:g}):L.loadEmpty();const H={style:L,id:I.id,config:I.config};if(w){const Z=this.fragments.findIndex(({id:ne})=>ne===w);this.fragments=this.fragments.slice(0,Z).concat(H).concat(this.fragments.slice(Z))}else this.fragments.push(H)}return Promise.allSettled(j)}getImportGlobalIds(d=this,g=new Set){for(const w of d.fragments)w.style.globalId&&g.add(w.style.globalId),this.getImportGlobalIds(w.style,g);return[...g.values()]}_createFragmentStyle(d){const g=this.scope?a.F(d.id,this.scope):d.id;let w;const j=this._initialConfig&&this._initialConfig[g];(d.config||j)&&(w=Object.assign({},d.config,j));const I=new yu(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:w,configOptions:this.options,colorThemeOverride:d["color-theme"],configDependentLayers:this._configDependentLayers,indoorDependentLayers:this._indoorDependentLayers});return I.setEventedParent(this.map,{style:I}),I}_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 I=Object.assign({},eb,{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(I,g)}if(this.updateConfig(this._config,d.schema),g&&Jm(this,du(d)))return;this._loaded=!0;for(const I in d.sources)this.addSource(I,d.sources[I],{validate:!1,isInitialLoad:!0});this.stylesheet=a.d9(d);const w=()=>{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 I=XT(this.stylesheet.layers);if(this._order=I.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 $r(z.properties,z.id)}else this.setLights(this.stylesheet.lights);this.light||(this.light=new $r(this.stylesheet.light)),this._layers={};for(const z of I){const H=a.de(z,this.scope,this._styleColorTheme.lut,this.options);H.expressionDependencies.configDependencies.size!==0&&this._configDependentLayers.add(H.fqid),H.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(H.fqid),this._hasAppearances=this._hasAppearances||H.getAppearances().length!==0,H.setEventedParent(this,{layer:{id:H.id}}),this._layers[H.id]=H;const Z=this.getOwnLayerSourceCache(H),ne=!!this.directionalLight&&this.directionalLight.shadowsEnabled();Z&&H.canCastShadows()&&ne&&(Z.castsShadows=!0)}if(this.glyphManager.url){const z=new Set;for(const H in this._layers){const Z=this._layers[H];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 H of z)this.glyphManager.prefetchRange(H,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 I=this._evaluateColorThemeData(j);this._loadColorTheme(I).then(()=>{w()}).catch(L=>{a.w(`Couldn't load color theme from the stylesheet: ${L}`),w()})}else this._styleColorTheme.lut=null,w()}isRootStyle(){return this.importDepth===0}hasAppearances(){return this._hasAppearances||this.fragments.some(d=>d.style.hasAppearances())}mergeAll(){let d,g,w,j,I,L,F,z,H,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&&(w=re.directionalLight);j=this._prioritizeTerrain(j,re.terrain,re.stylesheet.terrain),re.stylesheet.fog&&re.fog!=null&&(I=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&&(H=re.stylesheet.transition),ne[re.scope]=re._styleColorTheme}}),this.light=d,this.ambientLight=g,this.directionalLight=w,this.fog=I,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({},oE,H),this.mergeSources(),this.mergeLayers(),this.mergeIndoor()}forEachFragmentStyle(d){const g=w=>{for(const j of w.fragments)g(j.style);d(w)};g(this)}_prioritizeTerrain(d,g,w){const j=d&&d.drapeRenderMode===0;return w===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={},w={},j={};this.forEachFragmentStyle(I=>{for(const L in I._sourceCaches){const F=a.F(L,I.scope);d[F]=I._sourceCaches[L]}for(const L in I._otherSourceCaches){const F=a.F(L,I.scope);g[F]=I._otherSourceCaches[L]}for(const L in I._symbolSourceCaches){const F=a.F(L,I.scope);w[F]=I._symbolSourceCaches[L]}for(const L in I._fillExtrusionSourceCaches){const F=a.F(L,I.scope);j[F]=I._fillExtrusionSourceCaches[L]}}),this._mergedSourceCaches=d,this._mergedOtherSourceCaches=g,this._mergedSymbolSourceCaches=w,this._mergedFillExtrusionSourceCaches=j}mergeIndoor(){this.forEachFragmentStyle(d=>{if(d.stylesheet&&d.stylesheet.indoor)for(const g of Object.values(d.stylesheet.indoor)){const w=g,j=a.F(w.sourceId,d.scope);this._mergedIndoor[j]=new Set(w.sourceLayers||[])}})}mergeLayers(){const d={},g=[],w={};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 H=a.da(F);if(d[H])continue;d[H]=[]}z.slot&&d[z.slot]?d[z.slot].push(z):g.push(z)}}),this._mergedOrder=[];let j=-1;const I=(L=[])=>{for(const F of L)if(F.type==="slot"){const z=a.da(F.id);d[z]&&I(d[z]),this._mergedSlots.push(z)}else{const z=a.F(F.id,F.scope);this._mergedOrder.push(z),w[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(I(g),this._has3DLayers){const L={};for(let F=0;FL[F]-L[z])}this._mergedLayers=w,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,w,j){const I=Object.assign({},w);for(const F of Object.keys(sE))I[F]===void 0&&(I[F]=sE[F].default);const L=new a.aa(Dg,g,new Map(j));return L.setTransitionOrValue(I,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((w,j)=>{const I="data:image/png;base64,";if(!d||d.length===0)return this._styleColorTheme.lut=null,this._styleColorTheme.lutLoading=!1,void w();let L=d;L.startsWith(I)||(L=I+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 w();this._styleColorTheme.lutLoading=!1;const{width:H,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(H!==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:H,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},w()):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,w,j){let I,L,F;const z=a.o.devicePixelRatio>1?"@2x":"";let H=a.m(w.transformRequest(w.normalizeSpriteURL(g,z,".json"),a.R.SpriteJSON),(re,ie)=>{H=null,F||(F=re,I=ie,ne())}),Z=a.n(w.transformRequest(w.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(I&&L){const re=a.o.getImageData(L),ie={};for(const ce in I){const{width:oe,height:xe,x:ye,y:Pe,sdf:Me,pixelRatio:Se,stretchX:Ze,stretchY:$e,content:Ke}=I[ce],De=new a.q({width:oe,height:xe});a.q.copy(re,De,{x:ye,y:Pe},{x:0,y:0},{width:oe,height:xe},null),ie[ce]={data:De,pixelRatio:Se!==void 0?Se:1,sdf:Me!==void 0&&Me,stretchX:Ze,stretchY:$e,content:Ke,usvg:!1,version:0}}j(null,ie)}}return{cancel(){H&&(H.cancel(),H=null),Z&&(Z.cancel(),Z=null)}}}(d,this.map._requestManager,(g,w)=>{if(this._spriteRequest=null,g)this.fire(new a.B(g));else if(w){const j=new Map;for(const I in w)j.set(a.I.from(I),w[I]);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 w=this.getOwnSourceCache(g.source);if(!w)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=w.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 I=new iE(d,this.scope,w);this.imageManager.addImageProvider(I,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 w,j;this._spriteRequest=(j=(I,L)=>{if(this._spriteRequest=null,I)g?this._loadSprite(d):this.fire(new a.B(I));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((w=this.map._requestManager).transformRequest(w.normalizeIconsetURL(d),a.R.Iconset),(I,L)=>{if(I)return void j(I);const F={},z=a.c$(new a.a$(L));for(const H of z.icons){const Z={version:1,pixelRatio:a.o.devicePixelRatio,content:jC(H),stretchX:H.metadata?p0(H.metadata.stretch_x_areas):void 0,stretchY:H.metadata?p0(H.metadata.stretch_y_areas):void 0,sdf:!1,usvg:!0,icon:H};F[H.name]=Z}j(null,F)}))}_validateLayer(d){const g=this.getOwnSource(d.source);if(!g)return;const w=d.sourceLayer;w&&(g.type==="geojson"||g.vectorLayerIds&&g.vectorLayerIds.indexOf(w)===-1)&&this.fire(new a.B(new Error(`Source layer "${w}" 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 w=this.fragments[g];return w&&w.style&&(d.data=w.style.serialize()),d})}_serializeSources(){const d={};for(const g in this._sourceCaches){const w=this._sourceCaches[g].getSource();d[w.id]||(d[w.id]=w.serialize())}return d}_serializeLayers(d){const g=[];for(const w of d){const j=this._layers[w];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 w=g._transitionablePaint._values["line-emissive-strength"];if(w&&w.value&&w.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 w=this.map.painter;if(w)for(let j=d.minzoom||0;j<(d.maxzoom||25.5);j++){const I=d.getProgramIds();if(I)for(const L of I){const F=d.getDefaultProgramParams(L,g.zoom,this._styleColorTheme.lut);F&&(w.style=this,this.fog&&(w._fogVisible=!0,F.overrideFog=!0,w.getOrCreateProgram(L,F)),w._fogVisible=!1,F.overrideFog=!1,w.getOrCreateProgram(L,F),(this.stylesheet.terrain||this.stylesheet.projection&&this.stylesheet.projection.name==="globe")&&(F.overrideRtt=!0,w.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 w=this._changes.isDirty();let j=!1;if(this._changes.isDirty()){const z=this._changes.getLayerUpdatesByScope();for(const H in z){const{updatedIds:Z,removedIds:ne}=z[H];(Z||ne)&&(this._updateWorkerLayers(H,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 I={};for(const z in this._mergedSourceCaches){const H=this._mergedSourceCaches[z];I[z]=H.used,H.used=!1,H.tileCoverLift=0}const L={};for(const z of this._mergedOrder){const H=this._mergedLayers[z];if((H.visibility!=="none"||H.hasTransition())&&H.recalculate(d,this._availableImages),!H.isHidden(d.zoom)){const Z=this.getLayerSourceCache(H);Z&&(Z.used=!0,Z.tileCoverLift=Math.max(Z.tileCoverLift,H.tileCoverLift()))}if(H.type==="fill-extrusion"){const Z=a.F(H.source,H.scope);if(Z in this._mergedFillExtrusionSourceCaches){const ne=H.layout&&H.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(H,d)}):this.precompilePrograms(H,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 I){const H=this._mergedSourceCaches[z];I[z]!==H.used&&H.getSource().fire(new a.C("data",{sourceDataType:"visibility",dataType:"source",sourceId:H.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),w&&this.fire(new a.C("data",{dataType:"style"}))}updateImageProviders(){const d=this.imageManager.getPendingImageProviders();for(const g of d){const w=g.resolvePendingRequests(),j=this.getFragmentStyle(g.scope);j&&j.addImages(w)}}_updateTilesForChangedImages(){const d={};for(const g in this._mergedSourceCaches){const w=this._mergedSourceCaches[g].getSource().scope;d[w]=d[w]||this._changes.getUpdatedImages(w),d[w].length!==0&&this._mergedSourceCaches[g].reloadTilesForDependencies(["icons","patterns"],d[w])}for(const g in d)this._changes.resetUpdatedImages(g)}_updateWorkerLayers(d,g,w){const j=this.getFragmentStyle(d);j&&this.dispatcher.broadcast("updateLayers",{layers:g?j._serializeLayers(g):[],scope:d,removedIds:w||[],options:j.options})}setState(d,g){if(this._checkLoaded(),Jm(this,du(d)))return!1;(d=a.d9(d)).layers=XT(d.layers);const w=function(L,F){if(!L)return[{command:es.setStyle,args:[F]}];let z=[];try{if(!a.b6(L.version,F.version))return[{command:es.setStyle,args:[F]}];if(a.b6(L.center,F.center)||z.push({command:es.setCenter,args:[F.center]}),a.b6(L.zoom,F.zoom)||z.push({command:es.setZoom,args:[F.zoom]}),a.b6(L.bearing,F.bearing)||z.push({command:es.setBearing,args:[F.bearing]}),a.b6(L.pitch,F.pitch)||z.push({command:es.setPitch,args:[F.pitch]}),a.b6(L.sprite,F.sprite)||z.push({command:es.setSprite,args:[F.sprite]}),a.b6(L.glyphs,F.glyphs)||z.push({command:es.setGlyphs,args:[F.glyphs]}),a.b6(L.imports,F.imports)||function(ie=[],ce=[],oe){ce=ce||[];const xe=(ie=ie||[]).map(Ig),ye=ce.map(Ig),Pe=ie.reduce(n0,{}),Me=ce.reduce(n0,{}),Se=xe.slice();let Ze,$e,Ke,De;for(Ze=0,$e=0;Ze{ie.source&&H[ie.source]?z.push({command:es.removeLayer,args:[ie.id]}):ne.push(ie)});let re=L.terrain;re&&H[re.source]&&(z.push({command:es.setTerrain,args:[void 0]}),re=void 0),z=z.concat(Z),a.b6(re,F.terrain)||z.push({command:es.setTerrain,args:[F.terrain]}),function(ie,ce,oe){ce=ce||[];const xe=(ie=ie||[]).map(Ig),ye=ce.map(Ig),Pe=ie.reduce(n0,{}),Me=ce.reduce(n0,{}),Se=xe.slice(),Ze=Object.create(null);let $e,Ke,De,Be,Ge,at,Qe;for($e=0,Ke=0;$e!(L.command in AC));if(w.length===0)return!1;const j=w.filter(L=>!(L.command in B4));if(j.length>0)throw new Error(`Unimplemented: ${j.map(L=>L.command).join(", ")}.`);const I=[];return w.forEach(L=>{I.push(this[L.command](...L.args))}),g&&Promise.all(I).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,w]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,w),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,w=!1){this.imageManager.updateImage(d,this.scope,g),w&&(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,w={}){return this._checkLoaded(),this._validate(Ut,`models.${d}`,g,null,w)||(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,w={}){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(e0,`sources.${d}`,g,null,w))return;this.map&&this.map._collectResourceTiming&&(g.collectResourceTiming=!0);const j=z_(d,g,this.dispatcher,this);j.scope=this.scope,j.setEventedParent(this,()=>({isSourceLoaded:this._isSourceCacheLoaded(j.id),source:j.serialize(),sourceId:j.id}));const I=L=>{const F=(L===a.b4.Symbol?"symbol:":L===a.b4.FillExtrusion?"fill-extrusion:":"other:")+j.id,z=a.F(F,this.scope),H=this._sourceCaches[F]=new fu(z,j,L);L===a.b4.Symbol?this._symbolSourceCaches[j.id]=H:L===a.b4.FillExtrusion?this._fillExtrusionSourceCaches[j.id]=H:this._otherSourceCaches[j.id]=H,H.onAdd(this.map)};I(a.b4.Other),g.type!=="vector"&&g.type!=="geojson"||(I(a.b4.Symbol),g.type==="vector"&&I(a.b4.FillExtrusion)),j.onAdd&&j.onAdd(this.map),w.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(([I,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 w=this.getOwnSourceCaches(d);for(const j of w){const I=a.da(j.id);delete this._sourceCaches[I],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 w=this.getOwnSourceCache(g);w&&d.push(w.getSource())}return d}areTilesLoaded(){const d=this._mergedSourceCaches;for(const g in d){const w=d[g]._tiles;for(const j in w){const I=w[j];if(I.state!=="loaded"&&I.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 I of d){if(this._validate(de,"lights",I))return;switch(I.type){case"ambient":if(this.ambientLight){const L=this.ambientLight;L.set(I),L.updateTransitions(g)}else this.ambientLight=new Aa(I,To(),this.scope,this.options);break;case"directional":if(this.directionalLight){const L=this.directionalLight;L.set(I),L.updateTransitions(g)}else this.directionalLight=new Aa(I,cc(),this.scope,this.options)}}const w=Object.assign(g,{worldview:this.map.getWorldview()}),j=new a.ae(this.z||0,w);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 w=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(),I=d.properties.get("intensity"),L=d.properties.get("direction"),F=1-a.cP(L.x,L.y,L.z)[2]/90,z=w(j)*I*F,H=g.properties.get("color").toNonPremultipliedRenderColor(null).toArray01(),Z=g.properties.get("intensity"),ne=w(H)*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),w=this.fragments.find(({id:I})=>I===g);if(!w)return;const j=a.da(d);return w.style.getFragmentStyle(j)}{const g=this.fragments.find(({id:w})=>w===d);return g?g.style:void 0}}setFeaturesetSelectors(d){if(!d)return;const g=(w,j="")=>`${w}::${j}`;this._featuresetSelectors={};for(const w in d){const j={},I=this._featuresetSelectors[w]=[];for(const L of d[w].selectors){if(L.featureNamespace){const z=this.getOwnLayer(L.layer);if(!z){a.w(`Layer is undefined for selector: ${L.layer}`);continue}const H=g(z.source,z.sourceLayer);if(H in j&&j[H]!==L.featureNamespace){a.w(`"featureNamespace ${L.featureNamespace} of featureset ${w}'s selector is not associated to the same source, skip this selector`);continue}j[H]=L.featureNamespace}let F;if(L.properties)for(const z in L.properties){const H=a.X(L.properties[z]);H.result==="success"&&(F=F||{},F[z]=H.value)}I.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 w=[];for(const j in g.stylesheet.featuresets)w.push({featuresetId:j,importId:g.scope?g.scope:void 0});return w}getFeaturesetLayers(d,g){const w=this.getFragmentStyle(g),j=w.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 I=[];for(const L of j[d].selectors){const F=w.getOwnLayer(L.layer);F&&I.push(F)}return I}getConfigProperty(d,g){const w=this.getFragmentStyle(d);if(!w)return null;const j=a.F(g,w.scope),I=w.options.get(j),L=I?I.value||I.default:null;return L?L.serialize():null}isIndoorEnabled(){return Object.keys(this._mergedIndoor).length>0}getIndoorSourceLayers(d,g){const w=a.F(d,g);return this._mergedIndoor[w]}setIndoorData(d,g){this.indoorManager.setIndoorData(g)}updateIndoorDependentLayers(){this._updateLayers(this._indoorDependentLayers),this.map._styleDirty=!0,this.map.triggerRepaint()}setConfigProperty(d,g,w){const j=this.getFragmentStyle(d);if(!j)return;const I=j.stylesheet.schema;if(!I||!I[g])return;const L=a.X(w);if(L.result!=="success")return void Jm(this,L.value);const F=L.value.expression,z=a.F(g,j.scope),H=j.options.get(z);if(!H)return;let Z;const{minValue:ne,maxValue:re,stepValue:ie,type:ce,values:oe}=I[g],xe=a.X(I[g].default);xe.result==="success"&&(Z=xe.value.expression),Z?(this.options.set(z,Object.assign({},H,{value:F,default:Z,minValue:ne,maxValue:re,stepValue:ie,type:ce,values:oe})),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 w=g.stylesheet.schema;if(!w)return null;const j={};for(const I in w){const L=a.F(I,g.scope),F=g.options.get(L),z=F?F.value||F.default:null;j[I]=z?z.serialize():null}return j}setConfig(d,g){const w=this.getFragmentStyle(d);w&&(w.updateConfig(g,w.stylesheet.schema),this.updateConfigDependencies())}getSchema(d){const g=this.getFragmentStyle(d);return g?g.stylesheet.schema:null}setSchema(d,g){const w=this.getFragmentStyle(d);w&&(w.stylesheet.schema=g,w.updateConfig(w._config,g),this.updateConfigDependencies())}updateConfig(d,g){if(this._config=d,d||g)if(g)for(const w in g){let j,I;const L=a.X(g[w].default);if(L.result==="success"&&(j=L.value.expression),d&&d[w]!==void 0){const re=a.X(d[w]);re.result==="success"&&(I=re.value.expression)}const{minValue:F,maxValue:z,stepValue:H,type:Z,values:ne}=g[w];if(j){const re=a.F(w,this.scope);this.options.set(re,{default:j,value:I,minValue:F,maxValue:z,stepValue:H,type:Z,values:ne})}else this.fire(new a.B(new Error(`No schema defined for config option "${w}".`)))}else this.fire(new a.B(new Error("Attempting to set config for a style without schema.")))}_updateLayers(d,g=()=>!0){for(const w of d){const j=this.getLayer(w);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 w=g._styleColorTheme.colorThemeOverride?g._styleColorTheme.colorThemeOverride:g._styleColorTheme.colorTheme;if(w){const j=g._evaluateColorThemeData(w);(!g._styleColorTheme.lut&&j!==""||g._styleColorTheme.lut&&j!==g._styleColorTheme.lut.data)&&g.setColorTheme(w)}}),this._changes.setDirty()}addLayer(d,g,w={}){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 I;if(d.type==="custom"){if(Jm(this,a.dd(d)))return;I=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(rt,`layers.${j}`,d,{arrayIndex:-1},w))return;I=a.de(d,this.scope,this._styleColorTheme.lut,this.options),this._validateLayer(I),I.setEventedParent(this,{layer:{id:j}})}const L=a.F(I.source,I.scope);I.expressionDependencies.configDependencies.size!==0&&this._configDependentLayers.add(L),I.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.`)));I.slot&&I.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]=I;const z=this.getOwnLayerSourceCache(I),H=!!this.directionalLight&&this.directionalLight.shadowsEnabled();z&&I.canCastShadows()&&H&&(z.castsShadows=!0);const Z=this._changes.getRemovedLayer(I);if(Z&&I.source&&z&&I.type!=="custom"){this._changes.discardLayerRemoval(I);const ne=a.F(I.source,I.scope);Z.type!==I.type?this._changes.updateSourceCache(ne,"clear"):(this._changes.updateSourceCache(ne,"reload"),z.pause())}this._updateLayer(I),I.onAdd&&I.onAdd(this.map),I.scope=this.scope,this.mergeLayers()}moveLayer(d,g){this._checkLoaded();const w=this._checkLayer(d);if(!w||d===g)return;const j=this._order.indexOf(d);this._order.splice(j,1);let I=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.`)));w.slot&&w.slot!==this._layers[g].slot?a.w(`Layer with id "${g}" has a different slot. Layers can only be rearranged within the same slot.`):I=L}this._order.splice(I,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 w=this._order.indexOf(d);this._order.splice(w,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 I=!1;for(const L in this._layers)if(this._layers[L].source===g.source&&this._layers[L].canCastShadows()){I=!0;break}j.castsShadows=I}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,w){this._checkLoaded();const j=this._checkLayer(d);j&&(j.minzoom===g&&j.maxzoom===w||(g!=null&&(j.minzoom=g),w!=null&&(j.maxzoom=w),this._updateLayer(j)))}getSlots(){return this._checkLoaded(),this._mergedSlots}setSlot(d,g){this._checkLoaded();const w=this._checkLayer(d);w&&w.slot!==g&&(w.slot=g,this._updateLayer(w))}setFilter(d,g,w={}){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(dt,`layers.${j.id}.filter`,g,{layerType:j.type},w)||(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,w,j={}){this._checkLoaded();const I=this._checkLayer(d);if(I&&!a.b6(I.getLayoutProperty(g),w)){if(w!=null&&(!j||j.validate!==!1)&&Jm(I,ht.call(du,{key:`layers.${d}.layout.${g}`,layerType:I.type,objectKey:g,value:w,styleSpec:a.a8,style:{glyphs:!0,sprite:!0}})))return;I.setLayoutProperty(g,w),I.expressionDependencies.configDependencies.size!==0&&this._configDependentLayers.add(I.fqid),I.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(I.fqid),this._updateLayer(I)}}setLayerProperty(d,g,w,j={}){this._checkLoaded();const I=this._checkLayer(d);I&&(g==="appearances"?(I.setAppearances(w),this._updateLayer(I)):I.isPaintProperty(g)?this.setPaintProperty(d,g,w,j):this.setLayoutProperty(d,g,w,j))}getLayoutProperty(d,g){const w=this._checkLayer(d);if(w)return w.getLayoutProperty(g)}setPaintProperty(d,g,w,j={}){this._checkLoaded();const I=this._checkLayer(d);if(!I||a.b6(I.getPaintProperty(g),w)||w!=null&&(!j||j.validate!==!1)&&Jm(I,it.call(du,{key:`layers.${d}.paint.${g}`,layerType:I.type,objectKey:g,value:w,styleSpec:a.a8})))return;const L=I.setPaintProperty(g,w);I.expressionDependencies.configDependencies.size!==0&&this._configDependentLayers.add(I.fqid),I.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(I.fqid),L&&this._updateLayer(I),this._changes.updatePaintProperties(I)}getPaintProperty(d,g){const w=this._checkLayer(d);if(w)return w.getPaintProperty(g)}setFeatureState(d,g){if(this._checkLoaded(),"target"in d){if("featuresetId"in d.target){const{featuresetId:z,importId:H}=d.target,Z=this.getFragmentStyle(H),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,H=this.getLayer(z);this.setFeatureState({id:d.id,source:H.source,sourceLayer:H.sourceLayer},g)}return}const w=d.source,j=d.sourceLayer,I=this._checkSource(w);if(!I)return;const L=I.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(w);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:H}=d.target,Z=this.getFragmentStyle(H),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,H=this.getLayer(z);this.removeFeatureState({id:d.id,source:H.source,sourceLayer:H.sourceLayer},g)}return}const w=d.source,j=this._checkSource(w);if(!j)return;const I=j.type,L=I==="vector"?d.sourceLayer:void 0;if(I==="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(w);for(const z of F)z.removeFeatureState(L,d.id,g)}getFeatureState(d){if(this._checkLoaded(),"target"in d){let I;if("featuresetId"in d.target){const{featuresetId:L,importId:F}=d.target,z=this.getFragmentStyle(F),H=z.getFeaturesetLayers(L);for(const{source:Z,sourceLayer:ne}of H){const re=z.getFeatureState({id:d.id,source:Z,sourceLayer:ne});if(re&&!I)I=re;else if(!a.b6(I,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);I=this.getFeatureState({id:d.id,source:F.source,sourceLayer:F.sourceLayer})}return I}const g=d.source,w=d.sourceLayer,j=this._checkSource(g);if(j){if(j.type!=="vector"||w)return d.id===void 0&&this.fire(new a.B(new Error("The feature id parameter must be provided."))),this.getOwnSourceCaches(g)[0].getFeatureState(w,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)},w=>w!==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),w=a.F(d.source,d.scope),j=this._changes.getUpdatedSourceCaches();d.source&&!j[w]&&g&&g.getSource().type!=="raster"&&(this._changes.updateSourceCache(w,"reload"),g.pause()),d.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(d){const g=F=>this._mergedLayers[F].is3D(!!this.terrain),w=this.order,j={},I=[];for(let F=w.length-1;F>=0;F--){const z=w[F];if(g(z)){j[z]=F;for(const H of d){const Z=H[z];if(Z)for(const ne of Z)I.push(ne)}}}I.sort((F,z)=>z.intersectionZ-F.intersectionZ);const L=[];for(let F=w.length-1;F>=0;F--){const z=w[F];if(g(z))for(let H=I.length-1;H>=0;H--){const Z=I[H].feature;if(Z.layer&&j[Z.layer.id]{if(aE.has(Z.type))return;const ne=this.getOwnLayerSourceCache(Z),re=I[ne.id]=I[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,I,w),z=this._flattenAndSortRenderedFeatures(F),H=[];for(const Z of z)a.dh(Z.layer.id)===this.scope&&H.push(Z);return H}queryRenderedFeatureset(d,g,w){let j;g&&!Array.isArray(g)&&g.filter&&(this._validate(dt,"queryRenderedFeatures.filter",g.filter,null,g),j=a.dg(g.filter));const I="mock",L=[];if(g&&g.target)L.push(Object.assign({},g,{targetId:I,filter:j}));else{const Z=this.getFeaturesetDescriptors();for(const ne of Z)L.push({targetId:I,filter:j,target:ne});for(const{style:ne}of this.fragments){const re=ne.getFeaturesetDescriptors();for(const ie of re)L.push({targetId:I,filter:j,target:ie})}}const F=this.queryRenderedTargets(d,L,w),z=[],H=new Set;for(const Z of F)for(const ne of Z.variants[I])Pd(ne,Z,H)||z.push(new a.di(Z,ne));return z}queryRenderedTargets(d,g,w){const j={},I=(F,z,H,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 H.uniqueFeatureID=!1,void ne.layers[F.fqid].targets.push(H);ne.layers[F.fqid].targets.push(Object.assign({},H,{namespace:Z.namespace,properties:Z.properties,uniqueFeatureID:Z.uniqueFeatureID}))};for(const F of g)if("featuresetId"in F.target){const{featuresetId:z,importId:H}=F.target,Z=this.getFragmentStyle(H);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&&!aE.has(ie.type)&&I(ie,Z.getOwnLayerSourceCache(ie),F,re)}}else if("layerId"in F.target){const{layerId:z}=F.target,H=this.getLayer(z);if(!H||aE.has(H.type))continue;I(H,this.getLayerSourceCache(H),F)}const L=this._queryRenderedFeatures(d,j,w);return this._flattenAndSortRenderedFeatures(L)}_queryRenderedFeatures(d,g,w){const j=[],I=!!this.map._showQueryGeometry,L=uc.createFromScreenPoints(d,w);for(const F in g){const z=_C(L,g[F],this._availableImages,w,I,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=U_(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 w=g&&g.filter;w&&this._validate(dt,"querySourceFeatures.filter",w,null,g);let j=[];const I=this.getOwnSourceCaches(d);for(const L of I)j=j.concat(WT(L,g));return j}addSourceType(d,g,w){return yu.getSourceType(d)?w(new Error(`A source type called "${d}" already exists.`)):(yu.setSourceType(d,g),g.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:d,url:g.workerSourceURL},w):w(null,null))}getFlatLight(){return this.light.getLight()}setFlatLight(d,g,w={}){this._checkLoaded();const j=this.light.getLight();let I=!1;for(const F in d)if(!a.b6(d[F],j[F])){I=!0;break}if(!I)return;const L=this._getTransitionParameters();this.light.setLight(d,g,w),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 w=d;const j=!("source"in d)||d.source==null;if(g===1){if(this.disableElevatedTerrain)return;if("source"in w&&typeof w.source=="object"){const F="terrain-dem-src";this.addSource(F,w.source),w=a.d9(w),w=Object.assign(w,{source:F})}const I=Object.assign({},w),L={};if(this.terrain&&j){I.source=this.terrain.get().source;const F=this.terrain?this.getFragmentStyle(this.terrain.scope):null;F&&(L.style=F.serialize())}if(this._validate(fe,"terrain",I,L))return}if(!this.terrain||this.terrain.scope!==this.scope&&!j||this.terrain&&g!==this.terrain.drapeRenderMode){if(!w)return;this._createTerrain(w,g),this.fire(new a.C("data",{dataType:"style"}))}else{const I=this.terrain,L=I.get();for(const F of Object.keys(a.a8.terrain))!w.hasOwnProperty(F)&&a.a8.terrain[F].default&&(w[F]=a.a8.terrain[F].default);for(const F in d)if(!a.b6(d[F],L[F])){I.set(d,this.options),this.stylesheet.terrain=d;const z=this._getTransitionParameters({duration:0});I.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 ai(d,this.map.transform,this.scope,this.options);this.stylesheet.fog=g.get();const w=this._getTransitionParameters({duration:0});g.updateTransitions(w)}_createSnow(d){const g=this.snow=new xi(d,this.map.transform,this.scope,this.options);this.stylesheet.snow=g.get();const w=this._getTransitionParameters({duration:0});g.updateTransitions(w)}_createRain(d){const g=this.rain=new Dn(d,this.map.transform,this.scope,this.options);this.stylesheet.rain=g.get();const w=this._getTransitionParameters({duration:0});g.updateTransitions(w)}_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 w=this._getTransitionParameters({duration:0});g.updateTransitions(w)}}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 w=this._getTransitionParameters({duration:0});g.updateTransitions(w)}}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 w=this._getTransitionParameters({duration:0});g.updateTransitions(w)}}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 w=this._evaluateColorThemeData(g);this._loadColorTheme(w).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 w=this.getFragmentStyle(d);w&&(w._styleColorTheme.colorThemeOverride=g,w._reloadColorTheme())}_getTransitionParameters(d){return{now:a.o.now(),transition:Object.assign(this.transition,d)}}updateDrapeFirstLayers(){if(!this.terrain)return;const d=[],g=[];for(const w of this._mergedOrder)this.isLayerDraped(this._mergedLayers[w])?d.push(w):g.push(w);this._drapedFirstOrder=[],this._drapedFirstOrder.push(...d),this._drapedFirstOrder.push(...g)}_createTerrain(d,g){const w=this.terrain=new Nn(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});w.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,w,j,I={}){if(I&&I.validate===!1)return!1;const L=Object.assign({},this.serialize());return Jm(this,d.call(du,Object.assign({key:g,style:L,value:w,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 w of g)w.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 w of g)w.resume(),w.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=EC(this.directionalLight));const w=new Set,j=new Set,I=new Set;for(const L in this._mergedLayers){const F=this._mergedLayers[L];F.type==="building"?w.add(F.source):F.type==="raster"&&F.paint&&F.paint.get("raster-elevation-reference")==="ground"&&I.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=I.has(F._source.id),w.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 l0),this.pauseablePlacement.requestFullPlacement()}_setLabelPlacementStale(){this.placement&&this.placement.setStale()}_updatePlacement(d,g,w,j,I){this.pauseablePlacement||(this.pauseablePlacement=new l0);let L=!1,F=!1;const z={},H={};for(const oe of this._mergedOrder){const xe=this._mergedLayers[oe];if(xe.type!=="symbol")continue;const ye=a.F(xe.source,xe.scope);let Pe=z[ye];if(!Pe){const Se=this.getLayerSourceCache(xe);if(!Se)continue;const Ze=Se.getRenderableIds(!0).map($e=>Se.getTileByID($e));H[ye]=Ze.slice(),Pe=z[ye]=Ze.sort(($e,Ke)=>Ke.tileID.overscaledZ-$e.tileID.overscaledZ||($e.tileID.isLessThan(Ke.tileID)?-1:1))}const Me=this.crossTileSymbolIndex.addLayer(xe,Pe,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&&!I||this.placement.lastReplacementSourceUpdateTime!==I.updateTime)),re=Z||ne||L,ie=(re||this.pauseablePlacement.isStale())&&w===0,ce=this.pauseablePlacement.isDone()&&!this.placement.stillRecent(a.o.now(),d.zoom)&&w!==0;if((this.pauseablePlacement.isFullPlacementRequested()||!this.pauseablePlacement.placement||ie||ce)&&(this.pauseablePlacement=this.pauseablePlacement.startNewPlacement(d,this._mergedOrder,g,w,j,this.placement,this.fog&&d.projection.supportsFog?this.fog.state:null,this._buildingIndex),this.map.painter)){const oe=this.map.painter.maxFrontCutoffRawStart;if(oe>0){const xe=180*d.pitch/Math.PI;if(xe>=15){const ye=Math.min(1,Math.max(0,(xe-15)/5)),Pe=ye*ye*(3-2*ye);this.pauseablePlacement.placement.frontCutoffStart=-.5*(1-Pe)+oe*Pe}}}if(this.pauseablePlacement.isDone()?re&&w!==0&&this.pauseablePlacement.setStale():(this.pauseablePlacement.continuePlacement(this._mergedOrder,this._mergedLayers,z,H,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 oe=0;oeI===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 w.push(d),this._loadImports([d],!0);const j=w.findIndex(({id:I})=>I===g);return j===-1&&this.fire(new a.B(new Error(`Import with id "${g}" does not exist on this map.`))),this.stylesheet.imports=w.slice(0,j).concat(d).concat(w.slice(j)),this._loadImports([d],!0,g)}updateImport(d,g){this._checkLoaded();const w=this.stylesheet.imports||[],j=this.getImportIndex(d);return j===-1?this:typeof g=="string"?(this.setImportUrl(d,g),this):(g.url&&g.url!==w[j].url&&this.setImportUrl(d,g.url),a.b6(g.config,w[j].config)||this.setImportConfig(d,g.config,g.data.schema),a.b6(g.data,w[j].data)||this.setImportData(d,g.data),this)}moveImport(d,g){this._checkLoaded();let w=this.stylesheet.imports||[];const j=this.getImportIndex(d);if(j===-1)return this;const I=this.getImportIndex(g);if(I===-1)return this;const L=w[j],F=this.fragments[j];return w=w.filter(({id:z})=>z!==d),this.fragments=this.fragments.filter(({id:z})=>z!==d),this.stylesheet.imports=w.slice(0,I).concat(L).concat(w.slice(I)),this.fragments=this.fragments.slice(0,I).concat(F).concat(this.fragments.slice(I)),this.mergeLayers(),this}setImportUrl(d,g){this._checkLoaded();const w=this.stylesheet.imports||[],j=this.getImportIndex(d);if(j===-1)return this;w[j].url=g;const I=this.fragments[j];return I.style=this._createFragmentStyle(w[j]),I.style.on("style.import.load",()=>this.mergeAll()),I.style.loadURL(g),this}setImportData(d,g){this._checkLoaded();const w=this.getImportIndex(d),j=this.stylesheet.imports||[];return w===-1?this:g?(this.fragments[w].style.setState(g),this._reloadImports(),this):(delete j[w].data,this.setImportUrl(d,j[w].url))}setImportConfig(d,g,w){this._checkLoaded();const j=this.getImportIndex(d),I=this.stylesheet.imports||[];if(j===-1)return this;g?I[j].config=g:delete I[j].config;const L=this.fragments[j];w&&L.style.stylesheet&&(L.style.stylesheet.schema=w);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||[],w=this.getImportIndex(d);w!==-1&&(g.splice(w,1),this.fragments[w].style._remove(),this.fragments.splice(w,1),this._reloadImports())}getImportIndex(d){const g=(this.stylesheet.imports||[]).findIndex(w=>w.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 w=this._mergedOtherSourceCaches[g];w&&d.push(w.getSource())}return d}getSource(d,g){const w=this.getSourceCache(d,g);return w&&w.getSource()}getLayerSource(d){const g=this.getLayerSourceCache(d);return g&&g.getSource()}getSourceCache(d,g){const w=a.F(d,g);return this._mergedOtherSourceCaches[w]}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 w=d[g];w==="reload"?this.reloadSource(g):w==="clear"&&this.clearSource(g)}}updateLayers(d){const g=this._changes.getUpdatedPaintProperties();for(const w of g){const j=this.getLayer(w);j&&j.updateTransitions(d)}}getGlyphsUrl(){return this.stylesheet.glyphs}setGlyphsUrl(d){this.stylesheet.glyphs=d,this.glyphManager.setURL(d)}getImages(d,g,w){this.imageManager.getImages(g.images,g.scope,w),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)}},I=a.F(g.source,g.scope);j(this._mergedOtherSourceCaches[I]),j(this._mergedSymbolSourceCaches[I]),g.images.some(L=>L.iconsetId)&&this.fire(new a.C("data",{dataType:"style"}))}rasterizeImages(d,g,w){this.imageManager.rasterizeImages(g,w)}checkAtlasCache(d,g,w){const j=this.imageManager.imageAtlasCache.findCachedAtlas(g.descriptor);w(null,j&&j.contentDescriptor?{iconPositions:j.iconPositions,patternPositions:j.patternPositions,sourceHash:j.contentDescriptor.hash}:null)}getGlyphs(d,g,w){this.glyphManager.getGlyphs(g.stacks,w)}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(w=>w.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 w=d.type==="fill-extrusion"&&(d.sourceLayer==="building"||d.sourceLayer==="procedural_buildings"),j=d.type==="building";if(d.is3D(!!this.terrain)){if(w||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)}}yu.getSourceType=function(_){return $_[_]},yu.setSourceType=function(_,d){$_[_]=d},yu.registerForPluginStateChange=a.dk;var lE=` #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`,cE=` #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;}`,Pf=` #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`,g0="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;}",uE=` #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`,dE=`#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`,Og=`#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`,Fg=`#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`,hE=`#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;}`,tb=`#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`,Ic=`#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 y0=/#include\s+"([^"]+)"/g,or=/#pragma mapbox: ([\w\-]+) ([\w]+) ([\w]+) ([\w]+)/g,kC=/\b[A-Za-z_][A-Za-z0-9_]*\b/g,NC=new Set(["ifdef","ifndef","elif","if","defined"]),ep=new Set;Eh(lE,ep),Eh(Pf,ep),Eh(cE,ep);const Ku={"_prelude_fog.vertex.glsl":dE,"_prelude_terrain.vertex.glsl":uE,"_prelude_shadow.vertex.glsl":tb,"_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":Og,"_prelude_shadow.fragment.glsl":Ic,"_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":Fg,"_prelude_raster_particle.glsl":hE},Bg={};Bn("",uE),Bn(Og,dE),Bn(Ic,tb),Bn(Fg,""),Bn(hE,"");const Rf=Bn(cE,Pf),x0=lE,$g=[` #if defined(GL_EXT_blend_func_extended) && defined(DUAL_SOURCE_BLENDING) #extension GL_EXT_blend_func_extended : require #endif`,"precision mediump float;",x0,Rf.fragmentSource].join(` `),$4=["precision highp float;",x0,Rf.vertexSource].join(` `);var CC={background:Bn(`#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:Bn(`#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:Bn(`#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:Bn(`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:Bn("void main() {}","in vec3 a_pos_3f;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos_3f,1.0);}"),circle:Bn(`#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:Bn("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:Bn(`#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:Bn(`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:Bn("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:Bn("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:Bn("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:Bn("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:Bn(`#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:Bn(`#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:Bn(`#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:Bn(`#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:Bn(`#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:Bn(`#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:Bn(`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:Bn(`#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:Bn("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:Bn(`#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:Bn(`#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:Bn(`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:Bn(`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:Bn(`#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:Bn(`#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:Bn(`#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:Bn(`#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:Bn(`#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:Bn("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:Bn("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:Bn(`#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:Bn(`#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:Bn(`#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:Bn("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:Bn(`#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 }`,g0),skyboxGradient:Bn(`#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 }`,g0),skyboxCapture:Bn(` 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:Bn(`#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:Bn(`#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:Bn(`#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:Bn("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:Bn(`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:Bn("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:Bn("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:Bn("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:Bn("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 Eh(_,d){const g=_.split(` `);for(let w of g){if(w=w.trimStart(),w[0]!=="#"||!w.includes("if")||w.startsWith("#endif"))continue;const j=w.match(kC);if(j)for(const I of j)NC.has(I)||d.add(I)}}function IC(_){return new Set(["uint","int","uvec2","ivec2","uvec3","ivec3","uvec4","ivec4"]).has(_)}function Bn(_,d){const g=new Set,w=[],j=[];_=_.replace(y0,(L,F)=>(j.push(F),"")),d=d.replace(y0,(L,F)=>(w.push(F),""));let I=new Set(ep);Eh(_,I),Eh(d,I);for(const L of[...w,...j])Bg[L]||(Bg[L]=new Set,Eh(Ku[L],Bg[L])),I=new Set([...I,...Bg[L]]);return{fragmentSource:_=_.replace(or,(L,F,z,H,Z)=>(g.add(Z),F==="define"?` #ifndef HAS_UNIFORM_u_${Z} ${IC(H)?"flat ":""}in ${z} ${H} ${Z}; #else uniform ${z} ${H} u_${Z}; #endif `:F==="initialize"?` #ifdef HAS_UNIFORM_u_${Z} ${z} ${H} ${Z} = u_${Z}; #endif `:F==="define-attribute"?` #ifdef HAS_ATTRIBUTE_a_${Z} in ${z} ${H} ${Z}; #endif `:F==="initialize-attribute"?"":void 0)),vertexSource:d=d.replace(or,(L,F,z,H,Z)=>{const ne=`MATERIAL_ATTRIBUTE_OFFSET_${Z}`,re=H==="float"?"vec2":H,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} ${H} 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 ${IC(H)?"flat ":""}out ${z} ${H} ${Z}; #else uniform ${z} ${H} u_${Z}; #endif `:F==="initialize"?ce==="vec4"||ce==="uvec4"?` #ifndef HAS_UNIFORM_u_${Z} ${Z} = a_${Z}; #else ${z} ${H} ${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} ${H} ${Z} = u_${Z}; #endif `:F==="define-attribute"?` #ifdef HAS_ATTRIBUTE_a_${Z} in ${z} ${H} a_${Z}; out ${z} ${H} ${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} ${H} 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} ${H} u_${Z}; #endif `:` #ifdef INSTANCED_ARRAYS in ${z} ${re} a_${Z}; #else uniform ${z} ${H} u_${Z}; #endif `:F==="initialize-attribute-custom"?` #ifdef HAS_ATTRIBUTE_a_${Z} ${z} ${H} ${Z} = a_${Z}; #endif `:ce==="vec4"||ce==="uvec4"?` #ifndef HAS_UNIFORM_u_${Z} #ifdef ${ne} ${z} ${H} ${Z} = ${ie}; #else ${z} ${H} ${Z} = a_${Z}; #endif #else ${z} ${H} ${Z} = u_${Z}; #endif `:` #ifndef HAS_UNIFORM_u_${Z} #ifdef ${ne} ${z} ${H} ${Z} = unpack_mix_${ce}(${ie}, u_${Z}_t); #else ${z} ${H} ${Z} = unpack_mix_${ce}(a_${Z}, u_${Z}_t); #endif #else ${z} ${H} ${Z} = u_${Z}; #endif `}),usedDefines:I,vertexIncludes:w,fragmentIncludes:j}}class PC{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffers=[],this.vao=null}bind(d,g,w,j,I,L,F,z){this.context=d;let H=this.boundPaintVertexBuffers.length!==j.length;for(let ne=0;!H&&ne{const Ze=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",at=Me.paint.get("hillshade-emissive-strength");let Qe=a.ap(Me.paint.get("hillshade-illumination-direction"));if(Me.paint.get("hillshade-illumination-anchor")==="viewport")Qe-=ye.transform.angle;else if(ye.style&&ye.style.enable3dLights()&&ye.style.directionalLight){const ft=ye.style.directionalLight.properties.get("direction"),Lt=a.cP(ft.x,ft.y,ft.z);Qe=a.ap(Lt[1])}const xt=!ye.options.moving;return{u_matrix:Se||ye.transform.calculateProjMatrix(Pe.tileID.toUnwrapped(),xt),u_image:0,u_latrange:fE(0,Pe.tileID),u_light:[Me.paint.get("hillshade-exaggeration"),Qe],u_shadow:Ze.toPremultipliedRenderColor($e?null:Me.lut),u_highlight:Ke.toPremultipliedRenderColor(De?null:Me.lut),u_emissive_strength:at,u_accent:Be.toPremultipliedRenderColor(Ge?null:Me.lut)}})(_,g,w,_.terrain?d.projMatrix:null);_.uploadCommonUniforms(F,re,d.toUnwrapped());const{tileBoundsBuffer:ce,tileBoundsIndexBuffer:oe,tileBoundsSegments:xe}=_.getTileBoundsBuffers(g);re.draw(_,z.TRIANGLES,j,I,L,Hr.disabled,ie,w.id,ce,oe,xe)}function RC(_,d,g){if(!d.needsDEMTextureUpload)return;const w=_.context,j=w.gl;w.pixelStoreUnpackPremultiplyAlpha.set(!1),d.demTexture=d.demTexture||_.getTileTexture(g.stride);const I=g.getPixels();d.demTexture?d.demTexture.update(I,{premultiply:!1}):d.demTexture=new a.T(w,I,j.R32F,{premultiply:!1}),d.needsDEMTextureUpload=!1}function U4(_,d,g){const w=_.context,j=w.gl;if(!d.dem)return;const I=d.dem;if(w.activeTexture.set(j.TEXTURE1),RC(_,d,I),!d.demTexture)return;d.demTexture.bind(j.NEAREST,j.CLAMP_TO_EDGE);const L=I.dim;w.activeTexture.set(j.TEXTURE0);let F=d.hillshadeFBO;if(!F){const re=new a.T(w,{width:L,height:L,data:null},j.RGBA8);re.bind(j.LINEAR,j.CLAMP_TO_EDGE),F=d.hillshadeFBO=w.createFramebuffer(L,L,1,"renderbuffer"),F.colorAttachment0.set(re.texture)}w.bindFramebuffer.set(F.framebuffer),w.viewport.set([0,0,L,L]);const{tileBoundsBuffer:z,tileBoundsIndexBuffer:H,tileBoundsSegments:Z}=_.getMercatorTileBoundsBuffers(),ne=[];_.linearFloatFilteringSupported()&&ne.push("TERRAIN_DEM_FLOAT_FORMAT"),_.terrain&&_.terrain.renderingToTexture&&_.emissiveMode==="mrt-fallback"&&ne.push("USE_MRT1"),_.getOrCreateProgram("hillshadePrepare",{defines:ne}).draw(_,j.TRIANGLES,Cr.disabled,Jr.disabled,Yr.unblended,Hr.disabled,((re,ie)=>{const ce=ie.stride,oe=a.bb();return a.bT(oe,0,a.an,-a.an,0,0,1),a.bx(oe,oe,[0,-a.an,0]),{u_matrix:oe,u_image:1,u_dimension:[ce,ce],u_zoom:re.overscaledZ}})(d.tileID,I),g.id,z,H,Z),d.needsHillshadePrepare=!1}class li{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 LC extends li{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 V4 extends li{getDefault(){return 1}set(d){(d!==this.current||this.dirty)&&(this.gl.clearDepth(d),this.current=d,this.dirty=!1)}}class rb extends li{getDefault(){return 0}set(d){(d!==this.current||this.dirty)&&(this.gl.clearStencil(d),this.current=d,this.dirty=!1)}}class q4 extends li{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 MC extends li{getDefault(){return!0}set(d){(d!==this.current||this.dirty)&&(this.gl.depthMask(d),this.current=d,this.dirty=!1)}}class mE extends li{getDefault(){return 255}set(d){(d!==this.current||this.dirty)&&(this.gl.stencilMask(d),this.current=d,this.dirty=!1)}}class nb extends li{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 pE extends li{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 tp extends li{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 rp extends li{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 zg extends li{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 Rd extends li{getDefault(){return this.gl.LESS}set(d){(d!==this.current||this.dirty)&&(this.gl.depthFunc(d),this.current=d,this.dirty=!1)}}class DC extends li{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 gE extends li{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 OC extends li{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 Ug extends li{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 sb extends li{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 ib extends li{getDefault(){return this.gl.BACK}set(d){(d!==this.current||this.dirty)&&(this.gl.cullFace(d),this.current=d,this.dirty=!1)}}class yE extends li{getDefault(){return this.gl.CCW}set(d){(d!==this.current||this.dirty)&&(this.gl.frontFace(d),this.current=d,this.dirty=!1)}}let ab=class extends li{getDefault(){return null}set(_){(_!==this.current||this.dirty)&&(this.gl.useProgram(_),this.current=_,this.dirty=!1)}};class v0 extends li{getDefault(){return this.gl.TEXTURE0}set(d){(d!==this.current||this.dirty)&&(this.gl.activeTexture(d),this.current=d,this.dirty=!1)}}class FC extends li{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 BC extends li{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 $C extends li{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 Vg extends li{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 zC extends li{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 G4 extends li{getDefault(){return null}set(d){const g=this.gl;g.bindBuffer(g.ELEMENT_ARRAY_BUFFER,d),this.current=d,this.dirty=!1}}class H4 extends li{getDefault(){return null}set(d){this.gl&&(d!==this.current||this.dirty)&&(this.gl.bindVertexArray(d),this.current=d,this.dirty=!1)}}class W4 extends li{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 xE extends li{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 vE extends li{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 _0 extends li{constructor(d,g){super(d),this.context=d,this.parent=g}getDefault(){return null}}class qg extends _0{constructor(d,g,w=0){super(d,g),this.attachmentPoint=d.gl.COLOR_ATTACHMENT0+w}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 _E extends _0{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 UC extends _0{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 K4 extends _E{attachment(){return this.gl.DEPTH_STENCIL_ATTACHMENT}}const b0=(_,d,g,w)=>({u_matrix:_,u_image0:0,u_image1:1,u_skirt_height:d,u_ground_shadow_factor:g,u_emissive_texture_available:w}),Gg=(_,d,g,w,j,I,L,F,z,H,Z,ne,re,ie,ce,oe,xe)=>({u_proj_matrix:Float32Array.from(_),u_globe_matrix:d,u_normalize_matrix:Float32Array.from(w),u_merc_matrix:g,u_zoom_transition:j,u_merc_center:I,u_image0:0,u_image1:1,u_frustum_tl:L,u_frustum_tr:F,u_frustum_br:z,u_frustum_bl:H,u_globe_pos:Z,u_globe_radius:ne,u_viewport:re,u_grid_matrix:xe?Float32Array.from(xe):new Float32Array(9),u_skirt_height:ie,u_far_z_cutoff:ce,u_emissive_texture_available:oe});function bE(_,d){return _!=null&&d!=null&&!(!_.hasData()||!d.hasData())&&_.demTexture!=null&&d.demTexture!=null&&_.tileID.key!==d.tileID.key}const zo=new class{constructor(){this.operations={}}newMorphing(_,d,g,w,j){if(_ in this.operations){const I=this.operations[_];I.to.tileID.key!==g.tileID.key&&(I.queued=g)}else this.operations[_]={startTime:w,phase:0,duration:j,from:d,to:g,queued:null}}getMorphValuesForProxy(_){if(!(_ in this.operations))return null;const d=this.operations[_];return{from:d.from,to:d.to,phase:d.phase}}update(_){for(const d in this.operations){const g=this.operations[d];for(g.phase=(_-g.startTime)/g.duration;g.phase>=1||!this._validOp(g);)if(!this._nextOp(g,_)){delete this.operations[d];break}}}_nextOp(_,d){return!!_.queued&&(_.from=_.to,_.to=_.queued,_.queued=null,_.phase=0,_.startTime=d,!0)}_validOp(_){return _.from.hasData()&&_.to.hasData()}},ob={0:null,1:"TERRAIN_VERTEX_MORPHING"};function w0(_,d,g){if(d===0)return 0;const w=d<1&&g===514?.25/d:1;return 6*Math.pow(1.5,22-_)*Math.max(d,1)*w}function lb(_,d){const g=1<<_.z;return!d&&(_.x===0||_.x===g-1)||_.y===0||_.y===g-1}function S0(_,d){if(!_.style||!_.style.enable3dLights())return;const g=_.context,w=g.gl;g.activeTexture.set(w.TEXTURE1),d?d.bind(w.LINEAR,w.CLAMP_TO_EDGE):_.emptyTexture.bind(w.LINEAR,w.CLAMP_TO_EDGE)}const T0=_=>({u_matrix:_});function E0(_,d,g,w,j){if(j>0){const I=a.o.now(),L=(I-_.timeAdded)/j,F=d?(I-d.timeAdded)/j:-1,z=g.getSource(),H=w.coveringZoomLevel({tileSize:z.tileSize,roundZoom:z.roundZoom}),Z=!d||Math.abs(d.tileID.overscaledZ-H)>Math.abs(_.tileID.overscaledZ-H),ne=Z&&_.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 cb extends fu{constructor(d){const g={type:"raster-dem",maxzoom:Math.ceil(d.transform.maxZoom)},w=z_("mock-dem",g,d.style.dispatcher,d.style);super("mock-dem",w,null),w.setEventedParent(this),this._sourceLoaded=!0}_loadTile(d,g){d.state="loaded",g(null)}}class wE extends fu{constructor(d){const g=z_("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,w){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((I,L)=>{if(I[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 I},{});for(const I in this._tiles)I in j||(this.freeFBO(I),this._tiles[I].unloadVectorData(),delete this._tiles[I])}freeFBO(d){const g=this.proxyCachedFBO[d];if(g!==void 0){const w=Object.values(g);this.renderCachePool.push(...w),delete this.proxyCachedFBO[d]}}deallocRenderCache(){this.renderCache.forEach(d=>d.fb.destroy()),this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}}class ub extends a.aR{constructor(d,g,w){super(d.overscaledZ,d.wrap,d.canonical.z,d.canonical.x,d.canonical.y),this.proxyTileKey=g,this.projMatrix=w}}class j0 extends a.bu{constructor(d,g){super(),this._debugParams={sortTilesHiZFirst:!0,disableRenderCache:!1},this.painter=d,this.terrainTileForTile={},this.prevTerrainTileForTile={};const[w,j,I]=function(){const z=new a.dB,H=new a.dC,Z=131;z.reserve(17161),H.reserve(33800);const ne=a.an/128,re=a.an+ne/2,ie=re+ne;for(let oe=-ne;oere||oe<0||oe>re?24575:0,Pe=a.aC(Math.round(xe),0,a.an),Me=a.aC(Math.round(oe),0,a.an);z.emplaceBack(Pe+ye,Me)}const ce=(oe,xe)=>{const ye=xe*Z+oe;H.emplaceBack(ye+1,ye,ye+Z),H.emplaceBack(ye+Z,ye+Z+1,ye+1)};for(let oe=1;oe<129;oe++)for(let xe=1;xe<129;xe++)ce(xe,oe);return[0,129].forEach(oe=>{for(let xe=0;xe<130;xe++)ce(xe,oe),ce(oe,xe)}),[z,H,32768]}(),L=d.context;this.gridBuffer=L.createVertexBuffer(w,a.dx.members),this.gridIndexBuffer=L.createIndexBuffer(j),this.gridSegments=a.dy.simpleSegment(0,0,w.length,j.length),this.gridNoSkirtSegments=a.dy.simpleSegment(0,0,w.length,I),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new wE(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 Jr({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 cb(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,w){if(d&&d.terrain){this._style!==d&&(this.style=d,this._evaluationZoom=void 0);const j=d.terrain.properties,I=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"),H=I?this._mockSourceCache:d.getSourceCache(z,F);if(!H)return void a.w(`Couldn't find terrain source "${z}".`);if(this.sourceCache=H,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,w),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,w=d.getFreeCameraOptions().position.z/d.pixelsPerMeter*d.worldSize;this._previousCameraAltitude=w;const j=g!=null?w-g:Number.MAX_VALUE;if(Math.abs(j)<2)return this._exaggeration;const I=d.zoom,L=this._style.terrain;if(!this._previousUpdateTimestamp)return L.getExaggeration(I);let F=I-this._previousZoom;const z=this._previousUpdateTimestamp;let H=I;this._evaluationZoom!=null&&(H=this._evaluationZoom,Math.abs(I-H)>.5&&(F=.5*(I-H+F)),F*j<0&&(H+=F)),this._evaluationZoom=H;const Z=L.getExaggeration(H),ne=Z===L.getExaggeration(Math.max(0,H-.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,w=this.painter.transform;this._initializing&&(this._initializing=w._centerAltitude===0&&this.getAtPointOrZero(a.ag.fromLngLat(w.center),-1)===-1,this._emptyDEMTextureDirty=!this._initializing);const j=this.proxyCoords=g.getIds().map(z=>{const H=g.getTileByID(z).tileID;return H.projMatrix=w.calculateProjMatrix(H.toUnwrapped()),H});(function(z,H){const Z=H.transform.pointCoordinate(H.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 H=L[z];if(!H.used||(H!==this.sourceCache&&this.resetTileLookupCache(H.id),this._setupProxiedCoordsForOrtho(H,d[z],I),H.usedForTerrain))continue;const Z=d[z];(H.getSource().reparseOverscaled||H._isRasterElevatedOverTerrain)&&this._assignTerrainTiles(Z)}this.proxiedCoords[g.id]=j.map(z=>new ub(z,z.key,this.orthoMatrix)),this._assignTerrainTiles(j),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(I),this.renderingToTexture=!1;const F={};this._visibleDemTiles=[];for(const z of this.proxyCoords){const H=this.terrainTileForTile[z.key];if(!H)continue;const Z=H.tileID.key;Z in F||(this._visibleDemTiles.push(H),F[Z]=Z)}}_assignTerrainTiles(d){this._initializing||d.forEach(g=>{if(this.terrainTileForTile[g.key])return;const w=this._findTileCoveringTileID(g,this.sourceCache);w&&(this.terrainTileForTile[g.key]=w)})}_prepareDEMTextures(){const d=this.painter.context,g=d.gl;for(const w in this.terrainTileForTile){const j=this.terrainTileForTile[w],I=j.dem;!I||j.demTexture&&!j.needsDEMTextureUpload||(d.activeTexture.set(g.TEXTURE1),RC(this.painter,j,I))}}_prepareDemTileUniforms(d,g,w,j){if(!g||g.demTexture==null)return!1;const I=d.tileID.canonical,L=Math.pow(2,g.tileID.canonical.z-I.z),F=j||"";return w[`u_dem_tl${F}`]=[I.x*L%1,I.y*L%1],w[`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((w,j)=>{if(!j.dem)return w;const I=j.dem.tree.minimums[0];return I>0&&d++,w+I},0);return d?g/d:0}_updateEmptyDEMTexture(){const d=this.painter.context,g=d.gl;d.activeTexture.set(g.TEXTURE2);const w=this._getLoadedAreaMinimum(),j=new a.dz({width:1,height:1},new Float32Array([w]));this._emptyDEMTextureDirty=!1;let I=this._emptyDEMTexture;return I?I.update(j,{premultiply:!1}):I=this._emptyDEMTexture=new a.T(d,j,g.R32F,{premultiply:!1}),I}setupElevationDraw(d,g,w){const j=this.painter.context,I=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,H=1;if(w&&w.morphing&&this._useVertexMorphing){const ie=w.morphing.srcDemTile,ce=w.morphing.dstDemTile;H=w.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()?I.LINEAR:I.NEAREST;let ne=null;var re;if(this.enabled?z&&F?(ne=F.demTexture,j.activeTexture.set(I.TEXTURE4),z.demTexture.bind(Z(z),I.CLAMP_TO_EDGE),L.u_dem_lerp=H):(F=this.terrainTileForTile[d.tileID.key],ne=this._prepareDemTileUniforms(d,F,L)?F.demTexture:this.emptyDEMTexture):ne=this.emptyDEMTexture,j.activeTexture.set(I.TEXTURE2),ne&&(L.u_dem_size=(re=ne).size[0]===1?1:re.size[0]-2,ne.bind(Z(F),I.CLAMP_TO_EDGE)),this.painter.setupDepthForOcclusion(w&&w.useDepthForOcclusion,g,L),w&&w.useMeterToDem&&F){const ie=(1<{if(ye===ft)return;const Lt=[ob[ft],"PROJECTION_GLOBE_VIEW"];Me&&Lt.push("CUSTOM_ANTIALIASING");const Bt=H.isTileAffectedByFog(xt);xe=H.getOrCreateProgram("globeRaster",{defines:Lt,overrideFog:Bt}),ye=ft},Ze=H.colorModeForRenderPass(),$e=new Cr(oe.LEQUAL,Cr.ReadWrite,H.depthRangeFor3D);zo.update(ie);const Ke=a.dq(Pe),De=[a.aH(Pe.center.lng),a.aL(Pe.center.lat)],Be=H.globeSharedBuffers,Ge=[Pe.width*a.o.devicePixelRatio,Pe.height*a.o.devicePixelRatio],at=Float32Array.from(Pe.globeMatrix),Qe={useDenormalizedUpVectorScale:!0};{const xt=H.transform,ft=w0(xt.zoom,Z.exaggeration(),Z.sourceCache._source.tileSize);ye=-1;const Lt=oe.TRIANGLES;for(const Bt of re){const lt=ne.getTile(Bt),tt=Jr.disabled,gt=Z.prevTerrainTileForTile[Bt.key],_t=Z.terrainTileForTile[Bt.key];bE(gt,_t)&&zo.newMorphing(Bt.key,gt,_t,ie,250),S0(H,lt.emissiveTexture),ce.activeTexture.set(oe.TEXTURE0),lt.texture&<.texture.bind(oe.LINEAR,oe.CLAMP_TO_EDGE);const Tt=zo.getMorphValuesForProxy(Bt.key),rr=Tt?1:0;Tt&&Object.assign(Qe,{morphing:{srcDemTile:Tt.from,dstDemTile:Tt.to,phase:a.dn(Tt.phase)}});const Wt=a.dr(Bt.canonical),Kt=a.ds(Wt.getCenter().lat),Ot=a.dt(Bt.canonical,Wt,Kt,xt.worldSize/xt._pixelsPerMercatorPixel),Ar=a.du(a.dv(Bt.canonical)),Lr=H.emissiveMode==="mrt-fallback"?1:0,gr=Gg(xt.expandedFarZProjMatrix,at,Ke,Ar,a.al(xt.zoom),De,xt.frustumCorners.TL,xt.frustumCorners.TR,xt.frustumCorners.BR,xt.frustumCorners.BL,xt.globeCenterInViewSpace,xt.globeRadius,Ge,ft,xt._farZ,Lr,Ot);if(Se(Bt,rr),xe&&(Z.setupElevationDraw(lt,xe,Qe),H.uploadCommonUniforms(ce,xe,Bt.toUnwrapped()),Be)){const[Tr,Wr,an]=Be.getGridBuffers(Kt,ft!==0);xe.draw(H,Lt,$e,tt,Ze,Hr.backCCW,gr,"globe_raster",Tr,Wr,an)}}}if(Be&&(H.renderDefaultNorthPole||H.renderDefaultSouthPole)){const xt=["GLOBE_POLES","PROJECTION_GLOBE_VIEW"];Me&&xt.push("CUSTOM_ANTIALIASING"),xe=H.getOrCreateProgram("globeRaster",{defines:xt});for(const ft of re){const{x:Lt,y:Bt,z:lt}=ft.canonical,tt=Bt===0,gt=Bt===(1<Tr.draw(H,oe.TRIANGLES,$e,Jr.disabled,Ze,Hr.disabled,Gg(Pe.expandedFarZProjMatrix,Ot,Ot,Ar,0,De,Pe.frustumCorners.TL,Pe.frustumCorners.TR,Pe.frustumCorners.BR,Pe.frustumCorners.BL,Pe.globeCenterInViewSpace,Pe.globeRadius,Ge,0,Pe._farZ,Lr),"globe_pole_raster",Wr,rr,Wt);Z.setupElevationDraw(Kt,xe,Qe),H.uploadCommonUniforms(ce,xe,ft.toUnwrapped()),tt&&H.renderDefaultNorthPole&&gr(xe,_t),gt&&H.renderDefaultSouthPole&&(Ot=a.cC(a.bb(),Ot,[1,-1,1]),gr(xe,Tt))}}}})(j,I,L,F,z);else{const H=j.context,Z=H.gl;let ne,re;const ie=j.shadowRenderer,ce=Ba(j,j.longestCutoffRange),oe=Ze=>{if(re===Ze)return;const $e=[];$e.push(ob[Ze]),ce.shouldRenderCutoff&&$e.push("RENDER_CUTOFF"),ie&&($e.push("RENDER_SHADOWS"),ie.useNormalOffset&&$e.push("NORMAL_OFFSET")),ne=j.getOrCreateProgram("terrainRaster",{defines:$e}),re=Ze},xe=j.colorModeForRenderPass(),ye=new Cr(Z.LEQUAL,Cr.ReadWrite,j.depthRangeFor3D);zo.update(z);const Pe=j.transform,Me=w0(Pe.zoom,I.exaggeration(),I.sourceCache._source.tileSize);let Se=[0,0,0];if(ie){const Ze=j.style.directionalLight,$e=j.style.ambientLight;Ze&&$e&&(Se=Wu(j.style,Ze,$e))}{re=-1;const Ze=Z.TRIANGLES,[$e,Ke]=[I.gridIndexBuffer,I.gridSegments];for(const De of F){const Be=L.getTile(De),Ge=Jr.disabled,at=I.prevTerrainTileForTile[De.key],Qe=I.terrainTileForTile[De.key];bE(at,Qe)&&zo.newMorphing(De.key,at,Qe,z,250),S0(j,Be.emissiveTexture),H.activeTexture.set(Z.TEXTURE0),Be.texture&&Be.texture.bind(Z.LINEAR,Z.CLAMP_TO_EDGE);const xt=zo.getMorphValuesForProxy(De.key),ft=xt?1:0;let Lt;xt&&(Lt={morphing:{srcDemTile:xt.from,dstDemTile:xt.to,phase:a.dn(xt.phase)}});const Bt=j.emissiveMode==="mrt-fallback"?1:0,lt=b0(De.projMatrix,lb(De.canonical,Pe.renderWorldCopies)?Me/10:Me,Se,Bt);if(oe(ft),!ne)continue;I.setupElevationDraw(Be,ne,Lt);const tt=De.toUnwrapped();ie&&ie.setupShadows(tt,ne),j.uploadCommonUniforms(H,ne,tt,null,ce),ne.draw(j,Ze,ye,Ge,xe,Hr.backCCW,lt,"terrain_raster",I.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,w=this.painter.context,j=this.proxySourceCache,I=this.proxiedCoords[j.id],L=this._drapedRenderBatches.shift(),F=g.style.order,z=[];this._updateFBOs(g.emissiveMode==="mrt-fallback");let H=0;for(const Z of I){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[H++],ce=re!==void 0;if(ne.texture=ie.tex,ne.emissiveTexture=ie.emissiveTex,ce&&!ie.dirty){z.push(ne.tileID);continue}w.bindFramebuffer.set(ie.fb.framebuffer);const oe=w.gl;let xe;oe.drawBuffers(g.emissiveMode==="mrt-fallback"?[oe.COLOR_ATTACHMENT0,oe.COLOR_ATTACHMENT1]:[oe.COLOR_ATTACHMENT0]),this.renderedToTile=!1,ie.dirty&&(w.clear({color:a.aq.transparent,stencil:0}),ie.dirty=!1);for(let ye=L.start;ye<=L.end;++ye){const Pe=g.style._mergedLayers[F[ye]];if(Pe.isHidden(g.transform.zoom))continue;const Me=g.style.getLayerSourceCache(Pe),Se=Me?this.proxyToSource[Z.key][Me.id]:[Z];if(!Se)continue;const Ze=Se;w.viewport.set([0,0,ie.fb.width,ie.fb.height]),xe!==(Me?Me.id:null)&&(this._setupStencil(ie,Se,Pe,Me),xe=Me?Me.id:null),g.renderLayer(g,Me,Pe,Ze)}if(oe.drawBuffers([oe.COLOR_ATTACHMENT0]),this._drapedRenderBatches.length===0)for(const ye of this._pendingGroundEffectLayers){const Pe=g.style._mergedLayers[F[ye]];if(Pe.isHidden(g.transform.zoom))continue;const Me=g.style.getLayerSourceCache(Pe),Se=Me?this.proxyToSource[Z.key][Me.id]:[Z];if(!Se)continue;const Ze=Se;w.viewport.set([0,0,ie.fb.width,ie.fb.height]),xe!==(Me?Me.id:null)&&(this._setupStencil(ie,Se,Pe,Me),xe=Me?Me.id:null),g.renderLayer(g,Me,Pe,Ze)}this.renderedToTile?(ie.dirty=!0,z.push(ne.tileID)):ce||--H,H===5&&(H=0,this.renderToBackBuffer(z))}return this.renderToBackBuffer(z),this.renderingToTexture=!1,w.bindFramebuffer.set(null),w.viewport.set([0,0,g.width,g.height]),L.end+1}postRender(){}isLayerOrderingCorrect(d){const g=d.order.length;let w=-1,j=g;for(let I=0;Iw}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,w){if(!this._visibleDemTiles)return null;const j=this._visibleDemTiles.filter(I=>I.dem).map(I=>{const L=I.tileID,F=1<(I.t!==null?I.t:Number.MAX_VALUE)-(L.t!==null?L.t:Number.MAX_VALUE));for(const I of j){if(I.t==null)return null;const L=I.tile.dem.tree.raycast(I.minx,I.miny,I.maxx,I.maxy,d,g,w);if(L!=null)return L}return null}_createFBO(){const d=this.painter.context,g=d.gl,w=this.drapeBufferSize;d.activeTexture.set(g.TEXTURE0);const j=new a.T(d,{width:w[0],height:w[1],data:null},g.RGBA8);j.bind(g.LINEAR,g.CLAMP_TO_EDGE);const I=d.createFramebuffer(w[0],w[1],1,null);let L;return I.colorAttachment0.set(j.texture),this._emissiveTexture&&(L=new a.T(d,{width:w[0],height:w[1],data:null},g.R8),L.bind(g.LINEAR,g.CLAMP_TO_EDGE),I.createColorAttachment(d,1),I.colorAttachment1.set(L.texture)),I.depthAttachment=new K4(d,I.framebuffer),this._sharedDepthStencil===void 0?(this._sharedDepthStencil=d.createRenderbuffer(d.gl.DEPTH_STENCIL,w[0],w[1]),this._stencilRef=0,I.depthAttachment.set(this._sharedDepthStencil),d.clear({stencil:0})):I.depthAttachment.set(this._sharedDepthStencil),d.extTextureFilterAnisotropic&&g.texParameterf(g.TEXTURE_2D,d.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,d.extTextureFilterAnisotropicMax),{fb:I,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 w=d.fb,j=this.painter.context,I=j.gl,L=this.drapeBufferSize;if(g){const F=new a.T(j,{width:L[0],height:L[1],data:null},I.R8);F.bind(I.LINEAR,I.CLAMP_TO_EDGE),d.emissiveTex=F,w.createColorAttachment(j,1),w.colorAttachment1.set(F.texture)}else d.emissiveTex=void 0,w.removeColorAttachment(j,1);d.dirty=!0}_initFBOPool(){for(;this.pool.length{const g=this._style._mergedLayers[d],w=g.isHidden(this.painter.transform.zoom);return g.type==="hillshade"||g.type==="custom"?!w&&g.shouldRedrape():!w&&g.hasTransition()})}_clearLineLayersFromRenderCache(){let d=!1;for(const w of this._style.getSources())if(w instanceof Ul){d=!0;break}if(!d)return;const g={};for(let w=0;wz>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=w}_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=w[L];if(g.getTileByID(F.key),g.proxyCachedFBO[F.key]!==void 0){const z=d[F.key],H=this.proxyToSource[F.key];let Z=0;for(const ne in H){const re=H[ne],ie=z[ne];if(!ie||ie.length!==re.length||re.some((ce,oe)=>ce!==ie[oe]||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 I=[...this._drapedRenderBatches];I.sort((L,F)=>F.end-F.start-(L.end-L.start));for(const L of I)for(const F of w){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,w,j){if(!j||!this._sourceTilesOverlap[j.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));const I=this.painter.context,L=I.gl;if(g.length<=1)return void(this._overlapStencilType=!1);let F;if(w.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&&(I.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=F,this._overlapStencilMode.ref=this._stencilRef,w.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):Jr.disabled}_renderTileClippingMasks(d,g){const w=this.painter,j=this.painter.context,I=j.gl;w._tileClippingMaskIDs={},j.setColorMode(Yr.disabled),j.setDepthMode(Cr.disabled);const L=w.getOrCreateProgram("clippingMask");for(const F of d){const z=w._tileClippingMaskIDs[F.key]=--g;L.draw(w,I.TRIANGLES,Cr.disabled,new Jr({func:I.ALWAYS,mask:0},z,255,I.KEEP,I.KEEP,I.REPLACE),Yr.disabled,Hr.disabled,T0(F.projMatrix),"$clipping",w.tileExtentBuffer,w.quadTriangleIndexBuffer,w.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 w=[d.x,d.y,1,1];a.aE(w,w,g.pixelMatrixInverse),a.cu(w,w,1/w[3]),w[0]/=g.worldSize,w[1]/=g.worldSize;const j=g._camera.position,I=a.bU(1,g.center.lat),L=[j[0],j[1],j[2]/I,0],F=a.cV([],w.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]*=I,L):null}_setupProxiedCoordsForOrtho(d,g,w){if(d.getSource()instanceof a.aV)return this._setupProxiedCoordsForImageSource(d,g,w);this._findCoveringTileCache[d.id]=this._findCoveringTileCache[d.id]||{};const j=this.proxiedCoords[d.id]=[],I=this.proxyCoords;for(let z=0;zZ.overscaledZ-H.overscaledZ)}_setupProxiedCoordsForImageSource(d,g,w){if(!d.getSource().loaded())return;const j=this.proxiedCoords[d.id]=[],I=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<xe+H.max.x||ce+oeye+H.max.y};for(let ne=0;neL.key===g.tileID.key);if(I)return I}if(g.tileID.key!==d.key){const I=d.canonical.z-g.tileID.canonical.z;let L,F,z;j=a.bb();const H=g.tileID.wrap-d.wrap<0?(L=a.an>>I,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&&(H.push(L.key),w=g.getTile(L))}const Z=ne=>{H.forEach(re=>{j[re]=ne}),H.length=0};for(F-=1;F>=z&&(!w||!w.hasData());F--){w&&Z(w.tileID.key);const ne=L.calculateScaledKey(F);if(w=g.getTileByID(ne),w&&w.hasData())break;const re=j[ne];if(re===null)break;re===void 0?H.push(ne):w=g.getTileByID(re)}return Z(w?w.tileID.key:null),w&&w.hasData()?w:null}findDEMTileFor(d){return this.enabled?this._findTileCoveringTileID(d,this.sourceCache):null}prepareDrawTile(){this.renderedToTile=!0}_clearRenderCacheForTile(d,g){let w=this._tilesDirty[d];w||(w=this._tilesDirty[d]={}),w[g.key]=!0}}function SE(_,d,g){const w=function(F,z,H){const Z=a.bi(z,F),ne=a.bi(H,[.2126,.7152,.0722]),re=(ce,oe,xe)=>(1-xe)*ce+xe*oe,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}(_,[0,0,1],d),j=[0,0,0];a.bJ(j,g.slice(0,3),w);const I=[0,0,0];a.bJ(I,d.slice(0,3),_[2]);const L=[0,0,0];return a.cT(L,j,I),a.cW(L)}const VC=["fill","fillOutline","fillPattern","line","linePattern","background","backgroundPattern","hillshade","raster"],qC=["stars","rainParticle","snowParticle","fillExtrusion","fillExtrusionGroundEffect","building","buildingBloom","elevatedStructures","model","symbol"];class np{static cacheKey(d,g,w,j){const I=[g];j&&I.push(j.cacheKey);for(const L of w)(typeof L=="string"&&L.includes(" ")||d.usedDefines.has(L))&&I.push(L);return I.join("/")}constructor(d,g,w,j,I,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(oe=>`#define ${oe}`)).join(` `)}`,H=[z,$g];for(const oe of w.fragmentIncludes)H.push(Ku[oe]);H.push(w.fragmentSource);const Z=H.join(` `),ne=[z,$4];for(const oe of w.vertexIncludes)ne.push(Ku[oe]);this.forceManualRenderingForInstanceIDShaders=d.forceManualRenderingForInstanceIDShaders&&w.vertexSource.includes("gl_InstanceID"),this.forceManualRenderingForInstanceIDShaders&&ne.push("uniform int u_instanceID;"),ne.push(w.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=I(d),this.fixedUniformsEntries=Object.entries(this.fixedUniforms),this.binderUniforms=j?j.getUniforms(d):[],this.forceManualRenderingForInstanceIDShaders&&(this.instancingUniforms=(oe=>({u_instanceID:new a.bX(oe)}))(d)),(L.includes("TERRAIN")||L.includes("ELEVATED")||g.includes("symbol")||g.includes("circle"))&&(this.terrainUniforms=(oe=>({u_dem:new a.bX(oe),u_dem_prev:new a.bX(oe),u_dem_tl:new a.b_(oe),u_dem_scale:new a.bZ(oe),u_dem_tl_prev:new a.b_(oe),u_dem_scale_prev:new a.bZ(oe),u_dem_size:new a.bZ(oe),u_dem_lerp:new a.bZ(oe),u_exaggeration:new a.bZ(oe),u_depth:new a.bX(oe),u_depth_size_inv:new a.b_(oe),u_depth_range_unpack:new a.b_(oe),u_occluder_half_size:new a.bZ(oe),u_occlusion_depth_offset:new a.bZ(oe),u_meter_to_dem:new a.bZ(oe),u_label_plane_matrix_inv:new a.b$(oe)}))(d)),L.includes("GLOBE")&&(this.globeUniforms=(oe=>({u_tile_tl_up:new a.bY(oe),u_tile_tr_up:new a.bY(oe),u_tile_br_up:new a.bY(oe),u_tile_bl_up:new a.bY(oe),u_tile_up_scale:new a.bZ(oe)}))(d)),L.includes("FOG")&&(this.fogUniforms=(oe=>({u_fog_matrix:new a.b$(oe),u_fog_range:new a.b_(oe),u_fog_color:new a.cO(oe),u_fog_horizon_blend:new a.bZ(oe),u_fog_vertical_limit:new a.b_(oe),u_fog_temporal_offset:new a.bZ(oe),u_frustum_tl:new a.bY(oe),u_frustum_tr:new a.bY(oe),u_frustum_br:new a.bY(oe),u_frustum_bl:new a.bY(oe),u_globe_pos:new a.bY(oe),u_globe_radius:new a.bZ(oe),u_globe_transition:new a.bZ(oe),u_is_globe:new a.bX(oe),u_viewport:new a.b_(oe)}))(d)),L.includes("RENDER_CUTOFF")&&(this.cutoffUniforms=(oe=>({u_cutoff_params:new a.cO(oe)}))(d)),L.includes("LIGHTING_3D_MODE")&&(this.lightsUniforms=(oe=>({u_lighting_ambient_color:new a.bY(oe),u_lighting_directional_dir:new a.bY(oe),u_lighting_directional_color:new a.bY(oe),u_ground_radiance:new a.bY(oe)}))(d)),L.includes("RENDER_SHADOWS")&&(this.shadowUniforms=(oe=>({u_light_matrix_0:new a.b$(oe),u_light_matrix_1:new a.b$(oe),u_fade_range:new a.b_(oe),u_shadow_normal_offset:new a.bY(oe),u_shadow_intensity:new a.bZ(oe),u_shadow_texel_size:new a.bZ(oe),u_shadow_map_resolution:new a.bZ(oe),u_shadow_direction:new a.bY(oe),u_shadow_bias:new a.bY(oe),u_shadowmap_0:new a.bX(oe),u_shadowmap_1:new a.bX(oe)}))(d)))}getAttributeLocation(d,g){let w=this.attributes[g];return w===void 0&&(w=this.attributes[g]=d.getAttribLocation(this.program,g)),w}setTerrainUniformValues(d,g){if(!this.terrainUniforms)return;const w=this.terrainUniforms;if(!this.failedToCreate){d.program.set(this.program);for(const j in g)w[j]&&w[j].set(this.program,j,g[j])}}setGlobeUniformValues(d,g){if(!this.globeUniforms)return;const w=this.globeUniforms;if(!this.failedToCreate){d.program.set(this.program);for(const j in g)w[j]&&w[j].set(this.program,j,g[j])}}setFogUniformValues(d,g){if(!this.fogUniforms)return;const w=this.fogUniforms;if(!this.failedToCreate){d.program.set(this.program);for(const j in g)w[j].set(this.program,j,g[j])}}setCutoffUniformValues(d,g){if(!this.cutoffUniforms)return;const w=this.cutoffUniforms;if(!this.failedToCreate){d.program.set(this.program);for(const j in g)w[j].set(this.program,j,g[j])}}setLightsUniformValues(d,g){if(!this.lightsUniforms)return;const w=this.lightsUniforms;if(!this.failedToCreate){d.program.set(this.program);for(const j in g)w[j].set(this.program,j,g[j])}}setShadowUniformValues(d,g){if(this.failedToCreate||!this.shadowUniforms)return;const w=this.shadowUniforms;d.program.set(this.program);for(const j in g)w[j].set(this.program,j,g[j])}_drawDebugWireframe(d,g,w,j,I,L,F,z,H,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||!VC.includes(this.name))||!(!ne.layers3D||!qC.includes(this.name))))return;const ie=re.gl,ce=d.wireframeDebugCache.getLinesFromTrianglesBuffer(d.frameCounter,I,re);if(!ce)return;const oe=[...this.fixedDefines,"DEBUG_WIREFRAME"],xe=d.getOrCreateProgram(this.name,{config:this.configuration,defines:oe});re.program.set(xe.program);const ye=(Se,Ze,$e)=>{if(Ze[Se]&&$e[Se])for(const Ke in Ze[Se])$e[Se][Ke]&&$e[Se][Ke].set($e.program,Ke,Ze[Se][Ke].current)};H&&H.setUniforms(xe.program,re,xe.binderUniforms,F,{zoom:z}),ye("fixedUniforms",this,xe),ye("terrainUniforms",this,xe),ye("globeUniforms",this,xe),ye("fogUniforms",this,xe),ye("lightsUniforms",this,xe),ye("shadowUniforms",this,xe),ce.bind(),re.setColorMode(new Yr([ie.ONE,ie.ONE_MINUS_SRC_ALPHA,ie.ZERO,ie.ONE],a.aq.transparent,[!0,!0,!0,!1])),re.setDepthMode(new Cr(g.func===ie.LESS?ie.LEQUAL:g.func,Cr.ReadOnly,g.range)),re.setStencilMode(Jr.disabled);const Pe=3*L.primitiveLength*2,Me=3*L.primitiveOffset*2*2;if(this.forceManualRenderingForInstanceIDShaders){const Se=Z||1;for(let Ze=0;Ze1?ie.drawElementsInstanced(ie.LINES,Pe,ie.UNSIGNED_SHORT,Me,Z):ie.drawElements(ie.LINES,Pe,ie.UNSIGNED_SHORT,Me);I.bind(),re.program.set(this.program),re.setDepthMode(g),re.setStencilMode(w),re.setColorMode(j)}checkUniforms(d,g,w){if(this.fixedDefines.includes(g)){for(const j of Object.keys(w))if(!w[j].initialized)throw new Error(`Program '${this.name}', from draw '${d}': uniform ${j} not set but required by ${g} being defined`)}}draw(d,g,w,j,I,L,F,z,H,Z,ne,re,ie,ce,oe,xe){const ye=d.context,Pe=ye.gl;if(this.failedToCreate)return;ye.program.set(this.program),ye.setDepthMode(w),ye.setStencilMode(j),ye.setColorMode(I),ye.setCullFace(L);for(const[De,Be]of this.fixedUniformsEntries)Be.set(this.program,De,F[De]);ce&&ce.setUniforms(this.program,ye,this.binderUniforms,re,{zoom:ie});const Me={[Pe.POINTS]:1,[Pe.LINES]:2,[Pe.TRIANGLES]:3,[Pe.LINE_STRIP]:1}[g];this.checkUniforms(z,"RENDER_SHADOWS",this.shadowUniforms);const Se=oe||[],Ze=ce?ce.getPaintVertexBuffers():[],$e=g===Pe.TRIANGLES&&Z,Ke=xe&&xe>0?1:void 0;for(const De of ne.get()){const Be=De.vaos||(De.vaos={});if((Be[z]||(Be[z]=new PC)).bind(ye,this,H,Ze,Z,De.vertexOffset,Se,Ke),this.forceManualRenderingForInstanceIDShaders){const Ge=xe||1;for(let at=0;at1?Pe.drawElementsInstanced(g,De.primitiveLength*Me,Pe.UNSIGNED_SHORT,De.primitiveOffset*Me*2,xe):Z?Pe.drawElements(g,De.primitiveLength*Me,Pe.UNSIGNED_SHORT,De.primitiveOffset*Me*2):Pe.drawArrays(g,De.vertexOffset,De.vertexLength);$e&&this._drawDebugWireframe(d,w,j,I,Z,De,re,ie,ce,xe)}}}function GC(_,d,g=0){const w=Math.pow(2,d.tileID.overscaledZ),j=d.tileSize*Math.pow(2,_.transform.tileZoom)/w,I=j*(d.tileID.canonical.x+d.tileID.wrap*w),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,_.transform.tileZoom),u_pixel_coord_upper:[I>>16,L>>16],u_pixel_coord_lower:[65535&I,65535&L],u_pattern_transition:g}}const db={terrain:0,flat:1},Y4=a.bb(),HC=(_,d,g,w,j,I,L,F,z,H,Z,ne,re,ie,ce,oe,xe,ye,Pe=[0,0,1])=>{const Me=d.style.light,Se=Me.properties.get("position"),Ze=[Se.x,Se.y,Se.z],$e=a.dE();Me.properties.get("anchor")==="viewport"&&(a.dF($e,-d.transform.angle),a.dG(Ze,Ze,$e));const Ke=Me.properties.get("color").toPremultipliedRenderColor(null),De=d.transform,Be={u_matrix:_,u_lightpos:Ze,u_lightintensity:Me.properties.get("intensity"),u_lightcolor:[Ke.r,Ke.g,Ke.b],u_vertical_gradient:+g,u_opacity:w,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:Y4,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0,u_height_type:db[H],u_base_type:db[Z],u_ao:j,u_edge_radius:I,u_width_scale:L,u_flood_light_color:ce,u_vertical_scale:oe,u_flood_light_intensity:xe,u_ground_shadow_factor:ye,u_front_cutoff_params:Pe};return De.projection.name==="globe"&&(Be.u_tile_id=[F.canonical.x,F.canonical.y,1<({u_matrix:_,u_edge_radius:d,u_width_scale:g,u_vertical_scale:w,u_height_type:db[j],u_base_type:db[I]}),X4=(_,d,g,w,j,I,L,F,z,H,Z,ne,re,ie,ce,oe,xe,ye)=>{const Pe=HC(_,d,g,w,j,I,L,F,H,Z,ne,re,ie,ce,oe,xe,1,[0,0,0]),Me={u_height_factor:-Math.pow(2,F.overscaledZ)/z.tileSize/8};return Object.assign(Pe,GC(d,z,ye),Me)},hb=(_,d,g)=>({u_matrix:_,u_emissive_strength:d,u_ground_shadow_factor:g}),fb=(_,d,g,w,j,I=0)=>Object.assign(hb(_,d,j),GC(g,w,I)),WC=(_,d,g,w)=>({u_matrix:_,u_world:g,u_emissive_strength:d,u_ground_shadow_factor:w}),Hg=(_,d,g,w,j,I,L=0)=>Object.assign(fb(_,d,g,w,I,L),{u_world:j}),KC=(_,d)=>({u_matrix:_,u_depth_bias:d}),YC=(_,d)=>({u_matrix:_,u_ground_shadow_factor:d}),A0=(_,d,g,w,j)=>({u_matrix:_,u_camera_pos:[d[0],d[1],d[2]],u_depth_bias:g,u_height_scale:w,u_reset_depth:j}),mb=(_,d,g)=>({u_image:_,u_opacity:d,u_blend_mode:g}),Lf=(_,d,g,w,j,I,L,F,z,H=[0,0,1])=>({u_matrix:_,u_normal_matrix:d,u_opacity:g,u_faux_facade_ao_intensity:w,u_camera_pos:j,u_tile_to_meter:I,u_facade_emissive_chance:L,u_flood_light_color:F,u_flood_light_intensity:z,u_front_cutoff_params:H}),pb=_=>({u_matrix:_}),gb=_=>({u_matrix:_}),ZC=(_,d,g,w,j,I,L,F)=>{const z=a.an/I.tileSize;return{u_matrix:_,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:w,u_tile_id:L,u_merc_center:j}},Mf=(_,d,g,w)=>({u_matrix:_,u_inv_matrix:d,u_camera_to_center_distance:g.getCameraToCenterDistance(w),u_viewport_size:[g.width,g.height]}),k0=(_,d,g=1)=>({u_matrix:_,u_color:d,u_overlay:0,u_overlay_scale:g}),yb=a.bb(),XC=(_,d,g,w,j,I,L)=>{const F=_.transform,z=F.projection.name==="globe",H=z?a.dH(F.zoom,d.canonical)*F._pixelsPerMercatorPixel:a.aA(g,1,I),Z={u_matrix:d.projMatrix,u_extrude_scale:H,u_intensity:L,u_inv_rot_matrix:yb,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=w,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:w,u_merc_matrix:j,u_grid_matrix:I,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:JC(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:H,u_colorization_mix:TE(a.dK,xe,Pe),u_colorization_offset:xb(a.dK,ye,Pe),u_color_ramp:oe,u_texture_offset:[Se/(Me+2*Se),Me/(Me+2*Se)],u_texture_res:[Me+2*Se,Me+2*Se],u_emissive_strength:Ze,u_zbias_factor:EE(_)});function JC(_){_*=Math.PI/180;const d=Math.sin(_),g=Math.cos(_);return[(2*g+1)/3,(-Math.sqrt(3)*d-g+1)/3,(Math.sqrt(3)*d-g+1)/3]}const Ld=.05,Q4=(_,d,g,w,j,I,L,F,z,H,Z,ne)=>({u_matrix:_,u_normalize_matrix:d,u_globe_matrix:g,u_merc_matrix:w,u_grid_matrix:j,u_tl_parent:I,u_scale_parent:H,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}),J4=(_,d,g,w,j,I,L,F,z,H)=>({u_particle_texture:_,u_particle_texture_side_len:d,u_tile_offset:g,u_velocity:w,u_color_ramp:I,u_velocity_res:j,u_max_speed:L,u_uv_offset:F,u_data_scale:[255*z[0],255*z[1]],u_data_offset:H,u_particle_pos_scale:1.1,u_particle_pos_offset:[Ld,Ld]}),eI=(_,d,g,w,j,I,L,F,z,H)=>({u_particle_texture:_,u_particle_texture_side_len:d,u_velocity:g,u_velocity_res:w,u_max_speed:j,u_speed_factor:I,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:H,u_particle_pos_scale:1.1,u_particle_pos_offset:[Ld,Ld]}),tI=a.bb(),vb=(_,d,g,w,j,I,L,F,z,H,Z,ne,re,ie,ce,oe,xe,ye,Pe,Me,Se,Ze,$e,Ke)=>{const De=j.transform,Be={u_is_size_zoom_constant:+(_==="constant"||_==="source"),u_is_size_feature_constant:+(_==="constant"||_==="camera"),u_size_t:d?d.uSizeT:0,u_size:d?d.uSize:0,u_camera_to_center_distance:De.getCameraToCenterDistance(Pe),u_rotate_symbol:+g,u_aspect_ratio:De.width/De.height,u_fade_change:j.options.fadeDuration?j.symbolFadeChange:1,u_matrix:I,u_label_plane_matrix:L,u_coord_matrix:F,u_is_text:+H,u_elevation_from_sea:z?1:0,u_pitch_with_map:+w,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:tI,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:tI,u_up_vector:[0,-1,0],u_color_adj_mat:Ze,u_icon_transition:$e||0,u_gamma_scale:w?j.transform.getCameraToCenterDistance(Pe)*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:Se,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 Pe.name==="globe"&&(Be.u_tile_id=[ie.canonical.x,ie.canonical.y,1<({u_matrix:_,u_emissive_strength:d,u_opacity:g,u_color:w}),Df=(_,d,g,w,j,I,L,F,z)=>Object.assign(function(H,Z,ne,re,ie,ce){const{width:oe,height:xe}=re.imageManager.getPixelSize(Z),ye=Math.pow(2,ce.tileID.overscaledZ),Pe=ce.tileSize*Math.pow(2,re.transform.tileZoom)/ye,Me=Pe*(ce.tileID.canonical.x+ce.tileID.wrap*ye),Se=Pe*ce.tileID.canonical.y;return{u_image:0,u_pattern_tl:ne.tl,u_pattern_br:ne.br,u_texsize:[oe,xe],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,Se>>16],u_pixel_coord_lower:[65535&Me,65535&Se]}}(0,I,L,w,F,z),{u_matrix:_,u_emissive_strength:d,u_opacity:g}),Wg=new Float32Array(a.b9([])),sp=(_,d,g,w,j,I,L,F,z,H,Z,ne,re,ie=[0,0,0],ce,oe,xe)=>{const ye=j.style.light,Pe=ye.properties.get("position"),Me=[-Pe.x,-Pe.y,Pe.z],Se=a.dE();ye.properties.get("anchor")==="viewport"&&(a.dF(Se,-j.transform.angle),a.dG(Me,Me,Se));const Ze=Z.alphaMode==="MASK",$e=ye.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),xe&&(De.r=xe[0],De.g=xe[1],De.b=xe[2],De.a=xe[3]),oe&&(De.r=oe.color.r,De.g=oe.color.g,De.b=oe.color.b,De.a=oe.colorMix,ne=oe.emissionStrength,I*=oe.opacity),{u_matrix:_,u_lighting_matrix:d,u_normal_matrix:g,u_node_matrix:w||Wg,u_lightpos:Me,u_lightintensity:ye.properties.get("intensity"),u_lightcolor:[$e.r,$e.g,$e.b],u_camera_pos:ie,u_opacity:I,u_baseTextureIsAlpha:0,u_alphaMask:+Ze,u_alphaCutoff:Z.alphaCutoff,u_baseColorFactor:L.toNonPremultipliedRenderColor(null).toArray01(),u_emissiveFactor:F.toNonPremultipliedRenderColor(null).toArray01(),u_metallicFactor:z,u_roughnessFactor:H,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]}},jE=(_,d=Wg,g=Wg)=>({u_matrix:_,u_instance:d,u_node_matrix:g}),_b={fillExtrusion:_=>({u_matrix:new a.b$(_),u_lightpos:new a.bY(_),u_lightintensity:new a.bZ(_),u_lightcolor:new a.bY(_),u_vertical_gradient:new a.bZ(_),u_opacity:new a.bZ(_),u_edge_radius:new a.bZ(_),u_width_scale:new a.bZ(_),u_ao:new a.b_(_),u_height_type:new a.bX(_),u_base_type:new a.bX(_),u_tile_id:new a.bY(_),u_zoom_transition:new a.bZ(_),u_inv_rot_matrix:new a.b$(_),u_merc_center:new a.b_(_),u_up_dir:new a.bY(_),u_height_lift:new a.bZ(_),u_flood_light_color:new a.bY(_),u_vertical_scale:new a.bZ(_),u_flood_light_intensity:new a.bZ(_),u_ground_shadow_factor:new a.bY(_),u_front_cutoff_params:new a.bY(_)}),fillExtrusionDepth:_=>({u_matrix:new a.b$(_),u_edge_radius:new a.bZ(_),u_width_scale:new a.bZ(_),u_vertical_scale:new a.bZ(_),u_height_type:new a.bX(_),u_base_type:new a.bX(_)}),fillExtrusionPattern:_=>({u_matrix:new a.b$(_),u_lightpos:new a.bY(_),u_lightintensity:new a.bZ(_),u_lightcolor:new a.bY(_),u_vertical_gradient:new a.bZ(_),u_height_factor:new a.bZ(_),u_edge_radius:new a.bZ(_),u_width_scale:new a.bZ(_),u_ao:new a.b_(_),u_height_type:new a.bX(_),u_base_type:new a.bX(_),u_tile_id:new a.bY(_),u_zoom_transition:new a.bZ(_),u_inv_rot_matrix:new a.b$(_),u_merc_center:new a.b_(_),u_up_dir:new a.bY(_),u_height_lift:new a.bZ(_),u_image:new a.bX(_),u_texsize:new a.b_(_),u_pixel_coord_upper:new a.b_(_),u_pixel_coord_lower:new a.b_(_),u_tile_units_to_pixels:new a.bZ(_),u_opacity:new a.bZ(_),u_pattern_transition:new a.bZ(_)}),fillExtrusionGroundEffect:_=>({u_matrix:new a.b$(_),u_opacity:new a.bZ(_),u_ao_pass:new a.bZ(_),u_meter_to_tile:new a.bZ(_),u_ao:new a.b_(_),u_flood_light_intensity:new a.bZ(_),u_flood_light_color:new a.bY(_),u_attenuation:new a.bZ(_),u_edge_radius:new a.bZ(_),u_fb:new a.bX(_),u_fb_size:new a.bZ(_),u_dynamic_offset:new a.bZ(_)}),fill:_=>({u_matrix:new a.b$(_),u_emissive_strength:new a.bZ(_),u_ground_shadow_factor:new a.bY(_)}),fillPattern:_=>({u_matrix:new a.b$(_),u_emissive_strength:new a.bZ(_),u_image:new a.bX(_),u_texsize:new a.b_(_),u_pixel_coord_upper:new a.b_(_),u_pixel_coord_lower:new a.b_(_),u_tile_units_to_pixels:new a.bZ(_),u_ground_shadow_factor:new a.bY(_),u_pattern_transition:new a.bZ(_)}),fillOutline:_=>({u_matrix:new a.b$(_),u_emissive_strength:new a.bZ(_),u_world:new a.b_(_),u_ground_shadow_factor:new a.bY(_)}),fillOutlinePattern:_=>({u_matrix:new a.b$(_),u_emissive_strength:new a.bZ(_),u_world:new a.b_(_),u_image:new a.bX(_),u_texsize:new a.b_(_),u_pixel_coord_upper:new a.b_(_),u_pixel_coord_lower:new a.b_(_),u_tile_units_to_pixels:new a.bZ(_),u_ground_shadow_factor:new a.bY(_),u_pattern_transition:new a.bZ(_)}),lineBlendComposite:_=>({u_image:new a.bX(_),u_opacity:new a.bZ(_),u_blend_mode:new a.bX(_)}),building:_=>({u_matrix:new a.b$(_),u_normal_matrix:new a.b$(_),u_opacity:new a.bZ(_),u_faux_facade_ao_intensity:new a.bZ(_),u_camera_pos:new a.bY(_),u_tile_to_meter:new a.bZ(_),u_facade_emissive_chance:new a.bZ(_),u_flood_light_color:new a.bY(_),u_flood_light_intensity:new a.bZ(_),u_front_cutoff_params:new a.bY(_)}),buildingBloom:_=>({u_matrix:new a.b$(_)}),buildingDepth:_=>({u_matrix:new a.b$(_)}),elevatedStructuresDepth:_=>({u_matrix:new a.b$(_),u_depth_bias:new a.bZ(_)}),elevatedStructures:_=>({u_matrix:new a.b$(_),u_ground_shadow_factor:new a.bY(_)}),elevatedStructuresDepthReconstruct:_=>({u_matrix:new a.b$(_),u_camera_pos:new a.bY(_),u_depth_bias:new a.bZ(_),u_height_scale:new a.bZ(_),u_reset_depth:new a.bZ(_)}),circle:a.dO,collisionBox:_=>({u_matrix:new a.b$(_),u_inv_rot_matrix:new a.b$(_),u_camera_to_center_distance:new a.bZ(_),u_extrude_scale:new a.b_(_),u_zoom_transition:new a.bZ(_),u_merc_center:new a.b_(_),u_tile_id:new a.bY(_)}),collisionCircle:_=>({u_matrix:new a.b$(_),u_inv_matrix:new a.b$(_),u_camera_to_center_distance:new a.bZ(_),u_viewport_size:new a.b_(_)}),debug:_=>({u_color:new a.dl(_),u_matrix:new a.b$(_),u_overlay:new a.bX(_),u_overlay_scale:new a.bZ(_)}),clippingMask:_=>({u_matrix:new a.b$(_)}),heatmap:_=>({u_extrude_scale:new a.bZ(_),u_intensity:new a.bZ(_),u_matrix:new a.b$(_),u_inv_rot_matrix:new a.b$(_),u_merc_center:new a.b_(_),u_tile_id:new a.bY(_),u_zoom_transition:new a.bZ(_),u_up_dir:new a.bY(_)}),heatmapTexture:_=>({u_image:new a.bX(_),u_color_ramp:new a.bX(_),u_opacity:new a.bZ(_)}),hillshade:_=>({u_matrix:new a.b$(_),u_image:new a.bX(_),u_latrange:new a.b_(_),u_light:new a.b_(_),u_shadow:new a.dl(_),u_highlight:new a.dl(_),u_emissive_strength:new a.bZ(_),u_accent:new a.dl(_)}),hillshadePrepare:_=>({u_matrix:new a.b$(_),u_image:new a.bX(_),u_dimension:new a.b_(_),u_zoom:new a.bZ(_)}),line:a.dN,linePattern:a.dM,raster:_=>({u_matrix:new a.b$(_),u_normalize_matrix:new a.b$(_),u_globe_matrix:new a.b$(_),u_merc_matrix:new a.b$(_),u_grid_matrix:new a.dm(_),u_tl_parent:new a.b_(_),u_scale_parent:new a.bZ(_),u_fade_t:new a.bZ(_),u_opacity:new a.bZ(_),u_image0:new a.bX(_),u_image1:new a.bX(_),u_brightness_low:new a.bZ(_),u_brightness_high:new a.bZ(_),u_saturation_factor:new a.bZ(_),u_contrast_factor:new a.bZ(_),u_spin_weights:new a.bY(_),u_perspective_transform:new a.b_(_),u_raster_elevation:new a.bZ(_),u_zoom_transition:new a.bZ(_),u_merc_center:new a.b_(_),u_cutoff_params:new a.cO(_),u_colorization_mix:new a.cO(_),u_colorization_offset:new a.bZ(_),u_color_ramp:new a.bX(_),u_texture_offset:new a.b_(_),u_texture_res:new a.b_(_),u_emissive_strength:new a.bZ(_),u_zbias_factor:new a.bZ(_)}),rasterParticle:_=>({u_matrix:new a.b$(_),u_normalize_matrix:new a.b$(_),u_globe_matrix:new a.b$(_),u_merc_matrix:new a.b$(_),u_grid_matrix:new a.dm(_),u_tl_parent:new a.b_(_),u_scale_parent:new a.bZ(_),u_fade_t:new a.bZ(_),u_opacity:new a.bZ(_),u_image0:new a.bX(_),u_image1:new a.bX(_),u_raster_elevation:new a.bZ(_),u_zoom_transition:new a.bZ(_),u_merc_center:new a.b_(_),u_cutoff_params:new a.cO(_)}),rasterParticleTexture:_=>({u_texture:new a.bX(_),u_opacity:new a.bZ(_)}),rasterParticleDraw:_=>({u_particle_texture:new a.bX(_),u_particle_texture_side_len:new a.bZ(_),u_tile_offset:new a.b_(_),u_velocity:new a.bX(_),u_color_ramp:new a.bX(_),u_velocity_res:new a.b_(_),u_max_speed:new a.bZ(_),u_uv_offset:new a.b_(_),u_data_scale:new a.b_(_),u_data_offset:new a.bZ(_),u_particle_pos_scale:new a.bZ(_),u_particle_pos_offset:new a.b_(_)}),rasterParticleUpdate:_=>({u_particle_texture:new a.bX(_),u_particle_texture_side_len:new a.bZ(_),u_velocity:new a.bX(_),u_velocity_res:new a.b_(_),u_max_speed:new a.bZ(_),u_speed_factor:new a.bZ(_),u_reset_rate:new a.bZ(_),u_rand_seed:new a.bZ(_),u_uv_offset:new a.b_(_),u_data_scale:new a.b_(_),u_data_offset:new a.bZ(_),u_particle_pos_scale:new a.bZ(_),u_particle_pos_offset:new a.b_(_)}),symbol:_=>({u_is_size_zoom_constant:new a.bX(_),u_is_size_feature_constant:new a.bX(_),u_size_t:new a.bZ(_),u_size:new a.bZ(_),u_camera_to_center_distance:new a.bZ(_),u_rotate_symbol:new a.bX(_),u_aspect_ratio:new a.bZ(_),u_fade_change:new a.bZ(_),u_matrix:new a.b$(_),u_label_plane_matrix:new a.b$(_),u_coord_matrix:new a.b$(_),u_is_text:new a.bX(_),u_elevation_from_sea:new a.bX(_),u_pitch_with_map:new a.bX(_),u_texsize:new a.b_(_),u_texsize_icon:new a.b_(_),u_texture:new a.bX(_),u_texture_icon:new a.bX(_),u_gamma_scale:new a.bZ(_),u_device_pixel_ratio:new a.bZ(_),u_tile_id:new a.bY(_),u_zoom_transition:new a.bZ(_),u_inv_rot_matrix:new a.b$(_),u_merc_center:new a.b_(_),u_camera_forward:new a.bY(_),u_tile_matrix:new a.b$(_),u_up_vector:new a.bY(_),u_ecef_origin:new a.bY(_),u_is_halo:new a.bX(_),u_icon_transition:new a.bZ(_),u_color_adj_mat:new a.b$(_),u_scale_factor:new a.bZ(_),u_ground_shadow_factor:new a.bY(_),u_inv_matrix:new a.b$(_),u_normal_scale:new a.bZ(_),u_lutTexture:new a.bX(_),u_zoom:new a.bZ(_),u_spp_fill_np_color:new a.cO(_),u_spp_halo_np_color:new a.cO(_),u_spp_opacity:new a.bZ(_),u_spp_halo_width:new a.bZ(_),u_spp_halo_blur:new a.bZ(_),u_spp_emissive_strength:new a.bZ(_),u_spp_occlusion_opacity:new a.bZ(_),u_spp_z_offset:new a.bZ(_),u_spp_translate_rotation:new a.b_(_)}),background:_=>({u_matrix:new a.b$(_),u_emissive_strength:new a.bZ(_),u_opacity:new a.bZ(_),u_color:new a.dl(_)}),backgroundPattern:_=>({u_matrix:new a.b$(_),u_emissive_strength:new a.bZ(_),u_opacity:new a.bZ(_),u_image:new a.bX(_),u_pattern_tl:new a.b_(_),u_pattern_br:new a.b_(_),u_texsize:new a.b_(_),u_pattern_size:new a.b_(_),u_pixel_coord_upper:new a.b_(_),u_pixel_coord_lower:new a.b_(_),u_pattern_units_to_pixels:new a.b_(_)}),terrainRaster:_=>({u_matrix:new a.b$(_),u_image0:new a.bX(_),u_image1:new a.bX(_),u_skirt_height:new a.bZ(_),u_ground_shadow_factor:new a.bY(_),u_emissive_texture_available:new a.bZ(_)}),skybox:_=>({u_matrix:new a.b$(_),u_sun_direction:new a.bY(_),u_cubemap:new a.bX(_),u_opacity:new a.bZ(_),u_temporal_offset:new a.bZ(_)}),skyboxGradient:_=>({u_matrix:new a.b$(_),u_color_ramp:new a.bX(_),u_center_direction:new a.bY(_),u_radius:new a.bZ(_),u_opacity:new a.bZ(_),u_temporal_offset:new a.bZ(_)}),skyboxCapture:_=>({u_matrix_3f:new a.dm(_),u_sun_direction:new a.bY(_),u_sun_intensity:new a.bZ(_),u_color_tint_r:new a.cO(_),u_color_tint_m:new a.cO(_),u_luminance:new a.bZ(_)}),globeRaster:_=>({u_proj_matrix:new a.b$(_),u_globe_matrix:new a.b$(_),u_normalize_matrix:new a.b$(_),u_merc_matrix:new a.b$(_),u_zoom_transition:new a.bZ(_),u_merc_center:new a.b_(_),u_image0:new a.bX(_),u_image1:new a.bX(_),u_grid_matrix:new a.dm(_),u_skirt_height:new a.bZ(_),u_far_z_cutoff:new a.bZ(_),u_frustum_tl:new a.bY(_),u_frustum_tr:new a.bY(_),u_frustum_br:new a.bY(_),u_frustum_bl:new a.bY(_),u_globe_pos:new a.bY(_),u_globe_radius:new a.bZ(_),u_viewport:new a.b_(_),u_emissive_texture_available:new a.bZ(_)}),globeAtmosphere:_=>({u_frustum_tl:new a.bY(_),u_frustum_tr:new a.bY(_),u_frustum_br:new a.bY(_),u_frustum_bl:new a.bY(_),u_horizon:new a.bZ(_),u_transition:new a.bZ(_),u_fadeout_range:new a.bZ(_),u_atmosphere_fog_color:new a.cO(_),u_high_color:new a.cO(_),u_space_color:new a.cO(_),u_temporal_offset:new a.bZ(_),u_horizon_angle:new a.bZ(_)}),model:_=>({u_matrix:new a.b$(_),u_lighting_matrix:new a.b$(_),u_normal_matrix:new a.b$(_),u_node_matrix:new a.b$(_),u_lightpos:new a.bY(_),u_lightintensity:new a.bZ(_),u_lightcolor:new a.bY(_),u_camera_pos:new a.bY(_),u_opacity:new a.bZ(_),u_baseColorFactor:new a.cO(_),u_emissiveFactor:new a.cO(_),u_metallicFactor:new a.bZ(_),u_roughnessFactor:new a.bZ(_),u_baseTextureIsAlpha:new a.bX(_),u_alphaMask:new a.bX(_),u_alphaCutoff:new a.bZ(_),u_baseColorTexture:new a.bX(_),u_metallicRoughnessTexture:new a.bX(_),u_normalTexture:new a.bX(_),u_occlusionTexture:new a.bX(_),u_emissionTexture:new a.bX(_),u_lutTexture:new a.bX(_),u_color_mix:new a.cO(_),u_aoIntensity:new a.bZ(_),u_emissive_strength:new a.bZ(_),u_occlusionTextureTransform:new a.cO(_)}),modelDepth:_=>({u_matrix:new a.b$(_),u_instance:new a.b$(_),u_node_matrix:new a.b$(_)}),groundShadow:_=>({u_matrix:new a.b$(_),u_ground_shadow_factor:new a.bY(_)}),stars:_=>({u_matrix:new a.b$(_),u_up:new a.bY(_),u_right:new a.bY(_),u_intensity_multiplier:new a.bZ(_)}),snowParticle:_=>({u_modelview:new a.b$(_),u_projection:new a.b$(_),u_time:new a.bZ(_),u_cam_pos:new a.bY(_),u_velocityConeAperture:new a.bZ(_),u_velocity:new a.bZ(_),u_horizontalOscillationRadius:new a.bZ(_),u_horizontalOscillationRate:new a.bZ(_),u_boxSize:new a.bZ(_),u_billboardSize:new a.bZ(_),u_simpleShapeParameters:new a.b_(_),u_screenSize:new a.b_(_),u_thinningCenterPos:new a.b_(_),u_thinningShape:new a.bY(_),u_thinningAffectedRatio:new a.bZ(_),u_thinningParticleOffset:new a.bZ(_),u_particleColor:new a.cO(_),u_direction:new a.bY(_)}),rainParticle:_=>({u_modelview:new a.b$(_),u_projection:new a.b$(_),u_time:new a.bZ(_),u_cam_pos:new a.bY(_),u_texScreen:new a.bX(_),u_velocityConeAperture:new a.bZ(_),u_velocity:new a.bZ(_),u_boxSize:new a.bZ(_),u_rainDropletSize:new a.b_(_),u_distortionStrength:new a.bZ(_),u_rainDirection:new a.bY(_),u_color:new a.cO(_),u_screenSize:new a.b_(_),u_thinningCenterPos:new a.b_(_),u_thinningShape:new a.bY(_),u_thinningAffectedRatio:new a.bZ(_),u_thinningParticleOffset:new a.bZ(_),u_shapeDirectionalPower:new a.bZ(_),u_shapeNormalPower:new a.bZ(_),u_mode:new a.bZ(_)}),vignette:_=>({u_vignetteShape:new a.bY(_),u_vignetteColor:new a.cO(_)}),occlusion:_=>({u_matrix:new a.b$(_),u_anchorPos:new a.bY(_),u_screenSizePx:new a.b_(_),u_occluderSizePx:new a.b_(_),u_color:new a.cO(_)})};class Yu{constructor(d,g,w,j){this.id=Yu.uniqueIdxCounter,Yu.uniqueIdxCounter++,this.context=d;const I=d.gl;this.buffer=I.createBuffer(),this.dynamicDraw=!!w,this.context.unbindVAO(),d.bindElementBuffer.set(this.buffer),I.bufferData(I.ELEMENT_ARRAY_BUFFER,g.arrayBuffer,this.dynamicDraw?I.DYNAMIC_DRAW:I.STATIC_DRAW),this.dynamicDraw||j||g.destroy()}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(d){this.id=Yu.uniqueIdxCounter,Yu.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)}}Yu.uniqueIdxCounter=0;const AE={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class rI{constructor(d,g,w,j,I,L){this.length=g.length,this.attributes=w,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||I||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 w of this.attributes){const j=g.getAttributeLocation(d,w.name);j!==-1&&d.enableVertexAttribArray(j)}}setVertexAttribPointers(d,g,w){for(const j of this.attributes){const I=g.getAttributeLocation(d,j.name);if(I!==-1){const L=j.offset+this.itemSize*(w||0);j.type==="Float32"?d.vertexAttribPointer(I,j.components,d.FLOAT,!1,this.itemSize,L):d.vertexAttribIPointer(I,j.components,d[AE[j.type]],this.itemSize,L)}}}setVertexAttribDivisor(d,g,w){for(let j=0;j0&&d.vertexAttribDivisor(I,w)}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class C0{constructor(d,g,w,j,I){this.context=d,this.width=g,this.height=w;const L=this.framebuffer=d.gl.createFramebuffer();j>0&&(this.colorAttachment0=new qg(d,L,0)),j>1&&(this.colorAttachment1=new qg(d,L,1)),I&&(this.depthAttachmentType=I,this.depthAttachment=I==="renderbuffer"?new _E(d,L):new UC(d,L))}static createWithTexture(d,g,w,j,I){const L=d.gl;if(d.activeTexture.set(L.TEXTURE1),d.viewport.set([0,0,w,j]),g&&g.width===w&&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:w,height:j,data:null},d.extRenderToTextureHalfFloat?d.gl.RGBA16F:d.gl.RGBA8);F.bind(L.LINEAR,L.CLAMP_TO_EDGE);const z=d.createFramebuffer(w,j,1,null);if(z.colorAttachment0.set(F.texture),I){const H=d.createRenderbuffer(L.DEPTH24_STENCIL8,w,j);d.bindFramebuffer.set(z.framebuffer),L.framebufferRenderbuffer(L.FRAMEBUFFER,L.DEPTH_STENCIL_ATTACHMENT,L.RENDERBUFFER,H),z._stencilRbo=H}return z}createColorAttachment(d,g){g===0?this.colorAttachment0=new qg(d,this.framebuffer,0):g===1&&(this.colorAttachment1=new qg(d,this.framebuffer,1))}removeColorAttachment(d,g){const w=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&&w.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 Kg{constructor(d,g){this.gl=d,this.clearColor=new LC(this),this.clearDepth=new V4(this),this.clearStencil=new rb(this),this.colorMask=new q4(this),this.depthMask=new MC(this),this.stencilMask=new mE(this),this.stencilFunc=new nb(this),this.stencilOp=new pE(this),this.stencilTest=new tp(this),this.depthRange=new rp(this),this.depthTest=new zg(this),this.depthFunc=new Rd(this),this.blend=new DC(this),this.blendFunc=new gE(this),this.blendColor=new OC(this),this.blendEquation=new Ug(this),this.cullFace=new sb(this),this.cullFaceSide=new ib(this),this.frontFace=new yE(this),this.program=new ab(this),this.activeTexture=new v0(this),this.viewport=new FC(this),this.bindFramebuffer=new BC(this),this.bindRenderbuffer=new $C(this),this.bindTexture=new Vg(this),this.bindVertexBuffer=new zC(this),this.bindElementBuffer=new G4(this),this.bindVertexArrayOES=new H4(this),this.pixelStoreUnpack=new W4(this),this.pixelStoreUnpackPremultiplyAlpha=new xE(this),this.pixelStoreUnpackFlipY=new vE(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,w){return new Yu(this,d,g,w)}createVertexBuffer(d,g,w,j,I){return new rI(this,d,g,w,j,I)}createRenderbuffer(d,g,w){const j=this.gl,I=j.createRenderbuffer();return this.bindRenderbuffer.set(I),j.renderbufferStorage(j.RENDERBUFFER,d,g,w),this.bindRenderbuffer.set(null),I}createFramebuffer(d,g,w,j){return new C0(this,d,g,w,j)}clear({color:d,depth:g,stencil:w,colorMask:j}){const I=this.gl;let L=0;d&&(L|=I.COLOR_BUFFER_BIT,this.clearColor.set(d.toNonPremultipliedRenderColor(null)),this.colorMask.set(j||[!0,!0,!0,!0])),g!==void 0&&(L|=I.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(g),this.depthMask.set(!0)),w!==void 0&&(L|=I.STENCIL_BUFFER_BIT,this.clearStencil.set(w),this.stencilMask.set(255)),I.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,Yr.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 ip;function _r(_,d,g,w,j,I,L){const F=_.context,z=F.gl,H=_.transform,Z=[a.aH(H.center.lng),a.aL(H.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",oe=ne!=="point",xe=[];let ye=0,Pe=0;for(let De=0;De0){const Lr=a.bb(),gr=Wt;a.cz(Lr,at.placementInvProjMatrix,H.glCoordMatrix),a.cz(Lr,Lr,at.placementViewportMatrix),xe.push({circleArray:Ot,circleOffset:Pe,transform:gr,invTransform:Lr,projection:at.getProjection()}),ye+=Ot.length/4,Pe=ye}if(!Kt)continue;_.terrain&&_.terrain.setupElevationDraw(Ge,rr);const Ar=_t?[Be.canonical.x,Be.canonical.y,1<=0&&(ie[Me.associatedIconIndex]={x:Qe,y:xt,z:ft,angle:gt})}else Rg($e,ne)}if(H){re.clear();const Pe=_.icon.placedSymbolArray;for(let Me=0;Me{let ln=[0,0,0];if(rs){const Ys=_.style.directionalLight,Ss=_.style.ambientLight;Ys&&Ss&&(ln=Wu(_.style,Ys,Ss))}return ln},bn=rs=>{if(_.context.disableSymbolUBO)return;rs.push("USE_PAINT_PROPERTIES_UBO");const ln=Math.floor(_.context.maxUniformBlockSize/4),Ys=Math.floor(ln/4);rs.push(`MAX_UBO_SIZE_VEC4 ${Ys}u`)},rn=rs=>{Be.depthOcclusionForSymbolsAndCircles&&(g.hasOcclusionOpacityProperties||_.terrain)&&(rs.push("DEPTH_D24"),rs.push("DEPTH_OCCLUSION"))},Hn=rs=>{g.lut&&!$e&&(g.lut.texture||(g.lut.texture=new a.dR(_.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),rs.push("APPLY_LUT_ON_GPU"))},ws=()=>{const rs=Ge&&g.layout.get("symbol-placement")!=="point",ln=[];rn(ln),Hn(ln);const Ys=rs||an,Ss=Ot.elevationType==="road",Bi=_.shadowRenderer,In=Ss&&Qe&&!!Bi&&Bi.enabled,ks=Ur(In),ra=Ss&&Qe&&!_.terrain?lt:Bt,jo=g.paint.get("icon-image-cross-fade");_.terrainRenderModeElevated()&&Qe&&ln.push("PITCH_WITH_MAP_TERRAIN"),Ar&&(ln.push("PROJECTION_GLOBE_VIEW"),Ys&&ln.push("PROJECTED_POS_ON_VIEWPORT")),jo>0&&Ot.hasAnySecondaryIcon&&ln.push("ICON_TRANSITION"),!Ot.icon.zOffsetVertexBuffer||Ss&&_.terrain||ln.push("Z_OFFSET"),ye===0&&Pe===0&&Me===0&&Se===1||ln.push("COLOR_ADJUSTMENT"),Ot.sdfIcons&&ln.push("RENDER_SDF"),In&&ln.push("RENDER_SHADOWS","NORMAL_OFFSET"),Ss&&Qe&&!_.terrain&&Ot.icon.orientationVertexBuffer&&ln.push("ELEVATED_ROADS"),bn(ln);const ma=Ke.disableSymbolUBO?Ot.icon.programConfigurations.get(g.id):null,Ka=_.getOrCreateProgram("symbol",{config:ma,defines:ln}),pc=Kt.imageAtlasTexture?Kt.imageAtlasTexture.size:[0,0],us=Ot.iconSizeData,Mc=a.bj(us,Be.zoom),Dc=Qe||!Be.isOrthographic,Os=kf(gr,Kt.tileID.canonical,Qe,Ge,Be,Ot.getProjection(),Tr),Vs=Pg(gr,Kt.tileID.canonical,Qe,Ge,Be,Ot.getProjection(),Tr),ys=Ot.icon.uboBinder&&Ot.icon.uboBinder.cachedHeader&&256&Ot.icon.uboBinder.cachedHeader.dataDrivenMask?[0,0]:F,Ri=_.translatePosMatrix(Vs,Kt,ys,H,!0),Uo=_.translatePosMatrix(gr,Kt,ys,H),fi=Ys?I0:Os,gc=Ge&&!Qe&&!rs;let Ff=rr;!_t&&!Be.mercatorFromTransition||Ge||(Ff=jh(Be));const fp=Ar?Ff:rr,mp=g.getColorAdjustmentMatrix(ye,Pe,Me,Se),ey=vb(us.kind,Mc,gc,Qe,_,Uo,fi,Ri,Ze,!1,pc,[0,0],0,Wt,Lr,tt,tn,fp,Ot.getProjection(),ks,_n,mp,jo,null),Ph=Kt.imageAtlasTexture?Kt.imageAtlasTexture:null,Bd=g.layout.get("icon-size").constantOr(0)!==1||Ot.iconsNeedLinear,ty=Ot.sdfIcons||_.options.rotating||_.options.zooming||Bd||Dc?De.LINEAR:De.NEAREST,ql=Ot.sdfIcons&&g.paint.get("icon-halo-width").constantOr(1)!==0,Bf=_.terrain&&Qe&&rs?a.b7(a.bb(),Os):I0;if(rs&&Ot.icon){const $f=a.bu.getAtTileOffsetFunc(Wt,Be.center.lat,Be.worldSize,Ot.getProjection()),zf=qu(gr,Kt.tileID.canonical,Qe,Ge,Be,Ot.getProjection(),Tr),qb=g.layout.get("icon-size-scale-range"),ry=a.aC(_.scaleFactor,qb[0],qb[1]);hc(Ot,gr,_,!1,zf,Vs,Qe,oe,$f,Wt,ry)}return{program:Ka,buffers:Ot.icon,uniformValues:ey,atlasTexture:Ph,atlasTextureIcon:null,atlasInterpolation:ty,atlasInterpolationIcon:null,isSDF:Ot.sdfIcons,hasHalo:ql,depthMode:ra,tile:Kt,renderWithShadows:In,labelPlaneMatrixInv:Bf}},Xs=()=>{const rs=at&&g.layout.get("symbol-placement")!=="point",ln=[],Ys=rs||gt||an,Ss=Ot.elevationType==="road",Bi=_.shadowRenderer,In=Ss&&xt&&!!Bi&&Bi.enabled,ks=Ur(In),ra=Ss&&xt&&!_.terrain?lt:Bt;_.terrainRenderModeElevated()&&xt&&ln.push("PITCH_WITH_MAP_TERRAIN"),Ar&&(ln.push("PROJECTION_GLOBE_VIEW"),Ys&&ln.push("PROJECTED_POS_ON_VIEWPORT")),!Ot.text.zOffsetVertexBuffer||Ss&&_.terrain||ln.push("Z_OFFSET"),Ot.iconsInText&&ln.push("RENDER_TEXT_AND_SYMBOL"),ln.push("RENDER_SDF"),In&&ln.push("RENDER_SHADOWS","NORMAL_OFFSET"),Ss&&xt&&!_.terrain&&Ot.text.orientationVertexBuffer&&ln.push("ELEVATED_ROADS"),rn(ln),bn(ln);const jo=Ke.disableSymbolUBO?Ot.text.programConfigurations.get(g.id):null,ma=_.getOrCreateProgram("symbol",{config:jo,defines:ln});let Ka,pc=[0,0],us=null;const Mc=Ot.textSizeData;Ot.iconsInText&&(pc=Kt.imageAtlasTexture?Kt.imageAtlasTexture.size:[0,0],us=Kt.imageAtlasTexture?Kt.imageAtlasTexture:null,Ka=xt||!Be.isOrthographic||_.options.rotating||_.options.zooming||Mc.kind==="composite"||Mc.kind==="camera"?De.LINEAR:De.NEAREST);const Dc=Kt.glyphAtlasTexture?Kt.glyphAtlasTexture.size:[0,0],Os=g.layout.get("text-size-scale-range"),Vs=a.aC(_.scaleFactor,Os[0],Os[1]),ys=a.bj(Mc,Be.zoom,Vs),Ri=kf(gr,Kt.tileID.canonical,xt,at,Be,Ot.getProjection(),Tr),Uo=Pg(gr,Kt.tileID.canonical,xt,at,Be,Ot.getProjection(),Tr),fi=Ot.text.uboBinder&&Ot.text.uboBinder.cachedHeader&&256&Ot.text.uboBinder.cachedHeader.dataDrivenMask?[0,0]:z,gc=_.translatePosMatrix(Uo,Kt,fi,Z,!0),Ff=_.translatePosMatrix(gr,Kt,fi,Z),fp=Ys?I0:Ri,mp=at&&!xt&&!rs;let ey=rr;!_t&&!Be.mercatorFromTransition||at||(ey=jh(Be));const Ph=vb(Mc.kind,ys,mp,xt,_,Ff,fp,gc,Ze,!0,Dc,pc,0,Wt,Lr,tt,tn,Ar?ey:rr,Ot.getProjection(),ks,_n,null,null,Vs),Bd=Kt.glyphAtlasTexture?Kt.glyphAtlasTexture:null,ty=De.LINEAR,ql=g.paint.get("text-halo-width").constantOr(1)!==0,Bf=_.terrain&&xt&&rs?a.b7(a.bb(),Ri):I0;if(rs&&Ot.text){const $f=a.bu.getAtTileOffsetFunc(Wt,Be.center.lat,Be.worldSize,Ot.getProjection()),zf=qu(gr,Kt.tileID.canonical,xt,at,Be,Ot.getProjection(),Tr);hc(Ot,gr,_,!0,zf,Uo,xt,xe,$f,Wt,Vs)}return{program:ma,buffers:Ot.text,uniformValues:Ph,atlasTexture:Bd,atlasTextureIcon:us,atlasInterpolation:ty,atlasInterpolationIcon:Ka,isSDF:!0,hasHalo:ql,depthMode:ra,tile:Kt,renderWithShadows:In,labelPlaneMatrixInv:Bf}},Is=Ot.icon.segments.get().length,ts=Ot.text.segments.get().length,gn=Is&&!L.onlyText?ws():null,yn=ts&&!L.onlyIcons?Xs():null,Ps=g.paint.get("icon-opacity").constantOr(1),ni=g.paint.get("text-opacity").constantOr(1);if(ft&&Ot.canOverlap){Lt=!0;const rs=Ps&&!L.onlyText?Ot.icon.segments.get():[],ln=ni&&!L.onlyIcons?Ot.text.segments.get():[];for(const Ys of rs)Tt.push({segments:new a.dy([Ys]),sortKey:Ys.sortKey,state:gn});for(const Ys of ln)Tt.push({segments:new a.dy([Ys]),sortKey:Ys.sortKey,state:yn})}else L.onlyText||Tt.push({segments:Ps?Ot.icon.segments:new a.dy([]),sortKey:0,state:gn}),L.onlyIcons||Tt.push({segments:ni?Ot.text.segments:new a.dy([]),sortKey:0,state:yn})}Lt&&Tt.sort((Wt,Kt)=>Wt.sortKey-Kt.sortKey);for(const Wt of Tt){const Kt=Wt.state;if(Kt)if(_.terrain?_.terrain.setupElevationDraw(Kt.tile,Kt.program,{useDepthForOcclusion:Be.depthOcclusionForSymbolsAndCircles,labelPlaneMatrixInv:Kt.labelPlaneMatrixInv}):_.setupDepthForOcclusion(Be.depthOcclusionForSymbolsAndCircles,Kt.program),Ke.activeTexture.set(De.TEXTURE0),Kt.atlasTexture&&Kt.atlasTexture.bind(Kt.atlasInterpolation,De.CLAMP_TO_EDGE,!0),Kt.atlasTextureIcon&&(Ke.activeTexture.set(De.TEXTURE1),Kt.atlasTextureIcon&&Kt.atlasTextureIcon.bind(Kt.atlasInterpolationIcon,De.CLAMP_TO_EDGE,!0)),Kt.renderWithShadows&&_.shadowRenderer.setupShadows(Kt.tile.tileID.toUnwrapped(),Kt.program,"vector-tile"),_.uploadCommonLightUniforms(_.context,Kt.program),Kt.hasHalo){const Ot=Kt.uniformValues;Ot.u_is_halo=1,wb(Kt.buffers,Wt.segments,g,_,Kt.program,Kt.depthMode,j,I,Ot,2),Ot.u_is_halo=0}else{if(Kt.isSDF){const Ot=Kt.uniformValues;Kt.hasHalo&&(Ot.u_is_halo=1,wb(Kt.buffers,Wt.segments,g,_,Kt.program,Kt.depthMode,j,I,Ot,1)),Ot.u_is_halo=0}wb(Kt.buffers,Wt.segments,g,_,Kt.program,Kt.depthMode,j,I,Kt.uniformValues,1)}}}function wb(_,d,g,w,j,I,L,F,z,H){const Z=w.context,ne=Z.gl,re=[_.dynamicLayoutVertexBuffer,_.opacityVertexBuffer,_.iconTransitioningVertexBuffer,_.globeExtVertexBuffer,_.zOffsetVertexBuffer,_.orientationVertexBuffer];_.featureIdBuffer&&re.push(_.featureIdBuffer);const ie=_.uboBinder?null:_.programConfigurations.get(g.id);if(_.uboBinder){_.uboBinder.layer=g;const xe=w.transform.zoom,ye=w.style.getBrightness?w.style.getBrightness():null,Pe=_.uboBinder.getConstantUniformValues(xe,ye);z.u_spp_fill_np_color=Pe.fill_np_color,z.u_spp_halo_np_color=Pe.halo_np_color,z.u_spp_opacity=Pe.opacity,z.u_spp_halo_width=Pe.halo_width,z.u_spp_halo_blur=Pe.halo_blur,z.u_spp_emissive_strength=Pe.emissive_strength,z.u_spp_occlusion_opacity=Pe.occlusion_opacity,z.u_spp_z_offset=Pe.z_offset;const Me=g.paint.get(_.uboBinder.isText?"text-translate-anchor":"icon-translate-anchor"),Se=_.uboBinder.cachedHeader&&256&_.uboBinder.cachedHeader.dataDrivenMask&&Me==="map"?w.transform.angle:0;z.u_spp_translate_rotation=[Math.cos(Se),Math.sin(Se)]}const{batchIndices:ce,batchSegments:oe}=_.getBatchGrouping(d);for(const xe of ce){const ye=oe.get(xe);_.uboBinder&&_.uboBinder.bind(Z,j.program,xe),j.draw(w,ne.TRIANGLES,I,L,F,Hr.disabled,z,g.id,_.layoutVertexBuffer,_.indexBuffer,ye,g.paint,w.transform.zoom,ie,re,H)}}function Sb(_,d,g,w,j,I){const L=g.paint.get("line-width"),F=g.paint.get("line-emissive-strength").isConstant(),z=g.paint.get("line-emissive-strength").constantOr(0),H=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=!(!_.terrain||!_.terrain.enabled),ce=_.context,oe=ce.gl;if(g.hasElevatedBuckets&&_.transform.projection.name==="globe")return;const xe=g.layout.get("line-cross-slope"),ye=xe!==void 0,Pe=xe<1,Me=j||_.colorModeForDrapableLayerRenderPass(F?z:null),Se=_.terrain&&_.terrain.renderingToTexture||I,Ze=Se?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),at=g.paint.get("line-pattern"),Qe=at.constantOr(1),xt=g.paint.get("line-pattern-cross-fade"),ft=at.constantOr(null),Lt=g.paint.get("line-opacity").constantOr(1);let Bt=!Qe&&Lt!==1||_.depthOcclusion&&H>0&&H<1;const lt=g.paint.get("line-gradient"),tt=Qe?"linePattern":"line",gt=a.dU(g);let _t;if(Se&&_.terrain&&_.terrain.clipOrMaskOverlapStencilType()&&(Bt=!1),H!==0&&_.depthOcclusion){const Ot=g.paint._values["line-opacity"];Ot&&Ot.value&&Ot.value.kind==="constant"?_t=Ot.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&>.push("VARIABLE_LINE_WIDTH"),Se&&(_.emissiveMode!=="dual-source-blending"||F?_.emissiveMode==="mrt-fallback"&>.push("USE_MRT1"):gt.push("DUAL_SOURCE_BLENDING"));const Tt={},rr=(Ot,Ar,Lr,gr,Tr,Wr)=>{for(const an of Ot){const tn=d.getTile(an);if(Qe&&!tn.patternsLoaded())continue;const _n=tn.getBucket(g);if(!_n||_n.elevationType!=="none"&&!Tr||_n.elevationType==="none"&&Tr)continue;_.prepareDrawTile();const Ur=[...Ar],bn=_.shadowRenderer,rn=_n.elevationType==="road"&&!!bn&&bn.enabled;let Hn=[0,0,0];if(rn){const In=_.style.directionalLight,ks=_.style.ambientLight;In&&ks&&(Hn=Wu(_.style,In,ks)),Ur.push("RENDER_SHADOWS","NORMAL_OFFSET")}const ws=_n.programConfigurations.get(g.id);let Xs=!1;if(ft&&tn.imageAtlas){const In=a.dV.from(ft),ks=In.getPrimary().scaleSelf(Ze).toString(),ra=tn.imageAtlas.patternPositions.get(ks),jo=In.getSecondary(),ma=jo?tn.imageAtlas.patternPositions.get(jo.scaleSelf(Ze).toString()):null;Xs=!!ra&&!!ma,ra&&ws.setConstantPatternPositions(ra,ma)}xt>0&&(Xs||ws.getPatternTransitionVertexBuffer("line-pattern"))&&Ur.push("LINE_PATTERN_TRANSITION"),_n.elevationGroundScaleVertexBuffer&&Ur.push("ELEVATION_GROUND_SCALE");const Is=_.isTileAffectedByFog(an),ts=_.getOrCreateProgram(tt,{config:ws,defines:Ur,overrideFog:Is});if(!Qe&&Be&&Ge&&tn.lineAtlas){const In=tn.lineAtlas.getDash(Be,Ge);In&&ws.setConstantPatternPositions(In)}rn&&bn.setupShadows(tn.tileID.toUnwrapped(),ts,"vector-tile");let[gn,yn]=g.paint.get("line-trim-offset");(Ge==="round"||Ge==="square")&&gn!==yn&&(gn===0&&(gn-=1),yn===1&&(yn+=1));const Ps=Se?an.projMatrix:null,ni=ne?1/_n.tileToMeter/a.aA(tn,1,_.transform.zoom):1,rs=ne?1/_n.tileToMeter/a.aA(tn,1,Math.floor(_.transform.zoom)):1,ln=Ke?g.paint._values["line-floorwidth"]:null;let Ys;if(ln&&ln.value.kind==="constant"){const In=_n.zoom;In in Tt||(Tt[In]=Math.max(.01,g.widthExpression().evaluate({zoom:In}))),Ys=ln.value.value;const ks=Math.floor(_.transform.zoom);ln.value.value=Tt[In]*Math.pow(2,ks-tn.tileID.overscaledZ)}const Ss=Qe?a.dW(_,tn,g,Ps,Ze,ni,rs,[gn,yn],Hn,xt):a.dX(_,tn,g,Ps,_n.lineClipsArray.length,Ze,ni,rs,[gn,yn],Hn);if(lt){const In=_n.gradients[g.id];let ks=In.texture;if(g.gradientVersion!==In.version){let ra=256;if(g.stepInterpolant){const jo=d.getSource().maxzoom,ma=an.canonical.z===jo?Math.ceil(1<<_.transform.maxZoom-an.canonical.z):1;ra=a.aC(a.dY(_n.maxLineLength/a.an*1024*ma),256,ce.maxTextureSize)}In.gradient=a.dZ({expression:g.gradientExpression(),evaluationKey:"lineProgress",resolution:ra,image:In.gradient||void 0,clips:_n.lineClipsArray}),In.texture?In.texture.update(In.gradient):In.texture=new a.T(ce,In.gradient,oe.RGBA8),In.version=g.gradientVersion,ks=In.texture}ce.activeTexture.set(oe.TEXTURE1),ks.bind(g.stepInterpolant?oe.NEAREST:oe.LINEAR,oe.CLAMP_TO_EDGE)}Ke&&(ce.activeTexture.set(oe.TEXTURE0),tn.lineAtlasTexture&&tn.lineAtlasTexture.bind(oe.LINEAR,oe.REPEAT),ws.updatePaintBuffers()),Qe&&(ce.activeTexture.set(oe.TEXTURE0),tn.imageAtlasTexture&&tn.imageAtlasTexture.bind(oe.LINEAR,oe.CLAMP_TO_EDGE),ws.updatePaintBuffers()),Tr&&_.terrain.setupElevationDraw(tn,ts),_.uploadCommonUniforms(ce,ts,an.toUnwrapped());const Bi=In=>{_t!=null&&(_t.value=Lt*H),ts.draw(_,oe.TRIANGLES,Lr,In,Me,Hr.disabled,Ss,g.id,_n.layoutVertexBuffer,_n.indexBuffer,_n.segments,g.paint,_.transform.zoom,ws,[_n.layoutVertexBuffer2,_n.patternVertexBuffer,_n.zOffsetVertexBuffer,_n.elevationGroundScaleVertexBuffer]),_t!=null&&(_t.value=Lt)};if(Bt&&!Tr){const In=_.stencilModeForClipping(an).ref;In===0&&Se&&ce.clear({stencil:0});const ks={func:oe.EQUAL,mask:255};Ss.u_alpha_discard_threshold=.8,Bi(new Jr(ks,In,255,oe.KEEP,oe.KEEP,oe.INVERT)),Ss.u_alpha_discard_threshold=0,Bi(new Jr(ks,In,255,oe.KEEP,oe.KEEP,oe.KEEP))}else Ss.u_alpha_discard_threshold=Bt&&Tr&&Wr?.8:0,Bi(Tr?gr:_.stencilModeForClipping(an));Ys!==void 0&&(ln.value.value=Ys)}};let Wt=_.depthModeForSublayer(0,Cr.ReadOnly);const Kt=new Cr(_.depthOcclusion?oe.GREATER:oe.LEQUAL,Cr.ReadOnly,_.depthRangeFor3D);if(g.hasNonElevatedBuckets){const Ot=!Se&&_.terrain;H!==0&&Ot?a.w(`Occlusion opacity for layer ${g.id} is supported on terrain only if the layer has line-z-offset enabled.`):Ot?a.w(`Cannot render non-elevated lines in immediate mode when terrain is enabled. Layer: ${g.id}.`):rr(w,gt,Wt,Jr.disabled,!1,!0)}if(g.hasElevatedBuckets){Z==="hd-road-markup"?ie||(Wt=Kt,gt.push("ELEVATED_ROADS")):(gt.push("ELEVATED"),Wt=Kt,ye&>.push(Pe?"CROSS_SLOPE_HORIZONTAL":"CROSS_SLOPE_VERTICAL"),re&>.push("ELEVATION_REFERENCE_SEA"));const Ot=Bt?_.stencilModeFor3D():Jr.disabled;_.forceTerrainMode=!0,rr(w,gt,Wt,Ot,!0,!0),Bt&&rr(w,gt,Wt,Ot,!0,!1),_.forceTerrainMode=!1}Bt&&(_.resetStencilClippingMasks(),Se&&ce.clear({stencil:0})),H===0||_.depthOcclusion||Se||_.layersWithOcclusionOpacity.push(_.currentLayer)}const Ah={additive:{clearColor:new a.aq(0,0,0,0),colorMode:Yr.additive,compositeUniformValue:1},multiply:{clearColor:new a.aq(1,1,1,1),colorMode:Yr.multiply,compositeUniformValue:0}};function kE(_,d){const g=1<<_.canonical.z,w=(d.x*g-_.canonical.x-_.wrap*g)*a.an,j=(d.y*g-_.canonical.y)*a.an,I=a.d_(d.z,d.y);return a.cQ(w,j,I)}function P0(_,d,g,w,j){if(!g.layout||g.layout.get("fill-elevation-reference")==="none"||g.paint.get("fill-opacity").constantOr(1)===0)return;const I=_.context.gl,L=new Cr(_.context.gl.LEQUAL,Cr.ReadWrite,_.depthRangeFor3D),F=new Cr(_.context.gl.GREATER,Cr.ReadWrite,_.depthRangeFor3D),z=function(ie){let ce=.01;return ie.isOrthographic&&(ce=a.am(1e-4,ce,a.cL(ie.pitch>=Qm?1:ie.pitch/Qm))),2*ce}(_.transform),H=_.transform.getFreeCameraOptions().position,Z="elevatedStructuresDepthReconstruct",ne=_.getOrCreateProgram(Z,{defines:["DEPTH_RECONSTRUCTION"]}),re=_.getOrCreateProgram(Z);for(const ie of w){const ce=d.getTile(ie),oe=ce.getBucket(g);if(!oe)continue;const xe=oe.elevatedStructures;if(!xe)continue;const ye=oe.elevationBufferData.heightRange,Pe=kE(ie.toUnwrapped(),H),Me=_.translatePosMatrix(ie.projMatrix,ce,g.paint.get("fill-translate"),g.paint.get("fill-translate-anchor"));let Se,Ze,$e,Ke;if(j==="initialize"){if(!ye||ye.min>=1||xe.depthSegments.segments[0].primitiveLength===0)continue;Se=A0(Me,Pe,z,1,0),Ze=L,$e=xe.depthSegments,Ke=ne}else if(j==="reset"){if(!ye||ye.min>=0||xe.maskSegments.segments[0].primitiveLength===0)continue;Se=A0(Me,Pe,0,0,1),Ze=F,$e=xe.maskSegments,Ke=ne}else if(j==="geometry"){if(xe.depthSegments.segments[0].primitiveLength===0)continue;Se=A0(Me,Pe,z,1,0),Ze=L,$e=xe.depthSegments,Ke=re}Ke.draw(_,I.TRIANGLES,Ze,Jr.disabled,Yr.disabled,Hr.disabled,Se,g.id,xe.vertexBuffer,xe.indexBuffer,$e,g.paint,_.transform.zoom)}}function R0(_,d,g,w){const{painter:j,sourceCache:I,layer:L,coords:F,colorMode:z,elevationType:H,terrainEnabled:Z,pass:ne}=_,re=j.context.gl,ie=L.paint.get("fill-pattern"),ce=L.paint.get("fill-pattern-cross-fade"),oe=ie.constantOr(null);let xe=H;H!=="road"||d&&!Z||(xe="none");const ye=xe==="road",Pe=_.painter.shadowRenderer,Me=ye&&!!Pe&&Pe.enabled,Se=new Cr(j.context.gl.LEQUAL,Cr.ReadOnly,j.depthRangeFor3D);let Ze=[0,0,0];if(Me){const Be=j.style.directionalLight,Ge=j.style.ambientLight;Be&&Ge&&(Ze=Wu(j.style,Be,Ge))}const $e=ie&&ie.constantOr(1),Ke=j.terrain&&j.terrain.renderingToTexture,De=(Be,Ge)=>{let at,Qe,xt,ft,Lt;Ge?(at=$e&&!L.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",xt=re.LINES):(at=$e?"fillPattern":"fill",xt=re.TRIANGLES);for(const Bt of F){const lt=I.getTile(Bt);if($e&&!lt.patternsLoaded())continue;const tt=lt.getBucket(L);if(!tt)continue;const gt=d?tt.elevationBufferData:tt.bufferData;if(gt.isEmpty())continue;j.prepareDrawTile();const _t=gt.programConfigurations.get(L.id),Tt=j.isTileAffectedByFog(Bt),rr=[],Wt=[];ye&&(rr.push("ELEVATED_ROADS"),Wt.push(gt.elevatedLayoutVertexBuffer)),Me&&rr.push("RENDER_SHADOWS","NORMAL_OFFSET"),Ke&&g&&rr.push("USE_MRT1"),$e&&(j.context.activeTexture.set(re.TEXTURE0),lt.imageAtlasTexture&<.imageAtlasTexture.bind(re.LINEAR,re.CLAMP_TO_EDGE),_t.updatePaintBuffers());let Kt=!1;if(oe&<.imageAtlas){const Tr=lt.imageAtlas,Wr=a.dV.from(oe),an=Wr.getPrimary().scaleSelf(a.o.devicePixelRatio).toString(),tn=Wr.getSecondary(),_n=Tr.patternPositions.get(an),Ur=tn?Tr.patternPositions.get(tn.scaleSelf(a.o.devicePixelRatio).toString()):null;Kt=!!_n&&!!Ur,_n&&_t.setConstantPatternPositions(_n,Ur)}ce>0&&(Kt||_t.getPatternTransitionVertexBuffer("fill-pattern"))&&rr.push("FILL_PATTERN_TRANSITION");const Ot=j.getOrCreateProgram(at,{config:_t,overrideFog:Tt,defines:rr}),Ar=j.translatePosMatrix(Bt.projMatrix,lt,L.paint.get("fill-translate"),L.paint.get("fill-translate-anchor"));Me&&Pe.setupShadows(lt.tileID.toUnwrapped(),Ot,"vector-tile");const Lr=L.paint.get("fill-emissive-strength");if(Ge){ft=gt.lineIndexBuffer,Lt=gt.lineSegments;const Tr=j.terrain&&j.terrain.renderingToTexture?j.terrain.drapeBufferSize:[re.drawingBufferWidth,re.drawingBufferHeight];Qe=at==="fillOutlinePattern"&&$e?Hg(Ar,Lr,j,lt,Tr,Ze,ce):WC(Ar,Lr,Tr,Ze)}else ft=gt.indexBuffer,Lt=gt.triangleSegments,Qe=$e?fb(Ar,Lr,j,lt,Ze,ce):hb(Ar,Lr,Ze);j.uploadCommonUniforms(j.context,Ot,Bt.toUnwrapped());let gr=Be;(H==="road"&&!Z||H==="offset")&&(gr=Se),Ot.draw(j,xt,gr,w||j.stencilModeForClipping(Bt),z,Hr.disabled,Qe,L.id,gt.layoutVertexBuffer,ft,Lt,L.paint,j.transform.zoom,_t,Wt)}};j.renderPass===ne&&De(j.depthModeForSublayer(1,j.renderPass==="opaque"?Cr.ReadWrite:Cr.ReadOnly),!1),xe==="none"&&j.renderPass==="translucent"&&L.paint.get("fill-antialias")&&De(j.depthModeForSublayer(L.getPaintProperty("fill-outline-color")?2:0,Cr.ReadOnly),!0)}function ap(_,d,g,w,j,I,L,F){g.resetLayerRenderingStats(_);const z=_.context,H=z.gl,Z=_.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),oe=g.paint.get("fill-extrusion-opacity"),xe=_.style.enable3dLights(),ye=g.paint.get(xe&&!ce?"fill-extrusion-ambient-occlusion-wall-radius":"fill-extrusion-ambient-occlusion-radius"),Pe=[g.paint.get("fill-extrusion-ambient-occlusion-intensity"),ye],Me=g.layout.get("fill-extrusion-edge-radius"),Se=Me>0&&!g.paint.get("fill-extrusion-rounded-roof"),Ze=Se?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",at=g.paint.get("fill-extrusion-flood-light-color").toNonPremultipliedRenderColor(Ge?null:g.lut).toArray01().slice(0,3),Qe=g.paint.get("fill-extrusion-flood-light-intensity"),xt=g.paint.get("fill-extrusion-vertical-scale"),ft=g.paint.get("fill-extrusion-line-width").constantOr(1)!==0,Lt=g.paint.get("fill-extrusion-height-alignment"),Bt=g.paint.get("fill-extrusion-base-alignment"),lt=Ba(_,g.paint.get("fill-extrusion-cutoff-fade-range")),tt=g.paint.get("fill-extrusion-front-cutoff"),gt=Tb(Z.pitch,tt,!!_.terrain),_t=gt[2]<1;_t&&(_.maxFrontCutoffRawStart=Math.max(_.maxFrontCutoffRawStart,tt[0]));const Tt=[];let rr;Ke&&Tt.push("PROJECTION_GLOBE_VIEW"),Pe[0]>0&&Tt.push("FAUX_AO"),Se&&Tt.push("ZERO_ROOF_RADIUS"),F&&Tt.push("HAS_CENTROID"),Qe>0&&Tt.push("FLOOD_LIGHT"),lt.shouldRenderCutoff&&Tt.push("RENDER_CUTOFF"),_t&&Tt.push("RENDER_FRONT_CUTOFF"),ft&&Tt.push("RENDER_WALL_MODE");const Wt=_.renderPass==="shadow",Kt=_.shadowRenderer,Ot=Wt&&!!Kt,Ar=Wt?Hr.disabled:Hr.backCCW;_.shadowRenderer&&(_.shadowRenderer.useNormalOffset=!0);let Lr=[0,0,0];if(Kt){const Wr=_.style.directionalLight,an=_.style.ambientLight;Wr&&an&&(Lr=Wu(_.style,Wr,an)),Wt||(Tt.push("RENDER_SHADOWS"),Kt.useNormalOffset&&Tt.push("NORMAL_OFFSET")),rr=Tt.concat(["SHADOWS_SINGLE_CASCADE"])}const gr=Ot?"fillExtrusionDepth":ce?"fillExtrusionPattern":"fillExtrusion",Tr=g.getLayerRenderingStats();for(const Wr of w){const an=d.getTile(Wr),tn=an.getBucket(g);if(!tn||tn.projection.name!==Z.projection.name)continue;let _n=!1;Kt&&(_n=Kt.getMaxCascadeForTile(Wr.toUnwrapped())===0);const Ur=_.isTileAffectedByFog(Wr),bn=tn.programConfigurations.get(g.id);let rn=!1;if(ie&&an.imageAtlas){const yn=an.imageAtlas,Ps=a.dV.from(ie),ni=Ps.getPrimary().scaleSelf(a.o.devicePixelRatio).toString(),rs=Ps.getSecondary(),ln=yn.patternPositions.get(ni),Ys=rs?yn.patternPositions.get(rs.scaleSelf(a.o.devicePixelRatio).toString()):null;rn=!!ln&&!!Ys,ln&&bn.setConstantPatternPositions(ln,Ys)}re>0&&(rn||bn.getPatternTransitionVertexBuffer("fill-extrusion-pattern"))&&Tt.push("FILL_EXTRUSION_PATTERN_TRANSITION");const Hn=_.getOrCreateProgram(gr,{config:bn,defines:_n?rr:Tt,overrideFog:Ur});if(_.terrain&&_.terrain.setupElevationDraw(an,Hn,{useMeterToDem:!0}),!tn.centroidVertexBuffer){const yn=Hn.getAttributeLocation(H,"a_centroid_pos");yn!==-1&&H.vertexAttribI4ui(yn,0,0,0,0)}!Wt&&Kt&&Kt.setupShadows(an.tileID.toUnwrapped(),Hn,"vector-tile"),ce&&(_.context.activeTexture.set(H.TEXTURE0),an.imageAtlasTexture&&an.imageAtlasTexture.bind(H.LINEAR,H.CLAMP_TO_EDGE),bn.updatePaintBuffers());const ws=g.paint.get("fill-extrusion-vertical-gradient"),Xs=1/tn.tileToMeter;let Is;if(Wt&&Kt){if(Eb(an.tileID,tn.maxHeight,_))continue;const yn=Kt.calculateShadowPassMatrixFromTile(an.tileID.toUnwrapped());Is=Z4(yn,Ze,Xs,xt,Lt,Bt)}else{const yn=_.translatePosMatrix(Wr.expandedProjMatrix,an,g.paint.get("fill-extrusion-translate"),g.paint.get("fill-extrusion-translate-anchor")),Ps=Z.projection.createInversionMatrix(Z,Wr.canonical);Is=ce?X4(yn,_,ws,oe,Pe,Ze,Xs,Wr,an,$e,Lt,Bt,De,Be,Ps,at,xt,re):HC(yn,_,ws,oe,Pe,Ze,Xs,Wr,$e,Lt,Bt,De,Be,Ps,at,xt,Qe,Lr,gt)}_.uploadCommonUniforms(z,Hn,Wr.toUnwrapped(),null,lt);let ts=tn.segments;if(Z.projection.name==="mercator"&&!Wt&&(ts=tn.getVisibleSegments(an.tileID,_.terrain,_.transform.getFrustum(0)),!ts.get().length))continue;if(Tr)if(Wt)for(const yn of ts.get())Tr.numRenderedVerticesInShadowPass+=yn.primitiveLength;else for(const yn of ts.get())Tr.numRenderedVerticesInTransparentPass+=yn.primitiveLength;const gn=[];(_.terrain||F)&&gn.push(tn.centroidVertexBuffer),Ke&&gn.push(tn.layoutVertexExtBuffer),ft&&gn.push(tn.wallVertexBuffer),Hn.draw(_,z.gl.TRIANGLES,j,I,L,Ar,Is,g.id,tn.layoutVertexBuffer,tn.indexBuffer,ts,g.paint,_.transform.zoom,bn,gn)}_.shadowRenderer&&(_.shadowRenderer.useNormalOffset=!1)}class NE{constructor(){this.translate=[0,0],this.translateAnchor="map",this.edgeRadius=0,this.cutoffFadeRange=0}}function Tb(_,d,g){if(!(d[2]<1)||g)return[0,0,1];const w=180*_/Math.PI;if(w<15)return[-.5,d[1],d[2]];const j=Math.min(1,Math.max(0,(w-15)/5)),I=j*j*(3-2*j);return[-.5*(1-I)+d[0]*I,d[1],d[2]]}function Md(_,d,g,w,j,I,L,F,z,H,Z,ne,re,ie,ce,oe,xe,ye,Pe,Me,Se){const Ze=d.context,$e=Ze.gl,Ke=d.transform,De=d.transform.zoom,Be=[],Ge=_.translate,at=_.translateAnchor,Qe=_.edgeRadius,xt=Ba(d,_.cutoffFadeRange);Z==="clear"?(Be.push("CLEAR_SUBPASS"),Me&&(Be.push("CLEAR_FROM_TEXTURE"),Ze.activeTexture.set($e.TEXTURE0),Me.bind($e.LINEAR,$e.CLAMP_TO_EDGE))):Z==="sdf"?Be.push("SDF_SUBPASS"):Z==="emissive"&&(Be.push("USE_MRT1"),Ze.activeTexture.set($e.TEXTURE0),Me.bind($e.LINEAR,$e.CLAMP_TO_EDGE)),ye&&Be.push("HAS_CENTROID"),xt.shouldRenderCutoff&&Be.push("RENDER_CUTOFF");const ft=(Lt,Bt,lt,tt,gt)=>{let _t=Be;Bt.groundRadiusBuffer!=null&&(_t=Be.concat("HAS_ATTRIBUTE_a_flood_light_ground_radius"));const Tt=Bt.programConfigurations.get(w.id),rr=d.isTileAffectedByFog(Lt),Wt=d.getOrCreateProgram("fillExtrusionGroundEffect",{config:Tt,defines:_t,overrideFog:rr}),Kt=((Ar,Lr,gr,Tr,Wr,an,tn,_n,Ur,bn,rn)=>({u_matrix:Lr,u_opacity:gr,u_ao_pass:Tr?1:0,u_meter_to_tile:Wr,u_ao:an,u_flood_light_intensity:tn,u_flood_light_color:_n,u_attenuation:Ur,u_edge_radius:bn,u_fb:0,u_fb_size:rn,u_dynamic_offset:1}))(0,tt,ne,H,gt,[re,ie*gt],ce,oe,xe,De>=17?0:Qe*gt,Me?Me.size[0]:0),Ot=[];ye&&Ot.push(Bt.hiddenByLandmarkVertexBuffer),Bt.groundRadiusBuffer!=null&&Ot.push(Bt.groundRadiusBuffer),d.uploadCommonUniforms(Ze,Wt,Lt.toUnwrapped(),null,xt),Wt.draw(d,Ze.gl.TRIANGLES,I,L,F,z,Kt,w.id,Bt.vertexBuffer,Bt.indexBuffer,lt,w.paint,De,Tt,Ot)};for(const Lt of j){const Bt=g.getTile(Lt),lt=Bt.getBucket(w);if(!lt||lt.projection.name!==Ke.projection.name||!lt.groundEffect||lt.groundEffect&&!lt.groundEffect.hasData())continue;const tt=lt.groundEffect,gt=1/lt.tileToMeter;{const _t=d.translatePosMatrix(Lt.projMatrix,Bt,Ge,at),Tt=tt.getDefaultSegment();ft(Lt,tt,Tt,_t,gt)}if(Pe)for(let _t=0;_t<4;_t++){const Tt=a.d$[_t](Lt),rr=g.getTile(Tt);if(!rr)continue;const Wt=rr.getBucket(w);if(!Wt||Wt.projection.name!==Ke.projection.name||!Wt.groundEffect||Wt.groundEffect&&!Wt.groundEffect.hasData())continue;const Kt=Wt.groundEffect;let Ot,Ar;_t===0?(Ot=[-a.an,0,0],Ar=1):_t===1?(Ot=[a.an,0,0],Ar=0):_t===2?(Ot=[0,-a.an,0],Ar=3):(Ot=[0,a.an,0],Ar=2);const Lr=Kt.regionSegments[Ar];if(!Lr)continue;const gr=new Float32Array(16);a.bx(gr,Lt.projMatrix,Ot),ft(Lt,Kt,Lr,d.translatePosMatrix(gr,Bt,Ge,at),gt)}}}function sI(_,d,g,w,j,I,L){w.centroidVertexArray.length===0&&w.createCentroidsBuffer();const F=I?I.findDEMTileFor(g):null;if(!(F&&F.dem||L))return;I&&F&&F.dem&&w.selfDEMTileTimestamp!==F.dem._timestamp&&(w.borderDoneWithNeighborZ=[-1,-1,-1,-1],w.selfDEMTileTimestamp=F.dem._timestamp);const z=(ye,Pe)=>{(ye.flags|Pe.flags)&a.e3?(ye.flags|=a.e3,Pe.flags|=a.e3):(ye.flags&=~a.e3,Pe.flags&=~a.e3)},H=ye=>new a.P(Math.ceil((ye+a.e4)*a.e5),0),Z=(ye,Pe,Me)=>{const Se=Math.ceil((ye+a.e4)*a.e5),Ze=Math.floor(Math.max(0,Math.min(a.an-1,Me))/4);return new a.P(Se,Ze<<5|(3&Pe)<<3|7)},ne=ye=>{const Pe=d.getSource().minzoom,Me=Ze=>{const $e=d.getTileByID(Ze);if($e&&$e.hasData())return $e.getBucket(j)},Se=[0,-1,1];for(const Ze of Se){if(ye.overscaledZ+Ze(re[0]=Math.min(ye.min.y,Pe.min.y),re[1]=Math.max(ye.max.y,Pe.max.y),re[2]=a.an-Pe.min.x>ye.max.x?Pe.min.x-a.an:ye.max.x,re),ce=(ye,Pe)=>(re[0]=Math.min(ye.min.x,Pe.min.x),re[1]=Math.max(ye.max.x,Pe.max.x),re[2]=a.an-Pe.min.y>ye.max.y?Pe.min.y-a.an:ye.max.y,re),oe=[(ye,Pe)=>ie(ye,Pe),(ye,Pe)=>ie(Pe,ye),(ye,Pe)=>ce(ye,Pe),(ye,Pe)=>ce(Pe,ye)],xe=(ye,Pe,Me,Se,Ze,$e,Ke)=>{if(!I)return 0;const De=[[$e?Me:ye,$e?ye:Me,0],[$e?Me:Pe,$e?Pe:Me,0]],Be=Ke<0?a.an+Ke:Ke,Ge=[$e?Be:(ye+Pe)/2,$e?(ye+Pe)/2:Be,0];return Me===0&&Ke<0||Me!==0&&Ke>0?I.getForTilePoints(Ze,[Ge],!0,Se):De.push(Ge),I.getForTilePoints(g,De,!0,F),Math.max(De[0][2],De[1][2],Ge[2])/I.exaggeration()};for(let ye=0;ye<4;ye++){const Pe=w.borderFeatureIndices[ye];if(Pe.length===0)continue;const Me=a.d$[ye](g),Se=ne(Me);if(!(Se&&Se instanceof a.e0))continue;const Ze=I?I.findDEMTileFor(Me):null;if(!(Ze&&Ze.dem||L)||(I&&Ze&&Ze.dem&&w.borderDEMTileTimestamp[ye]!==Ze.dem._timestamp&&(w.borderDoneWithNeighborZ[ye]=-1,w.borderDEMTileTimestamp[ye]=Ze.dem._timestamp),w.borderDoneWithNeighborZ[ye]===Se.canonical.z))continue;Se.centroidVertexArray.length===0&&Se.createCentroidsBuffer();const $e=(ye<2?1:5)-ye,Ke=Se.borderDoneWithNeighborZ[$e]!==w.canonical.z,De=Se.borderFeatureIndices[$e];let Be=0;if(w.canonical.z!==Se.canonical.z){for(const xt of Pe)w.showCentroid(w.featuresOnBorder[xt]);if(Ke)for(const xt of De)Se.showCentroid(Se.featuresOnBorder[xt]);w.borderDoneWithNeighborZ[ye]=Se.canonical.z,Se.borderDoneWithNeighborZ[$e]=w.canonical.z;continue}const Ge=new Map,at=new Set,Qe=new Set;for(let xt=0;xt1||lt.intersectsCount()>1;{let Wt=0;if(Ze&&Ze.dem&&!rr){const Kt=oe[ye](Lt,tt),Ot=ye%2?a.an-1:0;Wt=xe(Kt[0],Math.min(a.an-1,Kt[1]),Ot,Ze,Me,ye<2,Kt[2])}Lt.centroidXY=Z(Wt,ye,Tt),tt.centroidXY=Z(Wt,$e,Tt)}if(w.writeCentroidToBuffer(Lt),Se.writeCentroidToBuffer(tt),ft.buildingId!==void 0){for(const Wt of w.centroidData)Wt.buildingId===ft.buildingId&&Wt!==Lt&&(Wt.centroidXY=Lt.centroidXY,w.writeCentroidToBuffer(Wt));for(const Wt of Se.centroidData)Wt.buildingId===ft.buildingId&&Wt!==tt&&(Wt.centroidXY=tt.centroidXY,Se.writeCentroidToBuffer(Wt))}}for(const xt of Pe){if(at.has(xt))continue;const ft=w.featuresOnBorder[xt],Lt=w.centroidData[ft.centroidDataIndex],Bt=ft.borders[ye];let lt;for(;BeBt[0]+3||tt[0]>Bt[0]-3)break;Se.showCentroid(lt),Be++}if(lt&&BeBt[1]-3||(gt++,++Be===De.length))break;lt=Se.featuresOnBorder[De[Be]]}for(;tt=De.length){w.showCentroid(ft);continue}lt=Se.featuresOnBorder[De[tt]];let _t=!1;if(gt>=1){const Wt=lt.borders[$e];Math.abs(Bt[0]-Wt[0])<3&&Math.abs(Bt[1]-Wt[1])<3&&(gt=1,_t=!0,Be=tt+1)}else if(gt===0){w.showCentroid(ft);continue}const Tt=Se.centroidData[lt.centroidDataIndex];L&&_t&&z(Lt,Tt);const rr=ft.intersectsCount()>1||lt.intersectsCount()>1;if(gt>1)Be=tt,Lt.centroidXY=Tt.centroidXY=new a.P(0,0);else if(Ze&&Ze.dem&&!rr){const Wt=oe[ye](Lt,Tt),Kt=ye%2?a.an-1:0,Ot=xe(Wt[0],Math.min(a.an-1,Wt[1]),Kt,Ze,Me,ye<2,Wt[2]);Lt.centroidXY=Tt.centroidXY=H(Ot)}else rr?Lt.centroidXY=Tt.centroidXY=new a.P(0,0):(Lt.centroidXY=w.encodeBorderCentroid(ft),Tt.centroidXY=Se.encodeBorderCentroid(lt));w.writeCentroidToBuffer(Lt),Se.writeCentroidToBuffer(Tt)}else w.showCentroid(ft)}w.borderDoneWithNeighborZ[ye]=Se.canonical.z,Se.borderDoneWithNeighborZ[$e]=w.canonical.z}(w.needsCentroidUpdate||!w.centroidVertexBuffer&&w.centroidVertexArray.length!==0)&&w.uploadCentroid(_)}const iI=[1,0,0],aI=[0,1,0],CE=[0,0,1];function Eb(_,d,g){const w=g.transform,j=g.shadowRenderer;if(!j)return!0;const I=_.toUnwrapped(),L=w.tileSize*j._cascades[g.currentShadowCascade].scale;let F=d;if(w.elevation){const ce=w.elevation.getMinMaxForTile(_);ce&&(F+=ce.max)}const z=w.scaleZoom(L);F/=a.e2(w.center.lat,z);const H=[...j.shadowDirection];H[2]=-H[2];const Z=j.computeSimplifiedTileShadowVolume(I,F,L,H);if(!Z)return!1;const ne=[iI,aI,CE,H,[H[0],0,H[2]],[0,H[1],H[2]]],re=a.cl.fromInvProjectionMatrix(w.invProjMatrix,w.worldSize,z,w.projection.name!=="globe"),ie=j.getCurrentCascadeFrustum();return re.intersectsPrecise(Z.vertices,Z.planes,ne)===0||ie.intersectsPrecise(Z.vertices,Z.planes,ne)===0}function L0(_){const{painter:d,source:g,layer:w,coords:j}=_;let I=_.defines;const L=d.context,F=d.renderPass==="shadow",z=d.renderPass==="light-beam",H=d.shadowRenderer,Z=a.e2(d.transform.center.lat,d.transform.zoom),ne=Ba(d,w.paint.get("building-cutoff-fade-range"));ne.shouldRenderCutoff&&(I=I.concat("RENDER_CUTOFF"));const re=w.paint.get("building-front-cutoff"),ie=re[2]<1&&!d.terrain,ce=Tb(d.transform.pitch,re,!!d.terrain);ie&&(I=I.concat("RENDER_FRONT_CUTOFF"),d.maxFrontCutoffRawStart=Math.max(d.maxFrontCutoffRawStart,re[0])),_.floodLightIntensity>0&&(I=I.concat("FLOOD_LIGHT"));for(const oe of j){const xe=g.getTile(oe),ye=xe.getBucket(w);if(!ye)continue;H&&H.getMaxCascadeForTile(oe.toUnwrapped())===0&&(I=I.concat("SHADOWS_SINGLE_CASCADE"));const Pe=ye.programConfigurations.get(w.id);let Me,Se,Ze,$e=d.translatePosMatrix(oe.expandedProjMatrix,xe,[0,0],"map");if($e=a.cC(a.bb(),$e,[1,1,_.verticalScale]),F&&H){if(Eb(xe.tileID,ye.maxHeight*Z,d))continue;let De=H.calculateShadowPassMatrixFromTile(xe.tileID.toUnwrapped());De=a.cC(a.bb(),De,[1,1,_.verticalScale]),Ze=gb(De),Me=Se=d.getOrCreateProgram("buildingDepth",{config:Pe,defines:I,overrideFog:!1})}else if(z)Me=Se=d.getOrCreateProgram("buildingBloom",{config:Pe,defines:I,overrideFog:!1}),Ze=pb($e);else{const De=d.transform.calculatePosMatrix(oe.toUnwrapped(),d.transform.worldSize);a.cC(De,De,[1,1,_.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,at=1<{if(z){const Ge=De.entranceBloom;Be.draw(d,L.gl.TRIANGLES,_.depthMode,Jr.disabled,_.blendMode,Hr.disabled,Ze,w.id,Ge.layoutVertexBuffer,Ge.indexBuffer,Ge.segmentsBucket,w.paint,d.transform.zoom,Pe,[Ge.layoutAttenuationBuffer,Ge.layoutColorBuffer])}else{const Ge=De.segmentsBucket;let at=[De.layoutNormalBuffer,De.layoutCentroidBuffer,De.layoutColorBuffer,De.layoutFloodLightDataBuffer];De.layoutFacadePaintBuffer&&(at=at.concat([De.layoutFacadeDataBuffer,De.layoutFacadeVerticalRangeBuffer,De.layoutFacadePaintBuffer])),Be.draw(d,L.gl.TRIANGLES,_.depthMode,Jr.disabled,_.blendMode,F?Hr.disabled:Hr.backCW,Ze,w.id,De.layoutVertexBuffer,De.indexBuffer,Ge,w.paint,d.transform.zoom,Pe,at)}};d.uploadCommonUniforms(L,Se,oe.toUnwrapped(),null,ne),ye.buildingWithoutFacade&&Ke(ye.buildingWithoutFacade,Se),ye.buildingWithFacade&&(Me!==Se&&d.uploadCommonUniforms(L,Me,oe.toUnwrapped(),null,ne),Ke(ye.buildingWithFacade,Me))}}function IE(_,d,g,w,j,I,L,F,z,H,Z,ne,re,ie){const ce=_.context.gl,oe=_.depthModeForSublayer(1,Cr.ReadOnly,ce.LEQUAL,!0),xe=.1*(1-(ye=Z))+3*ye;var ye;const Pe=_._showOverdrawInspector,Me=ne,Se=new NE;Pe||Md(Se,_,d,g,w,oe,new Jr({func:ce.ALWAYS,mask:255},255,255,ce.KEEP,ce.KEEP,ce.REPLACE),new Yr([ce.ONE,ce.ONE,ce.ONE,ce.ONE],a.aq.transparent,[!1,!1,!1,!0],ce.MIN),Hr.disabled,j,"sdf",I,L,F,z,H,xe,Me,!1,void 0);{const Ze=Pe?Jr.disabled:new Jr({func:ce.EQUAL,mask:255},255,255,ce.KEEP,ce.DECR,ce.DECR),$e=Pe?_.colorModeForRenderPass():new Yr([ce.ONE_MINUS_DST_ALPHA,ce.DST_ALPHA,ce.ONE,ce.ONE],a.aq.transparent,[!0,!0,!0,!0]);Md(Se,_,d,g,w,oe,Ze,$e,Hr.disabled,j,"color",I,L,F,z,H,xe,Me,!1,void 0)}}function PE(_){return[_[0]*a.e7,_[1]*a.e7,_[2]*a.e7,0]}function jb(_,d,g,w,j,I,L,F,z){const H=w.getSource(),Z=g.globeSharedBuffers;if(!Z)return;let ne,re,ie;if(d&&(ne=w.getTile(d)),H instanceof a.aV?(re=H.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;_||(ie=a.cC(a.bb(),ie,[1,-1,1]));const ce=g.context,oe=ce.gl,xe=j.paint.get("raster-resampling")==="nearest"?oe.NEAREST:oe.LINEAR,ye=g.colorModeForDrapableLayerRenderPass(I),Pe=L.defines;Pe.push("GLOBE_POLES");const Me=new Cr(oe.LEQUAL,Cr.ReadWrite,g.depthRangeFor3D),Se=Float32Array.from(g.transform.expandedFarZProjMatrix),Ze=Float32Array.from(a.du(a.dv(new a.cn(0,0,0))));g.terrain&&g.terrain.prepareDrawTile(),ce.activeTexture.set(oe.TEXTURE0),re.bind(xe,oe.CLAMP_TO_EDGE),ce.activeTexture.set(oe.TEXTURE1),re.bind(xe,oe.CLAMP_TO_EDGE),"useMipmap"in re&&ce.extTextureFilterAnisotropic&&g.transform.pitch>20&&oe.texParameterf(oe.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 at;_?(at=$e,g.renderDefaultNorthPole=Ge!==0):(at=Ke,g.renderDefaultSouthPole=Ge!==0);const Qe=PE(L.mix),xt=((Lt,Bt,lt,tt,gt,_t,Tt,rr,Wt,Kt,Ot,Ar,Lr,gr)=>QC(Lt,Bt,lt,tt,new Float32Array(16),new Float32Array(9),[0,0],gt,[0,0],[0,0,0,0],1,{opacity:1,mix:0},Tt,[0,0],Wt,2,Ot,Ar,Lr,1,0,gr))(g,Se,Ze,ie,a.al(g.transform.zoom),0,j,0,Ge,0,Qe,L.offset,L.range,I),ft=g.getOrCreateProgram("raster",{defines:Pe});g.uploadCommonUniforms(ce,ft,null),ft.draw(g,oe.TRIANGLES,Me,z,ye,F,xt,j.id,at,De,Be)}function RE(_){if(_.isOrthographic)return[0,0,0,0];const d=_._nearZ,g=_.projection.farthestPixelDistance(_),w=g-d,j=.2*_.height,I=d+j;return[d,g,(I-j-d)/w,(I-d)/w]}function oI(_,d,g,w){if(_)return d instanceof Hm&&_ instanceof Wm?d.getTextureDescriptor(_,g,!0):{texture:_.texture,mix:PE(w.mix),offset:w.offset,buffer:0,tileSize:1}}var LE=a.e8([{name:"a_index",type:"Int16",components:1}]);class lI{constructor(d,g,w,j){const I={width:w[0],height:w[1],data:null},L=d.gl;this.targetColorTexture=new a.T(d,I,L.RGBA8,{useMipmap:!1}),this.backgroundColorTexture=new a.T(d,I,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 w=this.context.gl,j=g.width*g.height;this.particleTexture0=new a.T(this.context,g,w.RGBA8,{premultiply:!1,useMipmap:!1}),this.particleTexture1=new a.T(this.context,g,w.RGBA8,{premultiply:!1,useMipmap:!1});const I=new a.e9;I.reserve(j);for(let L=0;L0){const Qe=a.ec(g.canonical,z),xt=a.ed(Qe);re=a.aD(new Float32Array(16),z.globeMatrix,xt),a.aD(re,z.projMatrix,re)}const ie=a.bb();ie[12]+=2*j/(a.o.devicePixelRatio*z.width),ie[13]+=2*I/(a.o.devicePixelRatio*z.height),a.aD(re,ie,re);const ce=_.getOrCreateProgram("debug",{defines:ne}),oe=d.getTileByID(g.key);_.terrain&&_.terrain.setupElevationDraw(oe,ce);const xe=Cr.disabled,ye=Jr.disabled,Pe=_.colorModeForRenderPass(),Me="$debug";F.activeTexture.set(H.TEXTURE0),_.emptyTexture.bind(H.LINEAR,H.CLAMP_TO_EDGE),Z?oe._makeGlobeTileDebugBuffers(_.context,z):oe._makeDebugTileBoundsBuffers(_.context,z.projection);const Se=oe._tileDebugBuffer||_.debugBuffer,Ze=oe._tileDebugIndexBuffer||_.debugIndexBuffer,$e=oe._tileDebugSegments||_.debugSegments;if(ce.draw(_,H.LINE_STRIP,xe,ye,Pe,Hr.disabled,k0(re,w.toPremultipliedRenderColor(null)),Me,Se,Ze,$e,null,null,null,[oe._globeTileDebugBorderBuffer]),L){const Qe=oe.latestRawTileData,xt=Math.floor((Qe&&Qe.byteLength||0)/1024);let ft=g.canonical.toString();g.overscaledZ!==g.canonical.z&&(ft+=` => ${g.overscaledZ}`),ft+=` ${oe.state}`,ft+=` ${xt}kb`,function(Lt,Bt){Lt.initDebugOverlayCanvas();const lt=Lt.debugOverlayCanvas,tt=Lt.context.gl,gt=Lt.debugOverlayCanvas.getContext("2d");gt.clearRect(0,0,lt.width,lt.height),gt.shadowColor="white",gt.shadowBlur=2,gt.lineWidth=1.5,gt.strokeStyle="white",gt.textBaseline="top",gt.font="bold 36px Open Sans, sans-serif",gt.fillText(Bt,5,5),gt.strokeText(Bt,5,5),Lt.debugOverlayTexture.update(lt),Lt.debugOverlayTexture.bind(tt.LINEAR,tt.CLAMP_TO_EDGE)}(_,ft)}const Ke=d.getTile(g).tileSize,De=512/Math.min(Ke,512)*(g.overscaledZ/z.zoom)*.5,Be=oe._tileDebugTextBuffer||_.debugBuffer,Ge=oe._tileDebugTextIndexBuffer||_.quadTriangleIndexBuffer,at=oe._tileDebugTextSegments||_.debugSegments;ce.draw(_,H.TRIANGLES,xe,ye,Yr.alphaBlended,Hr.disabled,k0(re,a.aq.transparent.toPremultipliedRenderColor(null),De),Me,Be,Ge,at,null,null,null,[oe._globeTileDebugTextBuffer])}function uI(_,d,g,w){Ab(_,0,d+g/2,_.transform.width,g,w)}function BE(_,d,g,w){Ab(_,d-g/2,0,g,_.transform.height,w)}function Ab(_,d,g,w,j,I){const L=_.context,F=L.gl;F.enable(F.SCISSOR_TEST),F.scissor(d*a.o.devicePixelRatio,g*a.o.devicePixelRatio,w*a.o.devicePixelRatio,j*a.o.devicePixelRatio),L.clear({color:I}),F.disable(F.SCISSOR_TEST)}const n5=a.e8([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:fc}=n5;function Dd(_,d,g,w){_.emplaceBack(d,g,w)}class rl{constructor(d){this.vertexArray=new a.ee,this.indices=new a.dC,Dd(this.vertexArray,-1,-1,1),Dd(this.vertexArray,1,-1,1),Dd(this.vertexArray,-1,1,1),Dd(this.vertexArray,1,1,1),Dd(this.vertexArray,-1,-1,-1),Dd(this.vertexArray,1,-1,-1),Dd(this.vertexArray,-1,1,-1),Dd(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,fc),this.indexBuffer=d.createIndexBuffer(this.indices),this.segment=a.dy.simpleSegment(0,0,36,12)}}function Pc(_,d,g,w,j,I){const L=_.context.gl,F=d.paint.get("sky-atmosphere-color"),z=d.paint.get("sky-atmosphere-halo-color"),H=d.paint.get("sky-atmosphere-sun-intensity"),Z=((ne,re,ie,ce,oe)=>({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:[oe.r,oe.g,oe.b,oe.a],u_luminance:5e-5}))(a.eg(a.dE(),w),j,H,F.toPremultipliedRenderColor(null),z.toPremultipliedRenderColor(null));L.framebufferTexture2D(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_CUBE_MAP_POSITIVE_X+I,d.skyboxTexture,0),g.draw(_,L.TRIANGLES,Cr.disabled,Jr.disabled,Yr.unblended,Hr.frontCW,Z,"skyboxCapture",d.skyboxGeometry.vertexBuffer,d.skyboxGeometry.indexBuffer,d.skyboxGeometry.segment)}const dI=a.e8([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2}]);class $E{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 w=new a.dC;w.emplaceBack(0,1,2),w.emplaceBack(2,3,0),this.vertexBuffer=d.createVertexBuffer(g,dI.members),this.indexBuffer=d.createIndexBuffer(w),this.segments=a.dy.simpleSegment(0,0,4,2)}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy()}}const zE=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 UE{constructor(){this.starsCount=16e3,this.sizeMultiplier=.15,this.sizeRange=100,this.intensityRange=200}}class hI{constructor(d){this.colorModeAlphaBlendedWriteRGB=new Yr([1,Pi,1,Pi],a.aq.transparent,[!0,!0,!0,!1]),this.colorModeWriteAlpha=new Yr([1,0,1,0],a.aq.transparent,[!1,!1,!1,!0]),this.params=new UE,this.updateNeeded=!0}update(d){const g=d.context;if(!this.atmosphereBuffer||this.updateNeeded){this.updateNeeded=!1,this.atmosphereBuffer=new $E(g);const w=this.params.sizeRange,j=this.params.intensityRange,I=function(Z){const ne=a.em(30),re=[];for(let ie=0;ie{const De=I.projection.name==="globe"?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"];Ke&&De.push("ALPHA_PASS");const Be=d.getOrCreateProgram("globeAtmosphere",{defines:De}),Ge=((Qe,xt,ft,Lt,Bt,lt,tt,gt,_t,Tt,rr,Wt)=>({u_frustum_tl:Qe,u_frustum_tr:xt,u_frustum_br:ft,u_frustum_bl:Lt,u_horizon:Bt,u_transition:lt,u_fadeout_range:tt,u_atmosphere_fog_color:gt.toArray01(),u_high_color:_t.toArray01(),u_space_color:Tt.toArray01(),u_temporal_offset:rr,u_horizon_angle:Wt}))(I.frustumCorners.TL,I.frustumCorners.TR,I.frustumCorners.BR,I.frustumCorners.BL,I.frustumCorners.horizon,F,xe,Z,re,ce,Pe,Ze);d.uploadCommonUniforms(w,Be);const at=this.atmosphereBuffer;at&&Be.draw(d,j.TRIANGLES,L,Jr.disabled,Ke?this.colorModeWriteAlpha:this.colorModeAlphaBlendedWriteRGB,Hr.backCW,Ge,Ke?"atmosphere_glow_alpha":"atmosphere_glow",at.vertexBuffer,at.indexBuffer,at.segments)};$e(!1),$e(!0)}drawStars(d,g){const w=a.aC(g.properties.get("star-intensity"),0,1);if(w===0)return;const j=d.context,I=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 H=a.bR(new Float32Array(16),z),Z=a.aD([],L.starsProjMatrix,H),ne=a.eg([],H),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 oe=(xe=ie,ye=ce,Pe=w,{u_matrix:Float32Array.from(Z),u_up:xe,u_right:ye,u_intensity_multiplier:Pe});var xe,ye,Pe;d.uploadCommonUniforms(j,F),this.starsVx&&this.starsIdx&&F.draw(d,I.TRIANGLES,Cr.disabled,Jr.disabled,this.colorModeAlphaBlendedWriteRGB,Hr.disabled,oe,"atmosphere_stars",this.starsVx,this.starsIdx,this.starsSegments)}}class kh{constructor(){this.visibleTiles=[]}updateBorders(d,g){const w=[],j=[],I=d._getRenderableCoordinates(!1,!0);for(const z of I){const H=d.getTile(z);if(!H.hasData())continue;const Z=H.getBucket(g);Z&&(Z.isEmpty()||(w.push(z.key),j.push({bucket:Z,tileID:z.canonical})))}let L=w.length!==this.visibleTiles.length;if(!L){w.sort();for(let z=0;zz.tileID.z-H.tileID.z||z.tileID.x-H.tileID.x||z.tileID.y-H.tileID.y);for(const z of j){const H=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),H.push(re.footprintIndex));ne.updateFootprintHiddenFlags(H,a.en,!1),ne.updateFootprintHiddenFlags(Z,a.en,!0)}}}function fI(_,d){const g=[..._],w=d.cameraWorldSizeForFog/d.worldSize,j=a.b9([]);return a.cC(j,j,[w,w,1]),a.aD(g,j,g),a.aD(g,d.worldToFogMatrix,g),g}function as(_,d,g,w,j){const I=g.material,L=w.context,{baseColorTexture:F,metallicRoughnessTexture:z}=I.pbrMetallicRoughness,{normalTexture:H,occlusionTexture:Z,emissionTexture:ne}=I;function re(ce,oe,xe){if(ce&&(_.push(oe),L.activeTexture.set(L.gl.TEXTURE0+xe),ce.gfxTexture)){const{minFilter:ye,magFilter:Pe,wrapS:Me,wrapT:Se}=ce.sampler;ce.gfxTexture.bindExtraParam(ye,Pe,Me,Se)}}re(F,"HAS_TEXTURE_u_baseColorTexture",5),re(z,"HAS_TEXTURE_u_metallicRoughnessTexture",6),re(H,"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(w.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),_.push("APPLY_LUT_ON_GPU")),g.texcoordBuffer&&(_.push("HAS_ATTRIBUTE_a_uv_2f"),d.push(g.texcoordBuffer)),g.colorBuffer&&(_.push(g.colorBuffer.itemSize===12?"HAS_ATTRIBUTE_a_color_3f":"HAS_ATTRIBUTE_a_color_4f"),d.push(g.colorBuffer)),g.normalBuffer&&(_.push("HAS_ATTRIBUTE_a_normal_3f"),d.push(g.normalBuffer)),g.pbrBuffer&&(_.push("HAS_ATTRIBUTE_a_pbr"),_.push("HAS_ATTRIBUTE_a_heightBasedEmissiveStrength"),d.push(g.pbrBuffer)),I.alphaMode!=="OPAQUE"&&I.alphaMode!=="MASK"||_.push("UNPREMULT_TEXTURE_IN_SHADER"),I.defined||_.push("DIFFUSE_SHADED");const ie=w.shadowRenderer;ie&&(_.push("RENDER_SHADOWS"),ie.useNormalOffset&&_.push("NORMAL_OFFSET"))}function Yg(_,d,g,w,j,I){const L=_.modelOpacity,F=d.context,z=new Cr(d.context.gl.LEQUAL,_.isLightMesh?Cr.ReadOnly:Cr.ReadWrite,d.depthRangeFor3D),H=d.transform,Z=_.mesh,ne=Z.material,re=ne.pbrMetallicRoughness,ie=d.style.fog;let ce;ce=d.transform.projection.zAxisUnit==="pixels"?[..._.nodeModelMatrix]:a.aD([],w.zScaleMatrix,_.nodeModelMatrix),a.aD(ce,w.negCameraPosMatrix,ce);const oe=a.b7([],ce);a.e6(oe,oe);const xe=g.paint.get("model-color-use-theme").constantOr("default")==="none",ye=g.paint.get("model-emissive-strength").constantOr(0),Pe=sp(new Float32Array(_.worldViewProjection),new Float32Array(ce),new Float32Array(oe),null,d,L,re.baseColorFactor,ne.emissiveFactor,re.metallicFactor,re.roughnessFactor,ne,ye,g,void 0,void 0,_.materialOverride,_.modelColor),Me={defines:[]},Se=[],Ze=d.shadowRenderer;Ze&&(Ze.useNormalOffset=!1),as(Me.defines,Se,Z,d,xe?null:g.lut);let $e=null;if(ie){const Be=fI(_.nodeModelMatrix,d.transform);if($e=new Float32Array(Be),H.projection.name!=="globe"){const Ge=Z.aabb.min,at=Z.aabb.max,[Qe,xt]=ie.getOpacityForBounds(Be,Ge[0],Ge[1],at[0],at[1]);Me.overrideFog=Qe>=Ln||xt>=Ln}}const Ke=Ba(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"&&Ze&&Ze.setupShadowsFromMatrix(_.nodeModelMatrix,De),De.draw(d,F.gl.TRIANGLES,z,j,I,Z.material.doubleSided?Hr.disabled:Hr.backCCW,Pe,g.id,Z.vertexBuffer,Z.indexBuffer,Z.segments,g.paint,d.transform.zoom,void 0,Se)}function kb(_,d){return _.style._importedAsBasemap?"basemap":d.scope}function Nb(_,d,g,w,j,I,L,F,z,H){const Z=_.transform,ne=!!d.isGeometryBloom&&d.isGeometryBloom;if(ne&&_.renderPass==="shadow")return;const re=Z.projection.name==="globe"?a.ev(g,Z):[...g];a.aD(re,re,d.globalMatrix);const ie=a.aD([],w,re);if(d.meshes)for(const ce of d.meshes){const oe=F.get(ce.material.name);if(oe&&oe.opacity<=0)continue;if(ce.material.alphaMode!=="BLEND"){L.push({mesh:ce,depth:0,modelIndex:j,worldViewProjection:ie,nodeModelMatrix:re,isLightMesh:ne,materialOverride:oe,modelOpacity:z,modelColor:H,node:d,modelMatrix:g});continue}const xe=a.ah([],ce.centroid,ie);!Z.isOrthographic&&xe[2]<=0||I.push({mesh:ce,depth:xe[2],modelIndex:j,worldViewProjection:ie,nodeModelMatrix:re,isLightMesh:ne,materialOverride:oe,modelOpacity:z,modelColor:H,node:d,modelMatrix:g})}if(d.children)for(const ce of d.children)Nb(_,ce,g,w,j,I,L,F,z,H)}function Zg(_,d,g,w){const j=g.shadowRenderer;if(!j)return;const I=j.getShadowPassDepthMode(),L=j.calculateShadowPassMatrixFromMatrix(d),F=jE(L);g.getOrCreateProgram("modelDepth").draw(g,g.context.gl.TRIANGLES,I,Jr.disabled,Yr.disabled,Hr.disabled,F,w.id,_.vertexBuffer,_.indexBuffer,_.segments,w.paint,g.transform.zoom,void 0,void 0)}function VE(_,d,g,w){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,oe=new a.dB;oe.reserve(ie.length);for(const Ge of ie)oe.emplaceBack(Ge.x,Ge.y);const xe=new a.dC;xe.reserve(ce.length);for(let Ge=0;Ge0){const re=I.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;ceH&&(H=ie.max)}const Z=a.aC(w.x,I,L)-w.x,ne=a.aC(w.y,F,z)-w.y,re=a.bU(H,d.center.lat)-w.z;return d._zoomFromMercatorZ(Math.sqrt(Z*Z+ne*ne+re*re))}function ri(_,d,g,w,j,I,L){const F=_.context,z=_.renderPass==="shadow",H=_.shadowRenderer,Z=z&&H?H.getShadowPassDepthMode():new Cr(F.gl.LEQUAL,Cr.ReadWrite,_.depthRangeFor3D),ne=_.isTileAffectedByFog(I),re=_.transform.projection.name==="globe";if(g.meshes)for(const ie of g.meshes){const ce=re?[]:["MODEL_POSITION_ON_GPU"],oe=[];let xe,ye,Pe;const Me=!re&&w.instancedDataArray.length>20;Me&&ce.push("INSTANCED_ARRAYS");const Se=Ba(_,d.paint.get("model-cutoff-fade-range"));if(Se.shouldRenderCutoff&&ce.push("RENDER_CUTOFF"),z&&H)xe=_.getOrCreateProgram("modelDepth",{defines:ce}),ye=jE(L.shadowTileMatrix,L.shadowTileMatrix,Float32Array.from(g.globalMatrix)),Pe=Yr.disabled;else{as(ce,oe,ie,_,d.paint.get("model-color-use-theme").constantOr("default")==="none"?null:d.lut),xe=_.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);ye=sp(I.expandedProjMatrix,Float32Array.from(g.globalMatrix),new Float32Array(16),null,_,De,Ke.baseColorFactor,$e.emissiveFactor,Ke.metallicFactor,Ke.roughnessFactor,$e,Be,d,j),H&&(L.shadowUniformsInitialized?xe.setShadowUniformValues(F,H.getShadowUniformValues()):(H.setupShadows(I.toUnwrapped(),xe,"model-tile"),L.shadowUniformsInitialized=!0)),Pe=Se.shouldRenderCutoff||De<1||$e.alphaMode!=="OPAQUE"?Yr.alphaBlended:Yr.unblended}_.uploadCommonUniforms(F,xe,I.toUnwrapped(),null,Se);const Ze=ie.material.doubleSided?Hr.disabled:Hr.backCCW;if(Me)oe.push(w.instancedDataBuffer),xe.draw(_,F.gl.TRIANGLES,Z,Jr.disabled,Pe,Ze,ye,d.id,ie.vertexBuffer,ie.indexBuffer,ie.segments,d.paint,_.transform.zoom,void 0,oe,w.instancedDataArray.length);else{const $e=z?"u_instance":"u_normal_matrix";for(let Ke=0;Kez[1]?L:z,I[0]=g.max[0],L=a.aE(a.bE(),I,j),F=L[1]z[1]?L:z,I[1]=g.min[1],L=a.aE(a.bE(),I,j),F=L[1]z[1]?L:z;const H=a.aC(w[0],0,1),Z=100*d.pixelsPerMeter*a.aC(w[1],0,1),ne=a.aC(w[2],0,1),re=a.ey(a.bE(),F,z,H),ie=Math.tan(.5*d.fovX),ce=-re[2]*ie;if(Z===0)return re[1]<-Math.abs(ce)?ne:1;const oe=(-Math.abs(ce)-re[1])/Z,xe=(Pe,Me,Se)=>(1-Se)*Pe+Se*Me,ye=a.aC(xe(1,ne,oe),ne,1);return xe(1,ye,a.aC((d.pitch-20)/20,0,1))}class Ib{}class pI{constructor(){this._storage=new Map}getLinesFromTrianglesBuffer(d,g,w){{const ne=this._storage.get(g.id);if(ne)return ne.lastUsedFrameIdx=d,ne.buf}const j=w.gl,I=j.getBufferParameter(j.ELEMENT_ARRAY_BUFFER,j.BUFFER_SIZE),L=new ArrayBuffer(I),F=new Int16Array(L);j.getBufferSubData(j.ELEMENT_ARRAY_BUFFER,0,new Int16Array(L));const z=new a.eA;for(let ne=0;ne30&&(w.buf.destroy(),this._storage.delete(g))}destroy(){for(const[d,g]of this._storage)g.buf.destroy(),this._storage.delete(d)}}class gI{constructor(){this.occluderSize=30,this.depthOffset=-1e-4}}const Qg=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 yI{constructor(d){this.revealStart=11,this.revealRange=2}}const s5=a.e8([{type:"Float32",name:"a_pos_2f",components:2}]);class xI{destroy(){this.vignetteVx&&this.vignetteVx.destroy(),this.vignetteIdx&&this.vignetteIdx.destroy()}draw(d,g){const w=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,s5.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,w);const L={u_vignetteShape:(I={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:I.vignetteColor};w.draw(d,d.context.gl.TRIANGLES,Cr.disabled,Jr.disabled,Yr.alphaBlended,Hr.disabled,L,"vignette",this.vignetteVx,this.vignetteIdx,j)}var I}}class Pb{constructor(){this._accumulatedOffsetX=0,this._accumulatedOffsetY=0,this._accumulatedElevation=0}update(d,g){const w=d.getFreeCameraOptions().position,j=w.toAltitude(),I=w.toLngLat(),L=a.ap(I.lng),F=a.ap(I.lat),z=d.pixelsPerMeter/g,H=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+H)*z,this._accumulatedOffsetY+=ne*z,this._accumulatedElevation+=re*z,this._offsetXPrev=H,this._offsetYPrev=Z,this._elevationPrev=j}}getPosition(){return[this._accumulatedOffsetX,this._accumulatedOffsetY,this._accumulatedElevation]}}function Rb(_,d){return[-(_[0]-Math.floor(_[0]/d)*d),-(_[1]-Math.floor(_[1]/d)*d),-(_[2]-Math.floor(_[2]/d)*d)]}function HE(_){const d=a.em(1323123451230),g=[];for(let w=0;w<_;++w){const j=2*d()-1,I=2*d()-1,L=2*d()-1;g.push(a.cQ(j,I,L))}return g}function Ch(_,d,g,w,j){const I=a.aC((j-g)/(w-g),0,1);return(1-I)*_+I*d}class M0{constructor(d){this._movement=new Pb,this._accumulatedTimeFromStart=0,this._prevTime=Date.now()/1e3,this._vignette=new xI,this._ppmScaleFactor=d}destroy(){this.particlesVx&&this.particlesVx.destroy(),this.particlesIdx&&this.particlesIdx.destroy(),this._vignette&&this._vignette.destroy()}updateOnRender(d,g){const w=d.transform;this._movement.update(w,this._ppmScaleFactor);const j=w.starsProjMatrix,I=a.bL([]);a.bN(I,I,a.ap(90)-w._pitch),a.bM(I,I,-w.angle);const L=a.bR(new Float32Array(16),I),F=a.eC(1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1),z=a.e6([],F),H=a.aD([],z,L),Z=Date.now()/1e3;return this._accumulatedTimeFromStart+=(Z-this._prevTime)*g,this._prevTime=Z,{projectionMatrix:j,modelviewMatrix:H}}}class D0 extends M0{constructor(d){super(4.25),this._params={overrideStyleParameters:!1,intensity:.5,timeFactor:1,velocityConeAperture:0,velocity:300,boxSize:2500,dropletSizeX:1,dropletSizeYScale:10,distortionStrength:70,screenThinning:{intensity:.57,start:.46,range:1.17,fadePower:.17,affectedRatio:1,particleOffset:-.2},color:{r:.66,g:.68,b:.74,a:.7},direction:{x:-50,y:-35},shapeDirPower:2,shapeNormalPower:1},this._revealParams=new yI("Precipitation > 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 w=HE(this.particlesCount),j=new a.eE,I=new a.dC;let L=0;const F=a.em(1323123451230);for(let z=0;zw)return;const j=Ch(0,1,g.revealStart,g.revealStart+g.revealRange,w);if(!this.particlesVx||!this.particlesIdx)return;const I=structuredClone(this._params);let L=[-I.direction.x,I.direction.y,-100];a.ay(L,L);const F=structuredClone(this._vignetteParams);F.strength*=j,I.overrideStyleParameters||(I.intensity=d.style.rain.state.density,I.timeFactor=d.style.rain.state.intensity,I.color=structuredClone(d.style.rain.state.color),L=structuredClone(d.style.rain.state.direction),I.screenThinning.intensity=d.style.rain.state.centerThinning,I.dropletSizeX=d.style.rain.state.dropletSize[0],I.dropletSizeYScale=d.style.rain.state.dropletSize[1]/d.style.rain.state.dropletSize[0],I.distortionStrength=100*d.style.rain.state.distortionStrength,F.strength=1,F.color=structuredClone(d.style.rain.state.vignetteColor));const z=this.updateOnRender(d,I.timeFactor),H=d.context,Z=H.gl,ne=d.transform;this.screenTexture&&this.screenTexture.size[0]===d.width&&this.screenTexture.size[1]===d.height||(this.screenTexture=new a.T(H,{width:d.width,height:d.height,data:null},Z.RGBA8)),I.distortionStrength>0&&(H.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(H,re),H.activeTexture.set(Z.TEXTURE0),this.screenTexture.bind(Z.LINEAR,Z.CLAMP_TO_EDGE);const ie=[I.color.r,I.color.g,I.color.b,I.color.a],ce=(oe,xe)=>{const ye=Rb(this._movement.getPosition(),oe),Pe=I.dropletSizeX,Me=I.dropletSizeX*I.dropletSizeYScale,Se=d.width/2,Ze=d.height/2,$e=Ch(0,I.screenThinning.start,0,1,I.screenThinning.intensity),Ke=Ch(.001,I.screenThinning.range,0,1,I.screenThinning.intensity),De=Ch(0,I.screenThinning.particleOffset,0,1,I.screenThinning.intensity),Be=(Ge={modelview:z.modelviewMatrix,projection:z.projectionMatrix,time:this._accumulatedTimeFromStart,camPos:ye,velocityConeAperture:I.velocityConeAperture,velocity:I.velocity,boxSize:oe,rainDropletSize:[Pe,Me],distortionStrength:I.distortionStrength,rainDirection:L,color:ie,screenSize:[ne.width,ne.height],thinningCenterPos:[Se,Ze],thinningShape:[$e,Ke,Math.pow(10,I.screenThinning.fadePower)],thinningAffectedRatio:I.screenThinning.affectedRatio,thinningParticleOffset:De,shapeDirectionalPower:I.shapeDirPower,shapeNormalPower:I.shapeNormalPower,mode:xe?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 at=Math.round(I.intensity*this.particlesCount),Qe=a.dy.simpleSegment(0,0,4*at,2*at);re.draw(d,Z.TRIANGLES,Cr.disabled,Jr.disabled,Yr.alphaBlended,Hr.disabled,Be,"rain_particles",this.particlesVx,this.particlesIdx,Qe)};I.distortionStrength>0&&ce(I.boxSize,!0),ce(I.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 vI extends M0{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 yI("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 w=HE(this.particlesCount),j=new a.eF,I=new a.dC;let L=0;const F=a.em(1323123451230);for(let z=0;zL)return;const F=Ch(0,1,I.revealStart,I.revealStart+I.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),w=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 H=d.context,Z=H.gl,ne=d.transform,re=d.getOrCreateProgram("snowParticle");d.uploadCommonUniforms(H,re),((ie,ce,oe)=>{const xe=Rb(this._movement.getPosition(),ie),ye=ne.width/2,Pe=ne.height/2,Me=Ch(0,oe.screenThinning.start,0,1,oe.screenThinning.intensity),Se=Ch(.001,oe.screenThinning.range,0,1,oe.screenThinning.intensity),Ze=Ch(0,oe.screenThinning.particleOffset,0,1,oe.screenThinning.intensity),$e=(Ke={modelview:z.modelviewMatrix,projection:z.projectionMatrix,time:this._accumulatedTimeFromStart,camPos:xe,velocityConeAperture:oe.velocityConeAperture,velocity:oe.velocity,horizontalOscillationRadius:oe.horizontalOscillationRadius,horizontalOscillationRate:oe.horizontalOscillationRate,boxSize:ie,billboardSize:1*oe.billboardSize,simpleShapeParameters:[oe.shapeFadeStart,oe.shapeFadePower],screenSize:[ne.width,ne.height],thinningCenterPos:[ye,Pe],thinningShape:[Me,Se,Math.pow(10,oe.screenThinning.fadePower)],thinningAffectedRatio:oe.screenThinning.affectedRatio,thinningParticleOffset:Ze,color:[oe.color.r,oe.color.g,oe.color.b,oe.color.a],direction:w},{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(oe.intensity*this.particlesCount),Be=a.dy.simpleSegment(0,0,4*De,2*De);this.particlesVx&&this.particlesIdx&&re.draw(d,Z.TRIANGLES,Cr.disabled,Jr.disabled,Yr.alphaBlended,Hr.disabled,$e,"snow_particles",this.particlesVx,this.particlesIdx,Be)})(g.boxSize,0,g),this._vignette.draw(d,j)}}const _I={symbol:function(_,d,g,w,j){if(_.renderPass!=="translucent")return;const I=Jr.disabled,L=_.colorModeForRenderPass(),F=g.layout.get("text-variable-anchor"),z=g.layout.get("text-size-scale-range"),H=a.aC(_.scaleFactor,z[0],z[1]);F&&function(re,ie,ce,oe,xe,ye,Pe,Me){const Se=ie.transform,Ze=xe==="map",$e=ye==="map";for(const Ke of re){const De=oe.getTile(Ke),Be=De.getBucket(ce);if(!Be||!Be.text||!Be.text.segments.get().length)continue;const Ge=a.bj(Be.textSizeData,Se.zoom,Me),at=Km(Ke,Be.getProjection(),Se),Qe=Se.calculatePixelsToTileUnitsMatrix(De),xt=kf(at,De.tileID.canonical,$e,Ze,Se,Be.getProjection(),Qe),ft=Be.hasIconTextFit()&&Be.hasIconData();Ge&&nI(Be,Ze,$e,Pe,Se,xt,Ke,Math.pow(2,Se.zoom-De.tileID.overscaledZ),Ge,ft)}}(w,_,g,d,g.layout.get("text-rotation-alignment"),g.layout.get("text-pitch-alignment"),j,H);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)?bb(_,d,g,w,I,L):(Z&&bb(_,d,g,w,I,L,{onlyIcons:!0}),ne&&bb(_,d,g,w,I,L,{onlyText:!0})),d.map.showCollisionBoxes&&(_r(_,d,g,w,g.paint.get("text-translate"),g.paint.get("text-translate-anchor"),!0),_r(_,d,g,w,g.paint.get("icon-translate"),g.paint.get("icon-translate-anchor"),!1))},circle:function(_,d,g,w){if(_.renderPass!=="translucent")return;const j=g.paint.get("circle-opacity"),I=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&&(I.constantOr(1)===0||L.constantOr(1)===0))return;const H=_.context,Z=H.gl,ne=_.transform,re=!(!_.terrain||!_.terrain.enabled),ie=g.layout.get("circle-elevation-reference"),ce=_.depthModeForSublayer(0,Cr.ReadOnly),oe=new Cr(_.context.gl.LEQUAL,Cr.ReadOnly,_.depthRangeFor3D),xe=ie==="none"||re?ce:oe,ye=Jr.disabled,Pe=_.colorModeForDrapableLayerRenderPass(z),Me=ne.projection.name==="globe",Se=[a.aH(ne.center.lng),a.aL(ne.center.lat)],Ze=[];for(let Ke=0;KeKe.sortKey-De.sortKey);const $e={useDepthForOcclusion:ne.depthOcclusionForSymbolsAndCircles};for(const Ke of Ze){const{programConfiguration:De,program:Be,layoutVertexBuffer:Ge,dynamicBuffers:at,indexBuffer:Qe,uniformValues:xt,tile:ft}=Ke.state,Lt=Ke.segments;_.terrain&&_.terrain.setupElevationDraw(ft,Be,$e),_.uploadCommonUniforms(H,Be,ft.tileID.toUnwrapped()),Be.draw(_,Z.TRIANGLES,xe,ye,Pe,Hr.disabled,xt,g.id,Ge,Qe,Lt,g.paint,ne.zoom,De,at)}},heatmap:function(_,d,g,w){if(g.paint.get("heatmap-opacity")!==0)if(_.renderPass==="offscreen"){const j=_.context,I=j.gl,L=Jr.disabled,F=new Yr([I.ONE,I.ONE,I.ONE,I.ONE],a.aq.transparent,[!0,!0,!0,!0]),z=_.transform.projection.name==="globe"?.5:.25;g.heatmapFbo=C0.createWithTexture(j,g.heatmapFbo,_.width*z,_.height*z),j.clear({color:a.aq.transparent});const H=_.transform,Z=H.projection.name==="globe",ne=Z?["PROJECTION_GLOBE_VIEW"]:[],re=Z?Hr.frontCCW:Hr.disabled,ie=[a.aH(H.center.lng),a.aL(H.center.lat)];for(let ce=0;ce({u_image:0,u_color_ramp:1,u_opacity:ne.paint.get("heatmap-opacity")}))(0,I),I.id,j.viewportBuffer,j.quadTriangleIndexBuffer,j.viewportSegments,I.paint,j.transform.zoom)}(_,g))},line:function(_,d,g,w){const j=g.paint.get("line-opacity"),I=g.paint.get("line-width");if(j.constantOr(1)===0||I.constantOr(1)===0)return;const L=g.paint.get("line-blend-mode");if(L!=="default"&&_.transform.projection.name!=="globe")return _.terrain&&_.terrain.renderingToTexture?void function(F,z,H,Z,ne){if(F.renderPass!=="translucent")return;const re=F.context,ie=re.gl,ce=F.terrain;if(!ce)return;const oe=re.bindFramebuffer.current,xe=F.emissiveMode==="mrt-fallback";H.lineBlendDrapeFbo=C0.createWithTexture(re,H.lineBlendDrapeFbo,ce.drapeBufferSize[0],ce.drapeBufferSize[1],!0),H.lineBlendDrapeStencil=H.lineBlendDrapeFbo._stencilRbo,xe&&ie.drawBuffers([ie.COLOR_ATTACHMENT0]),re.clear({color:Ah[ne].clearColor,depth:1,stencil:0});const ye=F.currentStencilSource,Pe=F._tileClippingMaskIDs,Me=F.nextStencilID;F.currentStencilSource=void 0,F._tileClippingMaskIDs={},F.nextStencilID=1;const Se=F._terrain;F._terrain=null,F._renderTileClippingMasks(H,z,Z),Sb(F,z,H,Z,Ah[ne].colorMode,!0),F._terrain=Se,F.currentStencilSource=ye,F._tileClippingMaskIDs=Pe,F.nextStencilID=Me,re.bindFramebuffer.set(oe),xe&&ie.drawBuffers([ie.COLOR_ATTACHMENT0,ie.COLOR_ATTACHMENT1]);const Ze=ce.drapeBufferSize;re.viewport.set([0,0,Ze[0],Ze[1]]);const $e=H.lineBlendDrapeFbo;if(!$e)return;re.activeTexture.set(ie.TEXTURE0),ie.bindTexture(ie.TEXTURE_2D,$e.colorAttachment0.get());const Ke=ne==="additive"?1:H.paint.get("line-opacity").constantOr(1),De=H.paint.get("line-emissive-strength").constantOr(0),Be=ne==="additive"?F.colorModeForDrapableLayerRenderPass(De):Ah[ne].colorMode;F.getOrCreateProgram("lineBlendComposite").draw(F,ie.TRIANGLES,Cr.disabled,Jr.disabled,Be,Hr.disabled,mb(0,Ke,Ah[ne].compositeUniformValue),H.id,F.viewportBuffer,F.quadTriangleIndexBuffer,F.viewportSegments,H.paint,F.transform.zoom)}(_,d,g,w,L):_.renderPass==="offscreen"?void function(F,z,H,Z,ne){const re=F.context,ie=Math.ceil(F.width),ce=Math.ceil(F.height);H.lineBlendFbo=C0.createWithTexture(re,H.lineBlendFbo,ie,ce,!0),H.lineBlendStencil=H.lineBlendFbo._stencilRbo,re.clear({color:Ah[ne].clearColor,depth:1,stencil:0});const oe=F.currentStencilSource,xe=F._tileClippingMaskIDs,ye=F.nextStencilID;F.currentStencilSource=void 0,F._tileClippingMaskIDs={},F.nextStencilID=1,F._renderTileClippingMasks(H,z,Z);const Pe=F.renderPass;F.renderPass="translucent",Sb(F,z,H,Z,Ah[ne].colorMode),F.renderPass=Pe,F.currentStencilSource=oe,F._tileClippingMaskIDs=xe,F.nextStencilID=ye,re.viewport.set([0,0,F.width,F.height])}(_,d,g,w,L):_.renderPass==="translucent"?void function(F,z,H){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=H==="additive"?1:z.paint.get("line-opacity").constantOr(1),ce=H==="additive"?F.colorModeForDrapableLayerRenderPass(z.paint.get("line-emissive-strength").constantOr(0)):Ah[H].colorMode;F.getOrCreateProgram("lineBlendComposite").draw(F,ne.TRIANGLES,Cr.disabled,Jr.disabled,ce,Hr.disabled,mb(0,ie,Ah[H].compositeUniformValue),z.id,F.viewportBuffer,F.quadTriangleIndexBuffer,F.viewportSegments,z.paint,F.transform.zoom)}(_,g,L):void 0;_.renderPass==="translucent"&&Sb(_,d,g,w)},fill:function(_,d,g,w){const j=g.paint.get("fill-color"),I=g.paint.get("fill-opacity");if(I.constantOr(1)===0)return;const L=g.paint.get("fill-emissive-strength"),F=_.colorModeForDrapableLayerRenderPass(L),z=g.paint.get("fill-pattern"),H=_.opaquePassEnabledForLayer()&&!z.constantOr(1)&&j.constantOr(a.aq.transparent).a===1&&I.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=!(!_.terrain||!_.terrain.enabled),re={painter:_,sourceCache:d,layer:g,coords:w,colorMode:F,elevationType:Z,terrainEnabled:ne,pass:H};if(_.renderPass==="shadow")return void(_.shadowRenderer&&Z==="road"&&!ne&&function(ce){const{painter:oe,sourceCache:xe,layer:ye,coords:Pe}=ce,Me=oe.context.gl,Se=ce.painter.shadowRenderer;for(const Ze of Pe){const $e=xe.getTile(Ze),Ke=$e.getBucket(ye);if(!Ke)continue;const De=Ke.elevatedStructures;if(!De||!De.shadowCasterSegments||De.shadowCasterSegments.segments[0].primitiveLength===0)continue;oe.prepareDrawTile();const Be=Ke.bufferData.programConfigurations.get(ye.id),Ge=oe.isTileAffectedByFog(Ze),at=oe.getOrCreateProgram("elevatedStructuresDepth",{config:Be,overrideFog:Ge}),Qe=Se.calculateShadowPassMatrixFromTile($e.tileID.toUnwrapped());oe.uploadCommonUniforms(oe.context,at,Ze.toUnwrapped());const xt=KC(Qe,0);at.draw(oe,Me.TRIANGLES,Se.getShadowPassDepthMode(),Jr.disabled,Yr.disabled,Hr.disabled,xt,ye.id,De.vertexBuffer,De.indexBuffer,De.shadowCasterSegments,ye.paint,oe.transform.zoom,Be)}}(re));const ie=_.emissiveMode==="mrt-fallback";if(Z!=="offset"){if(R0(re,!1,ie),Z==="road"){const ce=!ne&&_.renderPass==="translucent";ce&&P0(_,d,g,w,"geometry"),R0(re,!0,ie,Jr.disabled),ce&&function(oe){const{painter:xe,sourceCache:ye,layer:Pe,coords:Me,colorMode:Se}=oe,Ze=xe.context.gl,$e=oe.painter.shadowRenderer,Ke=!!$e&&$e.enabled,De=new Cr(xe.context.gl.LEQUAL,Cr.ReadOnly,xe.depthRangeFor3D);let Be=[0,0,0];if(Ke){const at=xe.style.directionalLight,Qe=xe.style.ambientLight;at&&Qe&&(Be=Wu(xe.style,at,Qe))}const Ge=at=>{for(const Qe of Me){const xt=ye.getTile(Qe),ft=xt.getBucket(Pe);if(!ft)continue;const Lt=ft.elevatedStructures;if(!Lt)continue;let Bt,lt;if(at?(Bt=Lt.renderableBridgeSegments,lt=Lt.bridgeProgramConfigurations.get(Pe.id)):(Bt=Lt.renderableTunnelSegments,lt=Lt.tunnelProgramConfigurations.get(Pe.id)),!Bt||Bt.segments[0].primitiveLength===0)continue;lt.updatePaintBuffers(),xe.prepareDrawTile();const tt=xe.isTileAffectedByFog(Qe),gt=[];Ke&>.push("RENDER_SHADOWS","NORMAL_OFFSET");const _t=xe.getOrCreateProgram("elevatedStructures",{config:lt,overrideFog:tt,defines:gt}),Tt=xe.translatePosMatrix(Qe.projMatrix,xt,Pe.paint.get("fill-translate"),Pe.paint.get("fill-translate-anchor"));Ke&&$e.setupShadows(xt.tileID.toUnwrapped(),_t,"vector-tile");const rr=YC(Tt,Be);xe.uploadCommonUniforms(xe.context,_t,Qe.toUnwrapped()),_t.draw(xe,Ze.TRIANGLES,De,Jr.disabled,Se,Hr.backCCW,rr,Pe.id,Lt.vertexBuffer,Lt.indexBuffer,Bt,Pe.paint,xe.transform.zoom,lt,[Lt.vertexBufferNormal])}};Ge(!0),Ge(!1)}(re)}}else R0(re,!1,ie,_.stencilModeFor3D())},"fill-extrusion":function(_,d,g,w){const j=g.paint.get("fill-extrusion-opacity"),I=_.context,L=I.gl,F=_.terrain,z=F&&F.renderingToTexture;if(j===0)return;const H=_.emissiveMode==="mrt-fallback",Z=_.conflationActive&&_.style.isLayerClipped(g,d.getSource()),ne=_.style.order.indexOf(g.fqid);if(Z&&function(re,ie,ce,oe,xe){for(const ye of oe){const Pe=ie.getTile(ye).getBucket(ce);Pe&&(Pe.updateReplacement(ye,re.replacementSource,xe),Pe.uploadCentroid(re.context))}}(_,d,g,w,ne),F||Z)for(const re of w){const ie=d.getTile(re).getBucket(g);ie&&sI(_.context,d,re,ie,g,F,Z)}if(_.renderPass==="shadow"&&_.shadowRenderer){if(F&&j<.65&&g._transitionablePaint._values["fill-extrusion-opacity"].value.expression instanceof a.af)return;const re=_.shadowRenderer.getShadowPassDepthMode();ap(_,d,g,w,re,Jr.disabled,Yr.disabled,Z)}else if(_.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 Cr(_.context.gl.LEQUAL,Cr.ReadWrite,_.depthRangeFor3D);j===1&&re?ap(_,d,g,w,ce,Jr.disabled,Yr.unblended,Z):(ap(_,d,g,w,ce,Jr.disabled,Yr.disabled,Z),ap(_,d,g,w,ce,_.stencilModeFor3D(),_.colorModeForRenderPass(),Z),_.resetStencilClippingMasks())}if(_.style.enable3dLights()&&re&&(!F&&_.transform.projection.name!=="globe"||z)){const ce=g.paint.get("fill-extrusion-opacity"),oe=g.paint.get("fill-extrusion-ambient-occlusion-intensity"),xe=g.paint.get("fill-extrusion-ambient-occlusion-ground-radius"),ye=g.paint.get("fill-extrusion-flood-light-intensity"),Pe=g.paint.get("fill-extrusion-flood-light-color-use-theme").constantOr("default")==="none",Me=g.paint.get("fill-extrusion-flood-light-color").toNonPremultipliedRenderColor(Pe?null:g.lut).toArray01().slice(0,3),Se=oe>0&&xe>0,Ze=ye>0,$e=(Be,Ge,at)=>(1-at)*Be+at*Ge,Ke=new NE;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=_.depthModeForSublayer(1,Cr.ReadOnly,L.LEQUAL,!0),at=g.paint.get(Be?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),Qe=$e(.1,3,at),xt=_._showOverdrawInspector;if(!xt){const ft=new Jr({func:L.ALWAYS,mask:255},255,255,L.KEEP,L.KEEP,L.REPLACE),Lt=new Yr([L.ONE,L.ONE,L.ONE,L.ONE],a.aq.transparent,[!1,!1,!1,!0],L.MIN);Md(Ke,_,d,g,w,Ge,ft,Lt,Hr.disabled,Be,"sdf",ce,oe,xe,ye,Me,Qe,Z,!1)}{const ft=xt?Jr.disabled:new Jr({func:L.EQUAL,mask:255},255,255,L.KEEP,L.DECR,L.DECR),Lt=xt?_.colorModeForRenderPass():new Yr([L.ONE_MINUS_DST_ALPHA,L.DST_ALPHA,L.ONE,L.ONE],a.aq.transparent,[!0,!0,!0,!0]);Md(Ke,_,d,g,w,Ge,ft,Lt,Hr.disabled,Be,"color",ce,oe,xe,ye,Me,Qe,Z,!1)}};if(z){const Be=()=>{const at=F.drapeBufferSize[0],Qe=F.drapeBufferSize[1];let xt=F.framebufferCopyTexture;return xt&&(!xt||xt.size[0]===at&&xt.size[1]===Qe)||(xt&&xt.destroy(),xt=F.framebufferCopyTexture=new a.T(I,new a.q({width:at,height:Qe}),L.RGBA8)),xt.bind(L.LINEAR,L.CLAMP_TO_EDGE),L.copyTexSubImage2D(L.TEXTURE_2D,0,0,0,0,0,at,Qe),xt},Ge=(at,Qe,xt)=>{const ft=_.depthModeForSublayer(1,Cr.ReadOnly,L.LEQUAL,!1),Lt=g.paint.get(at?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),Bt=$e(.1,3,Lt);{const lt=new Yr([L.ONE,L.ONE,L.ONE,L.ONE],a.aq.transparent,[!1,!1,!1,!0]);Md(Ke,_,d,g,w,ft,Jr.disabled,lt,Hr.disabled,at,"clear",ce,oe,xe,ye,Me,Bt,Z,Qe)}{const lt=new Jr({func:L.ALWAYS,mask:255},255,255,L.KEEP,L.KEEP,L.REPLACE),tt=new Yr([L.ONE,L.ONE,L.ONE,L.ONE],a.aq.transparent,[!1,!1,!1,!0],L.MIN);Md(Ke,_,d,g,w,ft,lt,tt,Hr.disabled,at,"sdf",ce,oe,xe,ye,Me,Bt,Z,Qe)}H&&!at&&(xt=Be());{const lt=at?L.ZERO:L.ONE_MINUS_DST_ALPHA,tt=new Jr({func:L.EQUAL,mask:255},255,255,L.KEEP,L.DECR,L.DECR),gt=new Yr([lt,L.DST_ALPHA,L.ONE_MINUS_DST_ALPHA,L.ZERO],a.aq.transparent,[!0,!0,!0,!0]);Md(Ke,_,d,g,w,ft,tt,gt,Hr.disabled,at,"color",ce,oe,xe,ye,Me,Bt,Z,Qe)}if(!H||at){const lt=new Yr([L.ONE,L.ONE,L.ONE,at?L.ZERO:L.ONE],a.aq.transparent,[!1,!1,!1,!0],at?L.FUNC_ADD:L.MAX);Md(Ke,_,d,g,w,ft,Jr.disabled,lt,Hr.disabled,at,"clear",ce,oe,xe,ye,Me,Bt,Z,Qe,xt)}else{L.drawBuffers([L.NONE,L.COLOR_ATTACHMENT1]);const lt=new Jr({func:L.EQUAL,mask:255},254,255,L.KEEP,L.DECR,L.DECR),tt=new Yr([L.ONE,L.ONE,L.ONE,L.ONE],a.aq.transparent,[!0,!1,!1,!1],L.MAX);Md(Ke,_,d,g,w,ft,lt,tt,Hr.disabled,at,"emissive",ce,oe,xe,ye,Me,Bt,Z,Qe,xt),L.drawBuffers([L.COLOR_ATTACHMENT0])}};if(Se||Ze){let at;_.prepareDrawTile(),H&&!Se||(at=Be()),Se&&Ge(!0,!1,at),Ze&&Ge(!1,!0,at)}}else Se&&De(!0),Ze&&De(!1),(Se||Ze)&&_.resetStencilClippingMasks()}}},building:function(_,d,g,w){_.currentLayer<_.firstLightBeamLayer&&(_.firstLightBeamLayer=_.currentLayer);const j=g.paint.get("building-ambient-occlusion-ground-intensity"),I=g.paint.get("building-ambient-occlusion-ground-radius"),L=g.paint.get("building-ambient-occlusion-ground-attenuation"),F=g.paint.get("building-opacity");if(F<=0)return;let z=j>0&&I>0,H=!0;const Z=g.paint.get("building-vertical-scale");if(Z<=0)return;_.shadowRenderer||(H=!1);const ne=_.conflationActive&&_.style.isLayerClipped(g,d.getSource()),re=_.style.order.indexOf(g.fqid);if(function(ie,ce,oe,xe,ye,Pe){for(const Me of Pe){const Se=ce.getTile(Me).getBucket(oe);Se&&(ye&&Se.updateReplacement(Me,ie.replacementSource,xe),Se.uploadUpdatedIndexBuffer(ie.context))}}(_,d,g,re,ne,w),function(ie,ce,oe,xe){for(const ye of xe){const Pe=ce.getTile(ye).getBucket(oe);Pe&&Pe.needsEvaluation()&&Pe.uploadUpdatedColorBuffer(ie.context)}}(_,d,g,w),g.resetLayerRenderingStats(_),_.shadowRenderer&&(_.shadowRenderer.useNormalOffset=!0),_.renderPass==="shadow"&&_.shadowRenderer){const ie=[],ce=_.shadowRenderer.getShadowPassDepthMode();L0({painter:_,source:d,layer:g,coords:w,defines:ie,blendMode:Yr.disabled,depthMode:ce,opacity:F,verticalScale:Z,facadeEmissiveChance:0,facadeAOIntensity:0,floodLightIntensity:0,floodLightColor:[0,0,0]})}else if(_.renderPass==="translucent"){let ie=["HAS_ATTRIBUTE_a_part_color_emissive","LIGHTING_3D_MODE"];H&&(ie=ie.concat("RENDER_SHADOWS")),_.shadowRenderer&&_.shadowRenderer.useNormalOffset&&(ie=ie.concat("NORMAL_OFFSET"));const ce=g.paint.get("building-facade-emissive-chance"),oe=g.paint.get("building-ambient-occlusion-intensity"),xe=g.paint.get("building-flood-light-intensity"),ye=g.paint.get("building-flood-light-color-use-theme").constantOr("default")==="none",Pe=g.paint.get("building-flood-light-color").toNonPremultipliedRenderColor(ye?null:g.lut).toArray01().slice(0,3),Me=g.paint.get("building-flood-light-ground-attenuation"),Se=xe>0,Ze=new Cr(_.context.gl.LEQUAL,Cr.ReadWrite,_.depthRangeFor3D);F<1&&L0({painter:_,source:d,layer:g,coords:w,defines:ie,blendMode:Yr.disabled,depthMode:Ze,opacity:F,verticalScale:Z,facadeEmissiveChance:ce,facadeAOIntensity:oe,floodLightIntensity:xe,floodLightColor:Pe,depthOnly:!0});const $e=_.colorModeForRenderPass();L0({painter:_,source:d,layer:g,coords:w,defines:ie,blendMode:$e,depthMode:Ze,opacity:F,verticalScale:Z,facadeEmissiveChance:ce,facadeAOIntensity:oe,floodLightIntensity:xe,floodLightColor:Pe});const Ke=g.paint.get("building-front-cutoff");Tb(_.transform.pitch,Ke,!!_.terrain),z&&IE(_,d,g,w,!0,F,j,I,xe,Pe,L,ne),Se&&IE(_,d,g,w,!1,F,j,I,xe,Pe,Me,ne)}else if(_.renderPass==="light-beam"){const ie=["HAS_ATTRIBUTE_a_part_color_emissive","HAS_ATTRIBUTE_a_bloom_attenuation"],ce=new Cr(_.context.gl.LEQUAL,Cr.ReadOnly,_.depthRangeFor3D);L0({painter:_,source:d,layer:g,coords:w,defines:ie,blendMode:Yr.alphaBlended,depthMode:ce,opacity:F,verticalScale:Z,facadeEmissiveChance:0,facadeAOIntensity:0,floodLightIntensity:0,floodLightColor:[0,0,0]})}_.shadowRenderer&&(_.shadowRenderer.useNormalOffset=!1),_.resetStencilClippingMasks()},hillshade:function(_,d,g,w){if(_.renderPass!=="offscreen"&&_.renderPass!=="translucent"||_.style.disableElevatedTerrain)return;const j=_.context,I=_.terrain&&_.terrain.renderingToTexture,[L,F]=_.renderPass!=="translucent"||I?[{},w]:_.stencilConfigForOverlap(w);for(const z of F){const H=d.getTile(z);if(H.needsHillshadePrepare&&_.renderPass==="offscreen")U4(_,H,g);else if(_.renderPass==="translucent"){const Z=_.depthModeForSublayer(0,Cr.ReadOnly),ne=g.paint.get("hillshade-emissive-strength"),re=_.colorModeForDrapableLayerRenderPass(ne),ie=I&&_.terrain?_.terrain.stencilModeForRTTOverlap(z):L[z.overscaledZ];z4(_,z,H,g,Z,ie,re)}}j.viewport.set([0,0,_.width,_.height]),_.resetStencilClippingMasks()},raster:function(_,d,g,w,j,I){if(_.renderPass!=="translucent")return;const L=g.paint.get("raster-opacity");if(L===0)return;const F=_.transform.projection.name==="globe",z=g.paint.get("raster-elevation")!==0,H=z&&F,Z=_.terrain&&_.terrain.exaggeration()>0&&z&&g.paint.get("raster-elevation-reference")==="ground",ne=!F&&Z;if(_.renderElevatedRasterBackface&&!H)return;const re=_.context,ie=re.gl,ce=d.getSource(),oe=function(Be,Ge,at,Qe,xt){const ft=Ge.paint.get("raster-color"),Lt=Be.type==="raster-array",Bt=[],lt=Ge.paint.get("raster-resampling"),tt=Ge.paint.get("raster-color-mix");let gt=Ge.paint.get("raster-color-range");const _t=[tt[0],tt[1],tt[2],0],Tt=tt[3];let rr=lt==="nearest"?Qe.NEAREST:Qe.LINEAR;if(Lt&&(Bt.push("RASTER_ARRAY"),ft||Bt.push("RASTER_COLOR"),lt==="linear"&&Bt.push("RASTER_ARRAY_LINEAR"),rr=Qe.NEAREST,!gt&&Be.rasterLayers)){const Wt=Be.rasterLayers.find(({id:Kt})=>Kt===Ge.sourceLayer);Wt&&Wt.fields&&Wt.fields.range&&(gt=Wt.fields.range)}if(gt=gt||[0,1],ft){Bt.push("RASTER_COLOR"),at.activeTexture.set(Qe.TEXTURE2),Ge.updateColorRamp(gt);let Wt=Ge.colorRampTexture;Wt||(Wt=Ge.colorRampTexture=new a.T(at,Ge.colorRamp,Qe.RGBA8)),Wt.bind(rr,Qe.CLAMP_TO_EDGE)}return xt&&Bt.push("USE_MRT1"),{mix:_t,range:gt,offset:Tt,defines:Bt,resampling:rr}}(ce,g,re,ie,_.terrain&&_.terrain.renderingToTexture&&_.emissiveMode==="mrt-fallback");if(ce instanceof a.aV&&!w.length&&!F)return;const xe=g.paint.get("raster-emissive-strength"),ye=_.colorModeForDrapableLayerRenderPass(xe),Pe=_.terrain&&_.terrain.renderingToTexture,Me=!_.options.moving,Se=g.paint.get("raster-resampling")==="nearest"?ie.NEAREST:ie.LINEAR;if(ce instanceof a.aV&&!w.length&&(ce.onNorthPole||ce.onSouthPole)){const Be=z?_.stencilModeFor3D():Jr.disabled;return void jb(!!ce.onNorthPole,null,_,d,g,xe,oe,Hr.disabled,Be)}if(!w.length)return;const[Ze,$e]=ce instanceof a.aV||Pe?[{},w]:_.stencilConfigForOverlap(w),Ke=$e[$e.length-1].overscaledZ;H&&oe.defines.push("PROJECTION_GLOBE_VIEW"),z&&oe.defines.push("RENDER_CUTOFF","ELEVATED"),Z&&oe.defines.push("ELEVATION_REFERENCE_GROUND");const De=(Be,Ge,at)=>{for(const Qe of Be){const xt=Qe.toUnwrapped(),ft=d.getTile(Qe);if(Pe&&(!ft||!ft.hasData()))continue;re.activeTexture.set(ie.TEXTURE0);const Lt=oI(ft,ce,g,oe);if(!Lt||!Lt.texture)continue;const{texture:Bt,mix:lt,offset:tt,tileSize:gt,buffer:_t}=Lt;let Tt,rr;Pe?(Tt=Cr.disabled,rr=Qe.projMatrix):z?(Tt=new Cr(ie.LEQUAL,Cr.ReadWrite,_.depthRangeFor3D),rr=F?Float32Array.from(_.transform.expandedFarZProjMatrix):_.transform.calculateProjMatrix(xt,Me)):(Tt=_.depthModeForSublayer(Qe.overscaledZ-Ke,L===1?Cr.ReadWrite:Cr.ReadOnly,ie.LESS),rr=_.transform.calculateProjMatrix(xt,Me));const Wt=_.terrain&&Pe?_.terrain.stencilModeForRTTOverlap(Qe):Ze[Qe.overscaledZ],Kt=I?0:g.paint.get("raster-fade-duration");ft.registerFadeDuration(Kt);const Ot=d.findLoadedParent(Qe,0),Ar=E0(ft,Ot,d,_.transform,Kt);let Lr,gr;!Ar.isFading&&ft.refreshedUponExpiration&&(ft.refreshedUponExpiration=!1),_.terrain&&_.terrain.prepareDrawTile(),re.activeTexture.set(ie.TEXTURE0),Bt.bind(Se,ie.CLAMP_TO_EDGE),re.activeTexture.set(ie.TEXTURE1),Ot?(Ot.texture&&Ot.texture.bind(Se,ie.CLAMP_TO_EDGE),Lr=Math.pow(2,Ot.tileID.overscaledZ-ft.tileID.overscaledZ),gr=[ft.tileID.canonical.x*Lr%1,ft.tileID.canonical.y*Lr%1]):Bt.bind(Se,ie.CLAMP_TO_EDGE),"useMipmap"in Bt&&re.extTextureFilterAnisotropic&&_.transform.pitch>20&&ie.texParameterf(ie.TEXTURE_2D,re.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,re.extTextureFilterAnisotropicMax);const Tr=_.transform;let Wr;const an=z?RE(Tr):[0,0,0,0];let tn,_n,Ur,bn,rn,Hn=0;if(H&&ce instanceof a.aV&&ce.coordinates.length>3)tn=Float32Array.from(a.du(a.dv(new a.cn(0,0,0)))),_n=Float32Array.from(Tr.globeMatrix),Ur=Float32Array.from(a.dq(Tr)),bn=[a.aH(Tr.center.lng),a.aL(Tr.center.lat)],Wr=ce.elevatedGlobePerspectiveTransform,rn=ce.elevatedGlobeGridMatrix||new Float32Array(9);else if(H){const ts=a.dr(Qe.canonical);Hn=a.ds(ts.getCenter().lat),tn=Float32Array.from(a.du(a.dv(Qe.canonical))),_n=Float32Array.from(Tr.globeMatrix),Ur=Float32Array.from(a.dq(Tr)),bn=[a.aH(Tr.center.lng),a.aL(Tr.center.lat)],Wr=[0,0],rn=Float32Array.from(a.dt(Qe.canonical,ts,Hn,Tr.worldSize/Tr._pixelsPerMercatorPixel))}else Wr=ce instanceof a.aV?ce.perspectiveTransform:[0,0],tn=new Float32Array(16),_n=new Float32Array(9),Ur=new Float32Array(16),bn=[0,0],rn=new Float32Array(9);const ws=QC(_,rr,tn,_n,Ur,rn,gr||[0,0],a.al(_.transform.zoom),bn,an,Lr||1,Ar,g,Wr,z?g.paint.get("raster-elevation"):0,2,lt,tt,oe.range,gt,_t,xe),Xs=_.isTileAffectedByFog(Qe),Is=_.getOrCreateProgram("raster",{defines:oe.defines,overrideFog:Xs});if(_.uploadCommonUniforms(re,Is,xt),ce instanceof a.aV){const ts=ce.elevatedGlobeVertexBuffer,gn=ce.elevatedGlobeIndexBuffer;if(Pe||!F)ce.boundsBuffer&&ce.boundsSegments&&Is.draw(_,ie.TRIANGLES,Tt,Jr.disabled,ye,Hr.disabled,ws,g.id,ce.boundsBuffer,_.quadTriangleIndexBuffer,ce.boundsSegments);else if(ts&&gn){const yn=Tr.zoom<=a.cJ?ce.elevatedGlobeSegments:ce.getSegmentsForLongitude(Tr.center.lng);yn&&Is.draw(_,ie.TRIANGLES,Tt,Jr.disabled,ye,Ge,ws,g.id,ts,gn,yn)}}else if(H){Tt=new Cr(ie.LEQUAL,Cr.ReadOnly,_.depthRangeFor3D);const ts=_.globeSharedBuffers;if(ts){Z&&(_.terrain.setupElevationDraw(ft,Is),_.uploadCommonUniforms(re,Is,ft.tileID.toUnwrapped()));const[gn,yn,Ps]=ts.getGridBuffers(Hn,!1),ni=Is.getAttributeLocation(ie,"a_texture_pos");ni!==-1&&ie.vertexAttribI4ui(ni,0,0,0,0),Is.draw(_,ie.TRIANGLES,Tt,at||Wt,_.colorModeForRenderPass(),Ge,ws,g.id,gn,yn,Ps)}}else if(ne)Tt=new Cr(ie.LEQUAL,Cr.ReadWrite,_.depthRangeFor3D),_.terrain.setupElevationDraw(ft,Is),_.uploadCommonUniforms(re,Is,ft.tileID.toUnwrapped()),Tr.pitch>20&&Is.draw(_,ie.TRIANGLES,Tt,Jr.disabled,Yr.disabled,Hr.frontCCW,ws,g.id,_.terrain.gridBuffer,_.terrain.gridIndexBuffer,_.terrain.gridSegments),Is.draw(_,ie.TRIANGLES,Tt,Wt,ye,Hr.backCCW,ws,g.id,_.terrain.gridBuffer,_.terrain.gridIndexBuffer,_.terrain.gridSegments);else{const{tileBoundsBuffer:ts,tileBoundsIndexBuffer:gn,tileBoundsSegments:yn}=_.getTileBoundsBuffers(ft);Is.draw(_,ie.TRIANGLES,Tt,Wt,ye,Hr.disabled,ws,g.id,ts,gn,yn)}}if(!(ce instanceof a.aV)&&H)for(const Qe of Be){const xt=Qe.canonical.y===(1<a.d$[_t](xt));lt.push(xt);const tt=xt.canonical.x,gt=xt.canonical.y;for(const _t of lt){const Tt=Se.getTile(Ge?_t.wrapped():_t);if(!Tt)continue;const rr=Tt.rasterParticleState;if(!rr)continue;const Wt=_t.canonical.x+(1<<_t.canonical.z)*(_t.wrap-xt.wrap),Kt=_t.canonical.y;rr.particleTexture0.bind(De.NEAREST,De.CLAMP_TO_EDGE);const Ot=J4(1,rr.particleTexture0.size[0],[Wt-tt,Kt-gt],0,ft.texture.size,2,at,ft.textureOffset,ft.scale,ft.offset);Bt.draw(Me,De.POINTS,Cr.disabled,Jr.disabled,Yr.alphaBlended,Hr.disabled,Ot,Ze.id,rr.particleIndexBuffer,void 0,rr.particleSegment)}}}(L,F,z,xe),Z.bindFramebuffer.set(z.particleFramebuffer.framebuffer),function(Me,Se,Ze,$e){const Ke=Me.context,De=Ke.gl,Be=Se.paint.get("raster-particle-max-speed"),Ge=$e*Se.paint.get("raster-particle-speed-factor")*.15,at=function(xt){return Math.pow(xt,6)}(.01+1*Se.paint.get("raster-particle-reset-rate-factor")),Qe=Se.particleFramebuffer;Ke.viewport.set([0,0,Qe.width,Qe.height]);for(const xt of Ze){const[,ft,Lt]=xt;Ke.activeTexture.set(De.TEXTURE0+0),ft.texture.bind(De.LINEAR,De.CLAMP_TO_EDGE),Ke.activeTexture.set(De.TEXTURE0+1);const Bt=Lt.particleTexture0;Bt.bind(De.NEAREST,De.CLAMP_TO_EDGE);const lt=eI(1,Bt.size[0],0,ft.texture.size,Be,Ge,at,ft.textureOffset,ft.scale,ft.offset);Qe.colorAttachment0.set(Lt.particleTexture1.texture),Ke.clear({color:a.aq.transparent}),Me.getOrCreateProgram("rasterParticleUpdate",{defines:ft.defines}).draw(Me,De.TRIANGLES,Cr.disabled,Jr.disabled,Yr.unblended,Hr.disabled,lt,Se.id,Me.viewportBuffer,Me.quadTriangleIndexBuffer,Me.viewportSegments)}}(L,z,xe,Pe)}(_,d,g,w),_.renderPass==="translucent"&&(function(L,F,z,H){const Z=L.context,ne=Z.gl,re=F.getSource().tileSize,ie=5*(1-a.aj(a.cv,a.cv+1,L.transform.zoom))*re+z.paint.get("raster-particle-elevation"),ce=!L.options.moving,oe=L.transform.projection.name==="globe";if(!H.length)return;const[xe,ye]=L.stencilConfigForOverlap(H),Pe=[];oe&&Pe.push("PROJECTION_GLOBE_VIEW");const Me=L.stencilModeFor3D();for(const Se of ye){const Ze=Se.toUnwrapped(),$e=F.getTile(Se);if(!$e.rasterParticleState)continue;const Ke=$e.rasterParticleState,De=100;$e.registerFadeDuration(De);const Be=F.findLoadedParent(Se,0),Ge=E0($e,Be,F,L.transform,De);let at,Qe;L.terrain&&L.terrain.prepareDrawTile(),Z.activeTexture.set(ne.TEXTURE0),Ke.targetColorTexture.bind(ne.LINEAR,ne.CLAMP_TO_EDGE),Z.activeTexture.set(ne.TEXTURE1),Be&&Be.rasterParticleState?(Be.rasterParticleState.targetColorTexture.bind(ne.LINEAR,ne.CLAMP_TO_EDGE),at=Math.pow(2,Be.tileID.overscaledZ-$e.tileID.overscaledZ),Qe=[$e.tileID.canonical.x*at%1,$e.tileID.canonical.y*at%1]):Ke.targetColorTexture.bind(ne.LINEAR,ne.CLAMP_TO_EDGE);const xt=oe?Float32Array.from(L.transform.expandedFarZProjMatrix):L.transform.calculateProjMatrix(Ze,ce),ft=L.transform,Lt=DE(ft),Bt=a.dr(Se.canonical),lt=a.ds(Bt.getCenter().lat);let tt,gt,_t,Tt,rr;oe?(tt=Float32Array.from(a.du(a.dv(Se.canonical))),gt=Float32Array.from(ft.globeMatrix),_t=Float32Array.from(a.dq(ft)),Tt=[a.aH(ft.center.lng),a.aL(ft.center.lat)],rr=Float32Array.from(a.dt(Se.canonical,Bt,lt,ft.worldSize/ft._pixelsPerMercatorPixel))):(tt=new Float32Array(16),gt=new Float32Array(9),_t=new Float32Array(16),Tt=[0,0],rr=new Float32Array(9));const Wt=Q4(xt,tt,gt,_t,rr,Qe||[0,0],a.al(L.transform.zoom),Tt,Lt,at||1,Ge,ie),Kt=L.isTileAffectedByFog(Se),Ot=L.getOrCreateProgram("rasterParticle",{defines:Pe,overrideFog:Kt});if(L.uploadCommonUniforms(Z,Ot,Ze),oe){const Ar=new Cr(ne.LEQUAL,Cr.ReadOnly,L.depthRangeFor3D),Lr=0,gr=L.globeSharedBuffers;if(gr){const[Tr,Wr,an]=gr.getGridBuffers(lt,Lr!==0);Ot.draw(L,ne.TRIANGLES,Ar,Me,Yr.alphaBlended,L.renderElevatedRasterBackface?Hr.frontCCW:Hr.backCCW,Wt,z.id,Tr,Wr,an)}}else{const Ar=L.depthModeForSublayer(0,Cr.ReadOnly),Lr=xe[Se.overscaledZ],{tileBoundsBuffer:gr,tileBoundsIndexBuffer:Tr,tileBoundsSegments:Wr}=L.getTileBoundsBuffers($e);Ot.draw(L,ne.TRIANGLES,Ar,Lr,Yr.alphaBlended,Hr.disabled,Wt,z.id,gr,Tr,Wr)}}L.resetStencilClippingMasks()}(_,d,g,w),_.style.map.triggerRepaint())},background:function(_,d,g,w){const j=g.paint.get("background-color"),I=g.paint.get("background-color-use-theme").constantOr("default")==="none",L=g.paint.get("background-opacity"),F=g.paint.get("background-emissive-strength"),z=g.paint.get("background-pitch-alignment")==="viewport";if(L===0)return;const H=_.context,Z=H.gl,ne=_.transform,re=ne.tileSize,ie=g.paint.get("background-pattern");let ce;if(ie!==void 0&&(ie===null||(ce=_.imageManager.getPattern(a.I.from(ie.toString()),g.scope,_.style.getLut(g.scope)),!ce)))return;const oe=!ie&&j.a===1&&L===1&&_.opaquePassEnabledForLayer()?"opaque":"translucent";if(_.renderPass!==oe)return;const xe=Jr.disabled,ye=_.depthModeForSublayer(0,oe==="opaque"?Cr.ReadWrite:Cr.ReadOnly),Pe=_.colorModeForDrapableLayerRenderPass(F),Me=ie?"backgroundPattern":"background";let Se,Ze=w;Ze||(Se=_.getBackgroundTiles(),Ze=Object.values(Se).map(Ke=>Ke.tileID)),ie&&(H.activeTexture.set(Z.TEXTURE0),_.imageManager.bind(_.context,g.scope));const $e=[];if(_.terrain&&_.terrain.renderingToTexture&&_.emissiveMode==="mrt-fallback"&&$e.push("USE_MRT1"),z){const Ke=_.getOrCreateProgram(Me,{overrideFog:!1,overrideRtt:!0,defines:$e}),De=new Float32Array(a.b9([])),Be=new a.aR(0,0,0,0,0),Ge=ie?Df(De,F,L,_,0,g.scope,ce,z,{tileID:Be,tileSize:re}):N0(De,F,L,j.toPremultipliedRenderColor(I?null:g.lut));return void Ke.draw(_,Z.TRIANGLES,ye,xe,Pe,Hr.disabled,Ge,g.id,_.viewportBuffer,_.quadTriangleIndexBuffer,_.viewportSegments)}for(const Ke of Ze){const De=_.isTileAffectedByFog(Ke),Be=_.getOrCreateProgram(Me,{overrideFog:De,defines:$e}),Ge=Ke.toUnwrapped(),at=w?Ke.projMatrix:_.transform.calculateProjMatrix(Ge);_.prepareDrawTile();const Qe=d?d.getTile(Ke):Se?Se[Ke.key]:new a.b0(Ke,re,ne.zoom,_),xt=ie?Df(at,F,L,_,0,g.scope,ce,z,{tileID:Ke,tileSize:re}):N0(at,F,L,j.toPremultipliedRenderColor(I?null:g.lut));_.uploadCommonUniforms(H,Be,Ge);const{tileBoundsBuffer:ft,tileBoundsIndexBuffer:Lt,tileBoundsSegments:Bt}=_.getTileBoundsBuffers(Qe);Be.draw(_,Z.TRIANGLES,ye,xe,Pe,Hr.disabled,xt,g.id,ft,Lt,Bt)}},sky:function(_,d,g){const w=_._atmosphere?a.al(_.transform.zoom):1,j=g.paint.get("sky-opacity")*w;if(j===0)return;const I=_.context,L=g.paint.get("sky-type"),F=new Cr(I.gl.LEQUAL,Cr.ReadOnly,[0,1]),z=_.frameCounter/1e3%1;L==="atmosphere"?_.renderPass==="offscreen"?g.needsSkyboxCapture(_)&&(function(H,Z){const ne=H.context,re=ne.gl;let ie=Z.skyboxFbo;if(!ie){ie=Z.skyboxFbo=ne.createFramebuffer(32,32,1,null),Z.skyboxGeometry=new rl(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 ye=0;ye<6;++ye)re.texImage2D(re.TEXTURE_CUBE_MAP_POSITIVE_X+ye,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(H,!0),oe=H.getOrCreateProgram("skyboxCapture"),xe=new Float64Array(16);a.b9(xe),a.ef(xe,xe,.5*-Math.PI),Pc(H,Z,oe,xe,ce,0),a.b9(xe),a.ef(xe,xe,.5*Math.PI),Pc(H,Z,oe,xe,ce,1),a.b9(xe),a.cE(xe,xe,.5*-Math.PI),Pc(H,Z,oe,xe,ce,2),a.b9(xe),a.cE(xe,xe,.5*Math.PI),Pc(H,Z,oe,xe,ce,3),a.b9(xe),Pc(H,Z,oe,xe,ce,4),a.b9(xe),a.ef(xe,xe,Math.PI),Pc(H,Z,oe,xe,ce,5),ne.viewport.set([0,0,H.width,H.height])}(_,g),g.markSkyboxValid(_)):_.renderPass==="sky"&&function(H,Z,ne,re,ie){const ce=H.context,oe=ce.gl,xe=H.transform,ye=H.getOrCreateProgram("skybox");ce.activeTexture.set(oe.TEXTURE0),oe.bindTexture(oe.TEXTURE_CUBE_MAP,Z.skyboxTexture);const Pe=((Me,Se,Ze,$e,Ke)=>({u_matrix:Me,u_sun_direction:Se,u_cubemap:0,u_opacity:$e,u_temporal_offset:Ke}))(xe.skyboxMatrix,Z.getCenter(H,!1),0,re,ie);H.uploadCommonUniforms(ce,ye),ye.draw(H,oe.TRIANGLES,ne,Jr.disabled,H.colorModeForRenderPass(),Hr.backCW,Pe,"skybox",Z.skyboxGeometry.vertexBuffer,Z.skyboxGeometry.indexBuffer,Z.skyboxGeometry.segment)}(_,g,F,j,z):L==="gradient"&&_.renderPass==="sky"&&function(H,Z,ne,re,ie){const ce=H.context,oe=ce.gl,xe=H.transform,ye=H.getOrCreateProgram("skyboxGradient");Z.skyboxGeometry||(Z.skyboxGeometry=new rl(ce)),ce.activeTexture.set(oe.TEXTURE0);let Pe=Z.colorRampTexture;Pe||(Pe=Z.colorRampTexture=new a.T(ce,Z.colorRamp,oe.RGBA8)),Pe.bind(oe.LINEAR,oe.CLAMP_TO_EDGE);const Me=((Se,Ze,$e,Ke,De)=>({u_matrix:Se,u_color_ramp:0,u_center_direction:Ze,u_radius:a.ap($e),u_opacity:Ke,u_temporal_offset:De}))(xe.skyboxMatrix,Z.getCenter(H,!1),Z.paint.get("sky-gradient-radius"),re,ie);H.uploadCommonUniforms(ce,ye),ye.draw(H,oe.TRIANGLES,ne,Jr.disabled,H.colorModeForRenderPass(),Hr.backCW,Me,"skyboxGradient",Z.skyboxGeometry.vertexBuffer,Z.skyboxGeometry.indexBuffer,Z.skyboxGeometry.segment)}(_,g,F,j,z)},custom:function(_,d,g,w){const j=_.context,I=g.implementation;if(!_.transform.projection.unsupportedLayers||!_.transform.projection.unsupportedLayers.includes("custom")||_.terrain&&(_.terrain.renderingToTexture||_.renderPass==="offscreen")&&g.isDraped(d)){if(_.renderPass==="offscreen"){const L=I.prerender;if(L){if(_.setCustomLayerDefaults(),j.setColorMode(_.colorModeForRenderPass()),_.transform.projection.name==="globe"){const F=_.transform.pointMerc;L.call(I,j.gl,_.transform.customLayerMatrix(),_.transform.getProjection(),_.transform.globeToMercatorMatrix(),a.al(_.transform.zoom),[F.x,F.y],_.transform.pixelsPerMeterRatio)}else L.call(I,j.gl,_.transform.customLayerMatrix());j.setDirty(),_.setBaseState()}}else if(_.renderPass==="translucent"){if(_.terrain&&_.terrain.renderingToTexture){const F=I.renderToTile;if(F){const z=w[0].canonical,H={x:z.x+w[0].wrap*(I.wrapTileId?0:1<{H&&(H.useNormalOffset=!0,Z||(H.enabled=!0))},re=d.getSource();if(_.renderPass==="light-beam"&&re.type!=="batched-model")return;if(re.type==="vector"||re.type==="geojson")return function(Se,Ze,$e,Ke,De){const Be=Se.transform,Ge=Be.projection.name==="globe",at=Be.getFreeCameraOptions().position;if(!Se.modelManager)return;const Qe=Se.modelManager;$e.modelManager=Qe;const xt=Se.shadowRenderer;if(!$e._unevaluatedLayout._values.hasOwnProperty("model-id"))return;const ft=$e._unevaluatedLayout._values["model-id"],Lt=Object.assign({},$e.layout.get("model-id").parameters),Bt=Se.style.order.indexOf($e.fqid),lt=$e.paint.get("model-opacity").constantOr(1);for(const tt of Ke){const gt=Ze.getTile(tt).getBucket($e);if(!gt||gt.projection.name!==Be.projection.name)continue;const _t=gt.getModelUris();if(_t&&!gt.modelsRequested&&(Qe.addModelsFromBucket(_t,De),gt.modelsRequested=!0),Ge)Lt.zoom=tt.overscaledZ;else{const gr=Xg(tt,Be);Lt.zoom=gr}const Tt=ft.possiblyEvaluate(Lt);if(Qt(Se,gt,tt),Ht.shadowUniformsInitialized=!1,Ht.useSingleShadowCascade=!!xt&&xt.getMaxCascadeForTile(tt.toUnwrapped())===0,Se.renderPass==="shadow"&&xt){if(Se.currentShadowCascade===1&>.isInsideFirstShadowMapFrustum)continue;const gr=Be.calculatePosMatrix(tt.toUnwrapped(),Be.worldSize);if(Ht.tileMatrix.set(gr),Ht.shadowTileMatrix=Float32Array.from(xt.calculateShadowPassMatrixFromMatrix(gr)),Ht.aabb.min=[0,0,0],Ht.aabb.max[0]=Ht.aabb.max[1]=a.an,Ht.aabb.max[2]=0,mI(gt,Ht,Se,$e.scope))continue}const rr=1<0&&Se.style.isLayerClipped($e,Ze.getSource())&>.updateReplacement(tt,Se.replacementSource,Bt,$e.scope)&&(gt.uploaded=!1,gt.upload(Se.context));let Kt=0;const Ot=new Array,Ar=new Array,Lr=new Array;for(let gr in gt.instancesPerModel){const Tr=gt.instancesPerModel[gr];Tr.features.length>0&&!Ge&&(gr=Tt.evaluate(Tr.features[0].feature,{}));const Wr=Qe.getModel(gr,De);if(Wr||Qe.hasURLBeenRequested(gr)||gt.modelUris.includes(gr)||(gt.modelUris.push(gr),gt.modelsRequested=!1),Wr&&Wr.uploaded)if(Ge){const an=a.bJ([],[at.x,at.y,at.z],Se.transform.worldSize);a.eo(an,an);for(let tn=0;tn0&&bn.elevationUpdate(gr.terrain,tn,Ur,Wr.source),bn.needsReEvaluation(gr,_n,Wr)&&bn.evaluate(Wr))}})(Se,Ze,$e,Ke),function(){const gr=new Map;let Tr,Wr,an;Ot?(Tr=Ke.length-1,Wr=-1,an=-1):(Tr=0,Wr=Ke.length,an=1);const tn=new Float64Array(16),_n=a.ce(),Ur=new a.P(0,0);for(let bn=Tr;bn!==Wr;bn+=an){const rn=Ke[bn],Hn=Ze.getTile(rn).getBucket($e);if(!Hn||!Hn.uploaded)continue;let ws=!1;at&&(ws=at.getMaxCascadeForTile(rn.toUnwrapped())===0);const Xs=Be.calculatePosMatrix(rn.toUnwrapped(),Be.worldSize),Is=Hn.modelTraits;!rr&&Ot&&(a.b7(tn,Xs),a.ah(_n,xt,tn),Ur.x=_n[0],Ur.y=_n[1]);const ts=[];Hn.setFilter($e.filter);for(const gn of Hn.getNodesInfo()){if(gn.hiddenByReplacement||!gn.node.meshes)continue;const yn=gn.node;let Ps=0;Se.terrain&&yn.elevation&&(Ps=yn.elevation*Se.terrain.exaggeration());const ni=(()=>{const Ka=gn.aabb;return Tt.min=[...Ka.min],Tt.max=[...Ka.max],Tt.min[2]+=Ps,Tt.max[2]+=Ps,a.ah(Tt.min,Tt.min,Xs),a.ah(Tt.max,Tt.max,Xs),Tt})(),rs=gn.evaluatedScale;if(rs[0]<=1&&rs[1]<=1&&rs[2]<=1&&ni.intersects(Wt)===0)continue;if(!rr&&Ot){const Ka=.16666666666666666;gn.cameraCollisionOpacity=xt[0]>ni.min[0]&&xt[0]ni.min[1]&&xt[1]!Ot||gn.opacity===1&&yn.opacity===1?gn.depthyn.depth?-1:1);for(const gn of ts){const yn=gn.nodeInfo,Ps=yn.node;if(Se._debugParams.show3DModelFootprints&&Ps.footprint){const In=Ps.id||Ps.name||"footprint";gr.has(In)||gr.set(In,{node:Ps,mvp:gn.wvpForTile})}let ni=a.aD([],lt,gn.tileModelMatrix);a.aD(ni,Lt,ni);const rs=a.b7([],ni);a.e6(rs,rs),a.cC(rs,rs,st),ni=a.aD(ni,ni,Ps.globalMatrix);const ln=Se.renderPass==="light-beam",Ys=$e.paint.get("model-color-use-theme").constantOr("default")==="none",Ss=Is&a.ez.HasMapboxMeshFeatures,Bi=Ss?0:yn.evaluatedRMEA[0][2];for(let In=0;In=Ln||gc>=Ln}}const us=ks.material;let Mc;us.occlusionTexture&&us.occlusionTexture.offsetScale&&(Mc=us.occlusionTexture.offsetScale,ma.defines.push("OCCLUSION_TEXTURE_TRANSFORM"));const Dc=Se.getOrCreateProgram("model",ma);!rr&&at&&at.setupShadowsFromMatrix(gn.tileModelMatrix,Dc,at.useNormalOffset),Se.uploadCommonUniforms(De,Dc,null,pc);const Os=us.pbrMetallicRoughness;Os.metallicFactor=.9,Os.roughnessFactor=.5;const Vs=sp(new Float32Array(jo),new Float32Array(ni),new Float32Array(rs),new Float32Array(Ps.globalMatrix),Se,gn.opacity,Os.baseColorFactor,us.emissiveFactor,Os.metallicFactor,Os.roughnessFactor,us,Bi,$e,[0,0,0],Mc);!ra&&(yn.hasTranslucentParts||gn.opacity<1)&&Dc.draw(Se,De.gl.TRIANGLES,gt,Jr.disabled,Yr.disabled,Hr.backCCW,Vs,$e.id,ks.vertexBuffer,ks.indexBuffer,ks.segments,$e.paint,Se.transform.zoom,void 0,Ka),Dc.draw(Se,De.gl.TRIANGLES,ra?_t:gt,Jr.disabled,ra||gn.opacity<1||yn.hasTranslucentParts?Yr.alphaBlended:Yr.unblended,Hr.backCCW,Vs,$e.id,ks.vertexBuffer,ks.indexBuffer,ks.segments,$e.paint,Se.transform.zoom,void 0,Ka)}}}if(Se._debugParams.show3DModelFootprints&&gr.size>0){const bn=Array.from(gr.keys()).sort();for(const rn of bn){const{node:Hn,mvp:ws}=gr.get(rn);VE(Se,0,Hn,ws)}}}()}(_,d,g,w),void ne();if(re.type!=="model")return;const ie=re.getModels(),ce=[],oe=_.transform.getFreeCameraOptions().position,xe=a.bJ([],[oe.x,oe.y,oe.z],_.transform.worldSize);a.eo(xe,xe);const ye=[],Pe=[];let Me=0;for(const Se of ie){const Ze=d.getFeatureState("",Se.id),$e={type:"Unknown",id:Se.id,properties:Se.featureProperties},Ke=g.paint.get("model-rotation").evaluate($e,Ze),De=g.paint.get("model-scale").evaluate($e,Ze),Be=g.paint.get("model-translation").evaluate($e,Ze),Ge=g.paint.get("model-opacity").evaluate($e,Ze);qE(g,Se.id,Ze,Se.featureProperties,Se.nodeOverrideNames,Se.nodeOverrides),lp(g,Se.id,Ze,Se.featureProperties,Se.materialOverrideNames,Se.materialOverrides),Se.nodeOverrides.size>0&&Se.computeBoundsAndApplyParent(),Se.computeModelMatrix(_,Ke,De,Be,F,L,!1);const at=a.b9([]),Qe=a.e2(Se.position.lat,_.transform.zoom),xt=a.bP([],[1,1,1/Qe]);a.bx(at,at,xe),ce.push({zScaleMatrix:xt,negCameraPosMatrix:at});for(const ft of Se.nodes)Nb(_,ft,Se.matrix,_.transform.expandedFarZProjMatrix,Me,ye,Pe,Se.materialOverrides,Ge);Me++}if(ye.sort((Se,Ze)=>Ze.depth-Se.depth),_.renderPass!=="shadow"){if(_._debugParams.show3DModelFootprints){const Se=_.transform.projMatrix,Ze=new Map,$e=(De,Be)=>{if(De.footprint){const Ge=De.id||De.name||"footprint";if(!Ze.has(Ge)){const at=a.aD([],Se,Be);Ze.set(Ge,{node:De,mvp:at})}}};for(const De of Pe)$e(De.node,De.modelMatrix);for(const De of ye)$e(De.node,De.modelMatrix);const Ke=Array.from(Ze.keys()).sort();for(const De of Ke){const{node:Be,mvp:Ge}=Ze.get(De);VE(_,0,Be,Ge)}}Nh(_,g,ye,Pe,ce),ne()}else{for(const Se of Pe)Zg(Se.mesh,Se.nodeModelMatrix,_,g);for(const Se of ye)Zg(Se.mesh,Se.nodeModelMatrix,_,g);ne()}}},WE={line:function(_,d,g){if(_.hasElevatedBuckets=!1,_.hasNonElevatedBuckets=!1,_._unevaluatedLayout.getValue("line-elevation-reference")!==void 0||_._unevaluatedLayout.getValue("line-z-offset")!==void 0){if(d){const w=d.getVisibleCoordinates();for(const j of w){const I=d.getTile(j).getBucket(_);if(I&&(I.elevationType!=="none"?_.hasElevatedBuckets=!0:_.hasNonElevatedBuckets=!0,_.hasElevatedBuckets&&_.hasNonElevatedBuckets))break}}}else _.hasNonElevatedBuckets=!0},model:function(_,d,g){const w=d.getSource();if(!w.loaded())return;if(w.type==="vector"||w.type==="geojson")return void(g.modelManager&&g.modelManager.upload(g,kb(g,_)));if(w.type==="batched-model"||w.type!=="model")return;const j=w.getModels();for(const I of j)I.upload(g.context)},raster:function(_,d,g){const w=d.getSource();if(!(w instanceof Hm&&w.loaded()))return;const j=_.sourceLayer||w.rasterLayerIds&&w.rasterLayerIds[0];if(!j)return;const I=_.paint.get("raster-array-band")||w.getInitialBand(j);if(I==null)return;const L=d.getIds().map(F=>d.getTileByID(F));for(const F of L)F.updateNeeded(_.id,I)&&w.prepareTile(F,j,_.id,I)},"raster-particle":function(_,d,g){const w=d.getSource();if(!(w instanceof Hm&&w.loaded()))return;const j=_.sourceLayer||w.rasterLayerIds&&w.rasterLayerIds[0];if(!j)return;const I=_.paint.get("raster-particle-array-band")||w.getInitialBand(j);if(I==null)return;const L=d.getIds().map(F=>d.getTileByID(F));for(const F of L)F.updateNeeded(_.id,I)&&w.prepareTile(F,j,_.id,I)}},KE={fill:P0},YE={fill:function(_,d,g,w){if(!g.layout||g.layout.get("fill-elevation-reference")==="none"||g.paint.get("fill-opacity").constantOr(1)===0)return;const j=_.context.gl,I=new Cr(j.LEQUAL,Cr.ReadOnly,_.depthRangeFor3D),L=new Jr({func:j.ALWAYS,mask:255},255,255,j.KEEP,j.KEEP,j.REPLACE),F=_.transform.getFreeCameraOptions().position,z=_.getOrCreateProgram("elevatedStructuresDepthReconstruct");for(const H of w){const Z=d.getTile(H),ne=Z.getBucket(g);if(!ne)continue;const re=ne.elevatedStructures;if(!re||re.depthSegments.segments[0].primitiveLength===0)continue;const ie=kE(H.toUnwrapped(),F),ce=_.translatePosMatrix(H.projMatrix,Z,g.paint.get("fill-translate"),g.paint.get("fill-translate-anchor")),oe=A0(ce,ie,0,1,0);z.draw(_,j.TRIANGLES,I,L,Yr.disabled,Hr.disabled,oe,g.id,re.vertexBuffer,re.indexBuffer,re.depthSegments,g.paint,_.transform.zoom)}}};class i5{constructor(d,g,w,j,I){this.context=new Kg(d,g),this.transform=w,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 gI,this.setup(),this.numSublayers=fu.maxUnderzooming+fu.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 pI,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=I,this._forceEmissiveMode=!1,this.emissiveMode="constant"}updateTerrain(d,g){const w=!!d&&!!d.terrain&&this.transform.projection.supportsTerrain;if(!(w||this._terrain&&this._terrain.enabled))return;this._terrain||(this._terrain=new j0(this,d));const j=this._terrain;this.transform.elevation=w?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[w,j]=g.getFovAdjustedRange(this.transform._fov);if(w>j)return void(this.transform.fogCullDistSq=null);const I=w+.78*(j-w);this.transform.fogCullDistSq=I*I}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 j0(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 w of this.style.order)this.style._mergedLayers[w].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 w=new a.dB;w.emplaceBack(0,0),w.emplaceBack(a.an,0),w.emplaceBack(0,a.an),w.emplaceBack(a.an,a.an),this.debugBuffer=d.createVertexBuffer(w,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 I=new a.eH;I.emplaceBack(0,0,0,0),I.emplaceBack(a.an,0,a.an,0),I.emplaceBack(0,a.an,0,a.an),I.emplaceBack(a.an,a.an,a.an,a.an),this.mercatorBoundsBuffer=d.createVertexBuffer(I,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 H of[0,1,3,2,0])F.emplaceBack(H);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 Jr({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,Cr.disabled,this.stencilClearMode,Yr.disabled,Hr.disabled,T0(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs={})}_renderTileClippingMasks(d,g,w){if(!g||this.currentStencilSource===g.id||!d.isTileClipped()||!w||w.length===0)return;if(this._tileClippingMaskIDs&&!this.terrain){let F=!1;for(const z of w)if(this._tileClippingMaskIDs[z.key]===void 0){F=!0;break}if(!F)return}this.currentStencilSource=g.id;const j=this.context,I=j.gl;this.nextStencilID+w.length>256&&this.clearStencil(),j.setColorMode(Yr.disabled),j.setDepthMode(Cr.disabled);const L=this.getOrCreateProgram("clippingMask");this._tileClippingMaskIDs={};for(const F of w){const z=g.getTile(F),H=this._tileClippingMaskIDs[F.key]=this.nextStencilID++,{tileBoundsBuffer:Z,tileBoundsIndexBuffer:ne,tileBoundsSegments:re}=this.getTileBoundsBuffers(z);L.draw(this,I.TRIANGLES,Cr.disabled,new Jr({func:I.ALWAYS,mask:0},H,255,I.KEEP,I.KEEP,I.REPLACE),Yr.disabled,Hr.disabled,T0(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 Jr({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 Jr({func:g.EQUAL,mask:255},this._tileClippingMaskIDs[d.key],0,g.KEEP,g.KEEP,g.REPLACE)}stencilConfigForOverlap(d){const g=this.context.gl,w=d.sort((L,F)=>F.overscaledZ-L.overscaledZ),j=w[w.length-1].overscaledZ,I=w[0].overscaledZ-j+1;if(I>1){this.currentStencilSource=void 0,this.nextStencilID+I>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 w=a.o.now();this._dt=w-this._timeStamp,this._timeStamp=w,this._wireframeDebugCache.update(this.frameCounter),this._debugParams.continousRedraw=d.map.repaint,this.style=d,this.options=g;const j=this.style._mergedLayers,I=!(!this.terrain||!this.terrain.enabled),L=()=>this.style._getOrder(I).filter(lt=>{const tt=j[lt];return!(tt.type in this._debugParams.enabledLayers)||this._debugParams.enabledLayers[tt.type]});let F=L(),z=!1,H=!1,Z=null,ne=0,re=!1;for(const lt of F){const tt=j[lt];tt.visibility!=="none"&&(tt.type==="circle"?z=!0:tt.type==="building"?(Z=tt,++ne):tt.type==="symbol"&&(tt.hasOcclusionOpacityProperties?H=!0:z=!0))}this.updateEmissiveMode();let ie=F.map(lt=>j[lt]);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 lt in ce){const tt=ce[lt];tt.used&&(tt.prepare(this.context),tt.getSource().usedInConflation&&++ne)}let oe=!1;for(const lt of ie)lt.isHidden(this.transform.zoom)||(lt.type==="clip"&&(oe=!0),this.prepareLayer(lt));const xe={},ye={},Pe={},Me={},Se={};for(const lt in ce){const tt=ce[lt];xe[lt]=tt.getVisibleCoordinates(),ye[lt]=xe[lt].slice().reverse(),Pe[lt]=tt.getVisibleCoordinates(!0).reverse(),Me[lt]=tt.getShadowCasterCoordinates(),Se[lt]=tt.sortCoordinatesByDistance(xe[lt])}const Ze=lt=>{const tt=this.style.getLayerSourceCache(lt);return tt&&tt.used?tt.getSource():null};if(ne||oe||this._clippingActiveLastFrame){const lt=[],tt=[];let gt=0;for(const _t of ie)this.isSourceForClippingOrConflation(_t,Ze(_t))&&(lt.push(_t),tt.push(gt)),gt++;if(lt&&(oe||lt.length>1)||this._clippingActiveLastFrame){oe=!1;const _t=[];for(let Tt=0;Tt0){const _t=Ze(tt);_t&&(this.minCutoffZoom=Math.max(_t.minzoom,this.minCutoffZoom)),tt.minzoom&&(this.minCutoffZoom=Math.max(tt.minzoom,this.minCutoffZoom))}tt.is3D(I)&&(this.opaquePassCutoff===1/0&&(this.opaquePassCutoff=lt),this._lastOcclusionLayer=lt)}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(Pe),this.opaquePassCutoff=0,F=L(),ie=F.map(lt=>j[lt]));const Ke=this._shadowRenderer;if(Ke){Ke.updateShadowParameters(this.transform,this.style.directionalLight);for(const lt in ce)for(const tt of xe[lt]){let gt={min:0,max:0};this.terrain&&(gt=this.terrain.getMinMaxForTile(tt)||gt),Ke.addShadowReceiver(tt.toUnwrapped(),gt.min,gt.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 hI(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 vI(this)),!De&&this._snow&&(this._snow.destroy(),delete this._snow),Be&&!this._rain&&(this._rain=new D0(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 kh);const lt=this.style.getLayerSourceCache(Z);this.buildingTileBorderManager.updateBorders(lt,Z)}if(!yr.has(this.context.gl))return;this.renderPass="offscreen";for(const lt of ie){const tt=d.getLayerSourceCache(lt);if(!lt.hasOffscreenPass()||lt.isHidden(this.transform.zoom))continue;const gt=tt?ye[tt.id]:void 0;(lt.type==="custom"||lt.type==="raster"||lt.type==="raster-particle"||lt.isSky()||gt&>.length)&&this.renderLayer(this,tt,lt,gt)}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(),at=(()=>{if(g.showOverdrawInspector)return a.aq.black;const lt=this.style.fog;if(lt&&this.transform.projection.supportsFog){const tt=this.style.getLut(lt.scope);if(!Ge){const gt=lt.properties.get("color-use-theme")==="none",_t=lt.properties.get("color").toNonPremultipliedRenderColor(gt?null:tt).toArray01();return new a.aq(..._t)}if(Ge){const gt=lt.properties.get("space-color-use-theme")==="none",_t=lt.properties.get("space-color").toNonPremultipliedRenderColor(gt?null:tt).toArray01();return new a.aq(..._t)}}return a.aq.transparent})();if(this.context.clear({color:at,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 lt=ie[this.currentLayer],tt=d.getLayerSourceCache(lt);if(lt.isSky())continue;const gt=tt?(lt.is3D(I)?Se:ye)[tt.id]:void 0;this._renderTileClippingMasks(lt,tt,gt),this.renderLayer(this,tt,lt,gt)}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 gt=this.currentLayer;this.depthOcclusion=!0;for(const _t of this.layersWithOcclusionOpacity){this.currentLayer=_t;const Tt=ie[this.currentLayer],rr=d.getLayerSourceCache(Tt),Wt=rr?ye[rr.id]:void 0;this.terrain||this._renderTileClippingMasks(Tt,rr,rr?xe[rr.id]:void 0),this.renderLayer(this,rr,Tt,Wt)}this.depthOcclusion=!1,this.currentLayer=gt,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 lt=null;ie.forEach(tt=>{const gt=d.getLayerSourceCache(tt);gt&&!tt.isHidden(this.transform.zoom)&>.getVisibleCoordinates().length&&(!lt||lt.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,w){const j=w===void 0?this.terrain&&this.terrain.renderingToTexture:w,I=[];return this.style&&this.style.enable3dLights()&&(d==="globeRaster"||d==="terrainRaster"?(I.push("LIGHTING_3D_MODE"),I.push("LIGHTING_3D_ALPHA_EMISSIVENESS")):j||I.push("LIGHTING_3D_MODE")),this.terrainRenderModeElevated()&&(I.push("TERRAIN"),this.linearFloatFilteringSupported()&&I.push("TERRAIN_DEM_FLOAT_FORMAT")),this.transform.projection.name==="globe"&&I.push("GLOBE"),!this._fogVisible||j||g!==void 0&&!g||I.push("FOG"),j&&I.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&I.push("OVERDRAW_INSPECTOR"),I}getOrCreateProgram(d,g){this.cache=this.cache||{};const w=g&&g.defines||[],j=g&&g.config,I=this.currentGlobalDefines(d,g&&g.overrideFog,g&&g.overrideRtt).concat(w),L=np.cacheKey(CC[d],d,I,j);return this.cache[L]||(this.cache[L]=new np(this.context,d,CC[d],j,_b[d],I)),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 w=this.style.directionalLight,j=this.style.ambientLight;if(w&&j){const I=((L,F,z)=>{const H=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(),oe=F.properties.get("intensity"),xe=[H.x,H.y,H.z],ye=a.dD(ce,oe),Pe=a.dD(ne,re);return{u_lighting_ambient_color:ye,u_lighting_directional_dir:xe,u_lighting_directional_color:Pe,u_ground_radiance:SE(xe,Pe,ye)}})(w,j,this.style);g.setLightsUniformValues(d,I)}}}uploadCommonUniforms(d,g,w,j,I){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=((H,Z,ne,re,ie,ce,oe,xe,ye,Pe,Me,Se)=>{const Ze=H.transform,$e=Z.properties.get("color-use-theme")==="none",Ke=Z.properties.get("color").toNonPremultipliedRenderColor($e?null:H.style.getLut(Z.scope)).toArray01();Ke[3]=re;const De=H.frameCounter/1e3%1,[Be,Ge]=Z.properties.get("vertical-range");return{u_fog_matrix:ne?Ze.calculateFogTileMatrix(ne):Se||H.identityMat,u_fog_range:Z.getFovAdjustedRange(Ze._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:oe,u_frustum_bl:xe,u_globe_pos:ye,u_globe_radius:Pe,u_viewport:Me,u_globe_transition:a.al(Ze.zoom),u_is_globe:+(Ze.projection.name==="globe")}})(this,L,w,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)}I&&g.setCutoffUniformValues(d,I.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={},w=this.transform.coveringTiles({tileSize:512});for(const j of w)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]>=Ln||g[1]>=Ln}setupDepthForOcclusion(d,g,w){const j=this.context,I=j.gl,L=!!w;var F;w||(w={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(I.TEXTURE3),d&&this.depthFBO&&this.depthTexture?(this.depthTexture.bind(I.NEAREST,I.CLAMP_TO_EDGE),w.u_depth_size_inv=[1/this.depthFBO.width,1/this.depthFBO.height],w.u_depth_range_unpack=[2/((F=this.depthRangeFor3D)[1]-F[0]),-1-2*F[0]/(F[1]-F[0])],w.u_occluder_half_size=.5*this.occlusionParams.occluderSize,w.u_occlusion_depth_offset=this.occlusionParams.depthOffset):this.emptyDepthTexture.bind(I.NEAREST,I.CLAMP_TO_EDGE),j.activeTexture.set(I.TEXTURE0),L||g.setTerrainUniformValues(j,w)}updateEmissiveMode(){if(this._forceEmissiveMode)return;const d=this.style.hasDataDrivenEmissiveStrength();this.emissiveMode=d?this.context.extBlendFuncExtended?"dual-source-blending":"mrt-fallback":"constant"}}function ZE(_,d){let g=!1,w=null;const j=()=>{w=null,g&&(_(),w=setTimeout(j,d),g=!1)};return()=>(g=!0,w||j(),w)}class a5{constructor(d){this._hashName=d&&encodeURIComponent(d),a.aZ(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=ZE(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=nl(d);if(this._hashName){const w=this._hashName;let j=!1;const I=location.hash.slice(1).split("&").map(L=>{const F=L.split("=")[0];return F===w?(j=!0,`${F}=${g}`):L}).filter(L=>L);return j||I.push(`${w}=${g}`),`#${I.join("&")}`}return`#${g}`}_getCurrentHash(){const d=location.hash.replace("#","");if(this._hashName){let g;return d.split("&").map(w=>w.split("=")).forEach(w=>{w[0]===this._hashName&&(g=w)}),(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(w=>isNaN(Number(w)))){const w=d.dragRotate.isEnabled()&&d.touchZoomRotate.isEnabled()?+(g[3]||0):d.getBearing();return d.jumpTo({center:[+g[2],+g[1]],zoom:+g[0],bearing:w,pitch:+(g[4]||0)}),!0}return!1}_updateHashUnthrottled(){history.replaceState(history.state,"",location.href.replace(/(#.+)?$/,this.getHashString()))}}function nl(_,d){const g=_.getCenter(),w=Math.round(100*_.getZoom())/100,j=Math.ceil((w*Math.LN2+Math.log(512/360/.5))/Math.LN10),I=Math.pow(10,j),L=Math.round(g.lng*I)/I,F=Math.round(g.lat*I)/I,z=_.getBearing(),H=_.getPitch();let Z=d?`/${L}/${F}/${w}`:`${w}/${F}/${L}`;return(z||H)&&(Z+="/"+Math.round(10*z)/10),H&&(Z+=`/${Math.round(H)}`),Z}const Lb={linearity:.3,easing:a.eN(0,0,.3,1)},O0=Object.assign({deceleration:2500,maxSpeed:1400},Lb),o5=Object.assign({deceleration:20,maxSpeed:1400},Lb),Gs=Object.assign({deceleration:1e3,maxSpeed:360},Lb),Rn=Object.assign({deceleration:1e3,maxSpeed:90},Lb);class bI{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:I}of this._inertiaBuffer)g.zoom+=I.zoomDelta||0,g.bearing+=I.bearingDelta||0,g.pitch+=I.pitchDelta||0,I.panDelta&&g.pan._add(I.panDelta),I.around&&(g.around=I.around),I.pinchAround&&(g.pinchAround=I.pinchAround);const w=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,j={};if(g.pan.mag()){const I=Od(g.pan.mag(),w,Object.assign({},O0,d||{}));j.offset=g.pan.mult(I.amount/g.pan.mag()),j.center=this._map.transform.center,mc(j,I)}if(g.zoom){const I=Od(g.zoom,w,o5);j.zoom=this._map.transform.zoom+I.amount,mc(j,I)}if(g.bearing){const I=Od(g.bearing,w,Gs);j.bearing=this._map.transform.bearing+a.aC(I.amount,-179,179),mc(j,I)}if(g.pitch){const I=Od(g.pitch,w,Rn);j.pitch=this._map.transform.pitch+I.amount,mc(j,I)}if(j.zoom||j.bearing){const I=g.pinchAround===void 0?g.around:g.pinchAround;j.around=I?this._map.unproject(I):this._map.getCenter()}return this.clear(),j.noMoveStart=!0,j}}function mc(_,d){(!_.duration||_.durationg.unproject(z)),F=I.reduce((z,H,Z,ne)=>z.add(H.div(ne.length)),new a.P(0,0));super(d,{points:I,point:F,lngLats:L,lngLat:g.unproject(F),originalEvent:w}),this._defaultPrevented=!1}}class XE extends a.C{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(d,g){super("wheel",{originalEvent:g}),this._defaultPrevented=!1}}class QE{constructor(d,g){this._map=d,this._clickTolerance=g.clickTolerance}reset(){this._mousedownPos=void 0}wheel(d){return this._firePreventable(new XE(this._map,d))}mousedown(d,g){return this._mousedownPos=g,this._firePreventable(new Eo(d.type,this._map,d))}mouseup(d){this._map.fire(new Eo(d.type,this._map,d))}preclick(d){const g=new MouseEvent("preclick",d);this._map.fire(new Eo(g.type,this._map,g))}click(d,g){this._mousedownPos&&this._mousedownPos.dist(g)>=this._clickTolerance||(this.preclick(d),this._map.fire(new Eo(d.type,this._map,d)))}dblclick(d){return this._firePreventable(new Eo(d.type,this._map,d))}mouseover(d){this._map.fire(new Eo(d.type,this._map,d))}mouseout(d){this._map.fire(new Eo(d.type,this._map,d))}touchstart(d){return this._firePreventable(new Rc(d.type,this._map,d))}touchmove(d){this._map.fire(new Rc(d.type,this._map,d))}touchend(d){this._map.fire(new Rc(d.type,this._map,d))}touchcancel(d){this._map.fire(new Rc(d.type,this._map,d))}_firePreventable(d){if(this._map.fire(d),d.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class JE{constructor(d){this._map=d}reset(){this._delayContextMenu=!1,this._contextMenuEvent=void 0}mousemove(d){this._map.fire(new Eo(d.type,this._map,d))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new Eo("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(d){this._delayContextMenu?this._contextMenuEvent=d:this._map.fire(new Eo(d.type,this._map,d)),this._map.listens("contextmenu")&&d.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class ej{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&&(V(),this._startPos=this._lastPos=g,this._active=!0)}mousemoveWindow(d,g){if(!this._active)return;const w=g,j=this._startPos,I=this._lastPos;if(!j||!I||I.equals(w)||!this._box&&w.dist(j){this._box&&(this._box.style.transform=`translate(${L}px,${z}px)`,this._box.style.width=F-L+"px",this._box.style.height=H-z+"px")})}mouseupWindow(d,g){if(!this._active)return;const w=this._startPos,j=g;if(w&&d.button===0){if(this.reset(),Y(),w.x!==j.x||w.y!==j.y)return this._map.fire(new a.C("boxzoomend",{originalEvent:d})),{cameraAnimation:I=>I.fitScreenCoordinates(w,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),G(),delete this._startPos,delete this._lastPos}_fireEvent(d,g){return this._map.fire(new a.C(d,{originalEvent:g}))}}function F0(_,d){const g={};for(let w=0;w<_.length;w++)g[_[w].identifier]=d[w];return g}class xu{constructor(d){this.reset(),this.numTouches=d.numTouches}reset(){this.centroid=void 0,this.startTime=0,this.touches={},this.aborted=!1}touchstart(d,g,w){(this.centroid||w.length>this.numTouches)&&(this.aborted=!0),this.aborted||(this.startTime===0&&(this.startTime=d.timeStamp),w.length===this.numTouches&&(this.centroid=function(j){const I=new a.P(0,0);for(const L of j)I._add(L);return I.div(j.length)}(g),this.touches=F0(w,g)))}touchmove(d,g,w){if(this.aborted||!this.centroid)return;const j=F0(w,g);for(const I in this.touches){const L=j[I];(!L||L.dist(this.touches[I])>30)&&(this.aborted=!0)}}touchend(d,g,w){if((!this.centroid||d.timeStamp-this.startTime>500)&&(this.aborted=!0),w.length===0){const j=!this.aborted&&this.centroid;if(this.reset(),j)return j}}}class Fd{constructor(d){this.singleTap=new xu(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,w){this.singleTap.touchstart(d,g,w)}touchmove(d,g,w){this.singleTap.touchmove(d,g,w)}touchend(d,g,w){const j=this.singleTap.touchend(d,g,w);if(j){const I=d.timeStamp-this.lastTime<500,L=!this.lastTap||this.lastTap.dist(j)<30;if(I&&L||this.reset(),this.count++,this.lastTime=d.timeStamp,this.lastTap=j,this.count===this.numTaps)return this.reset(),j}}}class Jg{constructor(){this._zoomIn=new Fd({numTouches:1,numTaps:2}),this._zoomOut=new Fd({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(d,g,w){this._zoomIn.touchstart(d,g,w),this._zoomOut.touchstart(d,g,w)}touchmove(d,g,w){this._zoomIn.touchmove(d,g,w),this._zoomOut.touchmove(d,g,w)}touchend(d,g,w){const j=this._zoomIn.touchend(d,g,w),I=this._zoomOut.touchend(d,g,w);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})}):I?(this._active=!0,d.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:L=>L.easeTo({duration:300,zoom:L.getZoom()-1,around:L.unproject(I)},{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 Mb=0,tj=2,rj={[Mb]:1,[tj]:2},Ih={Control:"ctrlKey",Alt:"altKey",Shift:"shiftKey",Meta:"metaKey"};class B0{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 w=ee(d);this._correctButton(d,w)&&(this._lastPoint=g,this._eventButton=w)}mousemoveWindow(d,g){const w=this._lastPoint;if(w){if(d.preventDefault(),this._eventButton!=null&&function(j,I){const L=rj[I];return j.buttons===void 0||(j.buttons&L)!==L}(d,this._eventButton))this.reset();else if(this._moved||!(g.dist(w)0&&(this._active=!0);const j=F0(w,g),I=new a.P(0,0),L=new a.P(0,0);let F=0;for(const H in j){const Z=j[H],ne=this._touches[H];ne&&(I._add(Z),L._add(Z.sub(ne)),F++,j[H]=Z)}if(this._touches=j,F{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show"),this._alertContainer.removeAttribute("role")},500)}}class z0{constructor(){this.reset()}reset(){this._active=!1,this._firstTwoTouches=void 0}_start(d){}_move(d,g,w){return{}}touchstart(d,g,w){this._firstTwoTouches||w.length<2||(this._firstTwoTouches=[w[0].identifier,w[1].identifier],this._start([g[0],g[1]]))}touchmove(d,g,w){const j=this._firstTwoTouches;if(!j)return;d.preventDefault();const[I,L]=j,F=bi(w,g,I),z=bi(w,g,L);if(!F||!z)return;const H=this._aroundCenter?null:F.add(z).div(2);return this._move([F,z],H,d)}touchend(d,g,w){if(!this._firstTwoTouches)return;const[j,I]=this._firstTwoTouches,L=bi(w,g,j),F=bi(w,g,I);L&&F||(this._active&&Y(),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 bi(_,d,g){for(let w=0;w<_.length;w++)if(_[w].identifier===g)return d[w]}function Ob(_,d){return Math.log2(_/d)}class sj extends z0{reset(){super.reset(),this._distance=0,this._startDistance=0}_start(d){this._startDistance=this._distance=d[0].dist(d[1])}_move(d,g){const w=this._distance;if(this._distance=d[0].dist(d[1]),this._active||!(Math.abs(Ob(this._distance,this._startDistance))<.1))return this._active=!0,{zoomDelta:Ob(this._distance,w),pinchAround:g}}}function Fb(_,d){return 180*_.angleWith(d)/Math.PI}class up extends z0{reset(){super.reset(),this._minDiameter=0,this._startVector=void 0,this._vector=void 0}_start(d){this._startVector=this._vector=d[0].sub(d[1]),this._minDiameter=d[0].dist(d[1])}_move(d,g){const w=this._vector;if(this._vector=d[0].sub(d[1]),w&&(this._active||!this._isBelowThreshold(this._vector)))return this._active=!0,{bearingDelta:Fb(this._vector,w),pinchAround:g}}_isBelowThreshold(d){this._minDiameter=Math.min(this._minDiameter,d.mag());const g=25/(Math.PI*this._minDiameter)*360,w=this._startVector;if(!w)return!1;const j=Fb(d,w);return Math.abs(j)Math.abs(_.x)}class ij extends z0{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,U0(d[0].sub(d[1]))&&(this._valid=!1)}_move(d,g,w){const j=this._lastPoints;if(!j)return;const I=d[0].sub(j[0]),L=d[1].sub(j[1]);return this._map._cooperativeGestures&&!a.eO()&&w.touches.length<3||(this._valid=this.gestureBeginsVertically(I,L,w.timeStamp),!this._valid)?void 0:(this._lastPoints=d,this._active=!0,{pitchDelta:(I.y+L.y)/2*-.5})}gestureBeginsVertically(d,g,w){if(this._valid!==void 0)return this._valid;const j=d.mag()>=2,I=g.mag()>=2;if(!j&&!I)return;if(!j||!I)return this._firstMove==null&&(this._firstMove=w),w-this._firstMove<100&&void 0;const L=d.y>0==g.y>0;return U0(d)&&U0(g)&&L}}const aj={panStep:100,bearingStep:15,pitchStep:10};class dp{constructor(){const d=aj;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,w=0,j=0,I=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?w=-1:(d.preventDefault(),I=-1);break;case 39:d.shiftKey?w=1:(d.preventDefault(),I=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&&(w=0,j=0),{cameraAnimation:F=>{const z=F.getZoom();F.easeTo({duration:300,easeId:"keyboardHandler",easing:oj,zoom:g?Math.round(z)+g*(d.shiftKey?2:1):z,bearing:F.getBearing()+w*this._bearingStep,pitch:F.getPitch()+j*this._pitchStep,offset:[-I*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 oj(_){return _*(2-_)}const hp=4.000244140625,lj=1/450;class Bb{constructor(d,g){this._map=d,this._el=d.getCanvasContainer(),this._handler=g,this._delta=0,this._lastDelta=0,this._defaultZoomRate=.01,this._wheelZoomRate=lj,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 w=a.o.now(),j=w-(this._lastWheelEventTime||0);this._lastWheelEventTime=w,g!==0&&g%hp===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=J(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 H=this._type==="wheel"&&Math.abs(this._delta)>hp?this._wheelZoomRate:this._defaultZoomRate;let Z=2/(1+Math.exp(-Math.abs(this._delta*H)));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 w=typeof this._targetZoom=="number"?this._targetZoom:g(),j=this._startZoom,I=this._easing;let L,F=!1;if(this._type==="wheel"&&j&&I){const H=Math.min((a.o.now()-this._lastWheelEventTime)/200,1),Z=I(H);L=a.am(j,w,Z),H<1?this._frameId||(this._frameId=!0):F=!0}else L=w,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 w=this._prevEase,j=(a.o.now()-w.start)/w.duration,I=w.easing(j+.01)-w.easing(j),L=.27/Math.sqrt(I*I+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=R("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 $b{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 zb{constructor(){this.reset()}reset(){this._active=!1}blur(){this.reset()}dblclick(d,g){return d.preventDefault(),{cameraAnimation:w=>{w.easeTo({duration:300,zoom:w.getZoom()+(d.shiftKey?-1:1),around:w.unproject(g)},{originalEvent:d})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class wI{constructor(){this._tap=new Fd({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,w){this._swipePoint||(this._tapTime&&d.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?w.length>0&&(this._swipePoint=g[0],this._swipeTouch=w[0].identifier):this._tap.touchstart(d,g,w))}touchmove(d,g,w){if(this._tapTime){if(this._swipePoint){if(w[0].identifier!==this._swipeTouch)return;const j=g[0],I=j.y-this._swipePoint.y;return this._swipePoint=j,d.preventDefault(),this._active=!0,{zoomDelta:I/128}}}else this._tap.touchmove(d,g,w)}touchend(d,g,w){this._tapTime?this._swipePoint&&w.length===0&&this.reset():this._tap.touchend(d,g,w)&&(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 cj{constructor(d,g,w){this._el=d,this._mousePan=g,this._touchPan=w}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 SI{constructor(d,g,w){this._pitchWithRotate=d.pitchWithRotate,this._mouseRotate=g,this._mousePitch=w}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 TI{constructor(d,g,w,j){this._el=d,this._touchZoom=g,this._touchRotate=w,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 V0=_=>_.zoom||_.drag||_.pitch||_.rotate;class EI extends a.C{}class jI{constructor(){this.constants=[1,1,.01],this.radius=0}setup(d,g){const w=a.ax([],g,d);this.radius=a.ai(w[2]<0?a.eR([],w,this.constants):[w[0],w[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 w=a.bJ([],[0,0,1],a.bi(g,[0,0,1])),j=a.bJ([],a.ay([],[g[0],g[1],0]),this.radius),I=a.cT([],g,a.bJ([],a.ax([],a.cT([],j,w),g),2));g[0]=I[0],g[1]=I[1]}return g}}function q0(_){return _.panDelta&&_.panDelta.mag()||_.zoomDelta||_.bearingDelta||_.pitchDelta}class AI{constructor(d,g){this._map=d,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new bI(d),this._bearingSnap=g.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new jI,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(g),a.aZ(["handleEvent","handleWindowEvent"],this);const w=this._el;this._listeners=[[w,"touchstart",{passive:!0}],[w,"touchmove",{passive:!1}],[w,"touchend",void 0],[w,"touchcancel",void 0],[w,"mousedown",void 0],[w,"mousemove",void 0],[w,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[w,"mouseover",void 0],[w,"mouseout",void 0],[w,"dblclick",void 0],[w,"click",void 0],[w,"keydown",{capture:!1}],[w,"keyup",void 0],[w,"wheel",{passive:!1}],[w,"contextmenu",void 0],[window,"blur",void 0]];for(const[j,I,L]of this._listeners){const F=j===document?this.handleWindowEvent:this.handleEvent;j.addEventListener(I,F,L)}}destroy(){for(const[d,g,w]of this._listeners){const j=d===document?this.handleWindowEvent:this.handleEvent;d.removeEventListener(g,j,w)}}_addDefaultHandlers(d){const g=this._map,w=g.getCanvasContainer();this._add("mapEvent",new QE(g,d));const j=g.boxZoom=new ej(g,d);this._add("boxZoom",j);const I=new Jg,L=new zb;g.doubleClickZoom=new $b(L,I),this._add("tapZoom",I),this._add("clickZoom",L);const F=new wI;this._add("tapDragZoom",F);const z=g.touchPitch=new ij(g);this._add("touchPitch",z);const H=new Db(d),Z=new $0(d);g.dragRotate=new SI(d,H,Z),this._add("mouseRotate",H,["mousePitch"]),this._add("mousePitch",Z,["mouseRotate"]);const ne=new vu(d),re=new nj(g,d);g.dragPan=new cj(w,ne,re),this._add("mousePan",ne),this._add("touchPan",re,["touchZoom","touchRotate"]);const ie=new up,ce=new sj;g.touchZoomRotate=new TI(w,ce,ie,F),this._add("touchRotate",ie,["touchPan","touchZoom"]),this._add("touchZoom",ce,["touchPan","touchRotate"]),this._add("blockableMapEvent",new JE(g));const oe=g.scrollZoom=new Bb(g,this);this._add("scrollZoom",oe,["mousePan"]);const xe=g.keyboard=new dp;this._add("keyboard",xe);for(const ye of["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"])d.interactive&&d[ye]&&g[ye].enable(d[ye])}_add(d,g,w){this._handlers.push({handlerName:d,handler:g,allowed:w}),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!!V0(this._eventsInProgress)||this.isZooming()}_isDragging(){return!!this._eventsInProgress.drag}_blockedByActive(d,g,w){for(const j in d)if(j!==w&&(!g||g.indexOf(j)<0))return!0;return!1}handleWindowEvent(d){this.handleEvent(d,`${d.type}Window`)}_getMapTouches(d){const g=[];for(const w of d)this._el.contains(w.target)&&g.push(w);return g}handleEvent(d,g){this._updatingCamera=!0;const w=d.type==="renderFrame",j=w?void 0:d,I={needsRenderFrame:!1},L={},F={},z=d.touches?this._getMapTouches(d.touches):void 0,H=z?Q(this._el,z):w?void 0:J(this._el,d);for(const{handlerName:re,handler:ie,allowed:ce}of this._handlers){if(!ie.isEnabled())continue;let oe;this._blockedByActive(F,ce,re)?ie.reset():ie[g||d.type]&&(oe=ie[g||d.type](d,H,z),this.mergeHandlerResult(I,L,oe,re,j),oe&&oe.needsRenderFrame&&this._triggerRenderFrame()),(oe||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||q0(I))&&(this._changes.push([I,L,Z]),this._triggerRenderFrame()),(Object.keys(F).length||q0(I))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:ne}=I;ne&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],ne(this._map))}mergeHandlerResult(d,g,w,j,I){if(!w)return;Object.assign(d,w);const L={handlerName:j,originalEvent:w.originalEvent||I};w.zoomDelta!==void 0&&(g.zoom=L),w.panDelta!==void 0&&(g.drag=L),w.pitchDelta!==void 0&&(g.pitch=L),w.bearingDelta!==void 0&&(g.rotate=L)}_applyChanges(){const d={},g={},w={};for(const[j,I,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,I),Object.assign(w,L);this._updateMapTransform(d,g,w),this._changes=[]}_updateMapTransform(d,g,w){const j=this._map,I=j.transform,L=Pe=>[Pe.x,Pe.y,Pe.z];if((()=>{const Pe=this._eventsInProgress.drag;return Pe&&!this._handlersById[Pe.handlerName].isActive()})()&&!q0(d)){const Pe=I.zoom;I.cameraElevationReference="sea",this._originalZoom!=null&&I._orthographicProjectionAtLowPitch&&I.projection.name!=="globe"&&I.pitch===0?(I.cameraElevationReference="ground",I.zoom=this._originalZoom):(I.recenterOnTerrain(),I.cameraElevationReference="ground"),Pe!==I.zoom&&this._map._update(!0)}if(I._isCameraConstrained&&j._stop(!0),!q0(d))return void this._fireEvents(g,w,!0);let{panDelta:F,zoomDelta:z,bearingDelta:H,pitchDelta:Z,around:ne,aroundCoord:re,pinchAround:ie}=d;I._isCameraConstrained&&(z>0&&(z=0),I._isCameraConstrained=!1),ie!==void 0&&(ne=ie),(z||(Pe=>g[Pe]&&!this._eventsInProgress[Pe])("drag"))&&ne&&(this._dragOrigin=L(I.pointCoordinate3D(ne)),this._originalZoom=I.zoom,this._trackingEllipsoid.setup(I._camera.position,this._dragOrigin)),I.cameraElevationReference="sea",j._stop(!0),ne=ne||j.transform.centerPoint,H&&(I.bearing+=H),Z&&(I.pitch+=Z),I._updateCameraState();const ce=[0,0,0];if(F)if(I.projection.name==="mercator"){const Pe=this._trackingEllipsoid.projectRay(I.screenPointToMercatorRay(ne).dir),Me=this._trackingEllipsoid.projectRay(I.screenPointToMercatorRay(ne.sub(F)).dir);ce[0]=Me[0]-Pe[0],ce[1]=Me[1]-Pe[1]}else{const Pe=I.pointCoordinate(ne);if(I.projection.name==="globe"){F=F.rotate(-I.angle);const Me=I._pixelsPerMercatorPixel/I.worldSize;ce[0]=-F.x*a.eQ(a.bV(Pe.y))*Me,ce[1]=-F.y*a.eQ(I.center.lat)*Me}else{const Me=I.pointCoordinate(ne.sub(F));Pe&&Me&&(ce[0]=Me.x-Pe.x,ce[1]=Me.y-Pe.y)}}const oe=I.zoom,xe=[0,0,0];if(z){const Pe=L(re||I.pointCoordinate3D(ne)),Me={dir:a.ay([],a.ax([],Pe,I._camera.position))};if(Me.dir[2]<0){const Se=I.zoomDeltaToMovement(Pe,z);a.bJ(xe,Me.dir,Se)}}const ye=a.cT(ce,ce,xe);I._translateCameraConstrained(ye),z&&Math.abs(I.zoom-oe)>1e-4&&I.recenterOnTerrain(),I.cameraElevationReference="ground",this._map._update(),d.noInertia||this._inertia.record(d),this._fireEvents(g,w,!0)}_fireEvents(d,g,w){const j=V0(this._eventsInProgress),I=V0(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&&I&&this._fireEvent("movestart",I.originalEvent);for(const Z in L)this._fireEvent(Z,L[Z]);I&&this._fireEvent("move",I.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 H=V0(this._eventsInProgress);if(w&&(j||I)&&!H){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 EI("renderFrame",{timeStamp:d})),this._applyChanges()})}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}const uj="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class kI 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,w){return d=a.P.convert(d).mult(-1),this.panTo(this.transform.center,Object.assign({offset:d},g),w)}panTo(d,g,w){return this.easeTo(Object.assign({center:d},g),w)}getZoom(){return this.transform.zoom}setZoom(d,g){return this.jumpTo({zoom:d},g),this}zoomTo(d,g,w){return this.easeTo(Object.assign({zoom:d},g),w)}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,w){return this.easeTo(Object.assign({bearing:d},g),w)}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?w/(2*Math.tan(.5*d.fovX)*d.aspect):j/(2*Math.tan(.5*d.fovY)*d.aspect)}_cameraForBoundsOnGlobe(d,g,w,j,I,L){const F=d.clone(),z=this._extendCameraOptions(L);F.bearing=j,F.pitch=I;const H=a.aU.convert(g),Z=a.aU.convert(w),ne=.5*(H.lat+Z.lat),re=.5*(H.lng+Z.lng),ie=a.eT(ne,re),ce=a.ay([],ie),oe=a.ay([],a.bh([],ce,[0,1,0])),xe=a.bh([],oe,ce),ye=[oe[0],oe[1],oe[2],0,xe[0],xe[1],xe[2],0,ce[0],ce[1],ce[2],0,0,0,0,1],Pe=[ie,a.eT(H.lat,H.lng),a.eT(Z.lat,H.lng),a.eT(Z.lat,Z.lng),a.eT(H.lat,Z.lng),a.eT(ne,H.lng),a.eT(ne,Z.lng),a.eT(H.lat,re),a.eT(Z.lat,re)];let Me=a.cU.fromPoints(Pe.map(_t=>[a.bi(oe,_t),a.bi(xe,_t),a.bi(ce,_t)]));const Se=a.ah([],Me.center,ye);a.eU(Se)===0&&a.eV(Se,0,0,1),a.ay(Se,Se),a.bJ(Se,Se,a.aF),F.center=a.eW(Se);const Ze=F.getWorldToCameraMatrix(),$e=a.b7(new Float64Array(16),Ze);Me=a.cU.applyTransform(Me,a.aD([],Ze,ye));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(Se,Se,Ze);const De=.5*(Me.max[2]-Me.min[2]),Be=this._minimumAABBFrustumDistance(F,Me),Ge=a.bJ([],[0,0,1],De),at=a.cT(Ge,Se,Ge),Qe=Be+(F.pitch===0?0:a.bf(Se,at)),xt=F.globeCenterInViewSpace,ft=a.ax([],Se,[xt[0],xt[1],xt[2]]);a.ay(ft,ft),a.bJ(ft,ft,Qe);const Lt=a.cT([],Se,ft);a.ah(Lt,Lt,$e);const Bt=a.eD/a.aF,lt=a.ai(Lt),tt=a.bU(Math.max(lt*Bt-a.eD,Number.EPSILON),0),gt=Math.min(F.zoomFromMercatorZAdjusted(tt),z.maxZoom);return gt>.5*(a.cJ+a.cv)?(F.setProjection({name:"mercator"}),F.zoom=gt,this._cameraForBounds(F,g,w,j,I,L)):{center:F.center,zoom:gt,bearing:j,pitch:I}}_extendAABB(d,g,w,j){const I=.5*((w.padding.left||0)+(w.padding.right||0)),L=.5*((w.padding.top||0)+(w.padding.bottom||0)),F=L,z=I,H=I,Z=L,ne=g.width-(z+H),re=g.height-(F+Z),ie=a.ax([],d.max,d.min),ce=Math.min(ne/ie[0],re/ie[1]),oe=Math.min(g.scaleZoom(g.scale*ce),w.maxZoom);if(isNaN(oe))return null;const xe=g.scale/g.zoomScale(oe),ye=new a.cU([d.min[0]-z*xe,d.min[1]-Z*xe,d.min[2]],[d.max[0]+H*xe,d.max[1]+F*xe,d.max[2]]),Pe=(typeof w.offset.x=="number"&&typeof w.offset.y=="number"?new a.P(w.offset.x,w.offset.y):a.P.convert(w.offset)).rotate(-a.ap(j));return ye.center[0]-=Pe.x*xe,ye.center[1]+=Pe.y*xe,ye}queryTerrainElevation(d,g){const w=this.transform.elevation;return w?(g=Object.assign({},{exaggerated:!0},g),w.getAtPoint(a.ag.fromLngLat(d),null,g.exaggerated)):null}_cameraForBounds(d,g,w,j,I,L){if(d.projection.name==="globe")return this._cameraForBoundsOnGlobe(d,g,w,j,I,L);const F=d.clone(),z=this._extendCameraOptions(L);F.bearing=j,F.pitch=I;const H=a.aU.convert(g),Z=a.aU.convert(w),ne=new a.aU(H.lng,Z.lat),re=new a.aU(Z.lng,H.lat),ie=F.project(H),ce=F.project(Z),oe=this.queryTerrainElevation(H),xe=this.queryTerrainElevation(Z),ye=this.queryTerrainElevation(ne),Pe=this.queryTerrainElevation(re),Me=[[ie.x,ie.y,Math.min(oe||0,xe||0,ye||0,Pe||0)],[ce.x,ce.y,Math.max(oe||0,xe||0,ye||0,Pe||0)]];let Se=a.cU.fromPoints(Me);const Ze=F.getWorldToCameraMatrix(),$e=a.b7(new Float64Array(16),Ze);Se=a.cU.applyTransform(Se,Ze);const Ke=this._extendAABB(Se,F,z,j);if(!Ke)return void a.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");Se=Ke;const De=.5*a.ax([],Se.max,Se.min)[2],Be=this._minimumAABBFrustumDistance(F,Se),Ge=[0,0,1,0];a.aE(Ge,Ge,Ze),a.eX(Ge,Ge);const at=a.bJ([],Ge,Be+De),Qe=a.cT([],Se.center,at);a.ah(Se.center,Se.center,$e),a.ah(Qe,Qe,$e);const xt=F.unproject(new a.P(Se.center[0],Se.center[1])),ft=a.eY(F.projection,xt),Lt=Math.pow(2,ft),Bt=Math.min(F._zoomFromMercatorZ(Qe[2]*F.pixelsPerMeter*Lt/F.worldSize),z.maxZoom);return F.mercatorFromTransition&&Bt<.5*(a.cJ+a.cv)?(F.setProjection({name:"globe"}),F.zoom=Bt,this._cameraForBounds(F,g,w,j,I,L)):{center:xt,zoom:Bt,bearing:j,pitch:I}}fitBounds(d,g,w){const j=this.cameraForBounds(d,g);return this._fitInternal(j,g,w)}fitScreenCoordinates(d,g,w,j,I){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)),H=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(H),re=this.transform.pointLocation3D(new a.P(z.x,H.y)),ie=this.transform.pointLocation3D(new a.P(H.x,z.y)),ce=[Math.min(Z.lng,ne.lng,re.lng,ie.lng),Math.min(Z.lat,ne.lat,re.lat,ie.lat)],oe=[Math.max(Z.lng,ne.lng,re.lng,ie.lng),Math.max(Z.lat,ne.lat,re.lat,ie.lat)],xe=j&&j.pitch?j.pitch:this.getPitch(),ye=this._cameraForBounds(this.transform,ce,oe,w,xe,j);return this._fitInternal(ye,j,I)}_fitInternal(d,g,w){return d?(g=Object.assign(d,g)).linear?this.easeTo(g,w):this.flyTo(g,w):this}jumpTo(d,g){this.stop();const w=d.preloadOnly?this.transform.clone():this.transform;let j=!1,I=!1,L=!1;"zoom"in d&&w.zoom!==+d.zoom&&(j=!0,w.zoom=+d.zoom),d.center!==void 0&&(w.center=a.aU.convert(d.center)),"bearing"in d&&w.bearing!==+d.bearing&&(I=!0,w.bearing=+d.bearing),"pitch"in d&&w.pitch!==+d.pitch&&(L=!0,w.pitch=+d.pitch);const F=typeof d.padding=="number"?this._extendPadding(d.padding):d.padding;if(d.padding!=null&&!w.isPaddingEqual(F))if(d.retainPadding===!1){const z=w.clone();z.padding=F,w.setLocationAtPoint(w.center,z.centerPoint)}else w.padding=F;return d.preloadOnly?(this._preloadTiles(w),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)),I&&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(uj),this.transform.getFreeCameraOptions()}setFreeCameraOptions(d,g){const w=this.transform;if(!w.projection.supportsFreeCamera)return a.w(uj),this;this.stop();const j=w.zoom,I=w.pitch,L=w.bearing;w.setFreeCameraOptions(d);const F=j!==w.zoom,z=I!==w.pitch,H=L!==w.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)),H&&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 w=this.transform,j=this.getZoom(),I=this.getBearing(),L=this.getPitch(),F=this.getPadding(),z="zoom"in d?+d.zoom:j,H="bearing"in d?this._normalizeBearing(d.bearing,I):I,Z="pitch"in d?+d.pitch:L,ne=this._extendPadding(d.padding),re=a.P.convert(d.offset);let ie,ce,oe;if(w.projection.name==="globe"){const Ge=a.ag.fromLngLat(w.center),at=re.rotate(-w.angle);Ge.x+=at.x/w.worldSize,Ge.y+=at.y/w.worldSize;const Qe=Ge.toLngLat(),xt=a.aU.convert(d.center||Qe);this._normalizeCenter(xt),ie=w.centerPoint.add(at),ce=new a.P(Ge.x,Ge.y).mult(w.worldSize),oe=new a.P(a.aH(xt.lng),a.aL(xt.lat)).mult(w.worldSize).sub(ce)}else{ie=w.centerPoint.add(re);const Ge=w.pointLocation(ie),at=a.aU.convert(d.center||Ge);this._normalizeCenter(at),ce=w.project(Ge),oe=w.project(at).sub(ce)}const xe=w.zoomScale(z-j);let ye,Pe;d.around&&(ye=a.aU.convert(d.around),Pe=w.locationPoint(ye));const Me=this._zooming||z!==j,Se=this._rotating||I!==H,Ze=this._pitching||Z!==L,$e=!w.isPaddingEqual(ne),Ke=d.retainPadding===!1?w.clone():w,De=Ge=>at=>{if(Me&&(Ge.zoom=a.am(j,z,at)),Se&&(Ge.bearing=a.am(I,H,at)),Ze&&(Ge.pitch=a.am(L,Z,at)),$e&&(Ke.interpolatePadding(F,ne,at),ie=Ke.centerPoint.add(re)),ye)Ge.setLocationAtPoint(ye,Pe);else{const Qe=Ge.zoomScale(Ge.zoom-j),xt=z>j?Math.min(2,xe):Math.max(.5,xe),ft=Math.pow(xt,1-at),Lt=Ge.unproject(ce.add(oe.mult(at*ft)).mult(Qe));Ge.setLocationAtPoint(Ge.renderWorldCopies?Lt.wrap():Lt,ie)}return d.preloadOnly||this._fireMoveEvents(g),Ge};if(d.preloadOnly){const Ge=this._emulate(De,d.duration,w);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=Se,this._pitching=Ze,this._padding=$e,this._easeId=d.easeId,this._prepareEase(g,d.noMoveStart,Be),this._ease(De(w),Ge=>{w.cameraElevationReference==="sea"&&w.recenterOnTerrain(),this._afterEase(g,Ge)},d),this}_prepareEase(d,g,w={}){this._moving=!0,this.transform.cameraElevationReference="sea",this.transform._orthographicProjectionAtLowPitch&&this.transform.pitch===0&&this.transform.projection.name!=="globe"&&(this.transform.cameraElevationReference="ground"),g||w.moving||this.fire(new a.C("movestart",d)),this._zooming&&!w.zooming&&this.fire(new a.C("zoomstart",d)),this._rotating&&!w.rotating&&this.fire(new a.C("rotatestart",d)),this._pitching&&!w.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 w=this._zooming,j=this._rotating,I=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,w&&this.fire(new a.C("zoomend",d)),j&&this.fire(new a.C("rotateend",d)),I&&this.fire(new a.C("pitchend",d)),this.fire(new a.C("moveend",d))}flyTo(d,g){if(this._prefersReducedMotion(d)){const _t=a.aJ(d,["center","zoom","bearing","pitch","around","padding","retainPadding"]);return this.jumpTo(_t,g)}this.stop(),d=Object.assign({offset:[0,0],speed:1.2,curve:1.42,easing:a.eP},d);const w=this.transform,j=this.getZoom(),I=this.getBearing(),L=this.getPitch(),F=this.getPadding(),z="zoom"in d?a.aC(+d.zoom,w.minZoom,w.maxZoom):j,H="bearing"in d?this._normalizeBearing(d.bearing,I):I,Z="pitch"in d?+d.pitch:L,ne=this._extendPadding(d.padding),re=w.zoomScale(z-j),ie=a.P.convert(d.offset);let ce=w.centerPoint.add(ie);const oe=w.pointLocation(ce),xe=a.aU.convert(d.center||oe);this._normalizeCenter(xe);const ye=w.project(oe),Pe=w.project(xe).sub(ye);let Me=d.curve;const Se=Math.max(w.width,w.height),Ze=Se/re,$e=Pe.mag();if("minZoom"in d){const _t=a.aC(Math.min(d.minZoom,j,z),w.minZoom,w.maxZoom),Tt=Se/w.zoomScale(_t-j);Me=Math.sqrt(Tt/$e*2)}const Ke=Me*Me;function De(_t){const Tt=(Ze*Ze-Se*Se+(_t?-1:1)*Ke*Ke*$e*$e)/(2*(_t?Ze:Se)*Ke*$e);return Math.log(Math.sqrt(Tt*Tt+1)-Tt)}function Be(_t){return(Math.exp(_t)-Math.exp(-_t))/2}function Ge(_t){return(Math.exp(_t)+Math.exp(-_t))/2}const at=De(0);let Qe=function(_t){return Ge(at)/Ge(at+Me*_t)},xt=function(_t){return Se*((Ge(at)*(Be(Tt=at+Me*_t)/Ge(Tt))-Be(at))/Ke)/$e;var Tt},ft=(De(1)-at)/Me;if(Math.abs($e)<1e-6||!isFinite(ft)){if(Math.abs(Se-Ze)<1e-6)return this.easeTo(d,g);const _t=Zed.maxDuration&&(d.duration=0);const Lt=I!==H,Bt=Z!==L,lt=!w.isPaddingEqual(ne),tt=d.retainPadding===!1?w.clone():w,gt=_t=>Tt=>{const rr=Tt*ft,Wt=1/Qe(rr);_t.zoom=Tt===1?z:j+_t.scaleZoom(Wt),Lt&&(_t.bearing=a.am(I,H,Tt)),Bt&&(_t.pitch=a.am(L,Z,Tt)),lt&&(tt.interpolatePadding(F,ne,Tt),ce=tt.centerPoint.add(ie));const Kt=Tt===1?xe:_t.unproject(ye.add(Pe.mult(xt(rr))).mult(Wt));return _t.setLocationAtPoint(_t.renderWorldCopies?Kt.wrap():Kt,ce),_t._updateCameraOnTerrain(),d.preloadOnly||this._fireMoveEvents(g),_t};if(d.preloadOnly){const _t=this._emulate(gt,d.duration,w);return this._preloadTiles(_t),this}return this._zooming=!0,this._rotating=Lt,this._pitching=Bt,this._padding=lt,this._prepareEase(g,!1),this._ease(gt(w),()=>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 w=this._onEaseEnd;this._onEaseEnd=void 0,w.call(this,g)}if(!d){const w=this.handlers;w&&w.stop(!1)}return this}_ease(d,g,w){w.animate===!1||w.duration===0?(d(1),g()):(this._easeStart=a.o.now(),this._easeOptions=w,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 w=Math.abs(d-g);return Math.abs(d-360-g)180?-360:w<-180?360:0}_prefersReducedMotion(d){return this._respectPrefersReducedMotion&&a.o.prefersReducedMotion&&!(d&&d.essential)}_emulate(d,g,w){const j=Math.ceil(15*g/1e3),I=[],L=d(w.clone());for(let F=0;F<=j;F++){const z=L(F/j);I.push(z.clone())}return I}_preloadTiles(d,g){}}class dj{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,w=d._getUIString("AttributionControl.ToggleAttribution");this._map=d,this._container=R("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=R("button","mapboxgl-ctrl-attrib-button",this._container),this._compactButton.type="button",this._compactButton.addEventListener("click",this._toggleAttribution),this._compactButton.setAttribute("aria-label",w);const j=R("span","mapboxgl-ctrl-icon",this._compactButton);return j.setAttribute("aria-hidden","true"),j.setAttribute("title",w),this._innerContainer=R("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 w=g.reduce((j,I,L)=>(I.value&&(j+=`${I.key}=${I.value}${Lj.length-I.length),d=d.filter((j,I)=>{for(let L=I+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 w=d.map(j=>function(I){const L=new DOMParser().parseFromString(I,"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 H=F.getAttribute("href");if(!H||!/^(https?:|mailto:)/i.test(H))return void F.replaceWith(L.createTextNode(z));const Z=L.createElement("a");Z.href=H,Z.textContent=z,Z.rel="noopener nofollow";const ne=F.getAttribute("class");ne&&(Z.className=ne),F.replaceWith(Z)}),L.body.innerHTML}(j)).join(" | ");w!==this._attribHTML&&(this._attribHTML=w,d.length?(this._innerContainer.innerHTML=w,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 hj{constructor(){a.aZ(["_updateLogo","_updateCompact"],this)}onAdd(d){this._map=d,this._container=R("div","mapboxgl-ctrl");const g=R("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 w=d[g].getSource();if(w.hasOwnProperty("mapbox_logo")&&!w.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 NI{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,w=g?this._queue.concat(g):this._queue;for(const j of w)if(j.id===d)return void(j.cancelled=!0)}run(d=0){const g=this._currentlyRunning=this._queue;this._queue=[];for(const w of g)if(!w.cancelled&&(w.callback(d),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}class l5{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,w){this._start=this.getValue(g),this._end=d,this._startTime=g,this._endTime=g+w}}const c5={"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 Cs extends a.C{constructor(d,g,w,j){const{point:I,lngLat:L,originalEvent:F,target:z}=d;super(d.type,{point:I,lngLat:L,originalEvent:F,target:z}),this.preventDefault=()=>{d.preventDefault()},this.id=g,this.interaction=w,this.feature=j}}class Ub{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 w=g.filter;let j=g.type;w&&this.filters.set(d,a.dg(w)),j==="mouseover"&&(j="mouseenter"),j==="mouseout"&&(j="mouseleave");const I=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)):I.size===0&&this.map.on(j,this.handleType),I.size===0&&this.interactionsByType.set(j,I),I.set(d,g),this.typeById.set(d,j)}get(d){const g=this.typeById.get(d);if(!g)return;const w=this.interactionsByType.get(g);return w?w.get(d):void 0}remove(d){const g=this.typeById.get(d);if(!g)return;this.typeById.delete(d),this.filters.delete(d);const w=this.interactionsByType.get(g);w&&(w.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))):w.size===0&&this.map.off(g,this.handleType))}queryTargets(d,g){const w=[];for(const[j,I]of g)I.target&&w.push({targetId:j,target:I.target,filter:this.filters.get(j)});return this.map.style.queryRenderedTargets(d,w,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 w=new Map;for(const[j,{feature:I}]of this.prevHoveredFeatures)this.hoveredFeatures.has(j)||w.set(I.id,I);w.size&&(d.type="mouseleave",this.handleType(d,Array.from(w.values())))}handleOut(d){const g=Array.from(this.hoveredFeatures.values()).map(({feature:w})=>w);g.length&&(d.type="mouseleave",this.handleType(d,g)),this.hoveredFeatures.clear()}handleType(d,g){const w=d.type==="mouseenter";if(w&&!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(),I=!!g;g=g||this.queryTargets(d.point,j);let L=!1;const F=new Set;for(const z of g){for(const[H,Z]of j){if(!Z.target)continue;const ne=z.variants?z.variants[H]:null;if(ne){for(const re of ne){if(Pd(re,z,F,H))continue;const ie=new a.di(z,re),ce=HT(re,z,H);I&&ie.id!==void 0&&(ie.state=this.map.getFeatureState(ie));const oe=w?this.prevHoveredFeatures.get(ce):null,xe=new Cs(d,H,Z,ie),ye=oe?oe.stop:Z.handler(xe);if(w&&this.hoveredFeatures.set(ce,{feature:z,stop:ye}),ye!==!1){L=!0;break}}if(L)break}}if(L)break}if(!L)for(const[z,H]of j){const{handler:Z,target:ne}=H;if(!ne&&Z(new Cs(d,z,H,null))!==!1)break}}}function u5(_,d){if(Array.isArray(_)&&Array.isArray(d)){const g=new Set(_),w=new Set(d);return g.size===w.size&&_.every(j=>w.has(j))}return a.b6(_,d)}const d5={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},h5={showCompass:!0,showZoom:!0,visualizePitch:!1};class G0{constructor(d,g,w=!1){this._clickTolerance=10,this.element=g,this.mouseRotate=new Db({clickTolerance:d.dragRotate._mouseRotate._clickTolerance}),this.map=d,w&&(this.mousePitch=new $0({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),V()}move(d,g){const w=this.map,j=this.mouseRotate.mousemoveWindow(d,g),I=j&&j.bearingDelta;if(I&&w.setBearing(w.getBearing()+I),this.mousePitch){const L=this.mousePitch.mousemoveWindow(d,g),F=L&&L.pitchDelta;F&&w.setPitch(w.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(){G(),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()}),J(this.element,d)),window.addEventListener("mousemove",this.mousemove),window.addEventListener("mouseup",this.mouseup)}mousemove(d){this.move(d,J(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=Q(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=Q(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(w).distSqr(d)180;){const w=g.locationPoint3D(_);if(w.x>=0&&w.y>=0&&w.x<=g.width&&w.y<=g.height)break;_.lng>g.center.lng?_.lng-=360:_.lng+=360}return _}const H0={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%)"},Lc={rotation:0,rotationAlignment:"auto",pitchAlignment:"auto",occludedOpacity:.2,altitude:0};class _u 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:w="center",color:j="#3FB1CE",scale:I=1,draggable:L=!1,clickTolerance:F=0,rotation:z=Lc.rotation,rotationAlignment:H=Lc.rotationAlignment,pitchAlignment:Z=Lc.pitchAlignment,occludedOpacity:ne=Lc.occludedOpacity,altitude:re=Lc.altitude}=d||{};this._anchor=w,this._color=j,this._scale=I,this._draggable=L,this._clickTolerance=F,this._rotation=z,this._rotationAlignment=H,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",oe=>{oe.preventDefault()}),this._element.addEventListener("mousedown",oe=>{oe.preventDefault()});const ie=this._element.classList;for(const oe in H0)ie.remove(`mapboxgl-marker-anchor-${oe}`);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=R("div"),g=P("svg",{display:"block",height:41*this._scale+"px",width:27*this._scale+"px",viewBox:"0 0 27 41"},d);if(this._altitude===0){const w=P("radialGradient",{id:"shadowGradient"},P("defs",{},g));P("stop",{offset:"10%","stop-opacity":.4},w),P("stop",{offset:"100%","stop-opacity":.05},w),P("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},g)}return P("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),P("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),P("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||Lc.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,w=d.charCode||d.keyCode;g!=="Space"&&g!=="Enter"&&w!==32&&w!==13||this.togglePopup()}_onMapClick(d){const g=d.originalEvent.target,w=this._element;this._popup&&(g===w||w.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 w=d.unproject(g,this._altitude),j=d.getFreeCameraOptions();if(!j.position)return!1;const I=j.position.toLngLat();return I.distanceTo(w)<.9*I.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 w=d.unproject(g,this._altitude);let j;d._showingGlobe()&&a.e$(d.transform,this._lngLat)?j=0:(j=1-d._queryFogOpacity(w),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) ${H0[this._anchor]} ${this._calculateXYTransform()} ${this._calculateZTransform()} translate(${g.x}px,${g.y}px) `}_calculateXYTransform(){const d=this._pos,g=this._map,w=this.getPitchAlignment();if(!g||!d||w!=="map")return"";if(!g._showingGlobe()){const z=g.getPitch();return z?`rotateX(${z}deg)`:""}const j=a.cH(a.f0(g.transform,this._lngLat)),I=d.sub(a.f1(g.transform)),L=Math.abs(I.x)+Math.abs(I.y);if(L===0)return"";const F=j/L;return`rotateX(${-I.y*F}deg) rotateY(${I.x*F}deg)`}_calculateZTransform(){const d=this._pos,g=this._map;if(!g||!d)return"";let w=0;const j=this.getRotationAlignment();if(j==="map")if(g._showingGlobe()){const I=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(I);w=a.cH(Math.atan2(L.y,L.x))-90}else w=-g.getBearing();else if(j==="horizon"){const I=a.aj(4,6,g.getZoom()),L=a.f1(g.transform);L.y+=I*g.transform.height;const F=d.sub(L),z=a.cH(Math.atan2(F.y,F.x));w=(z>90?z-270:z+90)*(1-I)}return w+=this._rotation,w?`rotateZ(${w}deg)`:""}_update(d){cancelAnimationFrame(this._updateFrameId);const g=this._map;g&&(g.transform.renderWorldCopies&&(this._lngLat=fj(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 w=this._pointerdownPos,j=this._positionDelta;if(w&&j){if(!this._isDragging){const I=this._clickTolerance||g._clickTolerance;if(d.point.dist(w)_.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(_.minPitch!=null&&_.maxPitch!=null&&_.minPitch>_.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(_.minPitch!=null&&_.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(_.maxPitch!=null&&_.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");_.antialias&&a.eZ(window)&&(_.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 h0(_.minZoom,_.maxZoom,_.minPitch,_.maxPitch,_.renderWorldCopies,null,null),_),this._repaint=!!_.repaint,this._interactive=_.interactive,this._minTileCacheSize=_.minTileCacheSize,this._maxTileCacheSize=_.maxTileCacheSize,this._failIfMajorPerformanceCaveat=_.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=_.preserveDrawingBuffer,this._antialias=_.antialias,this._trackResize=_.trackResize,this._bearingSnap=_.bearingSnap,this._refreshExpiredTiles=_.refreshExpiredTiles,this._fadeDuration=_.fadeDuration,this._isInitialLoad=!0,this._crossSourceCollisions=_.crossSourceCollisions,this._collectResourceTiming=_.collectResourceTiming,this._language=this._parseLanguage(_.language),this._worldview=_.worldview,this._renderTaskQueue=new NI,this._domRenderTaskQueue=new NI,this._controls=[],this._markers=[],this._popups=[],this._mapId=a.r(),this._locale=Object.assign({},c5,_.locale),this._clickTolerance=_.clickTolerance,this._cooperativeGestures=_.cooperativeGestures,this._performanceMetricsCollection=_.performanceMetricsCollection,this._tessellationStep=_.tessellationStep,this._containerWidth=0,this._containerHeight=0,this._showParseStatus=!0,this._precompilePrograms=_.precompilePrograms,this._averageElevationLastSampledAt=-1/0,this._averageElevationExaggeration=0,this._averageElevation=new l5(0),this._interactionRange=[1/0,-1/0],this._visibilityHidden=0,this._useExplicitProjection=!1,this._frameId=0,this._scaleFactor=_.scaleFactor,this._requestManager=new Ae(_.transformRequest,_.accessToken,_.testMode);const g=je(_.accessToken||a.g.ACCESS_TOKEN);if(g&&"atlas"in g&&typeof g.atlas=="number"&&(this._tokenExpiration=g.atlas),this._silenceAuthErrors=!!_.testMode,this._contextCreateOptions=_.contextCreateOptions?Object.assign({},_.contextCreateOptions):{},typeof _.container=="string"){const w=document.getElementById(_.container);if(!w)throw new Error(`Container '${_.container.toString()}' not found.`);this._container=w}else{if(!(_.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=_.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."),_.maxBounds&&this.setMaxBounds(_.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 AI(this,_),this._localFontFamily=_.localFontFamily,this._localIdeographFontFamily=_.localIdeographFontFamily,this._useServerFontComposition=_.useServerFontComposition,(_.style||!_.testMode)&&this.setStyle(_.style||a.g.DEFAULT_STYLE,{config:_.config,localFontFamily:this._localFontFamily,localIdeographFontFamily:this._localIdeographFontFamily,useServerFontComposition:this._useServerFontComposition}),_.projection&&this.setProjection(_.projection),_.hash&&(this._hash=new a5(typeof _.hash=="string"&&_.hash||void 0).addTo(this)),!this._hash||!this._hash._onHashChange()){d.center==null&&d.zoom==null||(this.transform._unmodified=!1),this.jumpTo({center:_.center,zoom:_.zoom,bearing:_.bearing,pitch:_.pitch});const w=_.bounds;w&&(this.resize(),this.fitBounds(w,Object.assign({},_.fitBoundsOptions,{duration:0})))}this.resize(),_.attributionControl&&this.addControl(new dj({customAttribution:_.customAttribution})),this._logoControl=new hj,this.addControl(this._logoControl,_.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet),this._postStyleLoadEvent(),this._postStyleWithAppearanceEvent()}),this.on("data",w=>{this._update(w.dataType==="style"),this.fire(new a.C(`${w.dataType}data`,w))}),this.on("dataloading",w=>{this.fire(new a.C(`${w.dataType}dataloading`,w))}),this._interactions=new Ub(this)}_getMapId(){return this._mapId}addControl(_,d){if(d===void 0&&(d=_.getDefaultPosition?_.getDefaultPosition():"top-right"),!_||!_.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=_.onAdd(this);this._controls.push(_);const w=this._controlPositions[d];return d.indexOf("bottom")!==-1?w.insertBefore(g,w.firstChild):w.appendChild(g),this}removeControl(_){if(!_||!_.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(_);return d>-1&&this._controls.splice(d,1),_.onRemove(this),this}hasControl(_){return this._controls.indexOf(_)>-1}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}resize(_){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",_)).fire(new a.C("move",_)),this.fire(new a.C("resize",_)),d&&this.fire(new a.C("moveend",_)),this}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(_){return this.transform.setMaxBounds(a.aK.convert(_)),this._update()}setMinZoom(_){if((_=_??-2)>=-2&&_<=this.transform.maxZoom)return this.transform.minZoom=_,this._update(),this.getZoom()<_?this.setZoom(_):this.fire(new a.C("zoomstart")).fire(new a.C("zoom")).fire(new a.C("zoomend")),this;throw new Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this.transform.minZoom}setMaxZoom(_){if((_=_??22)>=this.transform.minZoom)return this.transform.maxZoom=_,this._update(),this.getZoom()>_?this.setZoom(_):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(_){if((_=_??0)<0)throw new Error("minPitch must be greater than or equal to 0");if(_>=0&&_<=this.transform.maxPitch)return this.transform.minPitch=_,this._update(),this.getPitch()<_?this.setPitch(_):this.fire(new a.C("pitchstart")).fire(new a.C("pitch")).fire(new a.C("pitchend")),this;throw new Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this.transform.minPitch}setMaxPitch(_){if((_=_??85)>85)throw new Error("maxPitch must be less than or equal to 85");if(_>=this.transform.minPitch)return this.transform.maxPitch=_,this._update(),this.getPitch()>_?this.setPitch(_):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(_){return this._scaleFactor=_,this.painter.scaleFactor=_,this.style&&this.style._setLabelPlacementStale(),this.style._updateFilteredLayers(d=>d.type==="symbol"),this._update(!0),this}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(_){return this.transform.renderWorldCopies=_,this.transform.renderWorldCopies||this._forceMarkerAndPopupUpdate(!0),this._update()}getLanguage(){return this._language}_parseLanguage(_){return _==="auto"?navigator.language:Array.isArray(_)?_.length===0?void 0:_.map(d=>d==="auto"?navigator.language:d):_}setLanguage(_){const d=this._parseLanguage(_);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(_){return this.style&&_!==this._worldview?(this._worldview=_,this._styleDirty=!0,this.style.setWorldview(_),this):this}getProjection(){return this.transform.mercatorFromTransition?{name:"globe",center:[0,0]}:this.transform.getProjection()}_showingGlobe(){return this.transform.projection.name==="globe"}setProjection(_){return this._lazyInitEmptyStyle(),_?typeof _=="string"&&(_={name:_}):_=null,this._useExplicitProjection=!!_,this._prioritizeAndUpdateProjection(_,this.style.projection)}_updateProjectionTransition(){if(this.getProjection().name!=="globe")return;const _=this.transform,d=_.projection.name;let g;d==="globe"&&_.zoom>=a.cv?(_.setMercatorFromTransition(),g=!0):d==="mercator"&&_.zoom=a.cv?this.transform.setMercatorFromTransition():this.transform.setProjection(_),this.style.applyProjectionUpdate();const w=this.transform.getProjection().name==="mercator"&&g!==this.transform.mercatorFromTransition;return(d||w)&&(this.painter.clearBackgroundTiles(),this.style.clearSources(),this._update(!0),this._forceMarkerAndPopupUpdate(!0)),this}project(_,d){return this.transform.locationPoint3D(a.aU.convert(_),d)}unproject(_,d){return this.transform.pointLocation3D(a.P.convert(_),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(_,d,g){const w=j=>{let I=[];if(Array.isArray(d)){const L=d.filter(F=>this.getLayer(F));I=L.length?this.queryRenderedFeatures(j,{layers:L}):[]}else I=this.queryRenderedFeatures(j,{target:d});return I};if(_==="mouseenter"||_==="mouseover"){let j=!1;return{listener:g,targets:d,delegates:{mousemove:L=>{const F=w(L.point);F.length?j||(j=!0,g.call(this,new Eo(_,this,L.originalEvent,{features:F}))):j=!1},mouseout:()=>{j=!1}}}}if(_==="mouseleave"||_==="mouseout"){let j=!1;return{listener:g,targets:d,delegates:{mousemove:F=>{w(F.point).length?j=!0:j&&(j=!1,g.call(this,new Eo(_,this,F.originalEvent)))},mouseout:F=>{j&&(j=!1,g.call(this,new Eo(_,this,F.originalEvent)))}}}}{const j=I=>{const L=w(I.point);L.length&&(I.features=L,g.call(this,I),delete I.features)};return{listener:g,targets:d,delegates:{[_]:j}}}}on(_,d,g){if(typeof d=="function"||g===void 0)return super.on(_,d);if(typeof d=="string"&&(d=[d]),!this._areTargetsValid(d))return this;const w=this._createDelegatedListener(_,d,g);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[_]=this._delegatedListeners[_]||[],this._delegatedListeners[_].push(w);for(const j in w.delegates)this.on(j,w.delegates[j]);return this}once(_,d,g){if(typeof d=="function"||g===void 0)return super.once(_,d);if(typeof d=="string"&&(d=[d]),!this._areTargetsValid(d))return this;const w=this._createDelegatedListener(_,d,g);for(const j in w.delegates)this.once(j,w.delegates[j]);return this}off(_,d,g){if(typeof d=="function"||g===void 0)return super.off(_,d);if(typeof d=="string"&&(d=[d]),!this._areTargetsValid(d))return this;const w=this._delegatedListeners?this._delegatedListeners[_]:void 0;return w&&(j=>{for(let I=0;I{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(_,d)}else w&&this._update(!0)},()=>this._postStyleLoadEvent()),this):(this._localIdeographFontFamily=d.localIdeographFontFamily,this._localFontFamily=d.localFontFamily,this._updateStyle(_,d))}_getUIString(_){const d=this._locale[_];if(d==null)throw new Error(`Missing UI string '${_}'`);return d}_updateStyle(_,d){if(this.style&&(this.style.setEventedParent(null),this.style._remove(),this.style=void 0),_){const g=Object.assign({},d);d&&d.config&&(g.initialConfig=d.config,delete g.config),this.style=new yu(this,g).load(_),this.style.setEventedParent(this,{style:this.style})}return this._updateTerrain(),this}_lazyInitEmptyStyle(){this.style||(this.style=new yu(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(_){return _==null?(this.fire(new a.B(new Error("IDs can't be empty."))),!1):!a.db(_)||(this.fire(new a.B(new Error(`IDs can't contain special symbols: "${_}".`))),!1)}_isTargetValid(_){return"featuresetId"in _?this._isValidId("importId"in _?_.importId:_.featuresetId):"layerId"in _&&this._isValidId(_.layerId)}_areTargetsValid(_){if(Array.isArray(_)){for(const d of _)if(!this._isValidId(d))return!1;return!0}return this._isTargetValid(_)}addSource(_,d){return this._isValidId(_)?(this._lazyInitEmptyStyle(),this.style.addSource(_,d),this._update(!0)):this}isSourceLoaded(_){return!!this._isValidId(_)&&!!this.style&&this.style._isSourceCacheLoaded(_)}areTilesLoaded(){return this.style.areTilesLoaded()}addSourceType(_,d,g){this._lazyInitEmptyStyle(),this.style.addSourceType(_,d,g)}removeSource(_){return this._isValidId(_)?(this.style.removeSource(_),this._updateTerrain(),this._update(!0)):this}getSource(_){return this._isValidId(_)?this.style.getOwnSource(_):null}addImage(_,d,{pixelRatio:g=1,sdf:w=!1,stretchX:j,stretchY:I,content:L}={}){this._lazyInitEmptyStyle();const F=a.I.from(_);if(d instanceof HTMLImageElement||ImageBitmap&&d instanceof ImageBitmap){const{width:z,height:H,data:Z}=a.o.getImageData(d);this.style.addImage(F,{data:new a.q({width:z,height:H},Z),pixelRatio:g,stretchX:j,stretchY:I,content:L,sdf:w,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:H}=d,Z=d;this.style.addImage(F,{data:new a.q({width:z,height:H},new Uint8Array(Z.data)),pixelRatio:g,stretchX:j,stretchY:I,content:L,sdf:w,usvg:!1,version:0,userImage:Z}),Z.onAdd&&Z.onAdd(this,_)}}updateImage(_,d){this._lazyInitEmptyStyle();const g=a.I.from(_),w=this.style.getImage(g);if(!w)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:I,height:L,data:F}=j;if(I===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(I!==(w.usvg?w.icon.usvg_tree.width:w.data.width)||L!==(w.usvg?w.icon.usvg_tree.height:w.data.height))return void this.fire(new a.B(new Error(`The width and height of the updated image (${I}, ${L}) must be that same as the previous version of the image (${w.data.width}, ${w.data.height})`)));const z=!(d instanceof HTMLImageElement||ImageBitmap&&d instanceof ImageBitmap);let H=!1;w.usvg?(w.data=new a.q({width:I,height:L},new Uint8Array(F)),w.usvg=!1,w.icon=void 0,H=!0):w.data.replace(F,z),this.style.updateImage(g,w,H)}hasImage(_){return _?!!this.style&&!!this.style.getImage(a.I.from(_)):(this.fire(new a.B(new Error("Missing required image id"))),!1)}removeImage(_){this.style.removeImage(a.I.from(_))}loadImage(_,d){a.n(this._requestManager.transformRequest(_,a.R.Image),(g,w)=>{d(g,w)})}listImages(){return this.style.listImages().map(_=>_.name)}addModel(_,d){this._lazyInitEmptyStyle(),this.style.addModel(_,d)}hasModel(_){return _?this.style.hasModel(_):(this.fire(new a.B(new Error("Missing required model id"))),!1)}removeModel(_){this.style.removeModel(_)}listModels(){return this.style.listModels()}addLayer(_,d){return this._isValidId(_.id)?(this._lazyInitEmptyStyle(),this.style.addLayer(_,d),this._update(!0)):this}getSlot(_){const d=this.getLayer(_);return d&&d.slot||null}setSlot(_,d){return this.style.setSlot(_,d),this.style.mergeLayers(),this._update(!0)}addImport(_,d){return this.style.addImport(_,d).catch(g=>this.fire(new a.B(new Error("Failed to add import",g)))),this}updateImport(_,d){return typeof d!="string"&&d.id!==_?(this.removeImport(_),this.addImport(d)):(this.style.updateImport(_,d),this._update(!0))}removeImport(_){return this.style.removeImport(_),this}moveImport(_,d){return this.style.moveImport(_,d),this._update(!0)}moveLayer(_,d){return this._isValidId(_)?(this.style.moveLayer(_,d),this._update(!0)):this}removeLayer(_){return this._isValidId(_)?(this.style.removeLayer(_),this._update(!0)):this}getLayer(_){if(!this._isValidId(_))return null;const d=this.style.getOwnLayer(_);return d?d.type==="custom"?d.implementation:d.serialize():void 0}getSlots(){return this.style.getSlots()}setLayerZoomRange(_,d,g){return this._isValidId(_)?(this.style.setLayerZoomRange(_,d,g),this._update(!0)):this}setFilter(_,d,g={}){return this._isValidId(_)?(this.style.setFilter(_,d,g),this._update(!0)):this}getFilter(_){return this._isValidId(_)?this.style.getFilter(_):null}setPaintProperty(_,d,g,w={}){return this._isValidId(_)?(this.style.setPaintProperty(_,d,g,w),this._update(!0)):this}getPaintProperty(_,d){return this._isValidId(_)?this.style.getPaintProperty(_,d):null}setLayoutProperty(_,d,g,w={}){return this._isValidId(_)?(this.style.setLayoutProperty(_,d,g,w),this._update(!0)):this}getLayoutProperty(_,d){return this._isValidId(_)?this.style.getLayoutProperty(_,d):null}setLayerProperty(_,d,g,w={}){return this._isValidId(_)?(d==="appearances"&&this._postAddingAppearancesToStyleEvent(),this.style.setLayerProperty(_,d,g,w),this._update(!0)):this}getGlyphsUrl(){return this.style.getGlyphsUrl()}setGlyphsUrl(_){return this.style.setGlyphsUrl(_),this._update(!0)}getSchema(_){return this.style.getSchema(_)}setSchema(_,d){return this.style.setSchema(_,d),this._update(!0)}getConfig(_){return this.style.getConfig(_)}setConfig(_,d){return this.style.setConfig(_,d),this._update(!0)}getConfigProperty(_,d){return this.style.getConfigProperty(_,d)}setConfigProperty(_,d,g){return this.style.setConfigProperty(_,d,g),this._update(!0)}getFeaturesetDescriptors(_){return this.style.getFeaturesetDescriptors(_)}setLights(_){if(this._lazyInitEmptyStyle(),_&&_.length===1&&_[0].type==="flat"){const d=_[0];d.properties?this.style.setFlatLight(d.properties,d.id,{}):this.style.setFlatLight({},"flat")}else this.style.setLights(_),this.painter.terrain&&(this.painter.terrain.invalidateRenderCache=!0);return this._update(!0)}getLights(){const _=this.style.getLights()||[];return _.length===0&&_.push({id:this.style.light.id,type:"flat",properties:this.style.getFlatLight()}),_}setLight(_,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:_}])}getLight(){return console.log("The `map.getLight` function is deprecated, prefer using `map.getLights` instead."),this.style.getFlatLight()}setTerrain(_){return this._lazyInitEmptyStyle(),!_&&this.transform.projection.requiresDraping?this.style.setTerrainForDraping():this.style.setTerrain(_),this._averageElevationLastSampledAt=-1/0,this._update(!0)}getTerrain(){return this.style?this.style.getTerrain():null}setFog(_){return this._lazyInitEmptyStyle(),this.style.setFog(_),this._update(!0)}getFog(){return this.style?this.style.getFog():null}setSnow(_){return this._lazyInitEmptyStyle(),this.style.setSnow(_),this._update(!0)}getSnow(){return this.style?this.style.getSnow():null}setRain(_){return this._lazyInitEmptyStyle(),this.style.setRain(_),this._update(!0)}getRain(){return this.style?this.style.getRain():null}setColorTheme(_){return this._lazyInitEmptyStyle(),this.style.setColorTheme(_),this._update(!0)}setImportColorTheme(_,d){return this._lazyInitEmptyStyle(),this.style.setImportColorTheme(_,d),this._update(!0)}setCamera(_){return this.style.setCamera(_),this._triggerCameraUpdate(_)}getNearClipOffset(){return this.transform.nearClipOffset}setNearClipOffset(_){const d=this.transform.nearClipOffset!==_;return this.transform.nearClipOffset=_,this._update(d)}_triggerCameraUpdate(_){return this._update(this.transform.setOrthographicProjectionAtLowPitch(_["camera-projection"]==="orthographic"))}getCamera(){return this.style.camera}_queryFogOpacity(_){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(a.aU.convert(_),this.transform):0}setFeatureState(_,d){return _.source&&!this._isValidId(_.source)?this:(this.style.setFeatureState(_,d),this._update())}removeFeatureState(_,d){return _.source&&!this._isValidId(_.source)?this:(this.style.removeFeatureState(_,d),this._update())}getFeatureState(_){return _.source&&!this._isValidId(_.source)?null:this.style.getFeatureState(_)}_selectIndoorFloor(_){this.style.indoorManager.selectFloor(_)}_setIndoorActiveFloorsVisibility(_){this.style.indoorManager.setActiveFloorsVisibility(_)}getIndoorTileOptions(_,d){return this.style.isIndoorEnabled()?this.style.indoorManager.getIndoorTileOptions(_,d):null}_updateContainerDimensions(){if(!this._container)return;const _=this._container.getBoundingClientRect().width||400,d=this._container.getBoundingClientRect().height||300;let g,w,j,I=this._container;for(;I&&(!w||!j);){const L=window.getComputedStyle(I).transform;L&&L!=="none"&&(g=L.match(/matrix.*\((.+)\)/)[1].split(", "),g[0]&&g[0]!=="0"&&g[0]!=="1"&&(w=g[0]),g[3]&&g[3]!=="0"&&g[3]!=="1"&&(j=g[3])),I=I.parentElement}this._containerWidth=w?Math.abs(_/w):_,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 _=this._container;_.classList.add("mapboxgl-map"),(this._missingCSSCanary=R("div","mapboxgl-canary",_)).style.visibility="hidden",this._detectMissingCSS();const d=this._canvasContainer=R("div","mapboxgl-canvas-container",_);this._canvas=R("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=R("div","mapboxgl-control-container",_),w=this._controlPositions={};["top-left","top","top-right","right","bottom-right","bottom","bottom-left","left"].forEach(j=>{w[j]=R("div",`mapboxgl-ctrl-${j}`,g)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(_,d){const g=a.o.devicePixelRatio||1;this._canvas.width=g*Math.ceil(_),this._canvas.height=g*Math.ceil(d),this._canvas.style.width=`${_}px`,this._canvas.style.height=`${d}px`}_addMarker(_){this._markers.push(_)}_removeMarker(_){const d=this._markers.indexOf(_);d!==-1&&this._markers.splice(d,1)}_addPopup(_){this._popups.push(_)}_removePopup(_){const d=this._popups.indexOf(_);d!==-1&&this._popups.splice(d,1)}_setupPainter(){const _=Object.assign({},k.supported.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),d=this._canvas.getContext("webgl2",_);d?(Pr(d,!0),this.painter=new i5(d,this._contextCreateOptions,this.transform,this._scaleFactor,this._worldview),this.on("data",g=>{if(g.dataType==="source"){const w=this.transform.elevation?this.transform.elevation._source():null;w&&g.sourceCacheId===w.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(_){_.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new a.C("webglcontextlost",{originalEvent:_}))}_contextRestored(_){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:_}))}_onMapScroll(_){if(_.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(_){return this.style?(this._styleDirty=this._styleDirty||_,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(_){return this._update(),this._renderTaskQueue.add(_)}_cancelRenderFrame(_){this._renderTaskQueue.remove(_)}_requestDomTask(_){!this.loaded()||this.loaded()&&!this.isMoving()?_():this._domRenderTaskQueue.add(_)}_render(_){let d;this.fire(new a.C("renderstart")),++this._frameId;const g=this.painter.context.extTimerQuery,w=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(_),this._domRenderTaskQueue.run(_),this._removed)return;this._updateProjectionTransition();const I=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;const z=this.transform.zoom,H=this.transform.pitch,Z=a.o.now(),ne=new a.ae(z,{now:Z,fadeDuration:I,pitch:H,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(w),this.style.updateSources(this.transform),this.style.updateImageProviders(),this.isMoving()||this._forceMarkerAndPopupUpdate()):L=this._updateAverageElevation(w),this.style&&(this._placementDirty=this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,I,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:I,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(p.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()-w;j.endQuery(g.TIME_ELAPSED_EXT),setTimeout(()=>{const H=j.getQueryParameter(d,j.QUERY_RESULT)/1e6;j.deleteQuery(d),this.fire(new a.C("gpu-timing-frame",{cpuTime:z,gpuTime:H}))},50)}if(this.listens("gpu-timing-layer")){const z=this.painter.collectGpuTimers();setTimeout(()=>{const H=this.painter.queryGpuTimers(z);this.fire(new a.C("gpu-timing-layer",{layerTimes:H}))},50)}if(this.listens("gpu-timing-deferred-render")){const z=this.painter.collectDeferredRenderGpuQueries();setTimeout(()=>{const H=this.painter.queryGpuTimeDeferredRender(z);this.fire(new a.C("gpu-timing-deferred-render",{gpuTime:H}))},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(w,!0)),L)this.triggerRepaint();else if(this._triggerFrame(!1),z&&(this.fire(new a.C("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){const H=this._calculateSpeedIndex();this.fire(new a.C("speedindexcompleted",{speedIndex:H})),this.speedIndexTiming=!1}}!this._loaded||this._fullyLoaded||F||(this._fullyLoaded=!0,y.mark(p.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(_){for(const d of this._markers)_&&!this.getRenderWorldCopies()&&(d._lngLat=d._lngLat.wrap()),d._update();for(const d of this._popups)!_||this.getRenderWorldCopies()||d._trackPointer||(d._lngLat=d._lngLat.wrap()),d._update()}_updateAverageElevation(_,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 w=this.transform.elevation&&this.transform.elevation.exaggeration()!==this._averageElevationExaggeration;if(w||(d||_-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(_)){const j=this.transform.averageElevation;let I=this.transform.sampleAverageElevation();this.transform.elevation!=null&&(this._averageElevationExaggeration=this.transform.elevation.exaggeration()),isNaN(I)?I=0:this._averageElevationLastSampledAt=_;const L=Math.abs(j-I);if(L>1){if(this._isInitialLoad||w)return this._averageElevation.jumpTo(I),g(I);this._averageElevation.easeTo(I,_,300)}else if(L>1e-4)return this._averageElevation.jumpTo(I),g(I)}return!!this._averageElevation.isEasing(_)&&g(this._averageElevation.getValue(_))}_isTokenExpired(){return this._tokenExpiration!=null&&Date.now()>this._tokenExpiration}_revokeAuth(){const _=this.painter.context.gl;Pr(_,!1),this._logoControl instanceof hj&&this._logoControl._updateLogo(),_&&_.clear(_.DEPTH_BUFFER_BIT|_.COLOR_BUFFER_BIT|_.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(){cr(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,_=>{_&&(_.message!==Te&&_.status!==401||this._revokeAuth())}),this._isTokenExpired()&&this._revokeAuth(),jt(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,()=>{})}_postStyleLoadEvent(){this.style.globalId&&Gt(this._requestManager._customAccessToken,{map:this,style:this.style.globalId,importedStyles:this.style.getImportGlobalIds()})}_postStyleWithAppearanceEvent(){this.style.globalId&&this.style.hasAppearances()&&Ct(this._requestManager._customAccessToken)}_postAddingAppearancesToStyleEvent(){wt(this._requestManager._customAccessToken)}_updateTerrain(){const _=this._isDragging();this.painter.updateTerrain(this.style,_)}_calculateSpeedIndex(){const _=this.painter.canvasCopy(),d=this.painter.getCanvasCopiesAndTimestamps();d.timeStamps.push(performance.now());const g=this.painter.context.gl,w=g.createFramebuffer();function j(I){g.framebufferTexture2D(g.FRAMEBUFFER,g.COLOR_ATTACHMENT0,g.TEXTURE_2D,I,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,w),this._canvasPixelComparison(j(_),d.canvasCopies.map(j),d.timeStamps)}_canvasPixelComparison(_,d,g){let w=g[1]-g[0];const j=_.length/4;for(let I=0;I{const g=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,g&&this._render(d)}))}_preloadTiles(_){const d=this.style?this.style.getSourceCaches():[];return a.t(d,(g,w)=>g._preloadTiles(_,w),()=>{this.triggerRepaint()}),this}_onWindowOnline(){this._update()}_onWindowResize(_){this._trackResize&&this.resize({originalEvent:_})._update()}_onVisibilityChange(){document.visibilityState==="hidden"&&this._visibilityHidden++}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(_){this._showTileBoundaries!==_&&(this._showTileBoundaries=_,this._update())}get showParseStatus(){return!!this._showParseStatus}set showParseStatus(_){this._showParseStatus!==_&&(this._showParseStatus=_,this._update())}get showTerrainWireframe(){return!!this._showTerrainWireframe}set showTerrainWireframe(_){this._showTerrainWireframe!==_&&(this._showTerrainWireframe=_,this._update())}get showLayers2DWireframe(){return!!this._showLayers2DWireframe}set showLayers2DWireframe(_){this._showLayers2DWireframe!==_&&(this._showLayers2DWireframe=_,this._update())}get showLayers3DWireframe(){return!!this._showLayers3DWireframe}set showLayers3DWireframe(_){this._showLayers3DWireframe!==_&&(this._showLayers3DWireframe=_,this._update())}get speedIndexTiming(){return!!this._speedIndexTiming}set speedIndexTiming(_){this._speedIndexTiming!==_&&(this._speedIndexTiming=_,this._update())}get showPadding(){return!!this._showPadding}set showPadding(_){this._showPadding!==_&&(this._showPadding=_,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(_){this._showCollisionBoxes!==_&&(this._showCollisionBoxes=_,this.style&&_?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(_){this._showOverdrawInspector!==_&&(this._showOverdrawInspector=_,this._update())}get repaint(){return!!this._repaint}set repaint(_){this._repaint!==_&&(this._repaint=_,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(_){this._vertices=_,this._update()}get showTileAABBs(){return!!this._showTileAABBs}set showTileAABBs(_){this._showTileAABBs!==_&&(this._showTileAABBs=_,_&&this._update())}_setCacheLimits(_,d){a.e_(_,d)}get version(){return f}},NavigationControl:class{constructor(_={}){this.options=Object.assign({},h5,_),this._container=R("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})}),R("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})}),R("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=R("span","mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}_updateZoomButtons(){const _=this._map;if(!_)return;const d=_.getZoom(),g=d===_.getMaxZoom(),w=d===_.getMinZoom();this._zoomInButton.disabled=g,this._zoomOutButton.disabled=w,this._zoomInButton.setAttribute("aria-disabled",g.toString()),this._zoomOutButton.setAttribute("aria-disabled",w.toString())}_rotateCompassArrow(){const _=this._map;if(!_)return;const d=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(_.transform.pitch*(Math.PI/180)),.5)}) rotateX(${_.transform.pitch}deg) rotateZ(${_.transform.angle*(180/Math.PI)}deg)`:`rotate(${_.transform.angle*(180/Math.PI)}deg)`;_._requestDomTask(()=>{this._compassIcon&&(this._compassIcon.style.transform=d)})}onAdd(_){return this._map=_,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),_.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&_.on("pitch",this._rotateCompassArrow),_.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new G0(_,this._compass,this.options.visualizePitch)),this._container}onRemove(){const _=this._map;_&&(this._container.remove(),this.options.showZoom&&_.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&_.off("pitch",this._rotateCompassArrow),_.off("rotate",this._rotateCompassArrow),this._handler&&this._handler.off(),this._handler=void 0),this._map=void 0)}_createButton(_,d){const g=R("button",_,this._container);return g.type="button",g.addEventListener("click",d),g}_setButtonTitle(_,d){if(!this._map)return;const g=this._map._getUIString(`NavigationControl.${d}`);_.setAttribute("aria-label",g),_.firstElementChild&&_.firstElementChild.setAttribute("title",g)}},GeolocateControl:class extends a.E{constructor(_={}){super();const d=navigator.geolocation;this.options=Object.assign({geolocation:d},W0,_),a.aZ(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],this),this._updateMarkerRotationThrottled=ZE(this._updateMarkerRotation,20),this._numberOfWatches=0}onAdd(_){return this._map=_,this._container=R("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(_){const d=(g=!!this.options.geolocation)=>{this._supportsGeolocation=g,_(g)};this._supportsGeolocation!==void 0?_(this._supportsGeolocation):navigator.permissions!==void 0?navigator.permissions.query({name:"geolocation"}).then(g=>d(g.state!=="denied")).catch(()=>d()):d()}_isOutOfMapMaxBounds(_){const d=this._map.getMaxBounds(),g=_.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(_){if(this._map){if(this._clearRequestTimeout(),this._isOutOfMapMaxBounds(_))return this._setErrorState(),this.fire(new a.C("outofmaxbounds",_)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=_,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(_),this.options.followUserLocation&&(!this.options.trackUserLocation||this._watchState==="ACTIVE_LOCK")&&this._updateCamera(_),this.options.showUserLocation&&this._userLocationDotMarker.removeClassName("mapboxgl-user-location-dot-stale"),this.fire(new a.C("geolocate",Object.assign({coords:_.coords,timestamp:_.timestamp},_.toJSON?{toJSON:_.toJSON.bind(_)}:{}))),this._finish()}}_updateCamera(_){const d=new a.aU(_.coords.longitude,_.coords.latitude),g=_.coords.accuracy,w=this._map.getBearing(),j=Object.assign({bearing:w},this.options.fitBoundsOptions);this._map.fitBounds(d.toBounds(g),j,{geolocateSource:!0})}_updateMarker(_){if(_){const d=new a.aU(_.coords.longitude,_.coords.latitude);this._accuracyCircleMarker.setLngLat(d).addTo(this._map),this._userLocationDotMarker.setLngLat(d).addTo(this._map),this._accuracy=_.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()}_updateCircleRadius(){const _=this._map.transform,d=a.bU(1,_._center.lat)*_.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(_){if(this._map){if(this._clearRequestTimeout(),this.options.trackUserLocation)if(_.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(_.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:_.code,message:_.message,PERMISSION_DENIED:_.PERMISSION_DENIED,POSITION_UNAVAILABLE:_.POSITION_UNAVAILABLE,TIMEOUT:_.TIMEOUT})),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_startRequestTimeout(){this._clearRequestTimeout();const _=this.options.positionOptions.timeout;_&&(this._requestTimeoutId=window.setTimeout(()=>{this._onError({code:3,message:"Geolocation request timed out"})},_))}_clearRequestTimeout(){this._requestTimeoutId!==void 0&&(clearTimeout(this._requestTimeoutId),this._requestTimeoutId=void 0)}_setupUI(_){if(this._map!==void 0){if(this._container.addEventListener("contextmenu",d=>d.preventDefault()),this._geolocateButton=R("button","mapboxgl-ctrl-geolocate",this._container),R("span","mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",_===!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=R("div","mapboxgl-user-location"),this._dotElement.appendChild(R("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(R("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new _u({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=R("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new _u({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(_){this._userLocationDotMarker&&(_.webkitCompassHeading?this._heading=_.webkitCompassHeading:_.absolute===!0&&(this._heading=-1*_.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 _;this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),this._numberOfWatches++,this._numberOfWatches>1?(_={maximumAge:6e5,timeout:0},this._noTimeout=!0):(_=this.options.positionOptions,this._noTimeout=!1),this._geolocationWatchID=this.options.geolocation.watchPosition(this._onSuccess,this._onError,_),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(_){return this.options.followUserLocation=_??W0.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 _=()=>{const d="ondeviceorientationabsolute"in window?"deviceorientationabsolute":"deviceorientation";window.addEventListener(d,this._onDeviceOrientation)};typeof DeviceOrientationEvent.requestPermission=="function"?DeviceOrientationEvent.requestPermission().then(d=>{d==="granted"&&_()}).catch(console.error):_()}_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:dj,ScaleControl:class{constructor(_={}){this.options=Object.assign({},fa,_),a.aZ(["_update","_setScale","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_update(){const _=this.options.maxWidth||100,d=this._map,g=d._containerHeight/2,w=d._containerWidth/2-_/2,j=d.unproject([w,g]),I=d.unproject([w+_,g]),L=j.distanceTo(I);if(this.options.unit==="imperial"){const F=3.2808*L;F>5280?this._setScale(_,F/5280,"mile"):this._setScale(_,F,"foot")}else this.options.unit==="nautical"?this._setScale(_,L/1852,"nautical-mile"):L>=1e3?this._setScale(_,L/1e3,"kilometer"):this._setScale(_,L,"meter")}_setScale(_,d,g){this._map._requestDomTask(()=>{const w=function(I){const L=Math.pow(10,`${Math.floor(I)}`.length-1);let F=I/L;return F=F>=10?10:F>=5?5:F>=3?3:F>=2?2:F>=1?1:function(z){const H=Math.pow(10,Math.ceil(-Math.log(z)/Math.LN10));return Math.round(z*H)/H}(F),L*F}(d),j=w/d;this._container.innerHTML=g!=="nautical-mile"?new Intl.NumberFormat(this._language,{style:"unit",unitDisplay:"short",unit:g}).format(w):`${w} ${bu[g]}`,this._container.style.width=_*j+"px"})}onAdd(_){return this._map=_,this._language=_.getLanguage(),this._container=R("div","mapboxgl-ctrl mapboxgl-ctrl-scale",_.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(_){this._language=_,this._update()}setUnit(_){this.options.unit=_,this._update()}},FullscreenControl:class{constructor(_={}){this._fullscreen=!1,_&&_.container&&(_.container instanceof HTMLElement?this._container=_.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(_){return this._map=_,this._container||(this._container=this._map.getContainer()),this._controlContainer=R("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 _=this._fullscreenButton=R("button","mapboxgl-ctrl-fullscreen",this._controlContainer);R("span","mapboxgl-ctrl-icon",_).setAttribute("aria-hidden","true"),_.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),document.addEventListener(this._fullscreenchange,this._changeIcon)}_updateTitle(){const _=this._getTitle();this._fullscreenButton.setAttribute("aria-label",_),this._fullscreenButton.firstElementChild&&this._fullscreenButton.firstElementChild.setAttribute("title",_)}_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(_){return this._map=_,this._container=R("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 _=this._map.style.indoorManager;_.off("selector-update",this._onIndoorUpdate),_.on("selector-update",this._onIndoorUpdate),this._onIndoorUpdate(_.getControlState())}}_createButton(_,d){const g=R("button",_,this._container);return g.type="button",g.addEventListener("click",d),g}_setButtonTitle(_,d){_.setAttribute("aria-label",d),_.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(_){if(!_||!_.floors||_.floors.length===0)return this._model=_,void(this._container.style.display="none");const d=this._model;this._model=_,this._container.style.display="inline-block";const g=!d||d.floors.length!==_.floors.length||d.floors.some((w,j)=>w.id!==_.floors[j].id);if(g&&(this._visibleFloorStart=0,this._lastSelectedFloorId=null),_.selectedFloorId){if(_.selectedFloorId!==this._lastSelectedFloorId||g){const w=_.floors.findIndex(j=>j.id===_.selectedFloorId);if(w!==-1){const j=_.floors.length;let I,L;j<=5?(I=0,L=j-1):this._visibleFloorStart===0?(I=0,L=3):this._visibleFloorStart>=j-3?(I=j-3-1,L=j-1):(I=this._visibleFloorStart,L=this._visibleFloorStart+3-1),wL&&(this._visibleFloorStart=w-2)}}this._lastSelectedFloorId=_.selectedFloorId}this._render()}_render(){if(!this._container||!this._model||!this._model.floors)return;this._container.innerHTML="";const _=this._createButton("mapboxgl-ctrl-indoor-toggle",this._toggleIndoor);R("span","mapboxgl-ctrl-icon",_).setAttribute("aria-hidden","true"),this._model.activeFloorsVisible||_.classList.add("mapboxgl-ctrl-level-button-selected"),this._container.appendChild(_);const d=this._model.floors,g=d.length;if(g<=5)return void d.forEach(L=>this._createFloorButton(L));const w=this._visibleFloorStart===0,j=this._visibleFloorStart>=g-3;if(w)this._createFloorButton(d[0]);else{const L=this._createButton("mapboxgl-ctrl-arrow-up",this._scrollUp);R("span","mapboxgl-ctrl-icon",L).setAttribute("aria-hidden","true"),this._container.appendChild(L)}let I=[];if(I=w?d.slice(1,4):j?d.slice(this._visibleFloorStart-1,this._visibleFloorStart+3-1):d.slice(this._visibleFloorStart,this._visibleFloorStart+3),I.forEach(L=>this._createFloorButton(L)),j)this._createFloorButton(d[g-1]);else{const L=this._createButton("mapboxgl-ctrl-arrow-down",this._scrollDown);R("span","mapboxgl-ctrl-icon",L).setAttribute("aria-hidden","true"),this._container.appendChild(L)}}_createFloorButton(_){const d=this._createButton("mapboxgl-ctrl-level-button",()=>{const I=_.id;this._model&&this._model.selectedFloorId===I&&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(I))}),g=(_.name||"").trim(),w=_.zIndex.toString(),j=g?Array.from(g).slice(0,3).join(""):w;this._setButtonTitle(d,j),this._model&&this._model.activeFloorsVisible&&_.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 _=this._model&&this._model.floors||[];if(_.length>3){const d=_.length-3;this._visibleFloorStart===d-1&&(this._visibleFloorStart=d-2)}this._render()}}_scrollDown(){if(this._model&&this._model.floors){const _=this._model.floors.length-3;this._visibleFloorStart<_&&(this._visibleFloorStart++,this._visibleFloorStart===1&&(this._visibleFloorStart=2),this._visibleFloorStart===_-1&&(this._visibleFloorStart=_),this._visibleFloorStart>_&&(this._visibleFloorStart=_),this._render())}}},Popup:class extends a.E{constructor(_){super(),this.options=Object.assign(Object.create(K0),_),this._altitude=this.options.altitude,a.aZ(["_update","_onClose","remove","_onMouseEvent"],this),this._classList=new Set(_&&_.className?_.className.trim().split(/\s+/):[])}addTo(_){return this._map&&this.remove(),this._map=_,this.options.closeOnClick&&_.on("preclick",this._onClose),this.options.closeOnMove&&_.on("move",this._onClose),_.on("remove",this.remove),this._update(),_._addPopup(this),this._focusFirstElement(),this._trackPointer?(_.on("mousemove",this._onMouseEvent),_.on("mouseup",this._onMouseEvent),_._canvasContainer.classList.add("mapboxgl-track-pointer")):_.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 _=this._map;return _&&(_.off("move",this._update),_.off("move",this._onClose),_.off("preclick",this._onClose),_.off("click",this._onClose),_.off("remove",this.remove),_.off("mousemove",this._onMouseEvent),_.off("mouseup",this._onMouseEvent),_.off("drag",this._onMouseEvent),_._canvasContainer&&_._canvasContainer.classList.remove("mapboxgl-track-pointer"),_._removePopup(this),this._map=void 0),this.fire(new a.C("close")),this}getLngLat(){return this._lngLat}setLngLat(_){this._lngLat=a.aU.convert(_),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(_){return this._altitude=_,this._update(),this}trackPointer(){this._trackPointer=!0,this._pos=null,this._update();const _=this._map;return _&&(_.off("move",this._update),_.on("mousemove",this._onMouseEvent),_.on("drag",this._onMouseEvent),_._canvasContainer.classList.add("mapboxgl-track-pointer")),this}getElement(){return this._container}setText(_){return this.setDOMContent(document.createTextNode(_))}setHTML(_){const d=document.createDocumentFragment(),g=document.createElement("body");let w;for(g.innerHTML=_;w=g.firstChild,w;)d.appendChild(w);return this.setDOMContent(d)}getMaxWidth(){return this._container&&this._container.style.maxWidth}setMaxWidth(_){return this.options.maxWidth=_,this._update(),this}setDOMContent(_){let d=this._content;if(d)for(;d.hasChildNodes();)d.firstChild&&d.removeChild(d.firstChild);else d=this._content=R("div","mapboxgl-popup-content",this._container||void 0);if(d.appendChild(_),this.options.closeButton){const g=this._closeButton=R("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(_){return this._classList.add(_),this._updateClassList(),this}removeClassName(_){return this._classList.delete(_),this._updateClassList(),this}setOffset(_){return this.options.offset=_,this._update(),this}toggleClassName(_){let d;return this._classList.delete(_)?d=!1:(this._classList.add(_),d=!0),this._updateClassList(),d}_onMouseEvent(_){this._update(_.point)}_getAnchor(_){if(this.options.anchor)return this.options.anchor;const d=this._map,g=this._container,w=this._pos;if(!d||!g||!w)return"bottom";const j=g.offsetWidth,I=g.offsetHeight,L=w.xd.transform.width-j/2;if(w.y+_d.transform.height-I){if(L)return"bottom-left";if(F)return"bottom-right"}return L?"left":F?"right":"bottom"}_updateClassList(){const _=this._container;if(!_)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"),_.className=d.join(" ")}_update(_){const d=this._map,g=this._content;if(!d||!this._lngLat&&!this._trackPointer||!g)return;let w=this._container;if(w||(w=this._container=R("div","mapboxgl-popup",d.getContainer()),this._tip=R("div","mapboxgl-popup-tip",w),w.appendChild(g)),this.options.maxWidth&&w.style.maxWidth!==this.options.maxWidth&&(w.style.maxWidth=this.options.maxWidth),d.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=fj(this._lngLat,this._pos,d.transform)),!this._trackPointer||_){const j=this._pos=this._trackPointer&&_ instanceof a.P?_:d.project(this._lngLat,this._altitude),I=Vb(this.options.offset),L=this._anchor=this._getAnchor(I.y),F=Vb(this.options.offset,L),z=j.add(F).round();d._requestDomTask(()=>{this._container&&L&&(this._container.style.transform=`${H0[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 _=this._container.querySelector(f5);_&&_.focus()}_onClose(){this.remove()}_setOpacity(_){this._container&&(this._container.style.opacity=`${_}`),this._content&&(this._content.style.pointerEvents=_?"auto":"none")}},Marker:_u,Style:yu,LngLat:a.aU,LngLatBounds:a.aK,Point:a.P,MercatorCoordinate:a.ag,FreeCameraOptions:u0,Evented:a.E,config:a.g,prewarm:function(){Tn().acquire(Ir)},clearPrewarmedResources:function(){const _=It;_&&(_.isPreloaded()&&_.numActive()===1?(_.release(Ir),It=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(_){a.g.ACCESS_TOKEN=_},get baseApiUrl(){return a.g.API_URL},set baseApiUrl(_){a.g.API_URL=_},get workerCount(){return ur.workerCount},set workerCount(_){ur.workerCount=_},get maxParallelImageRequests(){return a.g.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(_){a.g.MAX_PARALLEL_IMAGE_REQUESTS=_},clearStorage(_){a.f7(_)},get workerUrl(){return St.workerUrl},set workerUrl(_){St.workerUrl=_},get workerClass(){return St.workerClass},set workerClass(_){St.workerClass=_},get workerParams(){return St.workerParams},set workerParams(_){St.workerParams=_},get dracoUrl(){return a.f6()},set dracoUrl(_){a.g.DRACO_URL=a.o.resolveURL(_)},get meshoptUrl(){return a.f5()},set meshoptUrl(_){const d=a.o.resolveURL(_);a.g.MESHOPT_URL=d,a.g.MESHOPT_SIMD_URL=d},get buildingGenUrl(){return a.f4()},set buildingGenUrl(_){a.g.BUILDING_GEN_URL=a.o.resolveURL(_)},setNow:a.o.setNow,restoreNow:a.o.restoreNow}});var c=s;return c})})(hbe);var zXe=hbe.exports;const rh=hi(zXe),Tne={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"},Ene={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 UXe(t){return t>=1e6?`$${(t/1e6).toFixed(1)}M`:`$${(t/1e3).toFixed(0)}K`}function VXe({listings:t,isLoading:e}){const r=Wi(),n=N.useRef(null),s=N.useRef(null),o=N.useRef([]),[c,a]=N.useState(""),[f,p]=N.useState(!0);return N.useEffect(()=>{(async()=>{p(!0);try{const{data:S}=await Re.from("settings").select("value").eq("key","mapbox_public_token").maybeSingle();S!=null&&S.value&&a(S.value)}catch(S){console.error("Error fetching mapbox token:",S)}p(!1)})()},[]),N.useEffect(()=>{if(!n.current||!c||s.current)return;rh.accessToken=c;const v=t.filter(k=>k.latitude!=null&&k.longitude!=null);let S=[-98.5795,39.8283],E=4;if(v.length>0){const k=v.reduce((P,M)=>P+M.longitude,0)/v.length,R=v.reduce((P,M)=>P+M.latitude,0)/v.length;S=[k,R],E=v.length===1?12:10}return s.current=new rh.Map({container:n.current,style:"mapbox://styles/mapbox/light-v11",zoom:E,center:S}),s.current.addControl(new rh.NavigationControl,"top-right"),()=>{var k;(k=s.current)==null||k.remove(),s.current=null}},[c]),N.useEffect(()=>{if(!s.current||!c)return;o.current.forEach(S=>S.remove()),o.current=[];const v=t.filter(S=>S.latitude!=null&&S.longitude!=null);if(v.forEach(S=>{var V,G,W;const E=Tne[S.status]||"#10B981",k=((V=S.photos)==null?void 0:V.find(Y=>Y.is_primary))||((G=S.photos)==null?void 0:G[0]),P=window.location.hostname==="listings.relevelup.com"||window.location.hostname.startsWith("listings.")?`/${S.slug||S.id}`:`/public/listing/${S.slug||S.id}`,M=document.createElement("div");M.className="cursor-pointer",M.innerHTML=`
`;const D=new rh.Popup({offset:25,closeButton:!0,maxWidth:"280px"}).setHTML(`
${k!=null&&k.photo_url?``:""}
${UXe(S.price)}
${S.property_address||""}
${S.city}, ${S.state}
${Ene[S.status]||S.status} ${S.bedrooms?`${S.bedrooms} bed`:""} ${S.bathrooms?`${S.bathrooms} bath`:""}
${(W=S.agent)!=null&&W.name?`
Listed by ${S.agent.name}
`:""}
Click to view details →
`),B=new rh.Marker(M).setLngLat([S.longitude,S.latitude]).setPopup(D).addTo(s.current);o.current.push(B)}),v.length>1){const S=new rh.LngLatBounds;v.forEach(E=>S.extend([E.longitude,E.latitude])),s.current.fitBounds(S,{padding:60,maxZoom:13})}else v.length===1&&s.current.flyTo({center:[v[0].longitude,v[0].latitude],zoom:12})},[t,c]),N.useEffect(()=>(window.__navigateToPublicListing__=v=>{r(v)},()=>{delete window.__navigateToPublicListing__}),[r]),f||e?i.jsx(pl,{className:"w-full h-[500px] rounded-lg"}):!c||t.filter(v=>v.latitude!=null&&v.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(Tne).map(([v,S])=>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:S}}),i.jsx("span",{className:"text-xs text-gray-600",children:Ene[v]})]},v))}),i.jsx("div",{ref:n,className:"w-full h-[500px] rounded-lg shadow-lg border border-gray-200"})]})}const dz={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"},qXe={single_family:"Single Family",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury",commercial:"Commercial",other:"Other"},Nw="#0d0d0d",jne="#1a1a1a",Qs="#c9a84c",xy="#f0d78c";function mbe(){const[t,e]=N.useState(""),[r,n]=N.useState(!1),[s,o]=N.useState(!1),[c,a]=N.useState(!1),[f,p]=N.useState(-1),y=N.useRef(null),[v,S]=N.useState({status:"",propertyType:"",minPrice:"",maxPrice:""}),{data:E}=wXe(),k=N.useMemo(()=>{if(!E)return[];const le=t.trim().toLowerCase(),pe=[...E.cities.map(Ae=>({label:Ae.label,value:Ae.city,type:"city",count:Ae.count})),...E.neighborhoods.map(Ae=>({label:Ae.label,value:Ae.neighborhood,type:"neighborhood",count:Ae.count})),...E.zips.map(Ae=>({label:`ZIP ${Ae.label}`,value:Ae.zip,type:"zip",count:Ae.count}))];return(le?pe.filter(Ae=>Ae.label.toLowerCase().includes(le)||Ae.value.toLowerCase().includes(le)):pe).slice(0,8)},[E,t]);N.useEffect(()=>{const le=pe=>{y.current&&!y.current.contains(pe.target)&&a(!1)};return document.addEventListener("mousedown",le),()=>document.removeEventListener("mousedown",le)},[]);const{data:R,isLoading:P}=bXe({city:t||void 0,status:v.status||void 0,propertyType:v.propertyType||void 0,minPrice:v.minPrice?Number(v.minPrice):void 0,maxPrice:v.maxPrice?Number(v.maxPrice):void 0}),M=le=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(le),D=()=>{S({status:"",propertyType:"",minPrice:"",maxPrice:""}),e("")},B=t||v.status||v.propertyType||v.minPrice||v.maxPrice,V=typeof window<"u"&&(window.location.hostname==="listings.relevelup.com"||window.location.hostname.startsWith("listings.")),G=le=>V?`/${le.slug||le.id}`:`/public/listing/${le.slug||le.id}`,{featured:W,restListings:Y,luxeCount:J,cities:Q,activeCount:ee}=N.useMemo(()=>{const le=R||[],pe=le.filter(nt=>nt.status==="active"),Te=pe.length>0?pe:le,Ae=new Intl.DateTimeFormat("en-CA",{timeZone:"America/New_York",year:"numeric",month:"2-digit",day:"2-digit"}).format(new Date),[Le,ke,we]=Ae.split("-").map(Number),me=Math.floor(Date.UTC(Le,ke-1,we)/864e5),je=Te.length>0?Te[me%Te.length]:void 0,_e=le.filter(nt=>!je||nt.id!==je.id),Ee=Array.from(new Set(le.map(nt=>nt.city).filter(Boolean))).slice(0,8),ve=le.filter(nt=>(nt.price||0)>=1e6).length,qe=pe.length;return{featured:je,restListings:_e,luxeCount:ve,cities:Ee,activeCount:qe}},[R]);return i.jsxs(i.Fragment,{children:[i.jsxs(Oo,{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:Nw,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: ${Qs}; } .lu-gold-line { background: linear-gradient(90deg, transparent, ${Qs}, 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(qr,{to:"/",className:"flex items-center gap-3",children:[i.jsx("img",{src:Sne,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(qr,{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 ${Qs}`,color:Qs},children:"About LevelUp"})]}),i.jsx("button",{type:"button",onClick:()=>o(le=>!le),className:"md:hidden inline-flex items-center justify-center w-10 h-10 rounded-full",style:{border:`1px solid ${Qs}`,color:Qs},"aria-label":"Toggle menu","aria-expanded":s,children:s?i.jsx(ki,{className:"w-5 h-5"}):i.jsx(C_,{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(qr,{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 ${Qs}`,color:Qs},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:$Xe,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:Qs}}),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:xy},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 ${Qs}`,backdropFilter:"blur(12px)"},children:[i.jsxs("div",{className:"relative flex-1",children:[i.jsx(bd,{className:"absolute left-6 top-1/2 -translate-y-1/2 h-5 w-5",style:{color:Qs}}),i.jsx(Dr,{placeholder:"City, neighborhood, or ZIP",value:t,onChange:le=>{e(le.target.value),a(!0),p(-1)},onFocus:()=>a(!0),onKeyDown:le=>{if(!(!c||k.length===0))if(le.key==="ArrowDown")le.preventDefault(),p(pe=>Math.min(pe+1,k.length-1));else if(le.key==="ArrowUp")le.preventDefault(),p(pe=>Math.max(pe-1,0));else if(le.key==="Enter"&&f>=0){le.preventDefault();const pe=k[f];e(pe.value),a(!1)}else le.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(IDe,{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:Qs,color:Nw},onClick:()=>a(!1),children:[i.jsx(bd,{className:"h-5 w-5"}),i.jsx("span",{className:"hidden md:inline",children:"Search"})]})]}),c&&k.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:Qs},children:"Suggestions"}),i.jsx("ul",{className:"max-h-80 overflow-y-auto",children:k.map((le,pe)=>i.jsx("li",{children:i.jsxs("button",{type:"button",onMouseEnter:()=>p(pe),onClick:()=>{e(le.value),a(!1)},className:"w-full flex items-center justify-between gap-3 px-5 py-3 text-left transition",style:{background:f===pe?"rgba(201,168,76,0.12)":"transparent"},children:[i.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[le.type==="city"&&i.jsx(di,{className:"h-4 w-4 shrink-0",style:{color:Qs}}),le.type==="neighborhood"&&i.jsx(so,{className:"h-4 w-4 shrink-0",style:{color:Qs}}),le.type==="zip"&&i.jsx(Gi,{className:"h-4 w-4 shrink-0",style:{color:Qs}}),i.jsx("span",{className:"text-white/90 truncate",children:le.label})]}),i.jsxs("span",{className:"text-xs text-white/50 shrink-0",children:[le.count," ",le.count===1?"listing":"listings"]})]})},`${le.type}-${le.value}-${pe}`))})]}),c&&t.trim()&&k.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(ba,{value:v.status||"all",onValueChange:le=>S({...v,status:le==="all"?"":le}),children:[i.jsx(la,{className:"lu-input-dark",children:i.jsx(wa,{})}),i.jsxs(ca,{children:[i.jsx(mn,{value:"all",children:"Any status"}),Object.entries(dz).map(([le,pe])=>i.jsx(mn,{value:le,children:pe},le))]})]})]}),i.jsxs("div",{children:[i.jsx("label",{className:"lu-eyebrow text-white/60 mb-2 block",children:"Type"}),i.jsxs(ba,{value:v.propertyType||"all",onValueChange:le=>S({...v,propertyType:le==="all"?"":le}),children:[i.jsx(la,{className:"lu-input-dark",children:i.jsx(wa,{})}),i.jsxs(ca,{children:[i.jsx(mn,{value:"all",children:"Any type"}),Object.entries(qXe).map(([le,pe])=>i.jsx(mn,{value:le,children:pe},le))]})]})]}),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:v.minPrice,onChange:le=>S({...v,minPrice:le.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:v.maxPrice,onChange:le=>S({...v,maxPrice:le.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(Dt,{variant:"ghost",size:"sm",onClick:D,className:"text-white/70 hover:text-white gap-1",children:[i.jsx(ki,{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:((R==null?void 0:R.length)??0).toString()},{label:"Active Now",value:ee.toString()},{label:"Luxury $1M+",value:J.toString()}].map(le=>i.jsxs("div",{children:[i.jsx("div",{className:"lu-serif text-4xl md:text-5xl",style:{color:xy},children:le.value}),i.jsx("div",{className:"lu-eyebrow text-white/60 mt-1",children:le.label})]},le.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(xl,{className:"h-4 w-4 animate-bounce"})]})]})]}),Q.length>0&&i.jsx("section",{className:"py-8 overflow-hidden",style:{background:jne,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:[...Q,...Q,...Q].map((le,pe)=>i.jsxs("span",{className:"flex items-center gap-3 lu-serif text-2xl md:text-3xl text-white/40",children:[le,i.jsx("span",{className:"h-1.5 w-1.5 rounded-full",style:{background:Qs}})]},pe))})}),W&&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(vi,{className:"h-4 w-4",style:{color:Qs}}),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:xy},children:"standout"}),"."]})]}),i.jsx("div",{className:"hidden md:block h-px flex-1 mx-8 lu-gold-line"})]}),i.jsx(qr,{to:G(W),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 pe,Te;const le=((pe=W.photos)==null?void 0:pe.find(Ae=>Ae.is_primary))||((Te=W.photos)==null?void 0:Te[0]);return le?i.jsx("img",{src:le.photo_url,alt:W.property_address||W.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(Gi,{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:Qs,color:Nw},children:dz[W.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(di,{className:"h-3.5 w-3.5",style:{color:Qs}}),W.city,W.state?`, ${W.state}`:""]}),W.property_address&&i.jsx("h3",{className:"lu-serif text-3xl md:text-4xl mb-4 leading-tight",children:W.property_address}),i.jsx("div",{className:"lu-serif text-5xl md:text-6xl mb-6",style:{color:xy},children:M(W.price)}),i.jsxs("div",{className:"flex items-center gap-6 text-white/70 mb-8",children:[W.bedrooms&&i.jsxs("span",{className:"flex items-center gap-2",children:[i.jsx(oT,{className:"h-4 w-4",style:{color:Qs}}),W.bedrooms," bd"]}),W.bathrooms&&i.jsxs("span",{className:"flex items-center gap-2",children:[i.jsx(k_,{className:"h-4 w-4",style:{color:Qs}}),W.bathrooms," ba"]}),W.square_footage&&i.jsxs("span",{className:"flex items-center gap-2",children:[i.jsx(W9,{className:"h-4 w-4",style:{color:Qs}}),W.square_footage.toLocaleString()," sf"]})]}),W.description&&i.jsx("p",{className:"text-white/60 leading-relaxed mb-8 line-clamp-4",children:W.description}),i.jsxs("div",{className:"inline-flex items-center gap-3 lu-eyebrow group-hover:gap-5 transition-all",style:{color:Qs},children:["View Residence ",i.jsx(ji,{className:"h-4 w-4"})]})]})]})})]})}),i.jsx("section",{id:"collection",className:"py-20 md:py-28",style:{background:jne},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:Qs}}),i.jsx("span",{className:"lu-eyebrow lu-gold",children:"The Collection"}),i.jsx("span",{className:"h-px w-10",style:{background:Qs}})]}),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:xy},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."})]}),P?i.jsx("div",{className:"grid sm:grid-cols-2 lg:grid-cols-3 gap-8",children:[...Array(6)].map((le,pe)=>i.jsxs("div",{className:"space-y-3",children:[i.jsx(pl,{className:"aspect-[4/5] bg-white/5"}),i.jsx(pl,{className:"h-6 w-32 bg-white/5"}),i.jsx(pl,{className:"h-4 w-full bg-white/5"})]},pe))}):Y.length>0?i.jsx("div",{className:"grid sm:grid-cols-2 lg:grid-cols-3 gap-x-8 gap-y-14",children:Y.map(le=>{var Te,Ae,Le,ke,we;const pe=((Te=le.photos)==null?void 0:Te.find(me=>me.is_primary))||((Ae=le.photos)==null?void 0:Ae[0]);return i.jsxs(qr,{to:G(le),className:"group lu-card-hover block",children:[i.jsxs("div",{className:"relative aspect-[4/5] overflow-hidden bg-black mb-5 rounded-lg",children:[pe?i.jsx("img",{src:pe.photo_url,alt:le.property_address||le.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(Gi,{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:Qs,border:`1px solid ${Qs}`},children:dz[le.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:[le.bedrooms&&i.jsxs("span",{children:[le.bedrooms," bd"]}),le.bathrooms&&i.jsxs("span",{children:[le.bathrooms," ba"]}),le.square_footage&&i.jsxs("span",{children:[le.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(di,{className:"h-3 w-3",style:{color:Qs}}),le.city,le.state?`, ${le.state}`:""]}),i.jsx("div",{className:"lu-serif text-2xl md:text-3xl mb-1",style:{color:xy},children:M(le.price)}),le.property_address&&i.jsx("p",{className:"text-white/70 text-sm truncate",children:le.property_address}),((Le=le.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(so,{className:"h-3 w-3"}),le.agent.name,(((ke=le.agent.brokerage)==null?void 0:ke.name)||le.agent.brokerage_name)&&i.jsxs("span",{className:"truncate",children:["· ",((we=le.agent.brokerage)==null?void 0:we.name)||le.agent.brokerage_name]})]})]})]},le.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 ${Qs}`},children:i.jsx(Gi,{className:"h-8 w-8",style:{color:Qs}})}),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(Dt,{onClick:D,style:{background:Qs,color:Nw},className:"hover:brightness-110",children:"Clear filters"})]})]})}),R&&R.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:Qs}}),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:xy},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(VXe,{listings:R,isLoading:P})})]})}),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%, ${Nw} 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:Qs}}),i.jsx("span",{className:"lu-eyebrow lu-gold",children:"For Agents"}),i.jsx("span",{className:"h-px w-10",style:{background:Qs}})]}),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:xy},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:Qs,color:Nw},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:Sne,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(QZe,{}),i.jsx(JZe,{})]})}const GXe=Object.freeze(Object.defineProperty({__proto__:null,default:mbe},Symbol.toStringTag,{value:"Module"})),HXe=N.lazy(()=>Fe(()=>import("./PublicHomeValue-DLzpJ8KX.js"),[]));function WXe(){const t=Es(),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(mbe,{}):n==="home-value"||n==="whats-my-home-worth"?i.jsx(N.Suspense,{fallback:i.jsx("div",{}),children:i.jsx(HXe,{})}):n.startsWith("public/")?null:i.jsx(LH,{slugOverride:n})}const KXe=N.lazy(()=>Fe(()=>import("./CommercialMarketplace-BFsbxZHO.js"),[]));function YXe(){const e=Es().pathname.slice(1);return e?e.startsWith("public/")?null:i.jsx(LH,{slugOverride:e}):i.jsx(N.Suspense,{fallback:i.jsx("div",{className:"min-h-screen bg-[#0a0d12]"}),children:i.jsx(KXe,{})})}function lF({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 ZXe=t=>fr({queryKey:["agent-card-public",t],queryFn:async()=>{if(!t)throw new Error("No slug provided");const{data:e,error:r}=await Re.from("agent_cards").select("*").eq("slug",t).eq("is_published",!0).single();if(r)throw r;const{data:n}=await Re.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 Re.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 Re.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 Re.storage.from("avatars").list(`${e.user_id}`);if(f&&f.length>0){const{data:p}=Re.storage.from("avatars").getPublicUrl(`${e.user_id}/${f[0].name}`);o=`${p.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}),U9t=()=>fr({queryKey:["agent-cards-admin"],queryFn:async()=>{const{data:t,error:e}=await Re.from("agent_cards").select("*").order("created_at",{ascending:!1});if(e)throw e;return t}}),V9t=t=>fr({queryKey:["agent-card",t],queryFn:async()=>{if(!t)return null;const{data:e,error:r}=await Re.from("agent_cards").select("*").eq("user_id",t).maybeSingle();if(r)throw r;return e},enabled:!!t}),q9t=()=>{const t=Er();return wr({mutationFn:async e=>{const{data:r,error:n}=await Re.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)})},G9t=()=>{const t=Er();return wr({mutationFn:async({id:e,...r})=>{const{data:n,error:s}=await Re.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)})},ei=async(t,e,r,n)=>{const s=new URLSearchParams(window.location.search);await Re.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:{}})},XXe=async(t,e)=>{const{error:r}=await Re.from("agent_card_leads").insert({card_id:t,...e});if(r)throw r},H9t=t=>fr({queryKey:["agent-card-analytics",t],queryFn:async()=>{if(!t)return null;const{data:e,error:r}=await Re.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 Re.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 cF({open:t,onOpenChange:e,cardId:r,type:n,agentName:s}){const[o,c]=N.useState(""),[a,f]=N.useState(""),[p,y]=N.useState(""),[v,S]=N.useState(""),[E,k]=N.useState(""),[R,P]=N.useState(!1),M=async D=>{if(D.preventDefault(),!o.trim()){$t.error("Please enter your name");return}P(!0);try{await XXe(r,{lead_type:n,name:o.trim(),email:a.trim()||void 0,phone:p.trim()||void 0,message:E.trim()||void 0,intent:v||void 0}),ei(r,"lead_submitted",n),Re.functions.invoke("card-lead-notify",{body:{cardId:r,leadType:n,name:o.trim(),email:a.trim()||void 0,phone:p.trim()||void 0,message:E.trim()||void 0,intent:v||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(""),S(""),k("")}catch{$t.error("Something went wrong. Please try again.")}finally{P(!1)}};return i.jsx(Fa,{open:t,onOpenChange:e,children:i.jsxs(Sa,{className:"sm:max-w-md rounded-2xl",children:[i.jsxs(Fo,{children:[i.jsx(bo,{children:n==="booking"?"Book a Call":n==="connect"?"Connect with Me":"Refer a Friend"}),i.jsx(Fu,{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(Mr,{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(Mr,{htmlFor:"lead-phone",children:"Phone"}),i.jsx(Dr,{id:"lead-phone",type:"tel",value:p,onChange:D=>y(D.target.value),placeholder:"(555) 123-4567"})]}),i.jsxs("div",{children:[i.jsx(Mr,{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(Mr,{htmlFor:"lead-intent",children:"I'm looking to..."}),i.jsxs(ba,{value:v,onValueChange:S,children:[i.jsx(la,{children:i.jsx(wa,{placeholder:"Select one"})}),i.jsxs(ca,{children:[i.jsx(mn,{value:"buy",children:"Buy a home"}),i.jsx(mn,{value:"sell",children:"Sell my home"}),i.jsx(mn,{value:"both",children:"Buy & Sell"}),i.jsx(mn,{value:"other",children:"Something else"})]})]})]}),n!=="connect"&&i.jsxs("div",{children:[i.jsx(Mr,{htmlFor:"lead-message",children:n==="referral"?"Tell us about them":"Message (optional)"}),i.jsx(Dr,{id:"lead-message",value:E,onChange:D=>k(D.target.value),placeholder:n==="referral"?"Their name, phone, situation...":"Anything you'd like us to know"})]}),i.jsx(Dt,{type:"submit",className:"w-full rounded-2xl",disabled:R,children:R?"Sending...":"Submit"})]})]})})}const QXe=t=>fr({queryKey:["card-blocks",t],queryFn:async()=>{if(!t)return[];const{data:e,error:r}=await Re.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}),W9t=t=>fr({queryKey:["card-blocks-all",t],queryFn:async()=>{if(!t)return[];const{data:e,error:r}=await Re.from("card_blocks").select("*").eq("card_id",t).order("sort_order",{ascending:!0});if(r)throw r;return e||[]},enabled:!!t}),K9t=()=>{const t=Er();return wr({mutationFn:async e=>{const{data:r,error:n}=await Re.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)})},Y9t=()=>{const t=Er();return wr({mutationFn:async({id:e,...r})=>{const{data:n,error:s}=await Re.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)})},Z9t=()=>{const t=Er();return wr({mutationFn:async e=>{const{error:r}=await Re.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 JXe(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 eQe(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 tQe={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 rQe({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=eQe(r.video_url),o=n||!!s,c=n?JXe(r.video_url):s||r.video_url;return i.jsx("div",{className:tQe[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 nQe={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 sQe({block:t,variant:e}){const n=t.config.testimonials||[],[s,o]=N.useState(0);if(n.length===0)return null;const c=nQe[e],a=n[s];return i.jsxs("div",{className:c.container,children:[i.jsxs("div",{className:c.card,children:[i.jsx(TDe,{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(Om,{className:"h-4 w-4"})}),i.jsx("div",{className:"flex gap-1.5",children:n.map((f,p)=>i.jsx("div",{className:`h-1.5 w-1.5 rounded-full transition-colors cursor-pointer ${p===s?c.dot:c.dotInactive}`,onClick:()=>o(p)},p))}),i.jsx("button",{onClick:()=>o(f=>(f+1)%n.length),className:c.nav,children:i.jsx(kd,{className:"h-4 w-4"})})]})]})}const iQe={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 aQe({block:t,variant:e}){const n=t.config.tags||[];if(n.length===0)return null;const s=iQe[e];return i.jsx("div",{className:s.container,children:n.map((o,c)=>i.jsx("span",{className:s.tag,children:o},c))})}const oQe={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 lQe({block:t,cardId:e,variant:r}){const s=t.config.links||[];if(s.length===0)return null;const o=oQe[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:()=>ei(e,"button_click",`custom_link_${c.label}`),className:o.link,children:[i.jsx("span",{children:c.label}),i.jsx(N_,{className:`h-4 w-4 ${o.icon}`})]},a))})}const cQe={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 uQe({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 dQe={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 hQe({block:t,cardId:e,variant:r}){const s=t.config.platforms||[],o=dQe[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=cQe[c.platform.toLowerCase()];return!f||!c.url?null:i.jsx("a",{href:c.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>ei(e,"button_click",`social_${c.platform}`),className:o.linkClass,title:f.label,children:i.jsx(uQe,{path:f.icon,color:f.color})},a)})})]})}function uF({cardId:t,variant:e}){const{data:r}=QXe(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(rQe,{block:c,variant:e},c.id);case"testimonials":return i.jsx(sQe,{block:c,variant:e},c.id);case"specialties":return i.jsx(aQe,{block:c,variant:e},c.id);case"custom_links":return i.jsx(lQe,{block:c,cardId:t,variant:e},c.id);default:return null}}),o&&i.jsx(hQe,{block:o,cardId:t,variant:e})]})}async function fQe(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 mQe(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 dF(t){const{first:e,last:r}=mQe(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 fQe(t.avatarUrl);if(a){const p={"image/jpeg":"JPEG","image/jpg":"JPEG","image/png":"PNG","image/gif":"GIF","image/webp":"JPEG"}[a.mimeType]||"JPEG";n.push(`PHOTO;ENCODING=b;TYPE=${p}:${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 pQe({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)=>{ei(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")}),p=()=>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")}),v=()=>{t.booking_url?a("book",()=>window.open(t.booking_url,"_blank")):(s("booking"),r(!0),ei(t.id,"button_click","book"))},S=()=>{var D,B;ei(t.id,"contact_saved"),dF({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()=>{ei(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!")},k=()=>{s("referral"),r(!0),ei(t.id,"button_click","refer")},R=()=>{s("connect"),r(!0),ei(t.id,"button_click","connect")},P={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(wd,{className:"h-28 w-28 mx-auto mb-4 ring-4 ring-white shadow-lg",children:[i.jsx(Sd,{src:t.avatar_url||void 0,alt:o}),i.jsx(Td,{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(Dt,{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(zn,{className:"h-5 w-5"}),i.jsx("span",{className:"text-xs font-medium",children:"Call"})]}),i.jsxs(Dt,{onClick:p,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(ph,{className:"h-5 w-5"}),i.jsx("span",{className:"text-xs font-medium",children:"Text"})]}),i.jsxs(Dt,{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(ns,{className:"h-5 w-5"}),i.jsx("span",{className:"text-xs font-medium",children:"Email"})]})]}),i.jsxs(Dt,{onClick:v,className:"w-full h-12 text-base font-semibold rounded-2xl shadow-sm mb-6",variant:"outline",children:[i.jsx(co,{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($l,{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(lF,{card:t,variant:"standard"}),i.jsx(uF,{cardId:t.id,variant:"standard"}),i.jsxs("div",{className:"space-y-2 mb-6",children:[t.show_save_contact&&i.jsxs(Dt,{variant:"ghost",onClick:S,className:"w-full justify-start h-12 rounded-2xl text-slate-700 hover:bg-slate-100",children:[i.jsx(oc,{className:"h-4 w-4 mr-3 text-primary"}),"Save Contact"]}),t.show_leave_review&&t.review_source_url&&i.jsxs(Dt,{variant:"ghost",onClick:()=>{ei(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($l,{className:"h-4 w-4 mr-3 text-amber-500"}),"Leave a Review"]}),t.show_refer_friend&&i.jsxs(Dt,{variant:"ghost",onClick:k,className:"w-full justify-start h-12 rounded-2xl text-slate-700 hover:bg-slate-100",children:[i.jsx(ml,{className:"h-4 w-4 mr-3 text-primary"}),"Refer a Friend"]}),i.jsxs(Dt,{variant:"ghost",onClick:R,className:"w-full justify-start h-12 rounded-2xl text-slate-700 hover:bg-slate-100",children:[i.jsx(l3,{className:"h-4 w-4 mr-3 text-primary"}),"Connect with Me"]}),i.jsxs(Dt,{variant:"ghost",onClick:E,className:"w-full justify-start h-12 rounded-2xl text-slate-700 hover:bg-slate-100",children:[i.jsx(NN,{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:()=>ei(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:P[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(cF,{open:e,onOpenChange:r,cardId:t.id,type:n,agentName:o})]})}function gQe({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)=>{ei(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")}),p=()=>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")}),v=()=>{t.booking_url?a("book",()=>window.open(t.booking_url,"_blank")):(s("booking"),r(!0),ei(t.id,"button_click","book"))},S=()=>{var D,B;ei(t.id,"contact_saved"),dF({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()=>{ei(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!")},k=()=>{s("referral"),r(!0),ei(t.id,"button_click","refer")},R=()=>{s("connect"),r(!0),ei(t.id,"button_click","connect")},P={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(wd,{className:"h-32 w-32 mx-auto mb-5 ring-2 ring-[#c9a84c]/40 shadow-2xl",children:[i.jsx(Sd,{src:t.avatar_url||void 0,alt:o}),i.jsx(Td,{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:zn,label:"Call",handler:f},{icon:ph,label:"Text",handler:p},{icon:ns,label:"Email",handler:y}].map(({icon:D,label:B,handler:V})=>i.jsxs("button",{onClick:V,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:v,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(co,{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($l,{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(lF,{card:t,variant:"luxury"}),i.jsx(uF,{cardId:t.id,variant:"luxury"}),i.jsxs("div",{className:"space-y-1 mb-6",children:[t.show_save_contact&&i.jsxs("button",{onClick:S,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(oc,{className:"h-4 w-4 text-[#c9a84c]"})," Save Contact"]}),t.show_leave_review&&t.review_source_url&&i.jsxs("button",{onClick:()=>{ei(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($l,{className:"h-4 w-4 text-[#c9a84c]"})," Leave a Review"]}),t.show_refer_friend&&i.jsxs("button",{onClick:k,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(ml,{className:"h-4 w-4 text-[#c9a84c]"})," Refer a Friend"]}),i.jsxs("button",{onClick:R,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(l3,{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(NN,{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:()=>ei(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:P[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(cF,{open:e,onOpenChange:r,cardId:t.id,type:n,agentName:o})]})}function yQe({card:t}){var B,V,G,W;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(Y=>Y[0]).join("").toUpperCase().slice(0,2),a={accent:((V=t.bold_theme_colors)==null?void 0:V.accent)||"#ff5722",dark:((G=t.bold_theme_colors)==null?void 0:G.dark)||"#1a1a2e",button:((W=t.bold_theme_colors)==null?void 0:W.button)||"#ff5722"},f=(Y,J)=>{const Q=parseInt(Y.replace("#",""),16),ee=Math.max(0,(Q>>16)-J),le=Math.max(0,(Q>>8&255)-J),pe=Math.max(0,(Q&255)-J);return`#${(ee<<16|le<<8|pe).toString(16).padStart(6,"0")}`};f(a.accent,25),f(a.dark,-20),f(a.button,25);const p=(Y,J)=>{ei(t.id,"button_click",Y),J()},y=()=>p("call",()=>{var Y;(Y=t.profile)!=null&&Y.phone?window.location.href=`tel:${t.profile.phone}`:$t.error("Phone number not available")}),v=()=>p("text",()=>{var Y;(Y=t.profile)!=null&&Y.phone?window.location.href=`sms:${t.profile.phone}`:$t.error("Phone number not available")}),S=()=>p("email",()=>{var Y;(Y=t.profile)!=null&&Y.email?window.location.href=`mailto:${t.profile.email}`:$t.error("Email not available")}),E=()=>{t.booking_url?p("book",()=>window.open(t.booking_url,"_blank")):(s("booking"),r(!0),ei(t.id,"button_click","book"))},k=()=>{var Y,J;ei(t.id,"contact_saved"),dF({name:o,phone:(Y=t.profile)==null?void 0:Y.phone,email:(J=t.profile)==null?void 0:J.email,brokerage:t.brokerage_name,avatarUrl:t.avatar_url,cardUrl:window.location.href})},R=async()=>{ei(t.id,"share_event");const Y=`https://cards.relevelup.com/${t.slug}`,J="Here's my contact card — save it so we can stay in touch.";if(navigator.share)try{await navigator.share({title:`${o}`,text:J,url:Y})}catch{}else await navigator.clipboard.writeText(Y),$t.success("Link copied!")},P=()=>{s("referral"),r(!0),ei(t.id,"button_click","refer")},M=()=>{s("connect"),r(!0),ei(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(wd,{className:"h-28 w-28 mx-auto mb-4 shadow-2xl",style:{boxShadow:`0 0 0 4px ${a.accent}`},children:[i.jsx(Sd,{src:t.avatar_url||void 0,alt:o}),i.jsx(Td,{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:zn,label:"Call",handler:y},{icon:ph,label:"Text",handler:v},{icon:ns,label:"Email",handler:S}].map(({icon:Y,label:J,handler:Q})=>i.jsxs("button",{onClick:Q,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(Y,{className:"h-5 w-5"}),i.jsx("span",{className:"text-xs",children:J})]},J))}),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(co,{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($l,{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(lF,{card:t,variant:"bold"}),i.jsx(uF,{cardId:t.id,variant:"bold"}),i.jsxs("div",{className:"space-y-1 mb-6",children:[t.show_save_contact&&i.jsxs("button",{onClick:k,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(oc,{className:"h-4 w-4",style:{color:a.accent}})," Save Contact"]}),t.show_leave_review&&t.review_source_url&&i.jsxs("button",{onClick:()=>{ei(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($l,{className:"h-4 w-4",style:{color:a.accent}})," Leave a Review"]}),t.show_refer_friend&&i.jsxs("button",{onClick:P,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(ml,{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(l3,{className:"h-4 w-4",style:{color:a.accent}})," Connect with Me"]}),i.jsxs("button",{onClick:R,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(NN,{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((Y,J)=>i.jsx("a",{href:Y.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>ei(t.id,"button_click",`social_${Y.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[Y.platform.toLowerCase()]||"🔗"},J))})]}),i.jsx("div",{className:"text-center py-6",children:i.jsx("p",{className:"text-xs text-white/50",children:"Powered by LevelUp"})})]}),i.jsx(cF,{open:e,onOpenChange:r,cardId:t.id,type:n,agentName:o})]})}function xQe({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)=>{ei(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")}),p=()=>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")}),v=()=>{t.booking_url?a("book",()=>window.open(t.booking_url,"_blank")):(s("booking"),r(!0),ei(t.id,"button_click","book"))},S=()=>{var D,B;ei(t.id,"contact_saved"),dF({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()=>{ei(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!")},k=()=>{s("referral"),r(!0),ei(t.id,"button_click","refer")},R=()=>{s("connect"),r(!0),ei(t.id,"button_click","connect")},P={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(wd,{className:"h-28 w-28 mx-auto mb-4 ring-4 ring-white shadow-lg",children:[i.jsx(Sd,{src:t.avatar_url||void 0,alt:o}),i.jsx(Td,{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:zn,label:"Call",handler:f},{icon:ph,label:"Text",handler:p},{icon:ns,label:"Email",handler:y}].map(({icon:D,label:B,handler:V})=>i.jsxs("button",{onClick:V,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:v,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(co,{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($l,{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(lF,{card:t,variant:"classic"}),i.jsx(uF,{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:S,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(oc,{className:"h-4 w-4 text-[#5a7a6f]"})," Save Contact"]}),t.show_leave_review&&t.review_source_url&&i.jsxs("button",{onClick:()=>{ei(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($l,{className:"h-4 w-4 text-[#d4a843]"})," Leave a Review"]}),t.show_refer_friend&&i.jsxs("button",{onClick:k,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(ml,{className:"h-4 w-4 text-[#5a7a6f]"})," Refer a Friend"]}),i.jsxs("button",{onClick:R,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(l3,{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(NN,{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:()=>ei(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:P[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(cF,{open:e,onOpenChange:r,cardId:t.id,type:n,agentName:o})]})}function vQe({card:t}){switch(t.theme){case"luxury":return i.jsx(gQe,{card:t});case"bold":return i.jsx(yQe,{card:t});case"classic":return i.jsx(xQe,{card:t});case"standard":default:return i.jsx(pQe,{card:t})}}function _Qe(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 bQe(t){return`https://docs.google.com/gview?url=${encodeURIComponent(t)}&embedded=true`}function wQe(){if(typeof window>"u")return null;const t=_Qe(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:bQe(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(km,{className:"h-3.5 w-3.5"})," See Disclosures"]})]})}):null}function SQe(){const t=Es();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(TQe,{slug:e})}function TQe({slug:t}){return i.jsx(EQe,{slug:t})}function EQe({slug:t}){var o;const{data:e,isLoading:r,error:n}=ZXe(t);if(N.useEffect(()=>{e!=null&&e.id&&ei(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(pl,{className:"h-28 w-28 rounded-full"}),i.jsx(pl,{className:"h-6 w-48"}),i.jsx(pl,{className:"h-4 w-36"})]}),i.jsx(pl,{className:"h-12 w-full"}),i.jsx(pl,{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(Oo,{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(wQe,{}),i.jsx(vQe,{card:e})]})}function jQe({presentationId:t,ctaLabel:e,agentName:r,prefillName:n,prefillEmail:s,prefillPhone:o}){const[c,a]=N.useState(n||""),[f,p]=N.useState(s||""),[y,v]=N.useState(o||""),[S,E]=N.useState(""),[k,R]=N.useState(""),[P,M]=N.useState(!1),[D,B]=N.useState(!1),V=async G=>{if(G.preventDefault(),!c.trim()){$t.error("Please enter your name");return}M(!0);try{const{error:W}=await Re.from("smart_presentation_leads").insert({presentation_id:t,name:c.trim(),email:f.trim()||null,phone:y.trim()||null,intent:S||null,message:k.trim()||null});if(W)throw W;try{await Re.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{}Re.functions.invoke("presentation-lead-notify",{body:{presentationId:t,name:c.trim(),email:f.trim()||void 0,phone:y.trim()||void 0,intent:S||void 0,message:k.trim()||void 0}}).catch(Y=>console.error("Presentation lead notify failed:",Y)),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(Oa,{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:V,className:"space-y-4 max-w-md mx-auto",children:[i.jsxs("div",{children:[i.jsx(Mr,{htmlFor:"pres-lead-name",children:"Name *"}),i.jsx(Dr,{id:"pres-lead-name",value:c,onChange:G=>a(G.target.value),placeholder:"Your name",required:!0})]}),i.jsxs("div",{children:[i.jsx(Mr,{htmlFor:"pres-lead-phone",children:"Phone"}),i.jsx(Dr,{id:"pres-lead-phone",type:"tel",value:y,onChange:G=>v(G.target.value),placeholder:"(555) 123-4567"})]}),i.jsxs("div",{children:[i.jsx(Mr,{htmlFor:"pres-lead-email",children:"Email"}),i.jsx(Dr,{id:"pres-lead-email",type:"email",value:f,onChange:G=>p(G.target.value),placeholder:"you@example.com"})]}),i.jsxs("div",{children:[i.jsx(Mr,{htmlFor:"pres-lead-intent",children:"I'm looking to..."}),i.jsxs(ba,{value:S,onValueChange:E,children:[i.jsx(la,{children:i.jsx(wa,{placeholder:"Select one"})}),i.jsxs(ca,{children:[i.jsx(mn,{value:"buy",children:"Buy a home"}),i.jsx(mn,{value:"sell",children:"Sell my home"}),i.jsx(mn,{value:"both",children:"Buy & Sell"}),i.jsx(mn,{value:"other",children:"Something else"})]})]})]}),i.jsxs("div",{children:[i.jsx(Mr,{htmlFor:"pres-lead-message",children:"Message (optional)"}),i.jsx(Dr,{id:"pres-lead-message",value:k,onChange:G=>R(G.target.value),placeholder:"Anything you'd like us to know"})]}),i.jsx(Dt,{type:"submit",className:"w-full text-lg py-6 rounded-xl bg-blue-600 hover:bg-blue-700 text-white shadow-lg",disabled:P,children:P?"Sending...":e})]})}function AQe(){const t=Es();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(kQe,{shareToken:e})}function kQe({shareToken:t}){var k;const[e,r]=N.useState(null),[n,s]=N.useState(!0),[o,c]=N.useState(0),[a,f]=N.useState(!1);N.useEffect(()=>{p()},[t]);const p=async()=>{const{data:R,error:P}=await Re.from("smart_presentations").select("*").eq("share_token",t).eq("status","published").single();if(P||!R){f(!0),s(!1);return}const{data:M}=await Re.from("profiles").select("name, email, phone, avatar_url, title, brokerage_id").eq("id",R.owner_user_id).single();let D;if(M!=null&&M.brokerage_id){const{data:V}=await Re.from("brokerages").select("name").eq("id",M.brokerage_id).single();D=(V==null?void 0:V.name)||void 0}let B=null;if(R.contact_id){const{data:V}=await Re.from("innercircle_contacts").select("first_name, last_name, email, phone").eq("id",R.contact_id).single();B=V}r({...R,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 Re.rpc("log_presentation_view",{p_presentation_id:R.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 Re.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")}},v=R=>{const P=R.match(/(?:youtube\.com\/watch\?v=|youtu\.be\/)([a-zA-Z0-9_-]+)/);if(P)return`https://www.youtube.com/embed/${P[1]}?rel=0`;if(R.includes("iframe.mediadelivery.net/play/")){const B=R.replace("/play/","/embed/"),V=B.includes("?")?"&":"?";return`${B}${V}responsive=true`}if(R.includes("iframe.mediadelivery.net")){const B=R.includes("?")?"&":"?";return`${R}${B}responsive=true`}const M=R.match(/loom\.com\/share\/([a-zA-Z0-9]+)/);if(M)return`https://www.loom.com/embed/${M[1]}`;const D=R.match(/video\.bunnycdn\.com\/play\/(\d+)\/([a-f0-9-]+)/);return D?`https://iframe.mediadelivery.net/embed/${D[1]}/${D[2]}?responsive=true`:R};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(pl,{className:"h-12 w-3/4 mx-auto"}),i.jsx(pl,{className:"h-64 w-full"}),i.jsx(pl,{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 S=e.sections.filter(R=>R.is_visible!==!1),E=S[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:v(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:S.map((R,P)=>i.jsx("button",{onClick:()=>c(P),className:qt("w-full text-left p-4 rounded-xl border transition-all",o===P?"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(P+1).padStart(2,"0"),"."]}),i.jsxs("div",{children:[i.jsx("span",{className:"mr-2",children:R.icon}),i.jsx("span",{className:"font-semibold text-gray-900",children:R.title}),i.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:R.description})]})]})},P))})]}),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?"}),(k=e.cta_url)!=null&&k.trim()?i.jsxs(Dt,{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(N_,{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(jQe,{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 X9t(){const{user:t}=Wn(),e=Ls(),{data:r}=bT();return fr({queryKey:["open-houses",e,r==null?void 0:r.teamId,r==null?void 0:r.role],queryFn:async()=>{const{data:n,error:s}=await Re.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 Re.rpc("get_team_open_houses",{_user_id:e});if(!a&&c){const f=[...new Set(c.map(v=>v.agent_id))],p={};if(f.length>0){const{data:v}=await Re.from("profiles").select("id, name").in("id",f);v==null||v.forEach(S=>{S.name&&(p[S.id]=S.name)})}const y=c.map(v=>({...v,agent_name:p[v.agent_id]||void 0}));o=[...o,...y]}}return o.sort((c,a)=>a.event_date.localeCompare(c.event_date)),o},enabled:!!t&&!!e})}function Q9t(t){const{user:e}=Wn();return fr({queryKey:["open-house",t],queryFn:async()=>{const{data:r,error:n}=await Re.from("open_houses").select("*").eq("id",t).single();if(n)throw n;return r},enabled:!!e&&!!t})}function J9t(t){const{user:e}=Wn(),r=Er();return N.useEffect(()=>{if(!t)return;const n=`visitors-${t}-${Math.random().toString(36).slice(2,10)}`,s=Re.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()=>{Re.removeChannel(s)}},[t,r]),fr({queryKey:["open-house-visitors",t],queryFn:async()=>{const{data:n,error:s}=await Re.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 e7t(){const t=Er(),e=Ls();return wr({mutationFn:async r=>{const{data:n,error:s}=await Re.from("open_houses").insert({...r,agent_id:e}).select().single();if(s)throw s;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["open-houses"]}),Ai({title:"Open house created!"})},onError:r=>{Ai({title:"Error",description:r.message,variant:"destructive"})}})}function t7t(){const t=Er();return wr({mutationFn:async({id:e,...r})=>{const{error:n}=await Re.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 r7t(){const t=Er();return wr({mutationFn:async e=>{const{error:r}=await Re.from("open_houses").delete().eq("id",e);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["open-houses"]}),Ai({title:"Open house deleted"})}})}function pbe(t){return fr({queryKey:["public-open-house",t],queryFn:async()=>{const{data:e,error:r}=await Re.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 Re.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 n7t(t){const{user:e}=Wn();return fr({queryKey:["survey-questions",t],queryFn:async()=>{const{data:r,error:n}=await Re.from("open_house_survey_questions").select("*").eq("open_house_id",t).order("sort_order");if(n)throw n;return r},enabled:!!e&&!!t})}function NQe(t){return fr({queryKey:["public-survey-questions",t],queryFn:async()=>{const{data:e,error:r}=await Re.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 CQe(){return wr({mutationFn:async t=>{const{error:e}=await Re.from("open_house_survey_responses").insert(t);if(e)throw e}})}function s7t(t){const{user:e}=Wn();return fr({queryKey:["survey-responses",t],queryFn:async()=>{const{data:r,error:n}=await Re.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 Re.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 i7t(){const t=Er();return wr({mutationFn:async e=>{const{data:r,error:n}=await Re.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 a7t(){const t=Er();return wr({mutationFn:async({id:e,open_house_id:r,...n})=>{const{error:s}=await Re.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 o7t(){const t=Er();return wr({mutationFn:async({id:e,open_house_id:r})=>{const{error:n}=await Re.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 l7t(){const t=Er();return wr({mutationFn:async e=>{const{error:r}=await Re.rpc("seed_default_survey_questions",{_open_house_id:e});if(r)throw r},onSuccess:(e,r)=>{t.invalidateQueries({queryKey:["survey-questions",r]})}})}function IQe(){return wr({mutationFn:async t=>{const e=crypto.randomUUID(),{error:r}=await Re.from("open_house_visitors").insert({...t,id:e});if(r)throw r;return{id:e}}})}function PQe(){return wr({mutationFn:async({visitor_id:t,...e})=>{const{error:r}=await Re.from("open_house_visitors").update(e).eq("id",t);if(r)throw r}})}function RQe(){return wr({mutationFn:async t=>{await Re.rpc("increment_open_house_scan",{_slug:t})}})}async function gbe(t){const{data:e,error:r}=await Re.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 Re.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 p=f;(a[y=p.room_id]||(a[y]=[])).push(p)}),n.map(f=>({...f,media:a[f.id]||[]}))}function c7t(t){const{user:e}=Wn();return fr({queryKey:["open-house-rooms",t],queryFn:()=>gbe(t),enabled:!!e&&!!t})}function LQe(t){return fr({queryKey:["public-open-house-rooms",t],queryFn:()=>gbe(t),enabled:!!t})}function u7t(){const t=Er();return wr({mutationFn:async e=>{const{data:r,error:n}=await Re.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 d7t(){const t=Er();return wr({mutationFn:async({id:e,open_house_id:r,...n})=>{const{error:s}=await Re.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 h7t(){const t=Er();return wr({mutationFn:async({id:e,open_house_id:r})=>{const{error:n}=await Re.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 f7t(){const t=Er();return wr({mutationFn:async({open_house_id:e,...r})=>{const{data:n,error:s}=await Re.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 m7t(){const t=Er();return wr({mutationFn:async({id:e,open_house_id:r})=>{const{error:n}=await Re.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 p7t(){const t=Er();return wr({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 g7t(){const t=Er();return wr({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,p)=>{const y=a.get(f);return y?{...y,sort_order:p}: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 y7t(t){const{user:e}=Wn();return fr({queryKey:["open-house-leads",t],queryFn:async()=>{const{data:r,error:n}=await Re.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 x7t(){const t=Er();return wr({mutationFn:async({id:e,status:r,open_house_id:n})=>{const{error:s}=await Re.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 hF="Switch",[MQe,v7t]=Jo(hF),[DQe,OQe]=MQe(hF),ybe=N.forwardRef((t,e)=>{const{__scopeSwitch:r,name:n,checked:s,defaultChecked:o,required:c,disabled:a,value:f="on",onCheckedChange:p,form:y,...v}=t,[S,E]=N.useState(null),k=Zn(e,B=>E(B)),R=N.useRef(!1),P=S?y||!!S.closest("form"):!0,[M,D]=_d({prop:s,defaultProp:o??!1,onChange:p,caller:hF});return i.jsxs(DQe,{scope:r,checked:M,disabled:a,children:[i.jsx(nn.button,{type:"button",role:"switch","aria-checked":M,"aria-required":c,"data-state":bbe(M),"data-disabled":a?"":void 0,disabled:a,value:f,...v,ref:k,onClick:Fr(t.onClick,B=>{D(V=>!V),P&&(R.current=B.isPropagationStopped(),R.current||B.stopPropagation())})}),P&&i.jsx(_be,{control:S,bubbles:!R.current,name:n,value:f,checked:M,required:c,disabled:a,form:y,style:{transform:"translateX(-100%)"}})]})});ybe.displayName=hF;var xbe="SwitchThumb",vbe=N.forwardRef((t,e)=>{const{__scopeSwitch:r,...n}=t,s=OQe(xbe,r);return i.jsx(nn.span,{"data-state":bbe(s.checked),"data-disabled":s.disabled?"":void 0,...n,ref:e})});vbe.displayName=xbe;var FQe="SwitchBubbleInput",_be=N.forwardRef(({__scopeSwitch:t,control:e,checked:r,bubbles:n=!0,...s},o)=>{const c=N.useRef(null),a=Zn(c,o),f=KN(r),p=ON(e);return N.useEffect(()=>{const y=c.current;if(!y)return;const v=window.HTMLInputElement.prototype,E=Object.getOwnPropertyDescriptor(v,"checked").set;if(f!==r&&E){const k=new Event("click",{bubbles:n});E.call(y,r),y.dispatchEvent(k)}},[f,r,n]),i.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:r,...s,tabIndex:-1,ref:a,style:{...s.style,...p,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});_be.displayName=FQe;function bbe(t){return t?"checked":"unchecked"}var wbe=ybe,BQe=vbe;const jT=N.forwardRef(({className:t,...e},r)=>i.jsx(wbe,{className:qt("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(BQe,{className:qt("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")})}));jT.displayName=wbe.displayName;const $Qe=["Excellent","Good","Neutral","Bad","Very Bad"],zQe=[5,4,3,2,1];function UQe({questions:t,visitorId:e,onComplete:r,onSkip:n}){const s=CQe(),[o,c]=N.useState({}),a=t.filter(S=>S.question_type==="rating"),f=t.filter(S=>S.question_type!=="rating"),p=(S,E)=>{c(k=>({...k,[S]:{rating_value:E}}))},y=(S,E)=>{c(k=>({...k,[S]:{text_value:E}}))},v=async()=>{const S=Object.entries(o).filter(([,E])=>E.rating_value!=null||E.text_value&&E.text_value.trim()).map(([E,k])=>{var R;return{visitor_id:e,question_id:E,rating_value:k.rating_value??null,text_value:((R=k.text_value)==null?void 0:R.trim())||null}});if(S.length>0)try{await s.mutateAsync(S)}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"}),$Qe.map(S=>i.jsx("div",{className:"w-12 text-center",children:i.jsx("span",{className:"text-[10px] text-slate-400 leading-tight block",children:S})},S))]}),a.map(S=>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:S.question_text}),zQe.map(E=>{var k;return i.jsx("div",{className:"w-12 flex justify-center",children:i.jsx("button",{type:"button",onClick:()=>p(S.id,E),className:`w-6 h-6 rounded-full border-2 transition-all ${((k=o[S.id])==null?void 0:k.rating_value)===E?"bg-slate-900 border-slate-900":"border-slate-300 hover:border-slate-500"}`})},E)})]},S.id))]}),f.map(S=>{var E;return i.jsxs("div",{children:[i.jsx("label",{className:"text-sm font-medium text-slate-700 block mb-1",children:S.question_text}),i.jsx(Bu,{value:((E=o[S.id])==null?void 0:E.text_value)||"",onChange:k=>y(S.id,k.target.value),placeholder:"Your thoughts...",className:"h-16 text-sm resize-none rounded-xl border-slate-200"})]},S.id)}),i.jsx(Dt,{onClick:v,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(jc,{className:"h-5 w-5 animate-spin"}):"Submit Feedback"})]})}function m8(t){return/iframe\.mediadelivery\.net\/embed\//.test(t)}function VQe({rooms:t}){var R;const[e,r]=N.useState(((R=t[0])==null?void 0:R.id)||""),[n,s]=N.useState(null),[o,c]=N.useState(null),a=N.useRef({}),f=t.find(P=>P.id===n)||t[0],p=o!==null?f==null?void 0:f.media[o]:null,y=(f==null?void 0:f.media.length)??0,v=()=>{c(null),s(null)},S=()=>c(P=>P===null||y===0?P:(P-1+y)%y),E=()=>c(P=>P===null||y===0?P:(P+1)%y);N.useEffect(()=>{if(o===null)return;const P=M=>{M.key==="Escape"?v():M.key==="ArrowLeft"?S():M.key==="ArrowRight"&&E()};return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)},[o,y]),N.useEffect(()=>{const P=new IntersectionObserver(M=>{const D=M.filter(B=>B.isIntersecting).sort((B,V)=>B.boundingClientRect.top-V.boundingClientRect.top);D[0]&&r(D[0].target.dataset.roomId||"")},{rootMargin:"-90px 0px -55% 0px"});return Object.values(a.current).forEach(M=>M&&P.observe(M)),()=>P.disconnect()},[t]);const k=P=>{r(P);const M=a.current[P];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(P=>i.jsxs("button",{onClick:()=>k(P.id),className:qt("px-4 py-2 rounded-full text-sm font-medium whitespace-nowrap transition",e===P.id?"bg-white text-slate-900":"bg-white/5 text-white/70 hover:bg-white/10"),children:[P.name,i.jsx("span",{className:"ml-1.5 text-xs opacity-60",children:P.media.length})]},P.id))})}),t.map(P=>i.jsxs("section",{"data-room-id":P.id,ref:M=>{a.current[P.id]=M},className:"mt-10 first:mt-6",children:[i.jsx("h3",{className:"text-2xl font-bold",children:P.name}),P.description&&i.jsx("p",{className:"text-white/60 mt-1.5 text-sm max-w-2xl",children:P.description}),P.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:P.media.map((M,D)=>i.jsx("button",{onClick:()=>{s(P.id),c(D)},className:qt("relative aspect-[3/2] rounded-xl overflow-hidden bg-white/5 group",D===0&&P.media.length!==2&&"col-span-2 aspect-[16/9]"),children:M.kind==="video"?i.jsxs(i.Fragment,{children:[m8(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(hA,{className:"h-6 w-6 text-slate-900"})})})]}):i.jsx("img",{src:M.url,alt:P.name,loading:"lazy",className:"w-full h-full object-cover group-hover:scale-[1.03] transition-transform duration-500"})},M.id))})]},P.id)),p&&f&&i.jsxs("div",{className:"fixed inset-0 z-50 bg-black/95 flex items-center justify-center p-6 cursor-zoom-out",onClick:v,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:P=>{P.stopPropagation(),v()},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:P=>{P.stopPropagation(),S()},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(Om,{className:"h-6 w-6"})}),p.kind==="video"?m8(p.url)?i.jsx("iframe",{src:`${p.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:P=>P.stopPropagation()},p.url):i.jsx("video",{src:p.url,controls:!0,autoPlay:!0,className:"max-w-full max-h-full rounded-lg",onClick:P=>P.stopPropagation()},p.url):i.jsx("img",{src:p.url,alt:"",className:"max-w-full max-h-full rounded-lg cursor-default",onClick:P=>P.stopPropagation()}),y>1&&i.jsx("button",{onClick:P=>{P.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(kd,{className:"h-6 w-6"})})]})]}):null}function qQe({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((p,y)=>{e.push({type:"media",roomId:f.id,roomName:f.name,url:p.url,kind:p.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 p=0;const y=()=>{cancelAnimationFrame(p),p=requestAnimationFrame(()=>{const v=Math.round(f.scrollLeft/f.clientWidth);s(v)})};return f.addEventListener("scroll",y,{passive:!0}),()=>{f.removeEventListener("scroll",y),cancelAnimationFrame(p)}},[]);const o=f=>{const p=r.current;p&&p.scrollTo({left:f*p.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 p=e.findIndex(v=>v.roomId===f.id),y=c===f.id;return i.jsx("button",{onClick:()=>o(p),className:qt("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,p)=>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"?m8(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]})]})]})},p))}),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(Om,{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(kd,{className:"h-4 w-4"})]})]})]})}const hz={question:{label:"Ask a Question",title:"Ask the agent",placeholder:"What would you like to know about the home?",icon:ph},showing:{label:"Schedule a Showing",title:"Request a private showing",placeholder:"Anything specific to focus on during the showing? (optional)",icon:co},disclosure:{label:"Request Disclosures",title:"Request seller disclosures",placeholder:"Any specific documents? (optional)",icon:km},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:Yp}},GQe=["Seller's Property Disclosure","HOA Documents & Bylaws","Inspection Reports","Title / CC&Rs","Utility & Tax History"];function HQe(t){return t==null||t<=0?null:`$${t.toLocaleString("en-US")}`}function WQe({openHouse:t,visitorId:e,visitorName:r,visitorEmail:n,visitorPhone:s,previewMode:o=!1}){var tr;const c=t.profiles,a=((tr=c==null?void 0:c.name)==null?void 0:tr.split(" ").map(wt=>wt[0]).join("").slice(0,2))||"?",f=t.brand_color_override||null,[p,y]=N.useState(null),[v,S]=N.useState(""),[E,k]=N.useState(n||""),[R,P]=N.useState(s||""),[M,D]=N.useState(!1),[B,V]=N.useState(null),[G,W]=N.useState(""),[Y,J]=N.useState(""),[Q,ee]=N.useState(""),[le,pe]=N.useState([]),[Te,Ae]=N.useState(""),[Le,ke]=N.useState(""),[we,me]=N.useState(""),[je,_e]=N.useState(""),Ee=HQe(t.price),ve=t.tour_mode==="rooms",{data:qe=[]}=LQe(ve?t.id:void 0),nt=[t.enable_question&&"question",t.enable_showing&&"showing",t.enable_disclosures&&"disclosure",t.enable_offer&&"offer"].filter(Boolean),ot=wt=>{y(wt),S(""),W(""),J(""),ee(""),pe([]),Ae(""),ke(""),me(""),_e("")},jt=()=>{y(null)},vt=wt=>{pe(lr=>lr.includes(wt)?lr.filter(Sr=>Sr!==wt):[...lr,wt])},Gt=wt=>wt==="showing"?{preferred_date:G||null,preferred_time:Y||null,alternate_date:Q||null}:wt==="disclosure"?{requested_documents:le}:wt==="offer"?{offer_amount:Te||null,financing:Le||null,timeline:we||null,pre_approved:je||null}:{},pt=p?p==="showing"?!!G:p==="question"?v.trim().length>0:!0:!1,Ct=async()=>{if(p){if(o){Ai({title:"Preview mode",description:"Lead not sent — this is just a preview."}),V(p),setTimeout(()=>{y(null),V(null)},1500);return}D(!0);try{const wt=Gt(p),{error:lr}=await Re.from("open_house_leads").insert({open_house_id:t.id,visitor_id:e,action_type:p,payload:{message:v.trim()||null,email:E.trim()||null,phone:R.trim()||null,visitor_name:r,...wt}});if(lr)throw lr;Re.functions.invoke("send-virtual-open-house-lead",{body:{open_house_id:t.id,visitor_id:e,action_type:p,message:v.trim()||null,visitor_name:r,visitor_email:E.trim()||null,visitor_phone:R.trim()||null,extras:wt}}).catch(()=>{}),V(p),Ai({title:"Sent!",description:"The agent has been notified."}),setTimeout(()=>{jt(),V(null)},1400)}catch(wt){Ai({title:"Something went wrong",description:wt.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(di,{className:"h-3.5 w-3.5"}),t.city,t.state?`, ${t.state}`:""," ",t.zip]}),Ee&&i.jsx("p",{className:"text-3xl font-bold text-white mt-3",children:Ee}),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(oT,{className:"h-4 w-4"}),t.beds," bd"]}),t.baths!=null&&i.jsxs("span",{className:"flex items-center gap-1.5",children:[i.jsx(k_,{className:"h-4 w-4"}),t.baths," ba"]}),t.sqft!=null&&i.jsxs("span",{className:"flex items-center gap-1.5",children:[i.jsx(W9,{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(wd,{className:"h-12 w-12 ring-2 ring-white/20",style:f?{boxShadow:`0 0 0 2px ${f}`}:void 0,children:[i.jsx(Sd,{src:c.avatar_url||"",alt:c.name||""}),i.jsx(Td,{className:"bg-white/10 text-white",children:a})]}),t.co_host_name&&i.jsxs(wd,{className:"h-12 w-12 -ml-6 ring-2 ring-slate-950",children:[i.jsx(Sd,{src:t.co_host_photo_url||"",alt:t.co_host_name}),i.jsx(Td,{className:"bg-white/10 text-white",children:String(t.co_host_name).split(" ").map(wt=>wt[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(zn,{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(ns,{className:"h-4 w-4"})})]})]}),ve&&qe.length>0&&i.jsxs("div",{className:"mt-8",children:[i.jsx(VQe,{rooms:qe}),i.jsx(qQe,{rooms:qe})]}),nt.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:nt.map(wt=>{const lr=hz[wt],Sr=lr.icon;return i.jsxs("button",{onClick:()=>ot(wt),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:lr.label})]},wt)})})]}),i.jsx("p",{className:"text-center text-white/30 text-xs mt-8",children:"Powered by LevelUp Virtual Open House"})]}),i.jsx($xe,{open:!!p,onOpenChange:wt=>!wt&&jt(),children:i.jsx(z7,{side:"bottom",className:"rounded-t-2xl max-h-[92vh] overflow-y-auto",children:p&&i.jsxs(i.Fragment,{children:[i.jsxs(Uxe,{className:"text-left",children:[i.jsx(Vxe,{children:hz[p].title}),i.jsxs(qxe,{children:[(c==null?void 0:c.name)||"The agent"," will be notified by email."]})]}),B===p?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(Bl,{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(Mr,{className:"text-xs",children:"Email"}),i.jsx(Dr,{type:"email",value:E,onChange:wt=>k(wt.target.value),placeholder:"you@example.com",className:"mt-1"})]}),i.jsxs("div",{children:[i.jsx(Mr,{className:"text-xs",children:"Phone"}),i.jsx(Dr,{type:"tel",value:R,onChange:wt=>P(wt.target.value),placeholder:"(555) 123-4567",className:"mt-1"})]})]}),p==="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(Mr,{className:"text-xs",children:"Preferred date *"}),i.jsx(Dr,{type:"date",value:G,onChange:wt=>W(wt.target.value),className:"mt-1"})]}),i.jsxs("div",{children:[i.jsx(Mr,{className:"text-xs",children:"Preferred time"}),i.jsx(Dr,{type:"time",value:Y,onChange:wt=>J(wt.target.value),className:"mt-1"})]})]}),i.jsxs("div",{children:[i.jsx(Mr,{className:"text-xs",children:"Alternate date (optional)"}),i.jsx(Dr,{type:"date",value:Q,onChange:wt=>ee(wt.target.value),className:"mt-1"})]})]}),p==="disclosure"&&i.jsxs("div",{children:[i.jsx(Mr,{className:"text-xs",children:"Which documents? (select all that apply)"}),i.jsx("div",{className:"mt-2 space-y-2",children:GQe.map(wt=>i.jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[i.jsx(TT,{checked:le.includes(wt),onCheckedChange:()=>vt(wt)}),i.jsx("span",{children:wt})]},wt))})]}),p==="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(Mr,{className:"text-xs",children:"Estimated offer"}),i.jsx(Dr,{value:Te,onChange:wt=>Ae(wt.target.value),placeholder:"$",className:"mt-1"})]}),i.jsxs("div",{children:[i.jsx(Mr,{className:"text-xs",children:"Financing"}),i.jsxs(ba,{value:Le,onValueChange:ke,children:[i.jsx(la,{className:"mt-1",children:i.jsx(wa,{placeholder:"Select..."})}),i.jsxs(ca,{children:[i.jsx(mn,{value:"Cash",children:"Cash"}),i.jsx(mn,{value:"Conventional",children:"Conventional"}),i.jsx(mn,{value:"FHA",children:"FHA"}),i.jsx(mn,{value:"VA",children:"VA"}),i.jsx(mn,{value:"Other",children:"Other"})]})]})]})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[i.jsxs("div",{children:[i.jsx(Mr,{className:"text-xs",children:"Timeline"}),i.jsxs(ba,{value:we,onValueChange:me,children:[i.jsx(la,{className:"mt-1",children:i.jsx(wa,{placeholder:"Select..."})}),i.jsxs(ca,{children:[i.jsx(mn,{value:"ASAP",children:"ASAP"}),i.jsx(mn,{value:"30 days",children:"30 days"}),i.jsx(mn,{value:"60 days",children:"60 days"}),i.jsx(mn,{value:"90+ days",children:"90+ days"})]})]})]}),i.jsxs("div",{children:[i.jsx(Mr,{className:"text-xs",children:"Pre-approved?"}),i.jsxs(ba,{value:je,onValueChange:_e,children:[i.jsx(la,{className:"mt-1",children:i.jsx(wa,{placeholder:"Select..."})}),i.jsxs(ca,{children:[i.jsx(mn,{value:"Yes",children:"Yes"}),i.jsx(mn,{value:"No",children:"No"}),i.jsx(mn,{value:"In progress",children:"In progress"})]})]})]})]})]}),i.jsxs("div",{children:[i.jsxs(Mr,{className:"text-xs",children:["Message",p==="question"?" *":" (optional)"]}),i.jsx(Bu,{value:v,onChange:wt=>S(wt.target.value),placeholder:hz[p].placeholder,rows:4,className:"mt-1"})]}),i.jsx(Dt,{onClick:Ct,disabled:M||!pt,className:"w-full h-12 text-white hover:opacity-90",style:f?{backgroundColor:f}:void 0,children:M?i.jsx(jc,{className:"h-4 w-4 animate-spin"}):"Send to agent"})]})]})})})]})}const KQe=bg({first_name:Ns().trim().min(1,"First name is required").max(50),last_name:Ns().trim().max(50).optional(),email:Ns().trim().email("Please enter a valid email").max(255).optional().or(cD("")),phone:Ns().trim().max(20).optional().or(cD(""))}),YQe=[{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 Sbe({slug:t}={}){var ar;const e=$m(),r=t||e.slug,[n]=Fx(),s=n.get("kiosk")==="1"||n.get("mode")==="kiosk",o=8,{data:c,isLoading:a,error:f}=pbe(r),p=IQe(),y=PQe(),v=RQe(),S=N.useRef(!1),[E,k]=N.useState("welcome"),[R,P]=N.useState(null),[M,D]=N.useState({first_name:"",last_name:"",email:"",phone:"",visitor_address:""}),[B,V]=N.useState(""),[G,W]=N.useState(!1),[Y,J]=N.useState(!1),[Q,ee]=N.useState(""),[le,pe]=N.useState(""),[Te,Ae]=N.useState(o),[Le,ke]=N.useState(!1),[we,me]=N.useState(null),je=c==null?void 0:c.agent_card_slug,_e=je?`https://cards.relevelup.com/${je}${c!=null&&c.disclosure_pdf_url?`?oh_disclosure=${encodeURIComponent(c.disclosure_pdf_url)}`:""}`:null,Ee=E==="done"&&!s&&!!_e&&!!(c!=null&&c.auto_forward_to_card);N.useEffect(()=>{if(!Ee||Le){me(null);return}let It=c!=null&&c.disclosure_pdf_url?10:3;me(It);const pr=setInterval(()=>{if(It-=1,It<=0){clearInterval(pr),window.location.href=_e;return}me(It)},1e3);return()=>clearInterval(pr)},[Ee,Le,_e,c==null?void 0:c.disclosure_pdf_url]);const ve=N.useCallback(()=>{P(null),D({first_name:"",last_name:"",email:"",phone:"",visitor_address:""}),V(""),W(!1),J(!1),ee(""),pe(""),Ae(o),k(s?"info":"welcome")},[s]),qe=N.useCallback((It,pr)=>{c!=null&&c.id&&Re.functions.invoke("guestbook-lead-notify",{body:{open_house_id:c.id,visitor_id:It,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??G,has_agent:pr.has_agent??Y,working_with_agent_name:pr.working_with_agent_name??Q,visitor_address:pr.visitor_address??M.visitor_address}}).catch(Tn=>console.error("Guest book lead notify failed:",Tn))},[c==null?void 0:c.id,M,B,G,Y,Q]);N.useEffect(()=>{if(!s||E!=="done")return;Ae(o);const It=setInterval(()=>{Ae(pr=>pr<=1?(clearInterval(It),ve(),0):pr-1)},1e3);return()=>clearInterval(It)},[s,E,ve]),N.useEffect(()=>{if(!s)return;k(pr=>pr==="welcome"?"info":pr);let It=null;return(async()=>{var pr,Tn;try{It=await((Tn=(pr=navigator.wakeLock)==null?void 0:pr.request)==null?void 0:Tn.call(pr,"screen"))}catch{}})(),()=>{var pr;try{(pr=It==null?void 0:It.release)==null||pr.call(It)}catch{}}},[s]);const nt=N.useCallback(()=>{var pr;const It=document.documentElement;document.fullscreenElement||(pr=It.requestFullscreen||It.webkitRequestFullscreen)==null||pr.call(It).catch(()=>{})},[]),{data:ot,isLoading:jt}=NQe(c==null?void 0:c.id),vt=!!(c!=null&&c.enable_survey),Gt=(c==null?void 0:c.ask_visitor_intent)!==!1,pt=(c==null?void 0:c.ask_visitor_address)===!0;N.useEffect(()=>{if(!r||!(c!=null&&c.id)||S.current)return;const It=`oh_scan_${c.id}`;if(sessionStorage.getItem(It)){S.current=!0;return}S.current=!0,sessionStorage.setItem(It,"1"),v.mutate(r)},[r,c==null?void 0:c.id]),N.useEffect(()=>{E==="pending_survey"&&(jt||k(vt&&((ot==null?void 0:ot.length)??0)>0?"survey":"done"))},[E,jt,vt,ot]);const Ct=It=>{if(!It)return"";const[pr,Tn]=It.split(":"),ss=parseInt(pr),is=ss>=12?"PM":"AM";return`${ss>12?ss-12:ss||12}:${Tn} ${is}`},tr=async()=>{pe("");const It=KQe.safeParse(M);if(!It.success){pe(It.error.issues[0].message);return}if(!M.email&&!M.phone){pe("Please provide either an email or phone number");return}const pr=(c==null?void 0:c.kind)==="virtual";let Tn=null;if(!R&&(c!=null&&c.id))try{const ss=await p.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:pt&&M.visitor_address.trim()?M.visitor_address.trim():void 0,wants_market_updates:G,has_agent:Y,working_with_agent_name:Y&&Q.trim()?Q.trim():void 0,partial_signin:pr?!1:Gt});Tn=ss.id,P(ss.id)}catch{if(pr){pe("We could not start the virtual tour. Please try again.");return}}if(pr){Gt?k("intent"):(Tn&&qe(Tn,{}),k("done"));return}if(!Gt){Tn&&qe(Tn,{}),vt?!jt&&ot&&ot.length>0?k("survey"):k("pending_survey"):k("done");return}k("intent")},wt=async It=>{V(It);try{let pr=R;if(pr?await y.mutateAsync({visitor_id:pr,visitor_intent:It,wants_market_updates:G,has_agent:Y,working_with_agent_name:Y&&Q.trim()?Q.trim():null,partial_signin:!1}):(pr=(await p.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:pt&&M.visitor_address.trim()?M.visitor_address.trim():void 0,visitor_intent:It,wants_market_updates:G,has_agent:Y,working_with_agent_name:Y&&Q.trim()?Q.trim():void 0,partial_signin:!1})).id,P(pr)),pr&&qe(pr,{visitor_intent:It,wants_market_updates:G,has_agent:Y,working_with_agent_name:Y&&Q.trim()?Q.trim():null}),(c==null?void 0:c.kind)==="virtual"){k("done");return}vt?!jt&&ot&&ot.length>0?k("survey"):k("pending_survey"):k("done")}catch{pe("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(Gi,{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 lr=c.profiles,Sr=((ar=lr==null?void 0:lr.name)==null?void 0:ar.split(" ").map(It=>It[0]).join("").slice(0,2))||"?",sn=c.event_type==="community",cr=c.kind==="virtual",yr=typeof window<"u"&&new URLSearchParams(window.location.search).get("preview")==="1";if(cr&&(yr||E==="done"))return!yr&&!R?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(Oo,{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"})]}),yr&&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(WQe,{openHouse:c,visitorId:yr?"preview":R,visitorName:yr?"Preview Visitor":`${M.first_name} ${M.last_name}`.trim(),visitorEmail:yr?"":M.email,visitorPhone:yr?"":M.phone,previewMode:yr})]});const jn=`${cr?"Virtual Open House":sn?"Community Event":"Open House"} — ${c.property_address}`,St=[[c.city,c.state].filter(Boolean).join(", "),c.event_date?As(new Date(c.event_date+"T00:00:00"),"EEE, MMM d"):null,lr!=null&&lr.name?`Hosted by ${lr.name}`:null].filter(Boolean).join(" · "),Jt=c.photo_url||"",Ir=Jt&&Jt.includes("/storage/v1/object/public/")?Jt.replace("/object/public/","/render/image/public/")+"?width=1200&height=630&resize=cover":Jt||"https://dashboard.relevelup.com/og-image.png",ur=typeof window<"u"?window.location.href:`https://guestbook.relevelup.com/${r}`;return i.jsxs(i.Fragment,{children:[i.jsxs(Oo,{children:[i.jsx("title",{children:jn}),i.jsx("meta",{name:"description",content:St||`Sign in to ${c.property_address}`}),i.jsx("meta",{property:"og:type",content:"website"}),i.jsx("meta",{property:"og:title",content:jn}),i.jsx("meta",{property:"og:description",content:St||`Sign in to ${c.property_address}`}),i.jsx("meta",{property:"og:image",content:Ir}),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:ur}),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:jn}),i.jsx("meta",{name:"twitter:description",content:St||`Sign in to ${c.property_address}`}),i.jsx("meta",{name:"twitter:image",content:Ir}),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(wd,{className:"h-16 w-16 mx-auto mb-3 ring-2 ring-white/20",children:[i.jsx(Sd,{src:(lr==null?void 0:lr.avatar_url)||"",alt:(lr==null?void 0:lr.name)||""}),i.jsx(Td,{className:"bg-white/10 text-white text-lg",children:Sr})]}),i.jsx("p",{className:"text-white/60 text-sm",children:lr==null?void 0:lr.name}),(lr==null?void 0:lr.title)&&i.jsx("p",{className:"text-white/40 text-xs",children:lr.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(di,{className:"h-3 w-3"}),c.city,c.state?`, ${c.state}`:""," ",c.zip]}),!cr&&i.jsxs(i.Fragment,{children:[i.jsxs("span",{className:"flex items-center gap-1",children:[i.jsx(co,{className:"h-3 w-3"}),As(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(Ml,{className:"h-3 w-3"}),Ct(c.start_time),c.end_time?` – ${Ct(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:sn?i.jsx(so,{className:"h-5 w-5 text-white"}):i.jsx(Gi,{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(di,{className:"h-3 w-3"}),c.city,c.state?`, ${c.state}`:""," ",c.zip]}),!cr&&i.jsxs(i.Fragment,{children:[i.jsxs("span",{className:"flex items-center gap-1",children:[i.jsx(co,{className:"h-3 w-3"}),As(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(Ml,{className:"h-3 w-3"}),Ct(c.start_time),c.end_time?` – ${Ct(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(Dt,{onClick:()=>k("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:()=>k("welcome"),className:"text-slate-400 hover:text-slate-600",children:i.jsx(yx,{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(Mr,{className:"text-slate-600 text-xs",children:"First Name *"}),i.jsx(Dr,{value:M.first_name,onChange:It=>D(pr=>({...pr,first_name:It.target.value})),placeholder:"First",className:"mt-1 h-12 rounded-xl border-slate-200 text-base",autoFocus:!0})]}),i.jsxs("div",{children:[i.jsx(Mr,{className:"text-slate-600 text-xs",children:"Last Name"}),i.jsx(Dr,{value:M.last_name,onChange:It=>D(pr=>({...pr,last_name:It.target.value})),placeholder:"Last",className:"mt-1 h-12 rounded-xl border-slate-200 text-base"})]})]}),i.jsxs("div",{children:[i.jsx(Mr,{className:"text-slate-600 text-xs",children:"Email"}),i.jsx(Dr,{type:"email",value:M.email,onChange:It=>D(pr=>({...pr,email:It.target.value})),placeholder:"your@email.com",className:"mt-1 h-12 rounded-xl border-slate-200 text-base"})]}),i.jsxs("div",{children:[i.jsx(Mr,{className:"text-slate-600 text-xs",children:"Phone"}),i.jsx(Dr,{type:"tel",value:M.phone,onChange:It=>D(pr=>({...pr,phone:It.target.value})),placeholder:"(555) 123-4567",className:"mt-1 h-12 rounded-xl border-slate-200 text-base"})]}),pt&&i.jsxs("div",{children:[i.jsx(Mr,{className:"text-slate-600 text-xs",children:"Your Home Address"}),i.jsx(Dr,{value:M.visitor_address,onChange:It=>D(pr=>({...pr,visitor_address:It.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:G,onChange:It=>W(It.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:Y?"Yes":"No"}),i.jsx(jT,{checked:Y,onCheckedChange:J})]})]}),Y&&i.jsx(Dr,{value:Q,onChange:It=>ee(It.target.value),placeholder:"Agent's name",className:"mt-1 h-10 rounded-xl border-slate-200 text-sm"})]}),le&&i.jsx("p",{className:"text-destructive text-sm",children:le}),i.jsxs(Dt,{onClick:tr,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:()=>k("info"),className:"text-slate-400 hover:text-slate-600",children:i.jsx(yx,{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:YQe.map(It=>i.jsxs("button",{onClick:()=>wt(It.value),disabled:p.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:It.emoji}),i.jsx("span",{className:"text-sm font-medium text-slate-700 group-hover:text-slate-900",children:It.label})]},It.value))}),le&&i.jsx("p",{className:"text-destructive text-sm text-center",children:le})]}),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"&&R&&ot&&i.jsx(UQe,{questions:ot,visitorId:R,onComplete:()=>k("done"),onSkip:()=>k("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(Bl,{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,". ",sn?"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:()=>ke(!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(km,{className:"h-4 w-4"}),"View Seller's Disclosures"]}),_e&&i.jsxs("a",{href:_e,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 ",lr!=null&&lr.name?`${lr.name.split(" ")[0]}'s`:"My"," Business Card"]})]}),_e&&we!==null&&!Le&&i.jsxs("p",{className:"text-xs text-slate-400",children:["Opening the business card in ",we,"s…"," ",i.jsx("button",{type:"button",className:"underline",onClick:()=>ke(!0),children:"Stay here"})]}),(lr==null?void 0:lr.name)&&i.jsxs("p",{className:"text-sm text-slate-400",children:["Your host today: ",i.jsx("strong",{className:"text-slate-600",children:lr.name})]}),s&&i.jsxs("div",{className:"pt-4 space-y-3",children:[i.jsx(Dt,{onClick:ve,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 ",Te,"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(LDe,{className:"h-3 w-3"})," Tablet Mode"]}),i.jsx("button",{onClick:nt,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(hDe,{className:"h-3 w-3"})})]})]})})]})}const ZQe=Object.freeze(Object.defineProperty({__proto__:null,default:Sbe},Symbol.toStringTag,{value:"Module"}));function _7t(t){return fr({queryKey:["open-house-rsvps",t],queryFn:async()=>{const{data:e,error:r}=await Re.from("open_house_rsvps").select("*").eq("open_house_id",t).order("created_at",{ascending:!1});if(r)throw r;return e||[]},enabled:!!t})}function XQe(){const t=Er();return wr({mutationFn:async e=>{const{error:r}=await Re.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 b7t(t){const e=Er();return wr({mutationFn:async r=>{const{error:n}=await Re.from("open_house_rsvps").delete().eq("id",r);if(n)throw n},onSuccess:()=>e.invalidateQueries({queryKey:["open-house-rsvps",t]})})}function w7t(t){const e=Er();return wr({mutationFn:async({id:r,checkedIn:n})=>{const{error:s}=await Re.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 QQe=bg({first_name:Ns().trim().min(1,"First name is required").max(50),last_name:Ns().trim().max(50).optional(),email:Ns().trim().email("Please enter a valid email").max(255),phone:Ns().trim().max(20).optional().or(cD("")),message:Ns().trim().max(500).optional().or(cD(""))}),fz=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}`},JQe=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 Tbe({slug:t}={}){const e=$m(),r=t||e.slug,{data:n,isLoading:s,error:o}=pbe(r),c=XQe(),[a,f]=N.useState({first_name:"",last_name:"",email:"",phone:"",message:""}),[p,y]=N.useState(!1),[v,S]=N.useState(""),[E,k]=N.useState(""),[R,P]=N.useState(!1),M=N.useMemo(()=>JQe(n==null?void 0:n.event_date),[n==null?void 0:n.event_date]),D=N.useMemo(()=>{const J=n==null?void 0:n.photo_url;return J?J.includes("/storage/v1/object/public/")?J.replace("/object/public/","/render/image/public/")+"?width=1600&quality=80":J:""},[n]),B=n==null?void 0:n.profiles,V=[n==null?void 0:n.city,n==null?void 0:n.state].filter(Boolean).join(", "),G=async()=>{k("");const J=QQe.safeParse(a);if(!J.success){k(J.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:p,working_with_agent_name:p&&v.trim()?v.trim():void 0,message:a.message.trim()||void 0}),P(!0)}catch(Q){k((Q==null?void 0:Q.message)||"Something went wrong. Please try again.")}},W=N.useMemo(()=>{if(!n||!M)return"";const J=Ae=>String(Ae).padStart(2,"0"),Q=`${M.getFullYear()}${J(M.getMonth()+1)}${J(M.getDate())}`,ee=(n.start_time||"12:00").slice(0,5).replace(":","")+"00",le=(n.end_time||"14:00").slice(0,5).replace(":","")+"00",pe=encodeURIComponent(`Open House — ${n.property_address}`),Te=encodeURIComponent([n.property_address,V,n.zip].filter(Boolean).join(", "));return`https://calendar.google.com/calendar/render?action=TEMPLATE&text=${pe}&dates=${Q}T${ee}/${Q}T${le}&location=${Te}`},[n,M,V]);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(Gi,{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 Y=`https://www.google.com/maps/search/?api=1&query=${encodeURIComponent([n.property_address,V,n.zip].filter(Boolean).join(", "))}`;return i.jsxs("div",{className:"min-h-screen bg-[#f6f2ee]",children:[i.jsxs(Oo,{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 ${As(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}),V&&i.jsxs("p",{className:"mt-1 text-white/70",children:[V," ",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(co,{className:"h-4 w-4 text-[#d4b978]"}),As(M,"EEEE, MMMM d, yyyy")]}),n.start_time&&i.jsxs("span",{className:"flex items-center gap-1.5",children:[i.jsx(Ml,{className:"h-4 w-4 text-[#d4b978]"}),fz(n.start_time),n.end_time?` – ${fz(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(ER,{icon:i.jsx(Gi,{className:"h-4 w-4"}),label:"Price",value:`$${Number(n.price).toLocaleString()}`}):null,n.beds?i.jsx(ER,{icon:i.jsx(HMe,{className:"h-4 w-4"}),label:"Beds",value:String(n.beds)}):null,n.baths?i.jsx(ER,{icon:i.jsx(k_,{className:"h-4 w-4"}),label:"Baths",value:String(n.baths)}):null,n.sqft?i.jsx(ER,{icon:i.jsx(a3,{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:R?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(Bl,{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?As(M,"EEEE, MMMM d"):"soon",n.start_time?` at ${fz(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:[W&&i.jsx(Dt,{asChild:!0,className:"bg-[#1b3a4b] hover:bg-[#25505f]",children:i.jsxs("a",{href:W,target:"_blank",rel:"noreferrer",children:[i.jsx(Cme,{className:"mr-2 h-4 w-4"}),"Add to calendar"]})}),i.jsx(Dt,{asChild:!0,variant:"outline",children:i.jsxs("a",{href:Y,target:"_blank",rel:"noreferrer",children:[i.jsx(di,{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(Mr,{htmlFor:"rsvp-first",children:"First name *"}),i.jsx(Dr,{id:"rsvp-first",value:a.first_name,onChange:J=>f(Q=>({...Q,first_name:J.target.value})),className:"h-11"})]}),i.jsxs("div",{className:"space-y-1.5",children:[i.jsx(Mr,{htmlFor:"rsvp-last",children:"Last name"}),i.jsx(Dr,{id:"rsvp-last",value:a.last_name,onChange:J=>f(Q=>({...Q,last_name:J.target.value})),className:"h-11"})]}),i.jsxs("div",{className:"space-y-1.5",children:[i.jsx(Mr,{htmlFor:"rsvp-email",children:"Email *"}),i.jsx(Dr,{id:"rsvp-email",type:"email",value:a.email,onChange:J=>f(Q=>({...Q,email:J.target.value})),className:"h-11"})]}),i.jsxs("div",{className:"space-y-1.5",children:[i.jsx(Mr,{htmlFor:"rsvp-phone",children:"Phone"}),i.jsx(Dr,{id:"rsvp-phone",type:"tel",value:a.phone,onChange:J=>f(Q=>({...Q,phone:J.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(jT,{checked:p,onCheckedChange:y})]}),p&&i.jsx(Dr,{value:v,onChange:J=>S(J.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(Mr,{htmlFor:"rsvp-msg",children:"Anything you'd like us to know?"}),i.jsx(Bu,{id:"rsvp-msg",rows:3,value:a.message,onChange:J=>f(Q=>({...Q,message:J.target.value})),className:"resize-y"})]}),E&&i.jsx("p",{className:"mt-3 text-sm text-destructive",children:E}),i.jsx(Dt,{onClick:G,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(wd,{className:"h-14 w-14",children:[i.jsx(Sd,{src:B.avatar_url||void 0,alt:B.name}),i.jsx(Td,{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:Y,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1.5 text-sm text-[#406E71] hover:underline",children:[i.jsx(di,{className:"h-4 w-4"}),"Get directions to ",n.property_address]})})]})]})}function ER({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 eJe=Object.freeze(Object.defineProperty({__proto__:null,default:Tbe},Symbol.toStringTag,{value:"Module"}));function S7t(t){const{user:e}=Wn();return fr({queryKey:["cohost-tokens",t],queryFn:async()=>{const{data:r,error:n}=await Re.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 T7t(){const t=Er(),{user:e}=Wn();return wr({mutationFn:async({openHouseId:r,label:n})=>{const{data:s,error:o}=await Re.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 E7t(){const t=Er();return wr({mutationFn:async({id:e,openHouseId:r})=>{const{error:n}=await Re.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 tJe(t){return fr({queryKey:["cohost-validate",t],queryFn:async()=>{const{data:e,error:r}=await Re.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 Rm=(t,e,r)=>r>e?e:r{},TS=()=>{};const jx={},jbe=t=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t);function Abe(t){return typeof t=="object"&&t!==null}const kbe=t=>/^0[^.\s]+$/u.test(t);function Nbe(t){let e;return()=>(e===void 0&&(e=t()),e)}const dh=t=>t,nJe=(t,e)=>r=>e(t(r)),tC=(...t)=>t.reduce(nJe),bk=(t,e,r)=>{const n=e-t;return n===0?1:(r-t)/n};class FH{constructor(){this.subscriptions=[]}add(e){return OH(this.subscriptions,e),()=>fD(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,ih=t=>t/1e3;function Cbe(t,e){return e?t*(1e3/e):0}const Ibe=(t,e,r)=>(((1-3*r+3*e)*t+(3*r-6*e))*t+3*e)*t,sJe=1e-7,iJe=12;function aJe(t,e,r,n,s){let o,c,a=0;do c=e+(r-e)/2,o=Ibe(c,n,s)-t,o>0?r=c:e=c;while(Math.abs(o)>sJe&&++aaJe(o,0,1,t,r);return o=>o===0||o===1?o:Ibe(s(o),e,n)}const Pbe=t=>e=>e<=.5?t(2*e)/2:(2-t(2*(1-e)))/2,Rbe=t=>e=>1-t(1-e),Lbe=rC(.33,1.53,.69,.99),BH=Rbe(Lbe),Mbe=Pbe(BH),Dbe=t=>t>=1?1:(t*=2)<1?.5*BH(t):.5*(2-Math.pow(2,-10*(t-1))),$H=t=>1-Math.sin(Math.acos(t)),Obe=Rbe($H),Fbe=Pbe($H),oJe=rC(.42,0,1,1),lJe=rC(0,0,.58,1),Bbe=rC(.42,0,.58,1),cJe=t=>Array.isArray(t)&&typeof t[0]!="number",$be=t=>Array.isArray(t)&&typeof t[0]=="number",Ane={linear:dh,easeIn:oJe,easeInOut:Bbe,easeOut:lJe,circIn:$H,circInOut:Fbe,circOut:Obe,backIn:BH,backInOut:Mbe,backOut:Lbe,anticipate:Dbe},uJe=t=>typeof t=="string",kne=t=>{if($be(t)){TS(t.length===4,"Cubic bezier arrays must contain four numerical values.","cubic-bezier-length");const[e,r,n,s]=t;return rC(e,r,n,s)}else if(uJe(t))return TS(Ane[t]!==void 0,`Invalid easing type '${t}'`,"invalid-easing-type"),Ane[t];return t},jR=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"],Nne={value:null,addProjectionMetrics:null};function dJe(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 p(v){c.has(v)&&(y.schedule(v),t()),f++,v(a)}const y={schedule:(v,S=!1,E=!1)=>{const R=E&&s?r:n;return S&&c.add(v),R.add(v),v},cancel:v=>{n.delete(v),c.delete(v)},process:v=>{if(a=v,s){o=!0;return}s=!0;const S=r;r=n,n=S,r.forEach(p),e&&Nne.value&&Nne.value.frameloop[e].push(f),f=0,r.clear(),s=!1,o&&(o=!1,y.process(v))}};return y}const hJe=40;function zbe(t,e){let r=!1,n=!0;const s={delta:0,timestamp:0,isProcessing:!1},o=()=>r=!0,c=jR.reduce((B,V)=>(B[V]=dJe(o,e?V:void 0),B),{}),{setup:a,read:f,resolveKeyframes:p,preUpdate:y,update:v,preRender:S,render:E,postRender:k}=c,R=()=>{const B=jx.useManualTiming,V=B?s.timestamp:performance.now();r=!1,B||(s.delta=n?1e3/60:Math.max(Math.min(V-s.timestamp,hJe),1)),s.timestamp=V,s.isProcessing=!0,a.process(s),f.process(s),p.process(s),y.process(s),v.process(s),S.process(s),E.process(s),k.process(s),s.isProcessing=!1,r&&e&&(n=!1,t(R))},P=()=>{r=!0,n=!0,s.isProcessing||t(R)};return{schedule:jR.reduce((B,V)=>{const G=c[V];return B[V]=(W,Y=!1,J=!1)=>(r||P(),G.schedule(W,Y,J)),B},{}),cancel:B=>{for(let V=0;V($L===void 0&&Qc.set(Yl.isProcessing||jx.useManualTiming?Yl.timestamp:performance.now()),$L),set:t=>{$L=t,queueMicrotask(fJe)}},Ube=t=>e=>typeof e=="string"&&e.startsWith(t),Vbe=Ube("--"),mJe=Ube("var(--"),zH=t=>mJe(t)?pJe.test(t.split("/*")[0].trim()):!1,pJe=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function Cne(t){return typeof t!="string"?!1:t.split("/*")[0].includes("var(--")}const AT={test:t=>typeof t=="number",parse:parseFloat,transform:t=>t},wk={...AT,transform:t=>Rm(0,1,t)},AR={...AT,default:1},vA=t=>Math.round(t*1e5)/1e5,UH=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function gJe(t){return t==null}const yJe=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,VH=(t,e)=>r=>!!(typeof r=="string"&&yJe.test(r)&&r.startsWith(t)||e&&!gJe(r)&&Object.prototype.hasOwnProperty.call(r,e)),qbe=(t,e,r)=>n=>{if(typeof n!="string")return n;const[s,o,c,a]=n.match(UH);return{[t]:parseFloat(s),[e]:parseFloat(o),[r]:parseFloat(c),alpha:a!==void 0?parseFloat(a):1}},xJe=t=>Rm(0,255,t),pz={...AT,transform:t=>Math.round(xJe(t))},Lv={test:VH("rgb","red"),parse:qbe("red","green","blue"),transform:({red:t,green:e,blue:r,alpha:n=1})=>"rgba("+pz.transform(t)+", "+pz.transform(e)+", "+pz.transform(r)+", "+vA(wk.transform(n))+")"};function vJe(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 p8={test:VH("#"),parse:vJe,transform:Lv.transform},nC=t=>({test:e=>typeof e=="string"&&e.endsWith(t)&&e.split(" ").length===1,parse:parseFloat,transform:e=>`${e}${t}`}),Ey=nC("deg"),Em=nC("%"),Pn=nC("px"),_Je=nC("vh"),bJe=nC("vw"),Ine={...Em,parse:t=>Em.parse(t)/100,transform:t=>Em.transform(t*100)},u1={test:VH("hsl","hue"),parse:qbe("hue","saturation","lightness"),transform:({hue:t,saturation:e,lightness:r,alpha:n=1})=>"hsla("+Math.round(t)+", "+Em.transform(vA(e))+", "+Em.transform(vA(r))+", "+vA(wk.transform(n))+")"},Yo={test:t=>Lv.test(t)||p8.test(t)||u1.test(t),parse:t=>Lv.test(t)?Lv.parse(t):u1.test(t)?u1.parse(t):p8.parse(t),transform:t=>typeof t=="string"?t:t.hasOwnProperty("red")?Lv.transform(t):u1.transform(t),getAnimatableNone:t=>{const e=Yo.parse(t);return e.alpha=0,Yo.transform(e)}},wJe=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function SJe(t){var e,r;return isNaN(t)&&typeof t=="string"&&(((e=t.match(UH))==null?void 0:e.length)||0)+(((r=t.match(wJe))==null?void 0:r.length)||0)>0}const Gbe="number",Hbe="color",TJe="var",EJe="var(",Pne="${}",jJe=/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 ES(t){const e=t.toString(),r=[],n={color:[],number:[],var:[]},s=[];let o=0;const a=e.replace(jJe,f=>(Yo.test(f)?(n.color.push(o),s.push(Hbe),r.push(Yo.parse(f))):f.startsWith(EJe)?(n.var.push(o),s.push(TJe),r.push(f)):(n.number.push(o),s.push(Gbe),r.push(parseFloat(f))),++o,Pne)).split(Pne);return{values:r,split:a,indexes:n,types:s}}function AJe(t){return ES(t).values}function Wbe({split:t,types:e}){const r=t.length;return n=>{let s="";for(let o=0;otypeof t=="number"?0:Yo.test(t)?Yo.getAnimatableNone(t):t,CJe=(t,e)=>typeof t=="number"?e!=null&&e.trim().endsWith("/")?t:0:NJe(t);function IJe(t){const e=ES(t);return Wbe(e)(e.values.map((n,s)=>CJe(n,e.split[s])))}const yf={test:SJe,parse:AJe,createTransformer:kJe,getAnimatableNone:IJe};function gz(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 PJe({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=gz(f,a,t+1/3),o=gz(f,a,t),c=gz(f,a,t-1/3)}return{red:Math.round(s*255),green:Math.round(o*255),blue:Math.round(c*255),alpha:n}}function mD(t,e){return r=>r>0?e:t}const Ma=(t,e,r)=>t+(e-t)*r,yz=(t,e,r)=>{const n=t*t,s=r*(e*e-n)+n;return s<0?0:Math.sqrt(s)},RJe=[p8,Lv,u1],LJe=t=>RJe.find(e=>e.test(t));function Rne(t){const e=LJe(t);if(mF(!!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===u1&&(r=PJe(r)),r}const Lne=(t,e)=>{const r=Rne(t),n=Rne(e);if(!r||!n)return mD(t,e);const s={...r};return o=>(s.red=yz(r.red,n.red,o),s.green=yz(r.green,n.green,o),s.blue=yz(r.blue,n.blue,o),s.alpha=Ma(r.alpha,n.alpha,o),Lv.transform(s))},g8=new Set(["none","hidden"]);function MJe(t,e){return g8.has(t)?r=>r<=0?t:e:r=>r>=1?e:t}function DJe(t,e){return r=>Ma(t,e,r)}function qH(t){return typeof t=="number"?DJe:typeof t=="string"?zH(t)?mD:Yo.test(t)?Lne:BJe:Array.isArray(t)?Kbe:typeof t=="object"?Yo.test(t)?Lne:OJe:mD}function Kbe(t,e){const r=[...t],n=r.length,s=t.map((o,c)=>qH(o)(o,e[c]));return o=>{for(let c=0;c{for(const o in n)r[o]=n[o](s);return r}}function FJe(t,e){const r=[],n={color:0,var:0,number:0};for(let s=0;s{const r=yf.createTransformer(e),n=ES(t),s=ES(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?g8.has(t)&&!s.values.length||g8.has(e)&&!n.values.length?MJe(t,e):tC(Kbe(FJe(n,s),s.values),r):(mF(!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"),mD(t,e))};function Ybe(t,e,r){return typeof t=="number"&&typeof e=="number"&&typeof r=="number"?Ma(t,e,r):qH(t)(t,e)}const $Je=t=>{const e=({timestamp:r})=>t(r);return{start:(r=!0)=>ia.update(e,r),stop:()=>Ax(e),now:()=>Yl.isProcessing?Yl.timestamp:Qc.now()}},Zbe=(t,e,r=10)=>{let n="";const s=Math.max(Math.round(e/r),2);for(let o=0;o=pD?1/0:e}function zJe(t,e=100,r){const n=r({...t,keyframes:[0,e]}),s=Math.min(GH(n),pD);return{type:"keyframes",ease:o=>n.next(s*o).value/e,duration:ih(s)}}const to={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 y8(t,e){return t*Math.sqrt(1-e*e)}const UJe=12;function VJe(t,e,r){let n=r;for(let s=1;s{const y=p*c,v=y*t,S=y-r,E=y8(p,c),k=Math.exp(-v);return xz-S/E*k},o=p=>{const v=p*c*t,S=v*r+r,E=Math.pow(c,2)*Math.pow(p,2)*t,k=Math.exp(-v),R=y8(Math.pow(p,2),c);return(-s(p)+xz>0?-1:1)*((S-E)*k)/R}):(s=p=>{const y=Math.exp(-p*t),v=(p-r)*t+1;return-xz+y*v},o=p=>{const y=Math.exp(-p*t),v=(r-p)*(t*t);return y*v});const a=5/t,f=VJe(s,o,a);if(t=Ou(t),isNaN(f))return{stiffness:to.stiffness,damping:to.damping,duration:t};{const p=Math.pow(f,2)*n;return{stiffness:p,damping:c*2*Math.sqrt(n*p),duration:t}}}const GJe=["duration","bounce"],HJe=["stiffness","damping","mass"];function Mne(t,e){return e.some(r=>t[r]!==void 0)}function WJe(t){let e={velocity:to.velocity,stiffness:to.stiffness,damping:to.damping,mass:to.mass,isResolvedFromDuration:!1,...t};if(!Mne(t,HJe)&&Mne(t,GJe))if(e.velocity=0,t.visualDuration){const r=t.visualDuration,n=2*Math.PI/(r*1.2),s=n*n,o=2*Rm(.05,1,1-(t.bounce||0))*Math.sqrt(s);e={...e,mass:to.mass,stiffness:s,damping:o}}else{const r=qJe({...t,velocity:0});e={...e,...r,mass:to.mass},e.isResolvedFromDuration=!0}return e}function gD(t=to.visualDuration,e=to.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:p,mass:y,duration:v,velocity:S,isResolvedFromDuration:E}=WJe({...r,velocity:-ih(r.velocity||0)}),k=S||0,R=p/(2*Math.sqrt(f*y)),P=c-o,M=ih(Math.sqrt(f/y)),D=Math.abs(P)<5;n||(n=D?to.restSpeed.granular:to.restSpeed.default),s||(s=D?to.restDelta.granular:to.restDelta.default);let B,V,G,W,Y,J;if(R<1)G=y8(M,R),W=(k+R*M*P)/G,B=ee=>{const le=Math.exp(-R*M*ee);return c-le*(W*Math.sin(G*ee)+P*Math.cos(G*ee))},Y=R*M*W+P*G,J=R*M*P-W*G,V=ee=>Math.exp(-R*M*ee)*(Y*Math.sin(G*ee)+J*Math.cos(G*ee));else if(R===1){B=le=>c-Math.exp(-M*le)*(P+(k+M*P)*le);const ee=k+M*P;V=le=>Math.exp(-M*le)*(M*ee*le-k)}else{const ee=M*Math.sqrt(R*R-1);B=Ae=>{const Le=Math.exp(-R*M*Ae),ke=Math.min(ee*Ae,300);return c-Le*((k+R*M*P)*Math.sinh(ke)+ee*P*Math.cosh(ke))/ee};const le=(k+R*M*P)/ee,pe=R*M*le-P*ee,Te=R*M*P-le*ee;V=Ae=>{const Le=Math.exp(-R*M*Ae),ke=Math.min(ee*Ae,300);return Le*(pe*Math.sinh(ke)+Te*Math.cosh(ke))}}const Q={calculatedDuration:E&&v||null,velocity:ee=>Ou(V(ee)),next:ee=>{if(!E&&R<1){const pe=Math.exp(-R*M*ee),Te=Math.sin(G*ee),Ae=Math.cos(G*ee),Le=c-pe*(W*Te+P*Ae),ke=Ou(pe*(Y*Te+J*Ae));return a.done=Math.abs(ke)<=n&&Math.abs(c-Le)<=s,a.value=a.done?c:Le,a}const le=B(ee);if(E)a.done=ee>=v;else{const pe=Ou(V(ee));a.done=Math.abs(pe)<=n&&Math.abs(c-le)<=s}return a.value=a.done?c:le,a},toString:()=>{const ee=Math.min(GH(Q),pD),le=Zbe(pe=>Q.next(ee*pe).value,ee,30);return ee+"ms "+le},toTransition:()=>{}};return Q}gD.applyToOptions=t=>{const e=zJe(t,100,gD);return t.ease=e.ease,t.duration=Ou(e.duration),t.type="keyframes",t};const KJe=5;function Xbe(t,e,r){const n=Math.max(e-KJe,0);return Cbe(r-t(n),e-n)}function x8({keyframes:t,velocity:e=0,power:r=.8,timeConstant:n=325,bounceDamping:s=10,bounceStiffness:o=500,modifyTarget:c,min:a,max:f,restDelta:p=.5,restSpeed:y}){const v=t[0],S={done:!1,value:v},E=J=>a!==void 0&&Jf,k=J=>a===void 0?f:f===void 0||Math.abs(a-J)-R*Math.exp(-J/n),B=J=>M+D(J),V=J=>{const Q=D(J),ee=B(J);S.done=Math.abs(Q)<=p,S.value=S.done?M:ee};let G,W;const Y=J=>{E(S.value)&&(G=J,W=gD({keyframes:[S.value,k(S.value)],velocity:Xbe(B,J,S.value),damping:s,stiffness:o,restDelta:p,restSpeed:y}))};return Y(0),{calculatedDuration:null,next:J=>{let Q=!1;return!W&&G===void 0&&(Q=!0,V(J),Y(J)),G!==void 0&&J>=G?W.next(J-G):(!Q&&V(J),S)}}}function YJe(t,e,r){const n=[],s=r||jx.mix||Ybe,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=YJe(e,n,s),f=a.length,p=y=>{if(c&&y1)for(;vp(Rm(t[0],t[o-1],y)):p}function XJe(t,e){const r=t[t.length-1];for(let n=1;n<=e;n++){const s=bk(0,e,n);t.push(Ma(r,1,s))}}function QJe(t){const e=[0];return XJe(e,t.length-1),e}function JJe(t,e){return t.map(r=>r*e)}function eet(t,e){return t.map(()=>e||Bbe).splice(0,t.length-1)}function _A({duration:t=300,keyframes:e,times:r,ease:n="easeInOut"}){const s=cJe(n)?n.map(kne):kne(n),o={done:!1,value:e[0]},c=JJe(r&&r.length===e.length?r:QJe(e),t),a=ZJe(c,e,{ease:Array.isArray(s)?s:eet(e,s)});return{calculatedDuration:t,next:f=>(o.value=a(f),o.done=f>=t,o)}}const tet=t=>t!==null;function pF(t,{repeat:e,repeatType:r="loop"},n,s=1){const o=t.filter(tet),a=s<0||e&&r!=="loop"&&e%2===1?0:o.length-1;return!a||n===void 0?o[a]:n}const ret={decay:x8,inertia:x8,tween:_A,keyframes:_A,spring:gD};function Qbe(t){typeof t.type=="string"&&(t.type=ret[t.type])}class HH{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 net=t=>t/100;class yD extends HH{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!==Qc.now()&&this.tick(Qc.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;Qbe(e);const{type:r=_A,repeat:n=0,repeatDelay:s=0,repeatType:o,velocity:c=0}=e;let{keyframes:a}=e;const f=r||_A;f!==_A&&typeof a[0]!="number"&&(this.mixKeyframes=tC(net,Ybe(a[0],a[1])),a=[0,100]);const p=f({...e,keyframes:a});o==="mirror"&&(this.mirroredGenerator=f({...e,keyframes:[...a].reverse(),velocity:-c})),p.calculatedDuration===null&&(p.calculatedDuration=GH(p));const{calculatedDuration:y}=p;this.calculatedDuration=y,this.resolvedDuration=y+s,this.totalDuration=this.resolvedDuration*(n+1)-s,this.generator=p}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:p=0,keyframes:y,repeat:v,repeatType:S,repeatDelay:E,type:k,onUpdate:R,finalKeyframe:P}=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-p*(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,V=n;if(v){const J=Math.min(this.currentTime,s)/a;let Q=Math.floor(J),ee=J%1;!ee&&J>=1&&(ee=1),ee===1&&Q--,Q=Math.min(Q,v+1),!!(Q%2)&&(S==="reverse"?(ee=1-ee,E&&(ee-=E/a)):S==="mirror"&&(V=c)),B=Rm(0,1,ee)*a}let G;D?(this.delayState.value=y[0],G=this.delayState):G=V.next(B),o&&!D&&(G.value=o(G.value));let{done:W}=G;!D&&f!==null&&(W=this.playbackSpeed>=0?this.currentTime>=s:this.currentTime<=0);const Y=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&W);return Y&&k!==x8&&(G.value=pF(y,this.options,P,this.speed)),R&&R(G.value),Y&&this.finish(),G}then(e,r){return this.finished.then(e,r)}get duration(){return ih(this.calculatedDuration)}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+ih(e)}get time(){return ih(this.currentTime)}set time(e){e=Ou(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 Xbe(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(Qc.now()),this.playbackSpeed=e,r&&this.driver&&(this.time=ih(this.currentTime))}play(){var s,o;if(this.isStopped)return;const{driver:e=$Je,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(Qc.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 set(t){for(let e=1;et*180/Math.PI,v8=t=>{const e=Mv(Math.atan2(t[1],t[0]));return _8(e)},iet={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:t=>(Math.abs(t[0])+Math.abs(t[3]))/2,rotate:v8,rotateZ:v8,skewX:t=>Mv(Math.atan(t[1])),skewY:t=>Mv(Math.atan(t[2])),skew:t=>(Math.abs(t[1])+Math.abs(t[2]))/2},_8=t=>(t=t%360,t<0&&(t+=360),t),Dne=v8,One=t=>Math.sqrt(t[0]*t[0]+t[1]*t[1]),Fne=t=>Math.sqrt(t[4]*t[4]+t[5]*t[5]),aet={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:One,scaleY:Fne,scale:t=>(One(t)+Fne(t))/2,rotateX:t=>_8(Mv(Math.atan2(t[6],t[5]))),rotateY:t=>_8(Mv(Math.atan2(-t[2],t[0]))),rotateZ:Dne,rotate:Dne,skewX:t=>Mv(Math.atan(t[4])),skewY:t=>Mv(Math.atan(t[1])),skew:t=>(Math.abs(t[1])+Math.abs(t[4]))/2};function b8(t){return t.includes("scale")?1:0}function w8(t,e){if(!t||t==="none")return b8(e);const r=t.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let n,s;if(r)n=aet,s=r;else{const a=t.match(/^matrix\(([-\d.e\s,]+)\)$/u);n=iet,s=a}if(!s)return b8(e);const o=n[e],c=s[1].split(",").map(cet);return typeof o=="function"?o(c):c[o]}const oet=(t,e)=>{const{transform:r="none"}=getComputedStyle(t);return w8(r,e)};function cet(t){return parseFloat(t.trim())}const kT=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],NT=new Set(kT),Bne=t=>t===AT||t===Pn,uet=new Set(["x","y","z"]),det=kT.filter(t=>!uet.has(t));function het(t){const e=[];return det.forEach(r=>{const n=t.getValue(r);n!==void 0&&(e.push([r,n.get()]),n.set(r.startsWith("scale")?1:0))}),e}const Xy={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})=>w8(e,"x"),y:(t,{transform:e})=>w8(e,"y")};Xy.translateX=Xy.x;Xy.translateY=Xy.y;const Jv=new Set;let S8=!1,T8=!1,E8=!1;function Jbe(){if(T8){const t=Array.from(Jv).filter(n=>n.needsMeasurement),e=new Set(t.map(n=>n.element)),r=new Map;e.forEach(n=>{const s=het(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)})}T8=!1,S8=!1,Jv.forEach(t=>t.complete(E8)),Jv.clear()}function ewe(){Jv.forEach(t=>{t.readKeyframes(),t.needsMeasurement&&(T8=!0)})}function fet(){E8=!0,ewe(),Jbe(),E8=!1}class WH{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?(Jv.add(this),S8||(S8=!0,ia.read(ewe),ia.resolveKeyframes(Jbe))):(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])}set(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),Jv.delete(this)}cancel(){this.state==="scheduled"&&(Jv.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const met=t=>t.startsWith("--");function twe(t,e,r){met(e)?t.style.setProperty(e,r):t.style[e]=r}const pet={};function rwe(t,e){const r=Nbe(t);return()=>pet[e]??r()}const get=rwe(()=>window.ScrollTimeline!==void 0,"scrollTimeline"),nwe=rwe(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),X2=([t,e,r,n])=>`cubic-bezier(${t}, ${e}, ${r}, ${n})`,$ne={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:X2([0,.65,.55,1]),circOut:X2([.55,0,1,.45]),backIn:X2([.31,.01,.66,-.59]),backOut:X2([.33,1.53,.69,.99])};function swe(t,e){if(t)return typeof t=="function"?nwe()?Zbe(t,e):"ease-out":$be(t)?X2(t):Array.isArray(t)?t.map(r=>swe(r,e)||$ne.easeOut):$ne[t]}function yet(t,e,r,{delay:n=0,duration:s=300,repeat:o=0,repeatType:c="loop",ease:a="easeOut",times:f}={},p=void 0){const y={[e]:r};f&&(y.offset=f);const v=swe(a,s);Array.isArray(v)&&(y.easing=v);const S={delay:n,duration:s,easing:Array.isArray(v)?"linear":v,fill:"both",iterations:o+1,direction:c==="reverse"?"alternate":"normal"};return p&&(S.pseudoElement=p),t.animate(y,S)}function iwe(t){return typeof t=="function"&&"applyToOptions"in t}function xet({type:t,...e}){return iwe(t)&&nwe()?t.applyToOptions(e):(e.duration??(e.duration=300),e.ease??(e.ease="easeOut"),e)}class awe extends HH{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,TS(typeof e.type!="string",`Mini animate() doesn't support "type" as a string.`,"mini-spring");const p=xet(e);this.animation=yet(r,n,s,p,o),p.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!o){const y=pF(s,this.options,a,this.speed);this.updateMotionValue&&this.updateMotionValue(y),twe(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 ih(Number(e))}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+ih(e)}get time(){return ih(Number(this.animation.currentTime)||0)}set time(e){const r=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=Ou(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&&get()?(this.animation.timeline=e,r&&(this.animation.rangeStart=r),n&&(this.animation.rangeEnd=n),dh):s(this)}}const owe={anticipate:Dbe,backInOut:Mbe,circInOut:Fbe};function vet(t){return t in owe}function _et(t){typeof t.ease=="string"&&vet(t.ease)&&(t.ease=owe[t.ease])}const vz=10;class bet extends awe{constructor(e){_et(e),Qbe(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 yD({...c,autoplay:!1}),f=Math.max(vz,Qc.now()-this.startTime),p=Rm(0,vz,f-vz),y=a.sample(f).value,{name:v}=this.options;o&&v&&twe(o,v,y),r.setWithVelocity(a.sample(Math.max(0,f-p)).value,y,p),a.stop()}}const zne=(t,e)=>e==="zIndex"?!1:!!(typeof t=="number"||Array.isArray(t)||typeof t=="string"&&(yf.test(t)||t==="0")&&!t.startsWith("url("));function wet(t){const e=t[0];if(t.length===1)return!0;for(let r=0;rObject.hasOwnProperty.call(Element.prototype,"animate"));function Net(t){var v;const{motionValue:e,name:r,repeatDelay:n,repeatType:s,damping:o,type:c,keyframes:a}=t;if(!(((v=e==null?void 0:e.owner)==null?void 0:v.current)instanceof HTMLElement))return!1;const{onUpdate:p,transformTemplate:y}=e.owner.getProps();return ket()&&r&&(lwe.has(r)||Aet.has(r)&&jet(a))&&(r!=="transform"||!y)&&!p&&!n&&s!=="mirror"&&o!==0&&c!=="inertia"}const Cet=40;class Iet extends HH{constructor({autoplay:e=!0,delay:r=0,type:n="keyframes",repeat:s=0,repeatDelay:o=0,repeatType:c="loop",keyframes:a,name:f,motionValue:p,element:y,...v}){var k;super(),this.stop=()=>{var R,P;this._animation&&(this._animation.stop(),(R=this.stopTimeline)==null||R.call(this)),(P=this.keyframeResolver)==null||P.cancel()},this.createdAt=Qc.now();const S={autoplay:e,delay:r,type:n,repeat:s,repeatDelay:o,repeatType:c,name:f,motionValue:p,element:y,...v},E=(y==null?void 0:y.KeyframeResolver)||WH;this.keyframeResolver=new E(a,(R,P,M)=>this.onKeyframesResolved(R,P,S,!M),f,p,y),(k=this.keyframeResolver)==null||k.scheduleResolve()}onKeyframesResolved(e,r,n,s){var M,D;this.keyframeResolver=void 0;const{name:o,type:c,velocity:a,delay:f,isHandoff:p,onUpdate:y}=n;this.resolvedAt=Qc.now();let v=!0;Tet(e,o,c,a)||(v=!1,(jx.instantAnimations||!f)&&(y==null||y(pF(e,n,r))),e[0]=e[e.length-1],j8(n),n.repeat=0);const E={startTime:s?this.resolvedAt?this.resolvedAt-this.createdAt>Cet?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:r,...n,keyframes:e},k=v&&!p&&Net(E),R=(D=(M=E.motionValue)==null?void 0:M.owner)==null?void 0:D.current;let P;if(k)try{P=new bet({...E,element:R})}catch{P=new yD(E)}else P=new yD(E);P.finished.then(()=>{this.notifyFinished()}).catch(dh),this.pendingTimeline&&(this.stopTimeline=P.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=P}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(),fet()),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 cwe(t,e,r,n=0,s=1){const o=Array.from(t).sort((p,y)=>p.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 Pet=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function Ret(t){const e=Pet.exec(t);if(!e)return[,];const[,r,n,s]=e;return[`--${r??n}`,s]}const Let=4;function uwe(t,e,r=1){TS(r<=Let,`Max CSS variable fallback depth detected in property "${t}". This may indicate a circular fallback dependency.`,"max-css-var-depth");const[n,s]=Ret(t);if(!n)return;const o=window.getComputedStyle(e).getPropertyValue(n);if(o){const c=o.trim();return jbe(c)?parseFloat(c):c}return zH(s)?uwe(s,e,r+1):s}const Met={type:"spring",stiffness:500,damping:25,restSpeed:10},Det=t=>({type:"spring",stiffness:550,damping:t===0?2*Math.sqrt(550):30,restSpeed:10}),Oet={type:"keyframes",duration:.8},Fet={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},Bet=(t,{keyframes:e})=>e.length>2?Oet:NT.has(t)?t.startsWith("scale")?Det(e[1]):Met:Fet;function dwe(t,e){if(t!=null&&t.inherit&&e){const{inherit:r,...n}=t;return{...e,...n}}return t}function KH(t,e){const r=(t==null?void 0:t[e])??(t==null?void 0:t.default)??t;return r!==t?dwe(r,t):r}const $et=new Set(["when","delay","delayChildren","staggerChildren","staggerDirection","repeat","repeatType","repeatDelay","from","elapsed"]);function zet(t){for(const e in t)if(!$et.has(e))return!0;return!1}const YH=(t,e,r,n={},s,o)=>c=>{const a=KH(n,t)||{},f=a.delay||n.delay||0;let{elapsed:p=0}=n;p=p-Ou(f);const y={keyframes:Array.isArray(r)?r:[null,r],ease:"easeOut",velocity:e.getVelocity(),...a,delay:-p,onUpdate:S=>{e.set(S),a.onUpdate&&a.onUpdate(S)},onComplete:()=>{c(),a.onComplete&&a.onComplete()},name:t,motionValue:e,element:o?void 0:s};zet(a)||Object.assign(y,Bet(t,y)),y.duration&&(y.duration=Ou(y.duration)),y.repeatDelay&&(y.repeatDelay=Ou(y.repeatDelay)),y.from!==void 0&&(y.keyframes[0]=y.from);let v=!1;if((y.type===!1||y.duration===0&&!y.repeatDelay)&&(j8(y),y.delay===0&&(v=!0)),(jx.instantAnimations||jx.skipAnimations||s!=null&&s.shouldSkipAnimations)&&(v=!0,j8(y),y.delay=0),y.allowFlatten=!a.type&&!a.ease,v&&!o&&e.get()!==void 0){const S=pF(y.keyframes,a);if(S!==void 0){ia.update(()=>{y.onUpdate(S),y.onComplete()});return}}return a.isSync?new yD(y):new Iet(y)};function Une(t){const e=[{},{}];return t==null||t.values.forEach((r,n)=>{e[0][n]=r.get(),e[1][n]=r.getVelocity()}),e}function ZH(t,e,r,n){if(typeof e=="function"){const[s,o]=Une(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]=Une(n);e=e(r!==void 0?r:t.custom,s,o)}return e}function e_(t,e,r){const n=t.getProps();return ZH(n,e,r!==void 0?r:n.custom,t)}const hwe=new Set(["width","height","top","left","right","bottom",...kT]),Vne=30,Uet=t=>!isNaN(parseFloat(t));class Vet{constructor(e,r={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=n=>{var o;const s=Qc.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=Qc.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=Uet(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 FH);const n=this.events[e].add(r);return e==="change"?()=>{n(),ia.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=Qc.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>Vne)return 0;const r=Math.min(this.updatedAt-this.prevUpdatedAt,Vne);return Cbe(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 jS(t,e){return new Vet(t,e)}const A8=t=>Array.isArray(t);function qet(t,e,r){t.hasValue(e)?t.getValue(e).set(r):t.addValue(e,jS(r))}function Get(t){return A8(t)?t[t.length-1]||0:t}function Het(t,e){const r=e_(t,e);let{transitionEnd:n={},transition:s={},...o}=r||{};o={...o,...n};for(const c in o){const a=Get(o[c]);qet(t,c,a)}}const ic=t=>!!(t&&t.getVelocity);function Wet(t){return!!(ic(t)&&t.add)}function k8(t,e){const r=t.getValue("willChange");if(Wet(r))return r.add(e);if(!r&&jx.WillChange){const n=new jx.WillChange("auto");t.addValue("willChange",n),n.add(e)}}function XH(t){return t.replace(/([A-Z])/g,e=>`-${e.toLowerCase()}`)}const Ket="framerAppearId",fwe="data-"+XH(Ket);function mwe(t){return t.props[fwe]}function Yet({protectedKeys:t,needsAnimating:e},r){const n=t.hasOwnProperty(r)&&e[r]!==!0;return e[r]=!1,n}function pwe(t,e,{delay:r=0,transitionOverride:n,type:s}={}){let{transition:o,transitionEnd:c,...a}=e;const f=t.getDefaultTransition();o=o?dwe(o,f):f;const p=o==null?void 0:o.reduceMotion;n&&(o=n);const y=[],v=s&&t.animationState&&t.animationState.getState()[s];for(const S in a){const E=t.getValue(S,t.latestValues[S]??null),k=a[S];if(k===void 0||v&&Yet(v,S))continue;const R={delay:r,...KH(o||{},S)},P=E.get();if(P!==void 0&&!E.isAnimating()&&!Array.isArray(k)&&k===P&&!R.velocity){ia.update(()=>E.set(k));continue}let M=!1;if(window.MotionHandoffAnimation){const V=mwe(t);if(V){const G=window.MotionHandoffAnimation(V,S,ia);G!==null&&(R.startTime=G,M=!0)}}k8(t,S);const D=p??t.shouldReduceMotion;E.start(YH(S,E,k,D&&hwe.has(S)?{type:!1}:R,t,M));const B=E.animation;B&&y.push(B)}if(c){const S=()=>ia.update(()=>{c&&Het(t,c)});y.length?Promise.all(y).then(S):S()}return y}function N8(t,e,r={}){var f;const n=e_(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(pwe(t,n,r)):()=>Promise.resolve(),c=t.variantChildren&&t.variantChildren.size?(p=0)=>{const{delayChildren:y=0,staggerChildren:v,staggerDirection:S}=s;return Zet(t,e,p,y,v,S,r)}:()=>Promise.resolve(),{when:a}=s;if(a){const[p,y]=a==="beforeChildren"?[o,c]:[c,o];return p().then(()=>y())}else return Promise.all([o(),c(r.delay)])}function Zet(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(N8(f,e,{...c,delay:r+(typeof n=="function"?0:n)+cwe(t.variantChildren,f,n,s,o)}).then(()=>f.notify("AnimationComplete",e)));return Promise.all(a)}function Xet(t,e,r={}){t.notify("AnimationStart",e);let n;if(Array.isArray(e)){const s=e.map(o=>N8(t,o,r));n=Promise.all(s)}else if(typeof e=="string")n=N8(t,e,r);else{const s=typeof e=="function"?e_(t,e,r.custom):e;n=Promise.all(pwe(t,s,r))}return n.then(()=>{t.notify("AnimationComplete",e)})}const Qet={test:t=>t==="auto",parse:t=>t},gwe=t=>e=>e.test(t),ywe=[AT,Pn,Em,Ey,bJe,_Je,Qet],qne=t=>ywe.find(gwe(t));function Jet(t){return typeof t=="number"?t===0:t!==null?t==="none"||t==="0"||kbe(t):!0}const ett=new Set(["brightness","contrast","saturate","opacity"]);function ttt(t){const[e,r]=t.slice(0,-1).split("(");if(e==="drop-shadow")return t;const[n]=r.match(UH)||[];if(!n)return t;const s=r.replace(n,"");let o=ett.has(e)?1:0;return n!==r&&(o*=100),e+"("+o+s+")"}const rtt=/\b([a-z-]*)\(.*?\)/gu,C8={...yf,getAnimatableNone:t=>{const e=t.match(rtt);return e?e.map(ttt).join(" "):t}},I8={...yf,getAnimatableNone:t=>{const e=yf.parse(t);return yf.createTransformer(t)(e.map(n=>typeof n=="number"?0:typeof n=="object"?{...n,alpha:1}:n))}},Gne={...AT,transform:Math.round},ntt={rotate:Ey,rotateX:Ey,rotateY:Ey,rotateZ:Ey,scale:AR,scaleX:AR,scaleY:AR,scaleZ:AR,skew:Ey,skewX:Ey,skewY:Ey,distance:Pn,translateX:Pn,translateY:Pn,translateZ:Pn,x:Pn,y:Pn,z:Pn,perspective:Pn,transformPerspective:Pn,opacity:wk,originX:Ine,originY:Ine,originZ:Pn},QH={borderWidth:Pn,borderTopWidth:Pn,borderRightWidth:Pn,borderBottomWidth:Pn,borderLeftWidth:Pn,borderRadius:Pn,borderTopLeftRadius:Pn,borderTopRightRadius:Pn,borderBottomRightRadius:Pn,borderBottomLeftRadius:Pn,width:Pn,maxWidth:Pn,height:Pn,maxHeight:Pn,top:Pn,right:Pn,bottom:Pn,left:Pn,inset:Pn,insetBlock:Pn,insetBlockStart:Pn,insetBlockEnd:Pn,insetInline:Pn,insetInlineStart:Pn,insetInlineEnd:Pn,padding:Pn,paddingTop:Pn,paddingRight:Pn,paddingBottom:Pn,paddingLeft:Pn,paddingBlock:Pn,paddingBlockStart:Pn,paddingBlockEnd:Pn,paddingInline:Pn,paddingInlineStart:Pn,paddingInlineEnd:Pn,margin:Pn,marginTop:Pn,marginRight:Pn,marginBottom:Pn,marginLeft:Pn,marginBlock:Pn,marginBlockStart:Pn,marginBlockEnd:Pn,marginInline:Pn,marginInlineStart:Pn,marginInlineEnd:Pn,fontSize:Pn,backgroundPositionX:Pn,backgroundPositionY:Pn,...ntt,zIndex:Gne,fillOpacity:wk,strokeOpacity:wk,numOctaves:Gne},stt={...QH,color:Yo,backgroundColor:Yo,outlineColor:Yo,fill:Yo,stroke:Yo,borderColor:Yo,borderTopColor:Yo,borderRightColor:Yo,borderBottomColor:Yo,borderLeftColor:Yo,filter:C8,WebkitFilter:C8,mask:I8,WebkitMask:I8},xwe=t=>stt[t],itt=new Set([C8,I8]);function vwe(t,e){let r=xwe(t);return itt.has(r)||(r=yf),r.getAnimatableNone?r.getAnimatableNone(e):void 0}const att=new Set(["auto","none","0"]);function ott(t,e,r){let n=0,s;for(;n{e.getValue(f).set(p)}),this.resolveNoneKeyframes()}}function _we(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 bwe=(t,e)=>e&&typeof t=="number"?e.transform(t):t;function zL(t){return Abe(t)&&"offsetHeight"in t&&!("ownerSVGElement"in t)}const{schedule:JH,cancel:j7t}=zbe(queueMicrotask,!1),Kh={x:!1,y:!1};function wwe(){return Kh.x||Kh.y}function ctt(t){return t==="x"||t==="y"?Kh[t]?null:(Kh[t]=!0,()=>{Kh[t]=!1}):Kh.x||Kh.y?null:(Kh.x=Kh.y=!0,()=>{Kh.x=Kh.y=!1})}function Swe(t,e){const r=_we(t),n=new AbortController,s={passive:!0,...e,signal:n.signal};return[r,s,()=>n.abort()]}function utt(t){return!(t.pointerType==="touch"||wwe())}function dtt(t,e,r={}){const[n,s,o]=Swe(t,r);return n.forEach(c=>{let a=!1,f=!1,p;const y=()=>{c.removeEventListener("pointerleave",k)},v=P=>{p&&(p(P),p=void 0),y()},S=P=>{a=!1,window.removeEventListener("pointerup",S),window.removeEventListener("pointercancel",S),f&&(f=!1,v(P))},E=()=>{a=!0,window.addEventListener("pointerup",S,s),window.addEventListener("pointercancel",S,s)},k=P=>{if(P.pointerType!=="touch"){if(a){f=!0;return}v(P)}},R=P=>{if(!utt(P))return;f=!1;const M=e(c,P);typeof M=="function"&&(p=M,c.addEventListener("pointerleave",k,s))};c.addEventListener("pointerenter",R,s),c.addEventListener("pointerdown",E,s)}),o}const Twe=(t,e)=>e?t===e?!0:Twe(t,e.parentElement):!1,eW=t=>t.pointerType==="mouse"?typeof t.button!="number"||t.button<=0:t.isPrimary!==!1,htt=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function ftt(t){return htt.has(t.tagName)||t.isContentEditable===!0}const mtt=new Set(["INPUT","SELECT","TEXTAREA"]);function ptt(t){return mtt.has(t.tagName)||t.isContentEditable===!0}const UL=new WeakSet;function Hne(t){return e=>{e.key==="Enter"&&t(e)}}function _z(t,e){t.dispatchEvent(new PointerEvent("pointer"+e,{isPrimary:!0,bubbles:!0}))}const gtt=(t,e)=>{const r=t.currentTarget;if(!r)return;const n=Hne(()=>{if(UL.has(r))return;_z(r,"down");const s=Hne(()=>{_z(r,"up")}),o=()=>_z(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 Wne(t){return eW(t)&&!wwe()}const Kne=new WeakSet;function ytt(t,e,r={}){const[n,s,o]=Swe(t,r),c=a=>{const f=a.currentTarget;if(!Wne(a)||Kne.has(a))return;UL.add(f),r.stopPropagation&&Kne.add(a);const p=e(f,a),y=(E,k)=>{window.removeEventListener("pointerup",v),window.removeEventListener("pointercancel",S),UL.has(f)&&UL.delete(f),Wne(E)&&typeof p=="function"&&p(E,{success:k})},v=E=>{y(E,f===window||f===document||r.useGlobalTarget||Twe(f,E.target))},S=E=>{y(E,!1)};window.addEventListener("pointerup",v,s),window.addEventListener("pointercancel",S,s)};return n.forEach(a=>{(r.useGlobalTarget?window:a).addEventListener("pointerdown",c,s),zL(a)&&(a.addEventListener("focus",p=>gtt(p,s)),!ftt(a)&&!a.hasAttribute("tabindex")&&(a.tabIndex=0))}),o}function tW(t){return Abe(t)&&"ownerSVGElement"in t}const VL=new WeakMap;let jy;const Ewe=(t,e,r)=>(n,s)=>s&&s[0]?s[0][t+"Size"]:tW(n)&&"getBBox"in n?n.getBBox()[e]:n[r],xtt=Ewe("inline","width","offsetWidth"),vtt=Ewe("block","height","offsetHeight");function _tt({target:t,borderBoxSize:e}){var r;(r=VL.get(t))==null||r.forEach(n=>{n(t,{get width(){return xtt(t,e)},get height(){return vtt(t,e)}})})}function btt(t){t.forEach(_tt)}function wtt(){typeof ResizeObserver>"u"||(jy=new ResizeObserver(btt))}function Stt(t,e){jy||wtt();const r=_we(t);return r.forEach(n=>{let s=VL.get(n);s||(s=new Set,VL.set(n,s)),s.add(e),jy==null||jy.observe(n)}),()=>{r.forEach(n=>{const s=VL.get(n);s==null||s.delete(e),s!=null&&s.size||jy==null||jy.unobserve(n)})}}const qL=new Set;let d1;function Ttt(){d1=()=>{const t={get width(){return window.innerWidth},get height(){return window.innerHeight}};qL.forEach(e=>e(t))},window.addEventListener("resize",d1)}function Ett(t){return qL.add(t),d1||Ttt(),()=>{qL.delete(t),!qL.size&&typeof d1=="function"&&(window.removeEventListener("resize",d1),d1=void 0)}}function Yne(t,e){return typeof t=="function"?Ett(t):Stt(t,e)}function jtt(t){return tW(t)&&t.tagName==="svg"}const Att=[...ywe,Yo,yf],ktt=t=>Att.find(gwe(t)),Zne=()=>({translate:0,scale:1,origin:0,originPoint:0}),h1=()=>({x:Zne(),y:Zne()}),Xne=()=>({min:0,max:0}),ll=()=>({x:Xne(),y:Xne()}),Ntt=new WeakMap;function gF(t){return t!==null&&typeof t=="object"&&typeof t.start=="function"}function Sk(t){return typeof t=="string"||Array.isArray(t)}const rW=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],nW=["initial",...rW];function yF(t){return gF(t.animate)||nW.some(e=>Sk(t[e]))}function jwe(t){return!!(yF(t)||t.variants)}function Ctt(t,e,r){for(const n in e){const s=e[n],o=r[n];if(ic(s))t.addValue(n,s);else if(ic(o))t.addValue(n,jS(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,jS(c!==void 0?c:s,{owner:t}))}}for(const n in r)e[n]===void 0&&t.removeValue(n);return e}const P8={current:null},Awe={current:!1},Itt=typeof window<"u";function Ptt(){if(Awe.current=!0,!!Itt)if(window.matchMedia){const t=window.matchMedia("(prefers-reduced-motion)"),e=()=>P8.current=t.matches;t.addEventListener("change",e),e()}else P8.current=!1}const Qne=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];let xD={};function kwe(t){xD=t}function Rtt(){return xD}class Ltt{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=WH,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=Qc.now();this.renderScheduledAtthis.bindToMotionValue(o,s)),this.reducedMotionConfig==="never"?this.shouldReduceMotion=!1:this.reducedMotionConfig==="always"?this.shouldReduceMotion=!0:(Awe.current||Ptt(),this.shouldReduceMotion=P8.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(),Ax(this.notifyUpdate),Ax(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&&lwe.has(e)&&this.current instanceof HTMLElement){const{factory:c,keyframes:a,times:f,ease:p,duration:y}=r.accelerate,v=new awe({element:this.current,name:e,keyframes:a,times:f,ease:p,duration:Ou(y)}),S=c(v);this.valueSubscriptions.set(e,()=>{S(),v.cancel()});return}const n=NT.has(e);n&&this.onBindTransform&&this.onBindTransform();const s=r.on("change",c=>{this.latestValues[e]=c,this.props.onUpdate&&ia.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 xD){const r=xD[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):ll()}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=jS(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"&&(jbe(n)||kbe(n))?n=parseFloat(n):!ktt(n)&&yf.test(r)&&(n=vwe(e,r)),this.setBaseTarget(e,ic(n)?n.get():n)),ic(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=ZH(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&&!ic(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 FH),this.events[e].add(r)}notify(e,...r){this.events[e]&&this.events[e].notify(...r)}scheduleRenderMicrotask(){JH.render(this.render)}}class Nwe extends Ltt{constructor(){super(...arguments),this.KeyframeResolver=ltt}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;ic(e)&&(this.childSubscription=e.on("change",r=>{this.current&&(this.current.textContent=`${r}`)}))}}class Gx{constructor(e){this.isMounted=!1,this.node=e}update(){}}function Cwe({top:t,left:e,right:r,bottom:n}){return{x:{min:e,max:r},y:{min:t,max:n}}}function Mtt({x:t,y:e}){return{top:e.min,right:t.max,bottom:e.max,left:t.min}}function Dtt(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 bz(t){return t===void 0||t===1}function R8({scale:t,scaleX:e,scaleY:r}){return!bz(t)||!bz(e)||!bz(r)}function wv(t){return R8(t)||Iwe(t)||t.z||t.rotate||t.rotateX||t.rotateY||t.skewX||t.skewY}function Iwe(t){return Jne(t.x)||Jne(t.y)}function Jne(t){return t&&t!=="0%"}function vD(t,e,r){const n=t-r,s=e*n;return r+s}function ese(t,e,r,n,s){return s!==void 0&&(t=vD(t,s,n)),vD(t,r,n)+e}function L8(t,e=0,r=1,n,s){t.min=ese(t.min,e,r,n,s),t.max=ese(t.max,e,r,n,s)}function Pwe(t,{x:e,y:r}){L8(t.x,e.translate,e.scale,e.originPoint),L8(t.y,r.translate,r.scale,r.originPoint)}const tse=.999999999999,rse=1.0000000000001;function Ott(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;ftse&&(e.x=1),e.ytse&&(e.y=1)}function lm(t,e){t.min+=e,t.max+=e}function nse(t,e,r,n,s=.5){const o=Ma(t.min,t.max,s);L8(t,e,r,o,n)}function sse(t,e){return typeof t=="string"?parseFloat(t)/100*(e.max-e.min):t}function GL(t,e,r){const n=r??t;nse(t.x,sse(e.x,n.x),e.scaleX,e.scale,e.originX),nse(t.y,sse(e.y,n.y),e.scaleY,e.scale,e.originY)}function Rwe(t,e){return Cwe(Dtt(t.getBoundingClientRect(),e))}function Ftt(t,e,r){const n=Rwe(t,r),{scroll:s}=e;return s&&(lm(n.x,s.offset.x),lm(n.y,s.offset.y)),n}const Btt={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},$tt=kT.length;function ztt(t,e,r){let n="",s=!0;for(let o=0;o<$tt;o++){const c=kT[o],a=t[c];if(a===void 0)continue;let f=!0;if(typeof a=="number")f=a===(c.startsWith("scale")?1:0);else{const p=parseFloat(a);f=c.startsWith("scale")?p===1:p===0}if(!f||r){const p=bwe(a,QH[c]);if(!f){s=!1;const y=Btt[c]||c;n+=`${y}(${p}) `}r&&(e[c]=p)}}return n=n.trim(),r?n=r(e,s?"":n):s&&(n="none"),n}function sW(t,e,r){const{style:n,vars:s,transformOrigin:o}=t;let c=!1,a=!1;for(const f in e){const p=e[f];if(NT.has(f)){c=!0;continue}else if(Vbe(f)){s[f]=p;continue}else{const y=bwe(p,QH[f]);f.startsWith("origin")?(a=!0,o[f]=y):n[f]=y}}if(e.transform||(c||r?n.transform=ztt(e,t.transform,r):n.transform&&(n.transform="none")),a){const{originX:f="50%",originY:p="50%",originZ:y=0}=o;n.transformOrigin=`${f} ${p} ${y}`}}function Lwe(t,{style:e,vars:r},n,s){const o=t.style;let c;for(c in e)o[c]=e[c];s==null||s.applyProjectionStyles(o,n);for(c in r)o.setProperty(c,r[c])}function ise(t,e){return e.max===e.min?0:t/(e.max-e.min)*100}const w2={correct:(t,e)=>{if(!e.target)return t;if(typeof t=="string")if(Pn.test(t))t=parseFloat(t);else return t;const r=ise(t,e.target.x),n=ise(t,e.target.y);return`${r}% ${n}%`}},Utt={correct:(t,{treeScale:e,projectionDelta:r})=>{const n=t,s=yf.parse(t);if(s.length>5)return n;const o=yf.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 p=Ma(a,f,.5);return typeof s[2+c]=="number"&&(s[2+c]/=p),typeof s[3+c]=="number"&&(s[3+c]/=p),o(s)}},M8={borderRadius:{...w2,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:w2,borderTopRightRadius:w2,borderBottomLeftRadius:w2,borderBottomRightRadius:w2,boxShadow:Utt};function Mwe(t,{layout:e,layoutId:r}){return NT.has(t)||t.startsWith("origin")||(e||r!==void 0)&&(!!M8[t]||t==="opacity")}function iW(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)(ic(n[a])||s&&ic(s[a])||Mwe(a,t)||((c=r==null?void 0:r.getValue(a))==null?void 0:c.liveStyle)!==void 0)&&(o[a]=n[a]);return o}function Vtt(t){return window.getComputedStyle(t)}class qtt extends Nwe{constructor(){super(...arguments),this.type="html",this.renderInstance=Lwe}readValueFromInstance(e,r){var n;if(NT.has(r))return(n=this.projection)!=null&&n.isProjecting?b8(r):oet(e,r);{const s=Vtt(e),o=(Vbe(r)?s.getPropertyValue(r):s[r])||0;return typeof o=="string"?o.trim():o}}measureInstanceViewportBox(e,{transformPagePoint:r}){return Rwe(e,r)}build(e,r,n){sW(e,r,n.transformTemplate)}scrapeMotionValuesFromProps(e,r,n){return iW(e,r,n)}}const Gtt={offset:"stroke-dashoffset",array:"stroke-dasharray"},Htt={offset:"strokeDashoffset",array:"strokeDasharray"};function Wtt(t,e,r=1,n=0,s=!0){t.pathLength=1;const o=s?Gtt:Htt;t[o.offset]=`${-n}`,t[o.array]=`${e} ${r}`}const Ktt=["offsetDistance","offsetPath","offsetRotate","offsetAnchor"];function Dwe(t,{attrX:e,attrY:r,attrScale:n,pathLength:s,pathSpacing:o=1,pathOffset:c=0,...a},f,p,y){if(sW(t,a,p),f){t.style.viewBox&&(t.attrs.viewBox=t.style.viewBox);return}t.attrs=t.style,t.style={};const{attrs:v,style:S}=t;v.transform&&(S.transform=v.transform,delete v.transform),(S.transform||v.transformOrigin)&&(S.transformOrigin=v.transformOrigin??"50% 50%",delete v.transformOrigin),S.transform&&(S.transformBox=(y==null?void 0:y.transformBox)??"fill-box",delete v.transformBox);for(const E of Ktt)v[E]!==void 0&&(S[E]=v[E],delete v[E]);e!==void 0&&(v.x=e),r!==void 0&&(v.y=r),n!==void 0&&(v.scale=n),s!==void 0&&Wtt(v,s,o,c,!1)}const Owe=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"]),Fwe=t=>typeof t=="string"&&t.toLowerCase()==="svg";function Ytt(t,e,r,n){Lwe(t,e,void 0,n);for(const s in e.attrs)t.setAttribute(Owe.has(s)?s:XH(s),e.attrs[s])}function Bwe(t,e,r){const n=iW(t,e,r);for(const s in t)if(ic(t[s])||ic(e[s])){const o=kT.indexOf(s)!==-1?"attr"+s.charAt(0).toUpperCase()+s.substring(1):s;n[o]=t[s]}return n}class Ztt extends Nwe{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=ll}getBaseTargetFromProps(e,r){return e[r]}readValueFromInstance(e,r){if(NT.has(r)){const n=xwe(r);return n&&n.default||0}return r=Owe.has(r)?r:XH(r),e.getAttribute(r)}scrapeMotionValuesFromProps(e,r,n){return Bwe(e,r,n)}build(e,r,n){Dwe(e,r,this.isSVGTag,n.transformTemplate,n.style)}renderInstance(e,r,n,s){Ytt(e,r,n,s)}mount(e){this.isSVGTag=Fwe(e.tagName),super.mount(e)}}const Xtt=nW.length;function $we(t){if(!t)return;if(!t.isControllingVariants){const r=t.parent?$we(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})=>Xet(t,r,n)))}function trt(t){let e=ert(t),r=ase(),n=!0,s=!1;const o=p=>(y,v)=>{var E;const S=e_(t,v,p==="exit"?(E=t.presenceContext)==null?void 0:E.custom:void 0);if(S){const{transition:k,transitionEnd:R,...P}=S;y={...y,...P,...R}}return y};function c(p){e=p(t)}function a(p){const{props:y}=t,v=$we(t.parent)||{},S=[],E=new Set;let k={},R=1/0;for(let M=0;MR&&G,ee=!1;const le=Array.isArray(V)?V:[V];let pe=le.reduce(o(D),{});W===!1&&(pe={});const{prevResolvedValues:Te={}}=B,Ae={...Te,...pe},Le=me=>{Q=!0,E.has(me)&&(ee=!0,E.delete(me)),B.needsAnimating[me]=!0;const je=t.getValue(me);je&&(je.liveStyle=!1)};for(const me in Ae){const je=pe[me],_e=Te[me];if(k.hasOwnProperty(me))continue;let Ee=!1;A8(je)&&A8(_e)?Ee=!zwe(je,_e):Ee=je!==_e,Ee?je!=null?Le(me):E.add(me):je!==void 0&&E.has(me)?Le(me):B.protectedKeys[me]=!0}B.prevProp=V,B.prevResolvedValues=pe,B.isActive&&(k={...k,...pe}),(n||s)&&t.blockInitialAnimation&&(Q=!1);const ke=Y&&J;Q&&(!ke||ee)&&S.push(...le.map(me=>{const je={type:D};if(typeof me=="string"&&(n||s)&&!ke&&t.manuallyAnimateOnMount&&t.parent){const{parent:_e}=t,Ee=e_(_e,me);if(_e.enteringChildren&&Ee){const{delayChildren:ve}=Ee.transition||{};je.delay=cwe(_e.enteringChildren,t,ve)}}return{animation:me,options:je}}))}if(E.size){const M={};if(typeof y.initial!="boolean"){const D=e_(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),V=t.getValue(D);V&&(V.liveStyle=!0),M[D]=B??null}),S.push({animation:M})}let P=!!S.length;return n&&(y.initial===!1||y.initial===y.animate)&&!t.manuallyAnimateOnMount&&(P=!1),n=!1,s=!1,P?e(S):Promise.resolve()}function f(p,y){var S;if(r[p].isActive===y)return Promise.resolve();(S=t.variantChildren)==null||S.forEach(E=>{var k;return(k=E.animationState)==null?void 0:k.setActive(p,y)}),r[p].isActive=y;const v=a(p);for(const E in r)r[E].protectedKeys={};return v}return{animateChanges:a,setActive:f,setAnimateFunction:c,getState:()=>r,reset:()=>{r=ase(),s=!0}}}function rrt(t,e){return typeof e=="string"?e!==t:Array.isArray(e)?!zwe(e,t):!1}function uv(t=!1){return{isActive:t,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function ase(){return{animate:uv(!0),whileInView:uv(),whileHover:uv(),whileTap:uv(),whileDrag:uv(),whileFocus:uv(),exit:uv()}}function D8(t,e){t.min=e.min,t.max=e.max}function Uh(t,e){D8(t.x,e.x),D8(t.y,e.y)}function ose(t,e){t.translate=e.translate,t.scale=e.scale,t.originPoint=e.originPoint,t.origin=e.origin}const Uwe=1e-4,nrt=1-Uwe,srt=1+Uwe,Vwe=.01,irt=0-Vwe,art=0+Vwe;function Jc(t){return t.max-t.min}function ort(t,e,r){return Math.abs(t-e)<=r}function lse(t,e,r,n=.5){t.origin=n,t.originPoint=Ma(e.min,e.max,t.origin),t.scale=Jc(r)/Jc(e),t.translate=Ma(r.min,r.max,t.origin)-t.originPoint,(t.scale>=nrt&&t.scale<=srt||isNaN(t.scale))&&(t.scale=1),(t.translate>=irt&&t.translate<=art||isNaN(t.translate))&&(t.translate=0)}function bA(t,e,r,n){lse(t.x,e.x,r.x,n?n.originX:void 0),lse(t.y,e.y,r.y,n?n.originY:void 0)}function cse(t,e,r,n=0){const s=n?Ma(r.min,r.max,n):r.min;t.min=s+e.min,t.max=t.min+Jc(e)}function lrt(t,e,r,n){cse(t.x,e.x,r.x,n==null?void 0:n.x),cse(t.y,e.y,r.y,n==null?void 0:n.y)}function use(t,e,r,n=0){const s=n?Ma(r.min,r.max,n):r.min;t.min=e.min-s,t.max=t.min+Jc(e)}function _D(t,e,r,n){use(t.x,e.x,r.x,n==null?void 0:n.x),use(t.y,e.y,r.y,n==null?void 0:n.y)}function dse(t,e,r,n,s){return t-=e,t=vD(t,1/r,n),s!==void 0&&(t=vD(t,1/s,n)),t}function crt(t,e=0,r=1,n=.5,s,o=t,c=t){if(Em.test(e)&&(e=parseFloat(e),e=Ma(c.min,c.max,e/100)-c.min),typeof e!="number")return;let a=Ma(o.min,o.max,n);t===o&&(a-=e),t.min=dse(t.min,e,r,a,s),t.max=dse(t.max,e,r,a,s)}function hse(t,e,[r,n,s],o,c){crt(t,e[r],e[n],e[s],e.scale,o,c)}const urt=["x","scaleX","originX"],drt=["y","scaleY","originY"];function fse(t,e,r,n){hse(t.x,e,urt,r?r.x:void 0,n?n.x:void 0),hse(t.y,e,drt,r?r.y:void 0,n?n.y:void 0)}function mse(t){return t.translate===0&&t.scale===1}function qwe(t){return mse(t.x)&&mse(t.y)}function pse(t,e){return t.min===e.min&&t.max===e.max}function hrt(t,e){return pse(t.x,e.x)&&pse(t.y,e.y)}function gse(t,e){return Math.round(t.min)===Math.round(e.min)&&Math.round(t.max)===Math.round(e.max)}function Gwe(t,e){return gse(t.x,e.x)&&gse(t.y,e.y)}function yse(t){return Jc(t.x)/Jc(t.y)}function xse(t,e){return t.translate===e.translate&&t.scale===e.scale&&t.originPoint===e.originPoint}function nm(t){return[t("x"),t("y")]}function frt(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:p,rotate:y,rotateX:v,rotateY:S,skewX:E,skewY:k}=r;p&&(n=`perspective(${p}px) ${n}`),y&&(n+=`rotate(${y}deg) `),v&&(n+=`rotateX(${v}deg) `),S&&(n+=`rotateY(${S}deg) `),E&&(n+=`skewX(${E}deg) `),k&&(n+=`skewY(${k}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 Hwe=["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"],mrt=Hwe.length,vse=t=>typeof t=="string"?parseFloat(t):t,_se=t=>typeof t=="number"||Pn.test(t);function prt(t,e,r,n,s,o){s?(t.opacity=Ma(0,r.opacity??1,grt(n)),t.opacityExit=Ma(e.opacity??1,0,yrt(n))):o&&(t.opacity=Ma(e.opacity??1,r.opacity??1,n));for(let c=0;cne?1:r(bk(t,e,n))}function xrt(t,e,r){const n=ic(t)?t:jS(t);return n.start(YH("",n,e,r)),n.animation}function Tk(t,e,r,n={passive:!0}){return t.addEventListener(e,r,n),()=>t.removeEventListener(e,r)}const vrt=(t,e)=>t.depth-e.depth;class _rt{constructor(){this.children=[],this.isDirty=!1}add(e){OH(this.children,e),this.isDirty=!0}remove(e){fD(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(vrt),this.isDirty=!1,this.children.forEach(e)}}function brt(t,e){const r=Qc.now(),n=({timestamp:s})=>{const o=s-r;o>=e&&(Ax(n),t(o-e))};return ia.setup(n,!0),()=>Ax(n)}function HL(t){return ic(t)?t.get():t}class wrt{constructor(){this.members=[]}add(e){OH(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&&(fD(this.members,n),n.unmount())}e.scheduleRender()}remove(e){if(fD(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 WL={hasAnimatedSinceResize:!0,hasEverUpdated:!1},wz=["","X","Y","Z"],Srt=1e3;let Trt=0;function Sz(t,e,r,n){const{latestValues:s}=e;s[t]&&(r[t]=s[t],e.setStaticValue(t,0),n&&(n[t]=0))}function Kwe(t){if(t.hasCheckedOptimisedAppear=!0,t.root===t)return;const{visualElement:e}=t.options;if(!e)return;const r=mwe(e);if(window.MotionHasOptimisedAnimation(r,"transform")){const{layout:s,layoutId:o}=t.options;window.MotionCancelOptimisedAnimation(r,"transform",ia,!(s||o))}const{parent:n}=t;n&&!n.hasCheckedOptimisedAppear&&Kwe(n)}function Ywe({attachResizeListener:t,defaultParent:e,measureScroll:r,checkIsScrollRoot:n,resetTransform:s}){return class{constructor(c={},a=e==null?void 0:e()){this.id=Trt++,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(Art),this.nodes.forEach(Rrt),this.nodes.forEach(Lrt),this.nodes.forEach(krt)},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;ia.read(()=>{v=window.innerWidth}),t(c,()=>{const E=window.innerWidth;E!==v&&(v=E,this.root.updateBlockedByResize=!0,y&&y(),y=brt(S,250),WL.hasAnimatedSinceResize&&(WL.hasAnimatedSinceResize=!1,this.nodes.forEach(Tse)))})}a&&this.root.registerSharedNode(a,this),this.options.animate!==!1&&p&&(a||f)&&this.addEventListener("didUpdate",({delta:y,hasLayoutChanged:v,hasRelativeLayoutChanged:S,layout:E})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const k=this.options.transition||p.getDefaultTransition()||Brt,{onLayoutAnimationStart:R,onLayoutAnimationComplete:P}=p.getProps(),M=!this.targetLayout||!Gwe(this.targetLayout,E),D=!v&&S;if(this.options.layoutRoot||this.resumeFrom||D||v&&(M||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const B={...KH(k,"layout"),onPlay:R,onComplete:P};(p.shouldReduceMotion||this.options.layoutRoot)&&(B.delay=0,B.type=!1),this.startAnimation(B),this.setAnimationOrigin(y,D)}else v||Tse(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(),Ax(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(Mrt),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&&Kwe(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&&!Jc(this.snapshot.measuredBox.x)&&!Jc(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 G=V/1e3;Ese(v.x,c.x,G),Ese(v.y,c.y,G),this.setTargetDelta(v),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(_D(S,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),Ort(this.relativeTarget,this.relativeTargetOrigin,S,G),B&&hrt(this.relativeTarget,B)&&(this.isProjectionDirty=!1),B||(B=ll()),Uh(B,this.relativeTarget)),R&&(this.animationValues=y,prt(y,p,this.latestValues,G,D,M)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=G},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(c){var a,f,p;this.notifyListeners("animationStart"),(a=this.currentAnimation)==null||a.stop(),(p=(f=this.resumingFrom)==null?void 0:f.currentAnimation)==null||p.stop(),this.pendingAnimation&&(Ax(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=ia.update(()=>{WL.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=jS(0)),this.motionValue.jump(0,!1),this.currentAnimation=xrt(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(Srt),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const c=this.getLead();let{targetWithTransforms:a,target:f,layout:p,latestValues:y}=c;if(!(!a||!f||!p)){if(this!==c&&this.layout&&p&&Zwe(this.options.animationType,this.layout.layoutBox,p.layoutBox)){f=this.target||ll();const v=Jc(this.layout.layoutBox.x);f.x.min=c.target.x.min,f.x.max=f.x.min+v;const S=Jc(this.layout.layoutBox.y);f.y.min=c.target.y.min,f.y.max=f.y.min+S}Uh(a,f),GL(a,y),bA(this.projectionDeltaWithTransform,this.layoutCorrected,a,y)}}registerSharedNode(c,a){this.sharedNodes.has(c)||this.sharedNodes.set(c,new wrt),this.sharedNodes.get(c).add(a);const p=a.options.initialPromotionConfig;a.promote({transition:p?p.transition:void 0,preserveFollowOpacity:p&&p.shouldPreserveFollowOpacity?p.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 p=this.getStack();p&&p.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 p={};f.z&&Sz("z",c,p,this.animationValues);for(let y=0;y{var a;return(a=c.currentAnimation)==null?void 0:a.stop()}),this.root.nodes.forEach(wse),this.root.sharedNodes.clear()}}}function Ert(t){t.updateLayout()}function jrt(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")nm(v=>{const S=c?e.measuredBox[v]:e.layoutBox[v],E=Jc(S);S.min=n[v].min,S.max=S.min+E});else if(o==="x"||o==="y"){const v=o==="x"?"y":"x";D8(c?e.measuredBox[v]:e.layoutBox[v],n[v])}else Zwe(o,e.layoutBox,n)&&nm(v=>{const S=c?e.measuredBox[v]:e.layoutBox[v],E=Jc(n[v]);S.max=S.min+E,t.relativeTarget&&!t.currentAnimation&&(t.isProjectionDirty=!0,t.relativeTarget[v].max=t.relativeTarget[v].min+E)});const a=h1();bA(a,n,e.layoutBox);const f=h1();c?bA(f,t.applyTransform(s,!0),e.measuredBox):bA(f,n,e.layoutBox);const p=!qwe(a);let y=!1;if(!t.resumeFrom){const v=t.getClosestProjectingParent();if(v&&!v.resumeFrom){const{snapshot:S,layout:E}=v;if(S&&E){const k=t.options.layoutAnchor||void 0,R=ll();_D(R,e.layoutBox,S.layoutBox,k);const P=ll();_D(P,n,E.layoutBox,k),Gwe(R,P)||(y=!0),v.options.layoutRoot&&(t.relativeTarget=P,t.relativeTargetOrigin=R,t.relativeParent=v)}}}t.notifyListeners("didUpdate",{layout:n,snapshot:e,delta:f,layoutDelta:a,hasLayoutChanged:p,hasRelativeLayoutChanged:y})}else if(t.isLead()){const{onExitComplete:n}=t.options;n&&n()}t.options.transition=void 0}function Art(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 krt(t){t.isProjectionDirty=t.isSharedProjectionDirty=t.isTransformDirty=!1}function Nrt(t){t.clearSnapshot()}function wse(t){t.clearMeasurements()}function Crt(t){t.isLayoutDirty=!0,t.updateLayout()}function Sse(t){t.isLayoutDirty=!1}function Irt(t){t.isAnimationBlocked&&t.layout&&!t.isLayoutDirty&&(t.snapshot=t.layout,t.isLayoutDirty=!0)}function Prt(t){const{visualElement:e}=t.options;e&&e.getProps().onBeforeLayoutMeasure&&e.notify("BeforeLayoutMeasure"),t.resetTransform()}function Tse(t){t.finishAnimation(),t.targetDelta=t.relativeTarget=t.target=void 0,t.isProjectionDirty=!0}function Rrt(t){t.resolveTargetDelta()}function Lrt(t){t.calcProjection()}function Mrt(t){t.resetSkewAndRotation()}function Drt(t){t.removeLeadSnapshot()}function Ese(t,e,r){t.translate=Ma(e.translate,0,r),t.scale=Ma(e.scale,1,r),t.origin=e.origin,t.originPoint=e.originPoint}function jse(t,e,r,n){t.min=Ma(e.min,r.min,n),t.max=Ma(e.max,r.max,n)}function Ort(t,e,r,n){jse(t.x,e.x,r.x,n),jse(t.y,e.y,r.y,n)}function Frt(t){return t.animationValues&&t.animationValues.opacityExit!==void 0}const Brt={duration:.45,ease:[.4,0,.1,1]},Ase=t=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(t),kse=Ase("applewebkit/")&&!Ase("chrome/")?Math.round:dh;function Nse(t){t.min=kse(t.min),t.max=kse(t.max)}function $rt(t){Nse(t.x),Nse(t.y)}function Zwe(t,e,r){return t==="position"||t==="preserve-aspect"&&!ort(yse(e),yse(r),.2)}function zrt(t){var e;return t!==t.root&&((e=t.scroll)==null?void 0:e.wasRoot)}const Urt=Ywe({attachResizeListener:(t,e)=>Tk(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}),Tz={current:void 0},Xwe=Ywe({measureScroll:t=>({x:t.scrollLeft,y:t.scrollTop}),defaultParent:()=>{if(!Tz.current){const t=new Urt({});t.mount(window),t.setOptions({layoutScroll:!0}),Tz.current=t}return Tz.current},resetTransform:(t,e)=>{t.style.transform=e!==void 0?e:"none"},checkIsScrollRoot:t=>window.getComputedStyle(t).position==="fixed"}),aW=N.createContext({transformPagePoint:t=>t,isStatic:!1,reducedMotion:"never"});function Cse(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function Vrt(...t){return e=>{let r=!1;const n=t.map(s=>{const o=Cse(s,e);return!r&&typeof o=="function"&&(r=!0),o});if(r)return()=>{for(let s=0;s{const{width:E,height:k,top:R,left:P,right:M,bottom:D}=f.current;if(e||o===!1||!a.current||!E||!k)return;const B=r==="left"?`left: ${P}`:`right: ${M}`,V=n==="bottom"?`bottom: ${D}`:`top: ${R}`;a.current.dataset.motionPopId=c;const G=document.createElement("style");p&&(G.nonce=p);const W=s??document.head;return W.appendChild(G),G.sheet&&G.sheet.insertRule(` [data-motion-pop-id="${c}"] { position: absolute !important; width: ${E}px !important; height: ${k}px !important; ${B}px !important; ${V}px !important; } `),()=>{var Y;(Y=a.current)==null||Y.removeAttribute("data-motion-pop-id"),W.contains(G)&&W.removeChild(G)}},[e]),i.jsx(Grt,{isPresent:e,childRef:a,sizeRef:f,pop:o,children:o===!1?t:N.cloneElement(t,{ref:v})})}const Wrt=({children:t,initial:e,isPresent:r,onExitComplete:n,custom:s,presenceAffectsLayout:o,mode:c,anchorX:a,anchorY:f,root:p})=>{const y=DH(Krt),v=N.useId();let S=!0,E=N.useMemo(()=>(S=!1,{id:v,initial:e,isPresent:r,custom:s,onExitComplete:k=>{y.set(k,!0);for(const R of y.values())if(!R)return;n&&n()},register:k=>(y.set(k,!1),()=>y.delete(k))}),[r,y,n]);return o&&S&&(E={...E}),N.useMemo(()=>{y.forEach((k,R)=>y.set(R,!1))},[r]),N.useEffect(()=>{!r&&!y.size&&n&&n()},[r]),t=i.jsx(Hrt,{pop:c==="popLayout",isPresent:r,anchorX:a,anchorY:f,root:p,children:t}),i.jsx(fF.Provider,{value:E,children:t})};function Krt(){return new Map}function Qwe(t=!0){const e=N.useContext(fF);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 kR=t=>t.key||"";function Ise(t){const e=[];return N.Children.forEach(t,r=>{N.isValidElement(r)&&e.push(r)}),e}const Jwe=({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:p})=>{const[y,v]=Qwe(c),S=N.useMemo(()=>Ise(t),[t]),E=c&&!y?[]:S.map(kR),k=N.useRef(!0),R=N.useRef(S),P=DH(()=>new Map),M=N.useRef(new Set),[D,B]=N.useState(S),[V,G]=N.useState(S);Ebe(()=>{k.current=!1,R.current=S;for(let J=0;J{const Q=kR(J),ee=c&&!y?!1:S===V||E.includes(Q),le=()=>{if(M.current.has(Q))return;if(P.has(Q))M.current.add(Q),P.set(Q,!0);else return;let pe=!0;P.forEach(Te=>{Te||(pe=!1)}),pe&&(Y==null||Y(),G(R.current),c&&(v==null||v()),n&&n())};return i.jsx(Wrt,{isPresent:ee,initial:!k.current||r?void 0:!1,custom:e,presenceAffectsLayout:s,mode:o,root:p,onExitComplete:ee?void 0:le,anchorX:a,anchorY:f,children:J},Q)})})},e1e=N.createContext({strict:!1}),Pse={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 Rse=!1;function Yrt(){if(Rse)return;const t={};for(const e in Pse)t[e]={isEnabled:r=>Pse[e].some(n=>!!r[n])};kwe(t),Rse=!0}function t1e(){return Yrt(),Rtt()}function Zrt(t){const e=t1e();for(const r in t)e[r]={...e[r],...t[r]};kwe(e)}const Xrt=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 bD(t){return t.startsWith("while")||t.startsWith("drag")&&t!=="draggable"||t.startsWith("layout")||t.startsWith("onTap")||t.startsWith("onPan")||t.startsWith("onLayout")||Xrt.has(t)}let r1e=t=>!bD(t);function Qrt(t){typeof t=="function"&&(r1e=e=>e.startsWith("on")?!bD(e):t(e))}try{Qrt(require("@emotion/is-prop-valid").default)}catch{}function Jrt(t,e,r){const n={};for(const s in t)s==="values"&&typeof t.values=="object"||ic(t[s])||(r1e(s)||r===!0&&bD(s)||!e&&!bD(s)||t.draggable&&s.startsWith("onDrag"))&&(n[s]=t[s]);return n}const xF=N.createContext({});function ent(t,e){if(yF(t)){const{initial:r,animate:n}=t;return{initial:r===!1||Sk(r)?r:void 0,animate:Sk(n)?n:void 0}}return t.inherit!==!1?e:{}}function tnt(t){const{initial:e,animate:r}=ent(t,N.useContext(xF));return N.useMemo(()=>({initial:e,animate:r}),[Lse(e),Lse(r)])}function Lse(t){return Array.isArray(t)?t.join(" "):t}const oW=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function n1e(t,e,r){for(const n in e)!ic(e[n])&&!Mwe(n,r)&&(t[n]=e[n])}function rnt({transformTemplate:t},e){return N.useMemo(()=>{const r=oW();return sW(r,e,t),Object.assign({},r.vars,r.style)},[e])}function nnt(t,e){const r=t.style||{},n={};return n1e(n,r,t),Object.assign(n,rnt(t,e)),n}function snt(t,e){const r={},n=nnt(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 s1e=()=>({...oW(),attrs:{}});function int(t,e,r,n){const s=N.useMemo(()=>{const o=s1e();return Dwe(o,e,Fwe(n),t.transformTemplate,t.style),{...o.attrs,style:{...o.style}}},[e]);if(t.style){const o={};n1e(o,t.style,t),s.style={...o,...s.style}}return s}const ant=["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 lW(t){return typeof t!="string"||t.includes("-")?!1:!!(ant.indexOf(t)>-1||/[A-Z]/u.test(t))}function ont(t,e,r,{latestValues:n},s,o=!1,c){const f=(c??lW(t)?int:snt)(e,n,s,t),p=Jrt(e,typeof t=="string",o),y=t!==N.Fragment?{...p,...f,ref:r}:{},{children:v}=e,S=N.useMemo(()=>ic(v)?v.get():v,[v]);return N.createElement(t,{...y,children:S})}function lnt({scrapeMotionValuesFromProps:t,createRenderState:e},r,n,s){return{latestValues:cnt(r,n,s,t),renderState:e()}}function cnt(t,e,r,n){const s={},o=n(t,{});for(const S in o)s[S]=HL(o[S]);let{initial:c,animate:a}=t;const f=yF(t),p=jwe(t);e&&p&&!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 v=y?a:c;if(v&&typeof v!="boolean"&&!gF(v)){const S=Array.isArray(v)?v:[v];for(let E=0;E(e,r)=>{const n=N.useContext(xF),s=N.useContext(fF),o=()=>lnt(t,e,n,s);return r?o():DH(o)},unt=i1e({scrapeMotionValuesFromProps:iW,createRenderState:oW}),dnt=i1e({scrapeMotionValuesFromProps:Bwe,createRenderState:s1e}),hnt=Symbol.for("motionComponentSymbol");function fnt(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 a1e=N.createContext({});function Kw(t){return t&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"current")}function mnt(t,e,r,n,s,o){var B,V;const{visualElement:c}=N.useContext(xF),a=N.useContext(e1e),f=N.useContext(fF),p=N.useContext(aW),y=p.reducedMotion,v=p.skipAnimations,S=N.useRef(null),E=N.useRef(!1);n=n||a.renderer,!S.current&&n&&(S.current=n(t,{visualState:e,parent:c,props:r,presenceContext:f,blockInitialAnimation:f?f.initial===!1:!1,reducedMotionConfig:y,skipAnimations:v,isSVG:o}),E.current&&S.current&&(S.current.manuallyAnimateOnMount=!0));const k=S.current,R=N.useContext(a1e);k&&!k.projection&&s&&(k.type==="html"||k.type==="svg")&&pnt(S.current,r,s,R);const P=N.useRef(!1);N.useInsertionEffect(()=>{k&&P.current&&k.update(r,f)});const M=r[fwe],D=N.useRef(!!M&&typeof window<"u"&&!((B=window.MotionHandoffIsComplete)!=null&&B.call(window,M))&&((V=window.MotionHasOptimisedAnimation)==null?void 0:V.call(window,M)));return Ebe(()=>{E.current=!0,k&&(P.current=!0,window.MotionIsMounted=!0,k.updateFeatures(),k.scheduleRenderMicrotask(),D.current&&k.animationState&&k.animationState.animateChanges())}),N.useEffect(()=>{k&&(!D.current&&k.animationState&&k.animationState.animateChanges(),D.current&&(queueMicrotask(()=>{var G;(G=window.MotionHandoffMarkAsComplete)==null||G.call(window,M)}),D.current=!1),k.enteringChildren=void 0)}),k}function pnt(t,e,r,n){const{layoutId:s,layout:o,drag:c,dragConstraints:a,layoutScroll:f,layoutRoot:p,layoutAnchor:y,layoutCrossfade:v}=e;t.projection=new r(t.latestValues,e["data-framer-portal-id"]?void 0:o1e(t.parent)),t.projection.setOptions({layoutId:s,layout:o,alwaysMeasureLayout:!!c||a&&Kw(a),visualElement:t,animationType:typeof o=="string"?o:"both",initialPromotionConfig:n,crossfade:v,layoutScroll:f,layoutRoot:p,layoutAnchor:y})}function o1e(t){if(t)return t.options.allowProjection!==!1?t.projection:o1e(t.parent)}function Ez(t,{forwardMotionProps:e=!1,type:r}={},n,s){n&&Zrt(n);const o=r?r==="svg":lW(t),c=o?dnt:unt;function a(p,y){let v;const S={...N.useContext(aW),...p,layoutId:gnt(p)},{isStatic:E}=S,k=tnt(p),R=c(p,E);if(!E&&typeof window<"u"){ynt();const P=xnt(S);v=P.MeasureLayout,k.visualElement=mnt(t,R,S,s,P.ProjectionNode,o)}return i.jsxs(xF.Provider,{value:k,children:[v&&k.visualElement?i.jsx(v,{visualElement:k.visualElement,...S}):null,ont(t,p,fnt(R,k.visualElement,y),R,E,e,o)]})}a.displayName=`motion.${typeof t=="string"?t:`create(${t.displayName??t.name??""})`}`;const f=N.forwardRef(a);return f[hnt]=t,f}function gnt({layoutId:t}){const e=N.useContext(MH).id;return e&&t!==void 0?e+"-"+t:t}function ynt(t,e){N.useContext(e1e).strict}function xnt(t){const e=t1e(),{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 vnt(t,e){if(typeof Proxy>"u")return Ez;const r=new Map,n=(o,c)=>Ez(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,Ez(c,void 0,t,e)),r.get(c))})}const _nt=(t,e)=>e.isSVG??lW(t)?new Ztt(e):new qtt(e,{allowProjection:t!==N.Fragment});class bnt extends Gx{constructor(e){super(e),e.animationState||(e.animationState=trt(e))}updateAnimationControlsSubscription(){const{animate:e}=this.node.getProps();gF(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 wnt=0;class Snt extends Gx{constructor(){super(...arguments),this.id=wnt++,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=e_(this.node,c,a);if(f){const{transition:p,transitionEnd:y,...v}=f;for(const S in v)(o=this.node.getValue(S))==null||o.jump(v[S])}}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 Tnt={animation:{Feature:bnt},exit:{Feature:Snt}};function sC(t){return{point:{x:t.pageX,y:t.pageY}}}const Ent=t=>e=>eW(e)&&t(e,sC(e));function wA(t,e,r,n){return Tk(t,e,Ent(r),n)}const l1e=({current:t})=>t?t.ownerDocument.defaultView:null,Mse=(t,e)=>Math.abs(t-e);function jnt(t,e){const r=Mse(t.x,e.x),n=Mse(t.y,e.y);return Math.sqrt(r**2+n**2)}const Dse=new Set(["auto","scroll"]);class c1e{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=NR(this.lastRawMoveEventInfo,this.transformPagePoint));const E=jz(this.lastMoveEventInfo,this.history),k=this.startEvent!==null,R=jnt(E.offset,{x:0,y:0})>=this.distanceThreshold;if(!k&&!R)return;const{point:P}=E,{timestamp:M}=Yl;this.history.push({...P,timestamp:M});const{onStart:D,onMove:B}=this.handlers;k||(D&&D(this.lastMoveEvent,E),this.startEvent=this.lastMoveEvent),B&&B(this.lastMoveEvent,E)},this.handlePointerMove=(E,k)=>{this.lastMoveEvent=E,this.lastRawMoveEventInfo=k,this.lastMoveEventInfo=NR(k,this.transformPagePoint),ia.update(this.updatePoint,!0)},this.handlePointerUp=(E,k)=>{this.end();const{onEnd:R,onSessionEnd:P,resumeAnimation:M}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&M&&M(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const D=jz(E.type==="pointercancel"?this.lastMoveEventInfo:NR(k,this.transformPagePoint),this.history);this.startEvent&&R&&R(E,D),P&&P(E,D)},!eW(e))return;this.dragSnapToOrigin=o,this.handlers=r,this.transformPagePoint=n,this.distanceThreshold=c,this.contextWindow=s||window;const f=sC(e),p=NR(f,this.transformPagePoint),{point:y}=p,{timestamp:v}=Yl;this.history=[{...y,timestamp:v}];const{onSessionStart:S}=r;S&&S(e,jz(p,this.history)),this.removeListeners=tC(wA(this.contextWindow,"pointermove",this.handlePointerMove),wA(this.contextWindow,"pointerup",this.handlePointerUp),wA(this.contextWindow,"pointercancel",this.handlePointerUp)),a&&this.startScrollTracking(a)}startScrollTracking(e){let r=e.parentElement;for(;r;){const n=getComputedStyle(r);(Dse.has(n.overflowX)||Dse.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),ia.update(this.updatePoint,!0))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),Ax(this.updatePoint)}}function NR(t,e){return e?{point:e(t.point)}:t}function Ose(t,e){return{x:t.x-e.x,y:t.y-e.y}}function jz({point:t},e){return{point:t,delta:Ose(t,u1e(e)),offset:Ose(t,Ant(e)),velocity:knt(e,.1)}}function Ant(t){return t[0]}function u1e(t){return t[t.length-1]}function knt(t,e){if(t.length<2)return{x:0,y:0};let r=t.length-1,n=null;const s=u1e(t);for(;r>=0&&(n=t[r],!(s.timestamp-n.timestamp>Ou(e)));)r--;if(!n)return{x:0,y:0};n===t[0]&&t.length>2&&s.timestamp-n.timestamp>Ou(e)*2&&(n=t[1]);const o=ih(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 Nnt(t,{min:e,max:r},n){return e!==void 0&&tr&&(t=n?Ma(r,t,n.max):Math.min(t,r)),t}function Fse(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 Cnt(t,{top:e,left:r,bottom:n,right:s}){return{x:Fse(t.x,r,s),y:Fse(t.y,e,n)}}function Bse(t,e){let r=e.min-t.min,n=e.max-t.max;return e.max-e.minn?r=bk(e.min,e.max-n,t.min):n>s&&(r=bk(t.min,t.max-s,e.min)),Rm(0,1,r)}function Rnt(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 O8=.35;function Lnt(t=O8){return t===!1?t=0:t===!0&&(t=O8),{x:$se(t,"left","right"),y:$se(t,"top","bottom")}}function $se(t,e,r){return{min:zse(t,e),max:zse(t,r)}}function zse(t,e){return typeof t=="number"?t:t[e]||0}const Mnt=new WeakMap;class Dnt{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=ll(),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=v=>{r&&this.snapToCursor(sC(v).point),this.stopAnimation()},c=(v,S)=>{const{drag:E,dragPropagation:k,onDragStart:R}=this.getProps();if(E&&!k&&(this.openDragLock&&this.openDragLock(),this.openDragLock=ctt(E),!this.openDragLock))return;this.latestPointerEvent=v,this.latestPanInfo=S,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),nm(M=>{let D=this.getAxisMotionValue(M).get()||0;if(Em.test(D)){const{projection:B}=this.visualElement;if(B&&B.layout){const V=B.layout.layoutBox[M];V&&(D=Jc(V)*(parseFloat(D)/100))}}this.originPoint[M]=D}),R&&ia.update(()=>R(v,S),!1,!0),k8(this.visualElement,"transform");const{animationState:P}=this.visualElement;P&&P.setActive("whileDrag",!0)},a=(v,S)=>{this.latestPointerEvent=v,this.latestPanInfo=S;const{dragPropagation:E,dragDirectionLock:k,onDirectionLock:R,onDrag:P}=this.getProps();if(!E&&!this.openDragLock)return;const{offset:M}=S;if(k&&this.currentDirection===null){this.currentDirection=Fnt(M),this.currentDirection!==null&&R&&R(this.currentDirection);return}this.updateAxis("x",S.point,M),this.updateAxis("y",S.point,M),this.visualElement.render(),P&&ia.update(()=>P(v,S),!1,!0)},f=(v,S)=>{this.latestPointerEvent=v,this.latestPanInfo=S,this.stop(v,S),this.latestPointerEvent=null,this.latestPanInfo=null},p=()=>{const{dragSnapToOrigin:v}=this.getProps();(v||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:y}=this.getProps();this.panSession=new c1e(e,{onSessionStart:o,onStart:c,onMove:a,onSessionEnd:f,resumeAnimation:p},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:y,distanceThreshold:n,contextWindow:l1e(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&&ia.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||!CR(e,s,this.currentDirection))return;const o=this.getAxisMotionValue(e);let c=this.originPoint[e]+n[e];this.constraints&&this.constraints[e]&&(c=Nnt(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&&Kw(e)?this.constraints||(this.constraints=this.resolveRefConstraints()):e&&n?this.constraints=Cnt(n.layoutBox,e):this.constraints=!1,this.elastic=Lnt(r),s!==this.constraints&&!Kw(e)&&n&&this.constraints&&!this.hasMutatedConstraints&&nm(c=>{this.constraints!==!1&&this.getAxisMotionValue(c)&&(this.constraints[c]=Rnt(n.layoutBox[c],this.constraints[c]))})}resolveRefConstraints(){const{dragConstraints:e,onMeasureDragConstraints:r}=this.getProps();if(!e||!Kw(e))return!1;const n=e.current;TS(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=Ftt(n,s.root,this.visualElement.getTransformPagePoint());let c=Int(s.layout.layoutBox,o);if(r){const a=r(Mtt(c));this.hasMutatedConstraints=!!a,a&&(c=Cwe(a))}return c}startAnimation(e){const{drag:r,dragMomentum:n,dragElastic:s,dragTransition:o,dragSnapToOrigin:c,onDragTransitionEnd:a}=this.getProps(),f=this.constraints||{},p=nm(y=>{if(!CR(y,r,this.currentDirection))return;let v=f&&f[y]||{};(c===!0||c===y)&&(v={min:0,max:0});const S=s?200:1e6,E=s?40:1e7,k={type:"inertia",velocity:n?e[y]:0,bounceStiffness:S,bounceDamping:E,timeConstant:750,restDelta:1,restSpeed:10,...o,...v};return this.startAxisValueAnimation(y,k)});return Promise.all(p).then(a)}startAxisValueAnimation(e,r){const n=this.getAxisMotionValue(e);return k8(this.visualElement,e),n.start(YH(e,n,0,r,this.visualElement,!1))}stopAnimation(){nm(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){nm(r=>{const{drag:n}=this.getProps();if(!CR(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]-Ma(c,a,.5)+f)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:e,dragConstraints:r}=this.getProps(),{projection:n}=this.visualElement;if(!Kw(r)||!n||!this.constraints)return;this.stopAnimation();const s={x:0,y:0};nm(c=>{const a=this.getAxisMotionValue(c);if(a&&this.constraints!==!1){const f=a.get();s[c]=Pnt({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(),nm(c=>{if(!CR(c,e,null))return;const a=this.getAxisMotionValue(c),{min:f,max:p}=this.constraints[c];a.set(Ma(f,p,s[c]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;Mnt.set(this.visualElement,this);const e=this.visualElement.current,r=wA(e,"pointerdown",p=>{const{drag:y,dragListener:v=!0}=this.getProps(),S=p.target,E=S!==e&&ptt(S);y&&v&&!E&&this.start(p)});let n;const s=()=>{const{dragConstraints:p}=this.getProps();Kw(p)&&p.current&&(this.constraints=this.resolveRefConstraints(),n||(n=Ont(e,p.current,()=>this.scalePositionWithinConstraints())))},{projection:o}=this.visualElement,c=o.addEventListener("measure",s);o&&!o.layout&&(o.root&&o.root.updateScroll(),o.updateLayout()),ia.read(s);const a=Tk(window,"resize",()=>this.scalePositionWithinConstraints()),f=o.addEventListener("didUpdate",({delta:p,hasLayoutChanged:y})=>{this.isDragging&&y&&(nm(v=>{const S=this.getAxisMotionValue(v);S&&(this.originPoint[v]+=p[v].translate,S.set(S.get()+p[v].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=O8,dragMomentum:a=!0}=e;return{...e,drag:r,dragDirectionLock:n,dragPropagation:s,dragConstraints:o,dragElastic:c,dragMomentum:a}}}function Use(t){let e=!0;return()=>{if(e){e=!1;return}t()}}function Ont(t,e,r){const n=Yne(t,Use(r)),s=Yne(e,Use(r));return()=>{n(),s()}}function CR(t,e,r){return(e===!0||e===t)&&(r===null||r===t)}function Fnt(t,e=10){let r=null;return Math.abs(t.y)>e?r="y":Math.abs(t.x)>e&&(r="x"),r}class Bnt extends Gx{constructor(e){super(e),this.removeGroupControls=dh,this.removeListeners=dh,this.controls=new Dnt(e)}mount(){const{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||dh}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 Az=t=>(e,r)=>{t&&ia.update(()=>t(e,r),!1,!0)};class $nt extends Gx{constructor(){super(...arguments),this.removePointerDownListener=dh}onPointerDown(e){this.session=new c1e(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:l1e(this.node)})}createPanHandlers(){const{onPanSessionStart:e,onPanStart:r,onPan:n,onPanEnd:s}=this.node.getProps();return{onSessionStart:Az(e),onStart:Az(r),onMove:Az(n),onEnd:(o,c)=>{delete this.session,s&&ia.postRender(()=>s(o,c))}}}mount(){this.removePointerDownListener=wA(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 kz=!1;class znt 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),kz&&o.root.didUpdate(),o.addEventListener("animationComplete",()=>{this.safeToRemove()}),o.setOptions({...o.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),WL.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}),kz=!0,s||e.layoutDependency!==r||r===void 0||e.isPresent!==o?c.willUpdate():this.safeToRemove(),e.isPresent!==o&&(o?c.promote():c.relegate()||ia.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(),JH.postRender(()=>{!n.currentAnimation&&n.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:e,layoutGroup:r,switchLayoutGroup:n}=this.props,{projection:s}=e;kz=!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 d1e(t){const[e,r]=Qwe(),n=N.useContext(MH);return i.jsx(znt,{...t,layoutGroup:n,switchLayoutGroup:N.useContext(a1e),isPresent:e,safeToRemove:r})}const Unt={pan:{Feature:$nt},drag:{Feature:Bnt,ProjectionNode:Xwe,MeasureLayout:d1e}};function Vse(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&&ia.postRender(()=>o(e,sC(e)))}class Vnt extends Gx{mount(){const{current:e}=this.node;e&&(this.unmount=dtt(e,(r,n)=>(Vse(this.node,n,"Start"),s=>Vse(this.node,s,"End"))))}unmount(){}}class qnt extends Gx{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=tC(Tk(this.node.current,"focus",()=>this.onFocus()),Tk(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function qse(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&&ia.postRender(()=>o(e,sC(e)))}class Gnt extends Gx{mount(){const{current:e}=this.node;if(!e)return;const{globalTapTarget:r,propagate:n}=this.node.props;this.unmount=ytt(e,(s,o)=>(qse(this.node,o,"Start"),(c,{success:a})=>qse(this.node,c,a?"End":"Cancel")),{useGlobalTarget:r,stopPropagation:(n==null?void 0:n.tap)===!1})}unmount(){}}const F8=new WeakMap,Nz=new WeakMap,Hnt=t=>{const e=F8.get(t.target);e&&e(t)},Wnt=t=>{t.forEach(Hnt)};function Knt({root:t,...e}){const r=t||document;Nz.has(r)||Nz.set(r,{});const n=Nz.get(r),s=JSON.stringify(e);return n[s]||(n[s]=new IntersectionObserver(Wnt,{root:t,...e})),n[s]}function Ynt(t,e,r){const n=Knt(e);return F8.set(t,r),n.observe(t),()=>{F8.delete(t),n.unobserve(t)}}const Znt={some:0,all:1};class Xnt extends Gx{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:Znt[s]},a=p=>{const{isIntersecting:y}=p;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:v,onViewportLeave:S}=this.node.getProps(),E=y?v:S;E&&E(p)};this.stopObserver=Ynt(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(Qnt(e,r))&&this.startObserver()}unmount(){var e;(e=this.stopObserver)==null||e.call(this),this.hasEnteredView=!1,this.isInView=!1}}function Qnt({viewport:t={}},{viewport:e={}}={}){return r=>t[r]!==e[r]}const Jnt={inView:{Feature:Xnt},tap:{Feature:Gnt},focus:{Feature:qnt},hover:{Feature:Vnt}},est={layout:{ProjectionNode:Xwe,MeasureLayout:d1e}},tst={...Tnt,...Jnt,...Unt,...est},hr=vnt(tst,_nt);function rst(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 Gse(t){return t.visitor_intent==="buying"&&!t.has_agent}function nst({token:t}={}){var E;const e=$m(),r=t||e.token,{data:n,isLoading:s,isError:o}=tJe(r);Er();const c=(E=n==null?void 0:n.open_houses)==null?void 0:E.id,{data:a}=fr({queryKey:["cohost-visitors",r,c],queryFn:async()=>{const{data:k,error:R}=await Re.rpc("get_cohost_visitors",{_token:r});if(R)throw R;return k||[]},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,p=(a==null?void 0:a.length)||0,y=(a==null?void 0:a.filter(k=>k.visitor_intent==="buying").length)||0,v=(a==null?void 0:a.filter(Gse).length)||0,S=k=>{if(!k)return"";const[R,P]=k.split(":"),M=parseInt(R);return`${M>12?M-12:M||12}:${P} ${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(ml,{className:"h-4 w-4"}),i.jsx("span",{className:"font-bold text-white",children:p})]}),i.jsxs("div",{className:"flex items-center gap-1.5 text-orange-400",children:[i.jsx(Rme,{className:"h-4 w-4"}),i.jsx("span",{className:"font-bold text-white",children:v})]}),i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsx(Gi,{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:As(new Date(f.event_date+"T00:00:00"),"EEEE, MMMM d, yyyy")}),f.start_time&&i.jsxs("span",{children:[S(f.start_time),f.end_time?` – ${S(f.end_time)}`:""]})]}),i.jsx(Um,{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(Jwe,{children:a.map((k,R)=>{var D;const P=rst(k.visitor_intent),M=Gse(k);return i.jsxs(hr.div,{initial:{opacity:0,x:-40,scale:.95},animate:{opacity:1,x:0,scale:1},transition:{duration:.4,delay:R*.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=k.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:[k.first_name," ",k.last_name||""]}),M&&i.jsx(ii,{className:"bg-orange-500/20 text-orange-300 border-orange-500/40 text-[10px] px-1.5 py-0",children:"🔥 HOT"}),k.has_agent&&i.jsx(ii,{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(ii,{variant:"outline",className:`text-[10px] px-1.5 py-0 ${P.color}`,children:[P.emoji," ",P.label]}),i.jsx("span",{className:"text-white/30 text-xs",children:As(new Date(k.created_at),"h:mm a")})]})]})]},k.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(Fme,{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 sst(){const e=Es().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(nst,{token:r})}if(e.startsWith("rsvp/")){const r=e.slice(5);if(r)return i.jsx(Tbe,{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(Sbe,{slug:e})}function ist(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 ast({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=ist(c.target.value);a&&(o(a),e(a.value))},onBlur:c=>{o(null),r==null||r(c)}})}const Hse=[{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 Wse(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 Kse({value:t,className:e}){return i.jsx("span",{className:qt("tabular-nums",e),children:em(t)})}function ost({data:t,agent:e,interactive:r=!0,compact:n=!1}){var Y,J;const s=r&&t.allow_client_edits!==!1,[o,c]=N.useState(()=>t.scenarios.map(Q=>({...Q}))),[a,f]=N.useState(()=>({...t.inputs})),[p,y]=N.useState(()=>Math.min(1,Math.max(0,t.scenarios.length-1))),[v,S]=N.useState(!1),E=N.useMemo(()=>o.map(Q=>qYe(a,Q,t.close_date)),[o,a,t.close_date]),k=E[p]??E[0],R=E[Math.min(1,E.length-1)],P=[t.property_address,[t.city,t.state].filter(Boolean).join(", "),t.zip].filter(Boolean).join(" · "),M=t.mode==="offers",D=E.reduce((Q,ee,le)=>{var pe;return ee.net>(((pe=E[Q])==null?void 0:pe.net)??-1/0)?le:Q},0),B=(Q,ee)=>c(le=>le.map((pe,Te)=>Te===Q?{...pe,...ee}:pe)),V=()=>{c(t.scenarios.map(Q=>({...Q}))),f({...t.inputs})};if(!k)return null;const G=Math.max(k.price,1),W=[{label:"Sale price",get:Q=>Q.price},{label:`Listing commission (${a.listingCommissionPct}%)`,get:Q=>-Q.listingCommission,sub:!0},{label:`Buyer agent commission (${a.buyerCommissionPct}%)`,get:Q=>-Q.buyerCommission,sub:!0,hide:!a.buyerCommissionPct},{label:"Brokerage fee",get:Q=>-Q.brokerageFee,sub:!0,hide:!a.brokerageFee},{label:"Title & settlement",get:Q=>-Q.titleTotal,sub:!0},{label:"Mortgage payoff(s)",get:Q=>-Q.payoffs,sub:!0},{label:a.taxesInArrears?"Prorated property taxes":"Property tax credit",get:Q=>-Q.taxProration,sub:!0,hide:!a.annualTaxes},{label:"Buyer concessions",get:Q=>-Q.concessions,sub:!0,hide:E.every(Q=>!Q.concessions)},{label:"Repair credits",get:Q=>-Q.repairs,sub:!0,hide:E.every(Q=>!Q.repairs)},{label:"Other costs",get:Q=>-Q.otherTotal,sub:!0,hide:!((Y=E[0])!=null&&Y.otherTotal)}];return i.jsxs("div",{className:qt("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(Dt,{asChild:!0,variant:"outline",size:"sm",children:i.jsxs("a",{href:`tel:${e.phone}`,children:[i.jsx(zn,{className:"mr-1.5 h-4 w-4"}),"Call"]})}),i.jsx(Dt,{asChild:!0,variant:"outline",size:"sm",children:i.jsxs("a",{href:`sms:${e.phone}`,children:[i.jsx(ph,{className:"mr-1.5 h-4 w-4"}),"Text"]})})]}),(e==null?void 0:e.email)&&i.jsx(Dt,{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(ns,{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"}),P&&i.jsxs("p",{className:"flex items-center gap-2 text-sm opacity-90",children:[i.jsx(di,{className:"h-4 w-4"}),P]}),i.jsxs("div",{children:[i.jsxs("p",{className:"text-sm opacity-80",children:["Estimated walk-away · ",(J=o[p])==null?void 0:J.label]}),i.jsx("p",{className:"font-serif text-5xl font-semibold tracking-tight tabular-nums sm:text-6xl",children:em(k.net)})]}),i.jsxs("p",{className:"text-sm opacity-80",children:[Math.round(k.netPct*100),"% of the ",em(k.price)," sale price",Wse(t.close_date)&&i.jsxs(i.Fragment,{children:[" · ",i.jsx(co,{className:"inline h-3.5 w-3.5 -mt-0.5"})," closing ",Wse(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,k.net/G*100)}%`}}),Hse.map(Q=>{const ee=Q.key==="concessions"?k.concessions+k.repairs:k[Q.key];return ee>0?i.jsx("div",{className:qt("h-full transition-all duration-500",Q.cls),style:{width:`${ee/G*100}%`}},Q.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 ",em(k.net)]}),Hse.map(Q=>{const ee=Q.key==="concessions"?k.concessions+k.repairs:k[Q.key];return ee>0?i.jsxs("span",{className:"flex items-center gap-1.5",children:[i.jsx("i",{className:qt("h-2.5 w-2.5 rounded-full",Q.cls)}),Q.label," ",em(ee)]},Q.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:qt("grid gap-4",o.length===3?"md:grid-cols-3":o.length===2?"md:grid-cols-2":""),children:o.map((Q,ee)=>{var Te,Ae;const le=E[ee],pe=le.net-R.net;return i.jsxs("div",{role:"button",tabIndex:0,onClick:()=>y(ee),onKeyDown:Le=>Le.key==="Enter"&&y(ee),className:qt("relative cursor-pointer rounded-3xl border bg-card p-5 text-left transition-all",ee===p?"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:Q.label}),i.jsxs("p",{className:"mt-1 text-sm text-muted-foreground",children:["Sale price ",i.jsx(Kse,{value:le.price,className:"font-medium text-foreground"})]}),i.jsx("p",{className:"mt-3 text-3xl font-semibold tracking-tight text-foreground",children:i.jsx(Kse,{value:le.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:qt("mt-2 inline-flex items-center gap-1 text-xs font-medium",pe>=0?"text-primary":"text-destructive"),children:[i.jsx(_f,{className:qt("h-3.5 w-3.5",pe<0&&"rotate-180")}),pe>=0?"+":"−",em(Math.abs(pe))," vs ",o[Math.min(1,o.length-1)].label.toLowerCase()]}),Q.note&&i.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:Q.note}),s&&ee===p&&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(Zp,{min:Math.round((((Te=t.scenarios[ee])==null?void 0:Te.price)||le.price)*.8/1e3)*1e3,max:Math.round((((Ae=t.scenarios[ee])==null?void 0:Ae.price)||le.price)*1.2/1e3)*1e3||1e5,step:1e3,value:[Q.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:Q.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:Q.concessions||"",placeholder:"0",onChange:Le=>B(ee,{concessions:Number(Le.target.value.replace(/\D/g,""))})})]})]})]})]},Q.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:Q=>f({...a,firstPayoff:Number(Q.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(ast,{"aria-label":"Total commission %",value:a.listingCommissionPct+a.buyerCommissionPct,onValueChange:Q=>{const ee=a.listingCommissionPct+a.buyerCommissionPct,le=t.inputs.listingCommissionPct+t.inputs.buyerCommissionPct,pe=ee?a.listingCommissionPct/ee:le?t.inputs.listingCommissionPct/le:.5,Te=+(Q*pe).toFixed(3);f({...a,listingCommissionPct:Te,buyerCommissionPct:+(Q-Te).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(Dt,{variant:"ghost",size:"sm",onClick:V,children:[i.jsx(ADe,{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(Dt,{variant:"outline",size:"sm",className:"print:hidden",onClick:()=>window.print(),children:[i.jsx(SDe,{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((Q,ee)=>i.jsx("th",{className:qt("px-5 py-3 text-right font-medium",ee===p&&"text-primary"),children:Q.label},Q.id))]})}),i.jsxs("tbody",{children:[W.filter(Q=>!Q.hide).map(Q=>i.jsxs("tr",{className:"border-t",children:[i.jsx("td",{className:qt("px-5 py-2.5",Q.sub?"text-muted-foreground":"font-medium text-foreground"),children:Q.label==="Title & settlement"?i.jsxs("button",{className:"inline-flex items-center gap-1 text-left hover:text-foreground",onClick:()=>S(ee=>!ee),children:[Q.label,i.jsx(xl,{className:qt("h-3.5 w-3.5 transition-transform",v&&"rotate-180")})]}):Q.label}),E.map((ee,le)=>i.jsx("td",{className:qt("px-5 py-2.5 text-right tabular-nums",Q.sub?"text-muted-foreground":"font-medium text-foreground"),children:Q.get(ee)<0?`−${em(-Q.get(ee),!0)}`:em(Q.get(ee),!0)},le))]},Q.label)).flatMap(Q=>Q.key!=="Title & settlement"||!v?[Q]:[Q,...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((le,pe)=>i.jsxs("td",{className:"px-5 py-1.5 text-right tabular-nums text-muted-foreground",children:["−",em(ee.amount,!0)]},pe))]},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((Q,ee)=>i.jsx("td",{className:"px-5 py-4 text-right text-lg font-semibold tabular-nums text-primary",children:em(Q.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 lst({dealId:t}){const{data:e}=fr({queryKey:["portal-net-sheet",t],queryFn:async()=>{const{data:n,error:s}=await Re.rpc("get_portal_net_sheet",{_deal_id:t});if(s)throw s;return n??null}}),{data:r}=HYe(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(ost,{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 kx(t){return t==="seller"||t==="listing"}function wD(t){return t==="buyer"||t==="buy-side"}const cst="/assets/homeowner-garden-C8lI4Nq2.jpg";function ust(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 Cz=t=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(t),dst=["Kitchen remodel","Bathroom update","Added a bathroom","New roof","Finished basement","Deck or patio","New HVAC","Flooring","Windows","Solar panels","Landscaping","Other"];function hst({accessKey:t,agentName:e,onDone:r}){const[n,s]=N.useState(!1),[o,c]=N.useState([]),[a,f]=N.useState(""),[p,y]=N.useState(""),[v,S]=N.useState(""),[E,k]=N.useState(!1),[R,P]=N.useState(!1),M=B=>{const V=Number(B.replace(/[^0-9.]/g,""));return B.trim()&&V>0?V:null};async function D(){if(!o.length&&!v.trim()){$t.error("Pick at least one update or add a note");return}k(!0);const{error:B}=await Re.rpc("homeowner_hub_report_renovation",{_key:t,_items:o,_spend:M(a),_value_guess:M(p),_note:v.trim()||null});if(k(!1),B){$t.error("Could not send your updates. Please try again.");return}P(!0),s(!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(Dt,{variant:"outline",className:"homeowner-control",disabled:R,onClick:()=>s(!0),children:[R?i.jsx(Oa,{className:"h-4 w-4 mr-2"}):i.jsx(iDe,{className:"h-4 w-4 mr-2"}),R?"Updates sent":"Report home updates"]}),i.jsx(Fa,{open:n,onOpenChange:s,children:i.jsxs(Sa,{className:"max-h-[90dvh] overflow-y-auto",children:[i.jsxs(Fo,{children:[i.jsx(bo,{children:"What have you updated?"}),i.jsxs(Fu,{children:["Only ",e," sees this."]})]}),i.jsx("div",{className:"grid grid-cols-2 gap-2",children:dst.map(B=>i.jsxs("label",{className:"flex items-center gap-2 text-sm rounded-md border p-2 cursor-pointer",children:[i.jsx(TT,{checked:o.includes(B),onCheckedChange:V=>c(G=>V?[...G,B]:G.filter(W=>W!==B))}),B]},B))}),i.jsxs("div",{className:"grid sm:grid-cols-2 gap-3",children:[i.jsxs("div",{children:[i.jsx(Mr,{htmlFor:"tmv-spend",children:"About how much you spent ($)"}),i.jsx(Dr,{id:"tmv-spend",inputMode:"numeric",placeholder:"e.g. 40,000",value:a,onChange:B=>f(B.target.value)})]}),i.jsxs("div",{children:[i.jsx(Mr,{htmlFor:"tmv-guess",children:"What you think it’s worth ($)"}),i.jsx(Dr,{id:"tmv-guess",inputMode:"numeric",placeholder:"e.g. 520,000",value:p,onChange:B=>y(B.target.value)})]})]}),i.jsxs("div",{children:[i.jsx(Mr,{htmlFor:"tmv-note",children:"Anything else?"}),i.jsx(Bu,{id:"tmv-note",maxLength:1e3,value:v,onChange:B=>S(B.target.value),placeholder:"e.g. Quartz counters, new appliances in 2025"})]}),i.jsx(Dt,{className:"homeowner-primary w-full",disabled:E,onClick:D,children:E?"Sending…":`Send to ${e}`})]})})]})}function fst({equity:t,searchUrl:e}){const[r,n]=N.useState(20),[s,o]=N.useState(6.5),c=ust(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(q9,{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 ",Cz(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(Mr,{className:"block mb-3",children:["Down payment: ",r,"%"]}),i.jsx(Zp,{"aria-label":"Down payment percent",min:5,max:50,step:1,value:[r],onValueChange:f=>n(f[0])})]}),i.jsxs("div",{children:[i.jsxs(Mr,{className:"block mb-3",children:["Interest rate: ",s.toFixed(2),"%"]}),i.jsx(Zp,{"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:Cz(c.price)}),i.jsxs("p",{className:"homeowner-muted text-sm mt-2",children:["About ",Cz(c.payment),"/mo principal & interest on a 30-year loan. Excludes taxes, insurance and closing costs; not a loan approval."]}),a&&i.jsx(Dt,{asChild:!0,className:"homeowner-primary mt-4",children:i.jsxs("a",{href:a,target:"_blank",rel:"noopener noreferrer",children:[i.jsx(wm,{className:"h-4 w-4 mr-2"}),"Browse homes in this range"]})})]})]})]})}function Iz({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 Pz(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 mst(t,e){return t!==null&&e!==null&&Number.isFinite(t)&&Number.isFinite(e)&&t>0&&e>=0?t-e:null}function pst(t){return(t==null?void 0:t.is_won_stage)===!0&&t.is_lost_stage!==!0}const dv=t=>t===null?"—":new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(t);function gst({accessKey:t,standalone:e=!1}){var le,pe,Te,Ae,Le,ke,we,me,je;const r=Er(),[n,s]=N.useState(!1),[o,c]=N.useState(!1),[a,f]=N.useState(!1),[p,y]=N.useState(7),[v,S]=N.useState({}),{data:E,isLoading:k,error:R}=fr({queryKey:["homeowner-hub-public",t],queryFn:async()=>{const{data:_e,error:Ee}=await Re.rpc("homeowner_hub_read",{_key:t});if(Ee)throw Ee;return _e}});N.useEffect(()=>{E!=null&&E.hub.id&&Re.rpc("homeowner_hub_visit",{_key:t})},[t,E==null?void 0:E.hub.id]),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 P=E==null?void 0:E.hub;function M(){P&&(S(Object.fromEntries(["address","city","state","zip_code","home_value","mortgage_balance","interest_rate","remaining_months"].map(_e=>[_e,String(P[_e]??"")]))),s(!0))}async function D(){c(!0);try{const{error:_e}=await Re.rpc("homeowner_hub_save",{_key:t,_details:v});if(_e)throw _e;await r.invalidateQueries({queryKey:["homeowner-hub-public",t]}),s(!1),$t.success("Your home details are saved")}catch{$t.error("Could not save. Check the amounts and try again.")}finally{c(!1)}}async function B(){f(!0);try{const{error:_e}=await Re.rpc("homeowner_hub_request",{_key:t});if(_e)throw _e;await r.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{f(!1)}}if(k)return e?i.jsx("div",{className:"homeowner-page flex min-h-screen items-center justify-center",children:i.jsx(jc,{className:"animate-spin"})}):null;if(!P||!E||R)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 V=Iz({balance:P.mortgage_balance,rate:P.interest_rate,months:P.remaining_months},Pz(P.balance_updated_at)),G=(V==null?void 0:V.remaining)??P.mortgage_balance,W=mst(P.home_value,G),Y=Iz({balance:P.mortgage_balance,rate:P.interest_rate,months:P.remaining_months},Pz(P.balance_updated_at)+12),J=W===null||P.home_value===null?null:W-P.home_value*p/100,Q=P.valuation_requested_at&&Date.now()-Date.parse(P.valuation_requested_at)<864e5,ee=i.jsxs("section",{className:"homeowner-hub min-w-0","aria-label":"Homeowner Hub",children:[i.jsxs("header",{className:"homeowner-heading",children:[i.jsx("img",{src:cst,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(o3,{className:"h-4 w-4"})," PRIVATE HOMEOWNER HUB"]}),i.jsxs(Dt,{variant:"outline",className:"homeowner-hero-control",onClick:M,children:[i.jsx(Ome,{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:P.client_name?`AT HOME WITH ${P.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(di,{className:"h-4 w-4 shrink-0 mt-1"}),[P.address,P.city,P.state].filter(Boolean).join(", ")||"Let’s add your home address"]})]})]})]}),i.jsxs("div",{className:"homeowner-content",children:[P.mls_facts&&(()=>{const _e=P.mls_facts,Ee=[[_e.beds,"Beds"],[_e.baths,"Baths"],[_e.sqft&&Number(_e.sqft).toLocaleString("en-US"),"Sq ft"],[_e.yearBuilt,"Built"]].filter(([ve])=>ve);return i.jsxs("section",{className:"homeowner-facts flex flex-wrap items-center gap-6 pt-8","aria-label":"Home facts",children:[_e.photo&&i.jsx("img",{src:_e.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:[Ee.map(([ve,qe])=>i.jsxs("div",{children:[i.jsx("dt",{className:"homeowner-muted text-xs uppercase tracking-wide",children:qe}),i.jsx("dd",{className:"portal-serif text-2xl",children:ve})]},qe)),_e.lastSalePrice&&i.jsxs("div",{children:[i.jsxs("dt",{className:"homeowner-muted text-xs uppercase tracking-wide",children:["Last sold",_e.lastSaleDate?` · ${_e.lastSaleDate.split(/[-/T]/)[0]}`:""]}),i.jsx("dd",{className:"portal-serif text-2xl",children:dv(_e.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(_f,{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:dv(W)}),i.jsx("p",{className:"homeowner-muted text-sm mt-3 max-w-sm",children:W===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"}),W!==null&&P.home_value!==null&&i.jsx("circle",{cx:"60",cy:"60",r:"50",className:"homeowner-ring-value",strokeDasharray:`${Math.min(1,Math.max(0,W/P.home_value))*314.16} 314.16`,transform:"rotate(-90 60 60)"}),i.jsx(Gi,{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:dv(P.home_value)}),i.jsx("p",{className:"homeowner-muted text-xs mt-1",children:P.home_value===null?"Not provided":P.value_source==="agent_entered"?((le=P.mls_facts)==null?void 0:le.lastSalePrice)===P.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:dv(G)}),i.jsx("p",{className:"homeowner-muted text-xs mt-1",children:V?"Projected from your loan details":G===null?"Not provided":"Last balance provided"})]})]})]})]}),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(_f,{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:dv((V==null?void 0:V.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:dv(Y&&G!==null?G-Y.remaining:null)})]})]}),V&&G!==null&&Y&&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},(_e,Ee)=>{const ve=Iz({balance:P.mortgage_balance,rate:P.interest_rate,months:P.remaining_months},Pz(P.balance_updated_at)+Ee+1),qe=Y.remainingy(_e[0]??7),className:"homeowner-slider"})]})]}),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=E.agent)==null?void 0:pe.name)||"your agent"," for a fresh, local valuation."]})]}),i.jsxs(Dt,{className:"homeowner-primary",disabled:a||!!Q,onClick:B,children:[Q?i.jsx(Oa,{className:"h-4 w-4 mr-2"}):i.jsx(wm,{className:"h-4 w-4 mr-2"}),Q?"Valuation requested":a?"Sending…":"Request my home value"]})]}),i.jsx(hst,{accessKey:t,agentName:((Te=E.agent)==null?void 0:Te.name)||"your agent",onDone:()=>r.invalidateQueries({queryKey:["homeowner-hub-public",t]})}),i.jsx(fst,{equity:J??W,searchUrl:(Ae=E.site)!=null&&Ae.has_idx?`${E.site.url}/search?statuses=Active`:null}),((Le=E.site)==null?void 0:Le.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(([_e,Ee])=>{var ve;return i.jsx(Dt,{asChild:!0,variant:"outline",className:"homeowner-control homeowner-neighborhood-link",children:i.jsxs("a",{href:`${(ve=E.site)==null?void 0:ve.url}/search?q=${encodeURIComponent(P.zip_code||[P.city,P.state].filter(Boolean).join(", "))}&statuses=${_e}`,target:"_blank",rel:"noopener noreferrer",children:[Ee,i.jsx(wm,{className:"h-4 w-4 ml-2"})]})},_e)})}),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:[((ke=E.agent)==null?void 0:ke.avatar_url)&&i.jsx("img",{src:E.agent.avatar_url,alt:E.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:(we=E.agent)==null?void 0:we.name})]})]}),i.jsxs("div",{className:"flex gap-2",children:[((me=E.agent)==null?void 0:me.phone)&&i.jsx(Dt,{asChild:!0,variant:"outline",size:"icon",className:"homeowner-control",children:i.jsx("a",{href:`tel:${E.agent.phone}`,"aria-label":"Call your agent",children:i.jsx(zn,{className:"h-4 w-4"})})}),((je=E.agent)==null?void 0:je.email)&&i.jsx(Dt,{asChild:!0,variant:"outline",size:"icon",className:"homeowner-control",children:i.jsx("a",{href:`mailto:${E.agent.email}`,"aria-label":"Email your agent",children:i.jsx(ns,{className:"h-4 w-4"})})})]})]}),i.jsxs("p",{className:"homeowner-muted text-xs leading-relaxed mt-6",children:["Estimates use only details you or your agent provide. No automatic appraisal, verified ownership, live mortgage balance or guaranteed appreciation is implied. ",P.value_updated_at&&`Value last entered ${new Intl.DateTimeFormat("en-US",{timeZone:"America/New_York",month:"short",day:"numeric",year:"numeric"}).format(Date.parse(P.value_updated_at))}.`]})]}),i.jsx(Fa,{open:n,onOpenChange:s,children:i.jsxs(Sa,{className:"max-h-[90dvh] overflow-y-auto",children:[i.jsx(Fo,{children:i.jsx(bo,{children:"My home details"})}),i.jsxs("form",{onSubmit:_e=>{_e.preventDefault(),D()},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(([_e,Ee])=>i.jsxs("div",{children:[i.jsx(Mr,{htmlFor:`hub-${_e}`,children:Ee}),i.jsx(Dr,{id:`hub-${_e}`,value:v[_e]??"",type:["home_value","mortgage_balance","interest_rate","remaining_months"].includes(_e)?"number":"text",min:_e==="home_value"||_e==="remaining_months"?1:0,max:_e==="interest_rate"?30:_e==="remaining_months"?600:1e9,step:_e==="remaining_months"?1:"any",maxLength:_e==="address"?250:100,onChange:ve=>S(qe=>({...qe,[_e]:ve.target.value}))})]},_e))}),i.jsx(Dt,{type:"submit",disabled:o,className:"w-full",children:o?"Saving…":"Save home details"})]})]})})]});return e?i.jsx("div",{className:"homeowner-page min-h-screen",children:i.jsx("div",{className:"homeowner-shell",children:ee})}):ee}function yst({portal:t,children:e}){var c;const r=pst((c=t==null?void 0:t.deal_pipeline)==null?void 0:c.deal_pipeline_stages),[n,s]=N.useState("transaction"),{data:o}=fr({queryKey:["portal-homeowner-enabled",t==null?void 0:t.slug],queryFn:async()=>{const{data:a,error:f}=await Re.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(iF,{value:n,onValueChange:s,children:i.jsxs(JN,{className:"homeowner-control",children:[i.jsx(gf,{value:"transaction",children:"Your transaction"}),i.jsx(gf,{value:"homeowner",children:"Homeowner Hub"})]})})}),n==="homeowner"?i.jsx("div",{className:"max-w-5xl mx-auto px-5 pb-10",children:i.jsx(gst,{accessKey:t.slug},t.slug)}):e]})}function xst({dealData:t,agentProfile:e,welcomeMessage:r,isWon:n,branding:s}){var p;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(hr.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(hr.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:((p=e.name)==null?void 0:p.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(hr.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(Gi,{className:"w-3 h-3"}),kx(t==null?void 0:t.deal_type)?"Sale":wD(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(di,{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(zn,{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(ns,{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(uS,{className:"w-4 h-4"}),i.jsx("span",{className:"text-sm font-medium",children:"Text"})]})]})})})]})}function h1e({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=zHe(o,new Date);if(wS(o)&&!uh(o))return null;const f=uh(o),p=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(hr.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:p}),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:kx(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(hr.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 k7t(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 vst(t,e){return te.has(r.id))}function C7t(t){return t.reduce((e,r)=>e+r.file_size,0)>25*1024*1024?"Choose documents totaling no more than 25 MB.":null}const _st={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 f1e({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:kx(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=vst(c,e),f=n===c,p=_st[o.key];return i.jsxs("li",{className:"portal-roadmap-step","data-status":a,children:[i.jsxs(Dt,{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(Oa,{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(Ime,{className:"h-4 w-4 shrink-0"}):i.jsx(xl,{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}),p&&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:p.expect})]}),i.jsxs("div",{children:[i.jsx("p",{className:"portal-eyebrow mb-1",children:"Your next move"}),i.jsx("p",{children:p.action})]})]})]})]},o.key)})})]}):null}function m1e({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 Nx(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 I7t(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 bst(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 wst(t){return bst(t).filter(e=>e.show_in_portal)}function P7t(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 Sst=["January","February","March","April","May","June","July","August","September","October","November","December"],Tst=t=>String(t).padStart(2,"0");function p1e(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;yS.date.slice(0,10)===v)})}for(;f.length%7;)f.push(null);const p=[];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 y1e=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function Est({events:t,variant:e="app",provisionalNote:r}){const n=p1e(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=p=>s?{background:p?"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(p=>p.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(p=>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:p.title}),i.jsxs("div",{className:"grid grid-cols-7 gap-1 text-[10px] sm:text-xs",children:[y1e.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)),p.weeks.flat().map((y,v)=>i.jsx("div",{className:`min-h-[52px] sm:min-h-[64px] rounded p-1 ${s?"":y!=null&&y.events.length?y.events.every(S=>S.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(S=>S.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((S,E)=>i.jsxs("div",{className:`leading-tight font-medium ${S.done?"line-through opacity-60":""} ${s?"":"text-primary"}`,style:s?{color:"hsl(var(--portal-gold))"}:void 0,children:[S.label,S.provisional?"*":""]},E))]})},v))]}),i.jsx("ul",{className:"mt-3 space-y-2 text-sm",children:g1e(t,p.key).map((y,v)=>i.jsxs("li",{children:[i.jsxs("span",{className:"text-xs font-semibold uppercase tracking-wide",style:o,children:[As(Nx(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})]},v))})]},p.key))]})}const Vh=t=>t.replace(/[&<>"]/g,e=>({"&":"&","<":"<",">":">",'"':"""})[e]);function R7t(t){var c;const e=p1e(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(v=>v?`
${v.day}
${v.events.map(S=>`
${Vh(S.label)}${S.provisional?"*":""}
`).join("")}`:''),p=[];for(let v=0;v${f.slice(v,v+7).join("")}`);const y=g1e(t.events,a.key).map(v=>`
  • ${Vh(As(Nx(v.date),"MMM d").toUpperCase())}${v.provisional?"*":""}  |  ${Vh(v.label.toUpperCase())}${v.note?`
    ${Vh(v.note)}`:""}
  • `).join("");return`

    ${Vh(t.title)}

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

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

    ${a.title}

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

    Who does what

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