@happyvertical/smrt-planner 0.64.0 → 0.65.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app/404.html +18 -18
- package/app/_app/immutable/chunks/{Dvg9aUdV.js → -LK6mWjh.js} +1 -1
- package/app/_app/immutable/chunks/{QdJwhiGb.js → -vEu1ZGA.js} +1 -1
- package/app/_app/immutable/chunks/{NdB3txNl.js → 5lUoDTc0.js} +1 -1
- package/app/_app/immutable/chunks/B5Jaz9F5.js +1 -0
- package/app/_app/immutable/chunks/{UzLk-XJn.js → B70Winu6.js} +2 -2
- package/app/_app/immutable/chunks/{z_Iza899.js → BOt9eYuh.js} +1 -1
- package/app/_app/immutable/chunks/BkPMAGBQ.js +1 -0
- package/app/_app/immutable/chunks/{Cofbv9Gg.js → BpHwrH7t.js} +1 -1
- package/app/_app/immutable/chunks/{CLvGR8zy.js → CMGdJqaG.js} +1 -1
- package/app/_app/immutable/chunks/{CeZx3xs8.js → CSdlKL1i.js} +1 -1
- package/app/_app/immutable/chunks/{BFbKj-gV.js → CcivLGle.js} +1 -1
- package/app/_app/immutable/chunks/{C5Tt0tzJ.js → CgsqiVa4.js} +1 -1
- package/app/_app/immutable/chunks/CrfcWmKk.js +4 -0
- package/app/_app/immutable/chunks/{DwCT0kKb.js → D1XQMI-_.js} +1 -1
- package/app/_app/immutable/chunks/DC9J9fcW.js +1 -0
- package/app/_app/immutable/chunks/{BXfKCt5-.js → DE8WCcql.js} +1 -1
- package/app/_app/immutable/chunks/{ZR12Q6bm.js → DO2hJIgX.js} +33 -33
- package/app/_app/immutable/chunks/{C5WfbcH9.js → DZUyLFG9.js} +1 -1
- package/app/_app/immutable/chunks/{BcYsDC9x.js → Dj3pBCaI.js} +1 -1
- package/app/_app/immutable/chunks/{DPuDV4cm.js → DleIkzPF.js} +1 -1
- package/app/_app/immutable/chunks/{BDEVm0qt.js → XXuJoMdf.js} +1 -1
- package/app/_app/immutable/chunks/{DPqDMQ4n.js → ZA2TNtdm.js} +1 -1
- package/app/_app/immutable/chunks/{CIiHz5Nj.js → f1ZAQdZO.js} +1 -1
- package/app/_app/immutable/chunks/{Cn0Lprr0.js → iIW6nPvl.js} +1 -1
- package/app/_app/immutable/chunks/{DtkBUO18.js → j7XGtLC-.js} +1 -1
- package/app/_app/immutable/chunks/{B87Nnv6n.js → pg_2rTOh.js} +1 -1
- package/app/_app/immutable/chunks/{C4HawVbk.js → piDeHDEN.js} +3 -3
- package/app/_app/immutable/chunks/{Df9jB9pg.js → q5sdq2iJ.js} +1 -1
- package/app/_app/immutable/chunks/{C5dDNmaM.js → s1qq03w0.js} +1 -1
- package/app/_app/immutable/entry/{app.CbTIyuI1.js → app.Tj0SAIEn.js} +2 -2
- package/app/_app/immutable/entry/start.IQRV_t96.js +1 -0
- package/app/_app/immutable/nodes/{0.DMKfA_qZ.js → 0.DTVOzgxH.js} +1 -1
- package/app/_app/immutable/nodes/{1.DW5Y8yvh.js → 1.2ahntohw.js} +1 -1
- package/app/_app/immutable/nodes/{10.C5qZ3cnJ.js → 10.CRvz9EhF.js} +1 -1
- package/app/_app/immutable/nodes/{11.DPFqVkub.js → 11.BQRnnJ0I.js} +1 -1
- package/app/_app/immutable/nodes/{12.aFoUAcNQ.js → 12.B5vuXKf7.js} +1 -1
- package/app/_app/immutable/nodes/{13.HM6kmIbI.js → 13.DarHOACY.js} +1 -1
- package/app/_app/immutable/nodes/{14.zG3zLPVE.js → 14.DkTPQxLC.js} +1 -1
- package/app/_app/immutable/nodes/{2.CFrTZ88O.js → 2.g1gODAqr.js} +3 -3
- package/app/_app/immutable/nodes/{3.DLBISSbq.js → 3.BiCCPZyZ.js} +1 -1
- package/app/_app/immutable/nodes/{4.CbC471FQ.js → 4.DsaNttkz.js} +1 -1
- package/app/_app/immutable/nodes/{5.CRGNmNQw.js → 5.CnxmcDQj.js} +1 -1
- package/app/_app/immutable/nodes/{6.TebOq_64.js → 6.DOO6Ytf7.js} +1 -1
- package/app/_app/immutable/nodes/{7.B9RuWcaA.js → 7.B2af-4gU.js} +1 -1
- package/app/_app/immutable/nodes/{8.C8LYfemC.js → 8.CQYWVtpr.js} +1 -1
- package/app/_app/immutable/nodes/{9.BFhHYIN9.js → 9.Cukm3hL3.js} +1 -1
- package/app/_app/version.json +1 -1
- package/app/advanced-styles/index.html +20 -20
- package/app/ai/index.html +24 -24
- package/app/blueprint/index.html +19 -19
- package/app/cookbook/index.html +19 -19
- package/app/index.html +27 -27
- package/app/m/ads/AdDeliveryTier/index.html +23 -23
- package/app/m/ads/AdEvent/index.html +23 -23
- package/app/m/ads/AdFormat/index.html +23 -23
- package/app/m/ads/AdGroup/index.html +23 -23
- package/app/m/ads/AdVariation/index.html +23 -23
- package/app/m/analytics/AnalyticsDataStream/index.html +23 -23
- package/app/m/analytics/AnalyticsEvent/index.html +23 -23
- package/app/m/analytics/AnalyticsProperty/index.html +23 -23
- package/app/m/analytics/AnalyticsReport/index.html +23 -23
- package/app/m/approvals/ApprovalEvent/index.html +23 -23
- package/app/m/approvals/ApprovalPolicy/index.html +23 -23
- package/app/m/approvals/ApprovalRequest/index.html +23 -23
- package/app/m/assets/Asset/attachments/index.html +24 -24
- package/app/m/assets/Asset/index.html +23 -23
- package/app/m/assets/AssetAssociation/index.html +23 -23
- package/app/m/assets/AssetMetafield/index.html +23 -23
- package/app/m/assets/AssetStatus/index.html +23 -23
- package/app/m/assets/AssetType/index.html +23 -23
- package/app/m/assets/Folder/index.html +23 -23
- package/app/m/chat/AgentSession/index.html +23 -23
- package/app/m/chat/ChatMessage/index.html +23 -23
- package/app/m/chat/ChatParticipant/index.html +23 -23
- package/app/m/chat/ChatReaction/index.html +23 -23
- package/app/m/chat/ChatRoom/index.html +23 -23
- package/app/m/chat/ChatThread/index.html +23 -23
- package/app/m/chat/VoiceGatewayTurn/index.html +23 -23
- package/app/m/chat/VoiceSession/index.html +23 -23
- package/app/m/commerce/AccountingConnection/index.html +23 -23
- package/app/m/commerce/AccountingInvoiceReadback/index.html +23 -23
- package/app/m/commerce/AccountingMapping/index.html +23 -23
- package/app/m/commerce/AccountingPaymentSync/index.html +23 -23
- package/app/m/commerce/Agreement/index.html +23 -23
- package/app/m/commerce/Cart/index.html +23 -23
- package/app/m/commerce/Contract/index.html +23 -23
- package/app/m/commerce/ContractLineItem/index.html +23 -23
- package/app/m/commerce/Customer/index.html +23 -23
- package/app/m/commerce/DocumentTax/index.html +23 -23
- package/app/m/commerce/Estimate/index.html +23 -23
- package/app/m/commerce/Fulfillment/index.html +23 -23
- package/app/m/commerce/FulfillmentLineItem/index.html +23 -23
- package/app/m/commerce/HistoricalCustomerFunds/index.html +23 -23
- package/app/m/commerce/HistoricalCustomerFundsAllocation/index.html +23 -23
- package/app/m/commerce/HistoricalSalesLine/index.html +23 -23
- package/app/m/commerce/Invoice/index.html +23 -23
- package/app/m/commerce/InvoiceLineItem/index.html +23 -23
- package/app/m/commerce/Lease/index.html +23 -23
- package/app/m/commerce/LicenseSale/index.html +23 -23
- package/app/m/commerce/Order/index.html +23 -23
- package/app/m/commerce/Payment/index.html +23 -23
- package/app/m/commerce/PaymentAllocation/index.html +23 -23
- package/app/m/commerce/PaymentInstrument/index.html +23 -23
- package/app/m/commerce/PaymentIntent/index.html +23 -23
- package/app/m/commerce/Payout/index.html +23 -23
- package/app/m/commerce/ProductionOrder/index.html +23 -23
- package/app/m/commerce/PurchaseContract/index.html +23 -23
- package/app/m/commerce/PurchaseOrder/index.html +23 -23
- package/app/m/commerce/SalesContract/index.html +23 -23
- package/app/m/commerce/SupplierQuote/index.html +23 -23
- package/app/m/commerce/TaxCode/index.html +23 -23
- package/app/m/commerce/TaxComponent/index.html +23 -23
- package/app/m/commerce/TaxSettings/index.html +23 -23
- package/app/m/commerce/TaxSummaryReport/index.html +23 -23
- package/app/m/commerce/TenantPaymentAccount/index.html +23 -23
- package/app/m/commerce/Vendor/index.html +23 -23
- package/app/m/commerce/WholesaleOrder/index.html +23 -23
- package/app/m/content/Content/articles/index.html +24 -24
- package/app/m/content/Content/index.html +23 -23
- package/app/m/content/ContentContribution/index.html +23 -23
- package/app/m/content/ContentContributionAttachment/index.html +23 -23
- package/app/m/content/ContentContributionRevision/index.html +23 -23
- package/app/m/content/ContentContributionType/index.html +23 -23
- package/app/m/content/ContentContributor/index.html +23 -23
- package/app/m/content/ContentCorrection/index.html +23 -23
- package/app/m/content/ContentFeedSource/index.html +23 -23
- package/app/m/content/ContentGovernanceAssignment/index.html +23 -23
- package/app/m/content/ContentGovernancePolicy/index.html +23 -23
- package/app/m/content/ContentGovernanceProfile/index.html +23 -23
- package/app/m/content/ContentReference/index.html +23 -23
- package/app/m/content/ContentReview/index.html +23 -23
- package/app/m/content/ContentVersion/index.html +23 -23
- package/app/m/events/Event/index.html +23 -23
- package/app/m/events/EventParticipant/index.html +23 -23
- package/app/m/events/EventSeries/index.html +23 -23
- package/app/m/events/EventType/index.html +23 -23
- package/app/m/expenses/Expense/index.html +23 -23
- package/app/m/facts/Fact/index.html +23 -23
- package/app/m/facts/FactContent/index.html +23 -23
- package/app/m/facts/FactEvidence/index.html +23 -23
- package/app/m/facts/FactSource/index.html +23 -23
- package/app/m/facts/FactSubject/index.html +23 -23
- package/app/m/facts/FactTag/index.html +23 -23
- package/app/m/fields/FieldPolicy/index.html +23 -23
- package/app/m/fields/FieldPolicySuggestion/index.html +23 -23
- package/app/m/fields/FieldUsageCounter/index.html +23 -23
- package/app/m/human-resources/Employment/index.html +23 -23
- package/app/m/human-resources/EmploymentTerm/index.html +23 -23
- package/app/m/human-resources/HeldQualification/index.html +23 -23
- package/app/m/human-resources/Qualification/index.html +23 -23
- package/app/m/images/Image/index.html +23 -23
- package/app/m/inventory/InventoryLocation/index.html +23 -23
- package/app/m/inventory/Lot/index.html +23 -23
- package/app/m/inventory/LotCorrection/index.html +23 -23
- package/app/m/inventory/LotDocument/index.html +23 -23
- package/app/m/inventory/LotStockLevel/index.html +23 -23
- package/app/m/inventory/LotUsage/index.html +23 -23
- package/app/m/inventory/StockLevel/index.html +23 -23
- package/app/m/inventory/StockMovement/index.html +23 -23
- package/app/m/ledgers/Account/index.html +23 -23
- package/app/m/ledgers/Journal/index.html +23 -23
- package/app/m/ledgers/JournalEntry/index.html +23 -23
- package/app/m/ledgers/Ledger/index.html +23 -23
- package/app/m/manufacturing/Assembly/index.html +23 -23
- package/app/m/manufacturing/BillOfMaterials/index.html +23 -23
- package/app/m/manufacturing/BomLine/index.html +23 -23
- package/app/m/manufacturing/Operation/index.html +23 -23
- package/app/m/manufacturing/ProductionRun/index.html +23 -23
- package/app/m/manufacturing/ProductionRunCompletion/index.html +23 -23
- package/app/m/manufacturing/RoutingStep/index.html +23 -23
- package/app/m/marketing/Campaign/index.html +23 -23
- package/app/m/marketing/CampaignChannel/index.html +23 -23
- package/app/m/marketing/CampaignMetricSnapshot/index.html +23 -23
- package/app/m/messages/Account/index.html +23 -23
- package/app/m/messages/Attachment/index.html +23 -23
- package/app/m/messages/Blacklist/index.html +23 -23
- package/app/m/messages/Email/failed-sends/index.html +24 -24
- package/app/m/messages/Email/index.html +23 -23
- package/app/m/messages/Email/mailbox/index.html +24 -24
- package/app/m/messages/EmailAccount/index.html +23 -23
- package/app/m/messages/EmailAttachment/index.html +23 -23
- package/app/m/messages/EmailFolder/index.html +23 -23
- package/app/m/messages/Message/index.html +23 -23
- package/app/m/messages/MessagingEndpoint/index.html +23 -23
- package/app/m/messages/PersonaMessageRoute/index.html +23 -23
- package/app/m/messages/SlackAccount/index.html +23 -23
- package/app/m/messages/SlackMessage/index.html +23 -23
- package/app/m/messages/SlackMessage/slack-messages/index.html +24 -24
- package/app/m/messages/TelegramAccount/index.html +23 -23
- package/app/m/messages/Tweet/index.html +23 -23
- package/app/m/messages/TwitterAccount/index.html +23 -23
- package/app/m/messages/Whitelist/index.html +23 -23
- package/app/m/messages/ZulipAccount/index.html +23 -23
- package/app/m/places/Place/index.html +23 -23
- package/app/m/places/PlaceType/index.html +23 -23
- package/app/m/products/Category/index.html +23 -23
- package/app/m/products/Material/index.html +23 -23
- package/app/m/products/Product/index.html +23 -23
- package/app/m/products/Product/ingredients/index.html +24 -24
- package/app/m/products/ProductVariant/index.html +23 -23
- package/app/m/products/Sku/index.html +23 -23
- package/app/m/profiles/ApiKey/index.html +23 -23
- package/app/m/profiles/Bot/index.html +23 -23
- package/app/m/profiles/MagicLinkToken/index.html +23 -23
- package/app/m/profiles/NostrIdentity/index.html +23 -23
- package/app/m/profiles/OidcIdentity/index.html +23 -23
- package/app/m/profiles/Organization/index.html +23 -23
- package/app/m/profiles/Person/index.html +23 -23
- package/app/m/profiles/Profile/index.html +23 -23
- package/app/m/profiles/ProfileMetadata/index.html +23 -23
- package/app/m/profiles/ProfileMetafield/index.html +23 -23
- package/app/m/profiles/ProfileRelationship/index.html +23 -23
- package/app/m/profiles/ProfileRelationshipTerm/index.html +23 -23
- package/app/m/profiles/ProfileRelationshipType/index.html +23 -23
- package/app/m/profiles/ProfileType/index.html +23 -23
- package/app/m/projects/Comment/index.html +23 -23
- package/app/m/projects/Issue/index.html +23 -23
- package/app/m/projects/Label/index.html +23 -23
- package/app/m/projects/Project/index.html +23 -23
- package/app/m/projects/ProjectIntegration/index.html +23 -23
- package/app/m/projects/PullRequest/index.html +23 -23
- package/app/m/projects/Repository/index.html +23 -23
- package/app/m/properties/Property/index.html +23 -23
- package/app/m/properties/Zone/index.html +23 -23
- package/app/m/reports/RuntimeReport/index.html +23 -23
- package/app/m/reports/SmrtPrincipalReportRefreshTask/index.html +23 -23
- package/app/m/reports/SmrtReportLock/index.html +23 -23
- package/app/m/reports/SmrtReportRefreshTask/index.html +23 -23
- package/app/m/reports/SmrtReportRun/index.html +23 -23
- package/app/m/reports/SmrtReportSchedule/index.html +23 -23
- package/app/m/reports/SmrtReportWatermark/index.html +23 -23
- package/app/m/sales/Agreement/index.html +23 -23
- package/app/m/sales/AttributionException/index.html +23 -23
- package/app/m/sales/AttributionPolicy/index.html +23 -23
- package/app/m/sales/Commission/index.html +23 -23
- package/app/m/sales/CommissionAdjustment/index.html +23 -23
- package/app/m/sales/CommissionPayout/index.html +23 -23
- package/app/m/sales/CommissionPlan/index.html +23 -23
- package/app/m/sales/Earner/index.html +23 -23
- package/app/m/sales/EarnerSourceAttribution/index.html +23 -23
- package/app/m/sales/EarningEvent/index.html +23 -23
- package/app/m/sales/ExecutedAgreement/index.html +23 -23
- package/app/m/sales/Lead/index.html +23 -23
- package/app/m/sales/Opportunity/index.html +23 -23
- package/app/m/sales/OpportunityConversion/index.html +23 -23
- package/app/m/sales/PipelineDefinition/index.html +23 -23
- package/app/m/sales/PipelineStage/index.html +23 -23
- package/app/m/sales/Referral/index.html +23 -23
- package/app/m/sales/ReferralAgreement/index.html +23 -23
- package/app/m/sales/ReferralLink/index.html +23 -23
- package/app/m/sales/ReferralProgram/index.html +23 -23
- package/app/m/sales/ReferralTermSnapshot/index.html +23 -23
- package/app/m/sales/ReferralTouch/index.html +23 -23
- package/app/m/sales/Referrer/index.html +23 -23
- package/app/m/sales/ReferrerIdentifier/index.html +23 -23
- package/app/m/sales/SalesActivity/index.html +23 -23
- package/app/m/sales/SalesRepresentative/index.html +23 -23
- package/app/m/sites/DnsZone/index.html +23 -23
- package/app/m/sites/Domain/index.html +23 -23
- package/app/m/sites/ProjectDomain/index.html +23 -23
- package/app/m/sites/Site/index.html +23 -23
- package/app/m/sites/SiteAgentBinding/index.html +23 -23
- package/app/m/social/OAuthState/index.html +23 -23
- package/app/m/social/SocialAccount/index.html +23 -23
- package/app/m/social/SocialPost/index.html +23 -23
- package/app/m/social/SocialPostAnalyticsSnapshot/index.html +23 -23
- package/app/m/subscriptions/BillingAdjustment/index.html +23 -23
- package/app/m/subscriptions/ClientCharge/index.html +23 -23
- package/app/m/subscriptions/CreditGrant/index.html +23 -23
- package/app/m/subscriptions/PricingRule/index.html +23 -23
- package/app/m/subscriptions/RetailCharge/index.html +23 -23
- package/app/m/subscriptions/SpendingPolicy/index.html +23 -23
- package/app/m/subscriptions/SubscriptionPlan/index.html +23 -23
- package/app/m/subscriptions/SubscriptionPlanVersion/index.html +23 -23
- package/app/m/subscriptions/TenantSubscription/index.html +23 -23
- package/app/m/subscriptions/TenantUsageMetric/index.html +23 -23
- package/app/m/support/ServiceTimeEntry/index.html +23 -23
- package/app/m/support/SupportAiRun/index.html +23 -23
- package/app/m/support/SupportAvailability/index.html +23 -23
- package/app/m/support/SupportCase/index.html +23 -23
- package/app/m/support/SupportCaseEvent/index.html +23 -23
- package/app/m/support/SupportChannelBinding/index.html +23 -23
- package/app/m/support/SupportCharge/index.html +23 -23
- package/app/m/support/SupportCompensation/index.html +23 -23
- package/app/m/support/SupportCompensationPlan/index.html +23 -23
- package/app/m/support/SupportEscalation/index.html +23 -23
- package/app/m/support/SupportInteraction/index.html +23 -23
- package/app/m/support/SupportPlan/index.html +23 -23
- package/app/m/support/SupportPolicy/index.html +23 -23
- package/app/m/support/SupportQualification/index.html +23 -23
- package/app/m/support/SupportServiceTarget/index.html +23 -23
- package/app/m/support/SupportSpecialist/index.html +23 -23
- package/app/m/support/SupportWorkLink/index.html +23 -23
- package/app/m/tags/Tag/index.html +23 -23
- package/app/m/tags/TagAlias/index.html +23 -23
- package/app/m/timesheets/AttendanceBreak/index.html +23 -23
- package/app/m/timesheets/AttendancePunch/index.html +23 -23
- package/app/m/timesheets/AttendanceSegment/index.html +23 -23
- package/app/m/timesheets/ServiceChargeSnapshot/index.html +23 -23
- package/app/m/timesheets/ServiceCompensationSnapshot/index.html +23 -23
- package/app/m/timesheets/ServiceTimeEntry/index.html +23 -23
- package/app/m/users/Group/index.html +23 -23
- package/app/m/users/GroupMember/index.html +23 -23
- package/app/m/users/GroupRole/index.html +23 -23
- package/app/m/users/Membership/index.html +23 -23
- package/app/m/users/MembershipOverride/index.html +23 -23
- package/app/m/users/Permission/index.html +23 -23
- package/app/m/users/Role/index.html +23 -23
- package/app/m/users/RolePermission/index.html +23 -23
- package/app/m/users/Session/index.html +23 -23
- package/app/m/users/Tenant/index.html +23 -23
- package/app/m/users/TenantIntegration/index.html +23 -23
- package/app/m/users/TenantPermissionOverride/index.html +23 -23
- package/app/m/users/User/index.html +23 -23
- package/app/m/video/Character/index.html +23 -23
- package/app/m/video/CharacterAsset/index.html +23 -23
- package/app/m/video/CompositeJob/index.html +23 -23
- package/app/m/video/Performer/index.html +23 -23
- package/app/m/video/PerformerAsset/index.html +23 -23
- package/app/m/video/Scene/index.html +23 -23
- package/app/m/video/SceneAsset/index.html +23 -23
- package/app/m/video/VideoComposition/index.html +23 -23
- package/app/m/video/VideoCompositionAsset/index.html +23 -23
- package/app/m/video/VideoSequence/index.html +23 -23
- package/app/m/video/VideoSequenceAsset/index.html +23 -23
- package/app/m/video/VideoShot/index.html +23 -23
- package/app/m/video/VideoShotAsset/index.html +23 -23
- package/app/m/video/VideoShotCharacter/index.html +23 -23
- package/app/m/video/VideoWorkflow/index.html +23 -23
- package/app/m/voice/VoiceOutput/index.html +23 -23
- package/app/m/voice/VoiceProfile/index.html +23 -23
- package/app/m/voice/VoiceSample/index.html +23 -23
- package/app/mcp.html +2 -2
- package/app/packages/ads/index.html +21 -21
- package/app/packages/analytics/index.html +21 -21
- package/app/packages/app-mcp/index.html +21 -21
- package/app/packages/approvals/index.html +21 -21
- package/app/packages/assets/index.html +21 -21
- package/app/packages/chat/index.html +21 -21
- package/app/packages/comments/index.html +21 -21
- package/app/packages/commerce/index.html +21 -21
- package/app/packages/content/index.html +21 -21
- package/app/packages/events/index.html +21 -21
- package/app/packages/expenses/index.html +21 -21
- package/app/packages/facts/index.html +21 -21
- package/app/packages/fields/index.html +21 -21
- package/app/packages/human-resources/index.html +21 -21
- package/app/packages/images/index.html +21 -21
- package/app/packages/index.html +20 -20
- package/app/packages/inference/index.html +21 -21
- package/app/packages/ingestion/index.html +21 -21
- package/app/packages/inventory/index.html +21 -21
- package/app/packages/ledgers/index.html +21 -21
- package/app/packages/manufacturing/index.html +21 -21
- package/app/packages/marketing/index.html +21 -21
- package/app/packages/messages/index.html +21 -21
- package/app/packages/places/index.html +21 -21
- package/app/packages/preferences/index.html +21 -21
- package/app/packages/products/index.html +21 -21
- package/app/packages/profiles/index.html +21 -21
- package/app/packages/projects/index.html +21 -21
- package/app/packages/properties/index.html +21 -21
- package/app/packages/reactions/index.html +21 -21
- package/app/packages/reports/index.html +21 -21
- package/app/packages/sales/index.html +21 -21
- package/app/packages/sites/index.html +21 -21
- package/app/packages/social/index.html +21 -21
- package/app/packages/subscriptions/index.html +21 -21
- package/app/packages/support/index.html +21 -21
- package/app/packages/tags/index.html +21 -21
- package/app/packages/timesheets/index.html +21 -21
- package/app/packages/users/index.html +21 -21
- package/app/packages/video/index.html +21 -21
- package/app/packages/voice/index.html +21 -21
- package/app/packages/webhooks/index.html +21 -21
- package/app/recipes/account-access/help/index.html +21 -21
- package/app/recipes/account-access/index.html +23 -23
- package/app/recipes/activity/help/index.html +21 -21
- package/app/recipes/activity/index.html +23 -23
- package/app/recipes/ads.campaigns/help/index.html +21 -21
- package/app/recipes/ads.campaigns/index.html +23 -23
- package/app/recipes/affiliates.referrals/help/index.html +21 -21
- package/app/recipes/affiliates.referrals/index.html +23 -23
- package/app/recipes/agreements/help/index.html +21 -21
- package/app/recipes/agreements/index.html +23 -23
- package/app/recipes/analytics.reports/help/index.html +21 -21
- package/app/recipes/analytics.reports/index.html +23 -23
- package/app/recipes/approvals.requests/help/index.html +21 -21
- package/app/recipes/approvals.requests/index.html +23 -23
- package/app/recipes/assets/help/index.html +21 -21
- package/app/recipes/assets/index.html +23 -23
- package/app/recipes/billing/help/index.html +21 -21
- package/app/recipes/billing/index.html +23 -23
- package/app/recipes/chat.assistant/help/index.html +21 -21
- package/app/recipes/chat.assistant/index.html +23 -23
- package/app/recipes/comments/help/index.html +21 -21
- package/app/recipes/comments/index.html +23 -23
- package/app/recipes/commerce.customers/help/index.html +21 -21
- package/app/recipes/commerce.customers/index.html +23 -23
- package/app/recipes/commerce.estimates/help/index.html +21 -21
- package/app/recipes/commerce.estimates/index.html +23 -23
- package/app/recipes/commerce.purchases/help/index.html +21 -21
- package/app/recipes/commerce.purchases/index.html +23 -23
- package/app/recipes/commerce.sales/help/index.html +21 -21
- package/app/recipes/commerce.sales/index.html +23 -23
- package/app/recipes/commerce.vendors/help/index.html +21 -21
- package/app/recipes/commerce.vendors/index.html +23 -23
- package/app/recipes/commerce.wholesale/help/index.html +21 -21
- package/app/recipes/commerce.wholesale/index.html +23 -23
- package/app/recipes/content.articles/help/index.html +21 -21
- package/app/recipes/content.articles/index.html +23 -23
- package/app/recipes/events.calendar/help/index.html +21 -21
- package/app/recipes/events.calendar/index.html +23 -23
- package/app/recipes/expenses.tracking/help/index.html +21 -21
- package/app/recipes/expenses.tracking/index.html +23 -23
- package/app/recipes/fields.form-customization/help/index.html +21 -21
- package/app/recipes/fields.form-customization/index.html +23 -23
- package/app/recipes/human-resources.people/help/index.html +21 -21
- package/app/recipes/human-resources.people/index.html +23 -23
- package/app/recipes/human-resources.qualifications/help/index.html +21 -21
- package/app/recipes/human-resources.qualifications/index.html +23 -23
- package/app/recipes/ingestion/help/index.html +21 -21
- package/app/recipes/ingestion/index.html +23 -23
- package/app/recipes/integrations/help/index.html +21 -21
- package/app/recipes/integrations/index.html +23 -23
- package/app/recipes/inventory.stock/help/index.html +21 -21
- package/app/recipes/inventory.stock/index.html +23 -23
- package/app/recipes/ledgers.bookkeeping/help/index.html +21 -21
- package/app/recipes/ledgers.bookkeeping/index.html +23 -23
- package/app/recipes/manufacturing.assemblies/help/index.html +21 -21
- package/app/recipes/manufacturing.assemblies/index.html +23 -23
- package/app/recipes/manufacturing.production/help/index.html +21 -21
- package/app/recipes/manufacturing.production/index.html +23 -23
- package/app/recipes/marketing.campaigns/help/index.html +21 -21
- package/app/recipes/marketing.campaigns/index.html +23 -23
- package/app/recipes/messages/help/index.html +21 -21
- package/app/recipes/messages/index.html +23 -23
- package/app/recipes/places.locations/help/index.html +21 -21
- package/app/recipes/places.locations/index.html +23 -23
- package/app/recipes/products/help/index.html +21 -21
- package/app/recipes/products/index.html +23 -23
- package/app/recipes/profiles.identity/help/index.html +21 -21
- package/app/recipes/profiles.identity/index.html +23 -23
- package/app/recipes/projects.tracker/help/index.html +21 -21
- package/app/recipes/projects.tracker/index.html +23 -23
- package/app/recipes/reports.materialized/help/index.html +21 -21
- package/app/recipes/reports.materialized/index.html +23 -23
- package/app/recipes/reports.runtime/help/index.html +21 -21
- package/app/recipes/reports.runtime/index.html +23 -23
- package/app/recipes/sales.pipeline/help/index.html +21 -21
- package/app/recipes/sales.pipeline/index.html +23 -23
- package/app/recipes/social.posts/help/index.html +21 -21
- package/app/recipes/social.posts/index.html +23 -23
- package/app/recipes/subscriptions.plans/help/index.html +21 -21
- package/app/recipes/subscriptions.plans/index.html +23 -23
- package/app/recipes/support.tickets/help/index.html +21 -21
- package/app/recipes/support.tickets/index.html +23 -23
- package/app/recipes/tags.taxonomy/help/index.html +21 -21
- package/app/recipes/tags.taxonomy/index.html +23 -23
- package/app/recipes/team-collaboration/help/index.html +21 -21
- package/app/recipes/team-collaboration/index.html +23 -23
- package/app/recipes/timesheets.time-entries/help/index.html +21 -21
- package/app/recipes/timesheets.time-entries/index.html +23 -23
- package/app/recipes/video.library/help/index.html +21 -21
- package/app/recipes/video.library/index.html +23 -23
- package/app/recipes/voice.profiles/help/index.html +21 -21
- package/app/recipes/voice.profiles/index.html +23 -23
- package/app/s/custom-accounts/index.html +19 -19
- package/app/s/custom-appointments/index.html +19 -19
- package/app/s/custom-billing/index.html +19 -19
- package/app/s/custom-bookings/index.html +19 -19
- package/app/s/custom-buying/index.html +19 -19
- package/app/s/custom-checkout/index.html +19 -19
- package/app/s/custom-classes/index.html +19 -19
- package/app/s/custom-clients/index.html +19 -19
- package/app/s/custom-events/index.html +19 -19
- package/app/s/custom-fleet/index.html +19 -19
- package/app/s/custom-gigs/index.html +19 -19
- package/app/s/custom-giving/index.html +19 -19
- package/app/s/custom-instruments/index.html +19 -19
- package/app/s/custom-jobs/index.html +19 -19
- package/app/s/custom-kitchen/index.html +19 -19
- package/app/s/custom-lessons/index.html +19 -19
- package/app/s/custom-material/index.html +19 -19
- package/app/s/custom-meetings/index.html +19 -19
- package/app/s/custom-members/index.html +19 -19
- package/app/s/custom-merch/index.html +19 -19
- package/app/s/custom-money/index.html +19 -19
- package/app/s/custom-paint/index.html +19 -19
- package/app/s/custom-parts/index.html +19 -19
- package/app/s/custom-rentals/index.html +19 -19
- package/app/s/custom-roastery/index.html +19 -19
- package/app/s/custom-schedule/index.html +19 -19
- package/app/s/custom-shelf/index.html +19 -19
- package/app/s/custom-shop/index.html +19 -19
- package/app/s/custom-students/index.html +19 -19
- package/app/s/custom-wholesale/index.html +19 -19
- package/app/s/custom-work/index.html +19 -19
- package/app/s/custom-yard/index.html +19 -19
- package/app/s/section-access-control/index.html +19 -19
- package/app/s/section-account-security/index.html +19 -19
- package/app/s/section-accounting/index.html +19 -19
- package/app/s/section-agreements/index.html +19 -19
- package/app/s/section-analytics/index.html +19 -19
- package/app/s/section-approvals/index.html +19 -19
- package/app/s/section-assets/index.html +19 -19
- package/app/s/section-billing/index.html +19 -19
- package/app/s/section-calendar/index.html +19 -19
- package/app/s/section-catalog/index.html +19 -19
- package/app/s/section-grow/index.html +19 -19
- package/app/s/section-make/index.html +19 -19
- package/app/s/section-messages/index.html +19 -19
- package/app/s/section-more/index.html +19 -19
- package/app/s/section-operations/index.html +19 -19
- package/app/s/section-places/index.html +19 -19
- package/app/s/section-projects/index.html +19 -19
- package/app/s/section-publish/index.html +19 -19
- package/app/s/section-purchasing/index.html +19 -19
- package/app/s/section-reports.runtime/index.html +19 -19
- package/app/s/section-sales/index.html +19 -19
- package/app/s/section-staff/index.html +19 -19
- package/app/s/section-support/index.html +19 -19
- package/app/s/section-taxonomy/index.html +19 -19
- package/app/s/section-team/index.html +19 -19
- package/app/s/section-work/index.html +19 -19
- package/dist/catalog/catalog.json +41 -41
- package/dist/core/index.js +168 -52
- package/dist/smrt-version.d.ts +1 -1
- package/dist/smrt-version.js +1 -1
- package/package.json +59 -59
- package/app/_app/immutable/chunks/2yrVe07L.js +0 -1
- package/app/_app/immutable/chunks/4yPl9oYm.js +0 -4
- package/app/_app/immutable/chunks/CG9n0ZY7.js +0 -1
- package/app/_app/immutable/chunks/CT052RdO.js +0 -1
- package/app/_app/immutable/entry/start.faNKah4_.js +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@happyvertical/smrt-planner",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.65.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "The smrt planner as a mountable Svelte component with a typed command set and plan snapshot.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -43,15 +43,15 @@
|
|
|
43
43
|
"./package.json": "./package.json"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@happyvertical/ai": "^0.
|
|
47
|
-
"@happyvertical/smrt-assets": "0.
|
|
48
|
-
"@happyvertical/smrt-chat": "0.
|
|
49
|
-
"@happyvertical/smrt-commerce": "0.
|
|
50
|
-
"@happyvertical/smrt-core": "0.
|
|
51
|
-
"@happyvertical/smrt-reports": "0.
|
|
52
|
-
"@happyvertical/smrt-svelte": "0.
|
|
53
|
-
"@happyvertical/smrt-ui": "0.
|
|
54
|
-
"@happyvertical/speech": "^0.
|
|
46
|
+
"@happyvertical/ai": "^0.116.6",
|
|
47
|
+
"@happyvertical/smrt-assets": "0.65.0",
|
|
48
|
+
"@happyvertical/smrt-chat": "0.65.0",
|
|
49
|
+
"@happyvertical/smrt-commerce": "0.65.0",
|
|
50
|
+
"@happyvertical/smrt-core": "0.65.0",
|
|
51
|
+
"@happyvertical/smrt-reports": "0.65.0",
|
|
52
|
+
"@happyvertical/smrt-svelte": "0.65.0",
|
|
53
|
+
"@happyvertical/smrt-ui": "0.65.0",
|
|
54
|
+
"@happyvertical/speech": "^0.116.6",
|
|
55
55
|
"@huggingface/transformers": "^4.3.0",
|
|
56
56
|
"@mlc-ai/web-llm": "^0.2.85"
|
|
57
57
|
},
|
|
@@ -65,55 +65,55 @@
|
|
|
65
65
|
}
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
|
-
"@happyvertical/smrt-ads": "0.
|
|
69
|
-
"@happyvertical/smrt-affiliates": "0.
|
|
70
|
-
"@happyvertical/smrt-agents": "0.
|
|
71
|
-
"@happyvertical/smrt-analytics": "0.
|
|
72
|
-
"@happyvertical/smrt-app-mcp": "0.
|
|
73
|
-
"@happyvertical/smrt-approvals": "0.
|
|
74
|
-
"@happyvertical/smrt-comments": "0.
|
|
75
|
-
"@happyvertical/smrt-content": "0.
|
|
76
|
-
"@happyvertical/smrt-education": "0.
|
|
77
|
-
"@happyvertical/smrt-events": "0.
|
|
78
|
-
"@happyvertical/smrt-expenses": "0.
|
|
79
|
-
"@happyvertical/smrt-facts": "0.
|
|
80
|
-
"@happyvertical/smrt-features": "0.
|
|
81
|
-
"@happyvertical/smrt-fields": "0.
|
|
82
|
-
"@happyvertical/smrt-gnode": "0.
|
|
83
|
-
"@happyvertical/smrt-human-resources": "0.
|
|
84
|
-
"@happyvertical/smrt-images": "0.
|
|
85
|
-
"@happyvertical/smrt-inference": "0.
|
|
86
|
-
"@happyvertical/smrt-ingestion": "0.
|
|
87
|
-
"@happyvertical/smrt-inventory": "0.
|
|
88
|
-
"@happyvertical/smrt-jobs": "0.
|
|
89
|
-
"@happyvertical/smrt-languages": "0.
|
|
90
|
-
"@happyvertical/smrt-ledgers": "0.
|
|
91
|
-
"@happyvertical/smrt-manufacturing": "0.
|
|
92
|
-
"@happyvertical/smrt-marketing": "0.
|
|
93
|
-
"@happyvertical/smrt-messages": "0.
|
|
94
|
-
"@happyvertical/smrt-personas": "0.
|
|
95
|
-
"@happyvertical/smrt-places": "0.
|
|
96
|
-
"@happyvertical/smrt-playbooks": "0.
|
|
97
|
-
"@happyvertical/smrt-preferences": "0.
|
|
98
|
-
"@happyvertical/smrt-products": "0.
|
|
99
|
-
"@happyvertical/smrt-profiles": "0.
|
|
100
|
-
"@happyvertical/smrt-projects": "0.
|
|
101
|
-
"@happyvertical/smrt-prompts": "0.
|
|
102
|
-
"@happyvertical/smrt-properties": "0.
|
|
103
|
-
"@happyvertical/smrt-reactions": "0.
|
|
104
|
-
"@happyvertical/smrt-sales": "0.
|
|
105
|
-
"@happyvertical/smrt-secrets": "0.
|
|
106
|
-
"@happyvertical/smrt-sites": "0.
|
|
107
|
-
"@happyvertical/smrt-social": "0.
|
|
108
|
-
"@happyvertical/smrt-subscriptions": "0.
|
|
109
|
-
"@happyvertical/smrt-support": "0.
|
|
110
|
-
"@happyvertical/smrt-tags": "0.
|
|
111
|
-
"@happyvertical/smrt-tenancy": "0.
|
|
112
|
-
"@happyvertical/smrt-timesheets": "0.
|
|
113
|
-
"@happyvertical/smrt-users": "0.
|
|
114
|
-
"@happyvertical/smrt-video": "0.
|
|
115
|
-
"@happyvertical/smrt-voice": "0.
|
|
116
|
-
"@happyvertical/smrt-webhooks": "0.
|
|
68
|
+
"@happyvertical/smrt-ads": "0.65.0",
|
|
69
|
+
"@happyvertical/smrt-affiliates": "0.65.0",
|
|
70
|
+
"@happyvertical/smrt-agents": "0.65.0",
|
|
71
|
+
"@happyvertical/smrt-analytics": "0.65.0",
|
|
72
|
+
"@happyvertical/smrt-app-mcp": "0.65.0",
|
|
73
|
+
"@happyvertical/smrt-approvals": "0.65.0",
|
|
74
|
+
"@happyvertical/smrt-comments": "0.65.0",
|
|
75
|
+
"@happyvertical/smrt-content": "0.65.0",
|
|
76
|
+
"@happyvertical/smrt-education": "0.65.0",
|
|
77
|
+
"@happyvertical/smrt-events": "0.65.0",
|
|
78
|
+
"@happyvertical/smrt-expenses": "0.65.0",
|
|
79
|
+
"@happyvertical/smrt-facts": "0.65.0",
|
|
80
|
+
"@happyvertical/smrt-features": "0.65.0",
|
|
81
|
+
"@happyvertical/smrt-fields": "0.65.0",
|
|
82
|
+
"@happyvertical/smrt-gnode": "0.65.0",
|
|
83
|
+
"@happyvertical/smrt-human-resources": "0.65.0",
|
|
84
|
+
"@happyvertical/smrt-images": "0.65.0",
|
|
85
|
+
"@happyvertical/smrt-inference": "0.65.0",
|
|
86
|
+
"@happyvertical/smrt-ingestion": "0.65.0",
|
|
87
|
+
"@happyvertical/smrt-inventory": "0.65.0",
|
|
88
|
+
"@happyvertical/smrt-jobs": "0.65.0",
|
|
89
|
+
"@happyvertical/smrt-languages": "0.65.0",
|
|
90
|
+
"@happyvertical/smrt-ledgers": "0.65.0",
|
|
91
|
+
"@happyvertical/smrt-manufacturing": "0.65.0",
|
|
92
|
+
"@happyvertical/smrt-marketing": "0.65.0",
|
|
93
|
+
"@happyvertical/smrt-messages": "0.65.0",
|
|
94
|
+
"@happyvertical/smrt-personas": "0.65.0",
|
|
95
|
+
"@happyvertical/smrt-places": "0.65.0",
|
|
96
|
+
"@happyvertical/smrt-playbooks": "0.65.0",
|
|
97
|
+
"@happyvertical/smrt-preferences": "0.65.0",
|
|
98
|
+
"@happyvertical/smrt-products": "0.65.0",
|
|
99
|
+
"@happyvertical/smrt-profiles": "0.65.0",
|
|
100
|
+
"@happyvertical/smrt-projects": "0.65.0",
|
|
101
|
+
"@happyvertical/smrt-prompts": "0.65.0",
|
|
102
|
+
"@happyvertical/smrt-properties": "0.65.0",
|
|
103
|
+
"@happyvertical/smrt-reactions": "0.65.0",
|
|
104
|
+
"@happyvertical/smrt-sales": "0.65.0",
|
|
105
|
+
"@happyvertical/smrt-secrets": "0.65.0",
|
|
106
|
+
"@happyvertical/smrt-sites": "0.65.0",
|
|
107
|
+
"@happyvertical/smrt-social": "0.65.0",
|
|
108
|
+
"@happyvertical/smrt-subscriptions": "0.65.0",
|
|
109
|
+
"@happyvertical/smrt-support": "0.65.0",
|
|
110
|
+
"@happyvertical/smrt-tags": "0.65.0",
|
|
111
|
+
"@happyvertical/smrt-tenancy": "0.65.0",
|
|
112
|
+
"@happyvertical/smrt-timesheets": "0.65.0",
|
|
113
|
+
"@happyvertical/smrt-users": "0.65.0",
|
|
114
|
+
"@happyvertical/smrt-video": "0.65.0",
|
|
115
|
+
"@happyvertical/smrt-voice": "0.65.0",
|
|
116
|
+
"@happyvertical/smrt-webhooks": "0.65.0",
|
|
117
117
|
"@sveltejs/adapter-static": "^3.0.10",
|
|
118
118
|
"@sveltejs/kit": "2.70.3",
|
|
119
119
|
"@sveltejs/package": "^3.0.0",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{$ as e,bt as t,ct as n,gt as r,nt as i,ot as a,vt as o}from"./DG3qFFTE.js";import{F as s,W as c,_t as l}from"./ZR12Q6bm.js";import{v as u}from"./C4HawVbk.js";import{B as d,H as f,V as p}from"./4yPl9oYm.js";import{c as m,h,n as g,o as _}from"./UzLk-XJn.js";import{b as v,d as y,l as ee,o as te}from"./CLvGR8zy.js";import{n as b}from"./DtkBUO18.js";var x={id:`more`,label:`More`},ne=/^@[^/]+\/(?:smrt-)?([^:]+):(.+)$/;function S(e,t){let n=e.models.find(e=>e.id===t);if(n)return{packageId:n.packageId,name:n.name};let r=ne.exec(t);return r?{packageId:r[1],name:r[2]}:{packageId:`unknown`,name:t}}var C=(e,t,n)=>`item:${e}:${t}${n?`:${n}`:``}`,w=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/^./,e=>e.toUpperCase()),T=(e,t)=>w(S(e,t).name);function re(e,t){let n=new Map(e.recipes.map(e=>[e.id,e])),r=new Map;for(let i of[...t.recipes].sort()){let t=n.get(i);if(!t)continue;let a=t.section??{id:t.group?.id??t.id,label:t.group?.label??t.label},o=`section:${a.id}`,s=r.get(o)??{id:o,label:a.label,items:[]};for(let n of t.nav){let{packageId:t,name:r}=S(e,n.model),i=C(t,r,n.key);s.items.some(e=>e.id===i)||s.items.push({id:i,label:n.label,icon:n.icon??`fileText`})}r.set(o,s)}let i=[...r.values()].filter(e=>e.items.length>0),a=new Set(e.models.filter(e=>e.exposed!==!1).map(e=>e.id)),o=t.features.filter(e=>a.has(e));return o.length&&i.push({id:`section:${x.id}`,label:x.label,items:o.map(n=>{let{packageId:r,name:i}=S(e,n);return{id:C(r,i),label:t.models?.packageName===n.split(`:`)[0]?t.models.lists[i]?.label??w(i):w(i),icon:t.models?.packageName===n.split(`:`)[0]?t.models.lists[i]?.icon??`fileText`:`fileText`}})}),i}var E=(e,t)=>{if(!t?.length)return e;let n=e=>{let n=t.indexOf(e);return n<0?2**53-1:n};return[...e].sort((e,t)=>n(e.id)-n(t.id))};function D(e,t){let n=t.layout,r=re(e,t).map(e=>({id:e.id,label:e.label,defaultLabel:e.label,custom:!1,hidden:!1,items:e.items.map(e=>({id:e.id,label:e.label,defaultLabel:e.label,icon:n?.items?.[e.id]?.icon??e.icon,hidden:!1}))}));for(let e of n?.customSections??[])r.some(t=>t.id===e.id)||r.push({id:e.id,label:e.label,defaultLabel:e.label,custom:!0,hidden:!1,items:[]});for(let[e,t]of Object.entries(n?.moved??{})){let n=r.find(e=>e.id===t);if(n)for(let t of r){let r=t.items.findIndex(t=>t.id===e);r>=0&&t!==n&&n.items.push(...t.items.splice(r,1))}}let i=new Set(n?.hidden??[]);for(let e of r){let t=n?.sections?.[e.id]?.label?.trim();t&&!e.custom&&(e.label=t),e.hidden=i.has(e.id),e.items=E(e.items,n?.itemOrder?.[e.id]);for(let t of e.items){let e=n?.items?.[t.id]?.label?.trim();e&&(t.label=e),t.hidden=i.has(t.id)}}return E(r.filter(e=>e.custom||e.items.length>0),n?.sectionOrder)}var O=(e,t)=>e.models.find(e=>e.id===t),ie=e=>{let t={...e};for(let e of[`hidden`,`customSections`,`sectionOrder`])t[e]?.length||delete t[e];for(let e of[`sections`,`items`,`itemOrder`,`moved`,`panels`,`placements`])t[e]&&Object.keys(t[e]).length===0&&delete t[e];return Object.keys(t).length>1?t:void 0};function ae(e,t,n){let r=e?structuredClone(e):{version:1},i=n.trim();if(t.custom)return i?(r.customSections=r.customSections?.map(e=>e.id===t.id?{...e,label:i}:e),ie(r)):e;let a={...r.sections??{}},o={...a[t.id]??{}};return!i||i===t.defaultLabel?delete o.label:o.label=i,Object.keys(o).length?a[t.id]=o:delete a[t.id],r.sections=a,ie(r)}function oe(e,t,n){let r=e?structuredClone(e):{version:1},i=n?.trim()??``,a={...r.items??{}},o={...a[t.id]??{}};return!i||i===t.defaultLabel?delete o.label:o.label=i,Object.keys(o).length?a[t.id]=o:delete a[t.id],r.items=a,ie(r)}function se(e,t,n){let r=e?structuredClone(e):{version:1},i=(r.hidden??[]).filter(e=>e!==t);return r.hidden=n?[...i,t]:i,ie(r)}var ce=[`material`,`glass`,`studio`,`smrt`,`happyvertical`],k=`@happyvertical/smrt-commerce:`,le={currency:[`Order`,`PurchaseOrder`,`WholesaleOrder`,`Estimate`,`Invoice`,`Agreement`].map(e=>({model:`${k}${e}`,field:`currency`})),taxRate:[`InvoiceLineItem`,`ContractLineItem`].map(e=>({model:`${k}${e}`,field:`taxRate`})),pricesIncludeTax:[`Invoice`,`Contract`].map(e=>({model:`${k}${e}`,field:`lineAmountType`})),taxRounding:[`Invoice`,`Contract`].map(e=>({model:`${k}${e}`,field:`taxRoundingScope`})),paymentTerms:[...[`Order`,`WholesaleOrder`,`Estimate`,`Invoice`,`Agreement`].map(e=>({model:`${k}${e}`,field:`terms`})),{model:`${k}Customer`,field:`paymentTerms`}]},A=e=>e===void 0?e:structuredClone(e),ue=(e,t)=>JSON.stringify(e??null)===JSON.stringify(t??null),de=()=>({$schema:d,version:1,recipes:[],features:[],policies:[]});function fe(e){return!e.models&&!e.recipes.length&&!e.features.length&&!e.policies.length&&!Object.keys(e.exposure??{}).length&&!e.layout&&!e.theme&&!Object.keys(e.overviews??{}).length}var j=e=>[...new Set(e)].sort();function pe(e){let t=new Set([`$schema`,`version`,`name`,`description`,`specs`,`recipes`,`features`,`policies`,`exposure`,`layout`,`theme`,`overviews`,`models`]),n={$schema:d,version:1,...e.name?{name:e.name}:{},...e.description?{description:e.description}:{},...e.specs?{specs:e.specs}:{},recipes:j(e.recipes),features:j(e.features),policies:[...e.policies].sort((e,t)=>e.objectRef.localeCompare(t.objectRef)||e.fieldName.localeCompare(t.fieldName)).map(e=>({...e}))};if(e.models){let t=e=>Object.fromEntries(Object.entries(e).sort(([e],[t])=>e.localeCompare(t)));n.models={version:1,packageName:e.models.packageName,lists:Object.fromEntries(Object.entries(e.models.lists).sort(([e],[t])=>e.localeCompare(t)).map(([e,n])=>[e,{...A(n),fields:t(n.fields)}])),fields:Object.fromEntries(Object.entries(e.models.fields).sort(([e],[t])=>e.localeCompare(t)).map(([e,n])=>[e,t(n)]))}}let r=Object.fromEntries(Object.keys(e.exposure??{}).sort().filter(t=>e.exposure?.[t]?.length).map(t=>[t,[...e.exposure?.[t]??[]].sort()]));Object.keys(r).length&&(n.exposure=r),e.layout&&(n.layout=A(e.layout));let i=Pe(e.theme);i&&(n.theme=i);let a=Object.entries(e.overviews??{}).sort(([e],[t])=>e<t?-1:+(e>t));a.length&&(n.overviews=Object.fromEntries(a.map(([e,t])=>[e,A(t)])));for(let[r,i]of Object.entries(e))t.has(r)||(n[r]=A(i));return n}var M=e=>new Map(e.recipes.map(e=>[e.id,e]));function me(e,t){let n=new Set,r=e=>{let i=t.get(e);if(i&&!n.has(e)){n.add(e);for(let e of i.requires)r(e)}};for(let t of e)r(t);let i=!0;for(;i;){i=!1;for(let e of[...n])for(let a of t.get(e)?.requiresAny??[]){if(a.some(e=>n.has(e)))continue;let e=a.find(e=>t.has(e));e&&(r(e),i=!0)}}return j(n)}function he(e,t){let n=M(e);return new Set([...t.recipes.flatMap(e=>n.get(e)?.models??[]),...t.features])}function ge(e){return e.settingTargets??le}function _e(e,t){return Object.values(ge(e)).some(e=>e.some(e=>e.model===t.objectRef&&e.field===t.fieldName))}function ve(e,t){let n=he(e,t),r={...t,policies:t.policies.filter(t=>n.has(t.objectRef)||_e(e,t))};if(t.exposure){let e=Object.fromEntries(Object.entries(t.exposure).filter(([e])=>n.has(e)));Object.keys(e).length?r.exposure=e:delete r.exposure}return r}var ye=(e,t)=>{let n=M(e);return t.recipes.filter(e=>n.has(e))},be=(e,t)=>{let n=M(e);return t.recipes.filter(e=>!n.has(e))};function xe(e,t){let n=new Set(e),r=new Set(t);return{added:t.filter(e=>!n.has(e)),removed:e.filter(e=>!r.has(e))}}function Se(e,t,n){let r=M(e),i=ye(e,t),a=me([...i,...n],r);return{doc:{...t,recipes:j([...a,...be(e,t)])},changes:{...xe(i,a),kept:[]}}}function Ce(e,t,n){let r=M(e),i=ye(e,t),a=new Set(n),o=me(i.filter(e=>!a.has(e)),r),s=ve(e,{...t,recipes:j([...o,...be(e,t)])}),{added:c,removed:l}=xe(i,o);return{doc:s,changes:{added:c,removed:l,kept:n.filter(e=>o.includes(e)&&i.includes(e))}}}function we(e,t,n,r){let i=new Set(t.features);for(let e of n)r?i.add(e):i.delete(e);let a=[...i].sort(),o={...t,features:a};return r||(o=ve(e,o)),{doc:o,changes:{...xe(t.features,a),kept:[]}}}var Te=(e,t)=>({added:[...e.added,...t.added],removed:[...e.removed,...t.removed],kept:[...e.kept,...t.kept]}),Ee={currency:`USD`,taxRate:0,paymentTerms:``,pricesIncludeTax:!1,taxRounding:`line`},De=[`currency`,`taxRate`,`paymentTerms`,`pricesIncludeTax`,`taxRounding`];function Oe(e){if(e?.defaultValue!==void 0&&e.defaultValue!==null)try{return JSON.parse(e.defaultValue)}catch{return}}var ke=(e,t,n)=>e.find(e=>e.scopeType===`app`&&e.objectRef===t&&e.fieldName===n);function Ae(e,t){let n=ge(e),r={...Ee},i=(e,r)=>{for(let{model:i,field:a}of n[e]){let e=Oe(ke(t.policies,i,a));if(typeof e===r)return e}},a=i(`currency`,`string`),o=i(`taxRate`,`number`),s=i(`paymentTerms`,`string`),c=i(`pricesIncludeTax`,`string`),l=i(`taxRounding`,`string`);return typeof a==`string`&&(r.currency=a),typeof o==`number`&&(r.taxRate=o),typeof s==`string`&&(r.paymentTerms=s),(c===`inclusive`||c===`exclusive`)&&(r.pricesIncludeTax=c===`inclusive`),(l===`line`||l===`document`)&&(r.taxRounding=l),r}var je=e=>e==null||e===``;function Me(e,t,n,r){let i=M(e);for(let e of t.recipes){let t=i.get(e)?.options?.[n]?.fields?.[r];if(t&&`default`in t)return t.default}return O(e,n)?.fields?.find(e=>e.name===r)?.default}function Ne(e,t,n){let r=ge(e),i=t.policies.map(e=>({...e}));for(let a of De){let o=n[a],s=a===`paymentTerms`?String(o).trim():a===`currency`?String(o).trim().toUpperCase():a===`pricesIncludeTax`?o?`inclusive`:`exclusive`:o;for(let{model:n,field:o}of r[a]){let r=Me(e,t,n,o),c=!je(s)&&!(!je(r)&&r===s)&&!(je(r)&&a===`taxRate`&&s===0),l=ke(i,n,o);if(c){let e=JSON.stringify(s);l?l.defaultValue=e:i.push({objectRef:n,fieldName:o,scopeType:`app`,defaultValue:e})}else l&&(delete l.defaultValue,Object.keys(l).length<=3&&(i=i.filter(e=>e!==l)))}}return{...t,policies:i}}function Pe(e){if(!e)return;let t={};return e.preset&&(t.preset=e.preset),e.colorScheme&&(t.colorScheme=e.colorScheme),e.borderRadius&&(t.borderRadius=e.borderRadius),e.density&&(t.density=e.density),e.contrast&&(t.contrast=e.contrast),e.fontFamily&&(t.fontFamily=e.fontFamily),e.custom&&(t.custom={...e.custom}),e.customCss&&(t.customCss=e.customCss),Object.keys(t).length?t:void 0}function Fe(e){let t=e?.colorScheme??`system`,n=e?.custom?`brand colour ${e.custom.primary}`:e?.preset??`smrt`;return t===`system`?n:`${n}, ${t}`}function Ie(e,t){let n={...e.theme??{}};t.preset&&(n.preset=t.preset,delete n.custom),t.primary&&(n.custom={primary:t.primary.toLowerCase(),...e.theme?.custom?.fontFamily?{fontFamily:e.theme.custom.fontFamily}:{}}),t.colorScheme&&(n.colorScheme=t.colorScheme),t.borderRadius&&(n.borderRadius=t.borderRadius),t.density&&(n.density=t.density),t.contrast&&(n.contrast=t.contrast),t.fontFamily===null?(delete n.fontFamily,n.custom?.fontFamily&&(n.custom={primary:n.custom.primary})):t.fontFamily!==void 0&&(n.fontFamily=t.fontFamily);let r=Pe(n),i={...e};return r?i.theme=r:delete i.theme,i}function Le(e,t){e=f(e,t.models);let n=[],r=(e,t,r,i)=>n.push({severity:e,code:t,path:r,message:i}),i=p(t);if(!i.ok){for(let e of i.diagnostics.filter(e=>e.severity===`error`))r(`error`,`invalid_document`,e.path,e.message);return n}for(let e of i.diagnostics)r(e.severity,e.code===`migrated_schema`?`migrated`:e.code,e.path,e.message);let a=i.cookbook,o=M(e),s=D(e,{...a,layout:void 0}),c=p(a,{themePresets:e.themePresets??ce,layout:{sections:s.map(e=>e.id),items:s.flatMap(e=>e.items.map(e=>e.id)),...e.placementItems?{placementItems:e.placementItems}:{}},overviewIds:[...s.map(e=>e.id),...(a.layout?.customSections??[]).map(e=>e.id)]});for(let e of c.diagnostics)(e.code===`unknown_theme_preset`||e.code===`unknown_layout_id`||e.code===`unknown_overview`)&&r(e.code===`unknown_layout_id`&&!e.path.startsWith(`layout.placements.`)?`warning`:e.severity,e.code===`unknown_theme_preset`?`unknown_preset`:e.code,e.path,e.message);for(let[e,t]of a.recipes.entries())o.has(t)||r(`error`,`unknown_recipe`,`recipes[${e}]`,`Unknown recipe "${t}".`);let l=new Set(me(a.recipes,o));for(let e of l)a.recipes.includes(e)||r(`error`,`missing_requirement`,`recipes`,`A recipe needs "${e}", which is not listed.`);for(let[t,n]of a.features.entries()){let i=O(e,n);i?i.exposed===!1&&r(`error`,`model_not_exposed`,`features[${t}]`,`${n} cannot be added as a feature.`):r(`error`,`unknown_model`,`features[${t}]`,`Unknown model "${n}".`)}let u=he(e,a);for(let[t,n]of a.policies.entries()){let i=`policies[${t}]`,a=O(e,n.objectRef);a?(a.fields&&!a.fields.some(e=>e.name===n.fieldName&&!e.system)&&r(`error`,`unknown_field`,`${i}.fieldName`,`${a.name} has no field "${n.fieldName}".`),!u.has(n.objectRef)&&!_e(e,n)&&r(`warning`,`policy_not_covered`,i,`${a.name} is not in the app, so this row has no effect.`)):r(`error`,`unknown_model`,`${i}.objectRef`,`Unknown model "${n.objectRef}".`)}for(let t of Object.keys(a.exposure??{}))O(e,t)||r(`error`,`unknown_model`,`exposure.${t}`,`Unknown model "${t}".`);return n}var N=(e,t,n={})=>({ok:!1,error:{code:e,message:t,...n}}),P=(e,t=``,n={})=>({ok:!0,state:e,summary:t,...n}),Re=`This replaces the recipes, options, menu and look. Send replace: true to confirm.`,F=e=>e.join(`, `);function ze(e){return`${(e??``).normalize(`NFD`).replace(/\p{M}/gu,``).toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)||`my-app`}.cookbook.json`}var Be=e=>`${JSON.stringify(e,null,2)}\n`;function Ve(e,t){let n=new Map(e.recipes.map(e=>[e.id,e])),r=t.recipes.filter(e=>n.has(e)),i=t.recipes.filter(e=>!n.has(e));return pe(ve(e,{...A(t),recipes:[...me(r,n),...i]}))}function He(e,t){return t?e.cookbooks?.find(e=>e.id===t)?.name:void 0}var Ue=(e,t)=>{let n=t=>e.recipes.find(e=>e.id===t)?.label??t;return[t.added.length?`Added ${F(t.added.map(n))}.`:``,t.removed.length?`Removed ${F(t.removed.map(n))}.`:``,t.kept.length?`Kept ${F(t.kept.map(n))} (needed).`:``].filter(Boolean).join(` `)},We=(e,t)=>[t.added.length?`Added ${F(t.added.map(t=>T(e,t)))}.`:``,t.removed.length?`Removed ${F(t.removed.map(t=>T(e,t)))}.`:``].filter(Boolean).join(` `),Ge=e=>`${Number((e*100).toFixed(4))}%`,I=(e,t)=>({...e,doc:pe(t)});function Ke(e,t){let n=D(e,t);return{sections:n,section:e=>n.find(t=>t.id===e),item:e=>n.flatMap(e=>e.items).find(t=>t.id===e)}}var qe=(e,t)=>{let n={...e};return t?n.layout=t:delete n.layout,n},Je={add_recipes(e,t,{ids:n}){let r=n.filter(t=>!e.recipes.some(e=>e.id===t));if(r.length)return N(`not_found`,`No such recipe: ${F(r)}.`,{path:`input.ids`});let{doc:i,changes:a}=Se(e,t.doc,n);return P(I(t,i),Ue(e,a),{changes:a})},remove_recipes(e,t,{ids:n}){let{doc:r,changes:i}=Ce(e,t.doc,n);return P(I(t,r),Ue(e,i),{changes:i})},add_features(e,t,{ids:n}){let r=n.filter(t=>!O(e,t)?.exposed);if(r.length)return N(`not_found`,`No such model to add: ${F(r)}.`,{path:`input.ids`});let{doc:i,changes:a}=we(e,t.doc,n,!0);return P(I(t,i),We(e,a),{changes:a})},remove_features(e,t,{ids:n}){let{doc:r,changes:i}=we(e,t.doc,n,!1);return P(I(t,r),We(e,i),{changes:i})},add_cookbook(e,t,{id:n}){let r=e.cookbooks?.find(e=>e.id===n);if(!r)return N(`not_found`,`No cookbook "${n}".`,{path:`input.id`});let i=Se(e,t.doc,r.document.recipes),a=we(e,i.doc,r.document.features.filter(t=>O(e,t)?.exposed),!0),o=Te(i.changes,a.changes);return P(I(t,a.doc),o.added.length?`Added the ${r.name} cookbook.`:``,{changes:o})},remove_cookbook(e,t,{id:n}){let r=e.cookbooks?.find(e=>e.id===n);if(!r)return N(`not_found`,`No cookbook "${n}".`,{path:`input.id`});let i=Ce(e,t.doc,r.document.recipes),a=we(e,i.doc,r.document.features,!1),o=Te(i.changes,a.changes);return P(I(t,a.doc),[Ue(e,i.changes),We(e,a.changes)].filter(Boolean).join(` `),{changes:o})},apply_cookbook(e,t,{id:n,replace:r}){let i=e.cookbooks?.find(e=>e.id===n);return i?!r&&!fe(t.doc)?N(`confirmation_required`,Re):P({doc:Ve(e,i.document),applied:n},`${i.name} set up.`):N(`not_found`,`No cookbook "${n}".`,{path:`input.id`})},import_cookbook(e,t,{document:n,replace:r}){let i=p(n);if(!i.ok)return N(`invalid_input`,i.errors[0]??`Not a cookbook.`,{path:`input.document`,details:{errors:i.errors}});if(!r&&!fe(t.doc))return N(`confirmation_required`,Re);let a=i.cookbook.recipes.length;return P({doc:Ve(e,i.cookbook),applied:null},`Imported ${a} ${a===1?`recipe`:`recipes`}.`,i.warnings.length?{warnings:i.warnings}:{})},set_settings(e,t,n){let r=Ae(e,t.doc),i={...r},a=[];if(n.currency!==void 0){let t=n.currency.trim().toUpperCase();if(e.currencies&&!e.currencies.includes(t))return N(`invalid_input`,`${t} is not a known currency.`,{path:`input.currency`});if(!/^[A-Z]{3}$/.test(t))return N(`invalid_input`,`currency must be a three-letter code.`,{path:`input.currency`});t!==r.currency&&(i.currency=t,a.push(`currency ${t}`))}if(n.taxRate!==void 0){let e=Number((n.taxRate/100).toFixed(6));e!==r.taxRate&&(i.taxRate=e,a.push(`tax ${Ge(e)}`))}if(n.paymentTerms!==void 0){let e=[...n.paymentTerms].map(e=>e.charCodeAt(0)<32||e.charCodeAt(0)===127?` `:e).join(``).trim();if(!e)return N(`invalid_input`,`paymentTerms must not be empty.`,{path:`input.paymentTerms`});e!==r.paymentTerms&&(i.paymentTerms=e,a.push(`terms ${e}`))}if(n.pricesIncludeTax!==void 0&&n.pricesIncludeTax!==r.pricesIncludeTax&&(i.pricesIncludeTax=n.pricesIncludeTax,a.push(n.pricesIncludeTax?`prices include tax`:`prices exclude tax`)),n.taxRounding!==void 0&&n.taxRounding!==r.taxRounding&&(i.taxRounding=n.taxRounding,a.push(`${n.taxRounding} tax rounding`)),!a.length)return P(t);let o=a.join(`, `);return P(I(t,Ne(e,t.doc,i)),`${o[0].toUpperCase()}${o.slice(1)}.`)},set_policy(e,t,n){e=f(e,t.doc.models);let r=O(e,n.model);if(!r)return N(`not_found`,`No such model: ${n.model}.`,{path:`input.model`});if(r.fields){let e=r.fields.find(e=>e.name===n.field);if(!e||e.system)return N(`not_found`,`${r.name} has no field ${n.field}.`,{path:`input.field`})}if(!he(e,t.doc).has(r.id))return N(`not_found`,`${w(r.name)} is not in the app yet; add its recipe or feature first.`,{path:`input.model`});if(t.doc.recipes.some(t=>e.recipes.find(e=>e.id===t)?.options?.[r.id]?.fields?.[n.field]?.locked))return N(`failed`,`${n.field} is locked by its recipe.`,{path:`input.field`});let i=t.doc.policies.map(e=>({...e})),a=i.find(e=>e.objectRef===r.id&&e.fieldName===n.field),o=a??{objectRef:r.id,fieldName:n.field,scopeType:`app`},s=JSON.stringify(o);for(let e of[`visibility`,`label`,`help`,`readOnly`]){let t=n[e];t!==void 0&&(t===null?delete o[e]:o[e]=t)}if(n.defaultValue!==void 0){if(n.defaultValue===null)delete o.defaultValue;else{let e=JSON.stringify(n.defaultValue);if(e===void 0)return N(`invalid_input`,`defaultValue is not a JSON value.`,{path:`input.defaultValue`});o.defaultValue=e}}let c=Object.keys(o).length<=3;if(JSON.stringify(o)===s||c&&!a)return P(t);let l=i.filter(e=>e!==a);return P(I(t,{...t.doc,policies:c?l:[...l,o]}),`Updated ${w(r.name)} ${n.field}.`)},set_theme(e,t,n){let r=Ie(t.doc,n);return JSON.stringify(pe(r).theme??null)===JSON.stringify(t.doc.theme??null)?P(t):P(I(t,r),`Theme: ${Fe(pe(r).theme)}.`)},reset_theme(e,t){if(!t.doc.theme)return P(t);let n={...t.doc};return delete n.theme,P(I(t,n),`Theme: default.`)},set_name(e,t,n){let r={...t.doc};for(let e of[`name`,`description`,`specs`]){let t=n[e];if(t===void 0)continue;let i=t?.trim();i?r[e]=i:delete r[e]}if(JSON.stringify(pe(r))===JSON.stringify(t.doc))return P(t);let i=n.specs!==void 0&&n.name===void 0&&n.description===void 0;return P(I(t,r),n.name?`Named the app ${n.name.trim()}.`:i?`Updated the app specs.`:`Updated the app details.`)},rename_section(e,t,{id:n,label:r}){let i=Ke(e,t.doc).section(n);if(!i)return N(`not_found`,`No menu section "${n}".`,{path:`input.id`});let a=ae(t.doc.layout,i,r);return JSON.stringify(a??null)===JSON.stringify(t.doc.layout??null)?P(t):P(I(t,qe(t.doc,a)),`Renamed the section to ${r.trim()}.`)},rename_item(e,t,{id:n,label:r}){let i=Ke(e,t.doc).item(n);if(!i)return N(`not_found`,`No menu entry "${n}".`,{path:`input.id`});let a=oe(t.doc.layout,i,r);return JSON.stringify(a??null)===JSON.stringify(t.doc.layout??null)?P(t):P(I(t,qe(t.doc,a)),r?`Renamed the entry to ${r.trim()}.`:`Entry name restored.`)},hide(e,t,{id:n}){let r=Ke(e,t.doc);return r.section(n)??r.item(n)?t.doc.layout?.hidden?.includes(n)?P(t):P(I(t,qe(t.doc,se(t.doc.layout,n,!0))),`Hidden.`):N(`not_found`,`No menu section or entry "${n}".`,{path:`input.id`})},show(e,t,{id:n}){let r=Ke(e,t.doc);return!r.section(n)&&!r.item(n)?N(`not_found`,`No menu section or entry "${n}".`,{path:`input.id`}):t.doc.layout?.hidden?.includes(n)?P(I(t,qe(t.doc,se(t.doc.layout,n,!1))),`Shown.`):P(t)},validate(e,t){let n=Le(e,t.doc);return P(t,``,{data:{ok:!n.some(e=>e.severity===`error`),diagnostics:n}})},export_cookbook(e,t,{name:n}){return P(t,``,{data:{fileName:ze(n??t.doc.name??He(e,t.applied)),text:Be(t.doc),cookbook:A(t.doc)}})}};function Ye(e,t,n,r){let i=Je[n];return i?i(e,t,r):N(`unknown_command`,`No command "${n}".`)}var Xe=(e,t)=>({type:`array`,description:e,minItems:1,maxItems:100,items:t?.length?{type:`string`,enum:[...t]}:{type:`string`,minLength:1}}),L=(e,t={})=>({type:`string`,description:e,minLength:1,maxLength:200,...t}),R=(e,t=[])=>({type:`object`,properties:e,...t.length?{required:t}:{},additionalProperties:!1});function Ze(e){let t=e.recipes.map(e=>e.id),n=(e.cookbooks??[]).map(e=>e.id),r=e.themePresets??ce,i=e=>({type:`string`,description:e,...n.length?{enum:[...n]}:{minLength:1}}),a=e=>L(`The id of ${e}, as the plan snapshot's "sections" lists it.`),o={type:`boolean`,description:`Confirm replacing what is there.`};return[{name:`add_recipes`,description:`Switch recipes on. Recipes they require come along. Returns what was added.`,inputSchema:R({ids:Xe(`Recipe ids to add.`,t)},[`ids`])},{name:`remove_recipes`,description:`Switch recipes off. A recipe another one needs is kept and reported.`,inputSchema:R({ids:Xe(`Recipe ids to remove.`,t)},[`ids`])},{name:`add_features`,description:"Add single models no recipe covers, by qualified name (`@scope/pkg:Class`).",inputSchema:R({ids:Xe(`Qualified model names to add.`)},[`ids`])},{name:`remove_features`,description:`Remove single models added with add_features.`,inputSchema:R({ids:Xe(`Qualified model names to remove.`)},[`ids`])},{name:`add_cookbook`,description:`Add the recipes and features of a ready-made cookbook to the current app. Nothing is replaced.`,inputSchema:R({id:i(`The cookbook to add.`)},[`id`])},{name:`remove_cookbook`,description:`Remove the recipes and features a ready-made cookbook adds. Ones another recipe needs are kept.`,inputSchema:R({id:i(`The cookbook to remove.`)},[`id`])},{name:`apply_cookbook`,description:`Select a ready-made cookbook: replace the whole app (recipes, options, menu, theme) with it. When the app has anything in it, replace must be true.`,inputSchema:R({id:i(`The cookbook to set up.`),replace:o},[`id`])},{name:`import_cookbook`,description:`Replace the whole app with a cookbook document (version 1). Checked strictly; nothing is applied if it is invalid. When the app has anything in it, replace must be true.`,inputSchema:R({document:{type:`object`,description:`A cookbook document, version 1.`},replace:o},[`document`])},{name:`set_settings`,description:`Change app settings: currency, default tax rate (percent), default payment terms. Applies to new records only.`,inputSchema:R({currency:e.currencies?.length?{type:`string`,description:`ISO 4217 code, e.g. CAD.`,enum:[...e.currencies]}:{type:`string`,description:`ISO 4217 code, e.g. CAD.`,pattern:`^[A-Z]{3}$`},taxRate:{type:`number`,description:`Default tax rate in percent, 0 to 100.`,minimum:0,maximum:100},paymentTerms:{type:`string`,description:`Default payment terms, e.g. "Net 30".`,minLength:1,maxLength:40},pricesIncludeTax:{type:`boolean`,description:`Whether new document prices include tax.`},taxRounding:{enum:[`line`,`document`],description:`Whether tax rounds per line or per document.`}})},{name:`set_policy`,description:`Set one field's policy: default value, visibility, label or help. The model must be covered by a recipe or feature that is on. null clears a part.`,inputSchema:R({model:L(`Qualified model name, e.g. @happyvertical/smrt-commerce:Order.`),field:L(`The model field name.`),defaultValue:{description:`The default as a JSON value (a string, number or boolean). null clears it.`},visibility:{enum:[`basic`,`advanced`,`hidden`,null],description:`Whether the field shows in forms and lists.`},label:{type:[`string`,`null`],description:`A different label.`,maxLength:120},readOnly:{type:[`boolean`,`null`],description:`Prevent editing the record value; null inherits.`},help:{type:[`string`,`null`],description:`Help text under the field.`,maxLength:400}},[`model`,`field`])},{name:`set_theme`,description:`Change the look: a preset, a brand colour, light or dark. A preset replaces a brand colour.`,inputSchema:R({preset:{enum:[...r],description:`A built-in theme.`},primary:{type:`string`,description:`Brand colour as #rrggbb.`,pattern:`^#[0-9a-fA-F]{6}$`},colorScheme:{enum:[`light`,`dark`,`system`],description:`Light, dark or follow the device.`},fontFamily:{type:[`string`,`null`],minLength:1,description:`Font key. Null restores the preset font.`},borderRadius:{enum:[`none`,`sm`,`md`,`lg`,`xl`,`full`],description:`Corner roundness.`},density:{enum:[`comfortable`,`touch`],description:`Control size: comfortable, or larger touch targets.`},contrast:{enum:[`auto`,`standard`,`more`],description:`Contrast: auto follows the device, or force standard or more.`}})},{name:`reset_theme`,description:`Go back to the default look.`,inputSchema:R({})},{name:`set_name`,description:`Name, describe and specify the app. null clears a part.`,inputSchema:R({name:{type:[`string`,`null`],minLength:1,maxLength:60},description:{type:[`string`,`null`],minLength:1,maxLength:400},specs:{type:[`string`,`null`],minLength:1,maxLength:2e4,description:`Product requirements beyond recipes and features, as plain text or a short list.`}})},{name:`rename_section`,description:`Rename a menu section.`,inputSchema:R({id:a(`the section`),label:L(`The new name.`,{maxLength:60})},[`id`,`label`])},{name:`rename_item`,description:`Rename a menu entry. A null label restores its own name.`,inputSchema:R({id:a(`the entry`),label:{type:[`string`,`null`],minLength:1,maxLength:60}},[`id`,`label`])},{name:`hide`,description:`Hide a menu section or entry. Nothing is deleted.`,inputSchema:R({id:a(`the section or entry`)},[`id`])},{name:`show`,description:`Show a hidden menu section or entry again.`,inputSchema:R({id:a(`the section or entry`)},[`id`])},{name:`validate`,description:`Check the current cookbook against the catalog and report typed diagnostics. Changes nothing.`,inputSchema:R({})},{name:`export_cookbook`,description:`The cookbook as a <name>.cookbook.json file (text in the result). Changes nothing.`,inputSchema:R({name:L(`A name for the file.`,{maxLength:60})})},{name:`undo`,description:`Undo an earlier change by the undoId its receipt carried. Refused with a conflict when the plan changed since, unless force is true.`,inputSchema:R({undoId:L(`The undoId from a receipt.`),force:{type:`boolean`,description:`Undo even after later edits.`}},[`undoId`])}]}function Qe(e){return{name:`run_batch`,description:`Run several commands as one atomic batch: all apply or none does. A failure names the command and leaves the plan unchanged.`,inputSchema:{type:`object`,properties:{id:{type:`string`,minLength:1,maxLength:200},expectedRevision:{type:`integer`,minimum:0},commands:{type:`array`,minItems:1,maxItems:50,items:{oneOf:Ze(e).map(e=>({type:`object`,properties:{name:{const:e.name},input:e.inputSchema},required:[`name`],additionalProperties:!1}))}}},required:[`commands`],additionalProperties:!1}}}var $e=e=>e===null?`null`:Array.isArray(e)?`array`:Number.isInteger(e)?`integer`:typeof e;function et(e,t){let n=$e(t);return n===e||e===`number`&&n===`integer`}function tt(e,t,n=`input`){let r=e=>({path:n,message:`${n} ${e}`}),i=e.type;if(i){let e=Array.isArray(i)?i:[i];if(!e.some(e=>et(e,t)))return r(`must be ${e.join(` or `)}`)}let a=e.enum;if(a&&!a.includes(t))return r(a.length>12?`is not a known value`:`must be one of ${a.map(e=>JSON.stringify(e)).join(`, `)}`);if(typeof t==`string`){let{minLength:n,maxLength:i,pattern:a}=e;if(n!==void 0&&t.length<n)return r(`must not be empty`);if(i!==void 0&&t.length>i)return r(`must be at most ${i} characters`);if(a&&!new RegExp(a).test(t))return r(`has the wrong format`)}if(typeof t==`number`){let{minimum:n,maximum:i}=e;if(!Number.isFinite(t))return r(`must be a finite number`);if(n!==void 0&&t<n)return r(`must be at least ${n}`);if(i!==void 0&&t>i)return r(`must be at most ${i}`)}if(Array.isArray(t)){let{minItems:i,maxItems:a,items:o}=e;if(i!==void 0&&t.length<i)return r(`needs at least ${i} item${i===1?``:`s`}`);if(a!==void 0&&t.length>a)return r(`takes at most ${a} items`);if(o)for(let[e,r]of t.entries()){let t=tt(o,r,`${n}[${e}]`);if(t)return t}}if($e(t)===`object`){let r=t,{properties:i,required:a,additionalProperties:o}=e;for(let e of a??[])if(r[e]===void 0)return{path:`${n}.${e}`,message:`${n}.${e} is required`};for(let[e,t]of Object.entries(r)){let r=i?.[e];if(!r){if(o===!1)return{path:`${n}.${e}`,message:`${n}.${e} is not an option of this command`};continue}if(t===void 0)continue;let a=tt(r,t,`${n}.${e}`);if(a)return a}}return null}function nt(e){return Object.fromEntries(Ze(e).map(e=>[e.name,e.inputSchema]))}var z=(e,t,n={})=>({code:e,message:t,...n}),rt=e=>Array.isArray(e)?e.map(rt):e&&typeof e==`object`?Object.fromEntries(Object.keys(e).sort().map(t=>[t,rt(e[t])])):e,it=e=>{try{return JSON.stringify(rt(e))??`undefined`}catch{return`unserializable`}};function at(e,t,n){if(!e||typeof e!=`object`||Array.isArray(e))return{ok:!1,error:z(`unknown_command`,`A command is an object: { name, input }.`)};let r=e,{name:i,input:a={}}=r;if(typeof i!=`string`||!Object.hasOwn(t,i))return{ok:!1,error:z(`unknown_command`,`Unknown command ${JSON.stringify(i)}.`)};for(let e of Object.keys(r))if(e!==`name`&&e!==`input`&&!n.includes(e))return{ok:!1,error:z(`invalid_input`,`${e} is not part of a command.`,{path:e})};let o=tt(t[i],a);return o?{ok:!1,error:z(`invalid_input`,o.message,{path:o.path})}:{ok:!0,name:i,input:a}}var ot=e=>e===void 0||typeof e==`string`&&e.length>0&&e.length<=200?null:z(`invalid_input`,`id must be a non-empty string of at most 200 characters.`,{path:`id`}),st=e=>e===void 0||Number.isInteger(e)&&e>=0?null:z(`invalid_input`,`expectedRevision must be a whole number.`,{path:`expectedRevision`});function ct(e){let{catalog:t}=e,n=nt(t),r=Ze(t),i=Qe(t),a=e.maxJournal??500,o=e.maxUndo??20,s,c=0,l=new Map;if(e.state){let n=e.state,r=p(n.cookbook);if(!r.ok)throw Error(`Invalid saved cookbook: ${r.errors.join(`; `)}`);if(!Number.isInteger(n.revision)||n.revision<0)throw Error(`Invalid saved revision.`);s={doc:Ve(t,r.cookbook),applied:n.applied??null},c=n.revision;for(let e of n.journal??[])l.set(e.id,A(e))}else if(e.cookbook!==void 0){let n=p(e.cookbook);if(!n.ok)throw Error(`Invalid cookbook: ${n.errors.join(`; `)}`);s={doc:Ve(t,n.cookbook),applied:null}}else s={doc:Ve(t,de()),applied:null};let u=new Map,d=[],m=0,h=new Map;function g(e,n){let{doc:r}=e,i=f(t,r.models),a=new Map(t.recipes.map(e=>[e.id,e])),o=Ae(t,r),s=new Set(i.models.filter(e=>e.exposed!==!1).map(e=>e.id));return{version:1,revision:n,app:{name:r.name??He(t,e.applied)??`my-app`,description:r.description??null,specs:r.specs??null,cookbook:e.applied},recipes:r.recipes.flatMap(e=>{let t=a.get(e);return t?[{id:e,label:t.label}]:[]}),features:r.features.filter(e=>s.has(e)),...r.models?{customModels:Object.keys(r.models.lists).map(e=>`${r.models.packageName}:${e}`)}:{},unavailable:[...r.recipes.filter(e=>!a.has(e)),...r.features.filter(e=>!s.has(e))],settings:{currency:o.currency,taxRate:Number((o.taxRate*100).toFixed(4)),paymentTerms:o.paymentTerms,pricesIncludeTax:o.pricesIncludeTax,taxRounding:o.taxRounding},theme:{text:Fe(r.theme),preset:r.theme?.preset??null,primary:r.theme?.custom?.primary??null,colorScheme:r.theme?.colorScheme??`system`,borderRadius:r.theme?.borderRadius??null,density:r.theme?.density??null,contrast:r.theme?.contrast??null},sections:D(i,r).map(e=>({id:e.id,label:e.label,hidden:e.hidden,items:e.items.map(e=>({id:e.id,label:e.label,icon:e.icon,hidden:e.hidden}))})),policies:r.policies.length,undo:[...d]}}let _=()=>g(s,c);function v(){for(let[e,t]of h)t!==c&&(h.set(e,c),e(_()))}function y(e,t,n){if(e!==void 0)for(l.set(e,{id:e,fingerprint:t,result:A(n)});l.size>a;){let e=l.keys().next().value;if(e===void 0)break;l.delete(e)}}function ee(e,t){if(e===void 0)return null;let n=l.get(e);return n?n.fingerprint===t?{...A(n.result),replayed:!0}:{ok:!1,id:e,error:z(`id_reuse`,`The id "${e}" was already used for a different command.`,{path:`id`})}:null}function te(t,n){let r=`${e.undoPrefix??`undo`}-${++m}`;u.set(r,{before:A(t),after:A(n)}),d=[...d,r].slice(-o);for(let e of[...u.keys()])d.includes(e)||u.delete(e);return r}let b=(e,t)=>e.applied!==t.applied||!ue(e.doc,t.doc);function x(e,t,n,r,i,a,o){return{ok:!0,...e===void 0?{}:{id:e},snapshot:a,receipt:{name:t,...e===void 0?{}:{id:e},summary:i===r?``:n.summary,changed:i!==r,revisionBefore:r,revisionAfter:i,...o?{undoId:o}:{},...n.changes?{changes:n.changes}:{},...n.warnings?{warnings:n.warnings}:{}},...n.data===void 0?{}:{data:n.data}}}function ne(e,t){let n=u.get(t.undoId);if(!n)return{ok:!1,...e===void 0?{}:{id:e},error:z(`not_found`,`Nothing to undo for "${t.undoId}".`,{path:`input.undoId`})};if(!t.force&&b(s,n.after))return{ok:!1,...e===void 0?{}:{id:e},error:z(`conflict`,`The plan changed since; send force: true to undo anyway.`,{details:{currentRevision:c}})};let r=c,i=A(n.before),a=b(s,i);s=i,a&&(c+=1),u.delete(t.undoId),d=d.filter(e=>e!==t.undoId);let o=x(e,`undo`,{ok:!0,state:s,summary:`Undone.`},r,c,_());return v(),o}function S(e,r={}){try{let i=e&&typeof e==`object`&&!Array.isArray(e)?e:void 0,a=i?.id,o=ot(a);if(o)return{ok:!1,error:o};let l=i?.expectedRevision??r.expectedRevision,u=st(l);if(u)return{ok:!1,...a===void 0?{}:{id:a},error:u};let d=it({name:i?.name,input:i?.input??{},expectedRevision:l}),f=ee(a,d);if(f)return f;let p=e=>(y(a,d,e),e),m=e=>({ok:!1,...a===void 0?{}:{id:a},error:e}),h=at(e,n,[`id`,`expectedRevision`]);if(!h.ok)return p(m(h.error));if(l!==void 0&&l!==c)return p(m(z(`conflict`,`The plan is at revision ${c}, not ${l}. Read the snapshot and try again.`,{details:{expectedRevision:l,currentRevision:c}})));if(h.name===`undo`)return p(ne(a,h.input));let g=s,S=Ye(t,g,h.name,h.input);if(!S.ok)return p(m(S.error));let C=c,w=b(g,S.state),T;w&&(s=S.state,c+=1,T=te(g,S.state));let re=p(x(a,h.name,S,C,c,_(),T));return v(),re}catch(e){return{ok:!1,error:z(`failed`,e instanceof Error?e.message:String(e))}}}function C(e){let r=(e,t)=>({ok:!1,...t===void 0?{}:{id:t},error:e,snapshot:_()});try{if(!e||typeof e!=`object`||Array.isArray(e))return r(z(`invalid_input`,`A batch is an object: { commands }.`));let i=e,a=i.id,o=ot(a);if(o)return r(o);let l=st(i.expectedRevision);if(l)return r(l,a);let u=it({commands:i.commands,expectedRevision:i.expectedRevision}),d=ee(a,u);if(d)return`results`in d||`snapshot`in d?d:r(d.error,a);let f=e=>(y(a,u,e),e),p=i.commands;if(!Array.isArray(p)||p.length===0||p.length>50)return f(r(z(`invalid_input`,`commands must be a list of 1 to 50 commands.`,{path:`commands`}),a));let m=i.expectedRevision;if(m!==void 0&&m!==c)return f(r(z(`conflict`,`The plan is at revision ${c}, not ${m}. Read the snapshot and try again.`,{details:{expectedRevision:m,currentRevision:c}}),a));let h=(e,t,n)=>f(r(z(`batch_failed`,`Command ${e+1} (${String(t)}) failed: ${n.message}`,{path:`commands[${e}]`,details:{index:e,cause:n}}),a)),ne=s,S=c,C=ne,w=S,T=[];for(let[e,r]of p.entries()){let i=at(r,n,[]);if(!i.ok)return h(e,r?.name,i.error);if(i.name===`undo`)return h(e,`undo`,z(`invalid_input`,`undo cannot run inside a batch.`));let a=Ye(t,C,i.name,i.input);if(!a.ok)return h(e,i.name,a.error);let o=w;b(C,a.state)&&(w+=1),C=a.state,T.push(x(void 0,i.name,a,o,w,g(C,w)))}let re=w!==S,E;if(re){s=C,c=w,E=te(ne,C);for(let e of T)e.receipt.changed&&delete e.receipt.undoId}let D=f({ok:!0,...a===void 0?{}:{id:a},snapshot:_(),receipt:{...a===void 0?{}:{id:a},count:T.length,changed:re,revisionBefore:S,revisionAfter:w,...E?{undoId:E}:{}},results:T});return v(),D}catch(e){return r(z(`failed`,e instanceof Error?e.message:String(e)))}}return{run:S,batch:C,snapshot:_,cookbook:()=>A(s.doc),state:()=>({version:1,revision:c,applied:s.applied,cookbook:A(s.doc),journal:[...l.values()].map(e=>A(e))}),subscribe(e){return h.set(e,c),e(_()),()=>{h.delete(e)}},tools:r,batchTool:i}}var lt=new Set(`AED AFN ALL AMD ANG AOA ARS AUD AWG AZN BAM BBD BDT BGN BHD BIF BMD BND BOB BRL BSD BTN BWP BYN BZD CAD CDF CHF CLP CNY COP CRC CUP CVE CZK DJF DKK DOP DZD EGP ERN ETB EUR FJD FKP GBP GEL GHS GIP GMD GNF GTQ GYD HKD HNL HTG HUF IDR ILS INR IQD IRR ISK JMD JOD JPY KES KGS KHR KMF KPW KRW KWD KYD KZT LAK LBP LKR LRD LSL LYD MAD MDL MGA MKD MMK MNT MOP MRU MUR MVR MWK MXN MYR MZN NAD NGN NIO NOK NPR NZD OMR PAB PEN PGK PHP PKR PLN PYG QAR RON RSD RUB RWF SAR SBD SCR SDG SEK SGD SHP SLE SOS SRD SSP STN SYP SZL THB TJS TMT TND TOP TRY TTD TWD TZS UAH UGX USD UYU UZS VES VND VUV WST XAF XCD XOF XPF YER ZAR ZMW ZWG`.split(` `));function ut(){let e=l.packages.flatMap(e=>e.models.map(t=>({id:t.id,name:t.name,packageId:e.id,...t.description?{description:t.description}:{},exposed:t.exposed,fields:t.fields.map(e=>({name:e.name,...e.system?{system:!0}:{},...e.default===void 0?{}:{default:e.default}}))})));return{recipes:v,models:e,cookbooks:b.map(e=>({id:e.id,name:e.name,document:e.document})),themePresets:h,currencies:[...lt],settingTargets:te}}var dt;function ft(){return dt??=ut(),dt}var pt=[`specs`,`cookbooks`,`recipes`,`features`,`layout`,`theme`,`settings`,`export`],mt={name:`focus`,description:`Move the planner's view to a tab and/or a menu section. Navigation only; it changes nothing in the plan.`,inputSchema:{type:`object`,properties:{tab:{enum:[...pt],description:`The tab to open.`},section:{type:`string`,minLength:1,maxLength:200,description:`The id of a menu section, as the plan snapshot's "sections" lists it.`}},additionalProperties:!1}};function ht(e){return[...Ze(e),mt]}function gt(e,t){return ht({...ft(),recipes:e.map(e=>({id:e,label:e,models:[],nav:[],requires:[]})),cookbooks:t.map(e=>({id:e,name:e,document:{}}))})}var _t=gt(v.map(e=>e.id),b.map(e=>e.id));Object.fromEntries(_t.map(e=>[e.name,e.inputSchema])),_t.map(e=>e.name);function vt(e,t,n=`input`){return tt(e,t,n)?.message??null}function yt(e){let t=e;return{get:()=>t,set:e=>{t=e}}}var B=(e,t,n={})=>({code:e,message:t,...n}),V=(e,t)=>({ok:!1,...t===void 0?{}:{id:t},error:e}),H=e=>typeof e==`object`&&!!e&&!Array.isArray(e),bt=new Set([`apply_cookbook`,`import_cookbook`]),xt=e=>e instanceof Error?e.message:String(e);function St(e,t){if(!H(e))return JSON.stringify([t,e??null]);let{overviews:n,...r}=e;return JSON.stringify([t,r])}function Ct(e){let{catalog:t,port:n,options:r={},env:i={}}=e,a=i.section??yt(null),o=i.tab??yt(null),s=ht(t),c=e=>s.find(t=>t.name===e)?.inputSchema,l=c(`focus`),u=c(`undo`),d,f=``,p=null,m=new Map,h=new Map,g=0,_=new Map,v=()=>n?.applied?.()??null,y=()=>r.navigation?.getTab()??o.get();function ee(){if(!n?.read){d=ct(e.cookbook===void 0?{catalog:t}:{catalog:t,state:{version:1,revision:0,applied:null,cookbook:e.cookbook,journal:[]}});return}let r=n.read();f=St(r,v());try{d=ct({catalog:t,state:{version:1,revision:0,applied:v(),cookbook:r,journal:[]}})}catch(e){d=ct({catalog:t}),p=xt(e)}}ee();function te(e,n){let r=d.state();try{d=ct({catalog:t,state:{version:1,revision:r.revision+1,applied:v(),cookbook:e,journal:r.journal}}),p=null}catch(e){p=xt(e)}m=new Map,h=new Map,f=n}function b(){if(n?.read)try{let e=n.read(),t=St(e,v());if(t===f)return;te(e,t)}catch(e){p=xt(e)}}let x=()=>B(`failed`,`The app's document is not one the planner can read (${p}). Fix it or reset the cookbook, then try again.`),ne=e=>V(x(),e);function S(e){if(!e)return;let t=m.get(e);return t||(t=`undo-${++g}`,m.set(e,t),h.set(t,e)),t}function C(e){let t=new Set(e);for(let[e,n]of m)t.has(e)||(m.delete(e),h.delete(n))}let w=e=>({...e,undo:e.undo.map(e=>S(e)),focus:{tab:y(),section:a.get()}});function T(){let e=d.snapshot();return C(e.undo),w(e)}function re(e){if(!n?.read)return e;try{let t=n.read(),r=H(t)?t.overviews:void 0,{overviews:i,...a}=e;return pe(H(r)&&Object.keys(r).length?{...a,overviews:r}:a)}catch{return e}}function E(e){if(!e.ok)return e;let{receipt:t}=e,n=e.replayed?void 0:S(t.undoId),{undoId:r,...i}=t,a=e.data;if(t.name===`export_cookbook`&&H(a)&&!e.replayed){let e=re(a.cookbook);a={...a,cookbook:e,text:`${JSON.stringify(e,null,2)}\n`}}return{...e,...a===void 0?{}:{data:a},snapshot:T(),receipt:{...i,...n?{undoId:n}:{}}}}function D(e,t){if(!n?.write)return;let i=d.snapshot().app.cookbook,a=e.includes(`apply_cookbook`)||i!==null&&i!==t;n.write(d.cookbook(),{commands:e,replaced:e.some(e=>bt.has(e)),applied:i,libraryApplied:a}),n.read&&(f=St(n.read(),v())),a&&r.onReplaced?.()}function O(){if(!_.size)return;b();let e=T(),t=JSON.stringify(e);for(let[n,r]of _)r!==t&&(_.set(n,t),n(e))}function ie(e,t){for(let t of Object.keys(e))if(![`name`,`input`,`id`,`expectedRevision`].includes(t))return B(`invalid_input`,`${t} is not part of a command.`,{path:t});let{id:n}=e;if(n!==void 0&&!(typeof n==`string`&&n.length>0&&n.length<=200))return B(`invalid_input`,`id must be a non-empty string of at most 200 characters.`,{path:`id`});let r=e.expectedRevision??t.expectedRevision;return r!==void 0&&!(Number.isInteger(r)&&r>=0)?B(`invalid_input`,`expectedRevision must be a whole number.`,{path:`expectedRevision`}):null}function ae(e,t){let n=ie(e,t),i=typeof e.id==`string`?e.id:void 0;if(n)return V(n,i);let s=e.expectedRevision??t.expectedRevision,c=e.input??{},u=vt(l,c);if(u)return V(B(`invalid_input`,u,{path:`input`}),i);let f=d.snapshot().revision;if(s!==void 0&&s!==f)return V(B(`conflict`,`The plan is at revision ${f}, not ${s}. Read the snapshot and try again.`,{details:{expectedRevision:s,currentRevision:f}}),i);if(c.section!==void 0&&!T().sections.some(e=>e.id===c.section))return V(B(`not_found`,`No menu section "${c.section}".`,{path:`input.section`}),i);let p=!1;c.tab&&pt.includes(c.tab)&&(p||=y()!==c.tab,o.set(c.tab),r.navigation?.setTab(c.tab)),c.section!==void 0&&(p||=a.get()!==c.section,a.set(c.section),r.navigation?.setSection?.(c.section));let m={ok:!0,...i===void 0?{}:{id:i},snapshot:T(),receipt:{name:`focus`,...i===void 0?{}:{id:i},summary:``,changed:p,revisionBefore:f,revisionAfter:f}};return O(),m}function oe(e){let t=e.input;if(!n?.prepareImport||!H(t))return{raw:e};let r=n.prepareImport(t.document);return r.ok?{raw:{...e,input:{...t,document:r.cookbook}},dropped:r.dropped}:V(B(`invalid_input`,r.error,{path:`input.document`}),e.id)}function se(e){if(n?.read&&e.some(e=>typeof e==`string`&&bt.has(e)))try{let e=n.read();if(fe(d.cookbook())&&!fe(e)){let n=d.state();d=ct({catalog:t,state:{version:1,revision:n.revision,applied:v(),cookbook:e,journal:n.journal}}),m=new Map,h=new Map,f=St(e,v())}}catch(e){p=xt(e)}}function ce(e,t={}){try{if(b(),p)return ne(H(e)&&typeof e.id==`string`?e.id:void 0);if(!H(e))return E(d.run(e,t));if(e.name===`focus`)return ae(e,t);if(se([e.name]),p)return ne(typeof e.id==`string`?e.id:void 0);let n=e,r;if(e.name===`import_cookbook`){let t=oe(e);if(`ok`in t)return t;n=t.raw,r=t.dropped}let i=d.snapshot().app.cookbook,a=k(n),o=a?le(n,t,a):E(d.run(n,t));if(!o.ok)return o;!o.replayed&&o.receipt.changed&&D([String(n.name)],i);let s=o;return r?.length&&(s={...o,receipt:{...o.receipt,warnings:[...o.receipt.warnings??[],...r.map(e=>`Not imported: ${e}`)]}}),O(),s.ok?{...s,snapshot:T()}:s}catch(e){return V(B(`failed`,xt(e)))}}function k(e){let n=e.input;if(e.name!==`apply_cookbook`||!H(n))return;let r=t.cookbooks?.find(e=>e.id===n.id);if(!r)return;let i=d.cookbook().theme;if(!i)return;let a=r.document.theme;if(a)return a.colorScheme||!i.colorScheme?void 0:{colorScheme:i.colorScheme};let o={};return i.preset&&(o.preset=i.preset),i.custom?.primary&&(o.primary=i.custom.primary),i.colorScheme&&(o.colorScheme=i.colorScheme),i.borderRadius&&(o.borderRadius=i.borderRadius),i.density&&(o.density=i.density),i.contrast&&(o.contrast=i.contrast),Object.keys(o).length?o:void 0}function le(e,t,n){let r=d.batch({...e.id===void 0?{}:{id:e.id},expectedRevision:e.expectedRevision??t.expectedRevision,commands:[e,{name:`set_theme`,input:n}].map(({id:e,expectedRevision:t,...n})=>n)});if(!r.ok){let t=r.error.details?.cause;return V(r.error.code===`batch_failed`&&t?t:r.error,e.id)}let i=r.results[0],a=r.replayed?void 0:S(r.receipt.undoId);return{...i,...r.id===void 0?{}:{id:r.id},...r.replayed?{replayed:!0}:{},snapshot:T(),receipt:{...i.receipt,...r.id===void 0?{}:{id:r.id},revisionBefore:r.receipt.revisionBefore,revisionAfter:r.receipt.revisionAfter,changed:r.receipt.changed,...a?{undoId:a}:{}}}}function A(e){try{if(b(),p)return{ok:!1,error:x(),snapshot:T()};let t=H(e)&&Array.isArray(e.commands)?e.commands:[];if(se(t.map(e=>H(e)?e.name:void 0)),p)return{ok:!1,error:x(),snapshot:T()};let n=d.snapshot().app.cookbook,r=d.batch(e);if(!r.ok)return{...r,snapshot:T()};!r.replayed&&r.receipt.changed&&D(t.map(e=>String(e?.name)),n);let i=r.replayed?void 0:S(r.receipt.undoId),{undoId:a,...o}=r.receipt,s=T(),c={...r,snapshot:s,receipt:{...o,...i?{undoId:i}:{}},results:r.results.map(e=>({...e,snapshot:r.replayed?s:w(e.snapshot)}))};return O(),c}catch(e){return{ok:!1,error:B(`failed`,xt(e)),snapshot:T()}}}function ue(e){if(!H(e)||e.name!==`undo`||!H(e.input))return e;let t=e.input.undoId;return typeof t==`string`?{...e,input:{...e.input,undoId:h.get(t)??``}}:e}function de(e,t){if(e.ok||e.error.code!==`not_found`)return e;let n=h.get(t);return n?{...e,error:{...e.error,message:e.error.message.replace(`"${n}"`,`"${t}"`)}}:e}let j=(e,t)=>{if(H(e)&&e.name===`undo`&&H(e.input)){let n=e.input.undoId;if(typeof n==`string`&&vt(u,e.input)===null)return b(),T(),h.has(n)?de(ce(ue(e),t),n):V(B(`not_found`,`Nothing to undo for "${n}".`,{path:`input.undoId`}),e.id)}return ce(ue(e),t)};return{resetWorkspace(){b();let e=d.state().revision+1;d=ct({catalog:t,state:{version:1,revision:e,applied:v(),cookbook:n?.read?.()??d.cookbook(),journal:[]}}),m.clear(),h.clear(),p=null,f=St(n?.read?.()??d.cookbook(),v()),O()},run:j,batch:A,snapshot(){return b(),T()},cookbook(){return b(),re(d.cookbook())},undo(){b();let e=T().undo.at(-1);return e?j({name:`undo`,input:{undoId:e}}):V(B(`not_found`,`Nothing to undo.`))},state:()=>d.state(),get tools(){return s},get batchTool(){return d.batchTool},observe(){return b(),JSON.stringify(T())},deliver:O,subscribe(e){i.watch?.start(),b();let t=T();return _.set(e,JSON.stringify(t)),e(t),()=>{_.delete(e),_.size||i.watch?.stop()}}}}function wt(e){return e.recipes.length===0&&e.features.length===0&&e.policies.length===0&&Object.keys(e.exposure??{}).length===0&&e.theme===void 0&&u(e.layout)}function Tt(e){if(!e.theme?.colorScheme)return e;let{colorScheme:t,...n}=e.theme;return{...e,theme:Object.keys(n).length?n:void 0}}function Et(e){return JSON.stringify(Tt(e))}function Dt(e,t){let n=Tt(e);return wt(n)?!1:t===null||JSON.stringify(n)!==t}function Ot(e,t,n){return t(n?y(structuredClone(e.document),n):e.document)}var kt=`smrt-planner:cookbook`,At=`smrt-planner:cookbook-applied`,jt=new class{appliedListeners=new Set;onApplied(e){return this.appliedListeners.add(e),()=>this.appliedListeners.delete(e)}#e=t(null);get active(){return e(this.#e)}set active(e){o(this.#e,e,!0)}#t=t(null);get appliedWork(){return e(this.#t)}set appliedWork(e){o(this.#t,e,!0)}load(e=c()){try{this.active=e?.getItem(`smrt-planner:cookbook`)??null,this.appliedWork=e?.getItem(`smrt-planner:cookbook-applied`)??null}catch{this.active=null,this.appliedWork=null}s(this.active)}select(e,t=null,n=c()){this.active=e,this.appliedWork=t;for(let e of this.appliedListeners)e();try{n?.setItem(kt,e),t===null?n?.removeItem(At):n?.setItem(At,t)}catch{}}};function Mt(n){let i=t(r(n));return{get:()=>e(i),set:e=>{o(i,e,!0)}}}function Nt(e){return{read:()=>e.snapshot(),applied:()=>jt.active,prepareImport:e=>_(e),write(t,{replaced:n,applied:r,libraryApplied:i}){let a=n?t:{...t,overviews:e.snapshot().overviews};n?e.replace(a):e.apply(a),i&&r&&(jt.select(r,Et(e.snapshot())),s(r))}}}function Pt(e=g,t={}){let r,o=Ct({catalog:ft(),port:Nt(e),options:t,env:{section:Mt(null),tab:Mt(null),watch:{start(){r||=a(()=>{n(()=>{o.observe(),i(o.deliver)})})},stop(){r?.(),r=void 0}}}});return o}var Ft=()=>({$schema:m,version:1,recipes:[],features:[],policies:[]});function It(e){let{store:t,settings:n,theme:r}=e;return{read(){let e={...Ft(),recipes:[...t.ids].sort()};n&&(e=y(e,n.read()));let i=r?.read();return i?{...e,theme:i}:e},write(e){let i=new Set(e.recipes),a=new Set(t.ids),o=[...a].filter(e=>!i.has(e));o.length&&t.remove(...o);let s=[...i].filter(e=>!a.has(e));s.length&&t.add(...s),n&&n.write(ee(e)),r?.write(e.theme)}}}function Lt(e,t={}){return Ct({catalog:ft(),port:It(e),options:t})}var Rt=[`specs`,`cookbooks`,`recipes`,`features`,`layout`,`theme`,`settings`,`export`];function zt(e,t=`cookbooks`){let n=new URLSearchParams(e).get(`tab`);return Rt.find(e=>e===n)??t}var Bt=new class{#e=t(`cookbooks`);get active(){return e(this.#e)}set active(e){o(this.#e,e,!0)}fromSearch(e,t=`cookbooks`){this.active=zt(e,t)}leaveExport(e=`cookbooks`){this.active===`export`&&(this.active=e)}},Vt={},Ht=Pt(g,{navigation:{getTab:()=>Bt.active,setTab:e=>{Bt.active=e},setSection:e=>Vt.openSection?.(e)},onReplaced:()=>Vt.onReplaced?.()}),Ut=class extends Error{code;category;details;cause;constructor(e,t,n,r,i){super(e),this.name=this.constructor.name,this.code=t,this.category=n,this.details=r,this.cause=i,Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}toJSON(){return{name:this.name,message:this.message,code:this.code,category:this.category,details:this.details,stack:this.stack,cause:this.cause?{name:this.cause.name,message:this.cause.message,stack:this.cause.stack}:void 0}}},U=Object.freeze({maxTitleLength:120,maxDescriptionLength:500,maxDimensions:4,maxMeasures:6,maxFilters:12,maxHaving:4,maxSort:3,maxInValues:100,maxStringValueLength:256,defaultRowLimit:100,maxRowLimit:1e3,maxAliasLength:40,maxFieldNameLength:64,maxSourceIdLength:120}),Wt=[`minute`,`hour`,`day`,`week`,`month`,`quarter`,`year`],Gt=[`count`,`countDistinct`,`sum`,`avg`,`min`,`max`],Kt=[`eq`,`ne`,`gt`,`gte`,`lt`,`lte`,`in`,`notIn`,`contains`,`isNull`,`isNotNull`],qt=[`eq`,`ne`,`gt`,`gte`,`lt`,`lte`],Jt=[`table`,`bar`,`line`,`pie`,`stat`],W=class extends Ut{code;path;status;constructor(e,t,n){super(t?`${t}: ${n}`:n,e,`validation`),this.name=`RuntimeReportError`,this.code=e,this.path=t,this.status=e===`tenant_required`||e===`confirmation_required`?403:e===`invalid_result`?500:422}};function G(e,t){throw new W(`invalid_spec`,e,t)}var Yt=new Set(`all.and.as.asc.between.by.case.cast.check.column.constraint.create.cross.default.delete.desc.distinct.drop.else.end.except.exists.false.for.foreign.from.full.group.having.in.inner.insert.intersect.into.is.join.left.like.limit.natural.not.null.offset.on.or.order.outer.primary.references.right.select.set.table.then.to.true.union.unique.update.user.using.values.when.where.with`.split(`.`)),Xt=/^[a-z][a-z0-9_]*$/,Zt=/^[A-Za-z][A-Za-z0-9_]*$/,Qt=/^[A-Za-z@][A-Za-z0-9_@./:-]*$/;function $t(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&(Object.getPrototypeOf(e)===Object.prototype||Object.getPrototypeOf(e)===null)}function K(e,t,n){$t(e)||G(t,`must be an object`);for(let r of Object.keys(e))n.includes(r)||G(`${t}.${r}`,`is not a known key`);return e}function q(e,t,n,r=0){return e===void 0?[]:(Array.isArray(e)||G(t,`must be an array`),e.length>n&&G(t,`must have at most ${n} entries`),e.length<r&&G(t,`must have at least ${r} entries`),e)}function en(e,t,n,r={}){if(typeof e!=`string`){if(r.optional&&e===void 0)return``;G(t,`must be a string`)}let i=e.trim();return i.length===0&&!r.optional&&G(t,`must not be empty`),i.length>n&&G(t,`must be at most ${n} characters`),/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]/.test(i)&&G(t,`must not contain control characters`),i}function tn(e,t,n){return(typeof e!=`string`||!n.includes(e))&&G(t,`must be one of: ${n.join(`, `)}`),e}function nn(e,t){return typeof e!=`string`&&G(t,`must be a string`),(e.length===0||e.length>U.maxFieldNameLength||!Zt.test(e))&&G(t,`must be a plain field name (letters, digits, underscore)`),e}function J(e,t){return typeof e!=`string`&&G(t,`must be a string`),(e.length===0||e.length>U.maxAliasLength||!Xt.test(e))&&G(t,`must be a lowercase identifier of at most ${U.maxAliasLength} characters (a-z, 0-9, underscore)`),Yt.has(e)&&G(t,`'${e}' is a reserved word`),e}function rn(e,t){return typeof e==`string`?(e.length>U.maxStringValueLength&&G(t,`must be at most ${U.maxStringValueLength} characters`),e.includes(`\0`)&&G(t,`must not contain NUL`),e):typeof e==`number`?(Number.isFinite(e)||G(t,`must be a finite number`),e):typeof e==`boolean`?e:G(t,`must be a string, number or boolean`)}function an(e){return e.replace(/([a-z\d])([A-Z])/g,`$1_$2`).replace(/([A-Z]+)([A-Z][a-z])/g,`$1_$2`).toLowerCase()}function on(e,t){let n=K(e,t,[`field`,`as`,`bucket`]),r=nn(n.field,`${t}.field`),i=n.bucket===void 0?void 0:tn(n.bucket,`${t}.bucket`,Wt);return{field:r,as:n.as===void 0?J(i?`${an(r)}_${i}`:an(r),`${t}.as`):J(n.as,`${t}.as`),...i?{bucket:i}:{}}}function sn(e,t){let n=K(e,t,[`fn`,`field`,`as`]),r=tn(n.fn,`${t}.fn`,Gt),i=n.field===void 0?void 0:nn(n.field,`${t}.field`);!i&&r!==`count`&&G(`${t}.field`,`is required for ${r}`);let a=n.as===void 0?J(i?`${an(r)}_${an(i)}`:`row_count`,`${t}.as`):J(n.as,`${t}.as`);return{fn:r,...i?{field:i}:{},as:a}}function cn(e,t){let n=K(e,t,[`field`,`op`,`value`]),r=nn(n.field,`${t}.field`),i=tn(n.op,`${t}.op`,Kt);if(i===`isNull`||i===`isNotNull`)return n.value!==void 0&&G(`${t}.value`,`must be omitted for ${i}`),{field:r,op:i};if(n.value===void 0&&G(`${t}.value`,`is required for ${i}`),i===`in`||i===`notIn`)return{field:r,op:i,value:q(n.value,`${t}.value`,U.maxInValues,1).map((e,n)=>rn(e,`${t}.value[${n}]`))};Array.isArray(n.value)&&G(`${t}.value`,`must be a scalar for ${i}`);let a=rn(n.value,`${t}.value`);return i===`contains`&&typeof a!=`string`&&G(`${t}.value`,`must be a string for contains`),{field:r,op:i,value:a}}function ln(e,t){let n=K(e,t,[`measure`,`op`,`value`]),r=J(n.measure,`${t}.measure`),i=tn(n.op,`${t}.op`,qt);return(typeof n.value!=`number`||!Number.isFinite(n.value))&&G(`${t}.value`,`must be a finite number`),{measure:r,op:i,value:n.value}}function un(e,t){let n=K(e,t,[`by`,`direction`]);return{by:J(n.by,`${t}.by`),direction:n.direction===void 0?`asc`:tn(n.direction,`${t}.direction`,[`asc`,`desc`])}}function dn(e){let t=e;if(typeof e==`string`){e.length>65536&&G(``,`spec JSON is too large`);try{t=JSON.parse(e)}catch{G(``,`spec is not valid JSON`)}}let n=K(t,`spec`,[`version`,`title`,`description`,`source`,`dimensions`,`measures`,`filters`,`having`,`sort`,`limit`,`chart`]);n.version!==void 0&&n.version!==1&&G(`spec.version`,`unsupported version (expected 1)`);let r=en(n.title,`spec.title`,U.maxTitleLength),i=en(n.description,`spec.description`,U.maxDescriptionLength,{optional:!0});(typeof n.source!=`string`||n.source.length===0||n.source.length>U.maxSourceIdLength||!Qt.test(n.source))&&G(`spec.source`,`must be a source id`);let a=q(n.dimensions,`spec.dimensions`,U.maxDimensions).map((e,t)=>on(e,`spec.dimensions[${t}]`)),o=q(n.measures,`spec.measures`,U.maxMeasures,1).map((e,t)=>sn(e,`spec.measures[${t}]`)),s=q(n.filters,`spec.filters`,U.maxFilters).map((e,t)=>cn(e,`spec.filters[${t}]`)),c=q(n.having,`spec.having`,U.maxHaving).map((e,t)=>ln(e,`spec.having[${t}]`)),l=q(n.sort,`spec.sort`,U.maxSort).map((e,t)=>un(e,`spec.sort[${t}]`)),u=new Set,d=new Set,f=new Set;for(let[e,t]of a.entries())f.has(t.as)&&G(`spec.dimensions[${e}].as`,`duplicate alias '${t.as}'`),f.add(t.as),u.add(t.as);for(let[e,t]of o.entries())f.has(t.as)&&G(`spec.measures[${e}].as`,`duplicate alias '${t.as}'`),f.add(t.as),d.add(t.as);for(let[e,t]of c.entries())d.has(t.measure)||G(`spec.having[${e}].measure`,`must be a declared measure alias`);for(let[e,t]of l.entries())f.has(t.by)||G(`spec.sort[${e}].by`,`must be a declared dimension or measure alias`);let p=U.defaultRowLimit;n.limit!==void 0&&((typeof n.limit!=`number`||!Number.isSafeInteger(n.limit)||n.limit<1||n.limit>U.maxRowLimit)&&G(`spec.limit`,`must be an integer between 1 and ${U.maxRowLimit}`),p=n.limit);let m={type:`table`};if(n.chart!==void 0){let e=K(n.chart,`spec.chart`,[`type`,`x`,`y`]),t=tn(e.type,`spec.chart.type`,Jt),r=e.x===void 0?void 0:J(e.x,`spec.chart.x`);r!==void 0&&!u.has(r)&&G(`spec.chart.x`,`must be a declared dimension alias`);let i=q(e.y,`spec.chart.y`,U.maxMeasures).map((e,t)=>J(e,`spec.chart.y[${t}]`));for(let[e,t]of i.entries())d.has(t)||G(`spec.chart.y[${e}]`,`must be a declared measure alias`);m={type:t,...r?{x:r}:{},...i.length>0?{y:i}:{}}}return{version:1,title:r,...i?{description:i}:{},source:n.source,dimensions:a,measures:o,filters:s,having:c,sort:l,limit:p,chart:m}}function fn(e){return Array.isArray(e)?e.map(fn):$t(e)?Object.fromEntries(Object.keys(e).sort().map(t=>[t,fn(e[t])])):e}function pn(e){return JSON.stringify(fn(e))}async function mn(e){let t=globalThis.crypto?.subtle;if(!t)throw Error(`runtimeReportSpecDigest needs Web Crypto (crypto.subtle), which browsers offer only in a secure context`);let n=new TextEncoder().encode(pn(e)),r=new Uint8Array(await t.digest(`SHA-256`,n));return Array.from(r,e=>e.toString(16).padStart(2,`0`)).join(``)}var hn=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function gn(e){return e.replace(/([a-z\d])([A-Z])/g,`$1 $2`).replace(/[_-]+/g,` `).replace(/^./,e=>e.toUpperCase())}function _n(e,t){throw new W(`unknown_field`,e,`'${t}' is not a field available on this source`)}function vn(e,t){throw new W(`invalid_operation`,e,t)}function Y(e,t){throw new W(`invalid_value`,e,t)}var yn={string:[`eq`,`ne`,`gt`,`gte`,`lt`,`lte`,`in`,`notIn`,`contains`,`isNull`,`isNotNull`],integer:[`eq`,`ne`,`gt`,`gte`,`lt`,`lte`,`in`,`notIn`,`isNull`,`isNotNull`],decimal:[`eq`,`ne`,`gt`,`gte`,`lt`,`lte`,`in`,`notIn`,`isNull`,`isNotNull`],datetime:[`eq`,`ne`,`gt`,`gte`,`lt`,`lte`,`in`,`notIn`,`isNull`,`isNotNull`],boolean:[`eq`,`ne`,`isNull`,`isNotNull`],id:[`eq`,`ne`,`in`,`notIn`,`isNull`,`isNotNull`]};function bn(e){return e===`integer`||e===`decimal`?[`count`,`countDistinct`,`sum`,`avg`,`min`,`max`]:e===`datetime`?[`count`,`countDistinct`,`min`,`max`]:[`count`,`countDistinct`]}function xn(e,t,n){yn[t].includes(e.op)||vn(`${n}.op`,`'${e.op}' is not valid for ${t} fields`)}function Sn(e,t,n){switch(e){case`string`:return typeof t!=`string`&&Y(n,`must be a string`),t;case`integer`:return(typeof t!=`number`||!Number.isSafeInteger(t))&&Y(n,`must be a safe integer`),t;case`decimal`:return(typeof t!=`number`||!Number.isFinite(t))&&Y(n,`must be a finite number`),t;case`boolean`:return typeof t!=`boolean`&&Y(n,`must be true or false`),t;case`datetime`:{typeof t!=`string`&&Y(n,`must be an ISO-8601 string`);let e=new Date(t);return(Number.isNaN(e.getTime())||!/^\d{4}-\d{2}-\d{2}/.test(t))&&Y(n,`must be an ISO-8601 date or timestamp`),e}case`id`:return(typeof t!=`string`||!hn.test(t))&&Y(n,`must be a UUID`),t.toLowerCase()}}function Cn(e,t){let n=n=>{let r=e[n];if(r!==void 0){if(!Array.isArray(r)||Array.from(r).some(e=>typeof e!=`string`||!t.has(e)))throw new W(`unsupported_source`,`source.${n}`,`${n} must contain canonical field names declared on the source`);return new Set(r)}},r=n(`fields`),i=n(`excludeFields`);if(n(`dimensions`),e.timeField!==void 0&&(typeof e.timeField!=`string`||!t.has(e.timeField)))throw new W(`unsupported_source`,`source.timeField`,`timeField must be a canonical field name declared on the source`);return{...r?{included:r}:{},...i?{excluded:i}:{}}}function wn(e,t){return e===`count`||e===`countDistinct`?`integer`:e===`avg`?`decimal`:t?.type??`decimal`}function Tn(e,t){let n=(e,n)=>{let r=t.get(e);return r||_n(n,e),r},r=[];for(let[t,i]of e.dimensions.entries()){let e=`spec.dimensions[${t}]`,a=n(i.field,`${e}.field`);i.bucket&&a.type!==`datetime`&&vn(`${e}.bucket`,`buckets are only valid on datetime fields`),r.push({id:i.as,label:gn(i.as),role:`dimension`,type:i.bucket?`datetime`:a.type,field:a.name,...i.bucket?{bucket:i.bucket}:{},...a.format&&!i.bucket?{format:a.format}:{}})}for(let[t,i]of e.measures.entries()){let e=`spec.measures[${t}]`,a=i.field?n(i.field,`${e}.field`):void 0;(i.fn===`sum`||i.fn===`avg`)&&a?.type!==`integer`&&a?.type!==`decimal`&&vn(`${e}.fn`,`${i.fn} requires a numeric field`),(i.fn===`min`||i.fn===`max`)&&a?.type!==`integer`&&a?.type!==`decimal`&&a?.type!==`datetime`&&vn(`${e}.fn`,`${i.fn} requires a numeric or datetime field`);let o=a?.format&&(i.fn===`sum`||i.fn===`min`||i.fn===`max`||i.fn===`avg`);r.push({id:i.as,label:gn(i.as),role:`measure`,type:wn(i.fn,a),...a?{field:a.name}:{},fn:i.fn,...o?{format:a?.format}:{}})}return r}function En(e,t){if(t==null)return null;if(t instanceof Date)return t.toISOString();if(typeof t==`bigint`){let n=Number(t);if(!Number.isSafeInteger(n))throw new W(`invalid_result`,e.id,`integer result exceeds the JavaScript safe range`);return n}if(e.type===`boolean`){if(t===1||t===`1`||t===`true`||t===!0)return!0;if(t===0||t===`0`||t===`false`||t===!1)return!1}if(e.type===`integer`||e.type===`decimal`){let n=typeof t==`number`?t:Number(t);if(!Number.isFinite(n))throw new W(`invalid_result`,e.id,`numeric result is not finite`);if(e.type===`integer`&&!Number.isSafeInteger(n))throw new W(`invalid_result`,e.id,`integer result exceeds the JavaScript safe range`);return n}return typeof t==`string`||typeof t==`number`||typeof t==`boolean`?t:String(t)}var Dn=/^(?:id|_.*)$|(?:Hash|Json|Token|Secret|Signature|Authority|Snapshot|Checksum|Cursor|Etag)$|^(?:external|historical)[A-Z]/,On=/^(?:created|updated|deleted|synced|archived)At$|^last[A-Z]\w*At$/,kn=/^(?:status|state)$|(?:Status|State)$/,An=/^(?:kind|type|category|method|channel|stage|priority|segment|tier|source)$|(?:Kind|Type|Category|Method|Channel|Stage|Priority|Segment|Tier)$/,jn=/^(?:customer|vendor|supplier|client|member|employee|owner|assignee|product|location|project|account|contact)Id$/,Mn=50;function Nn(e){if(e.type===`datetime`)return e.name===`deletedAt`?void 0:`time`;if(!Dn.test(e.name)){if(e.type===`boolean`||e.type===`string`&&e.enum&&e.enum.length>0&&e.enum.length<=Mn)return`category`;if(e.type===`id`&&/Id$/.test(e.name))return`relation`}}function Pn(e){return e.type===`boolean`?10:e.type===`id`?jn.test(e.name)?70:30:kn.test(e.name)?100:An.test(e.name)?80:50}function Fn(e,t={}){let n=[...e.values()],r=new Map;for(let e of n){let t=Nn(e);t&&r.set(e.name,t)}let i=n.filter(e=>r.get(e.name)===`time`),a=(t.timeField&&e.get(t.timeField)?.type===`datetime`?t.timeField:void 0)??i.find(e=>e.businessDate)?.name??i.find(e=>!On.test(e.name))?.name??i.find(e=>e.name===`createdAt`)?.name??i[0]?.name,o=[...a?[a]:[],...i.map(e=>e.name).filter(e=>e!==a)],s;if(t.dimensions){s=t.dimensions.filter(t=>e.has(t)&&e.get(t)?.type!==`datetime`);for(let t of s)r.has(t)||r.set(t,e.get(t)?.type===`id`?`relation`:`category`);for(let[e,t]of[...r])t!==`time`&&!s.includes(e)&&r.delete(e)}else s=n.filter(e=>{let t=r.get(e.name);return t===`category`||t===`relation`}).map((e,t)=>({field:e,index:t})).sort((e,t)=>Pn(t.field)-Pn(e.field)||e.index-t.index).map(({field:e})=>e.name);return{kinds:r,timeFields:o,...a?{defaultTimeField:a}:{},dimensions:s}}function In(e,t={}){let n=Fn(e,t);return{fields:[...e.values()].map(e=>{let t=n.kinds.get(e.name);return{name:e.name,label:e.label,type:e.type,...e.format?{format:e.format}:{},...e.enum?{enum:e.enum}:{},...t?{dimension:t}:{},filterOperators:yn[e.type],aggregates:bn(e.type)}}),timeFields:n.timeFields,...n.defaultTimeField?{defaultTimeField:n.defaultTimeField}:{},dimensions:n.dimensions}}var Ln=new Set([`tenantId`,`tenant_id`]);function Rn(e,t){let n=e.find(e=>e.id===t);if(!n)throw new W(`unknown_source`,`spec.source`,`'${t}' is not an available report source`);return n}function zn(e){let{included:t,excluded:n}=Cn(e,new Set(e.schema.map(e=>e.name))),r=new Map;for(let i of e.schema)i.name.startsWith(`_`)||Ln.has(i.name)||n?.has(i.name)||t&&!t.has(i.name)||r.has(i.name)||r.set(i.name,{name:i.name,type:i.type,...i.format?{format:i.format}:{},...i.type===`string`&&i.enum?.length?{enum:i.enum}:{},...i.type===`datetime`&&i.format===`date`?{businessDate:!0}:{},label:i.label??gn(i.name)});return r}function Bn(e,t){let n=Rn(e,t);return{id:n.id,label:n.label??gn(n.id),...n.description?{description:n.description}:{},...In(zn(n),n)}}function Vn(e){if(e instanceof Date)return Number.isNaN(e.getTime())?null:e;if(typeof e==`string`||typeof e==`number`){let t=new Date(e);return Number.isNaN(t.getTime())?null:t}return null}function Hn(e,t){let n=e[t.name];if(n==null)return null;switch(t.type){case`integer`:case`decimal`:{if(typeof n==`bigint`){if(n>BigInt(2**53-1)||n<BigInt(-(2**53-1)))throw new W(`invalid_result`,t.name,`integer value exceeds the JavaScript safe range`);return Number(n)}let e=typeof n==`number`?n:typeof n==`string`&&n.trim()!==``?Number(n):NaN;return Number.isFinite(e)?e:null}case`boolean`:return n===!0||n===1||n===`1`||n===`true`?!0:n===!1||n===0||n===`0`||n===`false`?!1:null;case`datetime`:return Vn(n);default:return typeof n==`string`?n:String(n)}}function Un(e,t){let n=e instanceof Date?e.getTime():e,r=t instanceof Date?t.getTime():t;return typeof n==`boolean`||typeof r==`boolean`?Number(n)-Number(r):n<r?-1:+(n>r)}function Wn(e,t,n){xn(e,t.type,n);let r=e=>Hn(e,t);switch(e.op){case`isNull`:return e=>r(e)===null;case`isNotNull`:return e=>r(e)!==null;case`in`:case`notIn`:{let i=e.value.map((e,r)=>Sn(t.type,e,`${n}.value[${r}]`)),a=e=>i.some(t=>Un(e,t)===0);return e.op===`in`?e=>{let t=r(e);return t!==null&&a(t)}:e=>{let t=r(e);return t!==null&&!a(t)}}case`contains`:{let i=Sn(t.type,e.value,`${n}.value`);return e=>{let t=r(e);return typeof t==`string`&&t.includes(i)}}default:{let i=Sn(t.type,e.value,`${n}.value`),a={eq:e=>e===0,ne:e=>e!==0,gt:e=>e>0,gte:e=>e>=0,lt:e=>e<0,lte:e=>e<=0}[e.op];return e=>{let t=r(e);return t!==null&&a(Un(t,i))}}}}function Gn(e,t){let n=e.getUTCFullYear(),r=e.getUTCMonth(),i=e.getUTCDate();switch(t){case`minute`:return new Date(Date.UTC(n,r,i,e.getUTCHours(),e.getUTCMinutes()));case`hour`:return new Date(Date.UTC(n,r,i,e.getUTCHours()));case`day`:return new Date(Date.UTC(n,r,i));case`week`:{let t=(e.getUTCDay()+6)%7;return new Date(Date.UTC(n,r,i-t))}case`month`:return new Date(Date.UTC(n,r,1));case`quarter`:return new Date(Date.UTC(n,Math.floor(r/3)*3,1));case`year`:return new Date(Date.UTC(n,0,1))}}function Kn(e){return e===null?`n`:e instanceof Date?`d${e.getTime()}`:`${typeof e}:${String(e)}`}function qn(e,t,n){if(t===null)return n;let r=t.filter(e=>e!==null);switch(e){case`count`:return r.length;case`countDistinct`:return new Set(r.map(Kn)).size;case`sum`:return r.length===0?null:r.reduce((e,t)=>e+t,0);case`avg`:return r.length===0?null:r.reduce((e,t)=>e+t,0)/r.length;case`min`:case`max`:{if(r.length===0)return null;let t=r[0];for(let n of r.slice(1)){let r=Un(n,t);(e===`min`?r<0:r>0)&&(t=n)}return t}default:return null}}function Jn(e,t){if(typeof t!=`number`)return!1;switch(e.op){case`eq`:return t===e.value;case`ne`:return t!==e.value;case`gt`:return t>e.value;case`gte`:return t>=e.value;case`lt`:return t<e.value;case`lte`:return t<=e.value}}function Yn(e,t,n){let r;return r=e===null&&t===null?0:e===null?-1:t===null?1:Un(e,t),n===`desc`?-r:r}async function Xn(e,t,n){let r=dn(e),i=Rn(n.sources,r.source),a=zn(i),o=Tn(r,a),s=(e,t)=>{let n=a.get(e);return n||_n(t,e),n},c=[];i.schema.some(e=>e.name===`deletedAt`)&&c.push(e=>e.deletedAt===null||e.deletedAt===void 0);for(let[e,t]of r.filters.entries()){let n=`spec.filters[${e}]`;c.push(Wn(t,s(t.field,`${n}.field`),n))}let l=t.filter(e=>c.every(t=>t(e))),u=r.dimensions.map(e=>{let t=a.get(e.field);return n=>{let r=Hn(n,t);return e.bucket&&r instanceof Date?Gn(r,e.bucket):r}}),d=new Map;if(r.dimensions.length===0)d.set(``,{key:[],rows:l});else for(let e of l){let t=u.map(t=>t(e)),n=JSON.stringify(t.map(Kn)),r=d.get(n);r?r.rows.push(e):d.set(n,{key:t,rows:[e]})}let f=r.measures.map(e=>e.field?a.get(e.field):null),p=[...d.values()].map(e=>{let t={};return r.dimensions.forEach((n,r)=>{t[n.as]=e.key[r]}),r.measures.forEach((n,r)=>{let i=f[r];t[n.as]=qn(n.fn,i?e.rows.map(e=>Hn(e,i)):null,e.rows.length)}),t});r.having.length>0&&(p=p.filter(e=>r.having.every(t=>Jn(t,e[t.measure]))));let m=r.sort.length>0?r.sort:r.dimensions.length>0?[{by:r.dimensions[0].as,direction:`asc`}]:[];m.length>0&&(p=p.map((e,t)=>({values:e,index:t})).sort((e,t)=>{for(let n of m){let r=Yn(e.values[n.by],t.values[n.by],n.direction);if(r!==0)return r}return e.index-t.index}).map(({values:e})=>e));let h=Math.min(r.limit,n.maxRows??U.maxRowLimit),g=p.length>h,_=p.slice(0,h).map(e=>{let t={};for(let n of o)t[n.id]=En(n,e[n.id]);return t});return{version:1,specHash:await mn(r),title:r.title,columns:o,rows:_,rowCount:_.length,truncated:g,ranAt:(n.now?.()??new Date).toISOString(),chart:r.chart}}var X=864e5,Zn=e=>new Date(e).toISOString().slice(0,10),Qn=[`january`,`february`,`march`,`april`,`may`,`june`,`july`,`august`,`september`,`october`,`november`,`december`],$n={first:1,second:2,third:3,fourth:4},er=[[`minute`,/\b(?:minutely|(?:per|by|each|every|a) minute|minute by minute)\b/],[`hour`,/\b(?:hourly|(?:per|by|each|every|an?) hour|hour by hour)\b/],[`day`,/\b(?:daily|(?:per|by|each|every|a) day|day by day)\b/],[`week`,/\b(?:weekly|(?:per|by|each|every|a) week|week by week|week over week)\b/],[`month`,/\b(?:monthly|(?:per|by|each|every|a) month|month by month|month over month)\b/],[`quarter`,/\b(?:quarterly|(?:per|by|each|every|a) quarter|quarter by quarter|quarter over quarter)\b/],[`year`,/\b(?:yearly|annually|annual|(?:per|by|each|every|a) year|year by year|year over year)\b/]],tr=/\b(?:over time|trends?|trending|timeline|history)\b/;function nr(e){return e===null?`month`:e<=31?`day`:e<=92?`week`:e<=1098?`month`:`quarter`}function rr(e){return Math.round((Date.parse(`${e.to}T00:00:00Z`)-Date.parse(`${e.from}T00:00:00Z`))/X)}function ir(e,t){let n=e.toLowerCase().replace(/[_-]+/g,` `).replace(/\s+/g,` `),r=t.getUTCFullYear(),i=t.getUTCMonth(),a=Date.UTC(r,i,t.getUTCDate()),o=a+X,s=a-(t.getUTCDay()+6)%7*X,c=Math.floor(i/3)*3,l=(e,t,n)=>({from:Zn(e),to:Zn(t),label:n}),u=/\b(?:last|past|previous|trailing)\s+(\d{1,4})\s+(day|week|month|year)s?\b/.exec(n);if(u){let e=Number(u[1]),n=u[2];if(e>0)return l(n===`day`?o-e*X:n===`week`?o-e*7*X:n===`month`?Date.UTC(r,i-e,t.getUTCDate()+1):Date.UTC(r-e,i,t.getUTCDate()+1),o,`last ${e} ${n}${e===1?``:`s`}`)}let d=/\bq([1-4])(?:\s*(?:of\s*)?((?:19|20)\d{2}))?\b/.exec(n)??/\b(first|second|third|fourth) quarter(?: (?:of )?((?:19|20)\d{2}))?\b/.exec(n);if(d){let e=/^\d$/.test(d[1])?Number(d[1]):$n[d[1]],t=(e-1)*3,n=d[2]?Number(d[2]):Date.UTC(r,t,1)<=a?r:r-1;return l(Date.UTC(n,t,1),Date.UTC(n,t+3,1),`Q${e} ${n}`)}if(/\b(?:year to date|ytd)\b/.test(n))return l(Date.UTC(r,0,1),o,`year to date`);if(/\b(?:month to date|mtd)\b/.test(n))return l(Date.UTC(r,i,1),o,`month to date`);if(/\btoday\b/.test(n))return l(a,o,`today`);if(/\byesterday\b/.test(n))return l(a-X,a,`yesterday`);let f=/\b(this|current|last|previous|past) (week|month|quarter|year)\b/.exec(n);if(f){let e=f[1]!==`this`&&f[1]!==`current`,t=f[2],n=`${e?`last`:`this`} ${t}`;switch(t){case`week`:return e?l(s-7*X,s,n):l(s,s+7*X,n);case`month`:return e?l(Date.UTC(r,i-1,1),Date.UTC(r,i,1),n):l(Date.UTC(r,i,1),Date.UTC(r,i+1,1),n);case`quarter`:return e?l(Date.UTC(r,c-3,1),Date.UTC(r,c,1),n):l(Date.UTC(r,c,1),Date.UTC(r,c+3,1),n);default:return e?l(Date.UTC(r-1,0,1),Date.UTC(r,0,1),n):l(Date.UTC(r,0,1),Date.UTC(r+1,0,1),n)}}let p=RegExp(`\\b(${Qn.join(`|`)})(?: ((?:19|20)\\d{2}))?\\b`).exec(n);if(p&&(p[1]!==`may`||p[2])){let e=p,t=Qn.indexOf(e[1]),n=e[2]?Number(e[2]):Date.UTC(r,t,1)<=a?r:r-1,i=e[1].charAt(0).toUpperCase()+e[1].slice(1);return l(Date.UTC(n,t,1),Date.UTC(n,t+1,1),`${i} ${n}`)}let m=/\b(?:in|for|during)\s+((?:19|20)\d{2})\b/.exec(n)??/^\s*((?:19|20)\d{2})\s*$/.exec(n);if(m){let e=Number(m[1]);return l(Date.UTC(e,0,1),Date.UTC(e+1,0,1),String(e))}return null}function ar(e,t){let n=e.toLowerCase(),r=ir(n,t)??void 0,i=er.find(([,e])=>e.test(n))?.[0],a=tr.test(n);!i&&a&&(i=nr(r?rr(r):null));let o=!!(i||r||a)||/\b(?:date|dates|time|when|minute|hour|day|week|month|quarter|year)s?\b/.test(n);return{...i?{bucket:i}:{},...r?{range:r}:{},mentionsTime:o}}var or=[`today`,`yesterday`,`this_week`,`last_week`,`this_month`,`last_month`,`this_quarter`,`last_quarter`,`this_year`,`last_year`,`all_time`],sr=[`minute`,`hour`,`day`,`week`,`month`,`quarter`,`year`],cr=[`count`,`sum`,`avg`,`min`,`max`],lr=[`eq`,`ne`,`gt`,`gte`,`lt`,`lte`,`contains`],ur=4,dr=3,fr=64,pr=8;function mr(e){let t={type:`string`,maxLength:fr};return{type:[`object`,`null`],properties:{source:e.length?{enum:[...e]}:{type:`string`,maxLength:U.maxSourceIdLength},measures:{type:`array`,maxItems:ur,items:{type:`object`,properties:{fn:{enum:[...cr]},field:t},required:[`fn`],additionalProperties:!1}},groupBy:t,bucket:{enum:[...sr]},period:{enum:[...or]},range:{type:`string`,maxLength:40},dateField:t,filters:{type:`array`,maxItems:dr,items:{type:`object`,properties:{field:t,op:{enum:[...lr]},value:{type:[`string`,`number`,`boolean`]}},required:[`field`,`op`,`value`],additionalProperties:!1}},title:{type:`string`,maxLength:U.maxTitleLength}},required:[`source`],additionalProperties:!1}}var hr=(e,t)=>typeof e==`string`&&t.includes(e)?e:void 0,Z=(e,t=fr)=>typeof e==`string`&&e.trim()&&e.trim().length<=t?e.trim():void 0;function gr(e){if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e,n=Z(t.source,U.maxSourceIdLength);if(!n)return null;let r=e=>t[e]!==void 0&&t[e]!==null,i=Array.isArray(t.unreadable)?t.unreadable.filter(e=>typeof e==`string`&&e.trim().length>0).slice(0,pr).map(e=>e.trim().slice(0,fr)):[];r(`measures`)&&!Array.isArray(t.measures)&&i.push(`the measures`),r(`filters`)&&!Array.isArray(t.filters)&&i.push(`the filters`);let a=Array.isArray(t.measures)?t.measures.slice(0,ur).flatMap(e=>{let t=e&&typeof e==`object`?e:{},n=hr(t.fn,cr);if(!n)return i.push(`a measure`),[];let r=Z(t.field);return[{fn:n,...r?{field:r}:{}}]}):[],o=Array.isArray(t.filters)?t.filters.slice(0,dr).flatMap(e=>{let t=e&&typeof e==`object`?e:{},n=Z(t.field),r=hr(t.op,lr),a=t.value;return!n||!r||!(typeof a==`string`&&a.length<=256||typeof a==`number`&&Number.isFinite(a)||typeof a==`boolean`)?(i.push(n?`the ${n} filter`:`a filter`),[]):[{field:n,op:r,value:a}]}):[];Array.isArray(t.measures)&&t.measures.length>ur&&i.push(`more than ${ur} measures`),Array.isArray(t.filters)&&t.filters.length>dr&&i.push(`more than ${dr} filters`);let s=Z(t.groupBy),c=hr(t.bucket,sr),l=hr(t.period,or),u=Z(t.dateField),d=Z(t.range,40),f=Z(t.title,U.maxTitleLength);return r(`range`)&&!d&&i.push(`the period`),r(`groupBy`)&&!s&&i.push(`the grouping`),r(`bucket`)&&!c&&i.push(`the time grouping`),r(`period`)&&!l&&i.push(`the period`),r(`dateField`)&&!u&&i.push(`the date`),{source:n,...a.length?{measures:a}:{},...s?{groupBy:s}:{},...c?{bucket:c}:{},...l?{period:l}:{},...d?{range:d}:{},...u?{dateField:u}:{},...o.length?{filters:o}:{},...f?{title:f}:{},...i.length?{unreadable:i}:{}}}var _r=e=>e.toLowerCase().replace(/[^a-z0-9]/g,``);function Q(e,t,n=()=>!0){let r=_r(e),i=t.filter(n);return i.find(t=>t.name===e)??i.find(e=>_r(e.name)===r)??i.find(e=>_r(e.label)===r)}function vr(e){let t=e.slice(0,6),n=e.length>t.length?`, …`:``;return t.length<=1?`${t.join(``)}${n}`:`${t.slice(0,-1).join(`, `)}${n} or ${t[t.length-1]}`}var $=e=>({ok:!1,question:e}),yr=e=>e.options.length?{ok:!1,question:e.prompt,followUp:{...e,default:e.options[0].value}}:{ok:!1,question:e.prompt.replace(/…$/,` what?`)},br=8;function xr(e){let t=e=>(e.amountField?2:0)+ +!!e.dateField;return[...e].sort((e,n)=>t(n)-t(e))}function Sr(e){let t=xr(e).slice(0,br);return t.length?{field:`source`,label:`Records`,prompt:`Which records should the report cover?`,options:t.map(e=>({value:e.id,label:e.label,apply:{source:e.id}})),default:t[0].id}:null}function Cr(e){return e.length?`Which records should the report cover?`:`Which records should the report cover? Add a recipe with records first, such as invoicing?`}var wr={minute:`minute`,minutely:`minute`,hour:`hour`,hourly:`hour`,day:`day`,daily:`day`,week:`week`,weekly:`week`,month:`month`,monthly:`month`,quarter:`quarter`,quarterly:`quarter`,year:`year`,yearly:`year`,annual:`year`,annually:`year`},Tr=new Set([`by`,`per`,`the`,`each`,`every`,`a`,`over`,`time`,`date`,`dates`,`in`]);function Er(e){let t=e.replace(/([a-z])([A-Z])/g,`$1 $2`).toLowerCase().split(/[^a-z0-9]+/).filter(Boolean),n,r=!1,i=[];for(let e of t){let t=e.endsWith(`s`)?e.slice(0,-1):e,a=wr[e]??wr[t];a?(n??=a,r=!0):Tr.has(e)?(e===`date`||e===`dates`||e===`time`)&&(r=!0):i.push(e)}return{...n?{bucket:n}:{},rest:i.join(` `),time:r}}var Dr=[{value:`this month`,label:`This month`},{value:`last month`,label:`Last month`},{value:`this quarter`,label:`This quarter`},{value:`last quarter`,label:`Last quarter`},{value:`this year`,label:`This year`},{value:`last year`,label:`Last year`},{value:`all time`,label:`All time`}];function Or(e,t,n){let r=e=>e.replace(/([a-z\d])([A-Z])/g,`$1_$2`).toLowerCase().replace(/[^a-z0-9_]+/g,`_`);return(e===`count`||!t?`number_of_${r(n)}`:e===`sum`?r(t).startsWith(`total`)?r(t):`total_${r(t)}`:`${{avg:`average`,min:`lowest`,max:`highest`}[e]}_${r(t)}`).slice(0,U.maxAliasLength).replace(/_+$/,``)}var kr={eq:`is`,ne:`is not`,gt:`over`,gte:`at least`,lt:`under`,lte:`at most`,contains:`contains`},Ar=/^-?\s*[$€£¥]?\s*-?(\d{1,3}(,\d{3})+|\d+)(\.\d{1,2})?$/;function jr(e){if(typeof e==`number`)return Number.isFinite(e)?Math.round(e*100):null;if(typeof e!=`string`)return null;let t=e.trim();if(!Ar.test(t))return null;let n=Number(t.replace(/[^0-9.-]/g,``));return Number.isFinite(n)?Math.round(n*100):null}var Mr=e=>e.type===`integer`||e.type===`decimal`;function Nr(e,t,n,r=``){let i=t.find(t=>t.id===e.source);if(!i){let e=Sr(t);return e?{ok:!1,question:e.prompt,followUp:e}:$(Cr(t))}let a=Bn(t,i.id),{fields:o}=a,s=i.label,c=e=>o.find(t=>t.name===e)?.label??e;if(e.unreadable?.length)return $(`I could not read ${vr(e.unreadable).replace(/ or ([^,]+)$/,` and $1`)} for the ${s} report. Can you say that again?`);let l=ar(r,n),u=e.measures?.length?e.measures:[{fn:`count`},...i.amountField?[{fn:`sum`,field:i.amountField}]:[]],d=[];for(let[e,t]of u.entries()){if(t.fn===`count`){d.some(e=>e.fn===`count`)||d.push({fn:`count`,as:Or(`count`,void 0,i.id)});continue}let n=t.field??i.amountField,r=n?Q(n,o,e=>t.fn===`min`||t.fn===`max`?Mr(e)||e.type===`datetime`:Mr(e)):void 0;if(!r){let n=o.filter(e=>Mr(e)&&e.name!==`id`);if(!n.length)return $(`${s} have no amounts to total. Should I count them instead?`);let r=[...n.filter(e=>e.name===i.amountField),...n.filter(e=>e.format===`money`&&e.name!==i.amountField),...n.filter(e=>e.format!==`money`)].slice(0,br);return yr({field:`measure`,label:t.fn===`sum`?`Total`:`Amount`,prompt:`Which amount on ${s} should I ${t.fn===`sum`?`total`:`take the ${t.fn} of`}?`,options:r.map(n=>({value:n.name,label:n.label,apply:{measures:u.map((r,i)=>i===e?{fn:t.fn,field:n.name}:r)}}))})}d.push({fn:t.fn,field:r.name,as:Or(t.fn,r.name,i.id)})}let f=e.groupBy,p=e.dateField,m=e.bucket;if(f){let e=Er(f),t=Q(f,o,e=>e.type===`datetime`);if(t)p??=t.name,m??=`month`,f=void 0;else if(e.time){let t=e.rest?Q(e.rest,o,e=>e.type===`datetime`):void 0;(!e.rest||t)&&(t&&(p??=t.name),m??=e.bucket??l.bucket??`month`,f=void 0)}}m??=l.bucket;let h=null;if(e.range){if(h=ir(e.range,n),!h&&!/\ball\s*time\b|\bever\b/i.test(e.range))return yr({field:`period`,label:`Period`,prompt:`Which period should the ${s} report cover?`,options:Dr.map(e=>({...e,apply:{range:e.value,period:void 0}}))})}else e.period&&e.period!==`all_time`?h=ir(e.period,n):e.period||(h=l.range??null);let g;if((m||h)&&(g=p?Q(p,o,e=>e.type===`datetime`):a.defaultTimeField?o.find(e=>e.name===a.defaultTimeField):void 0,!g)){let e=a.timeFields.slice(0,br);return e.length?yr({field:`dateField`,label:`Date`,prompt:`Which date on ${s} should the report use?`,options:e.map(e=>({value:e,label:c(e),apply:{dateField:e}}))}):$(`${s} have no date to group or filter by. Should the report cover all of them?`)}let _=[];if(f){let e=new Set(a.dimensions),t=Q(f,o,t=>e.has(t.name))??Q(f,o,e=>e.type!==`datetime`);if(t)_.push({field:t.name});else if(!(m&&g))return yr(Pr(a,s,c,l.mentionsTime))}m&&g&&_.push({field:g.name,bucket:m});let v=[];h&&g&&(v.push({field:g.name,op:`gte`,value:h.from}),v.push({field:g.name,op:`lt`,value:h.to}));let y=[];for(let t of e.filters??[]){let e=Q(t.field,o);if(!e)return $(`Which field on ${s} should "${t.field}" filter: ${vr(o.map(e=>e.label))}?`);if(e.format===`money`){let n=jr(t.value);if(n===null)return $(`What amount should ${e.label} be compared with?`);v.push({field:e.name,op:t.op,value:n}),y.push(`${e.label} ${kr[t.op]} ${(n/100).toFixed(2)}`)}else v.push({field:e.name,op:t.op,value:t.value}),y.push(`${e.label} ${kr[t.op]} ${String(t.value)}`)}let ee=e.title??[[s,..._.map(e=>e.bucket?`by ${e.bucket}`:`by ${c(e.field).toLowerCase()}`)].join(` `),h?.label??``].filter(Boolean).join(`, `),te=y.join(`; `)||void 0,b=e=>e.measures.map(e=>e.as);try{let e=dn({title:ee,...te?{description:te}:{},source:i.id,dimensions:_,measures:d,filters:v}),t=e.measures.filter(e=>e.fn!==`count`),n=(t[0]??e.measures[0]).as,r=e.dimensions.find(e=>e.bucket),a=e.dimensions.find(e=>!e.bucket);return{ok:!0,spec:dn({...e,sort:a&&!r?[{by:n,direction:`desc`}]:[],chart:e.dimensions.length?{type:r&&!a?`line`:`bar`,x:(a??r)?.as,y:t.length?t.map(e=>e.as):b(e)}:{type:`stat`,y:b(e)}}),source:i}}catch(e){if(e instanceof W)return $(`I could not build that report (${e.message}). What should it show?`);throw e}}function Pr(e,t,n,r){let i=e.defaultTimeField,a=i?[`month`,`week`,`quarter`].map(e=>({value:`${i}:${e}`,label:`${n(i)} by ${e}`,keywords:[`${e}ly`,`date`,`time`,`per`,e],apply:{groupBy:void 0,bucket:e,dateField:i}})):[],o=e.dimensions.map(e=>({value:e,label:n(e),apply:{groupBy:e}})),s=r?[...a,...o]:[...o.slice(0,4),...a.slice(0,1),...o.slice(4),...a.slice(1)];return{field:`groupBy`,label:`Group by`,prompt:`Group ${t} by…`,options:s.slice(0,br)}}function Fr(e,t){return e.code===`invalid_value`?`That value does not fit ${t.label} (${e.message}). What value did you mean?`:e.code===`invalid_operation`?`I cannot use that on ${t.label} (${e.message}). What should the report show instead?`:`I could not build that report (${e.message}). What should it show?`}export{lt as C,pt as S,Lt as _,Nr as a,Et as b,Bn as c,Xn as d,mn as f,Bt as g,Vt as h,Sr as i,dn as l,Ht as m,Fr as n,Cr as o,pn as p,mr as r,W as s,gr as t,ir as u,jt as v,Dt as x,Ot as y};
|